From: nobody <> Date: Mon, 21 Dec 1998 20:06:34 +0000 (+0000) Subject: This commit was manufactured by cvs2svn to create branch 'FSF'. X-Git-Tag: gdb-4_18~456^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=94228bd3ca403b6bad17f96e32db7b8cf2e870c6;p=thirdparty%2Fbinutils-gdb.git This commit was manufactured by cvs2svn to create branch 'FSF'. Sprout from master 1991-11-19 05:16:47 UTC Stu Grossman 'Initial revision' Cherrypick from master 1998-12-21 20:06:33 UTC Elena Zannoni 'Initial revision': readline/INSTALL readline/bind.c readline/config.h.in readline/doc/Makefile.in readline/examples/histexamp.c readline/isearch.c readline/parens.c readline/search.c readline/shell.c readline/support/install.sh readline/support/mkdirs readline/tilde.c readline/tilde.h readline/xmalloc.c Cherrypick from master 1991-05-21 19:55:06 UTC K. Richard Pixley 'Initial revision': readline/Makefile.in readline/configure readline/readline.c Cherrypick from master 1994-01-16 03:39:57 UTC Per Bothner ' Merge in changes from bash-1.13. The most obvious one is': readline/complete.c readline/display.c readline/rldefs.h Delete: .Sanitize DOC.Sanitize DOC.configure INSTALL Makefile.in README.configure SUPPORTED bfd/.Sanitize bfd/COPYING bfd/ChangeLog bfd/Makefile bfd/Makefile.in bfd/TODO bfd/VERSION bfd/aout-encap.c bfd/aout.c bfd/aout32.c bfd/aout64.c bfd/aoutf1.h bfd/aoutx.c bfd/aoutx.h bfd/archive.c bfd/archures.c bfd/archures.h bfd/awkscan bfd/awkscan-ip bfd/awkscan-p bfd/bfd-in.h bfd/bfd.c bfd/bfd.doc bfd/bfd.doc.ps bfd/bfd.texinfo bfd/blins-p bfd/bout.c bfd/cache.c bfd/coff-a29k.c bfd/coff-code.h bfd/coff-i386.c bfd/coff-i960.c bfd/coff-m68k.c bfd/coff-m88k.c bfd/coff-mips.c bfd/coff-rs6000.c bfd/coffcode.h bfd/coffish.h bfd/coffswap.c bfd/config.sub bfd/configure bfd/configure.in bfd/core.c bfd/cplus-dem.c bfd/cpu-a29k.c bfd/cpu-h8300.c bfd/cpu-i386.c bfd/cpu-i960.c bfd/cpu-m88k.c bfd/cpu-rs6000.c bfd/cpu-vax.c bfd/ctor.c bfd/demo64.c bfd/doc/.Sanitize bfd/doc/Makefile bfd/doc/Makefile.in bfd/doc/awkscan bfd/doc/awkscan-ip bfd/doc/awkscan-p bfd/doc/bfd.info bfd/doc/bfd.texinfo bfd/doc/bfdinfo bfd/doc/blins-p bfd/doc/configure.in bfd/doc/exfil1-p bfd/doc/exfil3-p bfd/doc/exfilter bfd/doc/exfilter-p bfd/doc/exfiltst bfd/doc/exmerge bfd/doc/intobfd bfd/doc/mergecom-p bfd/doc/movecom-p bfd/doc/scanit bfd/doc/scanph bfd/doc/sedscript bfd/doc/sedscript-p bfd/doc/startcom-p bfd/doc/tolibbfd bfd/doc/tolibcoff bfd/doc/unPROTO bfd/elf.c bfd/exfilter bfd/exmerge bfd/filemode.c bfd/format.c bfd/host-aout.c bfd/hosts/.Sanitize bfd/hosts/amix.h bfd/hosts/decstation.h bfd/hosts/delta88.h bfd/hosts/dgux.h bfd/hosts/dose.h bfd/hosts/h-m68kv.h bfd/hosts/harris.h bfd/hosts/hp9000.h bfd/hosts/i386mach.h bfd/hosts/i386v.h bfd/hosts/irix3.h bfd/hosts/rs6000.h bfd/hosts/rtbsd.h bfd/hosts/sparc-ll.h bfd/hosts/sparc.h bfd/hosts/sun3.h bfd/hosts/tahoe.h bfd/hosts/ultra3.h bfd/hosts/vaxbsd.h bfd/hosts/vaxult.h bfd/howto.c bfd/i386aout.c bfd/ieee.c bfd/init.c bfd/intobfd bfd/libaout.h bfd/libbfd-in.h bfd/libbfd.c bfd/libbfd.h bfd/libcoff.h bfd/libieee.h bfd/liboasys.h bfd/mergecom-p bfd/misc.c bfd/misc.h bfd/movecom-p bfd/newsos3.c bfd/oasys.c bfd/obstack.c bfd/obstack.h bfd/opncls.c bfd/reloc.c bfd/scanit bfd/scanph bfd/section.c bfd/sedscript bfd/sedscript-p bfd/srec.c bfd/startcom-p bfd/sunos.c bfd/syms.c bfd/targets.c bfd/tolibbfd bfd/tolibcoff bfd/trad-core.c bfd/trad-core.h bfd/unPROTO binutils/.Sanitize binutils/ChangeLog binutils/Makefile.in binutils/README binutils/TODO binutils/alloca.c binutils/am29k-pinsn.c binutils/ar.1 binutils/ar.c binutils/binutils.texi binutils/binutils.texinfo binutils/bucomm.c binutils/config.sub binutils/configure binutils/configure.in binutils/copy.c binutils/cplus-dem.c binutils/filemode.c binutils/gmalloc.c binutils/i960-pinsn.c binutils/is-ranlib.c binutils/is-strip.c binutils/m68k-pinsn.c binutils/maybe-ranlib.c binutils/maybe-strip.c binutils/nm.1 binutils/nm.c binutils/not-ranlib.c binutils/not-strip.c binutils/objdump.1 binutils/objdump.c binutils/ostrip.c binutils/ranlib.1 binutils/ranlib.sh binutils/size.1 binutils/size.c binutils/sparc-pinsn.c binutils/strip.1 binutils/strip.c binutils/version.c config.sub config/.Sanitize config/mh-delta88 config/mh-dgux config/mh-sco config/mh-svr4 config/mh-sysv config/mt-a29k config/mt-ebmon29k configure configure.in gas/.Sanitize gas/.gdbinit gas/COPYING gas/ChangeLog gas/GNUmakefile-host gas/Makefile-intel gas/Makefile.generic gas/Makefile.in gas/Makefile.loic gas/Makefile.old gas/NOTES gas/NOTES.config gas/README gas/README-vms-dbg gas/README.coff gas/README.rich gas/VERSION gas/a.out.gnu.h gas/app.c gas/as.c gas/as.h gas/atof-generic.c gas/bignum-copy.c gas/bignum.h gas/cond.c gas/config.sub gas/config/.Sanitize gas/config/a.out.h gas/config/atof-ieee.c gas/config/atof-vax.c gas/config/coff.gnu.h gas/config/cplus-dem.c gas/config/ebmon29k.mt gas/config/h8300.mt gas/config/h8300hds.mt gas/config/ho-a29k.h gas/config/ho-ansi.h gas/config/ho-cygnus.h gas/config/ho-decstation.h gas/config/ho-generic.h gas/config/ho-hpux.h gas/config/ho-i386.h gas/config/ho-rs6000.h gas/config/ho-sun3.h gas/config/ho-sun386.h gas/config/ho-sun4.h gas/config/ho-sunos.h gas/config/ho-sysv.h gas/config/ho-vax.h gas/config/m68k.mt gas/config/mh-a29k gas/config/mh-cygnus gas/config/mh-i386 gas/config/mips.mt gas/config/obj-aout.c gas/config/obj-aout.h gas/config/obj-bfd-sunos.c gas/config/obj-bfd-sunos.h gas/config/obj-bout.c gas/config/obj-bout.h gas/config/obj-coff.c gas/config/obj-coff.h gas/config/obj-generic.c gas/config/obj-generic.h gas/config/obj-ieee.c gas/config/obj-ieee.h gas/config/ranlib.h gas/config/rs6000.mt gas/config/signame.h gas/config/stab.h gas/config/tc-a29k.c gas/config/tc-a29k.h gas/config/tc-generic.c gas/config/tc-generic.h gas/config/tc-h8300.c gas/config/tc-i386.c gas/config/tc-i386.h gas/config/tc-i860.c gas/config/tc-i860.h gas/config/tc-i960.c gas/config/tc-i960.h gas/config/tc-m68851.h gas/config/tc-m68k.c gas/config/tc-m68k.h gas/config/tc-ns32k.c gas/config/tc-ns32k.h gas/config/tc-rs6000.c gas/config/tc-rs6000.h gas/config/tc-sparc.c gas/config/tc-sparc.h gas/config/tc-vax.c gas/config/tc-vax.h gas/config/te-dpx2.h gas/config/te-generic.h gas/config/te-ic960.h gas/config/te-motor.h gas/config/te-sco386.h gas/config/te-sparc.h gas/config/te-sun3.h gas/config/te-sysv32.h gas/config/te-unisoft.h gas/config/tmake-sun3 gas/config/vax-inst.h gas/config/vms/.Sanitize gas/config/vms/objrecdef.h gas/config/vms/vms-dbg.c gas/config/vms/vms.c gas/configure gas/configure.in gas/configure.was gas/debug.c gas/doc/Makefile gas/doc/a29k-coff.m4 gas/doc/a29k.m4 gas/doc/all.m4 gas/doc/as.texinfo gas/doc/gen.m4 gas/doc/i80386.m4 gas/doc/i960.m4 gas/doc/m680x0.m4 gas/doc/none.m4 gas/doc/pretex.m4 gas/doc/sparc.m4 gas/doc/vax.m4 gas/doc/vintage.m4 gas/expr.c gas/expr.h gas/flonum-const.c gas/flonum-copy.c gas/flonum-mult.c gas/flonum.h gas/frags.c gas/frags.h gas/hash.c gas/hash.h gas/hex-value.c gas/input-file.c gas/input-file.h gas/input-scrub.c gas/link.cmd gas/make-gas.com gas/messages.c gas/obj.h gas/objdump.c gas/obsolete/gdb-blocks.c gas/obsolete/gdb-file.c gas/obsolete/gdb-lines.c gas/obsolete/gdb-symbols.c gas/obsolete/gdb.c gas/output-file.c gas/output-file.h gas/read.c gas/read.h gas/strstr.c gas/struc-symbol.h gas/subsegs.c gas/subsegs.h gas/symbols.c gas/symbols.h gas/tc.h gas/testscripts/doboth gas/testscripts/doobjcmp gas/testscripts/dostriptest gas/testscripts/dotest gas/testscripts/dounsortreloc gas/testscripts/dounsortsymbols gas/ver960.c gas/version.c gas/write.c gas/write.h gas/xmalloc.c gas/xrealloc.c gdb/.Sanitize gdb/.gdbinit gdb/Attic/Makefile.in gdb/COPYING gdb/ChangeLog gdb/ChangeLog-3.x gdb/Convex.notes gdb/Makefile gdb/Makefile.dist gdb/Makefile.in gdb/Makefile.sdir gdb/Makefile.srcdir gdb/Projects gdb/README gdb/TODO gdb/WHATS.NEW gdb/alldeps.mak gdb/alloca.c gdb/altos-xdep.c gdb/am29k-opcode.h gdb/am29k-pinsn.c gdb/am29k-tdep.c gdb/ansidecl.h gdb/arm-convert.s gdb/arm-opcode.h gdb/arm-pinsn.c gdb/arm-tdep.c gdb/arm-xdep.c gdb/blockframe.c gdb/breakpoint.c gdb/breakpoint.h gdb/buildsym.c gdb/buildsym.h gdb/c-exp.y gdb/coffread.c gdb/command.c gdb/command.h gdb/config.gdb gdb/config.status gdb/config.sub gdb/config/.Sanitize gdb/config/3b1.mh gdb/config/3b1.mt gdb/config/a29k-kern.mt gdb/config/a29k.mt gdb/config/altos.mh gdb/config/altos.mt gdb/config/altosgas.mh gdb/config/altosgas.mt gdb/config/am29k gdb/config/amix.mh gdb/config/amix.mt gdb/config/arm.mh gdb/config/arm.mt gdb/config/bigmips.mh gdb/config/bigmips.mt gdb/config/convex.mh gdb/config/convex.mt gdb/config/decstation.mh gdb/config/decstation.mt gdb/config/delta88.mh gdb/config/delta88.mt gdb/config/hp300bsd.mh gdb/config/hp300bsd.mt gdb/config/hp300hpux.mh gdb/config/hp300hpux.mt gdb/config/i386aout.mt gdb/config/i386mach.mh gdb/config/i386sco.mh gdb/config/i386sco.mt gdb/config/i386v-g.mh gdb/config/i386v-g.mt gdb/config/i386v.mh gdb/config/i386v.mt gdb/config/i386v32-g.mh gdb/config/i386v32-g.mt gdb/config/i386v32.mh gdb/config/i386v32.mt gdb/config/i960.mt gdb/config/irix3.mh gdb/config/irix3.mt gdb/config/isi.mh gdb/config/isi.mt gdb/config/littlemips.mh gdb/config/littlemips.mt gdb/config/m88k.mh gdb/config/m88k.mt gdb/config/merlin.mh gdb/config/merlin.mt gdb/config/mh-vax gdb/config/news.mh gdb/config/news.mt gdb/config/news1000.mh gdb/config/news1000.mt gdb/config/nindy960.mt gdb/config/none.mh gdb/config/none.mt gdb/config/np1.mh gdb/config/np1.mt gdb/config/pn.mh gdb/config/pn.mt gdb/config/pyramid.mh gdb/config/pyramid.mt gdb/config/rs6000.mh gdb/config/rs6000.mt gdb/config/rtbsd.mh gdb/config/sun2os3.mh gdb/config/sun2os3.mt gdb/config/sun2os4.mh gdb/config/sun2os4.mt gdb/config/sun3.mh gdb/config/sun3.mt gdb/config/sun386.mh gdb/config/sun386.mt gdb/config/sun3os3.mh gdb/config/sun3os3.mt gdb/config/sun3os4.mh gdb/config/sun3os4.mt gdb/config/sun4.mh gdb/config/sun4.mt gdb/config/sun4os3.mh gdb/config/sun4os3.mt gdb/config/sun4os4.mh gdb/config/sun4os4.mt gdb/config/symmetry.mh gdb/config/symmetry.mt gdb/config/tahoe.mh gdb/config/tahoe.mt gdb/config/ultra3.mh gdb/config/ultra3.mt gdb/config/umax.mh gdb/config/umax.mt gdb/config/vax.mt gdb/config/vxworks68.mt gdb/config/vxworks960.mt gdb/configure gdb/configure.in gdb/convex-opcode.h gdb/convex-pinsn.c gdb/convex-tdep.c gdb/convex-xdep.c gdb/convx-opcode.h gdb/copying.awk gdb/copying.c gdb/core.c gdb/coredep.c gdb/cplus-dem.c gdb/createtags gdb/dbxread.c gdb/defs.h gdb/depend gdb/doc/.Sanitize gdb/doc/Makefile gdb/doc/Makefile.in gdb/doc/all.m4 gdb/doc/amd29k.m4 gdb/doc/configure.in gdb/doc/gdb.alter-m4 gdb/doc/gdb.bugs-m4 gdb/doc/gdb.canned-m4 gdb/doc/gdb.cmds-m4 gdb/doc/gdb.ctl-m4 gdb/doc/gdb.data-m4 gdb/doc/gdb.emacs-m4 gdb/doc/gdb.files-m4 gdb/doc/gdb.gpl-m4 gdb/doc/gdb.install-m4 gdb/doc/gdb.invoc-m4 gdb/doc/gdb.rdln-m4 gdb/doc/gdb.rename-m4 gdb/doc/gdb.run-m4 gdb/doc/gdb.sample-m4 gdb/doc/gdb.src-m4 gdb/doc/gdb.stack-m4 gdb/doc/gdb.stop-m4 gdb/doc/gdb.symb-m4 gdb/doc/gdb.texinfo gdb/doc/gdb.tgts-m4 gdb/doc/gdb.top-m4 gdb/doc/gdbint.texinfo gdb/doc/gdbinv-m.m4 gdb/doc/gdbinv-m.m4.in gdb/doc/gdbinv-s.m4 gdb/doc/gdbinv-s.m4.in gdb/doc/gen.m4 gdb/doc/i80386.m4 gdb/doc/i960.m4 gdb/doc/interim-gdb.texinfo gdb/doc/interim-gdbinv-m.m4 gdb/doc/interim-gdbinv-s.m4 gdb/doc/m680x0.m4 gdb/doc/none.m4 gdb/doc/pretex.m4 gdb/doc/rc-cm.tex gdb/doc/rc-ps.tex gdb/doc/rc-pslong.tex gdb/doc/rdl-apps.texi gdb/doc/refcard.tex gdb/doc/sparc.m4 gdb/doc/threecol.tex gdb/doc/vax.m4 gdb/dwarfread.c gdb/elfread.c gdb/environ.c gdb/environ.h gdb/eval.c gdb/exec.c gdb/expprint.c gdb/expread.tab.c gdb/expread.y gdb/expression.h gdb/findvar.c gdb/frame.h gdb/gdb-int.texinfo gdb/gdbcmd.h gdb/gdbcore.h gdb/getpagesize.h gdb/gmalloc.c gdb/gmalloc.h gdb/gould-pinsn.c gdb/gould-xdep.c gdb/hp300hpux-xdep.c gdb/hp300ux-xdep.c gdb/i386-pinsn.c gdb/i386-tdep.c gdb/i386-xdep.c gdb/i387-tdep.c gdb/i960-pinsn.c gdb/i960-tdep.c gdb/ieee-float.c gdb/ieee-float.h gdb/infcmd.c gdb/inferior.h gdb/inflow.c gdb/infptrace.c gdb/infrun.c gdb/infrun.hacked.c gdb/inftarg.c gdb/kdb-start.c gdb/language.c gdb/language.h gdb/m2-exp.y gdb/m68k-opcode.h gdb/m68k-pinsn.c gdb/m68k-stub.c gdb/m68k-tdep.c gdb/m88k-opcode.h gdb/m88k-pinsn.c gdb/m88k-tdep.c gdb/m88k-xdep.c gdb/mach386-xdep.c gdb/main.c gdb/mcheck.c gdb/mem-break.c gdb/minimon.h gdb/mips-opcode.h gdb/mips-pinsn.c gdb/mips-tdep.c gdb/mips-xdep.c gdb/mipsread.c gdb/mtrace.awk gdb/mtrace.c gdb/munch gdb/news-xdep.c gdb/nindy-tdep.c gdb/np1-opcode.h gdb/ns32k-opcode.h gdb/ns32k-pinsn.c gdb/obstack.c gdb/obstack.h gdb/param-no-tm.h gdb/param.h gdb/parse.c gdb/parser-defs.h gdb/pn-opcode.h gdb/printcmd.c gdb/procfs.c gdb/putenv.c gdb/pyr-opcode.h gdb/pyr-pinsn.c gdb/pyr-tdep.c gdb/pyr-xdep.c gdb/regex.c gdb/regex.h gdb/rem-m68k.shar gdb/rem-multi.shar gdb/remote-adapt.c gdb/remote-eb.c gdb/remote-mm.c gdb/remote-multi.shar gdb/remote-nindy.c gdb/remote-sa.m68k.shar gdb/remote-sa.sparc.c gdb/remote-vx.68.c gdb/remote-vx.c gdb/remote.c gdb/rs6000-pinsn.c gdb/rs6000-tdep.c gdb/rs6000-xdep.c gdb/rs6k-opcode.def gdb/rs6k-opcode.h gdb/saber.suppress gdb/signals.h gdb/signame.c gdb/signame.h gdb/solib.c gdb/source.c gdb/sparc-opcode.h gdb/sparc-pinsn.c gdb/sparc-tdep.c gdb/sparc-xdep.c gdb/stab.def gdb/stack.c gdb/standalone.c gdb/stddef.h gdb/stdlib.h gdb/stuff.c gdb/sun3-xdep.c gdb/sun386-xdep.c gdb/symfile.c gdb/symfile.h gdb/symm-tdep.c gdb/symm-xdep.c gdb/symmetry-tdep.c gdb/symmetry-xdep.c gdb/symmisc.c gdb/symtab.c gdb/symtab.h gdb/tahoe-opcode.h gdb/tahoe-pinsn.c gdb/target.c gdb/target.h gdb/tdesc.c gdb/tdesc.h gdb/terminal.h gdb/tm-29k.h gdb/tm-3b1.h gdb/tm-68k.h gdb/tm-altos.h gdb/tm-altosgas.h gdb/tm-amix.h gdb/tm-arm.h gdb/tm-bigmips.h gdb/tm-convex.h gdb/tm-delta88.h gdb/tm-hp300bsd.h gdb/tm-hp300hpux.h gdb/tm-i386v-g.h gdb/tm-i386v.h gdb/tm-i960.h gdb/tm-irix3.h gdb/tm-isi.h gdb/tm-m88k.h gdb/tm-merlin.h gdb/tm-mips.h gdb/tm-news.h gdb/tm-nindy960.h gdb/tm-np1.h gdb/tm-pn.h gdb/tm-pyr.h gdb/tm-rs6000.h gdb/tm-sparc.h gdb/tm-sun2.h gdb/tm-sun2os4.h gdb/tm-sun3.h gdb/tm-sun386.h gdb/tm-sun3os4.h gdb/tm-sun4os4.h gdb/tm-sunos.h gdb/tm-svr4.h gdb/tm-symmetry.h gdb/tm-tahoe.h gdb/tm-ultra3.h gdb/tm-umax.h gdb/tm-vax.h gdb/tm-vx68.h gdb/tm-vx960.h gdb/tm-vxworks68.h gdb/tm-vxworks960.h gdb/ultra3-xdep.c gdb/umax-xdep.c gdb/utils.c gdb/valarith.c gdb/valops.c gdb/valprint.c gdb/value.h gdb/values.c gdb/vax-opcode.h gdb/vax-pinsn.c gdb/vx-share/.Sanitize gdb/vx-share/dbgRpcLib.h gdb/vx-share/ptrace.h gdb/vx-share/reg.h gdb/vx-share/vxTypes.h gdb/vx-share/vxWorks.h gdb/vx-share/wait.h gdb/vx-share/xdr_ld.c gdb/vx-share/xdr_ld.h gdb/vx-share/xdr_ptrace.c gdb/vx-share/xdr_ptrace.h gdb/vx-share/xdr_rdb.c gdb/vx-share/xdr_rdb.h gdb/vx-share/xdr_regs.c gdb/vx-share/xdr_regs.h gdb/xcoffexec.c gdb/xcoffread.c gdb/xm-3b1.h gdb/xm-altos.h gdb/xm-amix.h gdb/xm-arm.h gdb/xm-bigmips.h gdb/xm-convex.h gdb/xm-delta88.h gdb/xm-hp300bsd.h gdb/xm-hp300hpux.h gdb/xm-i386mach.h gdb/xm-i386sco.h gdb/xm-i386v.h gdb/xm-i386v32.h gdb/xm-irix3.h gdb/xm-isi.h gdb/xm-m68k.h gdb/xm-m88k.h gdb/xm-merlin.h gdb/xm-mips.h gdb/xm-news.h gdb/xm-news1000.h gdb/xm-np1.h gdb/xm-pn.h gdb/xm-pyr.h gdb/xm-rs6000.h gdb/xm-rtbsd.h gdb/xm-sparc.h gdb/xm-sun2.h gdb/xm-sun3.h gdb/xm-sun386.h gdb/xm-sun3os4.h gdb/xm-sun4os4.h gdb/xm-svr4.h gdb/xm-symmetry.h gdb/xm-tahoe.h gdb/xm-ultra3.h gdb/xm-umax.h gdb/xm-vax.h gprof/Makefile gprof/Makefile.in gprof/arcs.c gprof/config/mt-i386 gprof/config/mt-sparc gprof/config/tmake-i386 gprof/config/tmake-sparc gprof/configure gprof/configure.in gprof/dfn.c gprof/gmon.h gprof/gprof.1 gprof/gprof.c gprof/gprof.callg gprof/gprof.flat gprof/gprof.h gprof/hertz.c gprof/i386.c gprof/i386.h gprof/lookup.c gprof/pathnames.h gprof/printgprof.c gprof/printlist.c gprof/sparc.c gprof/sparc.h gprof/t.c gprof/tahoe.c gprof/tahoe.h gprof/vax.c gprof/vax.h include/.Sanitize include/COPYING include/ChangeLog include/a.out.encap.h include/a.out.host.h include/a.out.hp.h include/a.out.sun4.h include/a.out.vax.h include/a29k-opcode.h include/aout64.h include/ar.h include/arm-opcode.h include/bcs88kcoff.h include/bfd.h include/bout.h include/coff-a29k.h include/coff-i386.h include/coff-i960.h include/coff-m68k.h include/coff-m88k.h include/coff-mips.h include/coff-rs6000.h include/convx-opcode.h include/dwarf.h include/elf-common.h include/elf-external.h include/elf-internal.h include/gdbm.h include/getopt.h include/h8300-opcode.h include/i386-opcode.h include/i860-opcode.h include/i960-opcode.h include/ieee.h include/internalcoff.h include/m68k-opcode.h include/m88k-opcode.h include/mips-opcode.h include/np1-opcode.h include/ns32k-opcode.h include/oasys.h include/obstack.h include/pn-opcode.h include/pyr-opcode.h include/ranlib.h include/reloc.h include/sparc-opcode.h include/stab.def include/stab.gnu.h include/sysdep.h include/tahoe-opcode.h include/vax-opcode.h include/wait.h install.texinfo ld/.Sanitize ld/ChangeLog ld/Makefile ld/Makefile.in ld/README ld/config.h ld/config.sub ld/config/.Sanitize ld/config/coff-a29k.mt ld/config/decstation.mh ld/config/delta88.mh ld/config/dgux.mh ld/config/ebmon29k.mt ld/config/h-i386v ld/config/h-m68kv ld/config/hmake-dec3100 ld/config/hmake-dgux ld/config/hmake-rtbsd ld/config/hmake-sun3 ld/config/hmake-sun4 ld/config/hmake-sun4-64 ld/config/i386-aout.mt ld/config/i386v.mt ld/config/m68k.mt ld/config/m68kv.mt ld/config/m88k-bcs.mt ld/config/news.mh ld/config/news.mt ld/config/rtbsd.mh ld/config/sparc-ll.mh ld/config/sparc.mh ld/config/sun3.mh ld/config/sun4.mt ld/config/tmake-coff-a29k ld/config/tmake-m88k-bcs ld/config/tmake-sun4 ld/configure ld/configure.in ld/ebmon29k.sc ld/gld.1 ld/h8300hds.c ld/h8300hds.sc ld/i386aout.c ld/i386aout.sc ld/ld-emul.c ld/ld-gld-Ur.script ld/ld-gld-r.script ld/ld-gld.c ld/ld-gld.script ld/ld-gld68k-Ur.script ld/ld-gld68k-r.script ld/ld-gld68k.c ld/ld-gld68k.script ld/ld-gld960.c ld/ld-gld960.script ld/ld-gldm88kbcs-Ur.script ld/ld-gldm88kbcs-r.script ld/ld-gldm88kbcs.c ld/ld-gldm88kbcs.script ld/ld-lnk960-r.script ld/ld-lnk960.c ld/ld-lnk960.script ld/ld-vanilla.c ld/ld.h ld/ld.tex ld/ld.texinfo ld/ldemul.c ld/ldexp.c ld/ldexp.h ld/ldfile.c ld/ldfile.h ld/ldgld.c ld/ldgld.sc ld/ldgld.script ld/ldgld68k.c ld/ldgld68k.sc ld/ldgld68k.script ld/ldgld68kUr.sc ld/ldgld68kUr.script ld/ldgld68kr.sc ld/ldgld68kr.script ld/ldgld960.c ld/ldgld960.sc ld/ldgld960.script ld/ldgldUr.sc ld/ldgldUr.script ld/ldglda29k.c ld/ldglda29k.sc ld/ldglda29k.script ld/ldglda29kUr.sc ld/ldglda29kUr.script ld/ldglda29kr.sc ld/ldglda29kr.script ld/ldgldi386v.c ld/ldgldi386v.sc ld/ldgldi386vUr.sc ld/ldgldi386vr.sc ld/ldgldm68kv.c ld/ldgldm68kv.sc ld/ldgldm68kvUr.sc ld/ldgldm68kvr.sc ld/ldgldm88kbcs.c ld/ldgldm88kbcs.sc ld/ldgldm88kbcs.script ld/ldgldm88kbcsUr.sc ld/ldgldm88kbcsUr.script ld/ldgldm88kbcsr.sc ld/ldgldm88kbcsr.script ld/ldgldr.sc ld/ldgldr.script ld/ldgram.y ld/ldindr.c ld/ldindr.h ld/ldlang.c ld/ldlang.h ld/ldlex.h ld/ldlex.l ld/ldlnk960.c ld/ldlnk960.sc ld/ldlnk960.script ld/ldlnk960r.sc ld/ldlnk960r.script ld/ldm88k.c ld/ldm88k.sc ld/ldm88kUr.sc ld/ldm88kr.sc ld/ldmain.c ld/ldmain.h ld/ldmisc.c ld/ldmisc.h ld/ldsym.c ld/ldsym.h ld/ldtemplate ld/ldvanilla.c ld/ldver.c ld/ldver.h ld/ldwarn.c ld/ldwarn.h ld/ldwrite.c ld/ldwrite.h ld/mkscript.c ld/news.sc readline/.Sanitize readline/ChangeLog readline/config.sub readline/configure.in readline/doc/Makefile readline/doc/texindex.c readline/examples/Makefile readline/history.texi readline/history.texinfo readline/inc-hist.texi readline/inc-history.texinfo readline/inc-read.texi readline/inc-readline.texinfo readline/readline.texi readline/readline.texinfo readline/sysdep-aix.h readline/sysdep-norm.h --- diff --git a/.Sanitize b/.Sanitize deleted file mode 100644 index 893435a929a..00000000000 --- a/.Sanitize +++ /dev/null @@ -1,115 +0,0 @@ -# .Sanitize for devo. -# $Id$ -# - -# Each directory to survive it's way into a release will need a file -# like this one called "./.Sanitize". All keyword lines must exist, -# and must exist in the order specified by this file. Each directory -# in the tree will be processed, top down, in the following order. - -# Hash started lines like this one are comments and will be deleted -# before anything else is done. Blank lines will also be squashed -# out. - -# The lines between the "Do-first:" line and the "Things-to-keep:" -# line are executed as a /bin/sh shell script before anything else is -# done in this directory. - -Do-first: - -# All files listed between the "Things-to-keep:" line and the -# "Do-last:" line will be kept. All other files will be removed. -# Directories listed in this section will have their own Sanitize -# called. Directories not listed will be removed in their entirety -# with rm -rf. - -Things-to-keep: - -Makefile.in -README -DOC.configure -bison -bfd -binutils -clib -config -config.sub -configure -configure.in -cvs -diff -emacs -gas -gcc -gdb -gdbm -gnulib -grep -include -ld -libiberty -make -prms -rcs -readline -texinfo - -# The lines between the "Do-last:" line and the end of the file -# are executed as a /bin/sh shell script after everything else is -# done. - -Do-last: - -echo Looking for signs of \"v9\"... - -# Don't try to clean directories here, as the 'mv' command will fail. -# Also, grep fails on NFS mounted directories. -if ( echo $* | grep keep\-v9 > /dev/null ) ; then - for i in * ; do - if test ! -d $i && (grep sanitize-v9 $i > /dev/null) ; then - echo Keeping v9 stuff in $i - fi - done -else - for i in * ; do - if test ! -d $i && (grep sanitize-v9 $i > /dev/null) ; then - echo Cleaning the \"v9\" out of $i... - cp $i new - sed '/start\-sanitize\-v9/,/end-\sanitize\-v9/d' < $i > new - if [ -n "${safe}" -a ! -f .Recover/$i ] ; then - mv $i .Recover - fi - mv new $i - fi - done -fi - -echo Looking for signs of \"life\"... - -# Don't try to clean directories here, as the 'mv' command will fail. -# Also, grep fails on NFS mounted directories. -if ( echo $* | grep keep\-life > /dev/null ) ; then - for i in * ; do - if test ! -d $i && (grep sanitize-life $i > /dev/null) ; then - echo Keeping life alive in $i - fi - done -else - for i in * ; do - if test ! -d $i && (grep sanitize-life $i > /dev/null) ; then - echo Beating the \"life\" out of $i... - cp $i new - sed '/start\-sanitize\-life/,/end-\sanitize\-life/d' < $i > new - if [ -n "${safe}" -a ! -f .Recover/$i ] ; then - mv $i .Recover - fi - mv new $i - fi - done -fi - -for i in * ; do - if test ! -d $i && (grep sanitize $i > /dev/null) ; then - echo Some mentions of Sanitize are still left in $i! - fi -done diff --git a/DOC.Sanitize b/DOC.Sanitize deleted file mode 100644 index ce687d6ffd0..00000000000 --- a/DOC.Sanitize +++ /dev/null @@ -1,66 +0,0 @@ - - - The Sanitization Process - - -Usage: - -To sanitize a directory or subtree, foo: - -cd foo ; /usr/unsupported/bin/Sanitize - -and you should be left with source code free of any distribution -restrictions. - - -Configuration: - -Each directory to be kept in a release should have a .Sanitize file in -cvs. See devo/.Sanitize for a more or less self describing template. - -The default action is to remove all files and directories not -explicitly listed in the .Sanitize file as being "Things-to-keep:". -Directories that are kept will have Sanitize called on their own -.Sanitize files. - -For other than default action, there are three hooks. - -The "Do-first:" section of .Sanitize should be a shell script -fragment. It will be sourced by the Sanitize shell script after -verifying that the .Sanitize file looks reasonable but before taking -any other action. The arguments to Sanitize are passed to this -fragment so that you can take conditional action. For an example of -it's use, see devo/gcc/config/.Sanitize. - -If the "Do-first:" section sets the local shell variable -"keep_these_too", the files and/or directories listed there will be -kept in addition to any files listed in "Things-to-keep:". For an -example of it's use, see devo/gcc/config/.Sanitize. - -The "Do-last:" section of .Sanitize should be a shell script fragment. -It will be sourced by Sanitize after all other action is taken for -this directory. This section is intended to be used to strip code out -of source files. For an example of grep'ing out specific lines, see -devo/include/.Sanitize. For an example of sed'ing out sections of -code, see devo/gas/config/.Sanitize. - -Command line options are extremely free form. The Sanitize script -itself only knows about keep-cvs. All arguments to Sanitize are -passed to the "Do-first:" and "Do-last:" fragments. Feel free to add -new options as you see fit so long as you list them here. - -Defined options: - -keep-cvs avoids removing CVS.adm directories. This option is - actually recognized and handled by the Sanitize shell - script. - -keep-v9 avoids removing the v9 stuff. -keep-life avoids removing the life stuff. -keep-cri avoids removing the cray research inc changes to emacs. -for-intel builds a distribution in the style that Intel likes. -for-fsf builds a distribution in the style that the FSF likes. - -test instead of removing dirty files, cache them away in a - .Recover directory -recover intended to undo the effects of a "Sanitize test". diff --git a/DOC.configure b/DOC.configure deleted file mode 100755 index c77813d5db4..00000000000 --- a/DOC.configure +++ /dev/null @@ -1,573 +0,0 @@ - On Configuring Development Tools - - K. Richard Pixley - Cygnus Support - - Last Mod Tue Oct 1 21:20:21 PDT 1991, by rich@cygnus.com - -INTRO ------ - - This document attempts to describe the general concepts behind - configuration of the Cygnus Support release of the GNU Development - Tools. It also discusses common usage. Eventually, FIXME, there - will also be a man page for "configure", an "info" tree, etc. - - -BASICS ------- - -Some Basic Terms: - - There are a lot of terms that are frequently used when discussing - development tools. Most of the common terms have been used for - several different concepts such that their meanings have become - ambiguous to the point of being confusing. Typically, we only - guess at their meanings from context and we frequently guess - wrong. - - This document uses very few terms by comparison. The intent is to - make the concepts as clear as possible in order to convey the - usage and intent of these tools. - - "Programs" run on "machines". Programs are very nearly always - written in "source". Programs are "built" from source. - "Compilation" is a process that is frequently, but not always, - used when building programs. - - -Host Environments: - - In this document, the word "host" refers to the environment in - which this source will be compiled. "host" and "host name" have - nothing to do with the proper name of your host, like "ucbvax", - "prep.ai.mit.edu" or "att.com". Instead they refer to things like - "sun4" and "dec3100". - - Forget for a moment that this particular directory of source is - the source for a development environment. Instead, pretend that - it is the source for a simpler, more mundane, application, say, a - desk calculator. - - Source that can be compiled in more than one environment, - generally needs to be set up for each environment explicitly. - Here we refer to that process as configuration. That is, we - configure the source for a host. - - For example, if we wanted to configure our mythical desk - calculator to compile on a SparcStation, we might configure for - host sun4. With our configuration system: - - cd desk-calculator ; ./configure sun4 - - does the trick. "configure" is a shell script that sets up - Makefiles, subdirectories, and symbolic links appropriate for - compiling the source on a sun4. - - The "host" environment does not necessarily refer to the machine - on which the tools are built. It is possible to provide a sun3 - development environment on a sun4. If we wanted to use a cross - compiler on the sun4 to build a program intended to be run on a - sun3, we would configure the source for sun3. - - cd desk-calculator ; ./configure sun3 - - The fact that we are actually building the program on a sun4 makes - no difference if the sun3 cross compiler presents an environment - that looks like a sun3 from the point of view of the desk - calculator source code. Specifically, the environment is a sun3 - environment if the header files, predefined symbols, and libraries - appear as they do on a sun3. - - Nor does the host environment refer to the the machine on which - the program to be built will run. It is possible to provide a - sun3 emulation environment on a sun4 such that programs built in a - sun3 development environment actually run on the sun4. - - Host environment simply refers to the environment in which the - program will be built from the source. - - -Configuration Time Options: - - Many programs have compile time options. That is, features of the - program that are either compiled into the program or not based on a - choice made by the person who builds the program. We refer to these - as "configuration options". For example, our desk calculator might be - capable of being compiled into a program that either uses infix - notation or postfix as a configuration option. For a sun3, chosing - infix might be: - - ./configure sun3 +notation=infix - - while a sun4 with postfix might be: - - ./configure sun4 +notation=postfix - - If we wanted to build both at the same time, in the same directory - structure, the intermediate pieces used in the build process must - be kept separate. - - ./configure sun4 +subdirs +notation=postfix - ./configure sun3 +subdirs +notation=infix - - will create subdirectories for the intermediate pieces of the sun4 - and sun3 configurations. This is necessary as previous systems - were only capable of one configuration at a time. A second - configuration overwrote the first. We've chosen to retain this - behaviour so the "+subdirs" configuration option is necessary - to get the new behaviour. The order of the arguments doesn't - matter. There should be exactly one argument without a leading - '+' sign and that argument will be assumed to be the host name. - - From here on the examples will assume that you want to build the - tools "in place" and won't show the "+subdirs" option, but - remember that it is available. - - In order to actually install the program, the configuration system - needs to know where you would like the program installed. The - default location is /usr/local. We refer to this location as - $(destdir). All user visible programs will be installed in - $(destdir)/bin. All other programs and files will be installed in - a subdirectory of $(destdir)/lib. - - You can elect to change $(destdir) only as a configuration time - option. - - ./configure sun4 +notation=postfix +destdir=/local - - Will configure the source such that: - - make install - - will put it's programs in /local/bin and /local/lib/gcc. If you - change $(destdir) after building the source, you will need to: - - make clean - - before the change will be propogated properly. This is because - some tools need to know the locations of other tools. - - With these concepts in mind, we can drop the desk calculator and - move on to the application that resides in these directories, - namely, the source to a development environment. - - -SPECIFICS ---------- - - The GNU Development Tools can be built on a wide variety of hosts. - So, of course, they must be configured. Like the last example, - - ./configure sun4 +destdir=/local - ./configure sun3 +destdir=/local - - will configure the source to be built in subdirectories, in order - to keep the intermediate pieces separate, and to be installed in - /local. - - When built with suitable development environments, these will be - native tools. We'll explain the term "native" later. - - -BUILDING DEVELOPMENT ENVIRONMENTS ---------------------------------- - - The Cygnus Support GNU development tools can not only be built - with a number of host development environments, they can also be - configured to create a number of different development - environments on each of those hosts. We refer to a specific - development environment created as a "target". That is, the word - "target" refers to the development environment produced by - compiling this source and installing the resulting programs. - - For the Cygnus Support GNU development tools, the default target - is the same as the host. That is, the development environment - produced is intended to be compatible with the environment used to - build the tools. - - In the example above, we created two configurations, one for sun4 - and one for sun3. The first configuration is expecting to be - built in a sun4 development environment, to create a sun4 - development environment. It doesn't necessarily need to be built - on a sun4 if a sun4 development environment is available - elsewhere. Likewise, if the available sun4 development - environment produces executables intended for something other than - sun4, then the development environment built from this sun4 - configuration will run on something other than a sun4. From the - point of view of the configuration system and the GNU development - tools source, this doesn't matter. What matters is that they will - be built in a sun4 environment. - - Similarly, the second configuration given above is expecting to be - built in a sun3 development environment, to create a sun3 - development environment. - - The development environment produced, is a configuration time - option, just like $(destdir). - - ./configure sun4 +destdir=/local +target=sun3 - ./configure sun3 +destdir=/local +target=sun4 - - In this example, like before, we create two configurations. The - first is intended to be built in a sun4 environment, in - subdirectories, to be installed in /local. The second is intended - to be built in a sun3 environment, in subdirectories, to be - installed in /local. - - Unlike the previous example, the first configuration will produce - a sun3 development environment, perhaps even suitable for building - the second configuration. Likewise, the second configuration will - produce a sun4 development environment, perhaps even suitable for - building the first configuration. - - The development environment used to build these configurations - will determine the machines on which the resulting development - environments can be used. - - -A WALK THROUGH --------------- - -Native Development Environments: - - Let us assume for a moment that you have a sun4 and that with your - sun4 you received a development environment. This development - environment is intended to be run on your sun4 to build programs - that can be run on your sun4. You could, for instance, run this - development environment on your sun4 to build our example desk - calculator program. You could then run the desk calculator - program on your sun4. - - The resulting desk calculator program is referred to as a "native" - program. The development environment itself is composed of native - programs that, when run, build other native programs. Any other - program is referred to as "foreign". Programs intended for other - machines are foreign programs. - - This type of development environment, which is by far the most - common, is refered to as "native". That is, a native development - environment runs on some machine to build programs for that same - machine. The process of using a native development environment to - build native programs is called a "native" build. - - ./configure sun4 - - Will configure this source such that when built in a sun4 - development environment, with a development environment that - builds programs intended to be run on sun4 machines, the programs - built will be native programs and the resulting development - environment will be a native development environment. - - The development system that came with your sun4 is one such - environment. Using it to build the GNU Development Tools is a - very common activity and the resulting development environment is - very popular. - - make all - - will build the tools as configured and will assume that you want - to use the native development environment that came with your - machine. - - Using a development environment to build a development environment - is called "bootstrapping". The Cygnus Support release of the GNU - Development Tools is capable of bootstrapping itself. This is a - very powerful feature that we'll return to later. For now, let's - pretend that you used the native development environment that came - with your sun4 to bootstrap the Cygnus Support release and let's - call the new development environment stage1. - - Why bother? Well, most people find that the Cygnus Support - release builds programs that run faster and take up less space - than the native development environments that came with their - machines. Some people didn't get development environments with - their machines and some people just like using the GNU tools - better than using other tools. - - While you're at it, if the GNU tools produce better programs, maybe - you should use them to build the GNU tools. It's a good idea, so - let's pretend that you do. Let's call the new development - environment stage2. - - So far you've built a development environment, stage1, and you've - used stage1 to build a new, faster and smaller development - environment, stage2, but you haven't run any of the programs that - the GNU tools have built. You really don't yet know if these - tools work. Do you have any programs built with the GNU tools? - Yes, you do. stage2. What does that program do? It builds - programs. Ok, do you have any source handy to build into a - program? Yes, you do. The GNU tools themselves. In fact, if you - use stage2 to build the GNU tools again the resulting programs - should be identical to stage2. Let's pretend that you do and call - the new development environment stage3. - - You've just completed what's called a "three stage boot". You now - have a small, fast, somewhat tested, development environment. - - make bootstrap - - will do a three stage boot across all tools and will compare - stage2 to stage3 and complain if they are not identical. - - Once built, - - make install - - will install the development environment in the default location - or in $(destdir) if you specified an alternate when you - configured. In fact, you can skip the "make all" part and just - "make install" which will make sure that the development - environment is built before attempting to install anything. Even - better, for configurations where host is the same as target, like - this one, "make install" will make sure that a "make bootstrap" is - done before installing anything. - - Any development environment that is not a native development - environment is refered to as a "cross" development environment. - There are many different types of cross development environments - but most fall into one of FIXME basic categories. - - -Emulation Environments: - - The first category of cross development environment is called - "emulation". There are two primary types of emulation, but both - types result in programs that run on the native host. - - The first type is "software emulation". This form of cross - development environment involves a native program that when run on - the native host, is capable of interpreting, and in most aspects - running, a program intended for some other machine. This - technique is typically used when the other machine is either too - expensive, too slow, too fast, or not available, perhaps because - it hasn't yet been built. The native, interpreting program is - called a "software emulator". - - The GNU Development Tools do not currently include any software - emulators. Some do exist and the GNU Development Tools can be - configured to create simple cross development environments for - with these emulators. More on this later. - - The second type of emulation is when source intended for some - other development environment is built into a program intended for - the native host. The concept of universes in operating systems - and hosted operating systems are two such development - environments. - - The Cygnus Support Release of the GNU Development Tools can be - configured for one such emulation at this time. - - ./configure sun4 +ansi - - will configure the source such that when built in a sun4 - development environment the resulting development environment is - capable of building sun4 programs from strictly conforming ANSI - X3J11 C source. Remember that the environment used to build the - tools determines the machine on which this tools will run, so the - resulting programs aren't necessarily intended to run on a sun4, - although they usually are. Also note that the source for the GNU - tools is not strictly conforming ANSI source so this configuration - cannot be used to bootstrap the GNU tools. - - -Simple Cross Environments: - - ./configure sun4 +target=a29k - - will configure the tools such that when compiled in a sun4 - development environment the resulting development environment can - be used to create programs intended for an a29k. Again, this does - not necessarily mean that the new development environment can be - run on a sun4. That would depend on the development environment - used to build these tools. - - Earlier you saw how to configure the tools to build a native - development environment, that is, a development environment that - runs on your sun4 and builds programs for your sun4. Let's - pretend that you use stage3 to build this simple cross - configuration and let's call the new development environment - gcc-a29k. Remember that this is a native build. Gcc-a29k is a - collection of native programs intended to run on your sun4. - That's what stage3 builds, programs for your sun4. Gcc-a29k - represents an a29k development environment that builds programs - intended to run on an a29k. But, remember, gcc-a29k runs on your - sun4. Programs built with gcc-a29k will run on your sun4 only - with the help of an appropriate software emulator. - - Building gcc-a29k is also a bootstrap but of a slightly different - sort. We call gcc-a29k a simple cross environment and using - gcc-a29k to build a program intended for a29k is called "crossing - to" a29k. Simple cross environments are the second category of - cross development environments. - - -Crossing Into Targets: - - ./configure a29k +target=a29k - - will configure the tools such that when compiled in an a29k - development environment, the resulting development environment can - be used to create programs intended for an a29k. Again, this does - not necessarily mean that the new development environment can be - run on an a29k. That would depend on the development environment - used to build these tools. - - If you've been following along this walk through, then you've - already built an a29k environment, namely gcc-a29k. Let's pretend - you use gcc-a29k to build the current configuration. - - Gcc-a29k builds programs intended for the a29k so the new - development environment will be intended for use on an a29k. That - is, this new gcc consists of programs that are foreign to your - sun4. They cannot be run on your sun4. - - The process of building this configuration is another a bootstrap. - This bootstrap is also a cross to a29k. Because this type of - build is both a bootstrap and a cross to a29k, it is sometimes - referred to as a "cross into" a29k. This new development - environment isn't really a cross development environment at all. - It is intended to run on an a29k to produce programs for an a29k. - You'll remember that this makes it, by definition, an a29k native - compiler. "Crossing into" has been introduced here not because it - is a type of cross development environment, but because it is - frequently confused one. The process is "a cross" but the - resulting development environment is a native development - environment. - - You could not have built this configuration with stage3, because - stage3 doesn't provide an a29k environment. Instead it provides a - sun4 environment. - - If you happen to have an a29k lying around, you could now use - this fresh development environment on the a29k to three-stage - these tools all over again. This process would look just like it - did when we built the native sun4 development environment because - we would be building another native development environment, this - one on a29k. - - -The Three Party Cross: - - So far you've seen that our development environment source must be - configured for a specific host and for a specific target. You've - also seen that the resulting development environment depends on - the development environment used in the build process. - - When all four match identically, that is, the configured host, the - configured target, the environment presented by the development - environment used in the build, and the machine on which the - resulting development environment is intended to run, then the new - development environment will be a native development environment. - - When all four match except the configured host, then we can assume - that the development environment used in the build is some form of - library emulation. - - When all four match except for the configured target, then the - resulting development environment will be a simple cross - development environment. - - When all four match except for the host on which the development - environment used in the build runs, the build process is a "cross - into" and the resulting development environment will be native to - some other machine. - - Most of the other permutations do exist in some form, but only one - more is interesting to the current discussion. - - ./configure a29k +target=sun3 - - will configure the tools such that when compiled in an a29k - development environment, the resulting development environment can - be used to create programs intended for a sun3. Again, this does - not necessarily mean that the new development environment can be - run on an a29k. That would depend on the development environment - used to build these tools. - - If you are still following along, then you have two a29k - development environments, the native development environment that - runs on a29k, and the simple cross that runs on your sun4. If you - use the a29k native development environment on the a29k, you will - be doing the same thing we did a while back, namely building a - simple cross from a29k to sun3. Let's pretend that instead, you - use gcc-a29k, the simple cross development environment that runs - on sun4 but produces programs for a29k. - - The resulting development environment will run on a29k because - that's what gcc-a29k builds, a29k programs. This development - environment will produce programs for a sun3 because that is how - it was configured. This means that the resulting development - environment is a simple cross. - - There really isn't a common name for this process because very few - development environments are capable of being configured this - extensively. For the sake of discussion, let's call this process - a "three party cross". - - -FINAL NOTES ------------ - -By "configures", I mean that links, Makefile, .gdbinit, and -config.status are built. Configuration is always done from the source -directory. - -* "./configure name" configures this directory, perhaps recursively, - for a single host+target pair where the host and target are both - "name". If a previous configuration existed, it will be - overwritten. - -* "./configure hostname +target=targetname" configures this directory, - perhaps recursively, for a single host+target pair where the host is - hostname and target is targetname. If a previous configuration - existed, it will be overwritten. - -* "./configure +subdirs hostname +target=targetname" creates a - subdirectories H-hostname and H-hostname/T-targetname and - configures H-hostname/T-targetname. For now, makes should - be done from H-hostname/T-targetname. "./configure +sub name" - works as expected. That is, it creates H-name and - H-name/T-name and configures the latter. - - -Hacking configurations: - -The configure scripts essentially do three things, create -subdirectories if appropriate, build a Makefile, and create links to -files, all based on and tailored to, a specific host+target pair. The -scripts also create a .gdbinit if appropriate but this is not -tailored. - -The Makefile is created by prepending some variable definitions to a -Makefile template called Makefile.in and then inserting host and -target specific Makefile fragments. The variables are set based on -the chosen host+target pair and build style, that is, if you use -subdirectories or not. The host and target specific Makefile may or -may not exist. If fragments - -* Makefiles can be edited directly, but those changes will eventually - be lost. Changes intended to be permanent for a specific host - should be made to the host specific Makefile fragment. This should - be in ./config/hmake-host if it exists. Changes intended to be - permanent for a specific target should be made to the target - specific Makefile fragment. This should be in ./config/tmake-target - if it exists. Changes intended to be permanent for the directory - should be made in Makefile.in. To propogate changes to any of - these, either use "make Makefile" or re-configure from the source - directory. - -* configure can be edited directly, but those changes will eventually - be lost. Changes intended to be permanent for a specific directory - should be made to configure.in. Changes intended to be permanent - for all configure scripts should be made to configure.template. - Propogating changes to configure.in requires the presence of - configure.template which normally resides in the uppermost directory - you received. To propogate changes to either configure.template or - a configure.in, use "configure +template=pathtothetemplate". - This will configure the configure scripts themselves, recursively if - appropriate. - -* "./configure -srcdir=foo" is not supported yet. At the moment, things - will probably be configured correctly only for leaf directories, and - even they will not have paths to libraries set properly. diff --git a/INSTALL b/INSTALL deleted file mode 100644 index 4f5020e89da..00000000000 --- a/INSTALL +++ /dev/null @@ -1,85 +0,0 @@ - - - GNU Development Tools - A Cygnus Support Release - - -This is the procedure for installing the a29k cross compiler on a -sun4. - - -0. Load the tape. - - If you haven't already done so, load the tape with: - - tar xvf /dev/rst8 - - It doesn't really matter where, so long as the hard disk space - is available. The source for the tools will be loaded into - ./devo. - - The installed portion of the tools will take about 4 Mbytes of - disk space. Simply loading the source from tape will require - about 32 Mbytes. Loading the source from tape, building, and - installing the tools will need about 46 Mbytes. - - Once loaded: - - cd devo - -1. Create destdir. - - The default location for all installed files and programs is - /usr/local. We refer to this directory as $(destdir). You - can change $(destdir) only at configuration time. This is - because some tools have hard coded pathnames. - - If you change destdir after the tools are built, you will need - to "make clean" and then rebuild. If you don't understand - this, you should probably be using the defaults for now. - - User visible programs are installed in $(destdir)/bin. All - other files and programs are installed in $(destdir)/lib/gcc. - - If $(destdir) does not already exist, create it now. - -2. Configure the source. - - If you use the default $(destdir): - - configure +host=sun4 a29k - - Otherwise: - - configure +host=sun4 a29k +destdir=yourdestdir - - where "yourdestdir" should be the name of the $(destdir) that - you've chosen. - -3. Build and install the tools. - - Use: - make install - - This will take about 20 minutes on an otherwise unloaded - SparcStation 2 with a quick, sync, SCSI hard disk. - -That's it. You're done. If you don't plan to hack these sources in -the near future, you'll probably want to also: - -4. Remove intermediate object files. - - make clean - - and perhaps even: - - cd .. ; rm -rf devo - - -To use these tools, you will probably want to add $(destdir)/bin to -your path. The tools are named with the standard UNIX(tm) names with -"-a29k" appended so as to avoid conflict with native development -tools. That is, nm-a29k, etc. - -For more information on usage, please refer to {LOTS OF VERY PRETTY -HARD COPY} (sic) that you should have received with your tape. diff --git a/Makefile.in b/Makefile.in deleted file mode 100644 index e6535acf21c..00000000000 --- a/Makefile.in +++ /dev/null @@ -1,280 +0,0 @@ -# -# Makefile for directory with subdirs to build. -# Copyright (C) 1990, 1991 Cygnus Support -# -# 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 -# 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ -# -# Last Mod Wed Nov 13 23:26:23 PST 1991, by rich@cygnus.com -# -# $Id$ - -srcdir = . - -idestdir = /usr/local -ddestdir = $(idestdir) - -SHELL=/bin/sh - -RANLIB = ranlib -AR = ar -AR_FLAGS = cq - -BISON = `if [ -d $(unsubdir)/../bison ] ; \ - then echo \`pwd\`/$(unsubdir)/../bison$(subdir)/bison -y -L \`pwd\`/$(unsubdir)/../bison$(subdir)/ ; \ - else echo yacc ; fi` - -MAKEINFO = `if [ -d $(unsubdir)/../texinfo/C ] ; \ - then echo \`pwd\`/$(unsubdir)/../texinfo/C$(subdir)/makeinfo ; \ - else echo echo ; fi` - -#\`(cd $(srcdir)/bison ; \\`pwd\\`)\` -SUBDIRS = libiberty readline bfd gdb binutils ld gas gcc gnulib clib -OTHERS = - -ALL = all.normal -INSTALL_HEADERS = install-headers -INSTALL_FIXED_INCLUDES = install-fixed-includes - -### for debugging -#GCCVERBOSE=-v - -#### host and target specific makefile fragments come in here. -### - -all: $(ALL) - -all.normal: - $(MAKE) subdir_do DO=all "DODIRS=$(SUBDIRS) $(OTHERS)" - -# this is a bad hack. -all.xclib: all.normal - if [ -d clib ] ; then \ - (cd clib ; $(MAKE)) ; \ - fi - -subdir_do: force - for i in $(DODIRS); do \ - if [ -f $(unsubdir)/$$i/localenv ] ; then \ - if (cd $(unsubdir)/$$i$(subdir); \ - $(MAKE) \ - "against=$(against)" \ - "BISON=$(BISON)" \ - "MAKEINFO=$(MAKEINFO)" \ - $(DO)) ; then true ; \ - else exit 1 ; fi ; \ - else if [ -d $(unsubdir)/$$i ] ; then \ - if (cd $(unsubdir)/$$i$(subdir); \ - $(MAKE) \ - "against=$(against)" \ - "AR=$(AR)" \ - "CC=$(CC)" \ - "AR_FLAGS=$(AR_FLAGS)" \ - "RANLIB=$(RANLIB)" \ - "LOADLIBES=$(LOADLIBES)" \ - "LDFLAGS=$(LDFLAGS)" \ - "BISON=$(BISON)" \ - "MAKEINFO=$(MAKEINFO)" \ - $(DO)) ; then true ; \ - else exit 1 ; fi ; \ - else true ; fi ; \ - fi ; \ - done - - - -bootstrap: - $(MAKE) all - $(MAKE) stage1 - $(MAKE) pass "stagepass=stage1" - $(MAKE) stage2 - $(MAKE) pass "stagepass=stage2" - $(MAKE) comparison - -bootstrap2: - $(MAKE) pass "stagepass=stage1" - $(MAKE) stage2 - $(MAKE) pass "stagepass=stage2" - $(MAKE) comparison - -bootstrap3: - $(MAKE) pass "stagepass=stage2" - $(MAKE) comparison - -pass: - cp $(srcdir)/gcc/gstdarg.h $(unsubdir)/gas$(subdir)/stdarg.h - $(MAKE) subdir_do DO=all "DODIRS=$(SUBDIRS)" \ - "CC=`pwd`/$(unsubdir)/gcc$(subdir)/$(stagepass)/gcc \ - -O $(GCCVERBOSE) \ - -B`pwd`/$(unsubdir)/gcc$(subdir)/$(stagepass)/ \ - -B`pwd`/$(unsubdir)/gas$(subdir)/$(stagepass)/ \ - -B`pwd`/$(unsubdir)/ld$(subdir)/$(stagepass)/" \ - "AR=`pwd`/$(unsubdir)/binutils$(subdir)/$(stagepass)/ar" \ - "LD=`pwd`/$(unsubdir)/gcc$(subdir)/$(stagepass)/gcc $(GCCVERBOSE)" \ - "RANLIB=`pwd`/$(unsubdir)/binutils$(subdir)/$(stagepass)/ranlib" \ - "LOADLIBES=`pwd`/$(unsubdir)/gnulib$(subdir)/$(stagepass)/gnulib.a /lib/libc.a" \ - "LDFLAGS=-nostdlib /lib/crt0.o \ - -L`pwd`/$(unsubdir)/gnulib$(subdir)/$(stagepass)/ \ - -B`pwd`/$(unsubdir)/ld$(subdir)/$(stagepass)/" - - -stage1: - $(MAKE) subdir_do DO=stage1 "DODIRS=$(SUBDIRS)" - -stage2: - $(MAKE) subdir_do DO=stage2 "DODIRS=$(SUBDIRS)" - -stage3: - $(MAKE) subdir_do DO=stage3 "DODIRS=$(SUBDIRS)" - -stage4: - $(MAKE) subdir_do DO=stage4 "DODIRS=$(SUBDIRS)" - -against=stage2 - -comparison:; $(MAKE) subdir_do DO=comparison against=$(against) "DODIRS=$(SUBDIRS)" - -de-stage1:; $(MAKE) subdir_do DO=de-stage1 "DODIRS=$(SUBDIRS)" -de-stage2:; $(MAKE) subdir_do DO=de-stage2 "DODIRS=$(SUBDIRS)" -de-stage3:; $(MAKE) subdir_do DO=de-stage3 "DODIRS=$(SUBDIRS)" -de-stage4:; $(MAKE) subdir_do DO=de-stage4 "DODIRS=$(SUBDIRS)" - -clean: - rm -rf *.a TEMP errs core *.o *~ \#* TAGS *.E - $(MAKE) subdir_do DO=clean "DODIRS=$(SUBDIRS) $(OTHERS)" - -install: install-no-fixincludes $(INSTALL_FIXED_INCLUDES) - -install-no-fixincludes: install-dirs $(INSTALL_HEADERS) - $(MAKE) subdir_do DO=install "DODIRS=$(SUBDIRS) $(OTHERS)" - -# The "else true" stuff is for Ultrix; the shell returns the exit code -# of the "if" command, if no commands are run in the "then" or "else" part, -# causing Make to quit. - -MAKEDIRS= \ - $(ddestdir) \ - $(ddestdir)/bin \ - $(ddestdir)/include \ - $(ddestdir)/lib \ - $(ddestdir)/lib/emacs \ - $(idestdir) \ - $(idestdir)/lib \ - $(idestdir)/info \ - $(idestdir)/doc \ - $(idestdir)/man \ - $(idestdir)/man/man1 \ - $(idestdir)/man/man5 - -install-dirs: force - for i in $(MAKEDIRS) ; do \ - echo Making $$i... ; \ - if [ -d $$i ] ; then true ; else mkdir $$i ; fi ; \ - done - -install-headers: - if [ -d $(unsubdir)/gcc$(subdir) ] ; then \ - (cd $(unsubdir)/gcc$(subdir) ; \ - $(MAKE) install-dir) ; \ - else true; \ - fi - -install-fixed-includes: force - if [ -d $(unsubdir)/gcc$(subdir) ] ; then \ - (cd $(unsubdir)/gcc$(subdir) ; \ - $(MAKE) install-fixed-includes) ; \ - else true; \ - fi - -dir.info: force - gen-info-dir . > dir.info.new - mv -f dir.info.new dir.info - -generate-dir: force - - rm -f menus - for i in `find . -name \*.info -print` ; do \ - echo Frobbing $$i... ; \ - sed -e '1,/START-INFO-DIR-ENTRY/d' \ - -e '/END-INFO-DIR-ENTRY/,$$d' $$i >> menus ; \ - done - -etags tags: TAGS - -TAGS: FORCE - etags `$(MAKE) ls` - -ls: - @echo Makefile - @for i in $(SUBDIRS); \ - do \ - (cd $$i; \ - pwd=`pwd`; \ - wd=`basename $$pwd`; \ - for j in `$(MAKE) ls`; \ - do \ - echo $$wd/$$j; \ - done) \ - done - -force: - -# with the gnu make, this is done automatically. - -Makefile: $(srcdir)/Makefile.in $(host_makefile_frag) $(target_makefile_frag) - $(SHELL) ./config.status - -# -# Build GDB distributions that contain BFD, Include, Libiberty, Readline, etc - -DEVO_SUPPORT= README README.configure Makefile.in configure configure.in \ - config.sub config -GDB_SUPPORT_DIRS= bfd include libiberty readline -GDB_SUPPORT_FILES= $(GDB_SUPPORT_DIRS) texinfo/fsf/texinfo.tex - -setup-dirs: force_update - ./configure sun4 - make clean - ./configure -rm sun4 - chmod og=u `find $(DEVO_SUPPORT) $(GDB_SUPPORT_FILES) -print` - -bfd.ilrt.tar.Z: setup-dirs - rm -f bfd.ilrt.tar.Z - tar cf - $(DEVO_SUPPORT) $(GDB_SUPPORT_FILES) \ - | compress -v >bfd.ilrt.tar.Z - -gdb.tar.Z: setup-dirs - (cd gdb; $(MAKE) -f Makefile.in make-proto-gdb.dir) - $(MAKE) $(MFLAGS) -f Makefile.in make-gdb.tar.Z - -make-gdb.tar.Z: $(DEVO_SUPPORT) $(GDB_SUPPORT_DIRS) gdb texinfo/fsf/texinfo.tex - rm -rf proto-toplev; mkdir proto-toplev - ln -s ../gdb/proto-gdb.dir proto-toplev/gdb - (cd proto-toplev; for i in $(DEVO_SUPPORT) $(GDB_SUPPORT_DIRS); do \ - ln -s ../$$i . ; \ - done) - mkdir proto-toplev/texinfo - mkdir proto-toplev/texinfo/fsf - ln -s ../../../texinfo/fsf/texinfo.tex proto-toplev/texinfo/fsf/ - chmod og=u `find proto-toplev -print` - (VER=`sed Making gdb-$$VER.tar.Z"; \ - ln -s proto-toplev gdb-$$VER; \ - tar cfh - gdb-$$VER \ - | compress -v >gdb-$$VER.tar.Z) - -force_update: - -nothing: - -# end of Makefile.in diff --git a/README.configure b/README.configure deleted file mode 100755 index c77813d5db4..00000000000 --- a/README.configure +++ /dev/null @@ -1,573 +0,0 @@ - On Configuring Development Tools - - K. Richard Pixley - Cygnus Support - - Last Mod Tue Oct 1 21:20:21 PDT 1991, by rich@cygnus.com - -INTRO ------ - - This document attempts to describe the general concepts behind - configuration of the Cygnus Support release of the GNU Development - Tools. It also discusses common usage. Eventually, FIXME, there - will also be a man page for "configure", an "info" tree, etc. - - -BASICS ------- - -Some Basic Terms: - - There are a lot of terms that are frequently used when discussing - development tools. Most of the common terms have been used for - several different concepts such that their meanings have become - ambiguous to the point of being confusing. Typically, we only - guess at their meanings from context and we frequently guess - wrong. - - This document uses very few terms by comparison. The intent is to - make the concepts as clear as possible in order to convey the - usage and intent of these tools. - - "Programs" run on "machines". Programs are very nearly always - written in "source". Programs are "built" from source. - "Compilation" is a process that is frequently, but not always, - used when building programs. - - -Host Environments: - - In this document, the word "host" refers to the environment in - which this source will be compiled. "host" and "host name" have - nothing to do with the proper name of your host, like "ucbvax", - "prep.ai.mit.edu" or "att.com". Instead they refer to things like - "sun4" and "dec3100". - - Forget for a moment that this particular directory of source is - the source for a development environment. Instead, pretend that - it is the source for a simpler, more mundane, application, say, a - desk calculator. - - Source that can be compiled in more than one environment, - generally needs to be set up for each environment explicitly. - Here we refer to that process as configuration. That is, we - configure the source for a host. - - For example, if we wanted to configure our mythical desk - calculator to compile on a SparcStation, we might configure for - host sun4. With our configuration system: - - cd desk-calculator ; ./configure sun4 - - does the trick. "configure" is a shell script that sets up - Makefiles, subdirectories, and symbolic links appropriate for - compiling the source on a sun4. - - The "host" environment does not necessarily refer to the machine - on which the tools are built. It is possible to provide a sun3 - development environment on a sun4. If we wanted to use a cross - compiler on the sun4 to build a program intended to be run on a - sun3, we would configure the source for sun3. - - cd desk-calculator ; ./configure sun3 - - The fact that we are actually building the program on a sun4 makes - no difference if the sun3 cross compiler presents an environment - that looks like a sun3 from the point of view of the desk - calculator source code. Specifically, the environment is a sun3 - environment if the header files, predefined symbols, and libraries - appear as they do on a sun3. - - Nor does the host environment refer to the the machine on which - the program to be built will run. It is possible to provide a - sun3 emulation environment on a sun4 such that programs built in a - sun3 development environment actually run on the sun4. - - Host environment simply refers to the environment in which the - program will be built from the source. - - -Configuration Time Options: - - Many programs have compile time options. That is, features of the - program that are either compiled into the program or not based on a - choice made by the person who builds the program. We refer to these - as "configuration options". For example, our desk calculator might be - capable of being compiled into a program that either uses infix - notation or postfix as a configuration option. For a sun3, chosing - infix might be: - - ./configure sun3 +notation=infix - - while a sun4 with postfix might be: - - ./configure sun4 +notation=postfix - - If we wanted to build both at the same time, in the same directory - structure, the intermediate pieces used in the build process must - be kept separate. - - ./configure sun4 +subdirs +notation=postfix - ./configure sun3 +subdirs +notation=infix - - will create subdirectories for the intermediate pieces of the sun4 - and sun3 configurations. This is necessary as previous systems - were only capable of one configuration at a time. A second - configuration overwrote the first. We've chosen to retain this - behaviour so the "+subdirs" configuration option is necessary - to get the new behaviour. The order of the arguments doesn't - matter. There should be exactly one argument without a leading - '+' sign and that argument will be assumed to be the host name. - - From here on the examples will assume that you want to build the - tools "in place" and won't show the "+subdirs" option, but - remember that it is available. - - In order to actually install the program, the configuration system - needs to know where you would like the program installed. The - default location is /usr/local. We refer to this location as - $(destdir). All user visible programs will be installed in - $(destdir)/bin. All other programs and files will be installed in - a subdirectory of $(destdir)/lib. - - You can elect to change $(destdir) only as a configuration time - option. - - ./configure sun4 +notation=postfix +destdir=/local - - Will configure the source such that: - - make install - - will put it's programs in /local/bin and /local/lib/gcc. If you - change $(destdir) after building the source, you will need to: - - make clean - - before the change will be propogated properly. This is because - some tools need to know the locations of other tools. - - With these concepts in mind, we can drop the desk calculator and - move on to the application that resides in these directories, - namely, the source to a development environment. - - -SPECIFICS ---------- - - The GNU Development Tools can be built on a wide variety of hosts. - So, of course, they must be configured. Like the last example, - - ./configure sun4 +destdir=/local - ./configure sun3 +destdir=/local - - will configure the source to be built in subdirectories, in order - to keep the intermediate pieces separate, and to be installed in - /local. - - When built with suitable development environments, these will be - native tools. We'll explain the term "native" later. - - -BUILDING DEVELOPMENT ENVIRONMENTS ---------------------------------- - - The Cygnus Support GNU development tools can not only be built - with a number of host development environments, they can also be - configured to create a number of different development - environments on each of those hosts. We refer to a specific - development environment created as a "target". That is, the word - "target" refers to the development environment produced by - compiling this source and installing the resulting programs. - - For the Cygnus Support GNU development tools, the default target - is the same as the host. That is, the development environment - produced is intended to be compatible with the environment used to - build the tools. - - In the example above, we created two configurations, one for sun4 - and one for sun3. The first configuration is expecting to be - built in a sun4 development environment, to create a sun4 - development environment. It doesn't necessarily need to be built - on a sun4 if a sun4 development environment is available - elsewhere. Likewise, if the available sun4 development - environment produces executables intended for something other than - sun4, then the development environment built from this sun4 - configuration will run on something other than a sun4. From the - point of view of the configuration system and the GNU development - tools source, this doesn't matter. What matters is that they will - be built in a sun4 environment. - - Similarly, the second configuration given above is expecting to be - built in a sun3 development environment, to create a sun3 - development environment. - - The development environment produced, is a configuration time - option, just like $(destdir). - - ./configure sun4 +destdir=/local +target=sun3 - ./configure sun3 +destdir=/local +target=sun4 - - In this example, like before, we create two configurations. The - first is intended to be built in a sun4 environment, in - subdirectories, to be installed in /local. The second is intended - to be built in a sun3 environment, in subdirectories, to be - installed in /local. - - Unlike the previous example, the first configuration will produce - a sun3 development environment, perhaps even suitable for building - the second configuration. Likewise, the second configuration will - produce a sun4 development environment, perhaps even suitable for - building the first configuration. - - The development environment used to build these configurations - will determine the machines on which the resulting development - environments can be used. - - -A WALK THROUGH --------------- - -Native Development Environments: - - Let us assume for a moment that you have a sun4 and that with your - sun4 you received a development environment. This development - environment is intended to be run on your sun4 to build programs - that can be run on your sun4. You could, for instance, run this - development environment on your sun4 to build our example desk - calculator program. You could then run the desk calculator - program on your sun4. - - The resulting desk calculator program is referred to as a "native" - program. The development environment itself is composed of native - programs that, when run, build other native programs. Any other - program is referred to as "foreign". Programs intended for other - machines are foreign programs. - - This type of development environment, which is by far the most - common, is refered to as "native". That is, a native development - environment runs on some machine to build programs for that same - machine. The process of using a native development environment to - build native programs is called a "native" build. - - ./configure sun4 - - Will configure this source such that when built in a sun4 - development environment, with a development environment that - builds programs intended to be run on sun4 machines, the programs - built will be native programs and the resulting development - environment will be a native development environment. - - The development system that came with your sun4 is one such - environment. Using it to build the GNU Development Tools is a - very common activity and the resulting development environment is - very popular. - - make all - - will build the tools as configured and will assume that you want - to use the native development environment that came with your - machine. - - Using a development environment to build a development environment - is called "bootstrapping". The Cygnus Support release of the GNU - Development Tools is capable of bootstrapping itself. This is a - very powerful feature that we'll return to later. For now, let's - pretend that you used the native development environment that came - with your sun4 to bootstrap the Cygnus Support release and let's - call the new development environment stage1. - - Why bother? Well, most people find that the Cygnus Support - release builds programs that run faster and take up less space - than the native development environments that came with their - machines. Some people didn't get development environments with - their machines and some people just like using the GNU tools - better than using other tools. - - While you're at it, if the GNU tools produce better programs, maybe - you should use them to build the GNU tools. It's a good idea, so - let's pretend that you do. Let's call the new development - environment stage2. - - So far you've built a development environment, stage1, and you've - used stage1 to build a new, faster and smaller development - environment, stage2, but you haven't run any of the programs that - the GNU tools have built. You really don't yet know if these - tools work. Do you have any programs built with the GNU tools? - Yes, you do. stage2. What does that program do? It builds - programs. Ok, do you have any source handy to build into a - program? Yes, you do. The GNU tools themselves. In fact, if you - use stage2 to build the GNU tools again the resulting programs - should be identical to stage2. Let's pretend that you do and call - the new development environment stage3. - - You've just completed what's called a "three stage boot". You now - have a small, fast, somewhat tested, development environment. - - make bootstrap - - will do a three stage boot across all tools and will compare - stage2 to stage3 and complain if they are not identical. - - Once built, - - make install - - will install the development environment in the default location - or in $(destdir) if you specified an alternate when you - configured. In fact, you can skip the "make all" part and just - "make install" which will make sure that the development - environment is built before attempting to install anything. Even - better, for configurations where host is the same as target, like - this one, "make install" will make sure that a "make bootstrap" is - done before installing anything. - - Any development environment that is not a native development - environment is refered to as a "cross" development environment. - There are many different types of cross development environments - but most fall into one of FIXME basic categories. - - -Emulation Environments: - - The first category of cross development environment is called - "emulation". There are two primary types of emulation, but both - types result in programs that run on the native host. - - The first type is "software emulation". This form of cross - development environment involves a native program that when run on - the native host, is capable of interpreting, and in most aspects - running, a program intended for some other machine. This - technique is typically used when the other machine is either too - expensive, too slow, too fast, or not available, perhaps because - it hasn't yet been built. The native, interpreting program is - called a "software emulator". - - The GNU Development Tools do not currently include any software - emulators. Some do exist and the GNU Development Tools can be - configured to create simple cross development environments for - with these emulators. More on this later. - - The second type of emulation is when source intended for some - other development environment is built into a program intended for - the native host. The concept of universes in operating systems - and hosted operating systems are two such development - environments. - - The Cygnus Support Release of the GNU Development Tools can be - configured for one such emulation at this time. - - ./configure sun4 +ansi - - will configure the source such that when built in a sun4 - development environment the resulting development environment is - capable of building sun4 programs from strictly conforming ANSI - X3J11 C source. Remember that the environment used to build the - tools determines the machine on which this tools will run, so the - resulting programs aren't necessarily intended to run on a sun4, - although they usually are. Also note that the source for the GNU - tools is not strictly conforming ANSI source so this configuration - cannot be used to bootstrap the GNU tools. - - -Simple Cross Environments: - - ./configure sun4 +target=a29k - - will configure the tools such that when compiled in a sun4 - development environment the resulting development environment can - be used to create programs intended for an a29k. Again, this does - not necessarily mean that the new development environment can be - run on a sun4. That would depend on the development environment - used to build these tools. - - Earlier you saw how to configure the tools to build a native - development environment, that is, a development environment that - runs on your sun4 and builds programs for your sun4. Let's - pretend that you use stage3 to build this simple cross - configuration and let's call the new development environment - gcc-a29k. Remember that this is a native build. Gcc-a29k is a - collection of native programs intended to run on your sun4. - That's what stage3 builds, programs for your sun4. Gcc-a29k - represents an a29k development environment that builds programs - intended to run on an a29k. But, remember, gcc-a29k runs on your - sun4. Programs built with gcc-a29k will run on your sun4 only - with the help of an appropriate software emulator. - - Building gcc-a29k is also a bootstrap but of a slightly different - sort. We call gcc-a29k a simple cross environment and using - gcc-a29k to build a program intended for a29k is called "crossing - to" a29k. Simple cross environments are the second category of - cross development environments. - - -Crossing Into Targets: - - ./configure a29k +target=a29k - - will configure the tools such that when compiled in an a29k - development environment, the resulting development environment can - be used to create programs intended for an a29k. Again, this does - not necessarily mean that the new development environment can be - run on an a29k. That would depend on the development environment - used to build these tools. - - If you've been following along this walk through, then you've - already built an a29k environment, namely gcc-a29k. Let's pretend - you use gcc-a29k to build the current configuration. - - Gcc-a29k builds programs intended for the a29k so the new - development environment will be intended for use on an a29k. That - is, this new gcc consists of programs that are foreign to your - sun4. They cannot be run on your sun4. - - The process of building this configuration is another a bootstrap. - This bootstrap is also a cross to a29k. Because this type of - build is both a bootstrap and a cross to a29k, it is sometimes - referred to as a "cross into" a29k. This new development - environment isn't really a cross development environment at all. - It is intended to run on an a29k to produce programs for an a29k. - You'll remember that this makes it, by definition, an a29k native - compiler. "Crossing into" has been introduced here not because it - is a type of cross development environment, but because it is - frequently confused one. The process is "a cross" but the - resulting development environment is a native development - environment. - - You could not have built this configuration with stage3, because - stage3 doesn't provide an a29k environment. Instead it provides a - sun4 environment. - - If you happen to have an a29k lying around, you could now use - this fresh development environment on the a29k to three-stage - these tools all over again. This process would look just like it - did when we built the native sun4 development environment because - we would be building another native development environment, this - one on a29k. - - -The Three Party Cross: - - So far you've seen that our development environment source must be - configured for a specific host and for a specific target. You've - also seen that the resulting development environment depends on - the development environment used in the build process. - - When all four match identically, that is, the configured host, the - configured target, the environment presented by the development - environment used in the build, and the machine on which the - resulting development environment is intended to run, then the new - development environment will be a native development environment. - - When all four match except the configured host, then we can assume - that the development environment used in the build is some form of - library emulation. - - When all four match except for the configured target, then the - resulting development environment will be a simple cross - development environment. - - When all four match except for the host on which the development - environment used in the build runs, the build process is a "cross - into" and the resulting development environment will be native to - some other machine. - - Most of the other permutations do exist in some form, but only one - more is interesting to the current discussion. - - ./configure a29k +target=sun3 - - will configure the tools such that when compiled in an a29k - development environment, the resulting development environment can - be used to create programs intended for a sun3. Again, this does - not necessarily mean that the new development environment can be - run on an a29k. That would depend on the development environment - used to build these tools. - - If you are still following along, then you have two a29k - development environments, the native development environment that - runs on a29k, and the simple cross that runs on your sun4. If you - use the a29k native development environment on the a29k, you will - be doing the same thing we did a while back, namely building a - simple cross from a29k to sun3. Let's pretend that instead, you - use gcc-a29k, the simple cross development environment that runs - on sun4 but produces programs for a29k. - - The resulting development environment will run on a29k because - that's what gcc-a29k builds, a29k programs. This development - environment will produce programs for a sun3 because that is how - it was configured. This means that the resulting development - environment is a simple cross. - - There really isn't a common name for this process because very few - development environments are capable of being configured this - extensively. For the sake of discussion, let's call this process - a "three party cross". - - -FINAL NOTES ------------ - -By "configures", I mean that links, Makefile, .gdbinit, and -config.status are built. Configuration is always done from the source -directory. - -* "./configure name" configures this directory, perhaps recursively, - for a single host+target pair where the host and target are both - "name". If a previous configuration existed, it will be - overwritten. - -* "./configure hostname +target=targetname" configures this directory, - perhaps recursively, for a single host+target pair where the host is - hostname and target is targetname. If a previous configuration - existed, it will be overwritten. - -* "./configure +subdirs hostname +target=targetname" creates a - subdirectories H-hostname and H-hostname/T-targetname and - configures H-hostname/T-targetname. For now, makes should - be done from H-hostname/T-targetname. "./configure +sub name" - works as expected. That is, it creates H-name and - H-name/T-name and configures the latter. - - -Hacking configurations: - -The configure scripts essentially do three things, create -subdirectories if appropriate, build a Makefile, and create links to -files, all based on and tailored to, a specific host+target pair. The -scripts also create a .gdbinit if appropriate but this is not -tailored. - -The Makefile is created by prepending some variable definitions to a -Makefile template called Makefile.in and then inserting host and -target specific Makefile fragments. The variables are set based on -the chosen host+target pair and build style, that is, if you use -subdirectories or not. The host and target specific Makefile may or -may not exist. If fragments - -* Makefiles can be edited directly, but those changes will eventually - be lost. Changes intended to be permanent for a specific host - should be made to the host specific Makefile fragment. This should - be in ./config/hmake-host if it exists. Changes intended to be - permanent for a specific target should be made to the target - specific Makefile fragment. This should be in ./config/tmake-target - if it exists. Changes intended to be permanent for the directory - should be made in Makefile.in. To propogate changes to any of - these, either use "make Makefile" or re-configure from the source - directory. - -* configure can be edited directly, but those changes will eventually - be lost. Changes intended to be permanent for a specific directory - should be made to configure.in. Changes intended to be permanent - for all configure scripts should be made to configure.template. - Propogating changes to configure.in requires the presence of - configure.template which normally resides in the uppermost directory - you received. To propogate changes to either configure.template or - a configure.in, use "configure +template=pathtothetemplate". - This will configure the configure scripts themselves, recursively if - appropriate. - -* "./configure -srcdir=foo" is not supported yet. At the moment, things - will probably be configured correctly only for leaf directories, and - even they will not have paths to libraries set properly. diff --git a/SUPPORTED b/SUPPORTED deleted file mode 100644 index 5dfc6dc8558..00000000000 --- a/SUPPORTED +++ /dev/null @@ -1,4 +0,0 @@ -Wed Jun 12 14:43:18 PDT 1991 - -This directory currently supports only sun4 for sun4. - diff --git a/bfd/.Sanitize b/bfd/.Sanitize deleted file mode 100644 index 2fe9536cac8..00000000000 --- a/bfd/.Sanitize +++ /dev/null @@ -1,286 +0,0 @@ -# Sanitize.in for devo. -# $Id$ -# - -# Each directory to survive it's way into a release will need a file -# like this one called "./.Sanitize". All keyword lines must exist, -# and must exist in the order specified by this file. Each directory -# in the tree will be processed, top down, in the following order. - -# Hash started lines like this one are comments and will be deleted -# before anything else is done. Blank lines will also be squashed -# out. - -# The lines between the "Do-first:" line and the "Things-to-keep:" -# line are executed as a /bin/sh shell script before anything else is -# done in this - -Do-first: - -echo Sanitizing `pwd`. - -# All files listed between the "Things-to-keep:" line and the -# "Files-to-sed:" line will be kept. All other files will be removed. -# Directories listed in this section will have their own Sanitize -# called. Directories not listed will be removed in their entirety -# with rm -rf. - -Things-to-keep: -COPYING -doc -ChangeLog -Makefile.in -TODO -VERSION -aout32.c -aout64.c -aoutf1.h -aoutx.h -aout-target.h -archive.c -archures.c -bfd-in.h -bfd.c -bout.c -cache.c -ctor.c -coff-a29k.c -coff-i386.c -coff-i960.c -coff-m68k.c -coff-m88k.c -coff-mips.c -coff-rs6000.c -coffcode.h -config -configure.in -core.c -demo64.c -elf.c -filemode.c -format.c -host-aout.c -hosts -i386aout.c -ieee.c -libaout.h -libbfd-in.h -cpu-a29k.c -cpu-i386.c -cpu-m68k.c -cpu-mips.c -cpu-vax.c -cpu-h8300.c -cpu-i960.c -cpu-m88k.c -cpu-rs6000.c -init.c -cpu-sparc.c -libbfd.c -libbfd.h -libcoff-in.h -libcoff.h -libieee.h -liboasys.h -newsos3.c -oasys.c -opncls.c -reloc.c -section.c -srec.c -sunos.c -syms.c -targets.c -trad-core.c -trad-core.h - -Do-last: - -if ( echo $* | grep keep\-v9 > /dev/null ) ; then - echo Keeping v9 in aoutx.h -else - echo Sanitizing v9 in aoutx.h - rm -f new - while grep -s start-sanitize-v9 aoutx.h ; do - sed -e '/start-sanitize-v9/,/end-sanitize-v9/d' new - if [ -n "${safe}" ] ; then - mv aoutx.h .Recover - else - rm aoutx.h - fi - mv new aoutx.h - done -fi - -echo Done in `pwd`. - -# -# -# $Log$ -# Revision 1.29 1991/11/17 21:38:05 bothner -# * targets.c: Make the default target_vector contain -# just &DEFAULT_VECTOR. This makes executables a lot smaller. -# Old behavior can be gotten by defining ALL_TARGETS. -# * aoutf1.h, demo64.c, i386aout.c, newsos3.c, sunos.c: -# Factored out common code into new file aout-target.h. -# Saves a lot of duplicate code for a.out variants. -# -# Revision 1.28 1991/11/04 00:37:06 steve -# Added ctor.c (I remembered this time) -# -# Revision 1.27 1991/10/25 10:17:41 gnu -# * Rename COFF-related files in `coff-ARCH.c' form. -# coff-a29k.c, coff-i386.c, coff-i960.c, coff-m68k.c, coff-m88k.c, -# coff-mips.c, coff-rs6000.c to be exact. -# -# Revision 1.26 1991/10/25 07:16:59 gnu -# RS/6000 support -# -# Revision 1.25 1991/10/15 07:29:13 bothner -# Add hosts directory. -# -# Revision 1.24 1991/10/08 22:31:51 gnu -# Add i386aout.c -# -# Revision 1.23 1991/10/05 06:16:44 gnu -# howto.c, configure, config.sub gone. -# -# Revision 1.22 1991/10/03 22:23:56 gnu -# Add elf.c -# -# Revision 1.21 1991/10/01 03:55:34 steve -# Insert the incidentals and things I forgot to ci last time, same log message: -# -# Mon Sep 30 15:13:46 1991 Steve Chamberlain (steve at cygnus.com) -# -# * cpu-a29k.c, cpu-i386.c, cpu-m68k.c, cpu-mips.c, cpu-vax.c, -# cpu-h8300.c, cpu-i960.c, cpu-m88k.c, cpu-sparc.c: added. These -# files will eventually contain processor specific bits for bfd, -# like strange relocation information and dis/assembly. So far only -# the H8 has been even partially done. This work also ties in with -# the change in handling architectures. -# -# * amdcoff.c: (a29k_reloc) fix error message. -# -# * aout-f1.h: (choose_reloc_size) now calls bfd_get_arch to -# discover the architecture of the bfd. (sunos4_callback) calls the -# function bfd_set_arch_mach rather than stuffing stuff directly -# into the bfd. (sunos4_write_object_contents), changed names of -# accessor functions. -# -# * aoutx.h: (set_arch_mach) now calls bfd_default_set_arch_mach to -# setup the environment. -# -# * archive.c: (bfd_slurp_coff_armap) coff archives always have the -# headers in big endian format, regardless of the endianess of the -# host or target. -# -# * archures.c: totally changed. Now an architecture is represented -# with a pointer to an info structure rather than an enumerated type -# and a long. The old info is available as two elements in the -# structure. Future enhancements to architecure support will -# involve pointers to methods being placed into the info structure. -# -# * bfd.c: changed the definition of the bfd structure for the new -# architecture stuff. -# -# * bout.c: (b_out_set_arch_mach) changed to use the new -# architecture mechanism. -# -# * coffcode.h: (coff_set_arch_mach, coff_set_flags) changed to use -# the new architecture mechanism. -# -# * configure.in: added h8 stuff. -# -# * ieee.c: too many changes to note. Now ieee files written with -# bfd gas and ld can be read by gld and ieee only linkers and -# simulators. -# -# * libbfd.c, libbfd.h: changed prototype of bfd_write. -# -# * newsos3.c: (newos3_callback) now calls bfd_set_arch_mach rather -# than fixing the structure directly. -# -# * oasys.c: (oasys_object_p) now calls bfd_default_set_arch_mach rather -# than fixing the structure directly. -# -# * opncls.c: (new_bfd) makes sure that bfd_init has been called -# before opening a bfd. -# -# * srec.c: (srec_set_arch_mach) now calls bfd_default_set_arch_mach -# rather than fixing the structure directly. -# -# * targets.c: (target_vector) now by defining SELECT_VECS (perhaps -# in the t/hmake file) a user can select which backends they want -# linked with bfd without changing the source. -# -# * init.c: new, looks after initializing modules. -# -# * howto.c: for future use, will allow an application to work out -# what cookie to use as a handle on a relcoatio howto. -# -# Revision 1.20 1991/09/04 03:59:15 rich -# Added "recover"'ability. -# -# Revision 1.19 1991/09/03 22:21:30 rich -# "recover" aoutx.h -# -# Revision 1.18 1991/08/29 00:35:06 gnu -# paperwork handled for AMD Coff. -# -# Revision 1.17 1991/08/22 20:23:12 steve -# *** empty log message *** -# -# Revision 1.16 1991/08/22 07:31:21 gnu -# New config.sub -# -# Revision 1.15 1991/08/22 07:20:49 gnu -# Improve our Sanity. -# -# Revision 1.14 1991/08/17 00:17:00 steve -# Documentation -# -# Revision 1.13 1991/08/01 14:37:51 steve -# *** empty log message *** -# -# Revision 1.12 1991/08/01 05:33:39 gnu -# Forgot one more place to remove amdcoff.c reference (sigh). -# -# Revision 1.11 1991/08/01 01:27:44 gnu -# Delete CVS.adm from the release! -# -# Revision 1.10 1991/07/31 22:28:30 gnu -# Remove archures.h -# -# Revision 1.9 1991/07/31 17:37:00 gnu -# Remove amdcoff.c (and its name from Makefile.in) by default, because -# its copyright is not yet assigned to FSF. -# -# Revision 1.8 1991/07/31 07:54:31 gnu -# Better sanitize aoutx.h too! -# -# Revision 1.7 1991/07/16 00:39:03 steve -# *** empty log message *** -# -# Revision 1.6 1991/07/16 00:35:56 steve -# *** empty log message *** -# -# Revision 1.5 1991/07/15 23:32:40 steve -# *** empty log message *** -# -# Revision 1.4 1991/07/04 16:52:54 steve -# Now full of documentation. Yum Yum. -# -# Revision 1.3 1991/05/31 11:22:12 gnu -# Remove coff-code.h and liba.out.h, add libaout.h. -# -# Revision 1.2 1991/05/29 02:40:08 gnu -# Fix up .Sanitize file, remove files that are not referenced. -# -# Revision 1.1 1991/05/23 21:14:00 rich -# Initial revision -# -# -# - -# End of file. diff --git a/bfd/COPYING b/bfd/COPYING deleted file mode 100644 index 9a170375811..00000000000 --- a/bfd/COPYING +++ /dev/null @@ -1,249 +0,0 @@ - - GNU GENERAL PUBLIC LICENSE - Version 1, February 1989 - - Copyright (C) 1989 Free Software Foundation, Inc. - 675 Mass Ave, Cambridge, MA 02139, USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The license agreements of most software companies try to keep users -at the mercy of those companies. By contrast, our General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. The -General Public License applies to the Free Software Foundation's -software and to any other program whose authors commit to using it. -You can use it for your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Specifically, the General Public License is designed to make -sure that you have the freedom to give away or sell copies of free -software, that you receive source code or can get it if you want it, -that you can change the software or use pieces of it in new free -programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of a such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must tell them their rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any program or other work which -contains a notice placed by the copyright holder saying it may be -distributed under the terms of this General Public License. The -"Program", below, refers to any such program or work, and a "work based -on the Program" means either the Program or any work containing the -Program or a portion of it, either verbatim or with modifications. Each -licensee is addressed as "you". - - 1. You may copy and distribute verbatim copies of the Program's source -code as you receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice and -disclaimer of warranty; keep intact all the notices that refer to this -General Public License and to the absence of any warranty; and give any -other recipients of the Program a copy of this General Public License -along with the Program. You may charge a fee for the physical act of -transferring a copy. - - 2. You may modify your copy or copies of the Program or any portion of -it, and copy and distribute such modifications under the terms of Paragraph -1 above, provided that you also do the following: - - a) cause the modified files to carry prominent notices stating that - you changed the files and the date of any change; and - - b) cause the whole of any work that you distribute or publish, that - in whole or in part contains the Program or any part thereof, either - with or without modifications, to be licensed at no charge to all - third parties under the terms of this General Public License (except - that you may choose to grant warranty protection to some or all - third parties, at your option). - - c) If the modified program normally reads commands interactively when - run, you must cause it, when started running for such interactive use - in the simplest and most usual way, to print or display an - announcement including an appropriate copyright notice and a notice - that there is no warranty (or else, saying that you provide a - warranty) and that users may redistribute the program under these - conditions, and telling the user how to view a copy of this General - Public License. - - d) You may charge a fee for the physical act of transferring a - copy, and you may at your option offer warranty protection in - exchange for a fee. - -Mere aggregation of another independent work with the Program (or its -derivative) on a volume of a storage or distribution medium does not bring -the other work under the scope of these terms. - - 3. You may copy and distribute the Program (or a portion or derivative of -it, under Paragraph 2) in object code or executable form under the terms of -Paragraphs 1 and 2 above provided that you also do one of the following: - - a) accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of - Paragraphs 1 and 2 above; or, - - b) accompany it with a written offer, valid for at least three - years, to give any third party free (except for a nominal charge - for the cost of distribution) a complete machine-readable copy of the - corresponding source code, to be distributed under the terms of - Paragraphs 1 and 2 above; or, - - c) accompany it with the information you received as to where the - corresponding source code may be obtained. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form alone.) - -Source code for a work means the preferred form of the work for making -modifications to it. For an executable file, complete source code means -all the source code for all modules it contains; but, as a special -exception, it need not include source code for modules which are standard -libraries that accompany the operating system on which the executable -file runs, or for standard header files or definitions files that -accompany that operating system. - - 4. You may not copy, modify, sublicense, distribute or transfer the -Program except as expressly provided under this General Public License. -Any attempt otherwise to copy, modify, sublicense, distribute or transfer -the Program is void, and will automatically terminate your rights to use -the Program under this License. However, parties who have received -copies, or rights to use copies, from you under this General Public -License will not have their licenses terminated so long as such parties -remain in full compliance. - - 5. By copying, distributing or modifying the Program (or any work based -on the Program) you indicate your acceptance of this license to do so, -and all its terms and conditions. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the original -licensor to copy, distribute or modify the Program subject to these -terms and conditions. You may not impose any further restrictions on the -recipients' exercise of the rights granted herein. - - 7. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of the license which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -the license, you may choose any version ever published by the Free Software -Foundation. - - 8. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - Appendix: How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to humanity, the best way to achieve this is to make it -free software which everyone can redistribute and change under these -terms. - - To do so, attach the following notices to the program. It is safest to -attach them to the start of each source file to most effectively convey -the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - - - Copyright (C) 19yy - - 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) 19xx name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the -appropriate parts of the General Public License. Of course, the -commands you use may be called something other than `show w' and `show -c'; they could even be mouse-clicks or menu items--whatever suits your -program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - program `Gnomovision' (a program to direct compilers to make passes - at assemblers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -That's all there is to it! diff --git a/bfd/ChangeLog b/bfd/ChangeLog deleted file mode 100644 index de1e8e69653..00000000000 --- a/bfd/ChangeLog +++ /dev/null @@ -1,1360 +0,0 @@ -Thu Nov 14 19:49:10 1991 Per Bothner (bothner at cygnus.com) - - * aoutx.h (NAME(aout,print_symbol)): Fix thinko. - * syms.c (bfd_stab_names): Turn on new GNU_EXTRA_STABS macro - to include names of N_SETT etc. - -Thu Nov 14 19:11:13 1991 Fred Fish (fnf at cygnus.com) - - * elf.c: Add minimal support for ELF symbol tables. Generates - canonical bfd symbol tables from ELF symbol tables. Change the - name of some functions from bfd_ to elf_. - - * syms.c: Trivial fix to comment to remove a redundant "to". - -Wed Nov 13 17:02:01 1991 John Gilmore (gnu at cygnus.com) - - * coff-{i386,m68k,m88k}.c: Change name of file format to standard - form that GDB recognizes as COFF. - -Wed Nov 13 09:09:41 1991 Steve Chamberlain (sac at cygnus.com) - - * ieee.c (ieee_object_p): cast NULL correctly. - * configure.in: added harris host - - * coff-a29k.c: Lots of changes, most from David Wood. - -Tue Nov 12 07:21:41 1991 John Gilmore (gnu at cygnus.com) - - * coff-m88k.c (coff_write_armap): Just #undef it. - -Mon Nov 11 20:30:18 1991 Steve Chamberlain (sac at cygnus.com) - - * Makefile.in: standardize on MINUS_G to disable debugging - * coff-m88k.c: create coff armaps instead of bsd ones. - * opncls.c (bfd_close_all_done), (bfd_close): Mask out random bits - when calling chmod. - -Mon Nov 11 19:07:32 1991 Fred Fish (fnf at cygnus.com) - - * elf.c: Additions to support ELF format core files. - * config/mh-amix: Add -DHAVE_PROCFS to HDEFINES, since host - has support for /proc (all the include files in particular). - -Mon Nov 11 18:36:47 1991 Per Bothner (bothner at cygnus.com) - - * aoutx.h (NAME(aout,find_nearest_line)): Handle the case - of two N_SO stabs, one for directory, and one for filename. - - * bfd-in.h (print_vma): Factor out duplicate definition. - - Exit a little more gracefully when malloc returns NULL. - * libbfd.c: New function bfd_xmalloc (malloc wrapper). - * opncls.c, syms.c, bout.c, aoutx.h: Replace malloc by bfd_xmalloc. - * libbfd.h: Rre-generated due to libbfd.c update. - -Sat Nov 9 13:45:01 1991 Fred Fish (fnf at cygnus.com) - - * config/mt-m68k-elf: Define DEFAULT_VECTOR as elf_big_vec. - - * elf.c (elf_object_p): Don't try to create a bfd section for - the first ELF section header. It is just a placeholder. - -Sat Nov 9 03:04:26 1991 John Gilmore (gnu at cygnus.com) - - * coff-rs6000.c, config/mh-rs6000: Make it work on archive and - core files, when compiling native. - * hosts/h-rs6000.h: Define FASCIST_FDOPEN for bfd_fdopenr. - - FIXME: The aoutf1.h change below needs to be reversed back - to the way it was. - -Thu Nov 7 11:03:55 1991 Steve Chamberlain (sac at rtl.cygnus.com) - - * coffcode.h: Defined new macros [PUT|GET]LINENO_LNNO for - manipulation of lnno fields in lineno structs in a coff-.h - independent way. Override it in coff-.h to your favourite - number if you don't have a 16bit lnno field. (coff_swap_lineno_in) - (coff_swap_lineno_out): modified to use the new macros. - -Mon Nov 4 11:38:33 1991 Steve Chamberlain (sac at cygnus.com) - - * aoutf1.h (sunos4_callback): Now defaults to 68020 rather than - unknown arch when the magic number doesn't specify the - architecture, since some OSs (eg old sun3s) don't set the number, and - 020 is probably the right answer anyway. - -Sun Nov 3 12:07:08 1991 Per Bothner (bothner at cygnus.com) - - * hosts/h-news.h, hosts/h-rtbsd.h: - Get rid of MISSING_VFPRINTF, since libiberty provides one. - * bfd-in.h (bfd_print_symbol_type_hopw enum): Add new option - bfd_print_symbol_nm, for use by nm. - * aoutx.h (NAME(aout,print_symbol)): Add code for new - bfd_print_symbol_nm option, to print in nm format. - * coffcode.h (coff_print_symbol), ieee.c (ieee_print_symbol) - oasys.c (oasys_print_symbol): Provide stub implementations - for bfd_print_symbol_nm. - * syms.c: New function bfd_decode_symclass, used by nm printer. - New function bfd_stab_name to look up string name of stab code. - -Sat Nov 2 14:26:03 1991 Steve Chamberlain (steve at cygnus.com) - - * Makefile.in: Added ctor.c - * archures.c (bfd_default_arch_struct) added - bfd_default_reloc_type_lookup. - * coffcode.h: removed a load of #if 0ed code. - (coff_compute_file_section_positions): now works out the section - alignment and size correctly in all cases. - (coff_get_symtab): looks for constructor symbols and calls the - right function when they're found. (coff_canonicalize_reloc): - knows when a section is full of constructors and does the right - thing. - * cpu-m88k.c: Added default_reloc_type lookup to the architecture - description. - * libbfd-in.h: (bfd_default_reloc_type_lookup) defun added. - * libcoff.h: removed #if 0ed code - * reloc.c: (bfd_reloc_code_real_type) added BFD_RELOC_CTOR for - arch independent constructor relocation type. - (bfd_reloc_type_lookup): removed the comment "this will go away" - since it won't. (bfd_howto_32): stolen from 88k, this is a 32bit - reloc which is used when BFD_RELOC_CTOR falls through to give a - default 32bit reloc for constructors. - (bfd_default_reloc_type_lookup): added. - * aoutf1.h: fixed SEGMENT_SIZE typo. - -Thu Oct 31 18:23:06 1991 John Gilmore (gnu at cygnus.com) - - * coff-rs6000.c: Change name to "aixcoff-rs6000", to avoid - matching prefix "coff". - * coffcode.h (coff_swap_aux_in, coff_swap_aux_out): Handle - rs/6000 csect records. - -Sun Oct 27 16:56:58 1991 Steve Chamberlain (steve at cygnus.com) - - * coff-m88k.c, targets.c: change name of m88k_bcs to m88kbcs - * configure.in: add motorola delta88 cases - * libbfd.h, libbfd-in.h, archive.c, ieee.c, elf.c, srec.c: fix - write_armap prototype - * libbfd.c: add doc on bfd_write_bigendian_4byte_int - -Fri Oct 25 02:48:19 1991 John Gilmore (gnu at cygnus.com) - - * Rename COFF-related files in `coff-ARCH.c' form. - coff-a29k.c, coff-i386.c, coff-i960.c, coff-m68k.c, coff-m88k.c, - coff-mips.c, coff-rs6000.c to be exact. - - * Makefile.in: Only supply TARGET_DEFAULTS to targets.c, reducing - make output clutter. - * config/mt-*: Ditto. - -Thu Oct 24 22:40:07 1991 John Gilmore (gnu at cygnus.com) - - RS/6000 support, by Metin G. Ozisik, Mimi Phûông-ThÃ¥o Võ, and - John Gilmore. Archive support from Damon A. Permezel. - - * Makefile.in: Add cpu-rs6000.c and rs6000coff.c. - * configure.in: Add rs6000 case. - * targets.c: Add rs6000 vector. - * archures.c: Add rs6000, fix comment on romp. - * bfd-in.h (enum bfd_error): Add no_debug_section error. - * libcoff-in.h (struct coff_tdata): Remove unused string_table. - * bfd.c (bfd_errmsgs): Add no_debug_section error message. - * section.c (bfd_make_section): Return NULL on attempt to create - a section twice. - * coffcode.h (bfd_swap_reloc_in): Handle r_type and r_size. - (bfd_swap_aouthdr_in): Handle lots more members. - (make_a_section_from_file): If section has already been seen, - just return false rather than overwriting it. - (coff_real_object_p): Understand incoming magic numbers. - (coff_set_flags): Understand outgoing magic numbers. - (coff_compute_section_file_positions): outgoing aouthdr magic #. - (build_debug_section): Add fn for reading debug string section. - (get_normalized_symtab): Handle symbol names in debug string section. - Remove unused obj_string_table. - (coff_slurp_symbol_table): Handle rs6000-specific storage classes. - * aoutx.h (translate_from_native_sym_flags, N_SET*): Check for - existing section before making one. - * cpu-rs6000.c: New file. - * rs6000coff.c: New file. - -Thu Oct 24 02:03:24 1991 Fred Fish (fnf at cygnus.com) - - * elf.c: Add partial support for ELF format corefiles. Still needs - support for extracting registers from corefiles. - - * config/t-m68k-elf: Set DEFAULT_VECTOR to elf_big_vec. - - * config/{h-amix,h-dgux,h-irix3,h-ultra3}: For systems where - RANLIB is defined as echo, send the output to /dev/null to help - reduce clutter in the output from doing a make. - -Mon Oct 21 17:48:48 1991 John Gilmore (gnu at cygnus.com) - - * hosts/h-vaxult.h: Remove malloc/free decls covered in stdlib.h. - Fix HOST_PAGE_SIZE and HOST_SEGMENT_SIZE. From David Taylor. - -Mon Oct 21 09:34:11 1991 Steve Chamberlain (steve at rtl.cygnus.com) - - * coffcode.h (coff_compute_section_file_positions): make it pad - section size out if there are alignment restrictions so that the - image will be ok on a system where section positions are worked - out by accumulating sizes rather than from the section headers. - * targets.c (proto write_armap). Changed orl_count to unsigned. - * opncls.c (bfd_close_all_done). Added so that generative - programs like gas can close a bfd without causing bfd confusion. - * libbfd.h (changed becuase of protos) - * amdcoff.c: messed with the way that jmp displacements are - calcualated. This may not yet be totally correct. - * archive.c (coff_write_armap): rewrote the way that ranlibs are - written out. - * coffcode.h (fixup_symbol_value): now doesn't core dump if a non - abs symbol has no section (like a register symbol). - (coff_write_symbol) now zeros auxent before filling it up to help - with sensitive applications. - * libbfd.c (bfd_write_bigendian_4byte_int): added. - -Wed Oct 16 22:58:45 1991 John Gilmore (gnu at cygnus.com) - - * bfd.c: Make sure we don't get a macro strerror(). - * opncls.c (bfd_fdopenr): If FASCIST_FDOPEN, use "r", not "r+". - * trad-core.c (trad_unix_core_file_failing_command): Suppress - attempt to recover command, ifdef NO_CORE_COMMAND. - * hosts/h-tahoe.h: Add FASCIST_FDOPEN and NO_CORE_COMMAND; - revamp HOST_*, etc. - * hosts/h-i386v.h: Use , not , unlike POSIX. - -Wed Oct 16 12:43:49 1991 Per Bothner (bothner at cygnus.com) - - * archive.c (bsd_write_argmap): The size of the ranlib structures - should not include the size field itself. - * aoutx.h, libaout.h (NAME(aout, sizeof_headers)): Use - adata(abfd)->exec_bytes_size field instead of constant macro, - because aoutx.h compiles to a simple .o file shared by - all 32-bits a.out targets. - -Wed Oct 16 11:11:05 1991 John Gilmore (gnu at cygnus.com) - - * configure.in: Allow i386-sco-sysv. - * bout.c: Remove unused i960_align; lint dummy core file handlers. - * cpu-h8300.c: lint. - - * host-aout.c: New strategy. We use common code, include files, - and data structures to handle the file, but set a few parameters - from the host's config file (page size, text start addr, etc). - * libaout.h: Define HP BSD machine types. - * aoutf1.h: Handle reading a.outs with these types. - - * trad-core.c: Pass the u.u_ar0 value as the negative of the - virtual-memory-address of the .reg section. We can't just make a - section for "all the regs and nothing else" because only GDB knows - exactly where the regs are (scattered around the upage and stack). - Clean up memory allocation. Remove big- and little-endian - vectors, replace with single vector; this only runs on the host, - in host byte order. Replace byteswap routines with aborts in case - anyone calls them. - * targets.c: There's only one trad_core_vec now. - * aoutf1.h (sunos_core_file_p): VMA of .reg* now needs to be 0. - -Tue Oct 15 08:29:03 1991 John Gilmore (gnu at cygnus.com) - - * hosts/h-amix.h (free): Fix prototype. - - * aoutx.h: Don't use NULL as an integer, for braindead systems - that declare it as (void *)0. (From Peter Schauer.) - -Mon Oct 14 17:20:47 1991 Per Bothner (bothner at cygnus.com) - - * opncls.c (bfd_fdopenr): Add parentheses to avoid reported - problem with bad Ultrix system headers. - * aoutx.h (NAME(aout,set_section_contents)): Try to handle the - various kinds of alignments for the various kinds of - magic numbers. - -Mon Oct 14 14:23:10 1991 John Gilmore (gnu at cygnus.com) - - * doc/Makefile: Don't assume . is on the path (from James Clark). - -Fri Oct 11 22:45:14 1991 John Gilmore (gnu at cygnus.com) - - * Makefile.in: Avoid Sun Make VPATH bugs. - * targets.c: Declare trad_core vectors extern. - -Fri Oct 11 13:03:02 1991 Per Bothner (bothner at cygnus.com) - - * coffcode.h: Moved ALIGN macro to libbfd.h. Removed i960_align. - * libbfd.h: Moved ALIGN macro here. - * bout.c (b_out_callback): Replace i960_align by align_power. - - * libaout.h (struct aoutdata): Added fields page_size, - segment_size and exec_bytes_size. These help generic code - (in aoutx.h and libaout.h) to figure out where to align - the various segments in a demand paged file. - * libaout.h (WRITE_HEADER): Use new (struct aoutdata) fields - to decide if the exec header counts in a_text (text segment size). - Also, assume D_PAGED flag is set; don't set it here. - * bout.c (b_out_callback): Add initialization of - adata fields page_size, segment_size, and exec_bytes_size. - * host-aout.c (NAME(host_aout, callback) and - NAME(host_aout,mkobject): Ditto. - * i386aout.c (aout386_callback) and new aout386_mkobject): Ditto. - * newos3.c (newsos3_callback) and new newsos_mkobject): Ditto. - * aoutf1.c (sunos4_callback) and new sunos_mkobject): Ditto. - * aoutx.h (NAME(aout,some_aout_object_p)): Don't subtract - EXEC_BYTES_SIZE from the a_test size; this is only appropriate - for some systems (mainly sunos), so do it in the callback instead. - Same routine: Add stuff to the THIS_IS_ONLY_DOCUMENTATION comment. - * aoutx.h (NAME(aout,set_section_contents): Change the way - filepos and size of sections are carried out to support - older styles of demand paged executables. - - -Fri Oct 11 12:33:36 1991 Steve Chamberlain (steve at cygnus.com) - - * bfd-in.h: Added more macros to COFF_SWAP_TABLE. - * bfd.c: Added macros to enable gas to swap coff records. - * coffcode.h: Make the coff_swap_*_out routines return the number - of bytes swapped, and cleaned up their prototypes. - * configure.in: Added ebmon/coff support - * ecoff.c: Changed null definitions of coff_swap_*_out to conform - to new prototypes - * targets.c: Added new entry points for coff swapping - -Fri Oct 11 03:01:52 1991 John Gilmore (gnu at cygnus.com) - - Restructure configuration scheme for bfd, binutils, ld. - - * include/sys/h-*.h: Move to bfd/hosts/h-*.h. - * configure.in: Revise to symlink sysdep.h to hosts/h-xxx.h. - Change some config names to match other dirs. - * *.c: Include bfd.h before sysdep.h, so ansidecl and PROTO() - get defined first. - * Makefile.in: Use -I. to get sysdep.h. Remove refs to - ../include/sysdep.h. - * cpu-i960.c: Strncmp needed a length arg. - * ecoff.c: Don't ever call trad_unix_core_file_p from here. - * i386aout.c: Remove dead N_TXTOFF override. - * trad-core.c: Don't disable the whole file if SUN4_SYS. - * config/: Rename some config files to match up h-*.h names. - Remove all the HOST_SYS definitions from the config files. - * hosts/h-amix.h, h-i386v.h: Define POSIX_UTIME, not USG. - * hosts/h-hp9000.h: Remove USG comment. - * hosts/h-rs6000.h: Include for malloc. - * hosts/h-news.h, h-sparc-64.h: New config files that had - previously been kludged in the file. - -Thu Oct 10 17:54:08 1991 John Gilmore (gnu at cygnus.com) - - * config/*: trad-core support is HOST dependent, not target - dependent. Target config files only set DEFAULT_VECTOR and/or - other vector elements. Exception: when host-aout.c is in use, - in which case we're forced to assume we're native (hp, vax, - tahoe). Rename XDEPFILES to HDEPFILES. - * Makefile.in: Rename XDEPFILES. - * config/h-sun*: Don't force static linking. - * trad-core.c: Document how to use it nowadays. - * i386aout.c, newsos3.c: Clean up. - * i386coff.c: Allow 386 coff files to be used as core files too - (for reading core files from embedded systems). - -Tue Oct 8 15:30:39 1991 John Gilmore (gnu at cygnus.com) - - * Add i386aout.c for a.out support on the i386. - -Tue Oct 8 12:18:54 1991 Roland H. Pesch (pesch at cygnus.com) - - * reloc.c, section.c, syms.c, targets.c: correct info-node - structure in *doc* comments. - doc/Makefile: stop hiding complaints from makeinfo. - -Sun Oct 6 19:10:06 1991 John Gilmore (gnu at cygnus.com) - - * aoutx.h (...some_aout_object_p): Take a third parameter, - the internal_exec struct, and avoid ever looking at an - external_exec. All callers changed to read the entire - external_exec struct, swap and check its magic number, - swap in the whole structure, and pass the swapped-in version to - some_aout_object_p. - * bout.c: Bring into modern era. Use single _object_p routine - for big- aand little-endian. Provide internal and external - exec header structs. Use separate swap-in and swap-out routines. - - * libaout.h: Move struct internal_exec from ../include/aout64.h - to here. Add obj_symbol_entry_size to struct aoutdata. - * aoutx.h (...some_aout_object_p): Set obj_symbol_entry_size. - - * ../include/aout64.h: Change EXTERNAL_LIST_SIZE to - EXTERNAL_NLIST_SIZE. Callers changed. - -Fri Oct 4 18:18:46 1991 John Gilmore (gnu at cygnus.com) - - * bfd.c: Remove strerror() to libiberty. - - * elf.c: Remove elf_set_section_contents, use generic one. Lint. - * libbfd-in.h, libbfd.c: Add bfd_generic_set_section_contents. - * libbfd.c (bfd_generic_{get,set}_section_contents): Check that - last byte of transfer, not first byte, is within the section. - - * host-aout.c: Remove `BSD' archive support. Lint. - - * archures.c: Rename `struct bfd_arch_info_struct' to `struct - bfd_arch_info'. Rename `typedef bfd_arch_info_struct_type' to - `bfd_arch_info_type'. All uses changed. - * reloc.c: Rename `bfd_reloc_status_enum_type' to - `bfd_reloc_status_type'. Rename `bfd_reloc_code_enum_real_type' - to `bfd_reloc_code_real_type'. (This seems to be a misnomer, - it needs a better name.) All uses changed. - * targets.c: Rename `enum target_flavour_enum' to `enum - target_flavour', and remove the `_enum' from all of the enum - values themselves. All uses changed. - - * configure.in, config/h-i386mach: i386 mach host. - * config/t-i386-aout: Use host-aout.c. - - * trad-core.c: Give it its own xvec's to make it independent - of other file formats. - * ecoff.c, host-aout.c: Remove refs to trad-core. - * config/t-dec3100, t-hp300bsd, t-tahoe, t-vax: Define TRAD_CORE. - * targets.c: #ifdef TRAD_CORE, include it in the vector. - -Fri Oct 4 17:38:03 1991 Steve Chamberlain (steve at cygnus.com) - - * reloc.c: Extended NEWHOWTO macro - * ieee.c: Changed the way 8bit pcrel is done - * cpu-h8300.c: got the registers in the right order - -Thu Oct 3 19:39:55 1991 John Gilmore (gnu at cygnus.com) - - * bfd-in.h: enum boolean => enum bfd_boolean for SVR4. Gumby's - prediction is vindicated! - - * bfd-in.h, libbfd-in.h, doc/Makefile, doc/tolibbfd, doc/intobfd: - Remove refs to howto.c, since Steve forgot. - -Thu Oct 3 07:49:21 1991 Steve Chamberlain (steve at cygnus.com) - - * elf.c: took the abort out of set_arch_mach so that objdump -i will - still work. Now allows any architecture/machine to be set. - -Wed Oct 2 13:50:35 1991 Steve Chamberlain (steve at cygnus.com) - - * howto.c deleted and moved code to reloc.c - - * libbfd.h, libbfd-in.h removed $id stuff for real - - * cpu-h8300.c Made it match various different spellings of h8300. - - * archures.c: Took out the first char filter which made it only - look for a cpu/arch match when the first chars of supplied and - tested names were the same. - - * targets.c removed oasys stuff, pending someone to fix the bugs - in it. - - -Tue Oct 1 12:29:44 1991 John Gilmore (gnu at cygnus.com) - - * Makefile.in, configure.in, targets.c, elf.c: Add preliminary - ELF support good enough for GDB. - * configure.in, config/h-amix, config/t-m68k-elf: Handle - m68k-cbm-svr4 host and target. - * config/t-m68k-coff, t-m88k-coff, t-m88k-aout: Make files nonempty - so `diff' and `patch' can cope. - -Tue Oct 1 11:24:31 1991 Steve Chamberlain (steve at cygnus.com) - - * archures.c: removed texinfo error - - * init.c: added texinfo hooks, and removed initialization error - message. - - * libcoff-in.h, libbfd-in.h removed $id field so cvs can merge - without complaints. - -Tue Oct 1 05:02:53 1991 John Gilmore (gnu at cygnus.com) - - * cpu-i960.c: Avoid numerical count of initializers. - - Vax Ultrix changes from David Taylor : - * host-aout.c: Make little-endian vector really little-endian. - * configure.in: Separate vax and tahoe cases, handle ultrix. - * config/t-vax: Add trad-core.o. - * config/h-vaxult: New host system. - -Mon Sep 30 15:13:46 1991 Steve Chamberlain (steve at cygnus.com) - - * bfd-in.h VERSION, change version number to 0.18, this makes a - gap, but now is the same as the linker version number. - - * cpu-a29k.c, cpu-i386.c, cpu-m68k.c, cpu-mips.c, cpu-vax.c, - cpu-h8300.c, cpu-i960.c, cpu-m88k.c, cpu-sparc.c: added. These - files will eventually contain processor specific bits for bfd, - like strange relocation information and dis/assembly. So far only - the H8 has been even partially done. This work also ties in with - the change in handling architectures. - - * amdcoff.c: (a29k_reloc) fix error message. - - * aout-f1.h: (choose_reloc_size) now calls bfd_get_arch to - discover the architecture of the bfd. (sunos4_callback) calls the - function bfd_set_arch_mach rather than stuffing stuff directly - into the bfd. (sunos4_write_object_contents), changed names of - accessor functions. - - * aoutx.h: (set_arch_mach) now calls bfd_default_set_arch_mach to - setup the environment. - - * archive.c: (bfd_slurp_coff_armap) coff archives always have the - headers in big endian format, regardless of the endianess of the - host or target. - - * archures.c: totally changed. Now an architecture is represented - with a pointer to an info structure rather than an enumerated type - and a long. The old info is available as two elements in the - structure. Future enhancements to architecure support will - involve pointers to methods being placed into the info structure. - - * bfd.c: changed the definition of the bfd structure for the new - architecture stuff. - - * bout.c: (b_out_set_arch_mach) changed to use the new - architecture mechanism. - - * coffcode.h: (coff_set_arch_mach, coff_set_flags) changed to use - the new architecture mechanism. - - * configure.in: added h8 stuff. - - * ieee.c: too many changes to note. Now ieee files written with - bfd gas and ld can be read by gld and ieee only linkers and - simulators. - - * libbfd.c, libbfd.h: changed prototype of bfd_write. - - * newsos3.c: (newos3_callback) now calls bfd_set_arch_mach rather - than fixing the structure directly. - - * oasys.c: (oasys_object_p) now calls bfd_default_set_arch_mach rather - than fixing the structure directly. - - * opncls.c: (new_bfd) makes sure that bfd_init has been called - before opening a bfd. - - * srec.c: (srec_set_arch_mach) now calls bfd_default_set_arch_mach - rather than fixing the structure directly. - - * targets.c: (target_vector) now by defining SELECT_VECS (perhaps - in the t/hmake file) a user can select which backends they want - linked with bfd without changing the source. - - * init.c: new, looks after initializing modules. - - * howto.c: for future use, will allow an application to work out - what cookie to use as a handle on a relcoatio howto. - -Mon Sep 30 13:31:15 1991 John Gilmore (gnu at cygnus.com) - - * srec.c: Better error checking, partly from Peter Schauer. - (srec_object_p): Avoid assuming any file that starts with 'S' is - an S-record file! (Check for 3 uppercase-hex digits after it.) - (ISHEX): Define new macro for checking supposedly hex characters. - (pass_over): Treat as EOF any S-record line that: - * doesn't have hex in either size character - * produces a size larger than 0x7F - * has an unrecognized type number - -Thu Sep 26 15:27:29 1991 John Gilmore (gnu at cygnus.com) - - * aoutf1.h, aoutx.h, bout.c, coffcode.h, host-aout.c, oasys.c, - opncls.c: Lint (saber actually). - -Thu Sep 26 11:24:24 1991 Per Bothner (bothner at cygnus.com) - - * libaout.h (WRITE_HEADERS): Set header's a_text field always. - * newsos3.c: Fixed two types: newos3 -> newsos3. - * reloc.c (bfd_perform_relocation): Fix pc-relative relocation - to use correct segment. - -Mon Sep 23 18:24:34 1991 Per Bothner (bothner at cygnus.com) - - * aoutx.h (print_symbol): Handle missing symbol->name. - -Fri Sep 20 12:26:01 1991 Stu Grossman (grossman at cygnus.com) - - * aoutf1.h (swapcore_sparc): Change name of USRSTACK, fix comment - at top of routine. - -Tue Sep 17 17:23:49 1991 Stu Grossman (grossman at cygnus.com) - - * oasys.c, configure.in, config/h-irix3, config/t-irix3: - add sgi/irix support. - -Thu Sep 12 14:29:09 1991 John Gilmore (gnu at cygint.cygnus.com) - - Changes for the AMD 29000 Ultracomputer port from David Wood. - (wood@nyu.edu). - - * opncls.c (bfd_fdopenr): Handle NO_FCNTL. - - * Makefile.in: Make subdirs work by using $(INCDIR) in the - crude dependencies. - - * coffcode.h (coff_real_object_p): Pass information about the - current file's coff symbol format to BFD via the coff_data struct. - (coff_find_nearest_line): obj_icof => coff_data. - (coff_swap_sym_{in,out}): Check that SYMNMLEN == E_SYMNMLEN. - (coff_swap_aux_{in,out}): Check that FILNMLEN == E_FILNMLEN - and DIMNUM == E_DIMNUM. - * configure.in: Handle a29k-*-* hosts, and targets - a29k-*-coff, a29k-*-aout, and a29k-*-sym1. - * libcoff-in.h: Add local_n_btmask, local_n_btshft, - local_n_tmask, local_n_tshift, local_symesz, local_auxesz, - local_linesz to `coff_data' (tdata) struct. - (coff_data, coff_data_type, coff_tdata): Rename struct icofdata. - * config/h-ultra3: Handle a29k-*-* hosts as Ultracomputers. - -Thu Sep 12 14:07:22 1991 Roland H. Pesch (pesch at cygint.cygnus.com) - - * Makefile.in: $(MAKE) for make, $(docdir) for doc - * doc/Makefile: redundant dependencies for Sun-make VPATH bug - -Tue Sep 10 20:34:12 1991 John Gilmore (gnu at cygint.cygnus.com) - - * aoutf1.h (sunos4_core_file_p): Release the right storage in - error case. - (sunos4_core_file_matches_executable_p): Fix header comparison. - * aoutx.h: Avoid shifts of 32 bits, undefined in C. Lint. - * bout.c, icoff.c, ieee.c, libbfd.c, oasys.c: gcc -O -W lint. - -Wed Sep 4 00:44:52 1991 John Gilmore (gnu at cygint.cygnus.com) - - Allow GDB to patch object files. - - * aoutf1.h (sunos_core_file_p): Set SEC_HAS_CONTENTS on all sections. - * trad-core.h (trad_unix_core_file_p): Ditto. - * aoutx.h (aout_set_section_contents): On first output, check - abfd->direction and complain if erroneous. - - * Makefile.in: Add crude dependencies. - -Tue Sep 3 13:46:19 1991 Steve Chamberlain (steve at cygint.cygnus.com) - - * config/* aoutx.h configure* shortened all the h/tmake-xxxx - to h/t-xxxx files so that everything will work on System V. - -Fri Aug 23 13:51:06 1991 John Gilmore (gnu at cygint.cygnus.com) - - * aoutx.h: Add information on host-aout.c and how to configure - to use it, to the manual. - * configure.in: Tix typo. - * ecoff.c: If compiling for DEC3100, use trad_unix core files, - else dummy out the core file support. - * trad-core.c (trad_unix_core_file_p): If HOST_DATA_START_ADDR is - specified, use it to locate the data section. - * coffcode.h (coff_write_symbols): Declare buffer as bfd_bytes - rather than as chars (lint). - -Thu Aug 22 22:20:19 1991 Stu Grossman (grossman at cygint.cygnus.com) - - * aoutx.h, coffcode.h: saberized. - -Thu Aug 22 11:27:06 1991 Roland H. Pesch (pesch at cygint.cygnus.com) - - * bfd.texinfo: some cleanup, reincorporated more intro matter from - bfd.doc - bfd.c, targets.c: minor rewording of doc segments - - -Wed Aug 21 19:13:22 1991 John Gilmore (gnu at cygint.cygnus.com) - - * trad-core.c (trad_unix_core_file_p): Use HOST_TEXT_START_ADDR, - etc, rather than TEXT_START_ADDR. - * host-aout.c: Remove #if 0 around whole thing. - Update to modern (32/64-bit) a.out naming conventions. - Include a large chunk of ../include/a.out.gnu.h to get macros that - are not defined by the system include files. - (host_aout_{32,64}_write_object_contents): Use the WRITE_HEADERS - macro used by the other a.out implementations. - * Makefile.in: Give dependencies to OPTIONAL_BACKENDS. - -Wed Aug 21 14:33:06 1991 Roland H. Pesch (pesch at cygint.cygnus.com) - - * Makefile.in: use targets "bfd.dvi" and "bfd.ps" instead of - texdoc and psdoc; make these depend on generated .texi's - - * scanit, (new) unPROTO: turn PROTO macros into ANSI declarations in - doc - - * bfd.c, reloc.c, syms.c: minor spelling/wording fixes in doc - portions - - * Makefile.in, awkscan-ip, awkscan-p, intobfd, - libbfd.h, libcoff.h, tolibcoff; new bfd-in.h, libbfd-in.h, - libcoff-in.h: (a) use separate files for invariant parts of bfd.h, - libbfd.h, and libcoff.h; (b) in generated parts of same, use less - obtrusive marks indicating .c origins. - - * bfd.texinfo: generalize most references to linker - -Tue Aug 20 15:18:02 1991 Roland H. Pesch (pesch at cygint.cygnus.com) - - * Makefile.in: include core.p in PROTOS (building better bfd.h) - * archures.c: remove empty foo() definition (crept in at vn1.9) - -Mon Aug 19 13:48:22 1991 Roland H. Pesch (pesch at cygint.cygnus.com) - - * bfd.texinfo: use @setchapternewpage on instead of lots of - @page's; minor rephrasing in Introduction. - - * aoutx.h, archive.c, archures.c, bfd.c, bfd.texinfo, cache.c, - coffcode.h, core.c, format.c, ieee.c, libbfd.c, libbfd.h, libcoff.h, - oasys.c, opncls.c, reloc.c, section.c, syms.c, targets.c (documentation - segments): used BFD (caps) more consistently as a name in - discourse, fixed a few other minor typos and uses of fonts - - -Thu Aug 8 16:47:43 1991 Steve Chamberlain (steve at cygint.cygnus.com) - - * coffcode.h: fixed bug where string table size wasn't being swapped. - -Thu Aug 1 16:35:28 1991 Steve Chamberlain (steve at cygint.cygnus.com) - - * section.c: added SEC_CONSTRUCTOR_TEXT|DATA|BSS flags - - * syms.c: added BSF_CONSTRUCTOR, BSF_WARNING and BSF_INDIRECT - flags. (bfd_print_symbol_vandf) now knows what to do with the - above flags. - - * aoutx.h: made translate_from_native_sym_flags and - translate_to_native_sym_flags produce the above flags. - - -Wed Jul 31 09:53:52 1991 John Gilmore (gnu at cygint.cygnus.com) - - * all files: update copyright notices for GPL version 2. - Install header comments and attribute most modules to their - authors. BFD's name is now officially "Binary File Descriptor", - so remove any conflicting pejoratives. - archures.h: Consists solely of comments; remove it. - -Fri Jul 26 18:11:34 1991 Steve Chamberlain (steve at cygint.cygnus.com) - - * Makefile.in, bfd.c: Made it compile again. - -Fri Jul 19 08:17:09 1991 Steve Chamberlain (steve at cygint.cygnus.com) - - * newsos3.c, targets.c, coffcode.h: new patches from David Wood - - -Mon Jul 15 16:27:42 1991 Steve Chamberlain (steve at cygint.cygnus.com) - - * aoutf1.h archive.c bfd.c coffcode.h core.c ecoff.c ieee.c - bfd.texinfo oasys.c opncls.c reloc.c srec.c: More documentation on - lint fixes. - - * amdcoff.c bfd.texinfo Makefile.in : Folded in changes for amd - 29k coff by David Wood (wood@lab.ultra.nyu.edu). - -Thu Jul 4 09:53:16 1991 Steve Chamberlain (steve at cygint.cygnus.com) - - * Everything: created some new files, core.c format.c, reloc.c, - section.c and syms.c to split the functionality a bit better. - Cleaned up the rest of the files a bit, and added some - documentation. - - -Mon Jul 1 13:29:47 1991 David Wood (wood at david.ultra.nya.edu) - - * opncls.c, ../include/sys/h-sun3.h ../include/sys/h-sun4.h: fcntl - really takes 3 arguments, patched code and ammended prototypes. - -Fri Jun 14 13:19:40 1991 Steve Chamberlain (steve at cygint.cygnus.com) - - * ../include/bfd.h (struct bfd_target): Added new field - "align_power_min" which contains the minimum alignment for a - section. This is used in coff_new_section_hook. The field - insertion necessitates an update of all backends.. - - * aoutf1.h jump table field inserted - - * archive.c(snarf_ar_hdr)(bfd_slurp_coff_armap) can now parse dgux style extended - filenames too. - - * bout.c(b_out_squirt_out_relocs) fix to assertion tests. Jump - table field inserted. - - * coffcode.h(just about everything) Now patches up symbol tables - using a different mechanism. The Intel major bug has been fixed, - and the linker can self host on the Aviion and be debugged with - gdb. - - * ecoff.c: new include and jump table patch, i386coff.c: new - include and jump table patch, icoff.c: new include and jump table - patch, ieee.c: can now read archives containing ieee modules., - libcoff.h: added (combined_entry_type), libieee.h: uped max - sections to 20, m68kcoff.c: new include and jump table patch, - m88kbcs.c: new include and jump table patch, oasys.c: various bugs - fixed. opncls.c: added bfd_alloc_grow and bfd_alloc_finish. - srec.c: jump table patch. trad-code.c fixed #IF typeo - -Fri Jun 7 12:35:46 1991 Sean Fagan (sef at cygint.cygnus.com) - - * coffcode.h (coff_swap_aux_in): added else case to deal with - filenames less than 9 characters. - - -Thu Jun 6 18:27:38 1991 Steve Chamberlain (steve at cygint.cygnus.com) - - * ../include/oasys.h oasys.c (oasys_archive_p): fixed so it works - - * srec.c: now allows any number of sections to be created in a - file. Outputs addresses of the right length. - -Thu May 30 15:30:10 1991 Steve Chamberlain (steve at cygint.cygnus.com) - - * bfd.c (bfd_check_format): Fixed problem where when a defaulted - target didn't match, the format got set to the attempted match, - breaking a future test. - - *../include/i386coff.h : fixed typo in type field with size - - * i386coff.c icoff.c m88k-bcs.c ecoff.c ../include/bfd.h : Added - support in the jump table for the swapping routines exported to - gdb. Now gdb works with the 386. - -Tue May 28 17:21:43 1991 John Gilmore (gnu at cygint.cygnus.com) - - * Merge in changes from gdb-3.95 release. - Makefile.in: Allow hmake and tmake files to add OFILES. - aoutf1.h: - bfd.c: support specific targets as well as searching. When - searching, take default target in preference to others. - bfd.doc: typos - ieee.c, oasys.c: Avoid using the "tdata" macros left of assignment. - liba.out.h: Don't hard-code file offsets; use N_ macros for them. - libbfd.h: Support specific targets as well as searching. - opncls.c: Support specific targets as well as searching. - targets.c: Search is short-circuited if default target matches. - liboasys.c, libieee.c: Undo bothner changes that make macros - work to the left of assignment, but which depend on the - representations of different pointer types being the same. - -Fri May 24 18:56:52 1991 Steve Chamberlain (steve at cygint.cygnus.com) - - * i386coff.c: created. - * coffcode.h: added support for 386. - * Makefile.in: added support for 386. - * ../include/i386coff.h: created - -Wed May 22 07:26:38 1991 Steve Chamberlain (steve at cygint.cygnus.com) - - * coffcode.h: removed all put_x_ - * libbfd.c: Changed #ifdef __GNUC__ to #ifdef HOST_64_BIT, Added - DEFUNS - - -Tue May 21 08:58:58 1991 Steve Chamberlain (steve at cygint.cygnus.com) - (bothner) - * opncls.c: Changed obstack_chunk_alloc use xmalloc - -Mon May 20 17:12:17 1991 Steve Chamberlain (steve at cygint.cygnus.com) - - * everything: Removed sysdep.h from bfd.h and put back into files - from which it was split out. Now 64 bit version is built with a - -DHOST_64_BIT="long long" on the compile line. - - -Fri May 17 19:35:26 1991 Steve Chamberlain (steve at cygint.cygnus.com) - - Changed all the [get|put][name] routines to use [get|put]_[size - in bytes]. - - Put in support for 64 bit work. Now two versions of bfd may be - generated, according to the state of TARGET_64_BIT, one which is - 32 bit only, and one which is 64/32 bits. - Created new back end 'demo64' to test 64 bit functionality. - - Renamed some files to work on DOS. - - * archive.c: lint * bfd.c: prototypes and lint. * ecoff.c: added - 64bit transfer * icoff.c: added 64bit transfer * ieee.c: name - chage, 64 bit transfer. * liba.out.h: Split out common code from - sunos and newsos into liba.out. Name changes and prototype mods. * - libbfd.c: lint and prototypes, extra 64bit swaps. * libbfd.h: - prototypes for new functions. * libcoff.h: lint * libieee.h: make - work on DOS * liboasys.h: make work on DOS * m88k-bcs.c: Name - change and 64bit stuff.* newsos3.c: common code removed, new jump - table. * oasys.c: Name change * opncls.c: Portability fixes * - srec.c: Name changes * sunos.c: Removed comon code. * targets.c: - Added demo * aout32, aout64.c include aoutx.h * bout.c: used to - be called b.out.c * coffcode.h: used to be called coff-code.h, now - 64bit ized. * demo64.c: 64 bit a.out back end - - - - - -Thu May 16 16:02:07 1991 Steve Chamberlain (steve at cygint.cygnus.com) - from bothner - * libieee.h: Make ieee_data and ieee_ar_data macros usable - on LHS of assignment, even when using old compilers. - * liboasys.h: Ditto for oasys_data and oasys_ar_data. - * m68kcoff.c: Add enum-to-int casts to accomodate old compilers. - * newsos3.c: Fix definitions of SEGMENT_SIZE and TEXT_START_ADDR. - * opncls.c: Define S_IXUSR, S_IXGRP, S_IXOTH if undefined. - * targets.c: Add declaration of newsos3_vec. - - -Mon May 13 10:03:29 1991 Steve Chamberlain (steve at cygint.cygnus.com) - - * aout.c: fixxed some of the problems with filepos calculation. - (swap_ext_reloc): fixed problem with creation of relocs. - (aout_set_section_contents): fixed filepos problem - - * coff-code.h: (swap_filehdr_in, swap_filehdr_out) add. - (swap_filehdr) delete. Changed all the usage of bfd_h_put_x. - (swap_aouthdr_in, swap_aouthdr_out) add. (swap_aouthdr) delete. - (coff_real_object_p) cleaned up, added MIPS. (coff_object_p) - cleaned up. (coff_write_object_contents) cleaned up. - - * ecoff.c: Totally different. Now supports ecoff fully. - - * icoff.c: fixed problems in relocation callout. - - * libcoff.h: (struct icofdata) removed hdr structure from tdata. - - * m68kcoff.c: updated target vector. - - * sunos.c: (choose_reloc_size) added: (sunos4_callback) calls - choose_reloc_size. (sunos4_write_object_contents) now calls - choose_reloc_size so outputs relocs correctly, also calculates the - size of the sections correctly. - - - -Fri May 10 16:58:53 1991 John Gilmore (gnu at cygint.cygnus.com) - - Merge Per Bothner's changes to modularize BFD a.out a bit. - - * libbfd.h, libbfd.c (bfd_generic_get_section_contents): Add. - * ieee.c: Cast enums to int before comparing them, for brain- - dead compilers. - * coff-code.h: Remove coff_get_section_contents, and use the - generic one instead. - - * aout.c: Derive new module from sunos.c, containing generic - support code for all kinds of a.out files. - - * sunos.c: Remove all code that goes in aout.c. Split out - machine dependent followup in sunos4_object_p into - sunos4_callback. Use JUMP_TABLE(aout) for the transver vector, - and redefine only the names we CHANGE, not all the names. Drop - the little-endian vector, and rename the vector as sunos4 rather - than generic. - - * b.out.c: Use aout.c routines for most of the work. Slight - changes for the new regime. Remove close_and_cleanup and - get_section_contents in favor of generics. New transfer vector - regime. - - * newsos.c: New support for Sony NEWS, another a.out format. - - * ecoff.c: Remove close_and_cleanup. New tvec regime. - * icoff.c, m88k-bcs.c: Add write_contents to tvec. - * ieee.c, oasys.c: Remove close_and_cleanup, add write_contents - to tvec. - * opncls.c (bfd_close): Call format-dependent write_contents - routine, if writing, before calling target-dependent - close_and_cleanup routine (which is now always generic, I think). - * srec.c: Use bfd_alloc instead of malloc. Remove - close_and_cleanup and move code from it to - srec_write_object_contents. Add write_contents to tvec. - * targets.c: Remove a.out little vector, replace a.out big - vector with SunOS vector. FIXME: Need Vax support again now. - - * libbfd.h: Add write_contents format-dependent-vector to the - bfd_target vector. Supply a generic close_and_cleanup routine. - * liba.out.h: Handle the new aout.c split. Add prototypes for - all routines defined in aout.c. Rename "sunos" things to "aout" - things. Add a few fields where needed for various formats. - * Makefile.in: Add aout.c and newsos.c. - - * archive.c, ieee.c, oasys.c: Lint. - -Fri May 10 12:34:48 1991 Steve Chamberlain (steve at cygint.cygnus.com) - - * ../include/bfd.h - changed forward declaration struct stat; to reduce warnings. Changed - comment on bfd_h__x. - - * ../include/m68kcoff.h, ../include/intel-coff.h, - ../include/m88k-bcs.h - Now there are two incarnations of relocs, linenos and syments. One for - internal digestion, and one full of char arrays for I/O. The original - names have gone to detect errors. - - * Makefile.in, m68kcoff.c, targets.c - Test new structure code with a 68k coff implementaion - - * coff-code.h, icoff.c, coffswap.c, libcoff.h - Fixed all the places where there were problems with the size and - alignments of structures on disk and structures in memory. #ifed out - all the code in coffswap.c, since it should be done using the target - swap routines now. - -Thu May 9 11:00:45 1991 Steve Chamberlain (steve at cygint.cygnus.com) - - * ieee.c (do_one, ieee_slurp_section_data): now supports the load - multiple reloc command. - - * sunos.c (sunos4_set_section_contents): Made it so that sections - are always padded to their alignment size. - -Sat May 4 15:49:43 1991 John Gilmore (gnu at cygint.cygnus.com) - - * archive.c, bfd.c, coff-code.h, opncls.c, sunos.c, trad-core.c: - Clean up types and such (saber C problems). - * ecoff.c: Clean up types and such. Remove routines that are - not used. Fix up reading and swapping of shorts from files. - - Notes on bfd-0.5.2-patch1a, from Per Bothner: - - * a.out.vax.c: Remove two bogus "static" from prototypes. - - * ecoff.c: Got rid of lots of non-working junk (that had - been copied directly from coff-code.h). - Updated to be consistent with updates to icoff.c and coff-code.h. - - * libbfd.h: Added definitions for S_IXUSR, S_IXGRP, and S_IXOTH - if they're missing (as they are in (BDS-4.3-based) NewsOS-3). - - * sunos.c (n_txtoff): (Re-)Add support for sony. This is a kludge, - but until the target_vector is automatically generated, - it's as good as any. Note that the text offset is the only - difference between NewsOS and SunOs (including magic numbers). - (Most of the sunos_* routines should to renamed bsd_* - and move to a bsd.c file. Then (and when the target_vector - is automatically generated) it might make sense to create - a separate Sony target.) - - * sysdep.h: Don't declare fread and fwrite. Causes trouble - on some systems, and doesn't help on others. - Similarly, only define X_OK if not already defined. - - * trad-core.c: Don't include sys/stat.h - at least - on NewsOS 3, it has already been included. - -Tue Mar 5 01:47:57 1991 John Gilmore (gnu at cygint.cygnus.com) - - * coff-code.h (bfd_coff_swap_sym, bfd_coff_swap_aux, - bfd_coff_swap_lineno): Export the routines that byte-swap COFF - symbol tables if necessary when reading them in, so gdb can use - them. Add "bfd_coff_" to the names so they won't conflict with - names in calling programs. FIXME-soon: if coff-code.h is - included in two BFD modules, this will cause duplicate - definitions; the routines should be exported to a separate, - common, module (probably along with a mess of other ones). - -Sat Mar 2 12:11:26 1991 John Gilmore (gnu at cygint.cygnus.com) - - Improve modtime support. - - * bfd.h: Add boolean mtime_set, and declare bfd_get_mtime. - Remove #define for bfd_get_mtime. Remove gratuitous comment. - * bfd.c (bfd_get_mtime): New fn, caches mtime, gets if not cached. - BUG: archive members still do not get correct mod times. - - Improve floating point support for core files. - - * sunos.c (struct core): Change void *fpa_dummy to double fp_stuff. - (sunos4_core_file_p): Create a second registers section in the - core file, called ".reg2", for the float registers. - -Thu Feb 14 15:49:06 1991 Gumby Vinayak Wallace (gumby at cygint.cygnus.com) - - * many changes to improve archive handling; found a logic flaw in - bfd_check_format which only just happened to work by cooncidence. - -Thu Feb 14 07:53:16 1991 Steve Chamberlain (steve at cygint.cygnus.com) - - * bfd.c (bfd_perform_relocation): fixed to use output_offsets - correctly. - - * bfd.h: changed type of udata in asymbol to void *, like it - should be. Added bfd_reloc_dangerous enum member. - - * coff-code.h: Fixed it so that internally generated symbols get - their values relocated correctly in all cases. Removed calls to - xmalloc. - - * icoff.c: Not understanding the destination symbol of a reloc is - not a failure any more, just 'dangerous'. This allows linking of - b.out and coff images. - - * sunos.c: Cleaned up the way that ZMAGIC section sizes are - calculated. - - -Tue Feb 12 13:25:46 1991 Steve Chamberlain (steve at cygint.cygnus.com) - - * sunos.c (translate_to_native_sym_flags): fixed - sym_pointer->n_value so that symbols on the way out get their - section relative values calculated correctly. - - * coff-code.h (mangle_symbols): fixed problem where tags were not - being relocated for structs, enums, unions. Also various lints. - -Mon Feb 11 19:52:26 1991 Gumby Vinayak Wallace (gumby at cygint.cygnus.com) - - * archive.c (get_elt_at_filepos): system_call_error returned - incorrectly. - -Sun Feb 10 23:18:40 1991 Gumby Vinayak Wallace (gumby at cygint.cygnus.com) - - * Resolve the use of no_error and system_call_error. - The bfd library itself now will never set bfd_error to - no_error. - - The code still needs to be combed to make sure all the error - codes are correct. I suspect they are not always set correctly. - - * The names of all the messages have _ prepended because the sun - bundled compiler can't distinguish from a macro which takes an - argument and the same identifier in a non-macro context. - - * The reason for the above being that entry points which used to - be trampoline functions are now just macros which expand to a - direct call through the bfd's xfer vector. - - * (../include/intel-coff.h) F_AR32WR: fix this constant. Why - must gas have its own version of everything (the gas version - had the correct value) - -Tue Feb 5 11:46:53 1991 Steve Chamberlain (steve at cygint.cygnus.com) - - * b.out.c: Added patches supplied by chrisb@mipon2.intel.com to - properly support i960 architecture and output correct reloc stuff. - - * bfd.h: added prototype for bfd_printable_arch_mach, added - BFD_FAIL - - * coff-code.h: Applied patches from chrisb to support i960 - architecture, zero relocs and swap them correcly and conditionally - compiled the timestamp. - - * sunos.c: Made the default section alignment 2^3 so that doubles - are done properly. Fixed the same reloc bug that was in b.out.c - - * sysdep.h: Now compiles on a Posix box - -Wed Jan 30 21:36:26 1991 John Gilmore (gnu at cygint.cygnus.com) - - * icoff.c: Fix comment on big-endian version. - * coff-code.h: Make HAS_RELOC really work (it's backwards from - F_RELFLG). Set F_AR32WR in output files if little endian - architecture. - -Tue Jan 29 20:56:10 PST 1991 steve@cygnus.com - - * archures.c fixed =/== typo - - * sunos.c added architecture stuff for output. Fixed - bug where files where vma(data) != size(text) - were processed wrong. - - * coff-code.h added a lint cast - - * (../include/a.out.sun4.h) fixed it so zmagic - worked - -Mon Jan 28 19:15:29 PST 1991 steve@cygnus.com - - * archive.c removed loads of includes, and fixed bug where string - table didn't have a null at the end. - - * bfd.c fixed includes, added symbols argument to - canonicalize_reloc entry point. - - * libbfd.c fixed includes and added some lint patches. - - * targets.c added both sorts of intel coff. - - * b.out.c fixed included, changed was the canonical - relocs were done. - - * icoff.c added support for callj and big and little - enidian tables. - - * opncls.c added chmod+xing for files with EXEC_P set. - - * sunos.c fixed includes. Changed default section - alignement to words. Fixed relocation stuff to work with - new scheme - - * bfd.h various new types added, prototype for new - reloc calls, changed bfd->iostream to a void * - to including files don't need stdio.h. - - * libcoff.h added conversion table to tie relocs to - canonical symbols - - * sysdep.h created - - * coff-code.h fixed includes. Added code to support - big and little endian formats. Various lints. Better - processing of symbols. Changed reloc stuff to new - order - - * libbfd.h fixed includes - - -Mon Jan 21 11:53:51 PST 1991 steve@cygnus.com - - * bfd.h changed name of alignment entry in sec_struct to - alignment_power, because of conflicting uses within bfd. - Now it should be obvious that it's a 2**n alignment - specifier. Removed start_pad, end_alignment, block, minsize, - output_file_alignment, subsection_alignment and original_vma fields. - Added align_power() macro. Fixed bfd_section_alignment - acessor macros. Added bfd_symbol_same_target macro. - - * b.out.c (b_out_write_object_contents) fixed to use - new alignment member. Fixed (callj_callback) to use section - relative symbols properly. - - * sunos.c (sunos4_object_p) fixed to use new alignment_power. - Fixed (translate_from_native_sym_flags) to correctly make - symbols section relative. - - * bfd.c (bfd_errmsg) fixed various enum cast problems. - (bfd_make_section) took out initialization of obsolete members. - (bfd_print_symbol_vandf) added - - * opncls.c (bfd_create) created. - - * coff-code.h (coff_new_section_hook) took away refs - to obsolete members. (make_a_section_from_file) added - conversion between alignment types. (coff_symbol_from) - added. (coff_count_linenumbers) only counts linenumbers - if symbol is of coff-type. (coff_mangle_symbols) only - heavily mangles symbols if symbol is coff-type. - (coff_write_symbols) various lints. (coff_write_object_contents) - various lints and modification for alignment conversion. - (coff_slurp_relocs) fixed for use with new asection shape. - -Sat Jan 19 16:10:42 PST 1991 steve@cygnus.com - - * archive.c lots of lint - - * b.out.c added callj relocation support, upgrated reloc howto. - Fixed so that asymbol and reloc records are output - correctly. - - * bfd.c lots of lint, support for new bfd entry point - bfd_print_symbol. - - * bfd.h changed definition of asymbol to contain pointer to - owning bfd, removed target dependencies. - - * cache.c took out print statements, put in BFD_ASSERT calls. - - * coff-code.h various lints, corrected linenumber output - functionality. Added support for new style asymbols and - bfd_print_symbol. Fixed so that asymbol and - reloc records are handled correctly. Added timestamp. - - * icoff.c Added support for new howto shape. - - * liba.out.h Added support for new asymbol shape - - * libbfd.c various lints - - * libbfd.h various lints - - * libcoff.h added support for new asymbol shape. - - * sunos.c various lints. Added support for new asymbol shape - and bfd_print_symbol. - -Wed Jan 16 21:38:09 PST 1991 steve@cygnus.com - - * b.out.c removed prototype of sunos4_ennativate_symtab, lots of - pointer lint. Added support for callj relocation. Fixed bug where - the last 32 bytes of the text section were overwritten by data. Fixed bug - where archives of b.out didn't work due bfd_slurp_extended_name_table - returning false. - - * sunos.c added support for n_other field. Braced the howto table so - that it won't be affected by any lengthing of the howto struct typedef. - Various lints - - * bfd.h added support for n_other field, added special_function - reloc type, modified bfd_perform_relocation prototype. Added bfd_h_get_x - macros. - - * bfd.c upgraded bfd_perform_relocation, various lints. - -Wed Jan 16 01:55:53 1991 John Gilmore (gnu at rtl) - - * ChangeLog: Started ChangeLog for BFD. - * ToDo: Create file for suggestions. - - * Makefile: Support easy loading into Saber C. - Add dependencies for icoff.o and bcs88kcoff.o. - Rename coff.c to coff-code.h. Change callers. - - * bfd.c (bfd_check_format): Allow the check_format routines - to return the desired target vector, rather than just a Boolean. - bfd.h (bfd_check_format): Change function pointer return type. - archive.c (bfd_generic_archive_p): change callee. - b.out.c (b_out_little_object_p, b_out_big_object_p, - b_out_real_object_p): change callee. - libbfd.c (_bfd_dummy_target): Dummy routine replacing bfd_false - in check_format transfer vectors that need a filler. - libbfd.h (bfd_generic_archive_p, _bfd_dummy_target): Fix decls. - bcs88kcoff.c: change callee. - coff-code.h (coff_real_object_p, coff_big_object_p): change callee. - icoff.c: change callee. - sunos.c (sunos4_object_p, sunos4_core_file_p): change callee. - - * libbfd.c (zalloc): It should actually zero the storage! - This was commented out for some reason. - - * libbfd.h: Add malloc, xmalloc, memcpy, and fatal decls. - This is so callers can avoid which doesn't exist - on older systems. - - * bfd.c (map_over_sections): Add debugging code, since I - noticed the section count for sunos core files was bad, but only - GDB had detected the problem. - (bfd_set_section_lineno_size, bfd_set_section_linenos, - bfd_get_section_linenos): Remove obsolete functions. - (bfd_apply_relocations): Use longs, not ints, for the math. - - * bfd.h: Declare enum boolean and struct bfd_target as well - as typedefs for them. Remove obsolete - bfd_get_section_lineno_size. - - * cache.c: Make the "fdopen" support work. Keep better track - of how many files are open. Centralize the opening of files - and be sure bfd_open[rw] actually try to open the file. Evade - linked list initialization problems. - - * b.out.c, coff-code.h, opncls.c, sunos.c: lint. - - * coff-code.h (coff_slurp_symbol_table): Null-terminate symtab names. - - * cplus-dem.c: Delete file, since it is not part of BFD. - - * opncls.c (bfd_openr): Eliminate misplaced #if 0 code. - (bfd_openr, bfd_openw): Actually open the file, give error now. - - * sunos.c (sunos4_core_file_p): Set section count. - (sunos4_set_section_linenos, stab_names, fprint_name): Eliminiate - obsolete definitions. - (_write_symbol_table): Initialize counter. - (foop): Eliminate debugging code. - - - - diff --git a/bfd/Makefile b/bfd/Makefile deleted file mode 100755 index b20e9540873..00000000000 --- a/bfd/Makefile +++ /dev/null @@ -1,149 +0,0 @@ -# -# Copyright (C) 1990, 1991 Free Software Foundation, Inc. -# -# This file is part of BFD, the Binary File Diddler. -# -# BFD 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 1, or (at your option) -# any later version. -# -# BFD 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 BFD; see the file COPYING. If not, write to -# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -# $Id$ - -srcdir=../common -VPATH=../common -RANLIB = ranlib -CSWITCHES = -g # -Wall -CC=gcc -Wall -#__sun4__#CDEFINES=-DHOST_SYS=SUN4_SYS -#__sun3__#CDEFINES=-DHOST_SYS=SUN3_SYS -#__dgux__#CDEFINES=-DHOST_SYS=DGUX_SYS -#__dgux__#RANLIB=echo -INCDIR = ${srcdir}/../../include-cygnus -CSEARCH = -I$(INCDIR) - -TARG = libbfd.a -CFLAGS = $(CDEFINES) $(CSEARCH) $(CSWITCHES) - - -BFD_LIBS = libbfd.o opncls.o bfd.o archive.o targets.o cache.o archures.o obstack.o - -BFD_BACKENDS = oasys.o ieee.o srec.o sunos.o icoff.o b.out.o m88k-bcs.o - -BFD_H=$(INCDIR)/bfd.h -SYSDEP_H=$(INCDIR)/sysdep.h - -# C source files that correspond to .o's. -CFILES = libbfd.c opncls.c bfd.c archive.c targets.c cache.c archures.c \ - sunos.c icoff.c b.out.c srec.c oasys.c ieee.c m88k-bcs.c - -all: $(TARG) - -POINTOS = $(BFD_LIBS) $(BFD_BACKENDS) - -$(TARG): $(POINTOS) - rm -f $(TARG) - ar clq $(TARG) $(BFD_LIBS) $(BFD_BACKENDS) - $(RANLIB) $(TARG) - -tags etags: TAGS - -TAGS: .force - etags $(INCDIR)/*.h *.h *.c - -clean: - rm -f $(BFD_LIBS) $(BFD_BACKENDS) *~ core libbfd.a - -clobber realclean: clean - rm -f libbfd.a TAGS - -$(BFD_LIBS) $(BFD_BACKENDS): libbfd.h $(BFD_H) - -archive.o : archive.c libbfd.h $(BFD_H) $(SYSDEP_H) -archures.o : archures.c $(BFD_H) $(SYSDEP_H) archures.h -b.out.o : b.out.c libbfd.h $(BFD_H) $(SYSDEP_H) liba.out.h archures.h -m88k-bcs.o: m88k-bcs.c libbfd.h $(BFD_H) $(SYSDEP_H) libcoff.h coff-code.h archures.h -bfd.o : bfd.c libbfd.h $(BFD_H) $(SYSDEP_H) -cache.o : cache.c libbfd.h $(BFD_H) $(SYSDEP_H) -coff.o : coff.c -cplus-dem.o : cplus-dem.c -filemode.o : filemode.c -icoff.o : icoff.c libbfd.h $(BFD_H) $(SYSDEP_H) libcoff.h coff-code.h archures.h -libbfd.o : libbfd.c libbfd.h $(BFD_H) $(SYSDEP_H) -misc.o : misc.c -opncls.o : opncls.c libbfd.h $(BFD_H) $(SYSDEP_H) -sunos.o : sunos.c libbfd.h $(BFD_H) $(SYSDEP_H) liba.out.h -targets.o : targets.c libbfd.h $(BFD_H) $(SYSDEP_H) -obstack.o:obstack.c -ieee.o:ieee.c -oasys.o:oasys.c -srec.o:srec.c - - - -version.c: FORCE - rm -f version.c - echo "char ${TARG}_ver[]= \"${TARG} `cat VERSION`, `date`\";" > version.c - - -# This target should be invoked before building a new release. -# 'VERSION' file must be present and contain a string of the form "x.y" -# -roll: - @V=`cat VERSION` ; \ - MAJ=`sed 's/\..*//' VERSION` ; \ - MIN=`sed 's/.*\.//' VERSION` ; \ - V=$$MAJ.`expr $$MIN + 1` ; \ - rm -f VERSION ; \ - echo $$V >VERSION ; \ - echo Version $$V - -# Dummy target to force execution of dependent targets. -# -.force: -FORCE: - -# 'G960BASE' will be defined at invocation -install: - make ${TARG} OPT=-O - -# Target to uncomment host-specific lines in this makefile. Such lines must -# have the following string beginning in column 1: #____# -# Original Makefile is backed up as 'Makefile.old'. -# -# Invoke with: make make HOST=xxx -# -make: - -@if test $(HOST)x = x ; then \ - echo 'Specify "make make HOST=???"'; \ - exit 1; \ - fi ; \ - grep -s "^#The next line was generated by 'make make'" Makefile; \ - if test $$? = 0 ; then \ - echo "Makefile has already been processed with 'make make'";\ - exit 1; \ - fi ; \ - mv -f Makefile Makefile.old; \ - echo "# " >Makefile ;\ - echo "# " >>Makefile ;\ - echo "# D A N G E R" >>Makefile ;\ - echo "# " >>Makefile ;\ - echo "# This file was created by make make, change the source in ../common" >>Makefile ; \ - echo "#The next line was generated by 'make make'" >>Makefile ; \ - echo "HOST=$(HOST)" >>Makefile ; \ - echo >>Makefile ; \ - sed "s/^#__$(HOST)__#//" < Makefile.old >>Makefile - -Makefile: ../common/Makefile - mv Makefile Makefile.backup - cp ../common/Makefile . - $(MAKE) "HOST=$(HOST)" make diff --git a/bfd/Makefile.in b/bfd/Makefile.in deleted file mode 100644 index 4879897ccd4..00000000000 --- a/bfd/Makefile.in +++ /dev/null @@ -1,330 +0,0 @@ -# Makefile template for Configure for the BFD library. -# Copyright (C) 1990, 1991 Free Software Foundation, Inc. -# Written by Cygnus Support. -# -# This file is part of BFD, the Binary File Descriptor library. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -# $Id$ - -srcdir = . -ddestdir = /usr/local -libdir = $(ddestdir)/lib -docdir = $(srcdir)/doc -includedir= $(ddestdir)/include -RANLIB = ranlib -AR = ar -AR_FLAGS = clq -INCDIR = $(srcdir)/../include -CSEARCH = -I. -I$(srcdir) -I$(INCDIR) -DEP = mkdep -MINUS_G=-g - -SUBDIRS = doc - -#### host and target dependent Makefile fragments come in here. -### - -TARGETLIB = libbfd.a -CFLAGS = $(MINUS_G) $(HDEFINES) $(TDEFINES) $(CSEARCH) $(CSWITCHES) # -DINTEL960VERSION - - -BFD_LIBS = libbfd.o opncls.o bfd.o archive.o targets.o cache.o \ - archures.o core.o section.o format.o syms.o reloc.o init.o ctor.o - -BFD_MACHINES = cpu-h8300.o cpu-i960.o cpu-sparc.o cpu-m68k.o cpu-m88k.o \ - cpu-vax.o cpu-mips.o cpu-a29k.o cpu-i386.o cpu-rs6000.o - -BFD_BACKENDS = oasys.o ieee.o srec.o elf.o \ - aout64.o aout32.o demo64.o sunos.o newsos3.o i386aout.o bout.o \ - coff-i960.o coff-a29k.o coff-m68k.o coff-i386.o coff-m88k.o \ - coff-mips.o coff-rs6000.o - -OPTIONAL_BACKENDS = trad-core.o - -BFD_H=$(INCDIR)/bfd.h - -# C source files that correspond to .o's. -CFILES = libbfd.c opncls.c bfd.c archive.c targets.c cache.c archures.c \ - coff-i386.c aout64.c aout32.c sunos.c demo64.c coff-i960.c srec.c \ - oasys.c ieee.c coff-m68k.c coff-a29k.c coff-rs6000.c \ - format.c section.c core.c syms.c reloc.c init.c ctor.c \ - coff-m88k.c coff-mips.c trad-core.c newsos3.c i386aout.c bout.c elf.c \ - cpu-h8300.c cpu-i960.c cpu-sparc.c cpu-m68k.c cpu-m88k.c \ - cpu-vax.c cpu-mips.c cpu-a29k.c cpu-i386.c cpu-rs6000.c - -STAGESTUFF = $(TARGETLIB) $(OFILES) - -all: $(TARGETLIB) - $(MAKE) subdir_do DO=all "DODIRS=$(SUBDIRS)" - -all-info: force - $(MAKE) subdir_do DO=all-info "DODIRS=$(SUBDIRS)" - -install-info: force - $(MAKE) subdir_do DO=install-info "DODIRS=$(SUBDIRS)" - -# HDEPFILES comes from the host config; TDEPFILES from the target config. -OFILES = $(BFD_LIBS) $(BFD_BACKENDS) $(BFD_MACHINES) $(HDEPFILES) $(TDEPFILES) - -$(TARGETLIB): $(OFILES) - rm -f $(TARGETLIB) - $(AR) $(AR_FLAGS) $(TARGETLIB) $(OFILES) - $(RANLIB) $(TARGETLIB) - -# When compiling targets.c, supply the default target info from configure. -targets.o: targets.c - $(CC) $(CFLAGS) -c $(TDEFAULTS) $< - -subdir_do: force - for i in $(DODIRS); do \ - if [ -d $(unsubdir)/$$i ] ; then \ - if (cd $(unsubdir)/$$i$(subdir); \ - $(MAKE) \ - "against=$(against)" \ - "AR=$(AR)" \ - "CC=$(CC)" \ - "AR_FLAGS=$(AR_FLAGS)" \ - "RANLIB=$(RANLIB)" \ - "BISON=$(BISON)" $(DO)) ; then true ; \ - else exit 1 ; fi ; \ - else true ; fi ; \ - done - -stage1: force - - mkdir stage1 - - mv -f $(STAGESTUFF) stage1 - $(MAKE) subdir_do DO=stage1 "DODIRS=$(SUBDIRS)" - -stage2: force - - mkdir stage2 - - mv -f $(STAGESTUFF) stage2 - $(MAKE) subdir_do DO=stage2 "DODIRS=$(SUBDIRS)" - -stage3: force - - mkdir stage3 - - mv -f $(STAGESTUFF) stage3 - $(MAKE) subdir_do DO=stage3 "DODIRS=$(SUBDIRS)" - -against=stage2 - -comparison: force - for i in *.o ; do cmp $$i $(against)/$$i || exit 1 ; done - $(MAKE) subdir_do DO=comparison "DODIRS=$(SUBDIRS)" - -de-stage1: force - - (cd stage1 ; mv -f $(STAGESTUFF) ..) - - rmdir stage1 - $(MAKE) subdir_do DO=de-stage1 "DODIRS=$(SUBDIRS)" - -de-stage2: force - - (cd stage2 ; mv -f $(STAGESTUFF) ..) - - rmdir stage2 - $(MAKE) subdir_do DO=de-stage2 "DODIRS=$(SUBDIRS)" - -de-stage3: force - - (cd stage3 ; mv -f $(STAGESTUFF) ..) - - rmdir stage3 - $(MAKE) subdir_do DO=de-stage3 "DODIRS=$(SUBDIRS)" - -tags etags: TAGS - -TAGS: force - etags $(INCDIR)/*.h $(srcdir)/*.h $(srcdir)/*.c - -clean: - rm -f *.[oa] *~ core *.E *.p *.ip - $(MAKE) subdir_do DO=clean "DODIRS=$(SUBDIRS)" - -clobber realclean: clean - rm -f libbfd.a TAGS - $(MAKE) subdir_do DO=clobber "DODIRS=$(SUBDIRS)" - -# Mark everything as depending on config.status, since the timestamp on -# sysdep.h might actually move backwards if we reconfig and relink it -# to a different hosts/h-xxx.h file. This will force a recompile anyway. -RECONFIG = config.status -$(BFD_LIBS): libbfd.h $(BFD_H) $(RECONFIG) -$(BFD_MACHINES): libbfd.h $(BFD_H) $(RECONFIG) -$(BFD_BACKENDS): libbfd.h $(BFD_H) $(RECONFIG) -$(OPTIONAL_BACKENDS): libbfd.h $(BFD_H) $(RECONFIG) - -# Get around a Sun Make bug in SunOS 4.1.1 with VPATH -cpu-i386.o:cpu-i386.c - -saber: - #suppress 65 on bfd_map_over_sections - #suppress 66 on bfd_map_over_sections - #suppress 67 on bfd_map_over_sections - #suppress 68 on bfd_map_over_sections - #suppress 69 on bfd_map_over_sections - #suppress 70 on bfd_map_over_sections - #suppress 110 in bfd_map_over_sections - #suppress 112 in bfd_map_over_sections - #suppress 530 - #suppress 590 in swap_exec_header - #suppress 590 in _bfd_dummy_core_file_matches_executable_p - #suppress 590 in bfd_dont_truncate_arname - #suppress 590 on ignore - #suppress 590 on abfd - #setopt load_flags $(CFLAGS) - #load $(CFILES) - - -#----------------------------------------------------------------------------- -# 'STANDARD' GNU/960 TARGETS BELOW THIS POINT -# -# 'VERSION' file must be present and contain a string of the form "x.y" -#----------------------------------------------------------------------------- - -ver960.c: FORCE - rm -f ver960.c - echo "char ${TARG}_ver[]= \"${TARG} `cat VERSION`, `date`\";" > ver960.c - - -# This target should be invoked before building a new release. -# 'VERSION' file must be present and contain a string of the form "x.y" -# -roll: - @V=`cat VERSION` ; \ - MAJ=`sed 's/\..*//' VERSION` ; \ - MIN=`sed 's/.*\.//' VERSION` ; \ - V=$$MAJ.`expr $$MIN + 1` ; \ - rm -f VERSION ; \ - echo $$V >VERSION ; \ - echo Version $$V - -# Dummy target to force execution of dependent targets. -# -force: - -install: - cp libbfd.a $(libdir)/libbfd.a.new - $(RANLIB) $(libdir)/libbfd.a.new - mv -f $(libdir)/libbfd.a.new $(libdir)/libbfd.a - cp $(INCDIR)/bfd.h $(includedir)/bfd.h - $(MAKE) subdir_do DO=install "DODIRS=$(SUBDIRS)" - -# Target to uncomment host-specific lines in this makefile. Such lines must -# have the following string beginning in column 1: #____# -# Original Makefile is backed up as 'Makefile.old'. -# -# Invoke with: make make HOST=xxx -# -make: - -@if test $(HOST)x = x ; then \ - echo 'Specify "make make HOST=???"'; \ - exit 1; \ - fi ; \ - grep -s "^#The next line was generated by 'make make'" Makefile; \ - if test $$? = 0 ; then \ - echo "Makefile has already been processed with 'make make'";\ - exit 1; \ - fi ; \ - mv -f Makefile Makefile.old; \ - echo "#The next line was generated by 'make make'" >Makefile ; \ - echo "HOST=$(HOST)" >>Makefile ; \ - echo >>Makefile ; \ - sed "s/^#__$(HOST)__#//" < Makefile.old >>Makefile - -Makefile: $(srcdir)/Makefile.in $(host_makefile_frag) $(target_makefile_frag) - $(SHELL) ./config.status - -dep: $(CFILES) - mkdep $(CFLAGS) $? - - - -headers: - (cd $(docdir); $(MAKE) protos) - # Rebuild prototypes in bfd.h - cp $(docdir)/bfd.h $(BFD_H) - cp $(docdir)/libbfd.h $(srcdir)/libbfd.h - cp $(docdir)/libcoff.h $(srcdir)/libcoff.h - -bfd.info: - ( cd $(docdir); $(MAKE) bfd.info) - -bfd.dvi: - (cd $(docdir); $(MAKE) bfd.dvi) - -bfd.ps: - (cd $(docdir); $(MAKE) bfd.ps) - -# What appears below is generated by a hacked mkdep using gcc -MM. - -# DO NOT DELETE THIS LINE -- mkdep uses it. -# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. - -libbfd.o : libbfd.c $(INCDIR)/bfd.h $(INCDIR)/obstack.h libbfd.h -opncls.o : opncls.c $(INCDIR)/bfd.h $(INCDIR)/obstack.h libbfd.h -bfd.o : bfd.c $(INCDIR)/bfd.h $(INCDIR)/obstack.h libbfd.h -archive.o : archive.c $(INCDIR)/bfd.h $(INCDIR)/obstack.h libbfd.h \ - $(INCDIR)/ar.h $(INCDIR)/ranlib.h -targets.o : targets.c $(INCDIR)/bfd.h $(INCDIR)/obstack.h libbfd.h -cache.o : cache.c $(INCDIR)/bfd.h $(INCDIR)/obstack.h libbfd.h -archures.o : archures.c $(INCDIR)/bfd.h $(INCDIR)/obstack.h -coff-i386.o : coff-i386.c $(INCDIR)/bfd.h $(INCDIR)/obstack.h libbfd.h \ - $(INCDIR)/coff-i386.h $(INCDIR)/internalcoff.h libcoff.h coffcode.h -aout64.o : aout64.c -aout32.o : aout32.c aoutx.h $(INCDIR)/bfd.h $(INCDIR)/ansidecl.h \ - $(INCDIR)/obstack.h libaout.h libbfd.h $(INCDIR)/aout64.h \ - $(INCDIR)/stab.gnu.h $(INCDIR)/stab.def $(INCDIR)/ar.h -sunos.o : sunos.c aoutf1.h $(INCDIR)/bfd.h $(INCDIR)/obstack.h \ - libaout.h libbfd.h $(INCDIR)/aout64.h $(INCDIR)/stab.gnu.h \ - $(INCDIR)/stab.def $(INCDIR)/ar.h -demo64.o : demo64.c -coff-i960.o : coff-i960.c $(INCDIR)/bfd.h $(INCDIR)/obstack.h libbfd.h \ - $(INCDIR)/coff-i960.h $(INCDIR)/internalcoff.h libcoff.h coffcode.h -srec.o : srec.c $(INCDIR)/bfd.h $(INCDIR)/obstack.h libbfd.h -oasys.o : oasys.c $(INCDIR)/bfd.h $(INCDIR)/obstack.h libbfd.h \ - $(INCDIR)/oasys.h liboasys.h -ieee.o : ieee.c $(INCDIR)/bfd.h $(INCDIR)/obstack.h libbfd.h \ - $(INCDIR)/ieee.h libieee.h -coff-m68k.o : coff-m68k.c $(INCDIR)/bfd.h $(INCDIR)/obstack.h libbfd.h \ - $(INCDIR)/coff-m68k.h $(INCDIR)/internalcoff.h libcoff.h coffcode.h -coff-a29k.o : coff-a29k.c $(INCDIR)/bfd.h $(INCDIR)/obstack.h libbfd.h \ - $(INCDIR)/coff-a29k.h $(INCDIR)/internalcoff.h libcoff.h coffcode.h -coff-rs6000.o: coff-rs6000.c $(INCDIR)/bfd.h $(INCDIR)/obstack.h libbfd.h \ - $(INCDIR)/coff-rs6000.h $(INCDIR)/internalcoff.h libcoff.h coffcode.h -format.o : format.c $(INCDIR)/bfd.h \ - $(INCDIR)/obstack.h libbfd.h -section.o : section.c $(INCDIR)/bfd.h \ - $(INCDIR)/obstack.h libbfd.h -core.o : core.c $(INCDIR)/bfd.h \ - $(INCDIR)/obstack.h libbfd.h -syms.o : syms.c $(INCDIR)/bfd.h \ - $(INCDIR)/obstack.h libbfd.h -reloc.o : reloc.c $(INCDIR)/bfd.h \ - $(INCDIR)/obstack.h libbfd.h -coff-m88k.o : coff-m88k.c $(INCDIR)/bfd.h $(INCDIR)/obstack.h libbfd.h \ - $(INCDIR)/coff-m88k.h $(INCDIR)/internalcoff.h libcoff.h coffcode.h -coff-mips.o : coff-mips.c $(INCDIR)/bfd.h $(INCDIR)/obstack.h libbfd.h \ - $(INCDIR)/coff-mips.h $(INCDIR)/internalcoff.h libcoff.h trad-core.h \ - coffcode.h -trad-core.o : trad-core.c $(INCDIR)/bfd.h $(INCDIR)/obstack.h \ - libbfd.h libaout.h -newsos3.o : newsos3.c $(INCDIR)/bfd.h $(INCDIR)/obstack.h libbfd.h \ - $(INCDIR)/aout64.h $(INCDIR)/stab.gnu.h $(INCDIR)/stab.def \ - $(INCDIR)/ar.h libaout.h -i386aout.o : i386aout.c $(INCDIR)/bfd.h $(INCDIR)/obstack.h libbfd.h \ - $(INCDIR)/aout64.h $(INCDIR)/stab.gnu.h $(INCDIR)/stab.def \ - $(INCDIR)/ar.h libaout.h -bout.o : bout.c $(INCDIR)/bfd.h $(INCDIR)/obstack.h libbfd.h \ - $(INCDIR)/bout.h $(INCDIR)/stab.gnu.h $(INCDIR)/stab.def libaout.h - -# IF YOU PUT ANYTHING HERE IT WILL GO AWAY - diff --git a/bfd/TODO b/bfd/TODO deleted file mode 100644 index 26fd83b0f7c..00000000000 --- a/bfd/TODO +++ /dev/null @@ -1,41 +0,0 @@ -Things that still need to be handled: -*- Text -*- - - o - change the memory usage to reflect the message which follows the - page break. - o - implement bfd_abort, which should close the bfd but not alter the - filesystem. - o - update the bfd doc; write a how-to-write-a-backend doc. - o - change reloc handling as per Steve's suggestion. - (more details please.....) - -Changing the way bfd uses memory. The new convention is simple: - - o - bfd will never write into user-supplied memory, nor attempt to - free it. - o - closing a bfd may reclaim all bfd-allocated memory associated - with that bfd. - - - bfd_target_list will be the one exception; you must reclaim the - returned vector yourself. - -Interface implications are minor (get_symcount_upper_bound will go -away; bfd_cannicalize_symtab will allocate its own memory, etc). - -Certain operations consume a lot of memory; for them manual -reclaimation is available: - - o - bfd_canonicalize_symtab will return a pointer to a - null-terminated vector of symbols. Subsequent calls may or may - not return the same pointer. - bfd_canonicalize_relocs will do the same; returning a pointer to - an array of arelocs. Calling this function will read symbols in - too. - - o - bfd_reclaim_relocs will free the memory used by these relocs. - the symbols will be untouched. - bfd_reclaim_symtab (ne bfd_reclaim_symbol_table) will free the - memory allocated by canonialize_symtab. - Since relocations point to symbols, any relocations obtained by a - call to bfd_canonicalize_relocs will be reclaimed as well. - - o - if you don't call the reclaim_ functions, the memory will be - reclaimed at bfd_close time. diff --git a/bfd/VERSION b/bfd/VERSION deleted file mode 100644 index a4d2aceeb8d..00000000000 --- a/bfd/VERSION +++ /dev/null @@ -1 +0,0 @@ -0.18 diff --git a/bfd/aout-encap.c b/bfd/aout-encap.c deleted file mode 100644 index dc6ba10b821..00000000000 --- a/bfd/aout-encap.c +++ /dev/null @@ -1,328 +0,0 @@ -/* BFD back-end for a.out files encapsulated with COFF headers. - Copyright (C) 1990-1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* THIS MODULE IS NOT FINISHED. IT PROBABLY DOESN'T EVEN COMPILE. */ - -#if 0 -#define PAGE_SIZE 4096 -#define SEGMENT_SIZE PAGE_SIZE -#define TEXT_START_ADDR 0 -#define ARCH 32 -#define BYTES_IN_WORD 4 -#endif - -#include "bfd.h" -#include -#include "libbfd.h" -#include "aout64.h" - -/**From: bothner@cs.wisc.edu***********************************************/ -#undef N_TXTOFF -#define N_TXTOFF(x) ( (N_MAGIC((x)) == ZMAGIC) ? PAGE_SIZE : EXEC_BYTES_SIZE) -/**************************************************************************/ - -#include "stab.gnu.h" -#include "ar.h" -#include "libaout.h" /* BFD a.out internal data structures */ - -bfd_target *encap_callback (); - -bfd_target * -DEFUN(encap_object_p,(abfd), - bfd *abfd) -{ - unsigned char magicbuf[4]; /* Raw bytes of magic number from file */ - unsigned long magic; /* Swapped magic number */ - short coff_magic; - struct external_exec exec_bytes; - struct internal_exec exec; - - bfd_error = system_call_error; - - if (bfd_read ((PTR)magicbuf, 1, sizeof (magicbuf), abfd) != - sizeof (magicbuf)) - return 0; - - coff_magic = bfd_h_get_16 (abfd, magicbuf); - if (coff_magic != COFF_MAGIC) - return 0; /* Not an encap coff file */ - - __header_offset_temp==COFF_MAGIC ? sizeof(struct coffheader) : 0) - (fseek ((f), HEADER_OFFSET((f)), 1)) - - magic = bfd_h_get_32 (abfd, magicbuf); - - if (N_BADMAG (*((struct internal_exec *) &magic))) return 0; - - struct external_exec exec_bytes; - if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd) - != EXEC_BYTES_SIZE) { - bfd_error = wrong_format; - return 0; - } - NAME(aout,swap_exec_header_in)(abfd, &exec_bytes, &exec); - - return aout_32_some_aout_object_p (abfd, &exec, encap_callback); -} - -/* Finish up the reading of a encapsulated-coff a.out file header */ -bfd_target * -DEFUN(encap_callback,(abfd), - bfd *abfd) -{ - struct internal_exec *execp = exec_hdr (abfd); - - WORK_OUT_FILE_POSITIONS(abfd, execp) ; - - /* If we have a coff header, it can give us better values for - text_start and exec_data_start. This is particularly useful - for remote debugging of embedded systems. */ - if (N_FLAGS(exec_aouthdr) & N_FLAGS_COFF_ENCAPSULATE) - { - struct coffheader ch; - int val; - val = lseek (execchan, -(sizeof (AOUTHDR) + sizeof (ch)), 1); - if (val == -1) - perror_with_name (filename); - val = myread (execchan, &ch, sizeof (ch)); - if (val < 0) - perror_with_name (filename); - text_start = ch.text_start; - exec_data_start = ch.data_start; - } else - { - text_start = - IS_OBJECT_FILE (exec_aouthdr) ? 0 : N_TXTADDR (exec_aouthdr); - exec_data_start = IS_OBJECT_FILE (exec_aouthdr) - ? exec_aouthdr.a_text : N_DATADDR (exec_aouthdr); - } - - /* Determine the architecture and machine type of the object file. */ - bfd_default_set_arch_mach(abfd, bfd_arch_m68k, 0); /* FIXME */ - - return abfd->xvec; -} - -/* Write an object file in Encapsulated COFF format. - Section contents have already been written. We write the - file header, symbols, and relocation. */ - -boolean -DEFUN(encap_write_object_contents,(abfd), - bfd *abfd) -{ - bfd_size_type data_pad = 0; - struct external_exec exec_bytes; - struct internal_exec *execp = exec_hdr (abfd); - -/****** FIXME: Fragments from the old GNU LD program for dealing with - encap coff. */ -struct coffheader coffheader; -int need_coff_header; - - /* Determine whether to count the header as part of - the text size, and initialize the text size accordingly. - This depends on the kind of system and on the output format selected. */ - - N_SET_MAGIC (outheader, magic); -#ifdef INITIALIZE_HEADER - INITIALIZE_HEADER; -#endif - - text_size = sizeof (struct exec); -#ifdef COFF_ENCAPSULATE - if (relocatable_output == 0 && file_table[0].just_syms_flag == 0) - { - need_coff_header = 1; - /* set this flag now, since it will change the values of N_TXTOFF, etc */ - N_SET_FLAGS (outheader, N_FLAGS_COFF_ENCAPSULATE); - text_size += sizeof (struct coffheader); - } -#endif - -#ifdef COFF_ENCAPSULATE - if (need_coff_header) - { - /* We are encapsulating BSD format within COFF format. */ - struct coffscn *tp, *dp, *bp; - - tp = &coffheader.scns[0]; - dp = &coffheader.scns[1]; - bp = &coffheader.scns[2]; - - strcpy (tp->s_name, ".text"); - tp->s_paddr = text_start; - tp->s_vaddr = text_start; - tp->s_size = text_size; - tp->s_scnptr = sizeof (struct coffheader) + sizeof (struct exec); - tp->s_relptr = 0; - tp->s_lnnoptr = 0; - tp->s_nreloc = 0; - tp->s_nlnno = 0; - tp->s_flags = 0x20; - strcpy (dp->s_name, ".data"); - dp->s_paddr = data_start; - dp->s_vaddr = data_start; - dp->s_size = data_size; - dp->s_scnptr = tp->s_scnptr + tp->s_size; - dp->s_relptr = 0; - dp->s_lnnoptr = 0; - dp->s_nreloc = 0; - dp->s_nlnno = 0; - dp->s_flags = 0x40; - strcpy (bp->s_name, ".bss"); - bp->s_paddr = dp->s_vaddr + dp->s_size; - bp->s_vaddr = bp->s_paddr; - bp->s_size = bss_size; - bp->s_scnptr = 0; - bp->s_relptr = 0; - bp->s_lnnoptr = 0; - bp->s_nreloc = 0; - bp->s_nlnno = 0; - bp->s_flags = 0x80; - - coffheader.f_magic = COFF_MAGIC; - coffheader.f_nscns = 3; - /* store an unlikely time so programs can - * tell that there is a bsd header - */ - coffheader.f_timdat = 1; - coffheader.f_symptr = 0; - coffheader.f_nsyms = 0; - coffheader.f_opthdr = 28; - coffheader.f_flags = 0x103; - /* aouthdr */ - coffheader.magic = ZMAGIC; - coffheader.vstamp = 0; - coffheader.tsize = tp->s_size; - coffheader.dsize = dp->s_size; - coffheader.bsize = bp->s_size; - coffheader.entry = outheader.a_entry; - coffheader.text_start = tp->s_vaddr; - coffheader.data_start = dp->s_vaddr; - } -#endif - -#ifdef COFF_ENCAPSULATE - if (need_coff_header) - mywrite (&coffheader, sizeof coffheader, 1, outdesc); -#endif - -#ifndef COFF_ENCAPSULATE - padfile (N_TXTOFF (outheader) - sizeof outheader, outdesc); -#endif - - text_size -= N_TXTOFF (outheader); - WRITE_HEADERS(abfd, execp); - return true; -} - -/* Transfer vectors for Encapsulated-(aout-in)-coff */ - -/* We use BFD generic archive files. */ -#define newsos_openr_next_archived_file bfd_generic_openr_next_archived_file -#define newsos_generic_stat_arch_elt bfd_generic_stat_arch_elt -#define newsos_slurp_armap bfd_slurp_bsd_armap -#define newsos_slurp_extended_name_table bfd_true -#define newsos_write_armap bsd_write_armap -#define newsos_truncate_arname bfd_bsd_truncate_arname - -/* We don't support core files yet. FIXME. */ -#define newsos_core_file_failing_command _bfd_dummy_core_file_failing_command -#define newsos_core_file_failing_signal _bfd_dummy_core_file_failing_signal -#define newsos_core_file_matches_executable_p \ - _bfd_dummy_core_file_matches_executable_p -#define newsos_core_file_p _bfd_dummy_target - -#define newsos_bfd_debug_info_start bfd_void -#define newsos_bfd_debug_info_end bfd_void -#define newsos_bfd_debug_info_accumulate (PROTO(void,(*),(bfd*, struct sec *))) bfd_void - -#define newsos_mkobject aout_32_mkobject -#define newsos_close_and_cleanup aout_32_close_and_cleanup -#define newsos_set_section_contents aout_32_set_section_contents -#define newsos_get_section_contents aout_32_get_section_contents -#define newsos_new_section_hook aout_32_new_section_hook -#define newsos_get_symtab_upper_bound aout_32_get_symtab_upper_bound -#define newsos_get_symtab aout_32_get_symtab -#define newsos_get_reloc_upper_bound aout_32_get_reloc_upper_bound -#define newsos_canonicalize_reloc aout_32_canonicalize_reloc -#define newsos_make_empty_symbol aout_32_make_empty_symbol -#define newsos_print_symbol aout_32_print_symbol -#define newsos_get_lineno aout_32_get_lineno -#define newsos_set_arch_mach aout_32_set_arch_mach -#define newsos_find_nearest_line aout_32_find_nearest_line -#define newsos_sizeof_headers aout_32_sizeof_headers - - -/* We define our own versions of these routines. */ - - -bfd_target encap_big_vec = /* "Encapsulated coff": a.out with COFF header prefix */ -{ - "a.out-encap", /* name */ - bfd_target_aout_flavour, - true, /* target byte order */ - true, /* target headers byte order */ - (HAS_RELOC | EXEC_P | /* object flags */ - HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED), - (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ - ' ', /* ar_pad_char */ - 16, /* ar_max_namelen */ - 1, /* minimum alignment */ - _do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* data */ - _do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* hdrs */ - - {_bfd_dummy_target, newsos3_object_p, /* bfd_check_format */ - bfd_generic_archive_p, newsos_core_file_p}, - {bfd_false, newsos_mkobject, /* bfd_set_format */ - _bfd_generic_mkarchive, bfd_false}, - {bfd_false, newsos3_write_object_contents, /* bfd_write_contents */ - _bfd_write_archive_contents, bfd_false}, - - JUMP_TABLE(newsos) -}; - -/* Little-endian "encapsulated coff": a.out with COFF header prefix */ -bfd_target encap_little_vec = -{ - "a.out-encap-little", /* name */ - bfd_target_aout_flavour, - false, /* target byte order */ - false, /* target headers byte order */ - (HAS_RELOC | EXEC_P | /* object flags */ - HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED), - (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ - ' ', /* ar_pad_char */ - 16, /* ar_max_namelen */ - 1, /* minimum alignment */ - _do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putl16, /* data */ - _do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putb16, /* hdrs */ - - {_bfd_dummy_target, newsos3_object_p, /* bfd_check_format */ - bfd_generic_archive_p, newsos_core_file_p}, - {bfd_false, newsos_mkobject, /* bfd_set_format */ - _bfd_generic_mkarchive, bfd_false}, - {bfd_false, newsos3_write_object_contents, /* bfd_write_contents */ - _bfd_write_archive_contents, bfd_false}, - - JUMP_TABLE(newsos) -}; diff --git a/bfd/aout.c b/bfd/aout.c deleted file mode 100755 index 8a795e28df2..00000000000 --- a/bfd/aout.c +++ /dev/null @@ -1,1500 +0,0 @@ -/* BFD semi-generic back-end for a.out binaries */ - -/* Copyright (C) 1990, 1991 Free Software Foundation, Inc. - -This file is part of BFD, the Binary File Diddler. - -BFD 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 1, or (at your option) -any later version. - -BFD 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 BFD; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - - -#include -#include -#include "bfd.h" -#include "libbfd.h" - -#include "a.out.gnu.h" -#include "stab.gnu.h" -#include "ar.h" -#include "liba.out.h" /* BFD a.out internal data structures */ - -void (*bfd_error_trap)(); - -/*SUPPRESS558*/ -/*SUPPRESS529*/ - -#define CTOR_TABLE_RELOC_IDX 2 -static reloc_howto_type howto_table_ext[] = -{ - HOWTO(RELOC_8, 0, 0, 8, false, 0, true, true,0,"8", false, 0,0x000000ff, false), - HOWTO(RELOC_16, 0, 1, 16, false, 0, true, true,0,"16", false, 0,0x0000ffff, false), - HOWTO(RELOC_32, 0, 2, 32, false, 0, true, true,0,"32", false, 0,0xffffffff, false), - HOWTO(RELOC_DISP8, 0, 0, 8, true, 0, false, true,0,"DISP8", false, 0,0x000000ff, false), - HOWTO(RELOC_DISP16, 0, 1, 16, true, 0, false, true,0,"DISP16", false, 0,0x0000ffff, false), - HOWTO(RELOC_DISP32, 0, 2, 32, true, 0, false, true,0,"DISP32", false, 0,0xffffffff, false), - HOWTO(RELOC_WDISP30,2, 2, 30, true, 0, false, true,0,"WDISP30", false, 0,0x3fffffff, false), - HOWTO(RELOC_WDISP22,2, 2, 22, true, 0, false, true,0,"WDISP22", false, 0,0x003fffff, false), - HOWTO(RELOC_HI22, 10, 2, 22, false, 0, false, true,0,"HI22", false, 0,0x003fffff, false), - HOWTO(RELOC_22, 0, 2, 22, false, 0, false, true,0,"22", false, 0,0x003fffff, false), - HOWTO(RELOC_13, 0, 2, 13, false, 0, false, true,0,"13", false, 0,0x00001fff, false), - HOWTO(RELOC_LO10, 0, 2, 10, false, 0, false, true,0,"LO10", false, 0,0x000003ff, false), - HOWTO(RELOC_SFA_BASE,0, 2, 32, false, 0, false, true,0,"SFA_BASE", false, 0,0xffffffff, false), - HOWTO(RELOC_SFA_OFF13,0,2, 32, false, 0, false, true,0,"SFA_OFF13",false, 0,0xffffffff, false), - HOWTO(RELOC_BASE10, 0, 2, 16, false, 0, false, true,0,"BASE10", false, 0,0x0000ffff, false), - HOWTO(RELOC_BASE13, 0, 2, 13, false, 0, false, true,0,"BASE13", false, 0,0x00001fff, false), - HOWTO(RELOC_BASE22, 0, 2, 0, false, 0, false, true,0,"BASE22", false, 0,0x00000000, false), - HOWTO(RELOC_PC10, 0, 2, 10, false, 0, false, true,0,"PC10", false, 0,0x000003ff, false), - HOWTO(RELOC_PC22, 0, 2, 22, false, 0, false, true,0,"PC22", false, 0,0x003fffff, false), - HOWTO(RELOC_JMP_TBL,0, 2, 32, false, 0, false, true,0,"JMP_TBL", false, 0,0xffffffff, false), - HOWTO(RELOC_SEGOFF16,0, 2, 0, false, 0, false, true,0,"SEGOFF16", false, 0,0x00000000, false), - HOWTO(RELOC_GLOB_DAT,0, 2, 0, false, 0, false, true,0,"GLOB_DAT", false, 0,0x00000000, false), - HOWTO(RELOC_JMP_SLOT,0, 2, 0, false, 0, false, true,0,"JMP_SLOT", false, 0,0x00000000, false), - HOWTO(RELOC_RELATIVE,0, 2, 0, false, 0, false, true,0,"RELATIVE", false, 0,0x00000000, false), - HOWTO(RELOC_JUMPTARG,2, 13, 16, true, 0, false, true,0,"JUMPTARG", false, 0,0x0000ffff, false), - HOWTO(RELOC_CONST, 0, 13, 16, false, 0, false, true,0,"CONST", false, 0,0x0000ffff, false), - HOWTO(RELOC_CONSTH, 16, 13, 16, false, 0, false, true,0,"CONSTH", false, 0,0x0000ffff, false), -}; - -/* Convert standard reloc records to "arelent" format (incl byte swap). */ - -static reloc_howto_type howto_table_std[] = { - /* type rs size bsz pcrel bitpos abs ovrf sf name part_inpl readmask setmask pcdone */ -HOWTO( 0, 0, 0, 8, false, 0, true, true,0,"8", true, 0x000000ff,0x000000ff, false), -HOWTO( 1, 0, 1, 16, false, 0, true, true,0,"16", true, 0x0000ffff,0x0000ffff, false), -HOWTO( 2, 0, 2, 32, false, 0, true, true,0,"32", true, 0xffffffff,0xffffffff, false), -HOWTO( 3, 0, 3, 64, false, 0, true, true,0,"64", true, 0xdeaddead,0xdeaddead, false), -HOWTO( 4, 0, 0, 8, true, 0, false, true,0,"DISP8", true, 0x000000ff,0x000000ff, false), -HOWTO( 5, 0, 1, 16, true, 0, false, true,0,"DISP16", true, 0x0000ffff,0x0000ffff, false), -HOWTO( 6, 0, 2, 32, true, 0, false, true,0,"DISP32", true, 0xffffffff,0xffffffff, false), -HOWTO( 7, 0, 3, 64, true, 0, false, true,0,"DISP64", true, 0xfeedface,0xfeedface, false), -}; - - -bfd_error_vector_type bfd_error_vector; - -void -DEFUN(bfd_aout_swap_exec_header_in,(abfd, raw_bytes, execp), - bfd *abfd AND - unsigned char *raw_bytes AND - struct exec *execp) -{ - struct exec_bytes *bytes = (struct exec_bytes *)raw_bytes; - - /* Now fill in fields in the execp, from the bytes in the raw data. */ - execp->a_info = bfd_h_getlong (abfd, bytes->a_info); - execp->a_text = bfd_h_getlong (abfd, bytes->a_text); - execp->a_data = bfd_h_getlong (abfd, bytes->a_data); - execp->a_bss = bfd_h_getlong (abfd, bytes->a_bss); - execp->a_syms = bfd_h_getlong (abfd, bytes->a_syms); - execp->a_entry = bfd_h_getlong (abfd, bytes->a_entry); - execp->a_trsize = bfd_h_getlong (abfd, bytes->a_trsize); - execp->a_drsize = bfd_h_getlong (abfd, bytes->a_drsize); -} - -void -DEFUN(bfd_aout_swap_exec_header_out,(abfd, execp, raw_bytes), - bfd *abfd AND - struct exec *execp AND - unsigned char *raw_bytes) -{ - struct exec_bytes *bytes = (struct exec_bytes *)raw_bytes; - - /* Now fill in fields in the raw data, from the fields in the exec struct. */ - bfd_h_putlong (abfd, execp->a_info , bytes->a_info); - bfd_h_putlong (abfd, execp->a_text , bytes->a_text); - bfd_h_putlong (abfd, execp->a_data , bytes->a_data); - bfd_h_putlong (abfd, execp->a_bss , bytes->a_bss); - bfd_h_putlong (abfd, execp->a_syms , bytes->a_syms); - bfd_h_putlong (abfd, execp->a_entry , bytes->a_entry); - bfd_h_putlong (abfd, execp->a_trsize, bytes->a_trsize); - bfd_h_putlong (abfd, execp->a_drsize, bytes->a_drsize); -} - -/* Some A.OUT variant thinks that the file whose format we're checking - is an a.out file. Do some more checking, and set up for access if - it really is. Call back to the calling environment's "finish up" - function just before returning, to handle any last-minute setup. */ - -bfd_target * -some_aout_object_p (abfd, callback_to_real_object_p) - bfd *abfd; - bfd_target *(*callback_to_real_object_p) (); -{ - unsigned char exec_bytes[EXEC_BYTES_SIZE]; /* Raw bytes of exec hdr */ - struct exec *execp; - PTR rawptr; - - if (bfd_seek (abfd, 0L, false) < 0) { - bfd_error = system_call_error; - return 0; - } - - if (bfd_read ((PTR) exec_bytes, 1, EXEC_BYTES_SIZE, abfd) - != EXEC_BYTES_SIZE) { - bfd_error = wrong_format; - return 0; - } - - /* Use an intermediate variable for clarity */ - rawptr = (PTR) bfd_zalloc (abfd, sizeof (struct aoutdata) + sizeof (struct exec)); - - if (rawptr == NULL) { - bfd_error = no_memory; - return 0; - } - - set_tdata (abfd, ((struct aoutdata *) rawptr)); - exec_hdr (abfd) = execp = - (struct exec *) ((char *)rawptr + sizeof (struct aoutdata)); - - bfd_aout_swap_exec_header_in (abfd, exec_bytes, execp); - - /* Set the file flags */ - abfd->flags = NO_FLAGS; - if (execp->a_drsize || execp->a_trsize) - abfd->flags |= HAS_RELOC; - if (execp->a_entry) - abfd->flags |= EXEC_P; - if (execp->a_syms) - abfd->flags |= HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS; - - if (N_MAGIC (*execp) == ZMAGIC) abfd->flags |= D_PAGED; - if (N_MAGIC (*execp) == NMAGIC) abfd->flags |= WP_TEXT; - - bfd_get_start_address (abfd) = execp->a_entry; - - obj_aout_symbols (abfd) = (aout_symbol_type *)NULL; - bfd_get_symcount (abfd) = execp->a_syms / sizeof (struct nlist); - - /* Set the default architecture and machine type. These can be - overridden in the callback routine. */ - abfd->obj_arch = bfd_arch_unknown; - abfd->obj_machine = 0; - - /* The default relocation entry size is that of traditional V7 Unix. */ - obj_reloc_entry_size (abfd) = RELOC_STD_SIZE; - - /* create the sections. This is raunchy, but bfd_close wants to reclaim - them */ - obj_textsec (abfd) = (asection *)NULL; - obj_datasec (abfd) = (asection *)NULL; - obj_bsssec (abfd) = (asection *)NULL; - (void)bfd_make_section(abfd, ".text"); - (void)bfd_make_section(abfd, ".data"); - (void)bfd_make_section(abfd, ".bss"); - - abfd->sections = obj_textsec (abfd); - obj_textsec (abfd)->next = obj_datasec (abfd); - obj_datasec (abfd)->next = obj_bsssec (abfd); - - obj_datasec (abfd)->size = execp->a_data; - obj_bsssec (abfd)->size = execp->a_bss; - obj_textsec (abfd)->size = execp->a_text; - - if (abfd->flags & D_PAGED) { - obj_textsec (abfd)->size -= EXEC_BYTES_SIZE; - } - - - obj_textsec (abfd)->flags = (execp->a_trsize != 0 ? - (SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_HAS_CONTENTS) : - (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS)); - obj_datasec (abfd)->flags = (execp->a_drsize != 0 ? - (SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_HAS_CONTENTS) : - (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS)); - obj_bsssec (abfd)->flags = SEC_ALLOC; - -#ifdef THIS_IS_ONLY_DOCUMENTATION - /* Call back to the format-dependent code to fill in the rest of the - fields and do any further cleanup. Things that should be filled - in by the callback: */ - - struct exec *execp = exec_hdr (abfd); - - /* The virtual memory addresses of the sections */ - obj_datasec (abfd)->vma = N_DATADDR(*execp); - obj_bsssec (abfd)->vma = N_BSSADDR(*execp); - obj_textsec (abfd)->vma = N_TXTADDR(*execp); - - /* The file offsets of the sections */ - obj_textsec (abfd)->filepos = N_TXTOFF(*execp); - obj_datasec (abfd)->filepos = N_DATOFF(*execp); - - /* The file offsets of the relocation info */ - obj_textsec (abfd)->rel_filepos = N_TRELOFF(*execp); - obj_datasec (abfd)->rel_filepos = N_DRELOFF(*execp); - - /* The file offsets of the string table and symbol table. */ - obj_str_filepos (abfd) = N_STROFF (*execp); - obj_sym_filepos (abfd) = N_SYMOFF (*execp); - - /* This common code can't fill in those things because they depend - on either the start address of the text segment, the rounding - up of virtual addersses between segments, or the starting file - position of the text segment -- all of which varies among different - versions of a.out. */ - - /* Determine the architecture and machine type of the object file. */ - switch (N_MACHTYPE (*exec_hdr (abfd))) { - default: - abfd->obj_arch = bfd_arch_obscure; - break; - } - - /* Determine the size of a relocation entry */ - switch (abfd->obj_arch) { - case bfd_arch_sparc: - case bfd_arch_a29k: - obj_reloc_entry_size (abfd) = RELOC_EXT_SIZE; - default: - obj_reloc_entry_size (abfd) = RELOC_STD_SIZE; - } - - return abfd->xvec; - - /* The architecture is encoded in various ways in various a.out variants, - or is not encoded at all in some of them. The relocation size depends - on the architecture and the a.out variant. Finally, the return value - is the bfd_target vector in use. If an error occurs, return zero and - set bfd_error to the appropriate error code. - - Formats such as b.out, which have additional fields in the a.out - header, should cope with them in this callback as well. */ -#endif /* DOCUMENTATION */ - - - return (*callback_to_real_object_p)(abfd); -} - - -boolean -aout_mkobject (abfd) - bfd *abfd; -{ - char *rawptr; - - bfd_error = system_call_error; - - /* Use an intermediate variable for clarity */ - rawptr = bfd_zalloc (abfd, sizeof (struct aoutdata) + sizeof (struct exec)); - - if (rawptr == NULL) { - bfd_error = no_memory; - return false; - } - - set_tdata (abfd, (struct aoutdata *) rawptr); - exec_hdr (abfd) = (struct exec *) (rawptr + sizeof (struct aoutdata)); - - /* For simplicity's sake we just make all the sections right here. */ - - obj_textsec (abfd) = (asection *)NULL; - obj_datasec (abfd) = (asection *)NULL; - obj_bsssec (abfd) = (asection *)NULL; - bfd_make_section (abfd, ".text"); - bfd_make_section (abfd, ".data"); - bfd_make_section (abfd, ".bss"); - - return true; -} - -/* Keep track of machine architecture and machine type for a.out's. - Return the machine_type for a particular arch&machine, or M_UNKNOWN - if that exact arch&machine can't be represented in a.out format. - - If the architecture is understood, machine type 0 (default) should - always be understood. */ - -enum machine_type -aout_machine_type (arch, machine) - enum bfd_architecture arch; - unsigned long machine; -{ - enum machine_type arch_flags; - - arch_flags = M_UNKNOWN; - - switch (arch) { - case bfd_arch_sparc: - if (machine == 0) arch_flags = M_SPARC; - break; - - case bfd_arch_m68k: - switch (machine) { - case 0: arch_flags = M_68010; break; - case 68000: arch_flags = M_UNKNOWN; break; - case 68010: arch_flags = M_68010; break; - case 68020: arch_flags = M_68020; break; - default: arch_flags = M_UNKNOWN; break; - } - break; - - case bfd_arch_i386: - if (machine == 0) arch_flags = M_386; - break; - - case bfd_arch_a29k: - if (machine == 0) arch_flags = M_29K; - break; - - default: - arch_flags = M_UNKNOWN; - break; - } - return arch_flags; -} - -boolean -aout_set_arch_mach (abfd, arch, machine) - bfd *abfd; - enum bfd_architecture arch; - unsigned long machine; -{ - abfd->obj_arch = arch; - abfd->obj_machine = machine; - if (arch != bfd_arch_unknown && - aout_machine_type (arch, machine) == M_UNKNOWN) - return false; /* We can't represent this type */ - return true; /* We're easy ... */ -} - -/* exec and core file sections */ - -boolean -aout_new_section_hook (abfd, newsect) - bfd *abfd; - asection *newsect; -{ - /* align to double at least */ - newsect->alignment_power = 3; - - if (bfd_get_format (abfd) == bfd_object) { - if (obj_textsec(abfd) == NULL && !strcmp(newsect->name, ".text")) { - obj_textsec(abfd)= newsect; - return true; - } - - if (obj_datasec(abfd) == NULL && !strcmp(newsect->name, ".data")) { - obj_datasec(abfd) = newsect; - return true; - } - - if (obj_bsssec(abfd) == NULL && !strcmp(newsect->name, ".bss")) { - obj_bsssec(abfd) = newsect; - return true; - } - } - - /* We allow more than three sections internally */ - return true; -} - -boolean -aout_set_section_contents (abfd, section, location, offset, count) - bfd *abfd; - sec_ptr section; - PTR location; - file_ptr offset; - int count; -{ - if (abfd->output_has_begun == false) - { /* set by bfd.c handler */ - if ((obj_textsec (abfd) == NULL) || (obj_datasec (abfd) == NULL)) - { - bfd_error = invalid_operation; - return false; - } - - obj_textsec(abfd)->filepos = sizeof(struct exec); - obj_textsec(abfd)->size = align_power(obj_textsec(abfd)->size, - obj_textsec(abfd)->alignment_power); - obj_datasec(abfd)->filepos = obj_textsec (abfd)->size + EXEC_BYTES_SIZE; - obj_datasec(abfd)->size = align_power(obj_datasec(abfd)->size, - obj_datasec(abfd)->alignment_power); - - - } - /* regardless, once we know what we're doing, we might as well get going */ - if (section != obj_bsssec(abfd)) - { - bfd_seek (abfd, section->filepos + offset, SEEK_SET); - - if (count) { - return (bfd_write ((PTR)location, 1, count, abfd) == count) ? - true : false; - } - return false; - } - return true; -} - -/* Classify stabs symbols */ - -#define sym_in_text_section(sym) \ - (((sym)->n_type & (N_ABS | N_TEXT | N_DATA | N_BSS))== N_TEXT) - -#define sym_in_data_section(sym) \ - (((sym)->n_type & (N_ABS | N_TEXT | N_DATA | N_BSS))== N_DATA) - -#define sym_in_bss_section(sym) \ - (((sym)->n_type & (N_ABS | N_TEXT | N_DATA | N_BSS))== N_BSS) - -/* Symbol is undefined if type is N_UNDF|N_EXT and if it has - zero in the "value" field. Nonzeroes there are fortrancommon - symbols. */ -#define sym_is_undefined(sym) \ - ((sym)->n_type == (N_UNDF | N_EXT) && (sym)->n_value == 0) - -/* Symbol is a global definition if N_EXT is on and if it has - a nonzero type field. */ -#define sym_is_global_defn(sym) \ - (((sym)->n_type & N_EXT) && (sym)->n_type & N_TYPE) - -/* Symbol is debugger info if any bits outside N_TYPE or N_EXT - are on. */ -#define sym_is_debugger_info(sym) \ - ((sym)->n_type & ~(N_EXT | N_TYPE)) - -#define sym_is_fortrancommon(sym) \ - (((sym)->n_type == (N_EXT)) && (sym)->n_value != 0) - -/* Symbol is absolute if it has N_ABS set */ -#define sym_is_absolute(sym) \ - (((sym)->n_type & N_TYPE)== N_ABS) - - -#define sym_is_indirect(sym) \ - (((sym)->n_type & N_ABS)== N_ABS) - -/* Only in their own functions for ease of debugging; when sym flags have - stabilised these should be inlined into their (single) caller */ - -static void -translate_from_native_sym_flags (sym_pointer, cache_ptr, abfd) - struct nlist *sym_pointer; - aout_symbol_type *cache_ptr; - bfd *abfd; -{ - switch (cache_ptr->type & N_TYPE) { - case N_SETA: - case N_SETT: - case N_SETD: - case N_SETB: - { - asection *section = bfd_make_section(abfd, - cache_ptr->symbol.name); - arelent_chain *reloc = (arelent_chain *)bfd_alloc(abfd, sizeof(arelent_chain)); - - switch ( (cache_ptr->type & N_TYPE) ) { - case N_SETA: - reloc->relent.section = (asection *)NULL; - cache_ptr->symbol.section = (asection *)NULL; - break; - case N_SETT: - reloc->relent.section = (asection *)obj_textsec(abfd); - cache_ptr->symbol.value -= reloc->relent.section->vma; - break; - case N_SETD: - reloc->relent.section = (asection *)obj_datasec(abfd); - cache_ptr->symbol.value -= reloc->relent.section->vma; - break; - case N_SETB: - reloc->relent.section = (asection *)obj_bsssec(abfd); - cache_ptr->symbol.value -= reloc->relent.section->vma; - break; - } - cache_ptr->symbol.section = reloc->relent.section; - reloc->relent.addend = cache_ptr->symbol.value ; - - /* We modify the symbol to belong to a section depending upon the - name of the symbol - probably __CTOR__ or __DTOR__ but we don't - really care, and add to the size of the section to contain a - pointer to the symbol. Build a reloc entry to relocate to this - symbol attached to this section. */ - - section->flags = SEC_CONSTRUCTOR; - section->reloc_count++; - section->alignment_power = 2; - reloc->relent.sym_ptr_ptr = (asymbol **)NULL; - reloc->next = section->constructor_chain; - section->constructor_chain = reloc; - reloc->relent.address = section->size; - section->size += sizeof(int *); - - reloc->relent.howto = howto_table_ext +CTOR_TABLE_RELOC_IDX; - cache_ptr->symbol.flags |= BSF_DEBUGGING ; - } - break; - default: - - if (sym_is_debugger_info (sym_pointer)) { - cache_ptr->symbol.flags = BSF_DEBUGGING ; - /* Work out the section correct for this symbol */ - switch (sym_pointer->n_type & N_TYPE) - { - case N_TEXT: - case N_FN: - cache_ptr->symbol.section = obj_textsec (abfd); - cache_ptr->symbol.value -= obj_textsec(abfd)->vma; - break; - case N_DATA: - cache_ptr->symbol.value -= obj_datasec(abfd)->vma; - cache_ptr->symbol.section = obj_datasec (abfd); - break; - case N_BSS : - cache_ptr->symbol.section = obj_bsssec (abfd); - cache_ptr->symbol.value -= obj_bsssec(abfd)->vma; - break; - case N_ABS: - default: - cache_ptr->symbol.section = 0; - break; - } - } - else { - if (sym_is_fortrancommon (sym_pointer)) - { - cache_ptr->symbol.flags = BSF_FORT_COMM; - cache_ptr->symbol.section = (asection *)NULL; - } - else { - if (sym_is_undefined (sym_pointer)) { - cache_ptr->symbol.flags = BSF_UNDEFINED; - } - else if (sym_is_global_defn (sym_pointer)) { - cache_ptr->symbol.flags = BSF_GLOBAL | BSF_EXPORT; - } - - else if (sym_is_absolute (sym_pointer)) { - cache_ptr->symbol.flags = BSF_ABSOLUTE; - } - else { - cache_ptr->symbol.flags = BSF_LOCAL; - } - - /* In a.out, the value of a symbol is always relative to the - * start of the file, if this is a data symbol we'll subtract - * the size of the text section to get the section relative - * value. If this is a bss symbol (which would be strange) - * we'll subtract the size of the previous two sections - * to find the section relative address. - */ - - if (sym_in_text_section (sym_pointer)) { - cache_ptr->symbol.value -= obj_textsec(abfd)->vma; - cache_ptr->symbol.section = obj_textsec (abfd); - } - else if (sym_in_data_section (sym_pointer)){ - cache_ptr->symbol.value -= obj_datasec(abfd)->vma; - cache_ptr->symbol.section = obj_datasec (abfd); - } - else if (sym_in_bss_section(sym_pointer)) { - cache_ptr->symbol.section = obj_bsssec (abfd); - cache_ptr->symbol.value -= obj_bsssec(abfd)->vma; - } - else { - cache_ptr->symbol.section = (asection *)NULL; - cache_ptr->symbol.flags |= BSF_ABSOLUTE; - } - } - } - } -} - -void -translate_to_native_sym_flags (sym_pointer, cache_ptr_g, abfd) - struct nlist *sym_pointer; - PTR cache_ptr_g; - bfd *abfd; -{ - asymbol *cache_ptr = (asymbol *)cache_ptr_g; - - /* FIXME check for writing bss */ - if (bfd_get_section(cache_ptr)) { - if (bfd_get_output_section(cache_ptr) == obj_bsssec (abfd)) { - sym_pointer->n_type |= N_BSS; - } - else if (bfd_get_output_section(cache_ptr) == obj_datasec (abfd)) { - sym_pointer->n_type |= N_DATA; - } - else if (bfd_get_output_section(cache_ptr) == obj_textsec (abfd)) { - sym_pointer->n_type |= N_TEXT; - } - else { - bfd_error_vector.nonrepresentable_section(abfd, - bfd_get_output_section(cache_ptr)->name); - } - /* Turn the symbol from section relative to absolute again */ - sym_pointer->n_value += - cache_ptr->section->output_section->vma - + cache_ptr->section->output_offset ; - } - else { - sym_pointer->n_type |= N_ABS; - } - - if (cache_ptr->flags & (BSF_FORT_COMM | BSF_UNDEFINED)) { - sym_pointer->n_type = (N_UNDF | N_EXT); - return; - } - - if (cache_ptr->flags & BSF_ABSOLUTE) { - sym_pointer->n_type |= N_ABS; - } - - if (cache_ptr->flags & (BSF_GLOBAL | BSF_EXPORT)) { - sym_pointer->n_type |= N_EXT; - } - if (cache_ptr->flags & BSF_DEBUGGING) { - sym_pointer->n_type = ((aout_symbol_type *)cache_ptr)->type; - } -} - -/* Native-level interface to symbols. */ - -/* We read the symbols into a buffer, which is discarded when this - function exits. We read the strings into a buffer large enough to - hold them all plus all the cached symbol entries. */ - -asymbol * -aout_make_empty_symbol (abfd) -bfd *abfd; -{ - aout_symbol_type *new = - (aout_symbol_type *)bfd_zalloc (abfd, sizeof (aout_symbol_type)); - new->symbol.the_bfd = abfd; - - return &new->symbol; -} - -boolean -DEFUN(aout_slurp_symbol_table, (abfd), - bfd *abfd) -{ - size_t symbol_size; - size_t string_size; - unsigned char string_chars[LONG_SIZE]; - struct nlist *syms; - char *strings; - aout_symbol_type *cached; - - /* If there's no work to be done, don't do any */ - if (obj_aout_symbols (abfd) != (aout_symbol_type *)NULL) return true; - symbol_size = exec_hdr(abfd)->a_syms; - if (symbol_size == 0) { - bfd_error = no_symbols; - return false; - } - - bfd_seek (abfd, obj_str_filepos (abfd), SEEK_SET); - if (bfd_read ((PTR)string_chars, LONG_SIZE, 1, abfd) != LONG_SIZE) - return false; - string_size = bfd_h_getlong (abfd, string_chars); - - strings = bfd_alloc(abfd, string_size + 1); - cached = (aout_symbol_type *) - bfd_zalloc(abfd, bfd_get_symcount (abfd) * sizeof(aout_symbol_type)); - /* Alloc this last, so we can free it if obstack is in use. */ - syms = (struct nlist *) bfd_alloc(abfd, symbol_size); - - bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET); - if (bfd_read ((PTR)syms, 1, symbol_size, abfd) != symbol_size) { - bailout: - if (syms) bfd_release (abfd, syms); - if (cached) bfd_release (abfd, cached); - if (strings)bfd_release (abfd, strings); - return false; - } - - bfd_seek (abfd, obj_str_filepos (abfd), SEEK_SET); - if (bfd_read ((PTR)strings, 1, string_size, abfd) != string_size) { - goto bailout; - } - - /* OK, now walk the new symtable, cacheing symbol properties */ - { - register struct nlist *sym_pointer; - register struct nlist *sym_end = syms + bfd_get_symcount (abfd); - register aout_symbol_type *cache_ptr = cached; - - /* run through the table and byte swap if needed */ - for (sym_pointer = syms; sym_pointer < sym_end; sym_pointer++) { - sym_pointer->n_un.n_strx = - bfd_h_getlong (abfd, &sym_pointer->n_un.n_strx); - sym_pointer->n_desc = - bfd_h_getshort (abfd, &sym_pointer->n_desc); - sym_pointer->n_value = - bfd_h_getlong (abfd, &sym_pointer->n_value); - sym_pointer->n_other = (char) - bfd_h_getchar(abfd, &sym_pointer->n_other); - sym_pointer->n_type = (char) - bfd_h_getchar(abfd, &sym_pointer->n_type); - } - - /* Run through table and copy values */ - for (sym_pointer = syms, cache_ptr = cached; - sym_pointer < sym_end; sym_pointer++, cache_ptr++) - { - cache_ptr->symbol.the_bfd = abfd; - if (sym_pointer->n_un.n_strx) - cache_ptr->symbol.name = sym_pointer->n_un.n_strx + strings; - else - cache_ptr->symbol.name = (char *)NULL; - cache_ptr->symbol.value = sym_pointer->n_value; - cache_ptr->desc = sym_pointer->n_desc; - cache_ptr->other = sym_pointer->n_other; - cache_ptr->type = sym_pointer->n_type; - cache_ptr->symbol.udata = 0; - translate_from_native_sym_flags (sym_pointer, cache_ptr, abfd); - - } - } - - obj_aout_symbols (abfd) = cached; - bfd_release (abfd, (PTR)syms); - - return true; -} - - -void -DEFUN(aout_write_syms,(abfd), - bfd *abfd) -{ - unsigned int count ; - asymbol **generic = bfd_get_outsymbols (abfd); - - unsigned int stindex = sizeof(stindex); /* initial string length */ - - for (count = 0; count < bfd_get_symcount (abfd); count++) { - asymbol *g = generic[count]; - struct nlist nsp; - - if (g->name) { - unsigned int length = strlen(g->name) +1; - bfd_h_putlong (abfd, stindex, (unsigned char *)&nsp.n_un.n_strx); - stindex += length; - } - else { - bfd_h_putlong (abfd, 0, (unsigned char *)&nsp.n_un.n_strx); - } - - if (g->the_bfd->xvec->flavour == abfd->xvec->flavour) - { - nsp.n_desc = aout_symbol( g)->desc; - nsp.n_other = aout_symbol(g)->other; - nsp.n_type = aout_symbol(g)->type; - } - else - { - nsp.n_desc = 0; - nsp.n_other = 0; - nsp.n_type = 0; - } - - - nsp.n_value = g->value; - translate_to_native_sym_flags (&nsp, (PTR)g, abfd); - - - bfd_h_putshort (abfd, nsp.n_desc, (unsigned char *)&nsp.n_desc); - bfd_h_putlong (abfd, nsp.n_value, (unsigned char *)&nsp.n_value); - bfd_write((PTR)&nsp,1, sizeof(nsp), abfd); - } - - - /* Now output the strings. Be sure to put string length into correct - * byte ordering before writing it. - */ - bfd_h_putlong (abfd, stindex, (unsigned char *)&stindex); - - bfd_write((PTR)&stindex, 1, sizeof(stindex), abfd); - - generic = bfd_get_outsymbols(abfd); - for (count = 0; count < bfd_get_symcount(abfd); count++) - { - asymbol *g = *(generic++); - - if (g->name) - { - size_t length = strlen(g->name)+1; - bfd_write((PTR)g->name, 1, length, abfd); - } - if ((g->flags & BSF_FAKE)==0) { - g->name = itos(count); /* smash the generic symbol */ - } - } -} - - -void -DEFUN(aout_reclaim_symbol_table,(abfd), - bfd *abfd) -{ - -} - -unsigned int -aout_get_symtab_upper_bound (abfd) - bfd *abfd; -{ - if (!aout_slurp_symbol_table (abfd)) return 0; - - return (bfd_get_symcount (abfd)+1) * (sizeof (aout_symbol_type *)); -} - -unsigned int -aout_get_symtab (abfd, location) - bfd *abfd; - asymbol **location; -{ - unsigned int counter = 0; - aout_symbol_type *symbase; - - if (!aout_slurp_symbol_table (abfd)) return 0; - - for (symbase = obj_aout_symbols(abfd); counter++ < bfd_get_symcount (abfd);) - *(location++) = (asymbol *)( symbase++); - *location++ =0; - return bfd_get_symcount(abfd); -} - - -/* Standard reloc stuff */ -/* Output standard relocation information to a file in target byte order. */ - -void -swap_std_reloc_out (abfd, g, natptr) - bfd *abfd; - arelent *g; /* Generic relocation struct */ - struct reloc_std_bytes *natptr; -{ - int r_index; - int r_extern; - unsigned int r_length; - int r_pcrel; - int r_baserel, r_jmptable, r_relative; - unsigned int r_addend; - - bfd_h_putlong (abfd, g->address, natptr->r_address); - - r_length = g->howto->size ; /* Size as a power of two */ - r_pcrel = (int) g->howto->pc_relative; /* Relative to PC? */ - /* r_baserel, r_jmptable, r_relative??? FIXME-soon */ - r_baserel = 0; - r_jmptable = 0; - r_relative = 0; - - r_addend = g->addend; /* Start here, see how it goes */ - - /* name was clobbered by aout_write_syms to be symbol index */ - - if (g->sym_ptr_ptr != NULL) - { - if ((*(g->sym_ptr_ptr))->section) { - /* put the section offset into the addend for output */ - r_addend += (*(g->sym_ptr_ptr))->section->vma; - } - - r_index = stoi((*(g->sym_ptr_ptr))->name); - r_extern = 1; - } - else { - r_extern = 0; - if (g->section == NULL) { - /* It is possible to have a reloc with nothing, we generate an - abs + 0 */ - r_addend = 0; - r_index = N_ABS | N_EXT; - } - else if(g->section->output_section == obj_textsec(abfd)) { - r_index = N_TEXT | N_EXT; - r_addend += g->section->output_section->vma; - } - else if (g->section->output_section == obj_datasec(abfd)) { - r_index = N_DATA | N_EXT; - r_addend += g->section->output_section->vma; - } - else if (g->section->output_section == obj_bsssec(abfd)) { - r_index = N_BSS | N_EXT ; - r_addend += g->section->output_section->vma; - } - else { - BFD_ASSERT(0); - } - } - - /* now the fun stuff */ - if (abfd->xvec->header_byteorder_big_p != false) { - natptr->r_index[0] = r_index >> 16; - natptr->r_index[1] = r_index >> 8; - natptr->r_index[2] = r_index; - natptr->r_bits[0] = - (r_extern? RELOC_STD_BITS_EXTERN_BIG: 0) - | (r_pcrel? RELOC_STD_BITS_PCREL_BIG: 0) - | (r_baserel? RELOC_STD_BITS_BASEREL_BIG: 0) - | (r_jmptable? RELOC_STD_BITS_JMPTABLE_BIG: 0) - | (r_relative? RELOC_STD_BITS_RELATIVE_BIG: 0) - | (r_length << RELOC_STD_BITS_LENGTH_SH_BIG); - } else { - natptr->r_index[2] = r_index >> 16; - natptr->r_index[1] = r_index >> 8; - natptr->r_index[0] = r_index; - natptr->r_bits[0] = - (r_extern? RELOC_STD_BITS_EXTERN_LITTLE: 0) - | (r_pcrel? RELOC_STD_BITS_PCREL_LITTLE: 0) - | (r_baserel? RELOC_STD_BITS_BASEREL_LITTLE: 0) - | (r_jmptable? RELOC_STD_BITS_JMPTABLE_LITTLE: 0) - | (r_relative? RELOC_STD_BITS_RELATIVE_LITTLE: 0) - | (r_length << RELOC_STD_BITS_LENGTH_SH_LITTLE); - } -} - - -/* Extended stuff */ -/* Output extended relocation information to a file in target byte order. */ - -void -swap_ext_reloc_out (abfd, g, natptr) - bfd *abfd; - arelent *g; /* Generic relocation struct */ - register struct reloc_ext_bytes *natptr; -{ - int r_index; - int r_extern; - unsigned int r_type; - unsigned int r_addend; - - bfd_h_putlong (abfd, g->address, natptr->r_address); - - /* Find a type in the output format which matches the input howto - - at the moment we assume input format == output format FIXME!! */ - r_type = (enum reloc_type) g->howto->type; - - r_addend = g->addend; /* Start here, see how it goes */ - - /* name was clobbered by aout_write_syms to be symbol index*/ - - if (g->sym_ptr_ptr != NULL) - { - if ((*(g->sym_ptr_ptr))->section) { - /* put the section offset into the addend for output */ - r_addend += (*(g->sym_ptr_ptr))->section->vma; - } - - r_index = stoi((*(g->sym_ptr_ptr))->name); - r_extern = 1; - } - else { - r_extern = 0; - if (g->section == NULL) { - BFD_ASSERT(0); - r_index = N_ABS | N_EXT; - } - else if(g->section->output_section == obj_textsec(abfd)) { - r_index = N_TEXT | N_EXT; - r_addend += g->section->output_section->vma; - } - else if (g->section->output_section == obj_datasec(abfd)) { - r_index = N_DATA | N_EXT; - r_addend += g->section->output_section->vma; - } - else if (g->section->output_section == obj_bsssec(abfd)) { - r_index = N_BSS | N_EXT ; - r_addend += g->section->output_section->vma; - } - else { - BFD_ASSERT(0); - } - } - - /* now the fun stuff */ - if (abfd->xvec->header_byteorder_big_p != false) { - natptr->r_index[0] = r_index >> 16; - natptr->r_index[1] = r_index >> 8; - natptr->r_index[2] = r_index; - natptr->r_bits[0] = - (r_extern? RELOC_EXT_BITS_EXTERN_BIG: 0) - | (r_type << RELOC_EXT_BITS_TYPE_SH_BIG); - } else { - natptr->r_index[2] = r_index >> 16; - natptr->r_index[1] = r_index >> 8; - natptr->r_index[0] = r_index; - natptr->r_bits[0] = - (r_extern? RELOC_EXT_BITS_EXTERN_LITTLE: 0) - | (r_type << RELOC_EXT_BITS_TYPE_SH_LITTLE); - } - - bfd_h_putlong (abfd, r_addend, natptr->r_addend); -} - -#define MOVE_ADDRESS(ad) \ - if (r_extern) { \ - cache_ptr->sym_ptr_ptr = symbols + r_index; \ - cache_ptr->section = (asection *)NULL; \ - cache_ptr->addend = ad; \ - } else { \ - cache_ptr->sym_ptr_ptr = (asymbol **)NULL; \ - switch (r_index) { \ - case N_TEXT: \ - case N_TEXT | N_EXT: \ - cache_ptr->section = obj_textsec(abfd); \ - cache_ptr->addend = ad - su->textsec->vma; \ - break; \ - case N_DATA: \ - case N_DATA | N_EXT: \ - cache_ptr->section = obj_datasec(abfd); \ - cache_ptr->addend = ad - su->datasec->vma; \ - break; \ - case N_BSS: \ - case N_BSS | N_EXT: \ - cache_ptr->section = obj_bsssec(abfd); \ - cache_ptr->addend = ad - su->bsssec->vma; \ - break; \ - case N_ABS: \ - case N_ABS | N_EXT: \ - cache_ptr->section = NULL; /* No section */ \ - cache_ptr->addend = ad; /* FIXME, is this right? */ \ - BFD_ASSERT(1); \ - break; \ - default: \ - cache_ptr->section = NULL; /* No section */ \ - cache_ptr->addend = ad; /* FIXME, is this right? */ \ - BFD_ASSERT(1); \ - break; \ - } \ - } \ - -void -swap_ext_reloc_in (abfd, bytes, cache_ptr, symbols) - bfd *abfd; - struct reloc_ext_bytes *bytes; - arelent *cache_ptr; - asymbol **symbols; -{ - int r_index; - int r_extern; - unsigned int r_type; - struct aoutdata *su = (struct aoutdata *)(abfd->tdata); - - cache_ptr->address = bfd_h_getlong (abfd, bytes->r_address); - - /* now the fun stuff */ - if (abfd->xvec->header_byteorder_big_p != false) { - r_index = (bytes->r_index[0] << 16) - | (bytes->r_index[1] << 8) - | bytes->r_index[2]; - r_extern = (0 != (bytes->r_bits[0] & RELOC_EXT_BITS_EXTERN_BIG)); - r_type = (bytes->r_bits[0] & RELOC_EXT_BITS_TYPE_BIG) - >> RELOC_EXT_BITS_TYPE_SH_BIG; - } else { - r_index = (bytes->r_index[2] << 16) - | (bytes->r_index[1] << 8) - | bytes->r_index[0]; - r_extern = (0 != (bytes->r_bits[0] & RELOC_EXT_BITS_EXTERN_LITTLE)); - r_type = (bytes->r_bits[0] & RELOC_EXT_BITS_TYPE_LITTLE) - >> RELOC_EXT_BITS_TYPE_SH_LITTLE; - } - - cache_ptr->howto = howto_table_ext + r_type; - MOVE_ADDRESS(bfd_h_getlong(abfd,bytes->r_addend)); -} - -void -swap_std_reloc_in (abfd, bytes, cache_ptr, symbols) - bfd *abfd; - struct reloc_std_bytes *bytes; - arelent *cache_ptr; - asymbol **symbols; -{ - int r_index; - int r_extern; - unsigned int r_length; - int r_pcrel; - int r_baserel, r_jmptable, r_relative; - struct aoutdata *su = (struct aoutdata *)(abfd->tdata); - - cache_ptr->address = bfd_h_getlong (abfd, bytes->r_address); - - /* now the fun stuff */ - if (abfd->xvec->header_byteorder_big_p != false) { - r_index = (bytes->r_index[0] << 16) - | (bytes->r_index[1] << 8) - | bytes->r_index[2]; - r_extern = (0 != (bytes->r_bits[0] & RELOC_STD_BITS_EXTERN_BIG)); - r_pcrel = (0 != (bytes->r_bits[0] & RELOC_STD_BITS_PCREL_BIG)); - r_baserel = (0 != (bytes->r_bits[0] & RELOC_STD_BITS_BASEREL_BIG)); - r_jmptable= (0 != (bytes->r_bits[0] & RELOC_STD_BITS_JMPTABLE_BIG)); - r_relative= (0 != (bytes->r_bits[0] & RELOC_STD_BITS_RELATIVE_BIG)); - r_length = (bytes->r_bits[0] & RELOC_STD_BITS_LENGTH_BIG) - >> RELOC_STD_BITS_LENGTH_SH_BIG; - } else { - r_index = (bytes->r_index[2] << 16) - | (bytes->r_index[1] << 8) - | bytes->r_index[0]; - r_extern = (0 != (bytes->r_bits[0] & RELOC_STD_BITS_EXTERN_LITTLE)); - r_pcrel = (0 != (bytes->r_bits[0] & RELOC_STD_BITS_PCREL_LITTLE)); - r_baserel = (0 != (bytes->r_bits[0] & RELOC_STD_BITS_BASEREL_LITTLE)); - r_jmptable= (0 != (bytes->r_bits[0] & RELOC_STD_BITS_JMPTABLE_LITTLE)); - r_relative= (0 != (bytes->r_bits[0] & RELOC_STD_BITS_RELATIVE_LITTLE)); - r_length = (bytes->r_bits[0] & RELOC_STD_BITS_LENGTH_LITTLE) - >> RELOC_STD_BITS_LENGTH_SH_LITTLE; - } - - cache_ptr->howto = howto_table_std + r_length + 4 * r_pcrel; - /* FIXME-soon: Roll baserel, jmptable, relative bits into howto setting */ - - MOVE_ADDRESS(0); -} - -/* Reloc hackery */ - -boolean -aout_slurp_reloc_table (abfd, asect, symbols) - bfd *abfd; - sec_ptr asect; - asymbol **symbols; -{ - unsigned int count; - size_t reloc_size; - PTR relocs; - arelent *reloc_cache; - size_t each_size; - - if (asect->relocation) return true; - - if (asect->flags & SEC_CONSTRUCTOR) return true; - - if (asect == obj_datasec (abfd)) { - reloc_size = exec_hdr(abfd)->a_drsize; - goto doit; - } - - if (asect == obj_textsec (abfd)) { - reloc_size = exec_hdr(abfd)->a_trsize; - goto doit; - } - - bfd_error = invalid_operation; - return false; - - doit: - bfd_seek (abfd, asect->rel_filepos, SEEK_SET); - each_size = obj_reloc_entry_size (abfd); - - count = reloc_size / each_size; - - - reloc_cache = (arelent *) bfd_zalloc (abfd, (size_t)(count * sizeof - (arelent))); - if (!reloc_cache) { -nomem: - bfd_error = no_memory; - return false; - } - - relocs = bfd_alloc (abfd, reloc_size); - if (!relocs) { - bfd_release (abfd, reloc_cache); - goto nomem; - } - - if (bfd_read (relocs, 1, reloc_size, abfd) != reloc_size) { - bfd_release (abfd, relocs); - bfd_release (abfd, reloc_cache); - bfd_error = system_call_error; - return false; - } - - if (each_size == RELOC_EXT_SIZE) { - register struct reloc_ext_bytes *rptr = (struct reloc_ext_bytes *) relocs; - unsigned int counter = 0; - arelent *cache_ptr = reloc_cache; - - for (; counter < count; counter++, rptr++, cache_ptr++) { - swap_ext_reloc_in(abfd, rptr, cache_ptr, symbols); - } - } else { - register struct reloc_std_bytes *rptr = (struct reloc_std_bytes *) relocs; - unsigned int counter = 0; - arelent *cache_ptr = reloc_cache; - - for (; counter < count; counter++, rptr++, cache_ptr++) { - swap_std_reloc_in(abfd, rptr, cache_ptr, symbols); - } - - } - - bfd_release (abfd,relocs); - asect->relocation = reloc_cache; - asect->reloc_count = count; - return true; -} - - - -/* Write out a relocation section into an object file. */ - -boolean -aout_squirt_out_relocs (abfd, section) - bfd *abfd; - asection *section; -{ - arelent **generic; - unsigned char *native, *natptr; - size_t each_size; - - unsigned int count = section->reloc_count; - size_t natsize; - - if (count == 0) return true; - - each_size = obj_reloc_entry_size (abfd); - natsize = each_size * count; - native = (unsigned char *) bfd_zalloc (abfd, natsize); - if (!native) { - bfd_error = no_memory; - return false; - } - - generic = section->orelocation; - - if (each_size == RELOC_EXT_SIZE) - { - for (natptr = native; - count != 0; - --count, natptr += each_size, ++generic) - swap_ext_reloc_out (abfd, *generic, (struct reloc_ext_bytes *)natptr); - } - else - { - for (natptr = native; - count != 0; - --count, natptr += each_size, ++generic) - swap_std_reloc_out(abfd, *generic, (struct reloc_std_bytes *)natptr); - } - - if ( bfd_write ((PTR) native, 1, natsize, abfd) != natsize) { - bfd_release(abfd, native); - return false; - } - bfd_release (abfd, native); - - return true; -} - -/* This is stupid. This function should be a boolean predicate */ -unsigned int -aout_canonicalize_reloc (abfd, section, relptr, symbols) - bfd *abfd; - sec_ptr section; - arelent **relptr; - asymbol **symbols; -{ - arelent *tblptr = section->relocation; - unsigned int count; - - if (!(tblptr || aout_slurp_reloc_table (abfd, section, symbols))) - return 0; - - if (section->flags & SEC_CONSTRUCTOR) { - arelent_chain *chain = section->constructor_chain; - for (count = 0; count < section->reloc_count; count ++) { - *relptr ++ = &chain->relent; - chain = chain->next; - } - } - else { - tblptr = section->relocation; - if (!tblptr) return 0; - - for (count = 0; count++ < section->reloc_count;) - { - *relptr++ = tblptr++; - } - } - *relptr = 0; - - return section->reloc_count; -} - -unsigned int -aout_get_reloc_upper_bound (abfd, asect) - bfd *abfd; - sec_ptr asect; -{ - if (bfd_get_format (abfd) != bfd_object) { - bfd_error = invalid_operation; - return 0; - } - if (asect->flags & SEC_CONSTRUCTOR) { - return (sizeof (arelent *) * (asect->reloc_count+1)); - } - - - if (asect == obj_datasec (abfd)) - return (sizeof (arelent *) * - ((exec_hdr(abfd)->a_drsize / obj_reloc_entry_size (abfd)) - +1)); - - if (asect == obj_textsec (abfd)) - return (sizeof (arelent *) * - ((exec_hdr(abfd)->a_trsize / obj_reloc_entry_size (abfd)) - +1)); - - bfd_error = invalid_operation; - return 0; -} - -void -aout_reclaim_reloc (ignore_abfd, ignore) - bfd *ignore_abfd; - sec_ptr ignore; -{ - -} - - -alent * -aout_get_lineno(ignore_abfd, ignore_symbol) -bfd *ignore_abfd; -asymbol *ignore_symbol; -{ -return (alent *)NULL; -} - -void -aout_print_symbol(ignore_abfd, afile, symbol, how) -bfd *ignore_abfd; -PTR afile; -asymbol *symbol; -bfd_print_symbol_enum_type how; -{ - FILE *file = (FILE *)afile; - - switch (how) { - case bfd_print_symbol_name_enum: - fprintf(file,"%s", symbol->name); - break; - case bfd_print_symbol_type_enum: - fprintf(file,"%4x %2x %2x",(unsigned)(aout_symbol(symbol)->desc & 0xffff), - (unsigned)(aout_symbol(symbol)->other & 0xff), - (unsigned)(aout_symbol(symbol)->type)); - break; - case bfd_print_symbol_all_enum: - { - CONST char *section_name = symbol->section == (asection *)NULL ? - "*abs" : symbol->section->name; - - bfd_print_symbol_vandf((PTR)file,symbol); - - fprintf(file," %-5s %04x %02x %02x %s", - section_name, - (unsigned)(aout_symbol(symbol)->desc & 0xffff), - (unsigned)(aout_symbol(symbol)->other & 0xff), - (unsigned)(aout_symbol(symbol)->type & 0xff), - symbol->name); - } - break; - } -} - -/* - provided a bfd, a section and an offset into the section, calculate - and return the name of the source file and the line nearest to the - wanted location. -*/ - -boolean -DEFUN(aout_find_nearest_line,(abfd, - section, - symbols, - offset, - filename_ptr, - functionname_ptr, - line_ptr), - bfd *abfd AND - asection *section AND - asymbol **symbols AND - bfd_vma offset AND - CONST char **filename_ptr AND - CONST char **functionname_ptr AND - unsigned int *line_ptr) -{ - /* Run down the file looking for the filename, function and linenumber */ - asymbol **p; - static char buffer[100]; - bfd_vma high_line_vma = ~0; - bfd_vma low_func_vma = 0; - asymbol *func = 0; - *filename_ptr = abfd->filename; - *functionname_ptr = 0; - *line_ptr = 0; - if (symbols != (asymbol **)NULL) { - for (p = symbols; *p; p++) { - aout_symbol_type *q = (aout_symbol_type *)(*p); - switch (q->type){ - case N_SO: - *filename_ptr = q->symbol.name; - if (obj_textsec(abfd) != section) { - return true; - } - break; - case N_SLINE: - - case N_DSLINE: - case N_BSLINE: - /* We'll keep this if it resolves nearer than the one we have already */ - if (q->symbol.value >= offset && - q->symbol.value < high_line_vma) { - *line_ptr = q->desc; - high_line_vma = q->symbol.value; - } - break; - case N_FUN: - { - /* We'll keep this if it is nearer than the one we have already */ - if (q->symbol.value >= low_func_vma && - q->symbol.value <= offset) { - low_func_vma = q->symbol.value; - func = (asymbol *)q; - } - if (*line_ptr && func) { - CONST char *function = func->name; - char *p; - strncpy(buffer, function, sizeof(buffer)-1); - buffer[sizeof(buffer)-1] = 0; - /* Have to remove : stuff */ - p = strchr(buffer,':'); - if (p != NULL) {*p = NULL; } - *functionname_ptr = buffer; - return true; - - } - } - break; - } - } - } - - return true; - -} - -int -DEFUN(aout_sizeof_headers,(ignore_abfd), - bfd *ignore_abfd) -{ - return 0; /* FIXME, this is the wrong value! */ -} diff --git a/bfd/aout32.c b/bfd/aout32.c deleted file mode 100644 index a3727168b1e..00000000000 --- a/bfd/aout32.c +++ /dev/null @@ -1,4 +0,0 @@ - -#define ARCH_SIZE 32 - -#include "aoutx.h" diff --git a/bfd/aout64.c b/bfd/aout64.c deleted file mode 100644 index ad975088755..00000000000 --- a/bfd/aout64.c +++ /dev/null @@ -1,5 +0,0 @@ -#ifdef TARGET_64_BIT -#define ARCH_SIZE 64 -#include "aoutx.h" -#endif - diff --git a/bfd/aoutf1.h b/bfd/aoutf1.h deleted file mode 100644 index d6f28a3fc95..00000000000 --- a/bfd/aoutf1.h +++ /dev/null @@ -1,647 +0,0 @@ -/* A.out "format 1" file handling code - Copyright (C) 1990-1991 Free Software Foundation, Inc. - Written by Cygnus Support. - -This file is part of BFD, the Binary File Descriptor library. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include "bfd.h" -#include "sysdep.h" -#include "libbfd.h" - -#include -#include "libaout.h" - -#include "aout64.h" -#include "stab.gnu.h" -#include "ar.h" - -/* -The file @code{aoutf1.h} contains the code for BFD's -a.out back end. Control over the generated back end is given by these -two preprocessor names: -@table @code -@item ARCH_SIZE -This value should be either 32 or 64, depending upon the size of an -int in the target format. It changes the sizes of the structs which -perform the memory/disk mapping of structures. - -The 64 bit backend may only be used if the host compiler supports 64 -ints (eg long long with gcc), by defining the name @code{HOST_64_BIT} in @code{bfd.h}. -With this name defined, @emph{all} bfd operations are performed with 64bit -arithmetic, not just those to a 64bit target. - -@item TARGETNAME -The name put into the target vector. -@item -@end table - -*/ - -void (*bfd_error_trap)(); - -static bfd_target *sunos4_callback (); - -/*SUPPRESS558*/ -/*SUPPRESS529*/ - -bfd_target * -DEFUN(NAME(sunos,object_p), (abfd), - bfd *abfd) -{ - struct external_exec exec_bytes; /* Raw exec header from file */ - struct internal_exec exec; /* Cleaned-up exec header */ - - if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd) - != EXEC_BYTES_SIZE) { - bfd_error = wrong_format; - return 0; - } - - exec.a_info = bfd_h_get_32 (abfd, exec_bytes.e_info); - - if (N_BADMAG (exec)) return 0; - - NAME(aout,swap_exec_header_in)(abfd, &exec_bytes, &exec); - - return NAME(aout,some_aout_object_p) (abfd, &exec, sunos4_callback); -} - - /* Determine the size of a relocation entry, based on the architecture */ -static void -DEFUN(choose_reloc_size,(abfd), -bfd *abfd) -{ - switch (bfd_get_arch(abfd)) { - case bfd_arch_sparc: - case bfd_arch_a29k: - obj_reloc_entry_size (abfd) = RELOC_EXT_SIZE; - break; - default: - obj_reloc_entry_size (abfd) = RELOC_STD_SIZE; - break; - } -} - -/* Set parameters about this a.out file that are machine-dependent. - This routine is called from some_aout_object_p just before it returns. */ - -static bfd_target * -sunos4_callback (abfd) - bfd *abfd; -{ - struct internal_exec *execp = exec_hdr (abfd); - enum bfd_architecture arch; - long machine; - - WORK_OUT_FILE_POSITIONS(abfd, execp); - - /* Determine the architecture and machine type of the object file. */ - switch (N_MACHTYPE (*exec_hdr (abfd))) { - - case M_UNKNOWN: - arch = bfd_arch_unknown; - machine = 0; - break; - - case M_68010: - case M_HP200: - arch = bfd_arch_m68k; - machine = 68010; - break; - - case M_68020: - case M_HP300: - arch = bfd_arch_m68k; - machine = 68020; - break; - - case M_SPARC: - arch = bfd_arch_sparc; - machine = 0; - break; - - case M_386: - arch = bfd_arch_i386; - machine = 0; - break; - - case M_29K: - arch = bfd_arch_a29k; - machine = 0; - break; - - case M_HPUX: - arch = bfd_arch_m68k; - machine = 0; - break; - - default: - arch = bfd_arch_obscure; - machine = 0; - break; - } - bfd_set_arch_mach(abfd, arch, machine); - choose_reloc_size(abfd); - adata(abfd)->page_size = PAGE_SIZE; -#ifdef SEGMENT_SIZE - adata(abfd)->segment_size = SEGMENT_SIZE; -#else - adata(abfd)->segment_size = PAGE_SIZE; -#endif - adata(abfd)->exec_bytes_size = EXEC_BYTES_SIZE; - - return abfd->xvec; -} - - -static boolean -DEFUN(sunos_mkobject,(abfd), - bfd *abfd) -{ - if (NAME(aout,mkobject)(abfd) == false) - return false; - adata(abfd)->page_size = PAGE_SIZE; -#ifdef SEGMENT_SIZE - adata(abfd)->page_size = SEGMENT_SIZE; -#else - adata(abfd)->segment_size = PAGE_SIZE; -#endif - adata(abfd)->exec_bytes_size = EXEC_BYTES_SIZE; - return true; -} - -/* Write an object file in SunOS format. - Section contents have already been written. We write the - file header, symbols, and relocation. */ - -boolean -DEFUN(NAME(aout,sunos4_write_object_contents), - (abfd), - bfd *abfd) -{ - bfd_size_type data_pad = 0; - struct external_exec exec_bytes; - struct internal_exec *execp = exec_hdr (abfd); - - execp->a_text = obj_textsec (abfd)->size; - - /* Magic number, maestro, please! */ - switch (bfd_get_arch(abfd)) { - case bfd_arch_m68k: - switch (bfd_get_mach(abfd)) { - case 68010: - N_SET_MACHTYPE(*execp, M_68010); - break; - default: - case 68020: - N_SET_MACHTYPE(*execp, M_68020); - break; - } - break; - case bfd_arch_sparc: - N_SET_MACHTYPE(*execp, M_SPARC); - break; - case bfd_arch_i386: - N_SET_MACHTYPE(*execp, M_386); - break; - case bfd_arch_a29k: - N_SET_MACHTYPE(*execp, M_29K); - break; - default: - N_SET_MACHTYPE(*execp, M_UNKNOWN); - } - - choose_reloc_size(abfd); - - /* FIXME */ - N_SET_FLAGS (*execp, 0x1); - - WRITE_HEADERS(abfd, execp); - - return true; -} - -/* core files */ - -#define CORE_MAGIC 0x080456 -#define CORE_NAMELEN 16 - -/* The core structure is taken from the Sun documentation. - Unfortunately, they don't document the FPA structure, or at least I - can't find it easily. Fortunately the core header contains its own - length. So this shouldn't cause problems, except for c_ucode, which - so far we don't use but is easy to find with a little arithmetic. */ - -/* But the reg structure can be gotten from the SPARC processor handbook. - This really should be in a GNU include file though so that gdb can use - the same info. */ -struct regs { - int r_psr; - int r_pc; - int r_npc; - int r_y; - int r_g1; - int r_g2; - int r_g3; - int r_g4; - int r_g5; - int r_g6; - int r_g7; - int r_o0; - int r_o1; - int r_o2; - int r_o3; - int r_o4; - int r_o5; - int r_o6; - int r_o7; -}; - -/* Taken from Sun documentation: */ - -/* FIXME: It's worse than we expect. This struct contains TWO substructs - neither of whose size we know, WITH STUFF IN BETWEEN THEM! We can't - even portably access the stuff in between! */ - -struct external_sparc_core { - int c_magic; /* Corefile magic number */ - int c_len; /* Sizeof (struct core) */ -#define SPARC_CORE_LEN 432 - int c_regs[19]; /* General purpose registers -- MACHDEP SIZE */ - struct external_exec c_aouthdr; /* A.out header */ - int c_signo; /* Killing signal, if any */ - int c_tsize; /* Text size (bytes) */ - int c_dsize; /* Data size (bytes) */ - int c_ssize; /* Stack size (bytes) */ - char c_cmdname[CORE_NAMELEN + 1]; /* Command name */ - double fp_stuff[1]; /* external FPU state (size unknown by us) */ - /* The type "double" is critical here, for alignment. - SunOS declares a struct here, but the struct's alignment - is double since it contains doubles. */ - int c_ucode; /* Exception no. from u_code */ - /* (this member is not accessible by name since we don't - portably know the size of fp_stuff.) */ -}; - -struct external_sun3_core { - int c_magic; /* Corefile magic number */ - int c_len; /* Sizeof (struct core) */ -#define SUN3_CORE_LEN 826 /* As of SunOS 4.1.1 */ - int c_regs[18]; /* General purpose registers -- MACHDEP SIZE */ - struct external_exec c_aouthdr; /* A.out header */ - int c_signo; /* Killing signal, if any */ - int c_tsize; /* Text size (bytes) */ - int c_dsize; /* Data size (bytes) */ - int c_ssize; /* Stack size (bytes) */ - char c_cmdname[CORE_NAMELEN + 1]; /* Command name */ - double fp_stuff[1]; /* external FPU state (size unknown by us) */ - /* The type "double" is critical here, for alignment. - SunOS declares a struct here, but the struct's alignment - is double since it contains doubles. */ - int c_ucode; /* Exception no. from u_code */ - /* (this member is not accessible by name since we don't - portably know the size of fp_stuff.) */ -}; - -struct internal_sunos_core { - int c_magic; /* Corefile magic number */ - int c_len; /* Sizeof (struct core) */ - long c_regs_pos; /* file offset of General purpose registers */ - int c_regs_size; /* size of General purpose registers */ - struct internal_exec c_aouthdr; /* A.out header */ - int c_signo; /* Killing signal, if any */ - int c_tsize; /* Text size (bytes) */ - int c_dsize; /* Data size (bytes) */ - int c_ssize; /* Stack size (bytes) */ - long c_stacktop; /* Stack top (address) */ - char c_cmdname[CORE_NAMELEN + 1]; /* Command name */ - long fp_stuff_pos; /* file offset of external FPU state (regs) */ - int fp_stuff_size; /* Size of it */ - int c_ucode; /* Exception no. from u_code */ -}; - -/* byte-swap in the Sun-3 core structure */ -static void -DEFUN(swapcore_sun3,(abfd, ext, intcore), - bfd *abfd AND - char *ext AND - struct internal_sunos_core *intcore) -{ - struct external_sun3_core *extcore = (struct external_sun3_core *)ext; - - intcore->c_magic = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_magic); - intcore->c_len = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_len ); - intcore->c_regs_pos = (long) (((struct external_sun3_core *)0)->c_regs); - intcore->c_regs_size = sizeof (extcore->c_regs); - NAME(aout,swap_exec_header_in)(abfd, &extcore->c_aouthdr,&intcore->c_aouthdr); - intcore->c_signo = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_signo); - intcore->c_tsize = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_tsize); - intcore->c_dsize = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_dsize); - intcore->c_ssize = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_ssize); - bcopy (extcore->c_cmdname, intcore->c_cmdname, sizeof (intcore->c_cmdname)); - intcore->fp_stuff_pos = (long) (((struct external_sun3_core *)0)->fp_stuff); - /* FP stuff takes up whole rest of struct, except c_ucode. */ - intcore->fp_stuff_size = intcore->c_len - (sizeof extcore->c_ucode) - - (file_ptr)(((struct external_sun3_core *)0)->fp_stuff); - /* Ucode is the last thing in the struct -- just before the end */ - intcore->c_ucode = - bfd_h_get_32 (abfd, - intcore->c_len - sizeof (extcore->c_ucode) + (unsigned char *)extcore); - intcore->c_stacktop = 0x0E000000; /* By experimentation */ -} - - -/* byte-swap in the Sparc core structure */ -static void -DEFUN(swapcore_sparc,(abfd, ext, intcore), - bfd *abfd AND - char *ext AND - struct internal_sunos_core *intcore) -{ - struct external_sparc_core *extcore = (struct external_sparc_core *)ext; - - intcore->c_magic = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_magic); - intcore->c_len = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_len ); - intcore->c_regs_pos = (long) (((struct external_sparc_core *)0)->c_regs); - intcore->c_regs_size = sizeof (extcore->c_regs); - NAME(aout,swap_exec_header_in)(abfd, &extcore->c_aouthdr,&intcore->c_aouthdr); - intcore->c_signo = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_signo); - intcore->c_tsize = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_tsize); - intcore->c_dsize = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_dsize); - intcore->c_ssize = bfd_h_get_32 (abfd, (unsigned char *)&extcore->c_ssize); - bcopy (extcore->c_cmdname, intcore->c_cmdname, sizeof (intcore->c_cmdname)); - intcore->fp_stuff_pos = (long) (((struct external_sparc_core *)0)->fp_stuff); - /* FP stuff takes up whole rest of struct, except c_ucode. */ - intcore->fp_stuff_size = intcore->c_len - (sizeof extcore->c_ucode) - - (file_ptr)(((struct external_sparc_core *)0)->fp_stuff); - /* Ucode is the last thing in the struct -- just before the end */ - intcore->c_ucode = - bfd_h_get_32 (abfd, - intcore->c_len - sizeof (extcore->c_ucode) + (unsigned char *)extcore); - /* Supposedly the user stack grows downward from the bottom of kernel memory. - Presuming that this remains true, this definition will work. */ -#define SPARC_USRSTACK (-(128*1024*1024)) - intcore->c_stacktop = SPARC_USRSTACK; /* By experimentation */ -} - -/* need this cast because ptr is really void * */ -#define core_hdr(bfd) (((struct suncoredata *) (bfd->tdata))->hdr) -#define core_datasec(bfd) (((struct suncoredata *) ((bfd)->tdata))->data_section) -#define core_stacksec(bfd) (((struct suncoredata*)((bfd)->tdata))->stack_section) -#define core_regsec(bfd) (((struct suncoredata *) ((bfd)->tdata))->reg_section) -#define core_reg2sec(bfd) (((struct suncoredata *) ((bfd)->tdata))->reg2_section) - -/* These are stored in the bfd's tdata */ -struct suncoredata { - struct internal_sunos_core *hdr; /* core file header */ - asection *data_section; - asection *stack_section; - asection *reg_section; - asection *reg2_section; -}; - -static bfd_target * -DEFUN(sunos4_core_file_p,(abfd), - bfd *abfd) -{ - unsigned char longbuf[4]; /* Raw bytes of various header fields */ - int core_size; - int core_mag; - struct internal_sunos_core *core; - char *extcore; - struct mergem { - struct suncoredata suncoredata; - struct internal_sunos_core internal_sunos_core; - char external_core[1]; - } *mergem; - - bfd_error = system_call_error; - - if (bfd_read ((PTR)longbuf, 1, sizeof (longbuf), abfd) != - sizeof (longbuf)) - return 0; - core_mag = bfd_h_get_32 (abfd, longbuf); - - if (core_mag != CORE_MAGIC) return 0; - - /* SunOS core headers can vary in length; second word is size; */ - if (bfd_read ((PTR)longbuf, 1, sizeof (longbuf), abfd) != - sizeof (longbuf)) - return 0; - core_size = bfd_h_get_32 (abfd, longbuf); - /* Sanity check */ - if (core_size > 20000) - return 0; - - if (bfd_seek (abfd, 0L, false) < 0) return 0; - - mergem = (struct mergem *)bfd_zalloc (abfd, core_size + sizeof (struct mergem)); - if (mergem == NULL) { - bfd_error = no_memory; - return 0; - } - - extcore = mergem->external_core; - - if ((bfd_read ((PTR) extcore, 1, core_size, abfd)) != core_size) { - bfd_error = system_call_error; - bfd_release (abfd, (char *)mergem); - return 0; - } - - /* Validate that it's a core file we know how to handle, due to sun - botching the positioning of registers and other fields in a machine - dependent way. */ - core = &mergem->internal_sunos_core; - switch (core_size) { - case SPARC_CORE_LEN: - swapcore_sparc (abfd, extcore, core); - break; - case SUN3_CORE_LEN: - swapcore_sun3 (abfd, extcore, core); - break; - default: - bfd_error = system_call_error; /* FIXME */ - bfd_release (abfd, (char *)mergem); - return 0; - } - - set_tdata (abfd, &mergem->suncoredata); - core_hdr (abfd) = core; - - /* create the sections. This is raunchy, but bfd_close wants to reclaim - them */ - core_stacksec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection)); - if (core_stacksec (abfd) == NULL) { - loser: - bfd_error = no_memory; - bfd_release (abfd, (char *)mergem); - return 0; - } - core_datasec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection)); - if (core_datasec (abfd) == NULL) { - loser1: - bfd_release (abfd, core_stacksec (abfd)); - goto loser; - } - core_regsec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection)); - if (core_regsec (abfd) == NULL) { - loser2: - bfd_release (abfd, core_datasec (abfd)); - goto loser1; - } - core_reg2sec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection)); - if (core_reg2sec (abfd) == NULL) { - bfd_release (abfd, core_regsec (abfd)); - goto loser2; - } - - core_stacksec (abfd)->name = ".stack"; - core_datasec (abfd)->name = ".data"; - core_regsec (abfd)->name = ".reg"; - core_reg2sec (abfd)->name = ".reg2"; - - core_stacksec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS; - core_datasec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS; - core_regsec (abfd)->flags = SEC_ALLOC + SEC_HAS_CONTENTS; - core_reg2sec (abfd)->flags = SEC_ALLOC + SEC_HAS_CONTENTS; - - core_stacksec (abfd)->size = core->c_ssize; - core_datasec (abfd)->size = core->c_dsize; - core_regsec (abfd)->size = core->c_regs_size; - core_reg2sec (abfd)->size = core->fp_stuff_size; - - core_stacksec (abfd)->vma = (core->c_stacktop - core->c_ssize); - core_datasec (abfd)->vma = N_DATADDR(core->c_aouthdr); - core_regsec (abfd)->vma = 0; - core_reg2sec (abfd)->vma = 0; - - core_stacksec (abfd)->filepos = core->c_len + core->c_dsize; - core_datasec (abfd)->filepos = core->c_len; - /* We'll access the regs afresh in the core file, like any section: */ - core_regsec (abfd)->filepos = (file_ptr)core->c_regs_pos; - core_reg2sec (abfd)->filepos = (file_ptr)core->fp_stuff_pos; - - /* Align to word at least */ - core_stacksec (abfd)->alignment_power = 2; - core_datasec (abfd)->alignment_power = 2; - core_regsec (abfd)->alignment_power = 2; - core_reg2sec (abfd)->alignment_power = 2; - - abfd->sections = core_stacksec (abfd); - core_stacksec (abfd)->next = core_datasec (abfd); - core_datasec (abfd)->next = core_regsec (abfd); - core_regsec (abfd)->next = core_reg2sec (abfd); - - abfd->section_count = 4; - - return abfd->xvec; -} - -static char *sunos4_core_file_failing_command (abfd) -bfd *abfd; - { - return core_hdr (abfd)->c_cmdname; -} - -static int -DEFUN(sunos4_core_file_failing_signal,(abfd), - bfd *abfd) -{ - return core_hdr (abfd)->c_signo; -} - -static boolean -DEFUN(sunos4_core_file_matches_executable_p, (core_bfd, exec_bfd), - bfd *core_bfd AND - bfd *exec_bfd) -{ - if (core_bfd->xvec != exec_bfd->xvec) { - bfd_error = system_call_error; - return false; - } - - return (bcmp ((char *)&core_hdr (core_bfd)->c_aouthdr, - (char *) exec_hdr (exec_bfd), - sizeof (struct internal_exec)) == 0) ? true : false; -} - -/* We use BFD generic archive files. */ -#define aout_32_openr_next_archived_file bfd_generic_openr_next_archived_file -#define aout_32_generic_stat_arch_elt bfd_generic_stat_arch_elt -#define aout_32_slurp_armap bfd_slurp_bsd_armap -#define aout_32_slurp_extended_name_table bfd_true -#define aout_32_write_armap bsd_write_armap -#define aout_32_truncate_arname bfd_bsd_truncate_arname -#define aout_32_machine_type sunos_machine_type - -#define aout_32_core_file_failing_command sunos4_core_file_failing_command -#define aout_32_core_file_failing_signal sunos4_core_file_failing_signal -#define aout_32_core_file_matches_executable_p sunos4_core_file_matches_executable_p - - -#define aout_64_openr_next_archived_file bfd_generic_openr_next_archived_file -#define aout_64_generic_stat_arch_elt bfd_generic_stat_arch_elt -#define aout_64_slurp_armap bfd_slurp_bsd_armap -#define aout_64_slurp_extended_name_table bfd_true -#define aout_64_write_armap bsd_write_armap -#define aout_64_truncate_arname bfd_bsd_truncate_arname -#define aout_64_machine_type sunos_machine_type - -#define aout_64_core_file_failing_command sunos4_core_file_failing_command -#define aout_64_core_file_failing_signal sunos4_core_file_failing_signal -#define aout_64_core_file_matches_executable_p sunos4_core_file_matches_executable_p - -#define aout_64_bfd_debug_info_start bfd_void -#define aout_64_bfd_debug_info_end bfd_void -#define aout_64_bfd_debug_info_accumulate bfd_void - -#define aout_32_bfd_debug_info_start bfd_void -#define aout_32_bfd_debug_info_end bfd_void -#define aout_32_bfd_debug_info_accumulate (PROTO(void,(*),(bfd*, struct sec *))) bfd_void - - - -/* We implement these routines ourselves, rather than using the generic -a.out versions. */ -#define aout_write_object_contents sunos4_write_object_contents - -bfd_target VECNAME = - { - TARGETNAME, - bfd_target_aout_flavour, - true, /* target byte order */ - true, /* target headers byte order */ - (HAS_RELOC | EXEC_P | /* object flags */ - HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED), - (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ - ' ', /* ar_pad_char */ - 16, /* ar_max_namelen */ - 3, /* minimum alignment power */ - _do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* data */ - _do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* hdrs */ - - {_bfd_dummy_target, NAME(sunos,object_p), - bfd_generic_archive_p, sunos4_core_file_p}, - {bfd_false, sunos_mkobject, - _bfd_generic_mkarchive, bfd_false}, - {bfd_false, NAME(aout,sunos4_write_object_contents), /* bfd_write_contents */ - _bfd_write_archive_contents, bfd_false}, - - JUMP_TABLE(JNAME(aout)) - }; diff --git a/bfd/aoutx.c b/bfd/aoutx.c deleted file mode 100755 index e69de29bb2d..00000000000 diff --git a/bfd/aoutx.h b/bfd/aoutx.h deleted file mode 100644 index 16208468fc5..00000000000 --- a/bfd/aoutx.h +++ /dev/null @@ -1,1711 +0,0 @@ -/* BFD semi-generic back-end for a.out binaries - Copyright (C) 1990-1991 Free Software Foundation, Inc. - Written by Cygnus Support. - -This file is part of BFD, the Binary File Descriptor library. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/*doc* -@section a.out backends - -BFD supports a number of different flavours of a.out format, though -the major differences are only the sizes of the structures on disk, -and the shape of the relocation information. - -The support is split into a basic support file @code{aoutx.h} and -other files which derive functions from the base. One derivation file -is @code{aoutf1.h} (for a.out flavour 1), and adds to the basic a.out -functions support for sun3, sun4, 386 and 29k a.out files, to create a -target jump vector for a specific target. - -This information is further split out into more specific files for each -machine, including @code{sunos.c} for sun3 and sun4, @code{newsos3.c} for -the Sony NEWS, and @code{demo64.c} for a demonstration of a 64 bit a.out -format. - -The base file @code{aoutx.h} defines general mechanisms for reading -and writing records to and from disk, and various other methods which -BFD requires. It is included by @code{aout32.c} and @code{aout64.c} to -form the names aout_32_swap_exec_header_in, -aout_64_swap_exec_header_in, etc. - -As an example, this is what goes on to make the back end for a sun4, from aout32.c - -@example - #define ARCH_SIZE 32 - #include "aoutx.h" -@end example - -Which exports names: -@example - ... - aout_32_canonicalize_reloc - aout_32_find_nearest_line - aout_32_get_lineno - aout_32_get_reloc_upper_bound - ... -@end example - -from sunos.c - -@example - #define ARCH 32 - #define TARGET_NAME "a.out-sunos-big" - #define VECNAME sunos_big_vec - #include "aoutf1.h" -@end example -requires all the names from aout32.c, and produces the jump vector - -@example - sunos_big_vec -@end example - -The file host-aout.c is a special case. It is for a large set of hosts -that use ``more or less standard'' a.out files, and for which cross-debugging -is not interesting. It uses the standard 32-bit a.out support routines, -but determines the file offsets and addresses of the text, data, -and BSS sections, the machine architecture and machine type, -and the entry point address, in a host-dependent manner. Once these -values have been determined, generic code is used to handle the -object file. - -When porting it to run on a new system, you must supply: - - HOST_PAGE_SIZE - HOST_SEGMENT_SIZE - HOST_MACHINE_ARCH (optional) - HOST_MACHINE_MACHINE (optional) - HOST_TEXT_START_ADDR - HOST_STACK_END_ADDR - -in the file ../include/sys/h-XXX.h (for your host). These values, plus -the structures and macros defined in on your host system, will -produce a BFD target that will access ordinary a.out files on your host. - -To configure a new machine to use host-aout.c, specify: - -TDEFAULTS = -DDEFAULT_VECTOR=host_aout_big_vec -TDEPFILES= host-aout.o trad-core.o - -in the config/mt-XXX file, and modify configure.in to use the -mt-XXX file (by setting "bfd_target=XXX") when your configuration is -selected. - -*/ - -#define KEEPIT flags -#define KEEPITTYPE int - -#include "bfd.h" -#include -#include - -struct external_exec; -#include "libaout.h" -#include "libbfd.h" -#include "aout64.h" -#include "stab.gnu.h" -#include "ar.h" - -void (*bfd_error_trap)(); - -/*doc* -@subsection relocations -The file @code{aoutx.h} caters for both the @emph{standard} and -@emph{extended} forms of a.out relocation records. - -The standard records are characterised by containing only an address, -a symbol index and a type field. The extended records (used on 29ks -and sparcs) also have a full integer for an addend. -*/ -#define CTOR_TABLE_RELOC_IDX 2 - - -static reloc_howto_type howto_table_ext[] = -{ - HOWTO(RELOC_8, 0, 0, 8, false, 0, true, true,0,"8", false, 0,0x000000ff, false), - HOWTO(RELOC_16, 0, 1, 16, false, 0, true, true,0,"16", false, 0,0x0000ffff, false), - HOWTO(RELOC_32, 0, 2, 32, false, 0, true, true,0,"32", false, 0,0xffffffff, false), - HOWTO(RELOC_DISP8, 0, 0, 8, true, 0, false, true,0,"DISP8", false, 0,0x000000ff, false), - HOWTO(RELOC_DISP16, 0, 1, 16, true, 0, false, true,0,"DISP16", false, 0,0x0000ffff, false), - HOWTO(RELOC_DISP32, 0, 2, 32, true, 0, false, true,0,"DISP32", false, 0,0xffffffff, false), - HOWTO(RELOC_WDISP30,2, 2, 30, true, 0, false, true,0,"WDISP30", false, 0,0x3fffffff, false), - HOWTO(RELOC_WDISP22,2, 2, 22, true, 0, false, true,0,"WDISP22", false, 0,0x003fffff, false), - HOWTO(RELOC_HI22, 10, 2, 22, false, 0, false, true,0,"HI22", false, 0,0x003fffff, false), - HOWTO(RELOC_22, 0, 2, 22, false, 0, false, true,0,"22", false, 0,0x003fffff, false), - HOWTO(RELOC_13, 0, 2, 13, false, 0, false, true,0,"13", false, 0,0x00001fff, false), - HOWTO(RELOC_LO10, 0, 2, 10, false, 0, false, true,0,"LO10", false, 0,0x000003ff, false), - HOWTO(RELOC_SFA_BASE,0, 2, 32, false, 0, false, true,0,"SFA_BASE", false, 0,0xffffffff, false), - HOWTO(RELOC_SFA_OFF13,0,2, 32, false, 0, false, true,0,"SFA_OFF13",false, 0,0xffffffff, false), - HOWTO(RELOC_BASE10, 0, 2, 16, false, 0, false, true,0,"BASE10", false, 0,0x0000ffff, false), - HOWTO(RELOC_BASE13, 0, 2, 13, false, 0, false, true,0,"BASE13", false, 0,0x00001fff, false), - HOWTO(RELOC_BASE22, 0, 2, 0, false, 0, false, true,0,"BASE22", false, 0,0x00000000, false), - HOWTO(RELOC_PC10, 0, 2, 10, false, 0, false, true,0,"PC10", false, 0,0x000003ff, false), - HOWTO(RELOC_PC22, 0, 2, 22, false, 0, false, true,0,"PC22", false, 0,0x003fffff, false), - HOWTO(RELOC_JMP_TBL,0, 2, 32, false, 0, false, true,0,"JMP_TBL", false, 0,0xffffffff, false), - HOWTO(RELOC_SEGOFF16,0, 2, 0, false, 0, false, true,0,"SEGOFF16", false, 0,0x00000000, false), - HOWTO(RELOC_GLOB_DAT,0, 2, 0, false, 0, false, true,0,"GLOB_DAT", false, 0,0x00000000, false), - HOWTO(RELOC_JMP_SLOT,0, 2, 0, false, 0, false, true,0,"JMP_SLOT", false, 0,0x00000000, false), - HOWTO(RELOC_RELATIVE,0, 2, 0, false, 0, false, true,0,"RELATIVE", false, 0,0x00000000, false), - -}; - -/* Convert standard reloc records to "arelent" format (incl byte swap). */ - -static reloc_howto_type howto_table_std[] = { - /* type rs size bsz pcrel bitpos abs ovrf sf name part_inpl readmask setmask pcdone */ -HOWTO( 0, 0, 0, 8, false, 0, true, true,0,"8", true, 0x000000ff,0x000000ff, false), -HOWTO( 1, 0, 1, 16, false, 0, true, true,0,"16", true, 0x0000ffff,0x0000ffff, false), -HOWTO( 2, 0, 2, 32, false, 0, true, true,0,"32", true, 0xffffffff,0xffffffff, false), -HOWTO( 3, 0, 3, 64, false, 0, true, true,0,"64", true, 0xdeaddead,0xdeaddead, false), -HOWTO( 4, 0, 0, 8, true, 0, false, true,0,"DISP8", true, 0x000000ff,0x000000ff, false), -HOWTO( 5, 0, 1, 16, true, 0, false, true,0,"DISP16", true, 0x0000ffff,0x0000ffff, false), -HOWTO( 6, 0, 2, 32, true, 0, false, true,0,"DISP32", true, 0xffffffff,0xffffffff, false), -HOWTO( 7, 0, 3, 64, true, 0, false, true,0,"DISP64", true, 0xfeedface,0xfeedface, false), -}; - - -bfd_error_vector_type bfd_error_vector; - -/*doc* -@subsection Internal Entry Points -@code{aoutx.h} exports several routines for accessing the contents of -an a.out file, which are gathered and exported in turn by various -format specific files (eg sunos.c). -*/ - -/*doc* -*i aout__swap_exec_header_in -Swaps the information in an executable header taken from a raw byte stream memory image, -into the internal exec_header structure. -*; PROTO(void, aout__swap_exec_header_in, - (bfd *abfd, - struct external_exec *raw_bytes, - struct internal_exec *execp)); -*/ - -void -DEFUN(NAME(aout,swap_exec_header_in),(abfd, raw_bytes, execp), - bfd *abfd AND - struct external_exec *raw_bytes AND - struct internal_exec *execp) -{ - struct external_exec *bytes = (struct external_exec *)raw_bytes; - - /* Now fill in fields in the execp, from the bytes in the raw data. */ - execp->a_info = bfd_h_get_32 (abfd, bytes->e_info); - execp->a_text = GET_WORD (abfd, bytes->e_text); - execp->a_data = GET_WORD (abfd, bytes->e_data); - execp->a_bss = GET_WORD (abfd, bytes->e_bss); - execp->a_syms = GET_WORD (abfd, bytes->e_syms); - execp->a_entry = GET_WORD (abfd, bytes->e_entry); - execp->a_trsize = GET_WORD (abfd, bytes->e_trsize); - execp->a_drsize = GET_WORD (abfd, bytes->e_drsize); -} - -/*doc* -*i aout__swap_exec_header_out -Swaps the information in an internal exec header structure into the -supplied buffer ready for writing to disk. -*; PROTO(void, aout__swap_exec_header_out, - (bfd *abfd, - struct internal_exec *execp, - struct external_exec *raw_bytes)); -*/ -void -DEFUN(NAME(aout,swap_exec_header_out),(abfd, execp, raw_bytes), - bfd *abfd AND - struct internal_exec *execp AND - struct external_exec *raw_bytes) -{ - struct external_exec *bytes = (struct external_exec *)raw_bytes; - - /* Now fill in fields in the raw data, from the fields in the exec struct. */ - bfd_h_put_32 (abfd, execp->a_info , bytes->e_info); - PUT_WORD (abfd, execp->a_text , bytes->e_text); - PUT_WORD (abfd, execp->a_data , bytes->e_data); - PUT_WORD (abfd, execp->a_bss , bytes->e_bss); - PUT_WORD (abfd, execp->a_syms , bytes->e_syms); - PUT_WORD (abfd, execp->a_entry , bytes->e_entry); - PUT_WORD (abfd, execp->a_trsize, bytes->e_trsize); - PUT_WORD (abfd, execp->a_drsize, bytes->e_drsize); -} - -struct container { - struct aoutdata a; - struct internal_exec e; -}; - - -/*doc* -*i aout__some_aout_object_p - -Some A.OUT variant thinks that the file whose format we're checking -is an a.out file. Do some more checking, and set up for access if -it really is. Call back to the calling environments "finish up" -function just before returning, to handle any last-minute setup. - -*; PROTO(bfd_target *, aout__some_aout_object_p, - (bfd *abfd, - bfd_target *(*callback_to_real_object_p)())); -*/ - -bfd_target * -DEFUN(NAME(aout,some_aout_object_p),(abfd, execp, callback_to_real_object_p), - bfd *abfd AND - struct internal_exec *execp AND - bfd_target *(*callback_to_real_object_p) ()) -{ - struct container *rawptr; - - rawptr = (struct container *) bfd_zalloc (abfd, sizeof (struct container)); - if (rawptr == NULL) { - bfd_error = no_memory; - return 0; - } - - set_tdata (abfd, &rawptr->a); - exec_hdr (abfd) = &rawptr->e; - *exec_hdr (abfd) = *execp; /* Copy in the internal_exec struct */ - execp = exec_hdr (abfd); /* Switch to using the newly malloc'd one */ - - /* Set the file flags */ - abfd->flags = NO_FLAGS; - if (execp->a_drsize || execp->a_trsize) - abfd->flags |= HAS_RELOC; - if (execp->a_entry) - abfd->flags |= EXEC_P; - if (execp->a_syms) - abfd->flags |= HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS; - - if (N_MAGIC (*execp) == ZMAGIC) abfd->flags |= D_PAGED; - if (N_MAGIC (*execp) == NMAGIC) abfd->flags |= WP_TEXT; - - bfd_get_start_address (abfd) = execp->a_entry; - - obj_aout_symbols (abfd) = (aout_symbol_type *)NULL; - bfd_get_symcount (abfd) = execp->a_syms / sizeof (struct external_nlist); - - /* Set the default architecture and machine type. These can be - overridden in the callback routine. */ - - bfd_default_set_arch_mach(abfd, bfd_arch_unknown, 0); - - /* The default relocation entry size is that of traditional V7 Unix. */ - obj_reloc_entry_size (abfd) = RELOC_STD_SIZE; - - /* The default symbol entry size is that of traditional Unix. */ - obj_symbol_entry_size (abfd) = EXTERNAL_NLIST_SIZE; - - /* create the sections. This is raunchy, but bfd_close wants to reclaim - them */ - obj_textsec (abfd) = (asection *)NULL; - obj_datasec (abfd) = (asection *)NULL; - obj_bsssec (abfd) = (asection *)NULL; - (void)bfd_make_section(abfd, ".text"); - (void)bfd_make_section(abfd, ".data"); - (void)bfd_make_section(abfd, ".bss"); - - abfd->sections = obj_textsec (abfd); - obj_textsec (abfd)->next = obj_datasec (abfd); - obj_datasec (abfd)->next = obj_bsssec (abfd); - - obj_datasec (abfd)->size = execp->a_data; - obj_bsssec (abfd)->size = execp->a_bss; - obj_textsec (abfd)->size = execp->a_text; - - obj_textsec (abfd)->flags = (execp->a_trsize != 0 ? - (SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_HAS_CONTENTS) : - (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS)); - obj_datasec (abfd)->flags = (execp->a_drsize != 0 ? - (SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_HAS_CONTENTS) : - (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS)); - obj_bsssec (abfd)->flags = SEC_ALLOC; - -#ifdef THIS_IS_ONLY_DOCUMENTATION - /* Call back to the format-dependent code to fill in the rest of the - fields and do any further cleanup. Things that should be filled - in by the callback: */ - - struct exec *execp = exec_hdr (abfd); - - /* The virtual memory addresses of the sections */ - obj_datasec (abfd)->vma = N_DATADDR(*execp); - obj_bsssec (abfd)->vma = N_BSSADDR(*execp); - obj_textsec (abfd)->vma = N_TXTADDR(*execp); - - /* The file offsets of the sections */ - obj_textsec (abfd)->filepos = N_TXTOFF(*execp); - obj_datasec (abfd)->filepos = N_DATOFF(*execp); - - /* The file offsets of the relocation info */ - obj_textsec (abfd)->rel_filepos = N_TRELOFF(*execp); - obj_datasec (abfd)->rel_filepos = N_DRELOFF(*execp); - - /* The file offsets of the string table and symbol table. */ - obj_str_filepos (abfd) = N_STROFF (*execp); - obj_sym_filepos (abfd) = N_SYMOFF (*execp); - - /* This common code can't fill in those things because they depend - on either the start address of the text segment, the rounding - up of virtual addersses between segments, or the starting file - position of the text segment -- all of which varies among different - versions of a.out. */ - - /* Determine the architecture and machine type of the object file. */ - switch (N_MACHTYPE (*exec_hdr (abfd))) { - default: - abfd->obj_arch = bfd_arch_obscure; - break; - } - - /* Determine the size of a relocation entry */ - switch (abfd->obj_arch) { - case bfd_arch_sparc: - case bfd_arch_a29k: - obj_reloc_entry_size (abfd) = RELOC_EXT_SIZE; - default: - obj_reloc_entry_size (abfd) = RELOC_STD_SIZE; - } - - adata(abfd)->page_size = PAGE_SIZE; - adata(abfd)->segment_size = SEGMENT_SIZE; - adata(abfd)->exec_bytes_size = EXEC_BYTES_SIZE; - - return abfd->xvec; - - /* The architecture is encoded in various ways in various a.out variants, - or is not encoded at all in some of them. The relocation size depends - on the architecture and the a.out variant. Finally, the return value - is the bfd_target vector in use. If an error occurs, return zero and - set bfd_error to the appropriate error code. - - Formats such as b.out, which have additional fields in the a.out - header, should cope with them in this callback as well. */ -#endif /* DOCUMENTATION */ - - - return (*callback_to_real_object_p)(abfd); -} - -/*doc* -*i aout__mkobject - -This routine initializes a BFD for use with a.out files. - -*; PROTO(boolean, aout__mkobject, (bfd *)); -*/ - -boolean -DEFUN(NAME(aout,mkobject),(abfd), - bfd *abfd) -{ - struct container *rawptr; - - bfd_error = system_call_error; - - /* Use an intermediate variable for clarity */ - rawptr = (struct container *)bfd_zalloc (abfd, sizeof (struct container)); - - if (rawptr == NULL) { - bfd_error = no_memory; - return false; - } - - set_tdata (abfd, rawptr); - exec_hdr (abfd) = &(rawptr->e); - - /* For simplicity's sake we just make all the sections right here. */ - - obj_textsec (abfd) = (asection *)NULL; - obj_datasec (abfd) = (asection *)NULL; - obj_bsssec (abfd) = (asection *)NULL; - bfd_make_section (abfd, ".text"); - bfd_make_section (abfd, ".data"); - bfd_make_section (abfd, ".bss"); - - return true; -} - - -/*doc* -*i aout__machine_type - -Keep track of machine architecture and machine type for a.out's. -Return the machine_type for a particular arch&machine, or M_UNKNOWN -if that exact arch&machine can't be represented in a.out format. - -If the architecture is understood, machine type 0 (default) should -always be understood. - -*; PROTO(enum machine_type, aout__machine_type, - (enum bfd_architecture arch, - unsigned long machine)); -*/ - -enum machine_type -DEFUN(NAME(aout,machine_type),(arch, machine), - enum bfd_architecture arch AND - unsigned long machine) -{ - enum machine_type arch_flags; - - arch_flags = M_UNKNOWN; - - switch (arch) { - case bfd_arch_sparc: - if (machine == 0) arch_flags = M_SPARC; - break; - - case bfd_arch_m68k: - switch (machine) { - case 0: arch_flags = M_68010; break; - case 68000: arch_flags = M_UNKNOWN; break; - case 68010: arch_flags = M_68010; break; - case 68020: arch_flags = M_68020; break; - default: arch_flags = M_UNKNOWN; break; - } - break; - - case bfd_arch_i386: - if (machine == 0) arch_flags = M_386; - break; - - case bfd_arch_a29k: - if (machine == 0) arch_flags = M_29K; - break; - - default: - arch_flags = M_UNKNOWN; - break; - } - return arch_flags; -} - - -/*doc* -*i aout__set_arch_mach - -Sets the architecture and the machine of the BFD to those values -supplied. Verifies that the format can support the architecture -required. - -*; PROTO(boolean, aout__set_arch_mach, - (bfd *, - enum bfd_architecture, - unsigned long machine)); -*/ - -boolean -DEFUN(NAME(aout,set_arch_mach),(abfd, arch, machine), - bfd *abfd AND - enum bfd_architecture arch AND - unsigned long machine) -{ - bfd_default_set_arch_mach(abfd, arch, machine); - if (arch != bfd_arch_unknown && - NAME(aout,machine_type) (arch, machine) == M_UNKNOWN) - return false; /* We can't represent this type */ - return true; /* We're easy ... */ -} - -/*doc* - *i aout_new_section_hook - - Called by the BFD in response to a @code{bfd_make_section} request. - *; PROTO(boolean, aout__new_section_hook, - (bfd *abfd, - asection *newsect)); -*/ -boolean - DEFUN(NAME(aout,new_section_hook),(abfd, newsect), - bfd *abfd AND - asection *newsect) -{ - /* align to double at least */ - newsect->alignment_power = 3; - - if (bfd_get_format (abfd) == bfd_object) { - if (obj_textsec(abfd) == NULL && !strcmp(newsect->name, ".text")) { - obj_textsec(abfd)= newsect; - return true; - } - - if (obj_datasec(abfd) == NULL && !strcmp(newsect->name, ".data")) { - obj_datasec(abfd) = newsect; - return true; - } - - if (obj_bsssec(abfd) == NULL && !strcmp(newsect->name, ".bss")) { - obj_bsssec(abfd) = newsect; - return true; - } - } - - /* We allow more than three sections internally */ - return true; -} - -boolean - DEFUN(NAME(aout,set_section_contents),(abfd, section, location, offset, count), - bfd *abfd AND - sec_ptr section AND - PTR location AND - file_ptr offset AND - bfd_size_type count) -{ - file_ptr text_end; - bfd_size_type text_header_size; /* exec_bytes_size if if included in - text size. */ - bfd_size_type text_size; - if (abfd->output_has_begun == false) - { /* set by bfd.c handler */ - switch (abfd->direction) - { - case read_direction: - case no_direction: - bfd_error = invalid_operation; - return false; - - case both_direction: - break; - - case write_direction: - if ((obj_textsec (abfd) == NULL) || (obj_datasec (abfd) == NULL)) - { - bfd_error = invalid_operation; - return false; - } - obj_textsec(abfd)->size = - align_power(obj_textsec(abfd)->size, - obj_textsec(abfd)->alignment_power); - text_size = obj_textsec (abfd)->size; - /* Rule (heuristic) for when to pad to a new page. - * Note that there are (at least) two ways demand-paged - * (ZMAGIC) files have been handled. Most Berkeley-based systems - * start the text segment at (PAGE_SIZE). However, newer - * versions of SUNOS start the text segment right after the - * exec header; the latter is counted in the text segment size, - * and is paged in by the kernel with the rest of the text. */ - if (!(abfd->flags & D_PAGED)) - { /* Not demand-paged. */ - obj_textsec(abfd)->filepos = adata(abfd)->exec_bytes_size; - } - else if (obj_textsec(abfd)->vma % adata(abfd)->page_size - < adata(abfd)->exec_bytes_size) - { /* Old-style demand-paged. */ - obj_textsec(abfd)->filepos = adata(abfd)->page_size; - } - else - { /* Sunos-style demand-paged. */ - obj_textsec(abfd)->filepos = adata(abfd)->exec_bytes_size; - text_size += adata(abfd)->exec_bytes_size; - } - text_end = obj_textsec(abfd)->size + obj_textsec(abfd)->filepos; - if (abfd->flags & (D_PAGED|WP_TEXT)) - { - bfd_size_type text_pad = - ALIGN(text_size, adata(abfd)->segment_size) - text_size; - text_end += text_pad; - obj_textsec(abfd)->size += text_pad; - } - obj_datasec(abfd)->filepos = text_end; - obj_datasec(abfd)->size = - align_power(obj_datasec(abfd)->size, - obj_datasec(abfd)->alignment_power); - } - } - - /* regardless, once we know what we're doing, we might as well get going */ - if (section != obj_bsssec(abfd)) - { - bfd_seek (abfd, section->filepos + offset, SEEK_SET); - - if (count) { - return (bfd_write ((PTR)location, 1, count, abfd) == count) ? - true : false; - } - return false; - } - return true; -} - -/* Classify stabs symbols */ - -#define sym_in_text_section(sym) \ - (((sym)->type & (N_ABS | N_TEXT | N_DATA | N_BSS))== N_TEXT) - -#define sym_in_data_section(sym) \ - (((sym)->type & (N_ABS | N_TEXT | N_DATA | N_BSS))== N_DATA) - -#define sym_in_bss_section(sym) \ - (((sym)->type & (N_ABS | N_TEXT | N_DATA | N_BSS))== N_BSS) - -/* Symbol is undefined if type is N_UNDF|N_EXT and if it has - zero in the "value" field. Nonzeroes there are fortrancommon - symbols. */ -#define sym_is_undefined(sym) \ - ((sym)->type == (N_UNDF | N_EXT) && (sym)->symbol.value == 0) - -/* Symbol is a global definition if N_EXT is on and if it has - a nonzero type field. */ -#define sym_is_global_defn(sym) \ - (((sym)->type & N_EXT) && (sym)->type & N_TYPE) - -/* Symbol is debugger info if any bits outside N_TYPE or N_EXT - are on. */ -#define sym_is_debugger_info(sym) \ - ((sym)->type & ~(N_EXT | N_TYPE)) - -#define sym_is_fortrancommon(sym) \ - (((sym)->type == (N_EXT)) && (sym)->symbol.value != 0) - -/* Symbol is absolute if it has N_ABS set */ -#define sym_is_absolute(sym) \ - (((sym)->type & N_TYPE)== N_ABS) - - -#define sym_is_indirect(sym) \ - (((sym)->type & N_ABS)== N_ABS) - -/* Only in their own functions for ease of debugging; when sym flags have - stabilised these should be inlined into their (single) caller */ - -static void -DEFUN(translate_from_native_sym_flags,(sym_pointer, cache_ptr, abfd), -struct external_nlist *sym_pointer AND -aout_symbol_type *cache_ptr AND -bfd *abfd) -{ - switch (cache_ptr->type & N_TYPE) { - case N_SETA: - case N_SETT: - case N_SETD: - case N_SETB: - { - char *copy = bfd_alloc(abfd, strlen(cache_ptr->symbol.name)+1); - asection *section ; - arelent_chain *reloc = (arelent_chain *)bfd_alloc(abfd, sizeof(arelent_chain)); - strcpy(copy, cache_ptr->symbol.name); - section = bfd_get_section_by_name (abfd, copy); - if (!section) - section = bfd_make_section(abfd,copy); - - switch ( (cache_ptr->type & N_TYPE) ) { - case N_SETA: - section->flags = SEC_CONSTRUCTOR; - reloc->relent.section = (asection *)NULL; - cache_ptr->symbol.section = (asection *)NULL; - break; - case N_SETT: - section->flags = SEC_CONSTRUCTOR_TEXT; - reloc->relent.section = (asection *)obj_textsec(abfd); - cache_ptr->symbol.value -= reloc->relent.section->vma; - break; - case N_SETD: - section->flags = SEC_CONSTRUCTOR_DATA; - reloc->relent.section = (asection *)obj_datasec(abfd); - cache_ptr->symbol.value -= reloc->relent.section->vma; - break; - case N_SETB: - section->flags = SEC_CONSTRUCTOR_BSS; - reloc->relent.section = (asection *)obj_bsssec(abfd); - cache_ptr->symbol.value -= reloc->relent.section->vma; - break; - } - cache_ptr->symbol.section = reloc->relent.section; - reloc->relent.addend = cache_ptr->symbol.value ; - - /* We modify the symbol to belong to a section depending upon the - name of the symbol - probably __CTOR__ or __DTOR__ but we don't - really care, and add to the size of the section to contain a - pointer to the symbol. Build a reloc entry to relocate to this - symbol attached to this section. */ - - - section->reloc_count++; - section->alignment_power = 2; - reloc->relent.sym_ptr_ptr = (asymbol **)NULL; - reloc->next = section->constructor_chain; - section->constructor_chain = reloc; - reloc->relent.address = section->size; - section->size += sizeof(int *); - - reloc->relent.howto = howto_table_ext +CTOR_TABLE_RELOC_IDX; - cache_ptr->symbol.flags |= BSF_DEBUGGING | BSF_CONSTRUCTOR; - } - break; - default: - if (cache_ptr->type == N_WARNING) - { - /* This symbol is the text of a warning message, the next symbol - is the symbol to associate the warning with */ - cache_ptr->symbol.flags = BSF_DEBUGGING | BSF_WARNING; - cache_ptr->symbol.value = (bfd_vma)((cache_ptr+1)); - /* We furgle with the next symbol in place. We don't want it to be undefined, we'll trample the type */ - (sym_pointer+1)->e_type[0] = 0xff; - break; - } - if ((cache_ptr->type | N_EXT) == (N_INDR | N_EXT)) { - /* Two symbols in a row for an INDR message. The first symbol - contains the name we will match, the second symbol contains the - name the first name is translated into. It is supplied to us - undefined. This is good, since we want to pull in any files which - define it */ - cache_ptr->symbol.flags = BSF_DEBUGGING | BSF_INDIRECT; - cache_ptr->symbol.value = (bfd_vma)((cache_ptr+1)); - break; - } - - - if (sym_is_debugger_info (cache_ptr)) { - cache_ptr->symbol.flags = BSF_DEBUGGING ; - /* Work out the section correct for this symbol */ - switch (cache_ptr->type & N_TYPE) - { - case N_TEXT: - case N_FN: - cache_ptr->symbol.section = obj_textsec (abfd); - cache_ptr->symbol.value -= obj_textsec(abfd)->vma; - break; - case N_DATA: - cache_ptr->symbol.value -= obj_datasec(abfd)->vma; - cache_ptr->symbol.section = obj_datasec (abfd); - break; - case N_BSS : - cache_ptr->symbol.section = obj_bsssec (abfd); - cache_ptr->symbol.value -= obj_bsssec(abfd)->vma; - break; - case N_ABS: - default: - cache_ptr->symbol.section = 0; - break; - } - } - else { - - if (sym_is_fortrancommon (cache_ptr)) - { - cache_ptr->symbol.flags = BSF_FORT_COMM; - cache_ptr->symbol.section = (asection *)NULL; - } - else { - if (sym_is_undefined (cache_ptr)) { - cache_ptr->symbol.flags = BSF_UNDEFINED; - } - else if (sym_is_global_defn (cache_ptr)) { - cache_ptr->symbol.flags = BSF_GLOBAL | BSF_EXPORT; - } - - else if (sym_is_absolute (cache_ptr)) { - cache_ptr->symbol.flags = BSF_ABSOLUTE; - } - else { - cache_ptr->symbol.flags = BSF_LOCAL; - } - - /* In a.out, the value of a symbol is always relative to the - * start of the file, if this is a data symbol we'll subtract - * the size of the text section to get the section relative - * value. If this is a bss symbol (which would be strange) - * we'll subtract the size of the previous two sections - * to find the section relative address. - */ - - if (sym_in_text_section (cache_ptr)) { - cache_ptr->symbol.value -= obj_textsec(abfd)->vma; - cache_ptr->symbol.section = obj_textsec (abfd); - } - else if (sym_in_data_section (cache_ptr)){ - cache_ptr->symbol.value -= obj_datasec(abfd)->vma; - cache_ptr->symbol.section = obj_datasec (abfd); - } - else if (sym_in_bss_section(cache_ptr)) { - cache_ptr->symbol.section = obj_bsssec (abfd); - cache_ptr->symbol.value -= obj_bsssec(abfd)->vma; - } - else { - cache_ptr->symbol.section = (asection *)NULL; - cache_ptr->symbol.flags |= BSF_ABSOLUTE; - } - } - } - } -} - -static void -DEFUN(translate_to_native_sym_flags,(sym_pointer, cache_ptr, abfd), - struct external_nlist *sym_pointer AND - asymbol *cache_ptr AND - bfd *abfd) -{ - bfd_vma value = cache_ptr->value; - - if (bfd_get_section(cache_ptr)) { - if (bfd_get_output_section(cache_ptr) == obj_bsssec (abfd)) { - sym_pointer->e_type[0] |= N_BSS; - } - else if (bfd_get_output_section(cache_ptr) == obj_datasec (abfd)) { - sym_pointer->e_type[0] |= N_DATA; - } - else if (bfd_get_output_section(cache_ptr) == obj_textsec (abfd)) { - sym_pointer->e_type[0] |= N_TEXT; - } - else { - bfd_error_vector.nonrepresentable_section(abfd, - bfd_get_output_section(cache_ptr)->name); - } - /* Turn the symbol from section relative to absolute again */ - - value += - cache_ptr->section->output_section->vma - + cache_ptr->section->output_offset ; - } - else { - sym_pointer->e_type[0] |= N_ABS; - } - if (cache_ptr->flags & (BSF_WARNING)) { - (sym_pointer+1)->e_type[0] = 1; - } - if (cache_ptr->flags & (BSF_FORT_COMM | BSF_UNDEFINED)) { - sym_pointer->e_type[0] = (N_UNDF | N_EXT); - } - else { - if (cache_ptr->flags & BSF_ABSOLUTE) { - sym_pointer->e_type[0] |= N_ABS; - } - - if (cache_ptr->flags & (BSF_GLOBAL | BSF_EXPORT)) { - sym_pointer->e_type[0] |= N_EXT; - } - if (cache_ptr->flags & BSF_DEBUGGING) { - sym_pointer->e_type [0]= ((aout_symbol_type *)cache_ptr)->type; - } - } - PUT_WORD(abfd, value, sym_pointer->e_value); -} - -/* Native-level interface to symbols. */ - -/* We read the symbols into a buffer, which is discarded when this -function exits. We read the strings into a buffer large enough to -hold them all plus all the cached symbol entries. */ - -asymbol * -DEFUN(NAME(aout,make_empty_symbol),(abfd), - bfd *abfd) -{ - aout_symbol_type *new = - (aout_symbol_type *)bfd_zalloc (abfd, sizeof (aout_symbol_type)); - new->symbol.the_bfd = abfd; - - return &new->symbol; -} - -boolean -DEFUN(NAME(aout,slurp_symbol_table),(abfd), - bfd *abfd) -{ - bfd_size_type symbol_size; - bfd_size_type string_size; - unsigned char string_chars[BYTES_IN_WORD]; - struct external_nlist *syms; - char *strings; - aout_symbol_type *cached; - - /* If there's no work to be done, don't do any */ - if (obj_aout_symbols (abfd) != (aout_symbol_type *)NULL) return true; - symbol_size = exec_hdr(abfd)->a_syms; - if (symbol_size == 0) { - bfd_error = no_symbols; - return false; - } - - bfd_seek (abfd, obj_str_filepos (abfd), SEEK_SET); - if (bfd_read ((PTR)string_chars, BYTES_IN_WORD, 1, abfd) != BYTES_IN_WORD) - return false; - string_size = GET_WORD (abfd, string_chars); - - strings =(char *) bfd_alloc(abfd, string_size + 1); - cached = (aout_symbol_type *) - bfd_zalloc(abfd, (bfd_size_type)(bfd_get_symcount (abfd) * sizeof(aout_symbol_type))); - - /* malloc this, so we can free it if simply. The symbol caching - might want to allocate onto the bfd's obstack */ - syms = (struct external_nlist *) malloc(symbol_size); - bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET); - if (bfd_read ((PTR)syms, 1, symbol_size, abfd) != symbol_size) { - bailout: - if (syms) free (syms); - if (cached) bfd_release (abfd, cached); - if (strings)bfd_release (abfd, strings); - return false; - } - - bfd_seek (abfd, obj_str_filepos (abfd), SEEK_SET); - if (bfd_read ((PTR)strings, 1, string_size, abfd) != string_size) { - goto bailout; - } - - /* OK, now walk the new symtable, cacheing symbol properties */ - { - register struct external_nlist *sym_pointer; - register struct external_nlist *sym_end = syms + bfd_get_symcount (abfd); - register aout_symbol_type *cache_ptr = cached; - - /* Run through table and copy values */ - for (sym_pointer = syms, cache_ptr = cached; - sym_pointer < sym_end; sym_pointer++, cache_ptr++) - { - bfd_vma x = GET_WORD(abfd, sym_pointer->e_strx); - cache_ptr->symbol.the_bfd = abfd; - if (x) - cache_ptr->symbol.name = x + strings; - else - cache_ptr->symbol.name = (char *)NULL; - - cache_ptr->symbol.value = GET_SWORD(abfd, sym_pointer->e_value); - cache_ptr->desc = bfd_get_16(abfd, sym_pointer->e_desc); - cache_ptr->other =bfd_get_8(abfd, sym_pointer->e_other); - cache_ptr->type = bfd_get_8(abfd, sym_pointer->e_type); - cache_ptr->symbol.udata = 0; - translate_from_native_sym_flags (sym_pointer, cache_ptr, abfd); - } - } - - obj_aout_symbols (abfd) = cached; - free((PTR)syms); - - return true; -} - - -void -DEFUN(NAME(aout,write_syms),(abfd), - bfd *abfd) - { - unsigned int count ; - asymbol **generic = bfd_get_outsymbols (abfd); - - bfd_size_type stindex = BYTES_IN_WORD; /* initial string length */ - - for (count = 0; count < bfd_get_symcount (abfd); count++) { - asymbol *g = generic[count]; - struct external_nlist nsp; - - if (g->name) { - unsigned int length = strlen(g->name) +1; - PUT_WORD (abfd, stindex, (unsigned char *)nsp.e_strx); - stindex += length; - } - else { - PUT_WORD (abfd, 0, (unsigned char *)nsp.e_strx); - } - - if (g->the_bfd->xvec->flavour == abfd->xvec->flavour) - { - bfd_h_put_16(abfd, aout_symbol(g)->desc, nsp.e_desc); - bfd_h_put_8(abfd, aout_symbol(g)->other, nsp.e_other); - bfd_h_put_8(abfd, aout_symbol(g)->type, nsp.e_type); - } - else - { - bfd_h_put_16(abfd,0, nsp.e_desc); - bfd_h_put_8(abfd, 0, nsp.e_other); - bfd_h_put_8(abfd, 0, nsp.e_type); - } - - translate_to_native_sym_flags (&nsp, g, abfd); - - bfd_write((PTR)&nsp,1,EXTERNAL_NLIST_SIZE, abfd); - } - - /* Now output the strings. Be sure to put string length into correct - byte ordering before writing it. */ - { - char buffer[BYTES_IN_WORD]; - PUT_WORD (abfd, stindex, (unsigned char *)buffer); - - bfd_write((PTR)buffer, 1, BYTES_IN_WORD, abfd); - } - generic = bfd_get_outsymbols(abfd); - for (count = 0; count < bfd_get_symcount(abfd); count++) - { - asymbol *g = *(generic++); - - if (g->name) - { - size_t length = strlen(g->name)+1; - bfd_write((PTR)g->name, 1, length, abfd); - } - if ((g->flags & BSF_FAKE)==0) { - g->KEEPIT = (KEEPITTYPE) count; - } - } - } - - - -unsigned int -DEFUN(NAME(aout,get_symtab),(abfd, location), - bfd *abfd AND - asymbol **location) - { - unsigned int counter = 0; - aout_symbol_type *symbase; - - if (!NAME(aout,slurp_symbol_table)(abfd)) return 0; - - for (symbase = obj_aout_symbols(abfd); counter++ < bfd_get_symcount (abfd);) - *(location++) = (asymbol *)( symbase++); - *location++ =0; - return bfd_get_symcount(abfd); - } - - -/* Standard reloc stuff */ -/* Output standard relocation information to a file in target byte order. */ - -void -DEFUN(NAME(aout,swap_std_reloc_out),(abfd, g, natptr), - bfd *abfd AND - arelent *g AND - struct reloc_std_external *natptr) - { - int r_index; - int r_extern; - unsigned int r_length; - int r_pcrel; - int r_baserel, r_jmptable, r_relative; - unsigned int r_addend; - - PUT_WORD(abfd, g->address, natptr->r_address); - - r_length = g->howto->size ; /* Size as a power of two */ - r_pcrel = (int) g->howto->pc_relative; /* Relative to PC? */ - /* r_baserel, r_jmptable, r_relative??? FIXME-soon */ - r_baserel = 0; - r_jmptable = 0; - r_relative = 0; - - r_addend = g->addend; /* Start here, see how it goes */ - - /* name was clobbered by aout_write_syms to be symbol index */ - - if (g->sym_ptr_ptr != NULL) - { - if ((*(g->sym_ptr_ptr))->section) { - /* put the section offset into the addend for output */ - r_addend += (*(g->sym_ptr_ptr))->section->vma; - } - - r_index = ((*(g->sym_ptr_ptr))->KEEPIT); - r_extern = 1; - } - else { - r_extern = 0; - if (g->section == NULL) { - /* It is possible to have a reloc with nothing, we generate an - abs + 0 */ - r_addend = 0; - r_index = N_ABS | N_EXT; - } - else if(g->section->output_section == obj_textsec(abfd)) { - r_index = N_TEXT | N_EXT; - r_addend += g->section->output_section->vma; - } - else if (g->section->output_section == obj_datasec(abfd)) { - r_index = N_DATA | N_EXT; - r_addend += g->section->output_section->vma; - } - else if (g->section->output_section == obj_bsssec(abfd)) { - r_index = N_BSS | N_EXT ; - r_addend += g->section->output_section->vma; - } - else { - BFD_ASSERT(0); - r_index = N_ABS | N_EXT; - } - } - - /* now the fun stuff */ - if (abfd->xvec->header_byteorder_big_p != false) { - natptr->r_index[0] = r_index >> 16; - natptr->r_index[1] = r_index >> 8; - natptr->r_index[2] = r_index; - natptr->r_type[0] = - (r_extern? RELOC_STD_BITS_EXTERN_BIG: 0) - | (r_pcrel? RELOC_STD_BITS_PCREL_BIG: 0) - | (r_baserel? RELOC_STD_BITS_BASEREL_BIG: 0) - | (r_jmptable? RELOC_STD_BITS_JMPTABLE_BIG: 0) - | (r_relative? RELOC_STD_BITS_RELATIVE_BIG: 0) - | (r_length << RELOC_STD_BITS_LENGTH_SH_BIG); - } else { - natptr->r_index[2] = r_index >> 16; - natptr->r_index[1] = r_index >> 8; - natptr->r_index[0] = r_index; - natptr->r_type[0] = - (r_extern? RELOC_STD_BITS_EXTERN_LITTLE: 0) - | (r_pcrel? RELOC_STD_BITS_PCREL_LITTLE: 0) - | (r_baserel? RELOC_STD_BITS_BASEREL_LITTLE: 0) - | (r_jmptable? RELOC_STD_BITS_JMPTABLE_LITTLE: 0) - | (r_relative? RELOC_STD_BITS_RELATIVE_LITTLE: 0) - | (r_length << RELOC_STD_BITS_LENGTH_SH_LITTLE); - } - } - - -/* Extended stuff */ -/* Output extended relocation information to a file in target byte order. */ - -void -DEFUN(NAME(aout,swap_ext_reloc_out),(abfd, g, natptr), - bfd *abfd AND - arelent *g AND - register struct reloc_ext_external *natptr) - { - int r_index; - int r_extern; - unsigned int r_type; - unsigned int r_addend; - - PUT_WORD (abfd, g->address, natptr->r_address); - - /* Find a type in the output format which matches the input howto - - at the moment we assume input format == output format FIXME!! */ - r_type = (enum reloc_type) g->howto->type; - - r_addend = g->addend; /* Start here, see how it goes */ - - /* name was clobbered by aout_write_syms to be symbol index*/ - - if (g->sym_ptr_ptr != NULL) - { - if ((*(g->sym_ptr_ptr))->section) { - /* put the section offset into the addend for output */ - r_addend += (*(g->sym_ptr_ptr))->section->vma; - } - - r_index = stoi((*(g->sym_ptr_ptr))->KEEPIT); - r_extern = 1; - } - else { - r_extern = 0; - if (g->section == NULL) { - BFD_ASSERT(0); - r_index = N_ABS | N_EXT; - } - else if(g->section->output_section == obj_textsec(abfd)) { - r_index = N_TEXT | N_EXT; - r_addend += g->section->output_section->vma; - } - else if (g->section->output_section == obj_datasec(abfd)) { - r_index = N_DATA | N_EXT; - r_addend += g->section->output_section->vma; - } - else if (g->section->output_section == obj_bsssec(abfd)) { - r_index = N_BSS | N_EXT ; - r_addend += g->section->output_section->vma; - } - else { - BFD_ASSERT(0); - r_index = N_ABS | N_EXT; - } - } - - /* now the fun stuff */ - if (abfd->xvec->header_byteorder_big_p != false) { - natptr->r_index[0] = r_index >> 16; - natptr->r_index[1] = r_index >> 8; - natptr->r_index[2] = r_index; - natptr->r_type[0] = - (r_extern? RELOC_EXT_BITS_EXTERN_BIG: 0) - | (r_type << RELOC_EXT_BITS_TYPE_SH_BIG); - } else { - natptr->r_index[2] = r_index >> 16; - natptr->r_index[1] = r_index >> 8; - natptr->r_index[0] = r_index; - natptr->r_type[0] = - (r_extern? RELOC_EXT_BITS_EXTERN_LITTLE: 0) - | (r_type << RELOC_EXT_BITS_TYPE_SH_LITTLE); - } - - PUT_WORD (abfd, r_addend, natptr->r_addend); -} - -#define MOVE_ADDRESS(ad) \ - if (r_extern) { \ - cache_ptr->sym_ptr_ptr = symbols + r_index; \ - cache_ptr->section = (asection *)NULL; \ - cache_ptr->addend = ad; \ - } else { \ - cache_ptr->sym_ptr_ptr = (asymbol **)NULL; \ - switch (r_index) { \ - case N_TEXT: \ - case N_TEXT | N_EXT: \ - cache_ptr->section = obj_textsec(abfd); \ - cache_ptr->addend = ad - su->textsec->vma; \ - break; \ - case N_DATA: \ - case N_DATA | N_EXT: \ - cache_ptr->section = obj_datasec(abfd); \ - cache_ptr->addend = ad - su->datasec->vma; \ - break; \ - case N_BSS: \ - case N_BSS | N_EXT: \ - cache_ptr->section = obj_bsssec(abfd); \ - cache_ptr->addend = ad - su->bsssec->vma; \ - break; \ - case N_ABS: \ - case N_ABS | N_EXT: \ - cache_ptr->section = NULL; /* No section */ \ - cache_ptr->addend = ad; /* FIXME, is this right? */ \ - BFD_ASSERT(1); \ - break; \ - default: \ - cache_ptr->section = NULL; /* No section */ \ - cache_ptr->addend = ad; /* FIXME, is this right? */ \ - BFD_ASSERT(1); \ - break; \ - } \ - } \ - -void -DEFUN(NAME(aout,swap_ext_reloc_in), (abfd, bytes, cache_ptr, symbols), - bfd *abfd AND - struct reloc_ext_external *bytes AND - arelent *cache_ptr AND - asymbol **symbols) -{ - int r_index; - int r_extern; - unsigned int r_type; - struct aoutdata *su = (struct aoutdata *)(abfd->tdata); - - cache_ptr->address = (GET_SWORD (abfd, bytes->r_address)); - - /* now the fun stuff */ - if (abfd->xvec->header_byteorder_big_p != false) { - r_index = (bytes->r_index[0] << 16) - | (bytes->r_index[1] << 8) - | bytes->r_index[2]; - r_extern = (0 != (bytes->r_type[0] & RELOC_EXT_BITS_EXTERN_BIG)); - r_type = (bytes->r_type[0] & RELOC_EXT_BITS_TYPE_BIG) - >> RELOC_EXT_BITS_TYPE_SH_BIG; - } else { - r_index = (bytes->r_index[2] << 16) - | (bytes->r_index[1] << 8) - | bytes->r_index[0]; - r_extern = (0 != (bytes->r_type[0] & RELOC_EXT_BITS_EXTERN_LITTLE)); - r_type = (bytes->r_type[0] & RELOC_EXT_BITS_TYPE_LITTLE) - >> RELOC_EXT_BITS_TYPE_SH_LITTLE; - } - - cache_ptr->howto = howto_table_ext + r_type; - MOVE_ADDRESS(GET_SWORD(abfd,bytes->r_addend)); -} - -void -DEFUN(NAME(aout,swap_std_reloc_in), (abfd, bytes, cache_ptr, symbols), - bfd *abfd AND - struct reloc_std_external *bytes AND - arelent *cache_ptr AND - asymbol **symbols) -{ - int r_index; - int r_extern; - unsigned int r_length; - int r_pcrel; - int r_baserel, r_jmptable, r_relative; - struct aoutdata *su = (struct aoutdata *)(abfd->tdata); - - cache_ptr->address = (int32_type)(bfd_h_get_32 (abfd, bytes->r_address)); - - /* now the fun stuff */ - if (abfd->xvec->header_byteorder_big_p != false) { - r_index = (bytes->r_index[0] << 16) - | (bytes->r_index[1] << 8) - | bytes->r_index[2]; - r_extern = (0 != (bytes->r_type[0] & RELOC_STD_BITS_EXTERN_BIG)); - r_pcrel = (0 != (bytes->r_type[0] & RELOC_STD_BITS_PCREL_BIG)); - r_baserel = (0 != (bytes->r_type[0] & RELOC_STD_BITS_BASEREL_BIG)); - r_jmptable= (0 != (bytes->r_type[0] & RELOC_STD_BITS_JMPTABLE_BIG)); - r_relative= (0 != (bytes->r_type[0] & RELOC_STD_BITS_RELATIVE_BIG)); - r_length = (bytes->r_type[0] & RELOC_STD_BITS_LENGTH_BIG) - >> RELOC_STD_BITS_LENGTH_SH_BIG; - } else { - r_index = (bytes->r_index[2] << 16) - | (bytes->r_index[1] << 8) - | bytes->r_index[0]; - r_extern = (0 != (bytes->r_type[0] & RELOC_STD_BITS_EXTERN_LITTLE)); - r_pcrel = (0 != (bytes->r_type[0] & RELOC_STD_BITS_PCREL_LITTLE)); - r_baserel = (0 != (bytes->r_type[0] & RELOC_STD_BITS_BASEREL_LITTLE)); - r_jmptable= (0 != (bytes->r_type[0] & RELOC_STD_BITS_JMPTABLE_LITTLE)); - r_relative= (0 != (bytes->r_type[0] & RELOC_STD_BITS_RELATIVE_LITTLE)); - r_length = (bytes->r_type[0] & RELOC_STD_BITS_LENGTH_LITTLE) - >> RELOC_STD_BITS_LENGTH_SH_LITTLE; - } - - cache_ptr->howto = howto_table_std + r_length + 4 * r_pcrel; - /* FIXME-soon: Roll baserel, jmptable, relative bits into howto setting */ - - MOVE_ADDRESS(0); -} - -/* Reloc hackery */ - -boolean -DEFUN(NAME(aout,slurp_reloc_table),(abfd, asect, symbols), - bfd *abfd AND - sec_ptr asect AND - asymbol **symbols) -{ - unsigned int count; - bfd_size_type reloc_size; - PTR relocs; - arelent *reloc_cache; - size_t each_size; - - if (asect->relocation) return true; - - if (asect->flags & SEC_CONSTRUCTOR) return true; - - if (asect == obj_datasec (abfd)) { - reloc_size = exec_hdr(abfd)->a_drsize; - goto doit; - } - - if (asect == obj_textsec (abfd)) { - reloc_size = exec_hdr(abfd)->a_trsize; - goto doit; - } - - bfd_error = invalid_operation; - return false; - - doit: - bfd_seek (abfd, asect->rel_filepos, SEEK_SET); - each_size = obj_reloc_entry_size (abfd); - - count = reloc_size / each_size; - - - reloc_cache = (arelent *) bfd_zalloc (abfd, (size_t)(count * sizeof - (arelent))); - if (!reloc_cache) { -nomem: - bfd_error = no_memory; - return false; - } - - relocs = (PTR) bfd_alloc (abfd, reloc_size); - if (!relocs) { - bfd_release (abfd, reloc_cache); - goto nomem; - } - - if (bfd_read (relocs, 1, reloc_size, abfd) != reloc_size) { - bfd_release (abfd, relocs); - bfd_release (abfd, reloc_cache); - bfd_error = system_call_error; - return false; - } - - if (each_size == RELOC_EXT_SIZE) { - register struct reloc_ext_external *rptr = (struct reloc_ext_external *) relocs; - unsigned int counter = 0; - arelent *cache_ptr = reloc_cache; - - for (; counter < count; counter++, rptr++, cache_ptr++) { - NAME(aout,swap_ext_reloc_in)(abfd, rptr, cache_ptr, symbols); - } - } else { - register struct reloc_std_external *rptr = (struct reloc_std_external*) relocs; - unsigned int counter = 0; - arelent *cache_ptr = reloc_cache; - - for (; counter < count; counter++, rptr++, cache_ptr++) { - NAME(aout,swap_std_reloc_in)(abfd, rptr, cache_ptr, symbols); - } - - } - - bfd_release (abfd,relocs); - asect->relocation = reloc_cache; - asect->reloc_count = count; - return true; -} - - - -/* Write out a relocation section into an object file. */ - -boolean -DEFUN(NAME(aout,squirt_out_relocs),(abfd, section), - bfd *abfd AND - asection *section) -{ - arelent **generic; - unsigned char *native, *natptr; - size_t each_size; - - unsigned int count = section->reloc_count; - size_t natsize; - - if (count == 0) return true; - - each_size = obj_reloc_entry_size (abfd); - natsize = each_size * count; - native = (unsigned char *) bfd_zalloc (abfd, natsize); - if (!native) { - bfd_error = no_memory; - return false; - } - - generic = section->orelocation; - - if (each_size == RELOC_EXT_SIZE) - { - for (natptr = native; - count != 0; - --count, natptr += each_size, ++generic) - NAME(aout,swap_ext_reloc_out) (abfd, *generic, (struct reloc_ext_external *)natptr); - } - else - { - for (natptr = native; - count != 0; - --count, natptr += each_size, ++generic) - NAME(aout,swap_std_reloc_out)(abfd, *generic, (struct reloc_std_external *)natptr); - } - - if ( bfd_write ((PTR) native, 1, natsize, abfd) != natsize) { - bfd_release(abfd, native); - return false; - } - bfd_release (abfd, native); - - return true; -} - -/* This is stupid. This function should be a boolean predicate */ -unsigned int -DEFUN(NAME(aout,canonicalize_reloc),(abfd, section, relptr, symbols), - bfd *abfd AND - sec_ptr section AND - arelent **relptr AND - asymbol **symbols) -{ - arelent *tblptr = section->relocation; - unsigned int count; - - if (!(tblptr || NAME(aout,slurp_reloc_table)(abfd, section, symbols))) - return 0; - - if (section->flags & SEC_CONSTRUCTOR) { - arelent_chain *chain = section->constructor_chain; - for (count = 0; count < section->reloc_count; count ++) { - *relptr ++ = &chain->relent; - chain = chain->next; - } - } - else { - tblptr = section->relocation; - if (!tblptr) return 0; - - for (count = 0; count++ < section->reloc_count;) - { - *relptr++ = tblptr++; - } - } - *relptr = 0; - - return section->reloc_count; -} - -unsigned int -DEFUN(NAME(aout,get_reloc_upper_bound),(abfd, asect), - bfd *abfd AND - sec_ptr asect) -{ - if (bfd_get_format (abfd) != bfd_object) { - bfd_error = invalid_operation; - return 0; - } - if (asect->flags & SEC_CONSTRUCTOR) { - return (sizeof (arelent *) * (asect->reloc_count+1)); - } - - - if (asect == obj_datasec (abfd)) - return (sizeof (arelent *) * - ((exec_hdr(abfd)->a_drsize / obj_reloc_entry_size (abfd)) - +1)); - - if (asect == obj_textsec (abfd)) - return (sizeof (arelent *) * - ((exec_hdr(abfd)->a_trsize / obj_reloc_entry_size (abfd)) - +1)); - - bfd_error = invalid_operation; - return 0; -} - - - unsigned int -DEFUN(NAME(aout,get_symtab_upper_bound),(abfd), - bfd *abfd) -{ - if (!NAME(aout,slurp_symbol_table)(abfd)) return 0; - - return (bfd_get_symcount (abfd)+1) * (sizeof (aout_symbol_type *)); -} - alent * -DEFUN(NAME(aout,get_lineno),(ignore_abfd, ignore_symbol), - bfd *ignore_abfd AND - asymbol *ignore_symbol) -{ -return (alent *)NULL; -} - - -void -DEFUN(NAME(aout,print_symbol),(ignore_abfd, afile, symbol, how), - bfd *ignore_abfd AND - PTR afile AND - asymbol *symbol AND - bfd_print_symbol_type how) -{ - FILE *file = (FILE *)afile; - - switch (how) { - case bfd_print_symbol_name: - if (symbol->name) - fprintf(file,"%s", symbol->name); - break; - case bfd_print_symbol_more: - fprintf(file,"%4x %2x %2x",(unsigned)(aout_symbol(symbol)->desc & 0xffff), - (unsigned)(aout_symbol(symbol)->other & 0xff), - (unsigned)(aout_symbol(symbol)->type)); - break; - case bfd_print_symbol_all: - { - CONST char *section_name = symbol->section == (asection *)NULL ? - "*abs" : symbol->section->name; - - bfd_print_symbol_vandf((PTR)file,symbol); - - fprintf(file," %-5s %04x %02x %02x", - section_name, - (unsigned)(aout_symbol(symbol)->desc & 0xffff), - (unsigned)(aout_symbol(symbol)->other & 0xff), - (unsigned)(aout_symbol(symbol)->type & 0xff)); - if (symbol->name) - fprintf(file," %s", symbol->name); - } - break; - } -} - -/* - provided a BFD, a section and an offset into the section, calculate - and return the name of the source file and the line nearest to the - wanted location. -*/ - -boolean -DEFUN(NAME(aout,find_nearest_line),(abfd, - section, - symbols, - offset, - filename_ptr, - functionname_ptr, - line_ptr), - bfd *abfd AND - asection *section AND - asymbol **symbols AND - bfd_vma offset AND - CONST char **filename_ptr AND - CONST char **functionname_ptr AND - unsigned int *line_ptr) -{ - /* Run down the file looking for the filename, function and linenumber */ - asymbol **p; - static char buffer[100]; - bfd_vma high_line_vma = ~0; - bfd_vma low_func_vma = 0; - asymbol *func = 0; - *filename_ptr = abfd->filename; - *functionname_ptr = 0; - *line_ptr = 0; - if (symbols != (asymbol **)NULL) { - for (p = symbols; *p; p++) { - aout_symbol_type *q = (aout_symbol_type *)(*p); - switch (q->type){ - case N_SO: - *filename_ptr = q->symbol.name; - if (obj_textsec(abfd) != section) { - return true; - } - break; - case N_SLINE: - - case N_DSLINE: - case N_BSLINE: - /* We'll keep this if it resolves nearer than the one we have already */ - if (q->symbol.value >= offset && - q->symbol.value < high_line_vma) { - *line_ptr = q->desc; - high_line_vma = q->symbol.value; - } - break; - case N_FUN: - { - /* We'll keep this if it is nearer than the one we have already */ - if (q->symbol.value >= low_func_vma && - q->symbol.value <= offset) { - low_func_vma = q->symbol.value; - func = (asymbol *)q; - } - if (*line_ptr && func) { - CONST char *function = func->name; - char *p; - strncpy(buffer, function, sizeof(buffer)-1); - buffer[sizeof(buffer)-1] = 0; - /* Have to remove : stuff */ - p = strchr(buffer,':'); - if (p != NULL) { *p = '\0'; } - *functionname_ptr = buffer; - return true; - - } - } - break; - } - } - } - - return true; - -} - -int -DEFUN(NAME(aout,sizeof_headers),(abfd, execable), - bfd *abfd AND - boolean execable) -{ - return adata(abfd)->exec_bytes_size; -} diff --git a/bfd/archive.c b/bfd/archive.c deleted file mode 100644 index 17ee03bb763..00000000000 --- a/bfd/archive.c +++ /dev/null @@ -1,1329 +0,0 @@ -/* BFD back-end for archive files (libraries). - Copyright (C) 1990-1991 Free Software Foundation, Inc. - Written by Cygnus Support. Mostly Gumby Henkel-Wallace's fault. - -This file is part of BFD, the Binary File Descriptor library. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/*doc* -@setfilename archive-info -@section Archives - -Gumby, you promised to write this bit... - -Archives are supported in BFD in @code{archive.c}. - -An archive is represented internally just like another BFD, with a -pointer to a chain of contained BFDs. Archives can be created by -opening BFDs, linking them together and attaching them as children to -another BFD and then closing the parent BFD. - -*-*/ - -/* Assumes: - o - all archive elements start on an even boundary, newline padded; - o - all arch headers are char *; - o - all arch headers are the same size (across architectures). -*/ - -/* $Id$ */ - -#include "bfd.h" -#include "sysdep.h" -#include "libbfd.h" -#include "ar.h" -#include "ranlib.h" - -#ifdef GNU960 -#define BFD_GNU960_ARMAG(abfd) (BFD_COFF_FILE_P((abfd)) ? ARMAG : ARMAGB) -#endif - -/* We keep a cache of archive filepointers to archive elements to - speed up searching the archive by filepos. We only add an entry to - the cache when we actually read one. We also don't sort the cache; - it's short enough to search linearly. - Note that the pointers here point to the front of the ar_hdr, not - to the front of the contents! -*/ -struct ar_cache { - file_ptr ptr; - bfd* arelt; - struct ar_cache *next; -}; - -#define ar_padchar(abfd) ((abfd)->xvec->ar_pad_char) -#define ar_maxnamelen(abfd) ((abfd)->xvec->ar_max_namelen) - -#define arch_hdr(bfd) ((struct ar_hdr *) \ - (((struct areltdata *)((bfd)->arelt_data))->arch_header)) - -boolean -_bfd_generic_mkarchive (abfd) - bfd *abfd; -{ - set_tdata (abfd, bfd_zalloc(abfd, sizeof (struct artdata))); - - if (bfd_ardata (abfd) == NULL) { - bfd_error = no_memory; - return false; - } - bfd_ardata(abfd)->cache = 0; - return true; -} - -/*proto* bfd_get_next_mapent -What this does -*; PROTO(symindex, bfd_get_next_mapent, (bfd *, symindex, carsym **)); -*/ -symindex -bfd_get_next_mapent (abfd, prev, entry) - bfd *abfd; - symindex prev; - carsym **entry; -{ - if (!bfd_has_map (abfd)) { - bfd_error = invalid_operation; - return BFD_NO_MORE_SYMBOLS; - } - - if (prev == BFD_NO_MORE_SYMBOLS) prev = 0; - else if (++prev >= bfd_ardata (abfd)->symdef_count) - return BFD_NO_MORE_SYMBOLS; - - *entry = (bfd_ardata (abfd)->symdefs + prev); - return prev; -} - - -/* To be called by backends only */ -bfd * -_bfd_create_empty_archive_element_shell (obfd) - bfd *obfd; -{ - bfd *nbfd; - - nbfd = new_bfd_contained_in(obfd); - if (nbfd == NULL) { - bfd_error = no_memory; - return NULL; - } - return nbfd; -} - -/*proto* bfd_set_archive_head - -Used whilst processing archives. Sets the head of the chain of BFDs -contained in an archive to @var{new_head}. (see chapter on archives) - -*; PROTO(boolean, bfd_set_archive_head, (bfd *output, bfd *new_head)); - -*/ - -boolean -DEFUN(bfd_set_archive_head,(output_archive, new_head), - bfd *output_archive AND - bfd *new_head) -{ - - output_archive->archive_head = new_head; - return true; -} - -bfd * -look_for_bfd_in_cache (arch_bfd, filepos) - bfd *arch_bfd; - file_ptr filepos; -{ - struct ar_cache *current; - - for (current = bfd_ardata (arch_bfd)->cache; current != NULL; - current = current->next) - if (current->ptr == filepos) return current->arelt; - - return NULL; -} - -/* Kind of stupid to call cons for each one, but we don't do too many */ -boolean -add_bfd_to_cache (arch_bfd, filepos, new_elt) - bfd *arch_bfd, *new_elt; - file_ptr filepos; -{ - struct ar_cache *new_cache = (struct ar_cache *) - bfd_zalloc(arch_bfd, sizeof (struct ar_cache)); - - if (new_cache == NULL) { - bfd_error = no_memory; - return false; - } - - new_cache->ptr = filepos; - new_cache->arelt = new_elt; - new_cache->next = (struct ar_cache *)NULL; - if (bfd_ardata (arch_bfd)->cache == NULL) - bfd_ardata (arch_bfd)->cache = new_cache; - else { - struct ar_cache *current = bfd_ardata (arch_bfd)->cache; - - for (; current->next != NULL; current = current->next); - current->next = new_cache; - } - - return true; -} - - - -/* The name begins with space. Hence the rest of the name is an index into - the string table. */ - -char * -get_extended_arelt_filename (arch, name) - bfd *arch; - char *name; -{ -#ifndef errno - extern int errno; -#endif - unsigned long index = 0; - - /* Should extract string so that I can guarantee not to overflow into - the next region, but I"m too lazy. */ - errno = 0; - index = strtol (name, NULL, 10); - if (errno != 0) { - bfd_error = malformed_archive; - return NULL; - } - - return bfd_ardata (arch)->extended_names + index; -} - -/* This functions reads an arch header and returns an areltdata pointer, or - NULL on error. - - Presumes the file pointer is already in the right place (ie pointing - to the ar_hdr in the file). Moves the file pointer; on success it - should be pointing to the front of the file contents; on failure it - could have been moved arbitrarily. -*/ - -struct areltdata * -snarf_ar_hdr (abfd) - bfd *abfd; -{ -#ifndef errno - extern int errno; -#endif - - struct ar_hdr hdr; - char *hdrp = (char *) &hdr; - unsigned int parsed_size; - struct areltdata *ared; - char *filename = NULL; - unsigned int namelen = 0; - unsigned int allocsize = sizeof (struct areltdata) + sizeof (struct ar_hdr); - char *allocptr; - - if (bfd_read ((PTR)hdrp, 1, sizeof (struct ar_hdr), abfd) - != sizeof (struct ar_hdr)) { - bfd_error = no_more_archived_files; - return NULL; - } - if (strncmp ((hdr.ar_fmag), ARFMAG, 2)) { - bfd_error = malformed_archive; - return NULL; - } - - errno = 0; - parsed_size = strtol (hdr.ar_size, NULL, 10); - if (errno != 0) { - bfd_error = malformed_archive; - return NULL; - } - - /* extract the filename from the archive - there are two ways to - specify an extendend name table, either the first char of the - name is a space, or it's a slash */ - if ((hdr.ar_name[0] == '/' || hdr.ar_name[0] == ' ') && bfd_ardata (abfd)->extended_names != NULL) { - filename = get_extended_arelt_filename (abfd, hdr.ar_name); - if (filename == NULL) { - bfd_error = malformed_archive; - return NULL; - } - } - else - { - /* We judge the end of the name by looking for a space or a - padchar */ - - namelen = 0; - - while (namelen < (unsigned)ar_maxnamelen(abfd) && - ( hdr.ar_name[namelen] != 0 && - hdr.ar_name[namelen] != ' ' && - hdr.ar_name[namelen] != ar_padchar(abfd))) { - namelen++; - } - - allocsize += namelen + 1; - } - - allocptr = bfd_zalloc(abfd, allocsize); - if (allocptr == NULL) { - bfd_error = no_memory; - return NULL; - } - - ared = (struct areltdata *) allocptr; - - ared->arch_header = allocptr + sizeof (struct areltdata); - memcpy ((char *) ared->arch_header, (char *) &hdr, sizeof (struct ar_hdr)); - ared->parsed_size = parsed_size; - - if (filename != NULL) ared->filename = filename; - else { - ared->filename = allocptr + (sizeof (struct areltdata) + - sizeof (struct ar_hdr)); - if (namelen) - memcpy (ared->filename, hdr.ar_name, namelen); - ared->filename[namelen] = '\0'; - } - - return ared; -} - -bfd * -get_elt_at_filepos (archive, filepos) - bfd *archive; - file_ptr filepos; -{ - struct areltdata *new_areldata; - bfd *n_nfd; - - n_nfd = look_for_bfd_in_cache (archive, filepos); - if (n_nfd) return n_nfd; - - if (0 > bfd_seek (archive, filepos, SEEK_SET)) { - bfd_error = system_call_error; - return NULL; - } - - if ((new_areldata = snarf_ar_hdr (archive)) == NULL) return NULL; - - n_nfd = _bfd_create_empty_archive_element_shell (archive); - if (n_nfd == NULL) { - bfd_release (archive, (PTR)new_areldata); - return NULL; - } - n_nfd->origin = bfd_tell (archive); - n_nfd->arelt_data = (PTR) new_areldata; - n_nfd->filename = new_areldata->filename; - - if (add_bfd_to_cache (archive, filepos, n_nfd)) - return n_nfd; - - /* huh? */ - bfd_release (archive, (PTR)n_nfd); - bfd_release (archive, (PTR)new_areldata); - return NULL; -} - -/*proto* bfd_get_elt_at_index -Return the sub bfd contained within the archive at archive index n. - -*; PROTO(bfd *, bfd_get_elt_at_index, (bfd *, int)); - -*/ -bfd * -bfd_get_elt_at_index (abfd, index) - bfd *abfd; - int index; -{ - bfd *result = - get_elt_at_filepos - (abfd, (bfd_ardata (abfd)->symdefs + index)->file_offset); - return result; -} - -/*proto* bfd_openr_next_archived_file -Initially provided a BFD containing an archive and NULL, opens a BFD -on the first contained element and returns that. Subsequent calls to -bfd_openr_next_archived_file should pass the archive and the previous -return value to return a created BFD to the next contained element. -NULL is returned when there are no more. - -*; PROTO(bfd*, bfd_openr_next_archived_file, - (bfd *archive, bfd *previous)); - -*/ - -bfd * -DEFUN(bfd_openr_next_archived_file,(archive, last_file), - bfd *archive AND - bfd*last_file) -{ - - if ((bfd_get_format (archive) != bfd_archive) || - (archive->direction == write_direction)) { - bfd_error = invalid_operation; - return NULL; - } - - - return BFD_SEND (archive, - openr_next_archived_file, - (archive, - last_file)); - -} - -bfd *bfd_generic_openr_next_archived_file(archive, last_file) - bfd *archive; - bfd *last_file; -{ - file_ptr filestart; - - if (!last_file) - filestart = bfd_ardata (archive)->first_file_filepos; - else { - unsigned int size = arelt_size(last_file); - /* Pad to an even boundary... */ - filestart = last_file->origin + size + size%2; - } - - return get_elt_at_filepos (archive, filestart); -} - - -bfd_target * -bfd_generic_archive_p (abfd) - bfd *abfd; -{ - char armag[SARMAG+1]; - - if (bfd_read ((PTR)armag, 1, SARMAG, abfd) != SARMAG) { - bfd_error = wrong_format; - return 0; - } - -#ifdef GNU960 - if (strncmp (armag, BFD_GNU960_ARMAG(abfd), SARMAG)) return 0; -#else - if (strncmp (armag, ARMAG, SARMAG)) return 0; -#endif - - /* We are setting bfd_ardata(abfd) here, but since bfd_ardata - involves a cast, we can't do it as the left operand of assignment. */ - set_tdata (abfd, bfd_zalloc(abfd,sizeof (struct artdata))); - - if (bfd_ardata (abfd) == NULL) { - bfd_error = no_memory; - return 0; - } - - bfd_ardata (abfd)->first_file_filepos = SARMAG; - - if (!BFD_SEND (abfd, _bfd_slurp_armap, (abfd))) { - bfd_release(abfd, bfd_ardata (abfd)); - abfd->tdata = NULL; - return 0; - } - - if (!BFD_SEND (abfd, _bfd_slurp_extended_name_table, (abfd))) { - bfd_release(abfd, bfd_ardata (abfd)); - abfd->tdata = NULL; - return 0; - } - - return abfd->xvec; -} - -/* Returns false on error, true otherwise */ -boolean -bfd_slurp_bsd_armap (abfd) - bfd *abfd; -{ - - struct areltdata *mapdata; - char nextname[17]; - unsigned int counter = 0; - int *raw_armap, *rbase; - struct artdata *ardata = bfd_ardata (abfd); - char *stringbase; - - /* FIXME, if the read fails, this routine quietly returns "true"!! - It should probably do that if the read gives 0 bytes (empty archive), - but fail for any other size... */ - if (bfd_read ((PTR)nextname, 1, 16, abfd) == 16) { - /* The archive has at least 16 bytes in it */ - bfd_seek (abfd, -16L, SEEK_CUR); - - /* This should be using RANLIBMAG, but at least it can be grepped for - in this comment. */ - if (strncmp (nextname, "__.SYMDEF ", 16)) { - bfd_has_map (abfd) = false; - return true; - } - - mapdata = snarf_ar_hdr (abfd); - if (mapdata == NULL) return false; - - raw_armap = (int *) bfd_zalloc(abfd,mapdata->parsed_size); - if (raw_armap == NULL) { - bfd_error = no_memory; - byebye: - bfd_release (abfd, (PTR)mapdata); - return false; - } - - if (bfd_read ((PTR)raw_armap, 1, mapdata->parsed_size, abfd) != - mapdata->parsed_size) { - bfd_error = malformed_archive; - bfd_release (abfd, (PTR)raw_armap); - goto byebye; - } - - ardata->symdef_count = bfd_h_get_32(abfd, (PTR)raw_armap) / sizeof (struct symdef); - ardata->cache = 0; - rbase = raw_armap+1; - ardata->symdefs = (carsym *) rbase; - stringbase = ((char *) (ardata->symdefs + ardata->symdef_count)) + 4; - - for (;counter < ardata->symdef_count; counter++) { - struct symdef *sym = ((struct symdef *) rbase) + counter; - sym->s.name = bfd_h_get_32(abfd, (PTR)(&(sym->s.string_offset))) + stringbase; - sym->file_offset = bfd_h_get_32(abfd, (PTR)( &(sym->file_offset))); - } - - ardata->first_file_filepos = bfd_tell (abfd); - /* Pad to an even boundary if you have to */ - ardata->first_file_filepos += (ardata-> first_file_filepos) %2; - /* FIXME, we should provide some way to free raw_ardata when - we are done using the strings from it. For now, it seems - to be allocated on an obstack anyway... */ - bfd_has_map (abfd) = true; - } - return true; -} - -/* Returns false on error, true otherwise */ -boolean -bfd_slurp_coff_armap (abfd) - bfd *abfd; -{ - struct areltdata *mapdata; - char nextname; - int *raw_armap, *rawptr; - struct artdata *ardata = bfd_ardata (abfd); - char *stringbase; - unsigned int stringsize; - carsym *carsyms; - int result; - - result = bfd_read ((PTR)&nextname, 1, 1, abfd); - bfd_seek (abfd, -1L, SEEK_CUR); - - if (result != 1 || nextname != '/') { - /* Actually I think this is an error for a COFF archive */ - bfd_has_map (abfd) = false; - return true; - } - - mapdata = snarf_ar_hdr (abfd); - if (mapdata == NULL) return false; - - raw_armap = (int *) bfd_alloc(abfd,mapdata->parsed_size); - - if (raw_armap == NULL) - { - bfd_error = no_memory; - byebye: - bfd_release (abfd, (PTR)mapdata); - return false; - } - - /* read in the raw map */ - if (bfd_read ((PTR)raw_armap, 1, mapdata->parsed_size, abfd) != - mapdata->parsed_size) { - bfd_error = malformed_archive; - oops: - bfd_release (abfd, (PTR)raw_armap); - goto byebye; - } - - /* The coff armap must be read sequentially. So we construct a bsd-style - one in core all at once, for simplicity. - - It seems that all numeric information in a coff archive is always - in big endian format, nomatter the host or target. */ - - stringsize = mapdata->parsed_size - (4 * (_do_getb32((PTR)raw_armap))) - 4; - - { - unsigned int nsymz = _do_getb32( (PTR)raw_armap); - unsigned int carsym_size = (nsymz * sizeof (carsym)); - unsigned int ptrsize = (4 * nsymz); - unsigned int i; - ardata->symdefs = (carsym *) bfd_zalloc(abfd,carsym_size + stringsize + 1); - if (ardata->symdefs == NULL) { - bfd_error = no_memory; - goto oops; - } - carsyms = ardata->symdefs; - - stringbase = ((char *) ardata->symdefs) + carsym_size; - memcpy (stringbase, (char*)raw_armap + ptrsize + 4, stringsize); - - - /* OK, build the carsyms */ - for (i = 0; i < nsymz; i++) - { - rawptr = raw_armap + i + 1; - carsyms->file_offset = _do_getb32((PTR)rawptr); - carsyms->name = stringbase; - for (; *(stringbase++);); - carsyms++; - } - *stringbase = 0; - } - ardata->symdef_count = _do_getb32((PTR)raw_armap); - ardata->first_file_filepos = bfd_tell (abfd); - /* Pad to an even boundary if you have to */ - ardata->first_file_filepos += (ardata->first_file_filepos) %2; - - /* We'd like to release these allocations, but we have allocated stuff - since then (using the same obstack, if bfd_release is obstack based). - So they will stick around until the BFD is closed. */ - /* bfd_release (abfd, (PTR)raw_armap); - bfd_release (abfd, (PTR)mapdata); */ - bfd_has_map (abfd) = true; - return true; -} - -/** Extended name table. - - Normally archives support only 14-character filenames. - - Intel has extended the format: longer names are stored in a special - element (the first in the archive, or second if there is an armap); - the name in the ar_hdr is replaced by . Index is the P.R. of an int (radix: 8). Data General have - extended the format by using the prefix // for the special element */ - -/* Returns false on error, true otherwise */ -boolean -_bfd_slurp_extended_name_table (abfd) - bfd *abfd; -{ - char nextname[17]; - struct areltdata *namedata; - - /* FIXME: Formatting sucks here, and in case of failure of BFD_READ, - we probably don't want to return true. */ - if (bfd_read ((PTR)nextname, 1, 16, abfd) == 16) { - - bfd_seek (abfd, -16L, SEEK_CUR); - - if (strncmp (nextname, "ARFILENAMES/ ", 16) != 0 && - strncmp (nextname, "// ", 16) != 0) - { - bfd_ardata (abfd)->extended_names = NULL; - return true; - } - - namedata = snarf_ar_hdr (abfd); - if (namedata == NULL) return false; - - bfd_ardata (abfd)->extended_names = bfd_zalloc(abfd,namedata->parsed_size); - if (bfd_ardata (abfd)->extended_names == NULL) { - bfd_error = no_memory; - byebye: - bfd_release (abfd, (PTR)namedata); - return false; - } - - if (bfd_read ((PTR)bfd_ardata (abfd)->extended_names, 1, - namedata->parsed_size, abfd) != namedata->parsed_size) { - bfd_error = malformed_archive; - bfd_release (abfd, (PTR)(bfd_ardata (abfd)->extended_names)); - bfd_ardata (abfd)->extended_names = NULL; - goto byebye; - } - - /* Since the archive is supposed to be printable if it contains - text, the entries in the list are newline-padded, not null - padded. We'll fix that there.. */ - { - char *temp = bfd_ardata (abfd)->extended_names; - for (; *temp != '\0'; ++temp) - if (*temp == '\n') *temp = '\0'; - } - - /* Pad to an even boundary if you have to */ - bfd_ardata (abfd)->first_file_filepos = bfd_tell (abfd); - bfd_ardata (abfd)->first_file_filepos += - (bfd_ardata (abfd)->first_file_filepos) %2; - - /* FIXME, we can't release namedata here because it was allocated - below extended_names on the obstack... */ - /* bfd_release (abfd, namedata); */ - } - return true; -} - -static -char *normalize(file) -char *file; -{ - char * filename = strrchr(file, '/'); - if (filename != (char *)NULL) { - filename ++; - } - else { - filename = file; - } -return filename; -} - -/* Follows archive_head and produces an extended name table if necessary. - Returns (in tabloc) a pointer to an extended name table, and in tablen - the length of the table. If it makes an entry it clobbers the filename - so that the element may be written without further massage. - Returns true if it ran successfully, false if something went wrong. - A successful return may still involve a zero-length tablen! - */ -boolean -bfd_construct_extended_name_table (abfd, tabloc, tablen) - bfd *abfd; - char **tabloc; - unsigned int *tablen; -{ - unsigned int maxname = abfd->xvec->ar_max_namelen; - unsigned int total_namelen = 0; - bfd *current; - char *strptr; - - *tablen = 0; - - /* Figure out how long the table should be */ - for (current = abfd->archive_head; current != NULL; current = current->next){ - unsigned int thislen = strlen (normalize(current->filename)); - if (thislen > maxname) total_namelen += thislen + 1; /* leave room for \n */ - } - - if (total_namelen == 0) return true; - - *tabloc = bfd_zalloc (abfd,total_namelen); - if (*tabloc == NULL) { - bfd_error = no_memory; - return false; - } - - *tablen = total_namelen; - strptr = *tabloc; - - for (current = abfd->archive_head; current != NULL; current = - current->next) { - char *normal =normalize( current->filename); - unsigned int thislen = strlen (normal); - if (thislen > maxname) { - /* Works for now; may need to be re-engineered if we encounter an oddball - archive format and want to generalise this hack. */ - struct ar_hdr *hdr = arch_hdr(current); - strcpy (strptr, normal); - strptr[thislen] = '\n'; - hdr->ar_name[0] = ' '; - /* We know there will always be enough room (one of the few cases - where you may safely use sprintf). */ - sprintf ((hdr->ar_name) + 1, "%-o", (unsigned) (strptr - *tabloc)); - /* Kinda Kludgy. We should just use the returned value of sprintf - but not all implementations get this right */ - { - char *temp = hdr->ar_name +2; - for (; temp < hdr->ar_name + maxname; temp++) - if (*temp == '\0') *temp = ' '; - } - strptr += thislen + 1; - } - } - - return true; -} - -/** A couple of functions for creating ar_hdrs */ - -/* Takes a filename, returns an arelt_data for it, or NULL if it can't make one. - The filename must refer to a filename in the filesystem. - The filename field of the ar_hdr will NOT be initialized -*/ - -struct areltdata * -DEFUN(bfd_ar_hdr_from_filesystem, (abfd,filename), - bfd* abfd AND - CONST char *filename) -{ - struct stat status; - struct areltdata *ared; - struct ar_hdr *hdr; - char *temp, *temp1; - - - if (stat (filename, &status) != 0) { - bfd_error = system_call_error; - return NULL; - } - - ared = (struct areltdata *) bfd_zalloc(abfd, sizeof (struct ar_hdr) + - sizeof (struct areltdata)); - if (ared == NULL) { - bfd_error = no_memory; - return NULL; - } - hdr = (struct ar_hdr *) (((char *) ared) + sizeof (struct areltdata)); - - /* ar headers are space padded, not null padded! */ - temp = (char *) hdr; - temp1 = temp + sizeof (struct ar_hdr) - 2; - for (; temp < temp1; *(temp++) = ' '); - strncpy (hdr->ar_fmag, ARFMAG, 2); - - /* Goddamned sprintf doesn't permit MAXIMUM field lengths */ - sprintf ((hdr->ar_date), "%-12ld", status.st_mtime); - sprintf ((hdr->ar_uid), "%d", status.st_uid); - sprintf ((hdr->ar_gid), "%d", status.st_gid); - sprintf ((hdr->ar_mode), "%-8o", (unsigned) status.st_mode); - sprintf ((hdr->ar_size), "%-10ld", status.st_size); - /* Correct for a lossage in sprintf whereby it null-terminates. I cannot - understand how these C losers could design such a ramshackle bunch of - IO operations */ - temp = (char *) hdr; - temp1 = temp + sizeof (struct ar_hdr) - 2; - for (; temp < temp1; temp++) { - if (*temp == '\0') *temp = ' '; - } - strncpy (hdr->ar_fmag, ARFMAG, 2); - ared->parsed_size = status.st_size; - ared->arch_header = (char *) hdr; - - return ared; -} - -struct ar_hdr * -DEFUN(bfd_special_undocumented_glue, (abfd, filename), - bfd *abfd AND - char *filename) -{ - - return (struct ar_hdr *) bfd_ar_hdr_from_filesystem (abfd, filename) -> arch_header; -} - - -/* Analogous to stat call */ -int -bfd_generic_stat_arch_elt (abfd, buf) - bfd *abfd; - struct stat *buf; -{ - struct ar_hdr *hdr; - char *aloser; - - if (abfd->arelt_data == NULL) { - bfd_error = invalid_operation; - return -1; - } - - hdr = arch_hdr (abfd); - -#define foo(arelt, stelt, size) \ - buf->stelt = strtol (hdr->arelt, &aloser, size); \ - if (aloser == hdr->arelt) return -1; - - foo (ar_date, st_mtime, 10); - foo (ar_uid, st_uid, 10); - foo (ar_gid, st_gid, 10); - foo (ar_mode, st_mode, 8); - foo (ar_size, st_size, 10); - - return 0; -} - -void -bfd_dont_truncate_arname (abfd, pathname, arhdr) - bfd *abfd; - CONST char *pathname; - char *arhdr; -{ - /* FIXME: This interacts unpleasantly with ar's quick-append option. - Fortunately ic960 users will never use that option. Fixing this - is very hard; fortunately I know how to do it and will do so once - intel's release is out the door. */ - - struct ar_hdr *hdr = (struct ar_hdr *) arhdr; - int length; - CONST char *filename = strrchr (pathname, '/'); - int maxlen = ar_maxnamelen (abfd); - - if (filename == NULL) - filename = pathname; - else - ++filename; - - length = strlen (filename); - - if (length <= maxlen) - memcpy (hdr->ar_name, filename, length); - - if (length < maxlen) (hdr->ar_name)[length] = ar_padchar (abfd); - return; - -} - -void -bfd_bsd_truncate_arname (abfd, pathname, arhdr) - bfd *abfd; - CONST char *pathname; - char *arhdr; -{ - struct ar_hdr *hdr = (struct ar_hdr *) arhdr; - int length; - CONST char *filename = strrchr (pathname, '/'); - int maxlen = ar_maxnamelen (abfd); - - - if (filename == NULL) - filename = pathname; - else - ++filename; - - length = strlen (filename); - - if (length <= maxlen) - memcpy (hdr->ar_name, filename, length); - else { - /* pathname: meet procrustes */ - memcpy (hdr->ar_name, filename, maxlen); - length = maxlen; - } - - if (length < maxlen) (hdr->ar_name)[length] = ar_padchar (abfd); -} - -/* Store name into ar header. Truncates the name to fit. - 1> strip pathname to be just the basename. - 2> if it's short enuf to fit, stuff it in. - 3> If it doesn't end with .o, truncate it to fit - 4> truncate it before the .o, append .o, stuff THAT in. -*/ - -/* This is what gnu ar does. It's better but incompatible with the bsd ar. */ -void -bfd_gnu_truncate_arname (abfd, pathname, arhdr) - bfd *abfd; - CONST char *pathname; - char *arhdr; -{ - struct ar_hdr *hdr = (struct ar_hdr *) arhdr; - int length; - CONST char *filename = strrchr (pathname, '/'); - int maxlen = ar_maxnamelen (abfd); - - if (filename == NULL) - filename = pathname; - else - ++filename; - - length = strlen (filename); - - if (length <= maxlen) - memcpy (hdr->ar_name, filename, length); - else { /* pathname: meet procrustes */ - memcpy (hdr->ar_name, filename, maxlen); - if ((filename[length - 2] == '.') && (filename[length - 1] == 'o')) { - hdr->ar_name[maxlen - 2] = '.'; - hdr->ar_name[maxlen - 1] = 'o'; - } - length = maxlen; - } - - if (length < 16) (hdr->ar_name)[length] = ar_padchar (abfd); -} - - -PROTO (boolean, compute_and_write_armap, (bfd *arch, unsigned int elength)); - -/* The BFD is open for write and has its format set to bfd_archive */ -boolean -_bfd_write_archive_contents (arch) - bfd *arch; -{ - bfd *current; - char *etable = NULL; - unsigned int elength = 0; - boolean makemap = bfd_has_map (arch); - boolean hasobjects = false; /* if no .o's, don't bother to make a map */ - unsigned int i; - - /* Verify the viability of all entries; if any of them live in the - filesystem (as opposed to living in an archive open for input) - then construct a fresh ar_hdr for them. - */ - for (current = arch->archive_head; current; current = current->next) { - if (bfd_write_p (current)) { - bfd_error = invalid_operation; - return false; - } - if (!current->arelt_data) { - current->arelt_data = - (PTR) bfd_ar_hdr_from_filesystem (arch, current->filename); - if (!current->arelt_data) return false; - - /* Put in the file name */ - - BFD_SEND (arch, _bfd_truncate_arname,(arch, - current->filename, - (char *) arch_hdr(current))); - - - } - - if (makemap) { /* don't bother if we won't make a map! */ - if ((bfd_check_format (current, bfd_object)) -#if 0 /* FIXME -- these are not set correctly */ - && ((bfd_get_file_flags (current) & HAS_SYMS)) -#endif - ) - hasobjects = true; - } - } - - if (!bfd_construct_extended_name_table (arch, &etable, &elength)) - return false; - - bfd_seek (arch, 0, SEEK_SET); -#ifdef GNU960 - bfd_write (BFD_GNU960_ARMAG(arch), 1, SARMAG, arch); -#else - bfd_write (ARMAG, 1, SARMAG, arch); -#endif - - if (makemap && hasobjects) { - - if (compute_and_write_armap (arch, elength) != true) { - return false; - } - } - - if (elength != 0) { - struct ar_hdr hdr; - - memset ((char *)(&hdr), 0, sizeof (struct ar_hdr)); - sprintf (&(hdr.ar_name[0]), "ARFILENAMES/"); - sprintf (&(hdr.ar_size[0]), "%-10d", (int) elength); - hdr.ar_fmag[0] = '`'; hdr.ar_fmag[1] = '\n'; - for (i = 0; i < sizeof (struct ar_hdr); i++) - if (((char *)(&hdr))[i] == '\0') (((char *)(&hdr))[i]) = ' '; - bfd_write ((char *)&hdr, 1, sizeof (struct ar_hdr), arch); - bfd_write (etable, 1, elength, arch); - if ((elength % 2) == 1) bfd_write ("\n", 1, 1, arch); - - } - - for (current = arch->archive_head; current; current = current->next) { - char buffer[DEFAULT_BUFFERSIZE]; - unsigned int remaining = arelt_size (current); - struct ar_hdr *hdr = arch_hdr(current); - /* write ar header */ - - if (bfd_write ((char *)hdr, 1, sizeof(*hdr), arch) != sizeof(*hdr)) { - syserr: - bfd_error = system_call_error; - return false; - } - if (bfd_seek (current, 0L, SEEK_SET) != 0L) goto syserr; - while (remaining) - { - unsigned int amt = DEFAULT_BUFFERSIZE; - if (amt > remaining) { - amt = remaining; - } - if (bfd_read (buffer, amt, 1, current) != amt) goto syserr; - if (bfd_write (buffer, amt, 1, arch) != amt) goto syserr; - remaining -= amt; - } - if ((arelt_size (current) % 2) == 1) bfd_write ("\n", 1, 1, arch); - } -return true; -} - -/* Note that the namidx for the first symbol is 0 */ - -boolean -compute_and_write_armap (arch, elength) - bfd *arch; - unsigned int elength; -{ - bfd *current; - file_ptr elt_no = 0; - struct orl *map; - int orl_max = 15000; /* fine initial default */ - int orl_count = 0; - int stridx = 0; /* string index */ - - /* Dunno if this is the best place for this info... */ - if (elength != 0) elength += sizeof (struct ar_hdr); - elength += elength %2 ; - - map = (struct orl *) bfd_zalloc (arch,orl_max * sizeof (struct orl)); - if (map == NULL) { - bfd_error = no_memory; - return false; - } - - /* Map over each element */ - for (current = arch->archive_head; - current != (bfd *)NULL; - current = current->next, elt_no++) - { - if ((bfd_check_format (current, bfd_object) == true) - && ((bfd_get_file_flags (current) & HAS_SYMS))) { - asymbol **syms; - unsigned int storage; - unsigned int symcount; - unsigned int src_count; - - storage = get_symtab_upper_bound (current); - if (storage != 0) { - - syms = (asymbol **) bfd_zalloc (arch,storage); - if (syms == NULL) { - bfd_error = no_memory; /* FIXME -- memory leak */ - return false; - } - symcount = bfd_canonicalize_symtab (current, syms); - - - /* Now map over all the symbols, picking out the ones we want */ - for (src_count = 0; src_count flags; - if ((flags & BSF_GLOBAL) || - (flags & BSF_FORT_COMM)) { - - /* This symbol will go into the archive header */ - if (orl_count == orl_max) - { - orl_max *= 2; - map = (struct orl *) bfd_realloc (arch, (char *) map, - orl_max * sizeof (struct orl)); - } - - (map[orl_count]).name = (char **) &((syms[src_count])->name); - (map[orl_count]).pos = (file_ptr) current; - (map[orl_count]).namidx = stridx; - - stridx += strlen ((syms[src_count])->name) + 1; - ++orl_count; - } - } - } - } - } - /* OK, now we have collected all the data, let's write them out */ - if (!BFD_SEND (arch, write_armap, - (arch, elength, map, orl_count, stridx))) { - - return false; - } - - - return true; -} - -boolean -bsd_write_armap (arch, elength, map, orl_count, stridx) - bfd *arch; - unsigned int elength; - struct orl *map; - int orl_count; - int stridx; -{ - unsigned int ranlibsize = orl_count * sizeof (struct ranlib); - unsigned int stringsize = stridx + 4; - unsigned int mapsize = stringsize + ranlibsize + 4; - file_ptr firstreal; - bfd *current = arch->archive_head; - bfd *last_elt = current; /* last element arch seen */ - int temp; - int count; - struct ar_hdr hdr; - struct stat statbuf; - unsigned int i; - int padit = mapsize & 1; - - if (padit) mapsize ++; - - firstreal = mapsize + elength + sizeof (struct ar_hdr) + SARMAG; - - stat (arch->filename, &statbuf); - memset ((char *)(&hdr), 0, sizeof (struct ar_hdr)); - sprintf (hdr.ar_name, RANLIBMAG); - sprintf (hdr.ar_date, "%ld", statbuf.st_mtime); - sprintf (hdr.ar_uid, "%d", getuid()); - sprintf (hdr.ar_gid, "%d", getgid()); - sprintf (hdr.ar_size, "%-10d", (int) mapsize); - hdr.ar_fmag[0] = '`'; hdr.ar_fmag[1] = '\n'; - for (i = 0; i < sizeof (struct ar_hdr); i++) - if (((char *)(&hdr))[i] == '\0') (((char *)(&hdr))[i]) = ' '; - bfd_write ((char *)&hdr, 1, sizeof (struct ar_hdr), arch); - bfd_h_put_32(arch, ranlibsize, (PTR)&temp); - bfd_write (&temp, 1, sizeof (temp), arch); - - for (count = 0; count < orl_count; count++) { - struct symdef outs; - struct symdef *outp = &outs; - - if (((bfd *)(map[count]).pos) != last_elt) { - do { - firstreal += arelt_size (current) + sizeof (struct ar_hdr); - firstreal += firstreal % 2; - current = current->next; - } while (current != (bfd *)(map[count]).pos); - } /* if new archive element */ - - last_elt = current; - bfd_h_put_32(arch, ((map[count]).namidx),(PTR) &outs.s.string_offset); - bfd_h_put_32(arch, firstreal,(PTR) &outs.file_offset); - bfd_write ((char *)outp, 1, sizeof (outs), arch); - } - - /* now write the strings themselves */ - bfd_h_put_32(arch, stridx, (PTR)&temp); - bfd_write ((PTR)&temp, 1, sizeof (temp), arch); - for (count = 0; count < orl_count; count++) - bfd_write (*((map[count]).name), 1, strlen (*((map[count]).name))+1, arch); - - /* The spec sez this should be a newline. But in order to be - bug-compatible for sun's ar we use a null. */ - if (padit) - bfd_write("\0",1,1,arch); - - return true; -} - - -/* A coff armap looks like : - ARMAG - struct ar_hdr with name = '/' - number of symbols - offset of file for symbol 0 - offset of file for symbol 1 - .. - offset of file for symbol n-1 - symbol name 0 - symbol name 1 - .. - symbol name n-1 - -*/ - -boolean -coff_write_armap (arch, elength, map, symbol_count, stridx) - bfd *arch; - unsigned int elength; - struct orl *map; - unsigned int symbol_count; - int stridx; -{ - /* The size of the ranlib is the number of exported symbols in the - archive * the number of bytes in a int, + an int for the count */ - - unsigned int ranlibsize = (symbol_count * 4) + 4; - unsigned int stringsize = stridx; - unsigned int mapsize = stringsize + ranlibsize; - file_ptr archive_member_file_ptr; - bfd *current = arch->archive_head; - bfd *last_elt = current; /* last element arch seen */ - int count; - struct ar_hdr hdr; - unsigned int i; - int padit = mapsize & 1; - - if (padit) mapsize ++; - - /* work out where the first object file will go in the archive */ - archive_member_file_ptr = mapsize + elength + sizeof (struct ar_hdr) + SARMAG; - - memset ((char *)(&hdr), 0, sizeof (struct ar_hdr)); - hdr.ar_name[0] = '/'; - sprintf (hdr.ar_size, "%-10d", (int) mapsize); - sprintf (hdr.ar_date, "%ld", (long)time (NULL)); - /* This, at least, is what Intel coff sets the values to.: */ - sprintf ((hdr.ar_uid), "%d", 0); - sprintf ((hdr.ar_gid), "%d", 0); - sprintf ((hdr.ar_mode), "%-7o",(unsigned ) 0); - hdr.ar_fmag[0] = '`'; hdr.ar_fmag[1] = '\n'; - - for (i = 0; i < sizeof (struct ar_hdr); i++) - if (((char *)(&hdr))[i] == '\0') (((char *)(&hdr))[i]) = ' '; - - /* Write the ar header for this item and the number of symbols */ - - - bfd_write ((PTR)&hdr, 1, sizeof (struct ar_hdr), arch); - - bfd_write_bigendian_4byte_int(arch, symbol_count); - - /* Two passes, first write the file offsets for each symbol - - remembering that each offset is on a two byte boundary - */ - - /* Write out the file offset for the file associated with each - symbol, and remember to keep the offsets padded out */ - - current = arch->archive_head; - count = 0; - while (current != (bfd *)NULL && count < symbol_count) { - /* For each symbol which is used defined in this object, write out - the object file's address in the archive */ - - while (((bfd *)(map[count]).pos) == current) { - bfd_write_bigendian_4byte_int(arch, archive_member_file_ptr); - count++; - } - /* Add size of this archive entry */ - archive_member_file_ptr += arelt_size (current) + sizeof (struct - ar_hdr); - /* remember aboout the even alignment */ - archive_member_file_ptr += archive_member_file_ptr % 2; - current = current->next; - } - - - - /* now write the strings themselves */ - for (count = 0; count < symbol_count; count++) { - bfd_write ((PTR)*((map[count]).name), - 1, - strlen (*((map[count]).name))+1, arch); - - } - /* The spec sez this should be a newline. But in order to be - bug-compatible for arc960 we use a null. */ - if (padit) - bfd_write("\0",1,1,arch); - - return true; -} diff --git a/bfd/archures.c b/bfd/archures.c deleted file mode 100644 index 9141d5e1301..00000000000 --- a/bfd/archures.c +++ /dev/null @@ -1,613 +0,0 @@ -/* BFD library support routines for architectures. - Copyright (C) 1990-1991 Free Software Foundation, Inc. - Hacked by John Gilmore and Steve Chamberlain of Cygnus Support. - - -This file is part of BFD, the Binary File Descriptor library. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/*doc* -@section Architectures -BFD's idea of an architecture is implimented in @code{archures.c}. BFD -keeps one atom in a BFD describing the architecture of the data -attached to the BFD; a pointer to a @code{bfd_arch_info_type}. - -Pointers to structures can be requested independently of a bfd so that -an architecture's information can be interrogated without access to an -open bfd. - -The arch information is provided by each architecture package. The -set of default architectures is selected by the #define -@code{SELECT_ARCHITECTURES}. This is normally set up in the -@code{config\/h\-} file of your choice. If the name is not defined, -then all the architectures supported are included. - -When BFD starts up, all the architectures are called with an -initialize method. It is up to the architecture back end to insert as -many items into the list of arches as it wants to, generally this -would be one for each machine and one for the default case (an item -with a machine field of 0). - -*/ - -/*proto* bfd_architecture -This enum gives the object file's CPU -architecture, in a global sense. E.g. what processor family does it -belong to? There is another field, which indicates what processor -within the family is in use. The machine gives a number which -distingushes different versions of the architecture, containing for -example 2 and 3 for Intel i960 KA and i960 KB, and 68020 and 68030 for -Motorola 68020 and 68030. - -*+ -enum bfd_architecture -{ - bfd_arch_unknown, {* File arch not known *} - bfd_arch_obscure, {* Arch known, not one of these *} - bfd_arch_m68k, {* Motorola 68xxx *} - bfd_arch_vax, {* DEC Vax *} - bfd_arch_i960, {* Intel 960 *} - {* The order of the following is important. - lower number indicates a machine type that - only accepts a subset of the instructions - available to machines with higher numbers. - The exception is the "ca", which is - incompatible with all other machines except - "core". *} - -#define bfd_mach_i960_core 1 -#define bfd_mach_i960_ka_sa 2 -#define bfd_mach_i960_kb_sb 3 -#define bfd_mach_i960_mc 4 -#define bfd_mach_i960_xa 5 -#define bfd_mach_i960_ca 6 - - bfd_arch_a29k, {* AMD 29000 *} - bfd_arch_sparc, {* SPARC *} - bfd_arch_mips, {* MIPS Rxxxx *} - bfd_arch_i386, {* Intel 386 *} - bfd_arch_ns32k, {* National Semiconductor 32xxx *} - bfd_arch_tahoe, {* CCI/Harris Tahoe *} - bfd_arch_i860, {* Intel 860 *} - bfd_arch_romp, {* IBM ROMP PC/RT *} - bfd_arch_alliant, {* Alliant *} - bfd_arch_convex, {* Convex *} - bfd_arch_m88k, {* Motorola 88xxx *} - bfd_arch_pyramid, {* Pyramid Technology *} - bfd_arch_h8300, {* Hitachi H8/300 *} - bfd_arch_rs6000, {* IBM RS/6000 *} - bfd_arch_last - }; -*- - -stuff - -*/ - - - -/* $Id$ */ - -#include "bfd.h" -#include "sysdep.h" -#include "libbfd.h" - -/*proto* bfd_arch_info -This structure contains information on architectures. -*+ -typedef int bfd_reloc_code_type; - -typedef struct bfd_arch_info -{ - int bits_per_word; - int bits_per_address; - int bits_per_byte; - enum bfd_architecture arch; - long mach; - char *arch_name; - CONST char *printable_name; -{* true if this is the default machine for the architecture *} - boolean the_default; - CONST struct bfd_arch_info * EXFUN((*compatible),(CONST struct bfd_arch_info *a, - CONST struct bfd_arch_info *b)); - - boolean EXFUN((*scan),(CONST struct bfd_arch_info *,CONST char *)); - unsigned int EXFUN((*disassemble),(bfd_vma addr, CONST char *data, - PTR stream)); - CONST struct reloc_howto_struct *EXFUN((*reloc_type_lookup), (CONST struct - bfd_arch_info *, - bfd_reloc_code_type code)); - - struct bfd_arch_info *next; - -} bfd_arch_info_type; - - -*- -*/ - -bfd_arch_info_type *bfd_arch_info_list; - - -/*proto* bfd_printable_name - -Return a printable string representing the architecture and machine -from the pointer to the arch info structure - -*; CONST char *EXFUN(bfd_printable_name,(bfd *abfd)); - -*/ - -CONST char * -DEFUN(bfd_printable_name, (abfd), - bfd *abfd) -{ - return abfd->arch_info->printable_name; -} - - - -/*proto* -*i bfd_scan_arch -This routine is provided with a string and tries to work out if bfd -supports any cpu which could be described with the name provided. The -routine returns a pointer to an arch_info structure if a machine is -found, otherwise NULL. - -*; bfd_arch_info_type *EXFUN(bfd_scan_arch,(CONST char *)); -*/ - -bfd_arch_info_type * -DEFUN(bfd_scan_arch,(string), - CONST char *string) -{ - struct bfd_arch_info *ap; - - /* Look through all the installed architectures */ - for (ap = bfd_arch_info_list; - ap != (bfd_arch_info_type *)NULL; - ap = ap->next) { - - if (ap->scan(ap, string)) - return ap; - } - return (bfd_arch_info_type *)NULL; -} - - - -/*proto* bfd_arch_get_compatible -This routine is used to determine whether two BFDs' architectures and -machine types are compatible. It calculates the lowest common -denominator between the two architectures and machine types implied by -the BFDs and returns a pointer to an arch_info structure describing -the compatible machine. - -*; CONST bfd_arch_info_type *EXFUN(bfd_arch_get_compatible, - (CONST bfd *abfd, - CONST bfd *bbfd)); -*/ - -CONST bfd_arch_info_type * -DEFUN(bfd_arch_get_compatible,(abfd, bbfd), -CONST bfd *abfd AND -CONST bfd *bbfd) - -{ - return abfd->arch_info->compatible(abfd->arch_info,bbfd->arch_info); -} - - -/*proto-internal* bfd_default_arch_struct - -What bfds are seeded with - -*+ -extern bfd_arch_info_type bfd_default_arch_struct; -*- -*/ - -bfd_arch_info_type bfd_default_arch_struct = - { - 32,32,8,bfd_arch_unknown,0,"unknown","unknown",true, - bfd_default_compatible, bfd_default_scan, - - }; - -/*proto* bfd_set_arch_info - -*; void EXFUN(bfd_set_arch_info,(bfd *, bfd_arch_info_type *)); - -*/ - -void DEFUN(bfd_set_arch_info,(abfd, arg), -bfd *abfd AND -bfd_arch_info_type *arg) -{ - abfd->arch_info = arg; -} - -/*proto-internal* bfd_default_set_arch_mach - -Set the architecture and machine type in a bfd. This finds the correct -pointer to structure and inserts it into the arch_info pointer. - -*; boolean EXFUN(bfd_default_set_arch_mach,(bfd *abfd, - enum bfd_architecture arch, - unsigned long mach)); - -*/ - -boolean DEFUN(bfd_default_set_arch_mach,(abfd, arch, mach), - bfd *abfd AND - enum bfd_architecture arch AND - unsigned long mach) -{ - static struct bfd_arch_info *old_ptr = &bfd_default_arch_struct; - boolean found = false; - /* run through the table to find the one we want, we keep a little - cache to speed things up */ - if (old_ptr == 0 || arch != old_ptr->arch || mach != old_ptr->mach) { - bfd_arch_info_type *ptr; - old_ptr = (bfd_arch_info_type *)NULL; - for (ptr = bfd_arch_info_list; - ptr != (bfd_arch_info_type *)NULL; - ptr= ptr->next) { - if (ptr->arch == arch && - ((ptr->mach == mach) || (ptr->the_default && mach == 0))) { - old_ptr = ptr; - found = true; - break; - } - } - if (found==false) { - /*looked for it and it wasn't there, so put in the default */ - old_ptr = &bfd_default_arch_struct; - - } - } - else { - /* it was in the cache */ - found = true; - } - - abfd->arch_info = old_ptr; - - return found; -} - - - - - -/*proto* bfd_get_arch - -Returns the enumerated type which describes the supplied bfd's -architecture - -*; enum bfd_architecture EXFUN(bfd_get_arch, (bfd *abfd)); -*/ - - enum bfd_architecture DEFUN(bfd_get_arch, (abfd), bfd *abfd) - { - return abfd->arch_info->arch; - - - } - -/*proto* bfd_get_mach - -Returns the long type which describes the supplied bfd's -machine - -*; unsigned long EXFUN(bfd_get_mach, (bfd *abfd)); -*/ - -unsigned long DEFUN(bfd_get_mach, (abfd), bfd *abfd) -{ - return abfd->arch_info->mach; - } - -/*proto* bfd_arch_bits_per_byte - -Returns the number of bits in one of the architectures bytes - -*; unsigned int EXFUN(bfd_arch_bits_per_byte, (bfd *abfd)); -*/ - -unsigned int DEFUN(bfd_arch_bits_per_byte, (abfd), bfd *abfd) - { - return abfd->arch_info->bits_per_byte; - } - -/*proto* bfd_arch_bits_per_address - -Returns the number of bits in one of the architectures addresses - -*; unsigned int EXFUN(bfd_arch_bits_per_address, (bfd *abfd)); -*/ - -unsigned int DEFUN(bfd_arch_bits_per_address, (abfd), bfd *abfd) - { - return abfd->arch_info->bits_per_address; - } - - - -extern void EXFUN(bfd_h8300_arch,(void)); -extern void EXFUN(bfd_i960_arch,(void)); -extern void EXFUN(bfd_empty_arch,(void)); -extern void EXFUN(bfd_sparc_arch,(void)); -extern void EXFUN(bfd_m88k_arch,(void)); -extern void EXFUN(bfd_m68k_arch,(void)); -extern void EXFUN(bfd_vax_arch,(void)); -extern void EXFUN(bfd_a29k_arch,(void)); -extern void EXFUN(bfd_mips_arch,(void)); -extern void EXFUN(bfd_i386_arch,(void)); -extern void EXFUN(bfd_rs6000_arch,(void)); - - - -static void EXFUN((*archures_init_table[]),()) = -{ -#ifdef SELECT_ARCHITECTURES - SELECT_ARCHITECTURES, -#else - bfd_sparc_arch, - bfd_a29k_arch, - bfd_mips_arch, - bfd_h8300_arch, - bfd_i386_arch, - bfd_m88k_arch, - bfd_i960_arch, - bfd_m68k_arch, - bfd_vax_arch, - bfd_rs6000_arch, -#endif - 0 - }; - - - -/*proto-internal* - -This routine initializes the architecture dispatch table by calling -all installed architecture packages and getting them to poke around. - -*; PROTO(void, bfd_arch_init,(void)); - -*/ - -void -DEFUN_VOID(bfd_arch_init) -{ - void EXFUN((**ptable),()); - for (ptable = archures_init_table; - *ptable ; - ptable++) - { - (*ptable)(); - } -} - - -/*proto-internal* bfd_arch_linkin - -Link the provided arch info structure into the list - -*; void EXFUN(bfd_arch_linkin,(bfd_arch_info_type *)); - -*/ - -void DEFUN(bfd_arch_linkin,(ptr), - bfd_arch_info_type *ptr) -{ - ptr->next = bfd_arch_info_list; - bfd_arch_info_list = ptr; -} - - -/*proto-internal* bfd_default_compatible - -The default function for testing for compatibility - -*; CONST bfd_arch_info_type *EXFUN(bfd_default_compatible, - (CONST bfd_arch_info_type *a, - CONST bfd_arch_info_type *b)); -*/ - -CONST bfd_arch_info_type * -DEFUN(bfd_default_compatible,(a,b), - CONST bfd_arch_info_type *a AND - 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; -} - -/*proto-internal* bfd_default_scan -The default function for working out whether this is an architecture -hit and a machine hit - -*; boolean EXFUN(bfd_default_scan,(CONST struct bfd_arch_info *, CONST char *)); - -*/ - -boolean -DEFUN(bfd_default_scan,(info, string), -CONST struct bfd_arch_info *info AND -CONST char *string) -{ - CONST char *ptr_src; - CONST char *ptr_tst; - unsigned long number; - enum bfd_architecture arch; - /* First test for an exact match */ - if (strcmp(string, info->printable_name) == 0) return true; - - /* See how much of the supplied string matches with the - architecture, eg the string m68k:68020 would match the 68k entry - up to the :, then we get left with the machine number */ - - for (ptr_src = string, - ptr_tst = info->arch_name; - *ptr_src && *ptr_tst; - ptr_src++, - ptr_tst++) - { - if (*ptr_src != *ptr_tst) break; - } - - /* Chewed up as much of the architecture as will match, skip any - colons */ - if (*ptr_src == ':') ptr_src++; - - if (*ptr_src == 0) { - /* nothing more, then only keep this one if it is the default - machine for this architecture */ - return info->the_default; - } - number = 0; - while (isdigit(*ptr_src)) { - number = number * 10 + *ptr_src - '0'; - ptr_src++; - } - - switch (number) { - case 68010: - case 68020: - case 68030: - case 68040: - case 68332: - case 68050: - case 68000: - arch = bfd_arch_m68k; - break; - case 386: - case 80386: - case 486: - arch = bfd_arch_i386; - break; - case 29000: - arch = bfd_arch_a29k; - break; - - case 32016: - case 32032: - case 32132: - case 32232: - case 32332: - case 32432: - case 32532: - case 32000: - arch = bfd_arch_ns32k; - break; - - case 860: - case 80860: - arch = bfd_arch_i860; - break; - - case 6000: - arch = bfd_arch_rs6000; - break; - - default: - return false; - } - if (arch != info->arch) - return false; - - if (number != info->mach) - return false; - - return true; -} - - - - -/*proto* bfd_get_arch_info - -*; bfd_arch_info_type * EXFUN(bfd_get_arch_info,(bfd *)); - -*/ - -bfd_arch_info_type * -DEFUN(bfd_get_arch_info,(abfd), -bfd *abfd) -{ - return abfd->arch_info; -} - - -/*proto* bfd_lookup_arch - -*; bfd_arch_info_type * EXFUN(bfd_lookup_arch,(enum - bfd_architecture arch,long machine)); - -Look for the architecure info struct which matches the arguments -given. A machine of 0 will match the machine/architecture structure which -marks itself as the default. - -*/ - -bfd_arch_info_type * -DEFUN(bfd_lookup_arch,(arch, machine), -enum bfd_architecture arch AND -long machine) -{ - bfd_arch_info_type *ap; - bfd_check_init(); - for (ap = bfd_arch_info_list; - ap != (bfd_arch_info_type *)NULL; - ap = ap->next) { - if (ap->arch == arch && - ((ap->mach == machine) || (ap->the_default && machine == 0))) { - return ap; - } - } - return (bfd_arch_info_type *)NULL; -} - - - -/*proto* bfd_printable_arch_mach -Return a printable string representing the architecture and machine -type. - -NB. The use of this routine is depreciated. - -*; PROTO(CONST char *,bfd_printable_arch_mach, - (enum bfd_architecture arch, unsigned long machine)); -*/ - -CONST char * -DEFUN(bfd_printable_arch_mach,(arch, machine), - enum bfd_architecture arch AND - unsigned long machine) -{ - bfd_arch_info_type *ap = bfd_lookup_arch(arch, machine); - if(ap) return ap->printable_name; - return "UNKNOWN!"; -} diff --git a/bfd/archures.h b/bfd/archures.h deleted file mode 100755 index db14d1d228a..00000000000 --- a/bfd/archures.h +++ /dev/null @@ -1,35 +0,0 @@ -/* Intel 960 machine types */ - -/* Copyright (C) 1990, 1991 Free Software Foundation, Inc. - -This file is part of BFD, the Binary File Diddler. - -BFD 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 1, or (at your option) -any later version. - -BFD 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 BFD; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - Machine architecture and type definitions for BFD. - - These definitions are only used inside the BFD package. External programs - access them by calling bfd_scan_arch_mach() and bfd_arch_mach_string(). - - The architectures themselves are defined in bfd.h since they are an - enum needed for BFD structs. Numeric machine types are simply used - as-is, e.g. 68020. Non-numeric machine types like "i960CA" have - names in this file. */ - - -/* $Id$ */ - - diff --git a/bfd/awkscan b/bfd/awkscan deleted file mode 100755 index 69b0ceaa3ba..00000000000 --- a/bfd/awkscan +++ /dev/null @@ -1,12 +0,0 @@ -# NOTE: BEGIN pattern gives errors if other than 1st line; -# END ditto if other than last. -BEGIN { print "@c ------------------------------START TEXT FROM " FILENAME } -# -# Keep /*doc* blocks (terminated by either */ or *-*/) -/^\/\*doc\*/,/^\*\/|^\*-\*\// -# -# Also keep two kinds of /*proto blocks -/^\/\*proto\*/,/^\*\/|^\*-\*\// -/^\/\*proto-internal\*/,/^\*\/|^\*-\*\// -# -END { print "@c ------------------------------END TEXT FROM " FILENAME } diff --git a/bfd/awkscan-ip b/bfd/awkscan-ip deleted file mode 100755 index 73bd61fa95f..00000000000 --- a/bfd/awkscan-ip +++ /dev/null @@ -1,8 +0,0 @@ -# Awk filter, 1st filter for BFD internal prototype file extraction -# -# keep /*proto-internal blocks -/^\/\*proto-internal\*/,/^\*\/|^\*-\*\// -# -# Apparent bug in sed can discard last line in some situations; therefore -# make last line harmless. -END { print "\n" } diff --git a/bfd/awkscan-p b/bfd/awkscan-p deleted file mode 100755 index c7fe79fb342..00000000000 --- a/bfd/awkscan-p +++ /dev/null @@ -1,8 +0,0 @@ -# Awk filter, 1st filter for BFD prototype file extraction -# -# keep /*proto blocks -/^\/\*proto\*/,/^\*\/|^\*-\*\// -# -# Apparent bug in sed can discard last line in some situations; therefore -# make last line harmless. -END { print "\n" } diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h deleted file mode 100644 index a0915df9b52..00000000000 --- a/bfd/bfd-in.h +++ /dev/null @@ -1,355 +0,0 @@ -/* A -*- C -*- header file for the bfd library - Copyright 1990, 1991 Free Software Foundation, Inc. - Contributed by Cygnus Support. - -This file is part of BFD, the Binary File Descriptor library. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* bfd.h -- The only header file required by users of the bfd library - -This file is generated from various .c files, if you change it, your -bits may be lost. - -All the prototypes and definitions following the comment "THE FOLLOWING -IS EXTRACTED FROM THE SOURCE" are extracted from the source files for -BFD. If you change it, someone oneday will extract it from the source -again, and your changes will be lost. To save yourself from this bind, -change the definitions in the source in the bfd directory. Type "make -docs" and then "make headers" in that directory, and magically this file -will change to reflect your changes. - -If you don't have the tools to perform the extraction, then you are -safe from someone on your system trampling over your header files. -You should still maintain the equivalence between the source and this -file though; every change you make to the .c file should be reflected -here. */ - -#ifndef __BFD_H_SEEN__ -#define __BFD_H_SEEN__ - -#include "ansidecl.h" -#include "obstack.h" - -/* Make it easier to declare prototypes (puts conditional here) */ -#ifndef PROTO -# if __STDC__ -# define PROTO(type, name, arglist) type name arglist -# else -# define PROTO(type, name, arglist) type name () -# endif -#endif - -#define BFD_VERSION "0.18" - -/* forward declaration */ -typedef struct _bfd bfd; - -/* General rules: functions which are boolean return true on success - and false on failure (unless they're a predicate). -- bfd.doc */ -/* I'm sure this is going to break something and someone is going to - force me to change it. */ -/* typedef enum boolean {false, true} boolean; */ -/* Yup, SVR4 has a "typedef enum boolean" in -fnf */ -typedef enum bfd_boolean {false, true} boolean; - -/* Try to avoid breaking stuff */ -typedef long int file_ptr; - -/* Support for different sizes of target format ints and addresses */ - -#ifdef HOST_64_BIT -typedef HOST_64_BIT rawdata_offset; -typedef HOST_64_BIT bfd_vma; -typedef HOST_64_BIT bfd_word; -typedef HOST_64_BIT bfd_offset; -typedef HOST_64_BIT bfd_size_type; -typedef HOST_64_BIT symvalue; -typedef HOST_64_BIT bfd_64_type; -#define fprintf_vma(s,x) \ - fprintf(s,"%08x%08x", uint64_typeHIGH(x), uint64_typeLOW(x)) -#define printf_vma(x) \ - printf( "%08x%08x", uint64_typeHIGH(x), uint64_typeLOW(x)) -#else -typedef struct {int a,b;} bfd_64_type; -typedef unsigned long rawdata_offset; -typedef unsigned long bfd_vma; -typedef unsigned long bfd_offset; -typedef unsigned long bfd_word; -typedef unsigned long bfd_size; -typedef unsigned long symvalue; -typedef unsigned long bfd_size_type; -#define printf_vma(x) printf( "%08lx", x) -#define fprintf_vma(s,x) fprintf(s, "%08lx", x) -#endif - -typedef unsigned int flagword; /* 32 bits of flags */ - -/** File formats */ - -typedef enum bfd_format { - bfd_unknown = 0, /* file format is unknown */ - bfd_object, /* linker/assember/compiler output */ - bfd_archive, /* object archive file */ - bfd_core, /* core dump */ - bfd_type_end} /* marks the end; don't use it! */ - bfd_format; - -/* Object file flag values */ -#define NO_FLAGS 0 -#define HAS_RELOC 001 -#define EXEC_P 002 -#define HAS_LINENO 004 -#define HAS_DEBUG 010 -#define HAS_SYMS 020 -#define HAS_LOCALS 040 -#define DYNAMIC 0100 -#define WP_TEXT 0200 -#define D_PAGED 0400 - - -/* symbols and relocation */ - -typedef unsigned long symindex; - -#define BFD_NO_MORE_SYMBOLS ((symindex) ~0) - -typedef enum bfd_symclass { - bfd_symclass_unknown = 0, - bfd_symclass_fcommon, /* fortran common symbols */ - bfd_symclass_global, /* global symbol, what a surprise */ - bfd_symclass_debugger, /* some debugger symbol */ - bfd_symclass_undefined /* none known */ - } symclass; - - -typedef int symtype; /* Who knows, yet? */ - - -/* general purpose part of a symbol; - target specific parts will be found in libcoff.h, liba.out.h etc */ - - -#define bfd_get_section(x) ((x)->section) -#define bfd_get_output_section(x) ((x)->section->output_section) -#define bfd_set_section(x,y) ((x)->section) = (y) -#define bfd_asymbol_base(x) ((x)->section?((x)->section->vma):0) -#define bfd_asymbol_value(x) (bfd_asymbol_base(x) + x->value) -#define bfd_asymbol_name(x) ((x)->name) - -/* This is a type pun with struct ranlib on purpose! */ -typedef struct carsym { - char *name; - file_ptr file_offset; /* look here to find the file */ -} carsym; /* to make these you call a carsymogen */ - - -/* Used in generating armaps. Perhaps just a forward definition would do? */ -struct orl { /* output ranlib */ - char **name; /* symbol name */ - file_ptr pos; /* bfd* or file position */ - int namidx; /* index into string table */ -}; - - - -/* Linenumber stuff */ -typedef struct lineno_cache_entry { - unsigned int line_number; /* Linenumber from start of function*/ - union { - struct symbol_cache_entry *sym; /* Function name */ - unsigned long offset; /* Offset into section */ - } u; -} alent; - -/* object and core file sections */ - - -#define align_power(addr, align) \ - ( ((addr) + ((1<<(align))-1)) & (-1 << (align))) - -typedef struct sec *sec_ptr; - -#define bfd_section_name(bfd, ptr) ((ptr)->name) -#define bfd_section_size(bfd, ptr) ((ptr)->size) -#define bfd_section_vma(bfd, ptr) ((ptr)->vma) -#define bfd_section_alignment(bfd, ptr) ((ptr)->alignment_power) -#define bfd_get_section_flags(bfd, ptr) ((ptr)->flags) -#define bfd_get_section_userdata(bfd, ptr) ((ptr)->userdata) - -#define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (val)), 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) - -typedef struct stat stat_type; - -/** Error handling */ - -typedef enum bfd_error { - no_error = 0, system_call_error, invalid_target, - wrong_format, invalid_operation, no_memory, - no_symbols, no_relocation_info, - no_more_archived_files, malformed_archive, - symbol_not_found, file_not_recognized, - file_ambiguously_recognized, no_contents, - bfd_error_nonrepresentable_section, - no_debug_section, - invalid_error_code} bfd_ec; - -extern bfd_ec bfd_error; - -typedef struct bfd_error_vector { - PROTO(void,(* nonrepresentable_section ),(CONST bfd *CONST abfd, - CONST char *CONST name)); -} bfd_error_vector_type; - -PROTO (char *, bfd_errmsg, ()); -PROTO (void, bfd_perror, (CONST char *message)); - - -typedef enum bfd_print_symbol -{ - bfd_print_symbol_name, - bfd_print_symbol_more, - bfd_print_symbol_all -} bfd_print_symbol_type; - - - -/* The code that implements targets can initialize a jump table with this - macro. It must name all its routines the same way (a prefix plus - the standard routine suffix), or it must #define the routines that - are not so named, before calling JUMP_TABLE in the initializer. */ - -/* Semi-portable string concatenation in cpp */ -#ifndef CAT -#ifdef __STDC__ -#define CAT(a,b) a##b -#else -#define CAT(a,b) a/**/b -#endif -#endif - -#define JUMP_TABLE(NAME)\ -CAT(NAME,_core_file_failing_command),\ -CAT(NAME,_core_file_failing_signal),\ -CAT(NAME,_core_file_matches_executable_p),\ -CAT(NAME,_slurp_armap),\ -CAT(NAME,_slurp_extended_name_table),\ -CAT(NAME,_truncate_arname),\ -CAT(NAME,_write_armap),\ -CAT(NAME,_close_and_cleanup), \ -CAT(NAME,_set_section_contents),\ -CAT(NAME,_get_section_contents),\ -CAT(NAME,_new_section_hook),\ -CAT(NAME,_get_symtab_upper_bound),\ -CAT(NAME,_get_symtab),\ -CAT(NAME,_get_reloc_upper_bound),\ -CAT(NAME,_canonicalize_reloc),\ -CAT(NAME,_make_empty_symbol),\ -CAT(NAME,_print_symbol),\ -CAT(NAME,_get_lineno),\ -CAT(NAME,_set_arch_mach),\ -CAT(NAME,_openr_next_archived_file),\ -CAT(NAME,_find_nearest_line),\ -CAT(NAME,_generic_stat_arch_elt),\ -CAT(NAME,_sizeof_headers),\ -CAT(NAME,_bfd_debug_info_start),\ -CAT(NAME,_bfd_debug_info_end),\ -CAT(NAME,_bfd_debug_info_accumulate) - -#define COFF_SWAP_TABLE \ - coff_swap_aux_in, coff_swap_sym_in, coff_swap_lineno_in, \ - coff_swap_aux_out, coff_swap_sym_out, \ - coff_swap_lineno_out, coff_swap_reloc_out, \ - coff_swap_filehdr_out, coff_swap_aouthdr_out, \ - coff_swap_scnhdr_out - - - -/* User program access to BFD facilities */ - -extern CONST short _bfd_host_big_endian; -#define HOST_BYTE_ORDER_BIG_P (*(char *)&_bfd_host_big_endian) - -/* The bfd itself */ - -/* Cast from const char * to char * so that caller can assign to - a char * without a warning. */ -#define bfd_get_filename(abfd) ((char *) (abfd)->filename) -#define bfd_get_format(abfd) ((abfd)->format) -#define bfd_get_target(abfd) ((abfd)->xvec->name) -#define bfd_get_file_flags(abfd) ((abfd)->flags) -#define bfd_applicable_file_flags(abfd) ((abfd)->xvec->object_flags) -#define bfd_applicable_section_flags(abfd) ((abfd)->xvec->section_flags) -#define bfd_my_archive(abfd) ((abfd)->my_archive); -#define bfd_has_map(abfd) ((abfd)->has_armap) -#define bfd_header_twiddle_required(abfd) \ - ((((abfd)->xvec->header_byteorder_big_p) \ - != (boolean)HOST_BYTE_ORDER_BIG_P) ? true:false) - -#define bfd_valid_reloc_types(abfd) ((abfd)->xvec->valid_reloc_types) -#define bfd_usrdata(abfd) ((abfd)->usrdata) - -#define bfd_get_start_address(abfd) ((abfd)->start_address) -#define bfd_get_symcount(abfd) ((abfd)->symcount) -#define bfd_get_outsymbols(abfd) ((abfd)->outsymbols) -#define bfd_count_sections(abfd) ((abfd)->section_count) -#define bfd_get_architecture(abfd) ((abfd)->obj_arch) -#define bfd_get_machine(abfd) ((abfd)->obj_machine) - - - -#define BYTE_SIZE 1 -#define SHORT_SIZE 2 -#define LONG_SIZE 4 - - - -/*THE FOLLOWING IS EXTRACTED FROM THE SOURCE */ - - -/*:init.c*/ - -/*:opncls.c*/ - - -/*:libbfd.c*/ - -/*:section.c*/ - - -/*:archures.c*/ - -/*:reloc.c*/ - -/*:syms.c*/ - -/*:bfd.c*/ - -/*:archive.c*/ - -/*:core.c*/ - -/*:targets.c*/ - -/*:format.c*/ - -#endif - - - - - diff --git a/bfd/bfd.c b/bfd/bfd.c deleted file mode 100644 index ccf53ce1e49..00000000000 --- a/bfd/bfd.c +++ /dev/null @@ -1,452 +0,0 @@ -/* Generic BFD library interface and support routines. - Copyright (C) 1990-1991 Free Software Foundation, Inc. - Written by Cygnus Support. - -This file is part of BFD, the Binary File Descriptor library. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* $Id$ */ - -/*proto* -@section @code{typedef bfd} - -A BFD is has type @code{bfd}; objects of this type are the cornerstone -of any application using @code{libbfd}. References though the BFD and -to data in the BFD give the entire BFD functionality. - -Here is the struct used to define the type @code{bfd}. This contains -the major data about the file, and contains pointers to the rest of -the data. - -*+++ - -$struct _bfd -${ - The filename the application opened the BFD with. - -$ CONST char *filename; - -A pointer to the target jump table. - -$ struct bfd_target *xvec; - - -To avoid dragging too many header files into every file that -includes @file{bfd.h}, IOSTREAM has been declared as a "char *", and MTIME -as a "long". Their correct types, to which they are cast when used, -are "FILE *" and "time_t". - -The iostream is the result of an fopen on the filename. - -$ char *iostream; - -Is the file being cached @xref{File Caching}. - -$ boolean cacheable; - -Marks whether there was a default target specified when the BFD was -opened. This is used to select what matching algorithm to use to chose -the back end. - -$ boolean target_defaulted; - -The caching routines use these to maintain a least-recently-used list of -BFDs (@pxref{File Caching}). - -$ struct _bfd *lru_prev, *lru_next; - -When a file is closed by the caching routines, BFD retains state -information on the file here: - -$ file_ptr where; - -and here: - -$ boolean opened_once; - -$ boolean mtime_set; -File modified time - -$ long mtime; - -Reserved for an unimplemented file locking extension. - -$int ifd; - -The format which belongs to the BFD. - -$ bfd_format format; - -The direction the BFD was opened with - -$ enum bfd_direction {no_direction = 0, -$ read_direction = 1, -$ write_direction = 2, -$ both_direction = 3} direction; - -Format_specific flags - -$ flagword flags; - -Currently my_archive is tested before adding origin to anything. I -believe that this can become always an add of origin, with origin set -to 0 for non archive files. - -$ file_ptr origin; - -Remember when output has begun, to stop strange things happening. - -$ boolean output_has_begun; - -Pointer to linked list of sections - -$ struct sec *sections; - -The number of sections - -$ unsigned int section_count; - -Stuff only useful for object files: -The start address. - -$ bfd_vma start_address; -Used for input and output - -$ unsigned int symcount; -Symbol table for output BFD - -$ struct symbol_cache_entry **outsymbols; - -Pointer to structure which contains architecture information - -$ struct bfd_arch_info *arch_info; - -Stuff only useful for archives: - -$ PTR arelt_data; -$ struct _bfd *my_archive; -$ struct _bfd *next; -$ struct _bfd *archive_head; -$ boolean has_armap; - -Used by the back end to hold private data. - -$ PTR tdata; - -Used by the application to hold private data - -$ PTR usrdata; - -Where all the allocated stuff under this BFD goes (@pxref{Memory Usage}). - -$ struct obstack memory; -$}; - -*--- - -*/ -#include "bfd.h" -#include "sysdep.h" -#include "libbfd.h" - -#undef strerror -extern char *strerror(); - - -short _bfd_host_big_endian = 0x0100; - /* Accessing the above as (*(char*)&_bfd_host_big_endian), will - return 1 if the host is big-endian, 0 otherwise. - (assuming that a short is two bytes long!!! FIXME) - (See HOST_IS_BIG_ENDIAN_P in bfd.h.) */ - -/** Error handling - o - Most functions return nonzero on success (check doc for - precise semantics); 0 or NULL on error. - o - Internal errors are documented by the value of bfd_error. - If that is system_call_error then check errno. - o - The easiest way to report this to the user is to use bfd_perror. -*/ - -bfd_ec bfd_error = no_error; - -char *bfd_errmsgs[] = { "No error", - "System call error", - "Invalid target", - "File in wrong format", - "Invalid operation", - "Memory exhausted", - "No symbols", - "No relocation info", - "No more archived files", - "Malformed archive", - "Symbol not found", - "File format not recognized", - "File format is ambiguous", - "Section has no contents", - "Nonrepresentable section on output", - "Symbol needs debug section which does not exist", - "#" - }; - -static -void -DEFUN(bfd_nonrepresentable_section,(abfd, name), - CONST bfd * CONST abfd AND - CONST char * CONST name) -{ - printf("bfd error writing file %s, format %s can't represent section %s\n", - abfd->filename, - abfd->xvec->name, - name); - exit(1); -} - -bfd_error_vector_type bfd_error_vector = - { - bfd_nonrepresentable_section - }; - -char * -bfd_errmsg (error_tag) - bfd_ec error_tag; -{ -#ifndef errno - extern int errno; -#endif - if (error_tag == system_call_error) - return strerror (errno); - - if ((((int)error_tag <(int) no_error) || - ((int)error_tag > (int)invalid_error_code))) - error_tag = invalid_error_code;/* sanity check */ - - return bfd_errmsgs [(int)error_tag]; -} - - -void bfd_default_error_trap(error_tag) -bfd_ec error_tag; -{ - printf("bfd assert fail (%s)\n", bfd_errmsg(error_tag)); -} - -void (*bfd_error_trap)() = bfd_default_error_trap; -void (*bfd_error_nonrepresentabltrap)() = bfd_default_error_trap; - -void -DEFUN(bfd_perror,(message), - CONST char *message) -{ - if (bfd_error == system_call_error) - perror((char *)message); /* must be system error then... */ - else { - if (message == NULL || *message == '\0') - fprintf (stderr, "%s\n", bfd_errmsg (bfd_error)); - else - fprintf (stderr, "%s: %s\n", message, bfd_errmsg (bfd_error)); - } -} - - -/** Symbols */ - -/* returns the number of octets of storage required */ - -unsigned int -get_reloc_upper_bound (abfd, asect) - bfd *abfd; - sec_ptr asect; -{ - if (abfd->format != bfd_object) { - bfd_error = invalid_operation; - return 0; - } - - return BFD_SEND (abfd, _get_reloc_upper_bound, (abfd, asect)); -} - -unsigned int -bfd_canonicalize_reloc (abfd, asect, location, symbols) - bfd *abfd; - sec_ptr asect; - arelent **location; - asymbol **symbols; -{ - if (abfd->format != bfd_object) { - bfd_error = invalid_operation; - return 0; - } - - return BFD_SEND (abfd, _bfd_canonicalize_reloc, (abfd, asect, location, symbols)); -} - - -boolean -bfd_set_file_flags (abfd, flags) - bfd *abfd; - flagword flags; -{ - if (abfd->format != bfd_object) { - bfd_error = wrong_format; - return false; - } - - if (bfd_read_p (abfd)) { - bfd_error = invalid_operation; - return false; - } - - if ((flags & bfd_applicable_file_flags (abfd)) != flags) { - bfd_error = invalid_operation; - return false; - } - - bfd_get_file_flags (abfd) = flags; -return true; -} - - -void -bfd_set_reloc (ignore_abfd, asect, location, count) - bfd *ignore_abfd; - sec_ptr asect; - arelent **location; - unsigned int count; -{ - asect->orelocation = location; - asect->reloc_count = count; -} - -void -bfd_assert(file, line) -char *file; -int line; -{ - printf("bfd assertion fail %s:%d\n",file,line); -} - - -/*proto* bfd_set_start_address - -Marks the entry point of an output BFD. Returns @code{true} on -success, @code{false} otherwise. - -*; PROTO(boolean, bfd_set_start_address,(bfd *, bfd_vma)); -*/ - -boolean -bfd_set_start_address(abfd, vma) -bfd *abfd; -bfd_vma vma; -{ - abfd->start_address = vma; - return true; -} - - -/*proto* bfd_get_mtime - -Return cached file modification time (e.g. as read from archive header -for archive members, or from file system if we have been called -before); else determine modify time, cache it, and return it. - -*; PROTO(long, bfd_get_mtime, (bfd *)); - -*/ - -long -bfd_get_mtime (abfd) - bfd *abfd; -{ - FILE *fp; - struct stat buf; - - if (abfd->mtime_set) - return abfd->mtime; - - fp = bfd_cache_lookup (abfd); - if (0 != fstat (fileno (fp), &buf)) - return 0; - - abfd->mtime_set = true; - abfd->mtime = buf.st_mtime; - return abfd->mtime; -} - -/*proto* stuff - -*+ - -#define bfd_sizeof_headers(abfd, reloc) \ - BFD_SEND (abfd, _bfd_sizeof_headers, (abfd, reloc)) - -#define bfd_find_nearest_line(abfd, section, symbols, offset, filename_ptr, func, line_ptr) \ - BFD_SEND (abfd, _bfd_find_nearest_line, (abfd, section, symbols, offset, filename_ptr, func, line_ptr)) - -#define bfd_debug_info_start(abfd) \ - BFD_SEND (abfd, _bfd_debug_info_start, (abfd)) - -#define bfd_debug_info_end(abfd) \ - BFD_SEND (abfd, _bfd_debug_info_end, (abfd)) - -#define bfd_debug_info_accumulate(abfd, section) \ - BFD_SEND (abfd, _bfd_debug_info_accumulate, (abfd, section)) - -#define bfd_stat_arch_elt(abfd, stat) \ - BFD_SEND (abfd, _bfd_stat_arch_elt,(abfd, stat)) - -#define bfd_coff_swap_aux_in(a,e,t,c,i) \ - BFD_SEND (a, _bfd_coff_swap_aux_in, (a,e,t,c,i)) - -#define bfd_coff_swap_sym_in(a,e,i) \ - BFD_SEND (a, _bfd_coff_swap_sym_in, (a,e,i)) - -#define bfd_coff_swap_lineno_in(a,e,i) \ - BFD_SEND ( a, _bfd_coff_swap_lineno_in, (a,e,i)) - -#define bfd_set_arch_mach(abfd, arch, mach)\ - BFD_SEND ( abfd, _bfd_set_arch_mach, (abfd, arch, mach)) - -#define bfd_coff_swap_reloc_out(abfd, i, o) \ - BFD_SEND (abfd, _bfd_coff_swap_reloc_out, (abfd, i, o)) - -#define bfd_coff_swap_lineno_out(abfd, i, o) \ - BFD_SEND (abfd, _bfd_coff_swap_lineno_out, (abfd, i, o)) - -#define bfd_coff_swap_aux_out(abfd, i, t,c,o) \ - BFD_SEND (abfd, _bfd_coff_swap_aux_out, (abfd, i,t,c, o)) - -#define bfd_coff_swap_sym_out(abfd, i,o) \ - BFD_SEND (abfd, _bfd_coff_swap_sym_out, (abfd, i, o)) - -#define bfd_coff_swap_scnhdr_out(abfd, i,o) \ - BFD_SEND (abfd, _bfd_coff_swap_scnhdr_out, (abfd, i, o)) - -#define bfd_coff_swap_filehdr_out(abfd, i,o) \ - BFD_SEND (abfd, _bfd_coff_swap_filehdr_out, (abfd, i, o)) - -#define bfd_coff_swap_aouthdr_out(abfd, i,o) \ - BFD_SEND (abfd, _bfd_coff_swap_aouthdr_out, (abfd, i, o)) - -*- - -*/ - - - - - - diff --git a/bfd/bfd.doc b/bfd/bfd.doc deleted file mode 100755 index c74c8ce48ee..00000000000 --- a/bfd/bfd.doc +++ /dev/null @@ -1,705 +0,0 @@ -This file contains -*- Text -*-. - -BFD is a set of routines for reading and writing binary files. - -The user should call only the interface routines at the end of bfd.h. -The one I'm working out of is /4/gumby/bfd/bfd.h - - Sample "strip" program using BFD: - - #include "bfd.h" - - doit () - { - ibfd = bfd_openr(...) - obfd = bfd_openw(...) - bfd_check_format (ibfd, object); - bfd_set_format (obfd, object); - - bfd_set_arch_mach (obfd, ...) - bfd_set_start_address (obfd, ...) - etc... - - [optionally: - asymbol * foo = malloc (get_symtab_upper_bound (ibfd)); - bfd_canonicalize_symtab (ibfd, foo); - - bfd_set_symtab (obfd, foo, updated_symbol_count); - ] - - bfd_map_over_sections (abfd, setup, NULL); - bfd_map_over_sections (abfd, cleaner, NULL); - - bfd_close (obfd); - bfd_close (ibfd); - } - - setup (ibfd, sect) - { - osect = make_section (obfd, bfd_section_name (ibfd, sect)); - bfd_set_section_size (obfd, osect, bfd_section_size (ibfd, sect)); - ... - } - - cleaner (ibfd, sect) - { - osect = bfd_get_section_by_name (obfd, - bfd_section_name (ibfd, sect)); - bfd_copy_section (ibfd, sect, obfd, osect); - [perhaps: bfd_set_reloc (osect, NULL, 0); ] - } - - - -BFD is a package for manipulating binary files required for developing -programs. It implements a group of structured operations designed to -shield the programmer from the underlying representation of these -binary files. It understands object (compiled) files, archive -libraries, and core files. It is designed to work in a variety of -target environments. - -To use the library, include bfd.h and link with libbfd.a. - -A bfd iteself is a representation for a particular file. It is opened -in a manner similar to a file; code then manipulates it rather than -the raw files. - -BFD makes a distinction between TARGETS (families of file formats) and -FORMATS (individual file formats). For instance, the "sun4os4" target -can handle core, object and archive formats of files. The exact -layout of the different formats depends on the target environment. - -The target "default" means the first one known (usually used for -environments that only support one format, or where the common format -is known at compile or link time). The target NULL means the one -specified at runtime in the environment variable GNUTARGET; if that is -null or not defined then the first entry in the target list is chosen -(on output), or all targets are searched (on input) to find a matching -one.. - -Most programs should use the target NULL. - -There is a way to get a list of the names of all the targets: -char** bfd_target_list () - This function returns a freshly-malloced list of all the - defined targets (or NULL if it could not malloc). The names - are read-only. You could use this to prompt the user, or - perhaps to error-check. - -char * bfd_format_string (bfd_format format) - This function will give you a printable, single-word description - (like "core" or "archive") for a bfd format. - -Error handling - -General rules: -functions which are boolean return true on success and false on failure -(unless they're a predicate). Functions which return pointers to -objects return NULL on error. The specifics are documented with each -function. - -If a function fails, you should check the variable bfd_error. If the -value is no_error, then check the C variable errno just as you would -with any other program. The other values bfd_error may take on are -documented in bfd.h. - -If you would prefer a comprehensible string for the error message, use -the function bfd_errmsg: - char * bfd_errmsg (error_tag) -This function returns a read-only string which documents the error -code. If the error code is no_error then it will return a string -depending on the value of errno. - -bfd_perror() is like the perror() function except it understands -bfd_error. - -Operations on bfds themselves - -bfd * bfd_openr (char *filename, char *target); -bfd * bfd_fdopenr (int fd, char *target, char *filename); - - Open a binary file for reading. TARGET is the type of the file, - a char string like "sun4os4" or "elf". (Note this is not the - "function" of the file, e.g. an object versus a core file - versus an archive, but instead describes how all these files - are encoded.) Returns a new bfd or NULL upon failure. - -bfd * bfd_openw (char *filename, char *target); - - Open a file named `filename' for writing. If an existing - file has the same name, then it will be overwritten by a - successful bfd_close on the returned bfd. Will return either - a new bfd or NULL upon failure. - -boolean bfd_close (bfd *abfd); - - Close a BFD opened for either reading or writing. May involve - several filesystem operations, depending on the data format; - some things may not be known to the system until file-closing - time. Returns true if it successfully wrote the file, false - if not. A false return will not leave a partially-written - file behind with the name supplied to bfd_openw. - - On a bfd open for reading will generally successfully - complete. - - It is an error to call this on a file opened from inside an - archive. - - FIXME -- show which error codes may be recoverable and - followed by another call to bfd_close! - - -The defined formats are specified by the enumeration bfd_format. - -boolean bfd_check_format (bfd *abfd, bfd_format format); - - This routine must be called after a bfd_openr. It sets up - internal data structures based on the contents of the file. - It returns FALSE if the file is not really in the specified - format. - -boolean bfd_set_format (bfd *abfd, bfd_format format); - - This routine must be called after a bfd_openw. It sets up - internal data structures for the proper format of file. - It returns FALSE if that format is not supported for output - (e.g. core files). - -The following macros may be used to obtain information about a bfd: - -bfd_get_filename -- returns a pointer to a null-terminated string - which names the bfd's file, or NULL if that is not known. - Don't side-effect this string! -bfd_get_format -- returns the format code for the bfd. -bfd_get_target -- returns the string which names the bfd's target. -bfd_get_mtime -- returns an time_t indicating the modification time of an - input bfd, if that could be determined, or 0 of not. - -Object files have certain properties. For input bfds, these -properties may be read at any time. For output bfds you should set -them before you begin building any sections. - -bfd_vma bfd_get_start_address (bfd *abfd); - - Returns the address in an object file where execution will begin. - -boolean bfd_set_start_address (bfd *abfd, int vma); - - Set the address where execution will start in an object file. - - If the address you select is incorrect for your architecture - (for instance, if it's required to be on a page_boundary and - your supplied starting address is not, then you may get the - invalid_operation error. It is not always possible to - generate an error in this case. - -An object file has an architecture, which is the general instruction -set of the instructions that it contains. Architectures are defined in -enum bfd_architecture in bfd.h. New architectures can be added by -putting them in the enum, updating architectures.c, and adding code to -handle them for the object files that know that architecture. The -bfd_architecture values are not stored in files, but are only used -within the BFD library and its callers. - -An object file also has a machine type, which is the specific machine -within the architecture. For example, if the architecture is bfd_arch_m68k, -the Motorola 68000 series, then the machine type might be 68010, the mc68010 -chip. For architectures such as the SPARC where specific versions of -the architecture exist, the version number should probably be used. - -Particular object file formats may or may not store the machine architecture -and type. When copying an object file, you should copy these fields. -Most callers of BFD will not need to know the particular values that -these fields contain, but will instead propagate them from file to file, -or compare the architectures from two files. - -enum bfd_architecture bfd_get_architecture (bfd *abfd); -unsigned long bfd_get_machine (bfd *abfd); - - Get the machine type and architecture. - -boolean bfd_set_arch_mach (bfd *abfd, enum bfd_architecture arch, - unsigned long machine); - - Set the architecture and machine type. The result is true - if the object file can exactly represent the specified type. - The result is false otherwise. - -boolean bfd_arch_compatible (bfd *abfd, bfd *bbfd, - enum bfd_architecture *res_arch, - unsigned long *res_machine); - - Decides whether two BFD's contain compatible architectures and - machine types. If the result is TRUE and the res_arch and - res_machine pointers are non-NULL, the resulting "merged" - architecture and machine type are returned through the pointers. - A linker could call this to decide whether two object files - can be linked, and to deterine the arch and machine type of - the resulting file. - -char * bfd_printable_arch_mach (enum bfd_architecture arch, - unsigned long machine); - - Returns a printable string that represents the particular - combination of architecture and machine type. - -boolean bfd_scan_arch_mach (char *string, enum bfd_architecture *archp, - unsigned long *machinep); - - Examines a printable string and tries to extract an - architecture and machine type from it. The intended use is for - parsing specifications from the user, e.g. command line - arguments. The result is true if a known architecture was - found, and the resulting architecture and machine type are - stored through the argument pointers. Note that an - architecture scannable by this function might not be - representable by the particular object file format in use. - (i.e. bfd_set_arch_mach might return false). - - -There are also a number of boolean flags which apply to object bfds. - -flagword bfd_get_file_flags (bfd *abfd); - - returns a flagword containing the bfd's flags. - -boolean bfd_set_file_flags (bfd *abfd, flagword flags, - boolean on_or_off); - - sets (on_or_off == true) or clears (on_or_off == false) the flags - specified by flagword. All other flags are unaffected. - Some flag combinations don't make sense; It is not always - possible to detect them (since they may depend on other information). - Returns true if the flags could be modified as requested, - false if not. Upon a false return, no flags will have been - altered. - - -flagword bfd_applicable_file_flags (bfd *abfd); - - returns a flagword with bits set for all the flags which are - meaningful for the bfd. - -The flags are: - HAS_RELOC -- file contains unresolved relocation information. - EXEC_P -- file can be executed. These two may both be on in the - case of some dynamically-linked binaries. - HAS_LINENO -- has line number information. - HAS_DEBUG -- has debugging information. - HAS_SYMS -- has any symbols. - HAS_LOCALS -- has local symbols. - DYNAMIC -- binary is dynamically linked. - WP_TEXT -- text is write-protected - D_PAGED -- binary should be demand-paged - -These flags are one bit wide and may be OR-ed together with |. - -If you are building a large application with bfd there may be data -specific to your program that you may wish to associate with a bfd. -Rather than require you to build a parallel table structure, bfd -provides a void* pointer in each bfd for arbitrary user data. The -macro bfd_usrdata (bfd *abfd) extracts these data; you may set them -with = (ie bfd_usrdata (my_bfd) = frob_it (my_bfd, moon_phase);). - -Object and core files have sections. - -File sections are represented by opaque pointers. You may map over -the sections of a file or you may ask for one by name. Note that not -all files may have all the possible sections. - -Section pointers are valid from the time you get them until the bfd -to which they refer is closed. - -When doing output, you must set up all the file's sections before -outputting to any. All that means is that all the file's sections -must have already been created and their size set before output -commences. - -Each section contains some small information, plus three chunks of -data in the object file: contents, relocation, and line numbers. -In some file formats (e.g. a.out), the line number part is always -empty, and line number information (if any) is instead recorded in -the symbol table. - -sec_ptr bfd_get_section_by_name (bfd *abfd, char *name); - Returns a section named NAME, or NULL if none by that name - exists. Works on input and output bfds. - -sec_ptr bfd_make_section (bfd *abfd, char *name); - Creates a section named name in the output bfd abfd. - returns NULL if it cannot create the section (if, for instance, - the output format does not permit such a section). If a - section with that name already exists, it is returned; a new - one with the same name is NOT created. - -unsigned int bfd_count_sections (bfd *abfd) - - This function returns the number of sections in the bfd abfd. - -void bfd_map_over_sections (bfd *abfd, void (*operation)(), - void *user_storage); - - This is how you operate on all sections of an input file. - Pass in a function pointer. The function will be called for each - section of the file, in random order. It will be passed - three arguments: the bfd, the sec_ptr for the section, and - whatever was passed in as user_storage. - -char * bfd_section_name (bfd *abfd, sec_ptr ptr); - - Produces the name of a section, e.g. ".text" or ".data". - This will produce arbitrary names for files with extensible - section names (e.g. COFF, ELF) so don't assume that you will - only see a few values here. - -long bfd_section_size (bfd *abfd, sec_ptr ptr); - - The size of a section in bytes. Result == -1 for error. - -boolean bfd_set_section_size (bfd *abfd, sec_ptr section unsigned long size); - - Set the size of a section. This must be done before any data - transfer is done for the section. - -bfd_vma bfd_section_vma (bfd *abfd, sec_ptr ptr); - - Virtual memory address where a section "belongs". - -boolean bfd_set_section_vma (bfd *abfd, bfd_vma vma); - - Set the virtual memory address of a section. - -int bfd_get_section_alignment (bfd *abfd, sec_ptr ptr); - - returns the alignment of a section. If alignment is not - possible, return value is undefined. - -boolean bfd_set_section_alignment (bfd *abfd, sec_ptr ptr, int alignment) - - returns true if it can set the section to the requested value. - Alignment is an integer; it refers to the power of two - specifying the byte boundary we want (ie 0 is byte-aligned; 4 - is word aligned). If the requested alignment is not available - any existing value is unchanged. - -Sections have properties just as object files may: - -flagword bfd_get_section_flags (bfd *abfd, sec_ptr section); - - returns a flagword containing the section's flags. - -boolean bfd_set_section_flags (bfd *abfd, sec_ptr section, - flagword flags, boolean on_or_off); - - sets (on_or_off == true) or clears (on_or_off == false) the flags - specified by flagword. All other flags are unaffected. - Some flag combinations don't make sense; It is not always - possible to detect them (since they may depend on other information). - Returns true if the flags could me modified as requested, - false if not. Unpon a false return, no flags will have been - altered. - -flagword bfd_applicable_section_flags (bfd *abfd); - - returns a flagword with bits set for all the flags which are - meaningful for a section. - -The flags are: - - SEC_BALIGN -- segment can be byte-aligned. - SEC_RELOC -- segment should be relocated. - SEC_ALLOC -- when converted into a memory image with the intent of - constructing a runable process, memory space will be - allocated for this section. - SEC_LOAD -- when converted into a memory image with the intent of - constructing a runable process, section contents will be - copied from the object file into memory. When this flag - is set, SEC_ALLOC is guaranteed to also be set. - SEC_HAS_CONTENTS -- The contents of this section exist in the - object file. Sections whose contents do not exist in the - object file may still have their contents read. On read, - a segment filled with zeroes will be invented to satisfy - the read request. It is an error to attempt to set the - contents of a section that has no contents. - -These last three probably need some explanation. In a traditional, -native unix object format, there are three real sections, text, data, -and bss. The text section will be allocated memory on exec, and will -be loaded from file into memory on exec. So the flags for a -traditional unix text section would typically be at least (SEC_ALLOC | -SEC_LOAD | SEC_HAS_CONTENTS). The data section has basically these -same traits. The bss section, however is a little different. It is -not relocated, and it is not loaded from file on exec, but it is -allocated memory on exec. Thus, its flags would be more like -(SEC_ALLOC). It is possible to have a section which is the converse -of the bss section. That is, (SEC_HAS_CONTENTS & ~SEC_ALLOC). This -could be anything from profiling information or notes from one pass of -a toolchain to another to time and version stamp information. - -Note that the section flags currently lack information on position -dependance. - -boolean bfd_get_section_contents (bfd *abfd, sec_ptr section, - unsigned char *location, - int offset, int count); - - Stores count bytes from the section's contents starting at - offset from within those contents. The values are stored into - location. Returns true if it could do so. Supplying invalid - values for offset and count will produce unpredictable results. - -boolean bfd_set_section_contents (bfd *abfd, sec_ptr section, - unsigned char *location, - int offset, int count); - Stores count bytes from location into offset within the - section contents. You need not write all the contents contiguously - (that is, you may write words 5-7 followed by 0-4 if you - wish). However once you start writing into a section, any - other sections into which you have previously written are - considered finished, and you may not write in them any more. - -*** Line numbers *** - -bfd_get_section_lineno_size (bfd *abfd, sec_ptr section); - Returns how many bytes of line numbers are associated with this - section. - -bfd_set_section_lineno_size (bfd *abfd, sec_ptr section, unsigned long val); - Sets the number of bytes of line numbers that this section should - contain. - -boolean bfd_get_section_linenos (bfd *abfd, sec_ptr section, - unsigned char *location, - int offset, int count); - Same as get_section_contents, except that it works on the linenos - for this section. - -boolean bfd_set_section_linenos (bfd *abfd, sec_ptr section, - unsigned char *location, - int offset, int count); - Same as set_section_contents, except that it works on the linenos - for this section. - -As with files, you may associate arbitrary program-specific data with -a section of a bfd. The following two functions are provided for -manipulating these data: - -void * bfd_get_section_userdata (bfd *abfd, sec_ptr section) - Returns whatever was stored in section's user data, or NULL if nothing. - -boolean bfd_set_section_userdata (bfd *abfd, sec_ptr section, void *contents) - Set the section contents. Returns true if it can, false if not. - -Core files - -Core files are currently only supported for reading. - -Apart from opening them, looking at the various sections (generally -the .data, .stack, and .regs sections; maybe a .user_struct section -eventually), you can make some queries about the status of the core -file, detailed below. The ".regs" section contains the general and -floating point registers of the process that died, in some machine- -specific order and format "intended to be unsurprising to someone who -knows the machine". - -char * bfd_core_file_failing_command (bfd *abfd); - - The command name of the program that failed, creating the core file. - The result is NULL if BFD can't figure out what the failing command was. - -int bfd_core_file_failing_signal (bfd *abfd); - - The signal number which caused the program to die, causing the - core file to be created. It will be positive if valid. - -boolean core_file_matches_executable_p (bfd *core_bfd, bfd *exec_bfd); - - For debuggers, checks whether a core file "matches" (is likely to - have come from) an executable file. This will not be perfect on - most systems, but will just provide a way to reject gross mismatches. - -Archives. - -An archive is a special file which can contain other files. -Originally it was intended to be a general way to group files, the way -tar is today. But now it is used almost exclusively to hold object -files. - -An archive may be opened for reading or writing just like any other -bfd. Once it is open for reading you may obtain bfds for each of the -files contained within it with the following function: - -bfd * bfd_openr_next_archived_file (bfd *arch_bfd, bfd *last_file); - - If called with NULL as the second argument, returns the first - file contained in the archive arch_bfd. If called with a file - contained within arch_bfd, returns the one which follows that - one, or NULL if it was the last. Returns NULL also if the - bfd supplied as last_file did not come from the archive arch_bfd. - -Any bfd open for read may be placed in an output archive. When the -output archive is closed, the contents will be placed into the -archive. - -You control the order of files in an archive. You set the first one -with the following function: - -boolean bfd_set_archive_head (bfd *output_archive, bfd *new_head) - - This function sets the first file in the archive - output_archive to be the bfd new_head. - -bfd's contain a pointer called next, which is bfd *. It is used by -bfd_close when an archive is closed to decide which file should next -go into the archive. So to place a group of files into an archive, -open bfds for each of them, chain them together using the next pointer -in the order you desire (be sure to store NULL into the final one's -next pointer), then do bfd_set_archive_head with the head of the -chain. The next pointer may be freely smashed at any time; it is only -looked at when closing an output archive. - -bfds for files contained within archives are normal bfds; you can do -any input operations on them that you can do with a normal bfd. - -bfd_my_archive is a macro which takes an input bfd and returns NULL if -it lives in the filesystem and a bfd if it is contained in an archive. -In the latter case, the returned bfd is the archive itself. - -Archives containing only object files may have a "map" -- a table in -the front which maps external symbols to the files which contain them. - -Archive maps will refer only to object files; if an archive contains a -file which is not an archive that file will of course not appear in -the map. - -boolean bfd_has_map (bfd *archive_bfd) - - This macro takes a bfd of an archive and returns true or - false depending on whether the bfd has a map. For output - bfds this may be set to true or false, depending on whether - you want the map to be maintained or not. For some targets, - setting this to false will cause no map to be generated; for - others it will merely cause an empty map to be created, since - a map is required by that target. - -For archives with maps you may use the following function: - -int bfd_get_next_mapent (bfd *abfd, int prev, char **name) - - You may use this to step through all the entries in the archive - map. Supply BFD_NO_MORE_SYMBOLS as the 'prev' entry to get the - first entry; then use successive returned values from this - function to get the succeeding ones. The name of the next entry - will be stored through the pointer name. - - This function returns BFD_NO_MORE_SYMBOLS when there are no more - entries or on error. - -bfd * bfd_get_elt_at_index (abfd, int index) - - This function takes an index as returned by bfd_get_next_mapent - and returns the bfd which corresponds to that entry. Returns NULL - on error. - -Symbol and relocation information. - -Symbol-table information is the area of greatest incompatibility. -bfd has a canonical symbol representation; all formats are parsed into -and out of it. - -Note that canonicalize_symtab takes a pointer to an array of pointers -to canonical symbols. This is necessary so that the end of the array -can be marked with NULL. You may shuffle the pointers and you may -clobber the symbol contents. But don't move the symbols themselves. - -unsigned int bfd_get_symtab_upper_bound (bfd *abfd); - - Returns the maximum number of bytes that would be taken by - the output of canonicalize_symtab. Returns 0 on error. - -unsigned int bfd_canonicalize_symtab (bfd *abfd, asymbol **location); - - Produces a symbol table in canonical format at LOCATION, which - must be of size specified by get_symtab_upper_bound bytes. - Not all those bytes may be used. Returns the number of - symbol pointers written. Returns 0 upon error. - -boolean bfd_set_symtab (bfd *outbfd, asymbol **location, - unsigned int symcount); - - Takes a generic symbol table and an output bfd. Used to set - the symbol table for an output bfd. Do not change the table - after using this function (although the storage may be - reclaimed once the bfd has been closed). - -If you're done with the symbol table you can tell bfd about it by -calling bfd_reclaim_symbol_table, which takes a bfd. Calling this -function will also reclaim any relocation entries you may have -requested. If you don't use this function, bfd will keep around all -symbol information until the bfd is closed. - -Similarly, relocations have a canonical format. See the file bfd.h for -the exact definition. It is similar to the sun-4 relocation format. -Please note that: -o - Each relocation has a pointer to a generic symbol. -o - Not all values of reloc_type are supported for all targets. There - is a bitvector which explains which are; you can index into it by - relocation type. The macro which extracts it is bfd_valid_reloc_types. - -Since relocation information is saved on a per-section basis, the -interface is slightly different from that of the symbol table: - -unsigned int get_reloc_upper_bound (bfd *abfd, sec_ptr asect); - - Returns the maximum number of bytes that would be taken by - the output of canonicalize_reloc. Returns 0 on error. - -unsigned int canonicalize_reloc (bfd *abfd, sec_ptr asect, arelent *location); - - Produces a relocation table in canonical format at LOCATION, - which must be of size specified by get_reloc_upper_bound - bytes. Not all those bytes may be used. Returns the number - of entries written. Returns 0 upon error. - -boolean bfd_set_reloc (bfd *outbfd, sec_ptr asect, arelent *location, - unsigned int count); - - Takes a generic reloc table and an output bfd. Used to set - the reloc table for an output bfd. Do not change the table - after using this function (although the storage may be - reclaimed once the bfd has been closed). - -Byte-swapping - -Unfortunately, not all machines have the same byte order. Worse, -storage layout is in general highly machine-dependent. Although bfd -can hide that from you in most cases, it cannot do so with the section -contents, since they are totally uninterpreted. Hence you must -byte-swap those data yourself. This is not usually much of an issue -since you should just generate your data in the correct byte order. - -[THIS IS WRONG AND ALSO DOES NOT REFLECT THE CODE WHICH IS CORRECT] - -Fortunately, bfd can tell if byte-swapping or realignment is required -at all! The macro bfd_bit_twiddle_required takes a pointer to a bfd -and returns true if byte-swapping is required, false if not. - -However if you don't wish to check this you may just use the following -functions which will do the conversions required: - - -long bfd_getlong (bfd *abfd, unsigned char *ptr); - bfd_putlong (bfd *abfd, unsigned char *ptr, long time); - -short bfd_getshort (bfd *abfd, unsigned char *ptr); - bfd_putshort (bfd *abfd, unsigned char *ptr, short stop); - - These functions take a pointer that points to data which is, - or will be, part of a section contents. They extract numbers - from the data, or insert numbers into the data. The argument - or result is in the host's number format; the data stored at - the pointer or retrieved from it is in the target's number format. - Typically this transfer is either a no-op or is a byte-swap; - sometimes it involves an access to a "misaligned" location from - the host's point of view.. diff --git a/bfd/bfd.doc.ps b/bfd/bfd.doc.ps deleted file mode 100755 index 70638d5d777..00000000000 --- a/bfd/bfd.doc.ps +++ /dev/null @@ -1,4564 +0,0 @@ -%!PS-Adobe-2.0 -%%Creator: dvips 5.47 Copyright 1986-91 Radical Eye Software -%%Title: bfd.dvi -%%Pages: 61 1 -%%BoundingBox: 0 0 612 792 -%%EndComments -%%BeginProcSet: tex.pro -/TeXDict 200 dict def TeXDict begin /N /def load def /B{bind def}N /S /exch -load def /X{S N}B /TR /translate load N /isls false N /vsize 10 N /@rigin{ -isls{[0 1 -1 0 0 0]concat}if 72 Resolution div 72 VResolution div neg scale -Resolution VResolution vsize neg mul TR matrix currentmatrix dup dup 4 get -round 4 exch put dup dup 5 get round 5 exch put setmatrix}N /@letter{/vsize 10 -N}B /@landscape{/isls true N /vsize -1 N}B /@a4{/vsize 10.6929133858 N}B /@a3{ -/vsize 15.5531 N}B /@ledger{/vsize 16 N}B /@legal{/vsize 13 N}B /@manualfeed{ -statusdict /manualfeed true put}B /@copies{/#copies X}B /FMat[1 0 0 -1 0 0]N -/FBB[0 0 0 0]N /nn 0 N /IE 0 N /ctr 0 N /df-tail{/nn 8 dict N nn begin -/FontType 3 N /FontMatrix fntrx N /FontBBox FBB N string /base X array -/BitMaps X /BuildChar{CharBuilder}N /Encoding IE N end dup{/foo setfont}2 -array copy cvx N load 0 nn put /ctr 0 N[}B /df{/sf 1 N /fntrx FMat N df-tail} -B /dfs{div /sf X /fntrx[sf 0 0 sf neg 0 0]N df-tail}B /E{pop nn dup definefont -setfont}B /ch-width{ch-data dup length 5 sub get}B /ch-height{ch-data dup -length 4 sub get}B /ch-xoff{128 ch-data dup length 3 sub get sub}B /ch-yoff{ -ch-data dup length 2 sub get 127 sub}B /ch-dx{ch-data dup length 1 sub get}B -/ch-image{ch-data dup type /stringtype ne{ctr get /ctr ctr 1 add N}if}B /id 0 -N /rw 0 N /rc 0 N /gp 0 N /cp 0 N /G 0 N /sf 0 N /CharBuilder{save 3 1 roll S -dup /base get 2 index get S /BitMaps get S get /ch-data X pop /ctr 0 N ch-dx 0 -ch-xoff ch-yoff ch-height sub ch-xoff ch-width add ch-yoff setcachedevice -ch-width ch-height true[1 0 0 -1 -.1 ch-xoff sub ch-yoff .1 add]{ch-image} -imagemask restore}B /D{/cc X dup type /stringtype ne{]}if nn /base get cc ctr -put nn /BitMaps get S ctr S sf 1 ne{dup dup length 1 sub dup 2 index S get sf -div put}if put /ctr ctr 1 add N}B /I{cc 1 add D}B /bop{userdict /bop-hook -known{bop-hook}if /SI save N @rigin 0 0 moveto}N /eop{clear SI restore -showpage userdict /eop-hook known{eop-hook}if}N /@start{userdict /start-hook -known{start-hook}if /VResolution X /Resolution X 1000 div /DVImag X /IE 256 -array N 0 1 255{IE S 1 string dup 0 3 index put cvn put}for}N /p /show load N -/RMat[1 0 0 -1 0 0]N /BDot 260 string N /rulex 0 N /ruley 0 N /v{/ruley X -/rulex X V}B /V statusdict begin /product where{pop product dup length 7 ge{0 -7 getinterval(Display)eq}{pop false}ifelse}{false}ifelse end{{gsave TR -.1 -.1 -TR 1 1 scale rulex ruley false RMat{BDot}imagemask grestore}}{{gsave TR -.1 --.1 TR rulex ruley scale 1 1 false RMat{BDot}imagemask grestore}}ifelse B /a{ -moveto}B /delta 0 N /tail{dup /delta X 0 rmoveto}B /M{S p delta add tail}B /b{ -S p tail}B /c{-4 M}B /d{-3 M}B /e{-2 M}B /f{-1 M}B /g{0 M}B /h{1 M}B /i{2 M}B -/j{3 M}B /k{4 M}B /w{0 rmoveto}B /l{p -4 w}B /m{p -3 w}B /n{p -2 w}B /o{p -1 w -}B /q{p 1 w}B /r{p 2 w}B /s{p 3 w}B /t{p 4 w}B /x{0 S rmoveto}B /y{3 2 roll p -a}B /bos{/SS save N}B /eos{clear SS restore}B end -%%EndProcSet -%%BeginProcSet: special.pro -TeXDict begin /SDict 200 dict N SDict begin /@SpecialDefaults{/hs 612 N /vs -792 N /ho 0 N /vo 0 N /hsc 1 N /vsc 1 N /ang 0 N /CLIP false N /BBcalc false N -/p 3 def}B /@scaleunit 100 N /@hscale{@scaleunit div /hsc X}B /@vscale{ -@scaleunit div /vsc X}B /@hsize{/hs X /CLIP true N}B /@vsize{/vs X /CLIP true -N}B /@hoffset{/ho X}B /@voffset{/vo X}B /@angle{/ang X}B /@rwi{10 div /rwi X} -B /@llx{/llx X}B /@lly{/lly X}B /@urx{/urx X}B /@ury{/ury X /BBcalc true N}B -/magscale true def end /@MacSetUp{userdict /md known{userdict /md get type -/dicttype eq{md begin /letter{}N /note{}N /legal{}N /od{txpose 1 0 mtx -defaultmatrix dtransform S atan/pa X newpath clippath mark{transform{ -itransform moveto}}{transform{itransform lineto}}{6 -2 roll transform 6 -2 -roll transform 6 -2 roll transform{itransform 6 2 roll itransform 6 2 roll -itransform 6 2 roll curveto}}{{closepath}}pathforall newpath counttomark array -astore /gc xdf pop ct 39 0 put 10 fz 0 fs 2 F/|______Courier fnt invertflag{ -PaintBlack}if}N /txpose{pxs pys scale ppr aload pop por{noflips{pop S neg S TR -pop 1 -1 scale}if xflip yflip and{pop S neg S TR 180 rotate 1 -1 scale ppr 3 -get ppr 1 get neg sub neg ppr 2 get ppr 0 get neg sub neg TR}if xflip yflip -not and{pop S neg S TR pop 180 rotate ppr 3 get ppr 1 get neg sub neg 0 TR}if -yflip xflip not and{ppr 1 get neg ppr 0 get neg TR}if}{noflips{TR pop pop 270 -rotate 1 -1 scale}if xflip yflip and{TR pop pop 90 rotate 1 -1 scale ppr 3 get -ppr 1 get neg sub neg ppr 2 get ppr 0 get neg sub neg TR}if xflip yflip not -and{TR pop pop 90 rotate ppr 3 get ppr 1 get neg sub neg 0 TR}if yflip xflip -not and{TR pop pop 270 rotate ppr 2 get ppr 0 get neg sub neg 0 S TR}if} -ifelse scaleby96{ppr aload pop 4 -1 roll add 2 div 3 1 roll add 2 div 2 copy -TR .96 dup scale neg S neg S TR}if}N /cp{pop pop showpage pm restore}N end}if} -if}N /normalscale{Resolution 72 div VResolution 72 div neg scale magscale{ -DVImag dup scale}if}N /psfts{S 65536 div N}N /startTexFig{/psf$SavedState save -N userdict maxlength dict begin /magscale false def normalscale currentpoint -TR /psf$ury psfts /psf$urx psfts /psf$lly psfts /psf$llx psfts /psf$y psfts -/psf$x psfts currentpoint /psf$cy X /psf$cx X /psf$sx psf$x psf$urx psf$llx -sub div N /psf$sy psf$y psf$ury psf$lly sub div N psf$sx psf$sy scale psf$cx -psf$sx div psf$llx sub psf$cy psf$sy div psf$ury sub TR /showpage{}N -/erasepage{}N /copypage{}N /p 3 def @MacSetUp}N /doclip{psf$llx psf$lly -psf$urx psf$ury currentpoint 6 2 roll newpath 4 copy 4 2 roll moveto 6 -1 roll -S lineto S lineto S lineto closepath clip newpath moveto}N /endTexFig{end -psf$SavedState restore}N /@beginspecial{SDict begin /SpecialSave save N gsave -normalscale currentpoint TR @SpecialDefaults}N /@setspecial{CLIP{newpath 0 0 -moveto hs 0 rlineto 0 vs rlineto hs neg 0 rlineto closepath clip}if ho vo TR -hsc vsc scale ang rotate BBcalc{rwi urx llx sub div dup scale llx neg lly neg -TR}if /showpage{}N /erasepage{}N /copypage{}N newpath}N /@endspecial{grestore -clear SpecialSave restore end}N /@defspecial{SDict begin}N /@fedspecial{end}B -/li{lineto}B /rl{rlineto}B /rc{rcurveto}B /np{/SaveX currentpoint /SaveY X N 1 -setlinecap newpath}N /st{stroke SaveX SaveY moveto}N /fil{fill SaveX SaveY -moveto}N /ellipse{/endangle X /startangle X /yrad X /xrad X /savematrix matrix -currentmatrix N TR xrad yrad scale 0 0 1 startangle endangle arc savematrix -setmatrix}N end -%%EndProcSet -TeXDict begin 1000 300 300 @start /Fa 1 59 df<70F8F8F87005057C840D>58 -D E /Fb 1 59 df<78FCFCFCFC7806067B8510>58 D E /Fc 32 120 df<00FC00018200070300 -0607000E02000E00000E00000E00000E00000E0000FFFF000E07000E07000E07000E07000E0700 -0E07000E07000E07000E07000E07000E07000E07000E07000E07007F0FE0131A809915>12 -D45 D<078018603030303060186018E01CE01CE01CE01CE01CE01CE01C -E01CE01CE01CE01CE01C6018601870383030186007800E187E9713>48 D<03000700FF00070007 -00070007000700070007000700070007000700070007000700070007000700070007000700FFF0 -0C187D9713>I<0F80106020304038803CC01CE01C401C003C003800380070006000C001800100 -020004040804100430083FF87FF8FFF80E187E9713>I<0F8010E0207060787038203800780070 -0070006000C00F8000E000700038003C003CE03CE03CC03C4038407030E00F800E187E9713>I< -00300030007000F000F001700370027004700C7008701070307020704070C070FFFF0070007000 -7000700070007007FF10187F9713>I<30183FF03FE03FC02000200020002000200027C0386020 -3000380018001C001C401CE01CE01C80184038403030E00F800E187E9713>I<01E006100C1818 -383038300070006000E000E7C0E860F030F018E018E01CE01CE01C601C601C7018301830301860 -07C00E187E9713>I<40007FFE7FFC7FFC40088010801080200040004000800180018001000300 -03000300030007000700070007000700070002000F197E9813>I<078018603030201860186018 -601870103C303E600F8007C019F030F86038401CC00CC00CC00CC00C6008201018600FC00E187E -9713>I<07801860303070306018E018E018E01CE01CE01C601C603C303C185C0F9C001C001800 -18003870307060604021801F000E187E9713>I<1FC020604030C038E038E0380038007000E001 -8001000300020002000200020002000200000000000000000006000F000F0006000D1A7E9912> -63 D66 D68 D70 D<3F8070C070E0207000700070 -07F01C7030707070E070E071E071E0F171FB1E3C10107E8F13>97 DI<07F80C1C -381C30087000E000E000E000E000E000E0007000300438080C1807E00E107F8F11>I<07C01C30 -30187018600CE00CFFFCE000E000E000E0006000300438080C1807E00E107F8F11>101 -D<01F0031807380E100E000E000E000E000E000E00FFC00E000E000E000E000E000E000E000E00 -0E000E000E000E000E000E007FE00D1A80990C>I104 D<18003C003C00180000 -0000000000000000000000FC001C001C001C001C001C001C001C001C001C001C001C001C001C00 -1C00FF80091A80990A>I<018003C003C001800000000000000000000000000FC001C001C001C0 -01C001C001C001C001C001C001C001C001C001C001C001C001C001C001C041C0E180E3007E000A -2182990C>I108 DII<07E0 -1C38300C700E6006E007E007E007E007E007E0076006700E381C1C3807E010107F8F13>I114 -D<1F2060E04020C020C020F0007F003FC01FE000F080708030C030C020F0408F800C107F8F0F> -I<0400040004000C000C001C003C00FFC01C001C001C001C001C001C001C001C001C201C201C20 -1C201C200E4003800B177F960F>I119 D E /Fd 1 59 df<60F0F06004047D830B>58 D E -/Fe 42 123 df<0FC01FF03838701CE00EE00EE00E400E000E001C001C00380030007000E001C0 -030006000C00180E300E7FFE7FFE0F177E9614>50 D<000E003E007C00F003E007C01F003E00F8 -00F000F8003E001F0007C003E000F0007C003E000E0F137E9414>60 D<4000E000F8007C001E00 -0F8007C001F000F8003E001E003E00F801F007C00F801E007C00F800E00040000F157E9514>62 -D<01C00003E00003E0000360000360000770000770000770000770000630000E38000E38000E38 -000E38000E38001FFC001FFC001C1C001C1C003C1E00380E00FE3F80FE3F8011177F9614>65 -DI<03C60FFE1C3E181E381E700E700E600EE000E000E000E000 -E000E000E000600E700E700E380C181C1C380FF003C00F177E9614>IIII< -FE3F80FE3F80380E00380E00380E00380E00380E00380E00380E00380E003FFE003FFE00380E00 -380E00380E00380E00380E00380E00380E00380E00380E00FE3F80FE3F8011177F9614>72 -D77 -DI<1F -F07FFC783C701CE00EE00EE00EE00EE00EE00EE00EE00EE00EE00EE00EE00EE00EE00EE00E701C -783C7FFC1FF00F177E9614>II<7FFF80FFFF80E1C380E1C380 -E1C380E1C38001C00001C00001C00001C00001C00001C00001C00001C00001C00001C00001C000 -01C00001C00001C00001C0000FF8000FF80011177F9614>84 D87 D<7E3E007E3E001C38001E38000E78 -000F700007F00007E00003E00003C00001C00003C00003E00003E0000770000770000E78000E38 -001C3C001C1C003C1E00FE3F80FE3F8011177F9614>I<1FC0007FF000707800201800001C0000 -1C0007FC001FFC003C1C00701C00E01C00E01C00E01C00707C003FFF800F8F8011107E8F14>97 -DI<03 -F80FFC1C1C380870006000E000E000E000E00060007000380E1C1E0FFC03F00F107E8F14>I<00 -7E00007E00000E00000E00000E00000E00000E0007CE000FFE001C3E00301E00700E00E00E00E0 -0E00E00E00E00E00E00E00E00E00700E00301E00383E001FEFC007CFC012177F9614>I<07E00F -F01C38301C700CE00EE00EFFFEFFFEE00060007000380E1C1E0FFC03F00F107E8F14>I<007C00 -FE01CE03840380038003807FFEFFFE038003800380038003800380038003800380038003800380 -7FFC7FFC0F177F9614>I<07CF001FFF80383B80301800701C00701C00701C003018003838003F -F00037C0007000007000003FF8001FFC003FFE00700F00E00380E00380E00380E003807007003C -1E001FFC0007F00011197F8F14>II<030007800780030000000000000000007F807F80038003800380 -038003800380038003800380038003800380FFFCFFFC0E187D9714>I<006000F000F000600000 -0000000000001FF01FF00070007000700070007000700070007000700070007000700070007000 -7000700070007040E0E0C07F803F000C207E9714>IIIII<07C01FF03C78701C701CE00E -E00EE00EE00EE00EE00E701C783C3C781FF007C00F107E8F14>II114 D<0FD83FF86038C038C038F0007F803FF007F8001C6006E006F006F81CFFF8CFE0 -0F107E8F14>I<030007000700070007007FFCFFFC07000700070007000700070007000700070E -070E070E070C03FC00F00F157F9414>IIII<7E3F007E3F001E38000E780007 -700007E00003E00001C00003C00003E0000770000E78000E38001C1C00FE3F80FE3F8011107F8F -14>II<3FFF7FFF700E701C7038007000E001C0038007000E001C0738077007FFFFFFFF10107F -8F14>I E /Ff 70 123 df<0003F07C001E0DC600380F0F00701E0F00E01E0E00E00C0001C01C -0001C01C0001C01C0001C01C0001C01C00038038007FFFFFC00380380003803800038038000380 -38000700700007007000070070000700700007007000070070000E00E0000E00E0000E00E0000E -00E0000E00E0000E00E0001C01C0001E01E000FF8FFE0020207E9F1B>11 -D<0003E0001C1800381800703C00E03C00E03801C00001C00001C00001C00001C0000380007FFF -F00380700380700380700380700700E00700E00700E00700E00700E00700E00E01C00E01C00E01 -C00E01C00E01C00E01C01C03801E03C0FF0FF816207E9F19>I<0003F4001C1C00383C00703C00 -E03C00E03801C03801C03801C03801C03801C0380380707FFFF003807003807003807003807007 -00E00700E00700E00700E00700E00700E00E01C00E01C00E01C00E01C00E01C00E01C01C03801E -03C0FF9FF816207E9F19>I<0003F03F00001E09E08000380F80C000701F01E000E03E01E000E0 -1E01C001C01C000001C01C000001C01C000001C01C000001C01C000003803800007FFFFFFF8003 -803803800380380380038038038003803803800700700700070070070007007007000700700700 -070070070007007007000E00E00E000E00E00E000E00E00E000E00E00E000E00E00E000E00E00E -001C01C01C001E01E01E00FF8FF8FFC023207E9F26>I<387C7C7E3A040404080810204080070E -789F0D>39 D<00030004000800100020006000C0018001000300060006000C000C001C00180018 -00380030003000700070006000600060006000E000E000E000E000E000E0006000600060006000 -6000300030001000180008000C00040002000100102E7CA112>I<008000C00060002000300018 -0018000C000C000C000E00060006000600060006000600060006000600060006000E000E000E00 -0C000C001C001800180038003000300060006000C000C001800100030006000C00180030006000 -80000F2E7FA112>I<0020000060000060000060000060007061C03843800E4E0007580001E000 -01E00006B8001C9C00708700E0838001800001800001800001800001000012147AA117>I<1C3E -7E7E3A0202040408081020C0070E7D840D>44 DI<3078F8787005057C -840D>I<007E0001C3000301800701C00E00C00E00E01C00E01C00E03C01E03801E07801E07801 -E07801E07801E07801E0F003C0F003C0F003C0F003C0F003C0F00380F00780E00780E00700E007 -00E00E00600E00701C003038003870000FC000131F7C9D17>48 D<000C001C00FC0F3800380038 -00380038003800700070007000700070007000E000E000E000E000E000E001C001C001C001C001 -C001C0038003C0FFFE0F1E7C9D17>I<003F8000C1E00100F00200780400780400780F007C0F80 -7C0F807C0F00780600780000F80000F00001E00001C0000380000700000E00001C000038000060 -0000C0000180000300200600200800401000403FFFC07FFF80FFFF80161E7E9D17>I<007F0001 -83C00201E00400F00700F00F00F00F01F00F01F00001E00001E00003C0000380000700000E0000 -F800000E000007000007800007C00003C00007C03007C07807C0F807C0F807C0F00780800F0040 -0E00201C0018780007E000141F7D9D17>I<0000600000600000E00001C00003C00005C0000DC0 -0009C00011C000238000438000C380008380010380020380040700080700180700100700200700 -400700FFFFF0000E00000E00000E00000E00000E00001C00001E0001FFE0141E7E9D17>I<0180 -3001FFE003FFC003FF0003FC00020000020000020000040000040000040000047C000587000603 -800C01800801C00001C00001E00001E00001E00001E07003C0F803C0F003C0E003808007804007 -00400E00201C0018700007C000141F7D9D17>I<000F8000704000C0200180E00301E00701E00E -00C01E00001C00003C000038000078F800790E007A07007C0300F80380F80380F003C0F003C0F0 -03C0F003C0F00780E00780E00780E00700E00F00600E00701C0030180018700007C000131F7C9D -17>I<003F0000C1C00100600200600400300C00300C00300C00300C00600E00600F80C00FC180 -07F60003FC0001FC0001FF00063F800C0F801007C03003C06001C06000C0C000C0C000C0C000C0 -C00080C0010060030030040018180007E000141F7D9D17>56 D<007E0001C3000301800601C00E -01C01C00C03C00E03C00E03C01E07801E07801E07801E07801E07803E07803E03803C03807C01C -0BC00C13C003E380000780000780000700000E00600E00F01C00F01800E0300080600041C0003F -0000131F7C9D17>I<0E1F1F1E0C000000000000000000003078F8787008147C930D>I<07000F80 -0F800F000600000000000000000000000000000000000000000018003C007C007C003C00040004 -000800080010001000200040008000091D7D930D>I<1FFFFFF83FFFFFFC000000000000000000 -0000000000000000000000000000000000000000000000FFFFFFF07FFFFFE01E0C7C9023>61 -D<07E01838201C401C701CF03CF03C603C0038007000E001C00180030002000600040004000800 -0800080008000000000000000000000030007800F800780070000E20799F15>63 -D<0000100000001800000038000000380000007800000078000000FC000001BC0000013C000003 -3C0000023C0000063C0000043E0000081E0000081E0000101E0000101E0000201E0000200F0000 -400F0000400F0000FFFF0000800F0001000F800100078002000780020007800400078004000780 -0C0007C03E0007C0FF807FFC1E207E9F22>65 D<07FFFF00007C01C0003C01E0003C00F0007800 -F8007800F8007800F8007800F8007800F8007800F000F001F000F001E000F003C000F00F8000FF -FE0000F00F0001E007C001E003C001E003E001E001E001E001E001E001E003C001E003C003E003 -C003E003C003C003C007C003C00F8007800F0007803E00FFFFF0001D1F7E9E20>I<0001F80800 -0E061800380138007000F801E0007803C0007007800030078000300F0000301F0000301E000030 -3E0000203C0000007C0000007C0000007C0000007C000000F8000000F8000000F8000000F80000 -00F80000007800004078000080780000803C0000803C0001001C0002000E00020006000C000300 -100001C0E000003F00001D217B9F21>I<07FFFF00007C01E0003C00F0003C00780078003C0078 -003C0078001E0078001E0078001E0078001F00F0001F00F0001F00F0001F00F0001F00F0001F00 -F0001F01E0001E01E0003E01E0003E01E0003E01E0003C01E0007C03C0007803C000F003C000F0 -03C001E003C003C003C0078007800F0007803C00FFFFE000201F7E9E23>I<07FFFFF8007C0078 -003C0038003C001800780018007800080078000800780008007800080078080800F0100000F010 -0000F0100000F0300000FFF00000F0700001E0200001E0200001E0200001E0200001E0000801E0 -001003C0001003C0001003C0002003C0002003C0006003C000C0078001C0078007C0FFFFFF801D -1F7E9E1F>I<07FFFFF8007C0078003C0038003C00180078001800780008007800080078000800 -7800080078000800F0100000F0100000F0100000F0300000F0700000FFF00001E0600001E02000 -01E0200001E0200001E0200001E0000003C0000003C0000003C0000003C0000003C0000003C000 -000780000007C00000FFFE00001D1F7E9E1E>I<0001FC04000F030C003C009C0070007C00E000 -3C01C0003803800018078000180F0000181F0000181E0000183E0000103C0000007C0000007C00 -00007C0000007C000000F8000000F8000000F8007FFCF80003E0780001E0780001E0780003C078 -0003C03C0003C03C0003C01C0003C00E0007C007000B800380118001E06080003F80001E217B9F -24>I<07FFE0007C00003C00003C0000780000780000780000780000780000780000F00000F000 -00F00000F00000F00000F00001E00001E00001E00001E00001E00001E00003C00003C00003C000 -03C00003C00003C00007800007C000FFFC00131F7F9E10>73 D<07FFF000007E0000003C000000 -3C000000780000007800000078000000780000007800000078000000F0000000F0000000F00000 -00F0000000F0000000F0000001E0000001E0000001E0000001E0000001E0008001E0010003C001 -0003C0010003C0030003C0020003C0060003C0060007801E0007807C00FFFFFC00191F7E9E1C> -76 D<07FC0000FFC0007C0000F800003C00017800003C00017800004E0002F000004E0002F000 -004E0004F000004E0004F000004E0008F000004E0008F00000870011E00000870011E000008700 -21E00000870021E00000870041E00000838041E00001038083C00001038083C00001038103C000 -01038203C0000101C203C0000101C403C0000201C40780000201C80780000201C80780000201D0 -0780000200F00780000600E00780000600E00F00000F00C00F8000FFE0C1FFF8002A1F7E9E2A> -I<07FC01FFC0003E003E00003E001800003E001800004F001000004F0010000047801000004780 -10000043C010000043C010000083C020000081E020000081E020000080F020000080F020000080 -782000010078400001007C400001003C400001003C400001001E400001001E400002000F800002 -000F800002000F800002000780000200078000060003800006000300000F00010000FFE0010000 -221F7E9E22>I<0003F800001E0E000038070000E0038001C001C003C001E0078000E00F0000F0 -0F0000F01E0000F01E0000F83E0000F83C0000F87C0000F87C0000F87C0000F87C0000F8F80001 -F0F80001F0F80001F0F80001F0F80003E0780003E0780003C0780007C07C0007803C000F003C00 -1E001E001C000E0038000700F00003C3C00000FE00001D217B9F23>I<07FFFF00007C03C0003C -01E0003C00F0007800F0007800F8007800F8007800F8007800F8007800F000F001F000F001E000 -F003C000F0078000F00F0000FFF80001E0000001E0000001E0000001E0000001E0000001E00000 -03C0000003C0000003C0000003C0000003C0000003C000000780000007C00000FFFC00001D1F7E -9E1F>I<07FFFC00007C0700003C03C0003C01E0007801E0007801F0007801F0007801F0007801 -F0007801E000F003E000F003C000F0078000F00F0000F03C0000FFF00001E0300001E0380001E0 -1C0001E01C0001E01C0001E01E0003C03E0003C03E0003C03E0003C03E0003C03E0003C03E0207 -803E0407C01F04FFFC0F18000003E01F207E9E21>82 D<003F040060CC01803C03801C03001C07 -00180600080E00080E00080E00080E00000F00000F80000FE00007FE0003FF8001FFC0007FE000 -07E00001E00000E00000F00000F04000E04000E04000E04000E06000C0600180E00380F80300C6 -0C0081F80016217D9F19>I<3FFFFFF03C0780F03007803060078030400F0010400F0010C00F00 -10800F0010800F0010800F0010001E0000001E0000001E0000001E0000001E0000001E0000003C -0000003C0000003C0000003C0000003C0000003C00000078000000780000007800000078000000 -7800000078000000F0000001F800007FFFE0001C1F7A9E21>II87 D<00FE01FC01800180018001800180030003000300030003000300060006 -0006000600060006000C000C000C000C000C000C00180018001800180018001800300030003000 -300030003000600060006000600060006000FE00FE000F2D7EA10D>91 D<00FE01FC000C000C00 -0C000C000C00180018001800180018001800300030003000300030003000600060006000600060 -006000C000C000C000C000C000C0018001800180018001800180030003000300030003000300FE -00FE000F2D81A10D>93 D<07F8000C0C001E06001E07001C070000070000070000070000FF0007 -C7001E07003C0E00780E00F00E10F00E10F00E10F01E10F02E20784F401F878014147D9317>97 -D<0700003F00000F00000700000700000E00000E00000E00000E00000E00000E00001C00001C7C -001D87001E03801C01C01C01C03801C03801E03801E03801E03801E03801E07003C07003C07003 -80700780700700700E00E81C00C4380083E00013207B9F19>I<01FC07060E0F1C0F380E780070 -00F000F000F000F000E000E000E000E000F0027004300818300FC010147C9314>I<0000700003 -F00000F00000700000700000E00000E00000E00000E00000E00000E00001C000F9C00305C00E03 -C01C03C03801C0780380700380F00380F00380F00380F00380E00700E00700E00700E00700E007 -00700F00301E00186F000F8FE014207C9F19>I<00F800070E000E07001C070038038078038070 -0380F00380F00380FFFF80F00000E00000E00000E00000E00000F001007002003004001C180007 -E00011147D9314>I<0007800018C00031E00061E000E1C000C00001C00001C00001C00001C000 -01C0000380007FF800038000038000038000038000070000070000070000070000070000070000 -0E00000E00000E00000E00000E00000E00001C00001E0000FFE00013207E9F0E>I<00000E003E -1100E1A301C1C20381E00780E00701E00F01E00F01E00F01E00703C007038007870004FC000800 -000800001800001C00000FFF000FFFC007FFE01800F0300030600030C00030C00030C000306000 -603000C01C070007FC00181F809417>I<00E00007E00001E00000E00000E00001C00001C00001 -C00001C00001C00001C000038000038F800390E003A0E003C0600380600780E00700E00700E007 -00E00700E00700E00E01C00E01C00E01C00E01C00E01C00E01C01C03801E03C0FFCFF815207E9F -19>I<01C003E003E003E001C000000000000000000000000003801F8007800380038007000700 -07000700070007000E000E000E000E000E000E001C001E00FF800B1F7F9E0C>I<0003800007C0 -0007C0000780000300000000000000000000000000000000000000000700007F00000F00000700 -000700000E00000E00000E00000E00000E00000E00001C00001C00001C00001C00001C00001C00 -003800003800003800003800003800003800007000607000F06000F0C0006180003F0000122883 -9E0E>I<00E00007E00001E00000E00000E00001C00001C00001C00001C00001C00001C0000380 -000383FC0380F00380C0038180038100070400070800071800073800077C00071C000E1C000E0E -000E0E000E0F000E07000E07801C03801E07C0FF8FF016207E9F18>I<00E007E001E000E000E0 -01C001C001C001C001C001C00380038003800380038003800700070007000700070007000E000E -000E000E000E000E001C001E00FFC00B207F9F0C>I<0387C07C001F9861860007A072070003C0 -34030003803803000780780700070070070007007007000700700700070070070007007007000E -00E00E000E00E00E000E00E00E000E00E00E000E00E00E000E00E00E001C01C01C001E01E01E00 -FFCFFCFFC022147E9326>I<038F801F90E007A0E003C0600380600780E00700E00700E00700E0 -0700E00700E00E01C00E01C00E01C00E01C00E01C00E01C01C03801E03C0FFCFF815147E9319> -I<00FC000387000E01801C00C03800E03800E07000F0F000F0F000F0F000F0F000F0E001E0E001 -E0E001C0E003C0F00380700700380E001C1C0007E00014147D9317>I<00E3E007EC3800F01C00 -E01E00E00E01C00E01C00F01C00F01C00F01C00F01C00F03801E03801E03801C03803C03803803 -80700740E00721C0071F000700000700000700000E00000E00000E00000E00001E0000FFC00018 -1D809319>I<00F040038CC00E04C01C03C03C03C0780380780380F00380F00380F00380F00380 -E00700E00700E00700F00700F00F00700F00301E00186E000F8E00000E00000E00000E00001C00 -001C00001C00001C00003C0001FF80121D7C9318>I<038E001FB38007C78003C7800383000780 -000700000700000700000700000700000E00000E00000E00000E00000E00000E00001C00001E00 -00FFE00011147E9312>I<01F2060E080618061802380438001E001FE00FF003F8003C401C400C -400C600C6018E010D0608FC00F147E9312>I<0080010001000100030007000F001E00FFF80E00 -0E000E000E001C001C001C001C001C001C00380038203820382038203840384018800F000D1C7C -9B12>I<1C0380FC1F803C07801C03801C0380380700380700380700380700380700380700700E -00700E00700E00700E00701E00701E00703C00305E001F9FC012147B9319>III<1FF0FF03C07801C060 -01C04000E08000E180007300007600003C00003C00001C00002E00004E00008700010700020380 -0603800C01C03E03E0FF07FC18147F9318>I<0FF83F8001E00E0001C00C0001C0080000E01800 -00E0100000E0200000E0200000F040000070400000708000007080000071000000390000003A00 -00003E0000003C00000038000000180000001000000010000000200000002000000040000070C0 -0000F0800000F1000000E20000007C000000191D809318>I<07FFE00701E00401C00C03800807 -00080E00101C0000380000700000700000E00001C0000380800700800E00801C01001C01003803 -00700E00FFFE0013147F9314>I E /Fg 4 12 df8 D<00000040000000C0000000C0000000C0000000 -C0000000C000000180000001800000018000000180000003000000030000000600000006000000 -0C00000018000000180000003000000060000000C0000003800000070000001C00000078000007 -E00000FF800000F80000001A1B989A32>I<40000000C0000000C0000000C0000000C0000000C0 -000000600000006000000060000000300000003000000018000000180000000C00000006000000 -06000000030000000180000000C000000060000000380000001C0000000700000003C0000000F8 -0000003FE0000007E01B1B809A32>I<000007E000003FE00000F8000003C00000070000001C00 -00003800000060000000C00000018000000300000006000000060000000C000000180000001800 -00003000000030000000600000006000000060000000C0000000C0000000C0000000C0000000C0 -000000400000001B1B808132>I E /Fh 87 126 df<70F8F8F8F8F8F8F8F8F8F8F8F8F8F8F8F8 -70000000000070F8F8F870051C779B18>33 D<4010E038F078E038E038E038E038E038E038E038 -E038E038E03860300D0E7B9C18>I<030600078F00078F00078F00078F00078F00078F007FFFC0 -FFFFE0FFFFE07FFFC00F1E000F1E000F1E000F1E000F1E000F1E007FFFC0FFFFE0FFFFE07FFFC0 -1E3C001E3C001E3C001E3C001E3C001E3C000C1800131C7E9B18>I<3803007C07807C0780EE0F -80EE0F00EE0F00EE1F00EE1E00EE1E00EE3E007C3C007C3C00387C0000780000780000F80000F0 -0001F00001E00001E00003E00003C00003C00007C0000783800787C00F87C00F0EE00F0EE01F0E -E01E0EE01E0EE03E0EE03C07C03C07C018038013247E9F18>37 D<007000F001E003C007800F00 -1E001C00380038007000700070007000E000E000E000E000E000E000E000E00070007000700070 -00380038001C001E000F00078003C001F000F000700C24799F18>40 D<6000F00078003C001E00 -0F000780038001C001C000E000E000E000E00070007000700070007000700070007000E000E000 -E000E001C001C0038007800F001E003C007800F00060000C247C9F18>I<01C00001C00001C000 -01C000C1C180F1C780F9CF807FFF001FFC0007F00007F0001FFC007FFF00F9CF80F1C780C1C180 -01C00001C00001C00001C00011147D9718>I<00600000F00000F00000F00000F00000F00000F0 -0000F0007FFFC0FFFFE0FFFFE07FFFC000F00000F00000F00000F00000F00000F00000F0000060 -0013147E9718>I<1C3E7E7F3F1F070E1E7CF860080C788518>I<7FFF00FFFF80FFFF807FFF0011 -047D8F18>I<3078FCFC78300606778518>I<000300000780000780000F80000F00001F00001E00 -001E00003E00003C00007C0000780000780000F80000F00001F00001E00003E00003C00003C000 -07C0000780000F80000F00000F00001F00001E00003E00003C00003C00007C0000780000F80000 -F00000F0000060000011247D9F18>I<01F00007FC000FFE001F1F001C07003803807803C07001 -C07001C0E000E0E000E0E000E0E000E0E000E0E000E0E000E0E000E0E000E0F001E07001C07001 -C07803C03803801C07001F1F000FFE0007FC0001F000131C7E9B18>I<01800380038007800F80 -3F80FF80FB80438003800380038003800380038003800380038003800380038003800380038003 -807FFCFFFE7FFC0F1C7B9B18>I<03F0000FFE003FFF007C0F807003C0E001C0F000E0F000E060 -00E00000E00000E00001C00001C00003C0000780000F00001E00003C0000780000F00001E00007 -C0000F80001E00E03C00E07FFFE0FFFFE07FFFE0131C7E9B18>I<07F8001FFE003FFF00780780 -7803C07801C03001C00001C00003C0000380000F0003FF0003FE0003FF000007800003C00001C0 -0000E00000E00000E0F000E0F000E0F001C0F003C07C07803FFF001FFE0003F800131C7E9B18> -I<001F00003F0000770000770000E70001E70001C7000387000787000707000E07001E07003C07 -00380700780700F00700FFFFF8FFFFF8FFFFF8000700000700000700000700000700000700007F -F000FFF8007FF0151C7F9B18>I<1FFF803FFF803FFF8038000038000038000038000038000038 -00003800003800003BF8003FFE003FFF003C07801803C00001C00000E00000E06000E0F000E0F0 -00E0E001C07003C07C0F803FFF001FFC0003F000131C7E9B18>I<007E0001FF0007FF800F83C0 -1E03C01C03C0380180380000700000700000E1F800E7FE00FFFF00FE0780F803C0F001C0F000E0 -E000E0F000E07000E07000E07000E03801C03C03C01E07800FFF0007FE0001F800131C7E9B18> -II<03F8000FFE001FFF003E0F803803807001C07001C070 -01C07001C03803803C07801FFF0007FC000FFE001F1F003C07807001C0F001E0E000E0E000E0E0 -00E0E000E07001C07803C03E0F801FFF000FFE0003F800131C7E9B18>I<03F0000FFC001FFE00 -3C0F00780780700380E001C0E001C0E001C0E001E0E001E07001E07803E03C0FE01FFFE00FFEE0 -03F0E00000E00001C00001C00001C0300380780780780F00783E003FFC001FF00007C000131C7E -9B18>I<3078FCFC783000000000000000003078FCFC78300614779318>I<183C7E7E3C18000000 -0000000000183C7E7E3E1E0E1C3C78F060071A789318>I<000300000780001F80003F00007E00 -01FC0003F00007E0001FC0003F00007E0000FC0000FC00007E00003F00001FC00007E00003F000 -01FC00007E00003F00001F8000078000030011187D9918>I<7FFFC0FFFFE0FFFFE0FFFFE00000 -00000000000000000000FFFFE0FFFFE0FFFFE07FFFC0130C7E9318>I<600000F00000FC00007E -00003F00001FC00007E00003F00001FC00007E00003F00001F80001F80003F00007E0001FC0003 -F00007E0001FC0003F00007E0000FC0000F0000060000011187D9918>I<0FF0003FFC007FFF00 -700F00F00380F00380600780000F00003E00007C0001F00001E00003C00003C00003C00003C000 -03C00003800000000000000000000000000000000003800007C00007C00007C000038000111C7D -9B18>I<007C0001FE0007FF000F87801E03C03C1DC0387FC070FFE071E3E071C1E0E1C1E0E380 -E0E380E0E380E0E380E0E380E0E380E0E1C1C071C1C071E3C070FF80387F003C1C001E00E00F83 -E007FFC001FF80007E00131C7E9B18>I<00700000F80000F80000D80000D80001DC0001DC0001 -DC00018C00038E00038E00038E00038E000306000707000707000707000707000FFF800FFF800F -FF800E03800E03801C01C01C01C07F07F0FF8FF87F07F0151C7F9B18>II<00F8E003FEE007FFE00F07E01E03E03C01E03800E07000E07000E0700000E00000E000 -00E00000E00000E00000E00000E00000E000007000007000E07000E03800E03C00E01E01C00F07 -C007FF8003FE0000F800131C7E9B18>I<7FF800FFFE007FFF001C0F801C03C01C03C01C01E01C -00E01C00E01C00F01C00701C00701C00701C00701C00701C00701C00701C00701C00F01C00E01C -00E01C01E01C01C01C03C01C0F807FFF00FFFE007FF800141C7F9B18>III<01F1C003FDC00FFFC01F0FC01C03C03803C03801C070 -01C07001C0700000E00000E00000E00000E00000E00000E00FF0E01FF0E00FF07001C07001C070 -03C03803C03803C01C07C01F0FC00FFFC003FDC001F1C0141C7E9B18>I<7F07F0FF8FF87F07F0 -1C01C01C01C01C01C01C01C01C01C01C01C01C01C01C01C01C01C01FFFC01FFFC01FFFC01C01C0 -1C01C01C01C01C01C01C01C01C01C01C01C01C01C01C01C01C01C07F07F0FF8FF87F07F0151C7F -9B18>I<7FFF00FFFF807FFF0001C00001C00001C00001C00001C00001C00001C00001C00001C0 -0001C00001C00001C00001C00001C00001C00001C00001C00001C00001C00001C00001C00001C0 -007FFF00FFFF807FFF00111C7D9B18>I<01FFC003FFC001FFC0000E00000E00000E00000E0000 -0E00000E00000E00000E00000E00000E00000E00000E00000E00000E00000E00000E00000E0000 -0E00000E00F00E00F00E00F03C007FFC003FF0000FC000121C7D9B18>I<7F07F0FF87F87F07F0 -1C03C01C07801C07001C0E001C1E001C3C001C38001C70001CF0001DF0001DF0001FB8001FB800 -1F1C001E1C001C0E001C0E001C07001C07001C03801C03801C01C07F03F0FF87F87F03F0151C7F -9B18>I<7FE000FFE0007FE0000E00000E00000E00000E00000E00000E00000E00000E00000E00 -000E00000E00000E00000E00000E00000E00000E00000E00000E00700E00700E00700E00700E00 -707FFFF0FFFFF07FFFF0141C7F9B18>II<7E07F0FF0FF87F07F0 -1D81C01D81C01D81C01DC1C01CC1C01CC1C01CE1C01CE1C01CE1C01C61C01C71C01C71C01C31C0 -1C39C01C39C01C39C01C19C01C19C01C1DC01C0DC01C0DC01C0DC07F07C0FF87C07F03C0151C7F -9B18>I<0FF8003FFE007FFF00780F00700700F00780E00380E00380E00380E00380E00380E003 -80E00380E00380E00380E00380E00380E00380E00380E00380E00380E00380F00780700700780F -007FFF003FFE000FF800111C7D9B18>II<7FF800FFFE007FFF00 -1C0F801C03801C03C01C01C01C01C01C01C01C03C01C03801C0F801FFF001FFE001FFE001C0F00 -1C07001C03801C03801C03801C03801C03801C039C1C039C1C039C7F01F8FF81F87F00F0161C7F -9B18>82 D<03F3801FFF803FFF807C0F80700780E00380E00380E00380E000007000007800003F -00001FF00007FE0000FF00000F800003C00001C00000E00000E06000E0E000E0E001E0F001C0F8 -0780FFFF80FFFE00E7F800131C7E9B18>I<7FFFF8FFFFF8FFFFF8E07038E07038E07038E07038 -007000007000007000007000007000007000007000007000007000007000007000007000007000 -00700000700000700000700000700007FF0007FF0007FF00151C7F9B18>IIII<7F8FE07F9FE07F8F -E00E07000F0700070E00078E00039C0003DC0001F80001F80000F00000F00000700000F00000F8 -0001F80001DC00039E00038E00070F000707000E07800E03801E03C07F07F0FF8FF87F07F0151C -7F9B18>II<3FFFE07FFFE07FFFE07001C07003C0700780700700 -000F00001E00001C00003C0000780000700000F00001E00001C00003C0000780000700000F0000 -1E00E01C00E03C00E07800E07000E0FFFFE0FFFFE0FFFFE0131C7E9B18>II<600000F00000F0 -0000F800007800007C00003C00003C00003E00001E00001F00000F00000F00000F800007800007 -C00003C00003C00003E00001E00001F00000F00000F800007800007800007C00003C00003E0000 -1E00001E00001F00000F00000F8000078000078000030011247D9F18>II<018007C01FF07EFC -F83EE00E0F067C9B18>I<7FFF00FFFF80FFFF807FFF0011047D7F18>I<1FE0003FF8007FFC0078 -1E00300E0000070000070000FF0007FF001FFF007F0700780700E00700E00700E00700F00F0078 -1F003FFFF01FFBF007E1F014147D9318>97 D<7E0000FE00007E00000E00000E00000E00000E00 -000E00000E3E000EFF800FFFC00FC1E00F80E00F00700E00700E00380E00380E00380E00380E00 -380E00380F00700F00700F80E00FC1E00FFFC00EFF80063E00151C809B18>I<01FE0007FF001F -FF803E0780380300700000700000E00000E00000E00000E00000E00000E000007000007001C038 -01C03E03C01FFF8007FF0001FC0012147D9318>I<001F80003F80001F80000380000380000380 -00038000038003E3800FFB801FFF803C1F80380F80700780700380E00380E00380E00380E00380 -E00380E00380700780700780380F803C1F801FFFF00FFBF803E3F0151C7E9B18>I<01F00007FC -001FFE003E0F00380780700380700380E001C0E001C0FFFFC0FFFFC0FFFFC0E000007000007001 -C03801C03E03C01FFF8007FF0001FC0012147D9318>I<001F80007FC000FFE000E1E001C0C001 -C00001C00001C0007FFFC0FFFFC0FFFFC001C00001C00001C00001C00001C00001C00001C00001 -C00001C00001C00001C00001C00001C00001C0007FFF007FFF007FFF00131C7F9B18>I<01E1F0 -07FFF80FFFF81E1E301C0E003807003807003807003807003807001C0E001E1E001FFC001FF800 -39E0003800001C00001FFE001FFFC03FFFE07801F0700070E00038E00038E00038E000387800F0 -7E03F01FFFC00FFF8001FC00151F7F9318>I<7E0000FE00007E00000E00000E00000E00000E00 -000E00000E3E000EFF800FFFC00FC1C00F80E00F00E00E00E00E00E00E00E00E00E00E00E00E00 -E00E00E00E00E00E00E00E00E00E00E07FC3FCFFE7FE7FC3FC171C809B18>I<03800007C00007 -C00007C0000380000000000000000000000000007FC000FFC0007FC00001C00001C00001C00001 -C00001C00001C00001C00001C00001C00001C00001C00001C00001C00001C000FFFF00FFFF80FF -FF00111D7C9C18>I<0038007C007C007C003800000000000000000FFC1FFC0FFC001C001C001C -001C001C001C001C001C001C001C001C001C001C001C001C001C001C001C001C001C001C001C60 -38F078FFF07FE03F800E277E9C18>II<7FE000FFE0007FE00000 -E00000E00000E00000E00000E00000E00000E00000E00000E00000E00000E00000E00000E00000 -E00000E00000E00000E00000E00000E00000E00000E00000E0007FFFC0FFFFE07FFFC0131C7E9B -18>I<7CE0E000FFFBF8007FFFF8001F1F1C001E1E1C001E1E1C001C1C1C001C1C1C001C1C1C00 -1C1C1C001C1C1C001C1C1C001C1C1C001C1C1C001C1C1C001C1C1C001C1C1C007F1F1F00FFBFBF -807F1F1F001914819318>I<7E3E00FEFF807FFFC00FC1C00F80E00F00E00E00E00E00E00E00E0 -0E00E00E00E00E00E00E00E00E00E00E00E00E00E00E00E07FC3FCFFE7FE7FC3FC1714809318> -I<01F0000FFE001FFF003E0F803803807001C07001C0E000E0E000E0E000E0E000E0E000E0F001 -E07001C07803C03C07803E0F801FFF000FFE0001F00013147E9318>I<7E3E00FEFF807FFFC00F -C1E00F80E00F00700E00700E00380E00380E00380E00380E00380E00380F00700F00700F80E00F -C1E00FFFC00EFF800E3E000E00000E00000E00000E00000E00000E00000E00007FC000FFE0007F -C000151E809318>I<7F87E0FF9FF07FBFF803F87803F03003E00003C00003C000038000038000 -0380000380000380000380000380000380000380007FFE00FFFF007FFE0015147F9318>114 -D<07F7003FFF007FFF00780F00E00700E00700E007007C00007FE0001FFC0003FE00001F006007 -80E00380E00380F00380F80F00FFFF00FFFC00E7F00011147D9318>I<01800003800003800003 -80000380007FFFC0FFFFC0FFFFC003800003800003800003800003800003800003800003800003 -80000380400380E00380E00380E001C1C001FFC000FF80003E0013197F9818>I<7E07E0FE0FE0 -7E07E00E00E00E00E00E00E00E00E00E00E00E00E00E00E00E00E00E00E00E00E00E00E00E00E0 -0E01E00F03E007FFFC03FFFE01FCFC1714809318>I<7F8FF0FF8FF87F8FF01E03C00E03800E03 -800E0380070700070700070700038E00038E00038E00038E0001DC0001DC0001DC0000F80000F8 -0000700015147F9318>II< -7F8FF07F9FF07F8FF0070700078E00039E0001DC0001F80000F80000700000F00000F80001DC00 -039E00038E000707000F07807F8FF0FF8FF87F8FF015147F9318>I<7F8FF0FF8FF87F8FF00E01 -C00E03800E0380070380070700070700038700038600038E0001CE0001CE0000CC0000CC0000DC -0000780000780000780000700000700000700000F00000E00079E0007BC0007F80003F00001E00 -00151E7F9318>I<3FFFF07FFFF07FFFF07001E07003C0700780000F00001E00003C0000F80001 -F00003C0000780000F00701E00703C0070780070FFFFF0FFFFF0FFFFF014147F9318>I<0007E0 -001FE0007FE000780000E00000E00000E00000E00000E00000E00000E00000E00000E00000E000 -00E00001E0007FC000FF8000FF80007FC00001E00000E00000E00000E00000E00000E00000E000 -00E00000E00000E00000E00000E000007800007FE0001FE00007E013247E9F18>I<60F0F0F0F0 -F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0600424769F18>I<7C -0000FF0000FFC00003C00000E00000E00000E00000E00000E00000E00000E00000E00000E00000 -E00000E00000F000007FC0003FE0003FE0007FC000F00000E00000E00000E00000E00000E00000 -E00000E00000E00000E00000E00000E00003C000FFC000FF00007C000013247E9F18>I -E /Fi 25 121 df<0001C0000003C000000FC000007FC0001FFFC000FFFFC000FFBFC000E03FC0 -00003FC000003FC000003FC000003FC000003FC000003FC000003FC000003FC000003FC000003F -C000003FC000003FC000003FC000003FC000003FC000003FC000003FC000003FC000003FC00000 -3FC000003FC000003FC000003FC000003FC000003FC000003FC000003FC000003FC000003FC000 -003FC000003FC000003FC000003FC000003FC000003FC0007FFFFFE07FFFFFE07FFFFFE01B2E7A -AD28>49 D<003FE00001FFFE0007FFFF800F80FFC01E003FE038001FF07C000FF87E0007FCFF00 -07FCFF8007FEFF8007FEFF8003FEFF8003FE7F0003FE3E0007FE000007FE000007FC000007FC00 -000FF800000FF800000FF000001FE000001FC000003F8000007F0000007E000000F8000001F000 -0003E0000007C000000F0000001E000E003C000E0038000E0070001E00E0001C01C0001C030000 -3C07FFFFFC0FFFFFFC1FFFFFFC3FFFFFFC7FFFFFF8FFFFFFF8FFFFFFF8FFFFFFF81F2E7CAD28> -I<001FF80000007FFF000001FFFFC00003E03FE00007800FF0000FC00FF8001FE007F8001FE007 -FC001FE007FC001FE007FC001FE007FC000FC007FC00078007FC0000000FF80000000FF8000000 -0FF00000001FE00000001FC00000003F80000000FE0000003FF80000003FFF800000001FE00000 -0007F000000007F800000003FC00000003FE00000001FF00000001FF00000001FF80000001FF80 -000001FF801C0001FF803E0001FF807F0001FF80FF8001FF80FF8001FF00FF8001FF00FF8003FE -007F0003FE007E0007FC003C0007F8001FC01FF0000FFFFFC00003FFFF0000003FF80000212E7D -AD28>I66 D<000003FF80018000003FFFF003800001FFFFFC07800007FF003F0F80001FF800079F80 -003FC00001FF8000FF800000FF8001FE0000007F8003FC0000003F8007FC0000001F8007F80000 -000F800FF00000000F801FF000000007801FF000000007803FE000000007803FE000000003807F -E000000003807FE000000003807FC000000000007FC00000000000FFC00000000000FFC0000000 -0000FFC00000000000FFC00000000000FFC00000000000FFC00000000000FFC00000000000FFC0 -0000000000FFC000000000007FC000000000007FC000000000007FE000000000007FE000000003 -803FE000000003803FE000000003801FF000000003801FF000000007800FF0000000070007F800 -0000070007FC0000000E0003FC0000001E0001FE0000001C0000FF8000007800003FC00000F000 -001FF80003E0000007FF003F80000001FFFFFE000000003FFFF80000000003FF80000031317CB0 -3A>II70 -D73 D<7FFFFFFFFFFF007FFFFFFFFFFF007FFFFFFFFFFF007FC00FF801FF007E -000FF8003F007C000FF8001F0078000FF8000F0078000FF8000F0070000FF8000700F0000FF800 -0780F0000FF8000780F0000FF8000780E0000FF8000380E0000FF8000380E0000FF8000380E000 -0FF8000380E0000FF800038000000FF800000000000FF800000000000FF800000000000FF80000 -0000000FF800000000000FF800000000000FF800000000000FF800000000000FF800000000000F -F800000000000FF800000000000FF800000000000FF800000000000FF800000000000FF8000000 -00000FF800000000000FF800000000000FF800000000000FF800000000000FF800000000000FF8 -00000000000FF800000000000FF800000000000FF800000000000FF800000000000FF800000000 -000FF800000000000FF8000000007FFFFFFF0000007FFFFFFF0000007FFFFFFF000031307DAF38 ->84 D<00FFF0000003FFFE00000F803F80000FC00FE0001FE007F0001FE007F0001FE003F8000F -C003FC00078003FC00000003FC00000003FC00000003FC00000003FC000000FFFC00001FFFFC00 -00FFE3FC0003FC03FC000FF003FC001FC003FC003FC003FC007F8003FC007F8003FC00FF0003FC -00FF0003FC00FF0003FC00FF0007FC00FF0007FC007F800DFC003FC019FE001FE070FFF007FFE0 -7FF000FF803FF024207E9F27>97 D<01F8000000FFF8000000FFF8000000FFF80000000FF80000 -0007F800000007F800000007F800000007F800000007F800000007F800000007F800000007F800 -000007F800000007F800000007F800000007F800000007F800000007F83FE00007F8FFFC0007FB -E07F0007FF001F8007FE000FC007FC000FE007F80007F007F80007F807F80007F807F80003FC07 -F80003FC07F80003FC07F80003FE07F80003FE07F80003FE07F80003FE07F80003FE07F80003FE -07F80003FE07F80003FE07F80003FC07F80003FC07F80003FC07F80007F807F80007F807F80007 -F007FC000FE007FE000FC007E7003F8007C3C0FE000780FFF80007003FC00027327EB12D>I<00 -0FFF00007FFFC001FC01F003F003F007E007F80FE007F81FC007F83FC003F03FC001E07F800000 -7F8000007F800000FF800000FF800000FF800000FF800000FF800000FF800000FF800000FF8000 -007F8000007F8000007F8000003FC0001C3FC0001C1FC000380FE0003807E0007003F001E001FC -07C0007FFF00000FF8001E207D9F24>I<0000000FC0000007FFC0000007FFC0000007FFC00000 -007FC00000003FC00000003FC00000003FC00000003FC00000003FC00000003FC00000003FC000 -00003FC00000003FC00000003FC00000003FC00000003FC00000003FC00007F83FC0003FFF3FC0 -00FE07BFC003F801FFC007E0007FC00FE0007FC01FC0003FC03FC0003FC03FC0003FC07F80003F -C07F80003FC07F80003FC0FF80003FC0FF80003FC0FF80003FC0FF80003FC0FF80003FC0FF8000 -3FC0FF80003FC0FF80003FC07F80003FC07F80003FC07F80003FC03FC0003FC03FC0003FC01FC0 -003FC00FE0007FC007E000FFC003F003FFE001FC0F3FFE007FFE3FFE000FF03FFE27327DB12D> -I<000FFC00007FFF8001FC0FC003F003E007E001F00FE001F81FC000FC3FC000FE3FC000FE7F80 -007E7F80007F7F80007FFF80007FFF80007FFFFFFFFFFFFFFFFFFF800000FF800000FF800000FF -8000007F8000007F8000007F8000003FC000071FC000071FC0000E0FE0000E07F0001C03F80078 -00FE03E0003FFFC00007FE0020207E9F25>I<0001FE00000FFF80001FC3C0007F07E000FE0FF0 -01FE0FF001FC0FF003FC0FF003FC07E003FC018003FC000003FC000003FC000003FC000003FC00 -0003FC000003FC000003FC0000FFFFFC00FFFFFC00FFFFFC0003FC000003FC000003FC000003FC -000003FC000003FC000003FC000003FC000003FC000003FC000003FC000003FC000003FC000003 -FC000003FC000003FC000003FC000003FC000003FC000003FC000003FC000003FC000003FC0000 -03FC000003FC000003FC00007FFFF0007FFFF0007FFFF0001C327EB119>I<03C00007E0000FF0 -001FF8001FF8001FF8001FF8000FF00007E00003C0000000000000000000000000000000000000 -0000000000000000000001F800FFF800FFF800FFF8000FF80007F80007F80007F80007F80007F8 -0007F80007F80007F80007F80007F80007F80007F80007F80007F80007F80007F80007F80007F8 -0007F80007F80007F80007F80007F80007F800FFFF80FFFF80FFFF8011337DB217>105 -D<01F8000000FFF8000000FFF8000000FFF80000000FF800000007F800000007F800000007F800 -000007F800000007F800000007F800000007F800000007F800000007F800000007F800000007F8 -00000007F800000007F800000007F801FFF807F801FFF807F801FFF807F8003F0007F8003C0007 -F800780007F800F00007F803C00007F807800007F80F000007F81E000007F878000007F8FC0000 -07F9FE000007FBFE000007FFFF000007FE7F800007FC7FC00007F83FC00007F01FE00007F00FF0 -0007F00FF80007F007FC0007F003FC0007F001FE0007F000FF0007F000FF8007F0007F8007F000 -7FC0FFFF81FFFEFFFF81FFFEFFFF81FFFE27327EB12B>107 D<01F800FFF800FFF800FFF8000F -F80007F80007F80007F80007F80007F80007F80007F80007F80007F80007F80007F80007F80007 -F80007F80007F80007F80007F80007F80007F80007F80007F80007F80007F80007F80007F80007 -F80007F80007F80007F80007F80007F80007F80007F80007F80007F80007F80007F80007F80007 -F80007F80007F80007F800FFFFC0FFFFC0FFFFC012327DB117>I<03F007F800FFF03FFE00FFF0 -783F00FFF0C03F800FF1801FC007F3001FC007F6001FE007FC001FE007FC001FE007FC001FE007 -F8001FE007F8001FE007F8001FE007F8001FE007F8001FE007F8001FE007F8001FE007F8001FE0 -07F8001FE007F8001FE007F8001FE007F8001FE007F8001FE007F8001FE007F8001FE007F8001F -E007F8001FE007F8001FE007F8001FE0FFFFC3FFFFFFFFC3FFFFFFFFC3FFFF28207D9F2D>110 -D<0007FC0000007FFFC00001FC07F00003F001F80007E000FC000FC0007E001FC0007F003FC000 -7F803F80003F807F80003FC07F80003FC07F80003FC0FF80003FE0FF80003FE0FF80003FE0FF80 -003FE0FF80003FE0FF80003FE0FF80003FE0FF80003FE07F80003FC07F80003FC07F80003FC03F -C0007F803FC0007F801FC0007F000FE000FE0007E000FC0003F803F80001FE0FF000007FFFC000 -0007FC000023207E9F28>I<03F03F00FFF07FC0FFF1C3E0FFF187E00FF30FF007F60FF007F60F -F007FC07E007FC03C007FC000007FC000007F8000007F8000007F8000007F8000007F8000007F8 -000007F8000007F8000007F8000007F8000007F8000007F8000007F8000007F8000007F8000007 -F8000007F8000007F80000FFFFE000FFFFE000FFFFE0001C207E9F21>114 -D<01FF860007FFFE001F00FE003C003E0078001E0078000E00F8000E00F8000E00F8000E00FC00 -0000FF800000FFFC00007FFFC0007FFFF0003FFFF8001FFFFC0007FFFE0001FFFF00003FFF0000 -00FF8000003F8060001F80E0000F80E0000F80F0000F80F0000F00F8000F00FC001E00FE001C00 -FF807800F3FFF000C07F800019207D9F20>I<001C0000001C0000001C0000001C0000001C0000 -003C0000003C0000003C0000007C0000007C000000FC000001FC000003FC000007FC00001FFFFE -00FFFFFE00FFFFFE0003FC000003FC000003FC000003FC000003FC000003FC000003FC000003FC -000003FC000003FC000003FC000003FC000003FC000003FC000003FC000003FC000003FC038003 -FC038003FC038003FC038003FC038003FC038003FC038001FC038001FC070000FE0700007F0E00 -003FFC000007F000192E7FAD1F>I<01F80007E0FFF803FFE0FFF803FFE0FFF803FFE00FF8003F -E007F8001FE007F8001FE007F8001FE007F8001FE007F8001FE007F8001FE007F8001FE007F800 -1FE007F8001FE007F8001FE007F8001FE007F8001FE007F8001FE007F8001FE007F8001FE007F8 -001FE007F8001FE007F8001FE007F8001FE007F8003FE007F8003FE003F8007FE003F8007FE001 -FC00DFF000FE039FFF007FFF1FFF000FFC1FFF28207D9F2D>I<7FFF807FFC7FFF807FFC7FFF80 -7FFC03FE000F0001FE001E0000FF003C0000FF807800007FC07800003FE0F000001FE1E000000F -F3C000000FFF80000007FF00000003FE00000001FE00000000FF00000000FF80000000FFC00000 -01FFC0000003DFE00000078FF00000078FF800000F07FC00001E03FC00003C01FE00007800FF00 -00F000FF8000E0007FC001E0003FC0FFFC01FFFFFFFC01FFFFFFFC01FFFF28207F9F2B>120 -D E /Fj 18 117 df<387CFEFEFE7C3807077D860D>46 D<03F0000FFC001F3E003E1F003C0F00 -7C0F807C0F807C0F80FC0FC0FC0FC0FC0FC0FC0FC0FC0FC0FC0FC0FC0FC0FC0FC0FC0FC0FC0FC0 -FC0FC0FC0FC0FC0FC07C0F807C0F807C0F803C0F003E1F001F3E000FFC0003F000121D7E9C17> -48 D<00E001E00FE0FFE0F3E003E003E003E003E003E003E003E003E003E003E003E003E003E0 -03E003E003E003E003E003E003E003E003E07FFF7FFF101D7D9C17>I<07F0001FFC00387E007C -3F00FE1F80FE1F80FE1FC0FE0FC07C0FC0380FC0001FC0001F80001F80003F00003E00007C0000 -780000E00001C0000380000700C00600C00C00C01801C03FFF803FFF807FFF80FFFF80FFFF8012 -1D7E9C17>I<07F0000FFC001C3E003C3F007E1F807E1F807E1F807E1F803C3F00003F00003E00 -007C0003F80003F000003C00003F00001F80001F80001FC0381FC07C1FC0FE1FC0FE1FC0FE1F80 -FC1F80783F00383E001FFC0007F000121D7E9C17>I<000700000F00000F00001F00003F00003F -00006F0000EF0001CF00018F00038F00070F00060F000C0F001C0F00380F00300F00700F00E00F -00FFFFF0FFFFF0001F00001F00001F00001F00001F00001F0001FFF001FFF0141D7F9C17>I<38 -03003FFF003FFE003FFC003FF8003FE0003F000030000030000030000030000033F00037FC003C -1E00380F00100F80000F80000FC0000FC0780FC0FC0FC0FC0FC0FC0FC0FC0F80780F80601F0038 -3E001FFC0007E000121D7E9C17>I<00FC0003FE000783000F0F801E1F803E1F803C1F807C1F80 -7C0F007C0000FC0000FDFC00FFFE00FE0F00FE0F80FC0F80FC0FC0FC0FC0FC0FC0FC0FC0FC0FC0 -7C0FC07C0FC07C0F803C0F803E0F001E1E000FFC0003F000121D7E9C17>I<6000007FFFC07FFF -C07FFF807FFF007FFE00E00600C00C00C01800C0180000300000600000E00000E00001E00001C0 -0003C00003C00003C00007C00007C00007C0000FC0000FC0000FC0000FC0000FC0000FC0000780 -00030000121E7D9D17>I<03F0000FFC001E1E00380F003807807807807807807C07807E07807F -0F003FCE003FFC001FF8000FFE000FFF001FFF003C7F80783FC0700FC0F007C0F003C0F003C0F0 -03C0F003807803807807003E0E001FFC0007F000121D7E9C17>I<03F0000FFC001E1E003C1F00 -7C0F007C0F80FC0F80FC0F80FC0FC0FC0FC0FC0FC0FC0FC0FC0FC07C0FC07C1FC03C1FC01FFFC0 -0FEFC0000FC0000F803C0F807E0F807E0F007E1F007E1E007C3C003878001FF0000FC000121D7E -9C17>I<07F0001FFC003F1E003F1F003F0F803F0F800C0F80000F8000FF800FFF801F0F807C0F -807C0F80F80F80F80F80F80F80F817807C37803FE3F00F81F014147F9316>97 -DI<03F00FFC1E7E3E7E7C7E7C7EFC -18FC00FC00FC00FC00FC00FC00FC007C007E033E031F0E0FFC03F010147E9314>I<1C003E007F -007F007F003E001C00000000000000000000000000FF00FF001F001F001F001F001F001F001F00 -1F001F001F001F001F001F001F001F001F00FFE0FFE00B217FA00C>105 -D109 -D112 D<0300030003000300070007000F000F003F00FFF8 -FFF81F001F001F001F001F001F001F001F001F001F001F181F181F181F181F180F3007F003E00D -1D7F9C12>116 D E /Fk 34 122 df46 D<01800780FF80FF800F800F -800F800F800F800F800F800F800F800F800F800F800F800F800F800F800F807FE07FE00B177D96 -12>49 D<1F803FC07FE0F1F0F0F860F820F800F800F800F001F001E003C0078007000E001E001C -0038007000FFF8FFF87FF80D177E9612>I<1F803FC07FE0F1F061F041F001F001F001E003C00F -800FC001E000F000F800F800F880F8C0F8E1F07FF03FE01F800D177E9612>I<3FF83FF83FF83E -003E003E003E003E003E003FE03FF03C783878007C007C007C007C407C607CF0F87FF03FE00FC0 -0E177F9612>53 D58 -D<01FC0001FC0003FE0003FE0003DE0007DF0007DF00079F00078F000F8F800F8F800F0F801F07 -C01F07C01F07C03FFFE03FFFE03FFFE07C03F07C01F07C01F0F801F8F800F815177F9618>65 -D<7FF800FFFE00FFFF00F81F00F80F80F80F80F80F80F80F80F80F80F81F00FFFE00FFFE00F81F -80F80F80F807C0F807C0F807C0F807C0F807C0F81F80FFFF80FFFF007FFC0012177D9618>I<01 -FF0007FFC00FFFC01F83C03E00807C00007C0000F80000F80000F80000F80000F80000F80000F8 -0000F80000F800007C00007C00403E00C01F81C00FFFC007FF8001FE0012177E9617>I<7FF800 -FFFF00FFFF80F81FC0F807C0F803E0F803E0F801F0F801F0F801F0F801F0F801F0F801F0F801F0 -F801F0F801F0F803E0F803E0F807E0F80FC0FFFF80FFFF007FF80014177D961A>I<7FFCFFFCFF -FCF800F800F800F800F800F800F800FFF8FFF8FFF8F800F800F800F800F800F800F800F800F800 -78000E177D9614>70 D<78F8F8F8F8F8F8F8F8F8F8F8F8F8F8F8F8F8F8F8F8F87805177D960B> -73 D<7FF800FFFE00FFFF00F81F00F80F80F80F80F80F80F80F80F80F80F81F00FFFE00FFF800 -F8F800F8F800F87C00F87C00F83E00F83E00F81F00F81F00F80F80F80F807807C012177D9617> -82 D<7FFFF8FFFFF8FFFFF800F80000F80000F80000F80000F80000F80000F80000F80000F800 -00F80000F80000F80000F80000F80000F80000F80000F80000F80000F80000780015177F9618> -84 D<0FC03FF030F820F800F800F81FF83EF878F8F8F8F8F8F8F879F87FF81EF80D0F7F8E11> -97 D<7800F800F800F800F800F800F800F800FBE0FFF8F87CF83CF83EF83EF83EF83EF83EF83E -F83EF83CF878FFF07BE00F177E9613>I<0FE01FF83C387808F800F800F800F800F800F800F800 -78083C381FF80FE00D0F7F8E10>I<003E003E003E003E003E003E003E003E0FBE1FFE3C3E783E -F83EF83EF83EF83EF83EF83EF83E783E7C3E3FFE0FBE0F177F9613>I<0FC01FF03C787878F83C -F83CFFFCFFFCF800F800780078043C1C1FFC07F00E0F7F8E11>I<03F00FF00F101F001F001F00 -1F001F007F80FF801F001F001F001F001F001F001F001F001F001F001F001F000F000C1780960B ->I<1FCE3FFE78F0F8F8F8F8F8F8F8F878F03FE07FC0600060007FF07FF83FFC7FFEE00EE00EE0 -0E701C3FF81FF00F167F8E12>I<7800F800F800F800F800F800F800F800F9F0FBF8FE7CFC7CF8 -7CF87CF87CF87CF87CF87CF87CF87CF87CF87C787C0E177E9613>II<7000F000F000F000F000F000F000F000F078F0 -F8F3E0F7C0FF80FF00FF00FF80FFC0F3E0F1E0F0F0F0F8F07C703C0E177E9612>107 -D<79F0FBF8FE7CFC7CF87CF87CF87CF87CF87CF87CF87CF87CF87CF87C787C0E0F7E8E13>110 -D<0FE03FF87C7C783CF83EF83EF83EF83EF83EF83EF83E783C7C7C3FF80FE00F0F7F8E12>I<7B -E0FFF8F87CF87CF83EF83EF83EF83EF83EF83EF83EF87CF878FFF0FBE0F800F800F800F800F800 -78000F157E8E13>I<7BFFFFFCF8F8F8F8F8F8F8F8F8F878080F7E8E0C>114 -D<1F007FC0E0C0E040E000FE00FF807FC03FE007E0C0E0C0E0F0E07FC01F000B0F7F8E0E>I<1E -003E003E003E003E007F80FF803E003E003E003E003E003E003E003E003E003E003E403FC01F00 -0A147F930D>I<787CF87CF87CF87CF87CF87CF87CF87CF87CF87CF87CF87CF8FC7FFC3E7C0E0F -7E8E13>II -120 DI E /Fl 14 117 df<70F8F8F0E005057B840E>46 -D<000F800030E000E07001C0700380300380380700380F00780F00780E00781E00781E00703C00 -F03C00F03C00F03C00F07801E07801E07801E07801C07003C0F003C0F00380F00780F007007007 -00700E00701C003038001870000FC000151F7C9D17>48 D<000200020006000E003C00DC031C00 -1C0038003800380038007000700070007000E000E000E000E001C001C001C001C0038003800380 -03800780FFF80F1E7B9D17>I<00C06000FFC001FF8001FE000100000100000200000200000200 -00020000040000047800058C000606000C0700080700000780000780000780000780000F00700F -00F00F00F00E00E01E00801C0080380080300040600061C0001F0000131F7B9D17>53 -D<001F0000718000C0C00180C00380E00700E00F00E00F01E01E01E01E01E01E01E01E01C01C03 -C01C03C01C03C01C07C01C0F800C0F8006378003C700000F00000E00000E00001C00601C00F038 -00F07000E0600080C0004380003E0000131F7B9D17>57 D<01FFFFC0001E00F0001E0078001E00 -38001E003C003C003C003C003C003C003C003C003C0078007800780078007800F0007801E000F0 -078000FFFE0000F00F8000F003C001E001C001E001E001E001E001E001E003C001E003C001E003 -C001E003C001C0078003C00780078007800F0007801E000F007800FFFFE0001E1F7D9E20>66 -D<01FFFF80001E00E0001E0070001E0038001E001C003C001C003C000E003C000E003C000E0078 -000E0078000E0078000E0078000E00F0001E00F0001E00F0001E00F0001E01E0003C01E0003C01 -E0003C01E0007803C0007003C0007003C000E003C001C0078001C00780038007800E0007801C00 -0F007000FFFFC0001F1F7D9E22>68 D<01FFFFFC001E0038001E0018001E0008001E0008003C00 -08003C0008003C0008003C00080078001000780800007808000078080000F0100000F0300000FF -F00000F0300001E0200001E0200001E0200001E0200003C0000003C0000003C0000003C0000007 -8000000780000007800000078000000F800000FFF800001E1F7D9E1E>70 -D<00F1800389C00707800E03801C03803C0380380700780700780700780700F00E00F00E00F00E -00F00E20F01C40F01C40703C40705C40308C800F070013147C9317>97 D<007E0001C100030080 -0E07801E07801C07003C0200780000780000780000F00000F00000F00000F00000F00000700100 -70020030040018380007C00011147C9315>99 D<00C001E001E001C00000000000000000000000 -0000000E003300230043804300470087000E000E000E001C001C001C0038403880308070803100 -33001C000B1F7C9E0E>105 D<1C0F80F0002630C318004740640C004780680E004700700E0047 -00700E008E00E01C000E00E01C000E00E01C000E00E01C001C01C038001C01C038001C01C03800 -1C01C0708038038071003803806100380380E10038038062007007006600300300380021147C93 -25>109 D<01C1E002621804741C04781C04701E04701E08E01E00E01E00E01E00E01E01C03C01 -C03C01C03C01C0380380780380700380E003C1C0072380071E000700000700000E00000E00000E -00000E00001C00001C0000FFC000171D809317>112 D<018001C0038003800380038007000700 -FFF007000E000E000E000E001C001C001C001C003800380038003820704070407080708031001E -000C1C7C9B0F>116 D E /Fm 81 125 df<001F83E000F06E3001C078780380F8780300F03007 -007000070070000700700007007000070070000700700007007000FFFFFF800700700007007000 -070070000700700007007000070070000700700007007000070070000700700007007000070070 -000700700007007000070070000700700007007000070070007FE3FF001D20809F1B>11 -D<003F0000E0C001C0C00381E00701E00701E0070000070000070000070000070000070000FFFF -E00700E00700E00700E00700E00700E00700E00700E00700E00700E00700E00700E00700E00700 -E00700E00700E00700E00700E00700E07FC3FE1720809F19>I<003FE000E0E001C1E00381E007 -00E00700E00700E00700E00700E00700E00700E00700E0FFFFE00700E00700E00700E00700E007 -00E00700E00700E00700E00700E00700E00700E00700E00700E00700E00700E00700E00700E007 -00E07FE7FE1720809F19>I<001F81F80000F04F040001C07C06000380F80F000300F00F000700 -F00F00070070000007007000000700700000070070000007007000000700700000FFFFFFFF0007 -007007000700700700070070070007007007000700700700070070070007007007000700700700 -070070070007007007000700700700070070070007007007000700700700070070070007007007 -00070070070007007007007FE3FE3FF02420809F26>I<70F8F8F8F8F8F8F87070707070707070 -70702020202020000000000070F8F8F87005217CA00D>33 D<0078000000840000018400000302 -000007020000070200000702000007020000070400000704000007080000070800000310000003 -A00FFC03C003E0038001C001C0008001C0010003E0010004E0020008F002001870040030780800 -70380800701C1000F01E1000F00E2000F0074000F003C0087003C0087801C010380670301C1838 -6007E00F801E227EA023>38 D<70F8FCFC74040404080810102040060E7C9F0D>I<0020004000 -800100020006000C000C00180018003000300030007000600060006000E000E000E000E000E000 -E000E000E000E000E000E000E0006000600060007000300030003000180018000C000C00060002 -0001000080004000200B2E7DA112>I<800040002000100008000C000600060003000300018001 -80018001C000C000C000C000E000E000E000E000E000E000E000E000E000E000E000E000C000C0 -00C001C001800180018003000300060006000C00080010002000400080000B2E7DA112>I<0180 -0180018001800180C183F18F399C0FF003C003C00FF0399CF18FC1830180018001800180018010 -147DA117>I<70F8FCFC74040404080810102040060E7C840D>44 DI<70 -F8F8F87005057C840D>I<03F0000E1C001C0E00180600380700700380700380700380700380F0 -03C0F003C0F003C0F003C0F003C0F003C0F003C0F003C0F003C0F003C0F003C0F003C0F003C070 -03807003807003807807803807001806001C0E000E1C0003F000121F7E9D17>48 -D<018003800F80F380038003800380038003800380038003800380038003800380038003800380 -03800380038003800380038003800380038007C0FFFE0F1E7C9D17>I<03F0000C1C00100E0020 -0700400780800780F007C0F803C0F803C0F803C02007C00007C0000780000780000F00000E0000 -1C0000380000700000600000C0000180000300000600400C00401800401000803FFF807FFF80FF -FF80121E7E9D17>I<03F0000C1C00100E00200F00780F80780780780780380F80000F80000F00 -000F00000E00001C0000380003F000003C00000E00000F000007800007800007C02007C0F807C0 -F807C0F807C0F00780400780400F00200E001C3C0003F000121F7E9D17>I<000600000600000E -00000E00001E00002E00002E00004E00008E00008E00010E00020E00020E00040E00080E00080E -00100E00200E00200E00400E00C00E00FFFFF0000E00000E00000E00000E00000E00000E00000E -0000FFE0141E7F9D17>I<1803001FFE001FFC001FF8001FE00010000010000010000010000010 -000010000011F000161C00180E001007001007800003800003800003C00003C00003C07003C0F0 -03C0F003C0E00380400380400700200600100E000C380003E000121F7E9D17>I<007C00018200 -0701000E03800C07801C0780380300380000780000700000700000F1F000F21C00F40600F80700 -F80380F80380F003C0F003C0F003C0F003C0F003C07003C07003C0700380380380380700180700 -0C0E00061C0001F000121F7E9D17>I<4000007FFFC07FFF807FFF804001008002008002008004 -0000080000080000100000200000200000400000400000C00000C00001C0000180000380000380 -00038000038000078000078000078000078000078000078000078000030000121F7D9D17>I<03 -F0000C0C001006003003002001806001806001806001807001807803003E03003F06001FC8000F -F00003F80007FC000C7E00103F00300F806003804001C0C001C0C000C0C000C0C000C0C0008060 -01802001001002000C0C0003F000121F7E9D17>I<03F0000E18001C0C00380600380700700700 -700380F00380F00380F003C0F003C0F003C0F003C0F003C07007C07007C03807C0180BC00E13C0 -03E3C0000380000380000380000700300700780600780E00700C002018001070000FC000121F7E -9D17>I<70F8F8F8700000000000000000000070F8F8F87005147C930D>I<70F8F8F87000000000 -00000000000070F0F8F878080808101010202040051D7C930D>I<0FC0307040384038E03CF03C -F03C603C0038007000E000C0018001800100030002000200020002000200020000000000000000 -00000007000F800F800F8007000E207D9F15>63 D<001F800000E0700001000800060006000800 -010008000100100F00802030C0402060404040C0202041C01C2041C01C2081801C1083801C1083 -801C1083801C1083801C1083801C1083801C1081801C1041C01C1041C01C1040C03C2020605C20 -2030CC40100F0780080000000800000006000070010001C000E01F00001FF0001C207D9F23>I< -000100000003800000038000000380000007C0000007C0000007C0000009E0000009E0000009E0 -000010F0000010F0000010F00000207800002078000020780000403C0000403C0000403C000080 -1E0000801E0000FFFE0001000F0001000F0001000F00020007800200078002000780040003C00E -0003C01F0007E0FFC03FFE1F207F9F22>II<000FC040007030 -C001C009C0038005C0070003C00E0001C01E0000C01C0000C03C0000C07C0000407C0000407800 -0040F8000000F8000000F8000000F8000000F8000000F8000000F8000000F8000000F800000078 -0000007C0000407C0000403C0000401C0000401E0000800E000080070001000380020001C00400 -00703800000FC0001A217D9F21>IIII<000FE0200078186000E004E0038002E0070001E00F -0000E01E0000601E0000603C0000603C0000207C00002078000020F8000000F8000000F8000000 -F8000000F8000000F8000000F8000000F8007FFCF80003E0780001E07C0001E03C0001E03C0001 -E01E0001E01E0001E00F0001E0070001E0038002E000E0046000781820000FE0001E217D9F24> -III<0FFFC0007C00003C00003C00003C00003C00003C00003C00003C00003C00003C00 -003C00003C00003C00003C00003C00003C00003C00003C00003C00003C00003C00003C00203C00 -F83C00F83C00F83C00F0380040780040700030E0000F800012207E9E17>IIIII<001F800000F0F00001C0380007801E000F000F000E0007001E0007803C00 -03C03C0003C07C0003E0780001E0780001E0F80001F0F80001F0F80001F0F80001F0F80001F0F8 -0001F0F80001F0F80001F0F80001F0780001E07C0003E07C0003E03C0003C03C0003C01E000780 -0E0007000F000F0007801E0001C0380000F0F000001F80001C217D9F23>II82 D<07E0800C19801007803003806001 -80600180E00180E00080E00080E00080F00000F000007800007F00003FF0001FFC000FFE0003FF -00001F800007800003C00003C00001C08001C08001C08001C08001C0C00180C00380E00300F006 -00CE0C0081F80012217D9F19>I<7FFFFFE0780F01E0600F0060400F0020400F0020C00F003080 -0F0010800F0010800F0010800F0010000F0000000F0000000F0000000F0000000F0000000F0000 -000F0000000F0000000F0000000F0000000F0000000F0000000F0000000F0000000F0000000F00 -00000F0000000F0000000F0000001F800007FFFE001C1F7E9E21>IIII<7FF83FF80FE00FC007C0 -070003C0020001E0040001F00C0000F0080000781000007C1000003C2000003E4000001E400000 -0F8000000F8000000780000003C0000007E0000005E0000009F0000018F8000010780000207C00 -00603C0000401E0000801F0001800F0001000780020007C0070003C01F8007E0FFE01FFE1F1F7F -9E22>II<7FFFF87C00F87000F06001E04001E0C003C0C003C0 -800780800F80800F00001E00001E00003C00003C0000780000F80000F00001E00001E00003C004 -03C0040780040F80040F000C1E000C1E00083C00183C0018780038F801F8FFFFF8161F7D9E1C> -II93 D<1FE000303000781800781C -00300E00000E00000E00000E0000FE00078E001E0E00380E00780E00F00E10F00E10F00E10F01E -10781E103867200F83C014147E9317>97 D<0E0000FE00000E00000E00000E00000E00000E0000 -0E00000E00000E00000E00000E00000E3E000EC3800F01C00F00E00E00E00E00700E00700E0078 -0E00780E00780E00780E00780E00780E00700E00700E00E00F00E00D01C00CC300083E0015207F -9F19>I<03F80E0C1C1E381E380C70007000F000F000F000F000F000F00070007000380138011C -020E0C03F010147E9314>I<000380003F80000380000380000380000380000380000380000380 -00038000038000038003E380061B801C0780380380380380700380700380F00380F00380F00380 -F00380F00380F003807003807003803803803807801C07800E1B8003E3F815207E9F19>I<03F0 -000E1C001C0E00380700380700700700700380F00380F00380FFFF80F00000F00000F000007000 -007000003800801800800C010007060001F80011147F9314>I<007C00C6018F038F0706070007 -0007000700070007000700FFF00700070007000700070007000700070007000700070007000700 -070007000700070007007FF01020809F0E>I<0000E003E3300E3C301C1C30380E00780F00780F -00780F00780F00780F00380E001C1C001E380033E0002000002000003000003000003FFE001FFF -800FFFC03001E0600070C00030C00030C00030C000306000603000C01C038003FC00141F7F9417 ->I<0E0000FE00000E00000E00000E00000E00000E00000E00000E00000E00000E00000E00000E -3E000E43000E81800F01C00F01C00E01C00E01C00E01C00E01C00E01C00E01C00E01C00E01C00E -01C00E01C00E01C00E01C00E01C00E01C0FFE7FC16207F9F19>I<1C001E003E001E001C000000 -000000000000000000000E007E000E000E000E000E000E000E000E000E000E000E000E000E000E -000E000E000E000E00FFC00A1F809E0C>I<00E001F001F001F000E00000000000000000000000 -00007007F000F00070007000700070007000700070007000700070007000700070007000700070 -007000700070007000706070F060F0C061803F000C28829E0E>I<0E0000FE00000E00000E0000 -0E00000E00000E00000E00000E00000E00000E00000E00000E0FF00E03C00E03000E02000E0400 -0E08000E10000E30000E70000EF8000F38000E1C000E1E000E0E000E07000E07800E03800E03C0 -0E03E0FFCFF815207F9F18>I<0E00FE000E000E000E000E000E000E000E000E000E000E000E00 -0E000E000E000E000E000E000E000E000E000E000E000E000E000E000E000E000E000E00FFE00B -20809F0C>I<0E1F01F000FE618618000E81C81C000F00F00E000F00F00E000E00E00E000E00E0 -0E000E00E00E000E00E00E000E00E00E000E00E00E000E00E00E000E00E00E000E00E00E000E00 -E00E000E00E00E000E00E00E000E00E00E000E00E00E00FFE7FE7FE023147F9326>I<0E3E00FE -43000E81800F01C00F01C00E01C00E01C00E01C00E01C00E01C00E01C00E01C00E01C00E01C00E -01C00E01C00E01C00E01C00E01C0FFE7FC16147F9319>I<01F800070E001C03803801C03801C0 -7000E07000E0F000F0F000F0F000F0F000F0F000F0F000F07000E07000E03801C03801C01C0380 -070E0001F80014147F9317>I<0E3E00FEC3800F01C00F00E00E00E00E00F00E00700E00780E00 -780E00780E00780E00780E00780E00700E00F00E00E00F01E00F01C00EC3000E3E000E00000E00 -000E00000E00000E00000E00000E00000E0000FFE000151D7F9319>I<03E0800619801C05803C -0780380380780380700380F00380F00380F00380F00380F00380F0038070038078038038038038 -07801C0B800E138003E380000380000380000380000380000380000380000380000380003FF815 -1D7E9318>I<0E78FE8C0F1E0F1E0F0C0E000E000E000E000E000E000E000E000E000E000E000E -000E000E00FFE00F147F9312>I<1F9030704030C010C010C010E00078007F803FE00FF0007080 -3880188018C018C018E030D0608F800D147E9312>I<020002000200060006000E000E003E00FF -F80E000E000E000E000E000E000E000E000E000E000E000E080E080E080E080E080610031001E0 -0D1C7F9B12>I<0E01C0FE1FC00E01C00E01C00E01C00E01C00E01C00E01C00E01C00E01C00E01 -C00E01C00E01C00E01C00E01C00E01C00E03C00603C0030DC001F1FC16147F9319>III<7FC3FC0F01E0 -0701C007018003810001C20000E40000EC00007800003800003C00007C00004E00008700010700 -0303800201C00601E01E01E0FF07FE1714809318>II<3F -FF380E200E201C40384078407000E001E001C00380078007010E011E011C0338027006700EFFFE -10147F9314>I124 D E /Fn 53 122 df<0001FF01FE00001FFFCF -FF00007F01FF0F8000FC03FE1FC001F807FC1FC003F807FC1FC007F007F81FC007F007F80F8007 -F003F8000007F003F8000007F003F8000007F003F8000007F003F8000007F003F8000007F003F8 -0000FFFFFFFFF000FFFFFFFFF000FFFFFFFFF00007F003F8000007F003F8000007F003F8000007 -F003F8000007F003F8000007F003F8000007F003F8000007F003F8000007F003F8000007F003F8 -000007F003F8000007F003F8000007F003F8000007F003F8000007F003F8000007F003F8000007 -F003F8000007F003F8000007F003F8000007F003F8000007F003F800007FFF3FFFC0007FFF3FFF -C0007FFF3FFFC0002A2A7FA927>11 D<0001FF0000001FFFC000007F81E00000FC01E00001F807 -F00003F807F00007F007F00007F007F00007F007F00007F007F00007F001C00007F000000007F0 -00000007F000000007F03FF800FFFFFFF800FFFFFFF800FFFFFFF80007F003F80007F003F80007 -F003F80007F003F80007F003F80007F003F80007F003F80007F003F80007F003F80007F003F800 -07F003F80007F003F80007F003F80007F003F80007F003F80007F003F80007F003F80007F003F8 -0007F003F80007F003F80007F003F8007FFF3FFF807FFF3FFF807FFF3FFF80212A7FA925>I<3C -007F00FF80FF80FFC0FFC0FFC07FC03EC000C000C00180018001800300030006000E001C003800 -30000A157BA913>39 D<1C007F007F00FF80FF80FF807F007F001C0009097B8813>46 -D<003F800001FFF00007E0FC000FC07E001F803F001F001F003F001F803E000F807E000FC07E00 -0FC07E000FC07E000FC0FE000FE0FE000FE0FE000FE0FE000FE0FE000FE0FE000FE0FE000FE0FE -000FE0FE000FE0FE000FE0FE000FE0FE000FE0FE000FE0FE000FE0FE000FE07E000FC07E000FC0 -7E000FC07E000FC03F001F803F001F801F001F001F803F000FC07E0007E0FC0001FFF000003F80 -001B277DA622>48 D<000E00001E00007E0007FE00FFFE00FFFE00F8FE0000FE0000FE0000FE00 -00FE0000FE0000FE0000FE0000FE0000FE0000FE0000FE0000FE0000FE0000FE0000FE0000FE00 -00FE0000FE0000FE0000FE0000FE0000FE0000FE0000FE0000FE0000FE0000FE0000FE0000FE00 -7FFFFE7FFFFE7FFFFE17277BA622>I<00FF800007FFF0000FFFFC001E03FE003800FF807C003F -80FE003FC0FF001FC0FF001FE0FF000FE0FF000FE07E000FE03C001FE000001FE000001FC00000 -1FC000003F8000003F0000007E000000FC000000F8000001F0000003E00000078000000F000000 -1E0000003C00E0007000E000E000E001C001C0038001C0060001C00FFFFFC01FFFFFC03FFFFFC0 -7FFFFFC0FFFFFF80FFFFFF80FFFFFF801B277DA622>I<007F800003FFF00007FFFC000F80FE00 -1F007F003F807F003F803F803F803F803F803F801F803F801F003F8000007F0000007F0000007E -000000FC000001F8000007F00000FFC00000FFC0000001F80000007E0000003F0000003F800000 -1FC000001FC000001FE000001FE03C001FE07E001FE0FF001FE0FF001FE0FF001FC0FF003FC0FE -003F807C007F003F00FE001FFFFC0007FFF00000FF80001B277DA622>I<00000E0000001E0000 -003E0000007E000000FE000000FE000001FE000003FE0000077E00000E7E00000E7E00001C7E00 -00387E0000707E0000E07E0000E07E0001C07E0003807E0007007E000E007E000E007E001C007E -0038007E0070007E00E0007E00FFFFFFF8FFFFFFF8FFFFFFF80000FE000000FE000000FE000000 -FE000000FE000000FE000000FE000000FE00007FFFF8007FFFF8007FFFF81D277EA622>I<1800 -03001F801F001FFFFE001FFFFC001FFFF8001FFFF0001FFFC0001FFF00001C0000001C0000001C -0000001C0000001C0000001C0000001C0000001C7FC0001DFFF8001F80FC001E003F0008003F00 -00001F8000001FC000001FC000001FE000001FE018001FE07C001FE0FE001FE0FE001FE0FE001F -E0FE001FC0FC001FC078003F8078003F803C007F001F01FE000FFFFC0003FFF00000FF80001B27 -7DA622>I<0007F800003FFE0000FFFF0001FC078003F00FC007C01FC00F801FC01F801FC01F00 -1FC03F000F803F0000007E0000007E0000007E000000FE020000FE1FF000FE3FFC00FE603E00FE -801F00FF801F80FF000FC0FF000FC0FE000FE0FE000FE0FE000FE0FE000FE07E000FE07E000FE0 -7E000FE07E000FE03E000FE03F000FC01F000FC01F001F800F801F0007E07E0003FFFC0001FFF8 -00003FC0001B277DA622>I<380000003E0000003FFFFFF03FFFFFF03FFFFFF07FFFFFE07FFFFF -C07FFFFF807FFFFF0070000E0070000E0070001C00E0003800E0007000E000E0000001E0000001 -C000000380000007800000070000000F0000001F0000001E0000003E0000003E0000007E000000 -7C0000007C000000FC000000FC000000FC000000FC000001FC000001FC000001FC000001FC0000 -01FC000001FC000001FC000000F80000007000001C297CA822>I<003FC00001FFF00003FFFC00 -07C07E000F003F001E001F001E000F803E000F803E000F803F000F803F800F803FC00F803FF01F -001FFC1E001FFE3C000FFFF8000FFFE00007FFF80001FFFC0001FFFE0007FFFF000F0FFF801E03 -FFC03E01FFC07C007FE07C001FE0F8000FE0F80007E0F80003E0F80003E0F80003E0F80003C07C -0003C07E0007803F000F001FC03F000FFFFC0003FFF800007FC0001B277DA622>I<007F800001 -FFF00007FFF8000FC0FC001F803E003F001F007E001F807E001F807E000F80FE000FC0FE000FC0 -FE000FC0FE000FE0FE000FE0FE000FE0FE000FE0FE000FE07E001FE07E001FE03F003FE01F002F -E00F80CFE007FF8FE001FF0FE000080FE000000FC000000FC000000FC000001F803E001F807F00 -1F807F003F007F003E007F007E007E00FC003E03F8001FFFE0000FFF800001FE00001B277DA622 ->I<00000780000000000780000000000FC0000000000FC0000000000FC0000000001FE0000000 -001FE0000000003FF0000000003FF0000000003FF00000000077F80000000077F800000000F7FC -00000000E3FC00000000E3FC00000001C1FE00000001C1FE00000003C1FF0000000380FF000000 -0380FF00000007007F80000007007F8000000F007FC000000E003FC000000E003FC000001C001F -E000001C001FE000003FFFFFF000003FFFFFF000003FFFFFF00000700007F80000700007F80000 -F00007FC0000E00003FC0000E00003FC0001C00001FE0001C00001FE0003C00001FF00FFFE003F -FFFCFFFE003FFFFCFFFE003FFFFC2E297EA833>65 DI< -00007FE0030007FFFC07001FFFFF0F007FF00F9F00FF0001FF01FC0000FF03F800007F07F00000 -3F0FE000001F1FC000001F1FC000000F3F8000000F3F800000077F800000077F800000077F0000 -0000FF00000000FF00000000FF00000000FF00000000FF00000000FF00000000FF00000000FF00 -000000FF000000007F000000007F800000007F800000073F800000073F800000071FC00000071F -C000000E0FE000000E07F000001C03F800003C01FC00007800FF0001F0007FF007C0001FFFFF80 -0007FFFE0000007FF00028297CA831>II70 D<00007FE003000007FFFC0700001FFFFF0F00007FF00F9F00 -00FF0001FF0001FC0000FF0003F800007F0007F000003F000FE000001F001FC000001F001FC000 -000F003F8000000F003F80000007007F80000007007F80000007007F0000000000FF0000000000 -FF0000000000FF0000000000FF0000000000FF0000000000FF0000000000FF0000000000FF0000 -000000FF0000FFFFF87F0000FFFFF87F8000FFFFF87F800000FF003F800000FF003F800000FF00 -1FC00000FF001FC00000FF000FE00000FF0007F00000FF0003F80000FF0001FC0000FF0000FF00 -01FF00007FF007FF00001FFFFF9F000007FFFE0F0000007FF003002D297CA835>III77 D<0000FFC00000000FFFFC0000003F807F000000FE001FC00001F800 -07E00003F00003F00007E00001F8000FE00001FC001FC00000FE001FC00000FE003F8000007F00 -3F8000007F007F8000007F807F0000003F807F0000003F807F0000003F80FF0000003FC0FF0000 -003FC0FF0000003FC0FF0000003FC0FF0000003FC0FF0000003FC0FF0000003FC0FF0000003FC0 -FF0000003FC0FF0000003FC07F0000003F807F8000007F807F8000007F803F8000007F003F8000 -007F001FC00000FE001FC00000FE000FE00001FC0007F00003F80003F80007F00001FC000FE000 -00FE001FC000003FC0FF0000000FFFFC00000000FFC000002A297CA833>79 -D82 D<00FF00C003FFE1C00FFFF9C01F80FFC03F00 -3FC03E000FC07C0007C07C0007C0FC0003C0FC0003C0FC0001C0FE0001C0FE0001C0FF000000FF -C000007FFC00007FFFE0003FFFF8001FFFFE001FFFFF0007FFFF8003FFFFC000FFFFC0000FFFE0 -00007FE000001FF000000FF0000007F0E00003F0E00003F0E00003F0E00003F0F00003E0F00003 -E0F80007E0FC0007C0FF000F80FFE01F80E3FFFF00E1FFFC00C01FF0001C297CA825>I<7FFFFF -FFFF807FFFFFFFFF807FFFFFFFFF807F807F807F807C007F800F8078007F80078078007F800780 -70007F800380F0007F8003C0F0007F8003C0E0007F8001C0E0007F8001C0E0007F8001C0E0007F -8001C0E0007F8001C000007F80000000007F80000000007F80000000007F80000000007F800000 -00007F80000000007F80000000007F80000000007F80000000007F80000000007F80000000007F -80000000007F80000000007F80000000007F80000000007F80000000007F80000000007F800000 -00007F80000000007F80000000007F80000000007F80000000FFFFFFC00000FFFFFFC00000FFFF -FFC0002A287EA72F>IIII<03FF80000F -FFF0001F01FC003F80FE003F807F003F803F003F803F801F003F8000003F8000003F8000003F80 -00003F80003FFF8001FC3F800FE03F801F803F803F003F807E003F80FC003F80FC003F80FC003F -80FC003F80FC005F807E00DF803F839FFC1FFE0FFC03F803FC1E1B7E9A21>97 -DI<003FF00001FFFC0003F03E000FC07F001F807F -003F007F003F007F007F003E007E0000007E000000FE000000FE000000FE000000FE000000FE00 -0000FE000000FE0000007E0000007E0000007F0000003F0003803F8003801F8007000FE00E0003 -F83C0001FFF800003FC000191B7E9A1E>I<00007FF000007FF000007FF0000007F0000007F000 -0007F0000007F0000007F0000007F0000007F0000007F0000007F0000007F0000007F0000007F0 -003F87F001FFF7F007F03FF00FC00FF01F8007F03F0007F03F0007F07E0007F07E0007F07E0007 -F0FE0007F0FE0007F0FE0007F0FE0007F0FE0007F0FE0007F0FE0007F0FE0007F07E0007F07E00 -07F03F0007F03F0007F01F800FF00FC01FF007E07FFF01FFE7FF007F87FF202A7EA925>I<003F -C00001FFF00003E07C000F803E001F801F001F001F003F000F807E000F807E000FC07E000FC0FE -0007C0FE0007C0FFFFFFC0FFFFFFC0FE000000FE000000FE0000007E0000007E0000007F000000 -3F0001C01F0001C00F80038007C0070003F01E0000FFFC00003FE0001A1B7E9A1F>I<0007F800 -3FFC007E3E01FC7F03F87F03F07F07F07F07F03E07F00007F00007F00007F00007F00007F00007 -F000FFFFC0FFFFC0FFFFC007F00007F00007F00007F00007F00007F00007F00007F00007F00007 -F00007F00007F00007F00007F00007F00007F00007F00007F00007F00007F00007F0007FFF807F -FF807FFF80182A7EA915>I<007F80F001FFE3F807C0FE1C0F807C7C1F003E7C1F003E103F003F -003F003F003F003F003F003F003F003F003F003F001F003E001F003E000F807C0007C0F80005FF -E0000C7F8000180000001C0000001C0000001E0000001FFFF8001FFFFF000FFFFFC007FFFFE003 -FFFFF00FFFFFF03E0007F07C0001F8F80000F8F80000F8F80000F8F80000F87C0001F07C0001F0 -3F0007E00FC01F8007FFFF00007FF0001E287E9A22>II<07000F801FC03FE03FE03FE01FC00F8007000000000000000000000000000000FFE0FFE0 -FFE00FE00FE00FE00FE00FE00FE00FE00FE00FE00FE00FE00FE00FE00FE00FE00FE00FE00FE00F -E00FE00FE0FFFEFFFEFFFE0F2B7EAA12>I107 -DIII<003FE00001FFFC0003F07E000FC01F801F800FC03F0007E03F00 -07E07E0003F07E0003F07E0003F0FE0003F8FE0003F8FE0003F8FE0003F8FE0003F8FE0003F8FE -0003F8FE0003F87E0003F07E0003F03F0007E03F0007E01F800FC00FC01F8007F07F0001FFFC00 -003FE0001D1B7E9A22>II114 D<03FE300FFFF03E03F0 -7800F07000F0F00070F00070F80070FE0000FFE0007FFF007FFFC03FFFE01FFFF007FFF800FFF8 -0007FC0000FCE0007CE0003CF0003CF00038F80038FC0070FF01E0E7FFC0C1FF00161B7E9A1B> -I<00700000700000700000700000F00000F00000F00001F00003F00003F00007F0001FFFE0FFFF -E0FFFFE007F00007F00007F00007F00007F00007F00007F00007F00007F00007F00007F00007F0 -0007F00007F07007F07007F07007F07007F07007F07007F07003F0E001F8C000FFC0003F001426 -7FA51A>II -IIII E /Fo 5 103 df<0000300000F80001F80003F000 -0FE0001F80007F0000FE0003F80007F0000FC0003F80007E0000FC0000FC00007E00003F80000F -C00007F00003F80000FE00007F00001F80000FE00003F00001F80000F8000030151C7D9E1C>60 -D<600000F80000FC00007E00003F80000FC00007F00003F80000FE00007F00001F80000FE00003 -F00001F80001F80003F0000FE0001F80007F0000FE0003F80007F0000FC0003F80007E0000FC00 -00F80000600000151C7D9E1C>62 D98 D<000FF0000FF0000FF00000F00000F00000F00000F00000F00000F00000F000F8F003 -FEF00FFFF01F07F03E03F03C01F07800F07800F0F000F0F000F0F000F0F000F0F000F0F000F0F0 -00F07800F07801F03C01F03E03F01F07F00FFFFF07FEFF01F8FF18217EA01C>100 -D<0003F8000FFC001FFE003E1E003C0C0078000078000078000078000078007FFFF8FFFFF8FFFF -F80078000078000078000078000078000078000078000078000078000078000078000078000078 -000078000078000078000078003FFFF03FFFF03FFFF017217FA01C>102 -D E /Fp 10 109 df<00000001E00000000000000003F00000000000000003F000000000000000 -07F80000000000000007F80000000000000007F8000000000000000FFC000000000000000FFC00 -0000000000001FFE000000000000001FFE000000000000001FFE000000000000003FFF00000000 -0000003FFF000000000000007FFF800000000000007BFF800000000000007BFF80000000000000 -F3FFC0000000000000F1FFC0000000000001F1FFE0000000000001E0FFE0000000000001E0FFE0 -000000000003C0FFF0000000000003C07FF0000000000007C07FF8000000000007803FF8000000 -000007803FF800000000000F003FFC00000000000F001FFC00000000001F001FFE00000000001E -000FFE00000000001E000FFE00000000003C000FFF00000000003C0007FF00000000007C0007FF -8000000000780003FF8000000000780003FF8000000000F00003FFC000000000F00001FFC00000 -0001FFFFFFFFE000000001FFFFFFFFE000000003FFFFFFFFF000000003FFFFFFFFF000000003C0 -00007FF000000007C000007FF8000000078000003FF80000000F8000003FFC0000000F0000003F -FC0000000F0000001FFC0000001F0000001FFE0000001E0000000FFE0000003E0000000FFF0000 -003C00000007FF0000003C00000007FF0000007C00000007FF800000FC00000003FF8000FFFFF8 -0003FFFFFFC0FFFFF80003FFFFFFC0FFFFF80003FFFFFFC0FFFFF80003FFFFFFC0423B7DBA49> -65 D68 D70 D82 D<3FFFFFFFFFFFFFC03FFFFFFFFFFFFFC03FFFFFFFFFFFFFC03FFFFFFFFFFF -FFC03FF8007FF001FFC07FC0007FF0003FE07F80007FF0001FE07F00007FF0000FE07E00007FF0 -0007E07C00007FF00003E07C00007FF00003E07C00007FF00003E07800007FF00001E07800007F -F00001E07800007FF00001E07800007FF00001E0F000007FF00000F0F000007FF00000F0F00000 -7FF00000F0F000007FF00000F0F000007FF00000F00000007FF00000000000007FF00000000000 -007FF00000000000007FF00000000000007FF00000000000007FF00000000000007FF000000000 -00007FF00000000000007FF00000000000007FF00000000000007FF00000000000007FF0000000 -0000007FF00000000000007FF00000000000007FF00000000000007FF00000000000007FF00000 -000000007FF00000000000007FF00000000000007FF00000000000007FF00000000000007FF000 -00000000007FF00000000000007FF00000000000007FF00000000000007FF00000000000007FF0 -0000000000007FF00000000000007FF00000000000007FF00000000000007FF00000000000007F -F00000000000007FF0000000000FFFFFFFFF8000000FFFFFFFFF8000000FFFFFFFFF8000000FFF -FFFFFF80003C3A7DB943>84 D<00FE00000000FFFE00000000FFFE00000000FFFE00000000FFFE -0000000007FE0000000003FE0000000003FE0000000003FE0000000003FE0000000003FE000000 -0003FE0000000003FE0000000003FE0000000003FE0000000003FE0000000003FE0000000003FE -0000000003FE0000000003FE0000000003FE0000000003FE0000000003FE01FF000003FE1FFFF0 -0003FE7FFFFC0003FEFC03FE0003FFF000FF0003FFC0003F8003FF00001FC003FE00001FE003FE -00000FF003FE00000FF803FE00000FF803FE000007FC03FE000007FC03FE000007FC03FE000007 -FE03FE000007FE03FE000007FE03FE000007FE03FE000007FE03FE000007FE03FE000007FE03FE -000007FE03FE000007FE03FE000007FC03FE000007FC03FE000007FC03FE00000FFC03FE00000F -F803FE00000FF003FE00001FF003FF00001FE003FF80003FC003FFC0007F8003F9E000FF0003F0 -FC07FE0003F07FFFF80003E01FFFE00003C003FE00002F3C7DBB36>98 D<000000003F80000000 -3FFF800000003FFF800000003FFF800000003FFF8000000001FF8000000000FF8000000000FF80 -00000000FF8000000000FF8000000000FF8000000000FF8000000000FF8000000000FF80000000 -00FF8000000000FF8000000000FF8000000000FF8000000000FF8000000000FF8000000000FF80 -00000000FF800000FF80FF80000FFFF0FF80003FFFFCFF8000FFC03FFF8001FE000FFF8003FC00 -03FF8007F80001FF800FF00000FF801FF00000FF803FE00000FF803FE00000FF807FE00000FF80 -7FC00000FF807FC00000FF807FC00000FF80FFC00000FF80FFC00000FF80FFC00000FF80FFC000 -00FF80FFC00000FF80FFC00000FF80FFC00000FF80FFC00000FF80FFC00000FF807FC00000FF80 -7FC00000FF807FC00000FF803FE00000FF803FE00000FF801FE00000FF800FF00001FF8007F000 -03FF8003F80007FF8001FE001FFFC000FF807EFFFE007FFFF8FFFE000FFFE0FFFE0001FF00FFFE -2F3C7DBB36>100 D<00001FF0000000FFF8000003FFFE00000FF87F00001FE0FF00003FC1FF80 -007F81FF8000FF81FF8000FF81FF8001FF00FF0001FF007E0001FF003C0001FF00000001FF0000 -0001FF00000001FF00000001FF00000001FF00000001FF00000001FF00000001FF00000001FF00 -0000FFFFFF8000FFFFFF8000FFFFFF8000FFFFFF800001FF00000001FF00000001FF00000001FF -00000001FF00000001FF00000001FF00000001FF00000001FF00000001FF00000001FF00000001 -FF00000001FF00000001FF00000001FF00000001FF00000001FF00000001FF00000001FF000000 -01FF00000001FF00000001FF00000001FF00000001FF00000001FF00000001FF00000001FF0000 -0001FF00000001FF00000001FF0000007FFFFE00007FFFFE00007FFFFE00007FFFFE0000213C7D -BB1E>102 D<01E00007F80007FC000FFE000FFE001FFE001FFE000FFE000FFE0007FC0007F800 -01E00000000000000000000000000000000000000000000000000000000000000000000000FE00 -FFFE00FFFE00FFFE00FFFE0007FE0003FE0003FE0003FE0003FE0003FE0003FE0003FE0003FE00 -03FE0003FE0003FE0003FE0003FE0003FE0003FE0003FE0003FE0003FE0003FE0003FE0003FE00 -03FE0003FE0003FE0003FE0003FE0003FE0003FE00FFFFF0FFFFF0FFFFF0FFFFF0143D7DBC1A> -105 D<00FE00FFFE00FFFE00FFFE00FFFE0007FE0003FE0003FE0003FE0003FE0003FE0003FE00 -03FE0003FE0003FE0003FE0003FE0003FE0003FE0003FE0003FE0003FE0003FE0003FE0003FE00 -03FE0003FE0003FE0003FE0003FE0003FE0003FE0003FE0003FE0003FE0003FE0003FE0003FE00 -03FE0003FE0003FE0003FE0003FE0003FE0003FE0003FE0003FE0003FE0003FE0003FE0003FE00 -03FE0003FE0003FE0003FE0003FE00FFFFF8FFFFF8FFFFF8FFFFF8153C7DBB1A>108 -D E /Fq 4 106 df<0001FE00000007FF8000001E01E000007800780000E0001C000180000600 -030000030006000001800C000000C00C000000C018000000603000000030300000003030000000 -30600000001860000000186000000018C00000000CC00000000CC00000000CC00000000CC00000 -000CC00000000CC00000000CC00000000CC00000000C6000000018600000001860000000183000 -0000303000000030300000003018000000600C000000C00C000000C00600000180030000030001 -8000060000E0001C000078007800001E01E0000007FF80000001FE0000262B7DA02D>13 -D<03C00FF01FF83FFC7FFE7FFEFFFFFFFFFFFFFFFFFFFFFFFF7FFE7FFE3FFC1FF80FF003C01012 -7D9317>15 D<004000C00180018001800300030003000600060006000C000C0018001800180030 -0030003000600060006000C000C0006000600060003000300030001800180018000C000C000600 -0600060003000300030001800180018000C000400A2E7CA112>104 DI E /Fr 60 125 df<0003FC0FE0001FFF3FF8007E03FC7801F807F0FC -03F00FF0FC03F00FE0FC07E00FE07807E007E00007E007E00007E007E00007E007E00007E007E0 -0007E007E00007E007E000FFFFFFFF80FFFFFFFF8007E007E00007E007E00007E007E00007E007 -E00007E007E00007E007E00007E007E00007E007E00007E007E00007E007E00007E007E00007E0 -07E00007E007E00007E007E00007E007E00007E007E00007E007E00007E007E00007E007E00007 -E007E0007FFE7FFF007FFE7FFF0026267FA524>11 D<0003FC00003FFE00007E070001F80F8003 -F01F8003E01F8007E01F8007E01F8007E01F8007E0060007E0000007E0000007E0000007E0FFC0 -FFFFFFC0FFFFFFC007E00FC007E00FC007E00FC007E00FC007E00FC007E00FC007E00FC007E00F -C007E00FC007E00FC007E00FC007E00FC007E00FC007E00FC007E00FC007E00FC007E00FC007E0 -0FC007E00FC007E00FC07FFC7FFC7FFC7FFC1E267FA522>I<0003FFC0003FFFC000FE0FC001F8 -1FC003F01FC003E01FC007E00FC007E00FC007E00FC007E00FC007E00FC007E00FC007E00FC007 -E00FC0FFFFFFC0FFFFFFC007E00FC007E00FC007E00FC007E00FC007E00FC007E00FC007E00FC0 -07E00FC007E00FC007E00FC007E00FC007E00FC007E00FC007E00FC007E00FC007E00FC007E00F -C007E00FC007E00FC007E00FC07FFEFFFC7FFEFFFC1E267FA522>I<3C7EFFFFFFFF7E3C08087C -8711>46 D<007F800003FFF00007E1F8000F807C001F003E003F003F003E001F007E001F807E00 -1F807E001F807E001F80FE001FC0FE001FC0FE001FC0FE001FC0FE001FC0FE001FC0FE001FC0FE -001FC0FE001FC0FE001FC0FE001FC0FE001FC0FE001FC07E001F807E001F807E001F807E001F80 -3F003F003F003F001F003E000F807C0007E1F80003FFF000007F80001A237EA21F>48 -D<001C00003C0000FC00FFFC00FFFC0000FC0000FC0000FC0000FC0000FC0000FC0000FC0000FC -0000FC0000FC0000FC0000FC0000FC0000FC0000FC0000FC0000FC0000FC0000FC0000FC0000FC -0000FC0000FC0000FC0000FC0000FC0000FC0000FC007FFFFC7FFFFC16237CA21F>I<01FF0007 -FFC01E07F03803F86001FC7C00FEFE00FEFE00FFFE007FFE007F7C007F3800FF0000FF0000FE00 -00FE0001FC0001F80003F00007E0000780000F00001E00003C0000700000E00301C00303800707 -00060600060FFFFE1FFFFE3FFFFE7FFFFCFFFFFCFFFFFC18237DA21F>I<01FF0007FFE01E03F0 -3801F83C01FC7E00FE7E00FE7E00FE3E00FE1C01FE0001FC0001FC0003F80007F0000FC001FF00 -01FF000007E00001F00001F80000FC0000FE0000FF0000FF1000FF7C00FFFE00FFFE00FFFE00FE -FE00FE7C01FC7001F83E07F00FFFC001FF0018237DA21F>I<0000380000007800000078000000 -F8000001F8000003F8000007F8000006F800000CF800001CF8000038F8000030F8000060F80000 -E0F80001C0F8000180F8000300F8000700F8000E00F8001C00F8001800F8003000F8007000F800 -E000F800FFFFFFC0FFFFFFC00001F8000001F8000001F8000001F8000001F8000001F8000001F8 -00007FFFC0007FFFC01A237EA21F>I<18000C1F007C1FFFF81FFFF01FFFE01FFFC01FFF801FFE -0018000018000018000018000018000018FF001BFFE01F01F01C00F80800FC00007E00007E0000 -7E00007F00007F78007FFC007FFC007FFC007FFC007EF8007E6000FC7000FC3801F81E07E007FF -C001FE0018237DA21F>I<001FC0007FF001F83803E00C07803E0F807E1F007E3F007E3F007E7E -003C7E00007E00007E0000FE3FC0FE7FF0FE80F8FF80FCFF007CFF007EFE007EFE007FFE007FFE -007FFE007F7E007F7E007F7E007F7E007F3E007E3F007E1F007C0F80F807C1F003FFC0007F0018 -237DA21F>I<300000003C0000003FFFFFC03FFFFFC03FFFFF807FFFFF007FFFFE007FFFFC0060 -00180060001800E0003000C0006000C000C0000001800000018000000300000007000000060000 -000E0000001E0000001E0000001E0000003C0000003C0000007C0000007C0000007C0000007C00 -0000FC000000FC000000FC000000FC000000FC000000FC000000FC000000780000003000001A25 -7DA41F>I<00FF8003FFE00F01F81C007C38003C38001E78001E78001E7C001E7E001E7F803C7F -E03C3FF8781FFCF01FFFC00FFFC003FFE003FFF80FFFFC1E1FFC3C07FE7801FE7800FFF0003FF0 -001FF0000FF0000FF0000FF0000E78000E78001C3E00381F80F007FFE000FF0018237DA21F>I< -00FF0003FFC00F83E01F00F03F00F87E007C7E007C7E007EFE007EFE007EFE007EFE007FFE007F -FE007FFE007F7E007F7E00FF3E00FF3F01FF1F017F0FFE7F03FC7F00007F00007E00007E3C007E -7E00FC7E00FC7E00F87E00F07C01F03003E01C0F800FFF0003F80018237DA21F>I<00001C0000 -0000001C00000000003E00000000003E00000000003E00000000007F00000000007F0000000000 -FF8000000000FF8000000000FF80000000019FC0000000019FC0000000031FE0000000030FE000 -0000030FE00000000607F00000000607F00000000C07F80000000C03F80000001C03FC00000018 -01FC0000001801FC0000003001FE0000003000FE0000007FFFFF0000007FFFFF00000060007F00 -0000C0007F800000C0003F800001C0003FC0000180001FC0000180001FC0000300000FE0000300 -000FE0000780000FF000FFF801FFFF80FFF801FFFF8029257EA42E>65 DI<0000FF8008000FFFF018003F -C03C7800FE0006F801F80003F803F00001F807E00000F80FC00000781FC00000783F800000383F -800000387F800000187F000000187F00000018FF00000000FF00000000FF00000000FF00000000 -FF00000000FF00000000FF00000000FF00000000FF000000007F000000007F000000187F800000 -183F800000183F800000181FC00000300FC000003007E000006003F00000C001F800018000FE00 -0700003FC01E00000FFFF8000000FFC00025257DA42C>IIII72 DI76 DII<0003 -FF8000001FFFF000007F01FC0001FC007F0003F0001F8007E0000FC00FE0000FE01FC00007F01F -800003F03F800003F83F800003F87F800003FC7F000001FC7F000001FCFF000001FEFF000001FE -FF000001FEFF000001FEFF000001FEFF000001FEFF000001FEFF000001FEFF000001FE7F000001 -FC7F000001FC7F800003FC3F800003F83F800003F81FC00007F01FC00007F00FE0000FE007F000 -1FC003F8003F8001FC007F00007F01FC00001FFFF0000003FF800027257DA42E>II82 D<00FF008007FFE3800F80F780 -1E001F803C000F807800078078000380F8000380F8000180F8000180FC000180FC000000FF0000 -007FE000007FFF00003FFFE0003FFFF8001FFFFE0007FFFF0003FFFF80007FFF800003FFC00000 -3FC000000FE0000007E0000007E0C00003E0C00003E0C00003E0C00003C0E00003C0F00007C0F8 -000780FC000F00FFC03E00E3FFF800803FE0001B257DA422>I<7FFFFFFFF87FFFFFFFF87E00FE -01F87800FE00787000FE00386000FE00186000FE0018E000FE001CE000FE000CC000FE000CC000 -FE000CC000FE000CC000FE000C0000FE00000000FE00000000FE00000000FE00000000FE000000 -00FE00000000FE00000000FE00000000FE00000000FE00000000FE00000000FE00000000FE0000 -0000FE00000000FE00000000FE00000000FE00000000FE00000000FE00000000FE00000000FE00 -0000FFFFFE0000FFFFFE0026247EA32B>I86 DI<7FFFC0FFFE007FFFC0FFFE0003FC000F800001FC0007000001FE000E000000FF000C -0000007F80180000007F80380000003FC0700000001FE0600000001FE0C00000000FF1C0000000 -07FB8000000007FB0000000003FE0000000001FE0000000000FE0000000000FF00000000007F80 -000000007FC0000000007FC000000000DFE000000001CFF0000000038FF00000000307F8000000 -0603FC0000000E01FC0000001C01FE0000001800FF00000030007F80000070007F800000E0003F -C00000C0001FE0000180001FE00003C0000FF000FFFC00FFFF80FFFC00FFFF8029257EA42E>I< -07FF00001FFFC0003E03E0003F01F0003F01F8003F00FC001E00FC000000FC000000FC000000FC -00003FFC0003FCFC000FC0FC003F00FC007E00FC007E00FC00FC00FC00FC00FC00FC00FC00FC01 -7C007E017C003F067C001FFC3FE007F01FE01B187E971E>97 DI<007FE003FFF807C07C1F -80FC1F00FC3F00FC7E00787E0000FE0000FE0000FE0000FE0000FE0000FE0000FE0000FE00007E -00007F00003F000C1F800C1FC01807E07003FFE0007F0016187E971B>I<0001FF800001FF8000 -001F8000001F8000001F8000001F8000001F8000001F8000001F8000001F8000001F8000001F80 -00001F8000001F80007F1F8003FFDF8007E0FF801F803F803F001F803F001F807E001F807E001F -80FE001F80FE001F80FE001F80FE001F80FE001F80FE001F80FE001F80FE001F807E001F807E00 -1F803F001F803F003F801F807F800FC0FF8003FF9FF800FE1FF81D267EA522>I<007F0003FFC0 -07C1F00F80F81F00F83F007C7E007C7E007EFE007EFE007EFFFFFEFFFFFEFE0000FE0000FE0000 -7E00007E00007E00063F00061F000C0F801807E07003FFE0007F8017187E971C>I<000FC0007F -F000F8F001F1F803F1F803E1F807E0F007E00007E00007E00007E00007E00007E00007E000FFFF -00FFFF0007E00007E00007E00007E00007E00007E00007E00007E00007E00007E00007E00007E0 -0007E00007E00007E00007E00007E00007E00007E00007E0007FFF007FFF0015267EA513>I<01 -FF07C007FFDFE00F83F1E01F01F1E03E00F8007E00FC007E00FC007E00FC007E00FC007E00FC00 -7E00FC003E00F8001F01F0000F83E0000FFFC00011FF00003000000030000000380000003C0000 -003FFFE0001FFFFC001FFFFE000FFFFF001FFFFF803C003F8078000FC0F80007C0F80007C0F800 -07C0F80007C07C000F803E001F001F807E0007FFF80000FFC0001B247E971F>II<0F001F -803FC03FC03FC03FC01F800F000000000000000000000000000000FFC0FFC00FC00FC00FC00FC0 -0FC00FC00FC00FC00FC00FC00FC00FC00FC00FC00FC00FC00FC00FC00FC00FC0FFF8FFF80D277E -A611>I<001E00003F00007F80007F80007F80007F80003F00001E000000000000000000000000 -0000000000000000000001FF8001FF80001F80001F80001F80001F80001F80001F80001F80001F -80001F80001F80001F80001F80001F80001F80001F80001F80001F80001F80001F80001F80001F -80001F80001F80001F80001F80001F80781F80FC1F00FC3F00FC3E00787C003FF8000FE0001132 -83A613>IIIII<007F800003FF -F00007C0F8001F807E003F003F003F003F007E001F807E001F80FE001FC0FE001FC0FE001FC0FE -001FC0FE001FC0FE001FC0FE001FC0FE001FC07E001F807E001F803F003F003F003F001F807E00 -0FC0FC0003FFF000007F80001A187E971F>II114 D<07F9801FFF803C0F80700380F00180F00180F00180FC0000FF80 -007FFC007FFE003FFF800FFFC003FFC0001FE00003E0C001E0C001E0E001E0E001C0F003C0FC07 -80EFFF00C3FC0013187E9718>I<00600000600000600000600000E00000E00001E00001E00003 -E00007E0001FE000FFFFC0FFFFC007E00007E00007E00007E00007E00007E00007E00007E00007 -E00007E00007E00007E00007E06007E06007E06007E06007E06007E06003E0C003F0C001FF8000 -7E0013237FA218>IIII -II<3FFFF83FFFF83E03 -F03807F0300FE0700FC0701F80603F80603F00607E0000FE0000FC0001F80003F81803F01807E0 -180FE0180FC0381F80303F80707F00707E01F0FFFFF0FFFFF015187E971B>III -E end -%%EndProlog -%%BeginSetup -%%Feature: *Resolution 300 -TeXDict begin -%%EndSetup -%%Page: 1 1 -bop 0 2617 a @beginspecial 72 @llx 72 @lly 504 @urx 700 @ury -4320 @rwi @setspecial -%%BeginDocument: ctrcover.ps - -gsave - /inch { 72 mul} def - .9 setgray - /Helvetica-Bold findfont 130 scalefont setfont - gsave - 6.5 inch 7.5 inch moveto - -90 rotate - (cygnus) true charpath fill - grestore - - gsave - 5 inch 7.5 inch moveto - -90 rotate - (reports) true charpath fill - grestore -grestore -%%EndDocument - @endspecial 1696 350 a Fr(CTR)p Fq(\017\017)p Fr({)p Fq(\017\017)0 -563 y Fp(libbfd)p 277 542 1326 9 v 1359 w(DRAFT)0 870 y Fr(The)20 -b(Binary)h(File)f(Descriptor)h(Library)0 978 y(First)f(Edition|)p -Fo(bfd)h Fr(v)n(ersion)h Fo(<)e Fr(2.0)0 1036 y(April)h(1991)0 -1850 y Fn(Stev)n(e)i(Cham)n(b)r(erlain)0 1916 y(Cygn)n(us)f(Supp)r(ort)300 -2659 y Fr(1)e(August)h(1991)p eop -%%Page: 2 2 -bop 1328 233 a Fm(Cygn)o(us)15 b(Supp)q(ort)1288 283 y(stev)o(e@cygn)o -(us.com)1267 333 y Fl(BFD)p Fm(,)f(Revision:)22 b(1.5)849 382 -y(T)874 392 y(E)899 382 y(Xinfo)16 b(2.50,)e(Cygn)o(us)h(TR)30 -b(Revision:)22 b(1.6)300 2085 y(Cop)o(yrigh)o(t)526 2084 y(c)514 -2085 y Fq(\015)15 b Fm(1991)f(F)l(ree)h(Soft)o(w)o(are)f(F)l(oundation,)h -(Inc.)300 2147 y(P)o(ermission)g(is)f(gran)o(ted)f(to)h(mak)o(e)f(and)h -(distribute)h(v)o(erbatim)f(copies)h(of)f(this)300 2197 y(man)o(ual)g(pro)o -(vided)h(the)g(cop)o(yrigh)o(t)f(notice)h(and)f(this)h(p)q(ermission)g -(notice)g(are)300 2247 y(preserv)o(ed)h(on)f(all)h(copies.)300 -2309 y(P)o(ermission)22 b(is)g(gran)o(ted)f(to)g(cop)o(y)g(and)h(distribute)h -(mo)q(di\014ed)g(v)o(ersions)e(of)300 2359 y(this)f(man)o(ual)f(under)h(the)f -(conditions)i(for)d(v)o(erbatim)h(cop)o(ying,)i(sub)s(ject)e(to)300 -2408 y(the)h(terms)f(of)g(the)g(GNU)g(General)h(Public)i(License,)g(whic)o(h) -e(includes)i(the)300 2458 y(pro)o(vision)16 b(that)f(the)g(en)o(tire)h -(resulting)g(deriv)o(ed)g(w)o(ork)f(is)g(distributed)i(under)300 -2508 y(the)e(terms)g(of)g(a)g(p)q(ermission)h(notice)g(iden)o(tical)h(to)e -(this)g(one.)300 2570 y(P)o(ermission)d(is)g(gran)o(ted)f(to)f(cop)o(y)i(and) -f(distribute)i(translations)e(of)g(this)h(man-)300 2620 y(ual)18 -b(in)o(to)f(another)g(language,)h(under)g(the)f(ab)q(o)o(v)o(e)g(conditions)i -(for)e(mo)q(di\014ed)300 2670 y(v)o(ersions.)p eop -%%Page: 1 3 -bop 0 -58 a Fk(Chapter)13 b(1:)k(Intro)q(duction)p 377 -66 -698 3 v 723 w(DRAFT)p 1217 -66 V 723 w Fj(1)0 183 y Fi(1)41 -b(In)n(tro)r(duction)300 299 y Fm(Simply)13 b(put,)e Fh(bfd)g -Fm(is)g(a)g(pac)o(k)m(age)g(whic)o(h)h(allo)o(w)f(applications)i(to)d(use)h -(the)g(same)300 349 y(routines)19 b(to)f(op)q(erate)h(on)g(ob)s(ject)f -(\014les)i(whatev)o(er)e(the)h(ob)s(ject)f(\014le)i(format.)300 -399 y(A)15 b(di\013eren)o(t)g(ob)s(ject)g(\014le)h(format)d(can)j(b)q(e)f -(supp)q(orted)h(simply)g(b)o(y)f(creating)g(a)300 449 y(new)g(BFD)g(bac)o(k)g -(end)h(and)f(adding)h(it)g(to)e(the)i(library)l(.)300 512 y(BFD)f(is)g(split) -i(in)o(to)e(t)o(w)o(o)f(parts;)g(the)h(fron)o(t)f(end)i(and)g(the)f(man)o(y)g -(bac)o(k)g(ends.)337 575 y Fq(\017)30 b Fm(The)15 b(fron)o(t)f(end)i(of)e -(bfd)i(pro)o(vides)f(the)g(in)o(terface)h(to)e(the)h(user.)20 -b(It)15 b(man-)390 625 y(ages)h(memory)l(,)f(and)i(v)m(arious)f(canonical)i -(data)d(structures.)23 b(The)16 b(fron)o(t)390 675 y(end)i(also)e(decides)j -(whic)o(h)f(bac)o(k)e(end)i(to)e(use,)h(and)g(when)h(to)e(call)i(bac)o(k)390 -725 y(end)e(routines.)337 788 y Fq(\017)30 b Fm(The)22 b(bac)o(k)g(ends)h -(pro)o(vide)f(bfd)g(its)h(view)f(of)g(the)g(real)g(w)o(orld.)40 -b(Eac)o(h)390 837 y(bac)o(k)15 b(end)g(pro)o(vides)g(a)g(set)f(of)h(calls)h -(whic)o(h)f(the)g(bfd)g(fron)o(t)f(end)i(can)f(use)390 887 -y(to)j(main)o(tain)i(its)f(canonical)h(form.)30 b(The)19 b(bac)o(k)g(ends)h -(also)e(ma)o(y)h(k)o(eep)390 937 y(around)c(information)h(for)e(their)i(o)o -(wn)e(use,)i(for)e(greater)h(e\016ciency)l(.)0 1099 y Fn(1.1)33 -b(History)300 1191 y Fm(One)12 b(spur)g(b)q(ehind)h Fh(bfd)e -Fm(w)o(as)g(the)g(In)o(tel)i(Oregon's)e(GNU)g(960)f(team)h(desire)i(for)300 -1241 y(in)o(terop)q(erabilit)o(y)g(of)e(applications)i(on)f(their)g(COFF)f -(and)g(b.out)g(\014le)i(formats.)300 1290 y(Cygn)o(us)i(w)o(as)f(pro)o -(viding)i(GNU)e(supp)q(ort)h(for)g(the)g(team,)f(and)h(Cygn)o(us)f(w)o(ere) -300 1340 y(con)o(tracted)h(to)f(pro)o(vid)i(the)f(required)h(functionalit)o -(y)l(.)300 1403 y(The)11 b(name)h(came)f(from)f(a)h(con)o(v)o(ersation)g(Gum) -o(b)o(y)g(W)l(allace)h(w)o(as)e(ha)o(ving)i(with)300 1453 y(Ric)o(hard)i -(Stallman)f(ab)q(out)g(the)g(library)l(,)h(RMS)f(said)g(that)f(it)i(w)o(ould) -f(b)q(e)g(quite)300 1503 y(hard,)i(Gum)o(b)o(y)f(said)i(BFD.)f(\(Stallman)g -(w)o(as)g(righ)o(t,)f(but)h(the)h(name)f(stuc)o(k\).)300 1566 -y(A)o(t)f(the)g(same)g(time,)g(Ready)h(Systems)f(w)o(an)o(ted)g(m)o(uc)o(h)g -(the)g(same)g(thing,)h(but)300 1616 y(for)20 b(di\013eren)o(t)h(ob)s(ject)f -(\014le)i(formats,)e(IEEE-695,)i(Oasys,)f(Srecords,)h(a.out)300 -1666 y(and)15 b(68k)g(co\013.)300 1729 y(BFD)10 b(w)o(as)f(\014rst)h -(implemen)o(ted)i(b)o(y)e(Stev)o(e)g(Cham)o(b)q(erlain)h(\(stev)o(e)p -Fh(@)p Fm(cygn)o(us.com\),)p 1979 1740 21 46 v 300 1779 a(John)g(Gilmore)f -(\(gn)o(u)p Fh(@)p Fm(cygn)o(us.com\),)g(K.)g(Ric)o(hard)h(Pixley)g(\(ric)o -(h)p Fh(@)p Fm(cygn)o(us.com\))p 1979 1790 V 300 1828 a(and)g(Gum)o(b)o(y)f -(W)l(allace)i(\(gum)o(b)o(y)p Fh(@)p Fm(cygn)o(us.com\))c(at)i(Cygn)o(us)h -(Supp)q(ort)g(in)g(P)o(alo)300 1878 y(Alto,)k(California.)0 -2040 y Fn(1.2)33 b(Ho)n(w)21 b(It)h(W)-6 b(orks)300 2132 y -Fm(T)l(o)15 b(use)g(the)h(library)l(,)g(include)h Fh(bfd.h)e -Fm(and)g(link)i(with)e Fh(libbfd.a)p Fm(.)308 2195 y Fh(bfd)h -Fm(pro)o(vides)h(a)f(common)g(in)o(terface)h(to)f(the)h(parts)e(of)h(an)h(ob) -s(ject)f(\014le)h(to)f(a)300 2245 y(calling)h(application.)300 -2308 y(When)g(an)g(application)i(sucessfully)f(op)q(ens)g(a)e(target)g -(\014le)i(\(ob)s(ject,)e(arc)o(hiv)o(e)300 2358 y(or)k(whatev)o(er\))g(a)h(p) -q(oin)o(ter)h(to)e(an)h(in)o(ternal)h(structure)e(is)i(returned.)37 -b(This)300 2408 y(p)q(oin)o(ter)16 b(p)q(oin)o(ts)f(to)g(structure)g(describ) -q(ed)i(in)g Fh(include/bfd.h)p Fm(,)c(called)k Fh(bfd)p Fm(.)300 -2457 y(Con)o(v)o(en)o(tionally)c(this)h(p)q(oin)o(ter)f(is)g(called)i(a)d -Fh(bfd)p Fm(,)h(and)g(instances)g(of)g(it)g(within)300 2507 -y(co)q(de)19 b(are)g(called)42 b Fh(abfd)p Fm(.)31 b(All)20 -b(op)q(erations)f(on)g(the)f(target)g(ob)s(ject)g(\014le)i(are)300 -2557 y(applied)c(as)e(metho)q(ds)h(to)e(the)i Fh(bfd)p Fm(,)e(the)i(mapping)g -(is)f(de\014ned)i(within)g Fh(bfd.h)300 2607 y Fm(in)g(a)f(set)g(of)g -(macros,)f(all)i(b)q(eginning)h Fh(bfd)p 1027 2607 14 2 v 16 -w Fm(something.)300 2670 y(F)l(or)e(example,)g(this)h(sequence)g(w)o(ould)g -(do)f(what)g(y)o(ou)f(exp)q(ect:)0 2770 y Fk(c)6 b(y)g(g)g(n)g(u)g(s)36 -b(s)6 b(u)g(p)g(p)g(o)g(r)g(t)p 332 2761 1396 3 v 1421 w(Revision:)17 -b(1.5)p eop -%%Page: 2 4 -bop 0 -58 a Fk(Chapter)13 b(1:)k(Intro)q(duction)p 377 -66 -698 3 v 723 w(DRAFT)p 1217 -66 V 723 w Fj(2)300 26 y Fg(\013)p -325 26 1326 2 v 1325 w(\010)p 300 473 2 424 v 314 112 a Fh(#include)23 -b("bfd.h")314 212 y(unsigned)g(int)g(number_of_sections\(abfd\))314 -262 y(bfd)h(*abfd;)314 311 y({)362 361 y(return)f -(bfd_count_sections\(abfd\);)314 411 y(})p 1677 473 V 300 499 -a Fg(\012)p 325 499 1326 2 v 1325 w(\011)300 613 y Fm(The)18 -b(metaphor)e(used)i(within)32 b Fh(bfd)17 b Fm(is)h(that)e(an)i(ob)s(ject)e -(\014le)j(has)e(a)g(header,)300 663 y(a)f(n)o(um)o(bb)q(er)h(of)f(sections)h -(con)o(taining)g(ra)o(w)e(data,)h(a)g(set)g(of)g(relo)q(cations)h(and)300 -712 y(some)i(sym)o(b)q(ol)g(information.)32 b(Also,)43 b Fh(bfd)p -Fm(s)19 b(op)q(ened)h(up)q(on)g(arc)o(hiv)o(es)f(ha)o(v)o(e)300 -762 y(the)g(additional)i(attribute)d(of)h(an)g(index)h(and)g(con)o(tained)f -(sub)h(bfds.)31 b(This)300 812 y(approac)o(h)12 b(is)i(\014nd)f(for)f(a.out)g -(and)h(co\013,)f(but)h(lo)q(oses)g(e\016ciency)i(when)e(applied)300 -862 y(to)i(formats)e(suc)o(h)j(as)f(S-records)g(and)h(IEEE-695.)0 -1027 y Fn(1.3)33 b(What)23 b(BFD)f(V)-6 b(ersion)23 b(1)f(Can't)g(Do)300 -1120 y Fm(As)c(di\013eren)o(t)h(information)f(from)g(the)g(the)g(ob)s(ject)g -(\014les)h(is)g(required,)g(BFD)300 1169 y(reads)j(from)g(di\013eren)o(t)g -(sections)h(of)f(the)h(\014le)g(and)g(pro)q(cesses)f(them.)42 -b(F)l(or)300 1219 y(example)13 b(a)f(v)o(ery)g(common)f(op)q(eration)i(for)e -(the)i(link)o(er)g(is)g(pro)q(cessing)g(sym)o(b)q(ol)300 1269 -y(tables.)19 b(Eac)o(h)10 b(BFD)h(bac)o(k)f(end)i(pro)o(vides)f(a)g(routine)g -(for)f(con)o(v)o(erting)h(b)q(et)o(w)o(een)300 1319 y(the)16 -b(ob)s(ject)f(\014le's)h(represen)o(tation)g(of)f(sym)o(b)q(ols)h(and)g(an)f -(in)o(ternal)i(canonical)300 1369 y(format.)k(When)16 b(the)g(link)o(er)h -(asks)e(for)g(the)h(sym)o(b)q(ol)g(table)h(of)e(an)h(ob)s(ject)f(\014le,)300 -1418 y(it)j(calls)h(through)e(the)h(memory)f(p)q(oin)o(ter)h(to)f(the)g -(relev)m(an)o(t)i(BFD)e(bac)o(k)g(end)300 1468 y(routine)k(whic)o(h)g(reads)f -(and)h(con)o(v)o(erts)e(the)h(table)h(in)o(to)f(a)g(canonical)i(form.)300 -1518 y(The)e(link)o(er)i(then)e(op)q(erates)g(up)q(on)h(the)g(common)e(form.) -35 b(When)20 b(the)h(link)300 1568 y(is)c(\014nished)h(and)e(the)h(link)o(er) -g(writes)f(the)h(sym)o(b)q(ol)f(table)h(of)f(the)g(output)g(\014le,)300 -1618 y(another)10 b(BFD)g(bac)o(k)h(end)g(routine)g(is)g(called)i(whic)o(h)e -(tak)o(es)f(the)g(newly)i(created)300 1668 y(sym)o(b)q(ol)k(table)f(and)h -(con)o(v)o(erts)e(it)h(in)o(to)h(the)f(c)o(hosen)g(output)g(format.)0 -1816 y Fr(1.3.1)30 b(Information)19 b(Loss)300 1909 y Ff(Some)f(information)g -(is)h(lost)f(due)g(to)g(the)g(nature)g(of)f(the)i(\014le)g(format.)27 -b Fm(The)300 1958 y(output)15 b(targets)e(supp)q(orted)i(b)o(y)g(BFD)f(do)h -(not)f(pro)o(vide)i(iden)o(tical)g(facilities,)300 2008 y(and)e(information)f -(whic)o(h)h(ma)o(y)f(b)q(e)h(describ)q(ed)i(in)e(one)f(form)g(has)g(no)o -(where)h(to)300 2058 y(go)h(in)h(another)f(format.)k(One)d(example)g(of)f -(this)h(is)g(alignmen)o(t)g(information)300 2108 y(in)62 b -Fh(b.out)p Fm(.)40 b(There)22 b(is)g(no)o(where)g(in)g(an)62 -b Fh(a.out)21 b Fm(format)g(\014le)h(to)g(store)300 2158 y(alignmen)o(t)14 -b(information)f(on)h(the)f(con)o(tained)h(data,)f(so)f(when)i(a)f(\014le)i -(is)e(link)o(ed)300 2208 y(from)h Fh(b.out)f Fm(and)i(an)f -Fh(a.out)f Fm(image)i(is)g(pro)q(duced,)g(alignmen)o(t)g(information)300 -2257 y(will)20 b(not)e(propagate)f(to)h(the)g(output)g(\014le.)31 -b(\(The)18 b(link)o(er)h(will)h(still)g(use)f(the)300 2307 -y(alignmen)o(t)14 b(information)g(in)o(ternally)l(,)i(so)d(the)h(link)h(is)f -(p)q(erformed)g(correctly\).)300 2371 y(Another)j(example)h(is)f(COFF)g -(section)g(names.)25 b(COFF)17 b(\014les)h(ma)o(y)e(con)o(tain)300 -2421 y(an)21 b(unlimited)j(n)o(um)o(b)q(er)e(of)f(sections,)i(eac)o(h)e(one)h -(with)g(a)f(textual)g(section)300 2471 y(name.)e(If)14 b(the)f(target)f(of)h -(the)h(link)h(is)f(a)f(format)f(whic)o(h)i(do)q(es)f(not)g(ha)o(v)o(e)g(man)o -(y)300 2521 y(sections)20 b(\(eg)43 b Fh(a.out)p Fm(\))19 b(or)f(has)h -(sections)h(without)g(names)f(\(eg)g(the)g(Oasys)300 2570 y(format\))f(the)i -(link)h(cannot)f(b)q(e)g(done)g(simply)l(.)36 b(Y)l(ou)20 b(can)f(circum)o(v) -o(en)o(t)i(this)300 2620 y(problem)d(b)o(y)f(describing)i(the)e(desired)h -(input-to-output)g(section)f(mapping)300 2670 y(with)f(the)f(link)o(er)h -(command)f(language.)0 2770 y Fk(c)6 b(y)g(g)g(n)g(u)g(s)36 -b(s)6 b(u)g(p)g(p)g(o)g(r)g(t)p 332 2761 1396 3 v 1421 w(Revision:)17 -b(1.5)p eop -%%Page: 3 5 -bop 0 -58 a Fk(Chapter)13 b(1:)k(Intro)q(duction)p 377 -66 -698 3 v 723 w(DRAFT)p 1217 -66 V 723 w Fj(3)300 183 y Ff(Information)g(can)g -(b)q(e)g(lost)g(during)g(canonicalization.)27 b Fm(The)17 b(BFD)f(in)o -(ternal)300 233 y(canonical)k(form)d(of)h(the)g(external)h(formats)e(is)h -(not)g(exhaustiv)o(e;)i(there)e(are)300 283 y(structures)11 -b(in)h(input)h(formats)c(for)i(whic)o(h)h(there)g(is)g(no)f(direct)h -(represen)o(tation)300 333 y(in)o(ternally)l(.)22 b(This)16 -b(means)g(that)e(the)i(BFD)f(bac)o(k)g(ends)h(cannot)f(main)o(tain)h(all)300 -382 y(p)q(ossible)i(data)e(ric)o(hness)h(through)f(the)h(transformation)e(b)q -(et)o(w)o(een)i(external)300 432 y(to)e(in)o(ternal)h(and)f(bac)o(k)g(to)g -(external)g(formats.)300 495 y(This)i(limitation)g(is)f(only)h(a)f(problem)g -(when)h(using)f(the)g(link)o(er)i(to)d(read)h(one)300 545 y(format)j(and)i -(write)f(another.)35 b(Eac)o(h)20 b(BFD)g(bac)o(k)g(end)h(is)g(resp)q -(onsible)i(for)300 595 y(main)o(taining)16 b(as)f(m)o(uc)o(h)h(data)e(as)h(p) -q(ossible,)i(and)e(the)h(in)o(ternal)g(BFD)f(canon-)300 645 -y(ical)23 b(form)e(has)h(structures)g(whic)o(h)h(are)e(opaque)i(to)e(the)h -(BFD)g(core,)h(and)300 694 y(exp)q(orted)17 b(only)h(to)e(the)h(bac)o(k)g -(ends.)26 b(When)17 b(a)g(\014le)h(is)g(read)f(in)h(one)f(format,)300 -744 y(the)c(canonical)i(form)d(is)i(generated)f(for)g(BFD)f(and)i(the)f(link) -o(er.)20 b(A)o(t)13 b(the)g(same)300 794 y(time,)h(the)g(bac)o(k)g(end)g(sa)o -(v)o(es)f(a)o(w)o(a)o(y)f(an)o(y)i(information)g(whic)o(h)h(ma)o(y)e -(otherwise)300 844 y(b)q(e)g(lost.)19 b(If)13 b(the)g(data)f(is)i(then)f -(written)f(bac)o(k)h(in)h(the)e(same)h(format,)e(the)i(bac)o(k)300 -894 y(end)18 b(routine)h(will)g(b)q(e)g(able)f(to)f(use)i(the)e(canonical)i -(form)f(pro)o(vided)g(b)o(y)g(the)300 943 y(BFD)d(core)g(as)g(w)o(ell)h(as)f -(the)h(information)f(it)h(prepared)g(earlier.)21 b(Since)c(there)300 -993 y(is)d(a)f(great)g(deal)h(of)f(commonalit)o(y)g(b)q(et)o(w)o(een)h(bac)o -(k)f(ends,)h(this)g(mec)o(hanism)g(is)300 1043 y(v)o(ery)f(useful.)20 -b(There)13 b(is)g(no)g(information)g(lost)g(for)f(this)h(reason)g(when)g -(linking)300 1093 y(big)k(endian)h(COFF)e(to)g(little)i(endian)g(COFF,)e(or)g -(from)25 b Fh(a.out)16 b Fm(to)25 b Fh(b.out)p Fm(.)300 1143 -y(When)c(a)f(mixture)h(of)e(formats)g(is)i(link)o(ed,)i(the)e(information)f -(is)h(only)g(lost)300 1193 y(from)14 b(the)i(\014les)g(whose)f(format)f -(di\013ers)h(from)g(the)g(destination.)0 1330 y Fr(1.3.2)30 -b(Mec)n(hanism)300 1422 y Fm(The)17 b(greatest)f(p)q(oten)o(tial)i(for)f -(loss)g(of)g(information)g(is)g(when)h(there)f(is)h(least)300 -1472 y(o)o(v)o(erlap)13 b(b)q(et)o(w)o(een)g(the)g(information)g(pro)o(vided) -h(b)o(y)f(the)g(source)g(format,)f(that)300 1522 y(stored)17 -b(b)o(y)g(the)g(canonical)i(format,)d(and)h(the)h(information)f(needed)i(b)o -(y)e(the)300 1572 y(destination)j(format.)30 b(A)19 b(brief)h(description)g -(of)f(the)g(canonical)h(form)f(ma)o(y)300 1622 y(help)d(y)o(ou)f(appreciate)g -(what)f(kinds)i(of)e(data)g(y)o(ou)h(can)g(coun)o(t)f(on)h(preserving)300 -1671 y(across)f(con)o(v)o(ersions.)300 1734 y Ff(\014les)75 -b Fm(Information)21 b(on)f(target)g(mac)o(hine)i(arc)o(hitecture,)g -(particular)f(im-)450 1784 y(plemen)o(tation)h(and)g(format)f(t)o(yp)q(e)g -(are)h(stored)f(on)g(a)h(p)q(er-\014le)h(ba-)450 1834 y(sis.)28 -b(Other)18 b(information)g(includes)i(a)e(demand)g(pageable)g(bit)h(and)450 -1884 y(a)14 b(write)g(protected)g(bit.)20 b(Note)13 b(that)h(information)g -(lik)o(e)h(Unix)g(magic)450 1934 y(n)o(um)o(b)q(ers)g(is)h(not)e(stored)h -(here|only)h(the)f(magic)g(n)o(um)o(b)q(ers')g(mean-)450 1983 -y(ing,)i(so)f(a)23 b Fh(ZMAGIC)16 b Fm(\014le)h(w)o(ould)g(ha)o(v)o(e)f(b)q -(oth)h(the)f(demand)h(pageable)450 2033 y(bit)f(and)f(the)g(write)h -(protected)f(text)g(bit)g(set.)450 2096 y(The)i(b)o(yte)g(order)g(of)f(the)h -(target)f(is)h(stored)g(on)g(a)f(p)q(er-\014le)j(basis,)e(so)450 -2146 y(that)12 b(big-)h(and)g(little-endian)i(ob)s(ject)d(\014les)h(ma)o(y)f -(b)q(e)h(link)o(ed)h(with)f(one)450 2196 y(another.)300 2258 -y Ff(sections)450 2308 y Fm(Eac)o(h)18 b(section)g(in)g(the)g(input)h(\014le) -g(con)o(tains)f(the)g(name)f(of)h(the)g(sec-)450 2358 y(tion,)c(the)h -(original)g(address)f(in)h(the)g(ob)s(ject)e(\014le,)j(v)m(arious)e(\015ags,) -g(size)450 2408 y(and)f(alignmen)o(t)g(information)g(and)g(p)q(oin)o(ters)g -(in)o(to)g(other)f(BFD)h(data)450 2458 y(structures.)300 2521 -y Ff(sym)o(b)q(ols)450 2570 y Fm(Eac)o(h)h(sym)o(b)q(ol)h(con)o(tains)g(a)f -(p)q(oin)o(ter)h(to)f(the)g(ob)s(ject)g(\014le)i(whic)o(h)f(orig-)450 -2620 y(inally)22 b(de\014ned)g(it,)f(its)f(name,)h(its)g(v)m(alue,)h(and)e(v) -m(arious)h(\015ag)f(bits.)450 2670 y(When)14 b(a)f(BFD)g(bac)o(k)g(end)h -(reads)g(in)g(a)f(sym)o(b)q(ol)h(table,)g(the)f(bac)o(k)g(end)0 -2770 y Fk(c)6 b(y)g(g)g(n)g(u)g(s)36 b(s)6 b(u)g(p)g(p)g(o)g(r)g(t)p -332 2761 1396 3 v 1421 w(Revision:)17 b(1.5)p eop -%%Page: 4 6 -bop 0 -58 a Fk(Chapter)13 b(1:)k(Intro)q(duction)p 377 -66 -698 3 v 723 w(DRAFT)p 1217 -66 V 723 w Fj(4)450 183 y Fm(relo)q(cates)k(all)g -(sym)o(b)q(ols)f(to)g(mak)o(e)g(them)g(relativ)o(e)h(to)f(the)g(base)g(of)450 -233 y(the)c(section)g(where)h(they)f(w)o(ere)f(de\014ned.)24 -b(This)16 b(ensures)h(that)e(eac)o(h)450 283 y(sym)o(b)q(ol)d(p)q(oin)o(ts)h -(to)e(its)h(con)o(taining)h(section.)19 b(Eac)o(h)12 b(sym)o(b)q(ol)g(also)g -(has)450 333 y(a)j(v)m(arying)h(amoun)o(t)f(of)g(hidden)j(data)d(to)g(con)o -(tain)g(priv)m(ate)i(data)e(for)450 382 y(the)j(BFD)f(bac)o(k)g(end.)28 -b(Since)19 b(the)e(sym)o(b)q(ol)h(p)q(oin)o(ts)g(to)f(the)h(original)450 -432 y(\014le,)i(the)e(priv)m(ate)i(data)d(format)g(for)h(that)g(sym)o(b)q(ol) -h(is)g(accessible.)450 482 y Fh(gld)13 b Fm(can)i(op)q(erate)e(on)h(a)g -(collection)i(of)d(sym)o(b)q(ols)h(of)g(wildly)i(di\013eren)o(t)450 -532 y(formats)e(without)h(problems.)450 590 y(Normal)k(global)h(and)f(simple) -i(lo)q(cal)f(sym)o(b)q(ols)g(are)f(main)o(tained)h(on)450 640 -y(output,)f(so)f(an)h(output)g(\014le)g(\(no)g(matter)e(its)i(format\))e -(will)k(retain)450 690 y(sym)o(b)q(ols)14 b(p)q(oin)o(ting)g(to)f(functions)h -(and)g(to)e(global,)i(static,)f(and)h(com-)450 740 y(mon)e(v)m(ariables.)21 -b(Some)13 b(sym)o(b)q(ol)g(information)f(is)i(not)e(w)o(orth)g(retain-)450 -789 y(ing;)k(in)j Fh(a.out)c Fm(t)o(yp)q(e)h(information)g(is)g(stored)f(in)i -(the)e(sym)o(b)q(ol)i(table)450 839 y(as)e(long)g(sym)o(b)q(ol)h(names.)k -(This)c(information)g(w)o(ould)f(b)q(e)h(useless)h(to)450 889 -y(most)12 b(COFF)h(debuggers)h(and)f(ma)o(y)g(b)q(e)h(thro)o(wn)f(a)o(w)o(a)o -(y)e(with)j(appro-)450 939 y(priate)f(command)f(line)i(switc)o(hes.)20 -b(\(The)12 b(GNU)h(debugger)g Fh(gdb)f Fm(do)q(es)450 989 y(supp)q(ort)j -Fh(a.out)g Fm(st)o(yle)g(debugging)h(information)g(in)g(COFF\).)450 -1047 y(There)21 b(is)h(one)f(w)o(ord)g(of)g(t)o(yp)q(e)g(information)g -(within)i(the)e(sym)o(b)q(ol,)450 1097 y(so)h(if)h(the)g(format)e(supp)q -(orts)i(sym)o(b)q(ol)g(t)o(yp)q(e)g(information)g(within)450 -1146 y(sym)o(b)q(ols)18 b(\(for)e(example)i(COFF,)e(IEEE,)h(Oasys\))g(and)h -(the)f(t)o(yp)q(e)g(is)450 1196 y(simple)g(enough)f(to)f(\014t)g(within)i -(one)f(w)o(ord)f(\(nearly)h(ev)o(erything)g(but)450 1246 y(aggregates\))d -(the)j(information)f(will)i(b)q(e)f(preserv)o(ed.)300 1304 -y Ff(relo)q(cation)g(lev)o(el)450 1354 y Fm(Eac)o(h)h(canonical)h(BFD)e(relo) -q(cation)h(record)g(con)o(tains)g(a)f(p)q(oin)o(ter)i(to)450 -1404 y(the)f(sym)o(b)q(ol)g(to)f(relo)q(cate)h(to,)f(the)g(o\013set)g(of)g -(the)h(data)f(to)g(relo)q(cate,)450 1454 y(the)h(section)g(the)f(data)g(is)h -(in)g(and)g(a)f(p)q(oin)o(ter)h(to)f(a)g(relo)q(cation)h(t)o(yp)q(e)450 -1503 y(descriptor.)37 b(Relo)q(cation)22 b(is)g(p)q(erformed)f(e\013ectiv)o -(ely)h(b)o(y)e(message)450 1553 y(passing)h(through)f(the)g(relo)q(cation)h -(t)o(yp)q(e)f(descriptor)h(and)g(sym)o(b)q(ol)450 1603 y(p)q(oin)o(ter.)44 -b(It)24 b(allo)o(ws)f(relo)q(cations)h(to)f(b)q(e)h(p)q(erformed)f(on)g -(output)450 1653 y(data)17 b(using)i(a)e(relo)q(cation)h(metho)q(d)g(only)h -(a)o(v)m(ailable)g(in)g(one)f(of)f(the)450 1703 y(input)j(formats.)30 -b(F)l(or)19 b(instance,)h(Oasys)f(pro)o(vides)h(a)e(b)o(yte)h(relo)q(ca-)450 -1753 y(tion)h(format.)31 b(A)20 b(relo)q(cation)g(record)f(requesting)h(this) -g(relo)q(cation)450 1802 y(t)o(yp)q(e)e(w)o(ould)f(p)q(oin)o(t)h(indirectly)i -(to)d(a)g(routine)h(to)f(p)q(erform)g(this,)h(so)450 1852 y(the)e(relo)q -(cation)h(ma)o(y)e(b)q(e)i(p)q(erformed)f(on)g(a)g(b)o(yte)g(b)q(eing)h -(written)g(to)450 1902 y(a)e(COFF)h(\014le,)g(ev)o(en)h(though)e(68k)g(COFF)h -(has)f(no)h(suc)o(h)g(relo)q(cation)450 1952 y(t)o(yp)q(e.)300 -2010 y Ff(line)h(n)o(um)o(b)q(ers)450 2060 y Fm(Ob)s(ject)k(formats)e(can)i -(con)o(tain,)g(for)f(debugging)i(purp)q(oses,)g(some)450 2110 -y(form)14 b(of)h(mapping)g(b)q(et)o(w)o(een)g(sym)o(b)q(ols,)g(source)g(line) -i(n)o(um)o(b)q(ers,)e(and)450 2159 y(addresses)f(in)g(the)g(output)g(\014le.) -20 b(These)14 b(addresses)g(ha)o(v)o(e)f(to)g(b)q(e)h(relo-)450 -2209 y(cated)h(along)g(with)h(the)f(sym)o(b)q(ol)g(information.)20 -b(Eac)o(h)15 b(sym)o(b)q(ol)h(with)450 2259 y(an)j(asso)q(ciated)g(list)g(of) -f(line)j(n)o(um)o(b)q(er)e(records)f(p)q(oin)o(ts)h(to)g(the)f(\014rst)450 -2309 y(record)13 b(of)g(the)g(list.)20 b(The)14 b(head)g(of)e(a)h(line)i(n)o -(um)o(b)q(er)f(list)g(consists)f(of)g(a)450 2359 y(p)q(oin)o(ter)h(to)e(the)i -(sym)o(b)q(ol,)f(whic)o(h)h(allo)o(ws)g(divination)h(of)e(the)g(address)450 -2408 y(of)19 b(the)g(function)g(whose)g(line)i(n)o(um)o(b)q(er)e(is)g(b)q -(eing)i(describ)q(ed.)33 b(The)450 2458 y(rest)18 b(of)h(the)g(list)g(is)g -(made)g(up)g(of)g(pairs:)27 b(o\013sets)18 b(in)o(to)h(the)f(section)450 -2508 y(and)f(line)h(n)o(um)o(b)q(ers.)23 b(An)o(y)17 b(format)e(whic)o(h)i -(can)g(simply)g(deriv)o(e)h(this)450 2558 y(information)13 -b(can)g(pass)g(it)g(successfully)i(b)q(et)o(w)o(een)e(formats)e(\(COFF,)450 -2608 y(IEEE)k(and)h(Oasys\).)300 2670 y(What)f(is)g(a)g(bac)o(k)o(end)0 -2770 y Fk(c)6 b(y)g(g)g(n)g(u)g(s)36 b(s)6 b(u)g(p)g(p)g(o)g(r)g(t)p -332 2761 1396 3 v 1421 w(Revision:)17 b(1.5)p eop -%%Page: 5 7 -bop 0 -58 a Fk(Chapter)13 b(2:)k(BFD)c(front)g(end)p 413 -66 -680 3 v 703 w(DRAFT)p 1236 -66 V 705 w Fj(5)0 183 y Fi(2)41 -b(BFD)27 b(fron)n(t)f(end)0 396 y Fn(2.1)33 b(t)n(yp)r(edef)22 -b(bfd)300 488 y Fm(P)o(oin)o(ters)16 b(to)g(bfd)h(structs)f(are)g(the)h -(cornerstone)f(of)h(an)o(y)f(application)i(using)300 538 y(libbfd.)33 -b(References)20 b(though)e(the)h(bfd)h(and)f(to)f(data)g(in)i(the)f(bfd)g -(giv)o(e)g(the)300 588 y(en)o(tire)d(bfd)f(functionalit)o(y)l(.)300 -651 y(Finally!)22 b(The)15 b(BFD)g(struct)g(itself.)21 b(This)16 -b(con)o(tains)f(the)h(ma)s(jor)d(data)i(ab)q(out)300 701 y(the)g(\014le,)h -(and)g(con)o(tains)f(p)q(oin)o(ters)g(to)g(the)g(rest)g(of)g(the)g(data.)390 -751 y Fh(struct)23 b(_bfd)390 801 y({)300 864 y Ff(The)15 b(\014lename)i(the) -e(application)i(op)q(ened)f(the)f(bfd)h(with.)438 914 y Fh(CONST)23 -b(char)g(*filename;)300 977 y Ff(A)15 b(p)q(oin)o(ter)h(to)e(the)i(target)e -(jump)h(table.)438 1027 y Fh(struct)23 b(bfd_target)f(*xvec;)300 -1090 y Ff(T)l(o)14 b(a)o(v)o(oid)g(dragging)g(to)q(o)g(man)o(y)g(header)h -(\014les)g(in)o(to)f(ev)o(ery)h(\014le)g(that)g(includes)300 -1140 y(bfd.h,)f(IOSTREAM)h(has)e(b)q(een)i(declared)g(as)f(a)f -Fh(")p Ff(c)o(har)g(*)p Fh(")p Ff(,)h(and)f(MTIME)j(as)300 -1190 y(a)e Fh(")p Ff(long)p Fh(")p Ff(.)19 b(Their)c(correct)e(t)o(yp)q(es,)h -(to)f(whic)o(h)i(they)f(are)g(cast)f(when)i(used,)f(are)300 -1240 y Fh(")p Ff(FILE)h(*)p Fh(")g Ff(and)h Fh(")p Ff(time)p -710 1240 14 2 v 16 w(t)p Fh(")p Ff(.)300 1303 y(The)f(iostream)g(is)h(the)f -(result)h(of)f(an)g(fop)q(en)g(on)h(the)f(\014lename.)438 1353 -y Fh(char)23 b(*iostream;)300 1416 y Ff(Is)15 b(the)h(\014le)g(b)q(eing)g -(cac)o(hed)g(See)g(Chapter)f(3)g([File)h(Cac)o(hing],)e(page)i(45.)438 -1466 y Fh(boolean)23 b(cacheable;)300 1529 y Ff(Marks)12 b(whether)h(there)g -(w)o(as)g(a)f(default)i(target)e(sp)q(eci\014ed)j(when)e(the)g(bfd)h(w)o(as) -300 1579 y(op)q(ened.)33 b(This)19 b(is)h(used)g(to)e(select)i(what)e(matc)o -(hing)i(algorithm)f(to)f(use)i(to)300 1629 y(c)o(hose)e(the)d(bac)o(k)g(end.) -438 1679 y Fh(boolean)23 b(target_defaulted;)300 1742 y Ff(The)15 -b(cac)o(hing)h(routines)g(use)f(these)h(to)e(main)o(tain)i(an)f(LR)o(U)h -(list)g(of)f(bfds.)438 1792 y Fh(struct)23 b(_bfd)g(*lru_prev,)g(*lru_next;) -300 1855 y Ff(When)e(a)f(\014le)i(is)f(closed)g(b)o(y)g(the)f(cac)o(hing)i -(routines,)g(it)e(retains)h(the)g(state)300 1905 y(here:)438 -1955 y Fh(file_ptr)h(where;)300 2018 y Ff(and)15 b(here:)438 -2068 y Fh(boolean)23 b(opened_once;)438 2118 y(boolean)g(mtime_set;)300 -2181 y Ff(File)16 b(mo)q(di\014ed)h(time)438 2231 y Fh(long)23 -b(mtime;)300 2294 y Ff(F)l(or)15 b(output)g(\014les,)g(c)o(hannel)i(w)o(e)e -(lo)q(c)o(k)o(ed)h(\(is)f(this)h(used?\).)390 2344 y Fh(int)23 -b(ifd;)300 2407 y Ff(The)15 b(format)f(whic)o(h)i(b)q(elongs)g(to)f(the)g -(bfd.)438 2457 y Fh(bfd_format)22 b(format;)300 2521 y Ff(The)15 -b(direction)i(the)e(bfd)h(w)o(as)e(op)q(ened)i(with)438 2570 -y Fh(enum)23 b(bfd_direction)f({no_direction)g(=)i(0,)939 2620 -y(read_direction)e(=)i(1,)939 2670 y(write_direction)e(=)h(2,)0 -2770 y Fk(c)6 b(y)g(g)g(n)g(u)g(s)36 b(s)6 b(u)g(p)g(p)g(o)g(r)g(t)p -332 2761 1396 3 v 1421 w(Revision:)17 b(1.5)p eop -%%Page: 6 8 -bop 0 -58 a Fk(Chapter)13 b(2:)k(BFD)c(front)g(end)p 413 -66 -680 3 v 703 w(DRAFT)p 1236 -66 V 705 w Fj(6)939 183 y Fh(both_direction)22 -b(=)i(3})f(direction;)300 246 y Ff(F)l(ormat)p 449 246 14 2 -v 15 w(sp)q(eci\014c)17 b(\015ags)438 296 y Fh(flagword)22 -b(flags;)300 359 y Ff(Curren)o(tly)d(m)o(y)p 575 359 V 16 w(arc)o(hiv)o(e)f -(is)i(tested)e(b)q(efore)h(adding)g(origin)g(to)f(an)o(ything.)31 -b(I)300 409 y(b)q(eliev)o(e)16 b(that)e(this)g(can)h(b)q(ecome)f(alw)o(a)o -(ys)g(an)g(add)g(of)g(origin,)h(with)f(origin)h(set)300 458 -y(to)g(0)f(for)h(non)g(arc)o(hiv)o(e)h(\014les.)438 508 y Fh(file_ptr)22 -b(origin;)300 571 y Ff(Remem)o(b)q(er)11 b(when)g(output)f(has)g(b)q(egun,)i -(to)e(stop)f(strange)h(things)h(happ)q(ening.)438 621 y Fh(boolean)23 -b(output_has_begun;)300 684 y Ff(P)o(oin)o(ter)15 b(to)f(link)o(ed)j(list)f -(of)f(sections)438 734 y Fh(struct)23 b(sec)47 b(*sections;)300 -797 y Ff(The)15 b(n)o(um)o(b)q(er)h(of)f(sections)438 846 y -Fh(unsigned)22 b(int)i(section_count;)300 909 y Ff(Stu\013)15 -b(only)h(usefull)h(for)d(ob)s(ject)h(\014les:)21 b(The)16 b(start)e(address.) -438 959 y Fh(bfd_vma)23 b(start_address;)300 1022 y Ff(Used)16 -b(for)e(input)i(and)g(output)438 1072 y Fh(unsigned)22 b(int)i(symcount;)300 -1135 y Ff(Sym)o(tab)15 b(for)f(output)h(bfd)438 1184 y Fh(struct)23 -b(symbol_cache_entry)45 b(**outsymbols;)300 1247 y Ff(Arc)o(hitecture)16 -b(of)f(ob)s(ject)f(mac)o(hine,)i(eg)f(m68k)438 1297 y Fh(enum)23 -b(bfd_architecture)f(obj_arch;)300 1360 y Ff(P)o(articular)15 -b(mac)o(hine)h(within)h(arc)o(h,)d(e.g.)20 b(68010)438 1410 -y Fh(unsigned)i(long)i(obj_machine;)300 1473 y Ff(Stu\013)15 -b(only)h(usefull)h(for)d(arc)o(hiv)o(es:)438 1523 y Fh(PTR)23 -b(arelt_data;)438 1572 y(struct)g(_bfd)g(*my_archive;)438 1622 -y(struct)g(_bfd)g(*next;)438 1672 y(struct)g(_bfd)g(*archive_head;)438 -1722 y(boolean)g(has_armap;)300 1785 y Ff(Used)16 b(b)o(y)f(the)g(bac)o(k)g -(end)h(to)f(hold)h(priv)m(ate)f(data.)438 1834 y Fh(PTR)23 -b(tdata;)300 1897 y Ff(Used)16 b(b)o(y)f(the)g(application)i(to)d(hold)i -(priv)m(ate)g(data)438 1947 y Fh(PTR)23 b(usrdata;)300 2010 -y Ff(Where)15 b(all)h(the)g(allo)q(cated)g(stu\013)e(under)i(this)g(BFD)f(go) -q(es)438 2060 y Fh(struct)23 b(obstack)g(memory;)390 2110 y(};)0 -2248 y Fr(2.1.0.1)30 b(bfd)p 296 2248 19 3 v 22 w(set)p 394 -2248 V 22 w(start)p 543 2248 V 22 w(address)300 2340 y Fm(Marks)15 -b(the)i(en)o(try)e(p)q(oin)o(t)i(of)f(an)g(output)g(bfd.)23 -b(Returns)g Fh(true)15 b Fm(on)h(success,)300 2390 y Fh(false)e -Fm(otherwise.)390 2440 y Fh(PROTO\(boolean,)22 b(bfd_set_start_address,\(bfd) -e(*,)k(bfd_vma\)\);)p 2002 2446 21 38 v 0 2578 a Fr(2.1.0.2)30 -b(bfd)p 296 2578 19 3 v 22 w(get)p 401 2578 V 21 w(m)n(time)300 -2670 y Fm(Return)25 b(cac)o(hed)f(\014le)i(mo)q(di\014cation)f(time)f(\(e.g.) -46 b(as)24 b(read)g(from)g(arc)o(hiv)o(e)0 2770 y Fk(c)6 b(y)g(g)g(n)g(u)g(s) -36 b(s)6 b(u)g(p)g(p)g(o)g(r)g(t)p 332 2761 1396 3 v 1421 w(Revision:)17 -b(1.5)p eop -%%Page: 7 9 -bop 0 -58 a Fk(Chapter)13 b(2:)k(BFD)c(front)g(end)p 413 -66 -680 3 v 703 w(DRAFT)p 1236 -66 V 705 w Fj(7)300 183 y Fm(header)23 -b(for)f(arc)o(hiv)o(e)g(mem)o(b)q(ers,)i(or)e(from)g(\014le)h(system)f(if)h -(w)o(e)f(ha)o(v)o(e)g(b)q(een)300 233 y(called)17 b(b)q(efore\);)e(else)h -(determine)g(mo)q(dify)g(time,)f(cac)o(he)g(it,)g(and)h(return)f(it.)390 -283 y Fh(PROTO\(long,)22 b(bfd_get_mtime,)g(\(bfd)i(*\)\);)0 -416 y Fr(2.1.0.3)30 b(stu\013)300 475 y Fg(\013)p 325 475 1326 -2 v 1325 w(\010)p 300 2068 2 1570 v 314 611 a Fh(#define)23 -b(bfd_sizeof_headers\(abfd,)e(reloc\))i(\\)433 661 y(BFD_SEND)g(\(abfd,)g -(_bfd_sizeof_headers,)e(\(abfd,)i(reloc\)\))314 760 y(#define)g -(bfd_find_nearest_line\(abfd)o(,)e(section,)i(symbols,)g(off-)314 -810 y(set,)g(filename_ptr,)g(func,)g(line_ptr\))f(\\)433 860 -y(BFD_SEND)h(\(abfd,)g(_bfd_find_nearest_line,)45 b(\(abfd,)23 -b(sec-)314 910 y(tion,)g(symbols,)g(offset,)g(filename_ptr,)f(func,)h -(line_ptr\)\))314 1009 y(#define)g(bfd_debug_info_start\(abfd\))d(\\)505 -1059 y(BFD_SEND)j(\(abfd,)g(_bfd_debug_info_start,)e(\(abfd\)\))314 -1159 y(#define)i(bfd_debug_info_end\(abfd\))e(\\)505 1209 y(BFD_SEND)i -(\(abfd,)g(_bfd_debug_info_end,)e(\(abfd\)\))314 1308 y(#define)i -(bfd_debug_info_accumulate\()o(abfd,)e(section\))h(\\)505 1358 -y(BFD_SEND)h(\(abfd,)g(_bfd_debug_info_accumulat)o(e,)e(\(abfd,)314 -1408 y(section\)\))314 1507 y(#define)i(bfd_stat_arch_elt\(abfd,)e(stat\))i -(\\)505 1557 y(BFD_SEND)g(\(abfd,)g(_bfd_stat_arch_elt,\(abfd,)d(stat\)\))314 -1657 y(#define)j(bfd_coff_swap_aux_in\(a,e,t)o(,c,i\))e(\\)505 -1707 y(BFD_SEND)i(\(a,)g(_bfd_coff_swap_aux_in,)e(\(a,e,t,c,i\)\))314 -1806 y(#define)i(bfd_coff_swap_sym_in\(a,e,i)o(\))e(\\)505 -1856 y(BFD_SEND)i(\(a,)g(_bfd_coff_swap_sym_in,)e(\(a,e,i\)\))314 -1956 y(#define)i(bfd_coff_swap_lineno_in\(a,)o(e,i\))e(\\)505 -2006 y(BFD_SEND)i(\()h(a,)f(_bfd_coff_swap_lineno_in,)e(\(a,e,i\)\))p -1677 2068 V 300 2094 a Fg(\012)p 325 2094 1326 2 v 1325 w(\011)0 -2770 y Fk(c)6 b(y)g(g)g(n)g(u)g(s)36 b(s)6 b(u)g(p)g(p)g(o)g(r)g(t)p -332 2761 1396 3 v 1421 w(Revision:)17 b(1.5)p eop -%%Page: 8 10 -bop 0 -58 a Fk(Chapter)13 b(2:)k(BFD)c(front)g(end)p 413 -66 -680 3 v 703 w(DRAFT)p 1236 -66 V 705 w Fj(8)0 183 y Fn(2.2)33 -b(Memory)22 b(Usage)300 277 y Fm(BFD)17 b(k)o(eeps)h(all)h(its)f(in)o(ternal) -g(structures)g(in)g(obstac)o(ks.)27 b(There)18 b(is)g(one)g(ob-)300 -327 y(stac)o(k)c(p)q(er)g(op)q(en)i(bfd)e(\014le,)i(in)o(to)e(whic)o(h)h(the) -g(curren)o(t)f(state)g(is)g(stored.)20 b(When)300 376 y(a)c(bfd)h(is)h -(closed,)f(the)g(obstac)o(k)f(is)h(deleted,)h(and)f(so)f(ev)o(erything)i -(whic)o(h)f(has)300 426 y(b)q(een)f(allo)q(cated)h(b)o(y)e(libbfd)i(for)d -(the)i(closing)g(\014le)g(will)h(b)q(e)f(thro)o(wn)e(a)o(w)o(a)o(y)l(.)300 -491 y(BFD)j(will)h(not)f(free)g(an)o(ything)g(created)h(b)o(y)f(an)g -(application,)h(but)g(p)q(oin)o(ters)300 540 y(in)o(to)d(bfd)g(structures)g -(will)h(b)q(e)g(in)o(v)m(alidated)h(on)d(a)h Fh(bfd_close)p -Fm(;)e(for)h(example,)300 590 y(after)h(a)k Fh(bfd_close)c -Fm(the)g(v)o(ector)g(passed)h(to)j Fh(bfd_canonicalize_symtab)300 -640 y Fm(will)h(still)g(b)q(e)f(around,)f(since)i(it)e(has)g(b)q(een)i(allo)q -(cated)f(b)o(y)f(the)h(application,)300 690 y(but)c(the)h(data)e(that)h(it)g -(p)q(oin)o(ted)h(to)f(will)i(b)q(e)f(lost.)300 754 y(The)g(general)g(rule)g -(is)g(not)f(to)g(close)i(a)e(bfd)h(un)o(til)g(all)h(op)q(erations)e(dep)q -(enden)o(t)300 804 y(up)q(on)j(data)g(from)f(the)g(bfd)i(ha)o(v)o(e)e(b)q -(een)i(completed,)g(or)e(all)i(the)f(data)f(from)300 854 y(within)k(the)f -(\014le)h(has)e(b)q(een)i(copied.)35 b(T)l(o)19 b(help)i(with)g(the)e -(managemen)o(t)g(of)300 904 y(memory)l(,)g(there)g(is)h(a)e(function)i(\()i -Fh(bfd_alloc_size)p Fm(\))16 b(whic)o(h)k(returns)f(the)300 -953 y(n)o(um)o(b)q(er)e(of)f(b)o(ytes)g(in)h(obstac)o(ks)f(asso)q(ciated)g -(with)h(the)g(supplied)h(bfd.)24 b(This)300 1003 y(could)15 -b(b)q(e)f(used)g(to)g(select)g(the)g(greediest)g(op)q(en)h(bfd,)f(close)g(it) -g(to)f(reclaim)i(the)300 1053 y(memory)l(,)f(p)q(erform)g(some)h(op)q -(eration)g(and)g(reop)q(en)g(the)g(bfd)g(again,)f(to)g(get)g(a)300 -1103 y(fresh)h(cop)o(y)g(of)g(the)g(data)g(structures.)0 1276 -y Fn(2.3)33 b(Sections)300 1370 y Fm(Sections)16 b(are)f(supp)q(orted)h(in)g -(bfd)f(in)h Fh(section.c)p Fm(.)300 1434 y(The)f(ra)o(w)f(data)g(con)o -(tained)h(within)h(a)f(bfd)g(is)g(main)o(tained)h(through)f(the)g(sec-)300 -1484 y(tion)f(abstraction.)19 b(A)13 b(single)i(bfd)f(ma)o(y)f(ha)o(v)o(e)g -(an)o(y)h(n)o(um)o(b)q(er)g(of)f(sections,)h(and)300 1534 y(k)o(eeps)k(hold)h -(of)e(them)h(b)o(y)g(p)q(oin)o(ting)h(to)e(the)h(\014rst,)g(eac)o(h)g(one)g -(p)q(oin)o(ts)h(to)e(the)300 1584 y(next)e(in)h(the)g(list.)0 -1736 y Fr(2.3.1)30 b(Section)20 b(Input)300 1829 y Fm(When)15 -b(a)f(bfd)h(is)g(op)q(ened)g(for)f(reading,)h(the)g(section)g(structures)f -(are)g(created)300 1879 y(and)h(attatc)o(hed)g(to)f(the)i(bfd.)300 -1943 y(Eac)o(h)h(section)g(has)g(a)f(name)h(whic)o(h)h(describ)q(es)g(the)f -(section)h(in)f(the)g(outside)300 1993 y(w)o(orld)i(-)g(for)f(example,)44 -b Fh(a.out)18 b Fm(w)o(ould)h(con)o(tain)g(at)g(least)g(three)g(sections,)300 -2043 y(called)e Fh(.text)p Fm(,)d Fh(.data)g Fm(and)i Fh(.bss)p -Fm(.)300 2107 y(Sometimes)e(a)g(bfd)g(will)i(con)o(tain)e(more)f(than)h(the)g -('natural')f(n)o(um)o(b)q(er)h(of)g(sec-)300 2157 y(tions.)20 -b(A)13 b(bac)o(k)h(end)h(ma)o(y)e(attatc)o(h)f(other)i(sections)g(con)o -(taining)h(constructor)300 2207 y(data,)h(or)g(an)g(application)i(ma)o(y)e -(add)h(a)f(section)h(\(using)g(bfd)p 1362 2207 14 2 v 17 w(mak)o(e)p -1483 2207 V 16 w(section\))300 2257 y(to)f(the)h(sections)g(attatc)o(hed)f -(to)h(an)f(already)h(op)q(en)h(bfd.)25 b(F)l(or)16 b(example,)i(the)300 -2307 y(link)o(er)d(creates)f(a)g(sup)q(ern)o(umary)g(section)g -Fh(COMMON)g Fm(for)f(eac)o(h)h(input)h(\014le's)g(bfd)300 2357 -y(to)g(hold)h(information)f(ab)q(out)g(common)g(storage.)300 -2421 y(The)22 b(ra)o(w)f(data)h(is)g(not)g(necessarily)h(read)f(in)h(at)e -(the)h(same)g(time)g(as)g(the)300 2471 y(section)f(descriptor)f(is)h -(created.)35 b(Some)20 b(targets)f(ma)o(y)g(lea)o(v)o(e)h(the)h(data)e(in)300 -2521 y(place)e(un)o(til)g(a)i Fh(bfd_get_section_contents)13 -b Fm(call)k(is)f(made.)22 b(Other)16 b(bac)o(k)300 2570 y(ends)f(ma)o(y)e -(read)h(in)h(all)h(the)e(data)f(at)h(once)g(-)h(F)l(or)e(example;)i(an)f -(S-record)h(\014le)300 2620 y(has)g(to)f(b)q(e)i(read)e(once)i(to)e -(determine)i(the)f(size)h(of)e(the)h(data.)k(An)c(IEEE-695)300 -2670 y(\014le)22 b(do)q(esn't)f(con)o(tain)h(ra)o(w)e(data)g(in)i(sections,)h -(but)e(data)g(and)g(relo)q(cation)0 2770 y Fk(c)6 b(y)g(g)g(n)g(u)g(s)36 -b(s)6 b(u)g(p)g(p)g(o)g(r)g(t)p 332 2761 1396 3 v 1421 w(Revision:)17 -b(1.5)p eop -%%Page: 9 11 -bop 0 -58 a Fk(Chapter)13 b(2:)k(BFD)c(front)g(end)p 413 -66 -680 3 v 703 w(DRAFT)p 1236 -66 V 705 w Fj(9)300 183 y Fm(expressions)j(in)o -(termixed,)g(so)e(the)h(data)f(area)h(has)g(to)f(b)q(e)h(parsed)h(to)e(get)g -(out)300 233 y(the)h(data)g(and)g(relo)q(cations.)0 368 y Fr(2.3.2)30 -b(Section)20 b(Output)300 459 y Fm(T)l(o)i(write)g(a)f(new)h(ob)s(ject)g(st)o -(yle)g(bfd,)h(the)f(v)m(arious)h(sections)f(to)f(b)q(e)i(writ-)300 -509 y(ten)j(ha)o(v)o(e)f(to)g(b)q(e)h(created.)52 b(They)26 -b(are)f(attatc)o(hed)g(to)g(the)g(bfd)h(in)h(the)300 559 y(same)19 -b(w)o(a)o(y)g(as)g(input)i(sections,)f(data)f(is)h(written)g(to)f(the)h -(sections)g(using)300 608 y Fh(bfd_set_section_contents)p Fm(.)300 -671 y(The)d(link)o(er)h(uses)g(the)f(\014elds)29 b Fh(output_section)15 -b Fm(and)27 b Fh(output_offset)16 b Fm(to)300 721 y(create)f(an)g(output)g -(\014le.)300 783 y(The)i(data)g(to)g(b)q(e)g(written)h(comes)f(from)f(input)i -(sections)g(attatc)o(hed)e(to)h(the)300 833 y(output)h(sections.)30 -b(The)18 b(output)g(section)h(structure)f(can)h(b)q(e)g(considered)g(a)300 -883 y(\014lter)14 b(for)f(the)h(input)h(section,)f(the)g(output)f(section)i -(determines)f(the)g(vma)f(of)300 933 y(the)h(output)h(data)e(and)i(the)f -(name,)g(but)h(the)f(input)i(section)f(determines)g(the)300 -982 y(o\013set)f(in)o(to)h(the)h(output)f(section)g(of)g(the)g(data)g(to)g(b) -q(e)g(written.)300 1045 y(Eg)e(to)f(create)h(a)f(section)i -Fh(")p Fm(O)p Fh(")p Fm(,)f(starting)f(at)g(0x100,)g(0x123)g(long,)h(con)o -(taining)300 1095 y(t)o(w)o(o)19 b(subsections,)j Fh(")p Fm(A)p -Fh(")e Fm(at)g(o\013set)g(0x0)f(\(ie)i(at)f(vma)g(0x100\))f(and)h -Fh(")p Fm(B)p Fh(")h Fm(at)300 1144 y(o\013set)14 b(0x20)h(\(ie)g(at)g(vma)f -(0x120\))g(the)h(structures)g(w)o(ould)h(lo)q(ok)f(lik)o(e:)300 -1186 y Fg(\013)p 325 1186 1326 2 v 1325 w(\010)p 300 1832 2 -623 v 386 1322 a Fh(section)23 b(name)238 b("A")433 1372 y(output_offset)70 -b(0x00)433 1422 y(size)286 b(0x20)433 1471 y(output_section)22 -b(----------->)46 b(section)23 b(name)95 b("O")1006 1521 y(|)g(vma)310 -b(0x100)386 1571 y(section)23 b(name)238 b("B")23 b(|)95 b(size)286 -b(0x123)433 1621 y(output_offset)70 b(0x20)95 b(|)433 1671 -y(size)286 b(0x103)71 b(|)433 1720 y(output_section)46 b(--------|)p -1677 1832 V 300 1858 a Fg(\012)p 325 1858 1326 2 v 1325 w(\011)0 -2042 y Fr(2.3.3)30 b(t)n(yp)r(edef)20 b(asection)300 2134 y -Fm(The)15 b(shap)q(e)h(of)f(a)g(section)h(struct:)390 2184 -y Fh(typedef)23 b(struct)g(sec)g({)300 2246 y Ff(The)c(name)f(of)g(the)g -(section,)h(the)g(name)f(isn't)g(a)g(cop)o(y)l(,)h(the)f(p)q(oin)o(ter)h(is)i -(the)300 2296 y(same)15 b(as)g(that)f(passed)i(to)e(bfd)p 835 -2296 14 2 v 17 w(mak)o(e)p 956 2296 V 16 w(section.)485 2346 -y Fh(CONST)24 b(char)f(*name;)300 2408 y Ff(The)15 b(next)h(section)f(in)i -(the)e(list)h(b)q(elonging)h(to)d(the)h(bfd,)h(or)e(NULL.)485 -2458 y Fh(struct)23 b(sec)h(*next;)300 2521 y Ff(The)14 b(\014eld)h(\015ags)f -(con)o(tains)g(attributes)f(of)h(the)g(section.)19 b(Some)14 -b(of)g(these)i(\015ags)300 2570 y(are)d(read)h(in)g(from)f(the)h(ob)s(ject)f -(\014le,)h(and)g(some)f(are)h(syn)o(thesized)g(from)f(other)300 -2620 y(information.)390 2670 y Fh(flagword)23 b(flags;)0 2770 -y Fk(c)6 b(y)g(g)g(n)g(u)g(s)36 b(s)6 b(u)g(p)g(p)g(o)g(r)g(t)p -332 2761 1396 3 v 1421 w(Revision:)17 b(1.5)p eop -%%Page: 10 12 -bop 0 -58 a Fk(Chapter)13 b(2:)k(BFD)c(front)g(end)p 413 -66 -669 3 v 691 w(DRAFT)p 1224 -66 V 695 w Fj(10)390 183 y Fh(#define)23 -b(SEC_NO_FLAGS)70 b(0x000)300 246 y Ff(T)l(ells)22 b(the)e(OS)h(to)e(allo)q -(cate)i(space)f(for)g(this)g(section)h(when)g(loaded.)35 b(This)300 -296 y(w)o(ould)16 b(clear)f(for)g(a)g(section)h(con)o(taining)f(debug)h -(information)g(only)l(.)390 346 y Fh(#define)23 b(SEC_ALLOC)142 -b(0x001)300 409 y Ff(T)l(ells)21 b(the)f(OS)g(to)f(load)h(the)f(section)h -(from)f(the)h(\014le)g(when)g(loading.)34 b(This)300 458 y(w)o(ould)16 -b(b)q(e)f(clear)h(for)f(a)g(.bss)f(section)390 508 y Fh(#define)23 -b(SEC_LOAD)166 b(0x002)300 571 y Ff(The)15 b(section)f(con)o(tains)h(data)f -(still)h(to)f(b)q(e)h(relo)q(cated,)g(so)f(there)g(will)i(b)q(e)f(some)300 -621 y(relo)q(cation)h(information)f(to)q(o.)390 671 y Fh(#define)23 -b(SEC_RELOC)142 b(0x004)300 733 y Ff(Obsolete)16 b(?)390 783 -y Fh(#define)23 b(SEC_BALIGN)118 b(0x008)300 846 y Ff(A)15 -b(signal)h(to)f(the)g(OS)h(that)e(the)i(section)f(con)o(tains)h(read)f(only)h -(data.)390 896 y Fh(#define)23 b(SEC_READONLY)70 b(0x010)300 -959 y Ff(The)15 b(section)h(con)o(tains)f(co)q(de)h(only)l(.)390 -1009 y Fh(#define)23 b(SEC_CODE)166 b(0x020)300 1071 y Ff(The)15 -b(section)h(con)o(tains)f(data)g(only)l(.)390 1121 y Fh(#define)23 -b(SEC_DATA)190 b(0x040)300 1184 y Ff(The)15 b(section)h(will)h(reside)f(in)g -(R)o(OM.)390 1234 y Fh(#define)23 b(SEC_ROM)190 b(0x080)300 -1297 y Ff(The)19 b(section)g(con)o(tains)g(constructor)e(information.)31 -b(This)19 b(section)g(t)o(yp)q(e)f(is)300 1347 y(used)13 b(b)o(y)g(the)f -(link)o(er)i(to)e(create)g(lists)h(of)f(constructors)g(and)h(destructors)g -(used)300 1396 y(b)o(y)34 b Fh(g++)p Ff(.)27 b(When)18 b(a)g(bac)o(k)g(end)g -(sees)g(a)g(sym)o(b)q(ol)g(whic)o(h)h(should)f(b)q(e)h(used)h(in)300 -1446 y(a)15 b(constructor)f(list,)i(it)g(creates)f(a)g(new)g(section)h(for)f -(the)g(t)o(yp)q(e)g(of)g(name)j(\(eg)300 1496 y Fh(__CTOR_LIST__)p -Ff(\),)12 b(attatc)o(hes)i(the)g(sym)o(b)q(ol)h(to)f(it)h(and)g(builds)h(a)f -(relo)q(cation.)300 1546 y(T)l(o)g(build)i(the)e(lists)g(of)g(constructors,)f -(all)i(the)f(link)o(er)h(has)f(to)h(to)f(is)g(catenate)300 -1596 y(all)e(the)g(sections)g(called)g Fh(__CTOR_LIST__)e Ff(and)j(relo)q -(cte)f(the)g(data)e(con)o(tained)300 1645 y(within)16 b(-)g(exactly)f(the)h -(op)q(erations)f(it)g(w)o(ould)j(p)q(eform)d(on)g(standard)g(data.)390 -1695 y Fh(#define)23 b(SEC_CONSTRUCTOR)f(0x100)300 1758 y Ff(The)17 -b(section)g(is)f(a)g(constuctor,)g(and)h(should)g(b)q(e)g(placed)h(at)d(the)i -(end)g(of)f(the)300 1808 y(..)390 1858 y Fh(#define)23 b -(SEC_CONSTRUCTOR_TEXT)e(0x1100)390 1907 y(#define)i(SEC_CONSTRUCTOR_DATA)e -(0x2100)390 1957 y(#define)i(SEC_CONSTRUCTOR_BSS)45 b(0x3100)300 -2020 y Ff(The)21 b(section)g(has)f(con)o(ten)o(ts)g(-)g(a)g(bss)h(section)g -(could)g(b)q(e)55 b Fh(SEC_ALLOC)19 b(|)300 2070 y(SEC_HAS_CONTENTS)p -Ff(,)13 b(a)h(debug)i(section)g(could)g(b)q(e)j Fh(SEC_HAS_CONTENTS)390 -2120 y(#define)k(SEC_HAS_CONTENTS)f(0x200)300 2183 y Ff(An)d(instruction)g -(to)f(the)g(link)o(er)i(not)e(to)f(output)i(sections)f(con)o(taining)24 -b(this)300 2232 y(\015ag)14 b(ev)o(en)h(if)g(they)g(ha)o(v)o(e)f(information) -h(whic)o(h)g(w)o(ould)g(normally)g(b)q(e)g(written.)390 2282 -y Fh(#define)23 b(SEC_NEVER_LOAD)f(0x400)300 2345 y Ff(The)15 -b(base)h(address)f(of)g(the)g(section)h(in)g(the)f(address)g(space)h(of)f -(the)g(target.)462 2395 y Fh(bfd_vma)22 b(vma;)300 2458 y Ff(The)16 -b(size)g(of)g(the)f(section)i(in)f(b)o(ytes)f(of)h(the)f(loaded)i(section.)22 -b(This)16 b(con)o(tains)300 2508 y(a)f(v)m(alue)h(ev)o(en)g(if)g(the)f -(section)h(has)f(no)g(con)o(ten)o(ts)f(\(eg,)h(the)g(size)h(of)f -Fh(.bss)p Ff(\).)462 2557 y Fh(bfd_size_type)22 b(size;)300 -2620 y Ff(If)14 b(this)h(section)g(is)f(going)g(to)g(b)q(e)h(output,)e(then)i -(this)f(v)m(alue)i(is)e(the)j(o\013set)c(in)o(to)300 2670 y(the)k(output)g -(section)g(of)g(the)g(\014rst)f(b)o(yte)h(in)h(the)f(input)i(section.)25 -b(Eg,)17 b(if)h(this)0 2770 y Fk(c)6 b(y)g(g)g(n)g(u)g(s)36 -b(s)6 b(u)g(p)g(p)g(o)g(r)g(t)p 332 2761 1396 3 v 1421 w(Revision:)17 -b(1.5)p eop -%%Page: 11 13 -bop 0 -58 a Fk(Chapter)13 b(2:)k(BFD)c(front)g(end)p 413 -66 -669 3 v 691 w(DRAFT)p 1224 -66 V 695 w Fj(11)300 183 y Ff(w)o(as)g(going)g -(to)g(start)f(at)h(the)g(100th)g(b)o(yte)g(in)i(the)h(output)d(section,)h -(this)g(v)m(alue)300 233 y(w)o(ould)i(b)q(e)f(100.)462 283 -y Fh(bfd_vma)22 b(output_offset;)300 350 y Ff(The)15 b(output)g(section)h -(through)f(whic)o(h)h(to)f(map)g(on)g(output.)462 400 y Fh(struct)23 -b(sec)g(*output_section;)300 467 y Ff(The)f(alignmen)o(t)g(requiremen)o(t)g -(of)g(the)f(section,)j(as)d(an)h(exp)q(onen)o(t)g(-)g(eg)f(3)300 -517 y(aligns)16 b(to)f(2)p Fh(^)p Ff(3)f(\(or)g(8\))462 567 -y Fh(unsigned)22 b(int)i(alignment_power;)300 634 y Ff(If)14 -b(an)f(input)h(section,)g(a)f(p)q(oin)o(ter)h(to)e(a)h(v)o(ector)g(of)g(relo) -q(cation)h(records)f(for)j(the)300 684 y(data)f(in)h(this)f(section.)462 -733 y Fh(struct)23 b(reloc_cache_entry)e(*relocation;)300 801 -y Ff(If)c(an)g(output)g(section,)h(a)f(p)q(oin)o(ter)h(to)e(a)h(v)o(ector)f -(of)h(p)q(oin)o(ters)g(to)i(relo)q(cation)300 850 y(records)c(for)g(the)g -(data)f(in)i(this)g(section.)462 900 y Fh(struct)23 b(reloc_cache_entry)e -(**orelocation;)300 967 y Ff(The)15 b(n)o(um)o(b)q(er)h(of)f(relo)q(cation)h -(records)f(in)h(one)f(of)g(the)g(ab)q(o)o(v)o(e)462 1017 y -Fh(unsigned)22 b(reloc_count;)300 1084 y Ff(Whic)o(h)16 b(section)g(is)f(it)h -(0..n)o(th)462 1134 y Fh(int)23 b(index;)300 1201 y Ff(Information)15 -b(b)q(elo)o(w)h(is)g(bac)o(k)f(end)h(sp)q(eci\014c)i(-)d(and)h(not)f(alw)o(a) -o(ys)f(used)i(or)i(up-)300 1251 y(dated)300 1318 y(File)e(p)q(osition)h(of)d -(section)i(data)462 1368 y Fh(file_ptr)22 b(filepos;)300 1435 -y Ff(File)16 b(p)q(osition)h(of)d(relo)q(cation)i(info)462 -1485 y Fh(file_ptr)22 b(rel_filepos;)300 1552 y Ff(File)16 -b(p)q(osition)h(of)d(line)j(data)462 1602 y Fh(file_ptr)22 -b(line_filepos;)300 1669 y Ff(P)o(oin)o(ter)15 b(to)f(data)h(for)g -(applications)462 1719 y Fh(PTR)23 b(userdata;)462 1769 y(struct)g -(lang_output_section)e(*otheruserdata;)300 1836 y Ff(A)o(ttac)o(hed)15 -b(line)i(n)o(um)o(b)q(er)e(information)462 1886 y Fh(alent)23 -b(*lineno;)300 1953 y Ff(Num)o(b)q(er)16 b(of)e(line)j(n)o(um)o(b)q(er)f -(records)462 2003 y Fh(unsigned)22 b(int)i(lineno_count;)300 -2070 y Ff(When)14 b(a)e(section)i(is)g(b)q(eing)h(output,)e(this)g(v)m(alue)i -(c)o(hanges)e(as)g(more)i(linen)o(um-)300 2120 y(b)q(ers)h(are)e(written)i -(out)462 2170 y Fh(file_ptr)22 b(moving_line_filepos;)300 2237 -y Ff(what)15 b(the)g(section)h(n)o(um)o(b)q(er)f(is)h(in)g(the)f(target)f(w)o -(orld)462 2287 y Fh(unsigned)22 b(int)i(target_index;)462 2336 -y(PTR)f(used_by_bfd;)300 2404 y Ff(If)18 b(this)g(is)g(a)g(constructor)e -(section)j(then)f(here)g(is)g(a)f(list)i(of)e(the)j(relo)q(cations)300 -2453 y(created)15 b(to)g(relo)q(cate)g(items)h(within)g(it.)462 -2503 y Fh(struct)23 b(relent_chain)f(*constructor_chain;)300 -2570 y Ff(The)15 b(bfd)h(whic)o(h)g(o)o(wns)f(the)g(section.)462 -2620 y Fh(bfd)23 b(*owner;)390 2670 y(})h(asection)e(;)0 2770 -y Fk(c)6 b(y)g(g)g(n)g(u)g(s)36 b(s)6 b(u)g(p)g(p)g(o)g(r)g(t)p -332 2761 1396 3 v 1421 w(Revision:)17 b(1.5)p eop -%%Page: 12 14 -bop 0 -58 a Fk(Chapter)13 b(2:)k(BFD)c(front)g(end)p 413 -66 -669 3 v 691 w(DRAFT)p 1224 -66 V 695 w Fj(12)0 183 y Fr(2.3.4)30 -b(section)20 b(protot)n(yp)r(es)0 346 y(2.3.4.1)30 b(bfd)p -296 346 19 3 v 22 w(get)p 401 346 V 21 w(section)p 607 346 -V 22 w(b)n(y)p 693 346 V 23 w(name)300 437 y Fm(Runs)19 b(through)g(the)f -(pro)o(vided)i Ff(abfd)g Fm(and)f(returns)f(the)39 b Fh(asection)18 -b Fm(who's)300 487 y(name)c(matc)o(hes)g(that)g(pro)o(vided,)h(otherwise)g -(NULL.)g(See)g(Section)g(2.3)f([Sec-)300 537 y(tions],)h(page)g(8,)f(for)h -(more)g(information.)390 587 y Fh(PROTO\(asection)22 b(*,)i -(bfd_get_section_by_name)o(,)485 637 y(\(bfd)g(*abfd,)f(CONST)g(char)g -(*name\)\);)0 770 y Fr(2.3.4.2)30 b(bfd)p 296 770 V 22 w(mak)n(e)p -457 770 V 22 w(section)300 862 y Fm(This)13 b(function)g(creates)f(a)h(new)f -(empt)o(y)g(section)h(called)i Ff(name)g Fm(and)d(attatc)o(hes)300 -912 y(it)i(to)g(the)g(end)h(of)f(the)g(c)o(hain)h(of)f(sections)h(for)e -Ff(bfd)p Fm(.)20 b(An)15 b(attempt)e(to)g(create)h(a)300 961 -y(section)i(with)h(a)e(name)h(whic)o(h)g(is)h(already)f(in)h(use,)e(returns)h -(the)g(old)g(section)300 1011 y(b)o(y)f(that)g(name)g(instead.)300 -1074 y(P)o(ossible)h(errors)f(are:)300 1136 y Fh(invalid_operation)450 -1186 y Fm(If)g(output)g(has)h(already)f(started)f(for)h(this)h(bfd.)300 -1248 y Fh(no_memory)450 1298 y Fm(If)f(obstac)o(k)g(allo)q(c)h(fails.)390 -1348 y Fh(PROTO\(asection)22 b(*,)i(bfd_make_section,)d(\(bfd)i(*,)h(CONST)f -(char)390 1398 y(*name\)\);)0 1531 y Fr(2.3.4.3)30 b(bfd)p -296 1531 V 22 w(set)p 394 1531 V 22 w(section)p 601 1531 V -22 w(\015ags)300 1623 y Fm(A)o(ttempts)15 b(to)h(set)f(the)h(attributes)g(of) -g(the)g(section)h(named)f(in)h(the)f(bfd)g(sup-)300 1673 y(plied)i(to)e(the)g -(v)m(alue.)25 b(Returns)16 b(true)h(on)f(success,)h(false)f(on)h(error.)22 -b(P)o(ossible)300 1722 y(error)14 b(returns)i(are:)300 1785 -y Fh(invalid)e(operation)450 1835 y Fm(The)21 b(section)g(cannot)g(ha)o(v)o -(e)f(one)h(or)f(more)g(of)h(the)f(attributes)h(re-)450 1884 -y(quested.)h(F)l(or)15 b(example,)h(a)g(.bss)f(section)h(in)k -Fh(a.out)15 b Fm(ma)o(y)g(not)g(ha)o(v)o(e)450 1934 y(the)g -Fh(SEC_HAS_CONTENTS)e Fm(\014eld)k(set.)390 1984 y Fh(PROTO\(boolean,)22 -b(bfd_set_section_flags,)557 2034 y(\(bfd)h(*,)h(asection)f(*,)g -(flagword\)\);)0 2168 y Fr(2.3.4.4)30 b(bfd)p 296 2168 V 22 -w(map)p 433 2168 V 22 w(o)n(v)n(er)p 567 2168 V 23 w(sections)300 -2259 y Fm(Calls)20 b(the)g(pro)o(vided)h(function)f Ff(func)j -Fm(for)c(eac)o(h)h(section)g(attatc)o(hed)f(to)g(the)300 2309 -y(bfd)14 b Ff(abfd)p Fm(,)g(passing)h Ff(ob)s(j)f Fm(as)g(an)g(argumen)o(t.) -19 b(The)14 b(function)h(will)g(b)q(e)g(called)g(as)300 2359 -y(if)h(b)o(y)438 2408 y Fh(func\(abfd,)22 b(the_section,)g(obj\);)390 -2458 y(PROTO\(void,)g(bfd_map_over_sections,)676 2508 y(\(bfd)i(*abfd,)f -(void)g(\(*func\)\(\),)g(PTR)g(obj\)\);)300 2570 y Fm(This)13 -b(is)g(the)f(prefered)h(metho)q(d)g(for)e(iterating)i(o)o(v)o(er)e(sections,) -i(an)g(alternativ)o(e)300 2620 y(w)o(ould)j(b)q(e)f(to)g(use)h(a)e(lo)q(op:) -462 2670 y Fh(section)22 b(*p;)0 2770 y Fk(c)6 b(y)g(g)g(n)g(u)g(s)36 -b(s)6 b(u)g(p)g(p)g(o)g(r)g(t)p 332 2761 1396 3 v 1421 w(Revision:)17 -b(1.5)p eop -%%Page: 13 15 -bop 0 -58 a Fk(Chapter)13 b(2:)k(BFD)c(front)g(end)p 413 -66 -669 3 v 691 w(DRAFT)p 1224 -66 V 695 w Fj(13)462 183 y Fh(for)23 -b(\(p)h(=)f(abfd->sections;)f(p)i(!=)f(NULL;)h(p)f(=)h(p->next\))533 -233 y(func\(abfd,)f(p,)g(...\))0 366 y Fr(2.3.4.5)30 b(bfd)p -296 366 19 3 v 22 w(set)p 394 366 V 22 w(section)p 601 366 -V 22 w(size)300 457 y Fm(Sets)20 b Ff(section)g Fm(to)g(the)g(size)h -Ff(v)m(al)p Fm(.)34 b(If)21 b(the)f(op)q(eration)g(is)g(ok,)h(then)48 -b Fh(true)19 b Fm(is)300 507 y(returned,)c(else)h Fh(false)p -Fm(.)300 569 y(P)o(ossible)g(error)f(returns:)300 632 y Fh(invalid_operation) -450 681 y Fm(W)l(riting)h(has)f(started)f(to)h(the)g(bfd,)g(so)g(setting)g -(the)h(size)g(is)f(in)o(v)m(alid)390 731 y Fh(PROTO\(boolean,)22 -b(bfd_set_section_size,)509 781 y(\(bfd)i(*,)f(asection)g(*,)h(bfd_size_type) -e(val\)\);)0 914 y Fr(2.3.4.6)30 b(bfd)p 296 914 V 22 w(set)p -394 914 V 22 w(section)p 601 914 V 22 w(con)n(ten)n(ts)300 -1005 y Fm(Sets)14 b(the)f(con)o(ten)o(ts)g(of)g(the)h(section)g -Ff(section)h Fm(in)f(bfd)g Ff(abfd)h Fm(to)e(the)h(data)f(start-)300 -1055 y(ing)19 b(in)h(memory)e(at)g Ff(data)p Fm(.)29 b(The)19 -b(data)f(is)h(written)f(to)g(the)h(output)f(section)300 1105 -y(starting)d(at)f(o\013set)g Ff(o\013set)i Fm(for)e Ff(coun)o(t)i -Fm(b)o(ytes.)300 1167 y(Normally)g Fh(true)e Fm(is)i(returned,)f(else)h -Fh(false)p Fm(.)j(P)o(ossible)e(error)d(returns)h(are:)300 -1229 y Fh(no_contents)450 1279 y Fm(The)20 b(output)f(section)h(do)q(es)g -(not)g(ha)o(v)o(e)f(the)46 b Fh(SEC_HAS_CONTENTS)450 1329 y -Fm(attribute,)15 b(so)f(nothing)i(can)f(b)q(e)h(written)g(to)e(it.)300 -1391 y Fh(and)h(some)f(more)h(too)300 1454 y Fm(This)c(routine)f(is)h(fron)o -(t)e(end)i(to)f(the)g(bac)o(k)g(end)h(function)g Fh(_bfd_set_section_conten)o -(ts)p Fm(.)p 2166 1458 21 36 v 390 1503 a Fh(PROTO\(boolean,)22 -b(bfd_set_section_contents,)605 1553 y(\(bfd)h(*abfd,)605 1603 -y(asection)g(*section,)605 1653 y(PTR)g(data,)605 1703 y(file_ptr)g(offset,) -605 1753 y(bfd_size_type)f(count\)\);)0 1885 y Fr(2.3.4.7)30 -b(bfd)p 296 1885 19 3 v 22 w(get)p 401 1885 V 21 w(section)p -607 1885 V 22 w(con)n(ten)n(ts)300 1977 y Fm(This)13 b(function)h(reads)f -(data)f(from)g Ff(section)h Fm(in)g(bfd)h Ff(abfd)g Fm(in)o(to)f(memory)f -(start-)300 2027 y(ing)j(at)f Ff(lo)q(cation)p Fm(.)21 b(The)15 -b(data)f(is)h(read)f(at)g(an)h(o\013set)f(of)g Ff(o\013set)h -Fm(from)e(the)i(start)300 2076 y(of)g(the)g(input)h(section,)g(and)f(is)h -(read)f(for)f Ff(coun)o(t)i Fm(b)o(ytes.)300 2139 y(If)e(the)g(con)o(ten)o -(ts)f(of)h(a)g(constuctor)f(with)h(the)g Fh(SEC_CONSTUCTOR)e -Fm(\015ag)i(set)f(are)300 2188 y(requested,)i(then)h(the)f -Ff(lo)q(cation)h Fm(is)g(\014lled)h(with)e(zero)q(es.)300 2251 -y(If)g(no)h(errors)e(o)q(ccur,)h Fh(true)g Fm(is)h(returned,)f(else)h -Fh(false)p Fm(.)j(P)o(ossible)d(errors)f(are:)300 2313 y Fh(unknown)f(yet)390 -2363 y(PROTO\(boolean,)22 b(bfd_get_section_contents,)581 2413 -y(\(bfd)h(*abfd,)g(asection)g(*section,)g(PTR)g(location,)605 -2463 y(file_ptr)g(offset,)f(bfd_size_type)h(count\)\);)0 2770 -y Fk(c)6 b(y)g(g)g(n)g(u)g(s)36 b(s)6 b(u)g(p)g(p)g(o)g(r)g(t)p -332 2761 1396 3 v 1421 w(Revision:)17 b(1.5)p eop -%%Page: 14 16 -bop 0 -58 a Fk(Chapter)13 b(2:)k(BFD)c(front)g(end)p 413 -66 -669 3 v 691 w(DRAFT)p 1224 -66 V 695 w Fj(14)0 183 y Fn(2.4)33 -b(Sym)n(b)r(ols)300 352 y Fm(*bfd*)17 b(trys)f(to)g(main)o(tain)i(as)e(m)o -(uc)o(h)h(sym)o(b)q(ol)h(information)f(as)f(it)h(can)g(when)300 -401 y(it)i(mo)o(v)o(es)g(information)g(from)f(\014le)i(to)f(\014le.)32 -b(*bfd*)19 b(passes)g(information)h(to)300 451 y(applications)f(though)f(the) -34 b Fh(asymbol)17 b Fm(structure.)27 b(When)18 b(the)g(application)300 -501 y(requests)g(the)g(sym)o(b)q(ol)g(table,)h(BFD)e(reads)h(the)g(table)h -(in)g(the)f(nativ)o(e)g(form)300 551 y(and)13 b(translates)g(parts)g(of)g(it) -g(in)o(to)g(the)h(in)o(ternal)g(format.)k(T)l(o)13 b(main)o(tain)g(more)300 -601 y(than)k(the)g(infomation)g(passed)h(to)e(applications)j(some)d(targets)g -(k)o(eep)h(some)300 650 y(information)j('b)q(ehind)h(the)e(sceans',)h(in)g(a) -g(structure)f(only)h(the)f(particular)300 700 y(bac)o(k)h(end)g(kno)o(ws)g -(ab)q(out.)33 b(F)l(or)20 b(example,)h(the)f(co\013)f(bac)o(k)h(end)h(k)o -(eeps)f(the)300 750 y(original)j(sym)o(b)q(ol)f(table)h(structure)e(as)h(w)o -(ell)h(as)e(the)h(canonical)h(structure)300 800 y(when)c(a)g(*bfd*)f(is)h -(read)g(in.)31 b(On)20 b(output,)f(the)g(co\013)f(bac)o(k)g(end)i(can)f -(recon-)300 850 y(struct)e(the)g(output)h(sym)o(b)q(ol)f(table)h(so)f(that)g -(no)h(information)f(is)h(lost,)g(ev)o(en)300 899 y(information)d(unique)h(to) -d(co\013)h(whic)o(h)h(*bfd*)g(do)q(esn't)f(kno)o(w)g(or)g(understand.)300 -949 y(If)19 b(a)g(co\013)f(sym)o(b)q(ol)h(table)h(w)o(as)e(read,)h(but)g(w)o -(as)g(written)g(through)f(an)h(a.out)300 999 y(bac)o(k)g(end,)i(all)f(the)f -(co\013)g(sp)q(eci\014c)i(information)e(w)o(ould)h(b)q(e)g(lost.)32 -b(\(..)f(un)o(til)300 1049 y(BFD)15 b(2)g(:\).)300 1188 y(The)e(sym)o(b)q(ol) -g(table)g(of)f(a)g(bfd)h(is)g(not)g(necessarily)h(read)e(in)i(un)o(til)f(a)g -(canonical-)300 1238 y(ize)k(request)f(is)g(made.)22 b(Then)17 -b(the)f(bfd)g(bac)o(k)g(end)g(\014lls)h(in)g(a)f(table)g(pro)o(vided)300 -1288 y(b)o(y)f(the)g(application)i(with)f(p)q(oin)o(ters)f(to)g(the)g -(canonical)i(information.)300 1427 y(T)l(o)j(output)g(sym)o(b)q(ols,)h(the)g -(application)h(pro)o(vides)e(BFD)g(with)h(a)f(table)g(of)300 -1477 y(p)q(oin)o(ters)j(to)e(p)q(oin)o(ters)i(to)63 b Fh(asymbol)p -Fm(s.)40 b(This)23 b(allo)o(ws)f(applications)i(lik)o(e)300 -1527 y(the)16 b(link)o(er)i(to)d(output)h(a)g(sym)o(b)q(ol)h(as)f(read,)g -(since)h(the)f('b)q(ehind)i(the)f(sceens')300 1576 y(information)e(will)i(b)q -(e)f(still)h(a)o(v)m(ailable.)0 2402 y Fr(2.4.1)30 b(Reading)20 -b(Sym)n(b)r(ols)300 2570 y Fm(There)13 b(are)f(t)o(w)o(o)f(stages)g(to)h -(reading)h(a)f(sym)o(b)q(ol)h(table)g(from)e(a)i(bfd;)g(allo)q(cating)300 -2620 y(storage,)i(and)h(the)g(actual)g(reading)h(pro)q(cess.)22 -b(This)17 b(is)f(an)g(excerpt)h(from)e(an)300 2670 y(appliction)i(whic)o(h)f -(reads)f(the)h(sym)o(b)q(ol)f(table:)0 2770 y Fk(c)6 b(y)g(g)g(n)g(u)g(s)36 -b(s)6 b(u)g(p)g(p)g(o)g(r)g(t)p 332 2761 1396 3 v 1421 w(Revision:)17 -b(1.5)p eop -%%Page: 15 17 -bop 0 -58 a Fk(Chapter)13 b(2:)k(BFD)c(front)g(end)p 413 -66 -669 3 v 691 w(DRAFT)p 1224 -66 V 695 w Fj(15)300 26 y Fg(\013)p -325 26 1326 2 v 1325 w(\010)p 300 1021 2 972 v 362 112 a Fh(unsigned)23 -b(int)g(storage_needed;)362 162 y(asymbol)g(**symbol_table;)362 -212 y(unsigned)g(int)g(number_of_symbols;)362 262 y(unsigned)g(int)g(i;)362 -361 y(storage_needed)f(=)i(get_symtab_upper_bound)c(\(abfd\);)362 -461 y(if)j(\(storage_needed)f(==)i(0\))f({)433 511 y(return)g(;)362 -560 y(})362 610 y(symbol_table)f(=)i(\(asymbol)f(**\))g(malloc)g -(\(storage_needed\);)410 660 y(...)362 710 y(number_of_symbols)e(=)433 -760 y(bfd_canonicalize_symtab)g(\(abfd,)i(symbol_table\);)362 -859 y(for)g(\(i)h(=)g(0;)f(i)h(<)g(number_of_symbols;)d(i++\))i({)433 -909 y(process_symbol)f(\(symbol_table[i]\);)362 959 y(})p 1677 -1021 V 300 1047 a Fg(\012)p 325 1047 1326 2 v 1325 w(\011)300 -1228 y Fm(All)16 b(storage)d(for)g(the)i(sym)o(b)q(ols)g(themselv)o(es)f(is)h -(in)g(an)g(obstac)o(k)e(connected)j(to)300 1278 y(the)f(bfd,)g(and)h(is)g -(freed)f(when)h(the)f(bfd)h(is)f(closed.)0 2030 y Fr(2.4.2)30 -b(W)-5 b(riting)20 b(Sym)n(b)r(ols)300 2190 y Fm(W)l(riting)13 -b(of)f(a)f(sym)o(b)q(ol)i(table)g(is)f(automatic)g(when)h(a)f(bfd)g(op)q(en)h -(for)f(writing)g(is)300 2240 y(closed.)21 b(The)16 b(application)h(attatc)o -(hes)d(a)h(v)o(ector)g(of)g(p)q(oin)o(ters)h(to)f(p)q(oin)o(ters)h(to)300 -2290 y(sym)o(b)q(ols)e(to)g(the)g(bfd)h(b)q(eing)g(written,)f(and)h(\014lls)g -(in)h(the)e(sym)o(b)q(ol)g(coun)o(t.)20 b(The)300 2340 y(close)11 -b(and)f(clean)o(up)i(co)q(de)e(reads)g(through)g(the)g(table)h(pro)o(vided)g -(and)f(p)q(erforms)300 2389 y(all)21 b(the)g(necessary)f(op)q(erations.)35 -b(The)21 b(outputing)f(co)q(de)h(m)o(ust)f(alw)o(a)o(ys)f(b)q(e)300 -2439 y(pro)o(vided)c(with)g(an)g('o)o(wned')e(sym)o(b)q(ol;)i(one)g(whic)o(h) -g(has)f(come)h(from)e(another)300 2489 y(bfd,)i(or)g(one)g(whic)o(h)h(has)f -(b)q(een)i(created)e(using)h Fh(bfd_make_empty_symbol)p Fm(.)300 -2620 y(An)j(example)h(sho)o(wing)f(the)g(creation)g(of)g(a)f(sym)o(b)q(ol)i -(table)f(with)g(only)h(one)300 2670 y(elemen)o(t:)0 2770 y -Fk(c)6 b(y)g(g)g(n)g(u)g(s)36 b(s)6 b(u)g(p)g(p)g(o)g(r)g(t)p -332 2761 1396 3 v 1421 w(Revision:)17 b(1.5)p eop -%%Page: 16 18 -bop 0 -58 a Fk(Chapter)13 b(2:)k(BFD)c(front)g(end)p 413 -66 -669 3 v 691 w(DRAFT)p 1224 -66 V 695 w Fj(16)300 26 y Fg(\013)p -325 26 1326 2 v 1325 w(\010)p 300 1469 2 1420 v 314 112 a Fh(#include)23 -b("bfd.h")314 162 y(main\(\))314 212 y({)362 262 y(bfd)g(*abfd;)362 -311 y(asymbol)g(*ptrs[2];)362 361 y(asymbol)g(*new;)362 461 -y(abfd)g(=)h(bfd_openw\("foo","a.out-su)o(nos-big")o(\);)362 -511 y(bfd_set_format\(abfd,)d(bfd_object\);)362 560 y(new)i(=)h -(bfd_make_empty_symbol\(abfd)o(\);)362 610 y(new->name)e(=)i("dummy_symbol";) -362 660 y(new->section)e(=)i(\(asection)e(*\)0;)362 710 y(new->flags)g(=)i -(BSF_ABSOLUTE)e(|)i(BSF_GLOBAL;)362 760 y(new->value)e(=)i(0x12345;)362 -859 y(ptrs[0])f(=)g(new;)362 909 y(ptrs[1])g(=)g(\(asymbol)g(*\)0;)362 -1009 y(bfd_set_symtab\(abfd,)e(ptrs,)i(1\);)362 1059 y(bfd_close\(abfd\);)314 -1108 y(})314 1208 y(./makesym)314 1258 y(nm)h(foo)314 1308 -y(00012345)f(A)h(dummy_symbol)p 1677 1469 V 300 1495 a Fg(\012)p -325 1495 1326 2 v 1325 w(\011)300 1607 y Fm(Man)o(y)14 b(formats)g(cannot)h -(represen)o(t)g(arbitary)f(sym)o(b)q(ol)i(information;)f(for)f(in-)300 -1657 y(stance)e(the)h Fh(a.out)f Fm(ob)s(ject)g(format)f(do)q(es)i(not)f -(allo)o(w)h(an)f(arbitary)h(n)o(um)o(b)q(er)f(of)300 1707 y(sections.)20 -b(A)15 b(sym)o(b)q(ol)g(p)q(oin)o(ting)h(to)e(a)h(section)g(whic)o(h)g(is)h -(not)e(one)h(of)f Fh(.text)p Fm(,)300 1757 y Fh(.data)g Fm(or)h -Fh(.bss)g Fm(cannot)g(b)q(e)h(describ)q(ed.)0 1881 y Fr(2.4.3)30 -b(t)n(yp)r(edef)20 b(asym)n(b)r(ol)300 1973 y Fm(An)15 b Fh(asymbol)g -Fm(has)g(the)g(form:)390 2022 y Fh(typedef)23 b(struct)g(symbol_cache_entry) -390 2072 y({)300 2135 y Ff(A)d(p)q(oin)o(ter)g(to)e(the)i(bfd)g(whic)o(h)g(o) -o(wns)f(the)h(sym)o(b)q(ol.)33 b(This)20 b(information)f(is)300 -2184 y(necessary)14 b(so)f(that)g(a)g(bac)o(k)g(end)h(can)g(w)o(ork)e(out)i -(what)f(additional)h(\(in)o(visible)300 2234 y(to)j(the)e(application)i -(writer\))e(information)g(is)h(carried)g(with)f(the)g(sym)o(b)q(ol.)438 -2284 y Fh(struct)23 b(_bfd)g(*the_bfd;)300 2346 y Ff(The)14 -b(text)g(of)f(the)h(sym)o(b)q(ol.)20 b(The)14 b(name)g(is)g(left)h(alone,)f -(and)g(not)g(copied)h(-)f(the)300 2396 y(application)j(ma)o(y)d(not)h(alter)g -(it.)462 2446 y Fh(CONST)23 b(char)g(*name;)300 2508 y Ff(The)15 -b(v)m(alue)i(of)e(the)g(sym)o(b)q(ol.)462 2558 y Fh(symvalue)22 -b(value;)300 2620 y Ff(A)o(ttributes)15 b(of)g(a)g(sym)o(b)q(ol:)390 -2670 y Fh(#define)23 b(BSF_NO_FLAGS)94 b(0x00)0 2770 y Fk(c)6 -b(y)g(g)g(n)g(u)g(s)36 b(s)6 b(u)g(p)g(p)g(o)g(r)g(t)p 332 -2761 1396 3 v 1421 w(Revision:)17 b(1.5)p eop -%%Page: 17 19 -bop 0 -58 a Fk(Chapter)13 b(2:)k(BFD)c(front)g(end)p 413 -66 -669 3 v 691 w(DRAFT)p 1224 -66 V 695 w Fj(17)300 183 y Ff(The)18 -b(sym)o(b)q(ol)g(has)g(lo)q(cal)h(scop)q(e;)34 b Fh(static)17 -b Ff(in)34 b Fh(C)p Ff(.)27 b(The)18 b(v)m(alue)h(is)h(the)e(o\013set)300 -233 y(in)o(to)d(the)g(section)h(of)f(the)g(data.)390 283 y -Fh(#define)23 b(BSF_LOCAL)g(0x01)300 349 y Ff(The)16 b(sym)o(b)q(ol)g(has)f -(global)h(scop)q(e;)g(initialized)j(data)14 b(in)k Fh(C)p Ff(.)j(The)16 -b(v)m(alue)j(is)d(the)300 399 y(o\013set)e(in)o(to)h(the)h(section)f(of)g -(the)g(data.)390 449 y Fh(#define)23 b(BSF_GLOBAL)f(0x02)300 -515 y Ff(Obsolete)390 565 y Fh(#define)h(BSF_IMPORT)f(0x04)300 -631 y Ff(The)13 b(sym)o(b)q(ol)g(has)f(global)h(scop)q(e,)g(and)g(is)g(exp)q -(orted.)19 b(The)13 b(v)m(alue)g(is)g(the)g(o\013set)300 681 -y(in)o(to)i(the)g(section)h(of)f(the)g(data.)390 730 y Fh(#define)23 -b(BSF_EXPORT)f(0x08)300 797 y Ff(The)15 b(sym)o(b)q(ol)h(is)g(unde\014ned.)21 -b Fh(extern)15 b Ff(in)h Fh(C)p Ff(.)j(The)d(v)m(alue)g(has)f(no)h(meaning.) -390 846 y Fh(#define)23 b(BSF_UNDEFINED)f(0x10)300 913 y Ff(The)17 -b(sym)o(b)q(ol)g(is)g(common,)f(initialized)k(to)c(zero;)g(default)h(in)26 -b Fh(C)p Ff(.)d(The)d(v)m(alue)300 962 y(is)c(the)f(size)h(of)f(the)g(ob)s -(ject)g(in)h(b)o(ytes.)390 1012 y Fh(#define)23 b(BSF_FORT_COMM)f(0x20)300 -1078 y Ff(A)16 b(normal)21 b Fh(C)16 b Ff(sym)o(b)q(ol)g(w)o(ould)g(b)q(e)h -(one)f(of:)27 b Fh(BSF_LOCAL)p Ff(,)19 b Fh(BSF_FORT_COMM)p -Ff(,)300 1128 y Fh(BSF_UNDEFINED)13 b Ff(or)i Fh(BSF_EXPORT|BSD_GLOBAL)300 -1194 y Ff(The)g(sym)o(b)q(ol)f(is)h(a)f(debugging)i(record.)j(The)c(v)m(alue) -g(has)g(an)f(arbitary)g(mean-)300 1244 y(ing.)390 1294 y Fh(#define)23 -b(BSF_DEBUGGING)f(0x40)300 1360 y Ff(The)d(sym)o(b)q(ol)g(has)g(no)g(section) -g(attac)o(hed,)g(an)o(y)f(v)m(alue)i(is)g(the)f(actual)g(v)m(alue)300 -1410 y(and)e(is)f(not)f(a)g(relativ)o(e)g(o\013set)g(to)f(a)h(section.)390 -1460 y Fh(#define)23 b(BSF_ABSOLUTE)f(0x80)300 1526 y Ff(Used)16 -b(b)o(y)f(the)g(link)o(er)390 1576 y Fh(#define)23 b(BSF_KEEP)190 -b(0x10000)390 1625 y(#define)23 b(BSF_WARNING)118 b(0x20000)390 -1675 y(#define)23 b(BSF_KEEP_G)142 b(0x80000)300 1741 y Ff(Un)o(used)390 -1791 y Fh(#define)23 b(BSF_WEAK)190 b(0x100000)390 1841 y(#define)23 -b(BSF_CTOR)190 b(0x200000)390 1891 y(#define)23 b(BSF_FAKE)190 -b(0x400000)300 1957 y Ff(The)15 b(sym)o(b)q(ol)h(used)g(to)e(b)q(e)i(a)f -(common)g(sym)o(b)q(ol,)g(but)g(no)o(w)g(it)h(is)f(allo)q(cated.)390 -2007 y Fh(#define)23 b(BSF_OLD_COMMON)46 b(0x800000)300 2073 -y Ff(The)15 b(default)h(v)m(alue)h(for)d(common)h(data.)390 -2123 y Fh(#define)23 b(BFD_FORT_COMM_DEFAULT_VAL)o(UE)e(0)300 -2189 y Ff(In)14 b(some)g(\014les)g(the)g(t)o(yp)q(e)g(of)f(a)h(sym)o(b)q(ol)g -(sometimes)f(alters)h(its)g(lo)q(cation)g(in)h(an)300 2239 -y(output)i(\014le)h(-)f(ie)g(in)h(co\013)e(a)27 b Fh(ISFCN)16 -b Ff(sym)o(b)q(ol)h(whic)o(h)h(is)f(also)27 b Fh(C_EXT)17 b -Ff(sym)o(b)q(ol)300 2289 y(app)q(ears)d(where)g(it)g(w)o(as)f(declared)i(and) -e(not)h(at)f(the)h(end)g(of)f(a)h(section.)39 b(This)300 2338 -y(bit)16 b(is)f(set)g(b)o(y)h(the)f(target)f(bfd)h(part)g(to)f(con)o(v)o(ey)h -(this)h(information.)390 2388 y Fh(#define)23 b(BSF_NOT_AT_END)93 -b(0x40000)300 2454 y Ff(Signal)16 b(that)f(the)g(sym)o(b)q(ol)h(is)f(the)h -(lab)q(el)h(of)d(constructor)h(section.)390 2504 y Fh(#define)23 -b(BSF_CONSTRUCTOR)69 b(0x1000000)438 2554 y(flagword)22 b(flags;)300 -2620 y Ff(Aoin)o(ter)11 b(to)f(the)h(section)g(to)f(whic)o(h)i(this)f(sym)o -(b)q(ol)g(is)h(relativ)o(e,)g(or)e(0)g(if)i(the)h(sym-)300 -2670 y(b)q(ol)j(is)f(absolute)g(or)f(unde\014ned.)22 b(Note)14 -b(that)h(it)g(is)g(not)f(su\016cien)o(t)i(to)e(set)i(this)0 -2770 y Fk(c)6 b(y)g(g)g(n)g(u)g(s)36 b(s)6 b(u)g(p)g(p)g(o)g(r)g(t)p -332 2761 1396 3 v 1421 w(Revision:)17 b(1.5)p eop -%%Page: 18 20 -bop 0 -58 a Fk(Chapter)13 b(2:)k(BFD)c(front)g(end)p 413 -66 -669 3 v 691 w(DRAFT)p 1224 -66 V 695 w Fj(18)300 183 y Ff(lo)q(cation)j(to)e -(0)h(to)f(mark)g(a)h(sym)o(b)q(ol)g(as)g(absolute)g(-)g(the)g(\015ag)k -Fh(BSF_ABSOLUTE)300 233 y Ff(m)o(ust)c(b)q(e)g(set)g(also.)438 -283 y Fh(struct)23 b(sec)g(*section;)300 351 y Ff(Bac)o(k)14 -b(end)h(sp)q(ecial)h(data.)j(This)14 b(is)h(b)q(eing)h(phased)e(out)g(in)h -(fa)o(v)o(our)e(of)h(making)300 400 y(this)i(a)f(union.)438 -450 y Fh(PTR)23 b(udata;)390 500 y(})h(asymbol;)0 682 y Fr(2.4.4)30 -b(Sym)n(b)r(ol)21 b(Handling)f(F)-5 b(unctions)0 893 y(2.4.4.1)30 -b(get)p 292 893 19 3 v 21 w(sym)n(tab)p 506 893 V 23 w(upp)r(er)p -686 893 V 22 w(b)r(ound)300 989 y Fm(Returns)22 b(the)g(n)o(um)o(b)q(er)f(of) -g(b)o(ytes)h(required)g(in)g(a)g(v)o(ector)e(of)h(p)q(oin)o(ters)h(to)300 -1039 y Fh(asymbols)10 b Fm(for)g(all)i(the)f(sym)o(b)q(ols)h(in)f(the)h -(supplied)h(bfd,)f(including)i(a)c(terminal)300 1089 y(NULL)k(p)q(oin)o(ter.) -19 b(If)13 b(there)g(are)f(no)g(sym)o(b)q(ols)h(in)h(the)e(bfd,)i(then)f(0)f -(is)h(returned.)300 1128 y Fg(\013)p 325 1128 1326 2 v 1325 -w(\010)p 300 1326 2 175 v 314 1214 a Fh(#define)23 b -(get_symtab_upper_bound\(abf)o(d\))e(\\)433 1264 y(BFD_SEND)i(\(abfd,)g -(_get_symtab_upper_bound,)e(\(abfd\)\))p 1677 1326 V 300 1352 -a Fg(\012)p 325 1352 1326 2 v 1325 w(\011)0 1583 y Fr(2.4.4.2)30 -b(bfd)p 296 1583 19 3 v 22 w(canonicalize)p 637 1583 V 22 w(sym)n(tab)300 -1680 y Fm(Supplied)20 b(a)d(bfd)h(and)f(a)g(p)q(oin)o(ter)h(to)f(an)g -(uninitializ)q(ed)j(v)o(ector)d(of)g(p)q(oin)o(ters.)300 1730 -y(This)i(reads)f(in)h(the)f(sym)o(b)q(ols)g(from)g(the)g(bfd,)h(and)f -(\014lls)i(in)f(the)f(table)h(with)300 1780 y(p)q(oin)o(ters)f(to)f(the)h -(sym)o(b)q(ols,)g(and)g(a)f(trailing)i(NULL.)f(The)g(routine)g(returns)300 -1830 y(the)d(actual)h(n)o(um)o(b)q(er)f(of)g(sym)o(b)q(ol)h(p)q(oin)o(ters)f -(not)g(including)j(the)d(NULL.)300 1868 y Fg(\013)p 325 1868 -1326 2 v 1325 w(\010)p 300 2166 2 274 v 314 1955 a Fh(#define)23 -b(bfd_canonicalize_symtab\(ab)o(fd,)e(location\))i(\\)433 2005 -y(BFD_SEND)g(\(abfd,)g(_bfd_canonicalize_symtab,\\)744 2054 -y(\(abfd,)g(location\)\))p 1677 2166 V 300 2192 a Fg(\012)p -325 2192 1326 2 v 1325 w(\011)0 2424 y Fr(2.4.4.3)30 b(bfd)p -296 2424 19 3 v 22 w(set)p 394 2424 V 22 w(sym)n(tab)300 2521 -y Fm(Pro)o(vided)14 b(a)f(table)h(of)f(p)q(oin)o(ters)h(to)f(to)g(sym)o(b)q -(ols)g(and)h(a)f(coun)o(t,)h(writes)f(to)g(the)300 2570 y(output)i(bfd)h(the) -f(sym)o(b)q(ols)g(when)h(closed.)390 2620 y Fh(PROTO\(boolean,)22 -b(bfd_set_symtab,)g(\(bfd)h(*,)h(asymbol)f(**,)390 2670 y(unsigned)g(int)g -(\)\);)0 2770 y Fk(c)6 b(y)g(g)g(n)g(u)g(s)36 b(s)6 b(u)g(p)g(p)g(o)g(r)g(t)p -332 2761 1396 3 v 1421 w(Revision:)17 b(1.5)p eop -%%Page: 19 21 -bop 0 -58 a Fk(Chapter)13 b(2:)k(BFD)c(front)g(end)p 413 -66 -669 3 v 691 w(DRAFT)p 1224 -66 V 695 w Fj(19)0 183 y Fr(2.4.4.4)30 -b(bfd)p 296 183 19 3 v 22 w(prin)n(t)p 450 183 V 22 w(sym)n(b)r(ol)p -661 183 V 23 w(v)m(andf)300 275 y Fm(Prin)o(ts)15 b(the)g(v)m(alue)i(and)e -(\015ags)g(of)g(the)g(sym)o(b)q(ol)h(supplied)h(to)e(the)g(stream)f(\014le.) -390 324 y Fh(PROTO\(void,)22 b(bfd_print_symbol_vandf,)f(\(PTR)i(file,)h -(asym-)390 374 y(bol)f(*symbol\)\);)0 507 y Fr(2.4.4.5)30 b(bfd)p -296 507 V 22 w(mak)n(e)p 457 507 V 22 w(empt)n(y)p 646 507 -V 23 w(sym)n(b)r(ol)300 598 y Fm(This)22 b(function)f(creates)g(a)g(new)56 -b Fh(asymbol)20 b Fm(structure)h(for)f(the)h(bfd,)i(and)300 -648 y(returns)15 b(a)g(p)q(oin)o(ter)h(to)e(it.)300 710 y(This)e(routine)g -(is)g(necessary)l(,)g(since)h(eac)o(h)e(bac)o(k)g(end)h(has)g(priv)m(ate)g -(information)300 760 y(surrounding)k(the)g Fh(asymbol)p Fm(.)j(Building)f(y)o -(our)d(o)o(wn)g Fh(asymbol)f Fm(and)i(p)q(oin)o(ting)300 810 -y(to)d(it)h(will)h(not)e(create)h(the)f(priv)m(ate)i(information,)e(and)h -(will)h(cause)f(problems)300 860 y(later)h(on.)300 890 y Fg(\013)p -325 890 1326 2 v 1325 w(\010)p 300 1088 2 175 v 314 976 a Fh(#define)23 -b(bfd_make_empty_symbol\(abfd)o(\))e(\\)433 1026 y(BFD_SEND)i(\(abfd,)g -(_bfd_make_empty_symbol,)e(\(abfd\)\))p 1677 1088 V 300 1114 -a Fg(\012)p 325 1114 1326 2 v 1325 w(\011)0 2770 y Fk(c)6 b(y)g(g)g(n)g(u)g -(s)36 b(s)6 b(u)g(p)g(p)g(o)g(r)g(t)p 332 2761 1396 3 v 1421 -w(Revision:)17 b(1.5)p eop -%%Page: 20 22 -bop 0 -58 a Fk(Chapter)13 b(2:)k(BFD)c(front)g(end)p 413 -66 -669 3 v 691 w(DRAFT)p 1224 -66 V 695 w Fj(20)0 183 y Fn(2.5)33 -b(Arc)n(hiv)n(es)300 275 y Fm(Gum)o(b)o(y)l(,)15 b(y)o(ou)f(promised)i(to)f -(write)g(this)h(bit...)300 337 y(Arc)o(hiv)o(es)g(are)f(supp)q(orted)g(in)h -(bfd)g(in)g Fh(archive.c)p Fm(.)300 399 y(An)22 b(arc)o(hiv)o(e)g(is)h -(represen)o(ted)f(in)o(ternally)i(just)e(lik)o(e)h(another)e(bfd,)j(with)e(a) -300 449 y(p)q(oin)o(ter)f(to)f(a)g(c)o(hain)i(of)e(con)o(tained)h(bfds.)36 -b(Arc)o(hiv)o(es)21 b(can)g(b)q(e)g(created)g(b)o(y)300 499 -y(op)q(ening)15 b(bfds,)f(linking)i(them)d(together)g(and)h(attatc)o(hing)f -(them)h(as)f(c)o(hildren)300 549 y(to)i(another)f(bfd)i(and)f(then)h(closing) -g(the)f(paren)o(t)g(bfd.)0 681 y Fr(2.5.0.1)30 b(bfd)p 296 -681 19 3 v 22 w(get)p 401 681 V 21 w(next)p 540 681 V 23 w(map)r(en)n(t)300 -773 y Fm(What)15 b(this)g(do)q(es)390 823 y Fh(PROTO\(symindex,)22 -b(bfd_get_next_mapent,)f(\(bfd)i(*,)h(symin-)390 872 y(dex,)f(carsym)g -(**\)\);)0 1005 y Fr(2.5.0.2)30 b(bfd)p 296 1005 V 22 w(set)p -394 1005 V 22 w(arc)n(hiv)n(e)p 605 1005 V 23 w(head)300 1096 -y Fm(Used)18 b(whilst)g(pro)q(cessing)g(arc)o(hiv)o(es.)26 -b(Sets)17 b(the)g(head)h(of)f(the)g(c)o(hain)h(of)f(bfds)300 -1146 y(con)o(tained)f(in)g(an)f(arc)o(hiv)o(e)g(to)g Ff(new)p -914 1146 14 2 v 17 w(head)p Fm(.)20 b(\(see)15 b(c)o(hapter)g(on)g(arc)o(hiv) -o(es\))390 1196 y Fh(PROTO\(boolean,)22 b(bfd_set_archive_head,)f(\(bfd)i -(*output,)390 1246 y(bfd)g(*new_head\)\);)0 1379 y Fr(2.5.0.3)30 -b(bfd)p 296 1379 19 3 v 22 w(get)p 401 1379 V 21 w(elt)p 491 -1379 V 22 w(at)p 567 1379 V 22 w(index)390 1458 y Fh(PROTO\(bfd)23 -b(*,)g(bfd_get_elt_at_index,)e(\(bfd)j(*,)f(int\)\);)0 1590 -y Fr(2.5.0.4)30 b(bfd)p 296 1590 V 22 w(op)r(enr)p 472 1590 -V 21 w(next)p 611 1590 V 23 w(arc)n(hiv)n(ed)p 857 1590 V 23 -w(\014le)300 1682 y Fm(Initially)14 b(pro)o(vided)f(a)f(bfd)g(con)o(taining)g -(an)g(arc)o(hiv)o(e)g(and)g(NULL,)h(op)q(ens)f(a)g(bfd)300 -1732 y(on)j(the)g(\014rst)f(con)o(tained)i(elemen)o(t)g(and)f(returns)g -(that.)k(Subsequen)o(t)d(calls)g(to)300 1781 y(bfd)p 367 1781 -14 2 v 17 w(op)q(enr)p 496 1781 V 17 w(next)p 600 1781 V 16 -w(arc)o(hiv)o(ed)p 781 1781 V 17 w(\014le)c(should)h(pass)e(the)g(arc)o(hiv)o -(e)g(and)h(the)f(previous)300 1831 y(return)16 b(v)m(alue)i(to)e(return)h(a)f -(created)g(bfd)h(to)f(the)h(next)f(con)o(tained)i(elemen)o(t.)300 -1881 y(NULL)e(is)g(returned)f(when)h(there)f(are)g(no)g(more.)390 -1931 y Fh(PROTO\(bfd*,)22 b(bfd_openr_next_archived_file,)748 -1981 y(\(bfd)h(*archive,)g(bfd)g(*previous\)\);)0 2770 y Fk(c)6 -b(y)g(g)g(n)g(u)g(s)36 b(s)6 b(u)g(p)g(p)g(o)g(r)g(t)p 332 -2761 1396 3 v 1421 w(Revision:)17 b(1.5)p eop -%%Page: 21 23 -bop 0 -58 a Fk(Chapter)13 b(2:)k(BFD)c(front)g(end)p 413 -66 -669 3 v 691 w(DRAFT)p 1224 -66 V 695 w Fj(21)0 183 y Fn(2.6)33 -b(File)23 b(F)-6 b(ormats)300 275 y Fm(A)17 b(format)g(is)h(a)30 -b Fh(bfd)17 b Fm(concept)h(of)f(high)h(lev)o(el)h(\014le)g(con)o(ten)o(ts.)26 -b(The)17 b(formats)300 324 y(supp)q(orted)f(b)o(y)f Fh(bfd)g -Fm(are:)300 387 y Fh(bfd_object)450 437 y Fm(The)k(bfd)g(ma)o(y)f(con)o(tain) -h(data,)f(sym)o(b)q(ols,)i(relo)q(cations)f(and)g(debug)450 -486 y(info.)300 547 y Fh(bfd_archive)450 596 y Fm(The)c(bfd)h(con)o(tains)f -(other)g(bfds)h(and)f(an)g(optional)h(index.)300 657 y Fh(bfd_core)450 -707 y Fm(The)f(bfd)h(con)o(tains)f(the)h(result)f(of)g(an)g(executable)i -(core)e(dump.)0 832 y Fr(2.6.0.1)30 b(bfd)p 296 832 19 3 v -22 w(c)n(hec)n(k)p 462 832 V 23 w(format)300 923 y Fm(This)19 -b(routine)g(is)g(supplied)i(a)d(bfd)h(and)g(a)f(format.)29 -b(It)18 b(attempts)g(to)g(v)o(erify)300 973 y(if)e(the)g(\014le)g(attatc)o -(hed)f(to)g(the)g(bfd)h(is)g(indeed)h(compatible)g(with)f(the)f(format)300 -1023 y(sp)q(eci\014ed)i(\(ie,)f(one)f(of)g Fh(bfd_object)p -Fm(,)e Fh(bfd_archive)h Fm(or)g Fh(bfd_core)p Fm(\).)300 1085 -y(If)j(the)h(bfd)f(has)g(b)q(een)h(set)f(to)g(a)f(sp)q(eci\014c)j -Ff(target)e Fm(b)q(efore)h(the)f(call,)h(only)g(the)300 1135 -y(named)d(target)f(and)i(format)e(com)o(bination)h(will)i(b)q(e)f(c)o(hec)o -(k)o(ed.)k(If)c(the)f(target)300 1184 y(has)k(not)f(b)q(een)i(set,)f(or)g -(has)f(b)q(een)i(set)f(to)40 b Fh(default)18 b Fm(then)h(all)h(the)f(kno)o -(wn)300 1234 y(target)14 b(bac)o(k)o(ends)h(will)i(b)q(e)f(in)o(terrogated)f -(to)f(determine)i(a)f(matc)o(h.)300 1297 y(The)h(function)h(returns)22 -b Fh(true)15 b Fm(on)h(success,)h(otherwise)k Fh(false)16 b -Fm(with)g(one)g(of)300 1346 y(the)f(follo)o(wing)h(error)f(co)q(des:)450 -1409 y(in)o(v)m(alid)p 582 1409 14 2 v 19 w(op)q(eration)21 -b(if)58 b Fh(format)20 b Fm(is)h(not)g(one)h(of)56 b Fh(bfd_object)p -Fm(,)450 1458 y Fh(bfd_archive)14 b Fm(or)g Fh(bfd_core)p Fm(.)300 -1519 y Fh(system_call_error)450 1569 y Fm(if)g(an)g(error)f(o)q(ccured)h -(during)g(a)g(read)f(-)h(ev)o(en)g(some)f(\014le)i(mismatc)o(hes)450 -1618 y(can)g(cause)h(system)p 794 1618 V 16 w(call)p 877 1618 -V 17 w(errros)300 1679 y Fh(file_not_recognised)450 1729 y -Fm(none)g(of)e(the)i(bac)o(k)o(ends)f(recognised)h(the)f(\014le)i(format)300 -1789 y Fh(file_ambiguously_recognize)o(d)450 1839 y Fm(more)e(than)g(one)g -(bac)o(k)o(end)h(recognised)g(the)f(\014le)h(format.)390 1889 -y Fh(PROTO\(boolean,)22 b(bfd_check_format,)f(\(bfd)j(*abfd,)f(bfd_format)p -2002 1895 21 38 v 390 1938 a(format\)\);)0 2063 y Fr(2.6.0.2)30 -b(bfd)p 296 2063 19 3 v 22 w(set)p 394 2063 V 22 w(format)300 -2155 y Fm(This)18 b(function)g(sets)f(the)g(\014le)h(format)e(of)h(the)g -(supplied)j(bfd)d(to)g(the)g(format)300 2205 y(requested.)26 -b(If)17 b(the)h(target)d(set)i(in)h(the)f(bfd)h(do)q(es)f(not)g(supp)q(ort)g -(the)g(format)300 2254 y(requested,)c(the)f(format)f(is)i(illegal)i(or)d(the) -g(bfd)h(is)g(not)f(op)q(en)h(for)e(writing)i(than)300 2304 -y(an)i(error)g(o)q(ccurs.)390 2354 y Fh(PROTO\(boolean,bfd_set_form)o -(at,\(bfd)20 b(*,)k(bfd_format\)\);)0 2479 y Fr(2.6.0.3)30 -b(bfd)p 296 2479 V 22 w(format)p 498 2479 V 21 w(string)300 -2570 y Fm(This)12 b(function)f(tak)o(es)f(one)h(argumen)o(t,)g(and)g(en)o -(umerated)g(t)o(yp)q(e)g(\(bfd)p 1486 2570 14 2 v 17 w(format\))300 -2620 y(and)h(returns)f(a)g(p)q(oin)o(ter)h(to)e(a)h(const)g(string)h -Fh(")p Fm(in)o(v)m(alid)p Fh(")p Fm(,)h Fh(")p Fm(ob)s(ject)p -Fh(")p Fm(,)e Fh(")p Fm(arc)o(hiv)o(e)p Fh(")p Fm(,)300 2670 -y Fh(")p Fm(core)p Fh(")j Fm(or)f Fh(")p Fm(unkno)o(wn)p Fh(")h -Fm(dep)q(ending)j(up)q(on)e(the)f(v)m(alue)h(of)f(the)g(en)o(umeration.)0 -2770 y Fk(c)6 b(y)g(g)g(n)g(u)g(s)36 b(s)6 b(u)g(p)g(p)g(o)g(r)g(t)p -332 2761 1396 3 v 1421 w(Revision:)17 b(1.5)p eop -%%Page: 22 24 -bop 0 -58 a Fk(Chapter)13 b(2:)k(BFD)c(front)g(end)p 413 -66 -669 3 v 691 w(DRAFT)p 1224 -66 V 695 w Fj(22)390 183 y Fh(PROTO\(CONST)22 -b(char)i(*,)f(bfd_format_string,)f(\(bfd_format\)\);)0 2770 -y Fk(c)6 b(y)g(g)g(n)g(u)g(s)36 b(s)6 b(u)g(p)g(p)g(o)g(r)g(t)p -332 2761 1396 3 v 1421 w(Revision:)17 b(1.5)p eop -%%Page: 23 25 -bop 0 -58 a Fk(Chapter)13 b(2:)k(BFD)c(front)g(end)p 413 -66 -669 3 v 691 w(DRAFT)p 1224 -66 V 695 w Fj(23)0 183 y Fn(2.7)33 -b(Relo)r(cations)300 275 y Fm(Bfd)23 b(main)o(tains)h(relo)q(cations)f(in)h -(m)o(uc)o(h)f(the)g(same)g(w)o(as)f(as)g(it)i(main)o(tains)300 -324 y(sym)o(b)q(ols;)i(they)c(are)g(left)g(alone)h(un)o(til)g(required,)h -(then)f(read)f(in)h(en-mass)300 374 y(and)e(traslated)f(in)o(to)g(an)h(in)o -(ternal)g(form.)36 b(There)20 b(is)h(a)g(common)f(routine)300 -424 y Fh(bfd_perform_relocation)11 b Fm(whic)o(h)k(acts)e(up)q(on)i(the)f -(canonical)h(form)e(to)h(to)300 474 y(the)h(actual)h(\014xup.)300 -536 y(Note)h(that)g(relo)q(cations)i(are)e(main)o(tained)h(on)g(a)f(p)q(er)i -(section)f(basis,)g(whilst)300 586 y(sym)o(b)q(ols)d(are)g(main)o(tained)h -(on)g(a)e(p)q(er)i(bfd)g(basis.)300 648 y(All)g(a)e(bac)o(k)h(end)g(has)f(to) -g(do)h(to)f(\014t)g(the)h(bfd)g(in)o(terface)g(is)g(to)f(create)g(as)g(man)o -(y)300 698 y Fh(struct)g(reloc_cache_entry)i Fm(as)i(there)g(are)g(relo)q -(cations)h(in)g(a)f(particuar)300 748 y(section,)d(and)h(\014ll)g(in)g(the)g -(righ)o(t)f(bits:)0 873 y Fr(2.7.0.1)30 b(bfd)p 296 873 19 -3 v 22 w(p)r(erform)p 533 873 V 21 w(relo)r(cation)300 964 -y Fm(The)15 b(relo)q(cation)h(routine)g(returns)f(as)g(a)g(status)f(an)h(en)o -(umerated)h(t)o(yp)q(e:)390 1014 y Fh(typedef)23 b(enum)g(bfd_reloc_status)f -({)300 1076 y Ff(No)15 b(errors)f(detected)438 1126 y Fh(bfd_reloc_ok,)300 -1188 y Ff(The)h(relo)q(cation)h(w)o(as)f(p)q(erformed,)g(but)g(there)g(w)o -(as)g(an)g(o)o(v)o(er\015o)o(w.)438 1238 y Fh(bfd_reloc_overflow,)300 -1300 y Ff(The)g(address)h(to)e(relo)q(cate)i(w)o(as)e(not)h(within)h(the)g -(section)f(supplied)438 1350 y Fh(bfd_reloc_outofrange,)300 -1412 y Ff(Used)h(b)o(y)f(sp)q(ecial)i(functions)438 1462 y -Fh(bfd_reloc_continue,)300 1524 y Ff(Un)o(used)438 1574 y Fh -(bfd_reloc_notsupported,)300 1636 y Ff(Unsupp)q(orted)f(relo)q(cation)g(size) -g(requested.)438 1686 y Fh(bfd_reloc_other,)300 1748 y Ff(The)f(sym)o(b)q(ol) -h(to)f(relo)q(cate)g(against)g(w)o(as)f(unde\014ned.)438 1798 -y Fh(bfd_reloc_undefined,)300 1861 y Ff(The)j(relo)q(caction)g(w)o(as)e(p)q -(erformed,)i(but)g(ma)o(y)e(not)h(b)q(e)h(ok)f(-)h(presen)o(tly)g(gen-)300 -1910 y(erated)g(only)f(when)f(linking)i(i960)e(co\013)g(\014les)h(with)g -(i960)f(b.out)f(sym)o(b)q(ols.)438 1960 y Fh(bfd_reloc_dangerous)462 -2010 y(})414 2060 y(bfd_reloc_status_enum_typ)o(e;)390 2110 -y(typedef)23 b(struct)g(reloc_cache_entry)390 2159 y({)300 -2222 y Ff(A)15 b(p)q(oin)o(ter)h(in)o(to)f(the)g(canonical)i(table)f(of)e(p)q -(oin)o(ters)438 2271 y Fh(struct)23 b(symbol_cache_entry)e(**sym_ptr_ptr;)300 -2334 y Ff(o\013set)14 b(in)i(section)438 2384 y Fh(rawdata_offset)22 -b(address;)300 2446 y Ff(addend)16 b(for)f(relo)q(cation)h(v)m(alue)438 -2496 y Fh(bfd_vma)23 b(addend;)300 2558 y Ff(if)16 b(sym)f(is)g(n)o(ull)i -(this)f(is)f(the)h(section)438 2608 y Fh(struct)23 b(sec)g(*section;)300 -2670 y Ff(P)o(oin)o(ter)15 b(to)f(ho)o(w)h(to)g(p)q(erform)g(the)g(required)h -(relo)q(cation)0 2770 y Fk(c)6 b(y)g(g)g(n)g(u)g(s)36 b(s)6 -b(u)g(p)g(p)g(o)g(r)g(t)p 332 2761 1396 3 v 1421 w(Revision:)17 -b(1.5)p eop -%%Page: 24 26 -bop 0 -58 a Fk(Chapter)13 b(2:)k(BFD)c(front)g(end)p 413 -66 -669 3 v 691 w(DRAFT)p 1224 -66 V 695 w Fj(24)438 183 y Fh(CONST)23 -b(struct)g(reloc_howto_struct)e(*howto;)390 233 y(})j(arelent;)300 -326 y(sym_ptr_ptr)450 376 y Fm(The)e(sym)o(b)q(ol)g(table)g(p)q(oin)o(ter)g -(p)q(oin)o(ts)h(to)e(a)g(p)q(oin)o(ter)h(to)f(the)h(sym-)450 -426 y(b)q(ol)15 b(asco)q(ciated)g(with)f(the)h(relo)q(cation)g(request.)k -(This)c(w)o(ould)g(natu-)450 476 y(raly)g(b)q(e)g(the)g(p)q(oin)o(ter)g(in)o -(to)f(the)h(table)g(returned)g(b)o(y)g(the)f(bac)o(k)h(end's)450 -526 y(get)p 514 526 14 2 v 16 w(sym)o(tab)h(action.)23 b(See)17 -b(Section)h(2.4)d([Sym)o(b)q(ols],)h(page)h(14.)23 b(The)450 -575 y(sym)o(b)q(ol)18 b(is)h(referenced)f(through)g(a)g(p)q(oin)o(ter)g(to)f -(a)h(p)q(oin)o(ter)g(so)g(that)450 625 y(to)q(ols)j(lik)o(e)g(the)g(link)o -(er)h(can)f(\014xup)g(all)h(the)e(sym)o(b)q(ols)h(of)g(the)f(same)450 -675 y(name)h(b)o(y)g(mo)q(difying)i(only)e(one)h(p)q(oin)o(ter.)38 -b(The)21 b(relo)q(cation)h(rou-)450 725 y(tine)16 b(lo)q(oks)f(in)g(the)g -(sym)o(b)q(ol)h(and)f(uses)g(the)g(base)g(of)f(the)h(section)h(the)450 -775 y(sym)o(b)q(ol)k(is)h(attatc)o(hed)e(to)g(and)h(the)g(v)m(alue)h(of)e -(the)h(sym)o(b)q(ol)g(as)g(the)450 825 y(initial)h(relo)q(cation)f(o\013set.) -29 b(If)20 b(the)e(sym)o(b)q(ol)i(p)q(oin)o(ter)f(is)g(zero,)h(then)450 -874 y(the)15 b(section)h(pro)o(vided)g(is)g(lo)q(ok)o(ed)f(up.)300 -968 y Fh(address)450 1017 y Fm(The)d(address)g(\014eld)i(giv)o(es)e(the)g -(o\013set)f(in)i(b)o(ytes)f(from)f(the)h(base)g(of)g(the)450 -1067 y(section)g(data)e(whic)o(h)i(o)o(wns)f(the)g(relo)q(cation)h(record)f -(to)g(the)g(\014rst)g(b)o(yte)450 1117 y(of)j(relo)q(catable)h(information.)k -(The)14 b(actual)h(data)e(relo)q(cated)i(will)g(b)q(e)450 1167 -y(relativ)o(e)j(to)e(this)h(p)q(oin)o(t)h(-)f(for)g(example,)g(a)g(relo)q -(cation)h(t)o(yp)q(e)f(whic)o(h)450 1217 y(mo)q(di\014es)e(the)e(b)q(ottom)g -(t)o(w)o(o)f(b)o(ytes)i(of)f(a)g(four)g(b)o(yte)h(w)o(ord)e(w)o(ould)i(not) -450 1267 y(touc)o(h)h(the)g(\014rst)g(b)o(yte)g(p)q(oin)o(ted)h(to)f(in)h(a)f -(big)g(endian)i(w)o(orld.)300 1360 y Fh(addend)450 1410 y Fm(The)e(addend)g -(is)g(a)f(v)m(alue)h(pro)o(vided)h(b)o(y)e(the)g(bac)o(k)h(end)g(to)e(b)q(e)i -(added)450 1459 y(\(!\))27 b(to)17 b(the)g(relo)q(cation)i(o\013set.)26 -b(It's)17 b(in)o(terpretation)h(is)g(dep)q(enden)o(t)450 1509 -y(up)q(on)e(the)f(ho)o(wto.)k(F)l(or)c(example,)g(on)g(the)h(68k)e(the)h(co)q -(de:)450 1548 y Fg(\013)p 475 1548 1176 2 v 1175 w(\010)p 450 -1896 2 324 v 655 1634 a Fh(char)23 b(foo[];)655 1684 y(main\(\))846 -1734 y({)846 1784 y(return)g(foo[0x12345678];)846 1834 y(})p -1677 1896 V 450 1922 a Fg(\012)p 475 1922 1176 2 v 1175 w(\011)450 -2065 y Fm(Could)16 b(b)q(e)g(compiled)h(in)o(to:)450 2103 y -Fg(\013)p 475 2103 V 1175 w(\010)p 450 2451 2 324 v 655 2190 -a Fh(linkw)23 b(fp,#-4)655 2240 y(moveb)g(@#12345678,d0)655 -2289 y(extbl)g(d0)655 2339 y(unlk)g(fp)655 2389 y(rts)p 1677 -2451 V 450 2477 a Fg(\012)p 475 2477 1176 2 v 1175 w(\011)450 -2620 y Fm(This)15 b(could)g(create)f(a)g(relo)q(c)i(p)q(oin)o(ting)f(to)f(fo) -q(o,)f(but)i(lea)o(v)o(e)g(the)f(o\013set)450 2670 y(in)i(the)f(data)g -(\(something)g(lik)o(e\))0 2770 y Fk(c)6 b(y)g(g)g(n)g(u)g(s)36 -b(s)6 b(u)g(p)g(p)g(o)g(r)g(t)p 332 2761 1396 3 v 1421 w(Revision:)17 -b(1.5)p eop -%%Page: 25 27 -bop 0 -58 a Fk(Chapter)13 b(2:)k(BFD)c(front)g(end)p 413 -66 -669 3 v 691 w(DRAFT)p 1224 -66 V 695 w Fj(25)450 26 y Fg(\013)p -475 26 1176 2 v 1175 w(\010)p 450 573 2 524 v 464 112 a Fh(RELOCATION)23 -b(RECORDS)g(FOR)g([.text]:)464 162 y(OFFSET)71 b(TYPE)143 b(VALUE)464 -212 y(00000006)23 b(32)191 b(_foo)464 311 y(00000000)23 b(4e56)g(fffc)238 -b(;)24 b(linkw)f(fp,#-4)464 361 y(00000004)g(1039)g(1234)h(5678)118 -b(;)24 b(moveb)f(@#12345678,d0)464 411 y(0000000a)g(49c0)357 -b(;)24 b(extbl)f(d0)464 461 y(0000000c)g(4e5e)357 b(;)24 b(unlk)f(fp)464 -511 y(0000000e)g(4e75)357 b(;)24 b(rts)p 1677 573 V 450 599 -a Fg(\012)p 475 599 1176 2 v 1175 w(\011)450 751 y Fm(Using)17 -b(co\013)f(and)h(an)f(88k,)g(some)g(instructions)i(don't)d(ha)o(v)o(e)i -(enough)450 800 y(space)11 b(in)g(them)f(to)g(represen)o(t)h(the)f(full)i -(address)e(range,)h(and)g(p)q(oin)o(ters)450 850 y(ha)o(v)o(e)k(to)f(b)q(e)i -(loaded)g(in)g(t)o(w)o(o)e(parts.)19 b(So)c(y)o(ou'd)g(get)g(something)g(lik) -o(e:)450 889 y Fg(\013)p 475 889 V 1175 w(\010)p 450 1137 2 -225 v 655 975 a Fh(or.u)119 b(r13,r0,hi16\(_foo+0x123456)o(78\))655 -1025 y(ld.b)g(r2,r13,lo16\(_foo+0x123456)o(78\))655 1075 y(jmp)143 -b(r1)p 1677 1137 V 450 1163 a Fg(\012)p 475 1163 1176 2 v 1175 -w(\011)450 1315 y Fm(This)11 b(whould)g(create)f(t)o(w)o(o)f(relo)q(cs,)j(b)q -(oth)e(p)q(oin)o(ting)i(to)p 1380 1315 14 2 v 26 w(fo)q(o,)e(and)h(with)450 -1365 y(0x12340000)h(in)j(their)f(addend)h(\014eld.)21 b(The)14 -b(data)g(w)o(ould)g(consist)h(of:)450 1395 y Fg(\013)p 475 -1395 1176 2 v 1175 w(\010)p 450 1942 2 524 v 464 1531 a Fh(RELOCATION)23 -b(RECORDS)g(FOR)g([.text]:)464 1581 y(OFFSET)71 b(TYPE)143 -b(VALUE)464 1630 y(00000002)23 b(HVRT16)95 b(_foo+0x12340000)464 -1680 y(00000006)23 b(LVRT16)95 b(_foo+0x12340000)464 1780 y(00000000)23 -b(5da05678)261 b(;)24 b(or.u)f(r13,r0,0x5678)464 1830 y(00000004)g(1c4d5678) -261 b(;)24 b(ld.b)f(r2,r13,0x5678)464 1879 y(00000008)g(f400c001)261 -b(;)24 b(jmp)f(r1)p 1677 1942 V 450 1967 a Fg(\012)p 475 1967 -1176 2 v 1175 w(\011)450 2119 y Fm(The)13 b(relo)q(cation)g(routine)h(digs)f -(out)f(the)h(v)m(alue)h(from)e(the)h(data,)f(adds)450 2169 -y(it)k(to)f(the)h(addend)g(to)g(get)f(the)h(original)g(o\013set)f(and)h(then) -g(adds)g(the)450 2219 y(v)m(alue)j(of)p 627 2219 14 2 v 34 -w(fo)q(o.)28 b(Note)17 b(that)g(all)i(32)f(bits)g(ha)o(v)o(e)f(to)h(b)q(e)g -(k)o(ept)g(around)450 2269 y(somewhere,)d(to)f(cop)q(e)i(with)g(carry)e(from) -h(bit)h(15)e(to)h(bit)g(16.)450 2371 y(On)j(further)f(example)h(is)f(the)h -(sparc)f(and)g(the)g(a.out)f(format.)25 b(The)450 2421 y(sparc)14 -b(has)g(a)f(similar)j(problem)e(to)g(the)g(88k,)f(in)i(that)e(some)h -(instruc-)450 2471 y(tions)k(don't)f(ha)o(v)o(e)g(ro)q(om)g(for)f(an)i(en)o -(tire)g(o\013set,)e(but)i(on)g(the)f(sparc)450 2521 y(the)f(parts)g(are)g -(created)h(o)q(dd)f(sized)i(lumps.)24 b(The)17 b(designers)g(of)f(the)450 -2570 y(a.out)e(format)f(c)o(hose)h(not)h(to)e(use)i(the)g(data)f(within)i -(the)e(section)i(for)450 2620 y(storing)11 b(part)f(of)h(the)g(o\013set;)g -(all)h(the)f(o\013set)f(is)h(k)o(ept)g(within)h(the)g(relo)q(c.)450 -2670 y(An)o(y)j(thing)h(in)g(the)f(data)g(should)h(b)q(e)g(ignored.)0 -2770 y Fk(c)6 b(y)g(g)g(n)g(u)g(s)36 b(s)6 b(u)g(p)g(p)g(o)g(r)g(t)p -332 2761 1396 3 v 1421 w(Revision:)17 b(1.5)p eop -%%Page: 26 28 -bop 0 -58 a Fk(Chapter)13 b(2:)k(BFD)c(front)g(end)p 413 -66 -669 3 v 691 w(DRAFT)p 1224 -66 V 695 w Fj(26)450 26 y Fg(\013)p -475 26 1176 2 v 1175 w(\010)p 450 374 2 324 v 655 112 a Fh(save)23 -b(\045sp,-112,\045sp)655 162 y(sethi)g(\045hi\(_foo+0x12345678\),\045g2)655 -212 y(ldsb)g([\045g2+\045lo\(_foo+0x12345678\)],\045i)o(0)655 -262 y(ret)655 311 y(restore)p 1677 374 V 450 399 a Fg(\012)p -475 399 1176 2 v 1175 w(\011)450 510 y Fm(Both)17 b(relo)q(cs)h(con)o(tains)f -(a)g(p)q(oin)o(ter)h(to)e(fo)q(o,)h(and)g(the)g(o\013sets)g(w)o(ould)450 -560 y(con)o(tain)e(junk.)450 599 y Fg(\013)p 475 599 V 1175 -w(\010)p 450 1196 2 573 v 464 685 a Fh(RELOCATION)23 b(RECORDS)g(FOR)g -([.text]:)464 735 y(OFFSET)71 b(TYPE)143 b(VALUE)464 785 y(00000004)23 -b(HI22)143 b(_foo+0x12345678)464 835 y(00000008)23 b(LO10)143 -b(_foo+0x12345678)464 934 y(00000000)23 b(9de3bf90)118 b(;)24 -b(save)f(\045sp,-112,\045sp)464 984 y(00000004)g(05000000)118 -b(;)24 b(sethi)f(\045hi\(_foo+0\),\045g2)464 1034 y(00000008)g(f048a000)118 -b(;)24 b(ldsb)f([\045g2+\045lo\(_foo+0\)],\045i0)464 1084 y(0000000c)g -(81c7e008)118 b(;)24 b(ret)464 1133 y(00000010)f(81e80000)118 -b(;)24 b(restore)p 1677 1196 V 450 1221 a Fg(\012)p 475 1221 -1176 2 v 1175 w(\011)300 1332 y Fh(section)450 1382 y Fm(The)17 -b(section)g(\014eld)h(is)f(only)g(used)h(when)f(the)g(sym)o(b)q(ol)g(p)q(oin) -o(ter)g(\014eld)450 1432 y(is)f(n)o(ull.)21 b(It)15 b(supplies)j(the)d -(section)h(in)o(to)f(whic)o(h)h(the)f(data)g(should)h(b)q(e)450 -1482 y(relo)q(cated.)k(The)14 b(\014eld's)h(main)g(use)f(comes)g(from)f -(assem)o(blers)h(whic)o(h)450 1532 y(do)j(most)e(of)i(the)f(sym)o(b)q(ol)h -(\014xups)h(themselv)o(es;)f(an)g(assem)o(bler)g(ma)o(y)450 -1581 y(tak)o(e)12 b(an)g(in)o(ternal)h(reference)h(to)d(a)i(lab)q(el,)h(but)e -(since)i(it)f(kno)o(ws)f(where)450 1631 y(the)18 b(lab)q(el)j(is,)e(it)f(can) -h(turn)f(the)h(relo)q(cation)g(request)f(from)g(a)g(sym-)450 -1681 y(b)q(ol)g(lo)q(okup)f(in)o(to)g(a)g(section)g(relativ)o(e)h(relo)q -(cation)f(-)g(the)g(relo)q(cation)450 1731 y(emitted)f(has)f(no)g(sym)o(b)q -(ol,)g(just)g(a)g(section)h(to)e(relo)q(cate)i(against.)450 -1792 y(I'm)h(not)f(sure)h(what)g(it)g(means)g(when)g(b)q(oth)g(a)f(sym)o(b)q -(ol)i(p)q(oin)o(ter)f(an)450 1842 y(a)g(section)g(p)q(oin)o(ter)g(are)g -(presen)o(t.)25 b(Some)17 b(formats)e(use)i(this)g(sort)f(of)450 -1891 y(mec)o(hanism)e(to)e(describ)q(e)j(PIC)f(relo)q(cations,)g(but)f(bfd)g -(can't)g(to)g(that)450 1941 y(sort)h(of)h(thing)h(y)o(et.)300 -2002 y Fh(howto)30 b Fm(The)16 b(ho)o(wto)e(\014eld)i(can)g(b)q(e)g(imagined) -g(as)f(a)g(relo)q(cation)h(instruction.)450 2052 y(It)c(is)h(a)f(p)q(oin)o -(ter)h(to)f(a)g(struct)g(whic)o(h)h(con)o(tains)g(information)f(on)h(what)450 -2102 y(to)j(do)h(with)g(all)h(the)f(other)f(information)h(in)h(the)e(relo)q -(c)i(record)f(and)450 2152 y(data)g(section.)27 b(A)17 b(bac)o(k)g(end)h(w)o -(ould)g(normally)g(ha)o(v)o(e)f(a)g(relo)q(cation)450 2202 -y(instruction)g(set)e(and)h(turn)f(relo)q(cations)i(in)o(to)e(p)q(oin)o(ters) -h(to)f(the)h(cor-)450 2251 y(rect)i(structure)g(on)g(input)h(-)f(but)g(it)g -(w)o(ould)g(b)q(e)h(p)q(ossible)h(to)d(create)450 2301 y(eac)o(h)e(ho)o(wto)f -(\014eld)j(on)e(demand.)0 2429 y Fr(2.7.0.2)30 b(relo)r(c)p -339 2429 19 3 v 21 w(ho)n(wto)p 522 2429 V 22 w(t)n(yp)r(e)300 -2521 y Fm(The)d Fh(reloc_howto_type)14 b Fm(is)j(a)g(structure)f(whic)o(h)i -(con)o(tains)f(all)h(the)f(infor-)300 2570 y(mation)e(that)g(bfd)g(needs)h -(to)f(kno)o(w)f(to)h(tie)h(up)f(a)g(bac)o(k)g(end's)h(data.)390 -2620 y Fh(typedef)23 b(CONST)g(struct)g(reloc_howto_struct)390 -2670 y({)0 2770 y Fk(c)6 b(y)g(g)g(n)g(u)g(s)36 b(s)6 b(u)g(p)g(p)g(o)g(r)g -(t)p 332 2761 1396 3 v 1421 w(Revision:)17 b(1.5)p eop -%%Page: 27 29 -bop 0 -58 a Fk(Chapter)13 b(2:)k(BFD)c(front)g(end)p 413 -66 -669 3 v 691 w(DRAFT)p 1224 -66 V 695 w Fj(27)300 183 y Ff(The)18 -b(t)o(yp)q(e)g(\014eld)h(has)f(mainly)g(a)g(do)q(cumetary)g(use)g(-)g(the)g -(bac)o(k)f(end)i(can)f(to)300 233 y(what)f(it)g(w)o(an)o(ts)e(with)i(it,)g -(though)f(the)h(normally)g(the)f(bac)o(k)h(end's)g(external)300 -283 y(idea)f(of)24 b(what)15 b(a)g(relo)q(c)h(n)o(um)o(b)q(er)g(w)o(ould)g(b) -q(e)g(w)o(ould)g(b)q(e)g(stored)f(in)h(this)g(\014eld.)300 -333 y(F)l(or)f(example,)f(the)f(a)f(PC)g(relativ)o(e)h(w)o(ord)f(relo)q -(cation)i(in)f(a)g(co\013)f(en)o(vironmen)o(t)300 382 y(w)o(ould)i(ha)o(v)o -(e)d(the)h(t)o(yp)q(e)g(023)f(-)h(b)q(ecause)h(that's)e(what)g(the)h(outside) -g(w)o(orld)g(calls)300 432 y(a)j(R)p 374 432 14 2 v 17 w(PCR)-5 -b(W)o(ORD)15 b(relo)q(c.)438 482 y Fh(unsigned)22 b(int)i(type;)300 -548 y Ff(The)d(v)m(alue)h(the)f(\014nal)h(relo)q(cation)f(is)g(shifted)h -(righ)o(t)f(b)o(y)l(.)36 b(This)22 b(drops)g(un-)300 598 y(w)o(an)o(ted)15 -b(data)f(from)h(the)g(relo)q(cation.)438 648 y Fh(unsigned)22 -b(int)i(rightshift;)300 714 y Ff(The)17 b(size)g(of)f(the)h(item)g(to)f(b)q -(e)h(relo)q(cated)g(-)g(0,)f(is)h(one)g(b)o(yte,)f(1)h(is)g(2)f(b)o(ytes,)g -(3)300 764 y(is)g(four)f(b)o(ytes.)438 814 y Fh(unsigned)22 -b(int)i(size;)300 880 y Ff(No)o(w)15 b(obsolete)438 929 y Fh(unsigned)22 -b(int)i(bitsize;)300 996 y Ff(Notes)16 b(that)f(the)i(relo)q(cation)f(is)h -(relativ)o(e)g(to)e(the)i(lo)q(cation)g(in)g(the)f(data)g(sec-)300 -1045 y(tion)i(of)f(the)h(addend.)29 b(The)18 b(relo)q(cation)g(function)h -(will)h(subtract)d(from)g(the)300 1095 y(relo)q(cation)f(v)m(alue)g(the)g -(address)f(of)g(the)g(lo)q(cation)h(b)q(eing)g(relo)q(cated.)438 -1145 y Fh(boolean)23 b(pc_relative;)300 1211 y Ff(No)o(w)15 -b(obsolete)438 1261 y Fh(unsigned)22 b(int)i(bitpos;)300 1327 -y Ff(No)o(w)15 b(obsolete)438 1377 y Fh(boolean)23 b(absolute;)300 -1443 y Ff(Causes)10 b(the)h(relo)q(cation)h(routine)f(to)f(return)g(an)h -(error)f(if)h(o)o(v)o(er\015o)o(w)e(is)k(detected)300 1493 -y(when)j(relo)q(cating.)438 1543 y Fh(boolean)23 b(complain_on_overflow;)300 -1609 y Ff(If)10 b(this)h(\014eld)h(is)e(non)h(n)o(ull,)h(then)f(the)f -(supplied)j(function)e(is)f(called)i(rather)h(than)300 1658 -y(the)k(normal)g(function.)27 b(This)17 b(allo)o(ws)h(really)g(strange)e -(relo)q(cation)i(metho)q(ds)300 1708 y(to)d(b)q(e)g(accomo)q(dated)g(\(eg,)g -(i960)g(callj)h(instructions\).)438 1758 y Fh(bfd_reloc_status_enum_ty)o(pe) -21 b(\(*special_function\)\(\);)300 1824 y Ff(The)15 b(textual)h(name)f(of)g -(the)g(relo)q(cation)h(t)o(yp)q(e.)438 1874 y Fh(char)23 b(*name;)300 -1940 y Ff(When)17 b(p)q(erforming)h(a)f(partial)g(link,)i(some)d(formats)g(m) -o(ust)h(mo)q(dify)g(the)j(re-)300 1990 y(lo)q(cations)c(rather)f(than)g(the)g -(data)f(-)i(this)f(\015ag)g(signals)h(this.)438 2040 y Fh(boolean)23 -b(partial_inplace;)300 2106 y Ff(The)16 b(src)p 453 2106 V -16 w(mask)f(is)h(used)g(to)f(select)h(what)f(parts)g(of)g(the)g(read)g(in)i -(data)d(are)i(to)300 2156 y(b)q(e)j(used)f(in)h(the)f(relo)q(cation)g(sum.)28 -b(Eg,)18 b(if)h(this)f(w)o(as)f(an)h(8)f(bit)i(bit)f(of)g(data)300 -2205 y(whic)o(h)i(w)o(e)e(read)h(and)g(relo)q(cated,)h(this)g(w)o(ould)f(b)q -(e)g(0x000000\013.)29 b(When)19 b(w)o(e)300 2255 y(ha)o(v)o(e)d(relo)q(cs)e -(whic)o(h)h(ha)o(v)o(e)e(an)g(addend,)i(suc)o(h)f(as)f(sun4)h(extended)h -(relo)q(cs,)f(the)300 2305 y(v)m(alue)22 b(in)d(the)f(o\013set)f(part)g(of)h -(a)g(relo)q(cating)g(\014eld)i(is)e(garbage)f(so)h(w)o(e)g(nev)o(er)300 -2355 y(use)g(it.)i(In)c(this)g(case)f(the)g(mask)g(w)o(ould)g(b)q(e)h -(0x00000000.)438 2405 y Fh(bfd_word)22 b(src_mask;)300 2471 -y Ff(The)11 b(dst)p 453 2471 V 16 w(mask)f(is)h(what)f(parts)g(of)g(the)h -(instruction)g(are)f(replaced)i(in)o(to)f(the)i(in-)300 2521 -y(struction.)19 b(In)c(most)e(cases)g(src)p 846 2521 V 17 w(mask)g(==)h(dst)p -1124 2521 V 17 w(mask,)f(except)h(in)h(the)e(ab)q(o)o(v)o(e)300 -2570 y(sp)q(ecial)25 b(case,)h(where)e(dst)p 780 2570 V 16 -w(mask)f(w)o(ould)h(b)q(e)g(0x000000\013,)f(and)h(src)p 1534 -2570 V 16 w(mask)300 2620 y(w)o(ould)17 b(b)q(e)f(0x00000000.)438 -2670 y Fh(bfd_word)22 b(dst_mask;)0 2770 y Fk(c)6 b(y)g(g)g(n)g(u)g(s)36 -b(s)6 b(u)g(p)g(p)g(o)g(r)g(t)p 332 2761 1396 3 v 1421 w(Revision:)17 -b(1.5)p eop -%%Page: 28 30 -bop 0 -58 a Fk(Chapter)13 b(2:)k(BFD)c(front)g(end)p 413 -66 -669 3 v 691 w(DRAFT)p 1224 -66 V 695 w Fj(28)300 183 y Ff(When)18 -b(some)g(formats)e(create)i(PC)f(relativ)o(e)i(instructions,)g(they)f(lea)o -(v)o(e)g(the)300 233 y(v)m(alue)g(of)f(the)g(p)q(c)g(of)g(the)g(place)g(b)q -(eing)i(relo)q(cated)e(in)h(the)f(o\013set)f(slot)g(of)h(the)300 -283 y(instruction,)22 b(so)e(that)g(a)g(PC)g(relativ)o(e)h(relo)q(cation)h -(can)e(b)q(e)h(made)g(just)f(b)o(y)300 333 y(adding)15 b(in)f(an)g(ordinary)g -(o\013set)f(\(eg)g(sun3)h(a.out\).)k(Some)c(formats)e(lea)o(v)o(e)i(the)300 -382 y(displacemen)o(t)19 b(part)f(of)f(an)h(instruction)h(empt)o(y)f(\(eg)f -(m88k)g(b)q(cs\),)i(this)f(\015ag)300 432 y(signals)e(the)f(fact.)438 -482 y Fh(boolean)23 b(pcrel_offset;)390 532 y(})h(reloc_howto_type;)0 -677 y Fr(2.7.0.3)30 b(HO)n(WTO)300 770 y Fm(The)15 b(HO)o(WTO)h(de\014ne)g -(is)g(horrible)g(and)g(will)g(go)f(a)o(w)o(a)o(y)l(.)300 808 -y Fg(\013)p 325 808 1326 2 v 1325 w(\010)p 300 1057 2 225 v -314 895 a Fh(#define)23 b(HOWTO\(C,)g(R,S,B,)g(P,)g(BI,)h(ABS,)f(O,)h(SF,)f -(NAME,)g(INPLACE,)314 945 y(MASKSRC,)g(MASKDST,)g(PC\))g(\\)362 -994 y({\(unsigned\)C,R,S,B,)e(P,)j(BI,)f(ABS,O,SF,NAME,INPLACE,MASKS)o -(RC,MASKD)o(ST,PC})p 1988 1004 21 42 v 1677 1057 2 225 v 300 -1082 a Fg(\012)p 325 1082 1326 2 v 1325 w(\011)0 1277 y Fr(2.7.0.4)30 -b(relo)r(c)p 339 1277 19 3 v 21 w(c)n(hain)300 1336 y Fg(\013)p -325 1336 1326 2 v 1325 w(\010)p 300 1784 2 424 v 314 1422 a -Fh(typedef)23 b(unsigned)g(char)g(bfd_byte;)314 1522 y(typedef)g(struct)g -(relent_chain)f({)362 1572 y(arelent)h(relent;)362 1622 y(struct)71 -b(relent_chain)22 b(*next;)314 1672 y(})i(arelent_chain;)p -1677 1784 V 300 1809 a Fg(\012)p 325 1809 1326 2 v 1325 w(\011)300 -1923 y Fm(If)e(an)f(output)p 558 1923 14 2 v 16 w(bfd)h(is)g(supplied)i(to)d -(this)h(function)g(the)f(generated)h(image)300 1973 y(will)16 -b(b)q(e)e(relo)q(catable,)h(the)f(relo)q(cations)g(are)g(copied)h(to)e(the)h -(output)g(\014le)h(after)300 2022 y(they)g(ha)o(v)o(e)f(b)q(een)i(c)o(hanged) -f(to)g(re\015ect)g(the)g(new)g(state)f(of)g(the)h(w)o(orld.)20 -b(There)300 2072 y(are)15 b(t)o(w)o(o)g(w)o(a)o(ys)f(of)h(re\015ecting)i(the) -f(results)g(of)f(partial)h(link)m(age)h(in)g(an)e(output)300 -2122 y(\014le;)22 b(b)o(y)d(mo)q(difying)h(the)g(output)f(data)f(in)i(place,) -h(and)e(b)o(y)g(mo)q(difying)i(the)300 2172 y(relo)q(cation)h(record.)38 -b(Some)21 b(nativ)o(e)g(formats)f(\(eg)h(basic)h(a.out)e(and)h(basic)300 -2222 y(co\013)t(\))14 b(ha)o(v)o(e)h(no)g(w)o(a)o(y)f(of)h(sp)q(ecifying)i -(an)f(addend)g(in)g(the)f(relo)q(cation)h(t)o(yp)q(e,)f(so)300 -2271 y(the)f(addend)h(has)e(to)g(go)h(in)g(the)g(output)g(data.)19 -b(This)14 b(is)g(no)g(big)h(deal)f(since)h(in)300 2321 y(these)g(formats)e -(the)i(output)f(data)g(slot)g(will)j(alw)o(a)o(ys)d(b)q(e)h(big)g(enough)g -(for)f(the)300 2371 y(addend.)30 b(Complex)19 b(relo)q(c)g(t)o(yp)q(es)f -(with)g(addends)h(w)o(ere)f(in)o(v)o(en)o(ted)h(to)f(solv)o(e)300 -2421 y(just)d(this)h(problem.)390 2471 y Fh(PROTO\(bfd_reloc_status_enu)o -(m_type,)772 2521 y(bfd_perform_relocation,)963 2570 y(\(bfd)23 -b(*)h(abfd,)963 2620 y(arelent)f(*reloc_entry,)963 2670 y(PTR)g(data,)0 -2770 y Fk(c)6 b(y)g(g)g(n)g(u)g(s)36 b(s)6 b(u)g(p)g(p)g(o)g(r)g(t)p -332 2761 1396 3 v 1421 w(Revision:)17 b(1.5)p eop -%%Page: 29 31 -bop 0 -58 a Fk(Chapter)13 b(2:)k(BFD)c(front)g(end)p 413 -66 -669 3 v 691 w(DRAFT)p 1224 -66 V 695 w Fj(29)963 183 y Fh(asection)22 -b(*input_section,)963 233 y(bfd)h(*output_bfd\)\);)0 2770 y -Fk(c)6 b(y)g(g)g(n)g(u)g(s)36 b(s)6 b(u)g(p)g(p)g(o)g(r)g(t)p -332 2761 1396 3 v 1421 w(Revision:)17 b(1.5)p eop -%%Page: 30 32 -bop 0 -58 a Fk(Chapter)13 b(2:)k(BFD)c(front)g(end)p 413 -66 -669 3 v 691 w(DRAFT)p 1224 -66 V 695 w Fj(30)0 183 y Fn(2.8)33 -b(Core)21 b(\014les)300 275 y Fm(Bu\013)15 b(output)g(this)h(facinating)g -(topic)0 407 y Fr(2.8.0.1)30 b(bfd)p 296 407 19 3 v 22 w(core)p -429 407 V 22 w(\014le)p 530 407 V 22 w(failing)p 717 407 V -21 w(command)300 499 y Fm(Returns)22 b(a)g(read-only)h(string)e(explaining)k -(what)c(program)g(w)o(as)g(running)300 549 y(when)16 b(it)f(failed)i(and)e -(pro)q(duced)h(the)g(core)f(\014le)h(b)q(eing)g(read)390 598 -y Fh(PROTO\(CONST)22 b(char)i(*,)f(bfd_core_file_failing_comman)o(d,)390 -648 y(\(bfd)g(*\)\);)0 781 y Fr(2.8.0.2)30 b(bfd)p 296 781 -V 22 w(core)p 429 781 V 22 w(\014le)p 530 781 V 22 w(failing)p -717 781 V 21 w(signal)300 872 y Fm(Returns)17 b(the)f(signal)h(n)o(um)o(b)q -(er)g(whic)o(h)g(caused)g(the)f(core)h(dump)g(whic)o(h)g(gen-)300 -922 y(erated)e(the)g(\014le)i(the)e(bfd)g(is)h(attatc)o(hed)e(to.)390 -972 y Fh(PROTO\(int,)22 b(bfd_core_file_failing_signal,)e(\(bfd)k(*\)\);)0 -1105 y Fr(2.8.0.3)30 b(core)p 320 1105 V 22 w(\014le)p 421 -1105 V 22 w(matc)n(hes)p 659 1105 V 23 w(executable)p 964 1105 -V 22 w(p)300 1196 y Fm(Returns)15 b Fh(true)g Fm(if)g(the)g(core)g(\014le)h -(attatc)o(hed)e(to)h Ff(core)p 1214 1196 14 2 v 16 w(bfd)i -Fm(w)o(as)d(generated)h(b)o(y)300 1246 y(a)g(run)g(of)g(the)g(executable)i -(\014le)f(attatc)o(hed)e(to)h Ff(exec)p 1194 1246 V 17 w(bfd)p -Fm(,)g(or)g(else)h Fh(false)p Fm(.)390 1296 y Fh(PROTO\(boolean,)22 -b(core_file_matches_executab)o(le_p,)485 1346 y(\(bfd)i(*core_bfd,)e(bfd)i -(*exec_bfd\)\);)0 2770 y Fk(c)6 b(y)g(g)g(n)g(u)g(s)36 b(s)6 -b(u)g(p)g(p)g(o)g(r)g(t)p 332 2761 1396 3 v 1421 w(Revision:)17 -b(1.5)p eop -%%Page: 31 33 -bop 0 -58 a Fk(Chapter)13 b(2:)k(BFD)c(front)g(end)p 413 -66 -669 3 v 691 w(DRAFT)p 1224 -66 V 695 w Fj(31)0 183 y Fn(2.9)33 -b(T)-6 b(argets)300 276 y Fm(Eac)o(h)17 b(p)q(ort)g(of)g(BFD)g(to)f(a)h -(di\013eren)o(t)h(mac)o(hine)g(requries)g(the)f(creation)g(of)g(a)300 -325 y(target)11 b(bac)o(k)g(end.)20 b(All)13 b(the)f(bac)o(k)g(end)g(pro)o -(vides)h(to)e(the)h(ro)q(ot)f(part)g(of)h(bfd)g(is)g(a)300 -375 y(structure)h(con)o(taining)i(p)q(oin)o(ters)f(to)f(functions)h(whic)o(h) -h(p)q(erform)e(certain)h(lo)o(w)300 425 y(lev)o(el)k(op)q(erations)e(on)g -(\014les.)25 b(BFD)15 b(translates)h(the)h(applications's)g(requests)300 -475 y(through)e(a)g(p)q(oin)o(ter)g(in)o(to)h(calls)g(to)e(the)i(bac)o(k)f -(end)h(routines.)300 538 y(When)e(a)g(\014le)h(is)f(op)q(ened)h(with)f -Fh(bfd_openr)p Fm(,)f(its)h(format)e(and)i(target)f(are)g(un-)300 -588 y(kno)o(wn.)19 b(BFD)12 b(uses)i(v)m(arious)f(mec)o(hanisms)h(to)e -(determine)i(ho)o(w)e(to)h(in)o(terpret)300 638 y(the)i(\014le.)21 -b(The)16 b(op)q(eratios)f(p)q(erformed)g(are:)337 701 y Fq(\017)30 -b Fm(First)17 b(a)g(bfd)h(is)g(created)g(b)o(y)f(calling)i(the)f(in)o(ternal) -g(routine)32 b Fh(new_bfd)p Fm(,)390 751 y(then)15 b Fh(bfd_find_target)f -Fm(is)h(called)i(with)e(the)h(target)d(string)j(supplied)390 -800 y(to)f Fh(bfd_openr)e Fm(and)j(the)f(new)h(bfd)f(p)q(oin)o(ter.)337 -864 y Fq(\017)30 b Fm(If)21 b(a)f(n)o(ull)h(target)e(string)i(w)o(as)e(pro)o -(vided)i(to)51 b Fh(bfd_find_target)p Fm(,)19 b(it)390 914 -y(lo)q(oks)d(up)h(the)f(en)o(vironmen)o(t)g(v)m(ariable)23 -b Fh(GNUTARGET)15 b Fm(and)i(uses)f(that)f(as)390 963 y(the)g(target)f -(string.)337 1027 y Fq(\017)30 b Fm(If)12 b(the)h(target)e(string)h(is)g -(still)i(NULL,)f(or)e(the)i(target)e(string)h(is)g Fh(default)p -Fm(,)390 1076 y(then)h(the)f(\014rst)g(item)g(in)h(the)g(target)e(v)o(ector)g -(is)i(used)g(as)f(the)g(target)f(t)o(yp)q(e.)390 1126 y(See)16 -b Fq(h)p Fm(unde\014ned)p Fq(i)g Fm([targets],)d(page)i Fq(h)p -Fm(unde\014ned)p Fq(i)p Fm(.)337 1189 y Fq(\017)30 b Fm(Otherwise,)19 -b(the)e(elemen)o(ts)h(in)h(the)e(target)g(v)o(ector)f(are)h(insp)q(ected)j -(one)390 1239 y(b)o(y)f(one,)h(un)o(til)g(a)f(matc)o(h)f(on)h(target)f(name)h -(is)h(found.)32 b(When)19 b(found,)390 1289 y(that)14 b(is)i(used.)337 -1352 y Fq(\017)30 b Fm(Otherwise)15 b(the)f(error)g Fh(invalid_target)e -Fm(is)j(returned)f(to)g Fh(bfd_openr)p Fm(.)337 1415 y Fq(\017)30 -b Fh(bfd_openr)13 b Fm(attempts)g(to)g(op)q(en)i(the)f(\014le)h(using)g -Fh(bfd_open_file)p Fm(,)d(and)390 1465 y(returns)j(the)g(bfd.)300 -1528 y(Once)e(the)g(bfd)f(has)g(b)q(een)i(op)q(ened)f(and)g(the)f(target)f -(selected,)j(the)e(\014le)h(format)300 1578 y(ma)o(y)j(b)q(e)h(determined.)26 -b(This)17 b(is)g(done)g(b)o(y)g(calling)27 b Fh(bfd_check_format)14 -b Fm(on)300 1628 y(the)f(bfd)h(with)g(a)f(suggested)g(format.)18 -b(The)13 b(routine)h(returns)f Fh(true)g Fm(when)h(the)300 -1678 y(application)j(guesses)e(righ)o(t.)0 1819 y Fr(2.9.0.1)30 -b(bfd)p 296 1819 19 3 v 22 w(target)0 1990 y(2.9.1)g(bfd)p -248 1990 V 22 w(target)300 2082 y Fm(This)16 b(structure)f(con)o(tains)h(ev)o -(erything)g(that)f(BFD)g(kno)o(ws)g(ab)q(out)g(a)h(target.)300 -2132 y(It)g(includes)i(things)f(lik)o(e)g(its)f(b)o(yte)f(order,)h(name,)g -(what)f(routines)h(to)g(call)h(to)300 2181 y(do)e(v)m(arious)h(op)q -(erations,)f(etc.)300 2245 y(Ev)o(ery)g(BFD)g(p)q(oin)o(ts)g(to)g(a)g(target) -f(structure)h(with)g(its)g Fh(")p Fm(xv)o(ec)p Fh(")g Fm(mem)o(b)q(er.)300 -2308 y(Shortcut)f(for)g(declaring)h(\014elds)h(whic)o(h)f(are)f(protot)o(yp)q -(ed)g(function)h(p)q(oin)o(ters,)300 2358 y(while)i(a)o(v)o(oiding)e(anguish) -h(on)f(compilers)i(that)d(don't)h(supp)q(ort)g(protos.)390 -2408 y Fh(#define)23 b(SDEF\(ret,)g(name,)g(arglist\))f(\\)772 -2457 y(PROTO\(ret,\(*name\),arglist)o(\))390 2507 y(#define)h(SDEF_FMT\(ret,) -f(name,)h(arglist\))g(\\)772 2557 y(PROTO\(ret,\(*name[bfd_type)o(_end]\),)o -(arglist)o(\))p 2026 2567 21 42 v 300 2620 a Fm(These)34 b(macros)e(are)h -(used)g(to)g(dispatc)o(h)h(to)e(functions)i(through)f(the)300 -2670 y(bfd)p 367 2670 14 2 v 17 w(target)21 b(v)o(ector.)40 -b(They)22 b(are)g(used)h(in)g(a)f(n)o(um)o(b)q(er)g(of)g(macros)f(further)0 -2770 y Fk(c)6 b(y)g(g)g(n)g(u)g(s)36 b(s)6 b(u)g(p)g(p)g(o)g(r)g(t)p -332 2761 1396 3 v 1421 w(Revision:)17 b(1.5)p eop -%%Page: 32 34 -bop 0 -58 a Fk(Chapter)13 b(2:)k(BFD)c(front)g(end)p 413 -66 -669 3 v 691 w(DRAFT)p 1224 -66 V 695 w Fj(32)300 183 y Fm(do)o(wn)19 -b(in)h(bfd.h,)h(and)e(are)g(also)g(used)h(when)g(calling)h(v)m(arious)f -(routines)g(b)o(y)300 233 y(hand)e(inside)i(the)e(bfd)g(implemen)o(tation.)29 -b(The)18 b Fh(")p Fm(arglist)p Fh(")g Fm(argumen)o(t)f(m)o(ust)300 -283 y(b)q(e)12 b(paren)o(thesized;)i(it)e(con)o(tains)g(all)h(the)e(argumen)o -(ts)g(to)g(the)h(called)h(function.)390 333 y Fh(#define)23 -b(BFD_SEND\(bfd,)f(message,)h(arglist\))g(\\)748 382 y -(\(\(*\(\(bfd\)->xvec->message\)\))d(arglist\))300 447 y Fm(F)l(or)15 -b(op)q(erations)g(whic)o(h)h(index)g(on)g(the)f(bfd)g(format)390 -497 y Fh(#define)23 b(BFD_SEND_FMT\(bfd,)e(message,)i(arglist\))g(\\)676 -547 y(\(\(\(bfd\)->xvec->message[\(int\)\()o(\(bfd\)->)o(format\))o(]\))p -2050 557 21 42 v 390 597 a(arglist\))300 662 y Fm(This)15 b(is)f(the)h -(struct)e(whic)o(h)i(de\014nes)g(the)g(t)o(yp)q(e)f(of)g(BFD)f(this)i(is.)20 -b(The)14 b Fh(")p Fm(xv)o(ec)p Fh(")300 711 y Fm(mem)o(b)q(er)f(of)f(the)h -(struct)g(bfd)g(itself)h(p)q(oin)o(ts)f(here.)19 b(Eac)o(h)13 -b(mo)q(dule)h(that)e(imple-)300 761 y(men)o(ts)j(access)g(to)g(a)g -(di\013eren)o(t)g(target)f(under)i(BFD,)e(de\014nes)j(one)e(of)g(these.)300 -826 y(FIXME,)i(these)h(names)g(should)h(b)q(e)f(rationalised)h(with)g(the)f -(names)f(of)h(the)300 876 y(en)o(try)e(p)q(oin)o(ts)i(whic)o(h)f(call)h -(them.)25 b(T)l(o)q(o)16 b(bad)h(w)o(e)g(can't)f(ha)o(v)o(e)h(one)g(macro)f -(to)300 926 y(de\014ne)g(them)f(b)q(oth!)390 976 y Fh(typedef)23 -b(struct)g(bfd_target)390 1025 y({)300 1090 y Ff(iden)o(ti\014es)17 -b(the)e(kind)h(of)f(target,)f(eg)h(SunOS4,)h(Ultrix,)f(etc)438 -1140 y Fh(char)23 b(*name;)300 1205 y Ff(The)11 b Fh(")p Ff(\015a)o(v)o(our)p -Fh(")g Ff(of)f(a)h(bac)o(k)g(end)h(is)g(a)f(general)g(indication)i(ab)q(out)e -(the)h(con)o(ten)o(ts)300 1255 y(of)j(a)g(\014le.)438 1304 -y Fh(enum)23 b(target_flavour_enum)e({)485 1354 y -(bfd_target_aout_flavour_enum,)485 1404 y(bfd_target_coff_flavour_enum,)485 -1454 y(bfd_target_ieee_flavour_enum,)485 1504 y -(bfd_target_oasys_flavour_enum)o(,)485 1554 y(bfd_target_srec_flavour_enum})f -(flavour;)300 1618 y Ff(The)15 b(order)g(of)g(b)o(ytes)g(within)h(the)g(data) -e(area)h(of)g(a)g(\014le.)438 1668 y Fh(boolean)23 b(byteorder_big_p;)300 -1733 y Ff(The)15 b(order)g(of)g(b)o(ytes)g(within)h(the)g(header)f(parts)g -(of)g(a)g(\014le.)438 1783 y Fh(boolean)23 b(header_byteorder_big_p;)300 -1848 y Ff(This)c(is)f(a)g(mask)g(of)g(all)h(the)f(\015ags)g(whic)o(h)h(an)f -(executable)i(ma)o(y)d(ha)o(v)o(e)h(set)g(-)300 1897 y(from)c(the)i(set)f -Fh(NO_FLAGS)p Ff(,)e Fh(HAS_RELOC)p Ff(,)h(...)p Fh(D_PAGED)p -Ff(.)438 1947 y Fh(flagword)22 b(object_flags;)300 2012 y Ff(This)c(is)g(a)f -(mask)f(of)h(all)i(the)e(\015ags)g(whic)o(h)h(a)f(section)h(ma)o(y)e(ha)o(v)o -(e)h(set)g(-)h(from)300 2062 y(the)d(set)g Fh(SEC_NO_FLAGS)p -Ff(,)e Fh(SEC_ALLOC)p Ff(,)h(...)p Fh(SET_NEVER_LOAD)p Ff(.)438 -2112 y Fh(flagword)22 b(section_flags;)300 2177 y Ff(The)15 -b(pad)h(c)o(haracter)e(for)h(\014lenames)h(within)h(an)e(arc)o(hiv)o(e)g -(header.)438 2226 y Fh(char)23 b(ar_pad_char;)300 2291 y Ff(The)15 -b(maxim)o(um)h(n)o(um)o(b)q(er)f(of)g(c)o(haracters)f(in)i(an)f(arc)o(hiv)o -(e)h(header.)414 2341 y Fh(unsigned)23 b(short)g(ar_max_namelen;)300 -2406 y Ff(The)15 b(minim)o(um)i(alignmen)o(t)f(restriction)f(for)g(an)o(y)g -(section.)438 2456 y Fh(unsigned)22 b(int)i(align_power_min;)300 -2521 y Ff(En)o(tries)16 b(for)f(b)o(yte)h(sw)o(apping)g(for)g(data.)21 -b(These)16 b(are)g(di\013eren)o(t)g(to)f(the)h(other)300 2570 -y(en)o(try)j(p)q(oin)o(ts,)i(since)g(they)e(don't)g(tak)o(e)g(bfd)h(as)f -(\014rst)g(arg.)33 b(Certain)19 b(other)300 2620 y(handlers)f(could)e(do)f -(the)h(same.)438 2670 y Fh(SDEF)23 b(\(bfd_vma,)142 b(bfd_getx64,)22 -b(\(bfd_byte)h(*\)\);)0 2770 y Fk(c)6 b(y)g(g)g(n)g(u)g(s)36 -b(s)6 b(u)g(p)g(p)g(o)g(r)g(t)p 332 2761 1396 3 v 1421 w(Revision:)17 -b(1.5)p eop -%%Page: 33 35 -bop 0 -58 a Fk(Chapter)13 b(2:)k(BFD)c(front)g(end)p 413 -66 -669 3 v 691 w(DRAFT)p 1224 -66 V 695 w Fj(33)438 183 y Fh(SDEF)23 -b(\(void,)214 b(bfd_putx64,)22 b(\(bfd_vma,)h(bfd_byte)390 -233 y(*\)\);)438 283 y(SDEF)g(\(bfd_vma,)g(bfd_getx32,)f(\(bfd_byte)h(*\)\);) -438 333 y(SDEF)g(\(void,)214 b(bfd_putx32,)22 b(\(bfd_vma,)h(bfd_byte)390 -382 y(*\)\);)438 432 y(SDEF)g(\(bfd_vma,)g(bfd_getx16,)f(\(bfd_byte)h(*\)\);) -438 482 y(SDEF)g(\(void,)214 b(bfd_putx16,)22 b(\(bfd_vma,)h(bfd_byte)390 -532 y(*\)\);)300 600 y Ff(Byte)15 b(sw)o(apping)h(for)e(the)i(headers)438 -650 y Fh(SDEF)23 b(\(bfd_vma,)70 b(bfd_h_getx64,)22 b(\(bfd_byte)h(*\)\);)438 -700 y(SDEF)g(\(void,)238 b(bfd_h_putx64,)22 b(\(bfd_vma,)h(bfd_byte)p -2002 710 21 42 v 390 749 a(*\)\);)438 799 y(SDEF)g(\(bfd_vma,)47 -b(bfd_h_getx32,)22 b(\(bfd_byte)g(*\)\);)438 849 y(SDEF)h(\(void,)238 -b(bfd_h_putx32,)22 b(\(bfd_vma,)h(bfd_byte)p 2002 859 V 390 -899 a(*\)\);)438 949 y(SDEF)g(\(bfd_vma,)47 b(bfd_h_getx16,)22 -b(\(bfd_byte)g(*\)\);)438 998 y(SDEF)h(\(void,)238 b(bfd_h_putx16,)22 -b(\(bfd_vma,)h(bfd_byte)p 2002 1009 V 390 1048 a(*\)\);)300 -1116 y Ff(F)l(ormat)17 b(dep)q(enden)o(t)i(routines,)g(these)g(turn)f(in)o -(to)g(v)o(ectors)f(of)h(en)o(try)g(p)q(oin)o(ts)300 1166 y(within)e(the)g -(target)e(v)o(ector)g(structure;)h(one)g(for)g(eac)o(h)g(format)f(to)g(c)o -(hec)o(k.)300 1234 y(Chec)o(k)h(the)h(format)e(of)g(a)h(\014le)h(b)q(eing)h -(read.)j(Return)15 b(bfd)p 1288 1234 14 2 v 17 w(target)f(*)h(or)g(zero.)438 -1284 y Fh(SDEF_FMT)22 b(\(struct)h(bfd_target)g(*,)g(_bfd_check_format,)390 -1334 y(\(bfd)g(*\)\);)300 1402 y Ff(Set)15 b(the)h(format)d(of)i(a)g(\014le)h -(b)q(eing)h(written.)438 1452 y Fh(SDEF_FMT)22 b(\(boolean,)286 -b(_bfd_set_format,)21 b(\(bfd)390 1501 y(*\)\);)300 1569 y -Ff(W)l(rite)15 b(cac)o(hed)h(information)f(in)o(to)h(a)f(\014le)h(b)q(eing)g -(written,)f(at)g(bfd)p 1441 1569 V 16 w(close.)438 1619 y Fh(SDEF_FMT)22 -b(\(boolean,)286 b(_bfd_write_contents,)390 1669 y(\(bfd)23 -b(*\)\);)300 1737 y Ff(The)15 b(follo)o(wing)g(functions)g(are)f(de\014ned)h -(in)g Fh(JUMP_TABLE)p Ff(.)j(The)d(idea)g(is)i(that)300 1787 -y(the)e(bac)o(k)h(end)g(writer)f(of)h Fh(foo)f Ff(names)g(all)h(the)g -(routines)i Fh(foo_)p Ff(en)o(try)p 1506 1787 V 16 w(p)q(oin)o(t,)300 -1837 y Fh(JUMP_TABLE)12 b Ff(will)j(built)g(the)f(en)o(tries)i(in)e(this)g -(structure)f(in)i(the)e(righ)o(t)h(order.)300 1905 y(Core)h(\014le)h(en)o -(try)f(p)q(oin)o(ts)438 1954 y Fh(SDEF)23 b(\(char)g(*,)h -(_core_file_failing_comman)o(d,)d(\(bfd)i(*\)\);)438 2004 y(SDEF)g(\(int,)95 -b(_core_file_failing_signal)o(,)21 b(\(bfd)i(*\)\);)438 2054 -y(SDEF)g(\(boolean,)g(_core_file_matches_execu)o(table_p)o(,)e(\(bfd)390 -2104 y(*,)j(bfd)f(*\)\);)300 2172 y Ff(Arc)o(hiv)o(e)16 b(en)o(try)f(p)q(oin) -o(ts)414 2222 y Fh(SDEF)23 b(\(boolean,)g(_bfd_slurp_armap,)e(\(bfd)j(*\)\);) -414 2271 y(SDEF)f(\(boolean,)g(_bfd_slurp_extended_name_)o(table,)d(\(bfd)390 -2321 y(*\)\);)414 2371 y(SDEF)j(\(void,)71 b(_bfd_truncate_arname,)21 -b(\(bfd)i(*,)h(CONST)390 2421 y(char)f(*,)h(char)f(*\)\);)414 -2471 y(SDEF)g(\(boolean,)g(write_armap,)f(\(bfd)h(*arch,)1106 -2521 y(unsigned)g(int)g(elength,)1106 2570 y(struct)g(orl)g(*map,)1106 -2620 y(int)g(orl_count,)1106 2670 y(int)g(stridx\)\);)0 2770 -y Fk(c)6 b(y)g(g)g(n)g(u)g(s)36 b(s)6 b(u)g(p)g(p)g(o)g(r)g(t)p -332 2761 1396 3 v 1421 w(Revision:)17 b(1.5)p eop -%%Page: 34 36 -bop 0 -58 a Fk(Chapter)13 b(2:)k(BFD)c(front)g(end)p 413 -66 -669 3 v 691 w(DRAFT)p 1224 -66 V 695 w Fj(34)300 183 y Ff(Standard)i -(stu\013.)438 233 y Fh(SDEF)23 b(\(boolean,)g(_close_and_cleanup,)e(\(bfd)i -(*\)\);)438 283 y(SDEF)g(\(boolean,)g(_bfd_set_section_content)o(s,)e(\(bfd)i -(*,)390 333 y(sec_ptr,)g(PTR,)1440 382 y(file_ptr,)390 432 -y(bfd_size_type\)\);)438 482 y(SDEF)g(\(boolean,)g(_bfd_get_section_content)o -(s,)e(\(bfd)i(*,)390 532 y(sec_ptr,)g(PTR,)1440 582 y(file_ptr,)390 -632 y(bfd_size_type\)\);)438 681 y(SDEF)g(\(boolean,)g(_new_section_hook,)e -(\(bfd)i(*,)h(sec_ptr\)\);)300 777 y Ff(Sym)o(b)q(ols)16 b(and)f(relo)q -(ctions)414 827 y Fh(SDEF)23 b(\(unsigned)g(int,)g(_get_symtab_upper_bound,)e -(\(bfd)390 877 y(*\)\);)438 927 y(SDEF)i(\(unsigned)g(int,)g -(_bfd_canonicalize_symtab,)652 976 y(\(bfd)h(*,)f(struct)g -(symbol_cache_entry)f(**\)\);)438 1026 y(SDEF)h(\(unsigned)g(int,)g -(_get_reloc_upper_bound,)e(\(bfd)390 1076 y(*,)j(sec_ptr\)\);)438 -1126 y(SDEF)f(\(unsigned)g(int,)g(_bfd_canonicalize_reloc,)e(\(bfd)390 -1176 y(*,)j(sec_ptr,)e(arelent)h(**,)1512 1225 y(struct)390 -1275 y(symbol_cache_entry**\)\);)438 1325 y(SDEF)g(\(struct)g -(symbol_cache_entry)45 b(*,)24 b(_bfd_make_empty_symbol,)p -2146 1335 21 42 v 390 1375 a(\(bfd)f(*\)\);)438 1425 y(SDEF)g(\(void,)119 -b(_bfd_print_symbol,)21 b(\(bfd)i(*,)h(PTR,)f(struct)p 2026 -1435 V 390 1474 a(symbol_cache_entry)45 b(*,)1297 1524 y -(bfd_print_symbol_enum_typ)o(e\)\);)p 2289 1534 V 390 1574 -a(#define)23 b(bfd_print_symbol\(b,p,s,e\))d(BFD_SEND\(b,)j -(_bfd_print_symbol,)p 2217 1584 V 390 1624 a(\(b,p,s,e\)\))438 -1674 y(SDEF)g(\(alent)g(*,)71 b(_get_lineno,)23 b(\(bfd)g(*,)h(struct)f(sym-) -390 1724 y(bol_cache_entry)46 b(*\)\);)438 1823 y(SDEF)23 b(\(boolean,)70 -b(_bfd_set_arch_mach,)22 b(\(bfd)h(*,)h(enum)390 1873 y(bfd_architecture,) -1321 1923 y(unsigned)e(long\)\);)p 2002 1933 V 438 2022 a(SDEF)h(\(bfd)g(*,) -48 b(openr_next_archived_file,)20 b(\(bfd)k(*arch,)390 2072 -y(bfd)f(*prev\)\);)438 2122 y(SDEF)g(\(boolean,)g(_bfd_find_nearest_line,)581 -2172 y(\(bfd)g(*abfd,)g(struct)g(sec)48 b(*section,)605 2222 -y(struct)23 b(symbol_cache_entry)45 b(**symbols,bfd_vma)390 -2271 y(offset,)581 2321 y(CONST)23 b(char)g(**file,)g(CONST)g(char)h(**func,) -f(unsigned)390 2371 y(int)g(*line\)\);)438 2421 y(SDEF)g(\(int,)95 -b(_bfd_stat_arch_elt,)21 b(\(bfd)i(*,)h(struct)390 2471 y(stat)f(*\)\);)438 -2570 y(SDEF)g(\(int,)95 b(_bfd_sizeof_headers,)21 b(\(bfd)i(*,)h -(boolean\)\);)p 2002 2576 21 38 v 438 2670 a(SDEF)f(\(void,)g -(_bfd_debug_info_start,)e(\(bfd)i(*\)\);)0 2770 y Fk(c)6 b(y)g(g)g(n)g(u)g(s) -36 b(s)6 b(u)g(p)g(p)g(o)g(r)g(t)p 332 2761 1396 3 v 1421 w(Revision:)17 -b(1.5)p eop -%%Page: 35 37 -bop 0 -58 a Fk(Chapter)13 b(2:)k(BFD)c(front)g(end)p 413 -66 -669 3 v 691 w(DRAFT)p 1224 -66 V 695 w Fj(35)438 183 y Fh(SDEF)23 -b(\(void,)g(_bfd_debug_info_end,)e(\(bfd)j(*\)\);)438 233 y(SDEF)f(\(void,)g -(_bfd_debug_info_accumulate,)d(\(bfd)k(*,)f(struct)p 2026 243 -21 42 v 390 283 a(sec)47 b(*\)\);)300 345 y Ff(Sp)q(ecial)17 -b(en)o(try)e(p)q(oin)o(ts)h(for)e(gdb)i(to)e(sw)o(ap)h(in)h(co\013)e(sym)o(b) -q(ol)i(table)g(parts)438 395 y Fh(SDEF\(void,)22 b(_bfd_coff_swap_aux_in,\() -557 445 y(bfd)286 b(*abfd)23 b(,)557 495 y(PTR)310 b(ext,)557 -544 y(int)g(type,)557 594 y(int)g(class)23 b(,)557 644 y(PTR)310 -b(in\)\);)438 744 y(SDEF\(void,)22 b(_bfd_coff_swap_sym_in,\()557 -793 y(bfd)286 b(*abfd)23 b(,)557 843 y(PTR)310 b(ext,)557 893 -y(PTR)g(in\)\);)438 993 y(SDEF\(void,)22 b(_bfd_coff_swap_lineno_in,)45 -b(\()557 1043 y(bfd)286 b(*abfd,)557 1092 y(PTR)g(ext,)557 -1142 y(PTR)310 b(in\)\);)390 1242 y(})24 b(bfd_target;)0 1375 -y Fr(2.9.1.1)30 b(bfd)p 296 1375 19 3 v 22 w(\014nd)p 420 1375 -V 22 w(target)300 1466 y Fm(Returns)15 b(a)f(p)q(oin)o(ter)h(to)f(the)h -(transfer)f(v)o(ector)g(for)g(the)g(ob)s(ject)g(target)g(named)300 -1516 y(target)p 423 1516 14 2 v 15 w(name.)26 b(If)18 b(target)p -751 1516 V 15 w(name)f(is)h(NULL,)g(c)o(ho)q(oses)f(the)g(one)h(in)g(the)f -(en)o(vi-)300 1566 y(ronmen)o(t)f(v)m(ariable)i(GNUT)l(AR)o(GET;)e(if)h(that) -g(is)g(n)o(ull)h(or)e(not)h(de\014ned)h(then)300 1615 y(the)d(\014rst)g(en)o -(try)g(in)h(the)f(target)f(list)i(is)g(c)o(hosen.)k(P)o(assing)15 -b(in)h(the)f(string)h Fh(")p Fm(de-)300 1665 y(fault)p Fh(")d -Fm(or)f(setting)h(the)g(en)o(vironmen)o(t)g(v)m(ariable)i(to)d -Fh(")p Fm(default)p Fh(")h Fm(will)i(cause)e(the)300 1715 y(\014rst)k(en)o -(try)h(in)h(the)f(target)e(list)j(to)e(b)q(e)h(returned,)h(and)f -Fh(")p Fm(target)p 1431 1715 V 15 w(defaulted)p Fh(")300 1765 -y Fm(will)f(b)q(e)g(set)e(in)i(the)e(bfd.)22 b(This)16 b(causes)g(bfd)p -1062 1765 V 17 w(c)o(hec)o(k)p 1186 1765 V 17 w(format)e(to)h(lo)q(op)h(o)o -(v)o(er)f(all)300 1815 y(the)g(targets)f(to)h(\014nd)h(the)f(one)g(that)g -(matc)o(hes)g(the)g(\014le)h(b)q(eing)g(read.)390 1864 y Fh -(PROTO\(bfd_target)22 b(*,)h(bfd_find_target,\(CONST)e(char)i(*,)390 -1914 y(bfd)g(*\)\);)0 2047 y Fr(2.9.1.2)30 b(bfd)p 296 2047 -19 3 v 22 w(target)p 480 2047 V 21 w(list)300 2138 y Fm(This)15 -b(function)f(returns)g(a)g(freshly)g(mallo)q(ced)i(NULL-terminated)f(v)o -(ector)e(of)300 2188 y(the)i(names)g(of)g(all)h(the)g(v)m(alid)g(bfd)g -(targets.)j(Do)14 b(not)h(mo)q(dify)h(the)f(names)390 2238 -y Fh(PROTO\(CONST)22 b(char)i(**,bfd_target_list,\(\)\);)0 -2770 y Fk(c)6 b(y)g(g)g(n)g(u)g(s)36 b(s)6 b(u)g(p)g(p)g(o)g(r)g(t)p -332 2761 1396 3 v 1421 w(Revision:)17 b(1.5)p eop -%%Page: 36 38 -bop 0 -58 a Fk(Chapter)13 b(2:)k(BFD)c(front)g(end)p 413 -66 -669 3 v 691 w(DRAFT)p 1224 -66 V 695 w Fj(36)0 183 y Fn(2.10)32 -b(Arc)n(hitectures)300 436 y Fm(BFD's)15 b(idea)i(of)f(an)g(arc)o(hitecture)h -(is)f(implimen)o(ted)j(in)k Fh(archures.c)p Fm(.)e(BFD)300 -486 y(k)o(eeps)h(t)o(w)o(o)f(atoms)g(in)i(a)e(bfd)i(describing)h(the)e(arc)o -(hitecture)g(of)g(the)g(data)300 535 y(attatc)o(hed)c(to)h(the)g(bfd,)h(the) -43 b Fh(enum)15 b(bfd_architecture)e(arch)18 b Fm(\014eld)j(and)300 -585 y(the)15 b Fh(unsigned)f(long)h(machine)f Fm(\014eld.)0 -2168 y Fr(2.10.0.1)29 b(bfd)p 326 2168 19 3 v 22 w(arc)n(hitecture)300 -2421 y Fm(This)14 b(en)o(um)f(giv)o(es)g(the)g(ob)s(ject)g(\014le's)g(CPU)g -(arc)o(hitecture,)h(in)f(a)g(global)h(sense.)300 2471 y(E.g.)40 -b(what)21 b(pro)q(cessor)h(family)g(do)q(es)h(it)f(b)q(elong)h(to?)41 -b(There)22 b(is)g(another)300 2521 y(\014eld,)14 b(whic)o(h)g(indicates)g -(what)e(pro)q(cessor)g(within)i(the)f(family)h(is)f(in)g(use.)20 -b(The)300 2570 y(mac)o(hine)d(giv)o(es)e(a)h(n)o(um)o(b)q(er)g(whic)o(h)g -(distingushes)i(di\013eren)o(t)e(v)o(ersions)g(of)f(the)300 -2620 y(arc)o(hitecture,)j(con)o(taining)g(for)f(example)h(2)f(and)g(3)g(for)g -(In)o(tel)h(i960)f(KA)h(and)300 2670 y(i960)d(KB,)g(and)h(68020)d(and)j -(68030)e(for)g(Motorola)g(68020)g(and)h(68030.)0 2770 y Fk(c)6 -b(y)g(g)g(n)g(u)g(s)36 b(s)6 b(u)g(p)g(p)g(o)g(r)g(t)p 332 -2761 1396 3 v 1421 w(Revision:)17 b(1.5)p eop -%%Page: 37 39 -bop 0 -58 a Fk(Chapter)13 b(2:)k(BFD)c(front)g(end)p 413 -66 -669 3 v 691 w(DRAFT)p 1224 -66 V 695 w Fj(37)300 26 y Fg(\013)p -325 26 1326 2 v 1325 w(\010)p 300 1968 2 1918 v 314 112 a Fh(enum)23 -b(bfd_architecture)314 162 y({)362 212 y(bfd_arch_unknown,)69 -b(/*)24 b(File)f(arch)g(not)h(known)f(*/)362 262 y(bfd_arch_obscure,)69 -b(/*)24 b(Arch)f(known,)g(not)h(one)f(of)h(these)f(*/)362 311 -y(bfd_arch_m68k,)141 b(/*)24 b(Motorola)e(68xxx)i(*/)362 361 -y(bfd_arch_vax,)165 b(/*)24 b(DEC)f(Vax)h(*/)362 411 y(bfd_arch_i960,)141 -b(/*)24 b(Intel)f(960)g(*/)410 461 y(/*)g(The)h(order)f(of)g(the)h(following) -e(is)i(important.)481 511 y(lower)f(number)g(indicates)g(a)h(machine)f(type)g -(that)481 560 y(only)g(accepts)g(a)h(subset)f(of)h(the)f(instructions)481 -610 y(available)g(to)g(machines)g(with)g(higher)h(numbers.)481 -660 y(The)g(exception)e(is)i(the)f("ca",)g(which)h(is)481 710 -y(incompatible)e(with)i(all)f(other)g(machines)g(except)481 -760 y("core".)g(*/)314 859 y(#define)g(bfd_mach_i960_core)141 -b(1)314 909 y(#define)23 b(bfd_mach_i960_ka_sa)117 b(2)314 -959 y(#define)23 b(bfd_mach_i960_kb_sb)117 b(3)314 1009 y(#define)23 -b(bfd_mach_i960_mc)189 b(4)314 1059 y(#define)23 b(bfd_mach_i960_xa)189 -b(5)314 1108 y(#define)23 b(bfd_mach_i960_ca)189 b(6)362 1208 -y(bfd_arch_a29k,)141 b(/*)24 b(AMD)f(29000)g(*/)362 1258 y(bfd_arch_sparc,) -117 b(/*)24 b(SPARC)f(*/)362 1308 y(bfd_arch_mips,)141 b(/*)24 -b(MIPS)f(Rxxxx)g(*/)362 1357 y(bfd_arch_i386,)141 b(/*)24 b(Intel)f(386)g(*/) -362 1407 y(bfd_arch_ns32k,)117 b(/*)24 b(National)e(Semiconductor)h(32xxx)g -(*/)362 1457 y(bfd_arch_tahoe,)117 b(/*)24 b(CCI/Harris)e(Tahoe)h(*/)362 -1507 y(bfd_arch_i860,)141 b(/*)24 b(Intel)f(860)g(*/)362 1557 -y(bfd_arch_romp,)141 b(/*)24 b(IBM)f(ROMP)g(RS/6000)g(*/)362 -1606 y(bfd_arch_alliant,)69 b(/*)24 b(Alliant)f(*/)362 1656 -y(bfd_arch_convex,)93 b(/*)24 b(Convex)f(*/)362 1706 y(bfd_arch_m88k,)141 -b(/*)24 b(Motorola)e(88xxx)i(*/)362 1756 y(bfd_arch_pyramid,)69 -b(/*)24 b(Pyramid)f(Technology)f(*/)362 1806 y(bfd_arch_h8_300,)93 -b(/*)24 b(Hitachi)f(H8/300)g(*/)362 1856 y(bfd_arch_last)362 -1905 y(};)p 1677 1968 V 300 1993 a Fg(\012)p 325 1993 1326 -2 v 1325 w(\011)300 2118 y Fm(stu\013)0 2367 y Fr(2.10.0.2)29 -b(bfd)p 326 2367 19 3 v 22 w(prinable)p 567 2367 V 23 w(arc)n(h)p -704 2367 V 22 w(mac)n(h)300 2471 y Fm(Return)d(a)g(prin)o(table)h(string)e -(represen)o(ting)i(the)e(arc)o(hitecture)h(and)g(ma-)300 2521 -y(c)o(hine)34 b(t)o(yp)q(e.)71 b(The)33 b(result)g(is)g(only)g(go)q(o)q(d)f -(un)o(til)i(the)e(next)h(call)h(to)300 2570 y(bfd)p 367 2570 -14 2 v 17 w(prin)o(table)p 561 2570 V 17 w(arc)o(h)p 663 2570 -V 16 w(mac)o(h.)390 2620 y Fh(PROTO\(CONST)22 b(char)i -(*,bfd_printable_arch_mac)o(h,)485 2670 y(\(enum)g(bfd_architecture)d(arch,)i -(unsigned)g(long)h(machine\)\);)p 2050 2680 21 42 v 0 2770 -a Fk(c)6 b(y)g(g)g(n)g(u)g(s)36 b(s)6 b(u)g(p)g(p)g(o)g(r)g(t)p -332 2761 1396 3 v 1421 w(Revision:)17 b(1.5)p eop -%%Page: 38 40 -bop 0 -58 a Fk(Chapter)13 b(2:)k(BFD)c(front)g(end)p 413 -66 -669 3 v 691 w(DRAFT)p 1224 -66 V 695 w Fj(38)0 183 y Fr(2.10.0.3)29 -b(bfd)p 326 183 19 3 v 22 w(scan)p 463 183 V 23 w(arc)n(h)p -600 183 V 22 w(mac)n(h)300 275 y Fm(Scan)20 b(a)e(string)i(and)f(attempt)f -(to)h(turn)g(it)g(in)o(to)g(an)g(arc)o(hiv)o(e)h(and)f(mac)o(hine)300 -324 y(t)o(yp)q(e)c(com)o(bination.)390 374 y Fh(PROTO\(boolean,)22 -b(bfd_scan_arch_mach,)485 424 y(\(CONST)h(char)h(*,)f(enum)h -(bfd_architecture)d(*,)j(unsigned)390 474 y(long)f(*\)\);)0 -607 y Fr(2.10.0.4)29 b(bfd)p 326 607 V 22 w(arc)n(h)p 462 607 -V 23 w(compatible)300 698 y Fm(This)17 b(routine)h(is)f(used)h(to)e -(determine)i(whether)f(t)o(w)o(o)f(BFDs')g(arc)o(hitectures)300 -748 y(and)22 b(mac)o(hine)g(t)o(yp)q(es)g(are)f(compatible.)40 -b(It)22 b(calculates)g(the)g(lo)o(w)o(est)f(com-)300 798 y(mon)15 -b(denominator)h(b)q(et)o(w)o(een)g(the)g(t)o(w)o(o)e(arc)o(hitectures)i(and)g -(mac)o(hine)g(t)o(yp)q(es)300 847 y(implied)22 b(b)o(y)e(the)g(bfds)g(and)g -(sets)g(the)g(ob)s(jects)f(p)q(oin)o(ted)i(at)e(b)o(y)h Ff(arc)o(hp)h -Fm(and)300 897 y Ff(mac)o(hine)e Fm(if)c(non)h(NULL.)300 959 -y(This)g(routine)h(returns)i Fh(true)c Fm(if)i(the)f(bfds)g(are)f(of)h -(compatible)h(t)o(yp)q(e,)e(other-)300 1009 y(wise)h Fh(false)p -Fm(.)390 1059 y Fh(PROTO\(boolean,)22 b(bfd_arch_compatible,)509 -1109 y(\(bfd)i(*abfd,)509 1159 y(bfd)g(*bbfd,)509 1209 y(enum)g -(bfd_architecture)d(*archp,)509 1258 y(unsigned)i(long)g(*machinep\)\);)0 -1391 y Fr(2.10.0.5)29 b(bfd)p 326 1391 V 22 w(set)p 424 1391 -V 22 w(arc)n(h)p 560 1391 V 23 w(mac)n(h)300 1483 y Fm(Set)15 -b(atc)o(h)g(mac)o(h)300 1512 y Fg(\013)p 325 1512 1326 2 v -1325 w(\010)p 300 1761 2 225 v 314 1599 a Fh(#define)23 b -(bfd_set_arch_mach\(abfd,)e(arch,)i(mach\))g(\\)433 1649 y(BFD_SEND)g -(\(abfd,)g(_bfd_set_arch_mach,\\)791 1698 y(\(abfd,)g(arch,)h(mach\)\))p -1677 1761 V 300 1786 a Fg(\012)p 325 1786 1326 2 v 1325 w(\011)0 -2770 y Fk(c)6 b(y)g(g)g(n)g(u)g(s)36 b(s)6 b(u)g(p)g(p)g(o)g(r)g(t)p -332 2761 1396 3 v 1421 w(Revision:)17 b(1.5)p eop -%%Page: 39 41 -bop 0 -58 a Fk(Chapter)13 b(2:)k(BFD)c(front)g(end)p 413 -66 -669 3 v 691 w(DRAFT)p 1224 -66 V 695 w Fj(39)0 183 y Fn(2.11)32 -b(Op)r(ening)23 b(and)g(Closing)f(BFDs)0 358 y Fr(2.11.0.1)29 -b(bfd)p 326 358 19 3 v 22 w(op)r(enr)300 451 y Fm(Op)q(ens)22 -b(the)g(\014le)g(supplied)i(\(using)d(fop)q(en\))h(with)g(the)f(target)f -(supplied,)25 b(it)300 501 y(returns)15 b(a)g(p)q(oin)o(ter)h(to)e(the)h -(created)h(bfd.)300 564 y(If)h(NULL)h(is)g(returned)g(then)f(an)g(error)f -(has)h(o)q(ccured.)27 b(P)o(ossible)18 b(errors)e(are)300 614 -y(no)p 351 614 14 2 v 16 w(memory)l(,)f(in)o(v)m(alid)p 681 -614 V 18 w(target)f(or)h(system)p 1025 614 V 16 w(call)h(error.)390 -664 y Fh(PROTO\(bfd*,)22 b(bfd_openr,)h(\(CONST)g(char)g(*filename,CONST)390 -714 y(char*target\)\);)0 860 y Fr(2.11.0.2)29 b(bfd)p 326 860 -19 3 v 22 w(fdop)r(enr)300 952 y Fm(bfd)p 367 952 14 2 v 17 -w(fdop)q(enr)17 b(is)g(to)g(bfd)p 721 952 V 16 w(fop)q(enr)h(m)o(uc)o(h)e -(lik)o(e)i(fdop)q(en)g(is)f(to)f(fop)q(en.)26 b(It)16 b(op)q(ens)300 -1002 y(a)f(bfd)g(on)h(a)e(\014le)j(already)e(describ)q(ed)i(b)o(y)e(the)h -Ff(fd)h Fm(supplied.)300 1066 y(P)o(ossible)f(errors)f(are)f(no)p -730 1066 V 17 w(memory)l(,)g(in)o(v)m(alid)p 1060 1066 V 19 -w(target)g(and)h(system)p 1437 1066 V 16 w(call)i(error.)414 -1116 y Fh(PROTO\(bfd)22 b(*,)i(bfd_fdopenr,)485 1165 y(\(CONST)f(char)h -(*filename,)e(CONST)h(char)h(*target,)f(int)390 1215 y(fd\)\);)0 -1361 y Fr(2.11.0.3)29 b(bfd)p 326 1361 19 3 v 22 w(op)r(en)n(w)300 -1454 y Fm(Creates)21 b(a)g(bfd,)i(asso)q(ciated)f(with)g(\014le)h -Ff(\014lename)p Fm(,)h(using)e(the)g(\014le)g(format)300 1504 -y Ff(target)p Fm(,)14 b(and)h(returns)g(a)g(p)q(oin)o(ter)h(to)e(it.)300 -1567 y(P)o(ossible)i(errors)f(are)f(system)p 818 1567 14 2 -v 16 w(call)p 901 1567 V 18 w(error,)g(no)p 1091 1567 V 16 -w(memory)l(,)h(in)o(v)m(alid)p 1421 1567 V 19 w(target.)390 -1617 y Fh(PROTO\(bfd)23 b(*,)g(bfd_openw,)g(\(CONST)g(char)g(*filename,)g -(CONST)390 1667 y(char)g(*target\)\);)0 1813 y Fr(2.11.0.4)29 -b(bfd)p 326 1813 19 3 v 22 w(close)300 1906 y Fm(This)21 b(function)h(closes) -f(a)g(bfd.)36 b(If)21 b(the)g(bfd)g(w)o(as)f(op)q(en)h(for)f(writing,)j(then) -300 1955 y(p)q(ending)13 b(op)q(erations)f(are)f(completed)h(and)g(the)g -(\014le)g(written)g(out)f(and)g(closed.)300 2005 y(If)18 b(the)f(created)g -(\014le)i(is)e(executable,)i(then)30 b Fh(chmod)17 b Fm(is)h(called)h(to)d -(mark)h(it)g(as)300 2055 y(suc)o(h.)300 2119 y(All)f(memory)f(attatc)o(hed)f -(to)h(the)g(bfd's)g(obstac)o(ks)g(is)g(released.)300 2182 y -Fh(true)g Fm(is)g(returned)h(if)g(all)g(is)f(ok,)g(otherwise)g -Fh(false)p Fm(.)390 2232 y Fh(PROTO\(boolean,)22 b(bfd_close,\(bfd)g(*\)\);)0 -2378 y Fr(2.11.0.5)29 b(bfd)p 326 2378 V 22 w(create)300 2471 -y Fm(This)23 b(routine)f(creates)g(a)f(new)i(bfd)f(in)h(the)f(manner)g(of)g -(bfd)p 1406 2471 14 2 v 16 w(op)q(en)o(w,)i(but)300 2521 y(without)14 -b(op)q(ening)g(a)g(\014le.)20 b(The)14 b(new)g(bfd)g(tak)o(es)f(the)g(target) -g(from)f(the)i(target)300 2570 y(used)i(b)o(y)f Ff(template)p -Fm(.)20 b(The)15 b(format)f(is)i(alw)o(a)o(ys)e(set)h(to)g -Fh(bfd_object)p Fm(.)390 2620 y Fh(PROTO\(bfd)23 b(*,)g(bfd_create,)g -(\(CONST)g(char)g(*filename,)f(bfd)390 2670 y(*template\)\);)0 -2770 y Fk(c)6 b(y)g(g)g(n)g(u)g(s)36 b(s)6 b(u)g(p)g(p)g(o)g(r)g(t)p -332 2761 1396 3 v 1421 w(Revision:)17 b(1.5)p eop -%%Page: 40 42 -bop 0 -58 a Fk(Chapter)13 b(2:)k(BFD)c(front)g(end)p 413 -66 -669 3 v 691 w(DRAFT)p 1224 -66 V 695 w Fj(40)0 183 y Fr(2.11.0.6)29 -b(bfd)p 326 183 19 3 v 22 w(allo)r(c)p 472 183 V 22 w(size)300 -275 y Fm(Return)12 b(the)f(n)o(um)o(b)q(er)h(of)f(b)o(ytes)g(in)h(the)f -(obstac)o(ks)f(connected)j(to)d(the)i(supplied)300 324 y(bfd.)390 -374 y Fh(PROTO\(bfd_size_type,bfd_al)o(loc_siz)o(e,\(bfd)21 -b(*abfd\)\);)0 2770 y Fk(c)6 b(y)g(g)g(n)g(u)g(s)36 b(s)6 b(u)g(p)g(p)g(o)g -(r)g(t)p 332 2761 1396 3 v 1421 w(Revision:)17 b(1.5)p eop -%%Page: 41 43 -bop 0 -58 a Fk(Chapter)13 b(2:)k(BFD)c(front)g(end)p 413 -66 -669 3 v 691 w(DRAFT)p 1224 -66 V 695 w Fj(41)0 183 y Fr(2.11.1.7)29 -b(bfd)p 326 183 19 3 v 22 w(put)p 440 183 V 22 w(size)0 497 -y(2.11.1.8)g(bfd)p 326 497 V 22 w(get)p 431 497 V 22 w(size)300 -605 y Fm(These)17 b(macros)f(as)g(used)i(for)e(reading)h(and)g(writing)g(ra)o -(w)f(data)g(in)i(sections;)300 655 y(eac)o(h)e(access)f(\(except)h(for)e(b)o -(ytes\))h(is)h(v)o(ectored)f(through)h(the)f(target)f(format)300 -705 y(of)21 b(the)g(bfd)g(and)g(mangled)h(accordingly)l(.)39 -b(The)21 b(mangling)h(p)q(erforms)e(an)o(y)300 754 y(necessary)15 -b(endian)i(translations)e(and)g(remo)o(v)o(es)g(alignmen)o(t)h(restrictions.) -300 793 y Fg(\013)p 325 793 1326 2 v 1325 w(\010)p 300 1689 -2 872 v 314 879 a Fh(#define)23 b(bfd_put_8\(abfd,)f(val,)h(ptr\))g(\\)696 -929 y(\(*\(\(char)g(*\)ptr\))g(=)g(\(char\)val\))314 979 y(#define)g -(bfd_get_8\(abfd,)f(ptr\))h(\\)696 1029 y(\(*\(\(char)g(*\)ptr\)\))314 -1079 y(#define)g(bfd_put_16\(abfd,)f(val,)h(ptr\))g(\\)696 -1129 y(BFD_SEND\(abfd,)f(bfd_putx16,)g(\(val,ptr\)\))314 1178 -y(#define)h(bfd_get_16\(abfd,)f(ptr\))h(\\)696 1228 y(BFD_SEND\(abfd,)f -(bfd_getx16,)g(\(ptr\)\))314 1278 y(#define)h(bfd_put_32\(abfd,)f(val,)h -(ptr\))g(\\)696 1328 y(BFD_SEND\(abfd,)f(bfd_putx32,)g(\(val,ptr\)\))314 -1378 y(#define)h(bfd_get_32\(abfd,)f(ptr\))h(\\)696 1427 y(BFD_SEND\(abfd,)f -(bfd_getx32,)g(\(ptr\)\))314 1477 y(#define)h(bfd_put_64\(abfd,)f(val,)h -(ptr\))g(\\)696 1527 y(BFD_SEND\(abfd,)f(bfd_putx64,)g(\(val,)h(ptr\)\))314 -1577 y(#define)g(bfd_get_64\(abfd,)f(ptr\))h(\\)696 1627 y(BFD_SEND\(abfd,)f -(bfd_getx64,)g(\(ptr\)\))p 1677 1689 V 300 1715 a Fg(\012)p -325 1715 1326 2 v 1325 w(\011)0 2049 y Fr(2.11.1.9)29 b(bfd)p -326 2049 19 3 v 22 w(h)p 382 2049 V 22 w(put)p 496 2049 V 23 -w(size)0 2363 y(2.11.1.10)g(bfd)p 357 2363 V 22 w(h)p 413 2363 -V 22 w(get)p 518 2363 V 22 w(size)300 2471 y Fm(These)16 b(macros)e(ha)o(v)o -(e)h(the)g(same)g(function)h(as)f(their)g Fh(bfd_get_x)f Fm(bretherin,)300 -2521 y(except)19 b(that)f(they)h(are)f(used)h(for)f(remo)o(ving)h -(information)g(for)f(the)h(header)300 2570 y(records)c(of)g(ob)s(ject)g -(\014les.)22 b(Believ)o(e)17 b(it)f(or)f(not,)g(some)g(ob)s(ject)g(\014les)i -(k)o(eep)e(their)300 2620 y(header)21 b(records)f(in)h(big)g(endian)h(order,) -f(and)g(their)g(data)e(in)j(little)f(endan)300 2670 y(order.)0 -2770 y Fk(c)6 b(y)g(g)g(n)g(u)g(s)36 b(s)6 b(u)g(p)g(p)g(o)g(r)g(t)p -332 2761 1396 3 v 1421 w(Revision:)17 b(1.5)p eop -%%Page: 42 44 -bop 0 -58 a Fk(Chapter)13 b(2:)k(BFD)c(front)g(end)p 413 -66 -669 3 v 691 w(DRAFT)p 1224 -66 V 695 w Fj(42)300 26 y Fg(\013)p -325 26 1326 2 v 1325 w(\010)p 300 922 2 872 v 314 112 a Fh(#define)23 -b(bfd_h_put_8\(abfd,)f(val,)h(ptr\))g(\\)696 162 y(\(*\(\(char)g(*\)ptr\))g -(=)g(\(char\)val\))314 212 y(#define)g(bfd_h_get_8\(abfd,)f(ptr\))h(\\)696 -262 y(\(*\(\(char)g(*\)ptr\)\))314 311 y(#define)g(bfd_h_put_16\(abfd,)e -(val,)j(ptr\))f(\\)696 361 y(BFD_SEND\(abfd,)f(bfd_h_putx16,\(val,ptr\)\))314 -411 y(#define)h(bfd_h_get_16\(abfd,)e(ptr\))j(\\)696 461 y(BFD_SEND\(abfd,)e -(bfd_h_getx16,\(ptr\)\))314 511 y(#define)h(bfd_h_put_32\(abfd,)e(val,)j -(ptr\))f(\\)696 560 y(BFD_SEND\(abfd,)f(bfd_h_putx32,\(val,ptr\)\))314 -610 y(#define)h(bfd_h_get_32\(abfd,)e(ptr\))j(\\)696 660 y(BFD_SEND\(abfd,)e -(bfd_h_getx32,\(ptr\)\))314 710 y(#define)h(bfd_h_put_64\(abfd,)e(val,)j -(ptr\))f(\\)696 760 y(BFD_SEND\(abfd,)f(bfd_h_putx64,\(val,)f(ptr\)\))314 -809 y(#define)i(bfd_h_get_64\(abfd,)e(ptr\))j(\\)696 859 y(BFD_SEND\(abfd,)e -(bfd_h_getx64,\(ptr\)\))p 1677 922 V 300 947 a Fg(\012)p 325 -947 1326 2 v 1325 w(\011)0 1130 y Fr(2.11.1.11)29 b(bfd)p 357 -1130 19 3 v 22 w(log2)300 1221 y Fm(Return)17 b(the)g(log)f(base)h(2)f(of)g -(the)h(v)m(alue)h(supplied,)g(rounded)g(up.)24 b(eg)16 b(an)h(arg)300 -1271 y(of)e(1025)f(w)o(ould)h(return)h(11.)390 1321 y Fh(PROTO\(bfd_vma,)22 -b(bfd_log2,\(bfd_vma)f(x\)\);)0 2770 y Fk(c)6 b(y)g(g)g(n)g(u)g(s)36 -b(s)6 b(u)g(p)g(p)g(o)g(r)g(t)p 332 2761 1396 3 v 1421 w(Revision:)17 -b(1.5)p eop -%%Page: 43 45 -bop 0 -58 a Fk(Chapter)13 b(2:)k(BFD)c(front)g(end)p 413 -66 -669 3 v 691 w(DRAFT)p 1224 -66 V 695 w Fj(43)0 183 y Fn(2.12)32 -b(File)24 b(Cac)n(hing)300 276 y Fm(The)14 b(\014le)h(cac)o(hing)f(mec)o -(hanism)h(is)f(em)o(b)q(edded)h(within)h(BFD)d(and)h(allo)o(ws)g(the)300 -326 y(application)k(to)e(op)q(en)g(as)g(man)o(y)g(bfds)h(as)f(it)g(w)o(an)o -(ts)f(without)h(regard)g(to)g(the)300 376 y(underlying)21 b(op)q(erating)e -(system's)f(\014le)i(descriptor)f(limit)i(\(often)d(as)h(lo)o(w)f(as)300 -425 y(20)d(op)q(en)g(\014les\).)300 489 y(The)33 b(mo)q(dule)h(in)140 -b Fh(cache.c)32 b Fm(main)o(tains)h(a)g(least)g(recen)o(tly)g(used)300 -539 y(list)f(of)124 b Fh(BFD_CACHE_MAX_OPEN)29 b Fm(\014les,)35 -b(and)c(exp)q(orts)g(the)g(name)300 589 y Fh(bfd_cache_lookup)24 -b Fm(whic)o(h)i(runs)g(around)g(and)g(mak)o(es)f(sure)h(that)f(the)300 -638 y(required)18 b(bfd)f(is)g(op)q(en.)25 b(If)17 b(not,)f(then)h(it)g(c)o -(ho)q(oses)f(a)h(\014le)g(to)f(close,)h(closes)h(it)300 688 -y(and)d(op)q(ens)h(the)f(one)h(w)o(an)o(ted,)e(returning)i(its)f(\014le)h -(handle.)0 833 y Fr(2.12.0.1)29 b(BFD)p 369 833 19 3 v 22 w(CA)n(CHE)p -611 833 V 23 w(MAX)p 784 833 V 23 w(OPEN)300 926 y Fm(The)19 -b(maxium)o(um)g(n)o(um)o(b)q(er)g(of)g(\014les)h(whic)o(h)f(the)g(cac)o(he)g -(will)i(k)o(eep)e(op)q(en)h(at)300 976 y(one)15 b(time.)300 -1005 y Fg(\013)p 325 1005 1326 2 v 1325 w(\010)p 300 1154 2 -125 v 314 1092 a Fh(#define)23 b(BFD_CACHE_MAX_OPEN)e(10)p -1677 1154 V 300 1180 a Fg(\012)p 325 1180 1326 2 v 1325 w(\011)0 -1375 y Fr(2.12.0.2)29 b(bfd)p 326 1375 19 3 v 22 w(last)p 443 -1375 V 22 w(cac)n(he)300 1467 y Fm(Zero,)15 b(or)h(a)f(p)q(oin)o(ter)i(to)e -(the)h(topmost)f(bfd)h(on)g(the)g(c)o(hain.)23 b(This)17 b(is)f(used)h(b)o(y) -300 1517 y(the)h(bfd)p 448 1517 14 2 v 17 w(cac)o(he)p 572 -1517 V 17 w(lo)q(okup\(\))g(macro)f(in)i(libbfd.h)h(to)d(determine)i(when)g -(it)f(can)300 1567 y(a)o(v)o(oid)d(a)g(function)h(call.)300 -1597 y Fg(\013)p 325 1597 1326 2 v 1325 w(\010)p 300 1745 2 -125 v 314 1683 a Fh(extern)23 b(bfd)h(*bfd_last_cache;)p 1677 -1745 V 300 1771 a Fg(\012)p 325 1771 1326 2 v 1325 w(\011)0 -1966 y Fr(2.12.0.3)29 b(bfd)p 326 1966 19 3 v 22 w(cac)n(he)p -492 1966 V 23 w(lo)r(okup)300 2058 y Fm(Chec)o(ks)11 b(to)g(see)h(if)f(the)h -(required)g(bfd)g(is)g(the)f(same)g(as)g(the)g(last)h(one)f(lo)q(ok)o(ed)h -(up.)300 2108 y(If)17 b(so)e(then)i(it)g(can)f(use)h(the)f(iostream)g(in)h -(the)f(bfd)h(with)g(impunit)o(y)l(,)g(since)h(it)300 2158 y(can't)13 -b(ha)o(v)o(e)f(c)o(hanged)i(since)g(the)f(last)g(lo)q(okup,)h(otherwise)f(it) -h(has)f(to)f(p)q(erform)300 2208 y(the)j(complicated)i(lo)q(okup)f(function) -300 2247 y Fg(\013)p 325 2247 1326 2 v 1325 w(\010)p 300 2594 -2 324 v 314 2333 a Fh(#define)23 b(bfd_cache_lookup\(x\))e(\\)433 -2383 y(\(\(x\)==bfd_last_cache?)g(\\)505 2433 y -(\(FILE*\)\(bfd_last_cache->io)o(stream\):)f(\\)529 2482 y -(bfd_cache_lookup_worker\(x)o(\)\))p 1677 2594 V 300 2620 a -Fg(\012)p 325 2620 1326 2 v 1325 w(\011)0 2770 y Fk(c)6 b(y)g(g)g(n)g(u)g(s) -36 b(s)6 b(u)g(p)g(p)g(o)g(r)g(t)p 332 2761 1396 3 v 1421 w(Revision:)17 -b(1.5)p eop -%%Page: 44 46 -bop 0 -58 a Fk(Chapter)13 b(2:)k(BFD)c(front)g(end)p 413 -66 -669 3 v 691 w(DRAFT)p 1224 -66 V 695 w Fj(44)0 183 y Fr(2.12.0.4)29 -b(bfd)p 326 183 19 3 v 22 w(cac)n(he)p 492 183 V 23 w(init)300 -275 y Fm(Initialize)18 b(a)d(BFD)g(b)o(y)g(putting)h(it)f(on)g(the)g(cac)o -(he)h(LR)o(U.)390 324 y Fh(PROTO\(void,)22 b(bfd_cache_init,)g(\(bfd)h -(*\)\);)0 457 y Fr(2.12.0.5)29 b(bfd)p 326 457 V 22 w(cac)n(he)p -492 457 V 23 w(close)300 549 y Fm(Remo)o(v)o(e)18 b(the)g(bfd)g(from)f(the)h -(cac)o(he.)28 b(If)18 b(the)g(attatc)o(hed)f(\014le)i(is)g(op)q(en,)g(then) -300 598 y(close)d(it)f(to)q(o.)390 648 y Fh(PROTO\(void,)22 -b(bfd_cache_close,)g(\(bfd)h(*\)\);)0 781 y Fr(2.12.0.6)29 -b(bfd)p 326 781 V 22 w(op)r(en)p 477 781 V 22 w(\014le)300 -872 y Fm(Call)13 b(the)f(OS)g(to)f(op)q(en)i(a)f(\014le)h(for)e(this)h(BFD.)f -(Returns)i(the)f(FILE)g(*)g(\(p)q(ossibly)300 922 y(n)o(ull\))g(that)f -(results)h(from)e(this)i(op)q(eration.)19 b(Sets)11 b(up)h(the)f(BFD)g(so)g -(that)g(future)300 972 y(accesses)18 b(kno)o(w)e(the)i(\014le)g(is)g(op)q -(en.)26 b(If)18 b(the)f(FILE)h(*)e(returned)i(is)g(n)o(ull,)h(then)300 -1022 y(there)h(is)h(w)o(on't)d(ha)o(v)o(e)i(b)q(een)h(put)f(in)h(the)f(cac)o -(he,)h(so)e(it)i(w)o(on't)d(ha)o(v)o(e)i(to)f(b)q(e)300 1072 -y(remo)o(v)o(ed)c(from)f(it.)390 1121 y Fh(PROTO\(FILE)22 b(*,)i -(bfd_open_file,)e(\(bfd)h(*\)\);)0 1254 y Fr(2.12.0.7)29 b(bfd)p -326 1254 V 22 w(cac)n(he)p 492 1254 V 23 w(lo)r(okup)p 696 -1254 V 22 w(w)n(ork)n(er)300 1346 y Fm(Called)23 b(when)f(the)f(macro)59 -b Fh(bfd_cache_lookup)19 b Fm(fails)j(to)f(\014nd)h(a)f(quic)o(k)300 -1395 y(answ)o(er.)31 b(Finds)20 b(a)f(\014le)i(descriptor)e(for)g(this)h -(BFD.)e(If)i(necessary)l(,)g(it)f(op)q(en)300 1445 y(it.)28 -b(If)19 b(there)f(are)f(already)h(more)g(than)g(BFD)p 1106 -1445 14 2 v 16 w(CA)o(CHE)p 1286 1445 V 16 w(MAX)p 1412 1445 -V 16 w(OPEN)g(\014les)300 1495 y(op)q(en,)13 b(it)f(trys)f(to)g(close)h(one)g -(\014rst,)g(to)f(a)o(v)o(oid)h(running)g(out)g(of)f(\014le)i(descriptors.)390 -1545 y Fh(PROTO\(FILE)22 b(*,)i(bfd_cache_lookup_worker,)d(\(bfd)i(*\)\);)0 -2770 y Fk(c)6 b(y)g(g)g(n)g(u)g(s)36 b(s)6 b(u)g(p)g(p)g(o)g(r)g(t)p -332 2761 1396 3 v 1421 w(Revision:)17 b(1.5)p eop -%%Page: 45 47 -bop 0 -58 a Fk(Chapter)13 b(3:)k(BFD)c(back)f(end)p 409 -66 -670 3 v 693 w(DRAFT)p 1222 -66 V 697 w Fj(45)0 183 y Fi(3)41 -b(BFD)27 b(bac)n(k)f(end)300 295 y Fm(All)16 b(of)f(bfd)h(liv)o(es)g(in)g -(one)f(directory)l(.)0 2770 y Fk(c)6 b(y)g(g)g(n)g(u)g(s)36 -b(s)6 b(u)g(p)g(p)g(o)g(r)g(t)p 332 2761 1396 3 v 1421 w(Revision:)17 -b(1.5)p eop -%%Page: 46 48 -bop 0 -58 a Fk(Chapter)13 b(3:)k(BFD)c(back)f(end)p 409 -66 -670 3 v 693 w(DRAFT)p 1222 -66 V 697 w Fj(46)0 183 y Fn(3.1)33 -b(a.out)21 b(bac)n(k)n(ends)300 278 y Fm(BFD)13 b(supp)q(orts)g(a)g(n)o(um)o -(b)q(er)h(of)f(di\013eren)o(t)g(\015a)o(v)o(ours)g(of)g(a.out)f(format,)g -(though)300 328 y(the)h(ma)s(jor)e(di\013erences)j(are)f(only)g(the)g(sizes)h -(of)f(the)g(structures)f(on)h(disk,)h(and)300 378 y(the)h(shap)q(e)h(of)f -(the)g(relo)q(cation)h(information.)300 444 y(The)f(supp)q(ort)f(is)h(split)h -(in)o(to)e(a)g(basic)h(supp)q(ort)g(\014le)g Fh(aoutx.h)e Fm(and)i(other)f -(\014les)300 494 y(whic)o(h)e(deriv)o(e)h(functions)f(from)f(the)h(base.)18 -b(One)13 b(deriv)m(ation)f(\014le)h(is)f Fh(aoutf1.h)300 544 -y Fm(\(for)k(a.out)g(\015a)o(v)o(our)g(1\),)h(and)g(adds)g(to)f(the)h(basic)h -(a.out)e(functions)i(supp)q(ort)300 593 y(for)12 b(sun3,)h(sun4,)f(386)g(and) -h(29k)e(a.out)h(\014les,)i(to)d(create)i(a)f(target)f(jump)i(v)o(ector)300 -643 y(for)i(a)f(sp)q(eci\014c)k(target.)300 709 y(This)e(information)g(is)h -(further)e(split)i(out)f(in)o(to)g(more)f(sp)q(eci\014c)j(\014les)f(for)e -(eac)o(h)300 759 y(mac)o(hine,)j(including)30 b Fh(sunos.c)16 -b Fm(-)h(for)f(sun3)h(and)g(sun4)g(and)28 b Fh(demo64)16 b -Fm(for)g(a)300 809 y(demonstration)f(of)g(a)g(64)f(bit)i(a.out)e(format.)300 -875 y(The)k(base)g(\014le)34 b Fh(aoutx.h)16 b Fm(de\014nes)j(general)f(mec)o -(hanisms)g(for)g(reading)g(and)300 925 y(writing)f(records)g(to)f(and)h(from) -f(disk,)i(and)f(v)m(arious)g(other)f(metho)q(ds)h(whic)o(h)300 -975 y(bfd)f(requires.)23 b(It)15 b(is)i(included)h(b)o(y)i -Fh(aout32.c)14 b Fm(and)20 b Fh(aout64.c)15 b Fm(to)g(form)g(the)300 -1024 y(names)31 b(aout)p 547 1024 14 2 v 16 w(32)p 609 1024 -V 16 w(sw)o(ap)p 723 1024 V 16 w(exec)p 823 1024 V 17 w(header)p -971 1024 V 16 w(in,)36 b(aout)p 1162 1024 V 16 w(64)p 1224 -1024 V 16 w(sw)o(ap)p 1338 1024 V 16 w(exec)p 1438 1024 V 17 -w(header)p 1586 1024 V 16 w(in,)300 1074 y(etc.)300 1140 y(As)13 -b(an)f(example,)i(this)f(is)g(what)f(go)q(es)h(on)f(to)g(mak)o(e)g(the)h(bac) -o(k)g(end)g(for)f(a)g(sun4,)300 1190 y(from)i(aout32.c)462 -1240 y Fh(#define)22 b(ARCH_SIZE)h(32)462 1290 y(#include)f("aoutx.h")390 -1356 y Fm(Whic)o(h)16 b(exp)q(orts)f(names:)115 b Fh(...)462 -1406 y(aout_32_canonicalize_re)o(loc)462 1455 y(aout_32_find_nearest_li)o(ne) -462 1505 y(aout_32_get_lineno)462 1555 y(aout_32_get_reloc_upper)o(_bound)509 -1605 y(...)300 1671 y Fm(from)14 b(sunos.c)485 1721 y Fh(#define)23 -b(ARCH)h(32)485 1771 y(#define)f(TARGET_NAME)g("a.out-sunos-big")485 -1820 y(#define)g(VECNAME)95 b(sunos_big_vec)485 1870 y(#include)23 -b("aoutf1.h")300 1936 y Fm(requires)16 b(all)g(the)f(names)h(from)e -(aout32.c,)f(and)j(pro)q(duces)g(the)f(jump)h(v)o(ector)485 -1986 y Fh(sunos_big_vec)0 2153 y Fr(3.1.1)30 b(relo)r(cations)300 -2248 y Fm(The)17 b(\014le)29 b Fh(aoutx.h)16 b Fm(caters)h(for)f(b)q(oth)h -(the)g Ff(standard)i Fm(and)e Ff(extended)j Fm(forms)300 2298 -y(of)15 b(a.out)f(relo)q(cation)i(records.)300 2364 y(The)21 -b(standard)f(records)h(are)f(c)o(haracterised)h(b)o(y)g(con)o(taining)g(only) -g(an)g(ad-)300 2414 y(dress,)16 b(a)g(sym)o(b)q(ol)g(index)i(and)e(a)g(t)o -(yp)q(e)g(\014eld.)24 b(The)17 b(extended)g(records)f(\(used)300 -2463 y(on)f(29ks)g(and)g(sparcs\))g(also)g(ha)o(v)o(e)g(a)g(full)h(in)o -(teger)f(for)g(an)g(addend.)0 2630 y Fr(3.1.2)30 b(In)n(ternal)20 -b(En)n(try)i(P)n(oin)n(ts)0 2770 y Fk(c)6 b(y)g(g)g(n)g(u)g(s)36 -b(s)6 b(u)g(p)g(p)g(o)g(r)g(t)p 332 2761 1396 3 v 1421 w(Revision:)17 -b(1.5)p eop -%%Page: 47 49 -bop 0 -58 a Fk(Chapter)13 b(3:)k(BFD)c(back)f(end)p 409 -66 -670 3 v 693 w(DRAFT)p 1222 -66 V 697 w Fj(47)324 183 y Fh(aoutx.h)18 -b Fm(exp)q(orts)h(sev)o(eral)g(routines)h(for)f(accessing)g(the)h(con)o(ten)o -(ts)e(of)h(an)300 233 y(a.out)12 b(\014le,)h(whic)o(h)h(are)e(gathered)g(and) -h(exp)q(orted)g(in)g(turn)g(b)o(y)f(v)m(arious)h(format)300 -283 y(sp)q(eci\014c)k(\014les)f(\(eg)f(sunos.c\).)0 417 y Fr(3.1.2.1)30 -b(aout)p 328 417 19 3 v 21 w Fo(<)p Fr(size)p Fo(>)p 501 417 -V 23 w Fr(sw)n(ap)p 654 417 V 23 w(exec)p 792 417 V 22 w(header)p -993 417 V 23 w(in)300 509 y Fm(Sw)o(aps)11 b(the)h(information)f(in)i(an)e -(executable)i(header)f(tak)o(en)f(from)f(a)i(ra)o(w)e(b)o(yte)300 -559 y(stream)k(memory)h(image,)g(in)o(to)g(the)g(in)o(ternal)h(exec)p -1194 559 14 2 v 17 w(header)g(structure.)390 608 y Fh(PROTO\(void,)22 -b(aout__swap_exec_header_)o(in,)533 658 y(\(bfd)h(*abfd,)533 -708 y(struct)g(external_exec)f(*raw_bytes,)533 758 y(struct)h(internal_exec)f -(*execp\)\);)0 892 y Fr(3.1.2.2)30 b(aout)p 328 892 19 3 v -21 w Fo(<)p Fr(size)p Fo(>)p 501 892 V 23 w Fr(sw)n(ap)p 654 -892 V 23 w(exec)p 792 892 V 22 w(header)p 993 892 V 23 w(out)300 -984 y Fm(Sw)o(aps)16 b(the)f(information)i(in)f(an)g(in)o(ternal)h(exec)f -(header)g(structure)g(in)o(to)g(the)300 1033 y(supplied)i(bu\013er)d(ready)g -(for)f(writing)i(to)f(disk.)390 1083 y Fh(PROTO\(void,)22 b -(aout__swap_exec_header_)o(out,)438 1133 y(\(bfd)h(*abfd,)462 -1183 y(struct)g(internal_exec)f(*execp,)462 1233 y(struct)h(external_exec)f -(*raw_bytes\)\);)0 1367 y Fr(3.1.2.3)30 b(aout)p 328 1367 V -21 w Fo(<)p Fr(size)p Fo(>)p 501 1367 V 23 w Fr(some)p 658 -1367 V 22 w(aout)p 799 1367 V 22 w(ob)s(ject)p 987 1367 V 22 -w(p)300 1459 y Fm(Some)11 b(A.OUT)f(v)m(arian)o(t)h(thinks)g(that)f(the)h -(\014le)h(whose)f(format)e(w)o(e're)h(c)o(hec)o(king)300 1508 -y(is)18 b(an)f(a.out)g(\014le.)28 b(Do)17 b(some)g(more)g(c)o(hec)o(king,)h -(and)g(set)f(up)h(for)f(access)h(if)g(it)300 1558 y(really)f(is.)k(Call)16 -b(bac)o(k)g(to)f(the)g(calling)j(en)o(vironmen)o(ts)e Fh(")p -Fm(\014nish)g(up)p Fh(")g Fm(function)300 1608 y(just)f(b)q(efore)g -(returning,)h(to)e(handle)j(an)o(y)e(last-min)o(ute)h(setup.)390 -1658 y Fh(PROTO\(bfd_target)22 b(*,)h(aout__some_aout_object)o(_p,)414 -1708 y(\(bfd)g(*abfd,)438 1757 y(bfd_target)f(*\(*callback_to_real_object_p)o -(\)\(\)\)\);)0 1892 y Fr(3.1.2.4)30 b(aout)p 328 1892 V 21 -w Fo(<)p Fr(size)p Fo(>)p 501 1892 V 23 w Fr(mk)n(ob)s(ject)300 -1983 y Fm(This)16 b(routine)f(initialize)q(s)j(a)d(bfd)g(for)g(use)g(with)h -(a.out)e(\014les.)390 2033 y Fh(PROTO\(boolean,)22 b(aout__mkobject,)f -(\(bfd)i(*\)\);)0 2167 y Fr(3.1.2.5)30 b(aout)p 328 2167 V -21 w Fo(<)p Fr(size)p Fo(>)p 501 2167 V 23 w Fr(mac)n(hine)p -743 2167 V 23 w(t)n(yp)r(e)300 2259 y Fm(Keep)22 b(trac)o(k)e(of)h(mac)o -(hine)h(arc)o(hitecture)g(and)f(mac)o(hine)h(t)o(yp)q(e)f(for)g(a.out's.)300 -2309 y(Return)39 b(the)f(mac)o(hine)p 744 2309 14 2 v 17 w(t)o(yp)q(e)h(for)e -(a)h(particular)h(arc)o(h&mac)o(hine,)44 b(or)300 2358 y(M)p -345 2358 V 16 w(UNKNO)o(WN)25 b(if)g(that)e(exact)h(arc)o(h&mac)o(hine)i -(can't)d(b)q(e)i(represen)o(ted)300 2408 y(in)16 b(a.out)e(format.)300 -2471 y(If)20 b(the)g(arc)o(hitecture)g(is)h(understo)q(o)q(d,)g(mac)o(hine)g -(t)o(yp)q(e)f(0)f(\(default\))h(should)300 2521 y(alw)o(a)o(ys)14 -b(b)q(e)i(understo)q(o)q(d.)390 2570 y Fh(PROTO\(enum)22 b(machine_type,)h -(aout__machine_typ)o(e,)414 2620 y(\(enum)g(bfd_architecture)f(arch,) -438 2670 y(unsigned)g(long)i(machine\)\);)0 2770 y Fk(c)6 b(y)g(g)g(n)g(u)g -(s)36 b(s)6 b(u)g(p)g(p)g(o)g(r)g(t)p 332 2761 1396 3 v 1421 -w(Revision:)17 b(1.5)p eop -%%Page: 48 50 -bop 0 -58 a Fk(Chapter)13 b(3:)k(BFD)c(back)f(end)p 409 -66 -670 3 v 693 w(DRAFT)p 1222 -66 V 697 w Fj(48)0 183 y Fr(3.1.2.6)30 -b(aout)p 328 183 19 3 v 21 w Fo(<)p Fr(size)p Fo(>)p 501 183 -V 23 w Fr(set)p 600 183 V 22 w(arc)n(h)p 736 183 V 23 w(mac)n(h)300 -275 y Fm(Sets)13 b(the)h(arc)o(hitecture)f(and)g(the)h(mac)o(hine)g(of)f(the) -g(bfd)h(to)e(those)h(v)m(alues)h(sup-)300 324 y(plied.)21 b(V)l(eri\014es)14 -b(that)e(the)h(format)e(can)i(supp)q(ort)g(the)g(arc)o(hitecture)g(required.) -390 374 y Fh(PROTO\(boolean,)22 b(aout__set_arch_mach,)414 -424 y(\(bfd)h(*,)438 474 y(enum)g(bfd_architecture,)438 524 -y(unsigned)f(long)i(machine\)\);)0 656 y Fr(3.1.2.7)30 b(aout)p -328 656 V 21 w Fo(<)p Fr(size)p Fo(>)p Fr(new)p 607 656 V 23 -w(section)p 815 656 V 23 w(ho)r(ok)300 748 y Fm(Called)16 b(b)o(y)g(the)f -(bfd)g(in)h(resp)q(onse)g(to)f(a)g Fh(bfd_make_section)e Fm(request.)390 -798 y Fh(PROTO\(boolean,)22 b(aout__new_section_ho)o(ok,)605 -847 y(\(bfd)h(*abfd,)438 897 y(asection)f(*newsect\)\);)0 2770 -y Fk(c)6 b(y)g(g)g(n)g(u)g(s)36 b(s)6 b(u)g(p)g(p)g(o)g(r)g(t)p -332 2761 1396 3 v 1421 w(Revision:)17 b(1.5)p eop -%%Page: 49 51 -bop 0 -58 a Fk(Chapter)13 b(3:)k(BFD)c(back)f(end)p 409 -66 -670 3 v 693 w(DRAFT)p 1222 -66 V 697 w Fj(49)0 183 y Fn(3.2)33 -b(co\013)22 b(bac)n(k)n(ends)300 275 y Fm(BFD)e(supp)q(orts)h(a)g(n)o(um)o(b) -q(er)g(of)g(di\013eren)o(t)g(\015a)o(v)o(ours)f(of)h(co\013)f(format.)36 -b(The)300 325 y(ma)s(jor)20 b(di\013erence)k(b)q(et)o(w)o(een)e(formats)e -(are)i(the)g(sizes)h(and)f(alignmen)o(ts)g(of)300 375 y(\014elds)16 -b(in)g(structures)f(on)g(disk,)h(and)f(the)h(o)q(ccasional)g(extra)e -(\014eld.)300 438 y(Co\013)i(in)h(all)h(its)f(v)m(arieties)h(is)f(implimen)o -(ted)i(with)e(a)f(few)h(common)f(\014les)i(and)300 488 y(a)j(n)o(um)o(b)q(er) -h(of)e(implemen)o(tation)j(sp)q(eci\014c)g(\014les.)39 b(F)l(or)21 -b(example,)i(The)f(88k)300 538 y(b)q(cs)d(co\013)g(format)e(is)j(implemen)o -(ted)g(in)g(the)f(\014le)42 b Fh(m88k-bcs.c)p Fm(.)30 b(This)19 -b(\014le)300 588 y Fh(#include)p Fm(s)29 b Fh(m88k-bcs.h)15 -b Fm(whic)o(h)k(de\014nes)f(the)f(external)h(structure)f(of)g(the)300 -637 y(co\013)k(format)f(for)g(the)i(88k,)f(and)58 b Fh(internalcoff.h)19 -b Fm(whic)o(h)k(de\014nes)f(the)300 687 y(in)o(ternal)f(structure.)68 -b Fh(m88k-bcs.c)19 b Fm(also)h(de\014nes)i(the)e(relo)q(cations)h(used)300 -737 y(b)o(y)16 b(the)h(88k)e(format)g(See)i(Section)g(2.7)f([Relo)q -(cations],)g(page)h(28.)22 b(Then)17 b(the)300 787 y(ma)s(jor)f(p)q(ortion)i -(of)f(co\013)g(co)q(de)h(is)g(included)i(\()14 b Fh(coffcode.h)p -Fm(\))i(whic)o(h)i(de\014nes)300 837 y(the)d(metho)q(ds)h(used)g(to)f(act)g -(up)q(on)h(the)f(t)o(yp)q(es)h(de\014ned)g(in)i Fh(m88k-bcs.h)c -Fm(and)300 886 y Fh(internalcoff.h)p Fm(.)300 950 y(The)j(In)o(tel)g(i960)f -(pro)q(cessor)g(v)o(ersion)g(of)g(co\013)g(is)h(implemen)o(ted)h(in)23 -b Fh(icoff.c)p Fm(.)300 999 y(This)g(\014le)g(has)f(the)g(same)f(structure)h -(as)63 b Fh(m88k-bcs.c)p Fm(,)22 b(except)g(that)g(it)300 1049 -y(includes)17 b Fh(intel-coff.h)d Fm(rather)h(than)g Fh(m88k-bcs.h)p -Fm(.)0 1190 y Fr(3.2.1)30 b(P)n(orting)20 b(T)-5 b(o)20 b(A)g(New)h(V)-5 -b(ersion)21 b(of)f(Co\013)300 1282 y Fm(The)14 b(recommended)g(metho)q(d)g -(is)g(to)f(select)h(from)f(the)h(existing)g(implimen)o(ta-)300 -1332 y(tions)d(the)g(v)o(ersion)h(of)e(co\013)h(whic)o(h)h(is)g(most)e(lik)o -(e)i(the)f(one)g(y)o(ou)g(w)o(an)o(t)f(to)h(use,)h(for)300 -1381 y(our)j(purp)q(oses,)h(w)o(e'll)g(sa)o(y)f(that)g(i386)g(co\013)g(is)h -(the)f(one)h(y)o(ou)f(select,)h(and)g(that)300 1431 y(y)o(our)f(co\013)g -(\015a)o(v)o(our)g(is)h(called)h(fo)q(o.)k(Cop)o(y)15 b(the)j -Fh(i386coff.c)c Fm(to)k Fh(foocoff.c)p Fm(,)300 1481 y(cop)o(y)k -Fh(../include/i386coff.h)14 b Fm(to)22 b Fh(../include/foocoff.h)13 -b Fm(and)k(add)300 1531 y(the)d(lines)i(to)d Fh(targets.c)g -Fm(and)i Fh(Makefile.in)d Fm(so)i(that)f(y)o(our)h(new)g(bac)o(k)g(end)300 -1581 y(is)i(used.)300 1644 y(Alter)d(the)h(shap)q(es)f(of)g(the)g(structures) -g(in)h Fh(../include/foocoff.h)c Fm(so)j(that)300 1694 y(they)21 -b(matc)o(h)f(what)g(y)o(ou)g(need.)38 b(Y)l(ou)21 b(will)h(probably)f(also)g -(ha)o(v)o(e)f(to)g(add)300 1743 y Fh(#ifdef)p Fm(s)d(to)h(the)g(co)q(de)g(in) -37 b Fh(internalcoff.h)16 b Fm(and)35 b Fh(coffcode.h)17 b -Fm(if)h(y)o(our)300 1793 y(v)o(ersion)d(of)g(co\013)g(is)g(to)q(o)g(wild.)300 -1856 y(Y)l(ou)21 b(can)f(v)o(erify)h(that)f(y)o(our)g(new)h(bfd)g(bac)o(k)o -(end)f(w)o(orks)g(quite)h(simply)h(b)o(y)300 1906 y(building)14 -b Fh(objdump)d Fm(from)g(the)g Fh(binutils)g Fm(directory)l(,)h(and)g(making) -g(sure)g(that)300 1956 y(its)i(v)o(ersion)g(of)g(what's)e(going)i(on)g(at)f -(y)o(our)h(host)f(systems)g(idea)i(\(assuming)f(it)300 2006 -y(has)j(the)f(prett)o(y)g(standard)g(co\013)g(dump)i(utilit)o(y)f(\(usually)h -(called)27 b Fh(att-dump)300 2055 y Fm(or)15 b(just)g Fh(dump)p -Fm(\)\))f(are)g(the)i(same.)300 2119 y(Then)21 b(clean)g(up)g(y)o(our)f(co)q -(de,)i(and)e(send)h(what)f(y)o(ou'v)o(e)f(done)i(to)f(Cygn)o(us.)300 -2168 y(Then)f(y)o(our)e(stu\013)h(will)i(b)q(e)f(in)g(the)f(next)g(release,)i -(and)e(y)o(ou)g(w)o(on't)f(ha)o(v)o(e)h(to)300 2218 y(k)o(eep)e(in)o -(tegrating)f(it.)0 2359 y Fr(3.2.2)30 b(Ho)n(w)21 b(The)f(Co\013)g(Bac)n(k)n -(end)h(W)-5 b(orks)0 2528 y(3.2.2.1)30 b(Bit)20 b(Twiddling)300 -2620 y Fm(Eac)o(h)c(\015a)o(v)o(our)f(of)g(co\013)h(supp)q(orted)g(in)h(bfd)f -(has)g(its)g(o)o(wn)f(header)h(\014le)h(descib-)300 2670 y(ing)i(the)f -(external)g(la)o(y)o(out)g(of)g(the)g(structures.)28 b(There)18 -b(is)h(also)f(an)g(in)o(ternal)0 2770 y Fk(c)6 b(y)g(g)g(n)g(u)g(s)36 -b(s)6 b(u)g(p)g(p)g(o)g(r)g(t)p 332 2761 1396 3 v 1421 w(Revision:)17 -b(1.5)p eop -%%Page: 50 52 -bop 0 -58 a Fk(Chapter)13 b(3:)k(BFD)c(back)f(end)p 409 -66 -670 3 v 693 w(DRAFT)p 1222 -66 V 697 w Fj(50)300 183 y Fm(description)18 -b(of)d(the)h(co\013)g(la)o(y)o(out)f(\(in)21 b Fh(internalcoff.h)p -Fm(\))14 b(\014le)j(\()5 b(\).)21 b(A)16 b(ma)s(jor)300 233 -y(function)f(of)f(the)g(co\013)f(bac)o(k)o(end)i(is)f(sw)o(apping)h(the)f(b)o -(ytes)g(and)g(t)o(widdling)i(the)300 283 y(bits)g(to)f(translate)g(the)g -(external)h(form)f(of)g(the)g(structures)g(in)o(to)g(the)h(normal)300 -333 y(in)o(ternal)f(form.)j(This)d(is)f(all)h(p)q(erformed)f(in)h(the)f -Fh(bfd_swap)p 1340 333 14 2 v 15 w Ff(thing)p 1462 333 V 21 -w(direction)300 382 y Fm(routines.)19 b(Some)13 b(elemen)o(ts)g(are)f -(di\013eren)o(t)g(sizes)i(b)q(et)o(w)o(een)e(di\013eren)o(t)h(v)o(ersions)300 -432 y(of)f(co\013,)f(it)h(is)h(the)f(dut)o(y)g(of)f(the)h(co\013)f(v)o -(ersion)i(sp)q(eci\014c)g(include)i(\014le)e(to)e(o)o(v)o(erride)300 -482 y(the)18 b(de\014nitions)i(of)d(v)m(arious)i(pac)o(king)f(routines)g(in) -36 b Fh(coffcode.h)p Fm(.)26 b(Eg)18 b(the)300 532 y(size)d(of)e(line)i(n)o -(um)o(b)q(er)g(en)o(try)e(in)i(co\013)e(is)h(sometimes)g(16)f(bits,)h(and)g -(sometimes)300 582 y(32)h(bits.)22 b Fh(#define)p Fm(ing)17 -b Fh(PUT_LNSZ_LNNO)c Fm(and)k Fh(GET_LNSZ_LNNO)d Fm(will)j(select)300 -632 y(the)f(correct)g(one.)24 b(No)16 b(doubt,)g(some)g(da)o(y)g(someone)g -(will)i(\014nd)f(a)f(v)o(ersion)g(of)300 681 y(co\013)d(whic)o(h)i(has)e(a)h -(v)m(arying)g(\014eld)h(size)g(not)e(catered)h(for)f(at)g(the)h(momen)o(t.)k -(T)l(o)300 731 y(p)q(ort)d(bfd,)g(that)g(p)q(erson)g(will)i(ha)o(v)o(e)e(to)f -(add)i(more)e Fh(#defines)p Fm(.)300 793 y(Three)29 b(of)f(the)h(bit)g(t)o -(widdling)h(routines)f(are)g(exp)q(orted)g(to)108 b Fh(gdb)p -Fm(;)300 843 y Fh(coff_swap_aux_in)p Fm(,)19 b Fh(coff_swap_sym_in)14 -b Fm(and)21 b Fh(coff_swap_linno_in)p Fm(.)300 893 y Fh(GDB)14 -b Fm(reads)f(the)i(sym)o(b)q(ol)f(table)g(on)g(its)h(o)o(wn,)e(but)h(uses)g -(bfd)h(to)e(\014x)h(things)h(up.)0 1022 y Fr(3.2.2.2)30 b(Sym)n(b)r(ol)20 -b(Reading)300 1113 y Fm(The)12 b(simple)i(canonical)f(form)e(for)g(sym)o(b)q -(ols)h(used)h(b)o(y)f(bfd)g(is)h(not)e(ric)o(h)i(enough)300 -1163 y(to)f(k)o(eep)h(all)g(the)g(information)f(a)o(v)m(ailable)j(in)e(a)f -(co\013)g(sym)o(b)q(ol)h(table.)19 b(The)13 b(bac)o(k)300 1213 -y(end)20 b(gets)e(around)h(this)g(b)o(y)g(k)o(eeping)h(the)f(original)h(sym)o -(b)q(ol)f(table)g(around,)300 1263 y Fh(")p Fm(b)q(ehind)e(the)e(sceens)p -Fh(")p Fm(.)300 1325 y(When)c(a)e(sym)o(b)q(ol)i(table)f(is)h(requested)g -(\(through)e(a)h(call)h(to)f Fh(bfd_canonicalize_symtab)p Fm(,)p -2166 1336 21 46 v 300 1375 a(a)16 b(request)g(gets)f(through)h(to)k -Fh(get_normalized_symtab)p Fm(.)f(This)e(reads)f(the)300 1425 -y(sym)o(b)q(ol)k(table)g(from)f(the)h(co\013)f(\014le)i(and)f(sw)o(aps)f(all) -i(the)f(structures)f(inside)300 1474 y(in)o(to)e(the)h(in)o(ternal)g(form.)25 -b(It)18 b(also)f(\014xes)h(up)g(all)g(the)f(p)q(oin)o(ters)h(in)g(the)g -(table)300 1524 y(\(represen)o(ted)e(in)g(the)f(\014le)i(b)o(y)e(o\013sets)f -(from)h(the)g(\014rst)g(sym)o(b)q(ol)h(in)g(the)g(table\))300 -1574 y(in)o(to)k(ph)o(ysical)h(p)q(oin)o(ters)f(to)f(elemen)o(ts)h(in)h(the)f -(new)g(in)o(ternal)g(table.)34 b(This)300 1624 y(in)o(v)o(olv)o(es)18 -b(some)g(w)o(ork)f(since)i(the)f(meanings)h(of)f(\014elds)h(c)o(hanges)f(dep) -q(ending)300 1674 y(up)q(on)i(con)o(text;)h(a)e(\014eld)h(that)f(is)h(a)f(p)q -(oin)o(ter)h(to)f(another)g(structure)g(in)h(the)300 1724 y(sym)o(b)q(ol)c -(table)f(at)g(one)g(momen)o(t)g(ma)o(y)f(b)q(e)i(the)f(size)i(in)f(b)o(ytes)f -(of)f(a)h(structure)300 1773 y(in)h(the)f(next.)300 1836 y(Another)k(pass)f -(is)h(made)g(o)o(v)o(er)f(the)h(table.)30 b(All)20 b(sym)o(b)q(ols)f(whic)o -(h)h(mark)e(\014le)300 1885 y(names)i(\()26 b Fh(C_FILE)19 -b Fm(sym)o(b)q(ols\))h(are)f(mo)q(di\014ed)i(so)f(that)f(the)g(in)o(ternal)i -(string)300 1935 y(p)q(oin)o(ts)15 b(to)f(the)h(v)m(alue)h(in)g(the)e(auxen)o -(t)h(\(the)g(real)g(\014lename\))g(rather)f(than)h(the)300 -1985 y(normal)g(text)g(asso)q(ciated)g(with)h(the)f(sym)o(b)q(ol)h(\()p -Fh(".file")p Fm(\).)300 2047 y(A)o(t)j(this)h(time)f(the)h(sym)o(b)q(ol)f -(names)h(are)f(mo)o(v)o(ed)g(around.)32 b(Co\013)18 b(stores)h(all)300 -2097 y(sym)o(b)q(ols)d(less)g(than)f(nine)i(c)o(haracters)d(long)i(ph)o -(ysically)h(within)g(the)f(sym)o(b)q(ol)300 2147 y(table,)d(longer)h(strings) -e(are)h(k)o(ept)g(at)f(the)h(end)h(of)e(the)h(\014le)h(in)g(the)f(string)g -(table.)300 2197 y(This)22 b(pass)e(mo)o(v)o(es)h(all)h(strings)f(in)o(to)g -(memory)l(,)g(and)h(replaces)g(them)f(with)300 2247 y(p)q(oin)o(ters)16 -b(to)e(the)h(strings.)300 2309 y(The)20 b(sym)o(b)q(ol)h(table)g(is)g -(massaged)e(once)i(again,)g(this)g(time)f(to)g(create)g(the)300 -2359 y(canonical)12 b(table)f(used)h(b)o(y)f(the)g(bfd)g(application.)20 -b(Eac)o(h)11 b(sym)o(b)q(ol)g(is)g(insp)q(ected)300 2408 y(in)21 -b(turn,)f(and)g(a)g(decision)i(made)e(\(using)g(the)48 b Fh(sclass)19 -b Fm(\014eld\))i(ab)q(out)f(the)300 2458 y(v)m(arious)12 b(\015ags)f(to)f -(set)i(in)g(the)f Fh(asymbol)g Fm(See)g(Section)i(2.4)d([Sym)o(b)q(ols],)i -(page)f(14.)300 2508 y(The)h(generated)g(canonical)h(table)f(shares)f -(strings)h(with)g(the)g(hidden)h(in)o(ternal)300 2558 y(sym)o(b)q(ol)j -(table.)300 2620 y(An)o(y)d(linen)o(um)o(b)q(ers)i(are)e(read)g(from)f(the)i -(co\013)e(\014le)i(to)q(o,)f(and)g(attatc)o(hed)f(to)h(the)300 -2670 y(sym)o(b)q(ols)i(whic)o(h)i(o)o(wn)d(the)i(functions)f(the)h(linen)o -(um)o(b)q(ers)h(b)q(elong)f(to.)0 2770 y Fk(c)6 b(y)g(g)g(n)g(u)g(s)36 -b(s)6 b(u)g(p)g(p)g(o)g(r)g(t)p 332 2761 1396 3 v 1421 w(Revision:)17 -b(1.5)p eop -%%Page: 51 53 -bop 0 -58 a Fk(Chapter)13 b(3:)k(BFD)c(back)f(end)p 409 -66 -670 3 v 693 w(DRAFT)p 1222 -66 V 697 w Fj(51)0 183 y Fr(3.2.2.3)30 -b(Sym)n(b)r(ol)20 b(W)-5 b(riting)300 277 y Fm(W)l(riting)15 -b(a)e(sym)o(b)q(ol)i(to)e(a)h(co\013)g(\014le)h(whic)o(h)g(didn't)f(come)h -(from)e(a)h(co\013)f(\014le)i(will)300 327 y(lose)h(an)o(y)g(debugging)g -(information.)22 b(The)e Fh(asymbol)14 b Fm(structure)i(remem)o(b)q(ers)300 -377 y(the)k(bfd)g(from)f(whic)o(h)h(w)o(as)f(b)q(orn,)i(and)f(on)f(output)h -(the)g(bac)o(k)f(end)i(mak)o(es)300 427 y(sure)15 b(that)g(the)g(same)g -(destination)h(target)e(as)h(source)g(target)f(is)i(presen)o(t.)300 -492 y(When)f(the)g(sym)o(b)q(ols)g(ha)o(v)o(e)f(come)h(from)f(a)g(co\013)h -(\014le)g(then)g(all)h(the)f(debugging)300 541 y(information)g(is)h(preserv)o -(ed.)300 606 y(Sym)o(b)q(ol)i(tables)g(are)f(pro)o(vided)i(for)e(writing)h -(to)f(the)g(bac)o(k)h(end)g(in)g(a)g(v)o(ector)300 656 y(of)h(p)q(oin)o(ters) -i(to)e(p)q(oin)o(ters.)34 b(This)20 b(allo)o(ws)g(applications)i(lik)o(e)f -(the)f(link)o(er)h(to)300 706 y(accum)o(ulate)13 b(and)g(output)g(large)g -(sym)o(b)q(ol)g(tables)h(without)e(ha)o(ving)i(to)e(do)h(to)q(o)300 -756 y(m)o(uc)o(h)i(b)o(yte)g(cop)o(ying.)300 821 y(The)j(sym)o(b)q(ol)g -(table)g(is)g(not)f(output)h(to)f(a)g(writable)i(bfd)f(un)o(til)g(it)g(is)g -(closed.)300 870 y(The)d(order)g(of)f(op)q(erations)h(on)g(the)g(canonical)h -(sym)o(b)q(ol)g(table)f(at)f(that)g(p)q(oin)o(t)300 920 y(are:)300 -985 y Fh(coff_renumber_symbols)450 1035 y Fm(This)20 b(function)h(runs)f -(through)g(the)g(pro)o(vided)g(sym)o(b)q(ol)g(table)h(and)450 -1085 y(patc)o(hes)16 b(eac)o(h)h(sym)o(b)q(ol)f(mark)o(ed)g(as)g(a)g(\014le)h -(place)h(holder)f(\()7 b Fh(C_FILE)p Fm(\))450 1135 y(to)13 -b(p)q(oin)o(t)g(to)g(the)g(next)g(\014le)i(place)f(holder)g(in)g(the)f(list.) -20 b(It)13 b(also)h(marks)450 1185 y(eac)o(h)43 b Fh(offset)18 -b Fm(\014eld)j(in)f(the)f(list)h(with)f(the)h(o\013set)e(from)g(the)h -(\014rst)450 1234 y(sym)o(b)q(ol)d(of)e(the)i(curren)o(t)f(sym)o(b)q(ol.)450 -1299 y(Another)j(function)h(of)f(this)h(pro)q(cedure)g(is)g(to)e(turn)h(the)h -(canonical)450 1349 y(v)m(alue)f(form)d(of)h(bfd)h(in)o(to)f(the)g(form)g -(used)h(b)o(y)f(co\013.)23 b(In)o(ternally)l(,)18 b(bfd)450 -1399 y(exp)q(ects)e(sym)o(b)q(ol)g(v)m(alues)g(to)f(b)q(e)h(o\013sets)e(from) -h(a)g(section)h(base;)f(so)g(a)450 1449 y(sym)o(b)q(ol)c(ph)o(ysically)i(at)d -(0x120,)g(but)h(in)g(a)g(section)g(starting)f(at)g(0x100,)450 -1499 y(w)o(ould)16 b(ha)o(v)o(e)g(the)g(v)m(alue)h(0x20.)22 -b(Co\013)15 b(exp)q(ects)h(sym)o(b)q(ols)g(to)g(con)o(tain)450 -1548 y(their)d(\014nal)h(v)m(alue,)g(so)f(sym)o(b)q(ols)g(ha)o(v)o(e)g(their) -g(v)m(alues)h(c)o(hanged)f(at)g(this)450 1598 y(p)q(oin)o(t)20 -b(to)g(re\015ect)g(their)h(sum)f(with)g(their)g(o)o(wning)g(section.)35 -b(Note)450 1648 y(that)18 b(this)h(transformation)e(uses)i(the)39 -b Fh(output_section)17 b Fm(\014eld)i(of)450 1698 y(the)c Fh(asymbol)p -Fm('s)f Fh(asection)g Fm(See)i(Section)g(2.3)e([Sections],)h(page)g(8.)300 -1763 y Fh(coff_mangle_symbols)450 1813 y Fm(This)f(routine)f(runs)g(though)g -(the)g(pro)o(vided)h(sym)o(b)q(ol)f(table)h(and)f(uses)450 -1862 y(the)18 b(o\013sets)g(generated)g(b)o(y)h(the)f(previous)h(pass)f(and)h -(the)g(p)q(oin)o(ters)450 1912 y(generated)f(when)h(the)g(sym)o(b)q(ol)g -(table)g(w)o(as)e(read)i(in)g(to)f(create)g(the)450 1962 y(structured)c -(hierac)o(h)o(y)h(required)h(b)o(y)e(co\013.)19 b(It)c(c)o(hanges)f(eac)o(h)g -(p)q(oin)o(ter)450 2012 y(to)h(a)f(sym)o(b)q(ol)i(to)e(an)i(index)g(in)o(to)f -(the)g(sym)o(b)q(ol)h(table)g(of)e(the)i(sym)o(b)q(ol)450 2062 -y(b)q(eing)g(referenced.)300 2126 y Fh(coff_write_symbols)450 -2176 y Fm(This)i(routine)f(runs)g(through)g(the)g(sym)o(b)q(ol)h(table)f(and) -g(patc)o(hes)g(up)450 2226 y(the)g(sym)o(b)q(ols)g(from)e(their)j(in)o -(ternal)f(form)f(in)o(to)g(the)h(co\013)f(w)o(a)o(y)l(,)g(calls)450 -2276 y(the)f(bit)h(t)o(widdlers)g(and)f(writes)h(out)e(the)i(tab)q(el)g(to)e -(the)i(\014le.)300 2341 y(The)f(hidden)i(information)f(for)e(an)h(asym)o(b)q -(ol)h(is:)414 2391 y Fh(typedef)23 b(struct)g(coff_ptr_struct)414 -2441 y({)300 2505 y Ff(Remem)o(b)q(ers)12 b(the)f(o\013set)g(from)f(the)i -(\014rst)e(sym)o(b)q(ol)i(in)g(the)f(\014le)i(for)d(this)k(sym)o(b)q(ol.)300 -2555 y(Generated)h(b)o(y)g Fh(coff_renumber_symbols)p Ff(.)462 -2605 y Fh(unsigned)22 b(int)i(offset;)300 2670 y Ff(Should)f(the)f(tag)e -(\014eld)j(of)f(this)g(sym)o(b)q(ol)g(b)q(e)g(ren)o(um)o(b)q(ered.)40 -b(Created)21 b(b)o(y)0 2770 y Fk(c)6 b(y)g(g)g(n)g(u)g(s)36 -b(s)6 b(u)g(p)g(p)g(o)g(r)g(t)p 332 2761 1396 3 v 1421 w(Revision:)17 -b(1.5)p eop -%%Page: 52 54 -bop 0 -58 a Fk(Chapter)13 b(3:)k(BFD)c(back)f(end)p 409 -66 -670 3 v 693 w(DRAFT)p 1222 -66 V 697 w Fj(52)300 183 y Fh -(coff_pointerize_aux)p Ff(.)462 233 y Fh(char)23 b(fix_tag;)300 -296 y Ff(Should)18 b(the)e(endidx)i(\014eld)f(of)f(this)h(sym)o(b)q(ol)g(b)q -(e)g(ren)o(um)o(b)q(ered.)24 b(Created)16 b(b)o(y)300 346 y -Fh(coff_pointerize_aux)p Ff(.)462 396 y Fh(char)23 b(fix_end;)300 -459 y Ff(The)16 b(con)o(tainer)g(for)g(the)g(sym)o(b)q(ol)g(structure)f(as)h -(read)g(and)g(translated)g(from)300 508 y(the)f(\014le.)462 -558 y Fh(union)23 b({)509 608 y(union)g(internal_auxent)f(auxent;)509 -658 y(struct)h(internal_syment)f(syment;)462 708 y(})h(u;)414 -757 y(})h(combined_entry_type;)300 870 y Fm(Eac)o(h)15 b(canonical)i(asym)o -(b)q(ol)e(really)h(lo)q(oks)f(lik)o(e)i(this:)414 920 y Fh(typedef)23 -b(struct)g(coff_symbol_struct)414 970 y({)300 1033 y Ff(The)15 -b(actual)h(sym)o(b)q(ol)f(whic)o(h)h(the)g(rest)e(of)h(bfd)h(w)o(orks)e(with) -462 1083 y Fh(asymbol)22 b(symbol;)300 1146 y Ff(A)15 b(p)q(oin)o(ter)h(to)e -(the)i(hidden)h(information)e(for)g(this)g(sym)o(b)q(ol)462 -1195 y Fh(combined_entry_type)21 b(*native;)300 1258 y Ff(A)15 -b(p)q(oin)o(ter)h(to)e(the)i(linen)o(um)o(b)q(er)h(information)e(for)g(this)h -(sym)o(b)q(ol)462 1308 y Fh(struct)23 b(lineno_cache_entry)e(*lineno;)414 -1358 y(})j(coff_symbol_type;)0 1497 y Fr(3.2.2.4)30 b(W)-5 -b(riting)20 b(Relo)r(cations)300 1589 y Fm(T)l(o)i(write)h(a)g(relo)q -(cations,)i(all)e(the)g(bac)o(k)g(end)g(do)q(es)g(is)h(step)e(though)h(the) -300 1639 y(canonical)f(relo)q(cation)f(table,)h(and)f(create)g(an)53 -b Fh(internal_reloc)p Fm(.)34 b(The)300 1689 y(sym)o(b)q(ol)15 -b(index)i(to)d(use)h(is)h(remo)o(v)o(ed)e(from)g(the)h Fh(offset)f -Fm(\014eld)j(in)f(the)f(sym)o(b)q(ol)300 1739 y(table)d(supplied,)h(the)f -(address)f(comes)g(directly)h(from)e(the)i(sum)f(of)f(the)h(section)300 -1788 y(base)18 b(address)h(and)g(the)f(relo)q(cation)h(o\013set)f(and)g(the)h -(t)o(yp)q(e)f(is)h(dug)g(directly)300 1838 y(from)14 b(the)i(ho)o(wto)e -(\014eld.)300 1901 y(Then)26 b(the)85 b Fh(internal_reloc)23 -b Fm(is)j(sw)o(app)q(ed)g(in)o(to)f(the)g(shap)q(e)h(of)f(an)300 -1951 y Fh(external_reloc)13 b Fm(and)j(written)f(out)g(to)f(disk.)0 -2090 y Fr(3.2.2.5)30 b(Reading)20 b(Linen)n(um)n(b)r(ers)300 -2182 y Fm(Createing)c(the)g(linen)o(um)o(b)q(er)i(table)e(is)g(done)h(b)o(y)e -(reading)i(in)f(the)g(en)o(tire)h(co\013)300 2232 y(linen)o(um)o(b)q(er)g -(table,)f(and)f(creating)g(another)g(table)h(for)e(in)o(ternal)i(use.)300 -2295 y(A)c(co\013)f(line)i(n)o(um)o(b)q(er)f(table)h(is)f(structured)f(so)h -(that)f(eac)o(h)h(function)g(is)g(mark)o(ed)300 2345 y(as)19 -b(ha)o(ving)g(a)g(line)i(n)o(um)o(b)q(er)f(of)f(0.)31 b(Eac)o(h)19 -b(line)i(within)g(the)e(function)h(is)g(an)300 2395 y(o\013set)12 -b(from)h(the)g(\014rst)g(line)i(in)f(the)g(function.)20 b(The)13 -b(base)g(of)g(the)h(line)h(n)o(um)o(b)q(er)300 2444 y(information)f(for)g -(the)g(table)h(is)g(stored)f(in)h(the)f(sym)o(b)q(ol)h(asso)q(ciated)f(with)h -(the)300 2494 y(function.)300 2557 y(The)20 b(information)h(is)f(copied)h -(from)f(the)g(external)g(to)g(the)g(in)o(ternal)h(table,)300 -2607 y(and)14 b(eac)o(h)g(sym)o(b)q(ol)g(whic)o(h)h(marks)f(a)f(function)i -(is)f(mark)o(ed)g(b)o(y)g(p)q(oin)o(ting)h(its...)300 2670 -y(**Ho)o(w)f(do)q(es)i(this)f(w)o(ork)f(?**)0 2770 y Fk(c)6 -b(y)g(g)g(n)g(u)g(s)36 b(s)6 b(u)g(p)g(p)g(o)g(r)g(t)p 332 -2761 1396 3 v 1421 w(Revision:)17 b(1.5)p eop -%%Page: 53 55 -bop 0 -58 a Fk(Chapter)13 b(3:)k(BFD)c(back)f(end)p 409 -66 -670 3 v 693 w(DRAFT)p 1222 -66 V 697 w Fj(53)0 183 y Fr(3.2.2.6)30 -b(Reading)20 b(Relo)r(cations)300 275 y Fm(Co\013)d(relo)q(cations)h(are)g -(easily)g(transformed)f(in)o(to)h(the)g(in)o(ternal)g(bfd)g(form)f(\()300 -324 y Fh(arelent)p Fm(\).)300 387 y(Reading)f(a)f(co\013)g(relo)q(cation)h -(table)f(is)h(done)g(in)g(the)f(follo)o(wing)h(stages:)337 -449 y Fq(\017)30 b Fm(The)15 b(en)o(tire)h(co\013)f(relo)q(cation)h(table)f -(is)h(read)f(in)o(to)g(memory)l(.)337 511 y Fq(\017)30 b Fm(Eac)o(h)13 -b(relo)q(cation)h(is)g(pro)q(cessed)g(in)g(turn,)f(\014rst)g(it)h(is)g(sw)o -(app)q(ed)f(from)g(the)390 561 y(external)j(to)e(the)h(in)o(ternal)i(form.) -337 623 y Fq(\017)30 b Fm(The)g(sym)o(b)q(ol)f(referenced)i(in)f(the)f(relo)q -(cation's)h(sym)o(b)q(ol)g(index)g(is)390 673 y(turned)22 b(in)o(to)g(a)g(p)q -(oin)o(ter)h(in)o(to)f(the)g(canonical)h(sym)o(b)q(ol)f(table.)41 -b(Note)390 723 y(that)20 b(this)h(table)h(is)f(the)g(same)g(as)f(the)h(one)g -(returned)g(b)o(y)g(a)g(call)h(to)390 773 y Fh(bfd_canonicalize_symtab)p -Fm(.)c(The)e(bac)o(k)f(end)i(will)g(call)g(the)e(routine)390 -823 y(and)g(sa)o(v)o(e)g(the)g(result)h(if)f(a)g(canonicalization)j(hasn't)c -(b)q(een)j(done.)337 885 y Fq(\017)30 b Fm(The)14 b(relo)q(c)g(index)h(is)f -(turned)g(in)o(to)g(a)f(p)q(oin)o(ter)h(to)f(a)g(ho)o(wto)g(structure,)g(in) -390 935 y(a)i(bac)o(k)h(end)g(sp)q(eci\014c)h(w)o(a)o(y)l(.)j(F)l(or)15 -b(instance,)h(the)g(386)e(and)i(960)f(use)g(the)390 984 y Fh(r_type)g -Fm(to)h(directly)h(pro)q(duce)g(an)f(index)i(in)o(to)e(a)f(ho)o(wto)g(table)i -(v)o(ector;)390 1034 y(the)g(88k)f(subtracts)h(a)f(n)o(um)o(b)q(er)i(from)e -(the)28 b Fh(r_type)16 b Fm(\014eld)i(and)f(creates)390 1084 -y(an)e(addend)h(\014eld.)0 2770 y Fk(c)6 b(y)g(g)g(n)g(u)g(s)36 -b(s)6 b(u)g(p)g(p)g(o)g(r)g(t)p 332 2761 1396 3 v 1421 w(Revision:)17 -b(1.5)p eop -%%Page: 54 56 -bop 0 -58 a Fk(F)o(unction)13 b(Index)p 238 -66 756 3 v 779 -w(DRAFT)p 1137 -66 V 782 w Fj(54)0 183 y Fi(F)-7 b(unction)26 -b(Index)0 403 y Fn(A)0 457 y Fe(aout)p 82 457 12 2 v 13 w()p -215 457 V 11 w(machine)p 366 457 V 12 w(type)t Fd(:)6 b(:)g(:)g(:)g(:)g(:)g -(:)g(:)h(:)f(:)g(:)g(:)g(:)g Fc(47)0 503 y Fe(aout)p 82 503 -V 13 w()p 215 503 V 11 w(mkobject)f Fd(:)h(:)h(:)f(:)g(:)g(:)g(:)g(:)g -(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)j Fc(47)0 549 y Fe(aout)p -82 549 V 13 w()p 215 549 V 11 w(set)p 286 549 V 13 w(arch)p -379 549 V 13 w(mach)d Fd(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)i -Fc(48)0 594 y Fe(aout)p 82 594 V 13 w()p 215 594 V 11 -w(some)p 306 594 V 13 w(aout)p 399 594 V 13 w(object)p 532 -594 V 11 w(p)t Fd(:)e(:)g(:)g(:)g(:)g(:)g(:)t Fc(47)0 640 y -Fe(aout)p 82 640 V 13 w()p 215 640 V 11 w(swap)p 306 -640 V 13 w(exec)p 399 640 V 13 w(header)p 532 640 V 11 w(in)k -Fd(:)c(:)h(:)f(:)g(:)11 b Fc(47)0 686 y Fe(aout)p 82 686 V -13 w()p 215 686 V 11 w(swap)p 306 686 V 13 w(exec)p 399 -686 V 13 w(header)p 532 686 V 11 w(out)e Fd(:)d(:)g(:)g(:)k -Fc(47)0 731 y Fe(aout)p 82 731 V 13 w(ne)o(w)p 274 731 -V 11 w(section)p 425 731 V 12 w(hook)f Fd(:)d(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:) -11 b Fc(48)0 857 y Fn(B)0 911 y Fe(bfd)p 62 911 V 13 w(alloc)p -175 911 V 12 w(size)6 b Fd(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)h(:)f(:) -g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)i Fc(40)0 956 y -Fe(bfd)p 62 956 V 13 w(arch)p 155 956 V 13 w(compatib)o(le)e -Fd(:)g(:)g(:)g(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)k -Fc(38)0 1002 y Fe(bfd)p 62 1002 V 13 w(architect)o(ure)d Fd(:)f(:)g(:)g(:)g -(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)11 -b Fc(36)0 1048 y Fe(bfd)p 62 1048 V 13 w(cache)p 175 1048 V -12 w(close)t Fd(:)6 b(:)g(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g -(:)g(:)g(:)g(:)g(:)g(:)h(:)f(:)g Fc(44)0 1093 y Fe(bfd)p 62 -1093 V 13 w(cache)p 175 1093 V 12 w(init)g Fd(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g -(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)i -Fc(44)0 1139 y Fe(bfd)p 62 1139 V 13 w(cache)p 175 1139 V 12 -w(lookup)r Fd(:)f(:)f(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)h -(:)f(:)g(:)g(:)g(:)g(:)f Fc(43)0 1185 y Fe(bfd)p 62 1185 V -13 w(cache)p 175 1185 V 12 w(lookup)p 307 1185 V 12 w(worker)g -Fd(:)h(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)h(:)g -Fc(44)0 1230 y Fe(BFD)p 62 1230 V 13 w(CACHE)p 175 1230 V 12 -w(MAX)p 247 1230 V 13 w(OPEN)s Fd(:)f(:)h(:)f(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g -(:)g(:)g(:)g(:)g(:)g(:)h(:)f(:)g(:)f Fc(43)0 1276 y Fe(bfd)p -62 1276 V 13 w(canonical)o(ize)p 313 1276 V 10 w(symtab)r Fd(:)h(:)h(:)f(:)g -(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)f Fc(18)0 1322 y Fe(bfd)p -62 1322 V 13 w(check)p 175 1322 V 12 w(format)r Fd(:)i(:)f(:)g(:)g(:)g(:)g(:) -g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)g(:)f -Fc(21)0 1367 y Fe(bfd)p 62 1367 V 13 w(close)k Fd(:)d(:)g(:)g(:)g(:)g(:)g(:)g -(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)h(:)f -(:)g(:)g(:)11 b Fc(39)0 1413 y Fe(bfd)p 62 1413 V 13 w(core)p -155 1413 V 13 w(file)p 248 1413 V 12 w(failing)p 400 1413 V -12 w(command)c Fd(:)g(:)f(:)g(:)g(:)g(:)g(:)11 b Fc(30)0 1459 -y Fe(bfd)p 62 1459 V 13 w(core)p 155 1459 V 13 w(file)p 248 -1459 V 12 w(failing)p 400 1459 V 12 w(signal)q Fd(:)6 b(:)g(:)g(:)g(:)g(:)g -(:)g(:)g(:)t Fc(30)0 1504 y Fe(bfd)p 62 1504 V 13 w(create)h -Fd(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:) -g(:)h(:)f(:)g(:)g(:)g(:)g(:)g(:)g(:)k Fc(39)0 1550 y Fe(bfd)p -62 1550 V 13 w(fdopenr)c Fd(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g -(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)j -Fc(39)0 1596 y Fe(bfd)p 62 1596 V 13 w(find)p 155 1596 V 13 -w(target)s Fd(:)d(:)g(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g -(:)g(:)g(:)g(:)g(:)h(:)f(:)g Fc(35)0 1641 y Fe(bfd)p 62 1641 -V 13 w(format)p 195 1641 V 12 w(string)q Fd(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g -(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)t Fc(21)0 -1687 y Fe(bfd)p 62 1687 V 13 w(get)p 135 1687 V 13 w(elt)p -208 1687 V 13 w(at)p 261 1687 V 13 w(index)s Fd(:)g(:)g(:)h(:)f(:)g(:)g(:)g -(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g Fc(20)0 1733 y -Fe(bfd)p 62 1733 V 13 w(get)p 135 1733 V 13 w(mtime)i Fd(:)e(:)g(:)g(:)g(:)g -(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g -(:)g(:)k Fc(6)0 1778 y Fe(bfd)p 62 1778 V 13 w(get)p 135 1778 -V 13 w(next)p 228 1778 V 13 w(mapent)q Fd(:)c(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g -(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)g(:)g(:)t Fc(20)0 1824 y Fe(bfd)p -62 1824 V 13 w(get)p 135 1824 V 13 w(section)p 288 1824 V 11 -w(by)p 339 1824 V 14 w(name)i Fd(:)e(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)h(:)f(:)g -(:)g(:)g(:)k Fc(12)0 1870 y Fe(bfd)p 62 1870 V 13 w(get)p 135 -1870 V 13 w(section)p 288 1870 V 11 w(contents)s Fd(:)c(:)g(:)g(:)g(:)g(:)g -(:)g(:)h(:)f(:)g(:)g(:)g(:)g Fc(13)0 1915 y Fe(bfd)p 62 1915 -V 13 w(get)p 135 1915 V 13 w(size)i Fd(:)e(:)g(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:) -g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)k -Fc(41)0 1961 y Fe(bfd)p 62 1961 V 13 w(h)p 95 1961 V 14 w(get)p -169 1961 V 13 w(size)e Fd(:)e(:)g(:)g(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)g(:)g -(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)h(:)f(:)k Fc(41)0 2007 y -Fe(bfd)p 62 2007 V 13 w(h)p 95 2007 V 14 w(put)p 169 2007 V -13 w(size)e Fd(:)e(:)g(:)g(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:) -g(:)g(:)g(:)g(:)g(:)g(:)h(:)f(:)k Fc(41)0 2052 y Fe(bfd)p 62 -2052 V 13 w(last)p 155 2052 V 13 w(cache)5 b Fd(:)h(:)g(:)g(:)g(:)g(:)g(:)g -(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)i -Fc(43)0 2098 y Fe(bfd)p 62 2098 V 13 w(log2)r Fd(:)e(:)g(:)g(:)g(:)g(:)g(:)g -(:)h(:)f(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)h(:)f(:)g(:)g -(:)g(:)g(:)g(:)g(:)t Fc(42)0 2144 y Fe(bfd)p 62 2144 V 13 w(make)p -155 2144 V 13 w(empty)p 268 2144 V 12 w(symbol)h Fd(:)f(:)g(:)g(:)g(:)g(:)g -(:)g(:)h(:)f(:)g(:)g(:)g(:)g(:)g(:)g(:)k Fc(19)1230 403 y Fe(bfd)p -1292 403 V 13 w(make)p 1385 403 V 13 w(section)q Fd(:)d(:)f(:)g(:)g(:)g(:)g -(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)g(:)f -Fc(12)1230 449 y Fe(bfd)p 1292 449 V 13 w(map)p 1365 449 V -13 w(over)p 1458 449 V 13 w(sections)h Fd(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)h(:)f -(:)g(:)g(:)g(:)g(:)g(:)g(:)k Fc(12)1230 495 y Fe(bfd)p 1292 -495 V 13 w(open)p 1385 495 V 13 w(file)c Fd(:)h(:)f(:)g(:)g(:)g(:)g(:)g(:)g -(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)j -Fc(44)1230 540 y Fe(bfd)p 1292 540 V 13 w(openr)g Fd(:)d(:)g(:)g(:)g(:)g(:)g -(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)h -(:)f(:)g(:)g(:)11 b Fc(39)1230 586 y Fe(bfd)p 1292 586 V 13 -w(openr)p 1405 586 V 12 w(next)p 1497 586 V 13 w(archived)p -1670 586 V 11 w(file)r Fd(:)6 b(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)t -Fc(20)1230 632 y Fe(bfd)p 1292 632 V 13 w(openw)j Fd(:)d(:)g(:)g(:)g(:)g(:)g -(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)h -(:)f(:)g(:)g(:)11 b Fc(39)1230 677 y Fe(bfd)p 1292 677 V 13 -w(perform)p 1445 677 V 11 w(relocation)r Fd(:)6 b(:)g(:)g(:)g(:)g(:)g(:)h(:)f -(:)g(:)g(:)g(:)g(:)g(:)g(:)g Fc(23)1230 723 y Fe(bfd)p 1292 -723 V 13 w(prinable)p 1465 723 V 11 w(arch)p 1556 723 V 13 -w(mach)g Fd(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)j -Fc(37)1230 769 y Fe(bfd)p 1292 769 V 13 w(print)p 1405 769 -V 12 w(symbol)p 1537 769 V 12 w(vandf)d Fd(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)g(:) -g(:)g(:)g(:)g(:)g(:)g(:)j Fc(19)1230 814 y Fe(bfd)p 1292 814 -V 13 w(put)p 1365 814 V 13 w(size)f Fd(:)e(:)g(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:) -g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)k -Fc(41)1230 860 y Fe(bfd)p 1292 860 V 13 w(scan)p 1385 860 V -13 w(arch)p 1478 860 V 12 w(mach)s Fd(:)c(:)h(:)f(:)g(:)g(:)g(:)g(:)g(:)g(:)g -(:)g(:)g(:)g(:)g(:)g(:)g(:)h(:)f(:)g(:)f Fc(38)1230 906 y Fe(bfd)p -1292 906 V 13 w(set)p 1365 906 V 13 w(arch)p 1458 906 V 13 -w(mach)t Fd(:)h(:)g(:)g(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g -(:)g(:)g(:)g(:)g(:)h Fc(38)1230 951 y Fe(bfd)p 1292 951 V 13 -w(set)p 1365 951 V 13 w(archive)p 1518 951 V 11 w(head)j Fd(:)c(:)g(:)g(:)g -(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)h(:)f(:)g(:)11 b Fc(20)1230 -997 y Fe(bfd)p 1292 997 V 13 w(set)p 1365 997 V 13 w(format)5 -b Fd(:)h(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)g(:)g(:)g -(:)g(:)g(:)g(:)g(:)g(:)i Fc(21)1230 1043 y Fe(bfd)p 1292 1043 -V 13 w(set)p 1365 1043 V 13 w(section)p 1518 1043 V 11 w(contents)s -Fd(:)e(:)g(:)g(:)g(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)g Fc(13)1230 -1088 y Fe(bfd)p 1292 1088 V 13 w(set)p 1365 1088 V 13 w(section)p -1518 1088 V 11 w(flags)i Fd(:)e(:)g(:)g(:)g(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g -(:)g(:)g(:)g(:)k Fc(12)1230 1134 y Fe(bfd)p 1292 1134 V 13 -w(set)p 1365 1134 V 13 w(section)p 1518 1134 V 11 w(size)g -Fd(:)c(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)h(:)f(:)g(:)11 -b Fc(13)1230 1180 y Fe(bfd)p 1292 1180 V 13 w(set)p 1365 1180 -V 13 w(start)p 1478 1180 V 12 w(address)d Fd(:)e(:)g(:)g(:)g(:)g(:)g(:)h(:)f -(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)11 b Fc(6)1230 1225 y Fe(bfd)p -1292 1225 V 13 w(set)p 1365 1225 V 13 w(symtab)5 b Fd(:)h(:)g(:)g(:)g(:)g(:)g -(:)g(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)i -Fc(18)1230 1271 y Fe(bfd)p 1292 1271 V 13 w(target)f Fd(:)f(:)g(:)g(:)g(:)h -(:)f(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g -(:)g(:)g(:)g(:)k Fc(31)1230 1316 y Fe(bfd)p 1292 1316 V 13 -w(target)p 1425 1316 V 12 w(list)t Fd(:)c(:)g(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g -(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)h(:)f(:)g Fc(35)1230 -1420 y Fn(C)1230 1474 y Fe(core)p 1312 1474 V 13 w(file)p 1405 -1474 V 12 w(matches)p 1557 1474 V 12 w(executab)o(le)p 1768 -1474 V 11 w(p)j Fd(:)d(:)g(:)g(:)g(:)g(:)k Fc(30)1230 1578 -y Fn(G)1230 1632 y Fe(get)p 1292 1632 V 13 w(symtab)p 1425 -1632 V 12 w(upper)p 1537 1632 V 12 w(bound)c Fd(:)g(:)g(:)h(:)f(:)g(:)g(:)g -(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)j Fc(18)1230 1736 y Fn(H)1230 -1790 y Fe(HOWTO)s Fd(:)d(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)h(:)f(:)g -(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)g -(:)f Fc(28)1230 1886 y Fn(R)1230 1940 y Fe(reloc)p 1332 1940 -V 12 w(chain)i Fd(:)f(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)h -(:)f(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)j Fc(28)1230 -1986 y Fe(reloc)p 1332 1986 V 12 w(howto)p 1444 1986 V 12 w(type)s -Fd(:)e(:)f(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)h(:)f(:)g(:) -g(:)g(:)g(:)f Fc(26)1230 2090 y Fn(S)1230 2144 y Fe(stuff)t -Fd(:)h(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)g(:)g(:)g(:) -g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)g(:)g(:)g(:)g -Fc(7)0 2770 y Fk(c)g(y)g(g)g(n)g(u)g(s)36 b(s)6 b(u)g(p)g(p)g(o)g(r)g(t)p -332 2761 1396 3 v 1421 w(Revision:)17 b(1.5)p eop -%%Page: 55 57 -bop 0 -58 a Fk(Index)p 94 -66 828 3 v 851 w(DRAFT)p 1065 -66 -V 854 w Fj(55)0 183 y Fi(Index)0 403 y Fn(B)0 457 y Fc(BFD)6 -b Fd(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g -(:)g(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g -Fc(1)0 503 y(BFD)13 b(canonical)j(format)t Fd(:)6 b(:)g(:)g(:)g(:)g(:)g(:)g -(:)g(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)g(:)g(:)t Fc(3)1230 -403 y Fn(I)1230 457 y Fc(in)o(ternal)15 b(ob)r(ject-\014le)f(format)c -Fd(:)c(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)k -Fc(3)1230 562 y Fn(W)1230 616 y Fc(what)j(is)h(it?)9 b Fd(:)d(:)g(:)g(:)g(:)g -(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g(:)g -(:)g(:)g(:)g(:)g(:)g(:)j Fc(1)0 2770 y Fk(c)d(y)g(g)g(n)g(u)g(s)36 -b(s)6 b(u)g(p)g(p)g(o)g(r)g(t)p 332 2761 1396 3 v 1421 w(Revision:)17 -b(1.5)p eop -%%Page: 56 58 -bop 0 -58 a Fk(Index)p 94 -66 828 3 v 851 w(DRAFT)p 1065 -66 -V 854 w Fj(56)643 943 y Fm(The)16 b(b)q(o)q(dy)g(of)e(this)i(man)o(ual)f(is)h -(set)f(in)799 993 y(cmr10)g(at)f(10.95pt,)631 1042 y(with)i(headings)g(in)g -Fj(cm)o(b10)e(at)h(10.95pt)597 1092 y Fm(and)h(examples)g(in)g -Fh(cmtt10)23 b(at)g(10.95pt)p Fm(.)754 1142 y Fl(cmti10)17 -b(at)f(10.95pt)21 b Fm(and)799 1192 y Ff(cmsl10)15 b(at)g(10.95pt)754 -1242 y Fm(are)g(used)h(for)e(emphasis.)0 2770 y Fk(c)6 b(y)g(g)g(n)g(u)g(s)36 -b(s)6 b(u)g(p)g(p)g(o)g(r)g(t)p 332 2761 1396 3 v 1421 w(Revision:)17 -b(1.5)p eop -%%Page: -1 59 -bop 12 -66 885 3 v 909 -58 a Fk(DRAFT)p 1040 -66 V 911 w Fj(i)0 -183 y Fi(T)-7 b(able)27 b(of)f(Con)n(ten)n(ts)0 333 y Fn(1)67 -b(In)n(tro)r(duction)14 b Fb(:)e(:)e(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)h -(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)h(:)f -(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)h(:)f(:)g(:)g(:)k Fn(1)149 395 -y Fm(1.1)45 b(History)11 b Fa(:)d(:)f(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g -(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f -(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h -(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)k Fm(1)149 445 y(1.2)45 -b(Ho)o(w)15 b(It)g(W)l(orks)7 b Fa(:)f(:)h(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:) -g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f -(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h -(:)f(:)g(:)g(:)g(:)f Fm(1)149 495 y(1.3)45 b(What)15 b(BFD)f(V)l(ersion)i(1)f -(Can't)f(Do)6 b Fa(:)h(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:) -f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h -(:)f(:)g(:)e Fm(2)299 544 y(1.3.1)44 b(Information)15 b(Loss)6 -b Fa(:)h(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g -(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)h(:)f(:)g(:)g(:)g -(:)h(:)f(:)g(:)g(:)e Fm(2)299 594 y(1.3.2)44 b(Mec)o(hanism)13 -b Fa(:)7 b(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:) -h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g -(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)12 b Fm(3)0 694 y Fn(2)67 -b(BFD)22 b(fron)n(t)h(end)8 b Fb(:)i(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g -(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g -(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)e Fn(5)149 756 y -Fm(2.1)45 b(t)o(yp)q(edef)16 b(bfd)c Fa(:)c(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g -(:)g(:)h(:)f(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g -(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g -(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)j Fm(5)448 806 y(2.1.0.1)44 -b(bfd)p 690 806 14 2 v 16 w(set)p 762 806 V 16 w(start)p 873 -806 V 16 w(address)8 b Fa(:)f(:)g(:)h(:)f(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f -(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g -Fm(6)448 856 y(2.1.0.2)44 b(bfd)p 690 856 V 16 w(get)p 767 -856 V 16 w(m)o(time)11 b Fa(:)d(:)f(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g -(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g -(:)g(:)g(:)h(:)i Fm(6)448 906 y(2.1.0.3)44 b(stu\013)8 b Fa(:)e(:)h(:)h(:)f -(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)h(:)f -(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h -(:)f(:)g(:)g Fm(7)149 955 y(2.2)45 b(Memory)14 b(Usage)7 b -Fa(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:) -g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g -(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)f -Fm(8)149 1005 y(2.3)45 b(Sections)t Fa(:)8 b(:)f(:)h(:)f(:)g(:)g(:)g(:)h(:)f -(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h -(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g -(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)h(:)f(:)g(:)s Fm(8)299 -1055 y(2.3.1)44 b(Section)16 b(Input)10 b Fa(:)e(:)f(:)g(:)g(:)g(:)h(:)f(:)g -(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f -(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)i -Fm(8)299 1105 y(2.3.2)44 b(Section)16 b(Output)c Fa(:)7 b(:)g(:)h(:)f(:)g(:)g -(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g -(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)k -Fm(9)299 1155 y(2.3.3)44 b(t)o(yp)q(edef)15 b(asection)g Fa(:)7 -b(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f -(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h -(:)f(:)g(:)13 b Fm(9)299 1204 y(2.3.4)44 b(section)16 b(protot)o(yp)q(es)11 -b Fa(:)c(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g -(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g -(:)g(:)12 b Fm(12)448 1254 y(2.3.4.1)44 b(bfd)p 690 1254 V -16 w(get)p 767 1254 V 16 w(section)p 919 1254 V 17 w(b)o(y)p -984 1254 V 17 w(name)12 b Fa(:)7 b(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)h(:)f(:)g(:) -g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)12 b Fm(12)448 -1304 y(2.3.4.2)44 b(bfd)p 690 1304 V 16 w(mak)o(e)p 810 1304 -V 16 w(section)14 b Fa(:)7 b(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h -(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)13 -b Fm(12)448 1354 y(2.3.4.3)44 b(bfd)p 690 1354 V 16 w(set)p -762 1354 V 16 w(section)p 914 1354 V 17 w(\015ags)5 b Fa(:)i(:)g(:)h(:)f(:)g -(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f -(:)g(:)g(:)g(:)h(:)t Fm(12)448 1404 y(2.3.4.4)44 b(bfd)p 690 -1404 V 16 w(map)p 792 1404 V 17 w(o)o(v)o(er)p 892 1404 V 15 -w(sections)t Fa(:)8 b(:)f(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f -(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)t Fm(12)448 -1453 y(2.3.4.5)44 b(bfd)p 690 1453 V 16 w(set)p 762 1453 V -16 w(section)p 914 1453 V 17 w(size)15 b Fa(:)7 b(:)g(:)h(:)f(:)g(:)g(:)g(:)h -(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h -(:)f(:)13 b Fm(13)448 1503 y(2.3.4.6)44 b(bfd)p 690 1503 V -16 w(set)p 762 1503 V 16 w(section)p 914 1503 V 17 w(con)o(ten)o(ts)7 -b Fa(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f -(:)g(:)g(:)g(:)h(:)f(:)g(:)g Fm(13)448 1553 y(2.3.4.7)44 b(bfd)p -690 1553 V 16 w(get)p 767 1553 V 16 w(section)p 919 1553 V -17 w(con)o(ten)o(ts)5 b Fa(:)i(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:) -g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)e Fm(13)149 -1603 y(2.4)45 b(Sym)o(b)q(ols)11 b Fa(:)d(:)f(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f -(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h -(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g -(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)k Fm(14)299 1653 y(2.4.1)44 -b(Reading)16 b(Sym)o(b)q(ols)d Fa(:)7 b(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h -(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)h -(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)j Fm(14)299 1703 -y(2.4.2)44 b(W)l(riting)16 b(Sym)o(b)q(ols)7 b Fa(:)g(:)h(:)f(:)g(:)g(:)g(:)h -(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g -(:)h(:)f(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)g -Fm(15)299 1752 y(2.4.3)44 b(t)o(yp)q(edef)15 b(asym)o(b)q(ol)c -Fa(:)d(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:) -g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g -(:)g(:)g(:)k Fm(16)299 1802 y(2.4.4)44 b(Sym)o(b)q(ol)16 b(Handling)g(F)l -(unctions)9 b Fa(:)f(:)f(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f -(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)g -Fm(18)448 1852 y(2.4.4.1)44 b(get)p 687 1852 V 16 w(sym)o(tab)p -848 1852 V 15 w(upp)q(er)p 977 1852 V 17 w(b)q(ound)6 b Fa(:)i(:)f(:)h(:)f(:) -g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)e -Fm(18)448 1902 y(2.4.4.2)44 b(bfd)p 690 1902 V 16 w(canonicalize)p -941 1902 V 19 w(sym)o(tab)12 b Fa(:)c(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h -(:)f(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)13 b Fm(18)448 -1952 y(2.4.4.3)44 b(bfd)p 690 1952 V 16 w(set)p 762 1952 V -16 w(sym)o(tab)13 b Fa(:)7 b(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g -(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g -(:)13 b Fm(18)448 2001 y(2.4.4.4)44 b(bfd)p 690 2001 V 16 w(prin)o(t)p -803 2001 V 17 w(sym)o(b)q(ol)p 960 2001 V 17 w(v)m(andf)13 -b Fa(:)7 b(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:) -h(:)f(:)g(:)g(:)g(:)h(:)f(:)12 b Fm(19)448 2051 y(2.4.4.5)44 -b(bfd)p 690 2051 V 16 w(mak)o(e)p 810 2051 V 16 w(empt)o(y)p -950 2051 V 16 w(sym)o(b)q(ol)13 b Fa(:)7 b(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:) -f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)12 -b Fm(19)149 2101 y(2.5)45 b(Arc)o(hiv)o(es)9 b Fa(:)f(:)f(:)g(:)h(:)f(:)g(:)g -(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g -(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f -(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)i Fm(20)448 -2151 y(2.5.0.1)44 b(bfd)p 690 2151 V 16 w(get)p 767 2151 V -16 w(next)p 870 2151 V 17 w(map)q(en)o(t)7 b Fa(:)g(:)g(:)g(:)h(:)f(:)g(:)g -(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g -(:)g(:)g Fm(20)448 2201 y(2.5.0.2)44 b(bfd)p 690 2201 V 16 -w(set)p 762 2201 V 16 w(arc)o(hiv)o(e)p 918 2201 V 17 w(head)11 -b Fa(:)c(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f -(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)i Fm(20)448 2250 y(2.5.0.3)44 -b(bfd)p 690 2250 V 16 w(get)p 767 2250 V 16 w(elt)p 833 2250 -V 17 w(at)p 891 2250 V 16 w(index)8 b Fa(:)g(:)f(:)h(:)f(:)g(:)g(:)g(:)h(:)f -(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h -(:)f Fm(20)448 2300 y(2.5.0.4)44 b(bfd)p 690 2300 V 16 w(op)q(enr)p -818 2300 V 17 w(next)p 922 2300 V 17 w(arc)o(hiv)o(ed)p 1104 -2300 V 17 w(\014le)6 b Fa(:)i(:)f(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h -(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)f Fm(20)149 2350 y(2.6)45 b(File)16 -b(F)l(ormats)8 b Fa(:)e(:)h(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h -(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g -(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g -(:)g(:)h Fm(21)448 2400 y(2.6.0.1)44 b(bfd)p 690 2400 V 16 -w(c)o(hec)o(k)p 813 2400 V 17 w(format)12 b Fa(:)7 b(:)g(:)h(:)f(:)g(:)g(:)g -(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g -(:)g(:)h(:)f(:)g(:)13 b Fm(21)448 2450 y(2.6.0.2)44 b(bfd)p -690 2450 V 16 w(set)p 762 2450 V 16 w(format)9 b Fa(:)d(:)h(:)h(:)f(:)g(:)g -(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g -(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)g Fm(21)448 2500 y(2.6.0.3)44 -b(bfd)p 690 2500 V 16 w(format)p 840 2500 V 15 w(string)10 -b Fa(:)e(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g -(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)j Fm(21)149 -2549 y(2.7)45 b(Relo)q(cations)10 b Fa(:)e(:)f(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:) -g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f -(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h -(:)f(:)g(:)g(:)g(:)h(:)f(:)i Fm(23)448 2599 y(2.7.0.1)44 b(bfd)p -690 2599 V 16 w(p)q(erform)p 863 2599 V 17 w(relo)q(cation)7 -b Fa(:)h(:)f(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g -(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g Fm(23)448 2649 y(2.7.0.2)44 -b(relo)q(c)p 720 2649 V 17 w(ho)o(wto)p 858 2649 V 15 w(t)o(yp)q(e)t -Fa(:)8 b(:)f(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g -(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)t Fm(26)0 -2770 y Fk(c)f(y)g(g)g(n)g(u)g(s)36 b(s)6 b(u)g(p)g(p)g(o)g(r)g(t)p -332 2761 1396 3 v 1421 w(Revision:)17 b(1.5)p eop -%%Page: -2 60 -bop 12 -66 879 3 v 903 -58 a Fk(DRAFT)p 1034 -66 V 905 w Fj(ii)448 -42 y Fm(2.7.0.3)44 b(HO)o(WTO)10 b Fa(:)c(:)i(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g -(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g -(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)i Fm(28)448 91 y(2.7.0.4)44 -b(relo)q(c)p 720 91 14 2 v 17 w(c)o(hain)14 b Fa(:)7 b(:)g(:)g(:)h(:)f(:)g(:) -g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g -(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)13 b Fm(28)149 141 -y(2.8)45 b(Core)15 b(\014les)d Fa(:)c(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h -(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g -(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g -(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)j Fm(30)448 191 y(2.8.0.1)44 -b(bfd)p 690 191 V 16 w(core)p 787 191 V 17 w(\014le)p 861 191 -V 17 w(failing)p 999 191 V 18 w(command)11 b Fa(:)c(:)h(:)f(:)g(:)g(:)g(:)h -(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)k Fm(30)448 -241 y(2.8.0.2)44 b(bfd)p 690 241 V 16 w(core)p 787 241 V 17 -w(\014le)p 861 241 V 17 w(failing)p 999 241 V 18 w(signal)10 -b Fa(:)e(:)f(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g -(:)h(:)f(:)g(:)g(:)j Fm(30)448 291 y(2.8.0.3)44 b(core)p 707 -291 V 16 w(\014le)p 780 291 V 17 w(matc)o(hes)p 958 291 V 16 -w(executable)p 1181 291 V 18 w(p)14 b Fa(:)7 b(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:) -f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)14 b Fm(30)149 340 y(2.9)45 -b(T)l(argets)10 b Fa(:)c(:)h(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h -(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h -(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g -(:)h(:)f(:)g(:)g(:)g(:)h(:)h Fm(31)448 390 y(2.9.0.1)44 b(bfd)p -690 390 V 16 w(target)11 b Fa(:)c(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g -(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f -(:)g(:)g(:)g(:)h(:)f(:)g(:)k Fm(31)299 440 y(2.9.1)44 b(bfd)p -505 440 V 17 w(target)11 b Fa(:)c(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h -(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g -(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)13 -b Fm(31)448 490 y(2.9.1.1)44 b(bfd)p 690 490 V 16 w(\014nd)p -781 490 V 17 w(target)6 b Fa(:)g(:)h(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g -(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g -(:)g(:)h(:)d Fm(35)448 540 y(2.9.1.2)44 b(bfd)p 690 540 V 16 -w(target)p 826 540 V 15 w(list)15 b Fa(:)7 b(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g -(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g -(:)g(:)h(:)f(:)g(:)g(:)13 b Fm(35)149 589 y(2.10)45 b(Arc)o(hitectures)10 -b Fa(:)e(:)f(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g -(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g -(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)j -Fm(36)448 639 y(2.10.0.1)43 b(bfd)p 712 639 V 17 w(arc)o(hitecture)12 -b Fa(:)c(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g -(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)12 b Fm(36)448 -689 y(2.10.0.2)43 b(bfd)p 712 689 V 17 w(prinable)p 889 689 -V 18 w(arc)o(h)p 992 689 V 16 w(mac)o(h)9 b Fa(:)e(:)g(:)g(:)h(:)f(:)g(:)g(:) -g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)g -Fm(37)448 739 y(2.10.0.3)43 b(bfd)p 712 739 V 17 w(scan)p 815 -739 V 17 w(arc)o(h)p 917 739 V 16 w(mac)o(h)6 b Fa(:)h(:)g(:)g(:)g(:)h(:)f(:) -g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f -(:)g(:)f Fm(38)448 789 y(2.10.0.4)43 b(bfd)p 712 789 V 17 w(arc)o(h)p -814 789 V 16 w(compatible)11 b Fa(:)e(:)e(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g -(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)k -Fm(38)448 839 y(2.10.0.5)43 b(bfd)p 712 839 V 17 w(set)p 785 -839 V 16 w(arc)o(h)p 886 839 V 16 w(mac)o(h)11 b Fa(:)d(:)f(:)g(:)g(:)g(:)h -(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g -(:)h(:)f(:)g(:)k Fm(38)149 888 y(2.11)45 b(Op)q(ening)17 b(and)e(Closing)h -(BFDs)11 b Fa(:)6 b(:)i(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g -(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g -(:)g(:)g(:)h(:)i Fm(39)448 938 y(2.11.0.1)43 b(bfd)p 712 938 -V 17 w(op)q(enr)14 b Fa(:)7 b(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g -(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g -(:)g(:)h(:)f(:)g(:)13 b Fm(39)448 988 y(2.11.0.2)43 b(bfd)p -712 988 V 17 w(fdop)q(enr)15 b Fa(:)7 b(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h -(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g -(:)h(:)f(:)g(:)g(:)g(:)14 b Fm(39)448 1038 y(2.11.0.3)43 b(bfd)p -712 1038 V 17 w(op)q(en)o(w)6 b Fa(:)i(:)f(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:) -g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f -(:)g(:)g(:)g(:)h(:)f(:)g(:)f Fm(39)448 1088 y(2.11.0.4)43 b(bfd)p -712 1088 V 17 w(close)13 b Fa(:)8 b(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h -(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g -(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)12 b Fm(39)448 1137 y(2.11.0.5)43 -b(bfd)p 712 1137 V 17 w(create)10 b Fa(:)d(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:) -g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f -(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)j Fm(39)448 1187 y(2.11.0.6)43 -b(bfd)p 712 1187 V 17 w(allo)q(c)p 820 1187 V 18 w(size)10 -b Fa(:)e(:)f(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g -(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)j -Fm(40)448 1237 y(2.11.1.7)43 b(bfd)p 712 1237 V 17 w(put)p -797 1237 V 17 w(size)13 b Fa(:)7 b(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:) -g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f -(:)g(:)g(:)g(:)12 b Fm(41)448 1287 y(2.11.1.8)43 b(bfd)p 712 -1287 V 17 w(get)p 790 1287 V 16 w(size)6 b Fa(:)i(:)f(:)g(:)g(:)h(:)f(:)g(:)g -(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g -(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)d Fm(41)448 1337 y(2.11.1.9)43 -b(bfd)p 712 1337 V 17 w(h)p 754 1337 V 17 w(put)p 839 1337 -V 16 w(size)11 b Fa(:)e(:)e(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g -(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)k -Fm(41)448 1386 y(2.11.1.10)43 b(bfd)p 735 1386 V 17 w(h)p 777 -1386 V 16 w(get)p 854 1386 V 16 w(size)15 b Fa(:)7 b(:)h(:)f(:)g(:)g(:)g(:)h -(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g -(:)h(:)f(:)g(:)g(:)g(:)14 b Fm(41)448 1436 y(2.11.1.11)43 b(bfd)p -735 1436 V 17 w(log2)8 b Fa(:)e(:)i(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h -(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g -(:)h(:)f(:)g(:)g(:)g(:)h(:)f Fm(42)149 1486 y(2.12)45 b(File)16 -b(Cac)o(hing)8 b Fa(:)f(:)g(:)h(:)f(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g -(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f -(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h -(:)f Fm(43)448 1536 y(2.12.0.1)43 b(BFD)p 745 1536 V 16 w(CA)o(CHE)p -925 1536 V 16 w(MAX)p 1051 1536 V 16 w(OPEN)6 b Fa(:)i(:)f(:)h(:)f(:)g(:)g(:) -g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)h(:)f(:)g(:)f Fm(43)448 -1586 y(2.12.0.2)43 b(bfd)p 712 1586 V 17 w(last)p 800 1586 -V 16 w(cac)o(he)13 b Fa(:)7 b(:)h(:)f(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g -(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f -(:)12 b Fm(43)448 1636 y(2.12.0.3)43 b(bfd)p 712 1636 V 17 -w(cac)o(he)p 836 1636 V 17 w(lo)q(okup)11 b Fa(:)d(:)f(:)h(:)f(:)g(:)g(:)g(:) -h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g -(:)h(:)f(:)k Fm(43)448 1685 y(2.12.0.4)43 b(bfd)p 712 1685 -V 17 w(cac)o(he)p 836 1685 V 17 w(init)15 b Fa(:)7 b(:)g(:)h(:)f(:)g(:)g(:)g -(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g -(:)g(:)h(:)f(:)g(:)g(:)g(:)14 b Fm(44)448 1735 y(2.12.0.5)43 -b(bfd)p 712 1735 V 17 w(cac)o(he)p 836 1735 V 17 w(close)11 -b Fa(:)d(:)f(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g -(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)k Fm(44)448 -1785 y(2.12.0.6)43 b(bfd)p 712 1785 V 17 w(op)q(en)p 823 1785 -V 17 w(\014le)5 b Fa(:)k(:)e(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g -(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g -(:)g(:)e Fm(44)448 1835 y(2.12.0.7)43 b(bfd)p 712 1835 V 17 -w(cac)o(he)p 836 1835 V 17 w(lo)q(okup)p 986 1835 V 17 w(w)o(ork)o(er)8 -b Fa(:)e(:)h(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g -(:)g(:)g(:)h(:)f(:)g Fm(44)0 1939 y Fn(3)67 b(BFD)22 b(bac)n(k)h(end)9 -b Fb(:)h(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g -(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g -(:)g(:)h(:)e Fn(45)149 2001 y Fm(3.1)45 b(a.out)14 b(bac)o(k)o(ends)7 -b Fa(:)h(:)f(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g -(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g -(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g -Fm(46)299 2051 y(3.1.1)44 b(relo)q(cations)6 b Fa(:)h(:)h(:)f(:)g(:)g(:)h(:)f -(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h -(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g -(:)h(:)d Fm(46)299 2101 y(3.1.2)44 b(In)o(ternal)16 b(En)o(try)e(P)o(oin)o -(ts)d Fa(:)c(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g -(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)i -Fm(46)448 2151 y(3.1.2.1)44 b(aout)p 715 2151 V 15 w Fh(<)p -Fm(size)p Fh(>)p 848 2151 V 17 w Fm(sw)o(ap)p 963 2151 V 16 -w(exec)p 1063 2151 V 17 w(header)p 1211 2151 V 17 w(in)14 b -Fa(:)7 b(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)h(:)f(:)g(:)g(:)13 -b Fm(47)448 2201 y(3.1.2.2)44 b(aout)p 715 2201 V 15 w Fh(<)p -Fm(size)p Fh(>)p 848 2201 V 17 w Fm(sw)o(ap)p 963 2201 V 16 -w(exec)p 1063 2201 V 17 w(header)p 1211 2201 V 17 w(out)9 b -Fa(:)e(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)i -Fm(47)448 2250 y(3.1.2.3)44 b(aout)p 715 2250 V 15 w Fh(<)p -Fm(size)p Fh(>)p 848 2250 V 17 w Fm(some)p 964 2250 V 16 w(aout)p -1069 2250 V 16 w(ob)s(ject)p 1208 2250 V 16 w(p)11 b Fa(:)d(:)f(:)g(:)h(:)f -(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)k Fm(47)448 -2300 y(3.1.2.4)44 b(aout)p 715 2300 V 15 w Fh(<)p Fm(size)p -Fh(>)p 848 2300 V 17 w Fm(mk)o(ob)s(ject)11 b Fa(:)6 b(:)i(:)f(:)g(:)g(:)g(:) -h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h -(:)i Fm(47)448 2350 y(3.1.2.5)44 b(aout)p 715 2350 V 15 w Fh(<)p -Fm(size)p Fh(>)p 848 2350 V 17 w Fm(mac)o(hine)p 1027 2350 -V 18 w(t)o(yp)q(e)10 b Fa(:)d(:)g(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g -(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)i Fm(47)448 2400 y(3.1.2.6)44 -b(aout)p 715 2400 V 15 w Fh(<)p Fm(size)p Fh(>)p 848 2400 V -17 w Fm(set)p 921 2400 V 17 w(arc)o(h)p 1023 2400 V 16 w(mac)o(h)13 -b Fa(:)7 b(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:) -f(:)g(:)g(:)g(:)14 b Fm(48)448 2450 y(3.1.2.7)44 b(aout)p 715 -2450 V 15 w Fh(<)p Fm(size)p Fh(>)p Fm(new)p 926 2450 V 18 -w(section)p 1080 2450 V 17 w(ho)q(ok)9 b Fa(:)e(:)g(:)h(:)f(:)g(:)g(:)g(:)h -(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)i Fm(48)149 -2499 y(3.2)45 b(co\013)15 b(bac)o(k)o(ends)e Fa(:)7 b(:)g(:)g(:)h(:)f(:)g(:)g -(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g -(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g -(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)13 b Fm(49)299 2549 y(3.2.1)44 -b(P)o(orting)14 b(T)l(o)h(A)h(New)f(V)l(ersion)h(of)f(Co\013)6 -b Fa(:)g(:)h(:)g(:)g(:)h(:)f(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g -(:)h(:)f(:)g(:)g(:)g(:)f Fm(49)299 2599 y(3.2.2)44 b(Ho)o(w)14 -b(The)i(Co\013)e(Bac)o(k)o(end)h(W)l(orks)e Fa(:)8 b(:)f(:)g(:)g(:)g(:)h(:)f -(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h -(:)13 b Fm(49)448 2649 y(3.2.2.1)44 b(Bit)15 b(Twiddling)f -Fa(:)7 b(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h -(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)j -Fm(49)0 2770 y Fk(c)6 b(y)g(g)g(n)g(u)g(s)36 b(s)6 b(u)g(p)g(p)g(o)g(r)g(t)p -332 2761 1396 3 v 1421 w(Revision:)17 b(1.5)p eop -%%Page: -3 61 -bop 12 -66 873 3 v 897 -58 a Fk(DRAFT)p 1028 -66 V 898 w Fj(iii)448 -42 y Fm(3.2.2.2)44 b(Sym)o(b)q(ol)15 b(Reading)9 b Fa(:)g(:)e(:)g(:)h(:)f(:)g -(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g -(:)g(:)g(:)h(:)f(:)g(:)g(:)i Fm(50)448 91 y(3.2.2.3)44 b(Sym)o(b)q(ol)15 -b(W)l(riting)t Fa(:)9 b(:)e(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)h(:)f(:)g(:)g(:)g -(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)t -Fm(51)448 141 y(3.2.2.4)44 b(W)l(riting)15 b(Relo)q(cations)h -Fa(:)7 b(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g -(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)14 b Fm(52)448 191 y(3.2.2.5)44 -b(Reading)16 b(Linen)o(um)o(b)q(ers)6 b Fa(:)j(:)e(:)h(:)f(:)g(:)g(:)g(:)h(:) -f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)f -Fm(52)448 241 y(3.2.2.6)44 b(Reading)16 b(Relo)q(cations)9 -b Fa(:)f(:)g(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f -(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)g Fm(53)0 345 y Fn(F)-6 -b(unction)25 b(Index)10 b Fb(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)h(:)f(:)g -(:)g(:)g(:)h(:)f(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)h(:)f(:)g(:)g -(:)g(:)h(:)f(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f Fn(54)0 457 -y(Index)5 b Fb(:)12 b(:)e(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h -(:)f(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f -(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g(:)g(:)h(:)f(:)g(:)g(:)g(:)h(:)f(:)g -(:)c Fn(55)0 2770 y Fk(c)g(y)g(g)g(n)g(u)g(s)36 b(s)6 b(u)g(p)g(p)g(o)g(r)g -(t)p 332 2761 1396 3 v 1421 w(Revision:)17 b(1.5)p eop -%%Trailer -end -userdict /end-hook known{end-hook}if -%%EOF diff --git a/bfd/bfd.texinfo b/bfd/bfd.texinfo deleted file mode 100755 index 2320387b3fb..00000000000 --- a/bfd/bfd.texinfo +++ /dev/null @@ -1,492 +0,0 @@ -\input texinfo -@setfilename bfdinfo -@c $Id$ -@syncodeindex fn cp -@ifinfo -This file documents the BFD library. - -Copyright (C) 1991 Free Software Foundation, Inc. - -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. - -@ignore -Permission is granted to process this file through Tex and print the -results, provided the printed document carries copying permission -notice identical to this one except for the removal of this paragraph -(this paragraph not being relevant to the printed manual). - -@end ignore -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, subject to the terms -of the GNU General Public License, which includes the provision that the -entire resulting derived work is distributed under the terms of a -permission notice identical to this one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions. -@end ifinfo -@iftex -@c@finalout -@setchapternewpage on -@c@setchapternewpage odd -@settitle LIB BFD, the Binary File Descriptor Library -@titlepage -@title{libbfd} -@subtitle{The Binary File Descriptor Library} -@sp 1 -@subtitle First Edition---BFD version < 2.0 -@subtitle April 1991 -@author {Steve Chamberlain} -@author {Cygnus Support} -@page - -@tex -\def\$#1${{#1}} % Kluge: collect RCS revision info without $...$ -\xdef\manvers{\$Revision$} % For use in headers, footers too -{\parskip=0pt -\hfill Cygnus Support\par -\hfill steve\@cygnus.com\par -\hfill {\it BFD}, \manvers\par -\hfill \TeX{}info \texinfoversion\par -} -\global\parindent=0pt % Steve likes it this way -@end tex - -@vskip 0pt plus 1filll -Copyright @copyright{} 1991 Free Software Foundation, Inc. - -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. - -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, subject to the terms -of the GNU General Public License, which includes the provision that the -entire resulting derived work is distributed under the terms of a -permission notice identical to this one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions. -@end titlepage -@end iftex - -@node Top, Overview, (dir), (dir) -@ifinfo -This file documents the binary file descriptor library libbfd. -@end ifinfo - -@menu -* Overview:: Overview of BFD -* History:: History of BFD -* Backends:: Backends -* Porting:: Porting -* Future:: Future -* Index:: Index - -BFD body: -* Memory usage:: -* Sections:: -* Symbols:: -* Archives:: -* Formats:: -* Relocations:: -* Core Files:: -* Targets:: -* Architecturs:: -* Opening and Closing:: -* Internal:: -* File Caching:: - -BFD backends: -* a.out backends:: -* coff backends:: -@end menu - -@node Overview, History, Top, Top -@chapter Introduction -@cindex BFD -@cindex what is it? -BFD is a package for manipulating binary files required for developing -programs. It implements a group of structured operations designed to -shield the programmer from the underlying representation of these -binary files. It understands object (compiled) files, archive -libraries, and core files. It is designed to work in a variety of -target environments. - -Most simply put, BFD is a package which allows applications to use the -same routines to operate on object files whatever the object file -format. - -BFD is split into two parts; the front end and the many back ends. -@itemize @bullet -@item -The front end of BFD provides the interface to the user. It manages -memory, and various canonical data structures. The front end also -decides which back end to use, and when to call back end routines. -@item -The back ends provide BFD its view of the real world. A different -object file format can be supported simply by creating a new BFD back -end and adding it to the library. Each back end provides a set of calls -which the BFD front end can use to maintain its canonical form. The back -ends also may keep around information for their own use, for greater -efficiency. -@end itemize -@node History, How It Works, Overview,Top -@section History - -One spur behind BFD was the desire, on the part of the GNU 960 team at -Intel Oregon, for interoperability of applications on their COFF and -b.out file formats. Cygnus was providing GNU support for the team, and -Cygnus was contracted to provide the required functionality. - -The name came from a conversation David Wallace was having with Richard -Stallman about the library: RMS said that it would be quite hard---David -said ``BFD''. Stallman was right, but the name stuck. - -At the same time, Ready Systems wanted much the same thing, but for -different object file formats: IEEE-695, Oasys, Srecords, a.out and 68k -coff. - -BFD was first implemented by Steve Chamberlain (steve@@cygnus.com), -John Gilmore (gnu@@cygnus.com), K. Richard Pixley (rich@@cygnus.com) and -David Wallace (gumby@@cygnus.com) at Cygnus Support in Palo Alto, -California. - -@node How It Works, History, Porting, Top -@section How It Works - -To use the library, include @code{bfd.h} and link with @code{libbfd.a}. - -BFD provides a common interface to the parts of an object file -for a calling application. - -When an application sucessfully opens a target file (object, archive or -whatever) a pointer to an internal structure is returned. This pointer -points to a structure called @code{bfd}, described in -@code{include/bfd.h}. Our convention is to call this pointer a BFD, and -instances of it within code @code{abfd}. All operations on -the target object file are applied as methods to the BFD. The mapping is -defined within @code{bfd.h} in a set of macros, all beginning -@samp{bfd_}. - -In short, a BFD is a representation for a particular file. It is opened -in a manner similar to a file; code then manipulates it rather than the -raw files. - -For example, this sequence would do what you would probably expect: -return the number of sections in an object file attached to a BFD -@code{abfd}. - -@lisp -@cartouche -#include "bfd.h" - -unsigned int number_of_sections(abfd) -bfd *abfd; -@{ - return bfd_count_sections(abfd); -@} -@end cartouche -@end lisp - -The abstraction used within BFD is that an object file has a header, -a number of sections containing raw data, a set of relocations, and some -symbol information. Also, BFDs opened for archives have the -additional attribute of an index and contain subordinate BFDs. This approach is -fine for a.out and coff, but loses efficiency when applied to formats -such as S-records and IEEE-695. - -@cindex targets -@cindex formats -BFD makes a distinction between @dfn{targets} (families of file -formats) and @dfn{formats} (individual file formats). For instance, -the @code{"sun4os4"} target can handle core, object and archive formats of -files. The exact layout of the different formats depends on the target -environment. - -The target @code{"default"} means the first one known (usually used for -environments that only support one format, or where the common format -is known at compile or link time). The target @code{NULL} means the one -specified at runtime in the environment variable @code{GNUTARGET}; if that is -null or not defined then, on output, the first entry in the target list -is chosen; or, on input, all targets are searched to find a matching -one. - -Most programs should use the target @code{NULL}. See the descriptions -of @code{bfd_target_list} and @code{bfd_format_string} for functions to -inquire on targets and formats. - -@section What BFD Version 1 Can Do -As different information from the the object files is required, -BFD reads from different sections of the file and processes them. -For example a very common operation for the linker is processing symbol -tables. Each BFD back end provides a routine for converting -between the object file's representation of symbols and an internal -canonical format. When the linker asks for the symbol table of an object -file, it calls through the memory pointer to the relevant BFD -back end routine which reads and converts the table into a canonical -form. The linker then operates upon the canonical form. When the link is -finished and the linker writes the output file's symbol table, -another BFD back end routine is called which takes the newly -created symbol table and converts it into the chosen output format. - -@node BFD information loss, Mechanism, BFD outline, BFD -@subsection Information Loss -@emph{Some information is lost due to the nature of the file format.} The output targets -supported by BFD do not provide identical facilities, and -information which may be described in one form has nowhere to go in -another format. One example of this is alignment information in -@code{b.out}. There is nowhere in an @code{a.out} format file to store -alignment information on the contained data, so when a file is linked -from @code{b.out} and an @code{a.out} image is produced, alignment -information will not propagate to the output file. (The linker will -still use the alignment information internally, so the link is performed -correctly). - -Another example is COFF section names. COFF files may contain an -unlimited number of sections, each one with a textual section name. If -the target of the link is a format which does not have many sections (eg -@code{a.out}) or has sections without names (eg the Oasys format) the -link cannot be done simply. You can circumvent this problem by -describing the desired input-to-output section mapping with the linker command -language. - -@emph{Information can be lost during canonicalization.} The BFD -internal canonical form of the external formats is not exhaustive; there -are structures in input formats for which there is no direct -representation internally. This means that the BFD back ends -cannot maintain all possible data richness through the transformation -between external to internal and back to external formats. - -This limitation is only a problem when an application reads one -format and writes another. Each BFD back end is responsible for -maintaining as much data as possible, and the internal BFD -canonical form has structures which are opaque to the BFD core, -and exported only to the back ends. When a file is read in one format, -the canonical form is generated for BFD and the application. At the -same time, the back end saves away any information which may otherwise -be lost. If the data is then written back in the same format, the back -end routine will be able to use the canonical form provided by the -BFD core as well as the information it prepared earlier. Since -there is a great deal of commonality between back ends, this mechanism -is very useful. There is no information lost for this reason when -linking or copying big endian COFF to little endian COFF, or @code{a.out} to -@code{b.out}. When a mixture of formats is linked, the information is -only lost from the files whose format differs from the destination. - -@node Mechanism, , BFD information loss, BFD -@subsection Mechanism -The greatest potential for loss of information is when there is least -overlap between the information provided by the source format, that -stored by the canonical format, and the information needed by the -destination format. A brief description of the canonical form may help -you appreciate what kinds of data you can count on preserving across -conversions. -@cindex BFD canonical format -@cindex internal object-file format - -@table @emph -@item files -Information on target machine architecture, particular implementation -and format type are stored on a per-file basis. Other information -includes a demand pageable bit and a write protected bit. Note that -information like Unix magic numbers is not stored here---only the magic -numbers' meaning, so a @code{ZMAGIC} file would have both the demand -pageable bit and the write protected text bit set. The byte order of -the target is stored on a per-file basis, so that big- and little-endian -object files may be linked with one another. -@c FIXME: generalize above from "link"? - -@item sections -Each section in the input file contains the name of the section, the -original address in the object file, various flags, size and alignment -information and pointers into other BFD data structures. - -@item symbols -Each symbol contains a pointer to the object file which originally -defined it, its name, its value, and various flag bits. When a -BFD back end reads in a symbol table, the back end relocates all -symbols to make them relative to the base of the section where they were -defined. This ensures that each symbol points to its containing -section. Each symbol also has a varying amount of hidden data to contain -private data for the BFD back end. Since the symbol points to the -original file, the private data format for that symbol is accessible. -@code{gld} can operate on a collection of symbols of wildly different -formats without problems. - -Normal global and simple local symbols are maintained on output, so an -output file (no matter its format) will retain symbols pointing to -functions and to global, static, and common variables. Some symbol -information is not worth retaining; in @code{a.out} type information is -stored in the symbol table as long symbol names. This information would -be useless to most COFF debuggers; the linker has command line switches -to allow users to throw it away. - -There is one word of type information within the symbol, so if the -format supports symbol type information within symbols (for example COFF, -IEEE, Oasys) and the type is simple enough to fit within one word -(nearly everything but aggregates) the information will be preserved. - -@item relocation level -Each canonical BFD relocation record contains a pointer to the symbol to -relocate to, the offset of the data to relocate, the section the data -is in and a pointer to a relocation type descriptor. Relocation is -performed effectively by message passing through the relocation type -descriptor and symbol pointer. It allows relocations to be performed -on output data using a relocation method only available in one of the -input formats. For instance, Oasys provides a byte relocation format. -A relocation record requesting this relocation type would point -indirectly to a routine to perform this, so the relocation may be -performed on a byte being written to a COFF file, even though 68k COFF -has no such relocation type. - -@item line numbers -Object formats can contain, for debugging purposes, some form of mapping -between symbols, source line numbers, and addresses in the output file. -These addresses have to be relocated along with the symbol information. -Each symbol with an associated list of line number records points to the -first record of the list. The head of a line number list consists of a -pointer to the symbol, which allows divination of the address of the -function whose line number is being described. The rest of the list is -made up of pairs: offsets into the section and line numbers. Any format -which can simply derive this information can pass it successfully -between formats (COFF, IEEE and Oasys). -@end table - -@c FIXME: what is this line about? Do we want introductory remarks -@c FIXME... on back ends? commented out for now. -@c What is a backend -@node BFD front end, BFD back end, Mechanism, Top -@chapter BFD front end -@include bfd.texi - -@node Memory Usage, Errors, bfd, Top -@section Memory Usage -BFD keeps all its internal structures in obstacks. There is one obstack -per open BFD file, into which the current state is stored. When a BFD is -closed, the obstack is deleted, and so everything which has been -allocated by libbfd for the closing file will be thrown away. - -BFD will not free anything created by an application, but pointers into -@code{bfd} structures will be invalidated on a @code{bfd_close}; for example, -after a @code{bfd_close} the vector passed to -@code{bfd_canonicalize_symtab} will still be around, since it has been -allocated by the application, but the data that it pointed to will be -lost. - -The general rule is not to close a BFD until all operations dependent -upon data from the BFD have been completed, or all the data from within -the file has been copied. To help with the management of memory, there is a function -(@code{bfd_alloc_size}) which returns the number of bytes in obstacks -associated with the supplied BFD. This could be used to select the -greediest open BFD, close it to reclaim the memory, perform some -operation and reopen the BFD again, to get a fresh copy of the data -structures. - -@node Errors, Sections, Memory Usage, Top -@section Error Handling - -@cindex errors -In general, a boolean function returns true on success and false on failure -(unless it's a predicate). Functions which return pointers to -objects return @code{NULL} on error. The specifics are documented with each -function. - -If a function fails, you should check the variable @code{bfd_error}. If -the value is @code{no_error}, then check the C variable @code{errno} -just as you would with any other program. Other values for -@code{bfd_error} are documented in @file{bfd.h}. - -@findex bfd_errmsg -If you would prefer a comprehensible string for the error message, use -the function @code{bfd_errmsg}: -@example -char * bfd_errmsg (error_tag) -@end example -This function returns a read-only string which documents the error -code. If the error code is @code{no_error} then it will return a string -depending on the value of @code{errno}. - -@findex bfd_perror -@code{bfd_perror()} is like the @code{perror()} function except it understands -@code{bfd_error}. - - -@node Sections, Symbols, Errors, Top -@include section.texi - -@node Symbols, Archives ,Sections, To -@include syms.texi - -@node Archives, Formats, Symbols, Top -@include archive.texi - -@node Formats, Relocations, Archives, Top -@include format.texi - -@node Relocations, Core Files,Formats, Top -@include reloc.texi - -@node Core Files, Targets, Relocations, Top -@include core.texi - -@node Targets, Architectures, Core Files, Top -@include targets.texi - -@node Architectures, Opening and Closing, Targets, Top -@include archures.texi - -@node Opening and Closing, Internal, Architectures, Top -@include opncls.texi - -@node Internal, File Caching, Opening and Closing, Top -@include libbfd.texi - -@node File Caching, Top, Internal, Top -@include cache.texi - -@chapter BFD back end -@node BFD back end, ,BFD front end, Top -@menu -* What to put where -* a.out backends:: -* coff backends:: -* oasys backend:: -* ieee backend:: -* srecord backend:: -@end menu -@node What to Put Where, aout backends, BFD back end, BFD back end -All of BFD lives in one directory. - -@node aout backends, coff backends, What to Put Where, BFD back end -@include aoutx.texi - -@node coff backends, oasys backends, aout backends, BFD back end -@include coffcode.texi - -@node Index, , BFD, Top -@unnumbered Index -@printindex cp - -@tex -% I think something like @colophon should be in texinfo. In the -% meantime: -\long\def\colophon{\hbox to0pt{}\vfill -\centerline{The body of this manual is set in} -\centerline{\fontname\tenrm,} -\centerline{with headings in {\bf\fontname\tenbf}} -\centerline{and examples in {\tt\fontname\tentt}.} -\centerline{{\it\fontname\tenit\/} and} -\centerline{{\sl\fontname\tensl\/}} -\centerline{are used for emphasis.}\vfill} -\page\colophon -% Blame: pesch@cygnus.com, 28mar91. -@end tex - - -@contents -@bye - - diff --git a/bfd/blins-p b/bfd/blins-p deleted file mode 100755 index 858dcd7ecd7..00000000000 --- a/bfd/blins-p +++ /dev/null @@ -1,8 +0,0 @@ -# sed script for BFD header files -# Merge adjacent blank lines. Loop til no change. -:blin -/^$/,/^ *[^ ]*.*$/{ -/^$/N -s/^ *\n *$// -} -t blin diff --git a/bfd/bout.c b/bfd/bout.c deleted file mode 100644 index baa2ab27b39..00000000000 --- a/bfd/bout.c +++ /dev/null @@ -1,757 +0,0 @@ -/* BFD back-end for Intel 960 b.out binaries. - Copyright (C) 1990-1991 Free Software Foundation, Inc. - Written by Cygnus Support. - -This file is part of BFD, the Binary File Descriptor library. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* $Id$ */ - -#include "bfd.h" -#include "sysdep.h" -#include "libbfd.h" - -#include "bout.h" - -#include "stab.gnu.h" -#include "libaout.h" /* BFD a.out internal data structures */ - -/* Align an address by rounding it up to a power of two. It leaves the - address unchanged if align == 0 (2^0 = alignment of 1 byte) */ -#define i960_align(addr, align) \ - ( ((addr) + ((1<<(align))-1)) & (-1 << (align))) - - -PROTO (static boolean, b_out_squirt_out_relocs,(bfd *abfd, asection *section)); -PROTO (static bfd_target *, b_out_callback, (bfd *)); - -PROTO (boolean, aout_32_slurp_symbol_table, (bfd *abfd)); -PROTO (void , aout_32_write_syms, ()); - -/* Swaps the information in an executable header taken from a raw byte - stream memory image, into the internal exec_header structure. */ - -PROTO(void, bout_swap_exec_header_in, - (bfd *abfd, - struct external_exec *raw_bytes, - struct internal_exec *execp)); - -void -DEFUN(bout_swap_exec_header_in,(abfd, raw_bytes, execp), - bfd *abfd AND - struct external_exec *raw_bytes AND - struct internal_exec *execp) -{ - struct external_exec *bytes = (struct external_exec *)raw_bytes; - - /* Now fill in fields in the execp, from the bytes in the raw data. */ - execp->a_info = bfd_h_get_32 (abfd, bytes->e_info); - execp->a_text = GET_WORD (abfd, bytes->e_text); - execp->a_data = GET_WORD (abfd, bytes->e_data); - execp->a_bss = GET_WORD (abfd, bytes->e_bss); - execp->a_syms = GET_WORD (abfd, bytes->e_syms); - execp->a_entry = GET_WORD (abfd, bytes->e_entry); - execp->a_trsize = GET_WORD (abfd, bytes->e_trsize); - execp->a_drsize = GET_WORD (abfd, bytes->e_drsize); - execp->a_tload = GET_WORD (abfd, bytes->e_tload); - execp->a_dload = GET_WORD (abfd, bytes->e_dload); - execp->a_talign = bytes->e_talign[0]; - execp->a_dalign = bytes->e_dalign[0]; - execp->a_balign = bytes->e_balign[0]; -} - -/* Swaps the information in an internal exec header structure into the - supplied buffer ready for writing to disk. */ - -PROTO(void, bout_swap_exec_header_out, - (bfd *abfd, - struct internal_exec *execp, - struct external_exec *raw_bytes)); -void -DEFUN(bout_swap_exec_header_out,(abfd, execp, raw_bytes), - bfd *abfd AND - struct internal_exec *execp AND - struct external_exec *raw_bytes) -{ - struct external_exec *bytes = (struct external_exec *)raw_bytes; - - /* Now fill in fields in the raw data, from the fields in the exec struct. */ - bfd_h_put_32 (abfd, execp->a_info , bytes->e_info); - PUT_WORD (abfd, execp->a_text , bytes->e_text); - PUT_WORD (abfd, execp->a_data , bytes->e_data); - PUT_WORD (abfd, execp->a_bss , bytes->e_bss); - PUT_WORD (abfd, execp->a_syms , bytes->e_syms); - PUT_WORD (abfd, execp->a_entry , bytes->e_entry); - PUT_WORD (abfd, execp->a_trsize, bytes->e_trsize); - PUT_WORD (abfd, execp->a_drsize, bytes->e_drsize); - PUT_WORD (abfd, execp->a_tload , bytes->e_tload); - PUT_WORD (abfd, execp->a_dload , bytes->e_dload); - bytes->e_talign[0] = execp->a_talign; - bytes->e_dalign[0] = execp->a_dalign; - bytes->e_balign[0] = execp->a_balign; - bytes->e_unused[0] = 0; /* Clean structs are godly structs */ -} - - -static bfd_target * -b_out_object_p (abfd) - bfd *abfd; -{ - struct internal_exec anexec; - struct external_exec exec_bytes; - - if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd) - != EXEC_BYTES_SIZE) { - bfd_error = wrong_format; - return 0; - } - - anexec.a_info = bfd_h_get_32 (abfd, exec_bytes.e_info); - - if (N_BADMAG (anexec)) { - bfd_error = wrong_format; - return 0; - } - - bout_swap_exec_header_in (abfd, &exec_bytes, &anexec); - return aout_32_some_aout_object_p (abfd, &anexec, b_out_callback); -} - - -/* Finish up the opening of a b.out file for reading. Fill in all the - fields that are not handled by common code. */ - -static bfd_target * -b_out_callback (abfd) - bfd *abfd; -{ - struct internal_exec *execp = exec_hdr (abfd); - unsigned long bss_start; - - /* Architecture and machine type */ - bfd_set_arch_mach(abfd, - bfd_arch_i960, /* B.out only used on i960 */ - bfd_mach_i960_core /* Default */ - ); - - /* The positions of the string table and symbol table. */ - obj_str_filepos (abfd) = N_STROFF (*execp); - obj_sym_filepos (abfd) = N_SYMOFF (*execp); - - /* The alignments of the sections */ - obj_textsec (abfd)->alignment_power = execp->a_talign; - obj_datasec (abfd)->alignment_power = execp->a_dalign; - obj_bsssec (abfd)->alignment_power = execp->a_balign; - - /* The starting addresses of the sections. */ - obj_textsec (abfd)->vma = execp->a_tload; - obj_datasec (abfd)->vma = execp->a_dload; - bss_start = execp->a_dload + execp->a_data; /* BSS = end of data section */ - obj_bsssec (abfd)->vma = i960_align (bss_start, execp->a_balign); - - /* The file positions of the sections */ - obj_textsec (abfd)->filepos = N_TXTOFF(*execp); - obj_datasec (abfd)->filepos = N_DATOFF(*execp); - - /* The file positions of the relocation info */ - obj_textsec (abfd)->rel_filepos = N_TROFF(*execp); - obj_datasec (abfd)->rel_filepos = N_DROFF(*execp); - - return abfd->xvec; -} - -struct container { - struct aoutdata a; - struct internal_exec e; -}; - -static boolean -b_out_mkobject (abfd) - bfd *abfd; -{ - struct container *rawptr; - - rawptr = (struct container *) bfd_zalloc (abfd, sizeof (struct container)); - if (rawptr == NULL) { - bfd_error = no_memory; - return false; - } - - set_tdata (abfd, &rawptr->a); - exec_hdr (abfd) = &rawptr->e; - - /* For simplicity's sake we just make all the sections right here. */ - obj_textsec (abfd) = (asection *)NULL; - obj_datasec (abfd) = (asection *)NULL; - obj_bsssec (abfd) = (asection *)NULL; - - bfd_make_section (abfd, ".text"); - bfd_make_section (abfd, ".data"); - bfd_make_section (abfd, ".bss"); - - return true; -} - -static boolean -b_out_write_object_contents (abfd) - bfd *abfd; -{ - struct external_exec swapped_hdr; - - exec_hdr (abfd)->a_info = BMAGIC; - - exec_hdr (abfd)->a_text = obj_textsec (abfd)->size; - exec_hdr (abfd)->a_data = obj_datasec (abfd)->size; - exec_hdr (abfd)->a_bss = obj_bsssec (abfd)->size; - exec_hdr (abfd)->a_syms = bfd_get_symcount (abfd) * sizeof (struct nlist); - exec_hdr (abfd)->a_entry = bfd_get_start_address (abfd); - exec_hdr (abfd)->a_trsize = ((obj_textsec (abfd)->reloc_count) * - sizeof (struct relocation_info)); - exec_hdr (abfd)->a_drsize = ((obj_datasec (abfd)->reloc_count) * - sizeof (struct relocation_info)); - - exec_hdr (abfd)->a_talign = obj_textsec (abfd)->alignment_power; - exec_hdr (abfd)->a_dalign = obj_datasec (abfd)->alignment_power; - exec_hdr (abfd)->a_balign = obj_bsssec (abfd)->alignment_power; - - exec_hdr (abfd)->a_tload = obj_textsec (abfd)->vma; - exec_hdr (abfd)->a_dload = obj_datasec (abfd)->vma; - - bout_swap_exec_header_out (abfd, exec_hdr (abfd), &swapped_hdr); - - bfd_seek (abfd, 0L, SEEK_SET); - bfd_write ((PTR) &swapped_hdr, 1, EXEC_BYTES_SIZE, abfd); - - /* Now write out reloc info, followed by syms and strings */ - if (bfd_get_symcount (abfd) != 0) - { - bfd_seek (abfd, - (long)(N_SYMOFF(*exec_hdr(abfd))), SEEK_SET); - - aout_32_write_syms (abfd); - - bfd_seek (abfd, (long)(N_TROFF(*exec_hdr(abfd))), SEEK_SET); - - if (!b_out_squirt_out_relocs (abfd, obj_textsec (abfd))) return false; - bfd_seek (abfd, (long)(N_DROFF(*exec_hdr(abfd))), SEEK_SET); - - if (!b_out_squirt_out_relocs (abfd, obj_datasec (abfd))) return false; - } - return true; -} - -/** Some reloc hackery */ - -#define CALLS 0x66003800 /* Template for 'calls' instruction */ -#define BAL 0x0b000000 /* Template for 'bal' instruction */ -#define BAL_MASK 0x00ffffff - -static bfd_reloc_status_type -callj_callback(abfd, reloc_entry, symbol_in, data, input_section) -bfd *abfd; -arelent *reloc_entry; -asymbol *symbol_in; -unsigned char *data; -asection *input_section; -{ - int word = bfd_get_32(abfd, data+reloc_entry->address); - aout_symbol_type *symbol = aout_symbol(symbol_in); - - if (IS_OTHER(symbol->other)) { - /* Call to a system procedure - replace code with system - procedure number - */ - - word = CALLS | (symbol->other - 1); - bfd_put_32(abfd, word, data+reloc_entry->address); /* replace */ - return bfd_reloc_ok; - } - - if (IS_CALLNAME(symbol->other)) { - aout_symbol_type *balsym = symbol+1; - /* The next symbol should be an N_BALNAME */ - BFD_ASSERT(IS_BALNAME(balsym->other)); - - /* We are calling a leaf - so replace the call instruction - with a bal */ - - word = BAL | - (((word & BAL_MASK) + - balsym->symbol.section->output_offset + - balsym->symbol.section->output_section->vma+ - balsym->symbol.value + reloc_entry->addend - - ( input_section->output_section->vma + input_section->output_offset)) - & BAL_MASK); - - bfd_put_32(abfd, word, data+reloc_entry->address); /* replace */ - return bfd_reloc_ok; - } - return bfd_reloc_continue; - -} -/* type rshift size bitsize pcrel bitpos absolute overflow check*/ - - -static reloc_howto_type howto_reloc_callj = -HOWTO( 3, 0, 2, 24, true, 0, true, true, callj_callback,"callj", true, 0x00ffffff, 0x00ffffff,false); -static reloc_howto_type howto_reloc_abs32 = -HOWTO(1, 0, 2, 32, false, 0, true, true,0,"abs32", true, 0xffffffff,0xffffffff,false); -static reloc_howto_type howto_reloc_pcrel24 = -HOWTO(2, 0, 2, 24, true, 0, true, true,0,"pcrel24", true, 0x00ffffff,0x00ffffff,false); - -/* Allocate enough room for all the reloc entries, plus pointers to them all */ - -static boolean -b_out_slurp_reloc_table (abfd, asect, symbols) - bfd *abfd; - sec_ptr asect; - asymbol **symbols; -{ - unsigned int count; - size_t reloc_size; - struct relocation_info *relocs; - arelent *reloc_cache; - - if (asect->relocation) return true; - if (!aout_32_slurp_symbol_table (abfd)) return false; - - if (asect == obj_datasec (abfd)) { - reloc_size = exec_hdr(abfd)->a_drsize; - goto doit; - } - - if (asect == obj_textsec (abfd)) { - reloc_size = exec_hdr(abfd)->a_trsize; - goto doit; - } - - bfd_error = invalid_operation; - return false; - - doit: - bfd_seek (abfd, (long)(asect->rel_filepos), SEEK_SET); - count = reloc_size / sizeof (struct relocation_info); - - relocs = (struct relocation_info *) malloc (reloc_size); - if (!relocs) { - bfd_error = no_memory; - return false; - } - reloc_cache = (arelent *) malloc ((count+1) * sizeof (arelent)); - if (!reloc_cache) { - free ((char*)relocs); - bfd_error = no_memory; - return false; - } - - if (bfd_read ((PTR) relocs, 1, reloc_size, abfd) != reloc_size) { - bfd_error = system_call_error; - free (reloc_cache); - free (relocs); - return false; - } - - { - register struct relocation_info *rptr = relocs; - unsigned int counter = 0; - arelent *cache_ptr = reloc_cache; - int extern_mask, pcrel_mask, callj_mask; - - if (abfd->xvec->header_byteorder_big_p) { - /* Big-endian bit field allocation order */ - pcrel_mask = 0x80; - extern_mask = 0x10; - callj_mask = 0x02; - } else { - /* Little-endian bit field allocation order */ - pcrel_mask = 0x01; - extern_mask = 0x08; - callj_mask = 0x40; - } - - for (; counter < count; counter++, rptr++, cache_ptr++) - { - unsigned char *raw = (unsigned char *)rptr; - unsigned int symnum; - cache_ptr->address = bfd_h_get_32 (abfd, raw + 0); - if (abfd->xvec->header_byteorder_big_p) { - symnum = (raw[4] << 16) | (raw[5] << 8) | raw[6]; - } else { - symnum = (raw[6] << 16) | (raw[5] << 8) | raw[4]; - } - - if (raw[7] & extern_mask) { - /* If this is set then the r_index is a index into the symbol table; - * if the bit is not set then r_index contains a section map. - * We either fill in the sym entry with a pointer to the symbol, - * or point to the correct section - */ - cache_ptr->sym_ptr_ptr = symbols + symnum; - cache_ptr->addend = 0; - cache_ptr->section = (asection*)NULL; - } else { - /* In a.out symbols are relative to the beginning of the - * file rather than sections ? - * (look in translate_from_native_sym_flags) - * The reloc entry addend has added to it the offset into the - * file of the data, so subtract the base to make the reloc - * section relative */ - cache_ptr->sym_ptr_ptr = (asymbol **)NULL; - switch (symnum) { - case N_TEXT: - case N_TEXT | N_EXT: - cache_ptr->section = obj_textsec(abfd); - cache_ptr->addend = -obj_textsec(abfd)->vma; - break; - case N_DATA: - case N_DATA | N_EXT: - cache_ptr->section = obj_datasec(abfd); - cache_ptr->addend = - obj_datasec(abfd)->vma; - break; - case N_BSS: - case N_BSS | N_EXT: - cache_ptr->section = obj_bsssec(abfd); - cache_ptr->addend = - obj_bsssec(abfd)->vma; - break; - case N_ABS: - case N_ABS | N_EXT: - BFD_ASSERT(0); - break; - default: - BFD_ASSERT(0); - break; - } - - } - - /* The i960 only has a few relocation types: - abs 32-bit and pcrel 24bit. Except for callj's! */ - if (raw[7] & callj_mask) - cache_ptr->howto = &howto_reloc_callj; - else if ( raw[7] & pcrel_mask) - cache_ptr->howto = &howto_reloc_pcrel24; - else - cache_ptr->howto = &howto_reloc_abs32; - } - } - - free (relocs); - asect->relocation = reloc_cache; - asect->reloc_count = count; - return true; -} - - -static boolean -b_out_squirt_out_relocs (abfd, section) - bfd *abfd; - asection *section; -{ - arelent **generic; - - unsigned int count = section->reloc_count; - struct relocation_info *native, *natptr; - size_t natsize = count * sizeof (struct relocation_info); - int extern_mask, pcrel_mask, len_2, callj_mask; - if (count == 0) return true; - generic = section->orelocation; - native = ((struct relocation_info *) malloc (natsize)); - if (!native) { - bfd_error = no_memory; - return false; - } - - if (abfd->xvec->header_byteorder_big_p) { - /* Big-endian bit field allocation order */ - pcrel_mask = 0x80; - extern_mask = 0x10; - len_2 = 0x40; - callj_mask = 0x02; - } else { - /* Little-endian bit field allocation order */ - pcrel_mask = 0x01; - extern_mask = 0x08; - len_2 = 0x04; - callj_mask = 0x40; - } - - for (natptr = native; count > 0; --count, ++natptr, ++generic) - { - arelent *g = *generic; - unsigned char *raw = (unsigned char *)natptr; - unsigned int symnum; - - bfd_h_put_32(abfd, g->address, raw); - /* Find a type in the output format which matches the input howto - - * at the moment we assume input format == output format FIXME!! - */ - /* FIXME: Need callj stuff here, and to check the howto entries to - be sure they are real for this architecture. */ - if (g->howto== &howto_reloc_callj) { - raw[7] = callj_mask + pcrel_mask + len_2; - } - else if (g->howto == &howto_reloc_pcrel24) { - raw[7] = pcrel_mask +len_2; - } - else { - raw[7] = len_2; - } - if (g->sym_ptr_ptr != (asymbol **)NULL) - { - /* name clobbered by aout_write_syms to be symbol index*/ - if ((*(g->sym_ptr_ptr))->section) { - /* replace the section offset into the addent */ - g->addend += (*(g->sym_ptr_ptr))->section->vma ; - } - symnum = stoi((*(g->sym_ptr_ptr))->name); - raw[7] |= extern_mask; - BFD_ASSERT(g->addend == 0); - } - else { - if (g->section == (asection *)NULL) { - symnum = N_ABS; - BFD_ASSERT(0); - } - else if(g->section->output_section == obj_textsec(abfd)) { - symnum = N_TEXT; - BFD_ASSERT(g->addend + obj_textsec(abfd)->vma == 0); - } - else if (g->section->output_section == obj_datasec(abfd)) { - symnum = N_DATA; - BFD_ASSERT(g->addend + obj_datasec(abfd)->vma == 0); - } - else if (g->section->output_section == obj_bsssec(abfd)) { - symnum = N_BSS; - BFD_ASSERT(g->addend + obj_bsssec(abfd)->vma == 0); - } - else { - BFD_ASSERT(0); - symnum = N_ABS; - } - } - if (abfd->xvec->header_byteorder_big_p) { - raw[4] = (unsigned char) (symnum >> 16); - raw[5] = (unsigned char) (symnum >> 8); - raw[6] = (unsigned char) (symnum ); - } else { - raw[6] = (unsigned char) (symnum >> 16); - raw[5] = (unsigned char) (symnum >> 8); - raw[4] = (unsigned char) (symnum ); - } - } - - if (bfd_write ((PTR) native, 1, natsize, abfd) != natsize) { - free((PTR)native); - return false; - } - free ((PTR)native); - - return true; -} - -/* This is stupid. This function should be a boolean predicate */ -static unsigned int -b_out_canonicalize_reloc (abfd, section, relptr, symbols) - bfd *abfd; - sec_ptr section; - arelent **relptr; - asymbol **symbols; -{ - arelent *tblptr = section->relocation; - unsigned int count = 0; - - if (!(tblptr || b_out_slurp_reloc_table (abfd, section, symbols))) return 0; - tblptr = section->relocation; - if (!tblptr) return 0; - - for (; count++ < section->reloc_count;) - *relptr++ = tblptr++; - - *relptr = 0; - - return section->reloc_count; -} - -static unsigned int -b_out_get_reloc_upper_bound (abfd, asect) - bfd *abfd; - sec_ptr asect; -{ - if (bfd_get_format (abfd) != bfd_object) { - bfd_error = invalid_operation; - return 0; - } - - if (asect == obj_datasec (abfd)) - return (sizeof (arelent *) * - ((exec_hdr(abfd)->a_drsize / sizeof (struct relocation_info)) - +1)); - - if (asect == obj_textsec (abfd)) - return (sizeof (arelent *) * - ((exec_hdr(abfd)->a_trsize / sizeof (struct relocation_info)) - +1)); - - bfd_error = invalid_operation; - return 0; -} - -static boolean -b_out_set_section_contents (abfd, section, location, offset, count) - bfd *abfd; - sec_ptr section; - unsigned char *location; - file_ptr offset; - int count; -{ - if (abfd->output_has_begun == false) { /* set by bfd.c handler */ - if ((obj_textsec (abfd) == NULL) || (obj_datasec (abfd) == NULL) /*|| - (obj_textsec (abfd)->size == 0) || (obj_datasec (abfd)->size == 0)*/) { - bfd_error = invalid_operation; - return false; - } - - obj_textsec (abfd)->filepos = sizeof(struct internal_exec); - obj_datasec(abfd)->filepos = obj_textsec(abfd)->filepos - + obj_textsec (abfd)->size; - - } - /* regardless, once we know what we're doing, we might as well get going */ - bfd_seek (abfd, section->filepos + offset, SEEK_SET); - - if (count != 0) { - return (bfd_write ((PTR)location, 1, count, abfd) == count) ?true:false; - } - return false; -} - -static boolean -b_out_set_arch_mach (abfd, arch, machine) - bfd *abfd; - enum bfd_architecture arch; - unsigned long machine; -{ - bfd_default_set_arch_mach(abfd, arch, machine); - - if (arch == bfd_arch_unknown) /* Unknown machine arch is OK */ - return true; - if (arch == bfd_arch_i960) /* i960 default is OK */ - switch (machine) { - case bfd_mach_i960_core: - case bfd_mach_i960_kb_sb: - case bfd_mach_i960_mc: - case bfd_mach_i960_xa: - case bfd_mach_i960_ca: - case bfd_mach_i960_ka_sa: - case 0: - return true; - default: - return false; - } - - return false; -} - -static int -DEFUN(b_out_sizeof_headers,(ignore_abfd, ignore), - bfd *ignore_abfd AND - boolean ignore) -{ - return sizeof(struct internal_exec); -} - - - - -/* Build the transfer vectors for Big and Little-Endian B.OUT files. */ - -/* We don't have core files. */ -#define aout_32_core_file_failing_command _bfd_dummy_core_file_failing_command -#define aout_32_core_file_failing_signal _bfd_dummy_core_file_failing_signal -#define aout_32_core_file_matches_executable_p \ - _bfd_dummy_core_file_matches_executable_p - -/* We use BSD-Unix generic archive files. */ -#define aout_32_openr_next_archived_file bfd_generic_openr_next_archived_file -#define aout_32_generic_stat_arch_elt bfd_generic_stat_arch_elt -#define aout_32_slurp_armap bfd_slurp_bsd_armap -#define aout_32_slurp_extended_name_table bfd_true -#define aout_32_write_armap bsd_write_armap -#define aout_32_truncate_arname bfd_bsd_truncate_arname - -/* We override these routines from the usual a.out file routines. */ -#define aout_32_canonicalize_reloc b_out_canonicalize_reloc -#define aout_32_get_reloc_upper_bound b_out_get_reloc_upper_bound -#define aout_32_set_section_contents b_out_set_section_contents -#define aout_32_set_arch_mach b_out_set_arch_mach -#define aout_32_sizeof_headers b_out_sizeof_headers - -#define aout_32_bfd_debug_info_start bfd_void -#define aout_32_bfd_debug_info_end bfd_void -#define aout_32_bfd_debug_info_accumulate (PROTO(void,(*),(bfd*, struct sec *))) bfd_void - - -bfd_target b_out_vec_big_host = -{ - "b.out.big", /* name */ - bfd_target_aout_flavour, - false, /* data byte order is little */ - true, /* hdr byte order is big */ - (HAS_RELOC | EXEC_P | /* object flags */ - HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT ), - (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ - ' ', /* ar_pad_char */ - 16, /* ar_max_namelen */ - 2, /* minumum alignment power */ - -_do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putl16, /* data */ -_do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* hdrs */ - {_bfd_dummy_target, b_out_object_p, /* bfd_check_format */ - bfd_generic_archive_p, _bfd_dummy_target}, - {bfd_false, b_out_mkobject, /* bfd_set_format */ - _bfd_generic_mkarchive, bfd_false}, - {bfd_false, b_out_write_object_contents, /* bfd_write_contents */ - _bfd_write_archive_contents, bfd_false}, - - JUMP_TABLE(aout_32) -}; - - -bfd_target b_out_vec_little_host = -{ - "b.out.little", /* name */ - bfd_target_aout_flavour, - false, /* data byte order is little */ - false, /* header byte order is little */ - (HAS_RELOC | EXEC_P | /* object flags */ - HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT ), - (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ - ' ', /* ar_pad_char */ - 16, /* ar_max_namelen */ - 2, /* minum align */ -_do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putl16, /* data */ -_do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putl16, /* hdrs */ - - {_bfd_dummy_target, b_out_object_p, /* bfd_check_format */ - bfd_generic_archive_p, _bfd_dummy_target}, - {bfd_false, b_out_mkobject, /* bfd_set_format */ - _bfd_generic_mkarchive, bfd_false}, - {bfd_false, b_out_write_object_contents, /* bfd_write_contents */ - _bfd_write_archive_contents, bfd_false}, - JUMP_TABLE(aout_32) -}; diff --git a/bfd/cache.c b/bfd/cache.c deleted file mode 100644 index be85f2bdb5c..00000000000 --- a/bfd/cache.c +++ /dev/null @@ -1,264 +0,0 @@ -/* BFD library -- caching of file descriptors. - Copyright (C) 1990-1991 Free Software Foundation, Inc. - Hacked by Steve Chamberlain of Cygnus Support (steve@cygnus.com). - -This file is part of BFD, the Binary File Descriptor library. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/*doc* -@section File Caching -The file caching mechanism is embedded within BFD and allows the application to open as many -BFDs as it wants without regard to the underlying operating system's -file descriptor limit (often as low as 20 open files). - -The module in @code{cache.c} maintains a least recently used list of -@code{BFD_CACHE_MAX_OPEN} files, and exports the name -@code{bfd_cache_lookup} which runs around and makes sure that the -required BFD is open. If not, then it chooses a file to close, closes -it and opens the one wanted, returning its file handle. - -*/ - - - -/* $Id$ */ -#include -#include "bfd.h" -#include "libbfd.h" - - -/*proto-internal* BFD_CACHE_MAX_OPEN -The maxiumum number of files which the cache will keep open at one -time. -*+ -#define BFD_CACHE_MAX_OPEN 10 -*- - -*/ - - -static int open_files; - -static bfd *cache_sentinel; /* Chain of BFDs with active fds we've - opened */ - -/*proto-internal* bfd_last_cache -Zero, or a pointer to the topmost BFD on the chain. This is used by -the @code{bfd_cache_lookup} macro in @file{libbfd.h} to determine when -it can avoid a function call. -*+ -extern bfd *bfd_last_cache; -*- - -*/ - -bfd *bfd_last_cache; - -/*proto-internal* bfd_cache_lookup -Checks to see if the required BFD is the same as the last one looked -up. If so then it can use the iostream in the BFD with impunity, since -it can't have changed since the last lookup, otherwise it has to -perform the complicated lookup function -*+ -#define bfd_cache_lookup(x) \ - ((x)==bfd_last_cache? \ - (FILE*)(bfd_last_cache->iostream): \ - bfd_cache_lookup_worker(x)) - -*- - -*/ - -static void bfd_cache_delete(); - - -static void -DEFUN_VOID(close_one) -{ - bfd *kill = cache_sentinel; - if (kill == 0) /* Nothing in the cache */ - return ; - - /* We can only close files that want to play this game. */ - while (!kill->cacheable) { - kill = kill->lru_prev; - if (kill == cache_sentinel) /* Nobody wants to play */ - return ; - } - - kill->where = ftell((FILE *)(kill->iostream)); - bfd_cache_delete(kill); -} - -/* Cuts the BFD abfd out of the chain in the cache */ -static void -DEFUN(snip,(abfd), - bfd *abfd) -{ - abfd->lru_prev->lru_next = abfd->lru_next; - abfd->lru_next->lru_prev = abfd->lru_prev; - if (cache_sentinel == abfd) cache_sentinel = (bfd *)NULL; -} - -static void -DEFUN(bfd_cache_delete,(abfd), - bfd *abfd) -{ - fclose ((FILE *)(abfd->iostream)); - snip (abfd); - abfd->iostream = NULL; - open_files--; - bfd_last_cache = 0; -} - -static bfd * -DEFUN(insert,(x,y), - bfd *x AND - bfd *y) -{ - if (y) { - x->lru_next = y; - x->lru_prev = y->lru_prev; - y->lru_prev->lru_next = x; - y->lru_prev = x; - - } - else { - x->lru_prev = x; - x->lru_next = x; - } - return x; -} - - -/*proto-internal* -*i bfd_cache_init -Initialize a BFD by putting it on the cache LRU. -*; PROTO(void, bfd_cache_init, (bfd *)); -*-*/ - -void -DEFUN(bfd_cache_init,(abfd), - bfd *abfd) -{ - cache_sentinel = insert(abfd, cache_sentinel); -} - - -/*proto-internal* -*i bfd_cache_close -Remove the BFD from the cache. If the attatched file is open, then close it too. -*; PROTO(void, bfd_cache_close, (bfd *)); -*-*/ -void -DEFUN(bfd_cache_close,(abfd), - bfd *abfd) -{ - /* If this file is open then remove from the chain */ - if (abfd->iostream) - { - bfd_cache_delete(abfd); - } -} - -/*proto-internal* -*i bfd_open_file -Call the OS to open a file for this BFD. Returns the FILE * -(possibly null) that results from this operation. Sets up the -BFD so that future accesses know the file is open. If the FILE * -returned is null, then there is won't have been put in the cache, so -it won't have to be removed from it. -*; PROTO(FILE *, bfd_open_file, (bfd *)); -*-*/ -FILE * -DEFUN(bfd_open_file, (abfd), - bfd *abfd) -{ - abfd->cacheable = true; /* Allow it to be closed later. */ - if(open_files >= BFD_CACHE_MAX_OPEN) { - close_one(); - } - switch (abfd->direction) { - case read_direction: - case no_direction: - abfd->iostream = (char *) fopen(abfd->filename, "r"); - break; - case both_direction: - case write_direction: - if (abfd->opened_once == true) { - abfd->iostream = (char *) fopen(abfd->filename, "r+"); - if (!abfd->iostream) { - abfd->iostream = (char *) fopen(abfd->filename, "w+"); - } - } else { - /*open for creat */ - abfd->iostream = (char *) fopen(abfd->filename, "w"); - abfd->opened_once = true; - } - break; - } - if (abfd->iostream) { - open_files++; - bfd_cache_init (abfd); - } - - return (FILE *)(abfd->iostream); -} - -/*proto-internal* -*i bfd_cache_lookup_worker -Called when the macro @code{bfd_cache_lookup} fails to find a quick -answer. Finds a file descriptor for this BFD. If necessary, it open it. -If there are already more than BFD_CACHE_MAX_OPEN files open, it trys to close -one first, to avoid running out of file descriptors. -*; PROTO(FILE *, bfd_cache_lookup_worker, (bfd *)); - -*-*/ - -FILE * -DEFUN(bfd_cache_lookup_worker,(abfd), - bfd *abfd) -{ - if (abfd->my_archive) - { - abfd = abfd->my_archive; - } - /* Is this file already open .. if so then quick exit */ - if (abfd->iostream) - { - if (abfd != cache_sentinel) { - /* Place onto head of lru chain */ - snip (abfd); - cache_sentinel = insert(abfd, cache_sentinel); - } - } - /* This is a BFD without a stream - - so it must have been closed or never opened. - find an empty cache entry and use it. */ - else - { - - if (open_files >= BFD_CACHE_MAX_OPEN) - { - close_one(); - } - - BFD_ASSERT(bfd_open_file (abfd) != (FILE *)NULL) ; - fseek((FILE *)(abfd->iostream), abfd->where, false); - } - bfd_last_cache = abfd; - return (FILE *)(abfd->iostream); -} diff --git a/bfd/coff-a29k.c b/bfd/coff-a29k.c deleted file mode 100644 index 363be30ced0..00000000000 --- a/bfd/coff-a29k.c +++ /dev/null @@ -1,282 +0,0 @@ -/* AMD 29000 COFF back-end for BFD. - Copyright (C) 1990-1991 Free Software Foundation, Inc. - Contributed by David Wood at New York University 7/8/91. - -This file is part of BFD, the Binary File Descriptor library. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* $Id$ */ - -#define A29K 1 - -#include "bfd.h" -#include "sysdep.h" -#include "libbfd.h" -#include "obstack.h" -#include "coff-a29k.h" -#include "internalcoff.h" -#include "libcoff.h" - -#define INSERT_HWORD(WORD,HWORD) \ - (((WORD) & 0xff00ff00) | (((HWORD) & 0xff00) << 8) | ((HWORD)& 0xff)) -#define EXTRACT_HWORD(WORD) \ - (((WORD) & 0x00ff0000) >> 8) | ((WORD)& 0xff) -#define SIGN_EXTEND_HWORD(HWORD) \ - ((HWORD) & 0x8000 ? (HWORD)|0xffff0000 : (HWORD)) - -/* Provided the symbol, returns the value reffed */ -static long -get_symbol_value(symbol) -asymbol *symbol; -{ - long relocation = 0; - - if (symbol != (asymbol *)NULL) { - if (symbol->flags & BSF_FORT_COMM) { - relocation = 0; - } else { - relocation = symbol->value; - } - if (symbol->section != (asection *)NULL) { - relocation += symbol->section->output_section->vma + - symbol->section->output_offset; - } - } - return(relocation); -} - -/* this function is in charge of performing all the 29k relocations */ - -static bfd_reloc_status_type -DEFUN(a29k_reloc,(abfd, reloc_entry, symbol_in, data, input_section), - bfd *abfd AND - arelent *reloc_entry AND - asymbol *symbol_in AND - unsigned char *data AND - asection *input_section) -{ - /* the consth relocation comes in two parts, we have to remember - the state between calls, in these variables */ - static boolean part1_consth_active = false; - static unsigned long part1_consth_value; - - unsigned long insn; - unsigned long sym_value; - unsigned long unsigned_value; - unsigned short r_type; - long signed_value; - - - r_type = reloc_entry->howto->type; - - /* FIXME: Do we need to check for partial linking here */ - if (symbol_in && (symbol_in->flags & BSF_UNDEFINED)) - { - /* Keep the state machine happy in case we're called again */ - if (r_type == R_IHIHALF) - { - part1_consth_active = true; - part1_consth_value = 0; - } - return(bfd_reloc_undefined); - } - - if ((part1_consth_active) && (r_type != R_IHCONST)) - { - fprintf(stderr,"Relocation problem : "); - fprintf(stderr,"Missing IHCONST in module %s\n",abfd->filename); - part1_consth_active = false; - return(bfd_reloc_dangerous); - } - - insn = bfd_get_32(abfd, data + reloc_entry->address); - sym_value = get_symbol_value(symbol_in); - - switch (r_type) - { - case R_IREL: - /* Take the value in the field and sign extend it */ - signed_value = EXTRACT_HWORD(insn) << 2; - signed_value = SIGN_EXTEND_HWORD(signed_value); - signed_value += sym_value + reloc_entry->addend; - if ((signed_value&~0x3ffff) == 0) - { /* Absolute jmp/call */ - insn |= (1<<24); /* Make it absolute */ - /* FIXME: Should we change r_type to R_IABS */ - signed_value /= 2; - } - else - { - /* Relative jmp/call, so subtract from the value the - address of the place we're coming from */ - signed_value -= reloc_entry->address + - input_section->output_section->vma + - input_section->output_offset; - if (signed_value>0x1ffff || signed_value<-0x20000) - return(bfd_reloc_outofrange); - - signed_value /= 2; - } - insn = INSERT_HWORD(insn, signed_value); - break; - case R_ILOHALF: - unsigned_value = EXTRACT_HWORD(insn); - unsigned_value += sym_value + reloc_entry->addend; - insn = INSERT_HWORD(insn, unsigned_value); - break; - case R_IHIHALF: - /* consth, part 1 - Just get the symbol value that is referenced */ - part1_consth_active = true; - part1_consth_value = sym_value + reloc_entry->addend; - /* Don't modify insn until R_IHCONST */ - return(bfd_reloc_ok); - break; - case R_IHCONST: - /* consth, part 2 - Now relocate the reference */ - if (part1_consth_active == false) { - fprintf(stderr,"Relocation problem : "); - fprintf(stderr,"IHIHALF missing in module %s\n", - abfd->filename); - return(bfd_reloc_dangerous); - } - /* sym_ptr_ptr = r_symndx, in coff_slurp_reloc_table() */ - unsigned_value = 0; /*EXTRACT_HWORD(insn) << 16;*/ - unsigned_value += reloc_entry->addend; /* r_symndx */ - unsigned_value += part1_consth_value; - unsigned_value = unsigned_value >> 16; - insn = INSERT_HWORD(insn, unsigned_value); - part1_consth_active = false; - break; - case R_BYTE: - unsigned_value = (insn >> 24) + sym_value + reloc_entry->addend; - if (unsigned_value & 0xffffff00) { - fprintf(stderr,"Relocation problem : "); - fprintf(stderr,"byte value too large in module %s\n", - abfd->filename); - return(bfd_reloc_overflow); - } - insn = (insn & 0x00ffffff) | (unsigned_value << 24); - break; - case R_HWORD: - unsigned_value = (insn >> 16) + sym_value + reloc_entry->addend; - if (unsigned_value & 0xffff0000) { - fprintf(stderr,"Relocation problem : "); - fprintf(stderr,"hword value too large in module %s\n", - abfd->filename); - return(bfd_reloc_overflow); - } - insn = (insn & 0x0000ffff) | (unsigned_value<<16); - break; - case R_WORD: - insn += sym_value + reloc_entry->addend; - break; - default: - fprintf(stderr,"Relocation problem : "); - fprintf(stderr,"Unrecognized reloc type %d, in module %s\n", - r_type,abfd->filename); - return (bfd_reloc_dangerous); - } - - bfd_put_32(abfd, insn, data+reloc_entry->address); - return(bfd_reloc_ok); -} - -/* type rightshift - size - bitsize - pc-relative - bitpos - absolute - complain_on_overflow - special_function - relocation name - partial_inplace - src_mask -*/ - -/*FIXME: I'm not real sure about this table */ -#define NA 0 /* Obsolete fields, via the documentation */ -static reloc_howto_type howto_table[] = -{ - {R_ABS, 0, 3, NA, false, NA, NA, true,a29k_reloc,"ABS", true, 0xffffffff,0xffffffff, false}, - {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10}, - {11}, {12}, {13}, {14}, {15}, {16}, {17}, {18}, {19}, {20}, - {21}, {22}, {23}, - {R_IREL, 0, 3, NA, true, NA, NA, true,a29k_reloc,"IREL", true, 0xffffffff,0xffffffff, false}, - {R_IABS, 0, 3, NA, false, NA, NA, true,a29k_reloc,"IABS", true, 0xffffffff,0xffffffff, false}, - {R_ILOHALF, 0, 3, NA, true, NA, NA, true,a29k_reloc,"ILOHALF", true, 0x0000ffff,0x0000ffff, false}, - {R_IHIHALF, 0, 3, NA, true, NA, NA, true,a29k_reloc,"IHIHALF", true, 0xffff0000,0xffff0000, false}, - {R_IHCONST, 0, 3, NA, true, NA, NA, true,a29k_reloc,"IHCONST", true, 0xffff0000,0xffff0000, false}, - {R_BYTE, 0, 0, NA, false, NA, NA, true,a29k_reloc,"BYTE", true, 0x000000ff,0x000000ff, false}, - {R_HWORD, 0, 1, NA, false, NA, NA, true,a29k_reloc,"HWORD", true, 0x0000ffff,0x0000ffff, false}, - {R_WORD, 0, 2, NA, false, NA, NA, true,a29k_reloc,"WORD", true, 0xffffffff,0xffffffff, false}, -}; -#undef NA - -#define BADMAG(x) A29KBADMAG(x) - -#include "coffcode.h" - -bfd_target a29kcoff_big_vec = -{ - "coff-a29k-big", /* name */ - bfd_target_coff_flavour, - true, /* data byte order is big */ - true, /* header byte order is big */ - - (HAS_RELOC | EXEC_P | /* object flags */ - HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT), - - (SEC_HAS_CONTENTS | SEC_ALLOC /* section flags */ - | SEC_LOAD | SEC_RELOC - | SEC_READONLY ), - '/', /* ar_pad_char */ - 15, /* ar_max_namelen */ - 2, /* minimum section alignment */ - /* data */ - _do_getb64, _do_putb64, _do_getb32, - _do_putb32, _do_getb16, _do_putb16, - /* hdrs */ - _do_getb64, _do_putb64, _do_getb32, - _do_putb32, _do_getb16, _do_putb16, - - { - - _bfd_dummy_target, - coff_object_p, - bfd_generic_archive_p, - _bfd_dummy_target - }, - { - bfd_false, - coff_mkobject, - _bfd_generic_mkarchive, - bfd_false - }, - { - bfd_false, - coff_write_object_contents, - _bfd_write_archive_contents, - bfd_false - }, - - JUMP_TABLE(coff), - COFF_SWAP_TABLE - }; - diff --git a/bfd/coff-code.h b/bfd/coff-code.h deleted file mode 100755 index 90402365263..00000000000 --- a/bfd/coff-code.h +++ /dev/null @@ -1,2608 +0,0 @@ -/* Support for Intel 960 COFF and Motorola 88k BCS COFF (and maybe others) */ - -/* Copyright (C) 1990, 1991 Free Software Foundation, Inc. - -This file is part of BFD, the Binary File Diddler. - -BFD 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 1, or (at your option) any later version. - -BFD 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 - BFD; see the file COPYING. If not, write to the Free Software Foundation, - 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -/* $Id$ */ -/* Most of this hacked by Steve Chamberlain, steve@cygnus.com */ - -#include "archures.h" /* Machine architectures and types */ - -/* SUPPRESS 558 */ -/* SUPPRESS 590 */ -/* SUPPRESS 529 */ -/* SUPPRESS 530 */ - -/* Align an address upward to a boundary, expressed as a number of bytes. - E.g. align to an 8-byte boundary with argument of 8. */ -#define ALIGN(this, boundary) \ - ((( (this) + ((boundary) -1)) & (~((boundary)-1)))) - -/* Align an address upward to a power of two. Argument is the power - of two, e.g. 8-byte alignment uses argument of 3 (8 == 2^3). */ -#define i960_align(addr, align) \ - ( ((addr) + ((1<<(align))-1)) & (-1 << (align))) - -#define sp(x) bfd_h_put_x(abfd, x, &x) - -#ifndef I960 -#define GDB_EXPORT static -#else -#define GDB_EXPORT /* nothing */ -#endif - -PROTO(static void,force_indices_file_symbol_relative,(bfd *abfd, - struct internal_syment *symtab)); - - -/* void warning(); */ -extern asection abs_section; - -static int -DEFUN(get_index,(symbol), - asymbol *symbol) -{ - return (int) symbol->value; -} - -static void -DEFUN(set_index,(symbol, idx), - asymbol *symbol AND - unsigned int idx) -{ - symbol->value = idx; -} - - - - - -/* All the swapping routines: -*/ - - -GDB_EXPORT -void -DEFUN(bfd_swap_reloc_in,(abfd, reloc_src, reloc_dst), - bfd *abfd AND - RELOC *reloc_src AND - struct internal_reloc *reloc_dst) -{ - reloc_dst->r_vaddr = bfd_h_getlong(abfd, reloc_src->r_vaddr); - reloc_dst->r_symndx = bfd_h_getlong(abfd, reloc_src->r_symndx); - reloc_dst->r_type = bfd_h_getshort(abfd, reloc_src->r_type); -#if M88 - reloc_dst->r_offset = bfd_h_getshort(abfd, reloc_src->r_offset); -#endif -} - -GDB_EXPORT - void -DEFUN(bfd_swap_reloc_out,(abfd, reloc_src, reloc_dst), - bfd *abfd AND - struct internal_reloc *reloc_src AND - struct external_reloc *reloc_dst) -{ - bfd_h_putlong(abfd, reloc_src->r_vaddr, reloc_dst->r_vaddr); - bfd_h_putlong(abfd, reloc_src->r_symndx, reloc_dst->r_symndx); - bfd_h_putshort(abfd, reloc_src->r_type, reloc_dst->r_type); -#if M88 - bfd_h_putshort(abfd, reloc_src->r_offset, reloc_dst->r_offset); -#endif - -} - -GDB_EXPORT void -DEFUN(bfd_swap_filehdr_in,(abfd, filehdr_src, filehdr_dst), - bfd *abfd AND - FILHDR *filehdr_src AND - struct internal_filehdr *filehdr_dst) -{ - filehdr_dst->f_magic = bfd_h_get_x(abfd, filehdr_src->f_magic); - filehdr_dst->f_nscns = bfd_h_get_x(abfd,filehdr_src-> f_nscns); - filehdr_dst->f_timdat = bfd_h_get_x(abfd,filehdr_src-> f_timdat); - filehdr_dst->f_symptr = bfd_h_get_x(abfd,filehdr_src-> f_symptr); - filehdr_dst->f_nsyms = bfd_h_get_x(abfd,filehdr_src-> f_nsyms); - filehdr_dst->f_opthdr = bfd_h_get_x(abfd,filehdr_src-> f_opthdr); - filehdr_dst->f_flags = bfd_h_get_x(abfd,filehdr_src-> f_flags); -} - -GDB_EXPORT void -DEFUN(bfd_swap_filehdr_out,(abfd, filehdr_in, filehdr_out), - bfd *abfd AND - struct internal_filehdr *filehdr_in AND - FILHDR *filehdr_out) -{ - bfd_h_put_x(abfd, filehdr_in->f_magic, filehdr_out->f_magic); - bfd_h_put_x(abfd, filehdr_in->f_nscns, filehdr_out->f_nscns); - bfd_h_put_x(abfd, filehdr_in->f_timdat, filehdr_out->f_timdat); - bfd_h_put_x(abfd, filehdr_in->f_symptr, filehdr_out->f_symptr); - bfd_h_put_x(abfd, filehdr_in->f_nsyms, filehdr_out->f_nsyms); - bfd_h_put_x(abfd, filehdr_in->f_opthdr, filehdr_out->f_opthdr); - bfd_h_put_x(abfd, filehdr_in->f_flags, filehdr_out->f_flags); -} - - -GDB_EXPORT -void -DEFUN(bfd_coff_swap_sym_in,(abfd, ext, in), - bfd *abfd AND - SYMENT *ext AND - struct internal_syment *in) -{ - if( ext->e.e_name[0] == 0) { - in->_n._n_n._n_zeroes = 0; - in->_n._n_n._n_offset = bfd_h_getlong(abfd, ext->e.e.e_offset); - } - else { - memcpy(in->_n._n_name, ext->e.e_name, SYMNMLEN); - } - in->n_value = bfd_h_get_x(abfd, ext->e_value); - in->n_scnum = bfd_h_get_x(abfd, ext->e_scnum); - in->n_type = bfd_h_get_x(abfd, ext->e_type); - in->n_sclass = bfd_h_get_x(abfd, ext->e_sclass); - in->n_numaux = bfd_h_get_x(abfd, ext->e_numaux); -} - -GDB_EXPORT void -DEFUN(bfd_coff_swap_sym_out,(abfd,in, ext), - bfd *abfd AND - struct internal_syment *in AND - SYMENT *ext) -{ - if(in->_n._n_name[0] == 0) { - bfd_h_putlong(abfd, 0, ext->e.e.e_zeroes); - bfd_h_putlong(abfd, in->_n._n_n._n_offset, ext->e.e.e_offset); - } - else { - memcpy(ext->e.e_name, in->_n._n_name, SYMNMLEN); - } - bfd_h_put_x(abfd, in->n_value , ext->e_value); - bfd_h_put_x(abfd, in->n_scnum , ext->e_scnum); - bfd_h_put_x(abfd, in->n_type , ext->e_type); - bfd_h_put_x(abfd, in->n_sclass , ext->e_sclass); - bfd_h_put_x(abfd, in->n_numaux , ext->e_numaux); -} - -GDB_EXPORT void -DEFUN(bfd_coff_swap_aux_in,(abfd, ext, type, class, in), - bfd *abfd AND - AUXENT *ext AND - int type AND - int class AND - union internal_auxent *in) -{ - switch (class) { - case C_FILE: - if (ext->x_file.x_fname[0] == 0) { - in->x_file.x_n.x_zeroes = 0; - in->x_file.x_n.x_offset = bfd_h_getlong(abfd, ext->x_file.x_n.x_offset); - } - - break; - case C_STAT: -#ifdef C_LEAFSTAT - case C_LEAFSTAT: -#endif - case C_HIDDEN: - if (type == T_NULL) { - in->x_scn.x_scnlen = bfd_h_get_x(abfd, ext->x_scn.x_scnlen); - in->x_scn.x_nreloc = bfd_h_get_x(abfd, ext->x_scn.x_nreloc); - in->x_scn.x_nlinno = bfd_h_get_x(abfd, ext->x_scn.x_nlinno); - break; - } - default: - in->x_sym.x_tagndx = bfd_h_get_x(abfd, ext->x_sym.x_tagndx); - in->x_sym.x_tvndx = bfd_h_get_x(abfd, ext->x_sym.x_tvndx); - - if (ISARY(type) || class == C_BLOCK) { - in->x_sym.x_fcnary.x_ary.x_dimen[0] = bfd_h_get_x(abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[0]); - in->x_sym.x_fcnary.x_ary.x_dimen[1] = bfd_h_get_x(abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[1]); - in->x_sym.x_fcnary.x_ary.x_dimen[2] = bfd_h_get_x(abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[2]); - in->x_sym.x_fcnary.x_ary.x_dimen[3] = bfd_h_get_x(abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[3]); - } - else { - in->x_sym.x_fcnary.x_fcn.x_lnnoptr = bfd_h_get_x(abfd, ext->x_sym.x_fcnary.x_fcn.x_lnnoptr); - in->x_sym.x_fcnary.x_fcn.x_endndx = bfd_h_get_x(abfd, ext->x_sym.x_fcnary.x_fcn.x_endndx); - } - if (ISFCN(type)) { - in->x_sym.x_misc.x_fsize = bfd_h_get_x(abfd, ext->x_sym.x_misc.x_fsize); - } - else { - in->x_sym.x_misc.x_lnsz.x_lnno = bfd_h_get_x(abfd, ext->x_sym.x_misc.x_lnsz.x_lnno); - in->x_sym.x_misc.x_lnsz.x_size = bfd_h_get_x(abfd, ext->x_sym.x_misc.x_lnsz.x_size); - } - } -} - -GDB_EXPORT void -DEFUN(bfd_coff_swap_aux_out,(abfd, in, type, class, ext), - bfd *abfd AND - union internal_auxent *in AND - int type AND - int class AND - AUXENT *ext) -{ - switch (class) { - case C_FILE: - if (in->x_file.x_fname[0] == 0) { - bfd_h_put_x(abfd, 0, ext->x_file.x_n.x_zeroes ); - bfd_h_put_x(abfd, in->x_file.x_n.x_offset, ext->x_file.x_n.x_offset); - } - - break; - case C_STAT: -#ifdef C_LEAFSTAT - case C_LEAFSTAT: -#endif - case C_HIDDEN: - if (type == T_NULL) { - bfd_h_put_x(abfd, in->x_scn.x_scnlen, ext->x_scn.x_scnlen); - bfd_h_put_x(abfd, in->x_scn.x_nreloc, ext->x_scn.x_nreloc); - bfd_h_put_x(abfd, in->x_scn.x_nlinno, ext->x_scn.x_nlinno); - break; - } - default: - bfd_h_put_x(abfd, in->x_sym.x_tagndx, ext->x_sym.x_tagndx); - bfd_h_put_x(abfd, in->x_sym.x_tvndx , ext->x_sym.x_tvndx); - - if (ISARY(type) || class == C_BLOCK) { - bfd_h_put_x(abfd, in->x_sym.x_fcnary.x_ary.x_dimen[0],ext->x_sym.x_fcnary.x_ary.x_dimen[0]); - bfd_h_put_x(abfd, in->x_sym.x_fcnary.x_ary.x_dimen[1],ext->x_sym.x_fcnary.x_ary.x_dimen[1]); - bfd_h_put_x(abfd, in->x_sym.x_fcnary.x_ary.x_dimen[2],ext->x_sym.x_fcnary.x_ary.x_dimen[2]); - bfd_h_put_x(abfd, in->x_sym.x_fcnary.x_ary.x_dimen[3],ext->x_sym.x_fcnary.x_ary.x_dimen[3]); - } - else { - bfd_h_put_x(abfd, in->x_sym.x_fcnary.x_fcn.x_lnnoptr, ext->x_sym.x_fcnary.x_fcn.x_lnnoptr); - bfd_h_put_x(abfd, in->x_sym.x_fcnary.x_fcn.x_endndx, ext->x_sym.x_fcnary.x_fcn.x_endndx); - } - if (ISFCN(type)) { - bfd_h_put_x(abfd, in->x_sym.x_misc.x_fsize, ext->x_sym.x_misc.x_fsize); - } - else { - bfd_h_put_x(abfd, in->x_sym.x_misc.x_lnsz.x_lnno, ext->x_sym.x_misc.x_lnsz.x_lnno); - bfd_h_put_x(abfd, in->x_sym.x_misc.x_lnsz.x_size, ext->x_sym.x_misc.x_lnsz.x_size); - } - } -} - -GDB_EXPORT void -DEFUN(bfd_coff_swap_lineno_in,(abfd, ext, in), - bfd *abfd AND - LINENO *ext AND - struct internal_lineno *in) -{ - in->l_addr.l_symndx = bfd_h_get_x(abfd, ext->l_addr.l_symndx); - in->l_lnno = bfd_h_get_x(abfd, ext->l_lnno); -} - -GDB_EXPORT void -DEFUN(bfd_coff_swap_lineno_out,(abfd, in, ext), - bfd *abfd AND - struct internal_lineno *in AND - struct external_lineno *ext) -{ - bfd_h_put_x(abfd, in->l_addr.l_symndx, ext->l_addr.l_symndx); - bfd_h_put_x(abfd, in->l_lnno, ext->l_lnno); -} - - - - -GDB_EXPORT void -DEFUN(bfd_swap_aouthdr_in,(abfd, aouthdr_ext, aouthdr_int), - bfd *abfd AND - AOUTHDR *aouthdr_ext AND - struct internal_aouthdr *aouthdr_int) -{ - aouthdr_int->magic = bfd_h_get_x(abfd, aouthdr_ext->magic); - aouthdr_int->vstamp = bfd_h_get_x(abfd, aouthdr_ext->vstamp); - aouthdr_int->tsize = bfd_h_get_x(abfd, aouthdr_ext->tsize); - aouthdr_int->dsize = bfd_h_get_x(abfd, aouthdr_ext->dsize); - aouthdr_int->bsize = bfd_h_get_x(abfd, aouthdr_ext->bsize); - aouthdr_int->entry = bfd_h_get_x(abfd, aouthdr_ext->entry); - aouthdr_int->text_start = bfd_h_get_x(abfd, aouthdr_ext->text_start); - aouthdr_int->data_start = bfd_h_get_x(abfd, aouthdr_ext->data_start); -#ifdef I960 - aouthdr_int->tagentries = bfd_h_get_x(abfd, aouthdr_ext->tagentries); -#endif -} - -GDB_EXPORT void -DEFUN(bfd_swap_aouthdr_out,(abfd, aouthdr_in, aouthdr_out), - bfd *abfd AND - struct internal_aouthdr *aouthdr_in AND - AOUTHDR *aouthdr_out) -{ - bfd_h_put_x(abfd, aouthdr_in->magic, aouthdr_out->magic); - bfd_h_put_x(abfd, aouthdr_in->vstamp, aouthdr_out->vstamp); - bfd_h_put_x(abfd, aouthdr_in->tsize, aouthdr_out->tsize); - bfd_h_put_x(abfd, aouthdr_in->dsize, aouthdr_out->dsize); - bfd_h_put_x(abfd, aouthdr_in->bsize, aouthdr_out->bsize); - bfd_h_put_x(abfd, aouthdr_in->entry, aouthdr_out->entry); - bfd_h_put_x(abfd, aouthdr_in->text_start, aouthdr_out->text_start); - bfd_h_put_x(abfd, aouthdr_in->data_start, aouthdr_out->data_start); -#ifdef I960 - bfd_h_put_x(abfd, aouthdr_in->tagentries, aouthdr_out->tagentries); -#endif -} - -GDB_EXPORT void -DEFUN(bfd_coff_swap_scnhdr_in,(abfd, scnhdr_ext, scnhdr_int), - bfd *abfd AND - SCNHDR *scnhdr_ext AND - struct internal_scnhdr *scnhdr_int) -{ - memcpy(scnhdr_int->s_name, scnhdr_ext->s_name, sizeof(scnhdr_int->s_name)); - scnhdr_int->s_vaddr = bfd_h_get_x(abfd, scnhdr_ext->s_vaddr); - scnhdr_int->s_paddr = bfd_h_get_x(abfd, scnhdr_ext->s_paddr); - scnhdr_int->s_size = bfd_h_get_x(abfd, scnhdr_ext->s_size); - scnhdr_int->s_scnptr = bfd_h_get_x(abfd, scnhdr_ext->s_scnptr); - scnhdr_int->s_relptr = bfd_h_get_x(abfd, scnhdr_ext->s_relptr); - scnhdr_int->s_lnnoptr = bfd_h_get_x(abfd, scnhdr_ext->s_lnnoptr); - scnhdr_int->s_nreloc = bfd_h_get_x(abfd, scnhdr_ext->s_nreloc); - scnhdr_int->s_nlnno = bfd_h_get_x(abfd, scnhdr_ext->s_nlnno); - scnhdr_int->s_flags = bfd_h_get_x(abfd, scnhdr_ext->s_flags); -#ifdef I960 - scnhdr_int->s_align = bfd_h_get_x(abfd, scnhdr_ext->s_align); -#endif -} - -static void -DEFUN(swap_scnhdr_out,(abfd, scnhdr_int, scnhdr_ext), - bfd *abfd AND - struct internal_scnhdr *scnhdr_int AND - SCNHDR *scnhdr_ext) -{ - memcpy(scnhdr_ext->s_name, scnhdr_int->s_name, sizeof(scnhdr_int->s_name)); - bfd_h_put_x(abfd, scnhdr_int->s_vaddr, scnhdr_ext->s_vaddr); - bfd_h_put_x(abfd, scnhdr_int->s_paddr, scnhdr_ext->s_paddr); - bfd_h_put_x(abfd, scnhdr_int->s_size, scnhdr_ext->s_size); - bfd_h_put_x(abfd, scnhdr_int->s_scnptr, scnhdr_ext->s_scnptr); - bfd_h_put_x(abfd, scnhdr_int->s_relptr, scnhdr_ext->s_relptr); - bfd_h_put_x(abfd, scnhdr_int->s_lnnoptr, scnhdr_ext->s_lnnoptr); - bfd_h_put_x(abfd, scnhdr_int->s_nreloc, scnhdr_ext->s_nreloc); - bfd_h_put_x(abfd, scnhdr_int->s_nlnno, scnhdr_ext->s_nlnno); - bfd_h_put_x(abfd, scnhdr_int->s_flags, scnhdr_ext->s_flags); -#ifdef I960 - bfd_h_put_x(abfd, scnhdr_int->s_align, scnhdr_ext->s_align); -#endif -} - -/* - initialize a section structure with information peculiar to this - particular implementation of coff -*/ - -static boolean -DEFUN(coff_new_section_hook,(abfd_ignore, section_ignore), - bfd *abfd_ignore AND - asection *section_ignore) -{ -#ifdef MC88MAGIC - /* FIXME, shouldn't this ifdef be on something that says we are - actually COMPILING FOR an 88K coff file, rather than simply - knowing its magic number? */ - /* Align to at least 16 bytes */ - section_ignore->alignment_power = 4; -#endif -#if M68 - section_ignore->alignment_power = 3; -#endif - return true; -} - -/* Take a section header read from a coff file (in HOST byte order), - and make a BFD "section" out of it. */ -static boolean -DEFUN(make_a_section_from_file,(abfd, hdr), - bfd *abfd AND - struct internal_scnhdr *hdr) -{ - asection *return_section; - - { - /* Assorted wastage to null-terminate the name, thanks AT&T! */ - char *name = bfd_alloc(abfd, sizeof (hdr->s_name)+1); - if (name == NULL) { - bfd_error = no_memory; - return false; - } - strncpy(name, (char *) &hdr->s_name[0], sizeof (hdr->s_name)); - name[sizeof (hdr->s_name)] = 0; - - return_section = bfd_make_section(abfd, name); - } - - /* s_paddr is presumed to be = to s_vaddr */ -#define assign(to, from) return_section->to = hdr->from - assign(vma, s_vaddr); - /* assign (vma, s_vaddr); */ - assign(size, s_size); - assign(filepos, s_scnptr); - assign(rel_filepos, s_relptr); - assign(reloc_count, s_nreloc); -#ifdef I960 - { - /* FIXME, use a temp var rather than alignment_power */ - assign(alignment_power, s_align); - { - unsigned int i; - for (i = 0; i < 32; i++) { - if ((1 << i) >= (int) (return_section->alignment_power)) { - return_section->alignment_power = i; - break; - } - } - } - } -#endif - assign(line_filepos, s_lnnoptr); - /* - return_section->linesize = hdr->s_nlnno * sizeof (struct lineno); - */ - -#undef assign - return_section->lineno_count = hdr->s_nlnno; - return_section->userdata = NULL; - return_section->next = (asection *) NULL; - return_section->flags = 0; - if ((hdr->s_flags & STYP_TEXT) || (hdr->s_flags & STYP_DATA)) - return_section->flags = (SEC_LOAD | SEC_ALLOC); - else if (hdr->s_flags & STYP_BSS) - return_section->flags = SEC_ALLOC; - - if (hdr->s_nreloc != 0) - return_section->flags |= SEC_RELOC; - if (hdr->s_scnptr != 0) - return_section->flags |= SEC_HAS_CONTENTS; - return true; -} -static boolean -DEFUN(coff_mkobject,(abfd), - bfd *abfd) -{ - set_tdata (abfd, bfd_zalloc (abfd,sizeof(coff_data_type))); - if (coff_data(abfd) == 0) { - bfd_error = no_memory; - return false; - } - coff_data(abfd)->relocbase = 0; - return true; -} - -static -bfd_target * -DEFUN(coff_real_object_p,(abfd, nscns, internal_f, internal_a), - bfd *abfd AND - unsigned nscns AND - struct internal_filehdr *internal_f AND - struct internal_aouthdr *internal_a) -{ - coff_data_type *coff; - - size_t readsize; /* length of file_info */ - SCNHDR *external_sections; - - /* Build a play area */ - if (coff_mkobject(abfd) != true) - return 0; - coff = coff_data(abfd); - - - external_sections = (SCNHDR *)bfd_alloc(abfd, readsize = (nscns * SCNHSZ)); - if (bfd_read((PTR)external_sections, 1, readsize, abfd) != readsize) { - goto fail; - } - - - - /* Now copy data as required; construct all asections etc */ - coff->symbol_index_slew = 0; - coff->relocbase =0; - coff->raw_syment_count = 0; - coff->raw_linenos = 0; - coff->raw_syments = 0; - coff->sym_filepos =0; - coff->flags = internal_f->f_flags; - if (nscns != 0) { - unsigned int i; - for (i = 0; i < nscns; i++) { - struct internal_scnhdr tmp; - bfd_coff_swap_scnhdr_in(abfd, external_sections + i, &tmp); - make_a_section_from_file(abfd,&tmp); - } - } - /* Determine the machine architecture and type. */ - abfd->obj_machine = 0; - switch (internal_f->f_magic) { -#ifdef MIPS -case MIPS_MAGIC_1: -case MIPS_MAGIC_2: -case MIPS_MAGIC_3: - abfd->obj_arch = bfd_arch_mips; - abfd->obj_machine = 0; - break; -#endif - -#ifdef MC68MAGIC - case MC68MAGIC: - case M68MAGIC: - abfd->obj_arch = bfd_arch_m68k; - abfd->obj_machine = 68020; - break; -#endif -#ifdef MC88MAGIC - case MC88MAGIC: - case MC88DMAGIC: - case MC88OMAGIC: - abfd->obj_arch = bfd_arch_m88k; - abfd->obj_machine = 88100; - break; -#endif -#ifdef I960 -#ifdef I960ROMAGIC - case I960ROMAGIC: - case I960RWMAGIC: - abfd->obj_arch = bfd_arch_i960; - switch (F_I960TYPE & internal_f->f_flags) - { - default: - case F_I960CORE: - abfd->obj_machine = bfd_mach_i960_core; - break; - case F_I960KB: - abfd->obj_machine = bfd_mach_i960_kb_sb; - break; - case F_I960MC: - abfd->obj_machine = bfd_mach_i960_mc; - break; - case F_I960XA: - abfd->obj_machine = bfd_mach_i960_xa; - break; - case F_I960CA: - abfd->obj_machine = bfd_mach_i960_ca; - break; - case F_I960KA: - abfd->obj_machine = bfd_mach_i960_ka_sa; - break; - - } - break; -#endif -#endif - - default: /* Unreadable input file type */ - abfd->obj_arch = bfd_arch_obscure; - break; - } - - if (!(internal_f->f_flags & F_RELFLG)) - abfd->flags |= HAS_RELOC; - if ((internal_f->f_flags & F_EXEC)) - abfd->flags |= EXEC_P; - if (!(internal_f->f_flags & F_LNNO)) - abfd->flags |= HAS_LINENO; - if (!(internal_f->f_flags & F_LSYMS)) - abfd->flags |= HAS_LOCALS; - - - bfd_get_symcount(abfd) = internal_f->f_nsyms; - if (internal_f->f_nsyms) - abfd->flags |= HAS_SYMS; - - coff->sym_filepos = internal_f->f_symptr; - - - - coff->symbols = (coff_symbol_type *) NULL; - bfd_get_start_address(abfd) = internal_f->f_opthdr ? internal_a->entry : 0; - - return abfd->xvec; - fail: - bfd_release(abfd, coff); - return (bfd_target *)NULL; -} - -static bfd_target * -DEFUN(coff_object_p,(abfd), - bfd *abfd) - { - int nscns; - FILHDR filehdr; - AOUTHDR opthdr; - struct internal_filehdr internal_f; - struct internal_aouthdr internal_a; - - bfd_error = system_call_error; - - /* figure out how much to read */ - if (bfd_read((PTR) &filehdr, 1, FILHSZ, abfd) != FILHSZ) - return 0; - - bfd_swap_filehdr_in(abfd, &filehdr, &internal_f); - - if (BADMAG(internal_f)) { - bfd_error = wrong_format; - return 0; - } - nscns =internal_f.f_nscns; - - if (internal_f.f_opthdr) { - if (bfd_read((PTR) &opthdr, 1,AOUTSZ, abfd) != AOUTSZ) { - return 0; - } - bfd_swap_aouthdr_in(abfd, &opthdr, &internal_a); - } - - /* Seek past the opt hdr stuff */ - bfd_seek(abfd, internal_f.f_opthdr + FILHSZ, SEEK_SET); - - /* if the optional header is NULL or not the correct size then - quit; the only difference I can see between m88k dgux headers (MC88DMAGIC) - and Intel 960 readwrite headers (I960WRMAGIC) is that the - optional header is of a different size. - - But the mips keeps extra stuff in it's opthdr, so dont check - when doing that - */ - -#ifndef MIPS - if (internal_f.f_opthdr != 0 && AOUTSZ != internal_f.f_opthdr) - return (bfd_target *)NULL; -#endif - - return coff_real_object_p(abfd, nscns, &internal_f, &internal_a); - } - - - - -/* -Takes a bfd and a symbol, returns a pointer to the coff specific area -of the symbol if there is one. -*/ -static coff_symbol_type * -DEFUN(coff_symbol_from,(abfd, symbol), - bfd *abfd AND - asymbol *symbol) -{ - if (symbol->the_bfd->xvec->flavour != bfd_target_coff_flavour_enum) - return (coff_symbol_type *)NULL; - - if (symbol->the_bfd->tdata == (PTR)NULL) - return (coff_symbol_type *)NULL; - - return (coff_symbol_type *) symbol; -} - - - - - - - -static void -DEFUN(coff_count_linenumbers,(abfd), - bfd *abfd) -{ - unsigned int limit = bfd_get_symcount(abfd); - unsigned int i; - asymbol **p; - { - asection *s = abfd->sections->output_section; - while (s) { - BFD_ASSERT(s->lineno_count == 0); - s = s->next; - } - } - - - for (p = abfd->outsymbols, i = 0; i < limit; i++, p++) { - asymbol *q_maybe = *p; - if (q_maybe->the_bfd->xvec->flavour == bfd_target_coff_flavour_enum) { - coff_symbol_type *q = coffsymbol(q_maybe); - if (q->lineno) { - /* - This symbol has a linenumber, increment the owning - section's linenumber count - */ - alent *l = q->lineno; - q->symbol.section->output_section->lineno_count++; - l++; - while (l->line_number) { - q->symbol.section->output_section->lineno_count++; - l++; - } - } - } - } -} - -/* - This function returns true if the supplied SYMENT has an AUXENT with - a tagndx field which should be relocated. - - The coff book says that all auxents have this and should be moved, - but all the actual implementations I've looked at do this .. - (sac@cygnus.com) - -*/ -static boolean -DEFUN(uses_x_sym_x_tagndx_p,(abfd, native), - bfd *abfd AND - struct internal_syment *native) -{ - if (BTYPE(native->n_type) == T_STRUCT) return true; - if (BTYPE(native->n_type) == T_UNION) return true; - if (BTYPE(native->n_type) == T_ENUM) return true; - return false; -} - - -/* -This procedure runs through the native entries in a coff symbol table -and links up all the elements which should point to one another, in -particular these are: - -strtag, entag and untags have an auxent endindex which points to the -first syment after the .eos. This is simple to do, we just keep a -pointer to the symbol with the most recent pending strtag and patch it -when we see the eos. This works since coff structs are never nested. - -ISFCN type entries have an endindex which points to the next static or -extern in the table, thereby skipping the function contents. -The coff book says that an ISFCN's tagindex -points to the first .bf for the function, so far I havn't seen it -used. We do this using the same mechanism as strtags. - -Each file entry has a value which points to the next file entry, -the last file entry points to the first extern symbol in the table -which is not an ISFCN. - -Each .bb entry points to the matching .eb entry, but these are nested -so we keep a stack of them. - -The tagndx of .eos items points to the strtag attached to them, this -is simply the last_tagndx again. - -The tagndx of items with type strtag point to the defining struct. -This bit is complicated; We know that a struct ref and def must be -within the same file, so all the natives will be in the same vector. -This means that we can subtracts two pointers and get the index -differences between to items, used to work out the true index of the -target. - -We store in the name field of each syment the actual native index -applied so we can dig it out through a pointer. */ - -static void -DEFUN(coff_mangle_symbols,(bfd_ptr), - bfd *bfd_ptr) -{ - unsigned int symbol_count = bfd_get_symcount(bfd_ptr); - asymbol **symbol_ptr_ptr = bfd_ptr->outsymbols; - struct internal_syment *last_tagndx = (struct internal_syment *)NULL; - struct internal_syment *last_file = (struct internal_syment *)NULL; - struct internal_syment *last_fcn = (struct internal_syment *)NULL; - struct internal_syment *block_stack[50]; - struct internal_syment **last_block = &block_stack[0]; - boolean first_time = true; - unsigned int symbol_index; - unsigned int native_index = 0; - - for (symbol_index = 0; symbol_index < symbol_count; symbol_index++) { - coff_symbol_type *coff_symbol_ptr = - coff_symbol_from(bfd_ptr, symbol_ptr_ptr[symbol_index]); - if (coff_symbol_ptr == (coff_symbol_type *)NULL) { - /* - This symbol has no coff information in it, it will take up - only one slot in the output symbol table - */ - native_index++; - } - else { - struct internal_syment *syment = coff_symbol_ptr->native; - if (syment == (struct internal_syment *)NULL) { - native_index++; - } - else { - /* Normalize the symbol flags */ - if (coff_symbol_ptr->symbol.flags & BSF_FORT_COMM) { - /* a common symbol is undefined with a value */ - syment->n_scnum = N_UNDEF; - syment->n_value = coff_symbol_ptr->symbol.value; - } - else if (coff_symbol_ptr->symbol.flags & BSF_DEBUGGING) { - syment->n_value = coff_symbol_ptr->symbol.value; - } - else if (coff_symbol_ptr->symbol.flags & BSF_UNDEFINED) { - syment->n_scnum = N_UNDEF; - syment->n_value = 0; - } - else if (coff_symbol_ptr->symbol.flags & BSF_ABSOLUTE) { - syment->n_scnum = N_ABS; - syment->n_value = coff_symbol_ptr->symbol.value; - } - else { - syment->n_scnum = - coff_symbol_ptr->symbol.section->output_section->index+1; - - syment->n_value = - coff_symbol_ptr->symbol.value + - coff_symbol_ptr->symbol.section->output_offset + - coff_symbol_ptr->symbol.section->output_section->vma; - } - - - /* If this symbol ties up something then do it */ - - if (syment->n_sclass == C_FILE && last_file != (struct internal_syment *)NULL) - { - last_file->n_value = native_index; - } - else if ((syment->n_sclass == C_EXT - || syment->n_sclass == C_STAT -#ifdef C_LEAFEXT - || syment->n_sclass == C_LEAFEXT - || syment->n_sclass == C_LEAFSTAT -#endif - ) - && last_fcn != (struct internal_syment *)NULL) - { - union internal_auxent *auxent = (union internal_auxent *)(last_fcn+1); - auxent->x_sym.x_fcnary.x_fcn.x_endndx = native_index; - last_fcn = (struct internal_syment *)NULL; - - } - else if (syment->n_sclass == C_EOS && last_tagndx != (struct internal_syment*)NULL) - { - union internal_auxent *auxent = (union internal_auxent *)(last_tagndx+1); - /* Remember that we keep the native index in the offset - so patch the beginning of the struct to point to this - */ - auxent->x_sym.x_tagndx = last_tagndx->_n._n_n._n_offset; - auxent->x_sym.x_fcnary.x_fcn.x_endndx = syment->n_numaux + 1 + native_index; - /* Now point the eos to the structure */ - auxent = (union internal_auxent *)(syment+1); - auxent->x_sym.x_tagndx = last_tagndx->_n._n_n._n_offset; - } - else if (syment->n_sclass == C_BLOCK - && coff_symbol_ptr->symbol.name[1] == 'e') - { - union internal_auxent *auxent = (union internal_auxent *)((*(--last_block))+1); - auxent->x_sym.x_fcnary.x_fcn.x_endndx = native_index + syment->n_numaux + 1; - } - if (syment->n_sclass == C_EXT - && !ISFCN(syment->n_type) - && first_time == true - && last_file != (struct internal_syment *)NULL) { - /* This is the first external symbol seen which isn't a - function place it in the last .file entry */ - last_file->n_value = native_index; - first_time = false; - } -#ifdef C_LEAFPROC - if (syment->n_sclass == C_LEAFPROC && - syment->n_numaux == 2) { - union internal_auxent *auxent = (union internal_auxent *)(syment+2); - /* This is the definition of a leaf proc, we'll relocate the - address */ - auxent->x_bal.x_balntry = - coff_symbol_ptr->symbol.section->output_offset + - coff_symbol_ptr->symbol.section->output_section->vma + - auxent->x_bal.x_balntry ; - } -#endif - /* If this symbol needs to be tied up then remember some facts */ - if (syment->n_sclass == C_FILE) - { - last_file = syment; - } - if (syment->n_numaux != 0) { - /* - If this symbol would like to point to something in the - future then remember where it is - */ - if (uses_x_sym_x_tagndx_p(bfd_ptr, syment)) { - /* - If this is a ref to a structure then we'll tie it up - now - there are never any forward refs for one - */ - if (syment->n_sclass == C_STRTAG || - syment->n_sclass == C_ENTAG || - syment->n_sclass == C_UNTAG) { - last_tagndx = syment; - } - else { - /* - This is a ref to a structure - the structure must - have been defined within the same file, and previous - to this point, so we can deduce the new tagndx - directly. - */ - union internal_auxent *auxent = (union internal_auxent *)(syment+1); - bfd *bfd_ptr = coff_symbol_ptr->symbol.the_bfd; - struct internal_syment *base = obj_raw_syments(bfd_ptr); - auxent->x_sym.x_tagndx = base[auxent->x_sym.x_tagndx]._n._n_n._n_offset; - - - } - } - if (ISFCN(syment->n_type)) { - last_fcn = syment; - } - if (syment->n_sclass == C_BLOCK - && coff_symbol_ptr->symbol.name[1] == 'b') - { - *last_block++ = syment; - } - } - syment->_n._n_n._n_offset = native_index; - native_index = native_index + 1 + syment->n_numaux; - } - } - } -} - - -static void -DEFUN(coff_write_symbols,(abfd), -bfd *abfd) -{ - unsigned int i; - unsigned int limit = bfd_get_symcount(abfd); - unsigned int written = 0; - struct internal_syment dummy; - asymbol **p; - unsigned int string_size = 0; - - - /* Seek to the right place */ - bfd_seek(abfd, obj_sym_filepos(abfd), SEEK_SET); - - /* Output all the symbols we have */ - - written = 0; - for (p = abfd->outsymbols, i = 0; i < limit; i++, p++) { - asymbol *symbol = *p; - coff_symbol_type *c_symbol = coff_symbol_from(abfd, symbol); - - unsigned int j; - struct internal_syment *native; - if (c_symbol == (coff_symbol_type *) NULL || - c_symbol->native == (struct internal_syment *) NULL) { - /* - This symbol has been created by the loader, or come from a non - coff format. It has no native element to inherit, make our - own - */ - - native = &dummy; - native->n_type = T_NULL; -#ifdef I960 - native->n_flags = 0; -#endif - if (symbol->flags & BSF_ABSOLUTE) { - native->n_scnum = N_ABS; - native->n_value = symbol->value; - } - else if (symbol->flags & (BSF_UNDEFINED | BSF_FORT_COMM)) { - native->n_scnum = N_UNDEF; - native->n_value = symbol->value; - } - else if (symbol->flags & BSF_DEBUGGING) { - /* - remove name so it doesn't take up any space - */ - symbol->name = ""; - continue; - } - else { - native->n_scnum = symbol->section->output_section->index + - 1; - native->n_value = symbol->value + - symbol->section->output_section->vma + - symbol->section->output_offset; -#ifdef I960 - /* Copy the any flags from the the file hdr into the symbol */ - { - coff_symbol_type *c = coff_symbol_from(abfd, symbol); - if (c != (coff_symbol_type *)NULL) { - native->n_flags = c->symbol.the_bfd->flags; - } - } -#endif - } - -#ifdef HASPAD1 - native->pad1[0] = 0; - native->pad1[0] = 0; -#endif - - native->n_type = 0; - if (symbol->flags & BSF_LOCAL) - native->n_sclass = C_STAT; - else - native->n_sclass = C_EXT; - native->n_numaux = 0; - } - else - /* - Does this symbol have an ascociated line number - if so then - make it remember this symbol index. Also tag the auxent of - this symbol to point to the right place in the lineno table - */ - { - alent *lineno = c_symbol->lineno; - native = c_symbol->native; - if (lineno) { - unsigned int count = 0; - lineno[count].u.offset = written; - if (native->n_numaux) { - union internal_auxent *a = (union internal_auxent *) (native + 1); - - a->x_sym.x_fcnary.x_fcn.x_lnnoptr = - c_symbol->symbol.section->output_section->moving_line_filepos; - } - /* - And count and relocate all other linenumbers - */ - count++; - while (lineno[count].line_number) { - lineno[count].u.offset += - c_symbol->symbol.section->output_section->vma + - c_symbol->symbol.section->output_offset; - count++; - } - c_symbol->symbol.section->output_section->moving_line_filepos += - count * LINESZ; - - } - } /* if symbol new to coff */ - - /* Fix the symbol names */ - { - unsigned int name_length; - if (symbol->name == (char *) NULL) { - /* - coff symbols always have names, so we'll make one up - */ - symbol->name = "strange"; - } - name_length = strlen(symbol->name); - if (name_length <= SYMNMLEN) { - /* This name will fit into the symbol neatly */ - strncpy(native->_n._n_name, symbol->name, SYMNMLEN); - } - else { - native->_n._n_n._n_offset = string_size + 4; - native->_n._n_n._n_zeroes = 0; - string_size += name_length + 1; - } - { - unsigned int numaux = native->n_numaux; - int type = native->n_type; - int class = native->n_sclass; - SYMENT buf; - bfd_coff_swap_sym_out(abfd, native, &buf); - bfd_write((PTR)& buf, 1, SYMESZ, abfd); - for (j = 0; j != native->n_numaux; - j++) { - AUXENT buf1; - bfd_coff_swap_aux_out(abfd, - (union internal_auxent *)(native + j + 1), type, class, &buf1); - bfd_write((PTR) (native + j + 1), 1, AUXESZ, abfd); - } - /* - Reuse somewhere in the symbol to keep the index - */ - set_index(symbol, written); - written += 1 + numaux; - } - } - } /* for each out symbol */ - - bfd_get_symcount(abfd) = written; - /* Now write out strings */ - - if (string_size) { - unsigned int size = string_size + 4; - size = size; - bfd_write((PTR) &size, 1, sizeof(size), abfd); - for (p = abfd->outsymbols, i = 0; i < limit; i++, p++) { - asymbol *q = *p; - size_t name_length = strlen(q->name); - if (name_length > SYMNMLEN) { - bfd_write((PTR) (q->name), 1, name_length + 1, abfd); - } - } - } - else { - /* We would normally not write anything here, but we'll write - out 4 so that any stupid coff reader which tries to read - the string table even when there isn't one won't croak. - */ - - uint32e_type size = 4; - size = size; - bfd_write((PTR)&size, 1, sizeof(size), abfd); - - } - -} - -static void -coff_write_relocs(abfd) -bfd *abfd; - { - asection *s; - for (s = abfd->sections; s != (asection *) NULL; s = s->next) { - unsigned int i; - struct external_reloc dst; - - arelent **p = s->orelocation; - bfd_seek(abfd, s->rel_filepos, SEEK_SET); - for (i = 0; i < s->reloc_count; i++) { - struct internal_reloc n; - arelent *q = p[i]; - memset((PTR)&n, 0, sizeof(n)); - n.r_vaddr = q->address + s->vma; - if (q->sym_ptr_ptr) { - n.r_symndx = get_index((*(q->sym_ptr_ptr))); - } -#ifdef SELECT_RELOC - /* Work out reloc type from what is required */ - SELECT_RELOC(n.r_type, q->howto); -#else - n.r_type = q->howto->type; -#endif - bfd_swap_reloc_out(abfd, &n, &dst); - bfd_write((PTR) &n, 1, RELSZ, abfd); - } - } - } - -static void -DEFUN(coff_write_linenumbers,(abfd), - bfd *abfd) - { - asection *s; - for (s = abfd->sections; s != (asection *) NULL; s = s->next) { - if (s->lineno_count) { - asymbol **q = abfd->outsymbols; - bfd_seek(abfd, s->line_filepos, SEEK_SET); - /* Find all the linenumbers in this section */ - while (*q) { - asymbol *p = *q; - alent *l = BFD_SEND(p->the_bfd, _get_lineno, (p->the_bfd, p)); - if (l) { - /* Found a linenumber entry, output */ - struct internal_lineno out; - LINENO buff; - bzero( (PTR)&out, sizeof(out)); - out.l_lnno = 0; - out.l_addr.l_symndx = l->u.offset; - bfd_coff_swap_lineno_out(abfd, &out, &buff); - bfd_write((PTR) &buff, 1, LINESZ, abfd); - l++; - while (l->line_number) { - out.l_lnno = l->line_number; - out.l_addr.l_symndx = l->u.offset; - bfd_coff_swap_lineno_out(abfd, &out, &buff); - bfd_write((PTR) &buff, 1, LINESZ, abfd); - l++; - } - } - q++; - } - } - } - } - - -static asymbol * -coff_make_empty_symbol(abfd) -bfd *abfd; - { - coff_symbol_type *new = (coff_symbol_type *) bfd_alloc(abfd, sizeof(coff_symbol_type)); - if (new == NULL) { - bfd_error = no_memory; - return (NULL); - } /* on error */ - new->native = 0; - new->lineno = (alent *) NULL; - new->symbol.the_bfd = abfd; - return &new->symbol; - } - -static void -coff_print_symbol(ignore_abfd, file, symbol, how) -bfd *ignore_abfd; -FILE *file; -asymbol *symbol; -bfd_print_symbol_enum_type how; - { - switch (how) { - case bfd_print_symbol_name_enum: - fprintf(file, "%s", symbol->name); - break; - case bfd_print_symbol_type_enum: - fprintf(file, "coff %lx %lx", (unsigned long) coffsymbol(symbol)->native, - (unsigned long) coffsymbol(symbol)->lineno); - break; - case bfd_print_symbol_all_enum: - { - CONST char *section_name = symbol->section == (asection *) NULL ? - "*abs" : symbol->section->name; - bfd_print_symbol_vandf((PTR) file, symbol); - - fprintf(file, " %-5s %s %s %s", - section_name, - coffsymbol(symbol)->native ? "n" : "g", - coffsymbol(symbol)->lineno ? "l" : " ", - symbol->name); - } - - - break; - } - } - -static alent * -coff_get_lineno(ignore_abfd, symbol) -bfd *ignore_abfd; -asymbol *symbol; - { - return coffsymbol(symbol)->lineno; - } - -/* -Set flags and magic number of a coff file from architecture and machine -type. Result is true if we can represent the arch&type, false if not. -*/ -static boolean -coff_set_flags(abfd, magicp, flagsp) -bfd *abfd; -unsigned *magicp, -*flagsp; - { - - switch (abfd->obj_arch) { - -#ifdef I960ROMAGIC - - case bfd_arch_i960: - - { - unsigned flags; - *magicp = I960ROMAGIC; - /* - ((bfd_get_file_flags(abfd) & WP_TEXT) ? I960ROMAGIC : - I960RWMAGIC); FIXME??? - */ - switch (abfd->obj_machine) { - case bfd_mach_i960_core: - flags = F_I960CORE; - break; - case bfd_mach_i960_kb_sb: - flags = F_I960KB; - break; - case bfd_mach_i960_mc: - flags = F_I960MC; - break; - case bfd_mach_i960_xa: - flags = F_I960XA; - break; - case bfd_mach_i960_ca: - flags = F_I960CA; - break; - case bfd_mach_i960_ka_sa: - flags = F_I960KA; - break; - default: - return false; - } - *flagsp = flags; - return true; - } - break; -#endif -#ifdef MIPS - case bfd_arch_mips: - *magicp = MIPS_MAGIC_2; - return true; - break; -#endif -#ifdef MC68MAGIC - case bfd_arch_m68k: - *magicp = MC68MAGIC; - return true; -#endif - -#ifdef MC88MAGIC - case bfd_arch_m88k: - *magicp = MC88OMAGIC; - return true; - break; -#endif - - default: /* Unknown architecture */ - return false; - } - - return false; - } - - -static boolean -coff_set_arch_mach(abfd, arch, machine) -bfd *abfd; -enum bfd_architecture arch; -unsigned long machine; - { - unsigned dummy1, - dummy2; - abfd->obj_arch = arch; - abfd->obj_machine = machine; - if (arch != bfd_arch_unknown && - coff_set_flags(abfd, &dummy1, &dummy2) != true) - return false; /* We can't represent this type */ - return true; /* We're easy ... */ - } - - -/* Calculate the file position for each section. */ - -static void -coff_compute_section_file_positions(abfd) -bfd *abfd; - { - asection *current; - file_ptr sofar = FILHSZ; - if (bfd_get_start_address(abfd)) { - /* - A start address may have been added to the original file. In this - case it will need an optional header to record it. - */ - abfd->flags |= EXEC_P; - } - if (abfd->flags & EXEC_P) - sofar += AOUTSZ; - - - sofar += abfd->section_count * SCNHSZ; - - for (current = abfd->sections; current != NULL; current = - current->next) { - /* Only deal with sections which have contents */ - if (!(current->flags & SEC_HAS_CONTENTS)) - continue; - - /* Align the sections in the file to the same boundary on - which they are aligned in virtual memory. I960 doesn't - do this (FIXME) so we can stay in sync with Intel. 960 - doesn't yet page from files... */ -#ifndef I960 - sofar = ALIGN(sofar, 1 << current->alignment_power); -#endif - /* FIXME, in demand paged files, the low order bits of the file - offset must match the low order bits of the virtual address. - "Low order" is apparently implementation defined. Add code - here to round sofar up to match the virtual address. */ - - current->filepos = sofar; - sofar += current->size; - } - obj_relocbase(abfd) = sofar; - } - - - - -/* SUPPRESS 558 */ -/* SUPPRESS 529 */ -static boolean -DEFUN(coff_write_object_contents,(abfd), -bfd *abfd) -{ - asection *current; - boolean hasrelocs = false; - boolean haslinno = false; - file_ptr reloc_base; - file_ptr lineno_base; - file_ptr sym_base; - file_ptr scn_base; - file_ptr data_base; - unsigned long reloc_size = 0; - unsigned long lnno_size = 0; - asection *text_sec = NULL; - asection *data_sec = NULL; - asection *bss_sec = NULL; - - struct internal_filehdr internal_f; - struct internal_aouthdr internal_a; - - struct icofdata *coff = obj_icof(abfd); - - - bfd_error = system_call_error; - - - if(abfd->output_has_begun == false) { - coff_compute_section_file_positions(abfd); - } - - if (abfd->sections != (asection *)NULL) { - scn_base = abfd->sections->filepos; - } - else { - scn_base = 0; - } - if (bfd_seek(abfd, scn_base, SEEK_SET) != 0) - return false; - reloc_base = obj_relocbase(abfd); - - /* Make a pass through the symbol table to count line number entries and - put them into the correct asections */ - - coff_count_linenumbers(abfd); - data_base = scn_base; - - /* Work out the size of the reloc and linno areas */ - - for (current = abfd->sections; current != NULL; current = current->next) { - reloc_size += current->reloc_count * RELSZ; - lnno_size += current->lineno_count * LINESZ; - data_base += SCNHSZ; - } - - lineno_base = reloc_base + reloc_size; - sym_base = lineno_base + lnno_size; - - /* Indicate in each section->line_filepos its actual file address */ - for (current = abfd->sections; current != NULL; current = current->next) { - if (current->lineno_count) { - current->line_filepos = lineno_base; - current->moving_line_filepos = lineno_base; - lineno_base += current->lineno_count * LINESZ; - } - else { - current->line_filepos = 0; - } - if (current->reloc_count) { - current->rel_filepos = reloc_base; - reloc_base += current->reloc_count * sizeof(struct internal_reloc); - } - else { - current->rel_filepos = 0; - } - } - - /* Write section headers to the file. */ - - bfd_seek(abfd, - (file_ptr) ((abfd->flags & EXEC_P) ? - (FILHSZ + AOUTSZ) : FILHSZ), - SEEK_SET); - - { -#if 0 - unsigned int pad = abfd->flags & D_PAGED ? data_base : 0; -#endif - unsigned int pad = 0; - - for (current = abfd->sections; current != NULL; current = current->next) { - struct internal_scnhdr section; - strncpy(&(section.s_name[0]), current->name, 8); - section.s_vaddr = current->vma + pad; - section.s_paddr = current->vma + pad; - section.s_size = current->size - pad; - /* - If this section has no size or is unloadable then the scnptr - will be 0 too - */ - if (current->size - pad == 0 || - (current->flags & SEC_LOAD) == 0) { - section.s_scnptr = 0; - - } - else { - section.s_scnptr = current->filepos; - } - section.s_relptr = current->rel_filepos; - section.s_lnnoptr = current->line_filepos; - section.s_nreloc = current->reloc_count; - section.s_nlnno = current->lineno_count; - if (current->reloc_count != 0) - hasrelocs = true; - if (current->lineno_count != 0) - haslinno = true; - - if (!strcmp(current->name, _TEXT)) { - text_sec = current; - section.s_flags = STYP_TEXT; /* kinda stupid */ - } - else if (!strcmp(current->name, _DATA)) { - data_sec = current; - section.s_flags = STYP_DATA; /* kinda stupid */ - } - else if (!strcmp(current->name, _BSS)) { - bss_sec = current; - section.s_flags = STYP_BSS; /* kinda stupid */ - } - - -#ifdef I960 - section.s_align = (current->alignment_power - ? 1 << current->alignment_power - : 0); - -#endif - { - SCNHDR buff; - - swap_scnhdr_out(abfd, §ion, &buff); - bfd_write((PTR) (&buff), 1, SCNHSZ, abfd); - - } - pad = 0; - } - } - - /* OK, now set up the filehdr... */ - internal_f.f_nscns = abfd->section_count; - /* - We will NOT put a fucking timestamp in the header here. Every time you - put it back, I will come in and take it out again. I'm sorry. This - field does not belong here. We fill it with a 0 so it compares the - same but is not a reasonable time. -- gnu@cygnus.com - */ - /* - Well, I like it, so I'm conditionally compiling it in. - steve@cygnus.com - */ -#ifdef COFF_TIMESTAMP - internal_f.f_timdat = time(0); -#else - internal_f.f_timdat = 0; -#endif - - if (bfd_get_symcount(abfd) != 0) - internal_f.f_symptr = sym_base; - else - internal_f.f_symptr = 0; - - internal_f.f_flags = 0; - - if (abfd->flags & EXEC_P) - internal_f.f_opthdr = AOUTSZ; - else - internal_f.f_opthdr = 0; - - if (!hasrelocs) - internal_f.f_flags |= F_RELFLG; - if (!haslinno) - internal_f.f_flags |= F_LNNO; - if (0 == bfd_get_symcount(abfd)) - internal_f.f_flags |= F_LSYMS; - if (abfd->flags & EXEC_P) - internal_f.f_flags |= F_EXEC; -#if M88 - internal_f.f_flags |= F_AR32W; -#else - if (!abfd->xvec->byteorder_big_p) - internal_f.f_flags |= F_AR32WR; -#endif - /* - FIXME, should do something about the other byte orders and - architectures. - */ - - /* Set up architecture-dependent stuff */ - - { int magic = 0; - int flags = 0; - coff_set_flags(abfd, &magic, &flags); - internal_f.f_magic = magic; - internal_f.f_flags = flags; - - /* ...and the "opt"hdr... */ - -#ifdef I960 - internal_a.magic = (magic == I960ROMAGIC ? NMAGIC : OMAGIC); -#endif -#if M88 - internal_a.magic = PAGEMAGICBCS; -#endif - } - /* Now should write relocs, strings, syms */ - obj_sym_filepos(abfd) = sym_base; - - if (bfd_get_symcount(abfd) != 0) { - coff_mangle_symbols(abfd); - coff_write_symbols(abfd); - coff_write_linenumbers(abfd); - coff_write_relocs(abfd); - } - if (text_sec) { - internal_a.tsize = text_sec->size; - internal_a.text_start =text_sec->size ? text_sec->vma : 0; - } - if (data_sec) { - internal_a.dsize = data_sec->size; - internal_a.data_start = data_sec->size ? data_sec->vma : 0; - } - if (bss_sec) { - internal_a.bsize = bss_sec->size; - } - - internal_a.entry = bfd_get_start_address(abfd); - internal_f.f_nsyms = bfd_get_symcount(abfd); - - /* now write them */ - if (bfd_seek(abfd, 0L, SEEK_SET) != 0) - return false; - { - FILHDR buff; - bfd_swap_filehdr_out(abfd, &internal_f, &buff); - bfd_write((PTR) &buff, 1, FILHSZ, abfd); - } - if (abfd->flags & EXEC_P) { - AOUTHDR buff; - bfd_swap_aouthdr_out(abfd, &internal_a, &buff); - bfd_write((PTR) &buff, 1, AOUTSZ, abfd); - } - return true; -} - -static boolean -coff_set_section_contents(abfd, section, location, offset, count) - bfd *abfd; - sec_ptr section; - PTR location; - file_ptr offset; - size_t count; -{ - if (abfd->output_has_begun == false) /* set by bfd.c handler */ - coff_compute_section_file_positions(abfd); - - bfd_seek(abfd, (file_ptr) (section->filepos + offset), SEEK_SET); - - if (count != 0) { - return (bfd_write(location, 1, count, abfd) == count) ? true : false; - } - return true; -} - -static boolean -coff_close_and_cleanup(abfd) - bfd *abfd; -{ - if (!bfd_read_p(abfd)) - switch (abfd->format) { - case bfd_archive: - if (!_bfd_write_archive_contents(abfd)) - return false; - break; - case bfd_object: - if (!coff_write_object_contents(abfd)) - return false; - break; - default: - bfd_error = invalid_operation; - return false; - } - - /* We depend on bfd_close to free all the memory on the obstack. */ - /* FIXME if bfd_release is not using obstacks! */ - return true; -} - - -static PTR -buy_and_read(abfd, where, seek_direction, size) - bfd *abfd; - file_ptr where; - int seek_direction; - size_t size; -{ - PTR area = (PTR) bfd_alloc(abfd, size); - if (!area) { - bfd_error = no_memory; - return (NULL); - } - bfd_seek(abfd, where, seek_direction); - if (bfd_read(area, 1, size, abfd) != size) { - bfd_error = system_call_error; - return (NULL); - } /* on error */ - return (area); -} /* buy_and_read() */ - -static void -DEFUN(offset_symbol_indices,(abfd, symtab, count, offset), - bfd *abfd AND - struct internal_syment *symtab AND - unsigned long count AND - long offset) -{ - struct internal_syment *end = symtab + count; - for (; symtab < end; ++symtab) { - if (symtab->n_sclass == C_FILE) { - symtab->n_value = 0; - } - else if (symtab->n_sclass == C_ALIAS) { - /* - These guys have indices in their values. - */ - symtab->n_value = symtab->n_value + offset; - } - else if (symtab->n_numaux) { - /* - anybody else without an aux, has no indices. - */ - - if (symtab->n_sclass == C_EOS - || (BTYPE(symtab->n_type) == T_STRUCT - && symtab->n_sclass != C_STRTAG) - || BTYPE(symtab->n_type) == T_UNION - || BTYPE(symtab->n_type) == T_ENUM) { - /* If the tagndx is 0 then the struct hasn't really been - defined, so leave it alone */ - - if(((union internal_auxent *) (symtab + 1))->x_sym.x_tagndx != 0) { - ((union internal_auxent *) (symtab + 1))->x_sym.x_tagndx += offset; - } - - } /* These guys have a tagndx */ - if (symtab->n_sclass == C_STRTAG - || symtab->n_sclass == C_UNTAG - || symtab->n_sclass == C_ENTAG - || symtab->n_sclass == C_BLOCK - || symtab->n_sclass == C_FCN - || ISFCN(symtab->n_type)) { - - ((union internal_auxent *) (symtab + - 1))->x_sym.x_fcnary.x_fcn.x_endndx - += offset; - - } /* These guys have an endndx */ -#ifndef I960 - if (ISFCN(symtab->n_type)) { - ((union internal_auxent *) (symtab + 1))->x_sym.x_tvndx += offset; - } /* These guys have a tvndx. I think... - (FIXME) */ -#endif /* Not I960 */ - - } /* if value, else if aux */ - symtab += symtab->n_numaux; - } /* walk the symtab */ - - return; -} /* offset_symbol_indices() */ - -#if 0 -/* swap the entire symbol table - we c*/ -static void -swap_raw_symtab(abfd, raw_symtab) -bfd *abfd; -SYMENT *raw_symtab; - { - long i; - SYMENT *end = raw_symtab + bfd_get_symcount(abfd); - for (; raw_symtab < end; ++raw_symtab) { - bfd_coff_swap_sym(abfd, raw_symtab); - - for (i = raw_symtab->n_numaux; i; --i, ++raw_symtab) { - bfd_coff_swap_aux(abfd, - (AUXENT *)(raw_symtab + 1), - raw_symtab->n_type, - raw_symtab->n_sclass); - } /* swap all the aux entries */ - } /* walk the symbol table */ - - return; - } /* swap_raw_symtab() */ -#endif -/* -read a symbol table into freshly mallocated memory, swap it, and knit the -symbol names into a normalized form. By normalized here I mean that all -symbols have an n_offset pointer that points to a NULL terminated string. -Oh, and the first symbol MUST be a C_FILE. If there wasn't one there -before, put one there. -*/ - -static struct internal_syment * -DEFUN(get_normalized_symtab,(abfd), -bfd *abfd) -{ - - struct internal_syment *internal; - struct internal_syment *internal_ptr; - struct internal_syment *internal_end; - SYMENT *raw; - SYMENT *raw_src; - SYMENT *raw_end; - char *string_table = NULL; - unsigned long size; - char string_table_size_buffer[4]; - unsigned long string_table_size = 0; - unsigned int raw_size; - if (obj_raw_syments(abfd) != (struct internal_syment *)NULL) { - return obj_raw_syments(abfd); - } - if ((size = bfd_get_symcount(abfd) * sizeof(struct internal_syment)) == 0) { - bfd_error = no_symbols; - return (NULL); - } - - internal = (struct internal_syment *)bfd_alloc(abfd, size); - internal_end = internal + bfd_get_symcount(abfd); - - raw_size = bfd_get_symcount(abfd) * SYMESZ; - raw = (SYMENT *)bfd_alloc(abfd,raw_size); - - if (bfd_seek(abfd, obj_sym_filepos(abfd), SEEK_SET) == -1 - || bfd_read((PTR)raw, raw_size, 1, abfd) != raw_size) { - bfd_error = system_call_error; - return (NULL); - } - /* mark the end of the symbols */ - raw_end = raw + bfd_get_symcount(abfd); - /* - FIXME SOMEDAY. A string table size of zero is very weird, but - probably possible. If one shows up, it will probably kill us. - */ - - /* Swap all the raw entries */ - for (raw_src = raw, internal_ptr = internal; raw_src < raw_end; raw_src++, internal_ptr++) { - unsigned int i; - bfd_coff_swap_sym_in(abfd, raw_src,internal_ptr); - for (i = internal_ptr->n_numaux; i; --i, raw_src++, internal_ptr++) { - bfd_coff_swap_aux_in(abfd, (AUXENT *)(raw_src +1), internal_ptr->n_type, - internal_ptr->n_sclass, (union - internal_auxent *)(internal_ptr +1)); - } - } - - /* Free all the raw stuff */ - bfd_release(abfd, raw_src); - - for (internal_ptr = internal; internal_ptr < internal_end; internal_ptr ++) { - - if (internal_ptr->_n._n_n._n_zeroes != 0) { - /* - This is a "short" name. Make it long. - */ - unsigned long i = 0; - char *newstring = NULL; - /* - find the length of this string without walking into memory - that isn't ours. - */ - - for (i = 0; i < 8; ++i) { - if (internal_ptr->_n._n_name[i] == '\0') { - break; - } /* if end of string */ - } /* possible lengths of this string. */ - - if ((newstring = (PTR) bfd_alloc(abfd, ++i)) == NULL) { - bfd_error = no_memory; - return (NULL); - } /* on error */ - bzero(newstring, i); - strncpy(newstring, internal_ptr->_n._n_name, i-1); - internal_ptr->_n._n_n._n_offset = (int) newstring; - internal_ptr->_n._n_n._n_zeroes = 0; - - } - else { - if (string_table == NULL) { - /* - NOTE: we don't read the string table until now because we - don't necessarily know that we have one until now. - */ - /* - At this point we should be "seek"'d to the end of the - symbols === the symbol table size. - */ - - if (bfd_read((char *) string_table_size_buffer, - sizeof(string_table_size_buffer), - 1, abfd) != sizeof(string_table_size)) { - bfd_error = system_call_error; - return (NULL); - } /* on error */ - - string_table_size = bfd_h_getlong(abfd, string_table_size_buffer); - - if ((string_table = (PTR) bfd_alloc(abfd, string_table_size -= 4)) == NULL) { - bfd_error = no_memory; - return (NULL); - } /* on mallocation error */ - if (bfd_read(string_table, string_table_size, 1, abfd) != string_table_size) { - bfd_error = system_call_error; - return (NULL); - } /* on error */ - } /* have not yet read the string table. */ - /* - This is a long name already. Just point it at the string in - memory. - */ - internal_ptr->_n._n_n._n_offset = (int) (string_table - 4 + internal_ptr->_n._n_n._n_offset); - - } /* switch on type of symbol name */ - - internal_ptr += internal_ptr->n_numaux; - } /* for each symbol */ -#if 0 -#ifndef GNU960 - /* I'm not sure of the repercussions of this, so the Intel - folks will always do the force - */ - if (obj_symbol_slew(abfd) > 0) - force_indices_file_symbol_relative(abfd, internal); -#else - force_indices_file_symbol_relative(abfd, internal); -#endif -#endif - obj_raw_syments(abfd) = internal; - obj_string_table(abfd) = string_table; - - return (internal); -} /* get_normalized_symtab() */ - -static -struct sec * -DEFUN(section_from_bfd_index,(abfd, index), - bfd *abfd AND - int index) -{ - if (index > 0) { - struct sec *answer = abfd->sections; - while (--index) { - answer = answer->next; - } - return answer; - } - return 0; -} - - - - -static boolean -coff_slurp_line_table(abfd, asect) -bfd *abfd; -asection *asect; - { - LINENO *native_lineno; - alent *lineno_cache; - - BFD_ASSERT(asect->lineno == (alent *) NULL); - - native_lineno = (LINENO *) buy_and_read(abfd, - asect->line_filepos, - SEEK_SET, - (size_t) (LINESZ * - asect->lineno_count)); - lineno_cache = - (alent *) bfd_alloc(abfd, (size_t) ((asect->lineno_count + 1) * sizeof(alent))); - if (lineno_cache == NULL) { - bfd_error = no_memory; - return false; - } else { - unsigned int counter = 0; - alent *cache_ptr = lineno_cache; - LINENO *src = native_lineno; - - while (counter < asect->lineno_count) { - struct internal_lineno dst; - bfd_coff_swap_lineno_in(abfd, src, &dst); - cache_ptr->line_number = dst.l_lnno; - - if (cache_ptr->line_number == 0) { - coff_symbol_type *sym = - (coff_symbol_type *) (dst.l_addr.l_symndx - + obj_symbol_slew(abfd) - + obj_raw_syments(abfd))->_n._n_n._n_zeroes; - cache_ptr->u.sym = (asymbol *) sym; - sym->lineno = cache_ptr; - } - else { - cache_ptr->u.offset = dst.l_addr.l_paddr - - bfd_section_vma(abfd, asect); - } /* If no linenumber expect a symbol index */ - - cache_ptr++; - src++; - counter++; - } - cache_ptr->line_number = 0; - - } - asect->lineno = lineno_cache; - /* FIXME, free native_lineno here, or use alloca or something. */ - return true; - } /* coff_slurp_line_table() */ - -static struct internal_syment * -DEFUN(find_next_file_symbol,(abfd, current, end), - bfd *abfd AND - struct internal_syment *current AND - struct internal_syment *end) -{ - current += current->n_numaux + 1; - - while (current < end) { - if (current->n_sclass== C_FILE) { - return (current); - } - current += current->n_numaux + 1; - } - return end; -} - - -/* -Note that C_FILE symbols can, and some do, have more than 1 aux entry. -*/ - -static void -DEFUN(force_indices_file_symbol_relative,(abfd, symtab), - bfd *abfd AND - struct internal_syment *symtab) -{ - struct internal_syment *end = symtab + bfd_get_symcount(abfd); - struct internal_syment *current; - struct internal_syment *next; - /* the first symbol had damn well better be a C_FILE. */ - BFD_ASSERT(symtab->n_sclass == C_FILE); - - for (current = find_next_file_symbol(abfd, symtab, end); - current < end; - current = next) { - offset_symbol_indices(abfd, current, - ((next = - find_next_file_symbol(abfd, current, - end)) - current), - symtab - current); - } - return; -} - -static boolean -DEFUN(coff_slurp_symbol_table,(abfd), - bfd *abfd) - { - struct internal_syment *native_symbols; - coff_symbol_type *cached_area; - unsigned int *table_ptr; - - unsigned int number_of_symbols = 0; - if (obj_symbols(abfd)) - return true; - bfd_seek(abfd, obj_sym_filepos(abfd), SEEK_SET); - - /* Read in the symbol table */ - if ((native_symbols = get_normalized_symtab(abfd)) == NULL) { - return (false); - } /* on error */ - - - /* Allocate enough room for all the symbols in cached form */ - cached_area = - (coff_symbol_type *) - bfd_alloc(abfd, (size_t) (bfd_get_symcount(abfd) * sizeof(coff_symbol_type))); - - if (cached_area == NULL) { - bfd_error = no_memory; - return false; - } /* on error */ - table_ptr = - (unsigned int *) - bfd_alloc(abfd, (size_t) (bfd_get_symcount(abfd) * sizeof(unsigned int))); - - if (table_ptr == NULL) { - bfd_error = no_memory; - return false; - } else { - coff_symbol_type *dst = cached_area; - unsigned int last_native_index = bfd_get_symcount(abfd); - unsigned int this_index = 0; - while (this_index < last_native_index) { - struct internal_syment *src = native_symbols + this_index; - table_ptr[this_index] = number_of_symbols; - dst->symbol.the_bfd = abfd; - - dst->symbol.name = (char *)(src->_n._n_n._n_offset); - /* - We use the native name field to point to the cached field - */ - src->_n._n_n._n_zeroes = (int) dst; - dst->symbol.section = section_from_bfd_index(abfd, - src->n_scnum); - switch (src->n_sclass) { -#ifdef I960 - case C_LEAFEXT: -#if 0 - dst->symbol.value = src->n_value - dst->symbol.section->vma; - dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL; - dst->symbol.flags |= BSF_NOT_AT_END; -#endif - /* Fall through to next case */ - -#endif - - case C_EXT: - if ((src->n_scnum) == 0) { - if ((src->n_value) == 0) { - dst->symbol.flags = BSF_UNDEFINED; - dst->symbol.value= 0; - } - else { - dst->symbol.flags = BSF_FORT_COMM; - dst->symbol.value = (src->n_value); - } - } - else { - /* - Base the value as an index from the base of the - section - */ - if (dst->symbol.section == (asection *) NULL) { - dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL | BSF_ABSOLUTE; - dst->symbol.value = src->n_value; - } - else { - dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL; - dst->symbol.value = src->n_value - dst->symbol.section->vma; - } - if (ISFCN((src->n_type))) { - /* - A function ext does not go at the end of a file - */ - dst->symbol.flags |= BSF_NOT_AT_END; - } - } - - break; - case C_STAT: /* static */ -#ifdef I960 - case C_LEAFSTAT: /* static leaf procedure */ -#endif - case C_LABEL: /* label */ - dst->symbol.flags = BSF_LOCAL; - /* - Base the value as an index from the base of the section - */ - dst->symbol.value = (src->n_value) - dst->symbol.section->vma; - break; - - case C_MOS: /* member of structure */ - case C_EOS: /* end of structure */ - case C_REGPARM: /* register parameter */ - case C_REG: /* register variable */ -#ifdef C_AUTOARG - case C_AUTOARG: /* 960-specific storage class */ -#endif - case C_TPDEF: /* type definition */ - - case C_ARG: - case C_AUTO: /* automatic variable */ - case C_FIELD: /* bit field */ - case C_ENTAG: /* enumeration tag */ - case C_MOE: /* member of enumeration */ - case C_MOU: /* member of union */ - case C_UNTAG: /* union tag */ - - dst->symbol.flags = BSF_DEBUGGING; - dst->symbol.value = (src->n_value); - break; - - case C_FILE: /* file name */ - case C_STRTAG: /* structure tag */ - dst->symbol.flags = BSF_DEBUGGING; - dst->symbol.value = (src->n_value); - - break; - case C_BLOCK: /* ".bb" or ".eb" */ - case C_FCN: /* ".bf" or ".ef" */ - dst->symbol.flags = BSF_LOCAL; - /* - Base the value as an index from the base of the section - */ - dst->symbol.value = (src->n_value) - dst->symbol.section->vma; - - break; - case C_EFCN: /* physical end of function */ - case C_NULL: - case C_EXTDEF: /* external definition */ - case C_ULABEL: /* undefined label */ - case C_USTATIC: /* undefined static */ - case C_LINE: /* line # reformatted as symbol table entry */ - case C_ALIAS: /* duplicate tag */ - case C_HIDDEN: /* ext symbol in dmert public lib */ - - default: - - abort(); - dst->symbol.flags = BSF_DEBUGGING; - dst->symbol.value = (src->n_value); - - break; - } - - BFD_ASSERT(dst->symbol.flags != 0); - - dst->native = src; - - dst->symbol.udata = 0; - dst->lineno = (alent *) NULL; - this_index += (src->n_numaux) + 1; - dst++; - number_of_symbols++; - } /* walk the native symtab */ - } /* bfdize the native symtab */ - - obj_symbols(abfd) = cached_area; - obj_raw_syments(abfd) = native_symbols; - - bfd_get_symcount(abfd) = number_of_symbols; - obj_convert(abfd) = table_ptr; - /* Slurp the line tables for each section too */ - { - asection *p; - p = abfd->sections; - while (p) { - coff_slurp_line_table(abfd, p); - p = p->next; - } - } - return true; - } /* coff_slurp_symbol_table() */ - -static unsigned int -coff_get_symtab_upper_bound(abfd) -bfd *abfd; - { - if (!coff_slurp_symbol_table(abfd)) - return 0; - - return (bfd_get_symcount(abfd) + 1) * (sizeof(coff_symbol_type *)); - } - - -static unsigned int -coff_get_symtab(abfd, alocation) -bfd *abfd; -asymbol **alocation; - { - unsigned int counter = 0; - coff_symbol_type *symbase; - coff_symbol_type **location = (coff_symbol_type **) (alocation); - if (!coff_slurp_symbol_table(abfd)) - return 0; - - for (symbase = obj_symbols(abfd); counter++ < bfd_get_symcount(abfd);) - *(location++) = symbase++; - *location++ = 0; - return bfd_get_symcount(abfd); - } - -static unsigned int -coff_get_reloc_upper_bound(abfd, asect) -bfd *abfd; -sec_ptr asect; - { - if (bfd_get_format(abfd) != bfd_object) { - bfd_error = invalid_operation; - return 0; - } - return (asect->reloc_count + 1) * sizeof(arelent *); - } - -static boolean -DEFUN(coff_slurp_reloc_table,(abfd, asect, symbols), - bfd *abfd AND - sec_ptr asect AND - asymbol **symbols) - { - RELOC *native_relocs; - arelent *reloc_cache; - if (asect->relocation) - return true; - if (asect->reloc_count == 0) - return true; - if (!coff_slurp_symbol_table(abfd)) - return false; - native_relocs = - (RELOC *) buy_and_read(abfd, - asect->rel_filepos, - SEEK_SET, - (size_t) (RELSZ * - asect->reloc_count)); - reloc_cache = (arelent *) - bfd_alloc(abfd, (size_t) (asect->reloc_count * sizeof(arelent))); - - if (reloc_cache == NULL) { - bfd_error = no_memory; - return false; - } { /* on error */ - arelent *cache_ptr; - RELOC *src; - for (cache_ptr = reloc_cache, - src = native_relocs; - cache_ptr < reloc_cache + asect->reloc_count; - cache_ptr++, - src++) { - struct internal_reloc dst; - asymbol *ptr; - bfd_swap_reloc_in(abfd, src, &dst); - dst.r_symndx += obj_symbol_slew(abfd); - cache_ptr->sym_ptr_ptr = symbols + obj_convert(abfd)[dst.r_symndx]; - - ptr = *(cache_ptr->sym_ptr_ptr); - cache_ptr->address = dst.r_vaddr; - /* - The symbols definitions that we have read in have been - relocated as if their sections started at 0. But the offsets - refering to the symbols in the raw data have not been - modified, so we have to have a negative addend to compensate. - - Note that symbols which used to be common must be left alone - */ - - if (ptr->the_bfd == abfd - && ptr->section != (asection *) NULL - && ((ptr->flags & BSF_OLD_COMMON)== 0)) - { - cache_ptr->addend = -(ptr->section->vma + ptr->value); - } - else { - cache_ptr->addend = 0; - } - - cache_ptr->address -= asect->vma; - - cache_ptr->section = (asection *) NULL; - -#if I960 - cache_ptr->howto = howto_table + dst.r_type; -#endif -#if M68 - cache_ptr->howto = howto_table + dst.r_type - R_RELBYTE; -#endif -#if M88 - if (dst.r_type >= R_PCR16L && dst.r_type <= R_VRT32) { - cache_ptr->howto = howto_table + dst.r_type - R_PCR16L; - cache_ptr->addend += dst.r_offset << 16; - } - else { - BFD_ASSERT(0); - } -#endif - - } - - } - - asect->relocation = reloc_cache; - return true; - } - - -/* This is stupid. This function should be a boolean predicate */ -static unsigned int -coff_canonicalize_reloc(abfd, section, relptr, symbols) -bfd *abfd; -sec_ptr section; -arelent **relptr; -asymbol **symbols; - { - arelent *tblptr = section->relocation; - unsigned int count = 0; - if (!(tblptr || coff_slurp_reloc_table(abfd, section, symbols))) - return 0; - tblptr = section->relocation; - if (!tblptr) - return 0; - - for (; count++ < section->reloc_count;) - *relptr++ = tblptr++; - - *relptr = 0; - - return section->reloc_count; - } - - -/* -provided a bfd, a section and an offset into the section, calculate and -return the name of the source file and the line nearest to the wanted -location. -*/ - -static boolean -DEFUN(coff_find_nearest_line,(abfd, - section, - symbols, - offset, - filename_ptr, - functionname_ptr, - line_ptr), - bfd *abfd AND - asection *section AND - asymbol **symbols AND - bfd_vma offset AND - CONST char **filename_ptr AND - CONST char **functionname_ptr AND - unsigned int *line_ptr) -{ - static bfd *cache_abfd; - static asection *cache_section; - static bfd_vma cache_offset; - static unsigned int cache_i; - static alent *cache_l; - - unsigned int i = 0; - struct icofdata *cof = obj_icof(abfd); - /* Run through the raw syments if available */ - struct internal_syment *p; - alent *l; - unsigned int line_base = 0; - - - *filename_ptr = 0; - *functionname_ptr = 0; - *line_ptr = 0; - - /* Don't try and find line numbers in a non coff file */ - if (abfd->xvec->flavour != bfd_target_coff_flavour_enum) - return false; - - if (cof == (struct icofdata *)NULL) - return false; - - p = cof->raw_syments; - /* - I don't know for sure what's right, but this isn't it. First off, an - object file may not have any C_FILE's in it. After - get_normalized_symtab(), it should have at least 1, the one I put - there, but otherwise, all bets are off. Point #2, the first C_FILE - isn't necessarily the right C_FILE because any given object may have - many. I think you'll have to track sections as they coelesce in order - to find the C_STAT symbol for this section. Then you'll have to work - backwards to find the previous C_FILE, or choke if you get to a C_STAT - for the same kind of section. That will mean that the original object - file didn't have a C_FILE. xoxorich. - */ - -#ifdef WEREBEINGPEDANTIC - return false; -#endif - - for (i = 0; i < cof->raw_syment_count; i++) { - if (p->n_sclass == C_FILE) { - /* File name is embeded in auxent */ - /* - This isn't right. The fname should probably be normalized - during get_normalized_symtab(). In any case, what was here - wasn't right because a SYMENT.n_name isn't an - AUXENT.x_file.x_fname. xoxorich. - */ - - *filename_ptr = ((AUXENT *) (p + 1))->x_file.x_fname; - break; - } - p += 1 + p->n_numaux; - } - /* Now wander though the raw linenumbers of the section */ - /* - If this is the same bfd as we were previously called with and this is - the same section, and the offset we want is further down then we can - prime the lookup loop - */ - if (abfd == cache_abfd && - section == cache_section && - offset >= cache_offset) { - i = cache_i; - l = cache_l; - } - else { - i = 0; - l = section->lineno; - } - - for (; i < section->lineno_count; i++) { - if (l->line_number == 0) { - /* Get the symbol this line number points at */ - coff_symbol_type *coff = (coff_symbol_type *) (l->u.sym); - *functionname_ptr = coff->symbol.name; - if (coff->native) { - struct internal_syment *s = coff->native; - s = s + 1 + s->n_numaux; - /* - S should now point to the .bf of the function - */ - if (s->n_numaux) { - /* - The linenumber is stored in the auxent - */ - union internal_auxent *a = (union internal_auxent *) (s + 1); - line_base = a->x_sym.x_misc.x_lnsz.x_lnno; - } - } - } - else { - if (l->u.offset > offset) - break; - *line_ptr = l->line_number + line_base + 1; - } - l++; - } - - cache_abfd = abfd; - cache_section = section; - cache_offset = offset; - cache_i = i; - cache_l = l; - return true; -} - -#ifdef GNU960 -file_ptr -coff_sym_filepos(abfd) -bfd *abfd; - { - return obj_sym_filepos(abfd); - } -#endif - - -static int -DEFUN(coff_sizeof_headers,(abfd, reloc), - bfd *abfd AND - boolean reloc) - { - size_t size; - - if (reloc == false) { - size = FILHSZ + AOUTSZ; - } - else { - size = FILHSZ; - } - - size += abfd->section_count * SCNHSZ; - return size; - } - - -#define coff_core_file_failing_command _bfd_dummy_core_file_failing_command -#define coff_core_file_failing_signal _bfd_dummy_core_file_failing_signal -#define coff_core_file_matches_executable_p _bfd_dummy_core_file_matches_executable_p -#define coff_slurp_armap bfd_slurp_coff_armap -#define coff_slurp_extended_name_table _bfd_slurp_extended_name_table -#define coff_truncate_arname bfd_dont_truncate_arname -#define coff_openr_next_archived_file bfd_generic_openr_next_archived_file -#define coff_generic_stat_arch_elt bfd_generic_stat_arch_elt -#define coff_get_section_contents bfd_generic_get_section_contents -#define coff_close_and_cleanup bfd_generic_close_and_cleanup diff --git a/bfd/coff-i386.c b/bfd/coff-i386.c deleted file mode 100644 index c5c3dd6a4ab..00000000000 --- a/bfd/coff-i386.c +++ /dev/null @@ -1,100 +0,0 @@ -/* BFD back-end for Intel 386 COFF files. - Copyright (C) 1990-1991 Free Software Foundation, Inc. - Written by Cygnus Support. - -This file is part of BFD, the Binary File Descriptor library. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* $Id$ */ - -#define I386 1 -#include -#include -#include "bfd.h" -#include "libbfd.h" -#include "obstack.h" -#include "i386coff.h" -#include "internalcoff.h" -#include "libcoff.h" - - -static reloc_howto_type howto_table[] = -{ - {0}, - {1}, - {2}, - {3}, - {4}, - {5}, - HOWTO(R_DIR32, 0, 2, 32, false, 0, true,true,0,"dir32", true, 0xffffffff,0xffffffff, false), - {7}, - {010}, - {011}, - {012}, - {013}, - {014}, - {015}, - {016}, - HOWTO(R_RELBYTE, 0, 0, 8, false, 0, true, true,0,"8", true, 0x000000ff,0x000000ff, false), - HOWTO(R_RELWORD, 0, 1, 16, false, 0, true, true,0,"16", true, 0x0000ffff,0x0000ffff, false), - HOWTO(R_RELLONG, 0, 2, 32, false, 0, true, true,0,"32", true, 0xffffffff,0xffffffff, false), - HOWTO(R_PCRBYTE, 0, 0, 8, true, 0, false, true,0,"DISP8", true, 0x000000ff,0x000000ff, false), - HOWTO(R_PCRWORD, 0, 1, 16, true, 0, false, true,0,"DISP16", true, 0x0000ffff,0x0000ffff, false), - HOWTO(R_PCRLONG, 0, 2, 32, true, 0, false, true,0,"DISP32", true, 0xffffffff,0xffffffff, false), -}; - -/* Turn a howto into a reloc nunmber */ - -#define SELECT_RELOC(x,howto) { x = howto->type; } -#define BADMAG(x) I386BADMAG(x) -#include "coffcode.h" - -#define coff_write_armap bsd_write_armap - -bfd_target *i3coff_object_p(a) -bfd *a ; -{ return coff_object_p(a); } - -bfd_target i386coff_vec = -{ - "i386coff", /* name */ - bfd_target_coff_flavour, - false, /* data byte order is little */ - false, /* header byte order is little */ - - (HAS_RELOC | EXEC_P | /* object flags */ - HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT), - - (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ - '/', /* ar_pad_char */ - 15, /* ar_max_namelen */ - - 2, /* minimum alignment power */ - _do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putl16, /* data */ - _do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putl16, /* hdrs */ - -/* Note that we allow an object file to be treated as a core file as well. */ - {_bfd_dummy_target, i3coff_object_p, /* bfd_check_format */ - bfd_generic_archive_p, i3coff_object_p}, - {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */ - bfd_false}, - {bfd_false, coff_write_object_contents, /* bfd_write_contents */ - _bfd_write_archive_contents, bfd_false}, - - JUMP_TABLE(coff), - COFF_SWAP_TABLE - }; diff --git a/bfd/coff-i960.c b/bfd/coff-i960.c deleted file mode 100644 index 4c3b7e102d7..00000000000 --- a/bfd/coff-i960.c +++ /dev/null @@ -1,200 +0,0 @@ -/* Intel 960 COFF support for BFD. */ - -/* Copyright (C) 1990, 1991 Free Software Foundation, Inc. - -This file is part of BFD, the Binary File Diddler. - -BFD 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 1, or (at your option) -any later version. - -BFD 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 BFD; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* $Id$ */ - -#define I960 1 -#define BADMAG(x) I960BADMAG(x) - -#include -#include -#include "bfd.h" -#include "libbfd.h" -#include "obstack.h" -#include "intel-coff.h" -#include "libcoff.h" /* to allow easier abstraction-breaking */ - - -#define CALLS 0x66003800 /* Template for 'calls' instruction */ -#define BAL 0x0b000000 /* Template for 'bal' instruction */ -#define BAL_MASK 0x00ffffff - -static bfd_reloc_status_enum_type -optcall_callback(abfd, reloc_entry, symbol_in, data, ignore_input_section) -bfd *abfd; -arelent *reloc_entry; -asymbol *symbol_in; -unsigned char *data; -asection *ignore_input_section; -{ - /* This item has already been relocated correctly, but we may be - * able to patch in yet better code - done by digging out the - * correct info on this symbol */ - bfd_reloc_status_enum_type result; - coff_symbol_type *cs = coffsymbol(symbol_in); - - /* So the target symbol has to be of coff type, and the symbol - has to have the correct native information within it */ - if ((cs->symbol.the_bfd->xvec->flavour != bfd_target_coff_flavour_enum) - || (cs->native == (struct internal_syment *)NULL)) { - /* This is interesting, consider the case where we're outputting */ - /* coff from a mix n match input, linking from coff to a symbol */ - /* defined in a bout file will cause this match to be true. Should */ - /* I complain ? - This will only work if the bout symbol is non */ - /* leaf. */ - result = bfd_reloc_dangerous; - } - else { - switch (cs->native->n_sclass) - { - case C_LEAFSTAT: - case C_LEAFEXT: - /* This is a call to a leaf procedure, replace instruction with a bal - to the correct location */ - { - union internal_auxent *aux = (union internal_auxent *)(cs->native+2); - int word = bfd_get_32(abfd, data + reloc_entry->address); - int olf = (aux->x_bal.x_balntry - cs->native->n_value); - BFD_ASSERT(cs->native->n_numaux==2); - /* We replace the original call instruction with a bal to */ - /* the bal entry point - the offset of which is described in the */ - /* 2nd auxent of the original symbol. We keep the native sym and */ - /* auxents untouched, so the delta between the two is the */ - /* offset of the bal entry point */ - - word = ((word + olf) & BAL_MASK) | BAL; - bfd_put_32(abfd, word, data+reloc_entry->address); - } - result = bfd_reloc_ok; - break; - case C_SCALL: - { - /* This is a call to a system call, replace with a calls to # */ - BFD_ASSERT(0); - } - break; - default: - result = bfd_reloc_ok; - break; - } - } - return result; -} - - - -static reloc_howto_type howto_table[] = -{ - {0}, - {1}, - {2}, - {3}, - {4}, - {5}, - {6}, - {7}, - {8}, - {9}, - {10}, - {11}, - {12}, - {13}, - {14}, - {15}, - {16}, - - { (unsigned int) R_RELLONG, 0, 2, 32,false, 0, true, true, - 0,"rellong", true, 0xffffffff, 0xffffffff}, - {18}, - {19}, - {20}, - {21}, - {22}, - {23}, - {24}, - - { R_IPRMED, 0, 2, 24,true,0, true, true,0,"iprmed ", true, - 0x00ffffff, 0x00ffffff}, - {26}, - - { R_OPTCALL, 0,2,24,true,0, true, true, optcall_callback, - "optcall", true, 0x00ffffff, 0x00ffffff}, - -}; - -/* The real code is in coffcode.h */ - -#include "coffcode.h" - -bfd_target icoff_little_vec = -{ - "coff-Intel-little", /* name */ - bfd_target_coff_flavour_enum, - false, /* data byte order is little */ - false, /* header byte order is little */ - - (HAS_RELOC | EXEC_P | /* object flags */ - HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT), - - (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ - '/', /* ar_pad_char */ - 15, /* ar_max_namelen */ - - _do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putl16, /* data */ - _do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putl16, /* hdrs */ - - {_bfd_dummy_target, coff_object_p, /* bfd_check_format */ - bfd_generic_archive_p, _bfd_dummy_target}, - {bfd_false, coff_mkobject, /* bfd_set_format */ - _bfd_generic_mkarchive, bfd_false}, - {bfd_false, coff_write_object_contents, /* bfd_write_contents */ - _bfd_write_archive_contents, bfd_false}, - JUMP_TABLE(coff) - }; - - -bfd_target icoff_big_vec = -{ - "coff-Intel-big", /* name */ - bfd_target_coff_flavour_enum, - false, /* data byte order is little */ - true, /* header byte order is big */ - - (HAS_RELOC | EXEC_P | /* object flags */ - HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT), - - (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ - '/', /* ar_pad_char */ - 15, /* ar_max_namelen */ - -_do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putl16, /* data */ -_do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* hdrs */ - - {_bfd_dummy_target, coff_object_p, /* bfd_check_format */ - bfd_generic_archive_p, _bfd_dummy_target}, - {bfd_false, coff_mkobject, /* bfd_set_format */ - _bfd_generic_mkarchive, bfd_false}, - {bfd_false, coff_write_object_contents, /* bfd_write_contents */ - _bfd_write_archive_contents, bfd_false}, - JUMP_TABLE(coff), -COFF_SWAP_TABLE -}; diff --git a/bfd/coff-m68k.c b/bfd/coff-m68k.c deleted file mode 100644 index c3ae26e0a75..00000000000 --- a/bfd/coff-m68k.c +++ /dev/null @@ -1,83 +0,0 @@ -/* Copyright (C) 1990, 1991 Free Software Foundation, Inc. - -This file is part of BFD, the Binary File Diddler. - -BFD 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 1, or (at your option) -any later version. - -BFD 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 BFD; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - - -/* $Id$ */ - -#define M68 1 -#include -#include -#include "bfd.h" -#include "libbfd.h" -#include "obstack.h" -#include "m68kcoff.h" -#include "libcoff.h" - - -static reloc_howto_type howto_table[] = -{ - HOWTO(R_RELBYTE, 0, 0, 8, false, 0, true, true,0,"8", true, 0x000000ff,0x000000ff, false), - HOWTO(R_RELWORD, 0, 1, 16, false, 0, true, true,0,"16", true, 0x0000ffff,0x0000ffff, false), - HOWTO(R_RELLONG, 0, 2, 32, false, 0, true, true,0,"32", true, 0xffffffff,0xffffffff, false), - HOWTO(R_PCRBYTE, 0, 0, 8, true, 0, false, true,0,"DISP8", true, 0x000000ff,0x000000ff, false), - HOWTO(R_PCRWORD, 0, 1, 16, true, 0, false, true,0,"DISP16", true, 0x0000ffff,0x0000ffff, false), - HOWTO(R_PCRLONG, 0, 2, 32, true, 0, false, true,0,"DISP32", true, 0xffffffff,0xffffffff, false), -}; - - -/* Turn a howto into a reloc nunmber */ - -#define SELECT_RELOC(x,howto) { x = howto_table[howto->size +(int)howto->pc_relative*3].type; } -#define BADMAG(x) M68KBADMAG(x) -#include "coff-code.h" - - -#define coff_write_armap bsd_write_armap - - -bfd_target m68kcoff_vec = -{ - "m68kcoff", /* name */ - bfd_target_coff_flavour_enum, - true, /* data byte order is big */ - true, /* header byte order is big */ - - (HAS_RELOC | EXEC_P | /* object flags */ - HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT), - - (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ - '/', /* ar_pad_char */ - 15, /* ar_max_namelen */ - -_do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* data */ -_do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* hdrs */ - - {_bfd_dummy_target, coff_object_p, /* bfd_check_format */ - bfd_generic_archive_p, _bfd_dummy_target}, - {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */ - bfd_false}, - {bfd_false, coff_write_object_contents, /* bfd_write_contents */ - _bfd_write_archive_contents, bfd_false}, - - JUMP_TABLE(coff) - - }; - - - diff --git a/bfd/coff-m88k.c b/bfd/coff-m88k.c deleted file mode 100644 index d4c10bf2018..00000000000 --- a/bfd/coff-m88k.c +++ /dev/null @@ -1,117 +0,0 @@ -/* Motorola 88000 COFF support ("Binary Compatability Standard") for BFD. - Copyright (C) 1990-1991 Free Software Foundation, Inc. - Written by Cygnus Support. - -This file is part of BFD, the Binary File Descriptor library. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* $Id$ */ - -#define M88 1 /* Customize various include files */ -#include "bfd.h" -#include "sysdep.h" -#include "libbfd.h" -#include "obstack.h" -#include "coff-m88k.h" -#include "internalcoff.h" -#include "libcoff.h" - -/* Provided the symbol, returns the value reffed */ -#define HOWTO_PREPARE(relocation, symbol) \ - { \ - if (symbol != (asymbol *)NULL) { \ - if (symbol->flags & BSF_FORT_COMM) { \ - relocation = 0; \ - } \ - else { \ - relocation = symbol->value; \ - } \ - } \ - if (symbol->section != (asection *)NULL) { \ - relocation += symbol->section->output_section->vma + \ - symbol->section->output_offset; \ - } \ -} - - - -static bfd_reloc_status_type -DEFUN(howto_hvrt16,(abfd, reloc_entry, symbol_in, data, ignore_input_section), -bfd *abfd AND -arelent *reloc_entry AND -asymbol *symbol_in AND -unsigned char *data AND -asection *ignore_input_section) -{ - long relocation; - bfd_vma addr = reloc_entry->address; - long x = bfd_get_16(abfd, (bfd_byte *)data + addr); - - HOWTO_PREPARE(relocation, symbol_in); - - x = (x + relocation + reloc_entry->addend) >> 16; - - bfd_put_16(abfd, x, (bfd_byte *)data + addr); - return bfd_reloc_ok; -} - - - -static reloc_howto_type howto_table[] = -{ - HOWTO(R_PCR16L,02,1,16,true, 0,false,true,0,"PCR16L",false,0x0000ffff,0x0000ffff,true), - HOWTO(R_PCR26L,02,2,16,true, 0,false,true,0,"PCR26L",false,0x03ffffff,0x03ffffff,true), - HOWTO(R_VRT16, 00,1,16,false,0,false,true,0,"VRT16", false,0x0000ffff,0x0000ffff,true), - HOWTO(R_HVRT16,16,1,16,false,0,false,true,howto_hvrt16,"HVRT16",false,0x0000ffff,0x0000ffff,true), - HOWTO(R_LVRT16,00,1,16,false,0,false,true,0,"LVRT16",false,0x0000ffff,0x0000ffff,true), - HOWTO(R_VRT32, 00,2,32,false,0,false,true,0,"VRT32", false,0xffffffff,0xffffffff,true), -}; - - - -#define BADMAG(x) MC88BADMAG(x) -#include "coffcode.h" - -#undef coff_write_armap - -bfd_target m88kbcs_vec = -{ - "m88kbcs", /* name */ - bfd_target_coff_flavour, - true, /* data byte order is big */ - true, /* header byte order is big */ - - (HAS_RELOC | EXEC_P | /* object flags */ - HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT), - - (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ - '/', /* ar_pad_char */ - 15, /* ar_max_namelen */ - 3, /* default alignment power */ - _do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* data */ - _do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* hdrs */ - - {_bfd_dummy_target, coff_object_p, /* bfd_check_format */ - bfd_generic_archive_p, _bfd_dummy_target}, - {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */ - bfd_false}, - {bfd_false, coff_write_object_contents, /* bfd_write_contents */ - _bfd_write_archive_contents, bfd_false}, - - JUMP_TABLE(coff), - COFF_SWAP_TABLE -}; diff --git a/bfd/coff-mips.c b/bfd/coff-mips.c deleted file mode 100644 index 6db7df8b155..00000000000 --- a/bfd/coff-mips.c +++ /dev/null @@ -1,101 +0,0 @@ -/* MIPS Extended-Coff back-end for BFD. - Copyright (C) 1990-1991 Free Software Foundation, Inc. - Written by Per Bothner. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include "bfd.h" -#include "sysdep.h" -#include "libbfd.h" -#include "ecoff.h" -#include "internalcoff.h" -#include "libcoff.h" /* to allow easier abstraction-breaking */ -#include "trad-core.h" - -#define BADMAG(x) ECOFFBADMAG(x) - -/* Define NO_COFF_SYMBOLS and NO_COFF_LINENOS to avoid coffcode.h - defining a mess of useless functions. */ -#define NO_COFF_SYMBOLS -#define NO_COFF_LINENOS -/* Define MIPS to get MIPS magic numbers and such */ -#define MIPS 1 -#include "coffcode.h" - -/* We do not implement symbols for ecoff. */ -#define coff_get_symtab_upper_bound (PROTO(unsigned int, (*),(bfd *)))bfd_false -#define coff_get_symtab (PROTO(unsigned int, (*), (bfd *, asymbol **)))bfd_0 -#define coff_print_symbol \ - (PROTO(void,(*),(bfd *, PTR, asymbol *, enum bfd_print_symbol))) bfd_void -#define coff_swap_sym_in (PROTO(void,(*),(bfd *,PTR,PTR))) bfd_void -#define coff_swap_aux_in (PROTO(void,(*),(bfd *,PTR,int,int,PTR))) bfd_void - -/* We do not implement linenos for ecoff. */ -#define coff_get_lineno (struct lineno_cache_entry *(*)()) bfd_nullvoidptr -#define coff_swap_lineno_in (PROTO(void,(*),(bfd *,PTR,PTR))) bfd_void -#define coff_find_nearest_line (PROTO(boolean, (*),(bfd*,asection*,asymbol**,bfd_vma, CONST char**, CONST char**, unsigned int *))) bfd_false - -bfd_target ecoff_little_vec = - {"ecoff-littlemips", /* name */ - bfd_target_coff_flavour, - false, /* data byte order is little */ - false, /* header byte order is little */ - - (HAS_RELOC | EXEC_P | /* object flags */ - HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT), - - (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* sect flags */ - '/', /* ar_pad_char */ - 15, /* ar_max_namelen */ - 3, /* minimum alignment power */ -_do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putl16, /* data */ -_do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putl16, /* hdrs */ - - {_bfd_dummy_target, coff_object_p, /* bfd_check_format */ - bfd_generic_archive_p, _bfd_dummy_target}, - {bfd_false, coff_mkobject, bfd_false, /* bfd_set_format */ - bfd_false}, - {bfd_false, coff_write_object_contents, bfd_false, bfd_false}, - JUMP_TABLE (coff) -}; - -bfd_target ecoff_big_vec = - {"ecoff-bigmips", /* name */ - bfd_target_coff_flavour, - true, /* data byte order is big */ - true, /* header byte order is big */ - - (HAS_RELOC | EXEC_P | /* object flags */ - HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT), - - (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* sect flags */ - ' ', /* ar_pad_char */ - 16, /* ar_max_namelen */ - 3, /* minimum alignment power */ - _do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, - _do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, - {_bfd_dummy_target, coff_object_p, /* bfd_check_format */ - bfd_generic_archive_p, _bfd_dummy_target}, - {bfd_false, coff_mkobject, bfd_false, /* bfd_set_format */ - bfd_false}, - {bfd_false, coff_write_object_contents, /* bfd_write_contents */ - bfd_false, bfd_false}, - JUMP_TABLE(coff), - COFF_SWAP_TABLE -}; diff --git a/bfd/coff-rs6000.c b/bfd/coff-rs6000.c deleted file mode 100644 index 1787bfa0c84..00000000000 --- a/bfd/coff-rs6000.c +++ /dev/null @@ -1,498 +0,0 @@ -/* IBM RS/6000 "XCOFF" back-end for BFD. - Copyright (C) 1990, 1991 Free Software Foundation, Inc. - Written by Metin G. Ozisik, Mimi Phûông-ThÃ¥o Võ, and John Gilmore. - 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 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* This port currently only handles reading object files -- no archive - support, no core files, and no writing. FIXME. */ - -/* Internalcoff.h and coffcode.h modify themselves based on this flag. */ -#define RS6000COFF_C 1 - -#include "bfd.h" -#include "sysdep.h" -#include "libbfd.h" -#include "obstack.h" -#include "internalcoff.h" -#include "coff-rs6000.h" -#include "libcoff.h" - -/* The main body of code is in coffcode.h. */ -#include "coffcode.h" - - -#if 0 -/* These are not yet ready for prime time. */ -#define coff_core_file_matches_executable_p \ - rs6000coff_core_file_matches_executable_p -#define coff_get_section_contents rs6000coff_get_section_contents -#define coff_openr_next_archived_file rs6000coff_openr_next_archived_file -#define coff_write_armap rs6000coff_write_armap -#define coff_stat_arch_elt rs6000coff_stat_arch_elt -#define coff_snarf_ar_hdr rs6000coff_snarf_ar_hdr -#define coff_mkarchive rs6000coff_mkarchive - -static bfd_target *rs6000coff_archive_p (); -static bfd_target *rs6000coff_core_p (); -static bfd_target *rs6000coff_object_p (); -static bfd_target *rs6000coff_real_object_p (); -#endif - -bfd_target rs6000coff_vec = -{ - "coff-rs6000", /* name */ - bfd_target_coff_flavour, - true, /* data byte order is big */ - true, /* header byte order is big */ - - (HAS_RELOC | EXEC_P | /* object flags */ - HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT), - - (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ - '/', /* ar_pad_char */ - 15, /* ar_max_namelen??? FIXMEmgo */ - 3, /* default alignment power */ - - _do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* data */ - _do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* hdrs */ - - {_bfd_dummy_target, coff_object_p, /* bfd_check_format */ - bfd_generic_archive_p, _bfd_dummy_target}, - {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */ - bfd_false}, - {bfd_false, coff_write_object_contents, /* bfd_write_contents */ - _bfd_write_archive_contents, bfd_false}, - - JUMP_TABLE(coff), - COFF_SWAP_TABLE - -}; - - -#if 0 /* we don't have include file for this yet */ -/* ------------------------------------------------------------------------ */ -/* Support for archive file stuff.. */ -/* Stolen from Damon A. Parmazel's `bfd' portation. */ -/* ------------------------------------------------------------------------ */ - -#include "/usr/include/ar.h" /* doesn't do it. */ - - -#define arch_hdr(bfd) \ - ((struct ar_hdr *) \ - (((struct areltdata *)((bfd)->arelt_data))->arch_header)) - - -static boolean -rs6000coff_mkarchive (abfd) - bfd *abfd; -{ - bfd_error = invalid_operation; /* write not supported */ -} - - -/* This functions reads an arch header and returns an areltdata pointer, or - NULL on error. - - Presumes the file pointer is already in the right place (ie pointing - to the ar_hdr in the file). Moves the file pointer; on success it - should be pointing to the front of the file contents; on failure it - could have been moved arbitrarily. -*/ - -struct areltdata * -rs6000coff_snarf_ar_hdr (abfd) - bfd *abfd; -{ - extern int errno; - - struct { - struct ar_hdr hdr; - char namebuf[256]; - } h; - int size; - struct areltdata *ared; - unsigned int namelen = 0; - char *allocptr; - - size = sizeof (h.hdr); - if (bfd_read(&h.hdr, 1, size, abfd) != size) { - bfd_error = no_more_archived_files; - return NULL; - } - size = atoi(h.hdr.ar_namlen); /* ar_name[] length */ - size += size & 1; - - if (bfd_read(&h.hdr._ar_name.ar_name[2], 1, size, abfd) != size) { - bfd_error = no_more_archived_files; - return NULL; - } - - if (strncmp(h.hdr._ar_name.ar_fmag + size, AIAFMAG, 2)) { - bfd_error = malformed_archive; - return NULL; - } - - h.hdr._ar_name.ar_name[size] = 0; /* terminate filename */ - - /* - * if the filename is NULL, we're (probably) at the end. - */ - if (size == 0) { - bfd_error = no_more_archived_files; - return NULL; - } - - size += sizeof (h.hdr); - allocptr = bfd_zalloc(abfd, sizeof (*ared) + size); - - if (allocptr == NULL) { - bfd_error = no_memory; - return NULL; - } - - ared = (struct areltdata *) allocptr; - - ared->arch_header = (void *) (allocptr + sizeof (struct areltdata)); - memcpy ((char *) ared->arch_header, &h.hdr, size); - ared->parsed_size = atoi(h.hdr.ar_size); - ared->filename = ((AR_HDR*) ared->arch_header)->_ar_name.ar_name; - - return ared; -} - -/* - * xcoff_openr_next_archived_file - xcoff has nxt/prv seek addrs. - */ -static bfd * -rs6000coff_openr_next_archived_file(archive, last_file) - bfd *archive, *last_file; -{ - file_ptr filestart; - - if (!last_file) - filestart = bfd_ardata(archive)->first_file_filepos; - else - filestart = atol(arch_hdr(last_file)->ar_nxtmem); - - return get_elt_at_filepos (archive, filestart); -} - - -static bfd_target * -rs6000coff_archive_p (abfd) - bfd *abfd; -{ - struct fl_hdr hdr; - register struct artdata *art; - - if (bfd_read (&hdr, 1, sizeof (hdr), abfd) != sizeof (hdr)) { - bfd_error = wrong_format; - return 0; - } - - if (strncmp(hdr.fl_magic, AIAMAG, SAIAMAG)) { - bfd_error = wrong_format; - return 0; - } - - /* - * bfd_ardata() accesses the bfd->tdata field. - */ - abfd->tdata = (void *) bfd_zalloc(abfd, sizeof (*art) + sizeof (hdr)); - if ((art = bfd_ardata (abfd)) == NULL) { - bfd_error = no_memory; - return 0; - } - - art->first_file_filepos = atoi(hdr.fl_fstmoff); - *(struct fl_hdr *) (1 + art) = hdr; - - /* - * slurp in the member table, which I thing is the armap equivalent. - xcoff_slurp_armap(abfd); - */ - - if (abfd->obj_arch == bfd_arch_unknown) /* FIXME!!! */ - abfd->obj_arch = bfd_arch_rs6000; - - return abfd->xvec; -} - - -static int -rs6000coff_stat_arch_elt(abfd, buf) - bfd *abfd; - struct stat *buf; -{ - struct ar_hdr *hdr; - char *aloser; - - if (abfd->arelt_data == NULL) { - bfd_error = invalid_operation; - return -1; - } - - hdr = arch_hdr (abfd); - -#define foo(arelt, stelt, size) \ - buf->stelt = strtol (hdr->arelt, &aloser, size); \ - if (aloser == hdr->arelt) return -1; - - foo (ar_date, st_mtime, 10); - foo (ar_uid, st_uid, 10); - foo (ar_gid, st_gid, 10); - foo (ar_mode, st_mode, 8); - foo (ar_size, st_size, 10); - - return 0; -} - -static boolean -rs6000coff_write_armap (arch, elength, map, orl_count, stridx) - bfd *arch; - unsigned int elength; - struct orl *map; -{ - bfd_error = invalid_operation; - return false; -} - - -#endif /* if 0 */ - -#if 0 /* not sure if this will work on all hosts yet! */ -#ifdef AOUTHDR -#undef AOUTHDR -#endif - -/* ------------------------------------------------------------------------ */ -/* Support for core file stuff.. */ -/* ------------------------------------------------------------------------ */ - -#include -#include -#include - - -/* Number of special purpose registers supported bygdb. This value should match - `tm.h' in gdb directory. Clean this mess up and use the macros in sys/reg.h. - FIXMEmgo. */ - -#define NUM_OF_SPEC_REGS 7 -#define STACK_END_ADDR 0x2ff80000 - -#define core_hdr(bfd) (((Rs6kCorData*)(bfd->tdata))->hdr) -#define core_datasec(bfd) (((Rs6kCorData*)(bfd->tdata))->data_section) -#define core_stacksec(bfd) (((Rs6kCorData*)(bfd->tdata))->stack_section) -#define core_regsec(bfd) (((Rs6kCorData*)(bfd->tdata))->reg_section) -#define core_reg2sec(bfd) (((Rs6kCorData*)(bfd->tdata))->reg2_section) - -/* These are stored in the bfd's tdata */ -typedef struct { - struct core *hdr; /* core file header */ - asection *data_section, - *stack_section, - *reg_section, /* section for GPRs and special registers. */ - *reg2_section; /* section for FPRs. */ -} Rs6kCorData; - - -/* Decide if a given bfd represents a `core' file or not. There really is no - magic number or anything like, in rs6000coff. */ - -static bfd_target * -rs6000coff_core_p (abfd) - bfd *abfd; -{ - int fd; - struct core_dump coredata; - struct stat statbuf; - char *tmpptr; - - /* Use bfd_xxx routines, rather than O/S primitives to read coredata. FIXMEmgo */ - fd = open (abfd->filename, O_RDONLY); - - fstat (fd, &statbuf); - read (fd, &coredata, sizeof (struct core_dump)); - - close (fd); - - if (coredata.c_tab < (sizeof (coredata.c_u) + (int)&coredata.c_u - (int)&coredata.c_signo) || - coredata.c_tab >= statbuf.st_size || - (long)coredata.c_stack <= (long)coredata.c_tab ) { - return NULL; - } - -/* - If it looks like core file, then..... - read core file header..... (maybe you've done it above..) -*/ - - /* maybe you should alloc space for the whole core chunk over here!! FIXMEmgo */ - tmpptr = (char*)bfd_zalloc (abfd, sizeof (Rs6kCorData)); - set_tdata (abfd, tmpptr); - - /* .stack section. */ - if ((core_stacksec (abfd) = (asection*) bfd_zalloc (abfd, sizeof (asection))) - == NULL) { - bfd_error = no_memory; - /* bfd_release (abfd, ???? ) */ - return NULL; - } - core_stacksec (abfd)->name = ".stack"; - core_stacksec (abfd)->flags = SEC_ALLOC + SEC_LOAD; - core_stacksec (abfd)->size = coredata.c_size; - core_stacksec (abfd)->vma = STACK_END_ADDR - coredata.c_size; - core_stacksec (abfd)->filepos = coredata.c_stack; /*???? */ - - /* .reg section for GPRs and special registers. */ - if ((core_regsec (abfd) = (asection*) bfd_zalloc (abfd, sizeof (asection))) - == NULL) { - bfd_error = no_memory; - /* bfd_release (abfd, ???? ) */ - return NULL; - } - core_regsec (abfd)->name = ".reg"; - core_regsec (abfd)->flags = SEC_ALLOC; - core_regsec (abfd)->size = (32 + NUM_OF_SPEC_REGS) * 4; - core_regsec (abfd)->vma = NULL; /* not used?? */ - core_regsec (abfd)->filepos = - (char*)&coredata.c_u.u_save - (char*)&coredata; - - /* .reg2 section for FPRs (floating point registers). */ - if ((core_reg2sec (abfd) = (asection*) bfd_zalloc (abfd, sizeof (asection))) - == NULL) { - bfd_error = no_memory; - /* bfd_release (abfd, ???? ) */ - return NULL; - } - core_reg2sec (abfd)->name = ".reg2"; - core_reg2sec (abfd)->flags = SEC_ALLOC; - core_reg2sec (abfd)->size = 8 * 32; /* 32 FPRs. */ - core_reg2sec (abfd)->vma = NULL; /* not used?? */ - core_reg2sec (abfd)->filepos = - (char*)&coredata.c_u.u_save.fpr[0] - (char*)&coredata; - - /* set up section chain here. */ - abfd->section_count = 3; - abfd->sections = core_stacksec (abfd); - core_stacksec (abfd)->next = core_regsec(abfd); - core_regsec (abfd)->next = core_reg2sec (abfd); - core_reg2sec (abfd)->next = NULL; - - return abfd->xvec; /* this is garbage for now. */ -} - - - -/* return `true' if given core is from the given executable.. */ -static boolean -rs6000coff_core_file_matches_executable_p (core_bfd, exec_bfd) - bfd *core_bfd; - bfd *exec_bfd; -{ - FILE *fd; - struct core_dump coredata; - struct ld_info ldinfo; - char pathname [1024]; - char *str1, *str2; - - /* Use bfd_xxx routines, rather than O/S primitives, do error checking!! - FIXMEmgo */ - fd = fopen (core_bfd->filename, "r"); - - fread (&coredata, sizeof (struct core_dump), 1, fd); - fseek (fd, (long)coredata.c_tab, 0); - fread (&ldinfo, (char*)&ldinfo.ldinfo_filename[0] - (char*)&ldinfo.ldinfo_next, - 1, fd); - fscanf (fd, "%s", pathname); - printf ("path: %s\n", pathname); - - str1 = strrchr (pathname, '/'); - str2 = strrchr (exec_bfd->filename, '/'); - - /* step over character '/' */ - str1 = str1 ? str1+1 : &pathname[0]; - str2 = str2 ? str2+1 : exec_bfd->filename; - - fclose (fd); - return strcmp (str1, str2); -} - - -static boolean -rs6000coff_get_section_contents (abfd, section, location, offset, count) - bfd *abfd; - sec_ptr section; - PTR location; - file_ptr offset; - int count; -{ - if (count == 0) - return true; - - /* Reading a core file's sections will be slightly different. For the - rest of them we can use bfd_generic_get_section_contents () I suppose. */ - /* Make sure this routine works for any bfd and any section. FIXMEmgo. */ - - if (abfd->format == bfd_core && strcmp (section->name, ".reg") == 0) { - - struct mstsave mstatus; - int regoffset = (char*)&mstatus.gpr[0] - (char*)&mstatus; - - /* Assert that the only way this code will be executed is reading the - whole section. */ - if (offset || count != (sizeof(mstatus.gpr) + (4 * NUM_OF_SPEC_REGS))) - printf ("ERROR! in rs6000coff_get_section_contents()\n"); - - /* for `.reg' section, `filepos' is a pointer to the `mstsave' structure - in the core file. */ - - /* read GPR's into the location. */ - if ( bfd_seek(abfd, section->filepos + regoffset, SEEK_SET) == -1 - || bfd_read(location, 1, sizeof (mstatus.gpr), abfd) != sizeof (mstatus.gpr)) - return (false); /* on error */ - - /* increment location to the beginning of special registers in the section, - reset register offset value to the beginning of first special register - in mstsave structure, and read special registers. */ - - location = (PTR) ((char*)location + sizeof (mstatus.gpr)); - regoffset = (char*)&mstatus.iar - (char*)&mstatus; - - if ( bfd_seek(abfd, section->filepos + regoffset, SEEK_SET) == -1 - || bfd_read(location, 1, 4 * NUM_OF_SPEC_REGS, abfd) != - 4 * NUM_OF_SPEC_REGS) - return (false); /* on error */ - - /* increment location address, and read the special registers.. */ - /* FIXMEmgo */ - return (true); - } - - /* else, use default bfd section content transfer. */ - else - return bfd_generic_get_section_contents - (abfd, section, location, offset, count); -} - -#endif /* if 0 - for CORE */ diff --git a/bfd/coffcode.h b/bfd/coffcode.h deleted file mode 100644 index fbb04063b08..00000000000 --- a/bfd/coffcode.h +++ /dev/null @@ -1,3314 +0,0 @@ -/* Support for the generic parts of most COFF variants, for BFD. - Copyright (C) 1990-1991 Free Software Foundation, Inc. - Written by Cygnus Support. - -This file is part of BFD, the Binary File Descriptor library. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/*doc* -@section coff backends - -BFD supports a number of different flavours of coff format. The major -difference between formats are the sizes and alignments of fields in -structures on disk, and the occasional extra field. - -Coff in all its varieties is implimented with a few common files and a -number of implementation specific files. For example, The 88k bcs coff -format is implemented in the file @code{m88k-bcs.c}. This file -@code{#include}s @code{m88k-bcs.h} which defines the external -structure of the coff format for the 88k, and @code{internalcoff.h} -which defines the internal structure. @code{m88k-bcs.c} also defines -the relocations used by the 88k format @xref{Relocations}. Then the -major portion of coff code is included (@code{coffcode.h}) which -defines the methods used to act upon the types defined in -@code{m88k-bcs.h} and @code{internalcoff.h}. - -The Intel i960 processor version of coff is implemented in -@code{icoff.c}. This file has the same structure as -@code{m88k-bcs.c}, except that it includes @code{intel-coff.h} rather -than @code{m88k-bcs.h}. - -@subsection Porting To A New Version of Coff - -The recommended method is to select from the existing implimentations -the version of coff which is most like the one you want to use, for -our purposes, we'll say that i386 coff is the one you select, and that -your coff flavour is called foo. Copy the @code{i386coff.c} to @code{foocoff.c}, -copy @code{../include/i386coff.h} to @code{../include/foocoff.h} and -add the lines to @code{targets.c} and @code{Makefile.in} so that your -new back end is used. - -Alter the shapes of the structures in @code{../include/foocoff.h} so -that they match what you need. You will probably also have to add -@code{#ifdef}s to the code in @code{internalcoff.h} and -@code{coffcode.h} if your version of coff is too wild. - -You can verify that your new BFD backend works quite simply by -building @code{objdump} from the @code{binutils} directory, and -making sure that its version of what's going on at your host systems -idea (assuming it has the pretty standard coff dump utility (usually -called @code{att-dump} or just @code{dump})) are the same. - -Then clean up your code, and send what you've done to Cygnus. Then your stuff -will be in the next release, and you won't have to keep integrating -it. - -@subsection How The Coff Backend Works - -@subsubsection Bit Twiddling -Each flavour of coff supported in BFD has its own header file -descibing the external layout of the structures. There is also an -internal description of the coff layout (in @code{internalcoff.h}) -file (@code{}). A major function of the coff backend is swapping the -bytes and twiddling the bits to translate the external form of the -structures into the normal internal form. This is all performed in the -@code{bfd_swap}_@i{thing}_@i{direction} routines. Some elements are -different sizes between different versions of coff, it is the duty of -the coff version specific include file to override the definitions of -various packing routines in @code{coffcode.h}. Eg the size of line -number entry in coff is sometimes 16 bits, and sometimes 32 bits. -@code{#define}ing @code{PUT_LNSZ_LNNO} and @code{GET_LNSZ_LNNO} will -select the correct one. No doubt, some day someone will find a version -of coff which has a varying field size not catered for at the moment. -To port BFD, that person will have to add more @code{#defines}. - -Three of the bit twiddling routines are exported to @code{gdb}; -@code{coff_swap_aux_in}, @code{coff_swap_sym_in} and -@code{coff_swap_linno_in}. @code{GDB} reads the symbol table on its -own, but uses BFD to fix things up. - -More of the bit twiddlers are exported for @code{gas}; -@code{coff_swap_aux_out}, @code{coff_swap_sym_out}, -@code{coff_swap_lineno_out}, @code{coff_swap_reloc_out}, -@code{coff_swap_filehdr_out}, @code{coff_swap_aouthdr_out}, -@code{coff_swap_scnhdr_out}. @code{Gas} currently keeps track of all -the symbol table and reloc drudgery itself, thereby saving the -internal BFD overhead, but uses BFD to swap things on the way out, -making cross ports much safer. This also allows BFD (and thus the -linker) to use the same header files as @code{gas}, which makes one -avenue to disaster disappear. - -@subsubsection Symbol Reading -The simple canonical form for symbols used by BFD is not rich enough -to keep all the information available in a coff symbol table. The back -end gets around this by keeping the original symbol table around, -"behind the scenes". - -When a symbol table is requested (through a call to -@code{bfd_canonicalize_symtab}, a request gets through to -@code{get_normalized_symtab}. This reads the symbol table from the -coff file and swaps all the structures inside into the internal form. -It also fixes up all the pointers in the table (represented in the file -by offsets from the first symbol in the table) into physical pointers -to elements in the new internal table. This involves some work since -the meanings of fields changes depending upon context; a field that is a -pointer to another structure in the symbol table at one moment may be -the size in bytes of a structure in the next. - -Another pass is made over the table. All symbols which mark file names -(@code{C_FILE} symbols) are modified so that the internal string -points to the value in the auxent (the real filename) rather than the -normal text associated with the symbol (@code{".file"}). - -At this time the symbol names are moved around. Coff stores all -symbols less than nine characters long physically within the symbol -table, longer strings are kept at the end of the file in the string -table. This pass moves all strings into memory, and replaces them with -pointers to the strings. - -The symbol table is massaged once again, this time to create the -canonical table used by the BFD application. Each symbol is inspected -in turn, and a decision made (using the @code{sclass} field) about the -various flags to set in the @code{asymbol} @xref{Symbols}. The -generated canonical table shares strings with the hidden internal -symbol table. - -Any linenumbers are read from the coff file too, and attached to the -symbols which own the functions the linenumbers belong to. - -@subsubsection Symbol Writing -Writing a symbol to a coff file which didn't come from a coff file -will lose any debugging information. The @code{asymbol} structure -remembers the BFD from which was born, and on output the back end -makes sure that the same destination target as source target is -present. - -When the symbols have come from a coff file then all the debugging -information is preserved. - -Symbol tables are provided for writing to the back end in a vector of -pointers to pointers. This allows applications like the linker to -accumulate and output large symbol tables without having to do too -much byte copying. - -The symbol table is not output to a writable BFD until it is closed. -The order of operations on the canonical symbol table at that point -are: -@table @code -@item coff_renumber_symbols -This function runs through the provided symbol table and patches each -symbol marked as a file place holder (@code{C_FILE}) to point to the -next file place holder in the list. It also marks each @code{offset} -field in the list with the offset from the first symbol of the current -symbol. - -Another function of this procedure is to turn the canonical value form -of BFD into the form used by coff. Internally, BFD expects symbol -values to be offsets from a section base; so a symbol physically at -0x120, but in a section starting at 0x100, would have the value 0x20. -Coff expects symbols to contain their final value, so symbols have -their values changed at this point to reflect their sum with their -owning section. Note that this transformation uses the -@code{output_section} field of the @code{asymbol}'s @code{asection} -@xref{Sections}. -@item coff_mangle_symbols -This routine runs though the provided symbol table and uses the -offsets generated by the previous pass and the pointers generated when -the symbol table was read in to create the structured hierachy -required by coff. It changes each pointer to a symbol to an index into -the symbol table of the symbol being referenced. -@item coff_write_symbols -This routine runs through the symbol table and patches up the symbols -from their internal form into the coff way, calls the bit twiddlers -and writes out the tabel to the file. -@end table -*/ - -/*proto* - -The hidden information for an asymbol is: - -*+++ - -$ typedef struct coff_ptr_struct -$ { - -Remembers the offset from the first symbol in the file for this -symbol. Generated by @code{coff_renumber_symbols}. - -$ unsigned int offset; - -Should the tag field of this symbol be renumbered. -Created by @code{coff_pointerize_aux}. - -$ char fix_tag; - -Should the endidx field of this symbol be renumbered. -Created by @code{coff_pointerize_aux}. - -$ char fix_end; - -The container for the symbol structure as read and translated from the file. - -$ union { -$ union internal_auxent auxent; -$ struct internal_syment syment; -$ } u; -$ } combined_entry_type; -$ - -*--- - -Each canonical asymbol really looks like this: - -*+++ - -$ typedef struct coff_symbol_struct -$ { - -The actual symbol which the rest of BFD works with - -$ asymbol symbol; - -A pointer to the hidden information for this symbol - -$ combined_entry_type *native; - -A pointer to the linenumber information for this symbol - -$ struct lineno_cache_entry *lineno; -$ } coff_symbol_type; - -*--- - -*/ - -/* Most of this hacked by Steve Chamberlain, steve@cygnus.com */ - - -#define PUTWORD bfd_h_put_32 -#define PUTHALF bfd_h_put_16 -#define PUTBYTE bfd_h_put_8 - -#ifndef GET_FCN_LNNOPTR -#define GET_FCN_LNNOPTR(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_lnnoptr) -#endif - -#ifndef GET_FCN_ENDNDX -#define GET_FCN_ENDNDX(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_endndx) -#endif - -#ifndef PUT_FCN_LNNOPTR -#define PUT_FCN_LNNOPTR(abfd, in, ext) PUTWORD(abfd, in, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_lnnoptr) -#endif -#ifndef PUT_FCN_ENDNDX -#define PUT_FCN_ENDNDX(abfd, in, ext) PUTWORD(abfd, in, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_endndx) -#endif -#ifndef GET_LNSZ_LNNO -#define GET_LNSZ_LNNO(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_misc.x_lnsz.x_lnno) -#endif -#ifndef GET_LNSZ_SIZE -#define GET_LNSZ_SIZE(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_misc.x_lnsz.x_size) -#endif -#ifndef PUT_LNSZ_LNNO -#define PUT_LNSZ_LNNO(abfd, in, ext) bfd_h_put_16(abfd, in, (bfd_byte *)ext->x_sym.x_misc.x_lnsz.x_lnno) -#endif -#ifndef PUT_LNSZ_SIZE -#define PUT_LNSZ_SIZE(abfd, in, ext) bfd_h_put_16(abfd, in, (bfd_byte*) ext->x_sym.x_misc.x_lnsz.x_size) -#endif -#ifndef GET_SCN_SCNLEN -#define GET_SCN_SCNLEN(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *) ext->x_scn.x_scnlen) -#endif -#ifndef GET_SCN_NRELOC -#define GET_SCN_NRELOC(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *)ext->x_scn.x_nreloc) -#endif -#ifndef GET_SCN_NLINNO -#define GET_SCN_NLINNO(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *)ext->x_scn.x_nlinno) -#endif -#ifndef PUT_SCN_SCNLEN -#define PUT_SCN_SCNLEN(abfd,in, ext) bfd_h_put_32(abfd, in, (bfd_byte *) ext->x_scn.x_scnlen) -#endif -#ifndef PUT_SCN_NRELOC -#define PUT_SCN_NRELOC(abfd,in, ext) bfd_h_put_16(abfd, in, (bfd_byte *)ext->x_scn.x_nreloc) -#endif -#ifndef PUT_SCN_NLINNO -#define PUT_SCN_NLINNO(abfd,in, ext) bfd_h_put_16(abfd,in, (bfd_byte *) ext->x_scn.x_nlinno) -#endif -#ifndef GET_LINENO_LNNO -#define GET_LINENO_LNNO(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *) (ext->l_lnno)); -#endif -#ifndef PUT_LINNO_LNNO -#define PUT_LINENO_LNNO(abfd,val, ext) bfd_h_put_16(abfd,val, (bfd_byte *) (ext->l_lnno)); -#endif - - -/* void warning(); */ - -/* - * Return a word with STYP_* (scnhdr.s_flags) flags set to represent the - * incoming SEC_* flags. The inverse of this function is styp_to_sec_flags(). - * NOTE: If you add to/change this routine, you should mirror the changes - * in styp_to_sec_flags(). - */ -static long -DEFUN(sec_to_styp_flags, (sec_name, sec_flags), - CONST char * sec_name AND - flagword sec_flags) -{ - long styp_flags = 0; - - if (!strcmp(sec_name, _TEXT)) { - return((long)STYP_TEXT); - } else if (!strcmp(sec_name, _DATA)) { - return((long)STYP_DATA); - } else if (!strcmp(sec_name, _BSS)) { - return((long)STYP_BSS); - } - -/* Try and figure out what it should be */ - if (sec_flags & SEC_CODE) styp_flags = STYP_TEXT; - if (sec_flags & SEC_DATA) styp_flags = STYP_DATA; - else if (sec_flags & SEC_READONLY) -#ifdef STYP_LIT /* 29k readonly text/data section */ - styp_flags = STYP_LIT; -#else - styp_flags = STYP_TEXT; -#endif /* STYP_LIT */ - else if (sec_flags & SEC_LOAD) styp_flags = STYP_TEXT; - - if (styp_flags == 0) styp_flags = STYP_BSS; - - return(styp_flags); -} -/* - * Return a word with SEC_* flags set to represent the incoming - * STYP_* flags (from scnhdr.s_flags). The inverse of this - * function is sec_to_styp_flags(). - * NOTE: If you add to/change this routine, you should mirror the changes - * in sec_to_styp_flags(). - */ -static flagword -DEFUN(styp_to_sec_flags, (styp_flags), - long styp_flags) -{ - flagword sec_flags=0; - - if ((styp_flags & STYP_TEXT) || (styp_flags & STYP_DATA)) - sec_flags = (SEC_LOAD | SEC_ALLOC); - else if (styp_flags & STYP_BSS) - sec_flags = SEC_ALLOC; - -#ifdef STYP_LIT /* A29k readonly text/data section type */ - if ((styp_flags & STYP_LIT) == STYP_LIT) - sec_flags = (SEC_LOAD | SEC_ALLOC | SEC_READONLY); -#endif /* STYP_LIT */ - - return(sec_flags); -} - -#define get_index(symbol) ((int) (symbol)->value) -#define set_index(symbol, idx) ((symbol)->value = (idx)) - -/* ********************************************************************** -Here are all the routines for swapping the structures seen in the -outside world into the internal forms. -*/ - - -static void -DEFUN(bfd_swap_reloc_in,(abfd, reloc_src, reloc_dst), - bfd *abfd AND - RELOC *reloc_src AND - struct internal_reloc *reloc_dst) -{ - reloc_dst->r_vaddr = bfd_h_get_32(abfd, (bfd_byte *)reloc_src->r_vaddr); - reloc_dst->r_symndx = bfd_h_get_32(abfd, (bfd_byte *) reloc_src->r_symndx); - -#ifdef RS6000COFF_C - reloc_dst->r_type = bfd_h_get_8(abfd, reloc_src->r_type); - reloc_dst->r_size = bfd_h_get_8(abfd, reloc_src->r_size); -#else - reloc_dst->r_type = bfd_h_get_16(abfd, (bfd_byte *) reloc_src->r_type); -#endif - -#if M88 - reloc_dst->r_offset = bfd_h_get_16(abfd, (bfd_byte *) reloc_src->r_offset); -#endif -} - - -static unsigned int -DEFUN(coff_swap_reloc_out,(abfd, src, dst), - bfd *abfd AND - PTR src AND - PTR dst) -{ - struct internal_reloc *reloc_src = (struct internal_reloc *)src; - struct external_reloc *reloc_dst = (struct external_reloc *)dst; - bfd_h_put_32(abfd, reloc_src->r_vaddr, (bfd_byte *) reloc_dst->r_vaddr); - bfd_h_put_32(abfd, reloc_src->r_symndx, (bfd_byte *) reloc_dst->r_symndx); - bfd_h_put_16(abfd, reloc_src->r_type, (bfd_byte *) reloc_dst->r_type); -#if M88 - bfd_h_put_16(abfd, reloc_src->r_offset, (bfd_byte *) reloc_dst->r_offset); -#endif - return sizeof(struct external_reloc); -} - -static void -DEFUN(bfd_swap_filehdr_in,(abfd, filehdr_src, filehdr_dst), - bfd *abfd AND - FILHDR *filehdr_src AND - struct internal_filehdr *filehdr_dst) -{ - filehdr_dst->f_magic = bfd_h_get_16(abfd, (bfd_byte *) filehdr_src->f_magic); - filehdr_dst->f_nscns = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_nscns); - filehdr_dst->f_timdat = bfd_h_get_32(abfd, (bfd_byte *)filehdr_src-> f_timdat); - filehdr_dst->f_symptr = bfd_h_get_32(abfd, (bfd_byte *)filehdr_src-> f_symptr); - filehdr_dst->f_nsyms = bfd_h_get_32(abfd, (bfd_byte *)filehdr_src-> f_nsyms); - filehdr_dst->f_opthdr = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_opthdr); - filehdr_dst->f_flags = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_flags); -} - -static unsigned int -DEFUN(coff_swap_filehdr_out,(abfd, in, out), - bfd *abfd AND - PTR in AND - PTR out) -{ - struct internal_filehdr *filehdr_in = (struct internal_filehdr *)in; - FILHDR *filehdr_out = (FILHDR *)out; - bfd_h_put_16(abfd, filehdr_in->f_magic, (bfd_byte *) filehdr_out->f_magic); - bfd_h_put_16(abfd, filehdr_in->f_nscns, (bfd_byte *) filehdr_out->f_nscns); - bfd_h_put_32(abfd, filehdr_in->f_timdat, (bfd_byte *) filehdr_out->f_timdat); - bfd_h_put_32(abfd, filehdr_in->f_symptr, (bfd_byte *) filehdr_out->f_symptr); - bfd_h_put_32(abfd, filehdr_in->f_nsyms, (bfd_byte *) filehdr_out->f_nsyms); - bfd_h_put_16(abfd, filehdr_in->f_opthdr, (bfd_byte *) filehdr_out->f_opthdr); - bfd_h_put_16(abfd, filehdr_in->f_flags, (bfd_byte *) filehdr_out->f_flags); - return sizeof(FILHDR); -} - - -#ifndef NO_COFF_SYMBOLS - -static void -DEFUN(coff_swap_sym_in,(abfd, ext1, in1), - bfd *abfd AND - PTR ext1 AND - PTR in1) -{ - SYMENT *ext = (SYMENT *)ext1; - struct internal_syment *in = (struct internal_syment *)in1; - - if( ext->e.e_name[0] == 0) { - in->_n._n_n._n_zeroes = 0; - in->_n._n_n._n_offset = bfd_h_get_32(abfd, (bfd_byte *) ext->e.e.e_offset); - } - else { -#if SYMNMLEN != E_SYMNMLEN - -> Error, we need to cope with truncating or extending SYMNMLEN!; -#else - memcpy(in->_n._n_name, ext->e.e_name, SYMNMLEN); -#endif - } - in->n_value = bfd_h_get_32(abfd, (bfd_byte *) ext->e_value); - in->n_scnum = bfd_h_get_16(abfd, (bfd_byte *) ext->e_scnum); - if (sizeof(ext->e_type) == 2){ - in->n_type = bfd_h_get_16(abfd, (bfd_byte *) ext->e_type); - } - else { - in->n_type = bfd_h_get_32(abfd, (bfd_byte *) ext->e_type); - } - in->n_sclass = bfd_h_get_8(abfd, ext->e_sclass); - in->n_numaux = bfd_h_get_8(abfd, ext->e_numaux); -} - -static unsigned int -DEFUN(coff_swap_sym_out,(abfd, inp, extp), - bfd *abfd AND - PTR inp AND - PTR extp) -{ - struct internal_syment *in = (struct internal_syment *)inp; - SYMENT *ext =(SYMENT *)extp; - if(in->_n._n_name[0] == 0) { - bfd_h_put_32(abfd, 0, (bfd_byte *) ext->e.e.e_zeroes); - bfd_h_put_32(abfd, in->_n._n_n._n_offset, (bfd_byte *) ext->e.e.e_offset); - } - else { -#if SYMNMLEN != E_SYMNMLEN - -> Error, we need to cope with truncating or extending SYMNMLEN!; -#else - memcpy(ext->e.e_name, in->_n._n_name, SYMNMLEN); -#endif - } - bfd_h_put_32(abfd, in->n_value , (bfd_byte *) ext->e_value); - bfd_h_put_16(abfd, in->n_scnum , (bfd_byte *) ext->e_scnum); - if (sizeof(ext->e_type) == 2) - { - bfd_h_put_16(abfd, in->n_type , (bfd_byte *) ext->e_type); - } - else - { - bfd_h_put_32(abfd, in->n_type , (bfd_byte *) ext->e_type); - } - bfd_h_put_8(abfd, in->n_sclass , ext->e_sclass); - bfd_h_put_8(abfd, in->n_numaux , ext->e_numaux); - return sizeof(SYMENT); -} - -static void -DEFUN(coff_swap_aux_in,(abfd, ext1, type, class, in1), - bfd *abfd AND - PTR ext1 AND - int type AND - int class AND - PTR in1) -{ - AUXENT *ext = (AUXENT *)ext1; - union internal_auxent *in = (union internal_auxent *)in1; - switch (class) { - case C_FILE: - if (ext->x_file.x_fname[0] == 0) { - in->x_file.x_n.x_zeroes = 0; - in->x_file.x_n.x_offset = - bfd_h_get_32(abfd, (bfd_byte *) ext->x_file.x_n.x_offset); - } else { -#if FILNMLEN != E_FILNMLEN - -> Error, we need to cope with truncating or extending FILNMLEN!; -#else - memcpy (in->x_file.x_fname, ext->x_file.x_fname, FILNMLEN); -#endif - } - break; - - /* RS/6000 "csect" auxents */ -#ifdef RS6000COFF_C - case C_EXT: - case C_HIDEXT: - in->x_csect.x_scnlen = bfd_h_get_32 (abfd, (bfd_byte *) ext->x_csect.x_scnlen); - in->x_csect.x_parmhash = bfd_h_get_32 (abfd, (bfd_byte *) ext->x_csect.x_parmhash); - in->x_csect.x_snhash = bfd_h_get_16 (abfd, (bfd_byte *) ext->x_csect.x_snhash); - /* We don't have to hack bitfields in x_smtyp because it's defined by - shifts-and-ands, which are equivalent on all byte orders. */ - in->x_csect.x_smtyp = bfd_h_get_8 (abfd, (bfd_byte *) ext->x_csect.x_smtyp); - in->x_csect.x_smclas = bfd_h_get_8 (abfd, (bfd_byte *) ext->x_csect.x_smclas); - in->x_csect.x_stab = bfd_h_get_32 (abfd, (bfd_byte *) ext->x_csect.x_stab); - in->x_csect.x_snstab = bfd_h_get_16 (abfd, (bfd_byte *) ext->x_csect.x_snstab); - break; -#endif - - case C_STAT: -#ifdef C_LEAFSTAT - case C_LEAFSTAT: -#endif - case C_HIDDEN: - if (type == T_NULL) { - in->x_scn.x_scnlen = GET_SCN_SCNLEN(abfd, ext); - in->x_scn.x_nreloc = GET_SCN_NRELOC(abfd, ext); - in->x_scn.x_nlinno = GET_SCN_NLINNO(abfd, ext); - break; - } - default: - in->x_sym.x_tagndx.l = bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_tagndx); -#ifndef NO_TVNDX - in->x_sym.x_tvndx = bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_tvndx); -#endif - - if (ISARY(type) || class == C_BLOCK) { -#if DIMNUM != E_DIMNUM - -> Error, we need to cope with truncating or extending DIMNUM!; -#else - in->x_sym.x_fcnary.x_ary.x_dimen[0] = bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[0]); - in->x_sym.x_fcnary.x_ary.x_dimen[1] = bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[1]); - in->x_sym.x_fcnary.x_ary.x_dimen[2] = bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[2]); - in->x_sym.x_fcnary.x_ary.x_dimen[3] = bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[3]); -#endif - } - in->x_sym.x_fcnary.x_fcn.x_lnnoptr = GET_FCN_LNNOPTR(abfd, ext); - in->x_sym.x_fcnary.x_fcn.x_endndx.l = GET_FCN_ENDNDX(abfd, ext); - - if (ISFCN(type)) { - in->x_sym.x_misc.x_fsize = bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_misc.x_fsize); - } - else { - in->x_sym.x_misc.x_lnsz.x_lnno = GET_LNSZ_LNNO(abfd, ext); - in->x_sym.x_misc.x_lnsz.x_size = GET_LNSZ_SIZE(abfd, ext); - } - } -} - -static unsigned int -DEFUN(coff_swap_aux_out,(abfd, inp, type, class, extp), - bfd *abfd AND - PTR inp AND - int type AND - int class AND - PTR extp) -{ - union internal_auxent *in = (union internal_auxent *)inp; - AUXENT *ext = (AUXENT *)extp; - switch (class) { - case C_FILE: - if (in->x_file.x_fname[0] == 0) { - PUTWORD(abfd, 0, (bfd_byte *) ext->x_file.x_n.x_zeroes); - PUTWORD(abfd, - in->x_file.x_n.x_offset, - (bfd_byte *) ext->x_file.x_n.x_offset); - } - else { -#if FILNMLEN != E_FILNMLEN - -> Error, we need to cope with truncating or extending FILNMLEN!; -#else - memcpy (ext->x_file.x_fname, in->x_file.x_fname, FILNMLEN); -#endif - } - break; - -#ifdef RS6000COFF_C - /* RS/6000 "csect" auxents */ - case C_EXT: - case C_HIDEXT: - PUTWORD (abfd, in->x_csect.x_scnlen, ext->x_csect.x_scnlen); - PUTWORD (abfd, in->x_csect.x_parmhash, ext->x_csect.x_parmhash); - PUTHALF (abfd, in->x_csect.x_snhash, ext->x_csect.x_snhash); - /* We don't have to hack bitfields in x_smtyp because it's defined by - shifts-and-ands, which are equivalent on all byte orders. */ - PUTBYTE (abfd, in->x_csect.x_smtyp, ext->x_csect.x_smtyp); - PUTBYTE (abfd, in->x_csect.x_smclas, ext->x_csect.x_smclas); - PUTWORD (abfd, in->x_csect.x_stab, ext->x_csect.x_stab); - PUTHALF (abfd, in->x_csect.x_snstab, ext->x_csect.x_snstab); - break; -#endif - - case C_STAT: -#ifdef C_LEAFSTAT - case C_LEAFSTAT: -#endif - case C_HIDDEN: - if (type == T_NULL) { - PUT_SCN_SCNLEN(abfd, in->x_scn.x_scnlen, ext); - PUT_SCN_NRELOC(abfd, in->x_scn.x_nreloc, ext); - PUT_SCN_NLINNO(abfd, in->x_scn.x_nlinno, ext); - break; - } - default: - PUTWORD(abfd, in->x_sym.x_tagndx.l, (bfd_byte *) ext->x_sym.x_tagndx); -#ifndef NO_TVNDX - PUTWORD(abfd, in->x_sym.x_tvndx , (bfd_byte *) ext->x_sym.x_tvndx); -#endif - - if (ISFCN(type)) { - PUTWORD(abfd, in->x_sym.x_misc.x_fsize, (bfd_byte *) ext->x_sym.x_misc.x_fsize); - PUT_FCN_LNNOPTR(abfd, in->x_sym.x_fcnary.x_fcn.x_lnnoptr, ext); - PUT_FCN_ENDNDX(abfd, in->x_sym.x_fcnary.x_fcn.x_endndx.l, ext); - } - else { - - if (ISARY(type) || class == C_BLOCK) { -#if DIMNUM != E_DIMNUM - -> Error, we need to cope with truncating or extending DIMNUM!; -#else - bfd_h_put_16(abfd, in->x_sym.x_fcnary.x_ary.x_dimen[0], (bfd_byte *)ext->x_sym.x_fcnary.x_ary.x_dimen[0]); - bfd_h_put_16(abfd, in->x_sym.x_fcnary.x_ary.x_dimen[1], (bfd_byte *)ext->x_sym.x_fcnary.x_ary.x_dimen[1]); - bfd_h_put_16(abfd, in->x_sym.x_fcnary.x_ary.x_dimen[2], (bfd_byte *)ext->x_sym.x_fcnary.x_ary.x_dimen[2]); - bfd_h_put_16(abfd, in->x_sym.x_fcnary.x_ary.x_dimen[3], (bfd_byte *)ext->x_sym.x_fcnary.x_ary.x_dimen[3]); -#endif - } - PUT_LNSZ_LNNO(abfd, in->x_sym.x_misc.x_lnsz.x_lnno, ext); - PUT_LNSZ_SIZE(abfd, in->x_sym.x_misc.x_lnsz.x_size, ext); - - PUT_FCN_LNNOPTR(abfd, in->x_sym.x_fcnary.x_fcn.x_lnnoptr, ext); - PUT_FCN_ENDNDX(abfd, in->x_sym.x_fcnary.x_fcn.x_endndx.l, ext); - - - } - } -return sizeof(AUXENT); -} - -#endif /* NO_COFF_SYMBOLS */ - -#ifndef NO_COFF_LINENOS - -static void -DEFUN(coff_swap_lineno_in,(abfd, ext1, in1), - bfd *abfd AND - PTR ext1 AND - PTR in1) -{ - LINENO *ext = (LINENO *)ext1; - struct internal_lineno *in = (struct internal_lineno *)in1; - - in->l_addr.l_symndx = bfd_h_get_32(abfd, (bfd_byte *) ext->l_addr.l_symndx); - in->l_lnno = GET_LINENO_LNNO(abfd, ext); -} - -static unsigned int -DEFUN(coff_swap_lineno_out,(abfd, inp, outp), - bfd *abfd AND - PTR inp AND - PTR outp) -{ - struct internal_lineno *in = (struct internal_lineno *)inp; - struct external_lineno *ext = (struct external_lineno *)outp; - PUTWORD(abfd, in->l_addr.l_symndx, (bfd_byte *) - ext->l_addr.l_symndx); - - PUT_LINENO_LNNO (abfd, in->l_lnno, ext); - return sizeof(struct external_lineno); -} - -#endif /* NO_COFF_LINENOS */ - - -static void -DEFUN(bfd_swap_aouthdr_in,(abfd, aouthdr_ext1, aouthdr_int1), - bfd *abfd AND - PTR aouthdr_ext1 AND - PTR aouthdr_int1) -{ - AOUTHDR *aouthdr_ext = (AOUTHDR *) aouthdr_ext1; - struct internal_aouthdr *aouthdr_int = (struct internal_aouthdr *)aouthdr_int1; - - aouthdr_int->magic = bfd_h_get_16(abfd, (bfd_byte *) aouthdr_ext->magic); - aouthdr_int->vstamp = bfd_h_get_16(abfd, (bfd_byte *) aouthdr_ext->vstamp); - aouthdr_int->tsize = bfd_h_get_32(abfd, (bfd_byte *) aouthdr_ext->tsize); - aouthdr_int->dsize = bfd_h_get_32(abfd, (bfd_byte *) aouthdr_ext->dsize); - aouthdr_int->bsize = bfd_h_get_32(abfd, (bfd_byte *) aouthdr_ext->bsize); - aouthdr_int->entry = bfd_h_get_32(abfd, (bfd_byte *) aouthdr_ext->entry); - aouthdr_int->text_start = bfd_h_get_32(abfd, (bfd_byte *) aouthdr_ext->text_start); - aouthdr_int->data_start = bfd_h_get_32(abfd, (bfd_byte *) aouthdr_ext->data_start); -#ifdef I960 - aouthdr_int->tagentries = bfd_h_get_32(abfd, (bfd_byte *) aouthdr_ext->tagentries); -#endif - -#ifdef RS6000COFF_C - aouthdr_int->o_toc = bfd_h_get_32(abfd, aouthdr_ext->o_toc); - aouthdr_int->o_snentry = bfd_h_get_16(abfd, aouthdr_ext->o_snentry); - aouthdr_int->o_sntext = bfd_h_get_16(abfd, aouthdr_ext->o_sntext); - aouthdr_int->o_sndata = bfd_h_get_16(abfd, aouthdr_ext->o_sndata); - aouthdr_int->o_sntoc = bfd_h_get_16(abfd, aouthdr_ext->o_sntoc); - aouthdr_int->o_snloader = bfd_h_get_16(abfd, aouthdr_ext->o_snloader); - aouthdr_int->o_snbss = bfd_h_get_16(abfd, aouthdr_ext->o_snbss); - aouthdr_int->o_algntext = bfd_h_get_16(abfd, aouthdr_ext->o_algntext); - aouthdr_int->o_algndata = bfd_h_get_16(abfd, aouthdr_ext->o_algndata); - aouthdr_int->o_modtype = bfd_h_get_16(abfd, aouthdr_ext->o_modtype); - aouthdr_int->o_maxstack = bfd_h_get_32(abfd, aouthdr_ext->o_maxstack); -#endif -} - -static unsigned int -DEFUN(coff_swap_aouthdr_out,(abfd, in, out), - bfd *abfd AND - PTR in AND - PTR out) -{ - struct internal_aouthdr *aouthdr_in = (struct internal_aouthdr *)in; - AOUTHDR *aouthdr_out = (AOUTHDR *)out; - bfd_h_put_16(abfd, aouthdr_in->magic, (bfd_byte *) aouthdr_out->magic); - bfd_h_put_16(abfd, aouthdr_in->vstamp, (bfd_byte *) aouthdr_out->vstamp); - bfd_h_put_32(abfd, aouthdr_in->tsize, (bfd_byte *) aouthdr_out->tsize); - bfd_h_put_32(abfd, aouthdr_in->dsize, (bfd_byte *) aouthdr_out->dsize); - bfd_h_put_32(abfd, aouthdr_in->bsize, (bfd_byte *) aouthdr_out->bsize); - bfd_h_put_32(abfd, aouthdr_in->entry, (bfd_byte *) aouthdr_out->entry); - bfd_h_put_32(abfd, aouthdr_in->text_start, - (bfd_byte *) aouthdr_out->text_start); - bfd_h_put_32(abfd, aouthdr_in->data_start, (bfd_byte *) aouthdr_out->data_start); -#ifdef I960 - bfd_h_put_32(abfd, aouthdr_in->tagentries, (bfd_byte *) aouthdr_out->tagentries); -#endif - return sizeof(AOUTHDR); -} - -static void -DEFUN(coff_swap_scnhdr_in,(abfd, scnhdr_ext, scnhdr_int), - bfd *abfd AND - SCNHDR *scnhdr_ext AND - struct internal_scnhdr *scnhdr_int) -{ - memcpy(scnhdr_int->s_name, scnhdr_ext->s_name, sizeof(scnhdr_int->s_name)); - scnhdr_int->s_vaddr = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_vaddr); - scnhdr_int->s_paddr = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_paddr); - scnhdr_int->s_size = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_size); - scnhdr_int->s_scnptr = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_scnptr); - scnhdr_int->s_relptr = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_relptr); - scnhdr_int->s_lnnoptr = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_lnnoptr); - scnhdr_int->s_flags = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_flags); -#if defined(M88) - scnhdr_int->s_nreloc = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_nreloc); - scnhdr_int->s_nlnno = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_nlnno); -#else - scnhdr_int->s_nreloc = bfd_h_get_16(abfd, (bfd_byte *) scnhdr_ext->s_nreloc); - scnhdr_int->s_nlnno = bfd_h_get_16(abfd, (bfd_byte *) scnhdr_ext->s_nlnno); -#endif -#ifdef I960 - scnhdr_int->s_align = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_align); -#endif -} - -static unsigned int -DEFUN(coff_swap_scnhdr_out,(abfd, in, out), - bfd *abfd AND - PTR in AND - PTR out) -{ - struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *)in; - SCNHDR *scnhdr_ext = (SCNHDR *)out; - memcpy(scnhdr_ext->s_name, scnhdr_int->s_name, sizeof(scnhdr_int->s_name)); - PUTWORD(abfd, scnhdr_int->s_vaddr, (bfd_byte *) scnhdr_ext->s_vaddr); - PUTWORD(abfd, scnhdr_int->s_paddr, (bfd_byte *) scnhdr_ext->s_paddr); - PUTWORD(abfd, scnhdr_int->s_size, (bfd_byte *) scnhdr_ext->s_size); - PUTWORD(abfd, scnhdr_int->s_scnptr, (bfd_byte *) scnhdr_ext->s_scnptr); - PUTWORD(abfd, scnhdr_int->s_relptr, (bfd_byte *) scnhdr_ext->s_relptr); - PUTWORD(abfd, scnhdr_int->s_lnnoptr, (bfd_byte *) scnhdr_ext->s_lnnoptr); - PUTWORD(abfd, scnhdr_int->s_flags, (bfd_byte *) scnhdr_ext->s_flags); -#if defined(M88) - PUTWORD(abfd, scnhdr_int->s_nlnno, (bfd_byte *) scnhdr_ext->s_nlnno); - PUTWORD(abfd, scnhdr_int->s_nreloc, (bfd_byte *) scnhdr_ext->s_nreloc); -#else - PUTHALF(abfd, scnhdr_int->s_nlnno, (bfd_byte *) scnhdr_ext->s_nlnno); - PUTHALF(abfd, scnhdr_int->s_nreloc, (bfd_byte *) scnhdr_ext->s_nreloc); -#endif - -#if defined(I960) - PUTWORD(abfd, scnhdr_int->s_align, (bfd_byte *) scnhdr_ext->s_align); -#endif - return sizeof(SCNHDR); -} - - -/* - initialize a section structure with information peculiar to this - particular implementation of coff -*/ - -static boolean -DEFUN(coff_new_section_hook,(abfd_ignore, section_ignore), - bfd *abfd_ignore AND - asection *section_ignore) -{ - section_ignore->alignment_power = abfd_ignore->xvec->align_power_min; - return true; -} - -/* Take a section header read from a coff file (in HOST byte order), - and make a BFD "section" out of it. */ -static boolean -DEFUN(make_a_section_from_file,(abfd, hdr), - bfd *abfd AND - struct internal_scnhdr *hdr) -{ - asection *return_section; - - { - /* Assorted wastage to null-terminate the name, thanks AT&T! */ - char *name = bfd_alloc(abfd, sizeof (hdr->s_name)+1); - if (name == NULL) { - bfd_error = no_memory; - return false; - } - strncpy(name, (char *) &hdr->s_name[0], sizeof (hdr->s_name)); - name[sizeof (hdr->s_name)] = 0; - - return_section = bfd_make_section(abfd, name); - if (return_section == NULL) - return false; - } - - /* s_paddr is presumed to be = to s_vaddr */ -#define assign(to, from) return_section->to = hdr->from - assign(vma, s_vaddr); - /* assign (vma, s_vaddr); */ - assign(size, s_size); - assign(filepos, s_scnptr); - assign(rel_filepos, s_relptr); - assign(reloc_count, s_nreloc); -#ifdef I960 - { - /* FIXME, use a temp var rather than alignment_power */ - assign(alignment_power, s_align); - { - unsigned int i; - for (i = 0; i < 32; i++) { - if ((1 << i) >= (int) (return_section->alignment_power)) { - return_section->alignment_power = i; - break; - } - } - } - } -#endif - assign(line_filepos, s_lnnoptr); - /* - return_section->linesize = hdr->s_nlnno * sizeof (struct lineno); - */ - - return_section->lineno_count = hdr->s_nlnno; - return_section->userdata = NULL; - return_section->next = (asection *) NULL; - return_section->flags = styp_to_sec_flags(hdr->s_flags); - - - if (hdr->s_nreloc != 0) - return_section->flags |= SEC_RELOC; - /* FIXME: should this check 'hdr->s_size > 0' */ - if (hdr->s_scnptr != 0) - return_section->flags |= SEC_HAS_CONTENTS; - return true; -} -static boolean -DEFUN(coff_mkobject,(abfd), - bfd *abfd) -{ - set_tdata (abfd, bfd_zalloc (abfd,sizeof(coff_data_type))); - if (coff_data(abfd) == 0) { - bfd_error = no_memory; - return false; - } - coff_data(abfd)->relocbase = 0; - return true; -} - -static -bfd_target * -DEFUN(coff_real_object_p,(abfd, nscns, internal_f, internal_a), - bfd *abfd AND - unsigned nscns AND - struct internal_filehdr *internal_f AND - struct internal_aouthdr *internal_a) -{ - coff_data_type *coff; - enum bfd_architecture arch; - long machine; - size_t readsize; /* length of file_info */ - SCNHDR *external_sections; - - /* Build a play area */ - if (coff_mkobject(abfd) != true) - return 0; - coff = coff_data(abfd); - - - external_sections = (SCNHDR *)bfd_alloc(abfd, readsize = (nscns * SCNHSZ)); - - if (bfd_read((PTR)external_sections, 1, readsize, abfd) != readsize) { - goto fail; - } - - - /* Now copy data as required; construct all asections etc */ - coff->symbol_index_slew = 0; - coff->relocbase =0; - coff->raw_syment_count = 0; - coff->raw_linenos = 0; - coff->raw_syments = 0; - coff->sym_filepos =0; - coff->flags = internal_f->f_flags; - if (nscns != 0) { - unsigned int i; - for (i = 0; i < nscns; i++) { - struct internal_scnhdr tmp; - coff_swap_scnhdr_in(abfd, external_sections + i, &tmp); - make_a_section_from_file(abfd,&tmp); - } - } - /* Determine the machine architecture and type. */ -machine = 0; - switch (internal_f->f_magic) { -#ifdef I386MAGIC - case I386MAGIC: - arch = bfd_arch_i386; - machine = 0; - break; -#endif - -#ifdef A29K_MAGIC_BIG - case A29K_MAGIC_BIG: - case A29K_MAGIC_LITTLE: - arch = bfd_arch_a29k; - machine = 0; - break; -#endif - -#ifdef MIPS - case MIPS_MAGIC_1: - case MIPS_MAGIC_2: - case MIPS_MAGIC_3: - arch = bfd_arch_mips; - machine = 0; - break; -#endif - -#ifdef MC68MAGIC - case MC68MAGIC: - case M68MAGIC: - arch = bfd_arch_m68k; - machine = 68020; - break; -#endif -#ifdef MC88MAGIC - case MC88MAGIC: - case MC88DMAGIC: - case MC88OMAGIC: - arch = bfd_arch_m88k; - machine = 88100; - break; -#endif -#ifdef I960 -#ifdef I960ROMAGIC - case I960ROMAGIC: - case I960RWMAGIC: - arch = bfd_arch_i960; - switch (F_I960TYPE & internal_f->f_flags) - { - default: - case F_I960CORE: - machine = bfd_mach_i960_core; - break; - case F_I960KB: - machine = bfd_mach_i960_kb_sb; - break; - case F_I960MC: - machine = bfd_mach_i960_mc; - break; - case F_I960XA: - machine = bfd_mach_i960_xa; - break; - case F_I960CA: - machine = bfd_mach_i960_ca; - break; - case F_I960KA: - machine = bfd_mach_i960_ka_sa; - break; - } - break; -#endif -#endif - -#ifdef U802ROMAGIC - case U802ROMAGIC: - case U802WRMAGIC: - case U802TOCMAGIC: - arch = bfd_arch_rs6000; - machine = 6000; - break; -#endif - - - default: /* Unreadable input file type */ - arch = bfd_arch_obscure; - break; - } - - bfd_default_set_arch_mach(abfd, arch, machine); - if (!(internal_f->f_flags & F_RELFLG)) - abfd->flags |= HAS_RELOC; - if ((internal_f->f_flags & F_EXEC)) - abfd->flags |= EXEC_P; - if (!(internal_f->f_flags & F_LNNO)) - abfd->flags |= HAS_LINENO; - if (!(internal_f->f_flags & F_LSYMS)) - abfd->flags |= HAS_LOCALS; - - - bfd_get_symcount(abfd) = internal_f->f_nsyms; - if (internal_f->f_nsyms) - abfd->flags |= HAS_SYMS; - - coff->sym_filepos = internal_f->f_symptr; - - /* These members communicate important constants about the symbol table - to GDB's symbol-reading code. These `constants' unfortunately vary - from coff implementation to implementation... */ -#ifndef NO_COFF_SYMBOLS - coff->local_n_btmask = N_BTMASK; - coff->local_n_btshft = N_BTSHFT; - coff->local_n_tmask = N_TMASK; - coff->local_n_tshift = N_TSHIFT; - coff->local_symesz = SYMESZ; - coff->local_auxesz = AUXESZ; - coff->local_linesz = LINESZ; -#endif - - coff->symbols = (coff_symbol_type *) NULL; - bfd_get_start_address(abfd) = internal_f->f_opthdr ? internal_a->entry : 0; - - return abfd->xvec; - fail: - bfd_release(abfd, coff); - return (bfd_target *)NULL; -} - -static bfd_target * -DEFUN(coff_object_p,(abfd), - bfd *abfd) -{ - int nscns; - FILHDR filehdr; - AOUTHDR opthdr; - struct internal_filehdr internal_f; - struct internal_aouthdr internal_a; - - bfd_error = system_call_error; - - /* figure out how much to read */ - if (bfd_read((PTR) &filehdr, 1, FILHSZ, abfd) != FILHSZ) - return 0; - - bfd_swap_filehdr_in(abfd, &filehdr, &internal_f); - - if (BADMAG(internal_f)) { - bfd_error = wrong_format; - return 0; - } - nscns =internal_f.f_nscns; - - if (internal_f.f_opthdr) { - if (bfd_read((PTR) &opthdr, 1,AOUTSZ, abfd) != AOUTSZ) { - return 0; - } - bfd_swap_aouthdr_in(abfd, (char *)&opthdr, (char *)&internal_a); - } - - /* Seek past the opt hdr stuff */ - bfd_seek(abfd, internal_f.f_opthdr + FILHSZ, SEEK_SET); - - /* if the optional header is NULL or not the correct size then - quit; the only difference I can see between m88k dgux headers (MC88DMAGIC) - and Intel 960 readwrite headers (I960WRMAGIC) is that the - optional header is of a different size. - - But the mips keeps extra stuff in it's opthdr, so dont check - when doing that - */ - -#if defined(M88) || defined(I960) - if (internal_f.f_opthdr != 0 && AOUTSZ != internal_f.f_opthdr) - return (bfd_target *)NULL; -#endif - - return coff_real_object_p(abfd, nscns, &internal_f, &internal_a); -} - - - -#ifndef NO_COFF_LINENOS - -static void -DEFUN(coff_count_linenumbers,(abfd), - bfd *abfd) -{ - unsigned int limit = bfd_get_symcount(abfd); - unsigned int i; - asymbol **p; - { - asection *s = abfd->sections->output_section; - while (s) { - BFD_ASSERT(s->lineno_count == 0); - s = s->next; - } - } - - - for (p = abfd->outsymbols, i = 0; i < limit; i++, p++) { - asymbol *q_maybe = *p; - if (q_maybe->the_bfd->xvec->flavour == bfd_target_coff_flavour) { - coff_symbol_type *q = coffsymbol(q_maybe); - if (q->lineno) { - /* - This symbol has a linenumber, increment the owning - section's linenumber count - */ - alent *l = q->lineno; - q->symbol.section->output_section->lineno_count++; - l++; - while (l->line_number) { - q->symbol.section->output_section->lineno_count++; - l++; - } - } - } - } -} - -#endif /* NO_COFF_LINENOS */ - -#ifndef NO_COFF_SYMBOLS - -/* - Takes a bfd and a symbol, returns a pointer to the coff specific area - of the symbol if there is one. - */ -static coff_symbol_type * -DEFUN(coff_symbol_from,(ignore_abfd, symbol), - bfd *ignore_abfd AND - asymbol *symbol) -{ - if (symbol->the_bfd->xvec->flavour != bfd_target_coff_flavour) - return (coff_symbol_type *)NULL; - - if (symbol->the_bfd->tdata == (PTR)NULL) - return (coff_symbol_type *)NULL; - - return (coff_symbol_type *) symbol; -} - - - -static void -DEFUN(fixup_symbol_value,(coff_symbol_ptr, syment), -coff_symbol_type *coff_symbol_ptr AND -struct internal_syment *syment) -{ - - /* Normalize the symbol flags */ - if (coff_symbol_ptr->symbol.flags & BSF_FORT_COMM) { - /* a common symbol is undefined with a value */ - syment->n_scnum = N_UNDEF; - syment->n_value = coff_symbol_ptr->symbol.value; - } - else if (coff_symbol_ptr->symbol.flags & BSF_DEBUGGING) { - syment->n_value = coff_symbol_ptr->symbol.value; - } - else if (coff_symbol_ptr->symbol.flags & BSF_UNDEFINED) { - syment->n_scnum = N_UNDEF; - syment->n_value = 0; - } - else if (coff_symbol_ptr->symbol.flags & BSF_ABSOLUTE) { - syment->n_scnum = N_ABS; - syment->n_value = coff_symbol_ptr->symbol.value; - } - else { - if (coff_symbol_ptr->symbol.section) { - syment->n_scnum = - coff_symbol_ptr->symbol.section->output_section->index+1; - - syment->n_value = - coff_symbol_ptr->symbol.value + - coff_symbol_ptr->symbol.section->output_offset + - coff_symbol_ptr->symbol.section->output_section->vma; - } - else { - /* This can happen, but I don't know why yet (steve@cygnus.com) */ - syment->n_scnum = N_ABS; - syment->n_value = coff_symbol_ptr->symbol.value; - } - } -} - -/* run through all the symbols in the symbol table and work out what - their indexes into the symbol table will be when output - - Coff requires that each C_FILE symbol points to the next one in the - chain, and that the last one points to the first external symbol. We - do that here too. - -*/ -static void -DEFUN(coff_renumber_symbols,(bfd_ptr), - bfd *bfd_ptr) -{ - unsigned int symbol_count = bfd_get_symcount(bfd_ptr); - asymbol **symbol_ptr_ptr = bfd_ptr->outsymbols; - unsigned int native_index = 0; - struct internal_syment *last_file = (struct internal_syment *)NULL; - unsigned int symbol_index; - for (symbol_index = 0; symbol_index < symbol_count; symbol_index++) - { - coff_symbol_type *coff_symbol_ptr = coff_symbol_from(bfd_ptr, symbol_ptr_ptr[symbol_index]); - if (coff_symbol_ptr && coff_symbol_ptr->native) { - combined_entry_type *s = coff_symbol_ptr->native; - int i; - - if (s->u.syment.n_sclass == C_FILE) - { - if (last_file != (struct internal_syment *)NULL) { - last_file->n_value = native_index; - } - last_file = &(s->u.syment); - } - else { - - /* Modify the symbol values according to their section and - type */ - - fixup_symbol_value(coff_symbol_ptr, &(s->u.syment)); - } - for (i = 0; i < s->u.syment.n_numaux + 1; i++) { - s[i].offset = native_index ++; - } - } - else { - native_index++; - } - } -} - - -/* - Run thorough the symbol table again, and fix it so that all pointers to - entries are changed to the entries' index in the output symbol table. - -*/ -static void -DEFUN(coff_mangle_symbols,(bfd_ptr), - bfd *bfd_ptr) -{ - unsigned int symbol_count = bfd_get_symcount(bfd_ptr); - asymbol **symbol_ptr_ptr = bfd_ptr->outsymbols; - unsigned int symbol_index; - - for (symbol_index = 0; symbol_index < symbol_count; symbol_index++) - { - coff_symbol_type *coff_symbol_ptr = - coff_symbol_from(bfd_ptr, symbol_ptr_ptr[symbol_index]); - - if (coff_symbol_ptr && coff_symbol_ptr->native) { - int i; - combined_entry_type *s = coff_symbol_ptr->native; - - for (i = 0; i < s->u.syment.n_numaux ; i++) { - combined_entry_type *a = s + i + 1; - if (a->fix_tag) { - a->u.auxent.x_sym.x_tagndx.l = - a->u.auxent.x_sym.x_tagndx.p->offset; - } - if (a->fix_end) { - a->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.l = - a->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.p->offset; - } - - } - } - } -} - -static int string_size; -static void -DEFUN(coff_fix_symbol_name,(ignore_abfd, symbol, native), - bfd *ignore_abfd AND - asymbol *symbol AND - combined_entry_type *native) -{ - unsigned int name_length; - union internal_auxent *auxent; - char * name = ( char *)(symbol->name); - - if (name == (char *) NULL) { - /* coff symbols always have names, so we'll make one up */ - symbol->name = "strange"; - name = (char *)symbol->name; - } - name_length = strlen(name); - - if (native->u.syment.n_sclass == C_FILE) { - strncpy(native->u.syment._n._n_name, ".file", SYMNMLEN); - auxent = &(native+1)->u.auxent; - -#ifdef COFF_LONG_FILENAMES - if (name_length <= FILNMLEN) { - strncpy(auxent->x_file.x_fname, name, FILNMLEN); - } - else { - auxent->x_file.x_n.x_offset = string_size + 4; - auxent->x_file.x_n.x_zeroes = 0; - string_size += name_length + 1; - } -#else - strncpy(auxent->x_file.x_fname, name, FILNMLEN); - if (name_length > FILNMLEN) { - name[FILNMLEN] = '\0'; - } -#endif - } - else - { /* NOT A C_FILE SYMBOL */ - if (name_length <= SYMNMLEN) { - /* This name will fit into the symbol neatly */ - strncpy(native->u.syment._n._n_name, symbol->name, SYMNMLEN); - } - else { - native->u.syment._n._n_n._n_offset = string_size + 4; - native->u.syment._n._n_n._n_zeroes = 0; - string_size += name_length + 1; - } - } -} - - - -static unsigned int -DEFUN(coff_write_symbol,(abfd, symbol, native, written), -bfd *abfd AND -asymbol *symbol AND -combined_entry_type *native AND -unsigned int written) -{ - unsigned int numaux = native->u.syment.n_numaux; - int type = native->u.syment.n_type; - int class = native->u.syment.n_sclass; - SYMENT buf; - unsigned int j; - - coff_fix_symbol_name(abfd, symbol, native); - coff_swap_sym_out(abfd, &native->u.syment, &buf); - bfd_write((PTR)& buf, 1, SYMESZ, abfd); - for (j = 0; j != native->u.syment.n_numaux; j++) - { - AUXENT buf1; - bzero((PTR)&buf, AUXESZ); - coff_swap_aux_out(abfd, - &( (native + j + 1)->u.auxent), type, class, &buf1); - bfd_write((PTR) (&buf1), 1, AUXESZ, abfd); - } - /* - Reuse somewhere in the symbol to keep the index - */ - set_index(symbol, written); - return written + 1 + numaux; -} - - -static unsigned int -DEFUN(coff_write_alien_symbol,(abfd, symbol, written), - bfd *abfd AND - asymbol *symbol AND - unsigned int written) -{ - /* - This symbol has been created by the loader, or come from a non - coff format. It has no native element to inherit, make our - own - */ - combined_entry_type *native; - combined_entry_type dummy; - native = &dummy; - native->u.syment.n_type = T_NULL; -#ifdef I960 - native->u.syment.n_flags = 0; -#endif - if (symbol->flags & BSF_ABSOLUTE) { - native->u.syment.n_scnum = N_ABS; - native->u.syment.n_value = symbol->value; - } - else if (symbol->flags & (BSF_UNDEFINED | BSF_FORT_COMM)) { - native->u.syment.n_scnum = N_UNDEF; - native->u.syment.n_value = symbol->value; - } - else if (symbol->flags & BSF_DEBUGGING) { - /* - remove name so it doesn't take up any space - */ - symbol->name = ""; - } - else { - native->u.syment.n_scnum = symbol->section->output_section->index + - 1; - native->u.syment.n_value = symbol->value + - symbol->section->output_section->vma + - symbol->section->output_offset; -#ifdef I960 - /* Copy the any flags from the the file hdr into the symbol */ - { - coff_symbol_type *c = coff_symbol_from(abfd, symbol); - if (c != (coff_symbol_type *)NULL) { - native->u.syment.n_flags = c->symbol.the_bfd->flags; - } - } -#endif - } - -#ifdef HASPAD1 - native->u.syment.pad1[0] = 0; - native->u.syment.pad1[0] = 0; -#endif - - native->u.syment.n_type = 0; - if (symbol->flags & BSF_LOCAL) - native->u.syment.n_sclass = C_STAT; - else - native->u.syment.n_sclass = C_EXT; - native->u.syment.n_numaux = 0; - - return coff_write_symbol(abfd, symbol, native, written); -} - -static unsigned int -DEFUN(coff_write_native_symbol,(abfd, symbol, written), -bfd *abfd AND -coff_symbol_type *symbol AND -unsigned int written) -{ - /* - Does this symbol have an ascociated line number - if so then - make it remember this symbol index. Also tag the auxent of - this symbol to point to the right place in the lineno table - */ - combined_entry_type *native = symbol->native; - - alent *lineno = symbol->lineno; - - if (lineno) { - unsigned int count = 0; - lineno[count].u.offset = written; - if (native->u.syment.n_numaux) { - union internal_auxent *a = &((native+1)->u.auxent); - - a->x_sym.x_fcnary.x_fcn.x_lnnoptr = - symbol->symbol.section->output_section->moving_line_filepos; - } - /* - And count and relocate all other linenumbers - */ - count++; - while (lineno[count].line_number) { - lineno[count].u.offset += - symbol->symbol.section->output_section->vma + - symbol->symbol.section->output_offset; - count++; - } - symbol->symbol.section->output_section->moving_line_filepos += - count * LINESZ; - } - return coff_write_symbol(abfd, &( symbol->symbol), native,written); -} - -static void -DEFUN(coff_write_symbols,(abfd), - bfd *abfd) -{ - unsigned int i; - unsigned int limit = bfd_get_symcount(abfd); - unsigned int written = 0; - - asymbol **p; - - string_size = 0; - - - /* Seek to the right place */ - bfd_seek(abfd, obj_sym_filepos(abfd), SEEK_SET); - - /* Output all the symbols we have */ - - written = 0; - for (p = abfd->outsymbols, i = 0; i < limit; i++, p++) - { - asymbol *symbol = *p; - coff_symbol_type *c_symbol = coff_symbol_from(abfd, symbol); - - if (c_symbol == (coff_symbol_type *) NULL || - c_symbol->native == (combined_entry_type *)NULL) - { - written = coff_write_alien_symbol(abfd, symbol, written); - } - else - { - written = coff_write_native_symbol(abfd, c_symbol, written); - } - - } - - bfd_get_symcount(abfd) = written; - - /* Now write out strings */ - - if (string_size != 0) - { - unsigned int size = string_size + 4; - bfd_byte buffer[4]; - - bfd_h_put_32(abfd, size, buffer); - bfd_write((PTR) buffer, 1, sizeof(buffer), abfd); - for (p = abfd->outsymbols, i = 0; - i < limit; - i++, p++) - { - asymbol *q = *p; - size_t name_length = strlen(q->name); - int maxlen; - coff_symbol_type* c_symbol = coff_symbol_from(abfd, q); - maxlen = ((c_symbol != NULL && c_symbol->native != NULL) && - (c_symbol->native->u.syment.n_sclass == C_FILE)) ? - FILNMLEN : SYMNMLEN; - - if (name_length > maxlen) { - bfd_write((PTR) (q->name), 1, name_length + 1, abfd); - } - } - } - else { - /* We would normally not write anything here, but we'll write - out 4 so that any stupid coff reader which tries to read - the string table even when there isn't one won't croak. - */ - - uint32e_type size = 4; - size = size; - bfd_write((PTR)&size, 1, sizeof(size), abfd); - - } -} - -/*doc* -@subsubsection Writing Relocations -To write a relocations, all the back end does is step though the -canonical relocation table, and create an @code{internal_reloc}. The -symbol index to use is removed from the @code{offset} field in the -symbol table supplied, the address comes directly from the sum of the -section base address and the relocation offset and the type is dug -directly from the howto field. - -Then the @code{internal_reloc} is swapped into the shape of an -@code{external_reloc} and written out to disk. -*/ - -static void -DEFUN(coff_write_relocs,(abfd), - bfd *abfd) -{ - asection *s; - for (s = abfd->sections; s != (asection *) NULL; s = s->next) { - unsigned int i; - struct external_reloc dst; - - arelent **p = s->orelocation; - bfd_seek(abfd, s->rel_filepos, SEEK_SET); - for (i = 0; i < s->reloc_count; i++) { - struct internal_reloc n; - arelent *q = p[i]; - memset((PTR)&n, 0, sizeof(n)); - n.r_vaddr = q->address + s->vma; - if (q->sym_ptr_ptr) { - n.r_symndx = get_index((*(q->sym_ptr_ptr))); - } -#ifdef SELECT_RELOC - /* Work out reloc type from what is required */ - SELECT_RELOC(n.r_type, q->howto); -#else - n.r_type = q->howto->type; -#endif - coff_swap_reloc_out(abfd, &n, &dst); - bfd_write((PTR) &n, 1, RELSZ, abfd); - } - } -} -#endif /* NO_COFF_SYMBOLS */ - -#ifndef NO_COFF_LINENOS - -static void -DEFUN(coff_write_linenumbers,(abfd), - bfd *abfd) -{ - asection *s; - for (s = abfd->sections; s != (asection *) NULL; s = s->next) { - if (s->lineno_count) { - asymbol **q = abfd->outsymbols; - bfd_seek(abfd, s->line_filepos, SEEK_SET); - /* Find all the linenumbers in this section */ - while (*q) { - asymbol *p = *q; - alent *l = BFD_SEND(p->the_bfd, _get_lineno, (p->the_bfd, p)); - if (l) { - /* Found a linenumber entry, output */ - struct internal_lineno out; - LINENO buff; - memset( (PTR)&out, 0, sizeof(out)); - out.l_lnno = 0; - out.l_addr.l_symndx = l->u.offset; - coff_swap_lineno_out(abfd, &out, &buff); - bfd_write((PTR) &buff, 1, LINESZ, abfd); - l++; - while (l->line_number) { - out.l_lnno = l->line_number; - out.l_addr.l_symndx = l->u.offset; - coff_swap_lineno_out(abfd, &out, &buff); - bfd_write((PTR) &buff, 1, LINESZ, abfd); - l++; - } - } - q++; - } - } - } -} - -static alent * -DEFUN(coff_get_lineno,(ignore_abfd, symbol), - bfd *ignore_abfd AND - asymbol *symbol) -{ - return coffsymbol(symbol)->lineno; -} - -#endif /* NO_COFF_LINENOS */ - -static asymbol * -coff_make_empty_symbol(abfd) -bfd *abfd; -{ - coff_symbol_type *new = (coff_symbol_type *) bfd_alloc(abfd, sizeof(coff_symbol_type)); - if (new == NULL) { - bfd_error = no_memory; - return (NULL); - } /* on error */ - new->native = 0; - new->lineno = (alent *) NULL; - new->symbol.the_bfd = abfd; - return &new->symbol; -} - -#ifndef NO_COFF_SYMBOLS - -static void -DEFUN(coff_print_symbol,(ignore_abfd, filep, symbol, how), - bfd *ignore_abfd AND - PTR filep AND - asymbol *symbol AND - bfd_print_symbol_type how) -{ - FILE *file = (FILE *)filep; - switch (how) { - case bfd_print_symbol_name: - fprintf(file, "%s", symbol->name); - break; - case bfd_print_symbol_more: - fprintf(file, "coff %lx %lx", (unsigned long) coffsymbol(symbol)->native, - (unsigned long) coffsymbol(symbol)->lineno); - break; - case bfd_print_symbol_nm: - case bfd_print_symbol_all: - { - CONST char *section_name = symbol->section == (asection *) NULL ? - "*abs" : symbol->section->name; - bfd_print_symbol_vandf((PTR) file, symbol); - - fprintf(file, " %-5s %s %s %s", - section_name, - coffsymbol(symbol)->native ? "n" : "g", - coffsymbol(symbol)->lineno ? "l" : " ", - symbol->name); - } - - - break; - } -} - -#endif /* NO_COFF_SYMBOLS */ - -/* Set flags and magic number of a coff file from architecture and machine - type. Result is true if we can represent the arch&type, false if not. */ - -static boolean -DEFUN(coff_set_flags,(abfd, magicp, flagsp), - bfd *abfd AND - unsigned *magicp AND - unsigned short *flagsp) -{ - switch (bfd_get_arch(abfd)) { - -#ifdef I960ROMAGIC - - case bfd_arch_i960: - - { - unsigned flags; - *magicp = I960ROMAGIC; - /* - ((bfd_get_file_flags(abfd) & WP_TEXT) ? I960ROMAGIC : - I960RWMAGIC); FIXME??? - */ - switch (bfd_get_mach(abfd)) { - case bfd_mach_i960_core: - flags = F_I960CORE; - break; - case bfd_mach_i960_kb_sb: - flags = F_I960KB; - break; - case bfd_mach_i960_mc: - flags = F_I960MC; - break; - case bfd_mach_i960_xa: - flags = F_I960XA; - break; - case bfd_mach_i960_ca: - flags = F_I960CA; - break; - case bfd_mach_i960_ka_sa: - flags = F_I960KA; - break; - default: - return false; - } - *flagsp = flags; - return true; - } - break; -#endif -#ifdef MIPS - case bfd_arch_mips: - *magicp = MIPS_MAGIC_2; - return true; - break; -#endif -#ifdef I386MAGIC - case bfd_arch_i386: - *magicp = I386MAGIC; - return true; -#endif -#ifdef MC68MAGIC - case bfd_arch_m68k: - *magicp = MC68MAGIC; - return true; -#endif - -#ifdef MC88MAGIC - case bfd_arch_m88k: - *magicp = MC88OMAGIC; - return true; - break; -#endif - -#ifdef A29K_MAGIC_BIG - case bfd_arch_a29k: - if (abfd->xvec->byteorder_big_p) - *magicp = A29K_MAGIC_BIG; - else - *magicp = A29K_MAGIC_LITTLE; - return true; - break; -#endif - -#ifdef U802TOCMAGIC - case bfd_arch_rs6000: - *magicp = U802TOCMAGIC; - break; -#endif - - default: /* Unknown architecture */ - /* return false; -- fall through to "return false" below, to avoid - "statement never reached" errors on the one below. */ - break; - } - - return false; -} - - -static boolean -DEFUN(coff_set_arch_mach,(abfd, arch, machine), - bfd *abfd AND - enum bfd_architecture arch AND - unsigned long machine) -{ - unsigned dummy1; - unsigned short dummy2; - bfd_default_set_arch_mach(abfd, arch, machine); - - if (arch != bfd_arch_unknown && - coff_set_flags(abfd, &dummy1, &dummy2) != true) - return false; /* We can't represent this type */ - return true; /* We're easy ... */ -} - - -/* Calculate the file position for each section. */ - -static void -DEFUN(coff_compute_section_file_positions,(abfd), - bfd *abfd) -{ - asection *current; - asection *previous = (asection *)NULL; - file_ptr sofar = FILHSZ; - file_ptr old_sofar; - if (bfd_get_start_address(abfd)) - { - /* A start address may have been added to the original file. In this - case it will need an optional header to record it. */ - abfd->flags |= EXEC_P; - } - - if (abfd->flags & EXEC_P) - sofar += AOUTSZ; - - sofar += abfd->section_count * SCNHSZ; - for (current = abfd->sections; - current != (asection *)NULL; - current = current->next) { - - /* Only deal with sections which have contents */ - if (!(current->flags & SEC_HAS_CONTENTS)) - continue; - - /* Align the sections in the file to the same boundary on - which they are aligned in virtual memory. I960 doesn't - do this (FIXME) so we can stay in sync with Intel. 960 - doesn't yet page from files... */ -#ifndef I960 - { - /* make sure this section is aligned on the right boundary - by - padding the previous section up if necessary */ - - old_sofar= sofar; - sofar = ALIGN(sofar, 1 << current->alignment_power); - if (previous != (asection *)NULL) { - previous->size += sofar - old_sofar; - } - } - -#endif - /* FIXME, in demand paged files, the low order bits of the file - offset must match the low order bits of the virtual address. - "Low order" is apparently implementation defined. Add code - here to round sofar up to match the virtual address. */ - - current->filepos = sofar; - - /* make sure that this section is of the right size too */ - old_sofar = sofar += current->size; - sofar = ALIGN(sofar, 1 << current->alignment_power); - current->size += sofar - old_sofar ; - - previous = current; - } - obj_relocbase(abfd) = sofar; -} - - - - -/* SUPPRESS 558 */ -/* SUPPRESS 529 */ -static boolean -DEFUN(coff_write_object_contents,(abfd), - bfd *abfd) - { - asection *current; - boolean hasrelocs = false; - boolean haslinno = false; - file_ptr reloc_base; - file_ptr lineno_base; - file_ptr sym_base; - file_ptr scn_base; - file_ptr data_base; - unsigned long reloc_size = 0; - unsigned long lnno_size = 0; - asection *text_sec = NULL; - asection *data_sec = NULL; - asection *bss_sec = NULL; - - struct internal_filehdr internal_f; - struct internal_aouthdr internal_a; - - - bfd_error = system_call_error; - - - if(abfd->output_has_begun == false) { - coff_compute_section_file_positions(abfd); - } - - if (abfd->sections != (asection *)NULL) { - scn_base = abfd->sections->filepos; - } - else { - scn_base = 0; - } - if (bfd_seek(abfd, scn_base, SEEK_SET) != 0) - return false; - reloc_base = obj_relocbase(abfd); - - /* Make a pass through the symbol table to count line number entries and - put them into the correct asections */ - -#ifndef NO_COFF_LINENOS - coff_count_linenumbers(abfd); -#endif - data_base = scn_base; - - /* Work out the size of the reloc and linno areas */ - - for (current = abfd->sections; current != NULL; current = current->next) { - reloc_size += current->reloc_count * RELSZ; -#ifndef NO_COFF_LINENOS - lnno_size += current->lineno_count * LINESZ; -#endif - data_base += SCNHSZ; - } - - lineno_base = reloc_base + reloc_size; - sym_base = lineno_base + lnno_size; - - /* Indicate in each section->line_filepos its actual file address */ - for (current = abfd->sections; current != NULL; current = current->next) { - if (current->lineno_count) { - current->line_filepos = lineno_base; - current->moving_line_filepos = lineno_base; -#ifndef NO_COFF_LINENOS - lineno_base += current->lineno_count * LINESZ; -#endif - } - else { - current->line_filepos = 0; - } - if (current->reloc_count) { - current->rel_filepos = reloc_base; - reloc_base += current->reloc_count * sizeof(struct internal_reloc); - } - else { - current->rel_filepos = 0; - } - } - - /* Write section headers to the file. */ - - bfd_seek(abfd, - (file_ptr) ((abfd->flags & EXEC_P) ? - (FILHSZ + AOUTSZ) : FILHSZ), - SEEK_SET); - - { -#if 0 - unsigned int pad = abfd->flags & D_PAGED ? data_base : 0; -#endif - unsigned int pad = 0; - - for (current = abfd->sections; current != NULL; current = current->next) { - struct internal_scnhdr section; - strncpy(&(section.s_name[0]), current->name, 8); - section.s_vaddr = current->vma + pad; - section.s_paddr = current->vma + pad; - section.s_size = current->size - pad; - /* - If this section has no size or is unloadable then the scnptr - will be 0 too - */ - if (current->size - pad == 0 || - (current->flags & SEC_LOAD) == 0) { - section.s_scnptr = 0; - } - else { - section.s_scnptr = current->filepos; - } - section.s_relptr = current->rel_filepos; - section.s_lnnoptr = current->line_filepos; - section.s_nreloc = current->reloc_count; - section.s_nlnno = current->lineno_count; - if (current->reloc_count != 0) - hasrelocs = true; - if (current->lineno_count != 0) - haslinno = true; - - section.s_flags = sec_to_styp_flags(current->name,current->flags); - - if (!strcmp(current->name, _TEXT)) { - text_sec = current; - } else if (!strcmp(current->name, _DATA)) { - data_sec = current; - } else if (!strcmp(current->name, _BSS)) { - bss_sec = current; - } - -#ifdef I960 - section.s_align = (current->alignment_power - ? 1 << current->alignment_power - : 0); - -#endif - { - SCNHDR buff; - - coff_swap_scnhdr_out(abfd, §ion, &buff); - bfd_write((PTR) (&buff), 1, SCNHSZ, abfd); - - } - pad = 0; - } - } - - /* OK, now set up the filehdr... */ - internal_f.f_nscns = abfd->section_count; - /* - We will NOT put a fucking timestamp in the header here. Every time you - put it back, I will come in and take it out again. I'm sorry. This - field does not belong here. We fill it with a 0 so it compares the - same but is not a reasonable time. -- gnu@cygnus.com - */ - /* - Well, I like it, so I'm conditionally compiling it in. - steve@cygnus.com - */ -#ifdef COFF_TIMESTAMP - internal_f.f_timdat = time(0); -#else - internal_f.f_timdat = 0; -#endif - - if (bfd_get_symcount(abfd) != 0) - internal_f.f_symptr = sym_base; - else - internal_f.f_symptr = 0; - - internal_f.f_flags = 0; - - if (abfd->flags & EXEC_P) - internal_f.f_opthdr = AOUTSZ; - else - internal_f.f_opthdr = 0; - - if (!hasrelocs) - internal_f.f_flags |= F_RELFLG; - if (!haslinno) - internal_f.f_flags |= F_LNNO; - if (0 == bfd_get_symcount(abfd)) - internal_f.f_flags |= F_LSYMS; - if (abfd->flags & EXEC_P) - internal_f.f_flags |= F_EXEC; -#if M88 - internal_f.f_flags |= F_AR32W; -#else - if (!abfd->xvec->byteorder_big_p) - internal_f.f_flags |= F_AR32WR; -#endif - /* - FIXME, should do something about the other byte orders and - architectures. - */ - - /* Set up architecture-dependent stuff */ - - { unsigned int magic = 0; - unsigned short flags = 0; - coff_set_flags(abfd, &magic, &flags); - internal_f.f_magic = magic; - internal_f.f_flags |= flags; - /* ...and the "opt"hdr... */ - -#ifdef A29K -# ifdef ULTRA3 /* NYU's machine */ - /* FIXME: This is a bogus check. I really want to see if there - * is a .shbss or a .shdata section, if so then set the magic - * number to indicate a shared data executable. - */ - if (internal_f.f_nscns >= 7) - internal_a.magic = SHMAGIC; /* Shared magic */ - else -# endif /* ULTRA3 */ - internal_a.magic = NMAGIC; /* Assume separate i/d */ -#define __A_MAGIC_SET__ -#endif /* A29K */ -#ifdef I960 - internal_a.magic = (magic == I960ROMAGIC ? NMAGIC : OMAGIC); -#define __A_MAGIC_SET__ -#endif /* I960 */ -#if M88 -#define __A_MAGIC_SET__ - internal_a.magic = PAGEMAGICBCS; -#endif /* M88 */ - -#if M68 || I386 || MIPS -#define __A_MAGIC_SET__ - /* Never was anything here for the 68k */ -#endif /* M88 */ - -#if RS6000COFF_C -#define __A_MAGIC_SET__ - internal_a.magic = (abfd->flags & D_PAGED)? RS6K_AOUTHDR_ZMAGIC: - (abfd->flags & WP_TEXT)? RS6K_AOUTHDR_NMAGIC: - RS6K_AOUTHDR_OMAGIC; -#endif - -#ifndef __A_MAGIC_SET__ -# include "Your aouthdr magic number is not being set!" -#else -# undef __A_MAGIC_SET__ -#endif - } - /* Now should write relocs, strings, syms */ - obj_sym_filepos(abfd) = sym_base; - -#ifndef NO_COFF_SYMBOLS - if (bfd_get_symcount(abfd) != 0) { - coff_renumber_symbols(abfd); - coff_mangle_symbols(abfd); - coff_write_symbols(abfd); - coff_write_linenumbers(abfd); - coff_write_relocs(abfd); - } -#endif /* NO_COFF_SYMBOLS */ - if (text_sec) { - internal_a.tsize = text_sec->size; - internal_a.text_start =text_sec->size ? text_sec->vma : 0; - } - if (data_sec) { - internal_a.dsize = data_sec->size; - internal_a.data_start = data_sec->size ? data_sec->vma : 0; - } - if (bss_sec) { - internal_a.bsize = bss_sec->size; - } - - internal_a.entry = bfd_get_start_address(abfd); - internal_f.f_nsyms = bfd_get_symcount(abfd); - - /* now write them */ - if (bfd_seek(abfd, 0L, SEEK_SET) != 0) - return false; - { - FILHDR buff; - coff_swap_filehdr_out(abfd, &internal_f, &buff); - bfd_write((PTR) &buff, 1, FILHSZ, abfd); - } - if (abfd->flags & EXEC_P) { - AOUTHDR buff; - coff_swap_aouthdr_out(abfd, &internal_a, &buff); - bfd_write((PTR) &buff, 1, AOUTSZ, abfd); - } - return true; -} - -#ifndef NO_COFF_SYMBOLS - -/* -this function transforms the offsets into the symbol table into -pointers to syments. -*/ - - -static void -DEFUN(coff_pointerize_aux,(ignore_abfd, table_base, type, class, auxent), -bfd *ignore_abfd AND -combined_entry_type *table_base AND -int type AND -int class AND -combined_entry_type *auxent) -{ - /* Don't bother if this is a file or a section */ - if (class == C_STAT && type == T_NULL) return; - if (class == C_FILE) return; - - /* Otherwise patch up */ - if (ISFCN(type) || ISTAG(class) || class == C_BLOCK) { - auxent->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.p = table_base + - auxent->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.l; - auxent->fix_end = 1; - } - if (auxent->u.auxent.x_sym.x_tagndx.l != 0) { - auxent->u.auxent.x_sym.x_tagndx.p = table_base + auxent->u.auxent.x_sym.x_tagndx.l; - auxent->fix_tag = 1; - } -} - -#endif /* NO_COFF_SYMBOLS */ - -static boolean -DEFUN(coff_set_section_contents,(abfd, section, location, offset, count), - bfd *abfd AND - sec_ptr section AND - PTR location AND - file_ptr offset AND - bfd_size_type count) -{ - if (abfd->output_has_begun == false) /* set by bfd.c handler */ - coff_compute_section_file_positions(abfd); - - bfd_seek(abfd, (file_ptr) (section->filepos + offset), SEEK_SET); - - if (count != 0) { - return (bfd_write(location, 1, count, abfd) == count) ? true : false; - } - return true; -} -#if 0 -static boolean -coff_close_and_cleanup(abfd) - bfd *abfd; -{ - if (!bfd_read_p(abfd)) - switch (abfd->format) { - case bfd_archive: - if (!_bfd_write_archive_contents(abfd)) - return false; - break; - case bfd_object: - if (!coff_write_object_contents(abfd)) - return false; - break; - default: - bfd_error = invalid_operation; - return false; - } - - /* We depend on bfd_close to free all the memory on the obstack. */ - /* FIXME if bfd_release is not using obstacks! */ - return true; -} - -#endif -static PTR -buy_and_read(abfd, where, seek_direction, size) - bfd *abfd; - file_ptr where; - int seek_direction; - size_t size; -{ - PTR area = (PTR) bfd_alloc(abfd, size); - if (!area) { - bfd_error = no_memory; - return (NULL); - } - bfd_seek(abfd, where, seek_direction); - if (bfd_read(area, 1, size, abfd) != size) { - bfd_error = system_call_error; - return (NULL); - } /* on error */ - return (area); -} /* buy_and_read() */ - - -#ifndef NO_COFF_SYMBOLS - -static char * -DEFUN(build_string_table,(abfd), -bfd *abfd) -{ - char string_table_size_buffer[4]; - unsigned int string_table_size; - char *string_table; - - /* At this point we should be "seek"'d to the end of the - symbols === the symbol table size. */ - if (bfd_read((char *) string_table_size_buffer, - sizeof(string_table_size_buffer), - 1, abfd) != sizeof(string_table_size)) { - bfd_error = system_call_error; - return (NULL); - } /* on error */ - - string_table_size = bfd_h_get_32(abfd, (bfd_byte *) string_table_size_buffer); - - if ((string_table = (PTR) bfd_alloc(abfd, string_table_size -= 4)) == NULL) { - bfd_error = no_memory; - return (NULL); - } /* on mallocation error */ - if (bfd_read(string_table, string_table_size, 1, abfd) != string_table_size) { - bfd_error = system_call_error; - return (NULL); - } - return string_table; -} - -/* Allocate space for the ".debug" section, and read it. - We did not read the debug section until now, because - we didn't want to go to the trouble until someone needed it. */ - -static char * -DEFUN(build_debug_section,(abfd), - bfd *abfd) -{ - char *debug_section; - long position; - - asection *sect = bfd_get_section_by_name (abfd, ".debug"); - - if (!sect) { - bfd_error = no_debug_section; - return NULL; - } - - debug_section = (PTR) bfd_alloc (abfd, bfd_section_size (abfd, sect)); - if (debug_section == NULL) { - bfd_error = no_memory; - return NULL; - } - - /* Seek to the beginning of the `.debug' section and read it. - Save the current position first; it is needed by our caller. - Then read debug section and reset the file pointer. */ - - position = bfd_tell (abfd); - bfd_seek (abfd, sect->filepos, SEEK_SET); - if (bfd_read (debug_section, bfd_section_size (abfd, sect), 1, abfd) - != bfd_section_size (abfd, sect)) { - bfd_error = system_call_error; - return NULL; - } - bfd_seek (abfd, position, SEEK_SET); - return debug_section; -} - - -/* Return a pointer to a malloc'd copy of 'name'. 'name' may not be - \0-terminated, but will not exceed 'maxlen' characters. The copy *will* - be \0-terminated. */ -static char * -DEFUN(copy_name,(abfd, name, maxlen), - bfd *abfd AND - char *name AND - int maxlen) -{ - int len; - char *newname; - - for (len = 0; len < maxlen; ++len) { - if (name[len] == '\0') { - break; - } - } - - if ((newname = (PTR) bfd_alloc(abfd, len+1)) == NULL) { - bfd_error = no_memory; - return (NULL); - } - strncpy(newname, name, len); - newname[len] = '\0'; - return newname; -} - - -/* Read a symbol table into freshly bfd_allocated memory, swap it, and - knit the symbol names into a normalized form. By normalized here I - mean that all symbols have an n_offset pointer that points to a null- - terminated string. */ - -#ifndef SYMNAME_IN_DEBUG -#define SYMNAME_IN_DEBUG(x) 0 -#endif - -static combined_entry_type * -DEFUN(get_normalized_symtab,(abfd), -bfd *abfd) -{ - combined_entry_type *internal; - combined_entry_type *internal_ptr; - combined_entry_type *internal_end; - SYMENT *raw; - SYMENT *raw_src; - SYMENT *raw_end; - char *string_table = NULL; - char *debug_section = NULL; - unsigned long size; - - unsigned int raw_size; - if (obj_raw_syments(abfd) != (combined_entry_type *)NULL) { - return obj_raw_syments(abfd); - } - if ((size = bfd_get_symcount(abfd) * sizeof(combined_entry_type)) == 0) { - bfd_error = no_symbols; - return (NULL); - } - - internal = (combined_entry_type *)bfd_alloc(abfd, size); - internal_end = internal + bfd_get_symcount(abfd); - - raw_size = bfd_get_symcount(abfd) * SYMESZ; - raw = (SYMENT *)bfd_alloc(abfd,raw_size); - - if (bfd_seek(abfd, obj_sym_filepos(abfd), SEEK_SET) == -1 - || bfd_read((PTR)raw, raw_size, 1, abfd) != raw_size) { - bfd_error = system_call_error; - return (NULL); - } - /* mark the end of the symbols */ - raw_end = raw + bfd_get_symcount(abfd); - /* - FIXME SOMEDAY. A string table size of zero is very weird, but - probably possible. If one shows up, it will probably kill us. - */ - - /* Swap all the raw entries */ - for (raw_src = raw, internal_ptr = internal; - raw_src < raw_end; - raw_src++, internal_ptr++) { - - unsigned int i; - coff_swap_sym_in(abfd, (char *)raw_src, (char *)&internal_ptr->u.syment); - internal_ptr->fix_tag = 0; - internal_ptr->fix_end = 0; - - for (i = internal_ptr->u.syment.n_numaux; - i; - --i, raw_src++, internal_ptr++) { - - (internal_ptr+1)->fix_tag = 0; - (internal_ptr+1)->fix_end = 0; - - coff_swap_aux_in(abfd, (char *)(raw_src +1), - internal_ptr->u.syment.n_type, - internal_ptr->u.syment.n_sclass, - &(internal_ptr+1)->u.auxent); - - coff_pointerize_aux(abfd, - internal, - internal_ptr->u.syment.n_type, - internal_ptr->u.syment.n_sclass, - internal_ptr +1); - } - } - - /* Free all the raw stuff */ - bfd_release(abfd, raw); - - for (internal_ptr = internal; internal_ptr < internal_end; - internal_ptr ++) - { - if (internal_ptr->u.syment.n_sclass == C_FILE) { - /* make a file symbol point to the name in the auxent, since - the text ".file" is redundant */ - if ((internal_ptr+1)->u.auxent.x_file.x_n.x_zeroes == 0) { - /* the filename is a long one, point into the string table */ - if (string_table == NULL) { - string_table = build_string_table(abfd); - } - - internal_ptr->u.syment._n._n_n._n_offset = - (int) (string_table - 4 + - (internal_ptr+1)->u.auxent.x_file.x_n.x_offset); - } - else { - /* ordinary short filename, put into memory anyway */ - internal_ptr->u.syment._n._n_n._n_offset = (int) - copy_name(abfd, (internal_ptr+1)->u.auxent.x_file.x_fname, - FILNMLEN); - } - } - else { - if (internal_ptr->u.syment._n._n_n._n_zeroes != 0) { - /* This is a "short" name. Make it long. */ - unsigned long i = 0; - char *newstring = NULL; - - /* find the length of this string without walking into memory - that isn't ours. */ - for (i = 0; i < 8; ++i) { - if (internal_ptr->u.syment._n._n_name[i] == '\0') { - break; - } /* if end of string */ - } /* possible lengths of this string. */ - - if ((newstring = (PTR) bfd_alloc(abfd, ++i)) == NULL) { - bfd_error = no_memory; - return (NULL); - } /* on error */ - bzero(newstring, i); - strncpy(newstring, internal_ptr->u.syment._n._n_name, i-1); - internal_ptr->u.syment._n._n_n._n_offset = (int) newstring; - internal_ptr->u.syment._n._n_n._n_zeroes = 0; - } - else if (!SYMNAME_IN_DEBUG(&internal_ptr->u.syment)) { - /* Long name already. Point symbol at the string in the table. */ - if (string_table == NULL) { - string_table = build_string_table(abfd); - } - internal_ptr->u.syment._n._n_n._n_offset = (int) - (string_table - 4 + internal_ptr->u.syment._n._n_n._n_offset); - } - else { - /* Long name in debug section. Very similar. */ - if (debug_section == NULL) { - debug_section = build_debug_section(abfd); - } - internal_ptr->u.syment._n._n_n._n_offset = (int) - (debug_section + internal_ptr->u.syment._n._n_n._n_offset); - } - } - internal_ptr += internal_ptr->u.syment.n_numaux; - } - - obj_raw_syments(abfd) = internal; - - return (internal); -} /* get_normalized_symtab() */ - -#endif /* NO_COFF_SYMBOLS */ - -static -struct sec * -DEFUN(section_from_bfd_index,(abfd, index), - bfd *abfd AND - int index) -{ - if (index > 0) { - struct sec *answer = abfd->sections; - while (--index) { - answer = answer->next; - } - return answer; - } - return 0; -} - -#ifndef NO_COFF_LINENOS - -/*doc* -@subsubsection Reading Linenumbers -Createing the linenumber table is done by reading in the entire coff -linenumber table, and creating another table for internal use. - -A coff line number table is structured so that each -function is marked as having a line number of 0. Each line within the -function is an offset from the first line in the function. The base of -the line number information for the table is stored in the symbol -associated with the function. - -The information is copied from the external to the internal table, and -each symbol which marks a function is marked by pointing its... - -**How does this work ?** - -*/ - -static boolean -coff_slurp_line_table(abfd, asect) -bfd *abfd; -asection *asect; - { - LINENO *native_lineno; - alent *lineno_cache; - - BFD_ASSERT(asect->lineno == (alent *) NULL); - - native_lineno = (LINENO *) buy_and_read(abfd, - asect->line_filepos, - SEEK_SET, - (size_t) (LINESZ * - asect->lineno_count)); - lineno_cache = - (alent *) bfd_alloc(abfd, (size_t) ((asect->lineno_count + 1) * sizeof(alent))); - if (lineno_cache == NULL) { - bfd_error = no_memory; - return false; - } else { - unsigned int counter = 0; - alent *cache_ptr = lineno_cache; - LINENO *src = native_lineno; - - while (counter < asect->lineno_count) { - struct internal_lineno dst; - coff_swap_lineno_in(abfd, src, &dst); - cache_ptr->line_number = dst.l_lnno; - - if (cache_ptr->line_number == 0) { - coff_symbol_type *sym = - (coff_symbol_type *) (dst.l_addr.l_symndx - + obj_symbol_slew(abfd) - + obj_raw_syments(abfd))->u.syment._n._n_n._n_zeroes; - cache_ptr->u.sym = (asymbol *) sym; - sym->lineno = cache_ptr; - } - else { - cache_ptr->u.offset = dst.l_addr.l_paddr - - bfd_section_vma(abfd, asect); - } /* If no linenumber expect a symbol index */ - - cache_ptr++; - src++; - counter++; - } - cache_ptr->line_number = 0; - - } - asect->lineno = lineno_cache; - /* FIXME, free native_lineno here, or use alloca or something. */ - return true; - } /* coff_slurp_line_table() */ - -#endif /* NO_COFF_LINENOS */ - -#ifndef NO_COFF_LINENOS - -static boolean -DEFUN(coff_slurp_symbol_table,(abfd), - bfd *abfd) -{ - combined_entry_type *native_symbols; - coff_symbol_type *cached_area; - unsigned int *table_ptr; - - unsigned int number_of_symbols = 0; - if (obj_symbols(abfd)) - return true; - bfd_seek(abfd, obj_sym_filepos(abfd), SEEK_SET); - - /* Read in the symbol table */ - if ((native_symbols = get_normalized_symtab(abfd)) == NULL) { - return (false); - } /* on error */ - - /* Allocate enough room for all the symbols in cached form */ - cached_area = - (coff_symbol_type *) - bfd_alloc(abfd, (size_t) (bfd_get_symcount(abfd) * sizeof(coff_symbol_type))); - - if (cached_area == NULL) { - bfd_error = no_memory; - return false; - } /* on error */ - table_ptr = - (unsigned int *) - bfd_alloc(abfd, (size_t) (bfd_get_symcount(abfd) * sizeof(unsigned int))); - - if (table_ptr == NULL) { - bfd_error = no_memory; - return false; - } - else - { - coff_symbol_type *dst = cached_area; - unsigned int last_native_index = bfd_get_symcount(abfd); - unsigned int this_index = 0; - while (this_index < last_native_index) { - combined_entry_type *src = native_symbols + this_index; - table_ptr[this_index] = number_of_symbols; - dst->symbol.the_bfd = abfd; - - dst->symbol.name = (char *)(src->u.syment._n._n_n._n_offset); - /* - We use the native name field to point to the cached field - */ - src->u.syment._n._n_n._n_zeroes = (int) dst; - dst->symbol.section = section_from_bfd_index(abfd, - src->u.syment.n_scnum); - switch (src->u.syment.n_sclass) { -#ifdef I960 - case C_LEAFEXT: -#if 0 - dst->symbol.value = src->u.syment.n_value - dst->symbol.section->vma; - dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL; - dst->symbol.flags |= BSF_NOT_AT_END; -#endif - /* Fall through to next case */ - -#endif - - case C_EXT: -#ifdef RS6000COFF_C - case C_HIDEXT: -#endif - if ((src->u.syment.n_scnum) == 0) { - if ((src->u.syment.n_value) == 0) { - dst->symbol.flags = BSF_UNDEFINED; - dst->symbol.value= 0; - } - else { - dst->symbol.flags = BSF_FORT_COMM; - dst->symbol.value = (src->u.syment.n_value); - } - } - else { - /* - Base the value as an index from the base of the - section - */ - if (dst->symbol.section == (asection *) NULL) { - dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL | BSF_ABSOLUTE; - dst->symbol.value = src->u.syment.n_value; - } - else { - dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL; - dst->symbol.value = src->u.syment.n_value - dst->symbol.section->vma; - } - if (ISFCN((src->u.syment.n_type))) { - /* - A function ext does not go at the end of a file - */ - dst->symbol.flags |= BSF_NOT_AT_END; - } - } - - - break; - - case C_STAT: /* static */ -#ifdef I960 - case C_LEAFSTAT: /* static leaf procedure */ -#endif - case C_LABEL: /* label */ - if (src->u.syment.n_scnum == -2) - dst->symbol.flags = BSF_DEBUGGING; - else - dst->symbol.flags = BSF_LOCAL; - /* - Base the value as an index from the base of the section, if - there is one - */ - if (dst->symbol.section) - dst->symbol.value = (src->u.syment.n_value) - - dst->symbol.section->vma; - else - dst->symbol.value = (src->u.syment.n_value) ; - break; - - case C_MOS: /* member of structure */ - case C_EOS: /* end of structure */ -#ifdef NOTDEF /* C_AUTOARG has the same value */ -#ifdef C_GLBLREG - case C_GLBLREG: /* A29k-specific storage class */ -#endif -#endif - case C_REGPARM: /* register parameter */ - case C_REG: /* register variable */ -#ifdef C_AUTOARG - case C_AUTOARG: /* 960-specific storage class */ -#endif - case C_TPDEF: /* type definition */ - case C_ARG: - case C_AUTO: /* automatic variable */ - case C_FIELD: /* bit field */ - case C_ENTAG: /* enumeration tag */ - case C_MOE: /* member of enumeration */ - case C_MOU: /* member of union */ - case C_UNTAG: /* union tag */ - dst->symbol.flags = BSF_DEBUGGING; - dst->symbol.value = (src->u.syment.n_value); - break; - - case C_FILE: /* file name */ - case C_STRTAG: /* structure tag */ -#ifdef RS6000COFF_C - case C_BINCL: /* beginning of include file */ - case C_EINCL: /* ending of include file */ - case C_GSYM: - case C_LSYM: - case C_PSYM: - case C_RSYM: - case C_RPSYM: - case C_STSYM: - case C_DECL: - case C_ENTRY: - case C_FUN: - case C_BSTAT: - case C_ESTAT: -#endif - dst->symbol.flags = BSF_DEBUGGING; - dst->symbol.value = (src->u.syment.n_value); - break; - - case C_BLOCK: /* ".bb" or ".eb" */ - case C_FCN: /* ".bf" or ".ef" */ - case C_EFCN: /* physical end of function */ - dst->symbol.flags = BSF_LOCAL; - /* - Base the value as an index from the base of the section - */ - dst->symbol.value = (src->u.syment.n_value) - dst->symbol.section->vma; - break; - - case C_NULL: - case C_EXTDEF: /* external definition */ - case C_ULABEL: /* undefined label */ - case C_USTATIC: /* undefined static */ - case C_LINE: /* line # reformatted as symbol table entry */ - case C_ALIAS: /* duplicate tag */ - case C_HIDDEN: /* ext symbol in dmert public lib */ - default: - - fprintf(stderr,"Unrecognized storage class %d\n", - src->u.syment.n_sclass); - abort(); - dst->symbol.flags = BSF_DEBUGGING; - dst->symbol.value = (src->u.syment.n_value); - break; - } - - BFD_ASSERT(dst->symbol.flags != 0); - - dst->native = src; - - dst->symbol.udata = 0; - dst->lineno = (alent *) NULL; - this_index += (src->u.syment.n_numaux) + 1; - dst++; - number_of_symbols++; - } /* walk the native symtab */ - } /* bfdize the native symtab */ - - obj_symbols(abfd) = cached_area; - obj_raw_syments(abfd) = native_symbols; - - bfd_get_symcount(abfd) = number_of_symbols; - obj_convert(abfd) = table_ptr; - /* Slurp the line tables for each section too */ - { - asection *p; - p = abfd->sections; - while (p) { - coff_slurp_line_table(abfd, p); - p = p->next; - } - } - return true; -} /* coff_slurp_symbol_table() */ - -static unsigned int -coff_get_symtab_upper_bound(abfd) -bfd *abfd; - { - if (!coff_slurp_symbol_table(abfd)) - return 0; - - return (bfd_get_symcount(abfd) + 1) * (sizeof(coff_symbol_type *)); - } - - -static unsigned int -DEFUN(coff_get_symtab, (abfd, alocation), - bfd *abfd AND - asymbol **alocation) -{ - unsigned int counter = 0; - coff_symbol_type *symbase; - coff_symbol_type **location = (coff_symbol_type **) (alocation); - if (!coff_slurp_symbol_table(abfd)) - return 0; - - symbase = obj_symbols(abfd); - while (counter < bfd_get_symcount(abfd)) - { - /* This nasty code looks at the symbol to decide whether or - not it is descibes a constructor/destructor entry point. It - is structured this way to (hopefully) speed non matches */ - - if (symbase->symbol.name[9] == '$') - { - bfd_constructor_entry(abfd, - (asymbol **)location, - symbase->symbol.name[10] == 'I' ? - "CTOR" : "DTOR"); - } - - *(location++) = symbase++; - counter++; - } - *location++ = 0; - return bfd_get_symcount(abfd); -} - -#endif /* NO_COFF_SYMBOLS */ - -static unsigned int -coff_get_reloc_upper_bound(abfd, asect) -bfd *abfd; -sec_ptr asect; - { - if (bfd_get_format(abfd) != bfd_object) { - bfd_error = invalid_operation; - return 0; - } - return (asect->reloc_count + 1) * sizeof(arelent *); - } - -/*doc* -@subsubsection Reading Relocations -Coff relocations are easily transformed into the internal BFD form -(@code{arelent}). - -Reading a coff relocation table is done in the following stages: -@itemize @bullet -@item -The entire coff relocation table is read into memory. -@item -Each relocation is processed in turn, first it is swapped from the -external to the internal form. -@item -The symbol referenced in the relocation's symbol index is turned into -a pointer into the canonical symbol table. Note that this table is the -same as the one returned by a call to @code{bfd_canonicalize_symtab}. -The back end will call the routine and save the result if a -canonicalization hasn't been done. -@item -The reloc index is turned into a pointer to a howto structure, in a -back end specific way. For instance, the 386 and 960 use the -@code{r_type} to directly produce an index into a howto table vector; -the 88k subtracts a number from the @code{r_type} field and creates an -addend field. -@end itemize -*/ - -static boolean -DEFUN(coff_slurp_reloc_table,(abfd, asect, symbols), - bfd *abfd AND - sec_ptr asect AND - asymbol **symbols) -{ - RELOC *native_relocs; - arelent *reloc_cache; - if (asect->relocation) - return true; - if (asect->reloc_count == 0) - return true; - if (asect->flags & SEC_CONSTRUCTOR) - return true; -#ifndef NO_COFF_SYMBOLS - if (!coff_slurp_symbol_table(abfd)) - return false; -#endif - native_relocs = - (RELOC *) buy_and_read(abfd, - asect->rel_filepos, - SEEK_SET, - (size_t) (RELSZ * - asect->reloc_count)); - reloc_cache = (arelent *) - bfd_alloc(abfd, (size_t) (asect->reloc_count * sizeof(arelent))); - - if (reloc_cache == NULL) { - bfd_error = no_memory; - return false; - } { /* on error */ - arelent *cache_ptr; - RELOC *src; - for (cache_ptr = reloc_cache, - src = native_relocs; - cache_ptr < reloc_cache + asect->reloc_count; - cache_ptr++, - src++) { - struct internal_reloc dst; - asymbol *ptr; - bfd_swap_reloc_in(abfd, src, &dst); - - dst.r_symndx += obj_symbol_slew(abfd); - cache_ptr->sym_ptr_ptr = symbols + obj_convert(abfd)[dst.r_symndx]; -#ifdef A29K - /* AMD has two relocation entries for the 'consth' instruction. - * The first is R_IHIHALF (part 1), the second is R_IHCONST - * (part 2). The second entry's r_symndx does not contain - * an index to a symbol but rather a value (apparently). - * Also, see the ifdef below for saving the r_symndx value in addend. - */ - if (dst.r_type == R_IHCONST) { - ptr = NULL; - } else -#endif - ptr = *(cache_ptr->sym_ptr_ptr); - cache_ptr->address = dst.r_vaddr; - /* - The symbols definitions that we have read in have been - relocated as if their sections started at 0. But the offsets - refering to the symbols in the raw data have not been - modified, so we have to have a negative addend to compensate. - - Note that symbols which used to be common must be left alone */ - - if (ptr && ptr->the_bfd == abfd - && ptr->section != (asection *) NULL - && ((ptr->flags & BSF_OLD_COMMON)== 0)) - { -#ifndef M88 - cache_ptr->addend = -(ptr->section->vma + ptr->value); -#else - cache_ptr->addend = 0; -#endif - - } - else { - cache_ptr->addend = 0; - } - - cache_ptr->address -= asect->vma; - - cache_ptr->section = (asection *) NULL; - -#ifdef A29K - if (dst.r_type == R_IHCONST) { - /* Add in the value which was stored in the symbol index */ - /* See above comment */ - cache_ptr->addend += dst.r_symndx; - /* Throw away the bogus symbol pointer */ - cache_ptr->sym_ptr_ptr = 0; - } - cache_ptr->howto = howto_table + dst.r_type; -#endif -#if I386 - cache_ptr->howto = howto_table + dst.r_type; -#endif -#if I960 - cache_ptr->howto = howto_table + dst.r_type; -#endif -#if M68 - cache_ptr->howto = howto_table + dst.r_type - R_RELBYTE; -#endif -#if M88 - if (dst.r_type >= R_PCR16L && dst.r_type <= R_VRT32) { - cache_ptr->howto = howto_table + dst.r_type - R_PCR16L; - cache_ptr->addend += dst.r_offset << 16; - } - else { - BFD_ASSERT(0); - } -#endif - } - } - - asect->relocation = reloc_cache; - return true; -} - - -/* This is stupid. This function should be a boolean predicate */ -static unsigned int -DEFUN(coff_canonicalize_reloc, (abfd, section, relptr, symbols), -bfd *abfd AND -sec_ptr section AND -arelent **relptr AND -asymbol **symbols) -{ - arelent *tblptr = section->relocation; - unsigned int count = 0; - - - if (section->flags & SEC_CONSTRUCTOR) - { - /* this section has relocs made up by us, they are not in the - file, so take them out of their chain and place them into - the data area provided */ - arelent_chain *chain = section->constructor_chain; - for (count = 0; count < section->reloc_count; count ++) - { - *relptr ++ = &chain->relent; - chain = chain->next; - } - - } - else - { - coff_slurp_reloc_table(abfd, section, symbols); - - - tblptr = section->relocation; - if (!tblptr) - return 0; - - for (; count++ < section->reloc_count;) - *relptr++ = tblptr++; - - - } - *relptr = 0; - return section->reloc_count; -} - -#ifndef NO_COFF_SYMBOLS - -/* -provided a BFD, a section and an offset into the section, calculate and -return the name of the source file and the line nearest to the wanted -location. -*/ - -static boolean -DEFUN(coff_find_nearest_line,(abfd, - section, - ignore_symbols, - offset, - filename_ptr, - functionname_ptr, - line_ptr), - bfd *abfd AND - asection *section AND - asymbol **ignore_symbols AND - bfd_vma offset AND - CONST char **filename_ptr AND - CONST char **functionname_ptr AND - unsigned int *line_ptr) -{ - static bfd *cache_abfd; - static asection *cache_section; - static bfd_vma cache_offset; - static unsigned int cache_i; - static alent *cache_l; - - unsigned int i = 0; - coff_data_type *cof = coff_data(abfd); - /* Run through the raw syments if available */ - combined_entry_type *p; - alent *l; - unsigned int line_base = 0; - - - *filename_ptr = 0; - *functionname_ptr = 0; - *line_ptr = 0; - - /* Don't try and find line numbers in a non coff file */ - if (abfd->xvec->flavour != bfd_target_coff_flavour) - return false; - - if (cof == NULL) - return false; - - p = cof->raw_syments; - - for (i = 0; i < cof->raw_syment_count; i++) { - if (p->u.syment.n_sclass == C_FILE) { - /* File name has been moved into symbol */ - *filename_ptr = (char *) p->u.syment._n._n_n._n_offset; - break; - } - p += 1 + p->u.syment.n_numaux; - } - /* Now wander though the raw linenumbers of the section */ - /* - If this is the same BFD as we were previously called with and this is - the same section, and the offset we want is further down then we can - prime the lookup loop - */ - if (abfd == cache_abfd && - section == cache_section && - offset >= cache_offset) { - i = cache_i; - l = cache_l; - } - else { - i = 0; - l = section->lineno; - } - - for (; i < section->lineno_count; i++) { - if (l->line_number == 0) { - /* Get the symbol this line number points at */ - coff_symbol_type *coff = (coff_symbol_type *) (l->u.sym); - *functionname_ptr = coff->symbol.name; - if (coff->native) { - combined_entry_type *s = coff->native; - s = s + 1 + s->u.syment.n_numaux; - /* - S should now point to the .bf of the function - */ - if (s->u.syment.n_numaux) { - /* - The linenumber is stored in the auxent - */ - union internal_auxent *a = &((s + 1)->u.auxent); - line_base = a->x_sym.x_misc.x_lnsz.x_lnno; - } - } - } - else { - if (l->u.offset > offset) - break; - *line_ptr = l->line_number + line_base + 1; - } - l++; - } - - cache_abfd = abfd; - cache_section = section; - cache_offset = offset; - cache_i = i; - cache_l = l; - - return true; -} - -#ifdef GNU960 -file_ptr -coff_sym_filepos(abfd) -bfd *abfd; - { - return obj_sym_filepos(abfd); - } -#endif - -#endif /* NO_COFF_SYMBOLS */ - - -static int -DEFUN(coff_sizeof_headers,(abfd, reloc), - bfd *abfd AND - boolean reloc) -{ - size_t size; - - if (reloc == false) { - size = FILHSZ + AOUTSZ; - } - else { - size = FILHSZ; - } - - size += abfd->section_count * SCNHSZ; - return size; -} - - -#define coff_core_file_failing_command _bfd_dummy_core_file_failing_command -#define coff_core_file_failing_signal _bfd_dummy_core_file_failing_signal -#define coff_core_file_matches_executable_p _bfd_dummy_core_file_matches_executable_p -#define coff_slurp_armap bfd_slurp_coff_armap -#define coff_slurp_extended_name_table _bfd_slurp_extended_name_table -#define coff_truncate_arname bfd_dont_truncate_arname -#define coff_openr_next_archived_file bfd_generic_openr_next_archived_file -#define coff_generic_stat_arch_elt bfd_generic_stat_arch_elt -#define coff_get_section_contents bfd_generic_get_section_contents -#define coff_close_and_cleanup bfd_generic_close_and_cleanup - -#define coff_bfd_debug_info_start bfd_void -#define coff_bfd_debug_info_end bfd_void -#define coff_bfd_debug_info_accumulate (PROTO(void,(*),(bfd*, struct sec *))) bfd_void diff --git a/bfd/coffish.h b/bfd/coffish.h deleted file mode 100755 index 77e40c87135..00000000000 --- a/bfd/coffish.h +++ /dev/null @@ -1,601 +0,0 @@ - -/* All the swapping routines: -*/ - - - -static void -DEFUN(swap_reloc_in,(abfd, reloc_src, reloc_dst), - bfd *abfd AND - RELOC *reloc_src AND - struct internal_reloc *reloc_dst) -{ - reloc_dst->r_vaddr = bfd_h_getlong(abfd, reloc_src->r_vaddr); - reloc_dst->r_symndx = bfd_h_getlong(abfd, reloc_src->r_symndx); - reloc_dst->r_type = bfd_h_getshort(abfd, reloc_src->r_type); -#if M88 - reloc_dst->r_offset = bfd_h_getshort(abfd, reloc_src->r_offset); -#endif -} - -static void -DEFUN(swap_reloc_out,(abfd, reloc_src, reloc_dst), - bfd *abfd AND - struct internal_reloc *reloc_src AND - struct external_reloc *reloc_dst) -{ - bfd_h_putlong(abfd, reloc_src->r_vaddr, reloc_dst->r_vaddr); - bfd_h_putlong(abfd, reloc_src->r_symndx, reloc_dst->r_symndx); - bfd_h_putshort(abfd, reloc_src->r_type, reloc_dst->r_type); -#if M88 - bfd_h_putshort(abfd, reloc_src->r_offset, reloc_dst->r_offset); -#endif - -} - -static void -DEFUN(swap_filehdr_in,(abfd, filehdr_src, filehdr_dst), - bfd *abfd AND - FILHDR *filehdr_src AND - struct internal_filehdr *filehdr_dst) -{ - filehdr_dst->f_magic = bfd_h_get_x(abfd, filehdr_src->f_magic); - filehdr_dst->f_nscns = bfd_h_get_x(abfd,filehdr_src-> f_nscns); - filehdr_dst->f_timdat = bfd_h_get_x(abfd,filehdr_src-> f_timdat); - filehdr_dst->f_symptr = bfd_h_get_x(abfd,filehdr_src-> f_symptr); - filehdr_dst->f_nsyms = bfd_h_get_x(abfd,filehdr_src-> f_nsyms); - filehdr_dst->f_opthdr = bfd_h_get_x(abfd,filehdr_src-> f_opthdr); - filehdr_dst->f_flags = bfd_h_get_x(abfd,filehdr_src-> f_flags); -} - -static void -DEFUN(swap_filehdr_out,(abfd, filehdr_in, filehdr_out), - bfd *abfd AND - struct internal_filehdr *filehdr_in AND - FILHDR *filehdr_out) -{ - bfd_h_put_x(abfd, filehdr_in->f_magic, filehdr_out->f_magic); - bfd_h_put_x(abfd, filehdr_in->f_nscns, filehdr_out->f_nscns); - bfd_h_put_x(abfd, filehdr_in->f_timdat, filehdr_out->f_timdat); - bfd_h_put_x(abfd, filehdr_in->f_symptr, filehdr_out->f_symptr); - bfd_h_put_x(abfd, filehdr_in->f_nsyms, filehdr_out->f_nsyms); - bfd_h_put_x(abfd, filehdr_in->f_opthdr, filehdr_out->f_opthdr); - bfd_h_put_x(abfd, filehdr_in->f_flags, filehdr_out->f_flags); -} - - -static void -DEFUN(bfd_coff_swap_sym_in,(abfd, ext, in), - bfd *abfd AND - SYMENT *ext AND - struct internal_syment *in) -{ - if( ext->e.e_name[0] == 0) { - in->_n._n_n._n_zeroes = 0; - in->_n._n_n._n_offset = bfd_h_getlong(abfd, ext->e.e.e_offset); - } - else { - memcpy(in->_n._n_name, ext->e.e_name, SYMNMLEN); - } - in->n_value = bfd_h_get_x(abfd, ext->e_value); - in->n_scnum = bfd_h_get_x(abfd, ext->e_scnum); - in->n_type = bfd_h_get_x(abfd, ext->e_type); - in->n_sclass = bfd_h_get_x(abfd, ext->e_sclass); - in->n_numaux = bfd_h_get_x(abfd, ext->e_numaux); -} - -static void -DEFUN(bfd_coff_swap_sym_out,(abfd,in, ext), - bfd *abfd AND - struct internal_syment *in AND - SYMENT *ext) -{ - if(in->_n._n_name[0] == 0) { - bfd_h_putlong(abfd, 0, ext->e.e.e_zeroes); - bfd_h_putlong(abfd, in->_n._n_n._n_offset, ext->e.e.e_offset); - } - else { - memcpy(ext->e.e_name, in->_n._n_name, SYMNMLEN); - } - bfd_h_put_x(abfd, in->n_value , ext->e_value); - bfd_h_put_x(abfd, in->n_scnum , ext->e_scnum); - bfd_h_put_x(abfd, in->n_type , ext->e_type); - bfd_h_put_x(abfd, in->n_sclass , ext->e_sclass); - bfd_h_put_x(abfd, in->n_numaux , ext->e_numaux); -} - -static void -DEFUN(bfd_coff_swap_aux_in,(abfd, ext, type, class, in), - bfd *abfd AND - AUXENT *ext AND - int type AND - int class AND - union internal_auxent *in) -{ - switch (class) { - case C_FILE: - if (ext->x_file.x_fname[0] == 0) { - in->x_file.x_n.x_zeroes = 0; - in->x_file.x_n.x_offset = bfd_h_getlong(abfd, ext->x_file.x_n.x_offset); - } - - break; - case C_STAT: -#ifdef C_LEAFSTAT - case C_LEAFSTAT: -#endif - case C_HIDDEN: - if (type == T_NULL) { - in->x_scn.x_scnlen = bfd_h_get_x(abfd, ext->x_scn.x_scnlen); - in->x_scn.x_nreloc = bfd_h_get_x(abfd, ext->x_scn.x_nreloc); - in->x_scn.x_nlinno = bfd_h_get_x(abfd, ext->x_scn.x_nlinno); - break; - } - default: - in->x_sym.x_tagndx = bfd_h_get_x(abfd, ext->x_sym.x_tagndx); - in->x_sym.x_tvndx = bfd_h_get_x(abfd, ext->x_sym.x_tvndx); - - if (ISARY(type) || class == C_BLOCK) { - in->x_sym.x_fcnary.x_ary.x_dimen[0] = bfd_h_get_x(abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[0]); - in->x_sym.x_fcnary.x_ary.x_dimen[1] = bfd_h_get_x(abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[1]); - in->x_sym.x_fcnary.x_ary.x_dimen[2] = bfd_h_get_x(abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[2]); - in->x_sym.x_fcnary.x_ary.x_dimen[3] = bfd_h_get_x(abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[3]); - } - else { - in->x_sym.x_fcnary.x_fcn.x_lnnoptr = bfd_h_get_x(abfd, ext->x_sym.x_fcnary.x_fcn.x_lnnoptr); - in->x_sym.x_fcnary.x_fcn.x_endndx = bfd_h_get_x(abfd, ext->x_sym.x_fcnary.x_fcn.x_endndx); - } - if (ISFCN(type)) { - in->x_sym.x_misc.x_fsize = bfd_h_get_x(abfd, ext->x_sym.x_misc.x_fsize); - } - else { - in->x_sym.x_misc.x_lnsz.x_lnno = bfd_h_get_x(abfd, ext->x_sym.x_misc.x_lnsz.x_lnno); - in->x_sym.x_misc.x_lnsz.x_size = bfd_h_get_x(abfd, ext->x_sym.x_misc.x_lnsz.x_size); - } - } -} - -static void -DEFUN(bfd_coff_swap_aux_out,(abfd, in, type, class, ext), - bfd *abfd AND - union internal_auxent *in AND - int type AND - int class AND - AUXENT *ext) -{ - switch (class) { - case C_FILE: - if (in->x_file.x_fname[0] == 0) { - bfd_h_put_x(abfd, 0, ext->x_file.x_n.x_zeroes ); - bfd_h_put_x(abfd, in->x_file.x_n.x_offset, ext->x_file.x_n.x_offset); - } - - break; - case C_STAT: -#ifdef C_LEAFSTAT - case C_LEAFSTAT: -#endif - case C_HIDDEN: - if (type == T_NULL) { - bfd_h_put_x(abfd, in->x_scn.x_scnlen, ext->x_scn.x_scnlen); - bfd_h_put_x(abfd, in->x_scn.x_nreloc, ext->x_scn.x_nreloc); - bfd_h_put_x(abfd, in->x_scn.x_nlinno, ext->x_scn.x_nlinno); - break; - } - default: - bfd_h_put_x(abfd, in->x_sym.x_tagndx, ext->x_sym.x_tagndx); - bfd_h_put_x(abfd, in->x_sym.x_tvndx , ext->x_sym.x_tvndx); - - if (ISARY(type) || class == C_BLOCK) { - bfd_h_put_x(abfd, in->x_sym.x_fcnary.x_ary.x_dimen[0],ext->x_sym.x_fcnary.x_ary.x_dimen[0]); - bfd_h_put_x(abfd, in->x_sym.x_fcnary.x_ary.x_dimen[1],ext->x_sym.x_fcnary.x_ary.x_dimen[1]); - bfd_h_put_x(abfd, in->x_sym.x_fcnary.x_ary.x_dimen[2],ext->x_sym.x_fcnary.x_ary.x_dimen[2]); - bfd_h_put_x(abfd, in->x_sym.x_fcnary.x_ary.x_dimen[3],ext->x_sym.x_fcnary.x_ary.x_dimen[3]); - } - else { - bfd_h_put_x(abfd, in->x_sym.x_fcnary.x_fcn.x_lnnoptr, ext->x_sym.x_fcnary.x_fcn.x_lnnoptr); - bfd_h_put_x(abfd, in->x_sym.x_fcnary.x_fcn.x_endndx, ext->x_sym.x_fcnary.x_fcn.x_endndx); - } - if (ISFCN(type)) { - bfd_h_put_x(abfd, in->x_sym.x_misc.x_fsize, ext->x_sym.x_misc.x_fsize); - } - else { - bfd_h_put_x(abfd, in->x_sym.x_misc.x_lnsz.x_lnno, ext->x_sym.x_misc.x_lnsz.x_lnno); - bfd_h_put_x(abfd, in->x_sym.x_misc.x_lnsz.x_size, ext->x_sym.x_misc.x_lnsz.x_size); - } - } -} - -static void -DEFUN(bfd_coff_swap_lineno_in,(abfd, ext, in), - bfd *abfd AND - LINENO *ext AND - struct internal_lineno *in) -{ - in->l_addr.l_symndx = bfd_h_get_x(abfd, ext->l_addr.l_symndx); - in->l_lnno = bfd_h_get_x(abfd, ext->l_lnno); -} - -static void -DEFUN(bfd_coff_swap_lineno_out,(abfd, in, ext), - bfd *abfd AND - struct internal_lineno *in AND - struct external_lineno *ext) -{ - bfd_h_put_x(abfd, in->l_addr.l_symndx, ext->l_addr.l_symndx); - bfd_h_put_x(abfd, in->l_lnno, ext->l_lnno); -} - - - - -static void -DEFUN(swap_aouthdr_in,(abfd, aouthdr_ext, aouthdr_int), - bfd *abfd AND - AOUTHDR *aouthdr_ext AND - struct internal_aouthdr *aouthdr_int) -{ - aouthdr_int->magic = bfd_h_get_x(abfd, aouthdr_ext->magic); - aouthdr_int->vstamp = bfd_h_get_x(abfd, aouthdr_ext->vstamp); - aouthdr_int->tsize = bfd_h_get_x(abfd, aouthdr_ext->tsize); - aouthdr_int->dsize = bfd_h_get_x(abfd, aouthdr_ext->dsize); - aouthdr_int->bsize = bfd_h_get_x(abfd, aouthdr_ext->bsize); - aouthdr_int->entry = bfd_h_get_x(abfd, aouthdr_ext->entry); - aouthdr_int->text_start = bfd_h_get_x(abfd, aouthdr_ext->text_start); - aouthdr_int->data_start = bfd_h_get_x(abfd, aouthdr_ext->data_start); -#ifdef I960 - aouthdr_int->tagentries = bfd_h_get_x(abfd, aouthdr_ext->tagentries); -#endif -} - -static void -DEFUN(swap_aouthdr_out,(abfd, aouthdr_in, aouthdr_out), - bfd *abfd AND - struct internal_aouthdr *aouthdr_in AND - AOUTHDR *aouthdr_out) -{ - bfd_h_put_x(abfd, aouthdr_in->magic, aouthdr_out->magic); - bfd_h_put_x(abfd, aouthdr_in->vstamp, aouthdr_out->vstamp); - bfd_h_put_x(abfd, aouthdr_in->tsize, aouthdr_out->tsize); - bfd_h_put_x(abfd, aouthdr_in->dsize, aouthdr_out->dsize); - bfd_h_put_x(abfd, aouthdr_in->bsize, aouthdr_out->bsize); - bfd_h_put_x(abfd, aouthdr_in->entry, aouthdr_out->entry); - bfd_h_put_x(abfd, aouthdr_in->text_start, aouthdr_out->text_start); - bfd_h_put_x(abfd, aouthdr_in->data_start, aouthdr_out->data_start); -#ifdef I960 - bfd_h_put_x(abfd, aouthdr_in->tagentries, aouthdr_out->tagentries); -#endif -} - -static void -DEFUN(swap_scnhdr_in,(abfd, scnhdr_ext, scnhdr_int), - bfd *abfd AND - SCNHDR *scnhdr_ext AND - struct internal_scnhdr *scnhdr_int) -{ - memcpy(scnhdr_int->s_name, scnhdr_ext->s_name, sizeof(scnhdr_int->s_name)); - scnhdr_int->s_vaddr = bfd_h_get_x(abfd, scnhdr_ext->s_vaddr); - scnhdr_int->s_paddr = bfd_h_get_x(abfd, scnhdr_ext->s_paddr); - scnhdr_int->s_size = bfd_h_get_x(abfd, scnhdr_ext->s_size); - scnhdr_int->s_scnptr = bfd_h_get_x(abfd, scnhdr_ext->s_scnptr); - scnhdr_int->s_relptr = bfd_h_get_x(abfd, scnhdr_ext->s_relptr); - scnhdr_int->s_lnnoptr = bfd_h_get_x(abfd, scnhdr_ext->s_lnnoptr); - scnhdr_int->s_nreloc = bfd_h_get_x(abfd, scnhdr_ext->s_nreloc); - scnhdr_int->s_nlnno = bfd_h_get_x(abfd, scnhdr_ext->s_nlnno); - scnhdr_int->s_flags = bfd_h_get_x(abfd, scnhdr_ext->s_flags); -#ifdef I960 - scnhdr_int->s_align = bfd_h_get_x(abfd, scnhdr_ext->s_align); -#endif -} - -static void -DEFUN(swap_scnhdr_out,(abfd, scnhdr_int, scnhdr_ext), - bfd *abfd AND - struct internal_scnhdr *scnhdr_int AND - SCNHDR *scnhdr_ext) -{ - memcpy(scnhdr_ext->s_name, scnhdr_int->s_name, sizeof(scnhdr_int->s_name)); - bfd_h_put_x(abfd, scnhdr_int->s_vaddr, scnhdr_ext->s_vaddr); - bfd_h_put_x(abfd, scnhdr_int->s_paddr, scnhdr_ext->s_paddr); - bfd_h_put_x(abfd, scnhdr_int->s_size, scnhdr_ext->s_size); - bfd_h_put_x(abfd, scnhdr_int->s_scnptr, scnhdr_ext->s_scnptr); - bfd_h_put_x(abfd, scnhdr_int->s_relptr, scnhdr_ext->s_relptr); - bfd_h_put_x(abfd, scnhdr_int->s_lnnoptr, scnhdr_ext->s_lnnoptr); - bfd_h_put_x(abfd, scnhdr_int->s_nreloc, scnhdr_ext->s_nreloc); - bfd_h_put_x(abfd, scnhdr_int->s_nlnno, scnhdr_ext->s_nlnno); - bfd_h_put_x(abfd, scnhdr_int->s_flags, scnhdr_ext->s_flags); -#ifdef I960 - bfd_h_put_x(abfd, scnhdr_int->s_align, scnhdr_ext->s_align); -#endif -} - -/* - initialize a section structure with information peculiar to this - particular implementation of coff -*/ - -static boolean -DEFUN(coff_new_section_hook,(abfd_ignore, section_ignore), - bfd *abfd_ignore AND - asection *section_ignore) -{ -#ifdef MC88MAGIC - /* FIXME, shouldn't this ifdef be on something that says we are - actually COMPILING FOR an 88K coff file, rather than simply - knowing its magic number? */ - /* Align to at least 16 bytes */ - section_ignore->alignment_power = 4; -#endif -#if M68 - section_ignore->alignment_power = 3; -#endif - return true; -} - -/* Take a section header read from a coff file (in HOST byte order), - and make a BFD "section" out of it. */ -static boolean -DEFUN(make_a_section_from_file,(abfd, hdr), - bfd *abfd AND - struct internal_scnhdr *hdr) -{ - asection *return_section; - - { - /* Assorted wastage to null-terminate the name, thanks AT&T! */ - char *name = bfd_alloc(abfd, sizeof (hdr->s_name)+1); - if (name == NULL) { - bfd_error = no_memory; - return false; - } - strncpy(name, (char *) &hdr->s_name[0], sizeof (hdr->s_name)); - name[sizeof (hdr->s_name)] = 0; - - return_section = bfd_make_section(abfd, name); - } - - /* s_paddr is presumed to be = to s_vaddr */ -#define assign(to, from) return_section->to = hdr->from - assign(vma, s_vaddr); - /* assign (vma, s_vaddr); */ - assign(size, s_size); - assign(filepos, s_scnptr); - assign(rel_filepos, s_relptr); - assign(reloc_count, s_nreloc); -#ifdef I960 - { - /* FIXME, use a temp var rather than alignment_power */ - assign(alignment_power, s_align); - { - unsigned int i; - for (i = 0; i < 32; i++) { - if ((1 << i) >= (int) (return_section->alignment_power)) { - return_section->alignment_power = i; - break; - } - } - } - } -#endif - assign(line_filepos, s_lnnoptr); - /* - return_section->linesize = hdr->s_nlnno * sizeof (struct lineno); - */ - -#undef assign - return_section->lineno_count = hdr->s_nlnno; - return_section->userdata = NULL; - return_section->next = (asection *) NULL; - if ((hdr->s_flags & STYP_TEXT) || (hdr->s_flags & STYP_DATA)) - return_section->flags = (SEC_LOAD | SEC_ALLOC); - else if (hdr->s_flags & STYP_BSS) - return_section->flags = SEC_ALLOC; - - if (hdr->s_nreloc != 0) - return_section->flags |= SEC_RELOC; - if (hdr->s_scnptr != 0) - return_section->flags |= SEC_HAS_CONTENTS; - return true; -} -static boolean -DEFUN(coff_mkobject,(abfd), - bfd *abfd) -{ - set_tdata (abfd, bfd_zalloc (abfd,sizeof(coff_data_type))); - if (coff_data(abfd) == 0) { - bfd_error = no_memory; - return false; - } - coff_data(abfd)->relocbase = 0; - return true; -} - -static -bfd_target * -DEFUN(coff_real_object_p,(abfd, nscns, internal_f, internal_a), - bfd *abfd AND - unsigned nscns AND - struct internal_filehdr *internal_f AND - struct internal_aouthdr *internal_a) -{ - coff_data_type *coff; - - size_t readsize; /* length of file_info */ - SCNHDR *external_sections; - - /* Build a play area */ - if (coff_mkobject(abfd) != true) - return 0; - coff = coff_data(abfd); - - - external_sections = (SCNHDR *)bfd_alloc(abfd, readsize = (nscns * SCNHSZ)); - if (bfd_read((PTR)external_sections, 1, readsize, abfd) != readsize) { - goto fail; - } - - - - /* Now copy data as required; construct all asections etc */ - coff->symbol_index_slew = 0; - coff->relocbase =0; - coff->raw_syment_count = 0; - coff->raw_linenos = 0; - coff->raw_syments = 0; - coff->sym_filepos =0; - coff->flags = internal_f->f_flags; - if (nscns != 0) { - unsigned int i; - for (i = 0; i < nscns; i++) { - struct internal_scnhdr tmp; - swap_scnhdr_in(abfd, external_sections + i, &tmp); - make_a_section_from_file(abfd,&tmp); - } - } - /* Determine the machine architecture and type. */ - abfd->obj_machine = 0; - switch (internal_f->f_magic) { -#ifdef MIPS -#ifdef MIPSEBMAGIC - case SMIPSEBMAGIC: - case SMIPSELMAGIC: - case MIPSEBUMAGIC: - case MIPSELUMAGIC: - case MIPSEBMAGIC: - case MIPSELMAGIC: - abfd->obj_arch = bfd_arch_mips; - abfd->obj_machine = 0; - break; -#endif -#endif -#ifdef MC68MAGIC - case MC68MAGIC: - case M68MAGIC: - abfd->obj_arch = bfd_arch_m68k; - abfd->obj_machine = 68020; - break; -#endif -#ifdef MC88MAGIC - case MC88MAGIC: - case MC88DMAGIC: - case MC88OMAGIC: - abfd->obj_arch = bfd_arch_m88k; - abfd->obj_machine = 88100; - break; -#endif -#ifdef I960 -#ifdef I960ROMAGIC - case I960ROMAGIC: - case I960RWMAGIC: - abfd->obj_arch = bfd_arch_i960; - switch (F_I960TYPE & internal_f->f_flags) - { - default: - case F_I960CORE: - abfd->obj_machine = bfd_mach_i960_core; - break; - case F_I960KB: - abfd->obj_machine = bfd_mach_i960_kb_sb; - break; - case F_I960MC: - abfd->obj_machine = bfd_mach_i960_mc; - break; - case F_I960XA: - abfd->obj_machine = bfd_mach_i960_xa; - break; - case F_I960CA: - abfd->obj_machine = bfd_mach_i960_ca; - break; - case F_I960KA: - abfd->obj_machine = bfd_mach_i960_ka_sa; - break; - - } - break; -#endif -#endif - - default: /* Unreadable input file type */ - abfd->obj_arch = bfd_arch_obscure; - break; - } - - if (!(internal_f->f_flags & F_RELFLG)) - abfd->flags |= HAS_RELOC; - if ((internal_f->f_flags & F_EXEC)) - abfd->flags |= EXEC_P; - if (!(internal_f->f_flags & F_LNNO)) - abfd->flags |= HAS_LINENO; - if (!(internal_f->f_flags & F_LSYMS)) - abfd->flags |= HAS_LOCALS; - - - bfd_get_symcount(abfd) = internal_f->f_nsyms; - if (internal_f->f_nsyms) - abfd->flags |= HAS_SYMS; - - coff->sym_filepos = internal_f->f_symptr; - - - - coff->symbols = (coff_symbol_type *) NULL; - bfd_get_start_address(abfd) = internal_f->f_opthdr ? internal_a->entry : 0; - - return abfd->xvec; - fail: - bfd_release(abfd, coff); - return (bfd_target *)NULL; -} - -static bfd_target * -DEFUN(coff_object_p,(abfd), - bfd *abfd) - { - int nscns; - FILHDR filehdr; - AOUTHDR opthdr; - struct internal_filehdr internal_f; - struct internal_aouthdr internal_a; - - bfd_error = system_call_error; - - /* figure out how much to read */ - if (bfd_read((PTR) &filehdr, 1, FILHSZ, abfd) != FILHSZ) - return 0; - - swap_filehdr_in(abfd, &filehdr, &internal_f); - - if (BADMAG(internal_f)) { - bfd_error = wrong_format; - return 0; - } - nscns =internal_f.f_nscns; - - if (internal_f.f_opthdr) { - if (bfd_read((PTR) &opthdr, 1,AOUTSZ, abfd) != AOUTSZ) { - return 0; - } - swap_aouthdr_in(abfd, &opthdr, &internal_a); - } - - /* Seek past the opt hdr stuff */ - bfd_seek(abfd, internal_f.f_opthdr + FILHSZ, SEEK_SET); - - /* if the optional header is NULL or not the correct size then - quit; the only difference I can see between m88k dgux headers (MC88DMAGIC) - and Intel 960 readwrite headers (I960WRMAGIC) is that the - optional header is of a different size. - - But the mips keeps extra stuff in it's opthdr, so dont check - when doing that - */ - -#ifndef MIPS - if (internal_f.f_opthdr != 0 && AOUTSZ != internal_f.f_opthdr) - return (bfd_target *)NULL; -#endif - - return coff_real_object_p(abfd, nscns, &internal_f, &internal_a); - } - - diff --git a/bfd/coffswap.c b/bfd/coffswap.c deleted file mode 100755 index b1f74517eeb..00000000000 --- a/bfd/coffswap.c +++ /dev/null @@ -1,123 +0,0 @@ -/* Byte-swapping routines for COFF files */ - -/* Copyright (C) 1990, 1991 Free Software Foundation, Inc. - -This file is part of BFD, the Binary File Diddler. - -BFD 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 1, or (at your option) any later version. - -BFD 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 - BFD; see the file COPYING. If not, write to the Free Software Foundation, - 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -/* Most of this hacked by Steve Chamberlain, steve@cygnus.com */ -#if 0 -#include -#include "intel-coff.h" -#include "bfd.h" -#include "libcoff.h" /* to allow easier abstraction-breaking */ - -#define sp(x) bfd_h_put_x(abfd, x, &x) - -/* All the generic swapping routines: - -FIXME - These routines cater for the sizes and alignments and offsets of - all the contained fields. Because of this, the fields can change - size, so these should be phased out to use the ones specific to the - file format. - */ - -void -DEFUN(bfd_coff_swap_name,(abfd, ptr), - bfd *abfd AND - long *ptr) -{ - if (ptr[0] == 0) { - /* There is an index which needs to be swapped */ - bfd_h_put_x(abfd, ptr[1], (ptr + 1)); - } - else { - /* This is a string .. leave it alone */ - } -} - -void -DEFUN(bfd_coff_swap_sym,(abfd, se), - bfd *abfd AND - struct internal_syment *se) -{ - bfd_coff_swap_name(abfd, (long*)(se->n_name)); - bfd_h_put_x(abfd, se->n_value, &se->n_value); - bfd_h_put_x(abfd, se->n_scnum, &se->n_scnum); - bfd_h_put_x(abfd, se->n_type, &se->n_type); - bfd_h_put_x(abfd, se->n_sclass, &se->n_sclass); - bfd_h_put_x(abfd, se->n_numaux, &se->n_numaux); -} - -void -DEFUN(bfd_coff_swap_aux,(abfd, au, type, class), - bfd *abfd AND - struct internal_auxent *au AND - int type AND - int class) -{ - switch (class) { - case C_FILE: - bfd_coff_swap_name(abfd, (long *)(&au->x_file.x_n)); - break; - case C_STAT: -#ifdef C_LEAFSTAT - case C_LEAFSTAT: -#endif - case C_HIDDEN: - if (type == T_NULL) { - sp(au->x_scn.x_scnlen); - sp(au->x_scn.x_nreloc); - sp(au->x_scn.x_nlinno); - break; - } - default: - sp(au->x_sym.x_tagndx); - sp(au->x_sym.x_tvndx); - - if (ISARY(type) || class == C_BLOCK) { - sp(au->x_sym.x_fcnary.x_ary.x_dimen[0]); - sp(au->x_sym.x_fcnary.x_ary.x_dimen[1]); - sp(au->x_sym.x_fcnary.x_ary.x_dimen[2]); - sp(au->x_sym.x_fcnary.x_ary.x_dimen[3]); - } - else { - sp(au->x_sym.x_fcnary.x_fcn.x_lnnoptr); - sp(au->x_sym.x_fcnary.x_fcn.x_endndx); - } - if (ISFCN(type)) { - sp(au->x_sym.x_misc.x_fsize); - } - else { - sp(au->x_sym.x_misc.x_lnsz.x_lnno); - sp(au->x_sym.x_misc.x_lnsz.x_size); - } - } -} - -void -DEFUN(bfd_coff_swap_lineno,(abfd, lineno), - bfd *abfd AND - struct internal_lineno *lineno) -{ - sp(lineno->l_addr.l_symndx); - sp(lineno->l_lnno); -} - - - -#endif diff --git a/bfd/config.sub b/bfd/config.sub deleted file mode 100755 index dac9ab89d4f..00000000000 --- a/bfd/config.sub +++ /dev/null @@ -1,446 +0,0 @@ -#!/bin/sh - -# Configuration subroutine to validate and canonicalize a configuration type. -# Supply the specified configuration type as an argument. -# If it is invalid, we print an error message on stderr and exit with code 1. -# Otherwise, we print the canonical config type on stdout and succeed. - -# This file is supposed to be the same for all GNU packages -# and recognize all the CPU types, system types and aliases -# that are meaningful with *any* GNU software. -# Each package is responsible for reporting which valid configurations -# it does not support. The user should be able to distinguish -# a failure to support a valid configuration from a meaningless -# configuration (e.g. a typo). - -# Please email any bugs, comments, and/or additions to this file to: -# configure@cygnus.com - -# decode aliases into canonical names - -case "$1" in -# cpu alone is a valid alias for cpu-none-none. -vax | tahoe | i386 | i860 | m68k | m68000 | m88k | sparc | ns32k \ - | alliant | arm | c1 | c2 | mips | pyramid | tron | a29k \ - | romp | rs6000 | i960 | h8300) - cpu=$1 - vendor=none - os=none - ;; -altos | altos3068) - cpu=m68k - vendor=altos - os=sysv # maybe? - ;; -altosgas) - cpu=m68k - vendor=altos - os=gas - ;; -am29k) - cpu=a29k - vendor=none - os=bsd - ;; -amdahl) - cpu=580 - vendor=amdahl - os=uts - ;; -amigados) - cpu=m68k - vendor=cbm - os=amigados # Native AmigaDOS - ;; -amigaunix | amix) - cpu=m68k - vendor=cbm - os=svr4 # System V Release 4 (svr4 is an industry recognized acronym) - ;; -apollo68) - cpu=m68k - vendor=apollo - os=sysv # maybe? - ;; -balance) - cpu=ns32k - vendor=sequent - os=dynix - ;; -convex-c1) - cpu=c1 - vendor=convex - os=sysv # maybe? - ;; -convex-c2) - cpu=c2 - vendor=convex - os=sysv # maybe? - ;; -cray | ymp) - cpu=ymp - vendor=cray - os=unicos - ;; -cray2) - cpu=cray2 - vendor=cray - os=unicos - ;; -dec3100 | decstatn | decstation | decstation-3100 | pmax | pmin) - cpu=mips - vendor=dec - os=ultrix - ;; -delta | 3300 | motorola-3300 | motorola-delta \ - | 3300-motorola | delta-motorola) - cpu=m68k - vendor=motorola - os=sysv # maybe? - ;; - -delta88) - cpu=m88k - vendor=motorola - os=m88kbcs - ;; - -gmicro) - cpu=tron - vendor=gmicro - os=sysv # maybe? - ;; - -h8300hds) - cpu=h8300 - vendor=hitachi - os=hds - ;; - -# start-sanitize-v9 -hal-32 | hal32) - cpu=sparc64 - vendor=hal - os=hal32 - ;; -hal-64 | hal64) - cpu=sparc64 - vendor=hal - os=hal64 - ;; -sparc64) - cpu=sparc64 - vendor=sun - os=v9 - ;; -sparc64-v7 | sparc64v7) - cpu=sparc64 - vendor=sun - os=v7 - ;; -# end-sanitize-v9 -hp300bsd) - cpu=m68k - vendor=hp - os=bsd - ;; -hp300hpux | hpux | hp9k3[2-9][0-9]) - cpu=m68k - vendor=hp - os=hpux - ;; -hp9k31[0-9] | hp9k2[0-9][0-9]) - cpu=m68000 - vendor=hp - os=hpux - ;; -i386sco) - cpu=i386 - vendor=sco - os=sysv # maybe? - ;; -i386v) - cpu=i386 - vendor=none - os=sysv - ;; -i386v32) - cpu=i386 - vendor=none - os=sysv32 - ;; -iris | iris4d) - cpu=mips - vendor=sgi - os=irix # maybe? - ;; - -dpx2) - vendor=bull - cpu=m68k - os=sysv - ;; -isi | isi68) - cpu=m68k - vendor=isi - os=sysv # maybe? - ;; -littlemips) - cpu=mips - vendor=little - os=bsd - ;; -magnum | m3230) - cpu=mips - vendor=mips - os=sysv # maybe? - ;; -merlin) - cpu=ns32k - vendor=utek - os=sysv # maybe? - ;; -miniframe) - cpu=m68000 - vendor=convergent - os=sysv # maybe? - ;; -mmax) - cpu=ns32k - vendor=encore - os=sysv # maybe? - ;; -news | news700 | news800 | news900) - cpu=m68k - vendor=sony - os=newsos3 # Based on bsd-4.3 - ;; -news1000) - cpu=m68030 - vendor=sony - os=newsos3 # ? - ;; -news-3600 | bigmips | risc-news) - cpu=mips - vendor=sony - os=newsos4 # Presumably? - ;; -next) - cpu=m68k - vendor=next - os=sysv # maybe? - ;; -nindy960) - cpu=i960 - vendor=intel - os=nindy - ;; -none) - cpu=none - vendor=none - os=none - ;; -np1) - cpu=np1 - vendor=gould - os=sysv # maybe? - ;; -rtpc) - cpu=romp - vendor=ibm - os=aix # maybe? - ;; -pbd) - cpu=sparc - vendor=unicom - os=sysv - ;; -pn) - cpu=pn - vendor=gould - os=sysv # maybe? - ;; -ps2) - cpu=i386 - vendor=ibm - os=sysv # maybe? - ;; -sun2) - cpu=m68000 - vendor=sun - os=sunos4 - ;; -sun2os3) - cpu=m68000 - vendor=sun - os=sunos3 - ;; -sun2os4) - cpu=m68000 - vendor=sun - os=sunos4 - ;; -sun3) - cpu=m68k - vendor=sun - os=sunos4 - ;; -sun3os3) - cpu=m68k - vendor=sun - os=sunos3 - ;; -sun3os4) - cpu=m68k - vendor=sun - os=sunos4 - ;; -sun386 | roadrunner | sun386i) - cpu=i386 - vendor=sun - os=sunos - ;; -sun4) - cpu=sparc - vendor=sun - os=sunos4 - ;; -sun4os3) - cpu=sparc - vendor=sun - os=sunos3 - ;; -sun4os4) - cpu=sparc - vendor=sun - os=sunos4 - ;; -symmetry) - cpu=i386 - vendor=sequent - os=dynix - ;; -tower | tower-32) - cpu=m68k - vendor=ncr - os=sysv # maybe? - ;; -ultra3) - cpu=a29k - vendor=nyu - os=sym1 - ;; -umax) - cpu=ns32k - vendor=encore - os=sysv # maybe? - ;; -unixpc | safari | pc7300 | 3b1 | 7300 | 7300-att | att-7300) - cpu=m68k - vendor=att - os=sysv # maybe? - ;; -vax-dec) - cpu=vax - vendor=dec - os=ultrix # maybe? - ;; -vxworks68) - cpu=m68k - vendor=wrs - os=vxworks - ;; -vxworks960) - cpu=i960 - vendor=wrs - os=vxworks - ;; -xmp) - cpu=xmp - vendor=cray - os=unicos - ;; -# not an alias. parse what we expect to be a canonical name. -*) - cpu=`echo $1 | sed 's/-.*$//'` - - if [ "${cpu}" = "$1" ] ; then - # no vendor so this is an invalid name. - echo '***' No vendor: configuration \`$1\' not recognized 1>&2 - exit 1 - else - # parse out vendor - rest=`echo $1 | sed "s/${cpu}-//"` - vendor=`echo ${rest} | sed 's/-.*$//'` - - if [ "${vendor}" = "${rest}" ] ; then - # a missing os is acceptable - os=none - else - os=`echo ${rest} | sed "s/${vendor}-//"` - fi - fi - ;; -esac - -# At this point we should have three parts of a canonical name in cpu, -# vendor, and os. - -# verify that the cpu is known. - -case "${cpu}" in -none | vax | tahoe | i386 | i860 | m68k | m68000 | m88k | sparc \ - | ns32k | alliant | arm | c1 | c2 | mips | pyramid | tron \ - | a29k | romp | rs6000 | i960 | xmp | ymp | cray2 | 580 | h8300) - ;; - -# start-sanitize-v9 -sparc64) ;; -# end-sanitize-v9 - -*) - echo '***' Invalid cpu \`${cpu}\': configuration \`$1\' not recognized 1>&2 - exit 1 - ;; -esac - -# verify that the vendor is known. - -case "${vendor}" in - altos | amdahl | aout | apollo | att | bcs | bout |\ - cbm | convergent | convex | coff | cray | dec | encore |\ - gould | hitachi | intel | isi | hp | ibm | little | mips | motorola |\ - ncr | next | none | nyu | sco | sequent | sgi | sony | sun |\ - unicom | utek | wrs | bull ) ;; - -# start-sanitize-v9 -hal) ;; -# end-sanitize-v9 - -*) - echo '***' Invalid vendor \`${vendor}\': configuration \`$1\' not recognized 1>&2 - exit 1 - ;; -esac - -# verify that the os is known, if it exists. - -case "${os}" in -aix* | aout | bout | bsd* | coff | ctix* | dynix* | esix* | hpux* \ - | hds | irix* | isc* | kern | mach* | newsos* | nindy* | none \ - | osf* | sco* | sunos* | sysv* | ultrix* | unos* | v88r* \ - | vms* | vxworks* | sym[1-9]* | unicos* | uts | svr4 \ - | amigados) - ;; - -# start-sanitize-v9 -hal32 | hal64 | v7 | v9) ;; -# end-sanitize-v9 - -*) - echo '***' Invalid os \`${os}\': configuration \`$1\' not recognized 1>&2 - exit 1 - ;; -esac - -echo ${cpu}-${vendor}-${os} diff --git a/bfd/configure b/bfd/configure deleted file mode 100755 index e7e05e8ea83..00000000000 --- a/bfd/configure +++ /dev/null @@ -1,774 +0,0 @@ -#!/bin/sh - -# Configuration script -# Copyright (C) 1988, 1990, 1991 Free Software Foundation, Inc. - -#This file is part of GNU. - -# 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -# $Id$ - -# -# Shell script to create proper links to machine-dependent files in -# preparation for compilation. -# -# If configure succeeds, it leaves its status in config.status. -# If configure fails after disturbing the status quo, -# config.status is removed. -# - -remove=rm -hard_link=ln -symbolic_link='ln -s' - -#for Test -#remove="echo rm" -#hard_link="echo ln" -#symbolic_link="echo ln -s" - -progname=$0 - -# clear some things potentially inherited from environment. -ansi= -arguments=$* -defaulttargets= -destdir= -fatal= -hostsubdir= -Makefile=Makefile -Makefile_in=Makefile.in -norecursion= -recurring= -removing= -srcdir= -srctrigger= -target= -targets= -commontargets= -configdirs= -targetsubdir= -template= -verbose= - -for arg in $*; -do - case ${arg} in - -ansi | +a*) - ansi=true - clib=clib - ;; - -destdir=* | +destdir=* | +destdi=* | +destd=* | +dest=* | +des=* | +de=* | +d=*) - destdir=`echo ${arg} | sed 's/[+-]d[a-z]*=//'` - ;; - -languages=* | +languages=* | +language=* | +languag=* \ - | +langua=* | +langu=* | +lang=* | +lan=* | +la=* \ - | +l=*) - languages="${languages} `echo ${arg} | sed 's/[+-]l[a-z]*=//'`" - ;; - -gas | +g*) - gas=yes - ;; - -help | +h*) - fatal=true - ;; - -nfp | +nf*) - nfp=yes - ;; - -norecursion | +no*) - norecursion=true - ;; - -recurring | +recurring | +recurrin | +recurri | +recurr | +recur | +recu | +rec | +re) - recurring=true - ;; - -rm | +rm) - removing=${arg} - ;; -# -srcdir=* | +srcdir=* | +srcdi=* | +srcd=* | +src=* | +sr=* | +s=*) -# srcdir=`echo ${arg} | sed 's/[+-]s[a-z]*=//'` -# ;; - -subdirs | +f* | +su*) - subdirs=${arg} - ;; - -target=* | +target=* | +targe=* | +targ=* | +tar=* | +ta=*) - if [ -n "${targets}" ] ; then - subdirs="+subdirs" - fi - - newtargets="${targets} `echo ${arg} | sed 's/[+-]t[a-z]*=//'`" - targets="${newtargets}" - ;; - -template=* | +template=* | +templat=* | +templa=* | +templ=* | +temp=* | +tem=* | +te=*) - template=`echo ${arg} | sed 's/[+-]template=//'` - ;; - -v | -verbose | +v*) - verbose=${arg} - ;; - -* | +*) - (echo ; - echo "Unrecognized option: \"${arg}\"". ; - echo) 1>&2 - fatal=true - ;; - *) - if [ -n "${hosts}" ] ; then - subdirs="+subdirs" - fi - - newhosts="${hosts} ${arg}" - hosts=${newhosts} - ;; - esac -done - -if [ -n "${verbose}" ] ; then - echo `pwd`/configure $* -fi - -# process host and target only if not rebuilding configure itself or removing. -if [ -z "${template}" -a -z "${removing}" -a -z "${fatal}" ] ; then - # Complain if an arg is missing - if [ -z "${hosts}" ] ; then - (echo ; - echo "configure: No HOST specified." ; - echo) 1>&2 - fatal=true - fi -fi - -if [ -n "${fatal}" -o "${hosts}" = "help" ] ; then - (echo "Usage: configure HOST" ; - echo ; - echo "Options: [defaults in brackets]" ; - echo " +ansi configure w/ANSI library. [no ansi lib]" ; - echo " +destdir=MYDIR configure for installation into MYDIR. [/usr/local]" ; - echo " +subdirs configure in subdirectories. [in source directories]" ; - echo " +lang=LANG configure to build LANG. [gcc]" ; - echo " +help print this message. [normal config]" ; - echo " +gas configure the compilers for use with gas. [native as]" ; - echo " +nfp configure the compilers default to soft floating point. [hard float]" ; - echo " +norecursion configure this directory only. [recurse]" ; - echo " +rm remove this configuration. [build a configuration]" ; - echo " +target=TARGET configure for TARGET. [TARGET = HOST]" ; - echo " +template=TEM rebuild configure using TEM. [normal config]" ; - echo ; - echo "Where HOST and TARGET are something like \"vax\", \"sun3\", \"encore\", etc." ; - echo "Asking for more than one \"+target\" implies \"+subdirs\". Any other" ; - echo "options given will apply to all targets.") 1>&2 - - if [ -r config.status ] ; then - cat config.status - fi - - exit 1 -fi - -#### configure.in common parts come in here. -# This file is a shell script that supplies the information necessary -# to tailor a template configure script into the configure script -# appropriate for this directory. For more information, check any -# existing configure script. - -srctrigger=libbfd.c -srcname="bfd" - -## end of common part. - -# are we rebuilding config itself? -if [ -n "${template}" ] ; then - if [ ! -r ${template} ] ; then - echo '***' "Can't find template ${template}." 1>&2 - exit 1 - fi - -# prep the template - sed -e '/^#### configure.in common parts come in here.$/,/^## end of common part.$/c\ -#### configure.in common parts come in here.\ -## end of common part.' \ - -e '/^#### configure.in per-host parts come in here.$/,/^## end of per-host part.$/c\ -#### configure.in per-host parts come in here.\ -## end of per-host part.' \ - -e '/^#### configure.in per-target parts come in here.$/,/^## end of per-target part.$/c\ -#### configure.in per-target parts come in here.\ -## end of per-target part.' \ - -e '/^#### configure.in post-target parts come in here.$/,/^## end of post-target part.$/c\ -#### configure.in post-target parts come in here.\ -## end of post-target part.' \ - < ${template} > template.new - - if [ -r configure.in ] ; then - if [ -z "`grep '^# per\-host:' configure.in`" ] ; then - echo '***' `pwd`/configure.in has no "per-host:" line. 1>&2 - exit 1 - fi - - if [ -z "`grep '^# per\-target:' configure.in`" ] ; then - echo '***' `pwd`/configure.in has no "per-target:" line. 1>&2 - exit 1 - fi - - # split configure.in into common, per-host, per-target, - # and post-target parts. Post-target is optional. - sed -e '/^# per\-host:/,$d' configure.in > configure.com - sed -e '1,/^# per\-host:/d' -e '/^# per\-target:/,$d' configure.in > configure.hst - if grep -s '^# post-target:' configure.in ; then - sed -e '1,/^# per\-target:/d' -e '/^# post\-target:/,$d' configure.in > configure.tgt - sed -e '1,/^# post\-target:/d' configure.in > configure.pos - else - sed -e '1,/^# per\-target:/d' configure.in > configure.tgt - echo >configure.pos - fi - - # and insert them - sed -e '/^#### configure.in common parts come in here.$/ r configure.com' \ - -e '/^#### configure.in per\-host parts come in here.$/ r configure.hst' \ - -e '/^#### configure.in per\-target parts come in here.$/ r configure.tgt' \ - -e '/^#### configure.in post\-target parts come in here.$/ r configure.pos' \ - template.new > configure.new - - rm -f configure.com configure.tgt configure.hst configure.pos - else - echo Warning: no configure.in in `pwd` - cat ${template} >> configure - fi - - chmod a+x configure.new - rm template.new -# mv configure configure.old - mv configure.new configure - - if [ -n "${verbose}" ] ; then - echo Rebuilt configure in `pwd` - fi - - # Now update config.sub from the template directory. - if echo "$template" | grep -s 'configure$' ; then - cp `echo "$template" | sed s/configure$/config.sub/` ./config.sub.new - # mv config.sub config.sub.old - mv config.sub.new config.sub - - if [ -n "${verbose}" ] ; then - echo Rebuilt config.sub in `pwd` - fi - fi - - if [ -z "${norecursion}" ] ; then - # If template is relative path, make it absolute for recurring. - if echo "${template}" | grep -s '^/' ; then - true - else - template=`pwd`/${template} - fi - - while [ -n "${configdirs}" ] ; do - # set configdir to car of configdirs, configdirs to cdr of configdirs - set ${configdirs}; configdir=$1; shift; configdirs=$* - - if [ "`echo ${configdir}.*`" != "${configdir}.*" ] ; then - targetspecificdirs=${configdir}.* - else - targetspecificdirs= - fi - - for i in ${configdir} ${targetspecificdirs} ; do - if [ -d $i ] ; then - if [ -r $i/configure ] ; then - (cd $i ; - ./configure +template=${template} ${verbose}) - else - echo Warning: No configure script in `pwd`/$i - fi - else - if [ -n "${verbose}" ] ; then - echo Warning: directory $i is missing. - fi - fi - done - done - fi - - exit 0 -fi - -# some sanity checks on configure.in -if [ -z "${srctrigger}" ] ; then - echo Warning: srctrigger not set in configure.in. `pwd` not configured. - exit 1 -fi - -for host in ${hosts} ; do - # Default other arg - if [ -z "${targets}" -o -n "${defaulttargets}" ] ; then - targets=${host} - defaulttargets=true - fi - - host_alias=${host} - - result=`/bin/sh ./config.sub ${host}` - host_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'` - host_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'` - host_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'` - host=${host_cpu}-${host_vendor}-${host_os} - host_makefile_frag=config/hmake-${host} - -#### configure.in per-host parts come in here. - -if [ "${host_os}" = "posix" ] ; then - bfd_host=posix -else - case "${host_cpu}" in - rs6000) bfd_host=aix ;; - mips) - case "${host_vendor}" in - dec) bfd_host=dec3100 ;; - sgi) bfd_host=irix3 ;; - esac - ;; - m88k) - case "${host_vendor}" in - *) - case "${host_os}" in - dgux) bfd_host=dgux ;; - esac - ;; - esac - ;; - m68k) - case "${host_vendor}" in - cbm) - case ${host_os} in - amigados) bfd_host=amigados ;; - svr4) bfd_host=amix ;; - esac - ;; - hp) - case "${host_os}" in - hpux) bfd_host=hp9000 ;; - bsd) bfd_host=hp300bsd ;; - esac - ;; - sony) bfd_host=news ;; - sun) bfd_host=sun3 ;; - esac - ;; - - i386) - case "${host_vendor}" in - *) - case "${host_os}" in - sysv) bfd_host=i386v ;; - esac - ;; - esac - ;; - - sparc) - case "${host_vendor}" in - sun) bfd_host=sun4 ;; - esac - ;; - - rtpc) bfd_host=rtbsd - ;; - - a29k) bfd_host=ultra3 - ;; - - tahoe) - bfd_host=${host_cpu} - ;; - vax) - case "${host_os}" in - ultrix) bfd_host=vaxult ;; - *) bfd_host=vax ;; - esac - ;; - esac -fi - -if [ ! -f config/h-${bfd_host} ] ; then - echo '***' BFD does not support host ${host}: no file config/h-${bfd_host} - exit 1 -fi - -host_makefile_frag=config/h-${bfd_host} - -## end of per-host part. - - for target in ${targets} ; do - - target_alias=${target} - result=`/bin/sh ./config.sub ${target}` - target_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'` - target_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'` - target_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'` - target=${target_cpu}-${target_vendor}-${target_os} - target_makefile_frag=config/tmake-${target} - -#### configure.in per-target parts come in here. - -case "${target_vendor}" in -aout | coff | bout | elf) bfd_target=${target_cpu}-${target_vendor} ;; -sony) bfd_target=news ;; -intel) bfd_target=${target_cpu}-coff ;; -cbm) bfd_target=${target_cpu}-elf ;; - -hitachi) - case "${target_cpu}" in - h8300) bfd_target=h8300-ieee ;; - *) echo "bad hitachi cpu" ;; - esac - ;; - - -wrs) - case "${target_cpu}" in - i960) bfd_target=i960-bout ;; - m68k) bfd_target=m68k-aout ;; - esac - ;; -sun) - case "${target_cpu}" in - m68k) bfd_target=m68k-aout ;; - sparc) bfd_target=sparc-aout ;; - esac - ;; -dec) - case "${target_cpu}" in - mips) bfd_target=dec3100 ;; - vax) bfd_target=vax ;; - esac - ;; -hp) - case "${target_cpu}" in - m68k) - case "${target_os}" in - hpux) bfd_target=hp9000 ;; - bsd) bfd_target=hp300bsd ;; - esac - ;; - esac - ;; -sgi) - case "${target_cpu}" in - mips) - bfd_target=irix3 ;; - esac - ;; -none|nyu) - case "${target_cpu}" in - i386) bfd_target=i386-coff ;; - a29k) case "${target_os}" in - aout) bfd_target=a29k-aout ;; - coff) bfd_target=a29k-coff ;; - sym1) bfd_target=a29k-coff ;; - esac - ;; - tahoe | vax) bfd_target=${target_cpu} ;; - esac - ;; -*) - case "${target_cpu}" in - tahoe | vax) bfd_target=${target_cpu} ;; - esac - ;; -esac - -if [ ! -f config/t-${bfd_target} ] ; then - echo '***' BFD does not support target ${target}: no file config/t-${bfd_target} - exit 1 -fi - -target_makefile_frag=config/t-${bfd_target} - -files= -links= -## end of per-target part. - - # Temporarily, we support only direct subdir builds. - hostsubdir=H-${host_alias} - targetsubdir=T-${target_alias} - - if [ -n "${removing}" ] ; then - if [ -n "${subdirs}" ] ; then - if [ -d "${hostsubdir}" ] ; then - rm -rf ${hostsubdir}/${targetsubdir} - - if [ -z "`(ls ${hostsubdir}) 2>&1 | grep Target- | grep -v Target-independent`" ] ; then - rm -rf ${hostsubdir} - fi - else - echo Warning: no `pwd`/${hostsubdir} to remove. - fi - else - rm -f ${Makefile} config.status ${links} - fi - else - if [ -n "${subdirs}" ] ; then - # check for existing status before allowing forced subdirs. - if [ -f ${Makefile} ] ; then - echo '***' "${Makefile} already exists in source directory. `pwd` not configured." 1>&2 - exit 1 - fi - - if [ ! -d ${hostsubdir} ] ; then mkdir ${hostsubdir} ; fi - cd ${hostsubdir} - - if [ ! -d ${targetsubdir} ] ; then - if [ -z "${commontargets}" ] ; then - mkdir ${targetsubdir} - else - if [ ! -d Target-independent ] ; then - mkdir Target-independent - fi - - ${symbolic_link} Target-independent ${targetsubdir} - fi # if target independent - fi # if no target dir yet - - cd ${targetsubdir} - - srcdir=../.. - else - # if not subdir builds, then make sure none exist. - if [ -n "`(ls .) 2>&1 | grep Host-`" ] ; then - echo '***' "Configured subdirs exist. `pwd` not configured." 1>&2 - exit 1 - fi - fi - - # Find the source files, if location was not specified. - if [ -z "${srcdir}" ] ; then - srcdirdefaulted=1 - srcdir=. - if [ -n "${srctrigger}" -a ! -r ${srctrigger} ] ; then - srcdir=.. - fi - fi - - if [ -n "${srctrigger}" -a ! -r ${srcdir}/${srctrigger} ] ; then - if [ -z "${srcdirdefaulted}" ] ; then - echo '***' "${progname}: Can't find ${srcname} sources in `pwd`/${srcdir}" 1>&2 - else - echo '***' "${progname}: Can't find ${srcname} sources in `pwd`/. or `pwd`/.." 1>&2 - fi - - echo '***' \(At least ${srctrigger} is missing.\) 1>&2 - exit 1 - fi - - # Set up the list of links to be made. - # ${links} is the list of link names, and ${files} is the list of names to link to. - - # Make the links. - while [ -n "${files}" ] ; do - # set file to car of files, files to cdr of files - set ${files}; file=$1; shift; files=$* - set ${links}; link=$1; shift; links=$* - - if [ ! -r ${srcdir}/${file} ] ; then - echo '***' "${progname}: cannot create a link \"${link}\"," 1>&2 - echo '***' "since the file \"${file}\" does not exist." 1>&2 - exit 1 - fi - - ${remove} -f ${link} - rm -f config.status - # Make a symlink if possible, otherwise try a hard link - ${symbolic_link} ${srcdir}/${file} ${link} 2>/dev/null || ${hard_link} ${srcdir}/${file} ${link} - - if [ ! -r ${link} ] ; then - echo '***' "${progname}: unable to link \"${link}\" to \"${srcdir}/${file}\"." 1>&2 - exit 1 - fi - - if [ -n "${verbose}" ] ; then - echo "Linked \"${link}\" to \"${srcdir}/${file}\"." - fi - done - - # Create a .gdbinit file which runs the one in srcdir - # and tells GDB to look there for source files. - - case ${srcdir} in - .) - ;; - *) - echo "dir ." > .gdbinit - echo "dir ${srcdir}" >> .gdbinit - echo "source ${srcdir}/.gdbinit" >> .gdbinit - ;; - esac - - # Install a makefile, and make it set VPATH - # if necessary so that the sources are found. - # Also change its value of srcdir. - - # FIXME-someday: This business of always writing to .tem and mv back - # is so that I don't screw things up while developing. Once this - # template is stable, these should be optimized. xoxorich. - - # Define macro CROSS_COMPILE in compilation if this is a cross-compiler. - if [ "${host}" != "${target}" ] ; then - echo "CROSS=-DCROSS_COMPILE" > ${Makefile} - echo "ALL=start.encap" >> ${Makefile} - else - echo "ALL=all.internal" > ${Makefile} - fi - - # set target, host, VPATH - echo "host_alias = ${host_alias}" >> ${Makefile} - echo "host_cpu = ${host_cpu}" >> ${Makefile} - echo "host_vendor = ${host_vendor}" >> ${Makefile} - echo "host_os = ${host_os}" >> ${Makefile} - - echo "target_alias = ${target_alias}" >> ${Makefile} - echo "target_cpu = ${target_cpu}" >> ${Makefile} - echo "target_vendor = ${target_vendor}" >> ${Makefile} - echo "target_os = ${target_os}" >> ${Makefile} - - if [ -n "${subdirs}" ] ; then - echo "subdir = /${hostsubdir}/${targetsubdir}" >> ${Makefile} - else - echo "subdir =" >> ${Makefile} - fi - - # echo "workdir = `pwd`" >> ${Makefile} - echo "VPATH = ${srcdir}" >> ${Makefile} - - # add "Makefile.in" (or whatever it's called) - cat ${srcdir}/${Makefile_in} >> ${Makefile} - - # Conditionalize the makefile for this host. - if [ -f ${srcdir}/${host_makefile_frag} ] ; then - (echo "host_makefile_frag = ${srcdir}/${host_makefile_frag}" ; - sed -e "/^####/ r ${srcdir}/${host_makefile_frag}" ${Makefile}) > Makefile.tem - mv Makefile.tem ${Makefile} - fi - - # Conditionalize the makefile for this target. - if [ -f ${srcdir}/${target_makefile_frag} ] ; then - (echo "target_makefile_frag = ${srcdir}/${target_makefile_frag}" ; - sed -e "/^####/ r ${srcdir}/${target_makefile_frag}" ${Makefile}) > Makefile.tem - mv Makefile.tem ${Makefile} - fi - - # set srcdir - sed "s@^srcdir = \.@srcdir = ${srcdir}@" ${Makefile} > Makefile.tem - mv Makefile.tem ${Makefile} - - # set destdir - if [ -n "${destdir}" ] ; then - sed "s:^destdir =.*$:destdir = ${destdir}:" ${Makefile} > Makefile.tem - mv Makefile.tem ${Makefile} - fi - - # reset SUBDIRS - sed "s:^SUBDIRS =.*$:SUBDIRS = ${configdirs}:" ${Makefile} > Makefile.tem - mv Makefile.tem ${Makefile} - - # reset NONSUBDIRS - sed "s:^NONSUBDIRS =.*$:NONSUBDIRS = ${noconfigdirs}:" ${Makefile} > Makefile.tem - mv Makefile.tem ${Makefile} - - using= - if [ -f ${srcdir}/${host_makefile_frag} ] ; then - using=" using \"${host_makefile_frag}\"" - fi - - # remove any form feeds. - sed -e "s/ //" ${Makefile} > Makefile.tem - mv Makefile.tem ${Makefile} - - if [ -f ${srcdir}/${target_makefile_frag} ] ; then - if [ -z "${using}" ] ; then - andusing=" using \"${target_makefile_frag}\"" - else - andusing="${using} and \"${target_makefile_frag}\"" - fi - else - andusing=${using} - fi - - if [ -n "${verbose}" -o -z "${recurring}" ] ; then - echo "Created \"${Makefile}\"" in `pwd`${andusing}. - fi - -#### configure.in post-target parts come in here. - -## end of post-target part. - - # describe the chosen configuration in config.status. - # Make that file a shellscript which will reestablish - # the same configuration. Used in Makefiles to rebuild - # Makefiles. - - echo "#!/bin/sh -# ${srcname} was configured as follows: -${srcdir}/configure" ${arguments} `if [ -z "${norecursion}" ] ; then echo +norecursion ; else true ; fi` > config.status - chmod a+x config.status - - originaldir=`pwd` - cd ${srcdir} - fi - - # If there are subdirectories, then recurse. - if [ -z "${norecursion}" -a -n "${configdirs}" ] ; then - for configdir in ${configdirs} ; do - if [ -n "${verbose}" ] ; then - echo Configuring ${configdir}... - fi - - if [ -d ${configdir} ] ; then - (cd ${configdir} ; - ./configure +recurring ${host_alias} +target=${target_alias} \ - ${verbose} ${subdirs} ${removing} +destdir=${destdir}) \ - | sed 's/^/ /' - else - if [ -n "${verbose}" ] ; then - echo Warning: directory \"${configdir}\" is missing. - fi - fi - done - fi - done # for each target - - # Now build a Makefile for this host. - if [ -n "${subdirs}" -a ! -n "${removing}" ] ; then - cd ${hostsubdir} - cat > GNUmakefile << E!O!F -# Makefile generated by configure for host ${host_alias}. - -ALL := $(shell ls -d Target-*) - -%: - $(foreach subdir,$(ALL),$(MAKE) -C $(subdir) \$@ &&) true - -all: -E!O!F - cd .. - fi -done # for each host - -exit 0 - -# -# Local Variables: -# fill-column: 131 -# End: -# - -# end of configure diff --git a/bfd/configure.in b/bfd/configure.in deleted file mode 100644 index 5d16c80d2c9..00000000000 --- a/bfd/configure.in +++ /dev/null @@ -1,213 +0,0 @@ -# This file is a shell script that supplies the information necessary -# to tailor a template configure script into the configure script -# appropriate for this directory. For more information, check any -# existing configure script. - -srctrigger=libbfd.c -srcname="BFD" - -# per-host: - -case "${host_cpu}" in - -rs6000) my_host=rs6000 - ;; - -mips) - case "${host_vendor}" in - dec) my_host=decstation ;; - sgi) my_host=irix3 ;; - esac - ;; - -m88k) - case "${host_vendor}" in - motorola) - my_host=delta88 ;; - harris) - my_host=harris ;; - *) - case "${host_os}" in - dgux) my_host=dgux ;; - esac - ;; - esac - ;; - -m68k) - case "${host_vendor}" in - cbm) - case ${host_os} in - amigados) my_host=amigados ;; - svr4) my_host=amix ;; - esac - ;; - hp) - case "${host_os}" in - hpux) my_host=hp9000 ;; - bsd) my_host=hp300bsd ;; - esac - ;; - sony) my_host=news ;; - sun) my_host=sun3 ;; - esac - ;; - -i386) - case "${host_vendor}" in - *) - case "${host_os}" in - sysv*) my_host=i386v ;; - mach*) my_host=i386mach ;; - msdos*) my_host=dose ;; - esac - ;; - esac - ;; - -sparc) - case "${host_os}" in - sunos64) my_host=sparc-ll ;; - *) my_host=sparc ;; - esac - ;; - -romp) my_host=rtbsd - ;; - -a29k) my_host=ultra3 - ;; - -tahoe) - my_host=tahoe - ;; - -vax) - case "${host_os}" in - ultrix) my_host=vaxult ;; - *) my_host=vaxbsd ;; - esac - ;; -esac - -# Set up to make a link between the host's include file and "sysdep.h". -files="hosts/h-${my_host}.h" -links="sysdep.h" - -if [ ! -f ${files} ] ; then - if [ -n "${my_host}" ] ; then - echo '***' No file ${files} - fi - echo '***' ${srcname} does not support host ${host} - exit 1 -fi - -host_makefile_frag= -if [ -f config/mh-${my_host} ] ; then - host_makefile_frag=config/mh-${my_host} -fi - -# per-target: - -case "${target_vendor}" in -aout | coff | bout | elf) bfd_target=${target_cpu}-${target_vendor} ;; -sony) bfd_target=news ;; -intel) bfd_target=${target_cpu}-coff ;; -cbm) bfd_target=${target_cpu}-elf ;; - -ibm) my_host=rs6000 - case "${target_cpu}" in - rs6000) bfd_target=rs6000 ;; - esac - ;; - -amd) - case "${target_os}" in - ebmon) bfd_target=a29k-coff ;; - *) bfd_target=a29k-aout ;; - esac - ;; - -hitachi) - case "${target_cpu}" in - h8300) bfd_target=h8300-ieee ;; - *) echo "bad hitachi cpu" ;; - esac - ;; - - -wrs) - case "${target_cpu}" in - i960) bfd_target=i960-bout ;; - m68k) bfd_target=m68k-aout ;; - esac - ;; -sun) - case "${target_cpu}" in - m68k) bfd_target=m68k-aout ;; - sparc) bfd_target=sparc-aout ;; - esac - ;; -dec) - case "${target_cpu}" in - mips) bfd_target=decstation ;; - vax) bfd_target=vax ;; - esac - ;; -hp) - case "${target_cpu}" in - m68k) - case "${target_os}" in - hpux) bfd_target=hp9000 ;; - bsd) bfd_target=hp300bsd ;; - esac - ;; - esac - ;; -sgi) - case "${target_cpu}" in - mips) - bfd_target=irix3 ;; - esac - ;; -none|nyu|sco) - case "${target_cpu}" in - i386) bfd_target=i386-coff ;; - a29k) case "${target_os}" in - aout) bfd_target=a29k-aout ;; - coff) bfd_target=a29k-coff ;; - sym1) bfd_target=a29k-coff ;; - esac - ;; - tahoe | vax) bfd_target=${target_cpu} ;; - esac - ;; -harris) - case "${target_cpu}" in - m88k) bfd_target=m88kbcs ;; - esac - ;; - -motorola) - case "${target_cpu}" in - m88k) bfd_target=m88kbcs ;; - esac - ;; -*) - case "${target_cpu}" in - tahoe | vax) bfd_target=${target_cpu} ;; - esac - ;; -esac - -if [ ! -f config/mt-${bfd_target} ] ; then - if [ -n "${bfd_target}" ] ; then - echo '***' No file config/mt-${bfd_target} - fi - echo '***' BFD does not support target ${target} - exit 1 -fi -target_makefile_frag=config/mt-${bfd_target} - -# We don't do any links based on the target system, just very minor makefile -# config. diff --git a/bfd/core.c b/bfd/core.c deleted file mode 100644 index 49fa7dc9a42..00000000000 --- a/bfd/core.c +++ /dev/null @@ -1,85 +0,0 @@ -/* Core file generic interface routines for BFD. - Copyright (C) 1990-1991 Free Software Foundation, Inc. - Written by Cygnus Support. - -This file is part of BFD, the Binary File Descriptor library. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/*doc* -@section Core files -Buff output this facinating topic -*/ - -#include "bfd.h" -#include "sysdep.h" -#include "libbfd.h" - -/** Some core file info commands */ - -/*proto* bfd_core_file_failing_command -Returns a read-only string explaining what program was running when -it failed and produced the core file being read - -*; PROTO(CONST char *, bfd_core_file_failing_command, (bfd *)); -*/ - -CONST char * -DEFUN(bfd_core_file_failing_command,(abfd), - bfd *abfd) -{ - if (abfd->format != bfd_core) { - bfd_error = invalid_operation; - return NULL; - } - return BFD_SEND (abfd, _core_file_failing_command, (abfd)); -} - -/*proto* bfd_core_file_failing_signal -Returns the signal number which caused the core dump which generated -the file the BFD is attached to. - -*; PROTO(int, bfd_core_file_failing_signal, (bfd *)); -*/ -int -bfd_core_file_failing_signal (abfd) - bfd *abfd; -{ - if (abfd->format != bfd_core) { - bfd_error = invalid_operation; - return 0; - } - return BFD_SEND (abfd, _core_file_failing_signal, (abfd)); -} - - -/*proto* core_file_matches_executable_p -Returns @code{true} if the core file attached to @var{core_bfd} was -generated by a run of the executable file attached to @var{exec_bfd}, -or else @code{false}. -*; PROTO(boolean, core_file_matches_executable_p, - (bfd *core_bfd, bfd *exec_bfd)); -*/ -boolean -core_file_matches_executable_p (core_bfd, exec_bfd) - bfd *core_bfd, *exec_bfd; -{ - if ((core_bfd->format != bfd_core) || (exec_bfd->format != bfd_object)) { - bfd_error = wrong_format; - return false; - } - - return BFD_SEND (core_bfd, _core_file_matches_executable_p, (core_bfd, exec_bfd)); -} diff --git a/bfd/cplus-dem.c b/bfd/cplus-dem.c deleted file mode 100755 index edb9e39089c..00000000000 --- a/bfd/cplus-dem.c +++ /dev/null @@ -1,942 +0,0 @@ -/* Demangler for GNU C++ - Copyright (C) 1989 Free Software Foundation, Inc. - written by James Clark (jjc@jclark.uucp) - - 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* This is for g++ 1.36.1 (November 6 version). It will probably - require changes for any other version. - - Modified for g++ 1.36.2 (November 18 version). */ - -/* This file exports one function - - char *cplus_demangle (const char *name) - - If `name' is a mangled function name produced by g++, then - a pointer to a malloced string giving a C++ representation - of the name will be returned; otherwise NULL will be returned. - It is the caller's responsibility to free the string which - is returned. - - For example, - - cplus_demangle ("_foo__1Ai") - - returns - - "A::foo(int)" - - This file imports xmalloc and xrealloc, which are like malloc and - realloc except that they generate a fatal error if there is no - available memory. */ - -/* #define nounderscore 1 /* define this is names don't start with _ */ - -#include -#include -#include - -/* #include "misc.h" */ - -#ifdef USG -#include -#else -#define memcpy(s1, s2, n) strncpy(s1, s2, n) -#define memcmp(s1, s2, n) strncmp(s1, s2, n) -#define strchr(s, c) index(s, c) -#endif - -#ifndef __STDC__ -#define const -#endif - -#ifdef __STDC__ -extern char *cplus_demangle (const char *type); -#else -extern char *cplus_demangle (); -#endif - -static char **typevec = 0; -static int ntypes = 0; -static int typevec_size = 0; - -static struct { - const char *in; - const char *out; -} optable[] = { - "new", " new", - "delete", " delete", - "ne", "!=", - "eq", "==", - "ge", ">=", - "gt", ">", - "le", "<=", - "lt", "<", - "plus", "+", - "minus", "-", - "mult", "*", - "convert", "+", /* unary + */ - "negate", "-", /* unary - */ - "trunc_mod", "%", - "trunc_div", "/", - "truth_andif", "&&", - "truth_orif", "||", - "truth_not", "!", - "postincrement", "++", - "postdecrement", "--", - "bit_ior", "|", - "bit_xor", "^", - "bit_and", "&", - "bit_not", "~", - "call", "()", - "cond", "?:", - "alshift", "<<", - "arshift", ">>", - "component", "->", - "indirect", "*", - "method_call", "->()", - "addr", "&", /* unary & */ - "array", "[]", - "nop", "", /* for operator= */ -}; - -/* Beware: these aren't '\0' terminated. */ - -typedef struct { - char *b; /* pointer to start of string */ - char *p; /* pointer after last character */ - char *e; /* pointer after end of allocated space */ -} string; - -#ifdef __STDC__ -static void string_need (string *s, int n); -static void string_delete (string *s); -static void string_init (string *s); -static void string_clear (string *s); -static int string_empty (string *s); -static void string_append (string *p, const char *s); -static void string_appends (string *p, string *s); -static void string_appendn (string *p, const char *s, int n); -static void string_prepend (string *p, const char *s); -#if 0 -static void string_prepends (string *p, string *s); -#endif -static void string_prependn (string *p, const char *s, int n); -static int get_count (const char **type, int *count); -static int do_args (const char **type, string *decl); -static int do_type (const char **type, string *result); -static int do_arg (const char **type, string *result); -static int do_args (const char **type, string *decl); -static void munge_function_name (string *name); -#else -static void string_need (); -static void string_delete (); -static void string_init (); -static void string_clear (); -static int string_empty (); -static void string_append (); -static void string_appends (); -static void string_appendn (); -static void string_prepend (); -static void string_prepends (); -static void string_prependn (); -static int get_count (); -static int do_args (); -static int do_type (); -static int do_arg (); -static int do_args (); -static void munge_function_name (); -#endif - -char * -cplus_demangle (type) - const char *type; -{ - string decl; - int n; - int success = 0; - int constructor = 0; - int const_flag = 0; - int i; - const char *p, *premangle; - - if (type == NULL || *type == '\0') - return NULL; -#ifndef nounderscore - if (*type++ != '_') - return NULL; -#endif - p = type; - while (*p != '\0' && !(*p == '_' && p[1] == '_')) - p++; - if (*p == '\0') - { - /* destructor */ - if (type[0] == '_' && type[1] == '$' && type[2] == '_') - { - unsigned int l = (strlen (type) - 3)*2 + 3 + 2 + 1; - char *tem = (char *) zalloc (l); - strcpy (tem, type + 3); - strcat (tem, "::~"); - strcat (tem, type + 3); - strcat (tem, "()"); - return tem; - } - /* static data member */ - if (*type != '_' && (p = (char *) strchr (type, '$')) != NULL) - { - int n = strlen (type) + 2; - char *tem = (char *) xmalloc (n); - memcpy (tem, type, p - type); - strcpy (tem + (p - type), "::"); - strcpy (tem + (p - type) + 2, p + 1); - return tem; - } - /* virtual table */ - if (type[0] == '_' && type[1] == 'v' && type[2] == 't' && type[3] == '$') - { - int n = strlen (type + 4) + 14 + 1; - char *tem = (char *) xmalloc (n); - strcpy (tem, type + 4); - strcat (tem, " virtual table"); - return tem; - } - return NULL; - } - - string_init (&decl); - - if (p == type) - { - if (!isdigit (p[2])) - { - string_delete (&decl); - return NULL; - } - constructor = 1; - } - else - { - string_appendn (&decl, type, p - type); - munge_function_name (&decl); - } - p += 2; - - premangle = p; - switch (*p) - { - case 'C': - /* a const member function */ - if (!isdigit (p[1])) - { - string_delete (&decl); - return NULL; - } - p += 1; - const_flag = 1; - /* fall through */ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - n = 0; - do - { - n *= 10; - n += *p - '0'; - p += 1; - } - while (isdigit (*p)); - if (strlen (p) < n) - { - string_delete (&decl); - return NULL; - } - if (constructor) - { - string_appendn (&decl, p, n); - string_append (&decl, "::"); - string_appendn (&decl, p, n); - } - else - { - string_prepend (&decl, "::"); - string_prependn (&decl, p, n); - } -#ifndef LONGERNAMES - p = premangle; -#else - p += n; -#endif - success = do_args (&p, &decl); - if (const_flag) - string_append (&decl, " const"); - break; - case 'F': - p += 1; - success = do_args (&p, &decl); - break; - } - - for (i = 0; i < ntypes; i++) - if (typevec[i] != NULL) - free (typevec[i]); - ntypes = 0; - if (typevec != NULL) - { - free ((char *)typevec); - typevec = NULL; - typevec_size = 0; - } - - if (success) - { - string_appendn (&decl, "", 1); - return decl.b; - } - else - { - string_delete (&decl); - return NULL; - } -} - -static int -get_count (type, count) - const char **type; - int *count; -{ - if (!isdigit (**type)) - return 0; - *count = **type - '0'; - *type += 1; - /* see flush_repeats in cplus-method.c */ - if (isdigit (**type)) - { - const char *p = *type; - int n = *count; - do - { - n *= 10; - n += *p - '0'; - p += 1; - } - while (isdigit (*p)); - if (*p == '_') - { - *type = p + 1; - *count = n; - } - } - return 1; -} - -/* result will be initialised here; it will be freed on failure */ - -static int -do_type (type, result) - const char **type; - string *result; -{ - int n; - int done; - int non_empty = 0; - int success; - string decl; - const char *remembered_type; - - string_init (&decl); - string_init (result); - - done = 0; - success = 1; - while (success && !done) - { - int member; - switch (**type) - { - case 'P': - *type += 1; - string_prepend (&decl, "*"); - break; - - case 'R': - *type += 1; - string_prepend (&decl, "&"); - break; - - case 'T': - *type += 1; - if (!get_count (type, &n) || n >= ntypes) - success = 0; - else - { - remembered_type = typevec[n]; - type = &remembered_type; - } - break; - - case 'F': - *type += 1; - if (!string_empty (&decl) && decl.b[0] == '*') - { - string_prepend (&decl, "("); - string_append (&decl, ")"); - } - if (!do_args (type, &decl) || **type != '_') - success = 0; - else - *type += 1; - break; - - case 'M': - case 'O': - { - int constp = 0; - int volatilep = 0; - - member = **type == 'M'; - *type += 1; - if (!isdigit (**type)) - { - success = 0; - break; - } - n = 0; - do - { - n *= 10; - n += **type - '0'; - *type += 1; - } - while (isdigit (**type)); - if (strlen (*type) < n) - { - success = 0; - break; - } - string_append (&decl, ")"); - string_prepend (&decl, "::"); - string_prependn (&decl, *type, n); - string_prepend (&decl, "("); - *type += n; - if (member) - { - if (**type == 'C') - { - *type += 1; - constp = 1; - } - if (**type == 'V') - { - *type += 1; - volatilep = 1; - } - if (*(*type)++ != 'F') - { - success = 0; - break; - } - } - if ((member && !do_args (type, &decl)) || **type != '_') - { - success = 0; - break; - } - *type += 1; - if (constp) - { - if (non_empty) - string_append (&decl, " "); - else - non_empty = 1; - string_append (&decl, "const"); - } - if (volatilep) - { - if (non_empty) - string_append (&decl, " "); - else - non_empty = 1; - string_append (&decl, "volatilep"); - } - break; - } - - case 'C': - if ((*type)[1] == 'P') - { - *type += 1; - if (!string_empty (&decl)) - string_prepend (&decl, " "); - string_prepend (&decl, "const"); - break; - } - - /* fall through */ - default: - done = 1; - break; - } - } - - done = 0; - non_empty = 0; - while (success && !done) - { - switch (**type) - { - case 'C': - *type += 1; - if (non_empty) - string_append (result, " "); - else - non_empty = 1; - string_append (result, "const"); - break; - case 'U': - *type += 1; - if (non_empty) - string_append (result, " "); - else - non_empty = 1; - string_append (result, "unsigned"); - break; - case 'V': - *type += 1; - if (non_empty) - string_append (result, " "); - else - non_empty = 1; - string_append (result, "volatile"); - break; - default: - done = 1; - break; - } - } - - if (success) - switch (**type) - { - case '\0': - case '_': - break; - case 'v': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "void"); - break; - case 'l': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "long"); - break; - case 'i': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "int"); - break; - case 's': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "short"); - break; - case 'c': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "char"); - break; - case 'r': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "long double"); - break; - case 'd': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "double"); - break; - case 'f': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "float"); - break; - case 'G': - *type += 1; - if (!isdigit (**type)) - { - success = 0; - break; - } - /* fall through */ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - n = 0; - do - { - n *= 10; - n += **type - '0'; - *type += 1; - } - while (isdigit (**type)); - if (strlen (*type) < n) - { - success = 0; - break; - } - if (non_empty) - string_append (result, " "); - string_appendn (result, *type, n); - *type += n; - break; - default: - success = 0; - break; - } - - if (success) - { - if (!string_empty (&decl)) - { - string_append (result, " "); - string_appends (result, &decl); - } - string_delete (&decl); - return 1; - } - else - { - string_delete (&decl); - string_delete (result); - return 0; - } -} - -/* `result' will be initialised in do_type; it will be freed on failure */ - -static int -do_arg (type, result) - const char **type; - string *result; -{ - char *tem; - int len; - const char *start; - const char *end; - - start = *type; - if (!do_type (type, result)) - return 0; - end = *type; - if (ntypes >= typevec_size) - { - if (typevec_size == 0) - { - typevec_size = 3; - typevec = (char **) xmalloc (sizeof (char*)*typevec_size); - } - else - { - typevec_size *= 2; - typevec = (char **) realloc ((char *)typevec, sizeof (char*)*typevec_size); - } - } - len = end - start; - tem = (char *) xmalloc (len + 1); - memcpy (tem, start, len); - tem[len] = '\0'; - typevec[ntypes++] = tem; - return 1; -} - -/* `decl' must be already initialised, usually non-empty; - it won't be freed on failure */ - -static int -do_args (type, decl) - const char **type; - string *decl; -{ - string arg; - int need_comma = 0; - int dont_want_first; - -#ifndef LONGERNAMES - dont_want_first = 1; -#else - dont_want_first = 0; -#endif - - string_append (decl, "("); - - while (**type != '_' && **type != '\0' && **type != 'e' && **type != 'v') - { - if (**type == 'N') - { - int r; - int t; - *type += 1; - if (!get_count (type, &r) || !get_count (type, &t) || t >= ntypes) - return 0; - while (--r >= 0) - { - const char *tem = typevec[t]; - if (need_comma) - string_append (decl, ", "); - if (!do_arg (&tem, &arg)) - return 0; - string_appends (decl, &arg); - string_delete (&arg); - need_comma = 1; - } - } - else - { - if (need_comma) - string_append (decl, ", "); - if (!do_arg (type, &arg)) - return 0; - if (dont_want_first) - dont_want_first = 0; - else - { - string_appends (decl, &arg); - need_comma = 1; - } - string_delete (&arg); - } - } - - if (**type == 'v') - *type += 1; - else if (**type == 'e') - { - *type += 1; - if (need_comma) - string_append (decl, ","); - string_append (decl, "..."); - } - - string_append (decl, ")"); - return 1; -} - -static void -munge_function_name (name) - string *name; -{ - if (!string_empty (name) && name->p - name->b >= 3 - && name->b[0] == 'o' && name->b[1] == 'p' && name->b[2] == '$') - { - int i; - /* see if it's an assignment expression */ - if (name->p - name->b >= 10 /* op$assign_ */ - && memcmp (name->b + 3, "assign_", 7) == 0) - { - for (i = 0; i < sizeof (optable)/sizeof (optable[0]); i++) - { - int len = name->p - name->b - 10; - if (strlen (optable[i].in) == len - && memcmp (optable[i].in, name->b + 10, len) == 0) - { - string_clear (name); - string_append (name, "operator"); - string_append (name, optable[i].out); - string_append (name, "="); - return; - } - } - } - else - { - for (i = 0; i < sizeof (optable)/sizeof (optable[0]); i++) - { - int len = name->p - name->b - 3; - if (strlen (optable[i].in) == len - && memcmp (optable[i].in, name->b + 3, len) == 0) - { - string_clear (name); - string_append (name, "operator"); - string_append (name, optable[i].out); - return; - } - } - } - return; - } - else if (!string_empty (name) && name->p - name->b >= 5 - && memcmp (name->b, "type$", 5) == 0) - { - /* type conversion operator */ - string type; - const char *tem = name->b + 5; - if (do_type (&tem, &type)) - { - string_clear (name); - string_append (name, "operator "); - string_appends (name, &type); - string_delete (&type); - return; - } - } -} - -/* a mini string-handling package */ - -static void -string_need (s, n) - string *s; - int n; -{ - if (s->b == NULL) - { - if (n < 32) - n = 32; - s->p = s->b = (char *) xmalloc (n); - s->e = s->b + n; - } - else if (s->e - s->p < n) - { - int tem = s->p - s->b; - n += tem; - n *= 2; - s->b = (char *) realloc (s->b, n); - s->p = s->b + tem; - s->e = s->b + n; - } -} - -static void -string_delete (s) - string *s; -{ - if (s->b != NULL) - { - free (s->b); - s->b = s->e = s->p = NULL; - } -} - -static void -string_init (s) - string *s; -{ - s->b = s->p = s->e = NULL; -} - -static void -string_clear (s) - string *s; -{ - s->p = s->b; -} - -static int -string_empty (s) - string *s; -{ - return s->b == s->p; -} - -static void -string_append (p, s) - string *p; - const char *s; -{ - int n; - if (s == NULL || *s == '\0') - return; - n = strlen (s); - string_need (p, n); - memcpy (p->p, s, n); - p->p += n; -} - -static void -string_appends (p, s) - string *p, *s; -{ - int n; - if (s->b == s->p) - return; - n = s->p - s->b; - string_need (p, n); - memcpy (p->p, s->b, n); - p->p += n; -} - -static void -string_appendn (p, s, n) - string *p; - const char *s; - int n; -{ - if (n == 0) - return; - string_need (p, n); - memcpy (p->p, s, n); - p->p += n; -} - -static void -string_prepend (p, s) - string *p; - const char *s; -{ - if (s == NULL || *s == '\0') - return; - string_prependn (p, s, strlen (s)); -} - -static void -string_prependn (p, s, n) - string *p; - const char *s; - int n; -{ - char *q; - - if (n == 0) - return; - string_need (p, n); - for (q = p->p - 1; q >= p->b; q--) - q[n] = q[0]; - memcpy (p->b, s, n); - p->p += n; -} diff --git a/bfd/cpu-a29k.c b/bfd/cpu-a29k.c deleted file mode 100644 index e780d4078dd..00000000000 --- a/bfd/cpu-a29k.c +++ /dev/null @@ -1,24 +0,0 @@ -#include "bfd.h" -#include "sysdep.h" -#include "libbfd.h" - -static bfd_arch_info_type arch_info_struct = - { - 32, /* 32 bits in a word */ - 32, /* 32 bits in an address */ - 8, /* 8 bits in a byte */ - bfd_arch_a29k, - 0, /* only 1 machine */ - "a29k", - "a29k", - true, /* the one and only */ - bfd_default_compatible, - bfd_default_scan , - 0, - bfd_default_reloc_type_lookup, - }; - -void DEFUN_VOID(bfd_a29k_arch) -{ - bfd_arch_linkin(&arch_info_struct); -} diff --git a/bfd/cpu-h8300.c b/bfd/cpu-h8300.c deleted file mode 100644 index b4197cbdb74..00000000000 --- a/bfd/cpu-h8300.c +++ /dev/null @@ -1,413 +0,0 @@ -/* BFD library support routines for the Hitachi H8/300 architecture. - Copyright (C) 1990-1991 Free Software Foundation, Inc. - Hacked by Steve Chamberlain of Cygnus Support. - -This file is part of BFD, the Binary File Descriptor library. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "bfd.h" -#include "libbfd.h" - -#define DEFINE_TABLE -#include "h8300-opcode.h" - -#define MAXSAME 14 - -static struct h8_opcode * h8_opcodes_sorted[256][MAXSAME]; - -/* Run through the opcodes and sort them into order to make them easy - to disassemble - */ -static void -DEFUN_VOID(bfd_h8_disassemble_init) -{ - unsigned int i; - struct h8_opcode *p; - - for (p = h8_opcodes; p->name; p++) { - int where = 0; - int n1 = 0; - int n2 = 0; - int n3 = 0; - int n4= 0; - if ((int)p->data.nib[0] < 16) { - n1 =(int) p->data.nib[0] ; - } else n1 = 0; - if ((int)p->data.nib[1] < 16) { - n2 = (int) p->data.nib[1]; - }else n2 = 0; - - for (i = 0; i < MAXSAME; i++) { - int j = n1 * 16 + n2; - if (h8_opcodes_sorted[j][i] == (struct h8_opcode *)NULL) { - h8_opcodes_sorted[j][i] = p; - break; - } - } - - if (i==MAXSAME)abort(); - - /* Just make sure there are an even number of nibbles in it, and - that the count is the same s the length */ - for (i = 0; p->data.nib[i] != E; i++) ; - if (i & 1) abort(); - if (i/2 != p->length) abort(); - } - for (i = 0; i < 256; i++) - { - if (h8_opcodes_sorted[i][0]) - p = h8_opcodes_sorted[i][0]; - else h8_opcodes_sorted[i][0] = p; - } -} - - -unsigned int -DEFUN(bfd_h8_disassemble,(addr, data, stream), -bfd_vma addr AND -CONST bfd_byte *data AND -FILE *stream) -{ - /* Find the first entry in the table for this opcode */ - CONST static char *regnames[] = { - "r0h","r1h","r2h","r3h","r4h","r5h","r6h","r7h", - "r0l","r1l","r2l","r3l","r4l","r5l","r6l","r7l" }; - - int rs = 0; - int rd = 0; - int rdisp = 0; - int abs = 0; - struct h8_opcode **p = h8_opcodes_sorted[(unsigned)(data[0])]; - struct h8_opcode *q; - - /* Find the exact opcode/arg combo */ - while (*p) { - op_enum_type *nib; - unsigned int len = 0; - q = *p++; - nib =q->data.nib; - while (*nib != E) { - op_enum_type looking_for = *nib; - int thisnib = data[len>>1] ; - thisnib = (len & 1) ? (thisnib & 0xf) : ((thisnib >> 4) & 0xf); - if ((int)looking_for & (int)B31) { - if (((int)thisnib & 0x8) ==0) goto fail; - looking_for = (op_enum_type)((int)looking_for & ~(int)B31); - } - if ((int)looking_for & (int)B30) { - if (((int)thisnib & 0x8) !=0) goto fail; - looking_for = (op_enum_type)((int)looking_for & ~(int)B30); - } - switch (looking_for) { - case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: - case 8: case 9: case 10: case 11: case 12: case 13: case 14: case 15: - if ((int)looking_for != thisnib) goto fail; - break; - case ABS16SRC: - case ABS16DST: - case DISPSRC: - case DISPDST: - case IMM16: - abs = (data[len>>1]) * 256 + data[(len+2)>>1]; - len+=3; - nib+=3; - break; - case DISPREG: - rdisp = thisnib; - break; - case KBIT: - abs = thisnib == 0x80 ? 2:1; - break; - case IMM8: - case ABS8SRC: - case ABS8DST: - case DISP8: - abs= data[len>>1]; - len++; - nib++; - break; - case IMM3: - abs = thisnib ; - break; - case RS8: - case RS16: - case RSINC: - case RSIND: - rs = thisnib; - break; - case RD16: - case RDDEC: - case RD8: - case RDIND: - rd = thisnib; - break; - default: - fprintf(stream, "Dont understand \n"); - goto found; - } - len++; - nib++; - } - goto found; - fail: - ; - - } - fprintf(stream, "%02x %02x .word\tH'%x,H'%x\n", - data[0], data[1], - data[0], data[1]); - return 2; - found:; - { int i; - - for (i = 0; i < q->length; i++) { - fprintf(stream, "%02x ", data[i]); - } - for (; i < 6; i++) { - fprintf(stream, " "); - } - } - fprintf(stream, "%s\t",q->name); - /* Now print out the args */ - { - op_enum_type *args = q->args.nib; - int hadone = 0; - while (*args != E) { - if (hadone) - fprintf(stream, ","); - switch ((int)(*args) & ~((int)B30|(int)B31)) { - case IMM16: - case IMM8: - case IMM3: - fprintf(stream, "#H'%x", (unsigned)abs); break; - case RD8: - fprintf(stream, "%s", regnames[rd]); break; - case RS8: - fprintf(stream, "%s",regnames[rs]); break; - case RD16: - fprintf(stream, "r%d", rd& 0x7); break; - case RS16: - fprintf(stream, "r%d", rs & 0x7); break; - case RSINC: - fprintf(stream, "@r%d+", rs & 0x7); break; - case RDDEC: - fprintf(stream, "@-r%d", rd & 0x7); break; - case RDIND: - fprintf(stream, "@r%d", rd & 0x7); break; - case RSIND: - fprintf(stream, "@r%d",rs & 0x7); break; - case ABS8SRC: - case ABS16SRC: - case ABS16DST: - case ABS8DST: - fprintf(stream, "@H'%x", (unsigned)abs); break; - case DISP8: - fprintf(stream, ".%s%d (%x)",(char)abs>0 ? "+" :"", (char)abs, - addr + (char)abs); - break; - case DISPSRC: - case DISPDST: - fprintf(stream, "@(%d,r%d)", abs, rdisp & 0x7); break; - case CCR: - fprintf(stream, "ccr"); break; - case KBIT: - fprintf(stream, "#%d",abs); break; - default: - abort(); - } - hadone = 1; - args++; - } - } - return q->length; -} - - - -unsigned int DEFUN( print_insn_h8300,(addr, data, file), -bfd_vma addr AND -CONST bfd_byte *data AND -PTR file) -{ - static boolean init; - if (!init) { - bfd_h8_disassemble_init(); - init= 1; - - } - return bfd_h8_disassemble(addr, data, file); -} - -/* -Relocations for the H8 - -*/ -static bfd_reloc_status_enum_type -DEFUN(howto16_callback,(abfd, reloc_entry, symbol_in, data, ignore_input_section), -bfd *abfd AND -arelent *reloc_entry AND -asymbol *symbol_in AND -unsigned char *data AND -asection *ignore_input_section) -{ - long relocation = 0; - bfd_vma addr = reloc_entry->address; - long x = bfd_get_16(abfd, (bfd_byte *)data + addr); - - HOWTO_PREPARE(relocation, symbol_in); - - x = (x + relocation + reloc_entry->addend); - - bfd_put_16(abfd, x, (bfd_byte *)data + addr); - return bfd_reloc_ok; -} - - -static bfd_reloc_status_enum_type -DEFUN(howto8_callback,(abfd, reloc_entry, symbol_in, data, ignore_input_section), -bfd *abfd AND -arelent *reloc_entry AND -asymbol *symbol_in AND -unsigned char *data AND -asection *ignore_input_section) -{ - long relocation = 0; - bfd_vma addr = reloc_entry->address; - long x = bfd_get_8(abfd, (bfd_byte *)data + addr); - - HOWTO_PREPARE(relocation, symbol_in); - - x = (x + relocation + reloc_entry->addend); - - bfd_put_8(abfd, x, (bfd_byte *)data + addr); - return bfd_reloc_ok; -} - - -static bfd_reloc_status_enum_type -DEFUN(howto8_FFnn_callback,(abfd, reloc_entry, symbol_in, data, ignore_input_section), -bfd *abfd AND -arelent *reloc_entry AND -asymbol *symbol_in AND -unsigned char *data AND -asection *ignore_input_section) -{ - long relocation = 0; - bfd_vma addr = reloc_entry->address; - - long x = bfd_get_8(abfd, (bfd_byte *)data + addr); - abort(); - HOWTO_PREPARE(relocation, symbol_in); - - x = (x + relocation + reloc_entry->addend); - - bfd_put_8(abfd, x, (bfd_byte *)data + addr); - return bfd_reloc_ok; -} - -static bfd_reloc_status_enum_type -DEFUN(howto8_pcrel_callback,(abfd, reloc_entry, symbol_in, data, ignore_input_section), -bfd *abfd AND -arelent *reloc_entry AND -asymbol *symbol_in AND -unsigned char *data AND -asection *ignore_input_section) -{ - long relocation = 0; - bfd_vma addr = reloc_entry->address; - long x = bfd_get_8(abfd, (bfd_byte *)data + addr); - abort(); - HOWTO_PREPARE(relocation, symbol_in); - - x = (x + relocation + reloc_entry->addend); - - bfd_put_8(abfd, x, (bfd_byte *)data + addr); - return bfd_reloc_ok; -} - - -static reloc_howto_type howto_16 - = NEWHOWTO(howto16_callback,"abs16",1,0,0); -static reloc_howto_type howto_8 - = NEWHOWTO(howto8_callback,"abs8",0,0,0); - -static reloc_howto_type howto_8_FFnn - = NEWHOWTO(howto8_FFnn_callback,"ff00+abs8",0,0,0); - -static reloc_howto_type howto_8_pcrel - = NEWHOWTO(howto8_pcrel_callback,"pcrel8",0,1,1); - - - -static CONST struct reloc_howto_struct * -DEFUN(local_bfd_reloc_type_lookup,(arch, code), - bfd_arch_info_struct_type *arch AND - bfd_reloc_code_enum_type code) -{ - switch (code) { - case BFD_RELOC_16: - return &howto_16; - case BFD_RELOC_8_FFnn: - return &howto_8_FFnn; - case BFD_RELOC_8: - return &howto_8; - case BFD_RELOC_8_PCREL: - return &howto_8_pcrel; - } - return (reloc_howto_type *)NULL; -} - -int bfd_default_scan_num_mach(); - -static boolean -DEFUN(h8300_scan,(info, string), -CONST struct bfd_arch_info_struct *info AND -CONST char *string) -{ - if (strcmp(string,"h8300") == 0) return true; - if (strcmp(string,"H8300") == 0) return true; - if (strcmp(string,"h8/300") == 0) return true; - if (strcmp(string,"H8/300") == 0) return true; - return false; -} -static bfd_arch_info_struct_type arch_info_struct = - { - 16, /* 16 bits in a word */ - 16, /* 16 bits in an address */ - 8, /* 8 bits in a byte */ - bfd_arch_h8300, - 0, /* only 1 machine */ - "H8/300", /* arch_name */ - "H8/300", /* printable name */ - true, /* the default machine */ - bfd_default_compatible, - h8300_scan, - print_insn_h8300, - local_bfd_reloc_type_lookup, - 0, - }; - - - - -void DEFUN_VOID(bfd_h8300_arch) -{ - bfd_arch_linkin(&arch_info_struct); -} - - - diff --git a/bfd/cpu-i386.c b/bfd/cpu-i386.c deleted file mode 100644 index 2bafe58d8d9..00000000000 --- a/bfd/cpu-i386.c +++ /dev/null @@ -1,32 +0,0 @@ -#include -#include -#include "libbfd.h" - - - -static bfd_arch_info_struct_type arch_info_struct = - { - 32, /* 32 bits in a word */ - 32, /* 32 bits in an address */ - 8, /* 8 bits in a byte */ - bfd_arch_i386, - 0, /* only 1 machine */ - "i386", - "i386", - true, /* the one and only */ - bfd_default_compatible, - bfd_default_scan , - 0, - 0, - }; - - - - -void DEFUN_VOID(bfd_i386_arch) -{ - bfd_arch_linkin(&arch_info_struct); -} - - - diff --git a/bfd/cpu-i960.c b/bfd/cpu-i960.c deleted file mode 100644 index 5efa726ed21..00000000000 --- a/bfd/cpu-i960.c +++ /dev/null @@ -1,158 +0,0 @@ -/* BFD library support routines for the i960 architecture. - Copyright (C) 1990-1991 Free Software Foundation, Inc. - Hacked by Steve Chamberlain of Cygnus Support. - -This file is part of BFD, the Binary File Descriptor library. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - - -#include -#include "bfd.h" -#include "libbfd.h" - - -/* This routine is provided a string, and tries to work out if it - could possibly refer to the i960 machine pointed at in the - info_struct pointer */ - -static boolean -DEFUN(scan_960_mach, (ap, string), - CONST bfd_arch_info_struct_type *ap AND - CONST char *string) -{ - unsigned long machine; - - /* Look for the string i960, or somesuch at the front of the string */ - - if (strncmp("i960",string) == 0) { - string+=4; - } - else { - /* no match, can be us */ - return false; - } - if (string[0] == 0) { - /* i960 on it's own means core to us*/ - if (ap->mach == bfd_mach_i960_core) return true; - return false; - } - - if (string[0] != ':') { - return false; - } - string++; - if (string[0] == '\0') - return false; - if (string[0] == 'c' && string[1] == 'o' && string[2] == 'r' && - string[3] == 'e' && string[4] == '\0') - machine = bfd_mach_i960_core; - else if (string[1] == '\0' || string[2] != '\0') /* rest are 2-char */ - return false; - else if (string[0] == 'k' && string[1] == 'b') - machine = bfd_mach_i960_kb_sb; - else if (string[0] == 's' && string[1] == 'b') - machine = bfd_mach_i960_kb_sb; - else if (string[0] == 'm' && string[1] == 'c') - machine = bfd_mach_i960_mc; - else if (string[0] == 'x' && string[1] == 'a') - machine = bfd_mach_i960_xa; - else if (string[0] == 'c' && string[1] == 'a') - machine = bfd_mach_i960_ca; - else if (string[0] == 'k' && string[1] == 'a') - machine = bfd_mach_i960_ka_sa; - else if (string[0] == 's' && string[1] == 'a') - machine = bfd_mach_i960_ka_sa; - else - return false; - if (machine == ap->mach) return true; - return false; -} - - - -/* This routine is provided two arch_infos and works out the i960 - machine which would be compatible with both and returns a pointer - to its info structure */ - -CONST bfd_arch_info_struct_type * -DEFUN(compatible,(a,b), - CONST bfd_arch_info_struct_type *a AND - CONST bfd_arch_info_struct_type *b) -{ - - /* The i960 has two distinct subspecies which may not interbreed: - CORE CA - CORE KA KB MC XA - Any architecture on the same line is compatible, the one on - the right is the least restrictive. - - We represent this information in an array, each machine to a side */ - -#define ERROR 0 -#define CORE bfd_mach_i960_core /*1*/ -#define KA bfd_mach_i960_ka_sa /*2*/ -#define KB bfd_mach_i960_kb_sb /*3*/ -#define MC bfd_mach_i960_mc /*4*/ -#define XA bfd_mach_i960_xa /*5*/ -#define CA bfd_mach_i960_ca /*6*/ - - - static CONST char matrix[7][7] = - { - ERROR,CORE, KA, KB, MC, XA, CA, - CORE, CORE, KA, KB, MC, XA, CA, - KA, KA, KA, KB, MC, XA, ERROR, - KB, KB, KB, KB, MC, XA, ERROR, - MC, MC, MC, MC, MC, XA, ERROR, - XA, XA, XA, XA, XA, XA, ERROR, - CA, CA, ERROR, ERROR, ERROR, ERROR, CA - }; - - - if (a->arch != b->arch || matrix[a->mach][b->mach] == ERROR) - { - return (bfd_arch_info_struct_type *)NULL; - } - else - { - return (a->mach == matrix[a->mach][b->mach]) ? a : b; - } -} - - - -int bfd_default_scan_num_mach(); -#define N(a,b,d) \ -{ 32, 32, 8,bfd_arch_i960,a,"i960",b,d,compatible,scan_960_mach,0,} - -static bfd_arch_info_struct_type arch_info_struct[] = -{ - N(bfd_mach_i960_core,"i960:core",true), - N(bfd_mach_i960_ka_sa,"i960:ka_sa",false), - N(bfd_mach_i960_kb_sb,"i960:kb_sb",false), - N(bfd_mach_i960_mc,"i960:mc",false), - N(bfd_mach_i960_xa,"i960:xa",false), - N(bfd_mach_i960_ca,"i960:ca",false) - }; - - -void DEFUN_VOID(bfd_i960_arch) -{ - unsigned int i; - for (i = 0; i < 6; i++) { - bfd_arch_linkin(arch_info_struct + i); - } -} diff --git a/bfd/cpu-m88k.c b/bfd/cpu-m88k.c deleted file mode 100644 index a59637d086a..00000000000 --- a/bfd/cpu-m88k.c +++ /dev/null @@ -1,51 +0,0 @@ -/* bfd back-end for m88k support - Copyright (C) 1990-1991 Free Software Foundation, Inc. - Written by Steve Chamberlain of Cygnus Support. - -This file is part of BFD, the Binary File Descriptor library. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include -#include "libbfd.h" - - - -static bfd_arch_info_struct_type arch_info_struct = - { - 32, /* 32 bits in a word */ - 32, /* 32 bits in an address */ - 8, /* 8 bits in a byte */ - bfd_arch_m88k, - 88100, /* only 1 machine */ - "m88k", - "m88k:88100", - true, /* the one and only */ - bfd_default_compatible, - bfd_default_scan , - 0, - 0, - }; - - - -void DEFUN_VOID(bfd_m88k_arch) -{ - bfd_arch_linkin(&arch_info_struct); -} - - - diff --git a/bfd/cpu-rs6000.c b/bfd/cpu-rs6000.c deleted file mode 100644 index fe466a33ee1..00000000000 --- a/bfd/cpu-rs6000.c +++ /dev/null @@ -1,44 +0,0 @@ -/* BFD back-end for rs6000 support - Copyright (C) 1990-1991 Free Software Foundation, Inc. - Written by Mimi Phûông-ThÃ¥o Võ of IBM and John Gilmore of Cygnus Support. - -This file is part of BFD, the Binary File Descriptor library. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include "bfd.h" -#include "sysdep.h" -#include "libbfd.h" - -static bfd_arch_info_type arch_info_struct = - { - 32, /* 32 bits in a word */ - 32, /* 32 bits in an address */ - 8, /* 8 bits in a byte */ - bfd_arch_rs6000, - 6000, /* only 1 machine */ - "rs6000", - "rs6000:6000", - true, /* the one and only */ - bfd_default_compatible, - bfd_default_scan , - 0, - 0, - }; - -void DEFUN_VOID(bfd_rs6000_arch) -{ - bfd_arch_linkin(&arch_info_struct); -} diff --git a/bfd/cpu-vax.c b/bfd/cpu-vax.c deleted file mode 100644 index 4d5af2348c3..00000000000 --- a/bfd/cpu-vax.c +++ /dev/null @@ -1,52 +0,0 @@ -/* bfd back-end for vax support - Copyright (C) 1990-1991 Free Software Foundation, Inc. - Written by Steve Chamberlain of Cygnus Support. - -This file is part of BFD, the Binary File Descriptor library. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include -#include "libbfd.h" - - - -static bfd_arch_info_struct_type arch_info_struct = - { - 32, /* 32 bits in a word */ - 32, /* 32 bits in an address */ - 8, /* 8 bits in a byte */ - bfd_arch_vax, - 0, /* only 1 machine */ - "vax", - "vax", - true, /* the one and only */ - bfd_default_compatible, - bfd_default_scan , - 0, - 0, - }; - - - - -void DEFUN_VOID(bfd_vax_arch) -{ - bfd_arch_linkin(&arch_info_struct); -} - - - diff --git a/bfd/ctor.c b/bfd/ctor.c deleted file mode 100644 index 6d202691ebf..00000000000 --- a/bfd/ctor.c +++ /dev/null @@ -1,144 +0,0 @@ -/* BFD library support routines for constructors - Copyright (C) 1990-1991 Free Software Foundation, Inc. - - Hacked by Steve Chamberlain of Cygnus Support. With some help from - Judy Chamberlain too. - - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/*doc* -@section Constructors -Classes in C++ have 'constructors' and 'destructors'. These are -functions which are called automatically by the language whenever data -of a class is created or destroyed. Class data which is static data -may also be have a type which requires 'construction', the contructor -must be called before the data can be referenced, so the contructor -must be called before the program begins. - -The common solution to this problem is for the compiler to call a -magic function as the first statement @code{main}. This magic -function, (often called @code{__main}) runs around calling the -constructors for all the things needing it. - -With COFF the compile has a bargain with the linker et al. All -constructors are given strange names, for example -@code{__GLOBAL__$I$foo} might be the label of a contructor for the -class @var{foo}. The solution on unfortunate systems (most system V -machines) is to perform a partial link on all the .o files, do an -@code{nm} on the result, run @code{awk} or some such over the result -looking for strange @code{__GLOBAL__$} symbols, generate a C program -from this, compile it and link with the partially linked input. This -process is usually called @code{collect}. - -Some versions of @code{a.out} use something called the -@code{set_vector} mechanism. The constructor symbols are output from -the compiler with a special stab code saying that they are -constructors, and the linker can deal with them directly. - -BFD allows applications (ie the linker) to deal with constructor -information independently of their external implimentation by -providing a set of entry points for the indiviual object back ends to -call which maintains a database of the contructor information. The -application can interrogate the database to find out what it wants. - -The construction data essential for the linker to be able to perform -its job are: - -@itemize @bullet -@item asymbol -The asymbol of the contructor entry point contains all the information -necessary to call the function. -@item table id -The type of symbol, ie is it a contructor, a destructor or something -else someone dreamed up to make our lives difficult. -@end itemize - -This module takes this information and then builds extra sections -attached to the bfds which own the entry points. It creates these -sections as if they were tables of pointers to the entry points, and -builds relocation entries to go with them so that the tables can be -relocated along with the data they reference. - -These sections are marked with a special bit (@code{SEC_CONSTRUCTOR}) -which the linker notices and do with what it wants. - - -*/ - -#include -#include -#include - - - -/*proto-internal* bfd_constructor_entry - -This function is called with an a symbol describing the -function to be called, an string which descibes the xtor type, eg -something like "CTOR" or "DTOR" would be fine. And the bfd which owns -the function. - -It's duty is to create a section called "CTOR" or "DTOR" or whatever -if the bfd doesn't already have one, and grow a relocation table for -the entry points as they accumulate. - - -*; PROTO(void, bfd_constructor_entry, - (bfd *abfd, - asymbol **symbol_ptr_ptr, - CONST char*type)); - -*/ - - -void DEFUN(bfd_constructor_entry,(abfd, symbol_ptr_ptr, type), - bfd *abfd AND - asymbol **symbol_ptr_ptr AND - CONST char *type) - -{ - /* Look up the section we're using to store the table in */ - asection *rel_section = bfd_get_section_by_name (abfd, type); - if (rel_section == (asection *)NULL) { - rel_section = bfd_make_section (abfd, type); - rel_section->flags = SEC_CONSTRUCTOR; - rel_section->alignment_power = 2; - } - - /* Create a relocation into the section which references the entry - point */ - { - arelent_chain *reloc = (arelent_chain *)bfd_alloc(abfd, - sizeof(arelent_chain)); - - reloc->relent.section = (asection *)NULL; - reloc->relent.addend = 0; - - reloc->relent.sym_ptr_ptr = symbol_ptr_ptr; - reloc->next = rel_section->constructor_chain; - rel_section->constructor_chain = reloc; - reloc->relent.address = rel_section->size; - /* ask the cpu which howto to use */ - reloc->relent.howto = - bfd_reloc_type_lookup(abfd->arch_info, - BFD_RELOC_CTOR); - rel_section->size += sizeof(int *); - rel_section->reloc_count++; - } - -} diff --git a/bfd/demo64.c b/bfd/demo64.c deleted file mode 100644 index cb1e4e2a6aa..00000000000 --- a/bfd/demo64.c +++ /dev/null @@ -1,30 +0,0 @@ -/* BFD backend for sunos binaries */ - -/* Copyright (C) 1990, 1991 Free Software Foundation, Inc. - -This file is part of BFD, the Binary File Diddler. - -BFD 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 1, or (at your option) -any later version. - -BFD 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 BFD; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* $Id$ */ - -/* Can only compile this if TARGET_64_BIT is set */ -#ifdef TARGET_64_BIT -#define ARCH_SIZE 64 -#define TARGETNAME "demo64" -#define VECNAME "demo_64_vec" -#include "aoutf1.h" - -#endif diff --git a/bfd/doc/.Sanitize b/bfd/doc/.Sanitize deleted file mode 100644 index cce16acd27d..00000000000 --- a/bfd/doc/.Sanitize +++ /dev/null @@ -1,64 +0,0 @@ -# Sanitize.in for bfd/doc. - -# Each directory to survive it's way into a release will need a file -# like this one called "./.Sanitize". All keyword lines must exist, -# and must exist in the order specified by this file. Each directory -# in the tree will be processed, top down, in the following order. - -# Hash started lines like this one are comments and will be deleted -# before anything else is done. Blank lines will also be squashed -# out. - -# The lines between the "Do-first:" line and the "Things-to-keep:" -# line are executed as a /bin/sh shell script before anything else is -# done in this - -Do-first: - -echo Sanitizing `pwd`. - -# All files listed between the "Things-to-keep:" line and the -# "Files-to-sed:" line will be kept. All other files will be removed. -# Directories listed in this section will have their own Sanitize -# called. Directories not listed will be removed in their entirety -# with rm -rf. - -Things-to-keep: -Makefile.in -configure.in -awkscan -awkscan-ip -awkscan-p -bfd.texinfo -blins-p -exfil1-p -exfil3-p -exfilter -exfilter-p -exfiltst -exmerge -intobfd -mergecom-p -movecom-p -scanit -scanph -sedscript -sedscript-p -startcom-p -tolibbfd -tolibcoff -unPROTO - -Do-last: - -echo Done in `pwd`. - -# $Log$ -# Revision 1.2 1991/11/15 03:29:15 bothner -# Add Makefile.in, configure.in. Remove Makefile. -# -# Revision 1.1 1991/08/23 09:06:52 gnu -# Initial revision -# - -# End of file. diff --git a/bfd/doc/Makefile b/bfd/doc/Makefile deleted file mode 100755 index 2ac5d438d46..00000000000 --- a/bfd/doc/Makefile +++ /dev/null @@ -1,82 +0,0 @@ -.SUFFIXES: .texi .o .c .h .p .ip -VPATH=.. -.c.texi: - ./scanit $< $@ - -.h.texi: - ./scanit $< $@ - -.c.p: - ./scanph $< $@ - -.h.p: - ./scanph $< $@ - -.c.ip: - ./scanph -i $< $@ - -# main GDB source directory -srcdir = .. - -TEXIDIR=${srcdir}/../texinfo/fsf - -DOCFILES = aoutx.texi archive.texi archures.texi \ - bfd.texi cache.texi coffcode.texi \ - core.texi format.texi libbfd.texi \ - opncls.texi reloc.texi section.texi \ - syms.texi targets.texi init.texi ctor.texi - - -PROTOS = archive.p archures.p bfd.p \ - coffcode.p core.p format.p \ - libbfd.p opncls.p reloc.p \ - section.p syms.p targets.p \ - format.p coffcode.p core.p machines.p init.p - -IPROTOS = cache.ip libbfd.ip reloc.ip init.ip archures.ip ctor.ip - -# SRCDOC, SRCPROT, SRCIPROT only used to sidestep Sun Make bug in interaction -# between VPATH and suffix rules. If you use GNU Make, perhaps other Makes, -# you don't need these three: -SRCDOC = aoutx.h archive.c archures.c \ - bfd.c cache.c coffcode.h \ - core.c format.c libbfd.c \ - opncls.c reloc.c section.c \ - syms.c targets.c init.c - -SRCPROT = archive.c archures.c bfd.c \ - coffcode.h core.c format.c \ - libbfd.c opncls.c reloc.c \ - section.c syms.c targets.c init.c - -SRCIPROT = cache.c libbfd.c reloc.c cpu-h8300.c cpu-i960.c archures.c init.c ctor.c - - -docs: protos bfd.info bfd.dvi bfd.ps - -protos: $(PROTOS) $(IPROTOS) - sed -f intobfd bfd-in.h > bfd.h - sed -f tolibbfd libbfd-in.h > libbfd.h - sed -f tolibcoff libcoff-in.h > libcoff.h - -# Following three rules only for the benefit of Sun Make; see comment above -$(DOCFILES) : $(SRCDOC) -$(PROTOS) : $(SRCPROT) -$(IPROTOS) : $(SRCIPROT) - -clean: - rm -f $(PROTOS) *.p *.ip *.h bfd.?? $(DOCFILES) bfd.dvi bfd.ps *~* *# bfd.??? - -bfd.info: $(DOCFILES) bfd.texinfo - makeinfo bfd.texinfo - -bfd.dvi: $(DOCFILES) bfd.texinfo - TEXINPUTS=${TEXIDIR}:.:$$TEXINPUTS tex bfd.texinfo - texindex bfd.?? - TEXINPUTS=${TEXIDIR}:.:$$TEXINPUTS tex bfd.texinfo - -bfd.ps: bfd.dvi - dvips bfd -o - -quickdoc: $(DOCFILES) bfd.texinfo - TEXINPUTS=${TEXIDIR}:.:$$TEXINPUTS tex bfd.texinfo diff --git a/bfd/doc/Makefile.in b/bfd/doc/Makefile.in deleted file mode 100644 index 060698531d4..00000000000 --- a/bfd/doc/Makefile.in +++ /dev/null @@ -1,227 +0,0 @@ -srcdir = . - -ddestdir = /usr/local -idestdir = $(ddestdir) - -SHELL = /bin/sh - -MAKEINFO = makeinfo - -# main GDB source directory - -DOCFILES = aoutx.texi archive.texi archures.texi \ - bfd.texi cache.texi coffcode.texi \ - core.texi format.texi libbfd.texi \ - opncls.texi reloc.texi section.texi \ - syms.texi targets.texi init.texi ctor.texi - -PROTOS = archive.p archures.p bfd.p \ - coffcode.p core.p format.p \ - libbfd.p opncls.p reloc.p \ - section.p syms.p targets.p \ - format.p coffcode.p core.p init.p - -IPROTOS = cache.ip libbfd.ip reloc.ip init.ip archures.ip ctor.ip - -# SRCDOC, SRCPROT, SRCIPROT only used to sidestep Sun Make bug in interaction -# between VPATH and suffix rules. If you use GNU Make, perhaps other Makes, -# you don't need these three: -SRCDOC = $(srcdir)/../aoutx.h $(srcdir)/../archive.c \ - $(srcdir)/../archures.c $(srcdir)/../bfd.c \ - $(srcdir)/../cache.c $(srcdir)/../coffcode.h \ - $(srcdir)/../core.c $(srcdir)/../format.c \ - $(srcdir)/../libbfd.c $(srcdir)/../opncls.c \ - $(srcdir)/../reloc.c $(srcdir)/../section.c \ - $(srcdir)/../syms.c $(srcdir)/../targets.c \ - $(srcdir)/../init.c - -SRCPROT = $(srcdir)/../archive.c $(srcdir)/../archures.c \ - $(srcdir)/../bfd.c $(srcdir)/../coffcode.h $(srcdir)/../core.c \ - $(srcdir)/../format.c $(srcdir)/../libbfd.c \ - $(srcdir)/../opncls.c $(srcdir)/../reloc.c \ - $(srcdir)/../section.c $(srcdir)/../syms.c \ - $(srcdir)/../targets.c $(srcdir)/../init.c - -SRCIPROT = $(srcdir)/../cache.c $(srcdir)/../libbfd.c \ - $(srcdir)/../reloc.c $(srcdir)/../cpu-h8300.c \ - $(srcdir)/../cpu-i960.c $(srcdir)/../archures.c \ - $(srcdir)/../init.c $(srcdir)/../ctor.c - -STAGESTUFF = $(PROTOS) *.p *.ip *.h bfd.?? $(DOCFILES) - -all install: - -all-info: bfd.info - -install-info: all-info - for i in *.info* ; do \ - echo Installing $$i... ; \ - (cp $$i $(idestdir)/info/$$i.new \ - && mv -f $(idestdir)/info/$$i.new $(idestdir)/info/$$i) \ - || exit 1 ; \ - done - -docs: protos bfd.info bfd.dvi bfd.ps - -protos: $(PROTOS) $(IPROTOS) - sed -f intobfd $(srcdir)/../bfd-in.h > bfd.h - sed -f tolibbfd $(srcdir)/../libbfd-in.h > libbfd.h - sed -f tolibcoff $(srcdir)/../libcoff-in.h > libcoff.h - -aoutx.texi: $(srcdir)/scanit $(srcdir)/../aoutx.h - $(srcdir)/scanit $(srcdir)/../aoutx.h aoutx.texi $(srcdir) - -archive.texi: $(srcdir)/scanit $(srcdir)/../archive.c - $(srcdir)/scanit $(srcdir)/../archive.c archive.texi $(srcdir) - -archures.texi: $(srcdir)/scanit $(srcdir)/../archures.c - $(srcdir)/scanit $(srcdir)/../archures.c archures.texi $(srcdir) - -bfd.texi: $(srcdir)/scanit $(srcdir)/../bfd.c - $(srcdir)/scanit $(srcdir)/../bfd.c bfd.texi $(srcdir) - -cache.texi: $(srcdir)/scanit $(srcdir)/../cache.c - $(srcdir)/scanit $(srcdir)/../cache.c cache.texi $(srcdir) - -coffcode.texi: $(srcdir)/scanit $(srcdir)/../coffcode.h - $(srcdir)/scanit $(srcdir)/../coffcode.h coffcode.texi $(srcdir) - -core.texi: $(srcdir)/scanit $(srcdir)/../core.c - $(srcdir)/scanit $(srcdir)/../core.c core.texi $(srcdir) - -format.texi: $(srcdir)/scanit $(srcdir)/../format.c - $(srcdir)/scanit $(srcdir)/../format.c format.texi $(srcdir) - -libbfd.texi: $(srcdir)/scanit $(srcdir)/../libbfd.c - $(srcdir)/scanit $(srcdir)/../libbfd.c libbfd.texi $(srcdir) - -opncls.texi: $(srcdir)/scanit $(srcdir)/../opncls.c - $(srcdir)/scanit $(srcdir)/../opncls.c opncls.texi $(srcdir) - -reloc.texi : $(srcdir)/scanit $(srcdir)/../reloc.c - $(srcdir)/scanit $(srcdir)/../reloc.c reloc.texi $(srcdir) - -section.texi: $(srcdir)/scanit $(srcdir)/../section.c - $(srcdir)/scanit $(srcdir)/../section.c section.texi $(srcdir) - -syms.texi : $(srcdir)/scanit $(srcdir)/../syms.c - $(srcdir)/scanit $(srcdir)/../syms.c syms.texi $(srcdir) - -targets.texi: $(srcdir)/scanit $(srcdir)/../targets.c - $(srcdir)/scanit $(srcdir)/../targets.c targets.texi $(srcdir) - -init.texi: $(srcdir)/scanit $(srcdir)/../init.c - $(srcdir)/scanit $(srcdir)/../init.c init.texi $(srcdir) - -ctor.texi: $(srcdir)/scanit $(srcdir)/../ctor.c - $(srcdir)/scanit $(srcdir)/../ctor.c ctor.texi $(srcdir) - -archive.p: $(srcdir)/scanph $(srcdir)/../archive.c - $(srcdir)/scanph $(srcdir)/../archive.c archive $(srcdir) - -archures.p: $(srcdir)/scanph $(srcdir)/../archures.c - $(srcdir)/scanph $(srcdir)/../archures.c archures $(srcdir) - -bfd.p: $(srcdir)/scanph $(srcdir)/../bfd.c - $(srcdir)/scanph $(srcdir)/../bfd.c bfd $(srcdir) - -coffcode.p: $(srcdir)/scanph $(srcdir)/../coffcode.h - $(srcdir)/scanph $(srcdir)/../coffcode.h coffcode $(srcdir) - -core.p: $(srcdir)/scanph $(srcdir)/../core.c - $(srcdir)/scanph $(srcdir)/../core.c core $(srcdir) - -format.p: $(srcdir)/scanph $(srcdir)/../format.c - $(srcdir)/scanph $(srcdir)/../format.c format $(srcdir) - -libbfd.p: $(srcdir)/scanph $(srcdir)/../libbfd.c - $(srcdir)/scanph $(srcdir)/../libbfd.c libbfd $(srcdir) - -opncls.p: $(srcdir)/scanph $(srcdir)/../opncls.c - $(srcdir)/scanph $(srcdir)/../opncls.c opncls $(srcdir) - -reloc.p: $(srcdir)/scanph $(srcdir)/../reloc.c - $(srcdir)/scanph $(srcdir)/../reloc.c reloc $(srcdir) - -section.p: $(srcdir)/scanph $(srcdir)/../section.c - $(srcdir)/scanph $(srcdir)/../section.c section $(srcdir) - -syms.p: $(srcdir)/scanph $(srcdir)/../syms.c - $(srcdir)/scanph $(srcdir)/../syms.c syms $(srcdir) - -targets.p: $(srcdir)/scanph $(srcdir)/../targets.c - $(srcdir)/scanph $(srcdir)/../targets.c targets $(srcdir) - -init.p: $(srcdir)/scanph $(srcdir)/../init.c - $(srcdir)/scanph $(srcdir)/../init.c init $(srcdir) - -cache.ip: $(srcdir)/scanph $(srcdir)/../cache.c - $(srcdir)/scanph -i $(srcdir)/../cache.c cache $(srcdir) - -libbfd.ip: $(srcdir)/scanph $(srcdir)/../libbfd.c - $(srcdir)/scanph -i $(srcdir)/../libbfd.c libbfd $(srcdir) - -reloc.ip: $(srcdir)/scanph $(srcdir)/../reloc.c - $(srcdir)/scanph -i $(srcdir)/../reloc.c reloc $(srcdir) - -init.ip: $(srcdir)/scanph $(srcdir)/../init.c - $(srcdir)/scanph -i $(srcdir)/../init.c init $(srcdir) - -archures.ip: $(srcdir)/scanph $(srcdir)/../archures.c - $(srcdir)/scanph -i $(srcdir)/../archures.c archures $(srcdir) - -ctor.ip: $(srcdir)/scanph $(srcdir)/../ctor.c - $(srcdir)/scanph -i $(srcdir)/../ctor.c ctor $(srcdir) - - -clean: - rm -f $(STAGESTUFF) bfd.dvi bfd.ps *~* *# bfd.??? - -bfd.info: $(DOCFILES) bfd.texinfo - $(MAKEINFO) -o bfd.info $(srcdir)/bfd.texinfo - -bfd.dvi: $(DOCFILES) bfd.texinfo - TEXINPUTS=${TEXIDIR}:.:$$TEXINPUTS tex bfd.texinfo - texindex bfd.?? - TEXINPUTS=${TEXIDIR}:.:$$TEXINPUTS tex bfd.texinfo - -bfd.ps: bfd.dvi - dvips bfd -o - -quickdoc: $(DOCFILES) bfd.texinfo - TEXINPUTS=${TEXIDIR}:.:$$TEXINPUTS tex bfd.texinfo - -stage1: force - - mkdir stage1 - - mv -f $(STAGESTUFF) stage1 - -stage2: force - - mkdir stage2 - - mv -f $(STAGESTUFF) stage2 - -stage3: force - - mkdir stage3 - - mv -f $(STAGESTUFF) stage3 - -against=stage2 - -comparison: force - for i in *.o ; do cmp $$i $(against)/$$i || exit 1 ; done - -de-stage1: force - - (cd stage1 ; mv -f $(STAGESTUFF) ..) - - rmdir stage1 - -de-stage2: force - - (cd stage2 ; mv -f $(STAGESTUFF) ..) - - rmdir stage2 - -de-stage3: force - - (cd stage3 ; mv -f $(STAGESTUFF) ..) - - rmdir stage3 - -force: - -Makefile: $(srcdir)/Makefile.in $(host_makefile_frag) $(target_makefile_frag) - $(SHELL) ./config.status - diff --git a/bfd/doc/awkscan b/bfd/doc/awkscan deleted file mode 100755 index 69b0ceaa3ba..00000000000 --- a/bfd/doc/awkscan +++ /dev/null @@ -1,12 +0,0 @@ -# NOTE: BEGIN pattern gives errors if other than 1st line; -# END ditto if other than last. -BEGIN { print "@c ------------------------------START TEXT FROM " FILENAME } -# -# Keep /*doc* blocks (terminated by either */ or *-*/) -/^\/\*doc\*/,/^\*\/|^\*-\*\// -# -# Also keep two kinds of /*proto blocks -/^\/\*proto\*/,/^\*\/|^\*-\*\// -/^\/\*proto-internal\*/,/^\*\/|^\*-\*\// -# -END { print "@c ------------------------------END TEXT FROM " FILENAME } diff --git a/bfd/doc/awkscan-ip b/bfd/doc/awkscan-ip deleted file mode 100755 index 73bd61fa95f..00000000000 --- a/bfd/doc/awkscan-ip +++ /dev/null @@ -1,8 +0,0 @@ -# Awk filter, 1st filter for BFD internal prototype file extraction -# -# keep /*proto-internal blocks -/^\/\*proto-internal\*/,/^\*\/|^\*-\*\// -# -# Apparent bug in sed can discard last line in some situations; therefore -# make last line harmless. -END { print "\n" } diff --git a/bfd/doc/awkscan-p b/bfd/doc/awkscan-p deleted file mode 100755 index c7fe79fb342..00000000000 --- a/bfd/doc/awkscan-p +++ /dev/null @@ -1,8 +0,0 @@ -# Awk filter, 1st filter for BFD prototype file extraction -# -# keep /*proto blocks -/^\/\*proto\*/,/^\*\/|^\*-\*\// -# -# Apparent bug in sed can discard last line in some situations; therefore -# make last line harmless. -END { print "\n" } diff --git a/bfd/doc/bfd.info b/bfd/doc/bfd.info deleted file mode 100644 index 529d69d3226..00000000000 --- a/bfd/doc/bfd.info +++ /dev/null @@ -1,67 +0,0 @@ -Info file bfd.info, produced by Makeinfo, -*- Text -*- from input file -bfd.texinfo. - - This file documents the BFD library. - - Copyright (C) 1991 Free Software Foundation, Inc. - - Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. - - Permission is granted to copy and distribute modified versions of -this manual under the conditions for verbatim copying, subject to the -terms of the GNU General Public License, which includes the provision -that the entire resulting derived work is distributed under the terms -of a permission notice identical to this one. - - Permission is granted to copy and distribute translations of this -manual into another language, under the above conditions for modified -versions. - -Indirect: -bfd.info-1: 821 -bfd.info-2: 44533 -bfd.info-3: 89652 - -Tag Table: -(Indirect) -Node: Top823 -Node: Overview1086 -Node: History1985 -Node: How It Works2937 -Node: What BFD Version 1 Can Do4363 -Node: BFD information loss5388 -Node: Mechanism8002 -Node: BFD front end12332 -Node: Memory Usage17576 -Node: Initialization18818 -Node: Sections19432 -Node: Section Input19910 -Node: Section Output21190 -Node: typedef asection22559 -Node: section prototypes27347 -Node: Symbols30865 -Node: Reading Symbols32454 -Node: Writing Symbols33410 -Node: typedef asymbol34939 -Node: symbol handling functions38386 -Node: Archives40232 -Node: Formats41678 -Node: Relocations43795 -Node: typedef arelent44535 -Node: howto manager56584 -Node: Core Files57569 -Node: Targets58466 -Node: bfd_target60218 -Node: Architectures68923 -Node: Opening and Closing76770 -Node: Internal78654 -Node: File Caching81129 -Node: BFD back end83617 -Node: What to Put Where83810 -Node: aout83946 -Node: coff89654 -Node: Index100603 - -End Tag Table diff --git a/bfd/doc/bfd.texinfo b/bfd/doc/bfd.texinfo deleted file mode 100644 index 6a4699b0e93..00000000000 --- a/bfd/doc/bfd.texinfo +++ /dev/null @@ -1,446 +0,0 @@ -\input texinfo -@setfilename bfd.info -@c $Id$ -@synindex fn cp -@ifinfo -This file documents the BFD library. - -Copyright (C) 1991 Free Software Foundation, Inc. - -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. - -@ignore -Permission is granted to process this file through Tex and print the -results, provided the printed document carries copying permission -notice identical to this one except for the removal of this paragraph -(this paragraph not being relevant to the printed manual). - -@end ignore -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, subject to the terms -of the GNU General Public License, which includes the provision that the -entire resulting derived work is distributed under the terms of a -permission notice identical to this one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions. -@end ifinfo -@iftex -@c@finalout -@setchapternewpage on -@c@setchapternewpage odd -@settitle LIB BFD, the Binary File Descriptor Library -@titlepage -@title{libbfd} -@subtitle{The Binary File Descriptor Library} -@sp 1 -@subtitle First Edition---BFD version < 2.0 -@subtitle April 1991 -@author {Steve Chamberlain} -@author {Cygnus Support} -@page - -@tex -\def\$#1${{#1}} % Kluge: collect RCS revision info without $...$ -\xdef\manvers{\$Revision$} % For use in headers, footers too -{\parskip=0pt -\hfill Cygnus Support\par -\hfill steve\@cygnus.com\par -\hfill {\it BFD}, \manvers\par -\hfill \TeX{}info \texinfoversion\par -} -\global\parindent=0pt % Steve likes it this way -@end tex - -@vskip 0pt plus 1filll -Copyright @copyright{} 1991 Free Software Foundation, Inc. - -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. - -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, subject to the terms -of the GNU General Public License, which includes the provision that the -entire resulting derived work is distributed under the terms of a -permission notice identical to this one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions. -@end titlepage -@end iftex - -@node Top, Overview, (dir), (dir) -@ifinfo -This file documents the binary file descriptor library libbfd. -@end ifinfo - -@menu -* Overview:: Overview of BFD -* BFD front end:: BFD front end -* BFD back end:: BFD back end -* Index:: Index -@end menu - -@node Overview, BFD front end, Top, Top -@chapter Introduction -@cindex BFD -@cindex what is it? -Simply put, BFD is a package which allows applications to use the -same routines to operate on object files whatever the object file -format. A different object file format can be supported simply by -creating a new BFD back end and adding it to the library. - -BFD is split into two parts; the front end and the many back ends. -@itemize @bullet -@item The front end of BFD provides the interface to the user. It manages -memory, and various canonical data structures. The front end also -decides which back end to use, and when to call back end routines. -@item The back ends provide BFD its view of the real world. Each back -end provides a set of calls which the BFD front end can use to maintain -its canonical form. The back ends also may keep around information for -their own use, for greater efficiency. -@end itemize -@menu -* History:: History -* How It Works:: How It Works -* What BFD Version 1 Can Do:: What BFD Version 1 Can Do -@end menu - -@node History, How It Works, Overview, Overview -@section History - -One spur behind BFD was the desire, on the part of the GNU 960 team at -Intel Oregon, for interoperability of applications on their COFF and -b.out file formats. Cygnus was providing GNU support for the team, and -Cygnus was contracted to provide the required functionality. - -The name came from a conversation David Wallace was having with Richard -Stallman about the library: RMS said that it would be quite hard---David -said ``BFD''. Stallman was right, but the name stuck. - -At the same time, Ready Systems wanted much the same thing, but for -different object file formats: IEEE-695, Oasys, Srecords, a.out and 68k -coff. - -BFD was first implemented by Steve Chamberlain (steve@@cygnus.com), -John Gilmore (gnu@@cygnus.com), K. Richard Pixley (rich@@cygnus.com) and -David Wallace (gumby@@cygnus.com) at Cygnus Support in Palo Alto, -California. - -@node How It Works, What BFD Version 1 Can Do, History, Overview -@section How It Works - -To use the library, include @code{bfd.h} and link with @code{libbfd.a}. - -BFD provides a common interface to the parts of an object file -for a calling application. - -When an application sucessfully opens a target file (object, archive or -whatever) a pointer to an internal structure is returned. This pointer -points to a structure called @code{bfd}, described in -@code{include/bfd.h}. Our convention is to call this pointer a BFD, and -instances of it within code @code{abfd}. All operations on -the target object file are applied as methods to the BFD. The mapping is -defined within @code{bfd.h} in a set of macros, all beginning -@samp{bfd}_. - -For example, this sequence would do what you would probably expect: -return the number of sections in an object file attached to a BFD -@code{abfd}. - -@lisp -@c @cartouche -#include "bfd.h" - -unsigned int number_of_sections(abfd) -bfd *abfd; -@{ - return bfd_count_sections(abfd); -@} -@c @end cartouche -@end lisp - -The abstraction used within BFD is that an object file has a header, -a number of sections containing raw data, a set of relocations, and some -symbol information. Also, BFDs opened for archives have the -additional attribute of an index and contain subordinate BFDs. This approach is -fine for a.out and coff, but loses efficiency when applied to formats -such as S-records and IEEE-695. - -@node What BFD Version 1 Can Do, , How It Works, Overview -@section What BFD Version 1 Can Do -As different information from the the object files is required, -BFD reads from different sections of the file and processes them. -For example a very common operation for the linker is processing symbol -tables. Each BFD back end provides a routine for converting -between the object file's representation of symbols and an internal -canonical format. When the linker asks for the symbol table of an object -file, it calls through the memory pointer to the relevant BFD -back end routine which reads and converts the table into a canonical -form. The linker then operates upon the canonical form. When the link is -finished and the linker writes the output file's symbol table, -another BFD back end routine is called which takes the newly -created symbol table and converts it into the chosen output format. - -@menu -* BFD information loss:: Information Loss -* Mechanism:: Mechanism -@end menu - -@node BFD information loss, Mechanism, What BFD Version 1 Can Do, What BFD Version 1 Can Do -@subsection Information Loss -@emph{Some information is lost due to the nature of the file format.} The output targets -supported by BFD do not provide identical facilities, and -information which may be described in one form has nowhere to go in -another format. One example of this is alignment information in -@code{b.out}. There is nowhere in an @code{a.out} format file to store -alignment information on the contained data, so when a file is linked -from @code{b.out} and an @code{a.out} image is produced, alignment -information will not propagate to the output file. (The linker will -still use the alignment information internally, so the link is performed -correctly). - -Another example is COFF section names. COFF files may contain an -unlimited number of sections, each one with a textual section name. If -the target of the link is a format which does not have many sections (eg -@code{a.out}) or has sections without names (eg the Oasys format) the -link cannot be done simply. You can circumvent this problem by -describing the desired input-to-output section mapping with the linker command -language. - -@emph{Information can be lost during canonicalization.} The BFD -internal canonical form of the external formats is not exhaustive; there -are structures in input formats for which there is no direct -representation internally. This means that the BFD back ends -cannot maintain all possible data richness through the transformation -between external to internal and back to external formats. - -This limitation is only a problem when an application reads one -format and writes another. Each BFD back end is responsible for -maintaining as much data as possible, and the internal BFD -canonical form has structures which are opaque to the BFD core, -and exported only to the back ends. When a file is read in one format, -the canonical form is generated for BFD and the application. At the -same time, the back end saves away any information which may otherwise -be lost. If the data is then written back in the same format, the back -end routine will be able to use the canonical form provided by the -BFD core as well as the information it prepared earlier. Since -there is a great deal of commonality between back ends, this mechanism -is very useful. There is no information lost for this reason when -linking or copying big endian COFF to little endian COFF, or @code{a.out} to -@code{b.out}. When a mixture of formats is linked, the information is -only lost from the files whose format differs from the destination. - -@node Mechanism, , BFD information loss, What BFD Version 1 Can Do -@subsection Mechanism -The greatest potential for loss of information is when there is least -overlap between the information provided by the source format, that -stored by the canonical format, and the information needed by the -destination format. A brief description of the canonical form may help -you appreciate what kinds of data you can count on preserving across -conversions. -@cindex BFD canonical format -@cindex internal object-file format - -@table @emph -@item files -Information on target machine architecture, particular implementation -and format type are stored on a per-file basis. Other information -includes a demand pageable bit and a write protected bit. Note that -information like Unix magic numbers is not stored here---only the magic -numbers' meaning, so a @code{ZMAGIC} file would have both the demand -pageable bit and the write protected text bit set. The byte order of -the target is stored on a per-file basis, so that big- and little-endian -object files may be linked with one another. -@c FIXME: generalize above from "link"? - -@item sections -Each section in the input file contains the name of the section, the -original address in the object file, various flags, size and alignment -information and pointers into other BFD data structures. - -@item symbols -Each symbol contains a pointer to the object file which originally -defined it, its name, its value, and various flag bits. When a -BFD back end reads in a symbol table, the back end relocates all -symbols to make them relative to the base of the section where they were -defined. This ensures that each symbol points to its containing -section. Each symbol also has a varying amount of hidden data to contain -private data for the BFD back end. Since the symbol points to the -original file, the private data format for that symbol is accessible. -@code{gld} can operate on a collection of symbols of wildly different -formats without problems. - -Normal global and simple local symbols are maintained on output, so an -output file (no matter its format) will retain symbols pointing to -functions and to global, static, and common variables. Some symbol -information is not worth retaining; in @code{a.out} type information is -stored in the symbol table as long symbol names. This information would -be useless to most COFF debuggers; the linker has command line switches -to allow users to throw it away. - -There is one word of type information within the symbol, so if the -format supports symbol type information within symbols (for example COFF, -IEEE, Oasys) and the type is simple enough to fit within one word -(nearly everything but aggregates) the information will be preserved. - -@item relocation level -Each canonical BFD relocation record contains a pointer to the symbol to -relocate to, the offset of the data to relocate, the section the data -is in and a pointer to a relocation type descriptor. Relocation is -performed effectively by message passing through the relocation type -descriptor and symbol pointer. It allows relocations to be performed -on output data using a relocation method only available in one of the -input formats. For instance, Oasys provides a byte relocation format. -A relocation record requesting this relocation type would point -indirectly to a routine to perform this, so the relocation may be -performed on a byte being written to a COFF file, even though 68k COFF -has no such relocation type. - -@item line numbers -Object formats can contain, for debugging purposes, some form of mapping -between symbols, source line numbers, and addresses in the output file. -These addresses have to be relocated along with the symbol information. -Each symbol with an associated list of line number records points to the -first record of the list. The head of a line number list consists of a -pointer to the symbol, which allows divination of the address of the -function whose line number is being described. The rest of the list is -made up of pairs: offsets into the section and line numbers. Any format -which can simply derive this information can pass it successfully -between formats (COFF, IEEE and Oasys). -@end table - -@c FIXME: what is this line about? Do we want introductory remarks -@c FIXME... on back ends? commented out for now. -@c What is a backend - - -@node BFD front end, BFD back end, Overview, Top -@chapter BFD front end -@include bfd.texi - -@menu -* Memory Usage:: -* Initialization:: -* Sections:: -* Symbols:: -* Archives:: -* Formats:: -* Relocations:: -* Core Files:: -* Targets:: -* Architectures:: -* Opening and Closing:: -* Constructors:: -* Internal:: -* File Caching:: -@end menu - -@node Memory Usage, Initialization, BFD front end, BFD front end -@section Memory Usage -BFD keeps all its internal structures in obstacks. There is one obstack -per open BFD file, into which the current state is stored. When a BFD is -closed, the obstack is deleted, and so everything which has been -allocated by libbfd for the closing file will be thrown away. - -BFD will not free anything created by an application, but pointers into -@code{bfd} structures will be invalidated on a @code{bfd_close}; for example, -after a @code{bfd_close} the vector passed to -@code{bfd_canonicalize_symtab} will still be around, since it has been -allocated by the application, but the data that it pointed to will be -lost. - -The general rule is not to close a BFD until all operations dependent -upon data from the BFD have been completed, or all the data from within -the file has been copied. To help with the management of memory, there is a function -(@code{bfd_alloc_size}) which returns the number of bytes in obstacks -associated with the supplied BFD. This could be used to select the -greediest open BFD, close it to reclaim the memory, perform some -operation and reopen the BFD again, to get a fresh copy of the data structures. - -@node Initialization, Sections, Memory Usage, BFD front end -@include init.texi - -@node Sections, Symbols, Initialization, BFD front end -@include section.texi - -@node Symbols, Archives, Sections, BFD front end -@include syms.texi - -@node Archives, Formats, Symbols, BFD front end -@include archive.texi - -@node Formats, Relocations, Archives, BFD front end -@include format.texi - -@node Relocations, Core Files, Formats, BFD front end -@include reloc.texi - -@node Core Files, Targets, Relocations, BFD front end -@include core.texi - -@node Targets, Architectures, Core Files, BFD front end -@include targets.texi - -@node Architectures, Opening and Closing, Targets, BFD front end -@include archures.texi - -@node Opening and Closing, Constructors, Architectures, BFD front end -@include opncls.texi - -@node Constructors, Internal, Opening and Closing, BFD front end -@include ctor.texi - -@node Internal, File Caching, Constructors, BFD front end -@include libbfd.texi - -@node File Caching, , Internal, BFD front end -@include cache.texi - -@node BFD back end, Index, BFD front end, Top -@chapter BFD back end -@menu -* What to put where:: -* aout :: a.out backends -* coff :: coff backends -@ignore -* oasys :: oasys backends -* ieee :: ieee backend -* srecord :: s-record backend -@end ignore -@end menu -@node What to Put Where, aout, BFD back end, BFD back end -All of BFD lives in one directory. - -@node aout, coff, What to Put Where, BFD back end -@include aoutx.texi - -@node coff, , aout, BFD back end -@include coffcode.texi - -@node Index, , BFD back end, Top -@unnumbered Index -@printindex cp - -@tex -% I think something like @colophon should be in texinfo. In the -% meantime: -\long\def\colophon{\hbox to0pt{}\vfill -\centerline{The body of this manual is set in} -\centerline{\fontname\tenrm,} -\centerline{with headings in {\bf\fontname\tenbf}} -\centerline{and examples in {\tt\fontname\tentt}.} -\centerline{{\it\fontname\tenit\/} and} -\centerline{{\sl\fontname\tensl\/}} -\centerline{are used for emphasis.}\vfill} -\page\colophon -% Blame: pesch@cygnus.com, 28mar91. -@end tex - -@contents -@bye - - diff --git a/bfd/doc/bfdinfo b/bfd/doc/bfdinfo deleted file mode 100755 index 5bb06ff489d..00000000000 --- a/bfd/doc/bfdinfo +++ /dev/null @@ -1,1281 +0,0 @@ -Info file bfdinfo, produced by Makeinfo, -*- Text -*- from input file -bfd.texinfo. - - This file documents the BFD library. - - Copyright (C) 1991 Free Software Foundation, Inc. - - Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. - - Permission is granted to copy and distribute modified versions of -this manual under the conditions for verbatim copying, subject to the -terms of the GNU General Public License, which includes the provision -that the entire resulting derived work is distributed under the terms -of a permission notice identical to this one. - - Permission is granted to copy and distribute translations of this -manual into another language, under the above conditions for modified -versions. - - -File: bfdinfo, Node: Top, Next: Overview, Prev: (dir), Up: (dir) - - This file documents the binary file descriptor library libbfd. - -* Menu: - -* Overview:: Overview of BFD -* History:: History of BFD -* Backends:: Backends -* Porting:: Porting -* Future:: Future -* Index:: Index - -BFD body: -* Memory usage:: -* Sections:: -* Symbols:: -* Archives:: -* Formats:: -* Relocations:: -* Core Files:: -* Targets:: -* Architecturs:: -* Opening and Closing:: -* Internal:: -* File Caching:: - -BFD backends: -* a.out backends:: -* coff backends:: - - -File: bfdinfo, Node: Overview, Next: History, Prev: Top, Up: Top - -Introduction -************ - - Simply put, BFD is a package which allows applications to use the -same routines to operate on object files whatever the object file -format. A different object file format can be supported simply by -creating a new BFD back end and adding it to the library. - - BFD is split into two parts; the front end and the many back ends. - - * memory, and various canonical data structures. The front end also - decides which back end to use, and when to call back end routines. - - * end provides a set of calls which the BFD front end can use to - maintain its canonical form. The back ends also may keep around - information for their own use, for greater efficiency. - - -File: bfdinfo, Node: History, Next: How It Works, Prev: Overview, Up: Top - -History -======= - - One spur behind BFD was the desire, on the part of the GNU 960 team -at Intel Oregon, for interoperability of applications on their COFF and -b.out file formats. Cygnus was providing GNU support for the team, and -Cygnus was contracted to provide the required functionality. - - The name came from a conversation David Wallace was having with -Richard Stallman about the library: RMS said that it would be quite -hard--David said "BFD". Stallman was right, but the name stuck. - - At the same time, Ready Systems wanted much the same thing, but for -different object file formats: IEEE-695, Oasys, Srecords, a.out and 68k -coff. - - BFD was first implemented by Steve Chamberlain (steve@cygnus.com), -John Gilmore (gnu@cygnus.com), K. Richard Pixley (rich@cygnus.com) and -David Wallace (gumby@cygnus.com) at Cygnus Support in Palo Alto, -California. - - -File: bfdinfo, Node: How It Works, Next: History, Prev: Porting, Up: Top - -How It Works -============ - - To use the library, include `bfd.h' and link with `libbfd.a'. - - BFD provides a common interface to the parts of an object file for -a calling application. - - When an application sucessfully opens a target file (object, -archive or whatever) a pointer to an internal structure is returned. -This pointer points to a structure called `bfd', described in -`include/bfd.h'. Our convention is to call this pointer a BFD, and -instances of it within code `abfd'. All operations on the target -object file are applied as methods to the BFD. The mapping is defined -within `bfd.h' in a set of macros, all beginning `bfd'_. - - For example, this sequence would do what you would probably expect: -return the number of sections in an object file attached to a BFD -`abfd'. - - - #include "bfd.h" - - unsigned int number_of_sections(abfd) - bfd *abfd; - { - return bfd_count_sections(abfd); - } - - lisp - - The abstraction used within BFD is that an object file has a header, -a number of sections containing raw data, a set of relocations, and -some symbol information. Also, BFDs opened for archives have the -additional attribute of an index and contain subordinate BFDs. This -approach is fine for a.out and coff, but loses efficiency when applied -to formats such as S-records and IEEE-695. - -What BFD Version 1 Can Do -========================= - - As different information from the the object files is required, BFD -reads from different sections of the file and processes them. For -example a very common operation for the linker is processing symbol -tables. Each BFD back end provides a routine for converting between -the object file's representation of symbols and an internal canonical -format. When the linker asks for the symbol table of an object file, -it calls through the memory pointer to the relevant BFD back end -routine which reads and converts the table into a canonical form. The -linker then operates upon the canonical form. When the link is -finished and the linker writes the output file's symbol table, another -BFD back end routine is called which takes the newly created symbol -table and converts it into the chosen output format. - - -File: bfdinfo, Node: BFD information loss, Next: Mechanism, Prev: BFD outline, Up: BFD - -Information Loss ----------------- - - *Some information is lost due to the nature of the file format.* -The output targets supported by BFD do not provide identical -facilities, and information which may be described in one form has -nowhere to go in another format. One example of this is alignment -information in `b.out'. There is nowhere in an `a.out' format file to -store alignment information on the contained data, so when a file is -linked from `b.out' and an `a.out' image is produced, alignment -information will not propagate to the output file. (The linker will -still use the alignment information internally, so the link is -performed correctly). - - Another example is COFF section names. COFF files may contain an -unlimited number of sections, each one with a textual section name. If -the target of the link is a format which does not have many sections -(eg `a.out') or has sections without names (eg the Oasys format) the -link cannot be done simply. You can circumvent this problem by -describing the desired input-to-output section mapping with the linker -command language. - - *Information can be lost during canonicalization.* The BFD internal -canonical form of the external formats is not exhaustive; there are -structures in input formats for which there is no direct -representation internally. This means that the BFD back ends cannot -maintain all possible data richness through the transformation between -external to internal and back to external formats. - - This limitation is only a problem when an application reads one -format and writes another. Each BFD back end is responsible for -maintaining as much data as possible, and the internal BFD canonical -form has structures which are opaque to the BFD core, and exported -only to the back ends. When a file is read in one format, the -canonical form is generated for BFD and the application. At the same -time, the back end saves away any information which may otherwise be -lost. If the data is then written back in the same format, the back -end routine will be able to use the canonical form provided by the BFD -core as well as the information it prepared earlier. Since there is a -great deal of commonality between back ends, this mechanism is very -useful. There is no information lost for this reason when linking or -copying big endian COFF to little endian COFF, or `a.out' to `b.out'. -When a mixture of formats is linked, the information is only lost from -the files whose format differs from the destination. - - -File: bfdinfo, Node: Mechanism, Prev: BFD information loss, Up: BFD - -Mechanism ---------- - - The greatest potential for loss of information is when there is -least overlap between the information provided by the source format, -that stored by the canonical format, and the information needed by the -destination format. A brief description of the canonical form may help -you appreciate what kinds of data you can count on preserving across -conversions. - -*files* - Information on target machine architecture, particular - implementation and format type are stored on a per-file basis. - Other information includes a demand pageable bit and a write - protected bit. Note that information like Unix magic numbers is - not stored here--only the magic numbers' meaning, so a `ZMAGIC' - file would have both the demand pageable bit and the write - protected text bit set. The byte order of the target is stored - on a per-file basis, so that big- and little-endian object files - may be linked with one another. - -*sections* - Each section in the input file contains the name of the section, - the original address in the object file, various flags, size and - alignment information and pointers into other BFD data structures. - -*symbols* - Each symbol contains a pointer to the object file which originally - defined it, its name, its value, and various flag bits. When a - BFD back end reads in a symbol table, the back end relocates all - symbols to make them relative to the base of the section where - they were defined. This ensures that each symbol points to its - containing section. Each symbol also has a varying amount of - hidden data to contain private data for the BFD back end. Since - the symbol points to the original file, the private data format - for that symbol is accessible. `gld' can operate on a collection - of symbols of wildly different formats without problems. - - Normal global and simple local symbols are maintained on output, - so an output file (no matter its format) will retain symbols - pointing to functions and to global, static, and common - variables. Some symbol information is not worth retaining; in - `a.out' type information is stored in the symbol table as long - symbol names. This information would be useless to most COFF - debuggers; the linker has command line switches to allow users to - throw it away. - - There is one word of type information within the symbol, so if the - format supports symbol type information within symbols (for - example COFF, IEEE, Oasys) and the type is simple enough to fit - within one word (nearly everything but aggregates) the - information will be preserved. - -*relocation level* - Each canonical BFD relocation record contains a pointer to the - symbol to relocate to, the offset of the data to relocate, the - section the data is in and a pointer to a relocation type - descriptor. Relocation is performed effectively by message - passing through the relocation type descriptor and symbol - pointer. It allows relocations to be performed on output data - using a relocation method only available in one of the input - formats. For instance, Oasys provides a byte relocation format. - A relocation record requesting this relocation type would point - indirectly to a routine to perform this, so the relocation may be - performed on a byte being written to a COFF file, even though 68k - COFF has no such relocation type. - -*line numbers* - Object formats can contain, for debugging purposes, some form of - mapping between symbols, source line numbers, and addresses in - the output file. These addresses have to be relocated along with - the symbol information. Each symbol with an associated list of - line number records points to the first record of the list. The - head of a line number list consists of a pointer to the symbol, - which allows divination of the address of the function whose line - number is being described. The rest of the list is made up of - pairs: offsets into the section and line numbers. Any format - which can simply derive this information can pass it successfully - between formats (COFF, IEEE and Oasys). - - -File: bfdinfo, Node: BFD front end, Next: BFD back end, Prev: Mechanism, Up: Top - -BFD front end -************* - -typedef bfd -=========== - - Pointers to bfd structs are the cornerstone of any application using -`libbfd'. References though the BFD and to data in the BFD give the -entire BFD functionality. - - Here is the BFD struct itself. This contains the major data about -the file, and contains pointers to the rest of the data. - - struct _bfd - { - - The filename the application opened the BFD with. - - CONST char *filename; - - A pointer to the target jump table. - - struct bfd_target *xvec; - - To avoid dragging too many header files into every file that -includes `bfd.h', IOSTREAM has been declared as a "char *", and MTIME -as a "long". Their correct types, to which they are cast when used, -are "FILE *" and "time_t". - - The iostream is the result of an fopen on the filename. - - char *iostream; - - Is the file being cached *Note File Caching::. - - boolean cacheable; - - Marks whether there was a default target specified when the BFD was -opened. This is used to select what matching algorithm to use to chose -the back end. - - boolean target_defaulted; - - The caching routines use these to maintain a least-recently-used -list of BFDs (*note File Caching::.). - - struct _bfd *lru_prev, *lru_next; - - When a file is closed by the caching routines, BFD retains state -information on the file here: - - file_ptr where; - - and here: - - boolean opened_once; - - boolean mtime_set; - - File modified time - - long mtime; - - Reserved for an unimplemented file locking extension. - - int ifd; - - The format which belongs to the BFD. - - bfd_format format; - - The direction the BFD was opened with - - enum bfd_direction {no_direction = 0, - read_direction = 1, - write_direction = 2, - both_direction = 3} direction; - - Format_specific flags - - flagword flags; - - Currently my_archive is tested before adding origin to anything. I -believe that this can become always an add of origin, with origin set -to 0 for non archive files. - - file_ptr origin; - - Remember when output has begun, to stop strange things happening. - - boolean output_has_begun; - - Pointer to linked list of sections - - struct sec *sections; - - The number of sections - - unsigned int section_count; - - Stuff only useful for object files: The start address. - - bfd_vma start_address; - - Used for input and output - - unsigned int symcount; - - Symbol table for output BFD - - struct symbol_cache_entry **outsymbols; - - Architecture of object machine, eg m68k - - enum bfd_architecture obj_arch; - - Particular machine within arch, e.g. 68010 - - unsigned long obj_machine; - - Stuff only useful for archives: - - PTR arelt_data; - struct _bfd *my_archive; - struct _bfd *next; - struct _bfd *archive_head; - boolean has_armap; - - Used by the back end to hold private data. - - PTR tdata; - - Used by the application to hold private data - - PTR usrdata; - - Where all the allocated stuff under this BFD goes (*note Memory -Usage::.). - - struct obstack memory; - }; - -`bfd_set_start_address' -....................... - - Marks the entry point of an output BFD. Returns `true' on success, -`false' otherwise. - - boolean bfd_set_start_address(bfd *, bfd_vma); - -`bfd_get_mtime' -............... - - Return cached file modification time (e.g. as read from archive -header for archive members, or from file system if we have been called -before); else determine modify time, cache it, and return it. - - long bfd_get_mtime(bfd *); - -`stuff' -....... - - - - #define bfd_sizeof_headers(abfd, reloc) \ - BFD_SEND (abfd, _bfd_sizeof_headers, (abfd, reloc)) - - #define bfd_find_nearest_line(abfd, section, symbols, offset, filename_ptr, func, line_ptr) \ - BFD_SEND (abfd, _bfd_find_nearest_line, (abfd, section, symbols, offset, filename_ptr, func, line_ptr)) - - #define bfd_debug_info_start(abfd) \ - BFD_SEND (abfd, _bfd_debug_info_start, (abfd)) - - #define bfd_debug_info_end(abfd) \ - BFD_SEND (abfd, _bfd_debug_info_end, (abfd)) - - #define bfd_debug_info_accumulate(abfd, section) \ - BFD_SEND (abfd, _bfd_debug_info_accumulate, (abfd, section)) - - #define bfd_stat_arch_elt(abfd, stat) \ - BFD_SEND (abfd, _bfd_stat_arch_elt,(abfd, stat)) - - #define bfd_coff_swap_aux_in(a,e,t,c,i) \ - BFD_SEND (a, _bfd_coff_swap_aux_in, (a,e,t,c,i)) - - #define bfd_coff_swap_sym_in(a,e,i) \ - BFD_SEND (a, _bfd_coff_swap_sym_in, (a,e,i)) - - #define bfd_coff_swap_lineno_in(a,e,i) \ - BFD_SEND ( a, _bfd_coff_swap_lineno_in, (a,e,i)) - - lisp - - -File: bfdinfo, Node: Memory Usage, Next: Sections, Prev: bfd, Up: Top - -Memory Usage -============ - - BFD keeps all its internal structures in obstacks. There is one -obstack per open BFD file, into which the current state is stored. -When a BFD is closed, the obstack is deleted, and so everything which -has been allocated by libbfd for the closing file will be thrown away. - - BFD will not free anything created by an application, but pointers -into `bfd' structures will be invalidated on a `bfd_close'; for -example, after a `bfd_close' the vector passed to -`bfd_canonicalize_symtab' will still be around, since it has been -allocated by the application, but the data that it pointed to will be -lost. - - The general rule is not to close a BFD until all operations -dependent upon data from the BFD have been completed, or all the data -from within the file has been copied. To help with the management of -memory, there is a function (`bfd_alloc_size') which returns the -number of bytes in obstacks associated with the supplied BFD. This -could be used to select the greediest open BFD, close it to reclaim -the memory, perform some operation and reopen the BFD again, to get a -fresh copy of the data structures. - - -File: bfdinfo, Node: Sections, Next: Symbols, Prev: Memory Usage, Up: Top - -Sections -======== - - Sections are supported in BFD in `section.c'. - - The raw data contained within a BFD is maintained through the -section abstraction. A single BFD may have any number of sections, -and keeps hold of them by pointing to the first, each one points to -the next in the list. - -* Menu: - -* Section Input:: -* Section Output:: -* typedef asection:: -* section prototypes:: - - -File: bfdinfo, Node: Section Input, Next: Section Output, Up: Sections - -Section Input -------------- - - When a BFD is opened for reading, the section structures are created -and attached to the BFD. - - Each section has a name which describes the section in the outside -world - for example, `a.out' would contain at least three sections, -called `.text', `.data' and `.bss'. - - Sometimes a BFD will contain more than the 'natural' number of -sections. A back end may attach other sections containing constructor -data, or an application may add a section (using bfd_make_section) to -the sections attached to an already open BFD. For example, the linker -creates a supernumary section `COMMON' for each input file's BFD to -hold information about common storage. - - The raw data is not necessarily read in at the same time as the -section descriptor is created. Some targets may leave the data in -place until a `bfd_get_section_contents' call is made. Other back ends -may read in all the data at once - For example; an S-record file has -to be read once to determine the size of the data. An IEEE-695 file -doesn't contain raw data in sections, but data and relocation -expressions intermixed, so the data area has to be parsed to get out -the data and relocations. - - -File: bfdinfo, Node: Section Output, Next: typedef asection, Prev: Section Input, Up: Sections - -Section Output --------------- - - To write a new object style BFD, the various sections to be written -have to be created. They are attached to the BFD in the same way as -input sections, data is written to the sections using -`bfd_set_section_contents'. - - The linker uses the fields `output_section' and `output_offset' to -create an output file. - - The data to be written comes from input sections attached to the -output sections. The output section structure can be considered a -filter for the input section, the output section determines the vma of -the output data and the name, but the input section determines the -offset into the output section of the data to be written. - - Eg to create a section "O", starting at 0x100, 0x123 long, -containing two subsections, "A" at offset 0x0 (ie at vma 0x100) and -"B" at offset 0x20 (ie at vma 0x120) the structures would look like: - - - - section name "A" - output_offset 0x00 - size 0x20 - output_section -----------> section name "O" - | vma 0x100 - section name "B" | size 0x123 - output_offset 0x20 | - size 0x103 | - output_section --------| - - lisp - - -File: bfdinfo, Node: typedef asection, Next: section prototypes, Prev: Section Output, Up: Sections - -typedef asection ----------------- - - The shape of a section struct: - - typedef struct sec { - - The name of the section, the name isn't a copy, the pointer is the -same as that passed to bfd_make_section. - - CONST char *name; - - The next section in the list belonging to the BFD, or NULL. - - struct sec *next; - - The field flags contains attributes of the section. Some of these -flags are read in from the object file, and some are synthesized from -other information. - - flagword flags; - - #define SEC_NO_FLAGS 0x000 - - Tells the OS to allocate space for this section when loaded. This -would clear for a section containing debug information only. - - #define SEC_ALLOC 0x001 - - Tells the OS to load the section from the file when loading. This -would be clear for a .bss section - - #define SEC_LOAD 0x002 - - The section contains data still to be relocated, so there will be -some relocation information too. - - #define SEC_RELOC 0x004 - - Obsolete - - #define SEC_BALIGN 0x008 - - A signal to the OS that the section contains read only data. - - #define SEC_READONLY 0x010 - - The section contains code only. - - #define SEC_CODE 0x020 - - The section contains data only. - - #define SEC_DATA 0x040 - - The section will reside in ROM. - - #define SEC_ROM 0x080 - - The section contains constructor information. This section type is -used by the linker to create lists of constructors and destructors -used by `g++'. When a back end sees a symbol which should be used in a -constructor list, it creates a new section for the type of name (eg -`__CTOR_LIST__'), attaches the symbol to it and builds a relocation. -To build the lists of constructors, all the linker has to to is -catenate all the sections called `__CTOR_LIST__' and relocte the data -contained within - exactly the operations it would peform on standard -data. - - #define SEC_CONSTRUCTOR 0x100 - - The section is a constuctor, and should be placed at the end of the -.. - - #define SEC_CONSTRUCTOR_TEXT 0x1100 - - #define SEC_CONSTRUCTOR_DATA 0x2100 - - #define SEC_CONSTRUCTOR_BSS 0x3100 - - The section has contents - a bss section could be `SEC_ALLOC' | -`SEC_HAS_CONTENTS', a debug section could be `SEC_HAS_CONTENTS' - - #define SEC_HAS_CONTENTS 0x200 - - An instruction to the linker not to output sections containing this -flag even if they have information which would normally be written. - - #define SEC_NEVER_LOAD 0x400 - - The base address of the section in the address space of the target. - - bfd_vma vma; - - The size of the section in bytes of the loaded section. This -contains a value even if the section has no contents (eg, the size of -`.bss'). - - bfd_size_type size; - - If this section is going to be output, then this value is the -offset into the output section of the first byte in the input section. -Eg, if this was going to start at the 100th byte in the output -section, this value would be 100. - - bfd_vma output_offset; - - The output section through which to map on output. - - struct sec *output_section; - - The alignment requirement of the section, as an exponent - eg 3 -aligns to 2^3 (or 8) - - unsigned int alignment_power; - - If an input section, a pointer to a vector of relocation records for -the data in this section. - - struct reloc_cache_entry *relocation; - - If an output section, a pointer to a vector of pointers to -relocation records for the data in this section. - - struct reloc_cache_entry **orelocation; - - The number of relocation records in one of the above - - unsigned reloc_count; - - Which section is it 0..nth - - int index; - - Information below is back end specific - and not always used or -updated - - File position of section data - - file_ptr filepos; - - File position of relocation info - - file_ptr rel_filepos; - - File position of line data - - file_ptr line_filepos; - - Pointer to data for applications - - PTR userdata; - - struct lang_output_section *otheruserdata; - - Attached line number information - - alent *lineno; - - Number of line number records - - unsigned int lineno_count; - - When a section is being output, this value changes as more -linenumbers are written out - - file_ptr moving_line_filepos; - - what the section number is in the target world - - unsigned int target_index; - - PTR used_by_bfd; - - If this is a constructor section then here is a list of the -relocations created to relocate items within it. - - struct relent_chain *constructor_chain; - - The BFD which owns the section. - - bfd *owner; - - } asection ; - - -File: bfdinfo, Node: section prototypes, Next: Section, Prev: typedef section, Up: Sections - -section prototypes ------------------- - -`bfd_get_section_by_name' -......................... - - Runs through the provided ABFD and returns the `asection' who's -name matches that provided, otherwise NULL. *Note Sections::, for more -information. - - asection * bfd_get_section_by_name(bfd *abfd, CONST char *name); - -`bfd_make_section' -.................. - - This function creates a new empty section called NAME and attaches -it to the end of the chain of sections for the BFD supplied. An -attempt to create a section with a name which is already in use, -returns the old section by that name instead. - - Possible errors are: - -`invalid_operation' - If output has already started for this BFD. - -`no_memory' - If obstack alloc fails. - - asection * bfd_make_section(bfd *, CONST char *name); - -`bfd_set_section_flags' -....................... - - Attempts to set the attributes of the section named in the BFD -supplied to the value. Returns true on success, false on error. -Possible error returns are: - -`invalid operation' - The section cannot have one or more of the attributes requested. - For example, a .bss section in `a.out' may not have the - `SEC_HAS_CONTENTS' field set. - - boolean bfd_set_section_flags(bfd *, asection *, flagword); - -`bfd_map_over_sections' -....................... - - Calls the provided function FUNC for each section attached to the -BFD ABFD, passing OBJ as an argument. The function will be called as -if by - - func(abfd, the_section, obj); - - void bfd_map_over_sections(bfd *abfd, void (*func)(), PTR obj); - - This is the prefered method for iterating over sections, an -alternative would be to use a loop: - - section *p; - for (p = abfd->sections; p != NULL; p = p->next) - func(abfd, p, ...) - -`bfd_set_section_size' -...................... - - Sets SECTION to the size VAL. If the operation is ok, then `true' -is returned, else `false'. - - Possible error returns: - -`invalid_operation' - Writing has started to the BFD, so setting the size is invalid - - boolean bfd_set_section_size(bfd *, asection *, bfd_size_type val); - -`bfd_set_section_contents' -.......................... - - Sets the contents of the section SECTION in BFD ABFD to the data -starting in memory at DATA. The data is written to the output section -starting at offset OFFSET for COUNT bytes. - - Normally `true' is returned, else `false'. Possible error returns -are: - -`no_contents' - The output section does not have the `SEC_HAS_CONTENTS' - attribute, so nothing can be written to it. - -`and some more too' - This routine is front end to the back end function -`_bfd_set_section_contents'. - - boolean bfd_set_section_contents(bfd *abfd, - asection *section, - PTR data, - file_ptr offset, - bfd_size_type count); - -`bfd_get_section_contents' -.......................... - - This function reads data from SECTION in BFD ABFD into memory -starting at LOCATION. The data is read at an offset of OFFSET from the -start of the input section, and is read for COUNT bytes. - - If the contents of a constuctor with the `SEC_CONSTUCTOR' flag set -are requested, then the LOCATION is filled with zeroes. - - If no errors occur, `true' is returned, else `false'. Possible -errors are: - -`unknown yet' - boolean bfd_get_section_contents(bfd *abfd, asection *section, PTR location, - file_ptr offset, bfd_size_type count); - - -File: bfdinfo, Node: Symbols, Next: Archives, Prev: Sections, Up: To - -Symbols -======= - - BFD trys to maintain as much symbol information as it can when it -moves information from file to file. BFD passes information to -applications though the `asymbol' structure. When the application -requests the symbol table, BFD reads the table in the native form and -translates parts of it into the internal format. To maintain more than -the infomation passed to applications some targets keep some -information 'behind the sceans', in a structure only the particular -back end knows about. For example, the coff back end keeps the -original symbol table structure as well as the canonical structure -when a BFD is read in. On output, the coff back end can reconstruct -the output symbol table so that no information is lost, even -information unique to coff which BFD doesn't know or understand. If a -coff symbol table was read, but was written through an a.out back end, -all the coff specific information would be lost. (.. until BFD 2 :). - - The symbol table of a BFD is not necessarily read in until a -canonicalize request is made. Then the BFD back end fills in a table -provided by the application with pointers to the canonical information. - - To output symbols, the application provides BFD with a table of -pointers to pointers to `asymbol's. This allows applications like the -linker to output a symbol as read, since the 'behind the sceens' -information will be still available. - -* Menu: - -* Reading Symbols:: -* Writing Symbols:: -* typedef asymbol:: -* symbol handling functions:: - - -File: bfdinfo, Node: Reading Symbols, Next: Writing Symbols, Prev: Symbols, Up: Symbols - -Reading Symbols ---------------- - - There are two stages to reading a symbol table from a BFD; -allocating storage, and the actual reading process. This is an excerpt -from an appliction which reads the symbol table: - - - unsigned int storage_needed; - asymbol **symbol_table; - unsigned int number_of_symbols; - unsigned int i; - - storage_needed = get_symtab_upper_bound (abfd); - - if (storage_needed == 0) { - return ; - } - symbol_table = (asymbol **) malloc (storage_needed); - ... - number_of_symbols = - bfd_canonicalize_symtab (abfd, symbol_table); - - for (i = 0; i < number_of_symbols; i++) { - process_symbol (symbol_table[i]); - } - - lisp - - All storage for the symbols themselves is in an obstack connected to -the BFD, and is freed when the BFD is closed. - - -File: bfdinfo, Node: Writing Symbols, Next: typedef asymbol, Prev: Reading Symbols, Up: Symbols - -Writing Symbols ---------------- - - Writing of a symbol table is automatic when a BFD open for writing -is closed. The application attaches a vector of pointers to pointers -to symbols to the BFD being written, and fills in the symbol count. -The close and cleanup code reads through the table provided and -performs all the necessary operations. The outputing code must always -be provided with an 'owned' symbol; one which has come from another -BFD, or one which has been created using `bfd_make_empty_symbol'. - - An example showing the creation of a symbol table with only one -element: - - - #include "bfd.h" - main() - { - bfd *abfd; - asymbol *ptrs[2]; - asymbol *new; - - abfd = bfd_openw("foo","a.out-sunos-big"); - bfd_set_format(abfd, bfd_object); - new = bfd_make_empty_symbol(abfd); - new->name = "dummy_symbol"; - new->section = (asection *)0; - new->flags = BSF_ABSOLUTE | BSF_GLOBAL; - new->value = 0x12345; - - ptrs[0] = new; - ptrs[1] = (asymbol *)0; - - bfd_set_symtab(abfd, ptrs, 1); - bfd_close(abfd); - } - - ./makesym - nm foo - 00012345 A dummy_symbol - - lisp - - Many formats cannot represent arbitary symbol information; for -instance the `a.out' object format does not allow an arbitary number -of sections. A symbol pointing to a section which is not one of -`.text', `.data' or `.bss' cannot be described. - - -File: bfdinfo, Node: typedef asymbol, Next: symbol handling functions, Prev: Writing Symbols, Up: Symbols - -typedef asymbol ---------------- - - An `asymbol' has the form: - - typedef struct symbol_cache_entry - { - - A pointer to the BFD which owns the symbol. This information is -necessary so that a back end can work out what additional (invisible to -the application writer) information is carried with the symbol. - - struct _bfd *the_bfd; - - The text of the symbol. The name is left alone, and not copied - the -application may not alter it. - - CONST char *name; - - The value of the symbol. - - symvalue value; - - Attributes of a symbol: - - #define BSF_NO_FLAGS 0x00 - - The symbol has local scope; `static' in `C'. The value is the -offset into the section of the data. - - #define BSF_LOCAL 0x01 - - The symbol has global scope; initialized data in `C'. The value is -the offset into the section of the data. - - #define BSF_GLOBAL 0x02 - - Obsolete - - #define BSF_IMPORT 0x04 - - The symbol has global scope, and is exported. The value is the -offset into the section of the data. - - #define BSF_EXPORT 0x08 - - The symbol is undefined. `extern' in `C'. The value has no meaning. - - #define BSF_UNDEFINED 0x10 - - The symbol is common, initialized to zero; default in `C'. The -value is the size of the object in bytes. - - #define BSF_FORT_COMM 0x20 - - A normal `C' symbol would be one of: `BSF_LOCAL', `BSF_FORT_COMM', -`BSF_UNDEFINED' or `BSF_EXPORT|BSD_GLOBAL' - - The symbol is a debugging record. The value has an arbitary meaning. - - #define BSF_DEBUGGING 0x40 - - The symbol has no section attached, any value is the actual value -and is not a relative offset to a section. - - #define BSF_ABSOLUTE 0x80 - - Used by the linker - - #define BSF_KEEP 0x10000 - #define BSF_KEEP_G 0x80000 - - Unused - - #define BSF_WEAK 0x100000 - #define BSF_CTOR 0x200000 - #define BSF_FAKE 0x400000 - - The symbol used to be a common symbol, but now it is allocated. - - #define BSF_OLD_COMMON 0x800000 - - The default value for common data. - - #define BFD_FORT_COMM_DEFAULT_VALUE 0 - - In some files the type of a symbol sometimes alters its location in -an output file - ie in coff a `ISFCN' symbol which is also `C_EXT' -symbol appears where it was declared and not at the end of a section. -This bit is set by the target BFD part to convey this information. - - #define BSF_NOT_AT_END 0x40000 - - Signal that the symbol is the label of constructor section. - - #define BSF_CONSTRUCTOR 0x1000000 - - Signal that the symbol is a warning symbol. If the symbol is a -warning symbol, then the value field (I know this is tacky) will point -to the asymbol which when referenced will cause the warning. - - #define BSF_WARNING 0x2000000 - - Signal that the symbol is indirect. The value of the symbol is a -pointer to an undefined asymbol which contains the name to use instead. - - #define BSF_INDIRECT 0x4000000 - - flagword flags; - - A pointer to the section to which this symbol is relative, or 0 if -the symbol is absolute or undefined. Note that it is not sufficient to -set this location to 0 to mark a symbol as absolute - the flag -`BSF_ABSOLUTE' must be set also. - - struct sec *section; - - Back end special data. This is being phased out in favour of making -this a union. - - PTR udata; - } asymbol; - - -File: bfdinfo, Node: symbol handling functions, Next: Symbols, Prev: typedef asymbol, Up: Symbols - -Symbol Handling Functions -------------------------- - -`get_symtab_upper_bound' -........................ - - Returns the number of bytes required in a vector of pointers to -`asymbols' for all the symbols in the supplied BFD, including a -terminal NULL pointer. If there are no symbols in the BFD, then 0 is -returned. - - - #define get_symtab_upper_bound(abfd) \ - BFD_SEND (abfd, _get_symtab_upper_bound, (abfd)) - - lisp - -`bfd_canonicalize_symtab' -......................... - - Supplied a BFD and a pointer to an uninitialized vector of pointers. -This reads in the symbols from the BFD, and fills in the table with -pointers to the symbols, and a trailing NULL. The routine returns the -actual number of symbol pointers not including the NULL. - - - #define bfd_canonicalize_symtab(abfd, location) \ - BFD_SEND (abfd, _bfd_canonicalize_symtab,\ - (abfd, location)) - - lisp - -`bfd_set_symtab' -................ - - Provided a table of pointers to to symbols and a count, writes to -the output BFD the symbols when closed. - - boolean bfd_set_symtab(bfd *, asymbol **, unsigned int ); - -`bfd_print_symbol_vandf' -........................ - - Prints the value and flags of the symbol supplied to the stream -file. - - void bfd_print_symbol_vandf(PTR file, asymbol *symbol); - -`bfd_make_empty_symbol' -....................... - - This function creates a new `asymbol' structure for the BFD, and -returns a pointer to it. - - This routine is necessary, since each back end has private -information surrounding the `asymbol'. Building your own `asymbol' and -pointing to it will not create the private information, and will cause -problems later on. - - - #define bfd_make_empty_symbol(abfd) \ - BFD_SEND (abfd, _bfd_make_empty_symbol, (abfd)) - - lisp - - -File: bfdinfo, Node: Archives, Next: Formats, Prev: Symbols, Up: Top - -Archives -======== - - Gumby, you promised to write this bit... - - Archives are supported in BFD in `archive.c'. - - An archive is represented internally just like another BFD, with a -pointer to a chain of contained BFDs. Archives can be created by -opening BFDs, linking them together and attaching them as children to -another BFD and then closing the parent BFD. - -`bfd_get_next_mapent' -..................... - - What this does - - symindex bfd_get_next_mapent(bfd *, symindex, carsym **); - -`bfd_set_archive_head' -...................... - - Used whilst processing archives. Sets the head of the chain of BFDs -contained in an archive to NEW_HEAD. (see chapter on archives) - - boolean bfd_set_archive_head(bfd *output, bfd *new_head); - -`bfd_get_elt_at_index' -...................... - - Return the sub bfd contained within the archive at archive index n. - - bfd * bfd_get_elt_at_index(bfd *, int); - -`bfd_openr_next_archived_file' -.............................. - - Initially provided a BFD containing an archive and NULL, opens a BFD -on the first contained element and returns that. Subsequent calls to -bfd_openr_next_archived_file should pass the archive and the previous -return value to return a created BFD to the next contained element. -NULL is returned when there are no more. - - bfd* bfd_openr_next_archived_file(bfd *archive, bfd *previous); - - -File: bfdinfo, Node: Formats, Next: Relocations, Prev: Archives, Up: Top - -File Formats -============ - - A format is a BFD concept of high level file contents. The formats -supported by BFD are: - -`bfd_object' - The BFD may contain data, symbols, relocations and debug info. - -`bfd_archive' - The \ No newline at end of file diff --git a/bfd/doc/blins-p b/bfd/doc/blins-p deleted file mode 100755 index 858dcd7ecd7..00000000000 --- a/bfd/doc/blins-p +++ /dev/null @@ -1,8 +0,0 @@ -# sed script for BFD header files -# Merge adjacent blank lines. Loop til no change. -:blin -/^$/,/^ *[^ ]*.*$/{ -/^$/N -s/^ *\n *$// -} -t blin diff --git a/bfd/doc/configure.in b/bfd/doc/configure.in deleted file mode 100644 index c23601b2721..00000000000 --- a/bfd/doc/configure.in +++ /dev/null @@ -1,11 +0,0 @@ -# This file is a shell script that supplies the information necessary -# to tailor a template configure script into the configure script -# appropriate for this directory. For more information, check any -# existing configure script. - -srctrigger=bfd.texinfo -srcname="BFD doc" - -# per-host: - -# per-target: diff --git a/bfd/doc/exfil1-p b/bfd/doc/exfil1-p deleted file mode 100755 index a57fc957ad2..00000000000 --- a/bfd/doc/exfil1-p +++ /dev/null @@ -1,5 +0,0 @@ -# -# Locate and coalesce adjacent comments -/\*\/$/N -s/\*\/\n\/\*/\ -/ diff --git a/bfd/doc/exfil3-p b/bfd/doc/exfil3-p deleted file mode 100755 index c557a163acf..00000000000 --- a/bfd/doc/exfil3-p +++ /dev/null @@ -1,16 +0,0 @@ -# blank-line activity: -# Merge adjacent blank lines. Loop til no change. -:blin -/^$/,/^ *[^ ]*.*$/{ -/^$/N -s/^ *\n *$// -} -t blin -# -/^$/,/^ *[^ ]*.*$/{ -/^$/N -# Transpose -/^ *\n\*\/$/c\ -*\/\ - -} diff --git a/bfd/doc/exfilter b/bfd/doc/exfilter deleted file mode 100755 index 7551607763d..00000000000 --- a/bfd/doc/exfilter +++ /dev/null @@ -1,14 +0,0 @@ -# SED script for preprocessing embedded doc from source (S. Chamberlain markup) -# Final pass; cleanup work is done here. -# -# Within examples, make '{' and '}' printable: -/^@lisp$/,/^@end lisp$/s/{/@{/ -/^@lisp$/,/^@end lisp$/s/}/@}/ -/^@example$/,/^@end example$/s/{/@{/ -/^@example$/,/^@end example$/s/}/@}/ -# -# Delete empty @findex and @subsubsection entries (resulting from *proto* -# with no further text on same line, in middle pass) -/^@findex $/d -/^@subsubsection @code{}/d -# diff --git a/bfd/doc/exfilter-p b/bfd/doc/exfilter-p deleted file mode 100755 index 27a1d05a720..00000000000 --- a/bfd/doc/exfilter-p +++ /dev/null @@ -1,12 +0,0 @@ -# SED script for preprocessing embedded headers from C source comments -# (S. Chamberlain markup) -# beginning of many passes of cleanup work -# -# Delete empty comment blocks -/^\/\*$/N -/^\/\*\n\*\/ *$/d -# -# Locate and coalesce adjacent comments -/\*\/$/N -s/\*\/\n\/\*/\ -/ diff --git a/bfd/doc/exfiltst b/bfd/doc/exfiltst deleted file mode 100755 index 18bab5acfe0..00000000000 --- a/bfd/doc/exfiltst +++ /dev/null @@ -1,8 +0,0 @@ -# Merge adjacent blank lines. Loop til no change. -:blin -/^$/,/^ *[^ ]*.*$/{ -/^$/N -s/^ *\n *$// -} -t blin - diff --git a/bfd/doc/exmerge b/bfd/doc/exmerge deleted file mode 100755 index dafa4244dff..00000000000 --- a/bfd/doc/exmerge +++ /dev/null @@ -1,4 +0,0 @@ -# SED script for preprocessing embedded doc from source (S. Chamberlain markup) -# Locate and coalesce adjacent @example blocks -/^@end example/N -/^@end example\n@example$/d diff --git a/bfd/doc/intobfd b/bfd/doc/intobfd deleted file mode 100755 index f72d8e91e5f..00000000000 --- a/bfd/doc/intobfd +++ /dev/null @@ -1,13 +0,0 @@ -/\/\*:init.c\*\//r init.p -/\/\*:archive.c\*\//r archive.p -/\/\*:archures.c\*\//r archures.p -/\/\*:bfd.c\*\//r bfd.p -/\/\*:core.c\*\//r core.p -/\/\*:format.c\*\//r format.p -/\/\*:libbfd.c\*\//r libbfd.p -/\/\*:opncls.c\*\//r opncls.p -/\/\*:reloc.c\*\//r reloc.p -/\/\*:section.c\*\//r section.p -/\/\*:syms.c\*\//r syms.p -/\/\*:targets.c\*\//r targets.p - diff --git a/bfd/doc/mergecom-p b/bfd/doc/mergecom-p deleted file mode 100755 index 456478b7c48..00000000000 --- a/bfd/doc/mergecom-p +++ /dev/null @@ -1,5 +0,0 @@ -# SED script for preprocessing embedded headers from C source comments -# Locate and coalesce adjacent comments -/\*\/$/N -s/\*\/\n\/\*/\ -/ diff --git a/bfd/doc/movecom-p b/bfd/doc/movecom-p deleted file mode 100755 index 7ed04c7b112..00000000000 --- a/bfd/doc/movecom-p +++ /dev/null @@ -1,8 +0,0 @@ -# sed script for BFD header files: -# Transpose -/^$/,/^ *[^ ]*.*$/{ -/^$/N -/^ *\n\*\/$/c\ -*\/\ - -} diff --git a/bfd/doc/scanit b/bfd/doc/scanit deleted file mode 100755 index a989c786dc5..00000000000 --- a/bfd/doc/scanit +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh -# Script to coordinate parsing of S. Chamberlain source-embedded -# documentation markup language. - -# Four passes: -# 1) awk discards lines not intended for docn, and marks blocks of -# text with comments identifying source file; -# 2) first sed pass interprets Chamberlain markup; -# 3) second sed pass does cleanup that involves merging lines -# 4) third sed pass does remaining cleans up---making {} -# printable within examples, and eliminating empty index entries and -# headings. -#Third and second sed passes are separate because order of execution is hard -#to control otherwise, making one or another of the things involving @example -#inoperative. - -base=`echo $1 | cut -d '.' -f 1` -out=`echo $2 | cut -d '.' -f 1` - -awk -f $3/awkscan $1 | \ -sed -f $3/sedscript | \ -sed -f $3/unPROTO | \ -sed -f $3/exmerge | \ -sed -f $3/exfilter >$out.texi - diff --git a/bfd/doc/scanph b/bfd/doc/scanph deleted file mode 100755 index 956c2e9b5fe..00000000000 --- a/bfd/doc/scanph +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh -# Script to coordinate parsing of S. Chamberlain source-embedded -# header-file markup language. - -# '-i' option means use *proto-internal* segments, else just *proto* -SFX=p -if [ $1 = "-i" ]; then - SFX=ip - shift -fi - -out=`echo $2 | cut -d '.' -f 1` - -# passes: -# 1) awk discards lines not intended for header, and marks blocks of -# text with comments identifying source file; -# 2) first sed pass interprets Chamberlain markup; -# 3) further sed passes clean up---merging adjacent comments etc. - -awk -f $3/awkscan-$SFX $1 |\ -sed -f $3/sedscript-p |\ -sed -f $3/mergecom-p |\ -sed -f $3/startcom-p |\ -sed -f $3/blins-p |\ -sed -f $3/movecom-p >$out.$SFX diff --git a/bfd/doc/sedscript b/bfd/doc/sedscript deleted file mode 100755 index cc2022ce68c..00000000000 --- a/bfd/doc/sedscript +++ /dev/null @@ -1,85 +0,0 @@ -# SED script for preprocessing embedded doc from source (S. Chamberlain markup) -# middle pass; most of the work is done here. -# -# First, get rid of /*doc* markers; they've done their job in the first pass. -/^\/\*doc\*/d -# -# /*proto* markers may be optionally followed by a *i-style subsubsec, findex -# entry. This will generate empty @findex and @subsubsection entries if -# the *proto* is on a line by itself; third pass removes them. -/^\/\*proto\*/s/^\/\*proto\* *\(.*\)$/@findex \1\ -@subsubsection @code{\1}/ -# -# /*proto-internal* is just like /*proto* from doc point of view. -/^\/\*proto-internal\*/s/^\/\*proto-internal\* *\(.*\)$/@findex \1\ -@subsubsection @code{\1}/ -# -# *i at beginning of line: rest of line is both a subsubsection heading -# and an entry in function index. -/^\*i/s/^\*i *\(.*\)$/@findex \1\ -@subsubsection @code{\1}/ -# -# Two alternative docn block ends, '*/' and '*-*/' on lines by themselves; -# replace by blank lines (for texinfo source readability). -/^\*\/$/c\ - -/^\*-\*\/$/c\ - -# {* and *} are standins for comment markers (originally embedded in .c -# comments)---turn into real comment markers: -s/{\*/\/\*/ -s/\*}/\*\// -# -# '*+++' and '*---' span a block of text that includes both example lines -# (marked by leading '$') and explanatory text (to be italicized). -# Italicize lines lacking '$': -/\*\+\+\+/,/\*---/s/^\([^$].*\)$/@i{\1}/ -# -# We don't need *+++ and *--- markers any more; kill them (trailing marker -# becomes blank line for readability) -/\*\+\+\+/d -/\*---/c\ - -# Any line beginning with '$' is made an example line; third pass later -# coalesces adjacent example blocks. *DO NOT* introduce extra space after -# @end example, so we can spot adjacent ones in third pass. -/^\$/i\ -@example -/^\$/a\ -@end example -# -# In any example line, turn '{' and '}' into '@{' and '@}' -###/^\$/s/{/@{/g -###/^\$/s/}/@}/g -# -# Now delete the '$' markers themselves: -/^\$/s/\$// -# -# *+ and *- delimit large examples to be enclosed in cartouches. -/^\*\+$/c\ -@lisp\ -@c @cartouche -/^\*-$/c\ -@c @end cartouche\ -@end lisp\ - -# '*;' introduces an example which may have a single line or multiple lines; -# it extends until the next semicolon (which is also printed). -# One-line case: (do this first; else second line address for multi-line case -# will include random text til we happen to end a line in a doc comment with -# a semicolon) -/^\*;.*;$/{ -s/^\*;/@example\ -/ -s/;$/;\ -@end example\ -/ -} -# Multi-line case: -/^\*;/,/.*;$/{ -s/^\*;/@example\ -/ -s/;$/;\ -@end example\ -/ -} diff --git a/bfd/doc/sedscript-p b/bfd/doc/sedscript-p deleted file mode 100755 index 1f24900b4cb..00000000000 --- a/bfd/doc/sedscript-p +++ /dev/null @@ -1,63 +0,0 @@ -# SED script for preprocessing embedded headers from source -# (S. Chamberlain markup) -# middle pass; most of the work is done here. -# -# First, get rid of /*proto* markers; they've done their job in the first pass. -# (They remain comment-introducers) -/^\/\*proto\*/s/^\/\*proto\*/\/*/ -/^\/\*proto-internal\*/s/^\/\*proto-internal\*/\/*/ -# -# *-*/ is an alternative (older) comment-block end. Remap for uniformity: -s/^\*-\*\//\*\// -# -# {* and *} are standins for comment markers (originally embedded in .c -# comments)---turn into real comment markers: -s/{\*/\/\*/ -s/\*}/\*\// -# -# '*+++' and '*---' span a block of text that includes both header lines -# (marked by leading '$') and explanatory text (to be comments). -# No need to start comment at "*+++", or end it at "*---", since we're -# already in a *proto* comment block. Just delete. -/\*\+\+\+/d -/\*---/d -# -# Any line beginning with '$' is made a line of code in the header; -# stuff in between is comments, so *precede* each '$' line with -# END-comment, *follow* each '$' line with START-comment; third pass later -# eliminates empty comment blocks. -/^\$/i\ -*/ -/^\$/a\ -/* -# -# Now delete the '$' markers themselves: -/^\$/s/\$// -# -# *+ and *- delimit larger blocks of code, treated the same as '$' lines -/^\*\+$/c\ -*/ -/^\*-$/c\ -/* -# -# '*;' introduces code which may have a single line or multiple lines; -# it extends until the next semicolon (which is also printed). -# -# One-line case: (do this first; else second line address for multi-line case -# will include random text til we happen to end a line in a proto comment with -# a semicolon) -/^\*;.*;$/{ -s/^\*;/*\/\ -/ -s/;$/;\ -\/*\ -/ -} -# Multi-line case: -/^\*;/,/.*;$/{ -s/^\*;/*\/\ -/ -s/;$/;\ -\/*\ -/ -} diff --git a/bfd/doc/startcom-p b/bfd/doc/startcom-p deleted file mode 100755 index 0748faddbf7..00000000000 --- a/bfd/doc/startcom-p +++ /dev/null @@ -1,12 +0,0 @@ -# sed script for preprocessing BFD header files -# activity: -/^\/\*$/{ -N -# Delete empty comment blocks -/^\/\*\n\*\/ *$/d -# Transpose -s/^\/\*\n *$/\ -\/*/ -# merge on line by itself with following line -s/^\/\*\n\(.*\)/\/* \1/ -} diff --git a/bfd/doc/tolibbfd b/bfd/doc/tolibbfd deleted file mode 100755 index 3caa5eb2196..00000000000 --- a/bfd/doc/tolibbfd +++ /dev/null @@ -1,10 +0,0 @@ -/---------------START FROM/,/---------------END FROM/d -/\/\*:init.c\*\//r init.ip -/\/\*:libbfd.c\*\//r libbfd.ip -/\/\*:cache.c\*\//r cache.ip -/\/\*:cpu-h8300.c\*\//r cpu-h8300.ip -/\/\*:cpu-i960.c\*\//r cpu-i960.ip -/\/\*:cpu-empty.c\*\//r cpu-empty.ip -/\/\*:archures.c\*\//r archures.ip -/\/\*:reloc.c\*\//r reloc.ip -/\/\*:ctor.c\*\//r ctor.ip diff --git a/bfd/doc/tolibcoff b/bfd/doc/tolibcoff deleted file mode 100755 index 548c8baa59c..00000000000 --- a/bfd/doc/tolibcoff +++ /dev/null @@ -1 +0,0 @@ -/\/\*:coffcode.h\*\//r coffcode.p diff --git a/bfd/doc/unPROTO b/bfd/doc/unPROTO deleted file mode 100755 index a6f95207dba..00000000000 --- a/bfd/doc/unPROTO +++ /dev/null @@ -1,18 +0,0 @@ -# -# The PROTO macro is a subterfuge to be compatible with both ANSI and K&R -# declaration syntax. It's not widely known, so for the docn just map the -# thing to ANSI declaration syntax. -# -# First, join up defns broken across multiple lines in source---but leave -# any linebreaks, to prettify our examples -:pbegn -/PROTO(.*, *$/N -s/\n/?/ -t pbegn -s/?/\ -/g -# Now actually do the PROTO interpretation. -# A PROTO invocation looks like -# PROTO( resulttype, function, (arglist)); -s/[ ]*PROTO(\(.*\),[\n ]*\(.*\),[\n ]*\((.*)\));/\1 \2\3;/ - diff --git a/bfd/elf.c b/bfd/elf.c deleted file mode 100644 index bd62645c61e..00000000000 --- a/bfd/elf.c +++ /dev/null @@ -1,860 +0,0 @@ -/* ELF support for BFD. - Copyright (C) 1991 Free Software Foundation, Inc. - - Written by Fred Fish @ Cygnus Support, from information published - in "UNIX System V Release 4, Programmers Guide: ANSI C and - Programming Support Tools". - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - - - /**************************************** - - WARNING - - This is only a partial ELF implementation, - incorporating only those parts that are - required to get gdb up and running. It is - expected that it will be expanded to a full - ELF implementation at some future date. - - Unimplemented stubs call abort() to ensure - that they get proper attention if they are - ever called. The stubs are here since - this version was hacked from the COFF - version, and thus they will probably - go away or get expanded appropriately in a - future version. - - fnf@cygnus.com - - *****************************************/ - - -/* Problems and other issues to resolve. - - (1) BFD expects there to be some fixed number of "sections" in - the object file. I.E. there is a "section_count" variable in the - bfd structure which contains the number of sections. However, ELF - supports multiple "views" of a file. In particular, with current - implementations, executable files typically have two tables, a - program header table and a section header table, both of which - partition the executable. - - In ELF-speak, the "linking view" of the file uses the section header - table to access "sections" within the file, and the "execution view" - uses the program header table to access "segments" within the file. - "Segments" typically may contain all the data from one or more - "sections". - - Note that the section header table is optional in ELF executables, - but it is this information that is most useful to gdb. If the - section header table is missing, then gdb should probably try - to make do with the program header table. (FIXME) - -*/ - -#include "bfd.h" -#include "sysdep.h" -#include "libbfd.h" -#include "obstack.h" -#include "elf-common.h" -#include "elf-internal.h" -#include "elf-external.h" - -/* Forward data declarations */ -extern bfd_target elf_little_vec, elf_big_vec; - -/* Translate an ELF header in external format into an ELF header in internal - format. */ - -static void -DEFUN(bfd_swap_ehdr_in,(abfd, src, dst), - bfd *abfd AND - Elf_External_Ehdr *src AND - Elf_Internal_Ehdr *dst) -{ - bcopy (src -> e_ident, dst -> e_ident, EI_NIDENT); - dst -> e_type = bfd_h_get_16 (abfd, (bfd_byte *) src -> e_type); - dst -> e_machine = bfd_h_get_16 (abfd, (bfd_byte *) src -> e_machine); - dst -> e_version = bfd_h_get_32 (abfd, (bfd_byte *) src -> e_version); - dst -> e_entry = bfd_h_get_32 (abfd, (bfd_byte *) src -> e_entry); - dst -> e_phoff = bfd_h_get_32 (abfd, (bfd_byte *) src -> e_phoff); - dst -> e_shoff = bfd_h_get_32 (abfd, (bfd_byte *) src -> e_shoff); - dst -> e_flags = bfd_h_get_32 (abfd, (bfd_byte *) src -> e_flags); - dst -> e_ehsize = bfd_h_get_16 (abfd, (bfd_byte *) src -> e_ehsize); - dst -> e_phentsize = bfd_h_get_16 (abfd, (bfd_byte *) src -> e_phentsize); - dst -> e_phnum = bfd_h_get_16 (abfd, (bfd_byte *) src -> e_phnum); - dst -> e_shentsize = bfd_h_get_16 (abfd, (bfd_byte *) src -> e_shentsize); - dst -> e_shnum = bfd_h_get_16 (abfd, (bfd_byte *) src -> e_shnum); - dst -> e_shstrndx = bfd_h_get_16 (abfd, (bfd_byte *) src -> e_shstrndx); -} - - -/* Translate an ELF section header table entry in external format into an - ELF section header table entry in internal format. */ - -static void -DEFUN(bfd_swap_shdr_in,(abfd, src, dst), - bfd *abfd AND - Elf_External_Shdr *src AND - Elf_Internal_Shdr *dst) -{ - dst -> sh_name = bfd_h_get_32 (abfd, (bfd_byte *) src -> sh_name); - dst -> sh_type = bfd_h_get_32 (abfd, (bfd_byte *) src -> sh_type); - dst -> sh_flags = bfd_h_get_32 (abfd, (bfd_byte *) src -> sh_flags); - dst -> sh_addr = bfd_h_get_32 (abfd, (bfd_byte *) src -> sh_addr); - dst -> sh_offset = bfd_h_get_32 (abfd, (bfd_byte *) src -> sh_offset); - dst -> sh_size = bfd_h_get_32 (abfd, (bfd_byte *) src -> sh_size); - dst -> sh_link = bfd_h_get_32 (abfd, (bfd_byte *) src -> sh_link); - dst -> sh_info = bfd_h_get_32 (abfd, (bfd_byte *) src -> sh_info); - dst -> sh_addralign = bfd_h_get_32 (abfd, (bfd_byte *) src -> sh_addralign); - dst -> sh_entsize = bfd_h_get_32 (abfd, (bfd_byte *) src -> sh_entsize); -} - - -/* Translate an ELF program header table entry in external format into an - ELF program header table entry in internal format. */ - -static void -DEFUN(bfd_swap_phdr_in,(abfd, src, dst), - bfd *abfd AND - Elf_External_Phdr *src AND - Elf_Internal_Phdr *dst) -{ - dst -> p_type = bfd_h_get_32 (abfd, (bfd_byte *) src -> p_type); - dst -> p_offset = bfd_h_get_32 (abfd, (bfd_byte *) src -> p_offset); - dst -> p_vaddr = bfd_h_get_32 (abfd, (bfd_byte *) src -> p_vaddr); - dst -> p_paddr = bfd_h_get_32 (abfd, (bfd_byte *) src -> p_paddr); - dst -> p_filesz = bfd_h_get_32 (abfd, (bfd_byte *) src -> p_filesz); - dst -> p_memsz = bfd_h_get_32 (abfd, (bfd_byte *) src -> p_memsz); - dst -> p_flags = bfd_h_get_32 (abfd, (bfd_byte *) src -> p_flags); - dst -> p_align = bfd_h_get_32 (abfd, (bfd_byte *) src -> p_align); -} - - -/* Create a new bfd section from an ELF section header. */ - -static boolean -DEFUN(bfd_section_from_shdr, (abfd, hdr, shstrtab), - bfd *abfd AND - Elf_Internal_Shdr *hdr AND - char *shstrtab) -{ - asection *newsect; - char *name; - - name = hdr -> sh_name ? shstrtab + hdr -> sh_name : "unnamed"; - newsect = bfd_make_section (abfd, name); - newsect -> vma = hdr -> sh_addr; - newsect -> size = hdr -> sh_size; - if (!(hdr -> sh_type == SHT_NOBITS)) - { - newsect -> filepos = hdr -> sh_offset; - newsect -> flags |= SEC_HAS_CONTENTS; - } - if (hdr -> sh_flags & SHF_ALLOC) - { - newsect -> flags |= SEC_ALLOC; - if (hdr -> sh_type != SHT_NOBITS) - { - newsect -> flags |= SEC_LOAD; - } - } - if (!(hdr -> sh_flags & SHF_WRITE)) - { - newsect -> flags |= SEC_READONLY; - } - if (hdr -> sh_flags & SHF_EXECINSTR) - { - newsect -> flags |= SEC_CODE; /* FIXME: may only contain SOME code */ - } - if (hdr -> sh_type == SHT_SYMTAB) - { - abfd -> flags |= HAS_SYMS; - } - - return (true); -} - -/* Create a new bfd section from an ELF program header. - - Since program segments have no names, we generate a synthetic name - of the form segment, where NUM is generally the index in the - program header table. For segments that are split (see below) we - generate the names segmenta and segmentb. - - Note that some program segments may have a file size that is different than - (less than) the memory size. All this means is that at execution the - system must allocate the amount of memory specified by the memory size, - but only initialize it with the first "file size" bytes read from the - file. This would occur for example, with program segments consisting - of combined data+bss. - - To handle the above situation, this routine generates TWO bfd sections - for the single program segment. The first has the length specified by - the file size of the segment, and the second has the length specified - by the difference between the two sizes. In effect, the segment is split - into it's initialized and uninitialized parts. - - */ - -static boolean -DEFUN(bfd_section_from_phdr, (abfd, hdr, index), - bfd *abfd AND - Elf_Internal_Phdr *hdr AND - int index) -{ - asection *newsect; - char *name; - char namebuf[64]; - int split; - - split = ((hdr -> p_memsz > 0) && - (hdr -> p_filesz > 0) && - (hdr -> p_memsz > hdr -> p_filesz)); - sprintf (namebuf, split ? "segment%da" : "segment%d", index); - name = bfd_alloc (abfd, strlen (namebuf) + 1); - (void) strcpy (name, namebuf); - newsect = bfd_make_section (abfd, name); - newsect -> vma = hdr -> p_vaddr; - newsect -> size = hdr -> p_filesz; - newsect -> filepos = hdr -> p_offset; - newsect -> flags |= SEC_HAS_CONTENTS; - if (hdr -> p_type == PT_LOAD) - { - newsect -> flags |= SEC_ALLOC; - newsect -> flags |= SEC_LOAD; - if (hdr -> p_flags & PF_X) - { - /* FIXME: all we known is that it has execute PERMISSION, - may be data. */ - newsect -> flags |= SEC_CODE; - } - } - if (!(hdr -> p_flags & PF_W)) - { - newsect -> flags |= SEC_READONLY; - } - - if (split) - { - sprintf (namebuf, "segment%db", index); - name = bfd_alloc (abfd, strlen (namebuf) + 1); - (void) strcpy (name, namebuf); - newsect = bfd_make_section (abfd, name); - newsect -> vma = hdr -> p_vaddr + hdr -> p_filesz; - newsect -> size = hdr -> p_memsz - hdr -> p_filesz; - if (hdr -> p_type == PT_LOAD) - { - newsect -> flags |= SEC_ALLOC; - if (hdr -> p_flags & PF_X) - { - newsect -> flags |= SEC_CODE; - } - } - if (!(hdr -> p_flags & PF_W)) - { - newsect -> flags |= SEC_READONLY; - } - } - - return (true); -} - -/* Begin processing a given object. - - First we validate the file by reading in the ELF header and checking - the magic number. - - */ - -static bfd_target * -DEFUN (elf_object_p, (abfd), bfd *abfd) -{ - Elf_External_Ehdr x_ehdr; /* Elf file header, external form */ - Elf_Internal_Ehdr i_ehdr; /* Elf file header, internal form */ - Elf_External_Shdr *x_shdr; /* Section header table, external form */ - Elf_Internal_Shdr *i_shdr; /* Section header table, internal form */ - int shindex; - char *shstrtab; /* Internal copy of section header stringtab */ - int shstrtabsize; /* Size of section header string table */ - - /* Read in the ELF header in external format. */ - - if (bfd_read ((PTR) &x_ehdr, sizeof (x_ehdr), 1, abfd) != sizeof (x_ehdr)) - { - bfd_error = system_call_error; - return (NULL); - } - - /* Now check to see if we have a valid ELF file, and one that BFD can - make use of. The magic number must match, the address size ('class') - and byte-swapping must match our XVEC entry, and it must have a - section header table (FIXME: See comments re sections at top of this - file). */ - - if (x_ehdr.e_ident[EI_MAG0] != ELFMAG0 || - x_ehdr.e_ident[EI_MAG1] != ELFMAG1 || - x_ehdr.e_ident[EI_MAG2] != ELFMAG2 || - x_ehdr.e_ident[EI_MAG3] != ELFMAG3) - { -wrong: - bfd_error = wrong_format; - return (NULL); - } - - /* FIXME, Check EI_VERSION here ! */ - - switch (x_ehdr.e_ident[EI_CLASS]) { - case ELFCLASSNONE: /* address size not specified */ - goto wrong; /* No support if can't tell address size */ - case ELFCLASS32: /* 32-bit addresses */ - break; - case ELFCLASS64: /* 64-bit addresses */ - goto wrong; /* FIXME: 64 bits not yet supported */ - default: - goto wrong; /* No support if unknown address class */ - } - - /* Switch xvec to match the specified byte order. */ - switch (x_ehdr.e_ident[EI_DATA]) { - case ELFDATA2MSB: /* Big-endian */ - abfd->xvec = &elf_big_vec; - break; - case ELFDATA2LSB: /* Little-endian */ - abfd->xvec = &elf_little_vec; - case ELFDATANONE: /* No data encoding specified */ - default: /* Unknown data encoding specified */ - goto wrong; - } - - /* Now that we know the byte order, swap in the rest of the header */ - bfd_swap_ehdr_in (abfd, &x_ehdr, &i_ehdr); - - /* If there is no section header table, we're hosed. */ - if (i_ehdr.e_shoff == 0) - goto wrong; - - if (i_ehdr.e_type == ET_EXEC || i_ehdr.e_type == ET_DYN) - { - abfd -> flags |= EXEC_P; - } - - /* Allocate space for copies of the section header table in external - and internal form, seek to the section header table in the file, - read it in, and convert it to internal form. As a simple sanity - check, verify that the what BFD thinks is the size of each section - header table entry actually matches the size recorded in the file. */ - - if (i_ehdr.e_shentsize != sizeof (*x_shdr)) - goto wrong; - if ((x_shdr = (Elf_External_Shdr *) - bfd_alloc (abfd, sizeof (*x_shdr) * i_ehdr.e_shnum)) == NULL) - { - bfd_error = no_memory; - return (NULL); - } - if ((i_shdr = (Elf_Internal_Shdr *) - bfd_alloc (abfd, sizeof (*i_shdr) * i_ehdr.e_shnum)) == NULL) - { - bfd_error = no_memory; - return (NULL); - } - if (bfd_seek (abfd, i_ehdr.e_shoff, SEEK_SET) == -1) - { - bfd_error = system_call_error; - return (NULL); - } - for (shindex = 0; shindex < i_ehdr.e_shnum; shindex++) - { - if (bfd_read ((PTR) (x_shdr + shindex), sizeof (*x_shdr), 1, abfd) - != sizeof (*x_shdr)) - { - bfd_error = system_call_error; - return (NULL); - } - bfd_swap_shdr_in (abfd, x_shdr + shindex, i_shdr + shindex); - } - - /* Read in the string table containing the names of the sections. We - will need the base pointer to this table later. */ - - shstrtabsize = i_shdr[i_ehdr.e_shstrndx].sh_size; - if ((shstrtab = bfd_alloc (abfd, shstrtabsize)) == NULL) - { - bfd_error = no_memory; - return (NULL); - } - if (bfd_seek (abfd, i_shdr[i_ehdr.e_shstrndx].sh_offset, SEEK_SET) == -1) - { - bfd_error = system_call_error; - return (NULL); - } - if (bfd_read ((PTR) shstrtab, shstrtabsize, 1, abfd) != shstrtabsize) - { - bfd_error = system_call_error; - return (NULL); - } - - /* Once all of the section headers have been read and converted, we - can start processing them. Note that the first section header is - a dummy placeholder entry, so we ignore it. */ - - for (shindex = 1; shindex < i_ehdr.e_shnum; shindex++) - { - bfd_section_from_shdr (abfd, i_shdr + shindex, shstrtab); - } - - return (abfd->xvec); -} - -/* Core files are simply standard ELF formatted files that partition - the file using the execution view of the file (program header table) - rather than the linking view. In fact, there is no section header - table in a core file. - */ - -static bfd_target * -DEFUN (elf_core_file_p, (abfd), bfd *abfd) -{ - Elf_External_Ehdr x_ehdr; /* Elf file header, external form */ - Elf_Internal_Ehdr i_ehdr; /* Elf file header, internal form */ - Elf_External_Phdr *x_phdr; /* Program header table, external form */ - Elf_Internal_Phdr *i_phdr; /* Program header table, internal form */ - int phindex; - - /* Read in the ELF header in external format. */ - - if (bfd_read ((PTR) &x_ehdr, sizeof (x_ehdr), 1, abfd) != sizeof (x_ehdr)) - { - bfd_error = system_call_error; - return (NULL); - } - - /* Now check to see if we have a valid ELF file, and one that BFD can - make use of. The magic number must match, the address size ('class') - and byte-swapping must match our XVEC entry, and it must have a - program header table (FIXME: See comments re segments at top of this - file). */ - - if (x_ehdr.e_ident[EI_MAG0] != ELFMAG0 || - x_ehdr.e_ident[EI_MAG1] != ELFMAG1 || - x_ehdr.e_ident[EI_MAG2] != ELFMAG2 || - x_ehdr.e_ident[EI_MAG3] != ELFMAG3) - { -wrong: - bfd_error = wrong_format; - return (NULL); - } - - /* FIXME, Check EI_VERSION here ! */ - - switch (x_ehdr.e_ident[EI_CLASS]) { - case ELFCLASSNONE: /* address size not specified */ - goto wrong; /* No support if can't tell address size */ - case ELFCLASS32: /* 32-bit addresses */ - break; - case ELFCLASS64: /* 64-bit addresses */ - goto wrong; /* FIXME: 64 bits not yet supported */ - default: - goto wrong; /* No support if unknown address class */ - } - - /* Switch xvec to match the specified byte order. */ - switch (x_ehdr.e_ident[EI_DATA]) { - case ELFDATA2MSB: /* Big-endian */ - abfd->xvec = &elf_big_vec; - break; - case ELFDATA2LSB: /* Little-endian */ - abfd->xvec = &elf_little_vec; - case ELFDATANONE: /* No data encoding specified */ - default: /* Unknown data encoding specified */ - goto wrong; - } - - /* Now that we know the byte order, swap in the rest of the header */ - bfd_swap_ehdr_in (abfd, &x_ehdr, &i_ehdr); - - /* If there is no program header, or the type is not a core file, then - we are hosed. */ - if (i_ehdr.e_phoff == 0 || i_ehdr.e_type != ET_CORE) - goto wrong; - - /* Allocate space for copies of the program header table in external - and internal form, seek to the program header table in the file, - read it in, and convert it to internal form. As a simple sanity - check, verify that the what BFD thinks is the size of each program - header table entry actually matches the size recorded in the file. */ - - if (i_ehdr.e_phentsize != sizeof (*x_phdr)) - goto wrong; - if ((x_phdr = (Elf_External_Phdr *) - bfd_alloc (abfd, sizeof (*x_phdr) * i_ehdr.e_phnum)) == NULL) - { - bfd_error = no_memory; - return (NULL); - } - if ((i_phdr = (Elf_Internal_Phdr *) - bfd_alloc (abfd, sizeof (*i_phdr) * i_ehdr.e_phnum)) == NULL) - { - bfd_error = no_memory; - return (NULL); - } - if (bfd_seek (abfd, i_ehdr.e_phoff, SEEK_SET) == -1) - { - bfd_error = system_call_error; - return (NULL); - } - for (phindex = 0; phindex < i_ehdr.e_phnum; phindex++) - { - if (bfd_read ((PTR) (x_phdr + phindex), sizeof (*x_phdr), 1, abfd) - != sizeof (*x_phdr)) - { - bfd_error = system_call_error; - return (NULL); - } - bfd_swap_phdr_in (abfd, x_phdr + phindex, i_phdr + phindex); - } - - /* Once all of the program headers have been read and converted, we - can start processing them. */ - - for (phindex = 0; phindex < i_ehdr.e_phnum; phindex++) - { - bfd_section_from_phdr (abfd, i_phdr + phindex, phindex); - } - - return (abfd->xvec); -} - -static boolean -DEFUN (elf_mkobject, (abfd), bfd *abfd) -{ - fprintf (stderr, "elf_mkobject unimplemented\n"); - fflush (stderr); - abort (); - return (false); -} - -static boolean -DEFUN (elf_write_object_contents, (abfd), bfd *abfd) -{ - fprintf (stderr, "elf_write_object_contents unimplemented\n"); - fflush (stderr); - abort (); - return (false); -} - -static unsigned int -elf_get_symtab_upper_bound(abfd) -bfd *abfd; -{ - fprintf (stderr, "elf_get_symtab_upper_bound unimplemented\n"); - fflush (stderr); - abort (); - return (0); -} - -static unsigned int -elf_get_reloc_upper_bound (abfd, asect) -bfd *abfd; -sec_ptr asect; -{ - fprintf (stderr, "elf_get_reloc_upper_bound unimplemented\n"); - fflush (stderr); - abort (); - return (0); -} - -static unsigned int -elf_canonicalize_reloc (abfd, section, relptr, symbols) -bfd *abfd; -sec_ptr section; -arelent **relptr; -asymbol **symbols; -{ - fprintf (stderr, "elf_canonicalize_reloc unimplemented\n"); - fflush (stderr); - abort (); - return (0); -} - -static unsigned int -elf_get_symtab (abfd, alocation) -bfd *abfd; -asymbol **alocation; -{ - fprintf (stderr, "elf_get_symtab unimplemented\n"); - fflush (stderr); - abort (); - return (0); -} - -static asymbol * -elf_make_empty_symbol(abfd) -bfd *abfd; -{ - fprintf (stderr, "elf_make_empty_symbol unimplemented\n"); - fflush (stderr); - abort (); - return (NULL); -} - -static void -DEFUN (elf_print_symbol,(ignore_abfd, filep, symbol, how), - bfd *ignore_abfd AND - PTR filep AND - asymbol *symbol AND - bfd_print_symbol_type how) -{ - fprintf (stderr, "elf_print_symbol unimplemented\n"); - fflush (stderr); - abort (); -} - -static alent * -DEFUN (elf_get_lineno,(ignore_abfd, symbol), - bfd *ignore_abfd AND - asymbol *symbol) -{ - fprintf (stderr, "elf_get_lineno unimplemented\n"); - fflush (stderr); - abort (); - return (NULL); -} - -static boolean -DEFUN (elf_set_arch_mach,(abfd, arch, machine), - bfd *abfd AND - enum bfd_architecture arch AND - unsigned long machine) -{ - fprintf (stderr, "elf_set_arch_mach unimplemented\n"); - fflush (stderr); - /* Allow any architecture to be supported by the elf backend */ - return bfd_default_set_arch_mach(abfd, arch, machine); -} - -static boolean -DEFUN (elf_find_nearest_line,(abfd, - section, - symbols, - offset, - filename_ptr, - functionname_ptr, - line_ptr), - bfd *abfd AND - asection *section AND - asymbol **symbols AND - bfd_vma offset AND - CONST char **filename_ptr AND - CONST char **functionname_ptr AND - unsigned int *line_ptr) -{ - fprintf (stderr, "elf_find_nearest_line unimplemented\n"); - fflush (stderr); - abort (); - return (false); -} - -static int -DEFUN (elf_sizeof_headers, (abfd, reloc), - bfd *abfd AND - boolean reloc) -{ - fprintf (stderr, "elf_sizeof_headers unimplemented\n"); - fflush (stderr); - abort (); - return (0); -} - -/* This structure contains everything that BFD knows about a target. - It includes things like its byte order, name, what routines to call - to do various operations, etc. Every BFD points to a target structure - with its "xvec" member. - - There are two such structures here: one for big-endian machines and - one for little-endian machines. */ - -#define elf_core_file_failing_command _bfd_dummy_core_file_failing_command -#define elf_core_file_failing_signal _bfd_dummy_core_file_failing_signal -#define elf_core_file_matches_executable_p _bfd_dummy_core_file_matches_executable_p - -/* Archives are generic or unimplemented. */ -#define elf_slurp_armap bfd_false -#define elf_slurp_extended_name_table _bfd_slurp_extended_name_table -#define elf_truncate_arname bfd_dont_truncate_arname -#define elf_openr_next_archived_file bfd_generic_openr_next_archived_file -#define elf_generic_stat_arch_elt bfd_generic_stat_arch_elt -#define elf_write_armap (PROTO (boolean, (*), \ - (bfd *arch, unsigned int elength, struct orl *map, unsigned int orl_count, \ - int stridx))) bfd_false - -/* Ordinary section reading and writing */ -#define elf_new_section_hook _bfd_dummy_new_section_hook -#define elf_get_section_contents bfd_generic_get_section_contents -#define elf_set_section_contents bfd_generic_set_section_contents -#define elf_close_and_cleanup bfd_generic_close_and_cleanup - -#define elf_bfd_debug_info_start bfd_void -#define elf_bfd_debug_info_end bfd_void -#define elf_bfd_debug_info_accumulate (PROTO(void,(*),(bfd*, struct sec *))) bfd_void - -bfd_target elf_big_vec = -{ - /* name: identify kind of target */ - "elf-big", - - /* flavour: general indication about file */ - bfd_target_elf_flavour, - - /* byteorder_big_p: data is big endian */ - true, - - /* header_byteorder_big_p: header is also big endian */ - true, - - /* object_flags: mask of all file flags */ - (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS | - DYNAMIC | WP_TEXT), - - /* section_flags: mask of all section flags */ - (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_READONLY | - SEC_DATA), - - /* ar_pad_char: pad character for filenames within an archive header - FIXME: this really has nothing to do with ELF, this is a characteristic - of the archiver and/or os and should be independently tunable */ - '/', - - /* 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) */ - 15, - - /* align_power_min: minimum alignment restriction for any section - FIXME: this value may be target machine dependent */ - 3, - - /* Routines to byte-swap various sized integers from the data sections */ - _do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, - - /* Routines to byte-swap various sized integers from the file headers */ - _do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, - - /* bfd_check_format: check the format of a file being read */ - { _bfd_dummy_target, /* unknown format */ - elf_object_p, /* assembler/linker output (object file) */ - bfd_generic_archive_p, /* an archive */ - elf_core_file_p /* a core file */ - }, - - /* bfd_set_format: set the format of a file being written */ - { bfd_false, - elf_mkobject, - _bfd_generic_mkarchive, - bfd_false - }, - - /* bfd_write_contents: write cached information into a file being written */ - { bfd_false, - elf_write_object_contents, - _bfd_write_archive_contents, - bfd_false - }, - - /* Initialize a jump table with the standard macro. All names start - with "elf" */ - JUMP_TABLE(elf), - - /* SWAP_TABLE */ - NULL, NULL, NULL -}; - -bfd_target elf_little_vec = -{ - /* name: identify kind of target */ - "elf-little", - - /* flavour: general indication about file */ - bfd_target_elf_flavour, - - /* byteorder_big_p: data is big endian */ - false, /* Nope -- this one's little endian */ - - /* header_byteorder_big_p: header is also big endian */ - false, /* Nope -- this one's little endian */ - - /* object_flags: mask of all file flags */ - (HAS_RELOC | EXEC_P | HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS | - DYNAMIC | WP_TEXT), - - /* section_flags: mask of all section flags */ - (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_READONLY | - SEC_DATA), - - /* ar_pad_char: pad character for filenames within an archive header - FIXME: this really has nothing to do with ELF, this is a characteristic - of the archiver and/or os and should be independently tunable */ - '/', - - /* 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) */ - 15, - - /* align_power_min: minimum alignment restriction for any section - FIXME: this value may be target machine dependent */ - 3, - - /* Routines to byte-swap various sized integers from the data sections */ - _do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putl16, - - /* Routines to byte-swap various sized integers from the file headers */ - _do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putl16, - - /* bfd_check_format: check the format of a file being read */ - { _bfd_dummy_target, /* unknown format */ - elf_object_p, /* assembler/linker output (object file) */ - bfd_generic_archive_p, /* an archive */ - elf_core_file_p /* a core file */ - }, - - /* bfd_set_format: set the format of a file being written */ - { bfd_false, - elf_mkobject, - _bfd_generic_mkarchive, - bfd_false - }, - - /* bfd_write_contents: write cached information into a file being written */ - { bfd_false, - elf_write_object_contents, - _bfd_write_archive_contents, - bfd_false - }, - - /* Initialize a jump table with the standard macro. All names start - with "elf" */ - JUMP_TABLE(elf), - - /* SWAP_TABLE */ - NULL, NULL, NULL -}; diff --git a/bfd/exfilter b/bfd/exfilter deleted file mode 100755 index 7551607763d..00000000000 --- a/bfd/exfilter +++ /dev/null @@ -1,14 +0,0 @@ -# SED script for preprocessing embedded doc from source (S. Chamberlain markup) -# Final pass; cleanup work is done here. -# -# Within examples, make '{' and '}' printable: -/^@lisp$/,/^@end lisp$/s/{/@{/ -/^@lisp$/,/^@end lisp$/s/}/@}/ -/^@example$/,/^@end example$/s/{/@{/ -/^@example$/,/^@end example$/s/}/@}/ -# -# Delete empty @findex and @subsubsection entries (resulting from *proto* -# with no further text on same line, in middle pass) -/^@findex $/d -/^@subsubsection @code{}/d -# diff --git a/bfd/exmerge b/bfd/exmerge deleted file mode 100755 index dafa4244dff..00000000000 --- a/bfd/exmerge +++ /dev/null @@ -1,4 +0,0 @@ -# SED script for preprocessing embedded doc from source (S. Chamberlain markup) -# Locate and coalesce adjacent @example blocks -/^@end example/N -/^@end example\n@example$/d diff --git a/bfd/filemode.c b/bfd/filemode.c deleted file mode 100644 index d53cef11d34..00000000000 --- a/bfd/filemode.c +++ /dev/null @@ -1,193 +0,0 @@ -/* filemode.c -- make a string describing file modes - Copyright (C) 1985, 1990 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include - -void mode_string (); -static char ftypelet (); -static void rwx (); -static void setst (); - -/* filemodestring - fill in string STR with an ls-style ASCII - representation of the st_mode field of file stats block STATP. - 10 characters are stored in STR; no terminating null is added. - The characters stored in STR are: - - 0 File type. 'd' for directory, 'c' for character - special, 'b' for block special, 'm' for multiplex, - 'l' for symbolic link, 's' for socket, 'p' for fifo, - '-' for any other file type - - 1 'r' if the owner may read, '-' otherwise. - - 2 'w' if the owner may write, '-' otherwise. - - 3 'x' if the owner may execute, 's' if the file is - set-user-id, '-' otherwise. - 'S' if the file is set-user-id, but the execute - bit isn't set. - - 4 'r' if group members may read, '-' otherwise. - - 5 'w' if group members may write, '-' otherwise. - - 6 'x' if group members may execute, 's' if the file is - set-group-id, '-' otherwise. - 'S' if it is set-group-id but not executable. - - 7 'r' if any user may read, '-' otherwise. - - 8 'w' if any user may write, '-' otherwise. - - 9 'x' if any user may execute, 't' if the file is "sticky" - (will be retained in swap space after execution), '-' - otherwise. - 'T' if the file is sticky but not executable. */ - -void -filemodestring (statp, str) - struct stat *statp; - char *str; -{ - mode_string (statp->st_mode, str); -} - -/* Like filemodestring, but only the relevant part of the `struct stat' - is given as an argument. */ - -void -mode_string (mode, str) - unsigned short mode; - char *str; -{ - str[0] = ftypelet (mode); - rwx ((mode & 0700) << 0, &str[1]); - rwx ((mode & 0070) << 3, &str[4]); - rwx ((mode & 0007) << 6, &str[7]); - setst (mode, str); -} - -/* Return a character indicating the type of file described by - file mode BITS: - 'd' for directories - 'b' for block special files - 'c' for character special files - 'm' for multiplexor files - 'l' for symbolic links - 's' for sockets - 'p' for fifos - '-' for any other file type. */ - -static char -ftypelet (bits) - unsigned short bits; -{ - switch (bits & S_IFMT) - { - default: - return '-'; - case S_IFDIR: - return 'd'; -#ifdef S_IFLNK - case S_IFLNK: - return 'l'; -#endif -#ifdef S_IFCHR - case S_IFCHR: - return 'c'; -#endif -#ifdef S_IFBLK - case S_IFBLK: - return 'b'; -#endif -#ifdef S_IFMPC - case S_IFMPC: - case S_IFMPB: - return 'm'; -#endif -#ifdef S_IFSOCK - case S_IFSOCK: - return 's'; -#endif -#ifdef S_IFIFO -#if S_IFIFO != S_IFSOCK - case S_IFIFO: - return 'p'; -#endif -#endif -#ifdef S_IFNWK /* HP-UX */ - case S_IFNWK: - return 'n'; -#endif - } -} - -/* Look at read, write, and execute bits in BITS and set - flags in CHARS accordingly. */ - -static void -rwx (bits, chars) - unsigned short bits; - char *chars; -{ - chars[0] = (bits & S_IREAD) ? 'r' : '-'; - chars[1] = (bits & S_IWRITE) ? 'w' : '-'; - chars[2] = (bits & S_IEXEC) ? 'x' : '-'; -} - -/* Set the 's' and 't' flags in file attributes string CHARS, - according to the file mode BITS. */ - -static void -setst (bits, chars) - unsigned short bits; - char *chars; -{ -#ifdef S_ISUID - if (bits & S_ISUID) - { - if (chars[3] != 'x') - /* Set-uid, but not executable by owner. */ - chars[3] = 'S'; - else - chars[3] = 's'; - } -#endif -#ifdef S_ISGID - if (bits & S_ISGID) - { - if (chars[6] != 'x') - /* Set-gid, but not executable by group. */ - chars[6] = 'S'; - else - chars[6] = 's'; - } -#endif -#ifdef S_ISVTX - if (bits & S_ISVTX) - { - if (chars[9] != 'x') - /* Sticky, but not executable by others. */ - chars[9] = 'T'; - else - chars[9] = 't'; - } -#endif -} - - diff --git a/bfd/format.c b/bfd/format.c deleted file mode 100644 index 2dfc2934f20..00000000000 --- a/bfd/format.c +++ /dev/null @@ -1,214 +0,0 @@ -/* Generic BFD support for file formats. - Copyright (C) 1990-1991 Free Software Foundation, Inc. - Written by Cygnus Support. - -This file is part of BFD, the Binary File Descriptor library. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/*doc* -@section File Formats -A format is a BFD concept of high level file contents. The -formats supported by BFD are: -@table @code -@item bfd_object -The BFD may contain data, symbols, relocations and debug info. -@item bfd_archive -The BFD contains other BFDs and an optional index. -@item bfd_core -The BFD contains the result of an executable core dump. -@end table -*/ -#include "sysdep.h" -#include "bfd.h" -#include "libbfd.h" - - -extern bfd_target *target_vector[]; -extern bfd_target *default_vector[]; - - -/*proto* -*i bfd_check_format -This routine is supplied a BFD and a format. It attempts to verify if -the file attatched to the BFD is indeed compatible with the format -specified (ie, one of @code{bfd_object}, @code{bfd_archive} or -@code{bfd_core}). - -If the BFD has been set to a specific @var{target} before the call, -only the named target and format combination will be checked. If the -target has not been set, or has been set to @code{default} then all -the known target backends will be interrogated to determine a match. - -The function returns @code{true} on success, otherwise @code{false} -with one of the following error codes: -@table @code -@item -invalid_operation -if @code{format} is not one of @code{bfd_object}, @code{bfd_archive} -or @code{bfd_core}. -@item system_call_error -if an error occured during a read - even some file mismatches can -cause system_call_errros -@item file_not_recognised -none of the backends recognised the file format -@item file_ambiguously_recognized -more than one backend recognised the file format. -@end table -*; PROTO(boolean, bfd_check_format, (bfd *abfd, bfd_format format)); -*-*/ - -boolean -DEFUN(bfd_check_format,(abfd, format), - bfd *abfd AND - bfd_format format) -{ - bfd_target **target, *save_targ, *right_targ; - int match_count; - - if (!bfd_read_p (abfd) || - ((int)(abfd->format) < (int)bfd_unknown) || - ((int)(abfd->format) >= (int)bfd_type_end)) { - bfd_error = invalid_operation; - return false; - } - - if (abfd->format != bfd_unknown) - return (abfd->format == format)? true: false; - - /* presume the answer is yes */ - abfd->format = format; - - /* If the target type was explicitly specified, just check that target. */ - - if (!abfd->target_defaulted) { - bfd_seek (abfd, (file_ptr)0, SEEK_SET); /* rewind! */ - - right_targ = BFD_SEND_FMT (abfd, _bfd_check_format, (abfd)); - if (right_targ) { - abfd->xvec = right_targ; /* Set the target as returned */ - return true; /* File position has moved, BTW */ - } - abfd->format = bfd_unknown; - return false; /* Specified target is not right */ - } - - /* Since the target type was defaulted, check them - all in the hope that one will be uniquely recognized. */ - - save_targ = abfd->xvec; - match_count = 0; - right_targ = 0; - - for (target = target_vector; *target != NULL; target++) { - bfd_target *temp; - - abfd->xvec = *target; /* Change BFD's target temporarily */ - bfd_seek (abfd, (file_ptr)0, SEEK_SET); - temp = BFD_SEND_FMT (abfd, _bfd_check_format, (abfd)); - if (temp) { /* This format checks out as ok! */ - right_targ = temp; - match_count++; - /* If this is the default target, accept it, even if other targets - might match. People who want those other targets have to set - the GNUTARGET variable. */ - if (temp == default_vector[0]) - break; -#ifdef GNU960 - /* Big- and little-endian b.out archives look the same, but it doesn't - * matter: there is no difference in their headers, and member file byte - * orders will (I hope) be handled appropriately by bfd. Ditto for big - * and little coff archives. And the 4 coff/b.out object formats are - * unambiguous. So accept the first match we find. - */ - break; -#endif - } - } - - if (match_count == 1) { - abfd->xvec = right_targ; /* Change BFD's target permanently */ - return true; /* File position has moved, BTW */ - } - - abfd->xvec = save_targ; /* Restore original target type */ - abfd->format = bfd_unknown; /* Restore original format */ - bfd_error = ((match_count == 0) ? file_not_recognized : - file_ambiguously_recognized); - return false; -} -/*proto* -*i bfd_set_format -This function sets the file format of the supplied BFD to the format -requested. If the target set in the BFD does not support the format -requested, the format is illegal or the BFD is not open for writing -than an error occurs. -*; PROTO(boolean,bfd_set_format,(bfd *, bfd_format)); -*-*/ -boolean -DEFUN(bfd_set_format,(abfd, format), - bfd *abfd AND - bfd_format format) -{ - - if (bfd_read_p (abfd) || - ((int)abfd->format < (int)bfd_unknown) || - ((int)abfd->format >= (int)bfd_type_end)) { - bfd_error = invalid_operation; - return false; - } - - if (abfd->format != bfd_unknown) - return (abfd->format == format) ? true:false; - - /* presume the answer is yes */ - abfd->format = format; - - if (!BFD_SEND_FMT (abfd, _bfd_set_format, (abfd))) { - abfd->format = bfd_unknown; - return false; - } - - return true; -} - - -/*proto* -*i bfd_format_string -This function takes one argument, and enumerated type (bfd_format) and -returns a pointer to a const string "invalid", "object", "archive", -"core" or "unknown" depending upon the value of the enumeration. -*; PROTO(CONST char *, bfd_format_string, (bfd_format)); -*-*/ - -CONST char * -DEFUN(bfd_format_string,(format), - bfd_format format) -{ - if (((int)format <(int) bfd_unknown) - || ((int)format >=(int) bfd_type_end)) - return "invalid"; - - switch (format) { - case bfd_object: - return "object"; /* linker/assember/compiler output */ - case bfd_archive: - return "archive"; /* object archive file */ - case bfd_core: - return "core"; /* core dump */ - default: - return "unknown"; - } -} diff --git a/bfd/host-aout.c b/bfd/host-aout.c deleted file mode 100644 index cf556d0f451..00000000000 --- a/bfd/host-aout.c +++ /dev/null @@ -1,346 +0,0 @@ -/* BFD backend for local host's a.out binaries - Copyright (C) 1990-1991 Free Software Foundation, Inc. - Written by Cygnus Support. Probably John Gilmore's fault. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include "bfd.h" -#include "sysdep.h" -#include "libbfd.h" - -#include -#include "libaout.h" /* BFD a.out internal data structures */ - -#include "trad-core.h" /* Traditional Unix core files */ - -/*======== This next section is stolen from ../include/a.out.gnu.h - ======== for all the losing Unix systems that don't provide these - ======== macros. - - When porting to a new system, you must supply: - - HOST_PAGE_SIZE - HOST_SEGMENT_SIZE - HOST_MACHINE_ARCH (optional) - HOST_MACHINE_MACHINE (optional) - HOST_TEXT_START_ADDR - HOST_STACK_END_ADDR - - in the ../include/h-systemname.h file. */ - -#define PAGE_SIZE HOST_PAGE_SIZE -#define SEGMENT_SIZE HOST_SEGMENT_SIZE -#define TEXT_START_ADDR HOST_TEXT_START_ADDR -#define STACK_END_ADDR HOST_STACK_END_ADDR - -/*======== Stolen section begins below. =================================*/ - -#define a_info a_magic /* Old traditional Unix */ - -#define N_MAGIC(exec) ((exec).a_info & 0xffff) -#define N_SET_MAGIC(exec, magic) \ - ((exec).a_info = (((exec).a_info & 0xffff0000) | ((magic) & 0xffff))) - -/* Virtual Address of text segment from the a.out file. For OMAGIC, - (almost always "unlinked .o's" these days), should be zero. - For linked files, should reflect reality if we know it. */ - -#ifndef N_TXTADDR -#define N_TXTADDR(x) (N_MAGIC(x)==OMAGIC? 0 : TEXT_START_ADDR) -#endif - -#ifndef N_BADMAG -#define N_BADMAG(x) (N_MAGIC(x) != OMAGIC \ - && N_MAGIC(x) != NMAGIC \ - && N_MAGIC(x) != ZMAGIC) -#endif - -/* This complexity is for encapsulated COFF support */ -#ifndef _N_HDROFF -#define _N_HDROFF(x) (SEGMENT_SIZE - sizeof (struct exec)) -#endif - -#ifndef N_TXTOFF -#define N_TXTOFF(x) (N_MAGIC(x) == ZMAGIC ? \ - _N_HDROFF((x)) + sizeof (struct exec) : \ - sizeof (struct exec)) -#endif - - -#ifndef N_DATOFF -#define N_DATOFF(x) ( N_TXTOFF(x) + (x).a_text ) -#endif - -#ifndef N_TRELOFF -#define N_TRELOFF(x) ( N_DATOFF(x) + (x).a_data ) -#endif - -#ifndef N_DRELOFF -#define N_DRELOFF(x) ( N_TRELOFF(x) + (x).a_trsize ) -#endif - -#ifndef N_SYMOFF -#define N_SYMOFF(x) ( N_DRELOFF(x) + (x).a_drsize ) -#endif - -#ifndef N_STROFF -#define N_STROFF(x) ( N_SYMOFF(x) + (x).a_syms ) -#endif - -/* Address of text segment in memory after it is loaded. */ -#ifndef N_TXTADDR -#define N_TXTADDR(x) 0 -#endif - -#ifndef N_DATADDR -#define N_DATADDR(x) \ - (N_MAGIC(x)==OMAGIC? (N_TXTADDR(x)+(x).a_text) \ - : (SEGMENT_SIZE + ((N_TXTADDR(x)+(x).a_text-1) & ~(SEGMENT_SIZE-1)))) -#endif - -/* Address of bss segment in memory after it is loaded. */ -#ifndef N_BSSADDR -#define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data) -#endif - - -static bfd_target *NAME(host_aout,callback) (); - -/*SUPPRESS558*/ -/*SUPPRESS529*/ - -bfd_target * -DEFUN(NAME(host_aout,object_p), (abfd), - bfd *abfd) -{ - unsigned char magicbuf[4]; /* Raw bytes of magic number from file */ - struct external_exec exec_bytes; - struct internal_exec exec; - - if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd) - != EXEC_BYTES_SIZE) { - bfd_error = wrong_format; - return 0; - } - - exec.a_magic = bfd_h_get_32 (abfd, exec_bytes.a_magic); - - if (N_BADMAG (exec)) return 0; - - NAME(aout,swap_exec_header_in)(abfd, &exec_bytes, &exec); - return NAME(aout,some_aout_object_p) (abfd, &exec, NAME(host_aout,callback)); -} - -/* Set parameters about this a.out file that are machine-dependent. - This routine is called from NAME(some_aout_object_p) just before it returns. - */ - -static bfd_target * -DEFUN(NAME(host_aout,callback), (abfd), - bfd *abfd) -{ - /* exec_hdr (abfd), a "struct internal_exec *", is just an abstraction, - as far as the BFD a.out layer cares. We use it as a "struct exec *". - This routine moves any data from the exec header, - which is needed by the BFD code, out to places known to BFD. This - allows the rest of the BFD code to not know or care about the structure - of exec_hdr (abfd). */ - struct exec *execp = (struct exec *)exec_hdr (abfd); - - /* The virtual memory addresses of the sections */ - obj_datasec (abfd)->vma = N_DATADDR(*execp); - obj_bsssec (abfd)->vma = N_BSSADDR(*execp); - obj_textsec (abfd)->vma = N_TXTADDR(*execp); - - /* The file offsets of the sections */ - obj_textsec (abfd)->filepos = N_TXTOFF(*execp); - obj_datasec (abfd)->filepos = N_DATOFF(*execp); - - /* The file offsets of the relocation info */ - obj_textsec (abfd)->rel_filepos = N_TRELOFF(*execp); - obj_datasec (abfd)->rel_filepos = N_DRELOFF(*execp); - - /* The file offsets of the string table and symbol table. */ - obj_str_filepos (abfd) = N_STROFF (*execp); - obj_sym_filepos (abfd) = N_SYMOFF (*execp); - -#ifdef HOST_MACHINE_ARCH - bfd_default_set_arch_mach(abfd, - HOST_MACHINE_ARCH, -#ifdef HOST_MACHINE_MACHINE - HOST_MACHINE_MACHINE -#else /* not HOST_MACHINE_MACHINE */ - 0 -#endif /* not HOST_MACHINE_MACHINE */ - ); -#endif /* HOST_MACHINE_ARCH */ - - obj_reloc_entry_size (abfd) = sizeof (struct relocation_info); - return abfd->xvec; -} - - -boolean -DEFUN(NAME(host_aout,mkobject), (abfd), - bfd *abfd) -{ - /* This struct is just for allocating two things with one zalloc, so - they will be freed together, without violating alignment constraints. */ - struct aout_exec { - struct aoutdata aoutdata; - struct exec exec; - } *rawptr; - - bfd_error = system_call_error; - - /* Use an intermediate variable for clarity */ - rawptr = (struct aout_exec *)bfd_zalloc (abfd, sizeof (struct aout_exec)); - - if (rawptr == NULL) { - bfd_error = no_memory; - return false; - } - - set_tdata (abfd, &rawptr->aoutdata); - /* exec_hdr (abfd), a "struct internal_exec *", is just an abstraction, - as far as the BFD a.out layer cares. We use it as a "struct exec *". */ - exec_hdr (abfd) = (struct internal_exec *) &rawptr->exec; - - /* For simplicity's sake we just make all the sections right here. */ - - obj_textsec (abfd) = (asection *)NULL; - obj_datasec (abfd) = (asection *)NULL; - obj_bsssec (abfd) = (asection *)NULL; - bfd_make_section (abfd, ".text"); - bfd_make_section (abfd, ".data"); - bfd_make_section (abfd, ".bss"); - - return true; -} - -/* Write an object file in host a.out format. - Section contents have already been written. We write the - file header, symbols, and relocation. */ - -boolean -DEFUN(NAME(host_aout,write_object_contents), (abfd), - bfd *abfd) -{ -/* This works because we are on the host system */ -#define EXEC_BYTES_SIZE (sizeof (struct exec)) -#define EXTERNAL_NLIST_SIZE (sizeof (struct nlist)) - size_t data_pad = 0; - unsigned char exec_bytes[EXEC_BYTES_SIZE]; - struct exec *execp = (struct exec *)exec_hdr (abfd); - - execp->a_text = obj_textsec (abfd)->size; - - WRITE_HEADERS (abfd, execp); - return true; -} - -/* We use BFD generic archive files. */ -#define aout_32_openr_next_archived_file bfd_generic_openr_next_archived_file -#define aout_32_generic_stat_arch_elt bfd_generic_stat_arch_elt -#define aout_32_slurp_armap bfd_false -#define aout_32_slurp_extended_name_table bfd_true -#define aout_32_write_armap (PROTO (boolean, (*), \ - (bfd *arch, unsigned int elength, struct orl *map, int orl_count, \ - int stridx))) bfd_false -#define aout_32_truncate_arname bfd_dont_truncate_arname - -/* No core file defined here -- configure in trad-core.c separately. */ -#define aout_32_core_file_failing_command bfd_false -#define aout_32_core_file_failing_signal bfd_false -#define aout_32_core_file_matches_executable_p bfd_true -#define some_kinda_core_file_p bfd_false - -#define aout_32_bfd_debug_info_start bfd_void -#define aout_32_bfd_debug_info_end bfd_void -#define aout_32_bfd_debug_info_accumulate (PROTO(void,(*),(bfd*, struct sec *))) bfd_void - -#define aout_64_openr_next_archived_file aout_32_openr_next_archived_file -#define aout_64_generic_stat_arch_elt aout_32_generic_stat_arch_elt -#define aout_64_slurp_armap aout_32_slurp_armap -#define aout_64_slurp_extended_name_table aout_32_slurp_extended_name_table -#define aout_64_write_armap aout_32_write_armap -#define aout_64_truncate_arname aout_32_truncate_arname - -#define aout_64_core_file_failing_command aout_32_core_file_failing_command -#define aout_64_core_file_failing_signal aout_32_core_file_failing_signal -#define aout_64_core_file_matches_executable_p aout_32_core_file_matches_executable_p - -#define aout_64_bfd_debug_info_start aout_32_bfd_debug_info_start -#define aout_64_bfd_debug_info_end aout_32_bfd_debug_info_end -#define aout_64_bfd_debug_info_accumulate aout_32_bfd_debug_info_accumulate - - -/* We implement these routines ourselves, rather than using the generic - a.out versions. */ -#define aout_write_object_contents host_write_object_contents - -bfd_target host_aout_big_vec = - { - "a.out-host-big", - bfd_target_aout_flavour, - true, /* target byte order */ - true, /* target headers byte order */ - (HAS_RELOC | EXEC_P | /* object flags */ - HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED), - (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ - ' ', /* ar_pad_char */ - 16, /* ar_max_namelen */ - 3, /* minimum alignment power */ - _do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* data */ - _do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* hdrs */ - - {_bfd_dummy_target, NAME(host_aout,object_p), - bfd_generic_archive_p, some_kinda_core_file_p}, - {bfd_false, NAME(host_aout,mkobject), - _bfd_generic_mkarchive, bfd_false}, - {bfd_false, NAME(host_aout,write_object_contents), /* bfd_write_contents */ - _bfd_write_archive_contents, bfd_false}, - - JUMP_TABLE(JNAME(aout)) -}; - -bfd_target host_aout_little_vec = - { - "a.out-host-little", - bfd_target_aout_flavour, - false, /* target byte order */ - false, /* target headers byte order */ - (HAS_RELOC | EXEC_P | /* object flags */ - HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED), - (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ - ' ', /* ar_pad_char */ - 16, /* ar_max_namelen */ - 3, /* minimum alignment power */ - _do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putb16, /* data */ - _do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putl16, /* hdrs */ - - {_bfd_dummy_target, NAME(host_aout,object_p), - bfd_generic_archive_p, some_kinda_core_file_p}, - {bfd_false, NAME(host_aout,mkobject), - _bfd_generic_mkarchive, bfd_false}, - {bfd_false, NAME(host_aout,write_object_contents), /* bfd_write_contents */ - _bfd_write_archive_contents, bfd_false}, - - JUMP_TABLE(JNAME(aout)) -}; diff --git a/bfd/hosts/.Sanitize b/bfd/hosts/.Sanitize deleted file mode 100644 index 39bac4d52a4..00000000000 --- a/bfd/hosts/.Sanitize +++ /dev/null @@ -1,98 +0,0 @@ -# .Sanitize for devo/include/sys. -# $Id$ -# - -# Each directory to survive it's way into a release will need a file -# like this one called "./.Sanitize". All keyword lines must exist, -# and must exist in the order specified by this file. Each directory -# in the tree will be processed, top down, in the following order. - -# Hash started lines like this one are comments and will be deleted -# before anything else is done. Blank lines will also be squashed -# out. - -# The lines between the "Do-first:" line and the "Things-to-keep:" -# line are executed as a /bin/sh shell script before anything else is -# done in this - -Do-first: - -echo Sanitizing `pwd`... - -# All files listed between the "Things-to-keep:" line and the -# "Files-to-sed:" line will be kept. All other files will be removed. -# Directories listed in this section will have their own Sanitize -# called. Directories not listed will be removed in their entirety -# with rm -rf. - -Things-to-keep: - -h-amix.h -h-decstation.h -h-dgux.h -h-delta88.h -h-dose.h -h-harris.h -h-hp300bsd.h -h-hp9000.h -h-i386mach.h -h-i386v.h -h-irix3.h -h-news.h -h-rs6000.h -h-rtbsd.h -h-sparc-ll.h -h-sparc.h -h-sun3.h -h-tahoe.h -h-ultra3.h -h-vaxbsd.h -h-vaxult.h - -Do-last: - -echo Done in `pwd`. - -# -# -# $Log$ -# Revision 1.13 1991/11/14 15:24:43 sac -# Added harris -# -# Revision 1.12 1991/11/05 20:55:45 sac -# Added h-delta88 -# -# Revision 1.11 1991/10/16 21:40:40 gnu -# sparc-64 to sparc-ll -# -# Revision 1.10 1991/10/12 07:38:07 gnu -# Update for new bfd/hosts. -# -# Revision 1.9 1991/10/05 06:18:50 gnu -# h-amix.h -# -# Revision 1.8 1991/10/04 08:27:36 gnu -# Add 386 Mach host support. -# -# Revision 1.7 1991/09/20 03:42:22 gnu -# Undo precipitous changes. -# -# Revision 1.5 1991/09/17 06:57:44 grossman -# sgi/irix config stuff. -# -# Revision 1.4 1991/09/13 03:56:25 gnu -# Ultracomputer -# -# Revision 1.3 1991/08/22 08:01:20 gnu -# Add hp 300 BSD. -# -# Revision 1.2 1991/07/24 00:59:57 gnu -# Add h-rtbsd.h. -# -# Revision 1.1 1991/05/23 16:56:36 rich -# Initial revision -# -# -# - -# End of file. diff --git a/bfd/hosts/amix.h b/bfd/hosts/amix.h deleted file mode 100644 index 8481e94644a..00000000000 --- a/bfd/hosts/amix.h +++ /dev/null @@ -1,62 +0,0 @@ -/* Amiga Unix host system */ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef O_ACCMODE -#define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR) -#endif -#define SEEK_SET 0 -#define SEEK_CUR 1 - -#define POSIX_UTIME - -extern PROTO(int, abort,(void)); -extern PROTO(int, close,(int)); -extern PROTO(void, exit,(int)); -extern PROTO(int, fclose,(FILE*)); -extern PROTO(void, free,(PTR)); -extern PROTO(int, fseek,(FILE*, long, int)); -extern PROTO(int, getgid,()); -extern PROTO(int, getuid,()); -extern PROTO(PTR, malloc,(unsigned)); -extern PROTO(void, perror,(CONST char *)); -extern PROTO(int, qsort,(void *data,int els, int siz, int func())); -extern PROTO(PTR, realloc, (PTR, unsigned)); - -extern char *getenv(); -extern int chmod(); -extern int fstat(); -extern int stat(); -extern int strtol(); - -extern char *ctime(); -extern int _flsbuf(); -extern int fclose(); -extern int utimes(); -extern int vfprintf(); -extern long atol(); -extern int fputc(); -extern int unlink(); - -/* EXACT TYPES */ -typedef char int8e_type; -typedef unsigned char uint8e_type; -typedef short int16e_type; -typedef unsigned short uint16e_type; -typedef int int32e_type; -typedef unsigned int uint32e_type; - -/* CORRECT SIZE OR GREATER */ -typedef char int8_type; -typedef unsigned char uint8_type; -typedef short int16_type; -typedef unsigned short uint16_type; -typedef int int32_type; -typedef unsigned int uint32_type; diff --git a/bfd/hosts/decstation.h b/bfd/hosts/decstation.h deleted file mode 100644 index 875982c9f25..00000000000 --- a/bfd/hosts/decstation.h +++ /dev/null @@ -1,33 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef O_ACCMODE -#define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR) -#endif -#define SEEK_SET 0 -#define SEEK_CUR 1 - -extern char *malloc(); -extern void free(); - -/* EXACT TYPES */ -typedef char int8e_type; -typedef unsigned char uint8e_type; -typedef short int16e_type; -typedef unsigned short uint16e_type; -typedef int int32e_type; -typedef unsigned int uint32e_type; - -/* CORRECT SIZE OR GREATER */ -typedef char int8_type; -typedef unsigned char uint8_type; -typedef short int16_type; -typedef unsigned short uint16_type; -typedef int int32_type; -typedef unsigned int uint32_type; - diff --git a/bfd/hosts/delta88.h b/bfd/hosts/delta88.h deleted file mode 100644 index 879b03538d0..00000000000 --- a/bfd/hosts/delta88.h +++ /dev/null @@ -1,81 +0,0 @@ -#include -#include -#include - -#include -#include -#include -#include -#include - -#include - -#ifndef DONTDECLARE_MALLOC -extern PROTO(PTR,malloc,(unsigned)); -extern PROTO(PTR ,realloc, (PTR, unsigned)); -#endif -extern PROTO(int, abort,(void)); -extern PROTO(int, free,(PTR)); -extern PROTO(void, bcopy,(char*,char*,int)); -extern PROTO(void, exit,(int)); -extern int strtol(); -extern PROTO(void, bzero,(char *, int)); -#define NO_STDARG 1 - - - -extern PROTO(int, abort,(void)); -extern PROTO(int, close,(int)); -extern PROTO(int, fcntl,(int des, int cmd, int e)); - - -extern PROTO(int, qsort,(void *data,int els, int siz, int func())); -extern PROTO(unsigned short,getuid,(void)); -extern PROTO(unsigned short,getgid,(void)); -extern PROTO(int, fseek,(FILE*, int, int)); -extern PROTO(int, fclose,(FILE*)); -extern PROTO(void, bcopy,(char*,char*,int)); -extern PROTO(int, bcmp,(char *, char *, int)); -extern PROTO(void, bzero,(char *, int)); -extern char * strchr(); -extern PROTO(void, perror,(CONST char *)); -extern char *getenv(); -extern PROTO(PTR, memchr,(const void *, int, unsigned )); -extern char *strrchr(); -extern int chmod(); -extern int fread(); -extern int fstat(); -extern int fwrite(); -extern int sscanf(); -extern int stat(); -extern int strtol(); -extern int fileno(); -extern char *strrchr(); -extern char *ctime(); -extern int _flsbuf(); -extern int fclose(); -extern int time(); -extern int utimes(); -extern int vfprintf(); -extern long atol(); -extern char *getenv(); -extern int fputc(); -extern int unlink(); - - -/* EXACT TYPES */ -typedef char int8e_type; -typedef unsigned char uint8e_type; -typedef short int16e_type; -typedef unsigned short uint16e_type; -typedef int int32e_type; -typedef unsigned int uint32e_type; - -/* CORRECT SIZE OR GREATER */ -typedef char int8_type; -typedef unsigned char uint8_type; -typedef short int16_type; -typedef unsigned short uint16_type; -typedef int int32_type; -typedef unsigned int uint32_type; - diff --git a/bfd/hosts/dgux.h b/bfd/hosts/dgux.h deleted file mode 100644 index 7db80bfd503..00000000000 --- a/bfd/hosts/dgux.h +++ /dev/null @@ -1,27 +0,0 @@ -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include - -#ifndef DONTDECLARE_MALLOC -extern PROTO(PTR,malloc,(unsigned)); -extern PROTO(PTR ,realloc, (PTR, unsigned)); -#endif -extern PROTO(int, abort,(void)); -extern PROTO(int, free,(PTR)); -extern PROTO(void, bcopy,(char*,char*,int)); -extern PROTO(void, exit,(int)); -extern int strtol(); -extern PROTO(void, bzero,(char *, int)); -#define NO_STDARG 1 - - - diff --git a/bfd/hosts/dose.h b/bfd/hosts/dose.h deleted file mode 100644 index a03b49a6a13..00000000000 --- a/bfd/hosts/dose.h +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef O_ACCMODE -#define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR) -#endif -#define SEEK_SET 0 -#define SEEK_CUR 1 - -/* EXACT TYPES */ -typedef char int8e_type; -typedef unsigned char uint8e_type; -typedef short int16e_type; -typedef unsigned short uint16e_type; -typedef int int32e_type; -typedef unsigned int uint32e_type; - -/* CORRECT SIZE OR GREATER */ -typedef char int8_type; -typedef unsigned char uint8_type; -typedef short int16_type; -typedef unsigned short uint16_type; -typedef int int32_type; -typedef unsigned int uint32_type; diff --git a/bfd/hosts/h-m68kv.h b/bfd/hosts/h-m68kv.h deleted file mode 100644 index e667283f168..00000000000 --- a/bfd/hosts/h-m68kv.h +++ /dev/null @@ -1,51 +0,0 @@ -/* $Id$ */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define USG - -#ifdef __GNUC__ -#define alloca __builtin_alloca -#endif - - -#ifndef O_ACCMODE -#define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR) -#endif -#define SEEK_SET 0 -#define SEEK_CUR 1 - -#include -#define bcmp(b1,b2,len) memcmp(b1,b2,len) -#define bcopy(src,dst,len) memcpy(dst,src,len) -#define bzero(s,n) memset(s,0,n) - -#include -#define index(s,c) strchr(s,c) -#define rindex(s,c) strrchr(s,c) - - -/* EXACT TYPES */ -typedef char int8e_type; -typedef unsigned char uint8e_type; -typedef short int16e_type; -typedef unsigned short uint16e_type; -typedef int int32e_type; -typedef unsigned int uint32e_type; - -/* CORRECT SIZE OR GREATER */ -typedef char int8_type; -typedef unsigned char uint8_type; -typedef short int16_type; -typedef unsigned short uint16_type; -typedef int int32_type; -typedef unsigned int uint32_type; - diff --git a/bfd/hosts/harris.h b/bfd/hosts/harris.h deleted file mode 100644 index 138f1703ff9..00000000000 --- a/bfd/hosts/harris.h +++ /dev/null @@ -1,38 +0,0 @@ -#include -#include -#include - -#include -#include -#include -#include -#include - -#include - -#ifndef DONTDECLARE_MALLOC -extern PROTO(PTR,malloc,(unsigned)); -extern PROTO(PTR ,realloc, (PTR, unsigned)); -#endif -extern PROTO(int, abort,(void)); -extern PROTO(int, free,(PTR)); -extern PROTO(void, bcopy,(char*,char*,int)); -extern PROTO(void, exit,(int)); -extern int strtol(); -extern PROTO(void, bzero,(char *, int)); - -/* EXACT TYPES */ -typedef char int8e_type; -typedef unsigned char uint8e_type; -typedef short int16e_type; -typedef unsigned short uint16e_type; -typedef int int32e_type; -typedef unsigned int uint32e_type; - -/* CORRECT SIZE OR GREATER */ -typedef char int8_type; -typedef unsigned char uint8_type; -typedef short int16_type; -typedef unsigned short uint16_type; -typedef int int32_type; -typedef unsigned int uint32_type; diff --git a/bfd/hosts/hp9000.h b/bfd/hosts/hp9000.h deleted file mode 100644 index cbdb6d1308b..00000000000 --- a/bfd/hosts/hp9000.h +++ /dev/null @@ -1,65 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef O_ACCMODE -#define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR) -#endif -#define SEEK_SET 0 -#define SEEK_CUR 1 - -/* Some things that need to be defined in order to make code written for - BSD Unix compile under System V Unix. */ - -#include -#define bcmp(b1,b2,len) memcmp(b1,b2,len) -#define bcopy(src,dst,len) memcpy(dst,src,len) -#define bzero(s,n) memset(s,0,n) - -static int -rename(from, to) -{ - unlink(to); - return(link(from, to)); -} - -/* - * Might not need these. Leave them out for now. - * -#include -#define index(s,c) strchr(s,c) -#define rindex(s,c) strrchr(s,c) - -#ifdef SEEK_SET -# ifndef L_SET -# define L_SET SEEK_SET -# endif -# endif - -#ifdef SEEK_CUR -# ifndef L_INCR -# define L_INCR SEEK_CUR -# endif -# endif - */ - -/* EXACT TYPES */ -typedef char int8e_type; -typedef unsigned char uint8e_type; -typedef short int16e_type; -typedef unsigned short uint16e_type; -typedef int int32e_type; -typedef unsigned int uint32e_type; - -/* CORRECT SIZE OR GREATER */ -typedef char int8_type; -typedef unsigned char uint8_type; -typedef short int16_type; -typedef unsigned short uint16_type; -typedef int int32_type; -typedef unsigned int uint32_type; - diff --git a/bfd/hosts/i386mach.h b/bfd/hosts/i386mach.h deleted file mode 100644 index 6b6c9cef31d..00000000000 --- a/bfd/hosts/i386mach.h +++ /dev/null @@ -1,45 +0,0 @@ -#include -#include -extern int errno; /* forgets to do this... */ -#include -#include -#include -#include -#include -#include -#include - -#ifndef O_ACCMODE -#define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR) -#endif - -#define SEEK_SET 0 -#define SEEK_CUR 1 - -extern PROTO(PTR, malloc, (unsigned)); -extern PROTO(PTR, realloc, (PTR, unsigned)); -extern PROTO(void, free, (PTR)); - -#define HAVE_STRERROR - -#define HOST_PAGE_SIZE NBPG -#define HOST_SEGMENT_SIZE NBPG -#define HOST_MACHINE_ARCH bfd_arch_i386 -#define HOST_TEXT_START_ADDR 0x10000 /* By inspection */ -#define HOST_STACK_END_ADDR KERNBASE - -/* EXACT TYPES */ -typedef char int8e_type; -typedef unsigned char uint8e_type; -typedef short int16e_type; -typedef unsigned short uint16e_type; -typedef int int32e_type; -typedef unsigned int uint32e_type; - -/* CORRECT SIZE OR GREATER */ -typedef char int8_type; -typedef unsigned char uint8_type; -typedef short int16_type; -typedef unsigned short uint16_type; -typedef int int32_type; -typedef unsigned int uint32_type; diff --git a/bfd/hosts/i386v.h b/bfd/hosts/i386v.h deleted file mode 100644 index 657ec68c9d7..00000000000 --- a/bfd/hosts/i386v.h +++ /dev/null @@ -1,67 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef O_ACCMODE -#define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR) -#endif -#define SEEK_SET 0 -#define SEEK_CUR 1 - -#define POSIX_UTIME - -/* Some things that need to be defined in order to make code written for - BSD Unix compile under System V Unix. */ - -#include -#define bcmp(b1,b2,len) memcmp(b1,b2,len) -#define bcopy(src,dst,len) memcpy(dst,src,len) -#define bzero(s,n) memset(s,0,n) - -#include -#define index(s,c) strchr(s,c) -#define rindex(s,c) strrchr(s,c) - -/* - * Might not need these. Leave them out for now. - * -#ifdef SEEK_SET -# ifndef L_SET -# define L_SET SEEK_SET -# endif -# endif - -#ifdef SEEK_CUR -# ifndef L_INCR -# define L_INCR SEEK_CUR -# endif -# endif - */ - -#ifndef DONTDECLARE_MALLOC -extern PROTO(PTR,malloc,(unsigned)); -extern PROTO(PTR ,realloc, (PTR, unsigned)); -extern PROTO(void, free,(PTR)); -#endif - -/* EXACT TYPES */ -typedef char int8e_type; -typedef unsigned char uint8e_type; -typedef short int16e_type; -typedef unsigned short uint16e_type; -typedef int int32e_type; -typedef unsigned int uint32e_type; - -/* CORRECT SIZE OR GREATER */ -typedef char int8_type; -typedef unsigned char uint8_type; -typedef short int16_type; -typedef unsigned short uint16_type; -typedef int int32_type; -typedef unsigned int uint32_type; - diff --git a/bfd/hosts/irix3.h b/bfd/hosts/irix3.h deleted file mode 100644 index f6e5fa1979f..00000000000 --- a/bfd/hosts/irix3.h +++ /dev/null @@ -1,40 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if 0 -#include -#include -#endif - -#if !defined (O_ACCMODE) -#define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR) -#endif - -#if !defined (SEEK_SET) -#define SEEK_SET 0 -#define SEEK_CUR 1 -#endif - -/* EXACT TYPES */ -typedef char int8e_type; -typedef unsigned char uint8e_type; -typedef short int16e_type; -typedef unsigned short uint16e_type; -typedef int int32e_type; -typedef unsigned int uint32e_type; - -/* CORRECT SIZE OR GREATER */ -typedef char int8_type; -typedef unsigned char uint8_type; -typedef short int16_type; -typedef unsigned short uint16_type; -typedef int int32_type; -typedef unsigned int uint32_type; - diff --git a/bfd/hosts/rs6000.h b/bfd/hosts/rs6000.h deleted file mode 100644 index 7cf72b10379..00000000000 --- a/bfd/hosts/rs6000.h +++ /dev/null @@ -1,35 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include /* for malloc() */ - -/* fdopen() won't let you open read-only files for update */ -#define FASCIST_FDOPEN - -#ifndef O_ACCMODE -#define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR) -#endif -#define SEEK_SET 0 -#define SEEK_CUR 1 - -/* EXACT TYPES */ -typedef char int8e_type; -typedef unsigned char uint8e_type; -typedef short int16e_type; -typedef unsigned short uint16e_type; -typedef int int32e_type; -typedef unsigned int uint32e_type; - -/* CORRECT SIZE OR GREATER */ -typedef char int8_type; -typedef unsigned char uint8_type; -typedef short int16_type; -typedef unsigned short uint16_type; -typedef int int32_type; -typedef unsigned int uint32_type; - diff --git a/bfd/hosts/rtbsd.h b/bfd/hosts/rtbsd.h deleted file mode 100644 index 8525052763d..00000000000 --- a/bfd/hosts/rtbsd.h +++ /dev/null @@ -1,35 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef O_ACCMODE -#define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR) -#endif - -#define SEEK_SET 0 -#define SEEK_CUR 1 - -extern char *malloc(); -extern void free(); - - -/* EXACT TYPES */ -typedef char int8e_type; -typedef unsigned char uint8e_type; -typedef short int16e_type; -typedef unsigned short uint16e_type; -typedef int int32e_type; -typedef unsigned int uint32e_type; - -/* CORRECT SIZE OR GREATER */ -typedef char int8_type; -typedef unsigned char uint8_type; -typedef short int16_type; -typedef unsigned short uint16_type; -typedef int int32_type; -typedef unsigned int uint32_type; diff --git a/bfd/hosts/sparc-ll.h b/bfd/hosts/sparc-ll.h deleted file mode 100644 index 50a29459e3b..00000000000 --- a/bfd/hosts/sparc-ll.h +++ /dev/null @@ -1,123 +0,0 @@ -/* Host definition file for Sun-4 running with gcc, using "long long" - for addresses, to handle 64-bit target systems. */ - -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef O_ACCMODE -#define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR) -#endif -#define SEEK_SET 0 -#define SEEK_CUR 1 - -/* Make the basic types 64-bit quantities on the host */ -#define HOST_64_BIT long long - -extern PROTO(int, abort,(void)); -extern PROTO(int, close,(int)); -extern PROTO(int, fcntl,(int des, int cmd, int e)); -extern PROTO(int, fprintf,(FILE *,char *,...)); -extern PROTO(int, printf,(char *,...)); -extern PROTO(int, qsort,(void *data,int els, int siz, int func())); -extern PROTO(void, exit,(int)); -extern PROTO(int, fseek,(FILE*, int, int)); -extern PROTO(int, fclose,(FILE*)); -extern PROTO(void, bcopy,(char*,char*,int)); -extern PROTO(int, bcmp,(char *, char *, int)); -extern PROTO(void, bzero,(char *, int)); -extern PROTO(PTR,memset,(PTR, int,unsigned int)); -#ifndef __GNUC__ -PROTO(PTR, memcpy,(PTR,CONST PTR,unsigned int)); -#else -/* PROTO(char *, memcpy,(char *,CONST char *,unsigned int)); */ -#endif - -extern PROTO(int,getuid,()); -extern PROTO(int,getgid,()); -extern char * strchr(); -extern PROTO(void, perror,(CONST char *)); -extern char *getenv(); -extern char *memchr(); -extern char *strrchr(); -extern int chmod(); -extern int fread(); -extern int fstat(); -extern int fwrite(); -extern int sscanf(); -extern int stat(); -extern int strtol(); -#ifndef DONTDECLARE_MALLOC -extern PROTO(PTR,malloc,(unsigned)); -extern PROTO(PTR ,realloc, (PTR, unsigned)); -#endif - -extern PROTO(int, free,(PTR)); - - -extern char *strrchr(); -extern char *ctime(); -extern int _flsbuf(); -extern int fclose(); -extern int time(); -extern int utimes(); -extern int vfprintf(); -extern long atol(); -extern char *getenv(); -extern int fputc(); -extern int unlink(); - - -/* EXACT TYPES */ -typedef char int8e_type; -typedef unsigned char uint8e_type; -typedef short int16e_type; -typedef unsigned short uint16e_type; -typedef int int32e_type; -typedef unsigned int uint32e_type; - - -#ifdef __GNUC__ -typedef unsigned long long uint64e_type; - -#else -typedef struct { - uint32e_type low, high; -} uint64e_type; - -#endif -/* CORRECT SIZE OR GREATER */ -typedef char int8_type; -typedef unsigned char uint8_type; -typedef short int16_type; -typedef unsigned short uint16_type; -typedef int int32_type; -typedef unsigned int uint32_type; - -#ifdef __GNUC__ -typedef unsigned long long uint64_type; -typedef long long int64_type; -#else -typedef struct { - uint32e_type low, high; -} uint64_type; - -typedef struct { - uint32e_type low, high; -} int64_type; - -#endif - - -#define BYTES_IN_PRINTF_INT 4 -#ifndef __GNUC__ -#define uint64_typeLOW(x) (uint32_type)(((x).low)) -#define uint64_typeHIGH(x) (uint32_type)(((x).high)) -#else -#define uint64_typeLOW(x) (uint32_type)(((x) & 0xffffffff)) -#define uint64_typeHIGH(x) (uint32_type)(((x) >> 32) & 0xffffffff) -#endif diff --git a/bfd/hosts/sparc.h b/bfd/hosts/sparc.h deleted file mode 100644 index f93a21e8daf..00000000000 --- a/bfd/hosts/sparc.h +++ /dev/null @@ -1,117 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef O_ACCMODE -#define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR) -#endif -#define SEEK_SET 0 -#define SEEK_CUR 1 - -extern PROTO(int, abort,(void)); -extern PROTO(int, close,(int)); -extern PROTO(int, fcntl,(int des, int cmd, int e)); -extern PROTO(int, fprintf,(FILE *,char *,...)); -extern PROTO(int, printf,(char *,...)); -extern PROTO(int, qsort,(void *data,int els, int siz, int func())); -extern PROTO(void, exit,(int)); -extern PROTO(int, fseek,(FILE*, int, int)); -extern PROTO(int, fclose,(FILE*)); -extern PROTO(void, bcopy,(char*,char*,int)); -extern PROTO(int, bcmp,(char *, char *, int)); -extern PROTO(void, bzero,(char *, int)); -extern PROTO(PTR,memset,(PTR, int,unsigned int)); -#ifndef __GNUC__ -PROTO(PTR, memcpy,(PTR,CONST PTR,unsigned int)); -#else -/* PROTO(char *, memcpy,(char *,CONST char *,unsigned int)); */ -#endif - -extern PROTO(int,getuid,()); -extern PROTO(int,getgid,()); -extern char * strchr(); -extern PROTO(void, perror,(CONST char *)); -extern char *getenv(); -extern char *memchr(); -extern char *strrchr(); -extern int chmod(); -extern int fread(); -extern int fstat(); -extern int fwrite(); -extern int sscanf(); -extern int stat(); -extern int strtol(); -#ifndef DONTDECLARE_MALLOC -extern PROTO(PTR,malloc,(unsigned)); -extern PROTO(PTR ,realloc, (PTR, unsigned)); -#endif - -extern PROTO(int, free,(PTR)); - - -extern char *strrchr(); -extern char *ctime(); -extern int _flsbuf(); -extern int fclose(); -extern int time(); -extern int utimes(); -extern int vfprintf(); -extern long atol(); -extern char *getenv(); -extern int fputc(); -extern int unlink(); - - -/* EXACT TYPES */ -typedef char int8e_type; -typedef unsigned char uint8e_type; -typedef short int16e_type; -typedef unsigned short uint16e_type; -typedef int int32e_type; -typedef unsigned int uint32e_type; - - -#ifdef __GNUC__ -typedef unsigned long long uint64e_type; - -#else -typedef struct { - uint32e_type low, high; -} uint64e_type; - -#endif -/* CORRECT SIZE OR GREATER */ -typedef char int8_type; -typedef unsigned char uint8_type; -typedef short int16_type; -typedef unsigned short uint16_type; -typedef int int32_type; -typedef unsigned int uint32_type; - -#ifdef __GNUC__ -typedef unsigned long long uint64_type; -typedef long long int64_type; -#else -typedef struct { - uint32e_type low, high; -} uint64_type; - -typedef struct { - uint32e_type low, high; -} int64_type; - -#endif - - -#define BYTES_IN_PRINTF_INT 4 -#ifndef __GNUC__ -#define uint64_typeLOW(x) (uint32_type)(((x).low)) -#define uint64_typeHIGH(x) (uint32_type)(((x).high)) -#else -#define uint64_typeLOW(x) (uint32_type)(((x) & 0xffffffff)) -#define uint64_typeHIGH(x) (uint32_type)(((x) >> 32) & 0xffffffff) -#endif diff --git a/bfd/hosts/sun3.h b/bfd/hosts/sun3.h deleted file mode 100644 index eefa366f26e..00000000000 --- a/bfd/hosts/sun3.h +++ /dev/null @@ -1,70 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef O_ACCMODE -#define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR) -#endif -#define SEEK_SET 0 -#define SEEK_CUR 1 - -extern PROTO(int, abort,(void)); -extern PROTO(int, close,(int)); -extern PROTO(int, fcntl,(int des, int cmd, int e)); -extern PROTO(int, fprintf,(FILE *,char *,...)); -extern PROTO(int, printf,(char *,...)); -extern PROTO(int, qsort,(void *data,int els, int siz, int func())); -extern PROTO(int, exit,(int)); -extern PROTO(int, fseek,(FILE*, int, int)); -extern PROTO(int, fclose,(FILE*)); -extern PROTO(void, bcopy,(char*,char*,int)); -extern PROTO(int, bcmp,(char *, char *, int)); -extern PROTO(void, bzero,(char *, int)); -extern char * strchr(); -extern PROTO(void, perror,(CONST char *)); -extern char *getenv(); -extern char *memchr(); -extern char *strrchr(); -extern int chmod(); -extern int fread(); -extern int fstat(); -extern int fwrite(); -extern int sscanf(); -extern int stat(); -extern int strtol(); -void free(); -char *malloc(); -char *realloc(); -extern char *strrchr(); -extern char *ctime(); -extern int _flsbuf(); -extern int fclose(); -extern int time(); -extern int utimes(); -extern int vfprintf(); -extern long atol(); -extern char *getenv(); -extern int fputc(); -extern int unlink(); - - -/* EXACT TYPES */ -typedef char int8e_type; -typedef unsigned char uint8e_type; -typedef short int16e_type; -typedef unsigned short uint16e_type; -typedef int int32e_type; -typedef unsigned int uint32e_type; - -/* CORRECT SIZE OR GREATER */ -typedef char int8_type; -typedef unsigned char uint8_type; -typedef short int16_type; -typedef unsigned short uint16_type; -typedef int int32_type; -typedef unsigned int uint32_type; - diff --git a/bfd/hosts/tahoe.h b/bfd/hosts/tahoe.h deleted file mode 100644 index b8f07887046..00000000000 --- a/bfd/hosts/tahoe.h +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef O_ACCMODE -#define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR) -#endif -#define SEEK_SET 0 -#define SEEK_CUR 1 - -/* EXACT TYPES */ -typedef char int8e_type; -typedef unsigned char uint8e_type; -typedef short int16e_type; -typedef unsigned short uint16e_type; -typedef int int32e_type; -typedef unsigned int uint32e_type; - -/* CORRECT SIZE OR GREATER */ -typedef char int8_type; -typedef unsigned char uint8_type; -typedef short int16_type; -typedef unsigned short uint16_type; -typedef int int32_type; -typedef unsigned int uint32_type; - diff --git a/bfd/hosts/ultra3.h b/bfd/hosts/ultra3.h deleted file mode 100644 index e3df430c978..00000000000 --- a/bfd/hosts/ultra3.h +++ /dev/null @@ -1,34 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include - -#define SEEK_SET 0 -#define SEEK_CUR 1 - -#ifndef O_ACCMODE -#define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR) -#endif - -extern char *malloc(); -extern void free(); - -/* EXACT TYPES */ -typedef char int8e_type; -typedef unsigned char uint8e_type; -typedef short int16e_type; -typedef unsigned short uint16e_type; -typedef int int32e_type; -typedef unsigned int uint32e_type; - -/* CORRECT SIZE OR GREATER */ -typedef char int8_type; -typedef unsigned char uint8_type; -typedef short int16_type; -typedef unsigned short uint16_type; -typedef int int32_type; -typedef unsigned int uint32_type; diff --git a/bfd/hosts/vaxbsd.h b/bfd/hosts/vaxbsd.h deleted file mode 100644 index 330fac50185..00000000000 --- a/bfd/hosts/vaxbsd.h +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef O_ACCMODE -#define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR) -#endif - -/* EXACT TYPES */ -typedef char int8e_type; -typedef unsigned char uint8e_type; -typedef short int16e_type; -typedef unsigned short uint16e_type; -typedef int int32e_type; -typedef unsigned int uint32e_type; - -/* CORRECT SIZE OR GREATER */ -typedef char int8_type; -typedef unsigned char uint8_type; -typedef short int16_type; -typedef unsigned short uint16_type; -typedef int int32_type; -typedef unsigned int uint32_type; - diff --git a/bfd/hosts/vaxult.h b/bfd/hosts/vaxult.h deleted file mode 100644 index 2de63961e8a..00000000000 --- a/bfd/hosts/vaxult.h +++ /dev/null @@ -1,41 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef O_ACCMODE -#define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR) -#endif -#define SEEK_SET 0 -#define SEEK_CUR 1 - -#include -#include -#define HOST_PAGE_SIZE NBPG -#define HOST_SEGMENT_SIZE NBPG /* Data seg start addr rounds to NBPG */ -#define HOST_MACHINE_ARCH bfd_arch_vax -/* #define HOST_MACHINE_MACHINE */ - -#define HOST_TEXT_START_ADDR USRTEXT -#define HOST_STACK_END_ADDR USRSTACK - -/* EXACT TYPES */ -typedef char int8e_type; -typedef unsigned char uint8e_type; -typedef short int16e_type; -typedef unsigned short uint16e_type; -typedef int int32e_type; -typedef unsigned int uint32e_type; - -/* CORRECT SIZE OR GREATER */ -typedef char int8_type; -typedef unsigned char uint8_type; -typedef short int16_type; -typedef unsigned short uint16_type; -typedef int int32_type; -typedef unsigned int uint32_type; diff --git a/bfd/howto.c b/bfd/howto.c deleted file mode 100755 index 0be2261f09e..00000000000 --- a/bfd/howto.c +++ /dev/null @@ -1,85 +0,0 @@ -/* bfd howto manager. - Copyright (C) 1990-1991 Free Software Foundation, Inc. - Written by Steve Chamberlain of Cygnus Support. - -This file is part of BFD, the Binary File Descriptor library. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* The howto manager - - -When an application wants to create a relocation, but doesn't know -what the target machine might call it, it can find out by using this -bit of code. - -*/ - -#include -#include -#include "libbfd.h" -/*proto* bfd_reloc_code_enum_type - -*+++ - -$typedef enum -${ - -16 bits wide, simple reloc - -$ BFD_RELOC_16, - -8 bits wide, but used to form an address like 0xffnn - -$ BFD_RELOC_8_FFnn, - -8 bits wide, simple - -$ BFD_RELOC_8, - -8 bits wide, pc relative - -$ BFD_RELOC_8_PCREL -$ } bfd_reloc_code_enum_real_type; - -*--- - -*/ - - - -/*proto* bfd_reloc_type_lookup -This routine returns a pointer to a howto struct which when invoked, -will perform the supplied relocation on data from the architecture -noted. - -[Note] This function will go away. - -*; PROTO(struct reloc_howto_struct *, - bfd_reloc_type_lookup, - (enum bfd_architecture arch, bfd_reloc_code_enum_type code)); -*/ - - -struct reloc_howto_struct * -DEFUN(bfd_reloc_type_lookup,(arch, code), - enum bfd_architecture arch AND - bfd_reloc_code_enum_type code) -{ - return arch_functions(arch,0)->reloc_type_lookup(code); -} - - - diff --git a/bfd/i386aout.c b/bfd/i386aout.c deleted file mode 100644 index 78226c74ab8..00000000000 --- a/bfd/i386aout.c +++ /dev/null @@ -1,151 +0,0 @@ -/* BFD back-end for i386 a.out binaries. - Copyright (C) 1990, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#define PAGE_SIZE 4096 -#define SEGMENT_SIZE PAGE_SIZE -#define TEXT_START_ADDR 0x8000 -#define ARCH 32 -#define BYTES_IN_WORD 4 - -#include "bfd.h" -#include "sysdep.h" -#include "libbfd.h" -#include "aout64.h" -#include "stab.gnu.h" -#include "ar.h" -#include "libaout.h" /* BFD a.out internal data structures */ - -bfd_target *aout386_callback (); - -bfd_target * -DEFUN(aout386_object_p,(abfd), - bfd *abfd) -{ - struct external_exec exec_bytes; - struct internal_exec exec; - - if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd) - != EXEC_BYTES_SIZE) { - bfd_error = wrong_format; - return 0; - } - - exec.a_info = bfd_h_get_32 (abfd, exec_bytes.e_info); - - if (N_BADMAG (exec)) return 0; - - NAME(aout,swap_exec_header_in)(abfd, &exec_bytes, &exec); - return aout_32_some_aout_object_p (abfd, &exec, aout386_callback); -} - -/* Finish up the reading of the file header */ -bfd_target * -DEFUN(aout386_callback,(abfd), - bfd *abfd) -{ - struct internal_exec *execp = exec_hdr (abfd); - - WORK_OUT_FILE_POSITIONS(abfd, execp) ; - - /* Determine the architecture and machine type of the object file. */ - bfd_default_set_arch_mach(abfd, bfd_arch_i386, 0); - - return abfd->xvec; -} - -/* Write an object file. - Section contents have already been written. We write the - file header, symbols, and relocation. */ - -boolean -DEFUN(aout386_write_object_contents,(abfd), - bfd *abfd) -{ - bfd_size_type data_pad = 0; - struct external_exec exec_bytes; - struct internal_exec *execp = exec_hdr (abfd); - - WRITE_HEADERS(abfd, execp); - return true; -} - -/* Transfer vector */ - -/* We use BSD archive files. */ -#define aout386_openr_next_archived_file bfd_generic_openr_next_archived_file -#define aout386_generic_stat_arch_elt bfd_generic_stat_arch_elt -#define aout386_slurp_armap bfd_slurp_bsd_armap -#define aout386_slurp_extended_name_table bfd_true -#define aout386_write_armap bsd_write_armap -#define aout386_truncate_arname bfd_bsd_truncate_arname - -/* We don't support core files here. */ -#define aout386_core_file_failing_command _bfd_dummy_core_file_failing_command -#define aout386_core_file_failing_signal _bfd_dummy_core_file_failing_signal -#define aout386_core_file_matches_executable_p \ - _bfd_dummy_core_file_matches_executable_p -#define aout386_core_file_p _bfd_dummy_target - -#define aout386_bfd_debug_info_start bfd_void -#define aout386_bfd_debug_info_end bfd_void -#define aout386_bfd_debug_info_accumulate (PROTO(void,(*),(bfd*, struct sec *))) bfd_void - -#define aout386_mkobject aout_32_mkobject -#define aout386_close_and_cleanup aout_32_close_and_cleanup -#define aout386_set_section_contents aout_32_set_section_contents -#define aout386_get_section_contents aout_32_get_section_contents -#define aout386_new_section_hook aout_32_new_section_hook -#define aout386_get_symtab_upper_bound aout_32_get_symtab_upper_bound -#define aout386_get_symtab aout_32_get_symtab -#define aout386_get_reloc_upper_bound aout_32_get_reloc_upper_bound -#define aout386_canonicalize_reloc aout_32_canonicalize_reloc -#define aout386_make_empty_symbol aout_32_make_empty_symbol -#define aout386_print_symbol aout_32_print_symbol -#define aout386_get_lineno aout_32_get_lineno -#define aout386_set_arch_mach aout_32_set_arch_mach -#define aout386_find_nearest_line aout_32_find_nearest_line -#define aout386_sizeof_headers aout_32_sizeof_headers - -bfd_target i386aout_vec = /* Intel 386 running a.out, embedded. */ -{ - "a.out-i386", /* name */ - bfd_target_aout_flavour, - false, /* target byte order */ - false, /* target headers byte order */ - (HAS_RELOC | EXEC_P | /* object flags */ - HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED), - (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ - ' ', /* ar_pad_char */ - 16, /* ar_max_namelen */ - 1, /* minimum alignment */ - /* data swap routines */ - _do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putl16, - /* header swap routines */ - _do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putl16, - - {_bfd_dummy_target, aout386_object_p, /* bfd_check_format */ - bfd_generic_archive_p, aout386_core_file_p}, - {bfd_false, aout386_mkobject, /* bfd_set_format */ - _bfd_generic_mkarchive, bfd_false}, - {bfd_false, aout386_write_object_contents, /* bfd_write_contents */ - _bfd_write_archive_contents, bfd_false}, - - JUMP_TABLE(aout386) -}; diff --git a/bfd/ieee.c b/bfd/ieee.c deleted file mode 100644 index b433027bc35..00000000000 --- a/bfd/ieee.c +++ /dev/null @@ -1,2949 +0,0 @@ -/* bfd back-end for ieee-695 objects. - Copyright (C) 1990-1991 Free Software Foundation, Inc. - Written by Steve Chamberlain of Cygnus Support. - -This file is part of BFD, the Binary File Descriptor library. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* IEEE 695 format is a stream of records, which we parse using a simple one- - token (which is one byte in this lexicon) lookahead recursive decent - parser. */ - -#include "bfd.h" -#include "sysdep.h" -#include "libbfd.h" -#include "ieee.h" -#include "libieee.h" - -/* Functions for writing to ieee files in the strange way that the - standard requires. */ - -static void -DEFUN(ieee_write_byte,(abfd, byte), - bfd *abfd AND - bfd_byte byte) -{ - bfd_write((PTR)&byte, 1, 1, abfd); -} - - -static void -DEFUN(ieee_write_twobyte,(abfd, twobyte), - bfd *abfd AND - int twobyte) -{ - bfd_byte b[2]; - b[1] = twobyte & 0xff; - b[0] = twobyte >> 8; - bfd_write((PTR)&b[0], 1, 2, abfd); -} - - - -static void -DEFUN(ieee_write_2bytes,(abfd, bytes), - bfd *abfd AND - int bytes) -{ - bfd_byte buffer[2]; - buffer[0] = bytes >> 8; - buffer[1] = bytes & 0xff; - - bfd_write((PTR)buffer, 1, 2, abfd); -} - -static void -DEFUN(ieee_write_int,(abfd, value), - bfd *abfd AND - bfd_vma value) -{ - if (((unsigned)value) <= 127) { - ieee_write_byte(abfd, value); - } - else { - unsigned int length; - /* How many significant bytes ? */ - /* FIXME FOR LONGER INTS */ - if (value & 0xff000000) { - length = 4; - } - else if (value & 0x00ff0000) { - length = 3; - } - else if (value & 0x0000ff00) { - length = 2; - } - else length = 1; - - ieee_write_byte(abfd, (int)ieee_number_repeat_start_enum + length); - switch (length) { - case 4: - ieee_write_byte(abfd, value >> 24); - case 3: - ieee_write_byte(abfd, value >> 16); - case 2: - ieee_write_byte(abfd, value >> 8); - case 1: - ieee_write_byte(abfd, value); - } - } -} - -static void -DEFUN(ieee_write_id,(abfd, id), - bfd *abfd AND - CONST char *id) -{ - size_t length = strlen(id); - if (length >= 0 && length <= 127) { - ieee_write_byte(abfd, length); - } - else if (length < 255) { - ieee_write_byte(abfd, ieee_extension_length_1_enum); - ieee_write_byte(abfd, length); - } - else if (length < 65535) { - ieee_write_byte(abfd, ieee_extension_length_2_enum); - ieee_write_byte(abfd, length >> 8); - ieee_write_byte(abfd, length & 0xff); - } - else { - BFD_FAIL(); - } - bfd_write((PTR)id, 1, length, abfd); -} -/*************************************************************************** -Functions for reading from ieee files in the strange way that the -standard requires: -*/ - - -#define this_byte(ieee) *((ieee)->input_p) -#define next_byte(ieee) ((ieee)->input_p++) -#define this_byte_and_next(ieee) (*((ieee)->input_p++)) - - -static unsigned short -DEFUN(read_2bytes,(ieee), - common_header_type *ieee) -{ - unsigned char c1 = this_byte_and_next(ieee); - unsigned char c2 = this_byte_and_next(ieee); - return (c1<<8 ) | c2; - -} - -static void -DEFUN(bfd_get_string,(ieee, string, length), - common_header_type *ieee AND - char *string AND - size_t length) -{ - size_t i; - for (i= 0; i < length; i++) { - string[i] = this_byte_and_next(ieee); - } -} - -static char * -DEFUN(read_id,(ieee), - common_header_type *ieee) -{ - size_t length; - char *string; - length = this_byte_and_next(ieee); - if (length >= 0x00 && length <= 0x7f) { - /* Simple string of length 0 to 127 */ - } - else if (length == 0xde) { - /* Length is next byte, allowing 0..255 */ - length = this_byte_and_next(ieee); - } - else if (length == 0xdf) { - /* Length is next two bytes, allowing 0..65535 */ - length = this_byte_and_next(ieee) ; - length = (length * 256) + this_byte_and_next(ieee); - } - /* Buy memory and read string */ - string = bfd_alloc(ieee->abfd, length+1); - bfd_get_string(ieee, string, length); - string[length] = 0; - return string; -} - -static void -DEFUN(ieee_write_expression,(abfd, value, section, symbol, pcrel, index), - bfd*abfd AND - bfd_vma value AND - asection *section AND - asymbol *symbol AND - boolean pcrel AND - unsigned int index) -{ - unsigned int plus_count = 0; - if (value != 0) - ieee_write_int(abfd, value); - - if (section != (asection *)NULL) { - plus_count++; - ieee_write_byte(abfd, ieee_variable_R_enum); - ieee_write_byte(abfd, section->index +IEEE_SECTION_NUMBER_BASE); - } - - - - if (symbol != (asymbol *)NULL) { - plus_count++; - if ((symbol->flags & BSF_UNDEFINED ) || - (symbol->flags & BSF_FORT_COMM)) { - ieee_write_byte(abfd, ieee_variable_X_enum); - ieee_write_int(abfd, symbol->value); - } - else if (symbol->flags & BSF_GLOBAL) { - ieee_write_byte(abfd, ieee_variable_I_enum); - ieee_write_int(abfd, symbol->value); - } - else if (symbol->flags & BSF_LOCAL) { - /* This is a reference to a defined local symbol, - We can easily do a local as a section+offset */ - if (symbol->section != (asection *)NULL) { - /* If this symbol is not absolute, add the base of it */ - ieee_write_byte(abfd, ieee_variable_R_enum); /* or L */ - ieee_write_byte(abfd, symbol->section->index + - IEEE_SECTION_NUMBER_BASE); - plus_count++; - } - - ieee_write_int(abfd, symbol->value); - } - else { - - BFD_FAIL(); - } - } - - if(pcrel) { - /* subtract the pc from here by asking for PC of this section*/ - ieee_write_byte(abfd, ieee_variable_P_enum); - ieee_write_byte(abfd, index +IEEE_SECTION_NUMBER_BASE); - ieee_write_byte(abfd, ieee_function_minus_enum); - } - - if (value != 0){ - while (plus_count > 0) { - ieee_write_byte(abfd, ieee_function_plus_enum); - plus_count--; - } - } - else { - if (!plus_count) - ieee_write_byte(abfd,0); - } - -} - - - - - - - - - -/*****************************************************************************/ - -/* -writes any integer into the buffer supplied and always takes 5 bytes -*/ -static void -DEFUN(ieee_write_int5,(buffer, value), - bfd_byte*buffer AND - bfd_vma value ) -{ - buffer[0] = (bfd_byte)ieee_number_repeat_4_enum; - buffer[1] = (value >> 24 ) & 0xff; - buffer[2] = (value >> 16 ) & 0xff; - buffer[3] = (value >> 8 ) & 0xff; - buffer[4] = (value >> 0 ) & 0xff; -} -static void -DEFUN(ieee_write_int5_out, (abfd, value), - bfd *abfd AND - bfd_vma value) -{ - bfd_byte b[5]; - ieee_write_int5(b, value); - bfd_write((PTR)b,1,5,abfd); -} - - -static boolean -DEFUN(parse_int,(ieee, value_ptr), - common_header_type *ieee AND - bfd_vma *value_ptr) -{ - int value = this_byte(ieee); - int result; - if (value >= 0 && value <= 127) { - *value_ptr = value; - next_byte(ieee); - return true; - } - else if (value >= 0x80 && value <= 0x88) { - unsigned int count = value & 0xf; - result = 0; - next_byte(ieee); - while (count) { - result =(result << 8) | this_byte_and_next(ieee); - count--; - } - *value_ptr = result; - return true; - } - return false; -} -static int -DEFUN(parse_i,(ieee, ok), - common_header_type *ieee AND - boolean *ok) -{ - bfd_vma x; - *ok = parse_int(ieee, &x); - return x; -} - -static bfd_vma -DEFUN(must_parse_int,(ieee), - common_header_type *ieee) -{ - bfd_vma result; - BFD_ASSERT(parse_int(ieee, &result) == true); - return result; -} - -typedef struct -{ - bfd_vma value; - asection *section; - ieee_symbol_index_type symbol; -} ieee_value_type; - - -static -reloc_howto_type abs32_howto - = HOWTO(1,0,2,32,false,0,false,true,0,"abs32",true,0xffffffff, 0xffffffff,false); -static -reloc_howto_type abs16_howto - = HOWTO(1,0,1,16,false,0,false,true,0,"abs16",true,0x0000ffff, 0x0000ffff,false); - -static -reloc_howto_type abs8_howto - = HOWTO(1,0,0,8,false,0,false,true,0,"abs8",true,0x000000ff, 0x000000ff,false); - -static -reloc_howto_type rel32_howto - = HOWTO(1,0,2,32,true,0,false,true,0,"rel32",true,0xffffffff, 0xffffffff,true); -static -reloc_howto_type rel16_howto - = HOWTO(1,0,1,16,true,0,false,true,0,"rel16",true,0x0000ffff, 0x0000ffff,true); - -static -reloc_howto_type rel8_howto - = HOWTO(1,0,0,8,true,0,false,true,0,"rel8",true,0x000000ff, 0x000000ff,true); - - -static ieee_symbol_index_type NOSYMBOL = { 0, 0}; - - -static void -DEFUN(parse_expression,(ieee, value, section, symbol, pcrel, extra), - ieee_data_type *ieee AND - bfd_vma *value AND - asection **section AND - ieee_symbol_index_type *symbol AND - boolean *pcrel AND - unsigned int *extra) - -{ -#define POS sp[1] -#define TOS sp[0] -#define NOS sp[-1] -#define INC sp++; -#define DEC sp--; - - boolean loop = true; - ieee_value_type stack[10]; - - /* The stack pointer always points to the next unused location */ -#define PUSH(x,y,z) TOS.symbol=x;TOS.section=y;TOS.value=z;INC; -#define POP(x,y,z) DEC;x=TOS.symbol;y=TOS.section;z=TOS.value; - ieee_value_type *sp = stack; - - while (loop) { - switch (this_byte(&(ieee->h))) - { - case ieee_variable_P_enum: - /* P variable, current program counter for section n */ - { - int section_n ; - next_byte(&(ieee->h)); - *pcrel = true; - section_n = must_parse_int(&(ieee->h)); - PUSH(NOSYMBOL, 0, - TOS.value = ieee->section_table[section_n]->vma + - ieee_per_section(ieee->section_table[section_n])->pc); - break; - } - case ieee_variable_L_enum: - /* L variable address of section N */ - next_byte(&(ieee->h)); - PUSH(NOSYMBOL,ieee->section_table[must_parse_int(&(ieee->h))],0); - break; - case ieee_variable_R_enum: - /* R variable, logical address of section module */ - /* FIXME, this should be different to L */ - next_byte(&(ieee->h)); - PUSH(NOSYMBOL,ieee->section_table[must_parse_int(&(ieee->h))],0); - break; - case ieee_variable_S_enum: - /* S variable, size in MAUS of section module */ - next_byte(&(ieee->h)); - PUSH(NOSYMBOL, - 0, - ieee->section_table[must_parse_int(&(ieee->h))]->size); - break; - case ieee_variable_I_enum: - case ieee_variable_X_enum: - /* Push the address of external variable n */ - { - ieee_symbol_index_type sy; - next_byte(&(ieee->h)); - sy.index = (int)(must_parse_int(&(ieee->h))) ; - sy.letter = 'X'; - - PUSH(sy, 0, 0); - } - break; - case ieee_function_minus_enum: - { - bfd_vma value1, value2; - asection *section1, *section_dummy; - ieee_symbol_index_type sy; - next_byte(&(ieee->h)); - - POP(sy, section1, value1); - POP(sy, section_dummy, value2); - PUSH(sy, section1 ? section1 : section_dummy, value1-value2); - } - break; - case ieee_function_plus_enum: - { - bfd_vma value1, value2; - asection *section1; - asection *section2; - ieee_symbol_index_type sy1; - ieee_symbol_index_type sy2; - next_byte(&(ieee->h)); - - POP(sy1, section1, value1); - POP(sy2, section2, value2); - PUSH(sy1.letter ? sy1 : sy2, section1 ? section1: section2, value1+value2); - } - break; - default: - { - bfd_vma va; - BFD_ASSERT(this_byte(&(ieee->h)) < (int)ieee_variable_A_enum - || this_byte(&(ieee->h)) > (int)ieee_variable_Z_enum); - if (parse_int(&(ieee->h), &va)) - { - PUSH(NOSYMBOL,0, va); - } - else { - /* - Thats all that we can understand. As far as I can see - there is a bug in the Microtec IEEE output which I'm - using to scan, whereby the comma operator is ommited - sometimes in an expression, giving expressions with too - many terms. We can tell if that's the case by ensuring - that sp == stack here. If not, then we've pushed - something too far, so we keep adding - */ - - while (sp != stack+1) { - asection *section1; - ieee_symbol_index_type sy1; - POP(sy1, section1, *extra); - } - - POP(*symbol, *section, *value); - loop = false; - } - } - - } - } -} - - - -#define ieee_seek(abfd, offset) \ - ieee_data(abfd)->h.input_p = ieee_data(abfd)->h.first_byte + offset - -#define ieee_pos(abfd) ieee_data(abfd)->h.input_p -ieee_data(abfd)->h.first_byte - -static unsigned int last_index; - -static ieee_symbol_type * -DEFUN(get_symbol,(abfd, - ieee, - last_symbol, - symbol_count, -pptr, -max_index - ), - bfd *abfd AND - ieee_data_type *ieee AND - ieee_symbol_type *last_symbol AND - unsigned int *symbol_count AND - ieee_symbol_type *** pptr AND - unsigned int *max_index - ) -{ - /* Need a new symbol */ - unsigned int new_index = must_parse_int(&(ieee->h)); - if (new_index != last_index) { - ieee_symbol_type * new_symbol = (ieee_symbol_type *)bfd_alloc(ieee->h.abfd, - sizeof(ieee_symbol_type)); - - new_symbol->index = new_index; - last_index = new_index; - ( *symbol_count)++; - ** pptr= new_symbol; - *pptr = &new_symbol->next; - if (new_index > *max_index) { - *max_index = new_index; - } - return new_symbol; - } - return last_symbol; -} -static void -DEFUN(ieee_slurp_external_symbols,(abfd), - bfd *abfd) -{ - ieee_data_type *ieee = ieee_data(abfd); - file_ptr offset = ieee->w.r.external_part; - - - ieee_symbol_type **prev_symbols_ptr = &ieee->external_symbols; - ieee_symbol_type **prev_reference_ptr = &ieee->external_reference; - ieee_symbol_type *symbol = (ieee_symbol_type *)NULL; - unsigned int symbol_count = 0; - boolean loop = true; - last_index = 0xffffff; - ieee->symbol_table_full = true; - - ieee_seek(abfd, offset ); - - while (loop) { - switch (this_byte(&(ieee->h))) { - case ieee_nn_record: - next_byte(&(ieee->h)); - symbol = get_symbol(abfd, ieee, symbol, &symbol_count, - &prev_symbols_ptr, - &ieee->external_symbol_max_index); - - symbol->symbol.the_bfd = abfd; - symbol->symbol.name = read_id(&(ieee->h)); - symbol->symbol.udata = (PTR)NULL; - symbol->symbol.flags = BSF_NO_FLAGS; - - - break; - case ieee_external_symbol_enum: - next_byte(&(ieee->h)); - - symbol = get_symbol(abfd, ieee, symbol, &symbol_count, - &prev_symbols_ptr, - &ieee->external_symbol_max_index); - - - BFD_ASSERT (symbol->index >= ieee->external_symbol_min_index); - - symbol->symbol.the_bfd = abfd; - symbol->symbol.name = read_id(&(ieee->h)); - symbol->symbol.udata = (PTR)NULL; - symbol->symbol.flags = BSF_NO_FLAGS; - break; - case ieee_attribute_record_enum >> 8: - { - unsigned int symbol_name_index; - unsigned int symbol_type_index; - unsigned int symbol_attribute_def; - bfd_vma value; - next_byte(&(ieee->h)); /* Skip prefix */ - next_byte(&(ieee->h)); - symbol_name_index = must_parse_int(&(ieee->h)); - symbol_type_index = must_parse_int(&(ieee->h)); - symbol_attribute_def = must_parse_int(&(ieee->h)); - switch (symbol_attribute_def) { - case 63: - /* Module misc; followed by two fields which describe the - current module block. The first fired is the type id - number, the second is the number of asn records - associated with the directive */ - parse_int(&(ieee->h),&value); - parse_int(&(ieee->h),&value); - break; - - default: - parse_int(&(ieee->h),&value); - break; - } - } - break; - case ieee_value_record_enum >> 8: - { - unsigned int symbol_name_index; - ieee_symbol_index_type symbol_ignore; - boolean pcrel_ignore; - unsigned int extra; - next_byte(&(ieee->h)); - next_byte(&(ieee->h)); - - symbol_name_index = must_parse_int(&(ieee->h)); - parse_expression(ieee, - &symbol->symbol.value, - &symbol->symbol.section, - &symbol_ignore, - &pcrel_ignore, - &extra); - if (symbol->symbol.section != (asection *)NULL) { - symbol->symbol.flags = BSF_GLOBAL | BSF_EXPORT; - } - else { - symbol->symbol.flags = BSF_GLOBAL | BSF_EXPORT | BSF_ABSOLUTE; - } - } - break; - case ieee_weak_external_reference_enum: - { bfd_vma size; - bfd_vma value ; - next_byte(&(ieee->h)); - /* Throw away the external reference index */ - (void)must_parse_int(&(ieee->h)); - /* Fetch the default size if not resolved */ - size = must_parse_int(&(ieee->h)); - /* Fetch the defautlt value if available */ - if ( parse_int(&(ieee->h), &value) == false) { - value = 0; - } - /* This turns into a common */ - symbol->symbol.flags = BSF_FORT_COMM; - symbol->symbol.value = size; - } - break; - - case ieee_external_reference_enum: - next_byte(&(ieee->h)); - - symbol = get_symbol(abfd, ieee, symbol, &symbol_count, - &prev_reference_ptr, - &ieee->external_reference_max_index); - - - symbol->symbol.the_bfd = abfd; - symbol->symbol.name = read_id(&(ieee->h)); - symbol->symbol.udata = (PTR)NULL; - symbol->symbol.section = (asection *)NULL; - symbol->symbol.value = (bfd_vma)0; - symbol->symbol.flags = BSF_UNDEFINED; - - BFD_ASSERT (symbol->index >= ieee->external_reference_min_index); - break; - - default: - loop = false; - } - } - - if (ieee->external_symbol_max_index != 0) { - ieee->external_symbol_count = - ieee->external_symbol_max_index - - ieee->external_symbol_min_index + 1 ; - } - else { - ieee->external_symbol_count = 0; - } - - - if(ieee->external_reference_max_index != 0) { - ieee->external_reference_count = - ieee->external_reference_max_index - - ieee->external_reference_min_index + 1; - } - else { - ieee->external_reference_count = 0; - } - - abfd->symcount = - ieee->external_reference_count + ieee->external_symbol_count; - - if (symbol_count != abfd->symcount) { - /* There are gaps in the table -- */ - ieee->symbol_table_full = false; - } - - - *prev_symbols_ptr = (ieee_symbol_type *)NULL; - *prev_reference_ptr = (ieee_symbol_type *)NULL; -} - -static void -DEFUN(ieee_slurp_symbol_table,(abfd), - bfd *abfd) -{ - if (ieee_data(abfd)->read_symbols == false) { - ieee_slurp_external_symbols(abfd); - ieee_data(abfd)->read_symbols= true; - } -} - -unsigned int -DEFUN(ieee_get_symtab_upper_bound,(abfd), - bfd *abfd) -{ - ieee_slurp_symbol_table (abfd); - - return (abfd->symcount != 0) ? - (abfd->symcount+1) * (sizeof (ieee_symbol_type *)) : 0; -} - -/* -Move from our internal lists to the canon table, and insert in -symbol index order -*/ - -extern bfd_target ieee_vec; -unsigned int -DEFUN(ieee_get_symtab,(abfd, location), - bfd *abfd AND - asymbol **location) -{ - ieee_symbol_type *symp; - static bfd dummy_bfd; - static asymbol empty_symbol = - { &dummy_bfd," ieee empty",(symvalue)0,BSF_DEBUGGING | BSF_ABSOLUTE}; - -if (abfd->symcount) { - - - - - ieee_data_type *ieee = ieee_data(abfd); - dummy_bfd.xvec= &ieee_vec; - ieee_slurp_symbol_table(abfd); - - if (ieee->symbol_table_full == false) { - /* Arrgh - there are gaps in the table, run through and fill them */ - /* up with pointers to a null place */ - unsigned int i; - for (i= 0; i < abfd->symcount; i++) { - location[i] = &empty_symbol; - } - } - - - ieee->external_symbol_base_offset= - ieee->external_symbol_min_index; - for (symp = ieee_data(abfd)->external_symbols; - symp != (ieee_symbol_type *)NULL; - symp = symp->next) { - /* Place into table at correct index locations */ - location[symp->index + ieee->external_symbol_base_offset] = &symp->symbol; - - } - - /* The external refs are indexed in a bit */ - ieee->external_reference_base_offset = - - ieee->external_reference_min_index +ieee->external_symbol_count ; - - for (symp = ieee_data(abfd)->external_reference; - symp != (ieee_symbol_type *)NULL; - symp = symp->next) { - location[symp->index + ieee->external_reference_base_offset] = - &symp->symbol; - - } - - - - location[abfd->symcount] = (asymbol *)NULL; -} - return abfd->symcount; -} -static asection * -DEFUN(get_section_entry,(abfd, ieee,index), - bfd *abfd AND - ieee_data_type *ieee AND - unsigned int index) -{ - if (ieee->section_table[index] == (asection *)NULL) { - asection *section = bfd_make_section(abfd, " tempname"); - ieee->section_table[index] = section; - section->flags = SEC_NO_FLAGS; - section->target_index = index; - ieee->section_table[index] = section; - } - return ieee->section_table[index]; -} - -static void -DEFUN(ieee_slurp_sections,(abfd), - bfd *abfd) -{ - ieee_data_type *ieee = ieee_data(abfd); - file_ptr offset = ieee->w.r.section_part; - - asection *section = (asection *)NULL; - - if (offset != 0) { - bfd_byte section_type[3]; - ieee_seek(abfd, offset); - while (true) { - switch (this_byte(&(ieee->h))) { - case ieee_section_type_enum: - { - unsigned int section_index ; - next_byte(&(ieee->h)); - section_index = must_parse_int(&(ieee->h)); - /* Fixme to be nice about a silly number of sections */ - BFD_ASSERT(section_index < NSECTIONS); - - section =get_section_entry(abfd, ieee, section_index); - - section_type[0] = this_byte_and_next(&(ieee->h)); - switch (section_type[0]) { - case 0xC1: - /* Normal attributes for absolute sections */ - section_type[1] = this_byte(&(ieee->h)); - section->flags = SEC_LOAD | SEC_ALLOC | SEC_HAS_CONTENTS; - switch(section_type[1]) { - case 0xD3: - next_byte(&(ieee->h)); - section_type[2] = this_byte(&(ieee->h)); - switch (section_type[2]) - { - case 0xD0: - /* Normal code */ - next_byte(&(ieee->h)); - section->flags |= SEC_LOAD | SEC_CODE; - break; - case 0xC4: - next_byte(&(ieee->h)); - section->flags |= SEC_LOAD | SEC_DATA; - /* Normal data */ - break; - case 0xD2: - next_byte(&(ieee->h)); - /* Normal rom data */ - section->flags |= SEC_LOAD | SEC_ROM | SEC_DATA; - break; - default: - break; - } - } - break; - case 0xC3: - section_type[1] = this_byte(&(ieee->h)); - section->flags = SEC_LOAD | SEC_ALLOC | SEC_HAS_CONTENTS; - switch (section_type[1]) { - case 0xD0: - /* Normal code */ - next_byte(&(ieee->h)); - section->flags |= SEC_LOAD | SEC_CODE; - break; - case 0xC4: - next_byte(&(ieee->h)); - section->flags |= SEC_LOAD | SEC_DATA; - /* Normal data */ - break; - case 0xD2: - next_byte(&(ieee->h)); - /* Normal rom data */ - section->flags |= SEC_LOAD | SEC_ROM | SEC_DATA; - break; - default: - break; - } - } - section->name = read_id(&(ieee->h)); - { bfd_vma parent, brother, context; - parse_int(&(ieee->h), &parent); - parse_int(&(ieee->h), &brother); - parse_int(&(ieee->h), &context); - } - - - } - break; - case ieee_section_alignment_enum: - { - unsigned int section_index; - bfd_vma value; - asection *section; - next_byte(&(ieee->h)); - section_index = must_parse_int(&ieee->h); - section = get_section_entry(abfd, ieee, section_index); - if (section_index > ieee->section_count) { - ieee->section_count = section_index; - } - section->alignment_power = - bfd_log2(must_parse_int(&ieee->h)); - (void)parse_int(&(ieee->h), & value); - } - break; - case ieee_e2_first_byte_enum: - { - ieee_record_enum_type t = (ieee_record_enum_type)(read_2bytes(&(ieee->h))); - - switch (t) { - case ieee_section_size_enum: - section = ieee->section_table[must_parse_int(&(ieee->h))]; - section->size = must_parse_int(&(ieee->h)); - break; - case ieee_physical_region_size_enum: - section = ieee->section_table[must_parse_int(&(ieee->h))]; - section->size = must_parse_int(&(ieee->h)); - break; - case ieee_region_base_address_enum: - section = ieee->section_table[must_parse_int(&(ieee->h))]; - section->vma = must_parse_int(&(ieee->h)); - break; - case ieee_mau_size_enum: - must_parse_int(&(ieee->h)); - must_parse_int(&(ieee->h)); - break; - case ieee_m_value_enum: - must_parse_int(&(ieee->h)); - must_parse_int(&(ieee->h)); - break; - case ieee_section_base_address_enum: - section = ieee->section_table[must_parse_int(&(ieee->h))]; - section->vma = must_parse_int(&(ieee->h)); - break; - case ieee_section_offset_enum: - (void) must_parse_int(&(ieee->h)); - (void) must_parse_int(&(ieee->h)); - break; - default: - return; - } - } - break; - default: - return; - } - } - } -} - -/*********************************************************************** -* archive stuff -*/ -bfd_target * -DEFUN(ieee_archive_p,(abfd), - bfd *abfd) -{ - char *library; - boolean loop; - - unsigned int i; -uint8e_type buffer[512]; - - int buffer_offset = 0; - ieee_ar_data_type *save = ieee_ar_data(abfd); - ieee_ar_data_type *ieee ; - set_tdata(abfd, bfd_alloc(abfd, sizeof(ieee_ar_data_type))); - ieee= ieee_ar_data(abfd); - - - bfd_read((PTR)buffer, 1, sizeof(buffer), abfd); - - ieee->h.first_byte = buffer; - ieee->h.input_p = buffer; - - ieee->h.abfd = abfd; - - if (this_byte(&(ieee->h)) != Module_Beginning) return (bfd_target*)NULL; - - next_byte(&(ieee->h)); - library= read_id(&(ieee->h)); - if (strcmp(library , "LIBRARY") != 0) { - bfd_release(abfd, ieee); - set_tdata (abfd, save); - return (bfd_target *)NULL; - } - /* Throw away the filename */ - free( read_id(&(ieee->h))); - /* This must be an IEEE archive, so we'll buy some space to do - things */ - ieee->element_count = 0; - ieee->element_index = 0; - - next_byte(&(ieee->h)); /* Drop the ad part */ - must_parse_int(&(ieee->h)); /* And the two dummy numbers */ - must_parse_int(&(ieee->h)); - - loop = true; - /* Read the index of the BB table */ - while (loop) { - ieee_ar_obstack_type t; - int rec =read_2bytes(&(ieee->h)); - if (rec ==(int)ieee_assign_value_to_variable_enum) { - int record_number = must_parse_int(&(ieee->h)); - t.file_offset = must_parse_int(&(ieee->h)); - t.abfd = (bfd *)NULL; - ieee->element_count++; - bfd_alloc_grow(abfd, (PTR)&t, sizeof(t)); - - /* Make sure that we don't go over the end of the buffer */ - - if (ieee_pos(abfd) > sizeof(buffer)/2) { - /* Past half way, reseek and reprime */ - buffer_offset += ieee_pos(abfd); - bfd_seek(abfd, buffer_offset, SEEK_SET); - bfd_read((PTR)buffer, 1, sizeof(buffer), abfd); - ieee->h.first_byte = buffer; - ieee->h.input_p = buffer; - } - } - else loop = false; - } - - ieee->elements = (ieee_ar_obstack_type *)bfd_alloc_finish(abfd); - - /* Now scan the area again, and replace BB offsets with file */ - /* offsets */ - - - for (i = 2; i < ieee->element_count; i++) { - bfd_seek(abfd, ieee->elements[i].file_offset, SEEK_SET); - bfd_read((PTR)buffer, 1, sizeof(buffer), abfd); - ieee->h.first_byte = buffer; - ieee->h.input_p = buffer; - - next_byte(&(ieee->h)); /* Drop F8 */ - next_byte(&(ieee->h)); /* Drop 14 */ - must_parse_int(&(ieee->h)); /* Drop size of block */ - if (must_parse_int(&(ieee->h)) != 0) { - /* This object has been deleted */ - ieee->elements[i].file_offset = 0; - } - else { - ieee->elements[i].file_offset = must_parse_int(&(ieee->h)); - } - } - - return abfd->xvec; - -} - -static boolean -DEFUN(ieee_mkobject,(abfd), - bfd *abfd) -{ - set_tdata (abfd, bfd_zalloc(abfd,sizeof(ieee_data_type))); - - - return true; -} - -bfd_target * -DEFUN(ieee_object_p,(abfd), - bfd *abfd) -{ - char *processor; - unsigned int part; - ieee_data_type *ieee; - uint8e_type buffer[300]; - ieee_data_type *save = ieee_data(abfd); - set_tdata (abfd, 0); - ieee_mkobject(abfd); - ieee = ieee_data(abfd); - - /* Read the first few bytes in to see if it makes sense */ - bfd_read((PTR)buffer, 1, sizeof(buffer), abfd); - - ieee->h.input_p = buffer; - if (this_byte_and_next(&(ieee->h)) != Module_Beginning) goto fail; - - ieee->read_symbols= false; - ieee->read_data= false; - ieee->section_count = 0; - ieee->external_symbol_max_index = 0; - ieee->external_symbol_min_index = IEEE_PUBLIC_BASE; - ieee->external_reference_min_index =IEEE_REFERENCE_BASE; - ieee->external_reference_max_index = 0; - ieee->h.abfd = abfd; - memset((PTR)ieee->section_table, 0, sizeof(ieee->section_table)); - - processor = ieee->mb.processor = read_id(&(ieee->h)); - if (strcmp(processor,"LIBRARY") == 0) goto fail; - ieee->mb.module_name = read_id(&(ieee->h)); - if (abfd->filename == (char *)NULL) { - abfd->filename = ieee->mb.module_name; - } - /* Determine the architecture and machine type of the object file. - */ - { - bfd_arch_info_type *arch = bfd_scan_arch(processor); - if (arch == 0) goto fail; - abfd->arch_info = arch; - } - - if (this_byte(&(ieee->h)) != (int)ieee_address_descriptor_enum) { - goto fail; - } - next_byte(&(ieee->h)); - - if (parse_int(&(ieee->h), &ieee->ad.number_of_bits_mau) == false) { - goto fail; - } - if(parse_int(&(ieee->h), &ieee->ad.number_of_maus_in_address) == false) { - goto fail; - } - - /* If there is a byte order info, take it */ - if (this_byte(&(ieee->h)) == (int)ieee_variable_L_enum || - this_byte(&(ieee->h)) == (int)ieee_variable_M_enum) - next_byte(&(ieee->h)); - - - for (part = 0; part < N_W_VARIABLES; part++) { - boolean ok; - if (read_2bytes(&(ieee->h)) != (int) ieee_assign_value_to_variable_enum) { - goto fail; - } - if (this_byte_and_next(&(ieee->h)) != part) { - goto fail; - } - - ieee->w.offset[part] = parse_i(&(ieee->h), &ok); - if (ok==false) { - goto fail; - } - - } - abfd->flags = HAS_SYMS; - -/* By now we know that this is a real IEEE file, we're going to read - the whole thing into memory so that we can run up and down it - quickly. We can work out how big the file is from the trailer - record */ - - ieee_data(abfd)->h.first_byte = (uint8e_type *) bfd_alloc(ieee->h.abfd, ieee->w.r.me_record - + 50); - bfd_seek(abfd, 0, 0); - bfd_read((PTR)(ieee_data(abfd)->h.first_byte), 1, ieee->w.r.me_record+50, abfd); - - ieee_slurp_sections(abfd); - return abfd->xvec; - fail: - (void) bfd_release(abfd, ieee); - set_tdata (abfd, save); - return (bfd_target *)NULL; -} - - -void -DEFUN(ieee_print_symbol,(ignore_abfd, afile, symbol, how), - bfd *ignore_abfd AND - PTR afile AND - asymbol *symbol AND - bfd_print_symbol_type how) -{ - FILE *file = (FILE *)afile; - - switch (how) { - case bfd_print_symbol_name: - fprintf(file,"%s", symbol->name); - break; - case bfd_print_symbol_more: -#if 0 - fprintf(file,"%4x %2x",aout_symbol(symbol)->desc & 0xffff, - aout_symbol(symbol)->other & 0xff); -#endif - BFD_FAIL(); - break; - case bfd_print_symbol_all: - { - CONST char *section_name = symbol->section == (asection *)NULL ? - "*abs" : symbol->section->name; - if (symbol->name[0] == ' ') { - fprintf(file,"* empty table entry "); - } - else { - bfd_print_symbol_vandf((PTR)file,symbol); - - fprintf(file," %-5s %04x %02x %s", - section_name, - (unsigned) ieee_symbol(symbol)->index, - (unsigned) 0, /* - aout_symbol(symbol)->desc & 0xffff, - aout_symbol(symbol)->other & 0xff,*/ - symbol->name); - } - } - break; - } -} - - -static void -DEFUN(do_one,(ieee, current_map, location_ptr,s), - ieee_data_type *ieee AND - ieee_per_section_type *current_map AND - uint8e_type *location_ptr AND - asection *s) -{ - switch (this_byte(&(ieee->h))) - { - case ieee_load_constant_bytes_enum: - { - unsigned int number_of_maus; - unsigned int i; - next_byte(&(ieee->h)); - number_of_maus = must_parse_int(&(ieee->h)); - - for (i = 0; i < number_of_maus; i++) { - location_ptr[current_map->pc++]= this_byte(&(ieee->h)); - next_byte(&(ieee->h)); - } - } - break; - - case ieee_load_with_relocation_enum: - { - boolean loop = true; - next_byte(&(ieee->h)); - while (loop) - { - switch (this_byte(&(ieee->h))) - { - case ieee_variable_R_enum: - - case ieee_function_signed_open_b_enum: - case ieee_function_unsigned_open_b_enum: - case ieee_function_either_open_b_enum: - { - unsigned int extra = 4; - boolean pcrel = false; - - ieee_reloc_type *r = - (ieee_reloc_type *) bfd_alloc(ieee->h.abfd, - sizeof(ieee_reloc_type)); - - *(current_map->reloc_tail_ptr) = r; - current_map->reloc_tail_ptr= &r->next; - r->next = (ieee_reloc_type *)NULL; - next_byte(&(ieee->h)); - parse_expression(ieee, - &r->relent.addend, - &r->relent.section, - &r->symbol, - &pcrel, &extra); - r->relent.address = current_map->pc; - s->reloc_count++; - - if (this_byte(&(ieee->h)) == (int)ieee_comma) { - next_byte(&(ieee->h)); - /* Fetch number of bytes to pad */ - extra = must_parse_int(&(ieee->h)); - }; - - switch (this_byte(&(ieee->h))) { - case ieee_function_signed_close_b_enum: - next_byte(&(ieee->h)); - break; - case ieee_function_unsigned_close_b_enum: - next_byte(&(ieee->h)); - break; - case ieee_function_either_close_b_enum: - next_byte(&(ieee->h)); - break; - default: - break; - } - /* Build a relocation entry for this type */ - /* If pc rel then stick -ve pc into instruction - and take out of reloc .. - - I've changed this. It's all too - complicated. I keep 0 in the - instruction now. - */ - - switch (extra) - { - case 0: - case 4: - - if (pcrel == true) - { -#if KEEPMINUSPCININST - bfd_put_32(ieee->h.abfd, -current_map->pc, location_ptr + - current_map->pc); - r->relent.howto = &rel32_howto; - r->relent.addend -= - current_map->pc; -#else - bfd_put_32(ieee->h.abfd,0, location_ptr + - current_map->pc); - r->relent.howto = &rel32_howto; -#endif - } - else - { - bfd_put_32(ieee->h.abfd, 0, location_ptr + - current_map->pc); - r->relent.howto = &abs32_howto; - } - current_map->pc +=4; - break; - case 2: - if (pcrel == true) { -#if KEEPMINUSPCININST - bfd_put_16(ieee->h.abfd, (int)(-current_map->pc), location_ptr +current_map->pc); - r->relent.addend -= current_map->pc; - r->relent.howto = &rel16_howto; -#else - - bfd_put_16(ieee->h.abfd, 0, location_ptr +current_map->pc); - r->relent.howto = &rel16_howto; -#endif - } - - else { - bfd_put_16(ieee->h.abfd, 0, location_ptr +current_map->pc); - r->relent.howto = &abs16_howto; - } - current_map->pc +=2; - break; - case 1: - if (pcrel == true) { -#if KEEPMINUSPCININST - bfd_put_8(ieee->h.abfd, (int)(-current_map->pc), location_ptr +current_map->pc); - r->relent.addend -= current_map->pc; - r->relent.howto = &rel8_howto; -#else - bfd_put_8(ieee->h.abfd,0, location_ptr +current_map->pc); - r->relent.howto = &rel8_howto; -#endif - } - else { - bfd_put_8(ieee->h.abfd, 0, location_ptr +current_map->pc); - r->relent.howto = &abs8_howto; - } - current_map->pc +=1; - break; - - default: - BFD_FAIL(); - break; - } - } - break; - default: - { - bfd_vma this_size ; - if (parse_int(&(ieee->h), &this_size) == true) { - unsigned int i; - for (i = 0; i < this_size; i++) { - location_ptr[current_map->pc ++] = this_byte(&(ieee->h)); - next_byte(&(ieee->h)); - } - } - else { - loop = false; - } - } - } - } - } - } -} - -/* Read in all the section data and relocation stuff too */ -static boolean -DEFUN(ieee_slurp_section_data,(abfd), - bfd *abfd) -{ - bfd_byte *location_ptr = (bfd_byte *)NULL; - ieee_data_type *ieee = ieee_data(abfd); - unsigned int section_number ; - - ieee_per_section_type *current_map = (ieee_per_section_type *)NULL; - asection *s; - /* Seek to the start of the data area */ - if (ieee->read_data== true) return true; - ieee->read_data = true; - ieee_seek(abfd, ieee->w.r.data_part); - - /* Allocate enough space for all the section contents */ - - - for (s = abfd->sections; s != (asection *)NULL; s = s->next) { - ieee_per_section_type *per = (ieee_per_section_type *) s->used_by_bfd; - per->data = (bfd_byte *) bfd_alloc(ieee->h.abfd, s->size); - /*SUPPRESS 68*/ - per->reloc_tail_ptr = - (ieee_reloc_type **)&(s->relocation); - } - - - - while (true) { - switch (this_byte(&(ieee->h))) - { - /* IF we see anything strange then quit */ - default: - return true; - - case ieee_set_current_section_enum: - next_byte(&(ieee->h)); - section_number = must_parse_int(&(ieee->h)); - s = ieee->section_table[section_number]; - current_map = (ieee_per_section_type *) s->used_by_bfd; - location_ptr = current_map->data - s->vma; - /* The document I have says that Microtec's compilers reset */ - /* this after a sec section, even though the standard says not */ - /* to. SO .. */ - current_map->pc =s->vma; - break; - - - case ieee_e2_first_byte_enum: - next_byte(&(ieee->h)); - switch (this_byte(&(ieee->h))) - { - case ieee_set_current_pc_enum & 0xff: - { - bfd_vma value; - asection *dsection; - ieee_symbol_index_type symbol; - unsigned int extra; - boolean pcrel; - next_byte(&(ieee->h)); - must_parse_int(&(ieee->h)); /* Thow away section #*/ - parse_expression(ieee, &value, &dsection, &symbol, - &pcrel, &extra); - current_map->pc = value; - BFD_ASSERT((unsigned)(value - s->vma) <= s->size); - } - break; - - case ieee_value_starting_address_enum & 0xff: - /* We've got to the end of the data now - */ - return true; - default: - BFD_FAIL(); - return true; - } - break; - case ieee_repeat_data_enum: - { - /* Repeat the following LD or LR n times - we do this by - remembering the stream pointer before running it and - resetting it and running it n times. We special case - the repetition of a repeat_data/load_constant - */ - - unsigned int iterations ; - uint8e_type *start ; - next_byte(&(ieee->h)); - iterations = must_parse_int(&(ieee->h)); - start = ieee->h.input_p; - if (start[0] == (int)ieee_load_constant_bytes_enum && - start[1] == 1) { - while (iterations != 0) { - location_ptr[current_map->pc++] = start[2]; - iterations--; - } - next_byte(&(ieee->h)); - next_byte(&(ieee->h)); - next_byte(&(ieee->h)); - } - else { - while (iterations != 0) { - ieee->h.input_p = start; - do_one(ieee, current_map, location_ptr,s); - iterations --; - } - } - } - break; - case ieee_load_constant_bytes_enum: - case ieee_load_with_relocation_enum: - { - do_one(ieee, current_map, location_ptr,s); - } - } - } -} - - - - - -boolean -DEFUN(ieee_new_section_hook,(abfd, newsect), - bfd *abfd AND - asection *newsect) -{ - newsect->used_by_bfd = (PTR) - bfd_alloc(abfd, sizeof(ieee_per_section_type)); - ieee_per_section( newsect)->data = (bfd_byte *)NULL; - ieee_per_section(newsect)->section = newsect; - return true; -} - - -unsigned int -DEFUN(ieee_get_reloc_upper_bound,(abfd, asect), - bfd *abfd AND - sec_ptr asect) -{ - ieee_slurp_section_data(abfd); - return (asect->reloc_count+1) * sizeof(arelent *); -} - -static boolean -DEFUN(ieee_get_section_contents,(abfd, section, location, offset, count), - bfd *abfd AND - sec_ptr section AND - PTR location AND - file_ptr offset AND - bfd_size_type count) -{ - ieee_per_section_type *p = (ieee_per_section_type *) section->used_by_bfd; - ieee_slurp_section_data(abfd); - (void) memcpy((PTR)location, (PTR)(p->data + offset), (unsigned)count); - return true; -} - - -unsigned int -DEFUN(ieee_canonicalize_reloc,(abfd, section, relptr, symbols), - bfd *abfd AND - sec_ptr section AND - arelent **relptr AND - asymbol **symbols) -{ -/* ieee_per_section_type *p = (ieee_per_section_type *) section->used_by_bfd;*/ - ieee_reloc_type *src = (ieee_reloc_type *)(section->relocation); - ieee_data_type *ieee = ieee_data(abfd); - - while (src != (ieee_reloc_type *)NULL) { - /* Work out which symbol to attach it this reloc to */ - switch (src->symbol.letter) { - case 'X': - src->relent.sym_ptr_ptr = - symbols + src->symbol.index + ieee->external_reference_base_offset; - break; - case 0: - src->relent.sym_ptr_ptr = (asymbol **)NULL; - break; - default: - - BFD_FAIL(); - } - *relptr++ = &src->relent; - src = src->next; - } - *relptr = (arelent *)NULL; - return section->reloc_count; -} - - - -static int -DEFUN(comp,(ap, bp), - CONST PTR ap AND - CONST PTR bp) -{ - arelent *a = *((arelent **)ap); - arelent *b = *((arelent **)bp); - return a->address - b->address; -} - -/* -Write the section headers -*/ - -static void -DEFUN(ieee_write_section_part,(abfd), - bfd *abfd) -{ - ieee_data_type *ieee = ieee_data(abfd); - asection *s; - ieee->w.r.section_part = bfd_tell(abfd); - for (s = abfd->sections; s != (asection *)NULL; s=s->next) { - ieee_write_byte(abfd, ieee_section_type_enum); - ieee_write_byte(abfd, s->index + IEEE_SECTION_NUMBER_BASE); - - if (abfd->flags & EXEC_P) - { - /* This image is executable, so output absolute sections */ - ieee_write_byte(abfd, ieee_variable_A_enum); - ieee_write_byte(abfd, ieee_variable_S_enum); - } - else - { - ieee_write_byte(abfd, ieee_variable_C_enum); - } - - switch (s->flags &(SEC_CODE | SEC_DATA | SEC_ROM)) - { - case SEC_CODE | SEC_LOAD: - case SEC_CODE: - ieee_write_byte(abfd, ieee_variable_P_enum); - break; - case SEC_DATA: - default: - ieee_write_byte(abfd, ieee_variable_D_enum); - break; - case SEC_ROM: - case SEC_ROM | SEC_DATA: - case SEC_ROM | SEC_LOAD: - case SEC_ROM | SEC_DATA | SEC_LOAD: - - ieee_write_byte(abfd, ieee_variable_R_enum); - } - - - ieee_write_id(abfd, s->name); -#if 0 - ieee_write_int(abfd, 0); /* Parent */ - ieee_write_int(abfd, 0); /* Brother */ - ieee_write_int(abfd, 0); /* Context */ -#endif - /* Alignment */ - ieee_write_byte(abfd, ieee_section_alignment_enum); - ieee_write_byte(abfd, s->index + IEEE_SECTION_NUMBER_BASE); - ieee_write_int(abfd, 1 << s->alignment_power); - - /* Size */ - ieee_write_2bytes(abfd, ieee_section_size_enum); - ieee_write_byte(abfd, s->index + IEEE_SECTION_NUMBER_BASE); - ieee_write_int(abfd, s->size); - if (abfd->flags & EXEC_P) { - /* Relocateable sections don't have asl records */ - /* Vma */ - ieee_write_2bytes(abfd, ieee_section_base_address_enum); - ieee_write_byte(abfd, s->index + IEEE_SECTION_NUMBER_BASE); - ieee_write_int(abfd, s->vma); - } - - } -} - - - -static void -DEFUN(do_with_relocs,(abfd, s), - bfd *abfd AND - asection *s) -{ - unsigned int relocs_to_go = s->reloc_count; - - - bfd_byte *stream = ieee_per_section(s)->data; - arelent **p = s->orelocation; - - bfd_size_type current_byte_index = 0; - - qsort(s->orelocation, - relocs_to_go, - sizeof(arelent **), - comp); - - /* Output the section preheader */ - ieee_write_byte(abfd, ieee_set_current_section_enum); - ieee_write_byte(abfd, s->index + IEEE_SECTION_NUMBER_BASE); - - ieee_write_twobyte(abfd, ieee_set_current_pc_enum); - ieee_write_byte(abfd, s->index + IEEE_SECTION_NUMBER_BASE); - ieee_write_expression(abfd, 0, s, 0, 0, 0); - - if (relocs_to_go == 0) - { - /* If there arn't any relocations then output the load constant byte - opcode rather than the load with relocation opcode */ - - while (current_byte_index < s->size) { - bfd_size_type run; - unsigned int MAXRUN = 32; - run = MAXRUN; - if (run > s->size - current_byte_index) { - run = s->size - current_byte_index; - } - - if (run != 0) { - ieee_write_byte(abfd, ieee_load_constant_bytes_enum); - /* Output a stream of bytes */ - ieee_write_int(abfd, run); - bfd_write((PTR)(stream + current_byte_index), - 1, - run, - abfd); - current_byte_index += run; - } - } - } - else - { - ieee_write_byte(abfd, ieee_load_with_relocation_enum); - - - /* Output the data stream as the longest sequence of bytes - possible, allowing for the a reasonable packet size and - relocation stuffs */ - - if ((PTR)stream == (PTR)NULL) { - /* Outputting a section without data, fill it up */ - stream = (uint8e_type *)(bfd_alloc(abfd, s->size)); - memset((PTR)stream, 0, s->size); - } - while (current_byte_index < s->size) { - bfd_size_type run; - unsigned int MAXRUN = 32; - if (relocs_to_go) { - run = (*p)->address - current_byte_index; - } - else { - run = MAXRUN; - } - if (run > s->size - current_byte_index) { - run = s->size - current_byte_index; - } - - if (run != 0) { - /* Output a stream of bytes */ - ieee_write_int(abfd, run); - bfd_write((PTR)(stream + current_byte_index), - 1, - run, - abfd); - current_byte_index += run; - } - /* Output any relocations here */ - if (relocs_to_go && (*p) && (*p)->address == current_byte_index) { - while (relocs_to_go && (*p) && (*p)->address == current_byte_index) { - - arelent *r = *p; - bfd_vma ov; - -#if 0 - if (r->howto->pc_relative) { - r->addend += current_byte_index ; - } -#endif - - switch (r->howto->size) { - case 2: - - ov = bfd_get_32(abfd, - stream+current_byte_index); - current_byte_index +=4; - break; - case 1: - ov = bfd_get_16(abfd, - stream+current_byte_index); - current_byte_index +=2; - break; - case 0: - ov = bfd_get_8(abfd, - stream+current_byte_index); - current_byte_index ++; - break; - default: - ov = 0; - BFD_FAIL(); - } - ieee_write_byte(abfd, ieee_function_either_open_b_enum); - - if (r->sym_ptr_ptr != (asymbol **)NULL) { - ieee_write_expression(abfd, r->addend + ov, - r->section, - *(r->sym_ptr_ptr), - r->howto->pc_relative, s->index); - } - else { - ieee_write_expression(abfd, r->addend + ov, - r->section, - (asymbol *)NULL, - r->howto->pc_relative, s->index); - } - - if (1 || r->howto->size != 2) { - ieee_write_byte(abfd, ieee_comma); - ieee_write_int(abfd, 1<< r->howto->size); - } - ieee_write_byte(abfd, - ieee_function_either_close_b_enum); - - relocs_to_go --; - p++; - } - - } - } - } -} - -/* If there are no relocations in the output section then we can -be clever about how we write. We block items up into a max of 127 -bytes */ - -static void -DEFUN(do_as_repeat, (abfd, s), - bfd *abfd AND - asection *s) -{ - ieee_write_byte(abfd, ieee_set_current_section_enum); - ieee_write_byte(abfd, s->index + IEEE_SECTION_NUMBER_BASE); - ieee_write_byte(abfd, ieee_set_current_pc_enum >> 8); - ieee_write_byte(abfd, ieee_set_current_pc_enum & 0xff); - ieee_write_byte(abfd, s->index + IEEE_SECTION_NUMBER_BASE); - ieee_write_int(abfd, s->vma ); - - ieee_write_byte(abfd,ieee_repeat_data_enum); - ieee_write_int(abfd, s->size); - ieee_write_byte(abfd, ieee_load_constant_bytes_enum); - ieee_write_byte(abfd, 1); - ieee_write_byte(abfd, 0); -} - -static void -DEFUN(do_without_relocs, (abfd, s), - bfd *abfd AND - asection *s) -{ - bfd_byte *stream = ieee_per_section(s)->data; - - if (stream == 0 || ((s->flags & SEC_LOAD) == 0)) - { - do_as_repeat(abfd, s); - } - else - { - unsigned int i; - for (i = 0; i < s->size; i++) { - if (stream[i] != 0) { - do_with_relocs(abfd, s); - return; - } - } - do_as_repeat(abfd, s); - } - -} - - -static unsigned char *output_ptr_start; -static unsigned char *output_ptr; -static unsigned char *output_ptr_end; -static unsigned char *input_ptr_start; -static unsigned char *input_ptr; -static unsigned char *input_ptr_end; -static bfd *input_bfd; -static bfd *output_bfd; -static int output_buffer; - -static void fill() -{ - bfd_read((PTR)input_ptr_start, 1, input_ptr_end - input_ptr_start, input_bfd); - input_ptr = input_ptr_start; -} -static void flush() -{ - bfd_write((PTR)(output_ptr_start),1,output_ptr - output_ptr_start, output_bfd); - output_ptr = output_ptr_start; - output_buffer++; -} - -#define THIS() ( *input_ptr ) -#define NEXT() { input_ptr++; if (input_ptr == input_ptr_end) fill(); } -#define OUT(x) { *output_ptr++ = (x); if(output_ptr == output_ptr_end) flush(); } - -static void write_int(value) -int value; -{ - if (value >= 0 && value <= 127) { - OUT(value); - } - else { - unsigned int length; - /* How many significant bytes ? */ - /* FIXME FOR LONGER INTS */ - if (value & 0xff000000) { - length = 4; - } - else if (value & 0x00ff0000) { - length = 3; - } - else if (value & 0x0000ff00) { - length = 2; - } - else length = 1; - - OUT((int)ieee_number_repeat_start_enum + length); - switch (length) { - case 4: - OUT( value >> 24); - case 3: - OUT( value >> 16); - case 2: - OUT( value >> 8); - case 1: - OUT( value); - } - - } -} -static void copy_id() -{ - int length = THIS(); - char ch; - OUT(length); - NEXT(); - while (length--) { - ch = THIS(); - OUT(ch); - NEXT(); - } -} -#define VAR(x) ((x | 0x80)) -static void copy_expression() -{ - int stack[10]; - int *tos = stack; - int value = 0; - while (1) { - switch (THIS()) { - case 0x84: - NEXT(); - value = THIS(); NEXT(); - value = (value << 8) | THIS(); NEXT(); - value = (value << 8) | THIS(); NEXT(); - value = (value << 8) | THIS(); NEXT(); - *tos ++ = value; - break; - case 0x83: - NEXT(); - value = THIS(); NEXT(); - value = (value << 8) | THIS(); NEXT(); - value = (value << 8) | THIS(); NEXT(); - *tos ++ = value; - break; - case 0x82: - NEXT(); - value = THIS(); NEXT(); - value = (value << 8) | THIS(); NEXT(); - *tos ++ = value; - break; - case 0x81: - NEXT(); - value = THIS(); NEXT(); - *tos ++ = value; - break; - case 0x80: - NEXT(); - *tos ++ = 0; - break; - default: - if (THIS() >0x84) { - /* Not a number, just bug out with the answer */ - write_int(*(--tos)); - return; - } - *tos++ = THIS(); -NEXT(); - value = 0; - break; - case 0xa5: - /* PLUS anything */ - { - int value = *(--tos); - value += *(--tos); - *tos++ = value; - NEXT(); - } - break; - case VAR('R') : - { - int section_number ; - ieee_data_type *ieee; - asection *s; - NEXT(); - section_number = THIS(); - - NEXT(); - ieee= ieee_data(input_bfd); - s = ieee->section_table[section_number]; - if (s->output_section) { - value = s->output_section->vma ; - } else { value = 0; } - value += s->output_offset; - *tos++ = value; - value = 0; - } - break; - case 0x90: - { - NEXT(); - write_int(*(--tos)); - OUT(0x90); - return; - - } - } - } - -} - -/* Drop the int in the buffer, and copy a null into the gap, which we - will overwrite later */ - -struct output_buffer_struct { -unsigned char *ptrp; - int buffer; -} ; - -static void -DEFUN(fill_int,(buf), - struct output_buffer_struct *buf) -{ - if (buf->buffer == output_buffer) { - /* Still a chance to output the size */ - int value = output_ptr - buf->ptrp + 3; - buf->ptrp[0] = value >> 24; - buf->ptrp[1] = value >> 16; - buf->ptrp[2] = value >> 8; - buf->ptrp[3] = value >> 0; - } - -} -static void -DEFUN(drop_int,(buf), - struct output_buffer_struct *buf) -{ - int type = THIS(); - int ch; - if (type <= 0x84) { - NEXT(); - switch(type) { - case 0x84: ch = THIS(); NEXT(); - case 0x83: ch = THIS(); NEXT(); - case 0x82: ch = THIS(); NEXT(); - case 0x81: ch = THIS(); NEXT(); - case 0x80: break; - } - } - OUT(0x84); - buf->ptrp = output_ptr; - buf->buffer = output_buffer; - OUT(0);OUT(0);OUT(0);OUT(0); -} - -static void copy_int() -{ - int type = THIS(); - int ch; - if (type <= 0x84) { - OUT(type); - NEXT(); - switch(type) { - case 0x84: ch = THIS(); NEXT(); OUT(ch); - case 0x83: ch = THIS(); NEXT(); OUT(ch); - case 0x82: ch = THIS(); NEXT(); OUT(ch); - case 0x81: ch = THIS(); NEXT(); OUT(ch); - case 0x80: break; - } - } -} - -#define ID copy_id() -#define INT copy_int() -#define EXP copy_expression() -static void copy_till_end(); -#define INTn(q) copy_int() -#define EXPn(q) copy_expression() -static void f1_record() -{ - int ch; - /* ATN record */ - NEXT(); - ch = THIS(); - switch (ch) - { - default: - OUT(0xf1); OUT(ch); - break; - case 0xc9: - NEXT(); - OUT(0xf1); OUT(0xc9); - INT; INT; ch = THIS(); - switch (ch) - { - case 0x16: NEXT();break; - case 0x01: NEXT();break; - case 0x00: NEXT(); INT; break; - case 0x03: NEXT(); INT; break; - case 0x13: EXPn(instruction address); break; - default: - break; - } - break; - case 0xd8: - /* EXternal ref */ - NEXT(); - OUT(0xf1); OUT(0xd8); - EXP ; EXP; EXP; EXP; - break; - case 0xce: - NEXT(); - OUT(0xf1);OUT(0xce); INT; INT; ch = THIS(); INT; - switch (ch) { - case 0x01: - INT; INT; break; - case 0x02: - INT; break; - case 0x04: - EXPn(external function); break; - case 0x05: - break; - case 0x07: INTn(line number); INT; - case 0x08: break; - case 0x0a: INTn(locked register); INT; break; - case 0x3f: copy_till_end(); break; - case 0x3e: copy_till_end(); break; - case 0x40: copy_till_end(); break; - case 0x41: ID; break; - } - } - -} -static void f0_record() -{ - /* Attribute record */ - NEXT(); - OUT(0xf0); - INTn(Symbol name ); - ID; -} -static void copy_till_end() -{ - int ch = THIS(); - while (1) { - while (ch <= 0x80) - { - OUT(ch); - NEXT(); - ch = THIS(); - } - switch (ch) { - case 0x84: - OUT(THIS()); - NEXT(); - case 0x83: - OUT(THIS()); - NEXT(); - case 0x82: - OUT(THIS()); - NEXT(); - case 0x81: - OUT(THIS()); - NEXT(); - OUT(THIS()); - NEXT(); - - ch = THIS(); - break; - default: - return; - } - } - -} - -static void f2_record() -{ - NEXT(); - OUT(0xf2); - INT ; - NEXT(); - OUT(0xce); - INT ; - copy_till_end(); -} - - -static void block(); -static void f8_record() -{ - int ch; - NEXT(); - ch = THIS(); - switch (ch) - { - case 0x01: - case 0x02: - case 0x03: - /* Unique typedefs for module */ - /* GLobal typedefs */ - /* High level module scope beginning */ - { - struct output_buffer_struct ob; - NEXT(); - OUT(0xf8); OUT(ch); - drop_int(&ob); ID ; - - block(); - - NEXT(); - fill_int(&ob); - OUT(0xf9); - } - break; - case 0x04: - /* Global function */ - { - struct output_buffer_struct ob; - NEXT(); - OUT(0xf8); OUT(0x04); - drop_int(&ob); ID ; INTn(stack size); INTn(ret val); - EXPn(offset); - - block(); - - NEXT(); - OUT(0xf9); - EXPn(size of block); - fill_int(&ob); - } - break; - - case 0x05: - /* File name for source line numbers */ - { - struct output_buffer_struct ob; - NEXT(); - OUT(0xf8); OUT(0x05); - drop_int(&ob); - ID; INTn(year); INTn(month); INTn(day); - INTn(hour); INTn(monute); INTn(second); - block(); - NEXT(); - OUT(0xf9); - fill_int(&ob); - } - break; - - case 0x06: - /* Local function */ - { struct output_buffer_struct ob; - NEXT(); OUT(0xf8); OUT(0x06); - drop_int(&ob); - ID; INTn(stack size); INTn(type return); - EXPn(offset); - block(); - NEXT(); - OUT(0xf9); - EXPn(size); - fill_int(&ob); - } - break; - - case 0x0a: - /* Assembler module scope beginning -*/ - { struct output_buffer_struct ob; - - NEXT(); - OUT(0xf8); OUT(0x0a); - drop_int(&ob); - ID; ID; INT; ID; INT; INT; INT; INT; INT; INT; - - block(); - - NEXT(); - OUT(0xf9); - fill_int(&ob); - } - break; - case 0x0b: - { - struct output_buffer_struct ob; - NEXT(); - OUT(0xf8); OUT(0x0b); - drop_int(&ob); ID ; INT; INTn(section index); EXPn(offset); INTn(stuff); - - block(); - - OUT(0xf9); - NEXT(); - EXPn(Size in Maus); - fill_int(&ob); - } - break; - } -} - -static void e2_record() -{ - OUT(0xe2); - NEXT(); - OUT(0xce); - NEXT(); - INT; - EXP; -} - -static void DEFUN_VOID(block) -{ - int ch ; - while (1) { - ch = THIS(); - switch (ch) { - case 0xe1: - case 0xe5: - return; - case 0xf9: - return; - case 0xf0: - f0_record(); - break; - case 0xf1: - f1_record(); - break; - case 0xf2: - f2_record(); - break; - case 0xf8: - f8_record(); - break; - case 0xe2: - e2_record(); - break; - - } - } -} - - - -/* relocate_debug, - moves all the debug information from the source bfd to the output - bfd, and relocates any expressions it finds -*/ - -static void -DEFUN(relocate_debug,(output, input), - bfd *output AND - bfd *input) -{ -#define IBS 400 -#define OBS 400 - unsigned char input_buffer[IBS]; - - input_ptr_start = input_ptr = input_buffer; - input_ptr_end = input_buffer + IBS; - input_bfd = input; - bfd_read((PTR)input_ptr_start, 1, IBS, input); - block(); -} -/* - During linking, we we told about the bfds which made up our - contents, we have a list of them. They will still be open, so go to - the debug info in each, and copy it out, relocating it as we go. -*/ - -static void -DEFUN(ieee_write_debug_part, (abfd), - bfd *abfd) -{ - ieee_data_type *ieee = ieee_data(abfd); - bfd_chain_type *chain = ieee->chain_root; - unsigned char output_buffer[OBS]; - boolean some_debug = false; - file_ptr here = bfd_tell(abfd); - - output_ptr_start = output_ptr = output_buffer ; - output_ptr_end = output_buffer + OBS; - output_ptr = output_buffer; - output_bfd = abfd; - - if (chain == (bfd_chain_type *)NULL) { - /* There is no debug info, so we'll fake some up */ - CONST static char fake[] = { - 0xf8, 0xa, 0, 5, 't', 't', 't', 't', 't', 0, 2, 3, - '1','.','1',0x82, 1991>>8, 1991 & 0xff, 9, 20, 11, 07,50 }; - ieee->w.r.debug_information_part = 0; - -#if 0 -here; - - -/* bfd_write(fake, 1, sizeof(fake), abfd);*/ - /* Now write a header for each section */ - { - int i = 0; - asection *s = abfd->sections; - while (s) { - ieee_write_byte(abfd, 0xf8); - ieee_write_byte(abfd, 0x0b); - ieee_write_byte(abfd, 0); - ieee_write_byte(abfd, 0); - ieee_write_byte(abfd, 1); - ieee_write_byte(abfd, i + IEEE_SECTION_NUMBER_BASE); - ieee_write_expression(abfd, 0, s, 0, 0, 0); - ieee_write_byte(abfd,0); - ieee_write_byte(abfd, 0xf9); - ieee_write_expression(abfd, s->size, 0, 0, 0, 0); - s = s->next; - i++; - } - /* Close the scope */ - ieee_write_byte(abfd, 0xf9); - } -#endif - } - else{ - while (chain != (bfd_chain_type *)NULL) { - bfd *entry = chain->this; - ieee_data_type *entry_ieee = ieee_data(entry); - if (entry_ieee->w.r.debug_information_part) { - bfd_seek(entry, entry_ieee->w.r.debug_information_part, SEEK_SET); - relocate_debug(abfd, entry); - } - - chain = chain->next; - } - if (some_debug) { - ieee->w.r.debug_information_part = here; - } - else { - ieee->w.r.debug_information_part = 0; - } - } - flush(); - -} -/* write the data in an ieee way */ -static void -DEFUN(ieee_write_data_part,(abfd), - bfd *abfd) -{ - asection *s; - ieee_data_type *ieee = ieee_data(abfd); - ieee->w.r.data_part = bfd_tell(abfd); - for (s = abfd->sections; s != (asection *)NULL; s = s->next) - { - /* Sort the reloc records so we can insert them in the correct - places */ - if (s->reloc_count != 0) - { - do_with_relocs(abfd, s); - } - else - { - do_without_relocs(abfd, s); - } - } -} - - - -static void -DEFUN(init_for_output,(abfd), - bfd *abfd) -{ - asection *s; - for (s = abfd->sections; s != (asection *)NULL; s = s->next) { - if (s->size != 0) { - ieee_per_section(s)->data = (bfd_byte *)(bfd_alloc(abfd, s->size)); - } - } -} - -/** exec and core file sections */ - -/* set section contents is complicated with IEEE since the format is -* not a byte image, but a record stream. -*/ -boolean -DEFUN(ieee_set_section_contents,(abfd, section, location, offset, count), - bfd *abfd AND - sec_ptr section AND - PTR location AND - file_ptr offset AND - bfd_size_type count) -{ - if (ieee_per_section(section)->data == (bfd_byte *)NULL) { - init_for_output(abfd); - } - (void) memcpy((PTR)(ieee_per_section(section)->data + offset), - (PTR)location, - (unsigned int)count); - return true; -} - -/* -write the external symbols of a file, IEEE considers two sorts of -external symbols, public, and referenced. It uses to internal forms -to index them as well. When we write them out we turn their symbol -values into indexes from the right base. -*/ -static void -DEFUN(ieee_write_external_part,(abfd), - bfd *abfd) -{ - asymbol **q; - ieee_data_type *ieee = ieee_data(abfd); - - unsigned int reference_index = IEEE_REFERENCE_BASE; - unsigned int public_index = IEEE_PUBLIC_BASE+2; - file_ptr here = bfd_tell(abfd); - boolean hadone = false; - if (abfd->outsymbols != (asymbol **)NULL) { - - for (q = abfd->outsymbols; *q != (asymbol *)NULL; q++) { - asymbol *p = *q; - hadone = true; - if (p->flags & BSF_UNDEFINED) { - /* This must be a symbol reference .. */ - ieee_write_byte(abfd, ieee_external_reference_enum); - ieee_write_int(abfd, reference_index); - ieee_write_id(abfd, p->name); - p->value = reference_index; - reference_index++; - } - else if(p->flags & BSF_FORT_COMM) { - /* This is a weak reference */ - ieee_write_byte(abfd, ieee_external_reference_enum); - ieee_write_int(abfd, reference_index); - ieee_write_id(abfd, p->name); - ieee_write_byte(abfd, ieee_weak_external_reference_enum); - ieee_write_int(abfd, reference_index); - ieee_write_int(abfd, p->value); - ieee_write_int(abfd, BFD_FORT_COMM_DEFAULT_VALUE); - p->value = reference_index; - reference_index++; - } - else if(p->flags & BSF_GLOBAL) { - /* This must be a symbol definition */ - - - ieee_write_byte(abfd, ieee_external_symbol_enum); - ieee_write_int(abfd, public_index ); - ieee_write_id(abfd, p->name); - - ieee_write_twobyte(abfd, ieee_attribute_record_enum); - ieee_write_int(abfd, public_index ); - ieee_write_byte(abfd, 15); /* instruction address */ - ieee_write_byte(abfd, 19); /* static symbol */ - ieee_write_byte(abfd, 1); /* one of them */ - - - /* Write out the value */ - ieee_write_2bytes(abfd, ieee_value_record_enum); - ieee_write_int(abfd, public_index); - if (p->section != (asection *)NULL) - { - if (abfd->flags & EXEC_P) - { - /* If fully linked, then output all symbols - relocated */ - ieee_write_int(abfd, - p->value + p->section->output_offset+ p->section->output_section->vma); - - } - else { - ieee_write_expression(abfd, - p->value + p->section->output_offset, - p->section->output_section, - (asymbol *)NULL, false, 0); - } - } - else - { - ieee_write_expression(abfd, - p->value, - (asection *)NULL, - (asymbol *)NULL, false, 0); - } - p->value = public_index; - public_index++; - } - else { - /* This can happen - when there are gaps in the symbols read */ - /* from an input ieee file */ - } - } - } - if (hadone) - ieee->w.r.external_part = here; - -} - - -CONST static char exten[] = - { - 0xf0, 0x20, 0x00, - 0xf1, 0xce, 0x20, 0x00, 37, 3, 3, /* Set version 3 rev 3 */ - 0xf1, 0xce, 0x20, 0x00, 39, 2, /* keep symbol in original case */ - 0xf1, 0xce, 0x20, 0x00, 38 /* set object type relocateable to x */ - }; - -CONST static char environ[] = - { - 0xf0, 0x21, 0x00, - -/* 0xf1, 0xce, 0x21, 00, 50, 0x82, 0x07, 0xc7, 0x09, 0x11, 0x11, - 0x19, 0x2c, -*/ - 0xf1, 0xce, 0x21, 00, 52, 0x00, /* exec ok */ - - 0xf1, 0xce, 0x21, 0, 53, 0x03, /* host unix */ -/* 0xf1, 0xce, 0x21, 0, 54, 2,1,1 tool & version # */ - }; - -static -void -DEFUN(ieee_write_me_part,(abfd), - bfd *abfd) -{ - ieee_data_type *ieee= ieee_data(abfd); - ieee->w.r.trailer_part = bfd_tell(abfd); - if (abfd->start_address) { - ieee->w.r.me_record = bfd_tell(abfd); - ieee_write_2bytes(abfd, ieee_value_starting_address_enum); - ieee_write_byte(abfd, ieee_function_either_open_b_enum); - ieee_write_int(abfd, abfd->start_address); - ieee_write_byte(abfd, ieee_function_either_close_b_enum); - } - else { - ieee->w.r.me_record = bfd_tell(abfd); - } - ieee_write_byte(abfd, ieee_module_end_enum); - -} -boolean -DEFUN(ieee_write_object_contents,(abfd), - bfd *abfd) -{ - ieee_data_type *ieee = ieee_data(abfd); - unsigned int i; - file_ptr old; - /* Fast forward over the header area */ - bfd_seek(abfd, 0, 0); - ieee_write_byte(abfd, ieee_module_beginning_enum); - - ieee_write_id(abfd, bfd_printable_name(abfd)); - ieee_write_id(abfd, abfd->filename); - - - - - /* Fast forward over the variable bits */ - - - - ieee_write_byte(abfd, ieee_address_descriptor_enum); - - /* Bits per MAU */ - ieee_write_byte(abfd, bfd_arch_bits_per_byte(abfd)); - /* MAU's per address */ - ieee_write_byte(abfd, bfd_arch_bits_per_address(abfd) / - bfd_arch_bits_per_byte(abfd)); - - - old = bfd_tell(abfd); - bfd_seek(abfd, 8 * N_W_VARIABLES, 1); - - - ieee->w.r.extension_record = bfd_tell(abfd); - bfd_write(exten, 1, sizeof(exten), abfd); - if (abfd->flags & EXEC_P) - ieee_write_byte(abfd, 0x1); /* Absolute */ - else - ieee_write_byte(abfd, 0x2); /* Relocateable */ - - ieee->w.r.environmental_record = bfd_tell(abfd); - bfd_write(environ, 1, sizeof(environ), abfd); - output_bfd = abfd; - flush(); - - ieee_write_section_part(abfd); - /* - First write the symbols, this changes their values into table - indeces so we cant use it after this point - */ - ieee_write_external_part(abfd); - /* ieee_write_byte(abfd, ieee_record_seperator_enum);*/ - - - /* ieee_write_byte(abfd, ieee_record_seperator_enum);*/ - - - /* - Write any debugs we have been told about - */ - ieee_write_debug_part(abfd); - - /* - Can only write the data once the symbols have been written since - the data contains relocation information which points to the - symbols - */ - ieee_write_data_part(abfd); - - - /* - At the end we put the end ! - */ - ieee_write_me_part(abfd); - - - /* Generate the header */ - bfd_seek(abfd, old, false); - - for (i= 0; i < N_W_VARIABLES; i++) { - ieee_write_2bytes(abfd,ieee_assign_value_to_variable_enum); - ieee_write_byte(abfd, i); - ieee_write_int5_out(abfd, ieee->w.offset[i]); - } - return true; -} - - - - -/* Native-level interface to symbols. */ - -/* We read the symbols into a buffer, which is discarded when this -function exits. We read the strings into a buffer large enough to -hold them all plus all the cached symbol entries. */ - -asymbol * -DEFUN(ieee_make_empty_symbol,(abfd), - bfd *abfd) -{ - - ieee_symbol_type *new = - (ieee_symbol_type *)zalloc (sizeof (ieee_symbol_type)); - new->symbol.the_bfd = abfd; - return &new->symbol; - -} - -static bfd * -DEFUN(ieee_openr_next_archived_file,(arch, prev), - bfd *arch AND - bfd *prev) -{ - ieee_ar_data_type *ar = ieee_ar_data(arch); - /* take the next one from the arch state, or reset */ - if (prev == (bfd *)NULL) { - /* Reset the index - the first two entries are bogus*/ - ar->element_index = 2; - } - while (true) { - ieee_ar_obstack_type *p = ar->elements + ar->element_index; - ar->element_index++; - if (ar->element_index <= ar->element_count) { - if (p->file_offset != (file_ptr)0) { - if (p->abfd == (bfd *)NULL) { - p->abfd = _bfd_create_empty_archive_element_shell(arch); - p->abfd->origin = p->file_offset; - } - return p->abfd; - } - } - else { - bfd_error = no_more_archived_files; - return (bfd *)NULL; - } - - } -} - -static boolean -ieee_find_nearest_line(abfd, - section, - symbols, - offset, - filename_ptr, - functionname_ptr, - line_ptr) -bfd *abfd; -asection *section; -asymbol **symbols; -bfd_vma offset; -char **filename_ptr; -char **functionname_ptr; -int *line_ptr; -{ - return false; -} - - -static int -ieee_generic_stat_arch_elt(abfd, buf) -bfd *abfd; -struct stat *buf; -{ - ieee_ar_data_type *ar = ieee_ar_data(abfd); - if (ar == (ieee_ar_data_type *)NULL) { - bfd_error = invalid_operation; - return -1; - } - else { - buf->st_size = 0x1; - buf->st_mode = 0666; - return 0; - } -} -static int -DEFUN(ieee_sizeof_headers,(abfd, x), - bfd *abfd AND - boolean x) -{ - return 0; -} - - - -static void -DEFUN(ieee_bfd_debug_info_start,(abfd), - bfd *abfd) - { - - } - -static void -DEFUN(ieee_bfd_debug_info_end,(abfd), - bfd *abfd) - { - - } - - -/* Add this section to the list of sections we have debug info for, to - be ready to output it at close time - */ -static void -DEFUN(ieee_bfd_debug_info_accumulate,(abfd, section), - bfd *abfd AND - asection *section) -{ - ieee_data_type *ieee = ieee_data(section->owner); - ieee_data_type *output_ieee = ieee_data(abfd); - /* can only accumulate data from other ieee bfds */ - if (section->owner->xvec != abfd->xvec) - return; - /* Only bother once per bfd */ - if (ieee->done_debug == true) - return; - ieee->done_debug = true; - - /* Don't bother if there is no debug info */ - if (ieee->w.r.debug_information_part == 0) - return; - - - /* Add to chain */ - { - bfd_chain_type *n = (bfd_chain_type *) bfd_alloc(abfd, sizeof(bfd_chain_type)); - n->this = section->owner; - n->next = (bfd_chain_type *)NULL; - - if (output_ieee->chain_head) { - output_ieee->chain_head->next = n; - } - else { - output_ieee->chain_root = n; - - } - output_ieee->chain_head = n; - } -} - - - - - - -#define FOO PROTO -#define ieee_core_file_failing_command (char *(*)())(bfd_nullvoidptr) -#define ieee_core_file_failing_signal (int (*)())bfd_0 -#define ieee_core_file_matches_executable_p ( FOO(boolean, (*),(bfd *, bfd *)))bfd_false -#define ieee_slurp_armap bfd_true -#define ieee_slurp_extended_name_table bfd_true -#define ieee_truncate_arname (void (*)())bfd_nullvoidptr -#define ieee_write_armap (FOO( boolean, (*),(bfd *, unsigned int, struct orl *, unsigned int, int))) bfd_nullvoidptr -#define ieee_get_lineno (struct lineno_cache_entry *(*)())bfd_nullvoidptr -#define ieee_close_and_cleanup bfd_generic_close_and_cleanup -#define ieee_set_arch_mach bfd_default_set_arch_mach - -/*SUPPRESS 460 */ -bfd_target ieee_vec = -{ - "ieee", /* name */ - bfd_target_ieee_flavour, - true, /* target byte order */ - true, /* target headers byte order */ - (HAS_RELOC | EXEC_P | /* object flags */ - HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED), - (SEC_CODE|SEC_DATA|SEC_ROM|SEC_HAS_CONTENTS - |SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ - ' ', /* ar_pad_char */ - 16, /* ar_max_namelen */ - 1, /* minimum alignment */ -_do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* data */ -_do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* hdrs */ - - { _bfd_dummy_target, - ieee_object_p, /* bfd_check_format */ - ieee_archive_p, - _bfd_dummy_target, - }, - { - bfd_false, - ieee_mkobject, - _bfd_generic_mkarchive, - bfd_false - }, - { - bfd_false, - ieee_write_object_contents, - _bfd_write_archive_contents, - bfd_false, - }, - JUMP_TABLE(ieee) -}; diff --git a/bfd/init.c b/bfd/init.c deleted file mode 100644 index f73c42600cc..00000000000 --- a/bfd/init.c +++ /dev/null @@ -1,62 +0,0 @@ -/* bfd initialization stuff - Copyright (C) 1990-1991 Free Software Foundation, Inc. - Written by Steve Chamberlain of Cygnus Support. - -This file is part of BFD, the Binary File Descriptor library. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include -#include "bfd.h" -#include "libbfd.h" - -static boolean initialized = false; - -/*proto* bfd_init - -This routine must be called before any other bfd function to initialize -magical internal data structures. - -*; void EXFUN(bfd_init,(void)); -*/ - -void DEFUN_VOID(bfd_init) -{ - if (initialized == false) { - initialized = true; - - bfd_arch_init(); - } -} - - -/*proto-internal* bfd_check_init - -This routine is called before any other bfd function using initialized -data is used to ensure that the structures have been initialized. -Soon this function will go away, and the bfd library will assume that -bfd_init has been called. - -*; void EXFUN(bfd_check_init,(void)); -*/ - -void DEFUN_VOID(bfd_check_init) -{ - if (initialized == false) { - fprintf(stderr,"The bfd library now requires you to call bfd_init()\n"); - fprintf(stderr,"before any other calls to bfd routines. Please\n"); - fprintf(stderr,"change your source\n"); - bfd_init(); - } -} diff --git a/bfd/intobfd b/bfd/intobfd deleted file mode 100755 index b256f4bcca1..00000000000 --- a/bfd/intobfd +++ /dev/null @@ -1,11 +0,0 @@ -/\/\*:archive.c\*\//r archive.p -/\/\*:archures.c\*\//r archures.p -/\/\*:bfd.c\*\//r bfd.p -/\/\*:core.c\*\//r core.p -/\/\*:format.c\*\//r format.p -/\/\*:libbfd.c\*\//r libbfd.p -/\/\*:opncls.c\*\//r opncls.p -/\/\*:reloc.c\*\//r reloc.p -/\/\*:section.c\*\//r section.p -/\/\*:syms.c\*\//r syms.p -/\/\*:targets.c\*\//r targets.p diff --git a/bfd/libaout.h b/bfd/libaout.h deleted file mode 100644 index 0797bc51ce3..00000000000 --- a/bfd/libaout.h +++ /dev/null @@ -1,310 +0,0 @@ -/* BFD back-end data structures for a.out (and similar) files. - Copyright (C) 1990-1991 Free Software Foundation, Inc. - Written by Cygnus Support. - -This file is part of BFD, the Binary File Descriptor library. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* We try to encapsulate the differences in the various a.out file - variants in a few routines, and otherwise share large masses of code. - This means we only have to fix bugs in one place, most of the time. */ - -/* $Id$ */ - -#ifdef __STDC__ -#define CAT3(a,b,c) a##b##c -#else -#define CAT3(a,b,c) a/**/b/**/c -#endif - -/* Parameterize the a.out code based on whether it is being built - for a 32-bit architecture or a 64-bit architecture. */ -#if ARCH_SIZE==64 -#define GET_WORD bfd_h_get_64 -#define GET_SWORD (int64_type)GET_WORD -#define PUT_WORD bfd_h_put_64 -#define NAME(x,y) CAT3(x,_64_,y) -#define JNAME(x) CAT(x,_64) -#define BYTES_IN_WORD 8 -#else -#define GET_WORD bfd_h_get_32 -#define GET_SWORD (int32_type)GET_WORD -#define PUT_WORD bfd_h_put_32 -#define NAME(x,y) CAT3(x,_32_,y) -#define JNAME(x) CAT(x,_32) -#define BYTES_IN_WORD 4 -#endif - -/* Declare these types at file level, since they are used in parameter - lists, which have wierd scope. */ -struct external_exec; -struct internal_exec; - -/* This is the layout in memory of a "struct exec" while we process it. - All 'lengths' are given as a number of bytes. - All 'alignments' are for relinkable files only; an alignment of - 'n' indicates the corresponding segment must begin at an - address that is a multiple of (2**n). */ - -struct internal_exec -{ - long a_info; /* Magic number and flags, packed */ - bfd_vma a_text; /* length of text, in bytes */ - bfd_vma a_data; /* length of data, in bytes */ - bfd_vma a_bss; /* length of uninitialized data area in mem */ - bfd_vma a_syms; /* length of symbol table data in file */ - bfd_vma a_entry; /* start address */ - bfd_vma a_trsize; /* length of text's relocation info, in bytes */ - bfd_vma a_drsize; /* length of data's relocation info, in bytes */ - /* Added for i960 */ - bfd_vma a_tload; /* Text runtime load address */ - bfd_vma a_dload; /* Data runtime load address */ - unsigned char a_talign; /* Alignment of text segment */ - unsigned char a_dalign; /* Alignment of data segment */ - unsigned char a_balign; /* Alignment of bss segment */ -}; - -/* Magic number is written -< MSB > -3130292827262524232221201918171615141312111009080706050403020100 -< FLAGS >< MACHINE TYPE >< MAGIC NUMBER > -*/ -enum machine_type { - M_UNKNOWN = 0, - M_68010 = 1, - M_68020 = 2, - M_SPARC = 3, - /* skip a bunch so we dont run into any of suns numbers */ - M_386 = 100, - M_29K = 101, - M_HP200 = 200, /* HP 200 (68010) BSD binary */ - M_HP300 = (300 % 256), /* HP 300 (68020+68881) BSD binary */ - M_HPUX = (0x20c % 256),/* HP 200/300 HPUX binary */ -}; - -#define N_DYNAMIC(exec) ((exec).a_info & 0x8000000) - -#define N_MAGIC(exec) ((exec).a_info & 0xffff) -#define N_MACHTYPE(exec) ((enum machine_type)(((exec).a_info >> 16) & 0xff)) -#define N_FLAGS(exec) (((exec).a_info >> 24) & 0xff) -#define N_SET_INFO(exec, magic, type, flags) \ -((exec).a_info = ((magic) & 0xffff) \ - | (((int)(type) & 0xff) << 16) \ - | (((flags) & 0xff) << 24)) - -#define N_SET_MAGIC(exec, magic) \ -((exec).a_info = (((exec).a_info & 0xffff0000) | ((magic) & 0xffff))) - -#define N_SET_MACHTYPE(exec, machtype) \ -((exec).a_info = \ - ((exec).a_info&0xff00ffff) | ((((int)(machtype))&0xff) << 16)) - -#define N_SET_FLAGS(exec, flags) \ -((exec).a_info = \ - ((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24)) - -typedef struct aout_symbol { - asymbol symbol; - short desc; - char other; - unsigned char type; -} aout_symbol_type; - -/* The `tdata' struct for all a.out-like object file formats. - Various things depend on this struct being around any time an a.out - file is being handled. An example is dbxread.c in GDB. */ - -struct aoutdata { - struct internal_exec *hdr; /* exec file header */ - aout_symbol_type *symbols; /* symtab for input bfd */ - - /* For ease, we do this */ - asection *textsec; - asection *datasec; - asection *bsssec; - - /* We remember these offsets so that after check_file_format, we have - no dependencies on the particular format of the exec_hdr. */ - file_ptr sym_filepos; - file_ptr str_filepos; - - /* Size of a relocation entry in external form */ - unsigned reloc_entry_size; - - /* Size of a symbol table entry in external form */ - unsigned symbol_entry_size; - - /* Page size - needed for alignment of demand paged files. */ - unsigned long page_size; - - /* Segment size - needed for alignment of demand paged files. */ - unsigned long segment_size; - - unsigned exec_bytes_size; -}; - -#define adata(bfd) ((struct aoutdata *) ((bfd)->tdata)) -#define exec_hdr(bfd) (adata(bfd)->hdr) -#define obj_aout_symbols(bfd) (adata(bfd)->symbols) -#define obj_textsec(bfd) (adata(bfd)->textsec) -#define obj_datasec(bfd) (adata(bfd)->datasec) -#define obj_bsssec(bfd) (adata(bfd)->bsssec) -#define obj_sym_filepos(bfd) (adata(bfd)->sym_filepos) -#define obj_str_filepos(bfd) (adata(bfd)->str_filepos) -#define obj_reloc_entry_size(bfd) (adata(bfd)->reloc_entry_size) -#define obj_symbol_entry_size(bfd) (adata(bfd)->symbol_entry_size) - -/* We take the address of the first element of an asymbol to ensure that the - macro is only ever applied to an asymbol */ -#define aout_symbol(asymbol) ((aout_symbol_type *)(&(asymbol)->the_bfd)) - -/* Prototype declarations for functions defined in aoutx.h */ - -PROTO (boolean, NAME(aout,squirt_out_relocs),(bfd *abfd, asection *section)); - -PROTO (bfd_target *, NAME(aout,some_aout_object_p), (bfd *abfd, - struct internal_exec *execp, - bfd_target *(*callback)())); -PROTO (boolean, NAME(aout,mkobject), (bfd *abfd)); -PROTO (enum machine_type, NAME(aout,machine_type), (enum bfd_architecture arch, - unsigned long machine)); -PROTO (boolean, NAME(aout,set_arch_mach), (bfd *abfd, enum bfd_architecture arch, - unsigned long machine)); - -PROTO (boolean, NAME(aout,new_section_hook), (bfd *abfd, asection *newsect)); -PROTO (boolean, NAME(aout,set_section_contents), (bfd *abfd, sec_ptr section, - PTR location, file_ptr offset, bfd_size_type count)); - -PROTO (asymbol *,NAME(aout,make_empty_symbol), (bfd *abfd)); -PROTO (boolean, NAME(aout,slurp_symbol_table), (bfd *abfd)); -PROTO (void, NAME(aout,write_syms), (bfd *abfd)); -PROTO (void, NAME(aout,reclaim_symbol_table), (bfd *abfd)); -PROTO (unsigned int, NAME(aout,get_symtab_upper_bound), (bfd *abfd)); -PROTO (unsigned int, NAME(aout,get_symtab), (bfd *abfd, asymbol **location)); -PROTO (boolean, NAME(aout,slurp_reloc_table), (bfd *abfd, sec_ptr asect, - asymbol **symbols)); -PROTO (unsigned int, NAME(aout,canonicalize_reloc), (bfd *abfd, sec_ptr section, - arelent **relptr, asymbol **symbols)); -PROTO (unsigned int, NAME(aout,get_reloc_upper_bound), (bfd *abfd, sec_ptr asect)); -PROTO (void, NAME(aout,reclaim_reloc), (bfd *ignore_abfd, sec_ptr ignore)); -PROTO (alent *, NAME(aout,get_lineno), (bfd *ignore_abfd, asymbol *ignore_symbol)); -PROTO (void, NAME(aout,print_symbol), (bfd *ignore_abfd, PTR file, - asymbol *symbol, bfd_print_symbol_type how)); -PROTO (boolean, NAME(aout,close_and_cleanup), (bfd *abfd)); -PROTO (boolean, NAME(aout,find_nearest_line), (bfd *abfd, asection *section, - asymbol **symbols, bfd_vma offset, CONST char **filename_ptr, - CONST char **functionname_ptr, unsigned int *line_ptr)); -PROTO (int, NAME(aout,sizeof_headers), (bfd *ignore_abfd, boolean exec)); - - -PROTO (void, NAME(aout,swap_exec_header_in), (bfd *abfd, - struct external_exec *raw_bytes, struct internal_exec *execp)); - -PROTO (void, NAME(aout,swap_exec_header_out),(bfd *abfd, struct internal_exec *execp, - struct external_exec *raw_bytes)); - -/* A.out uses the generic versions of these routines... */ - -#define aout_32_get_section_contents bfd_generic_get_section_contents -#define aout_32_close_and_cleanup bfd_generic_close_and_cleanup - -#define aout_64_get_section_contents bfd_generic_get_section_contents -#define aout_64_close_and_cleanup bfd_generic_close_and_cleanup - -/* Calculate the file positions of the parts of a newly read aout header */ -#define WORK_OUT_FILE_POSITIONS(abfd, execp) \ - /* The virtual memory addresses of the sections */ \ - obj_datasec (abfd)->vma = N_DATADDR(*execp); \ - obj_bsssec (abfd)->vma = N_BSSADDR(*execp); \ - obj_textsec (abfd)->vma = N_TXTADDR(*execp); \ - \ - /* The file offsets of the sections */ \ - obj_textsec (abfd)->filepos = N_TXTOFF (*execp); \ - obj_datasec (abfd)->filepos = N_DATOFF (*execp); \ - \ - /* The file offsets of the relocation info */ \ - obj_textsec (abfd)->rel_filepos = N_TRELOFF(*execp); \ - obj_datasec (abfd)->rel_filepos = N_DRELOFF(*execp); \ - \ - /* The file offsets of the string table and symbol table. */ \ - obj_sym_filepos (abfd) = N_SYMOFF (*execp); \ - obj_str_filepos (abfd) = N_STROFF (*execp); \ - - -#define WRITE_HEADERS(abfd, execp) \ - { \ - if (abfd->flags & D_PAGED) \ - { \ - execp->a_text = obj_textsec (abfd)->size; \ - /* Kludge to distinguish old- and new-style ZMAGIC. \ - The latter includes the exec header in the text size. */ \ - if (obj_textsec(abfd)->filepos == EXEC_BYTES_SIZE) \ - execp->a_text += EXEC_BYTES_SIZE; \ - N_SET_MAGIC (*execp, ZMAGIC); \ - } \ - else \ - { \ - execp->a_text = obj_textsec (abfd)->size; \ - if (abfd->flags & WP_TEXT) \ - { N_SET_MAGIC (*execp, NMAGIC); } \ - else \ - { N_SET_MAGIC(*execp, OMAGIC); } \ - } \ - if (abfd->flags & D_PAGED) \ - { \ - data_pad = ALIGN(obj_datasec(abfd)->size, PAGE_SIZE) \ - - obj_datasec(abfd)->size; \ - \ - if (data_pad > obj_bsssec(abfd)->size) \ - execp->a_bss = 0; \ - else \ - execp->a_bss = obj_bsssec(abfd)->size - data_pad; \ - execp->a_data = obj_datasec(abfd)->size + data_pad; \ - } \ - else \ - { \ - execp->a_data = obj_datasec (abfd)->size; \ - execp->a_bss = obj_bsssec (abfd)->size; \ - } \ - \ - execp->a_syms = bfd_get_symcount (abfd) * EXTERNAL_NLIST_SIZE; \ - execp->a_entry = bfd_get_start_address (abfd); \ - \ - execp->a_trsize = ((obj_textsec (abfd)->reloc_count) * \ - obj_reloc_entry_size (abfd)); \ - execp->a_drsize = ((obj_datasec (abfd)->reloc_count) * \ - obj_reloc_entry_size (abfd)); \ - NAME(aout,swap_exec_header_out) (abfd, execp, &exec_bytes); \ - \ - bfd_seek (abfd, 0L, false); \ - bfd_write ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd); \ - /* Now write out reloc info, followed by syms and strings */ \ - \ - if (bfd_get_symcount (abfd) != 0) \ - { \ - bfd_seek (abfd, \ - (long)(N_SYMOFF(*execp)), false); \ - \ - NAME(aout,write_syms)(abfd); \ - \ - bfd_seek (abfd, (long)(N_TRELOFF(*execp)), false); \ - \ - if (!NAME(aout,squirt_out_relocs) (abfd, obj_textsec (abfd))) return false; \ - bfd_seek (abfd, (long)(N_DRELOFF(*execp)), false); \ - \ - if (!NAME(aout,squirt_out_relocs)(abfd, obj_datasec (abfd))) return false; \ - } \ - } diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h deleted file mode 100644 index 3114d052273..00000000000 --- a/bfd/libbfd-in.h +++ /dev/null @@ -1,207 +0,0 @@ - -/* libbfd.h -- Declarations used by bfd library *implementation*. - (This include file is not for users of the library.) - Copyright (C) 1990-1991 Free Software Foundation, Inc. - Written by Cygnus Support. - -This file is part of BFD, the Binary File Descriptor library. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - - -/* Align an address upward to a boundary, expressed as a number of bytes. - E.g. align to an 8-byte boundary with argument of 8. */ -#define ALIGN(this, boundary) \ - ((( (this) + ((boundary) -1)) & (~((boundary)-1)))) - -/* If you want to read and write large blocks, you might want to do it - in quanta of this amount */ -#define DEFAULT_BUFFERSIZE 8192 - -/* Set a tdata field. Can't use the other macros for this, since they - do casts, and casting to the left of assignment isn't portable. */ -#define set_tdata(bfd, v) ((bfd)->tdata = (PTR) (v)) - -/* tdata for an archive. For an input archive, cache - needs to be free()'d. For an output archive, symdefs do. */ - -struct artdata { - file_ptr first_file_filepos; - /* Speed up searching the armap */ - struct ar_cache *cache; - bfd *archive_head; /* Only interesting in output routines */ - carsym *symdefs; /* the symdef entries */ - symindex symdef_count; /* how many there are */ - char *extended_names; /* clever intel extension */ -}; - -#define bfd_ardata(bfd) ((struct artdata *) ((bfd)->tdata)) - -/* Goes in bfd's arelt_data slot */ -struct areltdata { - char * arch_header; /* it's actually a string */ - unsigned int parsed_size; /* octets of filesize not including ar_hdr */ - char *filename; /* null-terminated */ -}; - -#define arelt_size(bfd) (((struct areltdata *)((bfd)->arelt_data))->parsed_size) - -/* FIXME -- a lot of my code allocates a large block and subdivides it. - This can't always work, because of alignment restrictions. We should change - it before it becomes a problem -- Gumby */ - -PROTO (char *, zalloc, (bfd_size_type size)); - -/* These routines allocate and free things on the BFD's obstack. Note - that realloc can never occur in place. */ - -PROTO(PTR, bfd_alloc, (bfd *abfd, bfd_size_type size)); -PROTO(PTR, bfd_zalloc,(bfd *abfd, bfd_size_type size)); -PROTO(PTR, bfd_realloc,(bfd *abfd, PTR orig, bfd_size_type new)); -PROTO(void, bfd_alloc_grow,(bfd *abfd, PTR thing, bfd_size_type size)); -PROTO(PTR, bfd_alloc_finish,(bfd *abfd)); - -#define bfd_release(x,y) (void) obstack_free(&(x->memory),y) - - -PROTO (bfd_size_type, bfd_read, (PTR ptr, bfd_size_type size, bfd_size_type nitems, bfd *abfd)); -PROTO (bfd_size_type, bfd_write, (CONST PTR ptr, bfd_size_type size, bfd_size_type nitems, bfd *abfd)); - - - -PROTO (int, bfd_seek,(bfd* abfd, file_ptr fp , int direction)); -PROTO (long, bfd_tell, (bfd *abfd)); -PROTO (bfd *, _bfd_create_empty_archive_element_shell, (bfd *obfd)); -PROTO (bfd *, look_for_bfd_in_cache, (bfd *arch_bfd, file_ptr index)); -PROTO (boolean, _bfd_generic_mkarchive, (bfd *abfd)); -PROTO (struct areltdata *, snarf_ar_hdr, (bfd *abfd)); -PROTO (bfd_target *, bfd_generic_archive_p, (bfd *abfd)); -PROTO (boolean, bfd_slurp_bsd_armap, (bfd *abfd)); -PROTO (boolean, bfd_slurp_coff_armap, (bfd *abfd)); -PROTO (boolean, _bfd_slurp_extended_name_table, (bfd *abfd)); -PROTO (boolean, _bfd_write_archive_contents, (bfd *abfd)); -PROTO (bfd *, new_bfd, ()); - -#define DEFAULT_STRING_SPACE_SIZE 0x2000 -PROTO (boolean, bfd_add_to_string_table, (char **table, char *new_string, - unsigned int *table_length, - char **free_ptr)); -PROTO (bfd_vma, _do_getb64, (unsigned char *addr)); -PROTO (bfd_vma, _do_getl64, (unsigned char *addr)); -PROTO (bfd_vma, _do_getb32, (unsigned char *addr)); -PROTO (bfd_vma, _do_getl32, (unsigned char *addr)); -PROTO (bfd_vma, _do_getb16, (unsigned char *addr)); -PROTO (bfd_vma, _do_getl16, (unsigned char *addr)); -PROTO (void, _do_putb64, (bfd_vma data, unsigned char *addr)); -PROTO (void, _do_putl64, (bfd_vma data, unsigned char *addr)); -PROTO (void, _do_putb32, (bfd_vma data, unsigned char *addr)); -PROTO (void, _do_putl32, (bfd_vma data, unsigned char *addr)); -PROTO (void, _do_putb16, (bfd_vma data, unsigned char *addr)); -PROTO (void, _do_putl16, (bfd_vma data, unsigned char *addr)); - -PROTO (boolean, bfd_false, (bfd *ignore)); -PROTO (boolean, bfd_true, (bfd *ignore)); -PROTO (PTR, bfd_nullvoidptr, (bfd *ignore)); -PROTO (int, bfd_0, (bfd *ignore)); -PROTO (unsigned int, bfd_0u, (bfd *ignore)); -PROTO (void, bfd_void, (bfd *ignore)); - -PROTO (bfd *,new_bfd_contained_in,(bfd *)); -PROTO (boolean, _bfd_dummy_new_section_hook, (bfd *ignore, asection *newsect)); -PROTO (char *, _bfd_dummy_core_file_failing_command, (bfd *abfd)); -PROTO (int, _bfd_dummy_core_file_failing_signal, (bfd *abfd)); -PROTO (boolean, _bfd_dummy_core_file_matches_executable_p, (bfd *core_bfd, - bfd *exec_bfd)); -PROTO (bfd_target *, _bfd_dummy_target, (bfd *abfd)); - -PROTO (void, bfd_dont_truncate_arname, (bfd *abfd, CONST char *filename, - char *hdr)); -PROTO (void, bfd_bsd_truncate_arname, (bfd *abfd, CONST char *filename, - char *hdr)); -PROTO (void, bfd_gnu_truncate_arname, (bfd *abfd, CONST char *filename, - char *hdr)); - -PROTO (boolean, bsd_write_armap, (bfd *arch, unsigned int elength, - struct orl *map, unsigned int orl_count, int stridx)); - -PROTO (boolean, coff_write_armap, (bfd *arch, unsigned int elength, - struct orl *map, unsigned int orl_count, int stridx)); - -PROTO (bfd *, bfd_generic_openr_next_archived_file, (bfd *archive, - bfd *last_file)); - -PROTO(int, bfd_generic_stat_arch_elt, (bfd *, struct stat *)); - -PROTO(boolean, bfd_generic_get_section_contents, - (bfd *abfd, sec_ptr section, PTR location, file_ptr offset, - bfd_size_type count)); - -PROTO(boolean, bfd_generic_set_section_contents, - (bfd *abfd, sec_ptr section, PTR location, file_ptr offset, - bfd_size_type count)); - -/* Macros to tell if bfds are read or write enabled. - - Note that bfds open for read may be scribbled into if the fd passed - to bfd_fdopenr is actually open both for read and write - simultaneously. However an output bfd will never be open for - read. Therefore sometimes you want to check bfd_read_p or - !bfd_read_p, and only sometimes bfd_write_p. -*/ - -#define bfd_read_p(abfd) ((abfd)->direction == read_direction || (abfd)->direction == both_direction) -#define bfd_write_p(abfd) ((abfd)->direction == write_direction || (abfd)->direction == both_direction) - -PROTO (void, bfd_assert,(char*,int)); -#define BFD_ASSERT(x) \ -{ if (!(x)) bfd_assert(__FILE__,__LINE__); } - -#define BFD_FAIL() \ -{ bfd_assert(__FILE__,__LINE__); } - -PROTO (FILE *, bfd_cache_lookup_worker, (bfd *)); - -extern bfd *bfd_last_cache; - -/* Now Steve, what's the story here? */ -#ifdef lint -#define itos(x) "l" -#define stoi(x) 1 -#else -#define itos(x) ((char*)(x)) -#define stoi(x) ((int)(x)) -#endif - -/* Generic routine for close_and_cleanup is really just bfd_true. */ -#define bfd_generic_close_and_cleanup bfd_true - -/* THE FOLLOWING IS EXTRACTED FROM THE SOURCE*/ - -/*:init.c*/ - -/*:libbfd.c*/ - -/*:cache.c*/ - -/*:reloc.c*/ - -/*:cpu-h8300.c*/ - -/*:cpu-i960.c*/ - -/*:cpu-empty.c*/ - -/*:archures.c*/ - diff --git a/bfd/libbfd.c b/bfd/libbfd.c deleted file mode 100644 index 0d957dc2b5c..00000000000 --- a/bfd/libbfd.c +++ /dev/null @@ -1,548 +0,0 @@ -/* libbfd.c -- random BFD support routines, only used internally. - Copyright (C) 1990-1991 Free Software Foundation, Inc. - Written by Cygnus Support. - -This file is part of BFD, the Binary File Descriptor library. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* $Id$ */ - -#include "bfd.h" -#include "sysdep.h" -#include "libbfd.h" - -/** Dummies for targets that don't want or need to implement - certain operations */ - -boolean -DEFUN(_bfd_dummy_new_section_hook,(ignore, ignore_newsect), - bfd *ignore AND - asection *ignore_newsect) -{ - return true; -} - -boolean -DEFUN(bfd_false ,(ignore), - bfd *ignore) -{ - return false; -} - -boolean -DEFUN(bfd_true,(ignore), - bfd *ignore) -{ - return true; -} - -PTR -DEFUN(bfd_nullvoidptr,(ignore), - bfd *ignore) -{ - return (PTR)NULL; -} - -int -DEFUN(bfd_0,(ignore), - bfd *ignore) -{ - return 0; -} - -unsigned int -DEFUN(bfd_0u,(ignore), - bfd *ignore) -{ - return 0; -} - -void -DEFUN(bfd_void,(ignore), - bfd *ignore) -{ -} - -boolean -DEFUN(_bfd_dummy_core_file_matches_executable_p,(ignore_core_bfd, ignore_exec_bfd), - bfd *ignore_core_bfd AND - bfd *ignore_exec_bfd) -{ - bfd_error = invalid_operation; - return false; -} - -/* of course you can't initialize a function to be the same as another, grr */ - -char * -DEFUN(_bfd_dummy_core_file_failing_command,(ignore_abfd), - bfd *ignore_abfd) -{ - return (char *)NULL; -} - -int -DEFUN(_bfd_dummy_core_file_failing_signal,(ignore_abfd), - bfd *ignore_abfd) -{ - return 0; -} - -bfd_target * -DEFUN(_bfd_dummy_target,(ignore_abfd), - bfd *ignore_abfd) -{ - return 0; -} - -/** zalloc -- allocate and clear storage */ - - -#ifndef zalloc -char * -DEFUN(zalloc,(size), - bfd_size_type size) -{ - char *ptr = (char *) malloc ((int)size); - - if ((ptr != NULL) && (size != 0)) - memset(ptr,0, size); - - return ptr; -} -#endif - -/* Some IO code */ - - -/* Note that archive entries don't have streams; they share their parent's. - This allows someone to play with the iostream behind BFD's back. - - Also, note that the origin pointer points to the beginning of a file's - contents (0 for non-archive elements). For archive entries this is the - first octet in the file, NOT the beginning of the archive header. */ - -static -int DEFUN(real_read,(where, a,b, file), - PTR where AND - int a AND - int b AND - FILE *file) -{ - return fread(where, a,b,file); -} -bfd_size_type -DEFUN(bfd_read,(ptr, size, nitems, abfd), - PTR ptr AND - bfd_size_type size AND - bfd_size_type nitems AND - bfd *abfd) -{ - return (bfd_size_type)real_read (ptr, 1, (int)(size*nitems), bfd_cache_lookup(abfd)); -} - -bfd_size_type -DEFUN(bfd_write,(ptr, size, nitems, abfd), - CONST PTR ptr AND - bfd_size_type size AND - bfd_size_type nitems AND - bfd *abfd) -{ - return fwrite (ptr, 1, (int)(size*nitems), bfd_cache_lookup(abfd)); -} - -void -DEFUN(bfd_write_bigendian_4byte_int,(abfd, i), - bfd *abfd AND - int i) -{ - char buffer[4]; - _do_putb32(i, buffer); - bfd_write(buffer, 4, 1, abfd); -} - -int -DEFUN(bfd_seek,(abfd, position, direction), - bfd * CONST abfd AND - CONST file_ptr position AND - CONST int direction) -{ - /* For the time being, a BFD may not seek to it's end. The - problem is that we don't easily have a way to recognize - the end of an element in an archive. */ - - BFD_ASSERT(direction == SEEK_SET - || direction == SEEK_CUR); - - if (direction == SEEK_SET && abfd->my_archive != NULL) - { - /* This is a set within an archive, so we need to - add the base of the object within the archive */ - return(fseek(bfd_cache_lookup(abfd), - position + abfd->origin, - direction)); - } - else - { - return(fseek(bfd_cache_lookup(abfd), position, direction)); - } -} - -long -DEFUN(bfd_tell,(abfd), - bfd *abfd) -{ - file_ptr ptr; - - ptr = ftell (bfd_cache_lookup(abfd)); - - if (abfd->my_archive) - ptr -= abfd->origin; - return ptr; -} - -/** Make a string table */ - -/*>bfd.h< - Add string to table pointed to by table, at location starting with free_ptr. - resizes the table if necessary (if it's NULL, creates it, ignoring - table_length). Updates free_ptr, table, table_length */ - -boolean -DEFUN(bfd_add_to_string_table,(table, new_string, table_length, free_ptr), - char **table AND - char *new_string AND - unsigned int *table_length AND - char **free_ptr) -{ - size_t string_length = strlen (new_string) + 1; /* include null here */ - char *base = *table; - size_t space_length = *table_length; - unsigned int offset = (base ? *free_ptr - base : 0); - - if (base == NULL) { - /* Avoid a useless regrow if we can (but of course we still - take it next time */ - space_length = (string_length < DEFAULT_STRING_SPACE_SIZE ? - DEFAULT_STRING_SPACE_SIZE : string_length+1); - base = zalloc (space_length); - - if (base == NULL) { - bfd_error = no_memory; - return false; - } - } - - if ((size_t)(offset + string_length) >= space_length) { - /* Make sure we will have enough space */ - while ((size_t)(offset + string_length) >= space_length) - space_length += space_length/2; /* grow by 50% */ - - base = (char *) realloc (base, space_length); - if (base == NULL) { - bfd_error = no_memory; - return false; - } - - } - - memcpy (base + offset, new_string, string_length); - *table = base; - *table_length = space_length; - *free_ptr = base + offset + string_length; - - return true; -} - -/** The do-it-yourself (byte) sex-change kit */ - -/* The middle letter e.g. getshort indicates Big or Little endian - target machine. It doesn't matter what the byte order of the host - machine is; these routines work for either. */ - -/* FIXME: Should these take a count argument? - Answer (gnu@cygnus.com): No, but perhaps they should be inline - functions in swap.h #ifdef __GNUC__. - Gprof them later and find out. */ - -/*proto* -*i bfd_put_size -*i bfd_get_size -These macros as used for reading and writing raw data in sections; -each access (except for bytes) is vectored through the target format -of the BFD and mangled accordingly. The mangling performs any -necessary endian translations and removes alignment restrictions. -*+ -#define bfd_put_8(abfd, val, ptr) \ - (*((char *)ptr) = (char)val) -#define bfd_get_8(abfd, ptr) \ - (*((char *)ptr)) -#define bfd_put_16(abfd, val, ptr) \ - BFD_SEND(abfd, bfd_putx16, (val,ptr)) -#define bfd_get_16(abfd, ptr) \ - BFD_SEND(abfd, bfd_getx16, (ptr)) -#define bfd_put_32(abfd, val, ptr) \ - BFD_SEND(abfd, bfd_putx32, (val,ptr)) -#define bfd_get_32(abfd, ptr) \ - BFD_SEND(abfd, bfd_getx32, (ptr)) -#define bfd_put_64(abfd, val, ptr) \ - BFD_SEND(abfd, bfd_putx64, (val, ptr)) -#define bfd_get_64(abfd, ptr) \ - BFD_SEND(abfd, bfd_getx64, (ptr)) -*- -*-*/ - -/*proto* -*i bfd_h_put_size -*i bfd_h_get_size -These macros have the same function as their @code{bfd_get_x} -bretherin, except that they are used for removing information for the -header records of object files. Believe it or not, some object files -keep their header records in big endian order, and their data in little -endan order. -*+ -#define bfd_h_put_8(abfd, val, ptr) \ - (*((char *)ptr) = (char)val) -#define bfd_h_get_8(abfd, ptr) \ - (*((char *)ptr)) -#define bfd_h_put_16(abfd, val, ptr) \ - BFD_SEND(abfd, bfd_h_putx16,(val,ptr)) -#define bfd_h_get_16(abfd, ptr) \ - BFD_SEND(abfd, bfd_h_getx16,(ptr)) -#define bfd_h_put_32(abfd, val, ptr) \ - BFD_SEND(abfd, bfd_h_putx32,(val,ptr)) -#define bfd_h_get_32(abfd, ptr) \ - BFD_SEND(abfd, bfd_h_getx32,(ptr)) -#define bfd_h_put_64(abfd, val, ptr) \ - BFD_SEND(abfd, bfd_h_putx64,(val, ptr)) -#define bfd_h_get_64(abfd, ptr) \ - BFD_SEND(abfd, bfd_h_getx64,(ptr)) -*- -*-*/ - -bfd_vma -DEFUN(_do_getb16,(addr), - register bfd_byte *addr) -{ - return (addr[0] << 8) | addr[1]; -} - -bfd_vma -DEFUN(_do_getl16,(addr), - register bfd_byte *addr) -{ - return (addr[1] << 8) | addr[0]; -} - -void -DEFUN(_do_putb16,(data, addr), - bfd_vma data AND - register bfd_byte *addr) -{ - addr[0] = (bfd_byte)(data >> 8); - addr[1] = (bfd_byte )data; -} - -void -DEFUN(_do_putl16,(data, addr), - bfd_vma data AND - register bfd_byte *addr) -{ - addr[0] = (bfd_byte )data; - addr[1] = (bfd_byte)(data >> 8); -} - -bfd_vma -DEFUN(_do_getb32,(addr), - register bfd_byte *addr) -{ - return ((((addr[0] << 8) | addr[1]) << 8) | addr[2]) << 8 | addr[3]; -} - -bfd_vma -_do_getl32 (addr) - register bfd_byte *addr; -{ - return ((((addr[3] << 8) | addr[2]) << 8) | addr[1]) << 8 | addr[0]; -} - -bfd_vma -DEFUN(_do_getb64,(addr), - register bfd_byte *addr) -{ -#ifdef HOST_64_BIT - bfd_64_type low, high; - - high= ((((((((addr[0]) << 8) | - addr[1]) << 8) | - addr[2]) << 8) | - addr[3]) ); - - low = ((((((((addr[4]) << 8) | - addr[5]) << 8) | - addr[6]) << 8) | - addr[7])); - - return high << 32 | low; -#else - BFD_FAIL(); - return 0; -#endif - -} - -bfd_vma -DEFUN(_do_getl64,(addr), - register bfd_byte *addr) -{ - -#ifdef HOST_64_BIT - bfd_64_type low, high; - high= (((((((addr[7] << 8) | - addr[6]) << 8) | - addr[5]) << 8) | - addr[4])); - - low = (((((((addr[3] << 8) | - addr[2]) << 8) | - addr[1]) << 8) | - addr[0]) ); - - return high << 32 | low; -#else - BFD_FAIL(); - return 0; -#endif - -} - -void -DEFUN(_do_putb32,(data, addr), - bfd_vma data AND - register bfd_byte *addr) -{ - addr[0] = (bfd_byte)(data >> 24); - addr[1] = (bfd_byte)(data >> 16); - addr[2] = (bfd_byte)(data >> 8); - addr[3] = (bfd_byte)data; -} - -void -DEFUN(_do_putl32,(data, addr), - bfd_vma data AND - register bfd_byte *addr) -{ - addr[0] = (bfd_byte)data; - addr[1] = (bfd_byte)(data >> 8); - addr[2] = (bfd_byte)(data >> 16); - addr[3] = (bfd_byte)(data >> 24); -} -void -DEFUN(_do_putb64,(data, addr), - bfd_vma data AND - register bfd_byte *addr) -{ -#ifdef HOST_64_BIT - addr[0] = (bfd_byte)(data >> (7*8)); - addr[1] = (bfd_byte)(data >> (6*8)); - addr[2] = (bfd_byte)(data >> (5*8)); - addr[3] = (bfd_byte)(data >> (4*8)); - addr[4] = (bfd_byte)(data >> (3*8)); - addr[5] = (bfd_byte)(data >> (2*8)); - addr[6] = (bfd_byte)(data >> (1*8)); - addr[7] = (bfd_byte)(data >> (0*8)); -#else - BFD_FAIL(); -#endif - -} - -void -DEFUN(_do_putl64,(data, addr), - bfd_vma data AND - register bfd_byte *addr) -{ -#ifdef HOST_64_BIT - addr[7] = (bfd_byte)(data >> (7*8)); - addr[6] = (bfd_byte)(data >> (6*8)); - addr[5] = (bfd_byte)(data >> (5*8)); - addr[4] = (bfd_byte)(data >> (4*8)); - addr[3] = (bfd_byte)(data >> (3*8)); - addr[2] = (bfd_byte)(data >> (2*8)); - addr[1] = (bfd_byte)(data >> (1*8)); - addr[0] = (bfd_byte)(data >> (0*8)); -#else - BFD_FAIL(); -#endif - -} - - -/* Default implementation */ - -boolean -DEFUN(bfd_generic_get_section_contents, (abfd, section, location, offset, count), - bfd *abfd AND - sec_ptr section AND - PTR location AND - file_ptr offset AND - bfd_size_type count) -{ - if (count == 0) - return true; - if ((bfd_size_type)(offset+count) > section->size - || bfd_seek(abfd,(file_ptr)( section->filepos + offset), SEEK_SET) == -1 - || bfd_read(location, (bfd_size_type)1, count, abfd) != count) - return (false); /* on error */ - return (true); -} - -/* This generic function can only be used in implementations where creating - NEW sections is disallowed. It is useful in patching existing sections - in read-write files, though. See other set_section_contents functions - to see why it doesn't work for new sections. */ -boolean -DEFUN(bfd_generic_set_section_contents, (abfd, section, location, offset, count), - bfd *abfd AND - sec_ptr section AND - PTR location AND - file_ptr offset AND - bfd_size_type count) -{ - if (count == 0) - return true; - if ((bfd_size_type)(offset+count) > section->size - || bfd_seek(abfd, (file_ptr)(section->filepos + offset), SEEK_SET) == -1 - || bfd_write(location, (bfd_size_type)1, count, abfd) != count) - return (false); /* on error */ - return (true); -} - -/*proto-internal* -*i bfd_log2 -Return the log base 2 of the value supplied, rounded up. eg an arg -of 1025 would return 11. -*; PROTO(bfd_vma, bfd_log2,(bfd_vma x)); -*-*/ - -bfd_vma bfd_log2(x) -bfd_vma x; -{ - bfd_vma result = 0; - while ( (bfd_vma)(1<< result) < x) - result++; - return result; -} diff --git a/bfd/libbfd.h b/bfd/libbfd.h deleted file mode 100644 index 5dd471ddab3..00000000000 --- a/bfd/libbfd.h +++ /dev/null @@ -1,358 +0,0 @@ - -/* libbfd.h -- Declarations used by bfd library *implementation*. - (This include file is not for users of the library.) - Copyright (C) 1990-1991 Free Software Foundation, Inc. - Written by Cygnus Support. - -This file is part of BFD, the Binary File Descriptor library. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - - -/* Align an address upward to a boundary, expressed as a number of bytes. - E.g. align to an 8-byte boundary with argument of 8. */ -#define ALIGN(this, boundary) \ - ((( (this) + ((boundary) -1)) & (~((boundary)-1)))) - -/* If you want to read and write large blocks, you might want to do it - in quanta of this amount */ -#define DEFAULT_BUFFERSIZE 8192 - -/* Set a tdata field. Can't use the other macros for this, since they - do casts, and casting to the left of assignment isn't portable. */ -#define set_tdata(bfd, v) ((bfd)->tdata = (PTR) (v)) - -/* tdata for an archive. For an input archive, cache - needs to be free()'d. For an output archive, symdefs do. */ - -struct artdata { - file_ptr first_file_filepos; - /* Speed up searching the armap */ - struct ar_cache *cache; - bfd *archive_head; /* Only interesting in output routines */ - carsym *symdefs; /* the symdef entries */ - symindex symdef_count; /* how many there are */ - char *extended_names; /* clever intel extension */ -}; - -#define bfd_ardata(bfd) ((struct artdata *) ((bfd)->tdata)) - -/* Goes in bfd's arelt_data slot */ -struct areltdata { - char * arch_header; /* it's actually a string */ - unsigned int parsed_size; /* octets of filesize not including ar_hdr */ - char *filename; /* null-terminated */ -}; - -#define arelt_size(bfd) (((struct areltdata *)((bfd)->arelt_data))->parsed_size) - -/* FIXME -- a lot of my code allocates a large block and subdivides it. - This can't always work, because of alignment restrictions. We should change - it before it becomes a problem -- Gumby */ - -PROTO (char *, zalloc, (bfd_size_type size)); - -/* These routines allocate and free things on the BFD's obstack. Note - that realloc can never occur in place. */ - -PROTO(PTR, bfd_alloc, (bfd *abfd, bfd_size_type size)); -PROTO(PTR, bfd_zalloc,(bfd *abfd, bfd_size_type size)); -PROTO(PTR, bfd_realloc,(bfd *abfd, PTR orig, bfd_size_type new)); -PROTO(void, bfd_alloc_grow,(bfd *abfd, PTR thing, bfd_size_type size)); -PROTO(PTR, bfd_alloc_finish,(bfd *abfd)); - -#define bfd_release(x,y) (void) obstack_free(&(x->memory),y) - - -PROTO (bfd_size_type, bfd_read, (PTR ptr, bfd_size_type size, bfd_size_type nitems, bfd *abfd)); -PROTO (bfd_size_type, bfd_write, (CONST PTR ptr, bfd_size_type size, bfd_size_type nitems, bfd *abfd)); - - - -PROTO (int, bfd_seek,(bfd* abfd, file_ptr fp , int direction)); -PROTO (long, bfd_tell, (bfd *abfd)); -PROTO (bfd *, _bfd_create_empty_archive_element_shell, (bfd *obfd)); -PROTO (bfd *, look_for_bfd_in_cache, (bfd *arch_bfd, file_ptr index)); -PROTO (boolean, _bfd_generic_mkarchive, (bfd *abfd)); -PROTO (struct areltdata *, snarf_ar_hdr, (bfd *abfd)); -PROTO (bfd_target *, bfd_generic_archive_p, (bfd *abfd)); -PROTO (boolean, bfd_slurp_bsd_armap, (bfd *abfd)); -PROTO (boolean, bfd_slurp_coff_armap, (bfd *abfd)); -PROTO (boolean, _bfd_slurp_extended_name_table, (bfd *abfd)); -PROTO (boolean, _bfd_write_archive_contents, (bfd *abfd)); -PROTO (bfd *, new_bfd, ()); - -#define DEFAULT_STRING_SPACE_SIZE 0x2000 -PROTO (boolean, bfd_add_to_string_table, (char **table, char *new_string, - unsigned int *table_length, - char **free_ptr)); -PROTO (bfd_vma, _do_getb64, (unsigned char *addr)); -PROTO (bfd_vma, _do_getl64, (unsigned char *addr)); -PROTO (bfd_vma, _do_getb32, (unsigned char *addr)); -PROTO (bfd_vma, _do_getl32, (unsigned char *addr)); -PROTO (bfd_vma, _do_getb16, (unsigned char *addr)); -PROTO (bfd_vma, _do_getl16, (unsigned char *addr)); -PROTO (void, _do_putb64, (bfd_vma data, unsigned char *addr)); -PROTO (void, _do_putl64, (bfd_vma data, unsigned char *addr)); -PROTO (void, _do_putb32, (bfd_vma data, unsigned char *addr)); -PROTO (void, _do_putl32, (bfd_vma data, unsigned char *addr)); -PROTO (void, _do_putb16, (bfd_vma data, unsigned char *addr)); -PROTO (void, _do_putl16, (bfd_vma data, unsigned char *addr)); - -PROTO (boolean, bfd_false, (bfd *ignore)); -PROTO (boolean, bfd_true, (bfd *ignore)); -PROTO (PTR, bfd_nullvoidptr, (bfd *ignore)); -PROTO (int, bfd_0, (bfd *ignore)); -PROTO (unsigned int, bfd_0u, (bfd *ignore)); -PROTO (void, bfd_void, (bfd *ignore)); - -PROTO (bfd *,new_bfd_contained_in,(bfd *)); -PROTO (boolean, _bfd_dummy_new_section_hook, (bfd *ignore, asection *newsect)); -PROTO (char *, _bfd_dummy_core_file_failing_command, (bfd *abfd)); -PROTO (int, _bfd_dummy_core_file_failing_signal, (bfd *abfd)); -PROTO (boolean, _bfd_dummy_core_file_matches_executable_p, (bfd *core_bfd, - bfd *exec_bfd)); -PROTO (bfd_target *, _bfd_dummy_target, (bfd *abfd)); - -PROTO (void, bfd_dont_truncate_arname, (bfd *abfd, CONST char *filename, - char *hdr)); -PROTO (void, bfd_bsd_truncate_arname, (bfd *abfd, CONST char *filename, - char *hdr)); -PROTO (void, bfd_gnu_truncate_arname, (bfd *abfd, CONST char *filename, - char *hdr)); - -PROTO (boolean, bsd_write_armap, (bfd *arch, unsigned int elength, - struct orl *map, unsigned int orl_count, int stridx)); - -PROTO (boolean, coff_write_armap, (bfd *arch, unsigned int elength, - struct orl *map, unsigned int orl_count, int stridx)); - -PROTO (bfd *, bfd_generic_openr_next_archived_file, (bfd *archive, - bfd *last_file)); - -PROTO(int, bfd_generic_stat_arch_elt, (bfd *, struct stat *)); - -PROTO(boolean, bfd_generic_get_section_contents, - (bfd *abfd, sec_ptr section, PTR location, file_ptr offset, - bfd_size_type count)); - -PROTO(boolean, bfd_generic_set_section_contents, - (bfd *abfd, sec_ptr section, PTR location, file_ptr offset, - bfd_size_type count)); - -/* Macros to tell if bfds are read or write enabled. - - Note that bfds open for read may be scribbled into if the fd passed - to bfd_fdopenr is actually open both for read and write - simultaneously. However an output bfd will never be open for - read. Therefore sometimes you want to check bfd_read_p or - !bfd_read_p, and only sometimes bfd_write_p. -*/ - -#define bfd_read_p(abfd) ((abfd)->direction == read_direction || (abfd)->direction == both_direction) -#define bfd_write_p(abfd) ((abfd)->direction == write_direction || (abfd)->direction == both_direction) - -PROTO (void, bfd_assert,(char*,int)); -#define BFD_ASSERT(x) \ -{ if (!(x)) bfd_assert(__FILE__,__LINE__); } - -#define BFD_FAIL() \ -{ bfd_assert(__FILE__,__LINE__); } - -PROTO (FILE *, bfd_cache_lookup_worker, (bfd *)); - -extern bfd *bfd_last_cache; - -/* Now Steve, what's the story here? */ -#ifdef lint -#define itos(x) "l" -#define stoi(x) 1 -#else -#define itos(x) ((char*)(x)) -#define stoi(x) ((int)(x)) -#endif - -/* Generic routine for close_and_cleanup is really just bfd_true. */ -#define bfd_generic_close_and_cleanup bfd_true - -/* THE FOLLOWING IS EXTRACTED FROM THE SOURCE*/ - -/*:init.c*/ -/* bfd_check_init - -This routine is called before any other bfd function using initialized -data is used to ensure that the structures have been initialized. -Soon this function will go away, and the bfd library will assume that -bfd_init has been called. -*/ - - void EXFUN(bfd_check_init,(void)); - -/* -*/ - -/*:libbfd.c*/ -/* bfd_write_bigendian_4byte_int -*/ - - PROTO(void, bfd_write_bigendian_4byte_int,( bfd *abfd, int i)); - -/* - -*i bfd_log2 -Return the log base 2 of the value supplied, rounded up. eg an arg -of 1025 would return 11. -*/ - PROTO(bfd_vma, bfd_log2,(bfd_vma x)); - -/* -*/ - -/*:cache.c*/ -/* BFD_CACHE_MAX_OPEN -The maxiumum number of files which the cache will keep open at one -time. -*/ -#define BFD_CACHE_MAX_OPEN 10 - -/* - - bfd_last_cache -Zero, or a pointer to the topmost BFD on the chain. This is used by -the @code{bfd_cache_lookup} macro in @file{libbfd.h} to determine when -it can avoid a function call. -*/ -extern bfd *bfd_last_cache; - -/* - - bfd_cache_lookup -Checks to see if the required BFD is the same as the last one looked -up. If so then it can use the iostream in the BFD with impunity, since -it can't have changed since the last lookup, otherwise it has to -perform the complicated lookup function -*/ -#define bfd_cache_lookup(x) \ - ((x)==bfd_last_cache? \ - (FILE*)(bfd_last_cache->iostream): \ - bfd_cache_lookup_worker(x)) - -/* - -*i bfd_cache_init -Initialize a BFD by putting it on the cache LRU. -*/ - PROTO(void, bfd_cache_init, (bfd *)); - -/* - -*i bfd_cache_close -Remove the BFD from the cache. If the attached file is open, then close it too. -*/ - PROTO(void, bfd_cache_close, (bfd *)); - -/* - -*i bfd_open_file -Call the OS to open a file for this BFD. Returns the FILE * -(possibly null) that results from this operation. Sets up the -BFD so that future accesses know the file is open. If the FILE * -returned is null, then there is won't have been put in the cache, so -it won't have to be removed from it. -*/ - PROTO(FILE *, bfd_open_file, (bfd *)); - -/* - -*i bfd_cache_lookup_worker -Called when the macro @code{bfd_cache_lookup} fails to find a quick -answer. Finds a file descriptor for this BFD. If necessary, it open it. -If there are already more than BFD_CACHE_MAX_OPEN files open, it trys to close -one first, to avoid running out of file descriptors. -*/ - PROTO(FILE *, bfd_cache_lookup_worker, (bfd *)); - -/* -*/ - - -/*:reloc.c*/ - -/*:cpu-h8300.c*/ - -/*:cpu-i960.c*/ - -/*:cpu-empty.c*/ - -/*:archures.c*/ -/* bfd_default_arch_struct - -What bfds are seeded with -*/ - -extern bfd_arch_info_type bfd_default_arch_struct; - -/* - bfd_default_set_arch_mach - -Set the architecture and machine type in a bfd. This finds the correct -pointer to structure and inserts it into the arch_info pointer. -*/ - - boolean EXFUN(bfd_default_set_arch_mach,(bfd *abfd, - enum bfd_architecture arch, - unsigned long mach)); - -/* - -This routine initializes the architecture dispatch table by calling -all installed architecture packages and getting them to poke around. -*/ - - PROTO(void, bfd_arch_init,(void)); - -/* - - bfd_arch_linkin - -Link the provided arch info structure into the list -*/ - - void EXFUN(bfd_arch_linkin,(bfd_arch_info_type *)); - -/* - - bfd_default_compatible - -The default function for testing for compatibility -*/ - - CONST bfd_arch_info_type *EXFUN(bfd_default_compatible, - (CONST bfd_arch_info_type *a, - CONST bfd_arch_info_type *b)); - -/* - - bfd_default_scan -The default function for working out whether this is an architecture -hit and a machine hit -*/ - - boolean EXFUN(bfd_default_scan,(CONST struct bfd_arch_info *, CONST char *)); - -/* -*/ - - diff --git a/bfd/libcoff.h b/bfd/libcoff.h deleted file mode 100644 index a29b9c2ad6a..00000000000 --- a/bfd/libcoff.h +++ /dev/null @@ -1,161 +0,0 @@ -/* BFD COFF object file private structure. - Copyright (C) 1990-1991 Free Software Foundation, Inc. - Written by Cygnus Support. - -This file is part of BFD, the Binary File Descriptor library. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* $Id$ */ - -/* Object file tdata; access macros */ - -#define obj_icof(bfd) ((struct icofdata *) ((bfd)->tdata)) -#define coff_data(bfd) ((struct icofdata *) ((bfd)->tdata)) -#define exec_hdr(bfd) (obj_icof(bfd)->hdr) -#define obj_symbols(bfd) (obj_icof(bfd)->symbols) -#define obj_sym_filepos(bfd) (obj_icof(bfd)->sym_filepos) - -#define obj_relocbase(bfd) (obj_icof(bfd)->relocbase) -#define obj_raw_syments(bfd) (obj_icof(bfd)->raw_syments) -#define obj_convert(bfd) (obj_icof(bfd)->conversion_table) -#if CFILE_STUFF -#define obj_symbol_slew(bfd) (obj_icof(bfd)->symbol_index_slew) -#else -#define obj_symbol_slew(bfd) 0 -#endif -#define obj_string_table(bfd) (obj_icof(bfd)->string_table) - -#if 0 -typedef struct coff_ptr_struct -{ - unsigned int offset; - char fix_tag; - char fix_end; - union { - union internal_auxent auxent; - struct internal_syment syment; - } u; -} combined_entry_type; - - -typedef struct -{ - asymbol symbol; - combined_entry_type *native; - struct lineno_cache_entry *lineno; -} coff_symbol_type; -#endif - -typedef struct icofdata -{ - -struct coff_symbol_struct *symbols; /* symtab for input bfd */ - unsigned int *conversion_table; - file_ptr sym_filepos; - - long symbol_index_slew; /* used during read to mark whether a - C_FILE symbol as been added. */ - -struct coff_ptr_struct *raw_syments; - struct lineno *raw_linenos; - unsigned int raw_syment_count; - char *string_table; - unsigned short flags; - /* These are only valid once writing has begun */ - long int relocbase; -} coff_data_type; - -/* We take the address of the first element of a asymbol to ensure that the - * macro is only ever applied to an asymbol. */ -#define coffsymbol(asymbol) ((coff_symbol_type *)(&((asymbol)->the_bfd))) - - - -/*THE FOLLOWING IS EXTRACTED FROM THE SOURCE*/ - -/* FROM coffcode.h*/ -/* ------------------------------START FROM coffcode.h - -The hidden information for an asymbol is: -*/ - - typedef struct coff_ptr_struct - { - -/* -Remembers the offset from the first symbol in the file for this -symbol. Generated by @code{coff_renumber_symbols}. -*/ - - unsigned int offset; - -/* -Should the tag field of this symbol be renumbered. -Created by @code{coff_pointerize_aux}. -*/ - - char fix_tag; - -/* -Should the endidx field of this symbol be renumbered. -Created by @code{coff_pointerize_aux}. -*/ - - char fix_end; - -/* -The container for the symbol structure as read and translated from the file. -*/ - - union { - union internal_auxent auxent; - struct internal_syment syment; - } u; - } combined_entry_type; - -/* - -Each canonical asymbol really looks like this: -*/ - - typedef struct coff_symbol_struct - { - -/* -The actual symbol which the rest of BFD works with -*/ - - asymbol symbol; - -/* -A pointer to the hidden information for this symbol -*/ - - combined_entry_type *native; - -/* -A pointer to the linenumber information for this symbol -*/ - - struct lineno_cache_entry *lineno; - } coff_symbol_type; - -/* - - --------------------------------END FROM coffcode.h*/ - - - diff --git a/bfd/libieee.h b/bfd/libieee.h deleted file mode 100644 index 539d1742351..00000000000 --- a/bfd/libieee.h +++ /dev/null @@ -1,94 +0,0 @@ -typedef struct { - unsigned int index:24; - char letter; -} ieee_symbol_index_type; - -typedef struct ieee_symbol -{ - asymbol symbol; - struct ieee_symbol *next; - - unsigned int index; -} ieee_symbol_type; - - -typedef struct ieee_reloc { - arelent relent; - struct ieee_reloc *next; - ieee_symbol_index_type symbol; - -} ieee_reloc_type; - -#define ieee_symbol(x) ((ieee_symbol_type *)(x)) - -typedef struct ieee_per_section -{ - asection *section; - bfd_byte *data; - bfd_vma offset; - bfd_vma pc; - /* For output */ - file_ptr current_pos; - unsigned int current_byte; - boolean initialized; - ieee_reloc_type **reloc_tail_ptr; -} ieee_per_section_type; - -#define ieee_per_section(x) ((ieee_per_section_type *)((x)->used_by_bfd)) -#define NSECTIONS 10 - - - -typedef struct -{ - boolean read_symbols; - boolean read_data; - unsigned char *input_p; - unsigned char *first_byte; - file_ptr output_cursor; - /* Map of section indexes to section ptrs */ - asection * section_table[NSECTIONS]; - ieee_address_descriptor_type ad; - ieee_module_begin_type mb; - ieee_w_variable_type w; - - unsigned int section_count; - - unsigned int map_idx; - /* List of GLOBAL EXPORT symbols */ - ieee_symbol_type *external_symbols; - /* List of UNDEFINED symbols */ - ieee_symbol_type *external_reference; - - /* When the symbols have been canonicalized, they are in a - * special order, we remember various bases here.. */ - unsigned int external_symbol_max_index; - unsigned int external_symbol_min_index; - unsigned int external_symbol_count; - int external_symbol_base_offset; - - unsigned int external_reference_max_index; - unsigned int external_reference_min_index; - unsigned int external_reference_count; - int external_reference_base_offset; - - bfd *abfd; - boolean symbol_table_full; -} ieee_data_type; - -typedef struct { - file_ptr file_offset; - bfd *abfd; -} ieee_ar_obstack_type; - -typedef struct { - ieee_ar_obstack_type *elements; - struct obstack element_obstack; - unsigned int element_index ; - unsigned int element_count; -} ieee_ar_data_type; - -#define ieee_data(abfd) ((ieee_data_type *)(abfd)->tdata) -#define ieee_ar_data(abfd) ((ieee_ar_data_type *)(abfd)->arelt_data) - -#define ptr(abfd) (ieee_data(abfd)->input_p) diff --git a/bfd/liboasys.h b/bfd/liboasys.h deleted file mode 100644 index 4626ab0baac..00000000000 --- a/bfd/liboasys.h +++ /dev/null @@ -1,84 +0,0 @@ -/* BFD internal declarations for Oasys file format handling */ -/* Scrawled by Steve Chamberlain of Cygnus Support. */ - -/* Copyright (C) 1990, 1991 Free Software Foundation, Inc. - -This file is part of BFD, the Binary File Diddler. - -BFD 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 1, or (at your option) -any later version. - -BFD 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 BFD; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - - -typedef struct _oasys_symbol -{ - asymbol symbol; -} oasys_symbol_type; - -typedef struct _oasys_reloc { - arelent relent; - struct _oasys_reloc *next; - unsigned int symbol; -} oasys_reloc_type; - - -#define oasys_symbol(x) ((oasys_symbol_type *)(x)) -#define oasys_per_section(x) ((oasys_per_section_type *)(x->used_by_bfd)) - -typedef struct _oasys_per_section -{ - asection *section; - bfd_byte *data; - bfd_vma offset; - boolean had_vma; - oasys_reloc_type **reloc_tail_ptr; - bfd_vma pc; - - - file_ptr current_pos; - unsigned int current_byte; - boolean initialized; -} oasys_per_section_type; - -#define NSECTIONS 10 - -typedef struct _oasys_ar_obstack { - file_ptr file_offset; - bfd *abfd; -} oasys_ar_obstack_type; - - -typedef struct _oasys_module_info { - file_ptr pos; - unsigned int size; - bfd *abfd; - char *name; -} oasys_module_info_type; - -typedef struct _oasys_ar_data { - oasys_module_info_type *module; - unsigned int module_count; - unsigned int module_index; -} oasys_ar_data_type; - -typedef struct _oasys_data { - struct obstack oasys_obstack; - char *strings; - asymbol *symbols; - unsigned int symbol_string_length; - asection *sections[OASYS_MAX_SEC_COUNT]; - file_ptr first_data_record; -} oasys_data_type; - -#define oasys_data(abfd) ((oasys_data_type *)((abfd)->tdata)) -#define oasys_ar_data(abfd) ((oasys_ar_data_type *)((abfd)->tdata)) diff --git a/bfd/mergecom-p b/bfd/mergecom-p deleted file mode 100755 index 456478b7c48..00000000000 --- a/bfd/mergecom-p +++ /dev/null @@ -1,5 +0,0 @@ -# SED script for preprocessing embedded headers from C source comments -# Locate and coalesce adjacent comments -/\*\/$/N -s/\*\/\n\/\*/\ -/ diff --git a/bfd/misc.c b/bfd/misc.c deleted file mode 100755 index 041fcde8623..00000000000 --- a/bfd/misc.c +++ /dev/null @@ -1,98 +0,0 @@ -/* Copyright (C) 1990, 1991 Free Software Foundation, Inc. - -This file is part of BFD, the Binary File Diddler. - -BFD 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 1, or (at your option) -any later version. - -BFD 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 BFD; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* $Id$ */ - -#if 0 - /* xoxorich. coelesced from other binutils. */ -/* This crap should all be bundled with the binutils, or else be in its - own library, but for expediency we are doing it this way right now. */ - -/* - * Last Mod Mon Feb 18 14:49:39 PST 1991, by rich@cygint.cygnus.com - */ - -#include -#include "misc.h" -#if __STDC__ -extern char *realloc (char * ptr, int size); -extern char *malloc (int size); -#else -extern char *realloc (); -extern char *malloc (); -#endif - -/* Print the filename of the current file on 'outfile' (a stdio stream). */ - -/* Current file's name */ - -char *input_name; - -/* Current member's name, or 0 if processing a non-library file. */ - -char *input_member; - -void print_file_name (outfile) - FILE *outfile; -{ - fprintf (outfile, "%s", input_name); - if (input_member) - fprintf (outfile, "(%s)", input_member); -} - -/* process one input file */ -void scan_library (); - -char *program_name; - -/* Report a nonfatal error. - STRING is a format for printf, and ARG1 ... ARG3 are args for it. */ -/*VARARGS*/ -void -error (string, arg1, arg2, arg3) - char *string, *arg1, *arg2, *arg3; -{ - fprintf (stderr, "%s: ", program_name); - fprintf (stderr, string, arg1, arg2, arg3); - fprintf (stderr, "\n"); -} - - - -/* Report a nonfatal error. - STRING is printed, followed by the current file name. */ - -void -error_with_file (string) - char *string; -{ - fprintf (stderr, "%s: ", program_name); - print_file_name (stderr); - fprintf (stderr, ": "); - fprintf (stderr, string); - fprintf (stderr, "\n"); -} - -/* Like malloc but get fatal error if memory is exhausted. */ - - -/* Like realloc but get fatal error if memory is exhausted. */ - - -/* end of misc.c */ -#endif diff --git a/bfd/misc.h b/bfd/misc.h deleted file mode 100755 index 05935c28f6f..00000000000 --- a/bfd/misc.h +++ /dev/null @@ -1,93 +0,0 @@ -/* Copyright (C) 1990, 1991 Free Software Foundation, Inc. - -This file is part of BFD, the Binary File Diddler. - -BFD 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 1, or (at your option) -any later version. - -BFD 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 BFD; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* $Id$ */ - -/* xoxorich. coelesced from binutils. - * - * Last Mod Mon Feb 18 14:49:51 PST 1991, by rich@cygint.cygnus.com - */ - -#ifndef MISC_H -#define MISC_H 1 - -#include "ranlib.h" - -#ifdef USG -#include -#else -#include -#endif /* USG */ - -#ifdef never -#ifdef LOCKS -#undef LOCKS -#endif /* LOCKS */ -#endif /* never */ - - /* used for masking system io calls into stdio. */ - -/* the name, ie, argv[0], of this program. */ - -extern char *program_name; - -/* Current file's name */ - -extern char *input_name; - -/* Current member's name, or 0 if processing a non-library file. */ - -extern char *input_member; - -/* Report an error using the message for the last failed system call, - followed by the string NAME. */ - -#define perror_name(name) perror(concat(program_name, ": error on ", name)) -#define pfatal_with_name(name) {perror_name(name);exit(-1);} - -#ifdef __STDC__ - -extern char *concat(char *a, char *b, char *c); -extern void *xmalloc(unsigned int size); -extern void * xrealloc(char *ptr, int size); -extern void error(char *string, char *arg1, char *arg2, char *arg3); -extern void error_with_file(char *string); -extern void fatal(char *string, char*a1, char*a2, char*a3); -extern void print_file_name(FILE *outfile); -extern void swap_symdef_table(struct symdef *sym, int count); -#else -extern char *alloca(); -extern char *concat(); -extern void * xmalloc(); -extern void *xrealloc(); -extern void error(); -extern void error_with_file(); -extern void fatal(); -extern void print_file_name(); -extern void swap_symdef_table(); -#endif /* __STDC__ */ - -#endif /* MISC_H */ - -/* - * Local Variables: - * comment-column: 0 - * End: - */ - -/* end of misc.h */ diff --git a/bfd/movecom-p b/bfd/movecom-p deleted file mode 100755 index 7ed04c7b112..00000000000 --- a/bfd/movecom-p +++ /dev/null @@ -1,8 +0,0 @@ -# sed script for BFD header files: -# Transpose -/^$/,/^ *[^ ]*.*$/{ -/^$/N -/^ *\n\*\/$/c\ -*\/\ - -} diff --git a/bfd/newsos3.c b/bfd/newsos3.c deleted file mode 100644 index 8a1cfc84cfa..00000000000 --- a/bfd/newsos3.c +++ /dev/null @@ -1,169 +0,0 @@ -/* BFD back-end for NewsOS3 (Sony, 68k) binaries. - Copyright (C) 1990-1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#define PAGE_SIZE 4096 -#define SEGMENT_SIZE PAGE_SIZE -#define TEXT_START_ADDR 0 -#define ARCH 32 -#define BYTES_IN_WORD 4 - -#include "bfd.h" -#include "sysdep.h" -#include "libbfd.h" -#include "aout64.h" - -/**From: bothner@cs.wisc.edu***********************************************/ -#undef N_TXTOFF -#define N_TXTOFF(x) ( (N_MAGIC((x)) == ZMAGIC) ? PAGE_SIZE : EXEC_BYTES_SIZE) -/**************************************************************************/ - -#include "stab.gnu.h" -#include "ar.h" -#include "libaout.h" /* BFD a.out internal data structures */ -#if 0 -int vfprintf(file, format, args) /* Temporary crock! */ - FILE *file; char *format; char *args; -{ - return _doprnt (format, args, file); -} -#endif - - -bfd_target *newsos3_callback (); - -bfd_target * -DEFUN(newsos3_object_p,(abfd), - bfd *abfd) -{ - struct external_exec exec_bytes; - struct internal_exec exec; - - if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd) - != EXEC_BYTES_SIZE) { - bfd_error = wrong_format; - return 0; - } - - exec.a_info = bfd_h_get_32 (abfd, exec_bytes.e_info); - - if (N_BADMAG (exec)) return 0; - - NAME(aout,swap_exec_header_in)(abfd, &exec_bytes, &exec); - return aout_32_some_aout_object_p (abfd, &exec, newsos3_callback); -} - -/* Finish up the reading of a NEWS-OS a.out file header */ -bfd_target * -DEFUN(newsos3_callback,(abfd), - bfd *abfd) -{ - struct internal_exec *execp = exec_hdr (abfd); - - WORK_OUT_FILE_POSITIONS(abfd, execp) ; - - /* Determine the architecture and machine type of the object file. - */ - bfd_default_set_arch_mach(abfd, bfd_arch_m68k, 0); - - - return abfd->xvec; -} - -/* Write an object file in NEWS-OS format. - Section contents have already been written. We write the - file header, symbols, and relocation. */ - -boolean -DEFUN(newsos3_write_object_contents,(abfd), - bfd *abfd) -{ - bfd_size_type data_pad = 0; - struct external_exec exec_bytes; - struct internal_exec *execp = exec_hdr (abfd); - - WRITE_HEADERS(abfd, execp); - return true; -} - -/* Transfer vectors for NEWS-OS version 3 */ - -/* We use BFD generic archive files. */ -#define newsos_openr_next_archived_file bfd_generic_openr_next_archived_file -#define newsos_generic_stat_arch_elt bfd_generic_stat_arch_elt -#define newsos_slurp_armap bfd_slurp_bsd_armap -#define newsos_slurp_extended_name_table bfd_true -#define newsos_write_armap bsd_write_armap -#define newsos_truncate_arname bfd_bsd_truncate_arname - -/* We don't support core files yet. FIXME. */ -#define newsos_core_file_failing_command _bfd_dummy_core_file_failing_command -#define newsos_core_file_failing_signal _bfd_dummy_core_file_failing_signal -#define newsos_core_file_matches_executable_p \ - _bfd_dummy_core_file_matches_executable_p -#define newsos_core_file_p _bfd_dummy_target - -#define newsos_bfd_debug_info_start bfd_void -#define newsos_bfd_debug_info_end bfd_void -#define newsos_bfd_debug_info_accumulate (PROTO(void,(*),(bfd*, struct sec *))) bfd_void - -#define newsos_mkobject aout_32_mkobject -#define newsos_close_and_cleanup aout_32_close_and_cleanup -#define newsos_set_section_contents aout_32_set_section_contents -#define newsos_get_section_contents aout_32_get_section_contents -#define newsos_new_section_hook aout_32_new_section_hook -#define newsos_get_symtab_upper_bound aout_32_get_symtab_upper_bound -#define newsos_get_symtab aout_32_get_symtab -#define newsos_get_reloc_upper_bound aout_32_get_reloc_upper_bound -#define newsos_canonicalize_reloc aout_32_canonicalize_reloc -#define newsos_make_empty_symbol aout_32_make_empty_symbol -#define newsos_print_symbol aout_32_print_symbol -#define newsos_get_lineno aout_32_get_lineno -#define newsos_set_arch_mach aout_32_set_arch_mach -#define newsos_find_nearest_line aout_32_find_nearest_line -#define newsos_sizeof_headers aout_32_sizeof_headers - - -/* We define our own versions of these routines. */ - - -bfd_target newsos3_vec = /* Sony 68k-based machines running newsos3 */ -{ - "a.out-newsos3", /* name */ - bfd_target_aout_flavour, - true, /* target byte order */ - true, /* target headers byte order */ - (HAS_RELOC | EXEC_P | /* object flags */ - HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED), - (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ - ' ', /* ar_pad_char */ - 16, /* ar_max_namelen */ - 1, /* minimum alignment */ - _do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* data */ - _do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* hdrs */ - - {_bfd_dummy_target, newsos3_object_p, /* bfd_check_format */ - bfd_generic_archive_p, newsos_core_file_p}, - {bfd_false, newsos_mkobject, /* bfd_set_format */ - _bfd_generic_mkarchive, bfd_false}, - {bfd_false, newsos3_write_object_contents, /* bfd_write_contents */ - _bfd_write_archive_contents, bfd_false}, - - JUMP_TABLE(newsos) -}; diff --git a/bfd/oasys.c b/bfd/oasys.c deleted file mode 100644 index e5e34e68c7c..00000000000 --- a/bfd/oasys.c +++ /dev/null @@ -1,1322 +0,0 @@ -/* bfd backend for oasys objects. - Copyright (C) 1990-1991 Free Software Foundation, Inc. - Written by Steve Chamberlain of Cygnus Support . - -This file is part of BFD, the Binary File Descriptor library. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* $Id$ */ - -#define UNDERSCORE_HACK 1 -#include -#include - -#include "bfd.h" -#include "libbfd.h" -#include "oasys.h" -#include "liboasys.h" - -/* XXX - FIXME. offsetof belongs in the system-specific files in - ../include/sys. */ -/* Define offsetof for those systems which lack it */ - -#ifndef offsetof -#define offsetof(type, identifier) (size_t) &(((type *) 0)->identifier) -#endif - -/* Read in all the section data and relocation stuff too */ -PROTO(static boolean,oasys_slurp_section_data,(bfd *CONST abfd)); - -static void -DEFUN(oasys_read_record,(abfd, record), - bfd *CONST abfd AND - oasys_record_union_type *record) -{ - - bfd_read((PTR)record, 1, sizeof(record->header), abfd); - - if ((size_t) record->header.length <= (size_t) sizeof (record->header)) - return; - bfd_read((PTR)(((char *)record )+ sizeof(record->header)), - 1, record->header.length - sizeof(record->header), - abfd); -} -static size_t -DEFUN(oasys_string_length,(record), - oasys_record_union_type *record) -{ -return record->header.length - - ((char *)record->symbol.name - (char *)record); -} - -/*****************************************************************************/ - -/* - -Slurp the symbol table by reading in all the records at the start file -till we get to the first section record. - -We'll sort the symbolss into two lists, defined and undefined. The -undefined symbols will be placed into the table according to their -refno. - -We do this by placing all undefined symbols at the front of the table -moving in, and the defined symbols at the end of the table moving back. - -*/ - -static boolean -DEFUN(oasys_slurp_symbol_table,(abfd), - bfd * CONST abfd) -{ - oasys_record_union_type record; - oasys_data_type *data = oasys_data(abfd); - boolean loop = true; - asymbol *dest_defined; - asymbol *dest; - char *string_ptr; - - - if (data->symbols != (asymbol *)NULL) { - return true; - } - /* Buy enough memory for all the symbols and all the names */ - data->symbols = - (asymbol *)bfd_alloc(abfd, sizeof(asymbol) * abfd->symcount); -#ifdef UNDERSCORE_HACK - /* buy 1 more char for each symbol to keep the underscore in*/ - data->strings = bfd_alloc(abfd, data->symbol_string_length + - abfd->symcount); -#else - data->strings = bfd_alloc(abfd, data->symbol_string_length); -#endif - - - dest_defined = data->symbols + abfd->symcount -1; - - string_ptr = data->strings; - bfd_seek(abfd, (file_ptr)0, SEEK_SET); - while (loop) { - - oasys_read_record(abfd, &record); - switch (record.header.type) { - case oasys_record_is_header_enum: - break; - case oasys_record_is_local_enum: - case oasys_record_is_symbol_enum: - { - int flag = record.header.type == oasys_record_is_local_enum ? - (BSF_LOCAL) : (BSF_GLOBAL | BSF_EXPORT); - - - size_t length = oasys_string_length(&record); - switch (record.symbol.relb & RELOCATION_TYPE_BITS) { - case RELOCATION_TYPE_ABS: - dest = dest_defined--; - dest->section = 0; - dest->flags = BSF_ABSOLUTE | flag; - break; - case RELOCATION_TYPE_REL: - dest = dest_defined--; - dest->section = - oasys_data(abfd)->sections[record.symbol.relb & - RELOCATION_SECT_BITS]; - if (record.header.type == oasys_record_is_local_enum) - { - dest->flags = BSF_LOCAL; - if (dest->section ==(asection *)(~0)) { - /* It seems that sometimes internal symbols are tied up, but - still get output, even though there is no - section */ - dest->section = 0; - } - } - else { - - dest->flags = flag; - } - break; - case RELOCATION_TYPE_UND: - dest = data->symbols + bfd_h_get_16(abfd, (bfd_byte *)&record.symbol.refno[0]); - dest->section = (asection *)NULL; - dest->flags = BSF_UNDEFINED; - break; - case RELOCATION_TYPE_COM: - dest = dest_defined--; - dest->name = string_ptr; - dest->the_bfd = abfd; - - dest->section = (asection *)NULL; - dest->flags = BSF_FORT_COMM; - break; - default: - dest = dest_defined--; - BFD_ASSERT(0); - break; - } - dest->name = string_ptr; - dest->the_bfd = abfd; - dest->udata = (PTR)NULL; - dest->value = bfd_h_get_32(abfd, (bfd_byte *)&record.symbol.value[0]); - -#ifdef UNDERSCORE_HACK - if (record.symbol.name[0] != '_') { - string_ptr[0] = '_'; - string_ptr++; - } -#endif - memcpy(string_ptr, record.symbol.name, length); - - - string_ptr[length] =0; - string_ptr += length +1; - } - break; - default: - loop = false; - } - } - return true; -} - -static unsigned int -DEFUN(oasys_get_symtab_upper_bound,(abfd), - bfd *CONST abfd) -{ - oasys_slurp_symbol_table (abfd); - - return (abfd->symcount+1) * (sizeof (oasys_symbol_type *)); -} - -/* -*/ - -extern bfd_target oasys_vec; - -unsigned int -DEFUN(oasys_get_symtab,(abfd, location), - bfd *abfd AND - asymbol **location) -{ - asymbol *symbase ; - unsigned int counter ; - if (oasys_slurp_symbol_table(abfd) == false) { - return 0; - } - symbase = oasys_data(abfd)->symbols; - for (counter = 0; counter < abfd->symcount; counter++) { - *(location++) = symbase++; - } - *location = 0; - return abfd->symcount; -} - -/*********************************************************************** -* archive stuff -*/ - -static bfd_target * -DEFUN(oasys_archive_p,(abfd), - bfd *abfd) -{ - oasys_archive_header_type header; - oasys_extarchive_header_type header_ext; - unsigned int i; - file_ptr filepos; - bfd_seek(abfd, (file_ptr) 0, false); - - - bfd_read((PTR)&header_ext, 1, sizeof(header_ext), abfd); - - - header.version = bfd_h_get_32(abfd, (bfd_byte *)header_ext.version); - header.mod_count = bfd_h_get_32(abfd, (bfd_byte *)header_ext.mod_count); - header.mod_tbl_offset = bfd_h_get_32(abfd, (bfd_byte *)header_ext.mod_tbl_offset); - header.sym_tbl_size = bfd_h_get_32(abfd, (bfd_byte *)header_ext.sym_tbl_size); - header.sym_count = bfd_h_get_32(abfd, (bfd_byte *)header_ext.sym_count); - header.sym_tbl_offset = bfd_h_get_32(abfd, (bfd_byte *)header_ext.sym_tbl_offset); - header.xref_count = bfd_h_get_32(abfd, (bfd_byte *)header_ext.xref_count); - header.xref_lst_offset = bfd_h_get_32(abfd, (bfd_byte *)header_ext.xref_lst_offset); - - /* - There isn't a magic number in an Oasys archive, so the best we - can do to verify reasnableness is to make sure that the values in - the header are too weird - */ - - if (header.version>10000 || - header.mod_count>10000 || - header.sym_count>100000 || - header.xref_count > 100000) return (bfd_target *)NULL; - - /* - That all worked, lets buy the space for the header and read in - the headers. - */ - { - oasys_ar_data_type *ar = - (oasys_ar_data_type*) bfd_alloc(abfd, sizeof(oasys_ar_data_type)); - - - oasys_module_info_type *module = - (oasys_module_info_type*) - bfd_alloc(abfd, sizeof(oasys_module_info_type) * header.mod_count); - - - oasys_module_table_type record; - - - set_tdata(abfd, ar); - ar->module = module; - ar->module_count = header.mod_count; - - - filepos = header.mod_tbl_offset; - for (i = 0; i < header.mod_count; i++) { - bfd_seek(abfd , filepos, SEEK_SET); - - /* There are two ways of specifying the archive header */ - - if (0) { - oasys_extmodule_table_type_a_type record_ext; - bfd_read((PTR)&record_ext, 1, sizeof(record_ext), abfd); - - record.mod_size = bfd_h_get_32(abfd, (bfd_byte *)record_ext.mod_size); - record.file_offset = bfd_h_get_32(abfd, - (bfd_byte *) record_ext.file_offset); - - record.dep_count = bfd_h_get_32(abfd, (bfd_byte *)record_ext.dep_count); - record.depee_count = bfd_h_get_32(abfd,(bfd_byte *) record_ext.depee_count); - record.sect_count = bfd_h_get_32(abfd, (bfd_byte *) record_ext.sect_count); - - - module[i].name = bfd_alloc(abfd,33); - - memcpy(module[i].name, record_ext.mod_name, 33); - filepos += - sizeof(record_ext) + - record.dep_count * 4 + - record.depee_count * 4 + - record.sect_count * 8 + 187; - } - else { - oasys_extmodule_table_type_b_type record_ext; - bfd_read((PTR)&record_ext, 1, sizeof(record_ext), abfd); - - record.mod_size = bfd_h_get_32(abfd, (bfd_byte *) record_ext.mod_size); - record.file_offset = bfd_h_get_32(abfd, - (bfd_byte *)record_ext.file_offset); - - record.dep_count = bfd_h_get_32(abfd, (bfd_byte *) record_ext.dep_count); - record.depee_count = bfd_h_get_32(abfd, (bfd_byte *) record_ext.depee_count); - record.sect_count = bfd_h_get_32(abfd, (bfd_byte *) record_ext.sect_count); - record.module_name_size = bfd_h_get_32(abfd, (bfd_byte *) record_ext.mod_name_length); - - module[i].name = bfd_alloc(abfd,record.module_name_size + 1); - bfd_read((PTR)module[i].name, 1, record.module_name_size, abfd); - module[i].name[record.module_name_size] = 0; - filepos += - sizeof(record_ext) + - record.dep_count * 4 + - record.module_name_size + 1; - - } - - - module[i].size = record.mod_size; - module[i].pos = record.file_offset; - module[i].abfd = 0; - } - - } - return abfd->xvec; -} - -static boolean -DEFUN(oasys_mkobject,(abfd), - bfd *abfd) -{ - - set_tdata (abfd, - (oasys_data_type*)bfd_alloc(abfd, sizeof(oasys_data_type))); - return true; -} - -#define MAX_SECS 16 -static bfd_target * -DEFUN(oasys_object_p,(abfd), - bfd *abfd) -{ - oasys_data_type *oasys; - oasys_data_type *save = oasys_data(abfd); - boolean loop = true; - boolean had_usefull = false; - - set_tdata (abfd, 0); - oasys_mkobject(abfd); - oasys = oasys_data(abfd); - memset((PTR)oasys->sections, 0xff, sizeof(oasys->sections)); - - /* Point to the start of the file */ - bfd_seek(abfd, (file_ptr)0, SEEK_SET); - oasys->symbol_string_length = 0; - /* Inspect the records, but only keep the section info - - remember the size of the symbols - */ - oasys->first_data_record = 0; - while (loop) { - oasys_record_union_type record; - oasys_read_record(abfd, &record); - if ((size_t)record.header.length < (size_t)sizeof(record.header)) - goto fail; - - - switch ((oasys_record_enum_type)(record.header.type)) { - case oasys_record_is_header_enum: - had_usefull = true; - break; - case oasys_record_is_symbol_enum: - case oasys_record_is_local_enum: - /* Count symbols and remember their size for a future malloc */ - abfd->symcount++; - oasys->symbol_string_length += 1 + oasys_string_length(&record); - had_usefull = true; - break; - case oasys_record_is_section_enum: - { - asection *s; - char *buffer; - unsigned int section_number; - if (record.section.header.length != sizeof(record.section)) - { - goto fail; - } - buffer = bfd_alloc(abfd, 3); - section_number= record.section.relb & RELOCATION_SECT_BITS; - sprintf(buffer,"%u", section_number); - s = bfd_make_section(abfd,buffer); - oasys->sections[section_number] = s; - switch (record.section.relb & RELOCATION_TYPE_BITS) { - case RELOCATION_TYPE_ABS: - case RELOCATION_TYPE_REL: - break; - case RELOCATION_TYPE_UND: - case RELOCATION_TYPE_COM: - BFD_FAIL(); - } - - s->size = bfd_h_get_32(abfd, (bfd_byte *) & record.section.value[0]) ; - s->vma = bfd_h_get_32(abfd, (bfd_byte *)&record.section.vma[0]); - s->flags= 0; - had_usefull = true; - } - break; - case oasys_record_is_data_enum: - oasys->first_data_record = bfd_tell(abfd) - record.header.length; - case oasys_record_is_debug_enum: - case oasys_record_is_module_enum: - case oasys_record_is_named_section_enum: - case oasys_record_is_end_enum: - if (had_usefull == false) goto fail; - loop = false; - break; - default: - goto fail; - } - } - oasys->symbols = (asymbol *)NULL; - /* - Oasys support several architectures, but I can't see a simple way - to discover which one is in a particular file - we'll guess - */ - abfd->obj_arch = bfd_arch_m68k; - abfd->obj_machine =0; - if (abfd->symcount != 0) { - abfd->flags |= HAS_SYMS; - } - - /* - We don't know if a section has data until we've read it.. - */ - - oasys_slurp_section_data(abfd); - - - return abfd->xvec; - - fail: - (void) bfd_release(abfd, oasys); - set_tdata (abfd, save); - return (bfd_target *)NULL; -} - - -static void -DEFUN(oasys_print_symbol,(ignore_abfd, afile, symbol, how), - bfd *ignore_abfd AND - PTR afile AND - asymbol *symbol AND - bfd_print_symbol_enum_type how) -{ - FILE *file = (FILE *)afile; - - switch (how) { - case bfd_print_symbol_name_enum: - case bfd_print_symbol_type_enum: - fprintf(file,"%s", symbol->name); - break; - case bfd_print_symbol_all_enum: - { -CONST char *section_name = symbol->section == (asection *)NULL ? - "*abs" : symbol->section->name; - - bfd_print_symbol_vandf((PTR)file,symbol); - - fprintf(file," %-5s %s", - section_name, - symbol->name); - } - break; - } -} -/* - The howto table is build using the top two bits of a reloc byte to - index into it. The bits are PCREL,WORD/LONG -*/ -static reloc_howto_type howto_table[]= -{ - -HOWTO( 0, 0, 1, 16, false,0, true,true,0,"abs16",true,0x0000ffff, 0x0000ffff,false), -HOWTO( 0, 0, 2, 32, false,0, true,true,0,"abs32",true,0xffffffff, 0xffffffff,false), -HOWTO( 0, 0, 1, 16, true,0, true,true,0,"pcrel16",true,0x0000ffff, 0x0000ffff,false), -HOWTO( 0, 0, 2, 32, true,0, true,true,0,"pcrel32",true,0xffffffff, 0xffffffff,false) -}; - -/* Read in all the section data and relocation stuff too */ -static boolean -DEFUN(oasys_slurp_section_data,(abfd), - bfd *CONST abfd) -{ - oasys_record_union_type record; - oasys_data_type *data = oasys_data(abfd); - boolean loop = true; - - oasys_per_section_type *per ; - - asection *s; - - /* See if the data has been slurped already .. */ - for (s = abfd->sections; s != (asection *)NULL; s= s->next) { - per = oasys_per_section(s); - if (per->initialized == true) - return true; - } - - if (data->first_data_record == 0) return true; - - bfd_seek(abfd, data->first_data_record, SEEK_SET); - while (loop) { - oasys_read_record(abfd, &record); - switch (record.header.type) - { - case oasys_record_is_header_enum: - break; - case oasys_record_is_data_enum: - { - - uint8e_type *src = record.data.data; - uint8e_type *end_src = ((uint8e_type *)&record) + - record.header.length; - unsigned int relbit; - bfd_byte *dst_ptr ; - bfd_byte *dst_base_ptr ; - unsigned int count; - asection * section = - data->sections[record.data.relb & RELOCATION_SECT_BITS]; - bfd_vma dst_offset ; - per = oasys_per_section(section); - - - if (per->initialized == false) - { - per->data = (bfd_byte *) bfd_zalloc(abfd, section->size); - per->reloc_tail_ptr = (oasys_reloc_type **)&(section->relocation); - per->had_vma = false; - per->initialized = true; - section->reloc_count = 0; - section->flags = SEC_ALLOC; - } - - dst_offset = bfd_h_get_32(abfd, record.data.addr) ; - if (per->had_vma == false) { - /* Take the first vma we see as the base */ - - section->vma = dst_offset; - per->had_vma = true; - } - - - dst_offset -= section->vma; - - - dst_base_ptr = oasys_per_section(section)->data; - dst_ptr = oasys_per_section(section)->data + - dst_offset; - - if (src < end_src) { - section->flags |= SEC_LOAD | SEC_HAS_CONTENTS; - } - while (src < end_src) { - uint8e_type mod_byte = *src++; - uint32_type gap = end_src - src; - - count = 8; - if (mod_byte == 0 && gap >= 8) { - dst_ptr[0] = src[0]; - dst_ptr[1] = src[1]; - dst_ptr[2] = src[2]; - dst_ptr[3] = src[3]; - dst_ptr[4] = src[4]; - dst_ptr[5] = src[5]; - dst_ptr[6] = src[6]; - dst_ptr[7] = src[7]; - dst_ptr+= 8; - src += 8; - } - else { - for (relbit = 1; count-- != 0 && src < end_src; relbit <<=1) - { - if (relbit & mod_byte) - { - uint8e_type reloc = *src; - /* This item needs to be relocated */ - switch (reloc & RELOCATION_TYPE_BITS) { - case RELOCATION_TYPE_ABS: - - break; - - case RELOCATION_TYPE_REL: - { - /* Relocate the item relative to the section */ - oasys_reloc_type *r = - (oasys_reloc_type *) - bfd_alloc(abfd, - sizeof(oasys_reloc_type)); - *(per->reloc_tail_ptr) = r; - per->reloc_tail_ptr = &r->next; - r->next= (oasys_reloc_type *)NULL; - /* Reference to undefined symbol */ - src++; - /* There is no symbol */ - r->symbol = 0; - /* Work out the howto */ - r->relent.section = - data->sections[reloc & RELOCATION_SECT_BITS]; - r->relent.addend = - r->relent.section->vma; - r->relent.address = dst_ptr - dst_base_ptr; - r->relent.howto = &howto_table[reloc>>6]; - r->relent.sym_ptr_ptr = (asymbol **)NULL; - section->reloc_count++; - - /* Fake up the data to look like it's got the -ve pc in it, this makes - it much easier to convert into other formats. This is done by - hitting the addend. - */ - if (r->relent.howto->pc_relative == true) { - r->relent.addend -= dst_ptr - dst_base_ptr; - } - - - } - break; - - - case RELOCATION_TYPE_UND: - { - oasys_reloc_type *r = - (oasys_reloc_type *) - bfd_alloc(abfd, - sizeof(oasys_reloc_type)); - *(per->reloc_tail_ptr) = r; - per->reloc_tail_ptr = &r->next; - r->next= (oasys_reloc_type *)NULL; - /* Reference to undefined symbol */ - src++; - /* Get symbol number */ - r->symbol = (src[0]<<8) | src[1]; - /* Work out the howto */ - r->relent.section = (asection *)NULL; - r->relent.addend = 0; - r->relent.address = dst_ptr - dst_base_ptr; - r->relent.howto = &howto_table[reloc>>6]; - r->relent.sym_ptr_ptr = (asymbol **)NULL; - section->reloc_count++; - - src+=2; - /* Fake up the data to look like it's got the -ve pc in it, this makes - it much easier to convert into other formats. This is done by - hitting the addend. - */ - if (r->relent.howto->pc_relative == true) { - r->relent.addend -= dst_ptr - dst_base_ptr; - } - - - - } - break; - case RELOCATION_TYPE_COM: - BFD_FAIL(); - } - } - *dst_ptr++ = *src++; - } - } - } - } - break; - case oasys_record_is_local_enum: - case oasys_record_is_symbol_enum: - case oasys_record_is_section_enum: - break; - default: - loop = false; - } - } - - return true; - -} - - - -bfd_error_vector_type bfd_error_vector; - -static boolean -DEFUN(oasys_new_section_hook,(abfd, newsect), - bfd *abfd AND - asection *newsect) -{ - newsect->used_by_bfd = (PTR) - bfd_alloc(abfd, sizeof(oasys_per_section_type)); - oasys_per_section( newsect)->data = (bfd_byte *)NULL; - oasys_per_section(newsect)->section = newsect; - oasys_per_section(newsect)->offset = 0; - oasys_per_section(newsect)->initialized = false; - newsect->alignment_power = 1; - /* Turn the section string into an index */ - - sscanf(newsect->name,"%u", &newsect->target_index); - - return true; -} - - -static unsigned int -DEFUN(oasys_get_reloc_upper_bound, (abfd, asect), - bfd *abfd AND - sec_ptr asect) -{ - oasys_slurp_section_data(abfd); - return (asect->reloc_count+1) * sizeof(arelent *); -} - -static boolean -DEFUN(oasys_get_section_contents,(abfd, section, location, offset, count), - bfd *abfd AND - sec_ptr section AND - PTR location AND - file_ptr offset AND - bfd_size_type count) -{ - oasys_per_section_type *p = (oasys_per_section_type *) section->used_by_bfd; - oasys_slurp_section_data(abfd); - if (p->initialized == false) - { - (void) memset(location, 0, (int)count); - } - else - { - (void) memcpy(location,(PTR)( p->data + offset), (int)count); - } - return true; -} - - -unsigned int -DEFUN(oasys_canonicalize_reloc,(ignore_abfd, section, relptr, symbols), - bfd *ignore_abfd AND - sec_ptr section AND - arelent **relptr AND - asymbol **symbols) -{ - unsigned int reloc_count = 0; - oasys_reloc_type *src = (oasys_reloc_type *)(section->relocation); - while (src != (oasys_reloc_type *)NULL) { - if (src->relent.section == (asection *)NULL) - { - src->relent.sym_ptr_ptr = symbols + src->symbol; - } - *relptr ++ = &src->relent; - src = src->next; - reloc_count++; - } - *relptr = (arelent *)NULL; - return section->reloc_count = reloc_count; -} - - -boolean -DEFUN(oasys_set_arch_mach, (abfd, arch, machine), - bfd *abfd AND - enum bfd_architecture arch AND - unsigned long machine) -{ - abfd->obj_arch = arch; - abfd->obj_machine = machine; - return true; -} - - - -/* Writing */ - - -/* Calculate the checksum and write one record */ -static void -DEFUN(oasys_write_record,(abfd, type, record, size), - bfd *CONST abfd AND - CONST oasys_record_enum_type type AND - oasys_record_union_type *record AND - CONST size_t size) -{ - int checksum; - size_t i; - uint8e_type *ptr; - record->header.length = size; - record->header.type = type; - record->header.check_sum = 0; - record->header.fill = 0; - ptr = &record->pad[0]; - checksum = 0; - for (i = 0; i < size; i++) { - checksum += *ptr++; - } - record->header.check_sum = 0xff & (- checksum); - bfd_write((PTR)record, 1, size, abfd); -} - - -/* Write out all the symbols */ -static void -DEFUN(oasys_write_syms, (abfd), - bfd * CONST abfd) -{ - unsigned int count; - asymbol **generic = bfd_get_outsymbols(abfd); - unsigned int index = 0; - for (count = 0; count < bfd_get_symcount(abfd); count++) { - - oasys_symbol_record_type symbol; - asymbol * CONST g = generic[count]; - - CONST char *src = g->name; - char *dst = symbol.name; - unsigned int l = 0; - - if (g->flags & BSF_FORT_COMM) { - symbol.relb = RELOCATION_TYPE_COM; - bfd_h_put_16(abfd, index, (uint8e_type *)(&symbol.refno[0])); - index++; - } - else if (g->flags & BSF_ABSOLUTE) { - symbol.relb = RELOCATION_TYPE_ABS; - bfd_h_put_16(abfd, 0, (uint8e_type *)(&symbol.refno[0])); - - } - else if (g->flags & BSF_UNDEFINED) { - symbol.relb = RELOCATION_TYPE_UND ; - bfd_h_put_16(abfd, index, (uint8e_type *)(&symbol.refno[0])); - /* Overload the value field with the output index number */ - index++; - } - else if (g->flags & BSF_DEBUGGING) { - /* throw it away */ - continue; - } - else { - if (g->section == (asection *)NULL) { - /* Sometime, the oasys tools give out a symbol with illegal - bits in it, we'll output it in the same broken way */ - - symbol.relb = RELOCATION_TYPE_REL | 0; - } - else { - symbol.relb = RELOCATION_TYPE_REL |g->section->output_section->target_index; - } - bfd_h_put_16(abfd, 0, (uint8e_type *)(&symbol.refno[0])); - } - while (src[l]) { - dst[l] = src[l]; - l++; - } - - bfd_h_put_32(abfd, g->value, (bfd_byte*) symbol.value); - - - if (g->flags & BSF_LOCAL) { - oasys_write_record(abfd, - oasys_record_is_local_enum, - (oasys_record_union_type *) &symbol, - offsetof(oasys_symbol_record_type, name[0]) + l); - } - else { - oasys_write_record(abfd, - oasys_record_is_symbol_enum, - (oasys_record_union_type *) &symbol, - offsetof(oasys_symbol_record_type, name[0]) + l); - } - g->value = index-1; - } -} - - - /* Write a section header for each section */ -static void -DEFUN(oasys_write_sections, (abfd), - bfd *CONST abfd) -{ - asection *s; - static oasys_section_record_type out = {0}; - - for (s = abfd->sections; s != (asection *)NULL; s = s->next) { - if (!isdigit(s->name[0])) - { - bfd_error_vector.nonrepresentable_section(abfd, - s->name); - } - out.relb = RELOCATION_TYPE_REL | s->target_index; - bfd_h_put_32(abfd, s->size, (bfd_byte *) out.value); - bfd_h_put_32(abfd, s->vma, (bfd_byte *) out.vma); - - oasys_write_record(abfd, - oasys_record_is_section_enum, - (oasys_record_union_type *) &out, - sizeof(out)); - } -} - -static void -DEFUN(oasys_write_header, (abfd), - bfd *CONST abfd) -{ - /* Create and write the header */ - oasys_header_record_type r; - size_t length = strlen(abfd->filename); - if (length > (size_t)sizeof(r.module_name)) { - length = sizeof(r.module_name); - } - - (void)memcpy(r.module_name, - abfd->filename, - length); - (void)memset(r.module_name + length, - ' ', - sizeof(r.module_name) - length); - - r.version_number = OASYS_VERSION_NUMBER; - r.rev_number = OASYS_REV_NUMBER; - oasys_write_record(abfd, - oasys_record_is_header_enum, - (oasys_record_union_type *)&r, - offsetof(oasys_header_record_type, description[0])); - - - -} - -static void -DEFUN(oasys_write_end,(abfd), - bfd *CONST abfd) -{ - oasys_end_record_type end; - uint8e_type null = 0; - end.relb = RELOCATION_TYPE_ABS; - bfd_h_put_32(abfd, abfd->start_address, (bfd_byte *)end.entry); - bfd_h_put_16(abfd, 0, (bfd_byte *)end.fill); - end.zero =0; - oasys_write_record(abfd, - oasys_record_is_end_enum, - (oasys_record_union_type *)&end, - sizeof(end)); - bfd_write((PTR)&null, 1, 1, abfd); -} - -static int -DEFUN(comp,(ap, bp), - CONST PTR ap AND - CONST PTR bp) -{ - arelent *a = *((arelent **)ap); - arelent *b = *((arelent **)bp); - return a->address - b->address; -} - -/* - Writing data.. - -*/ -static void -DEFUN(oasys_write_data, (abfd), - bfd *CONST abfd) -{ - asection *s; - for (s = abfd->sections; s != (asection *)NULL; s = s->next) { - if (s->flags & SEC_LOAD) { - uint8e_type *raw_data = oasys_per_section(s)->data; - oasys_data_record_type processed_data; - bfd_size_type current_byte_index = 0; - unsigned int relocs_to_go = s->reloc_count; - arelent **p = s->orelocation; - if (s->reloc_count != 0) { - /* Sort the reloc records so it's easy to insert the relocs into the - data */ - - qsort(s->orelocation, - s->reloc_count, - sizeof(arelent **), - comp); - } - current_byte_index = 0; - processed_data.relb = s->target_index | RELOCATION_TYPE_REL; - - while (current_byte_index < s->size) - { - /* Scan forwards by eight bytes or however much is left and see if - there are any relocations going on */ - uint8e_type *mod = &processed_data.data[0]; - uint8e_type *dst = &processed_data.data[1]; - - unsigned int i; - unsigned int long_length = 128; - - - bfd_h_put_32(abfd, s->vma + current_byte_index, processed_data.addr); - if ((size_t)(long_length + current_byte_index) > (size_t)(s->size)) { - long_length = s->size - current_byte_index; - } - while (long_length > 0 && (dst - (uint8e_type*)&processed_data < 128)) { - - unsigned int length = long_length; - *mod =0; - if (length > 8) - length = 8; - - for (i = 0; i < length; i++) { - if (relocs_to_go != 0) { - arelent *r = *p; - reloc_howto_type *CONST how=r->howto; - /* There is a relocation, is it for this byte ? */ - if (r->address == current_byte_index) { - uint8e_type rel_byte; - p++; - relocs_to_go--; - - *mod |= (1<pc_relative) { - rel_byte = 0x80; - - /* Also patch the raw data so that it doesn't have - the -ve stuff any more */ - if (how->size != 2) { - bfd_put_16(abfd, - bfd_get_16(abfd,raw_data) + - current_byte_index, raw_data); - } - - else { - bfd_put_32(abfd, - bfd_get_32(abfd,raw_data) + - current_byte_index, raw_data); - } - } - else { - rel_byte = 0; - } - if (how->size ==2) { - rel_byte |= 0x40; - } - - /* Is this a section relative relocation, or a symbol - relative relocation ? */ - if (r->section != (asection*)NULL) - { - /* The relent has a section attached, so it must be section - relative */ - rel_byte |= RELOCATION_TYPE_REL; - rel_byte |= r->section->output_section->target_index; - *dst++ = rel_byte; - } - else - { - asymbol *p = *(r->sym_ptr_ptr); - - /* If this symbol has a section attached, then it - has already been resolved. Change from a symbol - ref to a section ref */ - if(p->section != (asection *)NULL) { - rel_byte |= RELOCATION_TYPE_REL; - rel_byte |= - p->section->output_section->target_index; - *dst++ = rel_byte; - } - else { - rel_byte |= RELOCATION_TYPE_UND; - - - *dst++ = rel_byte; - /* Next two bytes are a symbol index - we can get - this from the symbol value which has been zapped - into the symbol index in the table when the - symbol table was written - */ - *dst++ = p->value >> 8; - *dst++ = p->value; - } - - } - } - } - /* If this is coming from an unloadable section then copy - zeros */ - if (raw_data == (uint8e_type *)NULL) { - *dst++ = 0; - } - else { - *dst++ = *raw_data++; - } - current_byte_index++; - } - mod = dst++; - long_length -= length; - } - - oasys_write_record(abfd, - oasys_record_is_data_enum, - (oasys_record_union_type *)&processed_data, - dst - (uint8e_type*)&processed_data); - - } - } - } -} -static boolean -DEFUN(oasys_write_object_contents, (abfd), - bfd * CONST abfd) -{ - oasys_write_header(abfd); - oasys_write_syms(abfd); - oasys_write_sections(abfd); - oasys_write_data(abfd); - oasys_write_end(abfd); - return true; -} - - - - -/** exec and core file sections */ - -/* set section contents is complicated with OASYS since the format is -* not a byte image, but a record stream. -*/ -static boolean -DEFUN(oasys_set_section_contents,(abfd, section, location, offset, count), - bfd *abfd AND - sec_ptr section AND - PTR location AND - file_ptr offset AND - bfd_size_type count) -{ - if (count != 0) { - if (oasys_per_section(section)->data == (bfd_byte *)NULL ) - { - oasys_per_section(section)->data = - (bfd_byte *)(bfd_alloc(abfd,section->size)); - } - (void) memcpy((PTR)(oasys_per_section(section)->data + offset), - location, - count); - } - return true; -} - - - -/* Native-level interface to symbols. */ - -/* We read the symbols into a buffer, which is discarded when this -function exits. We read the strings into a buffer large enough to -hold them all plus all the cached symbol entries. */ - -static asymbol * -DEFUN(oasys_make_empty_symbol,(abfd), - bfd *abfd) -{ - - oasys_symbol_type *new = - (oasys_symbol_type *)bfd_zalloc (abfd, sizeof (oasys_symbol_type)); - new->symbol.the_bfd = abfd; - return &new->symbol; - -} - - - - -/* User should have checked the file flags; perhaps we should return -BFD_NO_MORE_SYMBOLS if there are none? */ - -static bfd * -oasys_openr_next_archived_file(arch, prev) -bfd *arch; -bfd *prev; -{ - oasys_ar_data_type *ar = oasys_ar_data(arch); - oasys_module_info_type *p; - /* take the next one from the arch state, or reset */ - if (prev == (bfd *)NULL) { - /* Reset the index - the first two entries are bogus*/ - ar->module_index = 0; - } - - p = ar->module + ar->module_index; - ar->module_index++; - - if (ar->module_index <= ar->module_count) { - if (p->abfd == (bfd *)NULL) { - p->abfd = _bfd_create_empty_archive_element_shell(arch); - p->abfd->origin = p->pos; - p->abfd->filename = p->name; - - /* Fixup a pointer to this element for the member */ - p->abfd->arelt_data = (PTR)p; - } - return p->abfd; - } - else { - bfd_error = no_more_archived_files; - return (bfd *)NULL; - } -} - -static boolean -oasys_find_nearest_line(abfd, - section, - symbols, - offset, - filename_ptr, - functionname_ptr, - line_ptr) -bfd *abfd; -asection *section; -asymbol **symbols; -bfd_vma offset; -char **filename_ptr; -char **functionname_ptr; -unsigned int *line_ptr; -{ - return false; - -} - -static int -DEFUN(oasys_generic_stat_arch_elt,(abfd, buf), - bfd *abfd AND - struct stat *buf) -{ - oasys_module_info_type *mod = (oasys_module_info_type *) abfd->arelt_data; - if (mod == (oasys_module_info_type *)NULL) { - bfd_error = invalid_operation; - return -1; - } - else { - buf->st_size = mod->size; - buf->st_mode = 0666; - return 0; - } -} - -static int -DEFUN(oasys_sizeof_headers,(abfd, exec), - bfd *abfd AND - boolean exec) -{ -return 0; -} -#define FOO PROTO -#define oasys_core_file_failing_command (char *(*)())(bfd_nullvoidptr) -#define oasys_core_file_failing_signal (int (*)())bfd_0 -#define oasys_core_file_matches_executable_p 0 -#define oasys_slurp_armap bfd_true -#define oasys_slurp_extended_name_table bfd_true -#define oasys_truncate_arname (void (*)())bfd_nullvoidptr -#define oasys_write_armap 0 -#define oasys_get_lineno (struct lineno_cache_entry *(*)())bfd_nullvoidptr -#define oasys_close_and_cleanup bfd_generic_close_and_cleanup - -#define oasys_bfd_debug_info_start bfd_void -#define oasys_bfd_debug_info_end bfd_void -#define oasys_bfd_debug_info_accumulate (FOO(void, (*), (bfd *, asection *)))bfd_void - - -/*SUPPRESS 460 */ -bfd_target oasys_vec = -{ - "oasys", /* name */ - bfd_target_oasys_flavour_enum, - true, /* target byte order */ - true, /* target headers byte order */ - (HAS_RELOC | EXEC_P | /* object flags */ - HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED), - (SEC_CODE|SEC_DATA|SEC_ROM|SEC_HAS_CONTENTS - |SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ - ' ', /* ar_pad_char */ - 16, /* ar_max_namelen */ - 1, /* minimum alignment */ - _do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* data */ - _do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* hdrs */ - - {_bfd_dummy_target, - oasys_object_p, /* bfd_check_format */ - oasys_archive_p, - _bfd_dummy_target, - }, - { /* bfd_set_format */ - bfd_false, - oasys_mkobject, - _bfd_generic_mkarchive, - bfd_false - }, - { /* bfd_write_contents */ - bfd_false, - oasys_write_object_contents, - _bfd_write_archive_contents, - bfd_false, - }, - JUMP_TABLE(oasys) -}; diff --git a/bfd/obstack.c b/bfd/obstack.c deleted file mode 100755 index bbed70b66f2..00000000000 --- a/bfd/obstack.c +++ /dev/null @@ -1,330 +0,0 @@ -/* obstack.c - subroutines used implicitly by object stack macros - Copyright (C) 1988 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 1, 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, 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include -#include -#include "obstack.h" - - -/* Determine default alignment. */ -struct fooalign {char x; double d;}; -#define DEFAULT_ALIGNMENT ((char *)&((struct fooalign *) 0)->d - (char *)0) -/* If malloc were really smart, it would round addresses to DEFAULT_ALIGNMENT. - But in fact it might be less smart and round addresses to as much as - DEFAULT_ROUNDING. So we prepare for it to do that. */ -union fooround {long x; double d;}; -#define DEFAULT_ROUNDING (sizeof (union fooround)) - -/* When we copy a long block of data, this is the unit to do it with. - On some machines, copying successive ints does not work; - in such a case, redefine COPYING_UNIT to `long' (if that works) - or `char' as a last resort. */ -#ifndef COPYING_UNIT -#define COPYING_UNIT int -#endif - -/* The non-GNU-C macros copy the obstack into this global variable - to avoid multiple evaluation. */ - -struct obstack *_obstack; - -/* Initialize an obstack H for use. Specify chunk size SIZE (0 means default). - Objects start on multiples of ALIGNMENT (0 means use default). - CHUNKFUN is the function to use to allocate chunks, - and FREEFUN the function to free them. */ - -void DEFUN(_obstack_begin,(h, size, alignment, chunkfun, freefun), - struct obstack *h AND - int size AND - int alignment AND - PTR (*chunkfun) () AND - void (*freefun) ()) -{ - register struct _obstack_chunk* chunk; /* points to new chunk */ - - if (alignment == 0) - alignment = DEFAULT_ALIGNMENT; - if (size == 0) - /* Default size is what GNU malloc can fit in a 4096-byte block. */ - { - /* 12 is sizeof (mhead) and 4 is EXTRA from GNU malloc. - Use the values for range checking, because if range checking is off, - the extra bytes won't be missed terribly, but if range checking is on - and we used a larger request, a whole extra 4096 bytes would be - allocated. - - These number are irrelevant to the new GNU malloc. I suspect it is - less sensitive to the size of the request. */ - int extra = ((((12 + DEFAULT_ROUNDING - 1) & ~(DEFAULT_ROUNDING - 1)) - + 4 + DEFAULT_ROUNDING - 1) - & ~(DEFAULT_ROUNDING - 1)); - size = 4096 - extra; - } - - h->chunkfun = chunkfun; - h->freefun = freefun; - h->chunk_size = size; - h->alignment_mask = alignment - 1; - - chunk = h->chunk = (struct _obstack_chunk *)(*h->chunkfun) (h->chunk_size); - h->next_free = h->object_base = chunk->contents; - h->chunk_limit = chunk->limit - = (char *) chunk + h->chunk_size; - chunk->prev = 0; -} - -/* Allocate a new current chunk for the obstack *H - on the assumption that LENGTH bytes need to be added - to the current object, or a new object of length LENGTH allocated. - Copies any partial object from the end of the old chunk - to the beginning of the new one. - - The function must be "int" so it can be used in non-ANSI C - compilers in a : expression. */ - -int -DEFUN(_obstack_newchunk,(h, length), - struct obstack *h AND - int length) -{ - register struct _obstack_chunk* old_chunk = h->chunk; - register struct _obstack_chunk* new_chunk; - register long new_size; - register int obj_size = h->next_free - h->object_base; - register int i; - int already; - - /* Compute size for new chunk. */ - new_size = (obj_size + length) + (obj_size >> 3) + 100; - if (new_size < h->chunk_size) - new_size = h->chunk_size; - - /* Allocate and initialize the new chunk. */ - new_chunk = h->chunk = (struct _obstack_chunk *)(*h->chunkfun) (new_size); - new_chunk->prev = old_chunk; - new_chunk->limit = h->chunk_limit = (char *) new_chunk + new_size; - - /* Move the existing object to the new chunk. - Word at a time is fast and is safe if the object - is sufficiently aligned. */ - if (h->alignment_mask + 1 >= DEFAULT_ALIGNMENT) - { - for (i = obj_size / sizeof (COPYING_UNIT) - 1; - i >= 0; i--) - ((COPYING_UNIT *)new_chunk->contents)[i] - = ((COPYING_UNIT *)h->object_base)[i]; - /* We used to copy the odd few remaining bytes as one extra COPYING_UNIT, - but that can cross a page boundary on a machine - which does not do strict alignment for COPYING_UNITS. */ - already = obj_size / sizeof (COPYING_UNIT) * sizeof (COPYING_UNIT); - } - else - already = 0; - /* Copy remaining bytes one by one. */ - for (i = already; i < obj_size; i++) - new_chunk->contents[i] = h->object_base[i]; - - h->object_base = new_chunk->contents; - h->next_free = h->object_base + obj_size; -return 0; -} - -/* Return nonzero if object OBJ has been allocated from obstack H. - This is here for debugging. - If you use it in a program, you are probably losing. */ - -int -DEFUN(_obstack_allocated_p, (h, obj), - struct obstack *h AND - PTR obj) -{ - register struct _obstack_chunk* lp; /* below addr of any objects in this chunk */ - register struct _obstack_chunk* plp; /* point to previous chunk if any */ - - lp = (h)->chunk; - while (lp != 0 && ((PTR)lp > obj || (PTR)(lp)->limit < obj)) - { - plp = lp -> prev; - lp = plp; - } - return lp != 0; -} - -/* Free objects in obstack H, including OBJ and everything allocate - more recently than OBJ. If OBJ is zero, free everything in H. */ - -#ifdef __STDC__ -#undef obstack_free -void -obstack_free (struct obstack *h, PTR obj) -#else -int -_obstack_free (h, obj) - struct obstack *h; - PTR obj; -#endif -{ - register struct _obstack_chunk* lp; /* below addr of any objects in this chunk */ - register struct _obstack_chunk* plp; /* point to previous chunk if any */ - - lp = (h)->chunk; - /* We use >= because there cannot be an object at the beginning of a chunk. - But there can be an empty object at that address - at the end of another chunk. */ - while (lp != 0 && ((PTR)lp >= obj || (PTR)(lp)->limit < obj)) - { - plp = lp -> prev; - (*h->freefun) ((PTR) lp); - lp = plp; - } - if (lp) - { - (h)->object_base = (h)->next_free = (char *)(obj); - (h)->chunk_limit = lp->limit; - (h)->chunk = lp; - } - else if (obj != 0) - /* obj is not in any of the chunks! */ - abort (); -} - -/* Let same .o link with output of gcc and other compilers. */ - -#ifdef __STDC__ -int -_obstack_free (h, obj) - struct obstack *h; - PTR obj; -{ - obstack_free (h, obj); - return 0; -} -#endif - -/* #if 0 */ -/* These are now turned off because the applications do not use it - and it uses bcopy via obstack_grow, which causes trouble on sysV. */ - -/* Now define the functional versions of the obstack macros. - Define them to simply use the corresponding macros to do the job. */ - -#ifdef __STDC__ -/* These function definitions do not work with non-ANSI preprocessors; - they won't pass through the macro names in parentheses. */ - -/* The function names appear in parentheses in order to prevent - the macro-definitions of the names from being expanded there. */ - -PTR (obstack_base) (obstack) - struct obstack *obstack; -{ - return obstack_base (obstack); -} - -PTR (obstack_next_free) (obstack) - struct obstack *obstack; -{ - return obstack_next_free (obstack); -} - -int (obstack_object_size) (obstack) - struct obstack *obstack; -{ - return obstack_object_size (obstack); -} - -int (obstack_room) (obstack) - struct obstack *obstack; -{ - return obstack_room (obstack); -} - -void (obstack_grow) (obstack, ptr, length) - struct obstack *obstack; - PTR ptr; - int length; -{ -(void) obstack_grow (obstack, ptr, length); -} - -void (obstack_grow0) (obstack, ptr, length) - struct obstack *obstack; - PTR ptr; - int length; -{ -(void) obstack_grow0 (obstack, ptr, length); -} - -void (obstack_1grow) (obstack, character) - struct obstack *obstack; - int character; -{ -(void) obstack_1grow (obstack, character); -} - -void (obstack_blank) (obstack, length) - struct obstack *obstack; - int length; -{ -(void) obstack_blank (obstack, length); -} - -void (obstack_1grow_fast) (obstack, character) - struct obstack *obstack; - int character; -{ - obstack_1grow_fast (obstack, character); -} - -void (obstack_blank_fast) (obstack, length) - struct obstack *obstack; - int length; -{ - obstack_blank_fast (obstack, length); -} - -PTR (obstack_finish) (obstack) - struct obstack *obstack; -{ - return obstack_finish (obstack); -} - -PTR (obstack_alloc) (obstack, length) - struct obstack *obstack; - int length; -{ - return obstack_alloc (obstack, length); -} - -PTR (obstack_copy) (obstack, ptr, length) - struct obstack *obstack; - PTR ptr; - int length; -{ - return obstack_copy (obstack, ptr, length); -} - -PTR (obstack_copy0) (obstack, ptr, length) - struct obstack *obstack; - PTR ptr; - int length; -{ - return obstack_copy0 (obstack, ptr, length); -} - -#endif /* __STDC__ */ - - diff --git a/bfd/obstack.h b/bfd/obstack.h deleted file mode 100755 index a4898ec1a0d..00000000000 --- a/bfd/obstack.h +++ /dev/null @@ -1,413 +0,0 @@ -/* obstack.h - object stack macros - Copyright (C) 1988 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 1, 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, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Summary: - -All the apparent functions defined here are macros. The idea -is that you would use these pre-tested macros to solve a -very specific set of problems, and they would run fast. -Caution: no side-effects in arguments please!! They may be -evaluated MANY times!! - -These macros operate a stack of objects. Each object starts life -small, and may grow to maturity. (Consider building a word syllable -by syllable.) An object can move while it is growing. Once it has -been "finished" it never changes address again. So the "top of the -stack" is typically an immature growing object, while the rest of the -stack is of mature, fixed size and fixed address objects. - -These routines grab large chunks of memory, using a function you -supply, called `obstack_chunk_alloc'. On occasion, they free chunks, -by calling `obstack_chunk_free'. You must define them and declare -them before using any obstack macros. - -Each independent stack is represented by a `struct obstack'. -Each of the obstack macros expects a pointer to such a structure -as the first argument. - -One motivation for this package is the problem of growing char strings -in symbol tables. Unless you are "fascist pig with a read-only mind" -[Gosper's immortal quote from HAKMEM item 154, out of context] you -would not like to put any arbitrary upper limit on the length of your -symbols. - -In practice this often means you will build many short symbols and a -few long symbols. At the time you are reading a symbol you don't know -how long it is. One traditional method is to read a symbol into a -buffer, realloc()ating the buffer every time you try to read a symbol -that is longer than the buffer. This is beaut, but you still will -want to copy the symbol from the buffer to a more permanent -symbol-table entry say about half the time. - -With obstacks, you can work differently. Use one obstack for all symbol -names. As you read a symbol, grow the name in the obstack gradually. -When the name is complete, finalize it. Then, if the symbol exists already, -free the newly read name. - -The way we do this is to take a large chunk, allocating memory from -low addresses. When you want to build a symbol in the chunk you just -add chars above the current "high water mark" in the chunk. When you -have finished adding chars, because you got to the end of the symbol, -you know how long the chars are, and you can create a new object. -Mostly the chars will not burst over the highest address of the chunk, -because you would typically expect a chunk to be (say) 100 times as -long as an average object. - -In case that isn't clear, when we have enough chars to make up -the object, THEY ARE ALREADY CONTIGUOUS IN THE CHUNK (guaranteed) -so we just point to it where it lies. No moving of chars is -needed and this is the second win: potentially long strings need -never be explicitly shuffled. Once an object is formed, it does not -change its address during its lifetime. - -When the chars burst over a chunk boundary, we allocate a larger -chunk, and then copy the partly formed object from the end of the old -chunk to the beginning of the new larger chunk. We then carry on -accreting characters to the end of the object as we normally would. - -A special macro is provided to add a single char at a time to a -growing object. This allows the use of register variables, which -break the ordinary 'growth' macro. - -Summary: - We allocate large chunks. - We carve out one object at a time from the current chunk. - Once carved, an object never moves. - We are free to append data of any size to the currently - growing object. - Exactly one object is growing in an obstack at any one time. - You can run one obstack per control block. - You may have as many control blocks as you dare. - Because of the way we do it, you can `unwind' a obstack - back to a previous state. (You may remove objects much - as you would with a stack.) -*/ - - -/* Don't do the contents of this file more than once. */ - -#ifndef __OBSTACKS__ -#define __OBSTACKS__ - -/* We use subtraction of (char *)0 instead of casting to int - because on word-addressable machines a simple cast to int - may ignore the byte-within-word field of the pointer. */ - -#ifndef __PTR_TO_INT -#define __PTR_TO_INT(P) ((P) - (char*)0) -#endif - -#ifndef __INT_TO_PTR -#define __INT_TO_PTR(P) ((P) + (char*)0) -#endif - -struct _obstack_chunk /* Lives at front of each chunk. */ -{ - char *limit; /* 1 past end of this chunk */ - struct _obstack_chunk *prev; /* address of prior chunk or NULL */ - char contents[4]; /* objects begin here */ -}; - -struct obstack /* control current object in current chunk */ -{ - long chunk_size; /* preferred size to allocate chunks in */ - struct _obstack_chunk* chunk; /* address of current struct obstack_chunk */ - char *object_base; /* address of object we are building */ - char *next_free; /* where to add next char to current object */ - char *chunk_limit; /* address of char after current chunk */ - int temp; /* Temporary for some macros. */ - int alignment_mask; /* Mask of alignment for each object. */ - - PTR(*chunkfun) (); /* User's fcn to allocate a chunk. */ - void (*freefun) (); /* User's function to free a chunk. */ -}; - -#ifdef __STDC__ - -/* Do the function-declarations after the structs - but before defining the macros. */ - -void obstack_init (struct obstack *obstack); - -void * obstack_alloc (struct obstack *obstack, int size); - -void * obstack_copy (struct obstack *obstack, void *address, int size); -void * obstack_copy0 (struct obstack *obstack, void *address, int size); - -void obstack_free (struct obstack *obstack, void *block); - -void obstack_blank (struct obstack *obstack, int size); - -void obstack_grow (struct obstack *obstack, void *data, int size); -void obstack_grow0 (struct obstack *obstack, void *data, int size); - -void obstack_1grow (struct obstack *obstack, int data_char); -void obstack_ptr_grow (struct obstack *obstack, void *data); -void obstack_int_grow (struct obstack *obstack, int data); - -void * obstack_finish (struct obstack *obstack); - -int obstack_object_size (struct obstack *obstack); - -int obstack_room (struct obstack *obstack); -void obstack_1grow_fast (struct obstack *obstack, int data_char); -void obstack_ptr_grow_fast (struct obstack *obstack, void *data); -void obstack_int_grow_fast (struct obstack *obstack, int data); -void obstack_blank_fast (struct obstack *obstack, int size); - -void * obstack_base (struct obstack *obstack); -void * obstack_next_free (struct obstack *obstack); -int obstack_alignment_mask (struct obstack *obstack); -int obstack_chunk_size (struct obstack *obstack); - -#endif /* __STDC__ */ - -/* Non-ANSI C cannot really support alternative functions for these macros, - so we do not declare them. */ - -/* Pointer to beginning of object being allocated or to be allocated next. - Note that this might not be the final address of the object - because a new chunk might be needed to hold the final size. */ - -#define obstack_base(h) ((h)->object_base) - -/* Size for allocating ordinary chunks. */ - -#define obstack_chunk_size(h) ((h)->chunk_size) - -/* Pointer to next byte not yet allocated in current chunk. */ - -#define obstack_next_free(h) ((h)->next_free) - -/* Mask specifying low bits that should be clear in address of an object. */ - -#define obstack_alignment_mask(h) ((h)->alignment_mask) - -#define obstack_init(h) \ - _obstack_begin ((h), 0, 0, obstack_chunk_alloc, obstack_chunk_free) - -#define obstack_begin(h, size) \ - _obstack_begin ((h), (size), 0, obstack_chunk_alloc, obstack_chunk_free) - -#define obstack_1grow_fast(h,achar) (*((h)->next_free)++ = achar) - -#define obstack_blank_fast(h,n) ((h)->next_free += (n)) - -#if defined (__GNUC__) && defined (__STDC__) - -/* For GNU C, if not -traditional, - we can define these macros to compute all args only once - without using a global variable. - Also, we can avoid using the `temp' slot, to make faster code. */ - -#define obstack_object_size(OBSTACK) \ - ({ struct obstack *__o = (OBSTACK); \ - (unsigned) (__o->next_free - __o->object_base); }) - -#define obstack_room(OBSTACK) \ - ({ struct obstack *__o = (OBSTACK); \ - (unsigned) (__o->chunk_limit - __o->next_free); }) - -#define obstack_grow(OBSTACK,where,length) \ -({ struct obstack *__o = (OBSTACK); \ - int __len = (length); \ - ((__o->next_free + __len > __o->chunk_limit) \ - ? _obstack_newchunk (__o, __len) : 0); \ - bcopy (where, __o->next_free, __len); \ - __o->next_free += __len; \ - (void) 0; }) - -#define obstack_grow0(OBSTACK,where,length) \ -({ struct obstack *__o = (OBSTACK); \ - int __len = (length); \ - ((__o->next_free + __len + 1 > __o->chunk_limit) \ - ? _obstack_newchunk (__o, __len + 1) : 0), \ - bcopy (where, __o->next_free, __len), \ - __o->next_free += __len, \ - *(__o->next_free)++ = 0; \ - (void) 0; }) - -#define obstack_1grow(OBSTACK,datum) \ -({ struct obstack *__o = (OBSTACK); \ - ((__o->next_free + 1 > __o->chunk_limit) \ - ? _obstack_newchunk (__o, 1) : 0), \ - *(__o->next_free)++ = (datum); \ - (void) 0; }) - -/* These assume that the obstack alignment is good enough for pointers or ints, - and that the data added so far to the current object - shares that much alignment. */ - -#define obstack_ptr_grow(OBSTACK,datum) \ -({ struct obstack *__o = (OBSTACK); \ - ((__o->next_free + sizeof (void *) > __o->chunk_limit) \ - ? _obstack_newchunk (__o, sizeof (void *)) : 0), \ - *((void **)__o->next_free)++ = ((void *)datum); \ - (void) 0; }) - -#define obstack_int_grow(OBSTACK,datum) \ -({ struct obstack *__o = (OBSTACK); \ - ((__o->next_free + sizeof (int) > __o->chunk_limit) \ - ? _obstack_newchunk (__o, sizeof (int)) : 0), \ - *((int *)__o->next_free)++ = ((int)datum); \ - (void) 0; }) - -#define obstack_ptr_grow_fast(h,aptr) (*((void **)(h)->next_free)++ = (void *)aptr) -#define obstack_int_grow_fast(h,aint) (*((int *)(h)->next_free)++ = (int)aint) - -#define obstack_blank(OBSTACK,length) \ -({ struct obstack *__o = (OBSTACK); \ - int __len = (length); \ - ((__o->chunk_limit - __o->next_free < __len) \ - ? _obstack_newchunk (__o, __len) : 0); \ - __o->next_free += __len; \ - (void) 0; }) - -#define obstack_alloc(OBSTACK,length) \ -({ struct obstack *__h = (OBSTACK); \ - obstack_blank (__h, (length)); \ - obstack_finish (__h); }) - -#define obstack_copy(OBSTACK,where,length) \ -({ struct obstack *__h = (OBSTACK); \ - obstack_grow (__h, (where), (length)); \ - obstack_finish (__h); }) - -#define obstack_copy0(OBSTACK,where,length) \ -({ struct obstack *__h = (OBSTACK); \ - obstack_grow0 (__h, (where), (length)); \ - obstack_finish (__h); }) - -#define obstack_finish(OBSTACK) \ -({ struct obstack *__o = (OBSTACK); \ - void *value = (void *) __o->object_base; \ - __o->next_free \ - = __INT_TO_PTR ((__PTR_TO_INT (__o->next_free)+__o->alignment_mask)\ - & ~ (__o->alignment_mask)); \ - ((__o->next_free - (char *)__o->chunk \ - > __o->chunk_limit - (char *)__o->chunk) \ - ? (__o->next_free = __o->chunk_limit) : 0); \ - __o->object_base = __o->next_free; \ - value; }) - -#define obstack_free(OBSTACK, OBJ) \ -({ struct obstack *__o = (OBSTACK); \ - void *__obj = (OBJ); \ - if (__obj > (void *)__o->chunk && __obj < (void *)__o->chunk_limit) \ - __o->next_free = __o->object_base = __obj; \ - else (obstack_free) (__o, __obj); }) - -#else /* not __GNUC__ or not __STDC__ */ - -#define obstack_object_size(h) \ - (unsigned) ((h)->next_free - (h)->object_base) - -#define obstack_room(h) \ - (unsigned) ((h)->chunk_limit - (h)->next_free) - -#define obstack_grow(h,where,length) \ -( (h)->temp = (length), \ - (((h)->next_free + (h)->temp > (h)->chunk_limit) \ - ? _obstack_newchunk ((h), (h)->temp) : 0), \ - bcopy (where, (h)->next_free, (h)->temp), \ - (h)->next_free += (h)->temp) - -#define obstack_grow0(h,where,length) \ -( (h)->temp = (length), \ - (((h)->next_free + (h)->temp + 1 > (h)->chunk_limit) \ - ? _obstack_newchunk ((h), (h)->temp + 1) : 0), \ - bcopy (where, (h)->next_free, (h)->temp), \ - (h)->next_free += (h)->temp, \ - *((h)->next_free)++ = 0) - -#define obstack_1grow(h,datum) \ -( (((h)->next_free + 1 > (h)->chunk_limit) \ - ? _obstack_newchunk ((h), 1) : 0), \ - *((h)->next_free)++ = (datum)) - -#define obstack_ptr_grow(h,datum) \ -( (((h)->next_free + sizeof (char *) > (h)->chunk_limit) \ - ? _obstack_newchunk ((h), sizeof (char *)) : 0), \ - *((char **)(h)->next_free)++ = ((char *)datum)) - -#define obstack_int_grow(h,datum) \ -( (((h)->next_free + sizeof (int) > (h)->chunk_limit) \ - ? _obstack_newchunk ((h), sizeof (int)) : 0), \ - *((int *)(h)->next_free)++ = ((int)datum)) - -#define obstack_ptr_grow_fast(h,aptr) (*((char **)(h)->next_free)++ = (char *)aptr) -#define obstack_int_grow_fast(h,aint) (*((int *)(h)->next_free)++ = (int)aint) - -#define obstack_blank(h,length) \ -( (h)->temp = (length), \ - (((h)->chunk_limit - (h)->next_free < (h)->temp) \ - ? _obstack_newchunk ((h), (h)->temp) : 0), \ - (h)->next_free += (h)->temp) - -#define obstack_alloc(h,length) \ - (obstack_blank ((h), (length)), obstack_finish ((h))) - -#define obstack_copy(h,where,length) \ - (obstack_grow ((h), (where), (length)), obstack_finish ((h))) - -#define obstack_copy0(h,where,length) \ - (obstack_grow0 ((h), (where), (length)), obstack_finish ((h))) - -#define obstack_finish(h) \ -( (h)->temp = __PTR_TO_INT ((h)->object_base), \ - (h)->next_free \ - = __INT_TO_PTR ((__PTR_TO_INT ((h)->next_free)+(h)->alignment_mask) \ - & ~ ((h)->alignment_mask)), \ - (((h)->next_free - (char *)(h)->chunk \ - > (h)->chunk_limit - (char *)(h)->chunk) \ - ? ((h)->next_free = (h)->chunk_limit) : 0), \ - (h)->object_base = (h)->next_free, \ - __INT_TO_PTR ((h)->temp)) - -#ifdef __STDC__ -#define obstack_free(h,obj) \ -( (h)->temp = (char *)(obj) - (char *) (h)->chunk, \ - (((h)->temp >= 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\ - ? (int) ((h)->next_free = (h)->object_base \ - = (h)->temp + (char *) (h)->chunk) \ - : ((obstack_free) ((h), (h)->temp + (char *) (h)->chunk), 0))) -#else -#define obstack_free(h,obj) \ -( (h)->temp = (char *)(obj) - (char *) (h)->chunk, \ - (((h)->temp >= 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\ - ? (int) ((h)->next_free = (h)->object_base \ - = (h)->temp + (char *) (h)->chunk) \ - : (int) _obstack_free ((h), (h)->temp + (char *) (h)->chunk))) -#endif - -#endif /* not __GNUC__ or not __STDC__ */ - -/* Declare the external functions we use; they are in obstack.c. */ - -#ifdef __STDC__ - extern int _obstack_newchunk (struct obstack *h, int length); - extern int _obstack_free (struct obstack *h, void *obj); - extern void _obstack_begin (struct obstack *h, int size, int alignment, - void *(*chunkfun) (), void (*freefun) ()); -#else - extern int _obstack_newchunk (); - extern int _obstack_free (); - extern void _obstack_begin (); -#endif - -#endif /* not __OBSTACKS__ */ - diff --git a/bfd/opncls.c b/bfd/opncls.c deleted file mode 100644 index 9e096f4d4a8..00000000000 --- a/bfd/opncls.c +++ /dev/null @@ -1,439 +0,0 @@ -/* opncls.c -- open and close a BFD. - Copyright (C) 1990-1991 Free Software Foundation, Inc. - Written by Cygnus Support. - -This file is part of BFD, the Binary File Descriptor library. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* $Id$ */ - -#include "bfd.h" -#include "sysdep.h" -#include "libbfd.h" -#include "obstack.h" -extern void bfd_cache_init(); -FILE *bfd_open_file(); - -/* fdopen is a loser -- we should use stdio exclusively. Unfortunately - if we do that we can't use fcntl. */ - - -#define obstack_chunk_alloc bfd_xmalloc -#define obstack_chunk_free free - -/* Return a new BFD. All BFD's are allocated through this routine. */ - -bfd *new_bfd() -{ - bfd *nbfd; - - nbfd = (bfd *)zalloc (sizeof (bfd)); - if (!nbfd) - return 0; - - bfd_check_init(); - obstack_begin((PTR)&nbfd->memory, 128); - - nbfd->arch_info = &bfd_default_arch_struct; - - nbfd->direction = no_direction; - nbfd->iostream = NULL; - nbfd->where = 0; - nbfd->sections = (asection *)NULL; - nbfd->format = bfd_unknown; - nbfd->my_archive = (bfd *)NULL; - nbfd->origin = 0; - nbfd->opened_once = false; - nbfd->output_has_begun = false; - nbfd->section_count = 0; - nbfd->usrdata = (PTR)NULL; - nbfd->sections = (asection *)NULL; - nbfd->cacheable = false; - nbfd->flags = NO_FLAGS; - nbfd->mtime_set = 0; - return nbfd; -} - -/* Allocate a new BFD as a member of archive OBFD. */ - -bfd *new_bfd_contained_in(obfd) -bfd *obfd; -{ - bfd *nbfd = new_bfd(); - nbfd->xvec = obfd->xvec; - nbfd->my_archive = obfd; - nbfd->direction = read_direction; - return nbfd; -} - -/*doc* -@section Opening and Closing BFDs - -*/ -/*proto* -*i bfd_openr -Opens the file supplied (using @code{fopen}) with the target supplied, it -returns a pointer to the created BFD. - -If NULL is returned then an error has occured. -Possible errors are no_memory, invalid_target or system_call error. -*; PROTO(bfd*, bfd_openr, (CONST char *filename,CONST char*target)); -*-*/ - -bfd * -DEFUN(bfd_openr, (filename, target), - CONST char *filename AND - CONST char *target) -{ - bfd *nbfd; - bfd_target *target_vec; - - nbfd = new_bfd(); - if (nbfd == NULL) { - bfd_error = no_memory; - return NULL; - } - - target_vec = bfd_find_target (target, nbfd); - if (target_vec == NULL) { - bfd_error = invalid_target; - return NULL; - } - - nbfd->filename = filename; - nbfd->direction = read_direction; - - if (bfd_open_file (nbfd) == NULL) { - bfd_error = system_call_error; /* File didn't exist, or some such */ - bfd_release(nbfd,0); - return NULL; - } - return nbfd; -} - - -/* Don't try to `optimize' this function: - - o - We lock using stack space so that interrupting the locking - 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. - */ -/*proto* -*i bfd_fdopenr -bfd_fdopenr is to bfd_fopenr much like fdopen is to fopen. It opens a BFD on -a file already described by the @var{fd} supplied. - -Possible errors are no_memory, invalid_target and system_call error. -*; PROTO(bfd *, bfd_fdopenr, - (CONST char *filename, CONST char *target, int fd)); -*-*/ - -bfd * -DEFUN(bfd_fdopenr,(filename, target, fd), - CONST char *filename AND - CONST char *target AND - int fd) -{ - bfd *nbfd; - bfd_target *target_vec; - int fdflags; - - bfd_error = system_call_error; - -#ifdef NO_FCNTL - fdflags = O_RDWR; /* Assume full access */ -#else - fdflags = fcntl (fd, F_GETFL, NULL); -#endif - if (fdflags == -1) return NULL; - - nbfd = new_bfd(); - - if (nbfd == NULL) { - bfd_error = no_memory; - return NULL; - } - - target_vec = bfd_find_target (target, nbfd); - if (target_vec == NULL) { - bfd_error = invalid_target; - return NULL; - } - -#ifdef FASCIST_FDOPEN - nbfd->iostream = (char *) fdopen (fd, "r"); -#else - /* if the fd were open for read only, this still would not hurt: */ - nbfd->iostream = (char *) fdopen (fd, "r+"); -#endif - if (nbfd->iostream == NULL) { - (void) obstack_free (&nbfd->memory, (PTR)0); - return NULL; - } - - /* 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 */ - switch (fdflags & (O_ACCMODE)) { - case O_RDONLY: nbfd->direction = read_direction; break; - case O_WRONLY: nbfd->direction = write_direction; break; - case O_RDWR: nbfd->direction = both_direction; break; - default: abort (); - } - - bfd_cache_init (nbfd); - - return nbfd; -} - -/** 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. */ - -/*proto* bfd_openw -Creates a BFD, associated with file @var{filename}, using the file -format @var{target}, and returns a pointer to it. - -Possible errors are system_call_error, no_memory, invalid_target. -*; PROTO(bfd *, bfd_openw, (CONST char *filename, CONST char *target)); -*/ - -bfd * -DEFUN(bfd_openw,(filename, target), - CONST char *filename AND - CONST char *target) -{ - bfd *nbfd; - bfd_target *target_vec; - - bfd_error = system_call_error; - - /* nbfd has to point to head of malloc'ed block so that bfd_close may - reclaim it correctly. */ - - nbfd = new_bfd(); - if (nbfd == NULL) { - bfd_error = no_memory; - return NULL; - } - - target_vec = bfd_find_target (target, nbfd); - if (target_vec == NULL) return NULL; - - nbfd->filename = filename; - nbfd->direction = write_direction; - - if (bfd_open_file (nbfd) == NULL) { - bfd_error = system_call_error; /* File not writeable, etc */ - (void) obstack_free (&nbfd->memory, (PTR)0); - return NULL; - } - return nbfd; -} - -/*proto* bfd_close -This function closes a BFD. If the BFD was open for writing, then -pending operations are completed and the file written out and closed. -If the created file is executable, then @code{chmod} is called to mark -it as such. - -All memory attached to the BFD's obstacks is released. - -@code{true} is returned if all is ok, otherwise @code{false}. -*; PROTO(boolean, bfd_close,(bfd *)); -*/ - -boolean -DEFUN(bfd_close,(abfd), - bfd *abfd) -{ - if (!bfd_read_p(abfd)) - if (BFD_SEND_FMT (abfd, _bfd_write_contents, (abfd)) != true) - return false; - - if (BFD_SEND (abfd, _close_and_cleanup, (abfd)) != true) return false; - - bfd_cache_close(abfd); - - /* If the file was open for writing and is now executable, - make it so */ - if (abfd->direction == write_direction - && abfd->flags & EXEC_P) { - struct stat buf; - stat(abfd->filename, &buf); -#ifndef S_IXUSR -#define S_IXUSR 0100 /* Execute by owner. */ -#endif -#ifndef S_IXGRP -#define S_IXGRP 0010 /* Execute by group. */ -#endif -#ifndef S_IXOTH -#define S_IXOTH 0001 /* Execute by others. */ -#endif - - chmod(abfd->filename,buf.st_mode | S_IXUSR | S_IXGRP | S_IXOTH); - } - (void) obstack_free (&abfd->memory, (PTR)0); - (void) free(abfd); - return true; -} - -/*proto* bfd_close_all_done -This function closes a BFD. It differs from @code{bfd_close} since it -does not complete any pending operations. This routine would be used -if the application had just used BFD for swapping and didn't want to -use any of the writing code. - -If the created file is executable, then @code{chmod} is called to mark -it as such. - -All memory attached to the BFD's obstacks is released. - -@code{true} is returned if all is ok, otherwise @code{false}. -*; PROTO(boolean, bfd_close_all_done,(bfd *)); -*/ - -boolean -DEFUN(bfd_close_all_done,(abfd), - bfd *abfd) -{ - bfd_cache_close(abfd); - - /* If the file was open for writing and is now executable, - make it so */ - if (abfd->direction == write_direction - && abfd->flags & EXEC_P) { - struct stat buf; - stat(abfd->filename, &buf); -#ifndef S_IXUSR -#define S_IXUSR 0100 /* Execute by owner. */ -#endif -#ifndef S_IXGRP -#define S_IXGRP 0010 /* Execute by group. */ -#endif -#ifndef S_IXOTH -#define S_IXOTH 0001 /* Execute by others. */ -#endif - - chmod(abfd->filename,buf.st_mode | S_IXUSR | S_IXGRP | S_IXOTH); - } - (void) obstack_free (&abfd->memory, (PTR)0); - (void) free(abfd); - return true; -} - -/*proto* bfd_create -This routine creates a new BFD in the manner of @code{bfd_openw}, but without -opening a file. The new BFD takes the target from the target used by -@var{template}. The format is always set to @code{bfd_object}. - -*; PROTO(bfd *, bfd_create, (CONST char *filename, bfd *template)); -*/ - -bfd * -DEFUN(bfd_create,(filename, template), - CONST char *filename AND - bfd *template) -{ - bfd *nbfd = new_bfd(); - if (nbfd == (bfd *)NULL) { - bfd_error = no_memory; - return (bfd *)NULL; - } - nbfd->filename = filename; - if(template) { - nbfd->xvec = template->xvec; - } - nbfd->direction = no_direction; - bfd_set_format(nbfd, bfd_object); - return nbfd; -} - -/* Memory allocation */ - -DEFUN(PTR bfd_alloc_by_size_t,(abfd, size), - bfd *abfd AND - size_t size) -{ - PTR res = obstack_alloc(&(abfd->memory), size); - return res; -} - -DEFUN(void bfd_alloc_grow,(abfd, ptr, size), - bfd *abfd AND - PTR ptr AND - bfd_size_type size) -{ - (void) obstack_grow(&(abfd->memory), ptr, size); -} -DEFUN(PTR bfd_alloc_finish,(abfd), - bfd *abfd) -{ - return obstack_finish(&(abfd->memory)); -} - -DEFUN(PTR bfd_alloc, (abfd, size), - bfd *abfd AND - bfd_size_type size) -{ - return bfd_alloc_by_size_t(abfd, (size_t)size); -} - -DEFUN(PTR bfd_zalloc,(abfd, size), - bfd *abfd AND - bfd_size_type size) -{ - PTR res = bfd_alloc(abfd, size); - memset(res, 0, (size_t)size); - return res; -} - -DEFUN(PTR bfd_realloc,(abfd, old, size), - bfd *abfd AND - PTR old AND - bfd_size_type size) -{ - PTR res = bfd_alloc(abfd, size); - memcpy(res, old, (size_t)size); - return res; -} - -/*proto* bfd_alloc_size -Return the number of bytes in the obstacks connected to the supplied -BFD. -*; PROTO(bfd_size_type,bfd_alloc_size,(bfd *abfd)); -*/ - -bfd_size_type -DEFUN( bfd_alloc_size,(abfd), - bfd *abfd) -{ - struct _obstack_chunk *chunk = abfd->memory.chunk; - size_t size = 0; - while (chunk) { - size += chunk->limit - &(chunk->contents[0]); - chunk = chunk->prev; - } - return size; -} diff --git a/bfd/reloc.c b/bfd/reloc.c deleted file mode 100644 index 4804e84e5f6..00000000000 --- a/bfd/reloc.c +++ /dev/null @@ -1,737 +0,0 @@ -/* BFD support for handling relocation entries. - Copyright (C) 1990-1991 Free Software Foundation, Inc. - Written by Cygnus Support. - -This file is part of BFD, the Binary File Descriptor library. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/*doc* -@section Relocations - -BFD maintains relocations in much the same was as it maintains -symbols; they are left alone until required, then read in en-mass and -traslated into an internal form. There is a common routine -@code{bfd_perform_relocation} which acts upon the canonical form to to -the actual fixup. - -Note that relocations are maintained on a per section basis, whilst -symbols are maintained on a per BFD basis. - -All a back end has to do to fit the BFD interface is to create as many -@code{struct reloc_cache_entry} as there are relocations in a -particuar section, and fill in the right bits: - -@menu -* typedef arelent:: -* reloc handling functions:: -@end menu - -*/ -#include "sysdep.h" -#include "bfd.h" -#include "libbfd.h" -/*doc -@node typedef arelent, Relocations, reloc handling functions, Relocations -@section typedef arelent - - -*/ - -/*proto* bfd_perform_relocation -The relocation routine returns as a status an enumerated type: - -*+++ - -$typedef enum bfd_reloc_status { -No errors detected - -$ bfd_reloc_ok, - -The relocation was performed, but there was an overflow. - -$ bfd_reloc_overflow, - -The address to relocate was not within the section supplied - -$ bfd_reloc_outofrange, - -Used by special functions - -$ bfd_reloc_continue, - -Unused - -$ bfd_reloc_notsupported, - -Unsupported relocation size requested. - -$ bfd_reloc_other, - -The symbol to relocate against was undefined. - -$ bfd_reloc_undefined, - -The relocation was performed, but may not be ok - presently generated -only when linking i960 coff files with i960 b.out symbols. - -$ bfd_reloc_dangerous -$ } -$ bfd_reloc_status_enum_type; - -*--- - -*/ - -/*proto* - -*+++ - -$typedef struct reloc_cache_entry -${ - -A pointer into the canonical table of pointers - -$ struct symbol_cache_entry **sym_ptr_ptr; - -offset in section - -$ rawdata_offset address; - -addend for relocation value - -$ bfd_vma addend; - -if sym is null this is the section - -$ struct sec *section; - -Pointer to how to perform the required relocation - -$ CONST struct reloc_howto_struct *howto; -$} arelent; - -*--- - -*/ - -/*doc* -@table @code -@item sym_ptr_ptr -The symbol table pointer points to a pointer to the symbol associated with the -relocation request. This would naturally be the pointer into the table -returned by the back end's get_symtab action. @xref{Symbols}. The -symbol is referenced through a pointer to a pointer so that tools like -the linker can fix up all the symbols of the same name by modifying -only one pointer. The relocation routine looks in the symbol and uses -the base of the section the symbol is attached to and the value of -the symbol as the initial relocation offset. If the symbol pointer is -zero, then the section provided is looked up. -@item address -The address field gives the offset in bytes from the base of the -section data which owns the relocation record to the first byte of -relocatable information. The actual data relocated will be relative to -this point - for example, a relocation type which modifies the bottom -two bytes of a four byte word would not touch the first byte pointed -to in a big endian world. -@item addend -The addend is a value provided by the back end to be added (!) to the -relocation offset. Its interpretation is dependent upon the howto. -For example, on the 68k the code: - -*+ - char foo[]; - main() - { - return foo[0x12345678]; - } -*- -Could be compiled into: - -*+ - linkw fp,#-4 - moveb @@#12345678,d0 - extbl d0 - unlk fp - rts -*- - -This could create a reloc pointing to foo, but leave the offset in the data -(something like) - -*+ -RELOCATION RECORDS FOR [.text]: -OFFSET TYPE VALUE -00000006 32 _foo - -00000000 4e56 fffc ; linkw fp,#-4 -00000004 1039 1234 5678 ; moveb @@#12345678,d0 -0000000a 49c0 ; extbl d0 -0000000c 4e5e ; unlk fp -0000000e 4e75 ; rts -*- -Using coff and an 88k, some instructions don't have enough space in them to -represent the full address range, and pointers have to be loaded in -two parts. So you'd get something like: - -*+ - or.u r13,r0,hi16(_foo+0x12345678) - ld.b r2,r13,lo16(_foo+0x12345678) - jmp r1 -*- -This whould create two relocs, both pointing to _foo, and with 0x12340000 -in their addend field. The data would consist of: - -*+ - -RELOCATION RECORDS FOR [.text]: -OFFSET TYPE VALUE -00000002 HVRT16 _foo+0x12340000 -00000006 LVRT16 _foo+0x12340000 - -00000000 5da05678 ; or.u r13,r0,0x5678 -00000004 1c4d5678 ; ld.b r2,r13,0x5678 -00000008 f400c001 ; jmp r1 -*- -The relocation routine digs out the value from the data, adds it to -the addend to get the original offset and then adds the value of _foo. -Note that all 32 bits have to be kept around somewhere, to cope with -carry from bit 15 to bit 16. - -On further example is the sparc and the a.out format. The sparc has a -similar problem to the 88k, in that some instructions don't have -room for an entire offset, but on the sparc the parts are created odd -sized lumps. The designers of the a.out format chose not to use the -data within the section for storing part of the offset; all the offset -is kept within the reloc. Any thing in the data should be ignored. - -*+ - save %sp,-112,%sp - sethi %hi(_foo+0x12345678),%g2 - ldsb [%g2+%lo(_foo+0x12345678)],%i0 - ret - restore -*- -Both relocs contains a pointer to foo, and the offsets would contain junk. - -*+ -RELOCATION RECORDS FOR [.text]: -OFFSET TYPE VALUE -00000004 HI22 _foo+0x12345678 -00000008 LO10 _foo+0x12345678 - -00000000 9de3bf90 ; save %sp,-112,%sp -00000004 05000000 ; sethi %hi(_foo+0),%g2 -00000008 f048a000 ; ldsb [%g2+%lo(_foo+0)],%i0 -0000000c 81c7e008 ; ret -00000010 81e80000 ; restore -*- -@item section -The section field is only used when the symbol pointer field is null. -It supplies the section into which the data should be relocated. The -field's main use comes from assemblers which do most of the symbol fixups -themselves; an assembler may take an internal reference to a label, -but since it knows where the label is, it can turn the relocation -request from a symbol lookup into a section relative relocation - the -relocation emitted has no symbol, just a section to relocate against. - -I'm not sure what it means when both a symbol pointer an a section -pointer are present. Some formats use this sort of mechanism to -describe PIC relocations, but BFD can't to that sort of thing yet. -@item howto -The howto field can be imagined as a relocation instruction. It is a -pointer to a struct which contains information on what to do with all -the other information in the reloc record and data section. A back end -would normally have a relocation instruction set and turn relocations -into pointers to the correct structure on input - but it would be -possible to create each howto field on demand. -@end table -*/ - - -/*proto* reloc_howto_type -The @code{reloc_howto_type} is a structure which contains all the -information that BFD needs to know to tie up a back end's data. - -*+++ - -$typedef CONST struct reloc_howto_struct -${ -The type field has mainly a documetary use - the back end can to what -it wants with it, though the normally the back end's external idea of -what a reloc number would be would be stored in this field. For -example, the a PC relative word relocation in a coff environment would -have the type 023 - because that's what the outside world calls a -R_PCRWORD reloc. - -$ unsigned int type; - -The value the final relocation is shifted right by. This drops -unwanted data from the relocation. - -$ unsigned int rightshift; - -The size of the item to be relocated - 0, is one byte, 1 is 2 bytes, 3 -is four bytes. - -$ unsigned int size; - -Now obsolete - -$ unsigned int bitsize; - -Notes that the relocation is relative to the location in the data -section of the addend. The relocation function will subtract from the -relocation value the address of the location being relocated. - -$ boolean pc_relative; - -Now obsolete - -$ unsigned int bitpos; - -Now obsolete - -$ boolean absolute; - -Causes the relocation routine to return an error if overflow is -detected when relocating. - -$ boolean complain_on_overflow; - -If this field is non null, then the supplied function is called rather -than the normal function. This allows really strange relocation -methods to be accomodated (eg, i960 callj instructions). - -$ bfd_reloc_status_enum_type (*special_function)(); - -The textual name of the relocation type. - -$ char *name; - -When performing a partial link, some formats must modify the -relocations rather than the data - this flag signals this. - -$ boolean partial_inplace; - -The src_mask is used to select what parts of the read in data are to -be used in the relocation sum. Eg, if this was an 8 bit bit of data -which we read and relocated, this would be 0x000000ff. When we have -relocs which have an addend, such as sun4 extended relocs, the value -in the offset part of a relocating field is garbage so we never use -it. In this case the mask would be 0x00000000. - -$ bfd_word src_mask; -The dst_mask is what parts of the instruction are replaced into the -instruction. In most cases src_mask == dst_mask, except in the above -special case, where dst_mask would be 0x000000ff, and src_mask would -be 0x00000000. - -$ bfd_word dst_mask; - -When some formats create PC relative instructions, they leave the -value of the pc of the place being relocated in the offset slot of the -instruction, so that a PC relative relocation can be made just by -adding in an ordinary offset (eg sun3 a.out). Some formats leave the -displacement part of an instruction empty (eg m88k bcs), this flag -signals the fact. - -$ boolean pcrel_offset; -$} reloc_howto_type; -*--- - -*/ - -/*proto* HOWTO -The HOWTO define is horrible and will go away. -*+ -#define HOWTO(C, R,S,B, P, BI, ABS, O, SF, NAME, INPLACE, MASKSRC, MASKDST, PC) \ - {(unsigned)C,R,S,B, P, BI, ABS,O,SF,NAME,INPLACE,MASKSRC,MASKDST,PC} -*- - -And will be replaced with the totally magic way. But for the moment, -we are compatible, so do it this way.. - -*+ -#define NEWHOWTO( FUNCTION, NAME,SIZE,REL,IN) HOWTO(0,0,SIZE,0,REL,0,false,false,FUNCTION, NAME,false,0,0,IN) -*- - -Helper routine to turn a symbol into a relocation value. - -*+ - - -#define HOWTO_PREPARE(relocation, symbol) \ - { \ - if (symbol != (asymbol *)NULL) { \ - if (symbol->flags & BSF_FORT_COMM) { \ - relocation = 0; \ - } \ - else { \ - relocation = symbol->value; \ - } \ - } \ - if (symbol->section != (asection *)NULL) { \ - relocation += symbol->section->output_section->vma + \ - symbol->section->output_offset; \ - } \ -} -*- -*/ - -/*proto* reloc_chain -*+ -typedef unsigned char bfd_byte; - -typedef struct relent_chain { - arelent relent; - struct relent_chain *next; -} arelent_chain; - -*- - -*/ - - - -/*proto* -If an output_bfd is supplied to this function the generated image -will be relocatable, the relocations are copied to the output file -after they have been changed to reflect the new state of the world. -There are two ways of reflecting the results of partial linkage in an -output file; by modifying the output data in place, and by modifying -the relocation record. Some native formats (eg basic a.out and basic -coff) have no way of specifying an addend in the relocation type, so -the addend has to go in the output data. This is no big deal since in -these formats the output data slot will always be big enough for the -addend. Complex reloc types with addends were invented to solve just -this problem. -*; PROTO(bfd_reloc_status_enum_type, - bfd_perform_relocation, - (bfd * abfd, - arelent *reloc_entry, - PTR data, - asection *input_section, - bfd *output_bfd)); -*/ - - -bfd_reloc_status_enum_type -DEFUN(bfd_perform_relocation,(abfd, - reloc_entry, - data, - input_section, - output_bfd), - bfd *abfd AND - arelent *reloc_entry AND - PTR data AND - asection *input_section AND - bfd *output_bfd) -{ - bfd_vma relocation; - bfd_reloc_status_enum_type flag = bfd_reloc_ok; - bfd_vma addr = reloc_entry->address ; - bfd_vma output_base = 0; - reloc_howto_type *howto = reloc_entry->howto; - asection *reloc_target_output_section; - asection *reloc_target_input_section; - asymbol *symbol; - - if (reloc_entry->sym_ptr_ptr) { - symbol = *( reloc_entry->sym_ptr_ptr); - if ((symbol->flags & BSF_UNDEFINED) && output_bfd == (bfd *)NULL) { - flag = bfd_reloc_undefined; - } - } - else { - symbol = (asymbol*)NULL; - } - - if (howto->special_function){ - bfd_reloc_status_enum_type cont; - cont = howto->special_function(abfd, - reloc_entry, - symbol, - data, - input_section); - if (cont != bfd_reloc_continue) return cont; - } - - /* - Work out which section the relocation is targetted at and the - initial relocation command value. - */ - - - if (symbol != (asymbol *)NULL){ - if (symbol->flags & BSF_FORT_COMM) { - relocation = 0; - } - else { - relocation = symbol->value; - } - if (symbol->section != (asection *)NULL) - { - reloc_target_input_section = symbol->section; - } - else { - reloc_target_input_section = (asection *)NULL; - } - } - else if (reloc_entry->section != (asection *)NULL) - { - relocation = 0; - reloc_target_input_section = reloc_entry->section; - } - else { - relocation = 0; - reloc_target_input_section = (asection *)NULL; - } - - - if (reloc_target_input_section != (asection *)NULL) { - - reloc_target_output_section = - reloc_target_input_section->output_section; - - if (output_bfd && howto->partial_inplace==false) { - output_base = 0; - } - else { - output_base = reloc_target_output_section->vma; - - } - - relocation += output_base + reloc_target_input_section->output_offset; - } - - relocation += reloc_entry->addend ; - - - if(reloc_entry->address > (bfd_vma)(input_section->size)) - { - return bfd_reloc_outofrange; - } - - - if (howto->pc_relative == true) - { - /* - Anything which started out as pc relative should end up that - way too. - - There are two ways we can see a pcrel instruction. Sometimes - the pcrel displacement has been partially calculated, it - includes the distance from the start of the section to the - instruction in it (eg sun3), and sometimes the field is - totally blank - eg m88kbcs. - */ - - - relocation -= - input_section->output_section->vma + input_section->output_offset; - - if (howto->pcrel_offset == true) { - relocation -= reloc_entry->address; - } - - } - - if (output_bfd!= (bfd *)NULL) { - if ( howto->partial_inplace == false) { - /* - This is a partial relocation, and we want to apply the relocation - to the reloc entry rather than the raw data. Modify the reloc - inplace to reflect what we now know. - */ - reloc_entry->addend = relocation ; - reloc_entry->section = reloc_target_input_section; - if (reloc_target_input_section != (asection *)NULL) { - /* If we know the output section we can forget the symbol */ - reloc_entry->sym_ptr_ptr = (asymbol**)NULL; - } - reloc_entry->address += - input_section->output_offset; - return flag; - } - else - { - /* This is a partial relocation, but inplace, so modify the - reloc record a bit. - - If we've relocated with a symbol with a section, change - into a ref to the section belonging to the symbol - */ - - if (symbol != (asymbol *)NULL && reloc_target_input_section != (asection *)NULL) - { - reloc_entry->section = reloc_target_input_section; - reloc_entry->sym_ptr_ptr = (asymbol **)NULL; - } - - } - } - - reloc_entry->addend = 0; - - - /* - Either we are relocating all the way, or we don't want to apply - the relocation to the reloc entry (probably because there isn't - any room in the output format to describe addends to relocs) - */ - relocation >>= howto->rightshift; - - /* Shift everything up to where it's going to be used */ - - relocation <<= howto->bitpos; - - /* Wait for the day when all have the mask in them */ - - /* What we do: - i instruction to be left alone - o offset within instruction - r relocation offset to apply - S src mask - D dst mask - N ~dst mask - A part 1 - B part 2 - R result - - Do this: - i i i i i o o o o o from bfd_get - and S S S S S to get the size offset we want - + r r r r r r r r r r to get the final value to place - and D D D D D to chop to right size - ----------------------- - A A A A A - And this: - ... i i i i i o o o o o from bfd_get - and N N N N N get instruction - ----------------------- - ... B B B B B - - And then: - B B B B B - or A A A A A - ----------------------- - R R R R R R R R R R put into bfd_put - */ - -#define DOIT(x) \ - x = ( (x & ~howto->dst_mask) | (((x & howto->src_mask) + relocation) & howto->dst_mask)) - - switch (howto->size) - { - case 0: - { - char x = bfd_get_8(abfd, (char *)data + addr); - DOIT(x); - bfd_put_8(abfd,x, (unsigned char *) data + addr); - } - break; - - case 1: - { - short x = bfd_get_16(abfd, (bfd_byte *)data + addr); - DOIT(x); - bfd_put_16(abfd, x, (unsigned char *)data + addr); - } - break; - case 2: - { - long x = bfd_get_32(abfd, (bfd_byte *) data + addr); - DOIT(x); - bfd_put_32(abfd,x, (bfd_byte *)data + addr); - } - break; - case 3: - - /* Do nothing */ - break; - default: - return bfd_reloc_other; - } - - return flag; -} - - - -/*doc* - -@section The howto manager - - -When an application wants to create a relocation, but doesn't know -what the target machine might call it, it can find out by using this -bit of code. - -*/ - -/*proto* bfd_reloc_code_enum_type - -*+++ - -$typedef enum -${ - -16 bits wide, simple reloc - -$ BFD_RELOC_16, - -8 bits wide, but used to form an address like 0xffnn - -$ BFD_RELOC_8_FFnn, - -8 bits wide, simple - -$ BFD_RELOC_8, - -8 bits wide, pc relative - -$ BFD_RELOC_8_PCREL -$ } bfd_reloc_code_enum_real_type; - -*--- - -*/ - - - -/*proto* bfd_reloc_type_lookup -This routine returns a pointer to a howto struct which when invoked, -will perform the supplied relocation on data from the architecture -noted. - -[Note] This function will go away. - -*; PROTO(CONST struct reloc_howto_struct *, - bfd_reloc_type_lookup, - (CONST bfd_arch_info_struct_type *arch, bfd_reloc_code_enum_type code)); -*/ - - -CONST struct reloc_howto_struct * -DEFUN(bfd_reloc_type_lookup,(arch, code), - CONST bfd_arch_info_struct_type *arch AND - bfd_reloc_code_enum_type code) -{ - return arch->reloc_type_lookup(arch, code); -} - - - diff --git a/bfd/scanit b/bfd/scanit deleted file mode 100755 index 27eee02082c..00000000000 --- a/bfd/scanit +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh -# Script to coordinate parsing of S. Chamberlain source-embedded -# documentation markup language. - -# Four passes: -# 1) awk discards lines not intended for docn, and marks blocks of -# text with comments identifying source file; -# 2) first sed pass interprets Chamberlain markup; -# 3) second sed pass does cleanup that involves merging lines -# 4) third sed pass does remaining cleans up---making {} -# printable within examples, and eliminating empty index entries and -# headings. -#Third and second sed passes are separate because order of execution is hard -#to control otherwise, making one or another of the things involving @example -#inoperative. - -base=`echo $1 | cut -d '.' -f 1` - -awk -f awkscan $1 | \ -sed -f sedscript | \ -sed -f unPROTO | \ -sed -f exmerge | \ -sed -f exfilter >$base.texi - diff --git a/bfd/scanph b/bfd/scanph deleted file mode 100755 index 46912c36357..00000000000 --- a/bfd/scanph +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh -# Script to coordinate parsing of S. Chamberlain source-embedded -# header-file markup language. - -# '-i' option means use *proto-internal* segments, else just *proto* -SFX=p -if [ $1 = "-i" ]; then - SFX=ip - shift -fi - -base=`echo $1 | cut -d '.' -f 1` - -# passes: -# 1) awk discards lines not intended for header, and marks blocks of -# text with comments identifying source file; -# 2) first sed pass interprets Chamberlain markup; -# 3) further sed passes clean up---merging adjacent comments etc. - -awk -f awkscan-$SFX $1 |\ -sed -f sedscript-p |\ -sed -f mergecom-p |\ -sed -f startcom-p |\ -sed -f blins-p |\ -sed -f movecom-p >$base.$SFX diff --git a/bfd/section.c b/bfd/section.c deleted file mode 100644 index 18baa11c736..00000000000 --- a/bfd/section.c +++ /dev/null @@ -1,582 +0,0 @@ -/* Object file "section" support for the BFD library. - Copyright (C) 1990-1991 Free Software Foundation, Inc. - Written by Cygnus Support. - -This file is part of BFD, the Binary File Descriptor library. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/*doc* -@section Sections -Sections are supported in BFD in @code{section.c}. - -The raw data contained within a BFD is maintained through the section -abstraction. A single BFD may have any number of sections, and keeps -hold of them by pointing to the first, each one points to the next in -the list. - -@menu -* Section Input:: -* Section Output:: -* typedef asection:: -* section prototypes:: -@end menu - -@node Section Input, Section Output, Sections, Sections -@subsection Section Input -When a BFD is opened for reading, the section structures are created -and attached to the BFD. - -Each section has a name which describes the section in the outside -world - for example, @code{a.out} would contain at least three -sections, called @code{.text}, @code{.data} and @code{.bss}. - -Sometimes a BFD will contain more than the 'natural' number of -sections. A back end may attach other sections containing constructor -data, or an application may add a section (using bfd_make_section) to -the sections attached to an already open BFD. For example, the linker -creates a supernumary section @code{COMMON} for each input file's BFD -to hold information about common storage. - -The raw data is not necessarily read in at the same time as the -section descriptor is created. Some targets may leave the data in -place until a @code{bfd_get_section_contents} call is made. Other back -ends may read in all the data at once - For example; an S-record file -has to be read once to determine the size of the data. An IEEE-695 -file doesn't contain raw data in sections, but data and relocation -expressions intermixed, so the data area has to be parsed to get out -the data and relocations. - -@node Section Output, typedef asection, Section Input, Sections -@subsection Section Output -To write a new object style BFD, the various sections to be written -have to be created. They are attached to the BFD in the same way as -input sections, data is written to the sections using -@code{bfd_set_section_contents}. - -The linker uses the fields @code{output_section} and -@code{output_offset} to create an output file. - -The data to be written comes from input sections attached to the -output sections. The output section structure can be considered a -filter for the input section, the output section determines the vma of -the output data and the name, but the input section determines the -offset into the output section of the data to be written. - -Eg to create a section "O", starting at 0x100, 0x123 long, containing two -subsections, "A" at offset 0x0 (ie at vma 0x100) and "B" at offset -0x20 (ie at vma 0x120) the structures would look like: - -*+ - - section name "A" - output_offset 0x00 - size 0x20 - output_section -----------> section name "O" - | vma 0x100 - section name "B" | size 0x123 - output_offset 0x20 | - size 0x103 | - output_section --------| - -*- - -*/ - - -#include "bfd.h" -#include "sysdep.h" -#include "libbfd.h" - - -/*doc* -@node typedef asection, section prototypes, Section Output, Sections -@subsection typedef asection -*/ - -/*proto* -The shape of a section struct: - -*+++ - -$typedef struct sec { - -The name of the section, the name isn't a copy, the pointer is -the same as that passed to bfd_make_section. - -$ CONST char *name; - -The next section in the list belonging to the BFD, or NULL. - -$ struct sec *next; - -The field flags contains attributes of the section. Some of these -flags are read in from the object file, and some are synthesized from -other information. - -$flagword flags; - - -$#define SEC_NO_FLAGS 0x000 - -Tells the OS to allocate space for this section when loaded. -This would clear for a section containing debug information only. - -$#define SEC_ALLOC 0x001 - -Tells the OS to load the section from the file when loading. -This would be clear for a .bss section - -$#define SEC_LOAD 0x002 - -The section contains data still to be relocated, so there will be some -relocation information too. - -$#define SEC_RELOC 0x004 - -Obsolete ? - -$#define SEC_BALIGN 0x008 - -A signal to the OS that the section contains read only data. - -$#define SEC_READONLY 0x010 - -The section contains code only. - -$#define SEC_CODE 0x020 - -The section contains data only. - -$#define SEC_DATA 0x040 - -The section will reside in ROM. - -$#define SEC_ROM 0x080 - -The section contains constructor information. This section type is -used by the linker to create lists of constructors and destructors -used by @code{g++}. When a back end sees a symbol which should be used -in a constructor list, it creates a new section for the type of name -(eg @code{__CTOR_LIST__}), attaches the symbol to it and builds a -relocation. To build the lists of constructors, all the linker has to -to is catenate all the sections called @code{__CTOR_LIST__} and -relocte the data contained within - exactly the operations it would -peform on standard data. - -$#define SEC_CONSTRUCTOR 0x100 - -The section is a constuctor, and should be placed at the end of the .. - -$#define SEC_CONSTRUCTOR_TEXT 0x1100 - -$#define SEC_CONSTRUCTOR_DATA 0x2100 - -$#define SEC_CONSTRUCTOR_BSS 0x3100 - - -The section has contents - a bss section could be -@code{SEC_ALLOC} | @code{SEC_HAS_CONTENTS}, a debug section could be -@code{SEC_HAS_CONTENTS} - -$#define SEC_HAS_CONTENTS 0x200 - -An instruction to the linker not to output sections containing -this flag even if they have information which would normally be written. - -$#define SEC_NEVER_LOAD 0x400 - - -The base address of the section in the address space of the target. - -$ bfd_vma vma; - -The size of the section in bytes of the loaded section. This contains -a value even if the section has no contents (eg, the size of @code{.bss}). - -$ bfd_size_type size; - -If this section is going to be output, then this value is the -offset into the output section of the first byte in the input -section. Eg, if this was going to start at the 100th byte in the -output section, this value would be 100. - -$ bfd_vma output_offset; - -The output section through which to map on output. - -$ struct sec *output_section; - -The alignment requirement of the section, as an exponent - eg 3 -aligns to 2^3 (or 8) - -$ unsigned int alignment_power; - -If an input section, a pointer to a vector of relocation records for -the data in this section. - -$ struct reloc_cache_entry *relocation; - -If an output section, a pointer to a vector of pointers to -relocation records for the data in this section. - -$ struct reloc_cache_entry **orelocation; - -The number of relocation records in one of the above - -$ unsigned reloc_count; - -Which section is it 0..nth - -$ int index; - -Information below is back end specific - and not always used or -updated - -File position of section data - -$ file_ptr filepos; -File position of relocation info - -$ file_ptr rel_filepos; - -File position of line data - -$ file_ptr line_filepos; - -Pointer to data for applications - -$ PTR userdata; - -$ struct lang_output_section *otheruserdata; - -Attached line number information - -$ alent *lineno; -Number of line number records - -$ unsigned int lineno_count; - -When a section is being output, this value changes as more -linenumbers are written out - -$ file_ptr moving_line_filepos; - -what the section number is in the target world - -$ unsigned int target_index; - -$ PTR used_by_bfd; - -If this is a constructor section then here is a list of the -relocations created to relocate items within it. - -$ struct relent_chain *constructor_chain; - -The BFD which owns the section. - -$ bfd *owner; - -$} asection ; - -*--- - -*/ - -/*doc* -@node section prototypes, , typedef asection, Sections -@subsection section prototypes - -*/ -/*proto* bfd_get_section_by_name -Runs through the provided @var{abfd} and returns the @code{asection} -who's name matches that provided, otherwise NULL. @xref{Sections}, for more information. - -*; PROTO(asection *, bfd_get_section_by_name, - (bfd *abfd, CONST char *name)); -*/ -asection * -DEFUN(bfd_get_section_by_name,(abfd, name), - bfd *abfd AND - CONST char *name) -{ - asection *sect; - - for (sect = abfd->sections; sect != NULL; sect = sect->next) - if (!strcmp (sect->name, name)) return sect; - return NULL; -} - - -/*proto* bfd_make_section -This function creates a new empty section called @var{name} and attaches it -to the end of the chain of sections for the BFD supplied. An attempt to -create a section with a name which is already in use, returns NULL without -changing the section chain. - -Possible errors are: -@table @code -@item invalid_operation -If output has already started for this BFD. -@item no_memory -If obstack alloc fails. -@end table - -*; PROTO(asection *, bfd_make_section, (bfd *, CONST char *name)); -*/ - - - -sec_ptr -DEFUN(bfd_make_section,(abfd, name), - bfd *abfd AND - CONST char * name) -{ - asection *newsect; - asection ** prev = &abfd->sections; - asection * sect = abfd->sections; - - if (abfd->output_has_begun) { - bfd_error = invalid_operation; - return NULL; - } - - while (sect) { - if (!strcmp(sect->name, name)) return NULL; - prev = §->next; - sect = sect->next; - } - - newsect = (asection *) bfd_zalloc(abfd, sizeof (asection)); - if (newsect == NULL) { - bfd_error = no_memory; - return NULL; - } - - newsect->name = name; - newsect->index = abfd->section_count++; - newsect->flags = SEC_NO_FLAGS; - - newsect->userdata = 0; - newsect->next = (asection *)NULL; - newsect->relocation = (arelent *)NULL; - newsect->reloc_count = 0; - newsect->line_filepos =0; - newsect->owner = abfd; - if (BFD_SEND (abfd, _new_section_hook, (abfd, newsect)) != true) { - free (newsect); - return NULL; - } - - *prev = newsect; - return newsect; -} - - -/*proto* bfd_set_section_flags -Attempts to set the attributes of the section named in the BFD -supplied to the value. Returns true on success, false on error. -Possible error returns are: -@table @code -@item invalid operation -The section cannot have one or more of the attributes requested. For -example, a .bss section in @code{a.out} may not have the -@code{SEC_HAS_CONTENTS} field set. -@end table - -*; PROTO(boolean, bfd_set_section_flags, - (bfd *, asection *, flagword)); -*/ - -boolean -DEFUN(bfd_set_section_flags,(abfd, section, flags), - bfd *abfd AND - sec_ptr section AND - flagword flags) -{ - if ((flags & bfd_applicable_section_flags (abfd)) != flags) { - bfd_error = invalid_operation; - return false; - } - - section->flags = flags; - return true; -} - - -/*proto* bfd_map_over_sections -Calls the provided function @var{func} for each section attached to -the BFD @var{abfd}, passing @var{obj} as an argument. The function -will be called as if by - -@example - func(abfd, the_section, obj); -@end example - - -*; PROTO(void, bfd_map_over_sections, - (bfd *abfd, void (*func)(), PTR obj)); - -This is the prefered method for iterating over sections, an -alternative would be to use a loop: - -@example - section *p; - for (p = abfd->sections; p != NULL; p = p->next) - func(abfd, p, ...) -@end example -*/ - -/*VARARGS2*/ -void -DEFUN(bfd_map_over_sections,(abfd, operation, user_storage), - bfd *abfd AND - void (*operation)() AND - PTR user_storage) -{ - asection *sect; - int i = 0; - - for (sect = abfd->sections; sect != NULL; i++, sect = sect->next) - (*operation) (abfd, sect, user_storage); - - if (i != abfd->section_count) /* Debugging */ - abort(); -} - - -/*proto* bfd_set_section_size -Sets @var{section} to the size @var{val}. If the operation is ok, then -@code{true} is returned, else @code{false}. - -Possible error returns: -@table @code -@item invalid_operation -Writing has started to the BFD, so setting the size is invalid -@end table - -*; PROTO(boolean, bfd_set_section_size, - (bfd *, asection *, bfd_size_type val)); -*/ - -boolean -DEFUN(bfd_set_section_size,(abfd, ptr, val), - bfd *abfd AND - sec_ptr ptr AND - bfd_size_type val) -{ - /* Once you've started writing to any section you cannot create or change - the size of any others. */ - - if (abfd->output_has_begun) { - bfd_error = invalid_operation; - return false; - } - - ptr->size = val; - - return true; -} - -/*proto* bfd_set_section_contents -Sets the contents of the section @var{section} in BFD @var{abfd} to -the data starting in memory at @var{data}. The data is written to the -output section starting at offset @var{offset} for @var{count} bytes. - -Normally @code{true} is returned, else @code{false}. Possible error -returns are: -@table @code -@item no_contents -The output section does not have the @code{SEC_HAS_CONTENTS} -attribute, so nothing can be written to it. -@item and some more too -@end table -This routine is front end to the back end function @code{_bfd_set_section_contents}. - -*; PROTO(boolean, bfd_set_section_contents, - (bfd *abfd, - asection *section, - PTR data, - file_ptr offset, - bfd_size_type count)); - -*/ - -boolean -DEFUN(bfd_set_section_contents,(abfd, section, location, offset, count), - bfd *abfd AND - sec_ptr section AND - PTR location AND - file_ptr offset AND - bfd_size_type count) -{ - if (!(bfd_get_section_flags(abfd, section) & SEC_HAS_CONTENTS)) - { - bfd_error = no_contents; - return(false); - } - - if (BFD_SEND (abfd, _bfd_set_section_contents, - (abfd, section, location, offset, count))) - { - abfd->output_has_begun = true; - return true; - } - - return false; -} - -/*proto* bfd_get_section_contents -This function reads data from @var{section} in BFD @var{abfd} into -memory starting at @var{location}. The data is read at an offset of -@var{offset} from the start of the input section, and is read for -@var{count} bytes. - -If the contents of a constuctor with the @code{SEC_CONSTUCTOR} flag -set are requested, then the @var{location} is filled with zeroes. - -If no errors occur, @code{true} is returned, else @code{false}. -Possible errors are: - -@table @code -@item unknown yet -@end table - -*; PROTO(boolean, bfd_get_section_contents, - (bfd *abfd, asection *section, PTR location, - file_ptr offset, bfd_size_type count)); - - -*/ -boolean -DEFUN(bfd_get_section_contents,(abfd, section, location, offset, count), - bfd *abfd AND - sec_ptr section AND - PTR location AND - file_ptr offset AND - bfd_size_type count) -{ - if (section->flags & SEC_CONSTRUCTOR) - { - memset(location, 0, (unsigned)count); - return true; - } - else - { - return (BFD_SEND (abfd, _bfd_get_section_contents, - (abfd, section, location, offset, count))); - } -} - diff --git a/bfd/sedscript b/bfd/sedscript deleted file mode 100755 index e8e225daec9..00000000000 --- a/bfd/sedscript +++ /dev/null @@ -1,85 +0,0 @@ -# SED script for preprocessing embedded doc from source (S. Chamberlain markup) -# middle pass; most of the work is done here. -# -# First, get rid of /*doc* markers; they've done their job in the first pass. -/^\/\*doc\*/d -# -# /*proto* markers may be optionally followed by a *i-style subsubsec, findex -# entry. This will generate empty @findex and @subsubsection entries if -# the *proto* is on a line by itself; third pass removes them. -/^\/\*proto\*/s/^\/\*proto\* *\(.*\)$/@findex \1\ -@subsubsection @code{\1}/ -# -# /*proto-internal* is just like /*proto* from doc point of view. -/^\/\*proto-internal\*/s/^\/\*proto-internal\* *\(.*\)$/@findex \1\ -@subsubsection @code{\1}/ -# -# *i at beginning of line: rest of line is both a subsubsection heading -# and an entry in function index. -/^\*i/s/^\*i *\(.*\)$/@findex \1\ -@subsubsection @code{\1}/ -# -# Two alternative docn block ends, '*/' and '*-*/' on lines by themselves; -# replace by blank lines (for texinfo source readability). -/^\*\/$/c\ - -/^\*-\*\/$/c\ - -# {* and *} are standins for comment markers (originally embedded in .c -# comments)---turn into real comment markers: -s/{\*/\/\*/ -s/\*}/\*\// -# -# '*+++' and '*---' span a block of text that includes both example lines -# (marked by leading '$') and explanatory text (to be italicized). -# Italicize lines lacking '$': -/\*\+\+\+/,/\*---/s/^\([^$].*\)$/@i{\1}/ -# -# We don't need *+++ and *--- markers any more; kill them (trailing marker -# becomes blank line for readability) -/\*\+\+\+/d -/\*---/c\ - -# Any line beginning with '$' is made an example line; third pass later -# coalesces adjacent example blocks. *DO NOT* introduce extra space after -# @end example, so we can spot adjacent ones in third pass. -/^\$/i\ -@example -/^\$/a\ -@end example -# -# In any example line, turn '{' and '}' into '@{' and '@}' -###/^\$/s/{/@{/g -###/^\$/s/}/@}/g -# -# Now delete the '$' markers themselves: -/^\$/s/\$// -# -# *+ and *- delimit large examples to be enclosed in cartouches. -/^\*\+$/c\ -@lisp\ -@cartouche -/^\*-$/c\ -@end cartouche\ -@end lisp\ - -# '*;' introduces an example which may have a single line or multiple lines; -# it extends until the next semicolon (which is also printed). -# One-line case: (do this first; else second line address for multi-line case -# will include random text til we happen to end a line in a doc comment with -# a semicolon) -/^\*;.*;$/{ -s/^\*;/@example\ -/ -s/;$/;\ -@end example\ -/ -} -# Multi-line case: -/^\*;/,/.*;$/{ -s/^\*;/@example\ -/ -s/;$/;\ -@end example\ -/ -} diff --git a/bfd/sedscript-p b/bfd/sedscript-p deleted file mode 100755 index 1f24900b4cb..00000000000 --- a/bfd/sedscript-p +++ /dev/null @@ -1,63 +0,0 @@ -# SED script for preprocessing embedded headers from source -# (S. Chamberlain markup) -# middle pass; most of the work is done here. -# -# First, get rid of /*proto* markers; they've done their job in the first pass. -# (They remain comment-introducers) -/^\/\*proto\*/s/^\/\*proto\*/\/*/ -/^\/\*proto-internal\*/s/^\/\*proto-internal\*/\/*/ -# -# *-*/ is an alternative (older) comment-block end. Remap for uniformity: -s/^\*-\*\//\*\// -# -# {* and *} are standins for comment markers (originally embedded in .c -# comments)---turn into real comment markers: -s/{\*/\/\*/ -s/\*}/\*\// -# -# '*+++' and '*---' span a block of text that includes both header lines -# (marked by leading '$') and explanatory text (to be comments). -# No need to start comment at "*+++", or end it at "*---", since we're -# already in a *proto* comment block. Just delete. -/\*\+\+\+/d -/\*---/d -# -# Any line beginning with '$' is made a line of code in the header; -# stuff in between is comments, so *precede* each '$' line with -# END-comment, *follow* each '$' line with START-comment; third pass later -# eliminates empty comment blocks. -/^\$/i\ -*/ -/^\$/a\ -/* -# -# Now delete the '$' markers themselves: -/^\$/s/\$// -# -# *+ and *- delimit larger blocks of code, treated the same as '$' lines -/^\*\+$/c\ -*/ -/^\*-$/c\ -/* -# -# '*;' introduces code which may have a single line or multiple lines; -# it extends until the next semicolon (which is also printed). -# -# One-line case: (do this first; else second line address for multi-line case -# will include random text til we happen to end a line in a proto comment with -# a semicolon) -/^\*;.*;$/{ -s/^\*;/*\/\ -/ -s/;$/;\ -\/*\ -/ -} -# Multi-line case: -/^\*;/,/.*;$/{ -s/^\*;/*\/\ -/ -s/;$/;\ -\/*\ -/ -} diff --git a/bfd/srec.c b/bfd/srec.c deleted file mode 100644 index 442ab0ebb5f..00000000000 --- a/bfd/srec.c +++ /dev/null @@ -1,436 +0,0 @@ -/* BFD backend for s-record objects. - Copyright (C) 1990-1991 Free Software Foundation, Inc. - Written by Steve Chamberlain of Cygnus Support . - -This file is part of BFD, the Binary File Descriptor library. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* S-records cannot hold anything but addresses and data, so that's all - that we implement. - - The only interesting thing is that s-records may come out of order and - there is no header, so an initial scan is required to discover the - minimum and maximum addresses used to create the vma and size of the - only section we create. We arbitrarily call this section ".text". - - When bfd_get_section_contents is called the file is read again, and - this time the data is placed into a bfd_alloc'd area. - - Any number of sections may be created for output, we just output them - in the order provided to bfd_set_section_contents. */ - -#include -#include "bfd.h" -#include "libbfd.h" - - -static char digs[] = "0123456789ABCDEF"; - -/* Macros for converting between hex and binary */ - -#define NIBBLE(x) (((x) >= '0' && (x) <= '9') ? ((x) - '0') : ((x) - 'A' + 10)) -#define HEX(buffer) ((NIBBLE((buffer)->high) <<4) + NIBBLE((buffer)->low)) -#define TOHEX(d,x) \ - ((d)->low = digs[(x) & 0xf], (d)->high = digs[((x)>>4)&0xf], (x)) -#define ISHEX(x) (((x) >= '0' && (x) <= '9') || ((x) >= 'A' && (x) <= 'F')) - -typedef struct { - char high; - char low; -} byte_as_two_char_type; - -/* The maximum number of bytes on a line is FF */ -#define MAXCHUNK 0xff -/* The number of bytes we fit onto a line on output */ -#define CHUNK 16 - -/* The shape of an s-record .. */ -typedef struct -{ - char S; - char type; - byte_as_two_char_type size; - union { - struct { - byte_as_two_char_type address[4]; - byte_as_two_char_type data[MAXCHUNK]; - /* If there isn't MAXCHUNK bytes of data then the checksum will - appear earlier */ - byte_as_two_char_type checksum; - char nl; - } type_3; - struct { - byte_as_two_char_type address[4]; - byte_as_two_char_type data[MAXCHUNK]; - byte_as_two_char_type checksum; - char nl; - } type_6; - - struct { - byte_as_two_char_type address[3]; - byte_as_two_char_type data[MAXCHUNK]; - byte_as_two_char_type checksum; - char nl; - } type_2; - - struct { - byte_as_two_char_type address[2]; - byte_as_two_char_type data[MAXCHUNK]; - byte_as_two_char_type checksum; - char nl; - } type_1; - byte_as_two_char_type data[MAXCHUNK]; - } u; -} srec_type; - -#define enda(x) (x->vma + x->size) -/* - called once per input s-record, used to work out vma and size of data. - */ - -static bfd_vma low,high; -static void -size_srec(abfd, section, address, raw, length) -bfd *abfd; -asection *section; -bfd_vma address; -byte_as_two_char_type *raw; -unsigned int length; -{ - if (address < low) - low = address; - if (address + length > high) - high = address + length; -} - - -/* - called once per input s-record, copies data from input into bfd_alloc'd area - */ - -static void -fillup(abfd, section, address, raw, length) -bfd *abfd; -asection *section; -bfd_vma address; -byte_as_two_char_type *raw; -unsigned int length; -{ - unsigned int i; - bfd_byte *dst = (bfd_byte *)(section->used_by_bfd) + address - section->vma; - for (i = 0; i < length; i++) { - *dst = HEX(raw); - dst++; - raw++; - } -} - -/* Pass over an s-record file, calling one of the above functions on each - record. */ - -static void -pass_over(abfd, func, section) - bfd *abfd; - void (*func)(); - asection *section; -{ - unsigned int bytes_on_line; - boolean eof = false; - bfd_vma address; - /* To the front of the file */ - bfd_seek(abfd, (file_ptr)0, SEEK_SET); - while (eof == false) - { - srec_type buffer; - - /* Find first 'S' */ - eof = bfd_read(&buffer.S, 1, 1, abfd) != 1; - while (buffer.S != 'S' && !eof) { - eof = bfd_read(&buffer.S, 1, 1, abfd) != 1; - } - if (eof) break; - - bfd_read(&buffer.type, 1, 3, abfd); - - if (!ISHEX (buffer.size.high) || !ISHEX (buffer.size.low)) - break; - bytes_on_line = HEX(&buffer.size); - if (bytes_on_line > MAXCHUNK/2) - break; - - bfd_read((PTR)buffer.u.data, 1 , bytes_on_line * 2, abfd); - - switch (buffer.type) { - case '6': - /* Prologue - ignore */ - break; - - case '3': - address = (HEX(buffer.u.type_3.address+0) << 24) - + (HEX(buffer.u.type_3.address+1) << 16) - + (HEX(buffer.u.type_3.address+2) << 8) - + (HEX(buffer.u.type_3.address+3)); - func(abfd,section, address, buffer.u.type_3.data, bytes_on_line -1); - break; - - case '2': - address = (HEX(buffer.u.type_2.address+0) << 16) - + (HEX(buffer.u.type_2.address+1) << 8) - + (HEX(buffer.u.type_2.address+2)); - func(abfd,section, address, buffer.u.type_2.data, bytes_on_line -1); - break; - - case '1': - address = (HEX(buffer.u.type_1.address+0) << 8) - + (HEX(buffer.u.type_1.address+1)); - func(abfd, section, address, buffer.u.type_1.data, bytes_on_line -1); - break; - - default: - goto end_of_file; - } - } - end_of_file: ; -} - - -bfd_target * -srec_object_p (abfd) -bfd *abfd; -{ - char b[4]; - asection *section; - bfd_seek(abfd, (file_ptr)0, SEEK_SET); - bfd_read(b, 1, 4, abfd); - if (b[0] != 'S' || !ISHEX(b[1]) || !ISHEX(b[2]) || !ISHEX(b[3])) - return (bfd_target*) NULL; - - /* We create one section called .text for all the contents, - and allocate enough room for the entire file. */ - - section = bfd_make_section(abfd, ".text"); - section->size = 0; - section->vma = 0xffffffff; - low = 0xffffffff; - high = 0; - pass_over(abfd, size_srec, section); - section->size = high - low; - section->vma = low; - return abfd->xvec; -} - - -static boolean -srec_get_section_contents (abfd, section, location, offset, count) -bfd *abfd; -sec_ptr section; -void *location; -file_ptr offset; -unsigned int count; -{ - if (section->used_by_bfd == (PTR)NULL) { - section->used_by_bfd = (PTR)bfd_alloc (abfd, section->size); - pass_over(abfd, fillup, section); - } - (void) memcpy((PTR)location, (PTR)((char *)(section->used_by_bfd) + offset), count); - return true; -} - - - -boolean -srec_set_arch_mach (abfd, arch, machine) -bfd *abfd; -enum bfd_architecture arch; -unsigned long machine; -{ - abfd->obj_arch = arch; - abfd->obj_machine = machine; - return true; -} - - - -boolean -srec_set_section_contents (abfd, section, location, offset, bytes_to_do) -bfd *abfd; -sec_ptr section; -unsigned char *location; -file_ptr offset; -int bytes_to_do; -{ - bfd_vma address; - int bytes_written; - - int type; - unsigned int i; - srec_type buffer; - bytes_written = 0; - if (section->vma <= 0xffff) - type = 1; - else if (section->vma <= 0xffffff) - type = 2; - else - type = 3; - - buffer.S = 'S'; - buffer.type = '0' + type; - - while (bytes_written < bytes_to_do) { - unsigned int size; - unsigned int check_sum; - byte_as_two_char_type *data; - unsigned int bytes_this_chunk = bytes_to_do - bytes_written; - - if (bytes_this_chunk > CHUNK) { - bytes_this_chunk = CHUNK; - } - - address = section->vma + offset + bytes_written; - - switch (type) { - case 3: - check_sum = TOHEX(buffer.u.type_3.address, address >> 24); - check_sum += TOHEX(buffer.u.type_3.address+1, address >> 16); - check_sum += TOHEX(buffer.u.type_3.address+2, address >> 8); - check_sum += TOHEX(buffer.u.type_3.address+3, address >> 0); - size = bytes_this_chunk + 5; - data = buffer.u.type_3.data; - break; - case 2: - check_sum = TOHEX(buffer.u.type_3.address, address >> 16); - check_sum += TOHEX(buffer.u.type_3.address+1, address >> 8); - check_sum += TOHEX(buffer.u.type_3.address+2, address >> 0); - size = bytes_this_chunk + 4; - data = buffer.u.type_2.data; - break; - - case 1: - check_sum = TOHEX(buffer.u.type_3.address+0, address >> 8); - check_sum += TOHEX(buffer.u.type_3.address+1, address >> 0); - size = bytes_this_chunk + 3; - data = buffer.u.type_1.data; - break; - } - - for (i = 0; i < bytes_this_chunk; i++) { - check_sum += TOHEX(data, (location[i])); - data++; - } - - check_sum += TOHEX(&(buffer.size), size ); - (void) TOHEX(data, ~check_sum); - data++; - - * ( (char *)(data)) = '\n'; - bfd_write((PTR)&buffer, 1, (char *)data - (char *)&buffer + 1 , abfd); - - bytes_written += bytes_this_chunk; - location += bytes_this_chunk; - } - - - return true; -} - -boolean -srec_write_object_contents (abfd) - bfd *abfd; -{ - bfd_write("S9030000FC\n", 1,11,abfd); - return true; -} - -static int -DEFUN(srec_sizeof_headers,(abfd, exec), - bfd *abfd AND - boolean exec) -{ -return 0; -} - -static asymbol * -DEFUN(srec_make_empty_symbol, (abfd), - bfd*abfd) -{ - asymbol *new= (asymbol *)bfd_zalloc (abfd, sizeof (asymbol)); - new->the_bfd = abfd; - return new; -} -#define FOO PROTO -#define srec_new_section_hook (FOO(boolean, (*), (bfd *, asection *)))bfd_true -#define srec_get_symtab_upper_bound (PROTO(unsigned int, (*),(bfd *)))bfd_false -#define srec_get_symtab (FOO(unsigned int, (*), (bfd *, asymbol **)))bfd_0 -#define srec_get_reloc_upper_bound (FOO(unsigned int, (*),(bfd*, asection *)))bfd_false -#define srec_canonicalize_reloc (FOO(unsigned int, (*),(bfd*,asection *, arelent **, asymbol **))) bfd_0 - -#define srec_print_symbol (FOO(void,(*),(bfd *, PTR, asymbol *, bfd_print_symbol_enum_type))) bfd_void - -#define srec_openr_next_archived_file (FOO(bfd *, (*), (bfd*,bfd*))) bfd_nullvoidptr -#define srec_find_nearest_line (FOO(boolean, (*),(bfd*,asection*,asymbol**,bfd_vma, CONST char**, CONST char**, unsigned int *))) bfd_false -#define srec_generic_stat_arch_elt (FOO(int, (*), (bfd *,struct stat *))) bfd_0 - - -#define srec_core_file_failing_command (char *(*)())(bfd_nullvoidptr) -#define srec_core_file_failing_signal (int (*)())bfd_0 -#define srec_core_file_matches_executable_p (FOO(boolean, (*),(bfd*, bfd*)))bfd_false -#define srec_slurp_armap bfd_true -#define srec_slurp_extended_name_table bfd_true -#define srec_truncate_arname (void (*)())bfd_nullvoidptr -#define srec_write_armap (FOO( boolean, (*),(bfd *, unsigned int, struct orl *, int, int))) bfd_nullvoidptr -#define srec_get_lineno (struct lineno_cache_entry *(*)())bfd_nullvoidptr -#define srec_close_and_cleanup bfd_generic_close_and_cleanup -#define srec_bfd_debug_info_start bfd_void -#define srec_bfd_debug_info_end bfd_void -#define srec_bfd_debug_info_accumulate (FOO(void, (*), (bfd *, asection *))) bfd_void - - -bfd_target srec_vec = -{ - "srec", /* name */ - bfd_target_srec_flavour_enum, - true, /* target byte order */ - true, /* target headers byte order */ - (HAS_RELOC | EXEC_P | /* object flags */ - HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED), - (SEC_CODE|SEC_DATA|SEC_ROM|SEC_HAS_CONTENTS - |SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ - ' ', /* ar_pad_char */ - 16, /* ar_max_namelen */ - 1, /* minimum alignment */ - _do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* data */ - _do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* hdrs */ - - {_bfd_dummy_target, - srec_object_p, /* bfd_check_format */ - (struct bfd_target *(*)()) bfd_nullvoidptr, - (struct bfd_target *(*)()) bfd_nullvoidptr, - }, - { - bfd_false, - bfd_true, /* mkobject */ - _bfd_generic_mkarchive, - bfd_false, - }, - { /* bfd_write_contents */ - bfd_false, - srec_write_object_contents, - _bfd_write_archive_contents, - bfd_false, - }, - JUMP_TABLE(srec) - }; diff --git a/bfd/startcom-p b/bfd/startcom-p deleted file mode 100755 index 0748faddbf7..00000000000 --- a/bfd/startcom-p +++ /dev/null @@ -1,12 +0,0 @@ -# sed script for preprocessing BFD header files -# activity: -/^\/\*$/{ -N -# Delete empty comment blocks -/^\/\*\n\*\/ *$/d -# Transpose -s/^\/\*\n *$/\ -\/*/ -# merge on line by itself with following line -s/^\/\*\n\(.*\)/\/* \1/ -} diff --git a/bfd/sunos.c b/bfd/sunos.c deleted file mode 100644 index a451a48914e..00000000000 --- a/bfd/sunos.c +++ /dev/null @@ -1,627 +0,0 @@ -/* BFD backend for sunos binaries */ - -/* Copyright (C) 1990, 1991 Free Software Foundation, Inc. - -This file is part of BFD, the Binary File Diddler. - -BFD 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 1, or (at your option) -any later version. - -BFD 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 BFD; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* $Id$ */ - -#include -#include "sysdep.h" -#include "bfd.h" -#include "libbfd.h" - -#include "a.out.sun4.h" -#include "a.out.gnu.h" -#include "stab.gnu.h" -#include "ar.h" -#include "liba.out.h" /* BFD a.out internal data structures */ - -void (*bfd_error_trap)(); - -static bfd_target *sunos4_callback (); - -/*SUPPRESS558*/ -/*SUPPRESS529*/ - -bfd_target * -sunos4_object_p (abfd) - bfd *abfd; -{ - unsigned char magicbuf[4]; /* Raw bytes of magic number from file */ - unsigned long magic; /* Swapped magic number */ - - bfd_error = system_call_error; - - if (bfd_read ((PTR)magicbuf, 1, sizeof (magicbuf), abfd) != - sizeof (magicbuf)) - return 0; - magic = bfd_h_getlong (abfd, magicbuf); - - if (N_BADMAG (*((struct exec *) &magic))) return 0; - - return some_aout_object_p (abfd, sunos4_callback); -} - - /* Determine the size of a relocation entry, based on the architecture */ -static void -DEFUN(choose_reloc_size,(abfd), -bfd *abfd) - { - switch (abfd->obj_arch) { - case bfd_arch_sparc: - case bfd_arch_a29k: - obj_reloc_entry_size (abfd) = RELOC_EXT_SIZE; - break; - default: - obj_reloc_entry_size (abfd) = RELOC_STD_SIZE; - break; - } - } - -/* Set parameters about this a.out file that are machine-dependent. - This routine is called from some_aout_object_p just before it returns. */ - -static bfd_target * -sunos4_callback (abfd) - bfd *abfd; -{ - struct exec *execp = exec_hdr (abfd); - - /* The virtual memory addresses of the sections */ - obj_datasec (abfd)->vma = N_DATADDR(*execp); - obj_bsssec (abfd)->vma = N_BSSADDR(*execp); - obj_textsec (abfd)->vma = N_TXTADDR(*execp); - - /* The file offsets of the sections */ - obj_textsec (abfd)->filepos = EXEC_BYTES_SIZE; /*N_TXTOFF(*execp);*/ - obj_datasec (abfd)->filepos = N_DATOFF(*execp); - - /* The file offsets of the relocation info */ - obj_textsec (abfd)->rel_filepos = N_TRELOFF(*execp); - obj_datasec (abfd)->rel_filepos = N_DRELOFF(*execp); - - /* The file offsets of the string table and symbol table. */ - obj_str_filepos (abfd) = N_STROFF (*execp); - obj_sym_filepos (abfd) = N_SYMOFF (*execp); - - - - /* Determine the architecture and machine type of the object file. */ - switch (N_MACHTYPE (*exec_hdr (abfd))) { - - case M_UNKNOWN: - abfd->obj_arch = bfd_arch_unknown; - abfd->obj_machine = 0; - break; - - case M_68010: - abfd->obj_arch = bfd_arch_m68k; - abfd->obj_machine = 68010; - break; - - case M_68020: - abfd->obj_arch = bfd_arch_m68k; - abfd->obj_machine = 68020; - break; - - case M_SPARC: - abfd->obj_arch = bfd_arch_sparc; - abfd->obj_machine = 0; - break; - - case M_386: - abfd->obj_arch = bfd_arch_i386; - abfd->obj_machine = 0; - break; - - case M_29K: - abfd->obj_arch = bfd_arch_a29k; - abfd->obj_machine = 0; - break; - - default: - abfd->obj_arch = bfd_arch_obscure; - abfd->obj_machine = 0; - break; - } - - choose_reloc_size(abfd); - return abfd->xvec; -} - - -boolean -sunos4_mkobject (abfd) - bfd *abfd; -{ - char *rawptr; - - bfd_error = system_call_error; - - /* Use an intermediate variable for clarity */ - rawptr = bfd_zalloc (abfd, sizeof (struct aoutdata) + sizeof (struct exec)); - - if (rawptr == NULL) { - bfd_error = no_memory; - return false; - } - - set_tdata (abfd, (struct aoutdata *) rawptr); - exec_hdr (abfd) = (struct exec *) (rawptr + sizeof (struct aoutdata)); - - /* For simplicity's sake we just make all the sections right here. */ - - obj_textsec (abfd) = (asection *)NULL; - obj_datasec (abfd) = (asection *)NULL; - obj_bsssec (abfd) = (asection *)NULL; - bfd_make_section (abfd, ".text"); - bfd_make_section (abfd, ".data"); - bfd_make_section (abfd, ".bss"); - - return true; -} - -/* Keep track of machine architecture and machine type for a.out's. - Return the machine_type for a particular arch&machine, or M_UNKNOWN - if that exact arch&machine can't be represented in a.out format. - - If the architecture is understood, machine type 0 (default) should - always be understood. */ - -static enum machine_type -aout_machine_type (arch, machine) - enum bfd_architecture arch; - unsigned long machine; -{ - enum machine_type arch_flags; - - arch_flags = M_UNKNOWN; - - switch (arch) { - case bfd_arch_sparc: - if (machine == 0) arch_flags = M_SPARC; - break; - - case bfd_arch_m68k: - switch (machine) { - case 0: arch_flags = M_68010; break; - case 68000: arch_flags = M_UNKNOWN; break; - case 68010: arch_flags = M_68010; break; - case 68020: arch_flags = M_68020; break; - default: arch_flags = M_UNKNOWN; break; - } - break; - - case bfd_arch_i386: - if (machine == 0) arch_flags = M_386; - break; - - case bfd_arch_a29k: - if (machine == 0) arch_flags = M_29K; - break; - - default: - arch_flags = M_UNKNOWN; - break; - } - return arch_flags; -} - -/* Write an object file in SunOS format. - Section contents have already been written. We write the - file header, symbols, and relocation. */ - -boolean -sunos4_write_object_contents (abfd) - bfd *abfd; -{ - size_t data_pad = 0; - unsigned char exec_bytes[EXEC_BYTES_SIZE]; - struct exec *execp = exec_hdr (abfd); - - - - execp->a_text = obj_textsec (abfd)->size; - - /* Magic number, maestro, please! */ - switch (bfd_get_architecture(abfd)) { - case bfd_arch_m68k: - switch (bfd_get_machine(abfd)) { - case 68010: - N_SET_MACHTYPE(*execp, M_68010); - break; - default: - case 68020: - N_SET_MACHTYPE(*execp, M_68020); - break; - } - break; - case bfd_arch_sparc: - N_SET_MACHTYPE(*execp, M_SPARC); - break; - case bfd_arch_i386: - N_SET_MACHTYPE(*execp, M_386); - break; - case bfd_arch_a29k: - N_SET_MACHTYPE(*execp, M_29K); - break; - default: - N_SET_MACHTYPE(*execp, M_UNKNOWN); - } - - choose_reloc_size(abfd); - - N_SET_MAGIC (*execp, OMAGIC); - if (abfd->flags & D_PAGED) { - /* This is not strictly true, but will probably do for the default - case. FIXME. - */ - - execp->a_text = obj_textsec (abfd)->size + EXEC_BYTES_SIZE; - N_SET_MAGIC (*execp, ZMAGIC); - } else if (abfd->flags & WP_TEXT) { - N_SET_MAGIC (*execp, NMAGIC); - } - N_SET_FLAGS (*execp, 0x1); /* copied from ld.c; who the hell knows? */ - - if (abfd->flags & D_PAGED) - { - data_pad = ((obj_datasec(abfd)->size + PAGE_SIZE -1) - & (- PAGE_SIZE)) - obj_datasec(abfd)->size; - - if (data_pad > obj_bsssec(abfd)->size) - execp->a_bss = 0; - else - execp->a_bss = obj_bsssec(abfd)->size - data_pad; - execp->a_data = obj_datasec(abfd)->size + data_pad; - - } - else { - execp->a_data = obj_datasec (abfd)->size; - execp->a_bss = obj_bsssec (abfd)->size; - } - - execp->a_syms = bfd_get_symcount (abfd) * sizeof (struct nlist); - execp->a_entry = bfd_get_start_address (abfd); - - - - - execp->a_trsize = ((obj_textsec (abfd)->reloc_count) * - obj_reloc_entry_size (abfd)); - - execp->a_drsize = ((obj_datasec (abfd)->reloc_count) * - obj_reloc_entry_size (abfd)); - - bfd_aout_swap_exec_header_out (abfd, execp, exec_bytes); - - bfd_seek (abfd, 0L, false); - bfd_write ((PTR) exec_bytes, 1, EXEC_BYTES_SIZE, abfd); - - /* Now write out reloc info, followed by syms and strings */ - - if (bfd_get_symcount (abfd) != 0) - { - bfd_seek (abfd, - (long)(N_SYMOFF(*execp)), false); - - aout_write_syms (abfd); - - bfd_seek (abfd, (long)(N_TRELOFF(*execp)), false); - - if (!aout_squirt_out_relocs (abfd, obj_textsec (abfd))) return false; - bfd_seek (abfd, (long)(N_DRELOFF(*execp)), false); - - if (!aout_squirt_out_relocs (abfd, obj_datasec (abfd))) return false; - } - return true; -} - -/* core files */ - -#define CORE_MAGIC 0x080456 -#define CORE_NAMELEN 16 - -/* The core structure is taken from the Sun documentation. - Unfortunately, they don't document the FPA structure, or at least I - can't find it easily. Fortunately the core header contains its own - length. So this shouldn't cause problems, except for c_ucode, which - so far we don't use but is easy to find with a little arithmetic. */ - -/* But the reg structure can be gotten from the SPARC processor handbook. - This really should be in a GNU include file though so that gdb can use - the same info. */ -struct regs { - int r_psr; - int r_pc; - int r_npc; - int r_y; - int r_g1; - int r_g2; - int r_g3; - int r_g4; - int r_g5; - int r_g6; - int r_g7; - int r_o0; - int r_o1; - int r_o2; - int r_o3; - int r_o4; - int r_o5; - int r_o6; - int r_o7; -}; - -/* Taken from Sun documentation: */ - -/* FIXME: It's worse than we expect. This struct contains TWO substructs - neither of whose size we know, WITH STUFF IN BETWEEN THEM! We can't - even portably access the stuff in between! */ - -struct core { - int c_magic; /* Corefile magic number */ - int c_len; /* Sizeof (struct core) */ - struct regs c_regs; /* General purpose registers -- MACHDEP SIZE */ - struct exec c_aouthdr; /* A.out header */ - int c_signo; /* Killing signal, if any */ - int c_tsize; /* Text size (bytes) */ - int c_dsize; /* Data size (bytes) */ - int c_ssize; /* Stack size (bytes) */ - char c_cmdname[CORE_NAMELEN + 1]; /* Command name */ - double fp_stuff[1]; /* external FPU state (size unknown by us) */ - /* The type "double" is critical here, for alignment. - SunOS declares a struct here, but the struct's alignment - is double since it contains doubles. */ - int c_ucode; /* Exception no. from u_code */ - /* (this member is not accessible by name since we don't - portably know the size of fp_stuff.) */ -}; - -/* Supposedly the user stack grows downward from the bottom of kernel memory. - Presuming that this remains true, this definition will work. */ -#define USRSTACK (-(128*1024*1024)) - -PROTO (static void, swapcore, (bfd *abfd, struct core *core)); - -/* need this cast b/c ptr is really void * */ -#define core_hdr(bfd) (((struct suncordata *) (bfd->tdata))->hdr) -#define core_datasec(bfd) (((struct suncordata *) ((bfd)->tdata))->data_section) -#define core_stacksec(bfd) (((struct suncordata*)((bfd)->tdata))->stack_section) -#define core_regsec(bfd) (((struct suncordata *) ((bfd)->tdata))->reg_section) -#define core_reg2sec(bfd) (((struct suncordata *) ((bfd)->tdata))->reg2_section) - -/* These are stored in the bfd's tdata */ -struct suncordata { - struct core *hdr; /* core file header */ - asection *data_section; - asection *stack_section; - asection *reg_section; - asection *reg2_section; -}; - -bfd_target * -sunos4_core_file_p (abfd) - bfd *abfd; -{ - unsigned char longbuf[4]; /* Raw bytes of various header fields */ - int core_size; - int core_mag; - struct core *core; - char *rawptr; - - bfd_error = system_call_error; - - if (bfd_read ((PTR)longbuf, 1, sizeof (longbuf), abfd) != - sizeof (longbuf)) - return 0; - core_mag = bfd_h_getlong (abfd, longbuf); - - if (core_mag != CORE_MAGIC) return 0; - - /* SunOS core headers can vary in length; second word is size; */ - if (bfd_read ((PTR)longbuf, 1, sizeof (longbuf), abfd) != - sizeof (longbuf)) - return 0; - core_size = bfd_h_getlong (abfd, longbuf); - /* Sanity check */ - if (core_size > 20000) - return 0; - - if (bfd_seek (abfd, 0L, false) < 0) return 0; - - rawptr = bfd_zalloc (abfd, core_size + sizeof (struct suncordata)); - if (rawptr == NULL) { - bfd_error = no_memory; - return 0; - } - - core = (struct core *) (rawptr + sizeof (struct suncordata)); - - if ((bfd_read ((PTR) core, 1, core_size, abfd)) != core_size) { - bfd_error = system_call_error; - bfd_release (abfd, rawptr); - return 0; - } - - swapcore (abfd, core); - set_tdata (abfd, ((struct suncordata *) rawptr)); - core_hdr (abfd) = core; - - /* create the sections. This is raunchy, but bfd_close wants to reclaim - them */ - core_stacksec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection)); - if (core_stacksec (abfd) == NULL) { -loser: - bfd_error = no_memory; - bfd_release (abfd, rawptr); - return 0; - } - core_datasec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection)); - if (core_datasec (abfd) == NULL) { -loser1: - bfd_release (abfd, core_stacksec (abfd)); - goto loser; - } - core_regsec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection)); - if (core_regsec (abfd) == NULL) { -loser2: - bfd_release (abfd, core_datasec (abfd)); - goto loser1; - } - core_reg2sec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection)); - if (core_reg2sec (abfd) == NULL) { - bfd_release (abfd, core_regsec (abfd)); - goto loser2; - } - - core_stacksec (abfd)->name = ".stack"; - core_datasec (abfd)->name = ".data"; - core_regsec (abfd)->name = ".reg"; - core_reg2sec (abfd)->name = ".reg2"; - - core_stacksec (abfd)->flags = SEC_ALLOC + SEC_LOAD; - core_datasec (abfd)->flags = SEC_ALLOC + SEC_LOAD; - core_regsec (abfd)->flags = SEC_ALLOC; - core_reg2sec (abfd)->flags = SEC_ALLOC; - - core_stacksec (abfd)->size = core->c_ssize; - core_datasec (abfd)->size = core->c_dsize; - core_regsec (abfd)->size = (sizeof core->c_regs); - /* Float regs take up end of struct, except c_ucode. */ - core_reg2sec (abfd)->size = core_size - (sizeof core->c_ucode) - - (file_ptr)(((struct core *)0)->fp_stuff); - - core_stacksec (abfd)->vma = (USRSTACK - core->c_ssize); - core_datasec (abfd)->vma = N_DATADDR(core->c_aouthdr); - core_regsec (abfd)->vma = -1; - core_reg2sec (abfd)->vma = -1; - - core_stacksec (abfd)->filepos = core->c_len + core->c_dsize; - core_datasec (abfd)->filepos = core->c_len; - /* In file header: */ - core_regsec (abfd)->filepos = (file_ptr)(&((struct core *)0)->c_regs); - core_reg2sec (abfd)->filepos = (file_ptr)(((struct core *)0)->fp_stuff); - - /* Align to word at least */ - core_stacksec (abfd)->alignment_power = 2; - core_datasec (abfd)->alignment_power = 2; - core_regsec (abfd)->alignment_power = 2; - core_reg2sec (abfd)->alignment_power = 2; - - abfd->sections = core_stacksec (abfd); - core_stacksec (abfd)->next = core_datasec (abfd); - core_datasec (abfd)->next = core_regsec (abfd); - core_regsec (abfd)->next = core_reg2sec (abfd); - - abfd->section_count = 4; - - return abfd->xvec; -} - -char * -sunos4_core_file_failing_command (abfd) - bfd *abfd; -{ - return core_hdr (abfd)->c_cmdname; -} - -int -sunos4_core_file_failing_signal (abfd) - bfd *abfd; -{ - return core_hdr (abfd)->c_signo; -} - -boolean -sunos4_core_file_matches_executable_p (core_bfd, exec_bfd) - bfd *core_bfd, *exec_bfd; -{ - if (core_bfd->xvec != exec_bfd->xvec) { - bfd_error = system_call_error; - return false; - } - - return (bcmp ((char *)&core_hdr (core_bfd), (char*) &exec_hdr (exec_bfd), - sizeof (struct exec)) == 0) ? true : false; -} - -/* byte-swap core structure */ -/* FIXME, this needs more work to swap IN a core struct from raw bytes */ -static void -swapcore (abfd, core) - bfd *abfd; - struct core *core; -{ - unsigned char exec_bytes[EXEC_BYTES_SIZE]; - - core->c_magic = bfd_h_getlong (abfd, (unsigned char *)&core->c_magic); - core->c_len = bfd_h_getlong (abfd, (unsigned char *)&core->c_len ); - /* Leave integer registers in target byte order. */ - bcopy ((char *)&(core->c_aouthdr), (char *)exec_bytes, EXEC_BYTES_SIZE); - bfd_aout_swap_exec_header_in (abfd, exec_bytes, &core->c_aouthdr); - core->c_signo = bfd_h_getlong (abfd, (unsigned char *)&core->c_signo); - core->c_tsize = bfd_h_getlong (abfd, (unsigned char *)&core->c_tsize); - core->c_dsize = bfd_h_getlong (abfd, (unsigned char *)&core->c_dsize); - core->c_ssize = bfd_h_getlong (abfd, (unsigned char *)&core->c_ssize); - /* Leave FP registers in target byte order. */ - /* Leave "c_ucode" unswapped for now, since we can't find it easily. */ -} - -/* We use BFD generic archive files. */ -#define aout_openr_next_archived_file bfd_generic_openr_next_archived_file -#define aout_generic_stat_arch_elt bfd_generic_stat_arch_elt -#define aout_slurp_armap bfd_slurp_bsd_armap -#define aout_slurp_extended_name_table bfd_true -#define aout_write_armap bsd_write_armap -#define aout_truncate_arname bfd_bsd_truncate_arname - -/* We use our own core file format. */ -#define aout_core_file_failing_command sunos4_core_file_failing_command -#define aout_core_file_failing_signal sunos4_core_file_failing_signal -#define aout_core_file_matches_executable_p \ - sunos4_core_file_matches_executable_p - -/* We implement these routines ourselves, rather than using the generic - a.out versions. */ -#define aout_write_object_contents sunos4_write_object_contents - -bfd_target sunos_big_vec = -{ - "a.out-sunos-big", /* name */ - bfd_target_aout_flavour_enum, - true, /* target byte order */ - true, /* target headers byte order */ - (HAS_RELOC | EXEC_P | /* object flags */ - HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED), - (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ - ' ', /* ar_pad_char */ - 16, /* ar_max_namelen */ - _do_getblong, _do_putblong, _do_getbshort, _do_putbshort, /* data */ - _do_getblong, _do_putblong, _do_getbshort, _do_putbshort, /* hdrs */ - - {_bfd_dummy_target, sunos4_object_p, - bfd_generic_archive_p, sunos4_core_file_p}, - {bfd_false, sunos4_mkobject, - _bfd_generic_mkarchive, bfd_false}, - {bfd_false, sunos4_write_object_contents, /* bfd_write_contents */ - _bfd_write_archive_contents, bfd_false}, - - JUMP_TABLE(aout) -}; diff --git a/bfd/syms.c b/bfd/syms.c deleted file mode 100644 index 30effa2cb31..00000000000 --- a/bfd/syms.c +++ /dev/null @@ -1,445 +0,0 @@ -/* Generic symbol-table support for the BFD library. - Copyright (C) 1990-1991 Free Software Foundation, Inc. - Written by Cygnus Support. - -This file is part of BFD, the Binary File Descriptor library. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/*doc* -@section Symbols -BFD trys to maintain as much symbol information as it can when it -moves information from file to file. BFD passes information to -applications though the @code{asymbol} structure. When the application -requests the symbol table, BFD reads the table in the native form and -translates parts of it into the internal format. To maintain more than -the infomation passed to applications some targets keep -some information 'behind the sceans', in a structure only the -particular back end knows about. For example, the coff back end keeps -the original symbol table structure as well as the canonical structure -when a BFD is read in. On output, the coff back end can reconstruct -the output symbol table so that no information is lost, even -information unique to coff which BFD doesn't know or understand. If a -coff symbol table was read, but was written through an a.out back end, -all the coff specific information would be lost. (.. until BFD 2 :). - -The symbol table of a BFD is not necessarily read in until a -canonicalize request is made. Then the BFD back end fills in a table -provided by the application with pointers to the canonical -information. - -To output symbols, the application provides BFD with a table of -pointers to pointers to @code{asymbol}s. This allows applications like -the linker to output a symbol as read, since the 'behind the sceens' -information will be still available. - -@menu -* Reading Symbols:: -* Writing Symbols:: -* typedef asymbol:: -* symbol handling functions:: -@end menu - -@node Reading Symbols, Writing Symbols, Symbols, Symbols -@subsection Reading Symbols -There are two stages to reading a symbol table from a BFD; allocating -storage, and the actual reading process. This is an excerpt from an -appliction which reads the symbol table: - -*+ - unsigned int storage_needed; - asymbol **symbol_table; - unsigned int number_of_symbols; - unsigned int i; - - storage_needed = get_symtab_upper_bound (abfd); - - if (storage_needed == 0) { - return ; - } - symbol_table = (asymbol **) bfd_xmalloc (storage_needed); - ... - number_of_symbols = - bfd_canonicalize_symtab (abfd, symbol_table); - - for (i = 0; i < number_of_symbols; i++) { - process_symbol (symbol_table[i]); - } -*- - -All storage for the symbols themselves is in an obstack connected to -the BFD, and is freed when the BFD is closed. - -@node Writing Symbols, typedef asymbol, Reading Symbols, Symbols -@subsection Writing Symbols -Writing of a symbol table is automatic when a BFD open for writing -is closed. The application attaches a vector of pointers to pointers to symbols -to the BFD being written, and fills in the symbol count. The close and -cleanup code reads through the table provided and performs all the -necessary operations. The outputing code must always be provided with -an 'owned' symbol; one which has come from another BFD, or one which -has been created using @code{bfd_make_empty_symbol}. - -An example showing the creation of a symbol table with only one -element: - -*+ -#include "bfd.h" -main() -{ - bfd *abfd; - asymbol *ptrs[2]; - asymbol *new; - - abfd = bfd_openw("foo","a.out-sunos-big"); - bfd_set_format(abfd, bfd_object); - new = bfd_make_empty_symbol(abfd); - new->name = "dummy_symbol"; - new->section = (asection *)0; - new->flags = BSF_ABSOLUTE | BSF_GLOBAL; - new->value = 0x12345; - - ptrs[0] = new; - ptrs[1] = (asymbol *)0; - - bfd_set_symtab(abfd, ptrs, 1); - bfd_close(abfd); -} - -./makesym -nm foo -00012345 A dummy_symbol - - -*- - -Many formats cannot represent arbitary symbol information; for -instance the @code{a.out} object format does not allow an arbitary -number of sections. A symbol pointing to a section which is not one of -@code{.text}, @code{.data} or @code{.bss} cannot be described. -*/ - - -/*doc* -@node typedef asymbol, symbol handling functions, Writing Symbols, Symbols - -*/ -/*proto* -@subsection typedef asymbol -An @code{asymbol} has the form: - -*+++ - -$typedef struct symbol_cache_entry -${ -A pointer to the BFD which owns the symbol. This information is -necessary so that a back end can work out what additional (invisible to -the application writer) information is carried with the symbol. - -$ struct _bfd *the_bfd; - -The text of the symbol. The name is left alone, and not copied - the -application may not alter it. - -$ CONST char *name; - -The value of the symbol. - -$ symvalue value; - -Attributes of a symbol: - -$#define BSF_NO_FLAGS 0x00 - -The symbol has local scope; @code{static} in @code{C}. The value is -the offset into the section of the data. - -$#define BSF_LOCAL 0x01 - -The symbol has global scope; initialized data in @code{C}. The value -is the offset into the section of the data. - -$#define BSF_GLOBAL 0x02 - -Obsolete - -$#define BSF_IMPORT 0x04 - -The symbol has global scope, and is exported. The value is the offset -into the section of the data. - -$#define BSF_EXPORT 0x08 - -The symbol is undefined. @code{extern} in @code{C}. The value has no meaning. - -$#define BSF_UNDEFINED 0x10 - -The symbol is common, initialized to zero; default in @code{C}. The -value is the size of the object in bytes. - -$#define BSF_FORT_COMM 0x20 - -A normal @code{C} symbol would be one of: -@code{BSF_LOCAL}, @code{BSF_FORT_COMM}, @code{BSF_UNDEFINED} or @code{BSF_EXPORT|BSD_GLOBAL} - -The symbol is a debugging record. The value has an arbitary meaning. - -$#define BSF_DEBUGGING 0x40 - -The symbol has no section attached, any value is the actual value and -is not a relative offset to a section. - -$#define BSF_ABSOLUTE 0x80 - -Used by the linker - -$#define BSF_KEEP 0x10000 -$#define BSF_KEEP_G 0x80000 - -Unused - -$#define BSF_WEAK 0x100000 -$#define BSF_CTOR 0x200000 -$#define BSF_FAKE 0x400000 - -The symbol used to be a common symbol, but now it is allocated. - -$#define BSF_OLD_COMMON 0x800000 - -The default value for common data. - -$#define BFD_FORT_COMM_DEFAULT_VALUE 0 - -In some files the type of a symbol sometimes alters its location -in an output file - ie in coff a @code{ISFCN} symbol which is also @code{C_EXT} -symbol appears where it was declared and not at the end of a section. -This bit is set by the target BFD part to convey this information. - -$#define BSF_NOT_AT_END 0x40000 - -Signal that the symbol is the label of constructor section. - -$#define BSF_CONSTRUCTOR 0x1000000 - -Signal that the symbol is a warning symbol. If the symbol is a warning -symbol, then the value field (I know this is tacky) will point to the -asymbol which when referenced will cause the warning. - -$#define BSF_WARNING 0x2000000 - -Signal that the symbol is indirect. The value of the symbol is a -pointer to an undefined asymbol which contains the name to use -instead. - -$#define BSF_INDIRECT 0x4000000 - -$ flagword flags; - -A pointer to the section to which this symbol is relative, or 0 if the -symbol is absolute or undefined. Note that it is not sufficient to set -this location to 0 to mark a symbol as absolute - the flag -@code{BSF_ABSOLUTE} must be set also. - -$ struct sec *section; - -Back end special data. This is being phased out in favour of making -this a union. - -$ PTR udata; -$} asymbol; -*--- - -*/ - -#include "bfd.h" -#include "sysdep.h" -#include "libbfd.h" -#include "stab.gnu.h" - -/*doc* -@node symbol handling functions, , typedef asymbol, Symbols -@subsection Symbol Handling Functions - -*/ - -/*proto* get_symtab_upper_bound -Returns the number of bytes required in a vector of pointers to -@code{asymbols} for all the symbols in the supplied BFD, including a -terminal NULL pointer. If there are no symbols in the BFD, then 0 is -returned. -*+ -#define get_symtab_upper_bound(abfd) \ - BFD_SEND (abfd, _get_symtab_upper_bound, (abfd)) -*- - -*/ - -/*proto* bfd_canonicalize_symtab -Supplied a BFD and a pointer to an uninitialized vector of pointers. -This reads in the symbols from the BFD, and fills in the table with -pointers to the symbols, and a trailing NULL. The routine returns the -actual number of symbol pointers not including the NULL. - -*+ -#define bfd_canonicalize_symtab(abfd, location) \ - BFD_SEND (abfd, _bfd_canonicalize_symtab,\ - (abfd, location)) - -*- -*/ - - -/*proto* bfd_set_symtab -Provided a table of pointers to symbols and a count, writes to the -output BFD the symbols when closed. - -*; PROTO(boolean, bfd_set_symtab, (bfd *, asymbol **, unsigned int )); -*/ - -boolean -bfd_set_symtab (abfd, location, symcount) - bfd *abfd; - asymbol **location; - unsigned int symcount; -{ - if ((abfd->format != bfd_object) || (bfd_read_p (abfd))) { - bfd_error = invalid_operation; - return false; - } - - bfd_get_outsymbols (abfd) = location; - bfd_get_symcount (abfd) = symcount; - return true; -} - -/*proto* bfd_print_symbol_vandf -Prints the value and flags of the symbol supplied to the stream file. - -*; PROTO(void, bfd_print_symbol_vandf, (PTR file, asymbol *symbol)); -*/ -void -DEFUN(bfd_print_symbol_vandf,(file, symbol), -PTR file AND -asymbol *symbol) -{ - flagword type = symbol->flags; - if (symbol->section != (asection *)NULL) - { - fprintf_vma(file, symbol->value+symbol->section->vma); - } - else - { - fprintf_vma(file, symbol->value); - } - fprintf(file," %c%c%c%c%c%c%c%c%c%c", - (type & BSF_LOCAL) ? 'l':' ', - (type & BSF_GLOBAL) ? 'g' : ' ', - (type & BSF_IMPORT) ? 'i' : ' ', - (type & BSF_EXPORT) ? 'e' : ' ', - (type & BSF_UNDEFINED) ? 'u' : ' ', - (type & BSF_FORT_COMM) ? 'c' : ' ', - (type & BSF_CONSTRUCTOR) ? 'C' : ' ', - (type & BSF_WARNING) ? 'W' : ' ', - (type & BSF_INDIRECT) ? 'I' : ' ', - (type & BSF_DEBUGGING) ? 'd' :' '); - -} - - -/*proto* bfd_make_empty_symbol -This function creates a new @code{asymbol} structure for the BFD, and -returns a pointer to it. - -This routine is necessary, since each back end has private information -surrounding the @code{asymbol}. Building your own @code{asymbol} and -pointing to it will not create the private information, and will cause -problems later on. -*+ -#define bfd_make_empty_symbol(abfd) \ - BFD_SEND (abfd, _bfd_make_empty_symbol, (abfd)) -*- -*/ - -/*proto* bfd_decode_symclass -Return a lower-case character corresponding to the symbol class of symbol. - -*; PROTO(int, bfd_decode_symclass, (asymbol *symbol)); -*/ -int -DEFUN(bfd_decode_symclass,(symbol), -asymbol *symbol) -{ - flagword flags = symbol->flags; - -#if 0 - if ((symbol->value == 0) && (symbol->section != NULL)) - /* Huh? All section names don't begin with "." */ - return (symbol->section->name)[1]; -#endif - - if (flags & BSF_FORT_COMM) return 'C'; - if (flags & BSF_UNDEFINED) return 'U'; - if (flags & BSF_ABSOLUTE) return 'a'; - - - if ( flags & (BSF_GLOBAL|BSF_LOCAL) ) { - if (symbol->section == (asection *)NULL) - return '*'; - else if ( !strcmp(symbol->section->name, ".text") ) - return (flags & BSF_GLOBAL) ? 'T' : 't'; - else if ( !strcmp(symbol->section->name, ".data") ) - return (flags & BSF_GLOBAL) ? 'D' : 'd'; - else if ( !strcmp(symbol->section->name, ".bss") ) - return (flags & BSF_GLOBAL) ? 'B' : 'b'; - else - return (flags & BSF_GLOBAL) ? 'O' : 'o'; - } - - /* We don't have to handle these cases just yet, but we will soon: - N_SETV: 'v'; - N_SETA: 'l'; - N_SETT: 'x'; - N_SETD: 'z'; - N_SETB: 's'; - N_INDR: 'i'; - */ - - return '?'; -} - -/* Create a table of debugging stab-codes and corresponding names. */ - -#define __define_stab(NAME, CODE, STRING) {NAME, STRING}, -struct {enum __stab_debug_code code; char *string;} bfd_stab_names[] - = { -#include "stab.def" - }; -#undef __define_stab - -/*proto* bfd_stab_name -Returns a string for the stab with the given code, or NULL if not found. - -*; PROTO(char *, bfd_stab_name, (int code)); -*/ -char * -DEFUN(bfd_stab_name,(code), -int code) -{ - register int i; - for (i = sizeof(bfd_stab_names) / sizeof(bfd_stab_names[0]) - 1; i >= 0; i--) - if (bfd_stab_names[i].code == (enum __stab_debug_code) code) - return bfd_stab_names[i].string; - return NULL; -} diff --git a/bfd/targets.c b/bfd/targets.c deleted file mode 100644 index d89e7bcb91d..00000000000 --- a/bfd/targets.c +++ /dev/null @@ -1,571 +0,0 @@ -/* Generic target-file-type support for the BFD library. - Copyright (C) 1990-1991 Free Software Foundation, Inc. - Written by Cygnus Support. - -This file is part of BFD, the Binary File Descriptor library. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* $Id$ */ - -#include "bfd.h" -#include "sysdep.h" -#include "libbfd.h" - -/*doc* -@section Targets -Each port of BFD to a different machine requries the creation of a -target back end. All the back end provides to the root part of BFD is -a structure containing pointers to functions which perform certain low -level operations on files. BFD translates the applications's requests -through a pointer into calls to the back end routines. - -When a file is opened with @code{bfd_openr}, its format and target are -unknown. BFD uses various mechanisms to determine how to interpret the -file. The operations performed are: -@itemize @bullet -@item -First a BFD is created by calling the internal routine -@code{new_bfd}, then @code{bfd_find_target} is called with the target -string supplied to @code{bfd_openr} and the new BFD pointer. -@item -If a null target string was provided to -@code{bfd_find_target}, it looks up the environment variable -@code{GNUTARGET} and uses that as the target string. -@item -If the target string is still NULL, or the target string -is @code{default}, then the first item in the target vector is used as -the target type. @xref{bfd_target}. -@item -Otherwise, the elements in the target vector are -inspected one by one, until a match on target name is found. When -found, that is used. -@item -Otherwise the error @code{invalid_target} is returned to -@code{bfd_openr}. -@item -@code{bfd_openr} attempts to open the file using -@code{bfd_open_file}, and returns the BFD. -@end itemize -Once the BFD has been opened and the target selected, the file format -may be determined. This is done by calling @code{bfd_check_format} on -the BFD with a suggested format. The routine returns @code{true} when -the application guesses right. - -@menu -* bfd_target:: -@end menu -*/ - - -/*proto* bfd_target -@node bfd_target, , Targets, Targets -@subsection bfd_target -This structure contains everything that BFD knows about a target. -It includes things like its byte order, name, what routines to call -to do various operations, etc. - -Every BFD points to a target structure with its "xvec" member. - - -Shortcut for declaring fields which are prototyped function pointers, -while avoiding anguish on compilers that don't support protos. - -$#define SDEF(ret, name, arglist) \ -$ PROTO(ret,(*name),arglist) -$#define SDEF_FMT(ret, name, arglist) \ -$ PROTO(ret,(*name[bfd_type_end]),arglist) - -These macros are used to dispatch to functions through the bfd_target -vector. They are used in a number of macros further down in @file{bfd.h}, and -are also used when calling various routines by hand inside the BFD -implementation. The "arglist" argument must be parenthesized; it -contains all the arguments to the called function. - -$#define BFD_SEND(bfd, message, arglist) \ -$ ((*((bfd)->xvec->message)) arglist) - -For operations which index on the BFD format - -$#define BFD_SEND_FMT(bfd, message, arglist) \ -$ (((bfd)->xvec->message[(int)((bfd)->format)]) arglist) - -This is the struct which defines the type of BFD this is. The -"xvec" member of the struct @code{bfd} itself points here. Each module -that implements access to a different target under BFD, defines -one of these. - -FIXME, these names should be rationalised with the names of the -entry points which call them. Too bad we can't have one macro to -define them both! - -*+++ - -$typedef struct bfd_target -${ - -identifies the kind of target, eg SunOS4, Ultrix, etc - -$ char *name; - -The "flavour" of a back end is a general indication about the contents -of a file. - -$ enum target_flavour { -$ bfd_target_unknown_flavour, -$ bfd_target_aout_flavour, -$ bfd_target_coff_flavour, -$ bfd_target_elf_flavour, -$ bfd_target_ieee_flavour, -$ bfd_target_oasys_flavour, -$ bfd_target_srec_flavour} flavour; - -The order of bytes within the data area of a file. - -$ boolean byteorder_big_p; - -The order of bytes within the header parts of a file. - -$ boolean header_byteorder_big_p; - -This is a mask of all the flags which an executable may have set - -from the set @code{NO_FLAGS}, @code{HAS_RELOC}, ...@code{D_PAGED}. - -$ flagword object_flags; - -This is a mask of all the flags which a section may have set - from -the set @code{SEC_NO_FLAGS}, @code{SEC_ALLOC}, ...@code{SET_NEVER_LOAD}. - -$ flagword section_flags; - -The pad character for filenames within an archive header. - -$ char ar_pad_char; - -The maximum number of characters in an archive header. - -$ unsigned short ar_max_namelen; - -The minimum alignment restriction for any section. - -$ unsigned int align_power_min; - -Entries for byte swapping for data. These are different to the other -entry points, since they don't take BFD as first arg. Certain other handlers -could do the same. - -$ SDEF (bfd_vma, bfd_getx64, (bfd_byte *)); -$ SDEF (void, bfd_putx64, (bfd_vma, bfd_byte *)); -$ SDEF (bfd_vma, bfd_getx32, (bfd_byte *)); -$ SDEF (void, bfd_putx32, (bfd_vma, bfd_byte *)); -$ SDEF (bfd_vma, bfd_getx16, (bfd_byte *)); -$ SDEF (void, bfd_putx16, (bfd_vma, bfd_byte *)); - -Byte swapping for the headers - -$ SDEF (bfd_vma, bfd_h_getx64, (bfd_byte *)); -$ SDEF (void, bfd_h_putx64, (bfd_vma, bfd_byte *)); -$ SDEF (bfd_vma, bfd_h_getx32, (bfd_byte *)); -$ SDEF (void, bfd_h_putx32, (bfd_vma, bfd_byte *)); -$ SDEF (bfd_vma, bfd_h_getx16, (bfd_byte *)); -$ SDEF (void, bfd_h_putx16, (bfd_vma, bfd_byte *)); - -Format dependent routines, these turn into vectors of entry points -within the target vector structure; one for each format to check. - -Check the format of a file being read. Return bfd_target * or zero. - -$ SDEF_FMT (struct bfd_target *, _bfd_check_format, (bfd *)); - -Set the format of a file being written. - -$ SDEF_FMT (boolean, _bfd_set_format, (bfd *)); - -Write cached information into a file being written, at bfd_close. - -$ SDEF_FMT (boolean, _bfd_write_contents, (bfd *)); - -The following functions are defined in @code{JUMP_TABLE}. The idea is -that the back end writer of @code{foo} names all the routines -@code{foo_}@var{entry_point}, @code{JUMP_TABLE} will built the entries -in this structure in the right order. - -Core file entry points - -$ SDEF (char *, _core_file_failing_command, (bfd *)); -$ SDEF (int, _core_file_failing_signal, (bfd *)); -$ SDEF (boolean, _core_file_matches_executable_p, (bfd *, bfd *)); - -Archive entry points - -$ SDEF (boolean, _bfd_slurp_armap, (bfd *)); -$ SDEF (boolean, _bfd_slurp_extended_name_table, (bfd *)); -$ SDEF (void, _bfd_truncate_arname, (bfd *, CONST char *, char *)); -$ SDEF (boolean, write_armap, (bfd *arch, -$ unsigned int elength, -$ struct orl *map, -$ unsigned int orl_count, -$ int stridx)); - -Standard stuff. - -$ SDEF (boolean, _close_and_cleanup, (bfd *)); -$ SDEF (boolean, _bfd_set_section_contents, (bfd *, sec_ptr, PTR, -$ file_ptr, bfd_size_type)); -$ SDEF (boolean, _bfd_get_section_contents, (bfd *, sec_ptr, PTR, -$ file_ptr, bfd_size_type)); -$ SDEF (boolean, _new_section_hook, (bfd *, sec_ptr)); - -Symbols and reloctions - -$ SDEF (unsigned int, _get_symtab_upper_bound, (bfd *)); -$ SDEF (unsigned int, _bfd_canonicalize_symtab, -$ (bfd *, struct symbol_cache_entry **)); -$ SDEF (unsigned int, _get_reloc_upper_bound, (bfd *, sec_ptr)); -$ SDEF (unsigned int, _bfd_canonicalize_reloc, (bfd *, sec_ptr, arelent **, -$ struct symbol_cache_entry**)); -$ SDEF (struct symbol_cache_entry *, _bfd_make_empty_symbol, (bfd *)); -$ SDEF (void, _bfd_print_symbol, (bfd *, PTR, struct symbol_cache_entry *, -$ bfd_print_symbol_type)); -$#define bfd_print_symbol(b,p,s,e) BFD_SEND(b, _bfd_print_symbol, (b,p,s,e)) -$ SDEF (alent *, _get_lineno, (bfd *, struct symbol_cache_entry *)); -$ -$ SDEF (boolean, _bfd_set_arch_mach, (bfd *, enum bfd_architecture, -$ unsigned long)); -$ -$ SDEF (bfd *, openr_next_archived_file, (bfd *arch, bfd *prev)); -$ SDEF (boolean, _bfd_find_nearest_line, -$ (bfd *abfd, struct sec *section, -$ struct symbol_cache_entry **symbols,bfd_vma offset, -$ CONST char **file, CONST char **func, unsigned int *line)); -$ SDEF (int, _bfd_stat_arch_elt, (bfd *, struct stat *)); -$ -$ SDEF (int, _bfd_sizeof_headers, (bfd *, boolean)); -$ -$ SDEF (void, _bfd_debug_info_start, (bfd *)); -$ SDEF (void, _bfd_debug_info_end, (bfd *)); -$ SDEF (void, _bfd_debug_info_accumulate, (bfd *, struct sec *)); - -Special entry points for gdb to swap in coff symbol table parts - -$ SDEF(void, _bfd_coff_swap_aux_in,( -$ bfd *abfd , -$ PTR ext, -$ int type, -$ int class , -$ PTR in)); -$ -$ SDEF(void, _bfd_coff_swap_sym_in,( -$ bfd *abfd , -$ PTR ext, -$ PTR in)); -$ -$ SDEF(void, _bfd_coff_swap_lineno_in, ( -$ bfd *abfd, -$ PTR ext, -$ PTR in)); -$ - -Special entry points for gas to swap coff parts - -$ SDEF(unsigned int, _bfd_coff_swap_aux_out,( -$ bfd *abfd, -$ PTR in, -$ int type, -$ int class, -$ PTR ext)); -$ -$ SDEF(unsigned int, _bfd_coff_swap_sym_out,( -$ bfd *abfd, -$ PTR in, -$ PTR ext)); -$ -$ SDEF(unsigned int, _bfd_coff_swap_lineno_out,( -$ bfd *abfd, -$ PTR in, -$ PTR ext)); -$ -$ SDEF(unsigned int, _bfd_coff_swap_reloc_out,( -$ bfd *abfd, -$ PTR src, -$ PTR dst)); -$ -$ SDEF(unsigned int, _bfd_coff_swap_filehdr_out,( -$ bfd *abfd, -$ PTR in, -$ PTR out)); -$ -$ SDEF(unsigned int, _bfd_coff_swap_aouthdr_out,( -$ bfd *abfd, -$ PTR in, -$ PTR out)); -$ -$ SDEF(unsigned int, _bfd_coff_swap_scnhdr_out,( -$ bfd *abfd, -$ PTR in, -$ PTR out)); -$ -$} bfd_target; - -*--- - -*/ -extern bfd_target ecoff_little_vec; -extern bfd_target ecoff_big_vec; -extern bfd_target sunos_big_vec; -extern bfd_target demo_64_vec; -extern bfd_target srec_vec; -extern bfd_target b_out_vec_little_host; -extern bfd_target b_out_vec_big_host; -extern bfd_target icoff_little_vec; -extern bfd_target icoff_big_vec; -extern bfd_target elf_little_vec; -extern bfd_target elf_big_vec; -extern bfd_target ieee_vec; -extern bfd_target oasys_vec; -extern bfd_target m88k_bcs_vec; -extern bfd_target m68kcoff_vec; -extern bfd_target i386coff_vec; -extern bfd_target i386aout_vec; -extern bfd_target a29kcoff_big_vec; -extern bfd_target trad_core_vec; -extern bfd_target rs6000coff_vec; - -#ifdef SELECT_VECS - -bfd_target *target_vector[] = { -SELECT_VECS, -0 - -}; -#else -#ifdef DEFAULT_VECTOR -extern bfd_target DEFAULT_VECTOR; -#endif - -#ifdef GNU960 -#define ICOFF_LITTLE_VEC icoff_little_vec -#define ICOFF_BIG_VEC icoff_big_vec -#define B_OUT_VEC_LITTLE_HOST b_out_vec_little_host -#define B_OUT_VEC_BIG_HOST b_out_vec_big_host -#endif /* GNU960 */ - -#ifndef RESTRICTED -#define ECOFF_LITTLE_VEC ecoff_little_vec -#define ECOFF_BIG_VEC ecoff_big_vec -#define ICOFF_LITTLE_VEC icoff_little_vec -#define ICOFF_BIG_VEC icoff_big_vec -#define ELF_LITTLE_VEC elf_little_vec -#define ELF_BIG_VEC elf_big_vec -#define ZB_OUT_VEC_LITTLE_HOST b_out_vec_little_host -#define ZB_OUT_VEC_BIG_HOST b_out_vec_big_host -#define SUNOS_VEC_BIG_HOST sunos_big_vec -#define DEMO_64_VEC demo_64_vec - -/* We have no oasys tools anymore, so we can't test any of this - anymore. If you want to test the stuff yourself, go ahead... - steve@cygnus.com */ -#if 0 -#define OASYS_VEC oasys_vec -#endif - -#define IEEE_VEC ieee_vec -#define M88K_BCS_VEC m88k_bcs_vec -#define SREC_VEC srec_vec -#define M68KCOFF_VEC m68kcoff_vec -#define I386COFF_VEC i386coff_vec -#define I386AOUT_VEC i386aout_vec -#define A29KCOFF_BIG_VEC a29kcoff_big_vec -#define RS6000COFF_VEC rs6000coff_vec -#endif - -bfd_target *target_vector[] = { - -#ifdef DEFAULT_VECTOR - &DEFAULT_VECTOR, -#endif - -#ifdef I386COFF_VEC - &I386COFF_VEC, -#endif - -#ifdef I386AOUT_VEC - &I386AOUT_VEC, -#endif - -#ifdef ECOFF_LITTLE_VEC - &ECOFF_LITTLE_VEC, -#endif - -#ifdef ECOFF_BIG_VEC - &ECOFF_BIG_VEC, -#endif - -#ifdef IEEE_VEC - &IEEE_VEC, -#endif - -#ifdef OASYS_VEC - &OASYS_VEC, -#endif - -#ifdef SUNOS_VEC_BIG_HOST - &SUNOS_VEC_BIG_HOST, -#endif - -#ifdef HOST_64_BIT -#ifdef DEMO_64_VEC - &DEMO_64_VEC, -#endif -#endif - -#ifdef M88K_BCS_VEC - &M88K_BCS_VEC, -#endif - -#ifdef SREC_VEC - &SREC_VEC, -#endif - -#ifdef ICOFF_LITTLE_VEC - &ICOFF_LITTLE_VEC, -#endif - -#ifdef ICOFF_BIG_VEC - &ICOFF_BIG_VEC, -#endif - -#ifdef ELF_LITTLE_VEC - &ELF_LITTLE_VEC, -#endif - -#ifdef ELF_BIG_VEC - &ELF_BIG_VEC, -#endif - -#ifdef B_OUT_VEC_LITTLE_HOST - &B_OUT_VEC_LITTLE_HOST, -#endif - -#ifdef B_OUT_VEC_BIG_HOST - &B_OUT_VEC_BIG_HOST, -#endif - -#ifdef M68KCOFF_VEC - &M68KCOFF_VEC, -#endif - -#ifdef A29KCOFF_BIG_VEC - &A29KCOFF_BIG_VEC, -#endif - -#ifdef TRAD_CORE - &trad_core_vec, -#endif - -#ifdef RS6000COFF_VEC - &RS6000COFF_VEC, -#endif - - NULL, /* end of list marker */ -}; - -#endif - -/* default_vector[0] contains either the address of the default vector, - if there is one, or zero if there isn't. */ - -bfd_target *default_vector[] = { -#ifdef DEFAULT_VECTOR - &DEFAULT_VECTOR, -#endif - 0, -}; - - - - -/*proto* -*i bfd_find_target -Returns a pointer to the transfer vector for the object target -named target_name. If target_name is NULL, chooses the one in the -environment variable GNUTARGET; if that is null or not defined then -the first entry in the target list is chosen. Passing in the -string "default" or setting the environment variable to "default" -will cause the first entry in the target list to be returned, -and "target_defaulted" will be set in the BFD. This causes -@code{bfd_check_format} to loop over all the targets to find the one -that matches the file being read. -*; PROTO(bfd_target *, bfd_find_target,(CONST char *, bfd *)); -*-*/ - -bfd_target * -DEFUN(bfd_find_target,(target_name, abfd), - CONST char *target_name AND - bfd *abfd) -{ - bfd_target **target; - extern char *getenv (); - CONST char *targname = (target_name ? target_name : getenv ("GNUTARGET")); - - /* This is safe; the vector cannot be null */ - if (targname == NULL || !strcmp (targname, "default")) { - abfd->target_defaulted = true; - return abfd->xvec = target_vector[0]; - } - - abfd->target_defaulted = false; - - for (target = &target_vector[0]; *target != NULL; target++) { - if (!strcmp (targname, (*target)->name)) - return abfd->xvec = *target; - } - - bfd_error = invalid_target; - return NULL; -} - - -/*proto* -*i bfd_target_list -This function returns a freshly malloced NULL-terminated vector of the -names of all the valid BFD targets. Do not modify the names -*; PROTO(CONST char **,bfd_target_list,()); - -*-*/ - -CONST char ** -DEFUN_VOID(bfd_target_list) -{ - int vec_length= 0; - bfd_target **target; - CONST char **name_list, **name_ptr; - - for (target = &target_vector[0]; *target != NULL; target++) - vec_length++; - - name_ptr = - name_list = (CONST char **) zalloc ((vec_length + 1) * sizeof (char **)); - - if (name_list == NULL) { - bfd_error = no_memory; - return NULL; - } - - for (target = &target_vector[0]; *target != NULL; target++) - *(name_ptr++) = (*target)->name; - - return name_list; -} diff --git a/bfd/tolibbfd b/bfd/tolibbfd deleted file mode 100755 index ef9531ef88a..00000000000 --- a/bfd/tolibbfd +++ /dev/null @@ -1,4 +0,0 @@ -/---------------START FROM/,/---------------END FROM/d -/\/\*:libbfd.c\*\//r libbfd.ip -/\/\*:cache.c\*\//r cache.ip -/\/\*:reloc.c\*\//r reloc.ip diff --git a/bfd/tolibcoff b/bfd/tolibcoff deleted file mode 100755 index 548c8baa59c..00000000000 --- a/bfd/tolibcoff +++ /dev/null @@ -1 +0,0 @@ -/\/\*:coffcode.h\*\//r coffcode.p diff --git a/bfd/trad-core.c b/bfd/trad-core.c deleted file mode 100644 index cd64383f07b..00000000000 --- a/bfd/trad-core.c +++ /dev/null @@ -1,282 +0,0 @@ -/* BFD back end for traditional Unix core files (U-area and raw sections) - Copyright (C) 1988, 1989, 1991 Free Software Foundation, Inc. - Written by John Gilmore of Cygnus Support. - -This file is part of BFD, the Binary File Descriptor library. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* To use this file on a particular host, configure the host with these - parameters in the config/h-HOST file: - - HDEFINES=-DTRAD_CORE - HDEPFILES=trad-core.o - - */ - -#include "bfd.h" -#include "sysdep.h" -#include "libbfd.h" -#include "libaout.h" /* BFD a.out internal data structures */ - -#include -#include -#include -#include -#include -#include - -#include /* After a.out.h */ -#include - -#include - -/* These are stored in the bfd's tdata */ -struct core_data { - struct user *upage; /* core file header */ - asection *data_section; - asection *stack_section; - asection *reg_section; -}; - -#define core_hdr(bfd) (((struct core_data *) (bfd->tdata))->hdr) -#define core_upage(bfd) (((struct core_data *) ((bfd)->tdata))->upage) -#define core_datasec(bfd) (((struct core_data *) ((bfd)->tdata))->data_section) -#define core_stacksec(bfd) (((struct core_data*)((bfd)->tdata))->stack_section) -#define core_regsec(bfd) (((struct core_data *) ((bfd)->tdata))->reg_section) - -/* Handle 4.2-style (and perhaps also sysV-style) core dump file. */ - -/* ARGSUSED */ -bfd_target * -trad_unix_core_file_p (abfd) - bfd *abfd; -{ - int val; - struct user u; - unsigned int reg_offset, fp_reg_offset; - /* This struct is just for allocating two things with one zalloc, so - they will be freed together, without violating alignment constraints. */ - struct core_user { - struct core_data coredata; - struct user u; - } *rawptr; - - val = bfd_read ((void *)&u, 1, sizeof u, abfd); - if (val != sizeof u) - return 0; /* Too small to be a core file */ - - /* Sanity check perhaps??? */ - if (u.u_dsize > 0x1000000) /* Remember, it's in pages... */ - return 0; - if (u.u_ssize > 0x1000000) - return 0; - /* Check that the size claimed is no greater than the file size. FIXME. */ - - /* OK, we believe you. You're a core file (sure, sure). */ - - /* Allocate both the upage and the struct core_data at once, so - a single free() will free them both. */ - rawptr = (struct core_user *)bfd_zalloc (abfd, sizeof (struct core_user)); - if (rawptr == NULL) { - bfd_error = no_memory; - return 0; - } - - set_tdata (abfd, &rawptr->coredata); - core_upage (abfd) = &rawptr->u; - *core_upage (abfd) = u; /* Save that upage! */ - - /* Create the sections. This is raunchy, but bfd_close wants to free - them separately. */ - core_stacksec (abfd) = (asection *) zalloc (sizeof (asection)); - if (core_stacksec (abfd) == NULL) { -loser: - bfd_error = no_memory; - free ((void *)rawptr); - return 0; - } - core_datasec (abfd) = (asection *) zalloc (sizeof (asection)); - if (core_datasec (abfd) == NULL) { -loser1: - free ((void *)core_stacksec (abfd)); - goto loser; - } - core_regsec (abfd) = (asection *) zalloc (sizeof (asection)); - if (core_regsec (abfd) == NULL) { -loser2: - free ((void *)core_datasec (abfd)); - goto loser1; - } - - core_stacksec (abfd)->name = ".stack"; - core_datasec (abfd)->name = ".data"; - core_regsec (abfd)->name = ".reg"; - - core_stacksec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS; - core_datasec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS; - core_regsec (abfd)->flags = SEC_ALLOC + SEC_HAS_CONTENTS; - - core_datasec (abfd)->size = NBPG * u.u_dsize; - core_stacksec (abfd)->size = NBPG * u.u_ssize; - core_regsec (abfd)->size = NBPG * UPAGES; /* Larger than sizeof struct u */ - - /* What a hack... we'd like to steal it from the exec file, - since the upage does not seem to provide it. FIXME. */ -#ifdef HOST_DATA_START_ADDR - core_datasec (abfd)->vma = HOST_DATA_START_ADDR; -#else - core_datasec (abfd)->vma = HOST_TEXT_START_ADDR + (NBPG * u.u_tsize); -#endif - core_stacksec (abfd)->vma = HOST_STACK_END_ADDR - (NBPG * u.u_ssize); - /* This is tricky. As the "register section", we give them the entire - upage and stack. u.u_ar0 points to where "register 0" is stored. - There are two tricks with this, though. One is that the rest of the - registers might be at positive or negative (or both) displacements - from *u_ar0. The other is that u_ar0 is sometimes an absolute address - in kernel memory, and on other systems it is an offset from the beginning - of the `struct user'. - - As a practical matter, we don't know where the registers actually are, - so we have to pass the whole area to GDB. We encode the value of u_ar0 - by setting the .regs section up so that its virtual memory address - 0 is at the place pointed to by u_ar0 (by setting the vma of the start - of the section to -u_ar0). GDB uses this info to locate the regs, - using minor trickery to get around the offset-or-absolute-addr problem. */ - core_regsec (abfd)->vma = 0 - (int) u.u_ar0; - - core_datasec (abfd)->filepos = NBPG * UPAGES; - core_stacksec (abfd)->filepos = (NBPG * UPAGES) + NBPG * u.u_dsize; - core_regsec (abfd)->filepos = 0; /* Register segment is the upage */ - - /* Align to word at least */ - core_stacksec (abfd)->alignment_power = 2; - core_datasec (abfd)->alignment_power = 2; - core_regsec (abfd)->alignment_power = 2; - - abfd->sections = core_stacksec (abfd); - core_stacksec (abfd)->next = core_datasec (abfd); - core_datasec (abfd)->next = core_regsec (abfd); - abfd->section_count = 3; - - return abfd->xvec; -} - -char * -trad_unix_core_file_failing_command (abfd) - bfd *abfd; -{ - if (*core_upage (abfd)->u_comm) - return core_upage (abfd)->u_comm; - else - return 0; -} - -/* ARGSUSED */ -int -trad_unix_core_file_failing_signal (ignore_abfd) - bfd *ignore_abfd; -{ - return -1; /* FIXME, where is it? */ -} - -/* ARGSUSED */ -boolean -trad_unix_core_file_matches_executable_p (core_bfd, exec_bfd) - bfd *core_bfd, *exec_bfd; -{ - return true; /* FIXME, We have no way of telling at this point */ -} - -/* No archive file support via this BFD */ -#define trad_unix_openr_next_archived_file bfd_generic_openr_next_archived_file -#define trad_unix_generic_stat_arch_elt bfd_generic_stat_arch_elt -#define trad_unix_slurp_armap bfd_false -#define trad_unix_slurp_extended_name_table bfd_true -#define trad_unix_write_armap (PROTO (boolean, (*), \ - (bfd *arch, unsigned int elength, struct orl *map, int orl_count, \ - int stridx))) bfd_false -#define trad_unix_truncate_arname bfd_dont_truncate_arname -#define aout_32_openr_next_archived_file bfd_generic_openr_next_archived_file - -#define trad_unix_close_and_cleanup bfd_generic_close_and_cleanup -#define trad_unix_set_section_contents (PROTO(boolean, (*), \ - (bfd *abfd, asection *section, PTR data, file_ptr offset, \ - bfd_size_type count))) bfd_false -#define trad_unix_get_section_contents bfd_generic_get_section_contents -#define trad_unix_new_section_hook (PROTO (boolean, (*), \ - (bfd *, sec_ptr))) bfd_true -#define trad_unix_get_symtab_upper_bound bfd_0u -#define trad_unix_get_symtab (PROTO (unsigned int, (*), \ - (bfd *, struct symbol_cache_entry **))) bfd_0u -#define trad_unix_get_reloc_upper_bound (PROTO (unsigned int, (*), \ - (bfd *, sec_ptr))) bfd_0u -#define trad_unix_canonicalize_reloc (PROTO (unsigned int, (*), \ - (bfd *, sec_ptr, arelent **, struct symbol_cache_entry**))) bfd_0u -#define trad_unix_make_empty_symbol (PROTO ( \ - struct symbol_cache_entry *, (*), (bfd *))) bfd_false -#define trad_unix_print_symbol (PROTO (void, (*), \ - (bfd *, PTR, struct symbol_cache_entry *, \ - bfd_print_symbol_type))) bfd_false -#define trad_unix_get_lineno (PROTO (alent *, (*), \ - (bfd *, struct symbol_cache_entry *))) bfd_nullvoidptr -#define trad_unix_set_arch_mach (PROTO (boolean, (*), \ - (bfd *, enum bfd_architecture, unsigned long))) bfd_false -#define trad_unix_find_nearest_line (PROTO (boolean, (*), \ - (bfd *abfd, struct sec *section, \ - struct symbol_cache_entry **symbols,bfd_vma offset, \ - CONST char **file, CONST char **func, unsigned int *line))) bfd_false -#define trad_unix_sizeof_headers (PROTO (int, (*), \ - (bfd *, boolean))) bfd_0 - -#define trad_unix_bfd_debug_info_start bfd_void -#define trad_unix_bfd_debug_info_end bfd_void -#define trad_unix_bfd_debug_info_accumulate (PROTO (void, (*), \ - (bfd *, struct sec *))) bfd_void - -/* If somebody calls any byte-swapping routines, shoot them. */ -void -swap_abort() -{ - abort(); /* This way doesn't require any declaration for ANSI to fuck up */ -} -#define NO_GET ((PROTO(bfd_vma, (*), ( bfd_byte *))) swap_abort ) -#define NO_PUT ((PROTO(void, (*), (bfd_vma, bfd_byte *))) swap_abort ) - -bfd_target trad_core_vec = - { - "trad-core", - bfd_target_unknown_flavour, - true, /* target byte order */ - true, /* target headers byte order */ - (HAS_RELOC | EXEC_P | /* object flags */ - HAS_LINENO | HAS_DEBUG | - HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED), - (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ - ' ', /* ar_pad_char */ - 16, /* ar_max_namelen */ - 3, /* minimum alignment power */ - NO_GET, NO_PUT, NO_GET, NO_PUT, NO_GET, NO_PUT, /* data */ - NO_GET, NO_PUT, NO_GET, NO_PUT, NO_GET, NO_PUT, /* hdrs */ - - {_bfd_dummy_target, _bfd_dummy_target, - _bfd_dummy_target, trad_unix_core_file_p}, - {bfd_false, bfd_false, /* bfd_create_object */ - bfd_false, bfd_false}, - {bfd_false, bfd_false, /* bfd_write_contents */ - bfd_false, bfd_false}, - - JUMP_TABLE(trad_unix) -}; diff --git a/bfd/trad-core.h b/bfd/trad-core.h deleted file mode 100644 index b86f485ec35..00000000000 --- a/bfd/trad-core.h +++ /dev/null @@ -1,28 +0,0 @@ -/* Declarations of BFD back end for traditional Unix core files - Copyright (C) 1990-1991 Free Software Foundation, Inc. - Written by Cygnus Support. Mostly John Gilmore's fault. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include "ansidecl.h" - -/* forward declaration */ -PROTO (bfd_target *, trad_unix_core_file_p, (bfd *abfd)); -PROTO (char *, trad_unix_core_file_failing_command, (bfd *abfd)); -PROTO (int, trad_unix_core_file_failing_signal, (bfd *abfd)); -PROTO (boolean, trad_unix_core_file_matches_executable_p, - (bfd *core_bfd, bfd *exec_bfd)); diff --git a/bfd/unPROTO b/bfd/unPROTO deleted file mode 100755 index a6f95207dba..00000000000 --- a/bfd/unPROTO +++ /dev/null @@ -1,18 +0,0 @@ -# -# The PROTO macro is a subterfuge to be compatible with both ANSI and K&R -# declaration syntax. It's not widely known, so for the docn just map the -# thing to ANSI declaration syntax. -# -# First, join up defns broken across multiple lines in source---but leave -# any linebreaks, to prettify our examples -:pbegn -/PROTO(.*, *$/N -s/\n/?/ -t pbegn -s/?/\ -/g -# Now actually do the PROTO interpretation. -# A PROTO invocation looks like -# PROTO( resulttype, function, (arglist)); -s/[ ]*PROTO(\(.*\),[\n ]*\(.*\),[\n ]*\((.*)\));/\1 \2\3;/ - diff --git a/binutils/.Sanitize b/binutils/.Sanitize deleted file mode 100644 index 9230ac3989f..00000000000 --- a/binutils/.Sanitize +++ /dev/null @@ -1,133 +0,0 @@ -# Sanitize.in for devo. -# $Id$ -# - -# Each directory to survive it's way into a release will need a file -# like this one called "./.Sanitize". All keyword lines must exist, -# and must exist in the order specified by this file. Each directory -# in the tree will be processed, top down, in the following order. - -# Hash started lines like this one are comments and will be deleted -# before anything else is done. Blank lines will also be squashed -# out. - -# The lines between the "Do-first:" line and the "Things-to-keep:" -# line are executed as a /bin/sh shell script before anything else is -# done in this - -Do-first: - -echo Sanitizing `pwd`... - -# All files listed between the "Things-to-keep:" line and the -# "Files-to-sed:" line will be kept. All other files will be removed. -# Directories listed in this section will have their own Sanitize -# called. Directories not listed will be removed in their entirety -# with rm -rf. - -Things-to-keep: - -ChangeLog -Makefile.in -TODO -alloca.c -ar.c -ar.1 -nm.1 -objdump.1 -ranlib.1 -size.1 -strip.1 -is-ranlib.c -not-ranlib.c -maybe-ranlib.c -is-strip.c -not-strip.c -maybe-strip.c -binutils.texi -bucomm.c -configure.in -copy.c -cplus-dem.c -filemode.c -gmalloc.c -am29k-pinsn.c -i960-pinsn.c -m68k-pinsn.c -nm.c -objdump.c -ranlib.sh -README -size.c -sparc-pinsn.c -version.c - -Do-last: - -echo Done in `pwd`. - -# -# -# $Log$ -# Revision 1.11 1991/11/18 08:04:14 bothner -# * Makefile.in: Bump to version 1.92. -# * version.c, Makefile.in: Get version string from Makefile. -# * copy.c, is-strip.c, not-strip.c, maybe-strip.c, Makefile.in: -# Make the same change that we earlier did for ar/ranlib: -# Generate two different binaries for strip and copy and use -# a global variable with different values to distinguish -# ostrip from copy. (-1 means to use argv[0] to decide, -# so you can get the old behavior, but it is no longer the default). -# * copy.c (copy_file): Set EXEC_P of output bfd if input is so. -# * copy.c (main): If is_strip==-1, compare last 5 chars -# of argv[0], not the whole path. -# * copy.c (main): Return 0, not 1. -# * copy.c (setup_sections): Fix due to change in bfd_make_section -# now failing if asked for a duplicate section. -# * strip.c, ostrip.c: Removed obsolete files. -# * ar.c, not-ranlib.c, maybe-ranlib.c: -# Change encoding of is_ranlib variable to be consistent -# with is_strip for strip.copy (i.e -1 to means use argv[0]). -# -# Revision 1.10 1991/11/15 23:34:33 pesch -# .Sanitize: reflect someone's apocopation of binutils.texi[nfo] name -# Makefile.in: improve texi2roff workarounds -# -# Revision 1.9 1991/11/06 09:06:02 sac -# Added nm.1, objdump.1, ranlib.1, size.1 and strip.1 -# -# Revision 1.8 1991/11/05 20:53:19 sac -# Added README to .Sanitize -# Made Makefile.in install using ddestdir -# -# Revision 1.7 1991/10/10 11:59:09 rich -# updating -# -# Revision 1.6 1991/10/08 01:50:59 gnu -# Remove configure and config.sub from the expected list. -# -# Revision 1.5 1991/10/08 01:48:04 gnu -# Add binutils.texinfo, and change *-ranlib.o to *-ranlib.c. -# -# Revision 1.4 1991/10/07 23:14:30 bothner -# * ar.c, Makefile.in, new files {is,not,maybe}-ranlib.c: -# Make two different binaries for ar and ranlib, instead of -# distinguishing them at run time using argv[0]. -# (Old behavior is still available if you "make ar_with_ranlib", -# but it is not the default.) -# * ranlib.sh (new): An alternative one-line -# shell implementation of ranlib. -# -# Revision 1.3 1991/09/01 03:47:07 steve -# Added config.sub -# -# Revision 1.2 1991/07/15 23:38:04 steve -# *** empty log message *** -# -# Revision 1.1 1991/05/23 21:49:14 rich -# Initial revision -# -# -# - -# End of file. diff --git a/binutils/ChangeLog b/binutils/ChangeLog deleted file mode 100644 index 234c12fb4f3..00000000000 --- a/binutils/ChangeLog +++ /dev/null @@ -1,176 +0,0 @@ -Mon Nov 18 12:05:37 1991 Per Bothner (bothner at cygnus.com) - - * README: Various improvements. - -Sun Nov 17 23:40:59 1991 Per Bothner (bothner at cygnus.com) - - * Makefile.in: Bump to version 1.92. - * version.c, Makefile.in: Get version string from Makefile. - * copy.c, is-strip.c, not-strip.c, maybe-strip.c, Makefile.in: - Make the same change that we earlier did for ar/ranlib: - Generate two different binaries for strip and copy and use - a global variable with different values to distinguish - ostrip from copy. (-1 means to use argv[0] to decide, - so you can get the old behavior, but it is no longer the default). - * copy.c (copy_file): Set EXEC_P of output bfd if input is so. - * copy.c (main): If is_strip==-1, compare last 5 chars - of argv[0], not the whole path. - * copy.c (main): Return 0, not 1. - * copy.c (setup_sections): Fix due to change in bfd_make_section - now failing if asked for a duplicate section. - * strip.c, ostrip.c: Removed obsolete files. - * ar.c, not-ranlib.c, maybe-ranlib.c: - Change encoding of is_ranlib variable to be consistent - with is_strip for strip.copy (i.e -1 to means use argv[0]). - -Thu Nov 14 20:11:02 1991 Per Bothner (bothner at cygnus.com) - - * version.c (program_version): Update to version 1.92. - -Tue Nov 12 16:17:53 1991 Per Bothner (bothner at cygnus.com) - - * ar.c (get_pos_bfd): Previous fix was missing a "break". - -Thu Nov 7 08:55:56 1991 Steve Chamberlain (sac at cygnus.com) - - * am29k-pinsn.c: Fixed bug in mtacc, dmac and fmac instruction - encodings. (Thaks to David Wood) - -Sun Nov 3 14:50:23 1991 Per Bothner (bothner at cygnus.com) - - * Makefile.in ($(DIST_NAME).tar.Z), TODO: Various fixes. - * ar.c (get_pos_bfd): Fix to handling of before/after - positioning options. - * bucomm.c (fatal): MISSING_VFPRINTF is no longer an issue, - since libiberty contains vfprintf etc if otherwise missing. - * m68k-pinsn.c (print_insn_arg): Support BB/BW/BL - type operands, as used by branch instructions. - * nm.c: Delegate printing of symbols to BFD, - by using bfd_print_symbol to do the formatting. - -Mon Oct 28 11:20:47 1991 Steve Chamberlain (steve at cygnus.com) - - * ar.c (write_archive.c): added unlink before rename since some - systems can't rename onto an existant file. - -Mon Oct 21 09:47:23 1991 Steve Chamberlain (steve at rtl.cygnus.com) - - * nm.c: now doesn't crash if a symbol with no section and no - SEC_ABS appears. - -Thu Oct 17 15:25:50 1991 Per Bothner (bothner at cygnus.com) - - * Makefile.in, version.c: Bump to version 1.91. - -Wed Oct 16 11:45:36 1991 Per Bothner (bothner at cygnus.com) - - * Makefile.in, ar.c, bucomm.c, copy.c, cplus-dem.c, filemode.c, - i960-pinsn.c, m68k-pinsn.c, nm.c, objdump.c, size.c, sparc-pinsn.c, - * strip.c: Add or update Copyright notice. - * TODO: Add note on 'nm -a'. - * version.c: Update version number to 1.90. - * Makefile.in: Fix making of documentation for dist. - -Tue Oct 15 00:17:17 1991 Per Bothner (bothner at cygnus.com) - - * README: New file. - * Makefile.in: New kludgy rules for making a tarfile. - * Makefile.in: Fix bindir path. - -Mon Oct 14 17:34:29 1991 Roland H. Pesch (pesch at cygnus.com) - - * Makefile.in: add targets binutils.mm, binutils.me - -Fri Oct 11 22:44:21 1991 John Gilmore (gnu at cygnus.com) - - * Makefile.in: Avoid Sun Make VPATH bugs by adding dependencies. - -Fri Oct 11 12:51:33 1991 Roland H. Pesch (pesch at cygnus.com) - - * Makefile.in: add target "binutils.ms" - - * binutils.texinfo: minor restructuring for texi2roff comfort. - -Fri Oct 11 04:12:28 1991 John Gilmore (gnu at cygnus.com) - - Restructure configuration scheme for bfd, binutils, ld. - - * include/sys/h-*.h: Move to bfd/hosts/h-*.h. - * configure.in: Revise to symlink sysdep.h to ../bfd/hosts/h-xxx.h. - Change some config names to match other dirs. - * *.c: Include bfd.h before sysdep.h, so ansidecl and PROTO() - get defined first. - * Makefile.in: Use -I. to get sysdep.h. - -Wed Oct 9 22:42:56 1991 Per Bothner (bothner at cygnus.com) - - * nm.c (print_symbols): Handle NULL name field of symbol. - * Makefile.in: Removed spurious comment. - -Tue Oct 8 16:55:03 1991 Roland H. Pesch (pesch at cygnus.com) - - * binutils.texinfo: minor typos, phrasing, formatting fixes. - -Tue Oct 8 15:13:20 1991 Per Bothner (bothner at cygnus.com) - - * configure.in: Get host file from ../bfd/config, not config. - * config/*: Remove config directory and its files. - -Tue Oct 8 13:58:59 1991 Roland H. Pesch (pesch at cygnus.com) - - * Makefile.in: new targets binutils.dvi, binutils.info - - * binutils.texinfo: remove most remaining FIXME's, delete - references to __.SYMDEF by name - - -Tue Oct 8 10:23:44 1991 Steve Chamberlain (steve at cygnus.com) - - * objdump.c (print_address) Print addresses nicely. - -Mon Oct 7 11:31:05 1991 Per Bothner (bothner at cygnus.com) - - * ar.c, Makefile.in, new files {is,not,maybe}-ranlib.c: - Make two different binaries for ar and ranlib, instead of - distinguishing them at run time using argv[0]. - (Old behavior is still available if you "make ar_with_ranlib", - but it is not the default.) - * ranlib.sh (new): An alternative one-line - shell implementation of ranlib. - -Fri Oct 4 21:49:44 1991 John Gilmore (gnu at cygnus.com) - - * objdump.c: Cope with renames of a few BFD types & enums. - -Fri Oct 4 19:08:09 1991 Roland H. Pesch (pesch at cygnus.com) - - * binutils.texinfo: add new file (rudimentary docn) - -Mon Sep 30 12:30:39 1991 Per Bothner (bothner at cygnus.com) - - * config/hmake-news: Add new file (for Sony NEWSOS3). - * bucomm.c (fatal): Conditionally compile fatal() depending on - MISSING_VFPRINTF, and don't confuse the issue with NO_VARARGS. - * objdump.c (dump_headers): Trivial output format change. - * objdump.c (display_info): Loop over integers, not enums, - to appease old compilers. - -Mon May 20 16:14:07 1991 Steve Chamberlain (steve at cygint.cygnus.com) - - *objdump.c *nm.c *copy.c :hanged some types to work with 64 bit object files - -Thu May 16 16:06:55 1991 Steve Chamberlain (steve at cygint.cygnus.com) - from bother - * objdump.c (print_address): Make disasembled output more - consistent with gdb and as: Add 0x when printing hex. - Don't print extra leading zeros. - Attempt to not print "filename.o". - * objdump.c: Add some enum-to-int casts to accomodate old compilers. - - -Fri May 3 22:21:44 1991 John Gilmore (gnu at cygint.cygnus.com) - - * copy.c: Change =& constructs to = &, since they confuse older - C compilers. - - diff --git a/binutils/Makefile.in b/binutils/Makefile.in deleted file mode 100644 index 969792a72b6..00000000000 --- a/binutils/Makefile.in +++ /dev/null @@ -1,359 +0,0 @@ -# Makefile for GNU binary-file utilities -# Copyright (C) 1989-1991 Free Software Foundation, Inc. - -# 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 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., 675 Mass Ave, Cambridge, MA 02139, USA. - -#$Id$ - -srcdir = . - -ddestdir = /usr/local -idestdir = $(ddestdir) - -SHELL = /bin/sh -MAKEINFO=makeinfo -TEXI2ROFF=texi2roff - -# Distribution version -VERSION=1.91 -# Distribution name -DIST_NAME=binutils-beta-${VERSION} - -version=`$(unsubdir)/../gcc$(subdir)/gcc -dumpversion` -prefix = $(ddestdir) -bindir = $(prefix)/bin -mandir = $(idestdir)/man - -# Where to find texinfo.tex to format docn with TeX -TEXIDIR = $(srcdir)/../texinfo/fsf - -MANPAGES= ar.1 nm.1 objdump.1 ranlib.1 size.1 strip.1 - -#INSTALL = install -c -#INSTALL_PROGRAM = $(INSTALL) -#INSTALL_FILE = $(INSTALL) - -#CC=gcc -Wall -# these two are almost the same program -AR_PROG=ar -RANLIB_PROG=ranlib - -# copy and strip should be the same program -COPY_PROG=copy -STRIP_PROG=strip - -# These should all be the same program too. -SIZE_PROG=size -NM_PROG=nm -OBJDUMP_PROG=objdump - -PROGS = $(SIZE_PROG) $(COPY_PROG) $(OBJDUMP_PROG) $(NM_PROG) $(AR_PROG) $(STRIP_PROG) $(RANLIB_PROG) -STAGESTUFF = $(PROGS) *.o - -BASEDIR = $(srcdir)/.. -LIBDIR = $(unsubdir)/../bfd$(subdir) - -MINUS_G = -g -#### host and target dependant Makefile fragments come in here. -### - -INCDIR = $(BASEDIR)/include - -CFLAGS = $(MINUS_G) -I. -I$(srcdir) -I$(INCDIR) $(HDEFINES) $(TDEFINES) - -# When adding .o files, to make VPATH work in Sun Make, you have to -# also add a foo.o: foo.c line at the bottom of the file. -DISASMS = m68k-pinsn.o i960-pinsn.o sparc-pinsn.o am29k-pinsn.o - -# -## Random definitions -# Hopefully all these may be flushed once we get configuration down pat. - -# alloca only needed for systems which don't have it and when cc != gcc. -# ALLOCA = alloca.o - -# nm tries to malloc enough space for the string table. The old GNU malloc -# rounds this up to a power of two (e.g. 5M becomes 8M), and so it might -# fail unnecessarily. I've also seen some Unix malloc's fail, even when -# there is enough memory. So use the new GNU malloc. -# MALLOC = gmalloc.o - -# Use the GNU getopt unless you have problems with it. -# The IRIS version could probably benefit from being assembled with -# libmalloc rather than the ordinary malloc. -LIBIBERTY = $(unsubdir)/../libiberty$(subdir)/libiberty.a - -# Code shared by all the binutils. -BULIBS = bucomm.o version.o filemode.o - -ADDL_LIBS = $(MALLOC) $(BULIBS) $(BFD) $(LIBIBERTY) - -BFD = $(LIBDIR)/libbfd.a -# -## The rules - -all: $(ADDL_LIBS) $(PROGS) - -all-info: binutils.info - -#$(BFD):$(LIBDIR)/../common/*.c -# (cd $(LIBDIR); make) - -$(SIZE_PROG): $(ADDL_LIBS) size.o $(BFD) - $(CC) $(LDFLAGS) $(CFLAGS) -o $(SIZE_PROG) size.o $(ADDL_LIBS) $(LOADLIBES) - -$(COPY_PROG): $(ADDL_LIBS) copy.o $(BFD) - $(CC) $(LDFLAGS) $(CFLAGS) -o $(COPY_PROG) copy.o $(ADDL_LIBS) $(LOADLIBES) - -$(NM_PROG): $(ADDL_LIBS) nm.o $(BFD) - $(CC) $(LDFLAGS) $(CFLAGS) -o $(NM_PROG) nm.o $(ADDL_LIBS) $(LOADLIBES) - -$(OBJDUMP_PROG): $(ADDL_LIBS) size.o objdump.o $(DISASMS) $(BFD) - $(CC) $(LDFLAGS) $(CFLAGS) -o $(OBJDUMP_PROG) objdump.o $(DISASMS) $(ADDL_LIBS) $(LOADLIBES) - -$(AR_PROG): $(ADDL_LIBS) ar.o not-ranlib.o $(BFD) - $(CC) $(LDFLAGS) $(CFLAGS) -o $(AR_PROG) ar.o not-ranlib.o $(ADDL_LIBS) $(LOADLIBES) - -$(RANLIB_PROG): $(ADDL_LIBS) ar.o is-ranlib.o $(BFD) - $(CC) $(LDFLAGS) $(CFLAGS) -o $(RANLIB_PROG) ar.o is-ranlib.o $(ADDL_LIBS) $(LOADLIBES) - -# This rule creates a single binary that switches between ar and ranlib -# by looking at argv[0]. Use this kludge to save some disk space. -# However, you have to install things by hand. -# (That is after 'make install', replace the installed ranlib by a link to ar.) - -# Alternatively, you can install ranlib.sh as ranlib. - -ar_with_ranlib: $(ADDL_LIBS) ar.o maybe-ranlib.o $(BFD) - $(CC) $(LDFLAGS) $(CFLAGS) -o $(AR_PROG) ar.o maybe-ranlib.o $(ADDL_LIBS) $(LOADLIBES) - -rm -f $(RANLIB_PROG) - -ln $(AR_PROG) $(RANLIB_PROG) - -$(STRIP_PROG): $(COPY_PROG) - -rm -f $(STRIP_PROG) - -ln $(COPY_PROG) $(STRIP_PROG) - -stage1: force - - mkdir stage1 - - mv -f $(STAGESTUFF) stage1 - -stage2: force - - mkdir stage2 - - mv -f $(STAGESTUFF) stage2 - -stage3: force - - mkdir stage3 - - mv -f $(STAGESTUFF) stage3 - -against=stage2 - -comparison: force - for i in $(STAGESTUFF) ; do cmp $$i $(against)/$$i ; done - -de-stage1: force - - (cd stage1 ; mv -f * ..) - - rmdir stage1 - -de-stage2: force - - (cd stage2 ; mv -f * ..) - - rmdir stage2 - -de-stage3: force - - (cd stage3 ; mv -f * ..) - - rmdir stage3 - -###################################################################### -# DOCUMENTATION TARGETS -# TeX output -binutils.dvi: $(srcdir)/binutils.texi - TEXINPUTS=${TEXIDIR}:.:$$TEXINPUTS tex $(srcdir)/binutils.texi - texindex binutils.?? - TEXINPUTS=${TEXIDIR}:.:$$TEXINPUTS tex $(srcdir)/binutils.texi - -# info file for online browsing -binutils.info: $(srcdir)/binutils.texi - $(MAKEINFO) -o binutils.info $(srcdir)/binutils.texi - -# different targets for -ms, -mm, -me -# Try to use a recent texi2roff. v2 was put on prep in jan91. -# If you want an index, see texi2roff doc for postprocessing -# and add -i to texi2roff invocations below. -# Workarounds for texi2roff-2 (probably fixed in later texi2roff's, delete -# correspondint -e lines when later texi2roff's are current) -# + @ifinfo's deleted explicitly due to texi2roff-2 bug w nested constructs. -# + @c's deleted explicitly because texi2roff sees texinfo commands in them -# + @ (that's at-BLANK) not recognized by texi2roff, turned into blank -# + @alphaenumerate is ridiculously new, turned into @enumerate - -# roff output (-ms) -binutils.ms: $(srcdir)/binutils.texi - sed -e '/\\input texinfo/d' \ - -e '/@c TEXI2ROFF-KILL/,/@c END TEXI2ROFF-KILL/d' \ - -e '/^@ifinfo/,/^@end ifinfo/d' \ - -e '/^@c/d' \ - -e 's/{.*,,/{/' \ - -e 's/@ / /g' \ - -e 's/^@alphaenumerate/@enumerate/g' \ - -e 's/^@end alphaenumerate/@end enumerate/g' \ - $(srcdir)/binutils.texi | \ - texi2roff -ms | \ - sed -e 's/---/\\(em/g' \ - >binutils.ms - -# roff output (-mm) -# '@noindent's removed due to texi2roff-2 mm bug; if yours is newer, -# try leaving them in -binutils.mm: $(srcdir)/binutils.texi - sed -e '/\\input texinfo/d' \ - -e '/@c TEXI2ROFF-KILL/,/@c END TEXI2ROFF-KILL/d' \ - -e '/^@ifinfo/,/^@end ifinfo/d' \ - -e '/^@c/d' \ - -e 's/{.*,,/{/' \ - -e '/@noindent/d' \ - -e 's/@ / /g' \ - -e 's/^@alphaenumerate/@enumerate/g' \ - -e 's/^@end alphaenumerate/@end enumerate/g' \ - $(srcdir)/binutils.texi | \ - texi2roff -mm | \ - sed -e 's/---/\\(em/g' \ - >binutils.mm - -# roff output (-me) -binutils.me: $(srcdir)/binutils.texi - sed -e '/\\input texinfo/d' \ - -e '/@c TEXI2ROFF-KILL/,/@c END TEXI2ROFF-KILL/d' \ - -e '/^@ifinfo/,/^@end ifinfo/d' \ - -e '/^@c/d' \ - -e 's/{.*,,/{/' \ - -e 's/@ / /g' \ - -e 's/^@alphaenumerate/@enumerate/g' \ - -e 's/^@end alphaenumerate/@end enumerate/g' \ - $(srcdir)/binutils.texi | \ - texi2roff -me | \ - sed -e 's/---/\\(em/g' \ - >binutils.me - - -###################################################################### - -clean: - -rm -f *.o *~ \#* core $(STAGESTUFF) TAGS binutils.?? binutils.??? - -etags tags: TAGS - -TAGS: force - etags $(INCDIR)/*.h $(BFDSRC)/*.[hc] *.[hc] - -realclean: clean - -rm -f $(STAGESTUFF) TAGS - -install: all - for i in $(PROGS) ; do \ - (cp $$i $(bindir)/$$i.new \ - && mv -f $(bindir)/$$i.new $(bindir)/$$i) \ - || exit 1 ; \ - done - for i in $(MANPAGES) ; do \ - (cp $(srcdir)/$$i $(mandir)/man1/$$i.new \ - && mv -f $(mandir)/man1/$$i.new $(mandir)/man1/$$i) \ - || exit 1 ; \ - done - -install-info: all-info - for i in *.info* ; do \ - (cp $$i $(idestdir)/info/$$i.new \ - && mv -f $(idestdir)/info/$$i.new $(idestdir)/info/$$i) \ - || exit 1 ; \ - done - -dist: $(DIST_NAME).tar.Z - -$(DIST_NAME).tar.Z: - cd ../..; rm -f $(DIST_NAME); ln -s devo $(DIST_NAME) - make binutils.mm -f Makefile.in - cd ../ld; make ld.mm -f Makefile.in - cd ../..; tar chf - $(DIST_NAME) | compress >$(DIST_NAME).tar.Z - rm -rf ../../$(DIST_NAME) - -# These get around a bug in Sun Make in SunOS 4.1.1 -alloca.o:alloca.c -am29k-pinsn.o: am29k-pinsn.c -ar.o: ar.c -bucomm.o: bucomm.c -copy.o: copy.c -cplus-dem.o:cplus-dem.c -filemode.o:filemode.c -getopt.o:getopt.c -getopt1.o:getopt1.c -gmalloc.o:gmalloc.c -i960-pinsn.o: i960-pinsn.c -is-ranlib.o:is-ranlib.c -m68k-pinsn.o: m68k-pinsn.c -maybe-ranlib.o:maybe-ranlib.c -nm.o: nm.c -not-ranlib.o:not-ranlib.c -objdump.o: objdump.c -size.o: size.c -sparc-pinsn.o: sparc-pinsn.c -strip.o:strip.c -version.o: version.c - -#----------------------------------------------------------------------------- -# 'STANDARD' GNU/960 TARGETS BELOW THIS POINT -# -# 'VERSION' file must be present and contain a string of the form "x.y" -#----------------------------------------------------------------------------- - -ver960.c: FORCE - rm -f ver960.c - echo "char ${TARG}_ver[]= \"${TARG} `cat VERSION`, `date`\";" > ver960.c - - -# Dummy target to force execution of dependent targets. -# -force: - -# Target to uncomment host-specific lines in this makefile. Such lines must -# have the following string beginning in column 1: #____# -# Original Makefile is backed up as 'Makefile.old'. -# -# Invoke with: make make HOST=xxx -# -make: - -@if test $(HOST)x = x ; then \ - echo 'Specify "make make HOST=???"'; \ - exit 1; \ - fi ; \ - grep -s "^#The next line was generated by 'make make'" Makefile; \ - if test $$? = 0 ; then \ - echo "Makefile has already been processed with 'make make'";\ - exit 1; \ - fi ; \ - mv -f Makefile Makefile.old; \ - echo "#The next line was generated by 'make make'" >Makefile ; \ - echo "HOST=$(HOST)" >>Makefile ; \ - echo >>Makefile ; \ - sed "s/^#__$(HOST)__#//" < Makefile.old >>Makefile - -Makefile: $(srcdir)/Makefile.in $(host_makefile_frag) $(target_makefile_frag) - $(SHELL) ./config.status - -### Local Variables: *** -### mode:fundamental *** -### page-delimiter: "^# " *** -### End: *** -### end of file diff --git a/binutils/README b/binutils/README deleted file mode 100644 index 7482e0b91d0..00000000000 --- a/binutils/README +++ /dev/null @@ -1,73 +0,0 @@ -This is a BETA release of a completely rewritten binutils distribution. -The linker (ld) has been moved into a separate directory, -which should be ../ld. Linker-specific notes are in ../ld/README. - -These programs have been tested on various architectures. -Most recently tested are sun3 and sun4s running sunos4, -as well as Sony News running newsos3. -However, since this is a beta release taken directly from an -evolving source tree, there might be some problems. In particular, -the programs have not been ported to as many machines as the -old binutils. There are also features of the old versions -that are missing on the new programs. We would appreciate -patches to make things run on other machines; especially welcome -are fixes for what used to work on the old programs! - -Unpacking and Installation -- quick overview -========================== - -In this release, the binary utilities, the linker, the generic GNU include -files, the BFD ("binary file description") library, and getopt all have -directories of their own underneath the binutils-2.0 directory. -The idea is that a variety of GNU tools can -share a common copy of these things. Configuration scripts and -makefiles exist to cruise up and down this directory tree and -automatically build all the pieces in the right order. - -When you unpack the binutils-2.0.tar.Z file, you'll get a directory called -something like `binutils-2.0', which contains: - - DOC.configure README config/ configure* ld/ - Makefile bfd/ config.status* configure.in libiberty/ - Makefile.in binutils/ config.sub include/ texinfo/ - -To build binutils, you can just do: - - cd binutils-2.0 - ./configure HOSTTYPE (e.g. sun4, decstation) - make - make install # copies the programs files into /usr/local/bin by default. - -This will configure and build all the libraries as well as binutils -and the linker. - -The binutils can be used in a cross-development environment. -The file DOC.configure contains more information. - -Porting -======= -Binutils-2.0 supports many different architectures, but there -are many more not supported, including some that were supported -by earlier versions. We are hoping for volunteers to -improve this situation. - -The major effort in porting binutils to a new host and/or target -architecture involves the BFD library. There is some documentation -in ../bfd/doc. The file ../gdb/doc/gdbint.texinfo (distributed -with gdb-3.2) may also be of help. - -If your system uses some variant of old-style a.out-format, -you can start with a copy of bfd/newsos3.c, and edit it to fit. -(You may also need to tweak bfd/aout-target.h.) -Alternatively, you could use the host-aout.c target. This is a -special kludge that only works for native (non-cross) configurations. - -Reporting bugs -============== -If you can't track down a bug and send suggestions/patches -for fixes, you should probably *not* be using this release. -I cannot work on finding bugs at this stage (except for -Cygnus-supported configurations). But if you have suggestions -or patches, send them to bothner@cygnus.com, for now. -(After the official release, the correct address will -be bug-gnu-utils@ai.mit.edu.) diff --git a/binutils/TODO b/binutils/TODO deleted file mode 100644 index 328c473f74a..00000000000 --- a/binutils/TODO +++ /dev/null @@ -1,17 +0,0 @@ -o - strip - Implement various options - Make faster by using ftruncate if available (and format is suitable). - -OLD: - -o - merge: - copy and strip - ar and ranlib - nm, size, and objdump - -o - make the long options more consistent. - -o - make ATT and BSD versions -- perhaps the options should be - controlled by an environment variable. - -o - Calling +help or +version should exit with a successful status (ie 0) diff --git a/binutils/alloca.c b/binutils/alloca.c deleted file mode 100644 index 9639def3142..00000000000 --- a/binutils/alloca.c +++ /dev/null @@ -1,191 +0,0 @@ -/* - alloca -- (mostly) portable public-domain implementation -- D A Gwyn - - last edit: 86/05/30 rms - include config.h, since on VMS it renames some symbols. - Use xmalloc instead of malloc. - - This implementation of the PWB library alloca() function, - which is used to allocate space off the run-time stack so - that it is automatically reclaimed upon procedure exit, - was inspired by discussions with J. Q. Johnson of Cornell. - - It should work under any C implementation that uses an - actual procedure stack (as opposed to a linked list of - frames). There are some preprocessor constants that can - be defined when compiling for your specific system, for - improved efficiency; however, the defaults should be okay. - - The general concept of this implementation is to keep - track of all alloca()-allocated blocks, and reclaim any - that are found to be deeper in the stack than the current - invocation. This heuristic does not reclaim storage as - soon as it becomes invalid, but it will do so eventually. - - As a special case, alloca(0) reclaims storage without - allocating any. It is a good idea to use alloca(0) in - your main control loop, etc. to force garbage collection. -*/ -#ifndef lint -static char SCCSid[] = "@(#)alloca.c 1.1"; /* for the "what" utility */ -#endif - -#ifdef emacs -#include "config.h" -#ifdef static -/* actually, only want this if static is defined as "" - -- this is for usg, in which emacs must undefine static - in order to make unexec workable - */ -#ifndef STACK_DIRECTION -you -lose --- must know STACK_DIRECTION at compile-time -#endif /* STACK_DIRECTION undefined */ -#endif /* static */ -#endif /* emacs */ - -#ifdef X3J11 -typedef void *pointer; /* generic pointer type */ -#else -typedef char *pointer; /* generic pointer type */ -#endif - -#define NULL 0 /* null pointer constant */ - -extern void free(); -extern pointer xmalloc(); - -/* - Define STACK_DIRECTION if you know the direction of stack - growth for your system; otherwise it will be automatically - deduced at run-time. - - STACK_DIRECTION > 0 => grows toward higher addresses - STACK_DIRECTION < 0 => grows toward lower addresses - STACK_DIRECTION = 0 => direction of growth unknown -*/ - -#ifndef STACK_DIRECTION -#define STACK_DIRECTION 0 /* direction unknown */ -#endif - -#if STACK_DIRECTION != 0 - -#define STACK_DIR STACK_DIRECTION /* known at compile-time */ - -#else /* STACK_DIRECTION == 0; need run-time code */ - -static int stack_dir; /* 1 or -1 once known */ -#define STACK_DIR stack_dir - -static void -find_stack_direction (/* void */) -{ - static char *addr = NULL; /* address of first - `dummy', once known */ - auto char dummy; /* to get stack address */ - - if (addr == NULL) - { /* initial entry */ - addr = &dummy; - - find_stack_direction (); /* recurse once */ - } - else /* second entry */ - if (&dummy > addr) - stack_dir = 1; /* stack grew upward */ - else - stack_dir = -1; /* stack grew downward */ -} - -#endif /* STACK_DIRECTION == 0 */ - -/* - An "alloca header" is used to: - (a) chain together all alloca()ed blocks; - (b) keep track of stack depth. - - It is very important that sizeof(header) agree with malloc() - alignment chunk size. The following default should work okay. -*/ - -#ifndef ALIGN_SIZE -#define ALIGN_SIZE sizeof(double) -#endif - -typedef union hdr -{ - char align[ALIGN_SIZE]; /* to force sizeof(header) */ - struct - { - union hdr *next; /* for chaining headers */ - char *deep; /* for stack depth measure */ - } h; -} header; - -/* - alloca( size ) returns a pointer to at least `size' bytes of - storage which will be automatically reclaimed upon exit from - the procedure that called alloca(). Originally, this space - was supposed to be taken from the current stack frame of the - caller, but that method cannot be made to work for some - implementations of C, for example under Gould's UTX/32. -*/ - -static header *last_alloca_header = NULL; /* -> last alloca header */ - -pointer -alloca (size) /* returns pointer to storage */ - unsigned size; /* # bytes to allocate */ -{ - auto char probe; /* probes stack depth: */ - register char *depth = &probe; - -#if STACK_DIRECTION == 0 - if (STACK_DIR == 0) /* unknown growth direction */ - find_stack_direction (); -#endif - - /* Reclaim garbage, defined as all alloca()ed storage that - was allocated from deeper in the stack than currently. */ - - { - register header *hp; /* traverses linked list */ - - for (hp = last_alloca_header; hp != NULL;) - if (STACK_DIR > 0 && hp->h.deep > depth - || STACK_DIR < 0 && hp->h.deep < depth) - { - register header *np = hp->h.next; - - free ((pointer) hp); /* collect garbage */ - - hp = np; /* -> next header */ - } - else - break; /* rest are not deeper */ - - last_alloca_header = hp; /* -> last valid storage */ - } - - if (size == 0) - return NULL; /* no allocation required */ - - /* Allocate combined header + user data storage. */ - - { - register pointer new = xmalloc (sizeof (header) + size); - /* address of header */ - - ((header *)new)->h.next = last_alloca_header; - ((header *)new)->h.deep = depth; - - last_alloca_header = (header *)new; - - /* User storage begins just after header. */ - - return (pointer)((char *)new + sizeof(header)); - } -} - diff --git a/binutils/am29k-pinsn.c b/binutils/am29k-pinsn.c deleted file mode 100644 index 431fe5e0725..00000000000 --- a/binutils/am29k-pinsn.c +++ /dev/null @@ -1,349 +0,0 @@ -/* Instruction printing code for the AMD 29000 - Copyright (C) 1990 Free Software Foundation, Inc. - Contributed by Cygnus Support. Written by Jim Kingdon. - -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 1, 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; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include - -#ifdef GDB -# include "defs.h" -# include "target.h" -# include "am29k-opcode.h" -#else -# include "bfd.h" -# include "sysdep.h" -# include "a29k-opcode.h" -# define am29k_opcodes a29k_opcodes -# define am29k_opcode a29k_opcode -# define NUM_OPCODES num_opcodes -# define fprintf_filtered fprintf -#endif - - -/* Print a symbolic representation of a general-purpose - register number NUM on STREAM. - NUM is a number as found in the instruction, not as found in - debugging symbols; it must be in the range 0-255. */ -static void -print_general (num, stream) - int num; - FILE *stream; -{ - if (num < 128) - fprintf_filtered (stream, "gr%d", num); - else - fprintf_filtered (stream, "lr%d", num - 128); -} - -/* Like print_general but a special-purpose register. - - The mnemonics used by the AMD assembler are not quite the same - as the ones in the User's Manual. We use the ones that the - assembler uses. */ -static void -print_special (num, stream) - int num; - FILE *stream; -{ - /* Register names of registers 0-SPEC0_NUM-1. */ - static char *spec0_names[] = { - "vab", "ops", "cps", "cfg", "cha", "chd", "chc", "rbp", "tmc", "tmr", - "pc0", "pc1", "pc2", "mmu", "lru" - }; -#define SPEC0_NUM ((sizeof spec0_names) / (sizeof spec0_names[0])) - - /* Register names of registers 128-128+SPEC128_NUM-1. */ - static char *spec128_names[] = { - "ipc", "ipa", "ipb", "q", "alu", "bp", "fc", "cr" - }; -#define SPEC128_NUM ((sizeof spec128_names) / (sizeof spec128_names[0])) - - /* Register names of registers 160-160+SPEC160_NUM-1. */ - static char *spec160_names[] = { - "fpe", "inte", "fps", "sr163", "exop" - }; -#define SPEC160_NUM ((sizeof spec160_names) / (sizeof spec160_names[0])) - - if (num < SPEC0_NUM) - fprintf_filtered (stream, spec0_names[num]); - else if (num >= 128 && num < 128 + SPEC128_NUM) - fprintf_filtered (stream, spec128_names[num-128]); - else if (num >= 160 && num < 160 + SPEC160_NUM) - fprintf_filtered (stream, spec160_names[num-160]); - else - fprintf_filtered (stream, "sr%d", num); -} - -/* Is an instruction with OPCODE a delayed branch? */ -static int -is_delayed_branch (opcode) - int opcode; -{ - return (opcode == 0xa8 || opcode == 0xa9 || opcode == 0xa0 || opcode == 0xa1 - || opcode == 0xa4 || opcode == 0xa5 - || opcode == 0xb4 || opcode == 0xb5 - || opcode == 0xc4 || opcode == 0xc0 - || opcode == 0xac || opcode == 0xad - || opcode == 0xcc); -} - -/* Now find the four bytes of INSN and put them in *INSN{0,8,16,24}. - Note that the amd can be set up as either - big or little-endian (the tm file says which) and we can't assume - the host machine is the same. */ -static void -find_bytes (insn, insn0, insn8, insn16, insn24) - char *insn; - unsigned char *insn0; - unsigned char *insn8; - unsigned char *insn16; - unsigned char *insn24; -{ -#if TARGET_BYTE_ORDER == BIG_ENDIAN - *insn24 = insn[0]; - *insn16 = insn[1]; - *insn8 = insn[2]; - *insn0 = insn[3]; -#else /* Little-endian. */ - *insn24 = insn[3]; - *insn16 = insn[2]; - *insn8 = insn[1]; - *insn0 = insn[0]; -#endif /* Little-endian. */ -} - -/* Print one instruction from MEMADDR on STREAM. - Return the size of the instruction (always 4 on am29k). */ -#ifdef GDB -print_insn (memaddr, stream) - CORE_ADDR memaddr; - FILE *stream; -#else -int -print_insn_a29k (memaddr, buffer, stream) - bfd_vma memaddr; - uint8e_type *buffer; - FILE *stream; -#endif -{ - /* The raw instruction. */ - char insn[4]; - - /* The four bytes of the instruction. */ - unsigned char insn24, insn16, insn8, insn0; - unsigned long value; - CONST struct am29k_opcode *opcode; - -#ifdef GDB - read_memory (memaddr, &insn[0], 4); -#else - insn[0] = ((char*)buffer)[0]; - insn[1] = ((char*)buffer)[1]; - insn[2] = ((char*)buffer)[2]; - insn[3] = ((char*)buffer)[3]; -#endif - - find_bytes (insn, &insn0, &insn8, &insn16, &insn24); - - value = (insn24 << 24) + (insn16 << 16) + (insn8 << 8) + insn0; - /* Handle the nop (aseq 0x40,gr1,gr1) specially */ - if ((insn24==0x70) && (insn16==0x40) && (insn8==0x01) && (insn0==0x01)) { - fprintf_filtered (stream,"nop"); - return 4; - } - - - /* The opcode is always in insn24. */ - for (opcode = &am29k_opcodes[0]; - opcode < &am29k_opcodes[NUM_OPCODES]; - ++opcode) - { -#ifdef GDB - if (insn24 == opcode->opcode) -#else - if (insn24 == (opcode->opcode >> 24)) -#endif - { - char *s; - - fprintf_filtered (stream, "%s ", opcode->name); - for (s = opcode->args; *s != '\0'; ++s) - { - switch (*s) - { - case 'a': - print_general (insn8, stream); - break; - - case 'b': - print_general (insn0, stream); - break; - - case 'c': - print_general (insn16, stream); - break; - - case 'i': - fprintf_filtered (stream, "%d", insn0); - break; - - case 'x': - fprintf_filtered (stream, "%d", (insn16 << 8) + insn0); - break; - - case 'h': - fprintf_filtered (stream, "0x%x", - (insn16 << 24) + (insn0 << 16)); - break; - - case 'X': - fprintf_filtered (stream, "%d", - ((insn16 << 8) + insn0) | 0xffff0000); - break; - - case 'P': - /* This output looks just like absolute addressing, but - maybe that's OK (it's what the GDB 68k and EBMON - 29k disassemblers do). */ - /* All the shifting is to sign-extend it. p*/ - print_address - (memaddr + - (((int)((insn16 << 10) + (insn0 << 2)) << 14) >> 14), - stream); - break; - - case 'A': - print_address ((insn16 << 10) + (insn0 << 2), stream); - break; - - case 'e': - fprintf_filtered (stream, "%d", insn16 >> 7); - break; - - case 'n': - fprintf_filtered (stream, "0x%x", insn16 & 0x7f); - break; - - case 'v': - fprintf_filtered (stream, "%x", insn16); - break; - - case 's': - print_special (insn8, stream); - break; - - case 'u': - fprintf_filtered (stream, "%d", insn0 >> 7); - break; - - case 'r': - fprintf_filtered (stream, "%d", (insn0 >> 4) & 7); - break; - - case 'd': - fprintf_filtered (stream, "%d", (insn0 >> 2) & 3); - break; - - case 'f': - fprintf_filtered (stream, "%d", insn0 & 3); - break; - - case 'F': - fprintf_filtered (stream, "%d", (value >> 18) & 0xf); - break; - - case 'C': - fprintf_filtered (stream, "%d", (value >> 16) & 3); - break; - - default: - fprintf_filtered (stream, "%c", *s); - } - } - - /* Now we look for a const,consth pair of instructions, - in which case we try to print the symbolic address. */ - if (insn24 == 2) /* consth */ - { - int errcode; - char prev_insn[4]; - unsigned char prev_insn0, prev_insn8, prev_insn16, prev_insn24; - -#ifdef GDB - errcode = target_read_memory (memaddr - 4, - &prev_insn[0], - 4); -#else - prev_insn[0] = ((char*)buffer)[0-4]; - prev_insn[1] = ((char*)buffer)[1-4]; - prev_insn[2] = ((char*)buffer)[2-4]; - prev_insn[3] = ((char*)buffer)[3-4]; - errcode = 0; -#endif - if (errcode == 0) - { - /* If it is a delayed branch, we need to look at the - instruction before the delayed brach to handle - things like - - const _foo - call _printf - consth _foo - */ - find_bytes (prev_insn, &prev_insn0, &prev_insn8, - &prev_insn16, &prev_insn24); - if (is_delayed_branch (prev_insn24)) - { -#ifdef GDB - errcode = target_read_memory - (memaddr - 8, &prev_insn[0], 4); -#else - prev_insn[0] = ((char*)buffer)[0-8]; - prev_insn[1] = ((char*)buffer)[1-8]; - prev_insn[2] = ((char*)buffer)[2-8]; - prev_insn[3] = ((char*)buffer)[3-8]; - errcode = 0; -#endif - find_bytes (prev_insn, &prev_insn0, &prev_insn8, - &prev_insn16, &prev_insn24); - } - } - - /* If there was a problem reading memory, then assume - the previous instruction was not const. */ - if (errcode == 0) - { - /* Is it const to the same register? */ - if (prev_insn24 == 3 - && prev_insn8 == insn8) - { - fprintf_filtered (stream, "\t; "); - print_address (((insn16 << 24) + (insn0 << 16) - + (prev_insn16 << 8) + (prev_insn0)), - stream); - } - } - } - - return 4; - } - } - fprintf_filtered (stream, ".word %8x", - (insn24 << 24) + (insn16 << 16) + (insn8 << 8) + insn0); - return 4; -} diff --git a/binutils/ar.1 b/binutils/ar.1 deleted file mode 100644 index 1cb4074b5f1..00000000000 --- a/binutils/ar.1 +++ /dev/null @@ -1,471 +0,0 @@ -.\" Copyright (c) 1991 Free Software Foundation -.\" See section COPYING for conditions for redistribution -.\" $Id$ -.TH ar 1 "5 November 1991" "cygnus support" "GNU Development Tools" -.de BP -.sp -.ti \-.2i -\(** -.. - -.SH NAME -ar\(em\&create, modify, and extract from archives. - -.SH SYNOPSIS -.hy 0 -.na -.BR ar " [\|" "-" "\|]"\c -.I pmod \c -[\|\c -.I membername\c -\&\|] \c -.I archive\c -\& \c -.I files\c -\&.\|.\|. - -.ad b -.hy 1 -.SH DESCRIPTION -The GNU \c -.B ar\c -\& program creates, modifies, and extracts from -archives. An \c -.I archive\c -\& is a single file holding a collection of -other files in a structure that makes it possible to retrieve -the original individual files (called \c -.I members\c -\& of the archive). - -The original files' contents, mode (permissions), timestamp, owner, and -group are preserved in the archive, and may be reconstituted on -extraction. - -GNU \c -.B ar\c -\& can maintain archives whose members have names of any -length; however, depending on how \c -.B ar\c -\& is configured on your -system, a limit on member-name length may be imposed (for compatibility -with archive formats maintained with other tools). If it exists, the -limit is often 15 characters (typical of formats related to a.out) or 16 -characters (typical of formats related to coff). - -\c -.B ar\c -\& is considered a binary utility because archives of this sort -are most often used as \c -.I libraries\c -\& holding commonly needed -subroutines. - -\c -.B ar\c -\& will create an index to the symbols defined in relocatable -object modules in the archive when you specify the modifier `\|\c -.B s\c -\|'. -Once created, this index is updated in the archive whenever \c -.B ar\c -\& -makes a change to its contents (save for the `\|\c -.B q\c -\|' update operation). -An archive with such an index speeds up linking to the library, and -allows routines in the library to call each other without regard to -their placement in the archive. - -You may use `\|\c -.B nm \-s\c -\|' or `\|\c -.B nm +print-armap\c -\|' to list this index -table. If an archive lacks the table, another form of \c -.B ar\c -\& called -\c -.B ranlib\c -\& can be used to add just the table. - -\c -.B ar\c -\& insists on at least two arguments to execute: one -keyletter specifying the \c -.I operation\c -\& (optionally accompanied by other -keyletters specifying \c -.I modifiers\c -\&), and the archive name to act on. - -Most operations can also accept further \c -.I files\c -\& arguments, -specifying particular files to operate on. - -.SH OPTIONS -GNU \c -.B ar\c -\& allows you to mix the operation code \c -.I p\c -\& and modifier -flags \c -.I mod\c -\& in any order, within the first command-line argument. - -If you wish, you may begin the first command-line argument with a -dash. - -The \c -.I p\c -\& keyletter specifies what operation to execute; it may be -any of the following, but you must specify only one of them: - -.TP -.B d -\c -.I Delete\c -\& modules from the archive. Specify the names of modules to -be deleted as \c -.I files\c -\&; the archive is untouched if you -specify no files to delete. - -If you specify the `\|\c -.B v\c -\|' modifier, \c -.B ar\c -\& will list each module -as it is deleted. - -.TP -.B m -Use this operation to \c -.I move\c -\& members in an archive. - -The ordering of members in an archive can make a difference in how -programs are linked using the library, if a symbol is defined in more -than one member. - -If no modifiers are used with \c -.B m\c -\&, any members you name in the -\c -.I files\c -\& arguments are moved to the \c -.I end\c -\& of the archive; -you can use the `\|\c -.B a\c -\|', `\|\c -.B b\c -\|', or `\|\c -.B i\c -\|' modifiers to move them to a -specified place instead. - -.TP -.B p -\c -.I Print\c -\& the specified members of the archive, to the standard -output file. If the `\|\c -.B v\c -\|' modifier is specified, show the member -name before copying its contents to standard output. - -If you specify no \c -.I files\c -\&, all the files in the archive are printed. - -.TP -.B q -\c -.I Quick append\c -\&; add \c -.I files\c -\& to the end of \c -.I archive\c -\&, -without checking for replacement. - -The modifiers `\|\c -.B a\c -\|', `\|\c -.B b\c -\|', and `\|\c -.B i\c -\|' do \c -.I not\c -\& affect this -operation; new members are always placed at the end of the archive. - -The modifier `\|\c -.B v\c -\|' makes \c -.B ar\c -\& list each file as it is appended. - -Since the point of this operation is speed, the archive's symbol table -index is not updated, even if it already existed; you can use `\|\c -.B ar s\c -\|' or -\c -.B ranlib\c -\& explicitly to update the symbol table index. - -.TP -.B r -Insert \c -.I files\c -\& into \c -.I archive\c -\& (with \c -.I replacement\c -\&). This -operation differs from `\|\c -.B q\c -\|' in that any previously existing members -are deleted if their names match those being added. - -If one of the files named in \c -.I files\c -\& doesn't exist, \c -.B ar\c -\& -displays an error message, and leaves undisturbed any existing members -of the archive matching that name. - -By default, new members are added at the end of the file; but you may -use one of the modifiers `\|\c -.B a\c -\|', `\|\c -.B b\c -\|', or `\|\c -.B i\c -\|' to request -placement relative to some existing member. - -The modifier `\|\c -.B v\c -\|' used with this operation elicits a line of -output for each file inserted, along with one of the letters `\|\c -.B a\c -\|' or -`\|\c -.B r\c -\|' to indicate whether the file was appended (no old member -deleted) or replaced. - -.TP -.B t -Display a \c -.I table\c -\& listing the contents of \c -.I archive\c -\&, or those -of the files listed in \c -.I files\c -\& that are present in the -archive. Normally only the member name is shown; if you also want to -see the modes (permissions), timestamp, owner, group, and size, you can -request that by also specifying the `\|\c -.B v\c -\|' modifier. - -If you do not specify any \c -.I files\c -\&, all files in the archive -are listed. - -If there is more than one file with the same name (say, `\|\c -.B fie\c -\|') in -an archive (say `\|\c -.B b.a\c -\|'), `\|\c -.B ar t b.a fie\c -\|' will list only the -first instance; to see them all, you must ask for a complete -listing\(em\&in our example, `\|\c -.B ar t b.a\c -\|'. - -.TP -.B x -\c -.I Extract\c -\& members (named \c -.I files\c -\&) from the archive. You can -use the `\|\c -.B v\c -\|' modifier with this operation, to request that -\c -.B ar\c -\& list each name as it extracts it. - -If you do not specify any \c -.I files\c -\&, all files in the archive -are extracted. - -.PP - -A number of modifiers (\c -.I mod\c -\&) may immediately follow the \c -.I p\c -\& -keyletter, to specify variations on an operation's behavior: - -.TP -.B a -Add new files \c -.I after\c -\& an existing member of the -archive. If you use the modifier \c -.B a\c -\&, the name of an existing archive -member must be present as the \c -.I membername\c -\& argument, before the -\c -.I archive\c -\& specification. - -.TP -.B b -Add new files \c -.I before\c -\& an existing member of the -archive. If you use the modifier \c -.B b\c -\&, the name of an existing archive -member must be present as the \c -.I membername\c -\& argument, before the -\c -.I archive\c -\& specification. (same as `\|\c -.B i\c -\|'). - -.TP -.B c -\c -.I Create\c -\& the archive. The specified \c -.I archive\c -\& is always -created if it didn't exist, when you request an update. But a warning is -issued unless you specify in advance that you expect to create it, by -using this modifier. - -.TP -.B i -Insert new files \c -.I before\c -\& an existing member of the -archive. If you use the modifier \c -.B i\c -\&, the name of an existing archive -member must be present as the \c -.I membername\c -\& argument, before the -\c -.I archive\c -\& specification. (same as `\|\c -.B b\c -\|'). - -.TP -.B l -This modifier is accepted but not used. - -.TP -.B o -Preserve the \c -.I original\c -\& dates of members when extracting them. If -you do not specify this modifier, files extracted from the archive -will be stamped with the time of extraction. - -.TP -.B s -Write an object-file index into the archive, or update an existing one, -even if no other change is made to the archive. You may use this modifier -flag either with any operation, or alone. Running `\|\c -.B ar s\c -\|' on an -archive is equivalent to running `\|\c -.B ranlib\c -\|' on it. - -.TP -.B u -Normally, \c -.B ar r\c -\&.\|.\|. inserts all files -listed into the archive. If you would like to insert \c -.I only\c -\& those -of the files you list that are newer than existing members of the same -names, use this modifier. The `\|\c -.B u\c -\|' modifier is allowed only for the -operation `\|\c -.B r\c -\|' (replace). In particular, the combination `\|\c -.B qu\c -\|' is -not allowed, since checking the timestamps would lose any speed -advantage from the operation `\|\c -.B q\c -\|'. - -.TP -.B v -This modifier requests the \c -.I verbose\c -\& version of an operation. Many -operations display additional information, such as filenames processed, -when the modifier `\|\c -.B v\c -\|' is appended. - -.PP - -.SH "SEE ALSO" -.RB "`\|" binutils "\|'" -entry in -.B -info\c -\&; -.I -The GNU Binary Utilities\c -, Roland H. Pesch (October 1991). -.BR nm ( 1 )\c -\&, -.BR ranlib( 1 )\c -\&. - -.SH COPYING -Copyright (c) 1991 Free Software Foundation, Inc. -.PP -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. -.PP -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided that the -entire resulting derived work is distributed under the terms of a -permission notice identical to this one. -.PP -Permission is granted to copy and distribute translations of this -manual into another language, under the above conditions for modified -versions, except that this permission notice may be included in -translations approved by the Free Software Foundation instead of in -the original English. diff --git a/binutils/ar.c b/binutils/ar.c deleted file mode 100644 index dbce5907e42..00000000000 --- a/binutils/ar.c +++ /dev/null @@ -1,945 +0,0 @@ -/* ar.c - Archive modify and extract. - Copyright (C) 1991 Free Software Foundation, Inc. - -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 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - Bugs: should use getopt the way tar does (complete w/optional -) and - should have long options too. GNU ar used to check file against filesystem - in quick_update and replace operations (would check mtime). Doesn't warn - when name truncated. No way to specify pos_end. Error messages should be - more consistant. -*/ -#include "bfd.h" -#include "sysdep.h" -#include "ar.h" -#include -#include -#include -#define BUFSIZE 8192 -/* FIXME: Not great to have these here. Should they be exported or not? */ -PROTO(size_t, bfd_read, (void *ptr, size_t size, size_t nitems, bfd * abfd)); -PROTO(size_t, bfd_write, (void *ptr, size_t size, size_t nitems, bfd * abfd)); -/* PROTO (void, open_inarch, (char *archive_filename)); */ -#ifdef __STDC__ -static void open_inarch(char *archive_filename); -#else -static void open_inarch(); -#endif /* __STDC__ */ - -PROTO(void, map_over_members, (void (*function) (), char **files, int count)); -PROTO(void, print_contents, (bfd * member)); -PROTO(void, extract_file, (bfd * abfd)); -PROTO(void, delete_members, (char **files_to_delete)); -PROTO(void, do_quick_append, (char *archive_filename, char **files_to_append)); -PROTO(void, move_members, (char **files_to_move)); -PROTO(void, replace_members, (char **files_to_replace)); -PROTO(void, print_descr, (bfd * abfd)); -PROTO(void, ranlib_only, (char *archname)); - -/** Globals and flags */ - -char *program_name = NULL; -bfd bogus_archive; -bfd *inarch; /* The input arch we're manipulating */ - -/* This flag distinguishes between ar and ranlib: - 1 means this is 'ranlib'; -1 means this is 'ar'. - 0 means if we should use argv[0] to decide. */ -extern int is_ranlib; -/* Nonzero means don't warn about creating the archive file if necessary. */ -int silent_create = 0; -/* Nonzero means describe each action performed. */ -int verbose = 0; -/* Nonzero means preserve dates of members when extracting them. */ -int preserve_dates = 0; -/* - Nonzero means don't replace existing members whose dates are more recent - than the corresponding files. -*/ -int newer_only = 0; -/* write a __.SYMDEF member into the modified archive. */ -boolean write_armap = false; -/* - Nonzero means don't update __.SYMDEF unless command line explicitly - requested it -*/ -int ignore_symdef = 0; -/* - Nonzero means it's the name of an existing member; position new or moved - files with respect to this one. -*/ -char *posname = NULL; -/* - Sez how to use `posname': pos_before means position before that member. - pos_after means position after that member. pos_end means always at end. - pos_default means default appropriately. For the latter two, `posname' - should also be zero. -*/ -enum pos { - pos_default, pos_before, pos_after, pos_end -} postype = pos_default; - -#ifdef GNU960 - char *default_target; - - void - gnu960_verify_target(abfd) - bfd *abfd; - { - if ( abfd->format == bfd_unknown ){ - bfd_check_format(abfd, bfd_object); - /* Don't really care if it's an object -- - * just want to get the correct xvec. - */ - } - if ( !BFD_COFF_FILE_P(abfd) ){ - fatal( "'%s' not a COFF file -- operation aborted", - abfd->filename ); - } - } -#endif - - - -boolean operation_alters_arch = false; - -/* - The option parsing should be in its own function. It will be when I have - getopt working. -*/ -int -main(argc, argv) - int argc; - char **argv; -{ - char *arg_ptr; - char c; - enum { - none = 0, delete, replace, print_table, - print_files, extract, move, quick_append - } operation = none; - int arg_index; - char **files; - char *inarch_filename; - char *temp; - - bfd_init(); - -#ifdef GNU960 - check_v960( argc, argv ); - default_target = bfd_make_targ_name(BFD_COFF_FORMAT,HOST_BYTE_ORDER_BIG_P); -#endif - - program_name = argv[0]; - - temp = strrchr(program_name, '/'); - if (temp == (char *) NULL) - temp = program_name; /* shouldn't happen, but... */ - else - ++temp; - if (is_ranlib > 0 || (is_ranlib == 0 && strcmp(temp, "ranlib") == 0)) { - if (argc < 2) - fatal("Too few command arguments."); - ranlib_only(argv[1]); - } - - - if (argc < 3) - fatal("Too few command arguments."); - - arg_ptr = argv[1]; - - if (*arg_ptr == '-') - ++arg_ptr; /* compatibility */ - - while (c = *arg_ptr++) { - switch (c) { - case 'd': - case 'm': - case 'p': - case 'q': - case 'r': - case 't': - case 'x': - if (operation != none) - fatal("two different operation switches specified"); - switch (c) { - case 'd': - operation = delete; - operation_alters_arch = true; - break; - case 'm': - operation = move; - operation_alters_arch = true; - break; - case 'p': - operation = print_files; - break; - case 'q': - operation = quick_append; - operation_alters_arch = true; - break; - case 'r': - operation = replace; - operation_alters_arch = true; - break; - case 't': - operation = print_table; - break; - case 'x': - operation = extract; - break; - } - case 'l': - break; - case 'c': - silent_create = 1; - break; - case 'o': - preserve_dates = 1; - break; - case 's': - write_armap = true; - break; - case 'u': - newer_only = 1; - break; - case 'v': - verbose = 1; - break; - case 'a': - postype = pos_after; - break; - case 'b': - postype = pos_before; - break; - case 'i': - postype = pos_before; - break; - default: - fatal("invalid option %c", c); - } - } - - if ((operation == none || operation == print_table) - && write_armap == true) - ranlib_only(argv[2]); - - if (operation == none) - fatal("no operation specified"); - - if (newer_only && operation != replace) - fatal("'u' only meaningful with 'r' option."); - - arg_index = 2; - - if (postype != pos_default) - posname = argv[arg_index++]; - - inarch_filename = argv[arg_index++]; - - if (arg_index < argc) { - files = argv + arg_index; - while (arg_index < argc) - if (!strcmp(argv[arg_index++], "__.SYMDEF")) { - ignore_symdef = 1; - break; - } - } - else - files = NULL; - - if (operation == quick_append) { - if (files != NULL) - do_quick_append(inarch_filename, files); - exit(0); - } - - - open_inarch(inarch_filename); - /* - If we have no archive, and we've been asked to replace then create one - */ -#if 0 - if (operation == replace && inarch == &bogus_archive) { - silent_create = 1; - do_quick_append(inarch_filename, 0); - open_inarch(inarch_filename); - } -#endif - switch (operation) { - - case print_table: - map_over_members(print_descr, files, argc - 3); - break; - - case print_files: - map_over_members(print_contents, files, argc - 3); - break; - - case extract: - map_over_members(extract_file, files, argc - 3); - break; - - case delete: - if (files != NULL) - delete_members(files); - break; - - case move: - if (files != NULL) - move_members(files); - break; - - case replace: - if (files != NULL || write_armap) - replace_members(files); - break; - - /* Shouldn't happen! */ - default: - fprintf(stderr, "Sorry; this option not implemented.\n"); - } - - return (0); -} /* main() */ - -static -char *normalize(file) -char *file; -{ - char * filename = strrchr(file, '/'); - if (filename != (char *)NULL) { - filename ++; - } - else { - filename = file; - } - return filename; -} - -static void -open_inarch(archive_filename) - char *archive_filename; -{ - bfd **last_one; - bfd *next_one; - struct stat sbuf; - bfd_error = no_error; - if (stat(archive_filename, &sbuf) != 0) { - if (errno != ENOENT) - bfd_fatal(archive_filename); - if (!operation_alters_arch) { - fprintf (stderr, "%s: %s not found.\n", program_name, - archive_filename); - exit (1); - } - if (!silent_create) - fprintf(stderr, - "%s: creating %s\n", program_name, archive_filename); - - inarch = &bogus_archive; - inarch->filename = archive_filename; - inarch->has_armap = true; - - } - else { -#ifdef GNU960 - inarch = bfd_openr(archive_filename, default_target); -#else - inarch = bfd_openr(archive_filename, NULL); -#endif - if (inarch == NULL) { - bloser: - bfd_perror(archive_filename); - exit(1); - } - - if (bfd_check_format(inarch, bfd_archive) != true) - fatal("File %s is not an archive.", archive_filename); -#ifdef GNU960 - gnu960_verify_target(inarch); /* Exits on failure */ -#endif - last_one = &(inarch->next); - /* Read all the contents right away, regardless. */ - for (next_one = bfd_openr_next_archived_file(inarch, NULL); - next_one; - next_one = bfd_openr_next_archived_file(inarch, next_one)) { - *last_one = next_one; - last_one = &next_one->next; - } - *last_one = (bfd *) NULL; - if (bfd_error != no_more_archived_files) - goto bloser; - } -} - - - -/* - If count is 0, then function is called once on each entry. if nonzero, - count is the length of the files chain; function is called on each entry - whose name matches one in files -*/ -void -map_over_members(function, files, count) - void (*function) (); - char **files; - int count; -{ - bfd *head; - - - - - if (count == 0) { - for (head = inarch->next; head; head = head->next) - function(head); - return; - } - /* - This may appear to be a baroque way of accomplishing what we want. - however we have to iterate over the filenames in order to notice where - a filename is requested but does not exist in the archive. Ditto - mapping over each file each time -- we want to hack multiple - references. - */ - - for (; count > 0; files++, count--) { - boolean found = false; - for (head = inarch->next; head; head = head->next) - if ((head->filename != NULL) && - (!strcmp(*files, head->filename))) { - found = true; - function(head); - } - if (!found) - fprintf(stderr, "No entry %s in archive.\n", *files); - } -} - - -/* Things which are interesting to map over all or some of the files: */ - -void -print_descr(abfd) - bfd *abfd; -{ - print_arelt_descr(abfd, verbose); -} - -void -print_contents(abfd) - bfd *abfd; -{ - int ncopied = 0; - struct stat buf; - long size; - if (bfd_stat_arch_elt(abfd, &buf) != 0) - fatal("Internal stat error on %s", abfd->filename); - - if (verbose) - printf("\n\n\n", abfd->filename); - - bfd_seek(abfd, 0, SEEK_SET); - - size = buf.st_size; - while (ncopied < size) { - char cbuf[BUFSIZE]; - int nread; - int tocopy = size - ncopied; - if (tocopy > BUFSIZE) - tocopy = BUFSIZE; - - nread = bfd_read(cbuf, 1, tocopy, abfd); /* oops -- broke - abstraction! */ - - if (nread != tocopy) - fatal("file %s not a valid archive", abfd->my_archive->filename); - fwrite(cbuf, 1, nread, stdout); - ncopied += tocopy; - } -} - - -/* - Extract a member of the archive into its own file. - -We defer opening the new file until after we have read a BUFSIZ chunk of the - old one, since we know we have just read the archive header for the old - one. Since most members are shorter than BUFSIZ, this means we will read - the old header, read the old data, write a new inode for the new file, and - write the new data, and be done. This 'optimization' is what comes from - sitting next to a bare disk and hearing it every time it seeks. -- Gnu - Gilmore -*/ - -void -extract_file(abfd) - bfd *abfd; -{ - FILE *ostream; - char cbuf[BUFSIZE]; - int nread, - tocopy; - int ncopied = 0; - long size; - struct stat buf; - if (bfd_stat_arch_elt(abfd, &buf) != 0) - fatal("Internal stat error on %s", abfd->filename); - size = buf.st_size; - - if (verbose) - printf("x - %s\n", abfd->filename); - - bfd_seek(abfd, 0, SEEK_SET); - - ostream = 0; - if (size == 0) { - /* Seems like an abstraction violation, eh? Well it's OK! */ - ostream = fopen(abfd->filename, "w"); - if (!ostream) { - perror(abfd->filename); - exit(1); - } - } else - while (ncopied < size) { - tocopy = size - ncopied; - if (tocopy > BUFSIZE) - tocopy = BUFSIZE; - - nread = bfd_read(cbuf, 1, tocopy, abfd); - if (nread != tocopy) - fatal("file %s not a valid archive", abfd->my_archive->filename); - - /* See comment above; this saves disk arm motion */ - if (!ostream) { - /* Seems like an abstraction violation, eh? Well it's OK! */ - ostream = fopen(abfd->filename, "w"); - if (!ostream) { - perror(abfd->filename); - exit(1); - } - } - fwrite(cbuf, 1, nread, ostream); - ncopied += tocopy; - } - - fclose(ostream); - chmod(abfd->filename, buf.st_mode); - - if (preserve_dates) { -#ifdef USG - long tb[2]; - tb[0] = buf.st_mtime; - tb[1] = buf.st_mtime; - utime(abfd->filename, tb); /* FIXME check result */ -#else - struct timeval tv[2]; - tv[0].tv_sec = buf.st_mtime; - tv[0].tv_usec = 0; - tv[1].tv_sec = buf.st_mtime; - tv[1].tv_usec = 0; - utimes(abfd->filename, tv); /* FIXME check result */ -#endif - } -} - - -/* Just do it quickly; don't worry about dups, armap, or anything like that */ - -/* This is ugly! XXX */ - -PROTO(struct ar_hdr *, bfd_special_undocumented_glue, (bfd *abfd, char *filename)); - -void -do_quick_append(archive_filename, files_to_append) - char *archive_filename; - char **files_to_append; - -{ - FILE *ofile, - *ifile; - char buf[BUFSIZE]; - long tocopy, - thistime; - bfd *temp; - struct stat sbuf; - boolean newfile = false; - bfd_error = no_error; - - if (stat(archive_filename, &sbuf) != 0) { - if (errno != ENOENT) - bfd_fatal(archive_filename); - newfile = true; - } - - - ofile = fopen(archive_filename, "a+"); - if (ofile == NULL) { - perror(program_name); - exit(1); - } - - /* bletch */ -#ifdef GNU960 - temp = bfd_openr(archive_filename, default_target); -#else - temp = bfd_openr(archive_filename, NULL); -#endif - if (temp == NULL) { - bfd_perror(archive_filename); - exit(1); - } - if (newfile == false) { - if (bfd_check_format(temp, bfd_archive) != true) - fatal("File %s is not an archive.", archive_filename); -#ifdef GNU960 - gnu960_verify_target(temp); /* Exits on failure */ -#endif - } - else { - fwrite(ARMAG, 1, SARMAG, ofile); - if (!silent_create) - fprintf(stderr, "%s: creating %s\n", program_name, archive_filename); - } - - /* assume it's an achive, go straight to the end, sans $200 */ - fseek(ofile, 0, 2); - - for (; files_to_append && *files_to_append; ++files_to_append) { - struct ar_hdr *hdr = bfd_special_undocumented_glue(temp, *files_to_append); - if (hdr == NULL) { - bfd_perror(*files_to_append); - exit(1); - } - - BFD_SEND(temp, _bfd_truncate_arname, (temp, *files_to_append, (char *) hdr)); - - ifile = fopen(*files_to_append, "r"); - if (ifile == NULL) - bfd_perror(program_name); - - if (stat(*files_to_append, &sbuf) != 0) - bfd_perror(*files_to_append); - - tocopy = sbuf.st_size; - - /* XXX should do error-checking! */ - fwrite(hdr, 1, sizeof(struct ar_hdr), ofile); - - - while (tocopy > 0) { - thistime = tocopy; - if (thistime > BUFSIZE) - thistime = BUFSIZE; - fread(buf, 1, thistime, ifile); - fwrite(buf, 1, thistime, ofile); - tocopy -= thistime; - } - fclose(ifile); - if ((sbuf.st_size % 2) == 1) - putc('\n', ofile); - } - fclose(ofile); - bfd_close(temp); -} - - -void -write_archive() -{ - bfd *obfd; - char *xmalloc(); - int namelen = strlen(inarch->filename); - char *new_name = xmalloc(namelen + 6); - bfd *contents_head = inarch->next; -#if 0 - if (inarch == &bogus_archive) { - /* How can this be ? */ - return; - } - else { -#endif - strcpy(new_name, inarch->filename); - strcpy(new_name + namelen, ".art"); - obfd = bfd_openw(new_name, - /* FIXME: violates abstraction; need a better protocol */ - (inarch->xvec ? bfd_get_target(inarch) : NULL)); - - if (obfd == NULL) - bfd_fatal(inarch->filename); - - bfd_set_format(obfd, bfd_archive); - obfd->has_armap = write_armap; - - if (bfd_set_archive_head(obfd, contents_head) != true) - bfd_fatal(inarch->filename); - - if (!bfd_close(obfd)) - bfd_fatal(inarch->filename); - - /* We don't care if this fails, we might be creating the - archive */ - (void) unlink(inarch->filename); - - if (rename(new_name, inarch->filename) != 0) - bfd_fatal(inarch->filename); -#if 0 - } -#endif -} - - - -/* - returns a pointer to the pointer to the entry which should be rplacd'd - into when altering. default_pos should be how to interpret pos_default, - and should be a pos value. -*/ - -bfd ** -get_pos_bfd(contents, default_pos) - bfd **contents; - enum pos default_pos; -{ - bfd **after_bfd = contents; - enum pos realpos = (postype == pos_default ? default_pos : postype); - - if (realpos == pos_end) { - while (*after_bfd) - after_bfd = &((*after_bfd)->next); - } - else { - for ( ; *after_bfd; after_bfd = &(*after_bfd)->next) - if (!strcmp((*after_bfd)->filename, posname)) { - if (realpos == pos_after) - after_bfd = &(*after_bfd)->next; - } - } - return after_bfd; -} - - -void -delete_members(files_to_delete) - char **files_to_delete; -{ - bfd **current_ptr_ptr; - boolean found; - boolean something_changed = false; - for (; *files_to_delete != NULL; ++files_to_delete) { - /* - In a.out systems, the armap is optional. It's also called - __.SYMDEF. So if the user asked to delete it, we should remember - that fact. The name is NULL in COFF archives, so using this as a - key is as good as anything I suppose - */ - if (!strcmp(*files_to_delete, "__.SYMDEF")) { - inarch->has_armap = false; - write_armap = false; - continue; - } - - found = false; - current_ptr_ptr = &(inarch->next); - while (*current_ptr_ptr) { - if (strcmp(*files_to_delete, (*current_ptr_ptr)->filename) == 0) { - found = true; - something_changed = true; - if (verbose) - printf("d - %s\n", - *files_to_delete); - *current_ptr_ptr = ((*current_ptr_ptr)->next); - goto next_file; - - } - else { - current_ptr_ptr = &((*current_ptr_ptr)->next); - } - } - - if (verbose && found == false) { - printf("No member named `%s'\n", *files_to_delete); - } -next_file:; - - } - - if (something_changed == true) { - write_archive(); - } -} - - -/* Reposition existing members within an archive */ - -void -move_members(files_to_move) - char **files_to_move; -{ - bfd **after_bfd; /* New entries go after this one */ - bfd **current_ptr_ptr; /* cdr pointer into contents */ - - - - - for (; *files_to_move; ++files_to_move) { - current_ptr_ptr = &(inarch->next); - while (*current_ptr_ptr) { - bfd *current_ptr = *current_ptr_ptr; - if (strcmp(normalize(*files_to_move), current_ptr->filename) == 0) { - /* - Move this file to the end of the list - first cut from - where it is. - */ - *current_ptr_ptr = current_ptr->next; - - /* Now glue to end */ - after_bfd = get_pos_bfd(&inarch->next, pos_end); - *after_bfd = current_ptr; - current_ptr->next = (bfd *) NULL; - - if (verbose) - printf("m - %s\n", *files_to_move); - - goto next_file; - } - current_ptr_ptr = &((*current_ptr_ptr)->next); - } - fprintf(stderr, "No entry %s in archive %s!\n", - *files_to_move, inarch->filename); - exit(1); -next_file:; - } - - write_archive(); -} - - -/* Ought to default to replacing in place, but this is existing practice! */ - -void -replace_members(files_to_move) - char **files_to_move; -{ - bfd **after_bfd; /* New entries go after this one */ - bfd *current; - bfd **current_ptr; - bfd *temp; - /* - If the first item in the archive is an __.SYMDEF then remove it - */ - if (inarch->next && - strcmp(inarch->next->filename, "__.SYMDEF") == 0) { - inarch->next = inarch->next->next; - } - - - - while (files_to_move && *files_to_move) { - current_ptr = &inarch->next; - while (*current_ptr) { - current = *current_ptr; - - if (!strcmp(normalize(*files_to_move), current->filename)) { - if (newer_only) { - struct stat fsbuf, - asbuf; - - if (current->arelt_data == NULL) { - /* This can only happen if you specify a file on the - command line more than once. */ - fprintf (stderr, "Duplicate file specified: %s -- skipping.\n", *files_to_move); - goto next_file; - } - - if (stat(*files_to_move, &fsbuf) != 0) { - if (errno != ENOENT) - bfd_fatal(*files_to_move); - goto next_file; - } - if (bfd_stat_arch_elt(current, &asbuf) != 0) - fatal("Internal stat error on %s", current->filename); - - if (fsbuf.st_mtime <= asbuf.st_mtime) - goto next_file; - } - - /* snip out this entry from the chain */ - *current_ptr = current->next; - - after_bfd = get_pos_bfd(&inarch->next, pos_end); - temp = *after_bfd; - *after_bfd = bfd_openr(*files_to_move, NULL); - if (*after_bfd == (bfd *) NULL) { - fprintf(stderr, "Can't open file %s\n", *files_to_move); - exit(1); - } -#ifdef GNU960 - gnu960_verify_target(*after_bfd); /* Exits on failure */ -#endif - (*after_bfd)->next = temp; - - if (verbose) { - printf("%c - %s\n", (postype == pos_after ? 'r' : 'a'), - *files_to_move); - } - goto next_file; - } - current_ptr = &(current->next); - } - - /* It isn't in there, so add to end */ - - after_bfd = get_pos_bfd(&inarch->next, pos_end); - temp = *after_bfd; - *after_bfd = bfd_openr(*files_to_move, NULL); - if (*after_bfd == (bfd *) NULL) { - fprintf(stderr, "Can't open file %s\n", *files_to_move); - exit(1); - } -#ifdef GNU960 - gnu960_verify_target(*after_bfd); /* Exits on failure */ -#endif - if (verbose) { - printf("c - %s\n", *files_to_move); - } - - (*after_bfd)->next = temp; - -next_file:; - - files_to_move++; - } - - - write_archive(); -} - -void -ranlib_only(archname) - char *archname; -{ - write_armap = true; - open_inarch(archname); - write_archive(); - exit(0); -} - - diff --git a/binutils/binutils.texi b/binutils/binutils.texi deleted file mode 100644 index 516d55036cc..00000000000 --- a/binutils/binutils.texi +++ /dev/null @@ -1,743 +0,0 @@ -\input texinfo -@setfilename binutils.info - -@ifinfo -@format -START-INFO-DIR-ENTRY - -* Binutils: (binutils). - The GNU binary utilities "ar", "ld", "objdump", "nm", - "size", "strip", and "ranlib". - -END-INFO-DIR-ENTRY -@end format -@end ifinfo - -@synindex ky cp -@c -@c This file documents the GNU binary utilities "ar", "ld", "objdump", "nm", -@c "size", "strip", and "ranlib". -@c -@c Copyright (C) 1991 Free Software Foundation, Inc. -@c -@c This text may be freely distributed under the terms of the GNU -@c General Public License. -@c -@c $Id$ -@iftex -@finalout -@c @smallbook -@end iftex -@c @cropmarks -@setchapternewpage odd -@settitle GNU Binary Utilities -@titlepage -@title The GNU Binary Utilities -@subtitle Version 1.90 -@sp 1 -@subtitle October 1991 -@author Roland H. Pesch -@author Cygnus Support -@page - -@tex -\def\$#1${{#1}} % Kluge: collect RCS revision info without $...$ -\xdef\manvers{\$Revision$} % For use in headers, footers too -{\parskip=0pt \hfill Cygnus Support\par \hfill \manvers\par \hfill -\TeX{}info \texinfoversion\par } -@end tex - -@vskip 0pt plus 1filll -Copyright @copyright{} 1991 Free Software Foundation, Inc. - -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. - -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided also that -the entire resulting derived work is distributed under the terms of a -permission notice identical to this one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions. -@end titlepage - -@node Top, ar, (dir), (dir) -@chapter Introduction - -@cindex version -This brief manual contains preliminary documentation for the GNU binary -utilities (collectively version 1.90): -@table @code -@item ar -Create, modify, and extract from archives - -@item nm -List symbols from object files - -@item objdump -Display information from object files - -@item ranlib -Generate index to archive contents - -@item size -List section sizes and total size - -@item strip -Discard symbols -@end table - -@ifinfo -Copyright @copyright{} 1991 Free Software Foundation, Inc. - -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. - -@ignore -Permission is granted to process this file through TeX and print the -results, provided the printed document carries a copying permission -notice identical to this one except for the removal of this paragraph -(this paragraph not being relevant to the printed manual). - -@end ignore - -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided also that -the entire resulting derived work is distributed under the terms of a -permission notice identical to this one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions. -@end ifinfo - -@menu -* ar:: Create, modify, and extract from archives -* ld:: See ld.info -* nm:: List symbols from object files -* objdump:: Display information from object files -* ranlib:: Generate index to archive contents -* size:: List section sizes and total size -* strip:: Discard symbols -* Index:: -@end menu - -@node ar, ld, Top, Top -@chapter ar - -@kindex ar -@cindex archives -@cindex collections of files -@smallexample - ar [-]@var{p}@var{mod} [ @var{membername} ] @var{archive} @var{files}@dots{} -@end smallexample - -The GNU @code{ar} program creates, modifies, and extracts from -archives. An @dfn{archive} is a single file holding a collection of -other files in a structure that makes it possible to retrieve -the original individual files (called @dfn{members} of the archive). - -The original files' contents, mode (permissions), timestamp, owner, and -group are preserved in the archive, and may be reconstituted on -extraction. - -@cindex name length -GNU @code{ar} can maintain archives whose members have names of any -length; however, depending on how @code{ar} is configured on your -system, a limit on member-name length may be imposed (for compatibility -with archive formats maintained with other tools). If it exists, the -limit is often 15 characters (typical of formats related to a.out) or 16 -characters (typical of formats related to coff). - -@cindex libraries -@code{ar} is considered a binary utility because archives of this sort -are most often used as @dfn{libraries} holding commonly needed -subroutines. - -@cindex symbol index -@code{ar} will create an index to the symbols defined in relocatable -object modules in the archive when you specify the modifier @samp{s}. -Once created, this index is updated in the archive whenever @code{ar} -makes a change to its contents (save for the @samp{q} update operation). -An archive with such an index speeds up linking to the library, and -allows routines in the library to call each other without regard to -their placement in the archive. - -You may use @samp{nm -s} or @samp{nm +print-armap} to list this index -table. If an archive lacks the table, another form of @code{ar} called -@code{ranlib} can be used to add just the table. - -@code{ar} insists on at least two arguments to execute: one -keyletter specifying the @emph{operation} (optionally accompanied by other -keyletters specifying @emph{modifiers}), and the archive name to act on. - -Most operations can also accept further @var{files} arguments, -specifying particular files to operate on. - -GNU @code{ar} allows you to mix the operation code @var{p} and modifier -flags @var{mod} in any order, within the first command-line argument. - -If you wish, you may begin the first command-line argument with a -dash. - -@cindex operations on archive -The @var{p} keyletter specifies what operation to execute; it may be -any of the following, but you must specify only one of them: - -@table @code -@item d -@cindex deleting from archive -@emph{Delete} modules from the archive. Specify the names of modules to -be deleted as @var{files}; the archive is untouched if you -specify no files to delete. - -If you specify the @samp{v} modifier, @code{ar} will list each module -as it is deleted. - -@item m -@cindex moving in archive -Use this operation to @emph{move} members in an archive. - -The ordering of members in an archive can make a difference in how -programs are linked using the library, if a symbol is defined in more -than one member. - -If no modifiers are used with @code{m}, any members you name in the -@var{files} arguments are moved to the @emph{end} of the archive; -you can use the @samp{a}, @samp{b}, or @samp{i} modifiers to move them to a -specified place instead. - -@item p -@cindex printing from archive -@emph{Print} the specified members of the archive, to the standard -output file. If the @samp{v} modifier is specified, show the member -name before copying its contents to standard output. - -If you specify no @var{files}, all the files in the archive are printed. - -@item q -@cindex quick append to archive -@emph{Quick append}; add @var{files} to the end of @var{archive}, -without checking for replacement. - -The modifiers @samp{a}, @samp{b}, and @samp{i} do @emph{not} affect this -operation; new members are always placed at the end of the archive. - -The modifier @samp{v} makes @code{ar} list each file as it is appended. - -Since the point of this operation is speed, the archive's symbol table -index is not updated, even if it already existed; you can use @samp{ar s} or -@code{ranlib} explicitly to update the symbol table index. - -@item r -@cindex replacement in archive -Insert @var{files} into @var{archive} (with @emph{replacement}). This -operation differs from @samp{q} in that any previously existing members -are deleted if their names match those being added. - -If one of the files named in @var{files} doesn't exist, @code{ar} -displays an error message, and leaves undisturbed any existing members -of the archive matching that name. - -By default, new members are added at the end of the file; but you may -use one of the modifiers @samp{a}, @samp{b}, or @samp{i} to request -placement relative to some existing member. - -The modifier @samp{v} used with this operation elicits a line of -output for each file inserted, along with one of the letters @samp{a} or -@samp{r} to indicate whether the file was appended (no old member -deleted) or replaced. - -@item t -@cindex contents of archive -Display a @emph{table} listing the contents of @var{archive}, or those -of the files listed in @var{files} that are present in the -archive. Normally only the member name is shown; if you also want to -see the modes (permissions), timestamp, owner, group, and size, you can -request that by also specifying the @samp{v} modifier. - -If you do not specify any @var{files}, all files in the archive -are listed. - -@cindex repeated names in archive -@cindex name duplication in archive -If there is more than one file with the same name (say, @samp{fie}) in -an archive (say @samp{b.a}), @samp{ar t b.a fie} will list only the -first instance; to see them all, you must ask for a complete -listing---in our example, @samp{ar t b.a}. -@c WRS only; per Gumby, this is implementation-dependent, and in a more -@c recent case in fact works the other way. - -@item x -@cindex extract from archive -@emph{Extract} members (named @var{files}) from the archive. You can -use the @samp{v} modifier with this operation, to request that -@code{ar} list each name as it extracts it. - -If you do not specify any @var{files}, all files in the archive -are extracted. - -@end table - -A number of modifiers (@var{mod}) may immediately follow the @var{p} -keyletter, to specify variations on an operation's behavior: - -@table @code -@item a -@cindex relative placement in archive -Add new files @emph{after} an existing member of the -archive. If you use the modifier @code{a}, the name of an existing archive -member must be present as the @var{membername} argument, before the -@var{archive} specification. - -@item b -Add new files @emph{before} an existing member of the -archive. If you use the modifier @code{b}, the name of an existing archive -member must be present as the @var{membername} argument, before the -@var{archive} specification. (same as @samp{i}). - -@item c -@cindex creating archives -@emph{Create} the archive. The specified @var{archive} is always -created if it didn't exist, when you request an update. But a warning is -issued unless you specify in advance that you expect to create it, by -using this modifier. - -@item i -Insert new files @emph{before} an existing member of the -archive. If you use the modifier @code{i}, the name of an existing archive -member must be present as the @var{membername} argument, before the -@var{archive} specification. (same as @samp{b}). - -@item l -This modifier is accepted but not used. -@c whaffor ar l modifier??? presumably compat; with -@c what???---pesch@@cygnus.com, 25jan91 - -@item o -@cindex dates in archive -Preserve the @emph{original} dates of members when extracting them. If -you do not specify this modifier, files extracted from the archive -will be stamped with the time of extraction. - -@item s -@cindex writing archive index -Write an object-file index into the archive, or update an existing one, -even if no other change is made to the archive. You may use this modifier -flag either with any operation, or alone. Running @samp{ar s} on an -archive is equivalent to running @samp{ranlib} on it. - -@item u -@cindex updating an archive -Normally, @code{ar r}@dots{} inserts all files -listed into the archive. If you would like to insert @emph{only} those -of the files you list that are newer than existing members of the same -names, use this modifier. The @samp{u} modifier is allowed only for the -operation @samp{r} (replace). In particular, the combination @samp{qu} is -not allowed, since checking the timestamps would lose any speed -advantage from the operation @samp{q}. - -@item v -This modifier requests the @emph{verbose} version of an operation. Many -operations display additional information, such as filenames processed, -when the modifier @samp{v} is appended. - -@end table - -@node ld, nm, ar, Top -@chapter ld -@cindex linker -@kindex ld -The GNU linker @code{ld} is now described in a separate manual. -@xref{Top,, Overview,, GLD: the GNU linker}. - -@node nm, objdump, ld, Top -@chapter nm -@cindex symbols -@kindex nm - -@smallexample - nm [ -a | +debug-syms ] [ -g | +extern-only ] - [ -s | +print-armap ] [ -o | +print-file-name ] - [ -n | +numeric-sort ] [ -p | +no-sort ] - [ -r | +reverse-sort ] [ -u | +undefined-only ] - [ +target @var{bfdname} ] - [ @var{objfiles}@dots{} ] -@end smallexample - -GNU @code{nm} will list the symbols from object files @var{objfiles}. - -The long and short forms of options, shown here as alternatives, are -equivalent. - -@table @code -@item @var{objfiles}@dots{} -@kindex a.out -Object files whose symbols are to be listed. If no object files are -listed as arguments, @code{nm} assumes @samp{a.out}. - -@item -a -@itemx +debug-syms -@cindex debugging symbols -Display debugger-only symbols; normally these are not listed. - -@item -g -@itemx +extern-only -@cindex external symbols -Display only external symbols. - -@item -p -@itemx +no-sort -@cindex sorting symbols -Don't bother to sort the symbols in any order; just print them in the -order encountered. - -@item -n -@itemx +numeric-sort -Sort symbols numerically by their addresses, not alphabetically by their -names. - -@item -s -@itemx +print-armap -@cindex symbol index, listing -When listing symbols from archive members, include the index: a mapping -(stored in the archive by @code{ar} or @code{ranlib}) of what modules -contain definitions for what names. - -@item -o -@itemx +print-file-name -@cindex input file name -@cindex file name -@cindex source file name -Precede each symbol by the name of the input file where it was found, -rather than identifying the input file once only before all of its -symbols. - -@item -r -@itemx +reverse-sort -Reverse the sense of the sort (whether numeric or alphabetic); let the -last come first. - -@item +target @var{bfdname} -@c @item +target -@cindex object code format -Specify an object code format other than your system's default format. -@xref{objdump}, for information on listing available formats. -@c FIXME what *does* +target/no arg do? - -@item -u -@itemx +undefined-only -@cindex external symbols -@cindex undefined symbols -Display only undefined symbols (those external to each object file). - -@end table - -@node objdump, ranlib, nm, Top -@chapter objdump - -@cindex object file information -@kindex objdump - -@smallexample - objdump [ -a ] [ -b @var{bfdname} ] [ -d ] [ -f ] - [ -h | +header ] [ -i ] [ -j @var{section} ] [ -l ] - [ -m @var{machine} ] [ -r | +reloc ] [ -s ] - [ -t | +syms ] [ -x ] - @var{objfiles}@dots{} -@end smallexample - -@code{objdump} displays information about one or more object files. -The options control what particular information to display. This -information is mostly useful to programmers who are working on the -compilation tools, as opposed to programmers who just want their -program to compile and work. - -The long and short forms of options, shown here as alternatives, are -equivalent. - -@table @code -@item @var{objfiles}@dots{} -The object files to be examined. When you specify archives, -@code{objdump} shows information on each of the member object files. - -@item -a -@c print_arelt_descr -@cindex archive headers -If any files from @var{objfiles} are archives, display the archive -header information (in a format similar to @samp{ls -l}). Besides the -information you could list with @samp{ar tv}, @samp{objdump -a} shows -the object file format of each archive member. - -@c suggest longname +target or +format or +bfd -@item -b @var{bfdname} -@cindex object code format -You can specify a particular object-code format for your object files as -@var{bfdname}. This may not be necessary; @var{objdump} can -automatically recognize many formats. For example, -@example -objdump -b oasys -m vax -h fu.o -@end example -@noindent -Displays summary information from the section headers (@samp{-h}) of -@file{fu.o}, which is explicitly identified (@samp{-m}) as a Vax object -file in the format produced by Oasys compilers. You can list the -formats available with the @samp{-i} option. - -@item -d -@cindex disassembling object code -@cindex machine instructions -Disassemble. Display the assembler mnemonics for the machine -instructions from @var{objfiles}. - -@item -f -@cindex object file header -File header. Display summary information from the overall header of -each file in @var{objfiles}. - -@item -h -@itemx +header -@cindex section headers -Header. Display summary information from the section headers of the -object file. - -@item -i -@cindex architectures available -@cindex object formats available -Display a list showing all architectures and object formats available -for specification with @code{-b} or @code{-m}. - -@c suggest longname +section -@item -j @var{name} -@cindex section information -Display information only for section @var{name} - -@c suggest longname +label or +linespec -@item -l -@cindex source filenames for object files -Label the display (using debugging information) with the source filename -and line numbers corresponding to the object code shown. - -@c suggest longname +architecture -@item -m @var{machine} -@cindex architecture -Specify the object files @var{objfiles} are for architecture -@var{machine}. You can list available architectures using the @samp{-i} -option. - -@item -r -@itemx +reloc -@cindex relocation entries, in object file -Relocation. Print the relocation entries of the file. - -@item -s -@cindex sections, full contents -@cindex object file sections -Display the full contents of any sections requested. - -@item -t -@itemx +syms -@cindex symbol table entries, printing -Symbol Table. Print the symbol table entries of the file. -This is similar to the information provided by the @samp{nm} program. - -@item -x -@cindex all header information, object file -@cindex header information, all -Display all available header information, including the symbol table and -relocation entries. Using @samp{-x} is equivalent to specifying all of -@samp{-a -f -h -r -t}. - -@end table - -@node ranlib, size, objdump, Top -@chapter ranlib - -@kindex ranlib -@cindex archive contents -@cindex symbol index - -@smallexample - ranlib @var{archive} -@end smallexample - -@code{ranlib} generates an index to the contents of an archive, and -stores it in the archive. The index lists each symbol defined by a -member of an archive that is a relocatable object file. - -You may use @samp{nm -s} or @samp{nm +print-armap} to list this index. - -An archive with such an index speeds up linking to the library, and -allows routines in the library to call each other without regard to -their placement in the archive. - -The GNU @code{ranlib} program is another form of GNU @code{ar}; running -@code{ranlib} is completely equivalent to executing @samp{ar -s}. -@xref{ar}. - -@node size, strip, ranlib, Top -@chapter size - -@kindex size -@cindex section sizes - -@smallexample - size [ -A | -B | +format @var{compatibility} ] - [ +help ] [ -d | -o | -x | +radix @var{number} ] - [ +target @var{bfdname} ] [ -V | +version ] - @var{objfiles}@dots{} -@end smallexample - -The GNU @code{size} utility lists the section sizes---and the total -size---for each of the object files @var{objfiles} in its argument list. -By default, one line of output is generated for each object file or each -module in an archive. - -The command line options have the following meanings: -@table @code -@item @var{objfiles}@dots{} -The object files to be examined. - -@item -A -@itemx -B -@itemx +format @var{compatibility} -@cindex size display format -Using one of these options, you can choose whether the output from GNU -@code{size} resembles output from System V @code{size} (using @samp{-A}, -or @samp{+format sysv}), or Berkeley @code{size} (using @samp{-B}, or -@samp{+format berkeley}). The default is the one-line format similar to -Berkeley's. -@c Bonus for doc-source readers: you can also say +format=strange (or -@c anything else that starts with 's') for sysv, and +format=boring (or -@c anything else that starts with 'b') for Berkeley. - -Here is an example of the Berkeley (default) format of output from -@code{size}: -@smallexample - eg$ size +format Berkeley ranlib size -text data bss dec hex filename -294880 81920 11592 388392 5ed28 ranlib -294880 81920 11888 388688 5ee50 size -@end smallexample - -@noindent -This is the same data, but displayed closer to System V conventions: - -@smallexample - eg$ size +format SysV ranlib size -ranlib : -section size addr -.text 294880 8192 -.data 81920 303104 -.bss 11592 385024 -Total 388392 - - -size : -section size addr -.text 294880 8192 -.data 81920 303104 -.bss 11888 385024 -Total 388688 -@end smallexample - -@item +help -Show a summary of acceptable arguments and options. - -@item -d -@itemx -o -@itemx -x -@itemx +radix @var{number} -@cindex size number format -@cindex radix for section sizes -Using one of these options, you can control whether the size of each -section is given in decimal (@samp{-d}, or @samp{+radix 10}); octal -(@samp{-o}, or @samp{+radix 8}); or hexadecimal (@samp{-x}, or -@samp{+radix 16}). In @samp{+radix @var{number}}, only the three -values (8, 10, 16) are supported. The total size is always given in two -radices; decimal and hexadecimal for @samp{-d} or @samp{-x} output, or -octal and hexadecimal if you're using @samp{-o}. - -@item +target @var{bfdname} -@cindex object code format -You can specify a particular object-code format for @var{objfiles} as -@var{bfdname}. This may not be necessary; @var{size} can -automatically recognize many formats. @xref{objdump}, for information -on listing available formats. - -@item -V -@itemx +version -Display version number information on @code{size} itself. - -@end table - -@node strip, Index, size, Top -@chapter strip - -@kindex strip -@cindex removing symbols -@cindex discarding symbols - -@smallexample - strip [ -s | +strip-all ] [ -g | -S | +strip-debug ] - [ -x | +discard-all ] [ -X | +discard-locals ] - [ -T @var{bfdname} ] - @var{objfiles}@dots{} -@end smallexample - -GNU @code{strip} will discard all symbols from object files -@var{objfiles}, if no options are specified; or only certain symbols, -depending on its command-line options. - -@code{strip} will not execute unless at least one object file is listed. - -@quotation -@emph{WARNING:} @code{strip} modifies the files named in its argument, -rather than writing modified copies under different names. -@end quotation - -The long and short forms of options, shown here as alternatives, are -equivalent. - -@table @code -@item -s -@itemx +strip-all -@cindex all symbols, discarding -This is the default case: strip all symbol entries from @var{objfiles}. - -@item -g -@itemx -S -@itemx +strip-debug -@cindex debugging symbols, discarding -Discard only debugging symbol information from @var{objfiles}. - -@item -x -@itemx +discard-all -@cindex local symbols, discarding -Discard all symbols local to each file in @var{objfiles}. -@emph{WARNING:} Note that @code{+discard-all} discards only @emph{local} -symbols, in spite of its name. - -@item -X -@itemx +discard-locals -Discard local symbols starting with @samp{L} from each file in -@var{objfiles}. (Some compilers produce internally-used symbols that -begin with @samp{L}.) - -@item -T @var{bfdname} -@cindex object code format -You can specify a particular object-code format @var{bfdname} for -@var{objfiles}. This may not be necessary; @var{strip} can automatically -recognize many formats. @xref{objdump}, for information on listing -available formats. -@end table - -@node Index, , strip, Top -@unnumbered Index - -@printindex cp - -@contents -@bye diff --git a/binutils/binutils.texinfo b/binutils/binutils.texinfo deleted file mode 100755 index 37167e56c87..00000000000 --- a/binutils/binutils.texinfo +++ /dev/null @@ -1,730 +0,0 @@ -\input texinfo -@setfilename binutils.info -@synindex ky cp -@c -@c This file documents the GNU binary utilities "ar", "ld", "objdump", "nm", -@c "size", "strip", and "ranlib". -@c -@c Copyright (C) 1991 Free Software Foundation, Inc. -@c -@c This text may be freely distributed under the terms of the GNU -@c General Public License. -@c -@c $Id$ -@iftex -@finalout -@c @smallbook -@end iftex -@c @cropmarks -@setchapternewpage odd -@settitle GNU Binary Utilities -@titlepage -@title The GNU Binary Utilities -@subtitle Version 1.90 -@sp 1 -@subtitle October 1991 -@author Roland H. Pesch -@author Cygnus Support -@page - -@tex -\def\$#1${{#1}} % Kluge: collect RCS revision info without $...$ -\xdef\manvers{\$Revision$} % For use in headers, footers too -{\parskip=0pt \hfill Cygnus Support\par \hfill \manvers\par \hfill -\TeX{}info \texinfoversion\par } -@end tex - -@vskip 0pt plus 1filll -Copyright @copyright{} 1991 Free Software Foundation, Inc. - -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. - -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided also that -the entire resulting derived work is distributed under the terms of a -permission notice identical to this one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions. -@end titlepage - -@node Top, ar, (dir), (dir) -@chapter Introduction - -@cindex version -This brief manual contains preliminary documentation for the GNU binary -utilities (collectively version 1.90): -@table @code -@item ar -Create, modify, and extract from archives - -@item nm -List symbols from object files - -@item objdump -Display information from object files - -@item ranlib -Generate index to archive contents - -@item size -List section sizes and total size - -@item strip -Discard symbols -@end table - -@ifinfo -Copyright @copyright{} 1991 Free Software Foundation, Inc. - -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. - -@ignore -Permission is granted to process this file through TeX and print the -results, provided the printed document carries a copying permission -notice identical to this one except for the removal of this paragraph -(this paragraph not being relevant to the printed manual). - -@end ignore - -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided also that -the entire resulting derived work is distributed under the terms of a -permission notice identical to this one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions. -@end ifinfo - -@menu -* ar:: Create, modify, and extract from archives -* ld:: See ld.info -* nm:: List symbols from object files -* objdump:: Display information from object files -* ranlib:: Generate index to archive contents -* size:: List section sizes and total size -* strip:: Discard symbols -* Index:: -@end menu - -@node ar, ld, Top, Top -@chapter ar - -@kindex ar -@cindex archives -@cindex collections of files -@smallexample - ar [-]@var{p}@var{mod} [ @var{membername} ] @var{archive} @var{files}@dots{} -@end smallexample - -The GNU @code{ar} program creates, modifies, and extracts from -archives. An @dfn{archive} is a single file holding a collection of -other files in a structure that makes it possible to retrieve -the original individual files (called @dfn{members} of the archive). - -The original files' contents, mode (permissions), timestamp, owner, and -group are preserved in the archive, and may be reconstituted on -extraction. - -@cindex name length -GNU @code{ar} can maintain archives whose members have names of any -length; however, depending on how @code{ar} is configured on your -system, a limit on member-name length may be imposed (for compatibility -with archive formats maintained with other tools). If it exists, the -limit is often 15 characters (typical of formats related to a.out) or 16 -characters (typical of formats related to coff). - -@cindex libraries -@code{ar} is considered a binary utility because archives of this sort -are most often used as @dfn{libraries} holding commonly needed -subroutines. - -@cindex symbol index -@code{ar} will create an index to the symbols defined in relocatable -object modules in the archive when you specify the modifier @samp{s}. -Once created, this index is updated in the archive whenever @code{ar} -makes a change to its contents (save for the @samp{q} update operation). -An archive with such an index speeds up linking to the library, and -allows routines in the library to call each other without regard to -their placement in the archive. - -You may use @samp{nm -s} or @samp{nm +print-armap} to list this index -table. If an archive lacks the table, another form of @code{ar} called -@code{ranlib} can be used to add just the table. - -@code{ar} insists on at least two arguments to execute: one -keyletter specifying the @emph{operation} (optionally accompanied by other -keyletters specifying @emph{modifiers}), and the archive name to act on. - -Most operations can also accept further @var{files} arguments, -specifying particular files to operate on. - -GNU @code{ar} allows you to mix the operation code @var{p} and modifier -flags @var{mod} in any order, within the first command-line argument. - -If you wish, you may begin the first command-line argument with a -dash. - -@cindex operations on archive -The @var{p} keyletter specifies what operation to execute; it may be -any of the following, but you must specify only one of them: - -@table @code -@item d -@cindex deleting from archive -@emph{Delete} modules from the archive. Specify the names of modules to -be deleted as @var{files}; the archive is untouched if you -specify no files to delete. - -If you specify the @samp{v} modifier, @code{ar} will list each module -as it is deleted. - -@item m -@cindex moving in archive -Use this operation to @emph{move} members in an archive. - -The ordering of members in an archive can make a difference in how -programs are linked using the library, if a symbol is defined in more -than one member. - -If no modifiers are used with @code{m}, any members you name in the -@var{files} arguments are moved to the @emph{end} of the archive; -you can use the @samp{a}, @samp{b}, or @samp{i} modifiers to move them to a -specified place instead. - -@item p -@cindex printing from archive -@emph{Print} the specified members of the archive, to the standard -output file. If the @samp{v} modifier is specified, show the member -name before copying its contents to standard output. - -If you specify no @var{files}, all the files in the archive are printed. - -@item q -@cindex quick append to archive -@emph{Quick append}; add @var{files} to the end of @var{archive}, -without checking for replacement. - -The modifiers @samp{a}, @samp{b}, and @samp{i} do @emph{not} affect this -operation; new members are always placed at the end of the archive. - -The modifier @samp{v} makes @code{ar} list each file as it is appended. - -Since the point of this operation is speed, the archive's symbol table -index is not updated, even if it already existed; you can use @samp{ar s} or -@code{ranlib} explicitly to update the symbol table index. - -@item r -@cindex replacement in archive -Insert @var{files} into @var{archive} (with @emph{replacement}). This -operation differs from @samp{q} in that any previously existing members -are deleted if their names match those being added. - -If one of the files named in @var{files} doesn't exist, @code{ar} -displays an error message, and leaves undisturbed any existing members -of the archive matching that name. - -By default, new members are added at the end of the file; but you may -use one of the modifiers @samp{a}, @samp{b}, or @samp{i} to request -placement relative to some existing member. - -The modifier @samp{v} used with this operation elicits a line of -output for each file inserted, along with one of the letters @samp{a} or -@samp{r} to indicate whether the file was appended (no old member -deleted) or replaced. - -@item t -@cindex contents of archive -Display a @emph{table} listing the contents of @var{archive}, or those -of the files listed in @var{files} that are present in the -archive. Normally only the member name is shown; if you also want to -see the modes (permissions), timestamp, owner, group, and size, you can -request that by also specifying the @samp{v} modifier. - -If you do not specify any @var{files}, all files in the archive -are listed. - -@cindex repeated names in archive -@cindex name duplication in archive -If there is more than one file with the same name (say, @samp{fie}) in -an archive (say @samp{b.a}), @samp{ar t b.a fie} will list only the -first instance; to see them all, you must ask for a complete -listing---in our example, @samp{ar t b.a}. -@c WRS only; per Gumby, this is implementation-dependent, and in a more -@c recent case in fact works the other way. - -@item x -@cindex extract from archive -@emph{Extract} members (named @var{files}) from the archive. You can -use the @samp{v} modifier with this operation, to request that -@code{ar} list each name as it extracts it. - -If you do not specify any @var{files}, all files in the archive -are extracted. - -@end table - -A number of modifiers (@var{mod}) may immediately follow the @var{p} -keyletter, to specify variations on an operation's behavior: - -@table @code -@item a -@cindex relative placement in archive -Add new files @emph{after} an existing member of the -archive. If you use the modifier @code{a}, the name of an existing archive -member must be present as the @var{membername} argument, before the -@var{archive} specification. - -@item b -Add new files @emph{before} an existing member of the -archive. If you use the modifier @code{b}, the name of an existing archive -member must be present as the @var{membername} argument, before the -@var{archive} specification. (same as @samp{i}). - -@item c -@cindex creating archives -@emph{Create} the archive. The specified @var{archive} is always -created if it didn't exist, when you request an update. But a warning is -issued unless you specify in advance that you expect to create it, by -using this modifier. - -@item i -Insert new files @emph{before} an existing member of the -archive. If you use the modifier @code{i}, the name of an existing archive -member must be present as the @var{membername} argument, before the -@var{archive} specification. (same as @samp{b}). - -@item l -This modifier is accepted but not used. -@c whaffor ar l modifier??? presumably compat; with -@c what???---pesch@@cygnus.com, 25jan91 - -@item o -@cindex dates in archive -Preserve the @emph{original} dates of members when extracting them. If -you do not specify this modifier, files extracted from the archive -will be stamped with the time of extraction. - -@item s -@cindex writing archive index -Write an object-file index into the archive, or update an existing one, -even if no other change is made to the archive. You may use this modifier -flag either with any operation, or alone. Running @samp{ar s} on an -archive is equivalent to running @samp{ranlib} on it. - -@item u -@cindex updating an archive -Normally, @code{ar r}@dots{} inserts all files -listed into the archive. If you would like to insert @emph{only} those -of the files you list that are newer than existing members of the same -names, use this modifier. The @samp{u} modifier is allowed only for the -operation @samp{r} (replace). In particular, the combination @samp{qu} is -not allowed, since checking the timestamps would lose any speed -advantage from the operation @samp{q}. - -@item v -This modifier requests the @emph{verbose} version of an operation. Many -operations display additional information, such as filenames processed, -when the modifier @samp{v} is appended. - -@end table - -@node ld, nm, ar, Top -@chapter ld -@cindex linker -@kindex ld -The GNU linker @code{ld} is now described in a separate manual. -@xref{Top,, Overview,, GLD: the GNU linker}. - -@node nm, objdump, ld, Top -@chapter nm -@cindex symbols -@kindex nm - -@smallexample - nm [ -a | +debug-syms ] [ -g | +extern-only ] - [ -s | +print-armap ] [ -o | +print-file-name ] - [ -n | +numeric-sort ] [ -p | +no-sort ] - [ -r | +reverse-sort ] [ -u | +undefined-only ] - [ +target @var{bfdname} ] - [ @var{objfiles}@dots{} ] -@end smallexample - -GNU @code{nm} will list the symbols from object files @var{objfiles}. - -The long and short forms of options, shown here as alternatives, are -equivalent. - -@table @code -@item @var{objfiles}@dots{} -@kindex a.out -Object files whose symbols are to be listed. If no object files are -listed as arguments, @code{nm} assumes @samp{a.out}. - -@item -a -@itemx +debug-syms -@cindex debugging symbols -Display debugger-only symbols; normally these are not listed. - -@item -g -@itemx +extern-only -@cindex external symbols -Display only external symbols. - -@item -p -@itemx +no-sort -@cindex sorting symbols -Don't bother to sort the symbols in any order; just print them in the -order encountered. - -@item -n -@itemx +numeric-sort -Sort symbols numerically by their addresses, not alphabetically by their -names. - -@item -s -@itemx +print-armap -@cindex symbol index, listing -When listing symbols from archive members, include the index: a mapping -(stored in the archive by @code{ar} or @code{ranlib}) of what modules -contain definitions for what names. - -@item -o -@itemx +print-file-name -@cindex input file name -@cindex file name -@cindex source file name -Precede each symbol by the name of the input file where it was found, -rather than identifying the input file once only before all of its -symbols. - -@item -r -@itemx +reverse-sort -Reverse the sense of the sort (whether numeric or alphabetic); let the -last come first. - -@item +target @var{bfdname} -@c @item +target -@cindex object code format -Specify an object code format other than your system's default format. -@xref{objdump}, for information on listing available formats. -@c FIXME what *does* +target/no arg do? - -@item -u -@itemx +undefined-only -@cindex external symbols -@cindex undefined symbols -Display only undefined symbols (those external to each object file). - -@end table - -@node objdump, ranlib, nm, Top -@chapter objdump - -@cindex object file information -@kindex objdump - -@smallexample - objdump [ -a ] [ -b @var{bfdname} ] [ -d ] [ -f ] - [ -h | +header ] [ -i ] [ -j @var{section} ] [ -l ] - [ -m @var{machine} ] [ -r | +reloc ] [ -s ] - [ -t | +syms ] [ -x ] - @var{objfiles}@dots{} -@end smallexample - -@code{objdump} displays information about one or more object files. -The options control what particular information to display. This -information is mostly useful to programmers who are working on the -compilation tools, as opposed to programmers who just want their -program to compile and work. - -The long and short forms of options, shown here as alternatives, are -equivalent. - -@table @code -@item @var{objfiles}@dots{} -The object files to be examined. When you specify archives, -@code{objdump} shows information on each of the member object files. - -@item -a -@c print_arelt_descr -@cindex archive headers -If any files from @var{objfiles} are archives, display the archive -header information (in a format similar to @samp{ls -l}). Besides the -information you could list with @samp{ar tv}, @samp{objdump -a} shows -the object file format of each archive member. - -@c suggest longname +target or +format or +bfd -@item -b @var{bfdname} -@cindex object code format -You can specify a particular object-code format for your object files as -@var{bfdname}. This may not be necessary; @var{objdump} can -automatically recognize many formats. For example, -@example -objdump -b oasys -m vax -h fu.o -@end example -@noindent -Displays summary information from the section headers (@samp{-h}) of -@file{fu.o}, which is explicitly identified (@samp{-m}) as a Vax object -file in the format produced by Oasys compilers. You can list the -formats available with the @samp{-i} option. - -@item -d -@cindex disassembling object code -@cindex machine instructions -Disassemble. Display the assembler mnemonics for the machine -instructions from @var{objfiles}. - -@item -f -@cindex object file header -File header. Display summary information from the overall header of -each file in @var{objfiles}. - -@item -h -@itemx +header -@cindex section headers -Header. Display summary information from the section headers of the -object file. - -@item -i -@cindex architectures available -@cindex object formats available -Display a list showing all architectures and object formats available -for specification with @code{-b} or @code{-m}. - -@c suggest longname +section -@item -j @var{name} -@cindex section information -Display information only for section @var{name} - -@c suggest longname +label or +linespec -@item -l -@cindex source filenames for object files -Label the display (using debugging information) with the source filename -and line numbers corresponding to the object code shown. - -@c suggest longname +architecture -@item -m @var{machine} -@cindex architecture -Specify the object files @var{objfiles} are for architecture -@var{machine}. You can list available architectures using the @samp{-i} -option. - -@item -r -@itemx +reloc -@cindex relocation entries, in object file -Relocation. Print the relocation entries of the file. - -@item -s -@cindex sections, full contents -@cindex object file sections -Display the full contents of any sections requested. - -@item -t -@itemx +syms -@cindex symbol table entries, printing -Symbol Table. Print the symbol table entries of the file. -This is similar to the information provided by the @samp{nm} program. - -@item -x -@cindex all header information, object file -@cindex header information, all -Display all available header information, including the symbol table and -relocation entries. Using @samp{-x} is equivalent to specifying all of -@samp{-a -f -h -r -t}. - -@end table - -@node ranlib, size, objdump, Top -@chapter ranlib - -@kindex ranlib -@cindex archive contents -@cindex symbol index - -@smallexample - ranlib @var{archive} -@end smallexample - -@code{ranlib} generates an index to the contents of an archive, and -stores it in the archive. The index lists each symbol defined by a -member of an archive that is a relocatable object file. - -You may use @samp{nm -s} or @samp{nm +print-armap} to list this index. - -An archive with such an index speeds up linking to the library, and -allows routines in the library to call each other without regard to -their placement in the archive. - -The GNU @code{ranlib} program is another form of GNU @code{ar}; running -@code{ranlib} is completely equivalent to executing @samp{ar -s}. -@xref{ar}. - -@node size, strip, ranlib, Top -@chapter size - -@kindex size -@cindex section sizes - -@smallexample - size [ -A | -B | +format @var{compatibility} ] - [ +help ] [ -d | -o | -x | +radix @var{number} ] - [ +target @var{bfdname} ] [ -V | +version ] - @var{objfiles}@dots{} -@end smallexample - -The GNU @code{size} utility lists the section sizes---and the total -size---for each of the object files @var{objfiles} in its argument list. -By default, one line of output is generated for each object file or each -module in an archive. - -The command line options have the following meanings: -@table @code -@item @var{objfiles}@dots{} -The object files to be examined. - -@item -A -@itemx -B -@itemx +format @var{compatibility} -@cindex size display format -Using one of these options, you can choose whether the output from GNU -@code{size} resembles output from System V @code{size} (using @samp{-A}, -or @samp{+format sysv}), or Berkeley @code{size} (using @samp{-B}, or -@samp{+format berkeley}). The default is the one-line format similar to -Berkeley's. -@c Bonus for doc-source readers: you can also say +format=strange (or -@c anything else that starts with 's') for sysv, and +format=boring (or -@c anything else that starts with 'b') for Berkeley. - -Here is an example of the Berkeley (default) format of output from -@code{size}: -@smallexample - eg$ size +format Berkeley ranlib size -text data bss dec hex filename -294880 81920 11592 388392 5ed28 ranlib -294880 81920 11888 388688 5ee50 size -@end smallexample - -@noindent -This is the same data, but displayed closer to System V conventions: - -@smallexample - eg$ size +format SysV ranlib size -ranlib : -section size addr -.text 294880 8192 -.data 81920 303104 -.bss 11592 385024 -Total 388392 - - -size : -section size addr -.text 294880 8192 -.data 81920 303104 -.bss 11888 385024 -Total 388688 -@end smallexample - -@item +help -Show a summary of acceptable arguments and options. - -@item -d -@itemx -o -@itemx -x -@itemx +radix @var{number} -@cindex size number format -@cindex radix for section sizes -Using one of these options, you can control whether the size of each -section is given in decimal (@samp{-d}, or @samp{+radix 10}); octal -(@samp{-o}, or @samp{+radix 8}); or hexadecimal (@samp{-x}, or -@samp{+radix 16}). In @samp{+radix @var{number}}, only the three -values (8, 10, 16) are supported. The total size is always given in two -radices; decimal and hexadecimal for @samp{-d} or @samp{-x} output, or -octal and hexadecimal if you're using @samp{-o}. - -@item +target @var{bfdname} -@cindex object code format -You can specify a particular object-code format for @var{objfiles} as -@var{bfdname}. This may not be necessary; @var{size} can -automatically recognize many formats. @xref{objdump}, for information -on listing available formats. - -@item -V -@itemx +version -Display version number information on @code{size} itself. - -@end table - -@node strip, Index, size, Top -@chapter strip - -@kindex strip -@cindex removing symbols -@cindex discarding symbols - -@smallexample - strip [ -s | +strip-all ] [ -g | -S | +strip-debug ] - [ -x | +discard-all ] [ -X | +discard-locals ] - [ -T @var{bfdname} ] - @var{objfiles}@dots{} -@end smallexample - -GNU @code{strip} will discard all symbols from object files -@var{objfiles}, if no options are specified; or only certain symbols, -depending on its command-line options. - -@code{strip} will not execute unless at least one object file is listed. - -@quotation -@emph{WARNING:} @code{strip} modifies the files named in its argument, -rather than writing modified copies under different names. -@end quotation - -The long and short forms of options, shown here as alternatives, are -equivalent. - -@table @code -@item -s -@itemx +strip-all -@cindex all symbols, discarding -This is the default case: strip all symbol entries from @var{objfiles}. - -@item -g -@itemx -S -@itemx +strip-debug -@cindex debugging symbols, discarding -Discard only debugging symbol information from @var{objfiles}. - -@item -x -@itemx +discard-all -@cindex local symbols, discarding -Discard all symbols local to each file in @var{objfiles}. -@emph{WARNING:} Note that @code{+discard-all} discards only @emph{local} -symbols, in spite of its name. - -@item -X -@itemx +discard-locals -Discard local symbols starting with @samp{L} from each file in -@var{objfiles}. (Some compilers produce internally-used symbols that -begin with @samp{L}.) - -@item -T @var{bfdname} -@cindex object code format -You can specify a particular object-code format @var{bfdname} for -@var{objfiles}. This may not be necessary; @var{strip} can automatically -recognize many formats. @xref{objdump}, for information on listing -available formats. -@end table - -@node Index, , strip, Top -@unnumbered Index - -@printindex cp - -@contents -@bye diff --git a/binutils/bucomm.c b/binutils/bucomm.c deleted file mode 100644 index 00f379f2293..00000000000 --- a/binutils/bucomm.c +++ /dev/null @@ -1,151 +0,0 @@ -/*** bucomm.c -- Bin Utils COMmon code. - - We might put this in a library someday so it could be dynamically - loaded, but for now it's not necessary */ - -#include "sysdep.h" -#include "bfd.h" -#include - -char *target = NULL; /* default as late as possible */ - -/* Yes, this is what atexit is for, but that isn't guaranteed yet. - And yes, I know this isn't as good, but it does what is needed just fine */ -void (*exit_handler) (); - -/** Memory hackery */ - -PROTO (char *, malloc, (unsigned size)); -PROTO (char *, realloc, (char *ptr, unsigned size)); - - -/* Error reporting */ - -char *program_name; - -void -bfd_fatal (string) - char *string; -{ - char *errmsg = bfd_errmsg (bfd_error); - - if (string) - fprintf (stderr, "%s: %s: %s\n", program_name, string, errmsg); - else - fprintf (stderr, "%s: %s\n", program_name, errmsg); - - if (NULL != exit_handler) (*exit_handler) (); - exit (1); -} - -#ifndef NO_STDARG -void -fatal (Format) - const char *Format; -{ - va_list args; - - va_start (args, Format); - vfprintf (stderr, Format, args); - va_end (args); - (void) putc ('\n', stderr); - if (NULL != exit_handler) (*exit_handler) (); - exit (1); -} -#else -#ifndef NO_VARARGS -void fatal (va_alist) - va_dcl -{ - char *Format; - va_list args; - - va_start (args); - Format = va_arg(args, char *); - vfprintf (stderr, Format, args); - va_end (args); - (void) putc ('\n', stderr); - if (NULL != exit_handler) (*exit_handler) (); - exit (1); -} /* fatal() */ -#else -/*VARARGS1 */ -fatal (Format, args) - char *Format; -{ - as_where (); - _doprnt (Format, &args, stderr); /* not terribly portable, but... */ - (void) putc ('\n', stderr); - if (NULL != exit_handler) (*exit_handler) (); - exit (1); -} -#endif /* not NO_VARARGS */ -#endif /* not NO_STDARG */ - - -/** Display the archive header for an element as if it were an ls -l listing */ - -/* Mode User\tGroup\tSize\tDate Name */ - -void -print_arelt_descr (abfd, verbose) - bfd *abfd; - boolean verbose; -{ - struct stat buf; - char modebuf[11]; - char timebuf[40]; - long when; - long current_time = time ((long *) 0); - - if (verbose) { - - if (bfd_stat_arch_elt (abfd, &buf) == 0) { /* if not, huh? */ - - mode_string (buf.st_mode, modebuf); - modebuf[10] = '\0'; - fputs (modebuf, stdout); - - when = buf.st_mtime; - strcpy (timebuf, ctime (&when)); - - /* This code comes from gnu ls. */ - if ((current_time - when > 6 * 30 * 24 * 60 * 60) - || (current_time - when < 0)) { - /* The file is fairly old or in the future. - POSIX says the cutoff is 6 months old; - approximate this by 6*30 days. - Show the year instead of the time of day. */ - strcpy (timebuf + 11, timebuf + 19); - } - timebuf[16] = 0; - - printf (" %d\t%d\t%ld\t%s ", buf.st_uid, buf.st_gid, buf.st_size, timebuf); - } - } - - puts (abfd->filename); -} - -/* Like malloc but get fatal error if memory is exhausted. */ -char * -xmalloc (size) - unsigned size; -{ - register char *result = malloc (size); - if (result == NULL && size != NULL) fatal ("virtual memory exhausted"); - - return result; -} - -/* Like realloc but get fatal error if memory is exhausted. */ -char * -xrealloc (ptr, size) - char *ptr; - unsigned size; -{ - register char *result = realloc (ptr, size); - if (result == 0 && size != 0) fatal ("virtual memory exhausted"); - - return result; -} diff --git a/binutils/config.sub b/binutils/config.sub deleted file mode 100755 index dac9ab89d4f..00000000000 --- a/binutils/config.sub +++ /dev/null @@ -1,446 +0,0 @@ -#!/bin/sh - -# Configuration subroutine to validate and canonicalize a configuration type. -# Supply the specified configuration type as an argument. -# If it is invalid, we print an error message on stderr and exit with code 1. -# Otherwise, we print the canonical config type on stdout and succeed. - -# This file is supposed to be the same for all GNU packages -# and recognize all the CPU types, system types and aliases -# that are meaningful with *any* GNU software. -# Each package is responsible for reporting which valid configurations -# it does not support. The user should be able to distinguish -# a failure to support a valid configuration from a meaningless -# configuration (e.g. a typo). - -# Please email any bugs, comments, and/or additions to this file to: -# configure@cygnus.com - -# decode aliases into canonical names - -case "$1" in -# cpu alone is a valid alias for cpu-none-none. -vax | tahoe | i386 | i860 | m68k | m68000 | m88k | sparc | ns32k \ - | alliant | arm | c1 | c2 | mips | pyramid | tron | a29k \ - | romp | rs6000 | i960 | h8300) - cpu=$1 - vendor=none - os=none - ;; -altos | altos3068) - cpu=m68k - vendor=altos - os=sysv # maybe? - ;; -altosgas) - cpu=m68k - vendor=altos - os=gas - ;; -am29k) - cpu=a29k - vendor=none - os=bsd - ;; -amdahl) - cpu=580 - vendor=amdahl - os=uts - ;; -amigados) - cpu=m68k - vendor=cbm - os=amigados # Native AmigaDOS - ;; -amigaunix | amix) - cpu=m68k - vendor=cbm - os=svr4 # System V Release 4 (svr4 is an industry recognized acronym) - ;; -apollo68) - cpu=m68k - vendor=apollo - os=sysv # maybe? - ;; -balance) - cpu=ns32k - vendor=sequent - os=dynix - ;; -convex-c1) - cpu=c1 - vendor=convex - os=sysv # maybe? - ;; -convex-c2) - cpu=c2 - vendor=convex - os=sysv # maybe? - ;; -cray | ymp) - cpu=ymp - vendor=cray - os=unicos - ;; -cray2) - cpu=cray2 - vendor=cray - os=unicos - ;; -dec3100 | decstatn | decstation | decstation-3100 | pmax | pmin) - cpu=mips - vendor=dec - os=ultrix - ;; -delta | 3300 | motorola-3300 | motorola-delta \ - | 3300-motorola | delta-motorola) - cpu=m68k - vendor=motorola - os=sysv # maybe? - ;; - -delta88) - cpu=m88k - vendor=motorola - os=m88kbcs - ;; - -gmicro) - cpu=tron - vendor=gmicro - os=sysv # maybe? - ;; - -h8300hds) - cpu=h8300 - vendor=hitachi - os=hds - ;; - -# start-sanitize-v9 -hal-32 | hal32) - cpu=sparc64 - vendor=hal - os=hal32 - ;; -hal-64 | hal64) - cpu=sparc64 - vendor=hal - os=hal64 - ;; -sparc64) - cpu=sparc64 - vendor=sun - os=v9 - ;; -sparc64-v7 | sparc64v7) - cpu=sparc64 - vendor=sun - os=v7 - ;; -# end-sanitize-v9 -hp300bsd) - cpu=m68k - vendor=hp - os=bsd - ;; -hp300hpux | hpux | hp9k3[2-9][0-9]) - cpu=m68k - vendor=hp - os=hpux - ;; -hp9k31[0-9] | hp9k2[0-9][0-9]) - cpu=m68000 - vendor=hp - os=hpux - ;; -i386sco) - cpu=i386 - vendor=sco - os=sysv # maybe? - ;; -i386v) - cpu=i386 - vendor=none - os=sysv - ;; -i386v32) - cpu=i386 - vendor=none - os=sysv32 - ;; -iris | iris4d) - cpu=mips - vendor=sgi - os=irix # maybe? - ;; - -dpx2) - vendor=bull - cpu=m68k - os=sysv - ;; -isi | isi68) - cpu=m68k - vendor=isi - os=sysv # maybe? - ;; -littlemips) - cpu=mips - vendor=little - os=bsd - ;; -magnum | m3230) - cpu=mips - vendor=mips - os=sysv # maybe? - ;; -merlin) - cpu=ns32k - vendor=utek - os=sysv # maybe? - ;; -miniframe) - cpu=m68000 - vendor=convergent - os=sysv # maybe? - ;; -mmax) - cpu=ns32k - vendor=encore - os=sysv # maybe? - ;; -news | news700 | news800 | news900) - cpu=m68k - vendor=sony - os=newsos3 # Based on bsd-4.3 - ;; -news1000) - cpu=m68030 - vendor=sony - os=newsos3 # ? - ;; -news-3600 | bigmips | risc-news) - cpu=mips - vendor=sony - os=newsos4 # Presumably? - ;; -next) - cpu=m68k - vendor=next - os=sysv # maybe? - ;; -nindy960) - cpu=i960 - vendor=intel - os=nindy - ;; -none) - cpu=none - vendor=none - os=none - ;; -np1) - cpu=np1 - vendor=gould - os=sysv # maybe? - ;; -rtpc) - cpu=romp - vendor=ibm - os=aix # maybe? - ;; -pbd) - cpu=sparc - vendor=unicom - os=sysv - ;; -pn) - cpu=pn - vendor=gould - os=sysv # maybe? - ;; -ps2) - cpu=i386 - vendor=ibm - os=sysv # maybe? - ;; -sun2) - cpu=m68000 - vendor=sun - os=sunos4 - ;; -sun2os3) - cpu=m68000 - vendor=sun - os=sunos3 - ;; -sun2os4) - cpu=m68000 - vendor=sun - os=sunos4 - ;; -sun3) - cpu=m68k - vendor=sun - os=sunos4 - ;; -sun3os3) - cpu=m68k - vendor=sun - os=sunos3 - ;; -sun3os4) - cpu=m68k - vendor=sun - os=sunos4 - ;; -sun386 | roadrunner | sun386i) - cpu=i386 - vendor=sun - os=sunos - ;; -sun4) - cpu=sparc - vendor=sun - os=sunos4 - ;; -sun4os3) - cpu=sparc - vendor=sun - os=sunos3 - ;; -sun4os4) - cpu=sparc - vendor=sun - os=sunos4 - ;; -symmetry) - cpu=i386 - vendor=sequent - os=dynix - ;; -tower | tower-32) - cpu=m68k - vendor=ncr - os=sysv # maybe? - ;; -ultra3) - cpu=a29k - vendor=nyu - os=sym1 - ;; -umax) - cpu=ns32k - vendor=encore - os=sysv # maybe? - ;; -unixpc | safari | pc7300 | 3b1 | 7300 | 7300-att | att-7300) - cpu=m68k - vendor=att - os=sysv # maybe? - ;; -vax-dec) - cpu=vax - vendor=dec - os=ultrix # maybe? - ;; -vxworks68) - cpu=m68k - vendor=wrs - os=vxworks - ;; -vxworks960) - cpu=i960 - vendor=wrs - os=vxworks - ;; -xmp) - cpu=xmp - vendor=cray - os=unicos - ;; -# not an alias. parse what we expect to be a canonical name. -*) - cpu=`echo $1 | sed 's/-.*$//'` - - if [ "${cpu}" = "$1" ] ; then - # no vendor so this is an invalid name. - echo '***' No vendor: configuration \`$1\' not recognized 1>&2 - exit 1 - else - # parse out vendor - rest=`echo $1 | sed "s/${cpu}-//"` - vendor=`echo ${rest} | sed 's/-.*$//'` - - if [ "${vendor}" = "${rest}" ] ; then - # a missing os is acceptable - os=none - else - os=`echo ${rest} | sed "s/${vendor}-//"` - fi - fi - ;; -esac - -# At this point we should have three parts of a canonical name in cpu, -# vendor, and os. - -# verify that the cpu is known. - -case "${cpu}" in -none | vax | tahoe | i386 | i860 | m68k | m68000 | m88k | sparc \ - | ns32k | alliant | arm | c1 | c2 | mips | pyramid | tron \ - | a29k | romp | rs6000 | i960 | xmp | ymp | cray2 | 580 | h8300) - ;; - -# start-sanitize-v9 -sparc64) ;; -# end-sanitize-v9 - -*) - echo '***' Invalid cpu \`${cpu}\': configuration \`$1\' not recognized 1>&2 - exit 1 - ;; -esac - -# verify that the vendor is known. - -case "${vendor}" in - altos | amdahl | aout | apollo | att | bcs | bout |\ - cbm | convergent | convex | coff | cray | dec | encore |\ - gould | hitachi | intel | isi | hp | ibm | little | mips | motorola |\ - ncr | next | none | nyu | sco | sequent | sgi | sony | sun |\ - unicom | utek | wrs | bull ) ;; - -# start-sanitize-v9 -hal) ;; -# end-sanitize-v9 - -*) - echo '***' Invalid vendor \`${vendor}\': configuration \`$1\' not recognized 1>&2 - exit 1 - ;; -esac - -# verify that the os is known, if it exists. - -case "${os}" in -aix* | aout | bout | bsd* | coff | ctix* | dynix* | esix* | hpux* \ - | hds | irix* | isc* | kern | mach* | newsos* | nindy* | none \ - | osf* | sco* | sunos* | sysv* | ultrix* | unos* | v88r* \ - | vms* | vxworks* | sym[1-9]* | unicos* | uts | svr4 \ - | amigados) - ;; - -# start-sanitize-v9 -hal32 | hal64 | v7 | v9) ;; -# end-sanitize-v9 - -*) - echo '***' Invalid os \`${os}\': configuration \`$1\' not recognized 1>&2 - exit 1 - ;; -esac - -echo ${cpu}-${vendor}-${os} diff --git a/binutils/configure b/binutils/configure deleted file mode 100755 index 55d5b9c5ad2..00000000000 --- a/binutils/configure +++ /dev/null @@ -1,676 +0,0 @@ -#!/bin/sh - -# Configuration script -# Copyright (C) 1988, 1990, 1991 Free Software Foundation, Inc. - -#This file is part of GNU. - -# 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -# $Id$ - -# -# Shell script to create proper links to machine-dependent files in -# preparation for compilation. -# -# If configure succeeds, it leaves its status in config.status. -# If configure fails after disturbing the status quo, -# config.status is removed. -# - -remove=rm -hard_link=ln -symbolic_link='ln -s' - -#for Test -#remove="echo rm" -#hard_link="echo ln" -#symbolic_link="echo ln -s" - -progname=$0 - -# clear some things potentially inherited from environment. -ansi= -arguments=$* -defaulttargets= -destdir= -fatal= -hostsubdir= -Makefile=Makefile -Makefile_in=Makefile.in -norecursion= -recurring= -removing= -srcdir= -srctrigger= -target= -targets= -commontargets= -configdirs= -targetsubdir= -template= -verbose= - -for arg in $*; -do - case ${arg} in - -ansi | +a*) - ansi=true - clib=clib - ;; - -destdir=* | +destdir=* | +destdi=* | +destd=* | +dest=* | +des=* | +de=* | +d=*) - destdir=`echo ${arg} | sed 's/[+-]d[a-z]*=//'` - ;; - -languages=* | +languages=* | +language=* | +languag=* \ - | +langua=* | +langu=* | +lang=* | +lan=* | +la=* \ - | +l=*) - languages="${languages} `echo ${arg} | sed 's/[+-]l[a-z]*=//'`" - ;; - -gas | +g*) - gas=yes - ;; - -help | +h*) - fatal=true - ;; - -nfp | +nf*) - nfp=yes - ;; - -norecursion | +no*) - norecursion=true - ;; - -recurring | +recurring | +recurrin | +recurri | +recurr | +recur | +recu | +rec | +re) - recurring=true - ;; - -rm | +rm) - removing=${arg} - ;; -# -srcdir=* | +srcdir=* | +srcdi=* | +srcd=* | +src=* | +sr=* | +s=*) -# srcdir=`echo ${arg} | sed 's/[+-]s[a-z]*=//'` -# ;; - -subdirs | +f* | +su*) - subdirs=${arg} - ;; - -target=* | +target=* | +targe=* | +targ=* | +tar=* | +ta=*) - if [ -n "${targets}" ] ; then - subdirs="+subdirs" - fi - - newtargets="${targets} `echo ${arg} | sed 's/[+-]t[a-z]*=//'`" - targets="${newtargets}" - ;; - -template=* | +template=* | +templat=* | +templa=* | +templ=* | +temp=* | +tem=* | +te=*) - template=`echo ${arg} | sed 's/[+-]template=//'` - ;; - -v | -verbose | +v*) - verbose=${arg} - ;; - -* | +*) - (echo ; - echo "Unrecognized option: \"${arg}\"". ; - echo) 1>&2 - fatal=true - ;; - *) - if [ -n "${hosts}" ] ; then - subdirs="+subdirs" - fi - - newhosts="${hosts} ${arg}" - hosts=${newhosts} - ;; - esac -done - -if [ -n "${verbose}" ] ; then - echo `pwd`/configure $* -fi - -# process host and target only if not rebuilding configure itself or removing. -if [ -z "${template}" -a -z "${removing}" -a -z "${fatal}" ] ; then - # Complain if an arg is missing - if [ -z "${hosts}" ] ; then - (echo ; - echo "configure: No HOST specified." ; - echo) 1>&2 - fatal=true - fi -fi - -if [ -n "${fatal}" -o "${hosts}" = "help" ] ; then - (echo "Usage: configure HOST" ; - echo ; - echo "Options: [defaults in brackets]" ; - echo " +ansi configure w/ANSI library. [no ansi lib]" ; - echo " +destdir=MYDIR configure for installation into MYDIR. [/usr/local]" ; - echo " +subdirs configure in subdirectories. [in source directories]" ; - echo " +lang=LANG configure to build LANG. [gcc]" ; - echo " +help print this message. [normal config]" ; - echo " +gas configure the compilers for use with gas. [native as]" ; - echo " +nfp configure the compilers default to soft floating point. [hard float]" ; - echo " +norecursion configure this directory only. [recurse]" ; - echo " +rm remove this configuration. [build a configuration]" ; - echo " +target=TARGET configure for TARGET. [TARGET = HOST]" ; - echo " +template=TEM rebuild configure using TEM. [normal config]" ; - echo ; - echo "Where HOST and TARGET are something like \"vax\", \"sun3\", \"encore\", etc." ; - echo "Asking for more than one \"+target\" implies \"+subdirs\". Any other" ; - echo "options given will apply to all targets.") 1>&2 - - if [ -r config.status ] ; then - cat config.status - fi - - exit 1 -fi - -#### configure.in common parts come in here. -# This file is a shell script that supplies the information necessary -# to tailor a template configure script into the configure script -# appropriate for this directory. For more information, check any -# existing configure script. - -srctrigger=ar.c -srcname="binutils" - -## end of common part. - -# are we rebuilding config itself? -if [ -n "${template}" ] ; then - if [ ! -r ${template} ] ; then - echo '***' "Can't find template ${template}." 1>&2 - exit 1 - fi - -# prep the template - sed -e '/^#### configure.in common parts come in here.$/,/^## end of common part.$/c\ -#### configure.in common parts come in here.\ -## end of common part.' \ - -e '/^#### configure.in per-host parts come in here.$/,/^## end of per-host part.$/c\ -#### configure.in per-host parts come in here.\ -## end of per-host part.' \ - -e '/^#### configure.in per-target parts come in here.$/,/^## end of per-target part.$/c\ -#### configure.in per-target parts come in here.\ -## end of per-target part.' \ - -e '/^#### configure.in post-target parts come in here.$/,/^## end of post-target part.$/c\ -#### configure.in post-target parts come in here.\ -## end of post-target part.' \ - < ${template} > template.new - - if [ -r configure.in ] ; then - if [ -z "`grep '^# per\-host:' configure.in`" ] ; then - echo '***' `pwd`/configure.in has no "per-host:" line. 1>&2 - exit 1 - fi - - if [ -z "`grep '^# per\-target:' configure.in`" ] ; then - echo '***' `pwd`/configure.in has no "per-target:" line. 1>&2 - exit 1 - fi - - # split configure.in into common, per-host, per-target, - # and post-target parts. Post-target is optional. - sed -e '/^# per\-host:/,$d' configure.in > configure.com - sed -e '1,/^# per\-host:/d' -e '/^# per\-target:/,$d' configure.in > configure.hst - if grep -s '^# post-target:' configure.in ; then - sed -e '1,/^# per\-target:/d' -e '/^# post\-target:/,$d' configure.in > configure.tgt - sed -e '1,/^# post\-target:/d' configure.in > configure.pos - else - sed -e '1,/^# per\-target:/d' configure.in > configure.tgt - echo >configure.pos - fi - - # and insert them - sed -e '/^#### configure.in common parts come in here.$/ r configure.com' \ - -e '/^#### configure.in per\-host parts come in here.$/ r configure.hst' \ - -e '/^#### configure.in per\-target parts come in here.$/ r configure.tgt' \ - -e '/^#### configure.in post\-target parts come in here.$/ r configure.pos' \ - template.new > configure.new - - rm -f configure.com configure.tgt configure.hst configure.pos - else - echo Warning: no configure.in in `pwd` - cat ${template} >> configure - fi - - chmod a+x configure.new - rm template.new -# mv configure configure.old - mv configure.new configure - - if [ -n "${verbose}" ] ; then - echo Rebuilt configure in `pwd` - fi - - # Now update config.sub from the template directory. - if echo "$template" | grep -s 'configure$' ; then - cp `echo "$template" | sed s/configure$/config.sub/` ./config.sub.new - # mv config.sub config.sub.old - mv config.sub.new config.sub - - if [ -n "${verbose}" ] ; then - echo Rebuilt config.sub in `pwd` - fi - fi - - if [ -z "${norecursion}" ] ; then - # If template is relative path, make it absolute for recurring. - if echo "${template}" | grep -s '^/' ; then - true - else - template=`pwd`/${template} - fi - - while [ -n "${configdirs}" ] ; do - # set configdir to car of configdirs, configdirs to cdr of configdirs - set ${configdirs}; configdir=$1; shift; configdirs=$* - - if [ "`echo ${configdir}.*`" != "${configdir}.*" ] ; then - targetspecificdirs=${configdir}.* - else - targetspecificdirs= - fi - - for i in ${configdir} ${targetspecificdirs} ; do - if [ -d $i ] ; then - if [ -r $i/configure ] ; then - (cd $i ; - ./configure +template=${template} ${verbose}) - else - echo Warning: No configure script in `pwd`/$i - fi - else - if [ -n "${verbose}" ] ; then - echo Warning: directory $i is missing. - fi - fi - done - done - fi - - exit 0 -fi - -# some sanity checks on configure.in -if [ -z "${srctrigger}" ] ; then - echo Warning: srctrigger not set in configure.in. `pwd` not configured. - exit 1 -fi - -for host in ${hosts} ; do - # Default other arg - if [ -z "${targets}" -o -n "${defaulttargets}" ] ; then - targets=${host} - defaulttargets=true - fi - - host_alias=${host} - - result=`/bin/sh ./config.sub ${host}` - host_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'` - host_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'` - host_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'` - host=${host_cpu}-${host_vendor}-${host_os} - host_makefile_frag=config/hmake-${host} - -#### configure.in per-host parts come in here. - -if [ "${host_os}" = "posix" ] ; then - my_host=posix -else - case "${host_cpu}" in - rs6000) my_host=aix ;; - mips) - case "${host_vendor}" in - dec) my_host=dec3100 ;; - esac - ;; - m88k) - case "${host_vendor}" in - *) - case "${host_os}" in - dgux) my_host=dgux ;; - esac - ;; - esac - ;; - - m68k) - case "${host_vendor}" in - hp) my_host=hp9000 ;; - sony) my_host=news ;; - sun) my_host=sun3 ;; - esac - ;; - - i386) - case "${host_vendor}" in - *) - case "${host_os}" in - sysv) my_host=i386v ;; - esac - ;; - esac - ;; - - sparc) - case "${host_vendor}" in - sun) my_host=sun4 ;; - esac - ;; - - rtpc) my_host=rtbsd ;; - tahoe | vax) my_host=${host_cpu} ;; - esac -fi - -if [ ! -f config/hmake-${my_host} ] ; then - echo '***' Binutils do not support host ${host} - exit 1 -fi - -host_makefile_frag=config/hmake-${my_host} - -## end of per-host part. - - for target in ${targets} ; do - - target_alias=${target} - result=`/bin/sh ./config.sub ${target}` - target_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'` - target_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'` - target_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'` - target=${target_cpu}-${target_vendor}-${target_os} - target_makefile_frag=config/tmake-${target} - -#### configure.in per-target parts come in here. - -files= -links= -## end of per-target part. - - # Temporarily, we support only direct subdir builds. - hostsubdir=H-${host_alias} - targetsubdir=T-${target_alias} - - if [ -n "${removing}" ] ; then - if [ -n "${subdirs}" ] ; then - if [ -d "${hostsubdir}" ] ; then - rm -rf ${hostsubdir}/${targetsubdir} - - if [ -z "`(ls ${hostsubdir}) 2>&1 | grep Target- | grep -v Target-independent`" ] ; then - rm -rf ${hostsubdir} - fi - else - echo Warning: no `pwd`/${hostsubdir} to remove. - fi - else - rm -f ${Makefile} config.status ${links} - fi - else - if [ -n "${subdirs}" ] ; then - # check for existing status before allowing forced subdirs. - if [ -f ${Makefile} ] ; then - echo '***' "${Makefile} already exists in source directory. `pwd` not configured." 1>&2 - exit 1 - fi - - if [ ! -d ${hostsubdir} ] ; then mkdir ${hostsubdir} ; fi - cd ${hostsubdir} - - if [ ! -d ${targetsubdir} ] ; then - if [ -z "${commontargets}" ] ; then - mkdir ${targetsubdir} - else - if [ ! -d Target-independent ] ; then - mkdir Target-independent - fi - - ${symbolic_link} Target-independent ${targetsubdir} - fi # if target independent - fi # if no target dir yet - - cd ${targetsubdir} - - srcdir=../.. - else - # if not subdir builds, then make sure none exist. - if [ -n "`(ls .) 2>&1 | grep Host-`" ] ; then - echo '***' "Configured subdirs exist. `pwd` not configured." 1>&2 - exit 1 - fi - fi - - # Find the source files, if location was not specified. - if [ -z "${srcdir}" ] ; then - srcdirdefaulted=1 - srcdir=. - if [ -n "${srctrigger}" -a ! -r ${srctrigger} ] ; then - srcdir=.. - fi - fi - - if [ -n "${srctrigger}" -a ! -r ${srcdir}/${srctrigger} ] ; then - if [ -z "${srcdirdefaulted}" ] ; then - echo '***' "${progname}: Can't find ${srcname} sources in `pwd`/${srcdir}" 1>&2 - else - echo '***' "${progname}: Can't find ${srcname} sources in `pwd`/. or `pwd`/.." 1>&2 - fi - - echo '***' \(At least ${srctrigger} is missing.\) 1>&2 - exit 1 - fi - - # Set up the list of links to be made. - # ${links} is the list of link names, and ${files} is the list of names to link to. - - # Make the links. - while [ -n "${files}" ] ; do - # set file to car of files, files to cdr of files - set ${files}; file=$1; shift; files=$* - set ${links}; link=$1; shift; links=$* - - if [ ! -r ${srcdir}/${file} ] ; then - echo '***' "${progname}: cannot create a link \"${link}\"," 1>&2 - echo '***' "since the file \"${file}\" does not exist." 1>&2 - exit 1 - fi - - ${remove} -f ${link} - rm -f config.status - # Make a symlink if possible, otherwise try a hard link - ${symbolic_link} ${srcdir}/${file} ${link} 2>/dev/null || ${hard_link} ${srcdir}/${file} ${link} - - if [ ! -r ${link} ] ; then - echo '***' "${progname}: unable to link \"${link}\" to \"${srcdir}/${file}\"." 1>&2 - exit 1 - fi - - if [ -n "${verbose}" ] ; then - echo "Linked \"${link}\" to \"${srcdir}/${file}\"." - fi - done - - # Create a .gdbinit file which runs the one in srcdir - # and tells GDB to look there for source files. - - case ${srcdir} in - .) - ;; - *) - echo "dir ." > .gdbinit - echo "dir ${srcdir}" >> .gdbinit - echo "source ${srcdir}/.gdbinit" >> .gdbinit - ;; - esac - - # Install a makefile, and make it set VPATH - # if necessary so that the sources are found. - # Also change its value of srcdir. - - # FIXME-someday: This business of always writing to .tem and mv back - # is so that I don't screw things up while developing. Once this - # template is stable, these should be optimized. xoxorich. - - # Define macro CROSS_COMPILE in compilation if this is a cross-compiler. - if [ "${host}" != "${target}" ] ; then - echo "CROSS=-DCROSS_COMPILE" > ${Makefile} - echo "ALL=start.encap" >> ${Makefile} - else - echo "ALL=all.internal" > ${Makefile} - fi - - # set target, host, VPATH - echo "host_alias = ${host_alias}" >> ${Makefile} - echo "host_cpu = ${host_cpu}" >> ${Makefile} - echo "host_vendor = ${host_vendor}" >> ${Makefile} - echo "host_os = ${host_os}" >> ${Makefile} - - echo "target_alias = ${target_alias}" >> ${Makefile} - echo "target_cpu = ${target_cpu}" >> ${Makefile} - echo "target_vendor = ${target_vendor}" >> ${Makefile} - echo "target_os = ${target_os}" >> ${Makefile} - - if [ -n "${subdirs}" ] ; then - echo "subdir = /${hostsubdir}/${targetsubdir}" >> ${Makefile} - else - echo "subdir =" >> ${Makefile} - fi - - # echo "workdir = `pwd`" >> ${Makefile} - echo "VPATH = ${srcdir}" >> ${Makefile} - - # add "Makefile.in" (or whatever it's called) - cat ${srcdir}/${Makefile_in} >> ${Makefile} - - # Conditionalize the makefile for this host. - if [ -f ${srcdir}/${host_makefile_frag} ] ; then - (echo "host_makefile_frag = ${srcdir}/${host_makefile_frag}" ; - sed -e "/^####/ r ${srcdir}/${host_makefile_frag}" ${Makefile}) > Makefile.tem - mv Makefile.tem ${Makefile} - fi - - # Conditionalize the makefile for this target. - if [ -f ${srcdir}/${target_makefile_frag} ] ; then - (echo "target_makefile_frag = ${srcdir}/${target_makefile_frag}" ; - sed -e "/^####/ r ${srcdir}/${target_makefile_frag}" ${Makefile}) > Makefile.tem - mv Makefile.tem ${Makefile} - fi - - # set srcdir - sed "s@^srcdir = \.@srcdir = ${srcdir}@" ${Makefile} > Makefile.tem - mv Makefile.tem ${Makefile} - - # set destdir - if [ -n "${destdir}" ] ; then - sed "s:^destdir =.*$:destdir = ${destdir}:" ${Makefile} > Makefile.tem - mv Makefile.tem ${Makefile} - fi - - # reset SUBDIRS - sed "s:^SUBDIRS =.*$:SUBDIRS = ${configdirs}:" ${Makefile} > Makefile.tem - mv Makefile.tem ${Makefile} - - # reset NONSUBDIRS - sed "s:^NONSUBDIRS =.*$:NONSUBDIRS = ${noconfigdirs}:" ${Makefile} > Makefile.tem - mv Makefile.tem ${Makefile} - - using= - if [ -f ${srcdir}/${host_makefile_frag} ] ; then - using=" using \"${host_makefile_frag}\"" - fi - - # remove any form feeds. - sed -e "s/ //" ${Makefile} > Makefile.tem - mv Makefile.tem ${Makefile} - - if [ -f ${srcdir}/${target_makefile_frag} ] ; then - if [ -z "${using}" ] ; then - andusing=" using \"${target_makefile_frag}\"" - else - andusing="${using} and \"${target_makefile_frag}\"" - fi - else - andusing=${using} - fi - - if [ -n "${verbose}" -o -z "${recurring}" ] ; then - echo "Created \"${Makefile}\"" in `pwd`${andusing}. - fi - -#### configure.in post-target parts come in here. - -## end of post-target part. - - # describe the chosen configuration in config.status. - # Make that file a shellscript which will reestablish - # the same configuration. Used in Makefiles to rebuild - # Makefiles. - - echo "#!/bin/sh -# ${srcname} was configured as follows: -${srcdir}/configure" ${arguments} `if [ -z "${norecursion}" ] ; then echo +norecursion ; else true ; fi` > config.status - chmod a+x config.status - - originaldir=`pwd` - cd ${srcdir} - fi - - # If there are subdirectories, then recurse. - if [ -z "${norecursion}" -a -n "${configdirs}" ] ; then - for configdir in ${configdirs} ; do - if [ -n "${verbose}" ] ; then - echo Configuring ${configdir}... - fi - - if [ -d ${configdir} ] ; then - (cd ${configdir} ; - ./configure +recurring ${host_alias} +target=${target_alias} \ - ${verbose} ${subdirs} ${removing} +destdir=${destdir}) \ - | sed 's/^/ /' - else - if [ -n "${verbose}" ] ; then - echo Warning: directory \"${configdir}\" is missing. - fi - fi - done - fi - done # for each target - - # Now build a Makefile for this host. - if [ -n "${subdirs}" -a ! -n "${removing}" ] ; then - cd ${hostsubdir} - cat > GNUmakefile << E!O!F -# Makefile generated by configure for host ${host_alias}. - -ALL := $(shell ls -d Target-*) - -%: - $(foreach subdir,$(ALL),$(MAKE) -C $(subdir) \$@ &&) true - -all: -E!O!F - cd .. - fi -done # for each host - -exit 0 - -# -# Local Variables: -# fill-column: 131 -# End: -# - -# end of configure diff --git a/binutils/configure.in b/binutils/configure.in deleted file mode 100644 index 4dbcaac5aad..00000000000 --- a/binutils/configure.in +++ /dev/null @@ -1,20 +0,0 @@ -# This file is a shell script that supplies the information necessary -# to tailor a template configure script into the configure script -# appropriate for this directory. For more information, check any -# existing configure script. - -srctrigger=ar.c -srcname="binutils" - -# per-host: - -if [ ! -f config/hmake-${host} ] ; then - echo No such host available: ${host} - exit 1 -fi - -# per-target: - -files= -links= - diff --git a/binutils/copy.c b/binutils/copy.c deleted file mode 100644 index fa86cf6e95a..00000000000 --- a/binutils/copy.c +++ /dev/null @@ -1,449 +0,0 @@ -/* copy.c -- copy object file from input to output, optionally massaging it. - Copyright (C) 1991 Free Software Foundation, Inc. - -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 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include "bfd.h" -#include "sysdep.h" - -asymbol **sympp; -char *input_target = NULL; -char *output_target = NULL; -char *input_filename = NULL; -char *output_filename = NULL; - - -static void setup_sections(); -static void copy_sections(); -static boolean strip; -static boolean verbose; - -/* This flag distinguishes between strip and copy: - 1 means this is 'strip'; 0 means this is 'copy'. - -1 means if we should use argv[0] to decide. */ -extern int is_strip; - -/* IMPORTS */ -extern char *program_name; -extern char *xmalloc(); - -static -void -usage() -{ - fprintf(stderr, - "Usage %s [-S][-s srcfmt] [-d dtfmt] [-b bothfmts] infile [outfile]\n", - program_name); - exit(1); -} - - -/* Create a temp file in the same directory as supplied */ -static -char * -make_tempname(filename) -char *filename; -{ - static char template[] = "stXXXXXX"; - char *tmpname; - char * slash = strrchr( filename, '/' ); - if (slash != (char *)NULL){ - *slash = 0; - tmpname = xmalloc(strlen(filename) + sizeof(template) + 1 ); - strcpy(tmpname, filename); - strcat(tmpname, "/" ); - strcat(tmpname, template); - mktemp(tmpname ); - *slash = '/'; - } else { - tmpname = xmalloc(sizeof(template)); - strcpy(tmpname, template); - mktemp(tmpname); - } - return tmpname; -} - -/* - All the symbols have been read in and point to their owning input section. - They have been relocated to that they are all relative to the base of - their owning section. On the way out, all the symbols will be relocated to - their new location in the output file, through some complex sums. - -*/ -static void -mangle_sections(ibfd, obfd) - bfd *ibfd; - bfd *obfd; -{ - asection *current = ibfd->sections; - for (; current != NULL; current = current->next) { - current->output_section = bfd_get_section_by_name(obfd, current->name); - current->output_offset = 0; - } -} - -static -void -copy_object(ibfd, obfd) -bfd *ibfd; -bfd *obfd; -{ - - unsigned int symcount; - - - if (!bfd_set_format(obfd, bfd_get_format(ibfd))) - bfd_fatal(output_filename); - - - if (verbose) - printf("copy from %s(%s) to %s(%s)\n", - ibfd->filename, ibfd->xvec->name, - obfd->filename, obfd->xvec->name); - - if ((bfd_set_start_address(obfd, bfd_get_start_address(ibfd)) == false) - || - (bfd_set_file_flags(obfd, (bfd_get_file_flags(ibfd) & - (HAS_LINENO | HAS_DEBUG | - HAS_RELOC | HAS_SYMS | D_PAGED | - HAS_LOCALS))) == false)) { - bfd_fatal(bfd_get_filename(ibfd)); - } - - /* Copy architecture of input file to output file */ - if (!bfd_set_arch_mach(obfd, bfd_get_arch(ibfd), - bfd_get_mach(ibfd))) { - fprintf(stderr, "Output file cannot represent architecture %s\n", - bfd_printable_arch_mach(bfd_get_arch(ibfd), - bfd_get_mach(ibfd))); - } - if (!bfd_set_format(obfd, bfd_get_format(ibfd))) - { - bfd_fatal(ibfd->filename); - } - - sympp = (asymbol **) xmalloc(get_symtab_upper_bound(ibfd)); - symcount = bfd_canonicalize_symtab(ibfd, sympp); - - bfd_set_symtab(obfd, sympp, is_strip ? 0 : symcount); - - /* - bfd mandates that all output sections be created and sizes set before - any output is done. Thus, we traverse all sections twice. - */ - bfd_map_over_sections(ibfd, setup_sections, (void *) obfd); - bfd_map_over_sections(ibfd, copy_sections, (void *) obfd); - mangle_sections(ibfd, obfd); -} -static -char * -cat(a,b,c) -char *a; -char *b; -char *c; -{ - int size = strlen(a) + strlen(b) + strlen(c); - char *r = xmalloc(size+1); - strcpy(r,a); - strcat(r,b); - strcat(r,c); - return r; -} - -static void -copy_archive(ibfd, obfd) -bfd *ibfd; -bfd *obfd; -{ - bfd **ptr = &obfd->archive_head; - bfd *this_element; - /* Read each archive element in turn from the input, copy the - contents to a temp file, and keep the temp file handle */ - char *dir = cat("./#",make_tempname(""),"cd"); - - /* Make a temp directory to hold the contents */ - mkdir(dir,0777); - obfd->has_armap = ibfd->has_armap; - this_element = bfd_openr_next_archived_file(ibfd, NULL); - ibfd->archive_head = this_element; - while (this_element != (bfd *)NULL) { - - /* Create an output file for this member */ - char *output_name = cat(dir, "/",this_element->filename); - bfd *output_bfd = bfd_openw(output_name, output_target); - - if (!bfd_set_format(obfd, bfd_get_format(ibfd))) - bfd_fatal(output_filename); - - if (output_bfd == (bfd *)NULL) { - bfd_fatal(output_name); - } - if (bfd_check_format(this_element, bfd_object) == true) { - copy_object(this_element, output_bfd); - } - - bfd_close(output_bfd); - /* Now open the newly output file and attatch to our list */ - output_bfd = bfd_openr(output_name, output_target); - /* Mark it for deletion */ - - *ptr = output_bfd; - - ptr = &output_bfd->next; - this_element->next = bfd_openr_next_archived_file(ibfd, this_element); - this_element = this_element->next; - - } - *ptr = (bfd *)NULL; - - if (!bfd_close(obfd)) - bfd_fatal(output_filename); - - /* Now delete all the files that we opened. - Construct their names again, unfortunately, but so what; - we're about to exit anyway. */ - for (this_element = ibfd->archive_head; - this_element != (bfd *)NULL; - this_element = this_element->next) - { - unlink(cat(dir,"/",this_element->filename)); - } - rmdir(dir); - if (!bfd_close(ibfd)) - bfd_fatal(input_filename); - -} - -static -void -copy_file(input_filename, output_filename) - char *input_filename; - char *output_filename; -{ - bfd *ibfd; - - ibfd = bfd_openr(input_filename, input_target); - if (ibfd == NULL) - bfd_fatal(input_filename); - - if (bfd_check_format(ibfd, bfd_object)) { - bfd * obfd = bfd_openw(output_filename, output_target); - if (obfd == NULL) - bfd_fatal(output_filename); - - copy_object(ibfd, obfd); - - if (ibfd->flags & EXEC_P) - obfd->flags |= EXEC_P; - if (!bfd_close(obfd)) - bfd_fatal(output_filename); - - if (!bfd_close(ibfd)) - bfd_fatal(input_filename); - } - else if (bfd_check_format(ibfd, bfd_archive)) { - bfd * obfd = bfd_openw(output_filename, output_target); - if (obfd == NULL) - bfd_fatal(output_filename); - copy_archive(ibfd, obfd); - } -} - - - -/** Actually do the work */ -static void -setup_sections(ibfd, isection, obfd) - bfd *ibfd; - sec_ptr isection; - bfd *obfd; -{ - sec_ptr osection; - char *err; - - osection = bfd_get_section_by_name(obfd, bfd_section_name(ibfd, isection)); - if (osection == NULL) { - osection = bfd_make_section(obfd, bfd_section_name(ibfd, isection)); - if (osection == NULL) { - err = "making"; - goto loser; - } - } - - if (!bfd_set_section_size(obfd, - osection, - bfd_section_size(ibfd, isection))) { - err = "size"; - goto loser; - } - - if (bfd_set_section_vma(obfd, - osection, - bfd_section_vma(ibfd, isection)) - == false) { - err = "vma"; - goto loser; - } /* on error */ - - if (bfd_set_section_alignment(obfd, - osection, - bfd_section_alignment(ibfd, isection)) - == false) { - err = "alignment"; - goto loser; - } /* on error */ - - if (!bfd_set_section_flags(obfd, osection, - bfd_get_section_flags(ibfd, isection))) { - err = "flags"; - goto loser; - } - - /* All went well */ - return; - -loser: - fprintf(stderr, "%s: file \"%s\", section \"%s\": error in %s: %s\n", - program_name, - bfd_get_filename(ibfd), bfd_section_name(ibfd, isection), - err, bfd_errmsg(bfd_error)); - exit(1); -} /* setup_sections() */ - -/* -Copy all the section related data from an input section -to an output section - -If stripping then don't copy any relocation info -*/ -static void -copy_sections(ibfd, isection, obfd) - bfd *ibfd; - sec_ptr isection; - bfd *obfd; -{ - - arelent **relpp; - int relcount; - sec_ptr osection; - bfd_size_type size; - osection = bfd_get_section_by_name(obfd, - bfd_section_name(ibfd, isection)); - - size = isection->size; - - if (size == 0) - return; - - if (is_strip || get_reloc_upper_bound(ibfd, isection) == 0) - { - bfd_set_reloc(obfd, osection, (arelent **)NULL, 0); - } - else - { - relpp = (arelent **) xmalloc(get_reloc_upper_bound(ibfd, isection)); - relcount = bfd_canonicalize_reloc(ibfd, isection, relpp, sympp); - bfd_set_reloc(obfd, osection, relpp, relcount); - } - - - if (bfd_get_section_flags(ibfd, isection) & SEC_HAS_CONTENTS) - { - PTR memhunk = (PTR) xmalloc((unsigned)size); - - if (!bfd_get_section_contents(ibfd, isection, memhunk, (file_ptr) 0, size)) - bfd_fatal(bfd_get_filename(ibfd)); - - if (!bfd_set_section_contents(obfd, osection, memhunk, (file_ptr)0, size)) - bfd_fatal(bfd_get_filename(obfd)); - free(memhunk); - } - - -} -int -main(argc, argv) - int argc; - char *argv[]; -{ - int i; - - program_name = argv[0]; - - bfd_init(); - - if (is_strip < 0) { - i = strlen (program_name); - is_strip = (i >= 5 && strcmp(program_name+i-5,"strip")); - } - - for (i = 1; i < argc; i++) - { - if (argv[i][0] == '-') { - switch (argv[i][1]) { - case 'v': - verbose = true; - break; - case 'b': - i++; - input_target = output_target = argv[i]; - break; - case 'S': - is_strip = 1; - break; - case 's': - i++; - input_target = argv[i]; - break; - case 'd': - i++; - output_target = argv[i]; - break; - default: - usage(); - } - } - else { - if (input_filename) { - output_filename = argv[i]; - } - else { - input_filename = argv[i]; - } - } - } - - if (input_filename == (char *) NULL) - usage(); - - if (output_target == (char *) NULL) - output_target = input_target; - - /* If there is no destination file then create a temp and rename - the result into the input */ - - if (output_filename == (char *)NULL) { - char * tmpname = make_tempname(input_filename); - copy_file(input_filename, tmpname); - output_filename = input_filename; - rename(tmpname, input_filename); - } - else { - copy_file(input_filename, output_filename); - } - return 0; -} diff --git a/binutils/cplus-dem.c b/binutils/cplus-dem.c deleted file mode 100644 index 22a38bac2c4..00000000000 --- a/binutils/cplus-dem.c +++ /dev/null @@ -1,934 +0,0 @@ -/* Demangler for GNU C++ - Copyright (C) 1989 Free Software Foundation, Inc. - written by James Clark (jjc@jclark.uucp) - - 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* This is for g++ 1.36.1 (November 6 version). It will probably - require changes for any other version. - - Modified for g++ 1.36.2 (November 18 version). */ - -/* This file exports one function - - char *cplus_demangle (const char *name) - - If `name' is a mangled function name produced by g++, then - a pointer to a malloced string giving a C++ representation - of the name will be returned; otherwise NULL will be returned. - It is the caller's responsibility to free the string which - is returned. - - For example, - - cplus_demangle ("_foo__1Ai") - - returns - - "A::foo(int)" - - This file imports xmalloc and xrealloc, which are like malloc and - realloc except that they generate a fatal error if there is no - available memory. */ - -#if 0 /* Should really be part of BFD */ -#define nounderscore 1 /* define this is names don't start with _ */ -#endif -#include "bfd.h" -#include "sysdep.h" - -#include - -#ifndef __STDC__ -#define const -#endif - -#ifdef __STDC__ -extern char *cplus_demangle (const char *type); -#else -extern char *cplus_demangle (); -#endif - -static char **typevec = 0; -static int ntypes = 0; -static int typevec_size = 0; - -static struct { - const char *in; - const char *out; -} optable[] = { - "new", " new", - "delete", " delete", - "ne", "!=", - "eq", "==", - "ge", ">=", - "gt", ">", - "le", "<=", - "lt", "<", - "plus", "+", - "minus", "-", - "mult", "*", - "convert", "+", /* unary + */ - "negate", "-", /* unary - */ - "trunc_mod", "%", - "trunc_div", "/", - "truth_andif", "&&", - "truth_orif", "||", - "truth_not", "!", - "postincrement", "++", - "postdecrement", "--", - "bit_ior", "|", - "bit_xor", "^", - "bit_and", "&", - "bit_not", "~", - "call", "()", - "cond", "?:", - "alshift", "<<", - "arshift", ">>", - "component", "->", - "indirect", "*", - "method_call", "->()", - "addr", "&", /* unary & */ - "array", "[]", - "nop", "", /* for operator= */ -}; - -/* Beware: these aren't '\0' terminated. */ - -typedef struct { - char *b; /* pointer to start of string */ - char *p; /* pointer after last character */ - char *e; /* pointer after end of allocated space */ -} string; - -#ifdef __STDC__ -static void string_need (string *s, int n); -static void string_delete (string *s); -static void string_init (string *s); -static void string_clear (string *s); -static int string_empty (string *s); -static void string_append (string *p, const char *s); -static void string_appends (string *p, string *s); -static void string_appendn (string *p, const char *s, int n); -static void string_prepend (string *p, const char *s); -#if 0 -static void string_prepends (string *p, string *s); -#endif -static void string_prependn (string *p, const char *s, int n); -static int get_count (const char **type, int *count); -static int do_args (const char **type, string *decl); -static int do_type (const char **type, string *result); -static int do_arg (const char **type, string *result); -static int do_args (const char **type, string *decl); -static void munge_function_name (string *name); -#else -static void string_need (); -static void string_delete (); -static void string_init (); -static void string_clear (); -static int string_empty (); -static void string_append (); -static void string_appends (); -static void string_appendn (); -static void string_prepend (); -static void string_prepends (); -static void string_prependn (); -static int get_count (); -static int do_args (); -static int do_type (); -static int do_arg (); -static int do_args (); -static void munge_function_name (); -#endif - -char * -cplus_demangle (type) - const char *type; -{ - string decl; - int n; - int success = 0; - int constructor = 0; - int const_flag = 0; - int i; - const char *p, *premangle; - - if (type == NULL || *type == '\0') - return NULL; -#ifndef nounderscore - if (*type++ != '_') - return NULL; -#endif - p = type; - while (*p != '\0' && !(*p == '_' && p[1] == '_')) - p++; - if (*p == '\0') - { - /* destructor */ - if (type[0] == '_' && type[1] == '$' && type[2] == '_') - { - unsigned int l = (strlen (type) - 3)*2 + 3 + 2 + 1; - char *tem = (char *) xmalloc (l); - strcpy (tem, type + 3); - strcat (tem, "::~"); - strcat (tem, type + 3); - strcat (tem, "()"); - return tem; - } - /* static data member */ - if (*type != '_' && (p = (char *) strchr (type, '$')) != NULL) - { - int n = strlen (type) + 2; - char *tem = (char *) xmalloc (n); - memcpy (tem, type, p - type); - strcpy (tem + (p - type), "::"); - strcpy (tem + (p - type) + 2, p + 1); - return tem; - } - /* virtual table */ - if (type[0] == '_' && type[1] == 'v' && type[2] == 't' && type[3] == '$') - { - int n = strlen (type + 4) + 14 + 1; - char *tem = (char *) xmalloc (n); - strcpy (tem, type + 4); - strcat (tem, " virtual table"); - return tem; - } - return NULL; - } - - string_init (&decl); - - if (p == type) - { - if (!isdigit (p[2])) - { - string_delete (&decl); - return NULL; - } - constructor = 1; - } - else - { - string_appendn (&decl, type, p - type); - munge_function_name (&decl); - } - p += 2; - - premangle = p; - switch (*p) - { - case 'C': - /* a const member function */ - if (!isdigit (p[1])) - { - string_delete (&decl); - return NULL; - } - p += 1; - const_flag = 1; - /* fall through */ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - n = 0; - do - { - n *= 10; - n += *p - '0'; - p += 1; - } - while (isdigit (*p)); - if (strlen (p) < n) - { - string_delete (&decl); - return NULL; - } - if (constructor) - { - string_appendn (&decl, p, n); - string_append (&decl, "::"); - string_appendn (&decl, p, n); - } - else - { - string_prepend (&decl, "::"); - string_prependn (&decl, p, n); - } -#ifndef LONGERNAMES - p = premangle; -#else - p += n; -#endif - success = do_args (&p, &decl); - if (const_flag) - string_append (&decl, " const"); - break; - case 'F': - p += 1; - success = do_args (&p, &decl); - break; - } - - for (i = 0; i < ntypes; i++) - if (typevec[i] != NULL) - free (typevec[i]); - ntypes = 0; - if (typevec != NULL) - { - free ((char *)typevec); - typevec = NULL; - typevec_size = 0; - } - - if (success) - { - string_appendn (&decl, "", 1); - return decl.b; - } - else - { - string_delete (&decl); - return NULL; - } -} - -static int -get_count (type, count) - const char **type; - int *count; -{ - if (!isdigit (**type)) - return 0; - *count = **type - '0'; - *type += 1; - /* see flush_repeats in cplus-method.c */ - if (isdigit (**type)) - { - const char *p = *type; - int n = *count; - do - { - n *= 10; - n += *p - '0'; - p += 1; - } - while (isdigit (*p)); - if (*p == '_') - { - *type = p + 1; - *count = n; - } - } - return 1; -} - -/* result will be initialised here; it will be freed on failure */ - -static int -do_type (type, result) - const char **type; - string *result; -{ - int n; - int done; - int non_empty = 0; - int success; - string decl; - const char *remembered_type; - - string_init (&decl); - string_init (result); - - done = 0; - success = 1; - while (success && !done) - { - int member; - switch (**type) - { - case 'P': - *type += 1; - string_prepend (&decl, "*"); - break; - - case 'R': - *type += 1; - string_prepend (&decl, "&"); - break; - - case 'T': - *type += 1; - if (!get_count (type, &n) || n >= ntypes) - success = 0; - else - { - remembered_type = typevec[n]; - type = &remembered_type; - } - break; - - case 'F': - *type += 1; - if (!string_empty (&decl) && decl.b[0] == '*') - { - string_prepend (&decl, "("); - string_append (&decl, ")"); - } - if (!do_args (type, &decl) || **type != '_') - success = 0; - else - *type += 1; - break; - - case 'M': - case 'O': - { - int constp = 0; - int volatilep = 0; - - member = **type == 'M'; - *type += 1; - if (!isdigit (**type)) - { - success = 0; - break; - } - n = 0; - do - { - n *= 10; - n += **type - '0'; - *type += 1; - } - while (isdigit (**type)); - if (strlen (*type) < n) - { - success = 0; - break; - } - string_append (&decl, ")"); - string_prepend (&decl, "::"); - string_prependn (&decl, *type, n); - string_prepend (&decl, "("); - *type += n; - if (member) - { - if (**type == 'C') - { - *type += 1; - constp = 1; - } - if (**type == 'V') - { - *type += 1; - volatilep = 1; - } - if (*(*type)++ != 'F') - { - success = 0; - break; - } - } - if ((member && !do_args (type, &decl)) || **type != '_') - { - success = 0; - break; - } - *type += 1; - if (constp) - { - if (non_empty) - string_append (&decl, " "); - else - non_empty = 1; - string_append (&decl, "const"); - } - if (volatilep) - { - if (non_empty) - string_append (&decl, " "); - else - non_empty = 1; - string_append (&decl, "volatilep"); - } - break; - } - - case 'C': - if ((*type)[1] == 'P') - { - *type += 1; - if (!string_empty (&decl)) - string_prepend (&decl, " "); - string_prepend (&decl, "const"); - break; - } - - /* fall through */ - default: - done = 1; - break; - } - } - - done = 0; - non_empty = 0; - while (success && !done) - { - switch (**type) - { - case 'C': - *type += 1; - if (non_empty) - string_append (result, " "); - else - non_empty = 1; - string_append (result, "const"); - break; - case 'U': - *type += 1; - if (non_empty) - string_append (result, " "); - else - non_empty = 1; - string_append (result, "unsigned"); - break; - case 'V': - *type += 1; - if (non_empty) - string_append (result, " "); - else - non_empty = 1; - string_append (result, "volatile"); - break; - default: - done = 1; - break; - } - } - - if (success) - switch (**type) - { - case '\0': - case '_': - break; - case 'v': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "void"); - break; - case 'l': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "long"); - break; - case 'i': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "int"); - break; - case 's': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "short"); - break; - case 'c': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "char"); - break; - case 'r': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "long double"); - break; - case 'd': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "double"); - break; - case 'f': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "float"); - break; - case 'G': - *type += 1; - if (!isdigit (**type)) - { - success = 0; - break; - } - /* fall through */ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - n = 0; - do - { - n *= 10; - n += **type - '0'; - *type += 1; - } - while (isdigit (**type)); - if (strlen (*type) < n) - { - success = 0; - break; - } - if (non_empty) - string_append (result, " "); - string_appendn (result, *type, n); - *type += n; - break; - default: - success = 0; - break; - } - - if (success) - { - if (!string_empty (&decl)) - { - string_append (result, " "); - string_appends (result, &decl); - } - string_delete (&decl); - return 1; - } - else - { - string_delete (&decl); - string_delete (result); - return 0; - } -} - -/* `result' will be initialised in do_type; it will be freed on failure */ - -static int -do_arg (type, result) - const char **type; - string *result; -{ - char *tem; - int len; - const char *start; - const char *end; - - start = *type; - if (!do_type (type, result)) - return 0; - end = *type; - if (ntypes >= typevec_size) - { - if (typevec_size == 0) - { - typevec_size = 3; - typevec = (char **) xmalloc (sizeof (char*)*typevec_size); - } - else - { - typevec_size *= 2; - typevec = (char **) xrealloc ((char *)typevec, sizeof (char*)*typevec_size); - } - } - len = end - start; - tem = (char *) xmalloc (len + 1); - memcpy (tem, start, len); - tem[len] = '\0'; - typevec[ntypes++] = tem; - return 1; -} - -/* `decl' must be already initialised, usually non-empty; - it won't be freed on failure */ - -static int -do_args (type, decl) - const char **type; - string *decl; -{ - string arg; - int need_comma = 0; - int dont_want_first; - -#ifndef LONGERNAMES - dont_want_first = 1; -#else - dont_want_first = 0; -#endif - - string_append (decl, "("); - - while (**type != '_' && **type != '\0' && **type != 'e' && **type != 'v') - { - if (**type == 'N') - { - int r; - int t; - *type += 1; - if (!get_count (type, &r) || !get_count (type, &t) || t >= ntypes) - return 0; - while (--r >= 0) - { - const char *tem = typevec[t]; - if (need_comma) - string_append (decl, ", "); - if (!do_arg (&tem, &arg)) - return 0; - string_appends (decl, &arg); - string_delete (&arg); - need_comma = 1; - } - } - else - { - if (need_comma) - string_append (decl, ", "); - if (!do_arg (type, &arg)) - return 0; - if (dont_want_first) - dont_want_first = 0; - else - { - string_appends (decl, &arg); - need_comma = 1; - } - string_delete (&arg); - } - } - - if (**type == 'v') - *type += 1; - else if (**type == 'e') - { - *type += 1; - if (need_comma) - string_append (decl, ","); - string_append (decl, "..."); - } - - string_append (decl, ")"); - return 1; -} - -static void -munge_function_name (name) - string *name; -{ - if (!string_empty (name) && name->p - name->b >= 3 - && name->b[0] == 'o' && name->b[1] == 'p' && name->b[2] == '$') - { - unsigned int i; - /* see if it's an assignment expression */ - if (name->p - name->b >= 10 /* op$assign_ */ - && memcmp (name->b + 3, "assign_", 7) == 0) - { - for (i = 0; i < sizeof (optable)/sizeof (optable[0]); i++) - { - int len = name->p - name->b - 10; - if (strlen (optable[i].in) == len - && memcmp (optable[i].in, name->b + 10, len) == 0) - { - string_clear (name); - string_append (name, "operator"); - string_append (name, optable[i].out); - string_append (name, "="); - return; - } - } - } - else - { - for (i = 0; i < sizeof (optable)/sizeof (optable[0]); i++) - { - int len = name->p - name->b - 3; - if (strlen (optable[i].in) == len - && memcmp (optable[i].in, name->b + 3, len) == 0) - { - string_clear (name); - string_append (name, "operator"); - string_append (name, optable[i].out); - return; - } - } - } - return; - } - else if (!string_empty (name) && name->p - name->b >= 5 - && memcmp (name->b, "type$", 5) == 0) - { - /* type conversion operator */ - string type; - const char *tem = name->b + 5; - if (do_type (&tem, &type)) - { - string_clear (name); - string_append (name, "operator "); - string_appends (name, &type); - string_delete (&type); - return; - } - } -} - -/* a mini string-handling package */ - -static void -string_need (s, n) - string *s; - int n; -{ - if (s->b == NULL) - { - if (n < 32) - n = 32; - s->p = s->b = (char *) xmalloc (n); - s->e = s->b + n; - } - else if (s->e - s->p < n) - { - int tem = s->p - s->b; - n += tem; - n *= 2; - s->b = (char *) xrealloc (s->b, n); - s->p = s->b + tem; - s->e = s->b + n; - } -} - -static void -string_delete (s) - string *s; -{ - if (s->b != NULL) - { - free (s->b); - s->b = s->e = s->p = NULL; - } -} - -static void -string_init (s) - string *s; -{ - s->b = s->p = s->e = NULL; -} - -static void -string_clear (s) - string *s; -{ - s->p = s->b; -} - -static int -string_empty (s) - string *s; -{ - return s->b == s->p; -} - -static void -string_append (p, s) - string *p; - const char *s; -{ - int n; - if (s == NULL || *s == '\0') - return; - n = strlen (s); - string_need (p, n); - memcpy (p->p, s, n); - p->p += n; -} - -static void -string_appends (p, s) - string *p, *s; -{ - int n; - if (s->b == s->p) - return; - n = s->p - s->b; - string_need (p, n); - memcpy (p->p, s->b, n); - p->p += n; -} - -static void -string_appendn (p, s, n) - string *p; - const char *s; - int n; -{ - if (n == 0) - return; - string_need (p, n); - memcpy (p->p, s, n); - p->p += n; -} - -static void -string_prepend (p, s) - string *p; - const char *s; -{ - if (s == NULL || *s == '\0') - return; - string_prependn (p, s, strlen (s)); -} - -static void -string_prependn (p, s, n) - string *p; - const char *s; - int n; -{ - char *q; - - if (n == 0) - return; - string_need (p, n); - for (q = p->p - 1; q >= p->b; q--) - q[n] = q[0]; - memcpy (p->b, s, n); - p->p += n; -} diff --git a/binutils/filemode.c b/binutils/filemode.c deleted file mode 100644 index 1bb5e642120..00000000000 --- a/binutils/filemode.c +++ /dev/null @@ -1,193 +0,0 @@ -/* filemode.c -- make a string describing file modes - Copyright (C) 1985, 1990 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include - -void mode_string (); -static char ftypelet (); -static void rwx (); -static void setst (); - -/* filemodestring - fill in string STR with an ls-style ASCII - representation of the st_mode field of file stats block STATP. - 10 characters are stored in STR; no terminating null is added. - The characters stored in STR are: - - 0 File type. 'd' for directory, 'c' for character - special, 'b' for block special, 'm' for multiplex, - 'l' for symbolic link, 's' for socket, 'p' for fifo, - '-' for any other file type - - 1 'r' if the owner may read, '-' otherwise. - - 2 'w' if the owner may write, '-' otherwise. - - 3 'x' if the owner may execute, 's' if the file is - set-user-id, '-' otherwise. - 'S' if the file is set-user-id, but the execute - bit isn't set. - - 4 'r' if group members may read, '-' otherwise. - - 5 'w' if group members may write, '-' otherwise. - - 6 'x' if group members may execute, 's' if the file is - set-group-id, '-' otherwise. - 'S' if it is set-group-id but not executable. - - 7 'r' if any user may read, '-' otherwise. - - 8 'w' if any user may write, '-' otherwise. - - 9 'x' if any user may execute, 't' if the file is "sticky" - (will be retained in swap space after execution), '-' - otherwise. - 'T' if the file is sticky but not executable. */ - -void -filemodestring (statp, str) - struct stat *statp; - char *str; -{ - mode_string (statp->st_mode, str); -} - -/* Like filemodestring, but only the relevant part of the `struct stat' - is given as an argument. */ - -void -mode_string (mode, str) - unsigned short mode; - char *str; -{ - str[0] = ftypelet (mode); - rwx ((mode & 0700) << 0, &str[1]); - rwx ((mode & 0070) << 3, &str[4]); - rwx ((mode & 0007) << 6, &str[7]); - setst (mode, str); -} - -/* Return a character indicating the type of file described by - file mode BITS: - 'd' for directories - 'b' for block special files - 'c' for character special files - 'm' for multiplexor files - 'l' for symbolic links - 's' for sockets - 'p' for fifos - '-' for any other file type. */ - -static char -ftypelet (bits) - unsigned short bits; -{ - switch (bits & S_IFMT) - { - default: - return '-'; - case S_IFDIR: - return 'd'; -#ifdef S_IFLNK - case S_IFLNK: - return 'l'; -#endif -#ifdef S_IFCHR - case S_IFCHR: - return 'c'; -#endif -#ifdef S_IFBLK - case S_IFBLK: - return 'b'; -#endif -#ifdef S_IFMPC - case S_IFMPC: - case S_IFMPB: - return 'm'; -#endif -#ifdef S_IFSOCK - case S_IFSOCK: - return 's'; -#endif -#ifdef S_IFIFO -#if S_IFIFO != S_IFSOCK - case S_IFIFO: - return 'p'; -#endif -#endif -#ifdef S_IFNWK /* HP-UX */ - case S_IFNWK: - return 'n'; -#endif - } -} - -/* Look at read, write, and execute bits in BITS and set - flags in CHARS accordingly. */ - -static void -rwx (bits, chars) - unsigned short bits; - char *chars; -{ - chars[0] = (bits & S_IREAD) ? 'r' : '-'; - chars[1] = (bits & S_IWRITE) ? 'w' : '-'; - chars[2] = (bits & S_IEXEC) ? 'x' : '-'; -} - -/* Set the 's' and 't' flags in file attributes string CHARS, - according to the file mode BITS. */ - -static void -setst (bits, chars) - unsigned short bits; - char *chars; -{ -#ifdef S_ISUID - if (bits & S_ISUID) - { - if (chars[3] != 'x') - /* Set-uid, but not executable by owner. */ - chars[3] = 'S'; - else - chars[3] = 's'; - } -#endif -#ifdef S_ISGID - if (bits & S_ISGID) - { - if (chars[6] != 'x') - /* Set-gid, but not executable by group. */ - chars[6] = 'S'; - else - chars[6] = 's'; - } -#endif -#ifdef S_ISVTX - if (bits & S_ISVTX) - { - if (chars[9] != 'x') - /* Sticky, but not executable by others. */ - chars[9] = 'T'; - else - chars[9] = 't'; - } -#endif -} - - diff --git a/binutils/gmalloc.c b/binutils/gmalloc.c deleted file mode 100644 index 046855170cc..00000000000 --- a/binutils/gmalloc.c +++ /dev/null @@ -1,1116 +0,0 @@ - -/* gmalloc.c - THIS FILE IS AUTOMAGICALLY GENERATED SO DON'T EDIT IT. */ - -/* Single-file skeleton for GNU malloc. - Copyright 1989 Free Software Foundation - Written May 1989 by Mike Haertel. - - 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - - The author may be reached (Email) at the address mike@ai.mit.edu, - or (US mail) as Mike Haertel c/o Free Software Foundation. */ - -#define __ONEFILE - -/* DO NOT DELETE THIS LINE -- ansidecl.h INSERTED HERE. */ -/* Copyright (C) 1989 Free Software Foundation, Inc. -This file is part of the GNU C Library. - -The GNU C Library 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 1, or (at your option) -any later version. - -The GNU C Library 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 the GNU C Library; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* ANSI and traditional C compatibility macros - - ANSI C is assumed if __STDC__ is #defined. - - Macros - PTR - Generic pointer type - LONG_DOUBLE - `long double' type - CONST - `const' keyword - VOLATILE - `volatile' keyword - SIGNED - `signed' keyword - PTRCONST - Generic const pointer (void *const) - - EXFUN(name, prototype) - declare external function NAME - with prototype PROTOTYPE - DEFUN(name, arglist, args) - define function NAME with - args ARGLIST of types in ARGS - DEFUN_VOID(name) - define function NAME with no args - AND - argument separator for ARGS - NOARGS - null arglist - DOTS - `...' in args - - For example: - extern int EXFUN(printf, (CONST char *format DOTS)); - int DEFUN(fprintf, (stream, format), - FILE *stream AND CONST char *format DOTS) { ... } - void DEFUN_VOID(abort) { ... } -*/ - -#ifndef _ANSIDECL_H - -#define _ANSIDECL_H 1 - - -/* Every source file includes this file, - so they will all get the switch for lint. */ -/* LINTLIBRARY */ - - -#ifdef __STDC__ - -#define PTR void * -#define PTRCONST void *CONST -#define LONG_DOUBLE long double - -#define AND , -#define NOARGS void -#define CONST const -#define VOLATILE volatile -#define SIGNED signed -#define DOTS , ... - -#define EXFUN(name, proto) name proto -#define DEFUN(name, arglist, args) name(args) -#define DEFUN_VOID(name) name(NOARGS) - -#else /* Not ANSI C. */ - -#define PTR char * -#define PTRCONST PTR -#define LONG_DOUBLE double - -#define AND ; -#define NOARGS -#define CONST -#define VOLATILE -#define SIGNED -#define DOTS - -#define EXFUN(name, proto) name() -#define DEFUN(name, arglist, args) name arglist args; -#define DEFUN_VOID(name) name() - -#endif /* ANSI C. */ - - -#endif /* ansidecl.h */ - -#ifdef __STDC__ -#include -#else -/* DO NOT DELETE THIS LINE -- limits.h INSERTED HERE. */ -/* Number of bits in a `char'. */ -#define CHAR_BIT 8 - -/* No multibyte characters supported yet. */ -#define MB_LEN_MAX 1 - -/* Minimum and maximum values a `signed char' can hold. */ -#define SCHAR_MIN -128 -#define SCHAR_MAX 127 - -/* Maximum value an `unsigned char' can hold. (Minimum is 0). */ -#define UCHAR_MAX 255U - -/* Minimum and maximum values a `char' can hold. */ -#ifdef __CHAR_UNSIGNED__ -#define CHAR_MIN 0 -#define CHAR_MAX 255U -#else -#define CHAR_MIN -128 -#define CHAR_MAX 127 -#endif - -/* Minimum and maximum values a `signed short int' can hold. */ -#define SHRT_MIN -32768 -#define SHRT_MAX 32767 - -/* Maximum value an `unsigned short int' can hold. (Minimum is 0). */ -#define USHRT_MAX 65535U - -/* Minimum and maximum values a `signed int' can hold. */ -#define INT_MIN -2147483648 -#define INT_MAX 2147483647 - -/* Maximum value an `unsigned int' can hold. (Minimum is 0). */ -#define UINT_MAX 4294967295U - -/* Minimum and maximum values a `signed long int' can hold. - (Same as `int'). */ -#define LONG_MIN (-LONG_MAX-1) -#define LONG_MAX 2147483647 - -/* Maximum value an `unsigned long int' can hold. (Minimum is 0). */ -#define ULONG_MAX 4294967295U -#endif - -#ifdef __STDC__ -#include -#else -/* DO NOT DELETE THIS LINE -- stddef.h INSERTED HERE. */ -#ifndef _STDDEF_H -#define _STDDEF_H - -/* Signed type of difference of two pointers. */ - -typedef long ptrdiff_t; - -/* Unsigned type of `sizeof' something. */ - -#ifndef _SIZE_T /* in case has defined it. */ -#define _SIZE_T -typedef unsigned long size_t; -#endif /* _SIZE_T */ - -/* A null pointer constant. */ - -#undef NULL /* in case has defined it. */ -#define NULL 0 - -/* Offset of member MEMBER in a struct of type TYPE. */ - -#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) - -#endif /* _STDDEF_H */ -#endif - -/* DO NOT DELETE THIS LINE -- stdlib.h INSERTED HERE. */ -/* Fake stdlib.h supplying the stuff needed by malloc. */ - -#ifndef __ONEFILE -#include -#endif - -extern void EXFUN(abort, (void)); -extern void EXFUN(free, (PTR)); -extern PTR EXFUN(malloc, (size_t)); -extern PTR EXFUN(realloc, (PTR, size_t)); - -/* DO NOT DELETE THIS LINE -- string.h INSERTED HERE. */ -/* Fake string.h supplying stuff used by malloc. */ -#ifndef __ONEFILE -#include -#endif - -extern PTR EXFUN(memcpy, (PTR, PTR, size_t)); -extern PTR EXFUN(memset, (PTR, int, size_t)); -#define memmove memcpy - -#define _MALLOC_INTERNAL -/* DO NOT DELETE THIS LINE -- malloc.h INSERTED HERE. */ -/* Declarations for `malloc' and friends. - Copyright 1990 Free Software Foundation - Written May 1989 by Mike Haertel. - - 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - - The author may be reached (Email) at the address mike@@ai.mit.edu, - or (US mail) as Mike Haertel c/o Free Software Foundation. */ - -#ifndef _MALLOC_H - -#define _MALLOC_H 1 - -#ifndef __ONEFILE -#define __need_NULL -#define __need_size_t -#define __need_ptrdiff_t -#include -#endif - -#ifdef _MALLOC_INTERNAL - -#ifndef __ONEFILE -#include -#endif - -/* The allocator divides the heap into blocks of fixed size; large - requests receive one or more whole blocks, and small requests - receive a fragment of a block. Fragment sizes are powers of two, - and all fragments of a block are the same size. When all the - fragments in a block have been freed, the block itself is freed. */ -#define INT_BIT (CHAR_BIT * sizeof(int)) -#define BLOCKLOG (INT_BIT > 16 ? 12 : 9) -#define BLOCKSIZE (1 << BLOCKLOG) -#define BLOCKIFY(SIZE) (((SIZE) + BLOCKSIZE - 1) / BLOCKSIZE) - -/* Determine the amount of memory spanned by the initial heap table - (not an absolute limit). */ -#define HEAP (INT_BIT > 16 ? 4194304 : 65536) - -/* Number of contiguous free blocks allowed to build up at the end of - memory before they will be returned to the system. */ -#define FINAL_FREE_BLOCKS 8 - -/* Where to start searching the free list when looking for new memory. - The two possible values are 0 and _heapindex. Starting at 0 seems - to reduce total memory usage, while starting at _heapindex seems to - run faster. */ -#define MALLOC_SEARCH_START _heapindex - -/* Data structure giving per-block information. */ -typedef union - { - /* Heap information for a busy block. */ - struct - { - /* Zero for a large block, or positive giving the - logarithm to the base two of the fragment size. */ - int type; - union - { - struct - { - size_t nfree; /* Free fragments in a fragmented block. */ - size_t first; /* First free fragment of the block. */ - } frag; - /* Size (in blocks) of a large cluster. */ - size_t size; - } info; - } busy; - /* Heap information for a free block (that may be the first of - a free cluster). */ - struct - { - size_t size; /* Size (in blocks) of a free cluster. */ - size_t next; /* Index of next free cluster. */ - size_t prev; /* Index of previous free cluster. */ - } free; - } malloc_info; - -/* Pointer to first block of the heap. */ -extern char *_heapbase; - -/* Table indexed by block number giving per-block information. */ -extern malloc_info *_heapinfo; - -/* Address to block number and vice versa. */ -#define BLOCK(A) (((char *) (A) - _heapbase) / BLOCKSIZE + 1) -#define ADDRESS(B) ((PTR) (((B) - 1) * BLOCKSIZE + _heapbase)) - -/* Current search index for the heap table. */ -extern size_t _heapindex; - -/* Limit of valid info table indices. */ -extern size_t _heaplimit; - -/* Doubly linked lists of free fragments. */ -struct list - { - struct list *next; - struct list *prev; - }; - -/* Free list headers for each fragment size. */ -extern struct list _fraghead[]; - -/* Instrumentation. */ -extern size_t _chunks_used; -extern size_t _bytes_used; -extern size_t _chunks_free; -extern size_t _bytes_free; - -/* Internal version of free() used in morecore(). */ -extern void EXFUN(__free, (PTR __ptr)); - -#endif /* _MALLOC_INTERNAL. */ - -/* Underlying allocation function; successive calls should - return contiguous pieces of memory. */ -extern PTR EXFUN((*__morecore), (ptrdiff_t __size)); - -/* Default value of previous. */ -extern PTR EXFUN(__default_morecore, (ptrdiff_t __size)); - -/* Flag whether malloc has been called. */ -extern int __malloc_initialized; - -/* Hooks for debugging versions. */ -extern void EXFUN((*__free_hook), (PTR __ptr)); -extern PTR EXFUN((*__malloc_hook), (size_t __size)); -extern PTR EXFUN((*__realloc_hook), (PTR __ptr, size_t __size)); - -/* Activate a standard collection of debugging hooks. */ -extern void EXFUN(mcheck, (void EXFUN((*func), (void)))); - -/* Statistics available to the user. */ -struct mstats - { - size_t bytes_total; /* Total size of the heap. */ - size_t chunks_used; /* Chunks allocated by the user. */ - size_t bytes_used; /* Byte total of user-allocated chunks. */ - size_t chunks_free; /* Chunks in the free list. */ - size_t bytes_free; /* Byte total of chunks in the free list. */ - }; - -/* Pick up the current statistics. */ -extern struct mstats EXFUN(mstats, (NOARGS)); - -#endif /* malloc.h */ - -/* DO NOT DELETE THIS LINE -- free.c INSERTED HERE. */ -/* Free a block of memory allocated by `malloc'. - Copyright 1990 Free Software Foundation - Written May 1989 by Mike Haertel. - - 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - - The author may be reached (Email) at the address mike@ai.mit.edu, - or (US mail) as Mike Haertel c/o Free Software Foundation. */ - -#ifndef __ONEFILE -#include "ansidecl.h" -#include -#include - -#define _MALLOC_INTERNAL -#include "malloc.h" -#endif /* __ONEFILE */ - -/* Debugging hook for free. */ -void EXFUN((*__free_hook), (PTR __ptr)); - -/* Return memory to the heap. Like free() but don't call a __free_hook - if there is one. */ -void -DEFUN(__free, (ptr), PTR ptr) -{ - int type; - size_t block, blocks; - register size_t i; - struct list *prev, *next; - - block = BLOCK(ptr); - - type = _heapinfo[block].busy.type; - switch (type) - { - case 0: - /* Get as many statistics as early as we can. */ - --_chunks_used; - _bytes_used -= _heapinfo[block].busy.info.size * BLOCKSIZE; - _bytes_free += _heapinfo[block].busy.info.size * BLOCKSIZE; - - /* Find the free cluster previous to this one in the free list. - Start searching at the last block referenced; this may benefit - programs with locality of allocation. */ - i = _heapindex; - if (i > block) - while (i > block) - i = _heapinfo[i].free.prev; - else - { - do - i = _heapinfo[i].free.next; - while (i > 0 && i < block); - i = _heapinfo[i].free.prev; - } - - /* Determine how to link this block into the free list. */ - if (block == i + _heapinfo[i].free.size) - { - /* Coalesce this block with its predecessor. */ - _heapinfo[i].free.size += _heapinfo[block].busy.info.size; - block = i; - } - else - { - /* Really link this block back into the free list. */ - _heapinfo[block].free.size = _heapinfo[block].busy.info.size; - _heapinfo[block].free.next = _heapinfo[i].free.next; - _heapinfo[block].free.prev = i; - _heapinfo[i].free.next = block; - _heapinfo[_heapinfo[block].free.next].free.prev = block; - ++_chunks_free; - } - - /* Now that the block is linked in, see if we can coalesce it - with its successor (by deleting its successor from the list - and adding in its size). */ - if (block + _heapinfo[block].free.size == _heapinfo[block].free.next) - { - _heapinfo[block].free.size - += _heapinfo[_heapinfo[block].free.next].free.size; - _heapinfo[block].free.next - = _heapinfo[_heapinfo[block].free.next].free.next; - _heapinfo[_heapinfo[block].free.next].free.prev = block; - --_chunks_free; - } - - /* Now see if we can return stuff to the system. */ - blocks = _heapinfo[block].free.size; - if (blocks >= FINAL_FREE_BLOCKS && block + blocks == _heaplimit - && (*__morecore)(0) == ADDRESS(block + blocks)) - { - register size_t bytes = blocks * BLOCKSIZE; - _heaplimit -= blocks; - (*__morecore)(- bytes); - _heapinfo[_heapinfo[block].free.prev].free.next - = _heapinfo[block].free.next; - _heapinfo[_heapinfo[block].free.next].free.prev - = _heapinfo[block].free.prev; - block = _heapinfo[block].free.prev; - --_chunks_free; - _bytes_free -= bytes; - } - - /* Set the next search to begin at this block. */ - _heapindex = block; - break; - - default: - /* Do some of the statistics. */ - --_chunks_used; - _bytes_used -= 1 << type; - ++_chunks_free; - _bytes_free += 1 << type; - - /* Get the address of the first free fragment in this block. */ - prev = (struct list *) ((char *) ADDRESS(block) + - (_heapinfo[block].busy.info.frag.first << type)); - - if (_heapinfo[block].busy.info.frag.nfree == (BLOCKSIZE >> type) - 1) - { - /* If all fragments of this block are free, remove them - from the fragment list and free the whole block. */ - next = prev; - for (i = 1; i < BLOCKSIZE >> type; ++i) - next = next->next; - prev->prev->next = next; - if (next != NULL) - next->prev = prev->prev; - _heapinfo[block].busy.type = 0; - _heapinfo[block].busy.info.size = 1; - - /* Keep the statistics accurate. */ - ++_chunks_used; - _bytes_used += BLOCKSIZE; - _chunks_free -= BLOCKSIZE >> type; - _bytes_free -= BLOCKSIZE; - - free(ADDRESS(block)); - } - else if (_heapinfo[block].busy.info.frag.nfree != 0) - { - /* If some fragments of this block are free, link this - fragment into the fragment list after the first free - fragment of this block. */ - next = (struct list *) ptr; - next->next = prev->next; - next->prev = prev; - prev->next = next; - if (next->next != NULL) - next->next->prev = next; - ++_heapinfo[block].busy.info.frag.nfree; - } - else - { - /* No fragments of this block are free, so link this - fragment into the fragment list and announce that - it is the first free fragment of this block. */ - prev = (struct list *) ptr; - _heapinfo[block].busy.info.frag.nfree = 1; - _heapinfo[block].busy.info.frag.first = (unsigned int) - (((char *) ptr - (char *) NULL) % BLOCKSIZE >> type); - prev->next = _fraghead[type].next; - prev->prev = &_fraghead[type]; - prev->prev->next = prev; - if (prev->next != NULL) - prev->next->prev = prev; - } - break; - } -} - -/* Return memory to the heap. */ -void -DEFUN(free, (ptr), PTR ptr) -{ - if (ptr == NULL) - return; - - if (__free_hook != NULL) - (*__free_hook)(ptr); - else - __free (ptr); -} - -/* DO NOT DELETE THIS LINE -- malloc.c INSERTED HERE. */ -/* Memory allocator `malloc'. - Copyright 1990 Free Software Foundation - Written May 1989 by Mike Haertel. - - 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - - The author may be reached (Email) at the address mike@ai.mit.edu, - or (US mail) as Mike Haertel c/o Free Software Foundation. */ - -#ifndef __ONEFILE -#include "ansidecl.h" -#include -#include -#include - -#define _MALLOC_INTERNAL -#include "malloc.h" -#endif /* __ONEFILE */ - -/* How to really get more memory. */ -PTR EXFUN((*__morecore), (ptrdiff_t __size)) = __default_morecore; - -/* Debugging hook for `malloc'. */ -PTR EXFUN((*__malloc_hook), (size_t __size)); - -/* Pointer to the base of the first block. */ -char *_heapbase; - -/* Block information table. Allocated with align/__free (not malloc/free). */ -malloc_info *_heapinfo; - -/* Number of info entries. */ -static size_t heapsize; - -/* Search index in the info table. */ -size_t _heapindex; - -/* Limit of valid info table indices. */ -size_t _heaplimit; - -/* Free lists for each fragment size. */ -struct list _fraghead[BLOCKLOG]; - -/* Instrumentation. */ -size_t _chunks_used; -size_t _bytes_used; -size_t _chunks_free; -size_t _bytes_free; - -/* Are you experienced? */ -int __malloc_initialized; - -/* Aligned allocation. */ -static PTR -DEFUN(align, (size), size_t size) -{ - PTR result; - unsigned int adj; - - result = (*__morecore)(size); - adj = (unsigned int) ((char *) result - (char *) NULL) % BLOCKSIZE; - if (adj != 0) - { - adj = BLOCKSIZE - adj; - (void) (*__morecore)(adj); - result = (char *) result + adj; - } - return result; -} - -/* Set everything up and remember that we have. */ -static int -DEFUN_VOID(initialize) -{ - heapsize = HEAP / BLOCKSIZE; - _heapinfo = (malloc_info *) align(heapsize * sizeof(malloc_info)); - if (_heapinfo == NULL) - return 0; - memset(_heapinfo, 0, heapsize * sizeof(malloc_info)); - _heapinfo[0].free.size = 0; - _heapinfo[0].free.next = _heapinfo[0].free.prev = 0; - _heapindex = 0; - _heapbase = (char *) _heapinfo; - __malloc_initialized = 1; - return 1; -} - -/* Get neatly aligned memory, initializing or - growing the heap info table as necessary. */ -static PTR -DEFUN(morecore, (size), size_t size) -{ - PTR result; - malloc_info *newinfo, *oldinfo; - size_t newsize; - - result = align(size); - if (result == NULL) - return NULL; - - /* Check if we need to grow the info table. */ - if (BLOCK((char *) result + size) > heapsize) - { - newsize = heapsize; - while (BLOCK((char *) result + size) > newsize) - newsize *= 2; - newinfo = (malloc_info *) align(newsize * sizeof(malloc_info)); - if (newinfo == NULL) - { - (*__morecore)(- size); - return NULL; - } - memset(newinfo, 0, newsize * sizeof(malloc_info)); - memcpy(newinfo, _heapinfo, heapsize * sizeof(malloc_info)); - oldinfo = _heapinfo; - newinfo[BLOCK(oldinfo)].busy.type = 0; - newinfo[BLOCK(oldinfo)].busy.info.size - = BLOCKIFY(heapsize * sizeof(malloc_info)); - _heapinfo = newinfo; - __free(oldinfo); - heapsize = newsize; - } - - _heaplimit = BLOCK((char *) result + size); - return result; -} - -/* Allocate memory from the heap. */ -PTR -DEFUN(malloc, (size), size_t size) -{ - PTR result; - size_t block, blocks, lastblocks, start; - register size_t i; - struct list *next; - - if (size == 0) - return NULL; - - if (__malloc_hook != NULL) - return (*__malloc_hook)(size); - - if (!__malloc_initialized) - if (!initialize()) - return NULL; - - if (size < sizeof(struct list)) - size = sizeof(struct list); - - /* Determine the allocation policy based on the request size. */ - if (size <= BLOCKSIZE / 2) - { - /* Small allocation to receive a fragment of a block. - Determine the logarithm to base two of the fragment size. */ - register size_t log = 1; - --size; - while ((size /= 2) != 0) - ++log; - - /* Look in the fragment lists for a - free fragment of the desired size. */ - next = _fraghead[log].next; - if (next != NULL) - { - /* There are free fragments of this size. - Pop a fragment out of the fragment list and return it. - Update the block's nfree and first counters. */ - result = (PTR) next; - next->prev->next = next->next; - if (next->next != NULL) - next->next->prev = next->prev; - block = BLOCK(result); - if (--_heapinfo[block].busy.info.frag.nfree != 0) - _heapinfo[block].busy.info.frag.first = (unsigned int) - (((char *) next->next - (char *) NULL) % BLOCKSIZE) >> log; - - /* Update the statistics. */ - ++_chunks_used; - _bytes_used += 1 << log; - --_chunks_free; - _bytes_free -= 1 << log; - } - else - { - /* No free fragments of the desired size, so get a new block - and break it into fragments, returning the first. */ - result = malloc(BLOCKSIZE); - if (result == NULL) - return NULL; - - /* Link all fragments but the first into the free list. */ - for (i = 1; i < BLOCKSIZE >> log; ++i) - { - next = (struct list *) ((char *) result + (i << log)); - next->next = _fraghead[log].next; - next->prev = &_fraghead[log]; - next->prev->next = next; - if (next->next != NULL) - next->next->prev = next; - } - - /* Initialize the nfree and first counters for this block. */ - block = BLOCK(result); - _heapinfo[block].busy.type = log; - _heapinfo[block].busy.info.frag.nfree = i - 1; - _heapinfo[block].busy.info.frag.first = i - 1; - - _chunks_free += (BLOCKSIZE >> log) - 1; - _bytes_free += BLOCKSIZE - (1 << log); - } - } - else - { - /* Large allocation to receive one or more blocks. - Search the free list in a circle starting at the last place visited. - If we loop completely around without finding a large enough - space we will have to get more memory from the system. */ - blocks = BLOCKIFY(size); - start = block = MALLOC_SEARCH_START; - while (_heapinfo[block].free.size < blocks) - { - block = _heapinfo[block].free.next; - if (block == start) - { - /* Need to get more from the system. Check to see if - the new core will be contiguous with the final free - block; if so we don't need to get as much. */ - block = _heapinfo[0].free.prev; - lastblocks = _heapinfo[block].free.size; - if (_heaplimit != 0 && block + lastblocks == _heaplimit && - (*__morecore)(0) == ADDRESS(block + lastblocks) && - (morecore((blocks - lastblocks) * BLOCKSIZE)) != NULL) - { - _heapinfo[block].free.size = blocks; - _bytes_free += (blocks - lastblocks) * BLOCKSIZE; - continue; - } - result = morecore(blocks * BLOCKSIZE); - if (result == NULL) - return NULL; - block = BLOCK(result); - _heapinfo[block].busy.type = 0; - _heapinfo[block].busy.info.size = blocks; - ++_chunks_used; - _bytes_used += blocks * BLOCKSIZE; - return result; - } - } - - /* At this point we have found a suitable free list entry. - Figure out how to remove what we need from the list. */ - result = ADDRESS(block); - if (_heapinfo[block].free.size > blocks) - { - /* The block we found has a bit left over, - so relink the tail end back into the free list. */ - _heapinfo[block + blocks].free.size - = _heapinfo[block].free.size - blocks; - _heapinfo[block + blocks].free.next - = _heapinfo[block].free.next; - _heapinfo[block + blocks].free.prev - = _heapinfo[block].free.prev; - _heapinfo[_heapinfo[block].free.prev].free.next - = _heapinfo[_heapinfo[block].free.next].free.prev - = _heapindex = block + blocks; - } - else - { - /* The block exactly matches our requirements, - so just remove it from the list. */ - _heapinfo[_heapinfo[block].free.next].free.prev - = _heapinfo[block].free.prev; - _heapinfo[_heapinfo[block].free.prev].free.next - = _heapindex = _heapinfo[block].free.next; - --_chunks_free; - } - - _heapinfo[block].busy.type = 0; - _heapinfo[block].busy.info.size = blocks; - ++_chunks_used; - _bytes_used += blocks * BLOCKSIZE; - _bytes_free -= blocks * BLOCKSIZE; - } - - return result; -} - -/* DO NOT DELETE THIS LINE -- realloc.c INSERTED HERE. */ -/* Change the size of a block allocated by `malloc'. - Copyright 1990 Free Software Foundation - Written May 1989 by Mike Haertel. - - 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - - The author may be reached (Email) at the address mike@ai.mit.edu, - or (US mail) as Mike Haertel c/o Free Software Foundation. */ - -#ifndef __ONEFILE -#include "ansidecl.h" -#include -#include - -#define _MALLOC_INTERNAL -#include "malloc.h" -#endif /* __ONEFILE */ - -#define MIN(A, B) ((A) < (B) ? (A) : (B)) - -/* Debugging hook for realloc. */ -PTR EXFUN((*__realloc_hook), (PTR __ptr, size_t __size)); - -/* Resize the given region to the new size, returning a pointer - to the (possibly moved) region. This is optimized for speed; - some benchmarks seem to indicate that greater compactness is - achieved by unconditionally allocating and copying to a - new region. This module has incestuous knowledge of the - internals of both free and malloc. */ -PTR -DEFUN(realloc, (ptr, size), PTR ptr AND size_t size) -{ - PTR result; - int type; - size_t block, blocks, oldlimit; - - if (size == 0) - { - free(ptr); - return NULL; - } - else if (ptr == NULL) - return malloc(size); - - if (__realloc_hook != NULL) - return (*__realloc_hook)(ptr, size); - - block = BLOCK(ptr); - - type = _heapinfo[block].busy.type; - switch (type) - { - case 0: - /* Maybe reallocate a large block to a small fragment. */ - if (size <= BLOCKSIZE / 2) - { - result = malloc(size); - if (result != NULL) - { - memcpy(result, ptr, size); - free(ptr); - return result; - } - } - - /* The new size is a large allocation as well; - see if we can hold it in place. */ - blocks = BLOCKIFY(size); - if (blocks < _heapinfo[block].busy.info.size) - { - /* The new size is smaller; return - excess memory to the free list. */ - _heapinfo[block + blocks].busy.type = 0; - _heapinfo[block + blocks].busy.info.size - = _heapinfo[block].busy.info.size - blocks; - _heapinfo[block].busy.info.size = blocks; - free(ADDRESS(block + blocks)); - result = ptr; - } - else if (blocks == _heapinfo[block].busy.info.size) - /* No size change necessary. */ - result = ptr; - else - { - /* Won't fit, so allocate a new region that will. - Free the old region first in case there is sufficient - adjacent free space to grow without moving. */ - blocks = _heapinfo[block].busy.info.size; - /* Prevent free from actually returning memory to the system. */ - oldlimit = _heaplimit; - _heaplimit = 0; - free(ptr); - _heaplimit = oldlimit; - result = malloc(size); - if (result == NULL) - { - (void) malloc(blocks * BLOCKSIZE); - return NULL; - } - if (ptr != result) - memmove(result, ptr, blocks * BLOCKSIZE); - } - break; - - default: - /* Old size is a fragment; type is logarithm - to base two of the fragment size. */ - if (size > 1 << (type - 1) && size <= 1 << type) - /* The new size is the same kind of fragment. */ - result = ptr; - else - { - /* The new size is different; allocate a new space, - and copy the lesser of the new size and the old. */ - result = malloc(size); - if (result == NULL) - return NULL; - memcpy(result, ptr, MIN(size, 1 << type)); - free(ptr); - } - break; - } - - return result; -} - -/* DO NOT DELETE THIS LINE -- unix.c INSERTED HERE. */ -/* unix.c - get more memory with a UNIX system call. - Copyright 1990 Free Software Foundation - Written May 1989 by Mike Haertel. - - 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - - The author may be reached (Email) at the address mike@ai.mit.edu, - or (US mail) as Mike Haertel c/o Free Software Foundation. */ - -#ifndef __ONEFILE -#include "ansidecl.h" -#include - -#define _MALLOC_INTERNAL -#include "malloc.h" -#endif /* __ONEFILE */ - -extern PTR EXFUN(sbrk, (ptrdiff_t size)); - -PTR -DEFUN(__default_morecore, (size), ptrdiff_t size) -{ - PTR result; - - result = sbrk(size); - if (result == (PTR) -1) - return NULL; - return result; -} - -#define __getpagesize getpagesize -/* DO NOT DELETE THIS LINE -- valloc.c INSERTED HERE. */ -/* Allocate memory on a page boundary. - Copyright 1990 Free Software Foundation - Written May 1989 by Mike Haertel. - - 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - - The author may be reached (Email) at the address mike@ai.mit.edu, - or (US mail) as Mike Haertel c/o Free Software Foundation. */ - -#ifndef __ONEFILE -#include "ansidecl.h" -#include -#endif /* __ONEFILE */ - -extern size_t EXFUN(__getpagesize, (NOARGS)); - -static size_t pagesize; - -PTR -DEFUN(valloc, (size), size_t size) -{ - PTR result; - unsigned int adj; - - if (pagesize == 0) - pagesize = __getpagesize(); - - result = malloc(size + pagesize); - if (result == NULL) - return NULL; - adj = (unsigned int) ((char *) result - (char *) NULL) % pagesize; - if (adj != 0) - result = (char *) result + pagesize - adj; - return result; -} diff --git a/binutils/i960-pinsn.c b/binutils/i960-pinsn.c deleted file mode 100644 index 4894c06747a..00000000000 --- a/binutils/i960-pinsn.c +++ /dev/null @@ -1,816 +0,0 @@ -/* Disassemble i80960 instructions. - Copyright (C) 1990, 1991 Free Software Foundation, Inc. - -This file is part of BFD, the Binary File Diddler. - -BFD 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. - -BFD 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 BFD; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* $Id$ */ - -#include "bfd.h" -#include "sysdep.h" - -extern char *xmalloc(); -extern int fputs(); - -static char *reg_names[] = { -/* 0 */ "pfp", "sp", "rip", "r3", "r4", "r5", "r6", "r7", -/* 8 */ "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", -/* 16 */ "g0", "g1", "g2", "g3", "g4", "g5", "g6", "g7", -/* 24 */ "g8", "g9", "g10", "g11", "g12", "g13", "g14", "fp", -/* 32 */ "pc", "ac", "ip", "tc", "fp0", "fp1", "fp2", "fp3" -}; - - -static FILE *stream; /* Output goes here */ -static void print_addr(); -static void ctrl(); -static void cobr(); -static void reg(); -static int mem(); -static void ea(); -static void dstop(); -static void regop(); -static void invalid(); -static int pinsn(); -static void put_abs(); - - -/* Print the i960 instruction at address 'memaddr' in debugged memory, - * on stream 's'. Returns length of the instruction, in bytes. - */ -int -print_insn_i960( memaddr, buffer, s ) - bfd_vma memaddr; - uint8e_type *buffer; - FILE *s; -{ - unsigned int word1, word2; - - stream = s; - word1 =buffer [0] |( buffer[1]<< 8) | (buffer[2] << 16) | ( buffer[3] <<24); - word2 =buffer [4] |( buffer[5]<< 8) | (buffer[6] << 16) | ( buffer[7] <<24); - return pinsn( memaddr, word1, word2 ); -} - -#define IN_GDB - -/***************************************************************************** - * All code below this point should be identical with that of - * the disassembler in gdmp960. - *****************************************************************************/ - -struct tabent { - char *name; - char numops; -}; - -static int -pinsn( memaddr, word1, word2 ) - unsigned long memaddr; - unsigned long word1, word2; -{ - int instr_len; - - instr_len = 4; - put_abs( word1, word2 ); - - /* Divide instruction set into classes based on high 4 bits of opcode*/ - switch ( (word1 >> 28) & 0xf ){ - case 0x0: - case 0x1: - ctrl( memaddr, word1, word2 ); - break; - case 0x2: - case 0x3: - cobr( memaddr, word1, word2 ); - break; - case 0x5: - case 0x6: - case 0x7: - reg( word1 ); - break; - case 0x8: - case 0x9: - case 0xa: - case 0xb: - case 0xc: - instr_len = mem( memaddr, word1, word2, 0 ); - break; - default: - /* invalid instruction, print as data word */ - invalid( word1 ); - break; - } - return instr_len; -} - -/****************************************/ -/* CTRL format */ -/****************************************/ -static void -ctrl( memaddr, word1, word2 ) - unsigned long memaddr; - unsigned long word1, word2; -{ - int i; - static struct tabent ctrl_tab[] = { - NULL, 0, /* 0x00 */ - NULL, 0, /* 0x01 */ - NULL, 0, /* 0x02 */ - NULL, 0, /* 0x03 */ - NULL, 0, /* 0x04 */ - NULL, 0, /* 0x05 */ - NULL, 0, /* 0x06 */ - NULL, 0, /* 0x07 */ - "b", 1, /* 0x08 */ - "call", 1, /* 0x09 */ - "ret", 0, /* 0x0a */ - "bal", 1, /* 0x0b */ - NULL, 0, /* 0x0c */ - NULL, 0, /* 0x0d */ - NULL, 0, /* 0x0e */ - NULL, 0, /* 0x0f */ - "bno", 1, /* 0x10 */ - "bg", 1, /* 0x11 */ - "be", 1, /* 0x12 */ - "bge", 1, /* 0x13 */ - "bl", 1, /* 0x14 */ - "bne", 1, /* 0x15 */ - "ble", 1, /* 0x16 */ - "bo", 1, /* 0x17 */ - "faultno", 0, /* 0x18 */ - "faultg", 0, /* 0x19 */ - "faulte", 0, /* 0x1a */ - "faultge", 0, /* 0x1b */ - "faultl", 0, /* 0x1c */ - "faultne", 0, /* 0x1d */ - "faultle", 0, /* 0x1e */ - "faulto", 0, /* 0x1f */ - }; - - i = (word1 >> 24) & 0xff; - if ( (ctrl_tab[i].name == NULL) || ((word1 & 1) != 0) ){ - invalid( word1 ); - return; - } - - fputs( ctrl_tab[i].name, stream ); - if ( word1 & 2 ){ /* Predicts branch not taken */ - fputs( ".f", stream ); - } - - if ( ctrl_tab[i].numops == 1 ){ - /* EXTRACT DISPLACEMENT AND CONVERT TO ADDRESS */ - word1 &= 0x00ffffff; - if ( word1 & 0x00800000 ){ /* Sign bit is set */ - word1 |= (-1 & ~0xffffff); /* Sign extend */ - } - putc( '\t', stream ); - print_addr( word1 + memaddr ); - } -} - -/****************************************/ -/* COBR format */ -/****************************************/ -static void -cobr( memaddr, word1, word2 ) - unsigned long memaddr; - unsigned long word1, word2; -{ - int src1; - int src2; - int i; - - static struct tabent cobr_tab[] = { - "testno", 1, /* 0x20 */ - "testg", 1, /* 0x21 */ - "teste", 1, /* 0x22 */ - "testge", 1, /* 0x23 */ - "testl", 1, /* 0x24 */ - "testne", 1, /* 0x25 */ - "testle", 1, /* 0x26 */ - "testo", 1, /* 0x27 */ - NULL, 0, /* 0x28 */ - NULL, 0, /* 0x29 */ - NULL, 0, /* 0x2a */ - NULL, 0, /* 0x2b */ - NULL, 0, /* 0x2c */ - NULL, 0, /* 0x2d */ - NULL, 0, /* 0x2e */ - NULL, 0, /* 0x2f */ - "bbc", 3, /* 0x30 */ - "cmpobg", 3, /* 0x31 */ - "cmpobe", 3, /* 0x32 */ - "cmpobge", 3, /* 0x33 */ - "cmpobl", 3, /* 0x34 */ - "cmpobne", 3, /* 0x35 */ - "cmpoble", 3, /* 0x36 */ - "bbs", 3, /* 0x37 */ - "cmpibno", 3, /* 0x38 */ - "cmpibg", 3, /* 0x39 */ - "cmpibe", 3, /* 0x3a */ - "cmpibge", 3, /* 0x3b */ - "cmpibl", 3, /* 0x3c */ - "cmpibne", 3, /* 0x3d */ - "cmpible", 3, /* 0x3e */ - "cmpibo", 3, /* 0x3f */ - }; - - i = ((word1 >> 24) & 0xff) - 0x20; - if ( cobr_tab[i].name == NULL ){ - invalid( word1 ); - return; - } - - fputs( cobr_tab[i].name, stream ); - if ( word1 & 2 ){ /* Predicts branch not taken */ - fputs( ".f", stream ); - } - putc( '\t', stream ); - - src1 = (word1 >> 19) & 0x1f; - src2 = (word1 >> 14) & 0x1f; - - if ( word1 & 0x02000 ){ /* M1 is 1 */ - fprintf( stream, "%d", src1 ); - } else { /* M1 is 0 */ - fputs( reg_names[src1], stream ); - } - - if ( cobr_tab[i].numops > 1 ){ - if ( word1 & 1 ){ /* S2 is 1 */ - fprintf( stream, ",sf%d,", src2 ); - } else { /* S1 is 0 */ - fprintf( stream, ",%s,", reg_names[src2] ); - } - - /* Extract displacement and convert to address - */ - word1 &= 0x00001ffc; - if ( word1 & 0x00001000 ){ /* Negative displacement */ - word1 |= (-1 & ~0x1fff); /* Sign extend */ - } - print_addr( memaddr + word1 ); - } -} - -/****************************************/ -/* MEM format */ -/****************************************/ -static int /* returns instruction length: 4 or 8 */ -mem( memaddr, word1, word2, noprint ) - unsigned long memaddr; - unsigned long word1, word2; - int noprint; /* If TRUE, return instruction length, but - * don't output any text. - */ -{ - int i, j; - int len; - int mode; - int offset; - char *reg1, *reg2, *reg3; - - /* This lookup table is too sparse to make it worth typing in, but not - * so large as to make a sparse array necessary. We allocate the - * table at runtime, initialize all entries to empty, and copy the - * real ones in from an initialization table. - * - * NOTE: In this table, the meaning of 'numops' is: - * 1: single operand - * 2: 2 operands, load instruction - * -2: 2 operands, store instruction - */ - static struct tabent *mem_tab = NULL; - static struct { int opcode; char *name; char numops; } mem_init[] = { -#define MEM_MIN 0x80 - 0x80, "ldob", 2, - 0x82, "stob", -2, - 0x84, "bx", 1, - 0x85, "balx", 2, - 0x86, "callx", 1, - 0x88, "ldos", 2, - 0x8a, "stos", -2, - 0x8c, "lda", 2, - 0x90, "ld", 2, - 0x92, "st", -2, - 0x98, "ldl", 2, - 0x9a, "stl", -2, - 0xa0, "ldt", 2, - 0xa2, "stt", -2, - 0xb0, "ldq", 2, - 0xb2, "stq", -2, - 0xc0, "ldib", 2, - 0xc2, "stib", -2, - 0xc8, "ldis", 2, - 0xca, "stis", -2, -#define MEM_MAX 0xca -#define MEM_SIZ ((MEM_MAX-MEM_MIN+1) * sizeof(struct tabent)) - 0, NULL, 0 - }; - - if ( mem_tab == NULL ){ - mem_tab = (struct tabent *) xmalloc( MEM_SIZ ); - bzero( (void *) mem_tab, MEM_SIZ ); - for ( i = 0; mem_init[i].opcode != 0; i++ ){ - j = mem_init[i].opcode - MEM_MIN; - mem_tab[j].name = mem_init[i].name; - mem_tab[j].numops = mem_init[i].numops; - } - } - - i = ((word1 >> 24) & 0xff) - MEM_MIN; - mode = (word1 >> 10) & 0xf; - - if ( (mem_tab[i].name != NULL) /* Valid instruction */ - && ((mode == 5) || (mode >=12)) ){ /* With 32-bit displacement */ - len = 8; - } else { - len = 4; - } - - if ( noprint ){ - return len; - } - - if ( (mem_tab[i].name == NULL) || (mode == 6) ){ - invalid( word1 ); - return len; - } - - fprintf( stream, "%s\t", mem_tab[i].name ); - - reg1 = reg_names[ (word1 >> 19) & 0x1f ]; /* MEMB only */ - reg2 = reg_names[ (word1 >> 14) & 0x1f ]; - reg3 = reg_names[ word1 & 0x1f ]; /* MEMB only */ - offset = word1 & 0xfff; /* MEMA only */ - - switch ( mem_tab[i].numops ){ - - case 2: /* LOAD INSTRUCTION */ - if ( mode & 4 ){ /* MEMB FORMAT */ - ea( memaddr, mode, reg2, reg3, word1, word2 ); - fprintf( stream, ",%s", reg1 ); - } else { /* MEMA FORMAT */ - fprintf( stream, "0x%x", (unsigned) offset ); - if (mode & 8) { - fprintf( stream, "(%s)", reg2 ); - } - fprintf( stream, ",%s", reg1 ); - } - break; - - case -2: /* STORE INSTRUCTION */ - if ( mode & 4 ){ /* MEMB FORMAT */ - fprintf( stream, "%s,", reg1 ); - ea( memaddr, mode, reg2, reg3, word1, word2 ); - } else { /* MEMA FORMAT */ - fprintf( stream, "%s,0x%x", reg1, (unsigned) offset ); - if (mode & 8) { - fprintf( stream, "(%s)", reg2 ); - } - } - break; - - case 1: /* BX/CALLX INSTRUCTION */ - if ( mode & 4 ){ /* MEMB FORMAT */ - ea( memaddr, mode, reg2, reg3, word1, word2 ); - } else { /* MEMA FORMAT */ - fprintf( stream, "0x%x", (unsigned) offset ); - if (mode & 8) { - fprintf( stream, "(%s)", reg2 ); - } - } - break; - } - - return len; -} - -/****************************************/ -/* REG format */ -/****************************************/ -static void -reg( word1 ) - unsigned long word1; -{ - int i, j; - int opcode; - int fp; - int m1, m2, m3; - int s1, s2; - int src, src2, dst; - char *mnemp; - - /* This lookup table is too sparse to make it worth typing in, but not - * so large as to make a sparse array necessary. We allocate the - * table at runtime, initialize all entries to empty, and copy the - * real ones in from an initialization table. - * - * NOTE: In this table, the meaning of 'numops' is: - * 1: single operand, which is NOT a destination. - * -1: single operand, which IS a destination. - * 2: 2 operands, the 2nd of which is NOT a destination. - * -2: 2 operands, the 2nd of which IS a destination. - * 3: 3 operands - * - * If an opcode mnemonic begins with "F", it is a floating-point - * opcode (the "F" is not printed). - */ - - static struct tabent *reg_tab = NULL; - static struct { int opcode; char *name; char numops; } reg_init[] = { -#define REG_MIN 0x580 - 0x580, "notbit", 3, - 0x581, "and", 3, - 0x582, "andnot", 3, - 0x583, "setbit", 3, - 0x584, "notand", 3, - 0x586, "xor", 3, - 0x587, "or", 3, - 0x588, "nor", 3, - 0x589, "xnor", 3, - 0x58a, "not", -2, - 0x58b, "ornot", 3, - 0x58c, "clrbit", 3, - 0x58d, "notor", 3, - 0x58e, "nand", 3, - 0x58f, "alterbit", 3, - 0x590, "addo", 3, - 0x591, "addi", 3, - 0x592, "subo", 3, - 0x593, "subi", 3, - 0x598, "shro", 3, - 0x59a, "shrdi", 3, - 0x59b, "shri", 3, - 0x59c, "shlo", 3, - 0x59d, "rotate", 3, - 0x59e, "shli", 3, - 0x5a0, "cmpo", 2, - 0x5a1, "cmpi", 2, - 0x5a2, "concmpo", 2, - 0x5a3, "concmpi", 2, - 0x5a4, "cmpinco", 3, - 0x5a5, "cmpinci", 3, - 0x5a6, "cmpdeco", 3, - 0x5a7, "cmpdeci", 3, - 0x5ac, "scanbyte", 2, - 0x5ae, "chkbit", 2, - 0x5b0, "addc", 3, - 0x5b2, "subc", 3, - 0x5cc, "mov", -2, - 0x5d8, "eshro", 3, - 0x5dc, "movl", -2, - 0x5ec, "movt", -2, - 0x5fc, "movq", -2, - 0x600, "synmov", 2, - 0x601, "synmovl", 2, - 0x602, "synmovq", 2, - 0x603, "cmpstr", 3, - 0x604, "movqstr", 3, - 0x605, "movstr", 3, - 0x610, "atmod", 3, - 0x612, "atadd", 3, - 0x613, "inspacc", -2, - 0x614, "ldphy", -2, - 0x615, "synld", -2, - 0x617, "fill", 3, - 0x630, "sdma", 3, - 0x631, "udma", 0, - 0x640, "spanbit", -2, - 0x641, "scanbit", -2, - 0x642, "daddc", 3, - 0x643, "dsubc", 3, - 0x644, "dmovt", -2, - 0x645, "modac", 3, - 0x646, "condrec", -2, - 0x650, "modify", 3, - 0x651, "extract", 3, - 0x654, "modtc", 3, - 0x655, "modpc", 3, - 0x656, "receive", -2, - 0x659, "sysctl", 3, - 0x660, "calls", 1, - 0x662, "send", 3, - 0x663, "sendserv", 1, - 0x664, "resumprcs", 1, - 0x665, "schedprcs", 1, - 0x666, "saveprcs", 0, - 0x668, "condwait", 1, - 0x669, "wait", 1, - 0x66a, "signal", 1, - 0x66b, "mark", 0, - 0x66c, "fmark", 0, - 0x66d, "flushreg", 0, - 0x66f, "syncf", 0, - 0x670, "emul", 3, - 0x671, "ediv", 3, - 0x673, "ldtime", -1, - 0x674, "Fcvtir", -2, - 0x675, "Fcvtilr", -2, - 0x676, "Fscalerl", 3, - 0x677, "Fscaler", 3, - 0x680, "Fatanr", 3, - 0x681, "Flogepr", 3, - 0x682, "Flogr", 3, - 0x683, "Fremr", 3, - 0x684, "Fcmpor", 2, - 0x685, "Fcmpr", 2, - 0x688, "Fsqrtr", -2, - 0x689, "Fexpr", -2, - 0x68a, "Flogbnr", -2, - 0x68b, "Froundr", -2, - 0x68c, "Fsinr", -2, - 0x68d, "Fcosr", -2, - 0x68e, "Ftanr", -2, - 0x68f, "Fclassr", 1, - 0x690, "Fatanrl", 3, - 0x691, "Flogeprl", 3, - 0x692, "Flogrl", 3, - 0x693, "Fremrl", 3, - 0x694, "Fcmporl", 2, - 0x695, "Fcmprl", 2, - 0x698, "Fsqrtrl", -2, - 0x699, "Fexprl", -2, - 0x69a, "Flogbnrl", -2, - 0x69b, "Froundrl", -2, - 0x69c, "Fsinrl", -2, - 0x69d, "Fcosrl", -2, - 0x69e, "Ftanrl", -2, - 0x69f, "Fclassrl", 1, - 0x6c0, "Fcvtri", -2, - 0x6c1, "Fcvtril", -2, - 0x6c2, "Fcvtzri", -2, - 0x6c3, "Fcvtzril", -2, - 0x6c9, "Fmovr", -2, - 0x6d9, "Fmovrl", -2, - 0x6e1, "Fmovre", -2, - 0x6e2, "Fcpysre", 3, - 0x6e3, "Fcpyrsre", 3, - 0x701, "mulo", 3, - 0x708, "remo", 3, - 0x70b, "divo", 3, - 0x741, "muli", 3, - 0x748, "remi", 3, - 0x749, "modi", 3, - 0x74b, "divi", 3, - 0x78b, "Fdivr", 3, - 0x78c, "Fmulr", 3, - 0x78d, "Fsubr", 3, - 0x78f, "Faddr", 3, - 0x79b, "Fdivrl", 3, - 0x79c, "Fmulrl", 3, - 0x79d, "Fsubrl", 3, - 0x79f, "Faddrl", 3, -#define REG_MAX 0x79f -#define REG_SIZ ((REG_MAX-REG_MIN+1) * sizeof(struct tabent)) - 0, NULL, 0 - }; - - if ( reg_tab == NULL ){ - reg_tab = (struct tabent *) xmalloc( REG_SIZ ); - bzero( (void *) reg_tab, REG_SIZ ); - for ( i = 0; reg_init[i].opcode != 0; i++ ){ - j = reg_init[i].opcode - REG_MIN; - reg_tab[j].name = reg_init[i].name; - reg_tab[j].numops = reg_init[i].numops; - } - } - - opcode = ((word1 >> 20) & 0xff0) | ((word1 >> 7) & 0xf); - i = opcode - REG_MIN; - - if ( (opcodeREG_MAX) || (reg_tab[i].name==NULL) ){ - invalid( word1 ); - return; - } - - mnemp = reg_tab[i].name; - if ( *mnemp == 'F' ){ - fp = 1; - mnemp++; - } else { - fp = 0; - } - - fputs( mnemp, stream ); - - s1 = (word1 >> 5) & 1; - s2 = (word1 >> 6) & 1; - m1 = (word1 >> 11) & 1; - m2 = (word1 >> 12) & 1; - m3 = (word1 >> 13) & 1; - src = word1 & 0x1f; - src2 = (word1 >> 14) & 0x1f; - dst = (word1 >> 19) & 0x1f; - - if ( reg_tab[i].numops != 0 ){ - putc( '\t', stream ); - - switch ( reg_tab[i].numops ){ - case 1: - regop( m1, s1, src, fp ); - break; - case -1: - dstop( m3, dst, fp ); - break; - case 2: - regop( m1, s1, src, fp ); - putc( ',', stream ); - regop( m2, s2, src2, fp ); - break; - case -2: - regop( m1, s1, src, fp ); - putc( ',', stream ); - dstop( m3, dst, fp ); - break; - case 3: - regop( m1, s1, src, fp ); - putc( ',', stream ); - regop( m2, s2, src2, fp ); - putc( ',', stream ); - dstop( m3, dst, fp ); - break; - } - } -} - - -/* - * Print out effective address for memb instructions. - */ -static void -ea( memaddr, mode, reg2, reg3, word1, word2 ) - unsigned long memaddr; - int mode; - char *reg2, *reg3; -int word1; - unsigned int word2; -{ - int scale; - static int scale_tab[] = { 1, 2, 4, 8, 16 }; - - scale = (word1 >> 7) & 0x07; - if ( (scale > 4) || ((word1 >> 5) & 0x03 != 0) ){ - invalid( word1 ); - return; - } - scale = scale_tab[scale]; - - switch (mode) { - case 4: /* (reg) */ - fprintf( stream, "(%s)", reg2 ); - break; - case 5: /* displ+8(ip) */ - print_addr( word2+8+memaddr ); - break; - case 7: /* (reg)[index*scale] */ - if (scale == 1) { - fprintf( stream, "(%s)[%s]", reg2, reg3 ); - } else { - fprintf( stream, "(%s)[%s*%d]",reg2,reg3,scale); - } - break; - case 12: /* displacement */ - print_addr( word2 ); - break; - case 13: /* displ(reg) */ - print_addr( word2 ); - fprintf( stream, "(%s)", reg2 ); - break; - case 14: /* displ[index*scale] */ - print_addr( word2 ); - if (scale == 1) { - fprintf( stream, "[%s]", reg3 ); - } else { - fprintf( stream, "[%s*%d]", reg3, scale ); - } - break; - case 15: /* displ(reg)[index*scale] */ - print_addr( word2 ); - if (scale == 1) { - fprintf( stream, "(%s)[%s]", reg2, reg3 ); - } else { - fprintf( stream, "(%s)[%s*%d]",reg2,reg3,scale ); - } - break; - default: - invalid( word1 ); - return; - } -} - - -/************************************************/ -/* Register Instruction Operand */ -/************************************************/ -static void -regop( mode, spec, reg, fp ) - int mode, spec, reg, fp; -{ - if ( fp ){ /* FLOATING POINT INSTRUCTION */ - if ( mode == 1 ){ /* FP operand */ - switch ( reg ){ - case 0: fputs( "fp0", stream ); break; - case 1: fputs( "fp1", stream ); break; - case 2: fputs( "fp2", stream ); break; - case 3: fputs( "fp3", stream ); break; - case 16: fputs( "0f0.0", stream ); break; - case 22: fputs( "0f1.0", stream ); break; - default: putc( '?', stream ); break; - } - } else { /* Non-FP register */ - fputs( reg_names[reg], stream ); - } - } else { /* NOT FLOATING POINT */ - if ( mode == 1 ){ /* Literal */ - fprintf( stream, "%d", reg ); - } else { /* Register */ - if ( spec == 0 ){ - fputs( reg_names[reg], stream ); - } else { - fprintf( stream, "sf%d", reg ); - } - } - } -} - -/************************************************/ -/* Register Instruction Destination Operand */ -/************************************************/ -static void -dstop( mode, reg, fp ) - int mode, reg, fp; -{ - /* 'dst' operand can't be a literal. On non-FP instructions, register - * mode is assumed and "m3" acts as if were "s3"; on FP-instructions, - * sf registers are not allowed so m3 acts normally. - */ - if ( fp ){ - regop( mode, 0, reg, fp ); - } else { - regop( 0, mode, reg, fp ); - } -} - - -static void -invalid( word1 ) - int word1; -{ - fprintf( stream, ".word\t0x%08x", (unsigned) word1 ); -} - -static void -print_addr(a) -int a; -{ - fprintf( stream, "0x%x", (unsigned) a ); -} - -static void -put_abs( word1, word2 ) - unsigned long word1, word2; -{ -#ifdef IN_GDB - return; -#else - int len; - - switch ( (word1 >> 28) & 0xf ){ - case 0x8: - case 0x9: - case 0xa: - case 0xb: - case 0xc: - /* MEM format instruction */ - len = mem( 0, word1, word2, 1 ); - break; - default: - len = 4; - break; - } - - if ( len == 8 ){ - fprintf( stream, "%08x %08x\t", word1, word2 ); - } else { - fprintf( stream, "%08x \t", word1 ); - } -; - -#endif -} diff --git a/binutils/is-ranlib.c b/binutils/is-ranlib.c deleted file mode 100644 index fde72a43da5..00000000000 --- a/binutils/is-ranlib.c +++ /dev/null @@ -1,3 +0,0 @@ -/* Linked with ar.o to flag that this program is 'ranlib' (not 'ar'). */ - -int is_ranlib = 1; diff --git a/binutils/is-strip.c b/binutils/is-strip.c deleted file mode 100644 index f5e1caceb28..00000000000 --- a/binutils/is-strip.c +++ /dev/null @@ -1,3 +0,0 @@ -/* Linked with copy.o to flag that this program is 'strip' (not 'copy'). */ - -int is_strip = 1; diff --git a/binutils/m68k-pinsn.c b/binutils/m68k-pinsn.c deleted file mode 100644 index 139a6637254..00000000000 --- a/binutils/m68k-pinsn.c +++ /dev/null @@ -1,835 +0,0 @@ -/* Print m68k instructions for objdump - Copyright (C) 1986, 1987, 1989, 1991 Free Software Foundation, Inc. - - -This file is part of the binutils. - -The binutils are 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. - -The binutils are distributed in the hope that they 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 the binutils; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* $Id$ - $Log$ - Revision 1.5 1991/11/03 22:58:44 bothner - * Makefile.in ($(DIST_NAME).tar.Z), TODO: Various fixes. - * ar.c (get_pos_bfd): Fix to handling of before/after - positioning options. - * bucomm.c (fatal): MISSING_VFPRINTF is no longer an issue, - since libiberty contains vfprintf etc if otherwise missing. - * m68k-pinsn.c (print_insn_arg): Support BB/BW/BL - type operands, as used by branch instructions. - * nm.c: Delegate printing of symbols to BFD, - by using bfd_print_symbol to do the formatting. - - * Revision 1.4 1991/10/16 18:56:56 bothner - * * Makefile.in, ar.c, bucomm.c, copy.c, cplus-dem.c, filemode.c, - * i960-pinsn.c, m68k-pinsn.c, nm.c, objdump.c, size.c, sparc-pinsn.c, - * * strip.c: Add or update Copyright notice. - * * TODO: Add note on 'nm -a'. - * * version.c: Update version number to 1.90. - * * Makefile.in: Fix making of documentation for dist. - * - * Revision 1.3 1991/10/11 11:22:00 gnu - * Include bfd.h before sysdep.h, so ansidecl and PROTO() get defined first. - * - * Revision 1.2 1991/06/14 22:54:44 steve - * *** empty log message *** - * - * Revision 1.1.1.1 1991/03/21 21:26:46 gumby - * Back from Intel with Steve - * - * Revision 1.1 1991/03/21 21:26:45 gumby - * Initial revision - * - * Revision 1.1 1991/03/13 00:34:06 chrisb - * Initial revision - * - * Revision 1.4 1991/03/09 04:36:34 rich - * Modified Files: - * sparc-pinsn.c ostrip.c objdump.c m68k-pinsn.c i960-pinsn.c - * binutils.h - * - * Pulled sysdep.h out of bfd.h. - * - * Revision 1.3 1991/03/08 21:54:45 rich - * Modified Files: - * Makefile ar.c binutils.h bucomm.c copy.c cplus-dem.c getopt.c - * i960-pinsn.c m68k-pinsn.c nm.c objdump.c sparc-opcode.h - * sparc-pinsn.c strip.c - * - * Verifying Portland tree with steve's last changes. Also, some partial - * porting. - * - * Revision 1.2 1991/03/08 07:46:24 sac - * Added -l option to disassembly - prints line numbers too. - * - * Revision 1.1 1991/02/22 16:48:02 sac - * Initial revision - * -*/ -#include "bfd.h" -#include "sysdep.h" -#include -#include "m68k-opcode.h" - -extern int fputs(); -extern void print_address(); - -/* 68k instructions are never longer than this many bytes. */ -#define MAXLEN 22 - -/* Number of elements in the opcode table. */ -#define NOPCODES (sizeof m68k_opcodes / sizeof m68k_opcodes[0]) - -extern char *reg_names[]; -char *fpcr_names[] = { "", "fpiar", "fpsr", "fpiar/fpsr", "fpcr", - "fpiar/fpcr", "fpsr/fpcr", "fpiar-fpcr"}; - -char *reg_names[] = {"d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "a0", "a1", "a2", "a3", "a4", "a5", "fp", "sp", "ps", "pc"}; -static unsigned char *print_insn_arg (); -static unsigned char *print_indexed (); -static void print_base (); -static int fetch_arg (); - -#define NEXTBYTE(p) (p += 2, ((char *)p)[-1]) - -#define NEXTWORD(p) \ - (p += 2, ((((char *)p)[-2]) << 8) + p[-1]) - -#define NEXTLONG(p) \ - (p += 4, (((((p[-4] << 8) + p[-3]) << 8) + p[-2]) << 8) + p[-1]) - -#define NEXTSINGLE(p) \ - (p += 4, *((float *)(p - 4))) - -#define NEXTDOUBLE(p) \ - (p += 8, *((double *)(p - 8))) - -#define NEXTEXTEND(p) \ - (p += 12, 0.0) /* Need a function to convert from extended to double - precision... */ - -#define NEXTPACKED(p) \ - (p += 12, 0.0) /* Need a function to convert from packed to double - precision. Actually, it's easier to print a - packed number than a double anyway, so maybe - there should be a special case to handle this... */ - -/* Print the m68k instruction at address MEMADDR in debugged memory, - on STREAM. Returns length of the instruction, in bytes. */ - -int -print_insn_m68k(addr, buffer, stream) - bfd_vma addr; -unsigned char *buffer; - FILE *stream; -{ - register unsigned int i; - register unsigned char *p; - register char *d; - register unsigned int bestmask; - int best; - - - - bestmask = 0; - best = -1; - for (i = 0; i < NOPCODES; i++) - { - register unsigned int opcode = m68k_opcodes[i].opcode; - register unsigned int match = m68k_opcodes[i].match; - if (((0xff & buffer[0] & (match >> 24)) == (0xff & (opcode >> 24))) - && ((0xff & buffer[1] & (match >> 16)) == (0xff & (opcode >> 16))) - && ((0xff & buffer[2] & (match >> 8)) == (0xff & (opcode >> 8))) - && ((0xff & buffer[3] & match) == (0xff & opcode))) - { - /* Don't use for printout the variants of divul and divsl - that have the same register number in two places. - The more general variants will match instead. */ - for (d = m68k_opcodes[i].args; *d; d += 2) - if (d[1] == 'D') - break; - - /* Don't use for printout the variants of most floating - point coprocessor instructions which use the same - register number in two places, as above. */ - if (*d == 0) - for (d = m68k_opcodes[i].args; *d; d += 2) - if (d[1] == 't') - break; - - if (*d == 0 && match > bestmask) - { - best = i; - bestmask = match; - } - } - } - - /* Handle undefined instructions. */ - if (best < 0) - { - fprintf (stream, "0%o", (unsigned) (buffer[0] << 8) + buffer[1]); - return 2; - } - - fprintf (stream, "%s", m68k_opcodes[best].name); - - /* Point at first word of argument data, - and at descriptor for first argument. */ - p = buffer + 2; - - /* Why do this this way? -MelloN */ - for (d = m68k_opcodes[best].args; *d; d += 2) - { - if (d[0] == '#') - { - if (d[1] == 'l' && p - buffer < 6) - p = buffer + 6; - else if (p - buffer < 4 && d[1] != 'C' && d[1] != '8' ) - p = buffer + 4; - } - if (d[1] >= '1' && d[1] <= '3' && p - buffer < 4) - p = buffer + 4; - if (d[1] >= '4' && d[1] <= '6' && p - buffer < 6) - p = buffer + 6; - if ((d[0] == 'L' || d[0] == 'l') && d[1] == 'w' && p - buffer < 4) - p = buffer + 4; - } - - d = m68k_opcodes[best].args; - - if (*d) - fputs (" ", stream); - - while (*d) - { - p = print_insn_arg (d, buffer, p, addr + p - buffer, stream); - d += 2; - if (*d && *(d - 2) != 'I' && *d != 'k') - fputs (",", stream); - } - return p - buffer; -} - -static unsigned char * -print_insn_arg (d, buffer, p, addr, stream) - char *d; - unsigned char *buffer; - register unsigned char *p; - bfd_vma addr; /* PC for this arg to be relative to */ - FILE *stream; -{ - register int val; - register int place = d[1]; - int regno; - register char *regname; - register unsigned char *p1; - register double flval; - int flt_p; - - switch (*d) - { - case 'C': - fprintf (stream, "ccr"); - break; - - case 'S': - fprintf (stream, "sr"); - break; - - case 'U': - fprintf (stream, "usp"); - break; - - case 'J': - { - static struct { char *name; int value; } names[] - = {{"sfc", 0x000}, {"dfc", 0x001}, {"cacr", 0x002}, - {"usp", 0x800}, {"vbr", 0x801}, {"caar", 0x802}, - {"msp", 0x803}, {"isp", 0x804}}; - - val = fetch_arg (buffer, place, 12); - for (regno = sizeof names / sizeof names[0] - 1; regno >= 0; regno--) - if (names[regno].value == val) - { - fprintf (stream, names[regno].name); - break; - } - if (regno < 0) - fprintf (stream, "%d", val); - } - break; - - case 'Q': - val = fetch_arg (buffer, place, 3); - if (val == 0) val = 8; - fprintf (stream, "#%d", val); - break; - - case 'M': - val = fetch_arg (buffer, place, 8); - if (val & 0x80) - val = val - 0x100; - fprintf (stream, "#%d", val); - break; - - case 'T': - val = fetch_arg (buffer, place, 4); - fprintf (stream, "#%d", val); - break; - - case 'D': - fprintf (stream, "%s", reg_names[fetch_arg (buffer, place, 3)]); - break; - - case 'A': - fprintf (stream, "%s", - reg_names[fetch_arg (buffer, place, 3) + 010]); - break; - - case 'R': - fprintf (stream, "%s", reg_names[fetch_arg (buffer, place, 4)]); - break; - - case 'F': - fprintf (stream, "fp%d", fetch_arg (buffer, place, 3)); - break; - - case 'O': - val = fetch_arg (buffer, place, 6); - if (val & 0x20) - fprintf (stream, "%s", reg_names [val & 7]); - else - fprintf (stream, "%d", val); - break; - - case '+': - fprintf (stream, "%s@+", - reg_names[fetch_arg (buffer, place, 3) + 8]); - break; - - case '-': - fprintf (stream, "%s@-", - reg_names[fetch_arg (buffer, place, 3) + 8]); - break; - - case 'k': - if (place == 'k') - fprintf (stream, "{%s}", reg_names[fetch_arg (buffer, place, 3)]); - else if (place == 'C') - { - val = fetch_arg (buffer, place, 7); - if ( val > 63 ) /* This is a signed constant. */ - val -= 128; - fprintf (stream, "{#%d}", val); - } - else - fprintf(stderr, "Invalid arg format in opcode table: \"%c%c\".", - *d, place); - break; - - case '#': - case '^': - p1 = buffer + (*d == '#' ? 2 : 4); - if (place == 's') - val = fetch_arg (buffer, place, 4); - else if (place == 'C') - val = fetch_arg (buffer, place, 7); - else if (place == '8') - val = fetch_arg (buffer, place, 3); - else if (place == '3') - val = fetch_arg (buffer, place, 8); - else if (place == 'b') - val = NEXTBYTE (p1); - else if (place == 'w') - val = NEXTWORD (p1); - else if (place == 'l') - val = NEXTLONG (p1); - else - fprintf(stderr, "Invalid arg format in opcode table: \"%c%c\".", - *d, place); - fprintf (stream, "#%d", val); - break; - - case 'B': - if (place == 'b') - val = NEXTBYTE (p); - else if (place == 'B') - val = buffer[1]; - else if (place == 'w' || place == 'W') - val = NEXTWORD (p); - else if (place == 'l' || place == 'L') - val = NEXTLONG (p); - else if (place == 'g') - { - val = ((char *)buffer)[1]; - if (val == 0) - val = NEXTWORD (p); - else if (val == -1) - val = NEXTLONG (p); - } - else if (place == 'c') - { - if (buffer[1] & 0x40) /* If bit six is one, long offset */ - val = NEXTLONG (p); - else - val = NEXTWORD (p); - } - else - fprintf(stderr, "Invalid arg format in opcode table: \"%c%c\".", - *d, place); - print_address (addr + val, stream); - break; - - case 'd': - val = NEXTWORD (p); - fprintf (stream, "%s@(%d)", - reg_names[fetch_arg (buffer, place, 3)], val); - break; - - case 's': - fprintf (stream, "%s", - fpcr_names[fetch_arg (buffer, place, 3)]); - break; - - case 'I': - val = fetch_arg (buffer, 'd', 3); /* Get coprocessor ID... */ - if (val != 1) /* Unusual coprocessor ID? */ - fprintf (stream, "(cpid=%d) ", val); - if (place == 'i') - p += 2; /* Skip coprocessor extended operands */ - break; - - case '*': - case '~': - case '%': - case ';': - case '@': - case '!': - case '$': - case '?': - case '/': - case '&': - - if (place == 'd') - { - val = fetch_arg (buffer, 'x', 6); - val = ((val & 7) << 3) + ((val >> 3) & 7); - } - else - val = fetch_arg (buffer, 's', 6); - - /* Get register number assuming address register. */ - regno = (val & 7) + 8; - regname = reg_names[regno]; - switch (val >> 3) - { - case 0: - fprintf (stream, "%s", reg_names[val]); - break; - - case 1: - fprintf (stream, "%s", regname); - break; - - case 2: - fprintf (stream, "%s@", regname); - break; - - case 3: - fprintf (stream, "%s@+", regname); - break; - - case 4: - fprintf (stream, "%s@-", regname); - break; - - case 5: - val = NEXTWORD (p); - fprintf (stream, "%s@(%d)", regname, val); - break; - - case 6: - p = print_indexed (regno, p, addr, stream); - break; - - case 7: - switch (val & 7) - { - case 0: - val = NEXTWORD (p); - fprintf (stream, "@#"); - print_address (val, stream); - break; - - case 1: - val = NEXTLONG (p); - fprintf (stream, "@#"); - print_address (val, stream); - break; - - case 2: - val = NEXTWORD (p); - print_address (addr + val, stream); - break; - - case 3: - p = print_indexed (-1, p, addr, stream); - break; - - case 4: - flt_p = 1; /* Assume it's a float... */ - switch( place ) - { - case 'b': - val = NEXTBYTE (p); - flt_p = 0; - break; - - case 'w': - val = NEXTWORD (p); - flt_p = 0; - break; - - case 'l': - val = NEXTLONG (p); - flt_p = 0; - break; - - case 'f': - flval = NEXTSINGLE(p); - break; - - case 'F': - flval = NEXTDOUBLE(p); - break; - - case 'x': - flval = NEXTEXTEND(p); - break; - - case 'p': - flval = NEXTPACKED(p); - break; - - default: - fprintf(stderr, "Invalid arg format in opcode table: \"%c%c\".", - *d, place); - } - if ( flt_p ) /* Print a float? */ - fprintf (stream, "#%g", flval); - else - fprintf (stream, "#%d", val); - break; - - default: - fprintf (stream, "", (unsigned) val); - } - } - break; - - case 'L': - case 'l': - if (place == 'w') - { - char doneany; - p1 = buffer + 2; - val = NEXTWORD (p1); - /* Move the pointer ahead if this point is farther ahead - than the last. */ - p = p1 > p ? p1 : p; - if (val == 0) - { - fputs ("#0", stream); - break; - } - if (*d == 'l') - { - register int newval = 0; - for (regno = 0; regno < 16; ++regno) - if (val & (0x8000 >> regno)) - newval |= 1 << regno; - val = newval; - } - val &= 0xffff; - doneany = 0; - for (regno = 0; regno < 16; ++regno) - if (val & (1 << regno)) - { - int first_regno; - if (doneany) - fputs ("/", stream); - doneany = 1; - fprintf (stream, "%s", reg_names[regno]); - first_regno = regno; - while (val & (1 << (regno + 1))) - ++regno; - if (regno > first_regno) - fprintf (stream, "-%s", reg_names[regno]); - } - } - else if (place == '3') - { - /* `fmovem' insn. */ - char doneany; - val = fetch_arg (buffer, place, 8); - if (val == 0) - { - fputs ("#0", stream); - break; - } - if (*d == 'l') - { - register int newval = 0; - for (regno = 0; regno < 8; ++regno) - if (val & (0x80 >> regno)) - newval |= 1 << regno; - val = newval; - } - val &= 0xff; - doneany = 0; - for (regno = 0; regno < 8; ++regno) - if (val & (1 << regno)) - { - int first_regno; - if (doneany) - fputs ("/", stream); - doneany = 1; - fprintf (stream, "fp%d", regno); - first_regno = regno; - while (val & (1 << (regno + 1))) - ++regno; - if (regno > first_regno) - fprintf (stream, "-fp%d", regno); - } - } - else - abort (); - break; - - default: - fprintf(stderr, "Invalid arg format in opcode table: \"%c\".", *d); - } - - return (unsigned char *) p; -} - -/* Fetch BITS bits from a position in the instruction specified by CODE. - CODE is a "place to put an argument", or 'x' for a destination - that is a general address (mode and register). - BUFFER contains the instruction. */ - -static int -fetch_arg (buffer, code, bits) - unsigned char *buffer; - char code; - int bits; -{ - register int val; - switch (code) - { - case 's': - val = buffer[1]; - break; - - case 'd': /* Destination, for register or quick. */ - val = (buffer[0] << 8) + buffer[1]; - val >>= 9; - break; - - case 'x': /* Destination, for general arg */ - val = (buffer[0] << 8) + buffer[1]; - val >>= 6; - break; - - case 'k': - val = (buffer[3] >> 4); - break; - - case 'C': - val = buffer[3]; - break; - - case '1': - val = (buffer[2] << 8) + buffer[3]; - val >>= 12; - break; - - case '2': - val = (buffer[2] << 8) + buffer[3]; - val >>= 6; - break; - - case '3': - case 'j': - val = (buffer[2] << 8) + buffer[3]; - break; - - case '4': - val = (buffer[4] << 8) + buffer[5]; - val >>= 12; - break; - - case '5': - val = (buffer[4] << 8) + buffer[5]; - val >>= 6; - break; - - case '6': - val = (buffer[4] << 8) + buffer[5]; - break; - - case '7': - val = (buffer[2] << 8) + buffer[3]; - val >>= 7; - break; - - case '8': - val = (buffer[2] << 8) + buffer[3]; - val >>= 10; - break; - - default: - abort (); - } - - switch (bits) - { - case 3: - return val & 7; - case 4: - return val & 017; - case 5: - return val & 037; - case 6: - return val & 077; - case 7: - return val & 0177; - case 8: - return val & 0377; - case 12: - return val & 07777; - default: - abort (); - return(0); - } -} /* fetch_arg() */ - -/* Print an indexed argument. The base register is BASEREG (-1 for pc). - P points to extension word, in buffer. - ADDR is the nominal core address of that extension word. */ - -static unsigned char * -print_indexed (basereg, p, addr, stream) - int basereg; - unsigned char *p; - FILE *stream; -bfd_vma addr; -{ - register int word; - static char *scales[] = {"", "*2", "*4", "*8"}; - register int base_disp; - register int outer_disp; - char buf[40]; - - word = NEXTWORD (p); - - /* Generate the text for the index register. - Where this will be output is not yet determined. */ - sprintf (buf, "[%s.%c%s]", - reg_names[(word >> 12) & 0xf], - (word & 0x800) ? 'l' : 'w', - scales[(word >> 9) & 3]); - - /* Handle the 68000 style of indexing. */ - - if ((word & 0x100) == 0) - { - print_base (basereg, - ((word & 0x80) ? word | 0xff00 : word & 0xff) - + ((basereg == -1) ? addr : 0), - stream); - fputs (buf, stream); - return p; - } - - /* Handle the generalized kind. */ - /* First, compute the displacement to add to the base register. */ - - if (word & 0200) - basereg = -2; - if (word & 0100) - buf[0] = 0; - base_disp = 0; - switch ((word >> 4) & 3) - { - case 2: - base_disp = NEXTWORD (p); - break; - case 3: - base_disp = NEXTLONG (p); - } - if (basereg == -1) - base_disp += addr; - - /* Handle single-level case (not indirect) */ - - if ((word & 7) == 0) - { - print_base (basereg, base_disp, stream); - fputs (buf, stream); - return p; - } - - /* Two level. Compute displacement to add after indirection. */ - - outer_disp = 0; - switch (word & 3) - { - case 2: - outer_disp = NEXTWORD (p); - break; - case 3: - outer_disp = NEXTLONG (p); - } - - fprintf (stream, "%d(", outer_disp); - print_base (basereg, base_disp, stream); - - /* If postindexed, print the closeparen before the index. */ - if (word & 4) - fprintf (stream, ")%s", buf); - /* If preindexed, print the closeparen after the index. */ - else - fprintf (stream, "%s)", buf); - - return p; -} - -/* Print a base register REGNO and displacement DISP, on STREAM. - REGNO = -1 for pc, -2 for none (suppressed). */ - -static void -print_base (regno, disp, stream) - int regno; - int disp; - FILE *stream; -{ - if (regno == -2) - fprintf (stream, "%d", disp); - else if (regno == -1) - fprintf (stream, "0x%x", (unsigned) disp); - else - fprintf (stream, "%d(%s)", disp, reg_names[regno]); -} diff --git a/binutils/maybe-ranlib.c b/binutils/maybe-ranlib.c deleted file mode 100644 index 882bb73d6ee..00000000000 --- a/binutils/maybe-ranlib.c +++ /dev/null @@ -1,4 +0,0 @@ -/* Linked with ar.o to flag that this program decides at runtime - (using argv[0] if it is is 'ar' or 'ranlib'. */ - -int is_ranlib = 0; diff --git a/binutils/maybe-strip.c b/binutils/maybe-strip.c deleted file mode 100644 index 7da8763cd9f..00000000000 --- a/binutils/maybe-strip.c +++ /dev/null @@ -1,4 +0,0 @@ -/* Linked with copy.o to flag that this program decides at runtime - (using argv[0] if it is is 'strip' or 'copy'. */ - -int is_strip = -1; diff --git a/binutils/nm.1 b/binutils/nm.1 deleted file mode 100644 index 8a88b493b37..00000000000 --- a/binutils/nm.1 +++ /dev/null @@ -1,154 +0,0 @@ -.\" Copyright (c) 1991 Free Software Foundation -.\" See section COPYING for conditions for redistribution -.\" $Id$ -.TH nm 1 "5 November 1991" "cygnus support" "GNU Development Tools" -.de BP -.sp -.ti \-.2i -\(** -.. - -.SH NAME -nm\(em\&list symbols from object files. - -.SH SYNOPSIS -.hy 0 -.na -.TP -.B nm -.RB "[\|" \-a | +debug-syms "\|]" -.RB "[\|" \-g | +extern-only "\|]" -.RB "[\|" \-s | +print-armap "\|]" -.RB "[\|" \-o | +print-file-name "\|]" -.RB "[\|" \-n | +numeric-sort "\|]" -.RB "[\|" \-p | +no-sort "\|]" -.RB "[\|" \-r | +reverse-sort "\|]" -.RB "[\|" \-u | +undefined-only "\|]" -.RB "[\|" "+target\ "\c -.I bfdname\c -\&\|] -.RB "[\|" \c -.I objfiles\c -\&.\|.\|.\|] -.ad b -.hy 1 -.SH DESCRIPTION -GNU \c -.B nm\c -\& will list the symbols from object files \c -.I objfiles\c -\&. - -.SH OPTIONS -The long and short forms of options, shown here as alternatives, are -equivalent. - -.TP -.IR "objfiles" .\|.\|. -Object files whose symbols are to be listed. If no object files are -listed as arguments, \c -.B nm\c -\& assumes `\|\c -.B a.out\c -\|'. - -.TP -.B \-a -.TP -.B +debug-syms -Display debugger-only symbols; normally these are not listed. - -.TP -.B \-g -.TP -.B +extern-only -Display only external symbols. - -.TP -.B \-p -.TP -.B +no-sort -Don't bother to sort the symbols in any order; just print them in the -order encountered. - -.TP -.B \-n -.TP -.B +numeric-sort -Sort symbols numerically by their addresses, not alphabetically by their -names. - -.TP -.B \-s -.TP -.B +print-armap -When listing symbols from archive members, include the index: a mapping -(stored in the archive by \c -.B ar\c -\& or \c -.B ranlib\c -\&) of what modules -contain definitions for what names. - -.TP -.B \-o -.TP -.B +print-file-name -Precede each symbol by the name of the input file where it was found, -rather than identifying the input file once only before all of its -symbols. - -.TP -.B \-r -.TP -.B +reverse-sort -Reverse the sense of the sort (whether numeric or alphabetic); let the -last come first. - -.TP -.BI "+target " "bfdname"\c -\& -Specify an object code format other than your system's default format. -See -.BR objdump ( 1 ), -for information on listing available formats. - -.TP -.B \-u -.TP -.B +undefined-only -Display only undefined symbols (those external to each object file). - -.PP - -.SH "SEE ALSO" -.RB "`\|" binutils "\|'" -entry in -.B -info\c -\&; -.I -The GNU Binary Utilities\c -\&, Roland H. Pesch (October 1991); -.BR ar "(" 1 ")," -.BR objdump ( 1 ), -.BR ranlib "(" 1 ")." - - -.SH COPYING -Copyright (c) 1991 Free Software Foundation, Inc. -.PP -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. -.PP -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided that the -entire resulting derived work is distributed under the terms of a -permission notice identical to this one. -.PP -Permission is granted to copy and distribute translations of this -manual into another language, under the above conditions for modified -versions, except that this permission notice may be included in -translations approved by the Free Software Foundation instead of in -the original English. diff --git a/binutils/nm.c b/binutils/nm.c deleted file mode 100644 index 2fa1d7e55c5..00000000000 --- a/binutils/nm.c +++ /dev/null @@ -1,431 +0,0 @@ -/* nm.c -- Describe symbol table of a rel file. - Copyright (C) 1991 Free Software Foundation, Inc. - -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 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include "bfd.h" -#include "sysdep.h" -#include "getopt.h" -#include "stab.gnu.h" -#include - - - -PROTO(static boolean, display_file, (char *filename)); -PROTO(static void, do_one_rel_file, (bfd *file)); -PROTO(static unsigned int, filter_symbols, (bfd *file, asymbol **syms, - unsigned long symcount)); - -PROTO(static void, print_symbols, (bfd *file, asymbol **syms, - unsigned long symcount)); -extern PROTO(int, (*sorters[2][2]), (char *x, char *y)); -PROTO(static void, print_symdef_entry, (bfd * abfd)); - -/* Command options. */ - -int external_only = 0; /* print external symbols only */ -int file_on_each_line = 0; /* print file name on each line */ -int no_sort = 0; /* don't sort; print syms in order found */ -int print_debug_syms = 0; /* print debugger-only symbols too */ -int print_armap = 0; /* describe __.SYMDEF data in archive files. */ -int reverse_sort = 0; /* sort in downward(alpha or numeric) order */ -int sort_numerically = 0; /* sort in numeric rather than alpha order */ -int undefined_only = 0; /* print undefined symbols only */ - -boolean print_each_filename = false; /* Ick. Used in archives. */ - -/* IMPORT */ -extern char *program_name; -extern char *program_version; -extern char *target; - -struct option long_options[] = { - {"debug-syms", 0, &print_debug_syms, 1}, - {"extern-only", 0, &external_only, 1}, - {"no-sort", 0, &no_sort, 1}, - {"numeric-sort", 0, &sort_numerically, 1}, - {"print-armap", 0, &print_armap, 1}, - {"print-file-name", 0, &file_on_each_line, 1}, - {"reverse-sort", 0, &reverse_sort, 1}, - {"target", 2, (int *)NULL, 0}, - {"undefined-only", 0, &undefined_only, 1}, - {0, 0, 0, 0} -}; - -int show_names = 0; - -/* Some error-reporting functions */ - -void -usage () -{ - fprintf(stderr, "nm %s\nUsage: %s [-agnoprsu] filename...\n", - program_version, program_name); - exit(0); -} - -int -main (argc, argv) - int argc; - char **argv; -{ - int c; /* sez which option char */ - int ind = 0; /* used by getopt and ignored by us */ - extern int optind; /* steps thru options */ - int retval; - program_name = *argv; - - bfd_init(); - - while ((c = getopt_long(argc, argv, "agnoprsu", long_options, &ind)) != EOF) { - switch (c) { - case 'a': print_debug_syms = 1; break; - case 'g': external_only = 1; break; - case 'n': sort_numerically = 1; break; - case 'o': file_on_each_line = 1; break; - case 'p': no_sort = 1; break; - case 'r': reverse_sort = 1; break; - case 's': print_armap = 1; break; - case 'u': undefined_only = 1; break; - - case 0: - if (!strcmp("target",(long_options[option_index]).name)) { - target = optarg; - } - - break; /* we've been given a long option */ - - default: - usage (); - } - } - - /* Strangely, for the shell you should return only a nonzero value - on sucess -- the inverse of the C sense. */ - - /* OK, all options now parsed. If no filename specified, do a.out. */ - if (optind == argc) return !display_file ("a.out"); - - retval = 0; - show_names = (argc -optind)>1; - /* We were given several filenames to do: */ - while (optind < argc) { - if (!display_file (argv[optind++])) { - retval++; - } - } - - return retval; -} - -/** Display a file's stats */ - -/* goto here is marginally cleaner than the nested if syntax */ - -static boolean -display_file (filename) - char *filename; -{ - boolean retval = true; - bfd *file; - bfd *arfile = NULL; - - file = bfd_openr(filename, target); - if (file == NULL) { - fprintf (stderr, "\n%s: can't open '%s'.\n", program_name, filename); - return false; - - - } - - - if (bfd_check_format(file, bfd_object)) - { - if (show_names) { - printf ("\n%s:\n",filename); - } - do_one_rel_file (file); - - } - else if (bfd_check_format (file, bfd_archive)) { - if (!bfd_check_format (file, bfd_archive)) { - fprintf (stderr, "%s: %s: unknown format.\n", program_name, filename); - retval = false; - goto closer; - } - - printf("\n%s:\n", filename); - if (print_armap) print_symdef_entry (file); - for (;;) { - arfile = bfd_openr_next_archived_file (file, arfile); - - if (arfile == NULL) { - if (bfd_error != no_more_archived_files) - bfd_fatal (filename); - goto closer; - } - - if (!bfd_check_format(arfile, bfd_object)) - printf("%s: not an object file\n", arfile->filename); - else { - printf ("\n%s:\n", arfile->filename); - do_one_rel_file (arfile) ; - } - } - } - else { - fprintf (stderr, "\n%s: %s: unknown format.\n", program_name, filename); - retval = false; - } - - - closer: - if (bfd_close(file) == false) - bfd_fatal (filename); - - return retval; -} - - -static void -do_one_rel_file (abfd) - bfd *abfd; -{ - unsigned int storage; - asymbol **syms; - unsigned int symcount = 0; - - if (!(bfd_get_file_flags (abfd) & HAS_SYMS)) { - (void) printf ("No symbols in \"%s\".\n", bfd_get_filename (abfd)); - return; - } - - - storage = get_symtab_upper_bound (abfd); - if (storage == 0) { - nosymz: - fprintf (stderr, "%s: Symflags set but there are none?\n", - bfd_get_filename (abfd)); - exit (1); - } - - syms = (asymbol **) xmalloc (storage); - - symcount = bfd_canonicalize_symtab (abfd, syms); - if (symcount == 0) goto nosymz; - - /* Discard the symbols we don't want to print. - It's OK to do this in place; we'll free the storage anyway - (after printing) */ - - symcount = filter_symbols (abfd, syms, symcount); - - if (!no_sort) - qsort((char *) syms, symcount, sizeof (asymbol *), - sorters[sort_numerically][reverse_sort]); - - if (print_each_filename && !file_on_each_line) - printf("\n%s:\n", bfd_get_filename(abfd)); - - print_symbols (abfd, syms, symcount); - free (syms); - -} - -/* Symbol-sorting predicates */ -#define valueof(x) ((x)->section ? (x)->section->vma + (x)->value : (x)->value) -int -numeric_forward (x, y) - char *x; - char *y; -{ - - return (valueof(*(asymbol **)x) - valueof(*(asymbol **) y));; -} - -int -numeric_reverse (x, y) - char *x; - char *y; -{ - return (valueof(*(asymbol **)y) - valueof(*(asymbol **) x)); - -} - -int -non_numeric_forward (x, y) - char *x; - char *y; -{ - CONST char *xn = (*(asymbol **) x)->name; - CONST char *yn = (*(asymbol **) y)->name; - - return ((xn == NULL) ? ((yn == NULL) ? 0 : -1) : - ((yn == NULL) ? 1 : strcmp (xn, yn))); -} - -int -non_numeric_reverse (x, y) - char *x; - char *y; -{ - return -(non_numeric_forward (x, y)); -} - -int (*sorters[2][2])() = { - {non_numeric_forward, non_numeric_reverse}, - {numeric_forward, numeric_reverse}, -}; - - -/* Choose which symbol entries to print; - compact them downward to get rid of the rest. - Return the number of symbols to be printed. */ -static unsigned int -filter_symbols (abfd, syms, symcount) - bfd *abfd; - asymbol **syms; - unsigned long symcount; -{ - asymbol **from, **to; - unsigned int dst_count = 0; - unsigned int src_count; - for (from = to = syms, src_count = 0; src_count flags; - - if (undefined_only) { - keep = (flags & BSF_UNDEFINED); - } else if (external_only) { - keep = ((flags & BSF_GLOBAL) || (flags & BSF_UNDEFINED) || - (flags & BSF_FORT_COMM)); - } else { - keep = 1; - } - - if (!print_debug_syms && ((flags & BSF_DEBUGGING) != 0)) { - keep = 0; - } - - if (keep) { - to[dst_count++] = from[src_count]; - } - } - - return dst_count; -} - - -/* Return a lower-case character corresponding to the symbol class of sym */ -char -decode_symclass (sym) - asymbol *sym; -{ - flagword flags = sym->flags; - - if ((sym->value == 0) && (sym->section != NULL)) - /* Huh? All section names don't begin with "." */ - return (sym->section->name)[1]; - - if (flags & BSF_FORT_COMM) return 'C'; - if (flags & BSF_UNDEFINED) return 'U'; - if (flags & BSF_ABSOLUTE) return 'a'; - - - if ( (flags & BSF_GLOBAL) || (flags & BSF_LOCAL) ){ - if (sym->section == (asection *)NULL) { - return '*'; - } - else if ( !strcmp(sym->section->name, ".text") ){ - return 't'; - } else if ( !strcmp(sym->section->name, ".data") ){ - return 'd'; - } else if ( !strcmp(sym->section->name, ".bss") ){ - return 'b'; - } else { - return 'o'; - } - } - - /* We don't have to handle these cases just yet, but we will soon: - N_SETV: 'v'; - N_SETA: 'l'; - N_SETT: 'x'; - N_SETD: 'z'; - N_SETB: 's'; - N_INDR: 'i'; - */ - - return '?'; -} - -static void -print_symbols (abfd, syms, symcount) - bfd *abfd; - asymbol **syms; - unsigned long symcount; -{ - asymbol **sym = syms, **end = syms + symcount; - char class; - - for (; sym < end; ++sym) { - if (file_on_each_line) printf("%s:", bfd_get_filename(abfd)); - - if (undefined_only) { - if ((*sym)->flags & BSF_UNDEFINED) - puts ((*sym)->name); - } - else { - asymbol *p = *sym; - if (p) { - class = decode_symclass (p); - - if (p->flags & BSF_GLOBAL) - class = toupper (class); - - if (p->value || ((p->flags & BSF_UNDEFINED) != BSF_UNDEFINED)) - printf_vma( (p->section ? p->value + p->section->vma : p->value)); - else fputs (" ", stdout); - - printf (" %c %s\n", class, p->name ? p->name : ""); - } - } - } -} - -static void -print_symdef_entry (abfd) - bfd * abfd; -{ - symindex idx = BFD_NO_MORE_SYMBOLS; - carsym *thesym; - boolean everprinted = false; - - for (idx = bfd_get_next_mapent (abfd, idx, &thesym); - idx != BFD_NO_MORE_SYMBOLS; - idx = bfd_get_next_mapent (abfd, idx, &thesym)) { - bfd *elt; - if (!everprinted) { - printf ("\nArchive index:\n"); - everprinted = true; - } - elt = bfd_get_elt_at_index (abfd, idx); - if (thesym->name != (char *)NULL) { - printf ("%s in %s\n", thesym->name, bfd_get_filename (elt)); -} - } -} diff --git a/binutils/not-ranlib.c b/binutils/not-ranlib.c deleted file mode 100644 index b4b730e616f..00000000000 --- a/binutils/not-ranlib.c +++ /dev/null @@ -1,3 +0,0 @@ -/* Linked with ar.o to flag that this program is 'ar' (not 'ranlib'). */ - -int is_ranlib = -1; diff --git a/binutils/not-strip.c b/binutils/not-strip.c deleted file mode 100644 index 0e491fb393c..00000000000 --- a/binutils/not-strip.c +++ /dev/null @@ -1,3 +0,0 @@ -/* Linked with copy.o to flag that this program is 'copy' (not 'strip'). */ - -int is_strip = 0; diff --git a/binutils/objdump.1 b/binutils/objdump.1 deleted file mode 100644 index 63d167881c3..00000000000 --- a/binutils/objdump.1 +++ /dev/null @@ -1,218 +0,0 @@ -.\" Copyright (c) 1991 Free Software Foundation -.\" See section COPYING for conditions for redistribution -.\" $Id$ -.TH objdump 1 "5 November 1991" "cygnus support" "GNU Development Tools" -.de BP -.sp -.ti \-.2i -\(** -.. - -.SH NAME -objdump\(em\&display information from object files. - -.SH SYNOPSIS -.hy 0 -.na -.TP -.B objdump -.RB "[\|" \-a "\|]" -.RB "[\|" "\-b\ "\c -.I bfdname\c -\&\|] -.RB "[\|" \-d "\|]" -.RB "[\|" \-f "\|]" -.RB "[\|" \-h | +header "\|]" -.RB "[\|" \-i "\|]" -.RB "[\|" "\-j\ "\c -.I section\c -\&\|] -.RB "[\|" \-l "\|]" -.RB "[\|" "\-m\ "\c -.I machine\c -\&\|] -.RB "[\|" \-r | +reloc "\|]" -.RB "[\|" \-s "\|]" -.RB "[\|" \-t | +syms "\|]" -.RB "[\|" \-x "\|]" -.I objfiles\c -\&.\|.\|. -.ad b -.hy 1 -.SH DESCRIPTION -\c -.B objdump\c -\& displays information about one or more object files. -The options control what particular information to display. This -information is mostly useful to programmers who are working on the -compilation tools, as opposed to programmers who just want their -program to compile and work. -.SH OPTIONS -Where long and short forms of an option are shown together, they are -equivalent. - -.TP -.IR "objfiles" .\|.\|. -The object files to be examined. When you specify archives, -\c -.B objdump\c -\& shows information on each of the member object files. - -.TP -.B \-a -If any files from \c -.I objfiles\c -\& are archives, display the archive -header information (in a format similar to `\|\c -.B ls \-l\c -\|'). Besides the -information you could list with `\|\c -.B ar tv\c -\|', `\|\c -.B objdump \-a\c -\|' shows -the object file format of each archive member. - -.TP -.BI "-b " "bfdname"\c -\& -You can specify a particular object-code format for your object files as -\c -.I bfdname\c -\&. This may not be necessary; \c -.I objdump\c -\& can -automatically recognize many formats. For example, -.sp -.br -objdump\ \-b\ oasys\ \-m\ vax\ \-h\ fu.o -.br -.sp - -Displays summary information from the section headers (`\|\c -.B \-h\c -\|') of -`\|\c -.B fu.o\c -\|', which is explicitly identified (`\|\c -.B \-m\c -\|') as a Vax object -file in the format produced by Oasys compilers. You can list the -formats available with the `\|\c -.B \-i\c -\|' option. - -.TP -.B \-d -Disassemble. Display the assembler mnemonics for the machine -instructions from \c -.I objfiles\c -\&. - -.TP -.B \-f -File header. Display summary information from the overall header of -each file in \c -.I objfiles\c -\&. - -.TP -.B \-h -.TP -.B +header -Header. Display summary information from the section headers of the -object file. - -.TP -.B \-i -Display a list showing all architectures and object formats available -for specification with \c -.B \-b\c -\& or \c -.B \-m\c -\&. - -.TP -.BI "-j " "name"\c -\& -Display information only for section \c -.I name\c -\& - -.TP -.B \-l -Label the display (using debugging information) with the source filename -and line numbers corresponding to the object code shown. - -.TP -.BI "-m " "machine"\c -\& -Specify the object files \c -.I objfiles\c -\& are for architecture -\c -.I machine\c -\&. You can list available architectures using the `\|\c -.B \-i\c -\|' -option. - -.TP -.B \-r -.TP -.B +reloc -Relocation. Print the relocation entries of the file. - -.TP -.B \-s -Display the full contents of any sections requested. - -.TP -.B \-t -.TP -.B +syms -Symbol Table. Print the symbol table entries of the file. -This is similar to the information provided by the `\|\c -.B nm\c -\|' program. - -.TP -.B \-x -Display all available header information, including the symbol table and -relocation entries. Using `\|\c -.B \-x\c -\|' is equivalent to specifying all of -`\|\c -.B \-a \-f \-h \-r \-t\c -\|'. - -.PP - -.SH "SEE ALSO" -.RB "`\|" binutils "\|'" -entry in -.B -info\c -\&; -.I -The GNU Binary Utilities\c -\&, Roland H. Pesch (October 1991); -.BR nm "(" 1 ")." - -.SH COPYING -Copyright (c) 1991 Free Software Foundation, Inc. -.PP -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. -.PP -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided that the -entire resulting derived work is distributed under the terms of a -permission notice identical to this one. -.PP -Permission is granted to copy and distribute translations of this -manual into another language, under the above conditions for modified -versions, except that this permission notice may be included in -translations approved by the Free Software Foundation instead of in -the original English. diff --git a/binutils/objdump.c b/binutils/objdump.c deleted file mode 100644 index d8dcb3f6bae..00000000000 --- a/binutils/objdump.c +++ /dev/null @@ -1,780 +0,0 @@ -/*** objdump.c -- dump information about an object file. */ - -/* Copyright (C) 1990, 1991 Free Software Foundation, Inc. - -This file is part of BFD, the Binary File Diddler. - -BFD 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 1, or (at your option) -any later version. - -BFD 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 BFD; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - $Id$ -*/ -/* - * Until there is other documentation, refer to the manual page dump(1) in - * the system 5 program's reference manual - */ - -#include "sysdep.h" -#include "bfd.h" -#include "getopt.h" -#include -#include - - - -char *xmalloc(); - -char *default_target = NULL; /* default at runtime */ - -char *program_name = NULL; - -int dump_section_contents; /* -s */ -int dump_section_headers; /* -h */ -boolean dump_file_header; /* -f */ -int dump_symtab; /* -t */ -int dump_reloc_info; /* -r */ -int dump_ar_hdrs; /* -a */ -int with_line_numbers; /* -l */ -boolean disassemble; /* -d */ -boolean info; /* -i */ -char *only; - -PROTO (void, display_file, (char *filename, char *target)); -PROTO (void, dump_data, (bfd *abfd)); -PROTO (void, dump_relocs, (bfd *abfd)); -PROTO (void, dump_symbols, (bfd *abfd)); -PROTO (void, print_arelt_descr, (bfd *abfd, boolean verbose)); - - - - - - - -char *machine = (char *)NULL; - asymbol **syms; - asymbol **syms2; - - -unsigned int storage; - -unsigned int symcount = 0; - -void -usage () -{ - fprintf (stderr, - "usage: %s [-ahifdrtxsl] [-m machine] [-j section_name] obj ...\n", - program_name); - exit (1); -} - -static struct option long_options[] = - {{"syms", 0, &dump_symtab, 1}, - {"reloc", 0, &dump_reloc_info, 1}, - {"header", 0, &dump_section_headers, 1}, - {0, 0, 0, 0}}; - - - -static void -dump_headers(abfd) -bfd *abfd; -{ - asection *section; - for (section = abfd->sections; - section != (asection *) NULL; - section = section->next) - { - char *comma = ""; -#define PF(x,y) \ - if (section->flags & x) { printf("%s%s",comma,y); comma = ", "; } - - - printf("SECTION %d [%s]\t: size %08x", - section->index, - section->name, - (unsigned) section->size); - printf(" vma "); - printf_vma(section->vma); - printf(" align 2**%u\n ", - section->alignment_power); - PF(SEC_ALLOC,"ALLOC"); - PF(SEC_CONSTRUCTOR,"CONSTRUCTOR"); - PF(SEC_CONSTRUCTOR_TEXT,"CONSTRUCTOR TEXT"); - PF(SEC_CONSTRUCTOR_DATA,"CONSTRUCTOR DATA"); - PF(SEC_CONSTRUCTOR_BSS,"CONSTRUCTOR BSS"); - PF(SEC_LOAD,"LOAD"); - PF(SEC_RELOC,"RELOC"); - PF(SEC_BALIGN,"BALIGN"); - PF(SEC_READONLY,"READONLY"); - PF(SEC_CODE,"CODE"); - PF(SEC_DATA,"DATA"); - PF(SEC_ROM,"ROM"); - printf("\n"); -#undef PF - } -} - -static asymbol ** -slurp_symtab(abfd) -bfd *abfd; -{ - asymbol **sy; - if (!(bfd_get_file_flags (abfd) & HAS_SYMS)) { - (void) printf ("No symbols in \"%s\".\n", bfd_get_filename (abfd)); - return(NULL); - } - - storage = get_symtab_upper_bound (abfd); - if (storage) { - sy = (asymbol **) malloc (storage); - if (sy == NULL) { - fprintf (stderr, "%s: out of memory.\n", program_name); - exit (1); - } - } - symcount = bfd_canonicalize_symtab (abfd, sy); - return sy; -} -/* Sort symbols into value order */ -static int comp(ap,bp) -asymbol **ap; -asymbol **bp; -{ - asymbol *a = *ap; - asymbol *b = *bp; - int diff; - - if ( a->name== (char *)NULL || (a->flags &( BSF_DEBUGGING| BSF_UNDEFINED) )) - a->the_bfd = 0; - if ( b->name== (char *)NULL || (b->flags &( BSF_DEBUGGING|BSF_UNDEFINED))) - b->the_bfd =0; - - diff = a->the_bfd - b->the_bfd; - if (diff) { - return -diff; - } - diff = a->value - b->value; - if (diff) { - return diff; - } - return a->section - b->section; -} - -/* Print the supplied address symbolically if possible */ -void -print_address(vma, stream) -bfd_vma vma; -FILE *stream; -{ - /* Perform a binary search looking for the closest symbol to - the required value */ - - unsigned int min = 0; - unsigned int max = symcount; - - unsigned int thisplace = 1; - unsigned int oldthisplace ; - - int vardiff; - if (symcount == 0) { - fprintf_vma(stream, vma); - } - else { - while (true) { - oldthisplace = thisplace; - thisplace = (max + min )/2 ; - if (thisplace == oldthisplace) break; - vardiff = syms[thisplace]->value - vma; - - if (vardiff) { - if (vardiff > 0) { - max = thisplace; - } - else { - min = thisplace; - } - } - else { - /* Totally awesome! the exact right symbol */ - CONST char *match_name = syms[thisplace]->name; - int sym_len = strlen(match_name); - /* Avoid "filename.o" as a match */ - if (sym_len > 2 - && match_name[sym_len - 2] == '.' - && match_name[sym_len - 1] == 'o' - && thisplace + 1 < symcount - && syms[thisplace+1]->value == vma) - match_name = syms[thisplace+1]->name; - /* Totally awesome! the exact right symbol */ - fprintf_vma(stream, vma); - fprintf(stream," (%s)", syms[thisplace]->name); - return; - } - } - /* We've run out of places to look, print the symbol before this one */ - /* see if this or the symbol before describes this location the best */ - - if (thisplace != 0) { - if (syms[thisplace-1]->value - vma > - syms[thisplace]->value-vma) { - /* Previous symbol is in correct section and is closer */ - thisplace --; - } - } - - fprintf_vma(stream, vma); - if (syms[thisplace]->value > vma) { - fprintf(stream," (%s-)", syms[thisplace]->name); - fprintf_vma(stream, syms[thisplace]->value - vma); - - } - else { - fprintf(stream," (%s+)", syms[thisplace]->name); - fprintf_vma(stream, vma - syms[thisplace]->value); - - - } - } -} - -void -disassemble_data(abfd) -bfd *abfd; -{ - bfd_byte *data = NULL; - bfd_arch_info_type *info ; - bfd_size_type datasize = 0; - bfd_size_type i; - unsigned int (*print)() ; - unsigned int print_insn_m68k(); - unsigned int print_insn_a29k(); - unsigned int print_insn_i960(); - unsigned int print_insn_sparc(); - unsigned int print_insn_h8300(); - enum bfd_architecture a; - unsigned long m; - asection *section; - /* Replace symbol section relative values with abs values */ - boolean done_dot = false; - - for (i = 0; i < symcount; i++) { - if (syms[i]->section != (asection *)NULL) { - syms[i]->value += syms[i]->section->vma; - } - } - - /* We keep a copy of the symbols in the original order */ - syms2 = slurp_symtab(abfd); - - /* Sort the symbols into section and symbol order */ - (void) qsort(syms, symcount, sizeof(asymbol *), comp); - - /* Find the first useless symbol */ - { unsigned int i; - for (i =0; i < symcount; i++) { - if (syms[i]->the_bfd == 0) { - symcount =i; - break; - } - } - } - - - - - if (machine!= (char *)NULL) { - info = bfd_scan_arch(machine); - if (info == 0) { - fprintf(stderr,"%s: Can't use supplied machine %s\n", - program_name, - machine); - exit(1); - } - abfd->arch_info = info; - } - - /* See if we can disassemble using bfd */ - - if(abfd->arch_info->disassemble) { - print = abfd->arch_info->disassemble; - } - else { - a = bfd_get_arch(abfd); - switch (a) { - case bfd_arch_sparc: - print = print_insn_sparc; - break; - case bfd_arch_m68k: - print = print_insn_m68k; - break; - case bfd_arch_a29k: - print = print_insn_a29k; - break; - case bfd_arch_i960: - print = print_insn_i960; - break; - default: - fprintf(stderr,"%s: Can't disassemble for architecture %s\n", - program_name, - bfd_printable_arch_mach(bfd_get_arch(abfd),0)); - exit(1); - } - - } - - for (section = abfd->sections; - section != (asection *)NULL; - section = section->next) { - - if (only == (char *)NULL || strcmp(only,section->name) == 0){ - printf("Disassembly of section %s:\n", section->name); - - if (section->size == 0) continue; - - data = (bfd_byte *)malloc(section->size); - - if (data == (bfd_byte *)NULL) { - fprintf (stderr, "%s: memory exhausted.\n", program_name); - exit (1); - } - datasize = section->size; - - - bfd_get_section_contents (abfd, section, data, 0, section->size); - - i = 0; - while (i size) { - if (data[i] ==0 && data[i+1] == 0 && data[i+2] == 0 && - data[i+3] == 0) { - if (done_dot == false) { - printf("...\n"); - done_dot=true; - } - i+=4; - } - else { - done_dot = false; - if (with_line_numbers) { - static prevline; - CONST char *filename; - CONST char *functionname; - unsigned int line; - bfd_find_nearest_line(abfd, - section, - syms, - section->vma + i, - &filename, - &functionname, - &line); - - if (filename && functionname && line && line != prevline) { - printf("%s:%u\n", filename, line); - prevline = line; - } - } - print_address(section->vma + i, stdout); - printf(" "); - - i += print(section->vma + i, - data + i, - stdout); - putchar ('\n') ; - } - } - - - - free(data); - } - } -} - -void -display_bfd (abfd) - bfd *abfd; -{ - - if (!bfd_check_format (abfd, bfd_object)) { - fprintf (stderr,"%s: %s not an object file\n", program_name, - abfd->filename); - return; - } - printf ("\n%s: file format %s\n", abfd->filename, abfd->xvec->name); - if (dump_ar_hdrs) print_arelt_descr (abfd, true); - - if (dump_file_header) { - char *comma = ""; - - printf("architecture: %s, ", - bfd_printable_arch_mach (bfd_get_arch (abfd), - bfd_get_mach (abfd))); - printf("flags 0x%08x:\n", abfd->flags); - -#define PF(x, y) if (abfd->flags & x) {printf("%s%s", comma, y); comma=", ";} - PF(HAS_RELOC, "HAS_RELOC"); - PF(EXEC_P, "EXEC_P"); - PF(HAS_LINENO, "HAS_LINENO"); - PF(HAS_DEBUG, "HAS_DEBUG"); - PF(HAS_SYMS, "HAS_SYMS"); - PF(HAS_LOCALS, "HAS_LOCALS"); - PF(DYNAMIC, "DYNAMIC"); - PF(WP_TEXT, "WP_TEXT"); - PF(D_PAGED, "D_PAGED"); - printf("\nstart address 0x"); - printf_vma(abfd->start_address); - } - printf("\n"); - - if (dump_section_headers) - dump_headers(abfd); - if (dump_symtab || dump_reloc_info || disassemble) { - syms = slurp_symtab(abfd); - } - if (dump_symtab) dump_symbols (abfd); - if (dump_reloc_info) dump_relocs(abfd); - if (dump_section_contents) dump_data (abfd); - if (disassemble) disassemble_data(abfd); -} - -void -display_file (filename, target) - char *filename; - char *target; -{ - bfd *file, *arfile = (bfd *) NULL; - - file = bfd_openr (filename, target); - if (file == NULL) { - bfd_perror (filename); - return; - } - - if (bfd_check_format (file, bfd_archive) == true) { - printf ("In archive %s:\n", bfd_get_filename (file)); - for(;;) { - bfd_error = no_error; - - arfile = bfd_openr_next_archived_file (file, arfile); - if (arfile == NULL) { - if (bfd_error != no_more_archived_files) - bfd_perror (bfd_get_filename(file)); - return; - } - - display_bfd (arfile); - /* Don't close the archive elements; we need them for next_archive */ - } - } - else - display_bfd(file); - - bfd_close(file); -} - -/* Actually display the various requested regions */ - - - - - - - - - - -void -dump_data (abfd) - bfd *abfd; -{ - asection *section; - bfd_byte *data ; - bfd_size_type datasize = 0; - bfd_size_type i; - - for (section = abfd->sections; section != NULL; section = - section->next) { - int onaline = 16; - - if (only == (char *)NULL || - strcmp(only,section->name) == 0){ - - - - printf("Contents of section %s:\n", section->name); - - if (section->size == 0) continue; - data = (bfd_byte *)malloc(section->size); - if (data == (bfd_byte *)NULL) { - fprintf (stderr, "%s: memory exhausted.\n", program_name); - exit (1); - } - datasize = section->size; - - - bfd_get_section_contents (abfd, section, (PTR)data, 0, section->size); - - for (i= 0; i < section->size; i += onaline) { - bfd_size_type j; - printf(" %04lx ", (unsigned long int)(i + section->vma)); - for (j = i; j < i+ onaline; j++) { - if (j < section->size) - printf("%02x", (unsigned)(data[j])); - else - printf(" "); - if ((j & 3 ) == 3) printf(" "); - } - - printf(" "); - for (j = i; j < i+onaline ; j++) { - if (j >= section->size) - printf(" "); - else - printf("%c", isprint(data[j]) ?data[j] : '.'); - } - putchar ('\n'); - } - } - - free (data); - } -} - - - -/* Should perhaps share code and display with nm? */ -void -dump_symbols (abfd) - bfd *abfd; -{ - - unsigned int count; - asymbol **current = syms; - printf("SYMBOL TABLE:\n"); - - for (count = 0; count < symcount; count++) { - - if (*current && (*current)->the_bfd) { - bfd_print_symbol((*current)->the_bfd, - stdout, - *current, bfd_print_symbol_all); - - printf("\n"); - - } - current++; - } - printf("\n"); - printf("\n"); -} - - -void -dump_relocs(abfd) -bfd *abfd; -{ - arelent **relpp; - unsigned int relcount; - asection *a; - for (a = abfd->sections; a != (asection *)NULL; a = a->next) { - printf("RELOCATION RECORDS FOR [%s]:",a->name); - - if (get_reloc_upper_bound(abfd, a) == 0) { - printf(" (none)\n\n"); - } - else { - arelent **p; - - relpp = (arelent **) xmalloc( get_reloc_upper_bound(abfd,a) ); - relcount = bfd_canonicalize_reloc(abfd,a,relpp, syms); - if (relcount == 0) { - printf(" (none)\n\n"); - } - else { - printf("\n"); - printf("OFFSET TYPE VALUE \n"); - - for (p =relpp; relcount && *p != (arelent *)NULL; p++, - relcount --) { - arelent *q = *p; - CONST char *sym_name; - CONST char *section_name = q->section == (asection *)NULL ? "*abs" : - q->section->name; - if (q->sym_ptr_ptr && *q->sym_ptr_ptr) { - sym_name = (*(q->sym_ptr_ptr))->name ; - } - else { - sym_name = 0; - } - if (sym_name) { - printf_vma(q->address); - printf(" %-8s %s", - q->howto->name, - sym_name); - } - else { - printf_vma(q->address); - printf(" %-8s [%s]", - q->howto->name, - section_name); - } - if (q->addend) { - printf("+0x"); - printf_vma(q->addend); - } - printf("\n"); - } - printf("\n\n"); - free(relpp); - } - } - - } -} - -static void -DEFUN_VOID(display_info) -{ - unsigned int i, j; - extern bfd_target *target_vector[]; - - printf("BFD header file version %s\n", BFD_VERSION); - for (i = 0; target_vector[i] != (bfd_target *)NULL; i++) - { - bfd_target *p = target_vector[i]; - bfd *abfd = bfd_openw("##dummy",p->name); - printf("%s\n (header %s, data %s)\n", p->name, - p->header_byteorder_big_p ? "big endian" : "little endian", - p->byteorder_big_p ? "big endian" : "little endian" ); - { - for (j = (int)bfd_arch_obscure +1; j < (int)bfd_arch_last; j++) - { - - if (bfd_set_arch_mach(abfd, (enum bfd_architecture)j, 0)) - printf(" %s\n", - bfd_printable_arch_mach((enum bfd_architecture)j,0)); - - } - - } - } - /* Again as a table */ - printf("%12s"," "); - for (i = 0; target_vector[i]; i++) { - printf("%s ",target_vector[i]->name); - } - printf("\n"); - - - for (j = (int)bfd_arch_obscure +1; (int)j <(int) bfd_arch_last; j++) - { - if (strcmp(bfd_printable_arch_mach(j,0),"UNKNOWN!") != 0) { - printf("%11s ", bfd_printable_arch_mach(j,0)); - for (i = 0; target_vector[i]; i++) { - { - bfd_target *p = target_vector[i]; - bfd *abfd = bfd_openw("##dummy",p->name); - int l = strlen(p->name); - int ok = bfd_set_arch_mach(abfd, j, 0); - if (ok) { - printf("%s ", p->name); - } - else { - while (l--) { - printf("%c",ok?'*':'-'); - } - printf(" "); - } - - } - - } - printf("\n"); - } - } -} -/** main and like trivia */ -int -main (argc, argv) - int argc; - char **argv; -{ - int c; - extern int optind; - extern char *optarg; - char *target = default_target; - boolean seenflag = false; - int ind = 0; - - bfd_init(); - program_name = *argv; - - while ((c = getopt_long (argc, argv, "ib:m:dlfahrtxsj:", long_options, &ind)) - != EOF) { - seenflag = true; - switch (c) { - case 'm': - machine = optarg; - break; - case 'j': - only = optarg; - break; - case 'l': - with_line_numbers = 1; - break; - case 'b': - target = optarg; - break; - case 'f': - dump_file_header = true; - break; - case 'i': - info = true; - break; - case 'x': - dump_symtab = 1; - dump_reloc_info = 1; - dump_file_header = true; - dump_ar_hdrs = 1; - dump_section_headers = 1; - break; - case 0 : break; /* we've been given a long option */ - case 't': dump_symtab = 1; break; - case 'd': disassemble = true ; break; - case 's': dump_section_contents = 1; break; - case 'r': dump_reloc_info = 1; break; - case 'a': dump_ar_hdrs = 1; break; - case 'h': dump_section_headers = 1; break; - default: - usage (); - } - } - - if (seenflag == false) - usage (); - - if (info) { - display_info(); - } - else { - if (optind == argc) - display_file ("a.out", target); - else - for (; optind < argc;) - display_file (argv[optind++], target); - } - return 0; -} diff --git a/binutils/ostrip.c b/binutils/ostrip.c deleted file mode 100755 index a66c76a5ff2..00000000000 --- a/binutils/ostrip.c +++ /dev/null @@ -1,417 +0,0 @@ -/* strip certain symbols from a rel file. - Copyright (C) 1986, 1990 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include "bfd.h" -#include "sysdep.h" -#include "getopt.h" - -#include -#include -#include -#include - -enum strip_action { - strip_undef, - strip_all, /* strip all symbols */ - strip_debug, /* strip all debugger symbols */ -}; - -/* Which symbols to remove. */ -enum strip_action strip_symbols; - -enum locals_action { - locals_undef, - locals_start_L, /* discard locals starting with L */ - locals_all, /* discard all locals */ -}; - -/* Which local symbols to remove. */ -enum locals_action discard_locals; - -/* The name this program was run with. */ -char *program_name; - -struct option long_options[] = { - {"strip-all", 0, 0, 's'}, - {"strip-debug", 0, 0, 'S'}, - {"discard-all", 0, 0, 'x'}, - {"discard-locals", 0, 0, 'X'}, - {0, 0, 0, 0}, -}; - -static char *target = NULL; - -static int fatal_error; - -extern char *malloc(); -extern char *mktemp(); -extern char *realloc(); -extern char *strcpy(); -extern int exit(); -extern int fprintf(); -extern int free(); -extern int getpid(); -extern int kill(); -extern int perror(); -extern int sprintf(); -extern int unlink(); - -#ifdef __STDC__ -static int strip_bfd(bfd *ibfd, bfd *obfd); -static int strip_file(char *filetostrip); -static void usage(void); -#else -static int strip_bfd(); -static int strip_file(); -static void usage(); -#endif /* __STDC__ */ -static void copy_sections (); -static void setup_sections (); - -int main(argc, argv) -char **argv; -int argc; -{ - int ind; - int c; - program_name = argv[0]; - - strip_symbols = strip_undef; /* default is to strip everything. */ - discard_locals = locals_undef; - - while ((c = getopt_long (argc, argv, "gsST:xX", long_options, &ind)) != EOF) { - switch (c) { - case 0: - break; - case 's': - strip_symbols = strip_all; - break; - case 'g': - case 'S': - strip_symbols = strip_debug; - break; - case 'T': - target = optarg; - break; - case 'x': - discard_locals = locals_all; - break; - case 'X': - discard_locals = locals_start_L; - break; - default: - usage (); - } /* switch on option */ - } /* for each option */ - - if (strip_symbols == strip_undef && discard_locals == locals_undef) { - strip_symbols = strip_all; - } /* Default is to strip all symbols. */ - - - if (argc == optind) { - return(strip_file("a.out")); - } else { - int retval = 0; - - for ( ; optind < argc; ++optind) { - retval &= strip_file(argv[optind]); - } /* for each file to strip */ - - return(retval); - } /* if no arguments given */ - -} /* main() */ - -static int delayed_signal; - -void delay_signal(signo) -int signo; -{ - delayed_signal = signo; - signal(signo, delay_signal); -} /* delay_signal() */ - -static int sigint_handled = 0; -static int sighup_handled = 0; -static int sigterm_handled = 0; - -void handle_sigs() { - /* Effectively defer handling of asynchronous kill signals. */ - delayed_signal = 0; - - if (signal (SIGINT, SIG_IGN) != SIG_IGN) { - sigint_handled = 1; - signal(SIGINT, delay_signal); - } /* if not ignored */ - - if (signal (SIGHUP, SIG_IGN) != SIG_IGN) { - sighup_handled = 1; - signal(SIGHUP, delay_signal); - } /* if not ignored */ - - if (signal (SIGTERM, SIG_IGN) != SIG_IGN) { - sigterm_handled = 1; - signal(SIGTERM, delay_signal); - } /* if not ignored */ - - return; -} /* handle_sigs() */ - -void unhandle_sigs() { - /* Effectively undefer handling. */ - if (sigint_handled) - signal (SIGINT, SIG_DFL); - if (sighup_handled) - signal (SIGHUP, SIG_DFL); - if (sigterm_handled) - signal (SIGTERM, SIG_DFL); - - /* Handle any signal that came in while they were deferred. */ - if (delayed_signal) - kill (getpid (), delayed_signal); - - return; -} /* unhandle_sigs() */ - -static int strip_file(filetostrip) -char *filetostrip; -{ - bfd *ibfd; - bfd *obfd; - char tmpfilename[] = "stXXXXXX"; - - if ((ibfd = bfd_openr(filetostrip, (char *)NULL)) == NULL) { - bfd_perror(filetostrip); - return(1); - } /* on error opening input */ - - obfd = bfd_openw(mktemp(tmpfilename), - target? target: bfd_get_target (ibfd)); - if (obfd == NULL) { - bfd_perror(tmpfilename); - - if (bfd_close(ibfd) == false) { - bfd_perror(bfd_get_filename(ibfd)); - } /* on close error */ - - return(1); - } /* on error opening output */ - - handle_sigs(); - - if (bfd_check_format(ibfd, bfd_object) != false) { - if (bfd_set_format(obfd, bfd_get_format(ibfd)) != false) { - if (!strip_bfd(ibfd, obfd)) { - /* success */ - - if (bfd_close(ibfd) == false) { - bfd_perror(bfd_get_filename(ibfd)); - } /* on close error */ - - if (bfd_close(obfd) == false) { - bfd_perror(bfd_get_filename(obfd)); - } /* on close error */ - - rename(tmpfilename, filetostrip); - unhandle_sigs(); - return(0); - } /* strip_bfd prints it's own failing messages */ - } else { - bfd_perror(filetostrip); - } /* can't set format */ - } else { - /* not an object file */ - (void) fprintf(stderr, "File %s has format 0x%x that will not be stripped.\n", - filetostrip, (unsigned) bfd_get_format(ibfd)); - } /* if anything fails along the way */ - - - if (bfd_close(ibfd) == false) { - bfd_perror(bfd_get_filename(ibfd)); - } /* on close error */ - - if (bfd_close(obfd) == false) { - bfd_perror(bfd_get_filename(obfd)); - } /* on close error */ - - if (unlink(tmpfilename)) { - perror(tmpfilename); - } /* on error */ - - unhandle_sigs(); - - return(1); -} /* strip_file() */ - - -boolean -bfd_set_start_address (abfd, new_address) - bfd *abfd; - bfd_vma new_address; -{ - bfd_get_start_address (abfd) = new_address; - return true; -} - - - -static int -strip_bfd(ibfd, obfd) - bfd *ibfd; - bfd *obfd; -{ - if (bfd_set_start_address(obfd, bfd_get_start_address(ibfd)) == false - || bfd_set_file_flags(obfd, bfd_get_file_flags(ibfd) & ~(HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS)) == false - || bfd_set_start_address(obfd, bfd_get_start_address(ibfd)) == false) { - bfd_perror(bfd_get_filename(ibfd)); - return(1); - } /* on error setting file attributes */ - - /* bfd mandates that all output sections be created and sizes set before - any output is done. Thus, we traverse all sections twice. */ - - fatal_error = 0; - bfd_map_over_sections (ibfd, setup_sections, (void *)obfd); - if (!fatal_error) - bfd_map_over_sections (ibfd, copy_sections, (void *)obfd); - return fatal_error; -} - -static void -setup_sections(ibfd, isection, obfd) -bfd *ibfd; -sec_ptr isection; -bfd *obfd; -{ - sec_ptr osection; - char *err; - - do { - err = "making"; - osection = bfd_make_section(obfd, bfd_section_name(ibfd, isection)); - if (osection == NULL) - break; - err = "size"; - if (!bfd_set_section_size(obfd, osection, - bfd_section_size(ibfd, isection))) - break; - err = "vma"; - if (!bfd_set_section_vma(obfd, osection, - bfd_section_vma(ibfd, isection))) - break; - err = "alignment"; - if (!bfd_set_section_alignment(obfd, osection, - bfd_section_alignment(ibfd, isection))) - break; - err = "flags"; - if (!bfd_set_section_flags(obfd, osection, - bfd_get_section_flags(ibfd, isection))) - break; - return; - } while (0); - - (void) fprintf(stderr, "file \"%s\", section \"%s\": error in %s: ", - bfd_get_filename(ibfd), - bfd_section_name(ibfd, isection), - err); - - bfd_perror(""); - fatal_error = 1; -} - -static void -copy_sections(ibfd, isection, obfd) -bfd *ibfd; -sec_ptr isection; -bfd *obfd; -{ - static char *memhunk = NULL; - static unsigned memhunksize = 0; - - sec_ptr osection; - unsigned long size; - flagword iflg; - char *temp; - - osection = bfd_get_section_by_name (obfd, - bfd_section_name(ibfd, isection)); - - size = bfd_section_size(ibfd, isection); - iflg = bfd_get_section_flags(ibfd, isection); - - /* either: - we don't need any memory because there's nothing in this section, - we had no memory so we got some, - we had some memory but not enough so we got more, - or we fail to allocat. */ - - if (size == 0) - return; - - if (memhunk == NULL) { - memhunk = malloc (size); - memhunksize = size; - } - - if (size > memhunksize) { - temp = realloc (memhunk, size); - memhunksize = size; - if (!temp) /* If realloc failed, blow away our mem */ - free (memhunk); - memhunk = temp; - } - - if (memhunk == NULL) { - /* failed to allocate or reallocate */ - /* FIXME, we should just copy in pieces. */ - (void) fprintf(stderr, - "Could not allocate %lu bytes in which to copy section.\n", size); - return; - } - - /* now we have enough memory */ - - if (!bfd_get_section_contents(ibfd, isection, memhunk, 0, size)) { - bfd_perror(bfd_get_filename(ibfd)); - fatal_error = 1; - return; - } - if (!bfd_set_section_contents(obfd, osection, memhunk, 0, size)) { - bfd_perror(bfd_get_filename(obfd)); - fatal_error = 1; - return; - } -} - -void -usage () -{ - fprintf (stderr, "\ -Usage: %s [-gsxSX] [+strip-all] [+strip-debug] [+discard-all]\n\ - [+discard-locals] file...\n", program_name); - exit (1); -} - -/* - * Local Variables: - * comment-column: 0 - * fill-column: 131 - * End: - */ - -/* end of strip.c */ diff --git a/binutils/ranlib.1 b/binutils/ranlib.1 deleted file mode 100644 index f63c0a02788..00000000000 --- a/binutils/ranlib.1 +++ /dev/null @@ -1,80 +0,0 @@ -.\" Copyright (c) 1991 Free Software Foundation -.\" See section COPYING for conditions for redistribution -.\" $Id$ -.TH ranlib 1 "5 November 1991" "cygnus support" "GNU Development Tools" -.de BP -.sp -.ti \-.2i -\(** -.. - -.SH NAME -ranlib\(em\&generate index to archive. - -.SH SYNOPSIS -.hy 0 -.na -.B ranlib \c -.I archive\c -\& -.ad b -.hy 1 -.SH DESCRIPTION -\c -.B ranlib\c -\& generates an index to the contents of an archive, and -stores it in the archive. The index lists each symbol defined by a -member of an archive that is a relocatable object file. - -You may use `\|\c -.B nm \-s\c -\|' or `\|\c -.B nm +print-armap\c -\|' to list this index. - -An archive with such an index speeds up linking to the library, and -allows routines in the library to call each other without regard to -their placement in the archive. - -The GNU \c -.B ranlib\c -\& program is another form of GNU \c -.B ar\c -\&; running -\c -.B ranlib\c -\& is completely equivalent to executing `\|\c -.B ar \-s\c -\|'. - - -.SH "SEE ALSO" -.RB "`\|" binutils "\|'" -entry in -.B -info\c -\&; -.I -The GNU Binary Utilities\c -\&, Roland H. Pesch (October 1991); -.BR ar "(" 1 ")," -.BR nm "(" 1 ")." - - -.SH COPYING -Copyright (c) 1991 Free Software Foundation, Inc. -.PP -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. -.PP -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided that the -entire resulting derived work is distributed under the terms of a -permission notice identical to this one. -.PP -Permission is granted to copy and distribute translations of this -manual into another language, under the above conditions for modified -versions, except that this permission notice may be included in -translations approved by the Free Software Foundation instead of in -the original English. diff --git a/binutils/ranlib.sh b/binutils/ranlib.sh deleted file mode 100755 index 2b6fbc479c6..00000000000 --- a/binutils/ranlib.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -# A simple ranlib script, to use less disk space than a ranlib program. -ar s $1 diff --git a/binutils/size.1 b/binutils/size.1 deleted file mode 100644 index 8b65f6301ae..00000000000 --- a/binutils/size.1 +++ /dev/null @@ -1,174 +0,0 @@ -.\" Copyright (c) 1991 Free Software Foundation -.\" See section COPYING for conditions for redistribution -.\" $Id$ -.TH size 1 "5 November 1991" "cygnus support" "GNU Development Tools" -.de BP -.sp -.ti \-.2i -\(** -.. - -.SH NAME -size\(em\&list section sizes and total size. - -.SH SYNOPSIS -.hy 0 -.na -.TP -.B size -.RB "[\|" \-A \||\| \-B \||\| \c -.BI "+format\ " compatibility\c -\&\|] -.RB "[\|" +help "\|]" -.RB "[\|" \-d \||\| \-o \||\| \-x\c -\||\|\c -.BI "+radix\ " number\c -\&\|] -.RB "[\|" \c -.BI "+target\ " bfdname\c -\&\|] -.RB "[\|" \-V \||\| +version "\|]" -.I objfiles\c -\&.\|.\|. -.ad b -.hy 1 -.SH DESCRIPTION -The GNU \c -.B size\c -\& utility lists the section sizes\(em\&and the total -size\(em\&for each of the object files \c -.I objfiles\c -\& in its argument list. -By default, one line of output is generated for each object file or each -module in an archive. - -.SH OPTIONS -.TP -.IR "objfiles" .\|.\|. -The object files to be examined. - -.TP -.B \-A -.TP -.B \-B -.TP -.BI "+format " "compatibility"\c -\& -Using one of these options, you can choose whether the output from GNU -\c -.B size\c -\& resembles output from System V \c -.B size\c -\& (using `\|\c -.B \-A\c -\|', -or `\|\c -.B +format sysv\c -\|'), or Berkeley \c -.B size\c -\& (using `\|\c -.B \-B\c -\|', or -`\|\c -.B +format berkeley\c -\|'). The default is the one-line format similar to -Berkeley's. - -.TP -.B +help -Show a summary of acceptable arguments and options. - -.TP -.B \-d -.TP -.B \-o -.TP -.B \-x -.TP -.BI "+radix " "number"\c -\& -Using one of these options, you can control whether the size of each -section is given in decimal (`\|\c -.B \-d\c -\|', or `\|\c -.B +radix 10\c -\|'); octal -(`\|\c -.B \-o\c -\|', or `\|\c -.B +radix 8\c -\|'); or hexadecimal (`\|\c -.B \-x\c -\|', or -`\|\c -.B +radix 16\c -\|'). In `\|\c -.B +radix \c -.I number\c -\&\c -\|', only the three -values (8, 10, 16) are supported. The total size is always given in two -radices; decimal and hexadecimal for `\|\c -.B \-d\c -\|' or `\|\c -.B \-x\c -\|' output, or -octal and hexadecimal if you're using `\|\c -.B \-o\c -\|'. - -.TP -.BI "+target " "bfdname"\c -\& -You can specify a particular object-code format for \c -.I objfiles\c -\& as -\c -.I bfdname\c -\&. This may not be necessary; \c -.I size\c -\& can -automatically recognize many formats. See -.BR objdump ( 1 ) -for information -on listing available formats. - -.TP -.B \-V -.TP -.B +version -Display version number information on \c -.B size\c -\& itself. - -.PP - -.SH "SEE ALSO" -.RB "`\|" binutils "\|'" -entry in -.B -info\c -\&; -.I -The GNU Binary Utilities\c -\&, Roland H. Pesch (October 1991); -.BR ar "(" 1 ")," -.BR objdump ( 1 ). - -.SH COPYING -Copyright (c) 1991 Free Software Foundation, Inc. -.PP -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. -.PP -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided that the -entire resulting derived work is distributed under the terms of a -permission notice identical to this one. -.PP -Permission is granted to copy and distribute translations of this -manual into another language, under the above conditions for modified -versions, except that this permission notice may be included in -translations approved by the Free Software Foundation instead of in -the original English. diff --git a/binutils/size.c b/binutils/size.c deleted file mode 100644 index 9f6800c9d33..00000000000 --- a/binutils/size.c +++ /dev/null @@ -1,320 +0,0 @@ -/*** size.c -- report size of various sections of an executable file */ -/* Extensions/incompatibilities: - o - BSD output has filenames at the end. - o - BSD output can appear in different radicies. - o - SysV output has less redundant whitespace. Filename comes at end. - o - SysV output doesn't show VMA which is always the same as the PMA. - o - We also handle core files. - o - We also handle archives. - If you write shell scripts which manipulate this info then you may be - out of luck; there's no +predantic switch. -*/ -#include "sysdep.h" -#include "bfd.h" -#include "getopt.h" - - -#ifndef BSD_DEFAULT -#define BSD_DEFAULT 1 -#endif - -PROTO(void, display_file, (char *filename)); -PROTO(void, print_sizes, (bfd *file)); - -/* Various program options */ - -enum {decimal, octal, hex} radix = decimal; -int berkeley_format = BSD_DEFAULT; /* 0 means use AT&T-style output */ -int show_version = 0; -int show_help = 0; - -/* IMPORTS */ -extern char *program_version; -extern char *program_name; -extern char *target; - -/** main and like trivia */ - -void -usage () -{ - fprintf (stderr, "size %s\nUsage: %s -{dox}{AB}V files ...\n", - program_version, program_name); - fputs("\t+radix={8|10|16} -- select appropriate output radix.\n\ -\t-d -- output in decimal\n\ -\t-o -- output in octal\n\ -\t-x -- output in hex", stderr); - fputs("\t+format={Berkeley|SysV} -- select display format.\n\ -\t-A -- SysV(AT&T) format\n\ -\t-B -- BSD format", stderr); -#if BSD_DEFAULT - fputs("\t (Default is +format=Berkeley)", stderr); -#else - fputs("\t (Default is +format=SysV)", stderr); -#endif - fputs("\t-V, +version -- display program version, etc.\n\ -\t+help -- this message\n", stderr); - exit(1); -} - -struct option long_options[] = {{"radix", 1, 0, 0}, - {"format", 1, 0, 0}, - {"version", 0, &show_version, 1}, - {"target", 2, NULL, NULL}, - {"help", 0, &show_help, 1}, - {0, 0, 0, 0}}; - -int -main (argc, argv) - int argc; - char **argv; -{ - int temp; - int c; /* sez which option char */ - int option_index = 0; - extern int optind; /* steps thru options */ - program_name = *argv; - - while ((c = getopt_long(argc, argv, "ABVdox", long_options, - &option_index)) != EOF) - switch(c) { - case 0: - if (!strcmp("format",(long_options[option_index]).name)) { - switch(*optarg) { - case 'B': case 'b': berkeley_format = 1; break; - case 'S': case 's': berkeley_format = 0; break; - default: printf("Unknown option to +format: %s\n", optarg); - usage(); - } - break; - } - - if (!strcmp("target",(long_options[option_index]).name)) { - target = optarg; - break; - } - - if (!strcmp("radix",(long_options[option_index]).name)) { -#ifdef ANSI_LIBRARIES - temp = strtol(optarg, NULL, 10); -#else - temp = atol(optarg); -#endif - switch(temp) { - case 10: radix = decimal; break; - case 8: radix = octal; break; - case 16: radix = hex; break; - default: printf("Unknown radix: %s\n", optarg); - usage(); - } - } - break; - case 'A': berkeley_format = 0; break; - case 'B': berkeley_format = 1; break; - case 'V': show_version = 1; break; - case 'd': radix = decimal; break; - case 'x': radix = hex; break; - case 'o': radix = octal; break; - case '?': usage(); - } - - if (show_version) printf("%s version %s\n", program_name, program_version); - if (show_help) usage(); - - if (berkeley_format) -#if 0 /* intel doesn't like bss/stk b/c they don't gave core files */ - puts((radix == octal) ? "text\tdata\tbss/stk\toct\thex\tfilename" : - "text\tdata\tbss/stk\tdec\thex\tfilename"); -#else - puts((radix == octal) ? "text\tdata\tbss\toct\thex\tfilename" : - "text\tdata\tbss\tdec\thex\tfilename"); -#endif - if (optind == argc) - display_file ("a.out"); - else - for (; optind < argc;) - display_file (argv[optind++]); - - return 0; -} - -/** Display a file's stats */ - -void -display_bfd (abfd) - bfd *abfd; -{ - char *core_cmd; - - if (bfd_check_format(abfd, bfd_archive)) return; - - if (bfd_check_format(abfd, bfd_object)) { - print_sizes(abfd); - goto done; - } - - if (bfd_check_format(abfd, bfd_core)) { - print_sizes(abfd); - fputs(" (core file", stdout); - - core_cmd = bfd_core_file_failing_command(abfd); - if (core_cmd) printf(" invoked as %s", core_cmd); - - puts(")"); - goto done; - } - - printf("Unknown file format: %s.", bfd_get_filename(abfd)); - - done: - - - printf("\n"); - return; -} - -void -display_file(filename) - char *filename; -{ - bfd *file, *arfile = (bfd *) NULL; - - file = bfd_openr (filename, target); - if (file == NULL) { - bfd_perror (filename); - return; - } - - if (bfd_check_format(file, bfd_archive) == true) { - for(;;) { - - bfd_error = no_error; - - arfile = bfd_openr_next_archived_file (file, arfile); - if (arfile == NULL) { - if (bfd_error != no_more_archived_files) - bfd_perror (bfd_get_filename (file)); - return; - } - - display_bfd (arfile); - /* Don't close the archive elements; we need them for next_archive */ - } - } - else - display_bfd (file); - - bfd_close (file); -} - -/* This is what lexical functions are for */ -void -lprint_number (width, num) - int width, num; -{ - printf ((radix == decimal ? "%-*d\t" : - ((radix == octal) ? "%-*o\t" : "%-*x\t")), width, num); -} - -void -rprint_number(width, num) - int width, num; -{ - printf ((radix == decimal ? "%*d\t" : - ((radix == octal) ? "%*o\t" : "%*x\t")), width, num); -} - -static char *bss_section_name = ".bss"; -static char *data_section_name = ".data"; -static char *stack_section_name = ".stack"; -static char *text_section_name = ".text"; - -void print_berkeley_format(abfd) -bfd *abfd; -{ - sec_ptr bsssection = NULL; - sec_ptr datasection = NULL; - sec_ptr textsection = NULL; - unsigned long bsssize = 0; - unsigned long datasize = 0; - unsigned long textsize = 0; - unsigned long total = 0; - - - if ((textsection = bfd_get_section_by_name (abfd, text_section_name)) - != NULL) { - textsize = bfd_section_size (abfd, textsection); - } - - if ((datasection = bfd_get_section_by_name (abfd, data_section_name)) - != NULL) { - datasize = bfd_section_size(abfd, datasection); - } - - if (bfd_get_format (abfd) == bfd_object) { - if ((bsssection = bfd_get_section_by_name (abfd, bss_section_name)) - != NULL) { - bsssize = bfd_section_size(abfd, bsssection); - } - } else { - if ((bsssection = bfd_get_section_by_name (abfd, stack_section_name)) - != NULL) { - bsssize = bfd_section_size(abfd, bsssection); - } - } - - total = textsize + datasize + bsssize; - - lprint_number (7, textsize); - lprint_number (7, datasize); - lprint_number (7, bsssize); - printf (((radix == octal) ? "%-7o\t%-7x\t" : "%-7d\t%-7x\t"), total, total); - - fputs(bfd_get_filename(abfd), stdout); - if (abfd->my_archive) printf (" (ex %s)", abfd->my_archive->filename); -} - -/* I REALLY miss lexical functions! */ -int svi_total = 0; - -void -sysv_internal_printer(file, sec) - bfd *file; - sec_ptr sec; -{ - int size = bfd_section_size (file, sec); - - svi_total += size; - - printf ("%-12s", bfd_section_name(file, sec)); - rprint_number (8, size); - printf(" "); - rprint_number (8, bfd_section_vma(file, sec)); - printf ("\n"); -} - -void -print_sysv_format(file) - bfd *file; -{ - svi_total = 0; - - printf ("%s ", bfd_get_filename (file)); - if (file->my_archive) printf (" (ex %s)", file->my_archive->filename); - - puts(":\nsection\t\tsize\t addr"); - bfd_map_over_sections (file, sysv_internal_printer, NULL); - - printf("Total "); - rprint_number(8, svi_total); - printf("\n"); printf("\n"); -} - -void -print_sizes(file) - bfd *file; -{ - if (berkeley_format) - print_berkeley_format(file); - else print_sysv_format(file); -} diff --git a/binutils/sparc-pinsn.c b/binutils/sparc-pinsn.c deleted file mode 100644 index 554bdda343a..00000000000 --- a/binutils/sparc-pinsn.c +++ /dev/null @@ -1,526 +0,0 @@ -/* disassemble sparc instructions for objdump - Copyright (C) 1986, 1987, 1989, 1991 Free Software Foundation, Inc. - - -This file is part of the binutils. - -The binutils are 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. - -The binutils are distributed in the hope that they 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 the binutils; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* $Id$ */ - -#include "bfd.h" -#include "sysdep.h" -#include -#include "sparc-opcode.h" - -extern int fputs(); -extern int print_address(); - -static char *reg_names[] = - { "g0", "g1", "g2", "g3", "g4", "g5", "g6", "g7", - "o0", "o1", "o2", "o3", "o4", "o5", "sp", "o7", - "l0", "l1", "l2", "l3", "l4", "l5", "l6", "l7", - "i0", "i1", "i2", "i3", "i4", "i5", "fp", "i7", - "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", - "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", - "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23", - "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31", - "y", "psr", "wim", "tbr", "pc", "npc", "fpsr", "cpsr" }; - -#define freg_names (®_names[4 * 8]) - -union sparc_insn - { - unsigned long int code; - struct - { - unsigned int _OP:2; -#define op ldst._OP - unsigned int _RD:5; -#define rd ldst._RD - unsigned int op3:6; - unsigned int _RS1:5; -#define rs1 ldst._RS1 - unsigned int i:1; - unsigned int _ASI:8; -#define asi ldst._ASI - unsigned int _RS2:5; -#define rs2 ldst._RS2 -#define shcnt rs2 - } ldst; - struct - { - unsigned int _OP:2, _RD:5, op3:6, _RS1:5, i:1; - unsigned int IMM13:13; -#define imm13 IMM13.IMM13 - } IMM13; - struct - { - unsigned int _OP:2; - unsigned int a:1; - unsigned int cond:4; - unsigned int op2:3; - unsigned int DISP22:22; -#define disp22 branch.DISP22 - } branch; -#ifndef NO_V9 - struct - { - unsigned int _OP:2, _RD:5, op3:6, _RS1:5; - unsigned int DISP14:14; -#define disp14 DISP14.DISP14 - } DISP14; - struct - { - unsigned int _OP:2; - unsigned int a:1; - unsigned int cond:4; - unsigned int op2:3; - unsigned int p:1; - unsigned int DISP21:21; -#define disp21 branch2.DISP21 - } branch2; -#endif /* NO_V9 */ - -#define imm22 disp22 - struct - { - unsigned int _OP:2; - unsigned int _DISP30:30; -#define disp30 call._DISP30 - } call; - }; - -/* Nonzero if INSN is the opcode for a delayed branch. */ -static int -is_delayed_branch (insn) - union sparc_insn insn; -{ - unsigned int i; - - for (i = 0; i < NUMOPCODES; ++i) - { - const struct sparc_opcode *opcode = &sparc_opcodes[i]; - if ((opcode->match & insn.code) == opcode->match - && (opcode->lose & insn.code) == 0 - && (opcode->flags&F_DELAYED)) - return 1; - } - return 0; -} - -static int opcodes_sorted = 0; - -/* Print one instruction from MEMADDR on STREAM. */ -int -print_insn_sparc (memaddr, buffer, stream) - bfd_vma memaddr; - bfd_byte *buffer; - FILE *stream; - -{ - union sparc_insn insn; - - register unsigned int i; - - if (!opcodes_sorted) - { - static int compare_opcodes (); - qsort ((char *) sparc_opcodes, NUMOPCODES, - sizeof (sparc_opcodes[0]), compare_opcodes); - opcodes_sorted = 1; - } - -memcpy(&insn,buffer, sizeof (insn)); - - for (i = 0; i < NUMOPCODES; ++i) - { - const struct sparc_opcode *opcode = &sparc_opcodes[i]; - if ((opcode->match & insn.code) == opcode->match - && (opcode->lose & insn.code) == 0) - { - /* Nonzero means that we have found an instruction which has - the effect of adding or or'ing the imm13 field to rs1. */ - int imm_added_to_rs1 = 0; - - /* Nonzero means that we have found a plus sign in the args - field of the opcode table. */ - int found_plus = 0; - - /* Do we have an 'or' instruction where rs1 is the same - as rsd, and which has the i bit set? */ - if (opcode->match == 0x80102000 - && insn.rs1 == insn.rd) - imm_added_to_rs1 = 1; - - if (index (opcode->args, 'S') != 0) - /* Reject the special case for `set'. - The real `sethi' will match. */ - continue; - if (insn.rs1 != insn.rd - && index (opcode->args, 'r') != 0) - /* Can't do simple format if source and dest are different. */ - continue; - - fputs (opcode->name, stream); - - { - register const char *s; - - if (opcode->args[0] != ',') - fputs (" ", stream); - for (s = opcode->args; *s != '\0'; ++s) { - while (*s == ',') { - fputs (",", stream); - ++s; - - switch (*s) { - case 'a': - fputs ("a", stream); - ++s; - continue; -#ifndef NO_V9 - case 'N': - fputs("pn", stream); - ++s; - continue; - - case 'T': - fputs("pt", stream); - ++s; - continue; -#endif /* NO_V9 */ - - default: - break; - } /* switch on arg */ - } /* while there are comma started args */ - - fputs (" ", stream); - - switch (*s) - { - case '+': - found_plus = 1; - - /* note fall-through */ - default: - fprintf (stream, "%c", *s); - break; - - case '#': - fputs ("0", stream); - break; - -#define reg(n) fprintf (stream, "%%%s", reg_names[n]) - case '1': - case 'r': - reg (insn.rs1); - break; - - case '2': - reg (insn.rs2); - break; - - case 'd': - reg (insn.rd); - break; -#undef reg - -#define freg(n) fprintf (stream, "%%%s", freg_names[n]) - case 'e': - freg (insn.rs1); - break; - - case 'f': - freg (insn.rs2); - break; - - case 'g': - freg (insn.rd); - break; -#undef freg - -#define creg(n) fprintf (stream, "%%c%u", (unsigned int) (n)) - case 'b': - creg (insn.rs1); - break; - - case 'c': - creg (insn.rs2); - break; - - case 'D': - creg (insn.rd); - break; -#undef creg - - case 'h': - fprintf (stream, "%%hi(%#x)", - (unsigned int) insn.imm22 << 10); - break; - - case 'i': - { - /* We cannot trust the compiler to sign-extend - when extracting the bitfield, hence the shifts. */ - int imm = ((int) insn.imm13 << 19) >> 19; - - /* Check to see whether we have a 1+i, and take - note of that fact. - - Note: because of the way we sort the table, - we will be matching 1+i rather than i+1, - so it is OK to assume that i is after +, - not before it. */ - if (found_plus) - imm_added_to_rs1 = 1; - - if (imm <= 9) - fprintf (stream, "%d", imm); - else - fprintf (stream, "%#x", (unsigned) imm); - } - break; - -#ifndef NO_V9 - case 'k': - print_address ((bfd_vma) - (memaddr - + (((int) insn.disp14 << 18) >> 18) * 4), - stream); - break; - - case 'K': - print_address ((bfd_vma) - (memaddr - + (((int) insn.disp21 << 11) >> 11) * 4), - stream); - break; - - case 'Y': - fputs ("%amr", stream); - break; - -#endif /* NO_V9 */ - - case 'M': - fprintf(stream, "%%asr%d", insn.rs1); - break; - - case 'm': - fprintf(stream, "%%asr%d", insn.rd); - break; - - case 'L': - print_address ((bfd_vma) memaddr + insn.disp30 * 4, - stream); - break; - - case 'l': - if ((insn.code >> 22) == 0) - /* Special case for `unimp'. Don't try to turn - it's operand into a function offset. */ - fprintf (stream, "%#x", - (unsigned) (((int) insn.disp22 << 10) >> 10)); - else - /* We cannot trust the compiler to sign-extend - when extracting the bitfield, hence the shifts. */ - print_address ((bfd_vma) - (memaddr - + (((int) insn.disp22 << 10) >> 10) * 4), - stream); - break; - - case 'A': - fprintf (stream, "(%d)", (int) insn.asi); - break; - - case 'C': - fputs ("%csr", stream); - break; - - case 'F': - fputs ("%fsr", stream); - break; - - case 'p': - fputs ("%psr", stream); - break; - - case 'q': - fputs ("%fq", stream); - break; - - case 'Q': - fputs ("%cq", stream); - break; - - case 't': - fputs ("%tbr", stream); - break; - - case 'w': - fputs ("%wim", stream); - break; - - case 'y': - fputs ("%y", stream); - break; - } - } - } - - /* If we are adding or or'ing something to rs1, then - check to see whether the previous instruction was - a sethi to the same register as in the sethi. - If so, attempt to print the result of the add or - or (in this context add and or do the same thing) - and its symbolic value. */ - if (imm_added_to_rs1) - { - union sparc_insn prev_insn; - int errcode; - - memcpy(&prev_insn, buffer -4, sizeof (prev_insn)); - - if (errcode == 0) - { - /* If it is a delayed branch, we need to look at the - instruction before the delayed branch. This handles - sequences such as - - sethi %o1, %hi(_foo), %o1 - call _printf - or %o1, %lo(_foo), %o1 - */ - - if (is_delayed_branch (prev_insn)) - memcpy(&prev_insn, buffer - 8, sizeof(prev_insn)); - - } - - /* If there was a problem reading memory, then assume - the previous instruction was not sethi. */ - if (errcode == 0) - { - /* Is it sethi to the same register? */ - if ((prev_insn.code & 0xc1c00000) == 0x01000000 - && prev_insn.rd == insn.rs1) - { - fprintf (stream, "\t! "); - /* We cannot trust the compiler to sign-extend - when extracting the bitfield, hence the shifts. */ - print_address (((int) prev_insn.imm22 << 10) - | (insn.imm13 << 19) >> 19, stream); - } - } - } - - return sizeof (insn); - } - } - - fprintf (stream, "%#8x", insn.code); - return sizeof (insn); -} - - -/* Compare opcodes A and B. */ - -static int -compare_opcodes (a, b) - char *a, *b; -{ - struct sparc_opcode *op0 = (struct sparc_opcode *) a; - struct sparc_opcode *op1 = (struct sparc_opcode *) b; - unsigned long int match0 = op0->match, match1 = op1->match; - unsigned long int lose0 = op0->lose, lose1 = op1->lose; - register unsigned int i; - - /* If a bit is set in both match and lose, there is something - wrong with the opcode table. */ - if (match0 & lose0) - { - fprintf (stderr, "Internal error: bad sparc-opcode.h: \"%s\", %#.8lx, %#.8lx\n", - op0->name, match0, lose0); - op0->lose &= ~op0->match; - lose0 = op0->lose; - } - - if (match1 & lose1) - { - fprintf (stderr, "Internal error: bad sparc-opcode.h: \"%s\", %#.8lx, %#.8lx\n", - op1->name, match1, lose1); - op1->lose &= ~op1->match; - lose1 = op1->lose; - } - - /* Because the bits that are variable in one opcode are constant in - another, it is important to order the opcodes in the right order. */ - for (i = 0; i < 32; ++i) - { - unsigned long int x = 1 << i; - int x0 = (match0 & x) != 0; - int x1 = (match1 & x) != 0; - - if (x0 != x1) - return x1 - x0; - } - - for (i = 0; i < 32; ++i) - { - unsigned long int x = 1 << i; - int x0 = (lose0 & x) != 0; - int x1 = (lose1 & x) != 0; - - if (x0 != x1) - return x1 - x0; - } - - /* They are functionally equal. So as long as the opcode table is - valid, we can put whichever one first we want, on aesthetic grounds. */ - { - int length_diff = strlen (op0->args) - strlen (op1->args); - if (length_diff != 0) - /* Put the one with fewer arguments first. */ - return length_diff; - } - - /* Put 1+i before i+1. */ - { - char *p0 = (char *) index(op0->args, '+'); - char *p1 = (char *) index(op1->args, '+'); - - if (p0 && p1) - { - /* There is a plus in both operands. Note that a plus - sign cannot be the first character in args, - so the following [-1]'s are valid. */ - if (p0[-1] == 'i' && p1[1] == 'i') - /* op0 is i+1 and op1 is 1+i, so op1 goes first. */ - return 1; - if (p0[1] == 'i' && p1[-1] == 'i') - /* op0 is 1+i and op1 is i+1, so op0 goes first. */ - return -1; - } - } - - /* They are, as far as we can tell, identical. - Since qsort may have rearranged the table partially, there is - no way to tell which one was first in the opcode table as - written, so just say there are equal. */ - return 0; -} diff --git a/binutils/strip.1 b/binutils/strip.1 deleted file mode 100644 index d16790babf5..00000000000 --- a/binutils/strip.1 +++ /dev/null @@ -1,143 +0,0 @@ -.\" Copyright (c) 1991 Free Software Foundation -.\" See section COPYING for conditions for redistribution -.\" $Id$ -.TH strip 1 "5 November 1991" "cygnus support" "GNU Development Tools" -.de BP -.sp -.ti \-.2i -\(** -.. - -.SH NAME -strip\(em\&Discard symbols from object files. - -.SH SYNOPSIS -.hy 0 -.na -.TP -.B strip -.RB "[\|" \-s | +strip-all "\|]" -.RB "[\|" \-g | \-S | +strip-debug\c -\|] -.RB "[\|" \-x | +discard-all "\|]" -.RB "[\|" \-X | +discard-locals "\|]" -.RB "[\|" "\-T\ "\c -.I bfdname\c -\&\|] -.I objfiles\c -\&.\|.\|. -.ad b -.hy 1 -.SH DESCRIPTION -GNU \c -.B strip\c -\& will discard all symbols from object files -\c -.I objfiles\c -\&, if no options are specified; or only certain symbols, -depending on its command-line options. - -\c -.B strip\c -\& will not execute unless at least one object file is listed. - -.I WARNING:\c -\& \c -.B strip\c -\& modifies the files named in its argument, -rather than writing modified copies under different names. - -.SH OPTIONS -The long and short forms of options, shown here as alternatives, are -equivalent. - -.TP -.B \-s -.TP -.B +strip-all -This is the default case: strip all symbol entries from \c -.I objfiles\c -\&. - -.TP -.B \-g -.TP -.B \-S -.TP -.B +strip-debug -Discard only debugging symbol information from \c -.I objfiles\c -\&. - -.TP -.B \-x -.TP -.B +discard-all -Discard all symbols local to each file in \c -.I objfiles\c -\&. -\c -.I WARNING:\c -\& Note that \c -.B +discard-all\c -\& discards only \c -.I local\c -\& -symbols, in spite of its name. - -.TP -.B \-X -.TP -.B +discard-locals -Discard local symbols starting with `\|\c -.B L\c -\|' from each file in -\c -.I objfiles\c -\&. (Some compilers produce internally-used symbols that -begin with `\|\c -.B L\c -\|'.) - -.TP -.BI "-T " "bfdname"\c -\& -You can specify a particular object-code format \c -.I bfdname\c -\& for -\c -.I objfiles\c -\&. This may not be necessary; \c -.I strip\c -\& can automatically -recognize many formats. for information on listing -available formats. -.PP - -.SH "SEE ALSO" -.RB "`\|" binutils "\|'" -entry in -.B -info\c -\&; -.I -The GNU Binary Utilities\c -\&, Roland H. Pesch (October 1991). - -.SH COPYING -Copyright (c) 1991 Free Software Foundation, Inc. -.PP -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. -.PP -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided that the -entire resulting derived work is distributed under the terms of a -permission notice identical to this one. -.PP -Permission is granted to copy and distribute translations of this -manual into another language, under the above conditions for modified -versions, except that this permission notice may be included in -translations approved by the Free Software Foundation instead of in -the original English. diff --git a/binutils/strip.c b/binutils/strip.c deleted file mode 100755 index 156b3eb211d..00000000000 --- a/binutils/strip.c +++ /dev/null @@ -1,362 +0,0 @@ -/* strip.c -- strip certain symbols from a rel file. - Copyright (C) 1986, 1990, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* BUGS: When there's not enough memory, this should do the copy - in pieces rather than just fail as it does now */ - -#include "bfd.h" -#include "sysdep.h" -#include "getopt.h" -#include - -/* Various program options */ - -int show_version = 0; - -/* Which symbols to remove. */ -enum strip_action { - strip_undef, - strip_all, /* strip all symbols */ - strip_debug, /* strip all debugger symbols */ -} strip_symbols; - -/* Which local symbols to remove. */ -enum { - locals_undef, - locals_start_L, /* discard locals starting with L */ - locals_all, /* discard all locals */ -} discard_locals; - -extern char *mktemp(); - -/* IMPORTS */ -extern char *program_version; -extern char *program_name; -extern char *target; -extern char *xmalloc(); - -PROTO(static boolean, strip_file, (char *filetostrip)); -PROTO(static void, copy_sections, (bfd *ibfd, sec_ptr isection, bfd *obfd)); -PROTO(static void, setup_sections, (bfd *ibfd, sec_ptr isection, bfd *obfd)); - -/** main, etc */ - -static void -usage () -{ - fprintf (stderr, "strip %s\nUsage: %s [-gsxSX] files ...\n", - program_version, program_name); - exit (1); -} - -struct option long_options[] = {{"strip-all", 0, 0, 's'}, - {"strip-debug", 0, 0, 'S'}, - {"discard-all", 0, 0, 'x'}, - {"discard-locals", 0, 0, 'X'}, - {0, 0, 0, 0} - }; - -int -main (argc, argv) - char **argv; - int argc; -{ - int ind; - int c; - program_name = argv[0]; - - bfd_init(); - - strip_symbols = strip_undef; /* default is to strip everything. */ - discard_locals = locals_undef; - - while ((c = getopt_long (argc, argv, "gsST:xX", long_options, &ind)) != EOF) { - switch (c) { - case 0: - break; - case 's': - strip_symbols = strip_all; - break; - case 'g': - case 'S': - strip_symbols = strip_debug; - break; - case 'T': - target = optarg; - break; - case 'x': - discard_locals = locals_all; - break; - case 'X': - discard_locals = locals_start_L; - break; - default: - usage (); - } - } - - /* Default is to strip all symbols: */ - if (strip_symbols == strip_undef && discard_locals == locals_undef) { - strip_symbols = strip_all; - } - - /* OK, all options now parsed. If no filename specified, do a.out. */ - if (optind == argc) return !strip_file ("a.out"); - - /* We were given several filenames to do: */ - while (optind < argc) - if (!strip_file (argv[optind++])) return 1; - - return 0; -} - -/** Hack signals */ - -/* Why does strip need to do this, and anyway, if it does shouldn't this be - handled by bfd? */ - -static int delayed_signal; - -static int sigint_handled = 0; -static int sighup_handled = 0; -static int sigterm_handled = 0; - -void -delay_signal (signo) - int signo; -{ - delayed_signal = signo; - signal (signo, delay_signal); -} - -/* Effectively defer handling of asynchronous kill signals. */ -void -handle_sigs () /* puff puff */ -{ - delayed_signal = 0; - - if (signal (SIGINT, SIG_IGN) != SIG_IGN) { - sigint_handled = 1; - signal (SIGINT, delay_signal); - } - - if (signal (SIGHUP, SIG_IGN) != SIG_IGN) { - sighup_handled = 1; - signal (SIGHUP, delay_signal); - } - - if (signal (SIGTERM, SIG_IGN) != SIG_IGN) { - sigterm_handled = 1; - signal (SIGTERM, delay_signal); - } - - return; -} - -/* Effectively undefer handling. */ -void -unhandle_sigs () /* put them down */ -{ - if (sigint_handled) signal (SIGINT, SIG_DFL); - - if (sighup_handled) signal (SIGHUP, SIG_DFL); - - if (sigterm_handled) signal (SIGTERM, SIG_DFL); - - /* Handle any signal that came in while they were deferred. */ - if (delayed_signal) - kill (getpid (), delayed_signal); - - return; -} - - -static boolean -strip_file (filetostrip) - char *filetostrip; -{ - static char template[] = "stXXXXXX"; - char *slash; - char *tmpname; - bfd *ibfd; - bfd *obfd; - - ibfd = bfd_openr (filetostrip, target); - - if (ibfd == NULL) bfd_fatal (filetostrip); - - handle_sigs (); /* light up */ - - if (!bfd_check_format (ibfd, bfd_object)) { - fprintf (stderr, "Can't strip %s file %s.\n", - bfd_format_string (bfd_get_format (ibfd)), filetostrip); - exit (1); - } - - slash = strrchr( filetostrip, '/' ); - if ( slash ){ - *slash = 0; - tmpname = xmalloc( strlen(filetostrip) + sizeof(template) + 1 ); - strcpy( tmpname, filetostrip ); - strcat( tmpname, "/" ); - strcat( tmpname, template ); - mktemp( tmpname ); - *slash = '/'; - } else { - tmpname = xmalloc( sizeof(template) ); - strcpy( tmpname, template ); - mktemp( tmpname ); - } - - obfd = bfd_openw (mktemp(tmpname), (target ? target : bfd_get_target (ibfd))); - if (obfd == NULL) bfd_fatal (tmpname); - - if (!bfd_set_format (obfd, bfd_get_format (ibfd))) - bfd_fatal (tmpname); - - - if ((bfd_set_start_address (obfd, bfd_get_start_address (ibfd)) == false) || - (bfd_set_file_flags (obfd, (bfd_get_file_flags (ibfd) & - ~(HAS_LINENO | HAS_DEBUG | HAS_SYMS | - HAS_LOCALS))) == false) || - bfd_set_start_address (obfd, bfd_get_start_address (ibfd)) == false) - bfd_fatal (bfd_get_filename (ibfd)); - - /* Copy architecture of input file to output file */ - if (!bfd_set_arch_mach (obfd, bfd_get_architecture (ibfd), - bfd_get_machine (ibfd))) { - fprintf(stderr, "Output file cannot represent architecture %s", - bfd_printable_arch_mach (bfd_get_architecture(ibfd), - bfd_get_machine (ibfd))); - } - - - /* bfd mandates that all output sections be created and sizes set before - any output is done. Thus, we traverse all sections twice. */ - bfd_map_over_sections (ibfd, setup_sections, (void *)obfd); - bfd_map_over_sections (ibfd, copy_sections, (void *)obfd); - - if (!bfd_close (obfd)) bfd_fatal (filetostrip); - if (!bfd_close (ibfd)) bfd_fatal (filetostrip); - - rename(tmpname, filetostrip); - free(tmpname); - - unhandle_sigs(); - - return true; -} - -/** Actually do the work */ -static void -setup_sections (ibfd, isection, obfd) - bfd *ibfd; - sec_ptr isection; - bfd *obfd; -{ - sec_ptr osection; - char *err; - - osection = bfd_make_section (obfd, bfd_section_name (ibfd, isection)); - if (osection == NULL) { - err = "making"; - goto loser; - } - - if (!bfd_set_section_size(obfd, osection, bfd_section_size(ibfd, isection))) { - err = "size"; - goto loser; - } - - if (!bfd_set_section_vma (obfd, osection, bfd_section_vma (ibfd, isection))) { - err = "vma"; - goto loser; - } - - if (bfd_set_section_alignment (obfd, osection, - bfd_section_alignment (ibfd, isection)) - != true) { - err = "alignment"; - goto loser; - } /* on error, I presume. */ - - if (!bfd_set_section_flags (obfd, osection, - bfd_get_section_flags (ibfd, isection))) { - err = "flags"; - goto loser; - } - - /* All went well */ - return; - - loser: - fprintf (stderr, "%s: file \"%s\", section \"%s\": error in %s: %s\n", - program_name, - bfd_get_filename (ibfd), bfd_section_name (ibfd, isection), - err, bfd_errmsg (bfd_error)); - exit (1); -} - -static void -copy_sections (ibfd, isection, obfd) - bfd *ibfd; - sec_ptr isection; - bfd *obfd; -{ - static unsigned char *memhunk = NULL; - static unsigned memhunksize = 0; - - sec_ptr osection; - unsigned long size; - flagword iflg; - unsigned char *temp; - - osection = bfd_get_section_by_name (obfd, bfd_section_name (ibfd, isection)); - - size = bfd_section_size (ibfd, isection); - iflg = bfd_get_section_flags (ibfd, isection); - - /* either: - we don't need any memory because there's nothing in this section, - we had no memory so we got some, - we had some memory but not enough so we got more, - or we fail to allocat. */ - - if (size == 0) - return; - - if ((iflg & SEC_HAS_CONTENTS) == 0) - return; - - if (memhunk == NULL) { - memhunk = (unsigned char *) xmalloc (size); - memhunksize = size; - } - - if (size > memhunksize) { - temp = (unsigned char *) xrealloc ((char *) memhunk, size); - memhunksize = size; - memhunk = temp; - } - - /* now we have enough memory, just do it: */ - if (!bfd_get_section_contents (ibfd, isection, memhunk, 0, size)) - bfd_fatal (bfd_get_filename (ibfd)); - - if (!bfd_set_section_contents (obfd, osection, memhunk, 0, size)) - bfd_fatal (bfd_get_filename (obfd)); -} diff --git a/binutils/version.c b/binutils/version.c deleted file mode 100644 index aab56dac0dd..00000000000 --- a/binutils/version.c +++ /dev/null @@ -1,5 +0,0 @@ -/*** version.c -- version number for binutils. - They all change in lockstep -- it's easier that way -*/ - -char *program_version = "1.90"; diff --git a/config.sub b/config.sub deleted file mode 100755 index 340aefaa3d0..00000000000 --- a/config.sub +++ /dev/null @@ -1,483 +0,0 @@ -#!/bin/sh - -# Configuration subroutine to validate and canonicalize a configuration type. -# Supply the specified configuration type as an argument. -# If it is invalid, we print an error message on stderr and exit with code 1. -# Otherwise, we print the canonical config type on stdout and succeed. - -# This file is supposed to be the same for all GNU packages -# and recognize all the CPU types, system types and aliases -# that are meaningful with *any* GNU software. -# Each package is responsible for reporting which valid configurations -# it does not support. The user should be able to distinguish -# a failure to support a valid configuration from a meaningless -# configuration (e.g. a typo). - -# Please email any bugs, comments, and/or additions to this file to: -# configure@cygnus.com - -# decode aliases into canonical names -# Note that aliases MUST fit into 12 characters or less otherwise the -# install targets and subdir builds all die on machines that support -# only 14 char file names. They die miserably on machines that rudely -# enforce the 14 character limit. - -case "$1" in -# cpu alone is a valid alias for cpu-none-none. -vax | tahoe | i386 | i860 | m68k | m68000 | m88k | sparc | ns32k \ - | alliant | arm | c1 | c2 | mips | pyramid | tron | a29k \ - | romp | i960 | h8300) - cpu=$1 - vendor=none - os=none - ;; -altos | altos3068) - cpu=m68k - vendor=altos - os=sysv # maybe? - ;; -altosgas) - cpu=m68k - vendor=altos - os=gas - ;; -am29k) - cpu=a29k - vendor=none - os=bsd - ;; -amdahl) - cpu=580 - vendor=amdahl - os=uts - ;; -amigados) - cpu=m68k - vendor=cbm - os=amigados # Native AmigaDOS - ;; -amigaunix | amix) - cpu=m68k - vendor=cbm - os=svr4 # System V Release 4 (svr4 is an industry recognized acronym) - ;; -apollo68) - cpu=m68k - vendor=apollo - os=sysv # maybe? - ;; -balance) - cpu=ns32k - vendor=sequent - os=dynix - ;; -convex-c1) - cpu=c1 - vendor=convex - os=sysv # maybe? - ;; -convex-c2) - cpu=c2 - vendor=convex - os=sysv # maybe? - ;; -cray | ymp) - cpu=ymp - vendor=cray - os=unicos - ;; -cray2) - cpu=cray2 - vendor=cray - os=unicos - ;; -dec3100 | decstatn | decstation | decstation-3100 | pmax | pmin) - cpu=mips - vendor=dec - os=ultrix - ;; -delta | 3300 | motorola-3300 | motorola-delta \ - | 3300-motorola | delta-motorola) - cpu=m68k - vendor=motorola - os=sysv # maybe? - ;; - -delta88) - cpu=m88k - vendor=motorola - os=m88kbcs - ;; - -ebmon29k) - cpu=a29k - vendor=amd - os=ebmon - ;; -gmicro) - cpu=tron - vendor=gmicro - os=sysv # maybe? - ;; - -harris) - cpu=m88k - vendor=harris - os=m88kbcs - ;; - -h8300hds) - cpu=h8300 - vendor=hitachi - os=hds - ;; - -# start-sanitize-life -life) - cpu=life - vendor=philips - os=none - ;; -# end-sanitize-life - -# start-sanitize-v9 -hal-32 | hal32) - cpu=sparc64 - vendor=hal - os=hal32 - ;; -hal-64 | hal64) - cpu=sparc64 - vendor=hal - os=hal64 - ;; -sparc64) - cpu=sparc64 - vendor=sun - os=v9 - ;; -sparc64-v7 | sparc64v7) - cpu=sparc64 - vendor=sun - os=v7 - ;; -# end-sanitize-v9 -hp300bsd) - cpu=m68k - vendor=hp - os=bsd - ;; -hp300hpux | hpux | hp9k3[2-9][0-9]) - cpu=m68k - vendor=hp - os=hpux - ;; -hp9k31[0-9] | hp9k2[0-9][0-9]) - cpu=m68000 - vendor=hp - os=hpux - ;; -i386sco) - cpu=i386 - vendor=sco - os=sysv32 # maybe? - ;; -i386v) - cpu=i386 - vendor=none - os=sysv - ;; -i386v32) - cpu=i386 - vendor=none - os=sysv32 - ;; -iris | iris4d) - cpu=mips - vendor=sgi - os=irix # maybe? - ;; - -dpx2) - vendor=bull - cpu=m68k - os=sysv - ;; -isi | isi68) - cpu=m68k - vendor=isi - os=sysv # maybe? - ;; -littlemips) - cpu=mips - vendor=little - os=bsd - ;; -magnum | m3230) - cpu=mips - vendor=mips - os=sysv # maybe? - ;; -merlin) - cpu=ns32k - vendor=utek - os=sysv # maybe? - ;; -miniframe) - cpu=m68000 - vendor=convergent - os=sysv # maybe? - ;; -mmax) - cpu=ns32k - vendor=encore - os=sysv # maybe? - ;; -news | news700 | news800 | news900) - cpu=m68k - vendor=sony - os=newsos # newsos3c or newsos4c, c stands for cisc. Based on bsd-4.3. - ;; -news1000) - cpu=m68030 - vendor=sony - os=newsos - ;; -news-3600 | bigmips | risc-news) - cpu=mips - vendor=sony - os=newsos # Presumably newsos4r, r stands for risc. Based on bsd-4.3. - ;; -next) - cpu=m68k - vendor=next - os=sysv # maybe? - ;; -nindy960) - cpu=i960 - vendor=intel - os=nindy - ;; -none) - cpu=none - vendor=none - os=none - ;; -np1) - cpu=np1 - vendor=gould - os=sysv # maybe? - ;; -rtpc) - cpu=romp - vendor=ibm - os=aix # maybe? - ;; -pbd) - cpu=sparc - vendor=unicom - os=sysv - ;; -pn) - cpu=pn - vendor=gould - os=sysv # maybe? - ;; -rs6000) - cpu=rs6000 - vendor=ibm - os=aix - ;; -ps2) - cpu=i386 - vendor=ibm - os=sysv # maybe? - ;; -sun2) - cpu=m68000 - vendor=sun - os=sunos4 - ;; -sun2os3) - cpu=m68000 - vendor=sun - os=sunos3 - ;; -sun2os4) - cpu=m68000 - vendor=sun - os=sunos4 - ;; -sun3) - cpu=m68k - vendor=sun - os=sunos4 - ;; -sun3os3) - cpu=m68k - vendor=sun - os=sunos3 - ;; -sun3os4) - cpu=m68k - vendor=sun - os=sunos4 - ;; -sun386 | roadrunner | sun386i) - cpu=i386 - vendor=sun - os=sunos - ;; -sun4) - cpu=sparc - vendor=sun - os=sunos4 - ;; -sun4os3) - cpu=sparc - vendor=sun - os=sunos3 - ;; -sun4os4) - cpu=sparc - vendor=sun - os=sunos4 - ;; -symmetry) - cpu=i386 - vendor=sequent - os=dynix - ;; -tower | tower-32) - cpu=m68k - vendor=ncr - os=sysv # maybe? - ;; -ultra3) - cpu=a29k - vendor=nyu - os=sym1 - ;; -umax) - cpu=ns32k - vendor=encore - os=sysv # maybe? - ;; -unixpc | safari | pc7300 | 3b1 | 7300 | 7300-att | att-7300) - cpu=m68k - vendor=att - os=sysv # maybe? - ;; -vax-dec) - cpu=vax - vendor=dec - os=ultrix # maybe? - ;; -vxworks68) - cpu=m68k - vendor=wrs - os=vxworks - ;; -vxworks960) - cpu=i960 - vendor=wrs - os=vxworks - ;; -xmp) - cpu=xmp - vendor=cray - os=unicos - ;; -# not an alias. parse what we expect to be a canonical name. -*) - cpu=`echo $1 | sed 's/-.*$//'` - - if [ "${cpu}" = "$1" ] ; then - # no vendor so this is an invalid name. - echo '***' Configuration \"$1\" not recognized 1>&2 - exit 1 - else - # parse out vendor - rest=`echo $1 | sed "s/${cpu}-//"` - vendor=`echo ${rest} | sed 's/-.*$//'` - - if [ "${vendor}" = "${rest}" ] ; then - # a missing os is acceptable - os=none - else - os=`echo ${rest} | sed "s/${vendor}-//"` - fi - fi - ;; -esac - -# At this point we should have three parts of a canonical name in cpu, -# vendor, and os. - -# verify that the cpu is known. - -case "${cpu}" in -none | vax | tahoe | i386 | i860 | m68k | m68000 | m88k | sparc \ - | ns32k | alliant | arm | c1 | c2 | mips | pyramid | tron \ - | a29k | romp | rs6000 | i960 | xmp | ymp | cray2 | 580 | h8300) - ;; - -# start-sanitize-life -life) ;; -# end-sanitize-life - -# start-sanitize-v9 -sparc64) ;; -# end-sanitize-v9 - -*) - echo '***' Invalid cpu \`${cpu}\': configuration \`$1\' not recognized 1>&2 - exit 1 - ;; -esac - -# verify that the vendor is known. - -case "${vendor}" in - altos | amd | amdahl | aout | apollo | att | bcs | bout |\ - cbm | convergent | convex | coff | cray | dec | encore |\ - gould | harris | hitachi | intel | isi | hp | ibm | little | mips | motorola | \ - ncr | next | none | nyu | sco | sequent | sgi | sony | sun |\ - unicom | utek | wrs | bull ) ;; - -# start-sanitize-life -philips) ;; -# end-sanitize-life - -# start-sanitize-v9 -hal) ;; -# end-sanitize-v9 - -*) - echo '***' Invalid vendor \`${vendor}\': configuration \`$1\' not recognized 1>&2 - exit 1 - ;; -esac - -# verify that the os is known, if it exists. - -case "${os}" in -aix* | aout | bout | bsd* | coff | ctix* | dgux* | dynix* | esix* \ - | ebmon | hpux* \ - | hds | irix* | isc* | kern | mach* | msdos* | newsos* | nindy* | none \ - | osf* | sco* | sunos* | sysv* | ultrix* | unos* | v88r* \ - | vms* | vxworks* | sym[1-9]* | unicos* | uts | svr4 | m88kbcs \ - | amigados) - ;; - -# start-sanitize-v9 -hal32 | hal64 | v7 | v9) ;; -# end-sanitize-v9 - -*) - echo '***' Invalid os \`${os}\': configuration \`$1\' not recognized 1>&2 - exit 1 - ;; -esac - -echo ${cpu}-${vendor}-${os} diff --git a/config/.Sanitize b/config/.Sanitize deleted file mode 100644 index dac15c0a0c2..00000000000 --- a/config/.Sanitize +++ /dev/null @@ -1,71 +0,0 @@ -# Sanitize.in for devo. -# $Id$ -# - -# Each directory to survive it's way into a release will need a file -# like this one called "./.Sanitize". All keyword lines must exist, -# and must exist in the order specified by this file. Each directory -# in the tree will be processed, top down, in the following order. - -# Hash started lines like this one are comments and will be deleted -# before anything else is done. Blank lines will also be squashed -# out. - -# The lines between the "Do-first:" line and the "Things-to-keep:" -# line are executed as a /bin/sh shell script before anything else is -# done in this - -Do-first: - -echo Sanitizing `pwd`... - -# All files listed between the "Things-to-keep:" line and the -# "Files-to-sed:" line will be kept. All other files will be removed. -# Directories listed in this section will have their own Sanitize -# called. Directories not listed will be removed in their entirety -# with rm -rf. - -Things-to-keep: - -mh-delta88 -mh-dgux -mh-svr4 -mh-sysv -mt-a29k -mt-ebmon29k -mh-rs6000 -Do-last: - -echo Done in `pwd`. - -# -# -# $Log$ -# Revision 1.6 1991/11/05 21:16:30 sac -# Added mh-rs6000 -# -# Revision 1.5 1991/11/05 20:58:27 sac -# renamed to make: -# mh-delta88 -# mh-dgux -# mh-svr4 -# mh-sysv -# mt-a29k -# mt-ebmon29k -# -# Revision 1.4 1991/10/04 06:49:00 gnu -# SVR4 support -# -# Revision 1.3 1991/09/17 06:53:29 grossman -# sgi/irix config stuff. -# -# Revision 1.2 1991/06/14 22:21:28 steve -# *** empty log message *** -# -# Revision 1.1 1991/05/23 17:05:04 rich -# Initial revision -# -# -# - -# End of file. diff --git a/config/mh-delta88 b/config/mh-delta88 deleted file mode 100644 index cde68713451..00000000000 --- a/config/mh-delta88 +++ /dev/null @@ -1,7 +0,0 @@ -RANLIB = echo >/dev/null -# Sorry about this, but my machine runs out of memory . -MINUS_G = -CC=gcc -O2 - - - diff --git a/config/mh-dgux b/config/mh-dgux deleted file mode 100644 index ce5db78d644..00000000000 --- a/config/mh-dgux +++ /dev/null @@ -1,4 +0,0 @@ -HDEFINES=-DHOST_SYS=DGUX_SYS -CC=gcc -Wall -ansi -D__using_DGUX -RANLIB=echo >/dev/null - diff --git a/config/mh-sco b/config/mh-sco deleted file mode 100644 index e2897502f05..00000000000 --- a/config/mh-sco +++ /dev/null @@ -1,4 +0,0 @@ -# Define SYSV as -DSYSV if you are using a System V operating system. -SYSV = -DSYSV -RANLIB = echo >/dev/null -BISON = yacc -Sm10400 diff --git a/config/mh-svr4 b/config/mh-svr4 deleted file mode 100755 index 0208c2dc1a3..00000000000 --- a/config/mh-svr4 +++ /dev/null @@ -1,6 +0,0 @@ -# Define SYSV as -DSYSV if you are using a System V operating system. -SYSV = -DSYSV -DSVR4 -RANLIB = echo >/dev/null - -# The l flag generates a warning from the SVR4 archiver, remove it. -AR_FLAGS = cq diff --git a/config/mh-sysv b/config/mh-sysv deleted file mode 100644 index f682838fff1..00000000000 --- a/config/mh-sysv +++ /dev/null @@ -1,3 +0,0 @@ -# Define SYSV as -DSYSV if you are using a System V operating system. -SYSV = -DSYSV -RANLIB = echo >/dev/null diff --git a/config/mt-a29k b/config/mt-a29k deleted file mode 100644 index fdaa41e4281..00000000000 --- a/config/mt-a29k +++ /dev/null @@ -1,9 +0,0 @@ -#AR = ar-a29k -#AR_FLAGS = qs -#RANLIB = echo >/dev/null - -# This is a hack. By declaring subdirs using "SUBDIRS=" rather than -# with a space, config won't reset this. This is a hack to override -# the set of directories to be made. -SUBDIRS= binutils gas gnulib gcc clib - diff --git a/config/mt-ebmon29k b/config/mt-ebmon29k deleted file mode 100644 index 1304238519d..00000000000 --- a/config/mt-ebmon29k +++ /dev/null @@ -1,9 +0,0 @@ - -# don't build gnulib -INSTALL_GNULIB = -INSTALL_HEADERS = - -# Turn off focred include mangling -INSTALL_FIXED_INCLUDES= nothing -INSTALL_USR_LOCAL = nothing - diff --git a/configure b/configure deleted file mode 100755 index fe1eee8f90c..00000000000 --- a/configure +++ /dev/null @@ -1,837 +0,0 @@ -#!/bin/sh - -# Configuration script -# Copyright (C) 1988, 1990, 1991 Free Software Foundation, Inc. - -#This file is part of GNU. - -# 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -# $Id$ - -# Please email any bugs, comments, and/or additions to this file to: -# configure@cygnus.com - -# -# Shell script to create proper links to machine-dependent files in -# preparation for compilation. -# -# If configure succeeds, it leaves its status in config.status. -# If configure fails after disturbing the status quo, -# config.status is removed. -# - -export PATH || (echo "OOPS, this isn't sh. Desperation time. I will feed myself to sh."; sh $0 $argv; kill $$) - -#set -e - -remove=rm -hard_link=ln -symbolic_link='ln -s' - -#for Test -#remove="echo rm" -#hard_link="echo ln" -#symbolic_link="echo ln -s" - -# clear some things potentially inherited from environment. - -Makefile=Makefile -Makefile_in=Makefile.in -ansi= -arguments=$* -commontargets= -configdirs= -ddestdir= -defaulttargets= -destdir= -fatal= -hostsubdir= -idestdir= -next_ddestdir= -next_destdir= -next_idestdir= -next_objdir= -next_site= -next_target= -next_tmpdir= -norecursion= -objdir= -objdiroption= -progname= -recurring= -removing= -srcdir= -srctrigger= -target= -targets= -targetsubdir= -verbose= -# or maybe grab from gcc/version.c -version_path="1.95.02" -for arg in $*; -do - # handle things that might have args following as separate words - if [ -n "${next_ddestdir}" ] ; then ddestdir=${arg} ; next_ddestdir= - elif [ -n "${next_destdir}" ] ; then destdir=${arg} ; next_destdir= ; ddestdir=${destdir} ; idestdir=${destdir} - elif [ -n "${next_idestdir}" ] ; then idestdir=${arg} ; next_idestdir= - elif [ -n "${next_objdir}" ] ; then objdir=${arg} ; next_objdir= - elif [ -n "${next_site}" ] ; then site=${arg} ; next_site= - elif [ -n "${next_target}" ] ; then - next_target= - if [ -n "${targets}" ] ; then - subdirs="+subdirs" - fi - - newtargets="${targets} ${arg}" - targets="${newtargets}" - - elif [ -n "${next_tmpdir}" ] ; then - next_tmpdir= - tmpdiroption="+tmpdir=${arg}" - TMPDIR=${arg} - - else - case ${arg} in - -ansi | +a*) - ansi=true - clib=clib - ;; - -noversion | +noversion) - version_path="" - ;; - -ddestdir=* | +ddestdir=* | +ddestdi=* | +ddestd=* | +ddest=* | +ddes=* | +dde=* | +dd=*) - ddestdir=`echo ${arg} | sed 's/[+-]dd[a-z]*=//'` - ;; - -ddestdir | +ddestdir | +ddestdi | +ddestd | +ddest | +ddes | +dde | +dd) - next_ddestdir=yes - ;; - -destdir=* | +destdir=* | +destdi=* | +destd=* | +dest=* | +des=* | +de=*) - destdir=`echo ${arg} | sed 's/[+-]d[a-z]*=//'` - ddestdir=${destdir} - idestdir=${destdir} - ;; - -destdir | +destdir | +destdi | +destd | +dest | +des | +de) - next_destdir=yes - ;; - -gas | +g*) - gas=yes - ;; - -help | +h*) - fatal=true - ;; - -idestdir=* | +idestdir=* | +idestdi=* | +idestd=* | +idest=* | +ides=* | +ide=* | +id=*) - idestdir=`echo ${arg} | sed 's/[+-]id[a-z]*=//'` - ;; - -idestdir | +idestdir | +idestdi | +idestd | +idest | +ides | +ide | +id) - next_idestdir=yes - ;; - -languages=* | +languages=* | +language=* | +languag=* \ - | +langua=* | +langu=* | +lang=* | +lan=* | +la=* \ - | +l=*) - languages="${languages} `echo ${arg} | sed 's/[+-]l[a-z]*=//'`" - ;; - -nfp | +nf*) - nfp=yes - ;; - -norecursion | +no*) - norecursion=true - ;; - -objdir=* | +objdir=* | +objdi=* | +objd=* | +obj=* | +ob=* | +o=*) - objdiroption=${arg} - objdir=`echo ${arg} | sed 's/[+-]o[a-z]*=//'` - ;; - -objdir | +objdir | +objdi | +objd | +obj | +ob | +o) - next_objdir=yes - ;; - -recurring | +recurring | +recurrin | +recurri | +recurr | +recur | +recu | +rec | +re) - recurring=true - arguments=`echo ${arguments} | sed "s:${arg}::"` - ;; - -rm | +rm) - removing=${arg} - ;; - -site=* | +site=* | +sit=* | +si=*) - site=`echo ${arg} | sed 's/[+-]s[a-z]*=//'` - ;; - -site | +site | +sit | +si) - next_site=yes - ;; - # -srcdir=* | +srcdir=* | +srcdi=* | +srcd=* | +src=* | +sr=*) - # srcdir=`echo ${arg} | sed 's/[+-]s[a-z]*=//'` - # ;; - -subdirs | +su*) - subdirs=${arg} - ;; - -target=* | +target=* | +targe=* | +targ=* | +tar=* | +ta=*) - if [ -n "${targets}" ] ; then - subdirs="+subdirs" - fi - - newtargets="${targets} `echo ${arg} | sed 's/[+-]t[a-z]*=//'`" - targets="${newtargets}" - ;; - -target | +target | +targe | +targ | +tar | +ta) - next_target=yes - ;; - -tmpdir=* | +tmpdir=* | +tmpdi=* | +tmpd=* | +tmp=* | +tm=*) - tmpdiroption=${arg} - TMPDIR=`echo ${arg} | sed 's/[+-]t[a-z]*=//'` - ;; - -tmpdir | +tmpdir | +tmpdi | +tmpd | +tmp | +tm) - next_tmpdir=yes - ;; - -v | -verbose | +v*) - verbose=${arg} - ;; - -* | +*) - (echo ; - echo "Unrecognized option: \"${arg}\"". ; - echo) 1>&2 - fatal=true - ;; - *) - if [ -n "${hosts}" ] ; then - subdirs="+subdirs" - fi - - newhosts="${hosts} ${arg}" - hosts=${newhosts} - ;; - esac - fi -done - -if [ -n "${verbose}" ] ; then - echo $0 $* -fi - -## this is a little touchy and won't always work, but... -## -## if the argv[0] starts with a slash then it is an absolute name that can be -## used as is. -## -## otherwise, if argv[0] has no slash in it, we can assume that it is on the -## path. Since PATH might include "." we also add `pwd` to the end of PATH. -## -## otherwise we prepend `pwd` to $0 and hope that will give us an absolute -## path. -## - -if (echo $0 | grep '^/' > /dev/null) ; then - progname=$0 -else - if (echo $0 | grep '/' > /dev/null) ; then - progname=`pwd`/$0 - else - progname=$0 - PATH=$PATH:`pwd` ; export PATH - fi -fi - -configsub=`echo ${progname} | sed 's/configure$/config.sub/'` - -if ${configsub} none >/dev/null 2>&1 ; then - true -else - echo '***' cannot find config.sub. - echo 1 -fi - -# process host and target only if not removing. -if [ -z "${removing}" -a -z "${fatal}" ] ; then - # Complain if an arg is missing - if [ -z "${hosts}" ] ; then - (echo ; - echo "configure: No HOST specified." ; - echo) 1>&2 - fatal=true - fi -fi - -if [ -n "${fatal}" -o "${hosts}" = "help" ] ; then - (echo "Usage: configure HOST" ; - echo ; - echo "Options: [defaults in brackets]" ; - echo " +ansi configure w/ANSI library. [no ansi lib]" ; - echo " +ddestdir=MYDIR configure for installation host dependent files" ; - echo " into MYDIR. [\"/usr/local\"]" ; - echo " +idestdir=MYDIR configure for installation host independent files" ; - echo " into MYDIR. [\"/usr/local\"]" ; - echo " +destdir=MYDIR configure for installation of both host dependent and" ; - echo " host independent files into MYDIR. [\"/usr/local\"]" ; - echo " +gas configure the compilers for use with gas. [native as]" ; - echo " +help print this message. [normal config]" ; - echo " +lang=LANG configure to build LANG. [gcc]" ; - echo " +nfp configure the compilers default to soft floating point. [hard float]" ; - echo " +norecursion configure this directory only. [recurse]" ; - echo " +objdir=ODIR configure in a parallel tree rooted in ODIR. [rooted in \".\"]" ; - echo " +rm remove this configuration. [build a configuration]" ; - echo " +site configure with site specific makefile" ; -# This is correctly aligned in the output, even though it isn't here. - echo " +subdirs configure in subdirectories. [in source directories]" ; - echo " +target=TARGET configure for TARGET. [TARGET = HOST]" ; - echo " +tmpdir=TMPDIR create temporary files in TMPDIR. [ TMPDIR = \"/tmp\" ]" ; - echo ; - echo "Where HOST and TARGET are something like \"vax\", \"sun3\", \"encore\", etc." ; - echo "Asking for more than one \"+target\" implies \"+subdirs\". Any other" ; - echo "options given will apply to all targets.") 1>&2 - - if [ -r config.status ] ; then - cat config.status - fi - - exit 1 -fi - -### break up configure.in. -if [ -r configure.in ] ; then - if [ -z "`grep '^# per\-host:' configure.in`" ] ; then - echo '***' `pwd`/configure.in has no "per-host:" line. 1>&2 - exit 1 - fi - - if [ -z "`grep '^# per\-target:' configure.in`" ] ; then - echo '***' `pwd`/configure.in has no "per-target:" line. 1>&2 - exit 1 - fi - - if [ -z "${TMPDIR}" ] ; then - TMPDIR=/tmp ; export TMPDIR - fi - - # keep this filename short for &%*%$*# 14 char file names - tmpfile=${TMPDIR}/cONf$$ - - # split configure.in into common, per-host, per-target, - # and post-target parts. Post-target is optional. - sed -e '/^# per\-host:/,$d' configure.in > ${tmpfile}.com - sed -e '1,/^# per\-host:/d' -e '/^# per\-target:/,$d' configure.in > ${tmpfile}.hst - if grep '^# post-target:' configure.in >/dev/null ; then - sed -e '1,/^# per\-target:/d' -e '/^# post\-target:/,$d' configure.in > ${tmpfile}.tgt - sed -e '1,/^# post\-target:/d' configure.in > ${tmpfile}.pos - else - sed -e '1,/^# per\-target:/d' configure.in > ${tmpfile}.tgt - echo >${tmpfile}.pos - fi - -else - echo '***' No configure.in in `pwd` - exit 1 -fi - -### do common part of configure.in - -. ${tmpfile}.com - -# some sanity checks on configure.in -if [ -z "${srctrigger}" ] ; then - echo '***' srctrigger not set in `pwd`/configure.in. - exit 1 -fi - -for host in ${hosts} ; do - # Default other arg - if [ -z "${targets}" -o -n "${defaulttargets}" ] ; then - targets=${host} - defaulttargets=true - fi - - host_alias=${host} - - result=`${configsub} ${host}` - host_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'` - host_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'` - host_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'` - host=${host_cpu}-${host_vendor}-${host_os} - host_makefile_frag=config/mh-${host} - if [ ! -f ${host_makefile_frag} ] - then - host_makefile_frag=config/mh-${host_alias} - fi - - . ${tmpfile}.hst - - for target in ${targets} ; do - - target_alias=${target} - result=`${configsub} ${target}` - target_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'` - target_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'` - target_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'` - target=${target_cpu}-${target_vendor}-${target_os} - target_makefile_frag=config/mt-${target} - if [ ! -f ${target_makefile_frag} ] - then - target_makefile_frag=config/mt-${target_alias} - fi - - . ${tmpfile}.tgt - - hostsubdir=H-${host_alias} - targetsubdir=T-${target_alias} - - if [ -n "${removing}" ] ; then - if [ -n "${objdir}" ] ; then - echo '***' +rm not supported for +objdir. Just \"rm -rf ${objdir}\" by hand. - exit 1 - fi - - if [ -n "${subdirs}" ] ; then - if [ -d "${hostsubdir}" ] ; then - rm -rf ${hostsubdir}/${targetsubdir} - - if [ -z "`(ls ${hostsubdir}) 2>&1 | grep T- | grep -v T-independent`" ] ; then - rm -rf ${hostsubdir} - fi - else - echo Warning: no `pwd`/${hostsubdir} to remove. - fi - else - rm -f ${Makefile} config.status ${links} - fi - else - if [ -n "${objdir}" ]; then - srcdir=`pwd` - cd ${objdir} - fi - - if [ -n "${subdirs}" ] ; then - # check for existing status before allowing forced subdirs. - if [ -f ${Makefile} ] ; then - echo '***' "${Makefile} already exists in source directory. `pwd` not configured." 1>&2 - exit 1 - fi - - if [ ! -d ${hostsubdir} ] ; then mkdir ${hostsubdir} ; fi - cd ${hostsubdir} - - if [ ! -d ${targetsubdir} ] ; then - if [ -z "${commontargets}" ] ; then - mkdir ${targetsubdir} - else - if [ ! -d T-independent ] ; then - mkdir T-independent - fi - - ${symbolic_link} T-independent ${targetsubdir} - fi # if target independent - fi # if no target dir yet - - cd ${targetsubdir} - - if [ -z "${srcdir}" ] ; then - srcdir=../.. - fi - else - # if not subdir builds, then make sure none exist. - if [ -n "`(ls .) 2>&1 | (grep H- ; true)`" ] ; then - echo '***' "Configured subdirs exist. `pwd` not configured." 1>&2 - exit 1 - else - true - fi - fi - - # Find the source files, if location was not specified. - if [ -z "${srcdir}" ] ; then - srcdirdefaulted=1 - srcdir=. - if [ -n "${srctrigger}" -a ! -r ${srctrigger} ] ; then - srcdir=.. - fi - fi - - if [ -n "${srctrigger}" -a ! -r ${srcdir}/${srctrigger} ] ; then - if [ -z "${srcdirdefaulted}" ] ; then - echo '***' "${progname}: Can't find ${srcname} sources in `pwd`/${srcdir}" 1>&2 - else - echo '***' "${progname}: Can't find ${srcname} sources in `pwd`/. or `pwd`/.." 1>&2 - fi - - echo '***' \(At least ${srctrigger} is missing.\) 1>&2 - exit 1 - fi - - # Set up the list of links to be made. - # ${links} is the list of link names, and ${files} is the list of names to link to. - - # Make the links. - while [ -n "${files}" ] ; do - # set file to car of files, files to cdr of files - set ${files}; file=$1; shift; files=$* - set ${links}; link=$1; shift; links=$* - - if [ ! -r ${srcdir}/${file} ] ; then - echo '***' "${progname}: cannot create a link \"${link}\"," 1>&2 - echo '***' "since the file \"${file}\" does not exist." 1>&2 - exit 1 - fi - - ${remove} -f ${link} - rm -f config.status - # Make a symlink if possible, otherwise try a hard link - ${symbolic_link} ${srcdir}/${file} ${link} 2>/dev/null || ${hard_link} ${srcdir}/${file} ${link} - - if [ ! -r ${link} ] ; then - echo '***' "${progname}: unable to link \"${link}\" to \"${srcdir}/${file}\"." 1>&2 - exit 1 - fi - - if [ -n "${verbose}" ] ; then - echo "Linked \"${link}\" to \"${srcdir}/${file}\"." - fi - done - - # Create a .gdbinit file which runs the one in srcdir - # and tells GDB to look there for source files. - - case ${srcdir} in - .) - ;; - *) - echo "dir ." > .gdbinit - echo "dir ${srcdir}" >> .gdbinit - echo "source ${srcdir}/.gdbinit" >> .gdbinit - ;; - esac - - # Install a makefile, and make it set VPATH - # if necessary so that the sources are found. - # Also change its value of srcdir. - - # FIXME-someday: This business of always writing to .tem and mv back - # is so that I don't screw things up while developing. Once this - # template is stable, these should be optimized. xoxorich. - - # Define macro CROSS_COMPILE in compilation if this is a cross-compiler. - if [ "${host}" != "${target}" ] ; then - echo "CROSS=-DCROSS_COMPILE" > ${Makefile} - echo "ALL=start.encap" >> ${Makefile} - else - echo "ALL=all.internal" > ${Makefile} - fi - - # set target, host, VPATH - echo "host_alias = ${host_alias}" >> ${Makefile} - echo "host_cpu = ${host_cpu}" >> ${Makefile} - echo "host_vendor = ${host_vendor}" >> ${Makefile} - echo "host_os = ${host_os}" >> ${Makefile} - echo "version_path = ${version_path}" >> ${Makefile} - echo "target_alias = ${target_alias}" >> ${Makefile} - echo "target_cpu = ${target_cpu}" >> ${Makefile} - echo "target_vendor = ${target_vendor}" >> ${Makefile} - echo "target_os = ${target_os}" >> ${Makefile} - - if [ -n "${subdirs}" ] ; then - (echo "subdir = /${hostsubdir}/${targetsubdir}" ; - echo "unsubdir = ../..") >> ${Makefile} - else - (echo "subdir =" ; - echo "unsubdir = .") >> ${Makefile} - fi - - # echo "workdir = `pwd`" >> ${Makefile} - echo "VPATH = ${srcdir}" >> ${Makefile} - - # add "Makefile.in" (or whatever it's called) - cat ${srcdir}/${Makefile_in} >> ${Makefile} - - # Conditionalize the makefile for this site. - if [ -n "${site}" ] ; then - site_makefile_frag=config/ms-${site} - - if [ -f ${srcdir}/${site_makefile_frag} ] ; then - (echo "site_makefile_frag = ${srcdir}/${site_makefile_frag}" ; - sed -e "/^####/ r ${srcdir}/${site_makefile_frag}" ${Makefile}) > Makefile.tem - else - (echo "site_makefile_frag =" ; - cat ${Makefile}) > Makefile.tem - fi - mv Makefile.tem ${Makefile} - fi - - # Conditionalize the makefile for this host. - if [ -f ${srcdir}/${host_makefile_frag} ] ; then - (echo "host_makefile_frag = ${srcdir}/${host_makefile_frag}" ; - sed -e "/^####/ r ${srcdir}/${host_makefile_frag}" ${Makefile}) > Makefile.tem - else - (echo "host_makefile_frag =" ; - cat ${Makefile}) > Makefile.tem - fi - mv Makefile.tem ${Makefile} - - # Conditionalize the makefile for this target. - if [ -f ${srcdir}/${target_makefile_frag} ] ; then - (echo "target_makefile_frag = ${srcdir}/${target_makefile_frag}" ; - sed -e "/^####/ r ${srcdir}/${target_makefile_frag}" ${Makefile}) > Makefile.tem - else - (echo "target_makefile_frag =" ; - cat ${Makefile}) > Makefile.tem - fi - mv Makefile.tem ${Makefile} - - # set srcdir - sed "s@^srcdir = \.@srcdir = ${srcdir}@" ${Makefile} > Makefile.tem - mv Makefile.tem ${Makefile} - - # set ddestdir - if [ -n "${ddestdir}" ] ; then - sed "s:^ddestdir =.*$:ddestdir = ${ddestdir}:" ${Makefile} > Makefile.tem - mv Makefile.tem ${Makefile} - fi - - # set idestdir - if [ -n "${idestdir}" ] ; then - sed "s:^idestdir =.*$:idestdir = ${idestdir}:" ${Makefile} > Makefile.tem - mv Makefile.tem ${Makefile} - fi - - # reset SUBDIRS - sed "s:^SUBDIRS =.*$:SUBDIRS = ${configdirs}:" ${Makefile} > Makefile.tem - mv Makefile.tem ${Makefile} - - # reset NONSUBDIRS - sed "s:^NONSUBDIRS =.*$:NONSUBDIRS = ${noconfigdirs}:" ${Makefile} > Makefile.tem - mv Makefile.tem ${Makefile} - - # remove any form feeds. - sed -e "s/ //" ${Makefile} > Makefile.tem - mv Makefile.tem ${Makefile} - - using= - if [ -f ${srcdir}/${host_makefile_frag} ] ; then - using="${using} and \"${host_makefile_frag}\"" - fi - if [ -f ${srcdir}/${target_makefile_frag} ] ; then - using="${using} and \"${target_makefile_frag}\"" - fi - if [ -n "${site}" -a \ - -f ${srcdir}/${site_makefile_frag} ] ; then - using="${using} and \"${site_makefile_frag}\"" - fi - using=`echo "${using}" | sed 's/and/using/'` - using="Created \"${Makefile}\" in `pwd`${using}." - - if [ -n "${verbose}" -o -z "${recurring}" ] ; then - echo ${using} - fi - - . ${tmpfile}.pos - - # describe the chosen configuration in config.status. - # Make that file a shellscript which will reestablish - # the same configuration. Used in Makefiles to rebuild - # Makefiles. - - echo "#!/bin/sh -# `pwd` was configured as follows: -(cd ${srcdir} ; ${progname}" ${arguments} `if [ -z "${norecursion}" ] ; then echo +norecursion ; else true ; fi` ") -# ${using}" > config.status - chmod a+x config.status - - originaldir=`pwd` - cd ${srcdir} - fi - - # If there are subdirectories, then recurse. - if [ -z "${norecursion}" -a -n "${configdirs}" ] ; then - for configdir in ${configdirs} ; do - if [ -n "${verbose}" ] ; then - echo Configuring ${configdir}... - fi - - if [ -d ${configdir} ] ; then - if [ -n "${objdir}" ] ; then - if [ ! -d ${objdir}/${configdir} ] ; then - mkdir ${objdir}/${configdir} - fi - fi - - POPDIR=`pwd` - cd ${configdir} - - if (${progname} +recurring ${host_alias} +target=${target_alias} \ - ${verbose} ${subdirs} ${removing} +ddestdir=${ddestdir} +idestdir=${idestdir} \ - `if [ -n "${objdir}" ] ; then echo +objdir=${objdir}/${configdir} ; fi` \ - ${tmpdiroption}) ; then - true - else - exit 1 - fi - - cd ${POPDIR} - -# (cd ${configdir} ; -# if (${progname} +recurring ${host_alias} +target=${target_alias} \ -# ${verbose} ${subdirs} ${removing} +destdir=${destdir} \ -# `if [ -n "${objdir}" ] ; then echo +objdir=${objdir}/${configdir} ; fi` \ -# ${tmpdiroption}) ; then true ; else exit 1 ; fi) \ -# | sed 's/^/ /' - else - if [ -n "${verbose}" ] ; then - echo Warning: directory \"${configdir}\" is missing. - fi - fi - done - fi - done # for each target - - # Now build a Makefile for this host. - if [ -n "${subdirs}" -a ! -n "${removing}" ] ; then - push=`pwd` - - if [ -n "${objdir}" ] ; then - cd ${objdir} - fi - - cd ${hostsubdir} - cat > GNUmakefile << 'E!O!F' -# Makefile generated by configure for host ${host_alias}. - -ALL := $(shell ls -d T-*) - -%: - $(foreach subdir,$(ALL),$(MAKE) -C $(subdir) \$@ &&) true - -all: -E!O!F - cd ${push} - fi -done # for each host - -### clean up. - -rm -f ${tmpfile}.com ${tmpfile}.tgt ${tmpfile}.hst ${tmpfile}.pos - -exit 0 - -# -# -# $Log$ -# Revision 1.71 1991/11/13 20:56:11 sac -# Passes down version_path for things which install themselves into -# libsubdir. -# -# Revision 1.70 1991/11/13 19:49:17 sac -# The +noversion flag will make an installation happen to the machine/.. -# directory rather than the machine/version/.. directory. -# -# Steve -# -# Revision 1.69 1991/11/12 04:41:21 rich -# allow +foo bar options. stolen from texinfo configure -# -# Revision 1.68 1991/11/09 11:34:52 rich -# correct a comment -# -# Revision 1.67 1991/11/06 22:28:08 rich -# pass +idestdir and +ddestdir -# -# Revision 1.66 1991/11/05 04:02:14 rich -# don't allow +recurring to reach config.status -# -# Revision 1.65 1991/11/01 00:25:28 rich -# new install theme -# -# Revision 1.64 1991/10/30 06:55:25 rich -# suck in site makefile frags first -# -# Revision 1.63 1991/10/25 02:07:18 steve -# More name changing -# -# Revision 1.62 1991/10/24 11:59:03 rich -# add null definitions for makefile_frag_foo -# -# Revision 1.61 1991/10/24 00:23:59 hgs -# Allow for using tmake-sun4 -# -# Revision 1.60 1991/10/23 21:48:28 rich -# Makefiles should include the makefile frag names even if the makefile -# frag doesn't exist in *this* directory. Otherwise we inherit the -# variable setting from our parent Makefile. -# -# Revision 1.59 1991/10/16 19:53:31 gnu -# Update for SCO problems. -# -# * Fix "Larry Wall kludge" line so it works. If this script is run by csh, -# it will complain, feed itself to sh, and complain some more. But will work. -# -# * Use <14 char file names in /tmp. -# -# Revision 1.58 1991/10/16 06:12:52 rich -# Two small bugs. First, single quoted sed line doesn't need to quote -# '$'. Second, use quotes around the hereis document trigger in order -# to quote the entire contents of the hereis document. -# -# Revision 1.57 1991/10/11 05:31:05 gnu -# Simplify "Using" message code. Put the message that configure prints -# (or suppresses) into the config.status file as a comment. -# -# Revision 1.56 1991/10/10 05:01:47 rich -# Remove the set -e but protect the recusion call. -# -# Revision 1.55 1991/10/10 04:57:23 rich -# * Die when sub-configure's do. -# * get the makefile building message line correct. -# * set -e -# -# Revision 1.54 1991/10/10 01:04:42 rich -# Backed out the "/bin/sh config.sub" change. Fails when config.sub was -# on PATH. -# -# Revision 1.53 1991/10/10 00:38:08 rich -# Call config.sub as "/bin/sh config.sub" instead of directly. This -# protects us from the case where config.sub isn't executable. -# -# Revision 1.52 1991/10/09 00:48:26 rich -# Another patch from jim. -# -# Revision 1.51 1991/10/08 06:07:58 wilson -# Fix bug in smake- file code. -# -# Revision 1.50 1991/10/04 23:49:37 rich -# Per's patch for my config.sub botch. -# -# Revision 1.49 1991/10/04 22:52:09 rich -# Use john's heuristic for finding ourselves. kinda like hare krishna. -# -# Revision 1.48 1991/10/02 13:17:28 rich -# take out the set -e for now -# -# Revision 1.47 1991/10/02 10:02:23 rich -# * temporary files in TMPDIR -# * +objdir -# -# Revision 1.46 1991/10/02 06:29:53 rich -# Added +site=foo option for naming site specific Makefile fragments. -# -# Revision 1.45 1991/10/02 06:15:13 rich -# Removed +f option. Used to stand for +forcesubdirs which is now -# called +subdirs. -# -# Revision 1.44 1991/10/02 06:02:35 rich -# Added rcs log line. -# -# -# - -# -# Local Variables: -# fill-column: 131 -# End: -# - -# end of configure diff --git a/configure.in b/configure.in deleted file mode 100644 index e40dd5c9e6b..00000000000 --- a/configure.in +++ /dev/null @@ -1,50 +0,0 @@ -# This file is a shell script fragment that supplies the information -# necessary to tailor a template configure script into the configure -# script appropriate for this directory. For more information, check -# any existing configure script. - -configdirs="libiberty texinfo bfd binutils byacc bison gcc readline ld gas gnulib clib gdb emacs make grep diff rcs gdbm cvs prms" -srctrigger=README -srcname="gnu development package" - -# per-host: - -# XXX - FIXME there needs to be a case for mh_dgux - -case "${host_os}" in -m88kbcs) host_makefile_frag=config/mh-delta88;; -sysv* | irix*) host_makefile_frag=config/mh-sysv ;; -svr4) host_makefile_frag=config/mh-svr4 ;; -esac - -case "${host_vendor}" in -sco*) host_makefile_frag=config/mh-sco ;; -esac - -# per-target: - - -bfd_target= - -case "${target_vendor}" in -amd) - case "${target_os}" in - ebmon) bfd_target="ebmon29k" - ;; - *) echo "bad target_os for amd" ;; - esac - ;; -*) - bfd_target=${target_alias} - ;; -esac - - -target_makefile_frag=config/mt-${bfd_target} - - -# -# Local Variables: -# fill-column: 131 -# End: -# diff --git a/gas/.Sanitize b/gas/.Sanitize deleted file mode 100644 index 74391b7a126..00000000000 --- a/gas/.Sanitize +++ /dev/null @@ -1,104 +0,0 @@ -# Sanitize.in for devo. -# $Id$ -# - -# Each directory to survive it's way into a release will need a file -# like this one called "./.Sanitize". All keyword lines must exist, -# and must exist in the order specified by this file. Each directory -# in the tree will be processed, top down, in the following order. - -# Hash started lines like this one are comments and will be deleted -# before anything else is done. Blank lines will also be squashed -# out. - -# The lines between the "Do-first:" line and the "Things-to-keep:" -# line are executed as a /bin/sh shell script before anything else is -# done in this - -Do-first: - -echo Sanitizing `pwd`... - -# All files listed between the "Things-to-keep:" line and the -# "Files-to-sed:" line will be kept. All other files will be removed. -# Directories listed in this section will have their own Sanitize -# called. Directories not listed will be removed in their entirety -# with rm -rf. - -Things-to-keep: - -.gdbinit -COPYING -ChangeLog -Makefile.in -NOTES -NOTES.config -README -README-vms-dbg -README.coff -README.rich -app.c -as.c -as.h -atof-generic.c -bignum-copy.c -bignum.h -cond.c -config -configure.in -debug.c -expr.c -expr.h -flonum-const.c -flonum-copy.c -flonum-mult.c -flonum.h -frags.c -frags.h -hash.c -hash.h -hex-value.c -input-file.c -input-file.h -input-scrub.c -make-gas.com -messages.c -obj.h -objdump.c -output-file.c -output-file.h -read.c -read.h -strstr.c -struc-symbol.h -subsegs.c -subsegs.h -symbols.c -symbols.h -tc.h -version.c -write.c -write.h -xmalloc.c -xrealloc.c - -Do-last: - -echo Done in `pwd`. - -# -# -# $Log$ -# Revision 1.3 1991/10/10 11:58:04 rich -# updating -# -# Revision 1.2 1991/09/02 01:05:04 rich -# Correcting some things. -# -# Revision 1.1 1991/05/23 17:18:12 rich -# Initial revision -# -# -# - -# End of file. diff --git a/gas/.gdbinit b/gas/.gdbinit deleted file mode 100644 index a20388c9c9f..00000000000 --- a/gas/.gdbinit +++ /dev/null @@ -1,3 +0,0 @@ -break as_warn -break as_bad -break as_fatal diff --git a/gas/COPYING b/gas/COPYING deleted file mode 100644 index 9a170375811..00000000000 --- a/gas/COPYING +++ /dev/null @@ -1,249 +0,0 @@ - - GNU GENERAL PUBLIC LICENSE - Version 1, February 1989 - - Copyright (C) 1989 Free Software Foundation, Inc. - 675 Mass Ave, Cambridge, MA 02139, USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The license agreements of most software companies try to keep users -at the mercy of those companies. By contrast, our General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. The -General Public License applies to the Free Software Foundation's -software and to any other program whose authors commit to using it. -You can use it for your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Specifically, the General Public License is designed to make -sure that you have the freedom to give away or sell copies of free -software, that you receive source code or can get it if you want it, -that you can change the software or use pieces of it in new free -programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of a such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must tell them their rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any program or other work which -contains a notice placed by the copyright holder saying it may be -distributed under the terms of this General Public License. The -"Program", below, refers to any such program or work, and a "work based -on the Program" means either the Program or any work containing the -Program or a portion of it, either verbatim or with modifications. Each -licensee is addressed as "you". - - 1. You may copy and distribute verbatim copies of the Program's source -code as you receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice and -disclaimer of warranty; keep intact all the notices that refer to this -General Public License and to the absence of any warranty; and give any -other recipients of the Program a copy of this General Public License -along with the Program. You may charge a fee for the physical act of -transferring a copy. - - 2. You may modify your copy or copies of the Program or any portion of -it, and copy and distribute such modifications under the terms of Paragraph -1 above, provided that you also do the following: - - a) cause the modified files to carry prominent notices stating that - you changed the files and the date of any change; and - - b) cause the whole of any work that you distribute or publish, that - in whole or in part contains the Program or any part thereof, either - with or without modifications, to be licensed at no charge to all - third parties under the terms of this General Public License (except - that you may choose to grant warranty protection to some or all - third parties, at your option). - - c) If the modified program normally reads commands interactively when - run, you must cause it, when started running for such interactive use - in the simplest and most usual way, to print or display an - announcement including an appropriate copyright notice and a notice - that there is no warranty (or else, saying that you provide a - warranty) and that users may redistribute the program under these - conditions, and telling the user how to view a copy of this General - Public License. - - d) You may charge a fee for the physical act of transferring a - copy, and you may at your option offer warranty protection in - exchange for a fee. - -Mere aggregation of another independent work with the Program (or its -derivative) on a volume of a storage or distribution medium does not bring -the other work under the scope of these terms. - - 3. You may copy and distribute the Program (or a portion or derivative of -it, under Paragraph 2) in object code or executable form under the terms of -Paragraphs 1 and 2 above provided that you also do one of the following: - - a) accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of - Paragraphs 1 and 2 above; or, - - b) accompany it with a written offer, valid for at least three - years, to give any third party free (except for a nominal charge - for the cost of distribution) a complete machine-readable copy of the - corresponding source code, to be distributed under the terms of - Paragraphs 1 and 2 above; or, - - c) accompany it with the information you received as to where the - corresponding source code may be obtained. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form alone.) - -Source code for a work means the preferred form of the work for making -modifications to it. For an executable file, complete source code means -all the source code for all modules it contains; but, as a special -exception, it need not include source code for modules which are standard -libraries that accompany the operating system on which the executable -file runs, or for standard header files or definitions files that -accompany that operating system. - - 4. You may not copy, modify, sublicense, distribute or transfer the -Program except as expressly provided under this General Public License. -Any attempt otherwise to copy, modify, sublicense, distribute or transfer -the Program is void, and will automatically terminate your rights to use -the Program under this License. However, parties who have received -copies, or rights to use copies, from you under this General Public -License will not have their licenses terminated so long as such parties -remain in full compliance. - - 5. By copying, distributing or modifying the Program (or any work based -on the Program) you indicate your acceptance of this license to do so, -and all its terms and conditions. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the original -licensor to copy, distribute or modify the Program subject to these -terms and conditions. You may not impose any further restrictions on the -recipients' exercise of the rights granted herein. - - 7. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of the license which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -the license, you may choose any version ever published by the Free Software -Foundation. - - 8. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - Appendix: How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to humanity, the best way to achieve this is to make it -free software which everyone can redistribute and change under these -terms. - - To do so, attach the following notices to the program. It is safest to -attach them to the start of each source file to most effectively convey -the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - - - Copyright (C) 19yy - - 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) 19xx name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the -appropriate parts of the General Public License. Of course, the -commands you use may be called something other than `show w' and `show -c'; they could even be mouse-clicks or menu items--whatever suits your -program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - program `Gnomovision' (a program to direct compilers to make passes - at assemblers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -That's all there is to it! diff --git a/gas/ChangeLog b/gas/ChangeLog deleted file mode 100644 index 88a16fa3193..00000000000 --- a/gas/ChangeLog +++ /dev/null @@ -1,1218 +0,0 @@ -Mon Oct 21 09:25:33 1991 Steve Chamberlain (steve at rtl.cygnus.com) - - * configure.in: added ebmon entry. - * output-file.c (output_file_create, output_file_close) added - stuff to use bfd. - * write.c: more bfd support - * config/obj-coff.c config/obj-coff.h use bfd for swapping - header info. - * tc-a29k: added the reloc types we support now - - -Mon Oct 14 11:44:03 1991 Roland H. Pesch (pesch at cygnus.com) - - * doc/Makefile (as.ms): one more sed workaround for texi2roff - (as.mm, as.me): new targets - -Fri Oct 11 18:18:37 1991 Roland H. Pesch (pesch at cygnus.com) - - * doc/Makefile: new targets as.info, as.ms - doc/as.texinfo: minor changes for texi2roff-2 - Makefile.in: revise 'doc' target. - -Fri Jan 4 12:48:22 EST 1991 Jay Fenlason (hack@ai.mit.edu) - - * messages.c Moved as_perror from input-scrub.c Modified the - error messages to look better. - - * output-file.c Don't call as_fatal, just call exit() - - expr.c Slightly improve checking for foo-foo case in - clean_up_expression(). Detect foo: bar: ... foo-bar... - -Tue Dec 4 16:29:20 EST 1990 Jay Fenlason (hack@ai.mit.edu) - - * m68k.c Fixed an obscure bug involving AOFF mode with a - large constant displacement (Was forgetting to output the - extension word.) - - make-gas.com Added a three line patch from Eric Youngdale that - makes it possible to submit make-gas.com to a batch queue. - -Wed Nov 21 15:07:51 EST 1990 Jay Fenlason (hack@ai.mit.edu) - - * vms.c (VMS_TBT_Routine_END) Add a four line patch from - Eric Youngdale. - -Tue Nov 13 14:02:15 EST 1990 Jay Fenlason (hack@ai.mti.edu) - - * vms-dbg.c (VMS_DBG_record()) Another one character patch from - Eric Youngdale. - -Mon Oct 29 15:49:21 EST 1990 Jay Fenlason (hack@ai.mit.edu) - - * read.c Replace some as_warn calls with as_bad. - -Fri Oct 26 15:21:15 EDT 1990 Jay Fenlason (hack@ai.mit.edu) - - * i386.c, i860.c, ns32k.c Add const changes. - -Mon Oct 22 14:04:26 EDT 1990 Jay Fenlason (hack@ai.mit.edu) - - * sparc.c Add const changes. - - * make-gas.com define const= for VMS, since many older versions of - GCC don't work correctly with const under VMS. - -Thu Oct 18 12:44:11 EDT 1990 Jay Fenlason (hack@ai.mit.edu) - - * i860.c i860-opcode.h Added patches from rgb@mcc.com - - * read.c, symbols.c, vms.c, + new_file vms-dbg-module.c - Added Eric Youngdale's VMS debugging - patches, so debugging GCC output now works. - - * hash.c (hash_grow) Remember to blank out the wall entry in the new - hash table. This is important on systems where malloc() returns - non-zero storage. . . - -Tue Oct 16 10:11:35 EDT 1990 Jay Fenlason (hack@ai.mit.edu) - - * output-file.c (output_file_create) if output filename is given as - '-', write to stdout. - - * m68k.c Finally get the PCREL code to work right. Add relaxation of - PCREL stuff This small fix from Ken Woodland - (kenny%datacube.uucp@uunet.uu.net). - - * m68k.c Added some const declarations to constants. (md_relax_table, - md_pseudo_table, etc. . .) - -Thu Oct 11 11:15:10 EDT 1990 Jay Fenlason (hack@ai.mit.edu) - - * Makefile, read.c, write.c Include the i860 port. - (New files i860.c i860-opcode.h i860.h) - - * m68k.c Fix some addressing modes, (AOFF, AINDEX, etc) to work in - PC relative mode. - - * (all over) Raeburn's const hacking. This reduces the data-space size by - declaring many tables, etc, as 'const'. - -Mon Oct 22 22:48:22 1990 John Gilmore (gnu at cygint) - - Make gas work if you turn on the know() checks. - - * app.c: Only pass a single space through: the one after - the opcode. All other whitespace is removed, to match the - expectations of the parser in read.c. - - * as.h: Remove obsolete comments. Remove JF's NDEBUG so - that know() can really work if you turn it on. Make - SEG_MAXIMUM_ORDINAL == SEG_REGISTER. - - * expr.c (operand): Change BITS_PER_INT to 8*sizeof(int). - - * input-scrub.c: strlen("\0") doesn't return 1... - (as_where): Add space after line number in errors, like gcc. - - * m68k.c (s_bss): Fake .bss into data section 255. - We can't cope with a real "BSS section" yet, but we can at - least do the right thing less efficiently (with lots of - zeroes). - - * read.c: Turn lots of as_warn()'s into as_bad()'s. - - * read.h (SKIP_WHITESPACE): Replace last instance of ASSERT() - with know(). - - * sparc.c (s_seg): We can't put frags into the BSS segment - yet, so just fake bss seg as 255th data segment. - - * vax.c: Remove \'s from continued macro *parameters*. These - must have been added after the last time someone turned on - know() checking... - - * write.c (relax_segment): Refine what we know() about the - symbols referenced during relaxation. - - * Makefile (OTHER_ALIGN): Remove, handled in tables now. - Flip options a bit. These options really ought to go - elsewhere. - -Sun Oct 21 03:57:21 1990 John Gilmore (gnu at cygint) - - Sun-3 fixes. - - * expr.c, write.c: Missing semicolon after know(). - - * write.c (fixup_segment): Allow pc-relative accesses to undefined - external symbols. Previously this would turn off pc-rel calc - of displacement, while leaving pc-rel opcode alone, botching. - - * m68k.c (m68k_ip): Allow pc-relative effective addresses - for source operands. "pea" instructions are a good example - where we can shorten from abs long to pc+16bit. - (md_convert_frag): Fix "JBSR" comments to refer to "JSR", the - actual instruction. Insert comments about bug in 68000 bcc - and dbcc long code (that doesn't get exercised much). Add - comments about long pcrel displacements for -pic. Remove - "this code has not been tested" comment. - (md_estimate_size_before_relax): Now that fixup_segment - doesn't shortcircuit pc-relative fixups for undefined symbols, - only output them if -pic; else turn them absolute, which is - slightly faster. More JBSR->JSR comments. - (md_parse_options): Parse -pic. - -Fri Oct 19 14:35:20 1990 John Gilmore (gnu at cygint) - - * Make sparc assembler more compatible with Sun assembler. - sparc.c: reformat pseudo-op table to match main table. - (md_assemble): Add SPECIAL_CASE_FDIV to assemble FDIV* - instructions as fdiv followed by fmovs to get around chip bug. - (s_common, s_seg): Accept "bss" section name. - (md_assemble): Handle "set" instructions with absolute - operands, that only take one instruction rather than two. - sparc-opcode.h (fdiv*): Mark instructions "S"pecial. - subsegs.c (subseg_change): Move tail pointer too. - symbols.c (colon): Allow new definitions to override .comm symbols, - as in VMS. Sun CC depends on this. - write.c (new_fix): Always take r_type argument, not just on sparc. - Chain fixP's in order, using tail pointer, so relocation - records come out in forward order like Sun as. Remove SPARC - ifdefs. - write.h: Add seg_fix_tailP, data_fix_tailP, text_fix_tailP. - - * am29k.c: Use s_align_bytes rather than a local copy. - - * read.c (s_align): Rather than ifdef it, make two functions, - s_align_bytes and s_align_ptwo. Individual pseudo-op tables - can call whichever one they like. - - * write.c (append): Move from append.c to here. - append.c: Remove file. - - * Makefile (MDSRC, mdsrc): Easy way to edit all md.c's. - Fix options. Add option for -DDEBUG for know() and assert(). - Remove append.c, am29k.h. Don't build special read-sparc.o. - Remove sparc.h. "make clean" removes am29k .o's. Add - dependencies on reloc.h. - -Thu Oct 18 17:56:34 1990 John Gilmore (gnu at cygint) - - * Generalize sparc extensions to relocation info. Gas now - keeps relocation information internally in a different format - than how it is stored in the resulting .o. md_ri_to_bytes() - converts to external format. md_reloc_size says how large - each relocation record is in external format. - sparc.h: Remove this file. Rename to reloc.h. Rename struct - to reloc_info_generic. - reloc.h: Add relocation types for AMD 29000. - read.c, write.c: Always call fix_new with reloc-type argument. - write.c (emit_relocations): Make md_ri_to_bytes write directly - to output area rather than overwriting its argument then - bcopying it. - md.h: Declare md_reloc_size and md_ri_to_bytes. - i386.c, am29k.c, vax.c, ms32k.c, m68k.c, sparc.c: include reloc.h. - (md_reloc_size): Specify correct value. - (md_ri_to_bytes): Convert format from internal to external. - - write.c (write_object_file): Call md_section_align() which - rounds section sizes up if desired. - sparc.c (md_section_align): Round to 8 byte boundary. - i386.c, am29k.c, vax.c, ns32k.c, m68k.c (md_section_align): Nop. - -Mon Oct 15 22:06:11 1990 John Gilmore (gnu at cygint) - - Changes in support of the AMD 29000 version of gas. - - * am29k-opcode.h: Add dummy entry to end so we can examine - item N+1 without exceeding table. - - * am29k.h: New include file, derived from sparc.h. Kludged - together, still needs major work to get relocation working. - - * am29k.c: New file, derived from sparc.c. - Put 29k-specific ASM29K pseudo-ops into table. - Change comment_chars to ASM29K. - Change s_seg to s_use. - Change s_sparc_align to s_29k_align, default operand to 4. - (define_some_regs): Define special register names. - (md_begin): Preprocess opcode table to mash together all - the variants of single opcodes. This simplifies later handling. - Call define_some_regs to preset special reg names. - (parse_operand): Add, parses out an operand from a stmt. - (machine_ip): Simplify, since 29K is simpler asm language. - Handle the various keyletters in the opcode table. - - - Handle include files in the assembler, with a .include - pseudo-op. - * as.h (input_scrub_include_file): declare. - * as.c (perform_an_assembly_pass): Avoid buffer hacking. - Start us off in text segment. - * read.c (read_a_source_file): Take a name as argument, - internalize all buffer handling. Don't start a new text - subsegment on each entry. Actually use the start and end - pointers returned by input_scrub_next_buffer. - (s_include): Call input_scrub_include_file for .include. - * input-scrub.c: Fix comments. - (struct input_save): Add, for saving state at .include. - (input_scrub_push, input_scrub_pop): Add, push & pop state. - (input_scrub_begin): Initialize next_saved_file. - (input_scrub_end): Free buffer. - (input_scrub_include_file): Add, to include a file. - (input_scrub_close): Add, to close a file. - (input_scrub_next_buffer): Set buffer-start address for - caller. If we hit EOF and were included, pop to previous file. - * input-file.c: Remove old includes. Remove old file-descriptor - hacking code, that was commented out. - (struct saved_file): Add, for saving state at .include. - (input_file_push, input_file_pop): Add, push & pop state. - (input_file_open): Don't buffer all files in one place. - (input_file_close): Add, close input file. - * input-file.h: Declare new functions. - * app.c: (struct app_save): Add, for saving state at .include. - (app_push, app_pop): Add, push and pop state. - (do_scrub_next_char): Move its static state variables out so - they can be saved and restored. - - - * app.c: Allow overriding of character meanings by machine - dependent strings. Avoid wiring character constants into app.c. - (do_scrub_begin): New meanings override old ones, not "OR" them. - Only handle /* comments if / is not already in use. - (do_scrub_next_char): Reorganize mass of nested if's - into a switch for speed. Don't assume ';' is line terminator. - Reorganize switch on characters, into a switch on their (machine- - dependent) lexer table meanings. - - - Encapsulate knowledge of segment types in fewer places. - This allows us to add the "SEG_REGISTER" type, as well as - providing flexibility for eventual COFF/ELF support. - * struc-symbol.h (symbol_to_segment, symbol_to_segment_type, - set_symbol_segment, set_symbol_segment_keep_ext, - segment_name): Define macros to encapsulate this info. - * as.h: Remove externs for seg_name, seg_N_TYPE, N_TYPE_seg. - * symbols.c (symbol_new): Change 'type' arg to 'seg'. - * expr.c, i386.c, m68k.c, ns32k.c, read.c, symbols.c, vax.c, - write.c: Use macros. - * i386.c, m68k.c, ns32k.c, vax.c, write.c: Change 2nd arg type of - md_estimate_size_before_relax. - * expr.c, read.c: Change 'type' arg to symbol_new. - * read.c, symbols.c, vax.c, write.c: Move md.h to end of includes. - - - Allow expressions to evaluate to registers. - * as.h: Add SEG_REGISTER. - * struc-symbol.h: Add fake N_REGISTER type. - * subseg.c: Add types to tables. - * expr.c (operand): Symbols of SEG_REGISTER type are - immediately evaluated like those of SEG_ABSOLUTE. - (clean_up_expression): Clean up SEG_REGISTER exprs. - - - Allow machine descriptions to cleanly extend the set of - possible operands. - * expr.c (operand): Call md_operand before rejecting an - operand as unacceptable. - * md.h: declare. - * i386.c, ns32k.c, m68k.c, sparc.c, vax.c: Define null function. - * am29k.c (md_operand): Use this for %% and & prefix operators. - - - Allow machine descriptions to cleanly permit symbols to be - predefined upon first usage. - * symbols.c (symbol_find_or_make): Call md_undefined_symbol - before making an undefined symbol. - * md.h: declare. - * i386.c, ns32k.c, m68k.c, sparc.c, vax.c: Define null function. - * am29k.c (md_undefined_symbol): use this for the local and - global register names; since there are hundreds of them, it - only defines them upon their first use. - * expr.c (operand): Call symbol_find_or_make rather than - roll our own undefined symbols. - - - Miscellaneous changes: - - * as.h (know): Make this useful if DEBUG defined. - - * write.h: Support SPARC-like relocation throughout all - versions. - - * read.c (read_a_source_file): Report the name of invalid - pseudo-ops. Don't double-report junk characters. Close the - input file, which gas never used to do. - (ignore_rest_of_line): Report junk chars in ascii if - printable. - (s_ignore): Ignore entire statement; used for 'listing - control' statements from ASM29K, e.g. .eject. - - * read.c (s_lsym): Handle register equates too. - - * read.c: Add most ASM29K pseudo-ops to the master table. - Not all are implemented yet. - - * cond.c: New file, for functions implementing conditional - assembly pseudo-ops: .ifdef, .ifndef, .else, .endif, .ifseq, - .ifsne, .end. So far, they are just stubbed out. - - * read.c (pobegin): Allow the machine dependent pseudo-op - table to override the generic one. Remove #ifdef SPARC - on .word, since it can now be overridden. - - * expr.c (operand): Support radix-2 constants. Kill off - support for octals with digits '8' and '9'. Initial steps - toward more general support for local-labels. - - * symbols.h (symbol_table_lookup): Remove macro, change all - occurrences (in read.c, expr.c, symbols.c) to symbol_find. - - * read.h (is_end_of_line): Define for external use. - - * i386.c (alloca): Use builtin_alloca or include or extern. - - * Makefile: Add ALL and all: entries. Add asm29k entries. - Add cond.c and cond.o. Remove special handling for messages.o. - Add lint entry. - -Thu Sep 27 13:43:49 EDT 1990 Jay Fenlason (hack@ai.mit.edu) - - * m68k.c (get_num) Fix so that 1:w is treated properly. - - * Makefile Replace references to a.out.h with a.out.gnu.h - -Tue Sep 25 15:50:36 EDT 1990 Jay Fenlason (hack@ai.mit.edu) - - * sparc.c (md_number_to_imm) Fix so that RELOC_32 locations contain - zero, so that it will work with some sparc loaders which don't assume - that the locations in question do. A xix line patch from Michael Bloom - (usc!srhqla!quad1!psivax!ttidca!mb@zaphod.mps.ohio-state.edu) - -Mon Sep 24 11:43:15 EDT 1990 Jay Fenlason (hack@ai.mit.edu) - - * as.c #include if _POSIX_SOURCE defined. This because - uses pid_t that's defined in it. - - * m68k.c reverse the sense of -l option, and allow :w and :l to - override the default size of AOFF indexes. - - Also, allow -l to shorten branches to unknown labels from LONG to WORD. - -Thu Sep 13 17:05:09 EDT 1990 Jay Fenlason (hack@ai.mit.edu) - - * vax.c (md_parse_option) Don't print a warning msg if given -J - -Wed Sep 5 14:26:14 EDT 1990 Jay Fenlason - - * expr.c (operand) Don't get garbaged high-order bits when given a - lot of leading zeroes. - -Tue Sep 4 11:40:21 EDT 1990 Jay Fenlason - - * read.c (pseudo_set) Compain if we're setting the symbol to the - difference of two symbols which are in different frags. (We can't - find out how far apart they are.) - -Wed Aug 15 12:18:58 EDT 1990 Jay Fenlason - - * m68k.c (m68k_ip_op) Dyke out the code that deals with parsing - :[wl] at the end of expressions since it is handled in get_num() - and this was putting the result in the wrong place anyway. - Corrected a couple of other references to ->isiz instead of con?->e_siz - -Mon Aug 13 15:53:46 EDT 1990 Jay Fenlason - - * read.c Handle .align specially on the sparc, or any other machine - where OTHER_ALIGN is defined. Added option and comments about it - to Makefile. - -Fri Aug 10 12:24:33 EDT 1990 Jay Fenlason - - * m68k.c (get_num) Handle SEG_PASS1 expressions. - -Mon Aug 6 16:32:29 EDT 1990 Jay Fenlason - - * write.c (fixup_segment) Added two patches for the NS32k - and SEQUENT A six line patch from Ian Dall - (asgard!aegir!hugin!augean!sibyl!ian@munnari.oz.au) - -Wed Aug 1 13:30:48 EDT 1990 Jay Fenlason (hack@ai.mit.edu) - - * m68k.c Include REGISTER_PREFIX ifdefs. - - * write.c Include LOCAL_LABEL() and DOT_LABEL_PREFIX feature. - - * vax.c (md_parse_option) Accept -H option. - - * vms.c New version of case hasher, etc. These from Eric Youngdale - - -Fri Jul 20 13:39:02 EDT 1990 Jay Fenlason (hack@ai.mit.edu) - - * README Added README.APOLLO and README.COFF stuff - -Wed Jul 18 16:29:22 EDT 1990 Jay Fenlason (hack@ai.mit.edu) - - * Makefile Added option for SEQUENT_COMPATABILITY - - * ns32k.c Add configurable syntax feature from - ian@sibyl.eleceng.ua.oz@augean.ua.oz.au - and SEQUENT_COMPATABILITY - - * ns32k-opcode.h Add configurable syntax feature. - -Mon Jul 16 11:44:14 EDT 1990 Jay Fenlason (hack@ai.mit.edu) - - * write.c (relax_segment) On ns32k, add fragP->fr_pcrel_adjust to - aim. - (fixup_segment) On ns32k, don't subtract size from - add_number on pcrel external symbols. - - * ns32k.c (md_relax_table) Use correct max displacements. - This is a six-line patch from ian@sibyl.eleceng.ua.oz.au - - * ns32k.c (md_atof, convert_iif) Emit floating point numbers in - the correct byte order. A seven line patch from - ian@sibyl.eleceng.ua.oz.au - - * ns32k.c (all over) Some lint fixes. - -Mon Jul 9 13:17:00 EDT 1990 Jay Fenlason (hack@ai.mit.edu) - - * app.c (do_scrub_next_char) If a comment is #{whitespace} - don't treat the next line as comment also. - - * m68k.c (...) Accept apc@(num:[wl]), etc. - - * i386.c (md_assemble) Get bitfields correct when doing cross - assembly to 386. A two line patch from Michael Bloom. - (usc!srhqla!quad1!ttidca!mb@zaphod.mps.ohio-state.edu). - - * README.APOLLO a new file with vasta@apollo's name, address - and phone # in it. - - * make-gas.com Deleted references to gdb source files. - -Fri Jul 6 14:34:27 EDT 1990 Jay Fenlason (hack@ai.mit.edu) - - * i386.c Ignore the .optim directive - - * input-file.c Change from _IOLBF to _IOFBF in setbuffer emulation - for SYSV. - -Mon Jun 18 15:36:49 EDT 1990 Jay Fenlason (hack@ai.mit.edu) - - * sparc.c #ifdef DONTDEF s_sparc_align, since it isn't called from - anywhere. - -Fri Jun 15 15:53:30 EDT 1990 Jay Fenlason (hack@ai.mit.edu) - - * vax.c (md_parse_option) make the code agree with the documentation - on the behaviour of the -d option. - -Thu Jun 7 14:23:54 EDT 1990 Jay Fenlason (hack@ai.mit.edu) - - * atof-ieee.c (gen_to_words) Assemble 0r-0 correctly. - - * Makefile Remove last references to gdb*.c files. - - * version.c New version 1.36 - -Tue May 22 13:22:26 EDT 1990 Jay Fenlason (hack@ai.mit.edu) - - * Makefile Mention a work-around for a possible problem with HPUX7.0 - -Mon May 21 14:06:04 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * sparc.c (sparc_ip): Change error message from "not in hash table" - to "unknown opcode". - -Wed May 16 15:33:14 EDT 1990 hack@wookumz - - * i386.c (i386_operand) Print error msg if given an operand like - 4(mumble) which we can't parse. - - * m68k.c (md_assemble) Add '3' to the list of operand-places that - can be found in 'symbol-dependent info'. Also change - 'confusing width' diagnostic to something more meaningful. - -Fri May 11 12:09:21 EDT 1990 hack@wookumz - - app.c (do_scrub_next_char) Don't flush the line after a line - consisting of a single '/' A one-line patch from Mike Kupfer - (kupfer@orc.olivetti.com) - - * i386.c (md_assemble) Call frag_wane() before calling frag_new() - A one line patch from Steve Bleazard (steve@robobar.co.uk - -Tue May 8 12:56:25 EDT 1990 hack@wookumz - - * atof-generic.c (atof-generic) Modified the Infinity detection code - to accept 0rinfinity and 0r-infinity as well as 0rinf and 0r-inf - -Thu Apr 26 15:17:31 EDT 1990 hack@wookumz - - * atof-ieee.c Change value of NaNs to 0x7fff ffff (float) and - 0x7fff ffff ffff ffff (double) If you want some other value for - NaN, use .long and spell it out yourself. - - atof-generic.c (atof_generic) Cleaned up code that detects NaN - and Inf. - - vax.c (md_assemble) print a useful error message if expression() - returns SEG_PASS1 or SEG_DIFFERENCE and we can't deal with those. - -Thu Apr 19 10:30:47 EDT 1990 hack@wookumz - - * input-scrub.c (AFTER_STRING) Make AFTER_STRING contain a null - so that the strstr() call when looking for "#NO_APP" after a "#APP" - will work. A two character patch from Bruce Robertson - (bruce@heather.pooh.com) - - * Makefile, i386.c Use atof-ieee.c instead of atof-i386.c - -Mon Apr 16 16:20:55 EDT 1990 hack@wookumz - - * m68k.c (md_relax_table) Many of the offsets were off by two. - Fixed some generic spacing problems thoughout the file. - -Thu Apr 12 12:22:35 EDT 1990 hack@wookumz - - * sparc.c (md_ri_to_chars) Handle little-endian cross assembly. - - * write.c (relax_segment) Compare addresses correctly to avoid - accidentally relaxing a branch that we don't have to. - These small changes from John Gilmore (gnu@toad.com) - -Fri Apr 6 12:52:15 EDT 1990 hack@wookumz - - * Makefile, expr.c symbols.c Correctly document the SUN_ASM_SYNTAX - option, and make it work. - -Tue Mar 20 12:46:59 EST 1990 - - * as.c (main) Only trap SIGHUP, SIGINT, SIGPIPE, and SIGTERM, - and only if they aren't being ignored. A three line patch - from Paul Eggert (eggert@twinsun.com) - - * write.c (relax_segment) Correct typo 'growth - ' should have been - growth = - - * atof-vax.c (next_bits, flonum_gen2vax) Clean up by sharing some - variables. While we're at it, fix next_bits so that it - doesn't use littlenums that don't exist. . . - -Tue Mar 13 16:23:21 EST 1990 hack@wookumz - - * Rename atof-m68k.c atof-ieee.c - - * Delete atof-ns32k.c - - * m68k.c sparc.c ns32k.c atof-ieee.c Call atof-ieee instead of - atof-m68k or atof-ns32k - - * Makefile Compile with atof-ieee.c instead of atof-ns32k.c or - atof-m68k.c - -Mon Mar 12 14:06:55 EST 1990 hack@wookumz - - * as.c If the signal handler gets called twice, exit immediatly. - - * ns32k.c Call gen_to_words with a pointer of the proper type, and - call md_number_to_chars to put the results in the proper byte-order. - Whoever wrote this code was *sloppy*! - - * Makefile ns32k.o depends on ns32k.c - - * vax.c (md_parse_option) If VMS, accept -+ and -h options. - - * vms.c (VMS_Case_Hack_Symbol) Replace #if NO_CASE_HACKING - with references to the -h option. These small VMS patches - from Angel Li (angel@flipper.miami.edu). - -Thu Mar 8 19:18:59 EST 1990 hack@wookumz - * vms.c Some trivial patches from Eric Youngdale - (YOUNGDALE@v6550c.nrl.navy.mil) - -Wed Mar 7 17:12:09 EST 1990 hack@wookumz - * make-gas.com (Define error as as_fatal when compiling vax.c and vms.c - A two line patch from Eric Youngdale - (YOUNGDALE@v6550c.nrl.navy.mil) - -Tue Mar 6 16:01:09 EST 1990 hack@wookumz - - * Makefile Include ns32k options in makefile. A small patch from - David Taylor (taylor@think.com). - - * as.c read.c write.c Makefile #ifdef DONTDEF out all the gdb - symbol stuff, since it isn't used anymore and it doesn't work. - -Mon Mar 5 14:51:04 EST 1990 hack@wookumz - - * i386.c (md_assemble) Replace memchr() with index(). - - * as.c Trap signals 1 through NSIG, print an error msg, and don't - produce an object file. - - * m68k.c Added a hack so that fsincosx fpx,fpy:fpz works. - - * messages.c New function: as_bad This is like as_warn, except - -W doesn't disable it, and calling it inhibits production of an - object file and causes a non-zero exit code. - -Tue Feb 13 14:25:53 EST 1990 hack@wookumz - * Makefile Include G0 and LOADLIBES for Sequent Symmetry. - Based on a small patch from Johan Widen (jw@sics.se) - -Thu Feb 1 14:08:58 EST 1990 hack@wookumz - * m68k.c Replace 'abort' with 'abort()' which will work. - -Wed Jan 24 17:15:08 EST 1990 hack@ai.mit.edu - - * read.c (ignore_rest_of_line) Have it print the first junk char - in both decimal and %c form. - - (read_a_source_file) On bad pseudo-op, print out the unknown - pseudo-op's name. - -Tue Jan 23 13:12:48 EST 1990 hack@ai.mit.edu - - * read.c (pseudo_set) If the symbol is external, have it remain - external. - - * i386-opcode.h Allow jc as a synonym for jb and jnc as a syn for jnb. - - -Wed Jan 3 09:35:31 EST 1990 hack@ai.mit.edu - - * ns32k.c [cpureg_032] Change register id of psr from 0x0b to 0x0d - * ns32k-opcode.h Change shift-counts for lsh and lshd - to one byte instead of 2 and 4. - A Trivial patch from John F. Peters (think!ames!practic.com!jfp@eddie) - -Tue Dec 5 16:37:44 EST 1989 hack@ai.mit.edu - - * ns32k.c (md_create_{long,short}_jump) Six line patch from - John F Peters (think!ames!vine!practice.com!jfp) to use the - correct addressing mode and byte-order for broken-word stuff. - - * write.c (write_object_file) One line patch to call fix_new_ns32k - with the correct # of args. - -Fri Dec 1 16:44:21 EST 1989 hack@ai.mit.edu - - * atof-generic.c, flonum-mult.c A real fix for the trailing-zeroes - problem from Georg Feil (ghfeil@white.toronto.edu) (two line change) - -Mon Nov 27 15:30:46 EST 1989 hack@ai.mit.edu - - * i386-opcode.h Fixed opcode-table entry for ljmp. A one char - patch from eliot@mgm.mit.edu - -Mon Nov 20 12:41:28 EST 1989 hack@ai.mit.edu - - * expr.c Replace the generic_buffer hack with a more portable one */ - - * atof-generic.c (atof_generic) Ignore trailing zeroes after a decimal - point. For some reason trailing zeroes (but not trailing nonzeroes) were - causing loss of precision. I don't know why. . . - - * vms.c Change copyright notice. Install changes from Kenneth Adelman - (adelman@tgv.com) for c++? (A dozen lines or so) - -Mon Nov 13 11:48:44 EST 1989 hack@ai.mit.edu - - * Makefile Add BINDIR and use it to control where the executable is - installed. - - * i386.c Use __builtin_alloca if possible (trivial patch from - Marco S. Hyman pacbell!dumbcat!marc) - -Mon Nov 6 18:24:47 EST 1989 hack@ai.mit.edu - - * version.c New version: 1.35 will be distributed with the - 1.36 gcc release. - -Mon Oct 30 10:38:11 EST 1989 hack@ai.mit.edu - - * atof-m68k.c (atof_m68k) Don't put the bits[] array on the stack, - since it may be pointed to after atof-m68k exits. - -Tue Oct 24 11:15:57 EDT 1989 hack@ai.mit.edu - - * atof-m68k.c Added #define for bcopy on USG systems. - #ifdef TEST the print_gen() function. - - * a.out.h if USE_HP_INC_HDR then use ../binutils/hp-include/a.out.h - -Fri Oct 13 14:36:48 EDT 1989 hack@ai.mit.edu - - * vax.c (all) Ran vax through indent -gnu to make it readable. - - vax.c (vip_op) Correctly assemble code like jmp $*0x11223344 - by setting vip_nbytes to 4 when using an immediate address. - I hope this works! - - m68k.c (s_proc (new)) Added s_proc no-op pseudo-op. - - Makefile Added instructions for compiling on Sequent Symmetry - and HP 9000/300. - - a.out.h Modified to compile on Sequent and HP above. (HP port - based on a msg from asjl@comp.vuw.ac.nz (real name unknown)). - -Tue Oct 10 14:39:44 EDT 1989 hack@ai.mit.edu - * vax.c (vip_op) Fixed a typo in an error msg and cleaned - up some spacing stuff. - -Wed Sep 27 19:07:12 EDT 1989 hack@ai.mit.edu - - * app.c (do_scrub_next_char) Fixed parsing of - # "file" garbage - text so that it'll work again? (8 line patch from Mike Hibler - (mike@cs.utah.edu)) - -Mon Sep 18 16:26:01 EDT 1989 hack@ai.mit.edu - - * app.c (do_scrub_next_char): Modify parsing of /* ... */ to work - on the text /* ****/ - - * sparc.c (sparc_ip): Don't abort on insns that use the Alternate - Spaces. Try to assemble them correctly. - -Thu Sep 14 11:42:44 EDT 1989 hack@ai.mit.edu - - * sparc.c (md_number_to_imm) Dozen line patch from jkp@sauna.hut.fi - (Jyrki Kuoppala) so that gas output will work with shared libraries. - - * ns32k.c Include instead of if USG defined. - - (md_end) free(freeptr_static) instead of free(freeptr) . - - * atof-ns32k.c Include as.h so that sysV stuff (bzero) will be - defined if needed. These ns32k changes from - nixbur!mollers.pad@seismo.css.gov (Josef Moellers) - -Fri Sep 1 11:39:52 EDT 1989 hack@ai.mit.edu - - * atof-m68k.c (gen_to_words) Get the sign right on negative - floating-point numbers. - -Wed Aug 30 13:59:57 EDT 1989 hack@ai.mit.edu - - * Makefile Remove the rest of the $< entries that kill sun make - -Fri Aug 25 15:00:30 EDT 1989 Nobody You Know (hack@ai.mit.edu) - - * atof-m68k.c (gen_to_words) deal with denormalized floating-point - numbers. - -Tue Aug 22 02:03:05 1989 Roland McGrath (roland at hobbes.ai.mit.edu) - - * Makefile (gas-dist.tar): Put ChangeLog in the tar file. - - * version.c: Added comment telling Jay Fenl--I mean people--not to put - changes in version.c, but to use ChangeLog instead. - - * version.c (version_string): Put "GNU" in all-caps. - - * version.c: Moved all comments about changes to ChangeLog (this file). - Many anonymous entries have been attributed to Jay Fenlason (hack). - -Thu Aug 17 15:53:57 1989 Jay Fenlason (hack at apple-gunkies.ai.mit.edu) - - * Makefile: Removed $< references that seem - to choke some versions of make. - - * frags.c (frag_grow): Fixed to deal with requests for very - large frags (larger than frags.chunk_size). - - * app.c (do_scrub_next_char): Have it ignore any characters - after the filename in a # line "filename". - - * sparc.c (s_common): On an error, don't print out - input_line_pointer past the end of the line where the error is. - - * atof-generic.c (atof_generic): Accept any case for - inf and nan. - - * m68k.c (m68_ip): Don't use PC-relative mode for alterable - addressing modes. - -Tue Aug 15 04:58:36 1989 Roland McGrath (roland at apple-gunkies.ai.mit.edu) - - * sparc.c (md_begin): Rewrote this function to perform consistency - checks with the new opcode table. - -Fri Aug 11 16:01:16 1989 Roland McGrath (roland at apple-gunkies.ai.mit.edu) - - * sparc-opcode.h (struct sparc_opcode): Replaced `mask' field with - `lose'; removed `last' field. Updated all opcodes accordingly. - Fixed several opcodes that generated the wrong instructions. - sparc.c (md_begin, sparc_ip): Changed to use new struct sparc_opcode. - -Thu Aug 3 14:44:24 1989 Jay Fenlason (hack at apple-gunkies.ai.mit.edu) - - * Makefile (a32k): Use read- and write-ns32k.o - * ns32k.c (encode_operand): Make sure pcrel_adjust starts out zeroed. - * read.c (cons): Call fix_new_ns32k() if NS32K is defined. - * write.c (write_object_file): Ditto. - These so that .word sym-sym (etc) will produce values with - the proper byte-order. - -Wed Aug 2 12:55:?? 1989 Jay Fenlason (hack at apple-gunkies.ai.mit.edu) - - * sparc.c (comment_chars[]): Removed '|' because it was causing - problems. Probably not the best fix, since I suspect other - assemblers (68020) may get | in .stabs also, and the 68020 needs - the '|' comment character. - -Mon Jul 31 09:22:28 1989 Roland McGrath (roland at apple-gunkies.ai.mit.edu) - - * sparc.c (sparc_ip): Allow the characters [0123] in opcodes. - -Tue Jul 25 16:32:12 1989 Jay Fenlason (hack) - - * atof-generic.c (atof_generic): Tried to keep - size_of_digits_in_littlenum from going negative. - - * sparc-opcode.h: Added duplicate [i+1] entries to go with - the [1+i] entries already there. A kludgy fix, but it works. - -Mon Jul 24 17:20:03 1989 Jay Fenlason (hack) - - * write.c (relax_segment): Modified rs_org code so it won't - occasionally dump core. - - * write.c (pseudo_set): Modified SEG_DIFFERENCE to (perhaps) - allow one to set a symbol to the difference of two other symbols. - - * ns32k.c (convert_iif): Moved size_so_far+=size and size=0 inside - the check for a valid type. - - * sparc-opcode.h: Modified the entries for std "q,[1+i]", "D,[1+i]", - and "Q,[1+i]". - -(In version 1.34) Jay Fenlason (hack) - - * Makefile: Reorganized, added stuff to make asparc. - - * sparc.c, sparc-opcode.h, sparc.h: Sparc port. - - * write.c: Set the size of text and bss segments to a multiple of eight - bytes. - - * m68k.c: Moved .single pseudo-op to machine independent part. - - * atof-generic.c: Fixed type in #ifdef __GNUC__. - - * sparc-opcode.h: Handle "mov REG, %y". - - * make-gas.com: Know that error.c no longer exists. - - * sparc.c: Handle [expr+reg]. - Don't call getExpression when looking for an immediate and getting - something that starts with % and isn't %hi or %lo. - - * Teach the 68k about long conditional branches. - -(In version 1.33) Jay Fenlason (hack) - - * Use __builtin_alloca if available. - - * README: Added more instructions for reporting bugs. - - * ns32k-opcode.h: Changed the acbb, acbw, and acbd insns. - - * vax.c: Replaced instances of LENGTH[STRING] with STRING[LENGTH]. - - * ns32k.c (encode_operand): Increased max size of bit field for exts - and inss instructions from 31 to 32 bits. - - * flonum-mult.c (flonum_multip): Fixed typo. - - * m68kc.: Allow #32 to be the same as #0 for bit-field ops. - - * make-gas.com, version.c, hex-value.c, flonum-const.c: VMS fixes. - - * ns32k.c, ns32k-opcode.h: More fixes from taylor@think.com. - Mostly typos in comments, etc. - - * ns32k-opcode.h: Fixed size of immediate operands to andw and andd - instructions. - -(In version 1.32) Jay Fenlason (hack) - - * read.c (s_set): Fixed misnamed variable. - - * as.c: Don't hang if given an invalid option. - - * m68k.c: Fixed bug in creating absolute long addresses for branches. - - * ns3k*: Some small ns32k patches. - - * m68k.c: Recognize 0rnan, 0rinf, 0r-inf. - - * app.c: Don't dump core on unterminated strings. - - * symbols.c: Give reasonable error messages. - - * ns32k*: Allow -m32032 and -m32532 options. - - * atof-*.c: Added support for NaN, Inf, and -Inf in atof_generic and - the various descriptions. - - * m68k.c (add_fix): Replace occurrences of "width==" with - "(width)==". This correct a precedence problem. - - * write.c, struc-symbol.h, m68k-opcode.h, m-hpux.h, Makefile: Changes - for HP-UX from Chris Hanson (cph@kleph.ai.mit.edu). - - * m68k-opcode.h: Reorder movem insns so gdb will see the ones using the - register list syntax first. - - * symbols.c (colon): Give more useful error messages when something was - defined as a .comm and is now trying to be defined locally. - Also, redefining a symbol is a fatal, not a warning. - - * m68k.c: Fixed a bug in using bignums as literal bit patterns for - floating-point numbers. - -(In version 1.31) Jay Fenlason (hack) - - * i386*: More patches. - - * Moved machine-dependent option parsing into the machine-dependent - source files. - -(In version 1.30) Jay Fenlason (hack) - - * i386*: New new version. - - * atof-m68k.c: Changed to be smaller, with somewhat better modularity. - Also fixed an obscure bug wherein next_bits would return random bits. - - * m68k.c: Be more careful about creating PC-relative addressing modes - on the 68000 and 68010. - - * frags.c (frag_new): Zero out the new frag. - - * Don't choke on "foo= bar" or on formfeeds. - - * read.c: Allow Sun-syntax local labels #ifdef SUN_ASM_SYNTAX. - * m-sun3.h: Defined SUN_ASM_SYNTAX. - -(In version 1.29) Jay Fenlason (hack) - - * i386.c: Newer version that fixes a bug wherein a jump instruction - would be split between two frags. - - * i386*: New version. - - * m68k.c: #ifdef M_SUN and -m68010, produce Sun-2 executables. - -(In version 1.28) Jay Fenlason (hack) - - * m68k.c: Added .single pseudo-op. - - * Made ". = X" and ".set .,X" equivalent to ".org X". - The pseudo-symbol "." has the value of the location the assembler is - currently assembling to. - -(In version 1.27) Jay Fenlason (hack) - - * Merged ns32k and i386 support. - -(In version 1.26) Jay Fenlason (hack) - - * Added partial ns32k support. - - * Added RMS's evil .word misfeature. Invented the -k (kludge) option - to warn that this misfeature was used. - - * Modified some files to get rid of warnings from GCC. - - * Added fix so that / can also be a comment character by itself. - -(In version 1.25) Jay Fenlason (hack) - - * Installed patches for VMS. - - * as.h (SIZEOF_STRUCT_FRAG): Added space before backslash-newline. - - * messages.c: Fixed typo. - - * app.c: Handle : correctly. - - * error.c: Removed; no longer used. - - * m68k-opcode.h: Added fnop. - Fixed to correctly handle fmovem with a register list and - non-predecriment addressing mode. - - * m68k-opcode.h: Fixed to know about long form of FBcc insns. - - * write.c: Warn if a fixup ended up being wider than its field width. - -(In version 1.24) Jay Fenlason (hack) - - * Accept and ignore -mc68010 and -m68010 switches. - - * Correctly assemble long subroutine calls on the 68000 without using a - 68020-specific instruction. - - * When calling with no filenames, read stdin. - -(In version 1.23) Jay Fenlason (hack) - - * app.c: Rewritten. - - * xmalloc.c, xrealloc.c: Replaced to work with GCC. - -(In version 1.22) Jay Fenlason (hack) - - * write.c: Fixed a VMS bug. - - * m68k.c: Fixed a bug having to do with turning absolute into - PC-relative. - - * atof-m68k.c (atof_m68k, gen_to_words): Try to avoid a problem with - running off the end of the LITTLENUMS. - - * vax.c: Fixed so parenthesized expressions work. - - * atof-generic.c: Added a cast that fixes problems with some C - compilers. - -(In version 1.21) - - * Changes for VMS support and correct bitfield order for - cross-assembly. - -(In version 1.20) - - * m68k*: Fixed "fmovel #N, fpcr". Added fpcr and fpsr to the list of - registers. - -(In version 1.19) - - * m68k.c? (md_convert_frag): Don't put the fixups for absolute long to - PC-relative in the data segment. - - * atof-generic.c: #include #ifdef sparc. - -(In version 1.18) - - * Re-fixed _vfprintf stuff (?). - - * Made "movem REG, ADDR" work. - - * Improved preprocessing, without temporary files. - -(In version 1.17) - - * Don't produce an undefined empty symbol for ".globl foo," (a line - ending with a comma). - - * Fixed a bug wherein ".long X" became ".long 0" on the Sparc. - - * Fixed a bug which caused many "#APP" "#NO_APP" pairs to dump core. - - * Fixed calls to _doprnt to call _vfprintf #ifndef NO_VARARGS. - -(In version 1.16) - - * Merged HP-UX changes from Chris Hanson (cph@zurich.ai.mit.edu). - - * flonum-multip.c: Renamed to flonum-mult.c. - - * m-hpux.h: Created. - - * m68k.c (bcopy): Fixed. - -(In version 1.15) - - * struct-symbol.h: Renamed to struc-symbol.h. - -(In version 1.14) - - * vax.c: Added a quick fix for the offset of fixed-width branches not - fitting in the field given. - - * gdb-lines.c, read.c: Added support for .gdline and .gdbline - pseudo-ops. - -(In version 1.13) - - * read.c, atof-generic.c: Fixed bugs in reading in floating-point - numbers. - - * m68k-opcode.h: Made "fmovep a0@, fp0" work. - -(In version 1.12) - - * write.c: Fixed an obscure bug in relaction that would occasionally - cause the assembler to stop relaxing when it really had at least one - more pass to do. - -(In version 1.11) - - * m68k*: Allow register lists in fmovem. - - * Added more floating-point exponents. - - * Print an error message on exponent overflow. - -(In version 1.10) - - * Fixed floating point bugs that made it generate incorrect numbers for - values over 10^16 or so. - -(In version 1.09) - - * Fixed bug wherein you couldn't forward reference local label 0. - -(In version 1.08) - - * m68k.c, m68k-opcode.h: Added support for fmovem with register lists. - - * Fixed an obscure bug having to do with generating PC-relative - addressing mode for things in the middle of the instruction instead of - at the end. - -Wed Mar 1 15:29:24 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * *.*: Modified copyright notices to reflect new General Public - License. - - * Makefile: Added copyright notice. - -Fri Feb 17 09:42:01 1989 Jay Fenlason (hack at spiff) - - * Patched frags.c so that new frags start out bzero()ed. - -Thu Jan 26 14:23:44 1989 Jay Fenlason (hack at apple-gunkies.ai.mit.edu) - - * Added patches from pace to files as.h i386.c i386-opcode.h - imull foo,%eax no longer gets assembled into the 32-64 bit - multiply, which clobbers %edx behind gcc's back - - jcxz/jecxz were backwards - - There was a bug when using %ebp as a base register with no - displacement - - Instructions like andb $0xffffff, %al used to put out too many - immediate bytes - - The splitting jump instructions across frags could happen when - obstack_room()==6 too. - -Local Variables: -mode: indented-text -left-margin: 8 -version-control: never -End: diff --git a/gas/GNUmakefile-host b/gas/GNUmakefile-host deleted file mode 100755 index 386c869b3a4..00000000000 --- a/gas/GNUmakefile-host +++ /dev/null @@ -1,6 +0,0 @@ -ALL := $(shell ls -d =*) - -%: - $(foreach subdir,$(ALL),$(MAKE) -C $(subdir) $@ &&) true - -gas: diff --git a/gas/Makefile-intel b/gas/Makefile-intel deleted file mode 100755 index 54487c217d8..00000000000 --- a/gas/Makefile-intel +++ /dev/null @@ -1,146 +0,0 @@ -#----------------------------------------------------------------------------- -# Makefile for gas960 -# -# $Id$ -#----------------------------------------------------------------------------- - -# The following two lines should be uncommented for system V (i386v). -#__i386v__#USG = -DUSG -#__i386v__#LIBS = -lmalloc -lPW - -# The following two lines should be uncommented for HP-UX -#__hp9000__#USG = -DUSG - -# The following line should be uncommented for Macintosh A/UX. -#__mac-aux__#USG = -DUSG - -#Always build with static libraries on Sun systems -#__sun3__#LDFLAGS = -Bstatic -#__sun386i__#LDFLAGS = -Bstatic -#__sun4__#LDFLAGS = -Bstatic - -# Essential under System V, harmless elsewhere -SHELL = /bin/sh - -TARG = gas960 -OPT = -g -IPATH = ../../include -CFLAGS = ${OPT} ${USG} -DI80960 -I${IPATH} - - -OBJS = app.o append.o as.o atof-generic.o bignum-copy.o expr.o \ - flonum-const.o flonum-copy.o flonum-mult.o frags.o gdb-blocks.o \ - gdb-file.o gdb-lines.o gdb-symbols.o gdb.o hash.o hex-value.o \ - input-file.o input-scrub.o messages.o obstack.o output-file.o read.o \ - strstr.o subsegs.o symbols.o version.o write.o xmalloc.o xrealloc.o - -# Note that we use the 386 floating-point support for the i80960 -I960OBJ = i960.o i960-opcode.o atof-i386.o - -gas960: ${OBJS} ${I960OBJ} VERSION - make ver960.o - ${CC} -o gas960 ${LDFLAGS} ${OBJS} ${I960OBJ} ver960.o ${LIBS} - -hash.o: hash.c - ${CC} -c ${CFLAGS} -Derror=as_fatal hash.c - -xmalloc.o: xmalloc.c - ${CC} -c ${CFLAGS} -Derror=as_fatal xmalloc.c - -xrealloc.o: xrealloc.c - ${CC} -c ${CFLAGS} -Derror=as_fatal xrealloc.c - -app.o: as.h - -as.o: ${IPATH}/b.out.h as.h read.h struc-symbol.h write.h -atof-generic.o: flonum.h -bignum-copy.o: bignum.h -expr.o: ${IPATH}/b.out.h as.h expr.h flonum.h obstack.h read.h -expr.o: struc-symbol.h symbols.h -flonum-const.o: flonum.h -flonum-copy.o: flonum.h -flonum-mult.o: flonum.h -flonum-normal.o:flonum.h -flonum-print.o: flonum.h -frags.o: ${IPATH}/b.out.h as.h frags.h obstack.h struc-symbol.h subsegs.h -gdb.o: as.h -gdb-blocks.o: as.h -gdb-lines.o: as.h frags.h obstack.h -gdb-symbols.o: ${IPATH}/b.out.h as.h struc-symbol.h -hash.o: hash.h -i960.o: as.h ${IPATH}/b.out.h expr.h flonum.h frags.h hash.h -i960.o: i960-opcode.h md.h obstack.h struc-symbol.h write.h -i960-opcode.o: i960-opcode.h -input-file.o: input-file.h -input-scrub.o: as.h input-file.h read.h -messages.o: as.h -obstack.o: obstack.h -read.o: ${IPATH}/b.out.h as.h expr.h flonum.h frags.h hash.h md.h -read.o: obstack.h read.h struc-symbol.h symbols.h -subsegs.o: ${IPATH}/b.out.h as.h frags.h obstack.h struc-symbol.h subsegs.h -subsegs.o: write.h -symbols.o: ${IPATH}/b.out.h as.h frags.h hash.h obstack.h struc-symbol.h -symbols.o: symbols.h -write.o: ${IPATH}/b.out.h as.h md.h obstack.h struc-symbol.h subsegs.h -write.o: symbols.h write.h - -flonum.h: bignum.h - -#----------------------------------------------------------------------------- -# 'STANDARD' GNU/960 TARGETS BELOW THIS POINT -# -# 'VERSION' file must be present and contain a string of the form "x.y" -#----------------------------------------------------------------------------- - -ver960.c: FORCE - rm -f ver960.c - echo "char ${TARG}_ver[]= \"${TARG} `cat VERSION`, `date`\";" > ver960.c - - -# This target should be invoked before building a new release. -# 'VERSION' file must be present and contain a string of the form "x.y" -# -roll: - @V=`cat VERSION` ; \ - MAJ=`sed 's/\..*//' VERSION` ; \ - MIN=`sed 's/.*\.//' VERSION` ; \ - V=$$MAJ.`expr $$MIN + 1` ; \ - rm -f VERSION ; \ - echo $$V >VERSION ; \ - echo Version $$V - -# Dummy target to force execution of dependent targets. -# -FORCE: - -# 'G960BASE' will be defined at invocation -install: - make ${TARG} OPT=-O - strip ${TARG} - rm -f ${G960BASE}/bin/${TARG} - mv ${TARG} ${G960BASE}/bin/${TARG} - -clean: - rm -f ${TARG} *.o core - -# Target to uncomment host-specific lines in this makefile. Such lines must -# have the following string beginning in column 1: #____# -# Original Makefile is backed up as 'Makefile.old'. -# -# Invoke with: make make HOST=xxx -# -make: - -@if test $(HOST)x = x ; then \ - echo 'Specify "make make HOST=???"'; \ - exit 1; \ - fi ; \ - grep -s "^#The next line was generated by 'make make'" Makefile; \ - if test $$? = 0 ; then \ - echo "Makefile has already been processed with 'make make'";\ - exit 1; \ - fi ; \ - mv -f Makefile Makefile.old; \ - echo "#The next line was generated by 'make make'" >Makefile ; \ - echo "HOST=$(HOST)" >>Makefile ; \ - echo >>Makefile ; \ - sed "s/^#__$(HOST)__#//" < Makefile.old >>Makefile diff --git a/gas/Makefile.generic b/gas/Makefile.generic deleted file mode 100755 index 1bf57a32667..00000000000 --- a/gas/Makefile.generic +++ /dev/null @@ -1,586 +0,0 @@ -host = generic -target = generic -# Makefile for GNU Assembler -# Copyright (C) 1987, 1988, 1990, 1991 Free Software Foundation, Inc. - -#This file is part of GNU GAS. - -#GNU GAS 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 1, or (at your option) -#any later version. - -#GNU GAS 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 GNU GAS; see the file COPYING. If not, write to -#the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - -# $Id$ - -# The targets for external use include: -# all, doc, proto, install, uninstall, includes, TAGS, -# clean, cleanconfig, realclean, stage1, stage2, stage3, stage4. - -# Variables that exist for you to override. -# See below for how to change them for certain systems. - -ALLOCA = -CFLAGS = -g $(XCFLAGS) # -I$(srcdir)/../include -INTERNAL_CFLAGS = $(CROSS) -OLDCC = cc -BISON = bison -BISONFLAGS = -v -AR = ar -OLDAR_FLAGS = qc -AR_FLAGS = rc -SHELL = /bin/sh -# on sysV, define this as cp. -INSTALL = install -c -# These permit overriding just for certain files. -INSTALL_PROGRAM = $(INSTALL) -INSTALL_FILE = $(INSTALL) - -# Define this as & to perform parallel make on a Sequent. -# Note that this has some bugs, and it seems currently necessary -# to compile all the gen* files first by hand to avoid erroneous results. -P = - -# How to invoke ranlib. -RANLIB = ranlib -# Test to use to see whether ranlib exists on the system. -RANLIB_TEST = [ -f /usr/bin/ranlib -o -f /bin/ranlib ] - -# CFLAGS for use with OLDCC, for compiling gnulib. -# NOTE: -O does not work on some Unix systems! -CCLIBFLAGS = -O - -# Version of ar to use when compiling gnulib. -OLDAR = ar - -version=`./gcc -dumpversion` - -# Directory where sources are, from where we are. -srcdir = . -# Common prefix for installation directories. -# NOTE: This directory must exist when you start installation. -prefix = /usr/local -# Directory in which to put the executable for the command `gcc' -bindir = $(prefix)/bin -# Directory in which to put the directories used by the compiler. -libdir = $(prefix)/lib -# Directory in which the compiler finds executables, libraries, etc. -libsubdir = $(libdir)/gcc/$(target)/$(version) -# Number to put in man-page filename. -manext = 1 -# Directory in which to put man pages. -mandir = $(prefix)/man/man$(manext) - -# Additional system libraries to link with. -CLIB= - -# Change this to a null string if obstacks are installed in the -# system library. -OBSTACK=obstack.o - -# Specify the rule for actually making gnulib. -GNULIB = gnulib.portable - -# Specify the rule for actually making gnulib2. -GNULIB2 = gnulib2.portable - -# List of extra C and assembler files to add to gnulib. -# Assembler files should have names ending in `.asm'. -LIBFUNCS_EXTRA = - -# Program to convert libraries. -LIBCONVERT = - -# Control whether header files are installed. -INSTALL_HEADERS=install-headers - -# Change this to empty to prevent installing limits.h -LIMITS_H = limits.h - -# Directory to link to, when using the target `maketest'. -DIR = ../gcc - -# For better debugging under COFF, define SEPARATE_AUX_OUTPUT in config.h -# and define the following variable as `aux-output2.c' in make-... -AUX_OUTPUT2 = - -# Flags to use when cross-building GCC. -# Prefix to apply to names of object files when using them -# to run on the machine we are compiling on. -HOST_PREFIX= -# Prefix to apply to names of object files when compiling them -# to run on the machine we are compiling on. -# The default for this variable is chosen to keep these rules -# out of the way of the other rules for compiling the same source files. -HOST_PREFIX_1=loser- -HOST_CC=$(CC) -HOST_CFLAGS=$(ALL_CFLAGS) -HOST_LDFLAGS=$(LDFLAGS) -HOST_CPPFLAGS=$(CPPFLAGS) - -# Choose the real default target. -ALL=bootstrap - -# End of variables for you to override. - -# Lists of files for various purposes. - -REAL_SOURCES = \ - $(srcdir)/app.c \ - $(srcdir)/as.c \ - $(srcdir)/atof-generic.c \ - $(srcdir)/bignum-copy.c \ - $(srcdir)/cond.c \ - $(srcdir)/expr.c \ - $(srcdir)/flonum-const.c \ - $(srcdir)/flonum-copy.c \ - $(srcdir)/flonum-mult.c \ - $(srcdir)/frags.c \ - $(srcdir)/hash.c \ - $(srcdir)/hex-value.c \ - $(srcdir)/input-file.c \ - $(srcdir)/input-scrub.c \ - $(srcdir)/messages.c \ - $(srcdir)/output-file.c \ - $(srcdir)/read.c \ - $(srcdir)/strstr.c \ - $(srcdir)/subsegs.c \ - $(srcdir)/symbols.c \ - $(srcdir)/version.c \ - $(srcdir)/write.c \ - $(srcdir)/xmalloc.c \ - $(srcdir)/xrealloc.c - -# in an expedient order -LINKED_SOURCES = \ - targ-cpu.c \ - obj-format.c \ - atof-targ.c - -SOURCES = $(LINKED_SOURCES) $(REAL_SOURCES) - -REAL_HEADERS = \ - $(srcdir)/as.h \ - $(srcdir)/bignum.h \ - $(srcdir)/expr.h \ - $(srcdir)/flonum.h \ - $(srcdir)/frags.h \ - $(srcdir)/hash.h \ - $(srcdir)/input-file.h \ - $(srcdir)/tc.h \ - $(srcdir)/obj.h \ - $(srcdir)/read.h \ - $(srcdir)/reloc.h \ - $(srcdir)/struc-symbol.h \ - $(srcdir)/subsegs.h \ - $(srcdir)/symbols.h \ - $(srcdir)/syscalls.h \ - $(srcdir)/write.h - -LINKED_HEADERS = \ - a.out.gnu.h \ - a.out.h \ - host.h \ - targ-env.h \ - targ-cpu.h \ - obj-format.h \ - atof-targ.h - -HEADERS = $(LINKED_HEADERS) $(REAL_HEADERS) - -OBJS = \ - targ-cpu.o \ - obj-format.o \ - atof-targ.o \ - app.o \ - as.o \ - atof-generic.o \ - bignum-copy.o \ - cond.o \ - expr.o \ - flonum-const.o \ - flonum-copy.o \ - flonum-mult.o \ - frags.o \ - hash.o \ - hex-value.o \ - input-file.o \ - input-scrub.o \ - messages.o \ - output-file.o \ - read.o \ - strstr.o \ - subsegs.o \ - symbols.o \ - version.o \ - write.o \ - xmalloc.o \ - xrealloc.o - -# Definition of `all' is here so that new rules inserted by sed -# do not specify the default target. -# The real definition is under `all.internal'. - -all: $(ALL) - -# sed inserts variable overrides after the following line. -#### - -# Now figure out from those variables how to compile and link. - -# This is the variable actually used when we compile. -ALL_CFLAGS = $(INTERNAL_CFLAGS) $(CFLAGS) - -# Even if ALLOCA is set, don't use it if compiling with GCC. -USE_ALLOCA= `if [ x"${CC}" = x"${OLDCC}" ] ; then echo ${ALLOCA}; else true; fi` -USE_HOST_ALLOCA= `if [ x"${CC}" = x"${OLDCC}" ] ; then echo ${HOST_PREFIX}${ALLOCA}; else true; fi` - -# Dependency on obstack, alloca, malloc or whatever library facilities -# are not installed in the system libraries. -# We don't use USE_ALLOCA because backquote expansion doesn't work in deps. -LIBDEPS= $(OBSTACK) $(ALLOCA) $(MALLOC) - -# Likewise, for use in the tools that must run on this machine -# even if we are cross-building GCC. -# We don't use USE_ALLOCA because backquote expansion doesn't work in deps. -HOST_LIBDEPS= $(HOST_PREFIX)$(OBSTACK) $(HOST_PREFIX)$(ALLOCA) $(HOST_PREFIX)$(MALLOC) - -# How to link with both our special library facilities -# and the system's installed libraries. -LIBS = $(OBSTACK) $(USE_ALLOCA) $(MALLOC) $(CLIB) - -# Likewise, for use in the tools that must run on this machine -# even if we are cross-building GCC. -HOST_LIBS = $(HOST_PREFIX)$(OBSTACK) $(USE_HOST_ALLOCA) $(HOST_PREFIX)$(MALLOC) $(CLIB) - -# Specify the directories to be searched for header files. -# Both . and srcdir are used, in that order, -# so that tm.h and config.h will be found in the compilation -# subdirectory rather than in the source directory. -INCLUDES = -I. -I$(srcdir) -I$(srcdir)/config -SUBDIR_INCLUDES = -I.. -I../$(srcdir) -I../$(srcdir)/config - -# Always use -I$(srcdir)/config when compiling. -.c.o: - $(CC) -c $(ALL_CFLAGS) $(CPPFLAGS) $(INCLUDES) $< - -# This tells GNU make version 3 not to export all the variables -# defined in this file into the environment. -.NOEXPORT: - -# Files to be copied away after each stage in building. -STAGE_GCC=gcc -STAGESTUFF = *.o gas - -# The files that "belong" in CONFIG_H are deliberately omitted -# because having them there would not be useful in actual practice. -# All they would do is cause complete recompilation every time -# one of the machine description files is edited. -# That may or may not be what one wants to do. -# If it is, rm *.o is an easy way to do it. -# CONFIG_H = config.h tm.h -CONFIG_H = - -gas: $(OBJS) $(LIBDEPS) - $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o gas $(OBJS) $(LIBS) - -all.internal: native -# This is what is made with the host's compiler if making a cross assembler. -native: config.status gas - -config.status: - @echo You must configure gas. Look at the INSTALL file for details. - @false - -compilations: ${OBJS} - -# Compiling object files from source files. - -# Note that dependencies on obstack.h are not written -# because that file is not part of GAS. - -app.o : app.c as.h host.h targ-env.h obj-format.h \ - targ-cpu.h struc-symbol.h reloc.h \ - write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h -as.o : as.c as.h host.h targ-env.h obj-format.h \ - targ-cpu.h struc-symbol.h reloc.h \ - write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h -atof-generic.o : atof-generic.c as.h host.h targ-env.h obj-format.h \ - targ-cpu.h struc-symbol.h reloc.h \ - write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h -bignum-copy.o : bignum-copy.c as.h host.h \ - targ-env.h obj-format.h \ - targ-cpu.h struc-symbol.h reloc.h \ - write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h -cond.o : cond.c as.h host.h targ-env.h obj-format.h \ - targ-cpu.h struc-symbol.h reloc.h \ - write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h \ - obstack.h -debug.o : debug.c as.h host.h targ-env.h obj-format.h \ - targ-cpu.h struc-symbol.h reloc.h \ - write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h \ - subsegs.h -expr.o : expr.c as.h host.h targ-env.h obj-format.h \ - targ-cpu.h struc-symbol.h reloc.h \ - write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h \ - obstack.h -flonum-const.o : flonum-const.c flonum.h bignum.h -flonum-copy.o : flonum-copy.c as.h host.h targ-env.h obj-format.h \ - targ-cpu.h struc-symbol.h reloc.h \ - write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h -flonum-mult.o : flonum-mult.c flonum.h bignum.h -frags.o : frags.c as.h host.h targ-env.h obj-format.h \ - targ-cpu.h struc-symbol.h reloc.h \ - write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h \ - subsegs.h obstack.h -hash.o : hash.c as.h host.h targ-env.h obj-format.h \ - targ-cpu.h struc-symbol.h reloc.h \ - write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h -hex-value.o : hex-value.c -input-file.o : input-file.c as.h host.h \ - targ-env.h obj-format.h targ-cpu.h \ - struc-symbol.h reloc.h write.h flonum.h bignum.h expr.h \ - frags.h hash.h read.h symbols.h tc.h obj.h input-file.h -input-scrub.o : input-scrub.c /usr/include/errno.h /usr/include/sys/errno.h \ - as.h host.h targ-env.h obj-format.h \ - targ-cpu.h struc-symbol.h reloc.h \ - write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h \ - input-file.h -messages.o : messages.c as.h host.h targ-env.h obj-format.h \ - targ-cpu.h struc-symbol.h reloc.h \ - write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h -obstack.o : obstack.c obstack.h -output-file.o : output-file.c as.h host.h targ-env.h obj-format.h \ - targ-cpu.h struc-symbol.h reloc.h \ - write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h \ - output-file.h -read.o : read.c as.h host.h targ-env.h obj-format.h \ - targ-cpu.h struc-symbol.h reloc.h \ - write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h \ - obstack.h -strstr.o : strstr.c -subsegs.o : subsegs.c as.h host.h targ-env.h obj-format.h \ - targ-cpu.h struc-symbol.h reloc.h \ - write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h \ - subsegs.h obstack.h -symbols.o : symbols.c as.h host.h targ-env.h obj-format.h \ - targ-cpu.h struc-symbol.h reloc.h \ - write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h \ - obstack.h subsegs.h -version.o : version.c -write.o : write.c as.h host.h targ-env.h obj-format.h \ - targ-cpu.h struc-symbol.h reloc.h \ - write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h \ - subsegs.h obstack.h output-file.h -xmalloc.o : xmalloc.c -xrealloc.o : xrealloc.c -atof-targ.o : atof-targ.c as.h host.h targ-env.h obj-format.h \ - targ-cpu.h struc-symbol.h reloc.h \ - write.h flonum.h bignum.h expr.h frags.h hash.h read.h \ - symbols.h tc.h obj.h -obj-format.o : obj-format.c as.h host.h targ-env.h obj-format.h \ - targ-cpu.h struc-symbol.h reloc.h \ - write.h flonum.h bignum.h expr.h frags.h hash.h read.h \ - symbols.h tc.h obj.h obstack.h -targ-cpu.o : targ-cpu.c targ-env.h obj-format.h \ - targ-cpu.h struc-symbol.h reloc.h \ - write.h flonum.h bignum.h expr.h frags.h hash.h read.h \ - symbols.h tc.h obj.h obstack.h - -# Normally this target is not used; but it is used if you -# define ALLOCA=alloca.o. In that case, you must get a suitable alloca.c -# from the GNU Emacs distribution. -# Note some machines won't allow $(CC) without -S on this source file. -alloca.o: alloca.c - $(CC) $(ALL_CFLAGS) $(CPPFLAGS) -S `echo $(srcdir)/alloca.c | sed 's,^\./,,'` - as alloca.s -o alloca.o - -# Compile the libraries to be used by gen*. -# If we are not cross-building, gen* use the same .o's that cc1 will use, -# and HOST_PREFIX_1 is `foobar', just to ensure these rules don't conflict -# with the rules for rtl.o, alloca.o, etc. -$(HOST_PREFIX_1)alloca.o: alloca.c - rm -f $(HOST_PREFIX)alloca.c - cp $(srcdir)/alloca.c $(HOST_PREFIX)alloca.c - $(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(HOST_PREFIX)alloca.c - -$(HOST_PREFIX_1)obstack.o: obstack.c - rm -f $(HOST_PREFIX)obstack.c - cp $(srcdir)/obstack.c $(HOST_PREFIX)obstack.c - $(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(HOST_PREFIX)obstack.c - -$(HOST_PREFIX_1)malloc.o: malloc.c - rm -f $(HOST_PREFIX)malloc.c - cp $(srcdir)/malloc.c $(HOST_PREFIX)malloc.c - $(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(HOST_PREFIX)malloc.c - -# Remake the info files. - -doc: $(srcdir)/gas.info - -$(srcdir)/gas.info: $(srcdir)/gas.texinfo - makeinfo `echo $(srcdir)/gas.texinfo | sed 's,^\./,,'` - - -# Deletion of files made during compilation. -# There are three levels of this: `clean', `cleanconfig' and `realclean'. -# `clean' deletes what you want to delete ordinarily to save space. -# This is most, but not all, of the files made by compilation. -# `cleanconfig' also deletes everything depending -# on the choice of config files. -# `realclean' also deletes everything that could be regenerated automatically. - -clean: - -rm -f $(STAGESTUFF) -# Delete the temporary source copies for cross compilation. - -rm -f $(HOST_PREFIX_1)alloca.c $(HOST_PREFIX_1)malloc.c - -rm -f $(HOST_PREFIX_1)obstack.c -# Delete the stamp files except stamp-gnulib2. - -rm -f core - -# Like clean but also delete the links made to configure gas. -cleanconfig: clean - -rm -f config.status Makefile host.h targ-env.h - -rm -f targ-cpu.h targ-cpu.c - -rm -f obj-format.h obj-format.c - -rm -f atof-targ.c - -# Get rid of every file that's generated from some other file (except INSTALL). -realclean: cleanconfig - -rm -f gas.aux gas.cps gas.fns gas.info gas.kys gas.pgs gas.tps gas.vrs - -rm -f TAGS - -rm -f gas.info* gas.?? gas.??s gas.log gas.toc gas.*aux - -rm -f *.dvi - -# Entry points `install', `includes' and `uninstall'. - -# Copy the files into directories where they will be run. -install: - $(INSTALL_PROGRAM) gas $(bindir)/as - -# Create the installation directory. -install-dir: - -mkdir $(libdir) - -mkdir $(libdir)/gcc - -mkdir $(libdir)/gcc/$(target) - -mkdir $(libdir)/gcc/$(target)/$(version) - -# Install the compiler executables built during cross compilation. -install-cross: native install-dir - -if [ -f cc1 ] ; then $(INSTALL_PROGRAM) cc1 $(libsubdir)/cc1; else true; fi - -if [ -f cc1plus ] ; then $(INSTALL_PROGRAM) cc1plus $(libsubdir)/cc1plus; else true; fi - $(INSTALL_PROGRAM) cpp $(libsubdir)/cpp - ./gcc -dumpspecs > $(libsubdir)/specs - $(INSTALL_PROGRAM) gcc $(bindir)/gcc - -# Install the man pages. -install-man: install-dir $(srcdir)/gcc.1 protoize.1 unprotoize.1 - $(INSTALL_FILE) $(srcdir)/gcc.1 $(mandir)/gcc.$(manext) - chmod a-x $(mandir)/gcc.$(manext) - $(INSTALL_FILE) $(srcdir)/protoize.1 $(mandir)/protoize.$(manext) - chmod a-x $(mandir)/protoize.$(manext) - $(INSTALL_FILE) $(srcdir)/unprotoize.1 $(mandir)/unprotoize.$(manext) - chmod a-x $(mandir)/unprotoize.$(manext) - -# Cancel installation by deleting the installed files. -uninstall: - -rm -rf $(libsubdir) - -rm -rf $(bindir)/gas - -rm -rf $(mandir)/gas.$(manext) - - -# These exist for maintenance purposes. - -tags TAGS: force - etags $(REAL_SOURCES) $(REAL_HEADERS) README Makefile config/*.[hc] - -bootstrap: gas force - $(MAKE) stage1 - $(MAKE) CC="$(CC)" CFLAGS="-O -Bstage1/ $(CFLAGS)" libdir=$(libdir) ALLOCA= gas - $(MAKE) stage2 - $(MAKE) CC="$(CC)" CFLAGS="-O -Bstage2/ $(CFLAGS)" libdir=$(libdir) ALLOCA= gas - for i in *.o; do cmp $$i stage2/$$i; done - -bootstrap2: force - $(MAKE) CC="$(CC)" CFLAGS="-O -Bstage1/ $(CFLAGS)" libdir=$(libdir) ALLOCA= gas - $(MAKE) stage2 - $(MAKE) CC="$(CC)" CFLAGS="-O -Bstage2/ $(CFLAGS)" libdir=$(libdir) ALLOCA= gas - for i in *.o; do cmp $$i stage2/$$i; done - -bootstrap3: force - $(MAKE) CC="$(CC)" CFLAGS="-O -Bstage2/ $(CFLAGS)" libdir=$(libdir) ALLOCA= gas - for i in *.o; do cmp $$i stage2/$$i; done - -# Copy the object files from a particular stage into a subdirectory. -stage1: force - -mkdir stage1 - -mv $(STAGESTUFF) stage1 - -(cd stage1 ; ln -s gas as) - -stage2: force - -mkdir stage2 - -mv $(STAGESTUFF) stage2 - -(cd stage2 ; ln -s gas as) - - -stage3: force - -mkdir stage3 - -mv $(STAGESTUFF) $(STAGE_GCC) stage3 - -rm -f stage3/gnulib - -cp gnulib stage3 - -if $(RANLIB_TEST) ; then $(RANLIB) stage3/gnulib; else true; fi - -stage4: force - -mkdir stage4 - -mv $(STAGESTUFF) $(STAGE_GCC) stage4 - -rm -f stage4/gnulib - -cp gnulib stage4 - -if $(RANLIB_TEST) ; then $(RANLIB) stage4/gnulib; else true; fi - -# Copy just the executable files from a particular stage into a subdirectory, -# and delete the object files. Use this if you're just verifying a version -# that is pretty sure to work, and you are short of disk space. -risky-stage1: force - -mkdir stage1 - -mv cc1 cpp cccp gcc stage1 - -rm -f stage1/gnulib - -cp gnulib stage1 && $(RANLIB) stage1/gnulib - -make clean - -risky-stage2: force - -mkdir stage2 - -mv cc1 cpp cccp gcc stage2 - -rm -f stage2/gnulib - -cp gnulib stage2 && $(RANLIB) stage2/gnulib - -make clean - -risky-stage3: force - -mkdir stage3 - -mv cc1 cpp cccp gcc stage3 - -rm -f stage3/gnulib - -cp gnulib stage3 && $(RANLIB) stage3/gnulib - -make clean - -risky-stage4: force - -mkdir stage4 - -mv cc1 cpp cccp gcc stage4 - -rm -f stage4/gnulib - -cp gnulib stage4 && $(RANLIB) stage4/gnulib - -make clean - -#In GNU Make, ignore whether `stage*' exists. -.PHONY: stage1 stage2 stage3 stage4 clean realclean TAGS bootstrap -.PHONY: risky-stage1 risky-stage2 risky-stage3 risky-stage4 - -force: - -Makefile: $(srcdir)/Makefile.in $(srcdir)/configure - $(srcdir)/configure.was -srcdir=$(srcdir) -host=$(host) $(target) diff --git a/gas/Makefile.in b/gas/Makefile.in deleted file mode 100644 index 1a3401c461f..00000000000 --- a/gas/Makefile.in +++ /dev/null @@ -1,581 +0,0 @@ -# Makefile for GNU Assembler -# Copyright (C) 1987, 1988, 1990, 1991 Free Software Foundation, Inc. - -#This file is part of GNU GAS. - -#GNU GAS 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 1, or (at your option) -#any later version. - -#GNU GAS 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 GNU GAS; see the file COPYING. If not, write to -#the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - -# $Id$ - -# The targets for external use include: -# all, doc, proto, install, uninstall, includes, TAGS, -# clean, cleanconfig, realclean, stage1, stage2, stage3, stage4. - -# Variables that exist for you to override. -# See below for how to change them for certain systems. - -ALLOCA = -CFLAGS = -g $(XCFLAGS) -I$(srcdir)/../include -INTERNAL_CFLAGS = $(CROSS) -OLDCC = cc -BISON = bison -BISONFLAGS = -v -AR = ar -OLDAR_FLAGS = qc -AR_FLAGS = rc -SHELL = /bin/sh -# on sysV, define this as cp. -INSTALL = install -c -# These permit overriding just for certain files. -INSTALL_PROGRAM = $(INSTALL) -INSTALL_FILE = $(INSTALL) - -# Define this as & to perform parallel make on a Sequent. -# Note that this has some bugs, and it seems currently necessary -# to compile all the gen* files first by hand to avoid erroneous results. -P = - -# How to invoke ranlib. -RANLIB = ranlib -# Test to use to see whether ranlib exists on the system. -RANLIB_TEST = [ -f /usr/bin/ranlib -o -f /bin/ranlib ] - -# CFLAGS for use with OLDCC, for compiling gnulib. -# NOTE: -O does not work on some Unix systems! -CCLIBFLAGS = -O - -# Version of ar to use when compiling gnulib. -OLDAR = ar - -version=`$(unsubdir)/../gcc$(subdir)/gcc -dumpversion` - -# Directory where sources are, from where we are. -srcdir = . -# Common prefix for installation directories. -# NOTE: This directory must exist when you start installation. -ddestdir = /usr/local -# Directory in which to put the executable for the command `gcc' -bindir = $(ddestdir)/bin -# Directory in which to put the directories used by the compiler. -libdir = $(ddestdir)/lib -# Directory in which the compiler finds executables, libraries, etc. -libsubdir = $(libdir)/gcc/$(target_alias)/$(version) -# Number to put in man-page filename. -manext = 1 -# Directory in which to put man pages. -mandir = $(destdir)/H-independent/man/man$(manext) - -# Additional system libraries to link with. -CLIB= - -# Specify the rule for actually making gnulib. -GNULIB = gnulib.portable - -# Specify the rule for actually making gnulib2. -GNULIB2 = gnulib2.portable - -# List of extra C and assembler files to add to gnulib. -# Assembler files should have names ending in `.asm'. -LIBFUNCS_EXTRA = - -# Program to convert libraries. -LIBCONVERT = - -# Control whether header files are installed. -INSTALL_HEADERS=install-headers - -# Change this to empty to prevent installing limits.h -LIMITS_H = limits.h - -# Directory to link to, when using the target `maketest'. -DIR = ../gcc - -# For better debugging under COFF, define SEPARATE_AUX_OUTPUT in config.h -# and define the following variable as `aux-output2.c' in make-... -AUX_OUTPUT2 = - -# Flags to use when cross-building GCC. -# Prefix to apply to names of object files when using them -# to run on the machine we are compiling on. -HOST_PREFIX= -# Prefix to apply to names of object files when compiling them -# to run on the machine we are compiling on. -# The default for this variable is chosen to keep these rules -# out of the way of the other rules for compiling the same source files. -HOST_PREFIX_1=loser- -HOST_CC=$(CC) -HOST_CFLAGS=$(ALL_CFLAGS) -HOST_LDFLAGS=$(LDFLAGS) -HOST_CPPFLAGS=$(CPPFLAGS) - -# Choose the real default target. -ALL=as.new - -# End of variables for you to override. - -# Lists of files for various purposes. - -REAL_SOURCES = \ - $(srcdir)/app.c \ - $(srcdir)/as.c \ - $(srcdir)/atof-generic.c \ - $(srcdir)/bignum-copy.c \ - $(srcdir)/cond.c \ - $(srcdir)/expr.c \ - $(srcdir)/flonum-const.c \ - $(srcdir)/flonum-copy.c \ - $(srcdir)/flonum-mult.c \ - $(srcdir)/frags.c \ - $(srcdir)/hash.c \ - $(srcdir)/hex-value.c \ - $(srcdir)/input-file.c \ - $(srcdir)/input-scrub.c \ - $(srcdir)/messages.c \ - $(srcdir)/output-file.c \ - $(srcdir)/read.c \ - $(srcdir)/strstr.c \ - $(srcdir)/subsegs.c \ - $(srcdir)/symbols.c \ - $(srcdir)/version.c \ - $(srcdir)/write.c \ - $(srcdir)/xmalloc.c \ - $(srcdir)/xrealloc.c - -# in an expedient order -LINKED_SOURCES = \ - targ-cpu.c \ - obj-format.c \ - atof-targ.c - -SOURCES = $(LINKED_SOURCES) $(REAL_SOURCES) - -REAL_HEADERS = \ - $(srcdir)/as.h \ - $(srcdir)/bignum.h \ - $(srcdir)/expr.h \ - $(srcdir)/flonum.h \ - $(srcdir)/frags.h \ - $(srcdir)/hash.h \ - $(srcdir)/input-file.h \ - $(srcdir)/tc.h \ - $(srcdir)/obj.h \ - $(srcdir)/read.h \ - $(srcdir)/struc-symbol.h \ - $(srcdir)/subsegs.h \ - $(srcdir)/symbols.h \ - $(srcdir)/syscalls.h \ - $(srcdir)/write.h - -LINKED_HEADERS = \ - a.out.gnu.h \ - a.out.h \ - host.h \ - targ-env.h \ - targ-cpu.h \ - obj-format.h \ - atof-targ.h - -HEADERS = $(LINKED_HEADERS) $(REAL_HEADERS) - -OBJS = \ - targ-cpu.o \ - obj-format.o \ - atof-targ.o \ - app.o \ - as.o \ - atof-generic.o \ - bignum-copy.o \ - cond.o \ - expr.o \ - flonum-const.o \ - flonum-copy.o \ - flonum-mult.o \ - frags.o \ - hash.o \ - hex-value.o \ - input-file.o \ - input-scrub.o \ - messages.o \ - output-file.o \ - read.o \ - strstr.o \ - subsegs.o \ - symbols.o \ - version.o \ - write.o \ - xmalloc.o \ - xrealloc.o - -#### host, target, and site specific Makefile frags come in here. - -# Definition of `all' is here so that new rules inserted by sed -# do not specify the default target. -# The real definition is under `all.internal'. - -all: $(ALL) - -fake-as: force - - rm -f ./as.new - cp /bin/as ./fake-as - -# Now figure out from those variables how to compile and link. - -# This is the variable actually used when we compile. -ALL_CFLAGS = $(INTERNAL_CFLAGS) $(CFLAGS) $(HDEFINES) $(TDEFINES) - -# Even if ALLOCA is set, don't use it if compiling with GCC. -USE_ALLOCA= `if [ x"${CC}" = x"${OLDCC}" ] ; then echo ${ALLOCA}; else true; fi` -USE_HOST_ALLOCA= `if [ x"${CC}" = x"${OLDCC}" ] ; then echo ${HOST_PREFIX}${ALLOCA}; else true; fi` - -# Likewise, for use in the tools that must run on this machine -# even if we are cross-building GCC. -# We don't use USE_ALLOCA because backquote expansion doesn't work in deps. -HOST_LIBDEPS= $(HOST_PREFIX)$(OBSTACK) $(HOST_PREFIX)$(ALLOCA) $(HOST_PREFIX)$(MALLOC) - -# How to link with both our special library facilities -# and the system's installed libraries. - -LIBS = $(LOCAL_LOADLIBES) $(CLIB) $(unsubdir)/../libiberty$(subdir)/libiberty.a - -# Likewise, for use in the tools that must run on this machine -# even if we are cross-building GCC. -HOST_LIBS = $(HOST_PREFIX)$(OBSTACK) $(USE_HOST_ALLOCA) $(HOST_PREFIX)$(MALLOC) $(CLIB) - -# Specify the directories to be searched for header files. -# Both . and srcdir are used, in that order, -# so that tm.h and config.h will be found in the compilation -# subdirectory rather than in the source directory. -INCLUDES = -I. -I$(srcdir) -I$(srcdir)/config -SUBDIR_INCLUDES = -I.. -I../$(srcdir) -I../$(srcdir)/config - -# Always use -I$(srcdir)/config when compiling. -.c.o: - $(CC) -c $(ALL_CFLAGS) $(CPPFLAGS) $(INCLUDES) $< - -# This tells GNU make version 3 not to export all the variables -# defined in this file into the environment. -.NOEXPORT: - -# Files to be copied away after each stage in building. -STAGE_GCC=gcc -STAGESTUFF = *.o as.new - -# The files that "belong" in CONFIG_H are deliberately omitted -# because having them there would not be useful in actual practice. -# All they would do is cause complete recompilation every time -# one of the machine description files is edited. -# That may or may not be what one wants to do. -# If it is, rm *.o is an easy way to do it. -# CONFIG_H = config.h tm.h -CONFIG_H = - -as.new: $(OBJS) $(LIBDEPS) - -mv -f as.new as.old - $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o as.new $(OBJS) $(LIBS) $(LOADLIBES) - -objdump: - -all.internal: native -# This is what is made with the host's compiler if making a cross assembler. -native: config.status as - -config.status: - @echo You must configure gas. Look at the INSTALL file for details. - @false - -compilations: ${OBJS} - -# Compiling object files from source files. - -app.o : app.c as.h host.h targ-env.h obj-format.h \ - targ-cpu.h struc-symbol.h \ - write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h -as.o : as.c as.h host.h targ-env.h obj-format.h \ - targ-cpu.h struc-symbol.h \ - write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h -atof-generic.o : atof-generic.c as.h host.h targ-env.h obj-format.h \ - targ-cpu.h struc-symbol.h \ - write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h -bignum-copy.o : bignum-copy.c as.h host.h \ - targ-env.h obj-format.h \ - targ-cpu.h struc-symbol.h \ - write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h -cond.o : cond.c as.h host.h targ-env.h obj-format.h \ - targ-cpu.h struc-symbol.h \ - write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h \ - -debug.o : debug.c as.h host.h targ-env.h obj-format.h \ - targ-cpu.h struc-symbol.h \ - write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h \ - subsegs.h -expr.o : expr.c as.h host.h targ-env.h obj-format.h \ - targ-cpu.h struc-symbol.h \ - write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h \ - -flonum-const.o : flonum-const.c flonum.h bignum.h -flonum-copy.o : flonum-copy.c as.h host.h targ-env.h obj-format.h \ - targ-cpu.h struc-symbol.h \ - write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h -flonum-mult.o : flonum-mult.c flonum.h bignum.h -frags.o : frags.c as.h host.h targ-env.h obj-format.h \ - targ-cpu.h struc-symbol.h \ - write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h \ - subsegs.h -hash.o : hash.c as.h host.h targ-env.h obj-format.h \ - targ-cpu.h struc-symbol.h \ - write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h -hex-value.o : hex-value.c -input-file.o : input-file.c as.h host.h \ - targ-env.h obj-format.h targ-cpu.h \ - struc-symbol.h write.h flonum.h bignum.h expr.h \ - frags.h hash.h read.h symbols.h tc.h obj.h input-file.h -input-scrub.o : input-scrub.c /usr/include/errno.h /usr/include/sys/errno.h \ - as.h host.h targ-env.h obj-format.h \ - targ-cpu.h struc-symbol.h \ - write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h \ - input-file.h -messages.o : messages.c as.h host.h targ-env.h obj-format.h \ - targ-cpu.h struc-symbol.h \ - write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h -obstack.o : obstack.c -output-file.o : output-file.c as.h host.h targ-env.h obj-format.h \ - targ-cpu.h struc-symbol.h \ - write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h \ - output-file.h -read.o : read.c as.h host.h targ-env.h obj-format.h \ - targ-cpu.h struc-symbol.h \ - write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h \ - -strstr.o : strstr.c -subsegs.o : subsegs.c as.h host.h targ-env.h obj-format.h \ - targ-cpu.h struc-symbol.h \ - write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h \ - subsegs.h -symbols.o : symbols.c as.h host.h targ-env.h obj-format.h \ - targ-cpu.h struc-symbol.h \ - write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h \ - subsegs.h -version.o : version.c -write.o : write.c as.h host.h targ-env.h obj-format.h \ - targ-cpu.h struc-symbol.h \ - write.h flonum.h bignum.h expr.h frags.h hash.h read.h symbols.h tc.h obj.h \ - subsegs.h output-file.h -xmalloc.o : xmalloc.c -xrealloc.o : xrealloc.c -atof-targ.o : atof-targ.c as.h host.h targ-env.h obj-format.h \ - targ-cpu.h struc-symbol.h \ - write.h flonum.h bignum.h expr.h frags.h hash.h read.h \ - symbols.h tc.h obj.h -obj-format.o : obj-format.c as.h host.h targ-env.h obj-format.h \ - targ-cpu.h struc-symbol.h \ - write.h flonum.h bignum.h expr.h frags.h hash.h read.h \ - symbols.h tc.h obj.h -targ-cpu.o : targ-cpu.c targ-env.h obj-format.h \ - targ-cpu.h struc-symbol.h \ - write.h flonum.h bignum.h expr.h frags.h hash.h read.h \ - symbols.h tc.h obj.h $(TARG_CPU_DEPENDENTS) - - -# Compile the libraries to be used by gen*. -# If we are not cross-building, gen* use the same .o's that cc1 will use, -# and HOST_PREFIX_1 is `foobar', just to ensure these rules don't conflict -# with the rules for rtl.o, alloca.o, etc. -$(HOST_PREFIX_1)alloca.o: alloca.c - rm -f $(HOST_PREFIX)alloca.c - cp $(srcdir)/alloca.c $(HOST_PREFIX)alloca.c - $(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(HOST_PREFIX)alloca.c - -$(HOST_PREFIX_1)obstack.o: obstack.c - rm -f $(HOST_PREFIX)obstack.c - cp $(srcdir)/obstack.c $(HOST_PREFIX)obstack.c - $(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(HOST_PREFIX)obstack.c - -$(HOST_PREFIX_1)malloc.o: malloc.c - rm -f $(HOST_PREFIX)malloc.c - cp $(srcdir)/malloc.c $(HOST_PREFIX)malloc.c - $(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(HOST_PREFIX)malloc.c - -# Remake the info files. - -doc: $(srcdir)/as.info - -$(srcdir)/as.info: $(srcdir)/doc/as.texinfo - (cd doc; make as.info; mv as.info $srcdir) - - -# Deletion of files made during compilation. -# There are three levels of this: `clean', `cleanconfig' and `realclean'. -# `clean' deletes what you want to delete ordinarily to save space. -# This is most, but not all, of the files made by compilation. -# `cleanconfig' also deletes everything depending -# on the choice of config files. -# `realclean' also deletes everything that could be regenerated automatically. - -clean: - -rm -f $(STAGESTUFF) -# Delete the temporary source copies for cross compilation. - -rm -f $(HOST_PREFIX_1)alloca.c $(HOST_PREFIX_1)malloc.c - -rm -f $(HOST_PREFIX_1)obstack.c -# Delete the stamp files except stamp-gnulib2. - -rm -f core - -# Like clean but also delete the links made to configure gas. -cleanconfig: clean - -rm -f config.status Makefile host.h targ-env.h - -rm -f targ-cpu.h targ-cpu.c - -rm -f obj-format.h obj-format.c - -rm -f atof-targ.c - -# Get rid of every file that's generated from some other file (except INSTALL). -realclean: cleanconfig - -rm -f gas.aux gas.cps gas.fns gas.info gas.kys gas.pgs gas.tps gas.vrs - -rm -f TAGS - -rm -f gas.info* gas.?? gas.??s gas.log gas.toc gas.*aux - -rm -f *.dvi - -# Entry points `install', `includes' and `uninstall'. - -# Copy the files into directories where they will be run. -install: $(ALL) - $(INSTALL_PROGRAM) $(ALL) $(libsubdir)/as -# cp $(ALL) $(bindir)/as.new -# mv -f $(bindir)/as.new $(bindir)/as - -# Create the installation directory. -install-dir: - -mkdir $(libdir) - -mkdir $(libdir)/gcc - -mkdir $(libdir)/gcc/$(target) - -mkdir $(libdir)/gcc/$(target)/$(version) - -# Install the compiler executables built during cross compilation. -install-cross: native install-dir - -if [ -f cc1 ] ; then $(INSTALL_PROGRAM) cc1 $(libsubdir)/cc1; else true; fi - -if [ -f cc1plus ] ; then $(INSTALL_PROGRAM) cc1plus $(libsubdir)/cc1plus; else true; fi - $(INSTALL_PROGRAM) cpp $(libsubdir)/cpp - ./gcc -dumpspecs > $(libsubdir)/specs - $(INSTALL_PROGRAM) gcc $(bindir)/gcc - -# Install the man pages. -install-man: install-dir $(srcdir)/gcc.1 protoize.1 unprotoize.1 - $(INSTALL_FILE) $(srcdir)/gcc.1 $(mandir)/gcc.$(manext) - chmod a-x $(mandir)/gcc.$(manext) - $(INSTALL_FILE) $(srcdir)/protoize.1 $(mandir)/protoize.$(manext) - chmod a-x $(mandir)/protoize.$(manext) - $(INSTALL_FILE) $(srcdir)/unprotoize.1 $(mandir)/unprotoize.$(manext) - chmod a-x $(mandir)/unprotoize.$(manext) - -# Cancel installation by deleting the installed files. -uninstall: - -rm -rf $(libsubdir) - -rm -rf $(bindir)/as - -rm -rf $(mandir)/gas.$(manext) - - -# These exist for maintenance purposes. - -tags TAGS: force - etags $(REAL_SOURCES) $(REAL_HEADERS) $(srcdir)/README $(srcdir)/Makefile $(srcdir)/config/*.[hc] - -bootstrap: $(ALL) force - $(MAKE) stage1 - $(MAKE) CC="$(CC)" CFLAGS="-O -Bstage1/ $(CFLAGS)" libdir=$(libdir) ALLOCA= $(ALL) - $(MAKE) stage2 - $(MAKE) CC="$(CC)" CFLAGS="-O -Bstage2/ $(CFLAGS)" libdir=$(libdir) ALLOCA= $(ALL) - $(MAKE) comparison against=stage2 - -bootstrap2: force - $(MAKE) CC="$(CC)" CFLAGS="-O -Bstage1/ $(CFLAGS)" libdir=$(libdir) ALLOCA= $(ALL) - $(MAKE) stage2 - $(MAKE) CC="$(CC)" CFLAGS="-O -Bstage2/ $(CFLAGS)" libdir=$(libdir) ALLOCA= $(ALL) - $(MAKE) comparison against=stage2 - -bootstrap3: force - $(MAKE) CC="$(CC)" CFLAGS="-O -Bstage2/ $(CFLAGS)" libdir=$(libdir) ALLOCA= $(ALL) - $(MAKE) comparison against=stage2 - -# Copy the object files from a particular stage into a subdirectory. -stage1: force - -mkdir stage1 - -mv $(STAGESTUFF) stage1 - if [ ! -f stage1/as ] ; then (cd stage1 ; ln -s as.new as) ; fi - -stage2: force - -mkdir stage2 - -mv $(STAGESTUFF) stage2 - if [ ! -f stage2/as ] ; then (cd stage2 ; ln -s as.new as) ; fi - -stage3: force - -mkdir stage3 - -mv $(STAGESTUFF) stage3 - if [ ! -f stage3/as ] ; then (cd stage3 ; ln -s as.new as) ; fi - -against=stage2 - -comparison: force - for i in $(STAGESTUFF) ; do cmp $$i $(against)/$$i ; done - -de-stage1: force - - (cd stage1 ; rm as ; mv -f * ..) - - rmdir stage1 - -de-stage2: force - - (cd stage2 ; rm as ; mv -f * ..) - - rmdir stage2 - -de-stage3: force - - (cd stage3 ; rm as ; mv -f * ..) - - rmdir stage3 - -# Copy just the executable files from a particular stage into a subdirectory, -# and delete the object files. Use this if you're just verifying a version -# that is pretty sure to work, and you are short of disk space. -risky-stage1: force - -mkdir stage1 - -mv cc1 cpp cccp gcc stage1 - -rm -f stage1/gnulib - -cp gnulib stage1 && $(RANLIB) stage1/gnulib - -make clean - -risky-stage2: force - -mkdir stage2 - -mv cc1 cpp cccp gcc stage2 - -rm -f stage2/gnulib - -cp gnulib stage2 && $(RANLIB) stage2/gnulib - -make clean - -risky-stage3: force - -mkdir stage3 - -mv cc1 cpp cccp gcc stage3 - -rm -f stage3/gnulib - -cp gnulib stage3 && $(RANLIB) stage3/gnulib - -make clean - -risky-stage4: force - -mkdir stage4 - -mv cc1 cpp cccp gcc stage4 - -rm -f stage4/gnulib - -cp gnulib stage4 && $(RANLIB) stage4/gnulib - -make clean - -#In GNU Make, ignore whether `stage*' exists. -.PHONY: stage1 stage2 stage3 stage4 clean realclean TAGS bootstrap -.PHONY: risky-stage1 risky-stage2 risky-stage3 risky-stage4 - -force: - -Makefile: $(srcdir)/Makefile.in $(host_makefile_frag) $(target_makefile_frag) - $(SHELL) ./config.status - diff --git a/gas/Makefile.loic b/gas/Makefile.loic deleted file mode 100755 index 4de7da125c7..00000000000 --- a/gas/Makefile.loic +++ /dev/null @@ -1,203 +0,0 @@ -# Makefile for GAS. -# Copyright (C) 1989, Free Software Foundation -# -# This file is part of GAS, the GNU Assembler. -# -# GAS 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 1, or (at your option) -# any later version. -# -# GAS 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 GAS; see the file COPYING. If not, write to -# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - -BINDIR = /usr/local/bin - -BINARY = gas - -# -# Add these flags to XCFLAGS below for specific use. -# -# If you machine does not have vfprintf, but does have _doprnt(), -# -DNO_VARARGS -# -# If the return-type of a signal-hander is void (instead of int), -# -DSIGTY -# -# To include the mc68851 mmu coprocessor instructions in the 68020 assembler, -# -Dm68851 -# -# If you want the 80386 assembler to correctly handle fsub/fsubr and fdiv/fdivr -# opcodes (unlike most 80386 assemblers) -# -DNON_BROKEN_WORDS -# -XCFLAGS = - -# Your favorite compiler -CC = gcc - -# Uncomment the following lines if you use USG - -INCLUDE_DIRS = -I. -COFF_OBJECTS = stack.o -CPPFLAGS = -DUSG -CFLAGS = -g $(CPPFLAGS) $(XCFLAGS) -LDFLAGS = -#LOADLIBES = -lPW - -# Uncomment the following lines if you use BSD -#INCLUDE_DIRS = -I. -#CPPFLAGS = -#CFLAGS = -g $(CPPFLAGS) $(XCFLAGS) -#LDFLAGS = -#LOADLIBES = - -CONFIG_FILES = \ - machine.c machine.h atof.c obj-format.c obj-format.h opcode.h - -OBJECTS = \ - as.o xrealloc.o xmalloc.o hash.o hex-value.o \ - atof-generic.o append.o messages.o expr.o app.o \ - frags.o input-file.o input-scrub.o output-file.o \ - subsegs.o symbols.o version.o flonum-const.o flonum-copy.o \ - flonum-mult.o strstr.o bignum-copy.o obstack.o write.o read.o \ - obj-format.o machine.o atof.o $(COFF_OBJECTS) - -SOURCES = $(OBJECTS:.o=.c) - -all : $(BINARY) - -install : all - cp $(BINARY) $(BINDIR) - -clean : - rm -f $(OBJECTS) - -clobber : clean - rm -f $(BINARY) $(CONFIG_FILES) dependencies TAGS m68k.h - -$(BINARY) : $(OBJECTS) - $(CC) -o $(BINARY) $(LDFLAGS) $(OBJECTS) $(LOADLIBES) - -TAGS : $(SOURCES) - etags $(SOURCES) *.h - -CXREF : $(SOURCES) - cxref -c $(INCLUDE_DIRS) $(SOURCES) - -stack.o: stack.c - $(CC) $(CFLAGS) -c stack.c - -atof.o: \ - flonum.h \ - bignum.h -obj-format.o: \ - as.h \ - md.h \ - aout.h \ - a.out.gnu.h \ - struc-symbol.h \ - write.h \ - append.h -read.o: \ - obj-format.h \ - a.out.gnu.h \ - as.h \ - read.h \ - md.h \ - hash.h \ - obstack.h \ - frags.h \ - flonum.h \ - bignum.h \ - struc-symbol.h \ - expr.h \ - symbols.h \ - sparc.h -write.o: \ - obj-format.h \ - a.out.gnu.h \ - as.h \ - md.h \ - subsegs.h \ - obstack.h \ - struc-symbol.h \ - write.h \ - symbols.h \ - append.h \ - sparc.h -obstack.o: \ - obstack.h -bignum-copy.o: \ - bignum.h -flonum-mult.o: \ - flonum.h \ - bignum.h -flonum-copy.o: \ - flonum.h \ - bignum.h -flonum-const.o: \ - flonum.h \ - bignum.h -symbols.o: \ - obj-format.h \ - a.out.gnu.h \ - as.h \ - hash.h \ - obstack.h \ - struc-symbol.h \ - symbols.h \ - frags.h -subsegs.o: \ - obj-format.h \ - a.out.gnu.h \ - as.h \ - subsegs.h \ - obstack.h \ - frags.h \ - struc-symbol.h \ - write.h -input-scrub.o: \ - as.h \ - read.h \ - input-file.h -input-file.o: \ - input-file.h -frags.o: \ - obj-format.h \ - a.out.gnu.h \ - as.h \ - subsegs.h \ - obstack.h \ - frags.h \ - struc-symbol.h -expr.o: \ - obj-format.h \ - a.out.gnu.h \ - as.h \ - flonum.h \ - bignum.h \ - read.h \ - struc-symbol.h \ - expr.h \ - obstack.h \ - symbols.h -messages.o: \ - as.h -atof-generic.o: \ - flonum.h \ - bignum.h -hash.o: \ - hash.h -as.o: \ - obj-format.h \ - a.out.gnu.h \ - as.h \ - struc-symbol.h \ - write.h diff --git a/gas/Makefile.old b/gas/Makefile.old deleted file mode 100644 index 9cbb532661e..00000000000 --- a/gas/Makefile.old +++ /dev/null @@ -1,434 +0,0 @@ -# Makefile for GAS. -# Copyright (C) 1989, Free Software Foundation -# -# This file is part of GAS, the GNU Assembler. -# -# GAS 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 1, or (at your option) -# any later version. -# -# GAS 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 GAS; see the file COPYING. If not, write to -# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - -# This makefile may be used to make the VAX, 68020, 80386, -# SPARC, AMD 29000, ns32k, or i860 assembler(s). -ALL = asm29k avax a68 a386 asparc a32k a860 a960 -MDSRC=vax.c m68k.c i386.c sparc.c am29k.c ns32k.c - -BINDIR = $(DESTDIR)/bin - -# If you are on a BSD system, un-comment the next two lines, and comment out -# the lines for SystemV and HPUX below -#G0 = -g -I. #-O -Wall -#LDFLAGS = $(CFLAGS) -# -# To compile gas on a System Five machine, comment out the two lines above -# and un-comment out the next three lines -# Comment out the -lPW on the LOADLIBES line if you are using GCC. -G0 = -g -I. -DUSG -LDFLAGS = $(CFLAGS) -LOADLIBES = # -lmalloc -lPW -# -# To compile gas for HPUX, link m-hpux.h to m68k.h , and un-comment the -# next two lines. (If you are using GCC, comment out the alloca.o part) -# (Get alloca from the emacs distribution, or use GCC.) -# HPUX 7.0 may have a bug in setvbuf. gas gives an error message like -# 1:"Unknown operator" -- Statement 'NO_APP' ignored -# if setvbuf is broken. Re-compile input-file.c (and only input-file.c -# with -DVMS and the problem should go away. -# -# G0 = -g -I. -DUSG -# LOADLIBES = alloca.o -# -# To compile gas for a Sequent Symmetry, comment out all the above lines, -# and un-comment the next two lines. -# G0 = -g -I. -DUSE_SYSTEM_HDR -DEXEC_VERSION=1 -# LOADLIBES = -lc /usr/att/lib/libc.a - -# Use these lines to build gas using hc. -#CC=hc29 -cmdlink.cmd -Dconst= -I../include/msdos -#CC=gcc29k -#LOADLIBES= ../binutils/alloca.o - -# If you just want to compile the vax assembler, type 'make avax' - -# If you just want to compile the i386 assembler, type 'make a386' - -# If you just want to compile the ns32k assembler, type 'make a32k' - -# If you just want to compile the sparc assembler, type 'make asparc' - -# If you just want to compile the AMD 29000 assembler, type 'make asm29k' - -# If you just want to compile the a860 assembler, type 'make a860' - -# If you just want to compile the a960 assembler, type 'make a960' - -# If you just want to compile the mc68020 assembler, make sure m68k.h -# is correctly set up, and type type 'make a68' (Except on HPUX machines, -# where you will have to make the changes marked below before typing -# 'make a68' -# m68k.h should be a symbolic or hard-link to one of -# m-sun3.h , m-hpux.h or m-generic.h -# depending on which machine you want to compile the 68020 assembler for. -# -# If you want the 68k assembler to be completely compatable with the the -# SUN one, un-comment the -DLOCAL_LABELS_FB and -DLOCAL_LABELS_DOLLAR -# lines below. -# -# Gas prefers STDARG's, but if your machine doesn't have stdarg.h, you -# should define remove the # from the -DNO_STDARG line below. In this -# case gas will try to use VARARGS instead. (but keep reading). -# -# If your machine does not have vfprintf, but does have _doprnt(), -# remove the # from the -DNO_VARARGS line below. -# -# If the return-type of a signal-hander is void (instead of int), -# remove the # from the -DSIGTY line below. -# -# To include the mc68851 mmu coprocessor instructions in the 68020 assembler, -# remove the # from the -Dm68851 line below. -# -# If you want the 68020 assembler use a register prefix character, un-comment -# the REGISTER_PREFIX line, and (maybe) change the '%' to the appropriate -# character. -# -# If you want the assembler to treat .L* or ..* symbols as local, instead of -# the usual L* symbols, un-comment the DOT_LABEL_PREFIX line. -# -# If you want the 80386 assembler to correctly handle fsub/fsubr and fdiv/fdivr -# opcodes (unlike most 80386 assemblers), remove the # from -# the -DNON_BROKEN_WORDS line below. -# -# To compile 80386 Gas for the Sequent Symmetry, un-comment the -DEXEC_VERSION -# and the -DUSE_SYSTEM_HDR lines below. -# -# To compile gas for the HP 9000/300 un-comment the -DUSE_HP_HDR line below. -# -# For the ns32k, the options are 32532 or 32032 CPU and 32381 or 32081 FPU. -# To select the NS32532, remove the # from the -DNS32532 line below. -# To compile in tne NS32381 opcodes in addition to the NS32081 opcodes -# (the 32381 is a superset of the 32081), remove the # from the -DNS32381 -# line below. -# -# For the ns32k on a Sequent, uncomment the SEQUENT_COMPATABILITY line below. -# -# If you want character constants to *require* closing single quotes, -# eg 'c' rather than 'c then use the -DREQUIRE_CHAR_CLOSE_QUOTE lines -# below. The default is for the closing quote to be optional. -# -# To produce intel's b.out format, use the B_OUT line below. -# -# if you want to allow "\v" to mean a control-k, use the BACKSLASH_V -# line below. - -# [Why is there a distinction between "Ox" and "Gx"? It would seem easier -# to not have to figure out that your code isn't working because some -# define's are only seen by some modules and you tested it in a module -# where it never gets defined... gnu@cygnus.com] - -O1 = -DNO_STDARG -O2 = # -DNO_VARARGS -O3 = # -DNON_BROKEN_WORDS -O4 = # -Dm68851 -O5 = # -DEXEC_VERSION=1 -O6 = # -DSIGTY=void -O6 = # -DNS32532 -O7 = # -DNS32381 -O8 = # -DDOT_LABEL_PREFIX -O9 = # -DSEQUENT_COMPATABILITY - -G1 = # -DREGISTER_PREFIX=\'%\' -G2 = # -DUSE_SYSTEM_HDR -G3 = # -DUSE_HP_HDR -G4 = # -DLOCAL_LABELS_DOLLAR -G5 = # -DLOCAL_LABELS_FB -G6 = # -DDEBUG -G7 = # -DREQUIRE_CHAR_CLOSE_QUOTE -G8 = -DB_OUT -G9 = -DBACKSLASH_V - -OPTIONS = $(O1) $(O2) $(O3) $(O4) $(O5) $(O6) $(O7) $(O8) $(O9) - -CFLAGS = $(G0) $(G1) $(G2) $(G3) $(G4) $(G5) $(G6) $(G7) $(G8) $(G9) $(OPTIONS) - -# -# To make the 68020 assembler compile as the default, un-comment the next -# line, and comment out all the other lines that start with DEFAULT_GAS -#DEFAULT_GAS=a68 -# -# To make the VAX assembler compile as the default, un-comment the next -# line and commment out all the other lines that start with DEFAULT_GAS -#DEFAULT_GAS=avax -# -# To make the 80386 assembler compile as the default, un-comment the next -# line and commment out all the other lines that start with DEFAULT_GAS -#DEFAULT_GAS=a386 -# -# To make the ns32k assembler compile as the default, un-comment the next -# line and commment out all the other lines that start with DEFAULT_GAS -#DEFAULT_GAS=a32k -# -# To make the sparc assembler compile as the default, un-comment the next -# line and commment out all the other lines that start with DEFAULT_GAS -#DEFAULT_GAS=asparc -# -# -# To make the i860 assembler compile as the default, un-comment the next -# line and comment out all the other lines that start with DEFAULT_GAS -#DEFAULT_GAS=a860 -# -# To make the asm29k assembler compile as the default, un-comment the next -# line and commment out all the other lines that start with DEFAULT_GAS -#DEFAULT_GAS=asm29k -# -# To make the i960 assembler compile as the default, un-comment the next -# line and commment out all the other lines that start with DEFAULT_GAS -#DEFAULT_GAS=a960 - -# Global Sources ------------------------------------------------------------- - -a =\ -as.o xrealloc.o xmalloc.o hash.o hex-value.o \ -atof-generic.o messages.o expr.o app.o \ -frags.o input-file.o input-scrub.o output-file.o \ -subsegs.o symbols.o version.o \ -flonum-const.o flonum-copy.o flonum-mult.o strstr.o bignum-copy.o \ -obstack.o cond.o -#gdb.o gdb-file.o gdb-symbols.o gdb-blocks.o gdb-lines.o - -a: $(DEFAULT_GAS) - @rm -f a - @ln $(DEFAULT_GAS) a - -# i960 GAS ------------------------------------------------------------------ -t = i960.o i960-opcode.o atof-ieee.o ver960.o read-i960.o write-i960.o - -T = i960.c i960-opcode.c atof-ieee.c ver960.c - -i960.o: i960.c i960-opcode.h as.h frags.h struc-symbol.h -i960.o: flonum.h expr.h hash.h md.h write.h read.h symbols.h - $(CC) -c $(CFLAGS) -DI80960 i960.c - -write-i960.o: write.c - $(CC) -c $(CFLAGS) write.c - mv write.o write-i960.o - -read-i960.o: read.c - $(CC) -c $(CFLAGS) read.c - mv read.o read-i960.o - -a960_cheat: $a $t - $(CC) -o a960 $(LDFLAGS) $a $t $(LOADLIBES) - -a960: force - $(MAKE) 'CFLAGS=$(CFLAGS) -DI80960' a960_cheat - -force: - -# AM29K GAS ------------------------------------------------------------------ -u = am29k.o atof-ieee.o write.o read.o - -U = am29k.c am29k-opcode.h - -am29k.o: am29k.c a.out.gnu.h as.h expr.h flonum.h frags.h hash.h -am29k.o: am29k-opcode.h md.h obstack.h struc-symbol.h - $(CC) $(CFLAGS) -c am29k.c - -asm29k: $a $u - $(CC) -o asm29k $(LDFLAGS) $a $u $(LOADLIBES) - -# I860 GAS ------------------------------------------------------------------ -u = i860.o atof-ieee.o write.o read.o - -U = i860.c i860-opcode.h - -i860.o: i860.c i860-opcode.h as.h frags.h struc-symbol.h -i860.o: flonum.h expr.h hash.h md.h write.h read.h symbols.h - $(CC) -c $(CFLAGS) i860.c - -atof-ieee.o: flonum.h - -a860: $a $u - $(CC) -o a860 $(LDFLAGS) $a $u $(LOADLIBES) - -# SPARC GAS ------------------------------------------------------------------ -v = sparc.o atof-ieee.o write.o read.o - -V = sparc.c sparc-opcode.h - -atof-ieee.o: flonum.h -sparc.o: sparc.c reloc.h sparc-opcode.h as.h frags.h struc-symbol.h -sparc.o: flonum.h expr.h hash.h md.h write.h read.h symbols.h - $(CC) -c $(CFLAGS) -DSPARC sparc.c - -asparc: $a $v - $(CC) -o asparc $(LDFLAGS) $a $v $(LOADLIBES) - -# NS32K GAS ------------------------------------------------------------------ -w = ns32k.o atof-ieee.o write-ns32k.o read-ns32k.o - -W = ns32k.c ns32k-opcode.h - -atof-ieee.o: flonum.h -ns32k.o: as.h frags.h struc-symbol.h flonum.h expr.h md.h hash.h -ns32k.o: write.h symbols.h ns32k-opcode.h ns32k.c - $(CC) $(CFLAGS) $(OPTIONS) -c ns32k.c - -write-ns32k.o: write.c - rm -f write-ns32k.c - cp write.c write-ns32k.c - $(CC) -c -DNS32K $(CFLAGS) write-ns32k.c - rm -f write-ns32k.c - -read-ns32k.o: read.c - rm -f read-ns32k.c - cp read.c read-ns32k.c - $(CC) -c -DNS32K $(CFLAGS) read-ns32k.c - rm -f read-ns32k.c - -a32k: $a $w - $(CC) -o a32k $(LDFLAGS) $a $w $(LOADLIBES) - -# 80386 GAS ------------------------------------------------------------------ -x = i386.o atof-ieee.o write.o read.o - -X = i386.c i386.h i386-opcode.h - -i386.o: i386.c as.h read.h flonum.h frags.h struc-symbol.h expr.h -i386.o: symbols.h hash.h md.h i386.h i386-opcode.h - $(CC) $(CFLAGS) $(OPTIONS) -c i386.c - -atof-ieee.o: flonum.h - -a386: $a $x - $(CC) -o a386 $(LDFLAGS) $a $x $(LOADLIBES) - -# 68020 GAS ------------------------------------------------------------------ -y = m68k.o atof-ieee.o write.o read.o - -Y = m68k.c atof-ieee.c m68k-opcode.h m-hpux.h m-sun3.h m-generic.h - -atof-ieee.o: flonum.h - -m68k.o: m68k.c a.out.gnu.h as.h expr.h flonum.h frags.h hash.h -m68k.o: m68k-opcode.h m68k.h md.h obstack.h struc-symbol.h - $(CC) $(CFLAGS) $(OPTIONS) -c m68k.c - -a68: $a $y - $(CC) -o a68 $(LDFLAGS) $a $y $(LOADLIBES) - -# VAX GAS -------------------------------------------------------------------- -z = vax.o atof-vax.o write.o read.o - -Z = vax.c atof-vax.c vax-opcode.h vax-inst.h \ - make-gas.com objrecdef.h vms.c vms-dbg.c README-vms-dbg - -vax.o: vax.c a.out.gnu.h as.h expr.h flonum.h frags.h md.h obstack.h -vax.o: read.h struc-symbol.h symbols.h vax-inst.h vax-opcode.h -atof-vax.o: as.h flonum.h read.h - -avax: $a $z - $(CC) -o avax $(LDFLAGS) $a $z $(LOADLIBES) - -# global files --------------------------------------------------------------- - -hash.o: hash.c - $(CC) $(CFLAGS) -Derror=as_fatal -c hash.c - -xmalloc.o: xmalloc.c - $(CC) $(CFLAGS) -Derror=as_fatal -c xmalloc.c - -xrealloc.o: xrealloc.c - $(CC) $(CFLAGS) -Derror=as_fatal -c xrealloc.c - -A =\ -as.c xrealloc.c xmalloc.c hash.c hex-value.c \ -atof-generic.c messages.c expr.c bignum-copy.c \ -frags.c input-file.c input-scrub.c output-file.c read.c \ -subsegs.c symbols.c write.c strstr.c \ -flonum-const.c flonum-copy.c flonum-mult.c app.c version.c \ -obstack.c cond.c \ -#gdb.c gdb-file.c gdb-symbols.c gdb-blocks.c \ -#gdb-lines.c - -H = \ -a.out.gnu.h as.h bignum.h expr.h flonum.h \ -frags.h hash.h input-file.h md.h \ -obstack.h read.h reloc.h struc-symbol.h subsegs.h \ -symbols.h write.h - -dist: COPYING README ChangeLog $A $H $U $V $W $X $Y $Z Makefile - echo gas-`sed -n -e '/ version /s/[^0-9.]*\([0-9.]*\).*/\1/p' < version.c` > .fname - mkdir `cat .fname` - - ln COPYING README ChangeLog $A $H $U $V $W $X $Y $Z Makefile `cat .fname` - tar cvhZf `cat .fname`.tar.Z `cat .fname` - -rm -rf .fname `cat .fname` - -clean: - rm -f a avax a68 a386 a32k asparc asm29k a860 a960 $a $u $v $w $x $y $z a core gmon.out bugs a.out - -all: $(ALL) - -install: install_tools -install_tools: a - cp a $(BINDIR)/as - -# For things like: emacs `make mdsrc` -mdsrc: - @ls $(MDSRC) - -LINT = /usr/5bin/lint -LINTFLAGS = - -lint: - $(LINT) $(LINTFLAGS) $(CFLAGS) $A - -# General .o-->.h dependencies - -app.o: as.h -as.o: a.out.gnu.h as.h read.h struc-symbol.h write.h -atof-generic.o: flonum.h -bignum-copy.o: bignum.h -expr.o: a.out.gnu.h as.h expr.h flonum.h obstack.h read.h struc-symbol.h -expr.o: symbols.h -flonum-const.o: flonum.h -flonum-copy.o: flonum.h -flonum-mult.o: flonum.h -flonum-normal.o:flonum.h -flonum-print.o: flonum.h -frags.o: a.out.gnu.h as.h frags.h obstack.h struc-symbol.h subsegs.h -#gdb.o: as.h -#gdb-blocks.o: as.h -#gdb-lines.o: as.h frags.h obstack.h -#gdb-symbols.o: a.out.gnu.h as.h struc-symbol.h -hash.o: hash.h -input-file.o: input-file.h -input-scrub.o: as.h input-file.h read.h -messages.o: as.h -obstack.o: obstack.h -read.o: a.out.gnu.h as.h expr.h flonum.h frags.h hash.h md.h obstack.h -read.o: read.h struc-symbol.h symbols.h reloc.h -subsegs.o: a.out.gnu.h as.h frags.h obstack.h struc-symbol.h subsegs.h write.h -symbols.o: a.out.gnu.h as.h frags.h hash.h obstack.h struc-symbol.h symbols.h -write.o: a.out.gnu.h as.h md.h obstack.h struc-symbol.h subsegs.h -write.o: symbols.h write.h reloc.h - -flonum.h: bignum.h - -etags tags: TAGS - -TAGS: force - etags Makefile* README* config.gas *.[hc] - -force: - -# End of Makefile diff --git a/gas/NOTES b/gas/NOTES deleted file mode 100644 index 0669aa7ffe9..00000000000 --- a/gas/NOTES +++ /dev/null @@ -1,19 +0,0 @@ -to do: - -fucked up on a.out.gnu.h, etc. -fucked up on foo-opcode.h. -remove the ifdef's from fx_callj tests? -what are callj tests? -search for (), build prototypes. -space tighten sparc alignment. -convert md_ri_to_chars to not pass structs. -convert md_ri_to_chars to emit fixP's. -fix number_to_chars, & family to have no side effects. -prototype. -md_ => tp_ -use CROSS_ASSEMBLE -multiple segments. -share b.out with a.out. - - -stack: diff --git a/gas/NOTES.config b/gas/NOTES.config deleted file mode 100644 index e12797d51c1..00000000000 --- a/gas/NOTES.config +++ /dev/null @@ -1,52 +0,0 @@ - - The GAS Configuration Plan - -Theory: - -The goal of the new configuration scheme is to bury all object format, -target processor, and host machine dependancies in object, target, and -host specific files. That is, to move all #ifdef's out of the gas -common code. - -Here's how it works. There is a .h and a .c file for each object file -format, a .h and a .c file for each target processor, and a .h for -each host. config.gas creates {sym}links in the current directory to -the appropriate files in the config directory. config.gas also serves -as a list of triplets {host, target, object-format} that have been -tested at one time or another. I also recommend that config.gas be -used to document triplet specific notes as to purpose of the triplet, -etc. - -Implementation: - -host.h is a {sym}link to .../config/xm-yourhost.h. It is intended to -be used to hide host compiler, system header file, and system library -differences between host machines. If your host needs actual c source -files, then either: these are generally useful functions, in which -case you should probably build a local library outside of the gas -source tree, or someone, perhaps me, is confused about what is needed -by different hosts. - -obj-format.h is a {sym}link to .../config/obj-something.h. It is intended - -All gas .c files include as.h. - -as.h #define's "gas", includes host.h, defines a number of gas -specific structures and types, and then includes tp.h, obj.h, and -target-environment.h. - -target-environment.h defines a target environment specific -preprocessor flag, eg, TE_SUN, and then includes obj-format.h. - -obj-format.h defines an object format specific preprocessor flag, eg, -OBJ_AOUT, OBJ_BOUT, OBJ_COFF, includes "target-processor.h", and then -defines the object specific macros, functions, types, and structures. - -target-processor.h - -target-processor. - -Porting: - -There appear to be four major types of ports; new hosts, new target -processors, new object file formats, and new target environments. diff --git a/gas/README b/gas/README deleted file mode 100644 index 204263930f9..00000000000 --- a/gas/README +++ /dev/null @@ -1,139 +0,0 @@ -This is the beta-test version of the GNU assembler. (Probably -around Version 1.38, but check version.c which gets updated more -often than this readme.) - -These files are currently set up to allow you to compile all of the -versions of the assembler on the same machine. 'make all' compiles -all of them. The resulting executable names are: - - 68020 a68 - Vax avax - NS 32xxx a32k - Intel 80386 a386 - SPARC asparc - AMD 29000 asm29k - -The Makefile contains instructions on how to make one of the -assemblers compile as the default. - -Before you can compile the 68020 version of the assembler, you must -make m68k.h be a link to m-sun3.h , m-hpux.h or m-generic.h . If -you are on a SUN-3 (or other machine that uses a magic number of -(2 << 16) | OMAGIC type 'ln -s m-sun3.h m68k.h' else if you are on a -machine running HP-UX, type 'ln m-hpux.h m689k.h' else type -'ln -s m-generic.h m68k.h' If your machine does not support symbolic -links, omit the '-s'. - -See the instructions in the Makefile for compiling gas for the Sequent -Symmetry (dynix 3.0.12 + others?) or for the HP 9000/300 - -If your machine does not have both varargs.h and vfprintf(), but does have -_doprnt() add -DNO_VARARGS to the CFLAGS line in the makefile. If your -machine has neither vfprintf() or _doprnt(), you will have to change -messages.c in order to get readable error messages from the assembler. - -The assembler has been modified to support a feature that is -potentially useful when assembling compiler output, but which may -confuse assembly language programmers. If assembler encounters a -.word pseudo-op of the form symbol1-symbol2 (the difference of two -symbols), and the difference of those two symbols will not fit in 16 -bits, the assembler will create a branch around a long jump to -symbol1, and insert this into the output directly before the next -label: The .word will (instead of containing garbage, or giving an -error message) contain (the address of the long jump)-symbol2. This -allows the assembler to assemble jump tables that jump to locations -very far away into code that works properly. If the next label is -more than 32K away from the .word, you lose (silently); RMS claims -this will never happen. If the -k option is given, you will get a -warning message when this happens. - - - REPORTING BUGS IN GAS - -Bugs in gas should be reported to bug-gnu-utils@prep.ai.mit.edu If you can't -get through to prep, try hack@gnu.ai.mit.edu or hack@media-lab.media.mit.edu - -If you report a bug in GAS, please remember to include: - -A description of exactly what went wrong. - -The type of machine GAS was running on (VAX, 68020, etc), - -The Operating System GAS was running under. - -The options given to GAS. - -The actual input file that caused the problem. - -It is silly to report a bug in GAS without including an input file for -GAS. Don't ask us to generate the file just because you made it from -files you think we have access to. - -1. You might be mistaken. -2. It might take us a lot of time to install things to regenerate that file. -3. We might get a different file from the one you got, and might not see any -bug. - -To save us these delays and uncertainties, always send the input file -for the program that failed. - -If the input file is very large, and you are on the internet, you may -want to make it avaliable for anonymous FTP instead of mailing it. If you -do, include instructions for FTP'ing it in your bug report. - ------------------------------- README.APOLLO --------------------------------- - -The changes required to get the GNU C compiler running on -Apollo 68K platforms are available via anonymous ftp from -labrea.stanford.edu (36.8.0.47) in the form of a compressed -tar file named "/pub/gnu/apollo-gcc-1.37.tar.Z". -The size of the file is 84145 bytes. - -To build GCC for the Apollo you'll need the virgin FSF -distributions of bison-1.03, gas-1.34, and gcc-1.37. They -are also on labrea.stanford.edu as well as prep.ai.mit.edu. -My changes are to enable gas to produce Apollo COFF object -files and allow gcc to parse some of the syntax extensions -which appear in Apollo C header files. Note that the -COFF encapsulation technique cannot be used on the Apollo. - -The tar file should be unpacked in the directory containing -the gas-1.34 and gcc-1.37 directories; a few files will be overlaid, -and an APOLLO-GCC-README file will appear in the top directory. -This file contains detailed instructions on how to proceed. - -These changes will only work for SR10.1 or later systems, using -the 6.6 or later version of the Apollo C compiler. - -If you do not have ftp access, I can mail you the changes in the -form of diffs; they are approximately 40K in length. If you request -them, be sure to give me a voice phone number so I can contact you -in case I can't send you mail; I've had several requests in the -past from people I can't contact. - -By the way, I'm working on getting the GNU C++ compiler running; -there are a couple problems to solve. I hope to be able to announce -the Apollo version shortly after the 1.37 version is released. - -John Vasta Hewlett-Packard Apollo Systems Division -vasta@apollo.hp.com M.S. CHA-01-LT -(508) 256-6600 x6362 300 Apollo Drive, Chelmsford, MA 01824 -UUCP: {decwrl!decvax, mit-eddie, attunix}!apollo!vasta - ------------------------------------- - -You might refer others who are interested in a similar thing. - -Kevin Buchs buchs@mayo.edu - - ------------------------------- README.COFF ----------------------------------- - -If you have a COFF system, you may wish to aquire - - UUCP: osu-cis!~/gnu/coff/gnu-coff.tar.Z - or - FTP: tut.cis.ohio-state.edu:/pub/gnu/coff/gnu-coff.tar.Z - -These contain patches for gas that will make it produce COFF output. -I have never seen these patches, so I don't know how well they work. diff --git a/gas/README-vms-dbg b/gas/README-vms-dbg deleted file mode 100644 index 61ab6dd6dbf..00000000000 --- a/gas/README-vms-dbg +++ /dev/null @@ -1,127 +0,0 @@ - 1) You should be aware that GNU-C, as with any other decent compiler, -will do things when optimization is turned on that you may not expect. -Sometimes intermediate results are not written to variables, if they are only -used in one place, and sometimes variables that are not used at all will not be -written to the symbol table. Also, parameters to inline functions are often -inaccessible. You can see the assembly code equivalent by using KP7 in the -debugger, and from this you can tell if in fact a variable should have the -value that you expect. You can find out if a variable lives withing a register -by doing a 'show symbol/addr'. - - 2) Overly complex data types, such as: - -int (*(*(*(*(*(* sarr6)[1])[1])[2])[3])[4])[5]; - -will not be debugged properly, since the debugging record overflows an internal -debugger buffer. gcc-as will convert these to *void as far as the debugger -symbol table is concerned, which will avoid any problems, and the assembler -will give you a message informing you that this has happened. - - 3) You must, of course, compile and link with /debug. If you link -without debug, you still get traceback table in the executable, but there is no -symbol table for variables. - - 4) Included in the patches to VMS.C are fixes to two bugs that are -unrelated to the changes that I have made. One of these made it impossible to -debug small programs sometimes, and the other caused the debugger to become -confused about which routine it was in, and give this incorrect info in -tracebacks. - - 5) If you are using the GNU-C++ compiler, you should modify the -compiler driver file GNU_CC:[000000]GCC.COM (or GXX.COM). If you have a -seperate GXX.COM, then you need to change one line in GXX.COM to: -$ if f$locate("D",p2) .ne. P2_Length then Debug = " ""-G0""" - Notice zero---> ^ -If you are using a GCC.COM that does both C and C++, add the following lines to -GCC.COM: - -$! -$! Use old style debugging records for VMS -$! -$ if (Debug.nes."" ).and. Plus then Debug = " ""-G0""" - -after the variables Plus and Debug are set. The reason for this, is that C++ -compiler by default generates debugging records that are more complex, -with many new syntactical elements that allow for the new features of the -language. The -G0 switch tells the C++ compiler to use the old style debugging -records. Until the debugger understands C++ there is not any point to try and -use the expanded syntax. - - 6) When you have nested scopes, i.e.: -main(){ - int i; - {int i; - {int i; -};};} -and you say "EXAM i" the debugger needs to figure out which variable you -actually want to reference. I have arranged things to define a block to the -debugger when you use brackets to enter a new scope, so in the example above, -the variables would be described as: -TEST\main\i -TEST\main\$0\i -TEST\main\$0\$0\i -At each level, the block name is a number with a dollar sign prefix, the -numbers start with 0 and count upward. When you say EXAM i, the debugger looks -at the current PC, and decides which block it is currently in. It works from -the innermost level outward until it finds a block that has the variable "i" -defined. You can always specify the scope explicitly. - - 7) With C++, there can be a lot of inline functions, and it would be -rather restrictive to force the user to debug the program by converting all of -the inline functions to normal functions. What I have done is to essentially -"add" (with the debugger) source lines from the include files that contain the -inline functions. Thus when you step into an inline function it appears as if -you have called the function, and you can examine variables and so forth. -There are several *very* important differences, however. First of all, since -there is no function call involved, you cannot step over the inline function -call - you always step into it. Secondly, since the same source lines are used -in many locations, there is a seperate copy of the source for *each* usage. -Without this, breakpoints do not work, since we must have a 1-to-1 mapping -between source lines and PC. - Since you cannot step over inline function calls, it can be a real pain -if you are not really interested in what is going on for that function call. -What I have done is to use the "-D" switch for the assembler to toggle the -following behavior. With the "-D" switch, all inline functions are included in -the object file, and you can debug everything. Without the "-D" switch -(default case with VMS implementation), inline functions are included *only* if -they did not come from system header files (i.e. from GNU_CC_INCLUDE: or -GNU_GXX_INCLUDE:). Thus, without the switch the user only debugs his/her own -inline functions, and not the system ones. (This is especially useful if you do -a lot of stream I/O in C++). This probably will not provide enough granularity -for many users, but for now this is still somewhat experimental, and I would -like to reflect upon it and get some feedback before I go any further. -Possible solutions include an interactive prompting, a logical name, or a new -command line option in gcc.c (which is then passed through somehow to the guts -of the assembler). - The inline functions from header files appear after the source code -for the source file. This has the advantage that the source file itself is -numbered with the same line numbers that you get with an editor. In addition, -the entire header file is not included, since the assembler makes a list of -the min and max source lines that are used, and only includes those lines from -the first to the last actually used. (It is easy to change it to include the -whole file). - - 8) When you are debugging C++ objects, the object "this" is refered to -as "$this". Actually, the compiler writes it as ".this", but the period is -not good for the debugger, so I have a routine to convert it to a $. (It -actually converts all periods to $, but only for variables, since this was -intended to allow us to access "this". - - 9) If you use the asm("...") keyword for global symbols, you will not -be able to see that symbol with the debugger. The reason is that there are two -records for the symbol stored in the data structures of the assembler. One -contains the info such as psect number and offset, and the other one contains -the information having to do with the data type of the variable. In order to -debug as symbol, you need to be able to coorelate these records, and the only -way to do this is by name. The record with the storage attributes will take -the name used in the asm directive, and the record that specifies the data type -has the actual variable name, and thus when you use the asm directive to change -a variable name, the symbol becomes invisible. - - 10) Older versions of the compiler ( GNU-C 1.37.92 and earlier) place -global constants in the text psect. This is unfortunate, since to the linker -this appears to be an entry point. I sent a patch to the compiler to RMS, -which will generate a .const section for these variables, and patched the -assembler to put these variables into a psect just like that for normal -variables, except that they are marked NOWRT. static constants are still -placed in the text psect, since there is no need for any external access. diff --git a/gas/README.coff b/gas/README.coff deleted file mode 100644 index 46c61cda909..00000000000 --- a/gas/README.coff +++ /dev/null @@ -1,79 +0,0 @@ -The coff patches intend to do the following : - - . Generate coff files very compatible with vanilla linker. - . Understands coff debug directives. - -Here are the guidelines of the work I have done : - - . Encapsulate format dependent code in macros where it is possible. - . Where not possible differenciate with #ifdef - . try not to change the calling conventions of the existing functions. - I made one exception : symbol_new. I would be pleased to hear about - a better solution. (symbols.c) - . Extend the use of N_TYPE_seg seg_N_TYPE tables so that segments can - be manipulated without using their format dependent name. (subsegs.c) - . Write a function to parse the .def debug directives - . Write two small peaces of code to handle the .ln directive. - . In write.c try to move all the cross compilation specifics (md_..) to - format dependent files. - . Encapsulate the data structures using generic types, macros calls. - . Added too much code to resolve the complexity of the symbol table - generated. Most of the code deals with debug stuff. - . Create another makefile, shorter, cleaner. - . Create a config.gas shell script to mimic the gcc,gdb... configuration - mechanism. This reduce the complexity of the makefile. - . Isolate the format dependent code in two files - coff.c coff.h - aout.c aout.h - elf.c elf.h [ Not yet ;-] - . added a little stack management routine for coff in file stack.c - . isolate os specific flags in m- files - -If further development is planed on it is should solve the following problems : - - . Encapsulate DESC & OTHER tests in a macro call. I'm not aware - of their exact semantics. - . Clean up the seg_N_TYPE N_TYPE_seg naming scheme - . Try to remove as much reference to segment dependent names as possible - . Find a cleaner solution for symbol_new. - . Report the modifications on vax, ns32k, sparc machine dependent files. - To acheive this goal, search for \> 16) & 0xff)) -#define N_FLAGS(exec) (((exec).a_info >> 24) & 0xff) -#define N_SET_INFO(exec, magic, type, flags) \ - ((exec).a_info = ((magic) & 0xffff) \ - | (((int)(type) & 0xff) << 16) \ - | (((flags) & 0xff) << 24)) -#define N_SET_MAGIC(exec, magic) \ - ((exec).a_info = (((exec).a_info & 0xffff0000) | ((magic) & 0xffff))) - -#define N_SET_MACHTYPE(exec, machtype) \ - ((exec).a_info = \ - ((exec).a_info&0xff00ffff) | ((((int)(machtype))&0xff) << 16)) - -#define N_SET_FLAGS(exec, flags) \ - ((exec).a_info = \ - ((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24)) - -/* Code indicating object file or impure executable. */ -#define OMAGIC 0407 -/* Code indicating pure executable. */ -#define NMAGIC 0410 -/* Code indicating demand-paged executable. */ -#define ZMAGIC 0413 - -/* Virtual Address of text segment from the a.out file. For OMAGIC, - (almost always "unlinked .o's" these days), should be zero. - For linked files, should reflect reality if we know it. */ - -#ifndef N_TXTADDR -#define N_TXTADDR(x) (N_MAGIC(x)==OMAGIC? 0 : TEXT_START_ADDR) -#endif - -#ifndef N_BADMAG -#define N_BADMAG(x) (N_MAGIC(x) != OMAGIC \ - && N_MAGIC(x) != NMAGIC \ - && N_MAGIC(x) != ZMAGIC) -#endif - -/* By default, segment size is constant. But on some machines, it can - be a function of the a.out header (e.g. machine type). */ -#ifndef N_SEGSIZE -#define N_SEGSIZE(x) SEGMENT_SIZE -#endif - -/* This complexity is for encapsulated COFF support */ -#ifndef _N_HDROFF -#define _N_HDROFF(x) (N_SEGSIZE(x) - sizeof (struct exec)) -#endif - -#ifndef N_TXTOFF -#define N_TXTOFF(x) (N_MAGIC(x) == ZMAGIC ? \ - _N_HDROFF((x)) + sizeof (struct exec) : \ - sizeof (struct exec)) -#endif - - -#ifndef N_DATOFF -#define N_DATOFF(x) ( N_TXTOFF(x) + (x).a_text ) -#endif - -#ifndef N_TRELOFF -#define N_TRELOFF(x) ( N_DATOFF(x) + (x).a_data ) -#endif - -#ifndef N_DRELOFF -#define N_DRELOFF(x) ( N_TRELOFF(x) + (x).a_trsize ) -#endif - -#ifndef N_SYMOFF -#define N_SYMOFF(x) ( N_DRELOFF(x) + (x).a_drsize ) -#endif - -#ifndef N_STROFF -#define N_STROFF(x) ( N_SYMOFF(x) + (x).a_syms ) -#endif - -/* Address of text segment in memory after it is loaded. */ -#ifndef N_TXTADDR -#define N_TXTADDR(x) 0 -#endif - -#ifndef N_DATADDR -#define N_DATADDR(x) \ - (N_MAGIC(x)==OMAGIC? (N_TXTADDR(x)+(x).a_text) \ - : (N_SEGSIZE(x) + ((N_TXTADDR(x)+(x).a_text-1) & ~(N_SEGSIZE(x)-1)))) -#endif - -/* Address of bss segment in memory after it is loaded. */ -#define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data) - -struct nlist { - union { - char *n_name; - struct nlist *n_next; - long n_strx; - } n_un; - unsigned char n_type; - char n_other; - short n_desc; - unsigned long n_value; -}; - -#define N_UNDF 0 -#define N_ABS 2 -#define N_TEXT 4 -#define N_DATA 6 -#define N_BSS 8 -#define N_COMM 0x12 /* common (visible in shared lib commons) */ -#define N_FN 0x1F /* File name of a .o file */ - -/* Note: N_EXT can only usefully be OR-ed with N_UNDF, N_ABS, N_TEXT, - N_DATA, or N_BSS. When the low-order bit of other types is set, - (e.g. N_WARNING versus N_FN), they are two different types. */ -#define N_EXT 1 -#define N_TYPE 036 -#define N_STAB 0340 - -/* The following type indicates the definition of a symbol as being - an indirect reference to another symbol. The other symbol - appears as an undefined reference, immediately following this symbol. - - Indirection is asymmetrical. The other symbol's value will be used - to satisfy requests for the indirect symbol, but not vice versa. - If the other symbol does not have a definition, libraries will - be searched to find a definition. */ - -#define N_INDR 0xa - -/* The following symbols refer to set elements. - All the N_SET[ATDB] symbols with the same name form one set. - Space is allocated for the set in the text section, and each set - element's value is stored into one word of the space. - The first word of the space is the length of the set (number of elements). - - The address of the set is made into an N_SETV symbol - whose name is the same as the name of the set. - This symbol acts like a N_DATA global symbol - in that it can satisfy undefined external references. */ - -/* These appear as input to LD, in a .o file. */ -#define N_SETA 0x14 /* Absolute set element symbol */ -#define N_SETT 0x16 /* Text set element symbol */ -#define N_SETD 0x18 /* Data set element symbol */ -#define N_SETB 0x1A /* Bss set element symbol */ - -/* This is output from LD. */ -#define N_SETV 0x1C /* Pointer to set vector in data area. */ - -/* Warning symbol. The text gives a warning message, the next symbol - in the table will be undefined. When the symbol is referenced, the - message is printed. */ - -#define N_WARNING 0x1e - -/* This structure describes a single relocation to be performed. - The text-relocation section of the file is a vector of these structures, - all of which apply to the text section. - Likewise, the data-relocation section applies to the data section. */ - -/* The following enum and struct were borrowed from SunOS's - /usr/include/sun4/a.out.h and extended to handle - other machines. It is currently used on SPARC and AMD 29000. - - reloc_ext_bytes is how it looks on disk. reloc_info_extended is - how we might process it on a native host. */ - -struct reloc_ext_bytes { - unsigned char r_address[4]; - unsigned char r_index[3]; - unsigned char r_bits[1]; - unsigned char r_addend[4]; -}; - -#define RELOC_EXT_BITS_EXTERN_BIG 0x80 -#define RELOC_EXT_BITS_EXTERN_LITTLE 0x01 - -#define RELOC_EXT_BITS_TYPE_BIG 0x1F -#define RELOC_EXT_BITS_TYPE_SH_BIG 0 -#define RELOC_EXT_BITS_TYPE_LITTLE 0xF8 -#define RELOC_EXT_BITS_TYPE_SH_LITTLE 3 - -#define RELOC_EXT_SIZE 12 /* Bytes per relocation entry */ - -struct reloc_info_extended -{ - unsigned long r_address; - unsigned int r_index:24; -# define r_symbolnum r_index - unsigned r_extern:1; - unsigned :2; -/* RS/6000 compiler does not support enum bitfield - enum reloc_type r_type:5; */ - enum reloc_type r_type; - long int r_addend; -}; - -/* The standard, old-fashioned, Berkeley compatible relocation struct */ - -struct reloc_std_bytes { - unsigned char r_address[4]; - unsigned char r_index[3]; - unsigned char r_bits[1]; -}; - -#define RELOC_STD_BITS_PCREL_BIG 0x80 -#define RELOC_STD_BITS_PCREL_LITTLE 0x01 - -#define RELOC_STD_BITS_LENGTH_BIG 0x60 -#define RELOC_STD_BITS_LENGTH_SH_BIG 5 /* To shift to units place */ -#define RELOC_STD_BITS_LENGTH_LITTLE 0x06 -#define RELOC_STD_BITS_LENGTH_SH_LITTLE 1 - -#define RELOC_STD_BITS_EXTERN_BIG 0x10 -#define RELOC_STD_BITS_EXTERN_LITTLE 0x08 - -#define RELOC_STD_BITS_BASEREL_BIG 0x08 -#define RELOC_STD_BITS_BASEREL_LITTLE 0x08 - -#define RELOC_STD_BITS_JMPTABLE_BIG 0x04 -#define RELOC_STD_BITS_JMPTABLE_LITTLE 0x04 - -#define RELOC_STD_BITS_RELATIVE_BIG 0x02 -#define RELOC_STD_BITS_RELATIVE_LITTLE 0x02 - -#define RELOC_STD_SIZE 8 /* Bytes per relocation entry */ - -struct relocation_info -{ - /* Address (within segment) to be relocated. */ - int r_address; - /* The meaning of r_symbolnum depends on r_extern. */ - unsigned int r_symbolnum:24; - /* Nonzero means value is a pc-relative offset - and it should be relocated for changes in its own address - as well as for changes in the symbol or section specified. */ - unsigned int r_pcrel:1; - /* Length (as exponent of 2) of the field to be relocated. - Thus, a value of 2 indicates 1<<2 bytes. */ - unsigned int r_length:2; - /* 1 => relocate with value of symbol. - r_symbolnum is the index of the symbol - in file's the symbol table. - 0 => relocate with the address of a segment. - r_symbolnum is N_TEXT, N_DATA, N_BSS or N_ABS - (the N_EXT bit may be set also, but signifies nothing). */ - unsigned int r_extern:1; - /* The next three bits are for SunOS shared libraries, and seem to - be undocumented. */ - unsigned int r_baserel:1; /* Linkage table relative */ - unsigned int r_jmptable:1; /* pc-relative to jump table */ - -#ifdef TC_NS32K -#define r_bsr r_baserel -#define r_disp r_jmptable -#endif /* TC_NS32K */ - - unsigned int r_relative:1; /* "relative relocation" */ - /* unused */ - unsigned int r_pad:1; /* Padding -- set to zero */ -}; - -#endif /* __A_OUT_GNU_H__ */ diff --git a/gas/app.c b/gas/app.c deleted file mode 100644 index c806cb70ee3..00000000000 --- a/gas/app.c +++ /dev/null @@ -1,508 +0,0 @@ -/* Copyright (C) 1987, 1990, 1991 Free Software Foundation, Inc. - -Modified by Allen Wirfs-Brock, Instantiations Inc 2/90 -*/ -/* This is the Assembler Pre-Processor - Copyright (C) 1987 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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 1, or (at your option) -any later version. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* App, the assembler pre-processor. This pre-processor strips out excess - spaces, turns single-quoted characters into a decimal constant, and turns - # into a .line \n.app-file pair. - This needs better error-handling. - */ - -/* static const char rcsid[] = "$Id$"; */ - -#include -#include "as.h" /* For BAD_CASE() only */ - -#if !defined(__STDC__) && !defined(const) -#define const /* Nothing */ -#endif - -static char lex [256]; -static char symbol_chars[] = - "$._ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; - -/* These will go in BSS if not defined elsewhere, producing empty strings. */ -extern const char comment_chars[]; -extern const char line_comment_chars[]; -extern const char line_separator_chars[]; - -#define LEX_IS_SYMBOL_COMPONENT 1 -#define LEX_IS_WHITESPACE 2 -#define LEX_IS_LINE_SEPARATOR 3 -#define LEX_IS_COMMENT_START 4 -#define LEX_IS_LINE_COMMENT_START 5 -#define LEX_IS_TWOCHAR_COMMENT_1ST 6 -#define LEX_IS_TWOCHAR_COMMENT_2ND 7 -#define LEX_IS_STRINGQUOTE 8 -#define LEX_IS_COLON 9 -#define LEX_IS_NEWLINE 10 -#define LEX_IS_ONECHAR_QUOTE 11 -#define IS_SYMBOL_COMPONENT(c) (lex [c] == LEX_IS_SYMBOL_COMPONENT) -#define IS_WHITESPACE(c) (lex [c] == LEX_IS_WHITESPACE) -#define IS_LINE_SEPARATOR(c) (lex [c] == LEX_IS_LINE_SEPARATOR) -#define IS_COMMENT(c) (lex [c] == LEX_IS_COMMENT_START) -#define IS_LINE_COMMENT(c) (lex [c] == LEX_IS_LINE_COMMENT_START) -#define IS_NEWLINE(c) (lex [c] == LEX_IS_NEWLINE) - -void do_scrub_begin() { - const char *p; - - lex [' '] = LEX_IS_WHITESPACE; - lex ['\t'] = LEX_IS_WHITESPACE; - lex ['\n'] = LEX_IS_NEWLINE; - lex [';'] = LEX_IS_LINE_SEPARATOR; - lex ['"'] = LEX_IS_STRINGQUOTE; - lex ['\''] = LEX_IS_ONECHAR_QUOTE; - lex [':'] = LEX_IS_COLON; - - /* Note that these override the previous defaults, e.g. if ';' - is a comment char, then it isn't a line separator. */ - for (p =symbol_chars;*p;++p) - lex[*p] = LEX_IS_SYMBOL_COMPONENT; - for (p=comment_chars;*p;p++) - lex[*p] = LEX_IS_COMMENT_START; - for (p=line_comment_chars;*p;p++) - lex[*p] = LEX_IS_LINE_COMMENT_START; - for (p=line_separator_chars;*p;p++) - lex[*p] = LEX_IS_LINE_SEPARATOR; - - /* Only allow slash-star comments if slash is not in use */ - if (lex['/'] == 0) { - lex ['/'] = LEX_IS_TWOCHAR_COMMENT_1ST; - lex ['*'] = LEX_IS_TWOCHAR_COMMENT_2ND; - } -} - -FILE *scrub_file; - -int scrub_from_file() { - return getc(scrub_file); -} - -void scrub_to_file(ch) -int ch; -{ - ungetc(ch,scrub_file); -} /* scrub_to_file() */ - -char *scrub_string; -char *scrub_last_string; - -int scrub_from_string() { - return scrub_string == scrub_last_string ? EOF : *scrub_string++; -} /* scrub_from_string() */ - -void scrub_to_string(ch) -int ch; -{ - *--scrub_string=ch; -} /* scrub_to_string() */ - -/* Saved state of the scrubber */ -static int state; -static int old_state; -static char *out_string; -static char out_buf[20]; -static int add_newlines = 0; - -/* Data structure for saving the state of app across #include's. Note that - app is called asynchronously to the parsing of the .include's, so our - state at the time .include is interpreted is completely unrelated. - That's why we have to save it all. */ - -struct app_save { - int state; - int old_state; - char *out_string; - char out_buf[sizeof (out_buf)]; - int add_newlines; - char *scrub_string; - char *scrub_last_string; - FILE *scrub_file; -}; - -char *app_push() { - register struct app_save *saved; - - saved = (struct app_save *) xmalloc(sizeof (*saved)); - saved->state = state; - saved->old_state = old_state; - saved->out_string = out_string; - bcopy(saved->out_buf, out_buf, sizeof(out_buf)); - saved->add_newlines = add_newlines; - saved->scrub_string = scrub_string; - saved->scrub_last_string = scrub_last_string; - saved->scrub_file = scrub_file; - - /* do_scrub_begin() is not useful, just wastes time. */ - return (char *)saved; -} - -void app_pop(arg) -char *arg; -{ - register struct app_save *saved = (struct app_save *)arg; - - /* There is no do_scrub_end (). */ - state = saved->state; - old_state = saved->old_state; - out_string = saved->out_string; - bcopy (out_buf, saved->out_buf, sizeof (out_buf)); - add_newlines = saved->add_newlines; - scrub_string = saved->scrub_string; - scrub_last_string = saved->scrub_last_string; - scrub_file = saved->scrub_file; - - free (arg); -} /* app_pop() */ - -int do_scrub_next_char(get,unget) -int (*get)(); -void (*unget)(); -{ - /*State 0: beginning of normal line - 1: After first whitespace on line (flush more white) - 2: After first non-white (opcode) on line (keep 1white) - 3: after second white on line (into operands) (flush white) - 4: after putting out a .line, put out digits - 5: parsing a string, then go to old-state - 6: putting out \ escape in a "d string. - 7: After putting out a .app-file, put out string. - 8: After putting out a .app-file string, flush until newline. - -1: output string in out_string and go to the state in old_state - -2: flush text until a '*' '/' is seen, then go to state old_state - */ - - register int ch, ch2; - - switch (state) { - case -1: - ch= *out_string++; - if(*out_string==0) { - state=old_state; - old_state=3; - } - return ch; - - case -2: - for(;;) { - do { - ch=(*get)(); - } while(ch!=EOF && ch!='\n' && ch!='*'); - if(ch=='\n' || ch==EOF) - return ch; - - /* At this point, ch must be a '*' */ - while ( (ch=(*get)()) == '*' ){ - ; - } - if(ch==EOF || ch=='/') - break; - (*unget)(ch); - } - state=old_state; - return ' '; - - case 4: - ch=(*get)(); - if(ch==EOF || (ch>='0' && ch<='9')) - return ch; - else { - while(ch!=EOF && IS_WHITESPACE(ch)) - ch=(*get)(); - if(ch=='"') { - (*unget)(ch); - out_string="\n.app-file "; - old_state=7; - state= -1; - return *out_string++; - } else { - while(ch!=EOF && ch!='\n') - ch=(*get)(); - return ch; - } - } - - case 5: - ch=(*get)(); - if(ch=='"') { - state=old_state; - return '"'; - } else if(ch=='\\') { - state=6; - return ch; - } else if(ch==EOF) { - as_warn("End of file in string: inserted '\"'"); - state=old_state; - (*unget)('\n'); - return '"'; - } else { - return ch; - } - - case 6: - state=5; - ch=(*get)(); - switch(ch) { - /* This is neet. Turn "string - more string" into "string\n more string" - */ - case '\n': - (*unget)('n'); - add_newlines++; - return '\\'; - - case '"': - case '\\': - case 'b': - case 'f': - case 'n': - case 'r': - case 't': -#ifdef BACKSLASH_V - case 'v': -#endif /* BACKSLASH_V */ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - break; - -#ifdef ONLY_STANDARD_ESCAPES - default: - as_warn("Unknown escape '\\%c' in string: Ignored",ch); - break; -#else /* ONLY_STANDARD_ESCAPES */ - default: - /* Accept \x as x for any x */ - break; -#endif /* ONLY_STANDARD_ESCAPES */ - - case EOF: - as_warn("End of file in string: '\"' inserted"); - return '"'; - } - return ch; - - case 7: - ch=(*get)(); - state=5; - old_state=8; - return ch; - - case 8: - do ch= (*get)(); - while(ch!='\n'); - state=0; - return ch; - } - - /* OK, we are somewhere in states 0 through 4 */ - -/* flushchar: */ - ch=(*get)(); - recycle: - if (ch == EOF) { - if (state != 0) - as_warn("End of file not at end of a line: Newline inserted."); - return ch; - } - - switch (lex[ch]) { - case LEX_IS_WHITESPACE: - do ch=(*get)(); - while(ch!=EOF && IS_WHITESPACE(ch)); - if(ch==EOF) - return ch; - if(IS_COMMENT(ch) || (state==0 && IS_LINE_COMMENT(ch)) || ch=='/' || IS_LINE_SEPARATOR(ch)) { - goto recycle; - } - switch (state) { - case 0: state++; goto recycle; /* Punted leading sp */ - case 1: BAD_CASE(state); /* We can't get here */ - case 2: state++; (*unget)(ch); return ' '; /* Sp after opco */ - case 3: goto recycle; /* Sp in operands */ - default: BAD_CASE(state); - } - break; - - case LEX_IS_TWOCHAR_COMMENT_1ST: - ch2=(*get)(); - if (ch2 != EOF && lex[ch2] == LEX_IS_TWOCHAR_COMMENT_2ND) { - for(;;) { - do { - ch2=(*get)(); - if(ch2 != EOF && IS_NEWLINE(ch2)) - add_newlines++; - } while(ch2!=EOF && - (lex[ch2] != LEX_IS_TWOCHAR_COMMENT_2ND)); - - while (ch2!=EOF && - (lex[ch2] == LEX_IS_TWOCHAR_COMMENT_2ND)){ - ch2=(*get)(); - } - - if(ch2==EOF - || lex[ch2] == LEX_IS_TWOCHAR_COMMENT_1ST) - break; - (*unget)(ch); - } - if(ch2==EOF) - as_warn("End of file in multiline comment"); - - ch = ' '; - goto recycle; - } else { - if(ch2!=EOF) - (*unget)(ch2); - return ch; - } - break; - - case LEX_IS_STRINGQUOTE: - old_state=state; - state=5; - return ch; - - case LEX_IS_ONECHAR_QUOTE: - ch=(*get)(); - if(ch==EOF) { - as_warn("End-of-file after a one-character quote; \000 inserted"); - ch=0; - } - sprintf(out_buf,"%d", (int)(unsigned char)ch); - - /* None of these 'x constants for us. We want 'x'. - */ - if ( (ch=(*get)()) != '\'' ) { -#ifdef REQUIRE_CHAR_CLOSE_QUOTE - as_warn("Missing close quote: (assumed)"); -#else - (*unget)(ch); -#endif - } - - old_state=state; - state= -1; - out_string=out_buf; - return *out_string++; - - case LEX_IS_COLON: - if(state!=3) - state=0; - return ch; - - case LEX_IS_NEWLINE: - /* Roll out a bunch of newlines from inside comments, etc. */ - if(add_newlines) { - --add_newlines; - (*unget)(ch); - } - /* fall thru into... */ - - case LEX_IS_LINE_SEPARATOR: - state=0; - return ch; - - case LEX_IS_LINE_COMMENT_START: - if (state != 0) /* Not at start of line, act normal */ - goto de_fault; - do ch=(*get)(); - while(ch!=EOF && IS_WHITESPACE(ch)); - if(ch==EOF) { - as_warn("EOF in comment: Newline inserted"); - return '\n'; - } - if(ch<'0' || ch>'9') { - /* Non-numerics: Eat whole comment line */ - while(ch!=EOF && !IS_NEWLINE(ch)) - ch=(*get)(); - if(ch==EOF) - as_warn("EOF in Comment: Newline inserted"); - state=0; - return '\n'; - } - /* Numerics begin comment. Perhaps CPP `# 123 "filename"' */ - (*unget)(ch); - old_state=4; - state= -1; - out_string=".line "; - return *out_string++; - - case LEX_IS_COMMENT_START: - do ch=(*get)(); - while(ch!=EOF && !IS_NEWLINE(ch)); - if(ch==EOF) - as_warn("EOF in comment: Newline inserted"); - state=0; - return '\n'; - - default: - de_fault: - /* Some relatively `normal' character. */ - if(state==0) { - state=2; /* Now seeing opcode */ - return ch; - } else if(state==1) { - state=2; /* Ditto */ - return ch; - } else { - return ch; /* Opcode or operands already */ - } - } - return -1; -} - -#ifdef TEST - -char comment_chars[] = "|"; -char line_comment_chars[] = "#"; - -main() -{ - int ch; - - app_begin(); - while((ch=do_scrub_next_char(stdin))!=EOF) - putc(ch,stdout); -} - -as_warn(str) -char *str; -{ - fputs(str,stderr); - putc('\n',stderr); -} -#endif - -/* - * Local Variables: - * comment-column: 0 - * fill-column: 131 - * End: - */ - -/* end of app.c */ diff --git a/gas/as.c b/gas/as.c deleted file mode 100644 index a885f0ddfd0..00000000000 --- a/gas/as.c +++ /dev/null @@ -1,361 +0,0 @@ -/* as.c - GAS main program. - Copyright (C) 1987, 1990, 1991 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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 1, or (at your option) -any later version. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* static const char rcsid[] = "$Id$"; */ - -/* - * Main program for AS; a 32-bit assembler of GNU. - * Understands command arguments. - * Has a few routines that don't fit in other modules because they - * are shared. - * - * - * bugs - * - * : initialisers - * Since no-one else says they will support them in future: I - * don't support them now. - * - */ - -#include -#include - -#ifdef _POSIX_SOURCE -#include /* For pid_t in signal.h */ -#endif -#include - -#define COMMON - -#include "as.h" - -#ifdef __STDC__ - - /* This prototype for got_sig() is ansi. If you want - anything else, then your compiler is lying to you when - it says that it is __STDC__. If you want to change it, - #ifdef protect it from those of us with real ansi - compilers. */ - -#define SIGTY void - -static void got_sig(int sig); -static char *stralloc(char *str); -static void perform_an_assembly_pass(int argc, char **argv); - -#else /* __STDC__ */ - -#ifndef SIGTY -#define SIGTY int -#endif - -static SIGTY got_sig(); -static char *stralloc(); /* Make a (safe) copy of a string. */ -static void perform_an_assembly_pass(); - -#endif /* __STDC__ */ - -#ifdef DONTDEF -static char * gdb_symbol_file_name; -long gdb_begin(); -#endif - -char *myname; /* argv[0] */ -extern char version_string[]; - -int main(argc,argv) -int argc; -char **argv; -{ - int work_argc; /* variable copy of argc */ - char **work_argv; /* variable copy of argv */ - char *arg; /* an arg to program */ - char a; /* an arg flag (after -) */ - static const int sig[] = { SIGHUP, SIGINT, SIGPIPE, SIGTERM, 0}; - - for(a=0;sig[a]!=0;a++) - if(signal(sig[a], SIG_IGN) != SIG_IGN) - signal(sig[a], got_sig); - - myname=argv[0]; - bzero (flagseen, sizeof(flagseen)); /* aint seen nothing yet */ -#ifndef OBJ_DEFAULT_OUTPUT_FILE_NAME -#define OBJ_DEFAULT_OUTPUT_FILE_NAME "a.out" -#endif /* OBJ_DEFAULT_OUTPUT_FILE_NAME */ - out_file_name = OBJ_DEFAULT_OUTPUT_FILE_NAME; - - symbol_begin(); /* symbols.c */ - subsegs_begin(); /* subsegs.c */ - read_begin(); /* read.c */ - md_begin(); /* MACHINE.c */ - input_scrub_begin(); /* input_scrub.c */ -#ifdef DONTDEF - gdb_symbol_file_name = 0; -#endif - /* - * Parse arguments, but we are only interested in flags. - * When we find a flag, we process it then make it's argv[] NULL. - * This helps any future argv[] scanners avoid what we processed. - * Since it is easy to do here we interpret the special arg "-" - * to mean "use stdin" and we set that argv[] pointing to "". - * After we have munged argv[], the only things left are source file - * name(s) and ""(s) denoting stdin. These file names are used - * (perhaps more than once) later. - */ - /* FIXME-SOMEDAY this should use getopt. */ - work_argc = argc-1; /* don't count argv[0] */ - work_argv = argv+1; /* skip argv[0] */ - for (;work_argc--;work_argv++) { - arg = * work_argv; /* work_argv points to this argument */ - - if (*arg!='-') /* Filename. We need it later. */ - continue; /* Keep scanning args looking for flags. */ - if (arg[1] == '-' && arg[2] == 0) { - /* "--" as an argument means read STDIN */ - /* on this scan, we don't want to think about filenames */ - * work_argv = ""; /* Code that means 'use stdin'. */ - continue; - } - /* This better be a switch. */ - arg ++; /*->letter. */ - - while ((a = * arg) != '\0') {/* scan all the 1-char flags */ - arg ++; /* arg->after letter. */ - a &= 0x7F; /* ascii only please */ - if (flagseen[a]) - as_tsktsk("%s: Flag option - %c has already been seen.", myname, a); - flagseen[a] = 1; - switch (a) { - case 'f': - break; /* -f means fast - no need for "app" preprocessor. */ - - case 'D': - /* DEBUG is implemented: it debugs different */ - /* things to other people's assemblers. */ - break; - -#ifdef DONTDEF - case 'G': /* GNU AS switch: include gdbsyms. */ - if (*arg) /* Rest of argument is file-name. */ - gdb_symbol_file_name = stralloc (arg); - else if (work_argc) { /* Next argument is file-name. */ - work_argc --; - * work_argv = NULL; /* Not a source file-name. */ - gdb_symbol_file_name = * ++ work_argv; - } else - as_warn("%s: I expected a filename after -G", myname); - arg = ""; /* Finished with this arg. */ - break; -#endif - - case 'I': { /* Include file directory */ - - char *temp; - if (*arg) - temp = stralloc (arg); - else if (work_argc) { - * work_argv = NULL; - work_argc--; - temp = * ++ work_argv; - } else - as_warn("%s: I expected a filename after -I", myname); - add_include_dir (temp); - arg = ""; /* Finished with this arg. */ - break; - } - -#ifndef WORKING_DOT_WORD - case 'k': - break; -#endif - - case 'L': /* -L means keep L* symbols */ - break; - - case 'o': - if (*arg) /* Rest of argument is object file-name. */ - out_file_name = stralloc (arg); - else if (work_argc) { /* Want next arg for a file-name. */ - * work_argv = NULL; /* This is not a file-name. */ - work_argc--; - out_file_name = * ++ work_argv; - } else - as_warn("%s: I expected a filename after -o. \"%s\" assumed.", myname, out_file_name); - arg = ""; /* Finished with this arg. */ - break; - - case 'R': - /* -R means put data into text segment */ - break; - - case 'v': -#ifdef VMS - { - extern char *compiler_version_string; - compiler_version_string = arg; - } -#else /* not VMS */ - fprintf(stderr,version_string); - if(*arg && strcmp(arg,"ersion")) - as_warn("Unknown -v option ignored"); -#endif - while(*arg) arg++; /* Skip the rest */ - break; - - case 'W': - /* -W means don't warn about things */ - case 'X': - /* -X means treat warnings as errors */ - case 'Z': - /* -Z means attempt to generate object file even after errors. */ - break; - - default: - --arg; - if(md_parse_option(&arg,&work_argc,&work_argv)==0) - as_warn("%s: I don't understand '%c' flag.", myname, a); - if(arg && *arg) - arg++; - break; - } - } - /* - * We have just processed a "-..." arg, which was not a - * file-name. Smash it so the - * things that look for filenames won't ever see it. - * - * Whatever work_argv points to, it has already been used - * as part of a flag, so DON'T re-use it as a filename. - */ - *work_argv = NULL; /* NULL means 'not a file-name' */ - } -#ifdef DONTDEF - if (gdb_begin(gdb_symbol_file_name) == 0) - flagseen ['G'] = 0; /* Don't do any gdbsym stuff. */ -#endif - /* Here with flags set up in flagseen[]. */ - perform_an_assembly_pass(argc,argv); /* Assemble it. */ -#ifdef TC_I960 - brtab_emit(); -#endif - if (seen_at_least_1_file() - && !((had_warnings() && flagseen['Z']) - || had_errors() > 0)) { - write_object_file(); /* relax() addresses then emit object file */ - } /* we also check in write_object_file() just before emit. */ - - input_scrub_end(); - md_end(); /* MACHINE.c */ - -#ifndef VMS - return((had_warnings() && flagseen['Z']) - || had_errors() > 0); /* WIN */ -#else /* VMS */ - return(!((had_warnings() && flagseen['Z']) - || had_errors() > 0)); /* WIN */ -#endif /* VMS */ - -} /* main() */ - - -/* perform_an_assembly_pass() - * - * Here to attempt 1 pass over each input file. - * We scan argv[*] looking for filenames or exactly "" which is - * shorthand for stdin. Any argv that is NULL is not a file-name. - * We set need_pass_2 TRUE if, after this, we still have unresolved - * expressions of the form (unknown value)+-(unknown value). - * - * Note the un*x semantics: there is only 1 logical input file, but it - * may be a catenation of many 'physical' input files. - */ -static void perform_an_assembly_pass(argc, argv) -int argc; -char **argv; -{ - int saw_a_file = 0; - - text_fix_root = NULL; - data_fix_root = NULL; - need_pass_2 = 0; - - subseg_new (SEG_TEXT, 0); - - argv++; /* skip argv[0] */ - argc--; /* skip argv[0] */ - while (argc--) { - if (*argv) { /* Is it a file-name argument? */ - saw_a_file++; - /* argv->"" if stdin desired, else->filename */ - read_a_source_file(*argv); - } - argv++; /* completed that argv */ - } - if(!saw_a_file) - read_a_source_file(""); -} /* perform_an_assembly_pass() */ - -/* - * stralloc() - * - * Allocate memory for a new copy of a string. Copy the string. - * Return the address of the new string. Die if there is any error. - */ - -static char * -stralloc (str) -char * str; -{ - register char * retval; - register long len; - - len = strlen (str) + 1; - retval = xmalloc (len); - (void) strcpy(retval, str); - return(retval); -} - -#ifdef comment -static void lose() { - as_fatal("%s: 2nd pass not implemented - get your code from random(3)", myname); - return; -} /* lose() */ -#endif /* comment */ - -static SIGTY -got_sig(sig) -int sig; -{ - static here_before = 0; - - as_bad("Interrupted by signal %d", sig); - if(here_before++) - exit(1); - return((SIGTY) 0); -} - -/* - * Local Variables: - * comment-column: 0 - * fill-column: 131 - * End: - */ - -/* end: as.c */ diff --git a/gas/as.h b/gas/as.h deleted file mode 100644 index 84c963a473c..00000000000 --- a/gas/as.h +++ /dev/null @@ -1,408 +0,0 @@ -/* as.h - global header file - Copyright (C) 1987, 1990, 1991 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* static const char rcsid[] = "$Id$"; */ - -#define GAS 1 - -#include "host.h" -#include "flonum.h" - -#ifndef __STDC__ -#define volatile /**/ -#ifndef const -#define const /**/ -#endif /* const */ -#endif /* __STDC__ */ - -#ifdef __GNUC__ -#define alloca __builtin_alloca -#define register -#endif /* __GNUC__ */ - -#ifndef __LINE__ -#define __LINE__ "unknown" -#endif /* __LINE__ */ - -#ifndef __FILE__ -#define __FILE__ "unknown" -#endif /* __FILE__ */ - -/* - * I think this stuff is largely out of date. xoxorich. - * - * CAPITALISED names are #defined. - * "lowercaseH" is #defined if "lowercase.h" has been #include-d. - * "lowercaseT" is a typedef of "lowercase" objects. - * "lowercaseP" is type "pointer to object of type 'lowercase'". - * "lowercaseS" is typedef struct ... lowercaseS. - * - * #define DEBUG to enable all the "know" assertion tests. - * #define SUSPECT when debugging. - * #define COMMON as "extern" for all modules except one, where you #define - * COMMON as "". - * If TEST is #defined, then we are testing a module: #define COMMON as "". - */ - -/* These #defines are for parameters of entire assembler. */ - -/* #define SUSPECT JF remove for speed testing */ -/* These #includes are for type definitions etc. */ - -#include -#include - -#define obstack_chunk_alloc xmalloc -#define obstack_chunk_free xfree - -#define BAD_CASE(value) \ -{ \ - as_fatal("Case value %d unexpected at line %d of file \"%s\"\n", \ - value, __LINE__, __FILE__); \ -} - - -/* These are assembler-wide concepts */ - - -#ifndef COMMON -#ifdef TEST -#define COMMON /* declare our COMMONs storage here. */ -#else -#define COMMON extern /* our commons live elswhere */ -#endif -#endif - /* COMMON now defined */ -#define DEBUG /* temporary */ - -#ifdef DEBUG -#undef NDEBUG -#define know(p) assert(p) /* Verify our assumptions! */ -#else -#define know(p) /* know() checks are no-op.ed */ -#endif - - -#define xfree free - -/* input_scrub.c */ - -/* - * Supplies sanitised buffers to read.c. - * Also understands printing line-number part of error messages. - */ - - -/* subsegs.c Sub-segments. Also, segment(=expression type)s.*/ - -/* - * This table describes the use of segments as EXPRESSION types. - * - * X_seg X_add_symbol X_subtract_symbol X_add_number - * SEG_ABSENT no (legal) expression - * SEG_PASS1 no (defined) " - * SEG_BIG * > 32 bits const. - * SEG_ABSOLUTE 0 - * SEG_DATA * 0 - * SEG_TEXT * 0 - * SEG_BSS * 0 - * SEG_UNKNOWN * 0 - * SEG_DIFFERENCE 0 * 0 - * SEG_REGISTER * - * - * The blank fields MUST be 0, and are nugatory. - * The '0' fields MAY be 0. The '*' fields MAY NOT be 0. - * - * SEG_BIG: X_add_number is < 0 if the result is in - * generic_floating_point_number. The value is -'c' where c is the - * character that introduced the constant. e.g. "0f6.9" will have -'f' - * as a X_add_number value. - * X_add_number > 0 is a count of how many littlenums it took to - * represent a bignum. - * SEG_DIFFERENCE: - * If segments of both symbols are known, they are the same segment. - * X_add_symbol != X_sub_symbol (then we just cancel them, => SEG_ABSOLUTE). - */ - -#ifdef MANY_SEGMENTS -#define SEG_NORMAL(x) ((x) >= SEG_E0 && (x) <= SEG_E9) -#else -#define SEG_NORMAL(x) ((x) == SEG_TEXT || (x) == SEG_DATA || (x) == SEG_BSS) -#endif - -typedef enum _segT { - SEG_ABSOLUTE = 0, -#ifdef MANY_SEGMENTS - /* For the moment, we allow only 10 extra segments to be specified by the user */ - SEG_E0, SEG_E1,SEG_E2,SEG_E3,SEG_E4,SEG_E5,SEG_E6,SEG_E7,SEG_E8,SEG_E9, -#else - SEG_TEXT, - SEG_DATA, - SEG_BSS, -#endif - SEG_UNKNOWN, - SEG_ABSENT, /* Mythical Segment (absent): NO expression seen. */ - SEG_PASS1, /* Mythical Segment: Need another pass. */ - SEG_GOOF, /* Only happens if AS has a logic error. */ - /* Invented so we don't crash printing */ - /* error message involving weird segment. */ - SEG_BIG, /* Bigger than 32 bits constant. */ - SEG_DIFFERENCE, /* Mythical Segment: absolute difference. */ - SEG_DEBUG, /* Debug segment */ - SEG_NTV, /* Transfert vector preload segment */ - SEG_PTV, /* Transfert vector postload segment */ - SEG_REGISTER, /* Mythical: a register-valued expression */ -} segT; - -#define SEG_MAXIMUM_ORDINAL (SEG_REGISTER) - -typedef int subsegT; - -COMMON subsegT now_subseg; - /* What subseg we are accreting now? */ - - -COMMON segT now_seg; - /* Segment our instructions emit to. */ - /* Only OK values are SEG_TEXT or SEG_DATA. */ - - -extern char *const seg_name[]; -extern int section_alignment[]; - - -/* relax() */ - -typedef enum _relax_state { - rs_fill, /* Variable chars to be repeated fr_offset times. Fr_symbol - unused. Used with fr_offset == 0 for a constant length - frag. */ - - rs_align, /* Align: Fr_offset: power of 2. 1 variable char: fill - character. */ - - rs_org, /* Org: Fr_offset, fr_symbol: address. 1 variable char: fill - character. */ - - rs_machine_dependent, - -#ifndef WORKING_DOT_WORD - rs_broken_word, /* JF: gunpoint */ -#endif -} relax_stateT; - -/* typedef unsigned char relax_substateT; */ -/* JF this is more likely to leave the end of a struct frag on an align - boundry. Be very careful with this. */ -typedef unsigned long relax_substateT; - -typedef unsigned long relax_addressT;/* Enough bits for address. */ - /* Still an integer type. */ - - -/* frags.c */ - -/* - * A code fragment (frag) is some known number of chars, followed by some - * unknown number of chars. Typically the unknown number of chars is an - * instruction address whose size is yet unknown. We always know the greatest - * possible size the unknown number of chars may become, and reserve that - * much room at the end of the frag. - * Once created, frags do not change address during assembly. - * We chain the frags in (a) forward-linked list(s). The object-file address - * of the 1st char of a frag is generally not known until after relax(). - * Many things at assembly time describe an address by {object-file-address - * of a particular frag}+offset. - - BUG: it may be smarter to have a single pointer off to various different -notes for different frag kinds. See how code pans - */ -struct frag /* a code fragment */ -{ - unsigned long fr_address; /* Object file address. */ - struct frag *fr_next; /* Chain forward; ascending address order. */ - /* Rooted in frch_root. */ - - long fr_fix; /* (Fixed) number of chars we know we have. */ - /* May be 0. */ - long fr_var; /* (Variable) number of chars after above. */ - /* May be 0. */ - struct symbol *fr_symbol; /* For variable-length tail. */ - long fr_offset; /* For variable-length tail. */ - char *fr_opcode; /*->opcode low addr byte,for relax()ation*/ - relax_stateT fr_type; /* What state is my tail in? */ - relax_substateT fr_subtype; - /* These are needed only on the NS32K machines */ - char fr_pcrel_adjust; - char fr_bsr; - char fr_literal [1]; /* Chars begin here. */ - /* One day we will compile fr_literal[0]. */ -}; -#define SIZEOF_STRUCT_FRAG \ - ((int)zero_address_frag.fr_literal-(int)&zero_address_frag) - /* We want to say fr_literal[0] above. */ - -typedef struct frag fragS; - -COMMON fragS * frag_now; /* -> current frag we are building. */ - /* This frag is incomplete. */ - /* It is, however, included in frchain_now. */ - /* Frag_now->fr_fix is bogus. Use: */ -/* Virtual frag_now->fr_fix==obstack_next_free(&frags)-frag_now->fr_literal.*/ - -COMMON fragS zero_address_frag; /* For foreign-segment symbol fixups. */ -COMMON fragS bss_address_frag; /* For local common (N_BSS segment) fixups. */ - -/* main program "as.c" (command arguments etc) */ - -COMMON char -flagseen[128]; /* ['x'] TRUE if "-x" seen. */ - -COMMON char * -out_file_name; /* name of emitted object file */ - -COMMON int need_pass_2; /* TRUE if we need a second pass. */ - -typedef struct { - char * poc_name; /* assembler mnemonic, lower case, no '.' */ - void (*poc_handler)(); /* Do the work */ - int poc_val; /* Value to pass to handler */ -} pseudo_typeS; - -#if defined(__STDC__) & !defined(NO_STDARG) - -int had_errors(void); -int had_warnings(void); -void as_bad(const char *Format, ...); -void as_fatal(const char *Format, ...); -void as_tsktsk(const char *Format, ...); -void as_warn(const char *Format, ...); - -#else - -int had_errors(); -int had_warnings(); -void as_bad(); -void as_fatal(); -void as_tsktsk(); -void as_warn(); - -#endif /* __STDC__ & !NO_STDARG */ - -#ifdef __STDC__ - -char *app_push(void); -char *atof_ieee(char *str, int what_kind, LITTLENUM_TYPE *words); -char *input_scrub_include_file(char *filename, char *position); -char *input_scrub_new_file(char *filename); -char *input_scrub_next_buffer(char **bufp); -char *strstr(const char *s, const char *wanted); -char *xmalloc(int size); -char *xrealloc(char *ptr, long n); -int do_scrub_next_char(int (*get)(), void (*unget)()); -int gen_to_words(LITTLENUM_TYPE *words, int precision, long exponent_bits); -int had_err(void); -int had_errors(void); -int had_warnings(void); -int ignore_input(void); -int scrub_from_file(void); -int scrub_from_file(void); -int scrub_from_string(void); -int seen_at_least_1_file(void); -void app_pop(char *arg); -void as_howmuch(FILE *stream); -void as_perror(char *gripe, char *filename); -void as_where(void); -void bump_line_counters(void); -void do_scrub_begin(void); -void input_scrub_begin(void); -void input_scrub_close(void); -void input_scrub_end(void); -void int_to_gen(long x); -void new_logical_line(char *fname, int line_number); -void scrub_to_file(int ch); -void scrub_to_string(int ch); -void subseg_change(segT seg, int subseg); -void subseg_new(segT seg, subsegT subseg); -void subsegs_begin(void); - -#else /* __STDC__ */ - -char *app_push(); -char *atof_ieee(); -char *input_scrub_include_file(); -char *input_scrub_new_file(); -char *input_scrub_next_buffer(); -char *strstr(); -char *xmalloc(); -char *xrealloc(); -int do_scrub_next_char(); -int gen_to_words(); -int had_err(); -int had_errors(); -int had_warnings(); -int ignore_input(); -int scrub_from_file(); -int scrub_from_file(); -int scrub_from_string(); -int seen_at_least_1_file(); -void app_pop(); -void as_howmuch(); -void as_perror(); -void as_where(); -void bump_line_counters(); -void do_scrub_begin(); -void input_scrub_begin(); -void input_scrub_close(); -void input_scrub_end(); -void int_to_gen(); -void new_logical_line(); -void scrub_to_file(); -void scrub_to_string(); -void subseg_change(); -void subseg_new(); -void subsegs_begin(); - -#endif /* __STDC__ */ - - /* this one starts the chain of target dependant headers */ -#include "targ-env.h" - - /* these define types needed by the interfaces */ -#include "struc-symbol.h" -#include "reloc.h" -#include "write.h" -#include "expr.h" -#include "frags.h" -#include "hash.h" -#include "read.h" -#include "symbols.h" - -#include "tc.h" -#include "obj.h" - -/* - * Local Variables: - * comment-column: 0 - * fill-column: 131 - * End: - */ - -/* end: as.h */ - diff --git a/gas/atof-generic.c b/gas/atof-generic.c deleted file mode 100644 index 7d2d8f4c1e5..00000000000 --- a/gas/atof-generic.c +++ /dev/null @@ -1,549 +0,0 @@ -/* atof_generic.c - turn a string of digits into a Flonum - Copyright (C) 1987, 1990, 1991 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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 1, or (at your option) -any later version. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* static const char rcsid[] = "$Id$"; */ - -#include -#include - -#include "as.h" - -#ifdef __GNUC__ -#define alloca __builtin_alloca -#else -#ifdef sparc -#include -#endif -#endif - -#ifdef USG -#define bzero(s,n) memset(s,0,n) -#endif - -/* #define FALSE (0) */ -/* #define TRUE (1) */ - -/***********************************************************************\ -* * -* Given a string of decimal digits , with optional decimal * -* mark and optional decimal exponent (place value) of the * -* lowest_order decimal digit: produce a floating point * -* number. The number is 'generic' floating point: our * -* caller will encode it for a specific machine architecture. * -* * -* Assumptions * -* uses base (radix) 2 * -* this machine uses 2's complement binary integers * -* target flonums use " " " " * -* target flonums exponents fit in a long * -* * -\***********************************************************************/ - -/* - - Syntax: - - ::= - ::= '+' | '-' | {empty} - ::= - | - | - | - ::= {empty} | - ::= | - ::= '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' - ::= {one character from "string_of_decimal_exponent_marks"} - ::= {one character from "string_of_decimal_marks"} - -*/ - -int /* 0 if OK */ -atof_generic ( - address_of_string_pointer, /* return pointer to just AFTER number we read. */ - string_of_decimal_marks, /* At most one per number. */ - string_of_decimal_exponent_marks, - address_of_generic_floating_point_number) - - char * * address_of_string_pointer; - const char * string_of_decimal_marks; - const char * string_of_decimal_exponent_marks; - FLONUM_TYPE * address_of_generic_floating_point_number; - -{ - - int return_value; /* 0 means OK. */ - char * first_digit; - /* char * last_digit; JF unused */ - int number_of_digits_before_decimal; - int number_of_digits_after_decimal; - long decimal_exponent; - int number_of_digits_available; - char digits_sign_char; - - { - /* - * Scan the input string, abstracting (1)digits (2)decimal mark (3) exponent. - * It would be simpler to modify the string, but we don't; just to be nice - * to caller. - * We need to know how many digits we have, so we can allocate space for - * the digits' value. - */ - - char * p; - char c; - int seen_significant_digit; - - first_digit = * address_of_string_pointer; - c= *first_digit; - if (c=='-' || c=='+') - { - digits_sign_char = c; - first_digit ++; - } - else - digits_sign_char = '+'; - - if( (first_digit[0]=='n' || first_digit[0]=='N') - && (first_digit[1]=='a' || first_digit[1]=='A') - && (first_digit[2]=='n' || first_digit[2]=='N')) { - address_of_generic_floating_point_number->sign=0; - address_of_generic_floating_point_number->exponent=0; - address_of_generic_floating_point_number->leader=address_of_generic_floating_point_number->low; - (*address_of_string_pointer)=first_digit+3; - return 0; - } - if( (first_digit[0]=='i' || first_digit[0]=='I') - && (first_digit[1]=='n' || first_digit[1]=='N') - && (first_digit[2]=='f' || first_digit[2]=='F')) { - address_of_generic_floating_point_number->sign= digits_sign_char=='+' ? 'P' : 'N'; - address_of_generic_floating_point_number->exponent=0; - address_of_generic_floating_point_number->leader=address_of_generic_floating_point_number->low; - if( (first_digit[3]=='i' || first_digit[3]=='I') - && (first_digit[4]=='n' || first_digit[4]=='N') - && (first_digit[5]=='i' || first_digit[5]=='I') - && (first_digit[6]=='t' || first_digit[6]=='T') - && (first_digit[7]=='y' || first_digit[7]=='Y')) - (*address_of_string_pointer)=first_digit+8; - else - (*address_of_string_pointer)=first_digit+3; - return 0; - } - - number_of_digits_before_decimal = 0; - number_of_digits_after_decimal = 0; - decimal_exponent = 0; - seen_significant_digit = 0; - for (p = first_digit; - ((c = * p) != '\0') - && (!c || ! strchr (string_of_decimal_marks, c) ) - && (!c || ! strchr (string_of_decimal_exponent_marks, c) ); - p ++) - { - if (isdigit(c)) - { - if (seen_significant_digit || c > '0') - { - number_of_digits_before_decimal ++; - seen_significant_digit = 1; - } - else - { - first_digit++; - } - } - else - { - break; /* p -> char after pre-decimal digits. */ - } - } /* For each digit before decimal mark. */ - -#ifndef OLD_FLOAT_READS - /* Ignore trailing 0's after the decimal point. The original code here - * (ifdef'd out) does not do this, and numbers like - * 4.29496729600000000000e+09 (2**31) - * come out inexact for some reason related to length of the digit - * string. - */ - if ( c && strchr(string_of_decimal_marks,c) ){ - int zeros = 0; /* Length of current string of zeros */ - - for ( p++; (c = *p) && isdigit(c); p++ ){ - if ( c == '0'){ - zeros++; - } else { - number_of_digits_after_decimal += 1 + zeros; - zeros = 0; - } - } - } -#else - if (c && strchr (string_of_decimal_marks, c)) - { - for (p ++; - ((c = * p) != '\0') - && (!c || ! strchr (string_of_decimal_exponent_marks, c) ); - p ++) - { - if (isdigit(c)) - { - number_of_digits_after_decimal ++; /* This may be retracted below. */ - if (/* seen_significant_digit || */ c > '0') - { - seen_significant_digit = TRUE; - } - } - else - { - if ( ! seen_significant_digit) - { - number_of_digits_after_decimal = 0; - } - break; - } - } /* For each digit after decimal mark. */ - } - while(number_of_digits_after_decimal && first_digit[number_of_digits_before_decimal+number_of_digits_after_decimal]=='0') - --number_of_digits_after_decimal; -/* last_digit = p; JF unused */ -#endif - - if (c && strchr (string_of_decimal_exponent_marks, c) ) - { - char digits_exponent_sign_char; - - c = * ++ p; - if (c && strchr ("+-",c)) - { - digits_exponent_sign_char = c; - c = * ++ p; - } - else - { - digits_exponent_sign_char = '+'; - } - for (; - (c); - c = * ++ p) - { - if (isdigit(c)) - { - decimal_exponent = decimal_exponent * 10 + c - '0'; - /* - * BUG! If we overflow here, we lose! - */ - } - else - { - break; - } - } - if (digits_exponent_sign_char == '-') - { - decimal_exponent = - decimal_exponent; - } - } - * address_of_string_pointer = p; - } - - number_of_digits_available = - number_of_digits_before_decimal - + number_of_digits_after_decimal; - return_value = 0; - if (number_of_digits_available == 0) - { - address_of_generic_floating_point_number -> exponent = 0; /* Not strictly necessary */ - address_of_generic_floating_point_number -> leader - = -1 + address_of_generic_floating_point_number -> low; - address_of_generic_floating_point_number -> sign = digits_sign_char; - /* We have just concocted (+/-)0.0E0 */ - } - else - { - LITTLENUM_TYPE * digits_binary_low; - int precision; - int maximum_useful_digits; - int number_of_digits_to_use; - int more_than_enough_bits_for_digits; - int more_than_enough_littlenums_for_digits; - int size_of_digits_in_littlenums; - int size_of_digits_in_chars; - FLONUM_TYPE power_of_10_flonum; - FLONUM_TYPE digits_flonum; - - - precision = (address_of_generic_floating_point_number -> high - - address_of_generic_floating_point_number -> low - + 1 - ); /* Number of destination littlenums. */ - /* Includes guard bits (two littlenums worth) */ - maximum_useful_digits = ( ((double) (precision - 2)) - * ((double) (LITTLENUM_NUMBER_OF_BITS)) - / (LOG_TO_BASE_2_OF_10) - ) - + 2; /* 2 :: guard digits. */ - if (number_of_digits_available > maximum_useful_digits) - { - number_of_digits_to_use = maximum_useful_digits; - } - else - { - number_of_digits_to_use = number_of_digits_available; - } - decimal_exponent += number_of_digits_before_decimal - number_of_digits_to_use; - - more_than_enough_bits_for_digits - = ((((double)number_of_digits_to_use) * LOG_TO_BASE_2_OF_10) + 1); - more_than_enough_littlenums_for_digits - = ( more_than_enough_bits_for_digits - / LITTLENUM_NUMBER_OF_BITS - ) - + 2; - - /* - * Compute (digits) part. In "12.34E56" this is the "1234" part. - * Arithmetic is exact here. If no digits are supplied then - * this part is a 0 valued binary integer. - * Allocate room to build up the binary number as littlenums. - * We want this memory to disappear when we leave this function. - * Assume no alignment problems => (room for n objects) == - * n * (room for 1 object). - */ - - size_of_digits_in_littlenums = more_than_enough_littlenums_for_digits; - size_of_digits_in_chars = size_of_digits_in_littlenums - * sizeof( LITTLENUM_TYPE ); - digits_binary_low = (LITTLENUM_TYPE *) - alloca (size_of_digits_in_chars); - bzero ((char *)digits_binary_low, size_of_digits_in_chars); - - /* Digits_binary_low[] is allocated and zeroed. */ - - { - /* - * Parse the decimal digits as if * digits_low was in the units position. - * Emit a binary number into digits_binary_low[]. - * - * Use a large-precision version of: - * (((1st-digit) * 10 + 2nd-digit) * 10 + 3rd-digit ...) * 10 + last-digit - */ - - char * p; - char c; - int count; /* Number of useful digits left to scan. */ - - for (p = first_digit, count = number_of_digits_to_use; - count; - p ++, -- count) - { - c = * p; - if (isdigit(c)) - { - /* - * Multiply by 10. Assume can never overflow. - * Add this digit to digits_binary_low[]. - */ - - long carry; - LITTLENUM_TYPE * littlenum_pointer; - LITTLENUM_TYPE * littlenum_limit; - - littlenum_limit - = digits_binary_low - + more_than_enough_littlenums_for_digits - - 1; - carry = c - '0'; /* char -> binary */ - for (littlenum_pointer = digits_binary_low; - littlenum_pointer <= littlenum_limit; - littlenum_pointer ++) - { - long work; - - work = carry + 10 * (long)(*littlenum_pointer); - * littlenum_pointer = work & LITTLENUM_MASK; - carry = work >> LITTLENUM_NUMBER_OF_BITS; - } - if (carry != 0) - { - /* - * We have a GROSS internal error. - * This should never happen. - */ - abort(); /* RMS prefers abort() to any message. */ - } - } - else - { - ++ count; /* '.' doesn't alter digits used count. */ - } /* if valid digit */ - } /* for each digit */ - } - - /* - * Digits_binary_low[] properly encodes the value of the digits. - * Forget about any high-order littlenums that are 0. - */ - while (digits_binary_low [size_of_digits_in_littlenums - 1] == 0 - && size_of_digits_in_littlenums >= 2) - size_of_digits_in_littlenums --; - - digits_flonum . low = digits_binary_low; - digits_flonum . high = digits_binary_low + size_of_digits_in_littlenums - 1; - digits_flonum . leader = digits_flonum . high; - digits_flonum . exponent = 0; - /* - * The value of digits_flonum . sign should not be important. - * We have already decided the output's sign. - * We trust that the sign won't influence the other parts of the number! - * So we give it a value for these reasons: - * (1) courtesy to humans reading/debugging - * these numbers so they don't get excited about strange values - * (2) in future there may be more meaning attached to sign, - * and what was - * harmless noise may become disruptive, ill-conditioned (or worse) - * input. - */ - digits_flonum . sign = '+'; - - { - /* - * Compute the mantssa (& exponent) of the power of 10. - * If sucessful, then multiply the power of 10 by the digits - * giving return_binary_mantissa and return_binary_exponent. - */ - - LITTLENUM_TYPE *power_binary_low; - int decimal_exponent_is_negative; - /* This refers to the "-56" in "12.34E-56". */ - /* FALSE: decimal_exponent is positive (or 0) */ - /* TRUE: decimal_exponent is negative */ - FLONUM_TYPE temporary_flonum; - LITTLENUM_TYPE *temporary_binary_low; - int size_of_power_in_littlenums; - int size_of_power_in_chars; - - size_of_power_in_littlenums = precision; -/* Precision has a built-in fudge factor so we get a few guard bits. */ - - - decimal_exponent_is_negative = decimal_exponent < 0; - if (decimal_exponent_is_negative) - { - decimal_exponent = - decimal_exponent; - } - /* From now on: the decimal exponent is > 0. Its sign is seperate. */ - - size_of_power_in_chars - = size_of_power_in_littlenums - * sizeof( LITTLENUM_TYPE ) + 2; - power_binary_low = (LITTLENUM_TYPE *) alloca ( size_of_power_in_chars ); - temporary_binary_low = (LITTLENUM_TYPE *) alloca ( size_of_power_in_chars ); - bzero ((char *)power_binary_low, size_of_power_in_chars); - * power_binary_low = 1; - power_of_10_flonum . exponent = 0; - power_of_10_flonum . low = power_binary_low; - power_of_10_flonum . leader = power_binary_low; - power_of_10_flonum . high = power_binary_low + size_of_power_in_littlenums - 1; - power_of_10_flonum . sign = '+'; - temporary_flonum . low = temporary_binary_low; - temporary_flonum . high = temporary_binary_low + size_of_power_in_littlenums - 1; - /* - * (power) == 1. - * Space for temporary_flonum allocated. - */ - - /* - * ... - * - * WHILE more bits - * DO find next bit (with place value) - * multiply into power mantissa - * OD - */ - { - int place_number_limit; - /* Any 10^(2^n) whose "n" exceeds this */ - /* value will fall off the end of */ - /* flonum_XXXX_powers_of_ten[]. */ - int place_number; - const FLONUM_TYPE * multiplicand; /* -> 10^(2^n) */ - - place_number_limit = table_size_of_flonum_powers_of_ten; - multiplicand - = ( decimal_exponent_is_negative - ? flonum_negative_powers_of_ten - : flonum_positive_powers_of_ten); - for (place_number = 1; /* Place value of this bit of exponent. */ - decimal_exponent; /* Quit when no more 1 bits in exponent. */ - decimal_exponent >>= 1 - , place_number ++) - { - if (decimal_exponent & 1) - { - if (place_number > place_number_limit) - { - /* - * The decimal exponent has a magnitude so great that - * our tables can't help us fragment it. Although this - * routine is in error because it can't imagine a - * number that big, signal an error as if it is the - * user's fault for presenting such a big number. - */ - return_value = ERROR_EXPONENT_OVERFLOW; - /* - * quit out of loop gracefully - */ - decimal_exponent = 0; - } - else - { -#ifdef TRACE -printf("before multiply, place_number = %d., power_of_10_flonum:\n", place_number); -flonum_print( & power_of_10_flonum ); -(void)putchar('\n'); -#endif - flonum_multip(multiplicand + place_number, &power_of_10_flonum, &temporary_flonum); - flonum_copy (& temporary_flonum, & power_of_10_flonum); - } /* If this bit of decimal_exponent was computable.*/ - } /* If this bit of decimal_exponent was set. */ - } /* For each bit of binary representation of exponent */ -#ifdef TRACE -printf( " after computing power_of_10_flonum: " ); -flonum_print( & power_of_10_flonum ); -(void)putchar('\n'); -#endif - } - - } - - /* - * power_of_10_flonum is power of ten in binary (mantissa) , (exponent). - * It may be the number 1, in which case we don't NEED to multiply. - * - * Multiply (decimal digits) by power_of_10_flonum. - */ - - flonum_multip (& power_of_10_flonum, & digits_flonum, address_of_generic_floating_point_number); - /* Assert sign of the number we made is '+'. */ - address_of_generic_floating_point_number -> sign = digits_sign_char; - - } /* If we had any significant digits. */ - return (return_value); -} /* atof_generic () */ - -/* end: atof_generic.c */ diff --git a/gas/bignum-copy.c b/gas/bignum-copy.c deleted file mode 100644 index 5c70128c1c8..00000000000 --- a/gas/bignum-copy.c +++ /dev/null @@ -1,77 +0,0 @@ -/* bignum_copy.c - copy a bignum - Copyright (C) 1987, 1990, 1991 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* static const char rcsid[] = "$Id$"; */ - -#include "as.h" - -#ifdef USG -#define bzero(s,n) memset(s,0,n) -#define bcopy(from,to,n) memcpy(to,from,n) -#endif - -/* - * bignum_copy () - * - * Copy a bignum from in to out. - * If the output is shorter than the input, copy lower-order littlenums. - * Return 0 or the number of significant littlenums dropped. - * Assumes littlenum arrays are densely packed: no unused chars between - * the littlenums. Uses bcopy() to move littlenums, and wants to - * know length (in chars) of the input bignum. - */ - -/* void */ -int -bignum_copy (in, in_length, out, out_length) - register LITTLENUM_TYPE * in; - register int in_length; /* in sizeof(littlenum)s */ - register LITTLENUM_TYPE * out; - register int out_length; /* in sizeof(littlenum)s */ -{ - register int significant_littlenums_dropped; - - if (out_length < in_length) - { - register LITTLENUM_TYPE * p; /* -> most significant (non-zero) input littlenum. */ - - bcopy ((char *)in, (char *)out, out_length << LITTLENUM_SHIFT); - for (p = in + in_length - 1; p >= in; -- p) - { - if (* p) break; - } - significant_littlenums_dropped = p - in - in_length + 1; - if (significant_littlenums_dropped < 0) - { - significant_littlenums_dropped = 0; - } - } - else - { - bcopy ((char *)in, (char *)out, in_length << LITTLENUM_SHIFT); - if (out_length > in_length) - { - bzero ((char *)(out + out_length), (out_length - in_length) << LITTLENUM_SHIFT); - } - significant_littlenums_dropped = 0; - } - return (significant_littlenums_dropped); -} - -/* end: bignum_copy.c */ diff --git a/gas/bignum.h b/gas/bignum.h deleted file mode 100644 index 9b1b8e8610a..00000000000 --- a/gas/bignum.h +++ /dev/null @@ -1,47 +0,0 @@ -/* bignum.h-arbitrary precision integers - Copyright (C) 1987 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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 1, or (at your option) -any later version. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/***********************************************************************\ -* * -* Arbitrary-precision integer arithmetic. * -* For speed, we work in groups of bits, even though this * -* complicates algorithms. * -* Each group of bits is called a 'littlenum'. * -* A bunch of littlenums representing a (possibly large) * -* integer is called a 'bignum'. * -* Bignums are >= 0. * -* * -\***********************************************************************/ - -#define LITTLENUM_NUMBER_OF_BITS (16) -#define LITTLENUM_RADIX (1 << LITTLENUM_NUMBER_OF_BITS) -#define LITTLENUM_MASK (0xFFFF) -#define LITTLENUM_SHIFT (1) -#define CHARS_PER_LITTLENUM (1 << LITTLENUM_SHIFT) -#ifndef BITS_PER_CHAR -#define BITS_PER_CHAR (8) -#endif - -typedef unsigned short LITTLENUM_TYPE; - -/* JF truncated this to get around a problem with GCC */ -#define LOG_TO_BASE_2_OF_10 (3.3219280948873623478703194294893901758651 ) - /* WARNING: I haven't checked that the trailing digits are correct! */ - -/* end: bignum.h */ diff --git a/gas/cond.c b/gas/cond.c deleted file mode 100644 index 38aec6fe4e3..00000000000 --- a/gas/cond.c +++ /dev/null @@ -1,128 +0,0 @@ -/* cond.c - conditional assembly pseudo-ops, and .include - Copyright (C) 1990, 1991 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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 1, or (at your option) -any later version. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* static const char rcsid[] = "$Id$"; */ - -#include "as.h" - -#include "obstack.h" - -void s_ifdef(arg) -int arg; -{ -/* register char c; */ - register char *name; /* points to name of symbol */ - register struct symbol * symbolP; /* Points to symbol */ - - SKIP_WHITESPACE(); /* Leading whitespace is part of operand. */ - name = input_line_pointer; - if (!is_name_beginner(*name)) { - as_bad("invalid identifier for .ifdef"); - obstack_1grow (&cond_obstack, 0); - } else { - get_symbol_end(); - ++input_line_pointer; - symbolP = symbol_find(name); - - /* ??? Should we try to optimize such that if we hit a .endif - before a .else, we don't need to push state? */ - obstack_1grow(&cond_obstack, (symbolP != 0) ^ arg); - } -} /* s_ifdef() */ - -/* This is allocated to grow and shrink as .ifdef/.endif pairs - are scanned. When the top element is nonzero, it means - we should accept input. Otherwise, we should ignore input. */ -struct obstack cond_obstack; - -void s_if(arg) -int arg; -{ - expressionS operand; - - SKIP_WHITESPACE(); /* Leading whitespace is part of operand. */ - expr(0, &operand); - - if (operand.X_add_symbol != NULL - || operand.X_subtract_symbol != NULL) - as_bad("non-constant expression in .if statement"); - - /* If the above error is signaled, this will dispatch - using an undefined result. No big deal. */ - obstack_1grow(&cond_obstack, (operand.X_add_number != 0) ^ arg); -} /* s_if() */ - -void s_endif(arg) -int arg; -{ - char *base = obstack_base(&cond_obstack); - char *ptr = obstack_next_free(&cond_obstack); - - if (ptr-1 == base) { - as_bad("unbalanced .endif"); - } else { - obstack_free(&cond_obstack, ptr-1); - cond_obstack.object_base = base; - } -} /* s_endif() */ - -void s_else(arg) -int arg; -{ - char *ptr = obstack_next_free(&cond_obstack); - if (ptr-1 == obstack_base(&cond_obstack)) { - as_bad(".else without matching .if"); - } else { - ptr[-1] = !ptr[-1]; - } -} /* s_else() */ - -void s_ifeqs(arg) -int arg; -{ - as_bad("ifeqs not implemented."); -} /* s_ifeqs() */ - -void s_end(arg) -int arg; -{ - ; -} /* s_end() */ - -int ignore_input() { - char *ptr = obstack_next_free (&cond_obstack); - - /* We cannot ignore certain pseudo ops. */ - if (input_line_pointer[-1] == '.') - { - if (input_line_pointer[0] == 'i' - && (!strncmp (input_line_pointer, "if", 2) - || !strncmp (input_line_pointer, "ifdef", 5) - || !strncmp (input_line_pointer, "ifndef", 6))) - return 0; - if (input_line_pointer[0] == 'e' - && (!strncmp (input_line_pointer, "else", 4) - || !strncmp (input_line_pointer, "endif", 5))) - return 0; - } - - return (ptr[-1] == 0); -} /* ignore_input() */ - -/* end of cond.c */ diff --git a/gas/config.sub b/gas/config.sub deleted file mode 100755 index dac9ab89d4f..00000000000 --- a/gas/config.sub +++ /dev/null @@ -1,446 +0,0 @@ -#!/bin/sh - -# Configuration subroutine to validate and canonicalize a configuration type. -# Supply the specified configuration type as an argument. -# If it is invalid, we print an error message on stderr and exit with code 1. -# Otherwise, we print the canonical config type on stdout and succeed. - -# This file is supposed to be the same for all GNU packages -# and recognize all the CPU types, system types and aliases -# that are meaningful with *any* GNU software. -# Each package is responsible for reporting which valid configurations -# it does not support. The user should be able to distinguish -# a failure to support a valid configuration from a meaningless -# configuration (e.g. a typo). - -# Please email any bugs, comments, and/or additions to this file to: -# configure@cygnus.com - -# decode aliases into canonical names - -case "$1" in -# cpu alone is a valid alias for cpu-none-none. -vax | tahoe | i386 | i860 | m68k | m68000 | m88k | sparc | ns32k \ - | alliant | arm | c1 | c2 | mips | pyramid | tron | a29k \ - | romp | rs6000 | i960 | h8300) - cpu=$1 - vendor=none - os=none - ;; -altos | altos3068) - cpu=m68k - vendor=altos - os=sysv # maybe? - ;; -altosgas) - cpu=m68k - vendor=altos - os=gas - ;; -am29k) - cpu=a29k - vendor=none - os=bsd - ;; -amdahl) - cpu=580 - vendor=amdahl - os=uts - ;; -amigados) - cpu=m68k - vendor=cbm - os=amigados # Native AmigaDOS - ;; -amigaunix | amix) - cpu=m68k - vendor=cbm - os=svr4 # System V Release 4 (svr4 is an industry recognized acronym) - ;; -apollo68) - cpu=m68k - vendor=apollo - os=sysv # maybe? - ;; -balance) - cpu=ns32k - vendor=sequent - os=dynix - ;; -convex-c1) - cpu=c1 - vendor=convex - os=sysv # maybe? - ;; -convex-c2) - cpu=c2 - vendor=convex - os=sysv # maybe? - ;; -cray | ymp) - cpu=ymp - vendor=cray - os=unicos - ;; -cray2) - cpu=cray2 - vendor=cray - os=unicos - ;; -dec3100 | decstatn | decstation | decstation-3100 | pmax | pmin) - cpu=mips - vendor=dec - os=ultrix - ;; -delta | 3300 | motorola-3300 | motorola-delta \ - | 3300-motorola | delta-motorola) - cpu=m68k - vendor=motorola - os=sysv # maybe? - ;; - -delta88) - cpu=m88k - vendor=motorola - os=m88kbcs - ;; - -gmicro) - cpu=tron - vendor=gmicro - os=sysv # maybe? - ;; - -h8300hds) - cpu=h8300 - vendor=hitachi - os=hds - ;; - -# start-sanitize-v9 -hal-32 | hal32) - cpu=sparc64 - vendor=hal - os=hal32 - ;; -hal-64 | hal64) - cpu=sparc64 - vendor=hal - os=hal64 - ;; -sparc64) - cpu=sparc64 - vendor=sun - os=v9 - ;; -sparc64-v7 | sparc64v7) - cpu=sparc64 - vendor=sun - os=v7 - ;; -# end-sanitize-v9 -hp300bsd) - cpu=m68k - vendor=hp - os=bsd - ;; -hp300hpux | hpux | hp9k3[2-9][0-9]) - cpu=m68k - vendor=hp - os=hpux - ;; -hp9k31[0-9] | hp9k2[0-9][0-9]) - cpu=m68000 - vendor=hp - os=hpux - ;; -i386sco) - cpu=i386 - vendor=sco - os=sysv # maybe? - ;; -i386v) - cpu=i386 - vendor=none - os=sysv - ;; -i386v32) - cpu=i386 - vendor=none - os=sysv32 - ;; -iris | iris4d) - cpu=mips - vendor=sgi - os=irix # maybe? - ;; - -dpx2) - vendor=bull - cpu=m68k - os=sysv - ;; -isi | isi68) - cpu=m68k - vendor=isi - os=sysv # maybe? - ;; -littlemips) - cpu=mips - vendor=little - os=bsd - ;; -magnum | m3230) - cpu=mips - vendor=mips - os=sysv # maybe? - ;; -merlin) - cpu=ns32k - vendor=utek - os=sysv # maybe? - ;; -miniframe) - cpu=m68000 - vendor=convergent - os=sysv # maybe? - ;; -mmax) - cpu=ns32k - vendor=encore - os=sysv # maybe? - ;; -news | news700 | news800 | news900) - cpu=m68k - vendor=sony - os=newsos3 # Based on bsd-4.3 - ;; -news1000) - cpu=m68030 - vendor=sony - os=newsos3 # ? - ;; -news-3600 | bigmips | risc-news) - cpu=mips - vendor=sony - os=newsos4 # Presumably? - ;; -next) - cpu=m68k - vendor=next - os=sysv # maybe? - ;; -nindy960) - cpu=i960 - vendor=intel - os=nindy - ;; -none) - cpu=none - vendor=none - os=none - ;; -np1) - cpu=np1 - vendor=gould - os=sysv # maybe? - ;; -rtpc) - cpu=romp - vendor=ibm - os=aix # maybe? - ;; -pbd) - cpu=sparc - vendor=unicom - os=sysv - ;; -pn) - cpu=pn - vendor=gould - os=sysv # maybe? - ;; -ps2) - cpu=i386 - vendor=ibm - os=sysv # maybe? - ;; -sun2) - cpu=m68000 - vendor=sun - os=sunos4 - ;; -sun2os3) - cpu=m68000 - vendor=sun - os=sunos3 - ;; -sun2os4) - cpu=m68000 - vendor=sun - os=sunos4 - ;; -sun3) - cpu=m68k - vendor=sun - os=sunos4 - ;; -sun3os3) - cpu=m68k - vendor=sun - os=sunos3 - ;; -sun3os4) - cpu=m68k - vendor=sun - os=sunos4 - ;; -sun386 | roadrunner | sun386i) - cpu=i386 - vendor=sun - os=sunos - ;; -sun4) - cpu=sparc - vendor=sun - os=sunos4 - ;; -sun4os3) - cpu=sparc - vendor=sun - os=sunos3 - ;; -sun4os4) - cpu=sparc - vendor=sun - os=sunos4 - ;; -symmetry) - cpu=i386 - vendor=sequent - os=dynix - ;; -tower | tower-32) - cpu=m68k - vendor=ncr - os=sysv # maybe? - ;; -ultra3) - cpu=a29k - vendor=nyu - os=sym1 - ;; -umax) - cpu=ns32k - vendor=encore - os=sysv # maybe? - ;; -unixpc | safari | pc7300 | 3b1 | 7300 | 7300-att | att-7300) - cpu=m68k - vendor=att - os=sysv # maybe? - ;; -vax-dec) - cpu=vax - vendor=dec - os=ultrix # maybe? - ;; -vxworks68) - cpu=m68k - vendor=wrs - os=vxworks - ;; -vxworks960) - cpu=i960 - vendor=wrs - os=vxworks - ;; -xmp) - cpu=xmp - vendor=cray - os=unicos - ;; -# not an alias. parse what we expect to be a canonical name. -*) - cpu=`echo $1 | sed 's/-.*$//'` - - if [ "${cpu}" = "$1" ] ; then - # no vendor so this is an invalid name. - echo '***' No vendor: configuration \`$1\' not recognized 1>&2 - exit 1 - else - # parse out vendor - rest=`echo $1 | sed "s/${cpu}-//"` - vendor=`echo ${rest} | sed 's/-.*$//'` - - if [ "${vendor}" = "${rest}" ] ; then - # a missing os is acceptable - os=none - else - os=`echo ${rest} | sed "s/${vendor}-//"` - fi - fi - ;; -esac - -# At this point we should have three parts of a canonical name in cpu, -# vendor, and os. - -# verify that the cpu is known. - -case "${cpu}" in -none | vax | tahoe | i386 | i860 | m68k | m68000 | m88k | sparc \ - | ns32k | alliant | arm | c1 | c2 | mips | pyramid | tron \ - | a29k | romp | rs6000 | i960 | xmp | ymp | cray2 | 580 | h8300) - ;; - -# start-sanitize-v9 -sparc64) ;; -# end-sanitize-v9 - -*) - echo '***' Invalid cpu \`${cpu}\': configuration \`$1\' not recognized 1>&2 - exit 1 - ;; -esac - -# verify that the vendor is known. - -case "${vendor}" in - altos | amdahl | aout | apollo | att | bcs | bout |\ - cbm | convergent | convex | coff | cray | dec | encore |\ - gould | hitachi | intel | isi | hp | ibm | little | mips | motorola |\ - ncr | next | none | nyu | sco | sequent | sgi | sony | sun |\ - unicom | utek | wrs | bull ) ;; - -# start-sanitize-v9 -hal) ;; -# end-sanitize-v9 - -*) - echo '***' Invalid vendor \`${vendor}\': configuration \`$1\' not recognized 1>&2 - exit 1 - ;; -esac - -# verify that the os is known, if it exists. - -case "${os}" in -aix* | aout | bout | bsd* | coff | ctix* | dynix* | esix* | hpux* \ - | hds | irix* | isc* | kern | mach* | newsos* | nindy* | none \ - | osf* | sco* | sunos* | sysv* | ultrix* | unos* | v88r* \ - | vms* | vxworks* | sym[1-9]* | unicos* | uts | svr4 \ - | amigados) - ;; - -# start-sanitize-v9 -hal32 | hal64 | v7 | v9) ;; -# end-sanitize-v9 - -*) - echo '***' Invalid os \`${os}\': configuration \`$1\' not recognized 1>&2 - exit 1 - ;; -esac - -echo ${cpu}-${vendor}-${os} diff --git a/gas/config/.Sanitize b/gas/config/.Sanitize deleted file mode 100644 index 7ab77901ddf..00000000000 --- a/gas/config/.Sanitize +++ /dev/null @@ -1,157 +0,0 @@ -# Sanitize.in for devo. -# $Id$ -# - -# Each directory to survive it's way into a release will need a file -# like this one called "./.Sanitize". All keyword lines must exist, -# and must exist in the order specified by this file. Each directory -# in the tree will be processed, top down, in the following order. - -# Hash started lines like this one are comments and will be deleted -# before anything else is done. Blank lines will also be squashed -# out. - -# The lines between the "Do-first:" line and the "Things-to-keep:" -# line are executed as a /bin/sh shell script before anything else is -# done in this - -Do-first: - -echo Sanitizing `pwd`... - -# All files listed between the "Things-to-keep:" line and the -# "Files-to-sed:" line will be kept. All other files will be removed. -# Directories listed in this section will have their own Sanitize -# called. Directories not listed will be removed in their entirety -# with rm -rf. - -Things-to-keep: - -a.out.h -atof-ieee.c -atof-vax.c -coff.gnu.h -cplus-dem.c -ho-a29k.h -ho-ansi.h -ho-cygnus.h -ho-decstation.h -ho-generic.h -ho-hpux.h -ho-i386.h -ho-rs6000.h -ho-sun3.h -ho-sun386.h -ho-sun4.h -ho-sunos.h -ho-sysv.h -ho-vax.h -mh-a29k -mh-cygnus -mh-i386 -mt-ebmon29k -mt-h8300 -mt-h8300hds -mt-m68k -mt-mips -obj-aout.c -obj-aout.h -obj-bfd-sunos.c -obj-bfd-sunos.h -obj-bout.c -obj-bout.h -obj-coff.c -obj-coff.h -obj-generic.c -obj-generic.h -obj-ieee.c -obj-ieee.h -ranlib.h -signame.h -stab.h -tc-a29k.c -tc-a29k.h -tc-generic.c -tc-generic.h -tc-h8300.c -tc-h8300.h -tc-i386.c -tc-i386.h -tc-i860.c -tc-i860.h -tc-i960.c -tc-i960.h -tc-m68851.h -tc-m68k.c -tc-m68k.h -tc-mips.c -tc-mips.h -tc-ns32k.c -tc-ns32k.h -tc-sparc.h -tc-sparc.c -tc-vax.c -tc-vax.h -te-dpx2.h -te-generic.h -te-ic960.h -te-motor.h -te-sco386.h -te-sparc.h -te-sun3.h -te-unisoft.h -tmake-m68k -vax-inst.h -vms - - - -Do-last: - -if ( echo $* | grep keep\-v9 > /dev/null ) ; then - echo Keeping v9 stuff in tc-sparc.c. -else - echo Cleaning tc-sparc.c... - sed '/start\-sanitize/,/end-sanitize/d' < tc-sparc.c > new - if [ -n "${safe}" ] ; then - cp tc-sparc.c .Recover - fi - mv new tc-sparc.c -fi - -echo Done in `pwd`. - -# -# -# $Log$ -# Revision 1.9 1991/11/11 23:36:39 sac -# Added tc-sparc.c -# -# Revision 1.8 1991/11/06 11:53:16 sac -# Wouldn't it be nice if Sanitize ignored spaces ? -# -# Revision 1.7 1991/11/06 09:14:33 sac -# Uniq contents, since configure gets confused if the same file is in more than once. -# -# Revision 1.6 1991/11/05 21:21:12 sac -# Added a load of mt/mh files -# -# Revision 1.5 1991/10/22 03:26:06 steve -# tmake-ebmon -# -# Revision 1.4 1991/09/04 01:55:53 rich -# test & recover a better way. -# -# Revision 1.3 1991/09/02 21:26:15 rich -# "recover" tc-sparc.c -# -# Revision 1.2 1991/09/02 01:03:38 rich -# Correct a few things. -# -# Revision 1.1 1991/05/23 17:09:03 rich -# Initial revision -# -# -# - -# End of file. diff --git a/gas/config/a.out.h b/gas/config/a.out.h deleted file mode 100755 index 58722415c2c..00000000000 --- a/gas/config/a.out.h +++ /dev/null @@ -1,150 +0,0 @@ -/* This file describes the a.out file format - Copyright (C) 1987 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* $Id$ */ - -#ifdef USE_HP_INC_HDR -#include "../binutils/hp-include/a.out.h" -#else - -#ifdef USE_SYSTEM_HDR -#include "/usr/include/a.out.h" -#else - -#ifdef USE_HP_HDR -/* The `exec' structure and overall layout must be close to HP's when - we are running on an HP system, otherwise we will not be able to - execute the resulting file. */ - -struct exec -{ - unsigned short a_machtype; /* machine type */ - unsigned short a_magic; /* magic number */ - unsigned long a_spare1; - unsigned long a_spare2; - unsigned long a_text; /* length of text, in bytes */ - unsigned long a_data; /* length of data, in bytes */ - unsigned long a_bss; /* length of uninitialized data area for file, in bytes */ - unsigned long a_trsize; /* length of relocation info for text, in bytes */ - unsigned long a_drsize; /* length of relocation info for data, in bytes */ - unsigned long a_spare3; /* HP = pascal interface size */ - unsigned long a_spare4; /* HP = symbol table size */ - unsigned long a_spare5; /* HP = debug name table size */ - unsigned long a_entry; /* start address */ - unsigned long a_spare6; /* HP = source line table size */ - unsigned long a_spare7; /* HP = value table size */ - unsigned long a_syms; /* length of symbol table data in file, in bytes */ - unsigned long a_spare8; -}; - -#define N_MAGIC(exec) ((exec) . a_magic) -#define N_MACHTYPE(exec) ((exec) . a_machtype) -#define N_SET_MAGIC(exec, magic) (((exec) . a_magic) = (magic)) -#define N_SET_MACHTYPE(exec, machtype) (((exec) . a_machtype) = (machtype)) - -#define N_BADMAG(x) ((_N_BADMAG (x)) || (_N_BADMACH (x))) - -#define _N_BADMACH(x) \ -(((N_MACHTYPE (x)) != HP9000S200_ID) && \ - ((N_MACHTYPE (x)) != HP98x6_ID)) - -#define _N_BADMAG(x) \ - (((x).a_magic)!=OMAGIC && ((x).a_magic)!=NMAGIC && ((x).a_magic)!=ZMAGIC) - -#define HP98x6_ID 0x20A -#define HP9000S200_ID 0x20C - -#else - - /* A Generic machine. . . */ - -/* JF I'm not sure where this file came from. I put the permit.text message in - it anyway. This file came to me as part of the original VAX assembler, but had - no copyright notices in it. */ - -struct exec { - long a_magic; /* number identifies as .o file and gives type of such. */ - unsigned a_text; /* length of text, in bytes */ - unsigned a_data; /* length of data, in bytes */ - unsigned a_bss; /* length of uninitialized data area for file, in bytes */ - unsigned a_syms; /* length of symbol table data in file, in bytes */ - unsigned a_entry; /* start address */ - unsigned a_trsize; /* length of relocation info for text, in bytes */ - unsigned a_drsize; /* length of relocation info for data, in bytes */ -}; - -#define N_BADMAG(x) \ - (((x).a_magic)!=OMAGIC && ((x).a_magic)!=NMAGIC && ((x).a_magic)!=ZMAGIC) - -#endif - - /* From here down is common to both the HP and the generic machine */ -#define OMAGIC 0407 -#define NMAGIC 0410 -#define ZMAGIC 0413 - - -#define N_TXTOFF(x) \ - ((x).a_magic == ZMAGIC ? 1024 : sizeof(struct exec)) - -#define N_SYMOFF(x) \ - (N_TXTOFF(x) + (x).a_text + (x).a_data + (x).a_trsize + (x).a_drsize) - -#define N_STROFF(x) \ - (N_SYMOFF(x) + (x).a_syms) - -struct nlist { - union { - char *n_name; - struct nlist *n_next; - long n_strx; - } n_un; - char n_type; - char n_other; - short n_desc; - unsigned n_value; -}; - -#define N_UNDF 0 -#define N_ABS 2 -#define N_TEXT 4 -#define N_DATA 6 -#define N_BSS 8 -#define N_FN 31 /* JF: Someone claims this should be 31 instead of - 15. I just inherited this file; I didn't write - it. Who is right? */ - - -#define N_EXT 1 -#define N_TYPE 036 -#define N_STAB 0340 - -struct relocation_info { - int r_address; - unsigned r_symbolnum:24, - r_pcrel:1, - r_length:2, - r_extern:1, - r_bsr:1, /* OVE: used on ns32k based systems, if you want */ - r_disp:1, /* OVE: used on ns32k based systems, if you want */ - nuthin:2; -}; - -#endif -#endif diff --git a/gas/config/atof-ieee.c b/gas/config/atof-ieee.c deleted file mode 100644 index 323d4e123bd..00000000000 --- a/gas/config/atof-ieee.c +++ /dev/null @@ -1,511 +0,0 @@ -/* atof_ieee.c - turn a Flonum into an IEEE floating point number - Copyright (C) 1987 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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 1, or (at your option) -any later version. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include "as.h" - -#ifdef USG -#define bzero(s,n) memset(s,0,n) -#define bcopy(from,to,n) memcpy((to),(from),(n)) -#endif - -extern FLONUM_TYPE generic_floating_point_number; /* Flonums returned here. */ - -#ifndef NULL -#define NULL (0) -#endif - -extern char EXP_CHARS[]; - /* Precision in LittleNums. */ -#define MAX_PRECISION (6) -#define F_PRECISION (2) -#define D_PRECISION (4) -#define X_PRECISION (6) -#define P_PRECISION (6) - - /* Length in LittleNums of guard bits. */ -#define GUARD (2) - -static unsigned long mask [] = { - 0x00000000, - 0x00000001, - 0x00000003, - 0x00000007, - 0x0000000f, - 0x0000001f, - 0x0000003f, - 0x0000007f, - 0x000000ff, - 0x000001ff, - 0x000003ff, - 0x000007ff, - 0x00000fff, - 0x00001fff, - 0x00003fff, - 0x00007fff, - 0x0000ffff, - 0x0001ffff, - 0x0003ffff, - 0x0007ffff, - 0x000fffff, - 0x001fffff, - 0x003fffff, - 0x007fffff, - 0x00ffffff, - 0x01ffffff, - 0x03ffffff, - 0x07ffffff, - 0x0fffffff, - 0x1fffffff, - 0x3fffffff, - 0x7fffffff, - 0xffffffff - }; - - -static int bits_left_in_littlenum; -static int littlenums_left; -static LITTLENUM_TYPE *littlenum_pointer; - -static int -next_bits (number_of_bits) - int number_of_bits; -{ - int return_value; - - if(!littlenums_left) - return 0; - if (number_of_bits >= bits_left_in_littlenum) - { - return_value = mask [bits_left_in_littlenum] & *littlenum_pointer; - number_of_bits -= bits_left_in_littlenum; - return_value <<= number_of_bits; - if(--littlenums_left) { - bits_left_in_littlenum = LITTLENUM_NUMBER_OF_BITS - number_of_bits; - littlenum_pointer --; - return_value |= (*littlenum_pointer>>bits_left_in_littlenum) & mask[number_of_bits]; - } - } - else - { - bits_left_in_littlenum -= number_of_bits; - return_value = mask [number_of_bits] & (*littlenum_pointer>>bits_left_in_littlenum); - } - return (return_value); -} - -/* Num had better be less than LITTLENUM_NUMBER_OF_BITS */ -static void -unget_bits(num) -int num; -{ - if(!littlenums_left) { - ++littlenum_pointer; - ++littlenums_left; - bits_left_in_littlenum=num; - } else if(bits_left_in_littlenum+num>LITTLENUM_NUMBER_OF_BITS) { - bits_left_in_littlenum= num-(LITTLENUM_NUMBER_OF_BITS-bits_left_in_littlenum); - ++littlenum_pointer; - ++littlenums_left; - } else - bits_left_in_littlenum+=num; -} - -static void -make_invalid_floating_point_number (words) - LITTLENUM_TYPE * words; -{ - as_bad("cannot create floating-point number"); - words[0]= ((unsigned)-1)>>1; /* Zero the leftmost bit */ - words[1]= -1; - words[2]= -1; - words[3]= -1; - words[4]= -1; - words[5]= -1; -} - -/***********************************************************************\ -* Warning: this returns 16-bit LITTLENUMs. It is up to the caller * -* to figure out any alignment problems and to conspire for the * -* bytes/word to be emitted in the right order. Bigendians beware! * -* * -\***********************************************************************/ - -/* Note that atof-ieee always has X and P precisions enabled. it is up - to md_atof to filter them out if the target machine does not support - them. */ - -char * /* Return pointer past text consumed. */ -atof_ieee (str, what_kind, words) - char * str; /* Text to convert to binary. */ - char what_kind; /* 'd', 'f', 'g', 'h' */ - LITTLENUM_TYPE * words; /* Build the binary here. */ -{ - static LITTLENUM_TYPE bits [MAX_PRECISION + MAX_PRECISION + GUARD]; - /* Extra bits for zeroed low-order bits. */ - /* The 1st MAX_PRECISION are zeroed, */ - /* the last contain flonum bits. */ - char * return_value; - int precision; /* Number of 16-bit words in the format. */ - long exponent_bits; - - return_value = str; - generic_floating_point_number.low = bits + MAX_PRECISION; - generic_floating_point_number.high = NULL; - generic_floating_point_number.leader = NULL; - generic_floating_point_number.exponent = NULL; - generic_floating_point_number.sign = '\0'; - - /* Use more LittleNums than seems */ - /* necessary: the highest flonum may have */ - /* 15 leading 0 bits, so could be useless. */ - - bzero (bits, sizeof(LITTLENUM_TYPE) * MAX_PRECISION); - - switch(what_kind) { - case 'f': - case 'F': - case 's': - case 'S': - precision = F_PRECISION; - exponent_bits = 8; - break; - - case 'd': - case 'D': - case 'r': - case 'R': - precision = D_PRECISION; - exponent_bits = 11; - break; - - case 'x': - case 'X': - case 'e': - case 'E': - precision = X_PRECISION; - exponent_bits = 15; - break; - - case 'p': - case 'P': - - precision = P_PRECISION; - exponent_bits= -1; - break; - - default: - make_invalid_floating_point_number (words); - return NULL; - } - - generic_floating_point_number.high = generic_floating_point_number.low + precision - 1 + GUARD; - - if (atof_generic (& return_value, ".", EXP_CHARS, & generic_floating_point_number)) { - /* as_bad("Error converting floating point number (Exponent overflow?)"); */ - make_invalid_floating_point_number (words); - return NULL; - } - gen_to_words(words, precision, exponent_bits); - return return_value; -} - -/* Turn generic_floating_point_number into a real float/double/extended */ -int gen_to_words(words, precision, exponent_bits) -LITTLENUM_TYPE *words; -int precision; -long exponent_bits; -{ - int return_value=0; - - long exponent_1; - long exponent_2; - long exponent_3; - long exponent_4; - int exponent_skippage; - LITTLENUM_TYPE word1; - LITTLENUM_TYPE * lp; - - if (generic_floating_point_number.low > generic_floating_point_number.leader) { - /* 0.0e0 seen. */ - if(generic_floating_point_number.sign=='+') - words[0]=0x0000; - else - words[0]=0x8000; - bzero (&words[1], sizeof(LITTLENUM_TYPE) * (precision-1)); - return return_value; - } - - /* NaN: Do the right thing */ - if(generic_floating_point_number.sign==0) { - if(precision==F_PRECISION) { - words[0]=0x7fff; - words[1]=0xffff; - } else { - words[0]=0x7fff; - words[1]=0xffff; - words[2]=0xffff; - words[3]=0xffff; - } - return return_value; - } else if(generic_floating_point_number.sign=='P') { - /* +INF: Do the right thing */ - if(precision==F_PRECISION) { - words[0]=0x7f80; - words[1]=0; - } else { - words[0]=0x7ff0; - words[1]=0; - words[2]=0; - words[3]=0; - } - return return_value; - } else if(generic_floating_point_number.sign=='N') { - /* Negative INF */ - if(precision==F_PRECISION) { - words[0]=0xff80; - words[1]=0x0; - } else { - words[0]=0xfff0; - words[1]=0x0; - words[2]=0x0; - words[3]=0x0; - } - return return_value; - } - /* - * The floating point formats we support have: - * Bit 15 is sign bit. - * Bits 14:n are excess-whatever exponent. - * Bits n-1:0 (if any) are most significant bits of fraction. - * Bits 15:0 of the next word(s) are the next most significant bits. - * - * So we need: number of bits of exponent, number of bits of - * mantissa. - */ - bits_left_in_littlenum = LITTLENUM_NUMBER_OF_BITS; - littlenum_pointer = generic_floating_point_number.leader; - littlenums_left = 1+generic_floating_point_number.leader - generic_floating_point_number.low; - /* Seek (and forget) 1st significant bit */ - for (exponent_skippage = 0;! next_bits(1); exponent_skippage ++) - ; - exponent_1 = generic_floating_point_number.exponent + generic_floating_point_number.leader + 1 - - generic_floating_point_number.low; - /* Radix LITTLENUM_RADIX, point just higher than generic_floating_point_number.leader. */ - exponent_2 = exponent_1 * LITTLENUM_NUMBER_OF_BITS; - /* Radix 2. */ - exponent_3 = exponent_2 - exponent_skippage; - /* Forget leading zeros, forget 1st bit. */ - exponent_4 = exponent_3 + ((1 << (exponent_bits - 1)) - 2); - /* Offset exponent. */ - - lp = words; - - /* Word 1. Sign, exponent and perhaps high bits. */ - word1 = (generic_floating_point_number.sign == '+') ? 0 : (1<<(LITTLENUM_NUMBER_OF_BITS-1)); - - /* Assume 2's complement integers. */ - if(exponent_4<1 && exponent_4>=-62) { - int prec_bits; - int num_bits; - - unget_bits(1); - num_bits= -exponent_4; - prec_bits=LITTLENUM_NUMBER_OF_BITS*precision-(exponent_bits+1+num_bits); - if(precision==X_PRECISION && exponent_bits==15) - prec_bits-=LITTLENUM_NUMBER_OF_BITS+1; - - if(num_bits>=LITTLENUM_NUMBER_OF_BITS-exponent_bits) { - /* Bigger than one littlenum */ - num_bits-=(LITTLENUM_NUMBER_OF_BITS-1)-exponent_bits; - *lp++=word1; - if(num_bits+exponent_bits+1>=precision*LITTLENUM_NUMBER_OF_BITS) { - /* Exponent overflow */ - make_invalid_floating_point_number(words); - return return_value; - } - if(precision==X_PRECISION && exponent_bits==15) { - *lp++=0; - *lp++=0; - num_bits-=LITTLENUM_NUMBER_OF_BITS-1; - } - while(num_bits>=LITTLENUM_NUMBER_OF_BITS) { - num_bits-=LITTLENUM_NUMBER_OF_BITS; - *lp++=0; - } - if(num_bits) - *lp++=next_bits(LITTLENUM_NUMBER_OF_BITS-(num_bits)); - } else { - if(precision==X_PRECISION && exponent_bits==15) { - *lp++=word1; - *lp++=0; - if(num_bits==LITTLENUM_NUMBER_OF_BITS) { - *lp++=0; - *lp++=next_bits(LITTLENUM_NUMBER_OF_BITS-1); - } else if(num_bits==LITTLENUM_NUMBER_OF_BITS-1) - *lp++=0; - else - *lp++=next_bits(LITTLENUM_NUMBER_OF_BITS-1-num_bits); - num_bits=0; - } else { - word1|= next_bits ((LITTLENUM_NUMBER_OF_BITS-1) - (exponent_bits+num_bits)); - *lp++=word1; - } - } - while(lpLITTLENUM_NUMBER_OF_BITS) { - int n = 0; - int tmp_bits; - - n=0; - tmp_bits=prec_bits; - while(tmp_bits>LITTLENUM_NUMBER_OF_BITS) { - if(lp[n]!=(LITTLENUM_TYPE)-1) - break; - --n; - tmp_bits-=LITTLENUM_NUMBER_OF_BITS; - } - if(tmp_bits>LITTLENUM_NUMBER_OF_BITS || (lp[n]&mask[tmp_bits])!=mask[tmp_bits]) { - unsigned long carry; - - for (carry = 1; carry && (lp >= words); lp --) { - carry = * lp + carry; - * lp = carry; - carry >>= LITTLENUM_NUMBER_OF_BITS; - } - } - } else if((*lp&mask[prec_bits])!=mask[prec_bits]) - lp++; - } - - return return_value; - } else if (exponent_4 & ~ mask [exponent_bits]) { - /* - * Exponent overflow. Lose immediately. - */ - - /* - * We leave return_value alone: admit we read the - * number, but return a floating exception - * because we can't encode the number. - */ - make_invalid_floating_point_number (words); - return return_value; - } else { - word1 |= (exponent_4 << ((LITTLENUM_NUMBER_OF_BITS-1) - exponent_bits)) - | next_bits ((LITTLENUM_NUMBER_OF_BITS-1) - exponent_bits); - } - - * lp ++ = word1; - - /* X_PRECISION is special: it has 16 bits of zero in the middle, - followed by a 1 bit. */ - if(exponent_bits==15 && precision==X_PRECISION) { - *lp++=0; - *lp++= 1<<(LITTLENUM_NUMBER_OF_BITS)|next_bits(LITTLENUM_NUMBER_OF_BITS-1); - } - - /* The rest of the words are just mantissa bits. */ - while(lp < words + precision) - *lp++ = next_bits (LITTLENUM_NUMBER_OF_BITS); - - if (next_bits (1)) { - unsigned long carry; - /* - * Since the NEXT bit is a 1, round UP the mantissa. - * The cunning design of these hidden-1 floats permits - * us to let the mantissa overflow into the exponent, and - * it 'does the right thing'. However, we lose if the - * highest-order bit of the lowest-order word flips. - * Is that clear? - */ - - -/* #if (sizeof(carry)) < ((sizeof(bits[0]) * BITS_PER_CHAR) + 2) - Please allow at least 1 more bit in carry than is in a LITTLENUM. - We need that extra bit to hold a carry during a LITTLENUM carry - propagation. Another extra bit (kept 0) will assure us that we - don't get a sticky sign bit after shifting right, and that - permits us to propagate the carry without any masking of bits. -#endif */ - for (carry = 1, lp --; carry && (lp >= words); lp --) { - carry = * lp + carry; - * lp = carry; - carry >>= LITTLENUM_NUMBER_OF_BITS; - } - if ( (word1 ^ *words) & (1 << (LITTLENUM_NUMBER_OF_BITS - 1)) ) { - /* We leave return_value alone: admit we read the - * number, but return a floating exception - * because we can't encode the number. - */ - *words&= ~ (1 << (LITTLENUM_NUMBER_OF_BITS - 1)); - /* make_invalid_floating_point_number (words); */ - /* return return_value; */ - } - } - return (return_value); -} - -/* This routine is a real kludge. Someone really should do it better, but - I'm too lazy, and I don't understand this stuff all too well anyway - (JF) - */ -void -int_to_gen(x) -long x; -{ - char buf[20]; - char *bufp; - - sprintf(buf,"%ld",x); - bufp= &buf[0]; - if(atof_generic(&bufp,".", EXP_CHARS, &generic_floating_point_number)) - as_bad("Error converting number to floating point (Exponent overflow?)"); -} - -#ifdef TEST -char * -print_gen(gen) -FLONUM_TYPE *gen; -{ - FLONUM_TYPE f; - LITTLENUM_TYPE arr[10]; - double dv; - float fv; - static char sbuf[40]; - - if(gen) { - f=generic_floating_point_number; - generic_floating_point_number= *gen; - } - gen_to_words(&arr[0],4,11); - bcopy(&arr[0],&dv,sizeof(double)); - sprintf(sbuf,"%x %x %x %x %.14G ",arr[0],arr[1],arr[2],arr[3],dv); - gen_to_words(&arr[0],2,8); - bcopy(&arr[0],&fv,sizeof(float)); - sprintf(sbuf+strlen(sbuf),"%x %x %.12g\n",arr[0],arr[1],fv); - if(gen) - generic_floating_point_number=f; - return sbuf; -} -#endif diff --git a/gas/config/atof-vax.c b/gas/config/atof-vax.c deleted file mode 100644 index 43c81d69d57..00000000000 --- a/gas/config/atof-vax.c +++ /dev/null @@ -1,509 +0,0 @@ -/* atof_vax.c - turn a Flonum into a VAX floating point number - Copyright (C) 1987 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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 1, or (at your option) -any later version. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - - /* JF added these two for md_atof() */ -#include "as.h" - -#include "flonum.h" - - - /* Precision in LittleNums. */ -#define MAX_PRECISION (8) -#define H_PRECISION (8) -#define G_PRECISION (4) -#define D_PRECISION (4) -#define F_PRECISION (2) - - /* Length in LittleNums of guard bits. */ -#define GUARD (2) - -int /* Number of chars in flonum type 'letter'. */ -atof_vax_sizeof (letter) - char letter; -{ - int return_value; - - /* - * Permitting uppercase letters is probably a bad idea. - * Please use only lower-cased letters in case the upper-cased - * ones become unsupported! - */ - switch (letter) - { - case 'f': - case 'F': - return_value = 4; - break; - - case 'd': - case 'D': - case 'g': - case 'G': - return_value = 8; - break; - - case 'h': - case 'H': - return_value = 16; - break; - - default: - return_value = 0; - break; - } - return (return_value); -} /* atof_vax_sizeof */ - -static const long mask [] = { - 0x00000000, - 0x00000001, - 0x00000003, - 0x00000007, - 0x0000000f, - 0x0000001f, - 0x0000003f, - 0x0000007f, - 0x000000ff, - 0x000001ff, - 0x000003ff, - 0x000007ff, - 0x00000fff, - 0x00001fff, - 0x00003fff, - 0x00007fff, - 0x0000ffff, - 0x0001ffff, - 0x0003ffff, - 0x0007ffff, - 0x000fffff, - 0x001fffff, - 0x003fffff, - 0x007fffff, - 0x00ffffff, - 0x01ffffff, - 0x03ffffff, - 0x07ffffff, - 0x0fffffff, - 0x1fffffff, - 0x3fffffff, - 0x7fffffff, - 0xffffffff - }; - - -/* Shared between flonum_gen2vax and next_bits */ -static int bits_left_in_littlenum; -static LITTLENUM_TYPE * littlenum_pointer; -static LITTLENUM_TYPE * littlenum_end; - -static int -next_bits (number_of_bits) - int number_of_bits; -{ - int return_value; - - if(littlenum_pointer= bits_left_in_littlenum) - { - return_value = mask [bits_left_in_littlenum] & * littlenum_pointer; - number_of_bits -= bits_left_in_littlenum; - return_value <<= number_of_bits; - bits_left_in_littlenum = LITTLENUM_NUMBER_OF_BITS - number_of_bits; - littlenum_pointer --; - if(littlenum_pointer>=littlenum_end) - return_value |= ( (* littlenum_pointer) >> (bits_left_in_littlenum) ) & mask [number_of_bits]; - } - else - { - bits_left_in_littlenum -= number_of_bits; - return_value = mask [number_of_bits] & ( (* littlenum_pointer) >> bits_left_in_littlenum); - } - return (return_value); -} - -static void -make_invalid_floating_point_number (words) - LITTLENUM_TYPE * words; -{ - * words = 0x8000; /* Floating Reserved Operand Code */ -} - -static int /* 0 means letter is OK. */ -what_kind_of_float (letter, precisionP, exponent_bitsP) - char letter; /* In: lowercase please. What kind of float? */ - int * precisionP; /* Number of 16-bit words in the float. */ - long * exponent_bitsP; /* Number of exponent bits. */ -{ - int retval; /* 0: OK. */ - - retval = 0; - switch (letter) - { - case 'f': - * precisionP = F_PRECISION; - * exponent_bitsP = 8; - break; - - case 'd': - * precisionP = D_PRECISION; - * exponent_bitsP = 8; - break; - - case 'g': - * precisionP = G_PRECISION; - * exponent_bitsP = 11; - break; - - case 'h': - * precisionP = H_PRECISION; - * exponent_bitsP = 15; - break; - - default: - retval = 69; - break; - } - return (retval); -} - -/***********************************************************************\ -* * -* Warning: this returns 16-bit LITTLENUMs, because that is * -* what the VAX thinks in. It is up to the caller to figure * -* out any alignment problems and to conspire for the bytes/word * -* to be emitted in the right order. Bigendians beware! * -* * -\***********************************************************************/ - -char * /* Return pointer past text consumed. */ -atof_vax (str, what_kind, words) - char * str; /* Text to convert to binary. */ - char what_kind; /* 'd', 'f', 'g', 'h' */ - LITTLENUM_TYPE * words; /* Build the binary here. */ -{ - FLONUM_TYPE f; - LITTLENUM_TYPE bits [MAX_PRECISION + MAX_PRECISION + GUARD]; - /* Extra bits for zeroed low-order bits. */ - /* The 1st MAX_PRECISION are zeroed, */ - /* the last contain flonum bits. */ - char * return_value; - int precision; /* Number of 16-bit words in the format. */ - long exponent_bits; - - return_value = str; - f . low = bits + MAX_PRECISION; - f . high = NULL; - f . leader = NULL; - f . exponent = NULL; - f . sign = '\0'; - - if (what_kind_of_float (what_kind, & precision, & exponent_bits)) - { - return_value = NULL; /* We lost. */ - make_invalid_floating_point_number (words); - } - if (return_value) - { - bzero (bits, sizeof(LITTLENUM_TYPE) * MAX_PRECISION); - - /* Use more LittleNums than seems */ - /* necessary: the highest flonum may have */ - /* 15 leading 0 bits, so could be useless. */ - f . high = f . low + precision - 1 + GUARD; - - if (atof_generic (& return_value, ".", "eE", & f)) - { - make_invalid_floating_point_number (words); - return_value = NULL; /* we lost */ - } - else - { - if (flonum_gen2vax (what_kind, & f, words)) - { - return_value = NULL; - } - } - } - return (return_value); -} - -/* - * In: a flonum, a vax floating point format. - * Out: a vax floating-point bit pattern. - */ - -int /* 0: OK. */ -flonum_gen2vax (format_letter, f, words) - char format_letter; /* One of 'd' 'f' 'g' 'h'. */ - FLONUM_TYPE * f; - LITTLENUM_TYPE * words; /* Deliver answer here. */ -{ - LITTLENUM_TYPE * lp; - int precision; - long exponent_bits; - int return_value; /* 0 == OK. */ - - return_value = what_kind_of_float (format_letter, & precision, & exponent_bits); - if (return_value != 0) - { - make_invalid_floating_point_number (words); - } - else - { - if (f -> low > f -> leader) - { - /* 0.0e0 seen. */ - bzero (words, sizeof(LITTLENUM_TYPE) * precision); - } - else - { - long exponent_1; - long exponent_2; - long exponent_3; - long exponent_4; - int exponent_skippage; - LITTLENUM_TYPE word1; - - /* JF: Deal with new Nan, +Inf and -Inf codes */ - if(f->sign!='-' && f->sign!='+') { - make_invalid_floating_point_number(words); - return return_value; - } - /* - * All vaxen floating_point formats (so far) have: - * Bit 15 is sign bit. - * Bits 14:n are excess-whatever exponent. - * Bits n-1:0 (if any) are most significant bits of fraction. - * Bits 15:0 of the next word are the next most significant bits. - * And so on for each other word. - * - * All this to be compatible with a KF11?? (Which is still faster - * than lots of vaxen I can think of, but it also has higher - * maintenance costs ... sigh). - * - * So we need: number of bits of exponent, number of bits of - * mantissa. - */ - -#ifdef NEVER /******* This zeroing seems redundant - Dean 3may86 **********/ - /* - * No matter how few bits we got back from the atof() - * routine, add enough zero littlenums so the rest of the - * code won't run out of "significant" bits in the mantissa. - */ - { - LITTLENUM_TYPE * ltp; - for (ltp = f -> leader + 1; - ltp <= f -> low + precision; - ltp ++) - { - * ltp = 0; - } - } -#endif - - bits_left_in_littlenum = LITTLENUM_NUMBER_OF_BITS; - littlenum_pointer = f -> leader; - littlenum_end = f->low; - /* Seek (and forget) 1st significant bit */ - for (exponent_skippage = 0; - ! next_bits(1); - exponent_skippage ++) - { - } - exponent_1 = f -> exponent + f -> leader + 1 - f -> low; - /* Radix LITTLENUM_RADIX, point just higher than f -> leader. */ - exponent_2 = exponent_1 * LITTLENUM_NUMBER_OF_BITS; - /* Radix 2. */ - exponent_3 = exponent_2 - exponent_skippage; - /* Forget leading zeros, forget 1st bit. */ - exponent_4 = exponent_3 + (1 << (exponent_bits - 1)); - /* Offset exponent. */ - - if (exponent_4 & ~ mask [exponent_bits]) - { - /* - * Exponent overflow. Lose immediately. - */ - - make_invalid_floating_point_number (words); - - /* - * We leave return_value alone: admit we read the - * number, but return a floating exception - * because we can't encode the number. - */ - } - else - { - lp = words; - - /* Word 1. Sign, exponent and perhaps high bits. */ - /* Assume 2's complement integers. */ - word1 = ((exponent_4 & mask [exponent_bits]) << (15 - exponent_bits)) - | ((f -> sign == '+') ? 0 : 0x8000) - | next_bits (15 - exponent_bits); - * lp ++ = word1; - - /* The rest of the words are just mantissa bits. */ - for (; lp < words + precision; lp++) - { - * lp = next_bits (LITTLENUM_NUMBER_OF_BITS); - } - - if (next_bits (1)) - { - /* - * Since the NEXT bit is a 1, round UP the mantissa. - * The cunning design of these hidden-1 floats permits - * us to let the mantissa overflow into the exponent, and - * it 'does the right thing'. However, we lose if the - * highest-order bit of the lowest-order word flips. - * Is that clear? - */ - - unsigned long carry; - - /* - #if (sizeof(carry)) < ((sizeof(bits[0]) * BITS_PER_CHAR) + 2) - Please allow at least 1 more bit in carry than is in a LITTLENUM. - We need that extra bit to hold a carry during a LITTLENUM carry - propagation. Another extra bit (kept 0) will assure us that we - don't get a sticky sign bit after shifting right, and that - permits us to propagate the carry without any masking of bits. - #endif - */ - for (carry = 1, lp --; - carry && (lp >= words); - lp --) - { - carry = * lp + carry; - * lp = carry; - carry >>= LITTLENUM_NUMBER_OF_BITS; - } - - if ( (word1 ^ *words) & (1 << (LITTLENUM_NUMBER_OF_BITS - 1)) ) - { - make_invalid_floating_point_number (words); - /* - * We leave return_value alone: admit we read the - * number, but return a floating exception - * because we can't encode the number. - */ - } - } /* if (we needed to round up) */ - } /* if (exponent overflow) */ - } /* if (0.0e0) */ - } /* if (float_type was OK) */ - return (return_value); -} - - -/* JF this used to be in vax.c but this looks like a better place for it */ - -/* - * md_atof() - * - * In: input_line_pointer -> the 1st character of a floating-point - * number. - * 1 letter denoting the type of statement that wants a - * binary floating point number returned. - * Address of where to build floating point literal. - * Assumed to be 'big enough'. - * Address of where to return size of literal (in chars). - * - * Out: Input_line_pointer -> of next char after floating number. - * Error message, or "". - * Floating point literal. - * Number of chars we used for the literal. - */ - -#define MAXIMUM_NUMBER_OF_LITTLENUMS (8) /* For .hfloats. */ - -char * -md_atof (what_statement_type, literalP, sizeP) - char what_statement_type; - char * literalP; - int * sizeP; -{ - LITTLENUM_TYPE words [MAXIMUM_NUMBER_OF_LITTLENUMS]; - register char kind_of_float; - register int number_of_chars; - register LITTLENUM_TYPE * littlenum_pointer; - - switch (what_statement_type) - { - case 'F': /* .float */ - case 'f': /* .ffloat */ - kind_of_float = 'f'; - break; - - case 'D': /* .double */ - case 'd': /* .dfloat */ - kind_of_float = 'd'; - break; - - case 'g': /* .gfloat */ - kind_of_float = 'g'; - break; - - case 'h': /* .hfloat */ - kind_of_float = 'h'; - break; - - default: - kind_of_float = 0; - break; - }; - - if (kind_of_float) - { - register LITTLENUM_TYPE * limit; - - input_line_pointer = atof_vax (input_line_pointer, - kind_of_float, - words); - /* - * The atof_vax() builds up 16-bit numbers. - * Since the assembler may not be running on - * a little-endian machine, be very careful about - * converting words to chars. - */ - number_of_chars = atof_vax_sizeof (kind_of_float); - know( number_of_chars <= MAXIMUM_NUMBER_OF_LITTLENUMS * sizeof(LITTLENUM_TYPE) ); - limit = words + (number_of_chars / sizeof(LITTLENUM_TYPE)); - for (littlenum_pointer = words; - littlenum_pointer < limit; - littlenum_pointer ++) - { - md_number_to_chars (literalP, * littlenum_pointer, sizeof(LITTLENUM_TYPE)); - literalP += sizeof(LITTLENUM_TYPE); - }; - } - else - { - number_of_chars = 0; - }; - - * sizeP = number_of_chars; - return (kind_of_float ? "" : "Bad call to md_atof()"); -} /* md_atof() */ - -/* atof_vax.c */ diff --git a/gas/config/coff.gnu.h b/gas/config/coff.gnu.h deleted file mode 100755 index 281ac17c425..00000000000 --- a/gas/config/coff.gnu.h +++ /dev/null @@ -1,568 +0,0 @@ -/*** coff information for 80960. Origins: Intel, AMD, etc., natch. */ - -/* - * At this point I'm sure this file is right for i960 and I'm pretty sure it's - * right for a29k, although it hasn't been tested rigorously. Please feel free - * to add your own machine's description here. Without that info, it isn't - * possible to build cross development tools from elsewhere nor is it easy to - * continue to support your machines format. - * - * The TC_foo ifdef's are mine. They are what gas uses. The other ifdef's - * remain for documentation from other scavenged files. xoxorich. - */ - -/* $Id$ */ - -/********************** FILE HEADER **********************/ - -struct filehdr { - unsigned short f_magic; /* magic number */ - unsigned short f_nscns; /* number of sections */ - long f_timdat; /* time & date stamp */ - long f_symptr; /* file pointer to symtab */ - long f_nsyms; /* number of symtab entries */ - unsigned short f_opthdr; /* sizeof(optional hdr) */ - unsigned short f_flags; /* flags */ -}; - -/* Bits for f_flags: - * F_RELFLG relocation info stripped from file - * F_EXEC file is executable (no unresolved externel references) - * F_LNNO line nunbers stripped from file - * F_LSYMS local symbols stripped from file - * F_AR32WR file has byte ordering of an AR32WR machine (e.g. vax) - */ -#define F_RELFLG (0x0001) -#define F_EXEC (0x0002) -#define F_LNNO (0x0004) -#define F_LSYMS (0x0008) - -#ifdef TC_I960 -#define F_AR32WR (0x0010) /* File has 32 bits per word, least - significant byte first. */ -#else /* TC_I960 */ -#define F_AR32WR (0x0100) -#endif /* TC_I960 */ - -#define F_MINMAL (0x0010) /* ??? */ -#define F_UPDATE (0x0020) /* ??? */ -#define F_SWABD (0x0040) /* ??? */ -#define F_AR16WR (0x0080) /* File has the byte ordering used by - the PDP*-11/70 processor. */ -#define F_AR32W (0x0200) /* File has 32 bits per word, most - significant byte first. */ - -/* - * Intel 80960 (I960) processor flags. - * F_I960TYPE == mask for processor type field. - */ - -#define F_I960TYPE (0xf000) -#define F_I960CORE (0x1000) -#define F_I960KB (0x2000) -#define F_I960SB (0x2000) -#define F_I960MC (0x3000) -#define F_I960XA (0x4000) -#define F_I960CA (0x5000) -#define F_I960KA (0x6000) -#define F_I960SA (0x6000) - -/* - * i80960 Magic Numbers - */ - -#define I960ROMAGIC (0x160) /* read-only text segments */ -#define I960RWMAGIC (0x161) /* read-write text segments */ - -#define I960BADMAG(x) (((x).f_magic != I960ROMAGIC) && ((x).f_magic != I960RWMAGIC)) - -#define SIPFBOMAGIC (0x17a) /* Am29000 (Byte 0 is MSB - Big Endian) */ -#define SIPRBOMAGIC (0x17b) /* Am29000 (Byte 0 is LSB - Little Endian) */ - -#define A29KBADMAG(x) (((x).f_magic != SIPFBOMAGIC) && ((x).f_magic != SIPRBOMAGIC)) - -#define FILHDR struct filehdr -#define FILHSZ sizeof(FILHDR) - - -/********************** AOUT "OPTIONAL HEADER" **********************/ - -typedef struct { - unsigned long phys_addr; - unsigned long bitarray; -} TAGBITS; - -/* These appear to be used only by exec(2). I don't know who cares - about them in a cross development environment. In any case, this - is my collection after researching the issue for a few hours. - Apparently, most have these have remained essentially unchanged - since v7 days, although a few new ones have been added. xoxorich. */ - -#define BAD0MAGIC (0401) /* (?) "lpd (UNIX/RT)" */ -#define BAD1MAGIC (0405) /* (?) overlay */ -#define OMAGIC (0407) /* old impure format. data immediately - follows text. both sections are rw. */ -#define NMAGIC (0410) /* split i&d, read-only text */ -#define A_MAGIC3 (0411) /* (?) "separated I&D" */ -#define ZMAGIC (0413) /* like NMAGIC, but demand loaded */ -#define PAGEMAGIC2 (0414) /* (?) like ZMAGIC, but address zero - explicitly unmapped. */ -#define REGMAGIC (0414) /* (?) a PAGEMAGIC2 alias? */ -#define PAGEMAGIC3 (0415) /* (?) like ZMAGIC, but address zero mapped. */ -#define A_MAGIC5 (0437) /* (?) "system overlay, separated I&D" */ - /* intended for non-unix cross development */ -#define SASMAGIC (010000) /* Single Address Space */ -#define MASMAGIC (020000) /* (?) "Multiple (separate I & D) Address Spaces" */ - -typedef struct aouthdr { - short magic; /* type of file */ - short vstamp; /* version stamp */ - unsigned long tsize; /* text size in bytes, padded to FW bdry*/ - unsigned long dsize; /* initialized data " " */ - unsigned long bsize; /* uninitialized data " " */ -#if U3B - unsigned long dum1; - unsigned long dum2; /* pad to entry point */ -#endif - unsigned long entry; /* entry pt. */ - unsigned long text_start; /* base of text used for this file */ - unsigned long data_start; /* base of data used for this file */ - /* CAREFUL: some formats omit the tagentries member. */ - unsigned long tagentries; /* number of tag entries to - follow (always zero for i960) */ -} AOUTHDR; - -/* return a pointer to the tag bits array */ - -#define TAGPTR(aout) ((TAGBITS *) (&(aout.tagentries)+1)) - -/* compute size of a header */ - -/*#define AOUTSZ(aout) (sizeof(AOUTHDR)+(aout.tagentries*sizeof(TAGBITS)))*/ -#define AOUTSZ (sizeof(AOUTHDR)) - - -/********************** STORAGE CLASSES **********************/ - -#define C_EFCN -1 /* physical end of function */ -#define C_NULL 0 -#define C_AUTO 1 /* automatic variable */ -#define C_EXT 2 /* external symbol */ -#define C_STAT 3 /* static */ -#define C_REG 4 /* register variable */ -#define C_EXTDEF 5 /* external definition */ -#define C_LABEL 6 /* label */ -#define C_ULABEL 7 /* undefined label */ -#define C_MOS 8 /* member of structure */ -#define C_ARG 9 /* function argument */ -#define C_STRTAG 10 /* structure tag */ -#define C_MOU 11 /* member of union */ -#define C_UNTAG 12 /* union tag */ -#define C_TPDEF 13 /* type definition */ -#define C_USTATIC 14 /* undefined static */ -#define C_ENTAG 15 /* enumeration tag */ -#define C_MOE 16 /* member of enumeration */ -#define C_REGPARM 17 /* register parameter */ -#define C_FIELD 18 /* bit field */ - -#ifdef TC_I960 -#define C_AUTOARG 19 /* auto argument */ -#define C_LASTENT 20 /* dummy entry (end of block) */ -#endif /* TC_I960 */ - -#ifdef TC_A29K -#define C_GLBLREG 19 /* global register */ -#define C_EXTREG 20 /* external global register */ -#define C_DEFREG 21 /* ext. def. of global register */ -#define C_STARTOF 22 /* as29 $SIZEOF and $STARTOF symbols */ -#endif /* TC_A29K */ - -#define C_BLOCK 100 /* ".bb" or ".eb" */ -#define C_FCN 101 /* ".bf" or ".ef" */ -#define C_EOS 102 /* end of structure */ -#define C_FILE 103 /* file name */ -#define C_LINE 104 /* line # reformatted as symbol table entry */ -#define C_ALIAS 105 /* duplicate tag */ -#define C_HIDDEN 106 /* ext symbol in dmert public lib. like static, - used to avoid name conflicts. */ - -#ifdef TC_I960 - /* New storage classes for 80960 */ -#define C_SCALL 107 /* Procedure reachable via system call */ - /* C_LEAFPROC is obsolete. Use C_LEAFEXT or C_LEAFSTAT */ -#define C_LEAFPROC 108 /* Leaf procedure, "call" via BAL */ -#define C_LEAFEXT 108 -#define C_OPTVAR 109 /* Optimized variable */ -#define C_DEFINE 110 /* Preprocessor #define */ -#define C_PRAGMA 111 /* Advice to compiler or linker */ -#define C_SEGMENT 112 /* 80960 segment name */ -#define C_LEAFSTAT 113 /* Static leaf */ -#endif /* TC_I960 */ - -#ifdef TC_A29K -#define C_SHADOW 107 /* shadow symbol */ -#endif /* TC_A29K */ - -/********************** SECTION HEADER **********************/ - -struct scnhdr { - char s_name[8]; /* section name */ - long s_paddr; /* physical address, aliased s_nlib */ - long s_vaddr; /* virtual address */ - long s_size; /* section size */ - long s_scnptr; /* file ptr to raw data for section */ - long s_relptr; /* file ptr to relocation */ - long s_lnnoptr; /* file ptr to line numbers */ - unsigned short s_nreloc; /* number of relocation entries */ - unsigned short s_nlnno; /* number of line number entries */ - long s_flags; /* flags */ - -#ifdef TC_I960 - unsigned long s_align; /* section alignment */ -#endif /* TC_I960 */ -}; - -#define SCNHDR struct scnhdr -#define SCNHSZ sizeof(SCNHDR) - -/* - * names of "special" sections - */ -#define _TEXT ".text" -#define _DATA ".data" -#define _BSS ".bss" - -/* - * s_flags "type" - */ - -/* - * In instances where it is necessary for a linker to - * produce an output file which contains text or data not - * based at virtual address 0, e.g. for a ROM, then the - * linker should accept address base information as command - * input and use PAD sections to skip over unused addresses. - * (at least for a29k. Maybe others.) - */ - -#define STYP_REG (0x0000) /* "regular" section: allocated, relocated, loaded */ -#define STYP_DSECT (0x0001) /* "dummy" section: not allocated, relocated, not loaded */ -#define STYP_NOLOAD (0x0002) /* "noload" section: allocated, relocated, not loaded */ -#define STYP_GROUP (0x0004) /* "grouped" section: formed of input sections */ -#define STYP_PAD (0x0008) /* "padding" section: not allocated, not relocated, loaded */ -#define STYP_COPY (0x0010) /* "copy" section: for decision function used by field update; not allocated, not relocated, - loaded; reloc & lineno entries processed normally */ -#define STYP_TEXT (0x0020) /* section contains text only */ -#define S_SHRSEG (0x0020) /* In 3b Update files (output of ogen), sections which appear in SHARED segments of the Pfile - will have the S_SHRSEG flag set by ogen, to inform dufr that updating 1 copy of the proc. will - update all process invocations. */ -#define STYP_DATA (0x0040) /* section contains data only */ -#define STYP_BSS (0x0080) /* section contains bss only */ -#define S_NEWFCN (0x0100) /* In a minimal file or an update file, a new function (as compared with a replaced function) */ -#define STYP_INFO (0x0200) /* comment section : not allocated not relocated, not loaded */ -#define STYP_OVER (0x0400) /* overlay section : relocated not allocated or loaded */ -#define STYP_LIB (0x0800) /* for .lib section : same as INFO */ -#define STYP_MERGE (0x2000) /* merge section -- combines with text, data or bss sections only */ -#define STYP_REVERSE_PAD (0x4000) /* section will be padded with no-op instructions wherever padding is necessary and there is a - word of contiguous bytes beginning on a word boundary. */ - -#ifdef TC_A29K -/* NOTE: The use of STYP_BSSREG for relocation is not yet defined. */ -#define STYP_BSSREG 0x1200 /* Global register area (like STYP_INFO) */ -#define STYP_ENVIR 0x2200 /* Environment (like STYP_INFO) */ -#define STYP_ABS 0x4000 /* Absolute (allocated, not reloc, loaded) */ -#define STYP_LIT 0x8020 /* Literal data (like STYP_TEXT) */ -#endif /* TC_A29K */ - -/********************** 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 lineno { - union { - long l_symndx; /* symbol index of function name, iff l_lnno == 0*/ - long l_paddr; /* (physical) address of line number */ - } l_addr; - unsigned short l_lnno; /* line number */ -#ifdef TC_I960 - /* not used on a29k */ - char padding[2]; /* force alignment */ -#endif /* TC_I960 */ -}; - -#define LINENO struct lineno -#define LINESZ sizeof(LINENO) - - -/********************** SYMBOLS **********************/ - -#define SYMNMLEN 8 /* # characters in a symbol name */ -#define FILNMLEN 14 /* # characters in a file name */ -#define DIMNUM 4 /* # array dimensions in auxiliary entry */ - -struct syment { - union { - char _n_name[SYMNMLEN]; /* old COFF version */ - struct { - long _n_zeroes; /* new == 0 */ - long _n_offset; /* offset into string table */ - } _n_n; - char *_n_nptr[2]; /* allows for overlaying */ - } _n; - long n_value; /* value of symbol */ - short n_scnum; /* section number */ - -#ifdef TC_I960 - /* This isn't yet used on the i960. In some formats this - is two bytes of padding. In others, it is missing entirely. */ - unsigned short n_flags; /* copy of flags from filhdr */ -#endif /* TC_I960 */ - -#ifdef TC_A29K - unsigned short n_type; /* type and derived type */ -#else /* TC_A29K */ - /* at least i960 uses long */ - unsigned long n_type; /* type and derived type */ -#endif /* TC_A29K */ - - char n_sclass; /* storage class */ - char n_numaux; /* number of aux. entries */ - -#ifndef TC_A29K - char pad2[2]; /* force alignment */ -#endif /* TC_A29K */ -}; - -#define SYMENT struct syment -#define SYMESZ sizeof(SYMENT) /* This had better also be sizeof(AUXENT) */ - -#define n_name _n._n_name -#define n_ptr _n._n_nptr[1] -#define n_zeroes _n._n_n._n_zeroes -#define n_offset _n._n_n._n_offset - -/* - * Relocatable symbols have number of the section in which they are defined, - * or one of the following: - */ - -#define N_SCNUM ((short) 1-65535) /* section num where symbol defined */ -#define N_UNDEF ((short)0) /* undefined symbol */ -#define N_ABS ((short)-1) /* value of symbol is absolute */ -#define N_DEBUG ((short)-2) /* debugging symbol -- symbol value is meaningless */ -#define N_TV ((short)-3) /* indicates symbol needs preload transfer vector */ -#define P_TV ((short)-4) /* indicates symbol needs transfer vector (postload) */ - -/* - * Type of a symbol, in low 4 bits of the word - */ -#define T_NULL 0 /* type not assigned */ -#define T_VOID 1 /* function argument (only used by compiler) (but now - real void). */ -#define T_CHAR 2 /* character */ -#define T_SHORT 3 /* short integer */ -#define T_INT 4 /* integer */ -#define T_LONG 5 /* long integer */ -#define T_FLOAT 6 /* floating point */ -#define T_DOUBLE 7 /* double word */ -#define T_STRUCT 8 /* structure */ -#define T_UNION 9 /* union */ -#define T_ENUM 10 /* enumeration */ -#define T_MOE 11 /* member of enumeration */ -#define T_UCHAR 12 /* unsigned character */ -#define T_USHORT 13 /* unsigned short */ -#define T_UINT 14 /* unsigned integer */ -#define T_ULONG 15 /* unsigned long */ - -#ifdef TC_I960 -#define T_LNGDBL 16 /* long double */ -#endif /* TC_I960 */ - -/* - * derived types, in n_type - */ -#define DT_NON (0) /* no derived type */ -#define DT_PTR (1) /* pointer */ -#define DT_FCN (2) /* function */ -#define DT_ARY (3) /* array */ - -#ifndef TC_I960 - -#define N_BTMASK (0x0f) -#define N_TMASK (0x30) -#define N_BTSHFT (4) -#define N_TSHIFT (2) - -#else /* TC_I960 */ - -#define N_BTMASK (0x1f) -#define N_TMASK (0x60) -#define N_BTSHFT (5) -#define N_TSHIFT (2) - -#endif /* TC_I960 */ - -#define BTYPE(x) ((x) & N_BTMASK) - -#define ISPTR(x) (((x) & N_TMASK) == (DT_PTR << N_BTSHFT)) -#define ISFCN(x) (((x) & N_TMASK) == (DT_FCN << N_BTSHFT)) -#define ISARY(x) (((x) & N_TMASK) == (DT_ARY << N_BTSHFT)) - -#define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK)) - -union auxent { - struct { - long x_tagndx; /* str, un, or enum tag indx */ - union { - struct { - unsigned short x_lnno; /* declaration line number */ - unsigned short x_size; /* str/union/array size */ - } x_lnsz; - long x_fsize; /* size of function */ - } x_misc; - union { - struct { /* if ISFCN, tag, or .bb */ - long x_lnnoptr; /* ptr to fcn line # */ - long x_endndx; /* entry ndx past block end */ - } x_fcn; - struct { /* if ISARY, up to 4 dimen. */ - unsigned short x_dimen[DIMNUM]; - } x_ary; - } x_fcnary; - unsigned short x_tvndx; /* tv index */ - } x_sym; - - /* This was just a struct x_file with x_fname only in a29k. xoxorich. */ - union { - char x_fname[FILNMLEN]; - struct { - long x_zeroes; - long x_offset; - } x_n; - } x_file; - - struct { - long x_scnlen; /* section length */ - unsigned short x_nreloc; /* # relocation entries */ - unsigned short x_nlinno; /* # line numbers */ - } x_scn; - - struct { - long x_tvfill; /* tv fill value */ - unsigned short x_tvlen; /* length of .tv */ - - /* This field was typo'd x_tvrna on a29k. xoxorich. */ - unsigned short x_tvran[2]; /* tv range */ - } x_tv; /* info about .tv section (in auxent of symbol .tv)) */ - -#ifdef TC_I960 - /****************************************** - * I960-specific *2nd* aux. entry formats - ******************************************/ - struct { - /* This is a very old typo that keeps getting propogated. */ -#define x_stdindx x_stindx - long x_stindx; /* sys. table entry */ - } x_sc; /* system call entry */ - - struct { - unsigned long x_balntry; /* BAL entry point */ - } x_bal; /* BAL-callable function */ - - struct { - unsigned long x_timestamp; /* time stamp */ - char x_idstring[20]; /* producer identity string */ - } x_ident; /* Producer ident info */ - - char a[sizeof(struct syment)]; /* force auxent/syment sizes to match */ -#endif /* TC_I960 */ -}; - -#define AUXENT union auxent -#define AUXESZ sizeof(AUXENT) /* This had better also be sizeof(SYMENT) */ - -#if VAX || I960 -# define _ETEXT "_etext" -#else -# define _ETEXT "etext" -#endif - -/********************** RELOCATION DIRECTIVES **********************/ - -struct reloc { - long r_vaddr; /* Virtual address of reference */ - long r_symndx; /* Index into symbol table */ - unsigned short r_type; /* Relocation type */ -#ifdef TC_I960 - /* not used for a29k */ - char pad[2]; /* Unused */ -#endif /* TC_I960 */ -}; - -#define RELOC struct reloc -#define RELSZ sizeof(RELOC) - -#ifdef TC_I960 -#define R_RELLONG (0x11) /* Direct 32-bit relocation */ -#define R_IPRSHORT (0x18) -#define R_IPRMED (0x19) /* 24-bit ip-relative relocation */ -#define R_IPRLONG (0x1a) -#define R_OPTCALL (0x1b) /* 32-bit optimizable call (leafproc/sysproc) */ -#define R_OPTCALLX (0x1c) /* 64-bit optimizable call (leafproc/sysproc) */ -#define R_GETSEG (0x1d) -#define R_GETPA (0x1e) -#define R_TAGWORD (0x1f) -#endif /* TC_I960 */ - -#ifdef TC_A29K -/* - * NOTE: All the "I" forms refer to Am29000 instruction - * formats. The linker is expected to know how the numeric - * information is split and/or aligned within the - * instruction word(s). R_BYTE works for instructions, too. - * - * If the parameter to a CONSTH instruction is a relocatable - * type, two relocation records are written. The first has - * an r_type of R_IHIHALF (33 octal) and a normal r_vaddr - * and r_symndx. The second relocation record has an r_type - * of R_IHCONST (34 octal), a normal r_vaddr (which is - * redundant), and an r_symndx containing the 32-bit - * constant offset to the relocation instead of the actual - * symbol table index. This second record is always - * written, even if the constant offset is zero. The - * constant fields of the instruction are set to zero. - */ - -#define R_ABS (0x00) /* reference is absolute */ -#define R_IREL (0x18) /* instruction relative (jmp/call) */ -#define R_IABS (0x19) /* instruction absolute (jmp/call) */ -#define R_ILOHALF (0x1a) /* instruction low half (const) */ -#define R_IHIHALF (0x1b) /* instruction high half (consth) part 1 */ -#define R_IHCONST (0x1c) /* instruction high half (consth) part 2 - constant offset of R_IHIHALF relocation */ -#define R_BYTE (0x1d) /* relocatable byte value */ -#define R_HWORD (0x1e) /* relocatable halfword value */ -#define R_WORD (0x1f) /* relocatable word value */ -#define R_IGLBLRC (0x20) /* instruction global register RC */ -#define R_IGLBLRA (0x21) /* instruction global register RA */ -#define R_IGLBLRB (0x22) /* instruction global register RB */ -#endif /* TC_A29K */ - - -#define DEFAULT_DATA_SECTION_ALIGNMENT 4 -#define DEFAULT_BSS_SECTION_ALIGNMENT 4 -#define DEFAULT_TEXT_SECTION_ALIGNMENT 16 -/* For new sections we havn't heard of before */ -#define DEFAULT_SECTION_ALIGNMENT 4 - - -/* - * Local Variables: - * comment-column: 0 - * End: - */ - -/* end of coff.gnu.h */ diff --git a/gas/config/cplus-dem.c b/gas/config/cplus-dem.c deleted file mode 100644 index 12b9d06d096..00000000000 --- a/gas/config/cplus-dem.c +++ /dev/null @@ -1,925 +0,0 @@ -/* Demangler for GNU C++ - Copyright (C) 1989 Free Software Foundation, Inc. - written by James Clark (jjc@jclark.uucp) - - 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* This is for g++ 1.36.1 (November 6 version). It will probably - require changes for any other version. */ - -/* This file exports one function - - char *cplus_demangle (const char *name) - - If `name' is a mangled function name produced by g++, then - a pointer to a malloced string giving a C++ representation - of the name will be returned; otherwise NULL will be returned. - It is the caller's responsibility to free the string which - is returned. - - For example, - - cplus_demangle ("_foo__1Ai") - - returns - - "A::foo(int)" - - This file imports xmalloc and xrealloc, which are like malloc and - realloc except that they generate a fatal error if there is no - available memory. */ - -/* #define nounderscore 1 /* define this is names don't start with _ */ - -#include -#include -#include - -#if !defined(sequent) && !defined(NeXT) -#include -#else -#define memcpy(s1, s2, n) strncpy(s1, s2, n) -#define memcmp(s1, s2, n) strncmp(s1, s2, n) -#define strchr(s, c) index(s, c) -#endif - -#ifndef __STDC__ -#define const -#endif - -#ifdef __STDC__ -extern char *cplus_demangle (const char *type); -#else -extern char *cplus_demangle (); -#endif - -#ifdef __STDC__ -extern char *xmalloc (int); -extern char *xrealloc (char *, int); -#else -extern char *xmalloc (); -extern char *xrealloc (); -#endif - -static char **typevec = 0; -static int ntypes = 0; -static int typevec_size = 0; - -static struct { - const char *in; - const char *out; -} optable[] = { - "new", " new", - "delete", " delete", - "ne", "!=", - "eq", "==", - "ge", ">=", - "gt", ">", - "le", "<=", - "lt", "<", - "plus", "+", - "minus", "-", - "mult", "*", - "negate", "-", - "trunc_mod", "%", - "trunc_div", "/", - "truth_andif", "&&", - "truth_orif", "||", - "postincrement", "++", - "postdecrement", "--", - "bit_ior", "|", - "bit_xor", "^", - "bit_and", "&", - "bit_not", "~", - "call", "()", - "cond", "?:", - "alshift", "<<", - "arshift", ">>", - "component", "->", - "nop", "", /* for operator= */ -}; - -/* Beware: these aren't '\0' terminated. */ - -typedef struct { - char *b; /* pointer to start of string */ - char *p; /* pointer after last character */ - char *e; /* pointer after end of allocated space */ -} string; - -#ifdef __STDC__ -static void string_need (string *s, int n); -static void string_delete (string *s); -static void string_init (string *s); -static void string_clear (string *s); -static int string_empty (string *s); -static void string_append (string *p, const char *s); -static void string_appends (string *p, string *s); -static void string_appendn (string *p, const char *s, int n); -static void string_prepend (string *p, const char *s); -#if 0 -static void string_prepends (string *p, string *s); -#endif -static void string_prependn (string *p, const char *s, int n); -static int get_count (const char **type, int *count); -static int do_args (const char **type, string *decl); -static int do_type (const char **type, string *result); -static int do_arg (const char **type, string *result); -static int do_args (const char **type, string *decl); -static void munge_function_name (string *name); -#else -static void string_need (); -static void string_delete (); -static void string_init (); -static void string_clear (); -static int string_empty (); -static void string_append (); -static void string_appends (); -static void string_appendn (); -static void string_prepend (); -static void string_prepends (); -static void string_prependn (); -static int get_count (); -static int do_args (); -static int do_type (); -static int do_arg (); -static int do_args (); -static void munge_function_name (); -#endif - -char * -cplus_demangle (type) - const char *type; -{ - string decl; - int n; - int success = 0; - int constructor = 0; - int const_flag = 0; - int i; - const char *p; - - if (type == NULL || *type == '\0') - return NULL; -#ifndef nounderscore - if (*type++ != '_') - return NULL; -#endif - p = type; - while (*p != '\0' && !(*p == '_' && p[1] == '_')) - p++; - if (*p == '\0') - { - /* destructor */ - if (type[0] == '_' && type[1] == '$' && type[2] == '_') - { - int n = (strlen (type) - 3)*2 + 3 + 2 + 1; - char *tem = (char *) xmalloc (n); - strcpy (tem, type + 3); - strcat (tem, "::~"); - strcat (tem, type + 3); - strcat (tem, "()"); - return tem; - } - /* static data member */ - if (*type != '_' && (p = strchr (type, '$')) != '\0') - { - int n = strlen (type) + 2; - char *tem = (char *) xmalloc (n); - memcpy (tem, type, p - type); - strcpy (tem + (p - type), "::"); - strcpy (tem + (p - type) + 2, p + 1); - return tem; - } - return NULL; - } - - string_init (&decl); - - if (p == type) - { - if (!isdigit (p[2])) - { - string_delete (&decl); - return NULL; - } - constructor = 1; - } - else - { - string_appendn (&decl, type, p - type); - munge_function_name (&decl); - } - p += 2; - - switch (*p) - { - case 'C': - /* a const member function */ - if (!isdigit (p[1])) - { - string_delete (&decl); - return NULL; - } - p += 1; - const_flag = 1; - /* fall through */ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - n = 0; - do - { - n *= 10; - n += *p - '0'; - p += 1; - } - while (isdigit (*p)); - if (strlen (p) < n) - { - string_delete (&decl); - return NULL; - } - if (constructor) - { - string_appendn (&decl, p, n); - string_append (&decl, "::"); - string_appendn (&decl, p, n); - } - else - { - string_prepend (&decl, "::"); - string_prependn (&decl, p, n); - } - p += n; - success = do_args (&p, &decl); - if (const_flag) - string_append (&decl, " const"); - break; - case 'F': - p += 1; - success = do_args (&p, &decl); - break; - } - - for (i = 0; i < ntypes; i++) - if (typevec[i] != NULL) - free (typevec[i]); - ntypes = 0; - if (typevec != NULL) - { - free ((char *)typevec); - typevec = NULL; - typevec_size = 0; - } - - if (success) - { - string_appendn (&decl, "", 1); - return decl.b; - } - else - { - string_delete (&decl); - return NULL; - } -} - -static int -get_count (type, count) - const char **type; - int *count; -{ - if (!isdigit (**type)) - return 0; - *count = **type - '0'; - *type += 1; - /* see flush_repeats in cplus-method.c */ - if (isdigit (**type)) - { - const char *p = *type; - int n = *count; - do - { - n *= 10; - n += *p - '0'; - p += 1; - } - while (isdigit (*p)); - if (*p == '_') - { - *type = p + 1; - *count = n; - } - } - return 1; -} - -/* result will be initialised here; it will be freed on failure */ - -static int -do_type (type, result) - const char **type; - string *result; -{ - int n; - int done; - int non_empty; - int success; - string decl; - const char *remembered_type; - - string_init (&decl); - string_init (result); - - done = 0; - success = 1; - while (success && !done) - { - int member; - switch (**type) - { - case 'P': - *type += 1; - string_prepend (&decl, "*"); - break; - - case 'R': - *type += 1; - string_prepend (&decl, "&"); - break; - - case 'T': - *type += 1; - if (!get_count (type, &n) || n >= ntypes) - success = 0; - else - { - remembered_type = typevec[n]; - type = &remembered_type; - } - break; - - case 'F': - *type += 1; - if (!string_empty (&decl) && decl.b[0] == '*') - { - string_prepend (&decl, "("); - string_append (&decl, ")"); - } - if (!do_args (type, &decl) || **type != '_') - success = 0; - else - *type += 1; - break; - - case 'M': - case 'O': - { - int constp = 0; - int volatilep = 0; - - member = **type == 'M'; - *type += 1; - if (!isdigit (**type)) - { - success = 0; - break; - } - n = 0; - do - { - n *= 10; - n += **type - '0'; - *type += 1; - } - while (isdigit (**type)); - if (strlen (*type) < n) - { - success = 0; - break; - } - string_append (&decl, ")"); - string_prepend (&decl, "::"); - string_prependn (&decl, *type, n); - string_prepend (&decl, "("); - *type += n; - if (member) - { - if (**type == 'C') - { - *type += 1; - constp = 1; - } - if (**type == 'V') - { - *type += 1; - volatilep = 1; - } - if (*(*type)++ != 'F') - { - success = 0; - break; - } - } - if ((member && !do_args (type, &decl)) || **type != '_') - { - success = 0; - break; - } - *type += 1; - if (constp) - { - if (non_empty) - string_append (&decl, " "); - else - non_empty = 1; - string_append (&decl, "const"); - } - if (volatilep) - { - if (non_empty) - string_append (&decl, " "); - else - non_empty = 1; - string_append (&decl, "volatilep"); - } - break; - } - - case 'C': - if ((*type)[1] == 'P') - { - *type += 1; - if (!string_empty (&decl)) - string_prepend (&decl, " "); - string_prepend (&decl, "const"); - break; - } - - /* fall through */ - default: - done = 1; - break; - } - } - - done = 0; - non_empty = 0; - while (success && !done) - { - switch (**type) - { - case 'C': - *type += 1; - if (non_empty) - string_append (result, " "); - else - non_empty = 1; - string_append (result, "const"); - break; - case 'U': - *type += 1; - if (non_empty) - string_append (result, " "); - else - non_empty = 1; - string_append (result, "unsigned"); - break; - case 'V': - *type += 1; - if (non_empty) - string_append (result, " "); - else - non_empty = 1; - string_append (result, "volatile"); - break; - default: - done = 1; - break; - } - } - - if (success) - switch (**type) - { - case '\0': - case '_': - break; - case 'v': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "void"); - break; - case 'l': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "long"); - break; - case 'i': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "int"); - break; - case 's': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "short"); - break; - case 'c': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "char"); - break; - case 'r': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "long double"); - break; - case 'd': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "double"); - break; - case 'f': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "float"); - break; - case 'G': - *type += 1; - if (!isdigit (**type)) - { - success = 0; - break; - } - /* fall through */ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - n = 0; - do - { - n *= 10; - n += **type - '0'; - *type += 1; - } - while (isdigit (**type)); - if (strlen (*type) < n) - { - success = 0; - break; - } - if (non_empty) - string_append (result, " "); - string_appendn (result, *type, n); - *type += n; - break; - default: - success = 0; - break; - } - - if (success) - { - if (!string_empty (&decl)) - { - string_append (result, " "); - string_appends (result, &decl); - } - string_delete (&decl); - return 1; - } - else - { - string_delete (&decl); - string_delete (result); - return 0; - } -} - -/* `result' will be initialised in do_type; it will be freed on failure */ - -static int -do_arg (type, result) - const char **type; - string *result; -{ - char *tem; - int len; - const char *start; - const char *end; - - start = *type; - if (!do_type (type, result)) - return 0; - end = *type; - if (ntypes >= typevec_size) - { - if (typevec_size == 0) - { - typevec_size = 3; - typevec = (char **) xmalloc (sizeof (char*)*typevec_size); - } - else - { - typevec_size *= 2; - typevec = (char **) xrealloc ((char *)typevec, sizeof (char*)*typevec_size); - } - } - len = end - start; - tem = (char *) xmalloc (len + 1); - memcpy (tem, start, len); - tem[len] = '\0'; - typevec[ntypes++] = tem; - return 1; -} - -/* `decl' must be already initialised, usually non-empty; - it won't be freed on failure */ - -static int -do_args (type, decl) - const char **type; - string *decl; -{ - string arg; - int need_comma = 0; - - string_append (decl, "("); - - while (**type != '_' && **type != '\0' && **type != 'e' && **type != 'v') - { - if (**type == 'N') - { - int r; - int t; - *type += 1; - if (!get_count (type, &r) || !get_count (type, &t) || t >= ntypes) - return 0; - while (--r >= 0) - { - const char *tem = typevec[t]; - if (need_comma) - string_append (decl, ", "); - if (!do_arg (&tem, &arg)) - return 0; - string_appends (decl, &arg); - string_delete (&arg); - need_comma = 1; - } - } - else - { - if (need_comma) - string_append (decl, ", "); - if (!do_arg (type, &arg)) - return 0; - string_appends (decl, &arg); - string_delete (&arg); - need_comma = 1; - } - } - - if (**type == 'v') - *type += 1; - else if (**type == 'e') - { - *type += 1; - if (need_comma) - string_append (decl, ","); - string_append (decl, "..."); - } - - string_append (decl, ")"); - return 1; -} - -static void -munge_function_name (name) - string *name; -{ - if (!string_empty (name) && name->p - name->b >= 3 - && name->b[0] == 'o' && name->b[1] == 'p' && name->b[2] == '$') - { - int i; - /* see if it's an assignment expression */ - if (name->p - name->b >= 10 /* op$assign_ */ - && memcmp (name->b + 3, "assign_", 7) == 0) - { - for (i = 0; i < sizeof (optable)/sizeof (optable[0]); i++) - { - int len = name->p - name->b - 10; - if (strlen (optable[i].in) == len - && memcmp (optable[i].in, name->b + 10, len) == 0) - { - string_clear (name); - string_append (name, "operator"); - string_append (name, optable[i].out); - string_append (name, "="); - return; - } - } - } - else - { - for (i = 0; i < sizeof (optable)/sizeof (optable[0]); i++) - { - int len = name->p - name->b - 3; - if (strlen (optable[i].in) == len - && memcmp (optable[i].in, name->b + 3, len) == 0) - { - string_clear (name); - string_append (name, "operator"); - string_append (name, optable[i].out); - return; - } - } - } - return; - } - else if (!string_empty (name) && name->p - name->b >= 5 - && memcmp (name->b, "type$", 5) == 0) - { - /* type conversion operator */ - string type; - const char *tem = name->b + 5; - if (do_type (&tem, &type)) - { - string_clear (name); - string_append (name, "operator "); - string_appends (name, &type); - string_delete (&type); - return; - } - } -} - -/* a mini string-handling package */ - -static void -string_need (s, n) - string *s; - int n; -{ - if (s->b == NULL) - { - if (n < 32) - n = 32; - s->p = s->b = (char *) xmalloc (n); - s->e = s->b + n; - } - else if (s->e - s->p < n) - { - int tem = s->p - s->b; - n += tem; - n *= 2; - s->b = (char *) xrealloc (s->b, n); - s->p = s->b + tem; - s->e = s->b + n; - } -} - -static void -string_delete (s) - string *s; -{ - if (s->b != NULL) - { - free (s->b); - s->b = s->e = s->p = NULL; - } -} - -static void -string_init (s) - string *s; -{ - s->b = s->p = s->e = NULL; -} - -static void -string_clear (s) - string *s; -{ - s->p = s->b; -} - -static int -string_empty (s) - string *s; -{ - return s->b == s->p; -} - -static void -string_append (p, s) - string *p; - const char *s; -{ - int n; - if (s == NULL || *s == '\0') - return; - n = strlen (s); - string_need (p, n); - memcpy (p->p, s, n); - p->p += n; -} - -static void -string_appends (p, s) - string *p, *s; -{ - int n; - if (s->b == s->p) - return; - n = s->p - s->b; - string_need (p, n); - memcpy (p->p, s->b, n); - p->p += n; -} - -static void -string_appendn (p, s, n) - string *p; - const char *s; - int n; -{ - if (n == 0) - return; - string_need (p, n); - memcpy (p->p, s, n); - p->p += n; -} - -static void -string_prepend (p, s) - string *p; - const char *s; -{ - if (s == NULL || *s == '\0') - return; - string_prependn (p, s, strlen (s)); -} - -#if 0 -static void -string_prepends (p, s) - string *p, *s; -{ - if (s->b == s->p) - return; - string_prependn (p, s->b, s->p - s->b); -} -#endif - -static void -string_prependn (p, s, n) - string *p; - const char *s; - int n; -{ - char *q; - - if (n == 0) - return; - string_need (p, n); - for (q = p->p - 1; q >= p->b; q--) - q[n] = q[0]; - memcpy (p->b, s, n); - p->p += n; -} diff --git a/gas/config/ebmon29k.mt b/gas/config/ebmon29k.mt deleted file mode 100644 index 0fda48ef079..00000000000 --- a/gas/config/ebmon29k.mt +++ /dev/null @@ -1,6 +0,0 @@ -TARG_CPU_DEPENDENTS= -LOCAL_LOADLIBES=$(srcdir)/../bfd$(subdir)/libbfd.a -TDEFINES=-DBFD_HEADERS - - - diff --git a/gas/config/h8300.mt b/gas/config/h8300.mt deleted file mode 100644 index 1e6eb3c8dc9..00000000000 --- a/gas/config/h8300.mt +++ /dev/null @@ -1,4 +0,0 @@ -TARG_CPU_DEPENDENTS=$(srcdir)/../include/h8300-opcode.h -LOCAL_LOADLIBES=$(srcdir)/../bfd/$(srcdir)/libbfd.a -TDEFINES=-DBFD -DMANY_SEGMENTS - diff --git a/gas/config/h8300hds.mt b/gas/config/h8300hds.mt deleted file mode 100644 index 1e6eb3c8dc9..00000000000 --- a/gas/config/h8300hds.mt +++ /dev/null @@ -1,4 +0,0 @@ -TARG_CPU_DEPENDENTS=$(srcdir)/../include/h8300-opcode.h -LOCAL_LOADLIBES=$(srcdir)/../bfd/$(srcdir)/libbfd.a -TDEFINES=-DBFD -DMANY_SEGMENTS - diff --git a/gas/config/ho-a29k.h b/gas/config/ho-a29k.h deleted file mode 100755 index 949e07c5b7f..00000000000 --- a/gas/config/ho-a29k.h +++ /dev/null @@ -1,45 +0,0 @@ -/* ho-a29k.h Host-specific header file intended for "eb" board with - HIF. - - Copyright (C) 1987, 1991 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* $Id$ */ - -#define HO_A29K 1 - -#include - -/* - * $Log$ - * Revision 1.2 1991/06/14 14:01:53 rich - * Version 2 GPL. - * - * Revision 1.1 1991/04/13 10:03:23 rich - * Initial revision - * - * Revision 1.1.1.1 1991/04/04 18:15:43 rich - * new gas main line - * - * Revision 1.1 1991/04/04 18:15:42 rich - * Initial revision - * - * - */ - -/* end of ho-a29k.h */ diff --git a/gas/config/ho-ansi.h b/gas/config/ho-ansi.h deleted file mode 100644 index 1e8ed7d24e6..00000000000 --- a/gas/config/ho-ansi.h +++ /dev/null @@ -1,46 +0,0 @@ -/* ho-ansi.h Host-specific header file for generic ansi environments. - Copyright (C) 1987, 1991 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* $Id$ */ - -#define M_ANSI 1 - -#include -#include -#include - -#define sys_nerr _sys_nerr -#define sys_errlist _sys_errlist -#define bzero(b,l) (memset((b),0,(l))) - -/* - * $Log$ - * Revision 1.2 1991/06/14 14:01:54 rich - * Version 2 GPL. - * - * Revision 1.1.1.1 1991/04/04 18:15:39 rich - * new gas main line - * - * Revision 1.1 1991/04/04 18:15:38 rich - * Initial revision - * - * - */ - -/* end of ho-ansi.h */ diff --git a/gas/config/ho-cygnus.h b/gas/config/ho-cygnus.h deleted file mode 100755 index 27cfebd556f..00000000000 --- a/gas/config/ho-cygnus.h +++ /dev/null @@ -1,47 +0,0 @@ -/* ho-ansi.h Host-specific header file for generic ansi environments. - Copyright (C) 1987, 1991 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* $Id$ */ - -#define M_ANSI 1 - -#include -#include -#include -#include - -#define sys_nerr _sys_nerr -#define sys_errlist _sys_errlist -#define bzero(s,l) (memset((s),0,(l))) - -/* - * $Log$ - * Revision 1.2 1991/06/14 14:01:55 rich - * Version 2 GPL. - * - * Revision 1.1.1.1 1991/04/04 18:15:42 rich - * new gas main line - * - * Revision 1.1 1991/04/04 18:15:40 rich - * Initial revision - * - * - */ - -/* end of ho-ansi.h */ diff --git a/gas/config/ho-decstation.h b/gas/config/ho-decstation.h deleted file mode 100644 index b6b8c75a73f..00000000000 --- a/gas/config/ho-decstation.h +++ /dev/null @@ -1,29 +0,0 @@ -/* ho-pmax.h Host-specific header file for decstation 3100. - Copyright (C) 1987, 1990, 1991 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include - -extern char *malloc(); -extern int free(); - -#if !defined(__GNUC__) -#define know(x) -#endif /* not gcc */ - -/* end of ho-pmax.h */ diff --git a/gas/config/ho-generic.h b/gas/config/ho-generic.h deleted file mode 100644 index 7a06c36ca45..00000000000 --- a/gas/config/ho-generic.h +++ /dev/null @@ -1,38 +0,0 @@ -/* ho-generic.h Generic host-specific header file. - Copyright (C) 1987, 1991 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* $Id$ */ - -#define M_GENERIC 1 - -/* - * $Log$ - * Revision 1.2 1991/06/14 14:01:58 rich - * Version 2 GPL. - * - * Revision 1.1.1.1 1991/04/04 18:15:43 rich - * new gas main line - * - * Revision 1.1 1991/04/04 18:15:42 rich - * Initial revision - * - * - */ - -/* end of ho-generic.h */ diff --git a/gas/config/ho-hpux.h b/gas/config/ho-hpux.h deleted file mode 100644 index 015fd20f72f..00000000000 --- a/gas/config/ho-hpux.h +++ /dev/null @@ -1,34 +0,0 @@ -/* ho-hpux.h -- Header to compile the assembler under HP-UX - Copyright (C) 1988, 1991 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* $Id$ */ - -#include "ho-sysv.h" - -/* This header file contains the #defines specific - to HPUX changes sent me by cph@zurich.ai.mit.edu */ -#ifndef hpux -#define hpux -#endif - -#ifdef setbuffer -#undef setbuffer -#endif /* setbuffer */ - -#define setbuffer(stream, buf, size) diff --git a/gas/config/ho-i386.h b/gas/config/ho-i386.h deleted file mode 100644 index d701b1abec6..00000000000 --- a/gas/config/ho-i386.h +++ /dev/null @@ -1,28 +0,0 @@ -/* ho-i386.h i386 specific header file. - Copyright (C) 1987, 1991 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* $Id$ */ - -#define HO_I386 1 - -#define NO_STDARG - -#include "ho-sysv.h" - -/* end of ho-i386.h */ diff --git a/gas/config/ho-rs6000.h b/gas/config/ho-rs6000.h deleted file mode 100644 index 250b23c53d8..00000000000 --- a/gas/config/ho-rs6000.h +++ /dev/null @@ -1,22 +0,0 @@ -/* ho-rs6000.h Rs6000 host-specific header file. - Copyright (C) 1987, 1991 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#define M_RS6000 1 - -/* end of ho-rs6000.h */ diff --git a/gas/config/ho-sun3.h b/gas/config/ho-sun3.h deleted file mode 100644 index 41d2f96825d..00000000000 --- a/gas/config/ho-sun3.h +++ /dev/null @@ -1,5 +0,0 @@ -/* $Id$ */ - -#include - -/* end of ho-sun3.h */ diff --git a/gas/config/ho-sun386.h b/gas/config/ho-sun386.h deleted file mode 100644 index 00eacada58d..00000000000 --- a/gas/config/ho-sun386.h +++ /dev/null @@ -1,7 +0,0 @@ -/* $Id$ */ - -#include - -extern int sprintf(); - -/* end of ho-sun386.h */ diff --git a/gas/config/ho-sun4.h b/gas/config/ho-sun4.h deleted file mode 100644 index 6cfd6b48ae2..00000000000 --- a/gas/config/ho-sun4.h +++ /dev/null @@ -1,5 +0,0 @@ -/* $Id$ */ - -#include - -/* end of ho-sun4.h */ diff --git a/gas/config/ho-sunos.h b/gas/config/ho-sunos.h deleted file mode 100644 index 81c067c2de8..00000000000 --- a/gas/config/ho-sunos.h +++ /dev/null @@ -1,61 +0,0 @@ -/* $Id$ */ - -#ifndef __STDC__ -#define NO_STDARG -#endif /* not __STDC__ */ - -#if !defined(__GNUC__) & !defined(__STDC__) -#include -#else -extern int memset(); -#endif - -#include -#include - -/* externs for system libraries. */ - -extern char *strchr(); -extern char *malloc(); -extern char *realloc(); -extern char *strrchr(); -extern int _filbuf(); -extern int _flsbuf(); -extern int abort(); -extern int bcopy(); -extern int bzero(); -extern int bzero(); -extern int exit(); -extern int fclose(); -extern int fprintf(); -extern int fread(); -extern int free(); -extern int perror(); -extern int printf(); -extern int setvbuf(); -extern int sscanf(); -extern int strcmp(); -extern int strlen(); -extern int strncmp(); -extern int time(); -extern int ungetc(); -extern int vfprintf(); -extern int vprintf(); -extern long atol(); - -#ifndef tolower -extern int tolower(); -#endif /* tolower */ - -#ifndef toupper -extern int toupper(); -#endif /* toupper */ - -/* - * Local Variables: - * fill-column: 80 - * comment-column: 0 - * End: - */ - -/* end of ho-sun4.h */ diff --git a/gas/config/ho-sysv.h b/gas/config/ho-sysv.h deleted file mode 100644 index 18560af1a0c..00000000000 --- a/gas/config/ho-sysv.h +++ /dev/null @@ -1,31 +0,0 @@ -/* ho-sysv.h System V specific header file. - Copyright (C) 1987, 1991 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* $Id$ */ - -#define HO_USG - -#define bcopy(from,to,n) memcpy((to),(from),(n)) -#define bzero(s,n) memset((s),0,(n)) -#define setbuffer(stream, buf, size) setvbuf((stream), (buf), _IOLBF, (size)) - -extern int free(); -extern char *malloc(); - -/* end of ho-sysv.h */ diff --git a/gas/config/ho-vax.h b/gas/config/ho-vax.h deleted file mode 100644 index 6c2b89dc134..00000000000 --- a/gas/config/ho-vax.h +++ /dev/null @@ -1,29 +0,0 @@ -/* ho-vax.h Intended for vax ultrix - Copyright (C) 1987, 1991 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#define M_VAX 1 - -#ifndef __STDC__ -#define NO_STDARG -#endif /* not ansi */ - -extern char *malloc(); -extern int free(); - -/* end of ho-vax.h */ diff --git a/gas/config/m68k.mt b/gas/config/m68k.mt deleted file mode 100644 index bcae8c283d1..00000000000 --- a/gas/config/m68k.mt +++ /dev/null @@ -1 +0,0 @@ -TARG_CPU_DEPENDENTS=$(srcdir)/../include/m68k-opcode.h diff --git a/gas/config/mh-a29k b/gas/config/mh-a29k deleted file mode 100755 index f8de0b93b41..00000000000 --- a/gas/config/mh-a29k +++ /dev/null @@ -1 +0,0 @@ -CC = gcc -ba29k diff --git a/gas/config/mh-cygnus b/gas/config/mh-cygnus deleted file mode 100755 index 774d20502ce..00000000000 --- a/gas/config/mh-cygnus +++ /dev/null @@ -1,8 +0,0 @@ -CC = gcc -b$(target) -Wall -nostdinc -nostdlib \ - -I$(srcdir)/../clib/ansi/include -I$(srcdir)/../os-layer/include - -CLIB = $(srcdir)/../clib/Host-$(host)/Target-$(target)/libc.a \ - $(srcdir)/../gcc/Host-sun4/Target-$(target)/gnulib - -LDFLAGS = /lib/crt0.o - diff --git a/gas/config/mh-i386 b/gas/config/mh-i386 deleted file mode 100644 index 3375d421849..00000000000 --- a/gas/config/mh-i386 +++ /dev/null @@ -1 +0,0 @@ -ALLOCA=alloca.o diff --git a/gas/config/mips.mt b/gas/config/mips.mt deleted file mode 100644 index f40f51d2bfa..00000000000 --- a/gas/config/mips.mt +++ /dev/null @@ -1 +0,0 @@ -ALL=fake-as diff --git a/gas/config/obj-aout.c b/gas/config/obj-aout.c deleted file mode 100644 index 6c1e100425b..00000000000 --- a/gas/config/obj-aout.c +++ /dev/null @@ -1,500 +0,0 @@ -/* a.out object file format - Copyright (C) 1989, 1990, 1991 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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 1, -or (at your option) any later version. - -GAS 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 GAS; see the file COPYING. If not, write -to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* $Id$ */ - -#include "as.h" - -#include "obstack.h" - - /* in: segT out: N_TYPE bits */ -const short seg_N_TYPE[] = { - N_ABS, - N_TEXT, - N_DATA, - N_BSS, - N_UNDF, /* unknown */ - N_UNDF, /* absent */ - N_UNDF, /* pass1 */ - N_UNDF, /* error */ - N_UNDF, /* bignum/flonum */ - N_UNDF, /* difference */ - N_UNDF, /* debug */ - N_UNDF, /* ntv */ - N_UNDF, /* ptv */ - N_REGISTER, /* register */ -}; - -const segT N_TYPE_seg [N_TYPE+2] = { /* N_TYPE == 0x1E = 32-2 */ - SEG_UNKNOWN, /* N_UNDF == 0 */ - SEG_GOOF, - SEG_ABSOLUTE, /* N_ABS == 2 */ - SEG_GOOF, - SEG_TEXT, /* N_TEXT == 4 */ - SEG_GOOF, - SEG_DATA, /* N_DATA == 6 */ - SEG_GOOF, - SEG_BSS, /* N_BSS == 8 */ - SEG_GOOF, - SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, - SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, - SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, - SEG_REGISTER, /* dummy N_REGISTER for regs = 30 */ - SEG_GOOF, -}; - -#ifdef __STDC__ -static void obj_aout_stab(int what); -static void obj_aout_line(void); -static void obj_aout_desc(void); -#else /* __STDC__ */ -static void obj_aout_desc(); -static void obj_aout_stab(); -static void obj_aout_line(); -#endif /* __STDC__ */ - -const pseudo_typeS obj_pseudo_table[] = { - { "line", obj_aout_line, 0 }, /* source code line number */ - { "ln", obj_aout_line, 0 }, /* source code line number */ - { "desc", obj_aout_desc, 0 }, /* def */ - { "stabd", obj_aout_stab, 'd' }, /* stabs */ - { "stabn", obj_aout_stab, 'n' }, /* stabs */ - { "stabs", obj_aout_stab, 's' }, /* stabs */ - - { NULL} /* end sentinel */ -}; /* obj_pseudo_table */ - - -/* Relocation. */ - -/* - * In: length of relocation (or of address) in chars: 1, 2 or 4. - * Out: GNU LD relocation length code: 0, 1, or 2. - */ - -static unsigned char -nbytes_r_length [] = { - 42, 0, 1, 42, 2 - }; - -/* - * emit_relocations() - * - * Crawl along a fixS chain. Emit the segment's relocations. - */ -void obj_emit_relocations(where, fixP, segment_address_in_file) -char **where; -fixS *fixP; /* Fixup chain for this segment. */ -relax_addressT segment_address_in_file; -{ - struct reloc_info_generic ri; - register symbolS *symbolP; - - /* If a machine dependent emitter is needed, call it instead. */ - if (md_emit_relocations) { - (*md_emit_relocations) (fixP, segment_address_in_file); - return; - } - - /* JF this is for paranoia */ - bzero((char *)&ri,sizeof(ri)); - for (; fixP; fixP = fixP->fx_next) { - if ((symbolP = fixP->fx_addsy) != 0) { - ri.r_bsr = fixP->fx_bsr; - ri.r_disp = fixP->fx_im_disp; - ri.r_callj = fixP->fx_callj; - ri.r_length = nbytes_r_length [fixP->fx_size]; - ri.r_pcrel = fixP->fx_pcrel; - ri.r_address = fixP->fx_frag->fr_address + fixP->fx_where - segment_address_in_file; - - if (S_GET_TYPE(symbolP) == N_UNDF) { - ri.r_extern = 1; - ri.r_symbolnum = symbolP->sy_number; - } else { - ri.r_extern = 0; - ri.r_symbolnum = S_GET_TYPE(symbolP); - } - - /* Output the relocation information in machine-dependent form. */ - md_ri_to_chars(*where, &ri); - *where += md_reloc_size; - } /* if there is an add symbol */ - } /* for each fix */ - - return; -} /* emit_relocations() */ - -/* Aout file generation & utilities */ -void obj_header_append(where, headers) -char **where; -object_headers *headers; -{ - tc_headers_hook(headers); - -#ifdef CROSS_ASSEMBLE - md_number_to_chars(*where, headers->header.a_info, sizeof(headers->header.a_info)); - *where += sizeof(headers->header.a_info); - md_number_to_chars(*where, headers->header.a_text, sizeof(headers->header.a_text)); - *where += sizeof(headers->header.a_text); - md_number_to_chars(*where, headers->header.a_data, sizeof(headers->header.a_data)); - *where += sizeof(headers->header.a_data); - md_number_to_chars(*where, headers->header.a_bss, sizeof(headers->header.a_bss)); - *where += sizeof(headers->header.a_bss); - md_number_to_chars(*where, headers->header.a_syms, sizeof(headers->header.a_syms)); - *where += sizeof(headers->header.a_syms); - md_number_to_chars(*where, headers->header.a_entry, sizeof(headers->header.a_entry)); - *where += sizeof(headers->header.a_entry); - md_number_to_chars(*where, headers->header.a_trsize, sizeof(headers->header.a_trsize)); - *where += sizeof(headers->header.a_trsize); - md_number_to_chars(*where, headers->header.a_drsize, sizeof(headers->header.a_drsize)); - *where += sizeof(headers->header.a_drsize); -#ifdef EXEC_MACHINE_TYPE - md_number_to_chars(*where, headers->header.a_machtype, sizeof(headers->header.a_machtype)); - *where += sizeof(headers->header.a_machtype); -#endif /* EXEC_MACHINE_TYPE */ -#ifdef EXEC_VERSION - md_number_to_chars(*where, headers->header.a_version, sizeof(headers->header.a_version)); - *where += sizeof(headers->header.a_version); -#endif /* EXEC_VERSION */ - -#else /* CROSS_ASSEMBLE */ - - append(where, (char *) &headers->header, sizeof(headers->header)); -#endif /* CROSS_ASSEMBLE */ - - return; -} /* obj_append_header() */ - -void obj_symbol_to_chars(where, symbolP) -char **where; -symbolS *symbolP; -{ - md_number_to_chars((char *)&(S_GET_OFFSET(symbolP)), S_GET_OFFSET(symbolP), sizeof(S_GET_OFFSET(symbolP))); - md_number_to_chars((char *)&(S_GET_DESC(symbolP)), S_GET_DESC(symbolP), sizeof(S_GET_DESC(symbolP))); - md_number_to_chars((char *)&(S_GET_VALUE(symbolP)), S_GET_VALUE(symbolP), sizeof(S_GET_VALUE(symbolP))); - - append(where, (char *)&symbolP->sy_symbol, sizeof(obj_symbol_type)); -} /* obj_symbol_to_chars() */ - -void obj_emit_symbols(where, symbol_rootP) -char **where; -symbolS *symbol_rootP; -{ - symbolS * symbolP; - - /* - * Emit all symbols left in the symbol chain. - */ - for(symbolP = symbol_rootP; symbolP; symbolP = symbol_next(symbolP)) { - /* Used to save the offset of the name. It is used to point - to the string in memory but must be a file offset. */ - register char *temp; - - temp = S_GET_NAME(symbolP); - S_SET_OFFSET(symbolP, symbolP->sy_name_offset); - - /* Any symbol still undefined and is not a dbg symbol is made N_EXT. */ - if (!S_IS_DEBUG(symbolP) && !S_IS_DEFINED(symbolP)) S_SET_EXTERNAL(symbolP); - - obj_symbol_to_chars(where, symbolP); - S_SET_NAME(symbolP,temp); - } -} /* emit_symbols() */ - -void obj_symbol_new_hook(symbolP) -symbolS *symbolP; -{ - S_SET_OTHER(symbolP, 0); - S_SET_DESC(symbolP, 0); - return; -} /* obj_symbol_new_hook() */ - -static void obj_aout_line() { - /* Assume delimiter is part of expression. */ - /* BSD4.2 as fails with delightful bug, so we */ - /* are not being incompatible here. */ - new_logical_line((char *)NULL, (int)(get_absolute_expression())); - demand_empty_rest_of_line(); -} /* obj_aout_line() */ - -/* - * stab() - * - * Handle .stabX directives, which used to be open-coded. - * So much creeping featurism overloaded the semantics that we decided - * to put all .stabX thinking in one place. Here. - * - * We try to make any .stabX directive legal. Other people's AS will often - * do assembly-time consistency checks: eg assigning meaning to n_type bits - * and "protecting" you from setting them to certain values. (They also zero - * certain bits before emitting symbols. Tut tut.) - * - * If an expression is not absolute we either gripe or use the relocation - * information. Other people's assemblers silently forget information they - * don't need and invent information they need that you didn't supply. - * - * .stabX directives always make a symbol table entry. It may be junk if - * the rest of your .stabX directive is malformed. - */ -static void obj_aout_stab(what) -int what; -{ - register symbolS * symbolP = 0; - register char * string; - int saved_type = 0; - int length; - int goof; /* TRUE if we have aborted. */ - long longint; - -/* - * Enter with input_line_pointer pointing past .stabX and any following - * whitespace. - */ - goof = 0; /* JF who forgot this?? */ - if (what == 's') { - string = demand_copy_C_string(& length); - SKIP_WHITESPACE(); - if (* input_line_pointer == ',') - input_line_pointer ++; - else { - as_bad("I need a comma after symbol's name"); - goof = 1; - } - } else - string = ""; - -/* - * Input_line_pointer->after ','. String->symbol name. - */ - if (! goof) { - symbolP = symbol_new(string, - SEG_UNKNOWN, - 0, - (struct frag *)0); - switch (what) { - case 'd': - S_SET_NAME(symbolP, NULL); /* .stabd feature. */ - S_SET_VALUE(symbolP, obstack_next_free(&frags) - frag_now->fr_literal); - symbolP->sy_frag = frag_now; - break; - - case 'n': - symbolP->sy_frag = &zero_address_frag; - break; - - case 's': - symbolP->sy_frag = & zero_address_frag; - break; - - default: - BAD_CASE(what); - break; - } - - if (get_absolute_expression_and_terminator(&longint) == ',') - symbolP->sy_symbol.n_type = saved_type = longint; - else { - as_bad("I want a comma after the n_type expression"); - goof = 1; - input_line_pointer --; /* Backup over a non-',' char. */ - } - } - - if (!goof) { - if (get_absolute_expression_and_terminator(&longint) == ',') - S_SET_OTHER(symbolP, longint); - else { - as_bad("I want a comma after the n_other expression"); - goof = 1; - input_line_pointer--; /* Backup over a non-',' char. */ - } - } - - if (!goof) { - S_SET_DESC(symbolP, get_absolute_expression()); - if (what == 's' || what == 'n') { - if (*input_line_pointer != ',') { - as_bad("I want a comma after the n_desc expression"); - goof = 1; - } else { - input_line_pointer++; - } - } - } - - if ((!goof) && (what=='s' || what=='n')) { - pseudo_set(symbolP); - symbolP->sy_symbol.n_type = saved_type; - } - - if (goof) - ignore_rest_of_line(); - else - demand_empty_rest_of_line (); -} /* obj_aout_stab() */ - -static void obj_aout_desc() { - register char *name; - register char c; - register char *p; - register symbolS *symbolP; - register int temp; - - /* - * Frob invented at RMS' request. Set the n_desc of a symbol. - */ - name = input_line_pointer; - c = get_symbol_end(); - p = input_line_pointer; - * p = c; - SKIP_WHITESPACE(); - if (*input_line_pointer != ',') { - *p = 0; - as_bad("Expected comma after name \"%s\"", name); - *p = c; - ignore_rest_of_line(); - } else { - input_line_pointer ++; - temp = get_absolute_expression(); - *p = 0; - symbolP = symbol_find_or_make(name); - *p = c; - S_SET_DESC(symbolP,temp); - } - demand_empty_rest_of_line(); -} /* obj_aout_desc() */ - -void obj_read_begin_hook() { - return; -} /* obj_read_begin_hook() */ - -void obj_crawl_symbol_chain(headers) -object_headers *headers; -{ - symbolS *symbolP; - symbolS **symbolPP; - int symbol_number = 0; - - /* JF deal with forward references first... */ - for (symbolP = symbol_rootP; symbolP; symbolP = symbol_next(symbolP)) { - if (symbolP->sy_forward) { - S_SET_VALUE(symbolP, S_GET_VALUE(symbolP) - + S_GET_VALUE(symbolP->sy_forward) - + symbolP->sy_forward->sy_frag->fr_address); - - symbolP->sy_forward=0; - } /* if it has a forward reference */ - } /* walk the symbol chain */ - - tc_crawl_symbol_chain(headers); - - symbolPP = &symbol_rootP; /*->last symbol chain link. */ - while ((symbolP = *symbolPP) != NULL) { - if (flagseen['R'] && (S_GET_SEGMENT(symbolP) == SEG_DATA)) { - S_SET_SEGMENT(symbolP, SEG_TEXT); - } /* if pusing data into text */ - - S_SET_VALUE(symbolP, S_GET_VALUE(symbolP) + symbolP->sy_frag->fr_address); - - /* OK, here is how we decide which symbols go out into the - brave new symtab. Symbols that do are: - - * symbols with no name (stabd's?) - * symbols with debug info in their N_TYPE - - Symbols that don't are: - * symbols that are registers - * symbols with \1 as their 3rd character (numeric labels) - * "local labels" as defined by S_LOCAL_NAME(name) - if the -L switch was passed to gas. - - All other symbols are output. We complain if a deleted - symbol was marked external. */ - - - if (!S_IS_REGISTER(symbolP) - && (!S_GET_NAME(symbolP) - || S_IS_DEBUG(symbolP) -#ifdef TC_I960 - /* FIXME-SOON this ifdef seems highly dubious to me. xoxorich. */ - || !S_IS_DEFINED(symbolP) - || S_IS_EXTERNAL(symbolP) -#endif /* TC_I960 */ - || (S_GET_NAME(symbolP)[0] != '\001' && (flagseen ['L'] || ! S_LOCAL_NAME(symbolP))))) { - symbolP->sy_number = symbol_number++; - - /* The + 1 after strlen account for the \0 at the - end of each string */ - if (!S_IS_STABD(symbolP)) { - /* Ordinary case. */ - symbolP->sy_name_offset = string_byte_count; - string_byte_count += strlen(S_GET_NAME(symbolP)) + 1; - } - else /* .Stabd case. */ - symbolP->sy_name_offset = 0; - symbolPP = &(symbol_next(symbolP)); - } else { - if (S_IS_EXTERNAL(symbolP) || !S_IS_DEFINED(symbolP)) { - as_bad("Local symbol %s never defined", S_GET_NAME(symbolP)); - } /* oops. */ - - /* Unhook it from the chain */ - *symbolPP = symbol_next(symbolP); - } /* if this symbol should be in the output */ - } /* for each symbol */ - - H_SET_SYMBOL_TABLE_SIZE(headers, symbol_number); - - return; -} /* obj_crawl_symbol_chain() */ - -/* - * Find strings by crawling along symbol table chain. - */ - -void obj_emit_strings(where) -char **where; -{ - symbolS *symbolP; - -#ifdef CROSS_ASSEMBLE - /* Gotta do md_ byte-ordering stuff for string_byte_count first - KWK */ - md_number_to_chars(*where, string_byte_count, sizeof(string_byte_count)); - *where += sizeof(string_byte_count); -#else /* CROSS_ASSEMBLE */ - append (where, (char *)&string_byte_count, (unsigned long)sizeof(string_byte_count)); -#endif /* CROSS_ASSEMBLE */ - - for(symbolP = symbol_rootP; symbolP; symbolP = symbol_next(symbolP)) { - if(S_GET_NAME(symbolP)) - append(&next_object_file_charP, S_GET_NAME(symbolP), - (unsigned long)(strlen (S_GET_NAME(symbolP)) + 1)); - } /* walk symbol chain */ - - return; -} /* obj_emit_strings() */ - -/* - * Local Variables: - * comment-column: 0 - * fill-column: 131 - * End: - */ - -/* end of obj-aout.c */ diff --git a/gas/config/obj-aout.h b/gas/config/obj-aout.h deleted file mode 100644 index 44e2c3a5346..00000000000 --- a/gas/config/obj-aout.h +++ /dev/null @@ -1,210 +0,0 @@ -/* a.out object file format - Copyright (C) 1989, 1990, 1991 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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. - -GAS 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 GAS; see the file COPYING. If not, write -to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* $Id$ */ - -/* Tag to validate a.out object file format processing */ -#define OBJ_AOUT 1 - -#include "targ-cpu.h" - -#ifndef VMS -#include "a.out.gnu.h" /* Needed to define struct nlist. Sigh. */ -#else -#include "a_out.h" -#endif - -struct reloc_info_generic -{ - unsigned long r_address; -/* - * Using bit fields here is a bad idea because the order is not portable. :-( - */ - unsigned int r_index; -#define r_symbolnum r_index - unsigned r_extern : 1; - unsigned r_pcrel:1; - unsigned r_length:2; /* 0=>byte 1=>short 2=>long 3=>8byte */ - unsigned r_bsr:1; /* NS32K */ - unsigned r_disp:1; /* NS32k */ - unsigned r_callj:1; /* i960 */ - enum reloc_type r_type; - long r_addend; -}; - -extern const short seg_N_TYPE[]; -extern const segT N_TYPE_seg[]; - -#ifndef DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE -#define DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE (OMAGIC) -#endif /* DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE */ - -/* SYMBOL TABLE */ -/* Symbol table entry data type */ - -typedef struct nlist obj_symbol_type; /* Symbol table entry */ - -/* If compiler generate leading underscores, remove them. */ - -#ifndef STRIP_UNDERSCORE -#define STRIP_UNDERSCORE 0 -#endif /* STRIP_UNDERSCORE */ - -/* Symbol table macros and constants */ - -/* - * Macros to extract information from a symbol table entry. - * This syntaxic indirection allows independence regarding a.out or coff. - * The argument (s) of all these macros is a pointer to a symbol table entry. - */ - -/* True if the symbol is external */ -#define S_IS_EXTERNAL(s) ((s)->sy_symbol.n_type & N_EXT) - -/* True if symbol has been defined, ie is in N_{TEXT,DATA,BSS,ABS} or N_EXT */ -#define S_IS_DEFINED(s) ((S_GET_TYPE(s) != N_UNDF) || (S_GET_OTHER(s) != 0) || (S_GET_DESC(s) != 0)) - -#define S_IS_REGISTER(s) ((s)->sy_symbol.n_type == N_REGISTER) - -/* True if a debug special symbol entry */ -#define S_IS_DEBUG(s) ((s)->sy_symbol.n_type & N_STAB) -/* True if a symbol is local symbol name */ -/* A symbol name whose name begin with ^A is a gas internal pseudo symbol - nameless symbols come from .stab directives. */ -#define S_IS_LOCAL(s) (S_GET_NAME(s) && \ - !S_IS_DEBUG(s) && \ - (S_GET_NAME(s)[0] == '\001' || \ - (S_LOCAL_NAME(s) && !flagseen['L']))) -/* True if a symbol is not defined in this file */ -#define S_IS_EXTERN(s) ((s)->sy_symbol.n_type & N_EXT) -/* True if the symbol has been generated because of a .stabd directive */ -#define S_IS_STABD(s) (S_GET_NAME(s) == (char *)0) - -/* Accessors */ -/* The value of the symbol */ -#define S_GET_VALUE(s) (((s)->sy_symbol.n_value)) -/* The name of the symbol */ -#define S_GET_NAME(s) ((s)->sy_symbol.n_un.n_name) -/* The pointer to the string table */ -#define S_GET_OFFSET(s) ((s)->sy_symbol.n_un.n_strx) -/* The type of the symbol */ -#define S_GET_TYPE(s) ((s)->sy_symbol.n_type & N_TYPE) -/* The numeric value of the segment */ -#define S_GET_SEGMENT(s) (N_TYPE_seg[S_GET_TYPE(s)]) -/* The n_other expression value */ -#define S_GET_OTHER(s) ((s)->sy_symbol.n_other) -/* The n_desc expression value */ -#define S_GET_DESC(s) ((s)->sy_symbol.n_desc) - -/* Modifiers */ -/* Set the value of the symbol */ -#define S_SET_VALUE(s,v) ((s)->sy_symbol.n_value = (unsigned long) (v)) -/* Assume that a symbol cannot be simultaneously in more than on segment */ - /* set segment */ -#define S_SET_SEGMENT(s,seg) ((s)->sy_symbol.n_type &= ~N_TYPE,(s)->sy_symbol.n_type|=SEGMENT_TO_SYMBOL_TYPE(seg)) -/* The symbol is external */ -#define S_SET_EXTERNAL(s) ((s)->sy_symbol.n_type |= N_EXT) -/* The symbol is not external */ -#define S_CLEAR_EXTERNAL(s) ((s)->sy_symbol.n_type &= ~N_EXT) -/* Set the name of the symbol */ -#define S_SET_NAME(s,v) ((s)->sy_symbol.n_un.n_name = (v)) -/* Set the offset in the string table */ -#define S_SET_OFFSET(s,v) ((s)->sy_symbol.n_un.n_strx = (v)) -/* Set the n_other expression value */ -#define S_SET_OTHER(s,v) ((s)->sy_symbol.n_other = (v)) -/* Set the n_desc expression value */ -#define S_SET_DESC(s,v) ((s)->sy_symbol.n_desc = (v)) - -/* File header macro and type definition */ - -#define H_GET_FILE_SIZE(h) (H_GET_HEADER_SIZE(h) \ - + H_GET_TEXT_SIZE(h) \ - + H_GET_DATA_SIZE(h) \ - + H_GET_SYMBOL_TABLE_SIZE(h) \ - + H_GET_TEXT_RELOCATION_SIZE(h) \ - + H_GET_DATA_RELOCATION_SIZE(h) \ - + H_GET_STRING_SIZE(h)) - -#define H_GET_HEADER_SIZE(h) (sizeof(struct exec)) -#define H_GET_TEXT_SIZE(h) ((h)->header.a_text) -#define H_GET_DATA_SIZE(h) ((h)->header.a_data) -#define H_GET_BSS_SIZE(h) ((h)->header.a_bss) -#define H_GET_TEXT_RELOCATION_SIZE(h) ((h)->header.a_trsize) -#define H_GET_DATA_RELOCATION_SIZE(h) ((h)->header.a_drsize) -#define H_GET_SYMBOL_TABLE_SIZE(h) ((h)->header.a_syms) -#define H_GET_MAGIC_NUMBER(h) ((h)->header.a_info) -#define H_GET_ENTRY_POINT(h) ((h)->header.a_entry) -#define H_GET_STRING_SIZE(h) ((h)->string_table_size) -#define H_GET_LINENO_SIZE(h) (0) - -#ifdef EXEC_MACHINE_TYPE -#define H_GET_MACHINE_TYPE(h) ((h)->header.a_machtype) -#endif /* EXEC_MACHINE_TYPE */ - -#ifdef EXEC_VERSION -#define H_GET_VERSION(h) ((h)->header.a_version) -#endif /* EXEC_VERSION */ - -#define H_SET_TEXT_SIZE(h,v) ((h)->header.a_text = md_section_align(SEG_TEXT, (v))) -#define H_SET_DATA_SIZE(h,v) ((h)->header.a_data = md_section_align(SEG_DATA, (v))) -#define H_SET_BSS_SIZE(h,v) ((h)->header.a_bss = md_section_align(SEG_BSS, (v))) - -#define H_SET_RELOCATION_SIZE(h,t,d) (H_SET_TEXT_RELOCATION_SIZE((h),(t)),\ - H_SET_DATA_RELOCATION_SIZE((h),(d))) - -#define H_SET_TEXT_RELOCATION_SIZE(h,v) ((h)->header.a_trsize = (v)) -#define H_SET_DATA_RELOCATION_SIZE(h,v) ((h)->header.a_drsize = (v)) -#define H_SET_SYMBOL_TABLE_SIZE(h,v) ((h)->header.a_syms = (v) * \ - sizeof(struct nlist)) - -#define H_SET_MAGIC_NUMBER(h,v) ((h)->header.a_info = (v)) - -#define H_SET_ENTRY_POINT(h,v) ((h)->header.a_entry = (v)) -#define H_SET_STRING_SIZE(h,v) ((h)->string_table_size = (v)) -#ifdef EXEC_MACHINE_TYPE -#define H_SET_MACHINE_TYPE(h,v) ((h)->header.a_machtype = (v)) -#endif /* EXEC_MACHINE_TYPE */ -#ifdef EXEC_VERSION -#define H_SET_VERSION(h,v) ((h)->header.a_version = (v)) -#endif /* EXEC_VERSION */ - -/* - * Current means for getting the name of a segment. - * This will change for infinite-segments support (e.g. COFF). - */ -#define segment_name(seg) ( seg_name[(int)(seg)] ) -extern char *const seg_name[]; - -typedef struct { - struct exec header; /* a.out header */ - long string_table_size; /* names + '\0' + sizeof(int) */ -} object_headers; - -/* line numbering stuff. */ -#define OBJ_EMIT_LINENO(a, b, c) ; -#define obj_pre_write_hook(a) ; - -/* - * Local Variables: - * comment-column: 0 - * fill-column: 131 - * End: - */ - -/* end of obj-aout.h */ diff --git a/gas/config/obj-bfd-sunos.c b/gas/config/obj-bfd-sunos.c deleted file mode 100644 index 0bbc60088be..00000000000 --- a/gas/config/obj-bfd-sunos.c +++ /dev/null @@ -1,51 +0,0 @@ -#include "as.h" - -static - -const short seg_N_TYPE[] = { - N_ABS, - N_TEXT, - N_DATA, - N_BSS, - N_UNDF, /* unknown */ - N_UNDF, /* absent */ - N_UNDF, /* pass1 */ - N_UNDF, /* error */ - N_UNDF, /* bignum/flonum */ - N_UNDF, /* difference */ - N_REGISTER, /* register */ -}; - -const segT N_TYPE_seg [N_TYPE+2] = { /* N_TYPE == 0x1E = 32-2 */ - SEG_UNKNOWN, /* N_UNDF == 0 */ - SEG_GOOF, - SEG_ABSOLUTE, /* N_ABS == 2 */ - SEG_GOOF, - SEG_TEXT, /* N_TEXT == 4 */ - SEG_GOOF, - SEG_DATA, /* N_DATA == 6 */ - SEG_GOOF, - SEG_BSS, /* N_BSS == 8 */ - SEG_GOOF, - SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, - SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, - SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, - SEG_REGISTER, /* dummy N_REGISTER for regs = 30 */ - SEG_GOOF, -}; - - -void obj_symbol_new_hook(symbolP) -symbolS *symbolP; -{ - return; -} /* obj_symbol_new_hook() */ - -/* - * Local Variables: - * comment-column: 0 - * fill-column: 131 - * End: - */ - -/* end of obj-bfd-sunos.c */ diff --git a/gas/config/obj-bfd-sunos.h b/gas/config/obj-bfd-sunos.h deleted file mode 100644 index 0d3275883dd..00000000000 --- a/gas/config/obj-bfd-sunos.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * This file is obj-bfd-sunos.h. - */ - - /* define an obj specific macro off which target cpu back ends may key. */ -#define OBJ_BFD -#define OBJ_BFD_SUNOS - -#include "bfd.h" - - /* include whatever target cpu is appropriate. */ -#include "targ-cpu.h" - -/* - * SYMBOLS - */ - -/* - * If your object format needs to reorder symbols, define this. When - * defined, symbols are kept on a doubly linked list and functions are - * made available for push, insert, append, and delete. If not defined, - * symbols are kept on a singly linked list, only the append and clear - * facilities are available, and they are macros. - */ - - /* #define SYMBOLS_NEED_PACKPOINTERS */ - -typedef asymbol obj_symbol_type; -typedef void *object_headers; - -#define S_SET_NAME(s, v) ((s)->sy_symbol.name = (v)) -#define S_GET_NAME(s) ((s)->sy_symbol.name) -#define S_SET_SEGMENT(s,v) ((s)->sy_symbol.udata = (v)) -#define S_GET_SEGMENT(s) ((s)->sy_symbol.udata) -#define S_SET_EXTERNAL(s) ((s)->sy_symbol.flags |= BSF_GLOBAL) -#define S_SET_VALUE(s,v) ((s)->sy_symbol.value = (v)) -#define S_GET_VALUE(s) ((s)->sy_symbol.value) -#define S_IS_DEFINED(s) (!((s)->sy_symbol.flags & BSF_UNDEFINED)) - -#define DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE (0) /* your magic number */ -#define OBJ_EMIT_LINENO(a,b,c) /* must be *something*. This no-op's it out. */ - -/* - * Local Variables: - * comment-column: 0 - * fill-column: 131 - * End: - */ - -/* end of obj-bfd-sunos.h */ diff --git a/gas/config/obj-bout.c b/gas/config/obj-bout.c deleted file mode 100644 index 883859cb9c6..00000000000 --- a/gas/config/obj-bout.c +++ /dev/null @@ -1,448 +0,0 @@ -/* b.out object file format - Copyright (C) 1989, 1990, 1991 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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. - -GAS 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 GAS; see the file COPYING. If not, write -to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* $Id$ */ - -#include "as.h" -#include "obstack.h" - -const short /* in: segT out: N_TYPE bits */ -seg_N_TYPE[] = { - N_ABS, - N_TEXT, - N_DATA, - N_BSS, - N_UNDF, /* unknown */ - N_UNDF, /* absent */ - N_UNDF, /* pass1 */ - N_UNDF, /* error */ - N_UNDF, /* bignum/flonum */ - N_UNDF, /* difference */ - N_REGISTER, /* register */ -}; - -const segT N_TYPE_seg [N_TYPE+2] = { /* N_TYPE == 0x1E = 32-2 */ - SEG_UNKNOWN, /* N_UNDF == 0 */ - SEG_GOOF, - SEG_ABSOLUTE, /* N_ABS == 2 */ - SEG_GOOF, - SEG_TEXT, /* N_TEXT == 4 */ - SEG_GOOF, - SEG_DATA, /* N_DATA == 6 */ - SEG_GOOF, - SEG_BSS, /* N_BSS == 8 */ - SEG_GOOF, - SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, - SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, - SEG_GOOF, SEG_GOOF, SEG_GOOF, SEG_GOOF, - SEG_REGISTER, /* dummy N_REGISTER for regs = 30 */ - SEG_GOOF, -}; - -#ifdef __STDC__ -static void obj_bout_stab(int what); -static void obj_bout_line(void); -static void obj_bout_desc(void); -#else /* __STDC__ */ -static void obj_bout_desc(); -static void obj_bout_stab(); -static void obj_bout_line(); -#endif /* __STDC__ */ - -const pseudo_typeS obj_pseudo_table[] = { - /* stabs (aka a.out aka b.out directives for debug symbols) */ - { "desc", obj_bout_desc, 0 }, /* def */ - { "line", obj_bout_line, 0 }, /* source code line number */ - { "stabd", obj_bout_stab, 'd' }, /* stabs */ - { "stabn", obj_bout_stab, 'n' }, /* stabs */ - { "stabs", obj_bout_stab, 's' }, /* stabs */ - - /* coff debugging directives. Currently ignored silently */ - { "def", s_ignore, 0 }, - { "dim", s_ignore, 0 }, - { "endef", s_ignore, 0 }, - { "ln", s_ignore, 0 }, - { "scl", s_ignore, 0 }, - { "size", s_ignore, 0 }, - { "tag", s_ignore, 0 }, - { "type", s_ignore, 0 }, - { "val", s_ignore, 0 }, - - /* other stuff we don't handle */ - { "ABORT", s_ignore, 0 }, - { "ident", s_ignore, 0 }, - - { NULL} /* end sentinel */ -}; /* obj_pseudo_table */ - -/* Relocation. */ - -/* - * emit_relocations() - * - * Crawl along a fixS chain. Emit the segment's relocations. - */ -void obj_emit_relocations(where, fixP, segment_address_in_file) -char **where; -fixS *fixP; /* Fixup chain for this segment. */ -relax_addressT segment_address_in_file; -{ - for (; fixP; fixP = fixP->fx_next) { - if (fixP->fx_addsy != NULL) { - tc_bout_fix_to_chars(*where, fixP, segment_address_in_file); - *where += sizeof(struct relocation_info); - } /* if there's a symbol */ - } /* for each fixup */ - -} /* emit_relocations() */ - -/* Aout file generation & utilities */ - -/* Convert a lvalue to machine dependent data */ -void obj_header_append(where, headers) -char **where; -object_headers *headers; -{ - /* Always leave in host byte order */ - - headers->header.a_talign = section_alignment[SEG_TEXT]; - - if (headers->header.a_talign < 2){ - headers->header.a_talign = 2; - } /* force to at least 2 */ - - headers->header.a_dalign = section_alignment[SEG_DATA]; - headers->header.a_balign = section_alignment[SEG_BSS]; - - headers->header.a_tload = 0; - headers->header.a_dload = md_section_align(SEG_DATA, H_GET_TEXT_SIZE(headers)); - - append(where, (char *) &headers->header, sizeof(headers->header)); -} /* a_header_append() */ - -void obj_symbol_to_chars(where, symbolP) -char **where; -symbolS *symbolP; -{ - /* leave in host byte order */ - append(where, (char *)&symbolP->sy_symbol, sizeof(obj_symbol_type)); -} /* obj_symbol_to_chars() */ - -void obj_emit_symbols(where, symbol_rootP) -char **where; -symbolS *symbol_rootP; -{ - symbolS * symbolP; - - /* - * Emit all symbols left in the symbol chain. - */ - for(symbolP = symbol_rootP; symbolP; symbolP = symbol_next(symbolP)) { - /* Used to save the offset of the name. It is used to point - to the string in memory but must be a file offset. */ - char *temp; - - temp = S_GET_NAME(symbolP); - S_SET_OFFSET(symbolP, symbolP->sy_name_offset); - - /* Any symbol still undefined and is not a dbg symbol is made N_EXT. */ - if (!S_IS_DEBUG(symbolP) && !S_IS_DEFINED(symbolP)) S_SET_EXTERNAL(symbolP); - - obj_symbol_to_chars(where, symbolP); - S_SET_NAME(symbolP,temp); - } -} /* emit_symbols() */ - -void obj_symbol_new_hook(symbolP) -symbolS *symbolP; -{ - S_SET_OTHER(symbolP, 0); - S_SET_DESC(symbolP, 0); - return; -} /* obj_symbol_new_hook() */ - -static void obj_bout_line() { - /* Assume delimiter is part of expression. */ - /* BSD4.2 as fails with delightful bug, so we */ - /* are not being incompatible here. */ - new_logical_line ((char *)NULL, (int)(get_absolute_expression ())); - demand_empty_rest_of_line(); -} /* obj_bout_line() */ - -/* - * stab() - * - * Handle .stabX directives, which used to be open-coded. - * So much creeping featurism overloaded the semantics that we decided - * to put all .stabX thinking in one place. Here. - * - * We try to make any .stabX directive legal. Other people's AS will often - * do assembly-time consistency checks: eg assigning meaning to n_type bits - * and "protecting" you from setting them to certain values. (They also zero - * certain bits before emitting symbols. Tut tut.) - * - * If an expression is not absolute we either gripe or use the relocation - * information. Other people's assemblers silently forget information they - * don't need and invent information they need that you didn't supply. - * - * .stabX directives always make a symbol table entry. It may be junk if - * the rest of your .stabX directive is malformed. - */ -static void obj_bout_stab(what) -int what; -{ - register symbolS * symbolP = 0; - register char * string; - int saved_type = 0; - int length; - int goof; /* TRUE if we have aborted. */ - long longint; - -/* - * Enter with input_line_pointer pointing past .stabX and any following - * whitespace. - */ - goof = 0; /* JF who forgot this?? */ - if (what == 's') { - string = demand_copy_C_string(& length); - SKIP_WHITESPACE(); - if (*input_line_pointer == ',') - input_line_pointer ++; - else { - as_bad("I need a comma after symbol's name"); - goof = 1; - } - } else - string = ""; - -/* - * Input_line_pointer->after ','. String->symbol name. - */ - if (!goof) { - symbolP = symbol_new(string, - SEG_UNKNOWN, - 0, - (struct frag *)0); - switch (what) { - case 'd': - S_SET_NAME(symbolP,NULL); /* .stabd feature. */ - S_SET_VALUE(symbolP,obstack_next_free(&frags) - - frag_now->fr_literal); - symbolP->sy_frag = frag_now; - break; - - case 'n': - symbolP->sy_frag = &zero_address_frag; - break; - - case 's': - symbolP->sy_frag = & zero_address_frag; - break; - - default: - BAD_CASE(what); - break; - } - if (get_absolute_expression_and_terminator(& longint) == ',') - symbolP->sy_symbol.n_type = saved_type = longint; - else { - as_bad("I want a comma after the n_type expression"); - goof = 1; - input_line_pointer--; /* Backup over a non-',' char. */ - } - } - if (! goof) { - if (get_absolute_expression_and_terminator (& longint) == ',') - S_SET_OTHER(symbolP,longint); - else { - as_bad("I want a comma after the n_other expression"); - goof = 1; - input_line_pointer--; /* Backup over a non-',' char. */ - } - } - if (! goof) { - S_SET_DESC(symbolP, get_absolute_expression ()); - if (what == 's' || what == 'n') { - if (* input_line_pointer != ',') { - as_bad("I want a comma after the n_desc expression"); - goof = 1; - } else { - input_line_pointer ++; - } - } - } - if ((! goof) && (what=='s' || what=='n')) { - pseudo_set(symbolP); - symbolP->sy_symbol.n_type = saved_type; - } - if (goof) - ignore_rest_of_line (); - else - demand_empty_rest_of_line (); -} /* obj_bout_stab() */ - -static void obj_bout_desc() { - register char *name; - register char c; - register char *p; - register symbolS * symbolP; - register int temp; - - /* - * Frob invented at RMS' request. Set the n_desc of a symbol. - */ - name = input_line_pointer; - c = get_symbol_end(); - p = input_line_pointer; - * p = c; - SKIP_WHITESPACE(); - if (*input_line_pointer != ',') { - *p = 0; - as_bad("Expected comma after name \"%s\"", name); - *p = c; - ignore_rest_of_line(); - } else { - input_line_pointer ++; - temp = get_absolute_expression (); - *p = 0; - symbolP = symbol_find_or_make(name); - *p = c; - S_SET_DESC(symbolP,temp); - } - demand_empty_rest_of_line(); -} /* obj_bout_desc() */ - -void obj_read_begin_hook() { - return; -} /* obj_read_begin_hook() */ - -void obj_crawl_symbol_chain(headers) -object_headers *headers; -{ - symbolS **symbolPP; - symbolS *symbolP; - int symbol_number = 0; - - /* JF deal with forward references first... */ - for (symbolP = symbol_rootP; symbolP; symbolP = symbol_next(symbolP)) { - if (symbolP->sy_forward) { - S_SET_VALUE(symbolP, S_GET_VALUE(symbolP) - + S_GET_VALUE(symbolP->sy_forward) - + symbolP->sy_forward->sy_frag->fr_address); - - symbolP->sy_forward=0; - } /* if it has a forward reference */ - } /* walk the symbol chain */ - - tc_crawl_symbol_chain(headers); - - symbolPP = & symbol_rootP; /*->last symbol chain link. */ - while ((symbolP = *symbolPP) != NULL) { - if (flagseen['R'] && (S_GET_SEGMENT(symbolP) == SEG_DATA)) { - S_SET_SEGMENT(symbolP, SEG_TEXT); - } /* if pusing data into text */ - - S_SET_VALUE(symbolP, S_GET_VALUE(symbolP) + symbolP->sy_frag->fr_address); - - /* OK, here is how we decide which symbols go out into the - brave new symtab. Symbols that do are: - - * symbols with no name (stabd's?) - * symbols with debug info in their N_TYPE - - Symbols that don't are: - * symbols that are registers - * symbols with \1 as their 3rd character (numeric labels) - * "local labels" as defined by S_LOCAL_NAME(name) - if the -L switch was passed to gas. - - All other symbols are output. We complain if a deleted - symbol was marked external. */ - - - if (1 - && !S_IS_REGISTER(symbolP) - && (!S_GET_NAME(symbolP) - || S_IS_DEBUG(symbolP) -#ifdef TC_I960 - /* FIXME-SOON this ifdef seems highly dubious to me. xoxorich. */ - || !S_IS_DEFINED(symbolP) - || S_IS_EXTERNAL(symbolP) -#endif /* TC_I960 */ - || (S_GET_NAME(symbolP)[0] != '\001' && (flagseen ['L'] || ! S_LOCAL_NAME(symbolP))))) { - symbolP->sy_number = symbol_number++; - - /* The + 1 after strlen account for the \0 at the - end of each string */ - if (!S_IS_STABD(symbolP)) { - /* Ordinary case. */ - symbolP->sy_name_offset = string_byte_count; - string_byte_count += strlen(S_GET_NAME(symbolP)) + 1; - } - else /* .Stabd case. */ - symbolP->sy_name_offset = 0; - symbolPP = &(symbol_next(symbolP)); - } else { - if (S_IS_EXTERNAL(symbolP) || !S_IS_DEFINED(symbolP)) { - as_bad("Local symbol %s never defined", S_GET_NAME(symbolP)); - } /* oops. */ - - /* Unhook it from the chain */ - *symbolPP = symbol_next(symbolP); - } /* if this symbol should be in the output */ - } /* for each symbol */ - - H_SET_SYMBOL_TABLE_SIZE(headers, symbol_number); - - return; -} /* obj_crawl_symbol_chain() */ - -/* - * Find strings by crawling along symbol table chain. - */ - -void obj_emit_strings(where) -char **where; -{ - symbolS *symbolP; - -#ifdef CROSS_COMPILE - /* Gotta do md_ byte-ordering stuff for string_byte_count first - KWK */ - md_number_to_chars(*where, string_byte_count, sizeof(string_byte_count)); - *where += sizeof(string_byte_count); -#else /* CROSS_COMPILE */ - append(where, (char *) &string_byte_count, (unsigned long) sizeof(string_byte_count)); -#endif /* CROSS_COMPILE */ - - for(symbolP = symbol_rootP; symbolP; symbolP = symbol_next(symbolP)) { - if(S_GET_NAME(symbolP)) - append(where, S_GET_NAME(symbolP), (unsigned long)(strlen (S_GET_NAME(symbolP)) + 1)); - } /* walk symbol chain */ - - return; -} /* obj_emit_strings() */ - -/* - * Local Variables: - * comment-column: 0 - * fill-column: 131 - * End: - */ - -/* end of obj-bout.c */ diff --git a/gas/config/obj-bout.h b/gas/config/obj-bout.h deleted file mode 100644 index 272c0c4f460..00000000000 --- a/gas/config/obj-bout.h +++ /dev/null @@ -1,316 +0,0 @@ -/* b.out object file format - Copyright (C) 1989, 1990, 1991 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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. - -GAS 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 GAS; see the file COPYING. If not, write -to the Free Software Foundation, 675 Mass Ave, Cambridge, MA -02139, USA. */ - -/* $Id$ */ - -/* - * This file is a modified version of 'a.out.h'. It is to be used in all GNU - * tools modified to support the i80960 b.out format (or tools that operate on - * object files created by such tools). - * - * All i80960 development is done in a CROSS-DEVELOPMENT environment. I.e., - * object code is generated on, and executed under the direction of a symbolic - * debugger running on, a host system. We do not want to be subject to the - * vagaries of which host it is or whether it supports COFF or a.out format, or - * anything else. We DO want to: - * - * o always generate the same format object files, regardless of host. - * - * o have an 'a.out' header that we can modify for our own purposes - * (the 80960 is typically an embedded processor and may require - * enhanced linker support that the normal a.out.h header can't - * accommodate). - * - * As for byte-ordering, the following rules apply: - * - * o Text and data that is actually downloaded to the target is always - * in i80960 (little-endian) order. - * - * o All other numbers (in the header, symbols, relocation directives) - * are in host byte-order: object files CANNOT be lifted from a - * little-end host and used on a big-endian (or vice versa) without - * modification. - * - * o The downloader ('comm960') takes care to generate a pseudo-header - * with correct (i80960) byte-ordering before shipping text and data - * off to the NINDY monitor in the target systems. Symbols and - * relocation info are never sent to the target. - */ - - -#define OBJ_BOUT 1 - -#include "targ-cpu.h" - - /* bout uses host byte order for headers */ -#ifdef CROSS_COMPILE -#undef CROSS_COMPILE -#endif /* CROSS_COMPILE */ - - /* We want \v. */ -#define BACKSLASH_V 1 - -#define OBJ_DEFAULT_OUTPUT_FILE_NAME "b.out" - -extern const short seg_N_TYPE[]; -extern const segT N_TYPE_seg[]; - -#define BMAGIC 0415 -/* We don't accept the following (see N_BADMAG macro). - * They're just here so GNU code will compile. - */ -#define OMAGIC 0407 /* old impure format */ -#define NMAGIC 0410 /* read-only text */ -#define ZMAGIC 0413 /* demand load format */ - -#ifndef DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE -#define DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE (BMAGIC) -#endif /* DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE */ - -/* FILE HEADER - * All 'lengths' are given as a number of bytes. - * All 'alignments' are for relinkable files only; an alignment of - * 'n' indicates the corresponding segment must begin at an - * address that is a multiple of (2**n). - */ -struct exec { - /* Standard stuff */ - unsigned long a_magic; /* Identifies this as a b.out file */ - unsigned long a_text; /* Length of text */ - unsigned long a_data; /* Length of data */ - unsigned long a_bss; /* Length of runtime uninitialized data area */ - unsigned long a_syms; /* Length of symbol table */ - unsigned long a_entry; /* Runtime start address */ - unsigned long a_trsize; /* Length of text relocation info */ - unsigned long a_drsize; /* Length of data relocation info */ - - /* Added for i960 */ - unsigned long a_tload; /* Text runtime load address */ - unsigned long a_dload; /* Data runtime load address */ - unsigned char a_talign; /* Alignment of text segment */ - unsigned char a_dalign; /* Alignment of data segment */ - unsigned char a_balign; /* Alignment of bss segment */ - unsigned char unused; /* (Just to make struct size a multiple of 4) */ -}; - -#define N_BADMAG(x) (((x).a_magic)!=BMAGIC) -#define N_TXTOFF(x) ( sizeof(struct exec) ) -#define N_DATOFF(x) ( N_TXTOFF(x) + (x).a_text ) -#define N_TROFF(x) ( N_DATOFF(x) + (x).a_data ) -#define N_DROFF(x) ( N_TROFF(x) + (x).a_trsize ) -#define N_SYMOFF(x) ( N_DROFF(x) + (x).a_drsize ) -#define N_STROFF(x) ( N_SYMOFF(x) + (x).a_syms ) - -/* A single entry in the symbol table - */ -struct nlist { - union { - char *n_name; - struct nlist *n_next; - long n_strx; /* Index into string table */ - } n_un; - unsigned char n_type; /* See below */ - char n_other; /* Used in i80960 support -- see below */ - short n_desc; - unsigned long n_value; -}; - -typedef struct nlist obj_symbol_type; - -/* Legal values of n_type - */ -#define N_UNDF 0 /* Undefined symbol */ -#define N_ABS 2 /* Absolute symbol */ -#define N_TEXT 4 /* Text symbol */ -#define N_DATA 6 /* Data symbol */ -#define N_BSS 8 /* BSS symbol */ -#define N_FN 31 /* Filename symbol */ - -#define N_EXT 1 /* External symbol (OR'd in with one of above) */ -#define N_TYPE 036 /* Mask for all the type bits */ -#define N_STAB 0340 /* Mask for all bits used for SDB entries */ - -#ifndef CUSTOM_RELOC_FORMAT -struct relocation_info { - int r_address; /* File address of item to be relocated */ - unsigned - r_index:24,/* Index of symbol on which relocation is based*/ - r_pcrel:1, /* 1 => relocate PC-relative; else absolute - * On i960, pc-relative implies 24-bit - * address, absolute implies 32-bit. - */ - r_length:2, /* Number of bytes to relocate: - * 0 => 1 byte - * 1 => 2 bytes - * 2 => 4 bytes -- only value used for i960 - */ - r_extern:1, - r_bsr:1, /* Something for the GNU NS32K assembler */ - r_disp:1, /* Something for the GNU NS32K assembler */ - r_callj:1, /* 1 if relocation target is an i960 'callj' */ - nuthin:1; /* Unused */ -}; -#endif /* CUSTOM_RELOC_FORMAT */ - -/* - * Macros to extract information from a symbol table entry. - * This syntaxic indirection allows independence regarding a.out or coff. - * The argument (s) of all these macros is a pointer to a symbol table entry. - */ - -/* Predicates */ -/* True if the symbol is external */ -#define S_IS_EXTERNAL(s) ((s)->sy_symbol.n_type & N_EXT) - -/* True if symbol has been defined, ie is in N_{TEXT,DATA,BSS,ABS} or N_EXT */ -#define S_IS_DEFINED(s) ((S_GET_TYPE(s) != N_UNDF) || (S_GET_DESC(s) != 0)) -#define S_IS_REGISTER(s) ((s)->sy_symbol.n_type == N_REGISTER) - -/* True if a debug special symbol entry */ -#define S_IS_DEBUG(s) ((s)->sy_symbol.n_type & N_STAB) -/* True if a symbol is local symbol name */ -/* A symbol name whose name begin with ^A is a gas internal pseudo symbol - nameless symbols come from .stab directives. */ -#define S_IS_LOCAL(s) (S_GET_NAME(s) && \ - !S_IS_DEBUG(s) && \ - (S_GET_NAME(s)[0] == '\001' || \ - (S_LOCAL_NAME(s) && !flagseen['L']))) -/* True if a symbol is not defined in this file */ -#define S_IS_EXTERN(s) ((s)->sy_symbol.n_type & N_EXT) -/* True if the symbol has been generated because of a .stabd directive */ -#define S_IS_STABD(s) (S_GET_NAME(s) == NULL) - -/* Accessors */ -/* The value of the symbol */ -#define S_GET_VALUE(s) ((unsigned long) ((s)->sy_symbol.n_value)) -/* The name of the symbol */ -#define S_GET_NAME(s) ((s)->sy_symbol.n_un.n_name) -/* The pointer to the string table */ -#define S_GET_OFFSET(s) ((s)->sy_symbol.n_un.n_strx) -/* The type of the symbol */ -#define S_GET_TYPE(s) ((s)->sy_symbol.n_type & N_TYPE) -/* The numeric value of the segment */ -#define S_GET_SEGMENT(s) (N_TYPE_seg[S_GET_TYPE(s)]) -/* The n_other expression value */ -#define S_GET_OTHER(s) ((s)->sy_symbol.n_other) -/* The n_desc expression value */ -#define S_GET_DESC(s) ((s)->sy_symbol.n_desc) - -/* Modifiers */ -/* Set the value of the symbol */ -#define S_SET_VALUE(s,v) ((s)->sy_symbol.n_value = (unsigned long) (v)) -/* Assume that a symbol cannot be simultaneously in more than on segment */ - /* set segment */ -#define S_SET_SEGMENT(s,seg) ((s)->sy_symbol.n_type &= ~N_TYPE,(s)->sy_symbol.n_type|=SEGMENT_TO_SYMBOL_TYPE(seg)) -/* The symbol is external */ -#define S_SET_EXTERNAL(s) ((s)->sy_symbol.n_type |= N_EXT) -/* The symbol is not external */ -#define S_CLEAR_EXTERNAL(s) ((s)->sy_symbol.n_type &= ~N_EXT) -/* Set the name of the symbol */ -#define S_SET_NAME(s,v) ((s)->sy_symbol.n_un.n_name = (v)) -/* Set the offset in the string table */ -#define S_SET_OFFSET(s,v) ((s)->sy_symbol.n_un.n_strx = (v)) -/* Set the n_other expression value */ -#define S_SET_OTHER(s,v) ((s)->sy_symbol.n_other = (v)) -/* Set the n_desc expression value */ -#define S_SET_DESC(s,v) ((s)->sy_symbol.n_desc = (v)) - -/* File header macro and type definition */ - -#define H_GET_FILE_SIZE(h) (sizeof(struct exec) + \ - H_GET_TEXT_SIZE(h) + H_GET_DATA_SIZE(h) + \ - H_GET_SYMBOL_TABLE_SIZE(h) + \ - H_GET_TEXT_RELOCATION_SIZE(h) + \ - H_GET_DATA_RELOCATION_SIZE(h) + \ - (h)->string_table_size) - -#define H_GET_HEADER_SIZE(h) (sizeof(struct exec)) -#define H_GET_TEXT_SIZE(h) ((h)->header.a_text) -#define H_GET_DATA_SIZE(h) ((h)->header.a_data) -#define H_GET_BSS_SIZE(h) ((h)->header.a_bss) -#define H_GET_TEXT_RELOCATION_SIZE(h) ((h)->header.a_trsize) -#define H_GET_DATA_RELOCATION_SIZE(h) ((h)->header.a_drsize) -#define H_GET_SYMBOL_TABLE_SIZE(h) ((h)->header.a_syms) -#define H_GET_MAGIC_NUMBER(h) ((h)->header.a_info) -#define H_GET_ENTRY_POINT(h) ((h)->header.a_entry) -#define H_GET_STRING_SIZE(h) ((h)->string_table_size) -#define H_GET_LINENO_SIZE(h) (0) - -#ifdef EXEC_MACHINE_TYPE -#define H_GET_MACHINE_TYPE(h) ((h)->header.a_machtype) -#endif /* EXEC_MACHINE_TYPE */ -#ifdef EXEC_VERSION -#define H_GET_VERSION(h) ((h)->header.a_version) -#endif /* EXEC_VERSION */ - -#define H_SET_TEXT_SIZE(h,v) ((h)->header.a_text = (v)) -#define H_SET_DATA_SIZE(h,v) ((h)->header.a_data = (v)) -#define H_SET_BSS_SIZE(h,v) ((h)->header.a_bss = (v)) - -#define H_SET_RELOCATION_SIZE(h,t,d) (H_SET_TEXT_RELOCATION_SIZE((h),(t)),\ - H_SET_DATA_RELOCATION_SIZE((h),(d))) - -#define H_SET_TEXT_RELOCATION_SIZE(h,v) ((h)->header.a_trsize = (v)) -#define H_SET_DATA_RELOCATION_SIZE(h,v) ((h)->header.a_drsize = (v)) -#define H_SET_SYMBOL_TABLE_SIZE(h,v) ((h)->header.a_syms = (v) * \ - sizeof(struct nlist)) - -#define H_SET_MAGIC_NUMBER(h,v) ((h)->header.a_magic = (v)) - -#define H_SET_ENTRY_POINT(h,v) ((h)->header.a_entry = (v)) -#define H_SET_STRING_SIZE(h,v) ((h)->string_table_size = (v)) -#ifdef EXEC_MACHINE_TYPE -#define H_SET_MACHINE_TYPE(h,v) ((h)->header.a_machtype = (v)) -#endif /* EXEC_MACHINE_TYPE */ -#ifdef EXEC_VERSION -#define H_SET_VERSION(h,v) ((h)->header.a_version = (v)) -#endif /* EXEC_VERSION */ - -/* - * Current means for getting the name of a segment. - * This will change for infinite-segments support (e.g. COFF). - */ -#define segment_name(seg) ( seg_name[(int)(seg)] ) -extern char *const seg_name[]; - -typedef struct { - struct exec header; /* a.out header */ - long string_table_size; /* names + '\0' + sizeof(int) */ -} object_headers; - -/* unused hooks. */ -#define OBJ_EMIT_LINENO(a, b, c) {;} -#define obj_pre_write_hook(a) {;} - -#ifdef __STDC__ -struct fix; -void tc_aout_fix_to_chars(char *where, struct fix *fixP, relax_addressT segment_address); -#else -void tc_aout_fix_to_chars(); -#endif /* __STDC__ */ - -/* - * Local Variables: - * comment-column: 0 - * fill-column: 131 - * End: - */ - -/* end of obj-bout.h */ diff --git a/gas/config/obj-coff.c b/gas/config/obj-coff.c deleted file mode 100644 index b157acca332..00000000000 --- a/gas/config/obj-coff.c +++ /dev/null @@ -1,1915 +0,0 @@ -/* coff object file format - Copyright (C) 1989, 1990, 1991 Free Software Foundation, Inc. - -This file is part of GAS. - -GAS 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. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* $Id$ */ - -#include "as.h" - -#include "obstack.h" - -lineno* lineno_rootP; - -const short seg_N_TYPE[] = { /* in: segT out: N_TYPE bits */ - C_ABS_SECTION, - C_TEXT_SECTION, - C_DATA_SECTION, - C_BSS_SECTION, - C_UNDEF_SECTION, /* SEG_UNKNOWN */ - C_UNDEF_SECTION, /* SEG_ABSENT */ - C_UNDEF_SECTION, /* SEG_PASS1 */ - C_UNDEF_SECTION, /* SEG_GOOF */ - C_UNDEF_SECTION, /* SEG_BIG */ - C_UNDEF_SECTION, /* SEG_DIFFERENCE */ - C_DEBUG_SECTION, /* SEG_DEBUG */ - C_NTV_SECTION, /* SEG_NTV */ - C_PTV_SECTION, /* SEG_PTV */ - C_REGISTER_SECTION, /* SEG_REGISTER */ -}; - - -/* Add 4 to the real value to get the index and compensate the negatives */ - -const segT N_TYPE_seg [32] = -{ - SEG_PTV, /* C_PTV_SECTION == -4 */ - SEG_NTV, /* C_NTV_SECTION == -3 */ - SEG_DEBUG, /* C_DEBUG_SECTION == -2 */ - SEG_ABSOLUTE, /* C_ABS_SECTION == -1 */ - SEG_UNKNOWN, /* C_UNDEF_SECTION == 0 */ - SEG_TEXT, /* C_TEXT_SECTION == 1 */ - SEG_DATA, /* C_DATA_SECTION == 2 */ - SEG_BSS, /* C_BSS_SECTION == 3 */ - SEG_REGISTER, /* C_REGISTER_SECTION == 4 */ - SEG_GOOF,SEG_GOOF,SEG_GOOF,SEG_GOOF,SEG_GOOF,SEG_GOOF,SEG_GOOF,SEG_GOOF, - SEG_GOOF,SEG_GOOF,SEG_GOOF,SEG_GOOF,SEG_GOOF,SEG_GOOF,SEG_GOOF,SEG_GOOF, - SEG_GOOF,SEG_GOOF,SEG_GOOF,SEG_GOOF,SEG_GOOF,SEG_GOOF,SEG_GOOF -}; - -#ifdef __STDC__ - -char *s_get_name(symbolS *s); -static symbolS *tag_find_or_make(char *name); -static symbolS* tag_find(char *name); -#ifdef BFD_HEADERS -static void obj_coff_section_header_append(char **where, struct internal_scnhdr *header); -#else -static void obj_coff_section_header_append(char **where, SCNHDR *header); -#endif -static void obj_coff_def(int what); -static void obj_coff_dim(void); -static void obj_coff_endef(void); -static void obj_coff_line(void); -static void obj_coff_ln(void); -static void obj_coff_scl(void); -static void obj_coff_size(void); -static void obj_coff_stab(int what); -static void obj_coff_tag(void); -static void obj_coff_type(void); -static void obj_coff_val(void); -static void tag_init(void); -static void tag_insert(char *name, symbolS *symbolP); - -#else - -char *s_get_name(); -static symbolS *tag_find(); -static symbolS *tag_find_or_make(); -static void obj_coff_section_header_append(); -static void obj_coff_def(); -static void obj_coff_dim(); -static void obj_coff_endef(); -static void obj_coff_line(); -static void obj_coff_ln(); -static void obj_coff_scl(); -static void obj_coff_size(); -static void obj_coff_stab(); -static void obj_coff_tag(); -static void obj_coff_type(); -static void obj_coff_val(); -static void tag_init(); -static void tag_insert(); - -#endif /* __STDC__ */ - -static struct hash_control *tag_hash; -static symbolS *def_symbol_in_progress = NULL; - -const pseudo_typeS obj_pseudo_table[] = { -#ifndef IGNORE_DEBUG - { "def", obj_coff_def, 0 }, - { "dim", obj_coff_dim, 0 }, - { "endef", obj_coff_endef, 0 }, - { "line", obj_coff_line, 0 }, - { "ln", obj_coff_ln, 0 }, - { "scl", obj_coff_scl, 0 }, - { "size", obj_coff_size, 0 }, - { "tag", obj_coff_tag, 0 }, - { "type", obj_coff_type, 0 }, - { "val", obj_coff_val, 0 }, -#else - { "def", s_ignore, 0 }, - { "dim", s_ignore, 0 }, - { "endef", s_ignore, 0 }, - { "line", s_ignore, 0 }, - { "ln", s_ignore, 0 }, - { "scl", s_ignore, 0 }, - { "size", s_ignore, 0 }, - { "tag", s_ignore, 0 }, - { "type", s_ignore, 0 }, - { "val", s_ignore, 0 }, -#endif /* ignore debug */ - - { "ident", s_ignore, 0 }, /* we don't yet handle this. */ - - - /* stabs aka a.out aka b.out directives for debug symbols. - Currently ignored silently. Except for .line at which - we guess from context. */ - { "desc", s_ignore, 0 }, /* def */ -/* { "line", s_ignore, 0 }, */ /* source code line number */ - { "stabd", obj_coff_stab, 'd' }, /* stabs */ - { "stabn", obj_coff_stab, 'n' }, /* stabs */ - { "stabs", obj_coff_stab, 's' }, /* stabs */ - - /* stabs-in-coff (?) debug pseudos (ignored) */ - { "optim", s_ignore, 0 }, /* For sun386i cc (?) */ - /* other stuff */ - { "ABORT", s_abort, 0 }, - - { NULL} /* end sentinel */ -}; /* obj_pseudo_table */ - - - /* obj dependant output values */ -#ifdef BFD_HEADERS -static struct internal_scnhdr bss_section_header; -struct internal_scnhdr data_section_header; -struct internal_scnhdr text_section_header; -#else -static SCNHDR bss_section_header; -SCNHDR data_section_header; -SCNHDR text_section_header; -#endif -/* Relocation. */ - -/* - * emit_relocations() - * - * Crawl along a fixS chain. Emit the segment's relocations. - */ - -void obj_emit_relocations(where, fixP, segment_address_in_file) -char **where; -fixS *fixP; /* Fixup chain for this segment. */ -relax_addressT segment_address_in_file; -{ -#ifdef BFD_HEADERS - struct internal_reloc ri; -#else - RELOC ri; -#endif - symbolS *symbolP; - - bzero((char *)&ri,sizeof(ri)); - for (; fixP; fixP = fixP->fx_next) { - if (symbolP = fixP->fx_addsy) { -#if defined(TC_M68K) - ri.r_type = (fixP->fx_pcrel ? - (fixP->fx_size == 1 ? R_PCRBYTE : - fixP->fx_size == 2 ? R_PCRWORD : - R_PCRLONG): - (fixP->fx_size == 1 ? R_RELBYTE : - fixP->fx_size == 2 ? R_RELWORD : - R_RELLONG)); -#elif defined(TC_I386) - /* FIXME-SOON R_OFF8 & R_DIR16 are a vague guess, completly untested. */ - ri.r_type = (fixP->fx_pcrel ? - (fixP->fx_size == 1 ? R_PCRBYTE : - fixP->fx_size == 2 ? R_PCRWORD : - R_PCRLONG): - (fixP->fx_size == 1 ? R_OFF8 : - fixP->fx_size == 2 ? R_DIR16 : - R_DIR32)); -#elif defined(TC_I960) - ri.r_type = (fixP->fx_pcrel - ? R_IPRMED - : R_RELLONG); -#elif defined(TC_A29K) - ri.r_type = tc_coff_fix2rtype(fixP); - -#else - you lose -#endif /* TC_M68K || TC_I386 */ - ri.r_vaddr = fixP->fx_frag->fr_address + fixP->fx_where; - /* If symbol associated to relocation entry is a bss symbol - or undefined symbol just remember the index of the symbol. - Otherwise store the index of the symbol describing the - section the symbol belong to. This heuristic speeds up ld. - */ - /* Local symbols can generate relocation information. In case - of structure return for instance. But they have no symbol - number because they won't be emitted in the final object. - In the case where they are in the BSS section, this leads - to an incorrect r_symndx. - Under bsd the loader do not care if the symbol reference is - incorrect. But the SYS V ld complains about this. To avoid - this we associate the symbol to the associated section, - *even* if it is the BSS section. */ - /* If someone can tell me why the other symbols of the bss - section are not associated with the .bss section entry, - I'd be gratefull. I guess that it has to do with the special - nature of the .bss section. Or maybe this is because the - bss symbols are declared in the common section and can - be resized later. Can it break code some where ? */ - ri.r_symndx = (S_GET_SEGMENT(symbolP) == SEG_TEXT - ? dot_text_symbol->sy_number - : (S_GET_SEGMENT(symbolP) == SEG_DATA - ? dot_data_symbol->sy_number - : ((SF_GET_LOCAL(symbolP) - ? dot_bss_symbol->sy_number - : symbolP->sy_number)))); /* bss or undefined */ - - /* md_ri_to_chars((char *) &ri, ri); */ /* Last step : write md f */ - - -#ifdef BFD_HEADERS - *where += bfd_coff_swap_reloc_out(stdoutput, &ri, *where); -#if defined(TC_A29K) - /* The 29k has a special kludge for the high 16 bit reloc. - Two relocations are emmited, R_IHIHALF, and R_IHCONST. The second one - doesn't contain a symbol, but uses the value for offset */ - if (ri.r_type == R_IHIHALF) { - /* now emit the second bit */ - ri.r_type = R_IHCONST; - ri.r_symndx = fixP->fx_addnumber; - *where += bfd_coff_swap_reloc_out(stdoutput, &ri, *where); - } - -#endif - -#else - append(where, (char *) &ri, sizeof(ri)); -#endif - -#ifdef TC_I960 - if (fixP->fx_callj) { - ri.r_type = R_OPTCALL; -#ifdef BFD_HEADERS - *where += bfd_coff_swap_reloc_out(stdoutput, &ri, *where); -#else - append(where, (char *) &ri, sizeof(ri)); -#endif - - - } /* if it's a callj, do it again for the opcode */ -#endif /* TC_I960 */ - - } /* if there's a symbol */ - } /* for each fixP */ - - return; -} /* obj_emit_relocations() */ - -/* Coff file generation & utilities */ - -#ifdef BFD_HEADERS -void obj_header_append(where, headers) -char **where; -object_headers *headers; -{ - tc_headers_hook(headers); - *where += bfd_coff_swap_filehdr_out(stdoutput, &(headers->filehdr), *where); -#ifndef OBJ_COFF_OMIT_OPTIONAL_HEADER - *where += bfd_coff_swap_aouthdr_out(stdoutput, &(headers->aouthdr), *where); -#endif - obj_coff_section_header_append(where, &text_section_header); - obj_coff_section_header_append(where, &data_section_header); - obj_coff_section_header_append(where, &bss_section_header); - -} - -#else - -void obj_header_append(where, headers) -char **where; -object_headers *headers; -{ - tc_headers_hook(headers); - -#ifdef CROSS_COMPILE - /* Eventually swap bytes for cross compilation for file header */ - md_number_to_chars(*where, headers->filehdr.f_magic, sizeof(headers->filehdr.f_magic)); - *where += sizeof(headers->filehdr.f_magic); - md_number_to_chars(*where, headers->filehdr.f_nscns, sizeof(headers->filehdr.f_nscns)); - *where += sizeof(headers->filehdr.f_nscns); - md_number_to_chars(*where, headers->filehdr.f_timdat, sizeof(headers->filehdr.f_timdat)); - *where += sizeof(headers->filehdr.f_timdat); - md_number_to_chars(*where, headers->filehdr.f_symptr, sizeof(headers->filehdr.f_symptr)); - *where += sizeof(headers->filehdr.f_symptr); - md_number_to_chars(*where, headers->filehdr.f_nsyms, sizeof(headers->filehdr.f_nsyms)); - *where += sizeof(headers->filehdr.f_nsyms); - md_number_to_chars(*where, headers->filehdr.f_opthdr, sizeof(headers->filehdr.f_opthdr)); - *where += sizeof(headers->filehdr.f_opthdr); - md_number_to_chars(*where, headers->filehdr.f_flags, sizeof(headers->filehdr.f_flags)); - *where += sizeof(headers->filehdr.f_flags); - -#ifndef OBJ_COFF_OMIT_OPTIONAL_HEADER - /* Eventually swap bytes for cross compilation for a.out header */ - md_number_to_chars(*where, headers->aouthdr.magic, sizeof(headers->aouthdr.magic)); - *where += sizeof(headers->aouthdr.magic); - md_number_to_chars(*where, headers->aouthdr.vstamp, sizeof(headers->aouthdr.vstamp)); - *where += sizeof(headers->aouthdr.vstamp); - md_number_to_chars(*where, headers->aouthdr.tsize, sizeof(headers->aouthdr.tsize)); - *where += sizeof(headers->aouthdr.tsize); - md_number_to_chars(*where, headers->aouthdr.dsize, sizeof(headers->aouthdr.dsize)); - *where += sizeof(headers->aouthdr.dsize); - md_number_to_chars(*where, headers->aouthdr.bsize, sizeof(headers->aouthdr.bsize)); - *where += sizeof(headers->aouthdr.bsize); - md_number_to_chars(*where, headers->aouthdr.entry, sizeof(headers->aouthdr.entry)); - *where += sizeof(headers->aouthdr.entry); - md_number_to_chars(*where, headers->aouthdr.text_start, sizeof(headers->aouthdr.text_start)); - *where += sizeof(headers->aouthdr.text_start); - md_number_to_chars(*where, headers->aouthdr.data_start, sizeof(headers->aouthdr.data_start)); - *where += sizeof(headers->aouthdr.data_start); - md_number_to_chars(*where, headers->aouthdr.tagentries, sizeof(headers->aouthdr.tagentries)); - *where += sizeof(headers->aouthdr.tagentries); -#endif /* OBJ_COFF_OMIT_OPTIONAL_HEADER */ - -#else /* CROSS_COMPILE */ - - append(where, (char *) &headers->filehdr, sizeof(headers->filehdr)); -#ifndef OBJ_COFF_OMIT_OPTIONAL_HEADER - append(where, (char *) &headers->aouthdr, sizeof(headers->aouthdr)); -#endif /* OBJ_COFF_OMIT_OPTIONAL_HEADER */ - -#endif /* CROSS_COMPILE */ - - /* Output the section headers */ - obj_coff_section_header_append(where, &text_section_header); - obj_coff_section_header_append(where, &data_section_header); - obj_coff_section_header_append(where, &bss_section_header); - - return; -} /* obj_header_append() */ -#endif -void obj_symbol_to_chars(where, symbolP) -char **where; -symbolS *symbolP; -{ -#ifdef BFD_HEADERS - unsigned int numaux = symbolP->sy_symbol.ost_entry.n_numaux; - unsigned int i; - - if (S_GET_SEGMENT(symbolP) == SEG_REGISTER) { - S_SET_SEGMENT(symbolP, SEG_ABSOLUTE); - } - *where += bfd_coff_swap_sym_out(stdoutput, &symbolP->sy_symbol.ost_entry, - *where); - - for (i = 0; i < numaux; i++) - { - *where += bfd_coff_swap_aux_out(stdoutput, - &symbolP->sy_symbol.ost_auxent[i], - S_GET_DATA_TYPE(symbolP), - S_GET_STORAGE_CLASS(symbolP), - *where); - } - -#else - SYMENT *syment = &symbolP->sy_symbol.ost_entry; - int i; - char numaux = syment->n_numaux; - unsigned short type = S_GET_DATA_TYPE(symbolP); - -#ifdef CROSS_COMPILE - md_number_to_chars(*where, syment->n_value, sizeof(syment->n_value)); - *where += sizeof(syment->n_value); - md_number_to_chars(*where, syment->n_scnum, sizeof(syment->n_scnum)); - *where += sizeof(syment->n_scnum); - md_number_to_chars(*where, syment->n_type, sizeof(syment->n_type)); - *where += sizeof(syment->n_type); - md_number_to_chars(*where, syment->n_sclass, sizeof(syment->n_sclass)); - *where += sizeof(syment->n_sclass); - md_number_to_chars(*where, syment->n_numaux, sizeof(syment->n_numaux)); - *where += sizeof(syment->n_numaux); -#else /* CROSS_COMPILE */ - append(where, (char *) syment, sizeof(*syment)); -#endif /* CROSS_COMPILE */ - - /* Should do the following : if (.file entry) MD(..)... else if (static entry) MD(..) */ - if (numaux > OBJ_COFF_MAX_AUXENTRIES) { - as_bad("Internal error? too many auxents for symbol"); - } /* too many auxents */ - - for (i = 0; i < numaux; ++i) { -#ifdef CROSS_COMPILE -#if 0 /* This code has never been tested */ - /* The most common case, x_sym entry. */ - if ((SF_GET(symbolP) & (SF_FILE | SF_STATICS)) == 0) { - md_number_to_chars(*where, auxP->x_sym.x_tagndx, sizeof(auxP->x_sym.x_tagndx)); - *where += sizeof(auxP->x_sym.x_tagndx); - if (ISFCN(type)) { - md_number_to_chars(*where, auxP->x_sym.x_misc.x_fsize, sizeof(auxP->x_sym.x_misc.x_fsize)); - *where += sizeof(auxP->x_sym.x_misc.x_fsize); - } else { - md_number_to_chars(*where, auxP->x_sym.x_misc.x_lnno, sizeof(auxP->x_sym.x_misc.x_lnno)); - *where += sizeof(auxP->x_sym.x_misc.x_lnno); - md_number_to_chars(*where, auxP->x_sym.x_misc.x_size, sizeof(auxP->x_sym.x_misc.x_size)); - *where += sizeof(auxP->x_sym.x_misc.x_size); - } - if (ISARY(type)) { - register int index; - for (index = 0; index < DIMNUM; index++) - md_number_to_chars(*where, auxP->x_sym.x_fcnary.x_ary.x_dimen[index], sizeof(auxP->x_sym.x_fcnary.x_ary.x_dimen[index])); - *where += sizeof(auxP->x_sym.x_fcnary.x_ary.x_dimen[index]); - } else { - md_number_to_chars(*where, auxP->x_sym.x_fcnary.x_fcn.x_lnnoptr, sizeof(auxP->x_sym.x_fcnary.x_fcn.x_lnnoptr)); - *where += sizeof(auxP->x_sym.x_fcnary.x_fcn.x_lnnoptr); - md_number_to_chars(*where, auxP->x_sym.x_fcnary.x_fcn.x_endndx, sizeof(auxP->x_sym.x_fcnary.x_fcn.x_endndx)); - *where += sizeof(auxP->x_sym.x_fcnary.x_fcn.x_endndx); - } - md_number_to_chars(*where, auxP->x_sym.x_tvndx, sizeof(auxP->x_sym.x_tvndx)); - *where += sizeof(auxP->x_sym.x_tvndx); - } else if (SF_GET_FILE(symbolP)) { /* .file */ - ; - } else if (SF_GET_STATICS(symbolP)) { /* .text, .data, .bss symbols */ - md_number_to_chars(*where, auxP->x_scn.x_scnlen, sizeof(auxP->x_scn.x_scnlen)); - *where += sizeof(auxP->x_scn.x_scnlen); - md_number_to_chars(*where, auxP->x_scn.x_nreloc, sizeof(auxP->x_scn.x_nreloc)); - *where += sizeof(auxP->x_scn.x_nreloc); - md_number_to_chars(*where, auxP->x_scn.x_nlinno, sizeof(auxP->x_scn.x_nlinno)); - *where += sizeof(auxP->x_scn.x_nlinno); - } -#endif /* 0 */ -#else /* CROSS_COMPILE */ - append(where, (char *) &symbolP->sy_symbol.ost_auxent[i], sizeof(symbolP->sy_symbol.ost_auxent[i])); -#endif /* CROSS_COMPILE */ - - }; /* for each aux in use */ -#endif /* BFD_HEADERS */ - return; -} /* obj_symbol_to_chars() */ - -#ifdef BFD_HEADERS -static void obj_coff_section_header_append(where, header) -char **where; -struct internal_scnhdr *header; -{ - *where += bfd_coff_swap_scnhdr_out(stdoutput, header, *where); -} -#else -static void obj_coff_section_header_append(where, header) -char **where; -SCNHDR *header; -{ -#ifdef CROSS_COMPILE - memcpy(*where, header->s_name, sizeof(header->s_name)); - *where += sizeof(header->s_name); - - md_number_to_chars(*where, header->s_paddr, sizeof(header->s_paddr)); - *where += sizeof(header->s_paddr); - - md_number_to_chars(*where, header->s_vaddr, sizeof(header->s_vaddr)); - *where += sizeof(header->s_vaddr); - - md_number_to_chars(*where, header->s_size, sizeof(header->s_size)); - *where += sizeof(header->s_size); - - md_number_to_chars(*where, header->s_scnptr, sizeof(header->s_scnptr)); - *where += sizeof(header->s_scnptr); - - md_number_to_chars(*where, header->s_relptr, sizeof(header->s_relptr)); - *where += sizeof(header->s_relptr); - - md_number_to_chars(*where, header->s_lnnoptr, sizeof(header->s_lnnoptr)); - *where += sizeof(header->s_lnnoptr); - - md_number_to_chars(*where, header->s_nreloc, sizeof(header->s_nreloc)); - *where += sizeof(header->s_nreloc); - - md_number_to_chars(*where, header->s_nlnno, sizeof(header->s_nlnno)); - *where += sizeof(header->s_nlnno); - - md_number_to_chars(*where, header->s_flags, sizeof(header->s_flags)); - *where += sizeof(header->s_flags); - -#ifdef TC_I960 - md_number_to_chars(*where, header->s_align, sizeof(header->s_align)); - *where += sizeof(header->s_align); -#endif /* TC_I960 */ - -#else /* CROSS_COMPILE */ - - append(where, (char *) header, sizeof(*header)); - -#endif /* CROSS_COMPILE */ - - return; -} /* obj_coff_section_header_append() */ - -#endif -void obj_emit_symbols(where, symbol_rootP) -char **where; -symbolS *symbol_rootP; -{ - symbolS *symbolP; - /* - * Emit all symbols left in the symbol chain. - */ - for (symbolP = symbol_rootP; symbolP; symbolP = symbol_next(symbolP)) { - /* Used to save the offset of the name. It is used to point - to the string in memory but must be a file offset. */ - register char * temp; - - tc_coff_symbol_emit_hook(symbolP); - - temp = S_GET_NAME(symbolP); - if (SF_GET_STRING(symbolP)) { - S_SET_OFFSET(symbolP, symbolP->sy_name_offset); - S_SET_ZEROES(symbolP, 0); - } else { - bzero(symbolP->sy_symbol.ost_entry.n_name, SYMNMLEN); - strncpy(symbolP->sy_symbol.ost_entry.n_name, temp, SYMNMLEN); - } - obj_symbol_to_chars(where, symbolP); - S_SET_NAME(symbolP,temp); - } -} /* obj_emit_symbols() */ - -/* Merge a debug symbol containing debug information into a normal symbol. */ - -void c_symbol_merge(debug, normal) -symbolS *debug; -symbolS *normal; -{ - S_SET_DATA_TYPE(normal, S_GET_DATA_TYPE(debug)); - S_SET_STORAGE_CLASS(normal, S_GET_STORAGE_CLASS(debug)); - - if (S_GET_NUMBER_AUXILIARY(debug) > S_GET_NUMBER_AUXILIARY(normal)) { - S_SET_NUMBER_AUXILIARY(normal, S_GET_NUMBER_AUXILIARY(debug)); - } /* take the most we have */ - - if (S_GET_NUMBER_AUXILIARY(debug) > 0) { - memcpy((char*)&normal->sy_symbol.ost_auxent[0], (char*)&debug->sy_symbol.ost_auxent[0], S_GET_NUMBER_AUXILIARY(debug) * AUXESZ); - } /* Move all the auxiliary information */ - - /* Move the debug flags. */ - SF_SET_DEBUG_FIELD(normal, SF_GET_DEBUG_FIELD(debug)); -} /* c_symbol_merge() */ - -static symbolS *previous_file_symbol = NULL; - -void c_dot_file_symbol(filename) -char *filename; -{ - symbolS* symbolP; - - symbolP = symbol_new(".file", - SEG_DEBUG, - 0, - &zero_address_frag); - - S_SET_STORAGE_CLASS(symbolP, C_FILE); - S_SET_NUMBER_AUXILIARY(symbolP, 1); - SA_SET_FILE_FNAME(symbolP, filename); - SF_SET_DEBUG(symbolP); - S_SET_VALUE(symbolP, (long) previous_file_symbol); - - previous_file_symbol = symbolP; - - /* Make sure that the symbol is first on the symbol chain */ - if (symbol_rootP != symbolP) { - if (symbolP == symbol_lastP) { - symbol_lastP = symbol_lastP->sy_previous; - } /* if it was the last thing on the list */ - - symbol_remove(symbolP, &symbol_rootP, &symbol_lastP); - symbol_insert(symbolP, symbol_rootP, &symbol_rootP, &symbol_lastP); - symbol_rootP = symbolP; - } /* if not first on the list */ - -} /* c_dot_file_symbol() */ -/* - * Build a 'section static' symbol. - */ - -char *c_section_symbol(name, value, length, nreloc, nlnno) -char *name; -long value; -long length; -unsigned short nreloc; -unsigned short nlnno; -{ - symbolS *symbolP; - - symbolP = symbol_new(name, - (name[1] == 't' - ? SEG_TEXT - : (name[1] == 'd' - ? SEG_DATA - : SEG_BSS)), - value, - &zero_address_frag); - - S_SET_STORAGE_CLASS(symbolP, C_STAT); - S_SET_NUMBER_AUXILIARY(symbolP, 1); - - SA_SET_SCN_SCNLEN(symbolP, length); - SA_SET_SCN_NRELOC(symbolP, nreloc); - SA_SET_SCN_NLINNO(symbolP, nlnno); - - SF_SET_STATICS(symbolP); - - return (char*)symbolP; -} /* c_section_symbol() */ - -void c_section_header(header, - name, - core_address, - size, - data_ptr, - reloc_ptr, - lineno_ptr, - reloc_number, - lineno_number, - alignment) -#ifdef BFD_HEADERS -struct internal_scnhdr *header; -#else -SCNHDR *header; -#endif -char *name; -long core_address; -long size; -long data_ptr; -long reloc_ptr; -long lineno_ptr; -long reloc_number; -long lineno_number; -long alignment; -{ - strncpy(header->s_name, name, 8); - header->s_paddr = header->s_vaddr = core_address; - header->s_scnptr = ((header->s_size = size) != 0) ? data_ptr : 0; - header->s_relptr = reloc_ptr; - header->s_lnnoptr = lineno_ptr; - header->s_nreloc = reloc_number; - header->s_nlnno = lineno_number; - -#ifdef OBJ_COFF_SECTION_HEADER_HAS_ALIGNMENT -#ifdef OBJ_COFF_BROKEN_ALIGNMENT - header->s_align = ((name[1] == 'b' || (size > 0)) ? 16 : 0); -#else - header->s_align = ((alignment == 0) - ? 0 - : (1 << alignment)); -#endif /* OBJ_COFF_BROKEN_ALIGNMENT */ -#endif /* OBJ_COFF_SECTION_HEADER_HAS_ALIGNMENT */ - - header->s_flags = STYP_REG | (name[1] == 't' - ? STYP_TEXT - : (name[1] == 'd' - ? STYP_DATA - : (name[1] == 'b' - ? STYP_BSS - : STYP_INFO))); - return; -} /* c_section_header() */ - -/* Line number handling */ - -int function_lineoff = -1; /* Offset in line#s where the last function - started (the odd entry for line #0) */ -int text_lineno_number = 0; -int our_lineno_number = 0; /* we use this to build pointers from .bf's - into the linetable. It should match - exactly the values that are later - assigned in text_lineno_number by - write.c. */ -lineno* lineno_lastP = (lineno*)0; - -int -c_line_new(paddr, line_number, frag) -long paddr; -unsigned short line_number; -fragS* frag; -{ - lineno* new_line = (lineno*)xmalloc(sizeof(lineno)); - - new_line->line.l_addr.l_paddr = paddr; - new_line->line.l_lnno = line_number; - new_line->frag = (char*)frag; - new_line->next = (lineno*)0; - - if (lineno_rootP == (lineno*)0) - lineno_rootP = new_line; - else - lineno_lastP->next = new_line; - lineno_lastP = new_line; - return LINESZ * our_lineno_number++; -} - -void obj_emit_lineno(where, line, file_start) -char **where; -lineno *line; -char *file_start; -{ -#ifdef BFD_HEADERS - struct bfd_internal_lineno *line_entry; -#else - LINENO *line_entry; -#endif - for (; line; line = line->next) { - line_entry = &line->line; - - /* FIXME-SOMEDAY Resolving the sy_number of function linno's used to be done in - write_object_file() but their symbols need a fileptr to the lnno, so - I moved this resolution check here. xoxorich. */ - - if (line_entry->l_lnno == 0) { - /* There is a good chance that the symbol pointed to - is not the one that will be emitted and that the - sy_number is not accurate. */ -/* char *name; */ - symbolS *symbolP; - - symbolP = (symbolS *) line_entry->l_addr.l_symndx; - - line_entry->l_addr.l_symndx = symbolP->sy_number; - symbolP->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_fcn.x_lnnoptr = *where - file_start; - - } /* if this is a function linno */ -#ifdef BFD_HEADERS - *where += bfd_coff_swap_lineno_out(stdoutput, line_entry, *where); -#else - /* No matter which member of the union we process, they are - both long. */ -#ifdef CROSS_COMPILE - md_number_to_chars(*where, line_entry->l_addr.l_paddr, sizeof(line_entry->l_addr.l_paddr)); - *where += sizeof(line_entry->l_addr.l_paddr); - - md_number_to_chars(*where, line_entry->l_lnno, sizeof(line_entry->l_lnno)); - *where += sizeof(line_entry->l_lnno); -#else /* CROSS_COMPILE */ - append(where, (char *) line_entry, LINESZ); -#endif /* CROSS_COMPILE */ -#endif - } /* for each line number */ - - return ; -} /* obj_emit_lineno() */ - -void obj_symbol_new_hook(symbolP) -symbolS *symbolP; -{ - char underscore = 0; /* Symbol has leading _ */ - - /* Effective symbol */ - /* Store the pointer in the offset. */ - S_SET_ZEROES(symbolP, 0L); - S_SET_DATA_TYPE(symbolP, T_NULL); - S_SET_STORAGE_CLASS(symbolP, 0); - S_SET_NUMBER_AUXILIARY(symbolP, 0); - /* Additional information */ - symbolP->sy_symbol.ost_flags = 0; - /* Auxiliary entries */ - bzero((char*)&symbolP->sy_symbol.ost_auxent[0], AUXESZ); - -#if STRIP_UNDERSCORE - /* Remove leading underscore at the beginning of the symbol. - * This is to be compatible with the standard librairies. - */ - if (*S_GET_NAME(symbolP) == '_') { - underscore = 1; - S_SET_NAME(symbolP, S_GET_NAME(symbolP) + 1); - } /* strip underscore */ -#endif /* STRIP_UNDERSCORE */ - - if (S_IS_STRING(symbolP)) - SF_SET_STRING(symbolP); - if (!underscore && S_IS_LOCAL(symbolP)) - SF_SET_LOCAL(symbolP); - - return; -} /* obj_symbol_new_hook() */ - - /* stack stuff */ -stack* stack_init(chunk_size, element_size) -unsigned long chunk_size; -unsigned long element_size; -{ - stack* st; - - if ((st = (stack*)malloc(sizeof(stack))) == (stack*)0) - return (stack*)0; - if ((st->data = malloc(chunk_size)) == (char*)0) { - free(st); - return (stack*)0; - } - st->pointer = 0; - st->size = chunk_size; - st->chunk_size = chunk_size; - st->element_size = element_size; - return st; -} /* stack_init() */ - -void stack_delete(st) -stack* st; -{ - free(st->data); - free(st); -} - -char *stack_push(st, element) -stack *st; -char *element; -{ - if (st->pointer + st->element_size >= st->size) { - st->size += st->chunk_size; - if ((st->data = xrealloc(st->data, st->size)) == (char*)0) - return (char*)0; - } - memcpy(st->data + st->pointer, element, st->element_size); - st->pointer += st->element_size; - return st->data + st->pointer; -} /* stack_push() */ - -char* stack_pop(st) -stack* st; -{ - if ((st->pointer -= st->element_size) < 0) { - st->pointer = 0; - return (char*)0; - } - return st->data + st->pointer; -} - -char* stack_top(st) -stack* st; -{ - return st->data + st->pointer - st->element_size; -} - - -/* - * Handle .ln directives. - */ - -static void obj_coff_ln() { - if (def_symbol_in_progress != NULL) { - as_warn(".ln pseudo-op inside .def/.endef: ignored."); - demand_empty_rest_of_line(); - return; - } /* wrong context */ - - c_line_new(obstack_next_free(&frags) - frag_now->fr_literal, - get_absolute_expression(), - frag_now); - - demand_empty_rest_of_line(); - return; -} /* obj_coff_line() */ - -/* - * def() - * - * Handle .def directives. - * - * One might ask : why can't we symbol_new if the symbol does not - * already exist and fill it with debug information. Because of - * the C_EFCN special symbol. It would clobber the value of the - * function symbol before we have a chance to notice that it is - * a C_EFCN. And a second reason is that the code is more clear this - * way. (at least I think it is :-). - * - */ - -#define SKIP_SEMI_COLON() while (*input_line_pointer++ != ';') -#define SKIP_WHITESPACES() while (*input_line_pointer == ' ' || \ - *input_line_pointer == '\t') \ - input_line_pointer++; - -static void obj_coff_def(what) -int what; -{ - char name_end; /* Char after the end of name */ - char *symbol_name; /* Name of the debug symbol */ - char *symbol_name_copy; /* Temporary copy of the name */ - unsigned int symbol_name_length; - /*$char* directiveP;$ */ /* Name of the pseudo opcode */ - /*$char directive[MAX_DIRECTIVE];$ */ /* Backup of the directive */ - /*$char end = 0;$ */ /* If 1, stop parsing */ - - if (def_symbol_in_progress != NULL) { - as_warn(".def pseudo-op used inside of .def/.endef: ignored."); - demand_empty_rest_of_line(); - return; - } /* if not inside .def/.endef */ - - SKIP_WHITESPACES(); - - def_symbol_in_progress = (symbolS *) obstack_alloc(¬es, sizeof(*def_symbol_in_progress)); - bzero(def_symbol_in_progress, sizeof(*def_symbol_in_progress)); - - symbol_name = input_line_pointer; - name_end = get_symbol_end(); - symbol_name_length = strlen(symbol_name); - symbol_name_copy = xmalloc(symbol_name_length + 1); - strcpy(symbol_name_copy, symbol_name); - - /* Initialize the new symbol */ -#if STRIP_UNDERSCORE - S_SET_NAME(def_symbol_in_progress, (*symbol_name_copy == '_' - ? symbol_name_copy + 1 - : symbol_name_copy)); -#else /* STRIP_UNDERSCORE */ - S_SET_NAME(def_symbol_in_progress, symbol_name_copy); -#endif /* STRIP_UNDERSCORE */ - /* free(symbol_name_copy); */ - def_symbol_in_progress->sy_name_offset = ~0; - def_symbol_in_progress->sy_number = ~0; - def_symbol_in_progress->sy_frag = &zero_address_frag; - - if (S_IS_STRING(def_symbol_in_progress)) { - SF_SET_STRING(def_symbol_in_progress); - } /* "long" name */ - - *input_line_pointer = name_end; - - demand_empty_rest_of_line(); - return; -} /* obj_coff_def() */ - -unsigned int dim_index; -static void obj_coff_endef() { - symbolS *symbolP; -/* DIM BUG FIX sac@cygnus.com */ - dim_index =0; - if (def_symbol_in_progress == NULL) { - as_warn(".endef pseudo-op used outside of .def/.endef: ignored."); - demand_empty_rest_of_line(); - return; - } /* if not inside .def/.endef */ - - /* Set the section number according to storage class. */ - switch (S_GET_STORAGE_CLASS(def_symbol_in_progress)) { - case C_STRTAG: - case C_ENTAG: - case C_UNTAG: - SF_SET_TAG(def_symbol_in_progress); - /* intentional fallthrough */ - case C_FILE: - case C_TPDEF: - SF_SET_DEBUG(def_symbol_in_progress); - S_SET_SEGMENT(def_symbol_in_progress, SEG_DEBUG); - break; - - case C_EFCN: - SF_SET_LOCAL(def_symbol_in_progress); /* Do not emit this symbol. */ - /* intentional fallthrough */ - case C_BLOCK: - SF_SET_PROCESS(def_symbol_in_progress); /* Will need processing before writing */ - /* intentional fallthrough */ - case C_FCN: - S_SET_SEGMENT(def_symbol_in_progress, SEG_TEXT); - - if (def_symbol_in_progress->sy_symbol.ost_entry.n_name[1] == 'b') { /* .bf */ - if (function_lineoff < 0) { - fprintf(stderr, "`.bf' symbol without preceding function\n"); - } /* missing function symbol */ - SA_GET_SYM_LNNOPTR(def_symbol_in_progress) = function_lineoff; - SF_SET_PROCESS(def_symbol_in_progress); /* Will need relocating */ - function_lineoff = -1; - } - break; - -#ifdef C_AUTOARG - case C_AUTOARG: -#endif /* C_AUTOARG */ - case C_AUTO: - case C_REG: - case C_MOS: - case C_MOE: - case C_MOU: - case C_ARG: - case C_REGPARM: - case C_FIELD: - case C_EOS: - SF_SET_DEBUG(def_symbol_in_progress); - S_SET_SEGMENT(def_symbol_in_progress, SEG_ABSOLUTE); - break; - - case C_EXT: - case C_STAT: - case C_LABEL: - /* Valid but set somewhere else (s_comm, s_lcomm, colon) */ - break; - - case C_USTATIC: - case C_EXTDEF: - case C_ULABEL: - as_warn("unexpected storage class %d", S_GET_STORAGE_CLASS(def_symbol_in_progress)); - break; - } /* switch on storage class */ - - /* Now that we have built a debug symbol, try to - find if we should merge with an existing symbol - or not. If a symbol is C_EFCN or SEG_ABSOLUTE or - untagged SEG_DEBUG it never merges. */ - - /* Two cases for functions. Either debug followed - by definition or definition followed by debug. - For definition first, we will merge the debug - symbol into the definition. For debug first, the - lineno entry MUST point to the definition - function or else it will point off into space - when obj_crawl_symbol_chain() merges the debug - symbol into the real symbol. Therefor, let's - presume the debug symbol is a real function - reference. */ - - /* FIXME-SOON If for some reason the definition - label/symbol is never seen, this will probably - leave an undefined symbol at link time. */ - - if (S_GET_STORAGE_CLASS(def_symbol_in_progress) == C_EFCN - || (S_GET_SEGMENT(def_symbol_in_progress) == SEG_DEBUG - && !SF_GET_TAG(def_symbol_in_progress)) - || S_GET_SEGMENT(def_symbol_in_progress) == SEG_ABSOLUTE - || (symbolP = symbol_find_base(S_GET_NAME(def_symbol_in_progress), DO_NOT_STRIP)) == NULL) { - - symbol_append(def_symbol_in_progress, symbol_lastP, &symbol_rootP, &symbol_lastP); - - } else { - /* This symbol already exists, merge the - newly created symbol into the old one. - This is not mandatory. The linker can - handle duplicate symbols correctly. But I - guess that it save a *lot* of space if - the assembly file defines a lot of - symbols. [loic] */ - - /* The debug entry (def_symbol_in_progress) - is merged into the previous definition. */ - - c_symbol_merge(def_symbol_in_progress, symbolP); - /* FIXME-SOON Should *def_symbol_in_progress be free'd? xoxorich. */ - def_symbol_in_progress = symbolP; - - if (SF_GET_FUNCTION(def_symbol_in_progress) - || SF_GET_TAG(def_symbol_in_progress)) { - /* For functions, and tags, the symbol *must* be where the debug symbol - appears. Move the existing symbol to the current place. */ - /* If it already is at the end of the symbol list, do nothing */ - if (def_symbol_in_progress != symbol_lastP) { - symbol_remove(def_symbol_in_progress, &symbol_rootP, &symbol_lastP); - symbol_append(def_symbol_in_progress, symbol_lastP, &symbol_rootP, &symbol_lastP); - } /* if not already in place */ - } /* if function */ - } /* normal or mergable */ - - if (SF_GET_TAG(def_symbol_in_progress) - && symbol_find_base(S_GET_NAME(def_symbol_in_progress), DO_NOT_STRIP) == NULL) { - tag_insert(S_GET_NAME(def_symbol_in_progress), def_symbol_in_progress); - } /* If symbol is a {structure,union} tag, associate symbol to its name. */ - - if (SF_GET_FUNCTION(def_symbol_in_progress)) { - know(sizeof(def_symbol_in_progress) <= sizeof(long)); - function_lineoff = c_line_new((long) def_symbol_in_progress, 0, &zero_address_frag); - SF_SET_PROCESS(def_symbol_in_progress); - - if (symbolP == NULL) { - /* That is, if this is the first - time we've seen the function... */ - symbol_table_insert(def_symbol_in_progress); - } /* definition follows debug */ - } /* Create the line number entry pointing to the function being defined */ - - def_symbol_in_progress = NULL; - demand_empty_rest_of_line(); - return; -} /* obj_coff_endef() */ -#ifndef TC_I960 -/*This code expects all the dims to be after one another, and that is not true -for gcc960 -sac@cygnus.com */ -static void obj_coff_dim() { - register int dim_index; - - if (def_symbol_in_progress == NULL) { - as_warn(".dim pseudo-op used outside of .def/.endef: ignored."); - demand_empty_rest_of_line(); - return; - } /* if not inside .def/.endef */ - - S_SET_NUMBER_AUXILIARY(def_symbol_in_progress, 1); - - for (dim_index = 0; dim_index < DIMNUM; dim_index++) { - SKIP_WHITESPACES(); - SA_SET_SYM_DIMEN(def_symbol_in_progress, dim_index, get_absolute_expression()); - - switch (*input_line_pointer) { - - case ',': - input_line_pointer++; - break; - - default: - as_warn("badly formed .dim directive ignored"); - /* intentional fallthrough */ - case ';': - dim_index = DIMNUM; - break; - } /* switch on following character */ - } /* for each dimension */ - - demand_empty_rest_of_line(); - return; -} /* obj_coff_dim() */ -#else - -static void -obj_coff_dim() -{ - if (def_symbol_in_progress == NULL) { - as_warn(".dim pseudo-op used outside of .def/.endef: ignored."); - demand_empty_rest_of_line(); - return; - } /* if not inside .def/.endef */ - - - S_SET_NUMBER_AUXILIARY(def_symbol_in_progress, 1); - - /* Grab as many dims as we can fit, until ; or full */ - while (dim_index < DIMNUM) - { - SKIP_WHITESPACES(); - SA_SET_SYM_DIMEN(def_symbol_in_progress, dim_index, get_absolute_expression()); - dim_index++; - if (*input_line_pointer == ';') break; - if (*input_line_pointer != ',') { - as_warn("badly formed .dim directive ignored"); - break; - } - input_line_pointer++; - } - demand_empty_rest_of_line(); - return; -} /* obj_coff_dim() */ -#endif - -static void obj_coff_line() { - if (def_symbol_in_progress == NULL) { - obj_coff_ln(); - return; - } /* if it looks like a stabs style line */ - - S_SET_NUMBER_AUXILIARY(def_symbol_in_progress, 1); - SA_SET_SYM_LNNO(def_symbol_in_progress, get_absolute_expression()); - - demand_empty_rest_of_line(); - return; -} /* obj_coff_line() */ - -static void obj_coff_size() { - if (def_symbol_in_progress == NULL) { - as_warn(".size pseudo-op used outside of .def/.endef ignored."); - demand_empty_rest_of_line(); - return; - } /* if not inside .def/.endef */ - - S_SET_NUMBER_AUXILIARY(def_symbol_in_progress, 1); - SA_SET_SYM_SIZE(def_symbol_in_progress, get_absolute_expression()); - demand_empty_rest_of_line(); - return; -} /* obj_coff_size() */ - -static void obj_coff_scl() { - if (def_symbol_in_progress == NULL) { - as_warn(".scl pseudo-op used outside of .def/.endef ignored."); - demand_empty_rest_of_line(); - return; - } /* if not inside .def/.endef */ - - S_SET_STORAGE_CLASS(def_symbol_in_progress, get_absolute_expression()); - demand_empty_rest_of_line(); - return; -} /* obj_coff_scl() */ - -static void obj_coff_tag() { - char *symbol_name; - char name_end; - - if (def_symbol_in_progress == NULL) { - as_warn(".tag pseudo-op used outside of .def/.endef ignored."); - demand_empty_rest_of_line(); - return; - } /* if not inside .def/.endef */ - - S_SET_NUMBER_AUXILIARY(def_symbol_in_progress, 1); - symbol_name = input_line_pointer; - name_end = get_symbol_end(); - - /* Assume that the symbol referred to by .tag is always defined. */ - /* This was a bad assumption. I've added find_or_make. xoxorich. */ - SA_SET_SYM_TAGNDX(def_symbol_in_progress, (long) tag_find_or_make(symbol_name)); - if (SA_GET_SYM_TAGNDX(def_symbol_in_progress) == 0L) { - as_warn("tag not found for .tag %s", symbol_name); - } /* not defined */ - - SF_SET_TAGGED(def_symbol_in_progress); - *input_line_pointer = name_end; - - demand_empty_rest_of_line(); - return; -} /* obj_coff_tag() */ - -static void obj_coff_type() { - if (def_symbol_in_progress == NULL) { - as_warn(".type pseudo-op used outside of .def/.endef ignored."); - demand_empty_rest_of_line(); - return; - } /* if not inside .def/.endef */ - - S_SET_DATA_TYPE(def_symbol_in_progress, get_absolute_expression()); - - if (ISFCN(S_GET_DATA_TYPE(def_symbol_in_progress)) && - S_GET_STORAGE_CLASS(def_symbol_in_progress) != C_TPDEF) { - SF_SET_FUNCTION(def_symbol_in_progress); - } /* is a function */ - - demand_empty_rest_of_line(); - return; -} /* obj_coff_type() */ - -static void obj_coff_val() { - if (def_symbol_in_progress == NULL) { - as_warn(".val pseudo-op used outside of .def/.endef ignored."); - demand_empty_rest_of_line(); - return; - } /* if not inside .def/.endef */ - - if (is_name_beginner(*input_line_pointer)) { - char *symbol_name = input_line_pointer; - char name_end = get_symbol_end(); - - if (!strcmp(symbol_name, ".")) { - def_symbol_in_progress->sy_frag = frag_now; - S_SET_VALUE(def_symbol_in_progress, obstack_next_free(&frags) - frag_now->fr_literal); - /* If the .val is != from the .def (e.g. statics) */ - } else if (strcmp(S_GET_NAME(def_symbol_in_progress), symbol_name)) { - def_symbol_in_progress->sy_forward = symbol_find_or_make(symbol_name); - - /* If the segment is undefined when the forward - reference is solved, then copy the segment id - from the forward symbol. */ - SF_SET_GET_SEGMENT(def_symbol_in_progress); - } - /* Otherwise, it is the name of a non debug symbol and its value will be calculated later. */ - *input_line_pointer = name_end; - } else { - S_SET_VALUE(def_symbol_in_progress, get_absolute_expression()); - } /* if symbol based */ - - demand_empty_rest_of_line(); - return; -} /* obj_coff_val() */ - -/* - * Maintain a list of the tagnames of the structres. - */ - -static void tag_init() { - tag_hash = hash_new(); - return ; -} /* tag_init() */ - -static void tag_insert(name, symbolP) -char *name; -symbolS *symbolP; -{ - register char * error_string; - - if (*(error_string = hash_jam(tag_hash, name, (char *)symbolP))) { - as_fatal("Inserting \"%s\" into structure table failed: %s", - name, error_string); - } - return ; -} /* tag_insert() */ - -static symbolS *tag_find_or_make(name) -char *name; -{ - symbolS *symbolP; - - if ((symbolP = tag_find(name)) == NULL) { - symbolP = symbol_new(name, - SEG_UNKNOWN, - 0, - &zero_address_frag); - - tag_insert(S_GET_NAME(symbolP), symbolP); - symbol_table_insert(symbolP); - } /* not found */ - - return(symbolP); -} /* tag_find_or_make() */ - -static symbolS *tag_find(name) -char *name; -{ -#if STRIP_UNDERSCORE - if (*name == '_') name++; -#endif /* STRIP_UNDERSCORE */ - return((symbolS*)hash_find(tag_hash, name)); -} /* tag_find() */ - -void obj_read_begin_hook() { - /* These had better be the same. Usually 18 bytes. */ -#ifndef BFD_HEADERS - know(sizeof(SYMENT) == sizeof(AUXENT)); - know(SYMESZ == AUXESZ); -#endif - tag_init(); - - return; -} /* obj_read_begin_hook() */ - -void obj_crawl_symbol_chain(headers) -object_headers *headers; -{ - int symbol_number = 0; - lineno *lineP; - symbolS *last_functionP = NULL; - symbolS *last_tagP; - symbolS *symbolP; - symbolS *symbol_externP = NULL; - symbolS *symbol_extern_lastP = NULL; - - /* Initialize the stack used to keep track of the matching .bb .be */ - stack* block_stack = stack_init(512, sizeof(symbolS*)); - - /* JF deal with forward references first... */ - for (symbolP = symbol_rootP; symbolP; symbolP = symbol_next(symbolP)) { - - if (symbolP->sy_forward) { - S_SET_VALUE(symbolP, (S_GET_VALUE(symbolP) - + S_GET_VALUE(symbolP->sy_forward) - + symbolP->sy_forward->sy_frag->fr_address)); - - if (SF_GET_GET_SEGMENT(symbolP)) { - S_SET_SEGMENT(symbolP, S_GET_SEGMENT(symbolP->sy_forward)); - } /* forward segment also */ - - symbolP->sy_forward=0; - } /* if it has a forward reference */ - } /* walk the symbol chain */ - - tc_crawl_symbol_chain(headers); - - /* The symbol list should be ordered according to the following sequence - * order : - * . .file symbol - * . debug entries for functions - * . fake symbols for .text .data and .bss - * . defined symbols - * . undefined symbols - * But this is not mandatory. The only important point is to put the - * undefined symbols at the end of the list. - */ - - if (symbol_rootP == NULL - || S_GET_STORAGE_CLASS(symbol_rootP) != C_FILE) { - know(!previous_file_symbol); - c_dot_file_symbol("fake"); - } /* Is there a .file symbol ? If not insert one at the beginning. */ - - /* - * Build up static symbols for .text, .data and .bss - */ - dot_text_symbol = (symbolS*) - c_section_symbol(".text", - 0, - H_GET_TEXT_SIZE(headers), - 0/*text_relocation_number */, - 0/*text_lineno_number */); - - dot_data_symbol = (symbolS*) - c_section_symbol(".data", - H_GET_TEXT_SIZE(headers), - H_GET_DATA_SIZE(headers), - 0/*data_relocation_number */, - 0); /* There are no data lineno entries */ - - dot_bss_symbol = (symbolS*) - c_section_symbol(".bss", - H_GET_TEXT_SIZE(headers) + H_GET_DATA_SIZE(headers), - H_GET_BSS_SIZE(headers), - 0, /* No relocation for a bss section. */ - 0); /* There are no bss lineno entries */ - -#if defined(DEBUG) - verify_symbol_chain(symbol_rootP, symbol_lastP); -#endif /* DEBUG */ - - /* Three traversals of symbol chains here. The - first traversal yanks externals into a temporary - chain, removing the externals from the global - chain, numbers symbols, and does some other guck. - The second traversal is on the temporary chain of - externals and just appends them to the global - chain again, numbering them as we go. The third - traversal patches pointers to symbols (using sym - indexes). The last traversal was once done as - part of the first pass, but that fails when a - reference preceeds a definition as the definition - has no number at the time we process the - reference. */ - - /* Note that symbolP will be NULL at the end of a loop - if an external was at the beginning of the list (it - gets moved off the list). Hence the weird check in - the loop control. - */ - for (symbolP = symbol_rootP; - symbolP; - symbolP = symbolP ? symbol_next(symbolP) : symbol_rootP) { - if (!SF_GET_DEBUG(symbolP)) { - /* Debug symbols do not need all this rubbish */ - symbolS* real_symbolP; - - /* L* and C_EFCN symbols never merge. */ - if (!SF_GET_LOCAL(symbolP) - && (real_symbolP = symbol_find_base(S_GET_NAME(symbolP), DO_NOT_STRIP)) - && real_symbolP != symbolP) { - /* FIXME-SOON: where do dups come from? Maybe tag references before definitions? xoxorich. */ - /* Move the debug data from the debug symbol to the - real symbol. Do NOT do the oposite (i.e. move from - real symbol to debug symbol and remove real symbol from the - list.) Because some pointers refer to the real symbol - whereas no pointers refer to the debug symbol. */ - c_symbol_merge(symbolP, real_symbolP); - /* Replace the current symbol by the real one */ - /* The symbols will never be the last or the first - because : 1st symbol is .file and 3 last symbols are - .text, .data, .bss */ - symbol_remove(real_symbolP, &symbol_rootP, &symbol_lastP); - symbol_insert(real_symbolP, symbolP, &symbol_rootP, &symbol_lastP); - symbol_remove(symbolP, &symbol_rootP, &symbol_lastP); - symbolP = real_symbolP; - } /* if not local but dup'd */ - - if (flagseen['R'] && (S_GET_SEGMENT(symbolP) == SEG_DATA)) { - S_SET_SEGMENT(symbolP, SEG_TEXT); - } /* push data into text */ - - S_SET_VALUE(symbolP, S_GET_VALUE(symbolP) + symbolP->sy_frag->fr_address); - - if (!S_IS_DEFINED(symbolP) && !SF_GET_LOCAL(symbolP)) { - S_SET_EXTERNAL(symbolP); - } else if (S_GET_STORAGE_CLASS(symbolP) == C_NULL) { - if (S_GET_SEGMENT(symbolP) == SEG_TEXT){ - S_SET_STORAGE_CLASS(symbolP, C_LABEL); - } else { - S_SET_STORAGE_CLASS(symbolP, C_STAT); - } - } /* no storage class yet */ - - /* Mainly to speed up if not -g */ - if (SF_GET_PROCESS(symbolP)) { - /* Handle the nested blocks auxiliary info. */ - if (S_GET_STORAGE_CLASS(symbolP) == C_BLOCK) { - if (!strcmp(S_GET_NAME(symbolP), ".bb")) - stack_push(block_stack, (char *) &symbolP); - else { /* .eb */ - register symbolS* begin_symbolP; - begin_symbolP = *(symbolS**)stack_pop(block_stack); - if (begin_symbolP == (symbolS*)0) - as_warn("mismatched .eb"); - else - SA_SET_SYM_ENDNDX(begin_symbolP, symbol_number+2); - } - } - /* If we are able to identify the type of a function, and we - are out of a function (last_functionP == 0) then, the - function symbol will be associated with an auxiliary - entry. */ - if (last_functionP == (symbolS*)0 && - SF_GET_FUNCTION(symbolP)) { - last_functionP = symbolP; - - if (S_GET_NUMBER_AUXILIARY(symbolP) < 1) { - S_SET_NUMBER_AUXILIARY(symbolP, 1); - } /* make it at least 1 */ - - /* Clobber possible stale .dim information. */ - bzero(symbolP->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_ary.x_dimen, - sizeof(symbolP->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_ary.x_dimen)); - } - /* The C_FCN doesn't need any additional information. - I don't even know if this is needed for sdb. But the - standard assembler generates it, so... - */ - if (S_GET_STORAGE_CLASS(symbolP) == C_EFCN) { - if (last_functionP == (symbolS*)0) - as_fatal("C_EFCN symbol out of scope"); - SA_SET_SYM_FSIZE(last_functionP, - (long)(S_GET_VALUE(symbolP) - - S_GET_VALUE(last_functionP))); - SA_SET_SYM_ENDNDX(last_functionP, symbol_number); - last_functionP = (symbolS*)0; - } - } - } else if (SF_GET_TAG(symbolP)) { - /* First descriptor of a structure must point to - the first slot after the structure description. */ - last_tagP = symbolP; - - } else if (S_GET_STORAGE_CLASS(symbolP) == C_EOS) { - /* +2 take in account the current symbol */ - SA_SET_SYM_ENDNDX(last_tagP, symbol_number + 2); - } else if (S_GET_STORAGE_CLASS(symbolP) == C_FILE) { - if (S_GET_VALUE(symbolP)) { - S_SET_VALUE((symbolS *) S_GET_VALUE(symbolP), symbol_number); - S_SET_VALUE(symbolP, 0); - } /* no one points at the first .file symbol */ - } /* if debug or tag or eos or file */ - - /* We must put the external symbols apart. The loader - does not bomb if we do not. But the references in - the endndx field for a .bb symbol are not corrected - if an external symbol is removed between .bb and .be. - I.e in the following case : - [20] .bb endndx = 22 - [21] foo external - [22] .be - ld will move the symbol 21 to the end of the list but - endndx will still be 22 instead of 21. */ - - - if (SF_GET_LOCAL(symbolP)) { - /* remove C_EFCN and LOCAL (L...) symbols */ - /* next pointer remains valid */ - symbol_remove(symbolP, &symbol_rootP, &symbol_lastP); - - } else if (!S_IS_DEFINED(symbolP) && !S_IS_DEBUG(symbolP) && !SF_GET_STATICS(symbolP)) { -/* S_GET_STORAGE_CLASS(symbolP) == C_EXT && !SF_GET_FUNCTION(symbolP)) { */ - /* if external, Remove from the list */ - symbolS *hold = symbol_previous(symbolP); - - symbol_remove(symbolP, &symbol_rootP, &symbol_lastP); - symbol_clear_list_pointers(symbolP); - symbol_append(symbolP, symbol_extern_lastP, &symbol_externP, &symbol_extern_lastP); - symbolP = hold; - } else { - if (SF_GET_STRING(symbolP)) { - symbolP->sy_name_offset = string_byte_count; - string_byte_count += strlen(S_GET_NAME(symbolP)) + 1; - } else { - symbolP->sy_name_offset = 0; - } /* fix "long" names */ - - symbolP->sy_number = symbol_number; - symbol_number += 1 + S_GET_NUMBER_AUXILIARY(symbolP); - } /* if local symbol */ - } /* traverse the symbol list */ - - for (symbolP = symbol_externP; symbol_externP;) { - symbolS *tmp = symbol_externP; - - /* append */ - symbol_remove(tmp, &symbol_externP, &symbol_extern_lastP); - symbol_append(tmp, symbol_lastP, &symbol_rootP, &symbol_lastP); - - /* and process */ - if (SF_GET_STRING(tmp)) { - tmp->sy_name_offset = string_byte_count; - string_byte_count += strlen(S_GET_NAME(tmp)) + 1; - } else { - tmp->sy_name_offset = 0; - } /* fix "long" names */ - - tmp->sy_number = symbol_number; - symbol_number += 1 + S_GET_NUMBER_AUXILIARY(tmp); - } /* append the entire extern chain */ - - /* When a tag reference preceeds the tag definition, - the definition will not have a number at the time - we process the reference during the first - traversal. Thus, a second traversal. */ - - for (symbolP = symbol_rootP; symbolP; symbolP = symbol_next(symbolP)) { - if (SF_GET_TAGGED(symbolP)) { - SA_SET_SYM_TAGNDX(symbolP, ((symbolS*) SA_GET_SYM_TAGNDX(symbolP))->sy_number); - } /* If the symbol has a tagndx entry, resolve it */ - } /* second traversal */ - - know(symbol_externP == NULL); - know(symbol_extern_lastP == NULL); - - /* FIXME-SOMEDAY I'm counting line no's here so we know what to put in the section - headers, and I'm resolving the addresses since I'm not sure how to - do it later. I am NOT resolving the linno's representing functions. - Their symbols need a fileptr pointing to this linno when emitted. - Thus, I resolve them on emit. xoxorich. */ - - for (lineP = lineno_rootP; lineP; lineP = lineP->next) { - if (lineP->line.l_lnno > 0) { - lineP->line.l_addr.l_paddr += ((fragS*)lineP->frag)->fr_address; - } else { - ; - } - text_lineno_number++; - } /* for each line number */ - - H_SET_SYMBOL_TABLE_SIZE(headers, symbol_number); - - return; -} /* obj_crawl_symbol_chain() */ - -/* - * Find strings by crawling along symbol table chain. - */ - -void obj_emit_strings(where) -char **where; -{ - symbolS *symbolP; - -#ifdef CROSS_COMPILE - /* Gotta do md_ byte-ordering stuff for string_byte_count first - KWK */ - md_number_to_chars(*where, string_byte_count, sizeof(string_byte_count)); - *where += sizeof(string_byte_count); -#else /* CROSS_COMPILE */ - append(where, (char *) &string_byte_count, (unsigned long) sizeof(string_byte_count)); -#endif /* CROSS_COMPILE */ - - for (symbolP = symbol_rootP; symbolP; symbolP = symbol_next(symbolP)) { - if (SF_GET_STRING(symbolP)) { - append(where, S_GET_NAME(symbolP), (unsigned long)(strlen(S_GET_NAME(symbolP)) + 1)); - } /* if it has a string */ - } /* walk the symbol chain */ - - return; -} /* obj_emit_strings() */ - -void obj_pre_write_hook(headers) -object_headers *headers; -{ - register int text_relocation_number = 0; - register int data_relocation_number = 0; - register fixS *fixP; - - /* FIXME-SOMEDAY this should be done at - fixup_segment time but I'm going to wait until I - do multiple segments. xoxorich. */ - /* Count the number of relocation entries for text and data */ - for (fixP = text_fix_root; fixP; fixP = fixP->fx_next) { - if (fixP->fx_addsy) { - ++text_relocation_number; -#ifdef TC_I960 - /* two relocs per callj under coff. */ - if (fixP->fx_callj) { - ++text_relocation_number; - } /* if callj and not already fixed. */ -#endif /* TC_I960 */ -#ifdef TC_A29K - /* Count 2 for a constH */ - if (fixP->fx_r_type == RELOC_CONSTH) { - ++text_relocation_number; - } -#endif - - } /* if not yet fixed */ - } /* for each fix */ - - SA_SET_SCN_NRELOC(dot_text_symbol, text_relocation_number); - /* Assign the number of line number entries for the text section */ - SA_SET_SCN_NLINNO(dot_text_symbol, text_lineno_number); - /* Assign the size of the section */ - SA_SET_SCN_SCNLEN(dot_text_symbol, H_GET_TEXT_SIZE(headers)); - - for (fixP = data_fix_root; fixP; fixP = fixP->fx_next) { - if (fixP->fx_addsy) { - ++data_relocation_number; - } /* if still relocatable */ -#ifdef TC_A29K - /* Count 2 for a constH */ - if (fixP->fx_r_type == RELOC_CONSTH) { - ++data_relocation_number; - } -#endif - - } /* for each fix */ - - - SA_SET_SCN_NRELOC(dot_data_symbol, data_relocation_number); - /* Assign the size of the section */ - SA_SET_SCN_SCNLEN(dot_data_symbol, H_GET_DATA_SIZE(headers)); - - /* Assign the size of the section */ - SA_SET_SCN_SCNLEN(dot_bss_symbol, H_GET_BSS_SIZE(headers)); - - /* pre write hook can add relocs (for 960 and 29k coff) so */ - headers->relocation_size = text_relocation_number * RELSZ + - data_relocation_number *RELSZ; - - - - /* Fill in extra coff fields */ - - /* Initialize general line number information. */ - H_SET_LINENO_SIZE(headers, text_lineno_number * LINESZ); - - /* filehdr */ - H_SET_FILE_MAGIC_NUMBER(headers, FILE_HEADER_MAGIC); - H_SET_NUMBER_OF_SECTIONS(headers, 3); /* text+data+bss */ -#ifndef OBJ_COFF_OMIT_TIMESTAMP - H_SET_TIME_STAMP(headers, (long)time((long*)0)); -#else /* OBJ_COFF_OMIT_TIMESTAMP */ - H_SET_TIME_STAMP(headers, 0); -#endif /* OBJ_COFF_OMIT_TIMESTAMP */ - H_SET_SYMBOL_TABLE_POINTER(headers, H_GET_SYMBOL_TABLE_FILE_OFFSET(headers)); -#if 0 -printf("FILHSZ %x\n", FILHSZ); -printf("OBJ_COFF_AOUTHDRSZ %x\n", OBJ_COFF_AOUTHDRSZ); -printf("section headers %x\n", H_GET_NUMBER_OF_SECTIONS(headers) * SCNHSZ); -printf("get text size %x\n", H_GET_TEXT_SIZE(headers)); -printf("get data size %x\n", H_GET_DATA_SIZE(headers)); -printf("get relocation size %x\n", H_GET_RELOCATION_SIZE(headers)); -printf("get lineno size %x\n", H_GET_LINENO_SIZE(headers)); -#endif - /* symbol table size allready set */ - H_SET_SIZEOF_OPTIONAL_HEADER(headers, OBJ_COFF_AOUTHDRSZ); - H_SET_FLAGS(headers, (text_lineno_number == 0 ? F_LNNO : 0) - | ((text_relocation_number + data_relocation_number) ? 0 : F_RELFLG) - | BYTE_ORDERING); - - /* aouthdr */ - /* magic number allready set */ - H_SET_VERSION_STAMP(headers, 0); - /* Text, data, bss size; entry point; text_start and data_start are already set */ - - /* Build section headers */ - - c_section_header(&text_section_header, - ".text", - 0, - H_GET_TEXT_SIZE(headers), - H_GET_TEXT_FILE_OFFSET(headers), - (SA_GET_SCN_NRELOC(dot_text_symbol) - ? H_GET_RELOCATION_FILE_OFFSET(headers) - : 0), - (text_lineno_number - ? H_GET_LINENO_FILE_OFFSET(headers) - : 0), - SA_GET_SCN_NRELOC(dot_text_symbol), - text_lineno_number, - section_alignment[(int) SEG_TEXT]); - - c_section_header(&data_section_header, - ".data", - H_GET_TEXT_SIZE(headers), - H_GET_DATA_SIZE(headers), - (H_GET_DATA_SIZE(headers) - ? H_GET_DATA_FILE_OFFSET(headers) - : 0), - (SA_GET_SCN_NRELOC(dot_data_symbol) - ? (H_GET_RELOCATION_FILE_OFFSET(headers) - + text_section_header.s_nreloc * RELSZ) - : 0), - 0, /* No line number information */ - SA_GET_SCN_NRELOC(dot_data_symbol), - 0, /* No line number information */ - section_alignment[(int) SEG_DATA]); - - c_section_header(&bss_section_header, - ".bss", - H_GET_TEXT_SIZE(headers) + H_GET_DATA_SIZE(headers), - H_GET_BSS_SIZE(headers), - 0, /* No file offset */ - 0, /* No relocation information */ - 0, /* No line number information */ - 0, /* No relocation information */ - 0, /* No line number information */ - section_alignment[(int) SEG_BSS]); - - return; -} /* obj_pre_write_hook() */ - -/* This is a copy from aout. All I do is neglect to actually build the symbol. */ - -static void obj_coff_stab(what) -int what; -{ - char *string; - expressionS e; - int goof = 0; /* TRUE if we have aborted. */ - int length; - int saved_type = 0; - long longint; - symbolS *symbolP = 0; - - if (what == 's') { - string = demand_copy_C_string(&length); - SKIP_WHITESPACE(); - - if (*input_line_pointer == ',') { - input_line_pointer++; - } else { - as_bad("I need a comma after symbol's name"); - goof = 1; - } /* better be a comma */ - } /* skip the string */ - - /* - * Input_line_pointer->after ','. String->symbol name. - */ - if (!goof) { - if (get_absolute_expression_and_terminator(&longint) != ',') { - as_bad("I want a comma after the n_type expression"); - goof = 1; - input_line_pointer--; /* Backup over a non-',' char. */ - } /* on error */ - } /* no error */ - - if (!goof) { - if (get_absolute_expression_and_terminator(&longint) != ',') { - as_bad("I want a comma after the n_other expression"); - goof = 1; - input_line_pointer--; /* Backup over a non-',' char. */ - } /* on error */ - } /* no error */ - - if (!goof) { - get_absolute_expression(); - - if (what == 's' || what == 'n') { - if (*input_line_pointer != ',') { - as_bad("I want a comma after the n_desc expression"); - goof = 1; - } else { - input_line_pointer++; - } /* on goof */ - } /* not stabd */ - } /* no error */ - - expression(&e); - - if (goof) { - ignore_rest_of_line(); - } else { - demand_empty_rest_of_line(); - } /* on error */ -} /* obj_coff_stab() */ - -#ifdef DEBUG - /* for debugging */ -char *s_get_name(s) -symbolS *s; -{ - return((s == NULL) ? "(NULL)" : S_GET_NAME(s)); -} /* s_get_name() */ - -void symbol_dump() { - symbolS *symbolP; - - for (symbolP = symbol_rootP; symbolP; symbolP = symbol_next(symbolP)) { - printf("%3ld: 0x%lx \"%s\" type = %ld, class = %d, segment = %d\n", - symbolP->sy_number, - (unsigned long) symbolP, - S_GET_NAME(symbolP), - (long) S_GET_DATA_TYPE(symbolP), - S_GET_STORAGE_CLASS(symbolP), - (int) S_GET_SEGMENT(symbolP)); - } /* traverse symbols */ - - return; -} /* symbol_dump() */ -#endif /* DEBUG */ - - -/* - * Local Variables: - * comment-column: 0 - * fill-column: 131 - * End: - */ - -/* end of obj-coff.c */ diff --git a/gas/config/obj-coff.h b/gas/config/obj-coff.h deleted file mode 100644 index f85ef5ad923..00000000000 --- a/gas/config/obj-coff.h +++ /dev/null @@ -1,593 +0,0 @@ -/* coff object file format - Copyright (C) 1989, 1990, 1991 Free Software Foundation, Inc. - -This file is part of GAS. - -GAS 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. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* $Id$ */ - -#define OBJ_COFF 1 - -#include "targ-cpu.h" - - - -#ifdef BFD_HEADERS -#ifdef TC_A29K -#include "bfd.h" -#include "coff-a29k.h" - -/* This internal_lineno crap is to stop namespace pollution from the bfd internal - coff headerfile. */ - - -#define internal_lineno bfd_internal_lineno -#include "internalcoff.h" -#undef internal_lineno -/* -#undef RELOC -#undef SYMENT -#undef AUXENT -#undef LINENO -#undef FILHDR -#undef SCNHDR -#define RELOC struct internal_reloc -#define SYMENT struct internal_syment -#define AUXENT union internal_auxent -#define SCNHDR struct internal_scnhdr -#define LINENO struct bfd_internal_lineno -#define AOUTHDR struct internal_aouthdr -#define FILHDR struct internal_filehdr -#define AOUTHDRSZ sizeof(struct external_aouthdr) -*/ -/*#define x_endndx x_endndx.l -#define x_tagndx x_tagndx.l*/ -#define TARGET_FORMAT "coff-a29k-big" -extern bfd *stdoutput; -#else -help me -#endif -#else -#include "coff.gnu.h" -#endif - -#ifdef USE_NATIVE_HEADERS -#include -#include -#include -#include -#include -#include -#include -#include -#endif /* USE_NATIVE_HEADERS */ - -/* Define some processor dependent values according to the processor we are - on. */ -#ifdef TC_M68K - -#define BYTE_ORDERING F_AR32W /* See filehdr.h for more info. */ -#ifndef FILE_HEADER_MAGIC -#define FILE_HEADER_MAGIC MC68MAGIC /* ... */ -#endif /* FILE_HEADER_MAGIC */ - -#elif defined(TC_I386) - -#define BYTE_ORDERING F_AR32WR /* See filehdr.h for more info. */ -#ifndef FILE_HEADER_MAGIC -#define FILE_HEADER_MAGIC I386MAGIC /* ... */ -#endif /* FILE_HEADER_MAGIC */ - -#elif defined(TC_I960) - -#define BYTE_ORDERING F_AR32WR /* See filehdr.h for more info. */ -#ifndef FILE_HEADER_MAGIC -#define FILE_HEADER_MAGIC I960ROMAGIC /* ... */ -#endif /* FILE_HEADER_MAGIC */ - -#elif defined(TC_A29K) - -#define BYTE_ORDERING F_AR32W /* big endian. */ -#ifndef FILE_HEADER_MAGIC -#define FILE_HEADER_MAGIC SIPFBOMAGIC -#endif /* FILE_HEADER_MAGIC */ - -#else -you lose -#endif - -#ifndef OBJ_COFF_MAX_AUXENTRIES -#define OBJ_COFF_MAX_AUXENTRIES 1 -#endif /* OBJ_COFF_MAX_AUXENTRIES */ - -extern const short seg_N_TYPE[]; -extern const segT N_TYPE_seg[]; - -/* Magic number of paged executable. */ -#define DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE (OMAGIC) - -#ifndef BFD_HEADERS - -/* Add these definitions to have a consistent convention for all the - types used in COFF format. */ -#define AOUTHDR struct aouthdr -#define AOUTHDRSZ sizeof(AOUTHDR) -#endif - -/* SYMBOL TABLE */ - - /* targets may also set this */ -#ifndef SYMBOLS_NEED_BACKPOINTERS -#define SYMBOLS_NEED_BACKPOINTERS 1 -#endif /* SYMBOLS_NEED_BACKPOINTERS */ - -/* Symbol table entry data type */ - -typedef struct { -#ifdef BFD_HEADERS - struct internal_syment ost_entry; /* Basic symbol */ - union internal_auxent ost_auxent[OBJ_COFF_MAX_AUXENTRIES]; /* Auxiliary entry. */ -#else - SYMENT ost_entry; /* Basic symbol */ - AUXENT ost_auxent[OBJ_COFF_MAX_AUXENTRIES]; /* Auxiliary entry. */ -#endif - unsigned int ost_flags; /* obj_coff internal use only flags */ -} obj_symbol_type; - -/* If compiler generate leading underscores, remove them. */ - -#ifndef STRIP_UNDERSCORE -#define STRIP_UNDERSCORE 0 -#endif /* STRIP_UNDERSCORE */ -#define DO_NOT_STRIP 0 -#define DO_STRIP 1 - -/* Symbol table macros and constants */ - -/* Possible and usefull section number in symbol table - * The values of TEXT, DATA and BSS may not be portable. - */ - -#define C_TEXT_SECTION ((short)1) -#define C_DATA_SECTION ((short)2) -#define C_BSS_SECTION ((short)3) -#define C_ABS_SECTION N_ABS -#define C_UNDEF_SECTION N_UNDEF -#define C_DEBUG_SECTION N_DEBUG -#define C_NTV_SECTION N_TV -#define C_PTV_SECTION P_TV -#define C_REGISTER_SECTION 4 - -/* - * Macros to extract information from a symbol table entry. - * This syntaxic indirection allows independence regarding a.out or coff. - * The argument (s) of all these macros is a pointer to a symbol table entry. - */ - -/* Predicates */ -/* True if the symbol is external */ -#define S_IS_EXTERNAL(s) ((s)->sy_symbol.ost_entry.n_scnum == C_UNDEF_SECTION) -/* True if symbol has been defined, ie : - section > 0 (DATA, TEXT or BSS) - section == 0 and value > 0 (external bss symbol) */ -#define S_IS_DEFINED(s) ((s)->sy_symbol.ost_entry.n_scnum > C_UNDEF_SECTION || \ - ((s)->sy_symbol.ost_entry.n_scnum == C_UNDEF_SECTION && \ - (s)->sy_symbol.ost_entry.n_value > 0)) -/* True if a debug special symbol entry */ -#define S_IS_DEBUG(s) ((s)->sy_symbol.ost_entry.n_scnum == C_DEBUG_SECTION) -/* True if a symbol is local symbol name */ -/* A symbol name whose name begin with ^A is a gas internal pseudo symbol */ -#define S_IS_LOCAL(s) (S_GET_NAME(s)[0] == '\001' || \ - (s)->sy_symbol.ost_entry.n_scnum == C_REGISTER_SECTION || \ - (S_LOCAL_NAME(s) && !flagseen['L'])) -/* True if a symbol is not defined in this file */ -#define S_IS_EXTERN(s) ((s)->sy_symbol.ost_entry.n_scnum == 0 && (s)->sy_symbol.ost_entry.n_value == 0) -/* - * True if a symbol can be multiply defined (bss symbols have this def - * though it is bad practice) - */ -#define S_IS_COMMON(s) ((s)->sy_symbol.ost_entry.n_scnum == 0 && (s)->sy_symbol.ost_entry.n_value != 0) -/* True if a symbol name is in the string table, i.e. its length is > 8. */ -#define S_IS_STRING(s) (strlen(S_GET_NAME(s)) > 8 ? 1 : 0) - -/* Accessors */ -/* The name of the symbol */ -#define S_GET_NAME(s) ((char*)(s)->sy_symbol.ost_entry.n_offset) -/* The pointer to the string table */ -#define S_GET_OFFSET(s) ((s)->sy_symbol.ost_entry.n_offset) -/* The zeroes if symbol name is longer than 8 chars */ -#define S_GET_ZEROES(s) ((s)->sy_symbol.ost_entry.n_zeroes) -/* The value of the symbol */ -#define S_GET_VALUE(s) ((unsigned) ((s)->sy_symbol.ost_entry.n_value)) -/* The numeric value of the segment */ -#define S_GET_SEGMENT(s) (N_TYPE_seg[(s)->sy_symbol.ost_entry.n_scnum+4]) -/* The data type */ -#define S_GET_DATA_TYPE(s) ((s)->sy_symbol.ost_entry.n_type) -/* The storage class */ -#define S_GET_STORAGE_CLASS(s) ((s)->sy_symbol.ost_entry.n_sclass) -/* The number of auxiliary entries */ -#define S_GET_NUMBER_AUXILIARY(s) ((s)->sy_symbol.ost_entry.n_numaux) - -/* Modifiers */ -/* Set the name of the symbol */ -#define S_SET_NAME(s,v) ((s)->sy_symbol.ost_entry.n_offset = (unsigned long)(v)) -/* Set the offset of the symbol */ -#define S_SET_OFFSET(s,v) ((s)->sy_symbol.ost_entry.n_offset = (v)) -/* The zeroes if symbol name is longer than 8 chars */ -#define S_SET_ZEROES(s,v) ((s)->sy_symbol.ost_entry.n_zeroes = (v)) -/* Set the value of the symbol */ -#define S_SET_VALUE(s,v) ((s)->sy_symbol.ost_entry.n_value = (v)) -/* The numeric value of the segment */ -#define S_SET_SEGMENT(s,v) ((s)->sy_symbol.ost_entry.n_scnum = SEGMENT_TO_SYMBOL_TYPE(v)) -/* The data type */ -#define S_SET_DATA_TYPE(s,v) ((s)->sy_symbol.ost_entry.n_type = (v)) -/* The storage class */ -#define S_SET_STORAGE_CLASS(s,v) ((s)->sy_symbol.ost_entry.n_sclass = (v)) -/* The number of auxiliary entries */ -#define S_SET_NUMBER_AUXILIARY(s,v) ((s)->sy_symbol.ost_entry.n_numaux = (v)) - -/* Additional modifiers */ -/* The symbol is external (does not mean undefined) */ -#define S_SET_EXTERNAL(s) { S_SET_STORAGE_CLASS(s, C_EXT) ; SF_CLEAR_LOCAL(s); } - -/* Auxiliary entry macros. SA_ stands for symbol auxiliary */ -/* Omit the tv related fields */ -/* Accessors */ -#ifdef BFD_HEADERS -#define SA_GET_SYM_TAGNDX(s) ((s)->sy_symbol.ost_auxent[0].x_sym.x_tagndx.l) -#else -#define SA_GET_SYM_TAGNDX(s) ((s)->sy_symbol.ost_auxent[0].x_sym.x_tagndx) -#endif -#define SA_GET_SYM_LNNO(s) ((s)->sy_symbol.ost_auxent[0].x_sym.x_misc.x_lnsz.x_lnno) -#define SA_GET_SYM_SIZE(s) ((s)->sy_symbol.ost_auxent[0].x_sym.x_misc.x_lnsz.x_size) -#define SA_GET_SYM_FSIZE(s) ((s)->sy_symbol.ost_auxent[0].x_sym.x_misc.x_fsize) -#define SA_GET_SYM_LNNOPTR(s) ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_fcn.x_lnnoptr) -#ifdef BFD_HEADERS -#define SA_GET_SYM_ENDNDX(s) ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_fcn.x_endndx.l) -#else -#define SA_GET_SYM_ENDNDX(s) ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_fcn.x_endndx) -#endif -#define SA_GET_SYM_DIMEN(s,i) ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_ary.x_dimen[(i)]) -#define SA_GET_FILE_FNAME(s) ((s)->sy_symbol.ost_auxent[0].x_file.x_fname) -#define SA_GET_SCN_SCNLEN(s) ((s)->sy_symbol.ost_auxent[0].x_scn.x_scnlen) -#define SA_GET_SCN_NRELOC(s) ((s)->sy_symbol.ost_auxent[0].x_scn.x_nreloc) -#define SA_GET_SCN_NLINNO(s) ((s)->sy_symbol.ost_auxent[0].x_scn.x_nlinno) - -/* Modifiers */ -#ifdef BFD_HEADERS -#define SA_SET_SYM_TAGNDX(s,v) ((s)->sy_symbol.ost_auxent[0].x_sym.x_tagndx.l=(v)) -#else -#define SA_SET_SYM_TAGNDX(s,v) ((s)->sy_symbol.ost_auxent[0].x_sym.x_tagndx=(v)) -#endif -#define SA_SET_SYM_LNNO(s,v) ((s)->sy_symbol.ost_auxent[0].x_sym.x_misc.x_lnsz.x_lnno=(v)) -#define SA_SET_SYM_SIZE(s,v) ((s)->sy_symbol.ost_auxent[0].x_sym.x_misc.x_lnsz.x_size=(v)) -#define SA_SET_SYM_FSIZE(s,v) ((s)->sy_symbol.ost_auxent[0].x_sym.x_misc.x_fsize=(v)) -#define SA_SET_SYM_LNNOPTR(s,v) ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_fcn.x_lnnoptr=(v)) -#ifdef BFD_HEADERS -#define SA_SET_SYM_ENDNDX(s,v) ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_fcn.x_endndx.l=(v)) -#else -#define SA_SET_SYM_ENDNDX(s,v) ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_fcn.x_endndx=(v)) -#endif -#define SA_SET_SYM_DIMEN(s,i,v) ((s)->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_ary.x_dimen[(i)]=(v)) -#define SA_SET_FILE_FNAME(s,v) strncpy((s)->sy_symbol.ost_auxent[0].x_file.x_fname,(v),FILNMLEN) -#define SA_SET_SCN_SCNLEN(s,v) ((s)->sy_symbol.ost_auxent[0].x_scn.x_scnlen=(v)) -#define SA_SET_SCN_NRELOC(s,v) ((s)->sy_symbol.ost_auxent[0].x_scn.x_nreloc=(v)) -#define SA_SET_SCN_NLINNO(s,v) ((s)->sy_symbol.ost_auxent[0].x_scn.x_nlinno=(v)) - -/* - * Internal use only definitions. SF_ stands for symbol flags. - * - * These values can be assigned to sy_symbol.ost_flags field of a symbolS. - * - * You'll break i960 if you shift the SYSPROC bits anywhere else. for - * more on the balname/callname hack, see tc-i960.h. b.out is done - * differently. - */ - -#define SF_I960_MASK (0x000001ff) /* Bits 0-8 are used by the i960 port. */ -#define SF_SYSPROC (0x0000003f) /* bits 0-5 are used to store the sysproc number */ -#define SF_IS_SYSPROC (0x00000040) /* bit 6 marks symbols that are sysprocs */ -#define SF_BALNAME (0x00000080) /* bit 7 marks BALNAME symbols */ -#define SF_CALLNAME (0x00000100) /* bit 8 marks CALLNAME symbols */ - -#define SF_NORMAL_MASK (0x0000ffff) /* bits 12-15 are general purpose. */ - -#define SF_STATICS (0x00001000) /* Mark the .text & all symbols */ -#define SF_DEFINED (0x00002000) /* Symbol is defined in this file */ -#define SF_STRING (0x00004000) /* Symbol name length > 8 */ -#define SF_LOCAL (0x00008000) /* Symbol must not be emitted */ - -#define SF_DEBUG_MASK (0xffff0000) /* bits 16-31 are debug info */ - -#define SF_FUNCTION (0x00010000) /* The symbol is a function */ -#define SF_PROCESS (0x00020000) /* Process symbol before write */ -#define SF_TAGGED (0x00040000) /* Is associated with a tag */ -#define SF_TAG (0x00080000) /* Is a tag */ -#define SF_DEBUG (0x00100000) /* Is in debug or abs section */ -#define SF_GET_SEGMENT (0x00200000) /* Get the section of the forward symbol. */ - /* All other bits are unused. */ - -/* Accessors */ -#define SF_GET(s) ((s)->sy_symbol.ost_flags) -#define SF_GET_NORMAL_FIELD(s) ((s)->sy_symbol.ost_flags & SF_NORMAL_MASK) -#define SF_GET_DEBUG_FIELD(s) ((s)->sy_symbol.ost_flags & SF_DEBUG_MASK) -#define SF_GET_FILE(s) ((s)->sy_symbol.ost_flags & SF_FILE) -#define SF_GET_STATICS(s) ((s)->sy_symbol.ost_flags & SF_STATICS) -#define SF_GET_DEFINED(s) ((s)->sy_symbol.ost_flags & SF_DEFINED) -#define SF_GET_STRING(s) ((s)->sy_symbol.ost_flags & SF_STRING) -#define SF_GET_LOCAL(s) ((s)->sy_symbol.ost_flags & SF_LOCAL) -#define SF_GET_FUNCTION(s) ((s)->sy_symbol.ost_flags & SF_FUNCTION) -#define SF_GET_PROCESS(s) ((s)->sy_symbol.ost_flags & SF_PROCESS) -#define SF_GET_DEBUG(s) ((s)->sy_symbol.ost_flags & SF_DEBUG) -#define SF_GET_TAGGED(s) ((s)->sy_symbol.ost_flags & SF_TAGGED) -#define SF_GET_TAG(s) ((s)->sy_symbol.ost_flags & SF_TAG) -#define SF_GET_GET_SEGMENT(s) ((s)->sy_symbol.ost_flags & SF_GET_SEGMENT) -#define SF_GET_I960(s) ((s)->sy_symbol.ost_flags & SF_I960_MASK) /* used by i960 */ -#define SF_GET_BALNAME(s) ((s)->sy_symbol.ost_flags & SF_BALNAME) /* used by i960 */ -#define SF_GET_CALLNAME(s) ((s)->sy_symbol.ost_flags & SF_CALLNAME) /* used by i960 */ -#define SF_GET_IS_SYSPROC(s) ((s)->sy_symbol.ost_flags & SF_IS_SYSPROC) /* used by i960 */ -#define SF_GET_SYSPROC(s) ((s)->sy_symbol.ost_flags & SF_SYSPROC) /* used by i960 */ - -/* Modifiers */ -#define SF_SET(s,v) ((s)->sy_symbol.ost_flags = (v)) -#define SF_SET_NORMAL_FIELD(s,v)((s)->sy_symbol.ost_flags |= ((v) & SF_NORMAL_MASK)) -#define SF_SET_DEBUG_FIELD(s,v) ((s)->sy_symbol.ost_flags |= ((v) & SF_DEBUG_MASK)) -#define SF_SET_FILE(s) ((s)->sy_symbol.ost_flags |= SF_FILE) -#define SF_SET_STATICS(s) ((s)->sy_symbol.ost_flags |= SF_STATICS) -#define SF_SET_DEFINED(s) ((s)->sy_symbol.ost_flags |= SF_DEFINED) -#define SF_SET_STRING(s) ((s)->sy_symbol.ost_flags |= SF_STRING) -#define SF_SET_LOCAL(s) ((s)->sy_symbol.ost_flags |= SF_LOCAL) -#define SF_CLEAR_LOCAL(s) ((s)->sy_symbol.ost_flags &= ~SF_LOCAL) -#define SF_SET_FUNCTION(s) ((s)->sy_symbol.ost_flags |= SF_FUNCTION) -#define SF_SET_PROCESS(s) ((s)->sy_symbol.ost_flags |= SF_PROCESS) -#define SF_SET_DEBUG(s) ((s)->sy_symbol.ost_flags |= SF_DEBUG) -#define SF_SET_TAGGED(s) ((s)->sy_symbol.ost_flags |= SF_TAGGED) -#define SF_SET_TAG(s) ((s)->sy_symbol.ost_flags |= SF_TAG) -#define SF_SET_GET_SEGMENT(s) ((s)->sy_symbol.ost_flags |= SF_GET_SEGMENT) -#define SF_SET_I960(s,v) ((s)->sy_symbol.ost_flags |= ((v) & SF_I960_MASK)) /* used by i960 */ -#define SF_SET_BALNAME(s) ((s)->sy_symbol.ost_flags |= SF_BALNAME) /* used by i960 */ -#define SF_SET_CALLNAME(s) ((s)->sy_symbol.ost_flags |= SF_CALLNAME) /* used by i960 */ -#define SF_SET_IS_SYSPROC(s) ((s)->sy_symbol.ost_flags |= SF_IS_SYSPROC) /* used by i960 */ -#define SF_SET_SYSPROC(s,v) ((s)->sy_symbol.ost_flags |= ((v) & SF_SYSPROC)) /* used by i960 */ - -/* File header macro and type definition */ - -/* - * File position calculators. Beware to use them when all the - * appropriate fields are set in the header. - */ - -#ifdef OBJ_COFF_OMIT_OPTIONAL_HEADER -#define OBJ_COFF_AOUTHDRSZ (0) -#else -#define OBJ_COFF_AOUTHDRSZ (AOUTHDRSZ) -#endif /* OBJ_COFF_OMIT_OPTIONAL_HEADER */ - -#define H_GET_FILE_SIZE(h) \ - (long)(FILHSZ + OBJ_COFF_AOUTHDRSZ + \ - H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ + \ - H_GET_TEXT_SIZE(h) + H_GET_DATA_SIZE(h) + \ - H_GET_RELOCATION_SIZE(h) + H_GET_LINENO_SIZE(h) + \ - H_GET_SYMBOL_TABLE_SIZE(h) + \ - (h)->string_table_size) -#define H_GET_TEXT_FILE_OFFSET(h) \ - (long)(FILHSZ + OBJ_COFF_AOUTHDRSZ + \ - H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ) -#define H_GET_DATA_FILE_OFFSET(h) \ - (long)(FILHSZ + OBJ_COFF_AOUTHDRSZ + \ - H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ + \ - H_GET_TEXT_SIZE(h)) -#define H_GET_BSS_FILE_OFFSET(h) 0 -#define H_GET_RELOCATION_FILE_OFFSET(h) \ - (long)(FILHSZ + OBJ_COFF_AOUTHDRSZ + \ - H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ + \ - H_GET_TEXT_SIZE(h) + H_GET_DATA_SIZE(h)) -#define H_GET_LINENO_FILE_OFFSET(h) \ - (long)(FILHSZ + OBJ_COFF_AOUTHDRSZ + \ - H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ + \ - H_GET_TEXT_SIZE(h) + H_GET_DATA_SIZE(h) + \ - H_GET_RELOCATION_SIZE(h)) -#define H_GET_SYMBOL_TABLE_FILE_OFFSET(h) \ - (long)(FILHSZ + OBJ_COFF_AOUTHDRSZ + \ - H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ + \ - H_GET_TEXT_SIZE(h) + H_GET_DATA_SIZE(h) + \ - H_GET_RELOCATION_SIZE(h) + H_GET_LINENO_SIZE(h)) - -/* Accessors */ -/* aouthdr */ -#define H_GET_MAGIC_NUMBER(h) ((h)->aouthdr.magic) -#define H_GET_VERSION_STAMP(h) ((h)->aouthdr.vstamp) -#define H_GET_TEXT_SIZE(h) ((h)->aouthdr.tsize) -#define H_GET_DATA_SIZE(h) ((h)->aouthdr.dsize) -#define H_GET_BSS_SIZE(h) ((h)->aouthdr.bsize) -#define H_GET_ENTRY_POINT(h) ((h)->aouthdr.entry) -#define H_GET_TEXT_START(h) ((h)->aouthdr.text_start) -#define H_GET_DATA_START(h) ((h)->aouthdr.data_start) -/* filehdr */ -#define H_GET_FILE_MAGIC_NUMBER(h) ((h)->filehdr.f_magic) -#define H_GET_NUMBER_OF_SECTIONS(h) ((h)->filehdr.f_nscns) -#define H_GET_TIME_STAMP(h) ((h)->filehdr.f_timdat) -#define H_GET_SYMBOL_TABLE_POINTER(h) ((h)->filehdr.f_symptr) -#define H_GET_SYMBOL_COUNT(h) ((h)->filehdr.f_nsyms) -#define H_GET_SYMBOL_TABLE_SIZE(h) (H_GET_SYMBOL_COUNT(h) * SYMESZ) -#define H_GET_SIZEOF_OPTIONAL_HEADER(h) ((h)->filehdr.f_opthdr) -#define H_GET_FLAGS(h) ((h)->filehdr.f_flags) -/* Extra fields to achieve bsd a.out compatibility and for convenience */ -#define H_GET_RELOCATION_SIZE(h) ((h)->relocation_size) -#define H_GET_STRING_SIZE(h) ((h)->string_table_size) -#define H_GET_LINENO_SIZE(h) ((h)->lineno_size) - -#ifndef OBJ_COFF_OMIT_OPTIONAL_HEADER -#define H_GET_HEADER_SIZE(h) (sizeof(FILHDR) \ - + sizeof(AOUTHDR)\ - + (H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ)) -#else /* OBJ_COFF_OMIT_OPTIONAL_HEADER */ -#define H_GET_HEADER_SIZE(h) (sizeof(FILHDR) \ - + (H_GET_NUMBER_OF_SECTIONS(h) * SCNHSZ)) -#endif /* OBJ_COFF_OMIT_OPTIONAL_HEADER */ - -#define H_GET_TEXT_RELOCATION_SIZE(h) (text_section_header.s_nreloc * RELSZ) -#define H_GET_DATA_RELOCATION_SIZE(h) (data_section_header.s_nreloc * RELSZ) - -/* Modifiers */ -/* aouthdr */ -#define H_SET_MAGIC_NUMBER(h,v) ((h)->aouthdr.magic = (v)) -#define H_SET_VERSION_STAMP(h,v) ((h)->aouthdr.vstamp = (v)) -#define H_SET_TEXT_SIZE(h,v) ((h)->aouthdr.tsize = (v)) -#define H_SET_DATA_SIZE(h,v) ((h)->aouthdr.dsize = (v)) -#define H_SET_BSS_SIZE(h,v) ((h)->aouthdr.bsize = (v)) -#define H_SET_ENTRY_POINT(h,v) ((h)->aouthdr.entry = (v)) -#define H_SET_TEXT_START(h,v) ((h)->aouthdr.text_start = (v)) -#define H_SET_DATA_START(h,v) ((h)->aouthdr.data_start = (v)) -/* filehdr */ -#define H_SET_FILE_MAGIC_NUMBER(h,v) ((h)->filehdr.f_magic = (v)) -#define H_SET_NUMBER_OF_SECTIONS(h,v) ((h)->filehdr.f_nscns = (v)) -#define H_SET_TIME_STAMP(h,v) ((h)->filehdr.f_timdat = (v)) -#define H_SET_SYMBOL_TABLE_POINTER(h,v) ((h)->filehdr.f_symptr = (v)) -#define H_SET_SYMBOL_TABLE_SIZE(h,v) ((h)->filehdr.f_nsyms = (v)) -#define H_SET_SIZEOF_OPTIONAL_HEADER(h,v) ((h)->filehdr.f_opthdr = (v)) -#define H_SET_FLAGS(h,v) ((h)->filehdr.f_flags = (v)) -/* Extra fields to achieve bsd a.out compatibility and for convinience */ -#define H_SET_RELOCATION_SIZE(h,t,d) ((h)->relocation_size = (t)+(d)) -#define H_SET_STRING_SIZE(h,v) ((h)->string_table_size = (v)) -#define H_SET_LINENO_SIZE(h,v) ((h)->lineno_size = (v)) - - /* Segment flipping */ -#define segment_name(v) (seg_name[(int) (v)]) - -typedef struct { -#ifdef BFD_HEADERS - struct internal_aouthdr aouthdr; /* a.out header */ - struct internal_filehdr filehdr; /* File header, not machine dep. */ -#else - AOUTHDR aouthdr; /* a.out header */ - FILHDR filehdr; /* File header, not machine dep. */ -#endif - long string_table_size; /* names + '\0' + sizeof(int) */ - long relocation_size; /* Cumulated size of relocation - information for all sections in - bytes. */ - long lineno_size; /* Size of the line number information - table in bytes */ -} object_headers; - -/* -------------- Line number handling ------- */ -extern int text_lineno_number; - -/* line numbering stuff. */ - -typedef struct internal_lineno { -#ifdef BFD_HEADERS - struct bfd_internal_lineno line; -#else - LINENO line; /* The lineno structure itself */ -#endif - char* frag; /* Frag to which the line number is related */ - struct internal_lineno* next; /* Forward chain pointer */ -} lineno; - -extern lineno *lineno_lastP; -extern lineno *lineno_rootP; -#define OBJ_EMIT_LINENO(a, b, c) obj_emit_lineno((a),(b),(c)) - -#ifdef __STDC__ -void obj_emit_lineno(char **where, lineno *line, char *file_start); -#else /* __STDC__ */ -void obj_emit_lineno(); -#endif /* __STDC__ */ - - /* stack stuff */ -typedef struct { - unsigned long chunk_size; - unsigned long element_size; - unsigned long size; - char* data; - unsigned long pointer; -} stack; - -#ifdef __STDC__ - -char *stack_pop(stack *st); -char *stack_push(stack *st, char *element); -char *stack_top(stack *st); -stack *stack_init(unsigned long chunk_size, unsigned long element_size); -void c_dot_file_symbol(char *filename); -void obj_extra_stuff(object_headers *headers); -void stack_delete(stack *st); - -#ifndef tc_headers_hook -void tc_headers_hook(object_headers *headers); -#endif /* tc_headers_hook */ - -#ifndef tc_coff_symbol_emit_hook -void tc_coff_symbol_emit_hook(); /* really tc_coff_symbol_emit_hook(symbolS *symbolP) */ -#endif /* tc_coff_symbol_emit_hook */ - -void c_section_header( -#ifdef BFD_HEADERS - struct internal_scnhdr *header, -#else - SCNHDR *header, -#endif - - char *name, - long core_address, - long size, - long data_ptr, - long reloc_ptr, - long lineno_ptr, - long reloc_number, - long lineno_number, - long alignment); - -#else /* __STDC__ */ - -char *stack_pop(); -char *stack_push(); -char *stack_top(); -stack *stack_init(); -void c_dot_file_symbol(); -void c_section_header(); -void obj_extra_stuff(); -void stack_delete(); -void tc_headers_hook(); -void tc_coff_symbol_emit_hook(); - -#endif /* __STDC__ */ - - - /* sanity check */ - -#ifdef TC_I960 -#ifndef C_LEAFSTAT -hey! Where is the C_LEAFSTAT definition? i960-coff support is depending on it. -#endif /* no C_LEAFSTAT */ -#endif /* TC_I960 */ -#ifdef BFD_HEADERS -extern struct internal_scnhdr data_section_header; -extern struct internal_scnhdr text_section_header; -#else -extern SCNHDR data_section_header; -extern SCNHDR text_section_header; -#endif -/* - * Local Variables: - * comment-column: 0 - * fill-column: 131 - * End: - */ - -/* end of obj-coff.h */ diff --git a/gas/config/obj-generic.c b/gas/config/obj-generic.c deleted file mode 100644 index 86eac73c2e8..00000000000 --- a/gas/config/obj-generic.c +++ /dev/null @@ -1,27 +0,0 @@ -/* - * This file is obj-generic.c and is intended to be a template for - * object format specific source files. - * - * Last Mod Thu Jan 3 19:30:50 PST 1991, by rich@sendai - */ - -/* Chars that can be used to separate mant from exp in floating point nums */ -char EXP_CHARS[] = "eE"; - -/* Chars that mean this number is a floating point constant */ -/* As in 0f12.456 */ -/* or 0d1.2345e12 */ -char FLT_CHARS[] = "rRsSfFdDxXpP"; - -/* These chars start a comment anywhere in a source file (except inside - another comment */ -const char comment_chars[] = "#"; - -/* - * Local Variables: - * comment-column: 0 - * fill-column: 131 - * End: - */ - -/* end of obj-generic.c */ diff --git a/gas/config/obj-generic.h b/gas/config/obj-generic.h deleted file mode 100644 index d9e03dcd538..00000000000 --- a/gas/config/obj-generic.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * This file is obj-generic.h and is intended to be a template for - * object format specific header files. - */ - - /* define an obj specific macro off which target cpu back ends may key. */ -#define OBJ_GENERIC 1 - - /* include whatever target cpu is appropriate. */ -#include "targ-cpu.h" - -/* - * SYMBOLS - */ - -/* - * If your object format needs to reorder symbols, define this. When - * defined, symbols are kept on a doubly linked list and functions are - * made available for push, insert, append, and delete. If not defined, - * symbols are kept on a singly linked list, only the append and clear - * facilities are available, and they are macros. - */ - - /* #define SYMBOLS_NEED_PACKPOINTERS */ - - /* */ -typedef struct { - void *nothing; -} obj_symbol_type; /* should be the format's symbol structure */ - -typedef void *object_headers; - - /* symbols have names */ -#define S_GET_NAME(s) ("foo") /* get the name of a symbolP */ -#define S_SET_NAME(s,v) ; - /* symbols have segments */ -#define S_GET_SEGMENT(s) (SEG_UNKNOWN) -#define S_SET_SEGMENT(s,v) ; - /* symbols have a value */ -#define S_GET_VALUE(s) (0) -#define S_SET_VALUE(s,v) ; - /* symbols may be external */ -#define S_IS_EXTERNAL(s) (0) -#define S_SET_EXTERNAL(s) ; - - /* symbols may or may not be defined */ -#define S_IS_DEFINED(s) (0) - - -#define DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE (0) /* your magic number */ - -#define OBJ_EMIT_LINENO(a,b,c) /* must be *something*. This no-op's it out. */ - -/* - * Local Variables: - * comment-column: 0 - * fill-column: 131 - * End: - */ - -/* end of obj-generic.h */ diff --git a/gas/config/obj-ieee.c b/gas/config/obj-ieee.c deleted file mode 100644 index aaffab5df44..00000000000 --- a/gas/config/obj-ieee.c +++ /dev/null @@ -1,537 +0,0 @@ -/* obj-format for ieee-695 records. - Copyright (C) 1991 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - - -/* - created by - - steve chamberlain steve@cygnus.com -*/ - -/* - this will hopefully become the port through which bfd and gas talk, - for the moment, only ieee is known to work well. -*/ - -#include "bfd.h" -#include "as.h" -#include "subsegs.h" -#include "output-file.h" -#include "frags.h" - -bfd *abfd; - -/* How many addresses does the .align take? */ -static relax_addressT relax_align(address, alignment) -register relax_addressT address; /* Address now. */ -register long alignment; /* Alignment (binary). */ -{ - relax_addressT mask; - relax_addressT new_address; - - mask = ~ ( (~0) << alignment ); - new_address = (address + mask) & (~ mask); - return (new_address - address); -} /* relax_align() */ - -/* calculate the size of the frag chain and create a bfd section - to contain all of it */ -static void DEFUN(size_section,(abfd, idx), - bfd *abfd AND - unsigned int idx) -{ - asection *sec; - unsigned int size = 0; - fragS *frag = segment_info[idx].frag_root; - while (frag) { - if (frag->fr_address != size) { - printf("Out of step\n"); - size = frag->fr_address; - } - size += frag->fr_fix; - switch (frag->fr_type) { - case rs_fill: - case rs_org: - size += frag->fr_offset * frag->fr_var; - break; - case rs_align: - size += relax_align(size, frag->fr_offset); - } - frag = frag->fr_next; - } - if (size) { - char *name = segment_info[idx].name; - if (name == (char *)NULL) { - name = ".data"; - } - segment_info[idx].user_stuff = (char *)(sec = bfd_make_section(abfd, name)); - /* Make it output through itself */ - sec->output_section = sec; - sec->flags |= SEC_HAS_CONTENTS; - bfd_set_section_size(abfd, sec, size); - } -} - -/* run through a frag chain and write out the data to go with it */ -static void DEFUN(fill_section,(abfd, idx), - bfd *abfd AND - unsigned int idx) -{ - asection *sec = segment_info[idx].user_stuff; - if (sec) { - fragS *frag = segment_info[idx].frag_root; - unsigned int offset = 0; - while (frag) { - unsigned int fill_size; - unsigned int count; - switch (frag->fr_type) { - case rs_fill: - case rs_align: - case rs_org: - if(frag->fr_fix) - { - bfd_set_section_contents(abfd, - sec, - frag->fr_literal, - frag->fr_address, - frag->fr_fix); - } - offset += frag->fr_fix; - fill_size = frag->fr_var; - if (fill_size) - { - unsigned int off = frag->fr_fix; - for (count = frag->fr_offset; count; count--) - { - bfd_set_section_contents(abfd, sec, - frag->fr_literal + - frag->fr_fix, - frag->fr_address + off, - fill_size); - off += fill_size; - } - } - break; - default: - abort(); - } - frag = frag->fr_next; - } - } -} - -/* Count the relocations in a chain */ - -static unsigned int DEFUN(count_entries_in_chain,(idx), - unsigned int idx) -{ - unsigned int nrelocs; - fixS *fixup_ptr; - - /* Count the relocations */ - fixup_ptr = segment_info[idx].fix_root; - nrelocs = 0; - while (fixup_ptr != (fixS *)NULL) - { - fixup_ptr = fixup_ptr->fx_next; - nrelocs ++ ; - } - return nrelocs; -} - -/* output all the relocations for a section */ -void DEFUN(do_relocs_for,(idx), - unsigned int idx) -{ - unsigned int nrelocs; - arelent **reloc_ptr_vector; - arelent *reloc_vector; - asymbol **ptrs; - asection *section = (asection *)(segment_info[idx].user_stuff); - unsigned int i; - fixS *from; - if (section) { - nrelocs = count_entries_in_chain(idx); - - reloc_ptr_vector = (arelent**)malloc((nrelocs+1) * sizeof(arelent *)); - reloc_vector = (arelent*)malloc(nrelocs * sizeof(arelent)); - ptrs = (asymbol **)malloc(nrelocs * sizeof(asymbol *)); - from = segment_info[idx].fix_root; - for (i = 0; i < nrelocs; i++) - { - arelent *to = reloc_vector + i; - asymbol *s ; - reloc_ptr_vector[i] = to; - to->howto = (reloc_howto_type *)(from->fx_r_type); - - /* We can't represent complicated things in a reloc yet */ - /* if (from->fx_addsy == 0 || - from->fx_subsy != 0) abort(); - */ - s = &( from->fx_addsy->sy_symbol.sy); - to->address = ((char *)( from->fx_frag->fr_address + - from->fx_where)) - - ((char *)(&(from->fx_frag->fr_literal))); - to->addend = from->fx_offset ; - /* If we know the symbol which we want to relocate to, turn this - reloaction into a section relative. - - If this relocation is pcrelative, and we know the - destination, we still want to keep the relocation - since - the linker might relax some of the bytes, but it stops - being pc relative and turns into an absolute relocation. - - */ - if (s) { - if ((s->flags & BSF_UNDEFINED)==0) { - to->section = s->section; - to->addend += s->value ; - to->sym_ptr_ptr = 0; - if (to->howto->pcrel_offset) { - /* This is a pcrel relocation, the addend should be adjusted */ - to->addend -= to->address +1; - } - } - else { - to->section = 0; - *ptrs = &(from->fx_addsy->sy_symbol.sy); - to->sym_ptr_ptr = ptrs; - - if (to->howto->pcrel_offset) { - /* This is a pcrel relocation, the addend should be adjusted */ - to->addend -= to->address -1; - } - } - - } - else { - to->section = 0; - } - - ptrs++; - from = from->fx_next; - } - - /* attatch to the section */ - section->orelocation = reloc_ptr_vector; - section->reloc_count = nrelocs; - section->flags |= SEC_LOAD; - } -} - -/* do the symbols.. */ -static void DEFUN(do_symbols, (abfd), - bfd *abfd) -{ - extern symbolS *symbol_rootP; - symbolS *ptr; - asymbol **symbol_ptr_vec; - asymbol *symbol_vec; - unsigned int count = 0; - unsigned int index; - - - for (ptr = symbol_rootP; - ptr != (symbolS *)NULL; - ptr = ptr->sy_next) - { - if (SEG_NORMAL(ptr->sy_symbol.seg)) - { - ptr->sy_symbol.sy.section = - (asection *)(segment_info[ptr->sy_symbol.seg].user_stuff); - ptr->sy_symbol.sy.value += ptr->sy_frag->fr_address; - if (ptr->sy_symbol.sy.flags == 0) { - ptr->sy_symbol.sy.flags = BSF_LOCAL ; - } - } - else { - switch (ptr->sy_symbol.seg) { - case SEG_ABSOLUTE: - ptr->sy_symbol.sy.flags |= BSF_ABSOLUTE; - ptr->sy_symbol.sy.section = 0; - break; - case SEG_UNKNOWN: - ptr->sy_symbol.sy.flags = BSF_UNDEFINED ; - ptr->sy_symbol.sy.section = 0; - break; - default: - abort(); - } - } - count++; - } - symbol_ptr_vec = (asymbol **)malloc((count+1) * sizeof(asymbol *)); - - index = 0; - for (ptr = symbol_rootP; - ptr != (symbolS *)NULL; - ptr = ptr->sy_next) - { - symbol_ptr_vec[index] = &(ptr->sy_symbol.sy); - index++; - } - symbol_ptr_vec[index] =0; - abfd->outsymbols = symbol_ptr_vec; - abfd->symcount = count; -} - -/* The generic as->bfd converter. Other backends may have special case - code */ - -void DEFUN_VOID(bfd_as_write_hook) -{ - int i; - - for (i = SEG_E0; i < SEG_UNKNOWN; i++) { - size_section(abfd, i); - } - - - for (i = SEG_E0; i < SEG_UNKNOWN; i++) - fill_section(abfd,i); - - do_symbols(abfd); - - for (i = SEG_E0; i < SEG_UNKNOWN; i++) - do_relocs_for(i); - -} - - - -S_GET_VALUE(x) -symbolS *x; -{ - return x->sy_symbol.sy.value; -} - -S_SET_SEGMENT(x,y) -symbolS *x ; -int y; -{ - x->sy_symbol.seg = y; -} - -S_IS_DEFINED(x) -symbolS *x; -{ - if (SEG_NORMAL(x->sy_symbol.seg)) - { - return 1; - } - switch (x->sy_symbol.seg) - { - case SEG_UNKNOWN: - return 0; - default: - abort(); - } -} - -S_IS_EXTERNAL(x) { abort(); } -S_GET_DESC(x) { abort() ; } - -S_GET_SEGMENT(x) -symbolS *x; - { return x->sy_symbol.seg; } - -S_SET_EXTERNAL(x) -symbolS *x; -{ -x->sy_symbol.sy.flags |= BSF_GLOBAL | BSF_EXPORT; -} - -S_SET_NAME(x,y) -symbolS*x; -char *y; { -x->sy_symbol.sy.name = y; } - -S_SET_VALUE(s,v) -symbolS *s; -long v; -{ - s->sy_symbol.sy.value = v; -} - -S_GET_OTHER(x) { abort() ;} -S_IS_DEBUG(x) { abort(); } - -char *segment_name() { abort(); } - -void obj_read_begin_hook() { } - -static void obj_ieee_section(ignore) -int ignore; -{ - extern char *input_line_pointer; - extern char is_end_of_line[]; - char *p= input_line_pointer; - char *s = p; - int i; - /* Look up the name, if it doesn't exist, make it */ - while (*p &&* p != ' ' && *p != ',' && !is_end_of_line[*p]) { - p++; - } - for (i = SEG_E0; i < SEG_UNKNOWN; i++) { - if (segment_info[i].hadone){ - if (strncmp(segment_info[i].name, s, p-s) ==0) { - goto ok; - - } - } - else break; - } - if (i == SEG_UNKNOWN) { - as_bad("too many sections"); - return; - } - - segment_info[i].hadone = 1; - segment_info[i].name = malloc(p-s + 1); - memcpy(segment_info[i].name, s, p-s); - segment_info[i].name[p-s] = 0; - ok: - subseg_new(i,0); - while (!is_end_of_line[*p]) - p++; - input_line_pointer = p; - -} - - -void cons(); -void s_ignore(); - - -/* - * stringer() - * - * We read 0 or more ',' seperated, double-quoted strings. - * - * Caller should have checked need_pass_2 is FALSE because we don't check it. - */ - -void stringer(); -void s_globl(); -const pseudo_typeS obj_pseudo_table[] = -{ - {"section", obj_ieee_section, 0}, - {"data.b", cons, 1}, - {"data.w", cons, 2}, - {"data.l", cons, 4}, - {"export", s_globl, 0}, - {"option", s_ignore, 0}, - {"end", s_ignore, 0}, - {"import", s_ignore, 0}, - {"sdata", stringer, 0}, - 0, - -}; - - - -void obj_symbol_new_hook(symbolP) -symbolS *symbolP; -{ - symbolP->sy_symbol.sy.the_bfd = abfd; -} - - - - - -#if 1 -extern void DEFUN_VOID(write_object_file) -{ - int i; - struct frchain *frchain_ptr; - struct frag *frag_ptr; - - abfd = bfd_openw(out_file_name, "ieee"); - - if (abfd == 0) { - as_perror ("FATAL: Can't create %s", out_file_name); - exit(42); - } - bfd_set_format(abfd, bfd_object); - bfd_set_arch_mach(abfd, bfd_arch_h8300, 0); - subseg_new(1,0); - subseg_new(2,0); - subseg_new(3,0); - for (frchain_ptr = frchain_root; - frchain_ptr != (struct frchain *)NULL; - frchain_ptr = frchain_ptr->frch_next) { - /* Run through all the sub-segments and align them up. Also close any - open frags. We tack a .fill onto the end of the frag chain so - that any .align's size can be worked by looking at the next - frag */ - - subseg_new(frchain_ptr->frch_seg, frchain_ptr->frch_subseg); -#define SUB_SEGMENT_ALIGN 2 - frag_align(SUB_SEGMENT_ALIGN,0); - frag_wane(frag_now); - frag_now->fr_fix = 0; - know( frag_now->fr_next == NULL ); - } - - /* Now build one big frag chain for each segment, linked through - fr_next. */ - for (i = SEG_E0; i < SEG_UNKNOWN; i++) - { - - fragS ** prev_frag_ptr_ptr ; - struct frchain *next_frchain_ptr; - - /* struct frag **head_ptr = segment_info[i].frag_root;*/ - - segment_info[i].frag_root = segment_info[i].frchainP->frch_root; -#if 0 - /* Im not sure what this is for */ - for (frchain_ptr = segment_info[i].frchainP->frch_root; - frchain_ptr != (struct frchain *)NULL; - frchain_ptr = frchain_ptr->frch_next) - { - *head_ptr = frchain_ptr; - head_ptr = &frchain_ptr->next; - } - - -#endif - } - - for (i = SEG_E0; i < SEG_UNKNOWN; i++) { - relax_segment(segment_info[i].frag_root, i); - } - - /* Now the addresses of the frags are correct within the segment */ - - bfd_as_write_hook(); - bfd_close(abfd); -} - -#endif - -H_SET_TEXT_SIZE(a,b) { abort(); } -H_GET_TEXT_SIZE() { abort(); } -H_SET_BSS_SIZE() { abort(); } -H_SET_STRING_SIZE() { abort(); } -H_SET_RELOCATION_SIZE() { abort(); } -H_SET_MAGIC_NUMBER() { abort(); } -H_GET_FILE_SIZE() { abort(); } -H_GET_TEXT_RELOCATION_SIZE() { abort(); } diff --git a/gas/config/obj-ieee.h b/gas/config/obj-ieee.h deleted file mode 100644 index c796e332554..00000000000 --- a/gas/config/obj-ieee.h +++ /dev/null @@ -1,25 +0,0 @@ -#define BFD 1 - - -#include - -typedef struct -{ -asymbol sy; -int seg; -} obj_symbol_type; - -#define S_GET_NAME(s) (((s)->sy_symbol.sy.name)) - -typedef struct { -int x; -} -object_headers; - -#define DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE 1 - - -int lineno_rootP; - - -#define IEEE_STYLE diff --git a/gas/config/ranlib.h b/gas/config/ranlib.h deleted file mode 100755 index 936ba3467c1..00000000000 --- a/gas/config/ranlib.h +++ /dev/null @@ -1,17 +0,0 @@ -/* ranlib.h 4.1 83/05/03 */ - -/* - * Structure of the __.SYMDEF table of contents for an archive. - * __.SYMDEF begins with a word giving the number of ranlib structures - * which immediately follow, and then continues with a string - * table consisting of a word giving the number of bytes of strings - * which follow and then the strings themselves. - * The ran_strx fields index the string table whose first byte is numbered 0. - */ -struct ranlib { - union { - off_t ran_strx; /* string table index of */ - char *ran_name; /* symbol defined by */ - } ran_un; - off_t ran_off; /* library member at this offset */ -}; diff --git a/gas/config/rs6000.mt b/gas/config/rs6000.mt deleted file mode 100644 index f40f51d2bfa..00000000000 --- a/gas/config/rs6000.mt +++ /dev/null @@ -1 +0,0 @@ -ALL=fake-as diff --git a/gas/config/signame.h b/gas/config/signame.h deleted file mode 100755 index d3d075e36fc..00000000000 --- a/gas/config/signame.h +++ /dev/null @@ -1,41 +0,0 @@ -/* Convert between signal names and numbers. - Copyright (C) 1990 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; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Names for signals from 0 to NSIG-1. */ -extern char *sys_siglist[]; - -#ifdef __STDC__ -/* Return the abbreviation (e.g. ABRT, FPE, etc.) for signal NUMBER. - Do not return this as a const char *. The caller might want to - assign it to a char *. */ -char *sig_abbrev (int number); - -/* Return the signal number for an ABBREV, or -1 if there is no - signal by that name. */ -int sig_number (const char *abbrev); - -/* Print to standard error the name of SIGNAL, preceded by MESSAGE and - a colon, and followed by a newline. */ -void psignal (int signal, const char *message); - -#else - -char *sig_abbrev (); -int sig_number (); -void psignal (); - -#endif diff --git a/gas/config/stab.h b/gas/config/stab.h deleted file mode 100755 index 77f2d411ce3..00000000000 --- a/gas/config/stab.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef __GNU_STAB__ - -/* Indicate the GNU stab.h is in use. */ - -#define __GNU_STAB__ - -#define __define_stab(NAME, CODE, STRING) NAME=CODE, - -enum __stab_debug_code -{ -#include "stab.def" -}; - -#undef __define_stab - -#endif /* __GNU_STAB_ */ diff --git a/gas/config/tc-a29k.c b/gas/config/tc-a29k.c deleted file mode 100644 index 3e716d514b1..00000000000 --- a/gas/config/tc-a29k.c +++ /dev/null @@ -1,1139 +0,0 @@ -/* tc-a29k.c -- Assemble for the AMD 29000. - Copyright (C) 1989, 1990, 1991 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* $Id$ */ - -/* John Gilmore has reorganized this module somewhat, to make it easier - to convert it to new machines' assemblers as desired. There was too - much bloody rewriting required before. There still probably is. */ - -#include "as.h" - -#include "a29k-opcode.h" - -/* Make it easier to clone this machine desc into another one. */ -#define machine_opcode a29k_opcode -#define machine_opcodes a29k_opcodes -#define machine_ip a29k_ip -#define machine_it a29k_it - -const relax_typeS md_relax_table[] = { 0 }; - -#define IMMEDIATE_BIT 0x01000000 /* Turns RB into Immediate */ -#define ABSOLUTE_BIT 0x01000000 /* Turns PC-relative to Absolute */ -#define CE_BIT 0x00800000 /* Coprocessor enable in LOAD */ -#define UI_BIT 0x00000080 /* Unsigned integer in CONVERT */ - -/* handle of the OPCODE hash table */ -static struct hash_control *op_hash = NULL; - -struct machine_it { - char *error; - unsigned long opcode; - struct nlist *nlistp; - expressionS exp; - int pcrel; - int reloc_offset; /* Offset of reloc within insn */ - enum reloc_type reloc; -} the_insn; - -#ifdef __STDC__ - -/* static int getExpression(char *str); */ -static void machine_ip(char *str); -/* static void print_insn(struct machine_it *insn); */ -static void s_data1(void); -static void s_use(void); - -#else /* __STDC__ */ - -/* static int getExpression(); */ -static void machine_ip(); -/* static void print_insn(); */ -static void s_data1(); -static void s_use(); - -#endif /* __STDC__ */ - -const pseudo_typeS -md_pseudo_table[] = { - { "align", s_align_bytes, 4 }, - { "block", s_space, 0 }, - { "cputype", s_ignore, 0 }, /* CPU as 29000 or 29050 */ - { "file", s_ignore, 0 }, /* COFF File name for debug info? */ - { "line", s_ignore, 0 }, /* Line number of coff symbol */ - { "reg", s_lsym, 0 }, /* Register equate, same as equ */ - { "space", s_ignore, 0 }, /* Listing control */ - { "sect", s_ignore, 0 }, /* Creation of coff sections */ - { "use", s_use, 0 }, - { "word", cons, 4 }, - { NULL, 0, 0 }, -}; - -int md_short_jump_size = 4; -int md_long_jump_size = 4; -#if defined(BFD_HEADERS) -#ifdef RELSZ -int md_reloc_size = RELSZ; /* Coff headers */ -#else -int md_reloc_size = 12; /* something else headers */ -#endif -#else -int md_reloc_size = 12; /* Not bfdized*/ -#endif - -/* This array holds the chars that always start a comment. If the - pre-processor is disabled, these aren't very useful */ -char comment_chars[] = ";"; - -/* This array holds the chars that only start a comment at the beginning of - a line. If the line seems to have the form '# 123 filename' - .line and .file directives will appear in the pre-processed output */ -/* Note that input_file.c hand checks for '#' at the beginning of the - first line of the input file. This is because the compiler outputs - #NO_APP at the beginning of its output. */ -/* Also note that comments like this one will always work */ -char line_comment_chars[] = "#"; - -/* We needed an unused char for line separation to work around the - lack of macros, using sed and such. */ -char line_separator_chars[] = "@"; - -/* Chars that can be used to separate mant from exp in floating point nums */ -char EXP_CHARS[] = "eE"; - -/* Chars that mean this number is a floating point constant */ -/* As in 0f12.456 */ -/* or 0d1.2345e12 */ -char FLT_CHARS[] = "rRsSfFdDxXpP"; - -/* Also be aware that MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT may have to be - changed in read.c . Ideally it shouldn't have to know about it at all, - but nothing is ideal around here. - */ - -static unsigned char octal[256]; -#define isoctal(c) octal[c] -static unsigned char toHex[256]; - -/* - * anull bit - causes the branch delay slot instructions to not be executed - */ -#define ANNUL (1 << 29) - -static void -s_use() -{ - - if (strncmp(input_line_pointer, ".text", 5) == 0) { - input_line_pointer += 5; - s_text(); - return; - } - if (strncmp(input_line_pointer, ".data", 5) == 0) { - input_line_pointer += 5; - s_data(); - return; - } - if (strncmp(input_line_pointer, ".data1", 6) == 0) { - input_line_pointer += 6; - s_data1(); - return; - } - /* Literals can't go in the text segment because you can't read - from instruction memory on some 29k's. So, into initialized data. */ - if (strncmp(input_line_pointer, ".lit", 4) == 0) { - input_line_pointer += 4; - subseg_new(SEG_DATA, 200); - demand_empty_rest_of_line(); - return; - } - - as_bad("Unknown segment type"); - demand_empty_rest_of_line(); - return; -} - -static void -s_data1() -{ - subseg_new(SEG_DATA, 1); - demand_empty_rest_of_line(); - return; -} - -/* Install symbol definition that maps REGNAME to REGNO. - FIXME-SOON: These are not recognized in mixed case. */ - -static void -insert_sreg (regname, regnum) - char *regname; - int regnum; -{ - /* FIXME-SOON, put something in these syms so they won't be output to the symbol - table of the resulting object file. */ - - /* Must be large enough to hold the names of the special registers. */ - char buf[80]; - int i; - - symbol_table_insert(symbol_new(regname, SEG_REGISTER, regnum, &zero_address_frag)); - for (i = 0; regname[i]; i++) - buf[i] = islower (regname[i]) ? toupper (regname[i]) : regname[i]; - buf[i] = '\0'; - - symbol_table_insert(symbol_new(buf, SEG_REGISTER, regnum, &zero_address_frag)); -} /* insert_sreg() */ - -/* Install symbol definitions for assorted special registers. - See ASM29K Ref page 2-9. */ - -void define_some_regs() { -#define SREG 256 - - /* Protected special-purpose register names */ - insert_sreg ("vab", SREG+0); - insert_sreg ("ops", SREG+1); - insert_sreg ("cps", SREG+2); - insert_sreg ("cfg", SREG+3); - insert_sreg ("cha", SREG+4); - insert_sreg ("chd", SREG+5); - insert_sreg ("chc", SREG+6); - insert_sreg ("rbp", SREG+7); - insert_sreg ("tmc", SREG+8); - insert_sreg ("tmr", SREG+9); - insert_sreg ("pc0", SREG+10); - insert_sreg ("pc1", SREG+11); - insert_sreg ("pc2", SREG+12); - insert_sreg ("mmu", SREG+13); - insert_sreg ("lru", SREG+14); - - /* Unprotected special-purpose register names */ - insert_sreg ("ipc", SREG+128); - insert_sreg ("ipa", SREG+129); - insert_sreg ("ipb", SREG+130); - insert_sreg ("q", SREG+131); - insert_sreg ("alu", SREG+132); - insert_sreg ("bp", SREG+133); - insert_sreg ("fc", SREG+134); - insert_sreg ("cr", SREG+135); - insert_sreg ("fpe", SREG+160); - insert_sreg ("inte",SREG+161); - insert_sreg ("fps", SREG+162); - /* "", SREG+163); Reserved */ - insert_sreg ("exop",SREG+164); -} /* define_some_regs() */ - -/* This function is called once, at assembler startup time. It should - set up all the tables, etc. that the MD part of the assembler will need. */ -void -md_begin() -{ - register char *retval = NULL; - int lose = 0; - register int skipnext = 0; - register unsigned int i; - register char *strend, *strend2; - - /* Hash up all the opcodes for fast use later. */ - - op_hash = hash_new(); - if (op_hash == NULL) - as_fatal("Virtual memory exhausted"); - - for (i = 0; i < num_opcodes; i++) - { - const char *name = machine_opcodes[i].name; - - if (skipnext) { - skipnext = 0; - continue; - } - - /* Hack to avoid multiple opcode entries. We pre-locate all the - variations (b/i field and P/A field) and handle them. */ - - if (!strcmp (name, machine_opcodes[i+1].name)) { - if ((machine_opcodes[i].opcode ^ machine_opcodes[i+1].opcode) - != 0x01000000) - goto bad_table; - strend = machine_opcodes[i ].args+strlen(machine_opcodes[i ].args)-1; - strend2 = machine_opcodes[i+1].args+strlen(machine_opcodes[i+1].args)-1; - switch (*strend) { - case 'b': - if (*strend2 != 'i') goto bad_table; - break; - case 'i': - if (*strend2 != 'b') goto bad_table; - break; - case 'P': - if (*strend2 != 'A') goto bad_table; - break; - case 'A': - if (*strend2 != 'P') goto bad_table; - break; - default: - bad_table: - fprintf (stderr, "internal error: can't handle opcode %s\n", name); - lose = 1; - } - - /* OK, this is an i/b or A/P pair. We skip the higher-valued one, - and let the code for operand checking handle OR-ing in the bit. */ - if (machine_opcodes[i].opcode & 1) - continue; - else - skipnext = 1; - } - - retval = hash_insert (op_hash, name, &machine_opcodes[i]); - if (retval != NULL && *retval != '\0') - { - fprintf (stderr, "internal error: can't hash `%s': %s\n", - machine_opcodes[i].name, retval); - lose = 1; - } - } - - if (lose) - as_fatal("Broken assembler. No assembly attempted."); - - for (i = '0'; i < '8'; ++i) - octal[i] = 1; - for (i = '0'; i <= '9'; ++i) - toHex[i] = i - '0'; - for (i = 'a'; i <= 'f'; ++i) - toHex[i] = i + 10 - 'a'; - for (i = 'A'; i <= 'F'; ++i) - toHex[i] = i + 10 - 'A'; - - define_some_regs (); -} - -void md_end() { - return; -} - -/* Assemble a single instruction. Its label has already been handled - by the generic front end. We just parse opcode and operands, and - produce the bytes of data and relocation. */ - -void md_assemble(str) - char *str; -{ - char *toP; -/* !!!! int rsd; */ - - know(str); - machine_ip(str); - toP = frag_more(4); - /* put out the opcode */ - md_number_to_chars(toP, the_insn.opcode, 4); - - /* put out the symbol-dependent stuff */ - if (the_insn.reloc != NO_RELOC) { - fix_new( - frag_now, /* which frag */ - (toP - frag_now->fr_literal + the_insn.reloc_offset), /* where */ - 4, /* size */ - the_insn.exp.X_add_symbol, - the_insn.exp.X_subtract_symbol, - the_insn.exp.X_add_number, - the_insn.pcrel, - the_insn.reloc - ); - } -} - -char * -parse_operand (s, operandp) - char *s; - expressionS *operandp; -{ - char *save = input_line_pointer; - char *new; - segT seg; - - input_line_pointer = s; - seg = expr (0, operandp); - new = input_line_pointer; - input_line_pointer = save; - - switch (seg) { - case SEG_ABSOLUTE: - case SEG_TEXT: - case SEG_DATA: - case SEG_BSS: - case SEG_UNKNOWN: - case SEG_DIFFERENCE: - case SEG_BIG: - case SEG_REGISTER: - return new; - - case SEG_ABSENT: - as_bad("Missing operand"); - return new; - - default: - as_bad("Don't understand operand of type %s", segment_name (seg)); - return new; - } -} - -/* Instruction parsing. Takes a string containing the opcode. - Operands are at input_line_pointer. Output is in the_insn. - Warnings or errors are generated. */ - -static void -machine_ip(str) - char *str; -{ - char *s; - const char *args; -/* !!!! char c; */ -/* !!!! unsigned long i; */ - struct machine_opcode *insn; - char *argsStart; - unsigned long opcode; -/* !!!! unsigned int mask; */ - expressionS the_operand; - expressionS *operand = &the_operand; - unsigned int reg; - - /* Must handle `div0' opcode. */ - s = str; - if (isalpha(*s)) - for (; isalnum(*s); ++s) - if (isupper (*s)) - *s = tolower (*s); - - switch (*s) { - case '\0': - break; - - case ' ': /* FIXME-SOMEDAY more whitespace */ - *s++ = '\0'; - break; - - default: - as_bad("Unknown opcode: `%s'", str); - return; - } - if ((insn = (struct machine_opcode *) hash_find(op_hash, str)) == NULL) { - as_bad("Unknown opcode `%s'.", str); - return; - } - argsStart = s; - opcode = insn->opcode; - bzero(&the_insn, sizeof(the_insn)); - the_insn.reloc = NO_RELOC; - - /* - * Build the opcode, checking as we go to make - * sure that the operands match. - * - * If an operand matches, we modify the_insn or opcode appropriately, - * and do a "continue". If an operand fails to match, we "break". - */ - if (insn->args[0] != '\0') - s = parse_operand (s, operand); /* Prime the pump */ - - for (args = insn->args; ; ++args) { - switch (*args) { - - case '\0': /* end of args */ - if (*s == '\0') { - /* We are truly done. */ - the_insn.opcode = opcode; - return; - } - as_bad("Too many operands: %s", s); - break; - - case ',': /* Must match a comma */ - if (*s++ == ',') { - s = parse_operand (s, operand); /* Parse next opnd */ - continue; - } - break; - - case 'v': /* Trap numbers (immediate field) */ - if (operand->X_seg == SEG_ABSOLUTE) { - if (operand->X_add_number < 256) { - opcode |= (operand->X_add_number << 16); - continue; - } else { - as_bad("Immediate value of %d is too large", - operand->X_add_number); - continue; - } - } - the_insn.reloc = RELOC_8; - the_insn.reloc_offset = 1; /* BIG-ENDIAN Byte 1 of insn */ - the_insn.exp = *operand; - continue; - - case 'b': /* A general register or 8-bit immediate */ - case 'i': - /* We treat the two cases identically since we mashed - them together in the opcode table. */ - if (operand->X_seg == SEG_REGISTER) - goto general_reg; - - opcode |= IMMEDIATE_BIT; - if (operand->X_seg == SEG_ABSOLUTE) { - if (operand->X_add_number < 256) { - opcode |= operand->X_add_number; - continue; - } else { - as_bad("Immediate value of %d is too large", - operand->X_add_number); - continue; - } - } - the_insn.reloc = RELOC_8; - the_insn.reloc_offset = 3; /* BIG-ENDIAN Byte 3 of insn */ - the_insn.exp = *operand; - continue; - - case 'a': /* next operand must be a register */ - case 'c': - general_reg: - /* lrNNN or grNNN or %%expr or a user-def register name */ - if (operand->X_seg != SEG_REGISTER) - break; /* Only registers */ - know (operand->X_add_symbol == 0); - know (operand->X_subtract_symbol == 0); - reg = operand->X_add_number; - if (reg >= SREG) - break; /* No special registers */ - - /* - * Got the register, now figure out where - * it goes in the opcode. - */ - switch (*args) { - case 'a': - opcode |= reg << 8; - continue; - - case 'b': - case 'i': - opcode |= reg; - continue; - - case 'c': - opcode |= reg << 16; - continue; - } - as_fatal("failed sanity check."); - break; - - case 'x': /* 16 bit constant, zero-extended */ - case 'X': /* 16 bit constant, one-extended */ - if (operand->X_seg == SEG_ABSOLUTE) { - opcode |= (operand->X_add_number & 0xFF) << 0 | - ((operand->X_add_number & 0xFF00) << 8); - continue; - } - the_insn.reloc = RELOC_CONST; - the_insn.exp = *operand; - continue; - - case 'h': - if (operand->X_seg == SEG_ABSOLUTE) { - opcode |= (operand->X_add_number & 0x00FF0000) >> 16 | - (((unsigned long)operand->X_add_number - /* avoid sign ext */ & 0xFF000000) >> 8); - continue; - } - the_insn.reloc = RELOC_CONSTH; - the_insn.exp = *operand; - continue; - - case 'P': /* PC-relative jump address */ - case 'A': /* Absolute jump address */ - /* These two are treated together since we folded the - opcode table entries together. */ - if (operand->X_seg == SEG_ABSOLUTE) { - opcode |= ABSOLUTE_BIT | - (operand->X_add_number & 0x0003FC00) << 6 | - ((operand->X_add_number & 0x000003FC) >> 2); - continue; - } - the_insn.reloc = RELOC_JUMPTARG; - the_insn.exp = *operand; - the_insn.pcrel = 1; /* Assume PC-relative jump */ - /* FIXME-SOON, Do we figure out whether abs later, after know sym val? */ - continue; - - case 'e': /* Coprocessor enable bit for LOAD/STORE insn */ - if (operand->X_seg == SEG_ABSOLUTE) { - if (operand->X_add_number == 0) - continue; - if (operand->X_add_number == 1) { - opcode |= CE_BIT; - continue; - } - } - break; - - case 'n': /* Control bits for LOAD/STORE instructions */ - if (operand->X_seg == SEG_ABSOLUTE && - operand->X_add_number < 128) { - opcode |= (operand->X_add_number << 16); - continue; - } - break; - - case 's': /* Special register number */ - if (operand->X_seg != SEG_REGISTER) - break; /* Only registers */ - if (operand->X_add_number < SREG) - break; /* Not a special register */ - opcode |= (operand->X_add_number & 0xFF) << 8; - continue; - - case 'u': /* UI bit of CONVERT */ - if (operand->X_seg == SEG_ABSOLUTE) { - if (operand->X_add_number == 0) - continue; - if (operand->X_add_number == 1) { - opcode |= UI_BIT; - continue; - } - } - break; - - case 'r': /* RND bits of CONVERT */ - if (operand->X_seg == SEG_ABSOLUTE && - operand->X_add_number < 8) { - opcode |= operand->X_add_number << 4; - continue; - } - break; - - case 'd': /* FD bits of CONVERT */ - if (operand->X_seg == SEG_ABSOLUTE && - operand->X_add_number < 4) { - opcode |= operand->X_add_number << 2; - continue; - } - break; - - - case 'f': /* FS bits of CONVERT */ - if (operand->X_seg == SEG_ABSOLUTE && - operand->X_add_number < 4) { - opcode |= operand->X_add_number << 0; - continue; - } - break; - - case 'C': - if (operand->X_seg == SEG_ABSOLUTE && - operand->X_add_number < 4) { - opcode |= operand->X_add_number << 16; - continue; - } - break; - - case 'F': - if (operand->X_seg == SEG_ABSOLUTE && - operand->X_add_number < 16) { - opcode |= operand->X_add_number << 18; - continue; - } - break; - - default: - BAD_CASE (*args); - } - /* Types or values of args don't match. */ - as_bad("Invalid operands"); - return; - } -} - -/* - This is identical to the md_atof in m68k.c. I think this is right, - but I'm not sure. - - Turn a string in input_line_pointer into a floating point constant of type - type, and store the appropriate bytes in *litP. The number of LITTLENUMS - emitted is stored in *sizeP . An error message is returned, or NULL on OK. - */ - -/* Equal to MAX_PRECISION in atof-ieee.c */ -#define MAX_LITTLENUMS 6 - -char * -md_atof(type,litP,sizeP) - char type; - char *litP; - int *sizeP; -{ - int prec; - LITTLENUM_TYPE words[MAX_LITTLENUMS]; - LITTLENUM_TYPE *wordP; - char *t; - - switch(type) { - - case 'f': - case 'F': - case 's': - case 'S': - prec = 2; - break; - - case 'd': - case 'D': - case 'r': - case 'R': - prec = 4; - break; - - case 'x': - case 'X': - prec = 6; - break; - - case 'p': - case 'P': - prec = 6; - break; - - default: - *sizeP=0; - return "Bad call to MD_ATOF()"; - } - t=atof_ieee(input_line_pointer,type,words); - if(t) - input_line_pointer=t; - *sizeP=prec * sizeof(LITTLENUM_TYPE); - for(wordP=words;prec--;) { - md_number_to_chars(litP,(long)(*wordP++),sizeof(LITTLENUM_TYPE)); - litP+=sizeof(LITTLENUM_TYPE); - } - return ""; /* Someone should teach Dean about null pointers */ -} - -/* - * Write out big-endian. - */ -void -md_number_to_chars(buf,val,n) - char *buf; - long val; - int n; -{ - - switch(n) { - - case 4: - *buf++ = val >> 24; - *buf++ = val >> 16; - case 2: - *buf++ = val >> 8; - case 1: - *buf = val; - break; - - default: - as_fatal("failed sanity check."); - } - return; -} - -void md_apply_fix(fixP, val) - fixS *fixP; - long val; -{ - char *buf = fixP->fx_where + fixP->fx_frag->fr_literal; - - fixP->fx_addnumber = val; /* Remember value for emit_reloc */ - - if (fixP->fx_r_type == NO_RELOC) { - as_fatal("failed sanity check."); /* FIXME-SOON, if this is never used, remove */ - switch (fixP->fx_size) { - case 1: - *buf = val; - break; - case 2: - *buf++ = (val>>8); - *buf = val; - break; - case 4: - *buf++ = (val>>24); - *buf++ = (val>>16); - *buf++ = (val>>8); - *buf = val; - break; - default: - as_fatal("failed sanity check."); - } - return; - } - - know(fixP->fx_size == 4); - know(fixP->fx_r_type < NO_RELOC); - - /* - * This is a hack. There should be a better way to - * handle this. - */ - if (fixP->fx_r_type == RELOC_WDISP30 && fixP->fx_addsy) { - val += fixP->fx_where + fixP->fx_frag->fr_address; - } - - switch (fixP->fx_r_type) { - - case RELOC_32: - buf[0] = val >> 24; - buf[1] = val >> 16; - buf[2] = val >> 8; - buf[3] = val; - break; - - case RELOC_8: - buf[0] = val; - break; - - case RELOC_WDISP30: - val = (val >>= 2) + 1; - buf[0] |= (val >> 24) & 0x3f; - buf[1]= (val >> 16); - buf[2] = val >> 8; - buf[3] = val; - break; - - case RELOC_HI22: - buf[1] |= (val >> 26) & 0x3f; - buf[2] = val >> 18; - buf[3] = val >> 10; - break; - - case RELOC_LO10: - buf[2] |= (val >> 8) & 0x03; - buf[3] = val; - break; - - case RELOC_BASE13: - buf[2] |= (val >> 8) & 0x1f; - buf[3] = val; - break; - - case RELOC_WDISP22: - val = (val >>= 2) + 1; - /* FALLTHROUGH */ - case RELOC_BASE22: - buf[1] |= (val >> 16) & 0x3f; - buf[2] = val >> 8; - buf[3] = val; - break; - -#if 0 - case RELOC_PC10: - case RELOC_PC22: - case RELOC_JMP_TBL: - case RELOC_SEGOFF16: - case RELOC_GLOB_DAT: - case RELOC_JMP_SLOT: - case RELOC_RELATIVE: -#endif - case RELOC_JUMPTARG: /* 00XX00XX pattern in a word */ - buf[1] = val >> 10; /* Holds bits 0003FFFC of address */ - buf[3] = val >> 2; - break; - - case RELOC_CONST: /* 00XX00XX pattern in a word */ - buf[1] = val >> 8; /* Holds bits 0000XXXX */ - buf[3] = val; - break; - - case RELOC_CONSTH: /* 00XX00XX pattern in a word */ - buf[1] = val >> 24; /* Holds bits XXXX0000 */ - buf[3] = val >> 16; - break; - - case NO_RELOC: - default: - as_bad("bad relocation type: 0x%02x", fixP->fx_r_type); - break; - } - return; -} - -#ifdef OBJ_COFF -short tc_coff_fix2rtype(fixP) -fixS *fixP; -{ - - /* FIXME-NOW: relocation type handling is not yet written for - a29k. */ - - - switch (fixP->fx_r_type) { - case RELOC_32: return(R_WORD); - case RELOC_8: return(R_BYTE); - case RELOC_CONST: return (R_ILOHALF); - case RELOC_CONSTH: return (R_IHIHALF); - case RELOC_JUMPTARG: return (R_IREL); - default: printf("need %o3\n", fixP->fx_r_type); - abort(0); - } /* switch on type */ - - return(0); -} /* tc_coff_fix2rtype() */ -#endif /* OBJ_COFF */ - -/* should never be called for sparc */ -void md_create_short_jump(ptr, from_addr, to_addr, frag, to_symbol) - char *ptr; - long from_addr, to_addr; -fragS *frag; -symbolS *to_symbol; -{ - as_fatal("a29k_create_short_jmp\n"); -} - -/* should never be called for 29k */ -void md_convert_frag(headers, fragP) -object_headers *headers; - register fragS *fragP; -{ - as_fatal("sparc_convert_frag\n"); -} - -/* should never be called for 29k */ -void md_create_long_jump(ptr, from_addr, to_addr, frag, to_symbol) - char *ptr; - long from_addr, - to_addr; - fragS *frag; - symbolS *to_symbol; -{ - as_fatal("sparc_create_long_jump\n"); -} - -/* should never be called for sparc */ -int md_estimate_size_before_relax(fragP, segtype) - register fragS *fragP; -segT segtype; -{ - as_fatal("sparc_estimate_size_before_relax\n"); -} - -#if 0 -/* for debugging only */ -static void -print_insn(insn) - struct machine_it *insn; -{ - char *Reloc[] = { - "RELOC_8", - "RELOC_16", - "RELOC_32", - "RELOC_DISP8", - "RELOC_DISP16", - "RELOC_DISP32", - "RELOC_WDISP30", - "RELOC_WDISP22", - "RELOC_HI22", - "RELOC_22", - "RELOC_13", - "RELOC_LO10", - "RELOC_SFA_BASE", - "RELOC_SFA_OFF13", - "RELOC_BASE10", - "RELOC_BASE13", - "RELOC_BASE22", - "RELOC_PC10", - "RELOC_PC22", - "RELOC_JMP_TBL", - "RELOC_SEGOFF16", - "RELOC_GLOB_DAT", - "RELOC_JMP_SLOT", - "RELOC_RELATIVE", - "NO_RELOC" - }; - - if (insn->error) { - fprintf(stderr, "ERROR: %s\n"); - } - fprintf(stderr, "opcode=0x%08x\n", insn->opcode); - fprintf(stderr, "reloc = %s\n", Reloc[insn->reloc]); - fprintf(stderr, "exp = {\n"); - fprintf(stderr, "\t\tX_add_symbol = %s\n", - insn->exp.X_add_symbol ? - (S_GET_NAME(insn->exp.X_add_symbol) ? - S_GET_NAME(insn->exp.X_add_symbol) : "???") : "0"); - fprintf(stderr, "\t\tX_sub_symbol = %s\n", - insn->exp.X_subtract_symbol ? - (S_GET_NAME(insn->exp.X_subtract_symbol) ? - S_GET_NAME(insn->exp.X_subtract_symbol) : "???") : "0"); - fprintf(stderr, "\t\tX_add_number = %d\n", - insn->exp.X_add_number); - fprintf(stderr, "}\n"); - return; -} -#endif - -/* Translate internal representation of relocation info to target format. - - On sparc/29k: first 4 bytes are normal unsigned long address, next three - bytes are index, most sig. byte first. Byte 7 is broken up with - bit 7 as external, bits 6 & 5 unused, and the lower - five bits as relocation type. Next 4 bytes are long addend. */ -/* Thanx and a tip of the hat to Michael Bloom, mb@ttidca.tti.com */ - -#ifdef OBJ_AOUT - -void tc_aout_fix_to_chars(where, fixP, segment_address_in_file) -char *where; -fixS *fixP; -relax_addressT segment_address_in_file; -{ - long r_index; - - know(fixP->fx_r_type < NO_RELOC); - know(fixP->fx_addsy != NULL); - - r_index = (S_IS_DEFINED(fixP->fx_addsy) - ? S_GET_TYPE(fixP->fx_addsy) - : fixP->fx_addsy->sy_number); - - /* this is easy */ - md_number_to_chars(where, - fixP->fx_frag->fr_address + fixP->fx_where - segment_address_in_file, - 4); - - /* now the fun stuff */ - where[4] = (r_index >> 16) & 0x0ff; - where[5] = (r_index >> 8) & 0x0ff; - where[6] = r_index & 0x0ff; - where[7] = (((!S_IS_DEFINED(fixP->fx_addsy)) << 7) & 0x80) | (0 & 0x60) | (fixP->fx_r_type & 0x1F); - /* Also easy */ - md_number_to_chars(&where[8], fixP->fx_addnumber, 4); - - return; -} /* tc_aout_fix_to_chars() */ - -#endif /* OBJ_AOUT */ - -int -md_parse_option(argP,cntP,vecP) - char **argP; - int *cntP; - char ***vecP; -{ - return(0); -} - - -/* Default the values of symbols known that should be "predefined". We - don't bother to predefine them unless you actually use one, since there - are a lot of them. */ - -symbolS *md_undefined_symbol (name) - char *name; -{ - long regnum; - char testbuf[5+ /*SLOP*/ 5]; - - if (name[0] == 'g' || name[0] == 'G' || name[0] == 'l' || name[0] == 'L') - { - /* Perhaps a global or local register name */ - if (name[1] == 'r' || name[1] == 'R') - { - /* Parse the number, make sure it has no extra zeroes or trailing - chars */ - regnum = atol(&name[2]); - if (regnum > 127) - return 0; - sprintf(testbuf, "%ld", regnum); - if (strcmp (testbuf, &name[2]) != 0) - return 0; /* gr007 or lr7foo or whatever */ - - /* We have a wiener! Define and return a new symbol for it. */ - if (name[0] == 'l' || name[0] == 'L') - regnum += 128; - return(symbol_new(name, SEG_REGISTER, regnum, &zero_address_frag)); - } - } - - return 0; -} - -/* Parse an operand that is machine-specific. */ - -void md_operand(expressionP) - expressionS *expressionP; -{ - - if (input_line_pointer[0] == '%' && input_line_pointer[1] == '%') - { - /* We have a numeric register expression. No biggy. */ - input_line_pointer += 2; /* Skip %% */ - (void)expression (expressionP); - if (expressionP->X_seg != SEG_ABSOLUTE - || expressionP->X_add_number > 255) - as_bad("Invalid expression after %%%%\n"); - expressionP->X_seg = SEG_REGISTER; - } - else if (input_line_pointer[0] == '&') - { - /* We are taking the 'address' of a register...this one is not - in the manual, but it *is* in traps/fpsymbol.h! What they - seem to want is the register number, as an absolute number. */ - input_line_pointer++; /* Skip & */ - (void)expression (expressionP); - if (expressionP->X_seg != SEG_REGISTER) - as_bad("Invalid register in & expression"); - else - expressionP->X_seg = SEG_ABSOLUTE; - } -} - -/* Round up a section size to the appropriate boundary. */ -long -md_section_align (segment, size) - segT segment; - long size; -{ - return size; /* Byte alignment is fine */ -} - -/* Exactly what point is a PC-relative offset relative TO? - On the 29000, they're relative to the address of the instruction, - which we have set up as the address of the fixup too. */ -long md_pcrel_from (fixP) - fixS *fixP; -{ - return fixP->fx_where + fixP->fx_frag->fr_address; -} - -/* - * Local Variables: - * comment-column: 0 - * End: - */ - -/* end of tc-a29k.c */ diff --git a/gas/config/tc-a29k.h b/gas/config/tc-a29k.h deleted file mode 100644 index 85f4de5e203..00000000000 --- a/gas/config/tc-a29k.h +++ /dev/null @@ -1,31 +0,0 @@ -/* tc-a29k.h -- Assemble for the AMD 29000. - Copyright (C) 1989, 1990, 1991 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* $Id$ */ - -#define TC_A29K - -#define tc_headers_hook(a) ; /* not used */ -#define tc_headers_hook(a) ; /* not used */ -#define tc_crawl_symbol_chain(a) ; /* not used */ -#define tc_coff_symbol_emit_hook(a) ; /* not used */ - -#define AOUT_MACHTYPE 101 - -/* end of tc-a29k.h */ diff --git a/gas/config/tc-generic.c b/gas/config/tc-generic.c deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/gas/config/tc-generic.h b/gas/config/tc-generic.h deleted file mode 100644 index aa63410e57f..00000000000 --- a/gas/config/tc-generic.h +++ /dev/null @@ -1,15 +0,0 @@ -/* - * This file is tc-generic.h and is intended to be a template for - * target cpu specific header files. - */ - -#define TC_GENERIC 1 - -/* - * Local Variables: - * comment-column: 0 - * fill-column: 131 - * End: - */ - -/* end of tc-generic.h */ diff --git a/gas/config/tc-h8300.c b/gas/config/tc-h8300.c deleted file mode 100644 index b68307d1522..00000000000 --- a/gas/config/tc-h8300.c +++ /dev/null @@ -1,662 +0,0 @@ -/* tc-h8300.c -- Assemble code for the Hitachi h8/300 - Copyright (C) 1991 Free Software Foundation. - -This file is part of GAS, the GNU Assembler. - -GAS 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. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - - -/* - Written By Steve Chamberlain - steve@cygnus.com - */ - -#include -#include "as.h" -#include "bfd.h" -#include "h8300-opcode.h" -#include - -char comment_chars[] = { ';',0 }; - -/* This table describes all the machine specific pseudo-ops the assembler - has to support. The fields are: - pseudo-op name without dot - function to call to execute this pseudo-op - Integer arg to pass to the function - */ -const pseudo_typeS md_pseudo_table[] = { - { 0, 0, 0 } -}; - -int md_reloc_size ; - -const char EXP_CHARS[] = "eE"; - -/* Chars that mean this number is a floating point constant */ -/* As in 0f12.456 */ -/* or 0d1.2345e12 */ - char FLT_CHARS[] = "rRsSfFdDxXpP"; - - -const relax_typeS md_relax_table[1]; - - -static struct hash_control *opcode_hash_control; /* Opcode mnemonics */ -static struct hash_control *register_hash_control; /* Register name hash table */ - - -/* - This function is called once, at assembler startup time. This should - set up all the tables, etc that the MD part of the assembler needs -*/ - -reloc_howto_type *r16; -reloc_howto_type *r8; -reloc_howto_type *r8ff; -reloc_howto_type *r8pcrel; - -void md_begin () -{ - bfd_arch_info_struct_type *ai; - const struct h8_opcode *opcode; - - opcode_hash_control = hash_new(); - for (opcode = h8_opcodes; opcode->name; opcode++) { - hash_insert(opcode_hash_control, opcode->name, (char *)opcode); - } - - ai = bfd_lookup_arch(bfd_arch_h8300,0); - - r16 = ai->reloc_type_lookup(ai, BFD_RELOC_16); - r8 = ai->reloc_type_lookup(ai, BFD_RELOC_8); - r8ff = ai->reloc_type_lookup(ai, BFD_RELOC_8_FFnn); - r8pcrel = ai->reloc_type_lookup(ai, BFD_RELOC_8_PCREL); - - -} - - -struct h8_exp { - char *e_beg; - char *e_end; - expressionS e_exp; -}; -struct h8_op -{ -op_enum_type mode; - unsigned reg; - expressionS exp; -}; - - - -/* - parse operands - WREG r0,r1,r2,r3,r4,r5,r6,r7,fp,sp - r0l,r0h,..r7l,r7h - @WREG - @WREG+ - @-WREG - #const - -*/ - -op_enum_type r8_sord[] = {RS8, RD8}; -op_enum_type r16_sord[] = {RS16, RD16}; -op_enum_type rind_sord[] = {RSIND, RDIND}; -op_enum_type abs_sord[2] = {ABS16SRC, ABS16DST}; -op_enum_type disp_sord[] = {DISPSRC, DISPDST}; -/* try and parse a reg name, returns number of chars consumed */ -int DEFUN(parse_reg,(src, mode, reg, dst), - char *src AND - op_enum_type *mode AND - unsigned int *reg AND - int dst) -{ - if (src[0] == 's' && src[1] == 'p') { - *mode = r16_sord[dst]; - *reg = 7; - return 2; - } - if (src[0] == 'c' && src[1] == 'c' && src[2] == 'r') { - *mode = CCR; - *reg = 0; - return 3; - } - if (src[0] == 'f' && src[1] == 'p') { - *mode = r16_sord[dst]; - *reg = 6; - return 2; - } - if (src[0] == 'r') { - if (src[1] >= '0' && src[1] <= '7') { - if(src[2] == 'l') { - *mode = r8_sord[dst]; - *reg = (src[1] - '0') + 8; - return 3; - } - if(src[2] == 'h') { - *mode = r8_sord[dst]; - *reg = (src[1] - '0') ; - return 3; - } - *mode = r16_sord[dst]; - *reg = (src[1] - '0'); - return 2; - } - } - return 0; -} - -char * -DEFUN(parse_exp,(s, op), - char *s AND - expressionS *op) -{ - char *save = input_line_pointer; - char *new; - segT seg; - input_line_pointer = s; - seg = expr(0,op); - new = input_line_pointer; - input_line_pointer = save; - if (SEG_NORMAL(seg)) - return new; - switch (seg) { - case SEG_ABSOLUTE: - case SEG_UNKNOWN: - case SEG_DIFFERENCE: - case SEG_BIG: - case SEG_REGISTER: - return new; - case SEG_ABSENT: - as_bad("Missing operand"); - return new; - default: - as_bad("Don't understand operand of type %s", segment_name (seg)); - return new; - } -} - - -static void -DEFUN(get_operand,(ptr, op, dst), - char **ptr AND - struct h8_op *op AND - unsigned int dst) -{ - char *src = *ptr; - op_enum_type mode; - unsigned int num; - unsigned int len; - op->mode = E; - - while (*src == ' ') src++; - len = parse_reg(src, &op->mode, &op->reg, dst); - if (len) { - *ptr = src + len; - return ; - } - - if (*src == '@') { - src++; - if (*src == '-') { - src++; - len = parse_reg(src, &mode, &num, dst); - if (len == 0 || mode != r16_sord[dst]) { - as_bad("@- needs word register"); - } - op->mode = RDDEC; - op->reg = num; - *ptr = src + len; - return; - } - if (*src == '(' && ')') { - /* Disp */ - src++; - src = parse_exp(src, &op->exp); - - if (*src == ')') { - src++; - op->mode = abs_sord[dst]; - *ptr = src; - return; - } - if (*src != ',') { - as_bad("expected @(exp, reg16)"); - } - src++; - len = parse_reg(src, &mode, &op->reg, dst); - if (len == 0 || mode != r16_sord[dst]) - { - as_bad("expected @(exp, reg16)"); - } - op->mode = disp_sord[dst]; - src += len; - if (*src != ')' && '(') { - as_bad("expected @(exp, reg16)"); - - } - *ptr = src +1; - - return; - } - len = parse_reg(src, &mode, &num, dst); - - if(len) { - src += len; - if (*src == '+') { - src++; - if (mode != RS16) { - as_bad("@Rn+ needs word register"); - } - op->mode = RSINC; - op->reg = num; - *ptr = src; - return; - } - if (mode != r16_sord[dst]) { - as_bad("@Rn needs word register"); - } - op->mode =rind_sord[dst]; - op->reg = num; - *ptr = src; - return; - } - else { - /* must be a symbol */ - op->mode = abs_sord[dst]; - *ptr = parse_exp(src, &op->exp); - return; - } - } - - - if (*src == '#') { - src++; - op->mode = IMM16; - *ptr = parse_exp(src, &op->exp); - return; - } - else { - *ptr = parse_exp(src, &op->exp); - op->mode = DISP8; - } -} - -/* This is the guts of the machine-dependent assembler. STR points to a - machine dependent instruction. This funciton is supposed to emit - the frags/bytes it assembles to. - */ - - -void -DEFUN(md_assemble,(str), - char *str) -{ - char *op_start; - char *op_end; - struct h8_opcode * opcode; - /* Drop leading whitespace */ - while (*str == ' ') - str++; - - - /* find the op code end */ - for (op_start = op_end = str; - *op_end != 0 && *op_end != ' '; - op_end ++) - ; - - if (op_end == op_start) { - as_bad("can't find opcode "); - } - *op_end = 0; - opcode = (struct h8_opcode *) hash_find(opcode_hash_control, - op_start); - - if (opcode == NULL) { - as_bad("unknown opcode"); - return; - } - - - { - int ok = 1; - int j,i; - int dispreg = 0; - struct h8_op operand[2]; - char *ptr = op_end+1; - if (opcode->noperands) - get_operand(& ptr, &operand[0],0); - else operand[0].mode = 0; - if (opcode->noperands==2) { - if (*ptr == ',') ptr++; - get_operand(& ptr, &operand[1], 1); - } - else operand[1].mode = 0; - - - - { - struct h8_opcode *this_try ; - int found = 0; - for (j = 0; j < opcode->nopcodes && !found; j++) { - this_try = opcode + j; - for (i = 0; i < opcode->noperands; i++) { - op_enum_type op = (this_try->args.nib[i]) & ~(B30|B31); - switch (op) { - case Hex0: - case Hex1: - case Hex2: - case Hex3: - case Hex4: - case Hex5: - case Hex6: - case Hex7: - case Hex8: - case Hex9: - case HexA: - case HexB: - case HexC: - case HexD: - case HexE: - case HexF: - break; - case DISPSRC: - case DISPDST: - dispreg = operand[i].reg; - case RD8: - case RS8: - case RDIND: - case RSIND: - case RD16: - case RS16: - case CCR: - case RSINC: - case RDDEC: - if (operand[i].mode != op) goto fail; - break; - case KBIT: - case IMM8: - case IMM16: - case IMM3: - if (operand[i].mode != IMM16) goto fail; - break; - case ABS16SRC: - case ABS8SRC: - if (operand[i].mode != ABS16SRC) goto fail; - break; - case ABS16DST: - case ABS8DST: - if (operand[i].mode != ABS16DST) goto fail; - - break; - } - } - found =1; - fail: ; - } - if (found == 0) - as_bad("illegal operands for opcode"); - - - /* Now we know what sort of opcodes etc, lets build the bytes - - actually we know how big the instruction will be too. So we - can get - */ - { - char *output = frag_more(this_try->length); - char *output_ptr = output; - op_enum_type *nibble_ptr = this_try->data.nib; - char part; - op_enum_type c; - char high; - int nib; - top: ; - while (*nibble_ptr != E) { - int nibble; - for (nibble = 0; nibble <2; nibble++) { - c = *nibble_ptr & ~(B30|B31); - switch (c) { - default: - abort(); - - case 0: - case 1: - case 2: case 3: case 4: case 5: case 6: - case 7: case 8: case 9: case 10: case 11: - case 12: case 13: case 14: case 15: - nib = c; - break; - case DISPREG: - nib = dispreg; - break; - case IMM8: - /* if no symbol then put value in place */ - if (operand[0].exp.X_add_symbol == 0) { - operand[0].mode = 0; /* stop it making a fix */ - *output_ptr++ = (operand[0].exp.X_add_number); - nibble_ptr += 2; - goto top; - } - nib = 0; - break; - - case DISPDST: - /* if no symbol then put value in place */ - if (operand[1].exp.X_add_symbol == 0) { - operand[1].mode = 0; /* stop it making a fix */ - *output_ptr++ =(operand[1].exp.X_add_number)>>8; - *output_ptr++ = (operand[1].exp.X_add_number); - nibble_ptr += 4; - goto top; - } - - nib = 0; - break; - case IMM3: - - if (operand[0].exp.X_add_symbol == 0) { - operand[0].mode = 0; /* stop it making a fix */ - nib = (operand[0].exp.X_add_number); - } - else as_bad("can't have symbol for bit number"); - break; - - case DISPSRC: - case IMM16: - /* if no symbol then put value in place */ - if (operand[0].exp.X_add_symbol == 0) { - operand[0].mode = 0; /* stop it making a fix */ - *output_ptr++ =(operand[0].exp.X_add_number)>>8; - *output_ptr++ = (operand[0].exp.X_add_number); - nibble_ptr += 4; - goto top; - } - - - case ABS16SRC: - case ABS16DST: - - case ABS8DST: - case ABS8SRC: - case IGNORE: - - - nib = 0; - break; - case DISP8: - nib = 0; - break; - - - case RS8: - case RS16: - case RSIND: - case RSINC: - case RDIND: - nib= operand[0].reg; - break; - case RD8: - case RD16: - case RDDEC: - nib = operand[1].reg; - - break; - case E: - abort(); - break; - } - if (*nibble_ptr & B31) nib|=0x8; - if (nibble == 0) { - *output_ptr = nib << 4; - } - else { - *output_ptr |= nib; - output_ptr++; - } - nibble_ptr++; - } - - } - - /* output any fixes */ - { - int i; - for (i = 0; i < 2; i++) { - switch (operand[i].mode) { - case 0: - break; - case DISP8: - fix_new(frag_now, - output+1, - 1, - operand[i].exp.X_add_symbol, - operand[i].exp.X_subtract_symbol, - operand[i].exp.X_add_number, - 0, - (int)r8pcrel); - break; - case ABS16SRC: - case ABS16DST: - case IMM16: - case DISPSRC: - case DISPDST: - fix_new(frag_now, - output+2, - 2, - operand[i].exp.X_add_symbol, - operand[i].exp.X_subtract_symbol, - operand[i].exp.X_add_number, - 0, - (int)r16); - break; - case RS8: - case RD8: - case RS16: - case RD16: - case RDDEC: - case RSINC: - case RDIND: - case RSIND: - break; - default: - abort(); - } - } - } - - } - } - } -} - -void -DEFUN(tc_crawl_symbol_chain, (headers), -object_headers *headers) -{ - printf("call to tc_crawl_symbol_chain \n"); -} - -symbolS *DEFUN(md_undefined_symbol,(name), - char *name) -{ -return 0; -} - -void -DEFUN(tc_headers_hook,(headers), - object_headers *headers) -{ - printf("call to tc_headers_hook \n"); -} -void -DEFUN_VOID(md_end) -{ -} - -/* Various routines to kill one day */ - -char *md_atof () { printf("call to md_atof \n"); abort(); } -int md_parse_option () { printf("call to md_parse_option \n"); abort(); } - -int md_short_jump_size; - -void tc_aout_fix_to_chars () { printf("call to tc_aout_fix_to_chars \n"); - abort(); } -void md_create_long_jump () { printf("call to md_create_long_jump \n"); - abort(); } -void md_convert_frag () { printf("call to md_convert_frag \n"); abort(); } - -long -DEFUN(md_section_align,(seg, size), - segT seg AND - long size) -{ - return((size + (1 << section_alignment[(int) seg]) - 1) & (-1 << section_alignment[(int) seg])); - -} - -void md_apply_fix () { printf("call to md_apply_fix \n"); abort(); } - -void DEFUN(md_operand, (expressionP),expressionS *expressionP) -{ } - -int md_long_jump_size; -int md_estimate_size_before_relax () { printf("call tomd_estimate_size_before_relax \n"); abort(); } -/* Put number into target byte order */ -void DEFUN(md_number_to_chars,(ptr, use, nbytes), - char *ptr AND - int use AND - unsigned int nbytes) -{ - switch (nbytes) { - case 4: *ptr++ = (use >> 24) & 0xff; - case 3: *ptr++ = (use >> 16) & 0xff; - case 2: *ptr++ = (use >> 8) & 0xff; - case 1: *ptr++ = (use >> 0) & 0xff; - break; - default: - abort(); - } -} - -long md_pcrel_from () { printf("call to md_pcrel_from \n"); abort(); } -void md_create_short_jump () { printf("call to md_create_short_jump \n"); - abort(); } - -void tc_coff_symbol_emit_hook() { } diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c deleted file mode 100644 index cff66a4a7e9..00000000000 --- a/gas/config/tc-i386.c +++ /dev/null @@ -1,1983 +0,0 @@ -/* i386.c -- Assemble code for the Intel 80386 - Copyright (C) 1989, 1991 Free Software Foundation. - -This file is part of GAS, the GNU Assembler. - -GAS 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 1, or (at your option) -any later version. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* $Id$ */ - -/* - Intel 80386 machine specific gas. - Written by Eliot Dresselhaus (eliot@mgm.mit.edu). - Bugs & suggestions are completely welcome. This is free software. - Please help us make it better. -*/ - -#include "as.h" - -#include "obstack.h" -#include "i386-opcode.h" - -/* 'md_assemble ()' gathers together information and puts it into a - i386_insn. */ - -typedef struct { - /* TM holds the template for the insn were currently assembling. */ - template tm; - /* SUFFIX holds the opcode suffix (e.g. 'l' for 'movl') if given. */ - char suffix; - /* Operands are coded with OPERANDS, TYPES, DISPS, IMMS, and REGS. */ - - /* OPERANDS gives the number of given operands. */ - unsigned int operands; - - /* REG_OPERANDS, DISP_OPERANDS, MEM_OPERANDS, IMM_OPERANDS give the number of - given register, displacement, memory operands and immediate operands. */ - unsigned int reg_operands, disp_operands, mem_operands, imm_operands; - - /* TYPES [i] is the type (see above #defines) which tells us how to - search through DISPS [i] & IMMS [i] & REGS [i] for the required - operand. */ - unsigned int types [MAX_OPERANDS]; - - /* Displacements (if given) for each operand. */ - expressionS * disps [MAX_OPERANDS]; - - /* Immediate operands (if given) for each operand. */ - expressionS * imms [MAX_OPERANDS]; - - /* Register operands (if given) for each operand. */ - reg_entry * regs [MAX_OPERANDS]; - - /* BASE_REG, INDEX_REG, and LOG2_SCALE_FACTOR are used to encode - the base index byte below. */ - reg_entry * base_reg; - reg_entry * index_reg; - unsigned int log2_scale_factor; - - /* SEG gives the seg_entry of this insn. It is equal to zero unless - an explicit segment override is given. */ - seg_entry * seg; /* segment for memory operands (if given) */ - - /* PREFIX holds all the given prefix opcodes (usually null). - PREFIXES is the size of PREFIX. */ - char prefix [MAX_PREFIXES]; - unsigned int prefixes; - - /* RM and IB are the modrm byte and the base index byte where the addressing - modes of this insn are encoded. */ - - modrm_byte rm; - base_index_byte bi; -} i386_insn; - -char FLT_CHARS[] = "fFdDxX"; -char EXP_CHARS[] = "eE"; -char line_comment_chars[] = "#"; -char comment_chars[] = "#/"; - -/* tables for lexical analysis */ -static char opcode_chars[256]; -static char register_chars[256]; -static char operand_chars[256]; -static char space_chars[256]; -static char identifier_chars[256]; -static char digit_chars[256]; - -/* lexical macros */ -#define is_opcode_char(x) (opcode_chars[(unsigned char) x]) -#define is_operand_char(x) (operand_chars[(unsigned char) x]) -#define is_register_char(x) (register_chars[(unsigned char) x]) -#define is_space_char(x) (space_chars[(unsigned char) x]) -#define is_identifier_char(x) (identifier_chars[(unsigned char) x]) -#define is_digit_char(x) (digit_chars[(unsigned char) x]) - -/* put here all non-digit non-letter charcters that may occur in an operand */ -static char operand_special_chars[] = "%$-+(,)*._~/<>|&^!:"; - -static char *ordinal_names[] = { "first", "second", "third" }; /* for printfs */ - -/* md_assemble() always leaves the strings it's passed unaltered. To - effect this we maintain a stack of saved characters that we've smashed - with '\0's (indicating end of strings for various sub-fields of the - assembler instruction). */ -static char save_stack[32]; -static char *save_stack_p; /* stack pointer */ -#define END_STRING_AND_SAVE(s) *save_stack_p++ = *s; *s = '\0' -#define RESTORE_END_STRING(s) *s = *--save_stack_p - -/* The instruction we're assembling. */ -static i386_insn i; - -/* Per instruction expressionS buffers: 2 displacements & 2 immediate max. */ -static expressionS disp_expressions[2], im_expressions[2]; - -/* pointers to ebp & esp entries in reg_hash hash table */ -static reg_entry *ebp, *esp; - -static int this_operand; /* current operand we are working on */ - -/* -Interface to relax_segment. -There are 2 relax states for 386 jump insns: one for conditional & one -for unconditional jumps. This is because the these two types of jumps -add different sizes to frags when we're figuring out what sort of jump -to choose to reach a given label. */ - -/* types */ -#define COND_JUMP 1 /* conditional jump */ -#define UNCOND_JUMP 2 /* unconditional jump */ -/* sizes */ -#define BYTE 0 -#define WORD 1 -#define DWORD 2 -#define UNKNOWN_SIZE 3 - -#define ENCODE_RELAX_STATE(type,size) ((type<<2) | (size)) -#define SIZE_FROM_RELAX_STATE(s) \ - ( (((s) & 0x3) == BYTE ? 1 : (((s) & 0x3) == WORD ? 2 : 4)) ) - -const relax_typeS md_relax_table[] = { -/* - The fields are: - 1) most positive reach of this state, - 2) most negative reach of this state, - 3) how many bytes this mode will add to the size of the current frag - 4) which index into the table to try if we can't fit into this one. -*/ - {1, 1, 0, 0}, - {1, 1, 0, 0}, - {1, 1, 0, 0}, - {1, 1, 0, 0}, - - /* For now we don't use word displacement jumps: they may be - untrustworthy. */ - {127+1, -128+1, 0, ENCODE_RELAX_STATE(COND_JUMP,DWORD) }, - /* word conditionals add 3 bytes to frag: - 2 opcode prefix; 1 displacement bytes */ - {32767+2, -32768+2, 3, ENCODE_RELAX_STATE(COND_JUMP,DWORD) }, - /* dword conditionals adds 4 bytes to frag: - 1 opcode prefix; 3 displacement bytes */ - {0, 0, 4, 0}, - {1, 1, 0, 0}, - - {127+1, -128+1, 0, ENCODE_RELAX_STATE(UNCOND_JUMP,DWORD) }, - /* word jmp adds 2 bytes to frag: - 1 opcode prefix; 1 displacement bytes */ - {32767+2, -32768+2, 2, ENCODE_RELAX_STATE(UNCOND_JUMP,DWORD) }, - /* dword jmp adds 3 bytes to frag: - 0 opcode prefix; 3 displacement bytes */ - {0, 0, 3, 0}, - {1, 1, 0, 0}, - -}; - -#ifdef __STDC__ - -static char *output_invalid(int c); -static int i386_operand(char *operand_string); -static reg_entry *parse_register(char *reg_string); - -#else /* __STDC__ */ - -static char *output_invalid(); -static int i386_operand(); -static reg_entry *parse_register(); - -#endif /* __STDC__ */ - - -/* Ignore certain directives generated by gcc. This probably should - not be here. */ -void dummy () -{ - while (*input_line_pointer && *input_line_pointer != '\n') - input_line_pointer++; -} - -const pseudo_typeS md_pseudo_table[] = { - { "ffloat", float_cons, 'f' }, - { "dfloat", float_cons, 'd' }, - { "tfloat", float_cons, 'x' }, - { "value", cons, 2 }, - { "ident", dummy, 0 }, /* ignore these directives */ -#if defined(OBJ_AOUT) | defined(OBJ_BOUT) - { "def", dummy, 0 }, -#endif /* OBJ_AOUT or OBJ_BOUT */ - { "def", dummy, 0 }, - { "optim", dummy, 0 }, /* For sun386i cc */ - { "version", dummy, 0 }, -#if defined(OBJ_AOUT) | defined(OBJ_BOUT) - { "ln", dummy, 0 }, -#endif /* OBJ_AOUT or OBJ_BOUT */ - { "ln", dummy, 0 }, - { 0, 0, 0 } -}; - -/* for interface with expression () */ -extern char * input_line_pointer; - -/* obstack for constructing various things in md_begin */ -struct obstack o; - -/* hash table for opcode lookup */ -static struct hash_control *op_hash = (struct hash_control *) 0; -/* hash table for register lookup */ -static struct hash_control *reg_hash = (struct hash_control *) 0; -/* hash table for prefix lookup */ -static struct hash_control *prefix_hash = (struct hash_control *) 0; - - -void md_begin () -{ - char * hash_err; - - obstack_begin (&o,4096); - - /* initialize op_hash hash table */ - op_hash = hash_new(); /* xmalloc handles error */ - - { - register const template *optab; - register templates *core_optab; - char *prev_name; - - optab = i386_optab; /* setup for loop */ - prev_name = optab->name; - obstack_grow (&o, optab, sizeof(template)); - core_optab = (templates *) xmalloc (sizeof (templates)); - - for (optab++; optab < i386_optab_end; optab++) { - if (! strcmp (optab->name, prev_name)) { - /* same name as before --> append to current template list */ - obstack_grow (&o, optab, sizeof(template)); - } else { - /* different name --> ship out current template list; - add to hash table; & begin anew */ - /* Note: end must be set before start! since obstack_next_free changes - upon opstack_finish */ - core_optab->end = (template *) obstack_next_free(&o); - core_optab->start = (template *) obstack_finish(&o); - hash_err = hash_insert (op_hash, prev_name, (char *) core_optab); - if (hash_err && *hash_err) { - hash_error: - as_fatal("Internal Error: Can't hash %s: %s", prev_name, hash_err); - } - prev_name = optab->name; - core_optab = (templates *) xmalloc (sizeof(templates)); - obstack_grow (&o, optab, sizeof(template)); - } - } - } - - /* initialize reg_hash hash table */ - reg_hash = hash_new(); - { - register const reg_entry *regtab; - - for (regtab = i386_regtab; regtab < i386_regtab_end; regtab++) { - hash_err = hash_insert (reg_hash, regtab->reg_name, regtab); - if (hash_err && *hash_err) goto hash_error; - } - } - - esp = (reg_entry *) hash_find (reg_hash, "esp"); - ebp = (reg_entry *) hash_find (reg_hash, "ebp"); - - /* initialize reg_hash hash table */ - prefix_hash = hash_new(); - { - register const prefix_entry *prefixtab; - - for (prefixtab = i386_prefixtab; - prefixtab < i386_prefixtab_end; prefixtab++) { - hash_err = hash_insert (prefix_hash, prefixtab->prefix_name, prefixtab); - if (hash_err && *hash_err) goto hash_error; - } - } - - /* fill in lexical tables: opcode_chars, operand_chars, space_chars */ - { - register unsigned int c; - - bzero (opcode_chars, sizeof(opcode_chars)); - bzero (operand_chars, sizeof(operand_chars)); - bzero (space_chars, sizeof(space_chars)); - bzero (identifier_chars, sizeof(identifier_chars)); - bzero (digit_chars, sizeof(digit_chars)); - - for (c = 0; c < 256; c++) { - if (islower(c) || isdigit(c)) { - opcode_chars[c] = c; - register_chars[c] = c; - } else if (isupper(c)) { - opcode_chars[c] = tolower(c); - register_chars[c] = opcode_chars[c]; - } else if (c == PREFIX_SEPERATOR) { - opcode_chars[c] = c; - } else if (c == ')' || c == '(') { - register_chars[c] = c; - } - - if (isupper(c) || islower(c) || isdigit(c)) - operand_chars[c] = c; - else if (c && strchr(operand_special_chars, c)) - operand_chars[c] = c; - - if (isdigit(c) || c == '-') digit_chars[c] = c; - - if (isalpha(c) || c == '_' || c == '.' || isdigit(c)) - identifier_chars[c] = c; - - if (c == ' ' || c == '\t') space_chars[c] = c; - } - } -} - -void md_end() {} /* not much to do here. */ - - -#ifdef DEBUG386 - -/* debugging routines for md_assemble */ -/* static void pi (), pte (), pt (), pe (), ps (); */ - -static void pi (line, x) - char * line; - i386_insn *x; -{ - register template *p; - int i; - - fprintf (stdout, "%s: template ", line); - pte (&x->tm); - fprintf (stdout, " modrm: mode %x reg %x reg/mem %x", - x->rm.mode, x->rm.reg, x->rm.regmem); - fprintf (stdout, " base %x index %x scale %x\n", - x->bi.base, x->bi.index, x->bi.scale); - for (i = 0; i < x->operands; i++) { - fprintf (stdout, " #%d: ", i+1); - pt (x->types[i]); - fprintf (stdout, "\n"); - if (x->types[i] & Reg) fprintf (stdout, "%s\n", x->regs[i]->reg_name); - if (x->types[i] & Imm) pe (x->imms[i]); - if (x->types[i] & (Disp|Abs)) pe (x->disps[i]); - } -} - -static void pte (t) - template *t; -{ - int i; - fprintf (stdout, " %d operands ", t->operands); - fprintf (stdout, "opcode %x ", - t->base_opcode); - if (t->extension_opcode != None) - fprintf (stdout, "ext %x ", t->extension_opcode); - if (t->opcode_modifier&D) - fprintf (stdout, "D"); - if (t->opcode_modifier&W) - fprintf (stdout, "W"); - fprintf (stdout, "\n"); - for (i = 0; i < t->operands; i++) { - fprintf (stdout, " #%d type ", i+1); - pt (t->operand_types[i]); - fprintf (stdout, "\n"); - } -} - -static void pe (e) - expressionS *e; -{ - fprintf (stdout, " segment %s\n", segment_name (e->X_seg)); - fprintf (stdout, " add_number %d (%x)\n", - e->X_add_number, e->X_add_number); - if (e->X_add_symbol) { - fprintf (stdout, " add_symbol "); - ps (e->X_add_symbol); - fprintf (stdout, "\n"); - } - if (e->X_subtract_symbol) { - fprintf (stdout, " sub_symbol "); - ps (e->X_subtract_symbol); - fprintf (stdout, "\n"); - } -} - -static void ps (s) - symbolS *s; -{ - fprintf (stdout, "%s type %s%s", - S_GET_NAME(s), - S_IS_EXTERNAL(s) ? "EXTERNAL " : "", - segment_name(S_GET_SEGMENT(s))); -} - -struct type_name { - unsigned int mask; - char *tname; -} type_names[] = { - { Reg8, "r8" }, { Reg16, "r16" }, { Reg32, "r32" }, { Imm8, "i8" }, - { Imm8S, "i8s" }, - { Imm16, "i16" }, { Imm32, "i32" }, { Mem8, "Mem8"}, { Mem16, "Mem16"}, - { Mem32, "Mem32"}, { BaseIndex, "BaseIndex" }, - { Abs8, "Abs8" }, { Abs16, "Abs16" }, { Abs32, "Abs32" }, - { Disp8, "d8" }, { Disp16, "d16" }, - { Disp32, "d32" }, { SReg2, "SReg2" }, { SReg3, "SReg3" }, { Acc, "Acc" }, - { InOutPortReg, "InOutPortReg" }, { ShiftCount, "ShiftCount" }, - { Imm1, "i1" }, { Control, "control reg" }, {Test, "test reg"}, - { FloatReg, "FReg"}, {FloatAcc, "FAcc"}, - { JumpAbsolute, "Jump Absolute"}, - { 0, "" } -}; - -static void pt (t) - unsigned int t; -{ - register struct type_name *ty; - - if (t == Unknown) { - fprintf (stdout, "Unknown"); - } else { - for (ty = type_names; ty->mask; ty++) - if (t & ty->mask) fprintf (stdout, "%s, ", ty->tname); - } - fflush (stdout); -} - -#endif /* DEBUG386 */ - -/* - This is the guts of the machine-dependent assembler. LINE points to a - machine dependent instruction. This funciton is supposed to emit - the frags/bytes it assembles to. - */ -void md_assemble (line) - char *line; -{ - /* Holds temlate once we've found it. */ - register template * t; - - /* Possible templates for current insn */ - templates *current_templates = (templates *) 0; - - /* Initialize globals. */ - bzero (&i, sizeof(i)); - bzero (disp_expressions, sizeof(disp_expressions)); - bzero (im_expressions, sizeof(im_expressions)); - save_stack_p = save_stack; /* reset stack pointer */ - - /* Fist parse an opcode & call i386_operand for the operands. - We assume that the scrubber has arranged it so that line[0] is the valid - start of a (possibly prefixed) opcode. */ - { - register char *l = line; /* Fast place to put LINE. */ - - /* 1 if operand is pending after ','. */ - unsigned int expecting_operand = 0; - /* 1 if we found a prefix only acceptable with string insns. */ - unsigned int expecting_string_instruction = 0; - /* Non-zero if operand parens not balenced. */ - unsigned int paren_not_balenced; - char * token_start = l; - - while (! is_space_char(*l) && *l != END_OF_INSN) { - if (! is_opcode_char(*l)) { - as_bad("invalid character %s in opcode", output_invalid(*l)); - return; - } else if (*l != PREFIX_SEPERATOR) { - *l = opcode_chars[(unsigned char) *l]; /* fold case of opcodes */ - l++; - } else { /* this opcode's got a prefix */ - register unsigned int q; - register prefix_entry * prefix; - - if (l == token_start) { - as_bad("expecting prefix; got nothing"); - return; - } - END_STRING_AND_SAVE (l); - prefix = (prefix_entry *) hash_find (prefix_hash, token_start); - if (! prefix) { - as_bad("no such opcode prefix ('%s')", token_start); - return; - } - RESTORE_END_STRING (l); - /* check for repeated prefix */ - for (q = 0; q < i.prefixes; q++) - if (i.prefix[q] == prefix->prefix_code) { - as_bad("same prefix used twice; you don't really want this!"); - return; - } - if (i.prefixes == MAX_PREFIXES) { - as_bad("too many opcode prefixes"); - return; - } - i.prefix[i.prefixes++] = prefix->prefix_code; - if (prefix->prefix_code == REPE || prefix->prefix_code == REPNE) - expecting_string_instruction = 1; - /* skip past PREFIX_SEPERATOR and reset token_start */ - token_start = ++l; - } - } - END_STRING_AND_SAVE (l); - if (token_start == l) { - as_bad("expecting opcode; got nothing"); - return; - } - - /* Lookup insn in hash; try intel & att naming conventions if appropriate; - that is: we only use the opcode suffix 'b' 'w' or 'l' if we need to. */ - current_templates = (templates *) hash_find (op_hash, token_start); - if (! current_templates) { - int last_index = strlen(token_start) - 1; - char last_char = token_start[last_index]; - switch (last_char) { - case DWORD_OPCODE_SUFFIX: - case WORD_OPCODE_SUFFIX: - case BYTE_OPCODE_SUFFIX: - token_start[last_index] = '\0'; - current_templates = (templates *) hash_find (op_hash, token_start); - token_start[last_index] = last_char; - i.suffix = last_char; - } - if (!current_templates) { - as_bad("no such 386 instruction: `%s'", token_start); return; - } - } - RESTORE_END_STRING (l); - - /* check for rep/repne without a string instruction */ - if (expecting_string_instruction && - ! IS_STRING_INSTRUCTION (current_templates-> - start->base_opcode)) { - as_bad("expecting string instruction after rep/repne"); - return; - } - - /* There may be operands to parse. */ - if (*l != END_OF_INSN && - /* For string instructions, we ignore any operands if given. This - kludges, for example, 'rep/movsb %ds:(%esi), %es:(%edi)' where - the operands are always going to be the same, and are not really - encoded in machine code. */ - ! IS_STRING_INSTRUCTION (current_templates-> - start->base_opcode)) { - /* parse operands */ - do { - /* skip optional white space before operand */ - while (! is_operand_char(*l) && *l != END_OF_INSN) { - if (! is_space_char(*l)) { - as_bad("invalid character %s before %s operand", - output_invalid(*l), - ordinal_names[i.operands]); - return; - } - l++; - } - token_start = l; /* after white space */ - paren_not_balenced = 0; - while (paren_not_balenced || *l != ',') { - if (*l == END_OF_INSN) { - if (paren_not_balenced) { - as_bad("unbalenced parenthesis in %s operand.", - ordinal_names[i.operands]); - return; - } else break; /* we are done */ - } else if (! is_operand_char(*l)) { - as_bad("invalid character %s in %s operand", - output_invalid(*l), - ordinal_names[i.operands]); - return; - } - if (*l == '(') ++paren_not_balenced; - if (*l == ')') --paren_not_balenced; - l++; - } - if (l != token_start) { /* yes, we've read in another operand */ - unsigned int operand_ok; - this_operand = i.operands++; - if (i.operands > MAX_OPERANDS) { - as_bad("spurious operands; (%d operands/instruction max)", - MAX_OPERANDS); - return; - } - /* now parse operand adding info to 'i' as we go along */ - END_STRING_AND_SAVE (l); - operand_ok = i386_operand (token_start); - RESTORE_END_STRING (l); /* restore old contents */ - if (!operand_ok) return; - } else { - if (expecting_operand) { - expecting_operand_after_comma: - as_bad("expecting operand after ','; got nothing"); - return; - } - if (*l == ',') { - as_bad("expecting operand before ','; got nothing"); - return; - } - } - - /* now *l must be either ',' or END_OF_INSN */ - if (*l == ',') { - if (*++l == END_OF_INSN) { /* just skip it, if it's \n complain */ - goto expecting_operand_after_comma; - } - expecting_operand = 1; - } - } while (*l != END_OF_INSN); /* until we get end of insn */ - } - } - - /* Now we've parsed the opcode into a set of templates, and have the - operands at hand. - Next, we find a template that matches the given insn, - making sure the overlap of the given operands types is consistent - with the template operand types. */ - -#define MATCH(overlap,given_type) \ - (overlap && \ - (overlap & (JumpAbsolute|BaseIndex|Mem8)) \ - == (given_type & (JumpAbsolute|BaseIndex|Mem8))) - - /* If m0 and m1 are register matches they must be consistent - with the expected operand types t0 and t1. - That is, if both m0 & m1 are register matches - i.e. ( ((m0 & (Reg)) && (m1 & (Reg)) ) ? - then, either 1. or 2. must be true: - 1. the expected operand type register overlap is null: - (t0 & t1 & Reg) == 0 - AND - the given register overlap is null: - (m0 & m1 & Reg) == 0 - 2. the expected operand type register overlap == the given - operand type overlap: (t0 & t1 & m0 & m1 & Reg). - */ -#define CONSISTENT_REGISTER_MATCH(m0, m1, t0, t1) \ - ( ((m0 & (Reg)) && (m1 & (Reg))) ? \ - ( ((t0 & t1 & (Reg)) == 0 && (m0 & m1 & (Reg)) == 0) || \ - ((t0 & t1) & (m0 & m1) & (Reg)) \ - ) : 1) - { - register unsigned int overlap0, overlap1; - expressionS * exp; - unsigned int overlap2; - unsigned int found_reverse_match; - - overlap0 = overlap1 = overlap2 = found_reverse_match = 0; - for (t = current_templates->start; - t < current_templates->end; - t++) { - - /* must have right number of operands */ - if (i.operands != t->operands) continue; - else if (!t->operands) break; /* 0 operands always matches */ - - overlap0 = i.types[0] & t->operand_types[0]; - switch (t->operands) { - case 1: - if (! MATCH (overlap0,i.types[0])) continue; - break; - case 2: case 3: - overlap1 = i.types[1] & t->operand_types[1]; - if (! MATCH (overlap0,i.types[0]) || - ! MATCH (overlap1,i.types[1]) || - ! CONSISTENT_REGISTER_MATCH(overlap0, overlap1, - t->operand_types[0], - t->operand_types[1])) { - - /* check if other direction is valid ... */ - if (! (t->opcode_modifier & COMES_IN_BOTH_DIRECTIONS)) - continue; - - /* try reversing direction of operands */ - overlap0 = i.types[0] & t->operand_types[1]; - overlap1 = i.types[1] & t->operand_types[0]; - if (! MATCH (overlap0,i.types[0]) || - ! MATCH (overlap1,i.types[1]) || - ! CONSISTENT_REGISTER_MATCH (overlap0, overlap1, - t->operand_types[0], - t->operand_types[1])) { - /* does not match either direction */ - continue; - } - /* found a reverse match here -- slip through */ - /* found_reverse_match holds which of D or FloatD we've found */ - found_reverse_match = t->opcode_modifier & COMES_IN_BOTH_DIRECTIONS; - } /* endif: not forward match */ - /* found either forward/reverse 2 operand match here */ - if (t->operands == 3) { - overlap2 = i.types[2] & t->operand_types[2]; - if (! MATCH (overlap2,i.types[2]) || - ! CONSISTENT_REGISTER_MATCH (overlap0, overlap2, - t->operand_types[0], - t->operand_types[2]) || - ! CONSISTENT_REGISTER_MATCH (overlap1, overlap2, - t->operand_types[1], - t->operand_types[2])) - continue; - } - /* found either forward/reverse 2 or 3 operand match here: - slip through to break */ - } - break; /* we've found a match; break out of loop */ - } /* for (t = ... */ - if (t == current_templates->end) { /* we found no match */ - as_bad("operands given don't match any known 386 instruction"); - return; - } - - /* Copy the template we found (we may change it!). */ - bcopy (t, &i.tm, sizeof (template)); - t = &i.tm; /* alter new copy of template */ - - /* If there's no opcode suffix we try to invent one based on register - operands. */ - if (! i.suffix && i.reg_operands) { - /* We take i.suffix from the LAST register operand specified. This - assumes that the last register operands is the destination register - operand. */ - int o; - for (o = 0; o < MAX_OPERANDS; o++) - if (i.types[o] & Reg) { - i.suffix = (i.types[o] == Reg8) ? BYTE_OPCODE_SUFFIX : - (i.types[o] == Reg16) ? WORD_OPCODE_SUFFIX : - DWORD_OPCODE_SUFFIX; - } - } - - /* Make still unresolved immediate matches conform to size of immediate - given in i.suffix. Note: overlap2 cannot be an immediate! - We assume this. */ - if ((overlap0 & (Imm8|Imm8S|Imm16|Imm32)) - && overlap0 != Imm8 && overlap0 != Imm8S - && overlap0 != Imm16 && overlap0 != Imm32) { - if (! i.suffix) { - as_bad("no opcode suffix given; can't determine immediate size"); - return; - } - overlap0 &= (i.suffix == BYTE_OPCODE_SUFFIX ? (Imm8|Imm8S) : - (i.suffix == WORD_OPCODE_SUFFIX ? Imm16 : Imm32)); - } - if ((overlap1 & (Imm8|Imm8S|Imm16|Imm32)) - && overlap1 != Imm8 && overlap1 != Imm8S - && overlap1 != Imm16 && overlap1 != Imm32) { - if (! i.suffix) { - as_bad("no opcode suffix given; can't determine immediate size"); - return; - } - overlap1 &= (i.suffix == BYTE_OPCODE_SUFFIX ? (Imm8|Imm8S) : - (i.suffix == WORD_OPCODE_SUFFIX ? Imm16 : Imm32)); - } - - i.types[0] = overlap0; - i.types[1] = overlap1; - i.types[2] = overlap2; - - if (overlap0 & ImplicitRegister) i.reg_operands--; - if (overlap1 & ImplicitRegister) i.reg_operands--; - if (overlap2 & ImplicitRegister) i.reg_operands--; - if (overlap0 & Imm1) i.imm_operands = 0; /* kludge for shift insns */ - - if (found_reverse_match) { - unsigned int save; - save = t->operand_types[0]; - t->operand_types[0] = t->operand_types[1]; - t->operand_types[1] = save; - } - - /* Finalize opcode. First, we change the opcode based on the operand - size given by i.suffix: we never have to change things for byte insns, - or when no opcode suffix is need to size the operands. */ - - if (! i.suffix && (t->opcode_modifier & W)) { - as_bad("no opcode suffix given and no register operands; can't size instruction"); - return; - } - - if (i.suffix && i.suffix != BYTE_OPCODE_SUFFIX) { - /* Select between byte and word/dword operations. */ - if (t->opcode_modifier & W) - t->base_opcode |= W; - /* Now select between word & dword operations via the - operand size prefix. */ - if (i.suffix == WORD_OPCODE_SUFFIX) { - if (i.prefixes == MAX_PREFIXES) { - as_bad("%d prefixes given and 'w' opcode suffix gives too many prefixes", - MAX_PREFIXES); - return; - } - i.prefix[i.prefixes++] = WORD_PREFIX_OPCODE; - } - } - - /* For insns with operands there are more diddles to do to the opcode. */ - if (i.operands) { - /* If we found a reverse match we must alter the opcode direction bit - found_reverse_match holds bit to set (different for int & - float insns). */ - - if (found_reverse_match) { - t->base_opcode |= found_reverse_match; - } - - /* - The imul $imm, %reg instruction is converted into - imul $imm, %reg, %reg. */ - if (t->opcode_modifier & imulKludge) { - i.regs[2] = i.regs[1]; /* Pretend we saw the 3 operand case. */ - i.reg_operands = 2; - } - - /* Certain instructions expect the destination to be in the i.rm.reg - field. This is by far the exceptional case. For these instructions, - if the source operand is a register, we must reverse the i.rm.reg - and i.rm.regmem fields. We accomplish this by faking that the - two register operands were given in the reverse order. */ - if ((t->opcode_modifier & ReverseRegRegmem) && i.reg_operands == 2) { - unsigned int first_reg_operand = (i.types[0] & Reg) ? 0 : 1; - unsigned int second_reg_operand = first_reg_operand + 1; - reg_entry *tmp = i.regs[first_reg_operand]; - i.regs[first_reg_operand] = i.regs[second_reg_operand]; - i.regs[second_reg_operand] = tmp; - } - - if (t->opcode_modifier & ShortForm) { - /* The register or float register operand is in operand 0 or 1. */ - unsigned int o = (i.types[0] & (Reg|FloatReg)) ? 0 : 1; - /* Register goes in low 3 bits of opcode. */ - t->base_opcode |= i.regs[o]->reg_num; - } else if (t->opcode_modifier & ShortFormW) { - /* Short form with 0x8 width bit. Register is always dest. operand */ - t->base_opcode |= i.regs[1]->reg_num; - if (i.suffix == WORD_OPCODE_SUFFIX || - i.suffix == DWORD_OPCODE_SUFFIX) - t->base_opcode |= 0x8; - } else if (t->opcode_modifier & Seg2ShortForm) { - if (t->base_opcode == POP_SEG_SHORT && i.regs[0]->reg_num == 1) { - as_bad("you can't 'pop cs' on the 386."); - return; - } - t->base_opcode |= (i.regs[0]->reg_num << 3); - } else if (t->opcode_modifier & Seg3ShortForm) { - /* 'push %fs' is 0x0fa0; 'pop %fs' is 0x0fa1. - 'push %gs' is 0x0fa8; 'pop %fs' is 0x0fa9. - So, only if i.regs[0]->reg_num == 5 (%gs) do we need - to change the opcode. */ - if (i.regs[0]->reg_num == 5) - t->base_opcode |= 0x08; - } else if (t->opcode_modifier & Modrm) { - /* The opcode is completed (modulo t->extension_opcode which must - be put into the modrm byte. - Now, we make the modrm & index base bytes based on all the info - we've collected. */ - - /* i.reg_operands MUST be the number of real register operands; - implicit registers do not count. */ - if (i.reg_operands == 2) { - unsigned int source, dest; - source = (i.types[0] & (Reg|SReg2|SReg3|Control|Debug|Test)) ? 0 : 1; - dest = source + 1; - i.rm.mode = 3; - /* We must be careful to make sure that all segment/control/test/ - debug registers go into the i.rm.reg field (despite the whether - they are source or destination operands). */ - if (i.regs[dest]->reg_type & (SReg2|SReg3|Control|Debug|Test)) { - i.rm.reg = i.regs[dest]->reg_num; - i.rm.regmem = i.regs[source]->reg_num; - } else { - i.rm.reg = i.regs[source]->reg_num; - i.rm.regmem = i.regs[dest]->reg_num; - } - } else { /* if it's not 2 reg operands... */ - if (i.mem_operands) { - unsigned int fake_zero_displacement = 0; - unsigned int o = (i.types[0] & Mem) ? 0 : ((i.types[1] & Mem) ? 1 : 2); - - /* Encode memory operand into modrm byte and base index byte. */ - - if (i.base_reg == esp && ! i.index_reg) { - /* (%esp) becomes two byte modrm with no index register. */ - i.rm.regmem = ESCAPE_TO_TWO_BYTE_ADDRESSING; - i.rm.mode = MODE_FROM_DISP_SIZE (i.types[o]); - i.bi.base = ESP_REG_NUM; - i.bi.index = NO_INDEX_REGISTER; - i.bi.scale = 0; /* Must be zero! */ - } else if (i.base_reg == ebp && !i.index_reg) { - if (! (i.types[o] & Disp)) { - /* Must fake a zero byte displacement. - There is no direct way to code '(%ebp)' directly. */ - fake_zero_displacement = 1; - /* fake_zero_displacement code does not set this. */ - i.types[o] |= Disp8; - } - i.rm.mode = MODE_FROM_DISP_SIZE (i.types[o]); - i.rm.regmem = EBP_REG_NUM; - } else if (! i.base_reg && (i.types[o] & BaseIndex)) { - /* There are three cases here. - Case 1: '<32bit disp>(,1)' -- indirect absolute. - (Same as cases 2 & 3 with NO index register) - Case 2: <32bit disp> (,) -- no base register with disp - Case 3: (, ) --- no base register; - no disp (must add 32bit 0 disp). */ - i.rm.regmem = ESCAPE_TO_TWO_BYTE_ADDRESSING; - i.rm.mode = 0; /* 32bit mode */ - i.bi.base = NO_BASE_REGISTER; - i.types[o] &= ~Disp; - i.types[o] |= Disp32; /* Must be 32bit! */ - if (i.index_reg) { /* case 2 or case 3 */ - i.bi.index = i.index_reg->reg_num; - i.bi.scale = i.log2_scale_factor; - if (i.disp_operands == 0) - fake_zero_displacement = 1; /* case 3 */ - } else { - i.bi.index = NO_INDEX_REGISTER; - i.bi.scale = 0; - } - } else if (i.disp_operands && !i.base_reg && !i.index_reg) { - /* Operand is just <32bit disp> */ - i.rm.regmem = EBP_REG_NUM; - i.rm.mode = 0; - i.types[o] &= ~Disp; - i.types[o] |= Disp32; - } else { - /* It's not a special case; rev'em up. */ - i.rm.regmem = i.base_reg->reg_num; - i.rm.mode = MODE_FROM_DISP_SIZE (i.types[o]); - if (i.index_reg) { - i.rm.regmem = ESCAPE_TO_TWO_BYTE_ADDRESSING; - i.bi.base = i.base_reg->reg_num; - i.bi.index = i.index_reg->reg_num; - i.bi.scale = i.log2_scale_factor; - if (i.base_reg == ebp && i.disp_operands == 0) { /* pace */ - fake_zero_displacement = 1; - i.types[o] |= Disp8; - i.rm.mode = MODE_FROM_DISP_SIZE (i.types[o]); - } - } - } - if (fake_zero_displacement) { - /* Fakes a zero displacement assuming that i.types[o] holds - the correct displacement size. */ - exp = &disp_expressions[i.disp_operands++]; - i.disps[o] = exp; - exp->X_seg = SEG_ABSOLUTE; - exp->X_add_number = 0; - exp->X_add_symbol = (symbolS *) 0; - exp->X_subtract_symbol = (symbolS *) 0; - } - - /* Select the correct segment for the memory operand. */ - if (i.seg) { - const unsigned int seg_index; - const seg_entry * default_seg; - - if (i.rm.regmem == ESCAPE_TO_TWO_BYTE_ADDRESSING) { - seg_index = (i.rm.mode<<3) | i.bi.base; - default_seg = two_byte_segment_defaults [seg_index]; - } else { - seg_index = (i.rm.mode<<3) | i.rm.regmem; - default_seg = one_byte_segment_defaults [seg_index]; - } - /* If the specified segment is not the default, use an - opcode prefix to select it */ - if (i.seg != default_seg) { - if (i.prefixes == MAX_PREFIXES) { - as_bad("%d prefixes given and %s segment override gives too many prefixes", - MAX_PREFIXES, i.seg->seg_name); - return; - } - i.prefix[i.prefixes++] = i.seg->seg_prefix; - } - } - } - - /* Fill in i.rm.reg or i.rm.regmem field with register operand - (if any) based on t->extension_opcode. Again, we must be careful - to make sure that segment/control/debug/test registers are coded - into the i.rm.reg field. */ - if (i.reg_operands) { - unsigned int o = - (i.types[0] & (Reg|SReg2|SReg3|Control|Debug|Test)) ? 0 : - (i.types[1] & (Reg|SReg2|SReg3|Control|Debug|Test)) ? 1 : 2; - /* If there is an extension opcode to put here, the register number - must be put into the regmem field. */ - if (t->extension_opcode != None) - i.rm.regmem = i.regs[o]->reg_num; - else i.rm.reg = i.regs[o]->reg_num; - - /* Now, if no memory operand has set i.rm.mode = 0, 1, 2 - we must set it to 3 to indicate this is a register operand - int the regmem field */ - if (! i.mem_operands) i.rm.mode = 3; - } - - /* Fill in i.rm.reg field with extension opcode (if any). */ - if (t->extension_opcode != None) - i.rm.reg = t->extension_opcode; - } - } - } - } - - /* Handle conversion of 'int $3' --> special int3 insn. */ - if (t->base_opcode == INT_OPCODE && i.imms[0]->X_add_number == 3) { - t->base_opcode = INT3_OPCODE; - i.imm_operands = 0; - } - - /* We are ready to output the insn. */ - { - register char * p; - - /* Output jumps. */ - if (t->opcode_modifier & Jump) { - int n = i.disps[0]->X_add_number; - - switch (i.disps[0]->X_seg) { - case SEG_ABSOLUTE: - if (FITS_IN_SIGNED_BYTE (n)) { - p = frag_more (2); - p[0] = t->base_opcode; - p[1] = n; -#if 0 /* leave out 16 bit jumps - pace */ - } else if (FITS_IN_SIGNED_WORD (n)) { - p = frag_more (4); - p[0] = WORD_PREFIX_OPCODE; - p[1] = t->base_opcode; - md_number_to_chars (&p[2], n, 2); -#endif - } else { /* It's an absolute dword displacement. */ - if (t->base_opcode == JUMP_PC_RELATIVE) { /* pace */ - /* unconditional jump */ - p = frag_more (5); - p[0] = 0xe9; - md_number_to_chars (&p[1], n, 4); - } else { - /* conditional jump */ - p = frag_more (6); - p[0] = TWO_BYTE_OPCODE_ESCAPE; - p[1] = t->base_opcode + 0x10; - md_number_to_chars (&p[2], n, 4); - } - } - break; - default: - /* It's a symbol; end frag & setup for relax. - Make sure there are 6 chars left in the current frag; if not - we'll have to start a new one. */ - /* I caught it failing with obstack_room == 6, - so I changed to <= pace */ - if (obstack_room (&frags) <= 6) { - frag_wane(frag_now); - frag_new (0); - } - p = frag_more (1); - p[0] = t->base_opcode; - frag_var (rs_machine_dependent, - 6, /* 2 opcode/prefix + 4 displacement */ - 1, - ((unsigned char) *p == JUMP_PC_RELATIVE - ? ENCODE_RELAX_STATE (UNCOND_JUMP, BYTE) - : ENCODE_RELAX_STATE (COND_JUMP, BYTE)), - i.disps[0]->X_add_symbol, - n, p); - break; - } - } else if (t->opcode_modifier & (JumpByte|JumpDword)) { - int size = (t->opcode_modifier & JumpByte) ? 1 : 4; - int n = i.disps[0]->X_add_number; - - if (FITS_IN_UNSIGNED_BYTE(t->base_opcode)) { - FRAG_APPEND_1_CHAR (t->base_opcode); - } else { - p = frag_more (2); /* opcode can be at most two bytes */ - /* put out high byte first: can't use md_number_to_chars! */ - *p++ = (t->base_opcode >> 8) & 0xff; - *p = t->base_opcode & 0xff; - } - - p = frag_more (size); - switch (i.disps[0]->X_seg) { - case SEG_ABSOLUTE: - md_number_to_chars (p, n, size); - if (size == 1 && ! FITS_IN_SIGNED_BYTE (n)) { - as_bad("loop/jecx only takes byte displacement; %d shortened to %d", - n, *p); - } - break; - default: - fix_new (frag_now, p - frag_now->fr_literal, size, - i.disps[0]->X_add_symbol, i.disps[0]->X_subtract_symbol, - i.disps[0]->X_add_number, 1, NO_RELOC); - break; - } - } else if (t->opcode_modifier & JumpInterSegment) { - p = frag_more (1 + 2 + 4); /* 1 opcode; 2 segment; 4 offset */ - p[0] = t->base_opcode; - if (i.imms[1]->X_seg == SEG_ABSOLUTE) - md_number_to_chars (p + 1, i.imms[1]->X_add_number, 4); - else - fix_new (frag_now, p + 1 - frag_now->fr_literal, 4, - i.imms[1]->X_add_symbol, - i.imms[1]->X_subtract_symbol, - i.imms[1]->X_add_number, 0, NO_RELOC); - if (i.imms[0]->X_seg != SEG_ABSOLUTE) - as_bad("can't handle non absolute segment in long call/jmp"); - md_number_to_chars (p + 5, i.imms[0]->X_add_number, 2); - } else { - /* Output normal instructions here. */ - register char *q; - - /* First the prefix bytes. */ - for (q = i.prefix; q < i.prefix + i.prefixes; q++) { - p = frag_more (1); - md_number_to_chars (p, (unsigned int) *q, 1); - } - - /* Now the opcode; be careful about word order here! */ - if (FITS_IN_UNSIGNED_BYTE(t->base_opcode)) { - FRAG_APPEND_1_CHAR (t->base_opcode); - } else if (FITS_IN_UNSIGNED_WORD(t->base_opcode)) { - p = frag_more (2); - /* put out high byte first: can't use md_number_to_chars! */ - *p++ = (t->base_opcode >> 8) & 0xff; - *p = t->base_opcode & 0xff; - } else { /* opcode is either 3 or 4 bytes */ - if (t->base_opcode & 0xff000000) { - p = frag_more (4); - *p++ = (t->base_opcode >> 24) & 0xff; - } else p = frag_more (3); - *p++ = (t->base_opcode >> 16) & 0xff; - *p++ = (t->base_opcode >> 8) & 0xff; - *p = (t->base_opcode ) & 0xff; - } - - /* Now the modrm byte and base index byte (if present). */ - if (t->opcode_modifier & Modrm) { - p = frag_more (1); - /* md_number_to_chars (p, i.rm, 1); */ - md_number_to_chars (p, (i.rm.regmem<<0 | i.rm.reg<<3 | i.rm.mode<<6), 1); - /* If i.rm.regmem == ESP (4) && i.rm.mode != Mode 3 (Register mode) - ==> need second modrm byte. */ - if (i.rm.regmem == ESCAPE_TO_TWO_BYTE_ADDRESSING && i.rm.mode != 3) { - p = frag_more (1); - /* md_number_to_chars (p, i.bi, 1); */ - md_number_to_chars (p,(i.bi.base<<0 | i.bi.index<<3 | i.bi.scale<<6), 1); - } - } - - if (i.disp_operands) { - register unsigned int n; - - for (n = 0; n < i.operands; n++) { - if (i.disps[n]) { - if (i.disps[n]->X_seg == SEG_ABSOLUTE) { - if (i.types[n] & (Disp8|Abs8)) { - p = frag_more (1); - md_number_to_chars (p, i.disps[n]->X_add_number, 1); - } else if (i.types[n] & (Disp16|Abs16)) { - p = frag_more (2); - md_number_to_chars (p, i.disps[n]->X_add_number, 2); - } else { /* Disp32|Abs32 */ - p = frag_more (4); - md_number_to_chars (p, i.disps[n]->X_add_number, 4); - } - } else { /* not SEG_ABSOLUTE */ - /* need a 32-bit fixup (don't support 8bit non-absolute disps) */ - p = frag_more (4); - fix_new (frag_now, p - frag_now->fr_literal, 4, - i.disps[n]->X_add_symbol, i.disps[n]->X_subtract_symbol, - i.disps[n]->X_add_number, 0, NO_RELOC); - } - } - } - } /* end displacement output */ - - /* output immediate */ - if (i.imm_operands) { - register unsigned int n; - - for (n = 0; n < i.operands; n++) { - if (i.imms[n]) { - if (i.imms[n]->X_seg == SEG_ABSOLUTE) { - if (i.types[n] & (Imm8|Imm8S)) { - p = frag_more (1); - md_number_to_chars (p, i.imms[n]->X_add_number, 1); - } else if (i.types[n] & Imm16) { - p = frag_more (2); - md_number_to_chars (p, i.imms[n]->X_add_number, 2); - } else { - p = frag_more (4); - md_number_to_chars (p, i.imms[n]->X_add_number, 4); - } - } else { /* not SEG_ABSOLUTE */ - /* need a 32-bit fixup (don't support 8bit non-absolute ims) */ - /* try to support other sizes ... */ - int size; - if (i.types[n] & (Imm8|Imm8S)) - size = 1; - else if (i.types[n] & Imm16) - size = 2; - else - size = 4; - p = frag_more (size); - fix_new (frag_now, p - frag_now->fr_literal, size, - i.imms[n]->X_add_symbol, i.imms[n]->X_subtract_symbol, - i.imms[n]->X_add_number, 0, NO_RELOC); - } - } - } - } /* end immediate output */ - } - -#ifdef DEBUG386 - if (flagseen ['D']) { - pi (line, &i); - } -#endif /* DEBUG386 */ - - } - return; -} - -/* Parse OPERAND_STRING into the i386_insn structure I. Returns non-zero - on error. */ - -static int i386_operand (operand_string) - char *operand_string; -{ - register char *op_string = operand_string; - - /* Address of '\0' at end of operand_string. */ - char * end_of_operand_string = operand_string + strlen(operand_string); - - /* Start and end of displacement string expression (if found). */ - char * displacement_string_start = 0; - char * displacement_string_end; - - /* We check for an absolute prefix (differentiating, - for example, 'jmp pc_relative_label' from 'jmp *absolute_label'. */ - if (*op_string == ABSOLUTE_PREFIX) { - op_string++; - i.types[this_operand] |= JumpAbsolute; - } - - /* Check if operand is a register. */ - if (*op_string == REGISTER_PREFIX) { - register reg_entry * r; - if (! (r = parse_register (op_string))) { - as_bad("bad register name ('%s')", op_string); - return 0; - } - /* Check for segment override, rather than segment register by - searching for ':' after %s where = s, c, d, e, f, g. */ - if ((r->reg_type & (SReg2|SReg3)) && op_string[3] == ':') { - switch (r->reg_num) { - case 0: - i.seg = &es; break; - case 1: - i.seg = &cs; break; - case 2: - i.seg = &ss; break; - case 3: - i.seg = &ds; break; - case 4: - i.seg = &fs; break; - case 5: - i.seg = &gs; break; - } - op_string += 4; /* skip % s : */ - operand_string = op_string; /* Pretend given string starts here. */ - if (!is_digit_char(*op_string) && !is_identifier_char(*op_string) - && *op_string != '(' && *op_string != ABSOLUTE_PREFIX) { - as_bad("bad memory operand after segment override"); - return 0; - } - /* Handle case of %es:*foo. */ - if (*op_string == ABSOLUTE_PREFIX) { - op_string++; - i.types[this_operand] |= JumpAbsolute; - } - goto do_memory_reference; - } - i.types[this_operand] |= r->reg_type; - i.regs[this_operand] = r; - i.reg_operands++; - } else if (*op_string == IMMEDIATE_PREFIX) { /* ... or an immediate */ - char * save_input_line_pointer; - register expressionS *exp; - segT exp_seg; - if (i.imm_operands == MAX_IMMEDIATE_OPERANDS) { - as_bad("only 1 or 2 immediate operands are allowed"); - return 0; - } - exp = &im_expressions[i.imm_operands++]; - i.imms [this_operand] = exp; - save_input_line_pointer = input_line_pointer; - input_line_pointer = ++op_string; /* must advance op_string! */ - exp_seg = expression (exp); - input_line_pointer = save_input_line_pointer; - switch (exp_seg) { - case SEG_ABSENT: /* missing or bad expr becomes absolute 0 */ - as_bad("missing or invalid immediate expression '%s' taken as 0", - operand_string); - exp->X_seg = SEG_ABSOLUTE; - exp->X_add_number = 0; - exp->X_add_symbol = (symbolS *) 0; - exp->X_subtract_symbol = (symbolS *) 0; - i.types[this_operand] |= Imm; - break; - case SEG_ABSOLUTE: - i.types[this_operand] |= SMALLEST_IMM_TYPE (exp->X_add_number); - break; - case SEG_TEXT: case SEG_DATA: case SEG_BSS: case SEG_UNKNOWN: - i.types[this_operand] |= Imm32; /* this is an address ==> 32bit */ - break; - default: -seg_unimplemented: - as_bad("Unimplemented segment type %d in parse_operand", exp_seg); - return 0; - } - /* shorten this type of this operand if the instruction wants - * fewer bits than are present in the immediate. The bit field - * code can put out 'andb $0xffffff, %al', for example. pace - * also 'movw $foo,(%eax)' - */ - switch (i.suffix) { - case WORD_OPCODE_SUFFIX: - i.types[this_operand] |= Imm16; - break; - case BYTE_OPCODE_SUFFIX: - i.types[this_operand] |= Imm16 | Imm8 | Imm8S; - break; - } - } else if (is_digit_char(*op_string) || is_identifier_char(*op_string) - || *op_string == '(') { - /* This is a memory reference of some sort. */ - register char * base_string; - unsigned int found_base_index_form; - - do_memory_reference: - if (i.mem_operands == MAX_MEMORY_OPERANDS) { - as_bad("more than 1 memory reference in instruction"); - return 0; - } - i.mem_operands++; - - /* Determine type of memory operand from opcode_suffix; - no opcode suffix implies general memory references. */ - switch (i.suffix) { - case BYTE_OPCODE_SUFFIX: - i.types[this_operand] |= Mem8; - break; - case WORD_OPCODE_SUFFIX: - i.types[this_operand] |= Mem16; - break; - case DWORD_OPCODE_SUFFIX: - default: - i.types[this_operand] |= Mem32; - } - - /* Check for base index form. We detect the base index form by - looking for an ')' at the end of the operand, searching - for the '(' matching it, and finding a REGISTER_PREFIX or ',' - after it. */ - base_string = end_of_operand_string - 1; - found_base_index_form = 0; - if (*base_string == ')') { - unsigned int parens_balenced = 1; - /* We've already checked that the number of left & right ()'s are equal, - so this loop will not be infinite. */ - do { - base_string--; - if (*base_string == ')') parens_balenced++; - if (*base_string == '(') parens_balenced--; - } while (parens_balenced); - base_string++; /* Skip past '('. */ - if (*base_string == REGISTER_PREFIX || *base_string == ',') - found_base_index_form = 1; - } - - /* If we can't parse a base index register expression, we've found - a pure displacement expression. We set up displacement_string_start - and displacement_string_end for the code below. */ - if (! found_base_index_form) { - displacement_string_start = op_string; - displacement_string_end = end_of_operand_string; - } else { - char *base_reg_name, *index_reg_name, *num_string; - int num; - - i.types[this_operand] |= BaseIndex; - - /* If there is a displacement set-up for it to be parsed later. */ - if (base_string != op_string + 1) { - displacement_string_start = op_string; - displacement_string_end = base_string - 1; - } - - /* Find base register (if any). */ - if (*base_string != ',') { - base_reg_name = base_string++; - /* skip past register name & parse it */ - while (isalpha(*base_string)) base_string++; - if (base_string == base_reg_name+1) { - as_bad("can't find base register name after '(%c'", - REGISTER_PREFIX); - return 0; - } - END_STRING_AND_SAVE (base_string); - if (! (i.base_reg = parse_register (base_reg_name))) { - as_bad("bad base register name ('%s')", base_reg_name); - return 0; - } - RESTORE_END_STRING (base_string); - } - - /* Now check seperator; must be ',' ==> index reg - OR num ==> no index reg. just scale factor - OR ')' ==> end. (scale factor = 1) */ - if (*base_string != ',' && *base_string != ')') { - as_bad("expecting ',' or ')' after base register in `%s'", - operand_string); - return 0; - } - - /* There may index reg here; and there may be a scale factor. */ - if (*base_string == ',' && *(base_string+1) == REGISTER_PREFIX) { - index_reg_name = ++base_string; - while (isalpha(*++base_string)); - END_STRING_AND_SAVE (base_string); - if (! (i.index_reg = parse_register(index_reg_name))) { - as_bad("bad index register name ('%s')", index_reg_name); - return 0; - } - RESTORE_END_STRING (base_string); - } - - /* Check for scale factor. */ - if (*base_string == ',' && isdigit(*(base_string+1))) { - num_string = ++base_string; - while (is_digit_char(*base_string)) base_string++; - if (base_string == num_string) { - as_bad("can't find a scale factor after ','"); - return 0; - } - END_STRING_AND_SAVE (base_string); - /* We've got a scale factor. */ - if (! sscanf (num_string, "%d", &num)) { - as_bad("can't parse scale factor from '%s'", num_string); - return 0; - } - RESTORE_END_STRING (base_string); - switch (num) { /* must be 1 digit scale */ - case 1: i.log2_scale_factor = 0; break; - case 2: i.log2_scale_factor = 1; break; - case 4: i.log2_scale_factor = 2; break; - case 8: i.log2_scale_factor = 3; break; - default: - as_bad("expecting scale factor of 1, 2, 4, 8; got %d", num); - return 0; - } - } else { - if (! i.index_reg && *base_string == ',') { - as_bad("expecting index register or scale factor after ','; got '%c'", - *(base_string+1)); - return 0; - } - } - } - - /* If there's an expression begining the operand, parse it, - assuming displacement_string_start and displacement_string_end - are meaningful. */ - if (displacement_string_start) { - register expressionS * exp; - segT exp_seg; - char * save_input_line_pointer; - exp = &disp_expressions[i.disp_operands]; - i.disps [this_operand] = exp; - i.disp_operands++; - save_input_line_pointer = input_line_pointer; - input_line_pointer = displacement_string_start; - END_STRING_AND_SAVE (displacement_string_end); - exp_seg = expression (exp); - if(*input_line_pointer) - as_bad("Ignoring junk '%s' after expression",input_line_pointer); - RESTORE_END_STRING (displacement_string_end); - input_line_pointer = save_input_line_pointer; - switch (exp_seg) { - case SEG_ABSENT: - /* missing expr becomes absolute 0 */ - as_bad("missing or invalid displacement '%s' taken as 0", - operand_string); - i.types[this_operand] |= (Disp|Abs); - exp->X_seg = SEG_ABSOLUTE; - exp->X_add_number = 0; - exp->X_add_symbol = (symbolS *) 0; - exp->X_subtract_symbol = (symbolS *) 0; - break; - case SEG_ABSOLUTE: - i.types[this_operand] |= SMALLEST_DISP_TYPE (exp->X_add_number); - break; - case SEG_TEXT: case SEG_DATA: case SEG_BSS: - case SEG_UNKNOWN: /* must be 32 bit displacement (i.e. address) */ - i.types[this_operand] |= Disp32; - break; - default: - goto seg_unimplemented; - } - } - - /* Make sure the memory operand we've been dealt is valid. */ - if (i.base_reg && i.index_reg && - ! (i.base_reg->reg_type & i.index_reg->reg_type & Reg)) { - as_bad("register size mismatch in (base,index,scale) expression"); - return 0; - } - if ((i.base_reg && (i.base_reg->reg_type & Reg32) == 0) || - (i.index_reg && (i.index_reg->reg_type & Reg32) == 0)) { - as_bad("base/index register must be 32 bit register"); - return 0; - } - if (i.index_reg && i.index_reg == esp) { - as_bad("%s may not be used as an index register", esp->reg_name); - return 0; - } - } else { /* it's not a memory operand; argh! */ - as_bad("invalid char %s begining %s operand '%s'", - output_invalid(*op_string), ordinal_names[this_operand], - op_string); - return 0; - } - return 1; /* normal return */ -} - -/* - * md_estimate_size_before_relax() - * - * Called just before relax(). - * Any symbol that is now undefined will not become defined. - * Return the correct fr_subtype in the frag. - * Return the initial "guess for fr_var" to caller. - * The guess for fr_var is ACTUALLY the growth beyond fr_fix. - * Whatever we do to grow fr_fix or fr_var contributes to our returned value. - * Although it may not be explicit in the frag, pretend fr_var starts with a - * 0 value. - */ -int -md_estimate_size_before_relax (fragP, segment) - register fragS * fragP; - register segT segment; -{ - register unsigned char * opcode; - register int old_fr_fix; - - old_fr_fix = fragP -> fr_fix; - opcode = (unsigned char *) fragP -> fr_opcode; - /* We've already got fragP->fr_subtype right; all we have to do is check - for un-relaxable symbols. */ - if (S_GET_SEGMENT(fragP -> fr_symbol) != segment) { - /* symbol is undefined in this segment */ - switch (opcode[0]) { - case JUMP_PC_RELATIVE: /* make jmp (0xeb) a dword displacement jump */ - opcode[0] = 0xe9; /* dword disp jmp */ - fragP -> fr_fix += 4; - fix_new (fragP, old_fr_fix, 4, - fragP -> fr_symbol, - (symbolS *) 0, - fragP -> fr_offset, 1, NO_RELOC); - break; - - default: - /* This changes the byte-displacement jump 0x7N --> - the dword-displacement jump 0x0f8N */ - opcode[1] = opcode[0] + 0x10; - opcode[0] = TWO_BYTE_OPCODE_ESCAPE; /* two-byte escape */ - fragP -> fr_fix += 1 + 4; /* we've added an opcode byte */ - fix_new (fragP, old_fr_fix + 1, 4, - fragP -> fr_symbol, - (symbolS *) 0, - fragP -> fr_offset, 1, NO_RELOC); - break; - } - frag_wane (fragP); - } - return (fragP -> fr_var + fragP -> fr_fix - old_fr_fix); -} /* md_estimate_size_before_relax() */ - -/* - * md_convert_frag(); - * - * Called after relax() is finished. - * In: Address of frag. - * fr_type == rs_machine_dependent. - * fr_subtype is what the address relaxed to. - * - * Out: Any fixSs and constants are set up. - * Caller will turn frag into a ".space 0". - */ -void -md_convert_frag (fragP) - register fragS * fragP; -{ - register unsigned char * opcode; - unsigned char * where_to_put_displacement; - unsigned int target_address, opcode_address; - unsigned int extension; - int displacement_from_opcode_start; - - opcode = (unsigned char *) fragP -> fr_opcode; - - /* Address we want to reach in file space. */ - target_address = S_GET_VALUE(fragP->fr_symbol) + fragP->fr_offset; - - /* Address opcode resides at in file space. */ - opcode_address = fragP->fr_address + fragP->fr_fix; - - /* Displacement from opcode start to fill into instruction. */ - displacement_from_opcode_start = target_address - opcode_address; - - switch (fragP->fr_subtype) { - case ENCODE_RELAX_STATE (COND_JUMP, BYTE): - case ENCODE_RELAX_STATE (UNCOND_JUMP, BYTE): - /* don't have to change opcode */ - extension = 1; /* 1 opcode + 1 displacement */ - where_to_put_displacement = &opcode[1]; - break; - - case ENCODE_RELAX_STATE (COND_JUMP, WORD): - opcode[1] = TWO_BYTE_OPCODE_ESCAPE; - opcode[2] = opcode[0] + 0x10; - opcode[0] = WORD_PREFIX_OPCODE; - extension = 4; /* 3 opcode + 2 displacement */ - where_to_put_displacement = &opcode[3]; - break; - - case ENCODE_RELAX_STATE (UNCOND_JUMP, WORD): - opcode[1] = 0xe9; - opcode[0] = WORD_PREFIX_OPCODE; - extension = 3; /* 2 opcode + 2 displacement */ - where_to_put_displacement = &opcode[2]; - break; - - case ENCODE_RELAX_STATE (COND_JUMP, DWORD): - opcode[1] = opcode[0] + 0x10; - opcode[0] = TWO_BYTE_OPCODE_ESCAPE; - extension = 5; /* 2 opcode + 4 displacement */ - where_to_put_displacement = &opcode[2]; - break; - - case ENCODE_RELAX_STATE (UNCOND_JUMP, DWORD): - opcode[0] = 0xe9; - extension = 4; /* 1 opcode + 4 displacement */ - where_to_put_displacement = &opcode[1]; - break; - - default: - BAD_CASE(fragP -> fr_subtype); - break; - } - /* now put displacement after opcode */ - md_number_to_chars (where_to_put_displacement, - displacement_from_opcode_start - extension, - SIZE_FROM_RELAX_STATE (fragP->fr_subtype)); - fragP -> fr_fix += extension; -} - - -int md_short_jump_size = 2; /* size of byte displacement jmp */ -int md_long_jump_size = 5; /* size of dword displacement jmp */ -int md_reloc_size = 8; /* Size of relocation record */ - -void md_create_short_jump(ptr, from_addr, to_addr, frag, to_symbol) - char *ptr; - long from_addr, to_addr; -fragS *frag; -symbolS *to_symbol; -{ - long offset; - - offset = to_addr - (from_addr + 2); - md_number_to_chars (ptr, (long) 0xeb, 1); /* opcode for byte-disp jump */ - md_number_to_chars (ptr + 1, offset, 1); -} - -void md_create_long_jump (ptr, from_addr, to_addr, frag, to_symbol) - char *ptr; - long from_addr, to_addr; - fragS *frag; - symbolS *to_symbol; -{ - long offset; - - if (flagseen['m']) { - offset = to_addr - S_GET_VALUE(to_symbol); - md_number_to_chars (ptr, 0xe9, 1); /* opcode for long jmp */ - md_number_to_chars (ptr + 1, offset, 4); - fix_new (frag, (ptr+1) - frag->fr_literal, 4, - to_symbol, (symbolS *) 0, (long) 0, 0, NO_RELOC); - } else { - offset = to_addr - (from_addr + 5); - md_number_to_chars(ptr, (long) 0xe9, 1); - md_number_to_chars(ptr + 1, offset, 4); - } -} - -int -md_parse_option(argP,cntP,vecP) -char **argP; -int *cntP; -char ***vecP; -{ - return 1; -} - -void /* Knows about order of bytes in address. */ -md_number_to_chars (con, value, nbytes) - char con []; /* Return 'nbytes' of chars here. */ - long value; /* The value of the bits. */ - int nbytes; /* Number of bytes in the output. */ -{ - register char * p = con; - - switch (nbytes) { - case 1: - p[0] = value & 0xff; - break; - case 2: - p[0] = value & 0xff; - p[1] = (value >> 8) & 0xff; - break; - case 4: - p[0] = value & 0xff; - p[1] = (value>>8) & 0xff; - p[2] = (value>>16) & 0xff; - p[3] = (value>>24) & 0xff; - break; - default: - BAD_CASE (nbytes); - } -} - - -/* Apply a fixup (fixS) to segment data, once it has been determined - by our caller that we have all the info we need to fix it up. - - On the 386, immediates, displacements, and data pointers are all in - the same (little-endian) format, so we don't need to care about which - we are handling. */ - -void -md_apply_fix (fixP, value) - fixS * fixP; /* The fix we're to put in */ - long value; /* The value of the bits. */ -{ - register char * p = fixP->fx_where + fixP->fx_frag->fr_literal; - - switch (fixP->fx_size) { - case 1: - *p = value; - break; - case 2: - *p++ = value; - *p = (value>>8); - break; - case 4: - *p++ = value; - *p++ = (value>>8); - *p++ = (value>>16); - *p = (value>>24); - break; - default: - BAD_CASE (fixP->fx_size); - } -} - -long /* Knows about the byte order in a word. */ -md_chars_to_number (con, nbytes) -unsigned char con[]; /* Low order byte 1st. */ - int nbytes; /* Number of bytes in the input. */ -{ - long retval; - for (retval=0, con+=nbytes-1; nbytes--; con--) - { - retval <<= BITS_PER_CHAR; - retval |= *con; - } - return retval; -} - -/* Not needed for coff since relocation structure does not - contain bitfields. */ -#if defined(OBJ_AOUT) | defined(OBJ_BOUT) -/* Output relocation information in the target's format. */ -void -md_ri_to_chars(the_bytes, ri) - char *the_bytes; - struct reloc_info_generic *ri; -{ - /* this is easy */ - md_number_to_chars(the_bytes, ri->r_address, 4); - /* now the fun stuff */ - the_bytes[6] = (ri->r_symbolnum >> 16) & 0x0ff; - the_bytes[5] = (ri->r_symbolnum >> 8) & 0x0ff; - the_bytes[4] = ri->r_symbolnum & 0x0ff; - the_bytes[7] = (((ri->r_extern << 3) & 0x08) | ((ri->r_length << 1) & 0x06) | - ((ri->r_pcrel << 0) & 0x01)) & 0x0F; -} -#endif /* OBJ_AOUT or OBJ_BOUT */ - - -#define MAX_LITTLENUMS 6 - -/* Turn the string pointed to by litP into a floating point constant of type - type, and emit the appropriate bytes. The number of LITTLENUMS emitted - is stored in *sizeP . An error message is returned, or NULL on OK. - */ -char * -md_atof(type,litP,sizeP) - char type; - char *litP; - int *sizeP; -{ - int prec; - LITTLENUM_TYPE words[MAX_LITTLENUMS]; - LITTLENUM_TYPE *wordP; - char *t; - - switch(type) { - case 'f': - case 'F': - prec = 2; - break; - - case 'd': - case 'D': - prec = 4; - break; - - case 'x': - case 'X': - prec = 5; - break; - - default: - *sizeP=0; - return "Bad call to md_atof ()"; - } - t = atof_ieee (input_line_pointer,type,words); - if(t) - input_line_pointer=t; - - *sizeP = prec * sizeof(LITTLENUM_TYPE); - /* this loops outputs the LITTLENUMs in REVERSE order; in accord with - the bigendian 386 */ - for(wordP = words + prec - 1;prec--;) { - md_number_to_chars (litP, (long) (*wordP--), sizeof(LITTLENUM_TYPE)); - litP += sizeof(LITTLENUM_TYPE); - } - return ""; /* Someone should teach Dean about null pointers */ -} - -char output_invalid_buf[8]; - -static char * output_invalid (c) - char c; -{ - if (isprint(c)) sprintf (output_invalid_buf, "'%c'", c); - else sprintf (output_invalid_buf, "(0x%x)", (unsigned) c); - return output_invalid_buf; -} - -static reg_entry *parse_register (reg_string) - char *reg_string; /* reg_string starts *before* REGISTER_PREFIX */ -{ - register char *s = reg_string; - register char *p; - char reg_name_given[MAX_REG_NAME_SIZE]; - - s++; /* skip REGISTER_PREFIX */ - for (p = reg_name_given; is_register_char (*s); p++, s++) { - *p = register_chars [*s]; - if (p >= reg_name_given + MAX_REG_NAME_SIZE) - return (reg_entry *) 0; - } - *p = '\0'; - return (reg_entry *) hash_find (reg_hash, reg_name_given); -} - - -/* We have no need to default values of symbols. */ - -/* ARGSUSED */ -symbolS * -md_undefined_symbol (name) - char *name; -{ - return 0; -} - -/* Parse an operand that is machine-specific. - We just return without modifying the expression if we have nothing - to do. */ - -/* ARGSUSED */ -void -md_operand (expressionP) - expressionS *expressionP; -{ -} - -/* Round up a section size to the appropriate boundary. */ -long -md_section_align (segment, size) - segT segment; - long size; -{ - return size; /* Byte alignment is fine */ -} - -/* Exactly what point is a PC-relative offset relative TO? - On the i386, they're relative to the address of the offset, plus - its size. (??? Is this right? FIXME-SOON!) */ -long -md_pcrel_from (fixP) - fixS *fixP; -{ - return fixP->fx_size + fixP->fx_where + fixP->fx_frag->fr_address; -} - -/* - * $Log$ - * Revision 1.1 1991/04/04 18:16:41 rich - * Initial revision - * - * Revision 1.2 1991/03/30 17:11:30 rich - * Updated md_create_short_jump calling protocol. - * - * - */ - -/* - * Local Variables: - * comment-column: 0 - * End: - */ - -/* end of tc-i386.c */ diff --git a/gas/config/tc-i386.h b/gas/config/tc-i386.h deleted file mode 100644 index a2b853e8cf0..00000000000 --- a/gas/config/tc-i386.h +++ /dev/null @@ -1,247 +0,0 @@ -/* i386.h -- Header file for i386.c - Copyright (C) 1989, Free Software Foundation. - -This file is part of GAS, the GNU Assembler. - -GAS 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 1, or (at your option) -any later version. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#define TC_I386 1 - -#define tc_crawl_symbol_chain(a) ; /* not used */ -#define tc_headers_hook(a) ; /* not used */ - -#define MAX_OPERANDS 3 /* max operands per insn */ -#define MAX_PREFIXES 4 /* max prefixes per opcode */ -#define MAX_IMMEDIATE_OPERANDS 2 /* max immediates per insn */ -#define MAX_MEMORY_OPERANDS 2 /* max memory ref per insn - * lcall uses 2 - */ -/* we define the syntax here (modulo base,index,scale syntax) */ -#define REGISTER_PREFIX '%' -#define IMMEDIATE_PREFIX '$' -#define ABSOLUTE_PREFIX '*' -#define PREFIX_SEPERATOR '/' - -#define TWO_BYTE_OPCODE_ESCAPE 0x0f - -/* register numbers */ -#define EBP_REG_NUM 5 -#define ESP_REG_NUM 4 - -/* modrm_byte.regmem for twobyte escape */ -#define ESCAPE_TO_TWO_BYTE_ADDRESSING ESP_REG_NUM -/* index_base_byte.index for no index register addressing */ -#define NO_INDEX_REGISTER ESP_REG_NUM -/* index_base_byte.base for no base register addressing */ -#define NO_BASE_REGISTER EBP_REG_NUM - -/* these are the att as opcode suffixes, making movl --> mov, for example */ -#define DWORD_OPCODE_SUFFIX 'l' -#define WORD_OPCODE_SUFFIX 'w' -#define BYTE_OPCODE_SUFFIX 'b' - -/* modrm.mode = REGMEM_FIELD_HAS_REG when a register is in there */ -#define REGMEM_FIELD_HAS_REG 0x3 /* always = 0x3 */ -#define REGMEM_FIELD_HAS_MEM (~REGMEM_FIELD_HAS_REG) - -#define END_OF_INSN '\0' - -/* -When an operand is read in it is classified by its type. This type includes -all the possible ways an operand can be used. Thus, '%eax' is both 'register -# 0' and 'The Accumulator'. In our language this is expressed by OR'ing -'Reg32' (any 32 bit register) and 'Acc' (the accumulator). -Operands are classified so that we can match given operand types with -the opcode table in i386-opcode.h. - */ -#define Unknown 0x0 -/* register */ -#define Reg8 0x1 /* 8 bit reg */ -#define Reg16 0x2 /* 16 bit reg */ -#define Reg32 0x4 /* 32 bit reg */ -#define Reg (Reg8|Reg16|Reg32) /* gen'l register */ -#define WordReg (Reg16|Reg32) /* for push/pop operands */ -/* immediate */ -#define Imm8 0x8 /* 8 bit immediate */ -#define Imm8S 0x10 /* 8 bit immediate sign extended */ -#define Imm16 0x20 /* 16 bit immediate */ -#define Imm32 0x40 /* 32 bit immediate */ -#define Imm1 0x80 /* 1 bit immediate */ -#define ImmUnknown Imm32 /* for unknown expressions */ -#define Imm (Imm8|Imm8S|Imm16|Imm32) /* gen'l immediate */ -/* memory */ -#define Disp8 0x200 /* 8 bit displacement (for jumps) */ -#define Disp16 0x400 /* 16 bit displacement */ -#define Disp32 0x800 /* 32 bit displacement */ -#define Disp (Disp8|Disp16|Disp32) /* General displacement */ -#define DispUnknown Disp32 /* for unknown size displacements */ -#define Mem8 0x1000 -#define Mem16 0x2000 -#define Mem32 0x4000 -#define BaseIndex 0x8000 -#define Mem (Disp|Mem8|Mem16|Mem32|BaseIndex) /* General memory */ -#define WordMem (Mem16|Mem32|Disp|BaseIndex) -#define ByteMem (Mem8|Disp|BaseIndex) -/* specials */ -#define InOutPortReg 0x10000 /* register to hold in/out port addr = dx */ -#define ShiftCount 0x20000 /* register to hold shift cound = cl */ -#define Control 0x40000 /* Control register */ -#define Debug 0x80000 /* Debug register */ -#define Test 0x100000 /* Test register */ -#define FloatReg 0x200000 /* Float register */ -#define FloatAcc 0x400000 /* Float stack top %st(0) */ -#define SReg2 0x800000 /* 2 bit segment register */ -#define SReg3 0x1000000 /* 3 bit segment register */ -#define Acc 0x2000000 /* Accumulator %al or %ax or %eax */ -#define ImplicitRegister (InOutPortReg|ShiftCount|Acc|FloatAcc) -#define JumpAbsolute 0x4000000 -#define Abs8 0x08000000 -#define Abs16 0x10000000 -#define Abs32 0x20000000 -#define Abs (Abs8|Abs16|Abs32) - -#define MODE_FROM_DISP_SIZE(t) \ - ((t&(Disp8)) ? 1 : \ - ((t&(Disp32)) ? 2 : 0)) - -#define Byte (Reg8|Imm8|Imm8S) -#define Word (Reg16|Imm16) -#define DWord (Reg32|Imm32) - -/* convert opcode suffix ('b' 'w' 'l' typically) into type specifyer */ -#define OPCODE_SUFFIX_TO_TYPE(s) \ - (s == BYTE_OPCODE_SUFFIX ? Byte : \ - (s == WORD_OPCODE_SUFFIX ? Word : DWord)) - -#define FITS_IN_SIGNED_BYTE(num) ((num) >= -128 && (num) <= 127) -#define FITS_IN_UNSIGNED_BYTE(num) ((num) >= 0 && (num) <= 255) -#define FITS_IN_UNSIGNED_WORD(num) ((num) >= 0 && (num) <= 65535) -#define FITS_IN_SIGNED_WORD(num) ((num) >= -32768 && (num) <= 32767) - -#define SMALLEST_DISP_TYPE(num) \ - FITS_IN_SIGNED_BYTE(num) ? (Disp8|Disp32|Abs8|Abs32) : (Disp32|Abs32) - -#define SMALLEST_IMM_TYPE(num) \ - (num == 1) ? (Imm1|Imm8|Imm8S|Imm16|Imm32): \ - FITS_IN_SIGNED_BYTE(num) ? (Imm8S|Imm8|Imm16|Imm32) : \ - FITS_IN_UNSIGNED_BYTE(num) ? (Imm8|Imm16|Imm32): \ - (FITS_IN_SIGNED_WORD(num)||FITS_IN_UNSIGNED_WORD(num)) ? (Imm16|Imm32) : \ - (Imm32) - -typedef struct { - /* instruction name sans width suffix ("mov" for movl insns) */ - char *name; - - /* how many operands */ - unsigned int operands; - - /* base_opcode is the fundamental opcode byte with a optional prefix(es). */ - unsigned int base_opcode; - - /* extension_opcode is the 3 bit extension for group insns. - If this template has no extension opcode (the usual case) use None */ - unsigned char extension_opcode; -#define None 0xff /* If no extension_opcode is possible. */ - - /* the bits in opcode_modifier are used to generate the final opcode from - the base_opcode. These bits also are used to detect alternate forms of - the same instruction */ - unsigned int opcode_modifier; - -/* opcode_modifier bits: */ -#define W 0x1 /* set if operands are words or dwords */ -#define D 0x2 /* D = 0 if Reg --> Regmem; D = 1 if Regmem --> Reg */ -/* direction flag for floating insns: MUST BE 0x400 */ -#define FloatD 0x400 -/* shorthand */ -#define DW (D|W) -#define ShortForm 0x10 /* register is in low 3 bits of opcode */ -#define ShortFormW 0x20 /* ShortForm and W bit is 0x8 */ -#define Seg2ShortForm 0x40 /* encoding of load segment reg insns */ -#define Seg3ShortForm 0x80 /* fs/gs segment register insns. */ -#define Jump 0x100 /* special case for jump insns. */ -#define JumpInterSegment 0x200 /* special case for intersegment leaps/calls */ -/* 0x400 CANNOT BE USED since it's already used by FloatD above */ -#define DONT_USE 0x400 -#define NoModrm 0x800 -#define Modrm 0x1000 -#define imulKludge 0x2000 -#define JumpByte 0x4000 -#define JumpDword 0x8000 -#define ReverseRegRegmem 0x10000 - - /* (opcode_modifier & COMES_IN_ALL_SIZES) is true if the - instuction comes in byte, word, and dword sizes and is encoded into - machine code in the canonical way. */ -#define COMES_IN_ALL_SIZES (W) - - /* (opcode_modifier & COMES_IN_BOTH_DIRECTIONS) indicates that the - source and destination operands can be reversed by setting either - the D (for integer insns) or the FloatD (for floating insns) bit - in base_opcode. */ -#define COMES_IN_BOTH_DIRECTIONS (D|FloatD) - - /* operand_types[i] describes the type of operand i. This is made - by OR'ing together all of the possible type masks. (e.g. - 'operand_types[i] = Reg|Imm' specifies that operand i can be - either a register or an immediate operand */ - unsigned int operand_types[3]; -} template; - -/* - 'templates' is for grouping together 'template' structures for opcodes - of the same name. This is only used for storing the insns in the grand - ole hash table of insns. - The templates themselves start at START and range up to (but not including) - END. -*/ -typedef struct { - template *start; - template *end; -} templates; - -/* these are for register name --> number & type hash lookup */ -typedef struct { - char * reg_name; - unsigned int reg_type; - unsigned int reg_num; -} reg_entry; - -typedef struct { - char * seg_name; - unsigned int seg_prefix; -} seg_entry; - -/* these are for prefix name --> prefix code hash lookup */ -typedef struct { - char * prefix_name; - unsigned char prefix_code; -} prefix_entry; - -/* 386 operand encoding bytes: see 386 book for details of this. */ -typedef struct { - unsigned regmem:3; /* codes register or memory operand */ - unsigned reg:3; /* codes register operand (or extended opcode) */ - unsigned mode:2; /* how to interpret regmem & reg */ -} modrm_byte; - -/* 386 opcode byte to code indirect addressing. */ -typedef struct { - unsigned base:3; - unsigned index:3; - unsigned scale:2; -} base_index_byte; - -/* end of tc-i386.h */ diff --git a/gas/config/tc-i860.c b/gas/config/tc-i860.c deleted file mode 100644 index d9dd84cd906..00000000000 --- a/gas/config/tc-i860.c +++ /dev/null @@ -1,1255 +0,0 @@ -/* i860.c -- Assemble for the I860 - Copyright (C) 1989 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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 1, or (at your option) -any later version. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* $Id$ */ - -#include "as.h" - -#include "i860-opcode.h" - -/* incorporated from i860.h */ -enum reloc_type /* NOTE: three bits max, see struct reloc_info_i860.r_type */ -{ - NO_RELOC = 0, BRADDR, LOW0, LOW1, LOW2, LOW3, LOW4, SPLIT0, SPLIT1, SPLIT2, RELOC_32, -}; - -enum highlow_type /* NOTE: two bits max, see reloc_info_i860.r_type */ -{ - NO_SPEC = 0, PAIR, HIGH, HIGHADJ, -}; - -struct reloc_info_i860 -{ - unsigned long r_address; -/* - * Using bit fields here is a bad idea because the order is not portable. :-( - */ - unsigned int r_symbolnum: 24; - unsigned int r_pcrel : 1; - unsigned int r_extern : 1; - /* combining the two field simplifies the argument passing in "new_fix()" */ - /* and is compatible with the existing Sparc #ifdef's */ - /* r_type: highlow_type - bits 5,4; reloc_type - bits 3-0 */ - unsigned int r_type : 6; - long r_addend; -}; - -#define relocation_info reloc_info_i860 - - -void md_begin(); -void md_end(); -void md_number_to_chars(); -void md_assemble(); -char *md_atof(); -void md_convert_frag(); -void md_create_short_jump(); -void md_create_long_jump(); -int md_estimate_size_before_relax(); -void md_number_to_imm(); -void md_number_to_disp(); -void md_number_to_field(); -void md_ri_to_chars(); -static void i860_ip(); -void emit_machine_reloc(); - -int md_reloc_size = sizeof(struct relocation_info); - -void (*md_emit_relocations)() = emit_machine_reloc; - -const relax_typeS md_relax_table[] = { 0 }; - -/* handle of the OPCODE hash table */ -static struct hash_control *op_hash = NULL; - -static void s_dual(), s_enddual(); -static void s_atmp(); - -const pseudo_typeS -md_pseudo_table[] = { - { "dual", s_dual, 4 }, - { "enddual", s_enddual, 4 }, - { "atmp", s_atmp, 4 }, - { NULL, 0, 0 }, -}; - -int md_short_jump_size = 4; -int md_long_jump_size = 4; - -/* This array holds the chars that always start a comment. If the - pre-processor is disabled, these aren't very useful */ -char comment_chars[] = "!/"; /* JF removed '|' from comment_chars */ - -/* This array holds the chars that only start a comment at the beginning of - a line. If the line seems to have the form '# 123 filename' - .line and .file directives will appear in the pre-processed output */ -/* Note that input_file.c hand checks for '#' at the beginning of the - first line of the input file. This is because the compiler outputs - #NO_APP at the beginning of its output. */ -/* Also note that comments like this one will always work. */ -char line_comment_chars[] = "#/"; - -/* Chars that can be used to separate mant from exp in floating point nums */ -char EXP_CHARS[] = "eE"; - -/* Chars that mean this number is a floating point constant */ -/* As in 0f12.456 */ -/* or 0d1.2345e12 */ -char FLT_CHARS[] = "rRsSfFdDxXpP"; - -/* Also be aware that MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT may have to be - changed in read.c . Ideally it shouldn't have to know about it at all, - but nothing is ideal around here. - */ -int size_reloc_info = sizeof(struct relocation_info); - -static unsigned char octal[256]; -#define isoctal(c) octal[c] -static unsigned char toHex[256]; - -struct i860_it { - char *error; - unsigned long opcode; - struct nlist *nlistp; - expressionS exp; - int pcrel; - enum expand_type expand; - enum highlow_type highlow; - enum reloc_type reloc; -} the_insn; - -#ifdef __STDC__ -static void print_insn(struct i860_it *insn); -static int getExpression(char *str); -#else -static void print_insn(); -static int getExpression(); -#endif -static char *expr_end; -static char last_expand; /* error if expansion after branch */ - -enum dual -{ - DUAL_OFF = 0, DUAL_ON, DUAL_DDOT, DUAL_ONDDOT, -}; -static enum dual dual_mode = DUAL_OFF; /* dual-instruction mode */ - -static void -s_dual() /* floating point instructions have dual set */ -{ - dual_mode = DUAL_ON; -} - -static void -s_enddual() /* floating point instructions have dual set */ -{ - dual_mode = DUAL_OFF; -} - -static int atmp = 31; /* temporary register for pseudo's */ - -static void -s_atmp() -{ - register int temp; - if (strncmp(input_line_pointer, "sp", 2) == 0) { - input_line_pointer += 2; - atmp = 2; - } - else if (strncmp(input_line_pointer, "fp", 2) == 0) { - input_line_pointer += 2; - atmp = 3; - } - else if (strncmp(input_line_pointer, "r", 1) == 0) { - input_line_pointer += 1; - temp = get_absolute_expression(); - if (temp >= 0 && temp <= 31) - atmp = temp; - else - as_bad("Unknown temporary pseudo register"); - } - else { - as_bad("Unknown temporary pseudo register"); - } - demand_empty_rest_of_line(); - return; -} - -/* This function is called once, at assembler startup time. It should - set up all the tables, etc. that the MD part of the assembler will need. */ -void -md_begin() -{ - register char *retval = NULL; - int lose = 0; - register unsigned int i = 0; - - op_hash = hash_new(); - if (op_hash == NULL) - as_fatal("Virtual memory exhausted"); - - while (i < NUMOPCODES) - { - const char *name = i860_opcodes[i].name; - retval = hash_insert(op_hash, name, &i860_opcodes[i]); - if(retval != NULL && *retval != '\0') - { - fprintf (stderr, "internal error: can't hash `%s': %s\n", - i860_opcodes[i].name, retval); - lose = 1; - } - do - { - if (i860_opcodes[i].match & i860_opcodes[i].lose) - { - fprintf (stderr, "internal error: losing opcode: `%s' \"%s\"\n", - i860_opcodes[i].name, i860_opcodes[i].args); - lose = 1; - } - ++i; - } while (i < NUMOPCODES - && !strcmp(i860_opcodes[i].name, name)); - } - - if (lose) - as_fatal("Broken assembler. No assembly attempted."); - - for (i = '0'; i < '8'; ++i) - octal[i] = 1; - for (i = '0'; i <= '9'; ++i) - toHex[i] = i - '0'; - for (i = 'a'; i <= 'f'; ++i) - toHex[i] = i + 10 - 'a'; - for (i = 'A'; i <= 'F'; ++i) - toHex[i] = i + 10 - 'A'; -} - -void -md_end() -{ - return; -} - -void -md_assemble(str) - char *str; -{ - char *toP; - int rsd; - int no_opcodes = 1; - int i; - struct i860_it pseudo[3]; - - assert(str); - i860_ip(str); - - /* check for expandable flag to produce pseudo-instructions */ - if (the_insn.expand != 0 && the_insn.highlow == NO_SPEC) { - for (i = 0; i < 3; i++) - pseudo[i] = the_insn; - - switch (the_insn.expand) { - - case E_DELAY: - no_opcodes = 1; - break; - - case E_MOV: - if (the_insn.exp.X_add_symbol == NULL && - the_insn.exp.X_subtract_symbol == NULL && - (the_insn.exp.X_add_number < (1 << 15) && - the_insn.exp.X_add_number >= -(1 << 15))) - break; - /* or l%const,r0,ireg_dest */ - pseudo[0].opcode = (the_insn.opcode & 0x001f0000) | 0xe4000000; - pseudo[0].highlow = PAIR; - /* orh h%const,ireg_dest,ireg_dest */ - pseudo[1].opcode = (the_insn.opcode & 0x03ffffff) | 0xec000000 | - ((the_insn.opcode & 0x001f0000) << 5); - pseudo[1].highlow = HIGH; - no_opcodes = 2; - break; - - case E_ADDR: - if (the_insn.exp.X_add_symbol == NULL && - the_insn.exp.X_subtract_symbol == NULL) - break; - /* orh ha%addr_expr,r0,r31 */ - pseudo[0].opcode = 0xec000000 | (atmp<<16); - pseudo[0].highlow = HIGHADJ; - pseudo[0].reloc = LOW0; /* must overwrite */ - /* l%addr_expr(r31),ireg_dest */ - pseudo[1].opcode = (the_insn.opcode & ~0x003e0000) | (atmp << 21); - pseudo[1].highlow = PAIR; - no_opcodes = 2; - break; - - case E_U32: /* 2nd version emulates Intel as, not doc. */ - if (the_insn.exp.X_add_symbol == NULL && - the_insn.exp.X_subtract_symbol == NULL && - (the_insn.exp.X_add_number < (1 << 16) && - the_insn.exp.X_add_number >= 0)) - break; - /* $(opcode)h h%const,ireg_src2,ireg_dest - pseudo[0].opcode = (the_insn.opcode & 0xf3ffffff) | 0x0c000000; */ - /* $(opcode)h h%const,ireg_src2,r31 */ - pseudo[0].opcode = (the_insn.opcode & 0xf3e0ffff) | 0x0c000000 | - (atmp << 16); - pseudo[0].highlow = HIGH; - /* $(opcode) l%const,ireg_dest,ireg_dest - pseudo[1].opcode = (the_insn.opcode & 0xf01f0000) | 0x04000000 | - ((the_insn.opcode & 0x001f0000) << 5); */ - /* $(opcode) l%const,r31,ireg_dest */ - pseudo[1].opcode = (the_insn.opcode & 0xf01f0000) | 0x04000000 | - (atmp << 21); - pseudo[1].highlow = PAIR; - no_opcodes = 2; - break; - - case E_AND: /* 2nd version emulates Intel as, not doc. */ - if (the_insn.exp.X_add_symbol == NULL && - the_insn.exp.X_subtract_symbol == NULL && - (the_insn.exp.X_add_number < (1 << 16) && - the_insn.exp.X_add_number >= 0)) - break; - /* andnot h%const,ireg_src2,ireg_dest - pseudo[0].opcode = (the_insn.opcode & 0x03ffffff) | 0xd4000000; */ - /* andnot h%const,ireg_src2,r31 */ - pseudo[0].opcode = (the_insn.opcode & 0x03e0ffff) | 0xd4000000 | - (atmp << 16); - pseudo[0].highlow = HIGH; - pseudo[0].exp.X_add_number = -1 - the_insn.exp.X_add_number; - /* andnot l%const,ireg_dest,ireg_dest - pseudo[1].opcode = (the_insn.opcode & 0x001f0000) | 0xd4000000 | - ((the_insn.opcode & 0x001f0000) << 5); */ - /* andnot l%const,r31,ireg_dest */ - pseudo[1].opcode = (the_insn.opcode & 0x001f0000) | 0xd4000000 | - (atmp << 21); - pseudo[1].highlow = PAIR; - pseudo[1].exp.X_add_number = -1 - the_insn.exp.X_add_number; - no_opcodes = 2; - break; - - case E_S32: - if (the_insn.exp.X_add_symbol == NULL && - the_insn.exp.X_subtract_symbol == NULL && - (the_insn.exp.X_add_number < (1 << 15) && - the_insn.exp.X_add_number >= -(1 << 15))) - break; - /* orh h%const,r0,r31 */ - pseudo[0].opcode = 0xec000000 | (atmp << 16); - pseudo[0].highlow = HIGH; - /* or l%const,r31,r31 */ - pseudo[1].opcode = 0xe4000000 | (atmp << 21) | (atmp << 16); - pseudo[1].highlow = PAIR; - /* r31,ireg_src2,ireg_dest */ - pseudo[2].opcode = (the_insn.opcode & ~0x0400ffff) | (atmp << 11); - pseudo[2].reloc = NO_RELOC; - no_opcodes = 3; - break; - - default: - abort(); - } - - the_insn = pseudo[0]; - /* check for expanded opcode after branch or in dual */ - if (no_opcodes > 1 && last_expand == 1) - as_warn("Expanded opcode after delayed branch: `%s'", str); - if (no_opcodes > 1 && dual_mode != DUAL_OFF) - as_warn("Expanded opcode in dual mode: `%s'", str); - } - - i = 0; - do { /* always produce at least one opcode */ - toP = frag_more(4); - /* put out the opcode */ - md_number_to_chars(toP, the_insn.opcode, 4); - - /* check for expanded opcode after branch or in dual */ - last_expand = the_insn.pcrel; - - /* put out the symbol-dependent stuff */ - if (the_insn.reloc != NO_RELOC) { - fix_new( - frag_now, /* which frag */ - (toP - frag_now->fr_literal), /* where */ - 4, /* size */ - the_insn.exp.X_add_symbol, - the_insn.exp.X_subtract_symbol, - the_insn.exp.X_add_number, - the_insn.pcrel, - /* merge bit fields into one argument */ - (int)(((the_insn.highlow & 0x3) << 4) | (the_insn.reloc & 0xf)) - ); - } - the_insn = pseudo[++i]; - } while (--no_opcodes > 0); - -} - -static void -i860_ip(str) - char *str; -{ - char *s; - const char *args; - char c; - unsigned long i; - struct i860_opcode *insn; - char *argsStart; - unsigned long opcode; - unsigned int mask; - int match = 0; - int comma = 0; - - - for (s = str; islower(*s) || *s == '.' || *s == '3'; ++s) - ; - switch (*s) { - - case '\0': - break; - - case ',': - comma = 1; - - /*FALLTHROUGH*/ - - case ' ': - *s++ = '\0'; - break; - - default: - as_bad("Unknown opcode: `%s'", str); - exit(1); - } - - if (strncmp(str, "d.", 2) == 0) { /* check for d. opcode prefix */ - if (dual_mode == DUAL_ON) - dual_mode = DUAL_ONDDOT; - else - dual_mode = DUAL_DDOT; - str += 2; - } - - if ((insn = (struct i860_opcode *) hash_find(op_hash, str)) == NULL) { - if (dual_mode == DUAL_DDOT || dual_mode == DUAL_ONDDOT) - str -= 2; - as_bad("Unknown opcode: `%s'", str); - return; - } - if (comma) { - *--s = ','; - } - argsStart = s; - for (;;) { - opcode = insn->match; - bzero(&the_insn, sizeof(the_insn)); - the_insn.reloc = NO_RELOC; - - /* - * Build the opcode, checking as we go to make - * sure that the operands match - */ - for (args = insn->args; ; ++args) { - switch (*args) { - - case '\0': /* end of args */ - if (*s == '\0') { - match = 1; - } - break; - - case '+': - case '(': /* these must match exactly */ - case ')': - case ',': - case ' ': - if (*s++ == *args) - continue; - break; - - case '#': /* must be at least one digit */ - if (isdigit(*s++)) { - while (isdigit(*s)) { - ++s; - } - continue; - } - break; - - case '1': /* next operand must be a register */ - case '2': - case 'd': - switch (*s) { - - case 'f': /* frame pointer */ - s++; - if (*s++ == 'p') { - mask = 0x3; - break; - } - goto error; - - case 's': /* stack pointer */ - s++; - if (*s++ == 'p') { - mask= 0x2; - break; - } - goto error; - - case 'r': /* any register */ - s++; - if (!isdigit(c = *s++)) { - goto error; - } - if (isdigit(*s)) { - if ((c = 10 * (c - '0') + (*s++ - '0')) >= 32) { - goto error; - } - } else { - c -= '0'; - } - mask= c; - break; - - default: /* not this opcode */ - goto error; - } - /* - * Got the register, now figure out where - * it goes in the opcode. - */ - switch (*args) { - - case '1': - opcode |= mask << 11; - continue; - - case '2': - opcode |= mask << 21; - continue; - - case 'd': - opcode |= mask << 16; - continue; - - } - break; - - case 'e': /* next operand is a floating point register */ - case 'f': - case 'g': - if (*s++ == 'f' && isdigit(*s)) { - mask = *s++; - if (isdigit(*s)) { - mask = 10 * (mask - '0') + (*s++ - '0'); - if (mask >= 32) { - break; - } - } else { - mask -= '0'; - } - switch (*args) { - - case 'e': - opcode |= mask << 11; - continue; - - case 'f': - opcode |= mask << 21; - continue; - - case 'g': - opcode |= mask << 16; - if (dual_mode != DUAL_OFF) - opcode |= (1 << 9); /* dual mode instruction */ - if (dual_mode == DUAL_DDOT) - dual_mode = DUAL_OFF; - if (dual_mode == DUAL_ONDDOT) - dual_mode = DUAL_ON; - if ((opcode & (1 << 10)) && (mask == ((opcode >> 11) & 0x1f))) - as_warn("Fsr1 equals fdest with Pipelining"); - continue; - } - } - break; - - case 'c': /* next operand must be a control register */ - if (strncmp(s, "fir", 3) == 0) { - opcode |= 0x0 << 21; - s += 3; - continue; - } - if (strncmp(s, "psr", 3) == 0) { - opcode |= 0x1 << 21; - s += 3; - continue; - } - if (strncmp(s, "dirbase", 7) == 0) { - opcode |= 0x2 << 21; - s += 7; - continue; - } - if (strncmp(s, "db", 2) == 0) { - opcode |= 0x3 << 21; - s += 2; - continue; - } - if (strncmp(s, "fsr", 3) == 0) { - opcode |= 0x4 << 21; - s += 3; - continue; - } - if (strncmp(s, "epsr", 4) == 0) { - opcode |= 0x5 << 21; - s += 4; - continue; - } - break; - - case '5': /* 5 bit immediate in src1 */ - bzero(&the_insn, sizeof(the_insn)); - if ( !getExpression(s)) { - s = expr_end; - if (the_insn.exp.X_add_number & ~0x1f) - as_bad("5-bit immediate too large"); - opcode |= (the_insn.exp.X_add_number & 0x1f) << 11; - bzero(&the_insn, sizeof(the_insn)); - the_insn.reloc = NO_RELOC; - continue; - } - break; - - case 'l': /* 26 bit immediate, relative branch */ - the_insn.reloc = BRADDR; - the_insn.pcrel = 1; - goto immediate; - - case 's': /* 16 bit immediate, split relative branch */ - /* upper 5 bits of offset in dest field */ - the_insn.pcrel = 1; - the_insn.reloc = SPLIT0; - goto immediate; - - case 'S': /* 16 bit immediate, split (st), aligned */ - if (opcode & (1 << 28)) - if (opcode & 0x1) - the_insn.reloc = SPLIT2; - else - the_insn.reloc = SPLIT1; - else - the_insn.reloc = SPLIT0; - goto immediate; - - case 'I': /* 16 bit immediate, aligned */ - if (opcode & (1 << 28)) - if (opcode & 0x1) - the_insn.reloc = LOW2; - else - the_insn.reloc = LOW1; - else - the_insn.reloc = LOW0; - goto immediate; - - case 'i': /* 16 bit immediate */ - the_insn.reloc = LOW0; - - /*FALLTHROUGH*/ - - immediate: - if(*s==' ') - s++; - if (strncmp(s, "ha%", 3) == 0) { - the_insn.highlow = HIGHADJ; - s += 3; - } else if (strncmp(s, "h%", 2) == 0) { - the_insn.highlow = HIGH; - s += 2; - } else if (strncmp(s, "l%", 2) == 0) { - the_insn.highlow = PAIR; - s += 2; - } - the_insn.expand = insn->expand; - - /* Note that if the getExpression() fails, we will still have - created U entries in the symbol table for the 'symbols' - in the input string. Try not to create U symbols for - registers, etc. */ - - if ( !getExpression(s)) { - s = expr_end; - continue; - } - break; - - default: - abort(); - } - break; - } - error: - if (match == 0) - { - /* Args don't match. */ - if (&insn[1] - i860_opcodes < NUMOPCODES - && !strcmp(insn->name, insn[1].name)) - { - ++insn; - s = argsStart; - continue; - } - else - { - as_bad("Illegal operands"); - return; - } - } - break; - } - - the_insn.opcode = opcode; - return; -} - -static int -getExpression(str) - char *str; -{ - char *save_in; - segT seg; - - save_in = input_line_pointer; - input_line_pointer = str; - switch (seg = expression(&the_insn.exp)) { - - case SEG_ABSOLUTE: - case SEG_TEXT: - case SEG_DATA: - case SEG_BSS: - case SEG_UNKNOWN: - case SEG_DIFFERENCE: - case SEG_BIG: - case SEG_ABSENT: - break; - - default: - the_insn.error = "bad segment"; - expr_end = input_line_pointer; - input_line_pointer=save_in; - return 1; - } - expr_end = input_line_pointer; - input_line_pointer = save_in; - return 0; -} - - -/* - This is identical to the md_atof in m68k.c. I think this is right, - but I'm not sure. - - Turn a string in input_line_pointer into a floating point constant of type - type, and store the appropriate bytes in *litP. The number of LITTLENUMS - emitted is stored in *sizeP . An error message is returned, or NULL on OK. - */ - -/* Equal to MAX_PRECISION in atof-ieee.c */ -#define MAX_LITTLENUMS 6 - -char * -md_atof(type,litP,sizeP) - char type; - char *litP; - int *sizeP; -{ - int prec; - LITTLENUM_TYPE words[MAX_LITTLENUMS]; - LITTLENUM_TYPE *wordP; - char *t; - char *atof_ieee(); - - switch(type) { - - case 'f': - case 'F': - case 's': - case 'S': - prec = 2; - break; - - case 'd': - case 'D': - case 'r': - case 'R': - prec = 4; - break; - - case 'x': - case 'X': - prec = 6; - break; - - case 'p': - case 'P': - prec = 6; - break; - - default: - *sizeP=0; - return "Bad call to MD_ATOF()"; - } - t=atof_ieee(input_line_pointer,type,words); - if(t) - input_line_pointer=t; - *sizeP=prec * sizeof(LITTLENUM_TYPE); - for(wordP=words;prec--;) { - md_number_to_chars(litP,(long)(*wordP++),sizeof(LITTLENUM_TYPE)); - litP+=sizeof(LITTLENUM_TYPE); - } - return ""; /* Someone should teach Dean about null pointers */ -} - -/* - * Write out big-endian. - */ -void -md_number_to_chars(buf,val,n) - char *buf; - long val; - int n; -{ - switch(n) { - - case 4: - *buf++ = val >> 24; - *buf++ = val >> 16; - case 2: - *buf++ = val >> 8; - case 1: - *buf = val; - break; - - default: - abort(); - } - return; -} - -void md_number_to_imm(buf,val,n, fixP) - char *buf; - long val; - int n; - fixS *fixP; -{ - enum reloc_type reloc = fixP->fx_r_type & 0xf; - enum highlow_type highlow = (fixP->fx_r_type >> 4) & 0x3; - - assert(buf); - assert(n == 4); /* always on i860 */ - - switch(highlow) - { - - case HIGHADJ: /* adjusts the high-order 16-bits */ - if (val & (1 << 15)) - val += (1 << 16); - - /*FALLTHROUGH*/ - - case HIGH: /* selects the high-order 16-bits */ - val >>= 16; - break; - - case PAIR: /* selects the low-order 16-bits */ - val = val & 0xffff; - break; - - default: - break; - } - - switch(reloc) - { - - case BRADDR: /* br,call,bc,bc.t,bnc,bnc.t w/26-bit immediate */ - if (fixP->fx_pcrel != 1) - as_bad("26-bit branch w/o pc relative set: 0x%08x", val); - val >>= 2; /* align pcrel offset, see manual */ - - if (val >= (1 << 25) || val < -(1 << 25)) /* check for overflow */ - as_bad("26-bit branch offset overflow: 0x%08x", val); - buf[0] = (buf[0] & 0xfc) | ((val >> 24) & 0x3); - buf[1] = val >> 16; - buf[2] = val >> 8; - buf[3] = val; - break; - - case SPLIT2: /* 16 bit immediate, 4-byte aligned */ - if (val & 0x3) - as_bad("16-bit immediate 4-byte alignment error: 0x%08x", val); - val &= ~0x3; /* 4-byte align value */ - /*FALLTHROUGH*/ - case SPLIT1: /* 16 bit immediate, 2-byte aligned */ - if (val & 0x1) - as_bad("16-bit immediate 2-byte alignment error: 0x%08x", val); - val &= ~0x1; /* 2-byte align value */ - /*FALLTHROUGH*/ - case SPLIT0: /* st,bla,bte,btne w/16-bit immediate */ - if (fixP->fx_pcrel == 1) - val >>= 2; /* align pcrel offset, see manual */ - /* check for bounds */ - if (highlow != PAIR && (val >= (1 << 16) || val < -(1 << 15))) - as_bad("16-bit branch offset overflow: 0x%08x", val); - buf[1] = (buf[1] & ~0x1f) | ((val >> 11) & 0x1f); - buf[2] = (buf[2] & ~0x7) | ((val >> 8) & 0x7); - buf[3] |= val; /* perserve bottom opcode bits */ - break; - - case LOW4: /* fld,pfld,pst,flush 16-byte aligned */ - if (val & 0xf) - as_bad("16-bit immediate 16-byte alignment error: 0x%08x", val); - val &= ~0xf; /* 16-byte align value */ - /*FALLTHROUGH*/ - case LOW3: /* fld,pfld,pst,flush 8-byte aligned */ - if (val & 0x7) - as_bad("16-bit immediate 8-byte alignment error: 0x%08x", val); - val &= ~0x7; /* 8-byte align value */ - /*FALLTHROUGH*/ - case LOW2: /* 16 bit immediate, 4-byte aligned */ - if (val & 0x3) - as_bad("16-bit immediate 4-byte alignment error: 0x%08x", val); - val &= ~0x3; /* 4-byte align value */ - /*FALLTHROUGH*/ - case LOW1: /* 16 bit immediate, 2-byte aligned */ - if (val & 0x1) - as_bad("16-bit immediate 2-byte alignment error: 0x%08x", val); - val &= ~0x1; /* 2-byte align value */ - /*FALLTHROUGH*/ - case LOW0: /* 16 bit immediate, byte aligned */ - /* check for bounds */ - if (highlow != PAIR && (val >= (1 << 16) || val < -(1 << 15))) - as_bad("16-bit immediate overflow: 0x%08x", val); - buf[2] = val >> 8; - buf[3] |= val; /* perserve bottom opcode bits */ - break; - - case NO_RELOC: - default: - as_bad("bad relocation type: 0x%02x", reloc); - break; - } - return; -} - -/* should never be called for i860 */ -void -md_create_short_jump(ptr, from_addr, to_addr, frag, to_symbol) - char *ptr; - long from_addr, to_addr; -fragS *frag; -symbolS *to_symbol; -{ - fprintf(stderr, "i860_create_short_jmp\n"); - abort(); -} - -/* should never be called for i860 */ -void -md_number_to_disp(buf,val,n) - char *buf; - long val; -{ - fprintf(stderr, "md_number_to_disp\n"); - abort(); -} - -/* should never be called for i860 */ -void -md_number_to_field(buf,val,fix) - char *buf; - long val; - void *fix; -{ - fprintf(stderr, "i860_number_to_field\n"); - abort(); -} - -/* the bit-field entries in the relocation_info struct plays hell - with the byte-order problems of cross-assembly. So as a hack, - I added this mach. dependent ri twiddler. Ugly, but it gets - you there. -KWK */ -/* on i860: first 4 bytes are normal unsigned long address, next three - bytes are index, most sig. byte first. Byte 7 is broken up with - bit 7 as pcrel, bit 6 as extern, and the lower six bits as - relocation type (highlow 5-4). Next 4 bytes are long addend. */ -/* Thanx and a tip of the hat to Michael Bloom, mb@ttidca.tti.com */ -void -md_ri_to_chars(ri_p, ri) - struct relocation_info *ri_p, ri; -{ -#if 0 - unsigned char the_bytes[sizeof(*ri_p)]; - - /* this is easy */ - md_number_to_chars(the_bytes, ri.r_address, sizeof(ri.r_address)); - /* now the fun stuff */ - the_bytes[4] = (ri.r_index >> 16) & 0x0ff; - the_bytes[5] = (ri.r_index >> 8) & 0x0ff; - the_bytes[6] = ri.r_index & 0x0ff; - the_bytes[7] = ((ri.r_extern << 7) & 0x80) | (0 & 0x60) | (ri.r_type & 0x1F); - /* Also easy */ - md_number_to_chars(&the_bytes[8], ri.r_addend, sizeof(ri.r_addend)); - /* now put it back where you found it, Junior... */ - bcopy (the_bytes, (char *)ri_p, sizeof(*ri_p)); -#endif -} - -/* should never be called for i860 */ -void -md_convert_frag(fragP) - register fragS *fragP; -{ - fprintf(stderr, "i860_convert_frag\n"); - abort(); -} - -/* should never be called for i860 */ -void -md_create_long_jump(ptr, from_addr, to_addr, frag, to_symbol) - char *ptr; - long from_addr, - to_addr; - fragS *frag; - symbolS *to_symbol; -{ - fprintf(stderr, "i860_create_long_jump\n"); - abort(); -} - -/* should never be called for i860 */ -int -md_estimate_size_before_relax(fragP, segtype) - register fragS *fragP; -segT segtype; -{ - fprintf(stderr, "i860_estimate_size_before_relax\n"); - abort(); - return 0; -} - -/* for debugging only, must match enum reloc_type */ -static char *Reloc[] = { - "NO_RELOC", - "BRADDR", - "LOW0", - "LOW1", - "LOW2", - "LOW3", - "LOW4", - "SPLIT0", - "SPLIT1", - "SPLIT2", - "RELOC_32", -}; -static char *Highlow[] = { - "NO_SPEC", - "PAIR", - "HIGH", - "HIGHADJ", -}; -static void -print_insn(insn) - struct i860_it *insn; -{ - if (insn->error) { - fprintf(stderr, "ERROR: %s\n"); - } - fprintf(stderr, "opcode=0x%08x\t", insn->opcode); - fprintf(stderr, "expand=0x%08x\t", insn->expand); - fprintf(stderr, "reloc = %s\t", Reloc[insn->reloc]); - fprintf(stderr, "highlow = %s\n", Highlow[insn->highlow]); - fprintf(stderr, "exp = {\n"); - fprintf(stderr, "\t\tX_add_symbol = %s\n", - insn->exp.X_add_symbol ? - (S_GET_NAME(insn->exp.X_add_symbol) ? - S_GET_NAME(insn->exp.X_add_symbol) : "???") : "0"); - fprintf(stderr, "\t\tX_sub_symbol = %s\n", - insn->exp.X_subtract_symbol ? - (S_GET_NAME(insn->exp.X_subtract_symbol) ? - S_GET_NAME(insn->exp.X_subtract_symbol) : "???") : "0"); - fprintf(stderr, "\t\tX_add_number = %d\n", - insn->exp.X_add_number); - fprintf(stderr, "}\n"); - return; -} - -int -md_parse_option(argP,cntP,vecP) - char **argP; - int *cntP; - char ***vecP; -{ - return 1; -} - -/* - * I860 relocations are completely different, so it needs - * this machine dependent routine to emit them. - */ -void -emit_machine_reloc(fixP, segment_address_in_file) - register fixS *fixP; - relax_addressT segment_address_in_file; -{ - struct reloc_info_i860 ri; - register symbolS *symbolP; - extern char *next_object_file_charP; - long add_number; - - bzero((char *) &ri, sizeof(ri)); - for (; fixP; fixP = fixP->fx_next) { - - if (fixP->fx_r_type & ~0x3f) { - fprintf(stderr, "fixP->fx_r_type = %d\n", fixP->fx_r_type); - abort(); - } - ri.r_pcrel = fixP->fx_pcrel; - ri.r_type = fixP->fx_r_type; - - if ((symbolP = fixP->fx_addsy) != NULL) { - ri.r_address = fixP->fx_frag->fr_address + - fixP->fx_where - segment_address_in_file; - if ((symbolP->sy_type & N_TYPE) == N_UNDF) { - ri.r_extern = 1; - ri.r_symbolnum = symbolP->sy_number; - } else { - ri.r_extern = 0; - ri.r_symbolnum = symbolP->sy_type & N_TYPE; - } - if (symbolP && symbolP->sy_frag) { - ri.r_addend = symbolP->sy_frag->fr_address; - } - ri.r_type = fixP->fx_r_type; - if (fixP->fx_pcrel) { - /* preserve actual offset vs. pc + 4 */ - ri.r_addend -= (ri.r_address + 4); - } else { - ri.r_addend = fixP->fx_addnumber; - } - - md_ri_to_chars((char *) &ri, ri); - append(&next_object_file_charP, (char *)& ri, sizeof(ri)); - } - } - return; -} - -/* Parse an operand that is machine-specific. - We just return without modifying the expression if we have nothing - to do. */ - -/* ARGSUSED */ -void -md_operand (expressionP) - expressionS *expressionP; -{ -} - -/* We have no need to default values of symbols. */ - -/* ARGSUSED */ -symbolS * -md_undefined_symbol (name) - char *name; -{ - return 0; -} - -/* Round up a section size to the appropriate boundary. */ -long -md_section_align (segment, size) - segT segment; - long size; -{ - return size; /* Byte alignment is fine */ -} - -/* Exactly what point is a PC-relative offset relative TO? - On the i860, they're relative to the address of the offset, plus - its size. (??? Is this right? FIXME-SOON!) */ -long -md_pcrel_from (fixP) - fixS *fixP; -{ - return fixP->fx_size + fixP->fx_where + fixP->fx_frag->fr_address; -} - -void -md_apply_fix(fixP, val) - fixS *fixP; - long val; -{ - char *place = fixP->fx_where + fixP->fx_frag->fr_literal; - - if (!fixP->fx_bit_fixP) { - - switch (fixP->fx_im_disp) { - case 0: - fixP->fx_addnumber = val; - md_number_to_imm(place, val, fixP->fx_size, fixP); - break; - case 1: - md_number_to_disp (place, - fixP->fx_pcrel ? val+fixP->fx_pcrel_adjust:val, - fixP->fx_size); - break; - case 2: /* fix requested for .long .word etc */ - md_number_to_chars (place, val, fixP->fx_size); - break; - default: - as_fatal("Internal error in md_apply_fix() in file \"%s\"", __FILE__); - } /* OVE: maybe one ought to put _imm _disp _chars in one md-func */ - } else { - md_number_to_field (place, val, fixP->fx_bit_fixP); - } - - return; -} /* md_apply_fix() */ - -/* - * $Log$ - * Revision 1.1 1991/04/04 18:16:48 rich - * Initial revision - * - * Revision 1.2 1991/03/30 17:11:32 rich - * Updated md_create_short_jump calling protocol. - * - * - */ - -/* - * Local Variables: - * fill-column: 131 - * comment-column: 0 - */ - -/* end of i860.c */ diff --git a/gas/config/tc-i860.h b/gas/config/tc-i860.h deleted file mode 100644 index 2fc651432ca..00000000000 --- a/gas/config/tc-i860.h +++ /dev/null @@ -1,14 +0,0 @@ -/* - * This file is tc-i860.h. - */ - -#define TC_I860 1 - -/* - * Local Variables: - * comment-column: 0 - * fill-column: 131 - * End: - */ - -/* end of tc-i860.h */ diff --git a/gas/config/tc-i960.c b/gas/config/tc-i960.c deleted file mode 100644 index a5513762cec..00000000000 --- a/gas/config/tc-i960.c +++ /dev/null @@ -1,2761 +0,0 @@ -/* i960.c - All the i80960-specific stuff - Copyright (C) 1989, 1990, 1991 Free Software Foundation, Inc. - -This file is part of GAS. - -GAS 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. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* $Id$ */ - -/* See comment on md_parse_option for 80960-specific invocation options. */ - -/****************************************************************************** - * i80690 NOTE!!!: - * Header, symbol, and relocation info will be used on the host machine - * only -- only executable code is actually downloaded to the i80960. - * Therefore, leave all such information in host byte order. - * - * (That's a slight lie -- we DO download some header information, but - * the downloader converts the file format and corrects the byte-ordering - * of the relevant fields while doing so.) - * - ***************************************************************************** */ - -/* There are 4 different lengths of (potentially) symbol-based displacements - * in the 80960 instruction set, each of which could require address fix-ups - * and (in the case of external symbols) emission of relocation directives: - * - * 32-bit (MEMB) - * This is a standard length for the base assembler and requires no - * special action. - * - * 13-bit (COBR) - * This is a non-standard length, but the base assembler has a hook for - * bit field address fixups: the fixS structure can point to a descriptor - * of the field, in which case our md_number_to_field() routine gets called - * to process it. - * - * I made the hook a little cleaner by having fix_new() (in the base - * assembler) return a pointer to the fixS in question. And I made it a - * little simpler by storing the field size (in this case 13) instead of - * of a pointer to another structure: 80960 displacements are ALWAYS - * stored in the low-order bits of a 4-byte word. - * - * Since the target of a COBR cannot be external, no relocation directives - * for this size displacement have to be generated. But the base assembler - * had to be modified to issue error messages if the symbol did turn out - * to be external. - * - * 24-bit (CTRL) - * Fixups are handled as for the 13-bit case (except that 24 is stored - * in the fixS). - * - * The relocation directive generated is the same as that for the 32-bit - * displacement, except that it's PC-relative (the 32-bit displacement - * never is). The i80960 version of the linker needs a mod to - * distinguish and handle the 24-bit case. - * - * 12-bit (MEMA) - * MEMA formats are always promoted to MEMB (32-bit) if the displacement - * is based on a symbol, because it could be relocated at link time. - * The only time we use the 12-bit format is if an absolute value of - * less than 4096 is specified, in which case we need neither a fixup nor - * a relocation directive. - */ - -#include -#include - -#include "as.h" - -#include "obstack.h" - -#include "i960-opcode.h" - -extern char *input_line_pointer; -extern struct hash_control *po_hash; -extern char *next_object_file_charP; - -#ifdef OBJ_COFF -int md_reloc_size = sizeof(struct reloc); -#else /* OBJ_COFF */ -int md_reloc_size = sizeof(struct relocation_info); -#endif /* OBJ_COFF */ - - /*************************** - * Local i80960 routines * - ************************** */ - -static void brcnt_emit(); /* Emit branch-prediction instrumentation code */ -static char * brlab_next(); /* Return next branch local label */ - void brtab_emit(); /* Emit br-predict instrumentation table */ -static void cobr_fmt(); /* Generate COBR instruction */ -static void ctrl_fmt(); /* Generate CTRL instruction */ -static char * emit(); /* Emit (internally) binary */ -static int get_args(); /* Break arguments out of comma-separated list */ -static void get_cdisp(); /* Handle COBR or CTRL displacement */ -static char * get_ispec(); /* Find index specification string */ -static int get_regnum(); /* Translate text to register number */ -static int i_scan(); /* Lexical scan of instruction source */ -static void mem_fmt(); /* Generate MEMA or MEMB instruction */ -static void mema_to_memb(); /* Convert MEMA instruction to MEMB format */ -static segT parse_expr(); /* Parse an expression */ -static int parse_ldconst();/* Parse and replace a 'ldconst' pseudo-op */ -static void parse_memop(); /* Parse a memory operand */ -static void parse_po(); /* Parse machine-dependent pseudo-op */ -static void parse_regop(); /* Parse a register operand */ -static void reg_fmt(); /* Generate a REG format instruction */ - void reloc_callj(); /* Relocate a 'callj' instruction */ -static void relax_cobr(); /* "De-optimize" cobr into compare/branch */ -static void s_leafproc(); /* Process '.leafproc' pseudo-op */ -static void s_sysproc(); /* Process '.sysproc' pseudo-op */ -static int shift_ok(); /* Will a 'shlo' substiture for a 'ldconst'? */ -static void syntax(); /* Give syntax error */ -static int targ_has_sfr(); /* Target chip supports spec-func register? */ -static int targ_has_iclass();/* Target chip supports instruction set? */ -/* static void unlink_sym(); */ /* Remove a symbol from the symbol list */ - -/* See md_parse_option() for meanings of these options */ -static char norelax = 0; /* True if -norelax switch seen */ -static char instrument_branches = 0; /* True if -b switch seen */ - -/* Characters that always start a comment. - * If the pre-processor is disabled, these aren't very useful. - */ -char comment_chars[] = "#"; - -/* Characters that only start a comment at the beginning of - * a line. If the line seems to have the form '# 123 filename' - * .line and .file directives will appear in the pre-processed output. - * - * Note that input_file.c hand checks for '#' at the beginning of the - * first line of the input file. This is because the compiler outputs - * #NO_APP at the beginning of its output. - */ - -/* Also note that comments started like this one will always work. */ - -char line_comment_chars[] = ""; - -/* Chars that can be used to separate mant from exp in floating point nums */ -char EXP_CHARS[] = "eE"; - -/* Chars that mean this number is a floating point constant, - * as in 0f12.456 or 0d1.2345e12 - */ -char FLT_CHARS[] = "fFdDtT"; - - -/* Table used by base assembler to relax addresses based on varying length - * instructions. The fields are: - * 1) most positive reach of this state, - * 2) most negative reach of this state, - * 3) how many bytes this mode will add to the size of the current frag - * 4) which index into the table to try if we can't fit into this one. - * - * For i80960, the only application is the (de-)optimization of cobr - * instructions into separate compare and branch instructions when a 13-bit - * displacement won't hack it. - */ -const relax_typeS -md_relax_table[] = { - {0, 0, 0,0}, /* State 0 => no more relaxation possible */ - {4088, -4096, 0,2}, /* State 1: conditional branch (cobr) */ - {0x800000-8,-0x800000,4,0}, /* State 2: compare (reg) & branch (ctrl) */ -}; - - -/* These are the machine dependent pseudo-ops. - * - * This table describes all the machine specific pseudo-ops the assembler - * has to support. The fields are: - * pseudo-op name without dot - * function to call to execute this pseudo-op - * integer arg to pass to the function - */ -#define S_LEAFPROC 1 -#define S_SYSPROC 2 - -const pseudo_typeS -md_pseudo_table[] = { - - { "bss", s_lcomm, 1 }, - { "extended", float_cons, 't' }, - { "leafproc", parse_po, S_LEAFPROC }, - { "sysproc", parse_po, S_SYSPROC }, - - { "word", cons, 4 }, - { "quad", big_cons, 16 }, - - { 0, 0, 0 } -}; - -/* Macros to extract info from an 'expressionS' structure 'e' */ -#define adds(e) e.X_add_symbol -#define subs(e) e.X_subtract_symbol -#define offs(e) e.X_add_number -#define segs(e) e.X_seg - - -/* Branch-prediction bits for CTRL/COBR format opcodes */ -#define BP_MASK 0x00000002 /* Mask for branch-prediction bit */ -#define BP_TAKEN 0x00000000 /* Value to OR in to predict branch */ -#define BP_NOT_TAKEN 0x00000002 /* Value to OR in to predict no branch */ - - -/* Some instruction opcodes that we need explicitly */ -#define BE 0x12000000 -#define BG 0x11000000 -#define BGE 0x13000000 -#define BL 0x14000000 -#define BLE 0x16000000 -#define BNE 0x15000000 -#define BNO 0x10000000 -#define BO 0x17000000 -#define CHKBIT 0x5a002700 -#define CMPI 0x5a002080 -#define CMPO 0x5a002000 - -#define B 0x08000000 -#define BAL 0x0b000000 -#define CALL 0x09000000 -#define CALLS 0x66003800 -#define RET 0x0a000000 - - -/* These masks are used to build up a set of MEMB mode bits. */ -#define A_BIT 0x0400 -#define I_BIT 0x0800 -#define MEMB_BIT 0x1000 -#define D_BIT 0x2000 - - -/* Mask for the only mode bit in a MEMA instruction (if set, abase reg is used) */ -#define MEMA_ABASE 0x2000 - -/* Info from which a MEMA or MEMB format instruction can be generated */ -typedef struct { - long opcode; /* (First) 32 bits of instruction */ - int disp; /* 0-(none), 12- or, 32-bit displacement needed */ - char *e; /* The expression in the source instruction from - * which the displacement should be determined - */ -} memS; - - -/* The two pieces of info we need to generate a register operand */ -struct regop { - int mode; /* 0 =>local/global/spec reg; 1=> literal or fp reg */ - int special; /* 0 =>not a sfr; 1=> is a sfr (not valid w/mode=0) */ - int n; /* Register number or literal value */ -}; - - -/* Number and assembler mnemonic for all registers that can appear in operands */ -static struct { - char *reg_name; - int reg_num; -} regnames[] = { - { "pfp", 0 }, { "sp", 1 }, { "rip", 2 }, { "r3", 3 }, - { "r4", 4 }, { "r5", 5 }, { "r6", 6 }, { "r7", 7 }, - { "r8", 8 }, { "r9", 9 }, { "r10", 10 }, { "r11", 11 }, - { "r12", 12 }, { "r13", 13 }, { "r14", 14 }, { "r15", 15 }, - { "g0", 16 }, { "g1", 17 }, { "g2", 18 }, { "g3", 19 }, - { "g4", 20 }, { "g5", 21 }, { "g6", 22 }, { "g7", 23 }, - { "g8", 24 }, { "g9", 25 }, { "g10", 26 }, { "g11", 27 }, - { "g12", 28 }, { "g13", 29 }, { "g14", 30 }, { "fp", 31 }, - - /* Numbers for special-function registers are for assembler internal - * use only: they are scaled back to range [0-31] for binary output. - */ -# define SF0 32 - - { "sf0", 32 }, { "sf1", 33 }, { "sf2", 34 }, { "sf3", 35 }, - { "sf4", 36 }, { "sf5", 37 }, { "sf6", 38 }, { "sf7", 39 }, - { "sf8", 40 }, { "sf9", 41 }, { "sf10",42 }, { "sf11",43 }, - { "sf12",44 }, { "sf13",45 }, { "sf14",46 }, { "sf15",47 }, - { "sf16",48 }, { "sf17",49 }, { "sf18",50 }, { "sf19",51 }, - { "sf20",52 }, { "sf21",53 }, { "sf22",54 }, { "sf23",55 }, - { "sf24",56 }, { "sf25",57 }, { "sf26",58 }, { "sf27",59 }, - { "sf28",60 }, { "sf29",61 }, { "sf30",62 }, { "sf31",63 }, - - /* Numbers for floating point registers are for assembler internal use - * only: they are scaled back to [0-3] for binary output. - */ -# define FP0 64 - - { "fp0", 64 }, { "fp1", 65 }, { "fp2", 66 }, { "fp3", 67 }, - - { NULL, 0 }, /* END OF LIST */ -}; - -#define IS_RG_REG(n) ((0 <= (n)) && ((n) < SF0)) -#define IS_SF_REG(n) ((SF0 <= (n)) && ((n) < FP0)) -#define IS_FP_REG(n) ((n) >= FP0) - -/* Number and assembler mnemonic for all registers that can appear as 'abase' - * (indirect addressing) registers. - */ -static struct { - char *areg_name; - int areg_num; -} aregs[] = { - { "(pfp)", 0 }, { "(sp)", 1 }, { "(rip)", 2 }, { "(r3)", 3 }, - { "(r4)", 4 }, { "(r5)", 5 }, { "(r6)", 6 }, { "(r7)", 7 }, - { "(r8)", 8 }, { "(r9)", 9 }, { "(r10)", 10 }, { "(r11)", 11 }, - { "(r12)", 12 }, { "(r13)", 13 }, { "(r14)", 14 }, { "(r15)", 15 }, - { "(g0)", 16 }, { "(g1)", 17 }, { "(g2)", 18 }, { "(g3)", 19 }, - { "(g4)", 20 }, { "(g5)", 21 }, { "(g6)", 22 }, { "(g7)", 23 }, - { "(g8)", 24 }, { "(g9)", 25 }, { "(g10)", 26 }, { "(g11)", 27 }, - { "(g12)", 28 }, { "(g13)", 29 }, { "(g14)", 30 }, { "(fp)", 31 }, - -# define IPREL 32 - /* for assembler internal use only: this number never appears in binary - * output. - */ - { "(ip)", IPREL }, - - { NULL, 0 }, /* END OF LIST */ -}; - - -/* Hash tables */ -static struct hash_control *op_hash = NULL; /* Opcode mnemonics */ -static struct hash_control *reg_hash = NULL; /* Register name hash table */ -static struct hash_control *areg_hash = NULL; /* Abase register hash table */ - - -/* Architecture for which we are assembling */ -#define ARCH_ANY 0 /* Default: no architecture checking done */ -#define ARCH_KA 1 -#define ARCH_KB 2 -#define ARCH_MC 3 -#define ARCH_CA 4 -int architecture = ARCH_ANY; /* Architecture requested on invocation line */ -int iclasses_seen = 0; /* OR of instruction classes (I_* constants) - * for which we've actually assembled - * instructions. - */ - - -/* BRANCH-PREDICTION INSTRUMENTATION - * - * The following supports generation of branch-prediction instrumentation - * (turned on by -b switch). The instrumentation collects counts - * of branches taken/not-taken for later input to a utility that will - * set the branch prediction bits of the instructions in accordance with - * the behavior observed. (Note that the KX series does not have - * brach-prediction.) - * - * The instrumentation consists of: - * - * (1) before and after each conditional branch, a call to an external - * routine that increments and steps over an inline counter. The - * counter itself, initialized to 0, immediately follows the call - * instruction. For each branch, the counter following the branch - * is the number of times the branch was not taken, and the difference - * between the counters is the number of times it was taken. An - * example of an instrumented conditional branch: - * - * call BR_CNT_FUNC - * .word 0 - * LBRANCH23: be label - * call BR_CNT_FUNC - * .word 0 - * - * (2) a table of pointers to the instrumented branches, so that an - * external postprocessing routine can locate all of the counters. - * the table begins with a 2-word header: a pointer to the next in - * a linked list of such tables (initialized to 0); and a count - * of the number of entries in the table (exclusive of the header. - * - * Note that input source code is expected to already contain calls - * an external routine that will link the branch local table into a - * list of such tables. - */ - -static int br_cnt = 0; /* Number of branches instrumented so far. - * Also used to generate unique local labels - * for each instrumented branch - */ - -#define BR_LABEL_BASE "LBRANCH" - /* Basename of local labels on instrumented - * branches, to avoid conflict with compiler- - * generated local labels. - */ - -#define BR_CNT_FUNC "__inc_branch" - /* Name of the external routine that will - * increment (and step over) an inline counter. - */ - -#define BR_TAB_NAME "__BRANCH_TABLE__" - /* Name of the table of pointers to branches. - * A local (i.e., non-external) symbol. - */ - -/***************************************************************************** - * md_begin: One-time initialization. - * - * Set up hash tables. - * - **************************************************************************** */ -void -md_begin() -{ - int i; /* Loop counter */ - const struct i960_opcode *oP; /* Pointer into opcode table */ - char *retval; /* Value returned by hash functions */ - - if (((op_hash = hash_new()) == 0) - || ((reg_hash = hash_new()) == 0) - || ((areg_hash = hash_new()) == 0)) { - as_fatal("virtual memory exceeded"); - } - - retval = ""; /* For some reason, the base assembler uses an empty - * string for "no error message", instead of a NULL - * pointer. - */ - - for (oP=i960_opcodes; oP->name && !*retval; oP++) { - retval = hash_insert(op_hash, oP->name, oP); - } - - for (i=0; regnames[i].reg_name && !*retval; i++) { - retval = hash_insert(reg_hash, regnames[i].reg_name, - ®names[i].reg_num); - } - - for (i=0; aregs[i].areg_name && !*retval; i++){ - retval = hash_insert(areg_hash, aregs[i].areg_name, - &aregs[i].areg_num); - } - - if (*retval) { - as_fatal("Hashing returned \"%s\".", retval); - } -} /* md_begin() */ - -/***************************************************************************** - * md_end: One-time final cleanup - * - * None necessary - * - **************************************************************************** */ -void -md_end() -{ -} - -/***************************************************************************** - * md_assemble: Assemble an instruction - * - * Assumptions about the passed-in text: - * - all comments, labels removed - * - text is an instruction - * - all white space compressed to single blanks - * - all character constants have been replaced with decimal - * - **************************************************************************** */ -void -md_assemble(textP) - char *textP; /* Source text of instruction */ -{ - char *args[4]; /* Parsed instruction text, containing NO whitespace: - * arg[0]->opcode mnemonic - * arg[1-3]->operands, with char constants - * replaced by decimal numbers - */ - int n_ops; /* Number of instruction operands */ - - struct i960_opcode *oP; - /* Pointer to instruction description */ - int branch_predict; - /* TRUE iff opcode mnemonic included branch-prediction - * suffix (".f" or ".t") - */ - long bp_bits; /* Setting of branch-prediction bit(s) to be OR'd - * into instruction opcode of CTRL/COBR format - * instructions. - */ - int n; /* Offset of last character in opcode mnemonic */ - - static const char bp_error_msg[] = "branch prediction invalid on this opcode"; - - - /* Parse instruction into opcode and operands */ - bzero(args, sizeof(args)); - n_ops = i_scan(textP, args); - if (n_ops == -1){ - return; /* Error message already issued */ - } - - /* Do "macro substitution" (sort of) on 'ldconst' pseudo-instruction */ - if (!strcmp(args[0],"ldconst")){ - n_ops = parse_ldconst(args); - if (n_ops == -1){ - return; - } - } - - /* Check for branch-prediction suffix on opcode mnemonic, strip it off */ - n = strlen(args[0]) - 1; - branch_predict = 0; - bp_bits = 0; - if (args[0][n-1] == '.' && (args[0][n] == 't' || args[0][n] == 'f')){ - /* We could check here to see if the target architecture - * supports branch prediction, but why bother? The bit - * will just be ignored by processors that don't use it. - */ - branch_predict = 1; - bp_bits = (args[0][n] == 't') ? BP_TAKEN : BP_NOT_TAKEN; - args[0][n-1] = '\0'; /* Strip suffix from opcode mnemonic */ - } - - /* Look up opcode mnemonic in table and check number of operands. - * Check that opcode is legal for the target architecture. - * If all looks good, assemble instruction. - */ - oP = (struct i960_opcode *) hash_find(op_hash, args[0]); - if (!oP || !targ_has_iclass(oP->iclass)) { - as_bad("invalid opcode, \"%s\".", args[0]); - - } else if (n_ops != oP->num_ops) { - as_bad("improper number of operands. expecting %d, got %d", oP->num_ops, n_ops); - - } else { - switch (oP->format){ - case FBRA: - case CTRL: - ctrl_fmt(args[1], oP->opcode | bp_bits, oP->num_ops); - if (oP->format == FBRA){ - /* Now generate a 'bno' to same arg */ - ctrl_fmt(args[1], BNO | bp_bits, 1); - } - break; - case COBR: - case COJ: - cobr_fmt(args, oP->opcode | bp_bits, oP); - break; - case REG: - if (branch_predict){ - as_warn(bp_error_msg); - } - reg_fmt(args, oP); - break; - case MEM1: - case MEM2: - case MEM4: - case MEM8: - case MEM12: - case MEM16: - if (branch_predict){ - as_warn(bp_error_msg); - } - mem_fmt(args, oP); - break; - case CALLJ: - if (branch_predict){ - as_warn(bp_error_msg); - } - /* Output opcode & set up "fixup" (relocation); - * flag relocation as 'callj' type. - */ - know(oP->num_ops == 1); - get_cdisp(args[1], "CTRL", oP->opcode, 24, 0, 1); - break; - default: - BAD_CASE(oP->format); - break; - } - } -} /* md_assemble() */ - -/***************************************************************************** - * md_number_to_chars: convert a number to target byte order - * - **************************************************************************** */ -void -md_number_to_chars(buf, value, n) - char *buf; /* Put output here */ - long value; /* The integer to be converted */ - int n; /* Number of bytes to output (significant bytes - * in 'value') - */ -{ - while (n--){ - *buf++ = value; - value >>= 8; - } - - /* XXX line number probably botched for this warning message. */ - if (value != 0 && value != -1){ - as_bad("Displacement too long for instruction field length."); - } - - return; -} /* md_number_to_chars() */ - -/***************************************************************************** - * md_chars_to_number: convert from target byte order to host byte order. - * - **************************************************************************** */ -int -md_chars_to_number(val, n) - unsigned char *val; /* Value in target byte order */ - int n; /* Number of bytes in the input */ -{ - int retval; - - for (retval=0; n--;){ - retval <<= 8; - retval |= val[n]; - } - return retval; -} - - -#define MAX_LITTLENUMS 6 -#define LNUM_SIZE sizeof(LITTLENUM_TYPE) - -/***************************************************************************** - * md_atof: convert ascii to floating point - * - * Turn a string at input_line_pointer into a floating point constant of type - * 'type', and store the appropriate bytes at *litP. The number of LITTLENUMS - * emitted is returned at 'sizeP'. An error message is returned, or a pointer - * to an empty message if OK. - * - * Note we call the i386 floating point routine, rather than complicating - * things with more files or symbolic links. - * - **************************************************************************** */ -char * md_atof(type, litP, sizeP) -int type; -char *litP; -int *sizeP; -{ - LITTLENUM_TYPE words[MAX_LITTLENUMS]; - LITTLENUM_TYPE *wordP; - int prec; - char *t; - char *atof_ieee(); - - switch(type) { - case 'f': - case 'F': - prec = 2; - break; - - case 'd': - case 'D': - prec = 4; - break; - - case 't': - case 'T': - prec = 5; - type = 'x'; /* That's what atof_ieee() understands */ - break; - - default: - *sizeP=0; - return "Bad call to md_atof()"; - } - - t = atof_ieee(input_line_pointer, type, words); - if (t){ - input_line_pointer = t; - } - - *sizeP = prec * LNUM_SIZE; - - /* Output the LITTLENUMs in REVERSE order in accord with i80960 - * word-order. (Dunno why atof_ieee doesn't do it in the right - * order in the first place -- probably because it's a hack of - * atof_m68k.) - */ - - for(wordP = words + prec - 1; prec--;){ - md_number_to_chars(litP, (long) (*wordP--), LNUM_SIZE); - litP += sizeof(LITTLENUM_TYPE); - } - - return ""; /* Someone should teach Dean about null pointers */ -} - - -/***************************************************************************** - * md_number_to_imm - * - **************************************************************************** */ -void -md_number_to_imm(buf, val, n) - char *buf; - long val; - int n; -{ - md_number_to_chars(buf, val, n); -} - - -/***************************************************************************** - * md_number_to_disp - * - **************************************************************************** */ -void -md_number_to_disp(buf, val, n) - char *buf; - long val; - int n; -{ - md_number_to_chars(buf, val, n); -} - -/***************************************************************************** - * md_number_to_field: - * - * Stick a value (an address fixup) into a bit field of - * previously-generated instruction. - * - **************************************************************************** */ -void -md_number_to_field(instrP, val, bfixP) - char *instrP; /* Pointer to instruction to be fixed */ - long val; /* Address fixup value */ - bit_fixS *bfixP; /* Description of bit field to be fixed up */ -{ - int numbits; /* Length of bit field to be fixed */ - long instr; /* 32-bit instruction to be fixed-up */ - long sign; /* 0 or -1, according to sign bit of 'val' */ - - /* Convert instruction back to host byte order - */ - instr = md_chars_to_number(instrP, 4); - - /* Surprise! -- we stored the number of bits - * to be modified rather than a pointer to a structure. - */ - numbits = (int)bfixP; - if (numbits == 1){ - /* This is a no-op, stuck here by reloc_callj() */ - return; - } - - know ((numbits==13) || (numbits==24)); - - /* Propagate sign bit of 'val' for the given number of bits. - * Result should be all 0 or all 1 - */ - sign = val >> ((int)numbits - 1); - if (((val < 0) && (sign != -1)) - || ((val > 0) && (sign != 0))){ - as_bad("Fixup of %d too large for field width of %d", - val, numbits); - } else { - /* Put bit field into instruction and write back in target - * byte order. - */ - val &= ~(-1 << (int)numbits); /* Clear unused sign bits */ - instr |= val; - md_number_to_chars(instrP, instr, 4); - } -} /* md_number_to_field() */ - - -/***************************************************************************** - * md_parse_option - * Invocation line includes a switch not recognized by the base assembler. - * See if it's a processor-specific option. For the 960, these are: - * - * -norelax: - * Conditional branch instructions that require displacements - * greater than 13 bits (or that have external targets) should - * generate errors. The default is to replace each such - * instruction with the corresponding compare (or chkbit) and - * branch instructions. Note that the Intel "j" cobr directives - * are ALWAYS "de-optimized" in this way when necessary, - * regardless of the setting of this option. - * - * -b: - * Add code to collect information about branches taken, for - * later optimization of branch prediction bits by a separate - * tool. COBR and CNTL format instructions have branch - * prediction bits (in the CX architecture); if "BR" represents - * an instruction in one of these classes, the following rep- - * resents the code generated by the assembler: - * - * call - * .word 0 # pre-counter - * Label: BR - * call - * .word 0 # post-counter - * - * A table of all such "Labels" is also generated. - * - * - * -AKA, -AKB, -AKC, -ASA, -ASB, -AMC, -ACA: - * Select the 80960 architecture. Instructions or features not - * supported by the selected architecture cause fatal errors. - * The default is to generate code for any instruction or feature - * that is supported by SOME version of the 960 (even if this - * means mixing architectures!). - * - **************************************************************************** */ -int -md_parse_option(argP, cntP, vecP) - char **argP; - int *cntP; - char ***vecP; -{ - char *p; - struct tabentry { char *flag; int arch; }; - static struct tabentry arch_tab[] = { - "KA", ARCH_KA, - "KB", ARCH_KB, - "SA", ARCH_KA, /* Synonym for KA */ - "SB", ARCH_KB, /* Synonym for KB */ - "KC", ARCH_MC, /* Synonym for MC */ - "MC", ARCH_MC, - "CA", ARCH_CA, - NULL, 0 - }; - struct tabentry *tp; - - if (!strcmp(*argP,"norelax")){ - norelax = 1; - - } else if (**argP == 'b'){ - instrument_branches = 1; - - } else if (**argP == 'A'){ - p = (*argP) + 1; - - for (tp = arch_tab; tp->flag != NULL; tp++){ - if (!strcmp(p,tp->flag)){ - break; - } - } - - if (tp->flag == NULL){ - as_bad("unknown architecture: %s", p); - } else { - architecture = tp->arch; - } - } else { - /* Unknown option */ - (*argP)++; - return 0; - } - **argP = '\0'; /* Done parsing this switch */ - return 1; -} - -/***************************************************************************** - * md_convert_frag: - * Called by base assembler after address relaxation is finished: modify - * variable fragments according to how much relaxation was done. - * - * If the fragment substate is still 1, a 13-bit displacement was enough - * to reach the symbol in question. Set up an address fixup, but otherwise - * leave the cobr instruction alone. - * - * If the fragment substate is 2, a 13-bit displacement was not enough. - * Replace the cobr with a two instructions (a compare and a branch). - * - **************************************************************************** */ -void -md_convert_frag(headers, fragP) -object_headers *headers; - fragS * fragP; -{ - fixS *fixP; /* Structure describing needed address fix */ - - switch (fragP->fr_subtype){ - case 1: - /* LEAVE SINGLE COBR INSTRUCTION */ - fixP = fix_new(fragP, - fragP->fr_opcode-fragP->fr_literal, - 4, - fragP->fr_symbol, - 0, - fragP->fr_offset, - 1, - 0); - - fixP->fx_bit_fixP = (bit_fixS *) 13; /* size of bit field */ - break; - case 2: - /* REPLACE COBR WITH COMPARE/BRANCH INSTRUCTIONS */ - relax_cobr(fragP); - break; - default: - BAD_CASE(fragP->fr_subtype); - break; - } -} - -/***************************************************************************** - * md_estimate_size_before_relax: How much does it look like *fragP will grow? - * - * Called by base assembler just before address relaxation. - * Return the amount by which the fragment will grow. - * - * Any symbol that is now undefined will not become defined; cobr's - * based on undefined symbols will have to be replaced with a compare - * instruction and a branch instruction, and the code fragment will grow - * by 4 bytes. - * - **************************************************************************** */ -int -md_estimate_size_before_relax(fragP, segment_type) - register fragS *fragP; - register segT segment_type; -{ - /* If symbol is undefined in this segment, go to "relaxed" state - * (compare and branch instructions instead of cobr) right now. - */ - if (S_GET_SEGMENT(fragP->fr_symbol) != segment_type) { - relax_cobr(fragP); - return 4; - } - return 0; -} /* md_estimate_size_before_relax() */ - - -/***************************************************************************** - * md_ri_to_chars: - * This routine exists in order to overcome machine byte-order problems - * when dealing with bit-field entries in the relocation_info struct. - * - * But relocation info will be used on the host machine only (only - * executable code is actually downloaded to the i80960). Therefore, - * we leave it in host byte order. - * - **************************************************************************** */ -void md_ri_to_chars(where, ri) -char *where; -struct relocation_info *ri; -{ - *((struct relocation_info *) where) = *ri; /* structure assignment */ -} /* md_ri_to_chars() */ - -#ifndef WORKING_DOT_WORD - -int md_short_jump_size = 0; -int md_long_jump_size = 0; - -void md_create_short_jump(ptr, from_addr, to_addr, frag, to_symbol) -char *ptr; -long from_addr; -long to_addr; -fragS *frag; -symbolS *to_symbol; -{ - abort(); -} - -void -md_create_long_jump(ptr,from_addr,to_addr,frag,to_symbol) - char *ptr; - long from_addr, to_addr; - fragS *frag; - symbolS *to_symbol; -{ - abort(); -} -#endif - - /************************************************************* - * * - * FOLLOWING ARE THE LOCAL ROUTINES, IN ALPHABETICAL ORDER * - * * - ************************************************************ */ - - - -/***************************************************************************** - * brcnt_emit: Emit code to increment inline branch counter. - * - * See the comments above the declaration of 'br_cnt' for details on - * branch-prediction instrumentation. - **************************************************************************** */ -static void -brcnt_emit() -{ - ctrl_fmt(BR_CNT_FUNC,CALL,1);/* Emit call to "increment" routine */ - emit(0); /* Emit inline counter to be incremented */ -} - -/***************************************************************************** - * brlab_next: generate the next branch local label - * - * See the comments above the declaration of 'br_cnt' for details on - * branch-prediction instrumentation. - **************************************************************************** */ -static char * -brlab_next() -{ - static char buf[20]; - - sprintf(buf, "%s%d", BR_LABEL_BASE, br_cnt++); - return buf; -} - -/***************************************************************************** - * brtab_emit: generate the fetch-prediction branch table. - * - * See the comments above the declaration of 'br_cnt' for details on - * branch-prediction instrumentation. - * - * The code emitted here would be functionally equivalent to the following - * example assembler source. - * - * .data - * .align 2 - * BR_TAB_NAME: - * .word 0 # link to next table - * .word 3 # length of table - * .word LBRANCH0 # 1st entry in table proper - * .word LBRANCH1 - * .word LBRANCH2 - ***************************************************************************** */ -void -brtab_emit() -{ - int i; - char buf[20]; - char *p; /* Where the binary was output to */ - fixS *fixP; /*->description of deferred address fixup */ - - if (!instrument_branches){ - return; - } - - subseg_new(SEG_DATA,0); /* .data */ - frag_align(2,0); /* .align 2 */ - record_alignment(now_seg,2); - colon(BR_TAB_NAME); /* BR_TAB_NAME: */ - emit(0); /* .word 0 #link to next table */ - emit(br_cnt); /* .word n #length of table */ - - for (i=0; ifr_literal, - 4, - symbol_find(buf), - 0, - 0, - 0, - 0); - fixP->fx_im_disp = 2; /* 32-bit displacement fix */ - } -} - -/***************************************************************************** - * cobr_fmt: generate a COBR-format instruction - * - **************************************************************************** */ -static -void -cobr_fmt(arg, opcode, oP) - char *arg[]; /* arg[0]->opcode mnemonic, arg[1-3]->operands (ascii) */ - long opcode; /* Opcode, with branch-prediction bits already set - * if necessary. - */ - struct i960_opcode *oP; - /*->description of instruction */ -{ - long instr; /* 32-bit instruction */ - struct regop regop; /* Description of register operand */ - int n; /* Number of operands */ - int var_frag; /* 1 if varying length code fragment should - * be emitted; 0 if an address fix - * should be emitted. - */ - - instr = opcode; - n = oP->num_ops; - - if (n >= 1) { - /* First operand (if any) of a COBR is always a register - * operand. Parse it. - */ - parse_regop(®op, arg[1], oP->operand[0]); - instr |= (regop.n << 19) | (regop.mode << 13); - } - if (n >= 2) { - /* Second operand (if any) of a COBR is always a register - * operand. Parse it. - */ - parse_regop(®op, arg[2], oP->operand[1]); - instr |= (regop.n << 14) | regop.special; - } - - - if (n < 3){ - emit(instr); - - } else { - if (instrument_branches){ - brcnt_emit(); - colon(brlab_next()); - } - - /* A third operand to a COBR is always a displacement. - * Parse it; if it's relaxable (a cobr "j" directive, or any - * cobr other than bbs/bbc when the "-norelax" option is not in - * use) set up a variable code fragment; otherwise set up an - * address fix. - */ - var_frag = !norelax || (oP->format == COJ); /* TRUE or FALSE */ - get_cdisp(arg[3], "COBR", instr, 13, var_frag, 0); - - if (instrument_branches){ - brcnt_emit(); - } - } -} /* cobr_fmt() */ - - -/***************************************************************************** - * ctrl_fmt: generate a CTRL-format instruction - * - **************************************************************************** */ -static -void -ctrl_fmt(targP, opcode, num_ops) - char *targP; /* Pointer to text of lone operand (if any) */ - long opcode; /* Template of instruction */ - int num_ops; /* Number of operands */ -{ - int instrument; /* TRUE iff we should add instrumentation to track - * how often the branch is taken - */ - - - if (num_ops == 0){ - emit(opcode); /* Output opcode */ - } else { - - instrument = instrument_branches && (opcode!=CALL) - && (opcode!=B) && (opcode!=RET) && (opcode!=BAL); - - if (instrument){ - brcnt_emit(); - colon(brlab_next()); - } - - /* The operand MUST be an ip-relative displacment. Parse it - * and set up address fix for the instruction we just output. - */ - get_cdisp(targP, "CTRL", opcode, 24, 0, 0); - - if (instrument){ - brcnt_emit(); - } - } - -} - - -/***************************************************************************** - * emit: output instruction binary - * - * Output instruction binary, in target byte order, 4 bytes at a time. - * Return pointer to where it was placed. - * - **************************************************************************** */ -static -char * -emit(instr) - long instr; /* Word to be output, host byte order */ -{ - char *toP; /* Where to output it */ - - toP = frag_more(4); /* Allocate storage */ - md_number_to_chars(toP, instr, 4); /* Convert to target byte order */ - return toP; -} - - -/***************************************************************************** - * get_args: break individual arguments out of comma-separated list - * - * Input assumptions: - * - all comments and labels have been removed - * - all strings of whitespace have been collapsed to a single blank. - * - all character constants ('x') have been replaced with decimal - * - * Output: - * args[0] is untouched. args[1] points to first operand, etc. All args: - * - are NULL-terminated - * - contain no whitespace - * - * Return value: - * Number of operands (0,1,2, or 3) or -1 on error. - * - **************************************************************************** */ -static int get_args(p, args) - register char *p; /* Pointer to comma-separated operands; MUCKED BY US */ - char *args[]; /* Output arg: pointers to operands placed in args[1-3]. - * MUST ACCOMMODATE 4 ENTRIES (args[0-3]). - */ -{ - register int n; /* Number of operands */ - register char *to; -/* char buf[4]; */ -/* int len; */ - - - /* Skip lead white space */ - while (*p == ' '){ - p++; - } - - if (*p == '\0'){ - return 0; - } - - n = 1; - args[1] = p; - - /* Squeze blanks out by moving non-blanks toward start of string. - * Isolate operands, whenever comma is found. - */ - to = p; - while (*p != '\0'){ - - if (*p == ' '){ - p++; - - } else if (*p == ','){ - - /* Start of operand */ - if (n == 3){ - as_bad("too many operands"); - return -1; - } - *to++ = '\0'; /* Terminate argument */ - args[++n] = to; /* Start next argument */ - p++; - - } else { - *to++ = *p++; - } - } - *to = '\0'; - return n; -} - - -/***************************************************************************** - * get_cdisp: handle displacement for a COBR or CTRL instruction. - * - * Parse displacement for a COBR or CTRL instruction. - * - * If successful, output the instruction opcode and set up for it, - * depending on the arg 'var_frag', either: - * o an address fixup to be done when all symbol values are known, or - * o a varying length code fragment, with address fixup info. This - * will be done for cobr instructions that may have to be relaxed - * in to compare/branch instructions (8 bytes) if the final address - * displacement is greater than 13 bits. - * - **************************************************************************** */ -static -void -get_cdisp(dispP, ifmtP, instr, numbits, var_frag, callj) - char *dispP; /*->displacement as specified in source instruction */ - char *ifmtP; /*->"COBR" or "CTRL" (for use in error message) */ - long instr; /* Instruction needing the displacement */ - int numbits; /* # bits of displacement (13 for COBR, 24 for CTRL) */ - int var_frag; /* 1 if varying length code fragment should be emitted; - * 0 if an address fix should be emitted. - */ - int callj; /* 1 if callj relocation should be done; else 0 */ -{ - expressionS e; /* Parsed expression */ - fixS *fixP; /* Structure describing needed address fix */ - char *outP; /* Where instruction binary is output to */ - - fixP = NULL; - - switch (parse_expr(dispP,&e)) { - - case SEG_GOOF: - as_bad("expression syntax error"); - break; - - case SEG_TEXT: - case SEG_UNKNOWN: - if (var_frag) { - outP = frag_more(8); /* Allocate worst-case storage */ - md_number_to_chars(outP, instr, 4); - frag_variant(rs_machine_dependent, 4, 4, 1, - adds(e), offs(e), outP, 0, 0); - } else { - /* Set up a new fix structure, so address can be updated - * when all symbol values are known. - */ - outP = emit(instr); - fixP = fix_new(frag_now, - outP - frag_now->fr_literal, - 4, - adds(e), - 0, - offs(e), - 1, - 0); - - fixP->fx_callj = callj; - - /* We want to modify a bit field when the address is - * known. But we don't need all the garbage in the - * bit_fix structure. So we're going to lie and store - * the number of bits affected instead of a pointer. - */ - fixP->fx_bit_fixP = (bit_fixS *) numbits; - } - break; - - case SEG_DATA: - case SEG_BSS: - as_bad("attempt to branch into different segment"); - break; - - default: - as_bad("target of %s instruction must be a label", ifmtP); - break; - } -} - - -/***************************************************************************** - * get_ispec: parse a memory operand for an index specification - * - * Here, an "index specification" is taken to be anything surrounded - * by square brackets and NOT followed by anything else. - * - * If it's found, detach it from the input string, remove the surrounding - * square brackets, and return a pointer to it. Otherwise, return NULL. - * - **************************************************************************** */ -static -char * -get_ispec(textP) - char *textP; /*->memory operand from source instruction, no white space */ -{ - char *start; /*->start of index specification */ - char *end; /*->end of index specification */ - - /* Find opening square bracket, if any - */ - start = strchr(textP, '['); - - if (start != NULL){ - - /* Eliminate '[', detach from rest of operand */ - *start++ = '\0'; - - end = strchr(start, ']'); - - if (end == NULL){ - as_bad("unmatched '['"); - - } else { - /* Eliminate ']' and make sure it was the last thing - * in the string. - */ - *end = '\0'; - if (*(end+1) != '\0'){ - as_bad("garbage after index spec ignored"); - } - } - } - return start; -} - -/***************************************************************************** - * get_regnum: - * - * Look up a (suspected) register name in the register table and return the - * associated register number (or -1 if not found). - * - **************************************************************************** */ -static -int -get_regnum(regname) - char *regname; /* Suspected register name */ -{ - int *rP; - - rP = (int *) hash_find(reg_hash, regname); - return (rP == NULL) ? -1 : *rP; -} - - -/***************************************************************************** - * i_scan: perform lexical scan of ascii assembler instruction. - * - * Input assumptions: - * - input string is an i80960 instruction (not a pseudo-op) - * - all comments and labels have been removed - * - all strings of whitespace have been collapsed to a single blank. - * - * Output: - * args[0] points to opcode, other entries point to operands. All strings: - * - are NULL-terminated - * - contain no whitespace - * - have character constants ('x') replaced with a decimal number - * - * Return value: - * Number of operands (0,1,2, or 3) or -1 on error. - * - **************************************************************************** */ -static int i_scan(iP, args) - register char *iP; /* Pointer to ascii instruction; MUCKED BY US. */ - char *args[]; /* Output arg: pointers to opcode and operands placed - * here. MUST ACCOMMODATE 4 ENTRIES. - */ -{ - - /* Isolate opcode */ - if (*(iP) == ' ') { - iP++; - } /* Skip lead space, if any */ - args[0] = iP; - for (; *iP != ' '; iP++) { - if (*iP == '\0') { - /* There are no operands */ - if (args[0] == iP) { - /* We never moved: there was no opcode either! */ - as_bad("missing opcode"); - return -1; - } - return 0; - } - } - *iP++ = '\0'; /* Terminate opcode */ - return(get_args(iP, args)); -} /* i_scan() */ - - -/***************************************************************************** - * mem_fmt: generate a MEMA- or MEMB-format instruction - * - **************************************************************************** */ -static void mem_fmt(args, oP) - char *args[]; /* args[0]->opcode mnemonic, args[1-3]->operands */ - struct i960_opcode *oP; /* Pointer to description of instruction */ -{ - int i; /* Loop counter */ - struct regop regop; /* Description of register operand */ - char opdesc; /* Operand descriptor byte */ - memS instr; /* Description of binary to be output */ - char *outP; /* Where the binary was output to */ - expressionS expr; /* Parsed expression */ - fixS *fixP; /*->description of deferred address fixup */ - - bzero(&instr, sizeof(memS)); - instr.opcode = oP->opcode; - - /* Process operands. */ - for (i = 1; i <= oP->num_ops; i++){ - opdesc = oP->operand[i-1]; - - if (MEMOP(opdesc)){ - parse_memop(&instr, args[i], oP->format); - } else { - parse_regop(®op, args[i], opdesc); - instr.opcode |= regop.n << 19; - } - } - - /* Output opcode */ - outP = emit(instr.opcode); - - if (instr.disp == 0){ - return; - } - - /* Parse and process the displacement */ - switch (parse_expr(instr.e,&expr)){ - - case SEG_GOOF: - as_bad("expression syntax error"); - break; - - case SEG_ABSOLUTE: - if (instr.disp == 32){ - (void) emit(offs(expr)); /* Output displacement */ - } else { - /* 12-bit displacement */ - if (offs(expr) & ~0xfff){ - /* Won't fit in 12 bits: convert already-output - * instruction to MEMB format, output - * displacement. - */ - mema_to_memb(outP); - (void) emit(offs(expr)); - } else { - /* WILL fit in 12 bits: OR into opcode and - * overwrite the binary we already put out - */ - instr.opcode |= offs(expr); - md_number_to_chars(outP, instr.opcode, 4); - } - } - break; - - case SEG_DIFFERENCE: - case SEG_TEXT: - case SEG_DATA: - case SEG_BSS: - case SEG_UNKNOWN: - if (instr.disp == 12){ - /* Displacement is dependent on a symbol, whose value - * may change at link time. We HAVE to reserve 32 bits. - * Convert already-output opcode to MEMB format. - */ - mema_to_memb(outP); - } - - /* Output 0 displacement and set up address fixup for when - * this symbol's value becomes known. - */ - outP = emit((long) 0); - fixP = fix_new(frag_now, - outP - frag_now->fr_literal, - 4, - adds(expr), - subs(expr), - offs(expr), - 0, - 0); - fixP->fx_im_disp = 2; /* 32-bit displacement fix */ - break; - - default: - BAD_CASE(segs(expr)); - break; - } -} /* memfmt() */ - - -/***************************************************************************** - * mema_to_memb: convert a MEMA-format opcode to a MEMB-format opcode. - * - * There are 2 possible MEMA formats: - * - displacement only - * - displacement + abase - * - * They are distinguished by the setting of the MEMA_ABASE bit. - * - **************************************************************************** */ -static void mema_to_memb(opcodeP) - char *opcodeP; /* Where to find the opcode, in target byte order */ -{ - long opcode; /* Opcode in host byte order */ - long mode; /* Mode bits for MEMB instruction */ - - opcode = md_chars_to_number(opcodeP, 4); - know(!(opcode & MEMB_BIT)); - - mode = MEMB_BIT | D_BIT; - if (opcode & MEMA_ABASE){ - mode |= A_BIT; - } - - opcode &= 0xffffc000; /* Clear MEMA offset and mode bits */ - opcode |= mode; /* Set MEMB mode bits */ - - md_number_to_chars(opcodeP, opcode, 4); -} /* mema_to_memb() */ - - -/***************************************************************************** - * parse_expr: parse an expression - * - * Use base assembler's expression parser to parse an expression. - * It, unfortunately, runs off a global which we have to save/restore - * in order to make it work for us. - * - * An empty expression string is treated as an absolute 0. - * - * Return "segment" to which the expression evaluates. - * Return SEG_GOOF regardless of expression evaluation if entire input - * string is not consumed in the evaluation -- tolerate no dangling junk! - * - **************************************************************************** */ -static -segT -parse_expr(textP, expP) - char *textP; /* Text of expression to be parsed */ - expressionS *expP; /* Where to put the results of parsing */ -{ - char *save_in; /* Save global here */ - segT seg; /* Segment to which expression evaluates */ - symbolS *symP; - - know(textP); - - if (*textP == '\0') { - /* Treat empty string as absolute 0 */ - expP->X_add_symbol = expP->X_subtract_symbol = NULL; - expP->X_add_number = 0; - seg = expP->X_seg = SEG_ABSOLUTE; - - } else { - save_in = input_line_pointer; /* Save global */ - input_line_pointer = textP; /* Make parser work for us */ - - seg = expression(expP); - if (input_line_pointer - textP != strlen(textP)) { - /* Did not consume all of the input */ - seg = SEG_GOOF; - } - symP = expP->X_add_symbol; - if (symP && (hash_find(reg_hash, S_GET_NAME(symP)))) { - /* Register name in an expression */ - seg = SEG_GOOF; - } - - input_line_pointer = save_in; /* Restore global */ - } - return seg; -} - - -/***************************************************************************** - * parse_ldcont: - * Parse and replace a 'ldconst' pseudo-instruction with an appropriate - * i80960 instruction. - * - * Assumes the input consists of: - * arg[0] opcode mnemonic ('ldconst') - * arg[1] first operand (constant) - * arg[2] name of register to be loaded - * - * Replaces opcode and/or operands as appropriate. - * - * Returns the new number of arguments, or -1 on failure. - * - **************************************************************************** */ -static -int -parse_ldconst(arg) - char *arg[]; /* See above */ -{ - int n; /* Constant to be loaded */ - int shift; /* Shift count for "shlo" instruction */ - static char buf[5]; /* Literal for first operand */ - static char buf2[5]; /* Literal for second operand */ - expressionS e; /* Parsed expression */ - - - arg[3] = NULL; /* So we can tell at the end if it got used or not */ - - switch(parse_expr(arg[1],&e)){ - - case SEG_TEXT: - case SEG_DATA: - case SEG_BSS: - case SEG_UNKNOWN: - case SEG_DIFFERENCE: - /* We're dependent on one or more symbols -- use "lda" */ - arg[0] = "lda"; - break; - - case SEG_ABSOLUTE: - /* Try the following mappings: - * ldconst 0, ->mov 0, - * ldconst 31, ->mov 31, - * ldconst 32, ->addo 1,31, - * ldconst 62, ->addo 31,31, - * ldconst 64, ->shlo 8,3, - * ldconst -1, ->subo 1,0, - * ldconst -31,->subo 31,0, - * - * anthing else becomes: - * lda xxx, - */ - n = offs(e); - if ((0 <= n) && (n <= 31)){ - arg[0] = "mov"; - - } else if ((-31 <= n) && (n <= -1)){ - arg[0] = "subo"; - arg[3] = arg[2]; - sprintf(buf, "%d", -n); - arg[1] = buf; - arg[2] = "0"; - - } else if ((32 <= n) && (n <= 62)){ - arg[0] = "addo"; - arg[3] = arg[2]; - arg[1] = "31"; - sprintf(buf, "%d", n-31); - arg[2] = buf; - - } else if ((shift = shift_ok(n)) != 0){ - arg[0] = "shlo"; - arg[3] = arg[2]; - sprintf(buf, "%d", shift); - arg[1] = buf; - sprintf(buf2, "%d", n >> shift); - arg[2] = buf2; - - } else { - arg[0] = "lda"; - } - break; - - default: - as_bad("invalid constant"); - return -1; - break; - } - return (arg[3] == 0) ? 2: 3; -} - -/***************************************************************************** - * parse_memop: parse a memory operand - * - * This routine is based on the observation that the 4 mode bits of the - * MEMB format, taken individually, have fairly consistent meaning: - * - * M3 (bit 13): 1 if displacement is present (D_BIT) - * M2 (bit 12): 1 for MEMB instructions (MEMB_BIT) - * M1 (bit 11): 1 if index is present (I_BIT) - * M0 (bit 10): 1 if abase is present (A_BIT) - * - * So we parse the memory operand and set bits in the mode as we find - * things. Then at the end, if we go to MEMB format, we need only set - * the MEMB bit (M2) and our mode is built for us. - * - * Unfortunately, I said "fairly consistent". The exceptions: - * - * DBIA - * 0100 Would seem illegal, but means "abase-only". - * - * 0101 Would seem to mean "abase-only" -- it means IP-relative. - * Must be converted to 0100. - * - * 0110 Would seem to mean "index-only", but is reserved. - * We turn on the D bit and provide a 0 displacement. - * - * The other thing to observe is that we parse from the right, peeling - * things * off as we go: first any index spec, then any abase, then - * the displacement. - * - **************************************************************************** */ -static -void -parse_memop(memP, argP, optype) - memS *memP; /* Where to put the results */ - char *argP; /* Text of the operand to be parsed */ - int optype; /* MEM1, MEM2, MEM4, MEM8, MEM12, or MEM16 */ -{ - char *indexP; /* Pointer to index specification with "[]" removed */ - char *p; /* Temp char pointer */ - char iprel_flag;/* True if this is an IP-relative operand */ - int regnum; /* Register number */ - int scale; /* Scale factor: 1,2,4,8, or 16. Later converted - * to internal format (0,1,2,3,4 respectively). - */ - int mode; /* MEMB mode bits */ - int *intP; /* Pointer to register number */ - - /* The following table contains the default scale factors for each - * type of memory instruction. It is accessed using (optype-MEM1) - * as an index -- thus it assumes the 'optype' constants are assigned - * consecutive values, in the order they appear in this table - */ - static int def_scale[] = { - 1, /* MEM1 */ - 2, /* MEM2 */ - 4, /* MEM4 */ - 8, /* MEM8 */ - -1, /* MEM12 -- no valid default */ - 16 /* MEM16 */ - }; - - - iprel_flag = mode = 0; - - /* Any index present? */ - indexP = get_ispec(argP); - if (indexP) { - p = strchr(indexP, '*'); - if (p == NULL) { - /* No explicit scale -- use default for this - *instruction type. - */ - scale = def_scale[ optype - MEM1 ]; - } else { - *p++ = '\0'; /* Eliminate '*' */ - - /* Now indexP->a '\0'-terminated register name, - * and p->a scale factor. - */ - - if (!strcmp(p,"16")){ - scale = 16; - } else if (strchr("1248",*p) && (p[1] == '\0')){ - scale = *p - '0'; - } else { - scale = -1; - } - } - - regnum = get_regnum(indexP); /* Get index reg. # */ - if (!IS_RG_REG(regnum)){ - as_bad("invalid index register"); - return; - } - - /* Convert scale to its binary encoding */ - switch (scale){ - case 1: scale = 0 << 7; break; - case 2: scale = 1 << 7; break; - case 4: scale = 2 << 7; break; - case 8: scale = 3 << 7; break; - case 16: scale = 4 << 7; break; - default: as_bad("invalid scale factor"); return; - }; - - memP->opcode |= scale | regnum; /* Set index bits in opcode */ - mode |= I_BIT; /* Found a valid index spec */ - } - - /* Any abase (Register Indirect) specification present? */ - if ((p = strrchr(argP,'(')) != NULL) { - /* "(" is there -- does it start a legal abase spec? - * (If not it could be part of a displacement expression.) - */ - intP = (int *) hash_find(areg_hash, p); - if (intP != NULL){ - /* Got an abase here */ - regnum = *intP; - *p = '\0'; /* discard register spec */ - if (regnum == IPREL){ - /* We have to specialcase ip-rel mode */ - iprel_flag = 1; - } else { - memP->opcode |= regnum << 14; - mode |= A_BIT; - } - } - } - - /* Any expression present? */ - memP->e = argP; - if (*argP != '\0'){ - mode |= D_BIT; - } - - /* Special-case ip-relative addressing */ - if (iprel_flag){ - if (mode & I_BIT){ - syntax(); - } else { - memP->opcode |= 5 << 10; /* IP-relative mode */ - memP->disp = 32; - } - return; - } - - /* Handle all other modes */ - switch (mode){ - case D_BIT | A_BIT: - /* Go with MEMA instruction format for now (grow to MEMB later - * if 12 bits is not enough for the displacement). - * MEMA format has a single mode bit: set it to indicate - * that abase is present. - */ - memP->opcode |= MEMA_ABASE; - memP->disp = 12; - break; - - case D_BIT: - /* Go with MEMA instruction format for now (grow to MEMB later - * if 12 bits is not enough for the displacement). - */ - memP->disp = 12; - break; - - case A_BIT: - /* For some reason, the bit string for this mode is not - * consistent: it should be 0 (exclusive of the MEMB bit), - * so we set it "by hand" here. - */ - memP->opcode |= MEMB_BIT; - break; - - case A_BIT | I_BIT: - /* set MEMB bit in mode, and OR in mode bits */ - memP->opcode |= mode | MEMB_BIT; - break; - - case I_BIT: - /* Treat missing displacement as displacement of 0 */ - mode |= D_BIT; - /*********************** - * Fall into next case * - ********************** */ - case D_BIT | A_BIT | I_BIT: - case D_BIT | I_BIT: - /* set MEMB bit in mode, and OR in mode bits */ - memP->opcode |= mode | MEMB_BIT; - memP->disp = 32; - break; - - default: - syntax(); - break; - } -} - -/***************************************************************************** - * parse_po: parse machine-dependent pseudo-op - * - * This is a top-level routine for machine-dependent pseudo-ops. It slurps - * up the rest of the input line, breaks out the individual arguments, - * and dispatches them to the correct handler. - **************************************************************************** */ -static -void -parse_po(po_num) - int po_num; /* Pseudo-op number: currently S_LEAFPROC or S_SYSPROC */ -{ - char *args[4]; /* Pointers operands, with no embedded whitespace. - * arg[0] unused. - * arg[1-3]->operands - */ - int n_ops; /* Number of operands */ - char *p; /* Pointer to beginning of unparsed argument string */ - char eol; /* Character that indicated end of line */ - - extern char is_end_of_line[]; - - /* Advance input pointer to end of line. */ - p = input_line_pointer; - while (!is_end_of_line[ *input_line_pointer ]){ - input_line_pointer++; - } - eol = *input_line_pointer; /* Save end-of-line char */ - *input_line_pointer = '\0'; /* Terminate argument list */ - - /* Parse out operands */ - n_ops = get_args(p, args); - if (n_ops == -1){ - return; - } - - /* Dispatch to correct handler */ - switch(po_num){ - case S_SYSPROC: s_sysproc(n_ops, args); break; - case S_LEAFPROC: s_leafproc(n_ops, args); break; - default: BAD_CASE(po_num); break; - } - - /* Restore eol, so line numbers get updated correctly. Base assembler - * assumes we leave input pointer pointing at char following the eol. - */ - *input_line_pointer++ = eol; -} - -/***************************************************************************** - * parse_regop: parse a register operand. - * - * In case of illegal operand, issue a message and return some valid - * information so instruction processing can continue. - **************************************************************************** */ -static -void -parse_regop(regopP, optext, opdesc) - struct regop *regopP; /* Where to put description of register operand */ - char *optext; /* Text of operand */ - char opdesc; /* Descriptor byte: what's legal for this operand */ -{ - int n; /* Register number */ - expressionS e; /* Parsed expression */ - - /* See if operand is a register */ - n = get_regnum(optext); - if (n >= 0){ - if (IS_RG_REG(n)){ - /* global or local register */ - if (!REG_ALIGN(opdesc,n)){ - as_bad("unaligned register"); - } - regopP->n = n; - regopP->mode = 0; - regopP->special = 0; - return; - } else if (IS_FP_REG(n) && FP_OK(opdesc)){ - /* Floating point register, and it's allowed */ - regopP->n = n - FP0; - regopP->mode = 1; - regopP->special = 0; - return; - } else if (IS_SF_REG(n) && SFR_OK(opdesc)){ - /* Special-function register, and it's allowed */ - regopP->n = n - SF0; - regopP->mode = 0; - regopP->special = 1; - if (!targ_has_sfr(regopP->n)){ - as_bad("no such sfr in this architecture"); - } - return; - } - } else if (LIT_OK(opdesc)){ - /* - * How about a literal? - */ - regopP->mode = 1; - regopP->special = 0; - if (FP_OK(opdesc)){ /* floating point literal acceptable */ - /* Skip over 0f, 0d, or 0e prefix */ - if ( (optext[0] == '0') - && (optext[1] >= 'd') - && (optext[1] <= 'f') ){ - optext += 2; - } - - if (!strcmp(optext,"0.0") || !strcmp(optext,"0") ){ - regopP->n = 0x10; - return; - } - if (!strcmp(optext,"1.0") || !strcmp(optext,"1") ){ - regopP->n = 0x16; - return; - } - - } else { /* fixed point literal acceptable */ - if ((parse_expr(optext,&e) != SEG_ABSOLUTE) - || (offs(e) < 0) || (offs(e) > 31)){ - as_bad("illegal literal"); - offs(e) = 0; - } - regopP->n = offs(e); - return; - } - } - - /* Nothing worked */ - syntax(); - regopP->mode = 0; /* Register r0 is always a good one */ - regopP->n = 0; - regopP->special = 0; -} /* parse_regop() */ - -/***************************************************************************** - * reg_fmt: generate a REG-format instruction - * - **************************************************************************** */ -static void reg_fmt(args, oP) - char *args[]; /* args[0]->opcode mnemonic, args[1-3]->operands */ - struct i960_opcode *oP; /* Pointer to description of instruction */ -{ - long instr; /* Binary to be output */ - struct regop regop; /* Description of register operand */ - int n_ops; /* Number of operands */ - - - instr = oP->opcode; - n_ops = oP->num_ops; - - if (n_ops >= 1){ - parse_regop(®op, args[1], oP->operand[0]); - - if ((n_ops == 1) && !(instr & M3)){ - /* 1-operand instruction in which the dst field should - * be used (instead of src1). - */ - regop.n <<= 19; - if (regop.special){ - regop.mode = regop.special; - } - regop.mode <<= 13; - regop.special = 0; - } else { - /* regop.n goes in bit 0, needs no shifting */ - regop.mode <<= 11; - regop.special <<= 5; - } - instr |= regop.n | regop.mode | regop.special; - } - - if (n_ops >= 2) { - parse_regop(®op, args[2], oP->operand[1]); - - if ((n_ops == 2) && !(instr & M3)){ - /* 2-operand instruction in which the dst field should - * be used instead of src2). - */ - regop.n <<= 19; - if (regop.special){ - regop.mode = regop.special; - } - regop.mode <<= 13; - regop.special = 0; - } else { - regop.n <<= 14; - regop.mode <<= 12; - regop.special <<= 6; - } - instr |= regop.n | regop.mode | regop.special; - } - if (n_ops == 3){ - parse_regop(®op, args[3], oP->operand[2]); - if (regop.special){ - regop.mode = regop.special; - } - instr |= (regop.n <<= 19) | (regop.mode <<= 13); - } - emit(instr); -} - - -/***************************************************************************** - * relax_cobr: - * Replace cobr instruction in a code fragment with equivalent branch and - * compare instructions, so it can reach beyond a 13-bit displacement. - * Set up an address fix/relocation for the new branch instruction. - * - **************************************************************************** */ - -/* This "conditional jump" table maps cobr instructions into equivalent - * compare and branch opcodes. - */ -static -struct { - long compare; - long branch; -} coj[] = { /* COBR OPCODE: */ - CHKBIT, BNO, /* 0x30 - bbc */ - CMPO, BG, /* 0x31 - cmpobg */ - CMPO, BE, /* 0x32 - cmpobe */ - CMPO, BGE, /* 0x33 - cmpobge */ - CMPO, BL, /* 0x34 - cmpobl */ - CMPO, BNE, /* 0x35 - cmpobne */ - CMPO, BLE, /* 0x36 - cmpoble */ - CHKBIT, BO, /* 0x37 - bbs */ - CMPI, BNO, /* 0x38 - cmpibno */ - CMPI, BG, /* 0x39 - cmpibg */ - CMPI, BE, /* 0x3a - cmpibe */ - CMPI, BGE, /* 0x3b - cmpibge */ - CMPI, BL, /* 0x3c - cmpibl */ - CMPI, BNE, /* 0x3d - cmpibne */ - CMPI, BLE, /* 0x3e - cmpible */ - CMPI, BO, /* 0x3f - cmpibo */ -}; - -static -void -relax_cobr(fragP) - register fragS *fragP; /* fragP->fr_opcode is assumed to point to - * the cobr instruction, which comes at the - * end of the code fragment. - */ -{ - int opcode, src1, src2, m1, s2; - /* Bit fields from cobr instruction */ - long bp_bits; /* Branch prediction bits from cobr instruction */ - long instr; /* A single i960 instruction */ - char *iP; /*->instruction to be replaced */ - fixS *fixP; /* Relocation that can be done at assembly time */ - - /* PICK UP & PARSE COBR INSTRUCTION */ - iP = fragP->fr_opcode; - instr = md_chars_to_number(iP, 4); - opcode = ((instr >> 24) & 0xff) - 0x30; /* "-0x30" for table index */ - src1 = (instr >> 19) & 0x1f; - m1 = (instr >> 13) & 1; - s2 = instr & 1; - src2 = (instr >> 14) & 0x1f; - bp_bits= instr & BP_MASK; - - /* GENERATE AND OUTPUT COMPARE INSTRUCTION */ - instr = coj[opcode].compare - | src1 | (m1 << 11) | (s2 << 6) | (src2 << 14); - md_number_to_chars(iP, instr, 4); - - /* OUTPUT BRANCH INSTRUCTION */ - md_number_to_chars(iP+4, coj[opcode].branch | bp_bits, 4); - - /* SET UP ADDRESS FIXUP/RELOCATION */ - fixP = fix_new(fragP, - iP+4 - fragP->fr_literal, - 4, - fragP->fr_symbol, - 0, - fragP->fr_offset, - 1, - 0); - - fixP->fx_bit_fixP = (bit_fixS *) 24; /* Store size of bit field */ - - fragP->fr_fix += 4; - frag_wane(fragP); -} - - -/***************************************************************************** - * reloc_callj: Relocate a 'callj' instruction - * - * This is a "non-(GNU)-standard" machine-dependent hook. The base - * assembler calls it when it decides it can relocate an address at - * assembly time instead of emitting a relocation directive. - * - * Check to see if the relocation involves a 'callj' instruction to a: - * sysproc: Replace the default 'call' instruction with a 'calls' - * leafproc: Replace the default 'call' instruction with a 'bal'. - * other proc: Do nothing. - * - * See b.out.h for details on the 'n_other' field in a symbol structure. - * - * IMPORTANT!: - * Assumes the caller has already figured out, in the case of a leafproc, - * to use the 'bal' entry point, and has substituted that symbol into the - * passed fixup structure. - * - **************************************************************************** */ -void reloc_callj(fixP) -fixS *fixP; /* Relocation that can be done at assembly time */ -{ - char *where; /*->the binary for the instruction being relocated */ - - if (!fixP->fx_callj) { - return; - } /* This wasn't a callj instruction in the first place */ - - where = fixP->fx_frag->fr_literal + fixP->fx_where; - - if (TC_S_IS_SYSPROC(fixP->fx_addsy)) { - /* Symbol is a .sysproc: replace 'call' with 'calls'. - * System procedure number is (other-1). - */ - md_number_to_chars(where, CALLS|TC_S_GET_SYSPROC(fixP->fx_addsy), 4); - - /* Nothing else needs to be done for this instruction. - * Make sure 'md_number_to_field()' will perform a no-op. - */ - fixP->fx_bit_fixP = (bit_fixS *) 1; - - } else if (TC_S_IS_CALLNAME(fixP->fx_addsy)) { - /* Should not happen: see block comment above */ - as_fatal("Trying to 'bal' to %s", S_GET_NAME(fixP->fx_addsy)); - - } else if (TC_S_IS_BALNAME(fixP->fx_addsy)) { - /* Replace 'call' with 'bal'; both instructions have - * the same format, so calling code should complete - * relocation as if nothing happened here. - */ - md_number_to_chars(where, BAL, 4); - } else if (TC_S_IS_BADPROC(fixP->fx_addsy)) { - as_bad("Looks like a proc, but can't tell what kind.\n"); - } /* switch on proc type */ - - /* else Symbol is neither a sysproc nor a leafproc */ - - return; -} /* reloc_callj() */ - - -/***************************************************************************** - * s_leafproc: process .leafproc pseudo-op - * - * .leafproc takes two arguments, the second one is optional: - * arg[1]: name of 'call' entry point to leaf procedure - * arg[2]: name of 'bal' entry point to leaf procedure - * - * If the two arguments are identical, or if the second one is missing, - * the first argument is taken to be the 'bal' entry point. - * - * If there are 2 distinct arguments, we must make sure that the 'bal' - * entry point immediately follows the 'call' entry point in the linked - * list of symbols. - * - **************************************************************************** */ -static void s_leafproc(n_ops, args) -int n_ops; /* Number of operands */ -char *args[]; /* args[1]->1st operand, args[2]->2nd operand */ -{ - symbolS *callP; /* Pointer to leafproc 'call' entry point symbol */ - symbolS *balP; /* Pointer to leafproc 'bal' entry point symbol */ - - if ((n_ops != 1) && (n_ops != 2)) { - as_bad("should have 1 or 2 operands"); - return; - } /* Check number of arguments */ - - /* Find or create symbol for 'call' entry point. */ - callP = symbol_find_or_make(args[1]); - - if (TC_S_IS_CALLNAME(callP)) { - as_warn("Redefining leafproc %s", S_GET_NAME(callP)); - } /* is leafproc */ - - /* If that was the only argument, use it as the 'bal' entry point. - * Otherwise, mark it as the 'call' entry point and find or create - * another symbol for the 'bal' entry point. - */ - if ((n_ops == 1) || !strcmp(args[1],args[2])) { - TC_S_FORCE_TO_BALNAME(callP); - - } else { - TC_S_FORCE_TO_CALLNAME(callP); - - balP = symbol_find_or_make(args[2]); - if (TC_S_IS_CALLNAME(balP)) { - as_warn("Redefining leafproc %s", S_GET_NAME(balP)); - } - TC_S_FORCE_TO_BALNAME(balP); - - tc_set_bal_of_call(callP, balP); - } /* if only one arg, or the args are the same */ - - return; -} /* s_leafproc() */ - - -/* - * s_sysproc: process .sysproc pseudo-op - * - * .sysproc takes two arguments: - * arg[1]: name of entry point to system procedure - * arg[2]: 'entry_num' (index) of system procedure in the range - * [0,31] inclusive. - * - * For [ab].out, we store the 'entrynum' in the 'n_other' field of - * the symbol. Since that entry is normally 0, we bias 'entrynum' - * by adding 1 to it. It must be unbiased before it is used. - */ -static void s_sysproc(n_ops, args) -int n_ops; /* Number of operands */ -char *args[]; /* args[1]->1st operand, args[2]->2nd operand */ -{ - expressionS exp; - symbolS *symP; - - if (n_ops != 2) { - as_bad("should have two operands"); - return; - } /* bad arg count */ - - /* Parse "entry_num" argument and check it for validity. */ - if ((parse_expr(args[2],&exp) != SEG_ABSOLUTE) - || (offs(exp) < 0) - || (offs(exp) > 31)) { - as_bad("'entry_num' must be absolute number in [0,31]"); - return; - } - - /* Find/make symbol and stick entry number (biased by +1) into it */ - symP = symbol_find_or_make(args[1]); - - if (TC_S_IS_SYSPROC(symP)) { - as_warn("Redefining entrynum for sysproc %s", S_GET_NAME(symP)); - } /* redefining */ - - TC_S_SET_SYSPROC(symP, offs(exp)); /* encode entry number */ - TC_S_FORCE_TO_SYSPROC(symP); - - return; -} /* s_sysproc() */ - - -/***************************************************************************** - * shift_ok: - * Determine if a "shlo" instruction can be used to implement a "ldconst". - * This means that some number X < 32 can be shifted left to produce the - * constant of interest. - * - * Return the shift count, or 0 if we can't do it. - * Caller calculates X by shifting original constant right 'shift' places. - * - **************************************************************************** */ -static -int -shift_ok(n) - int n; /* The constant of interest */ -{ - int shift; /* The shift count */ - - if (n <= 0){ - /* Can't do it for negative numbers */ - return 0; - } - - /* Shift 'n' right until a 1 is about to be lost */ - for (shift = 0; (n & 1) == 0; shift++){ - n >>= 1; - } - - if (n >= 32){ - return 0; - } - return shift; -} - - -/***************************************************************************** - * syntax: issue syntax error - * - **************************************************************************** */ -static void syntax() { - as_bad("syntax error"); -} /* syntax() */ - - -/***************************************************************************** - * targ_has_sfr: - * Return TRUE iff the target architecture supports the specified - * special-function register (sfr). - * - **************************************************************************** */ -static -int -targ_has_sfr(n) - int n; /* Number (0-31) of sfr */ -{ - switch (architecture){ - case ARCH_KA: - case ARCH_KB: - case ARCH_MC: - return 0; - case ARCH_CA: - default: - return ((0<=n) && (n<=2)); - } -} - - -/***************************************************************************** - * targ_has_iclass: - * Return TRUE iff the target architecture supports the indicated - * class of instructions. - * - **************************************************************************** */ -static -int -targ_has_iclass(ic) - int ic; /* Instruction class; one of: - * I_BASE, I_CX, I_DEC, I_KX, I_FP, I_MIL, I_CASIM - */ -{ - iclasses_seen |= ic; - switch (architecture){ - case ARCH_KA: return ic & (I_BASE | I_KX); - case ARCH_KB: return ic & (I_BASE | I_KX | I_FP | I_DEC); - case ARCH_MC: return ic & (I_BASE | I_KX | I_FP | I_DEC | I_MIL); - case ARCH_CA: return ic & (I_BASE | I_CX | I_CASIM); - default: - if ((iclasses_seen & (I_KX|I_FP|I_DEC|I_MIL)) - && (iclasses_seen & I_CX)){ - as_warn("architecture of opcode conflicts with that of earlier instruction(s)"); - iclasses_seen &= ~ic; - } - return 1; - } -} - - -/* Parse an operand that is machine-specific. - We just return without modifying the expression if we have nothing - to do. */ - -/* ARGSUSED */ -void -md_operand (expressionP) - expressionS *expressionP; -{ -} - -/* We have no need to default values of symbols. */ - -/* ARGSUSED */ -symbolS *md_undefined_symbol(name) -char *name; -{ - return 0; -} /* md_undefined_symbol() */ - -/* Exactly what point is a PC-relative offset relative TO? - On the i960, they're relative to the address of the instruction, - which we have set up as the address of the fixup too. */ -long -md_pcrel_from (fixP) - fixS *fixP; -{ - return fixP->fx_where + fixP->fx_frag->fr_address; -} - -void -md_apply_fix(fixP, val) - fixS *fixP; - long val; -{ - char *place = fixP->fx_where + fixP->fx_frag->fr_literal; - - if (!fixP->fx_bit_fixP) { - - switch (fixP->fx_im_disp) { - case 0: - fixP->fx_addnumber = val; - md_number_to_imm(place, val, fixP->fx_size, fixP); - break; - case 1: - md_number_to_disp(place, - fixP->fx_pcrel ? val + fixP->fx_pcrel_adjust : val, - fixP->fx_size); - break; - case 2: /* fix requested for .long .word etc */ - md_number_to_chars(place, val, fixP->fx_size); - break; - default: - as_fatal("Internal error in md_apply_fix() in file \"%s\"", __FILE__); - } /* OVE: maybe one ought to put _imm _disp _chars in one md-func */ - } else { - md_number_to_field(place, val, fixP->fx_bit_fixP); - } - - return; -} /* md_apply_fix() */ - -#if defined(OBJ_AOUT) | defined(OBJ_BOUT) -void tc_bout_fix_to_chars(where, fixP, segment_address_in_file) -char *where; -fixS *fixP; -relax_addressT segment_address_in_file; -{ - static unsigned char nbytes_r_length [] = { 42, 0, 1, 42, 2 }; - struct relocation_info ri; - symbolS *symbolP; - - /* JF this is for paranoia */ - bzero((char *)&ri, sizeof(ri)); - - know((symbolP = fixP->fx_addsy) != 0); - - /* These two 'cuz of NS32K */ - ri.r_callj = fixP->fx_callj; - - ri.r_length = nbytes_r_length[fixP->fx_size]; - ri.r_pcrel = fixP->fx_pcrel; - ri.r_address = fixP->fx_frag->fr_address + fixP->fx_where - segment_address_in_file; - - if (!S_IS_DEFINED(symbolP)) { - ri.r_extern = 1; - ri.r_index = symbolP->sy_number; - } else { - ri.r_extern = 0; - ri.r_index = S_GET_TYPE(symbolP); - } - - /* Output the relocation information in machine-dependent form. */ - md_ri_to_chars(where, &ri); - - return; -} /* tc_bout_fix_to_chars() */ - -#endif /* OBJ_AOUT or OBJ_BOUT */ - -/* Align an address by rounding it up to the specified boundary. - */ -long md_section_align(seg, addr) -segT seg; -long addr; /* Address to be rounded up */ -{ - return((addr + (1 << section_alignment[(int) seg]) - 1) & (-1 << section_alignment[(int) seg])); -} /* md_section_align() */ - -#ifdef OBJ_COFF -void tc_headers_hook(headers) -object_headers *headers; -{ - unsigned short arch_flag = 0; - - if (iclasses_seen == I_BASE){ - headers->filehdr.f_flags |= F_I960CORE; - } else if (iclasses_seen & I_CX){ - headers->filehdr.f_flags |= F_I960CA; - } else if (iclasses_seen & I_MIL){ - headers->filehdr.f_flags |= F_I960MC; - } else if (iclasses_seen & (I_DEC|I_FP)){ - headers->filehdr.f_flags |= F_I960KB; - } else { - headers->filehdr.f_flags |= F_I960KA; - } /* set arch flag */ - - if (flagseen['R']) { - headers->filehdr.f_magic = I960RWMAGIC; - headers->aouthdr.magic = OMAGIC; - } else { - headers->filehdr.f_magic = I960ROMAGIC; - headers->aouthdr.magic = NMAGIC; - } /* set magic numbers */ - - return; -} /* tc_headers_hook() */ -#endif /* OBJ_COFF */ - -/* - * Things going on here: - * - * For bout, We need to assure a couple of simplifying - * assumptions about leafprocs for the linker: the leafproc - * entry symbols will be defined in the same assembly in - * which they're declared with the '.leafproc' directive; - * and if a leafproc has both 'call' and 'bal' entry points - * they are both global or both local. - * - * For coff, the call symbol has a second aux entry that - * contains the bal entry point. The bal symbol becomes a - * label. - * - * For coff representation, the call symbol has a second aux entry that - * contains the bal entry point. The bal symbol becomes a label. - * - */ - -void tc_crawl_symbol_chain(headers) -object_headers *headers; -{ - symbolS *symbolP; - - for (symbolP = symbol_rootP; symbolP; symbolP = symbol_next(symbolP)) { -#ifdef OBJ_COFF - if (TC_S_IS_SYSPROC(symbolP)) { - /* second aux entry already contains the sysproc number */ - S_SET_NUMBER_AUXILIARY(symbolP, 2); - S_SET_STORAGE_CLASS(symbolP, C_SCALL); - S_SET_DATA_TYPE(symbolP, S_GET_DATA_TYPE(symbolP) | (DT_FCN << N_BTSHFT)); - continue; - } /* rewrite sysproc */ -#endif /* OBJ_COFF */ - - if (!TC_S_IS_BALNAME(symbolP) && !TC_S_IS_CALLNAME(symbolP)) { - continue; - } /* Not a leafproc symbol */ - - if (!S_IS_DEFINED(symbolP)) { - as_bad("leafproc symbol '%s' undefined", S_GET_NAME(symbolP)); - } /* undefined leaf */ - - if (TC_S_IS_CALLNAME(symbolP)) { - symbolS *balP = tc_get_bal_of_call(symbolP); - if (S_IS_EXTERNAL(symbolP) != S_IS_EXTERNAL(balP)) { - S_SET_EXTERNAL(symbolP); - S_SET_EXTERNAL(balP); - as_warn("Warning: making leafproc entries %s and %s both global\n", - S_GET_NAME(symbolP), S_GET_NAME(balP)); - } /* externality mismatch */ - } /* if callname */ - } /* walk the symbol chain */ - - return; -} /* tc_crawl_symbol_chain() */ - -/* - * For aout or bout, the bal immediately follows the call. - * - * For coff, we cheat and store a pointer to the bal symbol - * in the second aux entry of the call. - */ - -void tc_set_bal_of_call(callP, balP) -symbolS *callP; -symbolS *balP; -{ - know(TC_S_IS_CALLNAME(callP)); - know(TC_S_IS_BALNAME(balP)); - -#ifdef OBJ_COFF - - callP->sy_symbol.ost_auxent[1].x_bal.x_balntry = (int) balP; - S_SET_NUMBER_AUXILIARY(callP,2); - -#elif defined(OBJ_AOUT) || defined(OBJ_BOUT) - - /* If the 'bal' entry doesn't immediately follow the 'call' - * symbol, unlink it from the symbol list and re-insert it. - */ - if (symbol_next(callP) != balP) { - symbol_remove(balP, &symbol_rootP, &symbol_lastP); - symbol_append(balP, callP, &symbol_rootP, &symbol_lastP); - } /* if not in order */ - -#else - (as yet unwritten.); -#endif /* switch on OBJ_FORMAT */ - - return; -} /* tc_set_bal_of_call() */ - -char *_tc_get_bal_of_call(callP) -symbolS *callP; -{ - symbolS *retval; - - know(TC_S_IS_CALLNAME(callP)); - -#ifdef OBJ_COFF - retval = (symbolS *) (callP->sy_symbol.ost_auxent[1].x_bal.x_balntry); -#elif defined(OBJ_AOUT) || defined(OBJ_BOUT) - retval = symbol_next(callP); -#else - (as yet unwritten.); -#endif /* switch on OBJ_FORMAT */ - - know(TC_S_IS_BALNAME(retval)); - return((char *) retval); -} /* _tc_get_bal_of_call() */ - -void tc_coff_symbol_emit_hook(symbolP) -symbolS *symbolP; -{ - if (TC_S_IS_CALLNAME(symbolP)) { -#ifdef OBJ_COFF - symbolS *balP = tc_get_bal_of_call(symbolP); - - /* second aux entry contains the bal entry point */ -/* S_SET_NUMBER_AUXILIARY(symbolP, 2); */ - symbolP->sy_symbol.ost_auxent[1].x_bal.x_balntry = S_GET_VALUE(balP); - S_SET_STORAGE_CLASS(symbolP, (!SF_GET_LOCAL(symbolP) ? C_LEAFEXT : C_LEAFSTAT)); - S_SET_DATA_TYPE(symbolP, S_GET_DATA_TYPE(symbolP) | (DT_FCN << N_BTSHFT)); - /* fix up the bal symbol */ - S_SET_STORAGE_CLASS(balP, C_LABEL); -#endif /* OBJ_COFF */ - } /* only on calls */ - - return; -} /* tc_coff_symbol_emit_hook() */ - -/* - * Local Variables: - * comment-column: 0 - * fill-column: 131 - * End: - */ - -/* end of i960.c */ diff --git a/gas/config/tc-i960.h b/gas/config/tc-i960.h deleted file mode 100644 index 2b05340dbfa..00000000000 --- a/gas/config/tc-i960.h +++ /dev/null @@ -1,279 +0,0 @@ -/* tc-i960.h - Basic 80960 instruction formats. - Copyright (C) 1989, 1990, 1991 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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 1, -or (at your option) any later version. - -GAS 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 GAS; see the file COPYING. If not, write -to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* $Id$ */ - -/* - * The 'COJ' instructions are actually COBR instructions with the 'b' in - * the mnemonic replaced by a 'j'; they are ALWAYS "de-optimized" if necessary: - * if the displacement will not fit in 13 bits, the assembler will replace them - * with the corresponding compare and branch instructions. - * - * All of the 'MEMn' instructions are the same format; the 'n' in the name - * indicates the default index scale factor (the size of the datum operated on). - * - * The FBRA formats are not actually an instruction format. They are the - * "convenience directives" for branching on floating-point comparisons, - * each of which generates 2 instructions (a 'bno' and one other branch). - * - * The CALLJ format is not actually an instruction format. It indicates that - * the instruction generated (a CTRL-format 'call') should have its relocation - * specially flagged for link-time replacement with a 'bal' or 'calls' if - * appropriate. - */ - -#define TC_I960 1 - - /* tailor gas */ -#define SYMBOLS_NEED_BACKPOINTERS -#define LOCAL_LABELS_FB -#define WANT_BITFIELDS - - /* tailor the coff format */ -#define OBJ_COFF_SECTION_HEADER_HAS_ALIGNMENT -#define OBJ_COFF_MAX_AUXENTRIES (2) - - /* other */ -#define CTRL 0 -#define COBR 1 -#define COJ 2 -#define REG 3 -#define MEM1 4 -#define MEM2 5 -#define MEM4 6 -#define MEM8 7 -#define MEM12 8 -#define MEM16 9 -#define FBRA 10 -#define CALLJ 11 - -/* Masks for the mode bits in REG format instructions */ -#define M1 0x0800 -#define M2 0x1000 -#define M3 0x2000 - -/* Generate the 12-bit opcode for a REG format instruction by placing the - * high 8 bits in instruction bits 24-31, the low 4 bits in instruction bits - * 7-10. - */ - -#define REG_OPC(opc) ((opc & 0xff0) << 20) | ((opc & 0xf) << 7) - -/* Generate a template for a REG format instruction: place the opcode bits - * in the appropriate fields and OR in mode bits for the operands that will not - * be used. I.e., - * set m1=1, if src1 will not be used - * set m2=1, if src2 will not be used - * set m3=1, if dst will not be used - * - * Setting the "unused" mode bits to 1 speeds up instruction execution(!). - * The information is also useful to us because some 1-operand REG instructions - * use the src1 field, others the dst field; and some 2-operand REG instructions - * use src1/src2, others src1/dst. The set mode bits enable us to distinguish. - */ -#define R_0(opc) ( REG_OPC(opc) | M1 | M2 | M3 ) /* No operands */ -#define R_1(opc) ( REG_OPC(opc) | M2 | M3 ) /* 1 operand: src1 */ -#define R_1D(opc) ( REG_OPC(opc) | M1 | M2 ) /* 1 operand: dst */ -#define R_2(opc) ( REG_OPC(opc) | M3 ) /* 2 ops: src1/src2 */ -#define R_2D(opc) ( REG_OPC(opc) | M2 ) /* 2 ops: src1/dst */ -#define R_3(opc) ( REG_OPC(opc) ) /* 3 operands */ - -/* DESCRIPTOR BYTES FOR REGISTER OPERANDS - * - * Interpret names as follows: - * R: global or local register only - * RS: global, local, or (if target allows) special-function register only - * RL: global or local register, or integer literal - * RSL: global, local, or (if target allows) special-function register; - * or integer literal - * F: global, local, or floating-point register - * FL: global, local, or floating-point register; or literal (including - * floating point) - * - * A number appended to a name indicates that registers must be aligned, - * as follows: - * 2: register number must be multiple of 2 - * 4: register number must be multiple of 4 - */ - -#define SFR 0x10 /* Mask for the "sfr-OK" bit */ -#define LIT 0x08 /* Mask for the "literal-OK" bit */ -#define FP 0x04 /* Mask for "floating-point-OK" bit */ - -/* This macro ors the bits together. Note that 'align' is a mask - * for the low 0, 1, or 2 bits of the register number, as appropriate. - */ -#define OP(align,lit,fp,sfr) ( align | lit | fp | sfr ) - -#define R OP( 0, 0, 0, 0 ) -#define RS OP( 0, 0, 0, SFR ) -#define RL OP( 0, LIT, 0, 0 ) -#define RSL OP( 0, LIT, 0, SFR ) -#define F OP( 0, 0, FP, 0 ) -#define FL OP( 0, LIT, FP, 0 ) -#define R2 OP( 1, 0, 0, 0 ) -#define RL2 OP( 1, LIT, 0, 0 ) -#define F2 OP( 1, 0, FP, 0 ) -#define FL2 OP( 1, LIT, FP, 0 ) -#define R4 OP( 3, 0, 0, 0 ) -#define RL4 OP( 3, LIT, 0, 0 ) -#define F4 OP( 3, 0, FP, 0 ) -#define FL4 OP( 3, LIT, FP, 0 ) - -#define M 0x7f /* Memory operand (MEMA & MEMB format instructions) */ - -/* Macros to extract info from the register operand descriptor byte 'od'. - */ -#define SFR_OK(od) (od & SFR) /* TRUE if sfr operand allowed */ -#define LIT_OK(od) (od & LIT) /* TRUE if literal operand allowed */ -#define FP_OK(od) (od & FP) /* TRUE if floating-point op allowed */ -#define REG_ALIGN(od,n) ((od & 0x3 & n) == 0) - /* TRUE if reg #n is properly aligned */ -#define MEMOP(od) (od == M) /* TRUE if operand is a memory operand*/ - -/* Classes of 960 intructions: - * - each instruction falls into one class. - * - each target architecture supports one or more classes. - * - * EACH CONSTANT MUST CONTAIN 1 AND ONLY 1 SET BIT!: see targ_has_iclass(). - */ -#define I_BASE 0x01 /* 80960 base instruction set */ -#define I_CX 0x02 /* 80960Cx instruction */ -#define I_DEC 0x04 /* Decimal instruction */ -#define I_FP 0x08 /* Floating point instruction */ -#define I_KX 0x10 /* 80960Kx instruction */ -#define I_MIL 0x20 /* Military instruction */ - -/* MEANING OF 'n_other' in the symbol record. - * - * If non-zero, the 'n_other' fields indicates either a leaf procedure or - * a system procedure, as follows: - * - * 1 <= n_other <= 32 : - * The symbol is the entry point to a system procedure. - * 'n_value' is the address of the entry, as for any other - * procedure. The system procedure number (which can be used in - * a 'calls' instruction) is (n_other-1). These entries come from - * '.sysproc' directives. - * - * n_other == N_CALLNAME - * the symbol is the 'call' entry point to a leaf procedure. - * The *next* symbol in the symbol table must be the corresponding - * 'bal' entry point to the procedure (see following). These - * entries come from '.leafproc' directives in which two different - * symbols are specified (the first one is represented here). - * - * - * n_other == N_BALNAME - * the symbol is the 'bal' entry point to a leaf procedure. - * These entries result from '.leafproc' directives in which only - * one symbol is specified, or in which the same symbol is - * specified twice. - * - * Note that an N_CALLNAME entry *must* have a corresponding N_BALNAME entry, - * but not every N_BALNAME entry must have an N_CALLNAME entry. - */ -#define N_CALLNAME (-1) -#define N_BALNAME (-2) - - - /* i960 uses a custom relocation record. */ - - /* let obj-aout.h know */ -#define CUSTOM_RELOC_FORMAT 1 - /* let a.out.gnu.h know */ -#define N_RELOCATION_INFO_DECLARED 1 -struct relocation_info { - int r_address; /* File address of item to be relocated */ - unsigned - r_index:24,/* Index of symbol on which relocation is based*/ - r_pcrel:1, /* 1 => relocate PC-relative; else absolute - * On i960, pc-relative implies 24-bit - * address, absolute implies 32-bit. - */ - r_length:2, /* Number of bytes to relocate: - * 0 => 1 byte - * 1 => 2 bytes - * 2 => 4 bytes -- only value used for i960 - */ - r_extern:1, - r_bsr:1, /* Something for the GNU NS32K assembler */ - r_disp:1, /* Something for the GNU NS32K assembler */ - r_callj:1, /* 1 if relocation target is an i960 'callj' */ - nuthin:1; /* Unused */ -}; - - /* hacks for tracking callj's */ -#if defined(OBJ_AOUT) | defined(OBJ_BOUT) - -#define TC_S_IS_SYSPROC(s) ((1<=S_GET_OTHER(s)) && (S_GET_OTHER(s)<=32)) -#define TC_S_IS_BALNAME(s) (S_GET_OTHER(s) == N_BALNAME) -#define TC_S_IS_CALLNAME(s) (S_GET_OTHER(s) == N_CALLNAME) -#define TC_S_IS_BADPROC(s) ((S_GET_OTHER(s) != 0) && !TC_S_IS_CALLNAME(s) && !TC_S_IS_BALNAME(s) && !TC_S_IS_SYSPROC(s)) - -#define TC_S_SET_SYSPROC(s, p) (S_SET_OTHER((s), (p)+1)) -#define TC_S_GET_SYSPROC(s) (S_GET_OTHER(s)-1) - -#define TC_S_FORCE_TO_BALNAME(s) (S_SET_OTHER((s), N_BALNAME)) -#define TC_S_FORCE_TO_CALLNAME(s) (S_SET_OTHER((s), N_CALLNAME)) -#define TC_S_FORCE_TO_SYSPROC(s) {;} - -#elif defined(OBJ_COFF) - -#define TC_S_IS_SYSPROC(s) (S_GET_STORAGE_CLASS(s) == C_SCALL) -#define TC_S_IS_BALNAME(s) (SF_GET_BALNAME(s)) -#define TC_S_IS_CALLNAME(s) (SF_GET_CALLNAME(s)) -#define TC_S_IS_BADPROC(s) (TC_S_IS_SYSPROC(s) && TC_S_GET_SYSPROC(s) < 0 && 31 < TC_S_GET_SYSPROC(s)) - -#define TC_S_SET_SYSPROC(s, p) ((s)->sy_symbol.ost_auxent[1].x_sc.x_stindx = (p)) -#define TC_S_GET_SYSPROC(s) ((s)->sy_symbol.ost_auxent[1].x_sc.x_stindx) - -#define TC_S_FORCE_TO_BALNAME(s) (SF_SET_BALNAME(s)) -#define TC_S_FORCE_TO_CALLNAME(s) (SF_SET_CALLNAME(s)) -#define TC_S_FORCE_TO_SYSPROC(s) (S_SET_STORAGE_CLASS((s), C_SCALL)) - -#else /* switch on OBJ */ -you lose -#endif /* witch on OBJ */ - -#ifdef __STDC__ - -void brtab_emit(void); -void reloc_callj(); /* this is really reloc_callj(fixS *fixP) but I don't want to change header inclusion order. */ -void tc_set_bal_of_call(); /* this is really tc_set_bal_of_call(symbolS *callP, symbolS *balP) */ - -#else /* __STDC__ */ - -void brtab_emit(); -void reloc_callj(); -void tc_set_bal_of_call(); - -#endif /* __STDC__ */ - -char *_tc_get_bal_of_call(); /* this is really symbolS *tc_get_bal_of_call(symbolS *callP). */ -#define tc_get_bal_of_call(c) ((symbolS *) _tc_get_bal_of_call(c)) - -/* - * Local Variables: - * comment-column: 0 - * fill-column: 131 - * End: - */ - -/* end of tp-i960.h */ diff --git a/gas/config/tc-m68851.h b/gas/config/tc-m68851.h deleted file mode 100644 index ff984fe7efa..00000000000 --- a/gas/config/tc-m68851.h +++ /dev/null @@ -1,284 +0,0 @@ - -/* - * pmmu.h - */ - -/* I suppose we have to copyright this file. Someone on the net sent it - to us as part of the changes for the m68851 Memory Management Unit */ - -/* Copyright (C) 1987 Free Software Foundation, Inc. - -This file is part of Gas, the GNU Assembler. - -The GNU assembler is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the GNU Assembler General -Public License for full details. - -Everyone is granted permission to copy, modify and redistribute -the GNU Assembler, but only under the conditions described in the -GNU Assembler General Public License. A copy of this license is -supposed to have been given to you along with the GNU Assembler -so you can know your rights and responsibilities. It should be -in a file named COPYING. Among other things, the copyright -notice and this notice must be preserved on all copies. */ - -#ifdef m68851 - -/* - I didn't use much imagination in choosing the - following codes, so many of them aren't very - mnemonic. -rab - - P pmmu register - Possible values: - 000 TC Translation Control reg - 100 CAL Current Access Level - 101 VAL Validate Access Level - 110 SCC Stack Change Control - 111 AC Access Control - - W wide pmmu registers - Possible values: - 001 DRP Dma Root Pointer - 010 SRP Supervisor Root Pointer - 011 CRP Cpu Root Pointer - - f function code register - 0 SFC - 1 DFC - - V VAL register only - - X BADx, BACx - 100 BAD Breakpoint Acknowledge Data - 101 BAC Breakpoint Acknowledge Control - - Y PSR - Z PCSR - - | memory (modes 2-6, 7.*) - -*/ - -/* - * these defines should be in m68k.c but - * i put them here to keep all the m68851 stuff - * together -rab - * JF--Make sure these #s don't clash with the ones in m68k.c - * That would be BAD. - */ -#define TC (FPS+1) /* 48 */ -#define DRP (TC+1) /* 49 */ -#define SRP (DRP+1) /* 50 */ -#define CRP (SRP+1) /* 51 */ -#define CAL (CRP+1) /* 52 */ -#define VAL (CAL+1) /* 53 */ -#define SCC (VAL+1) /* 54 */ -#define AC (SCC+1) /* 55 */ -#define BAD (AC+1) /* 56,57,58,59, 60,61,62,63 */ -#define BAC (BAD+8) /* 64,65,66,67, 68,69,70,71 */ -#define PSR (BAC+8) /* 72 */ -#define PCSR (PSR+1) /* 73 */ - - /* name */ /* opcode */ /* match */ /* args */ - -{"pbac", one(0xf0c7), one(0xffbf), "Bc"}, -{"pbacw", one(0xf087), one(0xffbf), "Bc"}, -{"pbas", one(0xf0c6), one(0xffbf), "Bc"}, -{"pbasw", one(0xf086), one(0xffbf), "Bc"}, -{"pbbc", one(0xf0c1), one(0xffbf), "Bc"}, -{"pbbcw", one(0xf081), one(0xffbf), "Bc"}, -{"pbbs", one(0xf0c0), one(0xffbf), "Bc"}, -{"pbbsw", one(0xf080), one(0xffbf), "Bc"}, -{"pbcc", one(0xf0cf), one(0xffbf), "Bc"}, -{"pbccw", one(0xf08f), one(0xffbf), "Bc"}, -{"pbcs", one(0xf0ce), one(0xffbf), "Bc"}, -{"pbcsw", one(0xf08e), one(0xffbf), "Bc"}, -{"pbgc", one(0xf0cd), one(0xffbf), "Bc"}, -{"pbgcw", one(0xf08d), one(0xffbf), "Bc"}, -{"pbgs", one(0xf0cc), one(0xffbf), "Bc"}, -{"pbgsw", one(0xf08c), one(0xffbf), "Bc"}, -{"pbic", one(0xf0cb), one(0xffbf), "Bc"}, -{"pbicw", one(0xf08b), one(0xffbf), "Bc"}, -{"pbis", one(0xf0ca), one(0xffbf), "Bc"}, -{"pbisw", one(0xf08a), one(0xffbf), "Bc"}, -{"pblc", one(0xf0c3), one(0xffbf), "Bc"}, -{"pblcw", one(0xf083), one(0xffbf), "Bc"}, -{"pbls", one(0xf0c2), one(0xffbf), "Bc"}, -{"pblsw", one(0xf082), one(0xffbf), "Bc"}, -{"pbsc", one(0xf0c5), one(0xffbf), "Bc"}, -{"pbscw", one(0xf085), one(0xffbf), "Bc"}, -{"pbss", one(0xf0c4), one(0xffbf), "Bc"}, -{"pbssw", one(0xf084), one(0xffbf), "Bc"}, -{"pbwc", one(0xf0c9), one(0xffbf), "Bc"}, -{"pbwcw", one(0xf089), one(0xffbf), "Bc"}, -{"pbws", one(0xf0c8), one(0xffbf), "Bc"}, -{"pbwsw", one(0xf088), one(0xffbf), "Bc"}, - - -{"pdbac", two(0xf048, 0x0007), two(0xfff8, 0xffff), "DsBw"}, -{"pdbas", two(0xf048, 0x0006), two(0xfff8, 0xffff), "DsBw"}, -{"pdbbc", two(0xf048, 0x0001), two(0xfff8, 0xffff), "DsBw"}, -{"pdbbs", two(0xf048, 0x0000), two(0xfff8, 0xffff), "DsBw"}, -{"pdbcc", two(0xf048, 0x000f), two(0xfff8, 0xffff), "DsBw"}, -{"pdbcs", two(0xf048, 0x000e), two(0xfff8, 0xffff), "DsBw"}, -{"pdbgc", two(0xf048, 0x000d), two(0xfff8, 0xffff), "DsBw"}, -{"pdbgs", two(0xf048, 0x000c), two(0xfff8, 0xffff), "DsBw"}, -{"pdbic", two(0xf048, 0x000b), two(0xfff8, 0xffff), "DsBw"}, -{"pdbis", two(0xf048, 0x000a), two(0xfff8, 0xffff), "DsBw"}, -{"pdblc", two(0xf048, 0x0003), two(0xfff8, 0xffff), "DsBw"}, -{"pdbls", two(0xf048, 0x0002), two(0xfff8, 0xffff), "DsBw"}, -{"pdbsc", two(0xf048, 0x0005), two(0xfff8, 0xffff), "DsBw"}, -{"pdbss", two(0xf048, 0x0004), two(0xfff8, 0xffff), "DsBw"}, -{"pdbwc", two(0xf048, 0x0009), two(0xfff8, 0xffff), "DsBw"}, -{"pdbws", two(0xf048, 0x0008), two(0xfff8, 0xffff), "DsBw"}, - -{"pflusha", two(0xf000, 0x2400), two(0xffff, 0xffff), "" }, - -{"pflush", two(0xf000, 0x3010), two(0xffc0, 0xfe10), "T3T9" }, -{"pflush", two(0xf000, 0x3810), two(0xffc0, 0xfe10), "T3T9&s" }, -{"pflush", two(0xf000, 0x3008), two(0xffc0, 0xfe18), "D3T9" }, -{"pflush", two(0xf000, 0x3808), two(0xffc0, 0xfe18), "D3T9&s" }, -{"pflush", two(0xf000, 0x3000), two(0xffc0, 0xfe1e), "f3T9" }, -{"pflush", two(0xf000, 0x3800), two(0xffc0, 0xfe1e), "f3T9&s" }, - -{"pflushs", two(0xf000, 0x3410), two(0xfff8, 0xfe10), "T3T9" }, -{"pflushs", two(0xf000, 0x3c00), two(0xfff8, 0xfe00), "T3T9&s" }, -{"pflushs", two(0xf000, 0x3408), two(0xfff8, 0xfe18), "D3T9" }, -{"pflushs", two(0xf000, 0x3c08), two(0xfff8, 0xfe18), "D3T9&s" }, -{"pflushs", two(0xf000, 0x3400), two(0xfff8, 0xfe1e), "f3T9" }, -{"pflushs", two(0xf000, 0x3c00), two(0xfff8, 0xfe1e), "f3T9&s"}, - -{"pflushr", two(0xf000, 0xa000), two(0xffc0, 0xffff), "|s" }, - -{"ploadr", two(0xf000, 0x2210), two(0xffc0, 0xfff0), "T3&s" }, -{"ploadr", two(0xf000, 0x2208), two(0xffc0, 0xfff8), "D3&s" }, -{"ploadr", two(0xf000, 0x2200), two(0xffc0, 0xfffe), "f3&s" }, -{"ploadw", two(0xf000, 0x2010), two(0xffc0, 0xfff0), "T3&s" }, -{"ploadw", two(0xf000, 0x2008), two(0xffc0, 0xfff8), "D3&s" }, -{"ploadw", two(0xf000, 0x2000), two(0xffc0, 0xfffe), "f3&s" }, - -/* TC, CRP, DRP, SRP, CAL, VAL, SCC, AC */ -{"pmove", two(0xf000, 0x4000), two(0xffc0, 0xe3ff), "*sP8" }, -{"pmove", two(0xf000, 0x4200), two(0xffc0, 0xe3ff), "P8%s" }, -{"pmove", two(0xf000, 0x4000), two(0xffc0, 0xe3ff), "|sW8" }, -{"pmove", two(0xf000, 0x4200), two(0xffc0, 0xe3ff), "W8~s" }, - -/* BADx, BACx */ -{"pmove", two(0xf000, 0x6200), two(0xffc0, 0xe3e3), "*sX3" }, -{"pmove", two(0xf000, 0x6000), two(0xffc0, 0xe3e3), "X3%s" }, - -/* PSR, PCSR */ -/* {"pmove", two(0xf000, 0x6100), two(oxffc0, oxffff), "*sZ8" }, */ -{"pmove", two(0xf000, 0x6000), two(0xffc0, 0xffff), "*sY8" }, -{"pmove", two(0xf000, 0x6200), two(0xffc0, 0xffff), "Y8%s" }, -{"pmove", two(0xf000, 0x6600), two(0xffc0, 0xffff), "Z8%s" }, - -{"prestore", one(0xf140), one(0xffc0), "&s"}, -{"prestore", one(0xf158), one(0xfff8), "+s"}, -{"psave", one(0xf100), one(0xffc0), "&s"}, -{"psave", one(0xf100), one(0xffc0), "+s"}, - -{"psac", two(0xf040, 0x0007), two(0xffc0, 0xffff), "@s"}, -{"psas", two(0xf040, 0x0006), two(0xffc0, 0xffff), "@s"}, -{"psbc", two(0xf040, 0x0001), two(0xffc0, 0xffff), "@s"}, -{"psbs", two(0xf040, 0x0000), two(0xffc0, 0xffff), "@s"}, -{"pscc", two(0xf040, 0x000f), two(0xffc0, 0xffff), "@s"}, -{"pscs", two(0xf040, 0x000e), two(0xffc0, 0xffff), "@s"}, -{"psgc", two(0xf040, 0x000d), two(0xffc0, 0xffff), "@s"}, -{"psgs", two(0xf040, 0x000c), two(0xffc0, 0xffff), "@s"}, -{"psic", two(0xf040, 0x000b), two(0xffc0, 0xffff), "@s"}, -{"psis", two(0xf040, 0x000a), two(0xffc0, 0xffff), "@s"}, -{"pslc", two(0xf040, 0x0003), two(0xffc0, 0xffff), "@s"}, -{"psls", two(0xf040, 0x0002), two(0xffc0, 0xffff), "@s"}, -{"pssc", two(0xf040, 0x0005), two(0xffc0, 0xffff), "@s"}, -{"psss", two(0xf040, 0x0004), two(0xffc0, 0xffff), "@s"}, -{"pswc", two(0xf040, 0x0009), two(0xffc0, 0xffff), "@s"}, -{"psws", two(0xf040, 0x0008), two(0xffc0, 0xffff), "@s"}, - -{"ptestr", two(0xf000, 0x8210), two(0xffc0, 0xe3f0), "T3&sQ8" }, -{"ptestr", two(0xf000, 0x8310), two(0xffc0, 0xe310), "T3&sQ8A9" }, -{"ptestr", two(0xf000, 0x8208), two(0xffc0, 0xe3f8), "D3&sQ8" }, -{"ptestr", two(0xf000, 0x8308), two(0xffc0, 0xe318), "D3&sQ8A9" }, -{"ptestr", two(0xf000, 0x8200), two(0xffc0, 0xe3fe), "f3&sQ8" }, -{"ptestr", two(0xf000, 0x8300), two(0xffc0, 0xe31e), "f3&sQ8A9" }, - -{"ptestw", two(0xf000, 0x8010), two(0xffc0, 0xe3f0), "T3&sQ8" }, -{"ptestw", two(0xf000, 0x8110), two(0xffc0, 0xe310), "T3&sQ8A9" }, -{"ptestw", two(0xf000, 0x8008), two(0xffc0, 0xe3f8), "D3&sQ8" }, -{"ptestw", two(0xf000, 0x8108), two(0xffc0, 0xe318), "D3&sQ8A9" }, -{"ptestw", two(0xf000, 0x8000), two(0xffc0, 0xe3fe), "f3&sQ8" }, -{"ptestw", two(0xf000, 0x8100), two(0xffc0, 0xe31e), "f3&sQ8A9" }, - -{"ptrapacw", two(0xf07a, 0x0007), two(0xffff, 0xffff), "#w"}, -{"ptrapacl", two(0xf07b, 0x0007), two(0xffff, 0xffff), "#l"}, -{"ptrapac", two(0xf07c, 0x0007), two(0xffff, 0xffff), ""}, - -{"ptrapasw", two(0xf07a, 0x0006), two(0xffff, 0xffff), "#w"}, -{"ptrapasl", two(0xf07b, 0x0006), two(0xffff, 0xffff), "#l"}, -{"ptrapas", two(0xf07c, 0x0006), two(0xffff, 0xffff), ""}, - -{"ptrapbcw", two(0xf07a, 0x0001), two(0xffff, 0xffff), "#w"}, -{"ptrapbcl", two(0xf07b, 0x0001), two(0xffff, 0xffff), "#l"}, -{"ptrapbc", two(0xf07c, 0x0001), two(0xffff, 0xffff), ""}, - -{"ptrapbsw", two(0xf07a, 0x0000), two(0xffff, 0xffff), "#w"}, -{"ptrapbsl", two(0xf07b, 0x0000), two(0xffff, 0xffff), "#l"}, -{"ptrapbs", two(0xf07c, 0x0000), two(0xffff, 0xffff), ""}, - -{"ptrapccw", two(0xf07a, 0x000f), two(0xffff, 0xffff), "#w"}, -{"ptrapccl", two(0xf07b, 0x000f), two(0xffff, 0xffff), "#l"}, -{"ptrapcc", two(0xf07c, 0x000f), two(0xffff, 0xffff), ""}, - -{"ptrapcsw", two(0xf07a, 0x000e), two(0xffff, 0xffff), "#w"}, -{"ptrapcsl", two(0xf07b, 0x000e), two(0xffff, 0xffff), "#l"}, -{"ptrapcs", two(0xf07c, 0x000e), two(0xffff, 0xffff), ""}, - -{"ptrapgcw", two(0xf07a, 0x000d), two(0xffff, 0xffff), "#w"}, -{"ptrapgcl", two(0xf07b, 0x000d), two(0xffff, 0xffff), "#l"}, -{"ptrapgc", two(0xf07c, 0x000d), two(0xffff, 0xffff), ""}, - -{"ptrapgsw", two(0xf07a, 0x000c), two(0xffff, 0xffff), "#w"}, -{"ptrapgsl", two(0xf07b, 0x000c), two(0xffff, 0xffff), "#l"}, -{"ptrapgs", two(0xf07c, 0x000c), two(0xffff, 0xffff), ""}, - -{"ptrapicw", two(0xf07a, 0x000b), two(0xffff, 0xffff), "#w"}, -{"ptrapicl", two(0xf07b, 0x000b), two(0xffff, 0xffff), "#l"}, -{"ptrapic", two(0xf07c, 0x000b), two(0xffff, 0xffff), ""}, - -{"ptrapisw", two(0xf07a, 0x000a), two(0xffff, 0xffff), "#w"}, -{"ptrapisl", two(0xf07b, 0x000a), two(0xffff, 0xffff), "#l"}, -{"ptrapis", two(0xf07c, 0x000a), two(0xffff, 0xffff), ""}, - -{"ptraplcw", two(0xf07a, 0x0003), two(0xffff, 0xffff), "#w"}, -{"ptraplcl", two(0xf07b, 0x0003), two(0xffff, 0xffff), "#l"}, -{"ptraplc", two(0xf07c, 0x0003), two(0xffff, 0xffff), ""}, - -{"ptraplsw", two(0xf07a, 0x0002), two(0xffff, 0xffff), "#w"}, -{"ptraplsl", two(0xf07b, 0x0002), two(0xffff, 0xffff), "#l"}, -{"ptrapls", two(0xf07c, 0x0002), two(0xffff, 0xffff), ""}, - -{"ptrapscw", two(0xf07a, 0x0005), two(0xffff, 0xffff), "#w"}, -{"ptrapscl", two(0xf07b, 0x0005), two(0xffff, 0xffff), "#l"}, -{"ptrapsc", two(0xf07c, 0x0005), two(0xffff, 0xffff), ""}, - -{"ptrapssw", two(0xf07a, 0x0004), two(0xffff, 0xffff), "#w"}, -{"ptrapssl", two(0xf07b, 0x0004), two(0xffff, 0xffff), "#l"}, -{"ptrapss", two(0xf07c, 0x0004), two(0xffff, 0xffff), ""}, - -{"ptrapwcw", two(0xf07a, 0x0009), two(0xffff, 0xffff), "#w"}, -{"ptrapwcl", two(0xf07b, 0x0009), two(0xffff, 0xffff), "#l"}, -{"ptrapwc", two(0xf07c, 0x0009), two(0xffff, 0xffff), ""}, - -{"ptrapwsw", two(0xf07a, 0x0008), two(0xffff, 0xffff), "#w"}, -{"ptrapwsl", two(0xf07b, 0x0008), two(0xffff, 0xffff), "#l"}, -{"ptrapws", two(0xf07c, 0x0008), two(0xffff, 0xffff), ""}, - -{"pvalid", two(0xf000, 0x2800), two(0xffc0, 0xffff), "Vs&s"}, -{"pvalid", two(0xf000, 0x2c00), two(0xffc0, 0xfff8), "A3&s" }, - -#endif /* m68851 */ -/* end pmmu.h */ diff --git a/gas/config/tc-m68k.c b/gas/config/tc-m68k.c deleted file mode 100644 index 3b9f7dc4c08..00000000000 --- a/gas/config/tc-m68k.c +++ /dev/null @@ -1,3973 +0,0 @@ -/* m68k.c All the m68020 specific stuff in one convenient, huge, - slow to compile, easy to find file. - Copyright (C) 1987, 1991 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include - -#include "as.h" - -#include "obstack.h" - - /* note that this file includes real declarations and thus can only be included by one source file per executable. */ -#include "m68k-opcode.h" -#ifdef TE_SUN -/* This variable contains the value to write out at the beginning of - the a.out file. The 2<<16 means that this is a 68020 file instead - of an old-style 68000 file */ - -long omagic = 2<<16|OMAGIC; /* Magic byte for header file */ -#else -long omagic = OMAGIC; -#endif - -/* This array holds the chars that always start a comment. If the - pre-processor is disabled, these aren't very useful */ -const char comment_chars[] = "|"; - -/* This array holds the chars that only start a comment at the beginning of - a line. If the line seems to have the form '# 123 filename' - .line and .file directives will appear in the pre-processed output */ -/* Note that input_file.c hand checks for '#' at the beginning of the - first line of the input file. This is because the compiler outputs - #NO_APP at the beginning of its output. */ -/* Also note that comments like this one will always work. */ -const char line_comment_chars[] = "#"; - -/* Chars that can be used to separate mant from exp in floating point nums */ -const char EXP_CHARS[] = "eE"; - -/* Chars that mean this number is a floating point constant */ -/* As in 0f12.456 */ -/* or 0d1.2345e12 */ - -const char FLT_CHARS[] = "rRsSfFdDxXeEpP"; - -/* Also be aware that MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT may have to be - changed in read.c . Ideally it shouldn't have to know about it at all, - but nothing is ideal around here. - */ - -int md_reloc_size = 8; /* Size of relocation record */ - -/* Its an arbitrary name: This means I don't approve of it */ -/* See flames below */ -static struct obstack robyn; - -#define TAB(x,y) (((x)<<2)+(y)) -#define TABTYPE(xy) ((xy) >> 2) -#define BYTE 0 -#define SHORT 1 -#define LONG 2 -#define SZ_UNDEF 3 - -#define BRANCH 1 -#define FBRANCH 2 -#define PCREL 3 -#define BCC68000 4 -#define DBCC 5 -#define PCLEA 6 - -/* Operands we can parse: (And associated modes) - -numb: 8 bit num -numw: 16 bit num -numl: 32 bit num -dreg: data reg 0-7 -reg: address or data register -areg: address register -apc: address register, PC, ZPC or empty string -num: 16 or 32 bit num -num2: like num -sz: w or l if omitted, l assumed -scale: 1 2 4 or 8 if omitted, 1 assumed - -7.4 IMMED #num --> NUM -0.? DREG dreg --> dreg -1.? AREG areg --> areg -2.? AINDR areg@ --> *(areg) -3.? AINC areg@+ --> *(areg++) -4.? ADEC areg@- --> *(--areg) -5.? AOFF apc@(numw) --> *(apc+numw) -- empty string and ZPC not allowed here -6.? AINDX apc@(num,reg:sz:scale) --> *(apc+num+reg*scale) -6.? AINDX apc@(reg:sz:scale) --> same, with num=0 -6.? APODX apc@(num)@(num2,reg:sz:scale) --> *(*(apc+num)+num2+reg*scale) -6.? APODX apc@(num)@(reg:sz:scale) --> same, with num2=0 -6.? AMIND apc@(num)@(num2) --> *(*(apc+num)+num2) (previous mode without an index reg) -6.? APRDX apc@(num,reg:sz:scale)@(num2) --> *(*(apc+num+reg*scale)+num2) -6.? APRDX apc@(reg:sz:scale)@(num2) --> same, with num=0 -7.0 ABSL num:sz --> *(num) - num --> *(num) (sz L assumed) -*** MSCR otherreg --> Magic -With -l option -5.? AOFF apc@(num) --> *(apc+num) -- empty string and ZPC not allowed here still - -examples: - #foo #0x35 #12 - d2 - a4 - a3@ - a5@+ - a6@- - a2@(12) pc@(14) - a1@(5,d2:w:1) @(45,d6:l:4) - pc@(a2) @(d4) - etc . . . - - -#name@(numw) -->turn into PC rel mode -apc@(num8,reg:sz:scale) --> *(apc+num8+reg*scale) - -*/ - -enum operand_type { - IMMED = 1, - DREG, - AREG, - AINDR, - ADEC, - AINC, - AOFF, - AINDX, - APODX, - AMIND, - APRDX, - ABSL, - MSCR, - REGLST, -}; - - -struct m68k_exp { - char *e_beg; - char *e_end; - expressionS e_exp; - short e_siz; /* 0== default 1==short/byte 2==word 3==long */ -}; - -/* DATA and ADDR have to be contiguous, so that reg-DATA gives 0-7==data reg, - 8-15==addr reg for operands that take both types */ - -enum _register { - DATA = 1, /* 1- 8 == data registers 0-7 */ - DATA0 = DATA, - DATA1, - DATA2, - DATA3, - DATA4, - DATA5, - DATA6, - DATA7, - - ADDR, - ADDR0 = ADDR, - ADDR1, - ADDR2, - ADDR3, - ADDR4, - ADDR5, - ADDR6, - ADDR7, - -/* Note that COPNUM==processor #1 -- COPNUM+7==#8, which stores as 000 */ -/* I think. . . */ - - SP = ADDR7, - - FPREG, /* Eight FP registers */ - FP0 = FPREG, - FP1, - FP2, - FP3, - FP4, - FP5, - FP6, - FP7, - COPNUM = (FPREG+8), /* Co-processor #1-#8 */ - COP0 = COPNUM, - COP1, - COP2, - COP3, - COP4, - COP5, - COP6, - COP7, - PC, /* Program counter */ - ZPC, /* Hack for Program space, but 0 addressing */ - SR, /* Status Reg */ - CCR, /* Condition code Reg */ - -/* These have to be in order for the movec instruction to work. */ - USP, /* User Stack Pointer */ - ISP, /* Interrupt stack pointer */ - SFC, - DFC, - CACR, - VBR, - CAAR, - MSP, - ITT0, - ITT1, - DTT0, - DTT1, - MMUSR, - TC, - SRP, - URP, -/* end of movec ordering constraints */ - - FPI, - FPS, - FPC, - - DRP, - CRP, - CAL, - VAL, - SCC, - AC, - BAD, - BAD0 = BAD, - BAD1, - BAD2, - BAD3, - BAD4, - BAD5, - BAD6, - BAD7, - BAC, - BAC0 = BAC, - BAC1, - BAC2, - BAC3, - BAC4, - BAC5, - BAC6, - BAC7, - PSR, - PCSR, - - IC, /* instruction cache token */ - DC, /* data cache token */ - NC, /* no cache token */ - BC, /* both caches token */ - -}; - -/* Internal form of an operand. */ -struct m68k_op { - char *error; /* Couldn't parse it */ - enum operand_type mode; /* What mode this instruction is in. */ - enum _register reg; /* Base register */ - struct m68k_exp *con1; - int ireg; /* Index register */ - int isiz; /* 0==unspec 1==byte(?) 2==short 3==long */ - int imul; /* Multipy ireg by this (1,2,4,or 8) */ - struct m68k_exp *con2; -}; - -/* internal form of a 68020 instruction */ -struct m68k_it { - char *error; - char *args; /* list of opcode info */ - int numargs; - - int numo; /* Number of shorts in opcode */ - short opcode[11]; - - struct m68k_op operands[6]; - - int nexp; /* number of exprs in use */ - struct m68k_exp exprs[4]; - - int nfrag; /* Number of frags we have to produce */ - struct { - int fragoff; /* Where in the current opcode[] the frag ends */ - symbolS *fadd; - long foff; - int fragty; - } fragb[4]; - - int nrel; /* Num of reloc strucs in use */ - struct { - int n; - symbolS *add, - *sub; - long off; - char wid; - char pcrel; - } reloc[5]; /* Five is enough??? */ -}; - -static struct m68k_it the_ins; /* the instruction being assembled */ -static enum m68k_architecture max_arch_this_insn; - -/* Macros for adding things to the m68k_it struct */ - -#define addword(w) the_ins.opcode[the_ins.numo++]=(w) - -/* Like addword, but goes BEFORE general operands */ -#define insop(w) {int z;\ - for(z=the_ins.numo;z>opcode->m_codenum;--z)\ - the_ins.opcode[z]=the_ins.opcode[z-1];\ - for(z=0;zm_codenum]=w;\ - the_ins.numo++;\ -} - - -#define add_exp(beg,end) (\ - the_ins.exprs[the_ins.nexp].e_beg=beg,\ - the_ins.exprs[the_ins.nexp].e_end=end,\ - &the_ins.exprs[the_ins.nexp++]\ -) - - -/* The numo+1 kludge is so we can hit the low order byte of the prev word. Blecch*/ -#define add_fix(width,exp,pc_rel) {\ - the_ins.reloc[the_ins.nrel].n= ((width)=='B') ? (the_ins.numo*2-1) : \ - (((width)=='b') ? ((the_ins.numo-1)*2) : (the_ins.numo*2));\ - the_ins.reloc[the_ins.nrel].add=adds((exp));\ - the_ins.reloc[the_ins.nrel].sub=subs((exp));\ - the_ins.reloc[the_ins.nrel].off=offs((exp));\ - the_ins.reloc[the_ins.nrel].wid=width;\ - the_ins.reloc[the_ins.nrel++].pcrel=pc_rel;\ -} - -#define add_frag(add,off,type) {\ - the_ins.fragb[the_ins.nfrag].fragoff=the_ins.numo;\ - the_ins.fragb[the_ins.nfrag].fadd=add;\ - the_ins.fragb[the_ins.nfrag].foff=off;\ - the_ins.fragb[the_ins.nfrag++].fragty=type;\ -} - -#define isvar(exp) ((exp) && (adds(exp) || subs(exp))) - -#define seg(exp) ((exp)->e_exp.X_seg) -#define adds(exp) ((exp)->e_exp.X_add_symbol) -#define subs(exp) ((exp)->e_exp.X_subtract_symbol) -#define offs(exp) ((exp)->e_exp.X_add_number) - - -struct m68k_incant { - char *m_operands; - unsigned long m_opcode; - short m_opnum; - short m_codenum; - enum m68k_architecture m_arch; - struct m68k_incant *m_next; -}; - -#define getone(x) ((((x)->m_opcode)>>16)&0xffff) -#define gettwo(x) (((x)->m_opcode)&0xffff) - - -#ifdef __STDC__ - -static char *crack_operand(char *str, struct m68k_op *opP); -static int get_num(struct m68k_exp *exp, int ok); -static int get_regs(int i, char *str, struct m68k_op *opP); -static int reverse_16_bits(int in); -static int reverse_8_bits(int in); -static int try_index(char **s, struct m68k_op *opP); -static void install_gen_operand(int mode, int val); -static void install_operand(int mode, int val); -static void s_bss(void); -static void s_data1(void); -static void s_data2(void); -static void s_even(void); -static void s_proc(void); - -#else /* __STDC__ */ - -static char *crack_operand(); -static int get_num(); -static int get_regs(); -static int reverse_16_bits(); -static int reverse_8_bits(); -static int try_index(); -static void install_gen_operand(); -static void install_operand(); -static void s_bss(); -static void s_data1(); -static void s_data2(); -static void s_even(); -static void s_proc(); - -#endif /* __STDC__ */ - -static enum m68k_architecture current_architecture = m68020 -#ifndef NO_68881 - | m68881 -#endif -#ifndef NO_68851 - | m68851 -#endif - ; - -/* BCC68000 is for patching in an extra jmp instruction for long offsets - on the 68000. The 68000 doesn't support long branches with branchs */ - -/* This table desribes how you change sizes for the various types of variable - size expressions. This version only supports two kinds. */ - -/* Note that calls to frag_var need to specify the maximum expansion needed */ -/* This is currently 10 bytes for DBCC */ - -/* The fields are: - How far Forward this mode will reach: - How far Backward this mode will reach: - How many bytes this mode will add to the size of the frag - Which mode to go to if the offset won't fit in this one - */ -const relax_typeS -md_relax_table[] = { -{ 1, 1, 0, 0 }, /* First entries aren't used */ -{ 1, 1, 0, 0 }, /* For no good reason except */ -{ 1, 1, 0, 0 }, /* that the VAX doesn't either */ -{ 1, 1, 0, 0 }, - -{ (127), (-128), 0, TAB(BRANCH,SHORT)}, -{ (32767), (-32768), 2, TAB(BRANCH,LONG) }, -{ 0, 0, 4, 0 }, -{ 1, 1, 0, 0 }, - -{ 1, 1, 0, 0 }, /* FBRANCH doesn't come BYTE */ -{ (32767), (-32768), 2, TAB(FBRANCH,LONG)}, -{ 0, 0, 4, 0 }, -{ 1, 1, 0, 0 }, - -{ 1, 1, 0, 0 }, /* PCREL doesn't come BYTE */ -{ (32767), (-32768), 2, TAB(PCREL,LONG)}, -{ 0, 0, 4, 0 }, -{ 1, 1, 0, 0 }, - -{ (127), (-128), 0, TAB(BCC68000,SHORT)}, -{ (32767), (-32768), 2, TAB(BCC68000,LONG) }, -{ 0, 0, 6, 0 }, /* jmp long space */ -{ 1, 1, 0, 0 }, - -{ 1, 1, 0, 0 }, /* DBCC doesn't come BYTE */ -{ (32767), (-32768), 2, TAB(DBCC,LONG) }, -{ 0, 0, 10, 0 }, /* bra/jmp long space */ -{ 1, 1, 0, 0 }, - -{ 1, 1, 0, 0 }, /* PCLEA doesn't come BYTE */ -{ 32767, -32768, 2, TAB(PCLEA,LONG) }, -{ 0, 0, 6, 0 }, -{ 1, 1, 0, 0 }, - -}; - -/* These are the machine dependent pseudo-ops. These are included so - the assembler can work on the output from the SUN C compiler, which - generates these. - */ - -/* This table describes all the machine specific pseudo-ops the assembler - has to support. The fields are: - pseudo-op name without dot - function to call to execute this pseudo-op - Integer arg to pass to the function - */ -const pseudo_typeS md_pseudo_table[] = { - { "data1", s_data1, 0 }, - { "data2", s_data2, 0 }, - { "bss", s_bss, 0 }, - { "even", s_even, 0 }, - { "skip", s_space, 0 }, - { "proc", s_proc, 0 }, - { 0, 0, 0 } -}; - - -/* #define isbyte(x) ((x)>=-128 && (x)<=127) */ -/* #define isword(x) ((x)>=-32768 && (x)<=32767) */ - -#define issbyte(x) ((x)>=-128 && (x)<=127) -#define isubyte(x) ((x)>=0 && (x)<=255) -#define issword(x) ((x)>=-32768 && (x)<=32767) -#define isuword(x) ((x)>=0 && (x)<=65535) - -#define isbyte(x) ((x)>=-128 && (x)<=255) -#define isword(x) ((x)>=-32768 && (x)<=65535) -#define islong(x) (1) - -extern char *input_line_pointer; - -enum { - FAIL = 0, - OK = 1, -}; - -/* JF these tables here are for speed at the expense of size */ -/* You can replace them with the #if 0 versions if you really - need space and don't mind it running a bit slower */ - -static char mklower_table[256]; -#define mklower(c) (mklower_table[(unsigned char)(c)]) -static char notend_table[256]; -static char alt_notend_table[256]; -#define notend(s) ( !(notend_table[(unsigned char)(*s)] || (*s==':' &&\ - alt_notend_table[(unsigned char)(s[1])]))) - -#if 0 -#define mklower(c) (isupper(c) ? tolower(c) : c) -#endif - - -/* JF modified this to handle cases where the first part of a symbol name - looks like a register */ - -/* - * m68k_reg_parse() := if it looks like a register, return it's token & - * advance the pointer. - */ - -enum _register m68k_reg_parse(ccp) -register char **ccp; -{ -#ifndef MAX_REG_NAME_LEN -#define MAX_REG_NAME_LEN (6) -#endif /* MAX_REG_NAME_LEN */ - register char c[MAX_REG_NAME_LEN]; - char *p, *q; - register int n = 0, - ret = FAIL; - - c[0] = mklower(ccp[0][0]); -#ifdef REGISTER_PREFIX - if (c[0] != REGISTER_PREFIX) { - return(FAIL); - } /* need prefix */ -#endif - - for (p = c, q = ccp[0]; p < c + MAX_REG_NAME_LEN && *q != 0; ++p, ++q) { - *p = mklower(*q); - } /* downcase */ - - switch(c[0]) { - case 'a': - if(c[1]>='0' && c[1]<='7') { - n=2; - ret=ADDR+c[1]-'0'; - } -#ifndef NO_68851 - else if (c[1] == 'c') { - n = 2; - ret = AC; - } -#endif - break; -#ifndef NO_68851 - case 'b': - if (c[1] == 'a') { - if (c[2] == 'd') { - if (c[3] >= '0' && c[3] <= '7') { - n = 4; - ret = BAD + c[3] - '0'; - } - } /* BAD */ - if (c[2] == 'c') { - if (c[3] >= '0' && c[3] <= '7') { - n = 4; - ret = BAC + c[3] - '0'; - } - } /* BAC */ - } else if (c[1] == 'c') { - n = 2; - ret = BC; - } /* BC */ - break; -#endif - case 'c': -#ifndef NO_68851 - if (c[1] == 'a' && c[2] == 'l') { - n = 3; - ret = CAL; - } else -#endif - /* This supports both CCR and CC as the ccr reg. */ - if(c[1]=='c' && c[2]=='r') { - n=3; - ret = CCR; - } else if(c[1]=='c') { - n=2; - ret = CCR; - } else if(c[1]=='a' && (c[2]=='a' || c[2]=='c') && c[3]=='r') { - n=4; - ret = c[2]=='a' ? CAAR : CACR; - } -#ifndef NO_68851 - else if (c[1] == 'r' && c[2] == 'p') { - n = 3; - ret = (CRP); - } -#endif - break; - case 'd': - if (c[1] >= '0' && c[1] <= '7') { - n = 2; - ret = DATA + c[1] - '0'; - } else if (c[1] == 'f' && c[2] == 'c') { - n = 3; - ret = DFC; - } else if (c[1] == 'c') { - n = 2; - ret = DC; - } else if (c[1] == 't' && c[2] == 't') { - if ('0' <= c[3] && c[3] <= '1') { - n = 4; - ret = DTT0 + (c[3] - '0'); - } /* DTT[01] */ - } -#ifndef NO_68851 - else if (c[1] == 'r' && c[2] == 'p') { - n = 3; - ret = (DRP); - } -#endif - break; - case 'f': - if(c[1]=='p') { - if(c[2]>='0' && c[2]<='7') { - n=3; - ret = FPREG+c[2]-'0'; - if(c[3]==':') - ccp[0][3]=','; - } else if(c[2]=='i') { - n=3; - ret = FPI; - } else if(c[2]=='s') { - n= (c[3] == 'r' ? 4 : 3); - ret = FPS; - } else if(c[2]=='c') { - n= (c[3] == 'r' ? 4 : 3); - ret = FPC; - } - } - break; - case 'i': - if (c[1] == 's' && c[2] == 'p') { - n = 3; - ret = ISP; - } else if (c[1] == 'c') { - n = 2; - ret = IC; - } else if (c[1] == 't' && c[2] == 't') { - if ('0' <= c[3] && c[3] <= '1') { - n = 4; - ret = ITT0 + (c[3] - '0'); - } /* ITT[01] */ - } - break; - case 'm': - if (c[1] == 's' && c[2] == 'p') { - n = 3; - ret = MSP; - } else if (c[1] == 'm' && c[2] == 'u' && c[3] == 's' && c[4] == 'r') { - n = 5; - ret = MMUSR; - } - break; - case 'n': - if (c[1] == 'c') { - n = 2; - ret = NC; - } - break; - case 'p': - if(c[1]=='c') { -#ifndef NO_68851 - if(c[2] == 's' && c[3]=='r') { - n=4; - ret = (PCSR); - } else -#endif - { - n=2; - ret = PC; - } - } -#ifndef NO_68851 - else if (c[1] == 's' && c[2] == 'r') { - n = 3; - ret = (PSR); - } -#endif - break; - case 's': -#ifndef NO_68851 - if (c[1] == 'c' && c[2] == 'c') { - n = 3; - ret = (SCC); - } else -#endif - if (c[1] == 'r') { - if (c[2] == 'p') { - n = 3; - ret = SRP; - } else { - n = 2; - ret = SR; - } /* srp else sr */ - } else if (c[1] == 'p') { - n = 2; - ret = SP; - } else if (c[1] == 'f' && c[2] == 'c') { - n = 3; - ret = SFC; - } - break; - case 't': - if (c[1] == 'c') { - n = 2; - ret = TC; - } - break; - case 'u': - if (c[1] == 's' && c[2] == 'p') { - n=3; - ret = USP; - } else if (c[1] == 'r' && c[2] == 'p') { - n = 3; - ret = URP; - } - break; - case 'v': -#ifndef NO_68851 - if (c[1] == 'a' && c[2] == 'l') { - n = 3; - ret = (VAL); - } else -#endif - if(c[1]=='b' && c[2]=='r') { - n=3; - ret = VBR; - } - break; - case 'z': - if(c[1]=='p' && c[2]=='c') { - n=3; - ret = ZPC; - } - break; - default: - break; - } - if(n) { -#ifdef REGISTER_PREFIX - n++; -#endif - if(isalnum(ccp[0][n]) || ccp[0][n]=='_') - ret=FAIL; - else - ccp[0]+=n; - } else - ret = FAIL; - return ret; -} - -#define SKIP_WHITE() { str++; if(*str==' ') str++;} - -/* - * m68k_ip_op := '#' + - * | + range_sep + get_regs - * ; - * - * range_sep := '/' | '-' ; - * - * SKIP_WHITE := | ' ' ; - * - */ - -int -m68k_ip_op(str,opP) -char *str; -register struct m68k_op *opP; -{ - char *strend; - long i; - char *parse_index(); - - if (*str==' ') { - str++; - } /* Find the beginning of the string */ - - if(!*str) { - opP->error="Missing operand"; - return FAIL; - } /* Out of gas */ - - for(strend = str; *strend; strend++) ;; - - --strend; - - if(*str=='#') { - str++; - opP->con1=add_exp(str,strend); - opP->mode=IMMED; - return OK; - } /* Guess what: A constant. Shar and enjoy */ - - i = m68k_reg_parse(&str); - - /* is a register, is exactly a register, and is followed by '@' */ - - if((i==FAIL || *str!='\0') && *str!='@') { - char *stmp; - - if(i!=FAIL && (*str=='/' || *str=='-')) { - opP->mode=REGLST; - return get_regs(i,str,opP); - } - if ((stmp=strchr(str,'@')) != '\0') { - opP->con1=add_exp(str,stmp-1); - if(stmp==strend) { - opP->mode=AINDX; - return OK; - } - stmp++; - if(*stmp++!='(' || *strend--!=')') { - opP->error="Malformed operand"; - return FAIL; - } - i=try_index(&stmp,opP); - opP->con2=add_exp(stmp,strend); - - if (i == FAIL) { - opP->mode=AMIND; - if (max_arch_this_insn < m68020) { - max_arch_this_insn = m68020; - } /* bump arch */ - } else { - opP->mode=APODX; - if (max_arch_this_insn < m68020) { - max_arch_this_insn = m68020; - } /* bump arch */ - } - return OK; - } /* if there's an '@' */ - opP->mode=ABSL; - opP->con1=add_exp(str,strend); - return OK; - } /* not a register, not exactly a register, or no '@' */ - - opP->reg=i; - - if (*str=='\0') { - if(i>=DATA+0 && i<=DATA+7) - opP->mode=DREG; - else if(i>=ADDR+0 && i<=ADDR+7) - opP->mode=AREG; - else - opP->mode=MSCR; - return OK; - } - - if((iADDR+7) && i!=PC && i!=ZPC && i!=FAIL) { /* Can't indirect off non address regs */ - opP->error="Invalid indirect register"; - return FAIL; - } - know(*str == '@'); - - str++; - switch(*str) { - case '\0': - opP->mode=AINDR; - return OK; - case '-': - opP->mode=ADEC; - return OK; - case '+': - opP->mode=AINC; - return OK; - case '(': - str++; - break; - default: - opP->error="Junk after indirect"; - return FAIL; - } - /* Some kind of indexing involved. Lets find out how bad it is */ - i=try_index(&str,opP); - /* Didn't start with an index reg, maybe its offset or offset,reg */ - if(i==FAIL) { - char *beg_str; - - beg_str=str; - for(i=1;i;) { - switch(*str++) { - case '\0': - opP->error="Missing )"; - return FAIL; - case ',': i=0; break; - case '(': i++; break; - case ')': --i; break; - } - } - /* if(str[-3]==':') { - int siz; - - switch(str[-2]) { - case 'b': - case 'B': - siz=1; - break; - case 'w': - case 'W': - siz=2; - break; - case 'l': - case 'L': - siz=3; - break; - default: - opP->error="Specified size isn't :w or :l"; - return FAIL; - } - opP->con1=add_exp(beg_str,str-4); - opP->con1->e_siz=siz; - } else */ - opP->con1=add_exp(beg_str,str-2); - /* Should be offset,reg */ - if(str[-1]==',') { - i=try_index(&str,opP); - if(i==FAIL) { - opP->error="Malformed index reg"; - return FAIL; - } - } - } - /* We've now got offset) offset,reg) or reg) */ - - if(*str=='\0') { - /* Th-the-thats all folks */ - if(opP->reg==FAIL) opP->mode=AINDX; /* Other form of indirect */ - else if(opP->ireg==FAIL) opP->mode=AOFF; - else opP->mode=AINDX; - return OK; - } - /* Next thing had better be another @ */ - if(*str!='@' || str[1]!='(') { - opP->error="junk after indirect"; - return FAIL; - } - str+=2; - if(opP->ireg!=FAIL) { - opP->mode=APRDX; - - if (max_arch_this_insn < m68020) { - max_arch_this_insn = m68020; - } /* bump arch */ - - i=try_index(&str,opP); - if(i!=FAIL) { - opP->error="Two index registers! not allowed!"; - return FAIL; - } - } else - i=try_index(&str,opP); - - if (i == FAIL) { - char *beg_str; - - beg_str=str; - for(i=1;i;) { - switch(*str++) { - case '\0': - opP->error="Missing )"; - return FAIL; - case ',': i=0; break; - case '(': i++; break; - case ')': --i; break; - } - } - opP->con2=add_exp(beg_str,str-2); - if(str[-1]==',') { - if(opP->ireg!=FAIL) { - opP->error="Can't have two index regs"; - return FAIL; - } - i=try_index(&str,opP); - if(i==FAIL) { - opP->error="malformed index reg"; - return FAIL; - } - opP->mode=APODX; - if (max_arch_this_insn < m68020) { - max_arch_this_insn = m68020; - } /* bump arch */ - } else if(opP->ireg!=FAIL) { - opP->mode=APRDX; - - if (max_arch_this_insn < m68020) { - max_arch_this_insn = m68020; - } /* bump arch */ - } else { - opP->mode=AMIND; - - if (max_arch_this_insn < m68020) { - max_arch_this_insn = m68020; - } /* bump arch */ - } - } else { - opP->mode=APODX; - if (max_arch_this_insn < m68020) { - max_arch_this_insn = m68020; - } /* bump arch */ - } - - if(*str!='\0') { - opP->error="Junk after indirect"; - return FAIL; - } - return OK; -} - -/* - * - * try_index := data_or_address_register + ')' + SKIP_W - * | data_or_address_register + ':' + SKIP_W + size_spec + SKIP_W + multiplier + ')' + SKIP_W - * - * multiplier := - * | ':' + multiplier_number - * ; - * - * multiplier_number := '1' | '2' | '4' | '8' ; - * - * size_spec := 'l' | 'L' | 'w' | 'W' ; - * - * SKIP_W := | ' ' ; - * - */ - -static int try_index(s,opP) -char **s; -struct m68k_op *opP; -{ - register int i; - char *ss; -#define SKIP_W() { ss++; if (*ss==' ') ss++;} - - ss= *s; - /* SKIP_W(); */ - i=m68k_reg_parse(&ss); - if(!(i>=DATA+0 && i<=ADDR+7)) { /* if i is not DATA or ADDR reg */ - *s=ss; - return FAIL; - } - opP->ireg=i; - /* SKIP_W(); */ - if(*ss==')') { - opP->isiz=0; - opP->imul=1; - SKIP_W(); - *s=ss; - return OK; - } - if(*ss!=':') { - opP->error="Missing : in index register"; - *s=ss; - return FAIL; - } - SKIP_W(); - switch(*ss) { - case 'w': - case 'W': - opP->isiz=2; - break; - case 'l': - case 'L': - opP->isiz=3; - break; - default: - opP->error="Index register size spec not :w or :l"; - *s=ss; - return FAIL; - } - SKIP_W(); - if(*ss==':') { - SKIP_W(); - switch(*ss) { - case '1': - case '2': - case '4': - case '8': - opP->imul= *ss-'0'; - break; - default: - opP->error="index multiplier not 1, 2, 4 or 8"; - *s=ss; - return FAIL; - } - SKIP_W(); - } else opP->imul=1; - if(*ss!=')') { - opP->error="Missing )"; - *s=ss; - return FAIL; - } - SKIP_W(); - *s=ss; - return OK; -} /* try_index() */ - -#ifdef TEST1 /* TEST1 tests m68k_ip_op(), which parses operands */ -main() -{ - char buf[128]; - struct m68k_op thark; - - for(;;) { - if(!gets(buf)) - break; - bzero(&thark,sizeof(thark)); - if(!m68k_ip_op(buf,&thark)) printf("FAIL:"); - if(thark.error) - printf("op1 error %s in %s\n",thark.error,buf); - printf("mode %d, reg %d, ",thark.mode,thark.reg); - if(thark.b_const) - printf("Constant: '%.*s',",1+thark.e_const-thark.b_const,thark.b_const); - printf("ireg %d, isiz %d, imul %d ",thark.ireg,thark.isiz,thark.imul); - if(thark.b_iadd) - printf("Iadd: '%.*s'",1+thark.e_iadd-thark.b_iadd,thark.b_iadd); - printf("\n"); - } - exit(0); -} - -#endif - - -static struct hash_control* op_hash = NULL; /* handle of the OPCODE hash table - NULL means any use before m68k_ip_begin() - will crash */ - - -/* - * m 6 8 k _ i p ( ) - * - * This converts a string into a 68k instruction. - * The string must be a bare single instruction in sun format - * with RMS-style 68020 indirects - * (example: ) - * - * It provides some error messages: at most one fatal error message (which - * stops the scan) and at most one warning message for each operand. - * The 68k instruction is returned in exploded form, since we have no - * knowledge of how you parse (or evaluate) your expressions. - * We do however strip off and decode addressing modes and operation - * mnemonic. - * - * This function's value is a string. If it is not "" then an internal - * logic error was found: read this code to assign meaning to the string. - * No argument string should generate such an error string: - * it means a bug in our code, not in the user's text. - * - * You MUST have called m68k_ip_begin() once and m86_ip_end() never before using - * this function. - */ - -/* JF this function no longer returns a useful value. Sorry */ -void m68k_ip (instring) -char *instring; -{ - register char *p; - register struct m68k_op *opP; - register struct m68k_incant *opcode; - register char *s; - register int tmpreg = 0, - baseo = 0, - outro = 0, - nextword; - int siz1, - siz2; - char c; - int losing; - int opsfound; - char *crack_operand(); - LITTLENUM_TYPE words[6]; - LITTLENUM_TYPE *wordp; - - max_arch_this_insn = m68000; - - if (*instring == ' ') - instring++; /* skip leading whitespace */ - - /* Scan up to end of operation-code, which MUST end in end-of-string - or exactly 1 space. */ - for (p = instring; *p != '\0'; p++) - if (*p == ' ') - break; - - - if (p == instring) { - the_ins.error = "No operator"; - the_ins.opcode[0] = NULL; - /* the_ins.numo=1; */ - return; - } - - /* p now points to the end of the opcode name, probably whitespace. - make sure the name is null terminated by clobbering the whitespace, - look it up in the hash table, then fix it back. */ - c = *p; - *p = '\0'; - opcode = (struct m68k_incant *)hash_find (op_hash, instring); - *p = c; - - if (opcode == NULL) { - the_ins.error = "Unknown operator"; - the_ins.opcode[0] = NULL; - /* the_ins.numo=1; */ - return; - } - - /* found a legitimate opcode, start matching operands */ - while (*p == ' ') ++p; - - for(opP = &the_ins.operands[0]; *p; opP++) { - - p = crack_operand(p, opP); - - if (opP->error) { - the_ins.error=opP->error; - return; - } - } - - opsfound=opP- &the_ins.operands[0]; - - /* This ugly hack is to support the floating pt opcodes in their standard form */ - /* Essentially, we fake a first enty of type COP#1 */ - if (opcode->m_operands[0]=='I') { - int n; - - for(n=opsfound;n>0;--n) - the_ins.operands[n]=the_ins.operands[n-1]; - - /* bcopy((char *)(&the_ins.operands[0]),(char *)(&the_ins.operands[1]),opsfound*sizeof(the_ins.operands[0])); */ - bzero((char *)(&the_ins.operands[0]),sizeof(the_ins.operands[0])); - the_ins.operands[0].mode=MSCR; - the_ins.operands[0].reg=COPNUM; /* COP #1 */ - opsfound++; - } - - /* We've got the operands. Find an opcode that'll accept them */ - for (losing = 0; ; ) { - /* if we didn't get the right number of ops, or either - the modes of our args or this op line itself are out - of order... */ - - if ((opsfound != opcode->m_opnum) - || ((max_arch_this_insn > current_architecture) - || (opcode->m_arch > current_architecture))) { - ++losing; - - } else { - for (s=opcode->m_operands, opP = &the_ins.operands[0]; *s && !losing; s += 2, opP++) { - /* Warning: this switch is huge! */ - /* I've tried to organize the cases into this order: - non-alpha first, then alpha by letter. lower-case goes directly - before uppercase counterpart. */ - /* Code with multiple case ...: gets sorted by the lowest case ... - it belongs to. I hope this makes sense. */ - switch(*s) { - case '!': - if(opP->mode==MSCR || opP->mode==IMMED || - opP->mode==DREG || opP->mode==AREG || opP->mode==AINC || opP->mode==ADEC || opP->mode==REGLST) - losing++; - break; - - case '#': - if(opP->mode!=IMMED) - losing++; - else { - long t; - - t=get_num(opP->con1,80); - if(s[1]=='b' && !isbyte(t)) - losing++; - else if(s[1]=='w' && !isword(t)) - losing++; - } - break; - - case '^': - case 'T': - if(opP->mode!=IMMED) - losing++; - break; - - case '$': - if(opP->mode==MSCR || opP->mode==AREG || - opP->mode==IMMED || opP->reg==PC || opP->reg==ZPC || opP->mode==REGLST) - losing++; - break; - - case '%': - if(opP->mode==MSCR || opP->reg==PC || - opP->reg==ZPC || opP->mode==REGLST) - losing++; - break; - - - case '&': - if(opP->mode==MSCR || opP->mode==DREG || - opP->mode==AREG || opP->mode==IMMED || opP->reg==PC || opP->reg==ZPC || - opP->mode==AINC || opP->mode==ADEC || opP->mode==REGLST) - losing++; - break; - - case '*': - if(opP->mode==MSCR || opP->mode==REGLST) - losing++; - break; - - case '+': - if(opP->mode!=AINC) - losing++; - break; - - case '-': - if(opP->mode!=ADEC) - losing++; - break; - - case '/': - if(opP->mode==MSCR || opP->mode==AREG || - opP->mode==AINC || opP->mode==ADEC || opP->mode==IMMED || opP->mode==REGLST) - losing++; - break; - - case ';': - if(opP->mode==MSCR || opP->mode==AREG || opP->mode==REGLST) - losing++; - break; - - case '?': - if(opP->mode==MSCR || opP->mode==AREG || - opP->mode==AINC || opP->mode==ADEC || opP->mode==IMMED || opP->reg==PC || - opP->reg==ZPC || opP->mode==REGLST) - losing++; - break; - - case '@': - if(opP->mode==MSCR || opP->mode==AREG || - opP->mode==IMMED || opP->mode==REGLST) - losing++; - break; - - case '~': /* For now! (JF FOO is this right?) */ - if(opP->mode==MSCR || opP->mode==DREG || - opP->mode==AREG || opP->mode==IMMED || opP->reg==PC || opP->reg==ZPC || opP->mode==REGLST) - losing++; - break; - - case 'A': - if(opP->mode!=AREG) - losing++; - break; - case 'a': - if (opP->mode != AINDR) { - ++losing; - } /* if not address register indirect */ - break; - case 'B': /* FOO */ - if(opP->mode!=ABSL || (flagseen['S'] && instring[0] == 'j' - && instring[1] == 'b' - && instring[2] == 's' - && instring[3] == 'r')) - losing++; - break; - - case 'C': - if(opP->mode!=MSCR || opP->reg!=CCR) - losing++; - break; - - case 'd': /* FOO This mode is a KLUDGE!! */ - if(opP->mode!=AOFF && (opP->mode!=ABSL || - opP->con1->e_beg[0]!='(' || opP->con1->e_end[0]!=')')) - losing++; - break; - - case 'D': - if(opP->mode!=DREG) - losing++; - break; - - case 'F': - if(opP->mode!=MSCR || opP->reg<(FPREG+0) || opP->reg>(FPREG+7)) - losing++; - break; - - case 'I': - if(opP->mode!=MSCR || opP->regreg>=COPNUM+7) - losing++; - break; - - case 'J': - if (opP->mode != MSCR - || opP->reg < USP - || opP->reg > URP - || (current_architecture & m68000up) < m68010 /* before 68010 had none */ - || ((current_architecture & m68020up) == 0 - && opP->reg != SFC - && opP->reg != DFC - && opP->reg != USP - && opP->reg != VBR) /* 68010's had only these */ - || ((current_architecture & m68040) == 0 - && opP->reg != SFC - && opP->reg != DFC - && opP->reg != USP - && opP->reg != VBR - && opP->reg != CACR - && opP->reg != CAAR - && opP->reg != MSP - && opP->reg != ISP) /* 680[23]0's have only these */ - || ((current_architecture & m68040) /* 68040 has all but this */ - && opP->reg == CAAR)) { - losing++; - } /* doesn't cut it */ - break; - - case 'k': - if(opP->mode!=IMMED) - losing++; - break; - - case 'l': - case 'L': - if(opP->mode==DREG || opP->mode==AREG || opP->mode==FPREG) { - if(s[1]=='8') - losing++; - else { - opP->mode=REGLST; - opP->reg=1<<(opP->reg-DATA); - } - } else if(opP->mode!=REGLST) { - losing++; - } else if(s[1]=='8' && opP->reg&0x0FFffFF) - losing++; - else if(s[1]=='3' && opP->reg&0x7000000) - losing++; - break; - - case 'M': - if(opP->mode!=IMMED) - losing++; - else { - long t; - - t=get_num(opP->con1,80); - if(!issbyte(t) || isvar(opP->con1)) - losing++; - } - break; - - case 'O': - if(opP->mode!=DREG && opP->mode!=IMMED) - losing++; - break; - - case 'Q': - if(opP->mode!=IMMED) - losing++; - else { - long t; - - t=get_num(opP->con1,80); - if(t<1 || t>8 || isvar(opP->con1)) - losing++; - } - break; - - case 'R': - if(opP->mode!=DREG && opP->mode!=AREG) - losing++; - break; - - case 's': - if(opP->mode!=MSCR || !(opP->reg==FPI || opP->reg==FPS || opP->reg==FPC)) - losing++; - break; - - case 'S': - if(opP->mode!=MSCR || opP->reg!=SR) - losing++; - break; - - case 'U': - if(opP->mode!=MSCR || opP->reg!=USP) - losing++; - break; - - /* JF these are out of order. We could put them - in order if we were willing to put up with - bunches of #ifdef m68851s in the code */ -#ifndef NO_68851 - /* Memory addressing mode used by pflushr */ - case '|': - if(opP->mode==MSCR || opP->mode==DREG || - opP->mode==AREG || opP->mode==REGLST) - losing++; - break; - - case 'f': - if (opP->mode != MSCR || (opP->reg != SFC && opP->reg != DFC)) - losing++; - break; - - case 'P': - if (opP->mode != MSCR || (opP->reg != TC && opP->reg != CAL && - opP->reg != VAL && opP->reg != SCC && opP->reg != AC)) - losing++; - break; - - case 'V': - if (opP->reg != VAL) - losing++; - break; - - case 'W': - if (opP->mode != MSCR || (opP->reg != DRP && opP->reg != SRP && - opP->reg != CRP)) - losing++; - break; - - case 'X': - if (opP->mode != MSCR || - (!(opP->reg >= BAD && opP->reg <= BAD+7) && - !(opP->reg >= BAC && opP->reg <= BAC+7))) - losing++; - break; - - case 'Y': - if (opP->reg != PSR) - losing++; - break; - - case 'Z': - if (opP->reg != PCSR) - losing++; - break; -#endif - case 'c': - if (opP->reg != NC - && opP->reg != IC - && opP->reg != DC - && opP->reg != BC) { - losing++; - } /* not a cache specifier. */ - break; - - case '_': - if (opP->mode != ABSL) { - ++losing; - } /* not absolute */ - break; - - default: - as_fatal("Internal error: Operand mode %c unknown in line %s of file \"%s\"", - *s, __LINE__, __FILE__); - } /* switch on type of operand */ - - if (losing) break; - } /* for each operand */ - } /* if immediately wrong */ - - if (!losing) { - break; - } /* got it. */ - - opcode = opcode->m_next; - - if (!opcode) { - the_ins.error = "instruction/operands mismatch"; - return; - } /* Fell off the end */ - - losing = 0; - } - - - the_ins.args=opcode->m_operands; - the_ins.numargs=opcode->m_opnum; - the_ins.numo=opcode->m_codenum; - the_ins.opcode[0]=getone(opcode); - the_ins.opcode[1]=gettwo(opcode); - - for (s = the_ins.args, opP = &the_ins.operands[0]; *s; s += 2, opP++) { - /* This switch is a doozy. - Watch the first step; its a big one! */ - switch(s[0]) { - - case '*': - case '~': - case '%': - case ';': - case '@': - case '!': - case '&': - case '$': - case '?': - case '/': -#ifndef NO_68851 - case '|': -#endif - switch(opP->mode) { - case IMMED: - tmpreg=0x3c; /* 7.4 */ - if (strchr("bwl",s[1])) nextword=get_num(opP->con1,80); - else nextword=nextword=get_num(opP->con1,0); - if(isvar(opP->con1)) - add_fix(s[1],opP->con1,0); - switch(s[1]) { - case 'b': - if(!isbyte(nextword)) - opP->error="operand out of range"; - addword(nextword); - baseo=0; - break; - case 'w': - if(!isword(nextword)) - opP->error="operand out of range"; - addword(nextword); - baseo=0; - break; - case 'l': - addword(nextword>>16); - addword(nextword); - baseo=0; - break; - - case 'f': - baseo=2; - outro=8; - break; - case 'F': - baseo=4; - outro=11; - break; - case 'x': - baseo=6; - outro=15; - break; - case 'p': - baseo=6; - outro= -1; - break; - default: - as_fatal("Internal error: Can't decode %c%c in line %s of file \"%s\"", - *s, s[1], __LINE__, __FILE__); - } - if(!baseo) - break; - - /* We gotta put out some float */ - if(seg(opP->con1)!=SEG_BIG) { - int_to_gen(nextword); - gen_to_words(words,baseo,(long int)outro); - for(wordp=words;baseo--;wordp++) - addword(*wordp); - break; - } /* Its BIG */ - if(offs(opP->con1)>0) { - as_warn("Bignum assumed to be binary bit-pattern"); - if(offs(opP->con1)>baseo) { - as_warn("Bignum too big for %c format; truncated",s[1]); - offs(opP->con1)=baseo; - } - baseo-=offs(opP->con1); - for(wordp=generic_bignum+offs(opP->con1)-1;offs(opP->con1)--;--wordp) - addword(*wordp); - while(baseo--) - addword(0); - break; - } - gen_to_words(words,baseo,(long)outro); - for (wordp=words;baseo--;wordp++) - addword(*wordp); - break; - case DREG: - tmpreg=opP->reg-DATA; /* 0.dreg */ - break; - case AREG: - tmpreg=0x08+opP->reg-ADDR; /* 1.areg */ - break; - case AINDR: - tmpreg=0x10+opP->reg-ADDR; /* 2.areg */ - break; - case ADEC: - tmpreg=0x20+opP->reg-ADDR; /* 4.areg */ - break; - case AINC: - tmpreg=0x18+opP->reg-ADDR; /* 3.areg */ - break; - case AOFF: - - nextword=get_num(opP->con1,80); - /* Force into index mode. Hope this works */ - - /* We do the first bit for 32-bit displacements, - and the second bit for 16 bit ones. It is - possible that we should make the default be - WORD instead of LONG, but I think that'd - break GCC, so we put up with a little - inefficiency for the sake of working output. - */ - - if( !issword(nextword) - || ( isvar(opP->con1) - && ( ( opP->con1->e_siz==0 - && flagseen['l']==0) - || opP->con1->e_siz==3))) { - - if(opP->reg==PC) - tmpreg=0x3B; /* 7.3 */ - else - tmpreg=0x30+opP->reg-ADDR; /* 6.areg */ - if(isvar(opP->con1)) { - if(opP->reg==PC) { - add_frag(adds(opP->con1), - offs(opP->con1), - TAB(PCLEA,SZ_UNDEF)); - break; - } else { - addword(0x0170); - add_fix('l',opP->con1,1); - } - } else - addword(0x0170); - addword(nextword>>16); - } else { - if(opP->reg==PC) - tmpreg=0x3A; /* 7.2 */ - else - tmpreg=0x28+opP->reg-ADDR; /* 5.areg */ - - if(isvar(opP->con1)) { - if(opP->reg==PC) { - add_fix('w',opP->con1,1); - } else - add_fix('w',opP->con1,0); - } - } - addword(nextword); - break; - - case APODX: - case AMIND: - case APRDX: - if (max_arch_this_insn < m68020) { - max_arch_this_insn = m68020; - } /* bump arch */ - /* intentional fall-through */ - case AINDX: - nextword=0; - baseo=get_num(opP->con1,80); - outro=get_num(opP->con2,80); - /* Figure out the 'addressing mode' */ - /* Also turn on the BASE_DISABLE bit, if needed */ - if(opP->reg==PC || opP->reg==ZPC) { - tmpreg=0x3b; /* 7.3 */ - if(opP->reg==ZPC) - nextword|=0x80; - } else if(opP->reg==FAIL) { - nextword|=0x80; - tmpreg=0x30; /* 6.garbage */ - } else tmpreg=0x30+opP->reg-ADDR; /* 6.areg */ - - siz1= (opP->con1) ? opP->con1->e_siz : 0; - siz2= (opP->con2) ? opP->con2->e_siz : 0; - - /* Index register stuff */ - if(opP->ireg>=DATA+0 && opP->ireg<=ADDR+7) { - nextword|=(opP->ireg-DATA)<<12; - - if(opP->isiz==0 || opP->isiz==3) - nextword|=0x800; - switch(opP->imul) { - case 1: break; - case 2: nextword|=0x200; break; - case 4: nextword|=0x400; break; - case 8: nextword|=0x600; break; - default: as_fatal("failed sanity check."); - } - /* IF its simple, - GET US OUT OF HERE! */ - - /* Must be INDEX, with an index - register. Address register - cannot be ZERO-PC, and either - :b was forced, or we know - it will fit */ - if( opP->mode==AINDX - && opP->reg!=FAIL - && opP->reg!=ZPC - && ( siz1==1 - || ( issbyte(baseo) - && !isvar(opP->con1)))) { - nextword +=baseo&0xff; - addword(nextword); - if(isvar(opP->con1)) - add_fix('B',opP->con1,0); - break; - } - } else - nextword|=0x40; /* No index reg */ - - /* It aint simple */ - nextword|=0x100; - /* If the guy specified a width, we assume that - it is wide enough. Maybe it isn't. Ifso, we lose - */ - switch(siz1) { - case 0: - if(isvar(opP->con1) || !issword(baseo)) { - siz1=3; - nextword|=0x30; - } else if(baseo==0) - nextword|=0x10; - else { - nextword|=0x20; - siz1=2; - } - break; - case 1: - as_warn("Byte dispacement won't work. Defaulting to :w"); - case 2: - nextword|=0x20; - break; - case 3: - nextword|=0x30; - break; - } - - /* Figure out innner displacement stuff */ - if(opP->mode!=AINDX) { - switch(siz2) { - case 0: - if(isvar(opP->con2) || !issword(outro)) { - siz2=3; - nextword|=0x3; - } else if(outro==0) - nextword|=0x1; - else { - nextword|=0x2; - siz2=2; - } - break; - case 1: - as_warn("Byte dispacement won't work. Defaulting to :w"); - case 2: - nextword|=0x2; - break; - case 3: - nextword|=0x3; - break; - } - if(opP->mode==APODX) nextword|=0x04; - else if(opP->mode==AMIND) nextword|=0x40; - } - addword(nextword); - - if(isvar(opP->con1)) { - if(opP->reg==PC || opP->reg==ZPC) { - add_fix(siz1==3 ? 'l' : 'w',opP->con1,1); - opP->con1->e_exp.X_add_number+=6; - } else - add_fix(siz1==3 ? 'l' : 'w',opP->con1,0); - } - if(siz1==3) - addword(baseo>>16); - if(siz1) - addword(baseo); - - if(isvar(opP->con2)) { - if(opP->reg==PC || opP->reg==ZPC) { - add_fix(siz2==3 ? 'l' : 'w',opP->con2,1); - opP->con1->e_exp.X_add_number+=6; - } else - add_fix(siz2==3 ? 'l' : 'w',opP->con2,0); - } - if(siz2==3) - addword(outro>>16); - if(siz2) - addword(outro); - - break; - - case ABSL: - nextword=get_num(opP->con1,80); - switch(opP->con1->e_siz) { - default: - as_warn("Unknown size for absolute reference"); - case 0: - if(!isvar(opP->con1) && issword(offs(opP->con1))) { - tmpreg=0x38; /* 7.0 */ - addword(nextword); - break; - } - /* Don't generate pc relative code - on 68010 and 68000 */ - if(isvar(opP->con1) - && !subs(opP->con1) - && seg(opP->con1) == SEG_TEXT - && now_seg == SEG_TEXT - && (current_architecture & m68000up) <= m68010 - && !flagseen['S'] - && !strchr("~%&$?", s[0])) { - tmpreg=0x3A; /* 7.2 */ - add_frag(adds(opP->con1), - offs(opP->con1), - TAB(PCREL,SZ_UNDEF)); - break; - } - case 3: /* Fall through into long */ - if(isvar(opP->con1)) - add_fix('l',opP->con1,0); - - tmpreg=0x39; /* 7.1 mode */ - addword(nextword>>16); - addword(nextword); - break; - - case 2: /* Word */ - if(isvar(opP->con1)) - add_fix('w',opP->con1,0); - - tmpreg=0x38; /* 7.0 mode */ - addword(nextword); - break; - } - break; - case MSCR: - default: - as_bad("unknown/incorrect operand"); - /* abort(); */ - } - install_gen_operand(s[1],tmpreg); - break; - - case '#': - case '^': - switch(s[1]) { /* JF: I hate floating point! */ - case 'j': - tmpreg=70; - break; - case '8': - tmpreg=20; - break; - case 'C': - tmpreg=50; - break; - case '3': - default: - tmpreg=80; - break; - } - tmpreg=get_num(opP->con1,tmpreg); - if(isvar(opP->con1)) - add_fix(s[1],opP->con1,0); - switch(s[1]) { - case 'b': /* Danger: These do no check for - certain types of overflow. - user beware! */ - if(!isbyte(tmpreg)) - opP->error="out of range"; - insop(tmpreg); - if(isvar(opP->con1)) - the_ins.reloc[the_ins.nrel-1].n=(opcode->m_codenum)*2; - break; - case 'w': - if(!isword(tmpreg)) - opP->error="out of range"; - insop(tmpreg); - if(isvar(opP->con1)) - the_ins.reloc[the_ins.nrel-1].n=(opcode->m_codenum)*2; - break; - case 'l': - insop(tmpreg); /* Because of the way insop works, we put these two out backwards */ - insop(tmpreg>>16); - if(isvar(opP->con1)) - the_ins.reloc[the_ins.nrel-1].n=(opcode->m_codenum)*2; - break; - case '3': - tmpreg&=0xFF; - case '8': - case 'C': - install_operand(s[1],tmpreg); - break; - default: - as_fatal("Internal error: Unknown mode #%c in line %s of file \"%s\"", s[1], __LINE__, __FILE__); - } - break; - - case '+': - case '-': - case 'A': - case 'a': - install_operand(s[1],opP->reg-ADDR); - break; - - case 'B': - tmpreg=get_num(opP->con1,80); - switch(s[1]) { - case 'B': - /* Needs no offsetting */ - add_fix('B',opP->con1,1); - break; - case 'W': - /* Offset the displacement to be relative to byte disp location */ - opP->con1->e_exp.X_add_number+=2; - add_fix('w',opP->con1,1); - addword(0); - break; - case 'L': - long_branch: - if(current_architecture <= m68010) /* 68000 or 010 */ - as_warn("Can't use long branches on 68000/68010"); - the_ins.opcode[the_ins.numo-1]|=0xff; - /* Offset the displacement to be relative to byte disp location */ - opP->con1->e_exp.X_add_number+=4; - add_fix('l',opP->con1,1); - addword(0); - addword(0); - break; - case 'g': - if(subs(opP->con1)) /* We can't relax it */ - goto long_branch; - - /* This could either be a symbol, or an - absolute address. No matter, the - frag hacking will finger it out. - Not quite: it can't switch from - BRANCH to BCC68000 for the case - where opnd is absolute (it needs - to use the 68000 hack since no - conditional abs jumps). */ - if (((current_architecture <= m68010) || (0==adds(opP->con1))) - && (the_ins.opcode[0] >= 0x6200) - && (the_ins.opcode[0] <= 0x6f00)) { - add_frag(adds(opP->con1),offs(opP->con1),TAB(BCC68000,SZ_UNDEF)); - } else { - add_frag(adds(opP->con1),offs(opP->con1),TAB(BRANCH,SZ_UNDEF)); - } - break; - case 'w': - if(isvar(opP->con1)) { - /* check for DBcc instruction */ - if ((the_ins.opcode[0] & 0xf0f8) ==0x50c8) { - /* size varies if patch */ - /* needed for long form */ - add_frag(adds(opP->con1),offs(opP->con1),TAB(DBCC,SZ_UNDEF)); - break; - } - - /* Don't ask! */ - opP->con1->e_exp.X_add_number+=2; - add_fix('w',opP->con1,1); - } - addword(0); - break; - case 'C': /* Fixed size LONG coproc branches */ - the_ins.opcode[the_ins.numo-1]|=0x40; - /* Offset the displacement to be relative to byte disp location */ - /* Coproc branches don't have a byte disp option, but they are - compatible with the ordinary branches, which do... */ - opP->con1->e_exp.X_add_number+=4; - add_fix('l',opP->con1,1); - addword(0); - addword(0); - break; - case 'c': /* Var size Coprocesssor branches */ - if(subs(opP->con1)) { - add_fix('l',opP->con1,1); - add_frag((symbolS *)0,(long)0,TAB(FBRANCH,LONG)); - } else if(adds(opP->con1)) { - add_frag(adds(opP->con1),offs(opP->con1),TAB(FBRANCH,SZ_UNDEF)); - } else { - /* add_frag((symbolS *)0,offs(opP->con1),TAB(FBRANCH,SHORT)); */ - the_ins.opcode[the_ins.numo-1]|=0x40; - add_fix('l',opP->con1,1); - addword(0); - addword(4); - } - break; - default: - as_fatal("Internal error: operand type B%c unknown in line %s of file \"%s\"", - s[1], __LINE__, __FILE__); - } - break; - - case 'C': /* Ignore it */ - break; - - case 'd': /* JF this is a kludge */ - if(opP->mode==AOFF) { - install_operand('s',opP->reg-ADDR); - } else { - char *tmpP; - - tmpP=opP->con1->e_end-2; - opP->con1->e_beg++; - opP->con1->e_end-=4; /* point to the , */ - baseo=m68k_reg_parse(&tmpP); - if(baseoADDR+7) { - as_bad("Unknown address reg, using A0"); - baseo=0; - } else baseo-=ADDR; - install_operand('s',baseo); - } - tmpreg=get_num(opP->con1,80); - if(!issword(tmpreg)) { - as_warn("Expression out of range, using 0"); - tmpreg=0; - } - addword(tmpreg); - break; - - case 'D': - install_operand(s[1],opP->reg-DATA); - break; - - case 'F': - install_operand(s[1],opP->reg-FPREG); - break; - - case 'I': - tmpreg=1+opP->reg-COPNUM; - if(tmpreg==8) - tmpreg=0; - install_operand(s[1],tmpreg); - break; - - case 'J': /* JF foo */ - switch(opP->reg) { - case SFC: tmpreg=0x000; break; - case DFC: tmpreg=0x001; break; - case CACR: tmpreg=0x002; break; - case TC: tmpreg=0x003; break; - case ITT0: tmpreg=0x004; break; - case ITT1: tmpreg=0x005; break; - case DTT0: tmpreg=0x006; break; - case DTT1: tmpreg=0x007; break; - - case USP: tmpreg=0x800; break; - case VBR: tmpreg=0x801; break; - case CAAR: tmpreg=0x802; break; - case MSP: tmpreg=0x803; break; - case ISP: tmpreg=0x804; break; - case MMUSR: tmpreg=0x805; break; - case URP: tmpreg=0x806; break; - case SRP: tmpreg=0x807; break; - default: - as_fatal("failed sanity check."); - } - install_operand(s[1],tmpreg); - break; - - case 'k': - tmpreg=get_num(opP->con1,55); - install_operand(s[1],tmpreg&0x7f); - break; - - case 'l': - tmpreg=opP->reg; - if(s[1]=='w') { - if(tmpreg&0x7FF0000) - as_bad("Floating point register in register list"); - insop(reverse_16_bits(tmpreg)); - } else { - if(tmpreg&0x700FFFF) - as_bad("Wrong register in floating-point reglist"); - install_operand(s[1],reverse_8_bits(tmpreg>>16)); - } - break; - - case 'L': - tmpreg=opP->reg; - if(s[1]=='w') { - if(tmpreg&0x7FF0000) - as_bad("Floating point register in register list"); - insop(tmpreg); - } else if(s[1]=='8') { - if(tmpreg&0x0FFFFFF) - as_bad("incorrect register in reglist"); - install_operand(s[1],tmpreg>>24); - } else { - if(tmpreg&0x700FFFF) - as_bad("wrong register in floating-point reglist"); - else - install_operand(s[1],tmpreg>>16); - } - break; - - case 'M': - install_operand(s[1],get_num(opP->con1,60)); - break; - - case 'O': - tmpreg= (opP->mode==DREG) - ? 0x20+opP->reg-DATA - : (get_num(opP->con1,40)&0x1F); - install_operand(s[1],tmpreg); - break; - - case 'Q': - tmpreg=get_num(opP->con1,10); - if(tmpreg==8) - tmpreg=0; - install_operand(s[1],tmpreg); - break; - - case 'R': - /* This depends on the fact that ADDR registers are - eight more than their corresponding DATA regs, so - the result will have the ADDR_REG bit set */ - install_operand(s[1],opP->reg-DATA); - break; - - case 's': - if(opP->reg==FPI) tmpreg=0x1; - else if(opP->reg==FPS) tmpreg=0x2; - else if(opP->reg==FPC) tmpreg=0x4; - else as_fatal("failed sanity check."); - install_operand(s[1],tmpreg); - break; - - case 'S': /* Ignore it */ - break; - - case 'T': - install_operand(s[1],get_num(opP->con1,30)); - break; - - case 'U': /* Ignore it */ - break; - - case 'c': - switch (opP->reg) { - case NC: tmpreg = 0; break; - case DC: tmpreg = 1; break; - case IC: tmpreg = 2; break; - case BC: tmpreg = 3; break; - default: - as_fatal("failed sanity check"); - } /* switch on cache token */ - install_operand(s[1], tmpreg); - break; -#ifndef NO_68851 - /* JF: These are out of order, I fear. */ - case 'f': - switch (opP->reg) { - case SFC: - tmpreg=0; - break; - case DFC: - tmpreg=1; - break; - default: - as_fatal("failed sanity check."); - } - install_operand(s[1],tmpreg); - break; - - case 'P': - switch(opP->reg) { - case TC: - tmpreg=0; - break; - case CAL: - tmpreg=4; - break; - case VAL: - tmpreg=5; - break; - case SCC: - tmpreg=6; - break; - case AC: - tmpreg=7; - break; - default: - as_fatal("failed sanity check."); - } - install_operand(s[1],tmpreg); - break; - - case 'V': - if (opP->reg == VAL) - break; - as_fatal("failed sanity check."); - - case 'W': - switch(opP->reg) { - - case DRP: - tmpreg=1; - break; - case SRP: - tmpreg=2; - break; - case CRP: - tmpreg=3; - break; - default: - as_fatal("failed sanity check."); - } - install_operand(s[1],tmpreg); - break; - - case 'X': - switch (opP->reg) { - case BAD: case BAD+1: case BAD+2: case BAD+3: - case BAD+4: case BAD+5: case BAD+6: case BAD+7: - tmpreg = (4 << 10) | ((opP->reg - BAD) << 2); - break; - - case BAC: case BAC+1: case BAC+2: case BAC+3: - case BAC+4: case BAC+5: case BAC+6: case BAC+7: - tmpreg = (5 << 10) | ((opP->reg - BAC) << 2); - break; - - default: - as_fatal("failed sanity check."); - } - install_operand(s[1], tmpreg); - break; - case 'Y': - know(opP->reg == PSR); - break; - case 'Z': - know(opP->reg == PCSR); - break; -#endif /* m68851 */ - case '_': - tmpreg=get_num(opP->con1,80); - install_operand(s[1], tmpreg); - break; - default: - as_fatal("Internal error: Operand type %c unknown in line %s of file \"%s\"", s[0], __LINE__, __FILE__); - } - } - /* By the time whe get here (FINALLY) the_ins contains the complete - instruction, ready to be emitted. . . */ -} /* m68k_ip() */ - -/* - * get_regs := '/' + ? - * | '-' + - * | '-' + + ? - * | - * ; - * - - * The idea here must be to scan in a set of registers but I don't - * understand it. Looks awfully sloppy to me but I don't have any doc on - * this format so... - - * - * - */ - -static int get_regs(i,str,opP) -int i; -struct m68k_op *opP; -char *str; -{ - /* 26, 25, 24, 23-16, 15-8, 0-7 */ - /* Low order 24 bits encoded fpc,fps,fpi,fp7-fp0,a7-a0,d7-d0 */ - unsigned long cur_regs = 0; - int reg1, - reg2; - -#define ADD_REG(x) { if(x==FPI) cur_regs|=(1<<24);\ - else if(x==FPS) cur_regs|=(1<<25);\ - else if(x==FPC) cur_regs|=(1<<26);\ - else cur_regs|=(1<<(x-1)); } - - reg1=i; - for(;;) { - if(*str=='/') { - ADD_REG(reg1); - str++; - } else if(*str=='-') { - str++; - reg2=m68k_reg_parse(&str); - if(reg2=FPREG+8 || reg1==FPI || reg1==FPS || reg1==FPC) { - opP->error="unknown register in register list"; - return FAIL; - } - while(reg1<=reg2) { - ADD_REG(reg1); - reg1++; - } - if(*str=='\0') - break; - } else if(*str=='\0') { - ADD_REG(reg1); - break; - } else { - opP->error="unknow character in register list"; - return FAIL; - } -/* DJA -- Bug Fix. Did't handle d1-d2/a1 until the following instruction was added */ - if (*str=='/') - str ++; - reg1=m68k_reg_parse(&str); - if((reg1=FPREG+8) && !(reg1==FPI || reg1==FPS || reg1==FPC)) { - opP->error="unknown register in register list"; - return FAIL; - } - } - opP->reg=cur_regs; - return OK; -} /* get_regs() */ - -static int reverse_16_bits(in) -int in; -{ - int out=0; - int n; - - static int mask[16] = { -0x0001,0x0002,0x0004,0x0008,0x0010,0x0020,0x0040,0x0080, -0x0100,0x0200,0x0400,0x0800,0x1000,0x2000,0x4000,0x8000 - }; - for(n=0;n<16;n++) { - if(in&mask[n]) - out|=mask[15-n]; - } - return out; -} /* reverse_16_bits() */ - -static int reverse_8_bits(in) -int in; -{ - int out=0; - int n; - - static int mask[8] = { -0x0001,0x0002,0x0004,0x0008,0x0010,0x0020,0x0040,0x0080, - }; - - for(n=0;n<8;n++) { - if(in&mask[n]) - out|=mask[7-n]; - } - return out; -} /* reverse_8_bits() */ - -static void install_operand(mode,val) -int mode; -int val; -{ - switch(mode) { - case 's': - the_ins.opcode[0]|=val & 0xFF; /* JF FF is for M kludge */ - break; - case 'd': - the_ins.opcode[0]|=val<<9; - break; - case '1': - the_ins.opcode[1]|=val<<12; - break; - case '2': - the_ins.opcode[1]|=val<<6; - break; - case '3': - the_ins.opcode[1]|=val; - break; - case '4': - the_ins.opcode[2]|=val<<12; - break; - case '5': - the_ins.opcode[2]|=val<<6; - break; - case '6': - /* DANGER! This is a hack to force cas2l and cas2w cmds - to be three words long! */ - the_ins.numo++; - the_ins.opcode[2]|=val; - break; - case '7': - the_ins.opcode[1]|=val<<7; - break; - case '8': - the_ins.opcode[1]|=val<<10; - break; -#ifndef NO_68851 - case '9': - the_ins.opcode[1]|=val<<5; - break; -#endif - - case 't': - the_ins.opcode[1]|=(val<<10)|(val<<7); - break; - case 'D': - the_ins.opcode[1]|=(val<<12)|val; - break; - case 'g': - the_ins.opcode[0]|=val=0xff; - break; - case 'i': - the_ins.opcode[0]|=val<<9; - break; - case 'C': - the_ins.opcode[1]|=val; - break; - case 'j': - the_ins.opcode[1]|=val; - the_ins.numo++; /* What a hack */ - break; - case 'k': - the_ins.opcode[1]|=val<<4; - break; - case 'b': - case 'w': - case 'l': - break; - case 'e': - the_ins.opcode[0] |= (val << 6); - break; - case 'L': - the_ins.opcode[1] = (val >> 16); - the_ins.opcode[2] = val & 0xffff; - break; - case 'c': - default: - as_fatal("failed sanity check."); - } -} /* install_operand() */ - -static void install_gen_operand(mode,val) -int mode; -int val; -{ - switch(mode) { - case 's': - the_ins.opcode[0]|=val; - break; - case 'd': - /* This is a kludge!!! */ - the_ins.opcode[0]|=(val&0x07)<<9|(val&0x38)<<3; - break; - case 'b': - case 'w': - case 'l': - case 'f': - case 'F': - case 'x': - case 'p': - the_ins.opcode[0]|=val; - break; - /* more stuff goes here */ - default: - as_fatal("failed sanity check."); - } -} /* install_gen_operand() */ - -/* - * verify that we have some number of paren pairs, do m68k_ip_op(), and - * then deal with the bitfield hack. - */ - -static char *crack_operand(str,opP) -register char *str; -register struct m68k_op *opP; -{ - register int parens; - register int c; - register char *beg_str; - - if(!str) { - return str; - } - beg_str=str; - for(parens=0;*str && (parens>0 || notend(str));str++) { - if(*str=='(') parens++; - else if(*str==')') { - if(!parens) { /* ERROR */ - opP->error="Extra )"; - return str; - } - --parens; - } - } - if(!*str && parens) { /* ERROR */ - opP->error="Missing )"; - return str; - } - c= *str; - *str='\0'; - if(m68k_ip_op(beg_str,opP)==FAIL) { - *str=c; - return str; - } - *str=c; - if(c=='}') - c= *++str; /* JF bitfield hack */ - if(c) { - c= *++str; - if(!c) - as_bad("Missing operand"); - } - return str; -} - -/* See the comment up above where the #define notend(... is */ -#if 0 -notend(s) -char *s; -{ - if(*s==',') return 0; - if(*s=='{' || *s=='}') - return 0; - if(*s!=':') return 1; - /* This kludge here is for the division cmd, which is a kludge */ - if(index("aAdD#",s[1])) return 0; - return 1; -} -#endif - -/* This is the guts of the machine-dependent assembler. STR points to a - machine dependent instruction. This function is supposed to emit - the frags/bytes it assembles to. - */ -void -md_assemble(str) -char *str; -{ - char *er; - short *fromP; - char *toP = NULL; - int m,n = 0; - char *to_beg_P; - int shorts_this_frag; - - bzero((char *)(&the_ins),sizeof(the_ins)); /* JF for paranoia sake */ - m68k_ip(str); - er=the_ins.error; - if(!er) { - for(n=the_ins.numargs;n;--n) - if(the_ins.operands[n].error) { - er=the_ins.operands[n].error; - break; - } - } - if(er) { - as_bad("\"%s\" -- Statement '%s' ignored",er,str); - return; - } - - if(the_ins.nfrag==0) { /* No frag hacking involved; just put it out */ - toP=frag_more(2*the_ins.numo); - fromP= &the_ins.opcode[0]; - for(m=the_ins.numo;m;--m) { - md_number_to_chars(toP,(long)(*fromP),2); - toP+=2; - fromP++; - } - /* put out symbol-dependent info */ - for(m=0;mfr_literal)-the_ins.numo*2+the_ins.reloc[m].n, - n, - the_ins.reloc[m].add, - the_ins.reloc[m].sub, - the_ins.reloc[m].off, - the_ins.reloc[m].pcrel, - NO_RELOC); - } - return; - } - - /* There's some frag hacking */ - for(n=0,fromP= &the_ins.opcode[0];n= 2*shorts_this_frag /* 2*the_ins.fragb[n].fragoff */) { - the_ins.reloc[m].n-= 2*shorts_this_frag /* 2*the_ins.fragb[n].fragoff */; - break; - } - wid=the_ins.reloc[m].wid; - if(wid==0) - continue; - the_ins.reloc[m].wid=0; - wid = (wid=='b') ? 1 : (wid=='w') ? 2 : (wid=='l') ? 4 : 4000; - - fix_new(frag_now, - (toP-frag_now->fr_literal)-the_ins.numo*2+the_ins.reloc[m].n, - wid, - the_ins.reloc[m].add, - the_ins.reloc[m].sub, - the_ins.reloc[m].off, - the_ins.reloc[m].pcrel, - NO_RELOC); - } - know(the_ins.fragb[n].fadd); - (void)frag_var(rs_machine_dependent,10,0,(relax_substateT)(the_ins.fragb[n].fragty), - the_ins.fragb[n].fadd,the_ins.fragb[n].foff,to_beg_P); - } - n=(the_ins.numo-the_ins.fragb[n-1].fragoff); - shorts_this_frag=0; - if(n) { - toP=frag_more(n*sizeof(short)); - while(n--) { - md_number_to_chars(toP,(long)(*fromP),2); - toP+=2; - fromP++; - shorts_this_frag++; - } - } - for(m=0;mfr_literal)-/* the_ins.numo */ shorts_this_frag*2, - wid, - the_ins.reloc[m].add, - the_ins.reloc[m].sub, - the_ins.reloc[m].off, - the_ins.reloc[m].pcrel, - NO_RELOC); - } -} - -/* This function is called once, at assembler startup time. This should - set up all the tables, etc that the MD part of the assembler needs - */ -void -md_begin() -{ -/* - * md_begin -- set up hash tables with 68000 instructions. - * similar to what the vax assembler does. ---phr - */ - /* RMS claims the thing to do is take the m68k-opcode.h table, and make - a copy of it at runtime, adding in the information we want but isn't - there. I think it'd be better to have an awk script hack the table - at compile time. Or even just xstr the table and use it as-is. But - my lord ghod hath spoken, so we do it this way. Excuse the ugly var - names. */ - - register const struct m68k_opcode *ins; - register struct m68k_incant *hack, - *slak; - register char *retval = 0; /* empty string, or error msg text */ - register unsigned int i; - register char c; - - if ((op_hash = hash_new()) == NULL) - as_fatal("Virtual memory exhausted"); - - obstack_begin(&robyn,4000); - for (ins = m68k_opcodes; ins < endop; ins++) { - hack=slak=(struct m68k_incant *)obstack_alloc(&robyn,sizeof(struct m68k_incant)); - do { - /* we *could* ignore insns that don't match our - arch here but just leaving them out of the - hash. */ - slak->m_operands=ins->args; - slak->m_opnum=strlen(slak->m_operands)/2; - slak->m_arch = ins->arch; - slak->m_opcode=ins->opcode; - /* This is kludgey */ - slak->m_codenum=((ins->match)&0xffffL) ? 2 : 1; - if((ins+1)!=endop && !strcmp(ins->name,(ins+1)->name)) { - slak->m_next=(struct m68k_incant *) obstack_alloc(&robyn,sizeof(struct m68k_incant)); - ins++; - } else - slak->m_next=0; - slak=slak->m_next; - } while(slak); - - retval = hash_insert (op_hash, ins->name,(char *)hack); - /* Didn't his mommy tell him about null pointers? */ - if(retval && *retval) - as_fatal("Internal Error: Can't hash %s: %s",ins->name,retval); - } - - for (i = 0; i < sizeof(mklower_table) ; i++) - mklower_table[i] = (isupper(c = (char) i)) ? tolower(c) : c; - - for (i = 0 ; i < sizeof(notend_table) ; i++) { - notend_table[i] = 0; - alt_notend_table[i] = 0; - } - notend_table[','] = 1; - notend_table['{'] = 1; - notend_table['}'] = 1; - alt_notend_table['a'] = 1; - alt_notend_table['A'] = 1; - alt_notend_table['d'] = 1; - alt_notend_table['D'] = 1; - alt_notend_table['#'] = 1; - alt_notend_table['f'] = 1; - alt_notend_table['F'] = 1; -#ifdef REGISTER_PREFIX - alt_notend_table[REGISTER_PREFIX] = 1; -#endif -} - -#if 0 -#define notend(s) ((*s == ',' || *s == '}' || *s == '{' \ - || (*s == ':' && strchr("aAdD#", s[1]))) \ - ? 0 : 1) -#endif - -/* This funciton is called once, before the assembler exits. It is - supposed to do any final cleanup for this part of the assembler. - */ -void -md_end() -{ -} - -/* Equal to MAX_PRECISION in atof-ieee.c */ -#define MAX_LITTLENUMS 6 - -/* Turn a string in input_line_pointer into a floating point constant of type - type, and store the appropriate bytes in *litP. The number of LITTLENUMS - emitted is stored in *sizeP . An error message is returned, or NULL on OK. - */ -char * -md_atof(type,litP,sizeP) -char type; -char *litP; -int *sizeP; -{ - int prec; - LITTLENUM_TYPE words[MAX_LITTLENUMS]; - LITTLENUM_TYPE *wordP; - char *t; - char *atof_ieee(); - - switch(type) { - case 'f': - case 'F': - case 's': - case 'S': - prec = 2; - break; - - case 'd': - case 'D': - case 'r': - case 'R': - prec = 4; - break; - - case 'x': - case 'X': - prec = 6; - break; - - case 'p': - case 'P': - prec = 6; - break; - - default: - *sizeP=0; - return "Bad call to MD_ATOF()"; - } - t=atof_ieee(input_line_pointer,type,words); - if(t) - input_line_pointer=t; - - *sizeP=prec * sizeof(LITTLENUM_TYPE); - for(wordP=words;prec--;) { - md_number_to_chars(litP,(long)(*wordP++),sizeof(LITTLENUM_TYPE)); - litP+=sizeof(LITTLENUM_TYPE); - } - return ""; /* Someone should teach Dean about null pointers */ -} - -/* Turn an integer of n bytes (in val) into a stream of bytes appropriate - for use in the a.out file, and stores them in the array pointed to by buf. - This knows about the endian-ness of the target machine and does - THE RIGHT THING, whatever it is. Possible values for n are 1 (byte) - 2 (short) and 4 (long) Floating numbers are put out as a series of - LITTLENUMS (shorts, here at least) - */ -void -md_number_to_chars(buf,val,n) -char *buf; -long val; -int n; -{ - switch(n) { - case 1: - *buf++=val; - break; - case 2: - *buf++=(val>>8); - *buf++=val; - break; - case 4: - *buf++=(val>>24); - *buf++=(val>>16); - *buf++=(val>>8); - *buf++=val; - break; - default: - as_fatal("failed sanity check."); - } -} - -void -md_apply_fix(fixP, val) - fixS *fixP; - long val; -{ - char *buf = fixP->fx_where + fixP->fx_frag->fr_literal; - - switch(fixP->fx_size) { - case 1: - *buf++=val; - break; - case 2: - *buf++=(val>>8); - *buf++=val; - break; - case 4: - *buf++=(val>>24); - *buf++=(val>>16); - *buf++=(val>>8); - *buf++=val; - break; - default: - BAD_CASE (fixP->fx_size); - } -} - - -/* *fragP has been relaxed to its final size, and now needs to have - the bytes inside it modified to conform to the new size There is UGLY - MAGIC here. .. - */ -void -md_convert_frag(headers, fragP) -object_headers *headers; -register fragS *fragP; -{ - long disp; - long ext = 0; - - /* Address in object code of the displacement. */ - register int object_address = fragP -> fr_fix + fragP -> fr_address; - -#ifdef IBM_COMPILER_SUX - /* This is wrong but it convinces the native rs6000 compiler to - generate the code we want. */ - register char *buffer_address = fragP -> fr_literal; - buffer_address += fragP -> fr_fix; -#else /* IBM_COMPILER_SUX */ - /* Address in gas core of the place to store the displacement. */ - register char *buffer_address = fragP->fr_fix + fragP->fr_literal; -#endif /* IBM_COMPILER_SUX */ - - /* No longer true: know(fragP->fr_symbol); */ - - /* The displacement of the address, from current location. */ - disp = fragP->fr_symbol ? S_GET_VALUE(fragP->fr_symbol) : 0; - disp = (disp + fragP->fr_offset) - object_address; - - switch(fragP->fr_subtype) { - case TAB(BCC68000,BYTE): - case TAB(BRANCH,BYTE): - know(issbyte(disp)); - if(disp==0) - as_bad("short branch with zero offset: use :w"); - fragP->fr_opcode[1]=disp; - ext=0; - break; - case TAB(DBCC,SHORT): - know(issword(disp)); - ext=2; - break; - case TAB(BCC68000,SHORT): - case TAB(BRANCH,SHORT): - know(issword(disp)); - fragP->fr_opcode[1]=0x00; - ext=2; - break; - case TAB(BRANCH,LONG): - if (current_architecture <= m68010) { - if (fragP->fr_opcode[0]==0x61) { - fragP->fr_opcode[0]= 0x4E; - fragP->fr_opcode[1]= 0xB9; /* JBSR with ABSL LONG offset */ - subseg_change(SEG_TEXT, 0); - - fix_new(fragP, - fragP->fr_fix, - 4, - fragP->fr_symbol, - 0, - fragP->fr_offset, - 0, - NO_RELOC); - - fragP->fr_fix+=4; - ext=0; - } else if (fragP->fr_opcode[0]==0x60) { - fragP->fr_opcode[0]= 0x4E; - fragP->fr_opcode[1]= 0xF9; /* JMP with ABSL LONG offset */ - subseg_change(SEG_TEXT, 0); - fix_new(fragP, fragP->fr_fix, 4, fragP->fr_symbol, 0, fragP->fr_offset,0, - NO_RELOC); - fragP->fr_fix+=4; - ext=0; - } else { - as_bad("Long branch offset not supported."); - } - } else { - fragP->fr_opcode[1]=0xff; - ext=4; - } - break; - case TAB(BCC68000,LONG): - /* only Bcc 68000 instructions can come here */ - /* change bcc into b!cc/jmp absl long */ - fragP->fr_opcode[0] ^= 0x01; /* invert bcc */ - fragP->fr_opcode[1] = 0x6; /* branch offset = 6 */ - - /* JF: these used to be fr_opcode[2,3], but they may be in a - different frag, in which case refering to them is a no-no. - Only fr_opcode[0,1] are guaranteed to work. */ - *buffer_address++ = 0x4e; /* put in jmp long (0x4ef9) */ - *buffer_address++ = 0xf9; - fragP->fr_fix += 2; /* account for jmp instruction */ - subseg_change(SEG_TEXT,0); - fix_new(fragP, fragP->fr_fix, 4, fragP->fr_symbol, 0, - fragP->fr_offset,0, - NO_RELOC); - fragP->fr_fix += 4; - ext=0; - break; - case TAB(DBCC,LONG): - /* only DBcc 68000 instructions can come here */ - /* change dbcc into dbcc/jmp absl long */ - /* JF: these used to be fr_opcode[2-7], but that's wrong */ - *buffer_address++ = 0x00; /* branch offset = 4 */ - *buffer_address++ = 0x04; - *buffer_address++ = 0x60; /* put in bra pc+6 */ - *buffer_address++ = 0x06; - *buffer_address++ = 0x4e; /* put in jmp long (0x4ef9) */ - *buffer_address++ = 0xf9; - - fragP->fr_fix += 6; /* account for bra/jmp instructions */ - subseg_change(SEG_TEXT,0); - fix_new(fragP, fragP->fr_fix, 4, fragP->fr_symbol, 0, - fragP->fr_offset,0, - NO_RELOC); - fragP->fr_fix += 4; - ext=0; - break; - case TAB(FBRANCH,SHORT): - know((fragP->fr_opcode[1]&0x40)==0); - ext=2; - break; - case TAB(FBRANCH,LONG): - fragP->fr_opcode[1]|=0x40; /* Turn on LONG bit */ - ext=4; - break; - case TAB(PCREL,SHORT): - ext=2; - break; - case TAB(PCREL,LONG): - /* The thing to do here is force it to ABSOLUTE LONG, since - PCREL is really trying to shorten an ABSOLUTE address anyway */ - /* JF FOO This code has not been tested */ - subseg_change(SEG_TEXT,0); - fix_new(fragP, fragP->fr_fix, 4, fragP->fr_symbol, 0, fragP->fr_offset, 0, NO_RELOC); - if((fragP->fr_opcode[1] & 0x3F) != 0x3A) - as_bad("Internal error (long PC-relative operand) for insn 0x%04lx at 0x%lx", - fragP->fr_opcode[0],fragP->fr_address); - fragP->fr_opcode[1]&= ~0x3F; - fragP->fr_opcode[1]|=0x39; /* Mode 7.1 */ - fragP->fr_fix+=4; - /* md_number_to_chars(buffer_address, - (long)(fragP->fr_symbol->sy_value + fragP->fr_offset), - 4); */ - ext=0; - break; - case TAB(PCLEA,SHORT): - subseg_change(SEG_TEXT,0); - fix_new(fragP,(int)(fragP->fr_fix),2,fragP->fr_symbol,(symbolS *)0,fragP->fr_offset,1, - NO_RELOC); - fragP->fr_opcode[1] &= ~0x3F; - fragP->fr_opcode[1] |= 0x3A; - ext=2; - break; - case TAB(PCLEA,LONG): - subseg_change(SEG_TEXT,0); - fix_new(fragP,(int)(fragP->fr_fix)+2,4,fragP->fr_symbol,(symbolS *)0,fragP->fr_offset+2,1, - NO_RELOC); - *buffer_address++ = 0x01; - *buffer_address++ = 0x70; - fragP->fr_fix+=2; - /* buffer_address+=2; */ - ext=4; - break; - - } /* switch on subtype */ - - if (ext) { - md_number_to_chars(buffer_address, (long) disp, (int) ext); - fragP->fr_fix += ext; -/* H_SET_TEXT_SIZE(headers, H_GET_TEXT_SIZE(headers) + ext); */ - } /* if extending */ - - return; -} /* md_convert_frag() */ - -/* Force truly undefined symbols to their maximum size, and generally set up - the frag list to be relaxed - */ -int md_estimate_size_before_relax(fragP, segment) -register fragS *fragP; -segT segment; -{ - int old_fix; - register char *buffer_address = fragP->fr_fix + fragP->fr_literal; - - old_fix = fragP->fr_fix; - - /* handle SZ_UNDEF first, it can be changed to BYTE or SHORT */ - switch(fragP->fr_subtype) { - - case TAB(BCC68000,SZ_UNDEF): { - if((fragP->fr_symbol != NULL) - && S_GET_SEGMENT(fragP->fr_symbol) == segment) { - fragP->fr_subtype=TAB(BCC68000,BYTE); - break; - } - /* only Bcc 68000 instructions can come here */ - /* change bcc into b!cc/jmp absl long */ - fragP->fr_opcode[0] ^= 0x01; /* invert bcc */ - if(flagseen['l']) { - fragP->fr_opcode[1] = 0x04; /* branch offset = 6 */ - /* JF: these were fr_opcode[2,3] */ - buffer_address[0] = 0x4e; /* put in jmp long (0x4ef9) */ - buffer_address[1] = 0xf8; - fragP->fr_fix += 2; /* account for jmp instruction */ - subseg_change(SEG_TEXT,0); - fix_new(fragP, fragP->fr_fix, 2, fragP->fr_symbol, 0, - fragP->fr_offset, 0, NO_RELOC); - fragP->fr_fix += 2; - } else { - fragP->fr_opcode[1] = 0x06; /* branch offset = 6 */ - /* JF: these were fr_opcode[2,3] */ - buffer_address[2] = 0x4e; /* put in jmp long (0x4ef9) */ - buffer_address[3] = 0xf9; - fragP->fr_fix += 2; /* account for jmp instruction */ - subseg_change(SEG_TEXT,0); - fix_new(fragP, fragP->fr_fix, 4, fragP->fr_symbol, 0, - fragP->fr_offset, 0, NO_RELOC); - fragP->fr_fix += 4; - } - frag_wane(fragP); - break; - } /* case TAB(BCC68000,SZ_UNDEF) */ - - case TAB(DBCC,SZ_UNDEF): { - if (fragP->fr_symbol != NULL && S_GET_SEGMENT(fragP->fr_symbol) == segment) { - fragP->fr_subtype=TAB(DBCC,SHORT); - fragP->fr_var+=2; - break; - } - /* only DBcc 68000 instructions can come here */ - /* change dbcc into dbcc/jmp absl long */ - /* JF: these used to be fr_opcode[2-4], which is wrong. */ - buffer_address[0] = 0x00; /* branch offset = 4 */ - buffer_address[1] = 0x04; - buffer_address[2] = 0x60; /* put in bra pc + ... */ - - if(flagseen['l']) { - /* JF: these were fr_opcode[5-7] */ - buffer_address[3] = 0x04; /* plus 4 */ - buffer_address[4] = 0x4e;/* Put in Jump Word */ - buffer_address[5] = 0xf8; - fragP->fr_fix += 6; /* account for bra/jmp instruction */ - subseg_change(SEG_TEXT,0); - fix_new(fragP, fragP->fr_fix, 2, fragP->fr_symbol, 0, - fragP->fr_offset, 0, NO_RELOC); - fragP->fr_fix += 2; - } else { - /* JF: these were fr_opcode[5-7] */ - buffer_address[3] = 0x06; /* Plus 6 */ - buffer_address[4] = 0x4e; /* put in jmp long (0x4ef9) */ - buffer_address[5] = 0xf9; - fragP->fr_fix += 6; /* account for bra/jmp instruction */ - subseg_change(SEG_TEXT,0); - fix_new(fragP, fragP->fr_fix, 4, fragP->fr_symbol, 0, - fragP->fr_offset, 0, NO_RELOC); - fragP->fr_fix += 4; - } - - frag_wane(fragP); - break; - } /* case TAB(DBCC,SZ_UNDEF) */ - - case TAB(BRANCH,SZ_UNDEF): { - if((fragP->fr_symbol != NULL) /* Not absolute */ - && S_GET_SEGMENT(fragP->fr_symbol) == segment) { - fragP->fr_subtype=TAB(TABTYPE(fragP->fr_subtype),BYTE); - break; - } else if((fragP->fr_symbol == 0) || (current_architecture <= m68010)) { - /* On 68000, or for absolute value, switch to abs long */ - /* FIXME, we should check abs val, pick short or long */ - if(fragP->fr_opcode[0]==0x61) { - fragP->fr_opcode[0]= 0x4E; - fragP->fr_opcode[1]= 0xB9; /* JBSR with ABSL LONG offset */ - subseg_change(SEG_TEXT, 0); - fix_new(fragP, fragP->fr_fix, 4, - fragP->fr_symbol, 0, fragP->fr_offset, 0, NO_RELOC); - fragP->fr_fix+=4; - frag_wane(fragP); - } else if(fragP->fr_opcode[0]==0x60) { - fragP->fr_opcode[0]= 0x4E; - fragP->fr_opcode[1]= 0xF9; /* JMP with ABSL LONG offset */ - subseg_change(SEG_TEXT, 0); - fix_new(fragP, fragP->fr_fix, 4, - fragP->fr_symbol, 0, fragP->fr_offset, 0, NO_RELOC); - fragP->fr_fix+=4; - frag_wane(fragP); - } else { - as_warn("Long branch offset to extern symbol not supported."); - } - } else { /* Symbol is still undefined. Make it simple */ - fix_new(fragP, (int)(fragP->fr_fix), 4, fragP->fr_symbol, - (symbolS *)0, fragP->fr_offset+4, 1, NO_RELOC); - fragP->fr_fix+=4; - fragP->fr_opcode[1]=0xff; - frag_wane(fragP); - break; - } - - break; - } /* case TAB(BRANCH,SZ_UNDEF) */ - - case TAB(PCLEA,SZ_UNDEF): { - if ((S_GET_SEGMENT(fragP->fr_symbol))==segment || flagseen['l']) { - fragP->fr_subtype=TAB(PCLEA,SHORT); - fragP->fr_var+=2; - } else { - fragP->fr_subtype=TAB(PCLEA,LONG); - fragP->fr_var+=6; - } - break; - } /* TAB(PCLEA,SZ_UNDEF) */ - - case TAB(PCREL,SZ_UNDEF): { - if(S_GET_SEGMENT(fragP->fr_symbol) == segment || flagseen['l']) { - fragP->fr_subtype = TAB(PCREL,SHORT); - fragP->fr_var += 2; - } else { - fragP->fr_subtype = TAB(PCREL,LONG); - fragP->fr_var += 4; - } - break; - } /* TAB(PCREL,SZ_UNDEF) */ - - default: - break; - - } /* switch on subtype looking for SZ_UNDEF's. */ - - /* now that SZ_UNDEF are taken care of, check others */ - switch(fragP->fr_subtype) { - case TAB(BCC68000,BYTE): - case TAB(BRANCH,BYTE): - /* We can't do a short jump to the next instruction, - so we force word mode. */ - if (fragP->fr_symbol && S_GET_VALUE(fragP->fr_symbol)==0 && - fragP->fr_symbol->sy_frag==fragP->fr_next) { - fragP->fr_subtype=TAB(TABTYPE(fragP->fr_subtype),SHORT); - fragP->fr_var+=2; - } - break; - default: - break; - } - return fragP->fr_var + fragP->fr_fix - old_fix; -} - -#if defined(OBJ_AOUT) | defined(OBJ_BOUT) -/* the bit-field entries in the relocation_info struct plays hell - with the byte-order problems of cross-assembly. So as a hack, - I added this mach. dependent ri twiddler. Ugly, but it gets - you there. -KWK */ -/* on m68k: first 4 bytes are normal unsigned long, next three bytes -are symbolnum, most sig. byte first. Last byte is broken up with -bit 7 as pcrel, bits 6 & 5 as length, bit 4 as pcrel, and the lower -nibble as nuthin. (on Sun 3 at least) */ -/* Translate the internal relocation information into target-specific - format. */ -#ifdef comment -void -md_ri_to_chars(the_bytes, ri) - char *the_bytes; - struct reloc_info_generic *ri; -{ - /* this is easy */ - md_number_to_chars(the_bytes, ri->r_address, 4); - /* now the fun stuff */ - the_bytes[4] = (ri->r_symbolnum >> 16) & 0x0ff; - the_bytes[5] = (ri->r_symbolnum >> 8) & 0x0ff; - the_bytes[6] = ri->r_symbolnum & 0x0ff; - the_bytes[7] = (((ri->r_pcrel << 7) & 0x80) | ((ri->r_length << 5) & 0x60) | - ((ri->r_extern << 4) & 0x10)); -} -#endif /* comment */ - -void tc_aout_fix_to_chars(where, fixP, segment_address_in_file) -char *where; -fixS *fixP; -relax_addressT segment_address_in_file; -{ - /* - * In: length of relocation (or of address) in chars: 1, 2 or 4. - * Out: GNU LD relocation length code: 0, 1, or 2. - */ - - static unsigned char nbytes_r_length [] = { 42, 0, 1, 42, 2 }; - - long r_extern; - long r_symbolnum; - - /* this is easy */ - md_number_to_chars(where, - fixP->fx_frag->fr_address + fixP->fx_where - segment_address_in_file, - 4); - - /* now the fun stuff */ - if (S_GET_TYPE(fixP->fx_addsy) == N_UNDF) { - r_extern = 1; - r_symbolnum = fixP->fx_addsy->sy_number; - } else { - r_extern = 0; - r_symbolnum = S_GET_TYPE(fixP->fx_addsy); - } - - where[4] = (r_symbolnum >> 16) & 0x0ff; - where[5] = (r_symbolnum >> 8) & 0x0ff; - where[6] = r_symbolnum & 0x0ff; - where[7] = (((fixP->fx_pcrel << 7) & 0x80) | ((nbytes_r_length[fixP->fx_size] << 5) & 0x60) | - ((r_extern << 4) & 0x10)); - - return; -} /* tc_aout_fix_to_chars() */ - -#endif /* OBJ_AOUT or OBJ_BOUT */ - -#ifndef WORKING_DOT_WORD -const int md_short_jump_size = 4; -const int md_long_jump_size = 6; - -void -md_create_short_jump(ptr,from_addr,to_addr,frag,to_symbol) -char *ptr; -long from_addr, - to_addr; -fragS *frag; -symbolS *to_symbol; -{ - long offset; - - offset = to_addr - (from_addr+2); - - md_number_to_chars(ptr ,(long)0x6000,2); - md_number_to_chars(ptr+2,(long)offset,2); -} - -void -md_create_long_jump(ptr,from_addr,to_addr,frag,to_symbol) -char *ptr; -long from_addr, - to_addr; -fragS *frag; -symbolS *to_symbol; -{ - long offset; - - if (current_architecture <= m68010) { - offset=to_addr-S_GET_VALUE(to_symbol); - md_number_to_chars(ptr ,(long)0x4EF9,2); - md_number_to_chars(ptr+2,(long)offset,4); - fix_new(frag,(ptr+2)-frag->fr_literal,4,to_symbol,(symbolS *)0,(long)0,0, - NO_RELOC); - } else { - offset=to_addr - (from_addr+2); - md_number_to_chars(ptr ,(long)0x60ff,2); - md_number_to_chars(ptr+2,(long)offset,4); - } -} - -#endif -/* Different values of OK tell what its OK to return. Things that aren't OK are an error (what a shock, no?) - - 0: Everything is OK - 10: Absolute 1:8 only - 20: Absolute 0:7 only - 30: absolute 0:15 only - 40: Absolute 0:31 only - 50: absolute 0:127 only - 55: absolute -64:63 only - 60: absolute -128:127 only - 70: absolute 0:4095 only - 80: No bignums - -*/ - -static int get_num(exp,ok) -struct m68k_exp *exp; -int ok; -{ -#ifdef TEST2 - long l = 0; - - if(!exp->e_beg) - return 0; - if(*exp->e_beg=='0') { - if(exp->e_beg[1]=='x') - sscanf(exp->e_beg+2,"%x",&l); - else - sscanf(exp->e_beg+1,"%O",&l); - return l; - } - return atol(exp->e_beg); -#else - char *save_in; - char c_save; - - if(!exp) { - /* Can't do anything */ - return 0; - } - if(!exp->e_beg || !exp->e_end) { - seg(exp)=SEG_ABSOLUTE; - adds(exp)=0; - subs(exp)=0; - offs(exp)= (ok==10) ? 1 : 0; - as_warn("Null expression defaults to %ld",offs(exp)); - return 0; - } - - exp->e_siz=0; - if(/* ok!=80 && */exp->e_end[-1]==':' && (exp->e_end-exp->e_beg)>=2) { - switch(exp->e_end[0]) { - case 's': - case 'S': - case 'b': - case 'B': - exp->e_siz=1; - break; - case 'w': - case 'W': - exp->e_siz=2; - break; - case 'l': - case 'L': - exp->e_siz=3; - break; - default: - as_bad("Unknown size for expression \"%c\"",exp->e_end[0]); - } - exp->e_end-=2; - } - c_save=exp->e_end[1]; - exp->e_end[1]='\0'; - save_in=input_line_pointer; - input_line_pointer=exp->e_beg; - switch(expression(&(exp->e_exp))) { - case SEG_PASS1: - seg(exp)=SEG_ABSOLUTE; - adds(exp)=0; - subs(exp)=0; - offs(exp)= (ok==10) ? 1 : 0; - as_warn("Unknown expression: '%s' defaulting to %d",exp->e_beg,offs(exp)); - break; - - case SEG_ABSENT: - /* Do the same thing the VAX asm does */ - seg(exp)=SEG_ABSOLUTE; - adds(exp)=0; - subs(exp)=0; - offs(exp)=0; - if(ok==10) { - as_warn("expression out of range: defaulting to 1"); - offs(exp)=1; - } - break; - case SEG_ABSOLUTE: - switch(ok) { - case 10: - if(offs(exp)<1 || offs(exp)>8) { - as_warn("expression out of range: defaulting to 1"); - offs(exp)=1; - } - break; - case 20: - if(offs(exp)<0 || offs(exp)>7) - goto outrange; - break; - case 30: - if(offs(exp)<0 || offs(exp)>15) - goto outrange; - break; - case 40: - if(offs(exp)<0 || offs(exp)>32) - goto outrange; - break; - case 50: - if(offs(exp)<0 || offs(exp)>127) - goto outrange; - break; - case 55: - if(offs(exp)<-64 || offs(exp)>63) - goto outrange; - break; - case 60: - if(offs(exp)<-128 || offs(exp)>127) - goto outrange; - break; - case 70: - if(offs(exp)<0 || offs(exp)>4095) { - outrange: - as_warn("expression out of range: defaulting to 0"); - offs(exp)=0; - } - break; - default: - break; - } - break; - case SEG_TEXT: - case SEG_DATA: - case SEG_BSS: - case SEG_UNKNOWN: - case SEG_DIFFERENCE: - if(ok>=10 && ok<=70) { - seg(exp)=SEG_ABSOLUTE; - adds(exp)=0; - subs(exp)=0; - offs(exp)= (ok==10) ? 1 : 0; - as_warn("Can't deal with expression \"%s\": defaulting to %ld",exp->e_beg,offs(exp)); - } - break; - case SEG_BIG: - if(ok==80 && offs(exp)<0) { /* HACK! Turn it into a long */ - LITTLENUM_TYPE words[6]; - - gen_to_words(words,2,8L);/* These numbers are magic! */ - seg(exp)=SEG_ABSOLUTE; - adds(exp)=0; - subs(exp)=0; - offs(exp)=words[1]|(words[0]<<16); - } else if(ok!=0) { - seg(exp)=SEG_ABSOLUTE; - adds(exp)=0; - subs(exp)=0; - offs(exp)= (ok==10) ? 1 : 0; - as_warn("Can't deal with expression \"%s\": defaulting to %ld",exp->e_beg,offs(exp)); - } - break; - default: - as_fatal("failed sanity check."); - } - if(input_line_pointer!=exp->e_end+1) - as_bad("Ignoring junk after expression"); - exp->e_end[1]=c_save; - input_line_pointer=save_in; - if(exp->e_siz) { - switch(exp->e_siz) { - case 1: - if(!isbyte(offs(exp))) - as_warn("expression doesn't fit in BYTE"); - break; - case 2: - if(!isword(offs(exp))) - as_warn("expression doesn't fit in WORD"); - break; - } - } - return offs(exp); -#endif -} /* get_num() */ - -/* These are the back-ends for the various machine dependent pseudo-ops. */ -void demand_empty_rest_of_line(); /* Hate those extra verbose names */ - -static void s_data1() { - subseg_new(SEG_DATA,1); - demand_empty_rest_of_line(); -} /* s_data1() */ - -static void s_data2() { - subseg_new(SEG_DATA,2); - demand_empty_rest_of_line(); -} /* s_data2() */ - -static void s_bss() { - /* We don't support putting frags in the BSS segment, but we - can put them into initialized data for now... */ - subseg_new(SEG_DATA,255); /* FIXME-SOON */ - demand_empty_rest_of_line(); -} /* s_bss() */ - -static void s_even() { - register int temp; - register long temp_fill; - - temp = 1; /* JF should be 2? */ - temp_fill = get_absolute_expression (); - if ( ! need_pass_2 ) /* Never make frag if expect extra pass. */ - frag_align (temp, (int)temp_fill); - demand_empty_rest_of_line(); -} /* s_even() */ - -static void s_proc() { - demand_empty_rest_of_line(); -} /* s_proc() */ - -/* s_space is defined in read.c .skip is simply an alias to it. */ - -/* - * md_parse_option - * Invocation line includes a switch not recognized by the base assembler. - * See if it's a processor-specific option. These are: - * - * -[A]m[c]68000, -[A]m[c]68008, -[A]m[c]68010, -[A]m[c]68020, -[A]m[c]68030, -[A]m[c]68040 - * -[A]m[c]68881, -[A]m[c]68882, -[A]m[c]68851 - * Select the architecture. Instructions or features not - * supported by the selected architecture cause fatal - * errors. More than one may be specified. The default is - * -m68020 -m68851 -m68881. Note that -m68008 is a synonym - * for -m68000, and -m68882 is a synonym for -m68881. - * - */ - -int md_parse_option(argP,cntP,vecP) -char **argP; -int *cntP; -char ***vecP; -{ - switch(**argP) { - case 'l': /* -l means keep external to 2 bit offset - rather than 16 bit one */ - break; - - case 'S': /* -S means that jbsr's always turn into jsr's. */ - break; - - case 'A': - (*argP)++; - /* intentional fall-through */ - case 'm': - (*argP)++; - - if (**argP=='c') { - (*argP)++; - } /* allow an optional "c" */ - - if (!strcmp(*argP, "68000") - || !strcmp(*argP, "68008")) { - current_architecture |= m68000; - } else if (!strcmp(*argP, "68010")) { -#ifdef TE_SUN - omagic= 1<<16|OMAGIC; -#endif - current_architecture |= m68010; - - } else if (!strcmp(*argP, "68020")) { - current_architecture |= m68020; - - } else if (!strcmp(*argP, "68030")) { - current_architecture |= m68030; - - } else if (!strcmp(*argP, "68040")) { - current_architecture |= m68040; - -#ifndef NO_68881 - } else if (!strcmp(*argP, "68881") - || !strcmp(*argP, "68882")) { - current_architecture |= m68040; - -#endif /* NO_68881 */ -#ifndef NO_68851 - } else if (!strcmp(*argP,"68851")) { - current_architecture |= m68040; - -#endif /* NO_68851 */ - } else { - as_warn("Unknown architecture, \"%s\". option ignored", *argP); - } /* switch on architecture */ - - while(**argP) (*argP)++; - - break; - - case 'p': - if (!strcmp(*argP,"pic")) { - (*argP) += 3; - break; /* -pic, Position Independent Code */ - } else { - return(0); - } /* pic or not */ - - default: - return 0; - } - return 1; -} - - -#ifdef TEST2 - -/* TEST2: Test md_assemble() */ -/* Warning, this routine probably doesn't work anymore */ - -main() -{ - struct m68k_it the_ins; - char buf[120]; - char *cp; - int n; - - m68k_ip_begin(); - for(;;) { - if(!gets(buf) || !*buf) - break; - if(buf[0]=='|' || buf[1]=='.') - continue; - for(cp=buf;*cp;cp++) - if(*cp=='\t') - *cp=' '; - if(is_label(buf)) - continue; - bzero(&the_ins,sizeof(the_ins)); - m68k_ip(&the_ins,buf); - if(the_ins.error) { - printf("Error %s in %s\n",the_ins.error,buf); - } else { - printf("Opcode(%d.%s): ",the_ins.numo,the_ins.args); - for(n=0;nfr_next) { - printf("addr %lu next 0x%x fix %ld var %ld symbol 0x%x offset %ld\n", - fragP->fr_address,fragP->fr_next,fragP->fr_fix,fragP->fr_var,fragP->fr_symbol,fragP->fr_offset); - printf("opcode 0x%x type %d subtype %d\n\n",fragP->fr_opcode,fragP->fr_type,fragP->fr_subtype); - } - fflush(stdout); - return 0; -} -#endif - -#ifdef DONTDEF -/*VARARGS1*/ -panic(format,args) -char *format; -{ - fputs("Internal error:",stderr); - _doprnt(format,&args,stderr); - (void)putc('\n',stderr); - as_where(); - abort(); -} -#endif - -/* We have no need to default values of symbols. */ - -/* ARGSUSED */ -symbolS * -md_undefined_symbol (name) - char *name; -{ - return 0; -} - -/* Parse an operand that is machine-specific. - We just return without modifying the expression if we have nothing - to do. */ - -/* ARGSUSED */ -void -md_operand (expressionP) - expressionS *expressionP; -{ -} - -/* Round up a section size to the appropriate boundary. */ -long -md_section_align (segment, size) - segT segment; - long size; -{ - return size; /* Byte alignment is fine */ -} - -/* Exactly what point is a PC-relative offset relative TO? - On the 68k, they're relative to the address of the offset, plus - its size. (??? Is this right? FIXME-SOON!) */ -long -md_pcrel_from (fixP) - fixS *fixP; -{ - return fixP->fx_size + fixP->fx_where + fixP->fx_frag->fr_address; -} - -/* - * Local Variables: - * comment-column: 0 - * fill-column: 131 - * End: - */ - -/* end of tc-m68k.c */ diff --git a/gas/config/tc-m68k.h b/gas/config/tc-m68k.h deleted file mode 100644 index 4fa516cd298..00000000000 --- a/gas/config/tc-m68k.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * This file is tp-generic.h and is intended to be a template for - * target processor specific header files. - */ - -#define TC_M68K 1 - -#ifdef TE_SUN3 -/* This variable contains the value to write out at the beginning of - the a.out file. The 2<<16 means that this is a 68020 file instead - of an old-style 68000 file */ - -#define DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE (2<<16|OMAGIC); /* Magic byte for file header */ -#endif /* TE_SUN3 */ - -#define tc_crawl_symbol_chain(a) ; /* not used */ -#define tc_headers_hook(a) ; /* not used */ - -/* - * Local Variables: - * comment-column: 0 - * fill-column: 131 - * End: - */ - -/* end of tc-m68k.h */ diff --git a/gas/config/tc-ns32k.c b/gas/config/tc-ns32k.c deleted file mode 100644 index f4fd8830262..00000000000 --- a/gas/config/tc-ns32k.c +++ /dev/null @@ -1,1867 +0,0 @@ -/* ns32k.c -- Assemble on the National Semiconductor 32k series - Copyright (C) 1987 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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 1, or (at your option) -any later version. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/*#define SHOW_NUM 1*/ /* uncomment for debugging */ - -#include -#include -#ifdef USG -#include -#else -#include -#endif -#include "ns32k-opcode.h" - -#include "as.h" - -#include "obstack.h" - -/* Macros */ -#define IIF_ENTRIES 13 /* number of entries in iif */ -#define PRIVATE_SIZE 256 /* size of my garbage memory */ -#define MAX_ARGS 4 -#define DEFAULT -1 /* addr_mode returns this value when plain constant or label is encountered */ - -#define IIF(ptr,a1,c1,e1,g1,i1,k1,m1,o1,q1,s1,u1) \ - iif.iifP[ptr].type= a1; \ - iif.iifP[ptr].size= c1; \ - iif.iifP[ptr].object= e1; \ - iif.iifP[ptr].object_adjust= g1; \ - iif.iifP[ptr].pcrel= i1; \ - iif.iifP[ptr].pcrel_adjust= k1; \ - iif.iifP[ptr].im_disp= m1; \ - iif.iifP[ptr].relax_substate= o1; \ - iif.iifP[ptr].bit_fixP= q1; \ - iif.iifP[ptr].addr_mode= s1; \ - iif.iifP[ptr].bsr= u1; - -#ifdef SEQUENT_COMPATABILITY -#define LINE_COMMENT_CHARS "|" -#define ABSOLUTE_PREFIX '@' -#define IMMEDIATE_PREFIX '#' -#endif - -#ifndef LINE_COMMENT_CHARS -#define LINE_COMMENT_CHARS "#" -#endif - -char comment_chars[] = "#"; -char line_comment_chars[] = LINE_COMMENT_CHARS; -#if !defined(ABSOLUTE_PREFIX) && !defined(IMMEDIATE_PREFIX) -#define ABSOLUTE_PREFIX '@' /* One or the other MUST be defined */ -#endif - -struct addr_mode { - char mode; /* addressing mode of operand (0-31) */ - char scaled_mode; /* mode combined with scaled mode */ - char scaled_reg; /* register used in scaled+1 (1-8) */ - char float_flag; /* set if R0..R7 was F0..F7 ie a floating-point-register */ - char am_size; /* estimated max size of general addr-mode parts*/ - char im_disp; /* if im_disp==1 we have a displacement */ - char pcrel; /* 1 if pcrel, this is really redundant info */ - char disp_suffix[2]; /* length of displacement(s), 0=undefined */ - char *disp[2]; /* pointer(s) at displacement(s) - or immediates(s) (ascii) */ - char index_byte; /* index byte */ -}; -typedef struct addr_mode addr_modeS; - - -char *freeptr,*freeptr_static; /* points at some number of free bytes */ -struct hash_control *inst_hash_handle; - -struct ns32k_opcode *desc; /* pointer at description of instruction */ -addr_modeS addr_modeP; -char EXP_CHARS[] = "eE"; -char FLT_CHARS[] = "fd"; /* we don't want to support lowercase, do we */ - -/* UPPERCASE denotes live names - * when an instruction is built, IIF is used as an intermidiate form to store - * the actual parts of the instruction. A ns32k machine instruction can - * be divided into a couple of sub PARTs. When an instruction is assembled - * the appropriate PART get an assignment. When an IIF has been completed it's - * converted to a FRAGment as specified in AS.H */ - -/* internal structs */ -struct option { - char *pattern; - unsigned long or; - unsigned long and; -}; - -typedef struct { - int type; /* how to interpret object */ - int size; /* Estimated max size of object */ - unsigned long object; /* binary data */ - int object_adjust; /* number added to object */ - int pcrel; /* True if object is pcrel */ - int pcrel_adjust; /* It's value reflects the length in bytes from the instruction start to the displacement */ - int im_disp; /* True if the object is a displacement */ - relax_substateT relax_substate; /* Initial relaxsubstate */ - bit_fixS *bit_fixP; /* Pointer at bit_fix struct */ - int addr_mode; /* What addrmode do we associate with this iif-entry */ - char bsr; /* Sequent hack */ -}iif_entryT; /* Internal Instruction Format */ -struct int_ins_form { - int instr_size; /* Max size of instruction in bytes. */ - iif_entryT iifP[IIF_ENTRIES+1]; -}; -struct int_ins_form iif; -expressionS exprP; -char *input_line_pointer; -/* description of the PARTs in IIF - *object[n]: - * 0 total length in bytes of entries in iif - * 1 opcode - * 2 index_byte_a - * 3 index_byte_b - * 4 disp_a_1 - * 5 disp_a_2 - * 6 disp_b_1 - * 7 disp_b_2 - * 8 imm_a - * 9 imm_b - * 10 implied1 - * 11 implied2 - * - * For every entry there is a datalength in bytes. This is stored in size[n]. - * 0, the objectlength is not explicitly given by the instruction - * and the operand is undefined. This is a case for relaxation. - * Reserve 4 bytes for the final object. - * - * 1, the entry contains one byte - * 2, the entry contains two bytes - * 3, the entry contains three bytes - * 4, the entry contains four bytes - * etc - * - * Furthermore, every entry has a data type identifier in type[n]. - * - * 0, the entry is void, ignore it. - * 1, the entry is a binary number. - * 2, the entry is a pointer at an expression. - * Where expression may be as simple as a single '1', - * and as complicated as foo-bar+12, - * foo and bar may be undefined but suffixed by :{b|w|d} to - * control the length of the object. - * - * 3, the entry is a pointer at a bignum struct - * - * - * The low-order-byte coresponds to low physical memory. - * Obviously a FRAGment must be created for each valid disp in PART whose - * datalength is undefined (to bad) . - * The case where just the expression is undefined is less severe and is - * handled by fix. Here the number of bytes in the objectfile is known. - * With this representation we simplify the assembly and separates the - * machine dependent/independent parts in a more clean way (said OE) - */ - -struct option opt1[]= /* restore, exit */ -{ - { "r0", 0x80, 0xff }, - { "r1", 0x40, 0xff }, - { "r2", 0x20, 0xff }, - { "r3", 0x10, 0xff }, - { "r4", 0x08, 0xff }, - { "r5", 0x04, 0xff }, - { "r6", 0x02, 0xff }, - { "r7", 0x01, 0xff }, - { 0 , 0x00, 0xff } -}; -struct option opt2[]= /* save, enter */ -{ - { "r0", 0x01, 0xff }, - { "r1", 0x02, 0xff }, - { "r2", 0x04, 0xff }, - { "r3", 0x08, 0xff }, - { "r4", 0x10, 0xff }, - { "r5", 0x20, 0xff }, - { "r6", 0x40, 0xff }, - { "r7", 0x80, 0xff }, - { 0 , 0x00, 0xff } -}; -struct option opt3[]= /* setcfg */ -{ - { "c", 0x8, 0xff }, - { "m", 0x4, 0xff }, - { "f", 0x2, 0xff }, - { "i", 0x1, 0xff }, - { 0 , 0x0, 0xff } -}; -struct option opt4[]= /* cinv */ -{ - { "a", 0x4, 0xff }, - { "i", 0x2, 0xff }, - { "d", 0x1, 0xff }, - { 0 , 0x0, 0xff } -}; -struct option opt5[]= /* string inst */ -{ - { "b", 0x2, 0xff }, - { "u", 0xc, 0xff }, - { "w", 0x4, 0xff }, - { 0 , 0x0, 0xff } -}; -struct option opt6[]= /* plain reg ext,cvtp etc */ -{ - { "r0", 0x00, 0xff }, - { "r1", 0x01, 0xff }, - { "r2", 0x02, 0xff }, - { "r3", 0x03, 0xff }, - { "r4", 0x04, 0xff }, - { "r5", 0x05, 0xff }, - { "r6", 0x06, 0xff }, - { "r7", 0x07, 0xff }, - { 0 , 0x00, 0xff } -}; - -#if !defined(NS32032) && !defined(NS32532) -#define NS32032 -#endif - -struct option cpureg_532[]= /* lpr spr */ -{ - { "us", 0x0, 0xff }, - { "dcr", 0x1, 0xff }, - { "bpc", 0x2, 0xff }, - { "dsr", 0x3, 0xff }, - { "car", 0x4, 0xff }, - { "fp", 0x8, 0xff }, - { "sp", 0x9, 0xff }, - { "sb", 0xa, 0xff }, - { "usp", 0xb, 0xff }, - { "cfg", 0xc, 0xff }, - { "psr", 0xd, 0xff }, - { "intbase", 0xe, 0xff }, - { "mod", 0xf, 0xff }, - { 0 , 0x00, 0xff } -}; -struct option mmureg_532[]= /* lmr smr */ -{ - { "mcr", 0x9, 0xff }, - { "msr", 0xa, 0xff }, - { "tear", 0xb, 0xff }, - { "ptb0", 0xc, 0xff }, - { "ptb1", 0xd, 0xff }, - { "ivar0", 0xe, 0xff }, - { "ivar1", 0xf, 0xff }, - { 0 , 0x0, 0xff } -}; - -struct option cpureg_032[]= /* lpr spr */ -{ - { "upsr", 0x0, 0xff }, - { "fp", 0x8, 0xff }, - { "sp", 0x9, 0xff }, - { "sb", 0xa, 0xff }, - { "psr", 0xd, 0xff }, - { "intbase", 0xe, 0xff }, - { "mod", 0xf, 0xff }, - { 0 , 0x0, 0xff } -}; -struct option mmureg_032[]= /* lmr smr */ -{ - { "bpr0", 0x0, 0xff }, - { "bpr1", 0x1, 0xff }, - { "pf0", 0x4, 0xff }, - { "pf1", 0x5, 0xff }, - { "sc", 0x8, 0xff }, - { "msr", 0xa, 0xff }, - { "bcnt", 0xb, 0xff }, - { "ptb0", 0xc, 0xff }, - { "ptb1", 0xd, 0xff }, - { "eia", 0xf, 0xff }, - { 0 , 0x0, 0xff } -}; - -#if defined(NS32532) -struct option *cpureg = cpureg_532; -struct option *mmureg = mmureg_532; -#else -struct option *cpureg = cpureg_032; -struct option *mmureg = mmureg_032; -#endif - - -const pseudo_typeS md_pseudo_table[]={ /* so far empty */ - { 0, 0, 0 } -}; - -#define IND(x,y) (((x)<<2)+(y)) - -/* those are index's to relax groups in md_relax_table - ie it must be multiplied by 4 to point at a group start. Viz IND(x,y) - Se function relax_segment in write.c for more info */ - -#define BRANCH 1 -#define PCREL 2 - -/* those are index's to entries in a relax group */ - -#define BYTE 0 -#define WORD 1 -#define DOUBLE 2 -#define UNDEF 3 -/* Those limits are calculated from the displacement start in memory. - The ns32k uses the begining of the instruction as displacement base. - This type of displacements could be handled here by moving the limit window - up or down. I choose to use an internal displacement base-adjust as there - are other routines that must consider this. Also, as we have two various - offset-adjusts in the ns32k (acb versus br/brs/jsr/bcond), two set of limits - would have had to be used. - Now we dont have to think about that. */ - - -const relax_typeS md_relax_table[]={ - { 1, 1, 0, 0 }, - { 1, 1, 0, 0 }, - { 1, 1, 0, 0 }, - { 1, 1, 0, 0 }, - - { (63), (-64), 1, IND(BRANCH,WORD) }, - { (8192), (-8192), 2, IND(BRANCH,DOUBLE) }, - { 0, 0, 4, 0 }, - { 1, 1, 0, 0 } -}; - -/* Array used to test if mode contains displacements. - Value is true if mode contains displacement. */ - -char disp_test[]={ 0,0,0,0,0,0,0,0, - 1,1,1,1,1,1,1,1, - 1,1,1,0,0,1,1,0, - 1,1,1,1,1,1,1,1 }; - -/* Array used to calculate max size of displacements */ - -char disp_size[]={ 4,1,2,0,4 }; - - -#ifdef __STDC__ - -static segT evaluate_expr(expressionS *resultP, char *ptr); -static void md_number_to_disp(char *buf, long val, int n); -static void md_number_to_imm(char *buf, long val, int n); - -#else /* __STDC__ */ - -static segT evaluate_expr(); -static void md_number_to_disp(); -static void md_number_to_imm(); - -#endif /* __STDC__ */ - -/* Parses a general operand into an addressingmode struct - - in: pointer at operand in ascii form - pointer at addr_mode struct for result - the level of recursion. (always 0 or 1) - - out: data in addr_mode struct - */ -int addr_mode(operand,addr_modeP,recursive_level) - char *operand; - register addr_modeS *addr_modeP; -int recursive_level; -{ - register char *str; - register int i; - register int strl; - register int mode; - int j; - mode = DEFAULT; /* default */ - addr_modeP->scaled_mode=0; /* why not */ - addr_modeP->scaled_reg=0; /* if 0, not scaled index */ - addr_modeP->float_flag=0; - addr_modeP->am_size=0; - addr_modeP->im_disp=0; - addr_modeP->pcrel=0; /* not set in this function */ - addr_modeP->disp_suffix[0]=0; - addr_modeP->disp_suffix[1]=0; - addr_modeP->disp[0]=NULL; - addr_modeP->disp[1]=NULL; - str=operand; - if (str[0]==0) {return (0);} /* we don't want this */ - strl=strlen(str); - switch (str[0]) { - /* the following three case statements controls the mode-chars - this is the place to ed if you want to change them */ -#ifdef ABSOLUTE_PREFIX - case ABSOLUTE_PREFIX: - if (str[strl-1]==']') break; - addr_modeP->mode=21; /* absolute */ - addr_modeP->disp[0]=str+1; - return (-1); -#endif -#ifdef IMMEDIATE_PREFIX - case IMMEDIATE_PREFIX: - if (str[strl-1]==']') break; - addr_modeP->mode=20; /* immediate */ - addr_modeP->disp[0]=str+1; - return (-1); -#endif - case '.': - if (str[strl-1]!=']') { - switch (str[1]) { - case'-':case'+': - if (str[2]!='\000') { - addr_modeP->mode=27; /* pc-relativ */ - addr_modeP->disp[0]=str+2; - return (-1); - } - default: - as_warn("Invalid syntax in PC-relative addressing mode"); - return(0); - } - } - break; - case'e': - if (str[strl-1]!=']') { - if((!strncmp(str,"ext(",4)) && strl>7) { /* external */ - addr_modeP->disp[0]=str+4; - i=0; - j=2; - do { /* disp[0]'s termination point */ - j+=1; - if (str[j]=='(') i++; - if (str[j]==')') i--; - } while (jdisp[1]=str+j+2; - addr_modeP->mode=22; - return (-1); - } - } - break; - default:; - } - strl=strlen(str); - switch(strl) { - case 2: - switch (str[0]) { - case'f':addr_modeP->float_flag=1; - case'r': - if (str[1]>='0' && str[1]<'8') { - addr_modeP->mode=str[1]-'0'; - return (-1); - } - } - case 3: - if (!strncmp(str,"tos",3)) { - addr_modeP->mode=23; /* TopOfStack */ - return (-1); - } - default:; - } - if (strl>4) { - if (str[strl-1]==')') { - if (str[strl-2]==')') { - if (!strncmp(&str[strl-5],"(fp",3)) { - mode=16; /* Memory Relative */ - } - if (!strncmp(&str[strl-5],"(sp",3)) { - mode=17; - } - if (!strncmp(&str[strl-5],"(sb",3)) { - mode=18; - } - if (mode!=DEFAULT) { /* memory relative */ - addr_modeP->mode=mode; - j=strl-5; /* temp for end of disp[0] */ - i=0; - do { - strl-=1; - if (str[strl]==')') i++; - if (str[strl]=='(') i--; - } while (strl>-1 && i!=0); - if (i!=0) { - as_warn("Invalid syntax in Memory Relative addressing mode"); - return(0); - } - addr_modeP->disp[1]=str; - addr_modeP->disp[0]=str+strl+1; - str[j]='\000'; /* null terminate disp[0] */ - str[strl]='\000'; /* null terminate disp[1] */ - return (-1); - } - } - switch (str[strl-3]) { - case'r':case'R': - if (str[strl-2]>='0' && str[strl-2]<'8' && str[strl-4]=='(') { - addr_modeP->mode=str[strl-2]-'0'+8; - addr_modeP->disp[0]=str; - str[strl-4]=0; - return (-1); /* reg rel */ - } - default: - if (!strncmp(&str[strl-4],"(fp",3)) { - mode=24; - } - if (!strncmp(&str[strl-4],"(sp",3)) { - mode=25; - } - if (!strncmp(&str[strl-4],"(sb",3)) { - mode=26; - } - if (!strncmp(&str[strl-4],"(pc",3)) { - mode=27; - } - if (mode!=DEFAULT) { - addr_modeP->mode=mode; - addr_modeP->disp[0]=str; - str[strl-4]='\0'; - return (-1); /* memory space */ - } - } - } - /* no trailing ')' do we have a ']' ? */ - if (str[strl-1]==']') { - switch (str[strl-2]) { - case'b':mode=28;break; - case'w':mode=29;break; - case'd':mode=30;break; - case'q':mode=31;break; - default:; - as_warn("Invalid scaled-indexed mode, use (b,w,d,q)"); - if (str[strl-3]!=':' || str[strl-6]!='[' || - str[strl-5]=='r' || str[strl-4]<'0' || str[strl-4]>'7') { - as_warn("Syntax in scaled-indexed mode, use [Rn:m] where n=[0..7] m={b,w,d,q}"); - } - } /* scaled index */ - { - if (recursive_level>0) { - as_warn("Scaled-indexed addressing mode combined with scaled-index"); - return(0); - } - addr_modeP->am_size+=1; /* scaled index byte */ - j=str[strl-4]-'0'; /* store temporary */ - str[strl-6]='\000'; /* nullterminate for recursive call */ - i=addr_mode(str,addr_modeP,1); - if (!i || addr_modeP->mode==20) { - as_warn("Invalid or illegal addressing mode combined with scaled-index"); - return(0); - } - addr_modeP->scaled_mode=addr_modeP->mode; /* store the inferior mode */ - addr_modeP->mode=mode; - addr_modeP->scaled_reg=j+1; - return (-1); - } - } - } - addr_modeP->mode = DEFAULT; /* default to whatever */ - addr_modeP->disp[0]=str; - return (-1); -} - -/* ptr points at string - addr_modeP points at struct with result - This routine calls addr_mode to determine the general addr.mode of - the operand. When this is ready it parses the displacements for size - specifying suffixes and determines size of immediate mode via ns32k-opcode. - Also builds index bytes if needed. - */ -int get_addr_mode(ptr,addr_modeP) - char *ptr; - addr_modeS *addr_modeP; -{ - int tmp; - addr_mode(ptr,addr_modeP,0); - if (addr_modeP->mode == DEFAULT || addr_modeP->scaled_mode == -1) { - /* resolve ambigious operands, this shouldn't - be necessary if one uses standard NSC operand - syntax. But the sequent compiler doesn't!!! - This finds a proper addressinging mode if it - is implicitly stated. See ns32k-opcode.h */ - (void)evaluate_expr(&exprP,ptr); /* this call takes time Sigh! */ - if (addr_modeP->mode == DEFAULT) { - if (exprP.X_add_symbol || exprP.X_subtract_symbol) { - addr_modeP->mode=desc->default_model; /* we have a label */ - } else { - addr_modeP->mode=desc->default_modec; /* we have a constant */ - } - } else { - if (exprP.X_add_symbol || exprP.X_subtract_symbol) { - addr_modeP->scaled_mode=desc->default_model; - } else { - addr_modeP->scaled_mode=desc->default_modec; - } - } - /* must put this mess down in addr_mode to handle the scaled case better */ - } - /* It appears as the sequent compiler wants an absolute when we have a - label without @. Constants becomes immediates besides the addr case. - Think it does so with local labels too, not optimum, pcrel is better. - When I have time I will make gas check this and select pcrel when possible - Actually that is trivial. - */ - if (tmp=addr_modeP->scaled_reg) { /* build indexbyte */ - tmp--; /* remember regnumber comes incremented for flagpurpose */ - tmp|=addr_modeP->scaled_mode<<3; - addr_modeP->index_byte=(char)tmp; - addr_modeP->am_size+=1; - } - if (disp_test[addr_modeP->mode]) { /* there was a displacement, probe for length specifying suffix*/ - { - register char c; - register char suffix; - register char suffix_sub; - register int i; - register char *toP; - register char *fromP; - - addr_modeP->pcrel=0; - if (disp_test[addr_modeP->mode]) { /* there is a displacement */ - if (addr_modeP->mode==27 || addr_modeP->scaled_mode==27) { /* do we have pcrel. mode */ - addr_modeP->pcrel=1; - } - addr_modeP->im_disp=1; - for(i=0;i<2;i++) { - suffix_sub=suffix=0; - if (toP=addr_modeP->disp[i]) { /* suffix of expression, the largest size rules */ - fromP=toP; - while (c = *fromP++) { - *toP++=c; - if (c==':') { - switch (*fromP) { - case '\0': - as_warn("Premature end of suffix--Defaulting to d"); - suffix=4; - continue; - case 'b':suffix_sub=1;break; - case 'w':suffix_sub=2;break; - case 'd':suffix_sub=4;break; - default: - as_warn("Bad suffix after ':' use {b|w|d} Defaulting to d"); - suffix=4; - } - fromP++; - toP--; /* So we write over the ':' */ - if (suffixdisp_suffix[i]=suffix; - addr_modeP->am_size+=suffix ? suffix : 4; - } - } - } - } - } else { - if (addr_modeP->mode==20) { /* look in ns32k_opcode for size */ - addr_modeP->disp_suffix[0]=addr_modeP->am_size=desc->im_size; - addr_modeP->im_disp=0; - } - } - return addr_modeP->mode; -} - - -/* read an optionlist */ -void optlist(str,optionP,default_map) - char *str; /* the string to extract options from */ - struct option *optionP; /* how to search the string */ - unsigned long *default_map; /* default pattern and output */ -{ - register int i,j,k,strlen1,strlen2; - register char *patternP,*strP; - strlen1=strlen(str); - if (strlen1<1) { - as_fatal("Very short instr to option, ie you can't do it on a NULLstr"); - } - for (i=0;optionP[i].pattern!=0;i++) { - strlen2=strlen(optionP[i].pattern); - for (j=0;j3) as_fatal("Internal consistency error. check ns32k-opcode.h"); - pcrel=0; - pcrel_adjust=0; - tmp=0; - switch (operandsP[(loop<<1)+1]) { - case 'f': /* operand of sfsr turns out to be a nasty specialcase */ - opcode_bit_ptr-=5; - case 'F': /* 32 bit float general form */ - case 'L': /* 64 bit float */ - case 'Q': /* quad-word */ - case 'B': /* byte */ - case 'W': /* word */ - case 'D': /* double-word */ - case 'A': /* double-word gen-address-form ie no regs allowed */ - get_addr_mode(argv[i],&addr_modeP); - iif.instr_size+=addr_modeP.am_size; - if (opcode_bit_ptr==desc->opcode_size) b=4; else b=6; - for (j=b;j<(b+2);j++) { - if (addr_modeP.disp[j-b]) { - IIF(j, - 2, - addr_modeP.disp_suffix[j-b], - (unsigned long)addr_modeP.disp[j-b], - 0, - addr_modeP.pcrel, - iif.instr_size-addr_modeP.am_size, /* this aint used (now) */ - addr_modeP.im_disp, - IND(BRANCH,BYTE), - NULL, - addr_modeP.scaled_reg ? addr_modeP.scaled_mode:addr_modeP.mode, - 0); - } - } - opcode_bit_ptr-=5; - iif.iifP[1].object|=((long)addr_modeP.mode)<im_size); - argv[i]=freeptr; - freeptr=(char*)tmp; - pcrel-=1; /* make pcrel 0 inspite of what case 'p': wants */ - /* fall thru */ - case 'p': /* displacement - pc relative addressing */ - pcrel+=1; - /* fall thru */ - case 'd': /* displacement */ - iif.instr_size+=suffixP[i] ? suffixP[i] : 4; - IIF(12, 2, suffixP[i], (unsigned long)argv[i], 0, - pcrel, pcrel_adjust, 1, IND(BRANCH,BYTE), NULL,-1,0); - break; - case 'H': /* sequent-hack: the linker wants a bit set when bsr */ - pcrel=1; - iif.instr_size+=suffixP[i] ? suffixP[i] : 4; - IIF(12, 2, suffixP[i], (unsigned long)argv[i], 0, - pcrel, pcrel_adjust, 1, IND(BRANCH,BYTE), NULL,-1,1);break; - case 'q': /* quick */ - opcode_bit_ptr-=4; - IIF(11,2,42,(unsigned long)argv[i],0,0,0,0,0, - bit_fix_new(4,opcode_bit_ptr,-8,7,0,1,0),-1,0); - break; - case 'r': /* register number (3 bits) */ - list_search(argv[i],opt6,&tmp); - opcode_bit_ptr-=3; - iif.iifP[1].object|=tmp<operands) { - if (*lineptr++!='\0') { - sqr='['; - sep=','; - while (*lineptr!='\0') { - if (desc->operands[argc<<1]) { - suffix[argc]=0; - arg_type=desc->operands[(argc<<1)+1]; - switch (arg_type) { - case 'd': case 'b': case 'p': case 'H': /* the operand is supposed to be a displacement */ - /* Hackwarning: do not forget to update the 4 cases above when editing ns32k-opcode.h */ - suffix_separator=':'; - break; - default: - suffix_separator='\255'; /* if this char occurs we loose */ - } - suffix[argc]=0; /* 0 when no ':' is encountered */ - argv[argc]=freeptr; - *freeptr='\0'; - while ((c = *lineptr)!='\0' && c!=sep) { - if (c==sqr) { - if (sqr=='[') { - sqr=']';sep='\0'; - } else { - sqr='[';sep=','; - } - } - if (c==suffix_separator) { /* ':' - label/suffix separator */ - switch (lineptr[1]) { - case 'b':suffix[argc]=1;break; - case 'w':suffix[argc]=2;break; - case 'd':suffix[argc]=4;break; - default: as_warn("Bad suffix, defaulting to d"); - suffix[argc]=4; - if (lineptr[1]=='\0' || lineptr[1]==sep) { - lineptr+=1; - continue; - } - } - lineptr+=2; - continue; - } - *freeptr++=c; - lineptr++; - } - *freeptr++='\0'; - argc+=1; - if (*lineptr=='\0') continue; - lineptr+=1; - } else { - as_fatal("Too many operands passed to instruction"); - } - } - } - } - if (argc!=strlen(desc->operands)/2) { - if (strlen(desc->default_args)) { /* we can apply default, dont goof */ - if (parse(desc->default_args,1)!=1) { /* check error in default */ - as_fatal("Wrong numbers of operands in default, check ns32k-opcodes.h"); - } - } else { - as_fatal("Wrong number of operands"); - } - - } - for (i=0;iopcode_size/8; - IIF(1,1,iif.instr_size,desc->opcode_seed,0,0,0,0,0,0,-1,0); - - /* this call encodes operands to iif format */ - if (argc) { - encode_operand(argc, - argv, - &desc->operands[0], - &suffix[0], - desc->im_size, - desc->opcode_size); - } - return recursive_level; -} - - - /* Convert iif to fragments. - From this point we start to dribble with functions in other files than - this one.(Except hash.c) So, if it's possible to make an iif for an other - CPU, you don't need to know what frags, relax, obstacks, etc is in order - to port this assembler. You only need to know if it's possible to reduce - your cpu-instruction to iif-format (takes some work) and adopt the other - md_? parts according to given instructions - Note that iif was invented for the clean ns32k`s architecure. - */ -void convert_iif() { - register int i,j; - fragS *inst_frag; - char *inst_offset,*inst_opcode; - char *memP; - segT segment; - int l,k; - register int rem_size; /* count the remaining bytes of instruction */ - register char type; - register char size = 0; - int size_so_far=0; /* used to calculate pcrel_adjust */ - - rem_size=iif.instr_size; - memP=frag_more(iif.instr_size); /* make sure we have enough bytes for instruction */ - inst_opcode=memP; - inst_offset=(char*)(memP-frag_now->fr_literal); - inst_frag=frag_now; - for (i=0;ifx_bit_base) { /* expand fx_bit_base to point at opcode */ - iif.iifP[i].bit_fixP->fx_bit_base=(long)inst_opcode; - } - case 8: /* bignum or doublefloat */ - bzero (memP,8); - case 1:case 2:case 3:case 4:/* the final size in objectmemory is known */ - j=(unsigned long)iif.iifP[i].bit_fixP; - switch (type) { - case 1: /* the object is pure binary */ - if (j || iif.iifP[i].pcrel) { - fix_new_ns32k(frag_now, - (long)(memP-frag_now->fr_literal), - size, - 0, - 0, - iif.iifP[i].object, - iif.iifP[i].pcrel, - (char)size_so_far, /*iif.iifP[i].pcrel_adjust,*/ - iif.iifP[i].im_disp, - j, - iif.iifP[i].bsr); /* sequent hack */ - } else { /* good, just put them bytes out */ - switch (iif.iifP[i].im_disp) { - case 0: - md_number_to_chars(memP,iif.iifP[i].object,size);break; - case 1: - md_number_to_disp(memP,iif.iifP[i].object,size);break; - default: as_fatal("iif convert internal pcrel/binary"); - } - } - memP+=size; - rem_size-=size; - break; - case 2: /* the object is a pointer at an expression, so unpack - it, note that bignums may result from the expression - */ - if ((segment=evaluate_expr(&exprP,(char*)iif.iifP[i].object))==SEG_BIG || size==8) { - if ((k=exprP.X_add_number)>0) { /* we have a bignum ie a quad */ - /* this can only happens in a long suffixed instruction */ - bzero(memP,size); /* size normally is 8 */ - if (k*2>size) as_warn("Bignum too big for long"); - if (k==3) memP+=2; - for (l=0;k>0;k--,l+=2) { - md_number_to_chars(memP+l,generic_bignum[l>>1],sizeof(LITTLENUM_TYPE)); - } - } else { /* flonum */ - LITTLENUM_TYPE words[4]; - - switch(size) { - case 4: - gen_to_words(words,2,8); - md_number_to_imm(memP ,(long)words[0],sizeof(LITTLENUM_TYPE)); - md_number_to_imm(memP+sizeof(LITTLENUM_TYPE),(long)words[1],sizeof(LITTLENUM_TYPE)); - break; - case 8: - gen_to_words(words,4,11); - md_number_to_imm(memP ,(long)words[0],sizeof(LITTLENUM_TYPE)); - md_number_to_imm(memP+sizeof(LITTLENUM_TYPE) ,(long)words[1],sizeof(LITTLENUM_TYPE)); - md_number_to_imm(memP+2*sizeof(LITTLENUM_TYPE),(long)words[2],sizeof(LITTLENUM_TYPE)); - md_number_to_imm(memP+3*sizeof(LITTLENUM_TYPE),(long)words[3],sizeof(LITTLENUM_TYPE)); - break; - } - } - memP+=size; - rem_size-=size; - break; - } - if (j || - exprP.X_add_symbol || - exprP.X_subtract_symbol || - iif.iifP[i].pcrel) { /* fixit */ - /* the expression was undefined due to an undefined label */ - /* create a fix so we can fix the object later */ - exprP.X_add_number+=iif.iifP[i].object_adjust; - fix_new_ns32k(frag_now, - (long)(memP-frag_now->fr_literal), - size, - exprP.X_add_symbol, - exprP.X_subtract_symbol, - exprP.X_add_number, - iif.iifP[i].pcrel, - (char)size_so_far, /*iif.iifP[i].pcrel_adjust,*/ - iif.iifP[i].im_disp, - j, - iif.iifP[i].bsr); /* sequent hack */ - - } else { /* good, just put them bytes out */ - switch (iif.iifP[i].im_disp) { - case 0: - md_number_to_imm(memP,exprP.X_add_number,size);break; - case 1: - md_number_to_disp(memP,exprP.X_add_number,size);break; - default: as_fatal("iif convert internal pcrel/pointer"); - } - } - memP+=size; - rem_size-=size; - break; - default: as_fatal("Internal logic error in iif.iifP[n].type"); - } - break; - case 0: /* To bad, the object may be undefined as far as its final - nsize in object memory is concerned. The size of the object - in objectmemory is not explicitly given. - If the object is defined its length can be determined and - a fix can replace the frag. - */ - { - int temp; - segment=evaluate_expr(&exprP,(char*)iif.iifP[i].object); - if ((exprP.X_add_symbol || exprP.X_subtract_symbol) && - !iif.iifP[i].pcrel) { /* OVE: hack, clamp to 4 bytes */ - size=4; /* we dont wan't to frag this, use 4 so it reaches */ - fix_new_ns32k(frag_now, - (long)(memP-frag_now->fr_literal), - size, - exprP.X_add_symbol, - exprP.X_subtract_symbol, - exprP.X_add_number, - 0, /* never iif.iifP[i].pcrel, */ - (char)size_so_far, /*iif.iifP[i].pcrel_adjust,*/ - 1, /* always iif.iifP[i].im_disp, */ - 0,0); - memP+=size; - rem_size-=4; - break; /* exit this absolute hack */ - } - - if (exprP.X_add_symbol || exprP.X_subtract_symbol) { /* frag it */ - if (exprP.X_subtract_symbol) { /* We cant relax this case */ - as_fatal("Can't relax difference"); - } - else { - /* at this stage we must undo some of the effect caused - by frag_more, ie we must make sure that frag_var causes - frag_new to creat a valid fix-size in the frag it`s closing - */ - temp = -(rem_size-4); - obstack_blank_fast(&frags,temp); - /* we rewind none, some or all of the requested size we - requested by the first frag_more for this iif chunk. - Note: that we allocate 4 bytes to an object we NOT YET - know the size of, thus rem_size-4. - */ - (void)frag_variant(rs_machine_dependent, - 4, - 0, - IND(BRANCH,UNDEF), /* expecting the worst */ - exprP.X_add_symbol, - exprP.X_add_number, - (char*)inst_opcode, - (char)size_so_far, /*iif.iifP[i].pcrel_adjust);*/ - iif.iifP[i].bsr); /* sequent linker hack */ - rem_size-=4; - if (rem_size>0) { - memP=frag_more(rem_size); - } - } - } - else {/* Double work, this is done in md_number_to_disp */ -/* exprP.X_add_number; what was this supposed to be? - xoxorich. */ - if (-64<=exprP.X_add_number && exprP.X_add_number<=63) { - size=1; - } else { - if (-8192<=exprP.X_add_number && exprP.X_add_number<=8191) { - size=2; - } else { - if (-0x1f000000<=exprP.X_add_number && - exprP.X_add_number<=0x1fffffff) - /* if (-0x40000000<=exprP.X_add_number && - exprP.X_add_number<=0x3fffffff) */ - { - size=4; - } else { - as_warn("Displacement to large for :d"); - size=4; - } - } - } - /* rewind the bytes not used */ - temp = -(4-size); - md_number_to_disp(memP,exprP.X_add_number,size); - obstack_blank_fast(&frags,temp); - memP+=size; - rem_size-=4; /* we allocated this amount */ - } - } - break; - default: - as_fatal("Internal logic error in iif.iifP[].type"); - } - size_so_far+=size; - size=0; - } - } -} - -void md_assemble(line) -char *line; -{ - freeptr=freeptr_static; - parse(line,0); /* explode line to more fix form in iif */ - convert_iif(); /* convert iif to frags, fix's etc */ -#ifdef SHOW_NUM - printf(" \t\t\t%s\n",line); -#endif -} - - -void md_begin() { - /* build a hashtable of the instructions */ - register const struct ns32k_opcode *ptr; - register char *stat; - inst_hash_handle=hash_new(); - for (ptr=ns32k_opcodes;ptrname,(char*)ptr))) { - as_fatal("Can't hash %s: %s", ptr->name,stat); /*fatal*/ - exit(0); - } - } - freeptr_static=(char*)malloc(PRIVATE_SIZE); /* some private space please! */ -} - - -void -md_end() { - free(freeptr_static); -} - -/* Must be equal to MAX_PRECISON in atof-ieee.c */ -#define MAX_LITTLENUMS 6 - -/* Turn the string pointed to by litP into a floating point constant of type - type, and emit the appropriate bytes. The number of LITTLENUMS emitted - is stored in *sizeP . An error message is returned, or NULL on OK. - */ -char * -md_atof(type,litP,sizeP) -char type; -char *litP; -int *sizeP; -{ - int prec; - LITTLENUM_TYPE words[MAX_LITTLENUMS]; - LITTLENUM_TYPE *wordP; - char *t; - - switch(type) { - case 'f': - prec = 2; - break; - - case 'd': - prec = 4; - break; - default: - *sizeP=0; - return "Bad call to MD_ATOF()"; - } - t=atof_ieee(input_line_pointer,type,words); - if(t) - input_line_pointer=t; - - *sizeP=prec * sizeof(LITTLENUM_TYPE); - for(wordP=words+prec;prec--;) { - md_number_to_chars(litP,(long)(*--wordP),sizeof(LITTLENUM_TYPE)); - litP+=sizeof(LITTLENUM_TYPE); - } - return ""; /* Someone should teach Dean about null pointers */ -} - -/* Convert number to chars in correct order */ - -void -md_number_to_chars (buf, value, nbytes) - char *buf; - long value; - int nbytes; -{ - while (nbytes--) - { -#ifdef SHOW_NUM - printf("%x ",value & 0xff); -#endif - *buf++ = value; /* Lint wants & MASK_CHAR. */ - value >>= BITS_PER_CHAR; - } -} -/* Convert number to chars in correct order */ - - - -/* This is a variant of md_numbers_to_chars. The reason for its' existence - is the fact that ns32k uses Huffman coded displacements. This implies - that the bit order is reversed in displacements and that they are prefixed - with a size-tag. - - binary: msb -> lsb 0xxxxxxx byte - 10xxxxxx xxxxxxxx word - 11xxxxxx xxxxxxxx xxxxxxxx xxxxxxxx double word - - This must be taken care of and we do it here! - */ -static void md_number_to_disp(buf,val,n) - char *buf; - long val; - char n; -{ - switch(n) { - case 1: - if (val < -64 || val > 63) - as_warn("Byte displacement out of range. line number not valid"); - val&=0x7f; -#ifdef SHOW_NUM - printf("%x ",val & 0xff); -#endif - *buf++=val; - break; - case 2: - if (val < -8192 || val > 8191) - as_warn("Word displacement out of range. line number not valid"); - val&=0x3fff; - val|=0x8000; -#ifdef SHOW_NUM - printf("%x ",val>>8 & 0xff); -#endif - *buf++=(val>>8); -#ifdef SHOW_NUM - printf("%x ",val & 0xff); -#endif - *buf++=val; - break; - case 4: - if (val < -0x1f000000 || val >= 0x20000000) - /* if (val < -0x20000000 || val >= 0x20000000) */ - as_warn("Double word displacement out of range"); - val|=0xc0000000; -#ifdef SHOW_NUM - printf("%x ",val>>24 & 0xff); -#endif - *buf++=(val>>24); -#ifdef SHOW_NUM - printf("%x ",val>>16 & 0xff); -#endif - *buf++=(val>>16); -#ifdef SHOW_NUM - printf("%x ",val>>8 & 0xff); -#endif - *buf++=(val>>8); -#ifdef SHOW_NUM - printf("%x ",val & 0xff); -#endif - *buf++=val; - break; - default: - as_fatal("Internal logic error. line %s, file \"%s\"", __LINE__, __FILE__); - } -} - -static void md_number_to_imm(buf,val,n) - char *buf; - long val; - char n; -{ - switch(n) { - case 1: -#ifdef SHOW_NUM - printf("%x ",val & 0xff); -#endif - *buf++=val; - break; - case 2: -#ifdef SHOW_NUM - printf("%x ",val>>8 & 0xff); -#endif - *buf++=(val>>8); -#ifdef SHOW_NUM - printf("%x ",val & 0xff); -#endif - *buf++=val; - break; - case 4: -#ifdef SHOW_NUM - printf("%x ",val>>24 & 0xff); -#endif - *buf++=(val>>24); -#ifdef SHOW_NUM - printf("%x ",val>>16 & 0xff); -#endif - *buf++=(val>>16); -#ifdef SHOW_NUM - printf("%x ",val>>8 & 0xff); -#endif - *buf++=(val>>8); -#ifdef SHOW_NUM - printf("%x ",val & 0xff); -#endif - *buf++=val; - break; - default: - as_fatal("Internal logic error. line %s, file \"%s\"", __LINE__, __FILE__); - } -} - -/* Translate internal representation of relocation info into target format. - - OVE: on a ns32k the twiddling continues at an even deeper level - here we have to distinguish between displacements and immediates. - - The sequent has a bit for this. It also has a bit for relocobjects that - points at the target for a bsr (BranchSubRoutine) !?!?!?! - - This md_ri.... is tailored for sequent. - */ - -void -md_ri_to_chars(the_bytes, ri) - char *the_bytes; - struct reloc_info_generic *ri; -{ - if (ri->r_bsr) {ri->r_pcrel=0;} /* sequent seems to want this */ - md_number_to_chars(the_bytes, ri->r_address, sizeof(ri->r_address)); - md_number_to_chars(the_bytes+4, - (long)(ri->r_symbolnum ) | - (long)(ri->r_pcrel << 24 ) | - (long)(ri->r_length << 25 ) | - (long)(ri->r_extern << 27 ) | - (long)(ri->r_bsr << 28 ) | - (long)(ri->r_disp << 29 ), - 4); - /* the first and second md_number_to_chars never overlaps (32bit cpu case) */ -} - -/* fast bitfiddling support */ -/* mask used to zero bitfield before oring in the true field */ - -static unsigned long l_mask[]={ 0xffffffff, 0xfffffffe, 0xfffffffc, 0xfffffff8, - 0xfffffff0, 0xffffffe0, 0xffffffc0, 0xffffff80, - 0xffffff00, 0xfffffe00, 0xfffffc00, 0xfffff800, - 0xfffff000, 0xffffe000, 0xffffc000, 0xffff8000, - 0xffff0000, 0xfffe0000, 0xfffc0000, 0xfff80000, - 0xfff00000, 0xffe00000, 0xffc00000, 0xff800000, - 0xff000000, 0xfe000000, 0xfc000000, 0xf8000000, - 0xf0000000, 0xe0000000, 0xc0000000, 0x80000000, - }; -static unsigned long r_mask[]={ 0x00000000, 0x00000001, 0x00000003, 0x00000007, - 0x0000000f, 0x0000001f, 0x0000003f, 0x0000007f, - 0x000000ff, 0x000001ff, 0x000003ff, 0x000007ff, - 0x00000fff, 0x00001fff, 0x00003fff, 0x00007fff, - 0x0000ffff, 0x0001ffff, 0x0003ffff, 0x0007ffff, - 0x000fffff, 0x001fffff, 0x003fffff, 0x007fffff, - 0x00ffffff, 0x01ffffff, 0x03ffffff, 0x07ffffff, - 0x0fffffff, 0x1fffffff, 0x3fffffff, 0x7fffffff, - }; -#define MASK_BITS 31 -/* Insert bitfield described by field_ptr and val at buf - This routine is written for modification of the first 4 bytes pointed - to by buf, to yield speed. - The ifdef stuff is for selection between a ns32k-dependent routine - and a general version. (My advice: use the general version!) - */ - -static void -md_number_to_field(buf,val,field_ptr) - register char *buf; - register long val; - register bit_fixS *field_ptr; -{ - register unsigned long object; - register unsigned long mask; -/* define ENDIAN on a ns32k machine */ -#ifdef ENDIAN - register unsigned long *mem_ptr; -#else - register char *mem_ptr; -#endif - if (field_ptr->fx_bit_min<=val && val<=field_ptr->fx_bit_max) { -#ifdef ENDIAN - if (field_ptr->fx_bit_base) { /* override buf */ - mem_ptr=(unsigned long*)field_ptr->fx_bit_base; - } else { - mem_ptr=(unsigned long*)buf; - } -#else - if (field_ptr->fx_bit_base) { /* override buf */ - mem_ptr=(char*)field_ptr->fx_bit_base; - } else { - mem_ptr=buf; - } -#endif - mem_ptr+=field_ptr->fx_bit_base_adj; -#ifdef ENDIAN /* we have a nice ns32k machine with lowbyte at low-physical mem */ - object = *mem_ptr; /* get some bytes */ -#else /* OVE Goof! the machine is a m68k or dito */ - /* That takes more byte fiddling */ - object=0; - object|=mem_ptr[3] & 0xff; - object<<=8; - object|=mem_ptr[2] & 0xff; - object<<=8; - object|=mem_ptr[1] & 0xff; - object<<=8; - object|=mem_ptr[0] & 0xff; -#endif - mask=0; - mask|=(r_mask[field_ptr->fx_bit_offset]); - mask|=(l_mask[field_ptr->fx_bit_offset+field_ptr->fx_bit_size]); - object&=mask; - val+=field_ptr->fx_bit_add; - object|=((val<fx_bit_offset) & (mask ^ 0xffffffff)); -#ifdef ENDIAN - *mem_ptr=object; -#else - mem_ptr[0]=(char)object; - object>>=8; - mem_ptr[1]=(char)object; - object>>=8; - mem_ptr[2]=(char)object; - object>>=8; - mem_ptr[3]=(char)object; -#endif - } else { - as_warn("Bit field out of range"); - } -} - -/* Apply a fixS (fixup of an instruction or data that we didn't have - enough info to complete immediately) to the data in a frag. - - On the ns32k, everything is in a different format, so we have broken - out separate functions for each kind of thing we could be fixing. - They all get called from here. */ - -void -md_apply_fix(fixP, val) - fixS *fixP; - long val; -{ - char *buf = fixP->fx_where + fixP->fx_frag->fr_literal; - - if (fixP->fx_bit_fixP) { /* Bitfields to fix, sigh */ - md_number_to_field (buf, val, fixP->fx_bit_fixP); - } else switch (fixP->fx_im_disp) { - - case 0: /* Immediate field */ - md_number_to_imm (buf, val, fixP->fx_size); - break; - - case 1: /* Displacement field */ - md_number_to_disp (buf, - fixP->fx_pcrel? val + fixP->fx_pcrel_adjust: val, - fixP->fx_size); - break; - - case 2: /* Pointer in a data object */ - md_number_to_chars (buf, val, fixP->fx_size); - break; - } -} - -/* Convert a relaxed displacement to ditto in final output */ - -void -md_convert_frag(fragP) -register fragS *fragP; -{ - long disp; - long ext; - - /* Address in gas core of the place to store the displacement. */ - register char *buffer_address = fragP -> fr_fix + fragP -> fr_literal; - /* Address in object code of the displacement. */ - register int object_address = fragP -> fr_fix + fragP -> fr_address; - - know(fragP->fr_symbol); - - /* The displacement of the address, from current location. */ - disp = (S_GET_VALUE(fragP->fr_symbol) + fragP->fr_offset) - object_address; - disp+= fragP->fr_pcrel_adjust; - - switch(fragP->fr_subtype) { - case IND(BRANCH,BYTE): - ext=1; - break; - case IND(BRANCH,WORD): - ext=2; - break; - case IND(BRANCH,DOUBLE): - ext=4; - break; - } - if(ext) { - md_number_to_disp(buffer_address,(long)disp,(int)ext); - fragP->fr_fix+=ext; - } -} - - - -/* This function returns the estimated size a variable object will occupy, - one can say that we tries to guess the size of the objects before we - actually know it */ - -int md_estimate_size_before_relax(fragP, segment) - register fragS *fragP; - segT segment; -{ - int old_fix; - old_fix=fragP->fr_fix; - switch(fragP->fr_subtype) { - case IND(BRANCH,UNDEF): - if(S_GET_SEGMENT(fragP->fr_symbol) == segment) { - /* the symbol has been assigned a value */ - fragP->fr_subtype=IND(BRANCH,BYTE); - } else { - /* we don't relax symbols defined in an other segment - the thing to do is to assume the object will occupy 4 bytes */ - fix_new_ns32k(fragP, - (int)(fragP->fr_fix), - 4, - fragP->fr_symbol, - (symbolS *)0, - fragP->fr_offset, - 1, - fragP->fr_pcrel_adjust, - 1, - 0, - fragP->fr_bsr); /*sequent hack */ - fragP->fr_fix+=4; - /* fragP->fr_opcode[1]=0xff; */ - frag_wane(fragP); - break; - } - case IND(BRANCH,BYTE): - fragP->fr_var+=1; - break; - default: - break; - } - return fragP->fr_var + fragP->fr_fix - old_fix; -} - -int md_short_jump_size = 3; -int md_long_jump_size = 5; -int md_reloc_size = 8; /* Size of relocation record */ - -void -md_create_short_jump(ptr,from_addr,to_addr,frag,to_symbol) -char *ptr; -long from_addr, - to_addr; -fragS *frag; -symbolS *to_symbol; -{ - long offset; - - offset = to_addr - from_addr; - md_number_to_chars(ptr, (long)0xEA ,1); - md_number_to_disp(ptr+1,(long)offset,2); -} - -void -md_create_long_jump(ptr,from_addr,to_addr,frag,to_symbol) -char *ptr; -long from_addr, - to_addr; -fragS *frag; -symbolS *to_symbol; -{ - long offset; - - offset= to_addr - from_addr; - md_number_to_chars(ptr, (long)0xEA, 2); - md_number_to_disp(ptr+2,(long)offset,4); -} - -/* JF this is a new function to parse machine-dep options */ -int -md_parse_option(argP,cntP,vecP) -char **argP; -int *cntP; -char ***vecP; -{ - switch(**argP) { - case 'm': - (*argP)++; - - if(!strcmp(*argP,"32032")) { - cpureg = cpureg_032; - mmureg = mmureg_032; - } else if(!strcmp(*argP, "32532")) { - cpureg = cpureg_532; - mmureg = mmureg_532; - } else - as_warn("Unknown -m option ignored"); - - while(**argP) - (*argP)++; - break; - - default: - return 0; - } - return 1; -} - -/* - * bit_fix_new() - * - * Create a bit_fixS in obstack 'notes'. - * This struct is used to profile the normal fix. If the bit_fixP is a - * valid pointer (not NULL) the bit_fix data will be used to format the fix. - */ -bit_fixS *bit_fix_new (size,offset,min,max,add,base_type,base_adj) - char size; /* Length of bitfield */ - char offset; /* Bit offset to bitfield */ - long base_type; /* 0 or 1, if 1 it's exploded to opcode ptr */ - long base_adj; - long min; /* Signextended min for bitfield */ - long max; /* Signextended max for bitfield */ - long add; /* Add mask, used for huffman prefix */ -{ - register bit_fixS * bit_fixP; - - bit_fixP = (bit_fixS *)obstack_alloc(¬es,sizeof(bit_fixS)); - - bit_fixP -> fx_bit_size = size; - bit_fixP -> fx_bit_offset = offset; - bit_fixP -> fx_bit_base = base_type; - bit_fixP -> fx_bit_base_adj = base_adj; - bit_fixP -> fx_bit_max = max; - bit_fixP -> fx_bit_min = min; - bit_fixP -> fx_bit_add = add; - - return bit_fixP; -} - -void -fix_new_ns32k (frag, where, size, add_symbol, sub_symbol, offset, pcrel, - pcrel_adjust, im_disp, bit_fixP, bsr) - fragS * frag; /* Which frag? */ - int where; /* Where in that frag? */ - short int size; /* 1, 2 or 4 usually. */ - symbolS * add_symbol; /* X_add_symbol. */ - symbolS * sub_symbol; /* X_subtract_symbol. */ - long offset; /* X_add_number. */ - int pcrel; /* TRUE if PC-relative relocation. */ - char pcrel_adjust; /* not zero if adjustment of pcrel offset is needed */ - char im_disp; /* true if the value to write is a displacement */ - bit_fixS *bit_fixP; /* pointer at struct of bit_fix's, ignored if NULL */ - char bsr; /* sequent-linker-hack: 1 when relocobject is a bsr */ - -{ - register fixS * fixP; - - fixP = (fixS *)obstack_alloc(¬es,sizeof(fixS)); - fixP -> fx_frag = frag; - fixP -> fx_where = where; - fixP -> fx_size = size; - fixP -> fx_addsy = add_symbol; - fixP -> fx_subsy = sub_symbol; - fixP -> fx_offset = offset; - fixP -> fx_pcrel = pcrel; - fixP -> fx_pcrel_adjust = pcrel_adjust; - fixP -> fx_im_disp = im_disp; - fixP -> fx_bit_fixP = bit_fixP; - fixP -> fx_bsr = bsr; - fixP -> fx_next = * seg_fix_rootP; - - * seg_fix_rootP = fixP; -} - -/* We have no need to default values of symbols. */ - -symbolS * -md_undefined_symbol (name) - char *name; -{ - return 0; -} - -/* Parse an operand that is machine-specific. - We just return without modifying the expression if we have nothing - to do. */ - -/* ARGSUSED */ -void -md_operand (expressionP) - expressionS *expressionP; -{ -} - -/* Round up a section size to the appropriate boundary. */ -long -md_section_align (segment, size) - segT segment; - long size; -{ - return size; /* Byte alignment is fine */ -} - -/* Exactly what point is a PC-relative offset relative TO? - On the National warts, they're relative to the address of the offset, - with some funny adjustments in some circumstances during blue moons. - (??? Is this right? FIXME-SOON) */ -long -md_pcrel_from (fixP) - fixS *fixP; -{ - long res; - res = fixP->fx_where + fixP->fx_frag->fr_address; -#ifdef SEQUENT_COMPATABILITY - if (fixP->fx_frag->fr_bsr) - res += 0x12 /* FOO Kludge alert! */ -#endif - return res; -} - -/* - * $Log$ - * Revision 1.1 1991/04/04 18:17:05 rich - * Initial revision - * - * - */ - -/* - * Local Variables: - * comment-column: 0 - * End: - */ - -/* end of tc-ns32k.c */ diff --git a/gas/config/tc-ns32k.h b/gas/config/tc-ns32k.h deleted file mode 100644 index b96b6504dcb..00000000000 --- a/gas/config/tc-ns32k.h +++ /dev/null @@ -1,57 +0,0 @@ -/* ns32k-opcode.h -- Opcode table for National Semi 32k processor - Copyright (C) 1987 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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 1, or (at your option) -any later version. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - - -#ifdef SEQUENT_COMPATABILITY -#define DEF_MODEC 20 -#define DEF_MODEL 21 -#endif - -#ifndef DEF_MODEC -#define DEF_MODEC 20 -#endif - -#ifndef DEF_MODEL -#define DEF_MODEL 20 -#endif - -#define MAX_ARGS 4 -#define ARG_LEN 50 - -#ifdef __STDC__ - -void fix_new_ns32k(fragS *frag, - int where, - void *add_symbol, /* really symbolS */ - void *sub_symbol, /* really symbolS */ - long offset, - int pcrel, - int pcrel_adjust, - int im_disp, - void *bit_fixP, /* really bit_fixS */ - int bsr); - -#else /* __STDC__ */ - -void fix_new_ns32k(); - -#endif /* __STDC__ */ - - -/* end of tc-ns32k.h */ diff --git a/gas/config/tc-rs6000.c b/gas/config/tc-rs6000.c deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/gas/config/tc-rs6000.h b/gas/config/tc-rs6000.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/gas/config/tc-sparc.c b/gas/config/tc-sparc.c deleted file mode 100644 index 75935132b8f..00000000000 --- a/gas/config/tc-sparc.c +++ /dev/null @@ -1,1728 +0,0 @@ -/* tc-sparc.c -- Assemble for the SPARC - Copyright (C) 1989, 1990, 1991 Free Software Foundation, Inc. - - This file is part of GAS, the GNU Assembler. - - GAS 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. - - GAS 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 GAS; see the file COPYING. If not, write to - the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* static const char rcsid[] = "$Id$"; */ - -#include -#include - -#include "as.h" - -/* careful, this file includes data *declarations* */ -#include "sparc-opcode.h" - -void md_begin(); -void md_end(); -void md_number_to_chars(); -void md_assemble(); -char *md_atof(); -void md_convert_frag(); -void md_create_short_jump(); -void md_create_long_jump(); -int md_estimate_size_before_relax(); -void md_ri_to_chars(); -symbolS *md_undefined_symbol(); -static void sparc_ip(); - -static enum sparc_architecture current_architecture = v6; -static int architecture_requested = 0; -static int warn_on_bump = 0; - -const relax_typeS md_relax_table[] = { - 0 }; - -/* handle of the OPCODE hash table */ -static struct hash_control *op_hash = NULL; - -static void s_seg(), s_proc(), s_data1(), s_reserve(), s_common(); -extern void s_globl(), s_long(), s_short(), s_space(), cons(); -extern void s_align_bytes(), s_ignore(); - -const pseudo_typeS md_pseudo_table[] = { - { "align", s_align_bytes, 0 }, /* Defaulting is invalid (0) */ - { "common", s_common, 0 }, - { "global", s_globl, 0 }, - { "half", cons, 2 }, - { "optim", s_ignore, 0 }, - { "proc", s_proc, 0 }, - { "reserve", s_reserve, 0 }, - { "seg", s_seg, 0 }, - { "skip", s_space, 0 }, - { "word", cons, 4 }, - { NULL, 0, 0 }, -}; - -const int md_short_jump_size = 4; -const int md_long_jump_size = 4; -const int md_reloc_size = 12; /* Size of relocation record */ - -/* This array holds the chars that always start a comment. If the - pre-processor is disabled, these aren't very useful */ -const char comment_chars[] = "!"; /* JF removed '|' from comment_chars */ - -/* This array holds the chars that only start a comment at the beginning of - a line. If the line seems to have the form '# 123 filename' - .line and .file directives will appear in the pre-processed output */ -/* Note that input_file.c hand checks for '#' at the beginning of the - first line of the input file. This is because the compiler outputs - #NO_APP at the beginning of its output. */ -/* Also note that comments started like this one will always - work if '/' isn't otherwise defined. */ -const char line_comment_chars[] = "#"; - -/* Chars that can be used to separate mant from exp in floating point nums */ -const char EXP_CHARS[] = "eE"; - -/* Chars that mean this number is a floating point constant */ -/* As in 0f12.456 */ -/* or 0d1.2345e12 */ -const char FLT_CHARS[] = "rRsSfFdDxXpP"; - -/* Also be aware that MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT may have to be - changed in read.c . Ideally it shouldn't have to know about it at all, - but nothing is ideal around here. - */ - -static unsigned char octal[256]; -#define isoctal(c) octal[c] -static unsigned char toHex[256]; - -struct sparc_it { - char *error; - unsigned long opcode; - struct nlist *nlistp; - expressionS exp; - int pcrel; - enum reloc_type reloc; -} the_insn, set_insn; - -#ifdef __STDC__ -#if 0 -static void print_insn(struct sparc_it *insn); -#endif -static int getExpression(char *str); -#else -#if 0 -static void print_insn(); -#endif -static int getExpression(); -#endif -static char *expr_end; -static int special_case; - -/* - * Instructions that require wierd handling because they're longer than - * 4 bytes. - */ -#define SPECIAL_CASE_SET 1 -#define SPECIAL_CASE_FDIV 2 - -/* - * sort of like s_lcomm - * - */ -static void s_reserve() { - char *name; - char c; - char *p; - int temp; - symbolS *symbolP; - - name = input_line_pointer; - c = get_symbol_end(); - p = input_line_pointer; - *p = c; - SKIP_WHITESPACE(); - if (* input_line_pointer != ',') { - as_bad("Expected comma after name"); - ignore_rest_of_line(); - return; - } - input_line_pointer ++; - if ((temp = get_absolute_expression()) < 0) { - as_bad("BSS length (%d.) <0! Ignored.", temp); - ignore_rest_of_line(); - return; - } - *p = 0; - symbolP = symbol_find_or_make(name); - *p = c; - if (strncmp(input_line_pointer, ",\"bss\"", 6) != 0) { - as_bad("bad .reserve segment: `%s'", input_line_pointer); - return; - } - input_line_pointer += 6; - if (S_GET_OTHER(symbolP) == 0 - && S_GET_DESC(symbolP) == 0 - && ((S_GET_TYPE(symbolP) == N_BSS - && S_GET_VALUE(symbolP) == local_bss_counter) - || !S_IS_DEFINED(symbolP))) { - S_SET_VALUE(symbolP, local_bss_counter); - S_SET_SEGMENT(symbolP, SEG_BSS); - symbolP->sy_frag = & bss_address_frag; - local_bss_counter += temp; - } else { - as_warn("Ignoring attempt to re-define symbol from %d. to %d.", - S_GET_VALUE(symbolP), local_bss_counter); - } - demand_empty_rest_of_line(); - return; -} /* s_reserve() */ - -static void s_common() { - register char *name; - register char c; - register char *p; - register int temp; - register symbolS * symbolP; - - name = input_line_pointer; - c = get_symbol_end(); - /* just after name is now '\0' */ - p = input_line_pointer; - *p = c; - SKIP_WHITESPACE(); - if (* input_line_pointer != ',') { - as_bad("Expected comma after symbol-name"); - ignore_rest_of_line(); - return; - } - input_line_pointer ++; /* skip ',' */ - if ((temp = get_absolute_expression ()) < 0) { - as_bad(".COMMon length (%d.) <0! Ignored.", temp); - ignore_rest_of_line(); - return; - } - *p = 0; - symbolP = symbol_find_or_make(name); - *p = c; - if (S_IS_DEFINED(symbolP)) { - as_bad("Ignoring attempt to re-define symbol"); - ignore_rest_of_line(); - return; - } - if (S_GET_VALUE(symbolP) != 0) { - if (S_GET_VALUE(symbolP) != temp) { - as_warn("Length of .comm \"%s\" is already %d. Not changed to %d.", - S_GET_NAME(symbolP), S_GET_VALUE(symbolP), temp); - } - } else { - S_SET_VALUE(symbolP, temp); - S_SET_EXTERNAL(symbolP); - } - know(symbolP->sy_frag == &zero_address_frag); - if (strncmp(input_line_pointer, ",\"bss\"", 6) != 0 - && strncmp(input_line_pointer, ",\"data\"", 7) != 0) { - p=input_line_pointer; - while(*p && *p!='\n') - p++; - c= *p; - *p='\0'; - as_bad("bad .common segment: `%s'", input_line_pointer); - *p=c; - return; - } - input_line_pointer += 6 + (input_line_pointer[2] == 'd'); /* Skip either */ - demand_empty_rest_of_line(); - return; -} /* s_common() */ - -static void s_seg() { - - if (strncmp(input_line_pointer, "\"text\"", 6) == 0) { - input_line_pointer += 6; - s_text(); - return; - } - if (strncmp(input_line_pointer, "\"data\"", 6) == 0) { - input_line_pointer += 6; - s_data(); - return; - } - if (strncmp(input_line_pointer, "\"data1\"", 7) == 0) { - input_line_pointer += 7; - s_data1(); - return; - } - if (strncmp(input_line_pointer, "\"bss\"", 5) == 0) { - input_line_pointer += 5; - /* We only support 2 segments -- text and data -- for now, so - things in the "bss segment" will have to go into data for now. - You can still allocate SEG_BSS stuff with .lcomm or .reserve. */ - subseg_new(SEG_DATA, 255); /* FIXME-SOMEDAY */ - return; - } - as_bad("Unknown segment type"); - demand_empty_rest_of_line(); - return; -} /* s_seg() */ - -static void s_data1() { - subseg_new(SEG_DATA, 1); - demand_empty_rest_of_line(); - return; -} /* s_data1() */ - -static void s_proc() { - extern char is_end_of_line[]; - - while (!is_end_of_line[*input_line_pointer]) { - ++input_line_pointer; - } - ++input_line_pointer; - return; -} /* s_proc() */ - -/* This function is called once, at assembler startup time. It should - set up all the tables, etc. that the MD part of the assembler will need. */ -void md_begin() { - register char *retval = NULL; - int lose = 0; - register unsigned int i = 0; - - op_hash = hash_new(); - if (op_hash == NULL) - as_fatal("Virtual memory exhausted"); - - while (i < NUMOPCODES) { - const char *name = sparc_opcodes[i].name; - retval = hash_insert(op_hash, name, &sparc_opcodes[i]); - if(retval != NULL && *retval != '\0') { - fprintf (stderr, "internal error: can't hash `%s': %s\n", - sparc_opcodes[i].name, retval); - lose = 1; - } - do - { - if (sparc_opcodes[i].match & sparc_opcodes[i].lose) { - fprintf (stderr, "internal error: losing opcode: `%s' \"%s\"\n", - sparc_opcodes[i].name, sparc_opcodes[i].args); - lose = 1; - } - ++i; - } while (i < NUMOPCODES - && !strcmp(sparc_opcodes[i].name, name)); - } - - if (lose) - as_fatal("Broken assembler. No assembly attempted."); - - for (i = '0'; i < '8'; ++i) - octal[i] = 1; - for (i = '0'; i <= '9'; ++i) - toHex[i] = i - '0'; - for (i = 'a'; i <= 'f'; ++i) - toHex[i] = i + 10 - 'a'; - for (i = 'A'; i <= 'F'; ++i) - toHex[i] = i + 10 - 'A'; -} /* md_begin() */ - -void md_end() { - return; -} /* md_end() */ - -void md_assemble(str) -char *str; -{ - char *toP; - int rsd; - - know(str); - sparc_ip(str); - - /* See if "set" operand is absolute and small; skip sethi if so. */ - if (special_case == SPECIAL_CASE_SET && the_insn.exp.X_seg == SEG_ABSOLUTE) { - if (the_insn.exp.X_add_number >= -(1<<12) - && the_insn.exp.X_add_number < (1<<12)) { - the_insn.opcode = 0x80102000 /* or %g0,imm,... */ - | (the_insn.opcode & 0x3E000000) /* dest reg */ - | (the_insn.exp.X_add_number & 0x1FFF); /* imm */ - special_case = 0; /* No longer special */ - the_insn.reloc = NO_RELOC; /* No longer relocated */ - } - } - - toP = frag_more(4); - /* put out the opcode */ - md_number_to_chars(toP, the_insn.opcode, 4); - - /* put out the symbol-dependent stuff */ - if (the_insn.reloc != NO_RELOC) { - fix_new(frag_now, /* which frag */ - (toP - frag_now->fr_literal), /* where */ - 4, /* size */ - the_insn.exp.X_add_symbol, - the_insn.exp.X_subtract_symbol, - the_insn.exp.X_add_number, - the_insn.pcrel, - the_insn.reloc); - } - switch (special_case) { - - case SPECIAL_CASE_SET: - special_case = 0; - assert(the_insn.reloc == RELOC_HI22); - /* See if "set" operand has no low-order bits; skip OR if so. */ - if (the_insn.exp.X_seg == SEG_ABSOLUTE - && ((the_insn.exp.X_add_number & 0x3FF) == 0)) - return; - toP = frag_more(4); - rsd = (the_insn.opcode >> 25) & 0x1f; - the_insn.opcode = 0x80102000 | (rsd << 25) | (rsd << 14); - md_number_to_chars(toP, the_insn.opcode, 4); - fix_new(frag_now, /* which frag */ - (toP - frag_now->fr_literal), /* where */ - 4, /* size */ - the_insn.exp.X_add_symbol, - the_insn.exp.X_subtract_symbol, - the_insn.exp.X_add_number, - the_insn.pcrel, - RELOC_LO10); - return; - - case SPECIAL_CASE_FDIV: - /* According to information leaked from Sun, the "fdiv" instructions - on early SPARC machines would produce incorrect results sometimes. - The workaround is to add an fmovs of the destination register to - itself just after the instruction. This was true on machines - with Weitek 1165 float chips, such as the Sun-4/260 and /280. */ - special_case = 0; - assert(the_insn.reloc == NO_RELOC); - toP = frag_more(4); - rsd = (the_insn.opcode >> 25) & 0x1f; - the_insn.opcode = 0x81A00020 | (rsd << 25) | rsd; /* fmovs dest,dest */ - md_number_to_chars(toP, the_insn.opcode, 4); - return; - - case 0: - return; - - default: - as_fatal("failed sanity check."); - } -} /* md_assemble() */ - -static void sparc_ip(str) -char *str; -{ - char *error_message = ""; - char *s; - const char *args; - char c; - struct sparc_opcode *insn; - char *argsStart; - unsigned long opcode; - unsigned int mask = 0; - int match = 0; - int comma = 0; - - for (s = str; islower(*s) || (*s >= '0' && *s <= '3'); ++s) - ; - switch (*s) { - - case '\0': - break; - - case ',': - comma = 1; - - /*FALLTHROUGH */ - - case ' ': - *s++ = '\0'; - break; - - default: - as_bad("Unknown opcode: `%s'", str); - exit(1); - } - if ((insn = (struct sparc_opcode *) hash_find(op_hash, str)) == NULL) { - as_bad("Unknown opcode: `%s'", str); - return; - } - if (comma) { - *--s = ','; - } - argsStart = s; - for (;;) { - opcode = insn->match; - bzero(&the_insn, sizeof(the_insn)); - the_insn.reloc = NO_RELOC; - - /* - * Build the opcode, checking as we go to make - * sure that the operands match - */ - for (args = insn->args; ; ++args) { - switch (*args) { - - case 'M': - case 'm': - if (strncmp(s, "%asr", 4) == 0) { - s += 4; - - if (isdigit(*s)) { - long num = 0; - - while (isdigit(*s)) { - num = num*10 + *s-'0'; - ++s; - } - - if (num < 16 || 31 < num) { - error_message = ": asr number must be between 15 and 31"; - goto error; - } /* out of range */ - - opcode |= (*args == 'M' ? RS1(num) : RD(num)); - continue; - } else { - error_message = ": expecting %asrN"; - goto error; - } /* if %asr followed by a number. */ - - } /* if %asr */ - break; - - /* start-sanitize-v9 */ -#ifndef NO_V9 - case 'I': - the_insn.reloc = RELOC_11; - goto immediate; - - case 'k': - the_insn.reloc = RELOC_WDISP2_14; - the_insn.pcrel = 1; - goto immediate; - - case 'G': - the_insn.reloc = RELOC_WDISP19; - the_insn.pcrel = 1; - goto immediate; - - case 'N': - if (*s == 'p' && s[1] == 'n') { - s += 2; - continue; - } - break; - - case 'T': - if (*s == 'p' && s[1] == 't') { - s += 2; - continue; - } - break; - - case 'Y': - if (strncmp(s, "%amr", 4) == 0) { - s += 4; - continue; - } - break; - - case 'z': - if (*s == ' ') { - ++s; - } - if (strncmp(s, "icc", 3) == 0) { - s += 3; - continue; - } - break; - - case 'Z': - if (*s == ' ') { - ++s; - } - if (strncmp(s, "xcc", 3) == 0) { - s += 3; - continue; - } - break; - - case '6': - if (*s == ' ') { - ++s; - } - if (strncmp(s, "fcc0", 4) == 0) { - s += 4; - continue; - } - break; - - case '7': - if (*s == ' ') { - ++s; - } - if (strncmp(s, "fcc1", 4) == 0) { - s += 4; - continue; - } - break; - - case '8': - if (*s == ' ') { - ++s; - } - if (strncmp(s, "fcc2", 4) == 0) { - s += 4; - continue; - } - break; - - case '9': - if (*s == ' ') { - ++s; - } - if (strncmp(s, "fcc3", 4) == 0) { - s += 4; - continue; - } - break; - - case 'P': - if (strncmp(s, "%pc", 3) == 0) { - s += 3; - continue; - } - break; - - case 'E': - if (strncmp(s, "%modes", 6) == 0) { - s += 6; - continue; - } - break; - - case 'W': - if (strncmp(s, "%tick", 5) == 0) { - s += 5; - continue; - } - break; -#endif /* NO_V9 */ - /* end-sanitize-v9 */ - - case '\0': /* end of args */ - if (*s == '\0') { - match = 1; - } - break; - - case '+': - if (*s == '+') { - ++s; - continue; - } - if (*s == '-') { - continue; - } - break; - - case '[': /* these must match exactly */ - case ']': - case ',': - case ' ': - if (*s++ == *args) - continue; - break; - - case '#': /* must be at least one digit */ - if (isdigit(*s++)) { - while (isdigit(*s)) { - ++s; - } - continue; - } - break; - - case 'C': /* coprocessor state register */ - if (strncmp(s, "%csr", 4) == 0) { - s += 4; - continue; - } - break; - - case 'b': /* next operand is a coprocessor register */ - case 'c': - case 'D': - if (*s++ == '%' && *s++ == 'c' && isdigit(*s)) { - mask = *s++; - if (isdigit(*s)) { - mask = 10 * (mask - '0') + (*s++ - '0'); - if (mask >= 32) { - break; - } - } else { - mask -= '0'; - } - switch (*args) { - - case 'b': - opcode |= mask << 14; - continue; - - case 'c': - opcode |= mask; - continue; - - case 'D': - opcode |= mask << 25; - continue; - } - } - break; - - case 'r': /* next operand must be a register */ - case '1': - case '2': - case 'd': - if (*s++ == '%') { - switch (c = *s++) { - - case 'f': /* frame pointer */ - if (*s++ == 'p') { - mask = 0x1e; - break; - } - goto error; - - case 'g': /* global register */ - if (isoctal(c = *s++)) { - mask = c - '0'; - break; - } - goto error; - - case 'i': /* in register */ - if (isoctal(c = *s++)) { - mask = c - '0' + 24; - break; - } - goto error; - - case 'l': /* local register */ - if (isoctal(c = *s++)) { - mask= (c - '0' + 16) ; - break; - } - goto error; - - case 'o': /* out register */ - if (isoctal(c = *s++)) { - mask= (c - '0' + 8) ; - break; - } - goto error; - - case 's': /* stack pointer */ - if (*s++ == 'p') { - mask= 0xe; - break; - } - goto error; - - case 'r': /* any register */ - if (!isdigit(c = *s++)) { - goto error; - } - /* FALLTHROUGH */ - case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - if (isdigit(*s)) { - if ((c = 10 * (c - '0') + (*s++ - '0')) >= 32) { - goto error; - } - } else { - c -= '0'; - } - mask= c; - break; - - default: - goto error; - } - /* - * Got the register, now figure out where - * it goes in the opcode. - */ - switch (*args) { - - case '1': - opcode |= mask << 14; - continue; - - case '2': - opcode |= mask; - continue; - - case 'd': - opcode |= mask << 25; - continue; - - case 'r': - opcode |= (mask << 25) | (mask << 14); - continue; - } - } - break; - - /* start-sanitize-v9 */ -#ifndef NO_V9 - case 'j': - case 'u': - case 'U': -#endif /* NO_V9 */ - /* end-sanitize-v9 */ - case 'e': /* next operand is a floating point register */ - case 'v': - case 'V': - - case 'f': - case 'B': - case 'R': - - case 'g': - case 'H': - case 'J': { - char format; - - if (*s++ == '%' - - /* start-sanitize-v9 */ -#ifndef NO_V9 - && ((format = *s) == 'f' - || *s == 'd' - || *s == 'q') -#else - /* end-sanitize-v9 */ - && ((format = *s) == 'f') - - /* start-sanitize-v9 */ -#endif /* NO_V9 */ - /* end-sanitize-v9 */ - && isdigit(*++s)) { - - - - for (mask = 0; isdigit(*s); ++s) { - mask = 10 * mask + (*s - '0'); - } /* read the number */ - - if ((*args == 'u' - || *args == 'v' - || *args == 'B' - || *args == 'H') - && (mask & 1)) { - break; - } /* register must be even numbered */ - - if ((*args == 'U' - || *args == 'V' - || *args == 'R' - || *args == 'J') - && (mask & 3)) { - break; - } /* register must be multiple of 4 */ - - if (format == 'f') { - if (mask >= 32) { - error_message = ": There are only 32 f registers; [0-31]"; - goto error; - } /* on error */ - /* start-sanitize-v9 */ -#ifndef NO_V9 - } else { - if (format == 'd') { - if (mask >= 64) { - error_message = ": There are only 32 d registers [0, 2, ... 62]."; - goto error; - } else if (mask & 1) { - error_message = ": Only even numbered d registers exist."; - goto error; - } /* on error */ - - } else if (format == 'q') { - if (mask >= 64) { - error_message = - ": There are only 16 q registers [0, 4, ... 60]."; - goto error; - } else if (mask & 3) { - error_message = - ": Only q registers evenly divisible by four exist."; - goto error; - } /* on error */ - } else { - know(0); - } /* depending on format */ - - if (mask >= 32) { - mask -= 31; - } /* wrap high bit */ - } /* if not an 'f' register. */ -#endif /* NO_V9 */ - /* end-sanitize-v9 */ - } /* on error */ - - switch (*args) { - /* start-sanitize-v9 */ -#ifndef NO_V9 - case 'j': - case 'u': - case 'U': - opcode |= (mask & 0x1f) << 9; - continue; -#endif /* NO_V9 */ - /* end-sanitize-v9 */ - - case 'v': - case 'V': - case 'e': - opcode |= RS1(mask); - continue; - - - case 'f': - case 'B': - case 'R': - opcode |= RS2(mask); - continue; - - case 'g': - case 'H': - case 'J': - opcode |= RD(mask); - continue; - } /* pack it in. */ - - know(0); - break; - } /* float arg */ - - case 'F': - if (strncmp(s, "%fsr", 4) == 0) { - s += 4; - continue; - } - break; - - case 'h': /* high 22 bits */ - the_insn.reloc = RELOC_HI22; - goto immediate; - - case 'l': /* 22 bit PC relative immediate */ - the_insn.reloc = RELOC_WDISP22; - the_insn.pcrel = 1; - goto immediate; - - case 'L': /* 30 bit immediate */ - the_insn.reloc = RELOC_WDISP30; - the_insn.pcrel = 1; - goto immediate; - - case 'i': /* 13 bit immediate */ - the_insn.reloc = RELOC_BASE13; - - /*FALLTHROUGH */ - - immediate: - if(*s==' ') - s++; - if (*s == '%') { - if ((c = s[1]) == 'h' && s[2] == 'i') { - the_insn.reloc = RELOC_HI22; - s+=3; - } else if (c == 'l' && s[2] == 'o') { - the_insn.reloc = RELOC_LO10; - s+=3; - /* start-sanitize-v9 */ -#ifndef NO_V9 - } else if (c == 'h' - && s[2] == 'h' - && s[3] == 'i') { - the_insn.reloc = RELOC_HHI22; - s += 4; - - } else if (c == 'h' - && s[2] == 'l' - && s[3] == 'o') { - the_insn.reloc = RELOC_HLO10; - s += 4; -#endif /* NO_V9 */ - /* end-sanitize-v9 */ - } else - break; - } - /* Note that if the getExpression() fails, we - will still have created U entries in the - symbol table for the 'symbols' in the input - string. Try not to create U symbols for - registers, etc. */ - { - /* This stuff checks to see if the - expression ends in +%reg If it does, - it removes the register from the - expression, and re-sets 's' to point - to the right place */ - - char *s1; - - for(s1=s;*s1 && *s1!=','&& *s1!=']';s1++) - ; - - if(s1!=s && isdigit(s1[-1])) { - if(s1[-2]=='%' && s1[-3]=='+') { - s1-=3; - *s1='\0'; - (void)getExpression(s); - *s1='+'; - s=s1; - continue; - } else if(strchr("goli0123456789",s1[-2]) && s1[-3]=='%' && s1[-4]=='+') { - s1-=4; - *s1='\0'; - (void)getExpression(s); - *s1='+'; - s=s1; - continue; - } - } - } - (void)getExpression(s); - s = expr_end; - continue; - - case 'a': - if (*s++ == 'a') { - opcode |= ANNUL; - continue; - } - break; - - case 'A': /* alternate space */ - if (isdigit(*s)) { - long num; - - num=0; - while (isdigit(*s)) { - num= num*10 + *s-'0'; - ++s; - } - opcode |= num<<5; - continue; - } - break; - /* abort(); */ - - case 'p': - if (strncmp(s, "%psr", 4) == 0) { - s += 4; - continue; - } - break; - - case 'q': /* floating point queue */ - if (strncmp(s, "%fq", 3) == 0) { - s += 3; - continue; - } - break; - - case 'Q': /* coprocessor queue */ - if (strncmp(s, "%cq", 3) == 0) { - s += 3; - continue; - } - break; - - case 'S': - if (strcmp(str, "set") == 0) { - special_case = SPECIAL_CASE_SET; - continue; - } else if (strncmp(str, "fdiv", 4) == 0) { - special_case = SPECIAL_CASE_FDIV; - continue; - } - break; - - case 't': - if (strncmp(s, "%tbr", 4) != 0) - break; - s += 4; - continue; - - case 'w': - if (strncmp(s, "%wim", 4) != 0) - break; - s += 4; - continue; - - case 'y': - if (strncmp(s, "%y", 2) != 0) - break; - s += 2; - continue; - - default: - as_fatal("failed sanity check."); - } /* switch on arg code */ - break; - } /* for each arg that we expect */ - error: - if (match == 0) { - /* Args don't match. */ - if (((unsigned) (&insn[1] - sparc_opcodes)) < NUMOPCODES - && !strcmp(insn->name, insn[1].name)) { - ++insn; - s = argsStart; - continue; - } else { - as_bad("Illegal operands%s", error_message); - return; - } - } else { - if (insn->architecture > current_architecture) { - if (current_architecture != cypress - && (!architecture_requested || warn_on_bump)) { - - if (warn_on_bump) { - as_warn("architecture bumped from \"%s\" to \"%s\" on \"%s\"", - architecture_pname[current_architecture], - architecture_pname[insn->architecture], - str); - } /* if warning */ - - current_architecture = insn->architecture; - } else { - as_bad("architecture mismatch on \"%s\" (\"%s\"). current architecture is \"%s\"", - str, - architecture_pname[insn->architecture], - architecture_pname[current_architecture]); - return; - } /* if bump ok else error */ - } /* if architecture higher */ - } /* if no match */ - - break; - } /* forever looking for a match */ - - the_insn.opcode = opcode; - return; -} /* sparc_ip() */ - -static int getExpression(str) -char *str; -{ - char *save_in; - segT seg; - - save_in = input_line_pointer; - input_line_pointer = str; - switch (seg = expression(&the_insn.exp)) { - - case SEG_ABSOLUTE: - case SEG_TEXT: - case SEG_DATA: - case SEG_BSS: - case SEG_UNKNOWN: - case SEG_DIFFERENCE: - case SEG_BIG: - case SEG_ABSENT: - break; - - default: - the_insn.error = "bad segment"; - expr_end = input_line_pointer; - input_line_pointer=save_in; - return 1; - } - expr_end = input_line_pointer; - input_line_pointer = save_in; - return 0; -} /* getExpression() */ - - -/* - This is identical to the md_atof in m68k.c. I think this is right, - but I'm not sure. - - Turn a string in input_line_pointer into a floating point constant of type - type, and store the appropriate bytes in *litP. The number of LITTLENUMS - emitted is stored in *sizeP . An error message is returned, or NULL on OK. - */ - -/* Equal to MAX_PRECISION in atof-ieee.c */ -#define MAX_LITTLENUMS 6 - -char *md_atof(type,litP,sizeP) -char type; -char *litP; -int *sizeP; -{ - int prec; - LITTLENUM_TYPE words[MAX_LITTLENUMS]; - LITTLENUM_TYPE *wordP; - char *t; - char *atof_ieee(); - - switch(type) { - - case 'f': - case 'F': - case 's': - case 'S': - prec = 2; - break; - - case 'd': - case 'D': - case 'r': - case 'R': - prec = 4; - break; - - case 'x': - case 'X': - prec = 6; - break; - - case 'p': - case 'P': - prec = 6; - break; - - default: - *sizeP=0; - return "Bad call to MD_ATOF()"; - } - t=atof_ieee(input_line_pointer,type,words); - if(t) - input_line_pointer=t; - *sizeP=prec * sizeof(LITTLENUM_TYPE); - for(wordP=words;prec--;) { - md_number_to_chars(litP,(long)(*wordP++),sizeof(LITTLENUM_TYPE)); - litP+=sizeof(LITTLENUM_TYPE); - } - return ""; /* Someone should teach Dean about null pointers */ -} /* md_atof() */ - -/* - * Write out big-endian. - */ -void md_number_to_chars(buf,val,n) -char *buf; -long val; -int n; -{ - - switch(n) { - - case 4: - *buf++ = val >> 24; - *buf++ = val >> 16; - case 2: - *buf++ = val >> 8; - case 1: - *buf = val; - break; - - default: - as_fatal("failed sanity check."); - } - return; -} /* md_number_to_chars() */ - -/* Apply a fixS to the frags, now that we know the value it ought to - hold. */ - -void md_apply_fix(fixP, val) -fixS *fixP; -long val; -{ - char *buf = fixP->fx_where + fixP->fx_frag->fr_literal; - - assert(fixP->fx_size == 4); - assert(fixP->fx_r_type < NO_RELOC); - - fixP->fx_addnumber = val; /* Remember value for emit_reloc */ - - /* - * This is a hack. There should be a better way to - * handle this. - */ - if (fixP->fx_r_type == RELOC_WDISP30 && fixP->fx_addsy) { - val += fixP->fx_where + fixP->fx_frag->fr_address; - } - - switch (fixP->fx_r_type) { - - case RELOC_32: - buf[0] = 0; /* val >> 24; */ - buf[1] = 0; /* val >> 16; */ - buf[2] = 0; /* val >> 8; */ - buf[3] = 0; /* val; */ - break; - -#if 0 - case RELOC_8: /* These don't seem to ever be needed. */ - case RELOC_16: - case RELOC_DISP8: - case RELOC_DISP16: - case RELOC_DISP32: -#endif - case RELOC_WDISP30: - val = (val >>= 2) + 1; - buf[0] |= (val >> 24) & 0x3f; - buf[1]= (val >> 16); - buf[2] = val >> 8; - buf[3] = val; - break; - - /* start-sanitize-v9 */ -#ifndef NO_V9 - case RELOC_11: - if (((val > 0) && (val & ~0x7ff)) - || ((val < 0) && (~(val - 1) & ~0x7ff))) { - as_bad("relocation overflow."); - } /* on overflow */ - - buf[2] = (val >> 8) & 0x7; - buf[3] = val & 0xff; - break; - - case RELOC_WDISP2_14: - if (((val > 0) && (val & ~0x3fffc)) - || ((val < 0) && (~(val - 1) & ~0x3fffc))) { - as_bad("relocation overflow."); - } /* on overflow */ - - val = (val >>= 2) + 1; - buf[1] |= ((val >> 14) & 0x3) << 3; - buf[2] |= (val >> 8) & 0x3f ; - buf[3] = val & 0xff; - break; - - case RELOC_WDISP19: - if (((val > 0) && (val & ~0x1ffffc)) - || ((val < 0) && (~(val - 1) & ~0x1ffffc))) { - as_bad("relocation overflow."); - } /* on overflow */ - - val = (val >>= 2) + 1; - buf[1] |= (val >> 16) & 0x7; - buf[2] = (val >> 8) & 0xff; - buf[3] = val & 0xff; - break; - - case RELOC_HHI22: - val >>= 32; - /* intentional fallthrough */ -#endif /* NO_V9 */ - /* end-sanitize-v9 */ - - case RELOC_HI22: - if(!fixP->fx_addsy) { - buf[1] |= (val >> 26) & 0x3f; - buf[2] = val >> 18; - buf[3] = val >> 10; - } else { - buf[2]=0; - buf[3]=0; - } - break; -#if 0 - case RELOC_22: - case RELOC_13: -#endif - - /* start-sanitize-v9 */ -#ifndef NO_V9 - case RELOC_HLO10: - val >>= 32; - /* intentional fallthrough */ -#endif /* NO_V9 */ - /* end-sanitize-v9 */ - - case RELOC_LO10: - if(!fixP->fx_addsy) { - buf[2] |= (val >> 8) & 0x03; - buf[3] = val; - } else - buf[3]=0; - break; -#if 0 - case RELOC_SFA_BASE: - case RELOC_SFA_OFF13: - case RELOC_BASE10: -#endif - case RELOC_BASE13: - buf[2] |= (val >> 8) & 0x1f; - buf[3] = val; - break; - - case RELOC_WDISP22: - val = (val >>= 2) + 1; - /* FALLTHROUGH */ - case RELOC_BASE22: - buf[1] |= (val >> 16) & 0x3f; - buf[2] = val >> 8; - buf[3] = val; - break; - -#if 0 - case RELOC_PC10: - case RELOC_PC22: - case RELOC_JMP_TBL: - case RELOC_SEGOFF16: - case RELOC_GLOB_DAT: - case RELOC_JMP_SLOT: - case RELOC_RELATIVE: -#endif - - case NO_RELOC: - default: - as_bad("bad relocation type: 0x%02x", fixP->fx_r_type); - break; - } -} /* md_apply_fix() */ - -/* should never be called for sparc */ -void md_create_short_jump(ptr, from_addr, to_addr, frag, to_symbol) -char *ptr; -long from_addr; -long to_addr; -fragS *frag; -symbolS *to_symbol; -{ - as_fatal("sparc_create_short_jmp\n"); -} /* md_create_short_jump() */ - -/* Translate internal representation of relocation info to target format. - - On sparc: first 4 bytes are normal unsigned long address, next three - bytes are index, most sig. byte first. Byte 7 is broken up with - bit 7 as external, bits 6 & 5 unused, and the lower - five bits as relocation type. Next 4 bytes are long addend. */ -/* Thanx and a tip of the hat to Michael Bloom, mb@ttidca.tti.com */ -void tc_aout_fix_to_chars(where, fixP, segment_address_in_file) -char *where; -fixS *fixP; -relax_addressT segment_address_in_file; -{ - long r_index; - long r_extern; - long r_addend; - long r_address; - - know(fixP->fx_addsy); - - if ((S_GET_TYPE(fixP->fx_addsy)) == N_UNDF) { - r_extern = 1; - r_index = fixP->fx_addsy->sy_number; - } else { - r_extern = 0; - r_index = S_GET_TYPE(fixP->fx_addsy); - } - - /* this is easy */ - md_number_to_chars(where, - r_address = fixP->fx_frag->fr_address + fixP->fx_where - segment_address_in_file, - 4); - - /* now the fun stuff */ - where[4] = (r_index >> 16) & 0x0ff; - where[5] = (r_index >> 8) & 0x0ff; - where[6] = r_index & 0x0ff; - where[7] = ((r_extern << 7) & 0x80) | (0 & 0x60) | (fixP->fx_r_type & 0x1F); - - /* Also easy */ - if (fixP->fx_addsy->sy_frag) { - r_addend = fixP->fx_addsy->sy_frag->fr_address; - } - - if (fixP->fx_pcrel) { - r_addend -= r_address; - } else { - r_addend = fixP->fx_addnumber; - } - - md_number_to_chars(&where[8], r_addend, 4); - - return; -} /* tc_aout_fix_to_chars() */ - -/* should never be called for sparc */ -void md_convert_frag(headers, fragP) -object_headers *headers; -register fragS *fragP; -{ - as_fatal("sparc_convert_frag\n"); -} /* md_convert_frag() */ - -/* should never be called for sparc */ -void md_create_long_jump(ptr, from_addr, to_addr, frag, to_symbol) -char *ptr; -long from_addr, to_addr; -fragS *frag; -symbolS *to_symbol; -{ - as_fatal("sparc_create_long_jump\n"); -} /* md_create_long_jump() */ - -/* should never be called for sparc */ -int md_estimate_size_before_relax(fragP, segtype) -fragS *fragP; -segT segtype; -{ - as_fatal("sparc_estimate_size_before_relax\n"); -} /* md_estimate_size_before_relax() */ - -#if 0 -/* for debugging only */ -static void print_insn(insn) -struct sparc_it *insn; -{ - char *Reloc[] = { - "RELOC_8", - "RELOC_16", - "RELOC_32", - "RELOC_DISP8", - "RELOC_DISP16", - "RELOC_DISP32", - "RELOC_WDISP30", - "RELOC_WDISP22", - "RELOC_HI22", - "RELOC_22", - "RELOC_13", - "RELOC_LO10", - "RELOC_SFA_BASE", - "RELOC_SFA_OFF13", - "RELOC_BASE10", - "RELOC_BASE13", - "RELOC_BASE22", - "RELOC_PC10", - "RELOC_PC22", - "RELOC_JMP_TBL", - "RELOC_SEGOFF16", - "RELOC_GLOB_DAT", - "RELOC_JMP_SLOT", - "RELOC_RELATIVE", - "NO_RELOC" - }; - - if (insn->error) { - fprintf(stderr, "ERROR: %s\n"); - } - fprintf(stderr, "opcode=0x%08x\n", insn->opcode); - fprintf(stderr, "reloc = %s\n", Reloc[insn->reloc]); - fprintf(stderr, "exp = { -\n"); - fprintf(stderr, "\t\tX_add_symbol = %s\n", - ((insn->exp.X_add_symbol != NULL) - ? ((S_GET_NAME(insn->exp.X_add_symbol) != NULL) - ? S_GET_NAME(insn->exp.X_add_symbol) - : "???") - : "0")); - fprintf(stderr, "\t\tX_sub_symbol = %s\n", - ((insn->exp.X_subtract_symbol != NULL) - ? (S_GET_NAME(insn->exp.X_subtract_symbol) - ? S_GET_NAME(insn->exp.X_subtract_symbol) - : "???") - : "0")); - fprintf(stderr, "\t\tX_add_number = %d\n", - insn->exp.X_add_number); - fprintf(stderr, "}\n"); - return; -} /* print_insn() */ -#endif - -/* Set the hook... */ - -/* void emit_sparc_reloc(); -void (*md_emit_relocations)() = emit_sparc_reloc; */ - -#ifdef comment - -/* - * Sparc/AM29K relocations are completely different, so it needs - * this machine dependent routine to emit them. - */ -#if defined(OBJ_AOUT) || defined(OBJ_BOUT) -void emit_sparc_reloc(fixP, segment_address_in_file) -register fixS *fixP; -relax_addressT segment_address_in_file; -{ - struct reloc_info_generic ri; - register symbolS *symbolP; - extern char *next_object_file_charP; - /* long add_number; */ - - bzero((char *) &ri, sizeof(ri)); - for (; fixP; fixP = fixP->fx_next) { - - if (fixP->fx_r_type >= NO_RELOC) { - as_fatal("fixP->fx_r_type = %d\n", fixP->fx_r_type); - } - - if ((symbolP = fixP->fx_addsy) != NULL) { - ri.r_address = fixP->fx_frag->fr_address + - fixP->fx_where - segment_address_in_file; - if ((S_GET_TYPE(symbolP)) == N_UNDF) { - ri.r_extern = 1; - ri.r_index = symbolP->sy_number; - } else { - ri.r_extern = 0; - ri.r_index = S_GET_TYPE(symbolP); - } - if (symbolP && symbolP->sy_frag) { - ri.r_addend = symbolP->sy_frag->fr_address; - } - ri.r_type = fixP->fx_r_type; - if (fixP->fx_pcrel) { - /* ri.r_addend -= fixP->fx_where; */ - ri.r_addend -= ri.r_address; - } else { - ri.r_addend = fixP->fx_addnumber; - } - - md_ri_to_chars(next_object_file_charP, &ri); - next_object_file_charP += md_reloc_size; - } - } - return; -} /* emit_sparc_reloc() */ -#endif /* aout or bout */ -#endif /* comment */ - -/* - * md_parse_option - * Invocation line includes a switch not recognized by the base assembler. - * See if it's a processor-specific option. These are: - * - * -bump - * Warn on architecture bumps. See also -A. - * - * -Av6, -Av7, -Acypress, -Av8 - * Select the architecture. Instructions or features not - * supported by the selected architecture cause fatal errors. - * - * The default is to start at v6, and bump the architecture up - * whenever an instruction is seen at a higher level. - * - * If -bump is specified, a warning is printing when bumping to - * higher levels. - * - * If an architecture is specified, all instructions must match - * that architecture. Any higher level instructions are flagged - * as errors. - * - * if both an architecture and -bump are specified, the - * architecture starts at the specified level, but bumps are - * warnings. - * - * Note that where cypress specific instructions conflict with - * other instructions, the other instruction is assumed. Nothing - * is upward compatible with cypress. Thus, to get the cypress - * instruction set you MUST -Acypress. - * - */ - /* start-sanitize-v9 */ - /* There is also a -Av9 architecture option. xoxorich. */ - /* end-sanitize-v9 */ -int md_parse_option(argP, cntP, vecP) -char **argP; -int *cntP; -char ***vecP; -{ - char *p; - const char **arch; - - if (!strcmp(*argP,"bump")){ - warn_on_bump = 1; - - } else if (**argP == 'A'){ - p = (*argP) + 1; - - for (arch = architecture_pname; *arch != NULL; ++arch){ - if (strcmp(p, *arch) == 0){ - break; - } /* found a match */ - } /* walk the pname table */ - - if (*arch == NULL){ - as_bad("unknown architecture: %s", p); - } else { - current_architecture = (enum sparc_architecture) (arch - architecture_pname); - architecture_requested = 1; - } - } else { - /* Unknown option */ - (*argP)++; - return 0; - } - **argP = '\0'; /* Done parsing this switch */ - return 1; -} /* md_parse_option() */ - -/* We have no need to default values of symbols. */ - -/* ARGSUSED */ -symbolS *md_undefined_symbol(name) -char *name; -{ - return 0; -} /* md_undefined_symbol() */ - -/* Parse an operand that is machine-specific. - We just return without modifying the expression if we have nothing - to do. */ - -/* ARGSUSED */ -void md_operand(expressionP) -expressionS *expressionP; -{ -} /* md_operand() */ - -/* Round up a section size to the appropriate boundary. */ -long md_section_align (segment, size) -segT segment; -long size; -{ - return (size + 7) & ~7; /* Round all sects to multiple of 8 */ -} /* md_section_align() */ - -/* Exactly what point is a PC-relative offset relative TO? - On the sparc, they're relative to the address of the offset, plus - its size. This gets us to the following instruction. - (??? Is this right? FIXME-SOON) */ -long md_pcrel_from(fixP) -fixS *fixP; -{ - return fixP->fx_size + fixP->fx_where + fixP->fx_frag->fr_address; -} /* md_pcrel_from() */ - -/* - * Local Variables: - * comment-column: 0 - * fill-column: 131 - * End: - */ - -/* end of tp-sparc.c */ diff --git a/gas/config/tc-sparc.h b/gas/config/tc-sparc.h deleted file mode 100644 index dd19fdb5bb0..00000000000 --- a/gas/config/tc-sparc.h +++ /dev/null @@ -1,42 +0,0 @@ -/* tc-sparc.h - Macros and type defines for the sparc. - Copyright (C) 1989, 1990, 1991 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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 1, -or (at your option) any later version. - -GAS 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 GAS; see the file COPYING. If not, write -to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* $Id$ */ - -#define TC_SPARC 1 - -#ifdef OBJ_BOUT -#define DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE ((0x103 << 16) | BMAGIC) /* Magic number for header */ -#else -#ifdef OBJ_AOUT -#define DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE ((0x103 << 16) | OMAGIC) /* Magic number for header */ -#endif /* OBJ_AOUT */ -#endif /* OBJ_BOUT */ - -#define tc_headers_hook(a) ; /* don't need it. */ -#define tc_crawl_symbol_chain(a) ; /* don't need it. */ - -/* - * Local Variables: - * comment-column: 0 - * fill-column: 131 - * End: - */ - -/* end of tp-sparc.h */ diff --git a/gas/config/tc-vax.c b/gas/config/tc-vax.c deleted file mode 100644 index 11095c69076..00000000000 --- a/gas/config/tc-vax.c +++ /dev/null @@ -1,3337 +0,0 @@ -/* vax.c - vax-specific - - Copyright (C) 1987, 1991 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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 1, or (at your option) -any later version. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* $Id$ */ - -/* JF I moved almost all the vax specific stuff into this one file 'cuz RMS - seems to think its a good idea. I hope I managed to get all the VAX-isms */ - - -#include "as.h" - -#include "read.h" -#include "flonum.h" -#include "vax-inst.h" -#include "obstack.h" /* For FRAG_APPEND_1_CHAR macro in "frags.h" */ -#include "frags.h" -#include "expr.h" -#include "symbols.h" - -/* These chars start a comment anywhere in a source file (except inside - another comment */ -const char comment_chars[] = "#"; - -/* These chars only start a comment at the beginning of a line. */ -/* Note that for the VAX the are the same as comment_chars above. */ -const char line_comment_chars[] = "#"; - -/* Chars that can be used to separate mant from exp in floating point nums */ -const char EXP_CHARS[] = "eE"; - -/* Chars that mean this number is a floating point constant */ -/* as in 0f123.456 */ -/* or 0H1.234E-12 (see exp chars above) */ -const char FLT_CHARS[] = "dDfFgGhH"; - -/* Also be aware that MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT may have to be - changed in read.c . Ideally it shouldn't have to know about it at all, - but nothing is ideal around here. - */ - -static expressionS /* Hold details of an operand expression */ - exp_of_operand[VIT_MAX_OPERANDS]; - -static struct vit - v; /* A vax instruction after decoding. */ - -LITTLENUM_TYPE big_operand_bits[VIT_MAX_OPERANDS][SIZE_OF_LARGE_NUMBER]; - /* Hold details of big operands. */ -FLONUM_TYPE float_operand[VIT_MAX_OPERANDS]; - /* Above is made to point into */ - /* big_operand_bits by md_begin(). */ - -/* - * For VAX, relative addresses of "just the right length" are easy. - * The branch displacement is always the last operand, even in - * synthetic instructions. - * For VAX, we encode the relax_substateTs (in e.g. fr_substate) as: - * - * 4 3 2 1 0 bit number - * ---/ /--+-------+-------+-------+-------+-------+ - * | what state ? | how long ? | - * ---/ /--+-------+-------+-------+-------+-------+ - * - * The "how long" bits are 00=byte, 01=word, 10=long. - * This is a Un*x convention. - * Not all lengths are legit for a given value of (what state). - * The "how long" refers merely to the displacement length. - * The address usually has some constant bytes in it as well. - * - -groups for VAX address relaxing. - -1. "foo" pc-relative. - length of byte, word, long - -2a. J where is a simple flag test. - length of byte, word, long. - VAX opcodes are: (Hex) - bneq/bnequ 12 - beql/beqlu 13 - bgtr 14 - bleq 15 - bgeq 18 - blss 19 - bgtru 1a - blequ 1b - bvc 1c - bvs 1d - bgequ/bcc 1e - blssu/bcs 1f - Always, you complement 0th bit to reverse condition. - Always, 1-byte opcode, then 1-byte displacement. - -2b. J where cond tests a memory bit. - length of byte, word, long. - Vax opcodes are: (Hex) - bbs e0 - bbc e1 - bbss e2 - bbcs e3 - bbsc e4 - bbcc e5 - bbssi e6 - bbcci e7 - Always, you complement 0th bit to reverse condition. - Always, 1-byte opcde, longword-address, byte-address, 1-byte-displacement - -2c. J where cond tests low-order memory bit - length of byte,word,long. - Vax opcodes are: (Hex) - blbs e8 - blbc e9 - Always, you complement 0th bit to reverse condition. - Always, 1-byte opcode, longword-address, 1-byte displacement. - -3. Jbs/Jbr. - length of byte,word,long. - Vax opcodes are: (Hex) - bsbb 10 - brb 11 - These are like (2) but there is no condition to reverse. - Always, 1 byte opcode, then displacement/absolute. - -4a. JacbX - length of word, long. - Vax opcodes are: (Hex) - acbw 3d - acbf 4f - acbd 6f - abcb 9d - acbl f1 - acbg 4ffd - acbh 6ffd - Always, we cannot reverse the sense of the branch; we have a word - displacement. - The double-byte op-codes don't hurt: we never want to modify the - opcode, so we don't care how many bytes are between the opcode and - the operand. - -4b. JXobXXX - length of long, long, byte. - Vax opcodes are: (Hex) - aoblss f2 - aobleq f3 - sobgeq f4 - sobgtr f5 - Always, we cannot reverse the sense of the branch; we have a byte - displacement. - -The only time we need to modify the opcode is for class 2 instructions. -After relax() we may complement the lowest order bit of such instruction -to reverse sense of branch. - -For class 2 instructions, we store context of "where is the opcode literal". -We can change an opcode's lowest order bit without breaking anything else. - -We sometimes store context in the operand literal. This way we can figure out -after relax() what the original addressing mode was. -*/ - - /* These displacements are relative to */ - /* the start address of the displacement. */ - /* The first letter is Byte, Word. */ - /* 2nd letter is Forward, Backward. */ -#define BF (1+ 127) -#define BB (1+-128) -#define WF (2+ 32767) -#define WB (2+-32768) - /* Dont need LF, LB because they always */ - /* reach. [They are coded as 0.] */ - - -#define C(a,b) ENCODE_RELAX(a,b) - /* This macro has no side-effects. */ -#define ENCODE_RELAX(what,length) (((what) << 2) + (length)) - -const relax_typeS -md_relax_table[] = -{ - { - 1, 1, 0, 0 - }, /* error sentinel 0,0 */ - { - 1, 1, 0, 0 - }, /* unused 0,1 */ - { - 1, 1, 0, 0 - }, /* unused 0,2 */ - { - 1, 1, 0, 0 - }, /* unused 0,3 */ - { - BF + 1, BB + 1, 2, C (1, 1) - }, /* B^"foo" 1,0 */ - { - WF + 1, WB + 1, 3, C (1, 2) - }, /* W^"foo" 1,1 */ - { - 0, 0, 5, 0 - }, /* L^"foo" 1,2 */ - { - 1, 1, 0, 0 - }, /* unused 1,3 */ - { - BF, BB, 1, C (2, 1) - }, /* b B^"foo" 2,0 */ - { - WF + 2, WB + 2, 4, C (2, 2) - }, /* br.+? brw X 2,1 */ - { - 0, 0, 7, 0 - }, /* br.+? jmp X 2,2 */ - { - 1, 1, 0, 0 - }, /* unused 2,3 */ - { - BF, BB, 1, C (3, 1) - }, /* brb B^foo 3,0 */ - { - WF, WB, 2, C (3, 2) - }, /* brw W^foo 3,1 */ - { - 0, 0, 5, 0 - }, /* Jmp L^foo 3,2 */ - { - 1, 1, 0, 0 - }, /* unused 3,3 */ - { - 1, 1, 0, 0 - }, /* unused 4,0 */ - { - WF, WB, 2, C (4, 2) - }, /* acb_ ^Wfoo 4,1 */ - { - 0, 0, 10, 0 - }, /* acb_,br,jmp L^foo4,2 */ - { - 1, 1, 0, 0 - }, /* unused 4,3 */ - { - BF, BB, 1, C (5, 1) - }, /* Xob___,,foo 5,0 */ - { - WF + 4, WB + 4, 6, C (5, 2) - }, /* Xob.+2,brb.+3,brw5,1 */ - { - 0, 0, 9, 0 - }, /* Xob.+2,brb.+6,jmp5,2 */ -}; - -#undef C -#undef BF -#undef BB -#undef WF -#undef WB - -void float_cons (); - -const pseudo_typeS md_pseudo_table[] = -{ - {"dfloat", float_cons, 'd'}, - {"ffloat", float_cons, 'f'}, - {"gfloat", float_cons, 'g'}, - {"hfloat", float_cons, 'h'}, - {0} -}; - -#define STATE_PC_RELATIVE (1) -#define STATE_CONDITIONAL_BRANCH (2) -#define STATE_ALWAYS_BRANCH (3) /* includes BSB... */ -#define STATE_COMPLEX_BRANCH (4) -#define STATE_COMPLEX_HOP (5) - -#define STATE_BYTE (0) -#define STATE_WORD (1) -#define STATE_LONG (2) -#define STATE_UNDF (3) /* Symbol undefined in pass1 */ - - -#define min(a, b) ((a) < (b) ? (a) : (b)) - - -void -md_begin () -{ - char *vip_begin (); - char *errtxt; - FLONUM_TYPE *fP; - int i; - - if (*(errtxt = vip_begin (TRUE, "$", "*", "`"))) - { - as_fatal("VIP_BEGIN error:%s", errtxt); - } - - for (i = 0, fP = float_operand; - fP < float_operand + VIT_MAX_OPERANDS; - i++, fP++) - { - fP->low = &big_operand_bits[i][0]; - fP->high = &big_operand_bits[i][SIZE_OF_LARGE_NUMBER - 1]; - } -} - -void -md_end () -{ - vip_end (); -} - -void /* Knows about order of bytes in address. */ -md_number_to_chars (con, value, nbytes) - char con[]; /* Return 'nbytes' of chars here. */ - long value; /* The value of the bits. */ - int nbytes; /* Number of bytes in the output. */ -{ - int n; - long v; - - n = nbytes; - v = value; - while (nbytes--) - { - *con++ = value; /* Lint wants & MASK_CHAR. */ - value >>= BITS_PER_CHAR; - } - /* XXX line number probably botched for this warning message. */ - if (value != 0 && value != -1) - as_bad("Displacement (%ld) long for instruction field length (%d).", v, n); -} - -/* Fix up some data or instructions after we find out the value of a symbol - that they reference. */ - -void /* Knows about order of bytes in address. */ -md_apply_fix(fixP, value) - fixS *fixP; /* Fixup struct pointer */ - long value; /* The value of the bits. */ -{ - char *buf = fixP->fx_where + fixP->fx_frag->fr_literal; - int nbytes; /* Number of bytes in the output. */ - - nbytes = fixP->fx_size; - while (nbytes--) - { - *buf++ = value; /* Lint wants & MASK_CHAR. */ - value >>= BITS_PER_CHAR; - } -} - -long /* Knows about the byte order in a word. */ -md_chars_to_number (con, nbytes) - unsigned char con[]; /* Low order byte 1st. */ - int nbytes; /* Number of bytes in the input. */ -{ - long retval; - for (retval = 0, con += nbytes - 1; nbytes--; con--) - { - retval <<= BITS_PER_CHAR; - retval |= *con; - } - return retval; -} - -/* vax:md_assemble() emit frags for 1 instruction */ - -void -md_assemble (instruction_string) - char *instruction_string; /* A string: assemble 1 instruction. */ -{ - char *p; - register struct vop *operandP;/* An operand. Scans all operands. */ - char *save_input_line_pointer; - char c_save; /* What used to live after an expression. */ - struct frag *fragP; /* Fragment of code we just made. */ - register int goofed; /* TRUE: instruction_string bad for all passes. */ - register struct vop *end_operandP; /* -> slot just after last operand */ - /* Limit of the for (each operand). */ - register expressionS *expP; /* -> expression values for this operand */ - - /* These refer to an instruction operand expression. */ - segT to_seg; /* Target segment of the address. */ - register valueT this_add_number; - register struct symbol *this_add_symbol; /* +ve (minuend) symbol. */ - register struct symbol *this_subtract_symbol; /* -ve(subtrahend) symbol. */ - - long opcode_as_number; /* As a number. */ - char *opcode_as_chars; /* Least significant byte 1st. */ - /* As an array of characters. */ - char *opcode_low_byteP; /* Least significant byte 1st */ - struct details *detP; /* The details of an ADxxx frag. */ - int length; /* length (bytes) meant by vop_short. */ - int at; /* 0, or 1 if '@' is in addressing mode. */ - int nbytes; /* From vop_nbytes: vax_operand_width (in bytes) */ - FLONUM_TYPE *floatP; - char *vip (); - LITTLENUM_TYPE literal_float[8]; - /* Big enough for any floating point literal. */ - - if (*(p = vip (&v, instruction_string))) - { - as_fatal("vax_assemble\"%s\" in=\"%s\"", p, instruction_string); - } - /* - * Now we try to find as many as_warn()s as we can. If we do any as_warn()s - * then goofed=TRUE. Notice that we don't make any frags yet. - * Should goofed be TRUE, then this instruction will wedge in any pass, - * and we can safely flush it, without causing interpass symbol phase - * errors. That is, without changing label values in different passes. - */ - if (goofed = (*v.vit_error)) - { - as_warn ("Ignoring statement due to \"%s\"", v.vit_error); - } - /* - * We need to use expression() and friends, which require us to diddle - * input_line_pointer. So we save it and restore it later. - */ - save_input_line_pointer = input_line_pointer; - for (operandP = v.vit_operand, - expP = exp_of_operand, - floatP = float_operand, - end_operandP = v.vit_operand + v.vit_operands; - - operandP < end_operandP; - - operandP++, - expP++, - floatP++ - ) /* for each operand */ - { - if (*(operandP->vop_error)) - { - as_warn ("Ignoring statement because \"%s\"", (operandP->vop_error)); - goofed = TRUE; - } - else - { /* statement has no syntax goofs: lets sniff the expression */ - int can_be_short; /* TRUE if a bignum can be reduced to a short literal. */ - - input_line_pointer = operandP->vop_expr_begin; - c_save = operandP->vop_expr_end[1]; - operandP->vop_expr_end[1] = '\0'; - /* If to_seg == SEG_PASS1, expression() will have set need_pass_2 = TRUE. */ - switch (to_seg = expression (expP)) - { - case SEG_ABSENT: - /* for BSD4.2 compatibility, missing expression is absolute 0 */ - to_seg = expP->X_seg = SEG_ABSOLUTE; - expP->X_add_number = 0; - /* for SEG_ABSOLUTE, we shouldnt need to set X_subtract_symbol, X_add_symbol to any particular value. */ - /* But, we will program defensively. Since this situation occurs */ - /* rarely so it costs us little to do, and stops Dean */ - /* worrying about the origin of random bits in expressionS's. */ - expP->X_add_symbol = NULL; - expP->X_subtract_symbol = NULL; - case SEG_TEXT: - case SEG_DATA: - case SEG_BSS: - case SEG_ABSOLUTE: - case SEG_UNKNOWN: - break; - - case SEG_DIFFERENCE: - case SEG_PASS1: - /* - * Major bug. We can't handle the case of a - * SEG_DIFFERENCE expression in a VIT_OPCODE_SYNTHETIC - * variable-length instruction. - * We don't have a frag type that is smart enough to - * relax a SEG_DIFFERENCE, and so we just force all - * SEG_DIFFERENCEs to behave like SEG_PASS1s. - * Clearly, if there is a demand we can invent a new or - * modified frag type and then coding up a frag for this - * case will be easy. SEG_DIFFERENCE was invented for the - * .words after a CASE opcode, and was never intended for - * instruction operands. - */ - need_pass_2 = TRUE; - as_warn("Can't relocate expression"); - break; - - case SEG_BIG: - /* Preserve the bits. */ - if (expP->X_add_number > 0) - { - bignum_copy (generic_bignum, expP->X_add_number, - floatP->low, SIZE_OF_LARGE_NUMBER); - } - else - { - know (expP->X_add_number < 0); - flonum_copy (&generic_floating_point_number, - floatP); - if (strchr ("s i", operandP->vop_short)) - { /* Could possibly become S^# */ - flonum_gen2vax (-expP->X_add_number, floatP, literal_float); - switch (-expP->X_add_number) - { - case 'f': - can_be_short = - (literal_float[0] & 0xFC0F) == 0x4000 - && literal_float[1] == 0; - break; - - case 'd': - can_be_short = - (literal_float[0] & 0xFC0F) == 0x4000 - && literal_float[1] == 0 - && literal_float[2] == 0 - && literal_float[3] == 0; - break; - - case 'g': - can_be_short = - (literal_float[0] & 0xFF81) == 0x4000 - && literal_float[1] == 0 - && literal_float[2] == 0 - && literal_float[3] == 0; - break; - - case 'h': - can_be_short = - (literal_float[0] & 0xFFF8) == 0x4000 - && (literal_float[1] & 0xE000) == 0 - && literal_float[2] == 0 - && literal_float[3] == 0 - && literal_float[4] == 0 - && literal_float[5] == 0 - && literal_float[6] == 0 - && literal_float[7] == 0; - break; - - default: - BAD_CASE (-expP->X_add_number); - break; - } /* switch (float type) */ - } /* if (could want to become S^#...) */ - } /* bignum or flonum ? */ - - if (operandP->vop_short == 's' - || operandP->vop_short == 'i' - || (operandP->vop_short == ' ' - && operandP->vop_reg == 0xF - && (operandP->vop_mode & 0xE) == 0x8)) - { - /* Saw a '#'. */ - if (operandP->vop_short == ' ') - { /* We must chose S^ or I^. */ - if (expP->X_add_number > 0) - { /* Bignum: Short literal impossible. */ - operandP->vop_short = 'i'; - operandP->vop_mode = 8; - operandP->vop_reg = 0xF; /* VAX PC. */ - } - else - { /* Flonum: Try to do it. */ - if (can_be_short) - { - operandP->vop_short = 's'; - operandP->vop_mode = 0; - operandP->vop_ndx = -1; - operandP->vop_reg = -1; - /* JF hope this is the right thing */ - expP->X_seg = SEG_ABSOLUTE; - } - else - { - operandP->vop_short = 'i'; - operandP->vop_mode = 8; - operandP->vop_reg = 0xF; /* VAX PC */ - } - } /* bignum or flonum ? */ - } /* if #, but no S^ or I^ seen. */ - /* No more ' ' case: either 's' or 'i'. */ - if (operandP->vop_short == 's') - { - /* Wants to be a short literal. */ - if (expP->X_add_number > 0) - { - as_warn ("Bignum not permitted in short literal. Immediate mode assumed."); - operandP->vop_short = 'i'; - operandP->vop_mode = 8; - operandP->vop_reg = 0xF; /* VAX PC. */ - } - else - { - if (!can_be_short) - { - as_warn ("Can't do flonum short literal: immediate mode used."); - operandP->vop_short = 'i'; - operandP->vop_mode = 8; - operandP->vop_reg = 0xF; /* VAX PC. */ - } - else - { /* Encode short literal now. */ - register int temp; - - switch (-expP->X_add_number) - { - case 'f': - case 'd': - temp = literal_float[0] >> 4; - break; - - case 'g': - temp = literal_float[0] >> 1; - break; - - case 'h': - temp = ((literal_float[0] << 3) & 070) - | ((literal_float[1] >> 13) & 07); - break; - - default: - BAD_CASE (-expP->X_add_number); - break; - } - - floatP->low[0] = temp & 077; - floatP->low[1] = 0; - } /* if can be short literal float */ - } /* flonum or bignum ? */ - } - else - { /* I^# seen: set it up if float. */ - if (expP->X_add_number < 0) - { - bcopy (literal_float, floatP->low, sizeof (literal_float)); - } - } /* if S^# seen. */ - } - else - { - as_warn ("A bignum/flonum may not be a displacement: 0x%x used", - expP->X_add_number = 0x80000000); - /* Chosen so luser gets the most offset bits to patch later. */ - } - expP->X_add_number = floatP->low[0] - | ((LITTLENUM_MASK & (floatP->low[1])) << LITTLENUM_NUMBER_OF_BITS); -/* - * For the SEG_BIG case we have: - * If vop_short == 's' then a short floating literal is in the - * lowest 6 bits of floatP -> low [0], which is - * big_operand_bits [---] [0]. - * If vop_short == 'i' then the appropriate number of elements - * of big_operand_bits [---] [...] are set up with the correct - * bits. - * Also, just in case width is byte word or long, we copy the lowest - * 32 bits of the number to X_add_number. - */ - break; - - default: - BAD_CASE (to_seg); - break; - } - if (input_line_pointer != operandP->vop_expr_end + 1) - { - as_warn ("Junk at end of expression \"%s\"", input_line_pointer); - goofed = TRUE; - } - operandP->vop_expr_end[1] = c_save; - } - } /* for(each operand) */ - input_line_pointer = save_input_line_pointer; - - if (!need_pass_2 && !goofed) - { - /* We saw no errors in any operands - try to make frag(s) */ - int is_undefined; /* True if operand expression's */ - /* segment not known yet. */ - int length_code; - - /* Emit op-code. */ - /* Remember where it is, in case we want to modify the op-code later. */ - opcode_low_byteP = frag_more (v.vit_opcode_nbytes); - bcopy (v.vit_opcode, opcode_low_byteP, v.vit_opcode_nbytes); - opcode_as_number = md_chars_to_number (opcode_as_chars = v.vit_opcode, 4); - for (operandP = v.vit_operand, - expP = exp_of_operand, - floatP = float_operand, - end_operandP = v.vit_operand + v.vit_operands; - - operandP < end_operandP; - - operandP++, - floatP++, - expP++ - ) /* for each operand */ - { - if (operandP->vop_ndx >= 0) - { - /* indexed addressing byte */ - /* Legality of indexed mode already checked: it is OK */ - FRAG_APPEND_1_CHAR (0x40 + operandP->vop_ndx); - } /* if(vop_ndx>=0) */ - - /* Here to make main operand frag(s). */ - this_add_number = expP->X_add_number; - this_add_symbol = expP->X_add_symbol; - this_subtract_symbol = expP->X_subtract_symbol; - to_seg = expP->X_seg; - is_undefined = (to_seg == SEG_UNKNOWN); - know (to_seg == SEG_UNKNOWN - ||to_seg == SEG_ABSOLUTE - ||to_seg == SEG_DATA - ||to_seg == SEG_TEXT - ||to_seg == SEG_BSS - ||to_seg == SEG_BIG - ); - at = operandP->vop_mode & 1; - length = operandP->vop_short == 'b' ? 1 : operandP->vop_short == 'w' ? 2 : operandP->vop_short == 'l' ? 4 : 0; - nbytes = operandP->vop_nbytes; - if (operandP->vop_access == 'b') - { - if (to_seg == now_seg || is_undefined) - { /* If is_undefined, then it might BECOME now_seg. */ - if (nbytes) - { - p = frag_more (nbytes); - fix_new (frag_now, p - frag_now->fr_literal, nbytes, - this_add_symbol, 0, this_add_number, 1); - } - else - { /* to_seg==now_seg || to_seg == SEG_UNKNOWN */ - /* nbytes==0 */ - length_code = is_undefined ? STATE_UNDF : STATE_BYTE; - if (opcode_as_number & VIT_OPCODE_SPECIAL) - { - if (operandP->vop_width == VAX_WIDTH_UNCONDITIONAL_JUMP) - { - /* br or jsb */ - frag_var (rs_machine_dependent, 5, 1, - ENCODE_RELAX (STATE_ALWAYS_BRANCH, length_code), - this_add_symbol, this_add_number, - opcode_low_byteP); - } - else - { - if (operandP->vop_width == VAX_WIDTH_WORD_JUMP) - { - length_code = STATE_WORD; /* JF: There is no state_byte for this one! */ - frag_var (rs_machine_dependent, 10, 2, - ENCODE_RELAX (STATE_COMPLEX_BRANCH, length_code), - this_add_symbol, this_add_number, - opcode_low_byteP); - } - else - { - know (operandP->vop_width == VAX_WIDTH_BYTE_JUMP); - frag_var (rs_machine_dependent, 9, 1, - ENCODE_RELAX (STATE_COMPLEX_HOP, length_code), - this_add_symbol, this_add_number, - opcode_low_byteP); - } - } - } - else - { - know (operandP->vop_width == VAX_WIDTH_CONDITIONAL_JUMP); - frag_var (rs_machine_dependent, 7, 1, - ENCODE_RELAX (STATE_CONDITIONAL_BRANCH, length_code), - this_add_symbol, this_add_number, - opcode_low_byteP); - } - } - } - else - { /* to_seg != now_seg && to_seg != SEG_UNKNOWN */ -/* - * --- SEG FLOAT MAY APPEAR HERE ---- - */ - if (to_seg == SEG_ABSOLUTE) - { - if (nbytes) - { - know (!(opcode_as_number & VIT_OPCODE_SYNTHETIC)); - p = frag_more (nbytes); - /* Conventional relocation. */ - fix_new (frag_now, p - frag_now->fr_literal, - nbytes, &abs_symbol, 0, this_add_number, 1); - } - else - { - know (opcode_as_number & VIT_OPCODE_SYNTHETIC); - if (opcode_as_number & VIT_OPCODE_SPECIAL) - { - if (operandP->vop_width == VAX_WIDTH_UNCONDITIONAL_JUMP) - { - /* br or jsb */ - *opcode_low_byteP = opcode_as_chars[0] + VAX_WIDEN_LONG; - know (opcode_as_chars[1] == 0); - p = frag_more (5); - p[0] = VAX_ABSOLUTE_MODE; /* @#... */ - md_number_to_chars (p + 1, this_add_number, 4); - /* Now (eg) JMP @#foo or JSB @#foo. */ - } - else - { - if (operandP->vop_width == VAX_WIDTH_WORD_JUMP) - { - p = frag_more (10); - p[0] = 2; - p[1] = 0; - p[2] = VAX_BRB; - p[3] = 6; - p[4] = VAX_JMP; - p[5] = VAX_ABSOLUTE_MODE; /* @#... */ - md_number_to_chars (p + 6, this_add_number, 4); - /* - * Now (eg) ACBx 1f - * BRB 2f - * 1: JMP @#foo - * 2: - */ - } - else - { - know (operandP->vop_width == VAX_WIDTH_BYTE_JUMP); - p = frag_more (9); - p[0] = 2; - p[1] = VAX_BRB; - p[2] = 6; - p[3] = VAX_JMP; - p[4] = VAX_PC_RELATIVE_MODE + 1; /* @#... */ - md_number_to_chars (p + 5, this_add_number, 4); - /* - * Now (eg) xOBxxx 1f - * BRB 2f - * 1: JMP @#foo - * 2: - */ - } - } - } - else - { - /* b */ - *opcode_low_byteP ^= 1; /* To reverse the condition in a VAX branch, complement the lowest order bit. */ - p = frag_more (7); - p[0] = 6; - p[1] = VAX_JMP; - p[2] = VAX_ABSOLUTE_MODE; /* @#... */ - md_number_to_chars (p + 3, this_add_number, 4); - /* - * Now (eg) BLEQ 1f - * JMP @#foo - * 1: - */ - } - } - } - else - { /* to_seg != now_seg && to_seg != SEG_UNKNOWN && to_Seg != SEG_ABSOLUTE */ - if (nbytes > 0) - { - /* Pc-relative. Conventional relocation. */ - know (!(opcode_as_number & VIT_OPCODE_SYNTHETIC)); - p = frag_more (nbytes); - fix_new (frag_now, p - frag_now->fr_literal, - nbytes, &abs_symbol, 0, this_add_number, 1); - } - else - { - know (opcode_as_number & VIT_OPCODE_SYNTHETIC); - if (opcode_as_number & VIT_OPCODE_SPECIAL) - { - if (operandP->vop_width == VAX_WIDTH_UNCONDITIONAL_JUMP) - { - /* br or jsb */ - know (opcode_as_chars[1] == 0); - *opcode_low_byteP = opcode_as_chars[0] + VAX_WIDEN_LONG; - p = frag_more (5); - p[0] = VAX_PC_RELATIVE_MODE; - fix_new (frag_now, - p + 1 - frag_now->fr_literal, 4, - this_add_symbol, 0, - this_add_number, 1); - /* Now eg JMP foo or JSB foo. */ - } - else - { - if (operandP->vop_width == VAX_WIDTH_WORD_JUMP) - { - p = frag_more (10); - p[0] = 0; - p[1] = 2; - p[2] = VAX_BRB; - p[3] = 6; - p[4] = VAX_JMP; - p[5] = VAX_PC_RELATIVE_MODE; - fix_new (frag_now, - p + 6 - frag_now->fr_literal, 4, - this_add_symbol, 0, - this_add_number, 1); - /* - * Now (eg) ACBx 1f - * BRB 2f - * 1: JMP foo - * 2: - */ - } - else - { - know (operandP->vop_width == VAX_WIDTH_BYTE_JUMP); - p = frag_more (10); - p[0] = 2; - p[1] = VAX_BRB; - p[2] = 6; - p[3] = VAX_JMP; - p[4] = VAX_PC_RELATIVE_MODE; - fix_new (frag_now, - p + 5 - frag_now->fr_literal, - 4, this_add_symbol, 0, - this_add_number, 1); - /* - * Now (eg) xOBxxx 1f - * BRB 2f - * 1: JMP foo - * 2: - */ - } - } - } - else - { - know (operandP->vop_width == VAX_WIDTH_CONDITIONAL_JUMP); - *opcode_low_byteP ^= 1; /* Reverse branch condition. */ - p = frag_more (7); - p[0] = 6; - p[1] = VAX_JMP; - p[2] = VAX_PC_RELATIVE_MODE; - fix_new (frag_now, p + 3 - frag_now->fr_literal, - 4, this_add_symbol, 0, - this_add_number, 1); - } - } - } - } - } - else - { - know (operandP->vop_access != 'b'); /* So it is ordinary operand. */ - know (operandP->vop_access != ' '); /* ' ' target-independent: elsewhere. */ - know (operandP->vop_access == 'a' || operandP->vop_access == 'm' || operandP->vop_access == 'r' || operandP->vop_access == 'v' || operandP->vop_access == 'w'); - if (operandP->vop_short == 's') - { - if (to_seg == SEG_ABSOLUTE) - { - if (this_add_number < 0 || this_add_number >= 64) - { - as_warn ("Short literal overflow(%d.), immediate mode assumed.", this_add_number); - operandP->vop_short = 'i'; - operandP->vop_mode = 8; - operandP->vop_reg = 0xF; - } - } - else - { - as_warn ("Forced short literal to immediate mode. now_seg=%s to_seg=%s", segment_name(now_seg), segment_name(to_seg)); - operandP->vop_short = 'i'; - operandP->vop_mode = 8; - operandP->vop_reg = 0xF; - } - } - if (operandP->vop_reg >= 0 && (operandP->vop_mode < 8 || (operandP->vop_reg != 0xF && operandP->vop_mode < 10))) - { /* One byte operand. */ - know (operandP->vop_mode > 3); - FRAG_APPEND_1_CHAR (operandP->vop_mode << 4 | operandP->vop_reg); - /* All 1-bytes except S^# happen here. */ - } - else - { /* {@}{q^}foo{(Rn)} or S^#foo */ - if (operandP->vop_reg == -1 && operandP->vop_short != 's') - { /* "{@}{q^}foo" */ - if (to_seg == now_seg) - { - if (length == 0) - { - know (operandP->vop_short == ' '); - p = frag_var (rs_machine_dependent, 10, 2, - ENCODE_RELAX (STATE_PC_RELATIVE, STATE_BYTE), - this_add_symbol, this_add_number, - opcode_low_byteP); - know (operandP->vop_mode == 10 + at); - *p = at << 4; - /* At is the only context we need to carry to */ - /* other side of relax() process. */ - /* Must be in the correct bit position of VAX */ - /* operand spec. byte. */ - } - else - { - know (length); - know (operandP->vop_short != ' '); - p = frag_more (length + 1); - /* JF is this array stuff really going to work? */ - p[0] = 0xF | ((at + "?\12\14?\16"[length]) << 4); - fix_new (frag_now, p + 1 - frag_now->fr_literal, - length, this_add_symbol, 0, - this_add_number, 1); - } - } - else - { /* to_seg != now_seg */ - if (this_add_symbol == NULL) - { - know (to_seg == SEG_ABSOLUTE); - /* Do @#foo: simpler relocation than foo-.(pc) anyway. */ - p = frag_more (5); - p[0] = VAX_ABSOLUTE_MODE; /* @#... */ - md_number_to_chars (p + 1, this_add_number, 4); - if (length && length != 4) - { - as_warn ("Length specification ignored. Address mode 9F used"); - } - } - else - { - /* {@}{q^}other_seg */ - know ((length == 0 && operandP->vop_short == ' ') - ||(length > 0 && operandP->vop_short != ' ')); - if (is_undefined) - { - /* - * We have a SEG_UNKNOWN symbol. It might - * turn out to be in the same segment as - * the instruction, permitting relaxation. - */ - p = frag_var (rs_machine_dependent, 5, 2, - ENCODE_RELAX (STATE_PC_RELATIVE, STATE_UNDF), - this_add_symbol, this_add_number, - 0); - p[0] = at << 4; - } - else - { - if (length == 0) - { - know (operandP->vop_short == ' '); - length = 4; /* Longest possible. */ - } - p = frag_more (length + 1); - p[0] = 0xF | ((at + "?\12\14?\16"[length]) << 4); - md_number_to_chars (p + 1, this_add_number, length); - fix_new (frag_now, - p + 1 - frag_now->fr_literal, - length, this_add_symbol, 0, - this_add_number, 1); - } - } - } - } - else - { /* {@}{q^}foo(Rn) or S^# or I^# or # */ - if (operandP->vop_mode < 0xA) - { /* # or S^# or I^# */ - /* know( (length == 0 && operandP->vop_short == ' ') - || (length > 0 && operandP->vop_short != ' ')); */ - if (length == 0 - && to_seg == SEG_ABSOLUTE - && operandP->vop_mode == 8 /* No '@'. */ - && this_add_number < 64 - && this_add_number >= 0) - { - operandP->vop_short = 's'; - } - if (operandP->vop_short == 's') - { - FRAG_APPEND_1_CHAR (this_add_number); - } - else - { /* I^#... */ - know (nbytes); - p = frag_more (nbytes + 1); - know (operandP->vop_reg == 0xF); - p[0] = (operandP->vop_mode << 4) | 0xF; - if (to_seg == SEG_ABSOLUTE) - { -/* - * If nbytes > 4, then we are scrod. We don't know if the - * high order bytes are to be 0xFF or 0x00. - * BSD4.2 & RMS say use 0x00. OK --- but this - * assembler needs ANOTHER rewrite to - * cope properly with this bug. - */ - md_number_to_chars (p + 1, this_add_number, min (4, nbytes)); - if (nbytes > 4) - { - bzero (p + 5, nbytes - 4); - } - } - else - { - if (to_seg == SEG_BIG) - { -/* - * Problem here is to get the bytes in the right order. - * We stored our constant as LITTLENUMs, not bytes. - */ - LITTLENUM_TYPE *lP; - - lP = floatP->low; - if (nbytes & 1) - { - know (nbytes == 1); - p[1] = *lP; - } - else - { - for (p++; nbytes; nbytes -= 2, p += 2, lP++) - { - md_number_to_chars (p, *lP, 2); - } - } - } - else - { - fix_new (frag_now, p + 1 - frag_now->fr_literal, - nbytes, this_add_symbol, 0, - this_add_number, 0); - } - } - } - } - else - { /* {@}{q^}foo(Rn) */ - know ((length == 0 && operandP->vop_short == ' ') - ||(length > 0 && operandP->vop_short != ' ')); - if (length == 0) - { - if (to_seg == SEG_ABSOLUTE) - { - register long test; - - test = this_add_number; - - if (test < 0) - test = ~test; - - length = test & 0xffff8000 ? 4 - : test & 0xffffff80 ? 2 - : 1; - } - else - { - length = 4; - } - } - p = frag_more (1 + length); - know (operandP->vop_reg >= 0); - p[0] = operandP->vop_reg - | ((at | "?\12\14?\16"[length]) << 4); - if (to_seg == SEG_ABSOLUTE) - { - md_number_to_chars (p + 1, this_add_number, length); - } - else - { - fix_new (frag_now, p + 1 - frag_now->fr_literal, - length, this_add_symbol, 0, - this_add_number, 0); - } - } - } - } /* if(single-byte-operand) */ - } - } /* for(operandP) */ - } /* if(!need_pass_2&&!goofed) */ -} /* vax_assemble() */ - -/* - * md_estimate_size_before_relax() - * - * Called just before relax(). - * Any symbol that is now undefined will not become defined. - * Return the correct fr_subtype in the frag. - * Return the initial "guess for fr_var" to caller. - * The guess for fr_var is ACTUALLY the growth beyond fr_fix. - * Whatever we do to grow fr_fix or fr_var contributes to our returned value. - * Although it may not be explicit in the frag, pretend fr_var starts with a - * 0 value. - */ -int -md_estimate_size_before_relax (fragP, segment) - register fragS *fragP; - register segT segment; -{ - register char *p; - register int old_fr_fix; - - old_fr_fix = fragP->fr_fix; - switch (fragP->fr_subtype) - { - case ENCODE_RELAX (STATE_PC_RELATIVE, STATE_UNDF): - if (S_GET_SEGMENT(fragP->fr_symbol) == segment) - { /* A relaxable case. */ - fragP->fr_subtype = ENCODE_RELAX (STATE_PC_RELATIVE, STATE_BYTE); - } - else - { - p = fragP->fr_literal + old_fr_fix; - p[0] |= VAX_PC_RELATIVE_MODE; /* Preserve @ bit. */ - fragP->fr_fix += 1 + 4; - fix_new (fragP, old_fr_fix + 1, 4, fragP->fr_symbol, 0, - fragP->fr_offset, 1); - frag_wane (fragP); - } - break; - - case ENCODE_RELAX (STATE_CONDITIONAL_BRANCH, STATE_UNDF): - if (S_GET_SEGMENT(fragP->fr_symbol) == segment) - { - fragP->fr_subtype = ENCODE_RELAX (STATE_CONDITIONAL_BRANCH, STATE_BYTE); - } - else - { - p = fragP->fr_literal + old_fr_fix; - *fragP->fr_opcode ^= 1; /* Reverse sense of branch. */ - p[0] = 6; - p[1] = VAX_JMP; - p[2] = VAX_PC_RELATIVE_MODE; /* ...(PC) */ - fragP->fr_fix += 1 + 1 + 1 + 4; - fix_new (fragP, old_fr_fix + 3, 4, fragP->fr_symbol, 0, - fragP->fr_offset, 1); - frag_wane (fragP); - } - break; - - case ENCODE_RELAX (STATE_COMPLEX_BRANCH, STATE_UNDF): - if (S_GET_SEGMENT(fragP->fr_symbol) == segment) - { - fragP->fr_subtype = ENCODE_RELAX (STATE_COMPLEX_BRANCH, STATE_WORD); - } - else - { - p = fragP->fr_literal + old_fr_fix; - p[0] = 2; - p[1] = 0; - p[2] = VAX_BRB; - p[3] = 6; - p[4] = VAX_JMP; - p[5] = VAX_PC_RELATIVE_MODE; /* ...(pc) */ - fragP->fr_fix += 2 + 2 + 1 + 1 + 4; - fix_new (fragP, old_fr_fix + 6, 4, fragP->fr_symbol, 0, - fragP->fr_offset, 1); - frag_wane (fragP); - } - break; - - case ENCODE_RELAX (STATE_COMPLEX_HOP, STATE_UNDF): - if (S_GET_SEGMENT(fragP->fr_symbol) == segment) - { - fragP->fr_subtype = ENCODE_RELAX (STATE_COMPLEX_HOP, STATE_BYTE); - } - else - { - p = fragP->fr_literal + old_fr_fix; - p[0] = 2; - p[1] = VAX_BRB; - p[2] = 6; - p[3] = VAX_JMP; - p[4] = VAX_PC_RELATIVE_MODE; /* ...(pc) */ - fragP->fr_fix += 1 + 2 + 1 + 1 + 4; - fix_new (fragP, old_fr_fix + 5, 4, fragP->fr_symbol, 0, - fragP->fr_offset, 1); - frag_wane (fragP); - } - break; - - case ENCODE_RELAX (STATE_ALWAYS_BRANCH, STATE_UNDF): - if (S_GET_SEGMENT(fragP->fr_symbol) == segment) - { - fragP->fr_subtype = ENCODE_RELAX (STATE_ALWAYS_BRANCH, STATE_BYTE); - } - else - { - p = fragP->fr_literal + old_fr_fix; - *fragP->fr_opcode += VAX_WIDEN_LONG; - p[0] = VAX_PC_RELATIVE_MODE; /* ...(PC) */ - fragP->fr_fix += 1 + 4; - fix_new (fragP, old_fr_fix + 1, 4, fragP->fr_symbol, 0, - fragP->fr_offset, 1); - frag_wane (fragP); - } - break; - - default: - break; - } - return (fragP->fr_var + fragP->fr_fix - old_fr_fix); -} /* md_estimate_size_before_relax() */ - -/* - * md_convert_frag(); - * - * Called after relax() is finished. - * In: Address of frag. - * fr_type == rs_machine_dependent. - * fr_subtype is what the address relaxed to. - * - * Out: Any fixSs and constants are set up. - * Caller will turn frag into a ".space 0". - */ -void -md_convert_frag (fragP) - register fragS *fragP; -{ - register char *addressP; /* -> _var to change. */ - register char *opcodeP; /* -> opcode char(s) to change. */ - register short int length_code; /* 2=long 1=word 0=byte */ - register short int extension; /* Size of relaxed address. */ - /* Added to fr_fix: incl. ALL var chars. */ - register symbolS *symbolP; - register long where; - register long address_of_var; - /* Where, in file space, is _var of *fragP? */ - register long target_address; - /* Where, in file space, does addr point? */ - - know (fragP->fr_type == rs_machine_dependent); - length_code = fragP->fr_subtype & 3; /* depends on ENCODE_RELAX() */ - know (length_code >= 0 && length_code < 3); - where = fragP->fr_fix; - addressP = fragP->fr_literal + where; - opcodeP = fragP->fr_opcode; - symbolP = fragP->fr_symbol; - know (symbolP); - target_address = symbolP->sy_value + fragP->fr_offset; - address_of_var = fragP->fr_address + where; - switch (fragP->fr_subtype) - { - case ENCODE_RELAX (STATE_PC_RELATIVE, STATE_BYTE): - know (*addressP == 0 || *addressP == 0x10); /* '@' bit. */ - addressP[0] |= 0xAF; /* Byte displacement. */ - addressP[1] = target_address - (address_of_var + 2); - extension = 2; - break; - - case ENCODE_RELAX (STATE_PC_RELATIVE, STATE_WORD): - know (*addressP == 0 || *addressP == 0x10); /* '@' bit. */ - addressP[0] |= 0xCF; /* Word displacement. */ - md_number_to_chars (addressP + 1, target_address - (address_of_var + 3), 2); - extension = 3; - break; - - case ENCODE_RELAX (STATE_PC_RELATIVE, STATE_LONG): - know (*addressP == 0 || *addressP == 0x10); /* '@' bit. */ - addressP[0] |= 0xEF; /* Long word displacement. */ - md_number_to_chars (addressP + 1, target_address - (address_of_var + 5), 4); - extension = 5; - break; - - case ENCODE_RELAX (STATE_CONDITIONAL_BRANCH, STATE_BYTE): - addressP[0] = target_address - (address_of_var + 1); - extension = 1; - break; - - case ENCODE_RELAX (STATE_CONDITIONAL_BRANCH, STATE_WORD): - opcodeP[0] ^= 1; /* Reverse sense of test. */ - addressP[0] = 3; - addressP[1] = VAX_BRB + VAX_WIDEN_WORD; - md_number_to_chars (addressP + 2, target_address - (address_of_var + 4), 2); - extension = 4; - break; - - case ENCODE_RELAX (STATE_CONDITIONAL_BRANCH, STATE_LONG): - opcodeP[0] ^= 1; /* Reverse sense of test. */ - addressP[0] = 6; - addressP[1] = VAX_JMP; - addressP[2] = VAX_PC_RELATIVE_MODE; - md_number_to_chars (addressP + 3, target_address, 4); - extension = 7; - break; - - case ENCODE_RELAX (STATE_ALWAYS_BRANCH, STATE_BYTE): - addressP[0] = target_address - (address_of_var + 1); - extension = 1; - break; - - case ENCODE_RELAX (STATE_ALWAYS_BRANCH, STATE_WORD): - opcodeP[0] += VAX_WIDEN_WORD; /* brb -> brw, bsbb -> bsbw */ - md_number_to_chars (addressP, target_address - (address_of_var + 2), 2); - extension = 2; - break; - - case ENCODE_RELAX (STATE_ALWAYS_BRANCH, STATE_LONG): - opcodeP[0] += VAX_WIDEN_LONG; /* brb -> jmp, bsbb -> jsb */ - addressP[0] = VAX_PC_RELATIVE_MODE; - md_number_to_chars (addressP + 1, target_address - (address_of_var + 5), 4); - extension = 5; - break; - - case ENCODE_RELAX (STATE_COMPLEX_BRANCH, STATE_WORD): - md_number_to_chars (addressP, target_address - (address_of_var + 2), 2); - extension = 2; - break; - - case ENCODE_RELAX (STATE_COMPLEX_BRANCH, STATE_LONG): - addressP[0] = 2; - addressP[1] = 0; - addressP[2] = VAX_BRB; - addressP[3] = 6; - addressP[4] = VAX_JMP; - addressP[5] = VAX_PC_RELATIVE_MODE; - md_number_to_chars (addressP + 6, target_address, 4); - extension = 10; - break; - - case ENCODE_RELAX (STATE_COMPLEX_HOP, STATE_BYTE): - addressP[0] = target_address - (address_of_var + 1); - extension = 1; - break; - - case ENCODE_RELAX (STATE_COMPLEX_HOP, STATE_WORD): - addressP[0] = 2; - addressP[1] = VAX_BRB; - addressP[2] = 3; - addressP[3] = VAX_BRW; - md_number_to_chars (addressP + 4, target_address - (address_of_var + 6), 2); - extension = 6; - break; - - case ENCODE_RELAX (STATE_COMPLEX_HOP, STATE_LONG): - addressP[0] = 2; - addressP[1] = VAX_BRB; - addressP[2] = 6; - addressP[3] = VAX_JMP; - addressP[4] = VAX_PC_RELATIVE_MODE; - md_number_to_chars (addressP + 5, target_address, 4); - extension = 9; - break; - - default: - BAD_CASE (fragP->fr_subtype); - break; - } - fragP->fr_fix += extension; -} - -/* Translate internal format of relocation info into target format. - - On vax: first 4 bytes are normal unsigned long, next three bytes - are symbolnum, least sig. byte first. Last byte is broken up with - the upper nibble as nuthin, bit 3 as extern, bits 2 & 1 as length, and - bit 0 as pcrel. */ -void -md_ri_to_chars (the_bytes, ri) - char *the_bytes; - struct reloc_info_generic ri; -{ - /* this is easy */ - md_number_to_chars (the_bytes, ri.r_address, sizeof (ri.r_address)); - /* now the fun stuff */ - the_bytes[6] = (ri.r_symbolnum >> 16) & 0x0ff; - the_bytes[5] = (ri.r_symbolnum >> 8) & 0x0ff; - the_bytes[4] = ri.r_symbolnum & 0x0ff; - the_bytes[7] = (((ri.r_extern << 3) & 0x08) | ((ri.r_length << 1) & 0x06) | - ((ri.r_pcrel << 0) & 0x01)) & 0x0F; -} - -/* - * BUGS, GRIPES, APOLOGIA, etc. - * - * The opcode table 'votstrs' needs to be sorted on opcode frequency. - * That is, AFTER we hash it with hash_...(), we want most-used opcodes - * to come out of the hash table faster. - * - * I am sorry to inflict - * yet another VAX assembler on the world, but RMS says we must - * do everything from scratch, to prevent pin-heads restricting - * this software. - */ - -/* - * This is a vaguely modular set of routines in C to parse VAX - * assembly code using DEC mnemonics. It is NOT un*x specific. - * - * The idea here is that the assembler has taken care of all: - * labels - * macros - * listing - * pseudo-ops - * line continuation - * comments - * condensing any whitespace down to exactly one space - * and all we have to do is parse 1 line into a vax instruction - * partially formed. We will accept a line, and deliver: - * an error message (hopefully empty) - * a skeleton VAX instruction (tree structure) - * textual pointers to all the operand expressions - * a warning message that notes a silly operand (hopefully empty) - */ - -/* - * E D I T H I S T O R Y - * - * 17may86 Dean Elsner. Bug if line ends immediately after opcode. - * 30apr86 Dean Elsner. New vip_op() uses arg block so change call. - * 6jan86 Dean Elsner. Crock vip_begin() to call vip_op_defaults(). - * 2jan86 Dean Elsner. Invent synthetic opcodes. - * Widen vax_opcodeT to 32 bits. Use a bit for VIT_OPCODE_SYNTHETIC, - * which means this is not a real opcode, it is like a macro; it will - * be relax()ed into 1 or more instructions. - * Use another bit for VIT_OPCODE_SPECIAL if the op-code is not optimised - * like a regular branch instruction. Option added to vip_begin(): - * exclude synthetic opcodes. Invent synthetic_votstrs[]. - * 31dec85 Dean Elsner. Invent vit_opcode_nbytes. - * Also make vit_opcode into a char[]. We now have n-byte vax opcodes, - * so caller's don't have to know the difference between a 1-byte & a - * 2-byte op-code. Still need vax_opcodeT concept, so we know how - * big an object must be to hold an op.code. - * 30dec85 Dean Elsner. Widen typedef vax_opcodeT in "vax-inst.h" - * because vax opcodes may be 16 bits. Our crufty C compiler was - * happily initialising 8-bit vot_codes with 16-bit numbers! - * (Wouldn't the 'phone company like to compress data so easily!) - * 29dec85 Dean Elsner. New static table vax_operand_width_size[]. - * Invented so we know hw many bytes a "I^#42" needs in its immediate - * operand. Revised struct vop in "vax-inst.h": explicitly include - * byte length of each operand, and it's letter-code datum type. - * 17nov85 Dean Elsner. Name Change. - * Due to ar(1) truncating names, we learned the hard way that - * "vax-inst-parse.c" -> "vax-inst-parse." dropping the "o" off - * the archived object name. SO... we shortened the name of this - * source file, and changed the makefile. - */ - -static char *op_hash = NULL; /* handle of the OPCODE hash table */ - /* NULL means any use before vip_begin() */ - /* will crash */ - -/* - * In: 1 character, from "bdfghloqpw" being the data-type of an operand - * of a vax instruction. - * - * Out: the length of an operand of that type, in bytes. - * Special branch operands types "-?!" have length 0. - */ - -static const short int vax_operand_width_size[256] = -{ - -#define _ 0 - _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, - _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, - _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, - _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, - _, _, 1, _, 8, _, 4, 8, 16, _, _, _, 4, _, _, 16, /* ..b.d.fgh...l..o */ - _, 8, _, _, _, _, _, 2, _, _, _, _, _, _, _, _, /* .q.....w........ */ - _, _, 1, _, 8, _, 4, 8, 16, _, _, _, 4, _, _, 16, /* ..b.d.fgh...l..o */ - _, 8, _, _, _, _, _, 2, _, _, _, _, _, _, _, _, /* .q.....w........ */ - _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, - _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, - _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, - _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, - _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, - _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, - _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, - _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _}; -#undef _ - -/* - * This perversion encodes all the vax opcodes as a bunch of strings. - * RMS says we should build our hash-table at run-time. Hmm. - * Please would someone arrange these in decreasing frequency of opcode? - * Because of the way hash_...() works, the most frequently used opcode - * should be textually first and so on. - * - * Input for this table was 'vax.opcodes', awk(1)ed by 'vax.opcodes.c.awk' . - * So change 'vax.opcodes', then re-generate this table. - */ - -#include "vax-opcode.h" - -/* - * This is a table of optional op-codes. All of them represent - * 'synthetic' instructions that seem popular. - * - * Here we make some pseudo op-codes. Every code has a bit set to say - * it is synthetic. This lets you catch them if you want to - * ban these opcodes. They are mnemonics for "elastic" instructions - * that are supposed to assemble into the fewest bytes needed to do a - * branch, or to do a conditional branch, or whatever. - * - * The opcode is in the usual place [low-order n*8 bits]. This means - * that if you mask off the bucky bits, the usual rules apply about - * how long the opcode is. - * - * All VAX branch displacements come at the end of the instruction. - * For simple branches (1-byte opcode + 1-byte displacement) the last - * operand is coded 'b?' where the "data type" '?' is a clue that we - * may reverse the sense of the branch (complement lowest order bit) - * and branch around a jump. This is by far the most common case. - * That is why the VIT_OPCODE_SYNTHETIC bit is set: it says this is - * a 0-byte op-code followed by 2 or more bytes of operand address. - * - * If the op-code has VIT_OPCODE_SPECIAL set, then we have a more unusual - * case. - * - * For JBSB & JBR the treatment is the similar, except (1) we have a 'bw' - * option before (2) we can directly JSB/JMP because there is no condition. - * These operands have 'b-' as their access/data type. - * - * That leaves a bunch of random opcodes: JACBx, JxOBxxx. In these - * cases, we do the same idea. JACBxxx are all marked with a 'b!' - * JAOBxxx & JSOBxxx are marked with a 'b:'. - * - */ -#if (VIT_OPCODE_SYNTHETIC != 0x80000000) -You have just broken the encoding below, which assumes the sign bit - means 'I am an imaginary instruction'. -#endif - -#if (VIT_OPCODE_SPECIAL != 0x40000000) - You have just broken the encoding below, which assumes the 0x40 M bit means - 'I am not to be "optimised" the way normal branches are'. -#endif - -static const struct vot - synthetic_votstrs[] = -{ - {"jbsb", - {"b-", 0xC0000010}}, /* BSD 4.2 */ - /* jsb used already */ - {"jbr", - {"b-", 0xC0000011}}, /* BSD 4.2 */ - {"jr", - {"b-", 0xC0000011}}, /* consistent */ - {"jneq", - {"b?", 0x80000012}}, - {"jnequ", - {"b?", 0x80000012}}, - {"jeql", - {"b?", 0x80000013}}, - {"jeqlu", - {"b?", 0x80000013}}, - {"jgtr", - {"b?", 0x80000014}}, - {"jleq", - {"b?", 0x80000015}}, - /* un-used opcodes here */ - {"jgeq", - {"b?", 0x80000018}}, - {"jlss", - {"b?", 0x80000019}}, - {"jgtru", - {"b?", 0x8000001a}}, - {"jlequ", - {"b?", 0x8000001b}}, - {"jvc", - {"b?", 0x8000001c}}, - {"jvs", - {"b?", 0x8000001d}}, - {"jgequ", - {"b?", 0x8000001e}}, - {"jcc", - {"b?", 0x8000001e}}, - {"jlssu", - {"b?", 0x8000001f}}, - {"jcs", - {"b?", 0x8000001f}}, - - {"jacbw", - {"rwrwmwb!", 0xC000003d}}, - {"jacbf", - {"rfrfmfb!", 0xC000004f}}, - {"jacbd", - {"rdrdmdb!", 0xC000006f}}, - {"jacbb", - {"rbrbmbb!", 0xC000009d}}, - {"jacbl", - {"rlrlmlb!", 0xC00000f1}}, - {"jacbg", - {"rgrgmgb!", 0xC0004ffd}}, - {"jacbh", - {"rhrhmhb!", 0xC0006ffd}}, - - {"jbs", - {"rlvbb?", 0x800000e0}}, - {"jbc", - {"rlvbb?", 0x800000e1}}, - {"jbss", - {"rlvbb?", 0x800000e2}}, - {"jbcs", - {"rlvbb?", 0x800000e3}}, - {"jbsc", - {"rlvbb?", 0x800000e4}}, - {"jbcc", - {"rlvbb?", 0x800000e5}}, - {"jbssi", - {"rlvbb?", 0x800000e6}}, - {"jbcci", - {"rlvbb?", 0x800000e7}}, - {"jlbs", - {"rlb?", 0x800000e8}}, /* JF changed from rlvbb? */ - {"jlbc", - {"rlb?", 0x800000e9}}, /* JF changed from rlvbb? */ - - {"jaoblss", - {"rlmlb:", 0xC00000f2}}, - {"jaobleq", - {"rlmlb:", 0xC00000f3}}, - {"jsobgeq", - {"mlb:", 0xC00000f4}}, /* JF was rlmlb: */ - {"jsobgtr", - {"mlb:", 0xC00000f5}}, /* JF was rlmlb: */ - -/* CASEx has no branch addresses in our conception of it. */ -/* You should use ".word ..." statements after the "case ...". */ - - {"", ""} /* empty is end sentinel */ - -}; /* synthetic_votstrs */ - -/* - * v i p _ b e g i n ( ) - * - * Call me once before you decode any lines. - * I decode votstrs into a hash table at op_hash (which I create). - * I return an error text: hopefully "". - * If you want, I will include the 'synthetic' jXXX instructions in the - * instruction table. - * You must nominate metacharacters for eg DEC's "#", "@", "^". - */ - -char * -vip_begin (synthetic_too, immediate, indirect, displen) - int synthetic_too; /* TRUE means include jXXX op-codes. */ - char *immediate, *indirect, *displen; -{ - register const struct vot *vP; /* scan votstrs */ - register char *retval; /* error text */ - - char *hash_insert (); /* */ - char *hash_new (); /* lies */ - - if ((op_hash = hash_new ())) - { - retval = ""; /* OK so far */ - for (vP = votstrs; *vP->vot_name && !*retval; vP++) - { - retval = hash_insert (op_hash, vP->vot_name, &vP->vot_detail); - } - if (synthetic_too) - { - for (vP = synthetic_votstrs; *vP->vot_name && !*retval; vP++) - { - retval = hash_insert (op_hash, vP->vot_name, &vP->vot_detail); - } - } - } - else - { - retval = "virtual memory exceeded"; - } -#ifndef CONST_TABLE - vip_op_defaults (immediate, indirect, displen); -#endif - - return (retval); -} - - -/* - * v i p _ e n d ( ) - * - * Call me once after you have decoded all lines. - * I do any cleaning-up needed. - * - * We don't have to do any cleanup ourselves: all of our operand - * symbol table is static, and free()ing it is naughty. - */ -vip_end () -{ -} - -/* - * v i p ( ) - * - * This converts a string into a vax instruction. - * The string must be a bare single instruction in dec-vax (with BSD4 frobs) - * format. - * It provides some error messages: at most one fatal error message (which - * stops the scan) and at most one warning message for each operand. - * The vax instruction is returned in exploded form, since we have no - * knowledge of how you parse (or evaluate) your expressions. - * We do however strip off and decode addressing modes and operation - * mnemonic. - * - * The exploded instruction is returned to a struct vit of your choice. - * #include "vax-inst.h" to know what a struct vit is. - * - * This function's value is a string. If it is not "" then an internal - * logic error was found: read this code to assign meaning to the string. - * No argument string should generate such an error string: - * it means a bug in our code, not in the user's text. - * - * You MUST have called vip_begin() once and vip_end() never before using - * this function. - */ - -char * /* "" or bug string */ -vip (vitP, instring) - struct vit *vitP; /* We build an exploded instruction here. */ - char *instring; /* Text of a vax instruction: we modify. */ -{ - register struct vot_wot *vwP; /* How to bit-encode this opcode. */ - register char *p; /* 1/skip whitespace.2/scan vot_how */ - register char *q; /* */ - register char *bug; /* "" or program logic error */ - register unsigned char count; /* counts number of operands seen */ - register struct vop *operandp;/* scan operands in struct vit */ - register char *alloperr; /* error over all operands */ - register char c; /* Remember char, (we clobber it */ - /* with '\0' temporarily). */ - register vax_opcodeT oc; /* Op-code of this instruction. */ - - struct vot_wot *hash_find (); - char *vip_op (); - - bug = ""; - if (*instring == ' ') - ++instring; /* Skip leading whitespace. */ - for (p = instring; *p && *p != ' '; p++) - ; /* MUST end in end-of-string or exactly 1 space. */ - /* Scanned up to end of operation-code. */ - /* Operation-code is ended with whitespace. */ - if (p - instring == 0) - { - vitP->vit_error = "No operator"; - count = 0; - bzero (vitP->vit_opcode, sizeof (vitP->vit_opcode)); - } - else - { - c = *p; - *p = '\0'; - /* - * Here with instring pointing to what better be an op-name, and p - * pointing to character just past that. - * We trust instring points to an op-name, with no whitespace. - */ - vwP = hash_find (op_hash, instring); - *p = c; /* Restore char after op-code. */ - if (vwP == 0) - { - vitP->vit_error = "Unknown operator"; - count = 0; - bzero (vitP->vit_opcode, sizeof (vitP->vit_opcode)); - } - else - { - /* - * We found a match! So lets pick up as many operands as the - * instruction wants, and even gripe if there are too many. - * We expect comma to seperate each operand. - * We let instring track the text, while p tracks a part of the - * struct vot. - */ - /* - * The lines below know about 2-byte opcodes starting FD,FE or FF. - * They also understand synthetic opcodes. Note: - * we return 32 bits of opcode, including bucky bits, BUT - * an opcode length is either 8 or 16 bits for vit_opcode_nbytes. - */ - oc = vwP->vot_code; /* The op-code. */ - vitP->vit_opcode_nbytes = (oc & 0xFF) >= 0xFD ? 2 : 1; - md_number_to_chars (vitP->vit_opcode, oc, 4); - count = 0; /* no operands seen yet */ - instring = p; /* point just past operation code */ - alloperr = ""; - for (p = vwP->vot_how, operandp = vitP->vit_operand; - !*alloperr && !*bug && *p; - operandp++, p += 2 - ) - { - /* - * Here to parse one operand. Leave instring pointing just - * past any one ',' that marks the end of this operand. - */ - if (!p[1]) - bug = "p"; /* ODD(!!) number of bytes in vot_how?? */ - else if (*instring) - { - for (q = instring; (c = *q) && c != ','; q++) - ; - /* - * Q points to ',' or '\0' that ends argument. C is that - * character. - */ - *q = 0; - operandp->vop_width = p[1]; - operandp->vop_nbytes = vax_operand_width_size[p[1]]; - operandp->vop_access = p[0]; - bug = vip_op (instring, operandp); - *q = c; /* Restore input text. */ - if (*(operandp->vop_error)) - alloperr = "Bad operand"; - instring = q + (c ? 1 : 0); /* next operand (if any) */ - count++; /* won another argument, may have an operr */ - } - else - alloperr = "Not enough operands"; - } - if (!*alloperr) - { - if (*instring == ' ') - instring++; /* Skip whitespace. */ - if (*instring) - alloperr = "Too many operands"; - } - vitP->vit_error = alloperr; - } - } - vitP->vit_operands = count; - return (bug); -} - -#ifdef test - -/* - * Test program for above. - */ - -struct vit myvit; /* build an exploded vax instruction here */ -char answer[100]; /* human types a line of vax assembler here */ -char *mybug; /* "" or an internal logic diagnostic */ -int mycount; /* number of operands */ -struct vop *myvop; /* scan operands from myvit */ -int mysynth; /* TRUE means want synthetic opcodes. */ -char my_immediate[200]; -char my_indirect[200]; -char my_displen[200]; - -char *vip (); - -main () -{ - char *p; - char *vip_begin (); - - printf ("0 means no synthetic instructions. "); - printf ("Value for vip_begin? "); - gets (answer); - sscanf (answer, "%d", &mysynth); - printf ("Synthetic opcodes %s be included.\n", mysynth ? "will" : "will not"); - printf ("enter immediate symbols eg enter # "); - gets (my_immediate); - printf ("enter indirect symbols eg enter @ "); - gets (my_indirect); - printf ("enter displen symbols eg enter ^ "); - gets (my_displen); - if (*(p = vip_begin (mysynth, my_immediate, my_indirect, my_displen))) - { - error ("vip_begin=%s", p); - } - printf ("An empty input line will quit you from the vax instruction parser\n"); - for (;;) - { - printf ("vax instruction: "); - fflush (stdout); - gets (answer); - if (!*answer) - { - break; /* out of for each input text loop */ - } - mybug = vip (&myvit, answer); - if (*mybug) - { - printf ("BUG:\"%s\"\n", mybug); - } - if (*myvit.vit_error) - { - printf ("ERR:\"%s\"\n", myvit.vit_error); - } - printf ("opcode="); - for (mycount = myvit.vit_opcode_nbytes, p = myvit.vit_opcode; - mycount; - mycount--, p++ - ) - { - printf ("%02x ", *p & 0xFF); - } - printf (" operand count=%d.\n", mycount = myvit.vit_operands); - for (myvop = myvit.vit_operand; mycount; mycount--, myvop++) - { - printf ("mode=%xx reg=%xx ndx=%xx len='%c'=%c%c%d. expr=\"", - myvop->vop_mode, myvop->vop_reg, myvop->vop_ndx, - myvop->vop_short, myvop->vop_access, myvop->vop_width, - myvop->vop_nbytes); - for (p = myvop->vop_expr_begin; p <= myvop->vop_expr_end; p++) - { - putchar (*p); - } - printf ("\"\n"); - if (*myvop->vop_error) - { - printf (" err:\"%s\"\n", myvop->vop_error); - } - if (*myvop->vop_warn) - { - printf (" wrn:\"%s\"\n", myvop->vop_warn); - } - } - } - vip_end (); - exit (); -} - -#endif /* #ifdef test */ - -/* end of vax_ins_parse.c */ - - /* JF this used to be a separate file also */ -/* vax_reg_parse.c - convert a VAX register name to a number */ - -/* Copyright (C) 1987 Free Software Foundation, Inc. A part of GNU. */ - -/* - * v a x _ r e g _ p a r s e ( ) - * - * Take 3 char.s, the last of which may be `\0` (non-existent) - * and return the VAX register number that they represent. - * - * Return -1 if they don't form a register name. Good names return - * a number from 0:15 inclusive. - * - * Case is not important in a name. - * - * Register names understood are: - * - * R0 - * R1 - * R2 - * R3 - * R4 - * R5 - * R6 - * R7 - * R8 - * R9 - * R10 - * R11 - * R12 AP - * R13 FP - * R14 SP - * R15 PC - * - */ - -#include -#define AP (12) -#define FP (13) -#define SP (14) -#define PC (15) - -int /* return -1 or 0:15 */ -vax_reg_parse (c1, c2, c3) /* 3 chars of register name */ - char c1, c2, c3; /* c3 == 0 if 2-character reg name */ -{ - register int retval; /* return -1:15 */ - - retval = -1; - - if (isupper (c1)) - c1 = tolower (c1); - if (isupper (c2)) - c2 = tolower (c2); - if (isdigit (c2) && c1 == 'r') - { - retval = c2 - '0'; - if (isdigit (c3)) - { - retval = retval * 10 + c3 - '0'; - retval = (retval > 15) ? -1 : retval; - /* clamp the register value to 1 hex digit */ - } - else if (c3) - retval = -1; /* c3 must be '\0' or a digit */ - } - else if (c3) /* There are no three letter regs */ - retval = -1; - else if (c2 == 'p') - { - switch (c1) - { - case 's': - retval = SP; - break; - case 'f': - retval = FP; - break; - case 'a': - retval = AP; - break; - default: - retval = -1; - } - } - else if (c1 == 'p' && c2 == 'c') - retval = PC; - else - retval = -1; - return (retval); -} - -/* - * v i p _ o p ( ) - * - * Parse a vax operand in DEC assembler notation. - * For speed, expect a string of whitespace to be reduced to a single ' '. - * This is the case for GNU AS, and is easy for other DEC-compatible - * assemblers. - * - * Knowledge about DEC VAX assembler operand notation lives here. - * This doesn't even know what a register name is, except it believes - * all register names are 2 or 3 characters, and lets vax_reg_parse() say - * what number each name represents. - * It does, however, know that PC, SP etc are special registers so it can - * detect addressing modes that are silly for those registers. - * - * Where possible, it delivers 1 fatal or 1 warning message if the operand - * is suspect. Exactly what we test for is still evolving. - */ - -/* - * B u g s - * - * Arg block. - * - * There were a number of 'mismatched argument type' bugs to vip_op. - * The most general solution is to typedef each (of many) arguments. - * We used instead a typedef'd argument block. This is less modular - * than using seperate return pointers for each result, but runs faster - * on most engines, and seems to keep programmers happy. It will have - * to be done properly if we ever want to use vip_op as a general-purpose - * module (it was designed to be). - * - * G^ - * - * Doesn't support DEC "G^" format operands. These always take 5 bytes - * to express, and code as modes 8F or 9F. Reason: "G^" deprives you of - * optimising to (say) a "B^" if you are lucky in the way you link. - * When someone builds a linker smart enough to convert "G^" to "B^", "W^" - * whenever possible, then we should implement it. - * If there is some other use for "G^", feel free to code it in! - * - * - * speed - * - * If I nested if()s more, I could avoid testing (*err) which would save - * time, space and page faults. I didn't nest all those if()s for clarity - * and because I think the mode testing can be re-arranged 1st to test the - * commoner constructs 1st. Does anybody have statistics on this? - * - * - * - * error messages - * - * In future, we should be able to 'compose' error messages in a scratch area - * and give the user MUCH more informative error messages. Although this takes - * a little more code at run-time, it will make this module much more self- - * documenting. As an example of what sucks now: most error messages have - * hardwired into them the DEC VAX metacharacters "#^@" which are nothing like - * the Un*x characters "$`*", that most users will expect from this AS. - */ - -/* - * The input is a string, ending with '\0'. - * - * We also require a 'hint' of what kind of operand is expected: so - * we can remind caller not to write into literals for instance. - * - * The output is a skeletal instruction. - * - * The algorithm has two parts. - * 1. extract the syntactic features (parse off all the @^#-()+[] mode crud); - * 2. express the @^#-()+[] as some parameters suited to further analysis. - * - * 2nd step is where we detect the googles of possible invalid combinations - * a human (or compiler) might write. Note that if we do a half-way - * decent assembler, we don't know how long to make (eg) displacement - * fields when we first meet them (because they may not have defined values). - * So we must wait until we know how many bits are needed for each address, - * then we can know both length and opcodes of instructions. - * For reason(s) above, we will pass to our caller a 'broken' instruction - * of these major components, from which our caller can generate instructions: - * - displacement length I^ S^ L^ B^ W^ unspecified - * - mode (many) - * - register R0-R15 or absent - * - index register R0-R15 or absent - * - expression text what we don't parse - * - error text(s) why we couldn't understand the operand - */ - -/* - * To decode output of this, test errtxt. If errtxt[0] == '\0', then - * we had no errors that prevented parsing. Also, if we ever report - * an internal bug, errtxt[0] is set non-zero. So one test tells you - * if the other outputs are to be taken seriously. - */ - - - /* vax registers we need to know */ -/* JF #define SP (14) -/* JF for one big happy file #define PC (15) */ - - /* useful ideas */ -/* #define TRUE (1) */ -/* #define FALSE (0) */ - -/* - * Because this module is useful for both VMS and UN*X style assemblers - * and because of the variety of UN*X assemblers we must recognise - * the different conventions for assembler operand notation. For example - * VMS says "#42" for immediate mode, while most UN*X say "$42". - * We permit arbitrary sets of (single) characters to represent the - * 3 concepts that DEC writes '#', '@', '^'. - */ - - /* character tests */ -#define VIP_IMMEDIATE 01 /* Character is like DEC # */ -#define VIP_INDIRECT 02 /* Char is like DEC @ */ -#define VIP_DISPLEN 04 /* Char is like DEC ^ */ - -#define IMMEDIATEP(c) (vip_metacharacters [(c)&0xff]&VIP_IMMEDIATE) -#define INDIRECTP(c) (vip_metacharacters [(c)&0xff]&VIP_INDIRECT) -#define DISPLENP(c) (vip_metacharacters [(c)&0xff]&VIP_DISPLEN) - -/* We assume 8 bits per byte. Use vip_op_defaults() to set these up BEFORE we - * are ever called. - */ - -#if defined(CONST_TABLE) -#define _ 0, -#define I VIP_IMMEDIATE, -#define S VIP_INDIRECT, -#define D VIP_DISPLEN, -static const char -vip_metacharacters[256] = { -_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _/*^@ ^A ^B ^C ^D ^E ^F ^G ^H ^I ^J ^K ^L ^M ^N ^O*/ -_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _/*^P ^Q ^R ^S ^T ^U ^V ^W ^X ^Y ^Z ^[ ^\ ^] ^^ ^_*/ -_ _ _ _ I _ _ _ _ _ S _ _ _ _ _/*sp ! " # $ % & ' ( ) * + , - . /*/ -_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _/*0 1 2 3 4 5 6 7 8 9 : ; < = > ?*/ -_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _/*@ A B C D E F G H I J K L M N O*/ -_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _/*P Q R S T U V W X Y Z [ \ ] ^ _*/ -D _ _ _ _ _ _ _ _ _ _ _ _ _ _ _/*` a b c d e f g h i j k l m n o*/ -_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _/*p q r s t u v w x y z { | } ~ ^?*/ - -_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ -_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ -_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ -_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ -_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ -_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ -_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ -_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ -}; -#undef _ -#undef I -#undef S -#undef D -#else -static char vip_metacharacters[256]; - -/* Macro is faster under GCC; The constant table is faster yet, but only works with ASCII */ -#if 0 -static -#ifdef __GNUC__ -inline -#endif -static void -vip_op_1(bit,syms) -int bit; -char *syms; -{ - unsigned char t; - - while(t= *syms++) - vip_metacharacters[t]|=bit; -} -#else -#define vip_op_1(bit,syms) { \ - unsigned char t; \ - char *table=vip_metacharacters; \ - while(t= *syms++) \ - table[t]|=bit; \ - } -#endif - -vip_op_defaults (immediate, indirect, displen) /* can be called any time */ - char *immediate, /* Strings of characters for each job. */ - *indirect, *displen; /* more arguments may appear in future! */ -{ - vip_op_1 (VIP_IMMEDIATE, immediate); - vip_op_1 (VIP_INDIRECT, indirect); - vip_op_1 (VIP_DISPLEN, displen); -} -#endif - - -/* - * Dec defines the semantics of address modes (and values) - * by a two-letter code, explained here. - * - * letter 1: access type - * - * a address calculation - no data access, registers forbidden - * b branch displacement - * m read - let go of bus - write back "modify" - * r read - * v bit field address: like 'a' but registers are OK - * w write - * space no operator (eg ".long foo") [our convention] - * - * letter 2: data type (i.e. width, alignment) - * - * b byte - * d double precision floating point (D format) - * f single precision floating point (F format) - * g G format floating - * h H format floating - * l longword - * o octaword - * q quadword - * w word - * ? simple synthetic branch operand - * - unconditional synthetic JSB/JSR operand - * ! complex synthetic branch operand - * - * The '-?!' letter 2's are not for external consumption. They are used - * for various assemblers. Generally, all unknown widths are assumed 0. - * We don't limit your choice of width character. - * - * DEC operands are hard work to parse. For example, '@' as the first - * character means indirect (deferred) mode but elswhere it is a shift - * operator. - * The long-winded explanation of how this is supposed to work is - * cancelled. Read a DEC vax manual. - * We try hard not to parse anything that MIGHT be part of the expression - * buried in that syntax. For example if we see @...(Rn) we don't check - * for '-' before the '(' because mode @-(Rn) does not exist. - * - * After parsing we have: - * - * at TRUE if leading '@' (or Un*x '*') - * len takes one value from " bilsw". eg B^ -> 'b'. - * hash TRUE if leading '#' (or Un*x '$') - * expr_begin, expr_end the expression we did not parse - * even though we don't interpret it, we make use - * of its presence or absence. - * sign -1: -(Rn) 0: absent +1: (Rn)+ - * paren TRUE if () are around register - * reg major register number 0:15 -1 means absent - * ndx index register number 0:15 -1 means absent - * - * Again, I dare not explain it: just trace ALL the code! - */ - -char * /* (code here) bug message, "" = OK */ - /* our code bug, NOT bad assembly language */ -vip_op (optext, vopP) - char *optext; /* user's input string e.g.: */ - /* "@B^foo@bar(AP)[FP]:" */ - struct vop *vopP; /* In: vop_access, vop_width. */ - /* Out: _ndx, _reg, _mode, _short, _warn, */ - /* _error _expr_begin, _expr_end, _nbytes. */ - /* vop_nbytes : number of bytes in a datum. */ -{ - char *p; /* track operand text forward */ - char *q; /* track operand text backward */ - int at; /* TRUE if leading '@' ('*') seen */ - char len; /* one of " bilsw" */ - int hash; /* TRUE if leading '#' ('$') seen */ - int sign; /* -1, 0 or +1 */ - int paren; /* TRUE if () surround register */ - int reg; /* register number, -1:absent */ - int ndx; /* index register number -1:absent */ - char *bug; /* report any logic error in here, ""==OK */ - char *err; /* report illegal operand, ""==OK */ - /* " " is a FAKE error: means we won */ - /* ANY err that begins with ' ' is a fake. */ - /* " " is converted to "" before return */ - char *wrn; /* warn about weird modes pf address */ - char *oldq; /* preserve q in case we backup */ - int mode; /* build up 4-bit operand mode here */ - /* note: index mode is in ndx, this is */ - /* the major mode of operand address */ -/* - * Notice how we move wrong-arg-type bugs INSIDE this module: if we - * get the types wrong below, we lose at compile time rather than at - * lint or run time. - */ - char access; /* vop_access. */ - char width; /* vop_width. */ - - int vax_reg_parse (); /* returns 0:15 or -1 if not a register */ - - access = vopP->vop_access; - width = vopP->vop_width; - bug = /* none of our code bugs (yet) */ - err = /* no user text errors */ - wrn = ""; /* no warnings even */ - - p = optext; - - if (*p == ' ') /* Expect all whitespace reduced to ' '. */ - p++; /* skip over whitespace */ - - if (at = INDIRECTP (*p)) - { /* TRUE if *p=='@'(or '*' for Un*x) */ - p++; /* at is determined */ - if (*p == ' ') /* Expect all whitespace reduced to ' '. */ - p++; /* skip over whitespace */ - } - - /* - * This code is subtle. It tries to detect all legal (letter)'^' - * but it doesn't waste time explicitly testing for premature '\0' because - * this case is rejected as a mismatch against either (letter) or '^'. - */ - { - register char c; - - c = *p; - if (isupper (c)) - c = tolower (c); - if (DISPLENP (p[1]) && strchr ("bilws", len = c)) - p += 2; /* skip (letter) '^' */ - else /* no (letter) '^' seen */ - len = ' '; /* len is determined */ - } - - if (*p == ' ') /* Expect all whitespace reduced to ' '. */ - p++; /* skip over whitespace */ - - if (hash = IMMEDIATEP (*p)) /* TRUE if *p=='#' ('$' for Un*x) */ - p++; /* hash is determined */ - - /* - * p points to what may be the beginning of an expression. - * We have peeled off the front all that is peelable. - * We know at, len, hash. - * - * Lets point q at the end of the text and parse that (backwards). - */ - - for (q = p; *q; q++) - ; - q--; /* now q points at last char of text */ - - if (*q == ' ' && q >= p) /* Expect all whitespace reduced to ' '. */ - q--; - /* reverse over whitespace, but don't */ - /* run back over *p */ - - /* - * As a matter of policy here, we look for [Rn], although both Rn and S^# - * forbid [Rn]. This is because it is easy, and because only a sick - * cyborg would have [...] trailing an expression in a VAX-like assembler. - * A meticulous parser would first check for Rn followed by '(' or '[' - * and not parse a trailing ']' if it found another. We just ban expressions - * ending in ']'. - */ - if (*q == ']') - { - while (q >= p && *q != '[') - q--; - /* either q

= p) /* Expect all whitespace reduced to ' '. */ - q--; - /* reverse over whitespace, but don't */ - /* run back over *p */ - if (!*err) - { - sign = 0; /* no ()+ or -() seen yet */ - - if (q > p + 3 && *q == '+' && q[-1] == ')') - { - sign = 1; /* we saw a ")+" */ - q--; /* q points to ')' */ - } - - if (*q == ')' && q > p + 2) - { - paren = TRUE; /* assume we have "(...)" */ - while (q >= p && *q != '(') - q--; - /* either q

= 0 then we saw (Rn). - */ - } - /* - * If err == "..." then we lost. - * Otherwise paren==TRUE and reg = register in "()". - */ - } - else - paren = FALSE; - /* - * If err == "..." then we lost. - * Otherwise, q points just before "(Rn)", if any. - * If there was a "(...)" then paren==TRUE, and reg is the register. - */ - - /* - * We should only seek '-' of "-(...)" if: - * we saw "(...)" paren == TRUE - * we have no errors so far ! *err - * we did not see '+' of "(...)+" sign < 1 - * We don't check len. We want a specific error message later if - * user tries "x^...-(Rn)". This is a feature not a bug. - */ - if (!*err) - { - if (paren && sign < 1)/* !sign is adequate test */ - { - if (*q == '-') - { - sign = -1; - q--; - } - } - /* - * We have back-tracked over most - * of the crud at the end of an operand. - * Unless err, we know: sign, paren. If paren, we know reg. - * The last case is of an expression "Rn". - * This is worth hunting for if !err, !paren. - * We wouldn't be here if err. - * We remember to save q, in case we didn't want "Rn" anyway. - */ - if (!paren) - { - if (*q == ' ' && q >= p) /* Expect all whitespace reduced to ' '. */ - q--; - /* reverse over whitespace, but don't */ - /* run back over *p */ - if (q > p && q < p + 3) /* room for Rn or Rnn exactly? */ - reg = vax_reg_parse (p[0], p[1], q < p + 2 ? 0 : p[2]); - else - reg = -1; /* always comes here if no register at all */ - /* - * Here with a definitive reg value. - */ - if (reg >= 0) - { - oldq = q; - q = p - 1; - } - } - } - } - /* - * have reg. -1:absent; else 0:15 - */ - - /* - * We have: err, at, len, hash, ndx, sign, paren, reg. - * Also, any remaining expression is from *p through *q inclusive. - * Should there be no expression, q==p-1. So expression length = q-p+1. - * This completes the first part: parsing the operand text. - */ - - /* - * We now want to boil the data down, checking consistency on the way. - * We want: len, mode, reg, ndx, err, p, q, wrn, bug. - * We will deliver a 4-bit reg, and a 4-bit mode. - */ - - /* - * Case of branch operand. Different. No L^B^W^I^S^ allowed for instance. - * - * in: at ? - * len ? - * hash ? - * p:q ? - * sign ? - * paren ? - * reg ? - * ndx ? - * - * out: mode 0 - * reg -1 - * len ' ' - * p:q whatever was input - * ndx -1 - * err " " or error message, and other outputs trashed - */ - /* branch operands have restricted forms */ - if (!*err && access == 'b') - { - if (at || hash || sign || paren || ndx >= 0 || reg >= 0 || len != ' ') - err = "invalid branch operand"; - else - err = " "; - } - -/* Since nobody seems to use it: comment this 'feature'(?) out for now. */ -#ifdef NEVER - /* - * Case of stand-alone operand. e.g. ".long foo" - * - * in: at ? - * len ? - * hash ? - * p:q ? - * sign ? - * paren ? - * reg ? - * ndx ? - * - * out: mode 0 - * reg -1 - * len ' ' - * p:q whatever was input - * ndx -1 - * err " " or error message, and other outputs trashed - */ - if (!*err) - { - if (access == ' ') - { /* addresses have restricted forms */ - if (at) - err = "address prohibits @"; - else - { - if (hash) - err = "address prohibits #"; - else - { - if (sign) - { - if (sign < 0) - err = "address prohibits -()"; - else - err = "address prohibits ()+"; - } - else - { - if (paren) - err = "address prohibits ()"; - else - { - if (ndx >= 0) - err = "address prohibits []"; - else - { - if (reg >= 0) - err = "address prohibits register"; - else - { - if (len != ' ') - err = "address prohibits displacement length specifier"; - else - { - err = " "; /* succeed */ - mode = 0; - } - } - } - } - } - } - } - } - } -#endif /*#Ifdef NEVER*/ - - /* - * Case of S^#. - * - * in: at FALSE - * len 's' definition - * hash TRUE demand - * p:q demand not empty - * sign 0 by paren==FALSE - * paren FALSE by "()" scan logic because "S^" seen - * reg -1 or nn by mistake - * ndx -1 - * - * out: mode 0 - * reg -1 - * len 's' - * exp - * ndx -1 - */ - if (!*err && len == 's') - { - if (!hash || paren || at || ndx >= 0) - err = "invalid operand of S^#"; - else - { - if (reg >= 0) - { - /* - * SHIT! we saw S^#Rnn ! put the Rnn back in - * expression. KLUDGE! Use oldq so we don't - * need to know exact length of reg name. - */ - q = oldq; - reg = 0; - } - /* - * We have all the expression we will ever get. - */ - if (p > q) - err = "S^# needs expression"; - else if (access == 'r') - { - err = " "; /* WIN! */ - mode = 0; - } - else - err = "S^# may only read-access"; - } - } - - /* - * Case of -(Rn), which is weird case. - * - * in: at FALSE - * len ' - * hash FALSE - * p:q q

q) - { - at = TRUE; - paren = FALSE; - } - - /* - * Case of (Rn)+, which is slightly different. - * - * in: at - * len ' ' - * hash FALSE - * p:q q

0) - { - if (len != ' ' || hash || p <= q) - err = "invalid operand of ()+"; - else - { - err = " "; /* win */ - mode = 8 + (at ? 1 : 0); - if (reg == PC) - wrn = "(PC)+ unpredictable"; - else if (reg == ndx) - wrn = "[]index same as ()+register: unpredictable"; - } - } - - /* - * Case of #, without S^. - * - * in: at - * len ' ' or 'i' - * hash TRUE by definition - * p:q - * sign 0 - * paren FALSE - * reg absent - * ndx optional - * - * out: mode 8+@ - * reg PC - * len ' ' or 'i' - * exp - * ndx optional - */ - if (!*err && hash) - { - if (len != 'i' && len != ' ') - err = "# conflicts length"; - else if (paren) - err = "# bars register"; - else - { - if (reg >= 0) - { - /* - * SHIT! we saw #Rnn! Put the Rnn back into the expression. - * By using oldq, we don't need to know how long Rnn was. - * KLUDGE! - */ - q = oldq; - reg = -1; /* no register any more */ - } - err = " "; /* win */ - - /* JF a bugfix, I think! */ - if(at && access=='a') - vopP->vop_nbytes=4; - - mode = (at ? 9 : 8); - reg = PC; - if ((access == 'm' || access == 'w') && !at) - wrn = "writing or modifying # is unpredictable"; - } - } - /* - * If !*err, then sign == 0 - * hash == FALSE - */ - - /* - * Case of Rn. We seperate this one because it has a few special - * errors the remaining modes lack. - * - * in: at optional - * len ' ' - * hash FALSE by program logic - * p:q empty - * sign 0 by program logic - * paren FALSE by definition - * reg present by definition - * ndx optional - * - * out: mode 5+@ - * reg present - * len ' ' enforce no length - * exp "" enforce empty expression - * ndx optional warn if same as reg - */ - if (!*err && !paren && reg >= 0) - { - if (len != ' ') - err = "length not needed"; - else if (at) - { - err = " "; /* win */ - mode = 6; /* @Rn */ - } - else if (ndx >= 0) - err = "can't []index a register, because it has no address"; - else if (access == 'a') - err = "a register has no address"; - else - { - /* - * Idea here is to detect from length of datum - * and from register number if we will touch PC. - * Warn if we do. - * vop_nbytes is number of bytes in operand. - * Compute highest byte affected, compare to PC0. - */ - if ((vopP->vop_nbytes + reg * 4) > 60) - wrn = "PC part of operand unpredictable"; - err = " "; /* win */ - mode = 5; /* Rn */ - } - } - /* - * If !*err, sign == 0 - * hash == FALSE - * paren == TRUE OR reg==-1 - */ - - /* - * Rest of cases fit into one bunch. - * - * in: at optional - * len ' ' or 'b' or 'w' or 'l' - * hash FALSE by program logic - * p:q expected (empty is not an error) - * sign 0 by program logic - * paren optional - * reg optional - * ndx optional - * - * out: mode 10 + @ + len - * reg optional - * len ' ' or 'b' or 'w' or 'l' - * exp maybe empty - * ndx optional warn if same as reg - */ - if (!*err) - { - err = " "; /* win (always) */ - mode = 10 + (at ? 1 : 0); - switch (len) - { - case 'l': - mode += 2; - case 'w': - mode += 2; - case ' ': /* assumed B^ until our caller changes it */ - case 'b': - break; - } - } - - /* - * here with completely specified mode - * len - * reg - * expression p,q - * ndx - */ - - if (*err == ' ') - err = ""; /* " " is no longer an error */ - - vopP->vop_mode = mode; - vopP->vop_reg = reg; - vopP->vop_short = len; - vopP->vop_expr_begin = p; - vopP->vop_expr_end = q; - vopP->vop_ndx = ndx; - vopP->vop_error = err; - vopP->vop_warn = wrn; - return (bug); - -} /* vip_op() */ - -/* - -Summary of vip_op outputs. - - mode reg len ndx -(Rn) => @Rn -{@}Rn 5+@ n ' ' optional -branch operand 0 -1 ' ' -1 -S^#foo 0 -1 's' -1 --(Rn) 7 n ' ' optional -{@}(Rn)+ 8+@ n ' ' optional -{@}#foo, no S^ 8+@ PC " i" optional -{@}{q^}{(Rn)} 10+@+q option " bwl" optional - -*/ - -#ifdef TEST /* #Define to use this testbed. */ - -/* - * Follows a test program for this function. - * We declare arrays non-local in case some of our tiny-minded machines - * default to small stacks. Also, helps with some debuggers. - */ - -#include - -char answer[100]; /* human types into here */ -char *p; /* */ -char *myerr; -char *mywrn; -char *mybug; -char myaccess; -char mywidth; -char mymode; -char myreg; -char mylen; -char *myleft; -char *myright; -char myndx; -int my_operand_length; -char my_immediate[200]; -char my_indirect[200]; -char my_displen[200]; - -main () -{ - char *vip_op (); /* make cc happy */ - - printf ("enter immediate symbols eg enter # "); - gets (my_immediate); - printf ("enter indirect symbols eg enter @ "); - gets (my_indirect); - printf ("enter displen symbols eg enter ^ "); - gets (my_displen); - vip_op_defaults (my_immediate, my_indirect, my_displen); - for (;;) - { - printf ("access,width (eg 'ab' or 'wh') [empty line to quit] : "); - fflush (stdout); - gets (answer); - if (!answer[0]) - exit (0); - myaccess = answer[0]; - mywidth = answer[1]; - switch (mywidth) - { - case 'b': - my_operand_length = 1; - break; - case 'd': - my_operand_length = 8; - break; - case 'f': - my_operand_length = 4; - break; - case 'g': - my_operand_length = 16; - break; - case 'h': - my_operand_length = 32; - break; - case 'l': - my_operand_length = 4; - break; - case 'o': - my_operand_length = 16; - break; - case 'q': - my_operand_length = 8; - break; - case 'w': - my_operand_length = 2; - break; - case '!': - case '?': - case '-': - my_operand_length = 0; - break; - - default: - my_operand_length = 2; - printf ("I dn't understand access width %c\n", mywidth); - break; - } - printf ("VAX assembler instruction operand: "); - fflush (stdout); - gets (answer); - mybug = vip_op (answer, myaccess, mywidth, my_operand_length, - &mymode, &myreg, &mylen, &myleft, &myright, &myndx, - &myerr, &mywrn); - if (*myerr) - { - printf ("error: \"%s\"\n", myerr); - if (*mybug) - printf (" bug: \"%s\"\n", mybug); - } - else - { - if (*mywrn) - printf ("warning: \"%s\"\n", mywrn); - mumble ("mode", mymode); - mumble ("register", myreg); - mumble ("index", myndx); - printf ("width:'%c' ", mylen); - printf ("expression: \""); - while (myleft <= myright) - putchar (*myleft++); - printf ("\"\n"); - } - } -} - -mumble (text, value) - char *text; - int value; -{ - printf ("%s:", text); - if (value >= 0) - printf ("%xx", value); - else - printf ("ABSENT"); - printf (" "); -} - -#endif /* ifdef TEST */ - -/* end: vip_op.c */ - -const int md_short_jump_size = 3; -const int md_long_jump_size = 6; -const int md_reloc_size = 8; /* Size of relocation record */ - -void -md_create_short_jump (ptr, from_addr, to_addr, frag, to_symbol) - char *ptr; - long from_addr, to_addr; - fragS *frag; - symbolS *to_symbol; -{ - long offset; - - offset = to_addr - (from_addr + 1); - *ptr++ = 0x31; - md_number_to_chars (ptr, offset, 2); -} - -void -md_create_long_jump (ptr, from_addr, to_addr, frag, to_symbol) - char *ptr; - long from_addr, to_addr; - fragS *frag; - symbolS *to_symbol; -{ - long offset; - - offset = to_addr - to_symbol->sy_value; - *ptr++ = 0x17; - *ptr++ = 0x9F; - md_number_to_chars (ptr, offset, 4); - fix_new (frag, ptr - frag->fr_literal, 4, to_symbol, (symbolS *) 0, (long) 0, 0); -} - -int -md_parse_option (argP, cntP, vecP) - char **argP; - int *cntP; - char ***vecP; -{ - char *temp_name; /* name for -t or -d options */ - char opt; - - switch (**argP) - { - case 'J': - /* as_warn ("I can do better than -J!"); */ - break; - - case 'S': - as_warn ("SYMBOL TABLE not implemented"); - break; /* SYMBOL TABLE not implemented */ - - case 'T': - as_warn ("TOKEN TRACE not implemented"); - break; /* TOKEN TRACE not implemented */ - - case 'd': - case 't': - opt= **argP; - if (**argP) - { /* Rest of argument is filename. */ - temp_name = *argP; - while (**argP) - (*argP)++; - } - else if (*cntP) - { - while (**argP) - (*argP)++; - --(*cntP); - temp_name = *++(*vecP); - **vecP = NULL; /* Remember this is not a file-name. */ - } - else - { - as_warn ("I expected a filename after -%c.",opt); - temp_name = "{absent}"; - } - - if(opt=='d') - as_warn ("Displacement length %s ignored!", temp_name); - else - as_warn ("I don't need or use temp. file \"%s\".", temp_name); - break; - - case 'V': - as_warn ("I don't use an interpass file! -V ignored"); - break; - -#ifdef VMS - case '+': /* For g++ */ - break; - - case 'h': /* No hashing of mixed-case names */ - break; - - case 'H': /* Show new symbol after hash truncation */ - break; -#endif - - default: - return 0; - - } - return 1; -} - -/* We have no need to default values of symbols. */ - -/* ARGSUSED */ -symbolS * -md_undefined_symbol (name) - char *name; -{ - return 0; -} - -/* Parse an operand that is machine-specific. - We just return without modifying the expression if we have nothing - to do. */ - -/* ARGSUSED */ -void -md_operand (expressionP) - expressionS *expressionP; -{ -} - -/* Round up a section size to the appropriate boundary. */ -long -md_section_align (segment, size) - segT segment; - long size; -{ - return size; /* Byte alignment is fine */ -} - -/* Exactly what point is a PC-relative offset relative TO? - On the vax, they're relative to the address of the offset, plus - its size. (??? Is this right? FIXME-SOON) */ -long -md_pcrel_from (fixP) - fixS *fixP; -{ - return fixP->fx_size + fixP->fx_where + fixP->fx_frag->fr_address; -} diff --git a/gas/config/tc-vax.h b/gas/config/tc-vax.h deleted file mode 100644 index 00977826649..00000000000 --- a/gas/config/tc-vax.h +++ /dev/null @@ -1,14 +0,0 @@ -/* - * This file is tc-vax.h. - */ - -#define TC_VAX 1 - -/* - * Local Variables: - * comment-column: 0 - * fill-column: 131 - * End: - */ - -/* end of tc-vax.h */ diff --git a/gas/config/te-dpx2.h b/gas/config/te-dpx2.h deleted file mode 100644 index 52e17eb2070..00000000000 --- a/gas/config/te-dpx2.h +++ /dev/null @@ -1,7 +0,0 @@ -/* Machine specific defines for the dpx2 machine */ -#define dpx2 -#define TC_M68K - -/* The magic number is not the usual MC68MAGIC. */ -#define FILE_HEADER_MAGIC MC68KBCSMAGIC - diff --git a/gas/config/te-generic.h b/gas/config/te-generic.h deleted file mode 100644 index 4b40d61409e..00000000000 --- a/gas/config/te-generic.h +++ /dev/null @@ -1,18 +0,0 @@ -/* - * This file is te-generic.h and is intended to be a template for - * target environment specific header files. - */ - -#define TE_GENERIC 1 - - /* these define interfaces */ -#include "obj-format.h" - -/* - * Local Variables: - * comment-column: 0 - * fill-column: 131 - * End: - */ - -/* end of te-generic.h */ diff --git a/gas/config/te-ic960.h b/gas/config/te-ic960.h deleted file mode 100644 index 165a780d41d..00000000000 --- a/gas/config/te-ic960.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * This file is te-ic960.h and is intended to define ic960 environment - * specific differences. - */ - -/* $Id$ */ - -#define TE_IC960 1 - - /* intel uses host byte order for headers */ -#ifdef CROSS_COMPILE -#undef CROSS_COMPILE -#endif /* CROSS_COMPILE */ - -#define OBJ_COFF_OMIT_OPTIONAL_HEADER -#define LOCAL_LABEL(name) ( (name[0] =='L') \ - || (name[0] =='.' \ - && (name[1]=='C' || name[1]=='I' || name[1]=='.'))) -#include "obj-format.h" - -/* - * Local Variables: - * comment-column: 0 - * fill-column: 131 - * End: - */ - -/* end of te-ic960.h */ diff --git a/gas/config/te-motor.h b/gas/config/te-motor.h deleted file mode 100755 index 22548416bfd..00000000000 --- a/gas/config/te-motor.h +++ /dev/null @@ -1,4 +0,0 @@ -/* Machine specific defines for the unisoft 680x0 V.3.2 version 1.3 */ - -/* Remove leading underscore from the gcc generated symbol names */ -#define STRIP_UNDERSCORE 1 diff --git a/gas/config/te-sco386.h b/gas/config/te-sco386.h deleted file mode 100644 index 8b38cd46f69..00000000000 --- a/gas/config/te-sco386.h +++ /dev/null @@ -1,5 +0,0 @@ -/* Machine specific defines for the SCO Unix V.3.2 ODT */ -#define scounix - -/* Return true if s (a non null string pointer), points to a local variable name. */ -#define LOCAL_LABEL(n) ((n)[0] == '.' && (n)[1] == 'L') diff --git a/gas/config/te-sparc.h b/gas/config/te-sparc.h deleted file mode 100755 index c1a374392b4..00000000000 --- a/gas/config/te-sparc.h +++ /dev/null @@ -1,52 +0,0 @@ -/* sparc.h -- Header file for the SPARC - Copyright (C) 1989 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - * The following enum and struct were borrowed from - * sunOS /usr/include/sun4/a.out.h - * - */ - -enum reloc_type -{ - RELOC_8, RELOC_16, RELOC_32, RELOC_DISP8, - RELOC_DISP16, RELOC_DISP32, RELOC_WDISP30, RELOC_WDISP22, - RELOC_HI22, RELOC_22, RELOC_13, RELOC_LO10, - RELOC_SFA_BASE, RELOC_SFA_OFF13, RELOC_BASE10, RELOC_BASE13, - RELOC_BASE22, RELOC_PC10, RELOC_PC22, RELOC_JMP_TBL, - RELOC_SEGOFF16, RELOC_GLOB_DAT, RELOC_JMP_SLOT, RELOC_RELATIVE, - - NO_RELOC -}; - -struct reloc_info_sparc -{ - unsigned long r_address; -/* - * Using bit fields here is a bad idea because the order is not portable. :-( - */ - unsigned int r_index : 24; - unsigned int r_extern : 1; - unsigned int unused : 2; - enum reloc_type r_type : 5; - long r_addend; -}; - -#define relocation_info reloc_info_sparc - diff --git a/gas/config/te-sun3.h b/gas/config/te-sun3.h deleted file mode 100644 index 9d1ece4c2b9..00000000000 --- a/gas/config/te-sun3.h +++ /dev/null @@ -1,48 +0,0 @@ -/* te-sun3.h -- Sun-3 target environment declarations. - Copyright (C) 1987, 1990, 1991 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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 1, or (at your option) -any later version. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* $Id$ */ - -/* This header file contains the #defines specific - to SUN computer SUN 3 series computers. (The only kind - we have around here, unfortunatly.) - - Rumor has it that this file will work on the Sun-2 if the assembler - is called with -m68010 This is not tested. */ - - -#define TE_SUN3 1 -#define SUN_ASM_SYNTAX - -/* Could also be : -#define S_LOCAL_NAME(s) (S_GET_NAME(s)[0] == '.' && - S_GET_NAME(s)[1] == 'L' || - S_GET_NAME(s)[1] == '.') -*/ - -#include "obj-format.h" - -/* - * Local Variables: - * comment-column: 0 - * fill-column: 131 - * End: - */ - -/* end of te-sun3.h */ diff --git a/gas/config/te-sysv32.h b/gas/config/te-sysv32.h deleted file mode 100644 index a97f986544a..00000000000 --- a/gas/config/te-sysv32.h +++ /dev/null @@ -1,2 +0,0 @@ -/* Remove leading underscore from the gcc generated symbol names */ -#define STRIP_UNDERSCORE diff --git a/gas/config/te-unisoft.h b/gas/config/te-unisoft.h deleted file mode 100755 index 22548416bfd..00000000000 --- a/gas/config/te-unisoft.h +++ /dev/null @@ -1,4 +0,0 @@ -/* Machine specific defines for the unisoft 680x0 V.3.2 version 1.3 */ - -/* Remove leading underscore from the gcc generated symbol names */ -#define STRIP_UNDERSCORE 1 diff --git a/gas/config/tmake-sun3 b/gas/config/tmake-sun3 deleted file mode 100755 index 9681e6db874..00000000000 --- a/gas/config/tmake-sun3 +++ /dev/null @@ -1 +0,0 @@ -# This line from make-sun3. diff --git a/gas/config/vax-inst.h b/gas/config/vax-inst.h deleted file mode 100644 index 51b7c940620..00000000000 --- a/gas/config/vax-inst.h +++ /dev/null @@ -1,77 +0,0 @@ -/* vax-inst.h - GNU - Part of vax.c - Copyright (C) 1987 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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 1, or (at your option) -any later version. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - * This is part of vax-ins-parse.c & friends. - * We want to parse a vax instruction text into a tree defined here. - */ - -#define VIT_MAX_OPERANDS (6) /* maximum number of operands in one */ - /* single vax instruction */ - -struct vop /* vax instruction operand */ -{ - short int vop_ndx; /* -1, or index register. eg 7=[R7] */ - short int vop_reg; /* -1, or register number. eg @I^#=0xF */ - /* Helps distinguish "abs" from "abs(PC)". */ - short int vop_mode; /* addressing mode 4 bits. eg I^#=0x9 */ - char vop_short; /* operand displacement length as written */ - /* ' '=none, "bilsw"=B^I^L^S^W^. */ - char vop_access; /* 'b'branch ' 'no-instruction 'amrvw'norm */ - char vop_width; /* Operand width, one of "bdfghloqw" */ - char * vop_warn; /* warning message of this operand, if any */ - char * vop_error; /* say if operand is inappropriate */ - char * vop_expr_begin; /* Unparsed expression, 1st char ... */ - char * vop_expr_end; /* ... last char. */ - unsigned char vop_nbytes; /* number of bytes in datum */ -}; - - -typedef long vax_opcodeT; /* For initialising array of opcodes */ - /* Some synthetic opcodes > 16 bits! */ - -#define VIT_OPCODE_SYNTHETIC 0x80000000 /* Not real hardware instruction. */ -#define VIT_OPCODE_SPECIAL 0x40000000 /* Not normal branch optimising. */ - /* Never set without ..._SYNTHETIC */ - -#define VAX_WIDTH_UNCONDITIONAL_JUMP '-' /* These are encoded into */ -#define VAX_WIDTH_CONDITIONAL_JUMP '?' /* vop_width when vop_access=='b' */ -#define VAX_WIDTH_WORD_JUMP '!' /* and VIT_OPCODE_SYNTHETIC set. */ -#define VAX_WIDTH_BYTE_JUMP ':' /* */ - -#define VAX_JMP (0x17) /* Useful for branch optimising. Jump instr*/ -#define VAX_PC_RELATIVE_MODE (0xef) /* Use it after VAX_JMP */ -#define VAX_ABSOLUTE_MODE (0x9F) /* Use as @#... */ -#define VAX_BRB (0x11) /* Canonical branch. */ -#define VAX_BRW (0x31) /* Another canonical branch */ -#define VAX_WIDEN_WORD (0x20) /* Add this to byte branch to get word br. */ -#define VAX_WIDEN_LONG (0x6) /* Add this to byte branch to get long jmp.*/ - /* Needs VAX_PC_RELATIVE_MODE byte after it*/ - -struct vit /* vax instruction tree */ -{ - /* vit_opcode is char[] for portability. */ - char vit_opcode [ sizeof (vax_opcodeT) ]; - unsigned char vit_opcode_nbytes; /* How long is _opcode? (chars) */ - unsigned char vit_operands;/* */ - struct vop vit_operand[VIT_MAX_OPERANDS]; /* operands */ - char * vit_error; /* "" or error text */ -}; - -/* end: vax-inst.h */ diff --git a/gas/config/vms/.Sanitize b/gas/config/vms/.Sanitize deleted file mode 100644 index 116a0ebd96c..00000000000 --- a/gas/config/vms/.Sanitize +++ /dev/null @@ -1,53 +0,0 @@ -# Sanitize.in for devo. -# $Id$ -# - -# Each directory to survive it's way into a release will need a file -# like this one called "./.Sanitize". All keyword lines must exist, -# and must exist in the order specified by this file. Each directory -# in the tree will be processed, top down, in the following order. - -# Hash started lines like this one are comments and will be deleted -# before anything else is done. Blank lines will also be squashed -# out. - -# The lines between the "Do-first:" line and the "Things-to-keep:" -# line are executed as a /bin/sh shell script before anything else is -# done in this - -Do-first: - -echo Sanitizing `pwd`... - -# All files listed between the "Things-to-keep:" line and the -# "Files-to-sed:" line will be kept. All other files will be removed. -# Directories listed in this section will have their own Sanitize -# called. Directories not listed will be removed in their entirety -# with rm -rf. - -Things-to-keep: - -objrecdef.h -vms-dbg.c -vms.c - -Do-last: - -echo Done in `pwd`. - -# -# -# $Log$ -# Revision 1.2 1991/05/23 17:11:51 rich -# No tc-sparc.c here. -# -# Revision 1.1 1991/05/23 17:10:40 rich -# Initial revision -# -# Revision 1.1 1991/05/23 17:09:03 rich -# Initial revision -# -# -# - -# End of file. diff --git a/gas/config/vms/objrecdef.h b/gas/config/vms/objrecdef.h deleted file mode 100644 index fca8af40f56..00000000000 --- a/gas/config/vms/objrecdef.h +++ /dev/null @@ -1,255 +0,0 @@ -/* - * - * $OBJRECDEF - * Generated automatically by "vms_struct Version 1.00" - * Created from VMS definition file "objrecdef.mar" - * Mon Oct 14 14:01:29 1985 - * - */ -struct OBJREC { - unsigned char obj$b_rectyp; - unsigned char obj$b_subtyp; - unsigned char obj$b_mhd_strlv; - unsigned char obj$b_mhd_recsz[2]; - unsigned char obj$t_mhd_name[1]; - }; - -#define OBJ$C_HDR 0 -#define OBJ$C_HDR_MHD 0 -#define OBJ$C_HDR_LNM 1 -#define OBJ$C_HDR_SRC 2 -#define OBJ$C_HDR_TTL 3 -#define OBJ$C_HDR_CPR 4 -#define OBJ$C_HDR_MTC 5 -#define OBJ$C_HDR_GTX 6 -#define OBJ$C_GSD 1 -#define OBJ$C_GSD_PSC 0 -#define OBJ$C_GSD_SYM 1 -#define OBJ$C_GSD_EPM 2 -#define OBJ$C_GSD_PRO 3 -#define OBJ$C_GSD_SYMW 4 -#define OBJ$C_GSD_EPMW 5 -#define OBJ$C_GSD_PROW 6 -#define OBJ$C_GSD_IDC 7 -#define OBJ$C_GSD_ENV 8 -#define OBJ$C_GSD_LSY 9 -#define OBJ$C_GSD_LEPM 10 -#define OBJ$C_GSD_LPRO 11 -#define OBJ$C_GSD_SPSC 12 -#define OBJ$C_TIR 2 -#define OBJ$C_EOM 3 -#define OBJ$C_DBG 4 -#define OBJ$C_TBT 5 -#define OBJ$C_LNK 6 -#define OBJ$C_EOMW 7 -#define OBJ$C_MAXRECTYP 7 -#define OBJ$K_SUBTYP 1 -#define OBJ$C_SUBTYP 1 -#define OBJ$C_MAXRECSIZ 2048 -#define OBJ$C_STRLVL 0 -#define OBJ$C_SYMSIZ 31 -#define OBJ$C_STOREPLIM -1 -#define OBJ$C_PSCALILIM 9 - -#define MHD$C_MHD 0 -#define MHD$C_LNM 1 -#define MHD$C_SRC 2 -#define MHD$C_TTL 3 -#define MHD$C_CPR 4 -#define MHD$C_MTC 5 -#define MHD$C_GTX 6 -#define MHD$C_MAXHDRTYP 6 - -#define GSD$K_ENTRIES 1 -#define GSD$C_ENTRIES 1 -#define GSD$C_PSC 0 -#define GSD$C_SYM 1 -#define GSD$C_EPM 2 -#define GSD$C_PRO 3 -#define GSD$C_SYMW 4 -#define GSD$C_EPMW 5 -#define GSD$C_PROW 6 -#define GSD$C_IDC 7 -#define GSD$C_ENV 8 -#define GSD$C_LSY 9 -#define GSD$C_LEPM 10 -#define GSD$C_LPRO 11 -#define GSD$C_SPSC 12 -#define GSD$C_SYMV 13 -#define GSD$C_EPMV 14 -#define GSD$C_PROV 15 -#define GSD$C_MAXRECTYP 15 - -#define GSY$M_WEAK 1 -#define GSY$M_DEF 2 -#define GSY$M_UNI 4 -#define GSY$M_REL 8 - -#define GPS$M_PIC 1 -#define GPS$M_LIB 2 -#define GPS$M_OVR 4 -#define GPS$M_REL 8 -#define GPS$M_GBL 16 -#define GPS$M_SHR 32 -#define GPS$M_EXE 64 -#define GPS$M_RD 128 -#define GPS$M_WRT 256 -#define GPS$M_VEC 512 -#define GPS$K_NAME 9 -#define GPS$C_NAME 9 - -#define TIR$C_STA_GBL 0 -#define TIR$C_STA_SB 1 -#define TIR$C_STA_SW 2 -#define TIR$C_STA_LW 3 -#define TIR$C_STA_PB 4 -#define TIR$C_STA_PW 5 -#define TIR$C_STA_PL 6 -#define TIR$C_STA_UB 7 -#define TIR$C_STA_UW 8 -#define TIR$C_STA_BFI 9 -#define TIR$C_STA_WFI 10 -#define TIR$C_STA_LFI 11 -#define TIR$C_STA_EPM 12 -#define TIR$C_STA_CKARG 13 -#define TIR$C_STA_WPB 14 -#define TIR$C_STA_WPW 15 -#define TIR$C_STA_WPL 16 -#define TIR$C_STA_LSY 17 -#define TIR$C_STA_LIT 18 -#define TIR$C_STA_LEPM 19 -#define TIR$C_MAXSTACOD 19 -#define TIR$C_MINSTOCOD 20 -#define TIR$C_STO_SB 20 -#define TIR$C_STO_SW 21 -#define TIR$C_STO_L 22 -#define TIR$C_STO_BD 23 -#define TIR$C_STO_WD 24 -#define TIR$C_STO_LD 25 -#define TIR$C_STO_LI 26 -#define TIR$C_STO_PIDR 27 -#define TIR$C_STO_PICR 28 -#define TIR$C_STO_RSB 29 -#define TIR$C_STO_RSW 30 -#define TIR$C_STO_RL 31 -#define TIR$C_STO_VPS 32 -#define TIR$C_STO_USB 33 -#define TIR$C_STO_USW 34 -#define TIR$C_STO_RUB 35 -#define TIR$C_STO_RUW 36 -#define TIR$C_STO_B 37 -#define TIR$C_STO_W 38 -#define TIR$C_STO_RB 39 -#define TIR$C_STO_RW 40 -#define TIR$C_STO_RIVB 41 -#define TIR$C_STO_PIRR 42 -#define TIR$C_MAXSTOCOD 42 -#define TIR$C_MINOPRCOD 50 -#define TIR$C_OPR_NOP 50 -#define TIR$C_OPR_ADD 51 -#define TIR$C_OPR_SUB 52 -#define TIR$C_OPR_MUL 53 -#define TIR$C_OPR_DIV 54 -#define TIR$C_OPR_AND 55 -#define TIR$C_OPR_IOR 56 -#define TIR$C_OPR_EOR 57 -#define TIR$C_OPR_NEG 58 -#define TIR$C_OPR_COM 59 -#define TIR$C_OPR_INSV 60 -#define TIR$C_OPR_ASH 61 -#define TIR$C_OPR_USH 62 -#define TIR$C_OPR_ROT 63 -#define TIR$C_OPR_SEL 64 -#define TIR$C_OPR_REDEF 65 -#define TIR$C_OPR_DFLIT 66 -#define TIR$C_MAXOPRCOD 66 -#define TIR$C_MINCTLCOD 80 -#define TIR$C_CTL_SETRB 80 -#define TIR$C_CTL_AUGRB 81 -#define TIR$C_CTL_DFLOC 82 -#define TIR$C_CTL_STLOC 83 -#define TIR$C_CTL_STKDL 84 -#define TIR$C_MAXCTLCOD 84 - -/* - * Debugger symbol definitions: These are done by hand, as no - * machine-readable version seems - * to be available. - */ -#define DST$C_C 7 /* Language == "C" */ -#define DST$C_VERSION 153 -#define DST$C_SOURCE 155 /* Source file */ -#define DST$C_PROLOG 162 -#define DST$C_BLKBEG 176 /* Beginning of block */ -#define DST$C_BLKEND 177 /* End of block */ -#define DST$C_ENTRY 181 -#define DST$C_PSECT 184 -#define DST$C_LINE_NUM 185 /* Line Number */ -#define DST$C_LBLORLIT 186 -#define DST$C_LABEL 187 -#define DST$C_MODBEG 188 /* Beginning of module */ -#define DST$C_MODEND 189 /* End of module */ -#define DST$C_RTNBEG 190 /* Beginning of routine */ -#define DST$C_RTNEND 191 /* End of routine */ -#define DST$C_DELTA_PC_W 1 /* Incr PC */ -#define DST$C_INCR_LINUM 2 /* Incr Line # */ -#define DST$C_INCR_LINUM_W 3 /* Incr Line # */ -#define DST$C_SET_LINUM_INCR 4 -#define DST$C_SET_LINUM_INCR_W 5 -#define DST$C_RESET_LINUM_INCR 6 -#define DST$C_BEG_STMT_MODE 7 -#define DST$C_END_STMT_MODE 8 -#define DST$C_SET_LINE_NUM 9 /* Set Line # */ -#define DST$C_SET_PC 10 -#define DST$C_SET_PC_W 11 -#define DST$C_SET_PC_L 12 -#define DST$C_SET_STMTNUM 13 -#define DST$C_TERM 14 /* End of lines */ -#define DST$C_TERM_W 15 /* End of lines */ -#define DST$C_SET_ABS_PC 16 /* Set PC */ -#define DST$C_DELTA_PC_L 17 /* Incr PC */ -#define DST$C_INCR_LINUM_L 18 /* Incr Line # */ -#define DST$C_SET_LINUM_B 19 /* Set Line # */ -#define DST$C_SET_LINUM_L 20 /* Set Line # */ -#define DST$C_TERM_L 21 /* End of lines */ -/* these are used with DST$C_SOURCE */ -#define DST$C_SRC_FORMFEED 16 /* ^L counts */ -#define DST$C_SRC_DECLFILE 1 /* Declare file */ -#define DST$C_SRC_SETFILE 2 /* Set file */ -#define DST$C_SRC_SETREC_L 3 /* Set record */ -#define DST$C_SRC_DEFLINES_W 10 /* # of line */ -/* the following are the codes for the various data types. Anything not on - * the list is included under 'advanced_type' - */ -#define DBG$C_UCHAR 0x02 -#define DBG$C_USINT 0x03 -#define DBG$C_ULINT 0x04 -#define DBG$C_SCHAR 0x06 -#define DBG$C_SSINT 0x07 -#define DBG$C_SLINT 0x08 -#define DBG$C_REAL4 0x0a -#define DBG$C_REAL8 0x0b -#define DBG$C_FUNCTION_ADDR 0x17 -#define DBG$C_ADVANCED_TYPE 0xa3 -/* These are the codes that are used to generate the definitions of struct - * union and enum records - */ -#define DBG$C_ENUM_ITEM 0xa4 -#define DBG$C_ENUM_START 0xa5 -#define DBG$C_ENUM_END 0xa6 -#define DBG$C_STRUCT_START 0xab -#define DBG$C_STRUCT_ITEM 0xff -#define DBG$C_STRUCT_END 0xac -/* These are the codes that are used in the suffix records to determine the - * actual data type - */ -#define DBG$C_BASIC 0x01 -#define DBG$C_BASIC_ARRAY 0x02 -#define DBG$C_STRUCT 0x03 -#define DBG$C_POINTER 0x04 -#define DBG$C_VOID 0x05 -#define DBG$C_COMPLEX_ARRAY 0x07 -/* These codes are used in the generation of the symbol definition records - */ -#define DBG$C_FUNCTION_PARAMETER 0xc9 -#define DBG$C_LOCAL_SYM 0xd9 diff --git a/gas/config/vms/vms-dbg.c b/gas/config/vms/vms-dbg.c deleted file mode 100644 index 19c6c93f28f..00000000000 --- a/gas/config/vms/vms-dbg.c +++ /dev/null @@ -1,1125 +0,0 @@ -#include -#include "as.h" -#include "struc-symbol.h" -#include "symbols.h" -#include "objrecdef.h" -#include - -/* This file contains many of the routines needed to output debugging info into - * the object file that the VMS debugger needs to understand symbols. These - * routines are called very late in the assembly process, and thus we can be - * fairly lax about changing things, since the GSD and the TIR sections have - * already been output. - */ - -/* We need this info to cross correlate between the stabs def for a symbol and - * the actual symbol def. The actual symbol def contains the psect number and - * offset, which is needed to declare a variable to the debugger for global - * and static variables - */ -struct VMS_Symbol { - struct VMS_Symbol *Next; - struct symbol *Symbol; - int Size; - int Psect_Index; - int Psect_Offset; - }; -extern struct VMS_Symbol *VMS_Symbols; - -enum advanced_type {BASIC,POINTER,ARRAY,ENUM,STRUCT,UNION,FUNCTION,VOID,UNKNOWN}; - -/* this structure contains the information from the stabs directives, and the - * information is filled in by VMS_typedef_parse. Everything that is needed - * to generate the debugging record for a given symbol is present here. - * This could be done more efficiently, using nested struct/unions, but for now - * I am happy that it works. - */ -struct VMS_DBG_Symbol{ - struct VMS_DBG_Symbol * next; - enum advanced_type advanced; /* description of what this is */ - int dbx_type; /* this record is for this type */ - int type2; /* For advanced types this is the type referred to. - i.e. the type a pointer points to, or the type - of object that makes up an array */ - int VMS_type; /* Use this type when generating a variable def */ - int index_min; /* used for arrays - this will be present for all */ - int index_max; /* entries, but will be meaningless for non-arrays */ - int data_size; /* size in bytes of the data type. For an array, this - is the size of one element in the array */ - int struc_numb; /* Number of the structure/union/enum - used for ref */ -}; - -struct VMS_DBG_Symbol *VMS_Symbol_type_list={(struct VMS_DBG_Symbol*) NULL}; - -/* we need this structure to keep track of forward references to - * struct/union/enum that have not been defined yet. When they are ultimately - * defined, then we can go back and generate the TIR commands to make a back - * reference. - */ - -struct forward_ref{ - struct forward_ref * next; - int dbx_type; - int struc_numb; - char resolved; - }; - -struct forward_ref * f_ref_root={(struct forward_ref*) NULL}; - -static char * symbol_name; -static structure_count=0; - -/* this routine converts a number string into an integer, and stops when it - * sees an invalid character the return value is the address of the character - * just past the last character read. No error is generated. - */ -static char * cvt_integer(char* str,int * rtn){ - int ival, neg; - neg = *str == '-' ? ++str, -1 : 1; - ival=0; /* first get the number of the type for dbx */ - while((*str <= '9') && (*str >= '0')) - ival = 10*ival + *str++ -'0'; - *rtn = neg*ival; - return str; -} - -/* this routine fixes the names that are generated by C++, ".this" is a good - * example. The period does not work for the debugger, since it looks like - * the syntax for a structure element, and thus it gets mightily confused - */ -static fix_name(char* pnt){ - for( ;*pnt != 0; pnt++){ - if(*pnt == '.') *pnt = '$'; - }; -} - -/* this routine is used to compare the names of certain types to various - * fixed types that are known by the debugger. - */ -#define type_check(x) !strcmp( symbol_name , x ) - -/* When defining a structure, this routine is called to find the name of - * the actual structure. It is assumed that str points to the equal sign - * in the definition, and it moves backward until it finds the start of the - * name. If it finds a 0, then it knows that this structure def is in the - * outermost level, and thus symbol_name points to the symbol name. - */ -static char* get_struct_name(char* str){ - char* pnt; - pnt=str; - while((*pnt != ':') && (*pnt != '\0')) pnt--; - if(*pnt == '\0') return symbol_name; - *pnt-- = '\0'; - while((*pnt != ';') && (*pnt != '=')) pnt--; - if(*pnt == ';') return pnt+1; - while((*pnt < '0') || (*pnt > '9')) pnt++; - while((*pnt >= '0') && (*pnt <= '9')) pnt++; - return pnt; -} -/* search symbol list for type number dbx_type. Return a pointer to struct */ -static struct VMS_DBG_Symbol* find_symbol(int dbx_type){ - struct VMS_DBG_Symbol* spnt; - spnt=VMS_Symbol_type_list; - while (spnt!=(struct VMS_DBG_Symbol*) NULL){ - if(spnt->dbx_type==dbx_type) break; - spnt=spnt->next;}; - if(spnt==(struct VMS_DBG_Symbol*) NULL) return 0;/*Dunno what this is*/ - return spnt; -} - - -/* Many good programmers cringe when they see a fixed size array - since I am - * using this to generate the various descriptors for the data types present, - * you might argue that the descriptor could overflow the array for a - * complicated variable, and then I am in deep doo-doo. My answer to this is - * that the debugger records that we write have all sorts of length bytes - * stored in them all over the place, and if we exceed 127 bytes (since the top - * bit indicates data, rather than a command), we are dead anyhow. So I figure - * why not do this the easy way. Besides, to get 128 bytes, you need something - * like an array with 10 indicies, or something like - * char **************************************** var; - * Lets get real. If some idiot writes programs like that he/she gets what - * they deserve. (It is possible to overflow the record with a somewhat - * simpler example, like: int (*(*(*(*(*(* sarr6)[1])[1])[2])[3])[4])[5]; - * but still...). And if someone in the peanut gallery wants to know "What - * does VAX-C do with something like this?", I will tell you. It crashes. - * At least this code has the good sense to convert it to *void. - * In practice, I do not think that this presents too much of a problem, since - * struct/union/enum all use defined types, which sort of terminate the - * definition. It occurs to me that we could possibly do the same thing with - * arrays and pointers, but I don't know quite how it would be coded. - * - * And now back to the regularly scheduled program... - */ -#define MAX_DEBUG_RECORD 128 -static char Local[MAX_DEBUG_RECORD]; /* buffer for variable descriptor */ -static int Lpnt; /* index into Local */ -static char Asuffix[MAX_DEBUG_RECORD]; /* buffer for array descriptor */ -static int Apoint; /* index into Asuffix */ -static char overflow; /* flag to indicate we have written too much*/ -static int total_len; /* used to calculate the total length of variable - descriptor plus array descriptor - used for len byte*/ -static int struct_number; /* counter used to assign indexes to struct - unions and enums */ - -/* this routine puts info into either Local or Asuffix, depending on the sign - * of size. The reason is that it is easier to build the variable descriptor - * backwards, while the array descriptor is best built forwards. In the end - * they get put together, if there is not a struct/union/enum along the way - */ -push(int value, int size){ - char * pnt; - int i; - int size1; - long int val; - val=value; - pnt=(char*) &val; - size1 = size; - if (size < 0) {size1 = -size; pnt += size1-1;}; - if(size < 0) - for(i=0;i= MAX_DEBUG_RECORD) - {overflow = 1; Apoint =MAX_DEBUG_RECORD-1;};} -} - -/* this routine generates the array descriptor for a given array */ -static array_suffix(struct VMS_DBG_Symbol* spnt2){ - struct VMS_DBG_Symbol * spnt; - struct VMS_DBG_Symbol * spnt1; - int rank; - int total_size; - int i; - rank=0; - spnt=spnt2; - while(spnt->advanced != ARRAY) { - spnt=find_symbol(spnt->type2); - if(spnt == (struct VMS_DBG_Symbol *) NULL) return;}; - spnt1=spnt; - spnt1=spnt; - total_size= 1; - while(spnt1->advanced == ARRAY) {rank++; - total_size *= (spnt1->index_max - spnt1->index_min +1); - spnt1=find_symbol(spnt1->type2);}; - total_size = total_size * spnt1->data_size; - push(spnt1->data_size,2); - if(spnt1->VMS_type == 0xa3) push(0,1); - else push(spnt1->VMS_type,1); - push(4,1); - for(i=0;i<6;i++) push(0,1); - push(0xc0,1); - push(rank,1); - push(total_size,4); - push(0,4); - spnt1=spnt; - while(spnt1->advanced == ARRAY) { - push(spnt1->index_max - spnt1->index_min+1,4); - spnt1=find_symbol(spnt1->type2);}; - spnt1=spnt; - while(spnt1->advanced == ARRAY) { - push(spnt1->index_min,4); - push(spnt1->index_max,4); - spnt1=find_symbol(spnt1->type2);}; -} - -/* this routine generates the start of a variable descriptor based upon - * a struct/union/enum that has yet to be defined. We define this spot as - * a new location, and save four bytes for the address. When the struct is - * finally defined, then we can go back and plug in the correct address -*/ -static new_forward_ref(int dbx_type){ - struct forward_ref* fpnt; - fpnt = (struct forward_ref*) malloc(sizeof(struct forward_ref)); - fpnt->next = f_ref_root; - f_ref_root = fpnt; - fpnt->dbx_type = dbx_type; - fpnt->struc_numb = ++structure_count; - fpnt->resolved = 'N'; - push(3,-1); - total_len = 5; - push(total_len,-2); - struct_number = - fpnt->struc_numb; -} - -/* this routine generates the variable descriptor used to describe non-basic - * variables. It calls itself recursively until it gets to the bottom of it - * all, and then builds the descriptor backwards. It is easiest to do it this - *way since we must periodically write length bytes, and it is easiest if we know - *the value when it is time to write it. - */ -static int gen1(struct VMS_DBG_Symbol * spnt,int array_suffix_len){ - struct VMS_DBG_Symbol * spnt1; - int i; - switch(spnt->advanced){ - case VOID: - push(DBG$C_VOID,-1); - total_len += 1; - push(total_len,-2); - return 0; - case BASIC: - case FUNCTION: - if(array_suffix_len == 0) { - push(spnt->VMS_type,-1); - push(DBG$C_BASIC,-1); - total_len = 2; - push(total_len,-2); - return 1;}; - push(0,-4); - push(0xfa02,-2); - total_len = -2; - return 1; - case STRUCT: - case UNION: - case ENUM: - struct_number=spnt->struc_numb; - if(struct_number < 0) { - new_forward_ref(spnt->dbx_type); - return 1; - } - push(DBG$C_STRUCT,-1); - total_len = 5; - push(total_len,-2); - return 1; - case POINTER: - spnt1=find_symbol(spnt->type2); - i=1; - if(spnt1 == (struct VMS_DBG_Symbol *) NULL) - new_forward_ref(spnt->type2); - else i=gen1(spnt1,0); - if(i){ /* (*void) is a special case, do not put pointer suffix*/ - push(DBG$C_POINTER,-1); - total_len += 3; - push(total_len,-2); - }; - return 1; - case ARRAY: - spnt1=spnt; - while(spnt1->advanced == ARRAY) - {spnt1 = find_symbol(spnt1->type2); - if(spnt1 == (struct VMS_DBG_Symbol *) NULL) { - printf("gcc-as warning(debugger output):"); - printf("Forward reference error, dbx type %d\n", - spnt->type2); - return;} - }; -/* It is too late to generate forward references, so the user gets a message. - * This should only happen on a compiler error */ - i=gen1(spnt1,1); - i=Apoint; - array_suffix(spnt); - array_suffix_len = Apoint - i; - switch(spnt1->advanced){ - case BASIC: - case FUNCTION: - break; - default: - push(0,-2); - total_len += 2; - push(total_len,-2); - push(0xfa,-1); - push(0x0101,-2); - push(DBG$C_COMPLEX_ARRAY,-1); - }; - total_len += array_suffix_len + 8; - push(total_len,-2); - }; -} - -/* this generates a suffix for a variable. If it is not a defined type yet, - * then dbx_type contains the type we are expecting so we can generate a - * forward reference. This calls gen1 to build most of the descriptor, and - * then it puts the icing on at the end. It then dumps whatever is needed - * to get a complete descriptor (i.e. struct reference, array suffix ). - */ -static generate_suffix(struct VMS_DBG_Symbol * spnt,int dbx_type){ - int ilen; - int i; - char pvoid[6] = {5,0xaf,0,1,0,5}; - struct VMS_DBG_Symbol * spnt1; - Apoint=0; - Lpnt =MAX_DEBUG_RECORD-1; - total_len=0; - struct_number = 0; - overflow = 0; - if(spnt == (struct VMS_DBG_Symbol*) NULL) - new_forward_ref(dbx_type); - else{ - if(spnt->VMS_type != 0xa3) return 0; /* no suffix needed */ - gen1(spnt,0); - }; - push(0x00af,-2); - total_len += 4; - push(total_len,-1); -/* if the variable descriptor overflows the record, output a descriptor for - * a pointer to void. - */ - if((total_len >= MAX_DEBUG_RECORD) || overflow) { - printf(" Variable descriptor %d too complicated. Defined as *void ",spnt->dbx_type); - VMS_Store_Immediate_Data(pvoid, 6, OBJ$C_DBG); - return; - }; - i=0; - while(Lpnt < MAX_DEBUG_RECORD-1) Local[i++] = Local[++Lpnt]; - Lpnt = i; -/* we use this for a reference to a structure that has already been defined */ - if(struct_number > 0){ - VMS_Store_Immediate_Data(Local, Lpnt, OBJ$C_DBG);Lpnt=0; - VMS_Store_Struct(struct_number);}; -/* we use this for a forward reference to a structure that has yet to be -*defined. We store four bytes of zero to make room for the actual address once -* it is known -*/ - if(struct_number < 0){ - struct_number = -struct_number; - VMS_Store_Immediate_Data(Local, Lpnt,OBJ$C_DBG);Lpnt=0; - VMS_Def_Struct(struct_number); - for(i=0;i<4;i++) Local[Lpnt++] = 0; - VMS_Store_Immediate_Data(Local, Lpnt, OBJ$C_DBG);Lpnt=0; - }; - i=0; - while(i 0). - */ -VMS_DBG_record(struct VMS_DBG_Symbol* spnt,int Psect,int Offset, char* Name) -{ - char* pnt; - int j; - int maxlen; - int i=0; - if(Psect < 0) { /* this is a local variable, referenced to SP */ - maxlen=7+strlen(Name); - Local[i++] = maxlen; - Local[i++]=spnt->VMS_type; - if(Offset > 0) Local[i++] = DBG$C_FUNCTION_PARAMETER; - else Local[i++] = DBG$C_LOCAL_SYM; - pnt=(char*) &Offset; - for(j=0;j<4;j++) Local[i++]=*pnt++; /* copy the offset */ - } else { - maxlen=7+strlen(Name); /* symbols fixed in memory */ - Local[i++]=7+strlen(Name); - Local[i++]=spnt->VMS_type; - Local[i++]=1; - VMS_Store_Immediate_Data(Local, i, OBJ$C_DBG); i=0; - VMS_Set_Data(Psect,Offset,OBJ$C_DBG,0); - } - Local[i++]=strlen(Name); - pnt=Name; - fix_name(pnt); /* if there are bad characters in name, convert them */ - while(*pnt!='\0') Local[i++]=*pnt++; - VMS_Store_Immediate_Data(Local, i, OBJ$C_DBG); - if(spnt->VMS_type == DBG$C_ADVANCED_TYPE) generate_suffix(spnt,0); -} - - -/* This routine parses the stabs entries in order to make the definition - * for the debugger of local symbols and function parameters - */ -int VMS_local_stab_Parse(symbolS * sp){ - char *pnt; - char *pnt1; - char *str; - struct VMS_DBG_Symbol* spnt; - struct VMS_Symbol * vsp; - int dbx_type; - int VMS_type; - dbx_type=0; - str=sp->sy_nlist.n_un.n_name; - pnt=(char*) strchr(str,':'); - if(pnt==(char*) NULL) return; /* no colon present */ - pnt1=pnt++; /* save this for later, and skip colon */ - if(*pnt == 'c') return 0; /* ignore static constants */ -/* there is one little catch that we must be aware of. Sometimes function - * parameters are optimized into registers, and the compiler, in its infiite - * wisdom outputs stabs records for *both*. In general we want to use the - * register if it is present, so we must search the rest of the symbols for - * this function to see if this parameter is assigned to a register. - */ - { - char *str1; - char *pnt2; - symbolS * sp1; - if(*pnt == 'p'){ - for(sp1 = symbol_next(sp); sp1; sp1 = symbol_next(sp1)) { - if ((sp1->sy_nlist.n_type & N_STAB) == 0) continue; - if((unsigned char)sp1->sy_nlist.n_type == N_FUN) break; - if((unsigned char)sp1->sy_nlist.n_type != N_RSYM) continue; - str1=sp1->sy_nlist.n_un.n_name; /* and get the name */ - pnt2=str; - while(*pnt2 != ':') { - if(*pnt2 != *str1) break; - pnt2++; str1++;}; - if((*str1 != ':') || (*pnt2 != ':') ) continue; - return; /* they are the same! lets skip this one */ - }; /* for */ -/* first find the dbx symbol type from list, and then find VMS type */ - pnt++; /* skip p in case no register */ - };/* if */ }; /* p block */ - pnt = cvt_integer( pnt, &dbx_type); - spnt = find_symbol(dbx_type); - if(spnt==(struct VMS_DBG_Symbol*) NULL) return 0;/*Dunno what this is*/ - *pnt1='\0'; - VMS_DBG_record(spnt,-1,sp->sy_nlist.n_value,str); - *pnt1=':'; /* and restore the string */ - return 1; -} - -/* this routine parses a stabs entry to find the information required to define - * a variable. It is used for global and static variables. - * Basically we need to know the address of the symbol. With older versions - * of the compiler, const symbols are - * treated differently, in that if they are global they are written into the - * text psect. The global symbol entry for such a const is actually written - * as a program entry point (Yuk!!), so if we cannot find a symbol in the list - * of psects, we must search the entry points as well. static consts are even - * harder, since they are never assigned a memory address. The compiler passes - * a stab to tell us the value, but I am not sure what to do with it. - */ -static gave_compiler_message = 0; - -static int VMS_stab_parse(symbolS * sp,char expected_type, - int type1,int type2,int Text_Psect){ - char *pnt; - char *pnt1; - char *str; - symbolS * sp1; - struct VMS_DBG_Symbol* spnt; - struct VMS_Symbol * vsp; - int dbx_type; - int VMS_type; - dbx_type=0; - str=sp->sy_nlist.n_un.n_name; - pnt=(char*) strchr(str,':'); - if(pnt==(char*) NULL) return; /* no colon present */ - pnt1=pnt; /* save this for later*/ - pnt++; - if(*pnt==expected_type){ - pnt = cvt_integer(pnt+1,&dbx_type); - spnt = find_symbol(dbx_type); - if(spnt==(struct VMS_DBG_Symbol*) NULL) return 0;/*Dunno what this is*/ -/* now we need to search the symbol table to find the psect and offset for - * this variable. - */ - *pnt1='\0'; - vsp=VMS_Symbols; - while(vsp != (struct VMS_Symbol*) NULL) - {pnt=vsp->Symbol->sy_nlist.n_un.n_name; - if(pnt!=(char*) NULL) if(*pnt++ == '_') -/* make sure name is the same, and make sure correct symbol type */ - if((strlen(pnt) == strlen(str)) && (strcmp(pnt,str)==0) - && ((vsp->Symbol->sy_type == type1) || - (vsp->Symbol->sy_type == type2))) break; - vsp=vsp->Next;}; - if(vsp != (struct VMS_Symbol*) NULL){ - VMS_DBG_record(spnt,vsp->Psect_Index,vsp->Psect_Offset,str); - *pnt1=':'; /* and restore the string */ - return 1;}; -/* the symbol was not in the symbol list, but it may be an "entry point" - if it was a constant */ - for(sp1 = symbol_rootP; sp1; sp1 = symbol_next(sp1)) { - /* - * Dispatch on STAB type - */ - if(sp1->sy_type != (N_TEXT | N_EXT) && sp1->sy_type!=N_TEXT) - continue; - pnt = sp1->sy_nlist.n_un.n_name; - if(*pnt == '_') pnt++; - if(strcmp(pnt,str) == 0){ - if(!gave_compiler_message && expected_type=='G'){ -printf("***Warning - the assembly code generated by the compiler has placed\n"); -printf("global constant(s) in the text psect. These will not be available to\n"); -printf("other modules, since this is not the correct way to handle this. You\n"); -printf("have two options: 1) get a patched compiler that does not put global\n"); -printf("constants in the text psect, or 2) remove the 'const' keyword from\n"); -printf("definitions of global variables in your source module(s). Don't say\n"); -printf("I didn't warn you!"); -gave_compiler_message = 1;}; - VMS_DBG_record(spnt, - Text_Psect, - sp1->sy_nlist.n_value, - str); - *pnt1=':'; - *(sp1->sy_nlist.n_un.n_name) = 'L'; - /* fool assembler to not output this - * as a routine in the TBT */ - return 1;}; - }; - }; - *pnt1=':'; /* and restore the string */ - return 0; -} - - -VMS_GSYM_Parse(symbolS * sp,int Text_Psect){ /* Global variables */ - VMS_stab_parse(sp,'G',(N_UNDF | N_EXT),(N_DATA | N_EXT),Text_Psect); -} - - -VMS_LCSYM_Parse(symbolS * sp,int Text_Psect){/* Static symbols - uninitialized */ - VMS_stab_parse(sp,'S',N_BSS,-1,Text_Psect); -} - -VMS_STSYM_Parse(symbolS * sp,int Text_Psect){ /*Static symbols - initialized */ - VMS_stab_parse(sp,'S',N_DATA,-1,Text_Psect); -} - - -/* for register symbols, we must figure out what range of addresses within the - * psect are valid. We will use the brackets in the stab directives to give us - * guidance as to the PC range that this variable is in scope. I am still not - * completely comfortable with this but as I learn more, I seem to get a better - * handle on what is going on. - * Caveat Emptor. - */ -VMS_RSYM_Parse(symbolS * sp,symbolS * Current_Routine,int Text_Psect){ - char* pnt; - char* pnt1; - char* str; - int dbx_type; - struct VMS_DBG_Symbol* spnt; - int j; - int maxlen; - int i=0; - int bcnt=0; - int Min_Offset=-1; /* min PC of validity */ - int Max_Offset=0; /* max PC of validity */ - symbolS * symbolP; - for(symbolP = sp; symbolP; symbolP = symbol_next(symbolP)) { - /* - * Dispatch on STAB type - */ - switch((unsigned char)symbolP->sy_type) { - case N_LBRAC: - if(bcnt++==0) Min_Offset = symbolP->sy_nlist.n_value; - break; - case N_RBRAC: - if(--bcnt==0) Max_Offset = - symbolP->sy_nlist.n_value-1; - break; - } - if((Min_Offset != -1) && (bcnt == 0)) break; - if((unsigned char)symbolP->sy_type == N_FUN) break; - } -/* check to see that the addresses were defined. If not, then there were no - * brackets in the function, and we must try to search for the next function - * Since functions can be in any order, we should search all of the symbol list - * to find the correct ending address. */ - if(Min_Offset == -1){ - int Max_Source_Offset; - int This_Offset; - Min_Offset = sp->sy_nlist.n_value; - for(symbolP = symbol_rootP; symbolP; symbolP = symbol_next(symbolP)) { - /* - * Dispatch on STAB type - */ - This_Offset = symbolP->sy_nlist.n_value; - switch(symbolP->sy_type) { - case N_TEXT | N_EXT: - if((This_Offset > Min_Offset) && (This_Offset < Max_Offset)) - Max_Offset = This_Offset; - break; - case N_SLINE: - if(This_Offset > Max_Source_Offset) - Max_Source_Offset=This_Offset; - } - } -/* if this is the last routine, then we use the PC of the last source line - * as a marker of the max PC for which this reg is valid */ - if(Max_Offset == 0x7fffffff) Max_Offset = Max_Source_Offset; - }; - dbx_type=0; - str=sp->sy_nlist.n_un.n_name; - pnt=(char*) strchr(str,':'); - if(pnt==(char*) NULL) return; /* no colon present */ - pnt1=pnt; /* save this for later*/ - pnt++; - if(*pnt!='r') return 0; - pnt = cvt_integer( pnt+1, &dbx_type); - spnt = find_symbol(dbx_type); - if(spnt==(struct VMS_DBG_Symbol*) NULL) return 0;/*Dunno what this is yet*/ - *pnt1='\0'; - maxlen=25+strlen(sp->sy_nlist.n_un.n_name); - Local[i++]=maxlen; - Local[i++]=spnt->VMS_type; - Local[i++]=0xfb; - Local[i++]=strlen(sp->sy_nlist.n_un.n_name)+1; - Local[i++]=0x00; - Local[i++]=0x00; - Local[i++]=0x00; - Local[i++]=strlen(sp->sy_nlist.n_un.n_name); - pnt=sp->sy_nlist.n_un.n_name; - fix_name(pnt); /* if there are bad characters in name, convert them */ - while(*pnt!='\0') Local[i++]=*pnt++; - Local[i++]=0xfd; - Local[i++]=0x0f; - Local[i++]=0x00; - Local[i++]=0x03; - Local[i++]=0x01; - VMS_Store_Immediate_Data(Local, i, OBJ$C_DBG); i=0; - VMS_Set_Data(Text_Psect,Min_Offset,OBJ$C_DBG,1); - VMS_Set_Data(Text_Psect,Max_Offset,OBJ$C_DBG,1); - Local[i++]=0x03; - Local[i++]=sp->sy_nlist.n_value; - Local[i++]=0x00; - Local[i++]=0x00; - Local[i++]=0x00; - VMS_Store_Immediate_Data(Local, i, OBJ$C_DBG); - *pnt1=':'; - if(spnt->VMS_type == DBG$C_ADVANCED_TYPE) generate_suffix(spnt,0); -} - -/* this function examines a structure definition, checking all of the elements - * to make sure that all of them are fully defined. The only thing that we - * kick out are arrays of undefined structs, since we do not know how big - * they are. All others we can handle with a normal forward reference. - */ -static int forward_reference(char* pnt){ - int i; - struct VMS_DBG_Symbol * spnt; - struct VMS_DBG_Symbol * spnt1; - pnt = cvt_integer(pnt+1,&i); - if(*pnt == ';') return 0; /* no forward references */ - do{ - pnt=(char*) strchr(pnt,':'); - pnt = cvt_integer(pnt+1,&i); - spnt = find_symbol(i); - if(spnt == (struct VMS_DBG_Symbol*) NULL) return 0; - while((spnt->advanced == POINTER) || (spnt->advanced == ARRAY)){ - i=spnt->type2; - spnt1 = find_symbol(spnt->type2); - if((spnt->advanced == ARRAY) && - (spnt1 == (struct VMS_DBG_Symbol*) NULL))return 1; - if(spnt1 == (struct VMS_DBG_Symbol*) NULL) break; - spnt=spnt1; - }; - pnt = cvt_integer(pnt+1,&i); - pnt = cvt_integer(pnt+1,&i); - }while(*++pnt != ';'); - return 0; /* no forward refences found */ -} - -/* This routine parses the stabs directives to find any definitions of dbx type - * numbers. It makes a note of all of them, creating a structure element - * of VMS_DBG_Symbol that describes it. This also generates the info for the - * debugger that describes the struct/union/enum, so that further references - * to these data types will be by number - * We have to process pointers right away, since there can be references - * to them later in the same stabs directive. We cannot have forward - * references to pointers, (but we can have a forward reference to a pointer to - * a structure/enum/union) and this is why we process them immediately. - * After we process the pointer, then we search for defs that are nested even - * deeper. - */ -static int VMS_typedef_parse(char* str){ - char* pnt; - char* pnt1; - char* pnt2; - int i; - int dtype; - struct forward_ref * fpnt; - int i1,i2,i3; - int convert_integer; - struct VMS_DBG_Symbol* spnt; - struct VMS_DBG_Symbol* spnt1; -/* check for any nested def's */ - pnt=(char*)strchr(str+1,'='); - if((pnt != (char*) NULL) && (*(str+1) != '*')) - if(VMS_typedef_parse(pnt) == 1 ) return 1; -/* now find dbx_type of entry */ - pnt=str-1; - if(*pnt == 'c'){ /* check for static constants */ - *str = '\0'; /* for now we ignore them */ - return 0;}; - while((*pnt <= '9')&& (*pnt >= '0')) pnt--; - pnt++; /* and get back to the number */ - cvt_integer(pnt,&i1); - spnt = find_symbol(i1); -/* first we see if this has been defined already, due to a forward reference*/ - if(spnt == (struct VMS_DBG_Symbol*) NULL) { - if(VMS_Symbol_type_list==(struct VMS_DBG_Symbol*) NULL) - {spnt=(struct VMS_DBG_Symbol*) malloc(sizeof(struct VMS_DBG_Symbol)); - spnt->next = (struct VMS_DBG_Symbol*) NULL; - VMS_Symbol_type_list=spnt;} - else - {spnt=(struct VMS_DBG_Symbol*) malloc(sizeof(struct VMS_DBG_Symbol)); - spnt->next=VMS_Symbol_type_list; - VMS_Symbol_type_list = spnt;}; - spnt->dbx_type = i1; /* and save the type */ - }; -/* for structs and unions, do a partial parse, otherwise we sometimes get - * circular definitions that are impossible to resolve. We read enough info - * so that any reference to this type has enough info to be resolved - */ - pnt=str + 1; /* point to character past equal sign */ - if((*pnt == 'u') || (*pnt == 's')){ - }; - if((*pnt <= '9') && (*pnt >= '0')){ - if(type_check("void")){ /* this is the void symbol */ - *str='\0'; - spnt->advanced = VOID; - return 0;}; - printf("gcc-as warning(debugger output):"); - printf(" %d is an unknown untyped variable.\n",spnt->dbx_type); - return 1; /* do not know what this is */ - }; -/* now define this module*/ - pnt=str + 1; /* point to character past equal sign */ - switch (*pnt){ - case 'r': - spnt->advanced= BASIC; - if(type_check("int")) { - spnt->VMS_type=DBG$C_SLINT; spnt->data_size=4;} - else if(type_check("long int")) { - spnt->VMS_type=DBG$C_SLINT; spnt->data_size=4;} - else if(type_check("unsigned int")) { - spnt->VMS_type=DBG$C_ULINT; spnt->data_size = 4;} - else if(type_check("long unsigned int")) { - spnt->VMS_type=DBG$C_ULINT; spnt->data_size = 4;} - else if(type_check("short int")) { - spnt->VMS_type=DBG$C_SSINT; spnt->data_size = 2;} - else if(type_check("short unsigned int")) { - spnt->VMS_type=DBG$C_USINT; spnt->data_size = 2;} - else if(type_check("char")) { - spnt->VMS_type=DBG$C_SCHAR; spnt->data_size = 1;} - else if(type_check("signed char")) { - spnt->VMS_type=DBG$C_SCHAR; spnt->data_size = 1;} - else if(type_check("unsigned char")) { - spnt->VMS_type=DBG$C_UCHAR; spnt->data_size = 1;} - else if(type_check("float")) { - spnt->VMS_type=DBG$C_REAL4; spnt->data_size = 4;} - else if(type_check("double")) { - spnt->VMS_type=DBG$C_REAL8; spnt->data_size = 8;} - pnt1=(char*) strchr(str,';')+1; - break; - case 's': - case 'u': - if(*pnt == 's') spnt->advanced= STRUCT; - else spnt->advanced= UNION; - spnt->VMS_type = DBG$C_ADVANCED_TYPE; - pnt1 = cvt_integer(pnt+1,&spnt->data_size); - if(forward_reference(pnt)) { - spnt->struc_numb = -1; - return 1; - } - spnt->struc_numb = ++structure_count; - pnt1--; - pnt=get_struct_name(str); - VMS_Def_Struct(spnt->struc_numb); - fpnt = f_ref_root; - while(fpnt != (struct forward_ref*) NULL){ - if(fpnt->dbx_type == spnt->dbx_type) { - fpnt->resolved = 'Y'; - VMS_Set_Struct(fpnt->struc_numb); - VMS_Store_Struct(spnt->struc_numb);}; - fpnt = fpnt->next;}; - VMS_Set_Struct(spnt->struc_numb); - i=0; - Local[i++] = 11+strlen(pnt); - Local[i++] = DBG$C_STRUCT_START; - Local[i++] = 0x80; - for(i1=0;i1<4;i1++) Local[i++] = 0x00; - Local[i++] = strlen(pnt); - pnt2=pnt; - while(*pnt2 != '\0') Local[i++] = *pnt2++; - i2=spnt->data_size * 8; /* number of bits */ - pnt2=(char*) &i2; - for(i1=0;i1<4;i1++) Local[i++] = *pnt2++; - VMS_Store_Immediate_Data(Local, i, OBJ$C_DBG); i=0; - if(pnt != symbol_name) { - pnt += strlen(pnt); - *pnt=':';}; /* replace colon for later */ - while(*++pnt1 != ';'){ - pnt=(char*) strchr(pnt1,':'); - *pnt='\0'; - pnt2=pnt1; - pnt1 = cvt_integer(pnt+1,&dtype); - pnt1 = cvt_integer(pnt1+1,&i2); - pnt1 = cvt_integer(pnt1+1,&i3); - if((dtype == 1) && (i3 != 32)) { /* bitfield */ - Apoint = 0; - push(19+strlen(pnt2),1); - push(0xfa22,2); - push(1+strlen(pnt2),4); - push(strlen(pnt2),1); - while(*pnt2 != '\0') push(*pnt2++,1); - push(i3,2); /* size of bitfield */ - push(0x0d22,2); - push(0x00,4); - push(i2,4); /* start position */ - VMS_Store_Immediate_Data(Asuffix,Apoint,OBJ$C_DBG); - Apoint=0; - }else{ - Local[i++] = 7+strlen(pnt2); - spnt1 = find_symbol(dtype); - /* check if this is a forward reference */ - if(spnt1 != (struct VMS_DBG_Symbol*) NULL) - Local[i++] = spnt1->VMS_type; - else - Local[i++] = DBG$C_ADVANCED_TYPE; - Local[i++] = DBG$C_STRUCT_ITEM; - pnt=(char*) &i2; - for(i1=0;i1<4;i1++) Local[i++] = *pnt++; - Local[i++] = strlen(pnt2); - while(*pnt2 != '\0') Local[i++] = *pnt2++; - VMS_Store_Immediate_Data(Local, i, OBJ$C_DBG); i=0; - if(spnt1 == (struct VMS_DBG_Symbol*) NULL) - generate_suffix(spnt1,dtype); - else if(spnt1->VMS_type == DBG$C_ADVANCED_TYPE) - generate_suffix(spnt1,0); - }; - }; - pnt1++; - Local[i++] = 0x01; /* length byte */ - Local[i++] = DBG$C_STRUCT_END; - VMS_Store_Immediate_Data(Local, i, OBJ$C_DBG); i=0; - break; - case 'e': - spnt->advanced= ENUM; - spnt->VMS_type = DBG$C_ADVANCED_TYPE; - spnt->struc_numb = ++structure_count; - spnt->data_size=4; - VMS_Def_Struct(spnt->struc_numb); - fpnt = f_ref_root; - while(fpnt != (struct forward_ref*) NULL){ - if(fpnt->dbx_type == spnt->dbx_type) { - fpnt->resolved = 'Y'; - VMS_Set_Struct(fpnt->struc_numb); - VMS_Store_Struct(spnt->struc_numb);}; - fpnt = fpnt->next;}; - VMS_Set_Struct(spnt->struc_numb); - i=0; - Local[i++] = 3+strlen(symbol_name); - Local[i++] = DBG$C_ENUM_START; - Local[i++] = 0x20; - Local[i++] = strlen(symbol_name); - pnt2=symbol_name; - while(*pnt2 != '\0') Local[i++] = *pnt2++; - VMS_Store_Immediate_Data(Local, i, OBJ$C_DBG); i=0; - while(*++pnt != ';') { - pnt1=(char*) strchr(pnt,':'); - *pnt1++='\0'; - pnt1 = cvt_integer(pnt1,&i1); - Local[i++] = 7+strlen(pnt); - Local[i++] = DBG$C_ENUM_ITEM; - Local[i++] = 0x00; - pnt2=(char*) &i1; - for(i2=0;i2<4;i2++) Local[i++] = *pnt2++; - Local[i++] = strlen(pnt); - pnt2=pnt; - while(*pnt != '\0') Local[i++] = *pnt++; - VMS_Store_Immediate_Data(Local, i, OBJ$C_DBG); i=0; - pnt= pnt1; /* Skip final semicolon */ - }; - Local[i++] = 0x01; /* len byte */ - Local[i++] = DBG$C_ENUM_END; - VMS_Store_Immediate_Data(Local, i, OBJ$C_DBG); i=0; - pnt1=pnt + 1; - break; - case 'a': - spnt->advanced= ARRAY; - spnt->VMS_type = DBG$C_ADVANCED_TYPE; - pnt=(char*)strchr(pnt,';'); if (pnt == (char*) NULL) return 1; - pnt1 = cvt_integer(pnt+1,&spnt->index_min); - pnt1 = cvt_integer(pnt1+1,&spnt->index_max); - pnt1 = cvt_integer(pnt1+1,&spnt->type2); - break; - case 'f': - spnt->advanced= FUNCTION; - spnt->VMS_type = DBG$C_FUNCTION_ADDR; - /* this masquerades as a basic type*/ - spnt->data_size=4; - pnt1 = cvt_integer(pnt+1,&spnt->type2); - break; - case '*': - spnt->advanced= POINTER; - spnt->VMS_type = DBG$C_ADVANCED_TYPE; - spnt->data_size=4; - pnt1 = cvt_integer(pnt+1,&spnt->type2); - pnt=(char*)strchr(str+1,'='); - if((pnt != (char*) NULL)) - if(VMS_typedef_parse(pnt) == 1 ) return 1; - break; - default: - spnt->advanced= UNKNOWN; - spnt->VMS_type = 0; - printf("gcc-as warning(debugger output):"); - printf(" %d is an unknown type of variable.\n",spnt->dbx_type); - return 1; /* unable to decipher */ - }; -/* this removes the evidence of the definition so that the outer levels of -parsing do not have to worry about it */ - pnt=str; - while (*pnt1 != '\0') *pnt++ = *pnt1++; - *pnt = '\0'; - return 0; -} - - -/* - * This is the root routine that parses the stabs entries for definitions. - * it calls VMS_typedef_parse, which can in turn call itself. - * We need to be careful, since sometimes there are forward references to - * other symbol types, and these cannot be resolved until we have completed - * the parse. - */ -int VMS_LSYM_Parse(){ - char *pnt; - char *pnt1; - char *pnt2; - char *str; - char fixit[10]; - int incomplete,i,pass,incom1; - struct VMS_DBG_Symbol* spnt; - struct VMS_Symbol * vsp; - struct forward_ref * fpnt; - symbolS * sp; - pass=0; - incomplete = 0; - do{ - incom1=incomplete; - incomplete = 0; - for(sp = symbol_rootP; sp; sp = symbol_next(sp)) { - /* - * Deal with STAB symbols - */ - if ((sp->sy_nlist.n_type & N_STAB) != 0) { - /* - * Dispatch on STAB type - */ - switch((unsigned char)sp->sy_nlist.n_type) { - case N_GSYM: - case N_LCSYM: - case N_STSYM: - case N_PSYM: - case N_RSYM: - case N_LSYM: - case N_FUN: /*sometimes these contain typedefs*/ - str=sp->sy_nlist.n_un.n_name; - symbol_name = str; - pnt=(char*)strchr(str,':'); - if(pnt== (char*) NULL) break; - *pnt='\0'; - pnt1=pnt+1; - pnt2=(char*)strchr(pnt1,'='); - if(pnt2 == (char*) NULL){ - *pnt=':'; /* replace colon */ - break;}; /* no symbol here */ - incomplete += VMS_typedef_parse(pnt2); - *pnt=':'; /* put back colon so variable def code finds dbx_type*/ - break; - } /*switch*/ - } /* if */ - } /*for*/ - pass++; - } while((incomplete != 0) && (incomplete != incom1 )); - /* repeat until all refs resolved if possible */ -/* if(pass > 1) printf(" Required %d passes\n",pass);*/ - if(incomplete != 0){ - printf("gcc-as warning(debugger output):"); - printf("Unable to resolve %d circular references.\n",incomplete); - }; - fpnt = f_ref_root; - symbol_name="\0"; - while(fpnt != (struct forward_ref*) NULL){ - if(fpnt->resolved != 'Y') { - if( find_symbol(fpnt->dbx_type) != - (struct VMS_DBG_Symbol*) NULL){ - printf("gcc-as warning(debugger output):"); - printf("Forward reference error, dbx type %d\n", - fpnt->dbx_type); - break;}; - fixit[0]=0; - sprintf(&fixit[1],"%d=s4;",fpnt->dbx_type); - pnt2=(char*)strchr(&fixit[1],'='); - VMS_typedef_parse(pnt2); - }; - fpnt = fpnt->next;}; -} - -static symbolS* Current_Routine; -static int Text_Psect; - -static Define_Local_Symbols(symbolS* s1,symbolS* s2){ - symbolS * symbolP1; - for(symbolP1 = symbol_next(s1); symbolP1 != s2; symbolP1 = symbol_next(symbolP1)) { - if (symbolP1 == (symbolS *)NULL) return; - if (symbolP1->sy_nlist.n_type == N_FUN) return; - /* - * Deal with STAB symbols - */ - if ((symbolP1->sy_nlist.n_type & N_STAB) != 0) { - /* - * Dispatch on STAB type - */ - switch((unsigned char)symbolP1->sy_nlist.n_type) { - case N_LSYM: - case N_PSYM: - VMS_local_stab_Parse(symbolP1); - break; - case N_RSYM: - VMS_RSYM_Parse(symbolP1,Current_Routine,Text_Psect); - break; - } /*switch*/ - } /* if */ - } /* for */ -} - -static symbolS* Define_Routine(symbolS* symbolP,int Level){ - symbolS * sstart; - symbolS * symbolP1; - char str[10]; - char * pnt; - int rcount = 0; - int Offset; - sstart = symbolP; - for(symbolP1 = symbol_next(symbolP); symbolP1; symbolP1 = symbol_next(symbolP1)) { - if (symbolP1->sy_nlist.n_type == N_FUN) break; - /* - * Deal with STAB symbols - */ - if ((symbolP1->sy_nlist.n_type & N_STAB) != 0) { - /* - * Dispatch on STAB type - */ - if((unsigned char)symbolP1->sy_nlist.n_type == N_FUN) break; - switch((unsigned char)symbolP1->sy_nlist.n_type) { - case N_LBRAC: - if(Level != 0) { - pnt = str +sprintf(str,"$%d",rcount++); - *pnt = '\0'; - VMS_TBT_Block_Begin(symbolP1,Text_Psect,str); - }; - Offset = symbolP1->sy_nlist.n_value; - Define_Local_Symbols(sstart,symbolP1); - symbolP1 = - Define_Routine(symbolP1,Level+1); - if(Level != 0) - VMS_TBT_Block_End(symbolP1->sy_nlist.n_value - - Offset); - sstart=symbolP1; - break; - case N_RBRAC: - return symbolP1; - } /*switch*/ - } /* if */ - } /* for */ - /* we end up here if there were no brackets in this function. Define -everything */ - Define_Local_Symbols(sstart,(symbolS *) 0); -} - -VMS_DBG_Define_Routine(symbolS* symbolP,symbolS* Curr_Routine,int Txt_Psect){ - Current_Routine = Curr_Routine; - Text_Psect = Txt_Psect; - Define_Routine(symbolP,0); -} diff --git a/gas/config/vms/vms.c b/gas/config/vms/vms.c deleted file mode 100644 index dc819636b0d..00000000000 --- a/gas/config/vms/vms.c +++ /dev/null @@ -1,3741 +0,0 @@ -/* vms.c -- Write out a VAX/VMS object file - Copyright (C) 1987, 1988 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Written by David L. Kashtan */ -#include -#include - -#include "as.h" -#include "subsegs.h" -#include "obstack.h" -#include "struc-symbol.h" -#include "write.h" -#include "symbols.h" - -#ifdef VMS /* THIS MODULE IS FOR VMS ONLY */ - -#include -#include "objrecdef.h" /* Define VMS Object record lang. */ -#include /* Define File Access Block */ -#include /* Define NAM Block */ -#include /* Define XAB */ -#include /* Define Date XAB */ -#include /* Define File Header XAB */ - -const pseudo_typeS obj_pseudo_table[] = { - { "const", s_const, 0 }, - -}; /* obj_pseudo_table */ - -/* - * Version string of the compiler that produced the code we are - * assembling. (And this assembler, if we do not have compiler info.) - */ -extern char version_string[]; -char *compiler_version_string; - -extern char *myname; -static symbolS *Entry_Point_Symbol = 0; /* Pointer to "_main" */ - -/* - * We augment the "gas" symbol structure with this - */ -struct VMS_Symbol { - struct VMS_Symbol *Next; - struct symbol *Symbol; - int Size; - int Psect_Index; - int Psect_Offset; - }; -struct VMS_Symbol *VMS_Symbols = 0; - -/* we need this to keep track of the various input files, so that we can - * give the debugger the correct source line - */ - -struct input_file{ - struct input_file* next; - struct input_file* same_file_fpnt; - int file_number; - int max_line; - int min_line; - int offset; - char flag; - char * name; - symbolS * spnt; - }; - -static struct input_file * file_root = (struct input_file*)NULL; - -struct input_file * find_file(symbolS *); - - -/* - * If the procedure "main()" exists we have to add the instruction - * "jsb c$main_args" at the beginning to be compatible with VAX-11 "C". - */ -VMS_Check_For_Main() -{ - register symbolS *symbolP; -#ifdef HACK_DEC_C_STARTUP /* JF */ - register struct frchain *frchainP; - register fragS *fragP; - register fragS **prev_fragPP; - register struct fix *fixP; - register fragS *New_Frag; - int i; -#endif HACK_DEC_C_STARTUP - - symbolP = (struct symbol *)symbol_find("_main"); - if (symbolP && (symbolP->sy_nlist.n_type == (N_TEXT | N_EXT))) { -#ifdef HACK_DEC_C_STARTUP - if( !flagseen['+']) { -#endif - /* - * Remember the entry point symbol - */ - Entry_Point_Symbol = symbolP; -#ifdef HACK_DEC_C_STARTUP - } else { - /* - * Scan all the fragment chains for the one with "_main" - * (Actually we know the fragment from the symbol, but we need - * the previous fragment so we can change its pointer) - */ - frchainP = frchain_root; - while(frchainP) { - /* - * Scan all the fragments in this chain, remembering - * the "previous fragment" - */ - prev_fragPP = &frchainP->frch_root; - fragP = frchainP->frch_root; - while(fragP && (fragP != frchainP->frch_last)) { - /* - * Is this the fragment? - */ - if (fragP == symbolP->sy_frag) { - /* - * Yes: Modify the fragment by replacing - * it with a new fragment. - */ - New_Frag = (fragS *) - xmalloc(sizeof(*New_Frag) + - fragP->fr_fix + - fragP->fr_var + - 5); - /* - * The fragments are the same except - * that the "fixed" area is larger - */ - *New_Frag = *fragP; - New_Frag->fr_fix += 6; - /* - * Copy the literal data opening a hole - * 2 bytes after "_main" (i.e. just after - * the entry mask). Into which we place - * the JSB instruction. - */ - New_Frag->fr_literal[0] = fragP->fr_literal[0]; - New_Frag->fr_literal[1] = fragP->fr_literal[1]; - New_Frag->fr_literal[2] = 0x16; /* Jsb */ - New_Frag->fr_literal[3] = 0xef; - New_Frag->fr_literal[4] = 0; - New_Frag->fr_literal[5] = 0; - New_Frag->fr_literal[6] = 0; - New_Frag->fr_literal[7] = 0; - for(i = 2; i < fragP->fr_fix + fragP->fr_var; i++) - New_Frag->fr_literal[i+6] = - fragP->fr_literal[i]; - /* - * Now replace the old fragment with the - * newly generated one. - */ - *prev_fragPP = New_Frag; - /* - * Remember the entry point symbol - */ - Entry_Point_Symbol = symbolP; - /* - * Scan the text area fixup structures - * as offsets in the fragment may have - * changed - */ - for(fixP = text_fix_root; fixP; fixP = fixP->fx_next) { - /* - * Look for references to this - * fragment. - */ - if (fixP->fx_frag == fragP) { - /* - * Change the fragment - * pointer - */ - fixP->fx_frag = New_Frag; - /* - * If the offset is after - * the entry mask we need - * to account for the JSB - * instruction we just - * inserted. - */ - if (fixP->fx_where >= 2) - fixP->fx_where += 6; - } - } - /* - * Scan the symbols as offsets in the - * fragment may have changed - */ - for(symbolP = symbol_rootP; - symbolP; - symbolP = symbol_next(symbolP)) { - /* - * Look for references to this - * fragment. - */ - if (symbolP->sy_frag == fragP) { - /* - * Change the fragment - * pointer - */ - symbolP->sy_frag = New_Frag; - /* - * If the offset is after - * the entry mask we need - * to account for the JSB - * instruction we just - * inserted. - */ - if (symbolP->sy_nlist.n_value >= 2) - symbolP->sy_nlist.n_value += 6; - } - } - /* - * Make a symbol reference to - * "_c$main_args" so we can get - * its address inserted into the - * JSB instruction. - */ - symbolP = (symbolS *)xmalloc(sizeof(*symbolP)); - symbolP->sy_nlist.n_un.n_name = "_c$main_args"; - symbolP->sy_nlist.n_type = N_UNDF; - symbolP->sy_nlist.n_other = 0; - symbolP->sy_nlist.n_desc = 0; - symbolP->sy_nlist.n_value = 0; - symbolP->sy_name_offset = 0; - symbolP->sy_number = 0; - symbolP->sy_frag = New_Frag; - symbolP->sy_forward = 0; - /* this actually inserts at the beginning of the list */ - symbol_append(symbol_rootP, symbolP, &symbol_rootP, &symbol_lastP); - - symbol_rootP = symbolP; - /* - * Generate a text fixup structure - * to get "_c$main_args" stored into the - * JSB instruction. - */ - fixP = (struct fix *)xmalloc(sizeof(*fixP)); - fixP->fx_frag = New_Frag; - fixP->fx_where = 4; - fixP->fx_addsy = symbolP; - fixP->fx_subsy = 0; - fixP->fx_offset = 0; - fixP->fx_size = sizeof(long); - fixP->fx_pcrel = 1; - fixP->fx_next = text_fix_root; - text_fix_root = fixP; - /* - * Now make sure we exit from the loop - */ - frchainP = 0; - break; - } - /* - * Try the next fragment - */ - prev_fragPP = &fragP->fr_next; - fragP = fragP->fr_next; - } - /* - * Try the next fragment chain - */ - if (frchainP) frchainP=frchainP->frch_next; - } - } -#endif /* HACK_DEC_C_STARTUP */ - } -} - -/* - * Write a VAX/VMS object file (everything else has been done!) - */ -VMS_write_object_file(text_siz, data_siz, text_frag_root, data_frag_root) -unsigned text_siz; -unsigned data_siz; -struct frag *text_frag_root; -struct frag *data_frag_root; -{ - register fragS * fragP; - register symbolS * symbolP; - register symbolS * sp; - register struct fix * fixP; - register struct VMS_Symbol * vsp; - int Local_Initialized_Data_Size = 0; - int Psect_Number = 0; /* Psect Index Number */ - int Text_Psect = -1; /* Text Psect Index */ - int Data_Psect = -2; /* Data Psect Index JF: Was -1 */ - int Bss_Psect = -3; /* Bss Psect Index JF: Was -1 */ - - /* - * Create the VMS object file - */ - Create_VMS_Object_File(); - /* - * Write the module header records - */ - Write_VMS_MHD_Records(); - - /* - * Generate the VMS object file records - * 1st GSD then TIR records - */ - - /******* Global Symbol Dictionary *******/ - /* - * Define the Text Psect - */ - if (text_siz > 0) { - Text_Psect = Psect_Number++; - VMS_Psect_Spec("$code",text_siz,"TEXT"); - } - /* - * Define the BSS Psect - */ - if (local_bss_counter > 0) { - Bss_Psect = Psect_Number++; - VMS_Psect_Spec("$uninitialized_data",local_bss_counter,"DATA"); - } - /* - * Now scan the symbols and emit the appropriate GSD records - */ - for (sp = symbol_rootP; sp; sp = symbol_next(sp)) { - /* - * Dispatch on symbol type - */ - switch(sp->sy_type) { - /* - * Global uninitialized data - */ - case N_UNDF | N_EXT: - /* - * Make a VMS data symbol entry - */ - vsp = (struct VMS_Symbol *) - xmalloc(sizeof(*vsp)); - vsp->Symbol = sp; - vsp->Size = sp->sy_nlist.n_value; - vsp->Psect_Index = Psect_Number++; - vsp->Psect_Offset = 0; - vsp->Next = VMS_Symbols; - VMS_Symbols = vsp; - sp->sy_number = (int)vsp; - /* - * Make the psect for this data - */ - if(sp->sy_nlist.n_other) - VMS_Psect_Spec(sp->sy_nlist.n_un.n_name, - vsp->Size, - "CONST"); - else - VMS_Psect_Spec(sp->sy_nlist.n_un.n_name, - vsp->Size, - "COMMON"); -#ifdef NOT_VAX_11_C_COMPATIBLE - /* - * Place a global symbol at the - * beginning of the Psect - */ - VMS_Global_Symbol_Spec(sp->sy_nlist.n_un.n_name, - vsp->Psect_Index, - 0, - 1); -#endif NOT_VAX_11_C_COMPATIBLE - break; - /* - * Local uninitialized data - */ - case N_BSS: - /* - * Make a VMS data symbol entry - */ - vsp = (struct VMS_Symbol *) - xmalloc(sizeof(*vsp)); - vsp->Symbol = sp; - vsp->Size = 0; - vsp->Psect_Index = Bss_Psect; - vsp->Psect_Offset = - sp->sy_nlist.n_value - - bss_address_frag . fr_address; - vsp->Next = VMS_Symbols; - VMS_Symbols = vsp; - sp->sy_number = (int)vsp; - break; - /* - * Global initialized data - */ - case N_DATA | N_EXT: - /* - * Make a VMS data symbol entry - */ - vsp = (struct VMS_Symbol *) - xmalloc(sizeof(*vsp)); - vsp->Symbol = sp; - vsp->Size = VMS_Initialized_Data_Size(sp, - text_siz + data_siz); - vsp->Psect_Index = Psect_Number++; - vsp->Psect_Offset = 0; - vsp->Next = VMS_Symbols; - VMS_Symbols = vsp; - sp->sy_number = (int)vsp; - /* - * Make its psect - */ - if(sp->sy_nlist.n_other) - VMS_Psect_Spec(sp->sy_nlist.n_un.n_name, - vsp->Size, - "CONST"); - else - VMS_Psect_Spec(sp->sy_nlist.n_un.n_name, - vsp->Size, - "COMMON"); -#ifdef NOT_VAX_11_C_COMPATIBLE - /* - * Place a global symbol at the - * beginning of the Psect - */ - VMS_Global_Symbol_Spec(sp->sy_nlist.n_un.n_name, - vsp->Psect_Index, - 0, - 1); -#endif NOT_VAX_11_C_COMPATIBLE - break; - /* - * Local initialized data - */ - case N_DATA: - /* - * Make a VMS data symbol entry - */ - vsp = (struct VMS_Symbol *) - xmalloc(sizeof(*vsp)); - vsp->Symbol = sp; - vsp->Size = - VMS_Initialized_Data_Size(sp, - text_siz + data_siz); - vsp->Psect_Index = Data_Psect; - vsp->Psect_Offset = - Local_Initialized_Data_Size; - Local_Initialized_Data_Size += vsp->Size; - vsp->Next = VMS_Symbols; - VMS_Symbols = vsp; - sp->sy_number = (int)vsp; - break; - /* - * Global Text definition - */ - case N_TEXT | N_EXT: { - unsigned short Entry_Mask; - - /* - * Get the entry mask - */ - fragP = sp->sy_frag; - Entry_Mask = (fragP->fr_literal[0] & 0xff) + - ((fragP->fr_literal[1] & 0xff) - << 8); - /* - * Define the Procedure entry pt. - */ - VMS_Procedure_Entry_Pt(sp->sy_nlist.n_un.n_name, - Text_Psect, - sp->sy_nlist.n_value, - Entry_Mask); - break; - } - /* - * Local Text definition - */ - case N_TEXT: - /* - * Make a VMS data symbol entry - */ - if(Text_Psect != -1) { - vsp = (struct VMS_Symbol *) - xmalloc(sizeof(*vsp)); - vsp->Symbol = sp; - vsp->Size = 0; - vsp->Psect_Index = Text_Psect; - vsp->Psect_Offset = sp->sy_nlist.n_value; - vsp->Next = VMS_Symbols; - VMS_Symbols = vsp; - sp->sy_number = (int)vsp; - } - break; - /* - * Global Reference - */ - case N_UNDF: - /* - * Make a GSD global symbol reference - * record. - */ - VMS_Global_Symbol_Spec(sp->sy_nlist.n_un.n_name, - 0, - 0, - 0); - break; - /* - * Anything else - */ - default: - /* - * Ignore STAB symbols - * Including .stabs emitted by g++ - */ - if ((sp->sy_type & N_STAB) != 0 || sp->sy_nlist.n_type==22) - break; - /* - * Error - */ - if(sp->sy_nlist.n_type !=22) - printf(" ERROR, unknown type (%d)\n", - sp->sy_nlist.n_type); - break; - } - } - /* - * Define the Data Psect - */ - if ((data_siz > 0) && (Local_Initialized_Data_Size > 0)) { - /* - * Do it - */ - Data_Psect = Psect_Number++; - VMS_Psect_Spec("$data", - Local_Initialized_Data_Size, - "DATA"); - /* - * Scan the VMS symbols and fill in the data psect - */ - for (vsp = VMS_Symbols; vsp; vsp = vsp->Next) { - /* - * Only look for undefined psects - */ - if (vsp->Psect_Index < 0) { - /* - * And only initialized data - */ - if (vsp->Symbol->sy_nlist.n_type == N_DATA) - vsp->Psect_Index = Data_Psect; - } - } - } - - /******* Text Information and Relocation Records *******/ - /* - * Write the text segment data - */ - if (text_siz > 0) { - /* - * Scan the text fragments - */ - for(fragP = text_frag_root; fragP; fragP = fragP->fr_next) { - /* - * Stop if we get to the data fragments - */ - if (fragP == data_frag_root) break; - /* - * Ignore fragments with no data - */ - if ((fragP->fr_fix == 0) && (fragP->fr_var == 0)) - continue; - /* - * Go the the appropriate offset in the - * Text Psect. - */ - VMS_Set_Psect(Text_Psect,fragP->fr_address,OBJ$C_TIR); - /* - * Store the "fixed" part - */ - if (fragP->fr_fix) - VMS_Store_Immediate_Data(fragP->fr_literal, - fragP->fr_fix, - OBJ$C_TIR); - /* - * Store the "variable" part - */ - if (fragP->fr_var && fragP->fr_offset) - VMS_Store_Repeated_Data(fragP->fr_offset, - fragP->fr_literal+ - fragP->fr_fix, - fragP->fr_var, - OBJ$C_TIR); - } - /* - * Now we go through the text segment fixups and - * generate TIR records to fix up addresses within - * the Text Psect - */ - for(fixP = text_fix_root; fixP; fixP = fixP->fx_next) { - /* - * We DO handle the case of "Symbol - Symbol" as - * long as it is in the same segment. - */ - if (fixP->fx_subsy && fixP->fx_addsy) { - int i; - - /* - * They need to be in the same segment - */ - if (fixP->fx_subsy->sy_type != - fixP->fx_addsy->sy_type) - error("Fixup data addsy and subsy didn't have the same type"); - /* - * And they need to be in one that we - * can check the psect on - */ - if (((fixP->fx_addsy->sy_type & ~N_EXT) != N_DATA) && - ((fixP->fx_addsy->sy_type & ~N_EXT) != N_TEXT)) - error("Fixup data addsy and subsy didn't have an appropriate type"); - /* - * This had better not be PC relative! - */ - if (fixP->fx_pcrel) - error("Fixup data was erroneously \"pcrel\""); - /* - * Subtract their values to get the - * difference. - */ - i = fixP->fx_addsy->sy_value - - fixP->fx_subsy->sy_value; - /* - * Now generate the fixup object records - * Set the psect and store the data - */ - VMS_Set_Psect(Text_Psect, - fixP->fx_where + - fixP->fx_frag->fr_address, - OBJ$C_TIR); - VMS_Store_Immediate_Data(&i, - fixP->fx_size, - OBJ$C_TIR); - /* - * Done - */ - continue; - } - /* - * Size will HAVE to be "long" - */ - if (fixP->fx_size != sizeof(long)) - error("Fixup datum was not a longword"); - /* - * Symbol must be "added" (if it is ever - * subtracted we can - * fix this assumption) - */ - if (fixP->fx_addsy == 0) - error("Fixup datum was not \"fixP->fx_addsy\""); - /* - * Store the symbol value in a PIC fashion - */ - VMS_Store_PIC_Symbol_Reference(fixP->fx_addsy, - fixP->fx_offset, - fixP->fx_pcrel, - Text_Psect, - fixP->fx_where + - fixP->fx_frag->fr_address, - OBJ$C_TIR); - /* - * Check for indirect address reference, - * which has to be fixed up (as the linker - * will screw it up with TIR$C_STO_PICR). - */ - if (fixP->fx_pcrel) - VMS_Fix_Indirect_Reference(Text_Psect, - fixP->fx_where + - fixP->fx_frag->fr_address, - fixP->fx_frag, - text_frag_root); - } - } - /* - * Store the Data segment: - * - * Since this is REALLY hard to do any other way, - * we actually manufacture the data segment and - * the store the appropriate values out of it. - */ - if (data_siz > 0) { - char *Data_Segment; - - /* - * Allocate the data segment - */ - Data_Segment = (char *)xmalloc(data_siz); - /* - * Run through the data fragments, filling in the segment - */ - for(fragP = data_frag_root; fragP; fragP = fragP->fr_next) { - register long int count; - register char * fill_literal; - register long int fill_size; - int i; - - i = fragP->fr_address - text_siz; - if (fragP->fr_fix) - bcopy(fragP->fr_literal, - Data_Segment + i, - fragP->fr_fix); - i += fragP->fr_fix; - - fill_literal= fragP -> fr_literal + fragP -> fr_fix; - fill_size = fragP -> fr_var; - for (count = fragP -> fr_offset; count; count --) { - if (fill_size) - bcopy(fill_literal, - Data_Segment + i, - fill_size); - i += fill_size; - } - } - /* - * Now we can run through all the data symbols - * and store the data - */ - for(vsp = VMS_Symbols; vsp; vsp = vsp->Next) { - /* - * Ignore anything other than data symbols - */ - if ((vsp->Symbol->sy_nlist.n_type & ~N_EXT) != N_DATA) - continue; - /* - * Set the Psect + Offset - */ - VMS_Set_Psect(vsp->Psect_Index, - vsp->Psect_Offset, - OBJ$C_TIR); - /* - * Store the data - */ - VMS_Store_Immediate_Data(Data_Segment + - vsp->Symbol->sy_nlist.n_value - - text_siz, - vsp->Size, - OBJ$C_TIR); - } - /* - * Now we go through the data segment fixups and - * generate TIR records to fix up addresses within - * the Data Psects - */ - for(fixP = data_fix_root; fixP; fixP = fixP->fx_next) { - /* - * Find the symbol for the containing datum - */ - for(vsp = VMS_Symbols; vsp; vsp = vsp->Next) { - /* - * Only bother with Data symbols - */ - sp = vsp->Symbol; - if ((sp->sy_nlist.n_type & ~N_EXT) != N_DATA) - continue; - /* - * Ignore symbol if After fixup - */ - if (sp->sy_nlist.n_value > - (fixP->fx_where + - fixP->fx_frag->fr_address)) - continue; - /* - * See if the datum is here - */ - if ((sp->sy_nlist.n_value + vsp->Size) <= - (fixP->fx_where + - fixP->fx_frag->fr_address)) - continue; - /* - * We DO handle the case of "Symbol - Symbol" as - * long as it is in the same segment. - */ - if (fixP->fx_subsy && fixP->fx_addsy) { - int i; - - /* - * They need to be in the same segment - */ - if (fixP->fx_subsy->sy_type != - fixP->fx_addsy->sy_type) - error("Fixup data addsy and subsy didn't have the same type"); - /* - * And they need to be in one that we - * can check the psect on - */ - if (((fixP->fx_addsy->sy_type & ~N_EXT) != N_DATA) && - ((fixP->fx_addsy->sy_type & ~N_EXT) != N_TEXT)) - error("Fixup data addsy and subsy didn't have an appropriate type"); - /* - * This had better not be PC relative! - */ - if (fixP->fx_pcrel) - error("Fixup data was erroneously \"pcrel\""); - /* - * Subtract their values to get the - * difference. - */ - i = fixP->fx_addsy->sy_value - - fixP->fx_subsy->sy_value; - /* - * Now generate the fixup object records - * Set the psect and store the data - */ - VMS_Set_Psect(vsp->Psect_Index, - fixP->fx_frag->fr_address + - fixP->fx_where - - vsp->Symbol->sy_value + - vsp->Psect_Offset, - OBJ$C_TIR); - VMS_Store_Immediate_Data(&i, - fixP->fx_size, - OBJ$C_TIR); - /* - * Done - */ - break; - } - /* - * Size will HAVE to be "long" - */ - if (fixP->fx_size != sizeof(long)) - error("Fixup datum was not a longword"); - /* - * Symbol must be "added" (if it is ever - * subtracted we can - * fix this assumption) - */ - if (fixP->fx_addsy == 0) - error("Fixup datum was not \"fixP->fx_addsy\""); - /* - * Store the symbol value in a PIC fashion - */ - VMS_Store_PIC_Symbol_Reference( - fixP->fx_addsy, - fixP->fx_offset, - fixP->fx_pcrel, - vsp->Psect_Index, - fixP->fx_frag->fr_address + - fixP->fx_where - - vsp->Symbol->sy_value + - vsp->Psect_Offset, - OBJ$C_TIR); - /* - * Done - */ - break; - } - - } - } - - /* - * Write the Traceback Begin Module record - */ - VMS_TBT_Module_Begin(); - /* - * Scan the symbols and write out the routines - * (this makes the assumption that symbols are in - * order of ascending text segment offset) - */ - { - struct symbol *Current_Routine = 0; - int Current_Line_Number = 0; - int Current_Offset = -1; - struct input_file * Current_File; - -/* Output debugging info for global variables and static variables that are not - * specific to one routine. We also need to examine all stabs directives, to - * find the definitions to all of the advanced data types, and this is done by - * VMS_LSYM_Parse. This needs to be done before any definitions are output to - * the object file, since there can be forward references in the stabs - * directives. When through with parsing, the text of the stabs directive - * is altered, with the definitions removed, so that later passes will see - * directives as they would be written if the type were already defined. - * - * We also look for files and include files, and make a list of them. We - * examine the source file numbers to establish the actual lines that code was - * generated from, and then generate offsets. - */ - VMS_LSYM_Parse(); - for(symbolP = symbol_rootP; symbolP; symbolP = symbol_next(symbolP)) { - /* - * Deal with STAB symbols - */ - if ((symbolP->sy_nlist.n_type & N_STAB) != 0) { - /* - * Dispatch on STAB type - */ - switch((unsigned char)symbolP->sy_nlist.n_type) { - case N_SLINE: - if(symbolP->sy_nlist.n_desc > Current_File->max_line) - Current_File->max_line = symbolP->sy_nlist.n_desc; - if(symbolP->sy_nlist.n_desc < Current_File->min_line) - Current_File->min_line = symbolP->sy_nlist.n_desc; - break; - case N_SO: - Current_File =find_file(symbolP); - Current_File->flag = 1; - Current_File->min_line = 1; - break; - case N_SOL: - Current_File = find_file(symbolP); - break; - case N_GSYM: - VMS_GSYM_Parse(symbolP,Text_Psect); - break; - case N_LCSYM: - VMS_LCSYM_Parse(symbolP,Text_Psect); - break; - case N_FUN: /* For static constant symbols */ - case N_STSYM: - VMS_STSYM_Parse(symbolP,Text_Psect); - break; - } - } - } - - /* now we take a quick sweep through the files and assign offsets - to each one. This will essentially be the starting line number to the - debugger for each file. Output the info for the debugger to specify the - files, and then tell it how many lines to use */ - { - int File_Number = 0; - int Debugger_Offset = 0; - int file_available; - Current_File = file_root; - for(Current_File = file_root; Current_File; Current_File = Current_File->next){ - if(Current_File == (struct input_file*) NULL) break; - if(Current_File->max_line == 0) continue; - if((strncmp(Current_File->name,"GNU_GXX_INCLUDE:",16) == 0) && - !flagseen['D']) continue; - if((strncmp(Current_File->name,"GNU_CC_INCLUDE:",15) == 0) && - !flagseen['D']) continue; -/* show a few extra lines at the start of the region selected */ - if(Current_File->min_line > 2) Current_File->min_line -= 2; - Current_File->offset = Debugger_Offset - Current_File->min_line + 1; - Debugger_Offset += Current_File->max_line - Current_File->min_line + 1; - if(Current_File->same_file_fpnt != (struct input_file *) NULL) - Current_File->file_number =Current_File->same_file_fpnt->file_number; - else { - Current_File->file_number = ++File_Number; - file_available = VMS_TBT_Source_File(Current_File->name, - Current_File->file_number); - if(!file_available) {Current_File->file_number = 0; - File_Number--; - continue;}; - }; - VMS_TBT_Source_Lines(Current_File->file_number, - Current_File->min_line, - Current_File->max_line-Current_File->min_line+1); - }; /* for */ - }; /* scope */ - Current_File = (struct input_file*) NULL; - - for(symbolP = symbol_rootP; symbolP; symbolP = symbol_next(symbolP)) { - /* - * Deal with text symbols - */ - if ((symbolP->sy_nlist.n_type & ~N_EXT) == N_TEXT) { - /* - * Ignore symbols starting with "L", - * as they are local symbols - */ - if (symbolP->sy_nlist.n_un.n_name[0] == 'L') continue; - /* - * If there is a routine start defined, - * terminate it. - */ - if (Current_Routine) { - /* - * End the routine - */ - VMS_TBT_Routine_End(text_siz,Current_Routine); - } - /* - * Store the routine begin traceback info - */ - if(Text_Psect != -1) { - VMS_TBT_Routine_Begin(symbolP,Text_Psect); - Current_Routine = symbolP; - } -/* Output local symbols, i.e. all symbols that are associated with a specific - * routine. We output them now so the debugger recognizes them as local to - * this routine. - */ - { symbolS * symbolP1; - char* pnt; - char* pnt1; - for(symbolP1 = Current_Routine; symbolP1; symbolP1 = symbol_next(symbolP1)) { - if ((symbolP1->sy_nlist.n_type & N_STAB) == 0) continue; - if (symbolP1->sy_nlist.n_type != N_FUN) continue; - pnt=symbolP->sy_nlist.n_un.n_name; - pnt1=symbolP1->sy_nlist.n_un.n_name; - if(*pnt++ != '_') continue; - while(*pnt++ == *pnt1++) {}; - if((*(--pnt) == '\0') && (*(--pnt1) == ':')) break; - }; - if(symbolP1 != (symbolS *) NULL) - VMS_DBG_Define_Routine(symbolP1,Current_Routine,Text_Psect); - } /* local symbol block */ - /* - * Done - */ - continue; - } - /* - * Deal with STAB symbols - */ - if ((symbolP->sy_nlist.n_type & N_STAB) != 0) { - /* - * Dispatch on STAB type - */ - switch((unsigned char)symbolP->sy_nlist.n_type) { - /* - * Line number - */ - case N_SLINE: - /* Offset the line into the correct portion - * of the file */ - if(Current_File->file_number == 0) break; - /* Sometimes the same offset gets several source - * lines assigned to it. - * We should be selective about which lines - * we allow, we should prefer lines that are - * in the main source file when debugging - * inline functions. */ - if((Current_File->file_number != 1) && - symbolP->sy_nlist.n_value == - Current_Offset) break; - /* calculate actual debugger source line */ - symbolP->sy_nlist.n_desc - += Current_File->offset; - /* - * If this is the 1st N_SLINE, setup - * PC/Line correlation. Otherwise - * do the delta PC/Line. If the offset - * for the line number is not +ve we need - * to do another PC/Line correlation - * setup - */ - if (Current_Offset == -1) { - VMS_TBT_Line_PC_Correlation( - symbolP->sy_nlist.n_desc, - symbolP->sy_nlist.n_value, - Text_Psect, - 0); - } else { - if ((symbolP->sy_nlist.n_desc - - Current_Line_Number) <= 0) { - /* - * Line delta is not +ve, we - * need to close the line and - * start a new PC/Line - * correlation. - */ - VMS_TBT_Line_PC_Correlation(0, - symbolP->sy_nlist.n_value - - Current_Offset, - 0, - -1); - VMS_TBT_Line_PC_Correlation( - symbolP->sy_nlist.n_desc, - symbolP->sy_nlist.n_value, - Text_Psect, - 0); - } else { - /* - * Line delta is +ve, all is well - */ - VMS_TBT_Line_PC_Correlation( - symbolP->sy_nlist.n_desc - - Current_Line_Number, - symbolP->sy_nlist.n_value - - Current_Offset, - 0, - 1); - } - } - /* - * Update the current line/PC - */ - Current_Line_Number = symbolP->sy_nlist.n_desc; - Current_Offset = symbolP->sy_nlist.n_value; - /* - * Done - */ - break; - /* - * Source file - */ - case N_SO: - /* - * Remember that we had a source file - * and emit the source file debugger - * record - */ - Current_File = - find_file(symbolP); - break; -/* We need to make sure that we are really in the actual source file when - * we compute the maximum line number. Otherwise the debugger gets really - * confused */ - case N_SOL: - Current_File = - find_file(symbolP); - break; - } - } - } - /* - * If there is a routine start defined, - * terminate it (and the line numbers) - */ - if (Current_Routine) { - /* - * Terminate the line numbers - */ - VMS_TBT_Line_PC_Correlation(0, - text_siz - Current_Routine->sy_nlist.n_value, - 0, - -1); - /* - * Terminate the routine - */ - VMS_TBT_Routine_End(text_siz,Current_Routine); - } - } - /* - * Write the Traceback End Module TBT record - */ - VMS_TBT_Module_End(); - - /* - * Write the End Of Module record - */ - if (Entry_Point_Symbol == 0) - Write_VMS_EOM_Record(-1,0); - else - Write_VMS_EOM_Record(Text_Psect, - Entry_Point_Symbol->sy_nlist.n_value); - - /* - * All done, close the object file - */ - Close_VMS_Object_File(); -} - - - /****** VMS OBJECT FILE HACKING ROUTINES *******/ - - -/* - * Global data (Object records limited to 512 bytes by VAX-11 "C" runtime) - */ -static int VMS_Object_File_FD; /* File Descriptor for object file */ -static char Object_Record_Buffer[512]; /* Buffer for object file records */ -static int Object_Record_Offset; /* Offset to end of data */ -static int Current_Object_Record_Type; /* Type of record in above */ - -/* - * Macros for placing data into the object record buffer - */ -#define PUT_LONG(val) *((long *)(Object_Record_Buffer + \ - Object_Record_Offset)) = val; \ - Object_Record_Offset += sizeof(long) - -#define PUT_SHORT(val) *((short *)(Object_Record_Buffer + \ - Object_Record_Offset)) = val; \ - Object_Record_Offset += sizeof(short) - -#define PUT_CHAR(val) Object_Record_Buffer[Object_Record_Offset++] = val - -#define PUT_COUNTED_STRING(cp) {\ - register char *p = cp; \ - PUT_CHAR(strlen(p)); \ - while(*p) PUT_CHAR(*p++);} - -/* - * Macro for determining if a Name has psect attributes attached - * to it. - */ -#define PSECT_ATTRIBUTES_STRING "$$PsectAttributes_" -#define PSECT_ATTRIBUTES_STRING_LENGTH 18 - -#define HAS_PSECT_ATTRIBUTES(Name) \ - (strncmp((Name[0] == '_' ? Name + 1 : Name), \ - PSECT_ATTRIBUTES_STRING, \ - PSECT_ATTRIBUTES_STRING_LENGTH) == 0) - - -/* - * Create the VMS object file - */ -Create_VMS_Object_File() -{ -#ifdef eunice - VMS_Object_File_FD = creat(out_file_name, 0777, "var"); -#else eunice - VMS_Object_File_FD = creat(out_file_name, 0, "rfm=var"); -#endif eunice - /* - * Deal with errors - */ - if (VMS_Object_File_FD < 0) { - char Error_Line[256]; - - sprintf(Error_Line,"Couldn't create VMS object file \"%s\"", - out_file_name); - error(Error_Line); - } - /* - * Initialize object file hacking variables - */ - Object_Record_Offset = 0; - Current_Object_Record_Type = -1; -} - - -/* - * Declare a particular type of object file record - */ -Set_VMS_Object_File_Record(Type) -int Type; -{ - /* - * If the type matches, we are done - */ - if (Type == Current_Object_Record_Type) return; - /* - * Otherwise: flush the buffer - */ - Flush_VMS_Object_Record_Buffer(); - /* - * Set the new type - */ - Current_Object_Record_Type = Type; -} - - -/* - * Flush the object record buffer to the object file - */ -Flush_VMS_Object_Record_Buffer() -{ - int i; - - /* - * If the buffer is empty, we are done - */ - if (Object_Record_Offset == 0) return; - /* - * Write the data to the file - */ - i= write(VMS_Object_File_FD, - Object_Record_Buffer, - Object_Record_Offset); - if (i != Object_Record_Offset) - error("I/O error writing VMS object file"); - /* - * The buffer is now empty - */ - Object_Record_Offset = 0; -} - - -/* - * Close the VMS Object file - */ -Close_VMS_Object_File() -{ - close(VMS_Object_File_FD); -} - - -/* - * Write the MHD (Module Header) records - */ -Write_VMS_MHD_Records() -{ - register char *cp,*cp1; - register int i; - struct {int Size; char *Ptr;} Descriptor; - char Module_Name[256]; - char Now[17]; - - /* - * We are writing a module header record - */ - Set_VMS_Object_File_Record(OBJ$C_HDR); - /* - * *************************** - * *MAIN MODULE HEADER RECORD* - * *************************** - * - * Store record type and header type - */ - PUT_CHAR(OBJ$C_HDR); - PUT_CHAR(MHD$C_MHD); - /* - * Structure level is 0 - */ - PUT_CHAR(OBJ$C_STRLVL); - /* - * Maximum record size is size of the object record buffer - */ - PUT_SHORT(sizeof(Object_Record_Buffer)); - /* - * Get module name (the FILENAME part of the object file) - */ - cp = out_file_name; - cp1 = Module_Name; - while(*cp) { - if ((*cp == ']') || (*cp == '>') || - (*cp == ':') || (*cp == '/')) { - cp1 = Module_Name; - cp++; - continue; - } - *cp1++ = islower(*cp) ? toupper(*cp++) : *cp++; - } - *cp1 = 0; - /* - * Limit it to 31 characters and store in the object record - */ - while(--cp1 >= Module_Name) - if (*cp1 == '.') *cp1 = 0; - if (strlen(Module_Name) > 31) { - if(flagseen['+']) - printf("%s: Module name truncated: %s\n", myname, Module_Name); - Module_Name[31] = 0; - } - PUT_COUNTED_STRING(Module_Name); - /* - * Module Version is "V1.0" - */ - PUT_COUNTED_STRING("V1.0"); - /* - * Creation time is "now" (17 chars of time string) - */ - Descriptor.Size = 17; - Descriptor.Ptr = Now; - sys$asctim(0,&Descriptor,0,0); - for(i = 0; i < 17; i++) PUT_CHAR(Now[i]); - /* - * Patch time is "never" (17 zeros) - */ - for(i = 0; i < 17; i++) PUT_CHAR(0); - /* - * Flush the record - */ - Flush_VMS_Object_Record_Buffer(); - /* - * ************************* - * *LANGUAGE PROCESSOR NAME* - * ************************* - * - * Store record type and header type - */ - PUT_CHAR(OBJ$C_HDR); - PUT_CHAR(MHD$C_LNM); - /* - * Store language processor name and version - * (not a counted string!) - */ - cp = compiler_version_string; - if (cp == 0) { - cp ="GNU AS V"; - while(*cp) PUT_CHAR(*cp++); - cp = strchr(&version_string,'.'); - while(*cp != ' ') cp--; cp++; - }; - while(*cp >= 32) PUT_CHAR(*cp++); - /* - * Flush the record - */ - Flush_VMS_Object_Record_Buffer(); -} - - -/* - * Write the EOM (End Of Module) record - */ -Write_VMS_EOM_Record(Psect, Offset) -int Psect; -int Offset; -{ - /* - * We are writing an end-of-module record - */ - Set_VMS_Object_File_Record(OBJ$C_EOM); - /* - * Store record Type - */ - PUT_CHAR(OBJ$C_EOM); - /* - * Store the error severity (0) - */ - PUT_CHAR(0); - /* - * Store the entry point, if it exists - */ - if (Psect >= 0) { - /* - * Store the entry point Psect - */ - PUT_CHAR(Psect); - /* - * Store the entry point Psect offset - */ - PUT_LONG(Offset); - } - /* - * Flush the record - */ - Flush_VMS_Object_Record_Buffer(); -} - - -/* this hash routine borrowed from GNU-EMACS, and strengthened slightly ERY*/ - -static int -hash_string (ptr) - unsigned char *ptr; -{ - register unsigned char *p = ptr; - register unsigned char *end = p + strlen(ptr); - register unsigned char c; - register int hash = 0; - - while (p != end) - { - c = *p++; - hash = ((hash<<3) + (hash<<15) + (hash>>28) + c); - } - return hash; -} - -/* - * Generate a Case-Hacked VMS symbol name (limited to 31 chars) - */ -VMS_Case_Hack_Symbol(In,Out) -register char *In; -register char *Out; -{ - long int init = 0; - long int result; - char *pnt; - char *new_name; - char *old_name; - register int i; - int destructor = 0; /*hack to allow for case sens in a destructor*/ - int truncate = 0; - int Case_Hack_Bits = 0; - int Saw_Dollar = 0; - static char Hex_Table[16] = - {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'}; - - /* - * Kill any leading "_" - */ - if (*In == '_') In++; - - new_name=Out; /* save this for later*/ - - if((In[0]=='_')&&(In[1]=='$')&&(In[2]=='_')) - destructor=1; - - /* We may need to truncate the symbol, save the hash for later*/ - if(strlen(In)>23) result = hash_string(In); - /* - * Is there a Psect Attribute to skip?? - */ - if (HAS_PSECT_ATTRIBUTES(In)) { - /* - * Yes: Skip it - */ - In += PSECT_ATTRIBUTES_STRING_LENGTH; - while(*In) { - if ((In[0] == '$') && (In[1] == '$')) { - In += 2; - break; - } - In++; - } - } - - old_name=In; -/* if(strlen(In) > 31 && flagseen['+']) - printf("%s: Symbol name truncated: %s\n",myname,In);*/ - /* - * Do the case conversion - */ - i = 23; /* Maximum of 23 chars */ - while(*In && (--i >= 0)) { - Case_Hack_Bits <<= 1; - if (*In == '$') Saw_Dollar = 1; - if ((destructor==1)&&(i==21)) Saw_Dollar = 0; - if (isupper(*In)) { - *Out++ = *In++; - Case_Hack_Bits |= 1; - } else { - *Out++ = islower(*In) ? toupper(*In++) : *In++; - } - } - /* - * If we saw a dollar sign, we don't do case hacking - */ - if(flagseen['h'] || Saw_Dollar) - Case_Hack_Bits = 0; - - /* - * If we have more than 23 characters and everything is lowercase - * we can insert the full 31 characters - */ - if (*In) { - /* - * We have more than 23 characters - * If we must add the case hack, then we have truncated the str - */ - pnt=Out; - truncate=1; - if (Case_Hack_Bits == 0) { - /* - * And so far they are all lower case: - * Check up to 8 more characters - * and ensure that they are lowercase - */ - if(flagseen['h']) - i=8; - else - for(i = 0; (In[i] != 0) && (i < 8); i++) - if (isupper(In[i]) && !Saw_Dollar) - break; - if(In[i]==0) - truncate=0; - - if ((i >= 8) || (In[i] == 0)) { - /* - * They are: Copy up to 31 characters - * to the output string - */ - i = 8; - while((--i >= 0) && (*In)) - *Out++ = islower(*In) ? - toupper(*In++) : - *In++; - } - } - } - /* - * If there were any uppercase characters in the name we - * take on the case hacking string - */ - - /* Old behavior for regular GNU-C compiler */ - if (!flagseen['+']) - truncate=0; - if ((Case_Hack_Bits != 0)||(truncate==1)) { - if(truncate==0) { - *Out++ = '_'; - for(i = 0; i < 6; i++) { - *Out++ = Hex_Table[Case_Hack_Bits & 0xf]; - Case_Hack_Bits >>= 4; - } - *Out++ = 'X'; - } else { - Out=pnt; /*Cut back to 23 characters maximum */ - *Out++ = '_'; - for( i=0; i < 7; i++) { - init = result & 0x01f; - if (init < 10) - *Out++='0'+init; - else - *Out++ = 'A'+init-10; - result = result >> 5; - } - } - } /*Case Hack */ - /* - * Done - */ - *Out = 0; - if( truncate==1 && flagseen['+'] && flagseen['H']) - printf("%s: Symbol %s replaced by %s\n",myname,old_name,new_name); -} - - -/* - * Scan a symbol name for a psect attribute specification - */ -VMS_Modify_Psect_Attributes(Name, Attribute_Pointer) -char *Name; -int *Attribute_Pointer; -{ - register int i; - register char *cp; - int Negate; - static struct { - char *Name; - int Value; - } Attributes[] = { - {"PIC", GPS$M_PIC}, - {"LIB", GPS$M_LIB}, - {"OVR", GPS$M_OVR}, - {"REL", GPS$M_REL}, - {"GBL", GPS$M_GBL}, - {"SHR", GPS$M_SHR}, - {"EXE", GPS$M_EXE}, - {"RD", GPS$M_RD}, - {"WRT", GPS$M_WRT}, - {"VEC", GPS$M_VEC}, - {0, 0}}; - - /* - * Kill leading "_" - */ - if (*Name == '_') Name++; - /* - * Check for a PSECT attribute list - */ - if (!HAS_PSECT_ATTRIBUTES(Name)) return; /* If not, return */ - /* - * Skip the attribute list indicator - */ - Name += PSECT_ATTRIBUTES_STRING_LENGTH; - /* - * Process the attributes ("_" separated, "$" terminated) - */ - while(*Name != '$') { - /* - * Assume not negating - */ - Negate = 0; - /* - * Check for "NO" - */ - if ((Name[0] == 'N') && (Name[1] == 'O')) { - /* - * We are negating (and skip the NO) - */ - Negate = 1; - Name += 2; - } - /* - * Find the token delimiter - */ - cp = Name; - while(*cp && (*cp != '_') && (*cp != '$')) cp++; - /* - * Look for the token in the attribute list - */ - for(i = 0; Attributes[i].Name; i++) { - /* - * If the strings match, set/clear the attr. - */ - if (strncmp(Name, Attributes[i].Name, cp - Name) == 0) { - /* - * Set or clear - */ - if (Negate) - *Attribute_Pointer &= - ~Attributes[i].Value; - else - *Attribute_Pointer |= - Attributes[i].Value; - /* - * Done - */ - break; - } - } - /* - * Now skip the attribute - */ - Name = cp; - if (*Name == '_') Name++; - } - /* - * Done - */ - return; -} - - -/* - * Define a psect - */ -VMS_Psect_Spec(Name, Size, Type) -char *Name; -int Size; -char *Type; -{ - char Local[32]; - int Psect_Attributes; - - /* - * We are writing a GSD record - */ - Set_VMS_Object_File_Record(OBJ$C_GSD); - /* - * If the buffer is empty we must insert the GSD record type - */ - if (Object_Record_Offset == 0) PUT_CHAR(OBJ$C_GSD); - /* - * We are writing a PSECT definition subrecord - */ - PUT_CHAR(GSD$C_PSC); - /* - * Psects are always LONGWORD aligned - */ - PUT_CHAR(2); - /* - * Generate the appropriate PSECT flags given the PSECT type - */ - if (strcmp(Type,"COMMON") == 0) { - /* - * Common block psects are: PIC,OVR,REL,GBL,SHR,RD,WRT - */ - Psect_Attributes = (GPS$M_PIC|GPS$M_OVR|GPS$M_REL|GPS$M_GBL| - GPS$M_SHR|GPS$M_RD|GPS$M_WRT); - } else if (strcmp(Type,"CONST") == 0) { - /* - * Common block psects are: PIC,OVR,REL,GBL,SHR,RD - */ - Psect_Attributes = (GPS$M_PIC|GPS$M_OVR|GPS$M_REL|GPS$M_GBL| - GPS$M_SHR|GPS$M_RD); - } else if (strcmp(Type,"DATA") == 0) { - /* - * The Data psects are PIC,REL,RD,WRT - */ - Psect_Attributes = - (GPS$M_PIC|GPS$M_REL|GPS$M_RD|GPS$M_WRT); - } else if (strcmp(Type,"TEXT") == 0) { - /* - * The Text psects are PIC,REL,SHR,EXE,RD - */ - Psect_Attributes = - (GPS$M_PIC|GPS$M_REL|GPS$M_SHR| - GPS$M_EXE|GPS$M_RD); - } else { - /* - * Error: Unknown psect type - */ - error("Unknown VMS psect type"); - } - /* - * Modify the psect attributes according to any attribute string - */ - if (HAS_PSECT_ATTRIBUTES(Name)) - VMS_Modify_Psect_Attributes(Name,&Psect_Attributes); - /* - * Specify the psect attributes - */ - PUT_SHORT(Psect_Attributes); - /* - * Specify the allocation - */ - PUT_LONG(Size); - /* - * Finally, the psect name - */ - VMS_Case_Hack_Symbol(Name,Local); - PUT_COUNTED_STRING(Local); - /* - * Flush the buffer if it is more than 75% full - */ - if (Object_Record_Offset > - (sizeof(Object_Record_Buffer)*3/4)) - Flush_VMS_Object_Record_Buffer(); -} - - -/* - * Define a global symbol - */ -VMS_Global_Symbol_Spec(Name, Psect_Number, Psect_Offset, Defined) -char *Name; -int Psect_Number; -int Psect_Offset; -{ - char Local[32]; - - /* - * We are writing a GSD record - */ - Set_VMS_Object_File_Record(OBJ$C_GSD); - /* - * If the buffer is empty we must insert the GSD record type - */ - if (Object_Record_Offset == 0) PUT_CHAR(OBJ$C_GSD); - /* - * We are writing a Global symbol definition subrecord - */ - if (Psect_Number <= 255) { - PUT_CHAR(GSD$C_SYM); - } else { - PUT_CHAR(GSD$C_SYMW); - } - /* - * Data type is undefined - */ - PUT_CHAR(0); - /* - * Switch on Definition/Reference - */ - if (Defined) { - /* - * Definition: - * Flags = "RELOCATABLE" and "DEFINED" - */ - PUT_SHORT(GSY$M_DEF|GSY$M_REL); - /* - * Psect Number - */ - if (Psect_Number <= 255) { - PUT_CHAR(Psect_Number); - } else { - PUT_SHORT(Psect_Number); - } - /* - * Offset - */ - PUT_LONG(Psect_Offset); - } else { - /* - * Reference: - * Flags = "RELOCATABLE" - */ - PUT_SHORT(GSY$M_REL); - } - /* - * Finally, the global symbol name - */ - VMS_Case_Hack_Symbol(Name,Local); - PUT_COUNTED_STRING(Local); - /* - * Flush the buffer if it is more than 75% full - */ - if (Object_Record_Offset > - (sizeof(Object_Record_Buffer)*3/4)) - Flush_VMS_Object_Record_Buffer(); -} - - -/* - * Define a procedure entry pt/mask - */ -VMS_Procedure_Entry_Pt(Name, Psect_Number, Psect_Offset, Entry_Mask) -char *Name; -int Psect_Number; -int Psect_Offset; -int Entry_Mask; -{ - char Local[32]; - - /* - * We are writing a GSD record - */ - Set_VMS_Object_File_Record(OBJ$C_GSD); - /* - * If the buffer is empty we must insert the GSD record type - */ - if (Object_Record_Offset == 0) PUT_CHAR(OBJ$C_GSD); - /* - * We are writing a Procedure Entry Pt/Mask subrecord - */ - if (Psect_Number <= 255) { - PUT_CHAR(GSD$C_EPM); - } else { - PUT_CHAR(GSD$C_EPMW); - } - /* - * Data type is undefined - */ - PUT_CHAR(0); - /* - * Flags = "RELOCATABLE" and "DEFINED" - */ - PUT_SHORT(GSY$M_DEF|GSY$M_REL); - /* - * Psect Number - */ - if (Psect_Number <= 255) { - PUT_CHAR(Psect_Number); - } else { - PUT_SHORT(Psect_Number); - } - /* - * Offset - */ - PUT_LONG(Psect_Offset); - /* - * Entry mask - */ - PUT_SHORT(Entry_Mask); - /* - * Finally, the global symbol name - */ - VMS_Case_Hack_Symbol(Name,Local); - PUT_COUNTED_STRING(Local); - /* - * Flush the buffer if it is more than 75% full - */ - if (Object_Record_Offset > - (sizeof(Object_Record_Buffer)*3/4)) - Flush_VMS_Object_Record_Buffer(); -} - - -/* - * Set the current location counter to a particular Psect and Offset - */ -VMS_Set_Psect(Psect_Index, Offset, Record_Type) -int Psect_Index; -int Offset; -int Record_Type; -{ - /* - * We are writing a "Record_Type" record - */ - Set_VMS_Object_File_Record(Record_Type); - /* - * If the buffer is empty we must insert the record type - */ - if (Object_Record_Offset == 0) PUT_CHAR(Record_Type); - /* - * Stack the Psect base + Longword Offset - */ - if (Psect_Index < 255) { - PUT_CHAR(TIR$C_STA_PL); - PUT_CHAR(Psect_Index); - } else { - PUT_CHAR(TIR$C_STA_WPL); - PUT_SHORT(Psect_Index); - } - PUT_LONG(Offset); - /* - * Set relocation base - */ - PUT_CHAR(TIR$C_CTL_SETRB); - /* - * Flush the buffer if it is more than 75% full - */ - if (Object_Record_Offset > - (sizeof(Object_Record_Buffer)*3/4)) - Flush_VMS_Object_Record_Buffer(); -} - -/* - * Make a data reference - */ -VMS_Set_Data(Psect_Index, Offset, Record_Type,Force) -int Psect_Index; -int Offset; -int Record_Type; -int Force; -{ - /* - * We are writing a "Record_Type" record - */ - Set_VMS_Object_File_Record(Record_Type); - /* - * If the buffer is empty we must insert the record type - */ - if (Object_Record_Offset == 0) PUT_CHAR(Record_Type); - /* - * Stack the Psect base + Longword Offset - */ - if(Force==1){ - if(Psect_Index>127){ - PUT_CHAR(TIR$C_STA_WPL); - PUT_SHORT(Psect_Index); - PUT_LONG(Offset);} - else { - PUT_CHAR(TIR$C_STA_PL); - PUT_CHAR(Psect_Index); - PUT_LONG(Offset);} - } else {if(Offset>32767){ - PUT_CHAR(TIR$C_STA_WPL); - PUT_SHORT(Psect_Index); - PUT_LONG(Offset);} - else if(Offset>127){ - PUT_CHAR(TIR$C_STA_WPW); - PUT_SHORT(Psect_Index); - PUT_SHORT(Offset);} - else{ - PUT_CHAR(TIR$C_STA_WPB); - PUT_SHORT(Psect_Index); - PUT_CHAR(Offset);};}; - /* - * Set relocation base - */ - PUT_CHAR(TIR$C_STO_PIDR); - /* - * Flush the buffer if it is more than 75% full - */ - if (Object_Record_Offset > - (sizeof(Object_Record_Buffer)*3/4)) - Flush_VMS_Object_Record_Buffer(); -} - -/* - * Make a debugger reference to a struct, union or enum. - */ -VMS_Store_Struct(int Struct_Index) -{ - /* - * We are writing a "OBJ$C_DBG" record - */ - Set_VMS_Object_File_Record(OBJ$C_DBG); - /* - * If the buffer is empty we must insert the record type - */ - if (Object_Record_Offset == 0) PUT_CHAR(OBJ$C_DBG); - PUT_CHAR(TIR$C_STA_UW); - PUT_SHORT(Struct_Index); - PUT_CHAR(TIR$C_CTL_STKDL); - PUT_CHAR(TIR$C_STO_L); - /* - * Flush the buffer if it is more than 75% full - */ - if (Object_Record_Offset > - (sizeof(Object_Record_Buffer)*3/4)) - Flush_VMS_Object_Record_Buffer(); -} - -/* - * Make a debugger reference to partially define a struct, union or enum. - */ -VMS_Def_Struct(int Struct_Index) -{ - /* - * We are writing a "OBJ$C_DBG" record - */ - Set_VMS_Object_File_Record(OBJ$C_DBG); - /* - * If the buffer is empty we must insert the record type - */ - if (Object_Record_Offset == 0) PUT_CHAR(OBJ$C_DBG); - PUT_CHAR(TIR$C_STA_UW); - PUT_SHORT(Struct_Index); - PUT_CHAR(TIR$C_CTL_DFLOC); - /* - * Flush the buffer if it is more than 75% full - */ - if (Object_Record_Offset > - (sizeof(Object_Record_Buffer)*3/4)) - Flush_VMS_Object_Record_Buffer(); -} - -VMS_Set_Struct(int Struct_Index) -{/* see previous functions for comments */ - Set_VMS_Object_File_Record(OBJ$C_DBG); - if (Object_Record_Offset == 0) PUT_CHAR(OBJ$C_DBG); - PUT_CHAR(TIR$C_STA_UW); - PUT_SHORT(Struct_Index); - PUT_CHAR(TIR$C_CTL_STLOC); - if (Object_Record_Offset > - (sizeof(Object_Record_Buffer)*3/4)) - Flush_VMS_Object_Record_Buffer(); -} - -/* - * Store immediate data in current Psect - */ -VMS_Store_Immediate_Data(Pointer, Size, Record_Type) -register char *Pointer; -int Size; -int Record_Type; -{ - register int i; - - /* - * We are writing a "Record_Type" record - */ - Set_VMS_Object_File_Record(Record_Type); - /* - * We can only store 128 bytes at a time - */ - while(Size > 0) { - /* - * Store a maximum of 128 bytes - */ - i = (Size > 128) ? 128 : Size; - Size -= i; - /* - * If we cannot accommodate this record, flush the - * buffer. - */ - if ((Object_Record_Offset + i + 1) >= - sizeof(Object_Record_Buffer)) - Flush_VMS_Object_Record_Buffer(); - /* - * If the buffer is empty we must insert record type - */ - if (Object_Record_Offset == 0) PUT_CHAR(Record_Type); - /* - * Store the count - */ - PUT_CHAR(-i & 0xff); - /* - * Store the data - */ - while(--i >= 0) PUT_CHAR(*Pointer++); - /* - * Flush the buffer if it is more than 75% full - */ - if (Object_Record_Offset > - (sizeof(Object_Record_Buffer)*3/4)) - Flush_VMS_Object_Record_Buffer(); - } -} - - -/* - * Store repeated immediate data in current Psect - */ -VMS_Store_Repeated_Data(Repeat_Count,Pointer, Size, Record_Type) -int Repeat_Count; -register char *Pointer; -int Size; -int Record_Type; -{ - - /* - * Ignore zero bytes/words/longwords - */ - if ((Size == sizeof(char)) && (*Pointer == 0)) return; - if ((Size == sizeof(short)) && (*(short *)Pointer == 0)) return; - if ((Size == sizeof(long)) && (*(long *)Pointer == 0)) return; - /* - * If the data is too big for a TIR$C_STO_RIVB sub-record - * then we do it manually - */ - if (Size > 255) { - while(--Repeat_Count >= 0) - VMS_Store_Immediate_Data(Pointer,Size,Record_Type); - return; - } - /* - * We are writing a "Record_Type" record - */ - Set_VMS_Object_File_Record(Record_Type); - /* - * If the buffer is empty we must insert record type - */ - if (Object_Record_Offset == 0) PUT_CHAR(Record_Type); - /* - * Stack the repeat count - */ - PUT_CHAR(TIR$C_STA_LW); - PUT_LONG(Repeat_Count); - /* - * And now the command and its data - */ - PUT_CHAR(TIR$C_STO_RIVB); - PUT_CHAR(Size); - while(--Size >= 0) PUT_CHAR(*Pointer++); - /* - * Flush the buffer if it is more than 75% full - */ - if (Object_Record_Offset > - (sizeof(Object_Record_Buffer)*3/4)) - Flush_VMS_Object_Record_Buffer(); -} - - -/* - * Store a Position Independent Reference - */ -VMS_Store_PIC_Symbol_Reference(Symbol, Offset, PC_Relative, - Psect, Psect_Offset, Record_Type) -struct symbol *Symbol; -int Offset; -int PC_Relative; -int Psect; -int Psect_Offset; -int Record_Type; -{ - register struct VMS_Symbol *vsp = - (struct VMS_Symbol *)(Symbol->sy_number); - char Local[32]; - - /* - * We are writing a "Record_Type" record - */ - Set_VMS_Object_File_Record(Record_Type); - /* - * If the buffer is empty we must insert record type - */ - if (Object_Record_Offset == 0) PUT_CHAR(Record_Type); - /* - * Set to the appropriate offset in the Psect - */ - if (PC_Relative) { - /* - * For a Code reference we need to fix the operand - * specifier as well (so back up 1 byte) - */ - VMS_Set_Psect(Psect, Psect_Offset - 1, Record_Type); - } else { - /* - * For a Data reference we just store HERE - */ - VMS_Set_Psect(Psect, Psect_Offset, Record_Type); - } - /* - * Make sure we are still generating a "Record Type" record - */ - if (Object_Record_Offset == 0) PUT_CHAR(Record_Type); - /* - * Dispatch on symbol type (so we can stack its value) - */ - switch(Symbol->sy_nlist.n_type) { - /* - * Global symbol - */ -#ifdef NOT_VAX_11_C_COMPATIBLE - case N_UNDF | N_EXT: - case N_DATA | N_EXT: -#endif NOT_VAX_11_C_COMPATIBLE - case N_UNDF: - case N_TEXT | N_EXT: - /* - * Get the symbol name (case hacked) - */ - VMS_Case_Hack_Symbol(Symbol->sy_nlist.n_un.n_name,Local); - /* - * Stack the global symbol value - */ - PUT_CHAR(TIR$C_STA_GBL); - PUT_COUNTED_STRING(Local); - if (Offset) { - /* - * Stack the longword offset - */ - PUT_CHAR(TIR$C_STA_LW); - PUT_LONG(Offset); - /* - * Add the two, leaving the result on the stack - */ - PUT_CHAR(TIR$C_OPR_ADD); - } - break; - /* - * Uninitialized local data - */ - case N_BSS: - /* - * Stack the Psect (+offset) - */ - if (vsp->Psect_Index < 255) { - PUT_CHAR(TIR$C_STA_PL); - PUT_CHAR(vsp->Psect_Index); - } else { - PUT_CHAR(TIR$C_STA_WPL); - PUT_SHORT(vsp->Psect_Index); - } - PUT_LONG(vsp->Psect_Offset + Offset); - break; - /* - * Local text - */ - case N_TEXT: - /* - * Stack the Psect (+offset) - */ - if (vsp->Psect_Index < 255) { - PUT_CHAR(TIR$C_STA_PL); - PUT_CHAR(vsp->Psect_Index); - } else { - PUT_CHAR(TIR$C_STA_WPL); - PUT_SHORT(vsp->Psect_Index); - } - PUT_LONG(Symbol->sy_nlist.n_value); - break; - /* - * Initialized local or global data - */ - case N_DATA: -#ifndef NOT_VAX_11_C_COMPATIBLE - case N_UNDF | N_EXT: - case N_DATA | N_EXT: -#endif NOT_VAX_11_C_COMPATIBLE - /* - * Stack the Psect (+offset) - */ - if (vsp->Psect_Index < 255) { - PUT_CHAR(TIR$C_STA_PL); - PUT_CHAR(vsp->Psect_Index); - } else { - PUT_CHAR(TIR$C_STA_WPL); - PUT_SHORT(vsp->Psect_Index); - } - PUT_LONG(vsp->Psect_Offset + Offset); - break; - } - /* - * Store either a code or data reference - */ - PUT_CHAR(PC_Relative ? TIR$C_STO_PICR : TIR$C_STO_PIDR); - /* - * Flush the buffer if it is more than 75% full - */ - if (Object_Record_Offset > - (sizeof(Object_Record_Buffer)*3/4)) - Flush_VMS_Object_Record_Buffer(); -} - - -/* - * Check in the text area for an indirect pc-relative reference - * and fix it up with addressing mode 0xff [PC indirect] - * - * THIS SHOULD BE REPLACED BY THE USE OF TIR$C_STO_PIRR IN THE - * PIC CODE GENERATING FIXUP ROUTINE. - */ -VMS_Fix_Indirect_Reference(Text_Psect, Offset, fragP, text_frag_root) -int Text_Psect; -int Offset; -register fragS *fragP; -struct frag *text_frag_root; -{ - /* - * The addressing mode byte is 1 byte before the address - */ - Offset--; - /* - * Is it in THIS frag?? - */ - if ((Offset < fragP->fr_address) || - (Offset >= (fragP->fr_address + fragP->fr_fix))) { - /* - * We need to search for the fragment containing this - * Offset - */ - for(fragP = text_frag_root; fragP; fragP = fragP->fr_next) { - if ((Offset >= fragP->fr_address) && - (Offset < (fragP->fr_address + fragP->fr_fix))) - break; - } - /* - * If we couldn't find the frag, things are BAD!! - */ - if (fragP == 0) - error("Couldn't find fixup fragment when checking for indirect reference"); - } - /* - * Check for indirect PC relative addressing mode - */ - if (fragP->fr_literal[Offset - fragP->fr_address] == (char)0xff) { - static char Address_Mode = 0xff; - - /* - * Yes: Store the indirect mode back into the image - * to fix up the damage done by STO_PICR - */ - VMS_Set_Psect(Text_Psect,Offset,OBJ$C_TIR); - VMS_Store_Immediate_Data(&Address_Mode,1,OBJ$C_TIR); - } -} - - -/* - * Write the Traceback Module Begin record - */ -VMS_TBT_Module_Begin() -{ - register char *cp,*cp1; - int Size; - char Module_Name[256]; - char Local[256]; - - /* - * Get module name (the FILENAME part of the object file) - */ - cp = out_file_name; - cp1 = Module_Name; - while(*cp) { - if ((*cp == ']') || (*cp == '>') || - (*cp == ':') || (*cp == '/')) { - cp1 = Module_Name; - cp++; - continue; - } - *cp1++ = islower(*cp) ? toupper(*cp++) : *cp++; - } - *cp1 = 0; - /* - * Limit it to 31 characters - */ - while(--cp1 >= Module_Name) - if (*cp1 == '.') *cp1 = 0; - if (strlen(Module_Name) > 31) { - if(flagseen['+']) - printf("%s: Module name truncated: %s\n",myname, Module_Name); - Module_Name[31] = 0; - } - /* - * Arrange to store the data locally (leave room for size byte) - */ - cp = Local+1; - /* - * Begin module - */ - *cp++ = DST$C_MODBEG; - /* - * Unused - */ - *cp++ = 0; - /* - * Language type == "C" - */ - *(long *)cp = DST$C_C; - cp += sizeof(long); - /* - * Store the module name - */ - *cp++ = strlen(Module_Name); - cp1 = Module_Name; - while(*cp1) *cp++ = *cp1++; - /* - * Now we can store the record size - */ - Size = (cp - Local); - Local[0] = Size-1; - /* - * Put it into the object record - */ - VMS_Store_Immediate_Data(Local, Size, OBJ$C_TBT); -} - - -/* - * Write the Traceback Module End record -*/ -VMS_TBT_Module_End() -{ - char Local[2]; - - /* - * End module - */ - Local[0] = 1; - Local[1] = DST$C_MODEND; - /* - * Put it into the object record - */ - VMS_Store_Immediate_Data(Local, 2, OBJ$C_TBT); -} - - -/* - * Write the Traceback Routine Begin record - */ -VMS_TBT_Routine_Begin(symbolP, Psect) -struct symbol *symbolP; -int Psect; -{ - register char *cp,*cp1; - char *Name; - int Offset; - int Size; - char Local[512]; - - /* - * Strip the leading "_" from the name - */ - Name = symbolP->sy_nlist.n_un.n_name; - if (*Name == '_') Name++; - /* - * Get the text psect offset - */ - Offset = symbolP->sy_nlist.n_value; - /* - * Calculate the record size - */ - Size = 1+1+4+1+strlen(Name); - /* - * Record Size - */ - Local[0] = Size; - /* - * Begin Routine - */ - Local[1] = DST$C_RTNBEG; - /* - * Uses CallS/CallG - */ - Local[2] = 0; - /* - * Store the data so far - */ - VMS_Store_Immediate_Data(Local, 3, OBJ$C_TBT); - /* - * Make sure we are still generating a OBJ$C_TBT record - */ - if (Object_Record_Offset == 0) PUT_CHAR(OBJ$C_TBT); - /* - * Now get the symbol address - */ - PUT_CHAR(TIR$C_STA_WPL); - PUT_SHORT(Psect); - PUT_LONG(Offset); - /* - * Store the data reference - */ - PUT_CHAR(TIR$C_STO_PIDR); - /* - * Store the counted string as data - */ - cp = Local; - cp1 = Name; - Size = strlen(cp1) + 1; - *cp++ = Size - 1; - while(*cp1) *cp++ = *cp1++; - VMS_Store_Immediate_Data(Local, Size, OBJ$C_TBT); -} - - -/* - * Write the Traceback Routine End record - * We *must* search the symbol table to find the next routine, since - * the assember has a way of reassembling the symbol table OUT OF ORDER - * Thus the next routine in the symbol list is not necessarily the - * next one in memory. For debugging to work correctly we must know the - * size of the routine. - */ -VMS_TBT_Routine_End(Max_Size,sp) -int Max_Size; -symbolS *sp; -{ - symbolS *symbolP; - int Size = 0x7fffffff; - char Local[16]; - - - for(symbolP = symbol_rootP; symbolP; symbolP = symbol_next(symbolP)) { - if ((symbolP->sy_nlist.n_type & ~N_EXT) == N_TEXT) { - if (symbolP->sy_nlist.n_un.n_name[0] == 'L') continue; - if((symbolP->sy_nlist.n_value > sp->sy_nlist.n_value) && - (symbolP->sy_nlist.n_value < Size )) - Size = symbolP->sy_nlist.n_value; - /* check if gcc_compiled. has size of zero */ - if((symbolP->sy_nlist.n_value == sp->sy_nlist.n_value) && - sp != symbolP && - !strcmp(sp->sy_nlist.n_un.n_name,"gcc_compiled.")) - Size = symbolP->sy_nlist.n_value; - - }; - }; - if(Size == 0x7fffffff) Size = Max_Size; - Size -= sp->sy_nlist.n_value; /* and get the size of the routine */ - /* - * Record Size - */ - Local[0] = 6; - /* - * End of Routine - */ - Local[1] = DST$C_RTNEND; - /* - * Unused - */ - Local[2] = 0; - /* - * Size of routine - */ - *((long *)(Local+3)) = Size; - /* - * Store the record - */ - VMS_Store_Immediate_Data(Local,7, OBJ$C_TBT); -} -/* - * Write the Traceback Block End record - */ -VMS_TBT_Block_Begin(symbolP, Psect, Name) -struct symbol *symbolP; -int Psect; -char* Name; -{ - register char *cp,*cp1; - int Offset; - int Size; - char Local[512]; - /* - * Begin block - */ - Size = 1+1+4+1+strlen(Name); - /* - * Record Size - */ - Local[0] = Size; - /* - * Begin Block - We simulate with a phony routine - */ - Local[1] = DST$C_BLKBEG; - /* - * Uses CallS/CallG - */ - Local[2] = 0; - /* - * Store the data so far - */ - VMS_Store_Immediate_Data(Local, 3, OBJ$C_DBG); - /* - * Make sure we are still generating a OBJ$C_DBG record - */ - if (Object_Record_Offset == 0) PUT_CHAR(OBJ$C_DBG); - /* - * Now get the symbol address - */ - PUT_CHAR(TIR$C_STA_WPL); - PUT_SHORT(Psect); - /* - * Get the text psect offset - */ - Offset = symbolP->sy_nlist.n_value; - PUT_LONG(Offset); - /* - * Store the data reference - */ - PUT_CHAR(TIR$C_STO_PIDR); - /* - * Store the counted string as data - */ - cp = Local; - cp1 = Name; - Size = strlen(cp1) + 1; - *cp++ = Size - 1; - while(*cp1) *cp++ = *cp1++; - VMS_Store_Immediate_Data(Local, Size, OBJ$C_DBG); -} - - -/* - * Write the Traceback Block End record - */ -VMS_TBT_Block_End(int Size) -{ - char Local[16]; - - /* - * End block - simulate with a phony end routine - */ - Local[0] = 6; - Local[1] = DST$C_BLKEND; - *((long *)(Local+3)) = Size; - /* - * Unused - */ - Local[2] = 0; - VMS_Store_Immediate_Data(Local,7, OBJ$C_DBG); -} - - - -/* - * Write a Line number / PC correlation record - */ -VMS_TBT_Line_PC_Correlation(Line_Number, Offset, Psect, Do_Delta) -int Line_Number; -int Offset; -int Psect; -int Do_Delta; -{ - register char *cp; - char Local[64]; - - /* -* If not delta, set our PC/Line number correlation -*/ - if (Do_Delta == 0) { - /* - * Size - */ - Local[0] = 1+1+2+1+4; - /* - * Line Number/PC correlation - */ - Local[1] = DST$C_LINE_NUM; - /* - * Set Line number - */ - Local[2] = DST$C_SET_LINE_NUM; - *((unsigned short *)(Local+3)) = Line_Number-1; - /* - * Set PC - */ - Local[5] = DST$C_SET_ABS_PC; - VMS_Store_Immediate_Data(Local, 6, OBJ$C_TBT); - /* - * Make sure we are still generating a OBJ$C_TBT record - */ - if (Object_Record_Offset == 0) PUT_CHAR(OBJ$C_TBT); - if (Psect < 255) { - PUT_CHAR(TIR$C_STA_PL); - PUT_CHAR(Psect); - } else { - PUT_CHAR(TIR$C_STA_WPL); - PUT_SHORT(Psect); - } - PUT_LONG(Offset); - PUT_CHAR(TIR$C_STO_PIDR); - /* - * Do a PC offset of 0 to register the line number - */ - Local[0] = 2; - Local[1] = DST$C_LINE_NUM; - Local[2] = 0; /* Increment PC by 0 and register line # */ - VMS_Store_Immediate_Data(Local, 3, OBJ$C_TBT); - } else { - /* - * If Delta is negative, terminate the line numbers - */ - if (Do_Delta < 0) { - Local[0] = 1+1+4; - Local[1] = DST$C_LINE_NUM; - Local[2] = DST$C_TERM_L; - *((long *)(Local+3)) = Offset; - VMS_Store_Immediate_Data(Local, 7, OBJ$C_TBT); - /* - * Done - */ - return; - } - /* - * Do a PC/Line delta - */ - cp = Local+1; - *cp++ = DST$C_LINE_NUM; - if (Line_Number > 1) { - /* - * We need to increment the line number - */ - if (Line_Number-1 <= 255) { - *cp++ = DST$C_INCR_LINUM; - *cp++ = Line_Number-1; - } else { - *cp++ = DST$C_INCR_LINUM_W; - *(short *)cp = Line_Number-1; - cp += sizeof(short); - } - } - /* - * Increment the PC - */ - if (Offset <= 128) { - *cp++ = -Offset; - } else { - if (Offset < 0x10000) { - *cp++ = DST$C_DELTA_PC_W; - *(short *)cp = Offset; - cp += sizeof(short); - } else { - *cp++ = DST$C_DELTA_PC_L; - *(long *)cp = Offset; - cp += sizeof(long); - } - } - Local[0] = cp - (Local+1); - VMS_Store_Immediate_Data(Local,cp - Local, OBJ$C_TBT); - } -} - - -/* - * Describe a source file to the debugger - */ -VMS_TBT_Source_File(Filename, ID_Number) -char *Filename; -int ID_Number; -{ - register char *cp,*cp1; - int Status,i; - char Local[512]; - static struct FAB Fab; - static struct NAM Nam; - static struct XABDAT Date_Xab; - static struct XABFHC File_Header_Xab; - char Es_String[255],Rs_String[255]; - - /* - * Setup the Fab - */ - Fab.fab$b_bid = FAB$C_BID; - Fab.fab$b_bln = sizeof(Fab); - Fab.fab$l_nam = (&Nam); - Fab.fab$l_xab = (struct XAB *)&Date_Xab; - /* - * Setup the Nam block so we can find out the FULL name - * of the source file. - */ - Nam.nam$b_bid = NAM$C_BID; - Nam.nam$b_bln = sizeof(Nam); - Nam.nam$l_rsa = Rs_String; - Nam.nam$b_rss = sizeof(Rs_String); - Nam.nam$l_esa = Es_String; - Nam.nam$b_ess = sizeof(Es_String); - /* - * Setup the Date and File Header Xabs - */ - Date_Xab.xab$b_cod = XAB$C_DAT; - Date_Xab.xab$b_bln = sizeof(Date_Xab); - Date_Xab.xab$l_nxt = (char *)&File_Header_Xab; - File_Header_Xab.xab$b_cod = XAB$C_FHC; - File_Header_Xab.xab$b_bln = sizeof(File_Header_Xab); -/* ((struct XAB *)&Date_Xab)->xab$b_cod = XAB$C_DAT; */ -/* ((struct XAB *)&Date_Xab)->xab$b_bln = sizeof(Date_Xab); */ -/* ((struct XAB *)&Date_Xab)->xab$l_nxt = (struct XAB *)&File_Header_Xab; */ -/* ((struct XAB *)&File_Header_Xab)->xab$b_cod = XAB$C_FHC; */ -/* ((struct XAB *)&File_Header_Xab)->xab$b_bln = sizeof(File_Header_Xab); */ - /* - * Get the file information - */ - Fab.fab$l_fna = Filename; - Fab.fab$b_fns = strlen(Filename); - Status = sys$open(&Fab); - if (!(Status & 1)) { - printf("gas: Couldn't find source file \"%s\", Error = %%X%x\n", - Filename, Status); - return(0); - } - sys$close(&Fab); - /* - * Calculate the size of the resultant string - */ - i = Nam.nam$b_rsl; - /* - * Size of record - */ - Local[0] = 1+1+1+1+1+2+8+4+2+1+1+i+1; - /* - * Source declaration - */ - Local[1] = DST$C_SOURCE; - /* - * Make formfeeds count as source records - */ - Local[2] = DST$C_SRC_FORMFEED; - /* - * Declare source file - */ - Local[3] = DST$C_SRC_DECLFILE; - Local[4] = 1+2+8+4+2+1+1+i+1; - cp = Local+5; - /* - * Flags - */ - *cp++ = 0; - /* - * File ID - */ - *(short *)cp = ID_Number; - cp += sizeof(short); - /* - * Creation Date - */ - *(long *)cp = ((long *) &Date_Xab.xab$q_cdt)[0]; - cp += sizeof(long); - *(long *)cp = ((long *) &Date_Xab.xab$q_cdt)[1]; - cp += sizeof(long); - /* - * End of file block - */ - *(long *)cp = File_Header_Xab.xab$l_ebk; - cp += sizeof(long); - /* - * First free byte - */ - *(short *)cp = File_Header_Xab.xab$w_ffb; - cp += sizeof(short); - /* - * Record format - */ - *cp++ = File_Header_Xab.xab$b_rfo; - /* - * Filename - */ - *cp++ = i; - cp1 = Rs_String; - while(--i >= 0) *cp++ = *cp1++; - /* - * Library module name (none) - */ - *cp++ = 0; - /* - * Done - */ - VMS_Store_Immediate_Data(Local,cp - Local, OBJ$C_TBT); -} - - -/* - * Give the number of source lines to the debugger - */ -VMS_TBT_Source_Lines(ID_Number,Starting_Line_Number,Number_Of_Lines) -int ID_Number; -int Starting_Line_Number; -int Number_Of_Lines; -{ - char *cp,*cp1; - char Local[16]; - - /* - * Size of record - */ - Local[0] = 1+1+2+1+4+1+2; - /* - * Source declaration - */ - Local[1] = DST$C_SOURCE; - /* - * Set Source File - */ - cp = Local+2; - *cp++ = DST$C_SRC_SETFILE; - /* - * File ID Number - */ - *(short *)cp = ID_Number; - cp += sizeof(short); - /* - * Set record number - */ - *cp++ = DST$C_SRC_SETREC_L; - *(long *)cp = Starting_Line_Number; - cp += sizeof(long); - /* - * Define lines - */ - *cp++ = DST$C_SRC_DEFLINES_W; - *(short *)cp = Number_Of_Lines; - cp += sizeof(short); - /* - * Done - */ - VMS_Store_Immediate_Data(Local, cp-Local, OBJ$C_TBT); -} - - -/* - * Given the pointer to a symbol we calculate how big the data at the - * symbol is. We do this by looking for the next symbol (local or - * global) which will indicate the start of another datum. - */ -int VMS_Initialized_Data_Size(sp, End_Of_Data) -register struct symbol *sp; -int End_Of_Data; -{ - register struct symbol *sp1,*Next_Symbol; - - /* - * Find the next symbol - * it delimits this datum - */ - Next_Symbol = 0; - for (sp1 = symbol_rootP; sp1; sp1 = symbol_next(sp1)) { - /* - * The data type must match - */ - if ((sp1->sy_nlist.n_type & ~N_EXT) != N_DATA) continue; - /* - * The symbol must be AFTER this symbol - */ - if (sp1->sy_nlist.n_value <= sp->sy_nlist.n_value) continue; - /* - * We ignore THIS symbol - */ - if (sp1 == sp) continue; - /* - * If there is already a candidate selected for the - * next symbol, see if we are a better candidate - */ - if (Next_Symbol) { - /* - * We are a better candidate if we are "closer" - * to the symbol - */ - if (sp1->sy_nlist.n_value > - Next_Symbol->sy_nlist.n_value) - continue; - /* - * Win: Make this the candidate - */ - Next_Symbol = sp1; - } else { - /* - * This is the 1st candidate - */ - Next_Symbol = sp1; - } - } - /* - * Calculate its size - */ - return(Next_Symbol ? - (Next_Symbol->sy_nlist.n_value - - sp->sy_nlist.n_value) : - (End_Of_Data - sp->sy_nlist.n_value)); -} - - - -/* this routine locates a file in the list of files. If an entry does not - * exist, one is created. For include files, a new entry is always created - * such that inline functions can be properly debugged */ -struct input_file * -find_file(sp) -symbolS * sp; -{ - struct input_file * same_file; - struct input_file * fpnt; - same_file = (struct input_file*) NULL; - for(fpnt = file_root; fpnt; fpnt = fpnt->next){ - if(fpnt == (struct input_file*) NULL) break; - if(fpnt->spnt == sp) return fpnt; - }; - for(fpnt = file_root; fpnt; fpnt = fpnt->next){ - if(fpnt == (struct input_file*) NULL) break; - if (strcmp(sp->sy_nlist.n_un.n_name,fpnt->name) == 0){ - if(fpnt->flag == 1)return fpnt; - same_file = fpnt; - break; - }; - }; - fpnt = (struct input_file*) malloc(sizeof(struct input_file)); - if(file_root == (struct input_file*) NULL) file_root = fpnt; - else { - struct input_file * fpnt1; - for(fpnt1 = file_root; fpnt1->next; fpnt1 = fpnt1->next); - fpnt1->next = fpnt; - }; - fpnt->next = (struct input_file*) NULL; - fpnt->name = sp->sy_nlist.n_un.n_name; - fpnt->min_line = 0x7fffffff; - fpnt->max_line = 0; - fpnt->offset = 0; - fpnt->flag = 0; - fpnt->file_number = 0; - fpnt->spnt = sp; - fpnt->same_file_fpnt = same_file; - return fpnt; -} - - -/* - * This is a hacked _doprnt() for VAX-11 "C". It understands that - * it is ONLY called by as_fatal(Format, Args) with a pointer to the - * "Args" argument. From this we can make it all work right! - */ -#ifndef eunice -_doprnt(Format, a, f) -char *Format; -FILE *f; -char **a; -{ - int Nargs = ((int *)a)[-2]; /* This understands as_fatal() */ - - switch(Nargs) { - default: fprintf(f,"_doprnt error on \"%s\"!!",Format); break; - case 1: fprintf(f,Format); break; - case 2: fprintf(f,Format,a[0]); break; - case 3: fprintf(f,Format,a[0],a[1]); break; - case 4: fprintf(f,Format,a[0],a[1],a[2]); break; - case 5: fprintf(f,Format,a[0],a[1],a[2],a[3]); break; - case 6: fprintf(f,Format,a[0],a[1],a[2],a[3],a[4]); break; - case 7: fprintf(f,Format,a[0],a[1],a[2],a[3],a[4],a[5]); break; - case 8: fprintf(f,Format,a[0],a[1],a[2],a[3],a[4],a[5],a[6]); break; - case 9: fprintf(f,Format,a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7]); break; - case 10: fprintf(f,Format,a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8]); break; - } -} - -#endif /* eunice */ - -#endif /* VMS */ - -char const_flag = 0; -void s_const(); - -void -s_const() -{ - register int temp; - - temp = get_absolute_expression (); - subseg_new (SEG_DATA, (subsegT)temp); - const_flag = 1; - demand_empty_rest_of_line(); -} - -obj_crawl_symbol_chain() { - /* JF deal with forward references first. . . */ - for (symbolP = symbol_rootP; symbolP; symbolP = symbol_next(symbolP)) { - if (symbolP->sy_forward) { - symbolP->sy_value += symbolP->sy_forward->sy_value + symbolP->sy_forward->sy_frag->fr_address; -#ifdef OBJ_COFF - if(SF_GET_GET_SEGMENT(symbolP) && - S_GET_SEGMENT(symbolP) == SEG_UNKNOWN) - S_SET_SEGMENT(symbolP, S_GET_SEGMENT(symbolP->sy_forward)); -#endif /* OBJ_COFF */ - symbolP->sy_forward=0; - } /* if it has a forward reference */ - } /* walk the symbol chain */ - - { /* crawl symbol table */ - register int symbol_number = 0; - -#if defined(OBJ_COFF) - { /* OBJ_COFF version */ - lineno* lineP; - symbolS* symbol_externP = (symbolS*)0; - symbolS* symbol_extern_lastP = (symbolS*)0; - - /* The symbol list should be ordered according to the following sequence - * order : - * . .file symbol - * . debug entries for functions - * . fake symbols for .text .data and .bss - * . defined symbols - * . undefined symbols - * But this is not mandatory. The only important point is to put the - * undefined symbols at the end of the list. - */ - - if (symbol_rootP == NULL - || S_GET_STORAGE_CLASS(symbol_rootP) != C_FILE) { - c_dot_file_symbol("fake"); - } /* Is there a .file symbol ? If not insert one at the beginning. */ - - /* - * Build up static symbols for .text, .data and .bss - */ - dot_text_symbol = (symbolS*) - c_section_symbol(".text", - 0, - H_GET_TEXT_SIZE(&headers), - 0/*text_relocation_number*/, - 0/*text_lineno_number*/); - - dot_data_symbol = (symbolS*) - c_section_symbol(".data", - H_GET_TEXT_SIZE(&headers), - H_GET_DATA_SIZE(&headers), - 0/*data_relocation_number*/, - 0); /* There are no data lineno - entries */ - - dot_bss_symbol = (symbolS*) - c_section_symbol(".bss", - H_GET_TEXT_SIZE(&headers) + H_GET_DATA_SIZE(&headers), - H_GET_BSS_SIZE(&headers), - 0, /* No relocation for a bss section. */ - 0); /* There are no bss lineno entries */ - - /* FIXME late night before delivery, I don't know why the chain is - broken, but I can guess. So! Let's force them to be knit properly - at this point. */ - -/* as john pointed out, this wasn't right. Instead, we'll check here to - make sure that the list is doubly linked. */ - -#if defined(DEBUG) && defined(SYMBOLS_NEED_BACKPOINTERS) - for (symbolP = symbol_rootP; symbol_next(symbolP); symbolP = symbol_next(symbolP)) { - know(symbolP->sy_next->sy_previous == symbolP); - } /* walk the symbol chain */ -#endif /* DEBUG and SYMBOLS_NEED_BACKPOINTERS */ - symbolP = symbol_rootP; - - if (symbolP) { - while(symbolP) { - /* If the symbol has a tagndx entry, resolve it */ - if(SF_GET_TAGGED(symbolP)) { - SA_SET_SYM_TAGNDX(symbolP, - ((symbolS*)SA_GET_SYM_TAGNDX(symbolP))->sy_number); - } - /* Debug symbol do not need all this rubbish */ - if(!SF_GET_DEBUG(symbolP)) { - symbolS* real_symbolP; - /* L* and C_EFCN symbols never merge. */ - if(!SF_GET_LOCAL(symbolP) && - (real_symbolP = - symbol_find_base(S_GET_NAME(symbolP), DO_NOT_STRIP)) && - real_symbolP != symbolP) { - /* FIXME where do dups come from? xoxorich. */ - /* Move the debug data from the debug symbol to the - real symbol. Do NOT do the oposite (i.e. move from - real symbol to symbol and remove real symbol from the - list.) Because some pointers refer to the real symbol - whereas no pointers refer to the symbol. */ - c_symbol_merge(symbolP, real_symbolP); - /* Replace the current symbol by the real one */ - /* The symbols will never be the last or the first - because : 1st symbol is .file and 3 last symbols are - .text, .data, .bss */ - symbol_remove(real_symbolP, &symbol_rootP, &symbol_lastP); - symbol_insert(real_symbolP, symbolP, &symbol_rootP, &symbol_lastP); - symbol_remove(symbolP, &symbol_rootP, &symbol_lastP); - symbolP = real_symbolP; - } - if(flagseen['R'] && S_IS_DATA(symbolP)) - S_SET_TEXT(symbolP); - - symbolP->sy_value += symbolP->sy_frag->fr_address; - - if(!S_IS_DEFINED(symbolP)) - S_SET_EXTERNAL(symbolP); - else if(S_GET_STORAGE_CLASS(symbolP) == C_NULL) - S_SET_STORAGE_CLASS(symbolP, C_STAT); - - /* Mainly to speed up if not -g */ - if(SF_GET_PROCESS(symbolP)) { - /* Handle the nested blocks auxiliary info. */ - if(S_GET_STORAGE_CLASS(symbolP) == C_BLOCK) { - if(!strcmp(S_GET_NAME(symbolP), ".bb")) - stack_push(block_stack, (char *) &symbolP); - else { /* .eb */ - register symbolS* begin_symbolP; - begin_symbolP = *(symbolS**)stack_pop(block_stack); - if(begin_symbolP == (symbolS*)0) - as_warn("mismatched .eb"); - else - SA_SET_SYM_ENDNDX(begin_symbolP, symbol_number); - } - } - /* If we are able to identify the type of a function, and we - are out of a function (last_functionP == 0) then, the - function symbol will be associated with an auxiliary - entry. */ - if(last_functionP == (symbolS*)0 && - SF_GET_FUNCTION(symbolP)) { - last_functionP = symbolP; - S_SET_NUMBER_AUXILIARY(symbolP, 1); - /* Clobber possible stale .dim information. */ - memset(&symbolP->sy_auxent[0], '\0', sizeof(union auxent)); - } - /* The C_FCN doesn't need any additional information. - I don't even know if this is needed for sdb. But the - standard assembler generates it, so... - */ - if(S_GET_STORAGE_CLASS(symbolP) == C_EFCN) { - if(last_functionP == (symbolS*)0) - as_fatal("C_EFCN symbol out of scope"); - SA_SET_SYM_FSIZE(last_functionP, - (long)(symbolP->sy_value - - last_functionP->sy_value)); - SA_SET_SYM_ENDNDX(last_functionP, symbol_number); - last_functionP = (symbolS*)0; - } - } - } else { - /* First descriptor of a structure must point to the next - slot outside the structure description. */ - if(SF_GET_TAG(symbolP)) - last_tagP = symbolP; - else if(S_GET_STORAGE_CLASS(symbolP) == C_EOS) - /* +2 take in account the current symbol */ - SA_SET_SYM_ENDNDX(last_tagP, symbol_number+2); - } - - /* We must put the external symbols apart. The loader - does not bomb if we do not. But the references in - the endndx field for a .bb symbol are not corrected - if an external symbol is removed between .bb and .be. - I.e in the following case : - [20] .bb endndx = 22 - [21] foo external - [22] .be - ld will move the symbol 21 to the end of the list but - endndx will still be 22 instead of 21. */ - { - register symbolS* thisP = symbolP; - - symbolP = symbol_next(thisP); - /* remove C_EFCN and LOCAL (L...) symbols */ - if (SF_GET_LOCAL(thisP)) { - symbol_remove(thisP, &symbol_rootP, &symbol_lastP); - } else { - if(S_GET_STORAGE_CLASS(thisP) == C_EXT && - !SF_GET_FUNCTION(thisP)) { - /* Remove from the list */ - symbol_remove(thisP, &symbol_rootP, &symbol_lastP); - symbol_clear_list_pointers(thisP); - /* Move at the end of the list */ - if (symbol_extern_lastP == (symbolS*)0) - symbol_externP = thisP; - else - symbol_append(thisP, symbol_extern_lastP); - symbol_extern_lastP = thisP; - } else { - if(SF_GET_STRING(thisP)) { - thisP->sy_name_offset = string_byte_count; - string_byte_count += strlen(S_GET_NAME(thisP)) + 1; - } else - thisP->sy_name_offset = 0; - thisP->sy_number = symbol_number; - symbol_number += 1 + S_GET_NUMBER_AUXILIARY(thisP); - } - } - } - } - - /* this actually appends the entire extern chain */ - symbol_append(symbol_externP, symbol_lastP); - symbolP = symbol_externP; - while(symbolP) { - if(SF_GET_STRING(symbolP)) { - symbolP->sy_name_offset = string_byte_count; - string_byte_count += strlen(S_GET_NAME(symbolP)) + 1; - } else - symbolP->sy_name_offset = 0; - symbolP->sy_number = symbol_number; - symbol_number += 1 + S_GET_NUMBER_AUXILIARY(symbolP); - symbolP = symbol_next(symbolP); - } - } - - /* FIXME I'm counting line no's here so we know what to put in the section - headers, and I'm resolving the addresses since I'm not sure how to - do it later. I am NOT resolving the linno's representing functions. - Their symbols need a fileptr pointing to this linno when emitted. - Thus, I resolve them on emit. xoxorich. */ - - for (lineP = lineno_rootP; lineP; lineP = lineP->next) { - if (lineP->line.l_lnno) { - lineP->line.l_addr.l_paddr += ((fragS*)lineP->frag)->fr_address; - } else { - ; - } - text_lineno_number++; - } /* for each line number */ - } /* OBJ_COFF version */ -#elif defined(OBJ_AOUT) | defined(OBJ_BOUT) - { /* OBJ_AOUT version */ - symbolPP = & symbol_rootP; /* -> last symbol chain link. */ - while ((symbolP = *symbolPP) != NULL) - { - if (flagseen['R'] && S_IS_DATA(symbolP)) { - S_SET_TEXT(symbolP); - } /* if pusing data into text */ - - symbolP -> sy_value += symbolP -> sy_frag -> fr_address; - - /* OK, here is how we decide which symbols go out into the - brave new symtab. Symbols that do are: - - * symbols with no name (stabd's?) - * symbols with debug info in their N_TYPE - - Symbols that don't are: - * symbols that are registers - * symbols with \1 as their 3rd character (numeric labels) - * "local labels" as defined by S_LOCAL_NAME(name) - if the -L switch was passed to gas. - - All other symbols are output. We complain if a deleted - symbol was marked external. */ - - - if (1 - && !S_IS_REGISTER(symbolP) -#ifndef VMS /* Under VMS we need to keep local symbols */ - && ( !S_GET_NAME(symbolP) - || S_IS_DEBUG(symbolP) -#ifdef TC_I960 - /* FIXME this ifdef seems highly dubious to me. xoxorich. */ - || !S_IS_DEFINED(symbolP) - || S_IS_EXTERNAL(symbolP) -#endif /* TC_I960 */ - || (S_GET_NAME(symbolP)[0] != '\001' && (flagseen ['L'] || ! S_LOCAL_NAME(symbolP)))) -#endif /* not VMS */ - ) - { -#ifndef VMS - symbolP->sy_number = symbol_number++; - - /* The + 1 after strlen account for the \0 at the - end of each string */ - if (!S_IS_STABD(symbolP)) { - /* Ordinary case. */ - symbolP->sy_name_offset = string_byte_count; - string_byte_count += strlen(S_GET_NAME(symbolP)) + 1; - } - else /* .Stabd case. */ -#endif /* not VMS */ - symbolP->sy_name_offset = 0; - symbolPP = &(symbol_next(symbolP)); - } else { - if (S_IS_EXTERNAL(symbolP) || !S_IS_DEFINED(symbolP)) { - as_bad ("Local symbol %s never defined", name); - } /* oops. */ - -#ifndef VMS - /* Unhook it from the chain */ - *symbolPP = symbol_next(symbolP); -#endif /* VMS */ - } /* if this symbol should be in the output */ - } /* for each symbol */ - } /* OBJ_AOUT version */ -#else - cant_crawl_symbol_table(); -#endif - H_SET_STRING_SIZE(&headers,string_byte_count); - H_SET_SYMBOL_TABLE_SIZE(&headers, symbol_number); - } /* crawl symbol table */ - - /* JF deal with forward references first. . . */ - for (symbolP = symbol_rootP; symbolP; symbolP = symbol_next(symbolP)) { - if (symbolP->sy_forward) { - symbolP->sy_value += symbolP->sy_forward->sy_value + symbolP->sy_forward->sy_frag->fr_address; -#ifdef OBJ_COFF - if(SF_GET_GET_SEGMENT(symbolP) && - S_GET_SEGMENT(symbolP) == SEG_UNKNOWN) - S_SET_SEGMENT(symbolP, S_GET_SEGMENT(symbolP->sy_forward)); -#endif /* OBJ_COFF */ - symbolP->sy_forward=0; - } /* if it has a forward reference */ - } /* walk the symbol chain */ - - { /* crawl symbol table */ - register int symbol_number = 0; - -#if defined(OBJ_COFF) - { /* OBJ_COFF version */ - lineno* lineP; - symbolS* symbol_externP = (symbolS*)0; - symbolS* symbol_extern_lastP = (symbolS*)0; - - /* The symbol list should be ordered according to the following sequence - * order : - * . .file symbol - * . debug entries for functions - * . fake symbols for .text .data and .bss - * . defined symbols - * . undefined symbols - * But this is not mandatory. The only important point is to put the - * undefined symbols at the end of the list. - */ - - if (symbol_rootP == NULL - || S_GET_STORAGE_CLASS(symbol_rootP) != C_FILE) { - c_dot_file_symbol("fake"); - } /* Is there a .file symbol ? If not insert one at the beginning. */ - - /* - * Build up static symbols for .text, .data and .bss - */ - dot_text_symbol = (symbolS*) - c_section_symbol(".text", - 0, - H_GET_TEXT_SIZE(&headers), - 0/*text_relocation_number*/, - 0/*text_lineno_number*/); - - dot_data_symbol = (symbolS*) - c_section_symbol(".data", - H_GET_TEXT_SIZE(&headers), - H_GET_DATA_SIZE(&headers), - 0/*data_relocation_number*/, - 0); /* There are no data lineno - entries */ - - dot_bss_symbol = (symbolS*) - c_section_symbol(".bss", - H_GET_TEXT_SIZE(&headers) + H_GET_DATA_SIZE(&headers), - H_GET_BSS_SIZE(&headers), - 0, /* No relocation for a bss section. */ - 0); /* There are no bss lineno entries */ - - /* FIXME late night before delivery, I don't know why the chain is - broken, but I can guess. So! Let's force them to be knit properly - at this point. */ - -/* as john pointed out, this wasn't right. Instead, we'll check here to - make sure that the list is doubly linked. */ - -#if defined(DEBUG) && defined(SYMBOLS_NEED_BACKPOINTERS) - for (symbolP = symbol_rootP; symbol_next(symbolP); symbolP = symbol_next(symbolP)) { - know(symbolP->sy_next->sy_previous == symbolP); - } /* walk the symbol chain */ -#endif /* DEBUG and SYMBOLS_NEED_BACKPOINTERS */ - symbolP = symbol_rootP; - - if (symbolP) { - while(symbolP) { - /* If the symbol has a tagndx entry, resolve it */ - if(SF_GET_TAGGED(symbolP)) { - SA_SET_SYM_TAGNDX(symbolP, - ((symbolS*)SA_GET_SYM_TAGNDX(symbolP))->sy_number); - } - /* Debug symbol do not need all this rubbish */ - if(!SF_GET_DEBUG(symbolP)) { - symbolS* real_symbolP; - /* L* and C_EFCN symbols never merge. */ - if(!SF_GET_LOCAL(symbolP) && - (real_symbolP = - symbol_find_base(S_GET_NAME(symbolP), DO_NOT_STRIP)) && - real_symbolP != symbolP) { - /* FIXME where do dups come from? xoxorich. */ - /* Move the debug data from the debug symbol to the - real symbol. Do NOT do the oposite (i.e. move from - real symbol to symbol and remove real symbol from the - list.) Because some pointers refer to the real symbol - whereas no pointers refer to the symbol. */ - c_symbol_merge(symbolP, real_symbolP); - /* Replace the current symbol by the real one */ - /* The symbols will never be the last or the first - because : 1st symbol is .file and 3 last symbols are - .text, .data, .bss */ - symbol_remove(real_symbolP, &symbol_rootP, &symbol_lastP); - symbol_insert(real_symbolP, symbolP, &symbol_rootP, &symbol_lastP); - symbol_remove(symbolP, &symbol_rootP, &symbol_lastP); - symbolP = real_symbolP; - } - if(flagseen['R'] && S_IS_DATA(symbolP)) - S_SET_TEXT(symbolP); - - symbolP->sy_value += symbolP->sy_frag->fr_address; - - if(!S_IS_DEFINED(symbolP)) - S_SET_EXTERNAL(symbolP); - else if(S_GET_STORAGE_CLASS(symbolP) == C_NULL) - S_SET_STORAGE_CLASS(symbolP, C_STAT); - - /* Mainly to speed up if not -g */ - if(SF_GET_PROCESS(symbolP)) { - /* Handle the nested blocks auxiliary info. */ - if(S_GET_STORAGE_CLASS(symbolP) == C_BLOCK) { - if(!strcmp(S_GET_NAME(symbolP), ".bb")) - stack_push(block_stack, (char *) &symbolP); - else { /* .eb */ - register symbolS* begin_symbolP; - begin_symbolP = *(symbolS**)stack_pop(block_stack); - if(begin_symbolP == (symbolS*)0) - as_warn("mismatched .eb"); - else - SA_SET_SYM_ENDNDX(begin_symbolP, symbol_number); - } - } - /* If we are able to identify the type of a function, and we - are out of a function (last_functionP == 0) then, the - function symbol will be associated with an auxiliary - entry. */ - if(last_functionP == (symbolS*)0 && - SF_GET_FUNCTION(symbolP)) { - last_functionP = symbolP; - S_SET_NUMBER_AUXILIARY(symbolP, 1); - /* Clobber possible stale .dim information. */ - memset(&symbolP->sy_auxent[0], '\0', sizeof(union auxent)); - } - /* The C_FCN doesn't need any additional information. - I don't even know if this is needed for sdb. But the - standard assembler generates it, so... - */ - if(S_GET_STORAGE_CLASS(symbolP) == C_EFCN) { - if(last_functionP == (symbolS*)0) - as_fatal("C_EFCN symbol out of scope"); - SA_SET_SYM_FSIZE(last_functionP, - (long)(symbolP->sy_value - - last_functionP->sy_value)); - SA_SET_SYM_ENDNDX(last_functionP, symbol_number); - last_functionP = (symbolS*)0; - } - } - } else { - /* First descriptor of a structure must point to the next - slot outside the structure description. */ - if(SF_GET_TAG(symbolP)) - last_tagP = symbolP; - else if(S_GET_STORAGE_CLASS(symbolP) == C_EOS) - /* +2 take in account the current symbol */ - SA_SET_SYM_ENDNDX(last_tagP, symbol_number+2); - } - - /* We must put the external symbols apart. The loader - does not bomb if we do not. But the references in - the endndx field for a .bb symbol are not corrected - if an external symbol is removed between .bb and .be. - I.e in the following case : - [20] .bb endndx = 22 - [21] foo external - [22] .be - ld will move the symbol 21 to the end of the list but - endndx will still be 22 instead of 21. */ - { - register symbolS* thisP = symbolP; - - symbolP = symbol_next(thisP); - /* remove C_EFCN and LOCAL (L...) symbols */ - if (SF_GET_LOCAL(thisP)) { - symbol_remove(thisP, &symbol_rootP, &symbol_lastP); - } else { - if(S_GET_STORAGE_CLASS(thisP) == C_EXT && - !SF_GET_FUNCTION(thisP)) { - /* Remove from the list */ - symbol_remove(thisP, &symbol_rootP, &symbol_lastP); - symbol_clear_list_pointers(thisP); - /* Move at the end of the list */ - if (symbol_extern_lastP == (symbolS*)0) - symbol_externP = thisP; - else - symbol_append(thisP, symbol_extern_lastP); - symbol_extern_lastP = thisP; - } else { - if(SF_GET_STRING(thisP)) { - thisP->sy_name_offset = string_byte_count; - string_byte_count += strlen(S_GET_NAME(thisP)) + 1; - } else - thisP->sy_name_offset = 0; - thisP->sy_number = symbol_number; - symbol_number += 1 + S_GET_NUMBER_AUXILIARY(thisP); - } - } - } - } - - /* this actually appends the entire extern chain */ - symbol_append(symbol_externP, symbol_lastP); - symbolP = symbol_externP; - while(symbolP) { - if(SF_GET_STRING(symbolP)) { - symbolP->sy_name_offset = string_byte_count; - string_byte_count += strlen(S_GET_NAME(symbolP)) + 1; - } else - symbolP->sy_name_offset = 0; - symbolP->sy_number = symbol_number; - symbol_number += 1 + S_GET_NUMBER_AUXILIARY(symbolP); - symbolP = symbol_next(symbolP); - } - } - - /* FIXME I'm counting line no's here so we know what to put in the section - headers, and I'm resolving the addresses since I'm not sure how to - do it later. I am NOT resolving the linno's representing functions. - Their symbols need a fileptr pointing to this linno when emitted. - Thus, I resolve them on emit. xoxorich. */ - - for (lineP = lineno_rootP; lineP; lineP = lineP->next) { - if (lineP->line.l_lnno) { - lineP->line.l_addr.l_paddr += ((fragS*)lineP->frag)->fr_address; - } else { - ; - } - text_lineno_number++; - } /* for each line number */ - } /* OBJ_COFF version */ -#elif defined(OBJ_AOUT) | defined(OBJ_BOUT) - { /* OBJ_AOUT version */ - symbolPP = & symbol_rootP; /* -> last symbol chain link. */ - while ((symbolP = *symbolPP) != NULL) - { - if (flagseen['R'] && S_IS_DATA(symbolP)) { - S_SET_TEXT(symbolP); - } /* if pusing data into text */ - - symbolP -> sy_value += symbolP -> sy_frag -> fr_address; - - /* OK, here is how we decide which symbols go out into the - brave new symtab. Symbols that do are: - - * symbols with no name (stabd's?) - * symbols with debug info in their N_TYPE - - Symbols that don't are: - * symbols that are registers - * symbols with \1 as their 3rd character (numeric labels) - * "local labels" as defined by S_LOCAL_NAME(name) - if the -L switch was passed to gas. - - All other symbols are output. We complain if a deleted - symbol was marked external. */ - - - if (1 - && !S_IS_REGISTER(symbolP) -#ifndef VMS /* Under VMS we need to keep local symbols */ - && ( !S_GET_NAME(symbolP) - || S_IS_DEBUG(symbolP) -#ifdef TC_I960 - /* FIXME this ifdef seems highly dubious to me. xoxorich. */ - || !S_IS_DEFINED(symbolP) - || S_IS_EXTERNAL(symbolP) -#endif /* TC_I960 */ - || (S_GET_NAME(symbolP)[0] != '\001' && (flagseen ['L'] || ! S_LOCAL_NAME(symbolP)))) -#endif /* not VMS */ - ) - { -#ifndef VMS - symbolP->sy_number = symbol_number++; - - /* The + 1 after strlen account for the \0 at the - end of each string */ - if (!S_IS_STABD(symbolP)) { - /* Ordinary case. */ - symbolP->sy_name_offset = string_byte_count; - string_byte_count += strlen(S_GET_NAME(symbolP)) + 1; - } - else /* .Stabd case. */ -#endif /* not VMS */ - symbolP->sy_name_offset = 0; - symbolPP = &(symbol_next(symbolP)); - } else { - if (S_IS_EXTERNAL(symbolP) || !S_IS_DEFINED(symbolP)) { - as_bad ("Local symbol %s never defined", name); - } /* oops. */ - -#ifndef VMS - /* Unhook it from the chain */ - *symbolPP = symbol_next(symbolP); -#endif /* VMS */ - } /* if this symbol should be in the output */ - } /* for each symbol */ - } /* OBJ_AOUT version */ -#else - cant_crawl_symbol_table(); -#endif - H_SET_STRING_SIZE(&headers,string_byte_count); - H_SET_SYMBOL_TABLE_SIZE(&headers, symbol_number); - } /* crawl symbol table */ - -} /* obj_crawl_symbol_chain() */ - -/* end of obj-vms.c */ diff --git a/gas/configure b/gas/configure deleted file mode 100755 index 3cdccfe5019..00000000000 --- a/gas/configure +++ /dev/null @@ -1,687 +0,0 @@ -#!/bin/sh - -# Configuration script -# Copyright (C) 1988, 1990, 1991 Free Software Foundation, Inc. - -#This file is part of GNU. - -# 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -# $Id$ - -# -# Shell script to create proper links to machine-dependent files in -# preparation for compilation. -# -# If configure succeeds, it leaves its status in config.status. -# If configure fails after disturbing the status quo, -# config.status is removed. -# - -remove=rm -hard_link=ln -symbolic_link='ln -s' - -#for Test -#remove="echo rm" -#hard_link="echo ln" -#symbolic_link="echo ln -s" - -progname=$0 - -# clear some things potentially inherited from environment. -ansi= -arguments=$* -defaulttargets= -destdir= -fatal= -hostsubdir= -Makefile=Makefile -Makefile_in=Makefile.in -norecursion= -recurring= -removing= -srcdir= -srctrigger= -target= -targets= -commontargets= -configdirs= -targetsubdir= -template= -verbose= - -for arg in $*; -do - case ${arg} in - -ansi | +a*) - ansi=true - clib=clib - ;; - -destdir=* | +destdir=* | +destdi=* | +destd=* | +dest=* | +des=* | +de=* | +d=*) - destdir=`echo ${arg} | sed 's/[+-]d[a-z]*=//'` - ;; - -languages=* | +languages=* | +language=* | +languag=* \ - | +langua=* | +langu=* | +lang=* | +lan=* | +la=* \ - | +l=*) - languages="${languages} `echo ${arg} | sed 's/[+-]l[a-z]*=//'`" - ;; - -gas | +g*) - gas=yes - ;; - -help | +h*) - fatal=true - ;; - -nfp | +nf*) - nfp=yes - ;; - -norecursion | +no*) - norecursion=true - ;; - -recurring | +recurring | +recurrin | +recurri | +recurr | +recur | +recu | +rec | +re) - recurring=true - ;; - -rm | +rm) - removing=${arg} - ;; -# -srcdir=* | +srcdir=* | +srcdi=* | +srcd=* | +src=* | +sr=* | +s=*) -# srcdir=`echo ${arg} | sed 's/[+-]s[a-z]*=//'` -# ;; - -subdirs | +f* | +su*) - subdirs=${arg} - ;; - -target=* | +target=* | +targe=* | +targ=* | +tar=* | +ta=*) - if [ -n "${targets}" ] ; then - subdirs="+subdirs" - fi - - newtargets="${targets} `echo ${arg} | sed 's/[+-]t[a-z]*=//'`" - targets="${newtargets}" - ;; - -template=* | +template=* | +templat=* | +templa=* | +templ=* | +temp=* | +tem=* | +te=*) - template=`echo ${arg} | sed 's/[+-]template=//'` - ;; - -v | -verbose | +v*) - verbose=${arg} - ;; - -* | +*) - (echo ; - echo "Unrecognized option: \"${arg}\"". ; - echo) 1>&2 - fatal=true - ;; - *) - if [ -n "${hosts}" ] ; then - subdirs="+subdirs" - fi - - newhosts="${hosts} ${arg}" - hosts=${newhosts} - ;; - esac -done - -if [ -n "${verbose}" ] ; then - echo `pwd`/configure $* -fi - -# process host and target only if not rebuilding configure itself or removing. -if [ -z "${template}" -a -z "${removing}" -a -z "${fatal}" ] ; then - # Complain if an arg is missing - if [ -z "${hosts}" ] ; then - (echo ; - echo "configure: No HOST specified." ; - echo) 1>&2 - fatal=true - fi -fi - -if [ -n "${fatal}" -o "${hosts}" = "help" ] ; then - (echo "Usage: configure HOST" ; - echo ; - echo "Options: [defaults in brackets]" ; - echo " +ansi configure w/ANSI library. [no ansi lib]" ; - echo " +destdir=MYDIR configure for installation into MYDIR. [/usr/local]" ; - echo " +subdirs configure in subdirectories. [in source directories]" ; - echo " +lang=LANG configure to build LANG. [gcc]" ; - echo " +help print this message. [normal config]" ; - echo " +gas configure the compilers for use with gas. [native as]" ; - echo " +nfp configure the compilers default to soft floating point. [hard float]" ; - echo " +norecursion configure this directory only. [recurse]" ; - echo " +rm remove this configuration. [build a configuration]" ; - echo " +target=TARGET configure for TARGET. [TARGET = HOST]" ; - echo " +template=TEM rebuild configure using TEM. [normal config]" ; - echo ; - echo "Where HOST and TARGET are something like \"vax\", \"sun3\", \"encore\", etc." ; - echo "Asking for more than one \"+target\" implies \"+subdirs\". Any other" ; - echo "options given will apply to all targets.") 1>&2 - - if [ -r config.status ] ; then - cat config.status - fi - - exit 1 -fi - -#### configure.in common parts come in here. -# This file is a shell script that supplies the information necessary -# to tailor a template configure script into the configure script -# appropriate for this directory. For more information, check any -# existing configure script. - -srctrigger=as.c -srcname="gas" -targetdependent=true - -## end of common part. - -# are we rebuilding config itself? -if [ -n "${template}" ] ; then - if [ ! -r ${template} ] ; then - echo '***' "Can't find template ${template}." 1>&2 - exit 1 - fi - -# prep the template - sed -e '/^#### configure.in common parts come in here.$/,/^## end of common part.$/c\ -#### configure.in common parts come in here.\ -## end of common part.' \ - -e '/^#### configure.in per-host parts come in here.$/,/^## end of per-host part.$/c\ -#### configure.in per-host parts come in here.\ -## end of per-host part.' \ - -e '/^#### configure.in per-target parts come in here.$/,/^## end of per-target part.$/c\ -#### configure.in per-target parts come in here.\ -## end of per-target part.' \ - -e '/^#### configure.in post-target parts come in here.$/,/^## end of post-target part.$/c\ -#### configure.in post-target parts come in here.\ -## end of post-target part.' \ - < ${template} > template.new - - if [ -r configure.in ] ; then - if [ -z "`grep '^# per\-host:' configure.in`" ] ; then - echo '***' `pwd`/configure.in has no "per-host:" line. 1>&2 - exit 1 - fi - - if [ -z "`grep '^# per\-target:' configure.in`" ] ; then - echo '***' `pwd`/configure.in has no "per-target:" line. 1>&2 - exit 1 - fi - - # split configure.in into common, per-host, per-target, - # and post-target parts. Post-target is optional. - sed -e '/^# per\-host:/,$d' configure.in > configure.com - sed -e '1,/^# per\-host:/d' -e '/^# per\-target:/,$d' configure.in > configure.hst - if grep -s '^# post-target:' configure.in ; then - sed -e '1,/^# per\-target:/d' -e '/^# post\-target:/,$d' configure.in > configure.tgt - sed -e '1,/^# post\-target:/d' configure.in > configure.pos - else - sed -e '1,/^# per\-target:/d' configure.in > configure.tgt - echo >configure.pos - fi - - # and insert them - sed -e '/^#### configure.in common parts come in here.$/ r configure.com' \ - -e '/^#### configure.in per\-host parts come in here.$/ r configure.hst' \ - -e '/^#### configure.in per\-target parts come in here.$/ r configure.tgt' \ - -e '/^#### configure.in post\-target parts come in here.$/ r configure.pos' \ - template.new > configure.new - - rm -f configure.com configure.tgt configure.hst configure.pos - else - echo Warning: no configure.in in `pwd` - cat ${template} >> configure - fi - - chmod a+x configure.new - rm template.new -# mv configure configure.old - mv configure.new configure - - if [ -n "${verbose}" ] ; then - echo Rebuilt configure in `pwd` - fi - - # Now update config.sub from the template directory. - if echo "$template" | grep -s 'configure$' ; then - cp `echo "$template" | sed s/configure$/config.sub/` ./config.sub.new - # mv config.sub config.sub.old - mv config.sub.new config.sub - - if [ -n "${verbose}" ] ; then - echo Rebuilt config.sub in `pwd` - fi - fi - - if [ -z "${norecursion}" ] ; then - # If template is relative path, make it absolute for recurring. - if echo "${template}" | grep -s '^/' ; then - true - else - template=`pwd`/${template} - fi - - while [ -n "${configdirs}" ] ; do - # set configdir to car of configdirs, configdirs to cdr of configdirs - set ${configdirs}; configdir=$1; shift; configdirs=$* - - if [ "`echo ${configdir}.*`" != "${configdir}.*" ] ; then - targetspecificdirs=${configdir}.* - else - targetspecificdirs= - fi - - for i in ${configdir} ${targetspecificdirs} ; do - if [ -d $i ] ; then - if [ -r $i/configure ] ; then - (cd $i ; - ./configure +template=${template} ${verbose}) - else - echo Warning: No configure script in `pwd`/$i - fi - else - if [ -n "${verbose}" ] ; then - echo Warning: directory $i is missing. - fi - fi - done - done - fi - - exit 0 -fi - -# some sanity checks on configure.in -if [ -z "${srctrigger}" ] ; then - echo Warning: srctrigger not set in configure.in. `pwd` not configured. - exit 1 -fi - -for host in ${hosts} ; do - # Default other arg - if [ -z "${targets}" -o -n "${defaulttargets}" ] ; then - targets=${host} - defaulttargets=true - fi - - host_alias=${host} - - result=`/bin/sh ./config.sub ${host}` - host_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'` - host_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'` - host_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'` - host=${host_cpu}-${host_vendor}-${host_os} - host_makefile_frag=config/hmake-${host} - -#### configure.in per-host parts come in here. - -gas_host=generic - -case "${host_cpu}" in -a29k | rs6000 | vax) gas_host=${host_cpu} ;; -mips) - case "${host_os}" in - ultrix) gas_host=decstation ;; - esac - ;; -*) - case "${host_os}" in - ansi | ultrix | hpux | sysv*) gas_host=${host_os} ;; - *) - case "${host_vendor}" in - sun) - case "${host_cpu}" in - m68k) gas_host=sun3 ;; - i386) gas_host=sun386 ;; - sparc) gas_host=sun4 ;; - esac - ;; - esac - ;; - esac - ;; -esac - -## end of per-host part. - - for target in ${targets} ; do - - target_alias=${target} - result=`/bin/sh ./config.sub ${target}` - target_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'` - target_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'` - target_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'` - target=${target_cpu}-${target_vendor}-${target_os} - target_makefile_frag=config/tmake-${target} - -#### configure.in per-target parts come in here. - -# assign cpu type -emulation=generic - -cpu_type=${target_cpu} - -# assign object format -case ${target_os} in -sysv* | -coff*) - obj_format=coff - ;; -bout*) - obj_format=bout - ;; -bsd* | sunos* | *) - obj_format=aout - ;; -generic) - obj_format=generic - ;; -esac - -# assign floating point type -case ${target_cpu} in -vax) - atof=vax - ;; -*) - atof=ieee - ;; -esac - -# and target makefile frag - -target_makefile_frag=config/tmake-${target_cpu} - -files="config/ho-${gas_host}.h config/tc-${cpu_type}.c \ - config/tc-${cpu_type}.h config/te-${emulation}.h \ - config/obj-${obj_format}.h config/obj-${obj_format}.c \ - config/atof-${atof}.c" - -links="host.h targ-cpu.c targ-cpu.h targ-env.h obj-format.h obj-format.c atof-targ.c" -## end of per-target part. - - # Temporarily, we support only direct subdir builds. - hostsubdir=H-${host_alias} - targetsubdir=T-${target_alias} - - if [ -n "${removing}" ] ; then - if [ -n "${subdirs}" ] ; then - if [ -d "${hostsubdir}" ] ; then - rm -rf ${hostsubdir}/${targetsubdir} - - if [ -z "`(ls ${hostsubdir}) 2>&1 | grep Target- | grep -v Target-independent`" ] ; then - rm -rf ${hostsubdir} - fi - else - echo Warning: no `pwd`/${hostsubdir} to remove. - fi - else - rm -f ${Makefile} config.status ${links} - fi - else - if [ -n "${subdirs}" ] ; then - # check for existing status before allowing forced subdirs. - if [ -f ${Makefile} ] ; then - echo '***' "${Makefile} already exists in source directory. `pwd` not configured." 1>&2 - exit 1 - fi - - if [ ! -d ${hostsubdir} ] ; then mkdir ${hostsubdir} ; fi - cd ${hostsubdir} - - if [ ! -d ${targetsubdir} ] ; then - if [ -z "${commontargets}" ] ; then - mkdir ${targetsubdir} - else - if [ ! -d Target-independent ] ; then - mkdir Target-independent - fi - - ${symbolic_link} Target-independent ${targetsubdir} - fi # if target independent - fi # if no target dir yet - - cd ${targetsubdir} - - srcdir=../.. - else - # if not subdir builds, then make sure none exist. - if [ -n "`(ls .) 2>&1 | grep Host-`" ] ; then - echo '***' "Configured subdirs exist. `pwd` not configured." 1>&2 - exit 1 - fi - fi - - # Find the source files, if location was not specified. - if [ -z "${srcdir}" ] ; then - srcdirdefaulted=1 - srcdir=. - if [ -n "${srctrigger}" -a ! -r ${srctrigger} ] ; then - srcdir=.. - fi - fi - - if [ -n "${srctrigger}" -a ! -r ${srcdir}/${srctrigger} ] ; then - if [ -z "${srcdirdefaulted}" ] ; then - echo '***' "${progname}: Can't find ${srcname} sources in `pwd`/${srcdir}" 1>&2 - else - echo '***' "${progname}: Can't find ${srcname} sources in `pwd`/. or `pwd`/.." 1>&2 - fi - - echo '***' \(At least ${srctrigger} is missing.\) 1>&2 - exit 1 - fi - - # Set up the list of links to be made. - # ${links} is the list of link names, and ${files} is the list of names to link to. - - # Make the links. - while [ -n "${files}" ] ; do - # set file to car of files, files to cdr of files - set ${files}; file=$1; shift; files=$* - set ${links}; link=$1; shift; links=$* - - if [ ! -r ${srcdir}/${file} ] ; then - echo '***' "${progname}: cannot create a link \"${link}\"," 1>&2 - echo '***' "since the file \"${file}\" does not exist." 1>&2 - exit 1 - fi - - ${remove} -f ${link} - rm -f config.status - # Make a symlink if possible, otherwise try a hard link - ${symbolic_link} ${srcdir}/${file} ${link} 2>/dev/null || ${hard_link} ${srcdir}/${file} ${link} - - if [ ! -r ${link} ] ; then - echo '***' "${progname}: unable to link \"${link}\" to \"${srcdir}/${file}\"." 1>&2 - exit 1 - fi - - if [ -n "${verbose}" ] ; then - echo "Linked \"${link}\" to \"${srcdir}/${file}\"." - fi - done - - # Create a .gdbinit file which runs the one in srcdir - # and tells GDB to look there for source files. - - case ${srcdir} in - .) - ;; - *) - echo "dir ." > .gdbinit - echo "dir ${srcdir}" >> .gdbinit - echo "source ${srcdir}/.gdbinit" >> .gdbinit - ;; - esac - - # Install a makefile, and make it set VPATH - # if necessary so that the sources are found. - # Also change its value of srcdir. - - # FIXME-someday: This business of always writing to .tem and mv back - # is so that I don't screw things up while developing. Once this - # template is stable, these should be optimized. xoxorich. - - # Define macro CROSS_COMPILE in compilation if this is a cross-compiler. - if [ "${host}" != "${target}" ] ; then - echo "CROSS=-DCROSS_COMPILE" > ${Makefile} - echo "ALL=start.encap" >> ${Makefile} - else - echo "ALL=all.internal" > ${Makefile} - fi - - # set target, host, VPATH - echo "host_alias = ${host_alias}" >> ${Makefile} - echo "host_cpu = ${host_cpu}" >> ${Makefile} - echo "host_vendor = ${host_vendor}" >> ${Makefile} - echo "host_os = ${host_os}" >> ${Makefile} - - echo "target_alias = ${target_alias}" >> ${Makefile} - echo "target_cpu = ${target_cpu}" >> ${Makefile} - echo "target_vendor = ${target_vendor}" >> ${Makefile} - echo "target_os = ${target_os}" >> ${Makefile} - - if [ -n "${subdirs}" ] ; then - echo "subdir = /${hostsubdir}/${targetsubdir}" >> ${Makefile} - else - echo "subdir =" >> ${Makefile} - fi - - # echo "workdir = `pwd`" >> ${Makefile} - echo "VPATH = ${srcdir}" >> ${Makefile} - - # add "Makefile.in" (or whatever it's called) - cat ${srcdir}/${Makefile_in} >> ${Makefile} - - # Conditionalize the makefile for this host. - if [ -f ${srcdir}/${host_makefile_frag} ] ; then - (echo "host_makefile_frag = ${srcdir}/${host_makefile_frag}" ; - sed -e "/^####/ r ${srcdir}/${host_makefile_frag}" ${Makefile}) > Makefile.tem - mv Makefile.tem ${Makefile} - fi - - # Conditionalize the makefile for this target. - if [ -f ${srcdir}/${target_makefile_frag} ] ; then - (echo "target_makefile_frag = ${srcdir}/${target_makefile_frag}" ; - sed -e "/^####/ r ${srcdir}/${target_makefile_frag}" ${Makefile}) > Makefile.tem - mv Makefile.tem ${Makefile} - fi - - # set srcdir - sed "s@^srcdir = \.@srcdir = ${srcdir}@" ${Makefile} > Makefile.tem - mv Makefile.tem ${Makefile} - - # set destdir - if [ -n "${destdir}" ] ; then - sed "s:^destdir =.*$:destdir = ${destdir}:" ${Makefile} > Makefile.tem - mv Makefile.tem ${Makefile} - fi - - # reset SUBDIRS - sed "s:^SUBDIRS =.*$:SUBDIRS = ${configdirs}:" ${Makefile} > Makefile.tem - mv Makefile.tem ${Makefile} - - # reset NONSUBDIRS - sed "s:^NONSUBDIRS =.*$:NONSUBDIRS = ${noconfigdirs}:" ${Makefile} > Makefile.tem - mv Makefile.tem ${Makefile} - - using= - if [ -f ${srcdir}/${host_makefile_frag} ] ; then - using=" using \"${host_makefile_frag}\"" - fi - - # remove any form feeds. - sed -e "s/ //" ${Makefile} > Makefile.tem - mv Makefile.tem ${Makefile} - - if [ -f ${srcdir}/${target_makefile_frag} ] ; then - if [ -z "${using}" ] ; then - andusing=" using \"${target_makefile_frag}\"" - else - andusing="${using} and \"${target_makefile_frag}\"" - fi - else - andusing=${using} - fi - - if [ -n "${verbose}" -o -z "${recurring}" ] ; then - echo "Created \"${Makefile}\"" in `pwd`${andusing}. - fi - -#### configure.in post-target parts come in here. - -## end of post-target part. - - # describe the chosen configuration in config.status. - # Make that file a shellscript which will reestablish - # the same configuration. Used in Makefiles to rebuild - # Makefiles. - - echo "#!/bin/sh -# ${srcname} was configured as follows: -${srcdir}/configure" ${arguments} `if [ -z "${norecursion}" ] ; then echo +norecursion ; else true ; fi` > config.status - chmod a+x config.status - - originaldir=`pwd` - cd ${srcdir} - fi - - # If there are subdirectories, then recurse. - if [ -z "${norecursion}" -a -n "${configdirs}" ] ; then - for configdir in ${configdirs} ; do - if [ -n "${verbose}" ] ; then - echo Configuring ${configdir}... - fi - - if [ -d ${configdir} ] ; then - (cd ${configdir} ; - ./configure +recurring ${host_alias} +target=${target_alias} \ - ${verbose} ${subdirs} ${removing} +destdir=${destdir}) \ - | sed 's/^/ /' - else - if [ -n "${verbose}" ] ; then - echo Warning: directory \"${configdir}\" is missing. - fi - fi - done - fi - done # for each target - - # Now build a Makefile for this host. - if [ -n "${subdirs}" -a ! -n "${removing}" ] ; then - cd ${hostsubdir} - cat > GNUmakefile << E!O!F -# Makefile generated by configure for host ${host_alias}. - -ALL := $(shell ls -d Target-*) - -%: - $(foreach subdir,$(ALL),$(MAKE) -C $(subdir) \$@ &&) true - -all: -E!O!F - cd .. - fi -done # for each host - -exit 0 - -# -# Local Variables: -# fill-column: 131 -# End: -# - -# end of configure diff --git a/gas/configure.in b/gas/configure.in deleted file mode 100644 index 854352e1d9b..00000000000 --- a/gas/configure.in +++ /dev/null @@ -1,92 +0,0 @@ -# This file is a shell script that supplies the information necessary -# to tailor a template configure script into the configure script -# appropriate for this directory. For more information, check any -# existing configure script. - -srctrigger=as.c -srcname="gas" -targetdependent=true -need_bfd= -# per-host: - -gas_host=generic - -case "${host_cpu}" in -a29k | rs6000 | vax) gas_host=${host_cpu} ;; -mips) - case "${host_os}" in - ultrix) gas_host=decstation ;; - esac - ;; -*) - case "${host_os}" in - ansi | ultrix | hpux | sysv*) gas_host=${host_os} ;; - *) - case "${host_vendor}" in - sun) - case "${host_cpu}" in - m68k) gas_host=sun3 ;; - i386) gas_host=sun386 ;; - sparc) gas_host=sun4 ;; - esac - ;; - esac - ;; - esac - ;; -esac - -# per-target: - -# assign cpu type -emulation=generic - -cpu_type=${target_cpu} - -# assign object format -case ${target_os} in -bout*) obj_format=bout ;; -bsd* | sunos*) obj_format=aout ;; - -ebmon) - obj_format=coff - need_bfd="$(unsubdir)/../bfd$(subdir)/libbfd.a" - target_cpu=ebmon29k - ;; - -generic) obj_format=generic ;; - -hds) - obj_format=ieee - need_bfd="$(unsubdir)/../bfd$(subdir)/libbfd.a" - ;; - -coff* | sysv*) obj_format=coff ;; - -*) - case ${target_vendor} in - aout) obj_format=aout ;; - bout) obj_format=bout ;; - coff) obj_format=coff ;; - *) obj_format=aout ;; - esac - ;; - -esac - -# assign floating point type -case ${target_cpu} in -vax) atof=vax ;; -*) atof=ieee ;; -esac - -# and target makefile frag - -target_makefile_frag=config/mt-${target_cpu} - -files="config/ho-${gas_host}.h config/tc-${cpu_type}.c \ - config/tc-${cpu_type}.h config/te-${emulation}.h \ - config/obj-${obj_format}.h config/obj-${obj_format}.c \ - config/atof-${atof}.c" - -links="host.h targ-cpu.c targ-cpu.h targ-env.h obj-format.h obj-format.c atof-targ.c" diff --git a/gas/configure.was b/gas/configure.was deleted file mode 100755 index 24859272f04..00000000000 --- a/gas/configure.was +++ /dev/null @@ -1,340 +0,0 @@ -#!/bin/sh -# Configuration script for GNU GAS -# Copyright (C) 1988, 1990, 1991 Free Software Foundation, Inc. - -#This file is not yet part of GNU GAS. - -#GNU GAS 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 1, or (at your option) -#any later version. - -#GNU GAS 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 GNU GAS; see the file COPYING. If not, write to -#the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - -# $Id$ - -# -# Shell script to create proper links to machine-dependent files in -# preparation for compiling gas. -# -# Usage: configure [-srcdir=DIR] [-host=HOST] TARGET -# -# If configure succeeds, it leaves its status in config.status. -# If configure fails after disturbing the status quo, -# config.status is removed. -# - -progname=$0 - -remove=rm -hard_link=ln -symbolic_link='ln -s' - -host= -target= - -#for Test -#remove="echo rm" -#hard_link="echo ln" -#symbolic_link="echo ln -s" - -for arg in $*; -do - case $arg in - -srcdir=* | +srcdir=* | +srcdi=* | +srcd=* | +src=* | +sr=* | +s=*) - srcdir=`echo $arg | sed 's/[+-]s[a-z]*=//'` - ;; - -host=* | +host=* | +hos=* | +ho=* | +h=*) - host=`echo $arg | sed 's/[+-]h[a-z]*=//'` - ;; - *) -# Allow configure HOST TARGET - if [ x$host = x ] - then - host=$target - fi - target=$arg - ;; - esac -done - -# Complain if an arg is missing -if [ x$target = x ] -then - echo "Usage: $progname [+srcdir=DIR] [+host=HOST] TARGET" - echo -n "Where HOST and TARGET are something like " - echo "\`vax', \`sun3', \`encore', etc." - if [ -r config.status ] - then - cat config.status - fi - exit 1 -fi - -# Default other arg -if [ x$host = x ] -then - host=$target -fi - -# Find the source files, if location was not specified. -if [ x$srcdir = x ] -then - srcdirdefaulted=1 - srcdir=. - if [ ! -r as.c ] - then - srcdir=.. - fi -fi - -if [ ! -r ${srcdir}/as.c ] -then - if [ x$srcdirdefaulted = x ] - then - echo "$progname: Can't find assembler sources in \`${srcdir}'." 1>&2 - else - echo "$progname: Can't find assembler sources in \`.' or \`..'." 1>&2 - fi - exit 1 -fi - -# Decode the host machine, then the target machine. -# For the host machine, we save the ho variable as host_ho; -# then we decode the target machine and forget everything else -# that came from the host machine. -for machine in $host $target; do - tc= - obj= - - host_header= - obj_header= - obj_source= - te_header= - tc_header= - tc_source= - - make_var_file= - - case $machine in - generic) - ;; - i860) - tc=i860 - obj=aout - ;; - pmax | dec3100) - ho=pmax - ;; - sun386) - ho=sun386 - ;; - sun4 | sun4-aout | sun-4 | sun4-os4 | sun-4-os4) - ho=sun4 - tc=sparc - obj=aout - ;; - sun4-bout) - tc=sparc - obj=bout - ;; - sun4-bfd-sunos) - tc=sparc - obj=bfd-sunos - ;; - i960 | i960-coff) - tc=i960 - obj=coff - te=ic960 - ;; - i960-bout) - tc=i960 - obj=bout - ;; - i960-aout) - tc=i960 - obj=aout - ;; - sun3 | sun3-aout) - ho=sun3 - tc=m68k - obj=aout - te=sun3 - ;; - a29k | a29k-aout) - tc=a29k - obj=aout - ;; - a29k-coff) - tc=a29k - obj=coff - ;; - i386) - tc=i386 - obj=aout - ;; - ns32k) - tc=ns32k - obj=aout - ;; - vax) - tc=vax - obj=aout - ;; - rs6000) - ;; - esac - if [ x$pass1done = x ] - then - if [ x$ho = x ]; then ho=$host; fi - if [ x$ho_header = x ]; then ho_ho_header=ho-$ho.h - else ho_ho_header=$ho_header - fi - if [ x$make_var_file = x ] - then make_var_file=make-$ho; fi - ho_make_var_file=$make_var_file - pass1done=yes - else - host_make_var_file=$ho_make_var_file - ho_header=$ho_ho_header - fi -done - - -# Default the machine-specific variables that were not explicitly set. -if [ x$te = x ] -then te=generic; fi - -if [ x$te_header = x ] -then te_header=te-$te.h; fi - - -if [ x$tc = x ] -then tc=generic; fi - -if [ x$tc_header = x ] -then tc_header=tc-$tc.h; fi - -if [ x$tc_source = x ] -then tc_source=tc-$tc.c; fi - - -if [ x$obj = x ] -then obj=generic; fi - -if [ x$obj_header = x ] -then obj_header=obj-$obj.h; fi - -if [ x$obj_source = x ] -then obj_source=obj-$obj.c; fi - - -if [ x$atof_source = x ] -then atof_source=atof-ieee.c; fi - -# Set up the list of links to be made. -# $links is the list of link names, and $files is the list of names to link to. -files="$ho_header $te_header $tc_header $tc_source $obj_header $obj_source $atof_source" -links="host.h targ-env.h targ-cpu.h targ-cpu.c obj-format.h obj-format.c atof-targ.c" - -# Make the links. -while [ -n "$files" ] -do - # set file to car of files, files to cdr of files - set $files; file=$1; shift; files=$* - set $links; link=$1; shift; links=$* - - if [ ! -r ${srcdir}/config/$file ] - then - echo "$progname: cannot create a link \`$link'," 1>&2 - echo "since the file \`config/$file' does not exist." 1>&2 - exit 1 - fi - - $remove -f $link - rm -f config.status - # Make a symlink if possible, otherwise try a hard link - $symbolic_link ${srcdir}/config/$file $link 2>/dev/null || $hard_link ${srcdir}/config/$file $link - - if [ ! -r $link ] - then - echo "$progname: unable to link \`$link' to \`${srcdir}/config/$file'." 1>&2 - exit 1 - fi - echo "Linked \`$link' to \`${srcdir}/config/$file'." -done - -# Build a Makefile - -# Install a makefile, and make it set srcdir -# if necessary so that the sources are found. -# Also change its value of srcdir. -# Also create a .gdbinit file which runs the one in srcdir -# and tells GDB to look there for source files. -case $srcdir in -.) - ;; -*) - echo "VPATH = ${srcdir}" > x - cat x ${srcdir}/Makefile.in | sed "s@^srcdir = \.@srcdir = ${srcdir}@" > Makefile.in - rm x - echo "dir ." > .gdbinit - echo "dir ${srcdir}" >> .gdbinit - echo "source ${srcdir}/.gdbinit" >> .gdbinit - ;; -esac - -# Conditionalize the makefile for this machine. -if [ -f ${srcdir}/config/${host_make_var_file} ] -then - sed -e "/####/ r ${srcdir}/config/${host_make_var_file}" Makefile.in > Makefile.tem -else - cp Makefile.in Makefile.tem -fi - -# Remove all formfeeds, since some Makes get confused by them. -sed "s/ //" Makefile.tem > Makefile.tem1 - -# Delete the intermediate files -rm Makefile.tem -if [ x$srcdir != x. ] -then - rm Makefile.in -fi - - -# actual Makefile starts here. - -echo "host = $host" > Makefile -echo "target = $target" >> Makefile - -# Define macro CROSS_ASSEMBLE in compilation if this is a cross-assembler. -if [ x$host = x$target ] -then - sed "/^ALL=gas/s//ALL=bootstrap/" < Makefile.tem1 >> Makefile -else - echo "CROSS=-DCROSS_ASSEMBLE" >> Makefile - cat Makefile.tem1 >> Makefile -fi - -rm Makefile.tem1 - -echo "Edited the makefile" - -if [ x$host = x$target ] -then - echo "Links are now set up for use with a $target." \ - | tee config.status -else - echo "Links are now set up for host $host and target $target." \ - | tee config.status -fi - -exit 0 diff --git a/gas/debug.c b/gas/debug.c deleted file mode 100644 index c1e1dbef207..00000000000 --- a/gas/debug.c +++ /dev/null @@ -1,79 +0,0 @@ -/* Routines for debug use only. Don't link into product. - */ - -#include "as.h" -#include "subsegs.h" - -dmp_frags() -{ - frchainS *chp; - char *p; - - for ( chp=frchain_root; chp; chp = chp->frch_next ){ - switch ( chp->frch_seg ){ - case SEG_DATA: - p ="Data"; - break; - case SEG_TEXT: - p ="Text"; - break; - default: - p ="???"; - break; - } - printf("\nSEGMENT %s %d\n", p, chp->frch_subseg); - dmp_frag( chp->frch_root,"\t"); - } -} - -dmp_frag( fp, indent ) - struct frag *fp; - char *indent; -{ - for ( ; fp; fp = fp->fr_next ){ - printf("%sFRAGMENT @ 0x%x\n", indent, fp); - switch( fp->fr_type ){ - case rs_align: - printf("%srs_align(%d)\n",indent, fp->fr_offset); - break; - case rs_fill: - printf("%srs_fill(%d)\n",indent, fp->fr_offset); - printf("%s", indent); - var_chars( fp, fp->fr_var + fp->fr_fix ); - printf("%s\t repeated %d times,", - indent, fp->fr_offset); - printf(" fixed length if # chars == 0)\n"); - break; - case rs_org: - printf("%srs_org(%d+sym @0x%x)\n",indent, - fp->fr_offset, fp->fr_symbol); - printf("%sfill with ",indent); - var_chars( fp, 1 ); - printf("\n"); - break; - case rs_machine_dependent: - printf("%smachine_dep\n",indent); - break; - default: - printf("%sunknown type\n",indent); - break; - } - printf("%saddr=%d(0x%x)\n",indent,fp->fr_address,fp->fr_address); - printf("%sfr_fix=%d\n",indent,fp->fr_fix); - printf("%sfr_var=%d\n",indent,fp->fr_var); - printf("%sfr_offset=%d\n",indent,fp->fr_offset); - printf("%schars @ 0x%x\n",indent,fp->fr_literal); - printf("\n"); - } -} - -var_chars( fp, n ) - struct frag *fp; - int n; -{ - unsigned char *p; - - for ( p=(unsigned char*)fp->fr_literal; n; n-- , p++ ){ - printf("%02x ", *p ); - } -} diff --git a/gas/doc/Makefile b/gas/doc/Makefile deleted file mode 100755 index 463f645e961..00000000000 --- a/gas/doc/Makefile +++ /dev/null @@ -1,91 +0,0 @@ -# Makefile for as.texinfo preprocessing and TeXing -# $Id$ -# see pretex.m4 for discussion of preprocessor definitions - -# What version of the manual you want (see *.m4); "all" includes everything -CONFIG=all - -# Sun/Berkeley m4 doesn't have all the things we need; use GNU or sV -#M4=gm4 -M4=/usr/5bin/m4 - -# Directory for gas source -srcdir=.. - -# Where to find texinfo.tex to format docn with TeX -TEXIDIR = $(srcdir)/../texinfo/fsf - -as.info: as-${CONFIG}.texinfo - makeinfo -o as.info as-${CONFIG}.texinfo - -# There's no index yet; when there is, add texindex call before tex 2nd pass -as.dvi: as-${CONFIG}.texinfo - TEXINPUTS=${TEXIDIR}:.:$$TEXINPUTS tex as-${CONFIG}.texinfo - TEXINPUTS=${TEXIDIR}:.:$$TEXINPUTS tex as-${CONFIG}.texinfo - mv as-${CONFIG}.dvi as.dvi - rm as-${CONFIG}.?? as-${CONFIG}.??? - -# ROFF doc targets as.ms, as.mm, as.me -# (we don't use a variable because we don't trust all makes to handle -# a var in the target name right). -# roff output (-ms) -as.ms: as-${CONFIG}.texinfo - sed -e '/\\input texinfo/d' \ - -e '/@c TEXI2ROFF-KILL/,/@c END TEXI2ROFF-KILL/d' \ - -e 's/{.*,,/{/' \ - as-${CONFIG}.texinfo | \ - texi2roff -ms >as.ms - -# roff output (-mm) -as.mm: as-${CONFIG}.texinfo - sed -e '/\\input texinfo/d' \ - -e '/@c TEXI2ROFF-KILL/,/@c END TEXI2ROFF-KILL/d' \ - -e 's/{.*,,/{/' \ - -e '/@noindent/d' \ - as-${CONFIG}.texinfo | \ - texi2roff -mm | \ - sed -e 's/---/\\(em/g' \ - >as.mm - -# roff output (-me) -as.me: as-${CONFIG}.texinfo - sed -e '/\\input texinfo/d' \ - -e '/@c TEXI2ROFF-KILL/,/@c END TEXI2ROFF-KILL/d' \ - -e 's/{.*,,/{/' \ - as-${CONFIG}.texinfo | \ - texi2roff -me >as.me - - - -as-all.texinfo: as.texinfo pretex.m4 none.m4 all.m4 - ${M4} pretex.m4 none.m4 all.m4 as.texinfo >as-all.texinfo - -as-amd29k.texinfo: as.texinfo pretex.m4 none.m4 amd29k.m4 - ${M4} pretex.m4 none.m4 amd29k.m4 as.texinfo >as-amd29k.texinfo - -as-amd29k-coff.texinfo: as.texinfo pretex.m4 none.m4 amd29k-coff.m4 - ${M4} pretex.m4 none.m4 amd29k-coff.m4 as.texinfo >as-amd29k-coff.texinfo - -as-gen.texinfo: as.texinfo pretex.m4 none.m4 gen.m4 - ${M4} pretex.m4 none.m4 gen.m4 as.texinfo >as-gen.texinfo - -as-i80386.texinfo: as.texinfo pretex.m4 none.m4 i80386.m4 - ${M4} pretex.m4 none.m4 i80386.m4 as.texinfo >as-i80386.texinfo - -as-i960.texinfo: as.texinfo pretex.m4 none.m4 i960.m4 - ${M4} pretex.m4 none.m4 i960.m4 as.texinfo >as-i960.texinfo - -as-m680x0.texinfo: as.texinfo pretex.m4 none.m4 m680x0.m4 - ${M4} pretex.m4 none.m4 m680x0.m4 as.texinfo >as-m680x0.texinfo - -as-sparc.texinfo: as.texinfo pretex.m4 none.m4 sparc.m4 - ${M4} pretex.m4 none.m4 sparc.m4 as.texinfo >as-sparc.texinfo - -as-vax.texinfo: as.texinfo pretex.m4 none.m4 vax.m4 - ${M4} pretex.m4 none.m4 vax.m4 as.texinfo >as-vax.texinfo - -as-vintage.texinfo: as.texinfo pretex.m4 none.m4 vintage.m4 - ${M4} pretex.m4 none.m4 vintage.m4 as.texinfo >as-vintage.texinfo - -clean: - rm -f as-${CONFIG}.* as.dvi diff --git a/gas/doc/a29k-coff.m4 b/gas/doc/a29k-coff.m4 deleted file mode 100644 index 29ebd342a94..00000000000 --- a/gas/doc/a29k-coff.m4 +++ /dev/null @@ -1,10 +0,0 @@ -_divert__(-1) -_define__(<_AMD29K__>,<1>) -_define__(<_GENERIC__>,<0>) -_define__(<_HOST__>,) -_define__(<_MACH_DEP__>,) -_define__(<_AOUT__>,<0>) -_define__(<_BOUT__>,<0>) -_define__(<_COFF__>,<1>) -_define__(<_ELF__>,<0>) -_divert__<> \ No newline at end of file diff --git a/gas/doc/a29k.m4 b/gas/doc/a29k.m4 deleted file mode 100644 index 7f368340af1..00000000000 --- a/gas/doc/a29k.m4 +++ /dev/null @@ -1,5 +0,0 @@ -_divert__(-1) -_define__(<_AMD29K__>,<1>) -_define__(<_HOST__>,) -_define__(<_MACH_DEP__>,) -_divert__<> \ No newline at end of file diff --git a/gas/doc/all.m4 b/gas/doc/all.m4 deleted file mode 100644 index 66f1fdd9c3b..00000000000 --- a/gas/doc/all.m4 +++ /dev/null @@ -1,19 +0,0 @@ -_divert__(-1) -<$Id$> -_define__(<_ALL_ARCH__>,<1>) -_define__(<_GENERIC__>,<1>) In case none.m4 changes its mind abt default - -_define__(<_AOUT__>,<1>) -_define__(<_BOUT__>,<1>) -_define__(<_COFF__>,<1>) -_define__(<_ELF__>,<1>) - -_define__(<_AMD29K__>,<1>) -_define__(<_I80386__>,<1>) -_define__(<_I960__>,<1>) -_define__(<_M680X0__>,<1>) -_define__(<_SPARC__>,<1>) -_define__(<_VAX__>,<1>) -_define__(<_VXWORKS__>,<1>) - -_divert__<> \ No newline at end of file diff --git a/gas/doc/as.texinfo b/gas/doc/as.texinfo deleted file mode 100644 index e79b61eb869..00000000000 --- a/gas/doc/as.texinfo +++ /dev/null @@ -1,5304 +0,0 @@ -\input texinfo -@c $Id$ -@c @tex -@c \special{twoside} -@c @end tex -_if__(_GENERIC__) -@setfilename as.info -_fi__(_GENERIC__) -_if__(_AMD29K__ && !_GENERIC__) -@setfilename as-29k.info -_fi__(_AMD29K__ && !_GENERIC__) -_if__(_I960__ && !_GENERIC__) -@setfilename as-960.info -_fi__(_I960__ && !_GENERIC__) -_if__(_M680X0__ && !_GENERIC__) -@setfilename as-m680x0.info -_fi__(_M680X0__ && !_GENERIC__) -_if__(0) - -NOTE: this manual is marked up for preprocessing with a collection -of m4 macros called "pretex.m4". - -THIS IS THE FULL SOURCE. The full source needs to be run through m4 -before either tex- or info- formatting: for example, - m4 pretex.m4 none.m4 m680x0.m4 as.texinfo >as-680x0.texinfo -will produce (assuming your path finds either GNU or SysV m4; Berkeley -won't do) a file suitable for formatting. See the text in "pretex.m4" -for a fuller explanation (and the macro definitions). - -_fi__(0) -@c -@synindex ky cp -@ifinfo -This file documents the GNU Assembler "_AS__". - -Copyright (C) 1991 Free Software Foundation, Inc. - -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. - -@ignore -Permission is granted to process this file through Tex and print the -results, provided the printed document carries copying permission -notice identical to this one except for the removal of this paragraph -(this paragraph not being relevant to the printed manual). - -@end ignore -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided also that the -section entitled ``GNU General Public License'' is included exactly as -in the original, and provided that the entire resulting derived work is -distributed under the terms of a permission notice identical to this -one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions, -except that the section entitled ``GNU General Public License'' may be -included in a translation approved by the Free Software Foundation -instead of in the original English. -@end ifinfo -@iftex -@finalout -@c @smallbook -@end iftex -@setchapternewpage odd -_if__(_GENERIC__) -@settitle Using _AS__ -_fi__(_GENERIC__) -_if__(!_GENERIC__) -@settitle Using _AS__ (_HOST__) -_fi__(!_GENERIC__) -@titlepage -@title{Using _AS__} -@subtitle{The GNU Assembler} -_if__(!_GENERIC__) -@subtitle{for the _HOST__ family} -_fi__(!_GENERIC__) -@sp 1 -@subtitle March 1991 -@sp 1 -@sp 13 -The Free Software Foundation Inc. thanks The Nice Computer -Company of Australia for loaning Dean Elsner to write the -first (Vax) version of @code{as} for Project GNU. -The proprietors, management and staff of TNCCA thank FSF for -distracting the boss while they got some work -done. -@sp 3 -@author{Dean Elsner, Jay Fenlason & friends} -@c edited by: pesch@cygnus.com -@page -@tex -\def\$#1${{#1}} % Kluge: collect RCS revision info without $...$ -\xdef\manvers{\$Revision$} % For use in headers, footers too -{\parskip=0pt -\hfill edited by Roland Pesch\par -\hfill for Cygnus Support\par -\hfill \manvers\par -\hfill \TeX{}info \texinfoversion\par -} -%"boxit" macro for figures: -%Modified from Knuth's ``boxit'' macro from TeXbook (answer to exercise 21.3) -\gdef\boxit#1#2{\vbox{\hrule\hbox{\vrule\kern3pt - \vbox{\parindent=0pt\parskip=0pt\hsize=#1\kern3pt\strut\hfil -#2\hfil\strut\kern3pt}\kern3pt\vrule}\hrule}}%box with visible outline -\gdef\ibox#1#2{\hbox to #1{#2\hfil}\kern8pt}% invisible box -@end tex - -@vskip 0pt plus 1filll -Copyright @copyright{} 1991 Free Software Foundation, Inc. - -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. - -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided also that the -section entitled ``GNU General Public License'' is included exactly as -in the original, and provided that the entire resulting derived work is -distributed under the terms of a permission notice identical to this -one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions, -except that the section entitled ``GNU General Public License'' may be -included in a translation approved by the Free Software Foundation -instead of in the original English. -@end titlepage -@page -@node Top, Overview, (dir), (dir) -@ifinfo -This file is a user guide to the GNU assembler @code{_AS__}. -_if__(!_GENERIC__) -This version of the file describes @code{_AS__} configured to generate -code for _HOST__ architectures. -_fi__(!_GENERIC__) -@end ifinfo -@menu -* Overview:: Overview -* Invoking:: Command-Line Options -* Syntax:: Syntax -* Segments:: Segments and Relocation -* Symbols:: Symbols -* Expressions:: Expressions -* Pseudo Ops:: Assembler Directives -* Machine Dependent:: Machine Dependent Features -* License:: GNU GENERAL PUBLIC LICENSE -@end menu - -@node Overview, Invoking, Top, Top -@chapter Overview -@iftex -This manual is a user guide to the GNU assembler @code{_AS__}. -_if__(!_GENERIC__) -This version of the manual describes @code{_AS__} configured to generate -code for _HOST__ architectures. -_fi__(!_GENERIC__) -@end iftex - -@heading Invoking @code{_AS__} - -Here is a brief summary of how to invoke @code{_AS__}. For details, -@pxref{Invoking,,Comand-Line Options}. - -@c We don't use @deffn and friends for the following because they seem -@c to be limited to one line for the header. -@smallexample - _AS__ [ -D ] [ -f ] [ -I @var{path} ] [ -k ] [ -L ] - [ -o @var{objfile} ] [ -R ] [ -v ] [ -w ] -_if__(_AMD29K__) -@c am29k has no machine-dependent assembler options -_fi__(_AMD29K__) -_if__(_I960__) -@c see md_parse_option in i960.c - [ -ACA | -ACA_A | -ACB | -ACC | -AKA | -AKB | -AKC | -AMC ] - [ -b ] [ -norelax ] -_fi__(_I960__) -_if__(_M680X0__) - [ -l ] [ -mc68000 | -mc68010 | -mc68020 ] -_fi__(_M680X0__) - [ -- | @var{files} @dots{} ] -@end smallexample - -@table @code - -@item -D -This option is accepted only for script compatibility with calls to -other assemblers; it has no effect on @code{_AS__}. - -@item -f -``fast''---skip preprocessing (assume source is compiler output) - -@item -I @var{path} -Add @var{path} to the search list for @code{.include} directives - -@item -k -_if__((!_GENERIC__) && (_AMD29K__ || _I960__)) -This option is accepted but has no effect on the _HOST__ family. -_fi__((!_GENERIC__) && (_AMD29K__ || _I960__)) -_if__(_GENERIC__) -Issue warnings when difference tables altered for long displacements. -_fi__(_GENERIC__) - -@item -L -Keep (in symbol table) local symbols, starting with @samp{L} - -@item -o @var{objfile} -Name the object-file output from @code{_AS__} - -@item -R -Fold data segment into text segment - -@item -W -Suppress warning messages - -_if__(_I960__) -@item -ACA | -ACA_A | -ACB | -ACC | -AKA | -AKB | -AKC | -AMC -Specify which variant of the 960 architecture is the target. - -@item -b -Add code to collect statistics about branches taken. - -@item -norelax -Do not alter compare-and-branch instructions for long displaements; -error if necessary. -_fi__(_I960__) - -_if__(_M680X0__) -@item -l -_if__(_GENERIC__) -(When configured for Motorola 68000). -_fi__(_GENERIC__) -Shorten references to undefined symbols, to one word instead of two - -@item -mc68000 | -mc68010 | -mc68020 -_if__(_GENERIC__) -(When configured for Motorola 68000). -_fi__(_GENERIC__) -Specify what processor in the 68000 family is the target (default 68020) -_fi__(_M680X0__) - -@item -- | @var{files} @dots{} -Source files to assemble, or standard input -@end table - -@menu -* Manual:: Structure of this Manual -* GNU Assembler:: _AS__, the GNU Assembler -* Object Formats:: Object File Formats -* Command Line:: Command Line -* Input Files:: Input Files -* Object:: Output (Object) File -* Errors:: Error and Warning Messages -@end menu - -@node Manual, GNU Assembler, Overview, Overview -@section Structure of this Manual -This document is intended to describe what you need to know to use -@code{_AS__}. We cover the syntax expected in source files, including -notation for symbols, constants, and expressions; the directives that -@code{_AS__} understands; and of course how to invoke @code{_AS__}. - -_if__(!_GENERIC__) -We also cover special features in the _HOST__ -configuration of @code{_AS__}, including assembler directives. -_fi__(!_GENERIC__) -_if__(_GENERIC__) -This document also describes some of the machine-dependent features of -various flavors of the assembler. -_fi__(_GENERIC__) -_if__(_INTERNALS__) -This document also describes how the assembler works internally, and -provides some information that may be useful to people attempting to -port the assembler to another machine. -_fi__(_INTERNALS__) -@refill - -On the other hand, this manual is @emph{not} intended as an introduction -to programming in assembly language---let alone programming in general! -In a similar vein, we make no attempt to introduce the machine -architecture; we do @emph{not} describe the instruction set, standard -mnemonics, registers or addressing modes that are standard to a -particular architecture. You may want to consult the manufacturer's -machine architecture manual for this information. - - -@c I think this is premature---pesch@cygnus.com, 17jan1991 -@ignore -Throughout this document, we assume that you are running @dfn{GNU}, -the portable operating system from the @dfn{Free Software -Foundation, Inc.}. This restricts our attention to certain kinds of -computer (in particular, the kinds of computers that GNU can run on); -once this assumption is granted examples and definitions need less -qualification. - -@code{_AS__} is part of a team of programs that turn a high-level -human-readable series of instructions into a low-level -computer-readable series of instructions. Different versions of -@code{_AS__} are used for different kinds of computer. -@end ignore - -@c There used to be a section "Terminology" here, which defined -@c "contents", "byte", "word", and "long". Defining "word" to any -@c particular size is confusing when the .word directive may generate 16 -@c bits on one machine and 32 bits on another; in general, for the user -@c version of this manual, none of these terms seem essential to define. -@c They were used very little even in the former draft of the manual; -@c this draft makes an effort to avoid them (except in names of -@c directives). - -@node GNU Assembler, Object Formats, Manual, Overview -@section _AS__, the GNU Assembler -GNU @code{as} is really a family of assemblers. -_if__(!_GENERIC__) -This manual describes @samp{_AS__}, a member of that family which is -configured for the _HOST__ architectures. -_fi__(!_GENERIC__) -If you use (or have used) the GNU assembler on one architecture, you -should find a fairly similar environment when you use it on another -architecture. Each version has much in common with the others, -including object file formats, most assembler directives (often called -@dfn{pseudo-ops)} and assembler syntax.@refill - -@code{_AS__} is primarily intended to assemble the output of the GNU C -compiler @code{_GCC__} for use by the linker @code{_LD__}. Nevertheless, -we've tried to make @code{_AS__} assemble correctly everything that the native -assembler would. -_if__(_VAX__) -Any exceptions are documented explicitly (@pxref{_MACH_DEP__}). -_fi__(_VAX__) -_if__(_GENERIC__||_M680X0__) -This doesn't mean @code{_AS__} always uses the same syntax as another -assembler for the same architecture; for example, we know of several -incompatible versions of 680x0 assembly language syntax. -_fi__(_GENERIC__||_M680X0__) - -Unlike older assemblers, @code{_AS__} is designed to assemble a source -program in one pass of the source file. This has a subtle impact on the -@kbd{.org} directive (@pxref{Org,,@code{.org}}). - -@node Object Formats, Command Line, GNU Assembler, Overview -@section Object File Formats -The GNU assembler can be configured to produce several alternative -object file formats. -_if__(!_GENERIC__) -_if__(!_I960__) -@code{_AS__} is configured to produce @code{a.out} format object -files.@refill -_fi__(!_I960__) -_if__(_I960__) -@code{_AS__} can be configured to produce either @code{b.out} or COFF -format object files. -_fi__(_I960__) -_fi__(!_GENERIC__) - -@node Command Line, Input Files, Object Formats, Overview -@section Command Line - -After the program name @code{_AS__}, the command line may contain -options and file names. Options may be in any order, and may be -before, after, or between file names. The order of file names is -significant. - -@file{--} (two hyphens) by itself names the standard input file -explicitly, as one of the files for @code{_AS__} to assemble. - -Except for @samp{--} any command line argument that begins with a -hyphen (@samp{-}) is an option. Each option changes the behavior of -@code{_AS__}. No option changes the way another option works. An -option is a @samp{-} followed by one or more letters; the case of -the letter is important. All options are optional. - -Some options expect exactly one file name to follow them. The file -name may either immediately follow the option's letter (compatible -with older assemblers) or it may be the next command argument (GNU -standard). These two command lines are equivalent: - -@smallexample -_AS__ -o my-object-file.o mumble.s -_AS__ -omy-object-file.o mumble.s -@end smallexample - -@node Input Files, Object, Command Line, Overview -@section Input Files - -We use the phrase @dfn{source program}, abbreviated @dfn{source}, to -describe the program input to one run of @code{_AS__}. The program may -be in one or more files; how the source is partitioned into files -doesn't change the meaning of the source. - -@c I added "con" prefix to "catenation" just to prove I can overcome my -@c APL training... pesch@cygnus.com -The source program is a concatenation of the text in all the files, in the -order specified. - -Each time you run @code{_AS__} it assembles exactly one source -program. The source program is made up of one or more files. -(The standard input is also a file.) - -You give @code{_AS__} a command line that has zero or more input file -names. The input files are read (from left file name to right). A -command line argument (in any position) that has no special meaning -is taken to be an input file name. - -If @code{_AS__} is given no file names it attempts to read one input file -from the @code{_AS__} standard input, which is normally your terminal. You -may have to type @key{ctl-D} to tell @code{_AS__} there is no more program -to assemble. - -Use @samp{--} if you need to explicitly name the standard input file -in your command line. - -If the source is empty, @code{_AS__} will produce a small, empty object -file. - -@subheading Filenames and Line-numbers -There are two ways of locating a line in the input file (or files) and both -are used in reporting error messages. One way refers to a line -number in a physical file; the other refers to a line number in a -``logical'' file. - -@dfn{Physical files} are those files named in the command line given -to @code{_AS__}. - -@dfn{Logical files} are simply names declared explicitly by assembler -directives; they bear no relation to physical files. Logical file names -help error messages reflect the original source file, when @code{_AS__} -source is itself synthesized from other files. -@xref{App-File,,@code{.app-file}}. - -@node Object, Errors, Input Files, Overview -@section Output (Object) File -Every time you run @code{_AS__} it produces an output file, which is -your assembly language program translated into numbers. This file -is the object file, named @code{a.out} unless you tell @code{_AS__} to -give it another name by using the @code{-o} option. Conventionally, -object file names end with @file{.o}. The default name of -@file{a.out} is used for historical reasons: older assemblers were -capable of assembling self-contained programs directly into a -runnable program. -@c This may still work, but hasn't been tested. - -The object file is meant for input to the linker @code{_LD__}. It contains -assembled program code, information to help @code{_LD__} integrate -the assembled program into a runnable file, and (optionally) symbolic -information for the debugger. - -@comment link above to some info file(s) like the description of a.out. -@comment don't forget to describe GNU info as well as Unix lossage. - -@node Errors, , Object, Overview -@section Error and Warning Messages - -@code{_AS__} may write warnings and error messages to the standard error -file (usually your terminal). This should not happen when @code{_AS__} is -run automatically by a compiler. Warnings report an assumption made so -that @code{_AS__} could keep assembling a flawed program; errors report a -grave problem that stops the assembly. - -Warning messages have the format -@smallexample -file_name:@b{NNN}:Warning Message Text -@end smallexample -@noindent -(where @b{NNN} is a line number). If a logical file name has -been given (@pxref{App-File,,@code{.app-file}}) it is used for the filename, otherwise the -name of the current input file is used. If a logical line number was -given -_if__(!_AMD29K__) -(@pxref{Line,,@code{.line}}) -_fi__(!_AMD29K__) -_if__(_AMD29K__) -(@pxref{Ln,,@code{.ln}}) -_fi__(_AMD29K__) -then it is used to calculate the number printed, -otherwise the actual line in the current source file is printed. The -message text is intended to be self explanatory (in the grand Unix -tradition). @refill - -Error messages have the format -@smallexample -file_name:@b{NNN}:FATAL:Error Message Text -@end smallexample -The file name and line number are derived as for warning -messages. The actual message text may be rather less explanatory -because many of them aren't supposed to happen. - -@node Invoking, Syntax, Overview, Top -@chapter Command-Line Options -This section describes command-line options available in @emph{all} -versions of the GNU assembler; @pxref{_MACH_DEP__}, for options specific -_if__(!_GENERIC__) -to the _HOST__. -_fi__(!_GENERIC__) -_if__(_GENERIC__) -to particular machine architectures. -_fi__(_GENERIC__) - -@subsection @code{-D} -This option has no effect whatsoever, but it is accepted to make it more -likely that scripts written for other assemblers will also work with -@code{_AS__}. - -@subsection Work Faster: @code{-f} -@samp{-f} should only be used when assembling programs written by a -(trusted) compiler. @samp{-f} stops the assembler from pre-processing -the input file(s) before assembling them. -@quotation -@emph{Warning:} if the files actually need to be pre-processed (if they -contain comments, for example), @code{_AS__} will not work correctly if -@samp{-f} is used. -@end quotation - -@subsection @code{.include} search path: @code{-I} @var{path} -Use this option to add a @var{path} to the list of directories -@code{_AS__} will search for files specified in @code{.include} -directives (@pxref{Include,,@code{.include}}). You may use @code{-I} as -many times as necessary to include a variety of paths. The current -working directory is always searched first; after that, @code{_AS__} -searches any @samp{-I} directories in the same order as they were -specified (left to right) on the command line. - -@subsection Difference Tables: @code{-k} -_if__((!_GENERIC__) && (_AMD29K__ || _I960__)) -On the _HOST__ family, this option is allowed, but has no effect. It is -permitted for compatibility with the GNU assembler on other platforms, -where it can be used to warn when the assembler alters the machine code -generated for @samp{.word} directives in difference tables. The _HOST__ -family does not have the addressing limitations that sometimes lead to this -alteration on other platforms. -_fi__((!_GENERIC__) && (_AMD29K__ || _I960__)) - -_if__(_GENERIC__ || (! _AMD29K__ || _I960__ )) -@code{_AS__} sometimes alters the code emitted for directives of the form -@samp{.word @var{sym1}-@var{sym2}}; @pxref{Word,,@code{.word}}. -You can use the @samp{-k} option if you want a warning issued when this -is done. -_fi__(_GENERIC__ || (! _AMD29K__ || _I960__ )) - -@subsection Include Local Labels: @code{-L} -Labels beginning with @samp{L} (upper case only) are called @dfn{local -labels}. @xref{Symbol Names}. Normally you don't see such labels when -debugging, because they are intended for the use of programs (like -compilers) that compose assembler programs, not for your notice. -Normally both @code{_AS__} and @code{_LD__} discard such labels, so you don't -normally debug with them. - -This option tells @code{_AS__} to retain those @samp{L@dots{}} symbols -in the object file. Usually if you do this you also tell the linker -@code{_LD__} to preserve symbols whose names begin with @samp{L}. - -@subsection Name the Object File: @code{-o} -There is always one object file output when you run @code{_AS__}. By -default it has the name @file{a.out}. You use this option (which -takes exactly one filename) to give the object file a different name. - -Whatever the object file is called, @code{_AS__} will overwrite any -existing file of the same name. - -@subsection Join Data and Text Segments: @code{-R} -@code{-R} tells @code{_AS__} to write the object file as if all -data-segment data lives in the text segment. This is only done at -the very last moment: your binary data are the same, but data -segment parts are relocated differently. The data segment part of -your object file is zero bytes long because all it bytes are -appended to the text segment. (@xref{Segments,,Segments and Relocation}.) - -When you specify @code{-R} it would be possible to generate shorter -address displacements (because we don't have to cross between text and -data segment). We refrain from doing this simply for compatibility with -older versions of @code{_AS__}. In future, @code{-R} may work this way. - -@subsection Suppress Warnings: @code{-W} -@code{_AS__} should never give a warning or error message when -assembling compiler output. But programs written by people often -cause @code{_AS__} to give a warning that a particular assumption was -made. All such warnings are directed to the standard error file. -If you use this option, no warnings are issued. This option only -affects the warning messages: it does not change any particular of how -@code{_AS__} assembles your file. Errors, which stop the assembly, are -still reported. - -@node Syntax, Segments, Invoking, Top -@chapter Syntax -This chapter describes the machine-independent syntax allowed in a -source file. @code{_AS__} syntax is similar to what many other assemblers -use; it is inspired in BSD 4.2 -_if__(!_VAX__) -assembler. @refill -_fi__(!_VAX__) -_if__(_VAX__) -assembler, except that @code{_AS__} does not assemble Vax bit-fields. -_fi__(_VAX__) - -@menu -* Pre-processing:: Pre-processing -* Whitespace:: Whitespace -* Comments:: Comments -* Symbol Intro:: Symbols -* Statements:: Statements -* Constants:: Constants -@end menu - -@node Pre-processing, Whitespace, Syntax, Syntax -@section Pre-processing - -The pre-processor: -@itemize @bullet -@item -adjusts and removes extra whitespace. It leaves one space or tab before -the keywords on a line, and turns any other whitespace on the line into -a single space. - -@item -removes all comments, replacing them with a single space, or an -appropriate number of newlines. - -@item -converts character constants into the appropriate numeric values. -@end itemize - -Excess whitespace, comments, and character constants -cannot be used in the portions of the input text that are not -pre-processed. - -If the first line of an input file is @code{#NO_APP} or the @samp{-f} -option is given, the input file will not be pre-processed. Within such -an input file, parts of the file can be pre-processed by putting a line -that says @code{#APP} before the text that should be pre-processed, and -putting a line that says @code{#NO_APP} after them. This feature is -mainly intend to support @code{asm} statements in compilers whose output -normally does not need to be pre-processed. - -@node Whitespace, Comments, Pre-processing, Syntax -@section Whitespace -@dfn{Whitespace} is one or more blanks or tabs, in any order. -Whitespace is used to separate symbols, and to make programs neater for -people to read. Unless within character constants -(@pxref{Characters,,Character Constants}), any whitespace means the same -as exactly one space. - -@node Comments, Symbol Intro, Whitespace, Syntax -@section Comments -There are two ways of rendering comments to @code{_AS__}. In both -cases the comment is equivalent to one space. - -Anything from @samp{/*} through the next @samp{*/} is a comment. -This means you may not nest these comments. - -@smallexample -/* - The only way to include a newline ('\n') in a comment - is to use this sort of comment. -*/ - -/* This sort of comment does not nest. */ -@end smallexample - -Anything from the @dfn{line comment} character to the next newline -is considered a comment and is ignored. The line comment character is -_if__(_VAX__) -@samp{#} on the Vax; -_fi__(_VAX__) -_if__(_I960__) -@samp{#} on the i960; -_fi__(_I960__) -_if__(_M680X0__) -@samp{|} on the 680x0; -_fi__(_M680X0__) -_if__(_AMD29K__) -@samp{;} for the AMD 29K family; -_fi__(_AMD29K__) -@pxref{_MACH_DEP__}. @refill -@c FIXME: fill in SPARC line comment char - -_if__(_GENERIC__) -On some machines there are two different line comment characters. One -will only begin a comment if it is the first non-whitespace character on -a line, while the other will always begin a comment. -_fi__(_GENERIC__) - -To be compatible with past assemblers a special interpretation is -given to lines that begin with @samp{#}. Following the @samp{#} an -absolute expression (@pxref{Expressions}) is expected: this will be -the logical line number of the @b{next} line. Then a string -(@xref{Strings}.) is allowed: if present it is a new logical file -name. The rest of the line, if any, should be whitespace. - -If the first non-whitespace characters on the line are not numeric, -the line is ignored. (Just like a comment.) -@smallexample - # This is an ordinary comment. -# 42-6 "new_file_name" # New logical file name - # This is logical line # 36. -@end smallexample -This feature is deprecated, and may disappear from future versions -of @code{_AS__}. - -@node Symbol Intro, Statements, Comments, Syntax -@section Symbols -A @dfn{symbol} is one or more characters chosen from the set of all -letters (both upper and lower case), digits and the three characters -@samp{_.$}. No symbol may begin with a digit. Case is significant. -There is no length limit: all characters are significant. Symbols are -delimited by characters not in that set, or by the beginning of a file -(since the source program must end with a newline, the end of a file is -not a possible symbol delimiter). @xref{Symbols}. - -@node Statements, Constants, Symbol Intro, Syntax -@section Statements -_if__(!_AMD29K__) -A @dfn{statement} ends at a newline character (@samp{\n}) or at a -semicolon (@samp{;}). The newline or semicolon is considered part of -the preceding statement. Newlines and semicolons within character -constants are an exception: they don't end statements. -_fi__(!_AMD29K__) -_if__(_AMD29K__) -A @dfn{statement} ends at a newline character (@samp{\n}) or an ``at'' -sign (@samp{@@}). The newline or at sign is considered part of the -preceding statement. Newlines and at signs within character constants -are an exception: they don't end statements. -_fi__(_AMD29K__) - -It is an error to end any statement with end-of-file: the last -character of any input file should be a newline.@refill - -You may write a statement on more than one line if you put a -backslash (@kbd{\}) immediately in front of any newlines within the -statement. When @code{_AS__} reads a backslashed newline both -characters are ignored. You can even put backslashed newlines in -the middle of symbol names without changing the meaning of your -source program. - -An empty statement is allowed, and may include whitespace. It is ignored. - -@c "key symbol" is not used elsewhere in the document; seems pedantic to -@c @defn{} it in that case, as was done previously... pesch@cygnus.com, -@c 13feb91. -A statement begins with zero or more labels, optionally followed by a -key symbol which determines what kind of statement it is. The key -symbol determines the syntax of the rest of the statement. If the -symbol begins with a dot @samp{.} then the statement is an assembler -directive: typically valid for any computer. If the symbol begins with -a letter the statement is an assembly language @dfn{instruction}: it -will assemble into a machine language instruction. -_if__(_GENERIC__) -Different versions of @code{_AS__} for different computers will -recognize different instructions. In fact, the same symbol may -represent a different instruction in a different computer's assembly -language.@refill -_fi__(_GENERIC__) - -A label is a symbol immediately followed by a colon (@code{:}). -Whitespace before a label or after a colon is permitted, but you may not -have whitespace between a label's symbol and its colon. @xref{Labels}. - -@smallexample -label: .directive followed by something -another$label: # This is an empty statement. - instruction operand_1, operand_2, @dots{} -@end smallexample - -@node Constants, , Statements, Syntax -@section Constants -A constant is a number, written so that its value is known by -inspection, without knowing any context. Like this: -@smallexample -.byte 74, 0112, 092, 0x4A, 0X4a, 'J, '\J # All the same value. -.ascii "Ring the bell\7" # A string constant. -.octa 0x123456789abcdef0123456789ABCDEF0 # A bignum. -.float 0f-314159265358979323846264338327\ -95028841971.693993751E-40 # - pi, a flonum. -@end smallexample - -@menu -* Characters:: Character Constants -* Numbers:: Number Constants -@end menu - -@node Characters, Numbers, Constants, Constants -@subsection Character Constants -There are two kinds of character constants. A @dfn{character} stands -for one character in one byte and its value may be used in -numeric expressions. String constants (properly called string -@emph{literals}) are potentially many bytes and their values may not be -used in arithmetic expressions. - -@menu -* Strings:: Strings -* Chars:: Characters -@end menu - -@node Strings, Chars, Characters, Characters -@subsubsection Strings -A @dfn{string} is written between double-quotes. It may contain -double-quotes or null characters. The way to get special characters -into a string is to @dfn{escape} these characters: precede them with -a backslash @samp{\} character. For example @samp{\\} represents -one backslash: the first @code{\} is an escape which tells -@code{_AS__} to interpret the second character literally as a backslash -(which prevents @code{_AS__} from recognizing the second @code{\} as an -escape character). The complete list of escapes follows. - -@table @kbd -@c @item \a -@c Mnemonic for ACKnowledge; for ASCII this is octal code 007. -@item \b -Mnemonic for backspace; for ASCII this is octal code 010. -@c @item \e -@c Mnemonic for EOText; for ASCII this is octal code 004. -@item \f -Mnemonic for FormFeed; for ASCII this is octal code 014. -@item \n -Mnemonic for newline; for ASCII this is octal code 012. -@c @item \p -@c Mnemonic for prefix; for ASCII this is octal code 033, usually known as @code{escape}. -@item \r -Mnemonic for carriage-Return; for ASCII this is octal code 015. -@c @item \s -@c Mnemonic for space; for ASCII this is octal code 040. Included for compliance with -@c other assemblers. -@item \t -Mnemonic for horizontal Tab; for ASCII this is octal code 011. -@c @item \v -@c Mnemonic for Vertical tab; for ASCII this is octal code 013. -@c @item \x @var{digit} @var{digit} @var{digit} -@c A hexadecimal character code. The numeric code is 3 hexadecimal digits. -@item \ @var{digit} @var{digit} @var{digit} -An octal character code. The numeric code is 3 octal digits. -For compatibility with other Unix systems, 8 and 9 are accepted as digits: -for example, @code{\008} has the value 010, and @code{\009} the value 011. -@item \\ -Represents one @samp{\} character. -@c @item \' -@c Represents one @samp{'} (accent acute) character. -@c This is needed in single character literals -@c (@xref{Characters,,Character Constants}.) to represent -@c a @samp{'}. -@item \" -Represents one @samp{"} character. Needed in strings to represent -this character, because an unescaped @samp{"} would end the string. -@item \ @var{anything-else} -Any other character when escaped by @kbd{\} will give a warning, but -assemble as if the @samp{\} was not present. The idea is that if -you used an escape sequence you clearly didn't want the literal -interpretation of the following character. However @code{_AS__} has no -other interpretation, so @code{_AS__} knows it is giving you the wrong -code and warns you of the fact. -@end table - -Which characters are escapable, and what those escapes represent, -varies widely among assemblers. The current set is what we think -the BSD 4.2 assembler recognizes, and is a subset of what most C -compilers recognize. If you are in doubt, don't use an escape -sequence. - -@node Chars, , Strings, Characters -@subsubsection Characters -A single character may be written as a single quote immediately -followed by that character. The same escapes apply to characters as -to strings. So if you want to write the character backslash, you -must write @kbd{'\\} where the first @code{\} escapes the second -@code{\}. As you can see, the quote is an acute accent, not a -grave accent. A newline -_if__(!_AMD29K__) -(or semicolon @samp{;}) -_fi__(!_AMD29K__) -_if__(_AMD29K__) -(or at sign @samp{@@}) -_fi__(_AMD29K__) -immediately following an acute accent is taken as a literal character -and does not count as the end of a statement. The value of a character -constant in a numeric expression is the machine's byte-wide code for -that character. @code{_AS__} assumes your character code is ASCII: -@kbd{'A} means 65, @kbd{'B} means 66, and so on. @refill - -@node Numbers, , Characters, Constants -@subsection Number Constants -@code{_AS__} distinguishes three kinds of numbers according to how they -are stored in the target machine. @emph{Integers} are numbers that -would fit into an @code{int} in the C language. @emph{Bignums} are -integers, but they are stored in more than 32 bits. @emph{Flonums} -are floating point numbers, described below. - -@menu -* Integers:: Integers -* Bignums:: Bignums -* Flonums:: Flonums -_if__(_I960__&&!_GENERIC__) -* Bit Fields:: Bit Fields -_fi__(_I960__&&!_GENERIC__) -@end menu - -@node Integers, Bignums, Numbers, Numbers -@subsubsection Integers -@c FIXME: are binary integers in vintage as? -A binary integer is @samp{0b} or @samp{0B} followed by zero or more of -the binary digits @samp{01}. - -An octal integer is @samp{0} followed by zero or more of the octal -digits (@samp{01234567}). - -A decimal integer starts with a non-zero digit followed by zero or -more digits (@samp{0123456789}). - -A hexadecimal integer is @samp{0x} or @samp{0X} followed by one or -more hexadecimal digits chosen from @samp{0123456789abcdefABCDEF}. - -Integers have the usual values. To denote a negative integer, use -the prefix operator @samp{-} discussed under expressions -(@pxref{Prefix Ops,,Prefix Operators}). - -@node Bignums, Flonums, Integers, Numbers -@subsubsection Bignums -A @dfn{bignum} has the same syntax and semantics as an integer -except that the number (or its negative) takes more than 32 bits to -represent in binary. The distinction is made because in some places -integers are permitted while bignums are not. - -_if__(_I960__&&!_GENERIC__) -@node Flonums, Bit Fields, Bignums, Numbers -_fi__(_I960__&&!_GENERIC__) -_if__(_GENERIC__||!_I960__) -@node Flonums, , Bignums, Numbers -_fi__(_GENERIC__||!_I960__) -@subsubsection Flonums -A @dfn{flonum} represents a floating point number. The translation is -complex: a decimal floating point number from the text is converted by -@code{_AS__} to a generic binary floating point number of more than -sufficient precision. This generic floating point number is converted -to a particular computer's floating point format (or formats) by a -portion of @code{_AS__} specialized to that computer. - -A flonum is written by writing (in order) -@itemize @bullet -@item -The digit @samp{0}. -@item -_if__(_GENERIC__) -A letter, to tell @code{_AS__} the rest of the number is a flonum. @kbd{e} -is recommended. Case is not important. -@ignore -@c FIXME: verify if flonum syntax really this vague for most cases - (Any otherwise illegal letter -will work here, but that might be changed. Vax BSD 4.2 assembler seems -to allow any of @samp{defghDEFGH}.) -@end ignore -_fi__(_GENERIC__) -_if__(_AMD29K__) -_if__(_GENERIC__) -On the AMD 29K architecture, the letter must be: -_fi__(_GENERIC__) -One of the letters @samp{DFPRSX} (in upper or lower case), to tell -@code{_AS__} the rest of the number is a flonum. -_fi__(_AMD29K__) -_if__(_I960__) -_if__(_GENERIC__) -On the Intel 960 architecture, the letter must be: -_fi__(_GENERIC__) -One of the letters @samp{DFT} (in upper or lower case), to tell -@code{_AS__} the rest of the number is a flonum. -_fi__(_I960__) -@item -An optional sign: either @samp{+} or @samp{-}. -@item -An optional @dfn{integer part}: zero or more decimal digits. -@item -An optional @dfn{fraction part}: @samp{.} followed by zero -or more decimal digits. -@item -An optional exponent, consisting of: -@itemize @bullet -@item -An @samp{E} or @samp{e}. -@c I can't find a config where "EXP_CHARS" is other than 'eE', but in -@c principle this can perfectly well be different on different targets. -@item -Optional sign: either @samp{+} or @samp{-}. -@item -One or more decimal digits. -@end itemize -@end itemize - -At least one of @var{integer part} or @var{fraction part} must be -present. The floating point number has the usual base-10 value. - -@code{_AS__} does all processing using integers. Flonums are computed -independently of any floating point hardware in the computer running -@code{_AS__}. - -_if__(_I960__&&!_GENERIC__) -@c Bit fields are written as a general facility but are also controlled -@c by a conditional-compilation flag---which is as of now (21mar91) -@c turned on only by the i960 config of GAS. -@node Bit Fields, , Flonums, Numbers -@subsubsection Bit Fields -You can also define numeric constants as @dfn{bit fields}. -specify two numbers separated by a colon--- -@example -@var{mask}:@var{value} -@end example -@noindent -the first will act as a mask; @code{_AS__} will bitwise-and it with the -second value. - -The resulting number is then packed -_if__(_GENERIC__) -@c this conditional paren in case bit fields turned on elsewhere than 960 -(in host-dependent byte order) -_fi__(_GENERIC__) -into a field whose width depends on which assembler directive has the -bit-field as its argument. Overflow (a result from the bitwise and -requiring more binary digits to represent) is not an error; instead, -more constants are generated, of the specified width, beginning with the -least significant digits.@refill - -The directives @code{.byte}, @code{.hword}, @code{.int}, @code{.long}, -@code{.short}, and @code{.word} accept bit-field arguments. -_fi__(_I960__&&!_GENERIC__) - -@node Segments, Symbols, Syntax, Top -@chapter Segments and Relocation - -@menu -* Segs Background:: Background -* _LD__ Segments:: _LD__ Segments -* _AS__ Segments:: _AS__ Internal Segments -* Sub-Segments:: Sub-Segments -* bss:: bss Segment -@end menu - -@node Segs Background, _LD__ Segments, Segments, Segments -@section Background -Roughly, a segment is a range of addresses, with no gaps; all data -``in'' those addresses is treated the same for some particular purpose. -For example there may be a ``read only'' segment. - -The linker @code{_LD__} reads many object files (partial programs) and -combines their contents to form a runnable program. When @code{_AS__} -emits an object file, the partial program is assumed to start at address -0. @code{_LD__} will assign the final addresses the partial program -occupies, so that different partial programs don't overlap. This is -actually an over-simplification, but it will suffice to explain how -@code{_AS__} uses segments. - -@code{_LD__} moves blocks of bytes of your program to their run-time -addresses. These blocks slide to their run-time addresses as rigid -units; their length does not change and neither does the order of bytes -within them. Such a rigid unit is called a @emph{segment}. Assigning -run-time addresses to segments is called @dfn{relocation}. It includes -the task of adjusting mentions of object-file addresses so they refer to -the proper run-time addresses. - -An object file written by @code{_AS__} has three segments, any of which may -be empty. These are named @dfn{text}, @dfn{data} and @dfn{bss} -segments. -_if__(_COFF__) - -@c Thanks, Rich! -@quotation -@emph{Warning:} @code{_AS__} can only assign output to one of these -three segments, even when configured for COFF output; the -@code{.section} directive is not supported. -@end quotation -_fi__(_COFF__) - -Within the object file, the text segment starts at address @code{0}, the -data segment follows, and the bss segment follows the data segment. - -To let @code{_LD__} know which data will change when the segments are -relocated, and how to change that data, @code{_AS__} also writes to the -object file details of the relocation needed. To perform relocation -@code{_LD__} must know, each time an address in the object -file is mentioned: -@itemize @bullet -@item -Where in the object file is the beginning of this reference to -an address? -@item -How long (in bytes) is this reference? -@item -Which segment does the address refer to? What is the numeric value of -@display -(@var{address}) @minus{} (@var{start-address of segment})? -@end display -@item -Is the reference to an address ``Program-Counter relative''? -@end itemize - -In fact, every address @code{_AS__} ever uses is expressed as -@display -(@var{segment}) + (@var{offset into segment}) -@end display -@noindent -Further, every expression @code{_AS__} computes is of this segmented -nature. @dfn{Absolute expression} means an expression with segment -``absolute'' (@pxref{_LD__ Segments}). A @dfn{pass1 expression} means -an expression with segment ``pass1'' (@pxref{_AS__ Segments,,_AS__ -Internal Segments}). In this manual we use the notation @{@var{segname} -@var{N}@} to mean ``offset @var{N} into segment @var{segname}''. - -Apart from text, data and bss segments you need to know about the -@dfn{absolute} segment. When @code{_LD__} mixes partial programs, -addresses in the absolute segment remain unchanged. That is, address -@code{@{absolute 0@}} is ``relocated'' to run-time address 0 by @code{_LD__}. -Although two partial programs' data segments will not overlap addresses -after linking, @emph{by definition} their absolute segments will overlap. -Address @code{@{absolute@ 239@}} in one partial program will always be the same -address when the program is running as address @code{@{absolute@ 239@}} in any -other partial program. - -The idea of segments is extended to the @dfn{undefined} segment. Any -address whose segment is unknown at assembly time is by definition -rendered @{undefined @var{U}@}---where @var{U} will be filled in later. -Since numbers are always defined, the only way to generate an undefined -address is to mention an undefined symbol. A reference to a named -common block would be such a symbol: its value is unknown at assembly -time so it has segment @emph{undefined}. - -By analogy the word @emph{segment} is used to describe groups of segments in -the linked program. @code{_LD__} puts all partial programs' text -segments in contiguous addresses in the linked program. It is -customary to refer to the @emph{text segment} of a program, meaning all -the addresses of all partial program's text segments. Likewise for -data and bss segments. - -Some segments are manipulated by @code{_LD__}; others are invented for -use of @code{_AS__} and have no meaning except during assembly. - -@node _LD__ Segments, _AS__ Segments, Segs Background, Segments -@section _LD__ Segments -@code{_LD__} deals with just five kinds of segments, summarized below. - -@table @strong - -@item text segment -@itemx data segment -These segments hold your program. @code{_AS__} and @code{_LD__} treat them as -separate but equal segments. Anything you can say of one segment is -true of the other. When the program is running, however, it is -customary for the text segment to be unalterable. The -text segment is often shared among processes: it will contain -instructions, constants and the like. The data segment of a running -program is usually alterable: for example, C variables would be stored -in the data segment. - -@item bss segment -This segment contains zeroed bytes when your program begins running. It -is used to hold unitialized variables or common storage. The length of -each partial program's bss segment is important, but because it starts -out containing zeroed bytes there is no need to store explicit zero -bytes in the object file. The bss segment was invented to eliminate -those explicit zeros from object files. - -@item absolute segment -Address 0 of this segment is always ``relocated'' to runtime address 0. -This is useful if you want to refer to an address that @code{_LD__} must -not change when relocating. In this sense we speak of absolute -addresses being ``unrelocatable'': they don't change during relocation. - -@item undefined segment -This ``segment'' is a catch-all for address references to objects not in -the preceding segments. -@c FIXME: ref to some other doc on obj-file formats could go here. - -@end table - -An idealized example of the three relocatable segments follows. Memory -addresses are on the horizontal axis. - -@ifinfo -@smallexample - +-----+----+--+ -partial program # 1: |ttttt|dddd|00| - +-----+----+--+ - - text data bss - seg. seg. seg. - - +---+---+---+ -partial program # 2: |TTT|DDD|000| - +---+---+---+ - - +--+---+-----+--+----+---+-----+~~ -linked program: | |TTT|ttttt| |dddd|DDD|00000| - +--+---+-----+--+----+---+-----+~~ - - addresses: 0 @dots{} -@end smallexample -@end ifinfo -@tex - -{\it Partial program \#1: } - -\line{\ibox{2.5cm}{\tt text}\ibox{2cm}{\tt data}\ibox{1cm}{\tt bss}\hfil} -\line{\boxit{2.5cm}{\tt ttttt}\boxit{2cm}{\tt dddd}\boxit{1cm}{\tt 00}\hfil} - -{\it Partial program \#2:} - -\line{\ibox{1cm}{\tt text}\ibox{1.5cm}{\tt data}\ibox{1cm}{\tt bss}\hfil} -\line{\boxit{1cm}{\tt TTT}\boxit{1.5cm}{\tt DDDD}\boxit{1cm}{\tt 000}\hfil} - -{\it linked program: } - -\line{\ibox{.5cm}{}\ibox{1cm}{\tt text}\ibox{2.5cm}{}\ibox{.75cm}{}\ibox{2cm}{\tt data}\ibox{1.5cm}{}\ibox{2cm}{\tt bss}\hfil} -\line{\boxit{.5cm}{}\boxit{1cm}{\tt TTT}\boxit{2.5cm}{\tt -ttttt}\boxit{.75cm}{}\boxit{2cm}{\tt dddd}\boxit{1.5cm}{\tt -DDDD}\boxit{2cm}{\tt 00000}\ \dots\hfil} - -{\it addresses:} - -\line{0\dots\hfil} - -@end tex - -@node _AS__ Segments, Sub-Segments, _LD__ Segments, Segments -@section _AS__ Internal Segments -These segments are invented for the internal use of @code{_AS__}. They -have no meaning at run-time. You don't need to know about these -segments except that they might be mentioned in the @code{_AS__} warning -messages. These segments are invented to permit the value of every -expression in your assembly language program to be a segmented -address. - -@table @b -@item absent segment -An expression was expected and none was -found. - -@item goof segment -An internal assembler logic error has been -found. This means there is a bug in the assembler. - -@item grand segment -A @dfn{grand number} is a bignum or a flonum, but not an integer. If a -number can't be written as a C @code{int} constant, it is a grand -number. @code{_AS__} has to remember that a flonum or a bignum does not -fit into 32 bits, and cannot be an argument (@pxref{Arguments}) in an -expression: this is done by making a flonum or bignum be in segment -grand. This is purely for internal @code{_AS__} convenience; grand -segment behaves similarly to absolute segment. - -@item pass1 segment -The expression was impossible to evaluate in the first pass. The -assembler will attempt a second pass (second reading of the source) to -evaluate the expression. Your expression mentioned an undefined symbol -in a way that defies the one-pass (segment + offset in segment) assembly -process. No compiler need emit such an expression. - -@quotation -@emph{Warning:} the second pass is currently not implemented. @code{_AS__} -will abort with an error message if one is required. -@end quotation - -@item difference segment -As an assist to the C compiler, expressions of the forms -@display - (@var{undefined symbol}) @minus{} (@var{expression}) - @var{something} @minus{} (@var{undefined symbol}) - (@var{undefined symbol}) @minus{} (@var{undefined symbol}) -@end display -are permitted, and belong to the difference segment. @code{_AS__} -re-evaluates such expressions after the source file has been read and -the symbol table built. If by that time there are no undefined symbols -in the expression then the expression assumes a new segment. The -intention is to permit statements like -@samp{.word label - base_of_table} -to be assembled in one pass where both @code{label} and -@code{base_of_table} are undefined. This is useful for compiling C and -Algol switch statements, Pascal case statements, FORTRAN computed goto -statements and the like. -@end table - -@node Sub-Segments, bss, _AS__ Segments, Segments -@section Sub-Segments -Assembled bytes fall into two segments: text and data. -Because you may have groups of text or data that you want to end up near -to each other in the object file, @code{_AS__} allows you to use -@dfn{subsegments}. Within each segment, there can be numbered -subsegments with values from 0 to 8192. Objects assembled into the same -subsegment will be grouped with other objects in the same subsegment -when they are all put into the object file. For example, a compiler -might want to store constants in the text segment, but might not want to -have them interspersed with the program being assembled. In this case, -the compiler could issue a @code{text 0} before each section of code -being output, and a @code{text 1} before each group of constants being -output. - -Subsegments are optional. If you don't use subsegments, everything -will be stored in subsegment number zero. - -_if__(_GENERIC__) -Each subsegment is zero-padded up to a multiple of four bytes. -(Subsegments may be padded a different amount on different flavors -of @code{_AS__}.) -_fi__(_GENERIC__) -_if__(_I960__) -@c Rich Pixley says padding here depends on target obj code format; that -@c doesn't seem particularly useful to say without further elaboration, -@c so for now I say nothing about it. If this is a generic BFD issue, -@c these paragraphs might need to vanish from this manual, and be -@c discussed in BFD chapter of binutils (or some such). -_fi__(_I960__) -_if__(_AMD29K__) -On the AMD 29K family, no particular padding is added to segment sizes; -_AS__ forces no alignment on this platform. -_fi__(_AMD29K__) -Subsegments appear in your object file in numeric order, lowest numbered -to highest. (All this to be compatible with other people's assemblers.) -The object file contains no representation of subsegments; @code{_LD__} and -other programs that manipulate object files will see no trace of them. -They just see all your text subsegments as a text segment, and all your -data subsegments as a data segment. - -To specify which subsegment you want subsequent statements assembled -into, use a @samp{.text @var{expression}} or a @samp{.data -@var{expression}} statement. @var{Expression} should be an absolute -expression. (@xref{Expressions}.) If you just say @samp{.text} -then @samp{.text 0} is assumed. Likewise @samp{.data} means -@samp{.data 0}. Assembly begins in @code{text 0}. -For instance: -@smallexample -.text 0 # The default subsegment is text 0 anyway. -.ascii "This lives in the first text subsegment. *" -.text 1 -.ascii "But this lives in the second text subsegment." -.data 0 -.ascii "This lives in the data segment," -.ascii "in the first data subsegment." -.text 0 -.ascii "This lives in the first text segment," -.ascii "immediately following the asterisk (*)." -@end smallexample - -Each segment has a @dfn{location counter} incremented by one for every -byte assembled into that segment. Because subsegments are merely a -convenience restricted to @code{_AS__} there is no concept of a subsegment -location counter. There is no way to directly manipulate a location -counter---but the @code{.align} directive will change it, and any label -definition will capture its current value. The location counter of the -segment that statements are being assembled into is said to be the -@dfn{active} location counter. - -@node bss, , Sub-Segments, Segments -@section bss Segment -The bss segment is used for local common variable storage. -You may allocate address space in the bss segment, but you may -not dictate data to load into it before your program executes. When -your program starts running, all the contents of the bss -segment are zeroed bytes. - -Addresses in the bss segment are allocated with special directives; you -may not assemble anything directly into the bss segment. Hence there -are no bss subsegments. @xref{Comm,,@code{.comm}}, -@pxref{Lcomm,,@code{.lcomm}}. - -@node Symbols, Expressions, Segments, Top -@chapter Symbols -Symbols are a central concept: the programmer uses symbols to name -things, the linker uses symbols to link, and the debugger uses symbols -to debug. - -@quotation -@emph{Warning:} @code{_AS__} does not place symbols in the object file in -the same order they were declared. This may break some debuggers. -@end quotation - -@menu -* Labels:: Labels -* Setting Symbols:: Giving Symbols Other Values -* Symbol Names:: Symbol Names -* Dot:: The Special Dot Symbol -* Symbol Attributes:: Symbol Attributes -@end menu - -@node Labels, Setting Symbols, Symbols, Symbols -@section Labels -A @dfn{label} is written as a symbol immediately followed by a colon -@samp{:}. The symbol then represents the current value of the -active location counter, and is, for example, a suitable instruction -operand. You are warned if you use the same symbol to represent two -different locations: the first definition overrides any other -definitions. - -@node Setting Symbols, Symbol Names, Labels, Symbols -@section Giving Symbols Other Values -A symbol can be given an arbitrary value by writing a symbol, followed -by an equals sign @samp{=}, followed by an expression -(@pxref{Expressions}). This is equivalent to using the @code{.set} -directive. @xref{Set,,@code{.set}}. - -@node Symbol Names, Dot, Setting Symbols, Symbols -@section Symbol Names -Symbol names begin with a letter or with one of @samp{$._}. That -character may be followed by any string of digits, letters, -underscores and dollar signs. Case of letters is significant: -@code{foo} is a different symbol name than @code{Foo}. - -_if__(_AMD29K__) -For the AMD 29K family, @samp{?} is also allowed in the -body of a symbol name, though not at its beginning. -_fi__(_AMD29K__) - -Each symbol has exactly one name. Each name in an assembly language -program refers to exactly one symbol. You may use that symbol name any -number of times in a program. - -@subheading Local Symbol Names - -Local symbols help compilers and programmers use names temporarily. -There are ten local symbol names, which are re-used throughout the -program. You may refer to them using the names @samp{0} @samp{1} -@dots{} @samp{9}. To define a local symbol, write a label of the form -@samp{@b{N}:} (where @b{N} represents any digit). To refer to the most -recent previous definition of that symbol write @samp{@b{N}b}, using the -same digit as when you defined the label. To refer to the next -definition of a local label, write @samp{@b{N}f}---where @b{N} gives you -a choice of 10 forward references. The @samp{b} stands for -``backwards'' and the @samp{f} stands for ``forwards''. - -Local symbols are not emitted by the current GNU C compiler. - -There is no restriction on how you can use these labels, but -remember that at any point in the assembly you can refer to at most -10 prior local labels and to at most 10 forward local labels. - -Local symbol names are only a notation device. They are immediately -transformed into more conventional symbol names before the assembler -uses them. The symbol names stored in the symbol table, appearing in -error messages and optionally emitted to the object file have these -parts: - -@table @code -@item L -All local labels begin with @samp{L}. Normally both @code{_AS__} and -@code{_LD__} forget symbols that start with @samp{L}. These labels are -used for symbols you are never intended to see. If you give the -@samp{-L} option then @code{_AS__} will retain these symbols in the -object file. If you also instruct @code{_LD__} to retain these symbols, -you may use them in debugging. - -@item @var{digit} -If the label is written @samp{0:} then the digit is @samp{0}. -If the label is written @samp{1:} then the digit is @samp{1}. -And so on up through @samp{9:}. - -@item @ctrl{A} -This unusual character is included so you don't accidentally invent -a symbol of the same name. The character has ASCII value -@samp{\001}. - -@item @emph{ordinal number} -This is a serial number to keep the labels distinct. The first -@samp{0:} gets the number @samp{1}; The 15th @samp{0:} gets the -number @samp{15}; @emph{etc.}. Likewise for the other labels @samp{1:} -through @samp{9:}. -@end table - -For instance, the first @code{1:} is named @code{L1@ctrl{A}1}, the 44th -@code{3:} is named @code{L3@ctrl{A}44}. - -@node Dot, Symbol Attributes, Symbol Names, Symbols -@section The Special Dot Symbol - -The special symbol @samp{.} refers to the current address that -@code{_AS__} is assembling into. Thus, the expression @samp{melvin: -.long .} will cause @code{melvin} to contain its own address. -Assigning a value to @code{.} is treated the same as a @code{.org} -directive. Thus, the expression @samp{.=.+4} is the same as saying -_if__(!_AMD29K__) -@samp{.space 4}. -_fi__(!_AMD29K__) -_if__(_AMD29K__) -@samp{.block 4}. -_fi__(_AMD29K__) - -@node Symbol Attributes, , Dot, Symbols -@section Symbol Attributes -Every symbol has, as well as its name, the attributes ``Value'' and -``Type''. Depending on output format, symbols also have auxiliary attributes. -_if__(_INTERNALS__) -The detailed definitions are in _0___1__. -_fi__(_INTERNALS__) - -If you use a symbol without defining it, @code{_AS__} assumes zero for -all these attributes, and probably won't warn you. This makes the -symbol an externally defined symbol, which is generally what you -would want. - -@menu -* Symbol Value:: Value -* Symbol Type:: Type -_if__(_GENERIC__||!_BOUT__) -* a.out Symbols:: Symbol Attributes: @code{a.out} -_fi__(_GENERIC__||!_BOUT__) -_if__(_BOUT__&&!_GENERIC__) -* a.out Symbols:: Symbol Attributes: @code{a.out}, @code{b.out} -_fi__(_BOUT__&&!_GENERIC__) -_if__(_COFF__) -* COFF Symbols:: Symbol Attributes for COFF -_fi__(_COFF__) -@end menu - -@node Symbol Value, Symbol Type, Symbol Attributes, Symbol Attributes -@subsection Value -The value of a symbol is (usually) 32 bits, the size of one GNU C -@code{int}. For a symbol which labels a location in the text, data, bss -or absolute segments the value is the number of addresses from the start -of that segment to the label. Naturally for text, data and bss segments -the value of a symbol changes as @code{_LD__} changes segment base -addresses during linking. Absolute symbols' values do not change during -linking: that is why they are called absolute. - -The value of an undefined symbol is treated in a special way. If it is -0 then the symbol is not defined in this assembler source program, and -@code{_LD__} will try to determine its value from other programs it is -linked with. You make this kind of symbol simply by mentioning a symbol -name without defining it. A non-zero value represents a @code{.comm} -common declaration. The value is how much common storage to reserve, in -bytes (addresses). The symbol refers to the first address of the -allocated storage. - -@node Symbol Type, a.out Symbols, Symbol Value, Symbol Attributes -@subsection Type -The type attribute of a symbol contains relocation (segment) -information, any flag settings indicating that a symbol is external, and -(optionally), other information for linkers and debuggers. The exact -format depends on the object-code output format in use. - -_if__(_AOUT__||_BOUT__) -@menu -* Symbol Desc:: Descriptor -* Symbol Other:: Other -@end menu - -_if__(_COFF__) -@node a.out Symbols, COFF Symbols, Symbol Type, Symbol Attributes -_fi__(_COFF__) -_if__(!_COFF__) -@node a.out Symbols, , Symbol Type, Symbol Attributes -_fi__(!_COFF__) -_if__(_BOUT__&&!_GENERIC__) -@subsection Symbol Attributes: @code{a.out}, @code{b.out} -These symbol attributes appear only when @code{_AS__} is configured for -one of the Berkeley-descended object output formats. -_fi__(_BOUT__&&!_GENERIC__) -_if__(_GENERIC__||!_BOUT__) -@subsection Symbol Attributes: @code{a.out} -_fi__(_GENERIC__||!_BOUT__) - -@menu -* Symbol Desc:: Descriptor -* Symbol Other:: Other -@end menu - -@node Symbol Desc, Symbol Other, a.out Symbols, a.out Symbols -@subsubsection Descriptor -This is an arbitrary 16-bit value. You may establish a symbol's -descriptor value by using a @code{.desc} statement -(@pxref{Desc,,@code{.desc}}). A descriptor value means nothing to -@code{_AS__}. - -@node Symbol Other, , Symbol Desc, a.out Symbols -@subsubsection Other -This is an arbitrary 8-bit value. It means nothing to @code{_AS__}. -_fi__(_AOUT__||_BOUT__) - -_if__(_COFF__) -@node COFF Symbols, , a.out Symbols, Symbol Attributes -@subsection Symbol Attributes for COFF -The COFF format supports a multitude of auxiliary symbol attributes; -like the primary symbol attributes, they are set between @code{.def} and -@code{.endef} directives. - -@subsubsection Primary Attributes -The symbol name is set with @code{.def}; the value and type, -respectively, with @code{.val} and @code{.type}. - -@subsubsection Auxiliary Attributes -The @code{_AS__} directives @code{.dim}, @code{.line}, @code{.scl}, -@code{.size}, and @code{.tag} can generate auxiliary symbol table -information for COFF. -_fi__(_COFF__) - -@node Expressions, Pseudo Ops, Symbols, Top -@chapter Expressions -An @dfn{expression} specifies an address or numeric value. -Whitespace may precede and/or follow an expression. - -@menu -* Empty Exprs:: Empty Expressions -* Integer Exprs:: Integer Expressions -@end menu - -@node Empty Exprs, Integer Exprs, Expressions, Expressions -@section Empty Expressions -An empty expression has no value: it is just whitespace or null. -Wherever an absolute expression is required, you may omit the -expression and @code{_AS__} will assume a value of (absolute) 0. This -is compatible with other assemblers. - -@node Integer Exprs, , Empty Exprs, Expressions -@section Integer Expressions -An @dfn{integer expression} is one or more @emph{arguments} delimited -by @emph{operators}. - -@menu -* Arguments:: Arguments -* Operators:: Operators -* Prefix Ops:: Prefix Operators -* Infix Ops:: Infix Operators -@end menu - -@node Arguments, Operators, Integer Exprs, Integer Exprs -@subsection Arguments - -@dfn{Arguments} are symbols, numbers or subexpressions. In other -contexts arguments are sometimes called ``arithmetic operands''. In -this manual, to avoid confusing them with the ``instruction operands'' of -the machine language, we use the term ``argument'' to refer to parts of -expressions only, reserving the word ``operand'' to refer only to machine -instruction operands. - -Symbols are evaluated to yield @{@var{segment} @var{NNN}@} where -@var{segment} is one of text, data, bss, absolute, -or undefined. @var{NNN} is a signed, 2's complement 32 bit -integer. - -Numbers are usually integers. - -A number can be a flonum or bignum. In this case, you are warned -that only the low order 32 bits are used, and @code{_AS__} pretends -these 32 bits are an integer. You may write integer-manipulating -instructions that act on exotic constants, compatible with other -assemblers. - -Subexpressions are a left parenthesis @samp{(} followed by an integer -expression, followed by a right parenthesis @samp{)}; or a prefix -operator followed by an argument. - -@node Operators, Prefix Ops, Arguments, Integer Exprs -@subsection Operators -@dfn{Operators} are arithmetic functions, like @code{+} or @code{%}. Prefix -operators are followed by an argument. Infix operators appear -between their arguments. Operators may be preceded and/or followed by -whitespace. - -@node Prefix Ops, Infix Ops, Operators, Integer Exprs -@subsection Prefix Operators -@code{_AS__} has the following @dfn{prefix operators}. They each take -one argument, which must be absolute. - -@c the tex/end tex stuff surrounding this small table is meant to make -@c it align, on the printed page, with the similar table in the next -@c section (which is inside an enumerate). -@tex -\global\advance\leftskip by \itemindent -@end tex - -@table @code -@item - -@dfn{Negation}. Two's complement negation. -@item ~ -@dfn{Complementation}. Bitwise not. -@end table - -@tex -\global\advance\leftskip by -\itemindent -@end tex - -@node Infix Ops, , Prefix Ops, Integer Exprs -@subsection Infix Operators - -@dfn{Infix operators} take two arguments, one on either side. Operators -have precedence, but operations with equal precedence are performed left -to right. Apart from @code{+} or @code{-}, both arguments must be -absolute, and the result is absolute. - -@enumerate - -@item -Highest Precedence -@table @code -@item * -@dfn{Multiplication}. -@item / -@dfn{Division}. Truncation is the same as the C operator @samp{/} -@item % -@dfn{Remainder}. -@item _0__<_1__ -@itemx _0__<<_1__ -@dfn{Shift Left}. Same as the C operator @samp{_0__<<_1__} -@item _0__>_1__ -@itemx _0__>>_1__ -@dfn{Shift Right}. Same as the C operator @samp{_0__>>_1__} -@end table - -@item -Intermediate precedence -@table @code -@item | -@dfn{Bitwise Inclusive Or}. -@item & -@dfn{Bitwise And}. -@item ^ -@dfn{Bitwise Exclusive Or}. -@item ! -@dfn{Bitwise Or Not}. -@end table - -@item -Lowest Precedence -@table @code -@item + -@dfn{Addition}. If either argument is absolute, the result -has the segment of the other argument. -If either argument is pass1 or undefined, the result is pass1. -Otherwise @code{+} is illegal. -@item - -@dfn{Subtraction}. If the right argument is absolute, the -result has the segment of the left argument. -If either argument is pass1 the result is pass1. -If either argument is undefined the result is difference segment. -If both arguments are in the same segment, the result is absolute---provided -that segment is one of text, data or bss. -Otherwise subtraction is illegal. -@end table -@end enumerate - -The sense of the rule for addition is that it's only meaningful to add -the @emph{offsets} in an address; you can only have a defined segment in -one of the two arguments. - -Similarly, you can't subtract quantities from two different segments. - -@node Pseudo Ops, _MACH_DEP__, Expressions, Top -@chapter Assembler Directives - -All assembler directives have names that begin with a period (@samp{.}). -The rest of the name is letters: their case does not matter. - -This chapter discusses directives present regardless of the target -machine configuration for the GNU assembler; @pxref{_MACH_DEP__} for -additional directives. - -@menu -* Abort:: @code{.abort} -_if__(_COFF__) -* coff-ABORT:: @code{.ABORT} -_fi__(_COFF__) -_if__(_BOUT__&&!_COFF__) -* bout-ABORT:: @code{.ABORT} -_fi__(_BOUT__&&!_COFF__) -* Align:: @code{.align @var{abs-expr} , @var{abs-expr}} -* App-File:: @code{.app-file @var{string}} -* Ascii:: @code{.ascii "@var{string}"}@dots{} -* Asciz:: @code{.asciz "@var{string}"}@dots{} -* Byte:: @code{.byte @var{expressions}} -* Comm:: @code{.comm @var{symbol} , @var{length} } -* Data:: @code{.data @var{subsegment}} -_if__(_COFF__||_BOUT__) -* Def:: @code{.def @var{name}} -_fi__(_COFF__||_BOUT__) -* Desc:: @code{.desc @var{symbol}, @var{abs-expression}} -_if__(_COFF__||_BOUT__) -* Dim:: @code{.dim} -_fi__(_COFF__||_BOUT__) -* Double:: @code{.double @var{flonums}} -* Else:: @code{.else} -_if__(_COFF__||_BOUT__) -* Endef:: @code{.endef} -_fi__(_COFF__||_BOUT__) -* Endif:: @code{.endif} -* Equ:: @code{.equ @var{symbol}, @var{expression}} -* Extern:: @code{.extern} -_if__(_GENERIC__||!_AMD29K__) -* File:: @code{.app-file @var{string}} -_fi__(_GENERIC__||!_AMD29K__) -* Fill:: @code{.fill @var{repeat} , @var{size} , @var{value}} -* Float:: @code{.float @var{flonums}} -* Global:: @code{.global @var{symbol}}, @code{.globl @var{symbol}} -* hword:: @code{.hword @var{expressions}} -* Ident:: @code{.ident} -* If:: @code{.if @var{absolute expression}} -* Include:: @code{.include "@var{file}"} -* Int:: @code{.int @var{expressions}} -* Lcomm:: @code{.lcomm @var{symbol} , @var{length}} -_if__(_GENERIC__||!_AMD29K__) -* Line:: @code{.line @var{line-number}} -_fi__(_GENERIC__||!_AMD29K__) -* Ln:: @code{.ln @var{line-number}} -* List:: @code{.list} and related directives -* Long:: @code{.long @var{expressions}} -* Lsym:: @code{.lsym @var{symbol}, @var{expression}} -* Octa:: @code{.octa @var{bignums}} -* Org:: @code{.org @var{new-lc} , @var{fill}} -* Quad:: @code{.quad @var{bignums}} -_if__(_COFF__||_BOUT__) -* Scl:: @code{.scl @var{class}} -_fi__(_COFF__||_BOUT__) -* Set:: @code{.set @var{symbol}, @var{expression}} -* Short:: @code{.short @var{expressions}} -* Single:: @code{.single @var{flonums}} -_if__(_COFF__||_BOUT__) -* Size:: @code{.size} -_fi__(_COFF__||_BOUT__) -* Space:: @code{.space @var{size} , @var{fill}} -* Stab:: @code{.stabd, .stabn, .stabs} -_if__(_COFF__||_BOUT__) -* Tag:: @code{.tag @var{structname}} -_fi__(_COFF__||_BOUT__) -* Text:: @code{.text @var{subsegment}} -_if__(_COFF__||_BOUT__) -* Type:: @code{.type @var{int}} -* Val:: @code{.val @var{addr}} -_fi__(_COFF__||_BOUT__) -* Word:: @code{.word @var{expressions}} -* Deprecated:: Deprecated Directives -@end menu - -_if__(_COFF__) -@node Abort, coff-ABORT, Pseudo Ops, Pseudo Ops -_fi__(_COFF__) -_if__((!_COFF__) && _BOUT__) -@node Abort, bout-ABORT, Pseudo Ops, Pseudo Ops -_fi__((!_COFF__) && _BOUT__) -_if__(! (_BOUT__ || _COFF__) ) -@node Abort, Align, Pseudo Ops, Pseudo Ops -_fi__(! (_BOUT__ || _COFF__) ) -@section @code{.abort} -This directive stops the assembly immediately. It is for -compatibility with other assemblers. The original idea was that the -assembly language source would be piped into the assembler. If the sender -of the source quit, it could use this directive tells @code{_AS__} to -quit also. One day @code{.abort} will not be supported. - -_if__(_COFF__) -@node coff-ABORT, Align, Abort, Pseudo Ops -@section @code{.ABORT} -When producing COFF output, @code{_AS__} accepts this directive as a -synonym for @samp{.abort}. -_fi__(_COFF__) - -_if__(_BOUT__) -_if__(!_COFF__) -@node bout-ABORT, Align, Abort, Pseudo Ops -@section @code{.ABORT} -_fi__(!_COFF__) - -When producing @code{b.out} output, @code{_AS__} accepts this directive, -but ignores it. -_fi__(_BOUT__) - -_if__( ! (_COFF__ || _BOUT__) ) -@node Align, App-File, Abort, Pseudo Ops -_fi__( ! (_COFF__ || _BOUT__) ) -_if__( _COFF__) -@node Align, App-File, coff-ABORT, Pseudo Ops -_fi__( _COFF__) -_if__( _BOUT__ && (! _COFF__)) -@node Align, App-File, bout-ABORT, Pseudo Ops -_fi__( _BOUT__ && (! _COFF__)) -@section @code{.align @var{abs-expr} , @var{abs-expr}} -Pad the location counter (in the current subsegment) to a particular -storage boundary. The first expression (which must be absolute) is the -number of low-order zero bits the location counter will have after -advancement. For example @samp{.align 3} will advance the location -counter until it a multiple of 8. If the location counter is already a -multiple of 8, no change is needed. - -The second expression (also absolute) gives the value to be stored in -the padding bytes. It (and the comma) may be omitted. If it is -omitted, the padding bytes are zero. - -@node App-File, Ascii, Align, Pseudo Ops -@section @code{.app-file @var{string}} -@code{.app-file} -_if__(!_AMD29K__) -(which may also be spelled @samp{.file}) -_fi__(!_AMD29K__) -tells @code{_AS__} that we are about to start a new -logical file. @var{string} is the new file name. In general, the -filename is recognized whether or not it is surrounded by quotes @samp{"}; -but if you wish to specify an empty file name is permitted, -you must give the quotes--@code{""}. This statement may go away in -future: it is only recognized to be compatible with old @code{_AS__} -programs.@refill - -@node Ascii, Asciz, App-File, Pseudo Ops -@section @code{.ascii "@var{string}"}@dots{} -@code{.ascii} expects zero or more string literals (@pxref{Strings}) -separated by commas. It assembles each string (with no automatic -trailing zero byte) into consecutive addresses. - -@node Asciz, Byte, Ascii, Pseudo Ops -@section @code{.asciz "@var{string}"}@dots{} -@code{.asciz} is just like @code{.ascii}, but each string is followed by -a zero byte. The ``z'' in @samp{.asciz} stands for ``zero''. - -@node Byte, Comm, Asciz, Pseudo Ops -@section @code{.byte @var{expressions}} - -@code{.byte} expects zero or more expressions, separated by commas. -Each expression is assembled into the next byte. - -@node Comm, Data, Byte, Pseudo Ops -@section @code{.comm @var{symbol} , @var{length} } -@code{.comm} declares a named common area in the bss segment. Normally -@code{_LD__} reserves memory addresses for it during linking, so no partial -program defines the location of the symbol. Use @code{.comm} to tell -@code{_LD__} that it must be at least @var{length} bytes long. @code{_LD__} -will allocate space for each @code{.comm} symbol that is at least as -long as the longest @code{.comm} request in any of the partial programs -linked. @var{length} is an absolute expression. - -_if__(_COFF__ || _BOUT__) -@node Data, Def, Comm, Pseudo Ops -_fi__(_COFF__ || _BOUT__) -_if__(!(_COFF__ || _BOUT__) && _AOUT__) -@node Data, Desc, Comm, Pseudo Ops -_fi__(!(_COFF__ || _BOUT__) && _AOUT__) -_if__(! (_COFF__ || _BOUT__ || _AOUT__) ) -@c Well, this *might* happen... -@node Data, Double, Comm, Pseudo Ops -_fi__(! (_COFF__ || _BOUT__ || _AOUT__) ) -@section @code{.data @var{subsegment}} -@code{.data} tells @code{_AS__} to assemble the following statements onto the -end of the data subsegment numbered @var{subsegment} (which is an -absolute expression). If @var{subsegment} is omitted, it defaults -to zero. - -_if__(_COFF__ || _BOUT__) -_if__(_AOUT__ || _BOUT__) -@node Def, Desc, Data, Pseudo Ops -_fi__(_AOUT__ || _BOUT__) -_if__(!(_AOUT__ || _BOUT__)) -@node Def, Dim, Data, Pseudo Ops -_fi__(!(_AOUT__ || _BOUT__)) -@section @code{.def @var{name}} -Begin defining debugging information for a symbol @var{name}; the -definition extends until the @code{.endef} directive is encountered. -_if__(_BOUT__) - -This directive is only observed when @code{_AS__} is configured for COFF -format output; when producing @code{b.out}, @samp{.def} is recognized, -but ignored. -_fi__(_BOUT__) -_fi__(_COFF__ || _BOUT__) - -_if__(_AOUT__||_BOUT__) -_if__(_COFF__||_BOUT__) -@node Desc, Dim, Def, Pseudo Ops -_fi__(_COFF__||_BOUT__) -_if__(!(_COFF__||_BOUT__)) -@node Desc, Double, Data, Pseudo Ops -_fi__(!(_COFF__||_BOUT__)) -@section @code{.desc @var{symbol}, @var{abs-expression}} -This directive sets the descriptor of the symbol (@pxref{Symbol Attributes}) -to the low 16 bits of an absolute expression. - -_if__(_COFF__) -The @samp{.desc} directive is not available when @code{_AS__} is -configured for COFF output; it is only for @code{a.out} or @code{b.out} -object format. For the sake of compatibility, @code{_AS__} will accept -it, but produce no output, when configured for COFF. -_fi__(_COFF__) -_fi__(_AOUT__||_BOUT__) - -_if__(_COFF__ || _BOUT__) -_if__(_AOUT__ || _BOUT__) -@node Dim, Double, Desc, Pseudo Ops -_fi__(_AOUT__ || _BOUT__) -_if__(!(_AOUT__ || _BOUT__)) -@node Dim, Double, Def, Pseudo Ops -_fi__(!(_AOUT__ || _BOUT__)) -@section @code{.dim} -This directive is generated by compilers to include auxiliary debugging -information in the symbol table. It is only permitted inside -@code{.def}/@code{.endef} pairs. -_if__(_BOUT__) - -@samp{.dim} is only meaningful when generating COFF format output; when -@code{_AS__} is generating @code{b.out}, it accepts this directive but -ignores it. -_fi__(_BOUT__) -_fi__(_COFF__ || _BOUT__) - -_if__(_COFF__||_BOUT__) -@node Double, Else, Dim, Pseudo Ops -_fi__(_COFF__||_BOUT__) -_if__(!(_COFF__||_BOUT__)) -@node Double, Else, Desc, Pseudo Ops -_fi__(!(_COFF__||_BOUT__)) -@section @code{.double @var{flonums}} -@code{.double} expects zero or more flonums, separated by commas. It -assembles floating point numbers. -_if__(_GENERIC__) -The exact kind of floating point numbers emitted depends on how -@code{_AS__} is configured. @xref{_MACH_DEP__}. -_fi__(_GENERIC__) -_if__((!_GENERIC__) && (_AMD29K__ || _I960__)) -On the _HOST__ family @samp{.double} emits 64-bit floating-point numbers -in IEEE format. -_fi__((!_GENERIC__) && (_AMD29K__ || _I960__)) - -_if__(_COFF__||_BOUT__) -@node Else, Endef, Double, Pseudo Ops -_fi__(_COFF__||_BOUT__) -_if__(!(_COFF__||_BOUT__)) -@node Else, Endif, Double, Pseudo Ops -_fi__(!(_COFF__||_BOUT__)) -@section @code{.else} -@code{.else} is part of the @code{_AS__} support for conditional -assembly; @pxref{If,,@code{.if}}. It marks the beginning of a section -of code to be assembled if the condition for the preceding @code{.if} -was false. - -_if__(0) -@node End, Endef, Else, Pseudo Ops -@section @code{.end} -This doesn't do anything---but isn't an s_ignore, so I suspect it's -meant to do something eventually (which is why it isn't documented here -as "for compatibility with blah"). -_fi__(0) - -_if__(_COFF__||_BOUT__) -@node Endef, Endif, Else, Pseudo Ops -@section @code{.endef} -This directive flags the end of a symbol definition begun with -@code{.def}. -_if__(_BOUT__) - -@samp{.endef} is only meaningful when generating COFF format output; if -@code{_AS__} is configured to generate @code{b.out}, it accepts this -directive but ignores it. -_fi__(_BOUT__) -_fi__(_COFF__||_BOUT__) - -_if__(_COFF__||_BOUT__) -@node Endif, Equ, Endef, Pseudo Ops -_fi__(_COFF__||_BOUT__) -_if__(!(_COFF__||_BOUT__)) -@node Endif, Equ, Else, Pseudo Ops -_fi__(!(_COFF__||_BOUT__)) -@section @code{.endif} -@code{.endif} is part of the @code{_AS__} support for conditional assembly; -it marks the end of a block of code that is only assembled -conditionally. @xref{If,,@code{.if}}. - -@node Equ, Extern, Endif, Pseudo Ops -@section @code{.equ @var{symbol}, @var{expression}} - -This directive sets the value of @var{symbol} to @var{expression}. -It is synonymous with @samp{.set}; @pxref{Set,,@code{.set}}. - -_if__(_GENERIC__||!_AMD29K__) -@node Extern, File, Equ, Pseudo Ops -_fi__(_GENERIC__||!_AMD29K__) -_if__(_AMD29K__&&!_GENERIC__) -@node Extern, Fill, Equ, Pseudo Ops -_fi__(_AMD29K__&&!_GENERIC__) -@section @code{.extern} -@code{.extern} is accepted in the source program---for compatibility -with other assemblers---but it is ignored. @code{_AS__} treats -all undefined symbols as external. - -_if__(_GENERIC__||!_AMD29K__) -@node File, Fill, Extern, Pseudo Ops -@section @code{.app-file @var{string}} -@code{.file} (which may also be spelled @samp{.app-file}) tells -@code{_AS__} that we are about to start a new logical file. -@var{string} is the new file name. In general, the filename is -recognized whether or not it is surrounded by quotes @samp{"}; but if -you wish to specify an empty file name, you must give the -quotes--@code{""}. This statement may go away in future: it is only -recognized to be compatible with old @code{_AS__} programs. -_if__(_AMD29K__) -In some configurations of @code{_AS__}, @code{.file} has already been -removed to avoid conflicts with other assemblers. @xref{_MACH_DEP__}. -_fi__(_AMD29K__) -_fi__(_GENERIC__||!_AMD29K__) - -_if__(_GENERIC__||!_AMD29K__) -@node Fill, Float, File, Pseudo Ops -_fi__(_GENERIC__||!_AMD29K__) -_if__(_AMD29K__&&!_GENERIC__) -@node Fill, Float, Extern, Pseudo Ops -_fi__(_AMD29K__&&!_GENERIC__) -@section @code{.fill @var{repeat} , @var{size} , @var{value}} -@var{result}, @var{size} and @var{value} are absolute expressions. -This emits @var{repeat} copies of @var{size} bytes. @var{Repeat} -may be zero or more. @var{Size} may be zero or more, but if it is -more than 8, then it is deemed to have the value 8, compatible with -other people's assemblers. The contents of each @var{repeat} bytes -is taken from an 8-byte number. The highest order 4 bytes are -zero. The lowest order 4 bytes are @var{value} rendered in the -byte-order of an integer on the computer @code{_AS__} is assembling for. -Each @var{size} bytes in a repetition is taken from the lowest order -@var{size} bytes of this number. Again, this bizarre behavior is -compatible with other people's assemblers. - -@var{size} and @var{value} are optional. -If the second comma and @var{value} are absent, @var{value} is -assumed zero. If the first comma and following tokens are absent, -@var{size} is assumed to be 1. - -@node Float, Global, Fill, Pseudo Ops -@section @code{.float @var{flonums}} -This directive assembles zero or more flonums, separated by commas. It -has the same effect as @code{.single}. -_if__(_GENERIC__) -The exact kind of floating point numbers emitted depends on how -@code{_AS__} is configured. -@xref{_MACH_DEP__}. -_fi__(_GENERIC__) -_if__((!_GENERIC__) && (_AMD29K__ || _I960__)) -On the _HOST__ family, @code{.float} emits 32-bit floating point numbers -in IEEE format. -_fi__((!_GENERIC__) && (_AMD29K__ || _I960__)) - -@node Global, hword, Float, Pseudo Ops -@section @code{.global @var{symbol}}, @code{.globl @var{symbol}} -@code{.global} makes the symbol visible to @code{_LD__}. If you define -@var{symbol} in your partial program, its value is made available to -other partial programs that are linked with it. Otherwise, -@var{symbol} will take its attributes from a symbol of the same name -from another partial program it is linked with. - -_if__(!_I960__) -@c FIXME BFD implications; this is different in COFF. -This is done by setting the @code{N_EXT} bit of that symbol's type byte -to 1. @xref{Symbol Attributes}. -_fi__(!_I960__) - -Both spellings (@samp{.globl} and @samp{.global}) are accepted, for -compatibility with other assemblers. - -_if__(_AOUT__||_BOUT__||_COFF__) -@node hword, Ident, Global, Pseudo Ops -_fi__(_AOUT__||_BOUT__||_COFF__) -_if__(!(_AOUT__||_BOUT__||_COFF__)) -@node hword, If, Global, Pseudo Ops -_fi__(!(_AOUT__||_BOUT__||_COFF__)) -@section @code{.hword @var{expressions}} -This expects zero or more @var{expressions}, and emits -a 16 bit number for each. - -_if__(_GENERIC__) -This directive is a synonym for @samp{.short}; depending on the target -architecture, it may also be a synonym for @samp{.word}. -_fi__(_GENERIC__) -_if__( (_AMD29K__ || _I960__) && !_GENERIC__ ) -This directive is a synonym for @samp{.short}. -_fi__( (_AMD29K__ || _I960__) && !_GENERIC__ ) - -_if__(_AOUT__||_BOUT__||_COFF__) -@node Ident, If, hword, Pseudo Ops -@section @code{.ident} -This directive is used by some assemblers to place tags in object files. -@code{_AS__} simply accepts the directive for source-file -compatibility with such assemblers, but does not actually emit anything -for it. -_fi__(_AOUT__||_BOUT__||_COFF__) - -_if__(_AOUT__||_BOUT__||_COFF__) -@node If, Include, Ident, Pseudo Ops -_fi__(_AOUT__||_BOUT__||_COFF__) -_if__(!(_AOUT__||_BOUT__||_COFF__)) -@node If, Include, hword, Pseudo Ops -_fi__(!(_AOUT__||_BOUT__||_COFF__)) -@section @code{.if @var{absolute expression}} -@code{.if} marks the beginning of a section of code which is only -considered part of the source program being assembled if the argument -(which must be an @var{absolute expression}) is non-zero. The end of -the conditional section of code must be marked by @code{.endif} -(@pxref{Endif,,@code{.endif}}); optionally, you may include code for the -alternative condition, flagged by @code{.else} (@pxref{Else,,@code{.else}}. - -The following variants of @code{.if} are also supported: -@table @code -@item ifdef @var{symbol} -Assembles the following section of code if the specified @var{symbol} -has been defined. - -_if__(0) -@item ifeqs -Not yet implemented. -_fi__(0) - -@item ifndef @var{symbol} -@itemx ifnotdef @var{symbol} -Assembles the following section of code if the specified @var{symbol} -has not been defined. Both spelling variants are equivalent. - -_if__(0) -@item ifnes -Not yet implemented. -_fi__(0) -@end table - -@node Include, Int, If, Pseudo Ops -@section @code{.include "@var{file}"} -This directive provides a way to include supporting files at specified -points in your source program. The code from @var{file} is assembled as -if it followed the point of the @code{.include}; when the end of the -included file is reached, assembly of the original file continues. You -can control the search paths used with the @samp{-I} command-line option -(@pxref{Invoking,,Command-Line Options}). Quotation marks are required -around @var{file}. - -@node Int, Lcomm, Include, Pseudo Ops -@section @code{.int @var{expressions}} -Expect zero or more @var{expressions}, of any segment, separated by -commas. For each expression, emit a 32-bit number that will, at run -time, be the value of that expression. The byte order of the -expression depends on what kind of computer will run the program. - -_if__(_GENERIC__||(!_AMD29K__)) -@node Lcomm, Line, Int, Pseudo Ops -_fi__(_GENERIC__||(!_AMD29K__)) -_if__((!_GENERIC__)&& _AMD29K__) -@node Lcomm, Ln, Int, Pseudo Ops -_fi__((!_GENERIC__)&& _AMD29K__) -@section @code{.lcomm @var{symbol} , @var{length}} -Reserve @var{length} (an absolute expression) bytes for a local common -denoted by @var{symbol}. The segment and value of @var{symbol} are -those of the new local common. The addresses are allocated in the bss -segment, so at run-time the bytes will start off zeroed. @var{Symbol} -is not declared global (@pxref{Global,,@code{.global}}), so is normally -not visible to @code{_LD__}. - -_if__(_GENERIC__ || !_AMD29K__) -@node Line, Ln, Lcomm, Pseudo Ops -@section @code{.line @var{line-number}} -_fi__(_GENERIC__ || (!_AMD29K__)) -_if__(_AMD29K__ && (!_GENERIC__)) -@node Ln, List, Lcomm, Pseudo Ops -@section @code{.ln @var{line-number}} -_fi__(_AMD29K__ && (!_GENERIC__)) -_if__(_AOUT__||_BOUT__) -Tell @code{_AS__} to change the logical line number. @var{line-number} must be -an absolute expression. The next line will have that logical line -number. So any other statements on the current line (after a statement -separator character -_if__(_AMD29K__&&(!_GENERIC__)) -@samp{@@}) -_fi__(_AMD29K__&&(!_GENERIC__)) -_if__(_GENERIC__ || (!_AMD29K__)) -@code{;}) -_fi__(_GENERIC__ || (!_AMD29K__)) -will be reported as on logical line number -@var{line-number} @minus{} 1. -One day this directive will be unsupported: it is used only -for compatibility with existing assembler programs. @refill - -_if__(_GENERIC__ && _AMD29K__) -@emph{Warning:} In the AMD29K configuration of _AS__, this command is -only available with the name @code{.ln}, rather than as either -@code{.line} or @code{.ln}. (Also, in that configuration the line -separator character is @samp{@@}). -_fi__(_GENERIC__ && _AMD29K__) -_fi__(_AOUT__||_BOUT__) -_if__(_COFF__) - -Even though this is a directive associated with the @code{a.out} or -@code{b.out} object-code formats, @code{_AS__} will still recognize it -when producing COFF output, and will treat @samp{.line} as though it -were the COFF @samp{.ln} @emph{if} it is found outside a -@code{.def}/@code{.endef} pair. - -Inside a @code{.def}, @samp{.line} is, instead, one of the directives -used by compilers to generate auxiliary symbol information for -debugging. -_fi__(_COFF__) - -_if__(_AOUT__&&(_GENERIC__||!_AMD29K__)) -@node Ln, List, Line, Pseudo Ops -@section @code{.ln @var{line-number}} -@samp{.ln} is a synonym for @samp{.line}. -_fi__(_AOUT__&&(_GENERIC__||!_AMD29K__)) -_if__(_COFF__&&!_AOUT__) -@node Ln, List, Line, Pseudo Ops -@section @code{.ln @var{line-number}} -Tell @code{_AS__} to change the logical line number. @var{line-number} -must be an absolute expression. The next line will have that logical -line number, so any other statements on the current line (after a -statement separator character @code{;}) will be reported as on logical -line number @var{line-number} @minus{} 1. -_if__(_BOUT__) - -This directive is accepted, but ignored, when @code{_AS__} is configured for -@code{b.out}; its effect is only associated with COFF output format. -_fi__(_BOUT__) -_fi__(_COFF__&&!_AOUT__) - -@node List, Long, Ln, Pseudo Ops -@section @code{.list} and related directives -@code{_AS__} ignores the directives @code{.list}, @code{.nolist}, -@code{.eject}, @code{.lflags}, @code{.title}, @code{.sbttl}; however, -they're accepted for compatibility with assemblers that use them. - -@node Long, Lsym, List, Pseudo Ops -@section @code{.long @var{expressions}} -@code{.long} is the same as @samp{.int}, @pxref{Int,,@code{.int}}. - -@node Lsym, Octa, Long, Pseudo Ops -@section @code{.lsym @var{symbol}, @var{expression}} -@code{.lsym} creates a new symbol named @var{symbol}, but does not put it in -the hash table, ensuring it cannot be referenced by name during the -rest of the assembly. This sets the attributes of the symbol to be -the same as the expression value: -@smallexample -@var{other} = @var{descriptor} = 0 -@var{type} = @r{(segment of @var{expression})} -@var{value} = @var{expression} -@end smallexample -@noindent -The new symbol is not flagged as external. - -@c FIXME: double size emitted for "octa" on i960, others? Or warn? -@node Octa, Org, Lsym, Pseudo Ops -@section @code{.octa @var{bignums}} -This directive expects zero or more bignums, separated by commas. For each -bignum, it emits a 16-byte integer. - -The term ``octa'' comes from contexts in which a ``word'' is two bytes; -hence @emph{octa}-word for 16 bytes. - -@node Org, Quad, Octa, Pseudo Ops -@section @code{.org @var{new-lc} , @var{fill}} - -@code{.org} will advance the location counter of the current segment to -@var{new-lc}. @var{new-lc} is either an absolute expression or an -expression with the same segment as the current subsegment. That is, -you can't use @code{.org} to cross segments: if @var{new-lc} has the -wrong segment, the @code{.org} directive is ignored. To be compatible -with former assemblers, if the segment of @var{new-lc} is absolute, -@code{_AS__} will issue a warning, then pretend the segment of @var{new-lc} -is the same as the current subsegment. - -@code{.org} may only increase the location counter, or leave it -unchanged; you cannot use @code{.org} to move the location counter -backwards. - -@c double negative used below "not undefined" because this is a specific -@c reference to "undefined" (as SEG_UNKNOWN is called in this manual) -@c segment. pesch@cygnus.com 18feb91 -Because @code{_AS__} tries to assemble programs in one pass @var{new-lc} -may not be undefined. If you really detest this restriction we eagerly await -a chance to share your improved assembler. - -Beware that the origin is relative to the start of the segment, not -to the start of the subsegment. This is compatible with other -people's assemblers. - -When the location counter (of the current subsegment) is advanced, the -intervening bytes are filled with @var{fill} which should be an -absolute expression. If the comma and @var{fill} are omitted, -@var{fill} defaults to zero. - -_if__(_COFF__||_BOUT__) -@node Quad, Scl, Org, Pseudo Ops -_fi__(_COFF__||_BOUT__) -_if__(!(_COFF__||_BOUT__)) -@node Quad, Set, Org, Pseudo Ops -_fi__(!(_COFF__||_BOUT__)) -@section @code{.quad @var{bignums}} -@code{.quad} expects zero or more bignums, separated by commas. For -each bignum, it emits -_if__(_GENERIC__||(!_I960__)) -an 8-byte integer. If the bignum won't fit in 8 -bytes, it prints a warning message; and just takes the lowest order 8 -bytes of the bignum.@refill - -The term ``quad'' comes from contexts in which a ``word'' is two bytes; -hence @emph{quad}-word for 8 bytes. -_fi__(_GENERIC__||(!_I960__)) -_if__(_I960__&&(!_GENERIC__)) -a 16-byte integer. If the bignum won't fit in 16 bytes, it prints a -warning message; and just takes the lowest order 16 bytes of the -bignum.@refill -_fi__(_I960__&&(!_GENERIC__)) - -_if__(_COFF__||_BOUT__) -@node Scl, Set, Quad, Pseudo Ops -@section @code{.scl @var{class}} -Set the storage-class value for a symbol. This directive may only be -used inside a @code{.def}/@code{.endef} pair. Storage class may flag -whether a symbol is static or external, or it may record further -symbolic debugging information. -_if__(_BOUT__) - -The @samp{.scl} directive is primarily associated with COFF output; when -configured to generate @code{b.out} output format, @code{_AS__} will -accept this directive but ignore it. -_fi__(_BOUT__) -_fi__(_COFF__||_BOUT__) - - -_if__(_COFF__||_BOUT__) -@node Set, Short, Scl, Pseudo Ops -_fi__(_COFF__||_BOUT__) -_if__(!(_COFF__||_BOUT__)) -@node Set, Short, Quad, Pseudo Ops -_fi__(!(_COFF__||_BOUT__)) -@section @code{.set @var{symbol}, @var{expression}} - -This directive sets the value of @var{symbol} to @var{expression}. This -will change @var{symbol}'s value and type to conform to -@var{expression}. If @var{symbol} was flagged as external, it remains -flagged. (@xref{Symbol Attributes}.) - -You may @code{.set} a symbol many times in the same assembly. -If the expression's segment is unknowable during pass 1, a second -pass over the source program will be forced. The second pass is -currently not implemented. @code{_AS__} will abort with an error -message if one is required. - -If you @code{.set} a global symbol, the value stored in the object -file is the last value stored into it. - -@node Short, Single, Set, Pseudo Ops -@section @code{.short @var{expressions}} -_if__(_GENERIC__ || !(_SPARC__ || _AMD29K__ || _I960__)) -@code{.short} is the same as @samp{.word}. @xref{Word,,@code{.word}}. -_if__(_SPARC__ || _AMD29K__ || _I960__) -In some configurations, however, @code{.short} and @code{.word} generate -numbers of different lengths; @pxref{_MACH_DEP__}. -_fi__(_SPARC__ || _AMD29K__ || _I960__) -_fi__(_GENERIC__|| !(_SPARC__ || _AMD29K__ || _I960__)) -_if__((!_GENERIC__) && (_SPARC__ || _AMD29K__ || _I960__)) -This expects zero or more @var{expressions}, and emits -a 16 bit number for each. -_fi__((!_GENERIC__) && (_SPARC__ || _AMD29K__ || _I960__)) -_if__(_COFF__||_BOUT__) -@node Single, Size, Short, Pseudo Ops -_fi__(_COFF__||_BOUT__) -_if__(!(_COFF__||_BOUT__)) -@node Single, Space, Short, Pseudo Ops -_fi__(!(_COFF__||_BOUT__)) -@section @code{.single @var{flonums}} -This directive assembles zero or more flonums, separated by commas. It -has the same effect as @code{.float}. -_if__(_GENERIC__) -The exact kind of floating point numbers emitted depends on how -@code{_AS__} is configured. @xref{_MACH_DEP__}. -_fi__(_GENERIC__) -_if__((!_GENERIC__) && (_AMD29K__ || _I960__ || _SPARC__)) -On the _HOST__ family, @code{.single} emits 32-bit floating point -numbers in IEEE format. -_fi__((!_GENERIC__) && (_AMD29K__ || _I960__ || _SPARC__)) - -_if__(_COFF__||_BOUT__) -@node Size, Space, Single, Pseudo Ops -@section @code{.size} -This directive is generated by compilers to include auxiliary debugging -information in the symbol table. It is only permitted inside -@code{.def}/@code{.endef} pairs. -_if__(_BOUT__) - -@samp{.size} is only meaningful when generating COFF format output; when -@code{_AS__} is generating @code{b.out}, it accepts this directive but -ignores it. -_fi__(_BOUT__) -_fi__(_COFF__||_BOUT__) - -_if__(_COFF__||_BOUT__) -@node Space, Stab, Size, Pseudo Ops -_fi__(_COFF__||_BOUT__) -_if__(!(_COFF__||_BOUT__)) -@node Space, Stab, Single, Pseudo Ops -_fi__(!(_COFF__||_BOUT__)) -_if__(_GENERIC__ || !_AMD29K__) -@section @code{.space @var{size} , @var{fill}} -This directive emits @var{size} bytes, each of value @var{fill}. Both -@var{size} and @var{fill} are absolute expressions. If the comma -and @var{fill} are omitted, @var{fill} is assumed to be zero. -_fi__(_GENERIC__ || !_AMD29K__) - -_if__(_AMD29K__) -On the AMD 29K, this directive is ignored; it is accepted for -compatibility with other AMD 29K assemblers. - -@quotation -@emph{Warning:} In other versions of the GNU assembler, the directive -@code{.space} has the effect of @code{.block} @xref{_MACH_DEP__}. -@end quotation -_fi__(_AMD29K__) - -_if__(_AOUT__||_BOUT__||_COFF__) -_if__(_COFF__||_BOUT__) -@node Stab, Tag, Space, Pseudo Ops -_fi__(_COFF__||_BOUT__) -_if__(!(_COFF__||_BOUT__)) -@node Stab, Text, Space, Pseudo Ops -_fi__(!(_COFF__||_BOUT__)) -@section @code{.stabd, .stabn, .stabs} -There are three directives that begin @samp{.stab}. -All emit symbols (@pxref{Symbols}), for use by symbolic debuggers. -The symbols are not entered in the @code{_AS__} hash table: they -cannot be referenced elsewhere in the source file. -Up to five fields are required: -@table @var -@item string -This is the symbol's name. It may contain any character except @samp{\000}, -so is more general than ordinary symbol names. Some debuggers used to -code arbitrarily complex structures into symbol names using this field. -@item type -An absolute expression. The symbol's type is set to the low 8 -bits of this expression. -Any bit pattern is permitted, but @code{_LD__} and debuggers will choke on -silly bit patterns. -@item other -An absolute expression. -The symbol's ``other'' attribute is set to the low 8 bits of this expression. -@item desc -An absolute expression. -The symbol's descriptor is set to the low 16 bits of this expression. -@item value -An absolute expression which becomes the symbol's value. -@end table - -If a warning is detected while reading a @code{.stabd}, @code{.stabn}, -or @code{.stabs} statement, the symbol has probably already been created -and you will get a half-formed symbol in your object file. This is -compatible with earlier assemblers! - -@table @code -@item .stabd @var{type} , @var{other} , @var{desc} - -The ``name'' of the symbol generated is not even an empty string. -It is a null pointer, for compatibility. Older assemblers used a -null pointer so they didn't waste space in object files with empty -strings. - -The symbol's value is set to the location counter, -relocatably. When your program is linked, the value of this symbol -will be where the location counter was when the @code{.stabd} was -assembled. - -@item .stabn @var{type} , @var{other} , @var{desc} , @var{value} - -The name of the symbol is set to the empty string @code{""}. - -@item .stabs @var{string} , @var{type} , @var{other} , @var{desc} , @var{value} - -All five fields are specified. -@end table -_fi__(_AOUT__||_BOUT__||_COFF__) - -_if__(_COFF__||_BOUT__) -@node Tag, Text, Stab, Pseudo Ops -@section @code{.tag @var{structname}} -This directive is generated by compilers to include auxiliary debugging -information in the symbol table. It is only permitted inside -@code{.def}/@code{.endef} pairs. Tags are used to link structure -definitions in the symbol table with instances of those structures. -_if__(_BOUT__) - -@samp{.tag} is only used when generating COFF format output; when -@code{_AS__} is generating @code{b.out}, it accepts this directive but -ignores it. -_fi__(_BOUT__) -_fi__(_COFF__||_BOUT__) - -_if__(_COFF__||_BOUT__) -@node Text, Type, Tag, Pseudo Ops -_fi__(_COFF__||_BOUT__) -_if__(!(_COFF__||_BOUT__)) -@node Text, Word, Stab, Pseudo Ops -_fi__(!(_COFF__||_BOUT__)) -@section @code{.text @var{subsegment}} -Tells @code{_AS__} to assemble the following statements onto the end of -the text subsegment numbered @var{subsegment}, which is an absolute -expression. If @var{subsegment} is omitted, subsegment number zero -is used. - -_if__(_COFF__||_BOUT__) -@node Type, Val, Text, Pseudo Ops -@section @code{.type @var{int}} -This directive, permitted only within @code{.def}/@code{.endef} pairs, -records the integer @var{int} as the type attribute of a symbol table entry. -_if__(_BOUT__) - -@samp{.type} is associated only with COFF format output; when -@code{_AS__} is configured for @code{b.out} output, it accepts this -directive but ignores it. -_fi__(_BOUT__) -_fi__(_COFF__||_BOUT__) - -_if__(_COFF__||_BOUT__) -@node Val, Word, Type, Pseudo Ops -@section @code{.val @var{addr}} -This directive, permitted only within @code{.def}/@code{.endef} pairs, -records the address @var{addr} as the value attribute of a symbol table -entry. -_if__(_BOUT__) - -@samp{.val} is used only for COFF output; when @code{_AS__} is -configured for @code{b.out}, it accepts this directive but ignores it. -_fi__(_BOUT__) -_fi__(_COFF__||_BOUT__) - -_if__(_COFF__||_BOUT__) -@node Word, Deprecated, Val, Pseudo Ops -_fi__(_COFF__||_BOUT__) -_if__(!(_COFF__||_BOUT__)) -@node Word, Deprecated, Text, Pseudo Ops -_fi__(!(_COFF__||_BOUT__)) -@section @code{.word @var{expressions}} -This directive expects zero or more @var{expressions}, of any segment, -separated by commas. -_if__((!_GENERIC__) && (_SPARC__ || _AMD29K__ || _I960__)) -For each expression, @code{_AS__} emits a 32-bit number. -_fi__((!_GENERIC__) && (_SPARC__ || _AMD29K__ || _I960__)) -_if__((!_GENERIC__) && (! (_SPARC__ || _AMD29K__ || _I960__) )) -For each expression, @code{_AS__} emits a 16-bit number. -_fi__((!_GENERIC__) && (! (_SPARC__ || _AMD29K__ || _I960__) )) - -_if__(_GENERIC__) -The size of the number emitted, and its byte order, -depends on what kind of computer will run the program. -_fi__(_GENERIC__) - -@c on amd29k, i960, sparc the "special treatment to support compilers" doesn't -@c happen---32-bit addressability, period; no long/short jumps. -_if__(_GENERIC__ || (! (_AMD29K__ || _I960__) )) -@quotation -@emph{Warning: Special Treatment to support Compilers} -@end quotation - -_if__(_GENERIC__) -Machines that do less than 32-bit addressing require the following -special treatment. If the machine of interest to you does 32-bit -addressing (@pxref{_MACH_DEP__}), you can ignore this issue. - -_fi__(_GENERIC__) -In order to assemble compiler output into something that will work, -@code{_AS__} will occasionlly do strange things to @samp{.word} directives. -Directives of the form @samp{.word sym1-sym2} are often emitted by -compilers as part of jump tables. Therefore, when @code{_AS__} assembles a -directive of the form @samp{.word sym1-sym2}, and the difference between -@code{sym1} and @code{sym2} does not fit in 16 bits, @code{_AS__} will -create a @dfn{secondary jump table}, immediately before the next label. -This @var{secondary jump table} will be preceded by a short-jump to the -first byte after the secondary table. This short-jump prevents the flow -of control from accidentally falling into the new table. Inside the -table will be a long-jump to @code{sym2}. The original @samp{.word} -will contain @code{sym1} minus the address of the long-jump to -@code{sym2}. - -If there were several occurrences of @samp{.word sym1-sym2} before the -secondary jump table, all of them will be adjusted. If there was a -@samp{.word sym3-sym4}, that also did not fit in sixteen bits, a -long-jump to @code{sym4} will be included in the secondary jump table, -and the @code{.word} directives will be adjusted to contain @code{sym3} -minus the address of the long-jump to @code{sym4}; and so on, for as many -entries in the original jump table as necessary. - -_if__(_INTERNALS__) -@emph{This feature may be disabled by compiling @code{_AS__} with the -@samp{-DWORKING_DOT_WORD} option.} This feature is likely to confuse -assembly language programmers. -_fi__(_INTERNALS__) -_fi__(_GENERIC__ || (! (_AMD29K__ || _I960__) )) - -@node Deprecated, , Word, Pseudo Ops -@section Deprecated Directives -One day these directives won't work. -They are included for compatibility with older assemblers. -@table @t -@item .abort -@item .app-file -@item .line -@end table - -@node _MACH_DEP__, License, Pseudo Ops, Top -_if__(_GENERIC__) -@chapter Machine Dependent Features -@menu -_if__(_VAX__) -* Vax-Dependent:: VAX Dependent Features -_fi__(_VAX__) -_if__(_AMD29K__) -* AMD29K-Dependent:: AMD 29K Dependent Features -_fi__(_AMD29K__) -_if__(_I960__) -* i960-Dependent:: Intel 80960 Dependent Features -_fi__(_I960__) -_if__(_M680X0__) -* M68K-Dependent:: M680x0 Dependent Features -_fi__(_M680X0__) -_if__(_SPARC__) -* Sparc-Dependent:: SPARC Dependent Features -_fi__(_SPARC__) -_if__(_I80386__) -* i386-Dependent:: 80386 Dependent Features -_fi__(_I80386__) -@end menu - -_fi__(_GENERIC__) -_if__(_VAX__) -@c @group -_if__(_GENERIC__) -@node Vax-Dependent, AMD29K-Dependent, Machine Dependent, Machine Dependent -_fi__(_GENERIC__) -_CHAPSEC__(0+_GENERIC__) VAX Dependent Features -@menu -* Vax-Opts:: VAX Command-Line Options -* VAX-float:: VAX Floating Point -* VAX-directives:: Vax Machine Directives -* VAX-opcodes:: VAX Opcodes -* VAX-branch:: VAX Branch Improvement -* VAX-operands:: VAX Operands -* VAX-no:: Not Supported on VAX -@end menu - -@node Vax-Opts, VAX-float, Vax-Dependent, Vax-Dependent -_CHAPSEC__(1+_GENERIC__) VAX Command-Line Options - -The Vax version of @code{_AS__} accepts any of the following options, -gives a warning message that the option was ignored and proceeds. -These options are for compatibility with scripts designed for other -people's assemblers. -@c @end group - -@table @asis -@item @kbd{-D} (Debug) -@itemx @kbd{-S} (Symbol Table) -@itemx @kbd{-T} (Token Trace) -These are obsolete options used to debug old assemblers. - -@item @kbd{-d} (Displacement size for JUMPs) -This option expects a number following the @kbd{-d}. Like options -that expect filenames, the number may immediately follow the -@kbd{-d} (old standard) or constitute the whole of the command line -argument that follows @kbd{-d} (GNU standard). - -@item @kbd{-V} (Virtualize Interpass Temporary File) -Some other assemblers use a temporary file. This option -commanded them to keep the information in active memory rather -than in a disk file. @code{_AS__} always does this, so this -option is redundant. - -@item @kbd{-J} (JUMPify Longer Branches) -Many 32-bit computers permit a variety of branch instructions -to do the same job. Some of these instructions are short (and -fast) but have a limited range; others are long (and slow) but -can branch anywhere in virtual memory. Often there are 3 -flavors of branch: short, medium and long. Some other -assemblers would emit short and medium branches, unless told by -this option to emit short and long branches. - -@item @kbd{-t} (Temporary File Directory) -Some other assemblers may use a temporary file, and this option -takes a filename being the directory to site the temporary -file. @code{_AS__} does not use a temporary disk file, so this -option makes no difference. @kbd{-t} needs exactly one -filename. -@end table - -The Vax version of the assembler accepts two options when -compiled for VMS. They are @kbd{-h}, and @kbd{-+}. The -@kbd{-h} option prevents @code{_AS__} from modifying the -symbol-table entries for symbols that contain lowercase -characters (I think). The @kbd{-+} option causes @code{_AS__} to -print warning messages if the FILENAME part of the object file, -or any symbol name is larger than 31 characters. The @kbd{-+} -option also insertes some code following the @samp{_main} -symbol so that the object file will be compatible with Vax-11 -"C". - -@node VAX-float, VAX-directives, Vax-Opts, Vax-Dependent -_CHAPSEC__(1+_GENERIC__) VAX Floating Point -Conversion of flonums to floating point is correct, and -compatible with previous assemblers. Rounding is -towards zero if the remainder is exactly half the least significant bit. - -@code{D}, @code{F}, @code{G} and @code{H} floating point formats -are understood. - -Immediate floating literals (@emph{e.g.} @samp{S`$6.9}) -are rendered correctly. Again, rounding is towards zero in the -boundary case. - -The @code{.float} directive produces @code{f} format numbers. -The @code{.double} directive produces @code{d} format numbers. - -@node VAX-directives, VAX-opcodes, VAX-float, Vax-Dependent -_CHAPSEC__(1+_GENERIC__) Vax Machine Directives -The Vax version of the assembler supports four directives for -generating Vax floating point constants. They are described in the -table below. - -@table @code -@item .dfloat -This expects zero or more flonums, separated by commas, and -assembles Vax @code{d} format 64-bit floating point constants. - -@item .ffloat -This expects zero or more flonums, separated by commas, and -assembles Vax @code{f} format 32-bit floating point constants. - -@item .gfloat -This expects zero or more flonums, separated by commas, and -assembles Vax @code{g} format 64-bit floating point constants. - -@item .hfloat -This expects zero or more flonums, separated by commas, and -assembles Vax @code{h} format 128-bit floating point constants. - -@end table - -@node VAX-opcodes, VAX-branch, VAX-directives, Vax-Dependent -_CHAPSEC__(1+_GENERIC__) VAX Opcodes -All DEC mnemonics are supported. Beware that @code{case@dots{}} -instructions have exactly 3 operands. The dispatch table that -follows the @code{case@dots{}} instruction should be made with -@code{.word} statements. This is compatible with all unix -assemblers we know of. - -@node VAX-branch, VAX-operands, VAX-opcodes, Vax-Dependent -_CHAPSEC__(1+_GENERIC__) VAX Branch Improvement -Certain pseudo opcodes are permitted. They are for branch -instructions. They expand to the shortest branch instruction that -will reach the target. Generally these mnemonics are made by -substituting @samp{j} for @samp{b} at the start of a DEC mnemonic. -This feature is included both for compatibility and to help -compilers. If you don't need this feature, don't use these -opcodes. Here are the mnemonics, and the code they can expand into. - -@table @code -@item jbsb -@samp{Jsb} is already an instruction mnemonic, so we chose @samp{jbsb}. -@table @asis -@item (byte displacement) -@kbd{bsbb @dots{}} -@item (word displacement) -@kbd{bsbw @dots{}} -@item (long displacement) -@kbd{jsb @dots{}} -@end table -@item jbr -@itemx jr -Unconditional branch. -@table @asis -@item (byte displacement) -@kbd{brb @dots{}} -@item (word displacement) -@kbd{brw @dots{}} -@item (long displacement) -@kbd{jmp @dots{}} -@end table -@item j@var{COND} -@var{COND} may be any one of the conditional branches -@code{neq nequ eql eqlu gtr geq lss gtru lequ vc vs gequ cc lssu cs}. -@var{COND} may also be one of the bit tests -@code{bs bc bss bcs bsc bcc bssi bcci lbs lbc}. -@var{NOTCOND} is the opposite condition to @var{COND}. -@table @asis -@item (byte displacement) -@kbd{b@var{COND} @dots{}} -@item (word displacement) -@kbd{b@var{NOTCOND} foo ; brw @dots{} ; foo:} -@item (long displacement) -@kbd{b@var{NOTCOND} foo ; jmp @dots{} ; foo:} -@end table -@item jacb@var{X} -@var{X} may be one of @code{b d f g h l w}. -@table @asis -@item (word displacement) -@kbd{@var{OPCODE} @dots{}} -@item (long displacement) -@example -@var{OPCODE} @dots{}, foo ; -brb bar ; -foo: jmp @dots{} ; -bar: -@end example -@end table -@item jaob@var{YYY} -@var{YYY} may be one of @code{lss leq}. -@item jsob@var{ZZZ} -@var{ZZZ} may be one of @code{geq gtr}. -@table @asis -@item (byte displacement) -@kbd{@var{OPCODE} @dots{}} -@item (word displacement) -@example -@var{OPCODE} @dots{}, foo ; -brb bar ; -foo: brw @var{destination} ; -bar: -@end example -@item (long displacement) -@example -@var{OPCODE} @dots{}, foo ; -brb bar ; -foo: jmp @var{destination} ; -bar: -@end example -@end table -@item aobleq -@itemx aoblss -@itemx sobgeq -@itemx sobgtr -@table @asis -@item (byte displacement) -@kbd{@var{OPCODE} @dots{}} -@item (word displacement) -@example -@var{OPCODE} @dots{}, foo ; -brb bar ; -foo: brw @var{destination} ; -bar: -@end example -@item (long displacement) -@example -@var{OPCODE} @dots{}, foo ; -brb bar ; -foo: jmp @var{destination} ; -bar: -@end example -@end table -@end table - -@node VAX-operands, VAX-no, VAX-branch, Vax-Dependent -_CHAPSEC__(1+_GENERIC__) VAX Operands -The immediate character is @samp{$} for Unix compatibility, not -@samp{#} as DEC writes it. - -The indirect character is @samp{*} for Unix compatibility, not -@samp{@@} as DEC writes it. - -The displacement sizing character is @samp{`} (an accent grave) for -Unix compatibility, not @samp{^} as DEC writes it. The letter -preceding @samp{`} may have either case. @samp{G} is not -understood, but all other letters (@code{b i l s w}) are understood. - -Register names understood are @code{r0 r1 r2 @dots{} r15 ap fp sp -pc}. Any case of letters will do. - -For instance -@smallexample -tstb *w`$4(r5) -@end smallexample - -Any expression is permitted in an operand. Operands are comma -separated. - -@c There is some bug to do with recognizing expressions -@c in operands, but I forget what it is. It is -@c a syntax clash because () is used as an address mode -@c and to encapsulate sub-expressions. - -@node VAX-no, , VAX-operands, Vax-Dependent -_CHAPSEC__(1+_GENERIC__) Not Supported on VAX -Vax bit fields can not be assembled with @code{_AS__}. Someone -can add the required code if they really need it. - -_fi__(_VAX__) -_if__(_AMD29K__) -@c @group -_if__(_GENERIC__) -@node AMD29K-Dependent, i960-Dependent, Vax-Dependent, Machine Dependent -_fi__(_GENERIC__) -_CHAPSEC__(0+_GENERIC__) AMD 29K Dependent Features -@menu -* AMD29K Options:: Options -* AMD29K Syntax:: Syntax -* AMD29K Floating Point:: Floating Point -* AMD29K Directives:: AMD 29K Machine Directives -* AMD29K Opcodes:: Opcodes -@end menu - -@node AMD29K Options, AMD29K Syntax, AMD29K-Dependent, AMD29K-Dependent -_CHAPSEC__(1+_GENERIC__) Options -@code{_AS__} has no additional command-line options for the AMD -29K family. -@c @end group - -@c @group -@node AMD29K Syntax, AMD29K Floating Point, AMD29K Options, AMD29K-Dependent -_CHAPSEC__(1+_GENERIC__) Syntax -@menu -* AMD29K-Chars:: Special Characters -* AMD29K-Regs:: Register Names -@end menu - -@node AMD29K-Chars, AMD29K-Regs, AMD29K Syntax, AMD29K Syntax -_CHAPSEC__(2+_GENERIC__) Special Characters -@samp{;} is the line comment character. - -@samp{@@} can be used instead of a newline to separate statements. - -The character @samp{?} is permitted in identifiers (but may not begin -an identifier). -@c @end group - -@node AMD29K-Regs, , AMD29K-Chars, AMD29K Syntax -_CHAPSEC__(2+_GENERIC__) Register Names -General-purpose registers are represented by predefined symbols of the -form @samp{GR@var{nnn}} (for global registers) or @samp{LR@var{nnn}} -(for local registers), where @var{nnn} represents a number between -@code{0} and @code{127}, written with no leading zeros. The leading -letters may be in either upper or lower case; for example, @samp{gr13} -and @samp{LR7} are both valid register names. - -You may also refer to general-purpose registers by specifying the -register number as the result of an expression (prefixed with @samp{%%} -to flag the expression as a register number): -@smallexample -%%@var{expression} -@end smallexample -@noindent ----where @var{expression} must be an absolute expression evaluating to a -number between @code{0} and @code{255}. The range [0, 127] refers to -global registers, and the range [128, 255] to local registers. - -In addition, @code{_AS__} understands the following protected -special-purpose register names for the AMD 29K family: - -@smallexample - vab chd pc0 - ops chc pc1 - cps rbp pc2 - cfg tmc mmu - cha tmr lru -@end smallexample - -These unprotected special-purpose register names are also recognized: -@smallexample - ipc alu fpe - ipa bp inte - ipb fc fps - q cr exop -@end smallexample - -@node AMD29K Floating Point, AMD29K Directives, AMD29K Syntax, AMD29K-Dependent -_CHAPSEC__(1+_GENERIC__) Floating Point -The AMD 29K family uses IEEE floating-point numbers. - -@c @group -@node AMD29K Directives, AMD29K Opcodes, AMD29K Floating Point, AMD29K-Dependent -_CHAPSEC__(1+_GENERIC__) AMD 29K Machine Directives - -@table @code -@item .block @var{size} , @var{fill} -This directive emits @var{size} bytes, each of value @var{fill}. Both -@var{size} and @var{fill} are absolute expressions. If the comma -and @var{fill} are omitted, @var{fill} is assumed to be zero. - -In other versions of the GNU assembler, this directive is called -@samp{.space}. -@end table -@c @end group - -@table @code -@item .cputype -This directive is ignored; it is accepted for compatibility with other -AMD 29K assemblers. - -@item .file -This directive is ignored; it is accepted for compatibility with other -AMD 29K assemblers. - -@quotation -@emph{Warning:} in other versions of the GNU assembler, @code{.file} is -used for the directive called @code{.app-file} in the AMD 29K support. -@end quotation - -@item .line -This directive is ignored; it is accepted for compatibility with other -AMD 29K assemblers. - -@item .reg @var{symbol}, @var{expression} -@code{.reg} has the same effect as @code{.lsym}; @pxref{Lsym,,@code{.lsym}}. - -@item .sect -This directive is ignored; it is accepted for compatibility with other -AMD 29K assemblers. - -@item .use @var{segment name} -Establishes the segment and subsegment for the following code; -@var{segment name} may be one of @code{.text}, @code{.data}, -@code{.data1}, or @code{.lit}. With one of the first three @var{segment -name} options, @samp{.use} is equivalent to the machine directive -@var{segment name}; the remaining case, @samp{.use .lit}, is the same as -@samp{.data 200}. -@end table - -@node AMD29K Opcodes, , AMD29K Directives, AMD29K-Dependent -_CHAPSEC__(1+_GENERIC__) Opcodes -@code{_AS__} implements all the standard AMD 29K opcodes. No -additional pseudo-instructions are needed on this family. - -For information on the 29K machine instruction set, see @cite{Am29000 -User's Manual}, Advanced Micro Devices, Inc. - -_fi__(_AMD29K__) -_if__(_I960__) -_if__(_GENERIC__) -@node i960-Dependent, M68K-Dependent, AMD29K-Dependent, Machine Dependent -_fi__(_GENERIC__) -_CHAPSEC__(0+_GENERIC__) Intel 80960 Dependent Features -@menu -* Options-i960:: i960 Command-line Options -* Floating Point-i960:: Floating Point -* Directives-i960:: i960 Machine Directives -* Opcodes for i960:: i960 Opcodes -@end menu - -@c FIXME! Add Syntax sec with discussion of bitfields here, at least so -@c long as they're not turned on for other machines than 960. -@node Options-i960, Floating Point-i960, i960-Dependent, i960-Dependent -_CHAPSEC__(1+_GENERIC__) i960 Command-line Options -@table @code - -@item -ACA | -ACA_A | -ACB | -ACC | -AKA | -AKB | -AKC | -AMC -Select the 80960 architecture. Instructions or features not supported -by the selected architecture cause fatal errors. - -@samp{-ACA} is equivalent to @samp{-ACA_A}; @samp{-AKC} is equivalent to -@samp{-AMC}. Synonyms are provided for compatibility with other tools. - -If none of these options is specified, @code{_AS__} will generate code for any -instruction or feature that is supported by @emph{some} version of the -960 (even if this means mixing architectures!). In principle, -@code{_AS__} will attempt to deduce the minimal sufficient processor -type if none is specified; depending on the object code format, the -processor type may be recorded in the object file. If it is critical -that the @code{_AS__} output match a specific architecture, specify that -architecture explicitly. - - -@item -b -Add code to collect information about conditional branches taken, for -later optimization using branch prediction bits. (The conditional branch -instructions have branch prediction bits in the CA, CB, and CC -architectures.) If @var{BR} represents a conditional branch instruction, -the following represents the code generated by the assembler when -@samp{-b} is specified: - -@smallexample - call @var{increment routine} - .word 0 # pre-counter -Label: @var{BR} - call @var{increment routine} - .word 0 # post-counter -@end smallexample - -The counter following a branch records the number of times that branch -was @emph{not} taken; the differenc between the two counters is the -number of times the branch @emph{was} taken. - -A table of all such @code{Label}s is also generated, so that the -external postprocessor @samp{gbr960} (supplied by Intel) can locate all -the counters. This table is always labelled @samp{__BRANCH_TABLE__}; -this is a local symbol to permit collecting statistics for many separate -object files. The table is word aligned, and begins with a two-word -header. The first word, initialized to 0, is used in maintaining linked -lists of branch tables. The second word is a count of the number of -entries in the table, which follow immediately: each is a word, pointing -to one of the labels illustrated above. - -@ifinfo -@example - +------------+------------+------------+ ... +------------+ - | | | | | | - | *NEXT | COUNT: N | *BRLAB 1 | | *BRLAB N | - | | | | | | - +------------+------------+------------+ ... +------------+ - - __BRANCH_TABLE__ layout -@end example -@end ifinfo -@tex -\vskip 1pc -\line{\leftskip=0pt\hskip\tableindent -\boxit{2cm}{\tt *NEXT}\boxit{2cm}{\tt COUNT: \it N}\boxit{2cm}{\tt -*BRLAB 1}\ibox{1cm}{\quad\dots}\boxit{2cm}{\tt *BRLAB \it N}\hfil} -\centerline{\it {\tt \_\_BRANCH\_TABLE\_\_} layout} -@end tex - -The first word of the header is used to locate multiple branch tables, -since each object file may contain one. Normally the links are -maintained with a call to an initialization routine, placed at the -beginning of each function in the file. The GNU C compiler will -generate these calls automatically when you give it a @samp{-b} option. -For further details, see the documentation of @samp{gbr960}. - -@item -norelax -Normally, Compare-and-Branch instructions with targets that require -displacements greater than 13 bits (or that have external targets) are -replaced with the corresponding compare (or @samp{chkbit}) and branch -instructions. You can use the @samp{-norelax} option to specify that -@code{_AS__} should generate errors instead, if the target displacement -is larger than 13 bits. - -This option does not affect the Compare-and-Jump instructions; the code -emitted for them is @emph{always} adjusted when necessary (depending on -displacement size), regardless of whether you use @samp{-norelax}. -@end table - -@node Floating Point-i960, Directives-i960, Options-i960, i960-Dependent -_CHAPSEC__(1+_GENERIC__) Floating Point -@code{_AS__} generates IEEE floating-point numbers for the directives -@samp{.float}, @samp{.double}, @samp{extended}, and @samp{.single}. - -@c @group -@node Directives-i960, Opcodes for i960, Floating Point-i960, i960-Dependent -_CHAPSEC__(1+_GENERIC__) i960 Machine Directives - -@table @code -@item .bss @var{symbol}, @var{length}, @var{align} -Reserve @var{length} bytes in the bss segment for a local @var{symbol}, -aligned to the power of two specified by @var{align}. @var{length} and -@var{align} must be positive absolute expressions. This directive -differs from @samp{.lcomm} only in that it permits you to specify -an alignment. @xref{Lcomm,,@code{.lcomm}}. -@end table -@c @end group - -@table @code -@item .extended @var{flonums} -@code{.extended} expects zero or more flonums, separated by commas; for -each flonum, @samp{.extended} emits an IEEE extended-format (80-bit) -floating-point number. - -@item .leafproc @var{call-lab}, @var{bal-lab} -You can use the @samp{.leafproc} directive in conjunction with the -optimized @code{callj} instruction to enable faster calls of leaf -procedures. If a procedure is known to call no other procedures, you -may define an entry point that skips procedure prolog code (and that does -not depend on system-supplied saved context), and declare it as the -@var{bal-lab} using @samp{.leafproc}. If the procedure also has an -entry point that goes through the normal prolog, you can specify that -entry point as @var{call-lab}. - -A @samp{.leafproc} declaration is meant for use in conjunction with the -optimized call instruction @samp{callj}; the directive records the data -needed later to choose between converting the @samp{callj} into a -@code{bal} or a @code{call}. - -@var{call-lab} is optional; if only one argument is present, or if the -two arguments are identical, the single argument is assumed to be the -@code{bal} entry point. - -@item .sysproc @var{name}, @var{index} -The @samp{.sysproc} directive defines a name for a system procedure. -After you define it using @samp{.sysproc}, you can use @var{name} to -refer to the system procedure identified by @var{index} when calling -procedures with the optimized call instruction @samp{callj}. - -Both arguments are required; @var{index} must be between 0 and 31 -(inclusive). -@end table - -@node Opcodes for i960, , Directives-i960, i960-Dependent -_CHAPSEC__(1+_GENERIC__) i960 Opcodes -All Intel 960 machine instructions are supported; -@pxref{Options-i960,,i960 Command-line Options} for a discussion of -selecting the instruction subset for a particular 960 -architecture.@refill - -Some opcodes are processed beyond simply emitting a single corresponding -instruction: @samp{callj}, and Compare-and-Branch or Compare-and-Jump -instructions with target displacements larger than 13 bits. - -@menu -* callj-i960:: @code{callj} -* Compare-and-branch-i960:: Compare-and-Branch -@end menu - -@node callj-i960, Compare-and-branch-i960, Opcodes for i960, Opcodes for i960 -_CHAPSEC__(2+_GENERIC__) @code{callj} -You can write @code{callj} to have the assembler or the linker determine -the most appropriate form of subroutine call: @samp{call}, -@samp{bal}, or @samp{calls}. If the assembly source contains -enough information---a @samp{.leafproc} or @samp{.sysproc} directive -defining the operand---then @code{_AS__} will translate the -@code{callj}; if not, it will simply emit the @code{callj}, leaving it -for the linker to resolve. - -@node Compare-and-branch-i960, , callj-i960, Opcodes for i960 -_CHAPSEC__(2+_GENERIC__) Compare-and-Branch - -The 960 architectures provide combined Compare-and-Branch instructions -that permit you to store the branch target in the lower 13 bits of the -instruction word itself. However, if you specify a branch target far -enough away that its address won't fit in 13 bits, the assembler can -either issue an error, or convert your Compare-and-Branch instruction -into separate instructions to do the compare and the branch. - -Whether @code{_AS__} gives an error or expands the instruction depends -on two choices you can make: whether you use the @samp{-norelax} option, -and whether you use a ``Compare and Branch'' instruction or a ``Compare -and Jump'' instruction. The ``Jump'' instructions are @emph{always} -expanded if necessary; the ``Branch'' instructions are expanded when -necessary @emph{unless} you specify @code{-norelax}---in which case -@code{_AS__} gives an error instead. - -@c @group -These are the Compare-and-Branch instructions, their ``Jump'' variants, -and the instruction pairs they may expand into: - -@ifinfo -@example - Compare and - Branch Jump Expanded to - ------ ------ ------------ - bbc chkbit; bno - bbs chkbit; bo - cmpibe cmpije cmpi; be - cmpibg cmpijg cmpi; bg - cmpibge cmpijge cmpi; bge - cmpibl cmpijl cmpi; bl - cmpible cmpijle cmpi; ble - cmpibno cmpijno cmpi; bno - cmpibne cmpijne cmpi; bne - cmpibo cmpijo cmpi; bo - cmpobe cmpoje cmpo; be - cmpobg cmpojg cmpo; bg - cmpobge cmpojge cmpo; bge - cmpobl cmpojl cmpo; bl - cmpoble cmpojle cmpo; ble - cmpobne cmpojne cmpo; bne -@end example -@end ifinfo -@tex -\hskip\tableindent -\halign{\hfil {\tt #}\quad&\hfil {\tt #}\qquad&{\tt #}\hfil\cr -\omit{\hfil\it Compare and\hfil}\span\omit&\cr -{\it Branch}&{\it Jump}&{\it Expanded to}\cr - bbc& & chkbit; bno\cr - bbs& & chkbit; bo\cr - cmpibe& cmpije& cmpi; be\cr - cmpibg& cmpijg& cmpi; bg\cr - cmpibge& cmpijge& cmpi; bge\cr - cmpibl& cmpijl& cmpi; bl\cr - cmpible& cmpijle& cmpi; ble\cr - cmpibno& cmpijno& cmpi; bno\cr - cmpibne& cmpijne& cmpi; bne\cr - cmpibo& cmpijo& cmpi; bo\cr - cmpobe& cmpoje& cmpo; be\cr - cmpobg& cmpojg& cmpo; bg\cr - cmpobge& cmpojge& cmpo; bge\cr - cmpobl& cmpojl& cmpo; bl\cr - cmpoble& cmpojle& cmpo; ble\cr - cmpobne& cmpojne& cmpo; bne\cr} -@end tex -@c @end group -_fi__(_I960__) - -@c @group -_if__(_M680X0__) -_if__(_GENERIC__) -@c FIXME! node conds are only sufficient for m68k alone, all, and vintage -_if__(_I960__) -@node M68K-Dependent, Sparc-Dependent, i960-Dependent, Machine Dependent -_fi__(_I960__) -_if__(!_I960__) -@node M68K-Dependent, Sparc-Dependent, Machine Dependent, Machine Dependent -_fi__(!_I960__) -_CHAPSEC__(0+_GENERIC__) M680x0 Dependent Features -_fi__(_GENERIC__) -@menu -* M68K-Opts:: M680x0 Options -* M68K-Syntax:: Syntax -* M68K-Float:: Floating Point -* M68K-Directives:: 680x0 Machine Directives -* M68K-opcodes:: Opcodes -@end menu - -@node M68K-Opts, M68K-Syntax, M68K-Dependent, M68K-Dependent -_CHAPSEC__(1+_GENERIC__) M680x0 Options -The Motorola 680x0 version of @code{_AS__} has two machine dependent options. -One shortens undefined references from 32 to 16 bits, while the -other is used to tell @code{_AS__} what kind of machine it is -assembling for. -@c @end group - -You can use the @kbd{-l} option to shorten the size of references to -undefined symbols. If the @kbd{-l} option is not given, references to -undefined symbols will be a full long (32 bits) wide. (Since @code{_AS__} -cannot know where these symbols will end up, @code{_AS__} can only allocate -space for the linker to fill in later. Since @code{_AS__} doesn't know how -far away these symbols will be, it allocates as much space as it can.) -If this option is given, the references will only be one word wide (16 -bits). This may be useful if you want the object file to be as small as -possible, and you know that the relevant symbols will be less than 17 -bits away. - -The 680x0 version of @code{_AS__} is most frequently used to assemble -programs for the Motorola MC68020 microprocessor. Occasionally it is -used to assemble programs for the mostly similar, but slightly different -MC68000 or MC68010 microprocessors. You can give @code{_AS__} the options -@samp{-m68000}, @samp{-mc68000}, @samp{-m68010}, @samp{-mc68010}, -@samp{-m68020}, and @samp{-mc68020} to tell it what processor is the -target. - -@node M68K-Syntax, M68K-Float, M68K-Opts, M68K-Dependent -_CHAPSEC__(1+_GENERIC__) Syntax - -The 680x0 version of @code{_AS__} uses syntax similar to the Sun assembler. -Size modifiers are appended directly to the end of the opcode without an -intervening period. For example, write @samp{movl} rather than -@samp{move.l}. - -_if__(_INTERNALS__) -If @code{_AS__} is compiled with SUN_ASM_SYNTAX defined, it will also allow -Sun-style local labels of the form @samp{1$} through @samp{$9}. -_fi__(_INTERNALS__) - -In the following table @dfn{apc} stands for any of the address -registers (@samp{a0} through @samp{a7}), nothing, (@samp{}), the -Program Counter (@samp{pc}), or the zero-address relative to the -program counter (@samp{zpc}). - -The following addressing modes are understood: -@table @dfn -@item Immediate -@samp{#@var{digits}} - -@item Data Register -@samp{d0} through @samp{d7} - -@item Address Register -@samp{a0} through @samp{a7} - -@item Address Register Indirect -@samp{a0@@} through @samp{a7@@} - -@item Address Register Postincrement -@samp{a0@@+} through @samp{a7@@+} - -@item Address Register Predecrement -@samp{a0@@-} through @samp{a7@@-} - -@item Indirect Plus Offset -@samp{@var{apc}@@(@var{digits})} - -@item Index -@samp{@var{apc}@@(@var{digits},@var{register}:@var{size}:@var{scale})} - -or @samp{@var{apc}@@(@var{register}:@var{size}:@var{scale})} - -@item Postindex -@samp{@var{apc}@@(@var{digits})@@(@var{digits},@var{register}:@var{size}:@var{scale})} - -or @samp{@var{apc}@@(@var{digits})@@(@var{register}:@var{size}:@var{scale})} - -@item Preindex -@samp{@var{apc}@@(@var{digits},@var{register}:@var{size}:@var{scale})@@(@var{digits})} - -or @samp{@var{apc}@@(@var{register}:@var{size}:@var{scale})@@(@var{digits})} - -@item Memory Indirect -@samp{@var{apc}@@(@var{digits})@@(@var{digits})} - -@item Absolute -@samp{@var{symbol}}, or @samp{@var{digits}} -@ignore -@c pesch@cygnus.com: gnu, rich concur the following needs careful -@c research before documenting. - , or either of the above followed -by @samp{:b}, @samp{:w}, or @samp{:l}. -@end ignore -@end table - -@node M68K-Float, M68K-Directives, M68K-Syntax, M68K-Dependent -_CHAPSEC__(1+_GENERIC__) Floating Point -The floating point code is not too well tested, and may have -subtle bugs in it. - -Packed decimal (P) format floating literals are not supported. -Feel free to add the code! - -The floating point formats generated by directives are these. -@table @code -@item .float -@code{Single} precision floating point constants. -@item .double -@code{Double} precision floating point constants. -@end table - -There is no directive to produce regions of memory holding -extended precision numbers, however they can be used as -immediate operands to floating-point instructions. Adding a -directive to create extended precision numbers would not be -hard, but it has not yet seemed necessary. - -@node M68K-Directives, M68K-opcodes, M68K-Float, M68K-Dependent -_CHAPSEC__(1+_GENERIC__) 680x0 Machine Directives -In order to be compatible with the Sun assembler the 680x0 assembler -understands the following directives. -@table @code -@item .data1 -This directive is identical to a @code{.data 1} directive. -@item .data2 -This directive is identical to a @code{.data 2} directive. -@item .even -This directive is identical to a @code{.align 1} directive. -@c Is this true? does it work??? -@item .skip -This directive is identical to a @code{.space} directive. -@end table - -@node M68K-opcodes, , M68K-Directives, M68K-Dependent -_CHAPSEC__(1+_GENERIC__) Opcodes -@c pesch@cygnus.com: I don't see any point in the following -@c paragraph. Bugs are bugs; how does saying this -@c help anyone? -@ignore -Danger: Several bugs have been found in the opcode table (and -fixed). More bugs may exist. Be careful when using obscure -instructions. -@end ignore - -@menu -* M68K-Branch:: Branch Improvement -* M68K-Chars:: Special Characters -@end menu - -@node M68K-Branch, M68K-Chars, M68K-opcodes, M68K-opcodes -_CHAPSEC__(2+_GENERIC__) Branch Improvement - -Certain pseudo opcodes are permitted for branch instructions. -They expand to the shortest branch instruction that will reach the -target. Generally these mnemonics are made by substituting @samp{j} for -@samp{b} at the start of a Motorola mnemonic. - -The following table summarizes the pseudo-operations. A @code{*} flags -cases that are more fully described after the table: - -@smallexample - Displacement - +--------------------------------------------------------- - | 68020 68000/10 -Pseudo-Op |BYTE WORD LONG LONG non-PC relative - +--------------------------------------------------------- - jbsr |bsrs bsr bsrl jsr jsr - jra |bras bra bral jmp jmp -* jXX |bXXs bXX bXXl bNXs;jmpl bNXs;jmp -* dbXX |dbXX dbXX dbXX; bra; jmpl -* fjXX |fbXXw fbXXw fbXXl fbNXw;jmp - -XX: condition -NX: negative of condition XX - -@end smallexample -@center @code{*}---see full description below - -@table @code -@item jbsr -@itemx jra -These are the simplest jump pseudo-operations; they always map to one -particular machine instruction, depending on the displacement to the -branch target. - -@item j@var{XX} -Here, @samp{j@var{XX}} stands for an entire family of pseudo-operations, -where @var{XX} is a conditional branch or condition-code test. The full -list of pseudo-ops in this family is: -@smallexample - jhi jls jcc jcs jne jeq jvc - jvs jpl jmi jge jlt jgt jle -@end smallexample - -For the cases of non-PC relative displacements and long displacements on -the 68000 or 68010, @code{_AS__} will issue a longer code fragment in terms of -@var{NX}, the opposite condition to @var{XX}: -@smallexample - j@var{XX} foo -@end smallexample -gives -@smallexample - b@var{NX}s oof - jmp foo - oof: -@end smallexample - -@item db@var{XX} -The full family of pseudo-operations covered here is -@smallexample - dbhi dbls dbcc dbcs dbne dbeq dbvc - dbvs dbpl dbmi dbge dblt dbgt dble - dbf dbra dbt -@end smallexample - -Other than for word and byte displacements, when the source reads -@samp{db@var{XX} foo}, @code{_AS__} will emit -@smallexample - db@var{XX} oo1 - bra oo2 - oo1:jmpl foo - oo2: -@end smallexample - -@item fj@var{XX} -This family includes -@smallexample - fjne fjeq fjge fjlt fjgt fjle fjf - fjt fjgl fjgle fjnge fjngl fjngle fjngt - fjnle fjnlt fjoge fjogl fjogt fjole fjolt - fjor fjseq fjsf fjsne fjst fjueq fjuge - fjugt fjule fjult fjun -@end smallexample - -For branch targets that are not PC relative, @code{_AS__} emits -@smallexample - fb@var{NX} oof - jmp foo - oof: -@end smallexample -when it encounters @samp{fj@var{XX} foo}. - -@end table - -@node M68K-Chars, , M68K-Branch, M68K-opcodes -_CHAPSEC__(2+_GENERIC__) Special Characters -The immediate character is @samp{#} for Sun compatibility. The -line-comment character is @samp{|}. If a @samp{#} appears at the -beginning of a line, it is treated as a comment unless it looks like -@samp{# line file}, in which case it is treated normally. - -_fi__(_M680X0__) -_if__(0) -@c pesch@cygnus.com: conditionalize on something other than 0 when filled in. -@section 32x32 -@section Options -The 32x32 version of @code{_AS__} accepts a @kbd{-m32032} option to -specify thiat it is compiling for a 32032 processor, or a -@kbd{-m32532} to specify that it is compiling for a 32532 option. -The default (if neither is specified) is chosen when the assembler -is compiled. - -@subsection Syntax -I don't know anything about the 32x32 syntax assembled by -@code{_AS__}. Someone who undersands the processor (I've never seen -one) and the possible syntaxes should write this section. - -@subsection Floating Point -The 32x32 uses IEEE floating point numbers, but @code{_AS__} will only -create single or double precision values. I don't know if the 32x32 -understands extended precision numbers. - -@subsection 32x32 Machine Directives -The 32x32 has no machine dependent directives. - -_fi__(0) -@c @group -_if__(_SPARC__) -_if__(_GENERIC__) -_if__(_I80386__&&_M680X0__) -@node Sparc-Dependent, i386-Dependent, M68K-Dependent, Machine Dependent -_fi__(_I80386__&&_M680X0__) -_if__(_I80386__&&_I960__&&!_M680X0__) -@node Sparc-Dependent, i386-Dependent, i960-Dependent, Machine Dependent -_fi__(_I80386__&&_I960__&&!_M680X0__) -_if__(_I80386__&&_AMD29K__&&(!_I960__)&&!_M680X0__) -@node Sparc-Dependent, i386-Dependent, AMD29K-Dependent, Machine Dependent -_fi__(_I80386__&&_AMD29K__&&(!_I960__)&&!_M680X0__) -_if__(_I80386__&&_VAX__&&(!_AMD29K__)&&(!_I960__)&&!_M680X0__) -@node Sparc-Dependent, i386-Dependent, Vax-Dependent, Machine Dependent -_fi__(_I80386__&&_VAX__&&(!_AMD29K__)&&(!_I960__)&&!_M680X0__) -_if__(_I80386__&&(!_VAX__)&&(!_AMD29K__)&&(!_I960__)&&!_M680X0__) -@node Sparc-Dependent, i386-Dependent, Machine Dependent, Machine Dependent -_fi__(_I80386__&&(!_VAX__)&&(!_AMD29K__)&&(!_I960__)&&!_M680X0__) -_if__((!_I80386__)&&_M680X0__) -@node Sparc-Dependent, , M68K-Dependent, Machine Dependent -_fi__((!_I80386__)&&_M680X0__) -_if__((!_I80386__)&&_I960__&&!_M680X0__) -@node Sparc-Dependent, , i960-Dependent, Machine Dependent -_fi__((!_I80386__)&&_I960__&&!_M680X0__) -_if__((!_I80386__)&&_AMD29K__&&(!_I960__)&&!_M680X0__) -@node Sparc-Dependent, , AMD29K-Dependent, Machine Dependent -_fi__((!_I80386__)&&_AMD29K__&&(!_I960__)&&!_M680X0__) -_if__((!_I80386__)&&_VAX__&&(!_AMD29K__)&&(!_I960__)&&!_M680X0__) -@node Sparc-Dependent, , Vax-Dependent, Machine Dependent -_fi__((!_I80386__)&&_VAX__&&(!_AMD29K__)&&(!_I960__)&&!_M680X0__) -_if__((!_I80386__)&&(!_VAX__)&&(!_AMD29K__)&&(!_I960__)&&!_M680X0__) -@node Sparc-Dependent, , Machine Dependent, Machine Dependent -_fi__((!_I80386__)&&(!_VAX__)&&(!_AMD29K__)&&(!_I960__)&&!_M680X0__) -_fi__(_GENERIC__) -_CHAPSEC__(0+_GENERIC__) SPARC Dependent Features -@menu -* Sparc-Opts:: Options -* Sparc-Float:: Floating Point -* Sparc-Directives:: Sparc Machine Directives -@end menu - -@node Sparc-Opts, Sparc-Float, Sparc-Dependent, Sparc-Dependent -_CHAPSEC__(1+_GENERIC__) Options -The Sparc has no machine dependent options. -@c @end group - -@ignore -@c FIXME: (sparc) Fill in "syntax" section! -@c subsection syntax -I don't know anything about Sparc syntax. Someone who does -will have to write this section. -@end ignore - -@node Sparc-Float, Sparc-Directives, Sparc-Opts, Sparc-Dependent -_CHAPSEC__(1+_GENERIC__) Floating Point -The Sparc uses @sc{ieee} floating-point numbers. - -@node Sparc-Directives, , Sparc-Float, Sparc-Dependent -_CHAPSEC__(1+_GENERIC__) Sparc Machine Directives -The Sparc version of @code{_AS__} supports the following additional -machine directives: - -@table @code -@item .common -This must be followed by a symbol name, a positive number, and -@code{"bss"}. This behaves somewhat like @code{.comm}, but the -syntax is different. - -@item .global -This is functionally identical to @code{.globl}. -@c FIXME: is this still really SPARC specific? (vintage/devo) - -@item .half -This is functionally identical to @code{.short}. - -@item .proc -This directive is ignored. Any text following it on the same -line is also ignored. - -@item .reserve -This must be followed by a symbol name, a positive number, and -@code{"bss"}. This behaves somewhat like @code{.lcomm}, but the -syntax is different. - -@item .seg -This must be followed by @code{"text"}, @code{"data"}, or -@code{"data1"}. It behaves like @code{.text}, @code{.data}, or -@code{.data 1}. - -@item .skip -This is functionally identical to the @code{.space} directive. - -@item .word -On the Sparc, the .word directive produces 32 bit values, -instead of the 16 bit values it produces on manyother machines. - -@end table - -_fi__(_SPARC__) -_if__(_I80386__) -_if__(_GENERIC__) -@c FIXME! Conditionalize for all combinations in this section -@node i386-Dependent, , Sparc-Dependent, Machine Dependent -_fi__(_GENERIC__) -_CHAPSEC__(0+_GENERIC__) 80386 Dependent Features - -@menu -* i386-Options:: Options -* i386-Syntax:: AT&T Syntax versus Intel Syntax -* i386-Opcodes:: Opcode Naming -* i386-Regs:: Register Naming -* i386-prefixes:: Opcode Prefixes -* i386-Memory:: Memory References -* i386-jumps:: Handling of Jump Instructions -* i386-Float:: Floating Point -* i386-Notes:: Notes -@end menu - -@node i386-Options, i386-Syntax, i386-Dependent, i386-Dependent -_CHAPSEC__(1+_GENERIC__) Options -The 80386 has no machine dependent options. - -@node i386-Syntax, i386-Opcodes, i386-Options, i386-Dependent -_CHAPSEC__(1+_GENERIC__) AT&T Syntax versus Intel Syntax -In order to maintain compatibility with the output of @code{_GCC__}, -@code{_AS__} supports AT&T System V/386 assembler syntax. This is quite -different from Intel syntax. We mention these differences because -almost all 80386 documents used only Intel syntax. Notable differences -between the two syntaxes are: -@itemize @bullet -@item -AT&T immediate operands are preceded by @samp{$}; Intel immediate -operands are undelimited (Intel @samp{push 4} is AT&T @samp{pushl $4}). -AT&T register operands are preceded by @samp{%}; Intel register operands -are undelimited. AT&T absolute (as opposed to PC relative) jump/call -operands are prefixed by @samp{*}; they are undelimited in Intel syntax. - -@item -AT&T and Intel syntax use the opposite order for source and destination -operands. Intel @samp{add eax, 4} is @samp{addl $4, %eax}. The -@samp{source, dest} convention is maintained for compatibility with -previous Unix assemblers. - -@item -In AT&T syntax the size of memory operands is determined from the last -character of the opcode name. Opcode suffixes of @samp{b}, @samp{w}, -and @samp{l} specify byte (8-bit), word (16-bit), and long (32-bit) -memory references. Intel syntax accomplishes this by prefixes memory -operands (@emph{not} the opcodes themselves) with @samp{byte ptr}, -@samp{word ptr}, and @samp{dword ptr}. Thus, Intel @samp{mov al, byte -ptr @var{foo}} is @samp{movb @var{foo}, %al} in AT&T syntax. - -@item -Immediate form long jumps and calls are -@samp{lcall/ljmp $@var{segment}, $@var{offset}} in AT&T syntax; the -Intel syntax is -@samp{call/jmp far @var{segment}:@var{offset}}. Also, the far return -instruction -is @samp{lret $@var{stack-adjust}} in AT&T syntax; Intel syntax is -@samp{ret far @var{stack-adjust}}. - -@item -The AT&T assembler does not provide support for multiple segment -programs. Unix style systems expect all programs to be single segments. -@end itemize - -@node i386-Opcodes, i386-Regs, i386-Syntax, i386-Dependent -_CHAPSEC__(1+_GENERIC__) Opcode Naming -Opcode names are suffixed with one character modifiers which specify the -size of operands. The letters @samp{b}, @samp{w}, and @samp{l} specify -byte, word, and long operands. If no suffix is specified by an -instruction and it contains no memory operands then @code{_AS__} tries to -fill in the missing suffix based on the destination register operand -(the last one by convention). Thus, @samp{mov %ax, %bx} is equivalent -to @samp{movw %ax, %bx}; also, @samp{mov $1, %bx} is equivalent to -@samp{movw $1, %bx}. Note that this is incompatible with the AT&T Unix -assembler which assumes that a missing opcode suffix implies long -operand size. (This incompatibility does not affect compiler output -since compilers always explicitly specify the opcode suffix.) - -Almost all opcodes have the same names in AT&T and Intel format. There -are a few exceptions. The sign extend and zero extend instructions need -two sizes to specify them. They need a size to sign/zero extend -@emph{from} and a size to zero extend @emph{to}. This is accomplished -by using two opcode suffixes in AT&T syntax. Base names for sign extend -and zero extend are @samp{movs@dots{}} and @samp{movz@dots{}} in AT&T -syntax (@samp{movsx} and @samp{movzx} in Intel syntax). The opcode -suffixes are tacked on to this base name, the @emph{from} suffix before -the @emph{to} suffix. Thus, @samp{movsbl %al, %edx} is AT&T syntax for -``move sign extend @emph{from} %al @emph{to} %edx.'' Possible suffixes, -thus, are @samp{bl} (from byte to long), @samp{bw} (from byte to word), -and @samp{wl} (from word to long). - -The Intel syntax conversion instructions -@itemize @bullet -@item -@samp{cbw} --- sign-extend byte in @samp{%al} to word in @samp{%ax}, -@item -@samp{cwde} --- sign-extend word in @samp{%ax} to long in @samp{%eax}, -@item -@samp{cwd} --- sign-extend word in @samp{%ax} to long in @samp{%dx:%ax}, -@item -@samp{cdq} --- sign-extend dword in @samp{%eax} to quad in @samp{%edx:%eax}, -@end itemize -are called @samp{cbtw}, @samp{cwtl}, @samp{cwtd}, and @samp{cltd} in -AT&T naming. @code{_AS__} accepts either naming for these instructions. - -Far call/jump instructions are @samp{lcall} and @samp{ljmp} in -AT&T syntax, but are @samp{call far} and @samp{jump far} in Intel -convention. - -@node i386-Regs, i386-prefixes, i386-Opcodes, i386-Dependent -_CHAPSEC__(1+_GENERIC__) Register Naming -Register operands are always prefixes with @samp{%}. The 80386 registers -consist of -@itemize @bullet -@item -the 8 32-bit registers @samp{%eax} (the accumulator), @samp{%ebx}, -@samp{%ecx}, @samp{%edx}, @samp{%edi}, @samp{%esi}, @samp{%ebp} (the -frame pointer), and @samp{%esp} (the stack pointer). - -@item -the 8 16-bit low-ends of these: @samp{%ax}, @samp{%bx}, @samp{%cx}, -@samp{%dx}, @samp{%di}, @samp{%si}, @samp{%bp}, and @samp{%sp}. - -@item -the 8 8-bit registers: @samp{%ah}, @samp{%al}, @samp{%bh}, -@samp{%bl}, @samp{%ch}, @samp{%cl}, @samp{%dh}, and @samp{%dl} (These -are the high-bytes and low-bytes of @samp{%ax}, @samp{%bx}, -@samp{%cx}, and @samp{%dx}) - -@item -the 6 segment registers @samp{%cs} (code segment), @samp{%ds} -(data segment), @samp{%ss} (stack segment), @samp{%es}, @samp{%fs}, -and @samp{%gs}. - -@item -the 3 processor control registers @samp{%cr0}, @samp{%cr2}, and -@samp{%cr3}. - -@item -the 6 debug registers @samp{%db0}, @samp{%db1}, @samp{%db2}, -@samp{%db3}, @samp{%db6}, and @samp{%db7}. - -@item -the 2 test registers @samp{%tr6} and @samp{%tr7}. - -@item -the 8 floating point register stack @samp{%st} or equivalently -@samp{%st(0)}, @samp{%st(1)}, @samp{%st(2)}, @samp{%st(3)}, -@samp{%st(4)}, @samp{%st(5)}, @samp{%st(6)}, and @samp{%st(7)}. -@end itemize - -@node i386-prefixes, i386-Memory, i386-Regs, i386-Dependent -_CHAPSEC__(1+_GENERIC__) Opcode Prefixes -Opcode prefixes are used to modify the following opcode. They are used -to repeat string instructions, to provide segment overrides, to perform -bus lock operations, and to give operand and address size (16-bit -operands are specified in an instruction by prefixing what would -normally be 32-bit operands with a ``operand size'' opcode prefix). -Opcode prefixes are usually given as single-line instructions with no -operands, and must directly precede the instruction they act upon. For -example, the @samp{scas} (scan string) instruction is repeated with: -@smallexample - repne - scas -@end smallexample - -Here is a list of opcode prefixes: -@itemize @bullet -@item -Segment override prefixes @samp{cs}, @samp{ds}, @samp{ss}, @samp{es}, -@samp{fs}, @samp{gs}. These are automatically added by specifying -using the @var{segment}:@var{memory-operand} form for memory references. - -@item -Operand/Address size prefixes @samp{data16} and @samp{addr16} -change 32-bit operands/addresses into 16-bit operands/addresses. Note -that 16-bit addressing modes (i.e. 8086 and 80286 addressing modes) -are not supported (yet). - -@item -The bus lock prefix @samp{lock} inhibits interrupts during -execution of the instruction it precedes. (This is only valid with -certain instructions; see a 80386 manual for details). - -@item -The wait for coprocessor prefix @samp{wait} waits for the -coprocessor to complete the current instruction. This should never be -needed for the 80386/80387 combination. - -@item -The @samp{rep}, @samp{repe}, and @samp{repne} prefixes are added -to string instructions to make them repeat @samp{%ecx} times. -@end itemize - -@node i386-Memory, i386-jumps, i386-prefixes, i386-Dependent -_CHAPSEC__(1+_GENERIC__) Memory References -An Intel syntax indirect memory reference of the form -@smallexample -@var{segment}:[@var{base} + @var{index}*@var{scale} + @var{disp}] -@end smallexample -is translated into the AT&T syntax -@smallexample -@var{segment}:@var{disp}(@var{base}, @var{index}, @var{scale}) -@end smallexample -where @var{base} and @var{index} are the optional 32-bit base and -index registers, @var{disp} is the optional displacement, and -@var{scale}, taking the values 1, 2, 4, and 8, multiplies @var{index} -to calculate the address of the operand. If no @var{scale} is -specified, @var{scale} is taken to be 1. @var{segment} specifies the -optional segment register for the memory operand, and may override the -default segment register (see a 80386 manual for segment register -defaults). Note that segment overrides in AT&T syntax @emph{must} have -be preceded by a @samp{%}. If you specify a segment override which -coincides with the default segment register, @code{_AS__} will @emph{not} -output any segment register override prefixes to assemble the given -instruction. Thus, segment overrides can be specified to emphasize which -segment register is used for a given memory operand. - -Here are some examples of Intel and AT&T style memory references: -@table @asis - -@item AT&T: @samp{-4(%ebp)}, Intel: @samp{[ebp - 4]} -@var{base} is @samp{%ebp}; @var{disp} is @samp{-4}. @var{segment} is -missing, and the default segment is used (@samp{%ss} for addressing with -@samp{%ebp} as the base register). @var{index}, @var{scale} are both missing. - -@item AT&T: @samp{foo(,%eax,4)}, Intel: @samp{[foo + eax*4]} -@var{index} is @samp{%eax} (scaled by a @var{scale} 4); @var{disp} is -@samp{foo}. All other fields are missing. The segment register here -defaults to @samp{%ds}. - -@item AT&T: @samp{foo(,1)}; Intel @samp{[foo]} -This uses the value pointed to by @samp{foo} as a memory operand. -Note that @var{base} and @var{index} are both missing, but there is only -@emph{one} @samp{,}. This is a syntactic exception. - -@item AT&T: @samp{%gs:foo}; Intel @samp{gs:foo} -This selects the contents of the variable @samp{foo} with segment -register @var{segment} being @samp{%gs}. - -@end table - -Absolute (as opposed to PC relative) call and jump operands must be -prefixed with @samp{*}. If no @samp{*} is specified, @code{_AS__} will -always choose PC relative addressing for jump/call labels. - -Any instruction that has a memory operand @emph{must} specify its size (byte, -word, or long) with an opcode suffix (@samp{b}, @samp{w}, or @samp{l}, -respectively). - -@node i386-jumps, i386-Float, i386-Memory, i386-Dependent -_CHAPSEC__(1+_GENERIC__) Handling of Jump Instructions -Jump instructions are always optimized to use the smallest possible -displacements. This is accomplished by using byte (8-bit) displacement -jumps whenever the target is sufficiently close. If a byte displacement -is insufficient a long (32-bit) displacement is used. We do not support -word (16-bit) displacement jumps (i.e. prefixing the jump instruction -with the @samp{addr16} opcode prefix), since the 80386 insists upon masking -@samp{%eip} to 16 bits after the word displacement is added. - -Note that the @samp{jcxz}, @samp{jecxz}, @samp{loop}, @samp{loopz}, -@samp{loope}, @samp{loopnz} and @samp{loopne} instructions only come in -byte displacements, so that it is possible that use of these -instructions (@code{_GCC__} does not use them) will cause the assembler to -print an error message (and generate incorrect code). The AT&T 80386 -assembler tries to get around this problem by expanding @samp{jcxz foo} to -@smallexample - jcxz cx_zero - jmp cx_nonzero -cx_zero: jmp foo -cx_nonzero: -@end smallexample - -@node i386-Float, i386-Notes, i386-jumps, i386-Dependent -_CHAPSEC__(1+_GENERIC__) Floating Point -All 80387 floating point types except packed BCD are supported. -(BCD support may be added without much difficulty). These data -types are 16-, 32-, and 64- bit integers, and single (32-bit), -double (64-bit), and extended (80-bit) precision floating point. -Each supported type has an opcode suffix and a constructor -associated with it. Opcode suffixes specify operand's data -types. Constructors build these data types into memory. - -@itemize @bullet -@item -Floating point constructors are @samp{.float} or @samp{.single}, -@samp{.double}, and @samp{.tfloat} for 32-, 64-, and 80-bit formats. -These correspond to opcode suffixes @samp{s}, @samp{l}, and @samp{t}. -@samp{t} stands for temporary real, and that the 80387 only supports -this format via the @samp{fldt} (load temporary real to stack top) and -@samp{fstpt} (store temporary real and pop stack) instructions. - -@item -Integer constructors are @samp{.word}, @samp{.long} or @samp{.int}, and -@samp{.quad} for the 16-, 32-, and 64-bit integer formats. The corresponding -opcode suffixes are @samp{s} (single), @samp{l} (long), and @samp{q} -(quad). As with the temporary real format the 64-bit @samp{q} format is -only present in the @samp{fildq} (load quad integer to stack top) and -@samp{fistpq} (store quad integer and pop stack) instructions. -@end itemize - -Register to register operations do not require opcode suffixes, -so that @samp{fst %st, %st(1)} is equivalent to @samp{fstl %st, %st(1)}. - -Since the 80387 automatically synchronizes with the 80386 @samp{fwait} -instructions are almost never needed (this is not the case for the -80286/80287 and 8086/8087 combinations). Therefore, @code{_AS__} suppresses -the @samp{fwait} instruction whenever it is implicitly selected by one -of the @samp{fn@dots{}} instructions. For example, @samp{fsave} and -@samp{fnsave} are treated identically. In general, all the @samp{fn@dots{}} -instructions are made equivalent to @samp{f@dots{}} instructions. If -@samp{fwait} is desired it must be explicitly coded. - -@node i386-Notes, , i386-Float, i386-Dependent -_CHAPSEC__(1+_GENERIC__) Notes -There is some trickery concerning the @samp{mul} and @samp{imul} -instructions that deserves mention. The 16-, 32-, and 64-bit expanding -multiplies (base opcode @samp{0xf6}; extension 4 for @samp{mul} and 5 -for @samp{imul}) can be output only in the one operand form. Thus, -@samp{imul %ebx, %eax} does @emph{not} select the expanding multiply; -the expanding multiply would clobber the @samp{%edx} register, and this -would confuse @code{_GCC__} output. Use @samp{imul %ebx} to get the -64-bit product in @samp{%edx:%eax}. - -We have added a two operand form of @samp{imul} when the first operand -is an immediate mode expression and the second operand is a register. -This is just a shorthand, so that, multiplying @samp{%eax} by 69, for -example, can be done with @samp{imul $69, %eax} rather than @samp{imul -$69, %eax, %eax}. - -_fi__(_I80386__) -_if__(0) -@c pesch@cygnus.com: we ignore the following chapters, since internals are -@c changing rapidly. These may need to be moved to another -@c book anyhow, if we adopt the model of user/modifier -@c books. -@node Maintenance, Retargeting, _MACH_DEP__, Top -@chapter Maintaining the Assembler -[[this chapter is still being built]] - -@section Design -We had these goals, in descending priority: -@table @b -@item Accuracy. -For every program composed by a compiler, @code{_AS__} should emit -``correct'' code. This leaves some latitude in choosing addressing -modes, order of @code{relocation_info} structures in the object -file, @emph{etc}. - -@item Speed, for usual case. -By far the most common use of @code{_AS__} will be assembling compiler -emissions. - -@item Upward compatibility for existing assembler code. -Well @dots{} we don't support Vax bit fields but everything else -seems to be upward compatible. - -@item Readability. -The code should be maintainable with few surprises. (JF: ha!) - -@end table - -We assumed that disk I/O was slow and expensive while memory was -fast and access to memory was cheap. We expect the in-memory data -structures to be less than 10 times the size of the emitted object -file. (Contrast this with the C compiler where in-memory structures -might be 100 times object file size!) -This suggests: -@itemize @bullet -@item -Try to read the source file from disk only one time. For other -reasons, we keep large chunks of the source file in memory during -assembly so this is not a problem. Also the assembly algorithm -should only scan the source text once if the compiler composed the -text according to a few simple rules. -@item -Emit the object code bytes only once. Don't store values and then -backpatch later. -@item -Build the object file in memory and do direct writes to disk of -large buffers. -@end itemize - -RMS suggested a one-pass algorithm which seems to work well. By not -parsing text during a second pass considerable time is saved on -large programs (@emph{e.g.} the sort of C program @code{yacc} would -emit). - -It happened that the data structures needed to emit relocation -information to the object file were neatly subsumed into the data -structures that do backpatching of addresses after pass 1. - -Many of the functions began life as re-usable modules, loosely -connected. RMS changed this to gain speed. For example, input -parsing routines which used to work on pre-sanitized strings now -must parse raw data. Hence they have to import knowledge of the -assemblers' comment conventions @emph{etc}. - -@section Deprecated Feature(?)s -We have stopped supporting some features: -@itemize @bullet -@item -@code{.org} statements must have @b{defined} expressions. -@item -Vax Bit fields (@kbd{:} operator) are entirely unsupported. -@end itemize - -It might be a good idea to not support these features in a future release: -@itemize @bullet -@item -@kbd{#} should begin a comment, even in column 1. -@item -Why support the logical line & file concept any more? -@item -Subsegments are a good candidate for flushing. -Depends on which compilers need them I guess. -@end itemize - -@section Bugs, Ideas, Further Work -Clearly the major improvement is DON'T USE A TEXT-READING -ASSEMBLER for the back end of a compiler. It is much faster to -interpret binary gobbledygook from a compiler's tables than to -ask the compiler to write out human-readable code just so the -assembler can parse it back to binary. - -Assuming you use @code{_AS__} for human written programs: here are -some ideas: -@itemize @bullet -@item -Document (here) @code{APP}. -@item -Take advantage of knowing no spaces except after opcode -to speed up @code{_AS__}. (Modify @code{app.c} to flush useless spaces: -only keep space/tabs at begin of line or between 2 -symbols.) -@item -Put pointers in this documentation to @file{a.out} documentation. -@item -Split the assembler into parts so it can gobble direct binary -from @emph{e.g.} @code{cc}. It is silly for@code{cc} to compose text -just so @code{_AS__} can parse it back to binary. -@item -Rewrite hash functions: I want a more modular, faster library. -@item -Clean up LOTS of code. -@item -Include all the non-@file{.c} files in the maintenance chapter. -@item -Document flonums. -@item -Implement flonum short literals. -@item -Change all talk of expression operands to expression quantities, -or perhaps to expression arguments. -@item -Implement pass 2. -@item -Whenever a @code{.text} or @code{.data} statement is seen, we close -of the current frag with an imaginary @code{.fill 0}. This is -because we only have one obstack for frags, and we can't grow new -frags for a new subsegment, then go back to the old subsegment and -append bytes to the old frag. All this nonsense goes away if we -give each subsegment its own obstack. It makes code simpler in -about 10 places, but nobody has bothered to do it because C compiler -output rarely changes subsegments (compared to ending frags with -relaxable addresses, which is common). -@end itemize - -@section Sources -@c The following files in the @file{_AS__} directory -@c are symbolic links to other files, of -@c the same name, in a different directory. -@c @itemize @bullet -@c @item -@c @file{atof_generic.c} -@c @item -@c @file{atof_vax.c} -@c @item -@c @file{flonum_const.c} -@c @item -@c @file{flonum_copy.c} -@c @item -@c @file{flonum_get.c} -@c @item -@c @file{flonum_multip.c} -@c @item -@c @file{flonum_normal.c} -@c @item -@c @file{flonum_print.c} -@c @end itemize - -Here is a list of the source files in the @file{_AS__} directory. - -@table @file -@item app.c -This contains the pre-processing phase, which deletes comments, -handles whitespace, etc. This was recently re-written, since app -used to be a separate program, but RMS wanted it to be inline. - -@item append.c -This is a subroutine to append a string to another string returning a -pointer just after the last @code{char} appended. (JF: All these -little routines should probably all be put in one file.) - -@item as.c -Here you will find the main program of the assembler @code{_AS__}. - -@item expr.c -This is a branch office of @file{read.c}. This understands -expressions, arguments. Inside @code{_AS__}, arguments are called -(expression) @emph{operands}. This is confusing, because we also talk -(elsewhere) about instruction @emph{operands}. Also, expression -operands are called @emph{quantities} explicitly to avoid confusion -with instruction operands. What a mess. - -@item frags.c -This implements the @b{frag} concept. Without frags, finding the -right size for branch instructions would be a lot harder. - -@item hash.c -This contains the symbol table, opcode table @emph{etc.} hashing -functions. - -@item hex_value.c -This is a table of values of digits, for use in atoi() type -functions. Could probably be flushed by using calls to strtol(), or -something similar. - -@item input-file.c -This contains Operating system dependent source file reading -routines. Since error messages often say where we are in reading -the source file, they live here too. Since @code{_AS__} is intended to -run under GNU and Unix only, this might be worth flushing. Anyway, -almost all C compilers support stdio. - -@item input-scrub.c -This deals with calling the pre-processor (if needed) and feeding the -chunks back to the rest of the assembler the right way. - -@item messages.c -This contains operating system independent parts of fatal and -warning message reporting. See @file{append.c} above. - -@item output-file.c -This contains operating system dependent functions that write an -object file for @code{_AS__}. See @file{input-file.c} above. - -@item read.c -This implements all the directives of @code{_AS__}. This also deals -with passing input lines to the machine dependent part of the -assembler. - -@item strstr.c -This is a C library function that isn't in most C libraries yet. -See @file{append.c} above. - -@item subsegs.c -This implements subsegments. - -@item symbols.c -This implements symbols. - -@item write.c -This contains the code to perform relaxation, and to write out -the object file. It is mostly operating system independent, but -different OSes have different object file formats in any case. - -@item xmalloc.c -This implements @code{malloc()} or bust. See @file{append.c} above. - -@item xrealloc.c -This implements @code{realloc()} or bust. See @file{append.c} above. - -@item atof-generic.c -The following files were taken from a machine-independent subroutine -library for manipulating floating point numbers and very large -integers. - -@file{atof-generic.c} turns a string into a flonum internal format -floating-point number. - -@item flonum-const.c -This contains some potentially useful floating point numbers in -flonum format. - -@item flonum-copy.c -This copies a flonum. - -@item flonum-multip.c -This multiplies two flonums together. - -@item bignum-copy.c -This copies a bignum. - -@end table - -Here is a table of all the machine-specific files (this includes -both source and header files). Typically, there is a -@var{machine}.c file, a @var{machine}-opcode.h file, and an -atof-@var{machine}.c file. The @var{machine}-opcode.h file should -be identical to the one used by GDB (which uses it for disassembly.) - -@table @file - -@item atof-ieee.c -This contains code to turn a flonum into a ieee literal constant. -This is used by tye 680x0, 32x32, sparc, and i386 versions of @code{_AS__}. - -@item i386-opcode.h -This is the opcode-table for the i386 version of the assembler. - -@item i386.c -This contains all the code for the i386 version of the assembler. - -@item i386.h -This defines constants and macros used by the i386 version of the assembler. - -@item m-generic.h -generic 68020 header file. To be linked to m68k.h on a -non-sun3, non-hpux system. - -@item m-sun2.h -68010 header file for Sun2 workstations. Not well tested. To be linked -to m68k.h on a sun2. (See also @samp{-DSUN_ASM_SYNTAX} in the -@file{Makefile}.) - -@item m-sun3.h -68020 header file for Sun3 workstations. To be linked to m68k.h before -compiling on a Sun3 system. (See also @samp{-DSUN_ASM_SYNTAX} in the -@file{Makefile}.) - -@item m-hpux.h -68020 header file for a HPUX (system 5?) box. Which box, which -version of HPUX, etc? I don't know. - -@item m68k.h -A hard- or symbolic- link to one of @file{m-generic.h}, -@file{m-hpux.h} or @file{m-sun3.h} depending on which kind of -680x0 you are assembling for. (See also @samp{-DSUN_ASM_SYNTAX} in the -@file{Makefile}.) - -@item m68k-opcode.h -Opcode table for 68020. This is now a link to the opcode table -in the @code{GDB} source directory. - -@item m68k.c -All the mc680x0 code, in one huge, slow-to-compile file. - -@item ns32k.c -This contains the code for the ns32032/ns32532 version of the -assembler. - -@item ns32k-opcode.h -This contains the opcode table for the ns32032/ns32532 version -of the assembler. - -@item vax-inst.h -Vax specific file for describing Vax operands and other Vax-ish things. - -@item vax-opcode.h -Vax opcode table. - -@item vax.c -Vax specific parts of @code{_AS__}. Also includes the former files -@file{vax-ins-parse.c}, @file{vax-reg-parse.c} and @file{vip-op.c}. - -@item atof-vax.c -Turns a flonum into a Vax constant. - -@item vms.c -This file contains the special code needed to put out a VMS -style object file for the Vax. - -@end table - -Here is a list of the header files in the source directory. -(Warning: This section may not be very accurate. I didn't -write the header files; I just report them.) Also note that I -think many of these header files could be cleaned up or -eliminated. - -@table @file - -@item a.out.h -This describes the structures used to create the binary header data -inside the object file. Perhaps we should use the one in -@file{/usr/include}? - -@item as.h -This defines all the globally useful things, and pulls in _0___1__ -and _0___1__. - -@item bignum.h -This defines macros useful for dealing with bignums. - -@item expr.h -Structure and macros for dealing with expression() - -@item flonum.h -This defines the structure for dealing with floating point -numbers. It #includes @file{bignum.h}. - -@item frags.h -This contains macro for appending a byte to the current frag. - -@item hash.h -Structures and function definitions for the hashing functions. - -@item input-file.h -Function headers for the input-file.c functions. - -@item md.h -structures and function headers for things defined in the -machine dependent part of the assembler. - -@item obstack.h -This is the GNU systemwide include file for manipulating obstacks. -Since nobody is running under real GNU yet, we include this file. - -@item read.h -Macros and function headers for reading in source files. - -@item struct-symbol.h -Structure definition and macros for dealing with the _AS__ -internal form of a symbol. - -@item subsegs.h -structure definition for dealing with the numbered subsegments -of the text and data segments. - -@item symbols.h -Macros and function headers for dealing with symbols. - -@item write.h -Structure for doing segment fixups. -@end table - -@comment ~subsection Test Directory -@comment (Note: The test directory seems to have disappeared somewhere -@comment along the line. If you want it, you'll probably have to find a -@comment REALLY OLD dump tape~dots{}) -@comment -@comment The ~file{test/} directory is used for regression testing. -@comment After you modify ~@code{_AS__}, you can get a quick go/nogo -@comment confidence test by running the new ~@code{_AS__} over the source -@comment files in this directory. You use a shell script ~file{test/do}. -@comment -@comment The tests in this suite are evolving. They are not comprehensive. -@comment They have, however, caught hundreds of bugs early in the debugging -@comment cycle of ~@code{_AS__}. Most test statements in this suite were naturally -@comment selected: they were used to demonstrate actual ~@code{_AS__} bugs rather -@comment than being written ~i{a prioi}. -@comment -@comment Another testing suggestion: over 30 bugs have been found simply by -@comment running examples from this manual through ~@code{_AS__}. -@comment Some examples in this manual are selected -@comment to distinguish boundary conditions; they are good for testing ~@code{_AS__}. -@comment -@comment ~subsubsection Regression Testing -@comment Each regression test involves assembling a file and comparing the -@comment actual output of ~@code{_AS__} to ``known good'' output files. Both -@comment the object file and the error/warning message file (stderr) are -@comment inspected. Optionally the ~@code{_AS__} exit status may be checked. -@comment Discrepencies are reported. Each discrepency means either that -@comment you broke some part of ~@code{_AS__} or that the ``known good'' files -@comment are now out of date and should be changed to reflect the new -@comment definition of ``good''. -@comment -@comment Each regression test lives in its own directory, in a tree -@comment rooted in the directory ~file{test/}. Each such directory -@comment has a name ending in ~file{.ret}, where `ret' stands for -@comment REgression Test. The ~file{.ret} ending allows ~code{find -@comment (1)} to find all regression tests in the tree, without -@comment needing to list them explicitly. -@comment -@comment Any ~file{.ret} directory must contain a file called -@comment ~file{input} which is the source file to assemble. During -@comment testing an object file ~file{output} is created, as well as -@comment a file ~file{stdouterr} which contains the output to both -@comment stderr and stderr. If there is a file ~file{output.good} in -@comment the directory, and if ~file{output} contains exactly the -@comment same data as ~file{output.good}, the file ~file{output} is -@comment deleted. Likewise ~file{stdouterr} is removed if it exactly -@comment matches a file ~file{stdouterr.good}. If file -@comment ~file{status.good} is present, containing a decimal number -@comment before a newline, the exit status of ~@code{_AS__} is compared -@comment to this number. If the status numbers are not equal, a file -@comment ~file{status} is written to the directory, containing the -@comment actual status as a decimal number followed by newline. -@comment -@comment Should any of the ~file{*.good} files fail to match their corresponding -@comment actual files, this is noted by a 1-line message on the screen during -@comment the regression test, and you can use ~@code{find (1)} to find any -@comment files named ~file{status}, ~file {output} or ~file{stdouterr}. -@comment -@node Retargeting, License, Maintenance, Top -@chapter Teaching the Assembler about a New Machine - -This chapter describes the steps required in order to make the -assembler work with another machine's assembly language. This -chapter is not complete, and only describes the steps in the -broadest terms. You should look at the source for the -currently supported machine in order to discover some of the -details that aren't mentioned here. - -You should create a new file called @file{@var{machine}.c}, and -add the appropriate lines to the file @file{Makefile} so that -you can compile your new version of the assembler. This should -be straighforward; simply add lines similar to the ones there -for the four current versions of the assembler. - -If you want to be compatible with GDB, (and the current -machine-dependent versions of the assembler), you should create -a file called @file{@var{machine}-opcode.h} which should -contain all the information about the names of the machine -instructions, their opcodes, and what addressing modes they -support. If you do this right, the assembler and GDB can share -this file, and you'll only have to write it once. Note that -while you're writing @code{_AS__}, you may want to use an -independent program (if you have access to one), to make sure -that @code{_AS__} is emitting the correct bytes. Since @code{_AS__} -and @code{GDB} share the opcode table, an incorrect opcode -table entry may make invalid bytes look OK when you disassemble -them with @code{GDB}. - -@section Functions You will Have to Write - -Your file @file{@var{machine}.c} should contain definitions for -the following functions and variables. It will need to include -some header files in order to use some of the structures -defined in the machine-independent part of the assembler. The -needed header files are mentioned in the descriptions of the -functions that will need them. - -@table @code - -@item long omagic; -This long integer holds the value to place at the beginning of -the @file{a.out} file. It is usually @samp{OMAGIC}, except on -machines that store additional information in the magic-number. - -@item char comment_chars[]; -This character array holds the values of the characters that -start a comment anywhere in a line. Comments are stripped off -automatically by the machine independent part of the -assembler. Note that the @samp{/*} will always start a -comment, and that only @samp{*/} will end a comment started by -@samp{*/}. - -@item char line_comment_chars[]; -This character array holds the values of the chars that start a -comment only if they are the first (non-whitespace) character -on a line. If the character @samp{#} does not appear in this -list, you may get unexpected results. (Various -machine-independent parts of the assembler treat the comments -@samp{#APP} and @samp{#NO_APP} specially, and assume that lines -that start with @samp{#} are comments.) - -@item char EXP_CHARS[]; -This character array holds the letters that can separate the -mantissa and the exponent of a floating point number. Typical -values are @samp{e} and @samp{E}. - -@item char FLT_CHARS[]; -This character array holds the letters that--when they appear -immediately after a leading zero--indicate that a number is a -floating-point number. (Sort of how 0x indicates that a -hexadecimal number follows.) - -@item pseudo_typeS md_pseudo_table[]; -(@var{pseudo_typeS} is defined in @file{md.h}) -This array contains a list of the machine_dependent directives -the assembler must support. It contains the name of each -pseudo op (Without the leading @samp{.}), a pointer to a -function to be called when that directive is encountered, and -an integer argument to be passed to that function. - -@item void md_begin(void) -This function is called as part of the assembler's -initialization. It should do any initialization required by -any of your other routines. - -@item int md_parse_option(char **optionPTR, int *argcPTR, char ***argvPTR) -This routine is called once for each option on the command line -that the machine-independent part of @code{_AS__} does not -understand. This function should return non-zero if the option -pointed to by @var{optionPTR} is a valid option. If it is not -a valid option, this routine should return zero. The variables -@var{argcPTR} and @var{argvPTR} are provided in case the option -requires a filename or something similar as an argument. If -the option is multi-character, @var{optionPTR} should be -advanced past the end of the option, otherwise every letter in -the option will be treated as a separate single-character -option. - -@item void md_assemble(char *string) -This routine is called for every machine-dependent -non-directive line in the source file. It does all the real -work involved in reading the opcode, parsing the operands, -etc. @var{string} is a pointer to a null-terminated string, -that comprises the input line, with all excess whitespace and -comments removed. - -@item void md_number_to_chars(char *outputPTR,long value,int nbytes) -This routine is called to turn a C long int, short int, or char -into the series of bytes that represents that number on the -target machine. @var{outputPTR} points to an array where the -result should be stored; @var{value} is the value to store; and -@var{nbytes} is the number of bytes in 'value' that should be -stored. - -@item void md_number_to_imm(char *outputPTR,long value,int nbytes) -This routine is called to turn a C long int, short int, or char -into the series of bytes that represent an immediate value on -the target machine. It is identical to the function @code{md_number_to_chars}, -except on NS32K machines.@refill - -@item void md_number_to_disp(char *outputPTR,long value,int nbytes) -This routine is called to turn a C long int, short int, or char -into the series of bytes that represent an displacement value on -the target machine. It is identical to the function @code{md_number_to_chars}, -except on NS32K machines.@refill - -@item void md_number_to_field(char *outputPTR,long value,int nbytes) -This routine is identical to @code{md_number_to_chars}, -except on NS32K machines. - -@item void md_ri_to_chars(struct relocation_info *riPTR,ri) -(@code{struct relocation_info} is defined in @file{a.out.h}) -This routine emits the relocation info in @var{ri} -in the appropriate bit-pattern for the target machine. -The result should be stored in the location pointed -to by @var{riPTR}. This routine may be a no-op unless you are -attempting to do cross-assembly. - -@item char *md_atof(char type,char *outputPTR,int *sizePTR) -This routine turns a series of digits into the appropriate -internal representation for a floating-point number. -@var{type} is a character from @var{FLT_CHARS[]} that describes -what kind of floating point number is wanted; @var{outputPTR} -is a pointer to an array that the result should be stored in; -and @var{sizePTR} is a pointer to an integer where the size (in -bytes) of the result should be stored. This routine should -return an error message, or an empty string (not (char *)0) for -success. - -@item int md_short_jump_size; -This variable holds the (maximum) size in bytes of a short (16 -bit or so) jump created by @code{md_create_short_jump()}. This -variable is used as part of the broken-word feature, and isn't -needed if the assembler is compiled with -@samp{-DWORKING_DOT_WORD}. - -@item int md_long_jump_size; -This variable holds the (maximum) size in bytes of a long (32 -bit or so) jump created by @code{md_create_long_jump()}. This -variable is used as part of the broken-word feature, and isn't -needed if the assembler is compiled with -@samp{-DWORKING_DOT_WORD}. - -@item void md_create_short_jump(char *resultPTR,long from_addr, -@code{long to_addr,fragS *frag,symbolS *to_symbol)} -This function emits a jump from @var{from_addr} to @var{to_addr} in -the array of bytes pointed to by @var{resultPTR}. If this creates a -type of jump that must be relocated, this function should call -@code{fix_new()} with @var{frag} and @var{to_symbol}. The jump -emitted by this function may be smaller than @var{md_short_jump_size}, -but it must never create a larger one. -(If it creates a smaller jump, the extra bytes of memory will not be -used.) This function is used as part of the broken-word feature, -and isn't needed if the assembler is compiled with -@samp{-DWORKING_DOT_WORD}.@refill - -@item void md_create_long_jump(char *ptr,long from_addr, -@code{long to_addr,fragS *frag,symbolS *to_symbol)} -This function is similar to the previous function, -@code{md_create_short_jump()}, except that it creates a long -jump instead of a short one. This function is used as part of -the broken-word feature, and isn't needed if the assembler is -compiled with @samp{-DWORKING_DOT_WORD}. - -@item int md_estimate_size_before_relax(fragS *fragPTR,int segment_type) -This function does the initial setting up for relaxation. This -includes forcing references to still-undefined symbols to the -appropriate addressing modes. - -@item relax_typeS md_relax_table[]; -(relax_typeS is defined in md.h) -This array describes the various machine dependent states a -frag may be in before relaxation. You will need one group of -entries for each type of addressing mode you intend to relax. - -@item void md_convert_frag(fragS *fragPTR) -(@var{fragS} is defined in @file{as.h}) -This routine does the required cleanup after relaxation. -Relaxation has changed the type of the frag to a type that can -reach its destination. This function should adjust the opcode -of the frag to use the appropriate addressing mode. -@var{fragPTR} points to the frag to clean up. - -@item void md_end(void) -This function is called just before the assembler exits. It -need not free up memory unless the operating system doesn't do -it automatically on exit. (In which case you'll also have to -track down all the other places where the assembler allocates -space but never frees it.) - -@end table - -@section External Variables You will Need to Use - -You will need to refer to or change the following external variables -from within the machine-dependent part of the assembler. - -@table @code -@item extern char flagseen[]; -This array holds non-zero values in locations corresponding to -the options that were on the command line. Thus, if the -assembler was called with @samp{-W}, @var{flagseen['W']} would -be non-zero. - -@item extern fragS *frag_now; -This pointer points to the current frag--the frag that bytes -are currently being added to. If nothing else, you will need -to pass it as an argument to various machine-independent -functions. It is maintained automatically by the -frag-manipulating functions; you should never have to change it -yourself. - -@item extern LITTLENUM_TYPE generic_bignum[]; -(@var{LITTLENUM_TYPE} is defined in @file{bignum.h}. -This is where @dfn{bignums}--numbers larger than 32 bits--are -returned when they are encountered in an expression. You will -need to use this if you need to implement directives (or -anything else) that must deal with these large numbers. -@code{Bignums} are of @code{segT} @code{SEG_BIG} (defined in -@file{as.h}, and have a positive @code{X_add_number}. The -@code{X_add_number} of a @code{bignum} is the number of -@code{LITTLENUMS} in @var{generic_bignum} that the number takes -up. - -@item extern FLONUM_TYPE generic_floating_point_number; -(@var{FLONUM_TYPE} is defined in @file{flonum.h}. -The is where @dfn{flonums}--floating-point numbers within -expressions--are returned. @code{Flonums} are of @code{segT} -@code{SEG_BIG}, and have a negative @code{X_add_number}. -@code{Flonums} are returned in a generic format. You will have -to write a routine to turn this generic format into the -appropriate floating-point format for your machine. - -@item extern int need_pass_2; -If this variable is non-zero, the assembler has encountered an -expression that cannot be assembled in a single pass. Since -the second pass isn't implemented, this flag means that the -assembler is punting, and is only looking for additional syntax -errors. (Or something like that.) - -@item extern segT now_seg; -This variable holds the value of the segment the assembler is -currently assembling into. - -@end table - -@section External functions will you need - -You will find the following external functions useful (or -indispensable) when you're writing the machine-dependent part -of the assembler. - -@table @code - -@item char *frag_more(int bytes) -This function allocates @var{bytes} more bytes in the current -frag (or starts a new frag, if it can't expand the current frag -any more.) for you to store some object-file bytes in. It -returns a pointer to the bytes, ready for you to store data in. - -@item void fix_new(fragS *frag, int where, short size, symbolS *add_symbol, symbolS *sub_symbol, long offset, int pcrel) -This function stores a relocation fixup to be acted on later. -@var{frag} points to the frag the relocation belongs in; -@var{where} is the location within the frag where the relocation begins; -@var{size} is the size of the relocation, and is usually 1 (a single byte), - 2 (sixteen bits), or 4 (a longword). -The value @var{add_symbol} @minus{} @var{sub_symbol} + @var{offset}, is added to the byte(s) -at _0__@var{frag->literal[where]}_1__. If @var{pcrel} is non-zero, the address of the -location is subtracted from the result. A relocation entry is also added -to the @file{a.out} file. @var{add_symbol}, @var{sub_symbol}, and/or -@var{offset} may be NULL.@refill - -@item char *frag_var(relax_stateT type, int max_chars, int var, -@code{relax_substateT subtype, symbolS *symbol, char *opcode)} -This function creates a machine-dependent frag of type @var{type} -(usually @code{rs_machine_dependent}). -@var{max_chars} is the maximum size in bytes that the frag may grow by; -@var{var} is the current size of the variable end of the frag; -@var{subtype} is the sub-type of the frag. The sub-type is used to index into -@var{md_relax_table[]} during @code{relaxation}. -@var{symbol} is the symbol whose value should be used to when relax-ing this frag. -@var{opcode} points into a byte whose value may have to be modified if the -addressing mode used by this frag changes. It typically points into the -@var{fr_literal[]} of the previous frag, and is used to point to a location -that @code{md_convert_frag()}, may have to change.@refill - -@item void frag_wane(fragS *fragPTR) -This function is useful from within @code{md_convert_frag}. It -changes a frag to type rs_fill, and sets the variable-sized -piece of the frag to zero. The frag will never change in size -again. - -@item segT expression(expressionS *retval) -(@var{segT} is defined in @file{as.h}; @var{expressionS} is defined in @file{expr.h}) -This function parses the string pointed to by the external char -pointer @var{input_line_pointer}, and returns the segment-type -of the expression. It also stores the results in the -@var{expressionS} pointed to by @var{retval}. -@var{input_line_pointer} is advanced to point past the end of -the expression. (@var{input_line_pointer} is used by other -parts of the assembler. If you modify it, be sure to restore -it to its original value.) - -@item as_warn(char *message,@dots{}) -If warning messages are disabled, this function does nothing. -Otherwise, it prints out the current file name, and the current -line number, then uses @code{fprintf} to print the -@var{message} and any arguments it was passed. - -@item as_bad(char *message,@dots{}) -This function should be called when @code{_AS__} encounters -conditions that are bad enough that @code{_AS__} should not -produce an object file, but should continue reading input and -printing warning and bad error messages. - -@item as_fatal(char *message,@dots{}) -This function prints out the current file name and line number, -prints the word @samp{FATAL:}, then uses @code{fprintf} to -print the @var{message} and any arguments it was passed. Then -the assembler exits. This function should only be used for -serious, unrecoverable errors. - -@item void float_const(int float_type) -This function reads floating-point constants from the current -input line, and calls @code{md_atof} to assemble them. It is -useful as the function to call for the directives -@samp{.single}, @samp{.double}, @samp{.float}, etc. -@var{float_type} must be a character from @var{FLT_CHARS}. - -@item void demand_empty_rest_of_line(void); -This function can be used by machine-dependent directives to -make sure the rest of the input line is empty. It prints a -warning message if there are additional characters on the line. - -@item long int get_absolute_expression(void) -This function can be used by machine-dependent directives to -read an absolute number from the current input line. It -returns the result. If it isn't given an absolute expression, -it prints a warning message and returns zero. - -@end table - - -@section The concept of Frags - -This assembler works to optimize the size of certain addressing -modes. (e.g. branch instructions) This means the size of many -pieces of object code cannot be determined until after assembly -is finished. (This means that the addresses of symbols cannot be -determined until assembly is finished.) In order to do this, -@code{_AS__} stores the output bytes as @dfn{frags}. - -Here is the definition of a frag (from @file{as.h}) -@smallexample -struct frag -@{ - long int fr_fix; - long int fr_var; - relax_stateT fr_type; - relax_substateT fr_substate; - unsigned long fr_address; - long int fr_offset; - struct symbol *fr_symbol; - char *fr_opcode; - struct frag *fr_next; - char fr_literal[]; -@} -@end smallexample - -@table @var -@item fr_fix -is the size of the fixed-size piece of the frag. - -@item fr_var -is the maximum (?) size of the variable-sized piece of the frag. - -@item fr_type -is the type of the frag. -Current types are: -rs_fill -rs_align -rs_org -rs_machine_dependent - -@item fr_substate -This stores the type of machine-dependent frag this is. (what -kind of addressing mode is being used, and what size is being -tried/will fit/etc. - -@item fr_address -@var{fr_address} is only valid after relaxation is finished. -Before relaxation, the only way to store an address is (pointer -to frag containing the address) plus (offset into the frag). - -@item fr_offset -This contains a number, whose meaning depends on the type of -the frag. -for machine_dependent frags, this contains the offset from -fr_symbol that the frag wants to go to. Thus, for branch -instructions it is usually zero. (unless the instruction was -@samp{jba foo+12} or something like that.) - -@item fr_symbol -for machine_dependent frags, this points to the symbol the frag -needs to reach. - -@item fr_opcode -This points to the location in the frag (or in a previous frag) -of the opcode for the instruction that caused this to be a frag. -@var{fr_opcode} is needed if the actual opcode must be changed -in order to use a different form of the addressing mode. -(For example, if a conditional branch only comes in size tiny, -a large-size branch could be implemented by reversing the sense -of the test, and turning it into a tiny branch over a large jump. -This would require changing the opcode.) - -@var{fr_literal} is a variable-size array that contains the -actual object bytes. A frag consists of a fixed size piece of -object data, (which may be zero bytes long), followed by a -piece of object data whose size may not have been determined -yet. Other information includes the type of the frag (which -controls how it is relaxed), - -@item fr_next -This is the next frag in the singly-linked list. This is -usually only needed by the machine-independent part of -@code{_AS__}. - -@end table -_fi__(0) - -@node License, , Machine Dependent, Top -@unnumbered GNU GENERAL PUBLIC LICENSE -@center Version 1, February 1989 - -@display -Copyright @copyright{} 1989 Free Software Foundation, Inc. -675 Mass Ave, Cambridge, MA 02139, USA - -Everyone is permitted to copy and distribute verbatim copies -of this license document, but changing it is not allowed. -@end display - -@unnumberedsec Preamble - - The license agreements of most software companies try to keep users -at the mercy of those companies. By contrast, our General Public -License is intended to guarantee your freedom to share and change free -software---to make sure the software is free for all its users. The -General Public License applies to the Free Software Foundation's -software and to any other program whose authors commit to using it. -You can use it for your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Specifically, the General Public License is designed to make -sure that you have the freedom to give away or sell copies of free -software, that you receive source code or can get it if you want it, -that you can change the software or use pieces of it in new free -programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of a such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must tell them their rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - The precise terms and conditions for copying, distribution and -modification follow. - -@iftex -@unnumberedsec TERMS AND CONDITIONS -@end iftex -@ifinfo -@center TERMS AND CONDITIONS -@end ifinfo - -@enumerate -@item -This License Agreement applies to any program or other work which -contains a notice placed by the copyright holder saying it may be -distributed under the terms of this General Public License. The -``Program'', below, refers to any such program or work, and a ``work based -on the Program'' means either the Program or any work containing the -Program or a portion of it, either verbatim or with modifications. Each -licensee is addressed as ``you''. - -@item -You may copy and distribute verbatim copies of the Program's source -code as you receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice and -disclaimer of warranty; keep intact all the notices that refer to this -General Public License and to the absence of any warranty; and give any -other recipients of the Program a copy of this General Public License -along with the Program. You may charge a fee for the physical act of -transferring a copy. - -@item -You may modify your copy or copies of the Program or any portion of -it, and copy and distribute such modifications under the terms of Paragraph -1 above, provided that you also do the following: - -@itemize @bullet -@item -cause the modified files to carry prominent notices stating that -you changed the files and the date of any change; and - -@item -cause the whole of any work that you distribute or publish, that -in whole or in part contains the Program or any part thereof, either -with or without modifications, to be licensed at no charge to all -third parties under the terms of this General Public License (except -that you may choose to grant warranty protection to some or all -third parties, at your option). - -@item -If the modified program normally reads commands interactively when -run, you must cause it, when started running for such interactive use -in the simplest and most usual way, to print or display an -announcement including an appropriate copyright notice and a notice -that there is no warranty (or else, saying that you provide a -warranty) and that users may redistribute the program under these -conditions, and telling the user how to view a copy of this General -Public License. - -@item -You may charge a fee for the physical act of transferring a -copy, and you may at your option offer warranty protection in -exchange for a fee. -@end itemize - -Mere aggregation of another independent work with the Program (or its -derivative) on a volume of a storage or distribution medium does not bring -the other work under the scope of these terms. - -@item -You may copy and distribute the Program (or a portion or derivative of -it, under Paragraph 2) in object code or executable form under the terms of -Paragraphs 1 and 2 above provided that you also do one of the following: - -@itemize @bullet -@item -accompany it with the complete corresponding machine-readable -source code, which must be distributed under the terms of -Paragraphs 1 and 2 above; or, - -@item -accompany it with a written offer, valid for at least three -years, to give any third party free (except for a nominal charge -for the cost of distribution) a complete machine-readable copy of the -corresponding source code, to be distributed under the terms of -Paragraphs 1 and 2 above; or, - -@item -accompany it with the information you received as to where the -corresponding source code may be obtained. (This alternative is -allowed only for noncommercial distribution and only if you -received the program in object code or executable form alone.) -@end itemize - -Source code for a work means the preferred form of the work for making -modifications to it. For an executable file, complete source code means -all the source code for all modules it contains; but, as a special -exception, it need not include source code for modules which are standard -libraries that accompany the operating system on which the executable -file runs, or for standard header files or definitions files that -accompany that operating system. - -@item -You may not copy, modify, sublicense, distribute or transfer the -Program except as expressly provided under this General Public License. -Any attempt otherwise to copy, modify, sublicense, distribute or transfer -the Program is void, and will automatically terminate your rights to use -the Program under this License. However, parties who have received -copies, or rights to use copies, from you under this General Public -License will not have their licenses terminated so long as such parties -remain in full compliance. - -@item -By copying, distributing or modifying the Program (or any work based -on the Program) you indicate your acceptance of this license to do so, -and all its terms and conditions. - -@item -Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the original -licensor to copy, distribute or modify the Program subject to these -terms and conditions. You may not impose any further restrictions on the -recipients' exercise of the rights granted herein. - -@item -The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of the license which applies to it and ``any -later version'', you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -the license, you may choose any version ever published by the Free Software -Foundation. - -@item -If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - -@iftex -@heading NO WARRANTY -@end iftex -@ifinfo -@center NO WARRANTY -@end ifinfo - -@item -BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM ``AS IS'' WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - -@item -IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL -ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES -ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT -LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES -SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE -WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN -ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -@end enumerate - -@iftex -@heading END OF TERMS AND CONDITIONS -@end iftex -@ifinfo -@center END OF TERMS AND CONDITIONS -@end ifinfo - -@page -@unnumberedsec Applying These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to humanity, the best way to achieve this is to make it -free software which everyone can redistribute and change under these -terms. - - To do so, attach the following notices to the program. It is safest to -attach them to the start of each source file to most effectively convey -the exclusion of warranty; and each file should have at least the -``copyright'' line and a pointer to where the full notice is found. - -@smallexample -@var{one line to give the program's name and a brief idea of what it does.} -Copyright (C) 19@var{yy} @var{name of author} - -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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. -@end smallexample - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - -@smallexample -Gnomovision version 69, Copyright (C) 19@var{yy} @var{name of author} -Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. -This is free software, and you are welcome to redistribute it -under certain conditions; type `show c' for details. -@end smallexample - -The hypothetical commands `show w' and `show c' should show the -appropriate parts of the General Public License. Of course, the -commands you use may be called something other than `show w' and `show -c'; they could even be mouse-clicks or menu items---whatever suits your -program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a ``copyright disclaimer'' for the program, if -necessary. Here is a sample; alter the names: - -@smallexample -Yoyodyne, Inc., hereby disclaims all copyright interest in the -program `Gnomovision' (a program to direct compilers to make passes -at assemblers) written by James Hacker. - -@var{signature of Ty Coon}, 1 April 1989 -Ty Coon, President of Vice -@end smallexample - -That's all there is to it! - - -@summarycontents -@contents -@bye diff --git a/gas/doc/gen.m4 b/gas/doc/gen.m4 deleted file mode 100644 index f794f9494a3..00000000000 --- a/gas/doc/gen.m4 +++ /dev/null @@ -1,14 +0,0 @@ -_divert__(-1) -<$Id$> -_define__(<_GENERIC__>,<1>) In case none.m4 changes its mind abt default - -_define__(<_AOUT__>,<1>) -_define__(<_COFF__>,<1>) -_define__(<_ELF__>,<1>) - -_define__(<_I80386__>,<1>) -_define__(<_M680X0__>,<1>) -_define__(<_SPARC__>,<1>) -_define__(<_VAX__>,<1>) - -_divert__<> \ No newline at end of file diff --git a/gas/doc/i80386.m4 b/gas/doc/i80386.m4 deleted file mode 100644 index f578887e24a..00000000000 --- a/gas/doc/i80386.m4 +++ /dev/null @@ -1,5 +0,0 @@ -_divert__(-1) -_define__(<_I80386__>,<1>) -_define__(<_HOST__>,) -_define__(<_MACH_DEP__>, -_divert__<> \ No newline at end of file diff --git a/gas/doc/i960.m4 b/gas/doc/i960.m4 deleted file mode 100644 index f94060e46ff..00000000000 --- a/gas/doc/i960.m4 +++ /dev/null @@ -1,12 +0,0 @@ -_divert__(-1) -_define__(<_I960__>,<1>) -_define__(<_AOUT__>,<0>) -_define__(<_BOUT__>,<1>) -_define__(<_COFF__>,<1>) -_define__(<_AS__>,) -_define__(<_GCC__>,) -_define__(<_LD__>,) -_define__(<_GDB__>,) -_define__(<_HOST__>,) -_define__(<_MACH_DEP__>,) -_divert__<> \ No newline at end of file diff --git a/gas/doc/m680x0.m4 b/gas/doc/m680x0.m4 deleted file mode 100644 index 752d5b69108..00000000000 --- a/gas/doc/m680x0.m4 +++ /dev/null @@ -1,5 +0,0 @@ -_divert__(-1) -_define__(<_M680X0__>,<1>) -_define__(<_HOST__>,) -_define__(<_MACH_DEP__>,) -_divert__<> \ No newline at end of file diff --git a/gas/doc/none.m4 b/gas/doc/none.m4 deleted file mode 100644 index 9ba5a453a7e..00000000000 --- a/gas/doc/none.m4 +++ /dev/null @@ -1,50 +0,0 @@ -_divert__(-1) -<$Id$> - -Switches: - -_define__(<_ALL_ARCH__>,<0>) (Meant as most inclusive; file turning - it on is expected to also turn on - all arch-related switches including - "_GENERIC__") -_define__(<_GENERIC__>,<1>) (may not be quite all configs; - meant for "most vanilla" manual) -_define__(<_INTERNALS__>,<0>) - -_define__(<_AOUT__>,<1>) Object formats. Note we turn on one. -_define__(<_BOUT__>,<0>) -_define__(<_COFF__>,<0>) -_define__(<_ELF__>,<0>) - -_define__(<_AMD29K__>,<0>) Specific architectures. Note none -_define__(<_I80386__>,<0>) starts out on. -_define__(<_I960__>,<0>) -_define__(<_M680X0__>,<0>) -_define__(<_SPARC__>,<0>) -_define__(<_VAX__>,<0>) -_define__(<_VXWORKS__>,<0>) - -Text: - -Default names; individual configs may override -Assembler: -_define__(<_AS__>,) -C Compiler: -_define__(<_GCC__>,) -Linker: -_define__(<_LD__>,) -Debugger name: -_define__(<_GDBN__>,) -Debugger program: -_define__(<_GDBP__>,) -Debugger init file: -_define__(<_GDBINIT__>,<.gdbinit>) - -Text for host; individual configs *should* override, but this may -catch some flubs -_define__(<_HOST__>,) - -"Machine Dependent" nodename -_define__(<_MACH_DEP__>,) - -_divert__<> \ No newline at end of file diff --git a/gas/doc/pretex.m4 b/gas/doc/pretex.m4 deleted file mode 100644 index 40c3d263453..00000000000 --- a/gas/doc/pretex.m4 +++ /dev/null @@ -1,268 +0,0 @@ -divert(-1) -*-Text-*- -` Copyright (c) 1991 Free Software Foundation, Inc.' -` This file defines and documents the M4 macros used ' -` to preprocess some GNU manuals' -` $Id$' - -I. INTRODUCTION - -This collection of M4 macros is meant to help in pre-processing texinfo -files to allow configuring them by hosts; for example, the reader of an -as manual who only has access to a 386 may not really want to see crud about -VAXen. - -A preprocessor is used, rather than extending texinfo, because this -way we can hack the conditionals in only one place; otherwise we would -have to write TeX macros, update makeinfo, and update the Emacs -info-formatting functions. - -II. COMPATIBILITY - -These macros should work with GNU m4 and System V m4; they do not work -with Sun or Berkeley M4. - -III. USAGE - -A. M4 INVOCATION -Assume this file is called "pretex.m4". Then, to preprocess a -document "mybook.texinfo" you might do something like the following: - - m4 pretex.m4 none.m4 PARTIC.m4 mybook.texinfo >mybook-PARTIC.texinfo - ----where your path is set to find GNU or SysV "m4", and the other m4 -files mentioned are as follows: - - none.m4: A file that defines, as 0, all the options you might - want to turn on using the conditionals defined below. - Unlike the C preprocessor, m4 does not default - undefined macros to 0. For example, here is a "none.m4" - I have been using: - _divert__(-1) - - _define__(<_ALL_ARCH__>,<0>) - _define__(<_INTERNALS__>,<0>) - - _define__(<_AMD29K__>,<0>) - _define__(<_I80386__>,<0>) - _define__(<_I960__>,<0>) - _define__(<_M680X0__>,<0>) - _define__(<_SPARC__>,<0>) - _define__(<_VAX__>,<0>) - - _divert__<> - - PARTIC.m4: A file that turns on whichever options you actually - want the manual configured for, in this particular - instance. Its contents are similar to one or more of - the lines in "none.m4", but of course the second - argument to _define__ is <1> rather than <0>. - - This is also a convenient place to _define__ any macros - that you want to expand to different text for - different configurations---for example, the name of - the program being described. - -Naturally, these are just suggested conventions; you could put your macro -definitions in any files or combinations of files you like. - -These macros use the characters < and > as m4 quotes; if you need -these characters in your text, you will also want to use the macros -_0__ and _1__ from this package---see the description of "Quote -Handling" in the "Implementation" section below. - -B. WHAT GOES IN THE PRE-TEXINFO SOURCE - -For the most part, the text of your book. In addition, you can -have text that is included only conditionally, using the macros -_if__ and _fi__ defined below. They BOTH take an argument! This is -primarily meant for readability (so a human can more easily see what -conditional end matches what conditional beginning), but the argument -is actually used in the _fi__ as well as the _if__ implementation. -You should always give a _fi__ the same argument as its matching -_if__. Other arguments may appear to work for a while, but are almost -certain to produce the wrong output for some configurations. - -For example, here is an excerpt from the very beginning of the -documentation for GNU as, to name the info file appropriately for -different configurations: - _if__(_ALL_ARCH__) - @setfilename as.info - _fi__(_ALL_ARCH__) - _if__(_M680X0__ && !_ALL_ARCH__) - @setfilename as-m680x0.info - _fi__(_M680X0__ && !_ALL_ARCH__) - _if__(_AMD29K__ && !_ALL_ARCH__) - @setfilename as-29k.info - _fi__(_AMD29K__ && !_ALL_ARCH__) - -Note that you can use Boolean expressions in the arguments; the -expression language is that of the built-in m4 macro `eval', described -in the m4 manual. - -IV. IMPLEMENTATION - -A.PRIMITIVE RENAMING -First, we redefine m4's built-ins to avoid conflict with plain text. -The naming convention used is that our macros all begin with a single -underbar and end with two underbars. The asymmetry is meant to avoid -conflict with some other conventions (which we may want to document) that -are intended to avoid conflict, like ANSI C predefined macros. - -define(`_undefine__',defn(`undefine')) -define(`_define__',defn(`define')) -define(`_defn__',defn(`defn')) -define(`_ppf__',`_define__(`_$1__',_defn__(`$1'))_undefine__(`$1')') -_ppf__(`builtin') -_ppf__(`changecom') -_ppf__(`changequote') -_ppf__(`decr') -_ppf__(`define') -_ppf__(`defn') -_ppf__(`divert') -_ppf__(`divnum') -_ppf__(`dnl') -_ppf__(`dumpdef') -_ppf__(`errprint') -_ppf__(`esyscmd') -_ppf__(`eval') -_ppf__(`format') -_ppf__(`ifdef') -_ppf__(`ifelse') -_ppf__(`include') -_ppf__(`incr') -_ppf__(`index') -_ppf__(`len') -_ppf__(`m4exit') -_ppf__(`m4wrap') -_ppf__(`maketemp') -_ppf__(`patsubst') -_ppf__(`popdef') -_ppf__(`pushdef') -_ppf__(`regexp') -_ppf__(`shift') -_ppf__(`sinclude') -_ppf__(`substr') -_ppf__(`syscmd') -_ppf__(`sysval') -_ppf__(`traceoff') -_ppf__(`traceon') -_ppf__(`translit') -_ppf__(`undefine') -_ppf__(`undivert') -_ppf__(`unix') - -B. QUOTE HANDLING. - -The characters used as quotes by M4, by default, are unfortunately -quite likely to occur in ordinary text. To avoid surprises, we will -use the characters <> ---which are just as suggestive (more so to -Francophones, perhaps) but a little less common in text (save for -those poor Francophones. You win some, you lose some). Still, we -expect also to have to set < and > occasionally in text; to do that, -we define a macro to turn off quote handling (_0__) and a macro to -turn it back on (_1__), according to our convention. - - BEWARE: This seems to make < and > unusable as relational operations - in calls to the builtin "eval". So far I've gotten - along without; but a better choice may be possible. - -Note that we postponed this for a while, for convenience in discussing -the issue and in the primitive renaming---not to mention in defining -_0__ and _1__ themselves! However, the quote redefinitions MUST -precede the _if__ / _fi__ definitions, because M4 will expand the text -as given---if we use the wrong quotes here, we will get the wrong -quotes when we use the conditionals. - -_define__(_0__,`_changequote__(,)')_define__(_1__,`_changequote__(<,>)') -_1__ - -C. CONDITIONALS - -We define two macros, _if__ and _fi__. BOTH take arguments! This is -meant both to help the human reader match up a _fi__ with its -corresponding _if__ and to aid in the implementation. You may use the -full expression syntax supported by M4 (see docn of `eval' builtin in -the m4 manual). - -The conditional macros are carefully defined to avoid introducing -extra whitespace (i.e., blank lines or blank characters). One side -effect exists--- - - BEWARE: text following an `_if__' on the same line is - DISCARDED even if the condition is true; text - following a `_fi__' on the same line is also - always discarded. - -The recommended convention is to always place _if__ and _fi__ on a -line by themselves. This will also aid the human reader. TeX won't -care about the line breaks; as for info, you may want to insert calls -to `@refill' at the end of paragraphs containing conditionalized text, -where you don't want line breaks separating unconditional from -conditional text. info formatting will then give you nice looking -paragraphs in the info file. - -Nesting: conditionals are designed to nest, in the following way: -*nothing* is output between an outer pair of false conditionals, even -if there are true conditionals inside. A false conditional "defeats" -all conditionals within it. The counter _IF_FS__ is used to -implement this; kindly avoid redefining it directly. - -_define__(<_IF_FS__>,<0>) - -NOTE: The definitions for our "pushf" and "popf" macros use eval -rather than incr and decr, because GNU m4 (0.75) tries to call eval -for us when we say "incr" or "decr"---but doesn't notice we've changed -eval's name. - -_define__( - <_pushf__>, - <_define__(<_IF_FS__>, - _eval__((_IF_FS__)+1))>) -_define__( - <_popf__>, - <_ifelse__(0,_IF_FS__, - <<>_dnl__<>>, - <_define__(<_IF_FS__>,_eval__((_IF_FS__)-1))>)>) - -_define__( - <_if__>, - <_ifelse__(1,_eval__( ($1) ), - <<>_dnl__<>>, - <_pushf__<>_divert__(-1)>)>) -_define__( - <_fi__>, - <_ifelse__(1,_eval__( ($1) ), - <<>_dnl__<>>, - <_popf__<>_ifelse__(0,_IF_FS__, - <_divert__<>_dnl__<>>,<>)>)>) - -D. CHAPTER/SECTION MACRO -In a parametrized manual, the heading level may need to be calculated; -for example, a manual that has a chapter on machine dependencies -should be conditionally structured as follows: - - IF the manual is configured for a SINGLE machine type, use -the chapter heading for that machine type, and run headings down -from there (top level for a particular machine is chapter, then within -that we have section, subsection etc); - - ELSE, if MANY machine types are described in the chapter, -use a generic chapter heading such as "@chapter Machine Dependencies", -use "section" for the top level description of EACH machine, and run -headings down from there (top level for a particular machine is -section, then within that we have subsection, subsubsection etc). - -The macro <_CHAPSEC__> is for this purpose: its argument is evaluated (so -you can construct expressions to express choices such as above), then -expands as follows: - 0: @chapter - 1: @section - 2: @subsection - 3: @subsubsection - ...and so on. - -_define__(<_CHAPSEC__>,<@_cs__(_eval__($1))>) -_define__(<_cs__>,<_ifelse__( - 0, $1, , - 1, $1,

, - _cs__(_eval__($1 - 1))>)>) - -_divert__<>_dnl__<> diff --git a/gas/doc/sparc.m4 b/gas/doc/sparc.m4 deleted file mode 100644 index 9b47db4f0d8..00000000000 --- a/gas/doc/sparc.m4 +++ /dev/null @@ -1,5 +0,0 @@ -_divert__(-1) -_define__(<_SPARC__>,<1>) -_define__(<_HOST__>,) -_define__(<_MACH_DEP__>,) -_divert__<> \ No newline at end of file diff --git a/gas/doc/vax.m4 b/gas/doc/vax.m4 deleted file mode 100644 index 76cb443cdb7..00000000000 --- a/gas/doc/vax.m4 +++ /dev/null @@ -1,5 +0,0 @@ -_divert__(-1) -_define__(<_VAX__>,<1>) -_define__(<_HOST__>,) -_define__(<_MACH_DEP__>,) -_divert__<> \ No newline at end of file diff --git a/gas/doc/vintage.m4 b/gas/doc/vintage.m4 deleted file mode 100644 index 342a2a36821..00000000000 --- a/gas/doc/vintage.m4 +++ /dev/null @@ -1,11 +0,0 @@ -_divert__(-1) -<$Id$> -_define__(<_ALL_ARCH__>,<1>) -_define__(<_GENERIC__>,<1>) In case none.m4 changes its mind abt default - -_define__(<_AOUT__>,<1>) - -_define__(<_M680X0__>,<1>) -_define__(<_SPARC__>,<1>) - -_divert__<> \ No newline at end of file diff --git a/gas/expr.c b/gas/expr.c deleted file mode 100644 index c62e39cb610..00000000000 --- a/gas/expr.c +++ /dev/null @@ -1,966 +0,0 @@ -/* expr.c -operands, expressions- - Copyright (C) 1987, 1990, 1991 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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 1, or (at your option) -any later version. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* static const char rcsid[] = "$Id$"; */ - -/* - * This is really a branch office of as-read.c. I split it out to clearly - * distinguish the world of expressions from the world of statements. - * (It also gives smaller files to re-compile.) - * Here, "operand"s are of expressions, not instructions. - */ - -#include -#include - -#include "as.h" - -#include "obstack.h" - -#ifdef __STDC__ -static void clean_up_expression(expressionS *expressionP); -#else /* __STDC__ */ -static void clean_up_expression(); /* Internal. */ -#endif /* __STDC__ */ -extern const char EXP_CHARS[]; /* JF hide MD floating pt stuff all the same place */ -extern const char FLT_CHARS[]; - -#ifdef LOCAL_LABELS_DOLLAR -extern int local_label_defined[]; -#endif - -/* - * Build any floating-point literal here. - * Also build any bignum literal here. - */ - -/* LITTLENUM_TYPE generic_buffer [6]; */ /* JF this is a hack */ -/* Seems atof_machine can backscan through generic_bignum and hit whatever - happens to be loaded before it in memory. And its way too complicated - for me to fix right. Thus a hack. JF: Just make generic_bignum bigger, - and never write into the early words, thus they'll always be zero. - I hate Dean's floating-point code. Bleh. - */ -LITTLENUM_TYPE generic_bignum [SIZE_OF_LARGE_NUMBER+6]; -FLONUM_TYPE generic_floating_point_number = -{ - & generic_bignum [6], /* low (JF: Was 0) */ - & generic_bignum [SIZE_OF_LARGE_NUMBER+6 - 1], /* high JF: (added +6) */ - 0, /* leader */ - 0, /* exponent */ - 0 /* sign */ -}; -/* If nonzero, we've been asked to assemble nan, +inf or -inf */ -int generic_floating_point_magic; - -/* - * Summary of operand(). - * - * in: Input_line_pointer points to 1st char of operand, which may - * be a space. - * - * out: A expressionS. X_seg determines how to understand the rest of the - * expressionS. - * The operand may have been empty: in this case X_seg == SEG_ABSENT. - * Input_line_pointer->(next non-blank) char after operand. - * - */ - -static segT -operand (expressionP) - register expressionS * expressionP; -{ - register char c; - register char *name; /* points to name of symbol */ - register symbolS * symbolP; /* Points to symbol */ - - extern char hex_value[]; /* In hex_value.c */ - - SKIP_WHITESPACE(); /* Leading whitespace is part of operand. */ - c = * input_line_pointer ++; /* Input_line_pointer->past char in c. */ - if (isdigit(c)) - { - register valueT number; /* offset or (absolute) value */ - register short int digit; /* value of next digit in current radix */ - /* invented for humans only, hope */ - /* optimising compiler flushes it! */ - register short int radix; /* 2, 8, 10 or 16 */ - /* 0 means we saw start of a floating- */ - /* point constant. */ - register short int maxdig = 0;/* Highest permitted digit value. */ - register int too_many_digits = 0; /* If we see >= this number of */ - /* digits, assume it is a bignum. */ - register char * digit_2; /*->2nd digit of number. */ - int small; /* TRUE if fits in 32 bits. */ - - if (c == '0') { /* non-decimal radix */ - if ((c = *input_line_pointer ++)=='x' || c=='X') { - c = *input_line_pointer ++; /* read past "0x" or "0X" */ - maxdig = radix = 16; - too_many_digits = 9; - } else { - /* If it says '0f' and the line ends or it DOESN'T look like - a floating point #, its a local label ref. DTRT */ - /* likewise for the b's. xoxorich. */ - if ((c == 'f' || c == 'b' || c == 'B') - && (!*input_line_pointer || - (!strchr("+-.0123456789",*input_line_pointer) && - !strchr(EXP_CHARS,*input_line_pointer)))) { - maxdig = radix = 10; - too_many_digits = 11; - c = '0'; - input_line_pointer -= 2; - - } else if (c == 'b' || c == 'B') { - c = *input_line_pointer++; - maxdig = radix = 2; - too_many_digits = 33; - - } else if (c && strchr(FLT_CHARS,c)) { - radix = 0; /* Start of floating-point constant. */ - /* input_line_pointer->1st char of number. */ - expressionP->X_add_number = -(isupper(c) ? tolower(c) : c); - - } else { /* By elimination, assume octal radix. */ - radix = maxdig = 8; - too_many_digits = 11; - } - } /* c == char after "0" or "0x" or "0X" or "0e" etc. */ - } else { - maxdig = radix = 10; - too_many_digits = 11; - } /* if operand starts with a zero */ - - if (radix) { /* Fixed-point integer constant. */ - /* May be bignum, or may fit in 32 bits. */ -/* - * Most numbers fit into 32 bits, and we want this case to be fast. - * So we pretend it will fit into 32 bits. If, after making up a 32 - * bit number, we realise that we have scanned more digits than - * comfortably fit into 32 bits, we re-scan the digits coding - * them into a bignum. For decimal and octal numbers we are conservative: some - * numbers may be assumed bignums when in fact they do fit into 32 bits. - * Numbers of any radix can have excess leading zeros: we strive - * to recognise this and cast them back into 32 bits. - * We must check that the bignum really is more than 32 - * bits, and change it back to a 32-bit number if it fits. - * The number we are looking for is expected to be positive, but - * if it fits into 32 bits as an unsigned number, we let it be a 32-bit - * number. The cavalier approach is for speed in ordinary cases. - */ - digit_2 = input_line_pointer; - for (number=0; (digit=hex_value[c])char after C. */ - small = input_line_pointer - digit_2 < too_many_digits; - if (! small) - { - /* - * We saw a lot of digits. Manufacture a bignum the hard way. - */ - LITTLENUM_TYPE * leader; /*->high order littlenum of the bignum. */ - LITTLENUM_TYPE * pointer; /*->littlenum we are frobbing now. */ - long carry; - - leader = generic_bignum; - generic_bignum [0] = 0; - generic_bignum [1] = 0; - /* We could just use digit_2, but lets be mnemonic. */ - input_line_pointer = -- digit_2; /*->1st digit. */ - c = *input_line_pointer ++; - for (; (carry = hex_value [c]) < maxdig; c = * input_line_pointer ++) - { - for (pointer = generic_bignum; - pointer <= leader; - pointer ++) - { - long work; - - work = carry + radix * * pointer; - * pointer = work & LITTLENUM_MASK; - carry = work >> LITTLENUM_NUMBER_OF_BITS; - } - if (carry) - { - if (leader < generic_bignum + SIZE_OF_LARGE_NUMBER - 1) - { /* Room to grow a longer bignum. */ - * ++ leader = carry; - } - } - } - /* Again, C is char after number, */ - /* input_line_pointer->after C. */ - know(sizeof (int) * 8 == 32); - know(LITTLENUM_NUMBER_OF_BITS == 16); - /* Hence the constant "2" in the next line. */ - if (leader < generic_bignum + 2) - { /* Will fit into 32 bits. */ - number = - ((generic_bignum [1] & LITTLENUM_MASK) << LITTLENUM_NUMBER_OF_BITS) - | (generic_bignum [0] & LITTLENUM_MASK); - small = 1; - } - else - { - number = leader - generic_bignum + 1; /* Number of littlenums in the bignum. */ - } - } - if (small) - { - /* - * Here with number, in correct radix. c is the next char. - * Note that unlike Un*x, we allow "011f" "0x9f" to - * both mean the same as the (conventional) "9f". This is simply easier - * than checking for strict canonical form. Syntax sux! - */ - if (number<10) - { - if (0 -#ifdef LOCAL_LABELS_FB - || c=='b' -#endif -#ifdef LOCAL_LABELS_DOLLAR - || (c=='$' && local_label_defined[number]) -#endif - ) - { - /* - * Backward ref to local label. - * Because it is backward, expect it to be DEFINED. - */ - /* - * Construct a local label. - */ - name = local_label_name ((int)number, 0); - if (((symbolP = symbol_find(name)) != NULL) /* seen before */ - && (S_IS_DEFINED(symbolP))) /* symbol is defined: OK */ - { /* Expected path: symbol defined. */ - /* Local labels are never absolute. Don't waste time checking absoluteness. */ - know((S_GET_SEGMENT(symbolP) == SEG_DATA) || (S_GET_SEGMENT(symbolP) == SEG_TEXT)); - expressionP->X_add_symbol = symbolP; - expressionP->X_add_number = 0; - expressionP->X_seg = S_GET_SEGMENT(symbolP); - } - else - { /* Either not seen or not defined. */ - as_bad("Backw. ref to unknown label \"%d:\", 0 assumed.", - number); - expressionP->X_add_number = 0; - expressionP->X_seg = SEG_ABSOLUTE; - } - } - else - { - if (0 -#ifdef LOCAL_LABELS_FB - || c == 'f' -#endif -#ifdef LOCAL_LABELS_DOLLAR - || (c=='$' && !local_label_defined[number]) -#endif - ) - { - /* - * Forward reference. Expect symbol to be undefined or - * unknown. Undefined: seen it before. Unknown: never seen - * it in this pass. - * Construct a local label name, then an undefined symbol. - * Don't create a XSEG frag for it: caller may do that. - * Just return it as never seen before. - */ - name = local_label_name((int)number, 1); - symbolP = symbol_find_or_make(name); - /* We have no need to check symbol properties. */ - know(S_GET_SEGMENT(symbolP) == SEG_UNKNOWN - || S_GET_SEGMENT(symbolP) == SEG_TEXT - || S_GET_SEGMENT(symbolP) == SEG_DATA); - expressionP->X_add_symbol = symbolP; - expressionP->X_seg = SEG_UNKNOWN; - expressionP->X_subtract_symbol = NULL; - expressionP->X_add_number = 0; - } - else - { /* Really a number, not a local label. */ - expressionP->X_add_number = number; - expressionP->X_seg = SEG_ABSOLUTE; - input_line_pointer --; /* Restore following character. */ - } /* if (c=='f') */ - } /* if (c=='b') */ - } - else - { /* Really a number. */ - expressionP->X_add_number = number; - expressionP->X_seg = SEG_ABSOLUTE; - input_line_pointer --; /* Restore following character. */ - } /* if (number<10) */ - } - else - { - expressionP->X_add_number = number; - expressionP->X_seg = SEG_BIG; - input_line_pointer --; /*->char following number. */ - } /* if (small) */ - } /* (If integer constant) */ - else - { /* input_line_pointer->*/ - /* floating-point constant. */ - int error_code; - - error_code = atof_generic - (& input_line_pointer, ".", EXP_CHARS, - & generic_floating_point_number); - - if (error_code) - { - if (error_code == ERROR_EXPONENT_OVERFLOW) - { - as_bad("Bad floating-point constant: exponent overflow, probably assembling junk"); - } - else - { - as_bad("Bad floating-point constant: unknown error code=%d.", error_code); - } - } - expressionP->X_seg = SEG_BIG; - /* input_line_pointer->just after constant, */ - /* which may point to whitespace. */ - know(expressionP->X_add_number < 0); /* < 0 means "floating point". */ - } /* if (not floating-point constant) */ - } - else if(c=='.' && !is_part_of_name(*input_line_pointer)) { - extern struct obstack frags; - - /* - JF: '.' is pseudo symbol with value of current location in current - segment. . . - */ - symbolP = symbol_new("L0\001", - now_seg, - (valueT)(obstack_next_free(&frags)-frag_now->fr_literal), - frag_now); - - expressionP->X_add_number=0; - expressionP->X_add_symbol=symbolP; - expressionP->X_seg = now_seg; - - } else if (is_name_beginner(c)) /* here if did not begin with a digit */ - { - /* - * Identifier begins here. - * This is kludged for speed, so code is repeated. - */ - name = -- input_line_pointer; - c = get_symbol_end(); - symbolP = symbol_find_or_make(name); - /* - * If we have an absolute symbol or a reg, then we know its value now. - */ - expressionP->X_seg = S_GET_SEGMENT(symbolP); - switch (expressionP->X_seg) - { - case SEG_ABSOLUTE: - case SEG_REGISTER: - expressionP->X_add_number = S_GET_VALUE(symbolP); - break; - - default: - expressionP->X_add_number = 0; - expressionP->X_add_symbol = symbolP; - } - * input_line_pointer = c; - expressionP->X_subtract_symbol = NULL; - } - else if (c=='(')/* didn't begin with digit & not a name */ - { - (void)expression(expressionP); - /* Expression() will pass trailing whitespace */ - if (* input_line_pointer ++ != ')') - { - as_bad("Missing ')' assumed"); - input_line_pointer --; - } - /* here with input_line_pointer->char after "(...)" */ - } - else if (c == '~' || c == '-' || c == '+') { - /* unary operator: hope for SEG_ABSOLUTE */ - switch (operand (expressionP)) { - case SEG_ABSOLUTE: - /* input_line_pointer->char after operand */ - if (c=='-') { - expressionP->X_add_number = - expressionP->X_add_number; - /* - * Notice: '-' may overflow: no warning is given. This is compatible - * with other people's assemblers. Sigh. - */ - } else if (c == '~') { - expressionP->X_add_number = ~ expressionP->X_add_number; - } else if (c != '+') { - know(0); - } /* switch on unary operator */ - break; - - case SEG_TEXT: - case SEG_DATA: - case SEG_BSS: - case SEG_PASS1: - case SEG_UNKNOWN: - if(c=='-') { /* JF I hope this hack works */ - expressionP->X_subtract_symbol=expressionP->X_add_symbol; - expressionP->X_add_symbol=0; - expressionP->X_seg=SEG_DIFFERENCE; - break; - } - default: /* unary on non-absolute is unsuported */ - as_bad("Unary operator %c ignored because bad operand follows", c); - break; - /* Expression undisturbed from operand(). */ - } - } - else if (c=='\'') - { -/* - * Warning: to conform to other people's assemblers NO ESCAPEMENT is permitted - * for a single quote. The next character, parity errors and all, is taken - * as the value of the operand. VERY KINKY. - */ - expressionP->X_add_number = * input_line_pointer ++; - expressionP->X_seg = SEG_ABSOLUTE; - } - else - { - /* can't imagine any other kind of operand */ - expressionP->X_seg = SEG_ABSENT; - input_line_pointer --; - md_operand (expressionP); - } -/* - * It is more 'efficient' to clean up the expressions when they are created. - * Doing it here saves lines of code. - */ - clean_up_expression (expressionP); - SKIP_WHITESPACE(); /*->1st char after operand. */ - know(* input_line_pointer != ' '); - return (expressionP->X_seg); -} /* operand() */ - -/* Internal. Simplify a struct expression for use by expr() */ - -/* - * In: address of a expressionS. - * The X_seg field of the expressionS may only take certain values. - * Now, we permit SEG_PASS1 to make code smaller & faster. - * Elsewise we waste time special-case testing. Sigh. Ditto SEG_ABSENT. - * Out: expressionS may have been modified: - * 'foo-foo' symbol references cancelled to 0, - * which changes X_seg from SEG_DIFFERENCE to SEG_ABSOLUTE; - * Unused fields zeroed to help expr(). - */ - -static void -clean_up_expression (expressionP) - register expressionS * expressionP; -{ - switch (expressionP->X_seg) - { - case SEG_ABSENT: - case SEG_PASS1: - expressionP->X_add_symbol = NULL; - expressionP->X_subtract_symbol = NULL; - expressionP->X_add_number = 0; - break; - - case SEG_BIG: - case SEG_ABSOLUTE: - expressionP->X_subtract_symbol = NULL; - expressionP->X_add_symbol = NULL; - break; - - case SEG_TEXT: - case SEG_DATA: - case SEG_BSS: - case SEG_UNKNOWN: - expressionP->X_subtract_symbol = NULL; - break; - - case SEG_DIFFERENCE: - /* - * It does not hurt to 'cancel' NULL==NULL - * when comparing symbols for 'eq'ness. - * It is faster to re-cancel them to NULL - * than to check for this special case. - */ - if (expressionP->X_subtract_symbol == expressionP->X_add_symbol - || (expressionP->X_subtract_symbol - && expressionP->X_add_symbol - && expressionP->X_subtract_symbol->sy_frag==expressionP->X_add_symbol->sy_frag - && S_GET_VALUE(expressionP->X_subtract_symbol) == S_GET_VALUE(expressionP->X_add_symbol))) { - expressionP->X_subtract_symbol = NULL; - expressionP->X_add_symbol = NULL; - expressionP->X_seg = SEG_ABSOLUTE; - } - break; - - case SEG_REGISTER: - expressionP->X_add_symbol = NULL; - expressionP->X_subtract_symbol = NULL; - break; - - default: - BAD_CASE (expressionP->X_seg); - break; - } -} /* clean_up_expression() */ - -/* - * expr_part () - * - * Internal. Made a function because this code is used in 2 places. - * Generate error or correct X_?????_symbol of expressionS. - */ - -/* - * symbol_1 += symbol_2 ... well ... sort of. - */ - -static segT -expr_part (symbol_1_PP, symbol_2_P) - symbolS ** symbol_1_PP; - symbolS * symbol_2_P; -{ - segT return_value; - - know((* symbol_1_PP) == NULL - || (S_GET_SEGMENT(*symbol_1_PP) == SEG_TEXT) - || (S_GET_SEGMENT(*symbol_1_PP) == SEG_DATA) - || (S_GET_SEGMENT(*symbol_1_PP) == SEG_BSS) - || (!S_IS_DEFINED(* symbol_1_PP))); - know(symbol_2_P == NULL - || (S_GET_SEGMENT(symbol_2_P) == SEG_TEXT) - || (S_GET_SEGMENT(symbol_2_P) == SEG_DATA) - || (S_GET_SEGMENT(symbol_2_P) == SEG_BSS) - || (!S_IS_DEFINED(symbol_2_P))); - if (* symbol_1_PP) - { - if (!S_IS_DEFINED(* symbol_1_PP)) - { - if (symbol_2_P) - { - return_value = SEG_PASS1; - * symbol_1_PP = NULL; - } - else - { - know(!S_IS_DEFINED(* symbol_1_PP)); - return_value = SEG_UNKNOWN; - } - } - else - { - if (symbol_2_P) - { - if (!S_IS_DEFINED(symbol_2_P)) - { - * symbol_1_PP = NULL; - return_value = SEG_PASS1; - } - else - { - /* {seg1} - {seg2} */ - as_bad("Expression too complex, 2 symbols forgotten: \"%s\" \"%s\"", - S_GET_NAME(* symbol_1_PP), S_GET_NAME(symbol_2_P)); - * symbol_1_PP = NULL; - return_value = SEG_ABSOLUTE; - } - } - else - { - return_value = S_GET_SEGMENT(* symbol_1_PP); - } - } - } - else - { /* (* symbol_1_PP) == NULL */ - if (symbol_2_P) - { - * symbol_1_PP = symbol_2_P; - return_value = S_GET_SEGMENT(symbol_2_P); - } - else - { - * symbol_1_PP = NULL; - return_value = SEG_ABSOLUTE; - } - } - know(return_value == SEG_ABSOLUTE - || return_value == SEG_TEXT - || return_value == SEG_DATA - || return_value == SEG_BSS - || return_value == SEG_UNKNOWN - || return_value == SEG_PASS1); - know((* symbol_1_PP) == NULL - || (S_GET_SEGMENT(* symbol_1_PP) == return_value)); - return (return_value); -} /* expr_part() */ - -/* Expression parser. */ - -/* - * We allow an empty expression, and just assume (absolute,0) silently. - * Unary operators and parenthetical expressions are treated as operands. - * As usual, Q==quantity==operand, O==operator, X==expression mnemonics. - * - * We used to do a aho/ullman shift-reduce parser, but the logic got so - * warped that I flushed it and wrote a recursive-descent parser instead. - * Now things are stable, would anybody like to write a fast parser? - * Most expressions are either register (which does not even reach here) - * or 1 symbol. Then "symbol+constant" and "symbol-symbol" are common. - * So I guess it doesn't really matter how inefficient more complex expressions - * are parsed. - * - * After expr(RANK,resultP) input_line_pointer->operator of rank <= RANK. - * Also, we have consumed any leading or trailing spaces (operand does that) - * and done all intervening operators. - */ - -typedef enum -{ -O_illegal, /* (0) what we get for illegal op */ - -O_multiply, /* (1) * */ -O_divide, /* (2) / */ -O_modulus, /* (3) % */ -O_left_shift, /* (4) < */ -O_right_shift, /* (5) > */ -O_bit_inclusive_or, /* (6) | */ -O_bit_or_not, /* (7) ! */ -O_bit_exclusive_or, /* (8) ^ */ -O_bit_and, /* (9) & */ -O_add, /* (10) + */ -O_subtract /* (11) - */ -} -operatorT; - -#define __ O_illegal - -static const operatorT op_encoding [256] = { /* maps ASCII->operators */ - -__, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, -__, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, - -__, O_bit_or_not, __, __, __, O_modulus, O_bit_and, __, -__, __, O_multiply, O_add, __, O_subtract, __, O_divide, -__, __, __, __, __, __, __, __, -__, __, __, __, O_left_shift, __, O_right_shift, __, -__, __, __, __, __, __, __, __, -__, __, __, __, __, __, __, __, -__, __, __, __, __, __, __, __, -__, __, __, __, __, __, O_bit_exclusive_or, __, -__, __, __, __, __, __, __, __, -__, __, __, __, __, __, __, __, -__, __, __, __, __, __, __, __, -__, __, __, __, O_bit_inclusive_or, __, __, __, - -__, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, -__, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, -__, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, -__, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, -__, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, -__, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, -__, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, -__, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __ -}; - - -/* - * Rank Examples - * 0 operand, (expression) - * 1 + - - * 2 & ^ ! | - * 3 * / % << >> - */ -static const operator_rankT -op_rank [] = { 0, 3, 3, 3, 3, 3, 2, 2, 2, 2, 1, 1 }; - -/* Return resultP->X_seg. */ -segT expr(rank, resultP) -register operator_rankT rank; /* Larger # is higher rank. */ -register expressionS *resultP; /* Deliver result here. */ -{ - expressionS right; - register operatorT op_left; - register char c_left; /* 1st operator character. */ - register operatorT op_right; - register char c_right; - - know(rank >= 0); - (void)operand (resultP); - know(* input_line_pointer != ' '); /* Operand() gobbles spaces. */ - c_left = * input_line_pointer; /* Potential operator character. */ - op_left = op_encoding [c_left]; - while (op_left != O_illegal && op_rank [(int) op_left] > rank) - { - input_line_pointer ++; /*->after 1st character of operator. */ - /* Operators "<<" and ">>" have 2 characters. */ - if (* input_line_pointer == c_left && (c_left == '<' || c_left == '>')) - { - input_line_pointer ++; - } /*->after operator. */ - if (SEG_ABSENT == expr (op_rank[(int) op_left], &right)) - { - as_warn("Missing operand value assumed absolute 0."); - resultP->X_add_number = 0; - resultP->X_subtract_symbol = NULL; - resultP->X_add_symbol = NULL; - resultP->X_seg = SEG_ABSOLUTE; - } - know(* input_line_pointer != ' '); - c_right = * input_line_pointer; - op_right = op_encoding [c_right]; - if (* input_line_pointer == c_right && (c_right == '<' || c_right == '>')) - { - input_line_pointer ++; - } /*->after operator. */ - know((int) op_right == 0 - || op_rank [(int) op_right] <= op_rank[(int) op_left]); - /* input_line_pointer->after right-hand quantity. */ - /* left-hand quantity in resultP */ - /* right-hand quantity in right. */ - /* operator in op_left. */ - if (resultP->X_seg == SEG_PASS1 || right . X_seg == SEG_PASS1) - { - resultP->X_seg = SEG_PASS1; - } - else - { - if (resultP->X_seg == SEG_BIG) - { - as_warn("Left operand of %c is a %s. Integer 0 assumed.", - c_left, resultP->X_add_number > 0 ? "bignum" : "float"); - resultP->X_seg = SEG_ABSOLUTE; - resultP->X_add_symbol = 0; - resultP->X_subtract_symbol = 0; - resultP->X_add_number = 0; - } - if (right . X_seg == SEG_BIG) - { - as_warn("Right operand of %c is a %s. Integer 0 assumed.", - c_left, right . X_add_number > 0 ? "bignum" : "float"); - right . X_seg = SEG_ABSOLUTE; - right . X_add_symbol = 0; - right . X_subtract_symbol = 0; - right . X_add_number = 0; - } - if (op_left == O_subtract) - { - /* - * Convert - into + by exchanging symbols and negating number. - * I know -infinity can't be negated in 2's complement: - * but then it can't be subtracted either. This trick - * does not cause any further inaccuracy. - */ - - register symbolS * symbolP; - - right . X_add_number = - right . X_add_number; - symbolP = right . X_add_symbol; - right . X_add_symbol = right . X_subtract_symbol; - right . X_subtract_symbol = symbolP; - if (symbolP) - { - right . X_seg = SEG_DIFFERENCE; - } - op_left = O_add; - } - - if (op_left == O_add) - { - segT seg1; - segT seg2; - - know(resultP->X_seg == SEG_DATA - || resultP->X_seg == SEG_TEXT - || resultP->X_seg == SEG_BSS - || resultP->X_seg == SEG_UNKNOWN - || resultP->X_seg == SEG_DIFFERENCE - || resultP->X_seg == SEG_ABSOLUTE - || resultP->X_seg == SEG_PASS1); - know(right . X_seg == SEG_DATA - || right . X_seg == SEG_TEXT - || right . X_seg == SEG_BSS - || right . X_seg == SEG_UNKNOWN - || right . X_seg == SEG_DIFFERENCE - || right . X_seg == SEG_ABSOLUTE - || right . X_seg == SEG_PASS1); - - clean_up_expression (& right); - clean_up_expression (resultP); - - seg1 = expr_part (& resultP->X_add_symbol, right . X_add_symbol); - seg2 = expr_part (& resultP->X_subtract_symbol, right . X_subtract_symbol); - if (seg1 == SEG_PASS1 || seg2 == SEG_PASS1) { - need_pass_2 = 1; - resultP->X_seg = SEG_PASS1; - } else if (seg2 == SEG_ABSOLUTE) - resultP->X_seg = seg1; - else if (seg1 != SEG_UNKNOWN - && seg1 != SEG_ABSOLUTE - && seg2 != SEG_UNKNOWN - && seg1 != seg2) { - know(seg2 != SEG_ABSOLUTE); - know(resultP->X_subtract_symbol); - - know(seg1 == SEG_TEXT || seg1 == SEG_DATA || seg1== SEG_BSS); - know(seg2 == SEG_TEXT || seg2 == SEG_DATA || seg2== SEG_BSS); - know(resultP->X_add_symbol); - know(resultP->X_subtract_symbol); - as_bad("Expression too complex: forgetting %s - %s", - S_GET_NAME(resultP->X_add_symbol), - S_GET_NAME(resultP->X_subtract_symbol)); - resultP->X_seg = SEG_ABSOLUTE; - /* Clean_up_expression() will do the rest. */ - } else - resultP->X_seg = SEG_DIFFERENCE; - - resultP->X_add_number += right . X_add_number; - clean_up_expression (resultP); - } - else - { /* Not +. */ - if (resultP->X_seg == SEG_UNKNOWN || right . X_seg == SEG_UNKNOWN) - { - resultP->X_seg = SEG_PASS1; - need_pass_2 = 1; - } - else - { - resultP->X_subtract_symbol = NULL; - resultP->X_add_symbol = NULL; - /* Will be SEG_ABSOLUTE. */ - if (resultP->X_seg != SEG_ABSOLUTE || right . X_seg != SEG_ABSOLUTE) - { - as_bad("Relocation error. Absolute 0 assumed."); - resultP->X_seg = SEG_ABSOLUTE; - resultP->X_add_number = 0; - } - else - { - switch (op_left) - { - case O_bit_inclusive_or: - resultP->X_add_number |= right . X_add_number; - break; - - case O_modulus: - if (right . X_add_number) - { - resultP->X_add_number %= right . X_add_number; - } - else - { - as_warn("Division by 0. 0 assumed."); - resultP->X_add_number = 0; - } - break; - - case O_bit_and: - resultP->X_add_number &= right . X_add_number; - break; - - case O_multiply: - resultP->X_add_number *= right . X_add_number; - break; - - case O_divide: - if (right . X_add_number) - { - resultP->X_add_number /= right . X_add_number; - } - else - { - as_warn("Division by 0. 0 assumed."); - resultP->X_add_number = 0; - } - break; - - case O_left_shift: - resultP->X_add_number <<= right . X_add_number; - break; - - case O_right_shift: - resultP->X_add_number >>= right . X_add_number; - break; - - case O_bit_exclusive_or: - resultP->X_add_number ^= right . X_add_number; - break; - - case O_bit_or_not: - resultP->X_add_number |= ~ right . X_add_number; - break; - - default: - BAD_CASE(op_left); - break; - } /* switch(operator) */ - } - } /* If we have to force need_pass_2. */ - } /* If operator was +. */ - } /* If we didn't set need_pass_2. */ - op_left = op_right; - } /* While next operator is >= this rank. */ - return (resultP->X_seg); -} - -/* - * get_symbol_end() - * - * This lives here because it belongs equally in expr.c & read.c. - * Expr.c is just a branch office read.c anyway, and putting it - * here lessens the crowd at read.c. - * - * Assume input_line_pointer is at start of symbol name. - * Advance input_line_pointer past symbol name. - * Turn that character into a '\0', returning its former value. - * This allows a string compare (RMS wants symbol names to be strings) - * of the symbol name. - * There will always be a char following symbol name, because all good - * lines end in end-of-line. - */ -char -get_symbol_end() -{ - register char c; - - while (is_part_of_name(c = * input_line_pointer ++)) - ; - * -- input_line_pointer = 0; - return (c); -} - -/* - * Local Variables: - * comment-column: 0 - * fill-column: 131 - * End: - */ - -/* end: expr.c */ diff --git a/gas/expr.h b/gas/expr.h deleted file mode 100644 index 350215e503b..00000000000 --- a/gas/expr.h +++ /dev/null @@ -1,79 +0,0 @@ -/* expr.h -> header file for expr.c - Copyright (C) 1987 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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 1, or (at your option) -any later version. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - * Abbreviations (mnemonics). - * - * O operator - * Q quantity, operand - * X eXpression - */ - -/* - * By popular demand, we define a struct to represent an expression. - * This will no doubt mutate as expressions become baroque. - * - * Currently, we support expressions like "foo-bar+42". - * In other words we permit a (possibly undefined) minuend, a - * (possibly undefined) subtrahend and an (absolute) augend. - * RMS says this is so we can have 1-pass assembly for any compiler - * emmissions, and a 'case' statement might emit 'undefined1 - undefined2'. - * - * To simplify table-driven dispatch, we also have a "segment" for the - * entire expression. That way we don't require complex reasoning about - * whether particular components are defined; and we can change component - * semantics without re-working all the dispatch tables in the assembler. - * In other words the "type" of an expression is its segment. - */ - -typedef struct -{ - symbolS *X_add_symbol; /* foo */ - symbolS *X_subtract_symbol; /* bar */ - long X_add_number; /* 42. Must be signed. */ - segT X_seg; /* What segment (expr type)? */ -} -expressionS; - - /* result should be type (expressionS *). */ -#define expression(result) expr(0,result) - - /* If an expression is SEG_BIG, look here */ - /* for its value. These common data may */ - /* be clobbered whenever expr() is called. */ -extern FLONUM_TYPE generic_floating_point_number; /* Flonums returned here. */ - /* Enough to hold most precise flonum. */ -extern LITTLENUM_TYPE generic_bignum []; /* Bignums returned here. */ -#define SIZE_OF_LARGE_NUMBER (20) /* Number of littlenums in above. */ - -typedef char operator_rankT; - -#ifdef __STDC__ - -char get_symbol_end(void); -segT expr(int rank, expressionS *resultP); - -#else /* __STDC__ */ - -char get_symbol_end(); -segT expr(); - -#endif /* __STDC__ */ - -/* end: expr.h */ diff --git a/gas/flonum-const.c b/gas/flonum-const.c deleted file mode 100755 index 7f54197d71a..00000000000 --- a/gas/flonum-const.c +++ /dev/null @@ -1,159 +0,0 @@ -/* flonum_const.c - Useful Flonum constants - Copyright (C) 1987, 1990, 1991 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* static const char rcsid[] = "$Id$"; */ - -#include "flonum.h" -/* JF: I added the last entry to this table, and I'm not - sure if its right or not. Could go either way. I wish - I really understood this stuff. */ - - -const int table_size_of_flonum_powers_of_ten = 11; - -static const LITTLENUM_TYPE zero[] = { 1 }; - -/***********************************************************************\ -* * -* Warning: the low order bits may be WRONG here. * -* I took this from a suspect bc(1) script. * -* "minus_X"[] is supposed to be 10^(2^-X) expressed in base 2^16. * -* The radix point is just AFTER the highest element of the [] * -* * -* Because bc rounds DOWN for printing (I think), the lowest * -* significance littlenums should probably have 1 added to them. * -* * -\***********************************************************************/ - -/* JF: If this equals 6553/(2^16)+39321/(2^32)+... it approaches .1 */ -static const LITTLENUM_TYPE minus_1 [] = { - 39321, 39321, 39321, 39321, 39321, 39321, 39321, 39321, 39321, 39321, - 39321, 39321, 39321, 39321, 39321, 39321, 39321, 39321, 39321, 6553 }; -static const LITTLENUM_TYPE plus_1 [] = { 10 }; - -/* JF: If this equals 655/(2^16) + 23592/(2^32) + ... it approaches .01 */ -static const LITTLENUM_TYPE minus_2 [] = { - 10485, 36700, 62914, 23592, 49807, 10485, 36700, 62914, 23592, 49807, - 10485, 36700, 62914, 23592, 49807, 10485, 36700, 62914, 23592, 655 }; -static const LITTLENUM_TYPE plus_2 [] = { 100 }; - -/* This approaches .0001 */ -static const LITTLENUM_TYPE minus_3 [] = { - 52533, 20027, 37329, 65116, 64067, 60397, 14784, 18979, 33659, 19503, - 2726, 9542, 629, 2202, 40475, 10590, 4299, 47815, 36280, 6 }; -static const LITTLENUM_TYPE plus_3 [] = { 10000 }; - -/* JF: this approaches 1e-8 */ -static const LITTLENUM_TYPE minus_4 [] = { - 22516, 49501, 54293, 19424, 60699, 6716, 24348, 22618, 23904, 21327, - 3919, 44703, 19149, 28803, 48959, 6259, 50273, 62237, 42 }; -/* This equals 1525 * 2^16 + 57600 */ -static const LITTLENUM_TYPE plus_4 [] = { 57600, 1525 }; - -/* This approaches 1e-16 */ -static const LITTLENUM_TYPE minus_5 [] = { - 22199, 45957, 17005, 26266, 10526, 16260, 55017, 35680, 40443, 19789, - 17356, 30195, 55905, 28426, 63010, 44197, 1844 }; -static const LITTLENUM_TYPE plus_5 [] = { 28609, 34546, 35 }; - -static const LITTLENUM_TYPE minus_6 [] = { - 30926, 26518, 13110, 43018, 54982, 48258, 24658, 15209, 63366, 11929, - 20069, 43857, 60487, 51 }; -static const LITTLENUM_TYPE plus_6 [] = { 61313, 34220, 16731, 11629, 1262 }; - -static const LITTLENUM_TYPE minus_7 [] = { - 29819, 14733, 21490, 40602, 31315, 65186, 2695 }; -static const LITTLENUM_TYPE plus_7 [] = { - 7937, 49002, 60772, 28216, 38893, 55975, 63988, 59711, 20227, 24 }; - -static const LITTLENUM_TYPE minus_8 [] = { - 45849, 19069, 18068, 36324, 37948, 48745, 10873, 64360, 15961, 20566, - 24178, 15922, 59427, 110 }; -static const LITTLENUM_TYPE plus_8 [] = { - 15873, 11925, 39177, 991, 14589, 19735, 25347, 65086, 53853, 938, - 37209, 47086, 33626, 23253, 32586, 42547, 9731, 59679, 590 }; - -static const LITTLENUM_TYPE minus_9 [] = { - 63601, 55221, 43562, 33661, 29067, 28203, 65417, 64352, 22462, 41110, - 12570, 28635, 23199, 50572, 28471, 27074, 46375, 64028, 13106, 63700, - 32698, 17493, 32420, 34382, 22750, 20681, 12300 }; -static const LITTLENUM_TYPE plus_9 [] = { - 63564, 61556, 29377, 54467, 18621, 28141, 36415, 61241, 47119, 30026, - 19740, 46002, 13541, 61413, 30480, 38664, 32205, 50593, 51112, 48904, - 48263, 43814, 286, 30826, 52813, 62575, 61390, 24540, 21495, 5 }; - -static const LITTLENUM_TYPE minus_10 [] = { - 50313, 34681, 1464, 25889, 19575, 41125, 17635, 4598, 49708, 13427, - 17287, 56115, 53783, 38255, 32415, 17778, 31596, 7557, 20951, 18477, - 40353, 1178, 44405, 11837, 11571, 50963, 15649, 11698, 40675, 2308, }; -static const LITTLENUM_TYPE plus_10[] = { -18520, 53764, 54535, 61910, 61962, 59843, 46270, 58053, 12473, 63785, - 2449, 43230, 50044, 47595, 10403, 35766, 32607, 1124, 24966, 35044, -25524, 23631, 18826, 14518, 58448, 14562, 49618, 5588, 25396, 28 }; - -static const LITTLENUM_TYPE minus_11 [] = { - 6223, 59909, 62437, 59960, 14652, 45336, 48800, 7647, 51962, 37982, - 60436, 58176, 26767, 8440, 9831, 48556, 20994, 14148, 6757, 17221, - 60624, 46129, 53210, 44085, 54016, 24259, 11232, 21229, 21313, 81, }; -static const LITTLENUM_TYPE plus_11 [] = { - 36159, 2055, 33615, 61362, 23581, 62454, 9748, 15275, 39284, 58636, - 16269, 42793, 47240, 45774, 50861, 48400, 9413, 40281, 4030, 9572, - 7984, 33038, 59522, 19450, 40593, 24486, 54320, 6661, 55766, 805, }; - -/* Shut up complaints about differing pointer types. They only differ - in the const attribute, but there isn't any easy way to do this - */ -#define X (LITTLENUM_TYPE *) - -const FLONUM_TYPE flonum_negative_powers_of_ten [] = { - {X zero, X zero, X zero, 0, '+'}, - {X minus_1, X minus_1 +19, X minus_1 + 19, -20, '+'}, - {X minus_2, X minus_2 +19, X minus_2 + 19, -20, '+'}, - {X minus_3, X minus_3 +19, X minus_3 + 19, -20, '+'}, - {X minus_4, X minus_4 +18, X minus_4 + 18, -20, '+'}, - {X minus_5, X minus_5 +16, X minus_5 + 16, -20, '+'}, - {X minus_6, X minus_6 +13, X minus_6 + 13, -20, '+'}, - {X minus_7, X minus_7 + 6, X minus_7 + 6, -20, '+'}, - {X minus_8, X minus_8 +13, X minus_8 + 13, -40, '+'}, - {X minus_9, X minus_9 +26, X minus_9 + 26, -80, '+'}, - {X minus_10, X minus_10+29, X minus_10 + 29,-136, '+'}, - {X minus_11, X minus_11+29, X minus_11 + 29,-242, '+'}, -}; - -const FLONUM_TYPE flonum_positive_powers_of_ten [] = { - {X zero, X zero, X zero, 0, '+'}, - {X plus_1, X plus_1 + 0, X plus_1 + 0, 0, '+'}, - {X plus_2, X plus_2 + 0, X plus_2 + 0, 0, '+'}, - {X plus_3, X plus_3 + 0, X plus_3 + 0, 0, '+'}, - {X plus_4, X plus_4 + 1, X plus_4 + 1, 0, '+'}, - {X plus_5, X plus_5 + 2, X plus_5 + 2, 1, '+'}, - {X plus_6, X plus_6 + 4, X plus_6 + 4, 2, '+'}, - {X plus_7, X plus_7 + 9, X plus_7 + 9, 4, '+'}, - {X plus_8, X plus_8 + 18, X plus_8 + 18, 8, '+'}, - {X plus_9, X plus_9 + 29, X plus_9 + 29, 24, '+'}, - {X plus_10, X plus_10 + 29, X plus_10 + 29, 77, '+'}, - {X plus_11, X plus_11 + 29, X plus_11 + 29, 183, '+'}, -}; - -#ifdef VMS -dummy1() -{ -} -#endif -/* end: flonum_const.c */ diff --git a/gas/flonum-copy.c b/gas/flonum-copy.c deleted file mode 100644 index 6678bdf250a..00000000000 --- a/gas/flonum-copy.c +++ /dev/null @@ -1,79 +0,0 @@ -/* flonum_copy.c - copy a flonum - Copyright (C) 1987, 1990, 1991 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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 1, or (at your option) -any later version. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* static const char rcsid[] = "$Id$"; */ - -#include "as.h" - -#ifdef USG -#define bzero(s,n) memset(s,0,n) -#define bcopy(from,to,n) memcpy(to,from,n) -#endif - -void -flonum_copy (in, out) - FLONUM_TYPE * in; - FLONUM_TYPE * out; -{ - int in_length; /* 0 origin */ - int out_length; /* 0 origin */ - - out -> sign = in -> sign; - in_length = in -> leader - in -> low; - if (in_length < 0) - { - out -> leader = out -> low - 1; /* 0.0 case */ - } - else - { - out_length = out -> high - out -> low; - /* - * Assume no GAPS in packing of littlenums. - * I.e. sizeof(array) == sizeof(element) * number_of_elements. - */ - if (in_length <= out_length) - { - { - /* - * For defensive programming, zero any high-order littlenums we don't need. - * This is destroying evidence and wasting time, so why bother??? - */ - if (in_length < out_length) - { - bzero ((char *)(out->low + in_length + 1), out_length - in_length); - } - } - bcopy ((char *)(in->low), (char *)(out->low), (int)((in_length + 1) * sizeof(LITTLENUM_TYPE))); - out -> exponent = in -> exponent; - out -> leader = in -> leader - in -> low + out -> low; - } - else - { - int shorten; /* 1-origin. Number of littlenums we drop. */ - - shorten = in_length - out_length; - /* Assume out_length >= 0 ! */ - bcopy ((char *)(in->low + shorten),(char *)( out->low), (int)((out_length + 1) * sizeof(LITTLENUM_TYPE))); - out -> leader = out -> high; - out -> exponent = in -> exponent + shorten; - } - } /* if any significant bits */ -} - -/* end: flonum_copy.c */ diff --git a/gas/flonum-mult.c b/gas/flonum-mult.c deleted file mode 100644 index b01f93ba94e..00000000000 --- a/gas/flonum-mult.c +++ /dev/null @@ -1,201 +0,0 @@ -/* flonum_multip.c - multiply two flonums - Copyright (C) 1987, 1990, 1991 Free Software Foundation, Inc. - -This file is part of Gas, the GNU Assembler. - -The GNU assembler is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY. No author or distributor -accepts responsibility to anyone for the consequences of using it -or for whether it serves any particular purpose or works at all, -unless he says so in writing. Refer to the GNU Assembler General -Public License for full details. - -Everyone is granted permission to copy, modify and redistribute -the GNU Assembler, but only under the conditions described in the -GNU Assembler General Public License. A copy of this license is -supposed to have been given to you along with the GNU Assembler -so you can know your rights and responsibilities. It should be -in a file named COPYING. Among other things, the copyright -notice and this notice must be preserved on all copies. */ - -/* static const char rcsid[] = "$Id$"; */ - -#include "flonum.h" - -/* plan for a . b => p(roduct) - - - +-------+-------+-/ /-+-------+-------+ - | a | a | ... | a | a | - | A | A-1 | | 1 | 0 | - +-------+-------+-/ /-+-------+-------+ - - - +-------+-------+-/ /-+-------+-------+ - | b | b | ... | b | b | - | B | B-1 | | 1 | 0 | - +-------+-------+-/ /-+-------+-------+ - - - +-------+-------+-/ /-+-------+-/ /-+-------+-------+ - | p | p | ... | p | ... | p | p | - | A+B+1| A+B | | N | | 1 | 0 | - +-------+-------+-/ /-+-------+-/ /-+-------+-------+ - - /^\ - (carry) a .b ... | ... a .b a .b - A B | 0 1 0 0 - | - ... | ... a .b - | 1 0 - | - | ... - | - | - | - | ___ - | \ - +----- P = > a .b - N /__ i j - - N = 0 ... A+B - - for all i,j where i+j=N - [i,j integers > 0] - -a[], b[], p[] may not intersect. -Zero length factors signify 0 significant bits: treat as 0.0. -0.0 factors do the right thing. -Zero length product OK. - -I chose the ForTran accent "foo[bar]" instead of the C accent "*garply" -because I felt the ForTran way was more intuitive. The C way would -probably yield better code on most C compilers. Dean Elsner. -(C style also gives deeper insight [to me] ... oh well ...) -*/ - -void flonum_multip (a, b, product) -const FLONUM_TYPE *a; -const FLONUM_TYPE *b; -FLONUM_TYPE *product; -{ - int size_of_a; /* 0 origin */ - int size_of_b; /* 0 origin */ - int size_of_product; /* 0 origin */ - int size_of_sum; /* 0 origin */ - int extra_product_positions;/* 1 origin */ - unsigned long work; - unsigned long carry; - long exponent; - LITTLENUM_TYPE * q; - long significant; /* TRUE when we emit a non-0 littlenum */ - /* ForTran accent follows. */ - int P; /* Scan product low-order -> high. */ - int N; /* As in sum above. */ - int A; /* Which [] of a? */ - int B; /* Which [] of b? */ - - if((a->sign!='-' && a->sign!='+') || (b->sign!='-' && b->sign!='+')) { - /* ... - Got to fail somehow. Any suggestions? */ - product->sign=0; - return; - } - product -> sign = (a->sign == b->sign) ? '+' : '-'; - size_of_a = a -> leader - a -> low; - size_of_b = b -> leader - b -> low; - exponent = a -> exponent + b -> exponent; - size_of_product = product -> high - product -> low; - size_of_sum = size_of_a + size_of_b; - extra_product_positions = size_of_product - size_of_sum; - if (extra_product_positions < 0) - { - P = extra_product_positions; /* P < 0 */ - exponent -= extra_product_positions; /* Increases exponent. */ - } - else - { - P = 0; - } - carry = 0; - significant = 0; - for (N = 0; - N <= size_of_sum; - N++) - { - work = carry; - carry = 0; - for (A = 0; - A <= N; - A ++) - { - B = N - A; - if (A <= size_of_a && B <= size_of_b && B >= 0) - { -#ifdef TRACE -printf("a:low[%d.]=%04x b:low[%d.]=%04x work_before=%08x\n", A, a->low[A], B, b->low[B], work); -#endif - work += a -> low [A] * b -> low [B]; - carry += work >> LITTLENUM_NUMBER_OF_BITS; - work &= LITTLENUM_MASK; -#ifdef TRACE -printf("work=%08x carry=%04x\n", work, carry); -#endif - } - } - significant |= work; - if (significant || P<0) - { - if (P >= 0) - { - product -> low [P] = work; -#ifdef TRACE -printf("P=%d. work[p]:=%04x\n", P, work); -#endif - } - P ++; - } - else - { - extra_product_positions ++; - exponent ++; - } - } - /* - * [P]-> position # size_of_sum + 1. - * This is where 'carry' should go. - */ -#ifdef TRACE -printf("final carry =%04x\n", carry); -#endif - if (carry) - { - if (extra_product_positions > 0) - { - product -> low [P] = carry; - } - else - { - /* No room at high order for carry littlenum. */ - /* Shift right 1 to make room for most significant littlenum. */ - exponent ++; - P --; - for (q = product -> low + P; - q >= product -> low; - q --) - { - work = * q; - * q = carry; - carry = work; - } - } - } - else - { - P --; - } - product -> leader = product -> low + P; - product -> exponent = exponent; -} - -/* end: flonum_multip.c */ diff --git a/gas/flonum.h b/gas/flonum.h deleted file mode 100644 index 570bd3acfd2..00000000000 --- a/gas/flonum.h +++ /dev/null @@ -1,122 +0,0 @@ -/* flonum.h - Floating point package - Copyright (C) 1987, 1990, 1991 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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 1, or (at your option) -any later version. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* $Id$ */ - -/***********************************************************************\ -* * -* Arbitrary-precision floating point arithmetic. * -* * -* * -* Notation: a floating point number is expressed as * -* MANTISSA * (2 ** EXPONENT). * -* * -* If this offends more traditional mathematicians, then * -* please tell me your nomenclature for flonums! * -* * -\***********************************************************************/ -#if !defined(__STDC__) && !defined(const) -#define const /* empty */ -#endif - -#include "bignum.h" - -/***********************************************************************\ -* * -* Variable precision floating point numbers. * -* * -* Exponent is the place value of the low littlenum. E.g.: * -* If 0: low points to the units littlenum. * -* If 1: low points to the LITTLENUM_RADIX littlenum. * -* If -1: low points to the 1/LITTLENUM_RADIX littlenum. * -* * -\***********************************************************************/ - -/* JF: A sign value of 0 means we have been asked to assemble NaN - A sign value of 'P' means we've been asked to assemble +Inf - A sign value of 'N' means we've been asked to assemble -Inf - */ -struct FLONUM_STRUCT -{ - LITTLENUM_TYPE * low; /* low order littlenum of a bignum */ - LITTLENUM_TYPE * high; /* high order littlenum of a bignum */ - LITTLENUM_TYPE * leader; /* -> 1st non-zero littlenum */ - /* If flonum is 0.0, leader==low-1 */ - long exponent; /* base LITTLENUM_RADIX */ - char sign; /* '+' or '-' */ -}; - -typedef struct FLONUM_STRUCT FLONUM_TYPE; - - -/***********************************************************************\ -* * -* Since we can (& do) meet with exponents like 10^5000, it * -* is silly to make a table of ~ 10,000 entries, one for each * -* power of 10. We keep a table where item [n] is a struct * -* FLONUM_FLOATING_POINT representing 10^(2^n). We then * -* multiply appropriate entries from this table to get any * -* particular power of 10. For the example of 10^5000, a table * -* of just 25 entries suffices: 10^(2^-12)...10^(2^+12). * -* * -\***********************************************************************/ - - -extern const FLONUM_TYPE flonum_positive_powers_of_ten[]; -extern const FLONUM_TYPE flonum_negative_powers_of_ten[]; -extern const int table_size_of_flonum_powers_of_ten; - /* Flonum_XXX_powers_of_ten[] table has */ - /* legal indices from 0 to */ - /* + this number inclusive. */ - - - -/***********************************************************************\ -* * -* Declare worker functions. * -* * -\***********************************************************************/ - -#ifdef __STDC__ - -int atof_generic(char **address_of_string_pointer, - const char *string_of_decimal_marks, - const char *string_of_decimal_exponent_marks, - FLONUM_TYPE *address_of_generic_floating_point_number); - -void flonum_copy(FLONUM_TYPE *in, FLONUM_TYPE *out); -void flonum_multip(const FLONUM_TYPE *a, const FLONUM_TYPE *b, FLONUM_TYPE *product); - -#else /* __STDC__ */ - -int atof_generic(); -void flonum_copy(); -void flonum_multip(); - -#endif /* __STDC__ */ - -/***********************************************************************\ -* * -* Declare error codes. * -* * -\***********************************************************************/ - -#define ERROR_EXPONENT_OVERFLOW (2) - -/* end: flonum.h */ diff --git a/gas/frags.c b/gas/frags.c deleted file mode 100644 index 3526603f1ed..00000000000 --- a/gas/frags.c +++ /dev/null @@ -1,285 +0,0 @@ -/* frags.c - manage frags - - Copyright (C) 1987, 1990, 1991 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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 1, or (at your option) -any later version. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* static const char rcsid[] = "$Id$"; */ - -#include "as.h" -#include "subsegs.h" -#include "obstack.h" - -struct obstack frags; /* All, and only, frags live here. */ - -fragS zero_address_frag = { - 0, /* fr_address */ - NULL, /* fr_next */ - 0, /* fr_fix */ - 0, /* fr_var */ - 0, /* fr_symbol */ - 0, /* fr_offset */ - NULL, /* fr_opcode */ - rs_fill, /* fr_type */ - 0, /* fr_subtype */ - 0, /* fr_pcrel_adjust */ - 0, /* fr_bsr */ - 0 /* fr_literal [0] */ -}; - -fragS bss_address_frag = { - 0, /* fr_address. Gets filled in to make up - sy_value-s. */ - NULL, /* fr_next */ - 0, /* fr_fix */ - 0, /* fr_var */ - 0, /* fr_symbol */ - 0, /* fr_offset */ - NULL, /* fr_opcode */ - rs_fill, /* fr_type */ - 0, /* fr_subtype */ - 0, /* fr_pcrel_adjust */ - 0, /* fr_bsr */ - 0 /* fr_literal [0] */ -}; - -/* - * frag_grow() - * - * Internal. - * Try to augment current frag by nchars chars. - * If there is no room, close of the current frag with a ".fill 0" - * and begin a new frag. Unless the new frag has nchars chars available - * do not return. Do not set up any fields of *now_frag. - */ -static void frag_grow(nchars) -unsigned int nchars; -{ - if (obstack_room (&frags) < nchars) { - unsigned int n,oldn; - long oldc; - - frag_wane(frag_now); - frag_new(0); - oldn=(unsigned)-1; - oldc=frags.chunk_size; - frags.chunk_size=2*nchars; - while((n=obstack_room(&frags))fr_fix = (char *) (obstack_next_free (&frags)) - - (frag_now->fr_literal) - old_frags_var_max_size; - /* Fix up old frag's fr_fix. */ - - obstack_finish (&frags); - /* This will align the obstack so the */ - /* next struct we allocate on it will */ - /* begin at a correct boundary. */ - frchP = frchain_now; - know (frchP); - former_last_fragP = frchP->frch_last; - know (former_last_fragP); - know (former_last_fragP == frag_now); - obstack_blank (&frags, SIZEOF_STRUCT_FRAG); - /* We expect this will begin at a correct */ - /* boundary for a struct. */ - tmp=obstack_alignment_mask(&frags); - obstack_alignment_mask(&frags)=0; /* Turn off alignment */ - /* If we ever hit a machine - where strings must be - aligned, we Lose Big */ - frag_now=(fragS *)obstack_finish(&frags); - obstack_alignment_mask(&frags)=tmp; /* Restore alignment */ - - /* Just in case we don't get zero'd bytes */ - bzero(frag_now, SIZEOF_STRUCT_FRAG); - -/* obstack_unaligned_done (&frags, &frag_now); */ -/* know (frags.obstack_c_next_free == frag_now->fr_literal); */ - /* Generally, frag_now->points to an */ - /* address rounded up to next alignment. */ - /* However, characters will add to obstack */ - /* frags IMMEDIATELY after the struct frag, */ - /* even if they are not starting at an */ - /* alignment address. */ - former_last_fragP->fr_next = frag_now; - frchP->frch_last = frag_now; - frag_now->fr_next = NULL; -} /* frag_new() */ - -/* - * frag_more() - * - * Start a new frag unless we have n more chars of room in the current frag. - * Close off the old frag with a .fill 0. - * - * Return the address of the 1st char to write into. Advance - * frag_now_growth past the new chars. - */ - -char *frag_more (nchars) -int nchars; -{ - register char *retval; - - frag_grow (nchars); - retval = obstack_next_free (&frags); - obstack_blank_fast (&frags, nchars); - return (retval); -} /* frag_more() */ - -/* - * frag_var() - * - * Start a new frag unless we have max_chars more chars of room in the current frag. - * Close off the old frag with a .fill 0. - * - * Set up a machine_dependent relaxable frag, then start a new frag. - * Return the address of the 1st char of the var part of the old frag - * to write into. - */ - -char *frag_var(type, max_chars, var, subtype, symbol, offset, opcode) -relax_stateT type; -int max_chars; -int var; -relax_substateT subtype; -symbolS *symbol; -long offset; -char *opcode; -{ - register char *retval; - - frag_grow (max_chars); - retval = obstack_next_free (&frags); - obstack_blank_fast (&frags, max_chars); - frag_now->fr_var = var; - frag_now->fr_type = type; - frag_now->fr_subtype = subtype; - frag_now->fr_symbol = symbol; - frag_now->fr_offset = offset; - frag_now->fr_opcode = opcode; - /* default these to zero. */ - frag_now->fr_pcrel_adjust = 0; - frag_now->fr_bsr = 0; - frag_new (max_chars); - return (retval); -} /* frag_var() */ - -/* - * frag_variant() - * - * OVE: This variant of frag_var assumes that space for the tail has been - * allocated by caller. - * No call to frag_grow is done. - * Two new arguments have been added. - */ - -char *frag_variant(type, max_chars, var, subtype, symbol, offset, opcode, pcrel_adjust,bsr) - relax_stateT type; - int max_chars; - int var; - relax_substateT subtype; - symbolS *symbol; - long offset; - char *opcode; - int pcrel_adjust; - char bsr; -{ - register char *retval; - -/* frag_grow (max_chars); */ - retval = obstack_next_free (&frags); -/* obstack_blank_fast (&frags, max_chars); */ /* OVE: so far the only diff */ - frag_now->fr_var = var; - frag_now->fr_type = type; - frag_now->fr_subtype = subtype; - frag_now->fr_symbol = symbol; - frag_now->fr_offset = offset; - frag_now->fr_opcode = opcode; - frag_now->fr_pcrel_adjust = pcrel_adjust; - frag_now->fr_bsr = bsr; - frag_new (max_chars); - return (retval); -} /* frag_variant() */ - -/* - * frag_wane() - * - * Reduce the variable end of a frag to a harmless state. - */ -void frag_wane(fragP) -register fragS * fragP; -{ - fragP->fr_type = rs_fill; - fragP->fr_offset = 0; - fragP->fr_var = 0; -} - -/* - * frag_align() - * - * Make a frag for ".align foo,bar". Call is "frag_align (foo,bar);". - * Foo & bar are absolute integers. - * - * Call to close off the current frag with a ".align", then start a new - * (so far empty) frag, in the same subsegment as the last frag. - */ - -void frag_align(alignment, fill_character) -int alignment; -int fill_character; -{ - *(frag_var (rs_align, 1, 1, (relax_substateT)0, (symbolS *)0, - (long)alignment, (char *)0)) = fill_character; -} /* frag_align() */ - -/* end: frags.c */ diff --git a/gas/frags.h b/gas/frags.h deleted file mode 100644 index aa089951117..00000000000 --- a/gas/frags.h +++ /dev/null @@ -1,84 +0,0 @@ -/* frags.h - Header file for the frag concept. - Copyright (C) 1987 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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 1, or (at your option) -any later version. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -extern struct obstack frags; - /* Frags ONLY live in this obstack. */ - /* We use obstack_next_free() macro */ - /* so please don't put any other objects */ - /* on this stack! */ - -/* - * A macro to speed up appending exactly 1 char - * to current frag. - */ -/* JF changed < 1 to <= 1 to avoid a race conditon */ -#define FRAG_APPEND_1_CHAR(datum) \ -{ \ - if (obstack_room( &frags ) <= 1) {\ - frag_wane (frag_now); \ - frag_new (0); \ - } \ - obstack_1grow( &frags, datum ); \ -} - - -#ifdef __STDC__ - -char *frag_more(int nchars); -void frag_align(int alignment, int fill_character); -void frag_new(int old_frags_var_max_size); -void frag_wane(fragS *fragP); - -char *frag_variant(relax_stateT type, - int max_chars, - int var, - relax_substateT subtype, - symbolS *symbol, - long offset, - char *opcode, - int pcrel_adjust, - int bsr); - -char *frag_var(relax_stateT type, - int max_chars, - int var, - relax_substateT subtype, - symbolS *symbol, - long offset, - char *opcode); - -#else /* __STDC__ */ - -char *frag_more(); -char *frag_var(); -char *frag_variant(); -void frag_align(); -void frag_new(); -void frag_wane(); - -#endif /* __STDC__ */ - -/* - * Local Variables: - * comment-column: 0 - * fill-column: 131 - * End: - */ - -/* end: frags.h */ diff --git a/gas/hash.c b/gas/hash.c deleted file mode 100644 index b57ba9ef25b..00000000000 --- a/gas/hash.c +++ /dev/null @@ -1,990 +0,0 @@ -/* hash.c - hash table lookup strings - - Copyright (C) 1987, 1990, 1991 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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 1, or (at your option) -any later version. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* static const char rcsid[] = "$Id$"; */ - -/* - * BUGS, GRIPES, APOLOGIA etc. - * - * A typical user doesn't need ALL this: I intend to make a library out - * of it one day - Dean Elsner. - * Also, I want to change the definition of a symbol to (address,length) - * so I can put arbitrary binary in the names stored. [see hsh.c for that] - * - * This slime is common coupled inside the module. Com-coupling (and other - * vandalism) was done to speed running time. The interfaces at the - * module's edges are adequately clean. - * - * There is no way to (a) run a test script through this heap and (b) - * compare results with previous scripts, to see if we have broken any - * code. Use GNU (f)utilities to do this. A few commands assist test. - * The testing is awkward: it tries to be both batch & interactive. - * For now, interactive rules! - */ - -/* - * The idea is to implement a symbol table. A test jig is here. - * Symbols are arbitrary strings; they can't contain '\0'. - * [See hsh.c for a more general symbol flavour.] - * Each symbol is associated with a char*, which can point to anything - * you want, allowing an arbitrary property list for each symbol. - * - * The basic operations are: - * - * new creates symbol table, returns handle - * find (symbol) returns char* - * insert (symbol,char*) error if symbol already in table - * delete (symbol) returns char* if symbol was in table - * apply so you can delete all symbols before die() - * die destroy symbol table (free up memory) - * - * Supplementary functions include: - * - * say how big? what % full? - * replace (symbol,newval) report previous value - * jam (symbol,value) assert symbol:=value - * - * You, the caller, have control over errors: this just reports them. - * - * This package requires malloc(), free(). - * Malloc(size) returns NULL or address of char[size]. - * Free(address) frees same. - */ - -/* - * The code and its structures are re-enterent. - * Before you do anything else, you must call hash_new() which will - * return the address of a hash-table-control-block (or NULL if there - * is not enough memory). You then use this address as a handle of the - * symbol table by passing it to all the other hash_...() functions. - * The only approved way to recover the memory used by the symbol table - * is to call hash_die() with the handle of the symbol table. - * - * Before you call hash_die() you normally delete anything pointed to - * by individual symbols. After hash_die() you can't use that symbol - * table again. - * - * The char* you associate with a symbol may not be NULL (0) because - * NULL is returned whenever a symbol is not in the table. Any other - * value is OK, except DELETED, #defined below. - * - * When you supply a symbol string for insertion, YOU MUST PRESERVE THE - * STRING until that symbol is deleted from the table. The reason is that - * only the address you supply, NOT the symbol string itself, is stored - * in the symbol table. - * - * You may delete and add symbols arbitrarily. - * Any or all symbols may have the same 'value' (char *). In fact, these - * routines don't do anything with your symbol values. - * - * You have no right to know where the symbol:char* mapping is stored, - * because it moves around in memory; also because we may change how it - * works and we don't want to break your code do we? However the handle - * (address of struct hash_control) is never changed in - * the life of the symbol table. - * - * What you CAN find out about a symbol table is: - * how many slots are in the hash table? - * how many slots are filled with symbols? - * (total hashes,collisions) for (reads,writes) (*) - * All of the above values vary in time. - * (*) some of these numbers will not be meaningful if we change the - * internals. - */ - -/* - * I N T E R N A L - * - * Hash table is an array of hash_entries; each entry is a pointer to a - * a string and a user-supplied value 1 char* wide. - * - * The array always has 2 ** n elements, n>0, n integer. - * There is also a 'wall' entry after the array, which is always empty - * and acts as a sentinel to stop running off the end of the array. - * When the array gets too full, we create a new array twice as large - * and re-hash the symbols into the new array, then forget the old array. - * (Of course, we copy the values into the new array before we junk the - * old array!) - * - */ - -#include - -#ifndef FALSE -#define FALSE (0) -#define TRUE (!FALSE) -#endif /* no FALSE yet */ - -#include -#define min(a, b) ((a) < (b) ? (a) : (b)) - -#include "as.h" - -#define error as_fatal - -#define DELETED ((char *)1) /* guarenteed invalid address */ -#define START_POWER (11) /* power of two: size of new hash table *//* JF was 6 */ -/* JF These next two aren't used any more. */ -/* #define START_SIZE (64) / * 2 ** START_POWER */ -/* #define START_FULL (32) / * number of entries before table expands */ -#define islive(ptr) (ptr->hash_string && ptr->hash_string!=DELETED) - /* above TRUE if a symbol is in entry @ ptr */ - -#define STAT_SIZE (0) /* number of slots in hash table */ - /* the wall does not count here */ - /* we expect this is always a power of 2 */ -#define STAT_ACCESS (1) /* number of hash_ask()s */ -#define STAT__READ (0) /* reading */ -#define STAT__WRITE (1) /* writing */ -#define STAT_COLLIDE (3) /* number of collisions (total) */ - /* this may exceed STAT_ACCESS if we have */ - /* lots of collisions/access */ -#define STAT_USED (5) /* slots used right now */ -#define STATLENGTH (6) /* size of statistics block */ -#if STATLENGTH != HASH_STATLENGTH -Panic! Please make #include "stat.h" agree with previous definitions! -#endif - -/* #define SUSPECT to do runtime checks */ -/* #define TEST to be a test jig for hash...() */ - -#ifdef TEST /* TEST: use smaller hash table */ -#undef START_POWER -#define START_POWER (3) -#undef START_SIZE -#define START_SIZE (8) -#undef START_FULL -#define START_FULL (4) -#endif - -/*------------------ plan ---------------------------------- i = internal - -struct hash_control * c; -struct hash_entry * e; i -int b[z]; buffer for statistics - z size of b -char * s; symbol string (address) [ key ] -char * v; value string (address) [datum] -boolean f; TRUE if we found s in hash table i -char * t; error string; "" means OK -int a; access type [0...n) i - -c=hash_new () create new hash_control - -hash_die (c) destroy hash_control (and hash table) - table should be empty. - doesn't check if table is empty. - c has no meaning after this. - -hash_say (c,b,z) report statistics of hash_control. - also report number of available statistics. - -v=hash_delete (c,s) delete symbol, return old value if any. - ask() NULL means no old value. - f - -v=hash_replace (c,s,v) replace old value of s with v. - ask() NULL means no old value: no table change. - f - -t=hash_insert (c,s,v) insert (s,v) in c. - ask() return error string. - f it is an error to insert if s is already - in table. - if any error, c is unchanged. - -t=hash_jam (c,s,v) assert that new value of s will be v. i - ask() it may decide to GROW the table. i - f i - grow() i -t=hash_grow (c) grow the hash table. i - jam() will invoke JAM. i - -?=hash_apply (c,y) apply y() to every symbol in c. - y evtries visited in 'unspecified' order. - -v=hash_find (c,s) return value of s, or NULL if s not in c. - ask() - f - -f,e=hash_ask() (c,s,a) return slot where s SHOULD live. i - code() maintain collision stats in c. i - -.=hash_code (c,s) compute hash-code for s, i - from parameters of c. i - -*/ - -static char hash_found; /* returned by hash_ask() to stop extra */ - /* testing. hash_ask() wants to return both */ - /* a slot and a status. This is the status. */ - /* TRUE: found symbol */ - /* FALSE: absent: empty or deleted slot */ - /* Also returned by hash_jam(). */ - /* TRUE: we replaced a value */ - /* FALSE: we inserted a value */ - -static struct hash_entry * hash_ask(); -static int hash_code (); -static char * hash_grow(); - -/* - * h a s h _ n e w ( ) - * - */ -struct hash_control * -hash_new() /* create a new hash table */ - /* return NULL if failed */ - /* return handle (address of struct hash) */ -{ - register struct hash_control * retval; - register struct hash_entry * room; /* points to hash table */ - register struct hash_entry * wall; - register struct hash_entry * entry; - register int * ip; /* scan stats block of struct hash_control */ - register int * nd; /* limit of stats block */ - - if (( room = (struct hash_entry *) malloc( sizeof(struct - hash_entry)*((1<hash_stat + STATLENGTH; - for (ip=retval->hash_stat; ip hash_stat[STAT_SIZE] = 1< hash_mask = (1< hash_sizelog = START_POWER; - /* works for 1's compl ok */ - retval -> hash_where = room; - retval -> hash_wall = - wall = room + (1< hash_full = (1<hash_string = NULL; - } - } - } - else - { - retval = NULL; /* no room for table: fake a failure */ - } - return(retval); /* return NULL or set-up structs */ -} - -/* - * h a s h _ d i e ( ) - * - * Table should be empty, but this is not checked. - * To empty the table, try hash_apply()ing a symbol deleter. - * Return to free memory both the hash table and it's control - * block. - * 'handle' has no meaning after this function. - * No errors are recoverable. - */ -void -hash_die(handle) - struct hash_control * handle; -{ - free((char *)handle->hash_where); - free((char *)handle); -} - -/* - * h a s h _ s a y ( ) - * - * Return the size of the statistics table, and as many statistics as - * we can until either (a) we have run out of statistics or (b) caller - * has run out of buffer. - * NOTE: hash_say treats all statistics alike. - * These numbers may change with time, due to insertions, deletions - * and expansions of the table. - * The first "statistic" returned is the length of hash_stat[]. - * Then contents of hash_stat[] are read out (in ascending order) - * until your buffer or hash_stat[] is exausted. - */ -void -hash_say(handle,buffer,bufsiz) - register struct hash_control * handle; - register int buffer[/*bufsiz*/]; - register int bufsiz; -{ - register int * nd; /* limit of statistics block */ - register int * ip; /* scan statistics */ - - ip = handle -> hash_stat; - nd = ip + min(bufsiz-1,STATLENGTH); - if (bufsiz>0) /* trust nothing! bufsiz<=0 is dangerous */ - { - *buffer++ = STATLENGTH; - for (; ip hash_value; - entry -> hash_string = DELETED; /* mark as deleted */ - handle -> hash_stat[STAT_USED] -= 1; /* slots-in-use count */ -#ifdef SUSPECT - if (handle->hash_stat[STAT_USED]<0) - { - error("hash_delete"); - } -#endif /* def SUSPECT */ - } - else - { - retval = NULL; - } - return(retval); -} - -/* - * h a s h _ r e p l a c e ( ) - * - * Try to replace the old value of a symbol with a new value. - * Normally return the old value. - * Return NULL and don't change the table if the symbol is not already - * in the table. - */ -char * -hash_replace(handle,string,value) - register struct hash_control * handle; - register char * string; - register char * value; -{ - register struct hash_entry * entry; - register char * retval; - - entry = hash_ask(handle,string,STAT__WRITE); - if (hash_found) - { - retval = entry -> hash_value; - entry -> hash_value = value; - } - else - { - retval = NULL; - } - ; - return (retval); -} - -/* - * h a s h _ i n s e r t ( ) - * - * Insert a (symbol-string, value) into the hash table. - * Return an error string, "" means OK. - * It is an 'error' to insert an existing symbol. - */ - -char * /* return error string */ -hash_insert(handle,string,value) - register struct hash_control * handle; - register char * string; - register char * value; -{ - register struct hash_entry * entry; - register char * retval; - - retval = ""; - if (handle->hash_stat[STAT_USED] > handle->hash_full) - { - retval = hash_grow(handle); - } - if ( ! * retval) - { - entry = hash_ask(handle,string,STAT__WRITE); - if (hash_found) - { - retval = "exists"; - } - else - { - entry -> hash_value = value; - entry -> hash_string = string; - handle-> hash_stat[STAT_USED] += 1; - } - } - return(retval); -} - -/* - * h a s h _ j a m ( ) - * - * Regardless of what was in the symbol table before, after hash_jam() - * the named symbol has the given value. The symbol is either inserted or - * (its value is) relpaced. - * An error message string is returned, "" means OK. - * - * WARNING: this may decide to grow the hashed symbol table. - * To do this, we call hash_grow(), WHICH WILL recursively CALL US. - * - * We report status internally: hash_found is TRUE if we replaced, but - * false if we inserted. - */ -char * -hash_jam(handle,string,value) - register struct hash_control * handle; - register char * string; - register char * value; -{ - register char * retval; - register struct hash_entry * entry; - - retval = ""; - if (handle->hash_stat[STAT_USED] > handle->hash_full) - { - retval = hash_grow(handle); - } - if (! * retval) - { - entry = hash_ask(handle,string,STAT__WRITE); - if ( ! hash_found) - { - entry -> hash_string = string; - handle->hash_stat[STAT_USED] += 1; - } - entry -> hash_value = value; - } - return(retval); -} - -/* - * h a s h _ g r o w ( ) - * - * Grow a new (bigger) hash table from the old one. - * We choose to double the hash table's size. - * Return a human-scrutible error string: "" if OK. - * Warning! This uses hash_jam(), which had better not recurse - * back here! Hash_jam() conditionally calls us, but we ALWAYS - * call hash_jam()! - * Internal. - */ -static char * -hash_grow(handle) /* make a hash table grow */ - struct hash_control * handle; -{ - register struct hash_entry * newwall; - register struct hash_entry * newwhere; - struct hash_entry * newtrack; - register struct hash_entry * oldtrack; - register struct hash_entry * oldwhere; - register struct hash_entry * oldwall; - register int temp; - int newsize; - char * string; - char * retval; -#ifdef SUSPECT - int oldused; -#endif - - /* - * capture info about old hash table - */ - oldwhere = handle -> hash_where; - oldwall = handle -> hash_wall; -#ifdef SUSPECT - oldused = handle -> hash_stat[STAT_USED]; -#endif - /* - * attempt to get enough room for a hash table twice as big - */ - temp = handle->hash_stat[STAT_SIZE]; - if (( newwhere = (struct hash_entry *) - xmalloc((long)((temp+temp+1)*sizeof(struct hash_entry)))) != NULL) - /* +1 for wall slot */ - { - retval = ""; /* assume success until proven otherwise */ - /* - * have enough room: now we do all the work. - * double the size of everything in handle, - * note: hash_mask frob works for 1's & for 2's complement machines - */ - handle->hash_mask = handle->hash_mask + handle->hash_mask + 1; - handle->hash_stat[STAT_SIZE] <<= 1; - newsize = handle->hash_stat[STAT_SIZE]; - handle->hash_where = newwhere; - handle->hash_full <<= 1; - handle->hash_sizelog += 1; - handle->hash_stat[STAT_USED] = 0; - handle->hash_wall = - newwall = newwhere + newsize; - /* - * set all those pesky new slots to vacant. - */ - for (newtrack=newwhere; newtrack <= newwall; newtrack++) - { - newtrack -> hash_string = NULL; - } - /* - * we will do a scan of the old table, the hard way, using the - * new control block to re-insert the data into new hash table. - */ - handle -> hash_stat[STAT_USED] = 0; /* inserts will bump it up to correct */ - for (oldtrack=oldwhere; oldtrack < oldwall; oldtrack++) - { - if ( ((string=oldtrack->hash_string) != NULL) && string!=DELETED ) - { - if ( * (retval = hash_jam(handle,string,oldtrack->hash_value) ) ) - { - break; - } - } - } -#ifdef SUSPECT - if ( !*retval && handle->hash_stat[STAT_USED] != oldused) - { - retval = "hash_used"; - } -#endif - if (!*retval) - { - /* - * we have a completely faked up control block. - * return the old hash table. - */ - free((char *)oldwhere); - /* - * Here with success. retval is already "". - */ - } - } - else - { - retval = "no room"; - } - return(retval); -} - -/* - * h a s h _ a p p l y ( ) - * - * Use this to scan each entry in symbol table. - * For each symbol, this calls (applys) a nominated function supplying the - * symbol's value (and the symbol's name). - * The idea is you use this to destroy whatever is associted with - * any values in the table BEFORE you destroy the table with hash_die. - * Of course, you can use it for other jobs; whenever you need to - * visit all extant symbols in the table. - * - * We choose to have a call-you-back idea for two reasons: - * asthetic: it is a neater idea to use apply than an explicit loop - * sensible: if we ever had to grow the symbol table (due to insertions) - * then we would lose our place in the table when we re-hashed - * symbols into the new table in a different order. - * - * The order symbols are visited depends entirely on the hashing function. - * Whenever you insert a (symbol, value) you risk expanding the table. If - * you do expand the table, then the hashing function WILL change, so you - * MIGHT get a different order of symbols visited. In other words, if you - * want the same order of visiting symbols as the last time you used - * hash_apply() then you better not have done any hash_insert()s or - * hash_jam()s since the last time you used hash_apply(). - * - * In future we may use the value returned by your nominated function. - * One idea is to abort the scan if, after applying the function to a - * certain node, the function returns a certain code. - * To be safe, please make your functions of type char *. If you always - * return NULL, then the scan will complete, visiting every symbol in - * the table exactly once. ALL OTHER RETURNED VALUES have no meaning yet! - * Caveat Actor! - * - * The function you supply should be of the form: - * char * myfunct(string,value) - * char * string; |* the symbol's name *| - * char * value; |* the symbol's value *| - * { - * |* ... *| - * return(NULL); - * } - * - * The returned value of hash_apply() is (char*)NULL. In future it may return - * other values. NULL means "completed scan OK". Other values have no meaning - * yet. (The function has no graceful failures.) - */ -char * -hash_apply(handle,function) - struct hash_control * handle; - char* (*function)(); -{ - register struct hash_entry * entry; - register struct hash_entry * wall; - - wall = handle->hash_wall; - for (entry = handle->hash_where; entry < wall; entry++) - { - if (islive(entry)) /* silly code: tests entry->string twice! */ - { - (*function)(entry->hash_string,entry->hash_value); - } - } - return (NULL); -} - -/* - * h a s h _ f i n d ( ) - * - * Given symbol string, find value (if any). - * Return found value or NULL. - */ -char * -hash_find(handle,string) /* return char* or NULL */ - struct hash_control * handle; - char * string; -{ - register struct hash_entry * entry; - register char * retval; - - entry = hash_ask(handle,string,STAT__READ); - if (hash_found) - { - retval = entry->hash_value; - } - else - { - retval = NULL; - } - return(retval); -} - -/* - * h a s h _ a s k ( ) - * - * Searches for given symbol string. - * Return the slot where it OUGHT to live. It may be there. - * Return hash_found: TRUE only if symbol is in that slot. - * Access argument is to help keep statistics in control block. - * Internal. - */ -static struct hash_entry * /* string slot, may be empty or deleted */ -hash_ask(handle,string,access) - struct hash_control * handle; - char * string; - int access; /* access type */ -{ - register char *string1; /* JF avoid strcmp calls */ - register char * s; - register int c; - register struct hash_entry * slot; - register int collision; /* count collisions */ - - slot = handle->hash_where + hash_code(handle,string); /* start looking here */ - handle->hash_stat[STAT_ACCESS+access] += 1; - collision = 0; - hash_found = FALSE; - while ( ((s = slot->hash_string) != NULL) && s!=DELETED ) - { - for(string1=string;;) { - if((c= *s++) == 0) { - if(!*string1) - hash_found = TRUE; - break; - } - if(*string1++!=c) - break; - } - if(hash_found) - break; - collision++; - slot++; - } - /* - * slot: return: - * in use: we found string slot - * at empty: - * at wall: we fell off: wrap round ???? - * in table: dig here slot - * at DELETED: dig here slot - */ - if (slot==handle->hash_wall) - { - slot = handle->hash_where; /* now look again */ - while( ((s = slot->hash_string) != NULL) && s!=DELETED ) - { - for(string1=string;*s;string1++,s++) { - if(*string1!=*s) - break; - } - if(*s==*string1) { - hash_found = TRUE; - break; - } - collision++; - slot++; - } - /* - * slot: return: - * in use: we found it slot - * empty: wall: ERROR IMPOSSIBLE !!!! - * in table: dig here slot - * DELETED:dig here slot - */ - } -/* fprintf(stderr,"hash_ask(%s)->%d(%d)\n",string,hash_code(handle,string),collision); */ - handle -> hash_stat[STAT_COLLIDE+access] += collision; - return(slot); /* also return hash_found */ -} - -/* - * h a s h _ c o d e - * - * Does hashing of symbol string to hash number. - * Internal. - */ -static int -hash_code(handle,string) - struct hash_control * handle; - register char * string; -{ - register long h; /* hash code built here */ - register long c; /* each character lands here */ - register int n; /* Amount to shift h by */ - - n = (handle->hash_sizelog - 3); - h = 0; - while ((c = *string++) != 0) - { - h += c; - h = (h<<3) + (h>>n) + c; - } - return (h & handle->hash_mask); -} - -/* - * Here is a test program to exercise above. - */ -#ifdef TEST - -#define TABLES (6) /* number of hash tables to maintain */ - /* (at once) in any testing */ -#define STATBUFSIZE (12) /* we can have 12 statistics */ - -int statbuf[STATBUFSIZE]; /* display statistics here */ -char answer[100]; /* human farts here */ -char * hashtable[TABLES]; /* we test many hash tables at once */ -char * h; /* points to curent hash_control */ -char ** pp; -char * p; -char * name; -char * value; -int size; -int used; -char command; -int number; /* number 0:TABLES-1 of current hashed */ - /* symbol table */ - -main() -{ - char (*applicatee()); - char * hash_find(); - char * destroy(); - char * what(); - struct hash_control * hash_new(); - char * hash_replace(); - int * ip; - - number = 0; - h = 0; - printf("type h for help\n"); - for(;;) - { - printf("hash_test command: "); - gets(answer); - command = answer[0]; - if (isupper(command)) command = tolower(command); /* ecch! */ - switch (command) - { - case '#': - printf("old hash table #=%d.\n",number); - whattable(); - break; - case '?': - for (pp=hashtable; pp=0 && numberradix-value - - Copyright (C) 1987, 1990, 1991 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* static const char rcsid[] = "$Id$"; */ - -/* - * Export: Hex_value[]. Converts digits to their radix-values. - * As distributed assumes 8 bits per char (256 entries) and ASCII. - */ - -#define __ (42) /* blatently illegal digit value */ - /* exceeds any normal radix */ -#if !defined(__STDC__) && !defined(const) -#define const /* empty */ -#endif -const char -hex_value [256] = { /* for fast ASCII -> binary */ - __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, - __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, - __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, __, __, __, __, __, __, - __, 10, 11, 12, 13, 14, 15, __, __, __, __, __, __, __, __, __, - __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, - __, 10, 11, 12, 13, 14, 15, __, __, __, __, __, __, __, __, __, - __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, - __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, - __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, - __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, - __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, - __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, - __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, - __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, - __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __ - }; - -#ifdef VMS -dummy2() -{ -} -#endif -/* end:hex_value.c */ diff --git a/gas/input-file.c b/gas/input-file.c deleted file mode 100644 index cf1a4c33f51..00000000000 --- a/gas/input-file.c +++ /dev/null @@ -1,322 +0,0 @@ -/* input_file.c - Deal with Input Files - - Copyright (C) 1987, 1990, 1991 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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 1, or (at your option) -any later version. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* static const char rcsid[] = "$Id$"; */ - -/* - * Confines all details of reading source bytes to this module. - * All O/S specific crocks should live here. - * What we lose in "efficiency" we gain in modularity. - * Note we don't need to #include the "as.h" file. No common coupling! - */ - -#ifdef USG -#define setbuffer(stream, buf, size) setvbuf((stream), (buf), _IOFBF, (size)) -#endif - -#include -#include -#include - -#include "as.h" -#include "input-file.h" - -/* This variable is non-zero if the file currently being read should be - preprocessed by app. It is zero if the file can be read straight in. - */ -int preprocess = 0; - -/* - * This code opens a file, then delivers BUFFER_SIZE character - * chunks of the file on demand. - * BUFFER_SIZE is supposed to be a number chosen for speed. - * The caller only asks once what BUFFER_SIZE is, and asks before - * the nature of the input files (if any) is known. - */ - -#define BUFFER_SIZE (32 * 1024) - -/* - * We use static data: the data area is not sharable. - */ - -FILE *f_in; -/* static JF remove static so app.c can use file_name */ -char * file_name; - -/* Struct for saving the state of this module for file includes. */ -struct saved_file { - FILE *f_in; - char *file_name; - int preprocess; - char *app_save; -}; - -/* These hooks accomodate most operating systems. */ - -void input_file_begin() { - f_in = (FILE *)0; -} - -void input_file_end () { } - - /* Return BUFFER_SIZE. */ -int input_file_buffer_size() { - return (BUFFER_SIZE); -} - -int input_file_is_open() { - return f_in!=(FILE *)0; -} - -/* Push the state of our input, returning a pointer to saved info that - can be restored with input_file_pop (). */ -char *input_file_push () { - register struct saved_file *saved; - - saved = (struct saved_file *)xmalloc (sizeof *saved); - - saved->f_in = f_in; - saved->file_name = file_name; - saved->preprocess = preprocess; - if (preprocess) - saved->app_save = app_push (); - - input_file_begin (); /* Initialize for new file */ - - return (char *)saved; -} - -void -input_file_pop (arg) - char *arg; -{ - register struct saved_file *saved = (struct saved_file *)arg; - - input_file_end (); /* Close out old file */ - - f_in = saved->f_in; - file_name = saved->file_name; - preprocess = saved->preprocess; - if (preprocess) - app_pop (saved->app_save); - - free(arg); -} - -#ifdef DONTDEF /* JF save old version in case we need it */ -void -input_file_open (filename, preprocess, debugging) - char * filename; /* "" means use stdin. Must not be 0. */ - int preprocess; /* TRUE if needs app. */ - int debugging; /* TRUE if we are debugging assembler. */ -{ - assert( filename != 0 ); /* Filename may not be NULL. */ - if (filename [0]) - { /* We have a file name. Suck it and see. */ - file_handle = open (filename, O_RDONLY, 0); - file_name = filename; - } - else - { /* use stdin for the input file. */ - file_handle = fileno (stdin); - file_name = "{standard input}"; /* For error messages. */ - } - if (file_handle < 0) - as_perror ("Can't open %s for reading", file_name); - if ( preprocess ) - { -/* - * This code was written in haste for a frobbed BSD 4.2. - * I have a flight to catch: will someone please do proper - * error checks? - Dean. - */ - int pid; - char temporary_file_name [12]; - int fd; - union wait status; - - (void)strcpy (temporary_file_name, "#appXXXXXX"); - (void)mktemp (temporary_file_name); - pid = vfork (); - if (pid == -1) - { - as_perror ("Vfork failed", file_name); - _exit (144); - } - if (pid == 0) - { - (void)dup2 (file_handle, fileno(stdin)); - fd = open (temporary_file_name, O_WRONLY + O_TRUNC + O_CREAT, 0666); - if (fd == -1) - { - (void)write(2,"Can't open temporary\n",21); - _exit (99); - } - (void)dup2 (fd, fileno(stdout)); -/* JF for testing #define PREPROCESSOR "/lib/app" */ -#define PREPROCESSOR "./app" - execl (PREPROCESSOR, PREPROCESSOR, 0); - execl ("app","app",0); - (void)write(2,"Exec of app failed. Get help.\n",31); - (void)unlink(temporary_file_name); - _exit (11); - } - (void)wait (& status); - if (status.w_status & 0xFF00) /* JF was 0xF000, was wrong */ - { - file_handle = -1; - as_bad( "Can't preprocess file \"%s\", status = %xx", file_name, status.w_status ); - } - else - { - file_handle = open (temporary_file_name, O_RDONLY, 0); - if ( ! debugging && unlink(temporary_file_name)) - as_perror ("Can't delete temp file %s", temporary_file_name); - } - if (file_handle == -1) - as_perror ("Can't retrieve temp file %s", temporary_file_name); - } -} -#else - -void -input_file_open (filename,pre) - char * filename; /* "" means use stdin. Must not be 0. */ - int pre; -{ - int c; - char buf[80]; - - preprocess = pre; - - assert( filename != 0 ); /* Filename may not be NULL. */ - if (filename [0]) { /* We have a file name. Suck it and see. */ - f_in=fopen(filename,"r"); - file_name=filename; - } else { /* use stdin for the input file. */ - f_in = stdin; - file_name = "{standard input}"; /* For error messages. */ - } - if (f_in==(FILE *)0) { - as_perror ("Can't open %s for reading", file_name); - return; - } - -#ifndef VMS - /* Ask stdio to buffer our input at BUFFER_SIZE, with a dynamically - allocated buffer. */ - setvbuf(f_in, (char *)NULL, _IOFBF, BUFFER_SIZE); -#endif /* VMS */ - - c = getc(f_in); - if (c == '#') { /* Begins with comment, may not want to preprocess */ - c = getc(f_in); - if (c == 'N') { - fgets(buf,80,f_in); - if (!strcmp(buf,"O_APP\n")) - preprocess=0; - if (!strchr(buf,'\n')) - ungetc('#',f_in); /* It was longer */ - else - ungetc('\n',f_in); - } else if(c=='\n') - ungetc('\n',f_in); - else - ungetc('#',f_in); - } else - ungetc(c,f_in); - -#ifdef DONTDEF - if ( preprocess ) { - char temporary_file_name [17]; - FILE *f_out; - - (void)strcpy (temporary_file_name, "/tmp/#appXXXXXX"); - (void)mktemp (temporary_file_name); - f_out=fopen(temporary_file_name,"w+"); - if(f_out==(FILE *)0) - as_perror("Can't open temp file %s",temporary_file_name); - - /* JF this will have to be moved on any system that - does not support removal of open files. */ - (void)unlink(temporary_file_name);/* JF do it NOW */ - do_scrub(f_in,f_out); - (void)fclose(f_in); /* All done with it */ - (void)rewind(f_out); - f_in=f_out; - } -#endif -} -#endif - -/* Close input file. */ -void input_file_close() { - fclose (f_in); - f_in = 0; -} - -char * -input_file_give_next_buffer (where) - char * where; /* Where to place 1st character of new buffer. */ -{ - char * return_value; /* -> Last char of what we read, + 1. */ - register int size; - - if (f_in == (FILE *)0) - return 0; - /* - * fflush (stdin); could be done here if you want to synchronise - * stdin and stdout, for the case where our input file is stdin. - * Since the assembler shouldn't do any output to stdout, we - * don't bother to synch output and input. - */ - if(preprocess) { - char *p; - int n; - int ch; - extern FILE *scrub_file; - - scrub_file=f_in; - for (p = where, n = BUFFER_SIZE; n; --n) { - - ch = do_scrub_next_char(scrub_from_file, scrub_to_file); - if (ch == EOF) - break; - *p++=ch; - } - size=BUFFER_SIZE-n; - } else - size= fread(where,sizeof(char),BUFFER_SIZE,f_in); - if (size < 0) - { - as_perror ("Can't read from %s", file_name); - size = 0; - } - if (size) - return_value = where + size; - else - { - if (fclose (f_in)) - as_perror ("Can't close %s", file_name); - f_in = (FILE *)0; - return_value = 0; - } - return (return_value); -} diff --git a/gas/input-file.h b/gas/input-file.h deleted file mode 100644 index 703d4c5cd2d..00000000000 --- a/gas/input-file.h +++ /dev/null @@ -1,84 +0,0 @@ -/* input_file.h header for input-file.c - Copyright (C) 1987 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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 1, or (at your option) -any later version. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/*"input_file.c":Operating-system dependant functions to read source files.*/ - - -/* - * No matter what the operating system, this module must provide the - * following services to its callers. - * - * input_file_begin() Call once before anything else. - * - * input_file_end() Call once after everything else. - * - * input_file_buffer_size() Call anytime. Returns largest possible - * delivery from - * input_file_give_next_buffer(). - * - * input_file_open(name) Call once for each input file. - * - * input_file_give_next_buffer(where) Call once to get each new buffer. - * Return 0: no more chars left in file, - * the file has already been closed. - * Otherwise: return a pointer to just - * after the last character we read - * into the buffer. - * If we can only read 0 characters, then - * end-of-file is faked. - * - * input_file_push() Push state, which can be restored - * later. Does implicit input_file_begin. - * Returns char * to saved state. - * - * input_file_pop (arg) Pops previously saved state. - * - * input_file_close () Closes opened file. - * - * All errors are reported (using as_perror) so caller doesn't have to think - * about I/O errors. No I/O errors are fatal: an end-of-file may be faked. - */ - -#ifdef __STDC__ - -char *input_file_give_next_buffer(char *where); -char *input_file_push(void); -int input_file_buffer_size(void); -int input_file_is_open(void); -void input_file_begin(void); -void input_file_close(void); -void input_file_end(void); -void input_file_open(char *filename, int pre); -void input_file_pop(char *arg); - -#else /* __STDC__ */ - -char *input_file_give_next_buffer(); -char *input_file_push(); -int input_file_buffer_size(); -int input_file_is_open(); -void input_file_begin(); -void input_file_close(); -void input_file_end(); -void input_file_open(); -void input_file_pop(); - -#endif /* __STDC__ */ - -/* end: input_file.h */ diff --git a/gas/input-scrub.c b/gas/input-scrub.c deleted file mode 100644 index a710913b1a4..00000000000 --- a/gas/input-scrub.c +++ /dev/null @@ -1,478 +0,0 @@ -/* input_scrub.c - Break up input buffers into whole numbers of lines. - Copyright (C) 1987, 1990, 1991 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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 1, or (at your option) -any later version. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* static const char rcsid[] = "$Id$"; */ - -#include /* Need this to make errno declaration right */ -#include "as.h" -#include "input-file.h" - -/* - * O/S independent module to supply buffers of sanitised source code - * to rest of assembler. We get sanitized input data of arbitrary length. - * We break these buffers on line boundaries, recombine pieces that - * were broken across buffers, and return a buffer of full lines to - * the caller. - * The last partial line begins the next buffer we build and return to caller. - * The buffer returned to caller is preceeded by BEFORE_STRING and followed - * by AFTER_STRING, as sentinels. The last character before AFTER_STRING - * is a newline. - * Also looks after line numbers, for e.g. error messages. - */ - -/* - * We don't care how filthy our buffers are, but our callers assume - * that the following sanitation has already been done. - * - * No comments, reduce a comment to a space. - * Reduce a tab to a space unless it is 1st char of line. - * All multiple tabs and spaces collapsed into 1 char. Tab only - * legal if 1st char of line. - * # line file statements converted to .line x;.file y; statements. - * Escaped newlines at end of line: remove them but add as many newlines - * to end of statement as you removed in the middle, to synch line numbers. - */ - -#define BEFORE_STRING ("\n") -#define AFTER_STRING ("\0") /* bcopy of 0 chars might choke. */ -#define BEFORE_SIZE (1) -#define AFTER_SIZE (1) - -static char * buffer_start; /*->1st char of full buffer area. */ -static char * partial_where; /*->after last full line in buffer. */ -static int partial_size; /* >=0. Number of chars in partial line in buffer. */ -static char save_source [AFTER_SIZE]; - /* Because we need AFTER_STRING just after last */ - /* full line, it clobbers 1st part of partial */ - /* line. So we preserve 1st part of partial */ - /* line here. */ -static int buffer_length; /* What is the largest size buffer that */ - /* input_file_give_next_buffer() could */ - /* return to us? */ - -/* Saved information about the file that .include'd this one. When we - hit EOF, we automatically pop to that file. */ - -static char *next_saved_file; - -/* -We can have more than one source file open at once, though the info for -all but the latest one are saved off in a struct input_save. These -files remain open, so we are limited by the number of open files allowed -by the underlying OS. -We may also sequentially read more than one source file in an assembly. - */ - - -/* -We must track the physical file and line number for error messages. -We also track a "logical" file and line number corresponding to (C?) -compiler source line numbers. -Whenever we open a file we must fill in physical_input_file. So if it is NULL -we have not opened any files yet. - */ - -static -char * physical_input_file, - * logical_input_file; - - - -typedef unsigned int line_numberT; /* 1-origin line number in a source file. */ - /* A line ends in '\n' or eof. */ - -static -line_numberT physical_input_line, - logical_input_line; - -/* Struct used to save the state of the input handler during include files */ -struct input_save { - char *buffer_start; - char *partial_where; - int partial_size; - char save_source [AFTER_SIZE]; - int buffer_length; - char *physical_input_file; - char *logical_input_file; - line_numberT physical_input_line; - line_numberT logical_input_line; - char *next_saved_file; /* Chain of input_saves */ - char *input_file_save; /* Saved state of input routines */ - char *saved_position; /* Caller's saved position in buf */ -}; - -#ifdef __STDC__ -static void as_1_char(unsigned int c, FILE *stream); -#else /* __STDC__ */ -static void as_1_char(); -#endif /* __STDC__ */ - -/* Push the state of input reading and scrubbing so that we can #include. - The return value is a 'void *' (fudged for old compilers) to a save - area, which can be restored by passing it to input_scrub_pop(). */ -char * -input_scrub_push(saved_position) - char *saved_position; -{ - register struct input_save *saved; - - saved = (struct input_save *) xmalloc(sizeof *saved); - - saved->saved_position = saved_position; - saved->buffer_start = buffer_start; - saved->partial_where = partial_where; - saved->partial_size = partial_size; - saved->buffer_length = buffer_length; - saved->physical_input_file = physical_input_file; - saved->logical_input_file = logical_input_file; - saved->physical_input_line = physical_input_line; - saved->logical_input_line = logical_input_line; - bcopy (saved->save_source, save_source, sizeof (save_source)); - saved->next_saved_file = next_saved_file; - saved->input_file_save = input_file_push (); - - input_scrub_begin (); /* Reinitialize! */ - - return (char *)saved; -} - -char * -input_scrub_pop (arg) - char *arg; -{ - register struct input_save *saved; - char *saved_position; - - input_scrub_end (); /* Finish off old buffer */ - - saved = (struct input_save *)arg; - - input_file_pop (saved->input_file_save); - saved_position = saved->saved_position; - buffer_start = saved->buffer_start; - buffer_length = saved->buffer_length; - physical_input_file = saved->physical_input_file; - logical_input_file = saved->logical_input_file; - physical_input_line = saved->physical_input_line; - logical_input_line = saved->logical_input_line; - partial_where = saved->partial_where; - partial_size = saved->partial_size; - next_saved_file = saved->next_saved_file; - bcopy (save_source, saved->save_source, sizeof (save_source)); - - free(arg); - return saved_position; -} - - -void -input_scrub_begin () -{ - know(strlen(BEFORE_STRING) == BEFORE_SIZE); - know(strlen(AFTER_STRING) == AFTER_SIZE - || (AFTER_STRING[0] == '\0' && AFTER_SIZE == 1)); - - input_file_begin (); - - buffer_length = input_file_buffer_size (); - - buffer_start = xmalloc((long)(BEFORE_SIZE + buffer_length + buffer_length + AFTER_SIZE)); - bcopy (BEFORE_STRING, buffer_start, (int)BEFORE_SIZE); - - /* Line number things. */ - logical_input_line = 0; - logical_input_file = (char *)NULL; - physical_input_file = NULL; /* No file read yet. */ - next_saved_file = NULL; /* At EOF, don't pop to any other file */ - do_scrub_begin(); -} - -void -input_scrub_end () -{ - if (buffer_start) - { - free (buffer_start); - buffer_start = 0; - input_file_end (); - } -} - -/* Start reading input from a new file. */ - -char * /* Return start of caller's part of buffer. */ -input_scrub_new_file (filename) - char * filename; -{ - input_file_open (filename, !flagseen['f']); - physical_input_file = filename[0] ? filename : "{standard input}"; - physical_input_line = 0; - - partial_size = 0; - return (buffer_start + BEFORE_SIZE); -} - - -/* Include a file from the current file. Save our state, cause it to - be restored on EOF, and begin handling a new file. Same result as - input_scrub_new_file. */ - -char * -input_scrub_include_file (filename, position) - char *filename; - char *position; -{ - next_saved_file = input_scrub_push (position); - return input_scrub_new_file (filename); -} - -void -input_scrub_close () -{ - input_file_close (); -} -char * -input_scrub_next_buffer (bufp) -char **bufp; -{ - register char * limit; /*->just after last char of buffer. */ - - *bufp = buffer_start + BEFORE_SIZE; - -#ifdef DONTDEF - if(preprocess) { - if(save_buffer) { - *bufp = save_buffer; - save_buffer = 0; - } - limit = input_file_give_next_buffer(buffer_start+BEFORE_SIZE); - if (!limit) { - partial_where = 0; - if(partial_size) - as_warn("Partial line at end of file ignored"); - return partial_where; - } - - if(partial_size) - bcopy(save_source, partial_where,(int)AFTER_SIZE); - do_scrub(partial_where,partial_size,buffer_start+BEFORE_SIZE,limit-(buffer_start+BEFORE_SIZE),&out_string,&out_length); - limit=out_string + out_length; - for(p=limit;*--p!='\n';) - ; - p++; - if(p<=buffer_start+BEFORE_SIZE) - as_fatal("Source line too long. Please change file '%s' and re-make the assembler.", __FILE__); - - partial_where = p; - partial_size = limit-p; - bcopy(partial_where, save_source,(int)AFTER_SIZE); - bcopy(AFTER_STRING, partial_where, (int)AFTER_SIZE); - - save_buffer = *bufp; - *bufp = out_string; - - return partial_where; - } - - /* We're not preprocessing. Do the right thing */ -#endif - if (partial_size) - { - bcopy (partial_where, buffer_start + BEFORE_SIZE, (int)partial_size); - bcopy (save_source, buffer_start + BEFORE_SIZE, (int)AFTER_SIZE); - } - limit = input_file_give_next_buffer (buffer_start + BEFORE_SIZE + partial_size); - if (limit) - { - register char * p; /* Find last newline. */ - - for (p = limit; * -- p != '\n';) - { - } - ++ p; - if (p <= buffer_start + BEFORE_SIZE) - { - as_fatal("Source line too long. Please change file %s then rebuild assembler.", __FILE__); - } - partial_where = p; - partial_size = limit - p; - bcopy (partial_where, save_source, (int)AFTER_SIZE); - bcopy (AFTER_STRING, partial_where, (int)AFTER_SIZE); - } - else - { - partial_where = 0; - if (partial_size > 0) - { - as_warn("Partial line at end of file ignored"); - } - /* If we should pop to another file at EOF, do it. */ - if (next_saved_file) - { - *bufp = input_scrub_pop (next_saved_file); /* Pop state */ - /* partial_where is now correct to return, since we popped it. */ - } - } - return (partial_where); -} - -/* - * The remaining part of this file deals with line numbers, error - * messages and so on. - */ - - -int -seen_at_least_1_file () /* TRUE if we opened any file. */ -{ - return (physical_input_file != NULL); -} - -void -bump_line_counters () -{ - ++ physical_input_line; - ++ logical_input_line; -} - -/* - * new_logical_line() - * - * Tells us what the new logical line number and file are. - * If the line_number is <0, we don't change the current logical line number. - * If the fname is NULL, we don't change the current logical file name. - */ -void new_logical_line(fname, line_number) - char *fname; /* DON'T destroy it! We point to it! */ - int line_number; -{ - if (fname) { - logical_input_file = fname; - } /* if we have a file name */ - - if (line_number >= 0) { - logical_input_line = line_number; - } /* if we have a line number */ -} /* new_logical_line() */ - -/* - * a s _ w h e r e () - * - * Write a line to stderr locating where we are in reading - * input source files. - * As a sop to the debugger of AS, pretty-print the offending line. - */ -void -as_where() -{ - char *p; - line_numberT line; - - if (physical_input_file) - { /* we tried to read SOME source */ - if (input_file_is_open()) - { /* we can still read lines from source */ -#ifdef DONTDEF - fprintf (stderr," @ physical line %ld., file \"%s\"", - (long) physical_input_line, physical_input_file); - fprintf (stderr," @ logical line %ld., file \"%s\"\n", - (long) logical_input_line, logical_input_file); - (void)putc(' ', stderr); - as_howmuch (stderr); - (void)putc('\n', stderr); -#else - p = logical_input_file ? logical_input_file : physical_input_file; - line = logical_input_line ? logical_input_line : physical_input_line; - fprintf(stderr,"%s:%u: ", p, line); -#endif - } - else - { -#ifdef DONTDEF - fprintf (stderr," After reading source.\n"); -#else - p = logical_input_file ? logical_input_file : physical_input_file; - line = logical_input_line ? logical_input_line : physical_input_line; - fprintf(stderr, "%s:%d:", p, (int) line); -#endif - } - } - else - { -#ifdef DONTDEF - fprintf (stderr," Before reading source.\n"); -#else -#endif - } -} - - - - -/* - * a s _ h o w m u c h () - * - * Output to given stream how much of line we have scanned so far. - * Assumes we have scanned up to and including input_line_pointer. - * No free '\n' at end of line. - */ -void -as_howmuch (stream) - FILE * stream; /* Opened for write please. */ -{ - register char * p; /* Scan input line. */ - /* register char c; JF unused */ - - for (p = input_line_pointer - 1; * p != '\n'; --p) - { - } - ++ p; /* p->1st char of line. */ - for (; p <= input_line_pointer; p++) - { - /* Assume ASCII. EBCDIC & other micro-computer char sets ignored. */ - /* c = *p & 0xFF; JF unused */ - as_1_char(*p, stream); - } -} - -static void as_1_char (c,stream) -unsigned int c; -FILE *stream; -{ - if (c > 127) - { - (void)putc('%', stream); - c -= 128; - } - if (c < 32) - { - (void)putc('^', stream); - c += '@'; - } - (void)putc(c, stream); -} - -/* - * Local Variables: - * comment-column: 0 - * fill-column: 131 - * End: - */ - -/* end: input_scrub.c */ diff --git a/gas/link.cmd b/gas/link.cmd deleted file mode 100644 index a035ca87daa..00000000000 --- a/gas/link.cmd +++ /dev/null @@ -1,10 +0,0 @@ -ALIGN=1024 -RESNUM 0x0000, 0x8000 -; Putting in .lit1 gives errors. -ORDER .data=0x80002000, .data1, .lit, .bss -; Let's put this on the command line so it goes first, which is what -; GDB expects. -; LOAD /s2/amd/29k/lib/crt0.o -LOAD /s2/amd/29k/lib/libqcb0h.lib -LOAD /s2/amd/29k/lib/libscb0h.lib -LOAD /s2/amd/29k/lib/libacb0h.lib diff --git a/gas/make-gas.com b/gas/make-gas.com deleted file mode 100644 index 96922c476cf..00000000000 --- a/gas/make-gas.com +++ /dev/null @@ -1,56 +0,0 @@ -$! Set the def dir to proper place for use in batch. Works for interactive to. -$flnm = f$enviroment("PROCEDURE") ! get current procedure name -$set default 'f$parse(flnm,,,"DEVICE")''f$parse(flnm,,,"DIRECTORY")' -$! -$! Command file to build a GNU assembler on VMS -$! -$! If you are using a version of GCC that supports global constants -$! you should remove the define="const=" from the gcc lines. -$ if "''p1'" .eqs. "LINK" then goto Link -$ gcc/debug/define=("VMS","const=") as.c -$ gcc/debug/define=("VMS", "error=as_fatal","const=") xrealloc.c -$ gcc/debug/define=("VMS", "error=as_fatal","const=") xmalloc.c -$ gcc/debug/define=("VMS", "error=as_fatal","const=") hash.c -$ gcc/debug/define=("VMS","const=") obstack.c -$ gcc/debug/define=("VMS","const=") hex-value.c -$ gcc/debug/define=("VMS","const=") atof-generic.c -$ gcc/debug/define=("VMS","const=") append.c -$ gcc/debug/define=("VMS","const=") messages.c -$ gcc/debug/define=("VMS","const=") expr.c -$ gcc/debug/define=("VMS","const=") app.c -$ gcc/debug/define=("VMS","const=") frags.c -$ gcc/debug/define=("VMS","const=") input-file.c -$ gcc/debug/define=("VMS","const=") input-scrub.c -$ gcc/debug/define=("VMS","const=") output-file.c -$ gcc/debug/define=("VMS","const=") read.c -$ gcc/debug/define=("VMS","const=") subsegs.c -$ gcc/debug/define=("VMS","const=") symbols.c -$ gcc/debug/define=("VMS","const=") write.c -$ gcc/debug/define=("VMS","const=") version.c -$ gcc/debug/define=("VMS","const=") flonum-const.c -$ gcc/debug/define=("VMS","const=") flonum-copy.c -$ gcc/debug/define=("VMS","const=") flonum-mult.c -$ gcc/debug/define=("VMS","const=") strstr.c -$ gcc/debug/define=("VMS","const=") bignum-copy.c -$ gcc/debug/define=("VMS", "error=as_fatal","const=") vax.c -$ gcc/debug/define=("VMS","const=") atof-vax.c -$ write sys$output " If you are building gas to work with the G++ compiler" -$ write sys$output " based upon gcc version 1.37.n or earlier, you should" -$ write sys$output " edit make-gas.com and make the changes indicated in the" -$ write sys$output "comments." -$! For older versions of G++, we need the jsb hack, the HACK_DEC_C_STARTUP -$! enables this. Just use the compilation for vms.c that defines this instead -$! of the other one. -$ gcc/debug/define=("VMS", "error=as_fatal","const=") vms.c -$! gcc/debug/define=("VMS", "error=as_fatal","HACK_DEC_C_STARTUP","const=") vms.c -$ gcc/debug/define=("VMS","const=") vms-dbg.c -$ Link: -$ link/exec=gcc-as sys$input:/opt -! -! Linker options file for GNU assembler -! -as,xrealloc,xmalloc,hash,hex-value,atof-generic,append,messages,expr,app,- -frags,input-file,input-scrub,output-file,read,subsegs,symbols,write,- -version,flonum-const,flonum-copy,flonum-mult,strstr,bignum-copy,- -obstack,vax,atof-vax,vms,vms-dbg,- -gnu_cc:[000000]gcclib/lib,sys$share:vaxcrtl/lib diff --git a/gas/messages.c b/gas/messages.c deleted file mode 100644 index 90e1f9589e5..00000000000 --- a/gas/messages.c +++ /dev/null @@ -1,391 +0,0 @@ -/* messages.c - error reporter - - Copyright (C) 1987, 1991 Free Software Foundation, Inc. - - This file is part of GAS, the GNU Assembler. - - GAS 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 1, or (at your option) - any later version. - - GAS 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 GAS; see the file COPYING. If not, write to - the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* $Id$ */ - -#include /* define stderr */ -#include - -#include "as.h" - -#ifndef NO_STDARG -#include -#else -#ifndef NO_VARARGS -#include -#endif /* NO_VARARGS */ -#endif /* NO_STDARG */ - -/* - * Despite the rest of the comments in this file, (FIXME-SOON), - * here is the current scheme for error messages etc: - * - * as_fatal() is used when gas is quite confused and - * continuing the assembly is pointless. In this case we - * exit immediately with error status. - * - * as_bad() is used to mark errors that result in what we - * presume to be a useless object file. Say, we ignored - * something that might have been vital. If we see any of - * these, assembly will continue to the end of the source, - * no object file will be produced, and we will terminate - * with error status. The new option, -Z, tells us to - * produce an object file anyway but we still exit with - * error status. The assumption here is that you don't want - * this object file but we could be wrong. - * - * as_warn() is used when we have an error from which we - * have a plausible error recovery. eg, masking the top - * bits of a constant that is longer than will fit in the - * destination. In this case we will continue to assemble - * the source, although we may have made a bad assumption, - * and we will produce an object file and return normal exit - * status (ie, no error). The new option -X tells us to - * treat all as_warn() errors as as_bad() errors. That is, - * no object file will be produced and we will exit with - * error status. The idea here is that we don't kill an - * entire make because of an error that we knew how to - * correct. On the other hand, sometimes you might want to - * stop the make at these points. - * - * as_tsktsk() is used when we see a minor error for which - * our error recovery action is almost certainly correct. - * In this case, we print a message and then assembly - * continues as though no error occurred. - */ - -/* - ERRORS - - JF: this is now bogus. We now print more standard error messages - that try to look like everyone else's. - - We print the error message 1st, beginning in column 1. - All ancillary info starts in column 2 on lines after the - key error text. - We try to print a location in logical and physical file - just after the main error text. - Caller then prints any appendices after that, begining all - lines with at least 1 space. - - Optionally, we may die. - There is no need for a trailing '\n' in your error text format - because we supply one. - - as_warn(fmt,args) Like fprintf(stderr,fmt,args) but also call errwhere(). - - as_fatal(fmt,args) Like as_warn() but exit with a fatal status. - - */ - -static int warning_count = 0; /* Count of number of warnings issued */ - -int had_warnings() { - return(warning_count); -} /* had_err() */ - -/* Nonzero if we've hit a 'bad error', and should not write an obj file, - and exit with a nonzero error code */ - -static int error_count = 0; - -int had_errors() { - return(error_count); -} /* had_errors() */ - - -/* - * a s _ p e r r o r - * - * Like perror(3), but with more info. - */ -void as_perror(gripe, filename) -char *gripe; /* Unpunctuated error theme. */ -char *filename; -{ - extern int sys_nerr; - extern char *sys_errlist[]; - - as_where(); - fprintf(stderr,gripe,filename); - - if (errno > sys_nerr) - fprintf(stderr, "Unknown error #%d.\n", errno); - else - fprintf(stderr, "%s.\n", sys_errlist[errno]); - errno = 0; /* After reporting, clear it. */ -} /* as_perror() */ - -/* - * a s _ t s k t s k () - * - * Send to stderr a string (with bell) (JF: Bell is obnoxious!) as a warning, and locate warning - * in input file(s). - * Please only use this for when we have some recovery action. - * Please explain in string (which may have '\n's) what recovery was done. - */ - -#ifndef NO_STDARG -void as_tsktsk(Format) -const char *Format; -{ - va_list args; - - as_where(); - va_start(args, Format); - vfprintf(stderr, Format, args); - va_end(args); - (void) putc('\n', stderr); -} /* as_tsktsk() */ -#else -#ifndef NO_VARARGS -void as_tsktsk(Format,va_alist) -char *Format; -va_dcl -{ - va_list args; - - as_where(); - va_start(args); - vfprintf(stderr, Format, args); - va_end(args); - (void) putc('\n', stderr); -} /* as_tsktsk() */ -#else -/*VARARGS1 */ -as_tsktsk(Format,args) -char *Format; -{ - as_where(); - _doprnt (Format, &args, stderr); - (void)putc ('\n', stderr); - /* as_where(); */ -} /* as_tsktsk */ -#endif /* not NO_VARARGS */ -#endif /* not NO_STDARG */ - -#ifdef DONTDEF -void as_tsktsk(Format,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an) -char *format; -{ - as_where(); - fprintf(stderr,Format,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an); - (void)putc('\n',stderr); -} /* as_tsktsk() */ -#endif -/* - * a s _ w a r n () - * - * Send to stderr a string (with bell) (JF: Bell is obnoxious!) as a warning, and locate warning - * in input file(s). - * Please only use this for when we have some recovery action. - * Please explain in string (which may have '\n's) what recovery was done. - */ - -#ifndef NO_STDARG -void as_warn(Format) -const char *Format; -{ - va_list args; - - if(!flagseen['W']) { - ++warning_count; - as_where(); - va_start(args, Format); - vfprintf(stderr, Format, args); - va_end(args); - (void) putc('\n', stderr); - } -} /* as_warn() */ -#else -#ifndef NO_VARARGS -void as_warn(Format,va_alist) -char *Format; -va_dcl -{ - va_list args; - - if(!flagseen['W']) { - ++warning_count; - as_where(); - va_start(args); - vfprintf(stderr, Format, args); - va_end(args); - (void) putc('\n', stderr); - } -} /* as_warn() */ -#else -/*VARARGS1 */ -as_warn(Format,args) -char *Format; -{ - /* -W supresses warning messages. */ - if (! flagseen ['W']) { - ++warning_count; - as_where(); - _doprnt (Format, &args, stderr); - (void)putc ('\n', stderr); - /* as_where(); */ - } -} /* as_warn() */ -#endif /* not NO_VARARGS */ -#endif /* not NO_STDARG */ - -#ifdef DONTDEF -void as_warn(Format,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an) -char *format; -{ - if(!flagseen['W']) { - ++warning_count; - as_where(); - fprintf(stderr,Format,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an); - (void)putc('\n',stderr); - } -} /* as_warn() */ -#endif -/* - * a s _ b a d () - * - * Send to stderr a string (with bell) (JF: Bell is obnoxious!) as a warning, - * and locate warning in input file(s). - * Please us when there is no recovery, but we want to continue processing - * but not produce an object file. - * Please explain in string (which may have '\n's) what recovery was done. - */ - -#ifndef NO_STDARG -void as_bad(Format) -const char *Format; -{ - va_list args; - - ++error_count; - as_where(); - va_start(args, Format); - vfprintf(stderr, Format, args); - va_end(args); - (void) putc('\n', stderr); -} /* as_bad() */ -#else -#ifndef NO_VARARGS -void as_bad(Format,va_alist) -char *Format; -va_dcl -{ - va_list args; - - ++error_count; - as_where(); - va_start(args); - vfprintf(stderr, Format, args); - va_end(args); - (void) putc('\n', stderr); -} /* as_bad() */ -#else -/*VARARGS1 */ -as_bad(Format,args) -char *Format; -{ - ++error_count; - as_where(); - _doprnt (Format, &args, stderr); - (void)putc ('\n', stderr); - /* as_where(); */ -} /* as_bad() */ -#endif /* not NO_VARARGS */ -#endif /* not NO_STDARG */ - -#ifdef DONTDEF -void as_bad(Format,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an) -char *format; -{ - ++error_count; - as_where(); - fprintf(stderr,Format,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an); - (void)putc('\n',stderr); -} /* as_bad() */ -#endif - -/* - * a s _ f a t a l () - * - * Send to stderr a string (with bell) (JF: Bell is obnoxious!) as a fatal - * message, and locate stdsource in input file(s). - * Please only use this for when we DON'T have some recovery action. - * It exit()s with a warning status. - */ - -#ifndef NO_STDARG -void as_fatal(Format) -const char *Format; -{ - va_list args; - - as_where(); - va_start(args, Format); - fprintf (stderr, "FATAL:"); - vfprintf(stderr, Format, args); - (void) putc('\n', stderr); - va_end(args); - exit(42); -} /* as_fatal() */ -#else -#ifndef NO_VARARGS -void as_fatal(Format,va_alist) -char *Format; -va_dcl -{ - va_list args; - - as_where(); - va_start(args); - fprintf (stderr, "FATAL:"); - vfprintf(stderr, Format, args); - (void) putc('\n', stderr); - va_end(args); - exit(42); -} /* as_fatal() */ -#else -/*VARARGS1 */ -as_fatal(Format, args) -char *Format; -{ - as_where(); - fprintf(stderr,"FATAL:"); - _doprnt (Format, &args, stderr); - (void)putc ('\n', stderr); - /* as_where(); */ - exit(42); /* What is a good exit status? */ -} /* as_fatal() */ -#endif /* not NO_VARARGS */ -#endif /* not NO_STDARG */ - -#ifdef DONTDEF -void as_fatal(Format,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an) -char *Format; -{ - as_where(); - fprintf (stderr, "FATAL:"); - fprintf(stderr, Format,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an); - (void) putc('\n', stderr); - exit(42); -} /* as_fatal() */ -#endif - -/* end: messages.c */ diff --git a/gas/obj.h b/gas/obj.h deleted file mode 100644 index 68e4243c3bb..00000000000 --- a/gas/obj.h +++ /dev/null @@ -1,67 +0,0 @@ -/* obj.h - defines the object dependent hooks for all object - format backends. - - Copyright (C) 1987, 1990, 1991 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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 1, or (at your option) -any later version. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* static const char rcsid[] = "$Id$"; */ - -#ifdef __STDC__ - -char *obj_default_output_file_name(void); -void obj_crawl_symbol_chain(object_headers *headers); -void obj_emit_relocations(char **where, fixS *fixP, relax_addressT segment_address_in_file); -void obj_emit_strings(char **where); -void obj_emit_symbols(char **where, symbolS *symbol_rootP); -void obj_header_append(char **where, object_headers *headers); -void obj_read_begin_hook(void); -void obj_symbol_new_hook(symbolS *symbolP); -void obj_symbol_to_chars(char **where, symbolS *symbolP); - -#ifndef obj_pre_write_hook -void obj_pre_write_hook(object_headers *headers); -#endif /* obj_pre_write_hook */ - -#else - -char *obj_default_output_file_name(); -void obj_crawl_symbol_chain(); -void obj_emit_relocations(); -void obj_emit_strings(); -void obj_emit_symbols(); -void obj_header_append(); -void obj_read_begin_hook(); -void obj_symbol_new_hook(); -void obj_symbol_to_chars(); - -#ifndef obj_pre_write_hook -void obj_pre_write_hook(); -#endif /* obj_pre_write_hook */ - -#endif /* __STDC__ */ - -extern const pseudo_typeS obj_pseudo_table[]; - -/* - * Local Variables: - * comment-column: 0 - * fill-column: 131 - * End: - */ - -/* end of obj.h */ diff --git a/gas/objdump.c b/gas/objdump.c deleted file mode 100755 index 20ad39e5097..00000000000 --- a/gas/objdump.c +++ /dev/null @@ -1,2232 +0,0 @@ -/* objdump -- dump information about an object file. - Copyright (C) 1988, 1991 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* $Id$ */ - -/* - * objdump - * - * dump information about an object file. Until there is other documentation, - * refer to the manual page dump(1) in the system 5 program's reference manual - */ -#include -#include - -#include "getopt.h" - -#include "as.h" - -/* #define COFF_ENCAPSULATE 1 */ - -typedef FILHDR fileheader; -typedef struct exec fileheader; - -#ifdef __STDC__ -static char *sym_pname(SYMENT *s); -static char *xmalloc(unsigned size); -static char *xrealloc(char *p, unsigned size); -static void doit(char *filename); -static void dump_data(fileheader *execp, FILE *f){}; -static void dump_header(fileheader *execp, FILE *f); -static void dump_lnno(fileheader *execp, FILE *f); -static void dump_nstuff(fileheader *execp){}; -static void dump_reloc(fileheader *execp, FILE *f); -static void dump_section_contents(fileheader *execp, FILE *f); -static void dump_section_headers(fileheader *execp, FILE *f); -static void dump_sym(fileheader *execp, FILE *f); -static void dump_text(fileheader *execp, FILE *f){}; -static void hex_dump(void *buffer, int size); -#endif /* __STDC__ */ - -#ifndef OBJ_COFF -#ifndef OBJ_BOUT -static void read_symbols (execp, f) -#else -read_symbols (execp, f) -#endif /* OBJ_BOUT */ -struct exec *execp; -#else -static void read_section_headers(execp, f) -fileheader *execp; -#endif /* OBJ_COFF */ -FILE *f; -{ -#ifndef OBJ_COFF - int i; - struct nlist *sp; - if (symtbl) - return; - nsyms = execp->a_syms / sizeof (struct nlist); - if (nsyms == 0) -#else - if (section_headers || execp->f_nscns == 0) { -#endif /* OBJ_COFF */ - return; -#ifdef OBJ_COFF - } /* already read them, or don't need to */ -#endif /* OBJ_COFF */ - -#ifndef OBJ_COFF - symtbl = (struct nlist *)xmalloc (nsyms * sizeof (struct nlist)); -#else - fseek(f, sizeof(*execp) + execp->f_opthdr, 0); - section_headers = (struct scnhdr *) xmalloc(execp->f_nscns * sizeof(*section_headers)); -#endif /* OBJ_COFF */ - -#ifndef OBJ_COFF -#ifndef OBJ_BOUT - fseek(f, N_STROFF(*execp), 0); - if (fread((char *)&strsize, sizeof strsize, 1, f) != 1) { - fprintf(stderr, "%s: can not read string table size\n", -#else - fseek (f, N_STROFF(*execp), 0); - if (fread ((char *)&strsize, sizeof strsize, 1, f) != 1) { - fprintf (stderr, "%s: can not read string table size\n", -#endif /* OBJ_BOUT */ - program_name); - exit (1); - } - strtbl = xmalloc (strsize); -#ifndef OBJ_BOUT - fseek(f, N_STROFF (*execp), 0); - if (fread(strtbl, 1, strsize, f) != strsize) { - fprintf(stderr, "%s: error reading string table\n", -#else - fseek (f, N_STROFF (*execp), 0); - if (fread (strtbl, 1, strsize, f) != strsize) { - fprintf (stderr, "%s: error reading string table\n", -#endif /* OBJ_BOUT */ - program_name); - exit (1); - } -#else - if (fread(section_headers, execp->f_nscns * sizeof(*section_headers), 1, f) != 1) { - perror("error reading section headers"); - abort(); - } /* on error */ -#endif /* OBJ_COFF */ - -#ifndef OBJ_COFF -#ifndef OBJ_BOUT - fseek(f, N_SYMOFF (*execp), 0); - if (fread((char *)symtbl, sizeof (struct nlist), nsyms, f) != nsyms) { - fprintf(stderr, "%s: error reading symbol table\n", -#else - fseek (f, N_SYMOFF (*execp), 0); - if (fread ((char *)symtbl, sizeof (struct nlist), nsyms, f) != nsyms) { - fprintf (stderr, "%s: error reading symbol table\n", -#endif /* OBJ_BOUT */ - program_name); - exit (1); - } -#else - return; -} /* read_section_headers() */ -#endif /* OBJ_COFF */ - -#ifndef OBJ_COFF - for (i = 0, sp = symtbl; i < nsyms; i++, sp++) { - if (sp->n_un.n_strx == 0) - sp->n_un.n_name = ""; - else if (sp->n_un.n_strx < 0 || sp->n_un.n_strx > strsize) - sp->n_un.n_name = ""; - else - sp->n_un.n_name = strtbl + sp->n_un.n_strx; - } -#ifndef OBJ_BOUT -} /* read_symbols() */ -#else -} -#endif /* OBJ_BOUT */ -#else -static SYMENT *symbols = NULL; -static int longest_symbol_name = SYMNMLEN; -#endif /* OBJ_COFF */ - -#ifndef OBJ_COFF -#ifndef OBJ_BOUT -static void free_symbols () -#else -free_symbols () -#endif /* OBJ_BOUT */ -#else -static void read_symbols(execp, f) -fileheader *execp; -FILE *f; -#endif /* OBJ_COFF */ -{ -#ifdef OBJ_COFF - long here; - int bufsiz = execp->f_nsyms * sizeof(struct syment); - SYMENT *s; - - if (symbols || bufsiz == 0) { - return; - } /* already read, or don't need to */ - - symbols = (SYMENT *) xmalloc(bufsiz); - - /* read symbols */ - fseek(f, execp->f_symptr, 0); - if (fread(symbols, bufsiz, 1, f) != 1) { - fprintf(stderr, "error reading symbol table.\n"); - abort(); - } /* on error */ - - here = ftell(f); - fseek(f, 0, 2); /* find end of file */ - - if (here != ftell(f)) { - /* find string table size */ - fseek(f, here, 0); - if (fread(&strsize, sizeof(strsize), 1, f) != 1) { - perror("error reading string table size"); - abort(); - } /* on error */ - - /* read string table if there is one */ - if (strsize > 0) { - strtbl = xmalloc(strsize); - fseek(f, -sizeof(strsize), 1); /* backup over size count */ - - if (fread(strtbl, strsize, 1, f) != 1) { - perror("error reading string table"); - abort(); - } /* on error */ - - /* then connect the dots. */ - for (s = symbols; s < symbols + execp->f_nsyms; ++s) { - if (!s->n_zeroes) { - int l; - - s->n_offset = (long) strtbl + s->n_offset; - l = strlen((char *) s->n_offset); - if (l > longest_symbol_name) { - longest_symbol_name = l; - } /* keep max */ - } /* "long" name */ - - s += s->n_numaux; /* skip aux entries */ - } /* walk the symbol table */ - } else { - fprintf(stderr, "Well, now that's weird. I have a string table whose size is zero?\n"); - } /* if there is a string table */ - } /* if there is a string table */ - return; -} /* read_symbols() */ - -#ifdef comment -static void free_symbols() { -#endif /* OBJ_COFF */ - if (symtbl) - free (symtbl); - symtbl = NULL; - if (strtbl) - free (strtbl); - strtbl = NULL; -#ifndef OBJ_COFF -#ifndef OBJ_BOUT -#endif /* OBJ_COFF */ -} /* free_symbols() */ -#ifndef OBJ_COFF -#else -} -#endif /* OBJ_BOUT */ -#else -#endif /* comment */ -#endif /* OBJ_COFF */ - -#ifndef OBJ_COFF - -#ifndef OBJ_BOUT -static void usage () -#else -usage () -#endif /* OBJ_BOUT */ -{ -#ifndef OBJ_BOUT -#else -static void usage() { -#endif /* OBJ_COFF */ - (void) fprintf(stderr, "Usage: %s\n", program_name); - (void) fprintf(stderr, "\t[-ahnrt] [+all] [+header] [+nstuff]\n"); - (void) fprintf(stderr, "\t[+reloc] [+symbols] [+text] [+data]\n"); - (void) fprintf(stderr, "\t[+omit-symbol-numbers] [+omit-reloc-numbers]\n"); - (void) fprintf(stderr, "\tfile...\n"); -#ifndef OBJ_COFF -#else - fprintf (stderr, "\ -Usage: %s [-hnrt] [+header] [+nstuff] [+reloc] [+symbols] file...\n", - program_name); -#endif /* OBJ_BOUT */ -#endif /* OBJ_COFF */ - exit (1); -#ifndef OBJ_COFF -} -#else -} /* usage() */ -#endif /* OBJ_COFF */ - -#ifndef OBJ_COFF -#ifndef OBJ_BOUT -#endif /* OBJ_COFF */ -static int aflag = 0; -static int hflag = 0; -#ifdef OBJ_COFF -static int lflag = 0; -#endif /* OBJ_COFF */ -static int nflag = 0; -static int rflag = 0; -#ifdef OBJ_COFF -static int sflag = 0; -#endif /* OBJ_COFF */ -static int tflag = 0; -static int Dflag = 0; -static int Tflag = 0; -static int omit_reloc_numbers_flag = 0; -static int omit_sym_numbers_flag = 0; -#ifndef OBJ_COFF -#else -int hflag; -int nflag; -int rflag; -int tflag; -#endif /* OBJ_BOUT */ -#else -static int section_headers_flag = 0; -static int section_contents_flag = 0; -#endif /* OBJ_COFF */ - -/* Size of a page. Required by N_DATADDR in a.out.gnu.h [VAX]. */ -int page_size; - -#ifndef OBJ_COFF -#ifndef OBJ_BOUT -int main (argc, argv) -#else -int main(argc, argv) -#endif /* OBJ_COFF */ -int argc; -#ifndef OBJ_COFF -#else -main (argc, argv) -#endif /* OBJ_BOUT */ -#endif /* OBJ_COFF */ -char **argv; -{ - int c; -#ifndef OBJ_COFF -#ifndef OBJ_BOUT -#endif /* OBJ_COFF */ -/* extern char *optarg; */ -#ifndef OBJ_COFF -#else - extern char *optarg; -#endif /* OBJ_BOUT */ -#endif /* OBJ_COFF */ - extern int optind; - int seenflag = 0; - int ind = 0; -#ifndef OBJ_COFF -#ifndef OBJ_BOUT -#endif /* OBJ_COFF */ - static struct option long_options[] = { -#ifdef OBJ_COFF - {"line-numbers", 0, &lflag, 1}, - {"section-contents", 0, §ion_contents_flag, 1}, - {"section-headers", 0, §ion_headers_flag, 1}, -#endif /* OBJ_COFF */ - {"symbols", 0, &tflag, 1}, - {"reloc", 0, &rflag, 1}, - {"nstuff", 0, &nflag, 1}, - {"header", 0, &hflag, 1}, - {"data", 0, &Dflag, 1}, - {"text", 0, &Tflag, 1}, - {"omit-relocation-numbers", 0, &omit_reloc_numbers_flag, 1}, - {"omit-symbol-numbers", 0, &omit_sym_numbers_flag, 1}, - {"all", 0, &aflag, 1}, - {NULL, 0, NULL, 0}, - }; -#ifndef OBJ_COFF -#else - static struct option long_options[] = - { - {"symbols", 0, &tflag, 1}, - {"reloc", 0, &rflag, 1}, - {"nstuff", 0, &nflag, 1}, - {"header", 0, &hflag, 1}, - {NULL, 0, NULL, 0} - }; -#endif /* OBJ_BOUT */ -#endif /* OBJ_COFF */ - -#ifndef OBJ_COFF - page_size = getpagesize (); - -#endif /* OBJ_COFF */ - program_name = argv[0]; - -#ifndef OBJ_COFF -#ifndef OBJ_BOUT - while ((c = getopt_long (argc, argv, "ahnrt", long_options, &ind)) != EOF) { -#else - while ((c = getopt_long (argc, argv, "hnrt", long_options, &ind)) - != EOF) { -#endif /* OBJ_BOUT */ -#else - while ((c = getopt_long (argc, argv, "ahlonrt", long_options, &ind)) != EOF) { -#endif /* OBJ_COFF */ - seenflag = 1; -#ifndef OBJ_COFF -#ifndef OBJ_BOUT -#endif /* OBJ_COFF */ - -#ifndef OBJ_COFF -#endif /* OBJ_BOUT */ -#endif /* OBJ_COFF */ - switch (c) { - case 0 : break; /* we've been given a long option */ -#ifndef OBJ_COFF -#ifndef OBJ_BOUT -#endif /* OBJ_COFF */ - case 'a': aflag = 1; break; - case 'h': hflag = 1; break; -#ifdef OBJ_COFF - case 'o': hflag = 1; break; - case 'l': lflag = 1; break; -#endif /* OBJ_COFF */ - case 'n': nflag = 1; break; - case 'r': rflag = 1; break; -#ifndef OBJ_COFF -#endif /* OBJ_BOUT */ -#endif /* OBJ_COFF */ - case 't': tflag = 1; break; -#ifndef OBJ_COFF -#ifdef OBJ_BOUT - case 'r': rflag = 1; break; - case 'n': nflag = 1; break; - case 'h': hflag = 1; break; -#endif /* OBJ_BOUT */ -#endif /* OBJ_COFF */ - default: - usage (); -#ifndef OBJ_COFF -#ifndef OBJ_BOUT -#endif /* OBJ_COFF */ - } /* switch on option */ - } /* while there are options */ -#ifndef OBJ_COFF -#else - } - } -#endif /* OBJ_BOUT */ -#endif /* OBJ_COFF */ - - if (seenflag == 0 || optind == argc) - usage (); - -#ifndef OBJ_COFF -#ifndef OBJ_BOUT -#endif /* OBJ_COFF */ - if (aflag) { - hflag = 1; -#ifdef OBJ_COFF - lflag = 1; -#endif /* OBJ_COFF */ - nflag = 1; - rflag = 1; - tflag = 1; - Dflag = 1; - Tflag = 1; -#ifdef OBJ_COFF - section_headers_flag = 1; - section_contents_flag = 1; -#endif /* OBJ_COFF */ - } /* if all */ - -#ifndef OBJ_COFF -#endif /* OBJ_BOUT */ -#endif /* OBJ_COFF */ - while (optind < argc) -#ifndef OBJ_COFF - doit (argv[optind++]); -#ifndef OBJ_BOUT -#else - doit(argv[optind++]); -#endif /* OBJ_COFF */ - - return(0); -} /* main() */ -#ifndef OBJ_COFF -#else -} -#endif /* OBJ_BOUT */ -#endif /* OBJ_COFF */ - -#ifndef OBJ_COFF -#ifndef OBJ_BOUT -static void doit (name) -#else -doit (name) -#endif /* OBJ_BOUT */ -#else -static void doit(name) -#endif /* OBJ_COFF */ -char *name; -{ - FILE *f; -#ifndef OBJ_COFF - struct exec exec; -#ifndef OBJ_BOUT -#else - fileheader exec; - - if (section_headers) { - free(section_headers); - section_headers = NULL; - } /* free section headers */ - - if (symbols) { - free(symbols); - symbols = NULL; - } /* free symbols */ - -#endif /* OBJ_COFF */ - printf("%s:\n", name); -#ifndef OBJ_COFF -#else - printf ("%s:\n", name); -#endif /* OBJ_BOUT */ -#endif /* OBJ_COFF */ - f = fopen (name, "r"); - if (f == NULL) { -#ifndef OBJ_COFF -#ifndef OBJ_BOUT -#endif /* OBJ_COFF */ - fprintf(stderr, "%s: can not open ", program_name); -#ifndef OBJ_COFF -#else - fprintf (stderr, "%s: can not open ", program_name); -#endif /* OBJ_BOUT */ -#endif /* OBJ_COFF */ - perror (name); - return; - } -#ifdef HEADER_SEEK - HEADER_SEEK (f); -#endif -#ifndef OBJ_COFF -#ifndef OBJ_BOUT - if (fread((char *)&exec, sizeof exec, 1, f) != 1) { -#else - if (fread((char *)&exec, sizeof(exec), 1, f) != 1) { -#endif /* OBJ_COFF */ - fprintf(stderr, "%s: can not read header for %s\n", -#ifndef OBJ_COFF -#else - if (fread ((char *)&exec, sizeof exec, 1, f) != 1) { - fprintf (stderr, "%s: can not read header for %s\n", -#endif /* OBJ_BOUT */ -#endif /* OBJ_COFF */ - program_name, name); - return; - } - -#ifdef OBJ_COFF -#ifdef I960ROMAGIC -#define N_BADMAG I960BADMAG -#endif /* I960ROMAGIC */ - -#endif /* OBJ_COFF */ - if (N_BADMAG (exec)) { -#ifndef OBJ_COFF -#ifndef OBJ_BOUT -#endif /* OBJ_COFF */ - fprintf(stderr, "%s: %s is not a%s object file\n", - program_name, name, -#ifdef B_OUT - " b.out" -#else - "n a.out" -#endif /* B_OUT */ - ); -#ifndef OBJ_COFF -#else - fprintf (stderr, "%s: %s is not an object file\n", - program_name, name); -#endif /* OBJ_BOUT */ -#endif /* OBJ_COFF */ - return; - } - -#ifndef OBJ_COFF -#ifndef OBJ_BOUT -#endif /* OBJ_COFF */ - if (hflag) dump_header(&exec, f); -#ifdef OBJ_COFF - if (lflag) dump_lnno(&exec, f); -#endif /* OBJ_COFF */ - if (nflag) dump_nstuff(&exec); -#ifdef OBJ_COFF - if (section_headers_flag) dump_section_headers(&exec, f); - if (section_contents_flag) dump_section_contents(&exec, f); - if (sflag) dump_section_contents(&exec, f); -#endif /* OBJ_COFF */ - if (Tflag) dump_text(&exec, f); - if (Dflag) dump_data(&exec, f); - if (tflag) dump_sym(&exec, f); - if (rflag) dump_reloc(&exec, f); -#ifndef OBJ_COFF -#else - if (hflag) - dump_header (&exec); -#endif /* OBJ_COFF */ - -#ifndef OBJ_COFF - if (nflag) - dump_nstuff (&exec); -#endif /* OBJ_BOUT */ -#else - printf("\n"); - fclose(f); - return; -} /* doit() */ -#endif /* OBJ_COFF */ - -#ifndef OBJ_COFF -#ifndef OBJ_BOUT - free_symbols(); -#else - if (tflag) - dump_sym (&exec, f); -#endif /* OBJ_BOUT */ -#else -static void dump_lnno(execp, f) -fileheader *execp; -FILE *f; -{ - int i = execp->f_nscns; - struct scnhdr *section; - char *buffer; - int bufsiz = 0; - - if (i) { - printf("Line numbers:\n"); - read_section_headers(execp, f); - read_symbols(execp, f); - - for (section = section_headers; i; ++section, --i) { - int size = section->s_nlnno * LINESZ; - LINENO *r; - - if (size > bufsiz) { - if (bufsiz) { - buffer = xrealloc(buffer, bufsiz = size); - } else { - buffer = xmalloc(bufsiz = size); - } /* if we had allocated anything before */ - } /* if bigger than our old buffer */ - - printf("%8.8s:", section->s_name); - fseek(f, section->s_lnnoptr, 0); - - if (size) { - int j; - - if (fread(buffer, size, 1, f) != 1) { - printf(" (error reading lnno)\n"); - continue; - } /* on read error */ - - printf("\n"); - - for (r = (LINENO *) buffer, j = 0; j < section->s_nlnno; ++j, ++r) { - printf("lnno = %d,", r->l_lnno); - - if (r->l_lnno) { - printf(" paddr = 0x%lx", (unsigned long) r->l_addr.l_paddr); - } else { - printf(" symndx = %ld, \"%s\"", - r->l_addr.l_symndx, - sym_pname(symbols + r->l_addr.l_symndx)); - } /* if not symbol'd */ - - if (r->padding[0] || r->padding[1]) { - printf(" (padding = %2x %2x)", - (unsigned) r->padding[0], - (unsigned) r->padding[1]); - } /* if padding not zero'd */ -#endif /* OBJ_COFF */ - -#ifndef OBJ_COFF -#ifndef OBJ_BOUT -#else - printf("\n"); - } /* for each lnno record */ - } else { - printf(" (section has no line numbers.)\n"); - } /* if there really is something in the section */ - } /* for each section */ - } else { - printf("No Sections.\n"); - } /* if there are sections */ - - free(buffer); - printf("\n"); -#endif /* OBJ_COFF */ - return; -#ifndef OBJ_COFF -} /* doit() */ -#else - if (rflag) - dump_reloc (&exec, f); -#endif /* OBJ_BOUT */ -#else -} /* dump_lnno() */ -#endif /* OBJ_COFF */ - -#ifndef OBJ_COFF -#ifndef OBJ_BOUT -static void dump_header(execp, f) -#else - free_symbols (); -#else -static void dump_reloc(execp, f) -fileheader *execp; -FILE *f; -{ - int i = execp->f_nscns; - struct scnhdr *section; - char *buffer; - int bufsiz = 0; - - if (i) { - read_section_headers(execp, f); - - printf("Relocations:\n"); - for (section = section_headers; i; ++section, --i) { - int size = section->s_nreloc * RELSZ; - RELOC *r; - - if (size > bufsiz) { - if (bufsiz) { - buffer = xrealloc(buffer, bufsiz = size); - } else { - buffer = xmalloc(bufsiz = size); - } /* if we had allocated anything before */ - } /* if bigger than our old buffer */ - - printf("%8.8s:", section->s_name); - fseek(f, section->s_relptr, 0); - - if (size) { - int j; - - if (fread(buffer, size, 1, f) != 1) { - printf(" (error reading reloc)\n"); - continue; - } /* on read error */ - - printf("\n"); - - for (r = (RELOC *) buffer, j = 0; j < section->s_nreloc; ++j, ++r) { - printf("vaddr = 0x%lx, symndx = %ld, r_type = ", - (unsigned long) r->r_vaddr, - r->r_symndx); - - switch (r->r_type) { - case R_RELLONG: printf(" RELLONG"); break; - case R_IPRSHORT: printf("IPRSHORT"); break; - case R_IPRMED: printf(" IPRMED"); break; - case R_IPRLONG: printf(" IPRLONG"); break; - case R_OPTCALL: printf(" OPTCALL"); break; - case R_OPTCALLX: printf("OPTCALLX"); break; - case R_GETSEG: printf(" GETSEG"); break; - case R_GETPA: printf(" GETPA"); break; - case R_TAGWORD: printf(" TAGWORD"); break; - default: printf("unrecognized"); break; - } /* switch on reloc type */ - - printf("."); - - if (r->pad[0] || r->pad[1]) { - printf(" (padding = %2x %2x)", - (unsigned) r->pad[0], - (unsigned) r->pad[1]); - } /* if padding isn't zero */ - - printf("\n"); - } /* for each reloc record */ - } else { - printf(" (section has no relocations.)\n"); - } /* if there really is something in the section */ - } /* for each section */ - } else { - printf("No Sections.\n"); - } /* if there are sections */ - - /* free(buffer); */ - printf("\n"); - return; -} /* dump_reloc() */ - -static void dump_section_contents(execp, f) -fileheader *execp; -FILE *f; -{ - int i = execp->f_nscns; - struct scnhdr *section; - char *buffer; - int bufsiz = 0; - - if (i) { - read_section_headers(execp, f); - printf("Section Contents:\n"); - - for (section = section_headers; i; ++section, --i) { - if (section->s_size > bufsiz) { - if (bufsiz) { - buffer = xrealloc(buffer, bufsiz = section->s_size); - } else { - buffer = xmalloc(bufsiz = section->s_size); - } /* if we had allocated anything before */ - } /* if bigger than our old buffer */ - - printf("%8.8s:", section->s_name); - - if (section->s_flags & STYP_BSS) { - printf(" bss sections have no contents.\n"); - } else { - fseek(f, section->s_scnptr, 0); - - if (section->s_size) { - if (fread(buffer, section->s_size, 1, f) != 1) { - printf(" (error reading section contents)\n"); - } /* on read error */ - - printf("\n"); - hex_dump(buffer, section->s_size); - printf("\n"); - } else { - printf(" (section has a size of zero.)\n"); - } /* if there really is a section */ - } /* if bss else dump */ - } /* for each section */ - } else { - printf("No Sections.\n"); - } /* if there are sections */ - - free(buffer); - printf("\n"); - return; -} /* dump_section_contents() */ - -static void dump_section_headers(execp, f) -fileheader *execp; -FILE *f; -{ - int i = execp->f_nscns; - struct scnhdr *section; - - if (i > 0) { - read_section_headers(execp, f); - printf("Section Headers:\n"); - - for (section = section_headers; i; ++section, --i) { - long flags = section->s_flags; - - printf("\"%8.8s\"", section->s_name); - - printf(" physical address: 0x%x vma: 0x%x size: 0x%x (%ld)", - (unsigned) section->s_paddr, - (unsigned) section->s_vaddr, - (unsigned) section->s_size, - section->s_size); - - printf(" relocs: %d linenos: %d alignment: 0x%lx (%ld)", - section->s_nreloc, - section->s_nlnno, - section->s_align, - (long) section->s_align); - - printf(" flags: 0x%x = ", (unsigned) section->s_flags); - - if (flags & STYP_REG) { - printf(" REG"); - flags &= ~STYP_REG; - } /* STYP_REG */ - - if (flags & STYP_DSECT) { - printf(" DSECT"); - flags &= ~STYP_DSECT; - } /* STYP_DSECT */ - - if (flags & STYP_NOLOAD) { - printf(" NOLOAD"); - flags &= ~STYP_NOLOAD; - } /* STYP_NOLOAD */ - - if (flags & STYP_GROUP) { - printf(" GROUP"); - flags &= ~STYP_GROUP; - } /* STYP_GROUP */ - - if (flags & STYP_PAD) { - printf(" PAD"); - flags &= ~STYP_PAD; - } /* STYP_PAD */ - - if (flags & STYP_COPY) { - printf(" COPY"); - flags &= ~STYP_COPY; - } /* STYP_COPY */ - - if (flags & STYP_TEXT) { - printf(" TEXT"); - flags &= ~STYP_TEXT; - } /* STYP_TEXT */ - - if (flags & S_SHRSEG) { - printf(" SHRSEG"); - flags &= ~S_SHRSEG; - } /* S_SHRSEG */ - - if (flags & STYP_DATA) { - printf(" DATA"); - flags &= ~STYP_DATA; - } /* STYP_DATA */ - - if (flags & STYP_BSS) { - printf(" BSS"); - flags &= ~STYP_BSS; - } /* STYP_BSS */ - - if (flags & S_NEWFCN) { - printf(" NEWFCN"); - flags &= ~S_NEWFCN; - } /* S_NEWFCN */ - - if (flags & STYP_INFO) { - printf(" INFO"); - flags &= ~STYP_INFO; - } /* STYP_INFO */ - - if (flags & STYP_OVER) { - printf(" OVER"); - flags &= ~STYP_OVER; - } /* STYP_OVER */ - - if (flags & STYP_LIB) { - printf(" LIB"); - flags &= ~STYP_LIB; - } /* STYP_LIB */ - - if (flags & STYP_MERGE) { - printf(" MERGE"); - flags &= ~STYP_MERGE; - } /* STYP_MERGE */ - - if (flags & STYP_REVERSE_PAD) { - printf(" REVERSE_PAD"); - flags &= ~STYP_REVERSE_PAD; - } /* STYP_REVERSE_PAD */ - - if (flags) { - printf(" +unknown"); - } /* foo */ - - printf("\n"); - } /* for each section header */ - } else { - printf("No section headers.\n"); - } /* if there are any sections */ -#endif /* OBJ_COFF */ - -#ifndef OBJ_COFF -} -#else - printf("\n"); - return; -} /* dump_section_headers() */ -#endif /* OBJ_COFF */ - -#ifndef OBJ_COFF -dump_header (execp) -#endif /* OBJ_BOUT */ -struct exec *execp; -#ifndef OBJ_BOUT -#else -static void dump_header(execp, f) -fileheader *execp; -#endif /* OBJ_COFF */ -FILE *f; -#ifndef OBJ_COFF -#endif /* OBJ_BOUT */ -#endif /* OBJ_COFF */ -{ -#ifdef OBJ_COFF -#ifdef COFF - printf("magic: 0x%x (%o) ", (unsigned) execp->f_magic, (unsigned) execp->f_magic); - printf("number of sections: %d number of syms: %ld ", execp->f_nscns, execp->f_nsyms); - printf("time stamp: %s", ctime(&(execp->f_timdat))); - printf("flags:"); - - if (execp->f_flags & F_RELFLG) { - printf(" RELFLG"); - } /* relflg */ - - if (execp->f_flags & F_EXEC) { - printf(" EXEC"); - } /* exec */ - - if (execp->f_flags & F_LNNO) { - printf(" LNNO"); - } /* lnno */ - - if (execp->f_flags & F_LSYMS) { - printf(" LSYMS"); - } /* lsyms */ - - if (execp->f_flags & F_AR32WR) { - printf(" AR32WR"); - } /* ar32wr */ - - assert(F_I960KB == F_I960SB); - assert(F_I960KA == F_I960SA); - - switch (execp->f_flags & F_I960TYPE) { - case F_I960CORE: printf(" I960CORE"); break; - case F_I960KB: printf(" I960KB (== I960SB)"); break; - case F_I960MC: printf(" I960MC"); break; - case F_I960XA: printf(" I960XA"); break; - case F_I960CA: printf(" I960CA"); break; - case F_I960KA: printf(" I960KA (== I960SA)"); break; - default: printf(" I960Unknown"); break; - } /* switch on i960 type */ - - if (execp->f_flags & ~(F_RELFLG | F_EXEC | F_LNNO | F_LSYMS | F_AR32WR | F_I960TYPE)) { - printf(" +unrecognized"); - } /* unrecognized */ - - printf("\n\n"); - - if (execp->f_opthdr) { - if (execp->f_opthdr == sizeof(AOUTHDR)) { - AOUTHDR hdr; - - fseek(f, sizeof(*execp), 0); - if (fread(&hdr, sizeof(AOUTHDR), 1, f) == 1) { - printf("aouthdr:\n"); - printf("magic: 0x%x (%o)", (unsigned) hdr.magic, (unsigned) hdr.magic); - printf(" vstamp: 0x%ld\n", (long) hdr.vstamp); - - printf("sizes: text 0x%lx (%ld), data 0x%lx (%ld), bss 0x%lx (%ld)\n", - hdr.tsize, - (long) hdr.tsize, - hdr.dsize, - (long) hdr.dsize, - hdr.bsize, - (long) hdr.bsize); - - printf("entry point: 0x%lx, starts: text 0x%lx (%ld), data 0x%lx (%ld)\n", - hdr.entry, - hdr.text_start, - (long) hdr.text_start, - hdr.data_start, - (long) hdr.data_start); - - printf("tag entries: %ld\n", - (long) hdr.tagentries); - } else { - fprintf(stderr, "%s: error reading optional header", program_name); - perror(NULL); - } /* on error */ - - } else { - printf("opthder != sizeof aouthdr?"); - } /* size mismatch */ - - } else { - printf("No optional header."); - } /* print optional header */ - - -#else /* COFF */ -#endif /* OBJ_COFF */ - int x; - -#if defined (__GNU_EXEC_MACROS__) && !defined (__STRUCT_EXEC_OVERRIDE__) -#ifndef OBJ_COFF -#ifndef OBJ_BOUT -#endif /* OBJ_COFF */ - printf("magic: 0x%x (%o)", N_MAGIC(*execp), N_MAGIC(*execp)); - printf("machine type: %d", N_MACHTYPE(*execp)); - printf("flags: 0x%x", N_FLAGS(*execp)); -#ifndef OBJ_COFF -#else - printf ("magic: 0x%x (%o)", N_MAGIC(*execp), N_MAGIC(*execp)); - printf ("machine type: %d", N_MACHTYPE(*execp)); - printf ("flags: 0x%x", N_FLAGS(*execp)); -#endif /* OBJ_BOUT */ -#endif /* OBJ_COFF */ -#else /* non-gnu struct exec. */ -#ifndef OBJ_COFF -#ifndef OBJ_BOUT -#endif /* OBJ_COFF */ - printf("magic: 0x%x (%o) ", (unsigned) execp->a_magic, (unsigned) execp->a_magic); -#ifndef OBJ_COFF -#else - printf ("magic: 0x%x (%o) ", execp->a_magic, execp->a_magic); -#endif /* OBJ_BOUT */ -#endif /* OBJ_COFF */ -#endif /* non-gnu struct exec. */ -#ifndef OBJ_COFF -#ifndef OBJ_BOUT -#endif /* OBJ_COFF */ - printf("text 0x%x ", (unsigned) execp->a_text); - printf("data 0x%x ", (unsigned) execp->a_data); - printf("bss 0x%x\n", (unsigned) execp->a_bss); - printf("nsyms %ld", (long) (execp->a_syms / sizeof(struct nlist))); - x = execp->a_syms % sizeof(struct nlist); -#ifndef OBJ_COFF -#else - printf ("text 0x%x ", execp->a_text); - printf ("data 0x%x ", execp->a_data); - printf ("bss 0x%x\n", execp->a_bss); - printf ("nsyms %d", execp->a_syms / sizeof (struct nlist)); - x = execp->a_syms % sizeof (struct nlist); -#endif /* OBJ_BOUT */ -#endif /* OBJ_COFF */ - if (x) -#ifndef OBJ_COFF -#ifndef OBJ_BOUT -#endif /* OBJ_COFF */ - printf(" (+ %d bytes)", x); - printf(" entry 0x%lx ", execp->a_entry); - -#ifdef B_OUT - printf(" talign 0x%x", (unsigned) execp->a_talign); - printf(" dalign 0x%x", (unsigned) execp->a_dalign); - printf(" balign 0x%x", (unsigned) execp->a_balign); - printf(" unused 0x%x", (unsigned) execp->unused); -#endif /* B_OUT */ - - printf(" trsize 0x%lx", execp->a_trsize); - printf(" drsize 0x%lx", execp->a_drsize); - - if (N_TXTOFF(*execp) != 0 && N_TXTOFF(*execp) != sizeof(*execp)) { - char *buffer; - char *i; - int size = N_TXTOFF(*execp) - sizeof(*execp); - - buffer = xmalloc(size); - - fseek(f, sizeof(*execp), 0); - if (fread(buffer, size, 1, f) != 1) { - fprintf(stderr, "%s: error reading between header and text", program_name); - perror(NULL); - } /* on error */ - - for (i = buffer; i < (buffer + size); ++i) { - if (*i != '\0') { - printf(" (garbage follows header)"); - break; - } /* non null */ - } /* walk the buffer looking for garbage */ - } /* check for garbage following header */ -#ifdef OBJ_COFF -#endif /* COFF */ -#endif /* OBJ_COFF */ - - printf("\n"); - return; -} /* dump_header() */ - -#ifdef OBJ_COFF -#ifdef comment -#endif /* OBJ_COFF */ -static void dump_nstuff(execp) -#ifndef OBJ_COFF -struct exec *execp; -#else -fileheader *execp; -#endif /* OBJ_COFF */ -{ - printf("N_BADMAG %d\n", N_BADMAG(*execp)); - printf("N_TXTOFF 0x%x\n", N_TXTOFF(*execp)); - printf("N_SYMOFF 0x%lx\n", N_SYMOFF(*execp)); - printf("N_STROFF 0x%lx\n", N_STROFF(*execp)); - printf("N_TXTADDR 0x%x\n", (unsigned) N_TXTADDR(*execp)); - printf("N_DATADDR 0x%lx\n", N_DATADDR(*execp)); - - return; -} /* dump_nstuff() */ -#ifndef OBJ_COFF -#else - printf (" (+ %d bytes)", x); - printf (" entry 0x%x ", execp->a_entry); -#endif /* OBJ_BOUT */ -#endif /* OBJ_COFF */ - -#ifndef OBJ_COFF -#ifndef OBJ_BOUT -#endif /* OBJ_COFF */ -static void dump_text(execp, f) -#ifndef OBJ_COFF -struct exec *execp; -#else -fileheader *execp; -#endif /* OBJ_COFF */ -FILE *f; -{ - void *buffer; - - if (execp->a_text) { - buffer = xmalloc(execp->a_text); - fseek(f, N_TXTOFF(*execp), 0); - - if (fread(buffer, execp->a_text, 1, f) != 1) { - fprintf(stderr, "%s: error reading text section.\n", program_name); - return; - } /* on error */ -#ifndef OBJ_COFF -#else - printf (" talign 0x%x ", execp->a_talign); - printf (" dalign 0x%x ", execp->a_dalign); - printf (" balign 0x%x ", execp->a_balign); - printf (" unused 0x%x ", execp->unused); -#endif /* OBJ_BOUT */ -#endif /* OBJ_COFF */ - -#ifndef OBJ_COFF -#ifndef OBJ_BOUT -#endif /* OBJ_COFF */ - hex_dump(buffer, execp->a_text); - free(buffer); - } else { - printf("No text section.\n"); - } /* if there is text */ - - return; -} /* dump_text() */ -#ifndef OBJ_COFF -#else - printf ("trsize 0x%x ", execp->a_trsize); - printf ("drsize 0x%x\n", execp->a_drsize); -} -#endif /* OBJ_BOUT */ -#endif /* OBJ_COFF */ - -#ifndef OBJ_COFF -#ifndef OBJ_BOUT -#endif /* OBJ_COFF */ -static void dump_data(execp, f) -#ifndef OBJ_COFF -#else -dump_nstuff (execp) -#endif /* OBJ_BOUT */ -struct exec *execp; -#ifndef OBJ_BOUT -#else -fileheader *execp; -#endif /* OBJ_COFF */ -FILE *f; -{ - void *buffer; - - if (execp->a_data) { - buffer = xmalloc(execp->a_data); - fseek(f, N_TXTOFF(*execp), 0); - - if (fread(buffer, execp->a_data, 1, f) != 1) { - fprintf(stderr, "%s: error reading data section.\n", program_name); - return; - } /* on error */ - - hex_dump(buffer, execp->a_data); - free(buffer); - } else { - printf("No data section.\n"); - } /* if there is data */ - - return; -} /* dump_data() */ -#ifdef OBJ_COFF -#endif /* comment */ -#endif /* OBJ_COFF */ - -static void hex_dump(buffer, size) -void *buffer; -int size; -#ifndef OBJ_COFF -#endif /* OBJ_BOUT */ -#endif /* OBJ_COFF */ -{ -#ifndef OBJ_COFF -#ifndef OBJ_BOUT -#endif /* OBJ_COFF */ - FILE *f; - -#ifndef OBJ_COFF - if ((f = popen("od -x +0x0", "w")) != NULL) { -#else - fflush(stdout); - - if ((f = popen("hexl", "w")) != NULL) { -#endif /* OBJ_COFF */ - if (fwrite(buffer, size, 1, f) != 1) { - (void) fprintf(stderr, "%s: error writing to od(1) pipe:", program_name); - perror(NULL); - } /* on error */ - } else { - (void) fprintf(stderr, "%s: error opening pipe to od(1):", program_name); - perror(NULL); - } /* on successful popen */ - - (void) pclose(f); -#ifdef OBJ_COFF - fflush(stdout); -#endif /* OBJ_COFF */ - return; -} /* hex_dump() */ -#ifndef OBJ_COFF -#else - printf ("N_BADMAG %d\n", N_BADMAG (*execp)); - printf ("N_TXTOFF 0x%x\n", N_TXTOFF (*execp)); - printf ("N_SYMOFF 0x%x\n", N_SYMOFF (*execp)); - printf ("N_STROFF 0x%x\n", N_STROFF (*execp)); - printf ("N_TXTADDR 0x%x\n", N_TXTADDR (*execp)); - printf ("N_DATADDR 0x%x\n", N_DATADDR (*execp)); -} -#endif /* OBJ_BOUT */ -#else - -char *sym_class_pname(class) -char class; -{ - switch (class) { - case C_EFCN: return("EFCN"); - case C_NULL: return("NULL"); - case C_AUTO: return("AUTO"); - case C_EXT: return("EXT"); - case C_STAT: return("STAT"); - case C_REG: return("REG"); - case C_EXTDEF: return("EXTDEF"); - case C_LABEL: return("LABEL"); - case C_ULABEL: return("ULABEL"); - case C_MOS: return("MOS"); - case C_ARG: return("ARG"); - case C_STRTAG: return("STRTAG"); - case C_MOU: return("MOU"); - case C_UNTAG: return("UNTAG"); - case C_TPDEF: return("TPDEF"); - case C_USTATIC: return("USTATIC"); - case C_ENTAG: return("ENTAG"); - case C_MOE: return("MOE"); - case C_REGPARM: return("REGPARM"); - case C_FIELD: return("FIELD"); - case C_BLOCK: return("BLOCK"); - case C_FCN: return("FCN"); - case C_EOS: return("EOS"); - case C_FILE: return("FILE"); - case C_LINE: return("LINE"); - case C_ALIAS: return("ALIAS"); - case C_HIDDEN: return("HIDDEN"); - - case C_SCALL: return("SCALL"); - case C_LEAFEXT: return("LEAFEXT"); - case C_OPTVAR: return("OPTVAR"); - case C_DEFINE: return("DEFINE"); - case C_PRAGMA: return("PRAGMA"); - case C_SEGMENT: return("SEGMENT"); - case C_LEAFSTAT:return("LEAFSTAT"); - case C_AUTOARG: return("AUTOARG"); - - default: return("(???)"); - } /* switch on class */ -} /* sym_class_pname() */ - -char *sym_type_pname(type) -unsigned long type; -{ - switch (type) { - case T_NULL: return("NULL"); - case T_VOID: return("VOID"); - case T_CHAR: return("CHAR"); - case T_SHORT: return("SHORT"); - case T_INT: return("INT"); - case T_LONG: return("LONG"); - case T_FLOAT: return("FLOAT"); - case T_DOUBLE: return("DOUBLE"); - case T_STRUCT: return("STRUCT"); - case T_UNION: return("UNION"); - case T_ENUM: return("ENUM"); - case T_MOE: return("MOE"); - case T_UCHAR: return("UCHAR"); - case T_USHORT: return("USHORT"); - case T_UINT: return("UINT"); - case T_ULONG: return("ULONG"); - case T_LNGDBL: return("LNGDBL"); - - default: return("(???)"); - } /* switch on type */ -} /* sym_type_pname() */ - -char *sym_section_pname(scnum, execp) -short scnum; -fileheader *execp; -{ - switch (scnum) { - case N_UNDEF: return("UNDEF"); - case N_ABS: return("ABS"); - case N_DEBUG: return("DEBUG"); - case N_TV: return("NTV"); - case P_TV: return("PTV"); - - default: - assert(0 <= (scnum-1)); - assert((scnum-1) < execp->f_nscns); - return(section_headers[scnum-1].s_name); - } /* switch on scnum */ -} /* sym_section_pname() */ - -static char *sym_pname(s) -SYMENT *s; -{ - static char buffer[SYMNMLEN + 1]; - if (s->n_zeroes) { - bzero(buffer, SYMNMLEN + 1); - bcopy(s->n_name, buffer, SYMNMLEN); - return(buffer); - } else { - return((char *) s->n_offset); - } /* if "short" name */ -} /* sym_pname() */ - -/* - * Notes: .file must be first, .text, .data, .bss must be last. - */ - -static void dump_aux_fcn(aux) -AUXENT *aux; -{ - /* function symbol */ - printf(" tagndx %ld,", aux->x_sym.x_tagndx); - printf(" size %ld,", aux->x_sym.x_misc.x_fsize); - printf(" lnnoptr 0x%lx,", (unsigned long) aux->x_sym.x_fcnary.x_fcn.x_lnnoptr); - printf(" endndx %ld", aux->x_sym.x_fcnary.x_fcn.x_endndx); - printf(" tvndx 0x%x,", (unsigned) aux->x_sym.x_tvndx); - return; -} /* dump_aux_fcn() */ - -static void dump_aux_tagmember(aux) -AUXENT *aux; -{ - printf(" tagndx %ld,", aux->x_sym.x_tagndx); - printf(" size %d,", aux->x_sym.x_misc.x_lnsz.x_size); - return; -} /* dump_aux_tagmember() */ - -static void dump_aux_array(aux) -AUXENT *aux; -{ - int i; -#endif /* OBJ_COFF */ - -#ifndef OBJ_COFF -#ifndef OBJ_BOUT -#else - printf(" size %d, ", aux->x_sym.x_misc.x_lnsz.x_size); - - for (i = 0; i < 4; ++i) { - printf("[%d]", aux->x_sym.x_fcnary.x_ary.x_dimen[i]); - } /* four dimensions */ - - return; -} /* dump_aux_array() */ - -#endif /* OBJ_COFF */ -static void dump_sym(execp, f) -#ifndef OBJ_COFF -#else -dump_sym (execp, f) -#endif /* OBJ_BOUT */ -struct exec *execp; -#else -fileheader *execp; -#endif /* OBJ_COFF */ -FILE *f; -{ - int i; -#ifndef OBJ_COFF - struct nlist *sp; -#else - SYMENT *sp; -#endif /* OBJ_COFF */ - -#ifndef OBJ_COFF -#ifndef OBJ_BOUT - read_symbols(execp, f); -#else - read_symbols (execp, f); -#endif /* OBJ_BOUT */ - if (nsyms == 0) { -#ifndef OBJ_BOUT -#else - read_section_headers(execp, f); - - if (execp->f_nsyms == 0) { -#endif /* OBJ_COFF */ - printf("no symbols\n"); -#ifndef OBJ_COFF -#else - printf ("no symbols\n"); -#endif /* OBJ_BOUT */ -#endif /* OBJ_COFF */ - return; -#ifndef OBJ_COFF - } -#else - } /* if there are any */ - - read_symbols(execp, f); - printf("Symbols:\n"); -#endif /* OBJ_COFF */ - -#ifndef OBJ_COFF -#ifndef OBJ_BOUT -#endif /* OBJ_COFF */ - if (!omit_sym_numbers_flag) { -#ifndef OBJ_COFF - printf("%3s: ", "#"); -#else - printf("%3s:", "#"); -#endif /* OBJ_COFF */ - } /* printing symbol numbers */ - -#ifndef OBJ_COFF - printf("%4s %5s %4s %8s\n", - "type", "other", "desc", "val"); -#else - printf(" %*.*s %8.8s %3.3s %8.8s %7.7s %3.3s %s\n", - SYMNMLEN, SYMNMLEN, "name", - "value", "num", "sec-name", "class", "aux", "type"); -#endif /* OBJ_COFF */ - -#ifndef OBJ_COFF -#else - printf ("%3s: %4s %5s %4s %8s\n", - "#", "type", "other", "desc", "val"); -#endif /* OBJ_BOUT */ - for (i = 0, sp = symtbl; i < nsyms; i++, sp++) { -#ifndef OBJ_BOUT -#else - for (i = 0, sp = symbols; sp < symbols + execp->f_nsyms; ++sp, ++i) { -#endif /* OBJ_COFF */ - if (!omit_sym_numbers_flag) { -#ifndef OBJ_COFF - printf("%3d: ", i); -#else - printf("%3d:", i); -#endif /* OBJ_COFF */ - } /* printing symbol numbers */ - -#ifndef OBJ_COFF - printf("%4x %5x %4x %8lx %s", - (unsigned) (sp->n_type & 0xff), - (unsigned) (sp->n_other & 0xff), - (unsigned) (sp->n_desc & 0xffff), -#else - printf ("%3d: %4x %5x %4x %8x %s", - i, - sp->n_type & 0xff, - sp->n_other & 0xff, - sp->n_desc & 0xffff, -#endif /* OBJ_BOUT */ - sp->n_value, - sp->n_un.n_name); -#ifndef OBJ_BOUT -#else - printf(" %*.*s", SYMNMLEN, SYMNMLEN, (sp->n_zeroes) ? sp->n_name : ""); -#endif /* OBJ_COFF */ - -#ifndef OBJ_COFF -#else - -#endif /* OBJ_BOUT */ - if (sp->n_type & N_EXT) printf(" N_EXT"); - if (sp->n_type & N_STAB) printf(" N_STAB"); -#ifndef OBJ_BOUT -#else - printf(" %8lx", (unsigned long) sp->n_value); - printf(" %3d", sp->n_scnum); - printf(" %8.8s", sym_section_pname(sp->n_scnum, execp)); - printf(" %7.7s", sym_class_pname(sp->n_sclass)); - printf(" %1d", sp->n_numaux); -#endif /* OBJ_COFF */ - -#ifndef OBJ_COFF -#else - -#endif /* OBJ_BOUT */ - if ((sp->n_type & N_TYPE) == N_UNDF) { - printf(" N_UNDF"); - } else { - if (sp->n_type & N_ABS) printf(" N_ABS"); - if (sp->n_type & N_TEXT) printf(" N_TEXT"); - if (sp->n_type & N_DATA) printf(" N_DATA"); - if (sp->n_type & N_BSS) printf(" N_BSS"); - if (sp->n_type & N_FN) printf(" N_FN"); - } /* if not undefined */ -#ifndef OBJ_BOUT -#else - printf(" %s", sym_type_pname(BTYPE(sp->n_type))); -#endif /* OBJ_COFF */ - -#ifndef OBJ_COFF -#ifdef B_OUT -#else - -#endif /* OBJ_BOUT */ - if (sp->n_other) { - printf(" ["); -#ifndef OBJ_BOUT -#else - /* derived type */ - printf("%s", (ISPTR(sp->n_type) - ? "(PTR)" - : (ISFCN(sp->n_type) - ? "(FCN)" - : (ISARY(sp->n_type) - ? "(ARY)" - : "")))); - - if (sp->n_type & ~(N_BTMASK | N_TMASK)) { - printf("+"); - } /* if type isn't all */ - - if (!sp->n_zeroes) { - printf(" \"%s\"", sym_pname(sp)); - } /* if "long" name */ - - /* FIXME do something with the flags field */ -#ifdef comment - if (sp->pad1[0] != 0 || sp->pad1[1] != 0) { - printf(" (pad1 %2.2x%2.2x)", (unsigned) sp->pad1[0], (unsigned) sp->pad1[1]); - } /* if padding not zeroed */ -#endif /* comment */ - - if (sp->pad2[0] != 0 || sp->pad2[1] != 0) { - printf(" (pad2 %2.2x%2.2x)", (unsigned) sp->pad2[0], (unsigned) sp->pad2[1]); - } /* if padding not zeroed */ - -#define DTYPE(x) (((x) & N_TMASK) >> N_BTSHFT) - - if (sp->n_numaux > 0) { - int auxcountshouldbe = 1; - AUXENT *aux = (AUXENT *) (sp + 1); - AUXENT *aux2 = (AUXENT *) (sp + 2); -#endif /* OBJ_COFF */ - -#ifndef OBJ_COFF -#else -#else - switch (sp->n_sclass) { - - case C_FILE: /* file symbol */ - printf(" filename \"%s\"", aux->x_file.x_fname); - break; - - case C_UNTAG: - case C_ENTAG: - case C_STRTAG: { - if (DTYPE(sp->n_type) == DT_NON - && (BTYPE(sp->n_type) == T_NULL - || BTYPE(sp->n_type) == T_STRUCT - || BTYPE(sp->n_type) == T_UNION - || BTYPE(sp->n_type) == T_ENUM)) { - printf(" size %d,", aux->x_sym.x_misc.x_lnsz.x_size); - printf(" endndx %ld", aux->x_sym.x_fcnary.x_fcn.x_endndx); - } else { - printf(" (don't know why this tag has an auxent)"); - abort(); - } /* if I understand */ - - break; - } /* tags */ - - case C_EOS: { - if (BTYPE(sp->n_type) == DT_NON && BTYPE(sp->n_type) == T_NULL) { - printf(" tagndx %ld,", aux->x_sym.x_tagndx); - printf(" size %d,", aux->x_sym.x_misc.x_lnsz.x_size); - } else { - printf(" (don't know why this eos has an auxent)"); - abort(); - } /* if I understand */ - break; - } /* eos */ - - case C_FCN: - case C_BLOCK: { - if (BTYPE(sp->n_type) == DT_NON && BTYPE(sp->n_type) == T_NULL) { - if (!strcmp(sp->n_name, ".bb") || !strcmp(sp->n_name, ".bf")) { - printf(" lnno %d", aux->x_sym.x_misc.x_lnsz.x_lnno); - printf(" endndx %ld", aux->x_sym.x_fcnary.x_fcn.x_endndx); - break; - - } else if (!strcmp(sp->n_name, ".eb") || !strcmp(sp->n_name, ".ef")) { - printf(" lnno %d", aux->x_sym.x_misc.x_lnsz.x_lnno); - break; - - } /* beginning or ending */ - } /* if I understand */ - - printf(" (don't know why this fcn or block has an auxent)"); - abort(); - break; - } /* begin/end blocks */ - - case C_LEAFEXT: - case C_LEAFSTAT: - case C_SCALL: - case C_EXT: { - assert(BTYPE(sp->n_type) != T_MOE); - - if (ISFCN(sp->n_type) - || BTYPE(sp->n_type) == T_NULL) { - dump_aux_fcn(aux); - - if (sp->n_sclass == C_SCALL) { - printf(" stindx %ld", aux2->x_sc.x_stindx); - auxcountshouldbe = 2; - } else if (sp->n_sclass == C_LEAFEXT - || sp->n_sclass == C_LEAFSTAT) { - printf(" balentry 0x%lx", aux2->x_bal.x_balntry); - auxcountshouldbe = 2; - } /* special functions */ - } else if (ISARY(sp->n_type)) { - dump_aux_array(aux); - } else if (BTYPE(sp->n_type) == T_STRUCT) { - printf(" tagndx %ld,", aux->x_sym.x_tagndx); - printf(" size %d,", aux->x_sym.x_misc.x_lnsz.x_size); - } else { - assert(0); - } /* on type */ - - break; - } /* function */ - - case C_STAT: { - switch (DTYPE(sp->n_type)) { - case DT_NON: - switch (BTYPE(sp->n_type)) { - case T_NULL: /* section symbol */ - printf(" length 0x%lx, relocs %d, lnnos %d", - (unsigned long) aux->x_scn.x_scnlen, - aux->x_scn.x_nreloc, - aux->x_scn.x_nlinno); - break; - case T_STRUCT: - case T_UNION: - case T_ENUM: - dump_aux_tagmember(aux); - break; - default: - printf(" (confused)."); - abort(); - } /* switch on btype */ - break; - - case DT_FCN: /* function */ - if (BTYPE(sp->n_type) == T_MOE) { - printf(" (confused)."); - abort(); - } else { - dump_aux_fcn(aux); - } /* if I understand */ - break; - - case DT_ARY: - assert(BTYPE(sp->n_type) != T_MOE); - dump_aux_array(aux); - /* intentional fall through */ - case DT_PTR: - assert(BTYPE(sp->n_type) == T_STRUCT - || BTYPE(sp->n_type) == T_UNION - || BTYPE(sp->n_type) == T_ENUM); - dump_aux_tagmember(aux); - break; - - default: - printf(" (confused.)"); - abort(); - } /* switch on derived type */ - - break; - } /* STAT */ - - case C_AUTO: - case C_MOS: - case C_MOU: - case C_TPDEF: - if (DTYPE(sp->n_type) == DT_ARY) { - assert(BTYPE(sp->n_type) != T_MOE); - dump_aux_array(aux); - } else { - dump_aux_tagmember(aux); - } /* if an array */ - break; -#endif /* OBJ_COFF */ - -#ifndef OBJ_COFF -#endif /* OBJ_BOUT */ - if (sp->n_other == N_CALLNAME) { - printf(" N_CALLNAME"); - } else if (sp->n_other == N_BALNAME) { - printf(" N_BALNAME"); - } else if (1 <= sp->n_other && sp->n_other <= 32) { - printf(" \"trap\""); - } else { - printf(" !!!invalid \"other\" field"); - } /* what is it */ -#ifndef OBJ_BOUT -#else - case C_FIELD: - printf(" tagndx %ld,", aux->x_sym.x_tagndx); - printf(" size %d,", aux->x_sym.x_misc.x_lnsz.x_size); - break; - - default: - printf(" (don't know why this symbol has aux entries.)"); - abort(); - break; - } /* switch on class */ -#endif /* OBJ_COFF */ - -#ifndef OBJ_COFF -#else - -#endif /* OBJ_BOUT */ - printf(" ]"); - } /* is defined */ -#ifndef OBJ_BOUT -#endif /* B_OUT */ -#else - if (sp->n_numaux != auxcountshouldbe) { - printf(" (expecting %d auxents here)", auxcountshouldbe); - abort(); - } /* on miscount */ - } /* do aux entries */ - - i += sp->n_numaux; - sp += sp->n_numaux; -#endif /* OBJ_COFF */ - - printf("\n"); - } /* for each symbol */ -#ifndef OBJ_COFF -#endif /* OBJ_BOUT */ -#endif /* OBJ_COFF */ - -#ifndef OBJ_COFF -#ifndef OBJ_BOUT -#else - printf("\n"); -#endif /* OBJ_COFF */ - return; -} /* dump_sym() */ -#ifndef OBJ_COFF -#else - printf("\n"); - } -} -#endif /* OBJ_BOUT */ -#endif /* OBJ_COFF */ - -#ifndef OBJ_COFF -#ifndef OBJ_BOUT -#else -#ifdef comment -#endif /* OBJ_COFF */ -static void dump_reloc (execp, f) -#ifndef OBJ_COFF -#else -dump_reloc (execp, f) -#endif /* OBJ_BOUT */ -struct exec *execp; -#else -fileheader *execp; -#endif /* OBJ_COFF */ -FILE *f; -{ -#ifndef OBJ_COFF - read_symbols (execp, f); -#else - read_symbols(execp, f); -#endif /* OBJ_COFF */ - if (execp->a_trsize) { -#ifndef OBJ_COFF -#ifndef OBJ_BOUT -#endif /* OBJ_COFF */ - printf("text reloc\n"); -#ifndef OBJ_COFF -#else - printf ("text reloc\n"); -#endif /* OBJ_BOUT */ -#endif /* OBJ_COFF */ - dump_reloc1 (execp, f, N_TRELOFF (*execp), execp->a_trsize); - } - if (execp->a_drsize) { -#ifndef OBJ_COFF -#ifndef OBJ_BOUT -#endif /* OBJ_COFF */ - printf("data reloc\n"); -#ifndef OBJ_COFF -#else - printf ("data reloc\n"); -#endif /* OBJ_BOUT */ -#endif /* OBJ_COFF */ - dump_reloc1 (execp, f, N_DRELOFF (*execp), execp->a_drsize); - } -#ifndef OBJ_COFF -#ifndef OBJ_BOUT -#endif /* OBJ_COFF */ - - return; -} /* dump_reloc() */ -#ifndef OBJ_COFF -#else -} -#endif /* OBJ_BOUT */ -#endif /* OBJ_COFF */ - -#ifndef OBJ_COFF -#ifndef OBJ_BOUT -#endif /* OBJ_COFF */ -static void dump_reloc1 (execp, f, off, size) -#ifndef OBJ_COFF -#else -dump_reloc1 (execp, f, off, size) -#endif /* OBJ_BOUT */ -struct exec *execp; -#else -fileheader *execp; -#endif /* OBJ_COFF */ -FILE *f; -#ifndef OBJ_COFF -#ifndef OBJ_BOUT -#endif /* OBJ_COFF */ -int off; -int size; -#ifndef OBJ_COFF -#endif /* OBJ_BOUT */ -#endif /* OBJ_COFF */ -{ - int nreloc; - struct relocation_info reloc; - int i; - - nreloc = size / sizeof (struct relocation_info); - -#ifndef OBJ_COFF -#ifndef OBJ_BOUT -#endif /* OBJ_COFF */ - if (!omit_reloc_numbers_flag) { - printf("%3s: ", "#"); - } /* if printing numbers */ - -#ifndef sparc - printf("%3s ", "len"); -#endif /* sparc */ - - printf("%8s %4s\n", "adr", "sym"); - - - fseek(f, off, 0); -#ifndef OBJ_COFF -#else - printf ("%3s: %3s %8s %4s\n", "#", "len", "adr", "sym"); - fseek (f, off, 0); -#endif /* OBJ_BOUT */ -#endif /* OBJ_COFF */ - for (i = 0; i < nreloc; i++) { -#ifndef OBJ_COFF -#ifndef OBJ_BOUT -#endif /* OBJ_COFF */ - if (fread((char *)&reloc, sizeof reloc, 1, f) != 1) { - fprintf(stderr, "%s: error reading reloc\n", -#ifndef OBJ_COFF -#else - if (fread ((char *)&reloc, sizeof reloc, 1, f) != 1) { - fprintf (stderr, "%s: error reading reloc\n", -#endif /* OBJ_BOUT */ -#endif /* OBJ_COFF */ - program_name); - return; - } -#ifndef OBJ_COFF -#ifndef OBJ_BOUT -#endif /* OBJ_COFF */ - - if (!omit_reloc_numbers_flag) { - printf("%3d: ", i); - } /* if printing numbers */ - -#ifndef sparc - printf("%3d ", 1 << reloc.r_length); -#endif /* sparc */ - - printf("%8lx ", (long unsigned) reloc.r_address); - -#ifndef B_OUT -#ifndef OBJ_COFF -#else - printf ("%3d: %3d %8x ", i, 1 << reloc.r_length, - reloc.r_address); - -#ifdef NOT -#endif /* OBJ_BOUT */ -#endif /* OBJ_COFF */ - if (reloc.r_extern) { -#ifndef OBJ_COFF -#ifndef OBJ_BOUT -#endif /* OBJ_COFF */ - if (!omit_sym_numbers_flag) { - (void) printf("%4d ", reloc.r_symbolnum); - } else { - (void) printf(" "); - } /* if printing sym numbers */ - -#ifndef OBJ_COFF -#else - printf ("%4d ", reloc.r_symbolnum); -#endif /* OBJ_BOUT */ -#endif /* OBJ_COFF */ - if (reloc.r_symbolnum < nsyms) -#ifndef OBJ_COFF -#ifndef OBJ_BOUT -#endif /* OBJ_COFF */ - printf("%s ", symtbl[reloc.r_symbolnum].n_un.n_name); -#ifndef OBJ_COFF -#else - printf ("%s ", - symtbl[reloc.r_symbolnum].n_un.n_name); -#endif /* OBJ_BOUT */ -#endif /* OBJ_COFF */ - } else { -#ifndef OBJ_COFF -#ifndef OBJ_BOUT -#endif /* OBJ_COFF */ - printf(" "); -#ifndef OBJ_COFF -#else - printf (" "); -#endif /* OBJ_BOUT */ -#endif /* OBJ_COFF */ - switch (reloc.r_symbolnum & ~N_EXT) { -#ifndef OBJ_COFF -#ifndef OBJ_BOUT -#endif /* OBJ_COFF */ - case N_TEXT: printf(".text "); break; - case N_DATA: printf(".data "); break; - case N_BSS: printf(".bss "); break; - case N_ABS: printf(".abs "); break; - default: printf("base %x ", (unsigned) reloc.r_symbolnum); break; -#ifndef OBJ_COFF -#else - case N_TEXT: printf (".text "); break; - case N_DATA: printf (".data "); break; - case N_BSS: printf (".bss "); break; - case N_ABS: printf (".abs "); break; - default: printf ("base %x ", reloc.r_symbolnum); break; -#endif /* OBJ_BOUT */ -#endif /* OBJ_COFF */ - } - } -#ifndef OBJ_COFF -#ifndef OBJ_BOUT -#endif /* OBJ_COFF */ -#endif /* not B_OUT */ - -#ifdef SPARC - if (reloc.r_addend) printf("+0x%x ", (unsigned) reloc.r_addend); - - switch (reloc.r_type) { - case RELOC_8: printf("R8 "); break; - case RELOC_16: printf("R16 "); break; - case RELOC_32: printf("R32 "); break; - case RELOC_DISP8: printf("DISP8 "); break; - case RELOC_DISP16: printf("DISP16 "); break; - case RELOC_DISP32: printf("DISP32 "); break; - case RELOC_WDISP30: printf("WDISP30 "); break; - case RELOC_WDISP22: printf("WDISP22 "); break; - case RELOC_HI22: printf("HI22 "); break; - case RELOC_22: printf("R22 "); break; - case RELOC_13: printf("R13 "); break; - case RELOC_LO10: printf("LO10 "); break; - case RELOC_SFA_BASE: printf("SFA_BASE "); break; - case RELOC_SFA_OFF13: printf("SFA_OFF13 "); break; - case RELOC_BASE10: printf("BASE10 "); break; - case RELOC_BASE13: printf("BASE13 "); break; - case RELOC_BASE22: printf("BASE22 "); break; - case RELOC_PC10: printf("PC10 "); break; - case RELOC_PC22: printf("PC22 "); break; - case RELOC_JMP_TBL: printf("JMP_TBL "); break; - case RELOC_SEGOFF16: printf("SEGOFF16 "); break; - case RELOC_GLOB_DAT: printf("GLOB_DAT "); break; - case RELOC_JMP_SLOT: printf("JMP_SLOT "); break; - case RELOC_RELATIVE: printf("RELATIVE "); break; - } /* switch on reloc type */ -#else /* SPARC */ - if (reloc.r_pcrel) printf("PCREL "); -#endif /* SPARC */ - -#ifdef B_OUT - if (reloc.r_bsr) printf("BSR "); - if (reloc.r_disp) printf("DISP "); - if (reloc.r_callj) printf("CALLJ "); - if (reloc.nuthin) printf("NUTHIN "); -#endif /* B_OUT */ - -#ifdef SPARC - { - struct reloc_info_sparc spare; - - bzero(&spare, sizeof(spare)); - - reloc.r_address = 0; - reloc.r_index = 0; - reloc.r_extern = 0; - reloc.r_type = 0; - reloc.r_addend = 0; - - if (bcmp(&reloc, &spare, sizeof(spare))) { - printf("(garbage in spare bits) "); - } /* if garbage in spare bits */ - } /* sparc */ -#endif /* SPARC */ - -#ifndef OBJ_COFF -#else -#endif /* NOT */ - if (reloc.r_pcrel) printf ("PCREL "); - if (reloc.r_bsr) printf ("BSR "); - if (reloc.r_disp) printf ("DISP "); - if (reloc.r_callj) printf ("CALLJ "); - if (reloc.nuthin) printf ("NUTHIN "); -#endif /* OBJ_BOUT */ -#endif /* OBJ_COFF */ -#if 0 -#ifndef OBJ_COFF -#ifndef OBJ_BOUT -#endif /* OBJ_COFF */ - if (reloc.r_pad) printf("PAD %x ", reloc.r_pad); -#ifndef OBJ_COFF -#else - if (reloc.r_pad) printf ("PAD %x ", reloc.r_pad); -#endif /* OBJ_BOUT */ -#endif /* OBJ_COFF */ -#endif -#ifndef OBJ_COFF -#ifndef OBJ_BOUT -#endif /* OBJ_COFF */ - printf("\n"); - } /* for each reloc record */ - - return; -} /* dump_reloc1() */ -#ifndef OBJ_COFF -#else - printf ("\n"); - } -} -#endif /* OBJ_BOUT */ -#else -#endif /* comment */ -#endif /* OBJ_COFF */ - -/* Allocate `n' bytes of memory dynamically, with error checking. */ - -#ifndef OBJ_COFF -char * -xmalloc (n) - unsigned n; -{ - char *p; - - p = malloc (n); - if (p == 0) - { -#ifndef OBJ_BOUT - fprintf(stderr, "%s: virtual memory exhausted\n", program_name); -#else - fprintf (stderr, "%s: virtual memory exhausted\n", program_name); -#endif /* OBJ_BOUT */ - exit (1); - } -#ifndef OBJ_BOUT - bzero(p, n); -#endif /* OBJ_BOUT */ - return p; -#ifndef OBJ_BOUT -#else -static char *xmalloc (n) -unsigned n; -{ - char *p; - - p = malloc (n); - if (p == NULL) - { - fprintf(stderr, "%s: virtual memory exhausted\n", program_name); - exit (1); - } - bzero(p, n); - return p; -#endif /* OBJ_COFF */ -} /* xmalloc() */ - -#ifdef OBJ_COFF -static char *xrealloc(p, size) -char *p; -unsigned size; -{ - p = realloc(p, size); - - if (p == NULL) { - fprintf(stderr, "%s: virtual memory exhausted\n", program_name); - exit (1); - } /* on malloc failure */ - - bzero(p, size); - return(p); -} /* xrealloc() */ - -#endif /* OBJ_COFF */ -/* - * Local Variables: - * comment-column: 0 - * fill-column: 131 - * End: - */ - -/* end of objdump.c */ -#ifndef OBJ_COFF -#else -} -#endif /* OBJ_BOUT */ -#endif /* OBJ_COFF */ diff --git a/gas/obsolete/gdb-blocks.c b/gas/obsolete/gdb-blocks.c deleted file mode 100644 index 15cd3478ca8..00000000000 --- a/gas/obsolete/gdb-blocks.c +++ /dev/null @@ -1,289 +0,0 @@ -/* gdb_block.c - Deal with GDB blocks - Copyright (C) 1987 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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 1, or (at your option) -any later version. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - * Implements .gdbblk, .gdbbeg, .gdbend concepts. - * No other modules need to know the details of these concepts. - * - * During assembly, note the addresses of block beginnings and ends. - * Each block has a begin-address, an end-address, a number, and - * a place in the GDB symbol file to place the 2 addresses. - * Block numbers are 0, 1, ... with no gaps. - * - * During assembly, we don't actually know the addresses, so they are - * expressed as {frag-address + offset-in-frag}. - * - * gdb_block_begin () - * Call once before using this package. - * - * gdb_block_beg (number, frag, offset) - * Note a block beginning. - * - * gdb_block_end (number, frag, offset) - * Note a block end. - * - * gdb_block_position (block_number, pos) - * Remember, after assembly, to copy a structure containing - * the beginning and ending addresses of block number - * block_number into the gdb file, starting at position pos. - * - * gdb_block_emit (block_number, where_in_gdb_symbol_file) - * Emit a block begin/end locations to a place in the GDB symbol - * file. - * - * uses: - * xmalloc() - * gdb_alter() - */ - - -#include "as.h" - -/* - * malloc() calls are considered expensive. So ... - * - * We remember blocks by making a tree, and each block number has a leaf. - * The tree is 3 levels, and we don't allocate interior nodes until they - * are needed. Both leaves and interior nodes are allocated in lumps, - * which should save on malloc() calls. Due to the way we break up a - * block number to navigate through the tree, we insist that lumps of - * memory contain a power of 2 items each. Powers of 2 may differ - * for different levels of tree. - */ - -/* - * A block number: - * - * +---------------+---------------+---------------+ - * | | | | - * | Z2-part bits | Z1-part bits | Z0-part bits | - * | | | | - * +---------------+---------------+---------------+ - * - * High order Low order - * - * "Z" is short for "siZe". - */ - -#define LOG_2_Z0 (8) /* How many bits are in Z0 part? */ -#define LOG_2_Z1 (8) /* How many bits are in Z1 part? */ -#define LOG_2_Z2 (8) /* How many bits are in Z2 part? */ - -#define BLOCK_NUMBER_LIMIT (1 << (LOG_2_Z0 + LOG_2_Z1 + LOG_2_Z2)) - /* What is the first block number that is */ - /* "too big"? */ - -struct gdb_block -{ - fragS * begin_frag; - fragS * end_frag; - long int begin_where_in_frag; - long int end_where_in_frag; - long int position; /* In GDB symbols file. */ -}; - -typedef struct gdb_block node_0_T [1 << LOG_2_Z0]; - -typedef node_0_T * node_1_T [1 << LOG_2_Z1]; - -typedef node_1_T * node_2_T [1 << LOG_2_Z2]; - - -static long int highest_block_number_seen; -static node_2_T * root; /* 3 level tree of block locations. */ - -static node_2_T * new_2 (); - - -char * xmalloc(); -void gdb_alter(); - -void -gdb_block_begin () -{ - root = new_2 (); - highest_block_number_seen = -1; -} - -static node_0_T * -new_0 () -{ - register node_0_T * place; - - place = (node_0_T *) xmalloc ((long)sizeof(node_0_T)); - bzero ((char *)place, sizeof(node_0_T)); - return (place); -} - -static node_1_T * -new_1 () -{ - register node_1_T * place; - - place = (node_1_T *) xmalloc ((long)sizeof(node_1_T)); - bzero ((char *)place, sizeof(node_1_T)); - return (place); -} - -static node_2_T * -new_2 () -{ - register node_2_T * place; - - place = (node_2_T *) xmalloc ((long)sizeof(node_2_T)); - bzero ((char *)place, sizeof(node_2_T)); - return (place); -} - -static struct gdb_block * -find (block_number) - register long int block_number; -{ - register node_1_T ** pp_1; - register node_0_T ** pp_0; - register struct gdb_block * b; - register int index0; - register int index1; - register int index2; - -#ifdef SUSPECT - if (block_number >= BLOCK_NUMBER_LIMIT) - { - as_fatal ("gdb_block: Block number = %ld.", block_number); - } -#endif - - index2 = block_number >> (LOG_2_Z0 + LOG_2_Z1); - index1 = block_number >> (LOG_2_Z0) & ((1 << LOG_2_Z1) - 1); - index0 = block_number & ((1 << LOG_2_Z0) - 1); - pp_1 = * root + index2; - if (* pp_1 == 0) - { - * pp_1 = new_1 (); - } - pp_0 = ** pp_1 + index1; - if (* pp_0 == 0) - { - * pp_0 = new_0 (); - } - b = ** pp_0 + index0; - return (b); -} - - -static struct gdb_block * -find_create (block_number) - long int block_number; -{ - if (highest_block_number_seen < block_number) - { - highest_block_number_seen = block_number; - } - return (find (block_number)); -} - -void -gdb_block_beg (block_number, frag, offset) - long int block_number; - fragS * frag; - long int offset; -{ - struct gdb_block * pointer; - - pointer = find_create (block_number); -#ifdef SUSPECT - if (pointer -> begin_frag != 0) - { - as_warn( "Overwriting begin_frag for block # %ld.", block_number ); - } - if (pointer -> begin_where_in_frag != 0) - { - as_warn( "Overwriting begin_where_in_frag for block # %ld.", block_number ); - } -#endif - pointer -> begin_frag = frag; - pointer -> begin_where_in_frag = offset; -} - -void -gdb_block_end (block_number, frag, offset) - long int block_number; - fragS * frag; - long int offset; -{ - struct gdb_block * pointer; - - pointer = find_create (block_number); -#ifdef SUSPECT - if (pointer -> end_frag != 0) - { - as_warn( "Overwriting end_frag for block # %ld.", block_number ); - } - if (pointer -> end_where_in_frag != 0) - { - as_warn( "Overwriting end_where_in_frag for block # %ld.", block_number ); - } -#endif - pointer -> end_frag = frag; - pointer -> end_where_in_frag = offset; -} - -void -gdb_block_position (block_number, pos) - long int block_number; - long int pos; -{ - struct gdb_block * pointer; - - pointer = find_create (block_number); - if (pointer -> position != 0) - { - as_warn( "Overwriting old position %ld. in block #%ld.", - pointer -> position, block_number); - } - pointer -> position = pos; -} - -void -gdb_block_emit () -{ - long int block_number; - struct gdb_block * b; - - for (block_number = 0; - block_number <= highest_block_number_seen; - block_number ++) - { - b = find (block_number); - if (b -> begin_frag) - { - gdb_alter (b -> position, - (long int) - (b -> begin_frag -> fr_address + b -> begin_where_in_frag)); - } - if (b -> end_frag) - { - gdb_alter (b -> position + sizeof( long int ), - (long int) - (b -> end_frag -> fr_address + b -> end_where_in_frag)); - } - } -} - -/* end: gdb_block.c */ diff --git a/gas/obsolete/gdb-file.c b/gas/obsolete/gdb-file.c deleted file mode 100644 index 42938adb670..00000000000 --- a/gas/obsolete/gdb-file.c +++ /dev/null @@ -1,80 +0,0 @@ -/* gdb_file.c -o/s specific- - Copyright (C) 1987 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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 1, or (at your option) -any later version. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include -#include - -static long file_len; -static FILE *file; -extern long get_len(); - - -void -gdb_file_begin () -{ -} - -void -gdb_file_end() -{ -} - -long int /* Open file, return size. 0: failed. */ -gdb_file_size (filename) -char *filename; -{ - struct stat stat_buf; - void as_perror(); - - file= fopen (filename, "r"); - if (file == (FILE *)NULL) - { - as_perror ("Can't read GDB symbolic information file", filename); - file_len=0; - } else { - (void)fstat (fileno(file), &stat_buf); - file_len=stat_buf . st_size; - } - return ((long int)file_len ); -} - -void /* Read the file, don't return if failed. */ -gdb_file_read (buffer, filename) - char * buffer; - char * filename; -{ - register off_t size_wanted; - void as_perror(); - - size_wanted = file_len; - if (fread (buffer, size_wanted, 1, file) != 1) - { - as_perror ("Can't read GDB symbolic info file", filename); - as_fatal ("Failed to read %ld. chars of GDB symbolic information", - size_wanted); - } - if (fclose(file)==EOF) - { - as_perror ("Can't close GDB symbolic info file", filename); - as_fatal ("I quit in disgust"); - } -} - -/* end: gdb_file.c */ diff --git a/gas/obsolete/gdb-lines.c b/gas/obsolete/gdb-lines.c deleted file mode 100644 index 6af0c429df6..00000000000 --- a/gas/obsolete/gdb-lines.c +++ /dev/null @@ -1,241 +0,0 @@ -/* gdb-lines.c -- Deal with source lines for GDB format - Copyright (C) 1989, Free Software Foundation. - -This file is part of GAS, the GNU Assembler. - -GAS 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 1, or (at your option) -any later version. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include "as.h" -#include "obstack.h" -#include "frags.h" - -/* This is a souce file that we're storing .gdbline information about */ -/* .gdbline refers to files by numbers. We keep a linked list of them - We store a list of vectors for each file. Each element of the vector - contains a line-number, a frag, and an offset within the frag. */ -struct g_line_file { - int gdb_line_file_file_number; /* fnum */ - int gdb_line_file_number_of_vectors; /* nv */ - long gdb_line_table_offset; /* taboff */ - struct g_line_vector *gdb_line_file_vectors; /* vec */ - struct g_line_file *gdb_line_file_next_file; /* nfile */ -}; - -/* In order to save on space (We expect there to be LOTS of lines), we - store line-number/address pairs in bunches of MAX_LINES_PER_VECTOR - (originally fifty). Each vector descriptor contains - - gdb_line_number_of_lines the number of line-number/address pairs - actually in this vector. - gdb_line_lines The actual vector. - - gdb_line_next_vector The next vector descriptor in the linked list. - */ -struct g_line_vector { - int gdb_line_number_of_lines; /* nlines */ - struct g_line *gdb_line_lines; /* lines */ - struct g_line_vector *gdb_line_next_vector; /* nvec */ -}; - - -/* A .gdbline wants to store a line-number/address pair. Unfortunatly, we - don't know addresses yet, so we store frag/offset which we can use to - generate the address at write-out time. */ -struct g_line { - int gdb_line_line_number; /* lno */ - fragS *gdb_line_frag; /* lfrag */ - int gdb_line_offset; /* loff */ -}; - - -/* The following is stolen from (gdb's? (or is it gcc's?) symseg.h file. - These structures describe the format for the line# symbolic info in - the gdb symbolic info file. This info is not particularly useful, - except to show what we're writing into. . . */ - -/* Source-file information. - This describes the relation between source files and line numbers - and addresses in the program text. */ - -struct sourcevector -{ - int length; /* Number of source files described */ - struct source *source[1]; /* Descriptions of the files */ -}; - -/* Line number and address of one line. */ - -struct line -{ - int linenum; - int address; -}; - -/* All the information on one source file. */ - -struct source -{ - char *name; /* Name of file */ - int nlines; /* Number of lines that follow */ - struct line lines[1]; /* Information on each line */ -}; - -/* End of text from symseg.h */ - -struct g_line_file *first_file; - -struct g_line_file *add_file(); -struct g_line_vector *add_vector(); - -#define MAX_LINES_PER_VECTOR 50 /* lpv */ - -/* We've been told that the current address corresponds to line LINENO in - file FILE_NUMBER */ -void -gdb_line(file_number,lineno) -int file_number; -int lineno; -{ - struct g_line_file *f; - struct g_line_vector *v; - struct g_line *line; - - for(f=first_file;f;f=f->gdb_line_file_next_file) - if(f->gdb_line_file_file_number==file_number) - break; - if(!f) f=add_file(file_number); - v=f->gdb_line_file_vectors; - if(!v || v->gdb_line_number_of_lines==MAX_LINES_PER_VECTOR) - v=add_vector(f); - line= &(v->gdb_line_lines)[v->gdb_line_number_of_lines]; - v->gdb_line_number_of_lines++; - line->gdb_line_line_number=lineno; - line->gdb_line_frag= frag_now; - line->gdb_line_offset=obstack_next_free(&frags)-frag_now->fr_literal; -} - -/* We've been told where to store the .line table for file FILE_NUMBER */ -void -gdb_line_tab(file_number,offset) -int file_number; -int offset; -{ - struct g_line_file *f; - - for(f=first_file;f;f=f->gdb_line_file_next_file) - if(f->gdb_line_file_file_number==file_number) - break; - if(!f) f=add_file(file_number); - if(f->gdb_line_table_offset) - as_warn("Ignoring duplicate .linetab for file %d",file_number); - else - f->gdb_line_table_offset=offset; -} - -/* We've got a file (FILE_NUMBER) that we haven't heard about before. Create - an entry for it, etc. . . */ -struct g_line_file * -add_file(file_number) -{ - struct g_line_file *f; - - f=(struct g_line_file *)xmalloc(sizeof(struct g_line_file)); - f->gdb_line_file_file_number=file_number; - f->gdb_line_table_offset = 0; - f->gdb_line_file_number_of_vectors=0; - f->gdb_line_file_vectors=(struct g_line_vector *)0; - f->gdb_line_file_next_file=first_file; - first_file=f; - return f; -} - -/* The last vector for file F is full. Allocate a new one. */ -struct g_line_vector * -add_vector(f) -struct g_line_file *f; -{ - struct g_line_vector *tmp_vec; - - f->gdb_line_file_number_of_vectors++; - tmp_vec=(struct g_line_vector *)xmalloc(sizeof(struct g_line_vector)); - tmp_vec->gdb_line_number_of_lines=0; - tmp_vec->gdb_line_lines=(struct g_line *)xmalloc(MAX_LINES_PER_VECTOR*sizeof(struct g_line)); - tmp_vec->gdb_line_next_vector=f->gdb_line_file_vectors; - f->gdb_line_file_vectors=tmp_vec; - return tmp_vec; -} - -/* All done. Time to write the stuff out. This should be fun. */ -void -gdb_lines_emit() -{ - struct g_line_file *f; - struct g_line_vector *v,*old_v,*v_tmp; - struct g_line *current_line_pointer; /* lp */ - int n; - int previous_line_number; - long int current_gdb_segment_pos; - unsigned int number_of_things_in_table; - - for(f=first_file;f;f=f->gdb_line_file_next_file) { - if(!f->gdb_line_table_offset) { - as_warn("No .gdblinetab given for file %d. Ignoring .gdbline(s) for it."); - continue; - } - - /* Reverse the linked list of vectors. Since we built it - last entry first, this puts the first entry at the start - of the list. Thus we can manage to put out low line #s - at the start of the table. . .*/ - v_tmp=0; - old_v=0; - for(v=f->gdb_line_file_vectors;v;v=v_tmp) { - v_tmp=v->gdb_line_next_vector; - v->gdb_line_next_vector=old_v; - old_v=v; - } - f->gdb_line_file_vectors=old_v; - - /* Start putting stuff at the beginning of the table */ - current_gdb_segment_pos=f->gdb_line_table_offset+sizeof(long int); - previous_line_number = -2; - number_of_things_in_table = 0; - - /* For every vector in the table: */ - for(v=f->gdb_line_file_vectors;v;v=v->gdb_line_next_vector) { - current_line_pointer=v->gdb_line_lines; - - /* For every element of every vector */ - for(n=v->gdb_line_number_of_lines;n;n--) { - - if(current_line_pointer->gdb_line_line_number != previous_line_number + 1) { - /* Write out the line number */ - gdb_alter(current_gdb_segment_pos, -(current_line_pointer->gdb_line_line_number)); - current_gdb_segment_pos+=sizeof(long int); - number_of_things_in_table++; - } - previous_line_number = current_line_pointer->gdb_line_line_number; - - /* And write out the address */ - gdb_alter(current_gdb_segment_pos,current_line_pointer->gdb_line_frag->fr_address+current_line_pointer->gdb_line_offset); - current_gdb_segment_pos+=sizeof(long int); - number_of_things_in_table++; - - current_line_pointer++; - } - } - gdb_alter(f->gdb_line_table_offset,number_of_things_in_table); - } -} diff --git a/gas/obsolete/gdb-symbols.c b/gas/obsolete/gdb-symbols.c deleted file mode 100644 index 8bd8f7d5c12..00000000000 --- a/gas/obsolete/gdb-symbols.c +++ /dev/null @@ -1,129 +0,0 @@ -/* gdb_symbols.c - Deal with symbols for GDB format - Copyright (C) 1987 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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 1, or (at your option) -any later version. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - * During assembly, note requests to place symbol values in the GDB - * symbol file. When symbol values are known and the symbol file is - * in memory, place the symbol values in the memory image of the file. - * - * This has static data: it is not data_sharable. - * - * gdb_symbols_begin () - * Call once before using this package. - * - * gdb_symbols_fixup (symbolP, offset_in_file) - * Remember to put the value of a symbol into the GDB file. - * - * gdb_symbols_emit () - * Perform all the symbol fixups. - * - * uses: - * xmalloc() - * gdb_alter() - */ - -#include "as.h" -#include "struc-symbol.h" - -#define SYM_GROUP (100) /* We allocate storage in lumps this big. */ - - -struct gdb_symbol /* 1 fixup request. */ -{ - symbolS * gs_symbol; - long int gs_offset; /* Where in GDB symbol file. */ -}; -typedef struct gdb_symbol gdb_symbolS; - -struct symbol_fixup_group -{ - struct symbol_fixup_group * sfg_next; - gdb_symbolS sfg_item [SYM_GROUP]; -}; -typedef struct symbol_fixup_group symbol_fixup_groupS; - -static symbol_fixup_groupS * root; -static short int used; /* # of last slot used. */ - /* Counts down from SYM_GROUP. */ - -static symbol_fixup_groupS * /* Make storage for some more reminders. */ -new_sfg () -{ - symbol_fixup_groupS * newP; - char * xmalloc(); - - newP = (symbol_fixup_groupS *) xmalloc ((long)sizeof(symbol_fixup_groupS)); - newP -> sfg_next = root; - used = SYM_GROUP; - root = newP; - return (newP); -} - - -void -gdb_symbols_begin () -{ - root = 0; - (void)new_sfg (); -} - - -void /* Build a reminder to put a symbol value */ -gdb_symbols_fixup (sy, offset) /* into the GDB symbol file. */ - symbolS * sy; /* Which symbol. */ - long int offset; /* Where in GDB symbol file. */ -{ - register symbol_fixup_groupS * p; - register gdb_symbolS * q; - - p = root; - know( used >= 0 ); - if ( used == 0) - { - p = new_sfg (); - } - q = p -> sfg_item + -- used; - q -> gs_symbol = sy; - q -> gs_offset = offset; -} - -void -gdb_symbols_emit () /* Append GDB symbols to object file. */ -{ - symbol_fixup_groupS * sfgP; - void gdb_alter(); - - for (sfgP = root; sfgP; sfgP = sfgP -> sfg_next) - { - register gdb_symbolS * gsP; - register gdb_symbolS * limit; - - limit = sfgP -> sfg_item + - (sfgP -> sfg_next ? 0 : used); - for (gsP = sfgP -> sfg_item + SYM_GROUP - 1; - gsP >= limit; - gsP --) - { - gdb_alter (gsP -> gs_offset, - (long int) gsP -> gs_symbol -> sy_value); - } - } -} - -/* end: gdb_symbols.c */ diff --git a/gas/obsolete/gdb.c b/gas/obsolete/gdb.c deleted file mode 100644 index 4896e2ec747..00000000000 --- a/gas/obsolete/gdb.c +++ /dev/null @@ -1,110 +0,0 @@ -/* gdb.c -as supports gdb- - Copyright (C) 1987 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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 1, or (at your option) -any later version. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* This code is independent of the underlying operating system. */ - -#include "as.h" - -static long int size; /* 0 or size of GDB symbol file. */ -static char * where; /* Where we put symbol file in memory. */ - -#define SUSPECT /* JF */ - -long int /* 0 means don't call gdb_... routines */ -gdb_begin (filename) /* because we failed to establish file */ - /* in memory. */ - char * filename; /* NULL: we have nothing to do. */ -{ - long int gdb_file_size(); - char * xmalloc(); - void gdb_file_begin(); - void gdb_file_read(); - void gdb_block_begin(); - void gdb_symbols_begin(); - - gdb_file_begin(); - size = 0; - if (filename && (size = gdb_file_size (filename))) - { - where = xmalloc( (long) size ); - gdb_file_read (where, filename); /* Read, then close file. */ - gdb_block_begin(); - gdb_symbols_begin(); - } - return (size); -} - -void -gdb_end() -{ - void gdb_file_end(); - - gdb_file_end(); -} - -void -gdb_emit (filename) /* Append GDB symbols to object file. */ -char * filename; -{ - void gdb_block_emit(); - void gdb_symbols_emit(); - void gdb_lines_emit(); - void output_file_append(); - - gdb_block_emit (); - gdb_symbols_emit (); - gdb_lines_emit(); - output_file_append (where, size, filename); -} - - - -/* - Notes: We overwrite what was there. - We assume all overwrites are 4-char numbers. -*/ - -void -gdb_alter (offset, value) /* put value into GDB file + offset. */ - long int offset; - long int value; -{ - void md_number_to_chars(); - -#ifdef SUSPECT - if (offset > size - sizeof(long int) || offset < 0) - { - as_warn( "gdb_alter: offset=%d. size=%ld.\n", offset, size ); - return; - } -#endif - -#ifdef B_OUT - /* Symbol info will be used on the host machine only (only executable - * code is actually downloaded to the i80960). Therefore, leave it - * in host byte order. - */ - - *(long int *)(where + offset) = value; -#else - md_number_to_chars (where + offset, value, 4); -#endif -} - -/* end: gdb.c */ diff --git a/gas/output-file.c b/gas/output-file.c deleted file mode 100644 index 423bab27714..00000000000 --- a/gas/output-file.c +++ /dev/null @@ -1,83 +0,0 @@ -/* output-file.c - Deal with the output file - Copyright (C) 1987, 1990, 1991 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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 1, or (at your option) -any later version. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* static const char rcsid[] = "$Id$"; */ - -/* - * Confines all details of emitting object bytes to this module. - * All O/S specific crocks should live here. - * What we lose in "efficiency" we gain in modularity. - * Note we don't need to #include the "as.h" file. No common coupling! - */ - - /* note that we do need config info. xoxorich. */ - -/* #include "style.h" */ -#include - -#include "as.h" - -#include "output-file.h" - -static FILE *stdoutput; - -void output_file_create(name) -char *name; -{ - if(name[0]=='-' && name[1]=='\0') - stdoutput=stdout; - else if ( ! (stdoutput = fopen( name, "w" )) ) - { - as_perror ("FATAL: Can't create %s", name); - exit(42); - } -} /* output_file_create() */ - - - -void output_file_close(filename) -char *filename; -{ - if ( EOF == fclose( stdoutput ) ) - { - as_perror ("FATAL: Can't close %s", filename); - exit(42); - } - stdoutput = NULL; /* Trust nobody! */ -} /* output_file_close() */ - -void output_file_append(where, length, filename) -char *where; -long length; -char *filename; -{ - - for (; length; length--,where++) - { - (void)putc(*where,stdoutput); - if(ferror(stdoutput)) - /* if ( EOF == (putc( *where, stdoutput )) ) */ - { - as_perror("Failed to emit an object byte", filename); - as_fatal("Can't continue"); - } - } -} /* output_file_append() */ - -/* end: output-file.c */ diff --git a/gas/output-file.h b/gas/output-file.h deleted file mode 100644 index f5c80738afd..00000000000 --- a/gas/output-file.h +++ /dev/null @@ -1,18 +0,0 @@ - - -#ifdef __STDC__ - -void output_file_append(char *where, long length, char *filename); -void output_file_close(char *filename); -void output_file_create(char *name); - -#else /* __STDC__ */ - -void output_file_append(); -void output_file_close(); -void output_file_create(); - -#endif /* __STDC__ */ - - -/* end of output-file.h */ diff --git a/gas/read.c b/gas/read.c deleted file mode 100644 index 818f1396d56..00000000000 --- a/gas/read.c +++ /dev/null @@ -1,2281 +0,0 @@ -/* read.c - read a source file - - Copyright (C) 1986, 1987, 1990, 1991 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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 1, or (at your option) -any later version. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* static const char rcsid[] = "$Id$"; */ - -#define MASK_CHAR (0xFF) /* If your chars aren't 8 bits, you will - change this a bit. But then, GNU isn't - spozed to run on your machine anyway. - (RMS is so shortsighted sometimes.) - */ - -#define MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT (16) - /* This is the largest known floating point */ - /* format (for now). It will grow when we */ - /* do 4361 style flonums. */ - - -/* Routines that read assembler source text to build spagetti in memory. */ -/* Another group of these functions is in the as-expr.c module */ - -#include "as.h" - -#include "obstack.h" - -char *input_line_pointer; /*->next char of source file to parse. */ - - -#if BITS_PER_CHAR != 8 -The following table is indexed by [ (char) ] and will break if -a char does not have exactly 256 states (hopefully 0:255!) ! -#endif - -const char /* used by is_... macros. our ctype[] */ -lex_type [256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* @ABCDEFGHIJKLMNO */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* PQRSTUVWXYZ[\]^_ */ - 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, /* _!"#$%&'()*+,-./ */ - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, /* 0123456789:;<=>? */ - 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* @ABCDEFGHIJKLMNO */ - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 3, /* PQRSTUVWXYZ[\]^_ */ - 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* `abcdefghijklmno */ - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, /* pqrstuvwxyz{|}~. */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; - - -/* - * In: a character. - * Out: 1 if this character ends a line. - */ -#define _ (0) -char is_end_of_line [256] = { -#ifdef CR_EOL - _, _, _, _, _, _, _, _, _, _,99, _, _, 99, _, _,/* @abcdefghijklmno */ -#else - _, _, _, _, _, _, _, _, _, _,99, _, _, _, _, _, /* @abcdefghijklmno */ -#endif - _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */ - _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */ - _, _, _, _, _, _, _, _, _, _, _,99, _, _, _, _, /* 0123456789:;<=>? */ - _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */ - _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */ - _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */ - _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */ - _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */ - _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */ - _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */ - _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* */ - _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ /* */ -}; -#undef _ - - /* Functions private to this file. */ - -char line_comment_chars[1]; -char line_separator_chars[1]; - -static char *buffer; /* 1st char of each buffer of lines is here. */ -static char *buffer_limit; /*->1 + last char in buffer. */ - -static char *bignum_low; /* Lowest char of bignum. */ -static char *bignum_limit; /* 1st illegal address of bignum. */ -static char *bignum_high; /* Highest char of bignum. */ - /* May point to (bignum_start-1). */ - /* Never >= bignum_limit. */ -static char *old_buffer = 0; /* JF a hack */ -static char *old_input; -static char *old_limit; - -/* Variables for handling include file directory list. */ - -char **include_dirs; /* List of pointers to directories to - search for .include's */ -int include_dir_count; /* How many are in the list */ -int include_dir_maxlen = 1; /* Length of longest in list */ - -#ifndef WORKING_DOT_WORD -struct broken_word *broken_words; -int new_broken_words = 0; -#endif - -#ifdef __STDC__ - -static char *demand_copy_string(int *lenP); -static int is_it_end_of_statement(void); -static unsigned int next_char_of_string(void); -static segT get_known_segmented_expression(expressionS *expP); -static void grow_bignum(void); -static void pobegin(void); -static void stringer(int append_zero); - -#else /* __STDC__ */ - -static char *demand_copy_string(); -static int is_it_end_of_statement(); -static unsigned int next_char_of_string(); -static segT get_known_segmented_expression(); -static void grow_bignum(); -static void pobegin(); -static void stringer(); - -#endif /* __STDC__ */ - - -void -read_begin() -{ - char *p; - - pobegin(); - obj_read_begin_hook(); - - obstack_begin(¬es, 5000); - /* Start off assuming that we won't need more than 20 levels - of .if/.endif; if we need more, we can always get it. */ - obstack_begin (&cond_obstack, 20); - /* We start life accepting input. */ - obstack_1grow (&cond_obstack, 1); - -#define BIGNUM_BEGIN_SIZE (16) - bignum_low = xmalloc((long)BIGNUM_BEGIN_SIZE); - bignum_limit = bignum_low + BIGNUM_BEGIN_SIZE; - - /* Use machine dependent syntax */ - for (p = line_separator_chars; *p; p++) - is_end_of_line[*p] = 1; - /* Use more. FIXME-SOMEDAY. */ -} - -/* set up pseudo-op tables */ - -struct hash_control * -po_hash = NULL; /* use before set up: NULL->address error */ - -#ifdef DONTDEF -void s_gdbline(), s_gdblinetab(); -void s_gdbbeg(), s_gdbblock(), s_gdbend(), s_gdbsym(); -#endif - -static const pseudo_typeS -potable[] = -{ - { "abort", s_abort, 0 }, - { "align", s_align_ptwo, 0 }, - { "ascii", stringer, 0 }, - { "asciz", stringer, 1 }, -/* block */ - { "byte", cons, 1 }, - { "comm", s_comm, 0 }, - { "data", s_data, 0 }, -/* dim */ - { "double", float_cons, 'd' }, -/* dsect */ - { "eject", s_ignore, 0 }, /* Formfeed listing */ - { "else", s_else, 0 }, - { "end", s_end, 0 }, - { "endif", s_endif, 0 }, -/* endef */ - { "equ", s_set, 0 }, -/* err */ -/* extend */ - { "extern", s_ignore, 0 }, /* We treat all undef as ext */ - { "app-file", s_app_file, 0 }, - { "file", s_app_file, 0 }, - { "fill", s_fill, 0 }, - { "float", float_cons, 'f' }, -#ifdef DONTDEF - { "gdbbeg", s_gdbbeg, 0 }, - { "gdbblock", s_gdbblock, 0 }, - { "gdbend", s_gdbend, 0 }, - { "gdbsym", s_gdbsym, 0 }, - { "gdbline", s_gdbline, 0 }, - { "gdblinetab",s_gdblinetab, 0 }, -#endif - { "global", s_globl, 0 }, - { "globl", s_globl, 0 }, - { "hword", cons, 2 }, - { "if", s_if, 0 }, - { "ifdef", s_ifdef, 0 }, - { "ifeqs", s_ifeqs, 0 }, - { "ifndef", s_ifdef, 1 }, - { "ifnes", s_ifeqs, 1 }, - { "ifnotdef", s_ifdef, 1 }, - { "include", s_include, 0 }, - { "int", cons, 4 }, - { "lcomm", s_lcomm, 0 }, - { "lflags", s_ignore, 0 }, /* Listing flags */ - { "list", s_ignore, 0 }, /* Turn listing on */ - { "long", cons, 4 }, - { "lsym", s_lsym, 0 }, - { "nolist", s_ignore, 0 }, /* Turn listing off */ - { "octa", big_cons, 16 }, - { "org", s_org, 0 }, -/* print */ - { "quad", big_cons, 8 }, - { "sbttl", s_ignore, 0 }, /* Subtitle of listing */ -/* scl */ -/* sect */ - { "set", s_set, 0 }, - { "short", cons, 2 }, - { "single", float_cons, 'f' }, -/* size */ - { "space", s_space, 0 }, -/* tag */ - { "text", s_text, 0 }, - { "title", s_ignore, 0 }, /* Listing title */ -/* type */ -/* use */ -/* val */ - { "word", cons, 2 }, - { NULL} /* end sentinel */ -}; - -static void pobegin() { - char * errtxt; /* error text */ - const pseudo_typeS * pop; - - po_hash = hash_new(); - - /* Do the target-specific pseudo ops. */ - for (pop=md_pseudo_table; pop->poc_name; pop++) { - errtxt = hash_insert (po_hash, pop->poc_name, (char *)pop); - if (errtxt && *errtxt) { - as_fatal("error constructing md pseudo-op table"); - } /* on error */ - } /* for each op */ - - /* Now object specific. Skip any that were in the target table. */ - for (pop=obj_pseudo_table; pop->poc_name; pop++) { - errtxt = hash_insert (po_hash, pop->poc_name, (char *)pop); - if (errtxt && *errtxt) { - if (!strcmp (errtxt, "exists")) { -#ifdef DIE_ON_OVERRIDES - as_fatal("pseudo op \".%s\" overridden.\n", pop->poc_name); -#endif /* DIE_ON_OVERRIDES */ - continue; /* OK if target table overrides. */ - } else { - as_fatal("error constructing obj pseudo-op table"); - } /* if overridden */ - } /* on error */ - } /* for each op */ - - /* Now portable ones. Skip any that we've seen already. */ - for (pop=potable; pop->poc_name; pop++) { - errtxt = hash_insert (po_hash, pop->poc_name, (char *)pop); - if (errtxt && *errtxt) { - if (!strcmp (errtxt, "exists")) { -#ifdef DIE_ON_OVERRIDES - as_fatal("pseudo op \".%s\" overridden.\n", pop->poc_name); -#endif /* DIE_ON_OVERRIDES */ - continue; /* OK if target table overrides. */ - } else { - as_fatal("error constructing obj pseudo-op table"); - } /* if overridden */ - } /* on error */ - } /* for each op */ - - return; -} /* pobegin() */ - -#define HANDLE_CONDITIONAL_ASSEMBLY() \ - if (ignore_input ()) \ - { \ - while (! is_end_of_line[*input_line_pointer++]) \ - if (input_line_pointer == buffer_limit) \ - break; \ - continue; \ - } - -/* read_a_source_file() - * - * We read the file, putting things into a web that - * represents what we have been reading. - */ -void read_a_source_file(name) -char *name; -{ - register char c; - register char * s; /* string of symbol, '\0' appended */ - register int temp; - /* register struct frag * fragP; JF unused */ /* a frag we just made */ - pseudo_typeS *pop; -#ifdef DONTDEF - void gdb_block_beg(); - void gdb_block_position(); - void gdb_block_end(); - void gdb_symbols_fixup(); -#endif - - buffer = input_scrub_new_file(name); - - while ((buffer_limit = input_scrub_next_buffer(&input_line_pointer)) != 0) { /* We have another line to parse. */ - know(buffer_limit[-1] == '\n'); /* Must have a sentinel. */ - contin: /* JF this goto is my fault I admit it. Someone brave please re-write - the whole input section here? Pleeze??? */ - while (input_line_pointer < buffer_limit) { /* We have more of this buffer to parse. */ - /* - * We now have input_line_pointer->1st char of next line. - * If input_line_pointer [-1] == '\n' then we just - * scanned another line: so bump line counters. - */ - if (input_line_pointer[-1] == '\n') { - bump_line_counters(); - } /* just passed a newline */ - /* - * We are at the begining of a line, or similar place. - * We expect a well-formed assembler statement. - * A "symbol-name:" is a statement. - * - * Depending on what compiler is used, the order of these tests - * may vary to catch most common case 1st. - * Each test is independent of all other tests at the (top) level. - * PLEASE make a compiler that doesn't use this assembler. - * It is crufty to waste a compiler's time encoding things for this - * assembler, which then wastes more time decoding it. - * (And communicating via (linear) files is silly! - * If you must pass stuff, please pass a tree!) - */ - if ((c = *input_line_pointer++) == '\t' || c == ' ' || c=='\f') { - c = *input_line_pointer++; - } - know(c != ' '); /* No further leading whitespace. */ - /* - * C is the 1st significant character. - * Input_line_pointer points after that character. - */ - if (is_name_beginner(c)) { /* want user-defined label or pseudo/opcode */ - HANDLE_CONDITIONAL_ASSEMBLY(); - - s = --input_line_pointer; - c = get_symbol_end(); /* name's delimiter */ - /* - * C is character after symbol. - * That character's place in the input line is now '\0'. - * S points to the beginning of the symbol. - * [In case of pseudo-op, s->'.'.] - * Input_line_pointer->'\0' where c was. - */ - if (c == ':') { - colon(s); /* user-defined label */ - * input_line_pointer ++ = ':'; /* Put ':' back for error messages' sake. */ - /* Input_line_pointer->after ':'. */ - SKIP_WHITESPACE(); - } else if (c == '=' || input_line_pointer[1] == '=') { /* JF deal with FOO=BAR */ - equals(s); - demand_empty_rest_of_line(); - } else { /* expect pseudo-op or machine instruction */ - if (*s == '.') { - /* - * PSEUDO - OP. - * - * WARNING: c has next char, which may be end-of-line. - * We lookup the pseudo-op table with s+1 because we - * already know that the pseudo-op begins with a '.'. - */ - - pop = (pseudo_typeS *) hash_find(po_hash, s+1); - - /* Print the error msg now, while we still can */ - if (!pop) { - as_bad("Unknown pseudo-op: `%s'",s); - *input_line_pointer = c; - s_ignore(0); - break; - } - - /* Put it back for error messages etc. */ - *input_line_pointer = c; - /* The following skip of whitespace is compulsory. */ - /* A well shaped space is sometimes all that separates keyword from operands. */ - if (c == ' ' || c == '\t') { - input_line_pointer++; - } /* Skip seperator after keyword. */ - /* - * Input_line is restored. - * Input_line_pointer->1st non-blank char - * after pseudo-operation. - */ - if (!pop) { - ignore_rest_of_line(); - break; - } else { - (*pop->poc_handler)(pop->poc_val); - } /* if we have one */ - } else { /* machine instruction */ - /* WARNING: c has char, which may be end-of-line. */ - /* Also: input_line_pointer->`\0` where c was. */ - * input_line_pointer = c; - while (!is_end_of_line[*input_line_pointer]) { - input_line_pointer++; - } - c = *input_line_pointer; - *input_line_pointer = '\0'; - md_assemble(s); /* Assemble 1 instruction. */ - *input_line_pointer++ = c; - /* We resume loop AFTER the end-of-line from this instruction */ - } /* if (*s=='.') */ - } /* if c==':' */ - continue; - } /* if (is_name_beginner(c) */ - - - if (is_end_of_line [c]) { - continue; - } /* empty statement */ - - if (isdigit(c)) { /* local label ("4:") */ - HANDLE_CONDITIONAL_ASSEMBLY (); - - temp = c - '0'; -#ifdef LOCAL_LABELS_DOLLAR - if (*input_line_pointer=='$') - input_line_pointer++; -#endif - if (* input_line_pointer ++ == ':') - { - local_colon (temp); - } - else - { - as_bad("Spurious digit %d.", temp); - input_line_pointer -- ; - ignore_rest_of_line(); - } - continue; - } /* local label ("4:") */ - - if (c && strchr(line_comment_chars,c)) { /* Its a comment. Better say APP or NO_APP */ - char *ends; - char *new_buf; - char *new_tmp; - int new_length; - char *tmp_buf = 0; - extern char *scrub_string,*scrub_last_string; - - bump_line_counters(); - s=input_line_pointer; - if (strncmp(s,"APP\n",4)) - continue; /* We ignore it */ - s+=4; - - ends=strstr(s,"#NO_APP\n"); - - if (!ends) { - int tmp_len; - int num; - - /* The end of the #APP wasn't in this buffer. We - keep reading in buffers until we find the #NO_APP - that goes with this #APP There is one. The specs - guarentee it. . . */ - tmp_len=buffer_limit-s; - tmp_buf=xmalloc(tmp_len); - bcopy(s,tmp_buf,tmp_len); - do { - new_tmp = input_scrub_next_buffer(&buffer); - if (!new_tmp) - break; - else - buffer_limit = new_tmp; - input_line_pointer = buffer; - ends = strstr(buffer,"#NO_APP\n"); - if (ends) - num=ends-buffer; - else - num=buffer_limit-buffer; - - tmp_buf = xrealloc(tmp_buf, tmp_len + num); - bcopy(buffer,tmp_buf+tmp_len,num); - tmp_len+=num; - } while(!ends); - - input_line_pointer= ends ? ends+8 : NULL; - - s=tmp_buf; - ends=s+tmp_len; - - } else { - input_line_pointer=ends+8; - } - new_buf=xmalloc(100); - new_length=100; - new_tmp=new_buf; - - scrub_string=s; - scrub_last_string = ends; - for(;;) { - int ch; - - ch = do_scrub_next_char(scrub_from_string, scrub_to_string); - if (ch==EOF) break; - *new_tmp++=ch; - if (new_tmp==new_buf+new_length) { - new_buf=xrealloc(new_buf,new_length+100); - new_tmp=new_buf+new_length; - new_length+=100; - } - } - - if (tmp_buf) - free(tmp_buf); - old_buffer=buffer; - old_input=input_line_pointer; - old_limit=buffer_limit; - buffer=new_buf; - input_line_pointer=new_buf; - buffer_limit=new_tmp; - continue; - } - - HANDLE_CONDITIONAL_ASSEMBLY(); - - /* as_warn("Junk character %d.",c); Now done by ignore_rest */ - input_line_pointer--; /* Report unknown char as ignored. */ - ignore_rest_of_line(); - } /* while (input_line_pointer max_alignment) { - as_bad("Alignment too large: %d. assumed.", temp = max_alignment); - } - - /* - * For the sparc, `.align (1<>= 1, ++i) - ; - } - if (temp != 1) - as_bad("Alignment not a power of 2"); - - temp = i; - if (*input_line_pointer == ',') { - input_line_pointer ++; - temp_fill = get_absolute_expression (); - } else { - temp_fill = 0; - } - /* Only make a frag if we HAVE to. . . */ - if (temp && ! need_pass_2) - frag_align(temp, (int)temp_fill); - - demand_empty_rest_of_line(); -} /* s_align_bytes() */ - -/* For machines where ".align 4" means align to 2**4 boundary. */ -void s_align_ptwo() { - register int temp; - register long temp_fill; - long max_alignment = 15; - - temp = get_absolute_expression (); - if (temp > max_alignment) - as_bad("Alignment too large: %d. assumed.", temp = max_alignment); - else if (temp < 0) { - as_bad("Alignment negative. 0 assumed."); - temp = 0; - } - if (*input_line_pointer == ',') { - input_line_pointer ++; - temp_fill = get_absolute_expression (); - } else - temp_fill = 0; - /* Only make a frag if we HAVE to. . . */ - if (temp && ! need_pass_2) - frag_align (temp, (int)temp_fill); - - record_alignment(now_seg, temp); - - demand_empty_rest_of_line(); -} /* s_align_ptwo() */ - -void s_comm() { - register char *name; - register char c; - register char *p; - register int temp; - register symbolS * symbolP; - - name = input_line_pointer; - c = get_symbol_end(); - /* just after name is now '\0' */ - p = input_line_pointer; - *p = c; - SKIP_WHITESPACE(); - if (*input_line_pointer != ',') { - as_bad("Expected comma after symbol-name: rest of line ignored."); - ignore_rest_of_line(); - return; - } - input_line_pointer ++; /* skip ',' */ - if ((temp = get_absolute_expression()) < 0) { - as_warn(".COMMon length (%d.) <0! Ignored.", temp); - ignore_rest_of_line(); - return; - } - *p = 0; - symbolP = symbol_find_or_make(name); - *p = c; - if (S_IS_DEFINED(symbolP)) { - as_bad("Ignoring attempt to re-define symbol"); - ignore_rest_of_line(); - return; - } - if (S_GET_VALUE(symbolP)) { - if (S_GET_VALUE(symbolP) != temp) - as_bad("Length of .comm \"%s\" is already %d. Not changed to %d.", - S_GET_NAME(symbolP), - S_GET_VALUE(symbolP), - temp); - } else { - S_SET_VALUE(symbolP, temp); - S_SET_EXTERNAL(symbolP); - } -#ifdef VMS - if (!temp) - symbolP->sy_other = const_flag; -#endif - know(symbolP->sy_frag == &zero_address_frag); - demand_empty_rest_of_line(); -} /* s_comm() */ - -void -s_data() -{ - register int temp; - - temp = get_absolute_expression (); - subseg_new (SEG_DATA, (subsegT)temp); -#ifdef VMS - const_flag = 0; -#endif - demand_empty_rest_of_line(); -} - -void s_app_file() { - register char *s; - int length; - - /* Some assemblers tolerate immediately following '"' */ - if ((s = demand_copy_string(&length)) != 0) { - new_logical_line(s, -1); - demand_empty_rest_of_line(); - } -#ifdef OBJ_COFF - c_dot_file_symbol(s); -#endif /* OBJ_COFF */ -} /* s_app_file() */ - -void s_fill() { - long temp_repeat; - long temp_size; - register long temp_fill; - char *p; - - if (get_absolute_expression_and_terminator(& temp_repeat) != ',') { - input_line_pointer --; /* Backup over what was not a ','. */ - as_bad("Expect comma after rep-size in .fill:"); - ignore_rest_of_line(); - return; - } - if (get_absolute_expression_and_terminator(& temp_size) != ',') { - input_line_pointer --; /* Backup over what was not a ','. */ - as_bad("Expected comma after size in .fill"); - ignore_rest_of_line(); - return; - } - /* - * This is to be compatible with BSD 4.2 AS, not for any rational reason. - */ -#define BSD_FILL_SIZE_CROCK_8 (8) - if (temp_size > BSD_FILL_SIZE_CROCK_8) { - as_bad(".fill size clamped to %d.", BSD_FILL_SIZE_CROCK_8); - temp_size = BSD_FILL_SIZE_CROCK_8 ; - } if (temp_size < 0) { - as_warn("Size negative: .fill ignored."); - temp_size = 0; - } else if (temp_repeat <= 0) { - as_warn("Repeat < 0, .fill ignored"); - temp_size = 0; - } - temp_fill = get_absolute_expression (); - if (temp_size && !need_pass_2) { - p = frag_var(rs_fill, (int)temp_size, (int)temp_size, (relax_substateT)0, (symbolS *)0, temp_repeat, (char *)0); - bzero (p, (int)temp_size); -/* - * The magic number BSD_FILL_SIZE_CROCK_4 is from BSD 4.2 VAX flavoured AS. - * The following bizzare behaviour is to be compatible with above. - * I guess they tried to take up to 8 bytes from a 4-byte expression - * and they forgot to sign extend. Un*x Sux. - */ -#define BSD_FILL_SIZE_CROCK_4 (4) - md_number_to_chars (p, temp_fill, temp_size > BSD_FILL_SIZE_CROCK_4 ? BSD_FILL_SIZE_CROCK_4 : (int)temp_size); -/* - * Note: .fill (),0 emits no frag (since we are asked to .fill 0 bytes) - * but emits no error message because it seems a legal thing to do. - * It is a degenerate case of .fill but could be emitted by a compiler. - */ - } - demand_empty_rest_of_line(); -} - -#ifdef DONTDEF -void -s_gdbbeg() -{ - register int temp; - - temp = get_absolute_expression (); - if (temp < 0) - as_warn("Block number <0. Ignored."); - else if (flagseen ['G']) - gdb_block_beg ((long) temp, frag_now, (long)(obstack_next_free(& frags) - frag_now->fr_literal)); - demand_empty_rest_of_line (); -} - -void -s_gdbblock() -{ - register int position; - int temp; - - if (get_absolute_expression_and_terminator (&temp) != ',') { - as_bad("expected comma before position in .gdbblock"); - --input_line_pointer; - ignore_rest_of_line (); - return; - } - position = get_absolute_expression (); - if (flagseen ['G']) - gdb_block_position ((long) temp, (long) position); - demand_empty_rest_of_line (); -} - -void -s_gdbend() -{ - register int temp; - - temp = get_absolute_expression (); - if (temp < 0) - as_warn("Block number <0. Ignored."); - else if (flagseen ['G']) - gdb_block_end ((long) temp, frag_now, (long)(obstack_next_free(& frags) - frag_now->fr_literal)); - demand_empty_rest_of_line (); -} - -void -s_gdbsym() -{ - register char *name, - *p; - register char c; - register symbolS * symbolP; - register int temp; - - name = input_line_pointer; - c = get_symbol_end(); - p = input_line_pointer; - symbolP = symbol_find_or_make(name); - *p = c; - SKIP_WHITESPACE(); - if (* input_line_pointer != ',') { - as_bad("Expected comma after name"); - ignore_rest_of_line(); - return; - } - input_line_pointer ++; - if ((temp = get_absolute_expression ()) < 0) { - as_bad("Bad GDB symbol file offset (%d.) <0! Ignored.", temp); - ignore_rest_of_line(); - return; - } - if (flagseen ['G']) - gdb_symbols_fixup (symbolP, (long)temp); - demand_empty_rest_of_line (); -} - -void -s_gdbline() -{ - int file_number, - lineno; - - if (get_absolute_expression_and_terminator(&file_number) != ',') { - as_bad("expected comman after filenum in .gdbline"); - ignore_rest_of_line(); - return; - } - lineno=get_absolute_expression(); - if (flagseen['G']) - gdb_line(file_number,lineno); - demand_empty_rest_of_line(); -} - - -void -s_gdblinetab() -{ - int file_number, - offset; - - if (get_absolute_expression_and_terminator(&file_number) != ',') { - as_bad("expected comma after filenum in .gdblinetab"); - ignore_rest_of_line(); - return; - } - offset=get_absolute_expression(); - if (flagseen['G']) - gdb_line_tab(file_number,offset); - demand_empty_rest_of_line(); -} -#endif - -void s_globl() { - register char *name; - register int c; - register symbolS * symbolP; - - do { - name = input_line_pointer; - c = get_symbol_end(); - symbolP = symbol_find_or_make(name); - * input_line_pointer = c; - SKIP_WHITESPACE(); - S_SET_EXTERNAL(symbolP); - if (c==',') { - input_line_pointer++; - SKIP_WHITESPACE(); - if (*input_line_pointer=='\n') - c='\n'; - } - } while(c==','); - demand_empty_rest_of_line(); -} /* s_globl() */ - -void s_lcomm(needs_align) -int needs_align; /* 1 if this was a ".bss" directive, which may require - * a 3rd argument (alignment). - * 0 if it was an ".lcomm" (2 args only) - */ -{ - register char *name; - register char c; - register char *p; - register int temp; - register symbolS * symbolP; - const int max_alignment = 15; - int align; - - name = input_line_pointer; - c = get_symbol_end(); - p = input_line_pointer; - *p = c; - SKIP_WHITESPACE(); - if (* input_line_pointer != ',') { - as_bad("Expected comma after name"); - ignore_rest_of_line(); - return; - } - input_line_pointer ++; - - if (*input_line_pointer == '\n') { - as_bad("Missing size expression"); - return; - } - - if ((temp = get_absolute_expression ()) < 0) { - as_warn("BSS length (%d.) <0! Ignored.", temp); - ignore_rest_of_line(); - return; - } - - if (needs_align) { - align = 0; - SKIP_WHITESPACE(); - if (*input_line_pointer != ',') { - as_bad("Expected comma after size"); - ignore_rest_of_line(); - return; - } - input_line_pointer++; - SKIP_WHITESPACE(); - if (*input_line_pointer == '\n') { - as_bad("Missing alignment"); - return; - } - align = get_absolute_expression (); - if (align > max_alignment){ - align = max_alignment; - as_warn("Alignment too large: %d. assumed.", align); - } else if (align < 0) { - align = 0; - as_warn("Alignment negative. 0 assumed."); - } - - record_alignment(SEG_BSS, align); - } /* if needs align */ - - *p = 0; - symbolP = symbol_find_or_make(name); - *p = c; - if ( -#if defined(OBJ_AOUT) | defined(OBJ_BOUT) - S_GET_OTHER(symbolP) == 0 && - S_GET_DESC(symbolP) == 0 && -#endif /* OBJ_AOUT or OBJ_BOUT */ - (((S_GET_SEGMENT(symbolP) == SEG_BSS) && (S_GET_VALUE(symbolP) == local_bss_counter)) - || (!S_IS_DEFINED(symbolP) && S_GET_VALUE(symbolP) == 0))) { - if (needs_align){ - /* Align */ - align = ~ ((~0) << align); /* Convert to a mask */ - local_bss_counter = - (local_bss_counter + align) & (~align); - } - - S_SET_VALUE(symbolP,local_bss_counter); - S_SET_SEGMENT(symbolP, SEG_BSS); -#ifdef OBJ_COFF - /* The symbol may already have been created with a preceding - * ".globl" directive -- be careful not to step on storage - * class in that case. Otherwise, set it to static. - */ - if (S_GET_STORAGE_CLASS(symbolP) != C_EXT){ - S_SET_STORAGE_CLASS(symbolP, C_STAT); - } -#endif /* OBJ_COFF */ - symbolP->sy_frag = & bss_address_frag; - local_bss_counter += temp; - } else { - as_bad("Ignoring attempt to re-define symbol from %d. to %d.", - S_GET_VALUE(symbolP), local_bss_counter); - } - demand_empty_rest_of_line(); - - return; -} /* s_lcomm() */ - -void -s_long() -{ - cons(4); -} - -void -s_int() -{ - cons(4); -} - -void s_lsym() { - register char *name; - register char c; - register char *p; - register segT segment; - expressionS exp; - register symbolS *symbolP; - - /* we permit ANY defined expression: BSD4.2 demands constants */ - name = input_line_pointer; - c = get_symbol_end(); - p = input_line_pointer; - *p = c; - SKIP_WHITESPACE(); - if (* input_line_pointer != ',') { - *p = 0; - as_bad("Expected comma after name \"%s\"", name); - *p = c; - ignore_rest_of_line(); - return; - } - input_line_pointer ++; - segment = expression(& exp); - if (segment != SEG_ABSOLUTE - && segment != SEG_DATA - && segment != SEG_TEXT - && segment != SEG_BSS - && segment != SEG_REGISTER) { - as_bad("Bad expression: %s", segment_name(segment)); - ignore_rest_of_line(); - return; - } - *p = 0; - symbolP = symbol_find_or_make(name); - - /* FIXME-SOON I pulled a (&& symbolP->sy_other == 0 - && symbolP->sy_desc == 0) out of this test - because coff doesn't have those fields, and I - can't see when they'd ever be tripped. I don't - think I understand why they were here so I may - have introduced a bug. As recently as 1.37 didn't - have this test anyway. xoxorich. */ - - if (S_GET_SEGMENT(symbolP) == SEG_UNKNOWN - && S_GET_VALUE(symbolP) == 0) { - /* The name might be an undefined .global symbol; be - sure to keep the "external" bit. */ - S_SET_SEGMENT(symbolP, segment); - S_SET_VALUE(symbolP, (valueT)(exp.X_add_number)); - } else { - as_bad("Symbol %s already defined", name); - } - *p = c; - demand_empty_rest_of_line(); -} /* s_lsym() */ - -void s_org() { - register segT segment; - expressionS exp; - register long temp_fill; - register char *p; -/* - * Don't believe the documentation of BSD 4.2 AS. - * There is no such thing as a sub-segment-relative origin. - * Any absolute origin is given a warning, then assumed to be segment-relative. - * Any segmented origin expression ("foo+42") had better be in the right - * segment or the .org is ignored. - * - * BSD 4.2 AS warns if you try to .org backwards. We cannot because we - * never know sub-segment sizes when we are reading code. - * BSD will crash trying to emit -ve numbers of filler bytes in certain - * .orgs. We don't crash, but see as-write for that code. - */ -/* - * Don't make frag if need_pass_2==1. - */ - segment = get_known_segmented_expression(&exp); - if (*input_line_pointer == ',') { - input_line_pointer ++; - temp_fill = get_absolute_expression (); - } else - temp_fill = 0; - if (! need_pass_2) { - if (segment != now_seg && segment != SEG_ABSOLUTE) - as_bad("Invalid segment \"%s\". Segment \"%s\" assumed.", - segment_name(segment), segment_name(now_seg)); - p = frag_var (rs_org, 1, 1, (relax_substateT)0, exp . X_add_symbol, - exp . X_add_number, (char *)0); - * p = temp_fill; - } /* if (ok to make frag) */ - demand_empty_rest_of_line(); -} /* s_org() */ - -void s_set() { - register char *name; - register char delim; - register char *end_name; - register symbolS *symbolP; - - /* - * Especial apologies for the random logic: - * this just grew, and could be parsed much more simply! - * Dean in haste. - */ - name = input_line_pointer; - delim = get_symbol_end(); - end_name = input_line_pointer; - *end_name = delim; - SKIP_WHITESPACE(); - - if (*input_line_pointer != ',') { - *end_name = 0; - as_bad("Expected comma after name \"%s\"", name); - *end_name = delim; - ignore_rest_of_line(); - return; - } - - input_line_pointer ++; - *end_name = 0; - - if (name[0]=='.' && name[1]=='\0') { - /* Turn '. = mumble' into a .org mumble */ - register segT segment; - expressionS exp; - register char *ptr; - - segment = get_known_segmented_expression(& exp); - - if (!need_pass_2) { - if (segment != now_seg && segment != SEG_ABSOLUTE) - as_bad("Invalid segment \"%s\". Segment \"%s\" assumed.", - segment_name(segment), - segment_name (now_seg)); - ptr = frag_var(rs_org, 1, 1, (relax_substateT)0, exp.X_add_symbol, - exp.X_add_number, (char *)0); - *ptr= 0; - } /* if (ok to make frag) */ - - *end_name = delim; - return; - } - - if ((symbolP = symbol_find(name)) == NULL - && (symbolP = md_undefined_symbol(name)) == NULL) { - symbolP = symbol_new(name, - SEG_UNKNOWN, - 0, - &zero_address_frag); -#ifdef OBJ_COFF - /* "set" symbols are local unless otherwise specified. */ - SF_SET_LOCAL(symbolP); -#endif /* OBJ_COFF */ - - } /* make a new symbol */ - - symbol_table_insert(symbolP); - - *end_name = delim; - pseudo_set(symbolP); - demand_empty_rest_of_line(); -} /* s_set() */ - -void s_space() { - long temp_repeat; - register long temp_fill; - register char *p; - - /* Just like .fill, but temp_size = 1 */ - if (get_absolute_expression_and_terminator(& temp_repeat) == ',') { - temp_fill = get_absolute_expression (); - } else { - input_line_pointer --; /* Backup over what was not a ','. */ - temp_fill = 0; - } - if (temp_repeat <= 0) { - as_warn("Repeat < 0, .space ignored"); - ignore_rest_of_line(); - return; - } - if (! need_pass_2) { - p = frag_var (rs_fill, 1, 1, (relax_substateT)0, (symbolS *)0, - temp_repeat, (char *)0); - * p = temp_fill; - } - demand_empty_rest_of_line(); -} /* s_space() */ - -void -s_text() -{ - register int temp; - - temp = get_absolute_expression (); - subseg_new (SEG_TEXT, (subsegT)temp); - demand_empty_rest_of_line(); -} /* s_text() */ - - -/*(JF was static, but can't be if machine dependent pseudo-ops are to use it */ - -void demand_empty_rest_of_line() { - SKIP_WHITESPACE(); - if (is_end_of_line [*input_line_pointer]) { - input_line_pointer++; - } else { - ignore_rest_of_line(); - } - /* Return having already swallowed end-of-line. */ -} /* Return pointing just after end-of-line. */ - -void -ignore_rest_of_line() /* For suspect lines: gives warning. */ -{ - if (! is_end_of_line [* input_line_pointer]) - { - if (isprint(*input_line_pointer)) - as_bad("Rest of line ignored. First ignored character is `%c'.", - *input_line_pointer); - else - as_bad("Rest of line ignored. First ignored character valued 0x%x.", - *input_line_pointer); - while (input_line_pointer < buffer_limit - && ! is_end_of_line [* input_line_pointer]) - { - input_line_pointer ++; - } - } - input_line_pointer ++; /* Return pointing just after end-of-line. */ - know(is_end_of_line [input_line_pointer [-1]]); -} - -/* - * pseudo_set() - * - * In: Pointer to a symbol. - * Input_line_pointer->expression. - * - * Out: Input_line_pointer->just after any whitespace after expression. - * Tried to set symbol to value of expression. - * Will change symbols type, value, and frag; - * May set need_pass_2 == 1. - */ -void -pseudo_set (symbolP) - symbolS * symbolP; -{ - expressionS exp; - register segT segment; -#if defined(OBJ_AOUT) | defined(OBJ_BOUT) - int ext; -#endif /* OBJ_AOUT or OBJ_BOUT */ - - know(symbolP); /* NULL pointer is logic error. */ -#if defined(OBJ_AOUT) | defined(OBJ_BOUT) - ext=S_IS_EXTERNAL(symbolP); -#endif /* OBJ_AOUT or OBJ_BOUT */ - - if ((segment = expression(& exp)) == SEG_ABSENT) - { - as_bad("Missing expression: absolute 0 assumed"); - exp . X_seg = SEG_ABSOLUTE; - exp . X_add_number = 0; - } - - switch (segment) - { - case SEG_BIG: - as_bad("%s number invalid. Absolute 0 assumed.", - exp . X_add_number > 0 ? "Bignum" : "Floating-Point"); - S_SET_SEGMENT(symbolP, SEG_ABSOLUTE); -#if defined(OBJ_AOUT) | defined(OBJ_BOUT) - ext ? S_SET_EXTERNAL(symbolP) : - S_CLEAR_EXTERNAL(symbolP); -#endif /* OBJ_AOUT or OBJ_BOUT */ - S_SET_VALUE(symbolP, 0); - symbolP->sy_frag = & zero_address_frag; - break; - - case SEG_ABSENT: - as_warn("No expression: Using absolute 0"); - S_SET_SEGMENT(symbolP, SEG_ABSOLUTE); -#if defined(OBJ_AOUT) | defined(OBJ_BOUT) - ext ? S_SET_EXTERNAL(symbolP) : - S_CLEAR_EXTERNAL(symbolP); -#endif /* OBJ_AOUT or OBJ_BOUT */ - S_SET_VALUE(symbolP, 0); - symbolP->sy_frag = & zero_address_frag; - break; - - case SEG_DIFFERENCE: - if (exp.X_add_symbol && exp.X_subtract_symbol - && (S_GET_SEGMENT(exp.X_add_symbol) == - S_GET_SEGMENT(exp.X_subtract_symbol))) { - if (exp.X_add_symbol->sy_frag != exp.X_subtract_symbol->sy_frag) { - as_bad("Unknown expression: symbols %s and %s are in different frags.", - S_GET_NAME(exp.X_add_symbol), S_GET_NAME(exp.X_subtract_symbol)); - need_pass_2++; - } - exp.X_add_number+=S_GET_VALUE(exp.X_add_symbol) - - S_GET_VALUE(exp.X_subtract_symbol); - } else - as_bad("Complex expression. Absolute segment assumed."); - case SEG_ABSOLUTE: - S_SET_SEGMENT(symbolP, SEG_ABSOLUTE); -#if defined(OBJ_AOUT) | defined(OBJ_BOUT) - ext ? S_SET_EXTERNAL(symbolP) : - S_CLEAR_EXTERNAL(symbolP); -#endif /* OBJ_AOUT or OBJ_BOUT */ - S_SET_VALUE(symbolP, exp.X_add_number); - symbolP->sy_frag = & zero_address_frag; - break; - - case SEG_DATA: - case SEG_TEXT: - case SEG_BSS: - switch(segment) { - case SEG_DATA: S_SET_SEGMENT(symbolP, SEG_DATA); break; - case SEG_TEXT: S_SET_SEGMENT(symbolP, SEG_TEXT); break; - case SEG_BSS: S_SET_SEGMENT(symbolP, SEG_BSS); break; - default: abort(); - } /* switch on segment */ - -#if defined(OBJ_AOUT) | defined(OBJ_BOUT) - if (ext) { - S_SET_EXTERNAL(symbolP); - } else { - S_CLEAR_EXTERNAL(symbolP); - } /* if external */ -#endif /* OBJ_AOUT or OBJ_BOUT */ - - S_SET_VALUE(symbolP, exp.X_add_number + S_GET_VALUE(exp.X_add_symbol)); - symbolP->sy_frag = exp . X_add_symbol->sy_frag; - break; - - case SEG_PASS1: /* Not an error. Just try another pass. */ - symbolP->sy_forward=exp.X_add_symbol; - as_bad("Unknown expression"); - know(need_pass_2 == 1); - break; - - case SEG_UNKNOWN: - symbolP->sy_forward=exp.X_add_symbol; - /* as_warn("unknown symbol"); */ - /* need_pass_2 = 1; */ - break; - - default: - BAD_CASE(segment); - break; - } -} - -/* - * cons() - * - * CONStruct more frag of .bytes, or .words etc. - * Should need_pass_2 be 1 then emit no frag(s). - * This understands EXPRESSIONS, as opposed to big_cons(). - * - * Bug (?) - * - * This has a split personality. We use expression() to read the - * value. We can detect if the value won't fit in a byte or word. - * But we can't detect if expression() discarded significant digits - * in the case of a long. Not worth the crocks required to fix it. - */ - - /* worker to do .byte etc statements */ - /* clobbers input_line_pointer, checks */ - /* end-of-line. */ -void cons(nbytes) -register unsigned int nbytes; /* 1=.byte, 2=.word, 4=.long */ -{ - register char c; - register long mask; /* High-order bits we will left-truncate, */ - /* but includes sign bit also. */ - register long get; /* what we get */ - register long use; /* get after truncation. */ - register long unmask; /* what bits we will store */ - register char * p; - register segT segment; - expressionS exp; - - /* - * Input_line_pointer->1st char after pseudo-op-code and could legally - * be a end-of-line. (Or, less legally an eof - which we cope with.) - */ - /* JF << of >= number of bits in the object is undefined. In particular - SPARC (Sun 4) has problems */ - - if (nbytes>=sizeof(long)) { - mask = 0; - } else { - mask = ~0 << (BITS_PER_CHAR * nbytes); /* Don't store these bits. */ - } /* bigger than a long */ - - unmask = ~mask; /* Do store these bits. */ - -#ifdef NEVER - "Do this mod if you want every overflow check to assume SIGNED 2's complement data."; - mask = ~ (unmask >> 1); /* Includes sign bit now. */ -#endif - - /* - * The following awkward logic is to parse ZERO or more expressions, - * comma seperated. Recall an expression includes its leading & - * trailing blanks. We fake a leading ',' if there is (supposed to - * be) a 1st expression, and keep demanding 1 expression for each ','. - */ - if (is_it_end_of_statement()) { - c = 0; /* Skip loop. */ - input_line_pointer++; /* Matches end-of-loop 'correction'. */ - } else { - c = ','; - } /* if the end else fake it */ - -/* Do loop. */ - while (c == ',') { - unsigned int bits_available = BITS_PER_CHAR * nbytes; - /* used for error messages and rescanning */ - char *hold = input_line_pointer; - - /* At least scan over the expression. */ - segment = expression(&exp); - -#ifdef WANT_BITFIELDS - /* Some other assemblers, (eg, asm960), allow - bitfields after ".byte" as w:x,y:z, where w and - y are bitwidths and x and y are values. They - then pack them all together. We do a little - better in that we allow them in words, longs, - etc. and we'll pack them in target byte order - for you. - - The rules are: pack least significat bit first, - if a field doesn't entirely fit, put it in the - next unit. Overflowing the bitfield is - explicitly *not* even a warning. The bitwidth - should be considered a "mask". - - FIXME-SOMEDAY: If this is considered generally - useful, this logic should probably be reworked. - xoxorich. */ - - if (*input_line_pointer == ':') { /* bitfields */ - long value = 0; - - for (;;) { - unsigned long width; - - if (*input_line_pointer != ':') { - input_line_pointer = hold; - break; - } /* next piece is not a bitfield */ - - /* In the general case, we can't allow - full expressions with symbol - differences and such. The relocation - entries for symbols not defined in this - assembly would require arbitrary field - widths, positions, and masks which most - of our current object formats don't - support. - - In the specific case where a symbol - *is* defined in this assembly, we - *could* build fixups and track it, but - this could lead to confusion for the - backends. I'm lazy. I'll take any - SEG_ABSOLUTE. I think that means that - you can use a previous .set or - .equ type symbol. xoxorich. */ - - if (segment == SEG_ABSENT) { - as_warn("Using a bit field width of zero."); - exp.X_add_number = 0; - segment = SEG_ABSOLUTE; - } /* implied zero width bitfield */ - - if (segment != SEG_ABSOLUTE) { - *input_line_pointer = '\0'; - as_bad("Field width \"%s\" too complex for a bitfield.\n", hold); - *input_line_pointer = ':'; - demand_empty_rest_of_line(); - return; - } /* too complex */ - - if ((width = exp.X_add_number) > (BITS_PER_CHAR * nbytes)) { - as_warn("Field width %d too big to fit in %d bytes: truncated to %d bits.", - width, nbytes, (BITS_PER_CHAR * nbytes)); - width = BITS_PER_CHAR * nbytes; - } /* too big */ - - if (width > bits_available) { - /* FIXME-SOMEDAY: backing up and - reparsing is wasteful */ - input_line_pointer = hold; - exp.X_add_number = value; - break; - } /* won't fit */ - - hold = ++input_line_pointer; /* skip ':' */ - - if ((segment = expression(&exp)) != SEG_ABSOLUTE) { - char cache = *input_line_pointer; - - *input_line_pointer = '\0'; - as_bad("Field value \"%s\" too complex for a bitfield.\n", hold); - *input_line_pointer = cache; - demand_empty_rest_of_line(); - return; - } /* too complex */ - - value |= (~(-1 << width) & exp.X_add_number) - << ((BITS_PER_CHAR * nbytes) - bits_available); - - if ((bits_available -= width) == 0 - || is_it_end_of_statement() - || *input_line_pointer != ',') { - break; - } /* all the bitfields we're gonna get */ - - hold = ++input_line_pointer; - segment = expression(&exp); - } /* forever loop */ - - exp.X_add_number = value; - segment = SEG_ABSOLUTE; - } /* if looks like a bitfield */ -#endif /* WANT_BITFIELDS */ - - if (!need_pass_2) { /* Still worthwhile making frags. */ - - /* Don't call this if we are going to junk this pass anyway! */ - know(segment != SEG_PASS1); - - if (segment == SEG_DIFFERENCE && exp.X_add_symbol == NULL) { - as_bad("Subtracting symbol \"%s\"(segment\"%s\") is too hard. Absolute segment assumed.", - S_GET_NAME(exp.X_subtract_symbol), - segment_name(S_GET_SEGMENT(exp.X_subtract_symbol))); - segment = SEG_ABSOLUTE; - /* Leave exp . X_add_number alone. */ - } - p = frag_more(nbytes); - switch (segment) { - case SEG_BIG: - as_bad("%s number invalid. Absolute 0 assumed.", - exp . X_add_number > 0 ? "Bignum" : "Floating-Point"); - md_number_to_chars (p, (long)0, nbytes); - break; - - case SEG_ABSENT: - as_warn("0 assumed for missing expression"); - exp . X_add_number = 0; - know(exp . X_add_symbol == NULL); - /* fall into SEG_ABSOLUTE */ - case SEG_ABSOLUTE: - get = exp . X_add_number; - use = get & unmask; - if ((get & mask) && (get & mask) != mask) - { /* Leading bits contain both 0s & 1s. */ - as_warn("Value x%x truncated to x%x.", get, use); - } - md_number_to_chars (p, use, nbytes); /* put bytes in right order. */ - break; - - case SEG_DIFFERENCE: -#ifndef WORKING_DOT_WORD - if (nbytes==2) { - struct broken_word *x; - - x=(struct broken_word *)xmalloc(sizeof(struct broken_word)); - x->next_broken_word=broken_words; - broken_words=x; - x->frag=frag_now; - x->word_goes_here=p; - x->dispfrag=0; - x->add=exp.X_add_symbol; - x->sub=exp.X_subtract_symbol; - x->addnum=exp.X_add_number; - x->added=0; - new_broken_words++; - break; - } - /* Else Fall through into. . . */ -#endif - case SEG_BSS: - case SEG_UNKNOWN: - case SEG_TEXT: - case SEG_DATA: -#ifdef TC_NS32K - fix_new_ns32k (frag_now, p - frag_now->fr_literal, nbytes, - exp . X_add_symbol, exp . X_subtract_symbol, - exp . X_add_number, 0, 0, 2, 0, 0); -#else - fix_new (frag_now, p - frag_now->fr_literal, nbytes, - exp . X_add_symbol, exp . X_subtract_symbol, - exp . X_add_number, 0, RELOC_32); -#endif /* TC_NS32K */ - break; - - default: - BAD_CASE(segment); - break; - } /* switch(segment) */ - } /* if (!need_pass_2) */ - c = *input_line_pointer++; - } /* while(c==',') */ - input_line_pointer--; /* Put terminator back into stream. */ - demand_empty_rest_of_line(); -} /* cons() */ - -/* - * big_cons() - * - * CONStruct more frag(s) of .quads, or .octa etc. - * Makes 0 or more new frags. - * If need_pass_2 == 1, generate no frag. - * This understands only bignums, not expressions. Cons() understands - * expressions. - * - * Constants recognised are '0...'(octal) '0x...'(hex) '...'(decimal). - * - * This creates objects with struct obstack_control objs, destroying - * any context objs held about a partially completed object. Beware! - * - * - * I think it sucks to have 2 different types of integers, with 2 - * routines to read them, store them etc. - * It would be nicer to permit bignums in expressions and only - * complain if the result overflowed. However, due to "efficiency"... - */ -/* worker to do .quad etc statements */ -/* clobbers input_line_pointer, checks */ -/* end-of-line. */ -/* 8=.quad 16=.octa ... */ - -void big_cons(nbytes) - register int nbytes; -{ - register char c; /* input_line_pointer->c. */ - register int radix; - register long length; /* Number of chars in an object. */ - register int digit; /* Value of 1 digit. */ - register int carry; /* For multi-precision arithmetic. */ - register int work; /* For multi-precision arithmetic. */ - register char * p; /* For multi-precision arithmetic. */ - - extern char hex_value[]; /* In hex_value.c. */ - - /* - * The following awkward logic is to parse ZERO or more strings, - * comma seperated. Recall an expression includes its leading & - * trailing blanks. We fake a leading ',' if there is (supposed to - * be) a 1st expression, and keep demanding 1 expression for each ','. - */ - if (is_it_end_of_statement()) - { - c = 0; /* Skip loop. */ - } - else - { - c = ','; /* Do loop. */ - -- input_line_pointer; - } - while (c == ',') - { - ++ input_line_pointer; - SKIP_WHITESPACE(); - c = * input_line_pointer; - /* C contains 1st non-blank character of what we hope is a number. */ - if (c == '0') - { - c = * ++ input_line_pointer; - if (c == 'x' || c=='X') - { - c = * ++ input_line_pointer; - radix = 16; - } - else - { - radix = 8; - } - } - else - { - radix = 10; - } - /* - * This feature (?) is here to stop people worrying about - * mysterious zero constants: which is what they get when - * they completely omit digits. - */ - if (hex_value[c] >= radix) { - as_bad("Missing digits. 0 assumed."); - } - bignum_high = bignum_low - 1; /* Start constant with 0 chars. */ - for(; (digit = hex_value [c]) < radix; c = * ++ input_line_pointer) - { - /* Multiply existing number by radix, then add digit. */ - carry = digit; - for (p=bignum_low; p <= bignum_high; p++) - { - work = (*p & MASK_CHAR) * radix + carry; - *p = work & MASK_CHAR; - carry = work >> BITS_PER_CHAR; - } - if (carry) - { - grow_bignum(); - * bignum_high = carry & MASK_CHAR; - know((carry & ~ MASK_CHAR) == 0); - } - } - length = bignum_high - bignum_low + 1; - if (length > nbytes) - { - as_warn("Most significant bits truncated in integer constant."); - } - else - { - register long leading_zeroes; - - for(leading_zeroes = nbytes - length; - leading_zeroes; - leading_zeroes --) - { - grow_bignum(); - * bignum_high = 0; - } - } - if (! need_pass_2) - { - p = frag_more (nbytes); - bcopy (bignum_low, p, (int)nbytes); - } - /* C contains character after number. */ - SKIP_WHITESPACE(); - c = * input_line_pointer; - /* C contains 1st non-blank character after number. */ - } - demand_empty_rest_of_line(); -} /* big_cons() */ - - /* Extend bignum by 1 char. */ -static void grow_bignum() { - register long length; - - bignum_high ++; - if (bignum_high >= bignum_limit) - { - length = bignum_limit - bignum_low; - bignum_low = xrealloc(bignum_low, length + length); - bignum_high = bignum_low + length; - bignum_limit = bignum_low + length + length; - } -} /* grow_bignum(); */ - -/* - * float_cons() - * - * CONStruct some more frag chars of .floats .ffloats etc. - * Makes 0 or more new frags. - * If need_pass_2 == 1, no frags are emitted. - * This understands only floating literals, not expressions. Sorry. - * - * A floating constant is defined by atof_generic(), except it is preceded - * by 0d 0f 0g or 0h. After observing the STRANGE way my BSD AS does its - * reading, I decided to be incompatible. This always tries to give you - * rounded bits to the precision of the pseudo-op. Former AS did premature - * truncatation, restored noisy bits instead of trailing 0s AND gave you - * a choice of 2 flavours of noise according to which of 2 floating-point - * scanners you directed AS to use. - * - * In: input_line_pointer->whitespace before, or '0' of flonum. - * - */ - -void /* JF was static, but can't be if VAX.C is goning to use it */ -float_cons(float_type) /* Worker to do .float etc statements. */ - /* Clobbers input_line-pointer, checks end-of-line. */ - register int float_type; /* 'f':.ffloat ... 'F':.float ... */ -{ - register char * p; - register char c; - int length; /* Number of chars in an object. */ - register char * err; /* Error from scanning floating literal. */ - char temp [MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT]; - - /* - * The following awkward logic is to parse ZERO or more strings, - * comma seperated. Recall an expression includes its leading & - * trailing blanks. We fake a leading ',' if there is (supposed to - * be) a 1st expression, and keep demanding 1 expression for each ','. - */ - if (is_it_end_of_statement()) - { - c = 0; /* Skip loop. */ - ++ input_line_pointer; /*->past termintor. */ - } - else - { - c = ','; /* Do loop. */ - } - while (c == ',') - { - /* input_line_pointer->1st char of a flonum (we hope!). */ - SKIP_WHITESPACE(); - /* Skip any 0{letter} that may be present. Don't even check if the - * letter is legal. Someone may invent a "z" format and this routine - * has no use for such information. Lusers beware: you get - * diagnostics if your input is ill-conditioned. - */ - - if (input_line_pointer[0]=='0' && isalpha(input_line_pointer[1])) - input_line_pointer+=2; - - err = md_atof (float_type, temp, &length); - know(length <= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT); - know(length > 0); - if (* err) - { - as_bad("Bad floating literal: %s", err); - ignore_rest_of_line(); - /* Input_line_pointer->just after end-of-line. */ - c = 0; /* Break out of loop. */ - } - else - { - if (! need_pass_2) - { - p = frag_more (length); - bcopy (temp, p, length); - } - SKIP_WHITESPACE(); - c = * input_line_pointer ++; - /* C contains 1st non-white character after number. */ - /* input_line_pointer->just after terminator (c). */ - } - } - -- input_line_pointer; /*->terminator (is not ','). */ - demand_empty_rest_of_line(); -} /* float_cons() */ - -/* - * stringer() - * - * We read 0 or more ',' seperated, double-quoted strings. - * - * Caller should have checked need_pass_2 is FALSE because we don't check it. - */ -static void stringer(append_zero) /* Worker to do .ascii etc statements. */ - /* Checks end-of-line. */ - register int append_zero; /* 0: don't append '\0', else 1 */ -{ - /* register char * p; JF unused */ - /* register int length; JF unused */ /* Length of string we read, excluding */ - /* trailing '\0' implied by closing quote. */ - /* register char * where; JF unused */ - /* register fragS * fragP; JF unused */ - register unsigned int c; - - /* - * The following awkward logic is to parse ZERO or more strings, - * comma seperated. Recall a string expression includes spaces - * before the opening '\"' and spaces after the closing '\"'. - * We fake a leading ',' if there is (supposed to be) - * a 1st, expression. We keep demanding expressions for each - * ','. - */ - if (is_it_end_of_statement()) - { - c = 0; /* Skip loop. */ - ++ input_line_pointer; /* Compensate for end of loop. */ - } - else - { - c = ','; /* Do loop. */ - } - for (; c == ','; c = *input_line_pointer++) { - SKIP_WHITESPACE(); - if (*input_line_pointer == '\"') { - ++input_line_pointer; /*->1st char of string. */ - while (is_a_char(c = next_char_of_string())) { - FRAG_APPEND_1_CHAR(c); - } - if (append_zero) { - FRAG_APPEND_1_CHAR(0); - } - know(input_line_pointer [-1] == '\"'); - } else { - as_warn("Expected \"-ed string"); - } - SKIP_WHITESPACE(); - } - --input_line_pointer; - demand_empty_rest_of_line(); -} /* stringer() */ - - /* FIXME-SOMEDAY: I had trouble here on characters with the - high bits set. We'll probably also have trouble with - multibyte chars, wide chars, etc. Also be careful about - returning values bigger than 1 byte. xoxorich. */ - -static unsigned int next_char_of_string() { - register unsigned int c; - - c = *input_line_pointer++ & CHAR_MASK; - switch (c) { - case '\"': - c = NOT_A_CHAR; - break; - - case '\\': - switch (c = *input_line_pointer++) { - case 'b': - c = '\b'; - break; - - case 'f': - c = '\f'; - break; - - case 'n': - c = '\n'; - break; - - case 'r': - c = '\r'; - break; - - case 't': - c = '\t'; - break; - -#ifdef BACKSLASH_V - case 'v': - c = '\013'; - break; -#endif - - case '\\': - case '"': - break; /* As itself. */ - - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': { - long number; - - for (number = 0; isdigit(c); c = *input_line_pointer++) { - number = number * 8 + c - '0'; - } - c = number & 0xff; - } - --input_line_pointer; - break; - - case '\n': - /* To be compatible with BSD 4.2 as: give the luser a linefeed!! */ - as_warn("Unterminated string: Newline inserted."); - c = '\n'; - break; - - default: - -#ifdef ONLY_STANDARD_ESCAPES - as_bad("Bad escaped character in string, '?' assumed"); - c = '?'; -#endif /* ONLY_STANDARD_ESCAPES */ - - break; - } /* switch on escaped char */ - break; - - default: - break; - } /* switch on char */ - return(c); -} /* next_char_of_string() */ - -static segT -get_segmented_expression (expP) - register expressionS * expP; -{ - register segT retval; - - if ((retval = expression(expP)) == SEG_PASS1 || retval == SEG_ABSENT || retval == SEG_BIG) - { - as_bad("Expected address expression: absolute 0 assumed"); - retval = expP->X_seg = SEG_ABSOLUTE; - expP->X_add_number = 0; - expP->X_add_symbol = expP->X_subtract_symbol = 0; - } - return (retval); /* SEG_ ABSOLUTE,UNKNOWN,DATA,TEXT,BSS */ -} - -static segT get_known_segmented_expression(expP) -register expressionS *expP; -{ - register segT retval; - register char * name1; - register char * name2; - - if ((retval = get_segmented_expression (expP)) == SEG_UNKNOWN) - { - name1 = expP->X_add_symbol ? S_GET_NAME(expP->X_add_symbol) : ""; - name2 = expP->X_subtract_symbol ? - S_GET_NAME(expP->X_subtract_symbol) : - ""; - if (name1 && name2) - { - as_warn("Symbols \"%s\" \"%s\" are undefined: absolute 0 assumed.", - name1, name2); - } - else - { - as_warn("Symbol \"%s\" undefined: absolute 0 assumed.", - name1 ? name1 : name2); - } - retval = expP->X_seg = SEG_ABSOLUTE; - expP->X_add_number = 0; - expP->X_add_symbol = expP->X_subtract_symbol = NULL; - } - know(retval == SEG_ABSOLUTE || retval == SEG_DATA || retval == SEG_TEXT || retval == SEG_BSS || retval == SEG_DIFFERENCE); - return (retval); -} /* get_known_segmented_expression() */ - - - -/* static */ long /* JF was static, but can't be if the MD pseudos are to use it */ -get_absolute_expression () -{ - expressionS exp; - register segT s; - - if ((s = expression(& exp)) != SEG_ABSOLUTE) - { - if (s != SEG_ABSENT) - { - as_bad("Bad Absolute Expression, absolute 0 assumed."); - } - exp . X_add_number = 0; - } - return (exp . X_add_number); -} - -char /* return terminator */ -get_absolute_expression_and_terminator(val_pointer) - long * val_pointer; /* return value of expression */ -{ - * val_pointer = get_absolute_expression (); - return (* input_line_pointer ++); -} - -/* - * demand_copy_C_string() - * - * Like demand_copy_string, but return NULL if the string contains any '\0's. - * Give a warning if that happens. - */ -char * -demand_copy_C_string (len_pointer) - int * len_pointer; -{ - register char * s; - - if ((s = demand_copy_string(len_pointer)) != 0) - { - register int len; - - for (len = * len_pointer; - len > 0; - len--) - { - if (* s == 0) - { - s = 0; - len = 1; - * len_pointer = 0; - as_bad("This string may not contain \'\\0\'"); - } - } - } - return (s); -} - -/* - * demand_copy_string() - * - * Demand string, but return a safe (=private) copy of the string. - * Return NULL if we can't read a string here. - */ -static char *demand_copy_string(lenP) -int *lenP; -{ - register unsigned int c; - register int len; - char *retval; - - len = 0; - SKIP_WHITESPACE(); - if (*input_line_pointer == '\"') { - input_line_pointer++; /* Skip opening quote. */ - - while (is_a_char(c = next_char_of_string())) { - obstack_1grow(¬es, c); - len ++; - } - /* JF this next line is so demand_copy_C_string will return a null - termanated string. */ - obstack_1grow(¬es,'\0'); - retval=obstack_finish(¬es); - } else { - as_warn("Missing string"); - retval = NULL; - ignore_rest_of_line(); - } - *lenP = len; - return(retval); -} /* demand_copy_string() */ - -/* - * is_it_end_of_statement() - * - * In: Input_line_pointer->next character. - * - * Do: Skip input_line_pointer over all whitespace. - * - * Out: 1 if input_line_pointer->end-of-line. - */ -static int is_it_end_of_statement() { - SKIP_WHITESPACE(); - return (is_end_of_line [* input_line_pointer]); -} /* is_it_end_of_statement() */ - -void equals(sym_name) -char *sym_name; -{ - register symbolS *symbolP; /* symbol we are working with */ - - input_line_pointer++; - if (*input_line_pointer=='=') - input_line_pointer++; - - while(*input_line_pointer==' ' || *input_line_pointer=='\t') - input_line_pointer++; - - if (sym_name[0]=='.' && sym_name[1]=='\0') { - /* Turn '. = mumble' into a .org mumble */ - register segT segment; - expressionS exp; - register char *p; - - segment = get_known_segmented_expression(& exp); - if (! need_pass_2) { - if (segment != now_seg && segment != SEG_ABSOLUTE) - as_warn("Illegal segment \"%s\". Segment \"%s\" assumed.", - segment_name(segment), - segment_name(now_seg)); - p = frag_var(rs_org, 1, 1, (relax_substateT)0, exp.X_add_symbol, - exp.X_add_number, (char *)0); - * p = 0; - } /* if (ok to make frag) */ - } else { - symbolP=symbol_find_or_make(sym_name); - pseudo_set(symbolP); - } -} /* equals() */ - -/* .include -- include a file at this point. */ - -/* ARGSUSED */ -void s_include(arg) -int arg; -{ - char *newbuf; - char *filename; - int i; - FILE *try; - char *path; - - filename = demand_copy_string(&i); - demand_empty_rest_of_line(); - path = malloc(i + include_dir_maxlen + 5 /* slop */); - for (i = 0; i < include_dir_count; i++) { - strcpy(path, include_dirs[i]); - strcat(path, "/"); - strcat(path, filename); - if (0 != (try = fopen(path, "r"))) - { - fclose (try); - goto gotit; - } - } - free(path); - path = filename; -gotit: - /* malloc Storage leak when file is found on path. FIXME-SOMEDAY. */ - newbuf = input_scrub_include_file (path, input_line_pointer); - buffer_limit = input_scrub_next_buffer (&input_line_pointer); -} /* s_include() */ - -void add_include_dir(path) -char *path; -{ - int i; - - if (include_dir_count == 0) - { - include_dirs = (char **)malloc (2 * sizeof (*include_dirs)); - include_dirs[0] = "."; /* Current dir */ - include_dir_count = 2; - } - else - { - include_dir_count++; - include_dirs = (char **) realloc(include_dirs, - include_dir_count*sizeof (*include_dirs)); - } - - include_dirs[include_dir_count-1] = path; /* New one */ - - i = strlen (path); - if (i > include_dir_maxlen) - include_dir_maxlen = i; -} /* add_include_dir() */ - -void s_ignore(arg) -int arg; -{ - extern char is_end_of_line[]; - - while (!is_end_of_line[*input_line_pointer]) { - ++input_line_pointer; - } - ++input_line_pointer; - - return; -} /* s_ignore() */ - -/* - * Local Variables: - * comment-column: 0 - * fill-column: 131 - * End: - */ - -/* end of read.c */ diff --git a/gas/read.h b/gas/read.h deleted file mode 100644 index 01351d6949f..00000000000 --- a/gas/read.h +++ /dev/null @@ -1,137 +0,0 @@ -/* read.h - of read.c - Copyright (C) 1986, 1990 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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 1, or (at your option) -any later version. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* $Id$ */ - -extern char *input_line_pointer; /* -> char we are parsing now. */ - -#define PERMIT_WHITESPACE /* Define to make whitespace be allowed in */ - /* many syntactically unnecessary places. */ - /* Normally undefined. For compatibility */ - /* with ancient GNU cc. */ -#undef PERMIT_WHITESPACE - -#ifdef PERMIT_WHITESPACE -#define SKIP_WHITESPACE() {if (* input_line_pointer == ' ') ++ input_line_pointer;} -#else -#define SKIP_WHITESPACE() know(*input_line_pointer != ' ' ) -#endif - - -#define LEX_NAME (1) /* may continue a name */ -#define LEX_BEGIN_NAME (2) /* may begin a name */ - -#define is_name_beginner(c) ( lex_type[c] & LEX_BEGIN_NAME ) -#define is_part_of_name(c) ( lex_type[c] & LEX_NAME ) - -#ifndef is_a_char -#define CHAR_MASK (0xff) -#define NOT_A_CHAR (CHAR_MASK+1) -#define is_a_char(c) (((unsigned)(c)) <= CHAR_MASK) -#endif /* is_a_char() */ - -extern const char lex_type[]; -extern char is_end_of_line[]; - -#ifdef __STDC__ - -char *demand_copy_C_string(int *len_pointer); -char get_absolute_expression_and_terminator(long *val_pointer); -long get_absolute_expression(void); -void add_include_dir(char *path); -void big_cons(int nbytes); -void cons(unsigned int nbytes); -void demand_empty_rest_of_line(void); -void equals(char *sym_name); -void float_cons(int float_type); -void ignore_rest_of_line(void); -void pseudo_set(symbolS *symbolP); -void read_a_source_file(char *name); -void read_begin(void); -void s_abort(void); -void s_align_bytes(int arg); -void s_align_ptwo(void); -void s_app_file(void); -void s_comm(void); -void s_data(void); -void s_else(int arg); -void s_end(int arg); -void s_endif(int arg); -void s_fill(void); -void s_globl(void); -void s_if(int arg); -void s_ifdef(int arg); -void s_ifeqs(int arg); -void s_ignore(int arg); -void s_include(int arg); -void s_lcomm(int needs_align); -void s_lsym(void); -void s_org(void); -void s_set(void); -void s_space(void); -void s_text(void); - -#else /* __STDC__ */ - -char *demand_copy_C_string(); -char get_absolute_expression_and_terminator(); -long get_absolute_expression(); -void add_include_dir(); -void big_cons(); -void cons(); -void demand_empty_rest_of_line(); -void equals(); -void float_cons(); -void ignore_rest_of_line(); -void pseudo_set(); -void read_a_source_file(); -void read_begin(); -void s_abort(); -void s_align_bytes(); -void s_align_ptwo(); -void s_app_file(); -void s_comm(); -void s_data(); -void s_else(); -void s_end(); -void s_endif(); -void s_fill(); -void s_globl(); -void s_if(); -void s_ifdef(); -void s_ifeqs(); -void s_ignore(); -void s_include(); -void s_lcomm(); -void s_lsym(); -void s_org(); -void s_set(); -void s_space(); -void s_text(); - -#endif /* __STDC__ */ - -/* - * Local Variables: - * comment-column: 0 - * fill-column: 131 - * End: - */ - -/* end: read.h */ diff --git a/gas/strstr.c b/gas/strstr.c deleted file mode 100644 index 69e94e58f83..00000000000 --- a/gas/strstr.c +++ /dev/null @@ -1,55 +0,0 @@ -/* strstr - find first occurrence of wanted in s - Copyright (C) 1989, 1990, 1991 Free Software Foundation. - -This file is part of GAS, the GNU Assembler. - -GAS 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. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* static const char rcsid[] = "$Id$"; */ - - /* If your compiler is really ansi, then you don't need this. */ -#ifndef __STDC__ - -#define SIZET int - -#define NULL 0 - -#include - -char * /* found string, or NULL if none */ -strstr(s, wanted) -char *s; -char *wanted; -{ - register char *scan; - register SIZET len; - register char firstc; - - /* - * The odd placement of the two tests is so "" is findable. - * Also, we inline the first char for speed. - * The ++ on scan has been moved down for optimization. - */ - firstc = *wanted; - len = strlen(wanted); - for (scan = s; *scan != firstc || strncmp(scan, wanted, len) != 0; ) - if (*scan++ == '\0') - return(NULL); - return(scan); -} /* strstr() */ - -#endif /* __STDC__ */ - -/* end of strstr.c */ diff --git a/gas/struc-symbol.h b/gas/struc-symbol.h deleted file mode 100644 index 2827648ea5f..00000000000 --- a/gas/struc-symbol.h +++ /dev/null @@ -1,113 +0,0 @@ -/* struct_symbol.h - Internal symbol structure - Copyright (C) 1987 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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 1, or (at your option) -any later version. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -struct symbol /* our version of an nlist node */ -{ - obj_symbol_type sy_symbol; /* what we write in .o file (if permitted) */ - unsigned long sy_name_offset; /* 4-origin position of sy_name in symbols */ - /* part of object file. */ - /* 0 for (nameless) .stabd symbols. */ - /* Not used until write_object_file() time. */ - long sy_number; /* 24 bit symbol number. */ - /* Symbol numbers start at 0 and are */ - /* unsigned. */ - struct symbol *sy_next; /* forward chain, or NULL */ -#ifdef SYMBOLS_NEED_BACKPOINTERS - struct symbol *sy_previous; /* backward chain, or NULL */ -#endif /* SYMBOLS_NEED_BACKPOINTERS */ - struct frag *sy_frag; /* NULL or -> frag this symbol attaches to. */ - struct symbol *sy_forward; /* value is really that of this other symbol */ -/* We will probably want to add a sy_segment here soon. */ -}; - -typedef struct symbol symbolS; - -typedef unsigned valueT; /* The type of n_value. Helps casting. */ - -#ifndef WORKING_DOT_WORD -struct broken_word { - struct broken_word *next_broken_word;/* One of these strucs per .word x-y */ - fragS *frag; /* Which frag its in */ - char *word_goes_here;/* Where in the frag it is */ - fragS *dispfrag; /* where to add the break */ - symbolS *add; /* symbol_x */ - symbolS *sub; /* - symbol_y */ - long addnum; /* + addnum */ - int added; /* nasty thing happend yet? */ - /* 1: added and has a long-jump */ - /* 2: added but uses someone elses long-jump */ - struct broken_word *use_jump; /* points to broken_word with a similar - long-jump */ -}; -extern struct broken_word *broken_words; -#endif /* ndef WORKING_DOT_WORD */ - -/* - * Current means for getting from symbols to segments and vice verse. - * This will change for infinite-segments support (e.g. COFF). - */ -/* #define SYMBOL_TYPE_TO_SEGMENT(symP) ( N_TYPE_seg [(int) (symP)->sy_type & N_TYPE] ) */ -extern segT N_TYPE_seg[]; /* subseg.c */ - -#define SEGMENT_TO_SYMBOL_TYPE(seg) ( seg_N_TYPE [(int) (seg)] ) -extern const short seg_N_TYPE[]; /* subseg.c */ - -#define N_REGISTER 30 /* Fake N_TYPE value for SEG_REGISTER */ - -#ifdef SYMBOLS_NEED_BACKPOINTERS -#ifdef __STDC__ - -void symbol_clear_list_pointers(symbolS *symbolP); -void symbol_insert(symbolS *addme, symbolS *target, symbolS **rootP, symbolS **lastP); -void symbol_remove(symbolS *symbolP, symbolS **rootP, symbolS **lastP); -void verify_symbol_chain(symbolS *rootP, symbolS *lastP); - -#else /* __STDC__ */ - -void symbol_clear_list_pointers(); -void symbol_insert(); -void symbol_remove(); -void verify_symbol_chain(); - -#endif /* __STDC__ */ - -#define symbol_previous(s) ((s)->sy_previous) - -#else /* SYMBOLS_NEED_BACKPOINTERS */ - -#define symbol_clear_list_pointers(clearme) {clearme->sy_next = NULL;} - -#endif /* SYMBOLS_NEED_BACKPOINTERS */ - -#ifdef __STDC__ -void symbol_append(symbolS *addme, symbolS *target, symbolS **rootP, symbolS **lastP); -#else /* __STDC__ */ -void symbol_append(); -#endif /* __STDC__ */ - -#define symbol_next(s) ((s)->sy_next) - -/* - * Local Variables: - * comment-column: 0 - * fill-column: 131 - * End: - */ - -/* end of struc-symbol.h */ diff --git a/gas/subsegs.c b/gas/subsegs.c deleted file mode 100644 index 00937ea783c..00000000000 --- a/gas/subsegs.c +++ /dev/null @@ -1,279 +0,0 @@ -/* subsegs.c - subsegments - - Copyright (C) 1987, 1990, 1991 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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 1, or (at your option) -any later version. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* static const char rcsid[] = "$Id$"; */ - -/* - * Segments & sub-segments. - */ - -#include "as.h" - -#include "subsegs.h" -#include "obstack.h" - -frchainS* frchain_root, - * frchain_now, /* Commented in "subsegs.h". */ - * data0_frchainP; - - -char * const /* in: segT out: char* */ -seg_name[] = { - "absolute", - "text", - "data", - "bss", - "unknown", - "absent", - "pass1", - "ASSEMBLER-INTERNAL-LOGIC-ERROR!", - "bignum/flonum", - "difference", - "debug", - "transfert vector preload", - "transfert vector postload", - "register", - "", -}; /* Used by error reporters, dumpers etc. */ - - -void -subsegs_begin() -{ - /* Check table(s) seg_name[], seg_N_TYPE[] is in correct order */ - know( SEG_ABSOLUTE == 0 ); - know( SEG_TEXT == 1 ); - know( SEG_DATA == 2 ); - know( SEG_BSS == 3 ); - know( SEG_UNKNOWN == 4 ); - know( SEG_ABSENT == 5 ); - know( SEG_PASS1 == 6 ); - know( SEG_GOOF == 7 ); - know( SEG_BIG == 8 ); - know( SEG_DIFFERENCE == 9 ); - know( SEG_DEBUG == 10 ); - know( SEG_NTV == 11 ); - know( SEG_PTV == 12 ); - know( SEG_REGISTER == 13 ); - know( SEG_MAXIMUM_ORDINAL == SEG_REGISTER ); - know( segment_name (SEG_MAXIMUM_ORDINAL + 1) [0] == 0 ); - - obstack_begin( &frags, 5000); - frchain_root = NULL; - frchain_now = NULL; /* Warn new_subseg() that we are booting. */ - /* Fake up 1st frag. */ - /* It won't be used=> is ok if obstack... */ - /* pads the end of it for alignment. */ - frag_now=(fragS *)obstack_alloc(&frags,SIZEOF_STRUCT_FRAG); - /* obstack_1blank( &frags, SIZEOF_STRUCT_FRAG, & frag_now ); */ - /* This 1st frag will not be in any frchain. */ - /* We simply give subseg_new somewhere to scribble. */ - now_subseg = 42; /* Lie for 1st call to subseg_new. */ - subseg_new (SEG_DATA, 0); /* .data 0 */ - data0_frchainP = frchain_now; -} - -/* - * subseg_change() - * - * Change the subsegment we are in, BUT DO NOT MAKE A NEW FRAG for the - * subsegment. If we are already in the correct subsegment, change nothing. - * This is used eg as a worker for subseg_new [which does make a new frag_now] - * and for changing segments after we have read the source. We construct eg - * fixSs even after the source file is read, so we do have to keep the - * segment context correct. - */ -void -subseg_change (seg, subseg) - register segT seg; - register int subseg; -{ - now_seg = seg; - now_subseg = subseg; - if (seg == SEG_DATA) - { - seg_fix_rootP = & data_fix_root; - seg_fix_tailP = & data_fix_tail; - } - else - { - know (seg == SEG_TEXT); - seg_fix_rootP = & text_fix_root; - seg_fix_tailP = & text_fix_tail; - } -} - -/* - * subseg_new() - * - * If you attempt to change to the current subsegment, nothing happens. - * - * In: segT, subsegT code for new subsegment. - * frag_now -> incomplete frag for current subsegment. - * If frag_now==NULL, then there is no old, incomplete frag, so - * the old frag is not closed off. - * - * Out: now_subseg, now_seg updated. - * Frchain_now points to the (possibly new) struct frchain for this - * sub-segment. - * Frchain_root updated if needed. - */ - -void -subseg_new (seg, subseg) /* begin assembly for a new sub-segment */ - register segT seg; /* SEG_DATA or SEG_TEXT */ - register subsegT subseg; -{ - long tmp; /* JF for obstack alignment hacking */ - - know( seg == SEG_DATA || seg == SEG_TEXT ); - - if (seg != now_seg || subseg != now_subseg) - { /* we just changed sub-segments */ - register frchainS * frcP; /* crawl frchain chain */ - register frchainS** lastPP; /* address of last pointer */ - frchainS * newP; /* address of new frchain */ - register fragS * former_last_fragP; - register fragS * new_fragP; - - if (frag_now) /* If not bootstrapping. */ - { - frag_now -> fr_fix = obstack_next_free(& frags) - frag_now -> fr_literal; - frag_wane(frag_now); /* Close off any frag in old subseg. */ - } -/* - * It would be nice to keep an obstack for each subsegment, if we swap - * subsegments a lot. Hence we would have much fewer frag_wanes(). - */ - { - - obstack_finish( &frags); - /* - * If we don't do the above, the next object we put on obstack frags - * will appear to start at the fr_literal of the current frag. - * Also, above ensures that the next object will begin on a - * address that is aligned correctly for the engine that runs - * this program. - */ - } - subseg_change (seg, (int)subseg); - /* - * Attempt to find or make a frchain for that sub seg. - * Crawl along chain of frchainSs, begins @ frchain_root. - * If we need to make a frchainS, link it into correct - * position of chain rooted in frchain_root. - */ - for (frcP = * (lastPP = & frchain_root); - frcP - && (int)(frcP -> frch_seg) <= (int)seg; - frcP = * ( lastPP = & frcP -> frch_next) - ) - { - if ( (int)(frcP -> frch_seg) == (int)seg - && frcP -> frch_subseg >= subseg) - { - break; - } - } - /* - * frcP: Address of the 1st frchainS in correct segment with - * frch_subseg >= subseg. - * We want to either use this frchainS, or we want - * to insert a new frchainS just before it. - * - * If frcP==NULL, then we are at the end of the chain - * of frchainS-s. A NULL frcP means we fell off the end - * of the chain looking for a - * frch_subseg >= subseg, so we - * must make a new frchainS. - * - * If we ever maintain a pointer to - * the last frchainS in the chain, we change that pointer - * ONLY when frcP==NULL. - * - * lastPP: Address of the pointer with value frcP; - * Never NULL. - * May point to frchain_root. - * - */ - if ( ! frcP - || ( (int)(frcP -> frch_seg) > (int)seg - || frcP->frch_subseg > subseg)) /* Kinky logic only works with 2 segments. */ - { - /* - * This should be the only code that creates a frchainS. - */ - newP=(frchainS *)obstack_alloc(&frags,sizeof(frchainS)); - /* obstack_1blank( &frags, sizeof(frchainS), &newP); */ - /* This begines on a good boundary */ - /* because a obstack_done() preceeded it. */ - /* It implies an obstack_done(), so we */ - /* expect the next object allocated to */ - /* begin on a correct boundary. */ - *lastPP = newP; - newP -> frch_next = frcP; /* perhaps NULL */ - (frcP = newP) -> frch_subseg = subseg; - newP -> frch_seg = seg; - newP -> frch_last = NULL; - } - /* - * Here with frcP ->ing to the frchainS for subseg. - */ - frchain_now = frcP; - /* - * Make a fresh frag for the subsegment. - */ - /* We expect this to happen on a correct */ - /* boundary since it was proceeded by a */ - /* obstack_done(). */ - tmp=obstack_alignment_mask(&frags); /* JF disable alignment */ - obstack_alignment_mask(&frags)=0; - frag_now=(fragS *)obstack_alloc(&frags,SIZEOF_STRUCT_FRAG); - obstack_alignment_mask(&frags)=tmp; - /* know( frags . obstack_c_next_free == frag_now -> fr_literal ); */ - /* But we want any more chars to come */ - /* immediately after the structure we just made. */ - new_fragP = frag_now; - new_fragP -> fr_next = NULL; - /* - * Append new frag to current frchain. - */ - former_last_fragP = frcP -> frch_last; - if (former_last_fragP) - { - know( former_last_fragP -> fr_next == NULL ); - know( frchain_now -> frch_root ); - former_last_fragP -> fr_next = new_fragP; - } - else - { - frcP -> frch_root = new_fragP; - } - frcP -> frch_last = new_fragP; - } /* if (changing subsegments) */ -} /* subseg_new() */ - -/* - * Local Variables: - * comment-column: 0 - * fill-column: 131 - * End: - */ - -/* end: subsegs.c */ diff --git a/gas/subsegs.h b/gas/subsegs.h deleted file mode 100644 index b8dbaf76e58..00000000000 --- a/gas/subsegs.h +++ /dev/null @@ -1,65 +0,0 @@ -/* subsegs.h -> subsegs.c - Copyright (C) 1987 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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 1, or (at your option) -any later version. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - * For every sub-segment the user mentions in the ASsembler program, - * we make one struct frchain. Each sub-segment has exactly one struct frchain - * and vice versa. - * - * Struct frchain's are forward chained (in ascending order of sub-segment - * code number). The chain runs through frch_next of each subsegment. - * This makes it hard to find a subsegment's frags - * if programmer uses a lot of them. Most programs only use text0 and - * data0, so they don't suffer. At least this way: - * (1) There are no "arbitrary" restrictions on how many subsegments - * can be programmed; - * (2) Subsegments' frchain-s are (later) chained together in the order in - * which they are emitted for object file viz text then data. - * - * From each struct frchain dangles a chain of struct frags. The frags - * represent code fragments, for that sub-segment, forward chained. - */ - -struct frchain /* control building of a frag chain */ -{ /* FRCH = FRagment CHain control */ - struct frag * frch_root; /* 1st struct frag in chain, or NULL */ - struct frag * frch_last; /* last struct frag in chain, or NULL */ - struct frchain * frch_next; /* next in chain of struct frchain-s */ - segT frch_seg; /* SEG_TEXT or SEG_DATA. */ - subsegT frch_subseg; /* subsegment number of this chain */ -}; - -typedef struct frchain frchainS; - -extern frchainS * frchain_root; /* NULL means no frchains yet. */ - /* all subsegments' chains hang off here */ - -extern frchainS * frchain_now; - /* Frchain we are assembling into now */ - /* That is, the current segment's frag */ - /* chain, even if it contains no (complete) */ - /* frags. */ - -extern frchainS * data0_frchainP; - /* Sentinel for frchain crawling. */ - /* Points to the 1st data-segment frchain. */ - /* (Which is pointed to by the last text- */ - /* segment frchain.) */ - -/* end: subsegs.h */ diff --git a/gas/symbols.c b/gas/symbols.c deleted file mode 100644 index 9d75ae1ea43..00000000000 --- a/gas/symbols.c +++ /dev/null @@ -1,652 +0,0 @@ -/* symbols.c -symbol table- - Copyright (C) 1987, 1990, 1991 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* static const char rcsid[] = "$Id$"; */ - -#include "as.h" - -#include "obstack.h" /* For "symbols.h" */ -#include "subsegs.h" - -#ifndef WORKING_DOT_WORD -extern int new_broken_words; -#endif -#ifdef VMS -extern char const_flag; -#endif - -static -struct hash_control * -sy_hash; /* symbol-name => struct symbol pointer */ - - /* Below are commented in "symbols.h". */ -unsigned int local_bss_counter; -symbolS * symbol_rootP; -symbolS * symbol_lastP; -symbolS abs_symbol; - -symbolS* dot_text_symbol; -symbolS* dot_data_symbol; -symbolS* dot_bss_symbol; - -struct obstack notes; - -/* - * Un*x idea of local labels. They are made by "n:" where n - * is any decimal digit. Refer to them with - * "nb" for previous (backward) n: - * or "nf" for next (forward) n:. - * - * Like Un*x AS, we have one set of local label counters for entire assembly, - * not one set per (sub)segment like in most assemblers. This implies that - * one can refer to a label in another segment, and indeed some crufty - * compilers have done just that. - * - * I document the symbol names here to save duplicating words elsewhere. - * The mth occurence of label n: is turned into the symbol "Ln^Am" where - * n is a digit and m is a decimal number. "L" makes it a label discarded - * unless debugging and "^A"('\1') ensures no ordinary symbol SHOULD get the - * same name as a local label symbol. The first "4:" is "L4^A1" - the m - * numbers begin at 1. - */ - -typedef short unsigned int -local_label_countT; - -static local_label_countT -local_label_counter[10]; - -static /* Returned to caller, then copied. */ - char symbol_name_build[12]; /* used for created names ("4f") */ - -#ifdef LOCAL_LABELS_DOLLAR -int local_label_defined[10]; -#endif - - -void -symbol_begin() -{ - symbol_lastP = NULL; - symbol_rootP = NULL; /* In case we have 0 symbols (!!) */ - sy_hash = hash_new(); - bzero ((char *)(& abs_symbol), sizeof(abs_symbol)); - S_SET_SEGMENT(&abs_symbol, SEG_ABSOLUTE); /* Can't initialise a union. Sigh. */ - bzero ((char *)(local_label_counter), sizeof(local_label_counter) ); - local_bss_counter = 0; -} - -/* - * local_label_name() - * - * Caller must copy returned name: we re-use the area for the next name. - */ - -char * /* Return local label name. */ -local_label_name(n, augend) - register int n; /* we just saw "n:", "nf" or "nb" : n a digit */ - register int augend; /* 0 for nb, 1 for n:, nf */ -{ - register char * p; - register char * q; - char symbol_name_temporary[10]; /* build up a number, BACKWARDS */ - - know( n >= 0 ); - know( augend == 0 || augend == 1 ); - p = symbol_name_build; - * p ++ = 'L'; - * p ++ = n + '0'; /* Make into ASCII */ - * p ++ = 1; /* ^A */ - n = local_label_counter [ n ] + augend; - /* version number of this local label */ - /* - * Next code just does sprintf( {}, "%d", n); - * It is more elegant to do the next part recursively, but a procedure - * call for each digit emitted is considered too costly. - */ - q = symbol_name_temporary; - for (*q++=0; n; q++) /* emits NOTHING if n starts as 0 */ - { - know(n>0); /* We expect n > 0 always */ - *q = n % 10 + '0'; - n /= 10; - } - while (( * p ++ = * -- q ) != '\0') ;; - - /* The label, as a '\0' ended string, starts at symbol_name_build. */ - return(symbol_name_build); -} /* local_label_name() */ - - -void local_colon (n) -int n; /* just saw "n:" */ -{ - local_label_counter [n] ++; -#ifdef LOCAL_LABELS_DOLLAR - local_label_defined[n]=1; -#endif - colon (local_label_name (n, 0)); -} - -/* - * symbol_new() - * - * Return a pointer to a new symbol. - * Die if we can't make a new symbol. - * Fill in the symbol's values. - * Add symbol to end of symbol chain. - * - * - * Please always call this to create a new symbol. - * - * Changes since 1985: Symbol names may not contain '\0'. Sigh. - * 2nd argument is now a SEG rather than a TYPE. The mapping between - * segments and types is mostly encapsulated herein (actually, we inherit it - * from macros in struc-symbol.h). - */ - -symbolS *symbol_new(name, segment, value, frag) -char *name; /* It is copied, the caller can destroy/modify */ -segT segment; /* Segment identifier (SEG_) */ -long value; /* Symbol value */ -fragS *frag; /* Associated fragment */ -{ - unsigned int name_length; - char *preserved_copy_of_name; - symbolS *symbolP; - - name_length = strlen(name) + 1; /* +1 for \0 */ - obstack_grow(¬es, name, name_length); - preserved_copy_of_name = obstack_finish(¬es); - symbolP = (symbolS *)obstack_alloc(¬es, sizeof(symbolS)); - - /* symbol must be born in some fixed state. This seems as good as any. */ - memset(symbolP, 0, sizeof(symbolS)); - -#ifdef STRIP_UNDERSCORE - S_SET_NAME(symbolP, (*preserved_copy_of_name == '_' - ? preserved_copy_of_name + 1 - : preserved_copy_of_name)); -#else /* STRIP_UNDERSCORE */ - S_SET_NAME(symbolP, preserved_copy_of_name); -#endif /* STRIP_UNDERSCORE */ - - S_SET_SEGMENT(symbolP, segment); - S_SET_VALUE(symbolP, value); -/* symbol_clear_list_pointers(symbolP); uneeded if symbol is born zeroed. */ - - symbolP->sy_frag = frag; - /* krm: uneeded if symbol is born zeroed. - symbolP->sy_forward = NULL; */ /* JF */ - symbolP->sy_number = ~0; - symbolP->sy_name_offset = ~0; - - /* - * Link to end of symbol chain. - */ - symbol_append(symbolP, symbol_lastP, &symbol_rootP, &symbol_lastP); - - obj_symbol_new_hook(symbolP); - -#ifdef DEBUG - verify_symbol_chain(symbol_rootP, symbol_lastP); -#endif /* DEBUG */ - - return(symbolP); -} /* symbol_new() */ - - -/* - * colon() - * - * We have just seen ":". - * Creates a struct symbol unless it already exists. - * - * Gripes if we are redefining a symbol incompatibly (and ignores it). - * - */ -void colon(sym_name) /* just seen "x:" - rattle symbols & frags */ - register char * sym_name; /* symbol name, as a cannonical string */ - /* We copy this string: OK to alter later. */ -{ - register symbolS * symbolP; /* symbol we are working with */ - -#ifdef LOCAL_LABELS_DOLLAR - /* Sun local labels go out of scope whenever a non-local symbol is defined. */ - - if(*sym_name !='L') - bzero((void *) local_label_defined, sizeof(local_label_defined)); -#endif - -#ifndef WORKING_DOT_WORD - if(new_broken_words) { - struct broken_word *a; - int possible_bytes; - fragS *frag_tmp; - char *frag_opcode; - - extern md_short_jump_size; - extern md_long_jump_size; - possible_bytes=md_short_jump_size + new_broken_words * md_long_jump_size; - - frag_tmp=frag_now; - frag_opcode=frag_var(rs_broken_word, - possible_bytes, - possible_bytes, - (relax_substateT) 0, - (symbolS *) broken_words, - 0L, - NULL); - - /* We want to store the pointer to where to insert the jump table in the - fr_opcode of the rs_broken_word frag. This requires a little hackery */ - while(frag_tmp && (frag_tmp->fr_type!=rs_broken_word || frag_tmp->fr_opcode)) - frag_tmp=frag_tmp->fr_next; - know(frag_tmp); - frag_tmp->fr_opcode=frag_opcode; - new_broken_words = 0; - - for(a=broken_words;a && a->dispfrag==0;a=a->next_broken_word) - a->dispfrag=frag_tmp; - } -#endif - if ((symbolP = symbol_find(sym_name)) != 0) { -#ifdef VMS - /* - * If the new symbol is .comm AND it has a size of zero, - * we ignore it (i.e. the old symbol overrides it) - */ - if ((SEGMENT_TO_SYMBOL_TYPE((int) now_seg) == (N_UNDF | N_EXT)) && - ((obstack_next_free(& frags) - frag_now->fr_literal) == 0)) - return; - /* - * If the old symbol is .comm and it has a size of zero, - * we override it with the new symbol value. - */ - if ((symbolP->sy_type == (N_UNDF | N_EXT)) - && (S_GET_VALUE(symbolP) == 0)) { - symbolP->sy_frag = frag_now; - symbolP->sy_other = const_flag; - S_SET_VALUE(symbolP, obstack_next_free(& frags) - frag_now->fr_literal); - symbolP->sy_type |= SEGMENT_TO_SYMBOL_TYPE((int) now_seg); /* keep N_EXT bit */ - return; - } -#endif /* VMS */ - /* - * Now check for undefined symbols - */ - if (!S_IS_DEFINED(symbolP)) { - if (S_GET_VALUE(symbolP) == 0) { - symbolP->sy_frag = frag_now; -#ifdef VMS - symbolP->sy_other = const_flag; -#endif - S_SET_VALUE(symbolP, obstack_next_free(&frags) - frag_now->fr_literal); - S_SET_SEGMENT(symbolP, now_seg); -#ifdef N_UNDF - know(N_UNDF == 0); -#endif /* if we have one, it better be zero. */ - - } else { - /* - * There are still several cases to check: - * A .comm/.lcomm symbol being redefined as - * initialized data is OK - * A .comm/.lcomm symbol being redefined with - * a larger size is also OK - * - * This only used to be allowed on VMS gas, but Sun cc - * on the sparc also depends on it. - */ -/* char New_Type = SEGMENT_TO_SYMBOL_TYPE((int) now_seg); */ -#ifdef MANY_SEGMENTS -#define SEG_BSS SEG_E2 -#define SEG_DATA SEG_E1 -#endif - - if (((!S_IS_DEBUG(symbolP) && !S_IS_DEFINED(symbolP) && S_IS_EXTERNAL(symbolP)) - || (S_GET_SEGMENT(symbolP) == SEG_BSS)) - && ((now_seg == SEG_DATA) - || (now_seg == S_GET_SEGMENT(symbolP)))) { - /* - * Select which of the 2 cases this is - */ - if (now_seg != SEG_DATA) { - /* - * New .comm for prev .comm symbol. - * If the new size is larger we just - * change its value. If the new size - * is smaller, we ignore this symbol - */ - if (S_GET_VALUE(symbolP) - < ((unsigned) (obstack_next_free(& frags) - frag_now->fr_literal))) { - S_SET_VALUE(symbolP, - obstack_next_free(& frags) - - frag_now->fr_literal); - } - } else { - /* - * It is a .comm/.lcomm being converted - * to initialized data. - */ - symbolP->sy_frag = frag_now; -#ifdef VMS - symbolP->sy_other = const_flag; -#endif /* VMS */ - S_SET_VALUE(symbolP, obstack_next_free(& frags) - frag_now->fr_literal); - S_SET_SEGMENT(symbolP, now_seg); /* keep N_EXT bit */ - } - } else { -#ifdef OBJ_COFF - as_fatal("Symbol \"%s\" is already defined as \"%s\"/%d.", - sym_name, - segment_name(S_GET_SEGMENT(symbolP)), - S_GET_VALUE(symbolP)); -#else /* OBJ_COFF */ - as_fatal("Symbol \"%s\" is already defined as \"%s\"/%d.%d.%d.", - sym_name, - segment_name(S_GET_SEGMENT(symbolP)), - S_GET_OTHER(symbolP), S_GET_DESC(symbolP), - S_GET_VALUE(symbolP)); -#endif /* OBJ_COFF */ - } - } /* if the undefined symbol has no value */ - } else { - as_fatal("Symbol %s already defined.", sym_name); - } /* if this symbol is not yet defined */ - - } else { - symbolP = symbol_new(sym_name, - now_seg, - (valueT)(obstack_next_free(&frags)-frag_now->fr_literal), - frag_now); -#ifdef VMS - S_SET_OTHER(symbolP, const_flag); -#endif /* VMS */ - - symbol_table_insert(symbolP); - } /* if we have seen this symbol before */ - - return; -} /* colon() */ - - -/* - * symbol_table_insert() - * - * Die if we can't insert the symbol. - * - */ - -void symbol_table_insert(symbolP) -symbolS *symbolP; -{ - register char *error_string; - - know(symbolP); - know(S_GET_NAME(symbolP)); - - if (*(error_string = hash_jam(sy_hash, S_GET_NAME(symbolP), (char *)symbolP))) { - as_fatal("Inserting \"%s\" into symbol table failed: %s", - S_GET_NAME(symbolP), error_string); - } /* on error */ -} /* symbol_table_insert() */ - -/* - * symbol_find_or_make() - * - * If a symbol name does not exist, create it as undefined, and insert - * it into the symbol table. Return a pointer to it. - */ -symbolS *symbol_find_or_make(name) -char *name; -{ - register symbolS *symbolP; - - symbolP = symbol_find(name); - - if (symbolP == NULL) { - symbolP = symbol_make(name); - - symbol_table_insert(symbolP); - } /* if symbol wasn't found */ - - return(symbolP); -} /* symbol_find_or_make() */ - -symbolS *symbol_make(name) -char *name; -{ - symbolS *symbolP; - - /* Let the machine description default it, e.g. for register names. */ - symbolP = md_undefined_symbol(name); - - if (!symbolP) { - symbolP = symbol_new(name, - SEG_UNKNOWN, - 0, - &zero_address_frag); - } /* if md didn't build us a symbol */ - - return(symbolP); -} /* symbol_make() */ - -/* - * symbol_find() - * - * Implement symbol table lookup. - * In: A symbol's name as a string: '\0' can't be part of a symbol name. - * Out: NULL if the name was not in the symbol table, else the address - * of a struct symbol associated with that name. - */ - -symbolS *symbol_find(name) -char *name; -{ -#ifdef STRIP_UNDERSCORE - return(symbol_find_base(name, 1)); -#else /* STRIP_UNDERSCORE */ - return(symbol_find_base(name, 0)); -#endif /* STRIP_UNDERSCORE */ -} /* symbol_find() */ - -symbolS *symbol_find_base(name, strip_underscore) -char *name; -int strip_underscore; -{ - if(strip_underscore && *name == '_') name++; - return ( (symbolS *) hash_find( sy_hash, name )); -} - -/* - * Once upon a time, symbols were kept in a singly linked list. At - * least coff needs to be able to rearrange them from time to time, for - * which a doubly linked list is much more convenient. Loic did these - * as macros which seemed dangerous to me so they're now functions. - * xoxorich. - */ - -/* Link symbol ADDME after symbol TARGET in the chain. */ -void symbol_append(addme, target, rootPP, lastPP) -symbolS *addme; -symbolS *target; -symbolS **rootPP; -symbolS **lastPP; -{ - if (target == NULL) { - know(*rootPP == NULL); - know(*lastPP == NULL); - *rootPP = addme; - *lastPP = addme; - return; - } /* if the list is empty */ - - if (target->sy_next != NULL) { -#ifdef SYMBOLS_NEED_BACKPOINTERS - target->sy_next->sy_previous = addme; -#endif /* SYMBOLS_NEED_BACKPOINTERS */ - } else { - know(*lastPP == target); - *lastPP = addme; - } /* if we have a next */ - - addme->sy_next = target->sy_next; - target->sy_next = addme; - -#ifdef SYMBOLS_NEED_BACKPOINTERS - addme->sy_previous = target; -#endif /* SYMBOLS_NEED_BACKPOINTERS */ - -#ifdef DEBUG - verify_symbol_chain(*rootPP, *lastPP); -#endif /* DEBUG */ - - return; -} /* symbol_append() */ - -#ifdef SYMBOLS_NEED_BACKPOINTERS -/* Remove SYMBOLP from the list. */ -void symbol_remove(symbolP, rootPP, lastPP) -symbolS *symbolP; -symbolS **rootPP; -symbolS **lastPP; -{ - if (symbolP == *rootPP) { - *rootPP = symbolP->sy_next; - } /* if it was the root */ - - if (symbolP == *lastPP) { - *lastPP = symbolP->sy_previous; - } /* if it was the tail */ - - if (symbolP->sy_next != NULL) { - symbolP->sy_next->sy_previous = symbolP->sy_previous; - } /* if not last */ - - if (symbolP->sy_previous != NULL) { - symbolP->sy_previous->sy_next = symbolP->sy_next; - } /* if not first */ - -#ifdef DEBUG - verify_symbol_chain(*rootPP, *lastPP); -#endif /* DEBUG */ - - return; -} /* symbol_remove() */ - -/* Set the chain pointers of SYMBOL to null. */ -void symbol_clear_list_pointers(symbolP) -symbolS *symbolP; -{ - symbolP->sy_next = NULL; - symbolP->sy_previous = NULL; -} /* symbol_clear_list_pointers() */ - -/* Link symbol ADDME before symbol TARGET in the chain. */ -void symbol_insert(addme, target, rootPP, lastPP) -symbolS *addme; -symbolS *target; -symbolS **rootPP; -symbolS **lastPP; -{ - if (target->sy_previous != NULL) { - target->sy_previous->sy_next = addme; - } else { - know(*rootPP == target); - *rootPP = addme; - } /* if not first */ - - addme->sy_previous = target->sy_previous; - target->sy_previous = addme; - addme->sy_next = target; - -#ifdef DEBUG - verify_symbol_chain(*rootPP, *lastPP); -#endif /* DEBUG */ - - return; -} /* symbol_insert() */ -#endif /* SYMBOLS_NEED_BACKPOINTERS */ - -void verify_symbol_chain(rootP, lastP) -symbolS *rootP; -symbolS *lastP; -{ - symbolS *symbolP = rootP; - - if (symbolP == NULL) { - return; - } /* empty chain */ - - for ( ; symbol_next(symbolP) != NULL; symbolP = symbol_next(symbolP)) { -#ifdef SYMBOLS_NEED_BACKPOINTERS - /*$if (symbolP->sy_previous) { - know(symbolP->sy_previous->sy_next == symbolP); - } else { - know(symbolP == rootP); - }$*/ /* both directions */ - know(symbolP->sy_next->sy_previous == symbolP); -#else /* SYMBOLS_NEED_BACKPOINTERS */ - ; -#endif /* SYMBOLS_NEED_BACKPOINTERS */ - } /* verify pointers */ - - know(lastP == symbolP); - - return; -} /* verify_symbol_chain() */ - - -/* - * decode name that may have been generated by local_label_name() above. If - * the name wasn't generated by local_label_name(), then return it unaltered. - * This is used for error messages. - */ - -char *decode_local_label_name(s) -char *s; -{ - char *symbol_decode; - int label_number; - /* int label_version; */ - char *message_format = "\"%d\" (instance number %s of a local label)"; - - if (s[0] != 'L' - || s[2] != 1) { - return(s); - } /* not a local_label_name() generated name. */ - - label_number = s[1] - '0'; - - (void) sprintf(symbol_decode = obstack_alloc(¬es, strlen(s + 3) + strlen(message_format) + 10), - message_format, label_number, s + 3); - - return(symbol_decode); -} /* decode_local_label_name() */ - - -/* - * Local Variables: - * comment-column: 0 - * fill-column: 131 - * End: - */ - -/* end: symbols.c */ diff --git a/gas/symbols.h b/gas/symbols.h deleted file mode 100644 index 8ced0d45ced..00000000000 --- a/gas/symbols.h +++ /dev/null @@ -1,77 +0,0 @@ -/* symbols.h - - Copyright (C) 1987, 1990 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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 1, or (at your option) -any later version. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* $Id$ */ - -extern struct obstack notes; /* eg FixS live here. */ - -extern struct obstack cond_obstack; /* this is where we track .ifdef/.endif - (if we do that at all). */ - -extern unsigned int local_bss_counter; /* Zeroed before a pass. */ - /* Only used by .lcomm directive. */ - -extern symbolS * symbol_rootP; /* all the symbol nodes */ -extern symbolS * symbol_lastP; /* last struct symbol we made, or NULL */ - -extern symbolS abs_symbol; - -extern symbolS* dot_text_symbol; -extern symbolS* dot_data_symbol; -extern symbolS* dot_bss_symbol; - -#ifdef __STDC__ - -char *local_label_name(int n, int augend); -symbolS *symbol_find(char *name); -symbolS *symbol_find_base(char *name, int strip_underscore); -symbolS *symbol_find_or_make(char *name); -symbolS *symbol_make(char *name); -symbolS *symbol_new(char *name, segT segment, long value, fragS *frag); -void colon(char *sym_name); -void local_colon(int n); -void symbol_begin(void); -void symbol_table_insert(symbolS *symbolP); -void verify_symbol_chain(symbolS *rootP, symbolS *lastP); - -#else - -char *local_label_name(); -symbolS *symbol_find(); -symbolS *symbol_find_base(); -symbolS *symbol_find_or_make(); -symbolS *symbol_make(); -symbolS *symbol_new(); -void colon(); -void local_colon(); -void symbol_begin(); -void symbol_table_insert(); -void verify_symbol_chain(); - -#endif /* __STDC__ */ - - -/* - * Local Variables: - * comment-column: 0 - * fill-column: 131 - * End: - */ - -/* end: symbols.h */ diff --git a/gas/tc.h b/gas/tc.h deleted file mode 100644 index b87ba60b024..00000000000 --- a/gas/tc.h +++ /dev/null @@ -1,112 +0,0 @@ -/* tc.h -target cpu dependent- */ - -/* Copyright (C) 1987, 1990, 1991 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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 1, or (at your option) -any later version. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* static const char rcsid[] = "$Id$"; */ - -/* In theory (mine, at least!) the machine dependent part of the assembler - should only have to include one file. This one. -- JF */ - -extern const pseudo_typeS md_pseudo_table[]; - -/* JF moved this here from as.h under the theory that nobody except MACHINE.c - and write.c care about it anyway. */ - -typedef struct -{ - long rlx_forward; /* Forward reach. Signed number. > 0. */ - long rlx_backward; /* Backward reach. Signed number. < 0. */ - unsigned char rlx_length; /* Bytes length of this address. */ - relax_substateT rlx_more; /* Next longer relax-state. */ - /* 0 means there is no 'next' relax-state. */ -} -relax_typeS; - -extern const relax_typeS md_relax_table[]; /* Define it in MACHINE.c */ - -extern int md_reloc_size; /* Size of a relocation record */ - -extern void (*md_emit_relocations)(); - -#ifdef __STDC__ - -char *md_atof(int what_statement_type, char *literalP, int *sizeP); -int md_estimate_size_before_relax(fragS *fragP, segT segtype); -int md_parse_option(char **argP, int *cntP, char ***vecP); -long md_pcrel_from(fixS *fixP); -long md_section_align(segT seg, long align); -short tc_coff_fix2rtype(fixS *fixP); -symbolS *md_undefined_symbol(char *name); -void md_apply_fix(fixS *fixP, long val); -void md_assemble(char *str); -void md_begin(void); -void md_convert_frag(fragS *fragP); -void md_create_long_jump(char *ptr, long from_addr, long to_addr, fragS *frag, symbolS *to_symbol); -void md_create_short_jump(char *ptr, long from_addr, long to_addr, fragS *frag, symbolS *to_symbol); -void md_end(void); -void md_number_to_chars(char *buf, long val, int n); -void md_operand(expressionS *expressionP); -void md_ri_to_chars(char *the_bytes, struct reloc_info_generic *ri); - -#ifndef tc_crawl_symbol_chain -void tc_crawl_symbol_chain(object_headers *headers); -#endif /* tc_crawl_symbol_chain */ - -#ifndef tc_headers_hook -void tc_headers_hook(object_headers *headers); -#endif /* tc_headers_hook */ - -#else - -char *md_atof(); -int md_estimate_size_before_relax(); -int md_parse_option(); -long md_pcrel_from(); -long md_section_align(); -short tc_coff_fix2rtype(); -symbolS *md_undefined_symbol(); -void md_apply_fix(); -void md_assemble(); -void md_begin(); -void md_convert_frag(); -void md_create_long_jump(); -void md_create_short_jump(); -void md_end(); -void md_number_to_chars(); -void md_operand(); -void md_ri_to_chars(); - -#ifndef tc_headers_hook -void tc_headers_hook(); -#endif /* tc_headers_hook */ - -#ifndef tc_crawl_symbol_chain -void tc_crawl_symbol_chain(); -#endif /* tc_crawl_symbol_chain */ - -#endif /* __STDC_ */ - -/* - * Local Variables: - * comment-column: 0 - * fill-column: 131 - * End: - */ - -/* end of tp.h */ diff --git a/gas/testscripts/doboth b/gas/testscripts/doboth deleted file mode 100755 index a8c33580bb0..00000000000 --- a/gas/testscripts/doboth +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh -# $Id$ - -x=$1 ; shift -y=$1 ; shift - -rm tmp.0 > /dev/null 2>&1 -ln -s $x tmp.0 -$* tmp.0 > tmp.1 - -rm tmp.0 -ln -s $y tmp.0 -$* tmp.0 > tmp.2 - -rm tmp.0 - -diff -c tmp.1 tmp.2 -exit - -#eof diff --git a/gas/testscripts/doobjcmp b/gas/testscripts/doobjcmp deleted file mode 100755 index 9fbe46b13f8..00000000000 --- a/gas/testscripts/doobjcmp +++ /dev/null @@ -1,89 +0,0 @@ -#!/bin/sh -# $Id$ -# compare two object files, in depth. - -x=$1 -y=$2 -BOTH="$1 $2" - - -# if they cmp, we're fine. -if (cmp $BOTH > /dev/null) -then - exit 0 -fi - -# otherwise, we must look closer. -if (doboth $BOTH size) -then - echo Sizes ok. -else - echo Sizes differ: - size $BOTH -# exit 1 -fi - -if (doboth $BOTH objdump +header) -then - echo Headers ok. -else - echo Header differences. -# exit 1 -fi - -if (doboth $BOTH objdump +text > /dev/null) -then - echo Text ok. -else - echo Text differences. -# doboth $BOTH objdump +text -# exit 1 -fi - -if (doboth $BOTH objdump +data > /dev/null) -then - echo Data ok. -else - echo Data differences. -# doboth $BOTH objdump +data -# exit 1 -fi - -if (doboth $BOTH objdump +symbols > /dev/null) -then - echo Symbols ok. -else - echo -n Symbol differences... - - if (doboth $BOTH dounsortsymbols) - then - echo but symbols are simply ordered differently. -# echo Now what to do about relocs'?' -# exit 1 - else - echo and symbols differ in content. - exit 1 - fi -fi - -# of course, if there were symbol diffs, then the reloc symbol indexes -# will be off. - -if (doboth $BOTH objdump -r > /dev/null) -then - echo Reloc ok. -else - echo -n Reloc differences... - - if (doboth $BOTH dounsortreloc) - then - echo but relocs are simply ordered differently. - else - echo and relocs differ in content. - exit 1 - fi -fi - -exit - -# eof diff --git a/gas/testscripts/dostriptest b/gas/testscripts/dostriptest deleted file mode 100755 index 4b89df8d2d5..00000000000 --- a/gas/testscripts/dostriptest +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh -# $Id$ - -x=striptest.xx.$$ -y=striptest.yy.$$ - -cp $1 $x -strip $x -cp $2 $y -strip $y - -doobjcmp $x $y -exit - -#eof diff --git a/gas/testscripts/dotest b/gas/testscripts/dotest deleted file mode 100755 index 8c7a28c6871..00000000000 --- a/gas/testscripts/dotest +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/sh -# ad hoc debug tool -# $Id$ - -x=$1 -y=$2 - -xout=`basename $x`.xxx.$$ -yout=`basename $x`.yyy.$$ - -mkdir $xout -mkdir $yout - -for i in *.s -do - echo Testing $i... - object=`basename $i .s`.o - $x $i -o $xout/$object - $y $i -o $yout/$object - -# if they cmp, we're ok. Otherwise we have to look closer. - - if (cmp $xout/$object $yout/$object) - then - echo $i is ok. - else - if (doobjcmp $xout/$object $yout/$object) - then - echo Not the same but objcmp ok. - else - exit 1 - fi - fi - - echo -done - -rm -rf $xout $yout - -exit 0 - -# EOF - - diff --git a/gas/testscripts/dounsortreloc b/gas/testscripts/dounsortreloc deleted file mode 100755 index d8da0a9d635..00000000000 --- a/gas/testscripts/dounsortreloc +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -# $Id$ -# objdump the reloc table, but strip off the headings and reloc -# numbers and sort the result. Intended for use in comparing reloc -# tables that may not be in the same order. - -objdump +reloc +omit-relocation-numbers +omit-symbol-numbers $1 \ - | sort -#eof diff --git a/gas/testscripts/dounsortsymbols b/gas/testscripts/dounsortsymbols deleted file mode 100755 index 8fb6db3f879..00000000000 --- a/gas/testscripts/dounsortsymbols +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -# $Id$ -# objdump the symbol table, but strip off the headings and symbol -# numbers and sort the result. Intended for use in comparing symbol -# tables that may not be in the same order. - -objdump +symbols +omit-symbol-numbers $1 \ - | sort -#eof diff --git a/gas/ver960.c b/gas/ver960.c deleted file mode 100644 index fee900043bf..00000000000 --- a/gas/ver960.c +++ /dev/null @@ -1 +0,0 @@ -char gas960_ver[]= "gas960 1.2, Fri Nov 30 03:01:56 PST 1990"; diff --git a/gas/version.c b/gas/version.c deleted file mode 100644 index 1e6f8531816..00000000000 --- a/gas/version.c +++ /dev/null @@ -1,23 +0,0 @@ -#if defined(__STDC__) || defined(const) -const -#endif -char version_string[] = "GNU assembler version 1.90.1 (Cygnus Support pre-release)\n"; - -/* DO NOT PUT COMMENTS ABOUT CHANGES IN THIS FILE. - - This file exists only to define `version_string'. - - Log changes in ChangeLog. The easiest way to do this is with - the Emacs command `add-change-log-entry'. If you don't use Emacs, - add entries of the form: - -Thu Jan 1 00:00:00 1970 Dennis Ritchie (dmr at alice) - - * universe.c (temporal_reality): Began Time. -*/ - -#ifdef VMS -dummy3() -{ -} -#endif diff --git a/gas/write.c b/gas/write.c deleted file mode 100644 index 7dce445d8f6..00000000000 --- a/gas/write.c +++ /dev/null @@ -1,1220 +0,0 @@ -/* write.c - emit .o file - Copyright (C) 1986, 1987, 1990, 1991 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* static const char rcsid[] = "$Id$"; */ - -/* - - This thing should be set up to do byteordering correctly. But... - - In order to cross-assemble the target machine must have an a.out header - similar to the one in a.out.h on THIS machine. Byteorder doesn't matter, - we take special care of it, but the numbers must be the same SIZE (# of - bytes) and in the same PLACE. If this is not true, you will have some - trouble. - */ - -#include "as.h" - -#include "subsegs.h" -#include "obstack.h" -#include "output-file.h" - -/* Hook for machine dependent relocation information output routine. - If not defined, the variable is allocated in BSS (Fortran common model). - If some other module defines it, we will see their value. */ - -void (*md_emit_relocations)(); - -/* - * In: length of relocation (or of address) in chars: 1, 2 or 4. - * Out: GNU LD relocation length code: 0, 1, or 2. - */ - -unsigned char -nbytes_r_length [] = { - 42, 0, 1, 42, 2 - }; - - -static struct frag *text_frag_root; -static struct frag *data_frag_root; - -static struct frag *text_last_frag; /* Last frag in segment. */ -static struct frag *data_last_frag; /* Last frag in segment. */ - -static object_headers headers; - -long string_byte_count; - -static char *the_object_file; - -char *next_object_file_charP; /* Tracks object file bytes. */ - -int magic_number_for_object_file = DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE; - -/* static long length; JF unused */ /* String length, including trailing '\0'. */ - - -#ifdef __STDC__ - -static int is_dnrange(struct frag *f1, struct frag *f2); -static long fixup_segment(fixS *fixP, segT this_segment_type); -static relax_addressT relax_align(relax_addressT address, long alignment); -static void relax_segment(struct frag *segment_frag_root, segT segment_type); - -#else - -static int is_dnrange(); -static long fixup_segment(); -static relax_addressT relax_align(); -static void relax_segment(); - -#endif /* __STDC__ */ - -/* - * fix_new() - * - * Create a fixS in obstack 'notes'. - */ -fixS *fix_new(frag, where, size, add_symbol, sub_symbol, offset, pcrel, r_type) -fragS *frag; /* Which frag? */ -int where; /* Where in that frag? */ -short int size; /* 1, 2 or 4 usually. */ -symbolS *add_symbol; /* X_add_symbol. */ -symbolS *sub_symbol; /* X_subtract_symbol. */ -long offset; /* X_add_number. */ -int pcrel; /* TRUE if PC-relative relocation. */ -enum reloc_type r_type; /* Relocation type */ -{ - register fixS * fixP; - - fixP = (fixS *)obstack_alloc(¬es,sizeof(fixS)); - - fixP->fx_frag = frag; - fixP->fx_where = where; - fixP->fx_size = size; - fixP->fx_addsy = add_symbol; - fixP->fx_subsy = sub_symbol; - fixP->fx_offset = offset; - fixP->fx_pcrel = pcrel; - fixP->fx_r_type = r_type; - - /* JF these 'cuz of the NS32K stuff */ - fixP->fx_im_disp = 0; - fixP->fx_pcrel_adjust = 0; - fixP->fx_bsr = 0; - fixP->fx_bit_fixP = 0; - - /* usually, we want relocs sorted numerically, but while - comparing to older versions of gas that have relocs - reverse sorted, it is convenient to have this compile - time option. xoxorich. */ - -#ifdef REVERSE_SORT_RELOCS - - fixP->fx_next = *seg_fix_rootP; - *seg_fix_rootP = fixP; - -#else /* REVERSE_SORT_RELOCS */ - - fixP->fx_next = NULL; - - if (*seg_fix_tailP) - (*seg_fix_tailP)->fx_next = fixP; - else - *seg_fix_rootP = fixP; - *seg_fix_tailP = fixP; - -#endif /* REVERSE_SORT_RELOCS */ - - fixP->fx_callj = 0; - return fixP; -} - -void write_object_file() { - register struct frchain * frchainP; /* Track along all frchains. */ - register fragS * fragP; /* Track along all frags. */ - register struct frchain * next_frchainP; - register fragS * * prev_fragPP; -/* register char * name; */ -/* symbolS *symbolP; */ -/* register symbolS ** symbolPP; */ - /* register fixS * fixP; JF unused */ - unsigned int data_siz; - -#ifdef DONTDEF - void gdb_emit(); - void gdb_end(); -#endif - long object_file_size; - -#ifdef VMS - /* - * Under VMS we try to be compatible with VAX-11 "C". Thus, we - * call a routine to check for the definition of the procedure - * "_main", and if so -- fix it up so that it can be program - * entry point. - */ - VMS_Check_For_Main(); -#endif /* VMS */ - /* - * After every sub-segment, we fake an ".align ...". This conforms to BSD4.2 - * brane-damage. We then fake ".fill 0" because that is the kind of frag - * that requires least thought. ".align" frags like to have a following - * frag since that makes calculating their intended length trivial. - */ -#define SUB_SEGMENT_ALIGN (2) - for (frchainP = frchain_root; frchainP; frchainP = frchainP->frch_next) { -#ifdef VMS - /* - * Under VAX/VMS, the linker (and PSECT specifications) - * take care of correctly aligning the segments. - * Doing the alignment here (on initialized data) can - * mess up the calculation of global data PSECT sizes. - */ -#undef SUB_SEGMENT_ALIGN -#define SUB_SEGMENT_ALIGN ((frchainP->frch_seg != SEG_DATA) ? 2 : 0) -#endif /* VMS */ - subseg_new (frchainP->frch_seg, frchainP->frch_subseg); - frag_align (SUB_SEGMENT_ALIGN, 0); - /* frag_align will have left a new frag. */ - /* Use this last frag for an empty ".fill". */ - /* - * For this segment ... - * Create a last frag. Do not leave a "being filled in frag". - */ - frag_wane (frag_now); - frag_now->fr_fix = 0; - know( frag_now->fr_next == NULL ); - /* know( frags . obstack_c_base == frags . obstack_c_next_free ); */ - /* Above shows we haven't left a half-completed object on obstack. */ - } /* walk the frag chain */ - - /* - * From now on, we don't care about sub-segments. - * Build one frag chain for each segment. Linked thru fr_next. - * We know that there is at least 1 text frchain & at least 1 data frchain. - */ - prev_fragPP = &text_frag_root; - for (frchainP = frchain_root; frchainP; frchainP = next_frchainP) { - know( frchainP->frch_root ); - * prev_fragPP = frchainP->frch_root; - prev_fragPP = & frchainP->frch_last->fr_next; - - if (((next_frchainP = frchainP->frch_next) == NULL) - || next_frchainP == data0_frchainP) { - prev_fragPP = & data_frag_root; - if (next_frchainP) { - text_last_frag = frchainP->frch_last; - } else { - data_last_frag = frchainP->frch_last; - } - } - } /* walk the frag chain */ - - /* - * We have two segments. If user gave -R flag, then we must put the - * data frags into the text segment. Do this before relaxing so - * we know to take advantage of -R and make shorter addresses. - */ - if (flagseen[ 'R' ]) { - fixS *tmp; - - text_last_frag->fr_next = data_frag_root; - text_last_frag = data_last_frag; - data_last_frag = NULL; - data_frag_root = NULL; - if (text_fix_root) { - for (tmp = text_fix_root; tmp->fx_next; tmp = tmp->fx_next) ;; - tmp->fx_next=data_fix_root; - } else - text_fix_root=data_fix_root; - data_fix_root=NULL; - } - - relax_segment(text_frag_root, SEG_TEXT); - relax_segment(data_frag_root, SEG_DATA); - /* - * Now the addresses of frags are correct within the segment. - */ - - know(text_last_frag->fr_type == rs_fill && text_last_frag->fr_offset == 0); - H_SET_TEXT_SIZE(&headers, text_last_frag->fr_address); - text_last_frag->fr_address = H_GET_TEXT_SIZE(&headers); - - /* - * Join the 2 segments into 1 huge segment. - * To do this, re-compute every rn_address in the SEG_DATA frags. - * Then join the data frags after the text frags. - * - * Determine a_data [length of data segment]. - */ - if (data_frag_root) { - register relax_addressT slide; - - know((text_last_frag->fr_type == rs_fill) - && (text_last_frag->fr_offset == 0)); - - H_SET_DATA_SIZE(&headers, data_last_frag->fr_address); - data_last_frag->fr_address = H_GET_DATA_SIZE(&headers); - slide = H_GET_TEXT_SIZE(&headers); /* & in file of the data segment. */ - - for (fragP = data_frag_root; fragP; fragP = fragP->fr_next) { - fragP->fr_address += slide; - } /* for each data frag */ - - know(text_last_frag != 0); - text_last_frag->fr_next = data_frag_root; - } else { - H_SET_DATA_SIZE(&headers,0); - data_siz = 0; - } - - bss_address_frag.fr_address = H_GET_TEXT_SIZE(&headers) + - H_GET_DATA_SIZE(&headers); - - H_SET_BSS_SIZE(&headers,local_bss_counter); - - /* - * - * Crawl the symbol chain. - * - * For each symbol whose value depends on a frag, take the address of - * that frag and subsume it into the value of the symbol. - * After this, there is just one way to lookup a symbol value. - * Values are left in their final state for object file emission. - * We adjust the values of 'L' local symbols, even if we do - * not intend to emit them to the object file, because their values - * are needed for fix-ups. - * - * Unless we saw a -L flag, remove all symbols that begin with 'L' - * from the symbol chain. (They are still pointed to by the fixes.) - * - * Count the remaining symbols. - * Assign a symbol number to each symbol. - * Count the number of string-table chars we will emit. - * Put this info into the headers as appropriate. - * - */ - know(zero_address_frag.fr_address == 0); - string_byte_count = sizeof(string_byte_count); - - obj_crawl_symbol_chain(&headers); - - if (string_byte_count == sizeof(string_byte_count)) { - string_byte_count = 0; - } /* if no strings, then no count. */ - - H_SET_STRING_SIZE(&headers, string_byte_count); - - /* - * Addresses of frags now reflect addresses we use in the object file. - * Symbol values are correct. - * Scan the frags, converting any ".org"s and ".align"s to ".fill"s. - * Also converting any machine-dependent frags using md_convert_frag(); - */ - subseg_change(SEG_TEXT, 0); - - for (fragP = text_frag_root; fragP; fragP = fragP->fr_next) { - switch (fragP->fr_type) { - case rs_align: - case rs_org: - fragP->fr_type = rs_fill; - know(fragP->fr_var == 1); - know(fragP->fr_next != NULL); - - fragP->fr_offset = (fragP->fr_next->fr_address - - fragP->fr_address - - fragP->fr_fix); - break; - - case rs_fill: - break; - - case rs_machine_dependent: - md_convert_frag(&headers, fragP); - /* - * After md_convert_frag, we make the frag into a ".space 0". - * Md_convert_frag() should set up any fixSs and constants - * required. - */ - frag_wane(fragP); - break; - -#ifndef WORKING_DOT_WORD - case rs_broken_word: { - struct broken_word *lie; - extern md_short_jump_size; - extern md_long_jump_size; - - if (fragP->fr_subtype) { - fragP->fr_fix+=md_short_jump_size; - for (lie=(struct broken_word *)(fragP->fr_symbol);lie && lie->dispfrag==fragP;lie=lie->next_broken_word) - if (lie->added==1) - fragP->fr_fix+=md_long_jump_size; - } - frag_wane(fragP); - } - break; -#endif - - default: - BAD_CASE( fragP->fr_type ); - break; - } /* switch (fr_type) */ - } /* for each frag. */ - -#ifndef WORKING_DOT_WORD - { - struct broken_word *lie; - struct broken_word **prevP; - - prevP= &broken_words; - for (lie=broken_words; lie; lie=lie->next_broken_word) - if (!lie->added) { -#ifdef TC_NS32K - fix_new_ns32k(lie->frag, - lie->word_goes_here - lie->frag->fr_literal, - 2, - lie->add, - lie->sub, - lie->addnum, - 0, 0, 2, 0, 0); -#else /* TC_NS32K */ - fix_new( lie->frag, lie->word_goes_here - lie->frag->fr_literal, - 2, lie->add, - lie->sub, lie->addnum, - 0, NO_RELOC); -#endif /* TC_NS32K */ - /* md_number_to_chars(lie->word_goes_here, - S_GET_VALUE(lie->add) - + lie->addnum - - S_GET_VALUE(lie->sub), - 2); */ - *prevP=lie->next_broken_word; - } else - prevP= &(lie->next_broken_word); - - for (lie=broken_words;lie;) { - struct broken_word *untruth; - char *table_ptr; - long table_addr; - long from_addr, - to_addr; - int n, - m; - - extern md_short_jump_size; - extern md_long_jump_size; - - fragP=lie->dispfrag; - - /* Find out how many broken_words go here */ - n=0; - for (untruth=lie;untruth && untruth->dispfrag==fragP;untruth=untruth->next_broken_word) - if (untruth->added==1) - n++; - - table_ptr=lie->dispfrag->fr_opcode; - table_addr=lie->dispfrag->fr_address+(table_ptr - lie->dispfrag->fr_literal); - /* Create the jump around the long jumps */ - /* This is a short jump from table_ptr+0 to table_ptr+n*long_jump_size */ - from_addr=table_addr; - to_addr = table_addr + md_short_jump_size + n * md_long_jump_size; - md_create_short_jump(table_ptr, from_addr, to_addr, lie->dispfrag, lie->add); - table_ptr+=md_short_jump_size; - table_addr+=md_short_jump_size; - - for (m=0;lie && lie->dispfrag==fragP;m++,lie=lie->next_broken_word) { - if (lie->added==2) - continue; - /* Patch the jump table */ - /* This is the offset from ??? to table_ptr+0 */ - to_addr = table_addr - - S_GET_VALUE(lie->sub); - md_number_to_chars(lie->word_goes_here,to_addr,2); - for (untruth=lie->next_broken_word;untruth && untruth->dispfrag==fragP;untruth=untruth->next_broken_word) { - if (untruth->use_jump==lie) - md_number_to_chars(untruth->word_goes_here,to_addr,2); - } - - /* Install the long jump */ - /* this is a long jump from table_ptr+0 to the final target */ - from_addr=table_addr; - to_addr=S_GET_VALUE(lie->add) + lie->addnum; - md_create_long_jump(table_ptr,from_addr,to_addr,lie->dispfrag,lie->add); - table_ptr+=md_long_jump_size; - table_addr+=md_long_jump_size; - } - } - } -#endif /* not WORKING_DOT_WORD */ - -#ifndef VMS - { /* not vms */ - /* - * Scan every FixS performing fixups. We had to wait until now to do - * this because md_convert_frag() may have made some fixSs. - */ - H_SET_RELOCATION_SIZE(&headers, - md_reloc_size * fixup_segment(text_fix_root, SEG_TEXT), - md_reloc_size * fixup_segment(data_fix_root, SEG_DATA)); - - /* FIXME move this stuff into the pre-write-hook */ - H_SET_MAGIC_NUMBER(&headers, magic_number_for_object_file); - H_SET_ENTRY_POINT(&headers, 0); - -#ifdef EXEC_MACHINE_TYPE - H_SET_MACHINE_TYPE(&headers, EXEC_MACHINE_TYPE); -#endif -#ifdef EXEC_VERSION - H_SET_VERSION(&headers, EXEC_VERSION); -#endif - - obj_pre_write_hook(&headers); /* extra coff stuff */ - - if ((had_warnings() && flagseen['Z']) - || had_errors() > 0) { - if (flagseen['Z']) { - as_warn("%d error%s, %d warning%s, generating bad object file.\n", - had_errors(), had_errors() == 1 ? "" : "s", - had_warnings(), had_warnings() == 1 ? "" : "s"); - } else { - as_fatal("%d error%s, %d warning%s, no object file generated.\n", - had_errors(), had_errors() == 1 ? "" : "s", - had_warnings(), had_warnings() == 1 ? "" : "s"); - } /* on want output */ - } /* on error condition */ - - object_file_size = H_GET_FILE_SIZE(&headers); - next_object_file_charP = the_object_file = xmalloc(object_file_size); - - output_file_create(out_file_name); - - obj_header_append(&next_object_file_charP, &headers); - know((next_object_file_charP - the_object_file) == H_GET_HEADER_SIZE(&headers)); - - /* - * Emit code. - */ - for (fragP = text_frag_root; fragP; fragP = fragP->fr_next) { - register long count; - register char *fill_literal; - register long fill_size; - - know(fragP->fr_type == rs_fill); - append(&next_object_file_charP, fragP->fr_literal, (unsigned long) fragP->fr_fix); - fill_literal = fragP->fr_literal + fragP->fr_fix; - fill_size = fragP->fr_var; - know(fragP->fr_offset >= 0); - - for (count = fragP->fr_offset; count; count--) { - append(&next_object_file_charP, fill_literal, (unsigned long) fill_size); - } /* for each */ - - } /* for each code frag. */ - - know((next_object_file_charP - the_object_file) - == (H_GET_HEADER_SIZE(&headers) - + H_GET_TEXT_SIZE(&headers) - + H_GET_DATA_SIZE(&headers))); - - /* - * Emit relocations. - */ - obj_emit_relocations(&next_object_file_charP, text_fix_root, (relax_addressT)0); - know((next_object_file_charP - the_object_file) - == (H_GET_HEADER_SIZE(&headers) - + H_GET_TEXT_SIZE(&headers) - + H_GET_DATA_SIZE(&headers) - + H_GET_TEXT_RELOCATION_SIZE(&headers))); -#ifdef TC_I960 - /* Make addresses in data relocation directives relative to beginning of - * first data fragment, not end of last text fragment: alignment of the - * start of the data segment may place a gap between the segments. - */ - obj_emit_relocations(&next_object_file_charP, data_fix_root, data0_frchainP->frch_root->fr_address); -#else /* TC_I960 */ - obj_emit_relocations(&next_object_file_charP, data_fix_root, text_last_frag->fr_address); -#endif /* TC_I960 */ - - know((next_object_file_charP - the_object_file) - == (H_GET_HEADER_SIZE(&headers) - + H_GET_TEXT_SIZE(&headers) - + H_GET_DATA_SIZE(&headers) - + H_GET_TEXT_RELOCATION_SIZE(&headers) - + H_GET_DATA_RELOCATION_SIZE(&headers))); - - /* - * Emit line number entries. - */ - OBJ_EMIT_LINENO(&next_object_file_charP, lineno_rootP, the_object_file); - know((next_object_file_charP - the_object_file) - == (H_GET_HEADER_SIZE(&headers) - + H_GET_TEXT_SIZE(&headers) - + H_GET_DATA_SIZE(&headers) - + H_GET_TEXT_RELOCATION_SIZE(&headers) - + H_GET_DATA_RELOCATION_SIZE(&headers) - + H_GET_LINENO_SIZE(&headers))); - - /* - * Emit symbols. - */ - obj_emit_symbols(&next_object_file_charP, symbol_rootP); - know((next_object_file_charP - the_object_file) - == (H_GET_HEADER_SIZE(&headers) - + H_GET_TEXT_SIZE(&headers) - + H_GET_DATA_SIZE(&headers) - + H_GET_TEXT_RELOCATION_SIZE(&headers) - + H_GET_DATA_RELOCATION_SIZE(&headers) - + H_GET_LINENO_SIZE(&headers) - + H_GET_SYMBOL_TABLE_SIZE(&headers))); - - /* - * Emit strings. - */ - - if (string_byte_count > 0) { - obj_emit_strings(&next_object_file_charP); - } /* only if we have a string table */ - - know((next_object_file_charP - the_object_file) - == (H_GET_HEADER_SIZE(&headers) - + H_GET_TEXT_SIZE(&headers) - + H_GET_DATA_SIZE(&headers) - + H_GET_TEXT_RELOCATION_SIZE(&headers) - + H_GET_DATA_RELOCATION_SIZE(&headers) - + H_GET_LINENO_SIZE(&headers) - + H_GET_SYMBOL_TABLE_SIZE(&headers) - + H_GET_STRING_SIZE(&headers))); - - know(next_object_file_charP == the_object_file + object_file_size); - /* Write the data to the file */ - output_file_append(the_object_file,object_file_size,out_file_name); - -#ifdef DONTDEF - if (flagseen['G']) /* GDB symbol file to be appended? */ - { - gdb_emit (out_file_name); - gdb_end (); - } -#endif /* DONTDEF */ - - output_file_close(out_file_name); - } /* non vms output */ -#else /* VMS */ - /* - * Now do the VMS-dependent part of writing the object file - */ - VMS_write_object_file(text_siz, data_siz, text_frag_root, data_frag_root); -#endif /* VMS */ -} /* write_object_file() */ - -/* - * relax_segment() - * - * Now we have a segment, not a crowd of sub-segments, we can make fr_address - * values. - * - * Relax the frags. - * - * After this, all frags in this segment have addresses that are correct - * within the segment. Since segments live in different file addresses, - * these frag addresses may not be the same as final object-file addresses. - */ -#ifndef VMS -static -#endif /* not VMS */ -void relax_segment(segment_frag_root, segment) - struct frag * segment_frag_root; - segT segment; /* SEG_DATA or SEG_TEXT */ -{ - register struct frag * fragP; - register relax_addressT address; - /* register relax_addressT old_address; JF unused */ - /* register relax_addressT new_address; JF unused */ - - know( segment == SEG_DATA || segment == SEG_TEXT ); - - /* In case md_estimate_size_before_relax() wants to make fixSs. */ - subseg_change(segment, 0); - - /* - * For each frag in segment: count and store (a 1st guess of) fr_address. - */ - address = 0; - for (fragP = segment_frag_root; fragP; fragP = fragP->fr_next) { - fragP->fr_address = address; - address += fragP->fr_fix; - - switch (fragP->fr_type) { - case rs_fill: - address += fragP->fr_offset * fragP->fr_var; - break; - - case rs_align: - address += relax_align(address, fragP->fr_offset); - break; - - case rs_org: - /* - * Assume .org is nugatory. It will grow with 1st relax. - */ - break; - - case rs_machine_dependent: - address += md_estimate_size_before_relax(fragP, segment); - break; - -#ifndef WORKING_DOT_WORD - /* Broken words don't concern us yet */ - case rs_broken_word: - break; -#endif - - default: - BAD_CASE(fragP->fr_type); - break; - } /* switch(fr_type) */ - } /* for each frag in the segment */ - - /* - * Do relax(). - */ - { - register long stretch; /* May be any size, 0 or negative. */ - /* Cumulative number of addresses we have */ - /* relaxed this pass. */ - /* We may have relaxed more than one address. */ - register long stretched; /* Have we stretched on this pass? */ - /* This is 'cuz stretch may be zero, when, - in fact some piece of code grew, and - another shrank. If a branch instruction - doesn't fit anymore, we could be scrod */ - - do { - stretch = stretched = 0; - for (fragP = segment_frag_root; fragP; fragP = fragP->fr_next) { - register long growth = 0; - register unsigned long was_address; - /* register long var; */ - register long offset; - register symbolS *symbolP; - register long target; - register long after; - register long aim; - - was_address = fragP->fr_address; - address = fragP->fr_address += stretch; - symbolP = fragP->fr_symbol; - offset = fragP->fr_offset; - /* var = fragP->fr_var; */ - - switch (fragP->fr_type) { - case rs_fill: /* .fill never relaxes. */ - growth = 0; - break; - -#ifndef WORKING_DOT_WORD - /* JF: This is RMS's idea. I do *NOT* want to be blamed - for it I do not want to write it. I do not want to have - anything to do with it. This is not the proper way to - implement this misfeature. */ - case rs_broken_word: { - struct broken_word *lie; - struct broken_word *untruth; - extern int md_short_jump_size; - extern int md_long_jump_size; - - /* Yes this is ugly (storing the broken_word pointer - in the symbol slot). Still, this whole chunk of - code is ugly, and I don't feel like doing anything - about it. Think of it as stubbornness in action */ - growth=0; - for (lie=(struct broken_word *)(fragP->fr_symbol); - lie && lie->dispfrag==fragP; - lie=lie->next_broken_word) { - - if (lie->added) - continue; - - offset= lie->add->sy_frag->fr_address+ S_GET_VALUE(lie->add) + lie->addnum - - (lie->sub->sy_frag->fr_address+ S_GET_VALUE(lie->sub)); - if (offset<=-32768 || offset>=32767) { - if (flagseen['k']) - as_warn(".word %s-%s+%ld didn't fit", - S_GET_NAME(lie->add), - S_GET_NAME(lie->sub), - lie->addnum); - lie->added=1; - if (fragP->fr_subtype==0) { - fragP->fr_subtype++; - growth+=md_short_jump_size; - } - for (untruth=lie->next_broken_word;untruth && untruth->dispfrag==lie->dispfrag;untruth=untruth->next_broken_word) - if ((untruth->add->sy_frag == lie->add->sy_frag) - && S_GET_VALUE(untruth->add) == S_GET_VALUE(lie->add)) { - untruth->added=2; - untruth->use_jump=lie; - } - growth+=md_long_jump_size; - } - } - - break; - } /* case rs_broken_word */ -#endif - case rs_align: - growth = relax_align((relax_addressT) (address + fragP->fr_fix), offset) - - relax_align((relax_addressT) (was_address + fragP->fr_fix), offset); - break; - - case rs_org: - target = offset; - - if (symbolP) { - know((S_GET_SEGMENT(symbolP) == SEG_ABSOLUTE) - || (S_GET_SEGMENT(symbolP) == SEG_DATA) - || (S_GET_SEGMENT(symbolP) == SEG_TEXT)); - know(symbolP->sy_frag); - know(!(S_GET_SEGMENT(symbolP) == SEG_ABSOLUTE) - || (symbolP->sy_frag == &zero_address_frag)); - target += S_GET_VALUE(symbolP) - + symbolP->sy_frag->fr_address; - } /* if we have a symbol */ - - know(fragP->fr_next); - after = fragP->fr_next->fr_address; - growth = ((target - after ) > 0) ? (target - after) : 0; - /* Growth may be -ve, but variable part */ - /* of frag cannot have < 0 chars. */ - /* That is, we can't .org backwards. */ - - growth -= stretch; /* This is an absolute growth factor */ - break; - - case rs_machine_dependent: { - register const relax_typeS * this_type; - register const relax_typeS * start_type; - register relax_substateT next_state; - register relax_substateT this_state; - - start_type = this_type = md_relax_table + (this_state = fragP->fr_subtype); - target = offset; - - if (symbolP) { - know((S_GET_SEGMENT(symbolP) == SEG_ABSOLUTE) || - (S_GET_SEGMENT(symbolP) == SEG_DATA) || - (S_GET_SEGMENT(symbolP) == SEG_TEXT)); - know(symbolP->sy_frag); - know(!(S_GET_SEGMENT(symbolP) == SEG_ABSOLUTE) || - symbolP->sy_frag==&zero_address_frag ); - target += - S_GET_VALUE(symbolP) - + symbolP->sy_frag->fr_address; - - /* If frag has yet to be reached on this pass, - assume it will move by STRETCH just as we did. - If this is not so, it will be because some frag - between grows, and that will force another pass. */ - - /* JF was just address */ - /* JF also added is_dnrange hack */ - /* There's gotta be a better/faster/etc way - to do this. . . */ - /* gnu@cygnus.com: I changed this from > to >= - because I ran into a zero-length frag (fr_fix=0) - which was created when the obstack needed a new - chunk JUST AFTER the opcode of a branch. Since - fr_fix is zero, fr_address of this frag is the same - as fr_address of the next frag. This - zero-length frag was variable and jumped to .+2 - (in the next frag), but since the > comparison - below failed (the two were =, not >), "stretch" - was not added to the target. Stretch was 178, so - the offset appeared to be .-176 instead, which did - not fit into a byte branch, so the assembler - relaxed the branch to a word. This didn't compare - with what happened when the same source file was - assembled on other machines, which is how I found it. - You might want to think about what other places have - trouble with zero length frags... */ - - if (symbolP->sy_frag->fr_address >= was_address - && is_dnrange(fragP,symbolP->sy_frag)) { - target += stretch; - } /* */ - - } /* if there's a symbol attached */ - - aim = target - address - fragP->fr_fix; - /* The displacement is affected by the instruction size - * for the 32k architecture. I think we ought to be able - * to add fragP->fr_pcrel_adjust in all cases (it should be - * zero if not used), but just in case it breaks something - * else we'll put this inside #ifdef NS32K ... #endif - */ -#ifdef TC_NS32K - aim += fragP->fr_pcrel_adjust; -#endif /* TC_NS32K */ - - if (aim < 0) { - /* Look backwards. */ - for (next_state = this_type->rlx_more; next_state; ) { - if (aim >= this_type->rlx_backward) { - next_state = 0; - } else { /* Grow to next state. */ - this_type = md_relax_table + (this_state = next_state); - next_state = this_type->rlx_more; - } - } - } else { -#ifdef DONTDEF - /* JF these next few lines of code are for the mc68020 which can't handle short - offsets of zero in branch instructions. What a kludge! */ - if (aim==0 && this_state==(1<<2+0)) { /* FOO hard encoded from m.c */ - aim=this_type->rlx_forward+1; /* Force relaxation into word mode */ - } -#endif - /* JF end of 68020 code */ - /* Look forwards. */ - for (next_state = this_type->rlx_more; next_state; ) { - if (aim <= this_type->rlx_forward) { - next_state = 0; - } else { /* Grow to next state. */ - this_type = md_relax_table + (this_state = next_state); - next_state = this_type->rlx_more; - } - } - } - - if ((growth = this_type->rlx_length - start_type->rlx_length) != 0) - fragP->fr_subtype = this_state; - - break; - } /* case rs_machine_dependent */ - - default: - BAD_CASE( fragP->fr_type ); - break; - } - if (growth) { - stretch += growth; - stretched++; - } - } /* For each frag in the segment. */ - } while (stretched); /* Until nothing further to relax. */ - } /* do_relax */ - - /* - * We now have valid fr_address'es for each frag. - */ - - /* - * All fr_address's are correct, relative to their own segment. - * We have made all the fixS we will ever make. - */ -} /* relax_segment() */ - -/* - * Relax_align. Advance location counter to next address that has 'alignment' - * lowest order bits all 0s. - */ - - /* How many addresses does the .align take? */ -static relax_addressT relax_align(address, alignment) -register relax_addressT address; /* Address now. */ -register long alignment; /* Alignment (binary). */ -{ - relax_addressT mask; - relax_addressT new_address; - - mask = ~ ( (~0) << alignment ); - new_address = (address + mask) & (~ mask); - return (new_address - address); -} /* relax_align() */ - -/* fixup_segment() - - Go through all the fixS's in a segment and see which ones can be - handled now. (These consist of fixS where we have since discovered - the value of a symbol, or the address of the frag involved.) - For each one, call md_apply_fix to put the fix into the frag data. - - Result is a count of how many relocation structs will be needed to - handle the remaining fixS's that we couldn't completely handle here. - These will be output later by emit_relocations(). */ - -static long fixup_segment(fixP, this_segment_type) -register fixS * fixP; -segT this_segment_type; /* N_TYPE bits for segment. */ -{ - register long seg_reloc_count; - register symbolS *add_symbolP; - register symbolS *sub_symbolP; - register long add_number; - register int size; - register char *place; - register long where; - register char pcrel; - register fragS *fragP; - register segT add_symbol_segment = SEG_ABSOLUTE; - - - seg_reloc_count = 0; - - for ( ; fixP; fixP = fixP->fx_next) { - fragP = fixP->fx_frag; - know(fragP); - where = fixP->fx_where; - place = fragP->fr_literal + where; - size = fixP->fx_size; - add_symbolP = fixP->fx_addsy; -#ifdef TC_I960 - if (fixP->fx_callj && TC_S_IS_CALLNAME(add_symbolP)) { - /* Relocation should be done via the - associated 'bal' entry point - symbol. */ - - if (!TC_S_IS_BALNAME(tc_get_bal_of_call(add_symbolP))) { - as_bad("No 'bal' entry point for leafproc %s", - S_GET_NAME(add_symbolP)); - continue; - } - fixP->fx_addsy = add_symbolP = tc_get_bal_of_call(add_symbolP); - } /* callj relocation */ -#endif - sub_symbolP = fixP->fx_subsy; - add_number = fixP->fx_offset; - pcrel = fixP->fx_pcrel; - - if (add_symbolP) { - add_symbol_segment = S_GET_SEGMENT(add_symbolP); - } /* if there is an addend */ - - if (sub_symbolP) { - if (!add_symbolP) { - /* Its just -sym */ - if (S_GET_SEGMENT(sub_symbolP) != SEG_ABSOLUTE) { - as_bad("Negative of non-absolute symbol %s", S_GET_NAME(sub_symbolP)); - } /* not absolute */ - - add_number -= S_GET_VALUE(sub_symbolP); - - /* if sub_symbol is in the same segment that add_symbol - and add_symbol is either in DATA, TEXT, BSS or ABSOLUTE */ - } else if ((S_GET_SEGMENT(sub_symbolP) == add_symbol_segment) - && ((add_symbol_segment == SEG_DATA) - || (add_symbol_segment == SEG_TEXT) - || (add_symbol_segment == SEG_BSS) - || (add_symbol_segment == SEG_ABSOLUTE))) { - /* Difference of 2 symbols from same segment. */ - /* Can't make difference of 2 undefineds: 'value' means */ - /* something different for N_UNDF. */ -#ifdef TC_I960 - /* Makes no sense to use the difference of 2 arbitrary symbols - * as the target of a call instruction. - */ - if (fixP->fx_callj) { - as_bad("callj to difference of 2 symbols"); - } -#endif /* TC_I960 */ - add_number += S_GET_VALUE(add_symbolP) - - S_GET_VALUE(sub_symbolP); - - add_symbolP = NULL; - fixP->fx_addsy = NULL; - } else { - /* Different segments in subtraction. */ - know(!(S_IS_EXTERNAL(sub_symbolP) && (S_GET_SEGMENT(sub_symbolP) == SEG_ABSOLUTE))); - - if ((S_GET_SEGMENT(sub_symbolP) == SEG_ABSOLUTE)) { - add_number -= S_GET_VALUE(sub_symbolP); - } else { - as_bad("Can't emit reloc {- %s-seg symbol \"%s\"} @ file address %d.", - segment_name(S_GET_SEGMENT(sub_symbolP)), - S_GET_NAME(sub_symbolP), fragP->fr_address + where); - } /* if absolute */ - } - } /* if sub_symbolP */ - - if (add_symbolP) { - if (add_symbol_segment == this_segment_type && pcrel) { - /* - * This fixup was made when the symbol's segment was - * SEG_UNKNOWN, but it is now in the local segment. - * So we know how to do the address without relocation. - */ -#ifdef TC_I960 - /* reloc_callj() may replace a 'call' with a 'calls' or a 'bal', - * in which cases it modifies *fixP as appropriate. In the case - * of a 'calls', no further work is required, and *fixP has been - * set up to make the rest of the code below a no-op. - */ - reloc_callj(fixP); -#endif /* TC_I960 */ - - add_number += S_GET_VALUE(add_symbolP); - add_number -= md_pcrel_from (fixP); - pcrel = 0; /* Lie. Don't want further pcrel processing. */ - fixP->fx_addsy = NULL; /* No relocations please. */ - } else { - switch (add_symbol_segment) { - case SEG_ABSOLUTE: -#ifdef TC_I960 - reloc_callj(fixP); /* See comment about reloc_callj() above*/ -#endif /* TC_I960 */ - add_number += S_GET_VALUE(add_symbolP); - fixP->fx_addsy = NULL; - add_symbolP = NULL; - break; - - case SEG_BSS: - case SEG_DATA: - case SEG_TEXT: - seg_reloc_count ++; - add_number += S_GET_VALUE(add_symbolP); - break; - - case SEG_UNKNOWN: -#ifdef TC_I960 - if ((int)fixP->fx_bit_fixP == 13) { - /* This is a COBR instruction. They have only a - * 13-bit displacement and are only to be used - * for local branches: flag as error, don't generate - * relocation. - */ - as_bad("can't use COBR format with external label"); - fixP->fx_addsy = NULL; /* No relocations please. */ - continue; - } /* COBR */ -#endif /* TC_I960 */ - /* FIXME-SOON: I think this is trash, but I'm not sure. xoxorich. */ -#ifdef comment -#ifdef OBJ_COFF - if (S_IS_COMMON(add_symbolP)) - add_number += S_GET_VALUE(add_symbolP); -#endif /* OBJ_COFF */ -#endif /* comment */ - - ++seg_reloc_count; - break; - - default: - BAD_CASE(add_symbol_segment); - break; - } /* switch on symbol seg */ - } /* if not in local seg */ - } /* if there was a + symbol */ - - if (pcrel) { - add_number -= md_pcrel_from(fixP); - if (add_symbolP == 0) { - fixP->fx_addsy = & abs_symbol; - ++seg_reloc_count; - } /* if there's an add_symbol */ - } /* if pcrel */ - - if (!fixP->fx_bit_fixP) { - if ((size==1 && - (add_number& ~0xFF) && (add_number&~0xFF!=(-1&~0xFF))) || - (size==2 && - (add_number& ~0xFFFF) && (add_number&~0xFFFF!=(-1&~0xFFFF)))) { - as_bad("Value of %d too large for field of %d bytes at 0x%x", - add_number, size, fragP->fr_address + where); - } /* generic error checking */ - } /* not a bit fix */ - - md_apply_fix(fixP, add_number); - } /* For each fixS in this segment. */ - -#ifdef OBJ_COFF -#ifdef TC_I960 - { - fixS *topP = fixP; - - /* two relocs per callj under coff. */ - for (fixP = topP; fixP; fixP = fixP->fx_next) { - if (fixP->fx_callj && fixP->fx_addsy != 0) { - ++seg_reloc_count; - } /* if callj and not already fixed. */ - } /* for each fix */ - } -#endif /* TC_I960 */ -#endif /* OBJ_COFF */ - return(seg_reloc_count); -} /* fixup_segment() */ - - -static int is_dnrange(f1,f2) -struct frag *f1; -struct frag *f2; -{ - while (f1) { - if (f1->fr_next==f2) - return 1; - f1=f1->fr_next; - } - return 0; -} /* is_dnrange() */ - -/* Append a string onto another string, bumping the pointer along. */ -void -append (charPP, fromP, length) -char **charPP; -char *fromP; -unsigned long length; -{ - if (length) { /* Don't trust bcopy() of 0 chars. */ - bcopy(fromP, *charPP, (int) length); - *charPP += length; - } -} - -int section_alignment[SEG_MAXIMUM_ORDINAL]; - -/* - * This routine records the largest alignment seen for each segment. - * If the beginning of the segment is aligned on the worst-case - * boundary, all of the other alignments within it will work. At - * least one object format really uses this info. - */ -void record_alignment(seg, align) -segT seg; /* Segment to which alignment pertains */ -int align; /* Alignment, as a power of 2 - * (e.g., 1 => 2-byte boundary, 2 => 4-byte boundary, etc.) - */ -{ - - if ( align > section_alignment[(int) seg] ){ - section_alignment[(int) seg] = align; - } /* if highest yet */ - - return; -} /* record_alignment() */ - -/* - * Local Variables: - * comment-column: 0 - * fill-column: 131 - * End: - */ - -/* end of write.c */ diff --git a/gas/write.h b/gas/write.h deleted file mode 100644 index 1eecdc09e1a..00000000000 --- a/gas/write.h +++ /dev/null @@ -1,130 +0,0 @@ -/* write.h -> write.c */ - -/* MODIFIED BY CHRIS BENENATI, FOR INTEL CORPORATION, 4/89 */ -/* write.h -> write.c - Copyright (C) 1987 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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 1, or (at your option) -any later version. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifndef TC_I960 -#ifdef hpux -#define EXEC_MACHINE_TYPE HP9000S200_ID -#endif -#endif /* TC_I960 */ - -#ifndef LOCAL_LABEL -#ifdef DOT_LABEL_PREFIX -#define LOCAL_LABEL(name) (name[0] =='.' \ - && ( name [1] == 'L' || name [1] == '.' )) -#else /* not defined DOT_LABEL_PREFIX */ -#define LOCAL_LABEL(name) (name [0] == 'L' ) -#endif /* not defined DOT_LABEL_PREFIX */ -#endif /* LOCAL_LABEL */ - -#define S_LOCAL_NAME(s) (LOCAL_LABEL(S_GET_NAME(s))) - -/* The bit_fix was implemented to support machines that need variables - to be inserted in bitfields other than 1, 2 and 4 bytes. - Furthermore it gives us a possibillity to mask in bits in the symbol - when it's fixed in the objectcode and check the symbols limits. - - The or-mask is used to set the huffman bits in displacements for the - ns32k port. - The acbi, addqi, movqi, cmpqi instruction requires an assembler that - can handle bitfields. Ie handle an expression, evaluate it and insert - the result in an some bitfield. ( ex: 5 bits in a short field of a opcode) - */ - -struct bit_fix { - int fx_bit_size; /* Length of bitfield */ - int fx_bit_offset; /* Bit offset to bitfield */ - long fx_bit_base; /* Where do we apply the bitfix. - If this is zero, default is assumed. */ - long fx_bit_base_adj;/* Adjustment of base */ - long fx_bit_max; /* Signextended max for bitfield */ - long fx_bit_min; /* Signextended min for bitfield */ - long fx_bit_add; /* Or mask, used for huffman prefix */ -}; -typedef struct bit_fix bit_fixS; -/* - * FixSs may be built up in any order. - */ - -struct fix -{ - fragS * fx_frag; /* Which frag? */ - long fx_where; /* Where is the 1st byte to fix up? */ - symbolS * fx_addsy; /* NULL or Symbol whose value we add in. */ - symbolS * fx_subsy; /* NULL or Symbol whose value we subtract. */ - long fx_offset; /* Absolute number we add in. */ - struct fix * fx_next; /* NULL or -> next fixS. */ - short int fx_size; /* How many bytes are involved? */ - char fx_pcrel; /* TRUE: pc-relative. */ - char fx_pcrel_adjust;/* pc-relative offset adjust */ - char fx_im_disp; /* TRUE: value is a displacement */ - bit_fixS * fx_bit_fixP; /* IF NULL no bitfix's to do */ - char fx_bsr; /* sequent-hack */ - enum reloc_type fx_r_type; /* Sparc hacks */ - char fx_callj; /* TRUE if target is a 'callj' - (used by i960) */ - long fx_addnumber; -}; - -typedef struct fix fixS; - -COMMON char *next_object_file_charP; - -COMMON fixS *text_fix_root, *text_fix_tail; /* Chains fixSs. */ -COMMON fixS *data_fix_root, *data_fix_tail; /* Chains fixSs. */ -COMMON fixS **seg_fix_rootP, **seg_fix_tailP; /* -> one of above. */ -extern long string_byte_count; -extern int section_alignment[]; - -#ifdef __STDC__ - -bit_fixS *bit_fix_new(char size, char offset, long base_type, long base_adj, long min, long max, long add); -void append(char **charPP, char *fromP, unsigned long length); -void record_alignment(segT seg, int align); -void write_object_file(void); - -fixS *fix_new(fragS *frag, - int where, - int size, - symbolS *add_symbol, - symbolS *sub_symbol, - long offset, - int pcrel, - enum reloc_type r_type); - -#else - -bit_fixS *bit_fix_new(); -fixS *fix_new(); -void append(); -void record_alignment(); -void write_object_file(); - -#endif /* __STDC__ */ - -/* - * Local Variables: - * comment-column: 0 - * fill-column: 131 - * End: - */ - -/* end of write.h */ diff --git a/gas/xmalloc.c b/gas/xmalloc.c deleted file mode 100644 index 08d30ee6795..00000000000 --- a/gas/xmalloc.c +++ /dev/null @@ -1,71 +0,0 @@ -/* xmalloc.c - get memory or bust - Copyright (C) 1987, 1990, 1991 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* static const char rcsid[] = "$Id$"; */ - -/* -NAME - xmalloc() - get memory or bust -INDEX - xmalloc() uses malloc() - -SYNOPSIS - char * my_memory; - - my_memory = xmalloc(42); / * my_memory gets address of 42 chars * / - -DESCRIPTION - - Use xmalloc() as an "error-free" malloc(). It does almost the same job. - When it cannot honour your request for memory it BOMBS your program - with a "virtual memory exceeded" message. Malloc() returns NULL and - does not bomb your program. - -SEE ALSO - malloc() - -*/ -#include - -#ifdef __STDC__ -#include -#else -#ifdef USG -#include -#else - char * malloc(); -#endif /* USG */ -#endif /* __STDC__ */ - -#define error as_fatal - -char * xmalloc(n) - long n; -{ - char * retval; - void error(); - - if ((retval = malloc ((unsigned)n)) == NULL) - { - error("virtual memory exceeded"); - } - return (retval); -} - -/* end: xmalloc.c */ diff --git a/gas/xrealloc.c b/gas/xrealloc.c deleted file mode 100644 index 4be4f69dbb0..00000000000 --- a/gas/xrealloc.c +++ /dev/null @@ -1,70 +0,0 @@ -/* xrealloc.c -new memory or bust- - Copyright (C) 1987, 1990, 1991 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - - -/* static const char rcsid[] = "$Id$"; */ - -/* - -NAME - xrealloc () - get more memory or bust -INDEX - xrealloc () uses realloc () -SYNOPSIS - char *my_memory; - - my_memory = xrealloc (my_memory, 42); - / * my_memory gets (perhaps new) address of 42 chars * / - -DESCRIPTION - - Use xrealloc () as an "error-free" realloc ().It does almost the same - job. When it cannot honour your request for memory it BOMBS your - program with a "virtual memory exceeded" message. Realloc() returns - NULL and does not bomb your program. - -SEE ALSO - realloc () -*/ - -#ifdef __STDC__ -#include -#else -#ifdef USG -#include -#else - char *realloc (); -#endif /* USG */ -#endif /* __STDC__ */ - -#define error as_fatal - -char * -xrealloc (ptr, n) -register char *ptr; -long n; -{ - void error(); - - if ((ptr = realloc (ptr, (unsigned)n)) == 0) - error ("virtual memory exceeded"); - return (ptr); -} - -/* end: xrealloc.c */ diff --git a/gdb/.Sanitize b/gdb/.Sanitize deleted file mode 100644 index c3c6345e653..00000000000 --- a/gdb/.Sanitize +++ /dev/null @@ -1,281 +0,0 @@ -# .Sanitize for devo/gdb. -# $Id$ -# - -# Each directory to survive it's way into a release will need a file -# like this one called "./.Sanitize". All keyword lines must exist, -# and must exist in the order specified by this file. Each directory -# in the tree will be processed, top down, in the following order. - -# Hash started lines like this one are comments and will be deleted -# before anything else is done. Blank lines will also be squashed -# out. - -# The lines between the "Do-first:" line and the "Things-to-keep:" -# line are executed as a /bin/sh shell script before anything else is -# done in this - -Do-first: - -echo Sanitizing `pwd`... - -# All files listed between the "Things-to-keep:" line and the -# "Files-to-sed:" line will be kept. All other files will be removed. -# Directories listed in this section will have their own Sanitize -# called. Directories not listed will be removed in their entirety -# with rm -rf. - -Things-to-keep: - -.gdbinit -gdb.1 -COPYING -ChangeLog -ChangeLog-3.x -Convex.notes -Makefile.in -Projects -README -TODO -WHATS.NEW -alldeps.mak -alloca.c -altos-xdep.c -am29k-opcode.h -am29k-pinsn.c -am29k-tdep.c -ansidecl.h -arm-convert.s -arm-opcode.h -arm-pinsn.c -arm-tdep.c -arm-xdep.c -blockframe.c -breakpoint.c -breakpoint.h -buildsym.c -buildsym.h -c-exp.y -coffread.c -command.c -command.h -configure.in -convex-pinsn.c -convex-tdep.c -convex-xdep.c -convx-opcode.h -copying.awk -copying.c -core.c -coredep.c -cplus-dem.c -createtags -dbxread.c -defs.h -depend -doc -dwarfread.c -elfread.c -environ.c -environ.h -eval.c -exec.c -expprint.c -expression.h -findvar.c -frame.h -gdbcmd.h -gdbcore.h -getpagesize.h -gmalloc.c -gmalloc.h -gould-pinsn.c -gould-xdep.c -hp300ux-xdep.c -i386-pinsn.c -i386-stub.c -i386-tdep.c -i386-xdep.c -i387-tdep.c -i960-pinsn.c -i960-tdep.c -ieee-float.c -ieee-float.h -infcmd.c -inferior.h -inflow.c -infptrace.c -infrun.c -inftarg.c -kdb-start.c -language.c -language.h -m2-exp.y -m68k-opcode.h -m68k-pinsn.c -m68k-stub.c -m68k-tdep.c -m88k-opcode.h -m88k-pinsn.c -m88k-tdep.c -m88k-xdep.c -mach386-xdep.c -main.c -mcheck.c -mem-break.c -minimon.h -mips-opcode.h -mips-pinsn.c -mips-tdep.c -mips-xdep.c -mipsread.c -mtrace.awk -mtrace.c -munch -news-xdep.c -nindy-share -nindy-tdep.c -np1-opcode.h -ns32k-opcode.h -ns32k-pinsn.c -param-no-tm.h -param.h -parse.c -parser-defs.h -pn-opcode.h -printcmd.c -procfs.c -putenv.c -pyr-opcode.h -pyr-pinsn.c -pyr-tdep.c -pyr-xdep.c -regex.c -regex.h -rem-multi.shar -remote-adapt.c -remote-eb.c -remote-mm.c -remote-nindy.c -remote-vx.c -remote.c -saber.suppress -signals.h -signame.c -signame.h -solib.c -source.c -sparc-opcode.h -sparc-pinsn.c -sparc-tdep.c -sparc-xdep.c -stack.c -standalone.c -stuff.c -sun3-xdep.c -sun386-xdep.c -symfile.c -symfile.h -symm-tdep.c -symm-xdep.c -symmisc.c -symtab.c -symtab.h -tahoe-opcode.h -tahoe-pinsn.c -target.c -target.h -tconfig -terminal.h -tm-29k.h -tm-3b1.h -tm-68k.h -tm-m88k.h -tm-altos.h -tm-altosgas.h -tm-amix.h -tm-arm.h -tm-bigmips.h -tm-convex.h -tm-hp300bsd.h -tm-hp300hpux.h -tm-i386v-g.h -tm-i386v.h -tm-i960.h -tm-irix3.h -tm-isi.h -tm-merlin.h -tm-mips.h -tm-news.h -tm-nindy960.h -tm-np1.h -tm-pn.h -tm-pyr.h -tm-sparc.h -tm-sun2.h -tm-sun2os4.h -tm-sun3.h -tm-sun386.h -tm-sun3os4.h -tm-sun4os4.h -tm-sunos.h -tm-svr4.h -tm-symmetry.h -tm-tahoe.h -tm-ultra3.h -tm-umax.h -tm-vax.h -tm-vx68.h -tm-vx960.h -ultra3-xdep.c -umax-xdep.c -utils.c -valarith.c -valops.c -valprint.c -value.h -values.c -vax-opcode.h -vax-pinsn.c -vx-share -xconfig -xm-3b1.h -xm-m88k.h -xm-altos.h -xm-amix.h -xm-arm.h -xm-bigmips.h -xm-convex.h -xm-hp300bsd.h -xm-hp300hpux.h -xm-i386mach.h -xm-i386sco.h -xm-i386v.h -xm-i386v32.h -xm-irix3.h -xm-isi.h -xm-m68k.h -xm-merlin.h -xm-mips.h -xm-news.h -xm-news1000.h -xm-np1.h -xm-pn.h -xm-pyr.h -xm-rtbsd.h -xm-sparc.h -xm-sun2.h -xm-sun3.h -xm-sun386.h -xm-sun3os4.h -xm-sun4os4.h -xm-svr4.h -xm-symmetry.h -xm-tahoe.h -xm-ultra3.h -xm-umax.h -xm-vax.h - -Do-last: - -# End of file. diff --git a/gdb/.gdbinit b/gdb/.gdbinit deleted file mode 100644 index 3adc4837d01..00000000000 --- a/gdb/.gdbinit +++ /dev/null @@ -1,13 +0,0 @@ -echo Setting up the environment for debugging gdb.\n - -set complaints 1 - -b fatal - -b info_command -commands - silent - return -end - -set prompt (top-gdb) diff --git a/gdb/Attic/Makefile.in b/gdb/Attic/Makefile.in deleted file mode 100755 index e69de29bb2d..00000000000 diff --git a/gdb/COPYING b/gdb/COPYING deleted file mode 100644 index a43ea2126fb..00000000000 --- a/gdb/COPYING +++ /dev/null @@ -1,339 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 675 Mass Ave, Cambridge, MA 02139, USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - Appendix: How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) 19yy - - 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., 675 Mass Ave, Cambridge, MA 02139, USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) 19yy name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/gdb/ChangeLog b/gdb/ChangeLog deleted file mode 100644 index 5395ac9482d..00000000000 --- a/gdb/ChangeLog +++ /dev/null @@ -1,7659 +0,0 @@ -Mon Nov 18 17:45:18 1991 Fred Fish (fnf at cygnus.com) - - * m68k-tdep.c (m68k_skip_prologue): Add generic m68k support for - skipping function prologues, ala the other cpu families (i386, - mips, m88k, etc). Add the ability to skip movm and fmovm - instructions in the prologues. Still needs support for profile - (-p compiled) prologue sequences (FIXME). - - * tm-68k.h: Change SKIP_PROLOGUE macro to use the new generic - m68k prologue skipping function by default. - - * tm-altos.h, tm-isi.h: Continue to use the old definition of - SKIP_PROLOGUE. - -Mon Nov 18 15:12:45 1991 John Gilmore (gnu at cygnus.com) - - * blockframe.c: Remove tdesc-related code. Default - FRAME_CHAIN_COMBINE if not defined. - * infrun.c: Remove tdesc-related code. - * m88k-tdep.c (frame_chain_combine, init_frame_pc): Remove copies - of defaultable things. - * tm-m88k.h: New file, common to all Moto 88k target configs. - Derived from tm-delta88.h. - * tm-delta88.h: Use it. - * xm-m88k.h: Common file for 88K hosts. Remove obsolete stuff. - * xm-delta88.h: Use it. - * tm-*.h: Remove FRAME_CHAIN_COMBINE macros, since all are - default. - * coffread.c: Remove tdesc stuff. - * tconfig/delta88, tconfig/m88k: Remove tdesc stuff. - * xconfig/m88k: Rename tm-88k.h to tm-m88k.h. - -Mon Nov 18 13:51:37 1991 Per Bothner (bothner at cygnus.com) - - * source.c (open_source_file): If openp fails, try again - using just the base (non-directory) part of the filename. - This solves various annoying problems, such as when the - source was compiled with an absolute pathname - and the - source files have moved. Or if the source was compiled - using a relative pathname, it can be more convenient - to just specific the source directory to the dir command. - -Mon Nov 18 00:04:41 1991 Fred Fish (fnf at cygnus.com) - - * cplus-dem.c (munge_function_name): Add missing third arg to - instance of call to do_type(). - - * dwarfread.c: Changes to match new dwarf.h. Remove - AT_deriv_list, AT_loclist, AT_incomplete, AT_const_data, - and AT_is_external. - -Sun Nov 17 16:20:53 1991 Michael Tiemann (tiemann at rtl.cygnus.com) - - * symtab.h (struct type): Moved C++-specific fields into new type - `struct cplus_struct_type'. Now takes 10% less memory. Many - macros changed. - * symtab.c (init_type): Don't set fields belonging to - TYPE_CPLUS_SPECIFIC unless TYPE is TYPE_CODE_STRUCT. - * buildsym.c (read_type): Allocate TYPE_CPLUS_SPECIFIC for - TYPE_CODE_STRUCT. - (read_struct_type): Ditto. Also, add comments about how we can - deduce TYPE_VPTR_FIELDNO from inheritance info and fieldname info. - * coffread.c (decode_base_type): Allocate TYPE_CPLUS_SPECIFIC for - TYPE_CODE_STRUCT. - (read_struct_type): Ditto. - * dwarfread.c (struct_type): Ditto. - - * symtab.c (read_range_type): Don't set TYPE_MAIN_VARIANT. - (lookup_pointer_type): Don't use or set TYPE_MAIN_VARIANT. - (lookup_reference_type): Ditto. - - * cplus-dem.c: Many changes made to handle decoding of - ANSI-mangled names. - * symtab.c (gdb_mangle_name): Mangle/demangle ANSI-mangled names - as well. - -Fri Nov 15 17:57:59 1991 Stu Grossman (grossman at cygnus.com) - - * mipsread.c (parse_partial_symbols): patch to keep DEC C - compiler from making gdb bomb out. Thanks to Ed Santiago! - -Thu Nov 14 19:27:30 1991 Fred Fish (fnf at cygnus.com) - - * symfile.c: Add function compact_misc_function_vector() to - remove duplicate misc function vector entries. See comments - in source for why this is necessary/desirable. - - * dwarfread.c: Add misc function type parameter to internal - record_misc_function(). Remove calls to init_misc_bunches() - and condense_misc_bunches(), these are now done in elfread.c. - - * elfread.c: Add support for reading bfd canonical symbol tables - and generating misc function vector entries for global and - absolute symbols. Do calls to init_misc_bunches() and - condense_misc_bunches() where they will enclose all calls to - record_misc_function(), including those in dwarfread.c. - -Thu Nov 14 17:02:11 1991 Roland H. Pesch (pesch at cygnus.com) - - * doc/Makefile.in: new targets gdb.me, gdb.ms, gdb.mm - (roffable documentation). - * doc/gdb.texinfo: embedded hints (as comments) for better - texi2roff conversion. - -Thu Nov 14 13:18:25 1991 John Gilmore (gnu at cygnus.com) - - * m88k-tdep.c (examine_prologue): Deal with OR instructions - that shuffle parameters into other regs. - * symtab.c (decode_line_1): Fix bug introduced in Per's change - of Nov 12th. - -Wed Nov 13 19:51:11 1991 Steve Chamberlain (sac at cygnus.com) - - * Makefile.in, xconfig/delta88 made it install a sysV manual page; - gdb.z into the right place. - -Wed Nov 13 16:45:13 1991 John Gilmore (gnu at cygnus.com) - - Motorola 88000 port without tears, I mean without tdescs. - - * m88k-tdep.c: Blow away all tdesc stuff. - Provide functions for all the frame-related macros in - tm-delta88.h. Adopt i960-style EXTRA_FRAME_INFO. - (examine_prologue, frame_find_saved_regs, skip_prologue): borrow - from i960-tdep.c and adapt to the function prologues on the 88k. - (read_next_frame_reg): Borrow from mips-tdep.c. - FIXME: frame_locals_address should go away. - - * tm-delta88.h: Dump all the tdesc stuff. - Macros for all frame-related stuff call fns of same name. - Remove duplicated definitions. FP_REGNUM becomes same as - SP_REGNUM. - - * xm-88k.h: Eliminate lots of library dependencies, now handled - in libiberty. Eliminate KDB nonsupport. - - * doc/gdbint.texinfo: Add rudiments on frames. FIXME, add more. - - - * stack.c (frame_info): Mark frameless functions. - Print locals address (FIXME, remove if same). - * blockframe.c: Comment changes, FIXME after. - * coffread.c: Even without TDESC, need to zap "@" symbols. - Don't register for wierd format names; change the names in BFD. - - * alloca.c, language.c, tdesc.c: Lint. - * tdesc.c, tdesc-lib: FIXME: remove these. - -Tue Nov 12 19:30:22 1991 John Gilmore (gnu at cygnus.com) - - * Makefile.in: Add tdesc library support. Fixups to lint, - copying.c rules. - -Tue Nov 12 13:43:26 1991 Per Bothner (bothner at cygnus.com) - - * symtab.c (decode_line_1): Remove spurious call to operator_chars. - - Allow setting breakpoints on C++ destructors. - * valops.c (destructor_name_p): Don't check TYPE_HAS_DESTRUCTOR, - since it lies. Rely on callers to catch missing destructors. - * symtab.c (decode_line_1): For example (see above), here. - * buildsym.c, symtab.h: Remove TYPE_FLAGS_HAS{CON,DE}STRUCTOR - flags since they are no longer used. - - Fixes to support C++ methods with functional parameters. - * c-exp.y (func_mod rule): Allow (and ignore) list of parameter - types in a function type. - * eval.c (parse_and_eval_type), value.h: New function, - parse_and_eval_type, is based on old code from check_stub_method. - But don't actually evaluate the cast, since that calls - value_cast(), whcih may fail. Just extract the type - from the parsed expression. - * values.c (check_stub_method): While looping through the - arguments, adjust depth *after* parameter has been handled. - Replace call and setup of parse_and_eval with new function - parse_and_eval_type. - -Tue Nov 12 09:40:07 1991 Fred Fish (fnf at cygnus.com) - - * utils.c, rem-multi.shar: Remove fixed arg count version of - concat(). - - * altos-xdep.c, arm-xdep.c, coffread.c, command.c, convex-xdep.c, - core.c, dwarfread.c, gould-xdep.c, infcmd.c, language.c, - m88k-xdep.c, main.c, printcmd.c, pyr-xdep.c, source.c, - sun386-xdep.c, symm-xdep.c, umax-xdep.c, values.c, xcoffread.c: - Change all instances of use of fixed args concat() to variable - args concat() now located in libiberty. - -Tue Nov 12 07:23:46 1991 John Gilmore (gnu at cygnus.com) - - * Makefile.in: Add xcoffread.c, xcoffexec.c. - * xcoffread.c: New file for handling AIX mangled-coff files. - * xconfig/rs6000, tconfig/rs6000: New files. - * buildsym.c: Add hooks for xcoffread.c. - * rs6000-pinsn.c, rs6000-tdep.c, rs6000-xdep.c, tm-rs6000.h, - xm-rs6000.h, rs6k-opcode.def, rs6k-opcode.h: New files. - * xcoffexec.c: New file for handling AIX shared libraries. - -Mon Nov 11 19:14:31 1991 Fred Fish (fnf at cygnus.com) - - * core.c: Minor rewording of message to user containing name of - (and possibly arguments to) the program that generated a core - file. - - * elfread.c: Remove the register_addr() stub now that it is no - longer needed. - - * procfs.c: Move misplaced #endif for ATTACH_DETACH. Add new - fetch_core_registers() function for core file support. - -Sat Nov 9 13:37:57 1991 Fred Fish (fnf at cygnus.com) - - * dwarfread.c (dwarf_psymtab_to_symtab): Remove leftover call - to do_cleanups() which resulted from a previous change. - - * elfread.c: Re-enable compilation of register_addr() stub - whenever it is not supplied by coredep.c - -Sat Nov 9 00:40:32 1991 John Gilmore (gnu at cygnus.com) - - Add tracking of object files (that contain symbols) to gdb. - This includes a "struct objfile" that owns symtabs and psymtabs - that were read in from that binary file. - - * symfile.h: Add struct objfile. Add pointer to the objfile - into the struct sym_fns. - Replace global `symfile' and `symfile_mtime' with - `symfile_objfile'. Add global object_files chain. - - * symfile.c: Move param.h above symtab.h. - (sort_misc_function_vector): Add. - (syms_from_objfile): Was syms_from_bfd. - (symfile_open): Now returns objfile. - (allocate_objfile): New. - (free_objfile): New, replacing free_all_.*symtabs. - (symfile_init): Takes objfile arg, puts it in sym_fns result. - (reread_symbols): Searches whole chain of objfiles. - (allocate_symtab): Takes objfile as new parameter, chains them. - Handle INIT_EXTRA_SYMTAB_INFO. - (free_all_psymtabs, free_all_symtabs): Move here from symmisc.c. - - * dbxread.c: Make more errors into complaints. - (push_subfile, pop_subfile): Move to buildsym.c. - (dbx_symfile_read, dbx_symfile_init, fill_symbuf, read_dbx_symtab, - start_psymtab, psymtab_to_symtab_1, read_ofile_symtab, - dbx_psymtab_to_symtab, ): Use bfd ops, don't use file descriptor. - Pass objfile. Change callers. - (fill_symbuf, SWAP_SYMBOL): Take bfd as arg. - (read_dbx_symtab): Just wipe out new symbols, not all, on error. - (end_psymtab): Blow away psymtab if empty. - (process_symbol_pair): Swallow into read_ofile_symtab. - (process_one_symbol): Use push_context and pop_context. - (virtual_context): Delete #if 0'd obsolete stuff. - - * buildsym.c (end_symtab): Pass objfile. - (dbx_lookup_type): Handle null typevector. - (dbx_alloc_type): Check file number, not sym number, for -1. - (find_symbol_in_list): Add for xcoffread. - (start_symtab): Default typevector is empty. Keep reusing same - context_stack. - (end_symtab): Take objfile argument and pass it to - allocate_symtab. Don't make a symtab if no blocks or symbols. - Handle empty typevector. - (push_context): New function for context stack nesting. - (read_type): Mark FIXME where we need to reintroduce type smashing. - - * buildsym.h (pop_context): Macro, paired with push_context. - (subfile_stack): Move here from dbxread.c. - - * coffread.c (end_symtab, read_coff_symtab): Take and use objfile arg. - (read_coff_symtab): Cleanup by freeing objfile, not all symtabs. - - * mipsread.c (read_mips_symtab, parse_partial_symbols, parse_fdr, - new_psymtab, new_symtab): Take and use objfile arg. - - * dwarfread.c (scan_compilation_units, start_psymtab, - process_dies, end_symtab, dwarf_build_psymtabs, - read_lexical_block_scope, read_func_scope, read_file_scope): Take - and use objfile argument. - (psymtab_to_symtab_1, read_ofile_symtab): Don't take or use file - descriptor. Use BFD internal functions instead. - (end_symtab): Call global allocate_symtab. - - * elfread.c, target.c: Minor changes to accommodate objfiles. - * symtab.h: partial_symbol_table has no symfile_name member now. - (fn_fieldlists voffset): avoid non-int bitfield. - (struct symtab): Add objfile * and objfile_chain * of symtabs. - (struct partial_symtab): Add objfile * and objfile_chain * of - psymtabs. Remove symfile_name. - - * symmisc.c: Lose free_all_symtabs, free_all_psymtabs. - (printsyms_command): Rename from print_symtabs. Add selective - listing if 2nd argument given. Print objfile info. - (printpsyms_command): Rename from print_partial_symtabs. Ditto all. - (printobjfiles_command): New; prints objfiles lists, and checks - for consistency of symtab, psymtab, and objfile lists. - - * symfile.h, symfile.c, symtab.h: Lint - -Fri Nov 8 23:38:48 1991 John Gilmore (gnu at cygnus.com) - - * command.c: Include param.h. - * defs.h (warning_setup, warning): Declare. - * expprint.c (print_subexp, UNOP_MEMVAL case): Lint. - * inflow.c (new_tty): Use USE_O_NOCTTY #define. - * language.c, printcmd.c (print_scalar_formatted), signame.c, - stack.c: lint. - -Thu Nov 7 18:26:15 1991 Steve Chamberlain (sac at rtl.cygnus.com) - - * Makefile.in: link with libiberty after libreadline, since - readline might want something in libiberty. - * m88k-xdep.c: Fixed the register offsets in the ptrace_user - struct for BCS 88k machines. - * xm-m88k.h: don't define USIZE if already defined. - * configure.in: Added delta88 target. - -Thu Nov 7 04:51:19 1991 John Gilmore (gnu at cygnus.com) - - * am29k-pinsn.c, am29k-opcode.h: Fix decoding of mtacc, dmac, fmac. - - * tm-*.h: Remove READ_DBX_FORMAT, COFF_FORMAT, and - READ_MIPS_FORMAT, which have been unused since BFD. Still - remaining is COFF_NO_LONG_FILE_NAMES. - * tm-sun3.h, tm-altos.h: Remove detritus accidentally left from - function calling code moved to m68k-tdep.c. - -Wed Nov 6 17:21:59 1991 John Gilmore (gnu at cygnus.com) - - * coffread.c: Eliminate c_nsyms in favor of c_naux. - Complain if no auxents on .bf and .ef FCN symbols, and assume - lots of line numbers. - (init_linenos, enter_linenos): Use a sentinel at the end of the - read-in linenos, to make for a fast, safe loop-end test. - -Wed Nov 6 02:54:08 1991 Steve Chamberlain (sac at cygnus.com) - - * coffread.c (read_coff_symtab): coffread used to rely on the - x_sym.x_misc.x_lnsz.x_lnno field giving the # of linnos in a - function. Two of the formats I'm using (29k and 88k) don't seem to - set it. Ths patch to fcn_last_line and (enter_linenos) is an - attempt to use the actual size of the linno table in the file to set - the number of linenos to process. - -Tue Nov 5 22:47:46 1991 Steve Chamberlain (sac at cygnus.com) - - * Makefile.in: put a - infront of the mv y.tab.c c-exp.tab.c and - mv y.tab.c m2-exp.tab.c, so that if bison is used, and the files - are created in place, so the mv fails, then the make continues. - -Tue Nov 5 16:47:47 1991 Per Bothner (bothner at cygnus.com) - - Add C++ as a separate language. - * defs.h (enum language): Add language_cplus. - * dwarfread.c (end_symtab): Support language_cplus. - * c-exp.y: Add new struct language_defn cplus_language_defn. - Don't set c to be the default language (see main.c). - * c-exp.y (yylex): Only look for field of this if - language is C++. (First difference from C!) - * language.c: Add case branches for C++ (currently, all - the same as C). Also, add c++ to "usage" note for "set lang". - * valprint.c (typedef_print). Add case branches for C++. - * main.c (main): New way to set initial language: Look at - file extension of psymtab containing main(). (Same as we - do for symtabs, but avoid loading the symtab yet.) - * symtab.c: New routine find_main_psymtab(), used by main() - to set initial language. - * symfile.c (allocate_symtab): Move code for mapping file - extensions-> languages to new deduce_language_from_filename(). - - Fix a C++ problem when looking for methods in super-classes. - There was confusion between base and derived types. - * valops.c (value_fn_field): Change function interface. - * values.c: Use new value_fn_field interface. - -Mon Nov 4 10:49:33 1991 Per Bothner (bothner at cygnus.com) - - * infrun.c: Fixed typo in comment. - * utils.c: All the v*fprintf emulation is now in libiberty, - so we can get rid of some junk. - * xm-sun3os4.h, xm-sun4os4.h, xconfig/decstation, xconfig/i386sco, - xconfig/sun3os4, xconfig/sun4os4: Don`t need HAVE_STRSTR any more. - * m68k-pinsn.c (print_insn_arg): Support BB/BW/BL - type operands, as used by branch instructions. - * gmalloc.c: Fix prototype of memcpy. - * elfread.c: Comment out register_addr, since it conflicts - with the one in coredep.c. - * buildsym.h: Remove extern declarations of two functions - that are really static in buildsym.c. - * tm-mips.h: Add symbolic names for more registers. - * mips-xdep.c (store_inferior_registers): Use new register names. - * xm-mips.h: Simplify REGISTER_U_ADDR, since it is now - only used for core files, not ptrace. Therefore, - the KERNEL_U_ADDR hack is no longer needed. - The mapping to ptrace number is now in in mips-xdep.c. - * mips-xdep.c: Define REGISTER_PTRACE_ADDR (using the - mapping from the old REGISTER_U_ADDR), and use it - in {fetch,store}_inferior_registers. - * mipsread.c: Rename #include ecoff.h to new name coff-mips.h. - * mips-tdep.c (mips_push_dummy_frame, mips_pop_frame): - Save/restore FP regs correctly (?). - * dbxread.c: Remove duplicate define_symbol and type_synonym_name - (these had been previously moved to buildsym.c). - Hence, define_symbol becomes extern instead of static. - * buildsym.c (read_struct_type): Comment out bogus handling - of C++ operator methods. Minor hacking of reading of class - contexts. Make define_symbol non-static, so dbxread.c can call it. - -Fri Nov 1 11:05:47 1991 John Gilmore (gnu at cygnus.com) - - * mipsread.c (read_mips_symtab, read_the_mips_symtab): Use real - filename with error messages. - * stack.c (frame_select_command): Rename to select_frame_command - to avoid "fr" and "fra" having nonunique completions. - * symfile.c (sort_symtab_syms): Ignore sort of zero symtab *. - (symfile_init): Print file format name when unable to handle it. - (free_named_symtabs): Use BLOCKVECTOR rather than obsolete BLOCKLIST. - * symmisc.c (free_symtab): Only free linetable if nonzero. - * symtab.h: Remove obsolete BLOCKLIST macros. - -Thu Oct 31 18:12:43 1991 Stu Grossman (grossman at cygnus.com) - - * infrun.c (wait_for_inferior): another stepi/nexti fix. Ensure - that stop_step is 1 at bottom of main loop. I don't know why this - needs to be done, but it helps me sleep better at night. - -Sun Oct 27 18:18:39 1991 Stu Grossman (grossman at cygnus.com) - - * main.c (initialize_history): Read history after reading all - init files. - -Sun Oct 27 14:09:25 1991 John Gilmore (gnu at cygnus.com) - - * buildsym.c: Break out initial malloc sizes. - (record_line): Record directly in a subfile. Alloc on demand. - (compare_line_numbers): Add from xcoffread.c. - (end_symtab): New params say whether to sort pendings and - linetable. Patch block stabs if defined. Shrink linetable before - allocating the symtab. - * buildsym.h: Delete line_vector* and prev_line_number. Add - global_stabs and file_stabs for xcoffread. - * dbxread.c (start_subfile): Move to buildsym. Change above calls. - * symtab.h: LINETABLE(symtab) can now be null. Zap LINELIST. - * symmisc.c, symtab.c: Cope with null LINETABLEs. - - * blockframe.c: Pass fromleaf to INIT_EXTRA_FRAME_INFO. - * tm-29k.h, tm-88k.h, tm-i960.h, tm-irix3.h, tm-mips.h, tm-pyr.h, - tm-sparc.h: Accept fromleaf parameter. - * c-exp.y (yyerror): Pass error message if given. - * configure.in: Add rs6000 host and target. - * inflow.c (new_tty): O_NOCTTY kludge for RS/6000. - * symfile.h (entry_point): Add. - -Sat Oct 26 00:16:32 1991 John Gilmore (gnu at cygus.com) - - * buildsym.c: New file. Breaks out symbol-table-building routines - from dbxread.c, so they can be shared with xcoffread.c. - * buildsym.h: New file. Declarations for buildsym.c users. - * dbxread.c: Remove large chunks into buildsym.c. - * Makefile.in: Add buildsym.c and buildsym.h. - - * symfile.c (syms_from_bfd): New routine. - (add_symbol_file): Call it to do the real work. - (syms_from_bfd): Initialize entry_point before calling symfile_init. - * symtab.h, symfile.c, coffread.c, mipsread.c, dwarfread.c: - Avoid declaring or setting entry_point (symfile.h & symfile.c cope). - -Fri Oct 25 10:58:16 1991 Mark Eichin (eichin at cygnus.com) - - * cplus-dem.c (cplus-demangle): added support for templates, static - data, and the new (correct) mangling for destructors. - - * dwarfread.c: (dwarfwarn): created a varargs version of - dwarfwarn, for non __STDC__ compilers. - - * c-exp.y: (yylex): added match for "template" token. - (typebase): added TEMPLATE name '<' type '>' clause, for explicit - specification of template types. - - * symtab.c: (lookup_template_type): new function for finding - templates in symbol table. - (type_name_no_tag): changed to explicitly check for s/u/e at the - beginning of the symbol - if it is a template, none of these will - be there (but the name will still contain spaces.) - -Fri Oct 25 18:59:32 1991 Per Bothner (bothner at cygnus.com) - - Various fixes to improve g++ debugging. - * symtab.h: Add is_const and is_volatile flags for each method. - These are bit fields - take their space from voffset, - which shrinks to 30 bits. Since voffset is now a bitfield, - make it unsigned for portability. This changes its interpretation - slightly: Static methods now have voffset 1 instead of -1, - and virtual offsets start at 2, not 1. - * symtab.c: Renamed gdb_mangle_typename to gdb_mangle_name, - since it now returns an entire magled method name, not just - the type part. This avoids some duplication. - It also allows us to correctly mangle const and volatile - methods (using the new is_const and is_volatile bit fields - mentioned above). - * valprint.c (type_print_base), values.c (check_stub_method): - Simplify by using new gdb_mangle_name. - * values.c (value_headof): Fix to correctly handle single - inheritance (actually two fixes, either of which suffices). - * dbxread.c (read_struct_type): Handle const and volatile - method specifiers. - * dbxread.c (read_struct_type): Yet one more place where - we must handle '\\' continuations. - * valprint.c (vtbl_ptr_name): Add final '\0'. - -Fri Oct 25 16:06:38 1991 Stu Grossman (grossman at cygnus.com) - - * tm-sparc.h, tm-68k.h (EXTRACT_RETURN_VALUE): fix output of - short return values for sparc and 68k. Patch from Paul Eggert. - - * coffread.c, coredep.c, i386-xdep.c: install patches for - SysV/386 3.2 from Mauro DePalma. - -Fri Oct 25 02:02:13 1991 John Gilmore (gnu at cygnus.com) - - * core.c (core_file_info), exec.c (exec_file_info): Print file - type. Use printf_filtered. - - * valops.c (value_fetch_lazy): Avoid 0-length fetches. - -Thu Oct 24 23:06:40 1991 Fred Fish (fnf at cygnus.com) - - * dwarfread.c: Add casts to remove compiler warnings. - - * tm-3b1.h, tm-68k.h, tm-altos.h, tm-amix.h, tm-hp300bsd.h, - tm-hp300hpux.h, tm-isi.h, tm-news.h, tm-pn.h, tm-sun2.h, - tm-sun3.h: Remove locally duplicated code for calling functions - in the inferior. The only differences were in the specific trap - vectors used and whether or not an fpu was present. These are - now handled by appropriate definitions of BPT_VECTOR and - HAVE_68881 respectively. Other minor obvious cleanups. - - * valops.c: Correct a minor misspelling. - - * utils.c: Remove local BSD/USG hacks that are now in libiberty. - - * dwarfread.c: Remove prototype for dwarfwarn. Does not work - with . - -Thu Oct 24 09:33:44 1991 John Gilmore (gnu at cygnus.com) - - * stack.c (frame_command): Always print. Use new - frame_select_command to select a frame without printing. - - * dwarfread.c: Use , since is not portable. - -Thu Oct 24 01:32:51 1991 Fred Fish (fnf at cygnus.com) - - * dwarfread.c: New file for DWARF debugging format support. - - * elfread.c: New file for ELF object file format support. - - * procfs.c: New file for SVR4 /proc (process file system) support. - - * tm-amix.h, xm-amix.h, tconfig/amix, xconfig/amix: New files for - Amiga UNIX support. - - * xm-svr4.h, tm-svr4.h: New files for SVR4 support. - - * xm-m68k.h: New file for host machines with m68k cpu. - - * Makefile.in: Add elfread.c and dwarfread.c to SFILES_MAINDIR. - Add elfread.o and dwarfread.o to OBS. - - * symfile.h: Add "elf" to list of supported formats in comment. - - * c-exp.y, defs.h, symtab.h, valprint.c: Add three new builtin - types to gdb, builtin_type_long_double, builtin_type_complex, and - builtin_type_double_complex. Add and use new TARGET_SHORT_BIT, - TARGET_INT_BIT, TARGET_LONG_BIT, TARGET_FLOAT_BIT, - TARGET_DOUBLE_BIT, TARGET_LONG_DOUBLE_BIT, TARGET_COMPLEX_BIT, and - TARGET_DOUBLE_COMPLEX_BIT, as the sizes in bits of the indicated - types on the target machine (ala the existing TARGET_LONG_LONG_BIT). - - * infrun.c: When using SVR4 /proc interface instead of ptrace(), - call proc_set_exec_trap() to setup child to stop at first instruction. - - * inftarg.c: When using SVR4 /proc interface, call proc_wait() - rather than wait(). - - * m68k-tdep.c: Add new routines supply_gregset(), fill_gregset(), - supply_fpregset(), and fill_fpregset(), which are machine - dependent support routines for SVR4 /proc interface. - - * utils.c: Add warning_setup() and warning(). Warning() behaves - the same as error() except that it returns normally rather than - jumping back to command level. Modules that don't want to call - warning() for some reason, but want to produce their own warnings, - can call warning_setup() to ensure compatibility with the way - warning() and error() deal with the terminal. - - * symtab.c: Make internal errors produce more useful messages. - - * tm-68k.h: Move code that is duplicated in almost every single - m68k based machine's configuration files to this common file. - Duplications in the configuration files still need to be removed - (FIXME). - - * infrun.c (child_create_inferior): System V versions must call - setpgrp() with no arguments, to comply with prototyping typically - in . - - * munch: Add support for SVR4 style nm output. - - * dbxread.c, mipsread.c symmisc.c, symtab.c: Remove the object - file specific fields from the partial symbol table structure and - replace them with a pointer to private data for each different - flavor of object file reader to initialize appropriately. - -Wed Oct 23 09:38:20 1991 John Gilmore (gnu at cygnus.com) - - * xconfig/sun[34]os4: Add note about strstr botch on sunos4.0.3c - and previous. - - * mipsread.c (fixup_undef_type): New function. If a struct / - union / enum is defined in a header file but nowhere else used, - (by typedefing, pointer referencing or declaration) the mipsread code - builds the complete tree for the structure but leaves its code as - TYPE_CODE_UNDEF as it doesn't know what kind of aggregate it is. - Guess its type based on the details of the members. - -Tue Oct 22 18:04:32 1991 Stu Grossman (grossman at cygnus.com) - - * infrun.c (wait_for_inferior): Check return value from - find_pc_line. - -Mon Oct 21 17:47:03 1991 Stu Grossman (grossman at cygnus.com) - - * infrun.c (wait_for_inferior): fix stepi/nexti that was broken - by my last edit to this routine. - -Mon Oct 21 14:27:43 1991 John Gilmore (gnu at cygnus.com) - - * tm-sun3.h (FIX_CALL_DUMMY): problem with cross debugging. - FIX_CALL_DUMMY does unaligned accesses and/or forgets to byte swap - the values before putting them into the dummy code. (From Peter - Schauer) - -Mon Oct 21 10:04:39 1991 Steve Chamberlain (steve at rtl.cygnus.com) - - * configure.in: added ebmon target. - -Wed Oct 16 22:49:58 1991 John Gilmore (gnu at cygnus.com) - - GDB-4.2 release! - - * Makefile.in: Roll VERSION to 4.2. - * README, TODO, WHATS.NEW: Update. - - * core.c (core_open): Improve error message for bad file. - Pass .reg virtual memory address to fetch_core_registers to help - it find the registers in the core-file header. - * coredep.c (fetch_core_registers): Take new argument, use it, - and pass it to register_addr to locate the block of registers. - * xm-mips.h: Update KERNEL_U_ADDR for new scheme. Cleanup a bit. - - * dbxread.c (read_dbx_symtab, process_one_symbol): Handle - Sequent N_FN_SEQ like everybody else's N_FN. - - * main.c: Circumvent SCO cc bug with #if !!defined(USG). - * tm-i386v.h: #endif guck. - * xconfig/i386*: Remove -Dgetpagesize()=4096 kludge. - * xconfig/i386sco: Add HAVE_STRSTR to avoid ANSI bdeath. - * xconfig/tahoe: Add REGEX, which seems to be missing. - - * coredep.c: Add for SCOnix. - * dbxread.c (read_dbx_symntab): Avoid coredump on malformed file. - * printcmd.c (print_formatted): Flush output before disassembly. - -Tue Oct 15 20:12:32 1991 Roland H. Pesch (pesch at fowanton.cygnus.com) - - * doc/refcard.tex (sec "Working Files"): consistent metavars and - other improvements, due to comments by François Pinard - (pinard@iro.umontreal.ca) - - * doc/gdb.texinfo (appendix "Installing GDB"): changes in - configure, and improvenets related to Pinard's refcard comments - -Tue Oct 15 08:45:12 1991 John Gilmore (gnu at cygnus.com) - - Changes from Fred Fish: - * tm-68k.h (FPI_REGNUM): Add. - * infrun.c (child_create_inferior): flush stdout and stderr - before forking. - * configure.in: Handle amigados, amix hosts and targets. - * inflow.c: Handle TIOCGLTC_BROKEN for Amiga. - - From Andreas Schwab: - * values.c (show_convenience): Use printf_filtered. - * main.c (define_command): Check result of lookup_command for - exact match. - (echo_command): Use printf_filtered, and force output out. - - * dbxread.c (read_enum_type): Avoid Modula-2 kludge that breaks C - programs. - * i387-tdep.c (double_to_i387): Fix typo for double_to_ieee_extended. - * utils.c (_initialize_utils): If !ISATTY, don't paginate. - * configure.in, tconfig/decstation, xconfig/decstation: Rename - dec3100 to decstation. - -Mon Oct 14 13:37:50 1991 Roland H. Pesch (pesch at cygnus.com) - - * doc/gdb.texinfo: Catch up to changes recorded here in ChangeLog - (nodes Continuing and Stepping; Memory; Targets) clarifications - due to Larry Breed - -Fri Oct 11 23:27:06 1991 John Gilmore (gnu at cygnus.com) - - * tm-{irix3,mips,nindy960,pn,symmetry,vx960}.h: Move - REGISTER_U_ADDR to corresponding xm- file. Sugg. by Peter Schauer. - - * symmisc.c (print_partial_symtabs): Add printpsyms debug cmd. - - * m68k-tdep.c (m68k_push_dummy_frame, m68k_pop_frame): Add - generic routines for calling inferior functions. - - * blockframe.c (inside_main_scope, inside_entry_scope): New. - - * copying.awk: Filter formfeeds out of copying & warrantee. - Make them available as `show copying' and `show warrantee' also. - * main.c (print_gnu_advertisement): Advt `show' commands. - -Thu Oct 10 17:25:47 1991 John Gilmore (gnu at cygnus.com) - - * mach386-xdep.c: Even when cross-compiling, leave in the - core-file reading code. - * core.c (get_core_registers): Avoid coredump if no .reg section. - -Wed Oct 9 17:03:34 1991 John Gilmore (gnu at cygnus.com) - - * mipsread.c, coffread.c: initialise TYPE_VPTR_FIELDNO to -1. - This avoids coredumps under `set print object on' in value_headof - (called erroneously by value_from_vtable_info) for `p &struct' - or `p *struct'. From Peter Schauer. - -Mon Oct 7 00:06:52 1991 John Gilmore (gnu at cygnus.com) - - * Makefile.in: Roll version to 4.1.2. - * dbxread.c: Use aout64.h, not a.out.gnu.h. Get external symbol entry - size from BFD (but, FIXME, we don't yet read external nlists's and - convert them to internal nlists's before handling them -- we still - assume they have the same size and alignment.) Use SET_NAMESTRING - everywhere useful. - * exec.c (exec_file_command): Move dead coff-encapsulation code - to BFD. - * m88k-tdep.c, m88k-xdep.c: Remove encap test and #inc . - -Fri Oct 4 22:30:06 1991 John Gilmore (gnu at cygnus.com) - - * configure.in, tm-i386v.h, xm-i386v.h: Intel 386 Mach host port. - * xm-i386mach.h, mach386-xdep.c, xconfig/i386mach: New files. - -Fri Oct 4 17:04:31 1991 Per Bothner (bothner at cygnus.com) - - More patches from Peter Schauer : - * mips-xdep.c (store_inferior_registers): Don't try to - write the (pseudo) FP. - * mipsread.c (parse_partial_symbols): Improved algorithm for - setting pst->texthigh. - -Fri Oct 4 16:47:32 1991 Roland H. Pesch (pesch at cygnus.com) - - * doc/Makefile: make TEXINPUTS include . everywhere - -Fri Oct 4 00:35:56 1991 John Gilmore (gnu at cygnus.com) - - * coffread.c, dbxread.c, symfile.c, symmisc.c, symtab.h: Remove - vestiges of typevectors, which were for symsegs and are no longer - used. (From a question by Eliot Dresselhaus - ). - -Thu Oct 3 09:33:26 1991 John Gilmore (gnu at cygnus.com) - - * dbxread.c, coffread.c: static-ize functions that were - gratuitiously external. (From Fred Fish.) - - * c-exp.y: sym->class to SYMBOL_CLASS (sym). - - * dbxread.c (dbx_lookup_type): Keep doubling size of typevector - until it is large enough. - - * dbxread.c (read_type): Handle error case slightly better. - Make complaint message not C++-specific. - -Wed Oct 2 17:21:07 1991 Stu Grossman (grossman at cygnus.com) - - * infrun.c (wait_for_inferior): Fix step/next so that you only - stop at the beginning of a new line. This fixes various problems - with for loops, nested if-else's and switch statements. - -Tue Oct 1 06:33:55 1991 John Gilmore (gnu at cygnus.com) - - * symtab.c (lookup_symtab_1, lookup_symbol): "fatal" errors - between symtabs and psymtabs become ordinary error()s. - - * dbxread.c (read_dbx_symtab): Relocate end_of_text_addr - properly, making "end pc" correct in shared lib psymtabs. - (From Guy Harris .) - -Mon Sep 30 13:15:31 1991 John Gilmore (gnu at cygnus.com) - - * dbxread.c: Enable, but soften, const_vol_complaint. - (read_dbx_symtab): N_STSYM and N_LCSYM define static vars. - Ditto Gould N_NBSTS and N_NBLCS. Also, all types in the psymtab - should be file-scope, not global. - (read_struct_type): Remove ancient multiple-inheritance warning. - (read_range_type): Check base type, complain & patch if undefined. - * stack.c (frame_info): Demangle the function name in `info stack'. - (From Peter Schauer) - -Sat Sep 28 10:02:33 1991 John Gilmore (gnu at cygnus.com) - - * eval.c (evaluate_subexp_for_address): Don't use - TYPE_POINTER_TYPE directly (it might be zero if this type has - never had a pointer created before); use lookup_pointer_type. - * symtab.c (lookup_method_type): Arguments were swapped in all - callers, so fix it here. I'm amazed this worked at all! - -Fri Sep 27 18:09:31 1991 John Gilmore (gnu at cygnus.com) - - * c-exp.y, m2-exp.y: Define more yysymbols that happen to be - "bss" rather than "data" symbols, but which still conflict. - * m2-exp.y: Lint. - - * coffread.c (coff_symfile_read): Use xmalloc, not malloc. - * core.c (core_files_info): Shorten output. - * exec.c (exec_files_info): Ditto. - (build_section_table): Ignore zero-length sections. - * language.c, printcmd.c: Lint. - * language.h (get_frame_language): Declare. - * saber.suppress: update. - * stack.c (find_relative_frame): Remove complex code that was - #if 0'd, stick with simple code. Lint. - * saber.suppress: Update a bit. - * symfile.c (add_symbol_file_command): Add "?" to question. - * utils.c (parse_escape): Avoid \a due to bdead compilers. - * value.h: Declare typedef_print. - - * valprint.c (val_print, type_print_base): TYPE_CODE_RANGE less - kludgey. - - * nindy-tdep.c (nindy_frame_chain_valid): Use lookup_misc_func. - (Reported by Mark Peek .) - - * solib.c (solib_map_sections): Relocate all sections, even - though only the text section's size is tracked. Mark ld_text - for eventual elimination as we generalize to N sections. - - * infrun.c (wait_for_inferior): Don't check if the PC is in a - call_dummy if we were stopped by a random signal that is being - passed to the program. This produced wierd results when calling - functions in the inferior and signals (e.g. SIGALRM) were in use. - -Tue Sep 24 18:05:30 1991 John Gilmore (gnu at cygnus.com) - - * infrun.c (IN_SIGTRAMP): Not parenthesized properly. - Bugfix from Paul Eggert . - * tm-ultra3.h (IN_SIGTRAMP): Ditto. - * valprint.c (print_floating): Print 9 digits for IEEE floats. - From Paul Eggert. - -Mon Sep 23 15:50:07 1991 John Gilmore (gnu at cygnus.com) - - * Makefile.in: Roll VERSION to 4.1.1. - * source.c (line_info): Peter Schauer fixes a bug I introduced in - hex conversion. - -Fri Sep 20 16:10:52 1991 John Gilmore (gnu at cygnus.com) - - GDB-4.1 release! - - * Makefile.in (VERSION): Set to 4.1. - * language.c (set_language_command): Print useful help message, - and restore the language string after giving help. - * valprint.c (typedef_print): Print typedef in C or M2. - * symtab.c (list_symbols): Use it. - * main.c (main): Avoid any output before (gdb) prompt when -q. - * language.c (set_language_command): Handle errors by restoring - the language string to its current state (fix from A. Beers). - * doc/gdbint.texinfo: Roll in information from README. Rearrange - "how to install" and "how to print the doc" stuff so it drops - easier into README. - * configure.in: Rename rtpc CPU to romp to match config.sub. - * README, WHATS.NEW, TODO: Update for gdb-4.1. - -Fri Sep 20 17:39:14 1991 Roland H. Pesch (pesch at cygnus.com) - - * doc/gdb.texinfo: Updates from ChangeLog. set/show write, - autoloading shared libs, copyright etc on GDB startup, clean up $_ - and $__ index refs, set/show listsize and related updates to list - cmd. New host/target configs. - -Fri Sep 20 15:46:00 1991 Roland H. Pesch (pesch at cygnus.com) - - * doc/Makefile: generate aux version-no file doc/gdbVN.m4 - from main Makefile.in version definition - doc/gdb.texinfo: use version recorded in doc/gdbVN.m4 for current - GDB version no refs - Makefile.in (setup-to-dist): generate doc/gdbVN.m4 - - * doc/gdb.texinfo: merge new language-switching and lang-specific - doc by Andrew Beers - -Fri Sep 20 15:00:57 1991 Per Bothner (bothner at cygnus.com) - - * mcheck.c: Add __ONEFILE kludge to allow compilation by non-ANSI - compilers (which may lack stddef.h). - -Fri Sep 20 13:29:42 1991 John Gilmore (gnu at cygnus.com) - - * dbxread.c (read_dbx_symtab, process_one_symbol): N_FN and - N_WARNING are the same except for the N_EXT bit, so just use their - values alone, rather than OR-ing them with N_EXT. - -Fri Sep 20 12:27:55 1991 Stu Grossman (grossman at cygnus.com) - - * mipsread.c (parse_lines): Deal with negative extended line - offsets correctly. - - * c-exp.y, m2-exp.y: #define yyerrflag and yynerrs to avoid - global symbol conflicts. - -Fri Sep 20 02:28:15 1991 John Gilmore (gnu at cygnus.com) - - * .gdbinit: Move 'set complaints' to top, so it runs even in - case we aren't debugging GDB. - * language.c (_initialize_language): Fix type check and range - check documentation strings. - * utils.c (!HAVE_VPRINTF): Define vfprintf as a function, so - language.c can use it. (Though language.c should really not be - handling warnings/errors the way it does, FIXME.) - * symtab.c (lookup_primitive_type): const lint. - - Bugfix from Peter Schauer: - * source.c (lines_to_list): Make signed, to avoid comparison - going unsigned and complaining that -3 is too high for 21 lines. - * stack.c (lines_to_list): Ditto. - -Thu Sep 19 23:33:41 1991 John Gilmore (gnu at cygnus.com) - - * Makefile.in (HFILES): Add minimon.h. - (VERSION): Roll version number to 4.0.95. - (gdb.tar.Z, make-proto-gdb.dir, setup-to-dist, gdb-XXX.tar.Z): - New rules for building distributions. Normal distribution - is built by doing `make -f Makefile.in gdb.tar.Z' in the directory - one level up from here; it calls make-proto-gdb.dir to build a - directory `proto-gdb' which is an image of the release. The old - `gdb.tar.Z' rule still works too. - * config.sub, configure: Roll in latest from .. - -Thu Sep 19 17:41:24 1991 Roland H. Pesch (pesch at cygnus.com) - - * doc/gdbint.texinfo: Reorder contents; reorganize new-host, - new-target, and new-config chapters; fix minor typos; come closer - to usual GNU markup conventions for @file @samp @code @var. - -Thu Sep 19 17:04:12 1991 Per Bothner (bothner at cygnus.com) - - Patches from Peter Schauer : - * mipsread.c (parse_partial_symbols): Enter the name of all - structs/unions... into the psymtab so we can access them if the - symtab is not read in. - * mips-tdep.c: Remove some unneeded #includes. - * xconfig/dec3100: Add HAVE_STRSTR. - -Thu Sep 19 15:14:23 1991 John Gilmore (gnu at cygnus.com) - - * Makefile.in: Circumvent Sun Make bug on *-exp.tab.o. - * c-exp.y, m2-exp.y: Lint. - * m2-exp.y: Avoid using yytname[] which is a Bison-ism. - * valprint.c (val_print_fields): Check for stub type. - * mipsread.c (_initialize_mipsread): Avoid using - builtin_type_void at initialize time. - (mipscoff_symfile_read): use it now. - -Wed Sep 18 15:55:51 1991 John Gilmore (gnu at cygnus.com) - - Merge multiple-language support, and partial Modula-2 support, - from Andrew Beers . - - * i387-tdep.c: New file, consolidates most 80387 support, - and eliminates host dependency on double<->extended conversions. - * i386-xdep.c, symm-xdep.c: Remove most 387 support. - * xconfig/i386{sco,v,v-g,v32,v32-g}: Now need i387-tdep.o. - - * symfile.c (allocate_symtab): New fn, consolidates the work - of allocating and initializing a new struct symtab. Set the - language of the symtab based on its filename extension. - * symfile.h: Declare it. - * mipsread.c (new_symtab): Use it. Minor formatting changes. - * dbxread.c (end_symtab): Use it. - - * mipsread.c (parse_symbol, case stParam and stProc): Add #if 0'd - code for saving types of parameters with each function definition. - * dbxread.c (define_symbol, function and parameter cases): Ditto. - (read_dbx_symtab, case N_DEFD): Ignore. - (read_enum_type): Recognize FALSE/TRUE enum as Modula-2 BOOLEAN. - (read_range_type): Rename MAX_OF_TYPE to MAX_OF_C_TYPE, etc. - #if 0 out its uses, though, since they set a dead value. - * coffread.c (end_symtab): Use allocate_symtab. - (process_coff_symbol): #if 0'd for functions and params as above. - (read_enum_type): Recognize Modula-2 BOOLEAN. - * symtab.c (add_param_to_type): #if 0'd function to add a - parameter type to a function type's field list. - - * defs.h (local_hex_format, local_hex_string, *_custom): Add. - * i386-xdep.c, pyr-tdep.c, pyr-xdep.c, remote-vx.c, solib.c, - source.c, symfile.c, dbxread.c, breakpoint.c, core.c, exec.c, - i387-tdep.c, infcmd.c, mips-tdep.c, stack.c, printcmd.c: Output - hex with local_hex_string for Modula-2 support. - - * breakpoint.c (breakpoint_cond_eval): Use new value_true to test - breakpoint condition language-independently. - - * parse.c: New file with the common code remains of expread.y. - * parser-defs.h: New file with common declarations from expread.y. - * c-exp.y: New file with the C parser from expread.y, and other - language-specific information. - * m2-exp.y: New file with the Modula-2 parser and etc. - * expread.y, expread.tab.c: Remove. - * breakpoint.c, eval.c, printcmd.c, expression.h: Use - parse_expression and parse_exp_1 rather than parse_c_expression - and parse_c_1. - - * symtab.h (enum languages): Move to defs.h. - (enum type_code): Add TYPE_CODE_CHAR and TYPE_CODE_BOOL. - Declare Modula-2 builtin types. - Add MAX_OF_TYPE and MIN_OF_TYPE macros. - - * symtab.c (_initialize_symtab): Remove builtin type - definition and initialization to *-exp.y. - (lookup_primitive_typename): Use language-dependent vector. - (lookup_typename): Fix bug, make it work if primitive typename. - (lookup_unsigned_typename): Call above. - (create_array_type): Set up range type for array index. - (list_symbols): Call typedef_print to print typedefs. - - * values.c (unpack_long, value_from_longest): Handle - TYPE_CODE_BOOL and TYPE_CODE_CHAR. - - * expression.h (enum exp_opcode): Add Modula-2 specific opcodes. - * expprint.c: Look up expression opcodes in language-specific - table, based on expression's language. Handle some Modula-2 - specific opcodes. - - * stack.c (frame_info): Print language of stack frame. - (select_frame): Also select language, if in auto-mode. - (get_frame_language): New subroutine. - * main.c (execute_command): Warn as language changes automatically. - - * printcmd.c (ptype_command): Parse types using the language - parser, both for language-independence, and so that scopes can - be specified. - - * language.h, language.c: New files for language-specific macros, - declarations, and definitions. - - Misc fixes: - - * main.c (main): If error() is called during early - initialization, print its message and then exit(1) from GDB. - - * valprint.c (type_print_base): Avoid printing garbage for ints - of unusual sizes. - (_initialize_valprint): Warn about host/target size assumption; - improve long long support slightly. - - * convex-tdep.c (comm_registers_info): Avoid parsing decimal and - hex -- let parse_and_eval_address do it. - - * doc/gdbint.texinfo (Languages): Doc how to add a language. - - * Makefile.in: Cope with new files and removed files. - -Tue Sep 17 08:37:41 1991 John Gilmore (gnu at cygint.cygnus.com) - - Add Andrew Beers' changes for Modula-2 support. His ChangeLog - entries are enclosed herein. Not all of these changes - have been merged into the master GDB sources -- check the - ChangeLog above here for the merge log. - -Mon Jun 3 17:05:45 EDT 1991 - - m2-exp.y Created. Tested outside of GDB for a few days. Proper - operators were added, C specific operators and tokens - removed. yylex() revamped to some extent. Still things - missing from the grammar, such as sets. - Tested for two weeks in GDB v3.5. - -Tue Jun 11 17:23:48 EDT 1991 - - m2-exp.y Added boolean constants TRUE and FALSE to the grammar - so they are built-in. Sort of a hack. - -Fri Jun 14 12:53:51 EDT 1991 - - m2-exp.y Added range checking for numeric constants. Any numeric - constant is assumed to be of builtin type INTEGER unless: - (1) it is octal or hexadecimal, in which case it is a - CARDINAL; (2) it is too big to fit into an INTEGER, in - which case it is a CARDINAL. - eval.c Added simple range checking for +, -, and * on integers. - Doesn't work very well for *, since 6 * 1,000,000,000 = - 1,705,032,704, which fails the simple test of result >= - first_operand, no matter in what order the operands are. - -Tue Jun 18 14:11:30 EDT 1991 - - Broke the parser into parts, one containing the C grammar and the other - containing code to be shared by all of the grammars. - - The following files no longer exist: - - expread.y - expread.tab.c - - The following files were added: - - c-exp.y (The C grammar) - m2-exp.y (The Modula-2 grammar) - parser-code.c (Code that is shared by the above grammar) - parser-code.h - parser-defs.h - - Makefile.dist Changed to reflect the above dependencies. NOTE: It is - now necessary to use the Bison compiler compiler, since it - will generate function/variable prefixes other than yy. - -Tue Jun 18 16:47:49 EDT 1991 - - symtab.[ch] Added the external variable working_lang, than holds the - value of the current working language. - Added the ennumerated type language_mode, with the values - language_auto and language_manual, the former meaning that - GDB sets working_lang as needed, and the latter meaning - that the value of working_lang is totally under user - control. - symtab.[ch] Added the Modula-2 pervasive types INTEGER, CARDINAL, - REAL, BOOLEAN and CHAR. Also added the type codes - TYPE_CODE_BOOL and TYPE_CODE_CHAR. - utils.c Added set_language_command and show_language_command to - implement the GDB support commands "set language" and - "show language". - expression.h A number of identifiers were added to the type exp_opcode - to facilitate Modula-2 builtin functions, integer - division, and array indexing. - -Wed Jun 19 13:25:58 EDT 1991 - - language.h Added the macro STRICT_TYPE, which evaluates to non-zero - if the language specified by working_lang requires the use - of strict typing of expressions. Eventually, even this - will be able to be changed by the user. - Added the macro RANGE_CHECK, which evaluates to non-zero - if the language specified by working_lang requires the - checking of a value against the domain of its type. - Eventually, even this will be able to be changed by the - user. - language.[ch] Predicates involving types (simple_type, ordered_type, - same_type, integral_type, numeric_type, character_type, - boolean_type, float_type) are added. These predicates are - based on the current value of working_lang, and are handy - in type-checking. - -Wed Jun 19 15:39:34 EDT 1991 - - eval.c Added the function type_array_rank which computes the rank - of an array type. - valarith.c Added the funtion value_bool, which when given a integer - value.h value (ie. struct value *) as an argument, it returns a - boolean value (ie. struct value *) true if that integer - is non-zero, and a boolean value false otherwise. - valprint.c Added cases for TYPE_CODE_BOOL, so Modula-2 BOOLEAN values - will print out properly. - -Wed Jun 19 16:36:34 EDT 1991 - - valops.c Added the function value_capitalize, which returns it - value.h argument capitalized if its argument is a lowercase - letter, or the argument unchanged if its argument is not a - letter. - valarith.c Added the function range_check_p, which returns non-zero - value.h if its value argument is between the integral bounds upper - and lower. - Added the function range_check_enum_p, which makes sure - that its value argument is a valid member of the domain of - its type argument. - Added the function range_check_range_p, which makes sure - its value argument lies between the upper and lower bounds - of its type argument, which must be a ranged type. - Added the function check_array_index, which range and type - checks an index of an array. - Added the function value_multi_subscript, which computes - array[idx1,idx2...idxN], given a value array and an array - of values representing indicies. - values.c Changed value_from_long to work with TYPE_CODE_CHAR and - unpack_long to work with TYPE_CODE_BOOL and - TYPE_CODE_CHAR. - -Wed Jun 19 18:04:08 EDT 1991 - - symtab.c Stored pervasive types in a structure and make - lookup_pervasive_type() a lookup function that was based - on working_lang. If lookup_pervasive_type() returned - non-zero, then that value was returned (a fix, since - before it simply wouldn't return the pervasive type.) - language.h Added the macro CAST_IS_CONVERSION, which evaluates to - non-zero if the language specified by working_lang means - "conversion" when it says "cast". - valops.c Added the function value_real_cast(), which performs a - value.h *cast*, not a *conversion*, which is what value_cast() - does when it can. In particular, - value_cast(,4) = 4.0, while - value_real_cast(,4) = some mess. - eval.c Modula-2 builtin functions implemented: ABS, CAP, CHR, - parser-code.c FLOAT, HIGH, MAX, MIN, ODD, ORD, TRUNC, and VAL. - expression.h Added macros MAX_OF_TYPE and MIN_OF_TYPE to work with MAX - and MIN on integral types. *NOTE*: These are currently - hardcoded to work only if there are 8 bits per storage - unit. FIXME. - eval.c Made logical functions call value_bool to return a - properly typed boolean value, based on working_lang. - -Thu Jun 20 11:55:27 EDT 1991 - - valprint.c Types now print out in a Modula-2 fashion. This works for - the cases when the type is printed out step-by-step, that - is, it doesn't work when the name of a structured type - (which includes the keyword "struct", etc.) is simply - displayed. - FIXME: Perhaps this is bad. Parts of it seem to kludgey, - since type specifications in C and Modula-2 are very - different. The C printing of a type is very recursive, - whereas in Modula-2 it is generally very simple. C has - type prefixes and suffixes, which have no real analogue in - Modula-2. Maybe type_print() should call a language - specific type printer. This is also advantageous if we - compile GDB to exclude some of the languages. We'll just - leave those functions out. - -Thu Jun 20 16:57:10 EDT 1991 - - dbxread.c When reading the complete symbol table in (via - psymtab_to_symtab()), the number and types of function - arguments are added to a function type. define_symbol() - calls add_param_to_type() to accomplish this. - Assumption: when we come across a function definition - (N_FUN symbol with an 'f' or 'F' in the name), its - arguments will appear before another function definition. - When a function is found, a pointer to its type is placed - in the global in_function_type. Changes that - add_param_to_type() makes are to this global. - valprint.c The type of a function now includes (for Modula-2) the - types of its parameters. - eval.c Type checking and a check for the proper number of - arguments is now done for function calls. Not sure of the - impact this has on C++ member function yet. - -Thu Jun 20 19:58:48 EDT 1991 - - valprint.c Rewrote the type printer. Broke it into two language - specific parts, adding the functions type_print_m2() and - type_print_m2_1(). - An unfortunate consequence is this: if you debugging a C - program in Modula-2 mode (why?), info types does not work - well with regular expressions, since the types are printed - out in Modula-2 terminology, but stored in C terminology. - language.[ch] Added the functions new_type_last(), type_keyword(), and - type_sep() to aid in the printing of typedefs. - symtab.c Made the printing of typedefs as language independent as - possible through calls to new_type_last(), type_keyword(), - and type_sep(). - -Fri Jun 21 11:50:26 EDT 1991 - - dbxread.c Check all incoming ennumerated types. If it looks like - Modula-2's BOOLEAN type, then change the type_code of the - type to TYPE_CODE_BOOL so we can process it as a boolean - variable. - valprint.c Replaced some of the 0x%x with calls to sprintf and - hexformat() in val_print(). - language.[ch] Added the function hex_to_string(), which converts its - integral argument to a hexadecimal number (format is - language based) and returns the result as a string. - -Mon Jun 24 12:25:07 EDT 1991 - - valprint.c Some functions call type_print_1() directly, instead of - value.h using type_print(), so they can specify where (column) to - print things. Since type_print() takes care of language - dependence, that needs to be called first. Added a - parameter depth to type_print() (so it is now like - type_print_1). Changed type_print to type_print_at, and - made type_print a macro that passes a depth argument of - zero. - symmisc.c Changed all calls to type_print_1 to calls to - type_print_at. - Makefile.dist Made it possible to build GDB for a specific set of - depend languages. Do this by passing a definition for the macro - LANGS to make. LANGS should be a string containing a - space-separated list of language names (ie. LANGS="c m2"). - The default is to build all languages. Note that grammar - files must follow the naming convention of -exp.y. - gdb.lang This holds the current value of the LANGS macro. It is - examined every time make is called, and is updated if - necessary. - eval.c Added #ifdef _LANG_ to these files. - expread.c Still need to add them to dbxread.c and coffread.c. - main.c - source.c - symtab.c - utils.c - valarith.c - valprint.c - -Mon Jun 24 16:33:11 EDT 1991 - - language.[ch] Added the functions hexformat_pre() and - hex_to_string_pre(), which take a prefix argument to - include in the format string. Thus, hexformat_pre("08") will - return "0x08x" (if the working language is language_c). - Made hexformat() and hex_to_string() calls to the above - with "" as the prefix argument. - - am29k-pinsn.c, arm-pinsn.c, breakpoint.c, convex-tdep.c, exec.c, core.c, - dbxread.c, i386-pinsn.c, i386-stub.c, i386-xdep.c, i960-pinsn.c, - infcmd.c, inflow.c, m68k-pinsn.c, m68k-stub.c, m88k-pinsn.c, - mips-pinsn.c, mips-tdep.c, ns32k-pinsn.c, printcmd.c, pyr-pinsn.c, - pyr-tdep.c, pyr-xdep.c, remote-vx.c, remote.c, solib.c, source.c, - stack.c, sun386-xdep.c, symfile.c, symm-xdep.c, symmisc.c, tahoe-pinsn.c, - valprint.c, vax-pinsn.c - - Changed all occurences of 0x%[0-9]*l*x in printf format strings to - calls to hexformat() and hex_to_string(). Format strings without - the leading "0x" were ignored. - - depend Updated to take the above into account. - - -Tue Jun 25 15:27:18 EDT 1991 - - symtab.h Added the types range_mode_t, range_check_t, type_mode_t, - and type_check_t to keep track of the current state of - range and type checking. - main.c Added the variables range_mode, range_check, type_mode, - and type_check to record the current state of range and - type checking. Added initialization code to main(). - language.h Changed the macros STRICT_TYPE and RANGE_CHECK to examine - the above variables. - - -Tue Jun 25 17:57:08 EDT 1991 - - dbxread.c process_one_symbol() updates the variable (enum language) - source_lang based on the extension of the filename - contained in the N_SO sybmol that started this symtab. - When end_symtab() is called, the value of source_lang is - put into the language field. - stack.c select_frame() sets working_lang (and possibly type_check - and range_check) to the language field of the symtab - associated with the frame that is selected if working_mode - is language_auto. If working_mode is language_manual, a - warning is printed and working_lang is not set. - language.c Added the function set_type_range(), which sets the value of - type_check and range_check (if their modes call for - automatic setting) based on the current value of - working_lang. A non-zero argument will cause the current - settings to be output. - - -Wed Jun 26 14:51:40 EDT 1991 - - eval.c Added range checks on assignment. - m2-exp.y Added the grammar for sets to the language. Currently, - these do not do anything except print an error message. - -Wed Jun 26 17:01:04 EDT 1991 - - m2-exp.y Added the ability for parse_number() to parse negative - numbers. A global flag is set upon encountering a unary - minus. This was done to make, for example, 1 parse as a - CARDINAL, and not as an integer, per Wirth's examples in - Programming in Modula-2 ed.4. - valprint.c Added support for "set radix 2" by then setting - output_format to 't'. - eval.c Implemented range checking on subrange types. Added calls - to range_check_range_p for BINOP_ASSIGN and BINOP_VAL. - Implemented MIN and MAX for ennumerated types. The - minimum value of an ennumerated type is defined by Wirth - as the first identifier, and the maximum as the last. - m2-exp.y Made octal numbers ending with "B" be characters and those - ending with "C" be numbers, per Wirth's book. (p. 34) - -Thu Jun 27 14:11:52 EDT 1991 - - stack.c select_frame() now only sets working_lang, it does not - notify the user. If working_mode is language_manual, then - a warning is issued once. - main.c At the end of each call to execute_command(), working_lang - is checked against the local static (enum language) - current. If they differ and working_mode is - language_auto, the new settings of language, type and - range checking are printed out. - stack.c Modified frame_info() to include the language of the - current frame in the output of "info frame". - language.[ch] Added the function language_str() which returns the name - of the current language. - -Fri Jun 28 15:33:14 EDT 1991 - - m2-exp.y Added the built-in procedures INC, INCL, DEC, and DECL to - the language. INCL and DECL currently cause an error, - since sets are not implemented yet. INC and DEC are - implemented as PREINCREMENT/PREDECREMENT with one - argument, and as ASSIGN_MODIFY with two arguments. - eval.c Added type checking to the above cases. - value.h Added not_lval_constant to the lval_type ennumerated type. - not_lval_constant means that the value is a constant - value; that is 3 or 'a' or TRUE, not as in a constant - identifier. This is used to help coerce numbers such as 3 - to either signed or unsigned numbers. - valops.c Added the function value_coerce_constants() which coerces - constant integers as following: if one is a constant and - the other is not, the constant's type is set to the type - of the other argument. If both are constants and one is - signed, the other is converted to a signed constant. - -Sat Jun 29 17:26:29 EDT 1991 - - valarith.c Added a better range checker. It now checks range - (successfully) on integral operations [+-] (signed and - unsigned) for any C sized type. Still does not work well - for multiplication.) - int_in_size() returns an integer that is coerced to fit into - specified number of bytes. - -Mon Jul 1 13:04:14 EDT 1991 - - language.[ch] Added the function binop_result_type(), which returns the - builtin (struct type *) type that would be the result of a - binop on the two values V1 and V2. - -Wed Jul 3 19:22:53 EDT 1991 - - source.c Extended source_info() to include the source language in - the output from "info source". - -Fri Jul 5 13:48:52 EDT 1991 - - utils.c Moved the support functions for the GDB set/show commands - dealing with language into language.c. - language.c Added the function language_info(), which displays info - about the current working language, type and range check - settings. Called via the GDB command "info language". - Added an initialization routine _initialize_language(), - that sets defaults for the language, type and range - variables and sets up the new GDB commands. - main.c Language setup moved to language.c. - depend Rebuilt. - -Mon Jul 8 10:10:22 EDT 1991 - - valarith.c Debugged the range checker for arithmetic. Still does not - work for multiplication very well. - -Mon Jul 8 12:40:37 EDT 1991 - - language.[ch] Added the function value_true() which returns non-zero if - its argument represents a boolean true value. - breakpoint.c Changed breakpoint_cond_eval() to call value_true() to - check the truth of an expression. - -Thu Jul 11 12:51:34 EDT 1991 - - language.[ch] Added the predicate structured_type(), which returns - non-zero if the argument is a structured type. - Added the predicate pointer_type(), which returns non-zero - if the argument is a pointer type. - eval.c Added the ability to do addition and substraction on - pointers and integers. This case simply bypasses the - type checker. - -Thu Jul 11 14:41:42 EDT 1991 - - include/stab.def - Added the symbol N_DEFD (0x4a) which is a definition - module dependency that is used by the GNU Modula-2 - compiler and the linker. It is not important to GDB, - except that [dbx|coff|mips]read.c should ignore these - symbols. - -Fri Jul 12 16:07:00 EDT 1991 - - valprint.c Changed the TYPE_LENGTH(type) >= 0 to TYPE_LENGTH(type) > - 0 in val_print(). Also added statements to the else part - to coerce type (argument to val_print) to a pointer type - if it is an "array of unspecified length". - valops.c Added the function value_m2_string(), which returns a - (value) value which is a constant string, whose type is - (ARRAY [0..n] OF CHAR). The length field of the type - structure is set to zero, so it will be interpreted as an - "array of unspecified length". - stack.c Moved the language/frame mismatch check to - main.c:execute_command(). - main.c The working language is recorded each time - execute_command() is executed. If working lang has - changed during its execution, then the new - language/type/range info is printed out for the user. If - the working language does not match the language of the - frame, a warning is issued. - -Sat Jul 13 16:16:39 EDT 1991 - - eval.c Moved all the type-checking stuff for operators to - language.[ch] language.c. This is so we can keep language-specific - stuff (like for what type operators are defined) in - language.c. - language.[ch] Added the function binop_type_check(), which checks to see - if its two (value) arguments are type-compatible with its - opcode argument. The opcode should represent an operation - involving an operator. Also added the macro function - unop_type_check, which calls binop_type_check with a - NULL second argument. - expprint.c Added Modula-2 operators to the op_print_tab, so info - expression.h break works correctly. Also added "op_string", which - returns the string corresponding to the (enum exp_opcode) - opcode that is its argument. - - -Sat Jul 13 18:26:18 EDT 1991 - - coffread.c Added code to record the type of function arguments with - each paricular function. Code is very similar to that - added to dbxread.c. - dbxread.c Moved add_param_to_type() to symtab.c - symtab.[ch] Added function add_param_to_type() from dbxread.c - - *** NOTE: The above additions have not been tested. - -Mon Jul 15 12:50:47 EDT 1991 - - langauge.[ch] Added the functions type_error and range_error, which work - like error() except if the type/range mode is set to - *_mode_warn, then they do not do a return_to_top_level(), - but merely print a warning. - Also changed [set|show]_[type|range]_command() to support - the new "warn" feature. - -Thu Jul 18 17:50:54 EDT 1991 - - mipsread.c Added code to record the type of function arguments with - each particular function. Code is very similar to that - added to dbxread.c. - - *** NOTE: The above additions have not been tested. - -Fri Jul 19 11:19:10 EDT 1991 - - defs.h Added macros MAX_OF_SIZE, MIN_OF_SIZE, UMAX_OF_SIZE, and - UMIN_OF_SIZE, which when given a size of a numeric type, - return the maximum and minimum value it can hold. UMAX... - and UMIN... return the result for unsigned types. - symtab.h Added the macros MAX_OF_TYPE and MIN_OF_TYPE to operate on - struct types. They call above macros. - dbxread.c Renamed the MAX and MIN_OF_TYPE macros to ..._OF_CTYPE to - avoid a name conlict with the above. - c-exp.y Added range checking on numeric constants in - parse_number() for completeness. - valarith.c Made binop_user_defined_p() and unop_user_defined_p() - return 0 if working_lang is not language_c. - -Thu Aug 8 14:17:22 EDT 1991 - - main.c - printcmd.c - breakpoint.c Documentation strings of some commands changed to - eliminate the references to the C language where - appropriate. - -Tue Aug 13 15:48:03 EDT 1991 - - m2-exp.y Added qualified identifiers to the grammar. The semantics - are slightly different from those of the GDB operator :: - c-exp.y - m2-exp.y Added a rule to each grammar of the form: start ::= exp | - type_exp, where type_exp is any valid type expression. - expression.h - eval.c Added the opcode OP_TYPE, and an error case in eval.c. - printcmd.c Modified ptype_command() so it actually parses the input - (necessary for type expressions with scope qualifiers). - Added the function ptype_eval() which expects an - expression composed of one OP_TYPE element. - *.[ch] Replaced all occurences of parse_c_expression with - parse_expression - *.[ch] Replaced all occurences of parse_c_1 with parse_exp_1 - -[End of ChangeLog entries from Andrew Beers for Modula-2 support.] - -Mon Sep 16 17:19:46 1991 John Gilmore (gnu at cygnus.com) - - Small fixes from Peter Schauer: - - * infrun.c (child_attach): Lint. - * solib.c (find_solib): Handle shared libs version 2. - - Small fixes from David Wood: - - * xm-ultra3.h (SYS_SIGLIST_MISSING): Typo. - - Small fixes: - - * remote-vx.c: Move to top, for FILE. Fix from - John S . - - * utils.c (wrap_here): Avoid wrap action of fputs_filtered if - chars_per_line is at maximum (user typed `set width 0'). Fix - from Andreas Schwab . - -Tue Sep 17 17:31:04 1991 Stu Grossman (grossman at cygnus.com) - - * coredep.c: include ptrace.h where necessary. - * mipsread.c(parse_lines): fix unsigned char problem that was - messing up line numbers on SGI's and possibly other MIPS based - platforms. - * infrun.c (child_create_inferior): use better test to check - return val from setpgrp(). - * tm-irix3.h, xm-irix3.h, tconfig/irix3, xconfig/irix3: add these - for sgi/irix support. - -Wed Sep 18 04:33:31 1991 Per Bothner (bothner at cygnus.com) - - * mipsread.c (parse_symbol): Put non-static procedures - in the global block. - -Fri Sep 13 00:14:52 1991 John Gilmore (gnu at cygnus.com) - - Patch together `text_start' and `text_end' for 29K port. - - * exec.c (exec_command): If NEED_TEXT_START_END, define the - variables and set them based on the exec file. - * am29k-tdep.c: declare text_start. - * valops.c (call_function_by_hand): declare text_end. - - * inferior.h: Eliminate CANNOT_EXECUTE_STACK in favor of - defining CALL_DUMMY_LOCATION as BEFORE_TEXT_END. This is - because machines that do this will also have to know to - set NEED_TEXT_START_END. Besides, it was a redundant way to - say the same thing. - * tm-29k.h, tm-convex.h, tm-np1.h: Eliminate - CANNOT_EXECUTE_STACK, define CALL_DUMMY_LOCATION and - NEED_TEXT_START_END. - -Thu Sep 12 00:22:24 1991 John Gilmore (gnu at cygint.cygnus.com) - - AMD 29000 changes from David Wood : - - * Makefile.in (CLIBS): Put XM_CLIBS and TM_CLIBS at end. - Pass MUNCH_DEFINE to munch whenever we run it. - * am29k-pinsn.c (print_insn): Handle NOP specially. Avoid %#x - format string; use 0x%x instead. - * am29k-tdep.c: Use DUMMY_SAVE_GREGS and RETURN_REGNUM. - * ultra-xdep.c, xm-ultra.h: New files for Ultracomputer host system. - * xm-rtbsd.h: New host support for RT/PC running BSD Unix. - * inflow.c: Handle `short' process group IDs. - * infptrace.c (fetch_register): Support CANNOT_FETCH_REGISTER, - and check for ptrace errors. - * coffread.c (SDB_REG_TO_REGNUM): Define if not already. - (coff_symfile_init): Initialize text_bfd_scnum. - (read_coff_symtab): Use it to find the text [and absolute?] sections. - * ../config.sub: Add vendor nyu and os "sym[1-9]*". - * configure.in: Add hosts rtpc-*-* and a29k-*-*. - Merge target arm case with other "easy" cases. Add target - cases a29k-*-none (rehack of am29k), a29k-*-kern (remote to - Ultracomputer kernel), and a29k-*-sym1 (ultracomputer OS's user - process). - * minimon.h, remote-adapt.c, remote-mm.c: Add. - * munch: Cope with RT/PC putting fns in data segment. - Restore ability to override `nm' by specifying MUNCH_NM. - * xconfig/rtbsd, xconfig/ultra3: New host systems. - * tconfig/a29k: Rename from tconfig/am29k. Add remote-mm - and remote-adapt. Remove encapsulated coff #define's (the - support should go in BFD, and gdb shouldn't know or care). - * tconfig/a29k-kern: Same, but for remote kernel debugging. - * tconfig/ultra3: For debugging user processes on Ultra3/Sym1. - * tm-29k.h: Update BADMAG (though it should go away). - Allow the register definitions to be overridden in another - tm-file. Fix SR_REGNUM. Add a mess of _REGNUM's. Separate - RETURN_REGNUM from GR96_REGNUM and DUMMY_SAVE_GREGS from - DUMMY_SAVE_GR96, for handling kernel calling conventions - that use GR64+ rather than GR96+. - * tm-ultra3.h: New file, for use on Ultra3 Unix as well as for - remote debugging of Ultra3 kernel. Includes tm-29k.h and - overrides various things. - - * remote-mm.c (mm_attach, mm_wait): Handle attach like - child_attach does, making a clean stop in the newly attached - program. - * remote-eb.c: Lint. - - * coffread.c: Make coffread independent of any particular - variant of COFF. Avoid #include-ing any particular one except - internalcoff.h. BFD now passes key values for symbol reading - as part of its coff_data structure (LINESZ, SYMESZ, AUXESZ, - and the symbol masks and shifts); use them. - Remove obsolete end_of_text_addr. - - * exec.c: Remove unused include files. - -Wed Sep 11 19:38:44 1991 John Gilmore (gnu at cygint.cygnus.com) - - * Makefile.in (documentation targets): Pass $(M4). - Bugfix from eggert@twinsun.com (Paul Eggert). - - * stack.c (down_silently_command): Check for stack existence. - -Tue Sep 10 23:08:29 1991 John Gilmore (gnu at cygint.cygnus.com) - - * Makefile.in (VERSION): Update to 4.0.3. - -Tue Sep 10 09:19:29 1991 John Gilmore (gnu at cygint.cygnus.com) - - * core.c (core_file_command): Print frame at coredump with - its level number, by calling print_stack_frame. - * frame.h: Add selected_frame_level, print_stack_frame. - * frame.h, stack.c: Remove print_sel_frame, print_selected_frame. - * convex-tdep.c, convex-xdep.c, infcmd.c, inflow.c, infrun.c: - Change print_sel_frame and print_selected_frame callers to - print_stack_frame. - - * dbxread.c (read_ofile_symtab): Avoid empty else clause. - * symfile.c (free_named_symtabs): Ditto. - * main.c (main): wrap_here needs an arg. - * solib.c (find_solib): Avoid memory access if _DYNAMIC is zero. - (solib_add): Avoid noise. - (solib_create_inferior_hook): Lint. - (sharedlibrary_command): Move dont_repeat to here. - * utils.c (error): Call wrap_here to force buffered output. - - Small patches from Peter Schauer: - - * coffread.c (start_symtab): Free any existing line_vector before - malloc-ing new one. - (read_coff_symtab): Ditto for type_vector. - - * source.c (lines_to_list): New variable, replacing function. - (all uses): Use as variable. - (_initialize_source): Add 'set listsize' and 'show listsize'. - * utils.c (lines_to_list): Remove function. - * stack.c (print_frame_info): Use as variable. - * defs.h (lines_to_list): Remove declaration. - -Mon Sep 9 13:45:57 1991 John Gilmore (gnu at cygint.cygnus.com) - - * breakpoint.c (insert_breakpoints): Restore warning about - the program might be running in another process, but only for - systems with this brain death (#ifdef ONE_PROCESS_WRITETEXT). - * xm-hp300bsd.h, xm-mips.h, xm-vax.h: Define it. - - * utils.c (error): if error_pre_print is set, print the string - first. - * main.c (main, print_gnu_advertisement, print_gdb_version): - Reformat legalese so it always prints, but acts as an "I'm here" - message while symbols are being read. If any errors occur, - print a few newlines to set off the message and start it at the - left margin. Remove mention of "help" command, and don't yak - about symbol reading. - (catch_errors): Error string is now printed first in case of - error, not last. - * command.c (undef_cmd_error, lookup_cmd): On undefined command, - suggest the "help" command. - - * Makefile.in (VERSION): Set to 4.0.2. - -Thu Sep 5 23:49:48 1991 John Gilmore (gnu at cygint.cygnus.com) - - * .gdbinit: Remove useless "rr" command. Set complaints - to 1 for people debugging gdb. - - * breakpoint.c, remote-vx.c: Reword strings printed by - catch_errors callers. - -Wed Sep 4 11:07:50 1991 John Gilmore (gnu at cygint.cygnus.com) - - * WHATS.NEW: "history write -> history save". Doc "write on/off". - (Fix from kenc@viewlogic.com.) - - Fix some infrastructure to be able to cope with host and target - machines with different sized basic types (ints, ptrs, etc). - (Idea from pierre@la.tce.com (Pierre Willard).) - - * values.c (value_from_longest): Rename from value_from_long. - Handle pointer types as well as integers, so that targets with - different pointer sizes from the host can be accomodated. - * breakpoint.c, convex-tdep.c, eval.c, expprint.c, printcmd.c, - valarith.c, valops.c, valprint.c, value.h, values.c: Rename - uses of value_from_long to value_from_longest. - * eval.c, findvar.c, printcmd.c, valarith.c, valops.c: Pass - the correct pointer type to value_from_long{est}. - - * doc/gdb.texinfo ($_, $__): Describe types of these variables. - - * remote-vx.c: Remove obsolete code for calling functions via - vxworks kludge interface (it referenced value_from_long). - - * valops.c (value_string): Find malloc with lookup_misc_func, not - raw search. - -Tue Sep 3 18:37:46 1991 John Gilmore (gnu at cygint.cygnus.com) - - Make writing to files work properly. (Fixes to BFD are also needed.) - - * core.c (core_open): Open file ourselves, read or r/w, depending on - write_files. Use bfd_fdopenr. - * gdbcore.h (write_files): New variable. - * exec.c (write_files): Define variable, add set&show for it. - (exec_file_command): Use write_files to open for read or r/write. - - Make shared library reading happen automatically. These changes - are mostly from Peter Schauer . - - * inferior.h (stop_soon_quietly): Add to exported variables. - * infrun.c (child_create_inferior): call solib hook, if defined. - (child_attach): call solib hook, if defined. - * solib.c: Include inferior.h. Add from_tty to so_list as kludge. - (find_solib): Use lookup_misc_func rather than hand-rolled. - (symbol_add_stub): New stub for catch_errors. - (solib_add): Avoid output if !from_tty. Catch errors rather - than just calling symbol_file_add and bombing. - (solib_create_inferior_hook): Interface with the target process - to let it read and alloc shared libs, then figure out what it did. - - * core.c (validate_files): Fix typo, soften warning. - (Fix from Hiroto Kagotani .) - - * utils.c (fputs_demangled): Avoid duplicate printing if - demangling is off. (Fix from J.T. Conklin .) - - * infrun.c (proceed): Cast -1 to (CORE_ADDR) before comparing. - (Fix from pierre@la.tce.com (Pierre Willard).) - - * main.c (catch_errors): Change argument to a char * from an int, - since a char * can point to a struct full of glop, but an int - is not guaranteed to be able to hold a pointer. - * breakpoint.c (breakpoint_cond_eval, bpstat_stop_status, - breakpoint_re_set_one, breakpoint_re_set): Adapt. - * core.c (core_open, solib_add_stub): Adapt. - * remote-vx.c (symbol_stub, add_symbol_stub, callers): Adapt. - -Wed Aug 28 18:18:05 1991 John Gilmore (gnu at cygint.cygnus.com) - - * Makefile.in: Update VERSION to 4.0.1. Evade GNU Make bug - by adding .NOEXPORT target. - -Fri Aug 23 17:14:25 1991 John Gilmore (gnu at cygint.cygnus.com) - - * GDB-4.0 release! - * Update README. - * Makefile.in (VERSION): Roll to 4.0. - (gdb.tar.Z): Make refcard.ps as well, for shipment. - -Fri Aug 23 14:07:09 1991 Roland H. Pesch (pesch at cygint.cygnus.com) - - * doc/gdb.texinfo: minor rewordings, crossref to ptype from print, - more on printsyms. - - * doc/Makefile, Makefile.in: generate "gdb-all.texi" rather than - "gdb-all.texinfo" - - * doc/rdl-apps.texi: renamed from rdl-apps.texinfo - - * Makefile.in, doc/Makefile, doc/.Sanitize, doc/gdb.texinfo: - reflect above name change - - * WHATS.NEW: correct pointer to refcard. - - * doc/gdb.texinfo: update New Features, Installing - - * doc/gdbint.texinfo: add short description of configure +template - -Fri Aug 23 11:46:08 1991 Roland H. Pesch (pesch at cygint.cygnus.com) - - * doc/gdb.texinfo: update, fix bugs in "Installing" appendix - -Fri Aug 23 01:02:00 1991 John Gilmore (gnu at cygint.cygnus.com) - - * Makefile.in: Add config.sub, make doc/rdl-apps.texinfo for - tar file, add dependencies for referenced doc files. - -Thu Aug 22 22:17:06 1991 Stu Grossman (grossman at cygint.cygnus.com) - - * coffread.c, symfile.c, stack.c: saberized. - -Thu Aug 22 16:20:27 1991 Roland H. Pesch (pesch at cygint.cygnus.com) - - * doc/refcard.tex: permuted Essential Commands sec - - * doc/gdb.texinfo: new C++ chapter; revised installation appendix; - new doc for - set/show symbol-reloading - default set complaints 0 - info all-registers - RET-repeat disabled after prompted long displays - processID (attach) interpretation of 2nd GDB cmdline arg - -Thu Aug 22 14:05:47 1991 Stu Grossman (grossman at cygint.cygnus.com) - - * expread.y, coffread.c, dbxread.c, target.c, mem-break.c, - cplus-dem.c, values.c, valprint.c, symfile.c, remote.c, - breakpoint.c, main.c: lint. - -Thu Aug 22 02:02:26 1991 John Gilmore (gnu at cygint.cygnus.com) - - Install new configuration scheme for GDB and friends. - - * config.sub: Translate ordinary names to three-part names. - * configure: Use three-part names internally. - * configure.in: Translate three-part names to filenames. - - * README, WHATS.NEW: Update for gdb-4.0. - * Makefile.in: Roll VERSION to 3.99. - -Wed Aug 21 18:21:09 1991 John Gilmore (gnu at cygint.cygnus.com) - - * infptrace.c (KERNEL_U_ADDR_BSD): Include a.out.gnu.h. - * i960-tdep.c, m68k-tdep.c, sparc-tdep.c, tm-i960.h, - tm-m68k.h, remote-nindy.c: Change ext_format_XXX structs - to single structures rather than arrays; when passing - their address, use &. This avoids trouble with bdead compilers. - * mcheck.c: Don't include ; just declare "void abort();" - instead. This avoids portability headaches. - * mips-tdep.c (mips_do_registers_info): Only print FP regs if - asked to. - * source.c (open_source_file): Avoid ANSI const bdeath by - skipping declaration and then casting result value. - * tm-hp300bsd.h: Clarify comment. - * utils.c (strstr): Result is const char *; ANSI bdeath. - * xm-hp300bsd.h: Define HOST_BYTE_ORDER. Redefine INT_MIN, - since system include file defines it differently from "defs.h", - though the two are equivalent for our purposes. - * tconfig/hp300bsd: Add m68k-tdep.o. - -Tue Aug 20 16:01:11 1991 John Gilmore (gnu at cygint.cygnus.com) - - * tconfig/sun*4: Remove warnings about system assembler. - -Mon Aug 19 13:44:46 1991 John Gilmore (gnu at cygint.cygnus.com) - - * mcheck.c: Avoid warning about undeclared abort fn. - * tm-sparc.h (PC_ADJUST): Avoid calling error() from this; - it causes recursive calls to error() when used in cleanups. - To do so requires that we make it a function, so we do. - * sparc-tdep.c (sparc_pc_adjust): New implem of PC_ADJUST. - * utils.c (do_cleanups): Remove the current cleanup from the - chain *before* calling it, in case error() is called from it. - The result won't be pretty, but won't be an infinite loop either. - -Mon Aug 19 00:41:04 1991 Michael Tiemann (tiemann at cygint.cygnus.com) - - * dbxread.c (read_struct_type): Grok anon structs for C++. - (vb_name, vptr_name): Null terminate these strings. - -Fri Aug 16 08:31:03 1991 John Gilmore (gnu at cygint.cygnus.com) - - Minor bug fixes from BSD Net2 gdb: - - * blockframe.c (get_prev_frame_info): If FRAME_CHAIN_COMBINE - returns 0, there is no previous frame. - * breakpoint.c (commands_command): If !from_tty, don't call - input_from_terminal_p(). - * dbxread.c (record_misc_function): Speed up slightly. - (compare_psymbols): Ditto. - * infcmd.c (do_registers_info): Take a second argument to - determine whether to print float registers. "info registers" - does not do so anymore. "info all-registers" does, now. - * mips-tdep.c, pyr-tdep.c (xxx_do_registers_info): Take second - arg and ignore it. - * tm-mips.h, tm-pyr.h (DO_REGISTERS_INFO): Pass second arg. - * inflow.c (initialize_inflow): Set tflags_ours correctly. - - Other fixes: - - * breakpoint.c (bpstat_do_actions): Use a cleanup to restore - executing_breakpoint_commands if we are interrupted by error. - * coffread.c (init_lineno): Avoid problem with zero-sized linetab - versus malloc/free. From: john@labtam.labtam.oz.au (John Carey). - * core.c (solib_add_stub, core_open): Call SOLIB_ADD inside a - catch_errors() so we can setup the frame regardless of whether - the shared libs work. - * ieee-float.c (double_to_ieee_extended): Get exponent from - right place in little-endian systems. From John Carey. - -Thu Aug 15 18:43:57 1991 John Gilmore (gnu at cygint.cygnus.com) - - * main.c: Remove unused terminating_signals and catch_termination(). - (long_options): Terminate with a zero element. - [Bugfix from Atsuo Kawaguchi .] - (gdb_readline): Make call-compatible with readline. - (init_signals): Improve comments re vfork vs. signal. - - * utils.c (prompt_for_continue): Use new gdb_readline(). - If we prompt for continuation, we don't let CR repeat the previous - command, once we get back to a prompt. It's too easy to keep - hitting CR, expecting "--more--" prompts, and have some long - command start repeating on you. - -Tue Aug 13 16:17:56 1991 John Gilmore (gnu at cygint.cygnus.com) - - * blockframe.c (frameless_look_for_prologue): Speed up by - calling SKIP_PROLOGUE_FRAMELESS_P if it's defined. - * tm-sparc.h (SKIP_PROLOGUE, SKIP_PROLOGUE_FRAMELESS_P): - Define two variants, one faster. - * sparc-tdep.c (sparc_frame_chain): Use target_read_memory - and return zero, rather than giving an error. - (setup_arbitrary_frame): Initialize the PC in the new frame. - (skip_prologue): Add a second arg saying whether we're just - checking for a frameless function or not. - - * core.c (core_open, core_close, core_xfer_memory): Move - section table pointers and bfd* into the target_ops. - (core_open): Allow errors in shared lib reading, etc. - (core_files_info): Describe shared library sections. - - * exec.c (exec_open, exec_close, exec_xfer_memory, xfer_memory, - exec_files_info, set_section_command): Move section table - pointers and bfd* into the target_ops. - (add_to_section_table): Add BFD to section table. - - * target.c (target_xfer_memory, target_info): Pass target to - xfer_memory and target_info functions. - * target.h: '' - - * gdbcore.h: Move struct section_table. - * target.h: New home of struct section_table. - - * solib.c (solib_add): New argument is the target_ops whose - section list is to be added to, if any. Reallocate the - sections in that target to add any that come from shared libs. - (throughout) so_sections renamed to sections. - (solib_xfer_memory): Deleted. - * tm-sunos.h (SOLIB_ADD): Add target argument. - (SOLIB_XFER_MEMORY): Delete. - - * core.c, exec.c, inftarg.c, remote-eb.c, remote-nindy.c, - remote-vx.c, remote.c, target.c, target.h: Remove add_syms vector - from target_ops. It's the same on all targets. Add two section - pointers to target_ops. - - * stack.c (find_relative_frame): Dump ancient algorithm for - "down", just use handy "next" pointers. - (frame_command): Don't error if there is no stack; let user - set one. - - * inflow.c (new_tty_prefork, new_tty): New prefork routine - modifies static state in the parent process; new_tty itself - runs in the child and modifies the child's file descriptors - to match the saved static state. - * infrun.c (child_create_inferior): Call new_tty_prefork, - fork, then new_tty. - - * infptrace.c (child_xfer_memory): Add ignored target arg. - * remote-eb.c (eb_xfer_inferior_memory): '' - * remote-nindy.c (nindy_xfer_inferior_memory): '' - * remote-vx.c (vx_xfer_memory): '' - * remote.c (remote_xfer_memory): ''. Rename from - remote_xfer_inferior_memory. - - * main.c (main): Only try to attach "corefile" argument if - it starts with a digit. - - * symfile.c (symbol_reloading): New "set/show" variable. - (symbol_file_add): Shorten message about symbol reading. - (add_symbol_file_command): Merge with add_syms_addr_command, - since this should work on all targets now. - (stop_whining): Default to zero, to shut up complaints - about bad symbol tables on many systems. - (free_named_symtabs): Just exit unless symbol_reloading. - - * xm-sun3os4.h, xm-sun4os4.h: Define BROKEN_LARGE_ALLOCA, - and add comment explaining shared library screw. - - * source.c: #if defined => #ifdef. - -Thu Aug 8 12:23:19 1991 John Gilmore (gnu at cygint.cygnus.com) - - * doc/gdbint.texinfo: Improve doc on porting to new OS's. - -Tue Aug 6 17:16:15 1991 Roland H. Pesch (pesch at cygint.cygnus.com) - - * doc/rdl-apps.texinfo: provide default readline-appendix finder - (doc/Makefile knows how to make one for local config) - - * Makefile.in: use doc/Makefile for doc targets - - * doc/Makefile: GDB documentation now has its own Makefile - doc/refcard.tex: renamed from "gdbrc.tex" - doc/.Sanitize: add Makefile; recognize renamed refcard.tex - doc/gdbint.texinfo: add markup in "Cleanups" chapter - - -Fri Aug 2 00:13:06 1991 John Gilmore (gnu at cygint.cygnus.com) - - * values.c (baseclass_addr): When reading target memory, use the - length of the basetype, not the upper type. We've only malloc'd - enough space for the basetype, leading to errors in free(). - - * expprint.c (print_subexp): Print UNOP_MEMVAL of an OP_LONG that - ends up as a function specially, since we know the actual type of - the pointed-to address. This (somewhat) fixes display of - expressions that include misc_function_vector names. Try `cond 1 - !strcmp("a","b")' then `i b'. - - * infrun.c: Move DO_DEFERRED_STORES from proceed() to resume(). - The child can be proceeded from inside wait_for_inferior in - evaluating breakpoint conditions, and DO_DEFERRED_STORES was - getting skipped in that case. - - * expprint.c (print_subexp): Use filtered output, since the - subroutines we call use it, otherwise the output is horribly - mangled, since output of wrappable stuff comes out late. - - * Makefile.in: Bump VERSION to 3.98.1 - - * infrun.c (child_create_process): Use execlp to find the - shell to exec our target program. This requires some fiddling - with `environ' since there is no execlpe(). - -Thu Aug 1 15:35:17 1991 Roland H. Pesch (pesch at fowanton.cygnus.com) - - * Makefile.in, doc/gdbrc.tex, doc/rc-* (new files): - Minor rearrangement of refcard permits two new make targets-- - gdbrc.dvi DVI output for refcard, using CM fonts - gdbrc.ps PostScript refcard, using PS fonts - -Wed Jul 31 16:46:21 1991 John Gilmore (gnu at cygint.cygnus.com) - - * GDB-3.98 release. - - * TODO, Projects, WHATS.NEW, README: Update for gdb-3.98. - * Makefile.in (gdb-all.texinfo): Avoid touching file if M4 dies. - -Wed Jul 31 16:35:58 1991 Roland H. Pesch (pesch at cygint.cygnus.com) - - * doc/gdb.texinfo: last changes for release. - Minor typo and formatting fixes; incorporated most fixes remaining from - filed mail commenting on earlier drafts. - - Added warnings: pipes don't work in run command; - conditions are converse of assertions; - step over fn without debug info goes to next fn; - vars may have "wrong" values near fn entrance, exit - - Added example from Kingston on printing repeated nonadjacent values - - Added explicit mention that in Emacs gdb mode C-c and C-z are like - shell mode for signals - - Renamed "Stepping and Continuing" to "Continuing and Stepping" so it - doesn't sound so much like its parent "Stopping and Continuing"; also - moved entries on continue to top of section, so they don't get lost. - - Improved installation directions in appendix, added manual formatting - instructions - -Tue Jul 30 17:26:39 1991 John Gilmore (gnu at cygint.cygnus.com) - - * configure.in: Remove xm.h and tm.h even if we aren't linking - new ones, so "./configure sun4; ./configure none" does the right - thing. Assume that alldeps.mak and depend are already built in - srcdir, and avoid running "make" (particularly "make depend", - which involves "gcc") from inside configure. Build Makefile - directly rather than building Makefile.conf first. - * configure: Regenerate with above changes. - * Makefile.in: Use $(BISON) to find bison. Roll VERSION - to 3.98. Revise gdb.tar.Z procedure to produce a file - called gdb-$(VERSION).tar.Z but which unpacks into a - directory called "gdb". Move non-source files out of - $(SFILES_SUBDIR). Pretty up alldeps.mak with comments. - (depend): Don't try to do "gcc expread.y". - (expread.o): Update dependencies by hand. - -Mon Jul 29 15:21:09 1991 Roland H. Pesch (pesch at cygint.cygnus.com) - - * doc/gdb.texinfo: - Fixed a variety of small typos that prevented info from formatting - cleanly; altered too-long heading for GPL Appendix, as discussed - w/RMS; Changed date on cover to July 91. - -Fri Jul 26 13:20:02 1991 Roland H. Pesch (pesch at cygint.cygnus.com) - - * doc/gdb.texinfo: - (1) Applied some fixes due to comments from Larry Breed (easier ones - through chapsec 5.2) - (2) Eliminated use of @footnote---had my doubts about it anyways, and - it's broken in latest texinfo - (3) Introduced *some* use of [] for optional arguments, where - explanation is not simpler by listing cmd w arg and cmd w/out arg - separately. Still not using @deffn. - (4) Dropped in GPL-2. NOTE: one of GPL-2 or texinfo is broken; a - couple of headings are too long. Need patches to texinfo or revision - to GPL-2. - - * Partial update to README (which still needs work for this - release!): (1) use of configure corrected for new script, - (2) "make gdb.dvi" and "make gdb.info" mentioned. - -Wed Jul 24 06:44:02 1991 John Gilmore (gnu at cygint.cygnus.com) - - * symtab.c (lookup_symbol): Don't complain right off about - no debug symbols; use the misc function vector first. - (list_symbols): Use misc function vector to find symbols - that don't have debug info, and print them. - (find_pc_symtab): Temporarily avoid fatal() when psymtab - PC range doesn't match symtab PC range, as it does on the - MIPS because our symtab reading isn't perfect. - - * dbxread.c (dbx_symfile_read): Make warning about - "no debug symbols" slightly nicer. - - * source.c (select_source_symtab): If "main" symbol exists, - but decode_line_spec can't find line info, don't just return - a zero; try other source symtabs or give an error. - - * mipsread.c (parse_partial_symbols): Sort the psymtabs by - their low addresses first, then rip through fixing high addrs. - - * ns32k-opcode.h (sfsr): Bugfix from Rune Nerg}rd, - . - (NS32K_SVC_IMMED_OPERANDS): Reverse the #ifndef. - -Tue Jul 23 18:52:43 1991 Roland H. Pesch (pesch at cygint.cygnus.com) - - * Minor, mostly mechanical, cleanup of doc subdir for clean - makeinfo'ing and TeXing; also ensured gdb-all.texinfo (post-m4) - and gdb.info (post- texinfo2 makeinfo) generated for distribution. - -Sun Jul 21 03:54:52 1991 John Gilmore (gnu at cygint.cygnus.com) - - Mostly MIPS and general symbol-reading fixups. - - * doc/gdbint.texinfo: Add documentation on symbol-reading - interface. - - * mipsread.c: Remove kludges around #include "ecoff.h". - Remove redefinitions of a_magic, etc, no longer used. - (parse_symbol, ): Convert "Internal:" printfs to complain()ts. - Fix global overview comments to match symfile.c protocol. - (mipscoff_new_init): Eliminate cur_hdr if we have one. - (mipscoff_symfile_read): Eliminate unused code. Avoid - sorting all the symtabs, when all we have read here is psymtabs. - The symtabs are sorted as they are created anyway. Tell - condense_misc_bunches whether we're mainline. - (psymtab_to_symtab_1): Pass filename when recursing, to make - stack trace more informative. - (parse_partial_symbols): Assume cur_hdr as argument. - (read_mips_symtab): Don't clobber cur_hdr, so it can be freed. - Pass cur_hdr implicitly to parse_partial_symbols. Avoid checking - the TYPE_NAME of char *, since that's done in symfile.c. - (free_numargs, parse_symbol, add_symbol, add_block, - shrink_linetable): Declare these fns void. - (upgrade_type): Convert tree of if's to switch. Clean up - bogus "off == 0" handling with a complaint. Avoid setting - field bitpos and bitsize of array with lower and upper bounds. - Check specified bitsize of elements against their actual type's - bitsize, and complain if different. Complain about unknown - type qualifiers. - (parse_fdr): Don't assume sizeof(char *) == sizeof (struct *). - (psymtab_to_symtab_1): Print names of subsidiary files that - are being read in. FIXME, we read far too many files. This code - is not the problem, the problem is in parse_fdr where the psymtabs - are set up. - (cross_ref): Result should indicate that we used one aux entry - normally, or two if we encountered a "next" entry. This used - to leave the caller pointing at the wrong aux entry. - (add_symbol): If overflowed cur_block, reallocate it larger, - chase all pointers to it, and complain(), rather than clobber memory. - (shrink_block): Use xrealloc rather than xmalloc-and-copy. - (new_field): Only allocate one field initially, not two. - Pull ++ out of macro argument. Simplify. - (_initialize_mipsread): Avoid initialization of importd - global_psymbols and static_psymbols. - - * symfile.c (psymtab_to_symtab): Depend on XXX_psymtab_to_symtab - to properly set pst->symtab; avoid searching for it. - (symfile_fns): Improve comments, add a FIXME. - * dbxread.c: Update comments to reflect symfile protocol. - (read_ofile_symtab, end_symtab): Return the symtab. - (psymtab_to_symtab_1): Set pst->symtab. - - * coffread.c (coff_symfile_read): tell condense_misc_bunches - whether we're mainline. - - * symfile.h (sym_fns): Remove unused sym_discard member. - * coffread.c, mipsread.c, dbxread.c: Remove XXX_symfile_discard. - - * mtrace.c (mtrace): Take effect if mallwatch is set, even if - the environment variable is not. - * infcmd.c (finish_command): Use filtered printfs. - * cplus-dem.c: Add struct tags to a few unnamed structs. - * valops.c (value_coerce_array): Improve comments. - * valprint.c (type_print_varspec_suffix): Print array size only - if greater than zero. - * m88k-tdep.c: Shift some lines left by one space, that had - apparently been trashed at some point. - * TODO: More things to do, a few got done. - -Thu Jul 18 22:46:05 1991 John Gilmore (gnu at cygint.cygnus.com) - - * symtab.h (LOC_EXTERNAL): Eliminate in favor of LOC_STATIC. - (ldsymoff, ldsymlen, globals_offset, statics_offset): Improve - comments. - * dbxread.c (read_dbx_symtab): LOC_EXTERNAL -> LOC_STATIC. - * expread.y, findvar.c, symmisc.c: Ditto. - * printcmd.c (address_info): Update printed forms of LOC_ - symbols. Elim LOC_EXTERNAL. - (print_frame_args): Keep track of param stack offsets before - re-looking up to find the local register param is kept in. - - * mipsread.c: Use and rather than . - Further integration of mipsread into gdb. Eliminate unused - routines, duplicate declarations. Handle static symbols in - psymtabs as well as external symbols. When reading symtabs, - insert symbols into the correct block (global, static, or a local - block). - (read_mips_symtab, parse_partial_symbols): Don't pass useless - "incremental" arg. - (mipscoff_symfile_read): Don't call select_source_symtab. - (parse_symbol): Use SYMBOL_VALUE_ADDRESS where appropriate, - rather than SYMBOL_VALUE. - (parse_external): Comment clobbering of top_stack. - (parse_partial_symbols): Update comments. Allocate and parse - static symbols as well as external symbols. FIXME, enum values - are not handled in this pass, but should be. Inline new_psymbol. - Use SYMBOL_VALUE_ADDRESS. - (psymtab_to_symtab_1): Read symbols into global static block - by default (until enter some function's local block context). - (sort_blocks): Clean up STATIC_BLOCK as well as GLOBAL_BLOCK. - (destroy_all_symtabs, new_psymbol): Eliminate, unused. - - * source.c (select_source_symtab): Select a source symtab - from either the symtabs or, failing that, the psymtabs. - (list_command): Update error message. - (forward_search_command, reverse_search_command): Use getc, not - fgetc, for speed. FIXME, add comment about buffers that die if - overrun by long line. - - * values.c (unpack_field_as_long, modify_field): Avoid shifting - by an entire word, which is not portable, if we have a 32-bit - field. (Code in dbxread.c already turns such bitfields, if - aligned, into ordinary ints, but fixing this will help for other - symbol formats and for future changes.) - * core.c (core_open): Handle ANSI const brain death. - * utils.c (vprintf): Fix varargs typo. - -Sun Jul 14 00:42:53 1991 John Gilmore (gnu at cygint.cygnus.com) - - * findvar.c (find_var_value): Handle &function better. - * TODO: Document work needed on &fn and &array. - * printcmd.c (print_address_symbolic): New arg is the prefix - to print if a name is printed. - (print_address_demangle): Honor "set print address" now. - Use new arg above to improve spacing of output. - * valprint.c (val_print): When printing function pointers, - print symbolic form too. - * breakpoint.c (breakpoint_1): Use new print_address_symbolic. - -Mon Jul 8 19:02:46 1991 John Gilmore (gnu at cygint.cygnus.com) - - * core.c (memory_error): Reword error msg to mislead less. - - * mips-pinsn.c (print_insn_arg 'd'): Print $ with reg name. - - * mipsread.c (read_mips_symtab, read_the_mips_symtab, - parse_partial_symbols): Use newer BFD internals (external_filehdr - and external_aouthdr), byte-swap the fields that we care about - before using them, and make the file header data local to - read_the_mips_symtab rather than global. - -Sat Jul 6 01:34:15 1991 John Gilmore (gnu at cygint.cygnus.com) - - * ns32k-opcode.h (movmw, movmd): Fix opcodes. Bug fix - from Rune Nerg}rd on 5 Jul 1991. - - * main.c (command_line_input): Flush stdout and stderr - before every call to readline. This reportedly fixes a bug - that comes up in Sys V running emacs-gdb and/or xxgdb, - when stdin/out are pipes or sockets. - -Thu Jul 4 14:47:06 1991 John Gilmore (gnu at cygint.cygnus.com) - - * configure.in, Makefile.in: Avoid rebuilding "depend" as much. - Avoid declaring Makefile dependencies, because GNU Make stupidly - tries to update it if we do. - - * coffread.c: Revise for minor changes to bfd internal coff - indexes. - - * configure: If -template= is given a relative path, make it - absolute before recurring in subdirectories. - - * configure, configure.in, Makefile.in: Install "configure" script - as replacement for config.gdb. - * config.gdb, Makefile.dist, Makefile.sdir: Remove - * README: Update for configure, mostly. FIXME. - - * Add dec3100 as equivalent to littlemips. Indicate in all host & - target config files that they are for the host. When the lines - get copied into the Makefile, this makes it more obvious what's - up. - -Mon Jun 24 23:49:07 1991 John Gilmore (gnu at cygint.cygnus.com) - - * sparc-opcode.h (trap opcodes): Avoid leading spaces or - tabs, which end up in the disassembler output inadvertently. - -Wed May 29 23:01:03 1991 John Gilmore (gnu at cygint.cygnus.com) - - Make it compile cleanly in an ANSI GCC2 environment. - - * blockframe.c: - * cplus-dem.c: free takes a void *, ifdef __STDC__ - * dbxread.c (read_huge_number): avoid gcc2 bug hoisting calc of - LONG_MAX/radix. - * defs.h (alloca): Avoid doing anything if alloca already def'd. - * stddef.h, stdlib.h: Remove these files. - * symtab.c: Avoid declaring qsort, close. - * symfile.c: Avoid declaring close. - * utils.c (vprintf): Declare "ap" arg as proper va_alist. - * sparc-tdep.c: Avoid including lots of Sun-host-specific files. - - Assorted other changes. - * dbxread.c: include "libaout.h", not "liba.out.h". - * printcmd.c (print_frame_args): Set recurse properly for - indentation of struct and array parameters. - * valops.c (value_cast): Allow cast to void. - * infrun.c (resume): If NO_SINGLE_STEP, call machine dependent - single_step() in a target-independent fashion. - * sparc-tdep.c (single_step): Don't call ptrace ourselves, just - set up to be ready to continue. This makes us target independent. - * infptrace.c (child_resume): Remove call to single_step; now - can single step a SPARC target of any kind. - -Wed May 22 18:18:24 1991 Roland H. Pesch (pesch at fowanton.cygnus.com) - - * Makefile.dist, doc/gdb.texinfo, doc/*-m4.texinfo: split up GDB - docn into separate sections---basically chapters, plus two loose - pieces that can be configured to go in different places. This - allows GNU m4 to preprocess the manual without coredumping. - - * Makefile.dist: tell TeX where to find texinfo. - -Mon May 20 12:15:04 1991 Roland H. Pesch (pesch at fowanton.cygnus.com) - - * Makefile.dist, doc/gdb.texinfo: respectively create, and use, - the new target "rdl-apps.texinfo" which captures the Makefile - variable that records where to find the Readline libraries. - -Sun May 19 05:36:59 1991 John Gilmore (gnu at cygint.cygnus.com) - - * tahoe-pinsn.c: #include "tahoe-opcode.h", not "opcode.h". - * tm-tahoe.h (FIX_CALL_DUMMY): Ignore more parameters. - * defs.h (const, volatile): Only define if not already defined. - * Makefile.dist (gdb.tar.Z): Create doc subdir w/out CVS/RCS crud. - - * README: Update for release 3.95. - * config.gdb: Don't create readline dir in subdir builds. - * main.c: Include with "..." form for non-system include files, - so "gcc -MM" for "make depend" works. - Include readline files with "...h" rather than . - * mipsread.c: Include "ecoff.h" rather than "intel-coff.h". - - * coffread.c: Undo minor damage done by Rich Pixley. Use - different internal and external representations of COFF - data structures. Use new BFD routines for swapping them in and - out. - * symfile.c (free_named_symtabs): Avoid freeing file names that - are null or empty. Old i960 tools seem to produce files that - claim to have empty names, causing each successive file read - to blow away the previous one. - * sparc-xdep.c (deferred_stores): Repair minor damage by Rich. - Move deferred_stores to top of file, but don't separate its - #define's from its variable. Add commentary. - * Makefile.dist: Fix Rich damage; undo "configure" changes in - favor of keeping the (working) config.gdb. Move readline - library up a notch. - -Fri May 17 12:49:56 1991 Per Bothner (via gnu at cygint.cygnus.com) - - * dbxread.c (read_struct_type): Try to handle g++ version 1 MI - debug info. - * infptrace.c (fetch_registers): no result, since now void. - * tconfig/news: target depends on m68k-tdep too. - -Fri May 17 14:40:14 1991 Roland H. Pesch (pesch at fowanton.cygnus.com) - - * Makefile.dist: added readline/inc-*.texinfo to dependencies for - gdb.dvi target - - * readline/inc-history.texinfo, readline/inc-readline.texinfo: - applied various small fixes due to or inspired by RMS comments - - * doc/gdb.texinfo: finished using all RMS comments, save those for - appendices on readline and cmd history (which are in other source - files) - -Thu May 16 18:06:05 1991 Roland H. Pesch (pesch at fowanton.cygnus.com) - - * doc/gdb.texinfo: (1) Updated w/ref to RMS comments through - chapter 9; (2) documented 'break' command's menu mode for - overloaded names, in response to hgs problem report C++ p-31 - -Wed May 15 11:02:48 1991 Roland H. Pesch (pesch at fowanton.cygnus.com) - - * doc/gdb.texinfo: (1) better introductory example; (2) more - consistent use of @code, @samp, @file, @kbd throughout; small - cleanups to first three nodes; (3) new "Contributors" node; - (4) Appendix, Renamed Commands; (5) divert specialized startup - instructions to "Targets" chapter for generic manuals, while - leaving them up front for manuals specific to specialized - environments; (6) apply fixes from RMS comments through chapter 4. - - * pretex.m4: modify explanatory text slightly (and redefine - "regexp") to keep GNU m4 from complaining. (It still crashes - later, but one step at a time...) - -Wed May 15 10:32:12 1991 John Gilmore (gnu at cygint.cygnus.com) - - * readline/readline.c (update_line): Avoid dereferencing a pointer - before comparing it to its bounds. Saber caught this. - (init_terminal_io): Don't set BC from the "pc=" termcap variable, - and only set PC if tgetstr returned non-null. Saber caught this. - -Tue May 14 16:29:53 PDT 1991 Roland Pesch (pesch at cygint.cygnus.com) - - * Makefile.dist: put gdb.dvi stuff (updated to use M4 preprocessor - stuff for config manual) here where it counts; updated - to use new subdir structure (gdb/doc/). - - * Makefile: generated from above via - config.gdb none - before checkin - - * gdbint.texinfo: added instructions on generating gdb.info* files - locally for release. These are ordinary info - files, formatted from gdb.texinfo (via gdb-all.texinfo, see - Makefile)---but due to use of texinfo 2, can't count on makeinfo - to generate these, so we distribute them already formatted. - - * gdb.texinfo: included full Info node and menu crud (as generated - by C-u M-x texinfo-master-menu using the texinfo-2 elisp code). - - * Makefile: updated "gdb.dvi" target to use M4 preprocessor; - put in comments-for-future gdb.info target (one day makeinfo will - work again). - -Tue May 14 13:51:36 PDT 1991 Roland Pesch (pesch at cygint.cygnus.com) - - * gdb.texinfo: Updated to include new or old undocumented - commands, at least the following (perhaps some others I forgot to - record): info f, info float, info path, info program, info s, info - set, info source, info terminal, info types, info user, set/show - print object. - Also covered all recent GDB command renames for v4. - -Mon May 13 14:57:46 1991 John Gilmore (gnu at cygint.cygnus.com) - - * mipsread.c: Rather than keeping count of how many symtabs - and psymtabs we have, for sorting purposes, count them when - we need to sort. This fixes bug in rereading of symbol tables. - -Fri May 10 15:43:33 PDT 1991 Roland Pesch (pesch at cygint.cygnus.com) - - * infcmd.c: renamed "info path" to "show paths" - * gdbrc.tex: documented above. - -Wed May 8 04:51:11 1991 John Gilmore (gnu at cygint.cygnus.com) - - * remote.c: Fix comments. - * utils.c (error): Force out any pending wrap output. - -Sat May 4 11:11:07 1991 John Gilmore (gnu at cygint.cygnus.com) - - * Makefile.dist: Roll VERSION to 3.95. - Fix up "saber_gdb" to work again. - * saber.suppress: Update. - - * coffread.c, exec.c, infptrace.c, inftarg.c, remote.c, solib.c, - symtab.h, target.c, target.h: Lint. - * core.c: setup and select frame after reading shared libs, - else reading shared libs will clobber them. Lint. - * utils.c (error): Force out any buffered wrap text. - -Fri May 3 22:01:56 1991 John Gilmore (gnu at cygint.cygnus.com) - - * remote.c: Remove decls of memory_insert_breakpoint - and memory_remove_breakpoint, no longer used. (Suggestion of - Jan Norden). - - * Makefile.dist: use ${subdir} in paths of BFD and LIBIBERTY, - to make it easier to interface to "configure"'d libraries. - -Fri May 3 13:10:01 PDT 1991 Roland Pesch (pesch at fowanton.cygnus.com) - - * valprint.c: introduce "set p", "set pr", "show p" and "show pr" as - aliases for set/show print. - -Thu May 2 11:22:02 1991 Jim Kingdon (kingdon at cygint.cygnus.com) - - * coffread.c (coff_sym_fns) [TDESC]: Make the type be m88kbcs. - - * m88k-tdep.c (IEEE_isNAN): New function. - - * infrun.c, m88k-tdep.c, m88k-xdep.c: Change - initialize_{tdesc,dcontext} to init_{tdesc,dcontext}. - - * infrun.c [TDESC]: Add a bunch of crud. - - * xm-88k.h [__GNUC__]: Don't define memset. - - * m88k-xdep.c: #if 0 out push_breakpoint. - - * tm-88k.h: Define GET_SAVED_REGISTER. - - * tm-88k.h: Define DGUX. - - * m88k-opcode.h (UEXT, SEXT, MAKE): Put parentheses around arguments. - - * m88k-pinsn.c (sprint_address): Declare at top of file. - - * m88k-xdep.c: #if 0 out core_file_command. - - * values.c ({unpack_,value_as_}pointer): Just call - {unpack_,value_as_}long (for now anyway). - - * m88k-tdep.c (get_saved_register): Make get_reg a dc_word_t (*)(). - (psr_register): Change return type to dc_word_t. - - * m88k-tdep.c (tdesc_read_function): Comment out call to ptrace. - - * m88k-tdep.c (get_saved_register): Add lvalp parameter. - - * gdbcore.h (write_memory): Don't prototype it. - - * tm-88k.h, m88k-tdep.c: Make stack_error, stack_jmp global. - m88k-xdep.c: Don't mention stack_error. - - * {x,t}config/m88k ({X,T}DEPFILES): Add missing files. - - * mtrace.c: Don't typedef things like size_t, just #define them. - - * coffread.c [TDESC]: #if 0 out references to coffsyn. - - * symtab.h (struct symtab): Include EXTRA_SYMTAB_INFO. - tm-88k.h: Define EXTRA_SYMTAB_INFO. - - * coffread.c [TDESC]: Include "tdesc.h" and make tdesc_handle - dc_dcontext_t not int. - - * coffread.c [TDESC]: Use system include files not . - - * coffread.c [TDESC]: Move setting of debug_info from - coff_symfile_read to find_linenos and make it work with BFD. - - * cplus-dem.c [__STDC__]: Make x{m,re}alloc return void*. - - * signame.c: Cast const char* to char* when assigning to sys_siglist. - - * utils.c (strsave): Make arg const char* not char*. - - * infrun.c (wait_for_inferior) [SHIFT_INSN_REGS]: Use - bpstat_explains_signal (stop_bpstat) not stop_breakpoint. - - * tm-88k.h (START_INFERIOR_HOOK): Make tdesc_handle a dc_handle_t. - - * tm-88k.h (EXTRACT_RETURN_VALUE): Use char * not void *. - - * findvar.c (read_var_value, case LOC_CONST_BYTES): Put the address - in a char *, not a CORE_ADDR. Use SYMBOL_VALUE_BYTES. - - * tm-88k.h (INIT_EXTRA_FRAME_INFO): Use fci not prev (fci is - prev except from create_new_frame). Make next_frame a - local variable. - Declare get_prev_context. - {x,t}m-88k.h: Enclose USG and BCS defines in #if !defined. - m88k-{opcode.h,pinsn.c,xdep.c,tdep.c}: New files (same contents as - before; they had just been left out of the distribution for a long - time). - -Thu May 2 17:53:56 1991 John Gilmore (gnu at cygint.cygnus.com) - - Mips bringup and general cleanup - - * cplus-dem.c: Move CPLUS_MARKER define to after defs.h. - * infptrace.c (PT_WRITE_D, PT_READ_D): Use correct values. - (This still doesn't seem to make MIPS bkpts work.) - * mipsread.c: Remove dup "Reading symbol data..." msg. - (symbol_file_command, add_file_command): Remove, obsol. - * printcmd.c (ptype_command): Say "an enum" rather than "a enum". - Wrap output appropriately. - * stack.c (locals_info, catch_info, args_info): Check - selected_frame rather than target_has_stack or coredumping. - * valprint.c (type_print_varspec_suffix): Wrap "ptype" output of - enums appropriately. - -Wed May 1 14:10:22 1991 Jim Kingdon (kingdon at cygint.cygnus.com) - - * signame.c: Include defs.h and param.h. - - * cplus-dem.c: Include defs.h and param.h. - Makefile.dist: Don't hack in the "param.h". - param.h: Don't include defs.h. - - * expread.y: Use a union to deal with the fact that type_stack - can have both ints and enum type_pieces in it. - ({push,pop}_type_int): New functions. - -Tue Apr 30 13:18:58 1991 Jim Kingdon (kingdon at cygint.cygnus.com) - - * cplus-dem.c (cplus_mangle_opname): Don't call error. - values.c (check_stub_method): Call error if NULL return from - cplus_mangle_opname. - - * blockframe.c, breakpoint.c, core.c, command.c, findvar.c, - eval.c, expprint.c, infcmd.c, infrun.c, main.c, printcmd.c, - remote.c, source.c, stack.c, dbxread.c, coffread.c, symfile.h, - symfile.c, utils.c, valarith.c, values.c, valops.c, tm-68k.h, - target.c, inftarg.c, ieee-float.c, environ.c, defs.h, - command.h, inferior.h, gdbcore.h, symtab.h, expression.h, - symtab.c, cplus-dem.c, value.h, expread.y, valprint.c, - copying.awk, solib.c, inflow.c, symmisc.c - : Lint. Use read_memory not read_memory_integer on CORE_ADDR's. - Use {value_as,unpack}_pointer (added to values.c) - not {value_as,unpack}_long on CORE_ADDR's. - Use longest_to_int (added to defs.h) instead of cast to int. - Remove from_tty arg to mod_path. - Put symfile_bfd in {coff,dbx}read.c not symfile.h. - Use OP_NULL instead of 0 where dummy enum exp_opcode needed. - - * tm-sparc.h: Remove GET_RWINDOW_REG. - (FRAME_CHAIN): Call sparc_frame_chain. - sparc-tdep.c (sparc_frame_chain): New function. - tm-sparc.h (EXTRACT_STRUCT_VALUE_ADDRESS): call - sparc_extract_struct_value_address (added to sparc-tdep.c). - - * xm-sun386.h: Don't define SET_STACK_LIMIT_HUGE. - -Tue Apr 30 13:13:33 1991 Michael Tiemann (tiemann at cygint.cygnus.com) - - * valprint.c (type_print_base): If the type being printed is a - struct containing undefined types, print "" - as the type instead of crashing. - * values.c (value_headof): Get the vtable pointer taking - TYPE_VPTR_BASETYPE into account. - * symtab.c, symtab.h, dbxread.c: Fix various whitespace splotches. - -Mon Apr 29 13:22:51 1991 Jim Kingdon (kingdon at cygint.cygnus.com) - - * Move BROKEN_LARGE_ALLOCA from tm-sun386.h to xm-sun386.h. - - * sun386-xdep.c [!GDB_TARGET_IS_SUN386]: Just provide empty - functions which don't do anything. - tm-sun386.h: Define GDB_TARGET_IS_SUN386. - - * Makefile.dist: Add comment about tm-sun3os4.h: tm-sun3.h, etc. - - * sun3-xdep.c, tm-sun3.h, tm-68k.h: Change TARGET_SUN3 to - GDB_TARGET_IS_SUN3. - - * infrun.c: Don't include sys/user.h and friends (wrong for - cross-debugging and not necessary anymore (see IN_SIGTRAMP in - xm-vax.h)). - [SET_STACK_LIMIT_HUGE]: Include . - xm-tahoe.h: Don't define _DIRENT_. - - * xm-tahoe.h: Remove USE_OLD_TTY (not needed now that terminal.h - includes sgtty.h before sys/ioctl.h). - -Sun Apr 28 22:04:47 1991 Jim Kingdon (kingdon at cygint.cygnus.com) - - * param-no-tm.h: Make BITS_BIG_ENDIAN defined to 0/1, not defined - or not defined. Don't define it based on TARGET_BYTE_ORDER if - it's already defined (in the tm.h file). - mips-opcode.h (BIT_FIELDS_*), - values.c (modify_field, unpack_field_as_long): - Use #if BITS_BIG_ENDIAN not #ifdef BITS_BIG_ENDIAN. - {x,t}m-tahoe.h, tahoe-pinsn.c, tahoe-opcode.h: New files. - -Fri Apr 26 12:02:06 1991 Jim Kingdon (kingdon at cygint.cygnus.com) - - * tm-sparc.h: Add comments about gcc version 2 and structure passing. - - * xconfig/i386v{,32}{,-g}: Add XM_CFLAGS=-Dgetpagesize()=4096. - gmalloc.c: #if 0 out !HAVE_GETPAGESIZE code. - - * expread.y (abs_decl): Accept '&' and '&' abs_decl. - - * symtab.c, symtab.h: Have a builtin_type_{,unsigned_}long_long - regardless of LONG_LONG. - defs.h (TARGET_LONG_LONG_BIT): New macro. - expread.y (typebase): Add {unsigned,} long long {,int}. - -Thu Apr 25 12:31:22 1991 Jim Kingdon (kingdon at cygint.cygnus.com) - - * valops.c (typecmp): If t2 == 0, return 1. - -Wed Apr 24 09:45:17 1991 Jim Kingdon (kingdon at cygint.cygnus.com) - Changes from Tiemann: - * cplus-dem.c (optable): Add "nw", "dl", "compound". - (cplus_mangle_opname): New function. - (do_type): Add case 'Q'. - * values.c (check_stub_method): Do lookup_method_type and stuff - rather than smash_to_method_type. - symtab.c, symtab.h (allocate_stub_method): New function. - dbxread.c (read_type): If we get "##", don't lookup_function_type - and start clobbering it; allocate_stub_method instead. - * printcmd.c (x_command): Dereference references. - * valprint.c (type_print_varspec_prefix, case TYPE_CODE_METHOD): - Don't print " " type_print_base (...) "::" if !passed_a_ptr. - * dbxread.c (read_struct_type): Put "op$" instead of "operator" - in the symbol table. - * values.c (check_stub_method): Deal with operator names. - * valprint.c (cplus_val_print): Check for error in baseclass_addr. - * values.c: Move declaration of cplus_demangle to top of file. - * values.c (baseclass_addr): If can't read memory, set *ERRP - rather than calling error(). - * value.h: Remove redundant declaration of value_static_field. - * values.c (value_static_field): Recursively check all baseclasses. - Return NULL if not found. - * values.c, value.h: New functions value_{headof,from_vtable_info}. - * valprint.c (val_print): Print out first element of vtbl - specially. - * valprint.c: Move print controls to top and add objectprint. - Add command "set print object on/off". - * valprint.c (value_print, is_vtbl_member): Put things in local - variables rather than continually doing VALUE_TYPE (val), etc. - * valops.c (value_struct_elt_for_address): Call check_stub_method. - * valops.c (value_struct_elt): Remove found, arg1_as_ptr. - * valops.c (search_struct_method): Give error if j > 0 && args == 0. - * valops.c (search_struct_field): New argument looking_for_baseclass. - Give error if value_static_field or value_primitive_field - return NULL. - valops.c (various): Call search_struct_field with extra parameter. - * symtab.c (decode_line_1): Deal with operators specified as - "operator" . - (operator_chars): Help do it. - * symtab.c (lookup_struct_elt_type): Call check_stub_type. - Take additional argument noerr. - Don't dump core if TYPE_FIELD_NAME is NULL. - Check the baseclasses recursively. - * symfile.c (fill_in_vptr_fieldno): Don't call check_stub_type. - Return void not int. (also declarations in symfile.h and value.h). - Deal with multiple inheritance. - * printcmd.c (print_command_1): Add if (objectprint) code. - * expread.y (variable): Allow for destructor with foo::~name. - * eval.c (evaluate_subexp, case UNOP_LOGNOT): If following opcode - is OP_SCOPE, give an error. - * eval.c (evaluate_subexp): Pass third arg to lookup_struct_elt_type. - * eval.c (evaluate_subexp), values.c (value_virtual_fn_field): - Don't bother to do anything with - return value from fill_in_vptr_fieldno. - * eval.c (evaluate_subexp): If value_static_field returns NULL, - give an error. - * dbxread.c (read_struct_type): Set fcontext to 0 for normal member - function. - * dbxread.c (read_struct_type): Initialize name to 0. - * dbxread.c (read_ofile_symtab, N_CATCH): Add offset to bufp->n_value. - * dbxread.c (dbx_create_type): Zero TYPE_VPTR_BASETYPE. - (read_struct_type): Don't bother to set TYPE_VTPR_{BASETYPE,FIELDNO} - if it's just going to be {0,1}. - - * dbxread.c (virtual_context): Use TYPE_BASECLASS starting at 0 - (yes, it's #if 0, but just in case...). - - * vax-opcode.h, expread.y, expprint.c, cplus-dem.c: Declare some - things "const". - - * i386-stub.c: New file. - - * WHATS.NEW: Remove mention of readline and more paging (in 3.5). - Try to keep command names up to date with renaming. - - * gmalloc.c [!HAVE_GETPAGESIZE]: Try to figure out the pagesize. - - * infun.c (resume, resume_cleanups): New functions. - (wait_for_inferior, proceed, child_create_inferior): Use resume - not target_resume. - - * remote.c (getpkt): Don't set immediate_quit. - - * blockframe.c, frame.h (reinit_frame_cache): New function. - solib.c (solib_add), symfile.c ({,add_}symbol_file_command): - Use it. - -Tue Apr 23 10:38:41 1991 Jim Kingdon (kingdon at cygint.cygnus.com) - - * symtab.c (lookup_symbol): Add 3 more of those loops through - the symtabs which we all know and love: (1) Look in the - STATIC_BLOCK for mangled symbols right after we check the blocks, - (2, 3) Look in the STATIC_BLOCK for all the symtabs and psymtabs - at the end. - - * main.c (cd_command): Call dont_repeat. - - * dbxread.c (read_struct_type): If const/volatile character is - missing, don't complain, just continue. - - * dbxread.c (read_struct_type): Only try to read the fcontext if - it is there. Also change "error_type " to "return error_type ". - values.c (value_virtual_fn_field): If there is no fcontext, - then do things the way GDB 3.x did. - valops.c (search_struct_method): Add type to value_virtual_fn_field - arguments. - - * dbxread.c (read_struct_type): Fix typo: *pp != '\0' -> **pp != '\0'. - -Mon Apr 22 00:02:43 1991 Jim Kingdon (kingdon at cygint.cygnus.com) - - * printcmd.c (print_scalar_formatted): Add 't' for binary. - - * dbxread.c (end_psymtab): Initialize pst->symtab. - - * core.c (core_open): Call ADD_SOLIB. - - * tm-sparc.h: Include not . - sparc-tdep.c: Don't include . - - * sun3-xdep.c [!TARGET_SUN3]: Just provide empty functions which - don't do anything. - - * core.c (core_open): Add make_cleanup (unpush_target, &core_ops). - - * Shared library/corefile changes from Peter Schauer: - core.c (core_close): Call CLEAR_SOLIB. - (core_open): Remove comment about "should deal with shared lib". - (core_xfer_memory): If we can't xfer the usual way, try the - shared libraries. - solib.c (so_list): New fields so_bfd and so_sections{,_end}. - (find_solib): Use solib_map_sections to get ld_text. - (solib_map_sections, solib_xfer_memory): New functions. - (clear_solib): Free so_sections and close so_bfd. - tm-sunos.h: Add solib_xfer_memory, solib_add. - - * sparc-tdep.c (skip_prologue): Don't skip anything unless there - is a "save" instruction in there somewhere. - - * symfile.c (symbol_file_add): Add comment. - solib.c (solib_add): Don't malloc name passed to symbol_file_add. - - * exec.c (build_section_table): If *start isn't NULL, free it. - - * stack.c (parse_frame_specification): Error if NULL selected_frame. - infcmd.c (finish_command): Error if NULL selected_frame. - inflow.c (kill_command): Deal with NULL selected_frame. - stack.c (record_selected_frame): Set *FRAMEP to NULL if there - is no selected frame. - infrun.c (restore_inferior_status): Add comment. - findvar.c (read_var_value): Check for NULL frame where we need - a frame. - breakpoint.c (get_catch_sals): Check for NULL selected_frame. - - * breakpoint.c (bpstat_print): Try all elements on the bpstat - chain before giving up with an internal error. - -Sun Apr 21 21:43:10 1991 Jim Kingdon (kingdon at cygint.cygnus.com) - - * value.h, values.c (value_{,free_to_}mark): New functions. - breakpoint.c (bpstat_stop_status): Use them. - - * tm-i386v{,-g}.h: Remove N_SET_MAGIC define. - -Sat Apr 20 21:42:47 1991 Jim Kingdon (kingdon at cygint.cygnus.com) - - * i386-tdep.c: Remove unnecessary #includes. - - * symtab.c (various): Change error return of find_line_common to -1. - - * coffread.c (find_linenos): Use LINESZ not sizeof (struct lineno). - - * coffread.c (end_symtab): Initialize language, dirname, and - fullname fields. - -Fri Apr 19 18:18:31 1991 Jim Kingdon (kingdon at cygint.cygnus.com) - - * mips-tdep.c (mips_frame_chain): Don't chain if saved_pc == 0. - - * stddef.h (size_t): Let either _SIZE_T or _SIZE_T_ guard it. - - * mipsread.c (parse_symbol): Set startup_file_{start,end} if - entry_point is in current file. - - * findvar.c (read_register_gen): Add "target byte-order" comment. - -Wed Apr 17 17:09:48 1991 Jim Kingdon (kingdon at cygint.cygnus.com) - - * i386-tdep.c (i386_get_frame_setup): Use SWAP_TARGET_AND_HOST - before returning locals or slocals. - - * i386-tdep.c (i386_follow_jump): Do not add data16 to pos in - call to codestream_seek; add one to pos if (and only if) - we are dealing with a jump with data16 == 1 (i.e. 0x66, 0xe9). - -Mon Apr 15 12:04:32 1991 Jim Kingdon (kingdon at cygint.cygnus.com) - - * valops.c (call_function_by_hand): Put dummy1 in target order - before FIX_CALL_DUMMY. - - * tm-i386v.h (FIX_CALL_DUMMY): Don't depend on host byte order. - -Sun Apr 14 11:55:19 1991 Jim Kingdon (kingdon at cygint.cygnus.com) - - * valops.c (push_word): Add SWAP_TARGET_AND_HOST. - - * remote.c (remote_open): Send '+' before calling putpkt(). - - * tm-i386v.h (REGISTER_VIRTUAL_TYPE): Return pointer to void, - not int, for pc, fp, and sp. - - * remote.c (remote_open): Call start_remote after putpkt("?"); - infrun.c (start_remote): Also call wait_for_inferior & normal_stop. - -Sat Apr 13 22:11:42 1991 Jim Kingdon (kingdon at spiff.cygnus.com) - - * exec.c: Include . - - * sun3-xdep.c (fetch_core_registers): Add #ifdef FP0_REGNUM. - -Fri Apr 19 09:36:50 1991 Jim Kingdon (kingdon at cygint.cygnus.com) - - * tm-68k.h (NUM_REGS): Conditionalize on TARGET_SUN3 not sun. - tm-sun3.h: Define TARGET_SUN3. - - * utils.c: Use CPLUS_MARKER not '$'. - - * cplus-dem.c: Use CPLUS_MARKER not '$'. If CPLUS_MARKER isn't - defined, define it to '$'. - - * arm-opcode.h: New file (same contents as before; it had - just been left out of the distribution for a long time). - - * tm-68k.h: Put declaration of ext_format_68881 outside the macros. - - * main.c: New HAVE_SIGSETMASK #ifdefs. - - * coffread.c (read_coff_symtab): Check for "LF%" with all the - other L*% things. - - * coffread.c (SDB_TYPE): New macro. - various: Use it instead of checking against T_NULL. - - * Makefile.dist (cplus-dem.o): Hack in an #include "param.h" - before we compile it. - defs.h: Protect against multiple inclusion. - param.h: Include defs.h. - signame.c: Change #ifdef SYS_SIGLIST_MISSING to #if. - param-no-tm.h: Define SYS_SIGLIST_MISSING from USG. - -Thu Apr 18 19:49:10 1991 Jim Kingdon (kingdon at cygint.cygnus.com) - - * i386-pinsn.c (OP_E): Change %d to 0x%x for consistency. - - * putenv.c: New file - Makefile.dist: Add it to $(OBS). - - * mipsread.c [!CMUCS]: #include . - - * mips-xdep.c (fetch_core_registers): #if 0 out the whole function. - - * Move read_memory_nobpt from mem-break.c to breakpoint.c. - -Mon Apr 15 21:45:35 1991 Jim Kingdon (kingdon at cygint.cygnus.com) - - * utils.c (_initialize_utils): Rename "set demangle" to - "set print demangle", "set asm-demangle" to "set print - asm-demangle" and "set sevenbit-strings" to "set print - sevenbit-strings". - - * main.c (initialize_main): Rename "set history write" to - "set history save". - - * main.c (initialize_main): Rename "set caution" to - "set confirm". - - * values.c (_initialize_values): Remove "info history" alias - for (what is now) "show values". - - * infcmd.c, gdbcmd.h: Add unsetlist. - infcmd.c: Add unset_command. - (_initialize_infcmd): Add "unset" and use it for "unset env". - - * breakpoint.c (_initialize_breakpoint): Remove "unset". - - * valprint.c: Add "set/show print", {set,show}_print. - Rename "set addressprint" to "set print address". - Rename "set arrayprint" to "set print array". - Rename "set array-max" to "set print elements". - Rename "set prettyprint" to "set print pretty". - Rename "set unionprint" to "set print union". - Rename "set vtblprint" to "set print vtbl". - - * main.c: Rename version_info to show_version. - (_initialize_main): Rename "info version" to "show version". - - * values.c: Rename value_history_info to show_values. - (_initialize_values): Rename "info values" to "show values". - -Sun Apr 14 23:08:34 1991 Jim Kingdon (kingdon at cygint.cygnus.com) - - * inftarg.c (child_open), remote-vx{,.68}.c (vx_proc_open): - New function to give correct error message. - -Thu Apr 11 17:19:41 1991 Jim Kingdon (kingdon at cygint.cygnus.com) - - * target.h: Add to_doc and target_preopen. - target.c: Add target_preopen and target_command. - Remove target_info. - (add_target): Call add_cmd and mess with targetlist->doc. - core.c, exec.c, remote-eb.c, remote-nindy.c, remote-vx.c, - remote-vx.68.c, inftarg.c, remote.c: Add doc field to target struct. - Call target_preopen from open routine. - - * main.c: Rename editing_info to show_commands. - (_initialize_main): Rename "info editing" to "show commands". - - * source.c: Rename directories_info to show_directories. - (_initialize_values): Rename "info directories" to "show directories". - - * values.c: Rename convenience_info to show_convenience. - (_initialize_values): Rename "info convenience" to "show convenience". - - * copying.awk (_initialize_copying): Rename "info copying" to - "show copying" and "info warranty" to "show warranty". - Rename {copying,warranty}_info to show_{copying,warranty}. - - * symfile.c: Rename add_syms_command to add_symbol_file_command. - (_initialize_symfile, add_syms_addr_command): - Rename add-syms to add-symbol-file. - -Thu Apr 18 18:08:30 1991 John Gilmore (gnu at cygint.cygnus.com) - - * symfile.h (free_named_symtabs): Rename from free_named_symtab. - * symfile.c (clear_symtab_users_once, cashier_psymtab, - free_named_symtabs): Move these routines from symmisc.c. - * symmisc.c (same): same. - (free_symtab): Make non-static. - * symtab.h (free_symtab): Declare as exported void fn now. - * dbxread.c (end_symtab, end_psymtab): Change comments. - (initialize_dbxread): Call dbx_new_init() in case the first - command is add-symbols. - * target.c (dummy_target): Permit add_syms_addr_command. - -Sat Apr 13 14:46:07 1991 John Gilmore (gnu at cygint.cygnus.com) - - Permit symbols to be superseded when new symbol files have - been read in, particularly for VxWorks. - - * dbxread.c (read_dbx_symtab): Allow N_SOL to cleanly take us back - to the main file, as well as to include files. Also, put global - functions into the global psymtab, to make "i fun" work. - (end_psymtab): Free named symtabs and psymtabs for a file, once a - new psymtab for it has been read. - * coffread.c (end_psymtab): Free named symtabs and psymtabs for - a file, once a new symtab has been read for it. - * mipsread.c: FIXME. We need to do the same for MIPS, but it - looks harder to determine the top-level block before it's been - queued to the psymtab list. - - * symfile.c (symbol_file_add): Use filtered printing and wrap it. - If we have wiped out any old symbol tables, clean up at end of - symbol reading. - (symbol_file_command): Don't reference symfile_fns if it's zero. - - * symtab.h (GLOBAL_BLOCK, STATIC_BLOCK, FIRST_LOCAL_BLOCK): New - defines for the blocks of a blockvector that contain global and - file-static symbols and the first of the smaller scope contours. - * symtab.c (lookup_symbol, find_pc_symtab, find_pc_line, - decode_line_1, make_symbol_completion_list): Use the above. - * coffread.c (end_symtab, patch_opaque_types): Ditto. - * dbxread.c (end_symtab): Ditto. - * expread.y (block): Ditto. - * mipsread.c (throughout): Ditto. - * symmisc.c (free_named_symtabs): Ditto. - - * symtab.c (list_symbols): Process the first symbol of the - static psymbols list. - (types_info): Restore this function from its untimely #if 0. - It's not perfect, but it is better than nothing. - (_initialize_symtab): Restore "info types". - -Thu Apr 11 05:23:19 1991 John Gilmore (gnu at cygint.cygnus.com) - - * m68k-stub.c: Remote stub for 680x0's, created from - rem-m68k.shar (which is removed). - * nindy-share/{Makefile,Onindy.c,blout.h,env.h,nindy.c,ttyflush.c}: - Remove RCS log stuff now that we use CVS and it blows our diffs. - -Wed Apr 10 14:18:06 1991 John Gilmore (gnu at cygint.cygnus.com) - - * symmisc.c (free_named_symtab): Make it work, in its current - kludgy fashion. Change result to indicate if we blew away bkpts. - * dbxread.c (end_symtab): Accumulate result from - free_named_symtab and print warning if we blew user's state. - * symfile.h: free_named_symtab now returns an int. - -Mon Apr 8 23:57:43 1991 John Gilmore (gnu at cygint.cygnus.com) - - * dbxread.c (dbx_symfile_read): Initialize psymbol list if this - is the first symbol read, even if not mainline. - (dbx_psymtab_to_symtab): symfile might be zero, cope. - * exec.c (exec_ops): Add_syms_addr is valid in our tvec. - (set_section_command): New command ("section xxx yyy" -- should - be renamed to "set section xxx yyy" FIXME) which sets the - base address of a section of the exec file, overriding the - virtual address that BFD reports. - -Fri Apr 5 17:14:39 1991 John Gilmore (gnu at cygint.cygnus.com) - - * exec.c: Add add_syms_addr_command to exec_ops, so you can - load symbols at any address while examining an exec file. - -Thu Apr 4 10:09:35 1991 John Gilmore (gnu at cygint.cygnus.com) - - * tm-i386v.h (FLOAT_INFO): Don't define it, since the code - for printing the float info is host-dependent, not - target-dependent. FIXME. - * i386-pinsn.c: Move #includes to top, remove useless ones. - * i386-tdep.c: Don't bother including <.../reg.h> since we - don't use it (and it doesn't exist on host systems). - - * ieee-float.c (ieee_extended_to_double): Convert NaN to Inf. - Convert negative numbers properly. - (ieee_test): Make numbers really random; fix format arg. - - * infcmd.c (attach_command, detach_command): Don't repeat on CR. - * core.c (core_detach): Unpush core_ops, which might not be on - top. We used to just pop the top, which broke things. Don't - need dont_repeat() any more. - (core_file_command): Psst! Don't repeat it. - * remote-nindy.c (nindy_detach): Don't need dont_repeat() now. - * expprint.c (print_subexp): Avoid switch fallthru on - BINOP_ASSIGN_MODIFY, so we can print += and such. - * frame.h: Fix typo. - * inflow.c (kill_command): After killing inferior, print our - current frame in the core file, if we have one. - (generic_mourn_inferior): When inferior dies, either select - the current frame (in the new target, e.g. core file), or - set both the current and selected frames to NULL. - - Changes from Peter Schauer. - - * infptrace.c: Avoid on USG. - - * Make all file names fit in 14 characters (sigh and damn!): - mv hp300hpux-xdep.c hp300ux-xdep.c - mv symmetry-xdep.c symm-xdep.c - mv symmetry-tdep.c symm-tdep.c - mv convex-opcode.h convx-opcode.h - mv tm-vxworks960.h tm-vx960.h - mv tm-vxworks68.h tm-vx68.h - mv Makefile.srcdir Makefile.sdir - mv gdb-int.texinfo gdbint.texinfo - mv remote-sa.m68k.shar rem-m68k.shar - mv remote-multi.shar rem-multi.shar - * Makefile.dist, README, config.gdb, convex-pinsn.c, - tconfig/symmetry, tconfig/vxworks960, tconfig/vxworks68, - xconfig/hp300hpux, xconfig/symmetry: Change names to shorter - names. - - * command.c (user_info_1, user_info): New command for listing - the user-defined commands. - -Wed Apr 3 15:00:26 1991 John Gilmore (gnu at cygint.cygnus.com) - - * dbxread.c (really_free_pendings): Clear file_symbols - and global_symbols after freeing them; otherwise, running - this function twice (if it appears twice on the cleanup - chain), we try to free things twice. - - * dbxread.c (read_dbx_symtab): Calculate end_of_text_addr - based on text_addr (the address of text in core), not on addr (the - offset between text in the .o file and in core). This change - is from Peter Schauer. - - * main.c: Define ALL_CLEANUPS as a cast of zero. - (return_to_top_level): Use it. - (main): Do all cleanups after each command run as part - of the gdb startup sequence. Also do all cleanups before - entering the command loop, and every time we exit the command - loop and reenter. Before, the cleanups from the startup sequence - were being left undone until the first error! - (command_loop): Rename do_nothing cleanup to command_loop_marker - so we can see it easily when examining the cleanup chain. - (init_signals): Add another do_nothing for signal handling. - (quit_command): Only try to kill target if it has execution. - Problems in the target stack got us into a state where - inferior_pid was nonzero but none of the targets had execution. - In this state you couldn't exit gdb. - - * dbxread.c: Two changes from Peter Schauer. - (echo_command): Fflush output after an echo command. - (show_history): Pass all args to cmd_show_list. - - * utils.c (init_malloc): Call mtrace to turn on tracing - if the environment variable MALLOC_TRACE is set to a file name. - * mtrace.c: Add source file which provides a log of every malloc, - free, and realloc to a trace file. - * mtrace.awk: Add source file which analyzes the trace file. - * Makefile.dist (GNU_MALLOC, MALLOCSRC): Add mtrace.{c,o,awk}. - (VERSION): Roll to 3.94.3. - - * breakpoint.c (breakpoint_1): Add a space to "i watch" output. - (check_duplicates): Don't bother with watchpoints. - (set_raw_breakpoint): Comment about danger of this routine. - (watch_command): Parse and eval all args before calling - set_raw_breakpoint. - - * solib.c (find_solib): Avoid error in referencing memory to - see if any more shared libraries have been added. This is - particularly useful if the target has terminated. Bug reported - by Peter Schauer. - - Changes from Peter Schauer - in bringing up 3.94.2 on the Sun-3. - - * Makefile.dist: Include CFLAGS in rule for cplus-dem.o. - * breakpoint.c (enable_breakpoint): Check for valid watchpoint - expression (in scope) before reenabling watchpoint. - * signame.c (init_sigs): Add missing declaration of i, fix - sys_siglist declaration. - * source.c (list_command): Fixed range computation to use - lines_to_list (). - * stack.c (backtrace_command): Do not allow command if target has - no stack, print informative error message. - * target.c (target_command): Do not write into command line - because this fails if the target command is used in a user defined - command. [This change was enhanced by gnu to support any- - unique-prefix matching on target names.] - * valops.c (value_struct_elt): Avoid infinite loop on an - erroneous attempt to print the member of function (try p main.p). - -Mon Apr 1 17:05:45 1991 John Gilmore (gnu at cygint.cygnus.com) - - * expread.y (name_no_typename): Avoid reduce/reduce errors - caused by ambiguity in handling NAME_OR_INT and NAME_OR_UINT. - Since the GDB parser really doesn't use name_no_typename in a - name-only context, the parser can't tell the diff between - names and numbers here. Avoid allowing a name_no_typename - to be a NAME_OR_*INT to resolve the conflict. - -Sun Mar 31 20:12:07 1991 John Gilmore (gnu at cygint.cygnus.com) - - Bugfixes from Mark Fox (markf@wrs.com) (test=testField.c): - - * valprint.c (val_print_fields): bitfield printing didn't handle - byte order. Indirect through a few more fns to cope. - - * values.c (modify_field): also cope with byte order. - -Sat Mar 23 10:02:21 1991 John Gilmore (gnu at cygint.cygnus.com) - - Cleanup for release 3.94.2: - - * Makefile.dist: Pull REMOTE_OBS. Fix saber includes for BFD - include files. Roll version to 3.94.2. - - * coffread.c (init_stringtab): Read length into unsigned char - array before swapping; don't assume 32-bit longs. - - * target.c (target_info): Don't bother with get_sym_file, just use - the symfile global variable. - * symtab.h, symfile.c (get_sym_file): Delete it. - - * dbxread.c (dbx_symfile_init): Don't depend on long == 4 bytes. - (define_symbol): Set symbol line number to 0 if not gcc-compiled. - (read_type): Replace one more error() with complain(). - - * mipsread.c (parse_partial_symbols): Replace printf with complain. - - * i960-tdep.c: Fix copyright attribution. - - * config.gdb: Quote all backquotes in doublequotes. You can - quote me on that. BSD 4.4 shell found this one. - - * infptrace.c (throughout): The third argument to ptrace is an - int *, not an int. - - * infrun.c (wait_for_inferior): When program has terminated, we - have to call target_terminal_ours before we pop that target off - the stack (e.g. before a call to target_kill or - target_mourn_inferior). This fixes problem where a program - terminates, then GDB stops for (tty output) and you have to type - "fg" to the shell to resume it. FIXME: This code for what to - do after termination really should be in normal_stop instead. - - * gdbcore.h (read_memory_check): Change declaration; it changed - names months ago. - - * terminal.h: Include before , since in BSD - 4.4 prereleases, this avoids a bug in their sgtty compatability - support. - * remote.c: Use terminal.h rather than hand-rolling the same. - - * signame.c, signame.h (psignal): Arg is unsigned, not int. - * utils.c (strsave, strstr): Fix arg types. - * valprint.c (val_print): lint - - MIPS symbol table support from Per Bothner: - - * symfile.c (symtab_fns): Remove initializer table that needs to - be hacked for each new symbol file format supported. - (add_symtab_fns): New function, chains symbol table - handlers into the global list. - (symfile_init): Search this list. - * symfile.h: Add next pointer, declare add_symtab_fns. - * coffread.c (_initialize_coffread): Call add_symtab_fns. - * dbxread.c (_initialize_dbxread): Call add_symtab_fns. - - * mipsread.c (psymtab_to_symtab_1): return void instead of (struct - symbol *). Thus, we no longer need the hack to trash - pst->filename. Good, since that hack confused code in symfile.c! - - (reorder_symtabs, destroy_all_symtabs): Removed static - all_symtabs, which was used to qsort symtabs in reorder_symtabs. - Instead, the latter now uses a temporary array (stack-allocated - from an obstack, and then freed). - - (parse_symbol): Added a hack to fix up BLOCK_{START,END} if they - haven't been set in the outermost stBlock of a procedure. This was - a problem with f77 binaries on Ultrix 4.?. - - (new_symtab, new_symbol, new_type): Continue changing code to use - obstacks more and otherwise conform to dbxread internal style. - Made the free_code of symtabs be free_linetable (as in dbxread) - instead of free_contents. This implies memory leaks when reading - a new symbol table, until the conversion is finished. Did change - (struct symbol) and (struct type) to be allocated on the - symbol_obstack. Blocks and blockvectors are among the things - still "leaking." - - * mipsread.c (parse_partial_symbols, parse_fdr): It hasn't been - tested much, but it solved one problem (reported by Meissner), and - cleans up some other things. The problem happened when an - included file contains actual code (functions) and not just - definitions. The mips coff is a little inconvenient there, since - it may cause a procedure to be mapped to the wrong psymtab. - - * mips-tdep.c (heuristic_proc_desc): Minor cleanup. - * mips-xdep.c (fetch_core_registers): Minor cleanup. FIXME, - this will need work for the new core paradigm. - - Opcode patches from the net: - - * mips-opcode.h: fix incorrect disassembly of the mfc1, cfc1, and - ctc1 instructions. Also, the cvt.d.w and cvt.s.w instructions were - missing altogether - they are added here. From Bruce Bauman. - * mips-opcode.h: The low mask for C0 instructions was too small. - From Garrett Lau. I modified the fix to check the entire 32-bit - opcode. - - * ns32k-opcode.h: Fix opcodes for deiw and deid. From Bruce - Bauman. - -Thu Mar 21 12:56:46 1991 John Gilmore (gnu at cygint.cygnus.com) - - Roll in changes from Per Bothner (Tue, 25 Sep 90 11:11:04): - - * dbxread.c (read_type): Pointer subtraction (value_sub in - valarith.c) sometimes failed because the types of the - pointers being subtracted were not identical. - These differed because dbxread.c was allocating pointer types - using dbx_alloc_type+smash_to_pointer_type instead of - lookup_pointer_type. I failed to find a justification for the - former, so I changed it to use the latter. Similarly, I - replaced smash_to_function_type by lookup_function_type, - and smash_to_reference_type by lookup_reference_type. - - * mipsread.c (parse_symbol, upgrade_type, parse_procedure, - _initialize_mipsread): corresponding changes. - - * symtab.c (smash_to_{pointer,reference,function}_type): eliminate. - - * source.c (mod_path): Do tilde_expand on each component of the path, - rather than on the (list of) paths as a whole. - (print_source_lines): Set first_line_listed in addition to - current_source_symtab and current_source_line. If the source was - not findable, after a "dir" command to fix the problem, - a "list" would get the wrong lines. - - While I was there... (gnu): - - * dbxread.c (read_type): Change error to complaint. - -Thu Mar 21 12:56:46 1991 John Gilmore (gnu at cygint.cygnus.com) - - First attempt at detailed understanding of symbol table memory alloc. - - * dbxread.c (dbx_symfile_read): Free our string table if we - aren't the mainline. Free the "info" struct since we're done with - it. - (init_psymbol_list): Free any previously allocated psymbol lists. - (): FIXME: Should realloc-down the psymbol lists when done reading - the main symbol file? - - * symmisc.c (free_symtab): Free fullname field too. - - * xm-hp300hpux.h (USG): #undef then #define so Makefile can -D. - (REGISTER_ADDR): Make result type unsigned int. - - * xconfig/{i386*,hp300hpux,altosgas,altos}: All config files that - define REGEX must also define REGEX1 (its dependency). - -Tue Mar 19 21:28:57 1991 John Gilmore (gnu at cygint.cygnus.com) - - * tconfig/i960: No longer works, points you at vxworks960 or - nindy960. - - * xgdb.c, XGDB-README: Remove file. Users can get the much - better xxgdb. - * Makefile.dist: Remove all trace of xgdb. - - * breakpoint.c (breakpoint_1): Pass demangle arg to - print_address_symbolic. - (clear_breakpoints): Remove unused function. - (breakpoint_re_set_one): Guts of breakpoint_re_set. - (breakpoint_re_set): Use catch_errors to do them all anyway. - - * gdb-int.texinfo (Host versus Target): Add section on what is - a "host" feature versus what is a "target" feature. - - * infcmd.c (path_command, path_info): Handle the PATH variable - (object search path) as conveniently as the source search path. - * environ.c (set_in_environ): Set some vars in GDB's environment, - in addition to the child's. PATH, G960BASE, G960BIN for starters. - * source.c (mod_path): New function, from guts of - directory_command, modifies a path. Used by path_command. - (directory_command): Call it. - * defs.h (strsave): Declare. - - * utils.c (sevenbit_strings): Add new printing option. - (printchar): Use it. - (strsave): Provide this handy helper routine. - (set_width_command): Rename set_screen_width_command. - (_initialize_utils): "set screen-width" => "set width"; - "set screen-height" => "set height"; add sevenbit-strings. - - * infcmd.c (do_registers_info): Print floating point registers - in raw hex as well as float format, regardless of whether it is - a "virtual" convertible register. - * tm-sparc.h (PRINT_REGISTER_HOOK): Print every pair of float - regs as a double, just in case it's being used that way. - * values.c (unpack_long): Comment on array/function coercion. - (unpack_double): Argument is in target byte order now. For - integer arguments, just call unpack_long and float the result. - * m68k-tdep.c: include defs.h for "const" handling. - * remote-nindy.c: Use ieee-float stuff. - (nindy_fetch_registers): Unpack double regs to host double, then - to extended. - (nindy_store_registers): Pack extendeds to host double, flip - around by misusing unpack_double, send as target double. - - * tm-vxworks68.h (FRAME_CHAIN): Handle current frame pointer of - zero, as when stopped at the first instruction of a process. - - * blockframe.c: Fix filename in comment (param.h => tm.h). - * sparc-tdep.c (skip_prologue): More explicit nudging comments. - * tm-68k.h: Fix typos. - -Fri Mar 15 01:09:34 1991 John Gilmore (gnu at cygint.cygnus.com) - - Changes from a bringup on the DEC Vax under Ultrix 4.0. - - * coredep.c (fetch_core_registers): Pass end-address of register - section to register_addr as expected. Don't call supply_register - if we'd just pass it garbage. - - * dbxread.c (read_dbx_symtab): Skip N_NSYMS on Ultrix. - - * exec.c (xfer_memory): Use boolean xfer_fn result, not int. - - * target.c (push_target, target_info): Cast enums to int for < or - > comparison. - - * stack.c (print_frame_info): Identify source file & line - even if we can't print it. - - * xm-vax.h (MISSING_VPRINTF): No longer missing in Ultrix V4.0. - -Sat Mar 9 10:08:20 1991 John Gilmore (gnu at cygint.cygnus.com) - - Clean up IEEE floating point support. - - * ieee-float.h: New file. - * ieee-float.c: Write real routines to convert between host - doubles and various target IEEE extendeds. - * m68k-xdep.c: Eliminate assembler code for extended floats. - * xconfig/{3b1,altos,altosgas,hp300bsd,isi,news,news1000,sun2os3, - sun2os4,sun3,sun3os3,sun3os4}: Eliminate use of m68k-xdep.o. - * tm-i960.h, tm-68k.h (REGISTER_CONVERT_TO_VIRTUAL, - REGISTER_CONVERT_TO_RAW): Use ieee_extended_to_double and - double_to_ieee_extended. - * i960-tdep.c: Define ext_format_i960. - * m68k-tdep.c: Define ext_format_68881. - * sparc-tdep.c: Define ext_format_sparc, though unused. - * Makefile.dist (HFILES): Add ieee-float.h. - * inftarg.c: #include "ieee-float.h" for the REGISTER_CONVERT - macros. - - Obsolete the "coffstrip" program in favor of using BFD's strip. - - * nindy-share/coffstrip.c: Remove file. - * nindy-share/nindy.c (coffstrip): Routine to run bfd_strip. - * Makefile.dist: Remove references to nindy-share/coffstrip.c. - * tconfig/nindy960: Remove reference to coffstrip.o. - - * Makefile.dist: Roll version number to 3.94.1 (not yet final). - -Wed Mar 6 09:56:45 1991 John Gilmore (gnu at cygint.cygnus.com) - - * symfile.h: Add symfile_bfd, common between dbxread and coffread. - * dbxread.c: Remove static symfile_bfd. - * infcmd.c (do_registers_info): Add PRINT_REGISTER_HOOK, though - it is not used yet. - * inftarg.c (child_detach): Pop the child_ops vector if the - detach is successful. - * remote-nindy.c (nindy_create_inferior): Don't push a new - nindy_ops since nindy uses the same one for execution and memory - examination anyway. - * core.c (core_ops): Use child_attach and child_create_inferior - rather than default attach and create_inferior functions. - - Handle floating point registers in core files. - - * sparc-xdep.c (fetch_core_registers): Rewrite for float support. - * sun3-xdep.c (fetch_core_registers): Rewrite for float support. - This version untested since BFD doesn't yet support sun3 core - files. - * hp300hpux-xdep.c: Rewrite fetch_core_registers to new calling - conventions. Fix comments and style. This version has not - been compiled yet, since we have no HP inhouse. - * core.c (get_core_registers): Look for two sections, ".reg" - and ".reg2", and pass both to fetch_core_registers sequentially. - - Revise directory path yet again. - - * source.c (forget_cached_source_info): Not static any more. - (init_source_path): New default source path is "$cdir:$cwd". - (dir_command): Handle variable arguments ($cdir, $cwd). - (source_info): Print "Compilation directory" rather than - "Originally compiled in" to remind people of $cdir. - (openp): If the path contains $cwd, use current directory. - (open_source_file): If compilation directory is known, replace - first $cdir in path with the compilation directory. - (print_source_lines): Even if we can't print the lines, set the - current symtab and line for future commands like "info source" or - "breakpoint". Also, error message now contains the file name, - line number, and file access error message. - (_initialize_source): Fix help text to describe changes. - * main.c (cd_command): Forget cached source info when we chdir. - * utils.c (strstr): Add simple implementation. - -Tue Mar 5 01:41:40 1991 John Gilmore (gnu at fowanton.cygnus.com) - - * coffread.c (read_one_sym, init_linetable, init_stringtab): - Byte-swap COFF symbol tables if necessary when reading them in. - Use complain() to replace error message in one spot. Needs - corresponding change in bfd/coff-code.h to make some symbol - swapping routines non-static. - -Mon Mar 4 00:53:40 1991 John Gilmore (gnu at cygint.cygnus.com) - - Merge changes from Eirik Fuller, for UTek. - - * defs.h (errno): Add declaration. - * altos-xdep.c, arm-xdep.c, convex-xdep.c, gould-xdep.c, - hp300hpux-xdep.c, infrun.c, inflow.c, infptrace.c, i386-tdep.c, - i386-xdep.c, pyr-xdep.c, mips-xdep.c, remote-eb.c, remote-nindy.c, - remote-vx.c, source.c, standalone.c, stuff.c, sun386-xdep.c, - symmetry-tdep.c, symmetry-xdep.c, umax-xdep.c, utils.c: Eliminate - declarations of errno. - - * remote-eb.c: Define B19200 and B38400 as EXTA and EXTB. - - * remote-vx.c: Include for UTek; Sun gets it via - and . - -Sat Mar 2 15:47:55 1991 John Gilmore (gnu at cygint.cygnus.com) - - * i960-tdep.c (examine_prologue): Add new argument limit, - which stops the scan at the end of the prologue, or at the PC. - This fixes a problem where it walks down into the code for the - user's statements if that code looks like function prologues. - Mark Fox and I have been bouncing this code back and forth, making - small changes to it. Callers changed to match. - -Tue Feb 26 01:47:07 1991 Cygnus John Gilmore (cygnus at yuba) - - Cleanup for gdb-3.94 release final: - - * Makefile.dist: Remove remote-vx.c, remote-nindy.c, and all - the .c files from vx-share and nindy-share, from the various - macros, since they are not found via ALLDEPFILES. - (SFILES): Add tm-i960.h. - (alldeps.mak rule): Break out ALLDEPFILES_MAINDIR and - ALLDEPFILES_SUBDIR. List all the nindy and vxworks subdir files - in the SUBDIR list. - (TAGFILES_MAINDIR): Change ALLDEPFILES to ALLDEPFILES_MAINDIR. - (gdb.tar.Z): Use ALLDEPFILES_SUBDIR as well as SFILES_SUBDIR. - -Mon Feb 25 16:02:35 1991 Cygnus John Gilmore (cygnus at oldman) - - * am29k-tdep.c: Add contribution line. - (examine_prologue): Cache information about function prologues in - the misc-function-vector to avoid lots of references over the - serial line while examining instructions. - - * core.c (core_close): New function made from cleanup_core. - - * core.c, exec.c, inftarg.c, remote-eb.c, remote-nindy.c, - remote-vx.c, remote.c, target.c, target.h, - Update target_ops vector to add attach, close, and load entries. - Use add_syms_addr_command, not add_file_addr_command, for - add_file. Break out close routine from existing code. - - * dbxread.c (really_free_pendings): Don't free pending_blocks; - they are in an obstack. - (read_dbx_symtab): Relocate end_of_text_addr in the psymtab. - Lint. - (define_symbol): Add symbol type parameter; change callers; - pass type parameter to DBX_PARM_SYMBOL_CLASS macro to allow - it to influence the symbol class on the i960. - (define_symbol): Swap LOC_CONST's into target byte order. - - * exec.c (exec_close): New function. - (exec_file_command): Call it. - - * findvar.c (read_relative_register_raw_bytes): Doc byte order, - Fix byte order of frame pointer. - (read_var_value): Result of 0 if var's value can't be found, - e.g. missing FRAME_ARGS_ADDRESS. Byte-swap LOC_CONST and - LOC_LABEL values to target order. Add LOC_LOCAL_ARG. - (locate_var_value): Use read_var_value and use its lazy address - as the location of the var's value. Lint. - - * i960-pinsn.c (next_insn): Add routine from vxgdb for scanning - instructions. - - * i960-tdep.c (arg_address, i960_frame_find_saved_regs): Remove - obsolete Intel versions in favor of vxgdb versions. - (check_host, byteswap, byteswap_val, reorder_val): Eliminate - code dealing with byte order of values, which Intel did in host byte - order rather than gdb-4's target byte order. - (i960_frame_chain_valid): Move to nindy-tdep.c. - (examine_prologue, skip_prologue, frame_find_saved_regs, - frame_args_address, leafproc_return, saved_pc_after_call, - pop_frame): Add vxgdb versions from Mark Fox. - (examine_prologue, frame_struct_result_address): Add code - to deal with the saved value of G13 (struct return address - pointer). - (frame_args_address): Modify Mark's version to prefer the - saved value over the current value in the topmost frame. - Cache result in the frame info to avoid performance hair in - callers. - (print_fault): Add gdb960 code for printing faults. - (_initialize_i960): Actually call check_host. - - * ieee-float.c (ieee_extended_to_double, ieee_double_to_extended): - add stub routines. FIXME, these currently just return zero! - - * infcmd.c (program_info): Use PRINT_RANDOM_SIGNAL. - (attach_command): Call target_attach, not target_open, now. - - * infrun.c (normal_stop): Make global, not static, for vx_attach. - (child_attach): Rename from child_open. - (wait_for_inferior): Use PRINT_RANDOM_SIGNAL. If stop_pc is zero, - don't confuse it with a zero step_resume_break_address. - - * inftarg.c (child_detach): Eliminate inferior_pid test. - (child_files_info): Clean up message a bit. - (child_ops): Use child_attach, not child_open, to attach. - - * mem-break.c: #ifdef out the whole file if BREAKPOINT is not - set (e.g. on VxWorks or NINDY). Move read_memory_nobpt from - findvar.c to here, since it depends on the contents of the - shadow_contents of breakpoints, but keep if #if 0 since it is - never called. - - * nindy-tdep.c: New file, contains nindy_frame_chain_valid, moved - from i960-tdep.c. - - * printcmd.c (address_info): Handle LOC_LOCAL_ARG. Lint. - (ptype_command, display_command): Eliminate have_inferior_p and - have_core_file_p in favor of target_has_stack or - target_has_execution. - (print_frame_args): Handle LOC_LOCAL_ARG. Eliminate duplicate - code for actually finding the values of arguments, though we still - keep track of the maximum stack offset for use in printing unnamed - arguments. Handle missing FRAME_ARGS_ADDRESS. - - * remote-nindy.c (i960_print_fault): Move to i960-tdep.c. - (struct nindy_regs): Define registers passed to/from nindy. - (nindy_fetch_registers, nindy_store-registers): Translate between - nindy and GDB formats for the registers. - (dcache_init): Statically allocate the cache, since it was being - allocated by a malloc that was never freed anyway. - (nindy_create_inferior): Error, not core dump, if no exec file. - (nindy_before_main_loop): Use target_load, not target_add_file. - - * remote-vx.c (net_load): Specify large timeout for load - requests. Allow user to break out with INTERRUPT. - (net_break): Remove useless code, clean up. Change callers. - (parse-args, skip_white_space, find_white_space): Clean up arg - parsing to cope with quoted strings. - (net_wait, net_quit): Never call error, just return status. - (vx_read_register, vx_write_register): Cleanup status checking. - #ifdef the code based on which CPU we are using (960 or 68k), - FIXME, this should be completely general but it isn't yet. - (vx_xfer_memory, vx_resume): Cleanup status checking. - (vx_run_files_info): Improve message. - (vx_load_command): Renamed from vx_add_file_command. Allow load - to be interrupted. - (net_ptrace): Remove unused routine. - (vx_wait): Adopt code from vxgdb960 to cope with broken - connections to target machine and prompt to disconnect. Remove - debug printouts. Map some EVENT_'s to SIGnals. - (add_symbol_stub, vx_open): Print names of object files we found, - and "ok" if we read their symbols OK. Clarify output in general. - (vx_attach, vx_detach, vx_kill): Add these commands. - (vx_convert_from_virtual, vx_convert_to_virtual): Simplify. - (vx_run_ops): Turn off all_mem, to avoid spurious msg in the - "info files" output, and create_inferior, since we already have - an inferior. - - * stack.c (frame_info): Replace Frame_unknown with 0. - (print_frame_arg_vars): Handle LOC_LOCAL_ARG. - (return_command): Pop until the PC matches as well as the FP, - so it works even if the FP is shared with another function, - as in "frameless" or "leaf" procedures. - - * symfile.c (load_command): renamed from add_file_target_command. - (add_syms_addr_command): renamed from add_file_addr_command. - (add_syms_command): Stub to call target_add_syms. - (_initialize_symfile): Change command names and descriptions, - add-file => add-syms, and load from alias to its own command. - - * target.c (kill_or_be_killed, maybe_kill_then_attach, - maybe_kill_then_create_inferior): Default for attempts to start - a process, if one is already running, is to ask about killing - it and retry if yes. - (upstack_create_inferior): #if-0 it, strata obsolete it. - (push_target, unpush_target, pop_target): to_close() a target - before unstacking it. - (target_info): Renamed from target_files_info. - (_initialize_targets): Rename "i files" as "i target", accessible - under both names. - - * target.h: Improve comments about the target_ vectored routines. - - * tm-i960.h: Remove NINDY-specific stuff to tm-nindy960.h. - Convert commenting style to standard GNU style. - (DBX_PARM_SYMBOL_CLASS): allow LOC_LOCAL_ARG's to be recognized. - (SKIP_PROLOGUE): No longer a no-op. - (SAVED_PC_AFTER_CALL): Now handles leaf procedures. - (*_REGNUM): Sort register numbers. - (REGISTER_BYTES, REGISTER_BYTE, REGISTER_RAW_SIZE, - MAX_REGISTER_RAW_SIZE, REGISTER_CONVERTIBLE, - REGISTER_CONVERT_TO_VIRTUAL, REGISTER_CONVERT_TO_RAW): Float regs - are now 10 byte extendeds, not 8 byte doubles. - (FRAME_CHAIN_VALID): Make this config-dependent, since it differs - for nindy versus vxworks targets. FIXME, this should possibly go - in the target vector. - (EXTRA_FRAME_INFO, INIT_EXTRA_FRAME_INFO): Cache both - frame_saved_regs and arg pointer with each frame. - (FRAMELESS_FUNCTION_INVOCATION): New leafproc support. - (FRAME_ARGS_ADDRESS): Use cached result. - (FRAME_ARGS_ADDRESS_CORRECT): New, avoids g14 guessing. - (FRAME_FIND_SAVED_REGS): Change arg to subsidiary fn. - (PRINT_RAMDON_SIGNAL): Call print_fault. - (POP_FRAME): Now works. - - * tm-nindy960.h: Break this off tm-i960.h. NINDY-specific - option parsing and startup; STACK_END_ADDR, FRAME_CHAIN_VALID, - BREAKPOINT, and DECR_PC_AFTER_BREAK are here. - (ADDITIONAL_OPTION_HANDLER): use target_load, not - target_add_file. - - * tm-vxworks960.h: Break this off tm-i960.h. VxGDB specific - startup; DECR_PC_AFTER_BREAK, and FRAME_CHAIN_VALID are here. - - * valarith.c (value_subscripted_rvalue): Avoid handling - floats and doubles specially; it gave alignment errors. Lint. - - * valops.c (value_of_variable, value_of_this): Error if unknown - value. - - * valprint.c (print_floating): Bcopy rather than pointer-deref, - to avoid alignment problems. - (value_print): Handle unknown value address. - (cplus_val_print): Two args are ignored; remove them. Change caller. - (val_print): Use unpack_long rather than pointer-deref. - - * values.c: Lint. - (unpack_long, unpack_double): Use bcopy rather than pointer-deref - to avoid alignment problems. - (value_being_returned): Error if return value unknown. - (set_return_value): Add bogosity warning, FIXME. * - - * TODO: A woman's work is never done. - - * Makefile.dist: Distribute REMOTE_OBS into tconfig files. - Separate INCLUDE_CFLAGS for use with lint. Add LINTFILES. - Add ieee-float.o to OBS. - * tconfig/{nindy960,vxworks68,vxworks960}: Include the desired - REMOTE_OBS remote-interface files in the TDEPFILES and TM_FILE. - * tconfig/i960: FIXME. Half-merge, produce warning if config'd. - - Changes to generalize the VxWorks RPC protocol slightly, to handle - i960 as well as 68000. - - * vx-share/dbgRpcLib.h (VX_SOURCE_STEP): Add. - * vx-share/reg.h: Produce i960 regs #ifdef I80960 - * vx-share/xdr_ptrace.c: Skip FPA registers if 960. - * vx-share/xdr_rdb.h: Add SOURCE_STEP struct and xdr decl. - * vx-share/xdr_rdb.c: Add xdr_SOURCE_STEP routine. - * vx-share/xdr_regs.c: Add xdr_regs, xdr_fp_status, xdr_ext_fp - for i960. Change xdr_vectors to xdr_opaques for 68k registers, - so they will move in target byte order rather than network - byte order (happens to be the same). - -Mon Feb 25 03:41:44 1991 John Gilmore (gnu at cygint.cygnus.com) - - * tm-convex.h (END_OF_TEXT_DEFAULT): Remove #if 0'd block. - -Sun Feb 24 00:55:53 1991 John Gilmore (gnu at cygint.cygnus.com) - - * am29k-pinsn.c, - Add contribution lines to various files, showing where they - came from. - - * breakpoint.c (break_insn, check_break_insn_size, - read_memory_nobpt): Remove to mem-break.c. - - * xm-*.h, param-no-tm.h, tm-29k.h, valprint.c: Change BYTE_ORDER to - HOST_BYTE_ORDER. - - * tm-29k.h (STAB_REG_TO_REGNUM): Warn user if symbol table - entry has bad register number. This change is not - tested in this release, FIXME. - - * frame.h: Eliminate Frame_unknown in favor of a simple zero. - tm-vax.h: Ditto. - - * value.h: Force value's contents field to be aligned to hold - at least a double or a long long (if supported). This avoids - doing bcopy's in and out of the contents field. - - (step_1): Avoid coredump under obscure circumstances when we - have no frame. - - * symtab.h (misc_info): Add field to misc function vector for - any kind of cached information the target code desires. AMD - 29000 uses this to avoid repeating examine_function_prologue's. - - * coffread.c: Lint. Remove static symfile, read_section_header. - core.c (have_core_file_p): Lint: remove. - expprint.c (print_subexp): Lint. - infptrace.c, valops.c, valprint.c: lint. - - Roll in changes from vxgdb-5.0.1: - - * symtab.h: Comment byte order of each address class. Add - LOC_LOCAL_ARG for frame-relative args (960). - expread.y: Use LOC_LOCAL_ARG where LOC_ARG is used. - symtab.c, symmisc.c: ditto. - - * infrun.c (init_wait_for_inferior): Clear stop_signal. - - * remote.c (remote_resume): Error if resume with a signal. - - * symfile.c (prim_record_misc_function): Clear misc_info. - (fill_in_vptr_fieldno): Check stub type of arg. - - * valops.c (value_cast): Avoid looking up names of types whose - name we don't know, to prevent coredump. Sun CC produces typedef - rtx and the name of *rtx is zero... - -Mon Feb 18 21:16:25 1991 John Gilmore (gnu at cygint.cygnus.com) - - Roll in changes from final AMD 29000 port (Tiemann). - - tconfig/am29k: Add COFF_ENCAPSULATE and TARGET=TARGET_AM29K - for ../include/a.out.encap.h. This might not work now that BFD - is separately compiled. Instead, BFD support for encap will have - to translate machine type 29k into the right COFF_MAGIC. - - * infcmd.c: Remove references to inferior_pid that aren't used - in actual ptrace calls; use target_has_execution, etc. - (have_inferior_p): Remove function. - (program_info): Print target info rather than "process number"; - avoid gratuitous messages unless from_tty. - (run_stack_dummy, finish_command): Set proceed_to_finish. - infrun.c: Remove inferior_pid refs. Decl & init proceed_to_finish. - main.c: Lint. Lose have_inferior_p(). - inferior.h (have_inferior_p): Remove, lint. - (proceed_to_finish): Add flag to ask that all regs be saved - by normal_stop, for the few commands that need it, speeding up - serial I/O. Add comments to stop_registers. - - * remote-eb.c: Remove newline from breakpoint message we grep - for. Never time out when running the user program. - - - -Wed Feb 13 15:34:40 1991 John Gilmore (gnu at cygint.cygnus.com) - - Roll in changes from vxgdb-5.0.1: - - * dbxread.c (read_dbx_symtab): If we encounter a "FORTRAN COMMON" - symbol in its raw form, we are processing an unlinked ".o" file. - See if the target environment has assigned it an address, using - target_lookup_symbol (VxWorks does), and enter it into the symtab - that way. - - * tm-vxworks.h (FRAME_CHAIN, FRAME_CHAIN_VALID): Override usual - 68k versions for a simpler version that assumes zero FP at bottom. - Fixes bug of truncated stack reports. - - * target.h (target_lookup_symbol): Define this routine's args - and result, finally. - - * target.c (nosymbol): Default routine for target_lookup_symbol. - (target_default): Default lookup_symbol and call_function too. - (files_info): Only print has_all_memory warning if a non-dummy - target follows. - - * remote-vx.c (vx_read_register, vx_convert_to_virtual, - vx_convert_from_virtual): If target does not have floating point, - zero register "values", and avoid doing cross-net conversions. - (vx_lookup_symbol): Rename net_lookup_symbol, add to vectors. - (vx_open): Rearrange code that attaches to target and reads - symbols for all loaded modules, to work if some of the modules - are not accessible. Add symbol_stub() and add_symbol_stub() - as callbacks from catch_errors(). Allow connect attempt to be - interrupted painlessly with ^C (FIXME, there are still some bugs - if the interrupt happens during symbol reading.). Print - final message with puts_filtered, since symbol messages are - now filtered too. - - Misc cleanup: - - * main.c (catch_errors): Only print errstring if non-null. - (command_loop): Avoid an ioctl per command to test ISATTY. - - * remote-vx.c (net_load): make static; avoid sophomoric msg. - (vx_xfer_memory): Return correct result! - (vx_files_info): Indicate whether target has float or not. - (vx_lookup_symbol): Complain, not error, if target gone. - (vx_open): Print "Connected" msg before disabling immediate-quit. - [FIXME: lookup_symbol and vx_open changes need testing.] - - target.c, remote-eb.c, inftarg.c, am29k-opcode.h, target.h, - tm-29k.h, tmm-vxworks68.h, symfile.c, gdb-int.texinfo: Add - contributor lines and update copyrights to 1991. - - Changes from an attempted H-PUX host port: - - * infptrace.c (PT_ATTACH, PT_DETACH): Handle HP/UX, which - defines PT_ATTACH and PT_DETACH but not PT_KILL. - * remote-eb.c (eb_open): Misplaced endif kills sysv H/PUX. - * remote-vx.c: include for HPUX. - * hp300hpux-xdep.c (fetch_core_registers): Rewrite old - "core_file_command" routine to BFD regime. May not work yet. - - Attempted port of "gdb-3.4 Van Jacobson xgdb" to modern gdb. - - * xgdb.c: Replace X10 version with some VJ version. - (FIXME: Its copyright assignment is not on record.) - * xgdb.c: Update include files to X11R4 (Xaw crud). - (xgdb_display_source, create_text_widget): fix call to - get_filename_and_charpos. Rewack source window stuff for X11R4 - (gleaned from include files, and "nm's" of binary libraries, since - I had no doc available). - (append_selection, append_selection_word): Disable with FIXME - since R4 changed interface here. - (create_buttons): Add back the old set of buttons. - (xgdb_create_window): Fix call to XtInitialize (&argc not argc). - - * Makefile.dist (xgdb, xgdb-init.c): Update for X11R4 on Suns. - Roll VERSION to 3.94 (not yet final though). - -Sat Feb 9 09:46:25 1991 John Gilmore (gnu at cygint.cygnus.com) - - * obstack.h (obstack_ptr_grow, obstack_ptr_grow_fast, - obstack_int_grow, obstack_int_grow_fast): Eliminate - cast on left of assignment, which gives MIPS cc fits and is - not Standard C. - - * sparc-pinsn.c (print_insn): Eliminate 'set' test, subsumed by - F_ALIAS. Use printf, not fprintf, when not passing a file - pointer... - (compare_opcodes): Check that identical instructions have - identical opcodes, complain otherwise. - - * sparc-opcode.h (st %fsr): Fix opcode "lose" mask. This - was reported by Roland McGrath. - (unimp): Only match if exactly zero instruction. (Roland) - (branches and traps): Generate all variations of these - instructions with macros, based on a single call that defines - each condition name and its binary representation. - (set): Turn on alias bit, to avoid test in sparc-pinsn.c. - - * valprint.c (val_print_fields): Take, and use, format parameter. - This means that "p/x struct" again prints the elements in the - desired format. Changed callers. - - * stack.c (frame_info): Use filtered output, and indicate wrap - points. Remove kludgy formatting designed to avoid line wrap. - - * utils.c (wrap_here): If the line is already full (because - we had printed a long indent or long wrapped string), do an - immediate newline-and-indent. - - * m68k-pinsn.c (print_insn_arg): Bugfix from - ntmtv!thompson@ames.arc.nasa.gov (Mike Thompson): 'bkpt #0' - instruction is incorrectly disassembled as bkpt #8. - - * dbxread.c (end_psymtab): Bugfix from Peter Schauer - : If you want to set a - breakpoint in a *.y file gdb will say Reading in symbols for *.y... - and then will dump core (sometimes). I traced it back to an - uninitialized symfile_name in psymtab_to_symtab. - (const_vol_complaint): Add quotes to message. - (define_symbol): Only believe line number if gcc_compiled. - Avoid allocating symbol if we will not return it. - - Add target strata support so that newly established targets go - into their right place in the target stack (e.g. a new exec file - doesn't wipe out the ability to access the running process). - - * target.h, core.c, exec.c, inftarg.c, remote-eb.c, - remote-nindy.c, remote-vx.c, remote.c, target.c: Add to_stratum - and initialize it properly in all the targets. - - * target.h: Document strata. Change return type of push_target. - - * target.c (nomemory): new function for dummy memory access. - (tcomplain): Rename complain, now also used in symfile.c. - (push_target): Push targets within strata. New return value shows - whether new target is on top of stack or not. Always keep dummy - target on stack. - (target_files_info): Ignore dummy target. - - * core.c (core_open): Warn user, and skip accessing file, if the - core target is not the topmost target in the stack. - * remote-nindy.c (nindy_create_inferior): Avoid unpush_target, now - already handled. - - * remote-vx.c: Remove vx_prepare_to_store from vxworks memory - target_ops, it doesn't belong there since we have no regs there. - Change name of target from machine => memory to clarify. - -Thu Feb 7 16:32:09 1991 John Gilmore (gnu at spiff.cygnus.com) - - * Freeze version 3.93 for release. - - * Makefile.dist: Handle vx-share and nindy-share subdirs - properly when building gdb.tar.Z. - - * symtab.c: lint; add no_symtab_msg to consolidate the messages - printed in various places, so I could change just one copy. - - * dbxread.c, coffread.c: Change references to bfd->iostream - to cast to FILE *, now that BFD avoids needing types defined - in other header files. - -Tue Feb 5 21:39:35 1991 John Gilmore (gnu at cygint.cygnus.com) - - * command.c, dbxread.c, expprint.c, infcmd.c, infptrace.c, - infrun.c, printcmd.c, remote-nindy.c, source.c, sparc-tdep.c, - sparc-xdep.c, symfile.h, symmisc.c, utils.c, valprint.c: Lint - (actually gcc -Wall). - - * dbxread.c: Remove first_global_sym, last_global_sym, since - they are never referenced. - - * defs.h (baud_rate): Declare. - main.c: Define it, and add the -b option to set it. - - * gdb-int.texinfo: Add text on how to define a new host or target - architecture, prompted by Per Bothner's questions about MIPS - support. - - * gdb.texinfo: Document "complaints". Change doc of -q since - gdb no longer prints the copyright and blurb if you specify a file - name to be debugged (just like Emacs). Add doc for Nindy-specific - command line flags for specifying target serial port and such. - Update copyright to 1991. - - * gdbcore.h: Remove a large mass of now-useless crud, since BFD - has taken over for us the job of ripping up executable files. The - crud caused Per Bothner's port to not compile. - - * infrun.c (normal_stop): Avoid printing "Program exited - normally" if we are in batch mode. This allows a GDB which - executes a program on a target system, to behave like a Unix - command (input from stdin, output to stdout, no extraneous - output). - - * main.c (main): Allow additional machine-dependent command line - options to be specified with the ADDITIONAL_OPTIONS, - ADDITIONAL_OPTION_CASES, ADDITIONAL_OPTION_HELP, and - ADDITIONAL_OPTION_HANDLER macros. Also allow machine-dependent - processing to occur just before the main loop with - BEFORE_MAIN_LOOP_HOOK. - (main): If a "core file" argument is specified, and it is not a - core file, try it as a process ID to attach. - (symbol_completion_function): Attempt to cope with - "show screen-" TAB, not very successfully. This needs more work, - FIXME. - (batch_file): New function, returns whether we are reading - commands from an interactive tty on stdin, or from somewhere else. - Called by normal_stop since it doesn't get from_tty passed down - to it like many commands do. - - * remote-nindy.c: Handle command line options for nindy - connection. - (nindy_before_main_loop): Prompt user for tty name if they - don't specify it before getting to the interactive command loop. - - * tm-i960.c: Add ADDITIONAL_OPTIONS, etc, to handle -O, -brk, - and -r command line options. Also add hook before main loop - to make it easy to specify a tty. - - * TODO: More things to do, one done. - -Mon Feb 4 23:57:39 1991 John Gilmore and Mike Tiemann (at cygint.cygnus.com) - - * dbxread.c: Make complaint() calls pass pointer, not struct. - Add complaints about badly formatted C++ type information - (const/volatile indicator, and parse errors resulting in - error_type). Fix C++ virtual member fn comment. - (read_struct_type): Avoid bumping pointer if we got a parse - error; this prevents our walking beyond the end of a string. - Terminate loop on null char as well as semicolon. - (process_one_symbol): Fix the LBRAC fix so that it uses the - last previous SLINE, FUN, or SO record's PC address. C++ debug - symbols did not have SLINE records in a useful order compared - to the LBRAC records. - (define_symbol): Handle "catch" records. - - * symtab.c (check_stub_type): Added new complain - `stub_noname_complain' and added a consistency check to - keep the debugger from crashing when finishing from an - exception frame. A real fix will be needed later. - -Sat Feb 2 10:43:05 1991 John Gilmore (gnu at cygint.cygnus.com) - - * infcmd.c (attach_command): Make global. - - * Makefile.dist (REMOTE_OBS): Make these compile by default, - but make them easy to comment out. Perhaps later they should - be enabled by what CPU you configure for? FIXME. - (VERSION): Roll to 3.93. - (pinsn.o): Remove rule for obsolete file. - (dbxread.o,coffread.o,mipsread.o): Use ${srcdir} explicitly. - - Run down a problem that manifested by printing the wrong function - name in stack traces of read_ofile_symtab. Turned out that the - problem was the SunOS 4.1.1 (and previous) C compiler outputs - the LBRAC symbol with an address in the *data* segment, which - blew our binary search through the blocks. - - * dbxread.c: Use the complain() facility consistently to bitch - about problems in the symbol file we are reading. - (finish_block): Add code to check the nesting of the blocks; - complain and Procrust them to fit if wrong. - (make_blockvector): Check the order of the blocks, complain - [but don't cope] if wrong. - (process_one_symbol): ifndef SUN_FIXED_LBRAC_BUG, check LBRAC - symbols to be sure their PC value is greater than the last SLINE - (line number) symbol we've seen, complaining and adopting the - SLINE PC value if wrong. - - * symfile.h (struct complaint, complaint_root, complain, - clear_complaints): Add. - * symfile.c (complain, complaint_root, clear_complaints): Add - facility to deal with non-fatal complaints and to regularize their - suppression. - (symbol_file_add): Clear complaint counters to allow new complaints. - (initialize_symfile): Add 'set complaints' and 'show complaints'. - - * dbxread.c (dbx_symfile_read): Remember the address and size - of the string table for the main symbol file, so we won't read it - more than once. - (dbx_psymtab_to_symtab): Fix the check for main symbol file, - to avoid reading the string table yet again. Lint. - (throughout): Improve filtered output, including word wrap. - (read_range_type): Improve Bothner's fix to handle other types too. - - * utils.c: Improve line wrap implementation. Handle unlimited - width by making chars_per_line unsigned. - (puts_filtered): New, easy, function. - - * defs.h (puts_filtered): add. - - * mipsread.c (compare_symbols, sort_symtab): Remove these fns, - call the identical sort_symtab_syms() in symfile.c instead. - - * expread.y: Suggest the `file' command rather than `symbol-file'. - - * command.h (enum var_types): Add zinteger for seroable - unsigned integer. - * command.c (do_setshow_command): Handle var_zinteger. Restructure - nested if's into a switch. - - * breakpoint.c (bpstat_print): If bpstat "print" flag is not set, - we did not stop because of a breakpoint (it must have been for - some other reason, like a "stepi"), so don't print anything. - - * symtab.c: Include all the time. Now that BFD - doesn't include , old SunOS's require it for - . - -Sat Feb 2 10:39:15 1991 Per Bothner (bothner@cs.wisc.edu) - - A test port of gdb-3.92.6 to the Sony NEWS. - - * Makefile.dist - Don't normally link in remote- or vx stuff. - Some of it doesn't compile, and it wastes space for 99% of the users. - Remove reference to no-longer-used HAVE_VPRINTF. - Fixed BFD_DEP typo to BFD_DIR. - * dbxread.c - Fix cast in arg to bfd_h_getlong. - Make char *prefix be const. - Fix how certain range types are mapped into builtin unsigned int types. - * infrun.c - Remove 2 #includes. They cause errors (on Sony, at least), - and aren't needed (they wern't in earlier versions). - * printcmd.c - print_address_symbolic should never demangle labels - (since it prints *assembler-level* labels). - - [This was superseded by the change to printcmd below.] - - * utils.c - Add some "volatile" return types to avoid warnings. - If MISSING_VPRINTF add vprintf function and not just macro - (since vprintf is used in printcmd.c). - * valprint.c - Unless __GNUC__, use obstack_grow instead of obstack_ptr_grow. - (The latter isn't grokked by some PCC-based compilers.) - - [This change is in abeyance, we prefer to fix obstack_ptr_grow.] - - Make chunk size of dont_print_obstack 32*4 instead of default 4096. - * nindy-share/coffstrip.c - Added some forward declarations (otherwise, gcc complains - about implicit extern redefined as static). - -Sun Jan 20 02:38:19 1991 John Gilmore (gnu at cygint.cygnus.com) - - Changes inspired by Per Bothner: - * printcmd.c (print_address_symbolic): Take additional parameter - specifying whether to demangle. - (print_address): Pass in asm_demangle to control demangling. - (print_address_demangle): New fn, takes explicit arg to control - demangling. - * utils.c: Add new vars demangle and asm_demangle, and let them - be set and shown. - (fputs_demangled): If !demangle, just print the argument. - (fprint_symbol): If !demangle, just print raw symbol. - * valprint.c (val_print): Call print_address_demangle rather than - print_address, to cause demangling to depend on the global - rather than assembler-level demangling setting. - * WHATS.NEW, gdb.texinfo: Document. - - * main.c (show_command): Show all settings if no arg. - (initialize_main): Make "info set" the same as naked "show". - * command.c (cmd_show_list): Handle prefix commands in the - list, and print the name of the setting as well as its English - description and value. - - Allow gdb functions to specify where a line should wrap if it - exceeds the size of a terminal line. Use it to make the output - prettier. - * utils.c (set_screen_width_command): New fn, mallocs a buffer - of the right size when screen width changes. - (set_screensize_command, screensize_info): Remove #if 0'd fns. - (wrap_here): New fn, indicates a point in the output where we - should wrap the line rather than just letting it overflow at a - random place. - (fputs_filtered): Implement wrapping. - (n_spaces): New fn, returns a pointer to N spaces. - (print_spaces_filtered): Use n_spaces. - * defs.h (n_spaces): Declare. - * stack.c (print_frame_info): Wrap with 4-space indent after - fn name and before filename and line number. - * printcmd.c (print_frame_args): Wrap with 4-space indent - before each argument name is printed. - * valprint.c (value_print): Wrap with no indentation before - each repetition. - (val_print_fields): Wrap with indentation relative to nesting - level before each field name. - (val_print): Wrap with nesting indentation before array elements. - * command.c (do_setshow_command): Avoid extra newlines, - wrap with 4-space indent around values printed, end with period. - * WHATS.NEW, gdb.texinfo, gdb-int.texinfo: Document. - - * breakpoint.c (breakpoint_1): Implement addressprint for - "info breakpoints" display. Change file name and line number - format to " at file:nnn" rather than " (file line nnn)". - * gdb.texinfo: Document. - - -Fri Jan 18 07:21:25 1991 John Gilmore (gnu at cygint.cygnus.com) - - Frozen for gdb-3.92.6 release. - - README, WHATS.NEW: Update for 3.92.6 release. - - tconfig/{altos, i386v, i386v32, m88k, umax}: Eliminate - coffread.o from configs since it is now built by default. - tconfig/{3b1, altosgas, arm, convex, hp300bsd, hp300hpux, - i386v-g, i386v32-g, isi, merlin, news, news1000, np1, pn, - pyramid, symmetry, vax, vxworks68}: Eliminate dbxread.o - from configs since it is now built by default. - - Makefile.dist: Update for release 3.92.6. Handle files that - have been moved to ../include, ../getopt, or ../bfd. Add - saber.suppress and tests directory. Add config.status to - the release (it will say "none"). - - coredep.c: Minor formatting fixes. - - These changes were made in early December but only checked in now: - * nindy-share/Onindy.c, nindy-share/coffstrip.c, - nindy-share/nindy.c: lint - * nindy-share/nindy.c (ninStopWhy): Don't byteswap the - register values coming back from the target; we store values - in target byte order everywhere. - -Wed Jan 16 19:01:37 1991 John Gilmore (gnu at cygint.cygnus.com) - - * am29k-opcode.h, am29k-pinsn.c: Add 29050 opcodes. - - * valprint.c (cplus_val_print, val_print_fields): New functions, - which print C++ objects. They conspire to avoid printing a - virtual base class more than once, following all the twists and - turns of C++ virtual base rules. - (val_print): Call the above rather than do it by hand. - - * symfile.c (symbol_file_add): Only reset symfile_mtime for main - symbol file, not for added files like shared libs. This really - needs to be generalized to a timestamp per file. - - * core.c (cleanup_core): Avoid coredump if no core file. - - * config.gdb: Accept -host or -target in place of +host or - +target. - - * coffread.c (find_linenos): Avoid desupported BFD interface - to line numbers. We still read them manually rather than using - BFD's "generic" features. - - * gdbrc.tex, threecol.tex: Add GDB reference card and its - formatting code. - Makefile.dist: Add refcard to OTHERS list for creating tar files. - - * Makefile.dist: Eliminate use of $< in explicit targets. - - * readline/Makefile: Use $< rather than $*.c, which does not - include the VPATH in GNU Make. - - * tconfig/i960-bout, tconfig/i960-coff: These are identical - copies of tconfig/i960, added for global configuration - compatability. All i960 versions can read both coff and b.out. - - * tm-88k.h: Fix multiline macro that lacked \'s. Remove - COFF_FORMAT and COFF_CHECK_X_ZEROES since these are now handled - automaticaly. - - * TODO: Think of more things to do. - -Wed Jan 2 19:09:29 1991 John Gilmore (gnu at spiff.cygnus.com) - - tconfig/{am29k,i960,sun2*,sun3*,sun4*}: Eliminate config - of sdb versus dbx debug symbols. Add kludge for 68881 80-bit to - 64-bit float conversion. - - tconfig/sun4, tconfig/sun3, xconfig/sun4, xconfig/sun3: Make - equivalent to sun?os4 so global config works. - -Wed Jan 2 18:20:51 1991 John Gilmore (gnu at spiff.cygnus.com) - - Fix from Eberhard Mattes - - * main.c: Only declare linesize once; declare pagesize not at - all, since it is never used. - (main): Clear newly allocated line before it is used. - -Fri Dec 28 00:13:42 1990 John Gilmore (gnu at cygint) - - Further stabilization for the Intel 960. - - * Makefile.dist: Parameterize the location of the "include" - and "bfd" directories, as well as "getopt". Add symfile.c. - Link in both dbxread and coffread. Fix up "make depend" to - rewack the locations of include, bfd, and getopt in its output. - - * README: Document moving include files, improve some of - the other doc. - - * coffread.c: Move common code out to symfile.c. Change - symbol_file_command style interface to use new *_symfile_init - and *_symfile_read interface under BFD. Use BFD internal - info to locate line table, symbols, etc. - - * core.c (core_fetch_registers): Rename to get_core_registers - to avoid confusion with fetch_core_registers. - (register_addr): Move to coredep.c, which is already machine - dependent. This leaves core.c pretty clean of dependencies. - - * coredep.c (register_addr): Accept this routine from core.c. - - * dbxread.c: Move common code (with coffread.c, etc) into new - symfile.c. Each psymtab now contains a pointer to the - format-dependent function that knows how to read it in. Make - some things static. - (dbx_psymtab_to_symtab): Renamed from psymtab_to_symtab_2. - (process_one_symbol): Add code to complain about a "compiler bug - we muzzle here", if we actually see it. - - * eval.c (evaluate_subexp): Insert missing "break" statements - in code that determines whether a variable is an lvalue in - memory, register, or whatever. I detected this via a compiler - bug in which it *almost* mashed out the whole switch statement. - - * gdb-int.texinfo: Add minor sections on configuring gdb for - release, and about the README file. - - * infcmd.c (registers_info): Fix formatting somewhat. Still - not as pretty as before, but it handles byte swapping. - - * remote-nindy.c: If data cache routines are interrupted while - waiting for the remote end, be sure that any uninitialized cache - blocks are on the free list, not on the valid list! - - * symfile.h: Flesh out this header file with all the various - routines and variables that have been merged in from dbxread.c - coffread.c, and symtab.c to symfile.c. - - * symfile.c: New file, containing code common to dbxread.c, - coffread.c, and some code from symtab.c. All generic code for - reading symbol files should be in here now. - (unrecord_misc_function): Remove unused function. - - * symtab.h: Remove file-reading things to symfile.h. - - * symtab.c: Remove file-reading things to symfile.c. - - * tm-i960.h: Fix FRAME_CHAIN types; define PRINT_RANDOM_SIGNAL - to decode i960 fault types. - - * target.h, remote.c, remote-eb.c, remote-vx.c, remote-nindy.c, - target.c: Change type of the "resume" function from int to void, - since its result was never used. - -Sat Dec 22 02:51:40 1990 John Gilmore (gnu at cygint) - - * main.c: Replace "stupid" with "caution"; you now "set caution - on or off". - - * printcmd.c (print_scalar_formatted): Fix typo in 'g' format - - * infcmd.c (do_registers_info): Call val_print to deal with the - byte order of the registers being printed. FIXME, this makes - the formatting of the output uglier. - - * infcmd.c (wait_for_inferior): If PRINT_RANDOM_SIGNAL is - defined, call it for signals the debugger doesn't itself use. - The i960 uses this for more detailed fault information. - - * remote.c (remote_open): If arg is null, print help rather than - dumping core. - - * sparc-xdep.c (register_valid): Avoid declaring size, since - various modules will think of various sizes depending on the - architecture of their tm-file. FIXME, we need protection against - actually entering one of those modules, which would clobber - storage if not for the target architecture compiled into gdb. - - * stack.c (up_command, down_command): Always print the frame - you arrive at. - (up_silently_command, down_silently_command): New commands - for use in scripts. - - * i960-pinsn.c (reg), i960-tdep.c: Lint. - - * i960-tdep.c (i960_frame_chain_valid): Lookup_symbol now takes - more parameters than it used to. - - * findvar.c (registers): Increase slop to 256 bytes, which should - protect us against even most RISC machines with large register - sets. - (locate_var_value): Move declaration inside related ifdef. - - * remote-nindy.c (): Use TIOCSETN rather than TIOCSETP - throughout, to avoid throwing away buffered input from the board. - (nindy_wait): Supply_register takes addr_of_value, not value. - (i960_print_fault): Renamed from i80960_fault. - (nindy_fetch_registers): Avoid have_regs stuff, just get them. - (nindy_store_registers): Avoid regs_changed stuff, just stuff - them. - (nindy_create_inferior): Don't bother to write PC_REGNUM since - we can set the PC in the call to proceed(). Unpush nindy_ops - before pushing it on top, to avoid message to user. Eliminate - commentary from Unix machines that just misleads here. - (reset_command): Fix error message to suggest target command. - -Wed Dec 19 11:03:56 1990 John Gilmore (gnu at cygint) - - Release 3.92.5 as frozen. - - Stabilize the merged release...with help from lint, Saber C, - gcc -W, etc. - - Everywhere: Add include files needed to declare return types - of functions called. - - * gdb.texinfo: Roland Pesch is documenting gdb, glory be! - - * breakpoint.h: Add undeclared breakpoint functions, and some - functions for display handling since I couldn't think of a better - .h to put them in. - - * breakpoint.c (insert_breakpoints): Make code for disabling - shared library bkpts more likely to work. It's used when we - rerun a program and stop before the shared library has been - mapped in. - (breakpoint_cond_eval, bpstat_stop_status): Pass arg as int, - cast from pointer, so it squeezes through catch_errors. - (bpstat_stop_status): Fix logic broken some time ago. We now - always create a bpstat if the stop address matches a breakpoint, - even if we don't stop there -- just like the old code used to do - before I got my fingers into it (sigh). - (breakpoint_1): Print "ignore count" after "stop only if" - condition, since that's how it actually works. - (mention): Handle watchpoints as well as breakpoints. - (watch_command): use set_raw_breakpoint and mention to do most - of the work (and initialize all the fields!). Only pass one - arg to parse_c_expression, since that's all it takes. - - * command.c (not_just_help_class_command): Rename arg to args - since we ignore "unused argument" warnings on vars named "args". - inflow.c (child_terminal_info): ditto. - infptrace.c (kill_inferior): ditto - main.c (catch_errors, version_info, quit_command, pwd_command, - source_command, dump_me_command, editing_info, - set_history_size_command, set_history, show_history, - set_verbose): ditto - stack.c (locals_info): ditto - target.c (target_files_info): ditto - valprint.c (set_input_radix, set_output_radix): ditto - - * core.c: Remove old variables for handling core and exec file - sections (data_start, data_end, stack_start, stack_end, - reg_stack_start, reg_stack_end, reg_stack_offset, text_start, - text_end, exec_data_start, exec_data_end, text_offset, - exec_data_offset, data_offset, stack_offset). They're - superseded the more general build_section_table and - xfer_memory. - (get_exec_file): Mention the `file' command. - (read_memory_check): Rename to memory_error, and only call it - in the case of an actual error. - (read_memory, write_memory): call memory_error. - (core_fetch_registers): Register section name is ".reg". - - coredep.c: Remove a bunch of crud now that all this file does - is pull the registers out of a core file. - (fetch_core_registers): Rewrite to actually work, I hope. - - dbxread.c: Use a.out.gnu.h, not system a.out, now. - Replace index() with strchr(). Remove all the pre-BFD macro - definitions for accessing the symbol file. - (struct dbx_symfile_info): Encapsulate the information that - dbx_symfile_init needs to pass to dbx_symfile_read in this - struct. - - (dbx_new_init, dbx_symfile_init, dbx_symfile_read, - dbx_symfile_discard): Rearrange symbol file reading to divide - the format-specific part from the format-independent part, - leaving the format-independent part such as file name expansion - and opening in symtab.c. This replaces - partial_symbol_file_open and partial_symbol_file_read. - Symbol_file_read, add_file, add_file_target_command, - add_file_addr_command move to symtab.c. Pass an explicit - "mainline" flag for when reading the main symbol table, rather - than relying on the offset address to be zero or nonzero. - - (dbx_symfile_read): Don't allow void *'s to be printed as - typedefs. - (SWAP_SYMBOL): Use bfd routines to byte-swap the symbols. - (ADD_PSYMBOL_TO_LIST): Make the "function call rather than - macro" debug version really work. - (read_dbx_symtab): Remove unref'd parameter inclink. - Avoid swapping N_SLINE symbols, for speed. - Merge N_TEXT!N_EXT case with the other external symbol - definitions' case. Add comments. - (start_psymtab): Allocate the symfile name in the psymtab on - the psymbol_obstack, rather than using the caller's storage. - (end_psymtab): Only allocate a dependencies list if there are - more than zero. - (psymtab_to_symtab_2): Use BFD when reopening file to read - its symbols for real. - (read_struct_type): Add FIXME comments where it needs work - for C++ bogosity. - (read_huge_number): Add FIXME about overflows. - (read_range_type): Add FIXME about comparing a long to 1<<32. - - * coffread.c: Minor changes to move things closer to the new - regime with symtab.c and dbxread.c Major work is still needed - here. - - * exec.c (exec_file_command): Remove old variables (see core.c - above). - (xfer_memory): If memory transfer is right at the end of a - section, don't lose. - - * findvar.c (get_saved_register): If value is in a real - register, LVAL is lval_register, not lval_memory. - - frame.h: Declare print_sel_frame and record_selected_frame. - - gdb-int.texinfo: New file, for GDB internals documentation. - Very simple, unformatted doc of cleanups is there for now. - - gdbcore.h: Remove obsolete variables that described a.out - section addresses and offsets. (See core.c above.) - Declare fetch_core_registers and registers_fetched. - - getopt.c: Declare char *alloca(); even on SPARC. - - infcmd.c (run_command): Call target_kill rather than - kill_inferior. - (step_command, next_command, stepi_command, nexti_command): - Declare from_tty parameter even though we don't use it. - (run_stack_dummy): argument BUFFER is a char array, not - a pointer to REGISTER_TYPE. - (finish_command): using_struct_return needed a value *, - not a struct symbol *. - - * infptrace.c (child_xfer_memory): To avoid dependency on - where sections are in memory, try PT_WRITE_D and if that fails, - try PT_WRITE_I. Most Unixes don't care which you use. - - * infrun.c (step_resume_break_shadow): Change to array to - match other breakpoint shadow storage. - (clear_proceed_status): Pass address of bpstat to - bpstat_clear, not the bpstat itself. - (child_create_inferior): FIXME comment about if the child - exits. - (start_inferior): Remove old function. - (child_open): Use target_kill rather than kill_inferior. - (wait_for_inferior): Ditto. - (insert_step_breakpoint, remote_step_breakpoint): Use - new step_resume_break_shadow. - - * inftarg.c (child_wait): If all child processes die, - pretend that the one being waited for exited with signal 42. - - * main.c (command_line_input): When scanning for comments, - don't coredump on unclosed quotes. - (quit_command): Use target_kill rther than kill_inferior. - (_initialize_main): Rename class_user from "user" to - "user-defined". - - * printcmd.c (print_command_1): Initialize "fmt" if no format - is specified by the user. - (print_frame_args): Only add to args_printed if we are - actually fetching args from the stack (avoiding undefined - arg_size). - (_initialize_printcmd): Remove bogus \{ from string. - - * remote-eb.c (eb_open): Avoid coredump on no argument. - - * remote-nindy.c: Bring out of Intel environment into new - target environment. Remove all conditional compilation on - I80960. Massive hacking throughout. - (nindy_xfer_inferior_memory): New routine stolen from - infptrace.c. - (nindy_create_inferior): New routine pieced together, probably - not quite working yet. - (nindy_ops): New target_ops struct for nindy. - - * remote-vx.c: Use write_memory rather than target_write_memory - to get error checking. - (vx_add_file_command, vx_open): Use symbol_file_add rather than - add_file. - (vx_create_inferior): Use target_terminal_ours... - - * signame.c (_initialize_signame): Always initialize, since - we need the table for things other than psignal. - - * solib.c (solib_add): Use symbol_file_add, not add_file. - (solib_address): Return boolean result rather than struct - pointer which nobody else knows the type of. - - * sparc-tdep.c, valops.c: Use write_memory rather than - target_write_memory, to get error checking. - - * stack.c (locals_info, catch_info, args_info, - get_selected_block, frame_command, up_command): Use - target_has_stack, rather than have_inferior_p or - have_core_file_p. - - * sun3-xdep.c (fetch_core_registers): Rewrite for new BFD regime. - - * symfile.h: New file, defining the interface between the - generic and object-file-specific symbol reading code. - - * symtab.c: Move generic symbol-reading interface to symtab.c, - from dbxread.c, coffread.c, mipsread.c, etc. Add symtab_fns - table to map BFD targets to symbol-reading modules in GDB. - Change index to strchr. - (lookup_struct_elt_type): Use error() rather than hand-made - simulations thereof. - (lookup_partial_symbol): Speedup slightly when length == 0. - (symbol_file_add): New function. - (symbol_file_command): Call it. - (symfile_open, symfile_init): New function. - (add_file_target_command, add_file_addr_command): moved from - dbxread.c. - - * target.c (target_command): use target_kill. - - * target.h (target_files_info): Don't declare, never called - from outside. - - * tm-sun2.h, tm-sun3.h (STACK_END_ADDR): Use system include - files to determine stack end address. - - * valarith.c (value_x_binop, value_x_unop): Change error message - to be more useful. Pass proper argument to value_struct_elt. - - * valops.c (value_assign): FIXME comment that long long - bitfields will break here. - - * Makefile.dist: Add symfile.h, remote-nindy.c, remote-eb.c. - Update `make saber_gdb' to work better. - - * TODO: A woman's work is never done. - - * cplus-dem.c, environ.c, inferior.h, infrun.c, inftarg.c, - main.c, obstack.c, printcmd.c, remote-eb.c, remote-nindy.c, - remote-vx.c, remote.c, solib.c, source.c, sparc-pinsn.c, - sparc-tdep.c, sparc-xdep.c, symmisc.c, symtab.c, symtab.h - target.c, terminal.h, tm-sparc.h, tm-sunos.h, utils.c, - valops.c, valprint.c, exec.c: Lint. - - -Wed Dec 12 23:44:15 1990 John Gilmore (gnu at cygnus.com) - - Continuing Intel 960 port merge of GDB. - - * Makefile.dist: Merge i960 "nindy-share" files. Rename - malloc.h to gmalloc.h to avoid name conflicts in /usr/include. - Don't ship gdb.dvi in tar file. Link gdb with init.o, not init.c. - Wack over "make depend" so it handles files in subdirectories - vx-share, nindy-share, bfd, and in the current directory. - - * blockframe.c (get_prev_frame_info): Remove fatal error - if stack not defined. - - * core.c (core_open, core_detach): New functions that handle - the old "core-file" command as "target core" and "detach" instead. - (core_file_command): Call them. - (core_xfer_memory): Use common routine xfer_memory. - - * dbxread.c: Include a.out.gnu.h, not system a.out.h. - dbxread now uses bfd for everything but symbol reading itself. - BFD internals are used to drag out the relevant file offsets. - (partial_symbol_file_open): Change args all around for BFD. - - * symtab.c: Rename "value" to "val" everywhere, so we can - #include "value.h". - (symbol_file_command): New command, moved from dbxread.c - and coffread.c. It uses BFD to read the file, then vectors - based on its type, to dbx or coff symbol readers. - * symtab.h: Extern a few vars for symbol_file_command. - - * target.h: Breakpoint takes a char * save area, not a char **. - - * valprint.c (val_print): When unpacking bitfields, offset - the address in gdb of the value, if it is declared with a shorter - type. Remove the last "runtime kludge test" of host byte order. - - * utils.c: Remove old my_bfd_read routine. - - * stack.c (frame_info): Use target_has_stack. Print program counter - register's actual name rather than "pc", since it's called the - "ip" (instruction pointer) on the i960 (sigh). - - * target.c (target_command): Add command for selecting a target - type and calling its open routine. This is used for initiating - communication with a particular target, in a generic way. - - * tm-i960.h: Update for modern gdb. Remove semicolons from - various macros. Handle reading struct return convention, and - error-out attempts to return structs with the "return" command. - Be sure gdb doesn't think we know how to call functions in the - inferior. - - * i960-tdep.c: Rename FRAME_CHAIN_VALID and FRAME_FIND_SAVED_REGS - to i960_xxx in lower case. - (arg_address): Circumvent errors due to LOC_ARG_BLOCK - not being defined yet. - - * remote.c (remote_open): Call start_remote to initialize - wait_for_inferior during open. - (remote_xfer_inferior_memory): Return length written rather - than errno value. - - * remote-vx.c (target_command -> vx_open): Use new generic - target command. - * remote-eb.c, inftarg.c, exec.c: ditto. - - * infrun.c: Fix comments. - (attach_program -> child_open): Use new generic target command. - (wait_for_inferior): Clear saved register values before target_wait, - so target_wait can set some of them if convenient. - - * infptrace.c (fetch_inferior_registers, store_inferior_registers): - Return success indicator, not void. - (child_xfer_memory): Avoid fetching initial word if we'll - overwrite it anyway. - - * infcmd.c (attach_command): Use new generic target open routine. - (_initialize_infcmd): Update doc on attach and detach commands. - (do_registers_info): Merge in a byte-order problem as a FIXME - comment. - - * findvar.c (find_saved_register): Avoid problem in current frame. - (read_relative_register): Ditto. - (write_register): Convert byte order on the way out. - - * exec.c (file_command): Add. - (add_to_section_table, exec_command): Use new bfd_map_over_sections. - (xfer_memory): Common function between core_xfer_memory and - exec_xfer_memory. - (exec_xfer_memory): Use it. - - * pn-opcode.h: Document that a "PN" is a Gould PowerNode. - - * breakpoint.c, breakpoint.h, symtab.h, value.h, frame.h, utils.c, - valops.c, stack.c, target.c, sparc-xdep.c, source.c, printcmd.c, - infcmd.c, i960-pinsn.c, eval.c, defs.h: lint and gcc -Wall. - -Sun Dec 2 16:45:06 1990 John Gilmore (gnu at cygnus.com) - - Merge Intel 960 port of gdb, continuing... - - * dbxread.c (partial_symbol_file_open, partial_symbol_file_read, - symbol_file_command): Pass from_tty arg to hush 'em up. - - * coffread.c (symbol_file_command): Avoid output if from_tty != 1. - Add magic numbers for 960 COFF format. - -Fri Nov 30 09:18:20 1990 John Gilmore (gnu at cygnus.com) - - Merge Intel 960 port of gdb, from Intel "1.2" release. - - CHANGE_LOG entries from their port, which was based on - gdb+-2.8.0: - - Thu Sep 6 11:02:22 PDT 1990 - Remove temp file if download is interrupted. - - Wed Aug 1 09:08:33 PDT 1990 - Now uses binary protocol to talk to NINDY. - Old hex protocol (NINDY 2.13 and older) supported with -O switch. - Times out after 5 seconds when trying to talk to NINDY. - - Tue May 29 12:54:49 PDT 1990 - Added variable baud rate (-b switch). - Source code reorganization. - - Thu Apr 26 11:09:55 PDT 1990 - More cleanup of batch mode; specifically, execute "-s", "-e", and - "-se" switches as soon as they are encountered on the invocation line. - - Fri Apr 20 13:47:15 PDT 1990 - Add -brk switch. - - Thu Apr 19 09:54:28 PDT 1990 - Add 'reset' command. - - Wed Apr 18 09:48:07 PDT 1990 - After opening remote tty, wait for 1 second to go by without input - from it before trying to talk to NINDY (fixes problems with the - Heurikon HK80/V960E). - - Mon Apr 4 16:33:05 PDT 1990 - Some output was not being suppressed in 'batch' mode. - - Thu Mar 22 15:31:11 PST 1990 - Ask user if old symbol table should be deleted when new file is - downloaded. - - Allow user to run a program downloaded before gdb960 was brought up. - - Correct "exec-file" help message for i80960 context. - - Correct bug in calculating user space address: could occasionally - corrupt user program. - - Make sure to zero low-order bits in rip's because of bug in 960CA - A-step part: could cause operation faults when "next"ing across - a function call. - - Correct bug that made it impossible to get source line numbers for - code loaded at addresses higher than 0x7fffffff. - - Wed Jan 10 12:43:22 PST 1990 - Open remote tty for exclusive use. - - Fri Jan 5 12:14:42 PST 1990 - Correct disassembly (CA manual was right after all): - opcode for sysctl is 0x659 - - Mon Oct 23 12:03:04 PDT 1989 - Use G960BASE and G960BIN environment variables to find 'sx' utility. - - Mon Oct 16 14:15:09 PDT 1989 - "sfr0"-"sfr31" should have been named "sf0"-"sf31" - - Mon Oct 2 15:56:31 PDT 1989 - - Added 960CA disassembly support. - - To simplify maintenance: - - eliminated use of symblic links on pinsn.c: use i960-pinsn.c - directly instead. - - eliminated opcode.h: incorporates tables into i960-pinsn.c - - moved 960-specific routines from i960-pinsn.c to i960-md.c - - made disassembly interface identical to that in gdmp960. - - - -Wed Nov 28 21:32:48 1990 John Gilmore (gnu at cygint) - - * target.h: Allow targets to stack. Add target_has_memory, - _registers, etc. Restructure memory access and "info files" - to walk the target stack. - * exec.c, core.c, inftarg.c, remote.c, remote-vx.c, remote-eb.c, - target.c: Change tables to match target.h. - * inflow.c (child_mourn_inferior): pop child_ops. - (generic_mourn_inferior): Use new has_stack flag. - * infptrace.c (child_xfer_memory): New memory regime. - * inftarg.c (child_files_info): New "info files" regime. - * remote-eb.c: New memory regime, new info files. - * remote-vx.c: New memory regime, new info files. Now use - separate targets for VxWorks attachment to machine, and - actually running a process under VxWorks, since one has - stack & execution & regs and the other doesn't. - * remote.c: New memory regime, new info files. - * sparc-xdep.c (fetch_core-registers): New memory regime. - * target.c: New routines and support for stacked targets, - new memory regime, new info files regime. - - - Generalize section handling for an arbitrary number of sections, - including use of the new BFD (binary file) library. - * gdbcore.h: Add struct section_table. - * exec.c (build_section_table): Iterate all sections and - record what gdb needs to know about them. - (exec_command): Use it. - (exec_xfer_memory): Use the table. - (exec_files_info): Print the table. - * core.c (core_file_command, core_xfer_memory, core_files_info): - Likewise. - * source.c (find_source_lines): Use bfd_get_mtime. - * dbxread.c: Quick changes to make it compile with new BFD. - * utils.c (error): Avoid using bfd_error in generic routines. - - * core.c (core_fetch_registers): Get from the ".regs" section of - the BFD core file. - * sparc-xdep.c (fetch_core_registers): Use the .regs info. - - * inferior.h (attach_flag): Export. - * infcmd.c (run_command): use new target_create_inferior. - * infrun.c (child_create_inferior): Don't return result. - * Makefile.dist (VERSION): 3.91.4. - -Fri Nov 23 28:15:38 1990 John Gilmore (gnu at cygint) - - * breakpoint.c (bpstat_num): Handle breakpoints which have - since been deleted, such as temporary breakpoints. - infcmd.c (program_info): ditto. - - * core.c (core_file_command): Display the frame where the core - dump occurred. - - * main.c: lint. - - * remote-vx.c (target_command): Merge in target command from - targ-vx.c. A few other cleanups. - - * TODO, Projects: Lots more stuff to do... - -Fri Nov 23 18:15:38 1990 John Gilmore (gnu at cygint) - - Massive changes to wall off the remote-debugging interface - behind a function vector. The port to handle VxWorks targets - is also part of this. - - All files: Replace references to renamed functions, - remove references to remote_debugging, remove references to - have_include_file, have_core_file in favor of target_has_stack, - target_has_memory, etc. - - * Modularize the breakpoint interface. - breakpoint.h (BREAKPOINT_MAX): New define sets max length of - a breakpoint instruction. - breakpoint.c: struct breakpoint's shadow_contents now sized as - BREAKPOINT_MAX. - (insert_breakpoints): Vector to target to install breakpoints. - (remove_breakpoints): Vector to target here too. - Remove REMOTE_SA_SPARC kludges and other remote_debugging. - sparc-tdep.c (single_step): Use new breakpoint interface for - the single-step breakpoints. - mem-break.c (memory_insert_breakpoint, memory_remove_breakpoint): - New file, contains routines to insert and remove breakpoints by - reading out the old contents and later replacing them. This is - how ptrace breakpoints work, and many remote systems as well. - - * tm-vxworks68.h: New config file, overrides a few things for - Wind River's preferences. - - * target.h: New file, for transfer vector used to talk to the - inferior (child, attached, core, exec, remote, etc). All accesses - to the thing being debugged should come through these vectors. - target.c: New file, routines to handle transfer vector. - (various files): Add transfer vectors XXX_ops for the various - targets and pseudo-targets (core files, etc) we support. - - * breakpoint.c (bpstat_stop_status): Further explorations of - watchpoints and why things don't work all the time. - (bpstat_alloc): New fn to allocate a bpstat and chain it. - - * config.gdb: Only add "source ${srcdir}/.gdbinit" to - the local gdbinit if it doesn't already have it. - - * core.c (core_ops): add and install. - Allow core debugging without exec file. - - * dbxread.c (free_and_init_header_files): Merge two fns. - (end_symtab): Free named symbol table when a new version comes in. - (read_dbx_symtab): Relocate all kinds of symbols with base - address. First step toward handling different text, data, bss - reloc. - (add_file_addr_command): Renamed add_file_command. - (add_file_command): Vector to remote handler. - Add "load" as an alias for "add-file" command. - - * defs.h: Allow "volatile" to be used in non-ANSI; use it for - non-returning functions. - - * exec.c: Add exec_ops, and push it as a target when an exec - file is specified. - - * infcmd.c (run_command): Pass executable file name and arg list - separately when starting an inferior. Permit "run" when no exec - file is specified, for VxWorks. - (detach_command): Move to child_detach in inftarg.c. - - * inftarg.c: New file. Unix-child-specific routines, and the - child_ops structure. - - * inferior.h (registers): Export "registers" as the way for - target dependent register handlers to find gdb's local copy of - the registers. Rename "stop_after_attach" to "stop_soon_quietly" - since it is now used by places that want wait_for_inferior to - handle the grunge but want to see every trap from the inferior. - - * inflow.c (create_inferior): Pull out, and merge into infrun.c. - Eliminate remote_debugging hooks in terminal handling. - - * infrun.c: Replace start_inferior with child_create_inferior. - Move all the hair of Unix shells and ptrace idiosyncracies into - child_create_inferior, so remote handlers don't have to deal. - Remove running_in_shell. Rename stop_after_attach to - stop_soon_quietly, and use it in a few other places where we want - to just call wait_for_inferior and get control back on the first - trap. trap_expected now never takes a value > 1. - (init_wait_for_inferior): Initialize static vars when a new - process is created. - - main.c (gdbinit): Add new hook for .gdbinit file name, let - it be overridden by config files as GDBINIT_FILENAME. - (DEFAULT_PROMPT): Add new hook for overriding (gdb) prompt. - Both of these are used for VxWorks gdb. - - mcheck.c: rename include file "gmalloc.c" to avoid problems - with system include file "malloc.c". - - param-no-tm.h: New include file, same as param.h but does not - include the default "tm.h" file. This is used in files where - the target is known, e.g. remote-eb.c or sparc-xdep.c. - - param.h: Now just a shell that includes tm.h and param-no-tm.h. - - remote-vx.c: New file, VxWorks remote debugging support. Uses - RPC routines that are shared with the target system, in directory - ${srcdir}/vx-share. - - remote.c: Vectorize remote interface. - - source.c: Globalize source_path, and make an alias "l" for "list" - since we now have the "load" command. - - sparc-xdep.c: Use new param-no-tm.h. - - symmisc.c (free_named_symtab): Add new function from Wind River. - However, ifdef it out for now while we think about what it should - really be doing. - - tm-sun3.h, xm-sparc.h, xm-sun3.h, xm-symmetry.h: Move - PREPARE_TO_STORE to - the xm- file, and change its name to CHILD_PREPARE_TO_STORE, since - non-Unix-children handle this with their own code in the target - transfer vector. - - Makefile.dist: Roll version to 3.92.3. Add vx-share stuff to - source and target lists. Add vx-share to default list of include - directories. Add new files to src and target lists: mem-break, - target, inftarg, remote-eb, remote-vx, targ-vx. Be sure the - ${srcdir} versions of munch and createtags are used. - - * valops.c (find_function_addr): Split out of call_function. - (call_function_by_hand): Rename call_function; this function - calls functions in the target by laboriously patching the target - word-by-word with the right stack, args, regs, etc. - - -Mon Nov 5 17:29:10 1990 John Gilmore (gnu at cygint) - - Handle AMD 29000 a bit better. - - * remote-eb.c (readchar): Mask received char log to make it readable. - (remote_start): Pass arguments down to executing program. - Make startaddr unsigned. - infrun.c (start_inferior): Accept args, pass them to - remote_start. - infcmd.c (run_command): Pass args down to start_inferior. - - * tconfig/am29k-aout, tconfig/am29k-coff: New files specifying - the target object file format. - tm-29k.h: Pay heed to COFF_ENCAPSULATE. - - * am29k-pinsn.c (print_insn): Print 0x on hex numbers in disassembly. - am29k-tdep.c (examine_prologue): Better checking of function prefixes. - -Sun Oct 7 18:20:45 1990 John Gilmore (gnu at cygint) - - * Makefile.dist (VERSION): Roll version to 3.91.9 and freeze. - * TODO: We did a few things, we have more to do though. - - * xm-sparc.h (CLEAR_DEFERRED_STORES): Define. - * inflow.c (inferior_died): Clear deferred stores. - - * Debug problems with dummy frames and calls to the inferior. - * tm-sparc.h (PUSH_DUMMY_FRAME, POP_FRAME): Move to sparc-tdep.c. - * sparc-tdep.c (do_restore_insn): Simplify. - (sparc_frame_find_saved_regs): Simplify and fix what we find. - (sparc_push_dummy_frame): Simplify and fix what we push. - (sparc_pop_frame): Slightly more hair here, deciding whether - we are restoring a saved PC or returning to a return address in %i7. - * sparc-xdep.c (read_inferior_registers): Debug if valid reg is read. - - * utils.c (xmalloc, xrealloc): Return type depends on __STDC__. - * symtab.h (xmalloc): ditto, for obstack_chunk_alloc. - * obstack.h (chunkfun): ditto. - * defs.h (xmalloc, xrealloc): ditto - - * utils.c (quit): Grab the terminal from the child if necessary. - - * inflow.c (term_status_command): Rename to term_info, change - to "info terminal". - - * sparc-pinsn.c (print_insn): Disassembly prefers real instructions. - (is_delayed_branch): Speed up. - * sparc-opcode.h: Add ALIAS bit to aliases. Fix up opcode tables. - Still missing some float ops, and needs testing. - - * Support for input and output radixes other than base 10 - * defs.h (input_radix, output_radix): Declare. - * expread.y (yyparse, parse_number): Handle changes of input - radix, and ambiguous names-or-numbers in radixes >10. - * printcmd.c (print_scalar_formatted): Print formatted hex - numbers in varying column widths. - * valprint.c (val_print): Use output_format to print scalar ints. - (set_input_radix, set_output_radix, set_radix): Create. - (set_output_radix): Set output_format from output_radix. - (_initialize_valprint): add `set radix' but leave the others off. - - * main.c (execute_command): Let stupid questions be turned off. - (_initialize_main): Handle "set stupidity", etc. - - * main.c, inflow.c, inferior.h, frame.h, command.c, defs.h, - sparc-pinsn.c, sparc-xdep.c, value.h, valops.c, values.c: Lint. - -Tue Oct 2 11:20:02 1990 John Gilmore (gnu at cygint) - - * TODO, Makefile.dist, ChangeLog: Freeze for 3.91.8 release. - bfd stuff is still screwed up, but with some manual work, it - compiles. - - * breakpoint.c (bpstat_do_actions): Start over if a command - proceeds the inferior, since the inferior will have stopped and - will need to have its new stop-actions taken care of. - - * dbxread.c (read_struct_type): Expression gives Sun3 4.0.3 - compiler fits, simplify it. - - * gdb.texinfo (directory command): Doc new dir command. - source.c (directory_command): "dir" now puts things on the front - of the path, moves dups up front, and handles multiple names - on the command line, inserting each one in order. It also - blows away cached line and full_filename info. - - * stack.c (backtrace_command): Skip "more stack frames follow" - unless interactive. - - * Change #ifndef HAVE_VPRINTF to #define MISSING_VPRINTF in - xm-convex.h, xm-hp300bsd.h, xm-isi.h, xm-merlin.h, xm-news.h, - xm-np1.h, xm-pn.h, xm-pyr.h, xm-symmetry.h, xm-umax.h, xm-vax.h. - The only odd one was Gould NP1, which had defined vprintf to - "printf"!!! - - * Merge Ted Goldstein 's changes for epoch. - printcmd.c (print_command_1): Pass 'inspect' flag down as a global - variable, inspect_it. - valprint.c (print_string, val_print): Use the global inspect_it - to indicate whether to print in Epoch style or normal style. - -Mon Oct 1 23:55:26 1990 John Gilmore (gnu at cygint) - - * printcmd.c (call_command): add an alias for the "print" command - which runs expressions and doesn't print the result if void. - (print_command_1): implement it. - - * command.c: Remove #if 0'd code. Initialize all the fields - in add_cmd (). Rename do_nothing_command to - not_just_help_class_command, and make it externally visible. - command.h: add user_commands to struct. - * main.c (define_command): Don't overload c->function with a char - string as well as a function pointer. - - * eval.c (evaluate_subexp): Reinstall tiemann changes to - calling convention of value_struct_elt () that got dropped in - merge. - - * tm-sparc.h (FRAME_FIND_SAVED_REGS): move to sparc-xdep.c. - sparc-tdep.c (sparc_frame_find_saved_regs): ditto. - - * tm-sparc.h (POP_FRAME): replace some constants with defines. - - * sparc-xdep.c (store_inferior_registers): defer stores to regs - until a good time (e.g. when we are about to run the child), - saving ptrace calls. - * infrun.c (proceed): handle DO_DEFERRED_STORES. - * tm-sparc.h: define DO_DEFERRED_STORES. - - * sparc-xdep.c (store_inferior_registers): when storing float - registers, don't store stack regs too. When storing the SP, - however, DO store the stack regs too. This fixes a bug in which - the dummy frame is not recognized when a call_function finishes, - because its frame pointer (in the stack regs) was never - initialized. - (read_inferior_registers): Mark WIM and TBR and FPS and CPS valid - even though we don't know how to read them from an inferior. - valops.c (call_function): Comment about storing SP. - - * infrun.c (save_inferior_status): Save away the original bpstat - chain so it can be restored later. Install the copied version for - use by whoever saved the status. It will be blow away by - restore_inferior_status, and the original chain restored. This is - important for people who have pointers into the original. - - * breakpoint.c, command.h, copying.awk, dbxread.c, defs.h, - findvar.c, frame.h, obstack.h, obstack.c, inflow.c, value.h, - main.c, printcmd.c, sparc-tdep.c, symtab.c, valprint.c: lint - - -Fri Sep 28 20:32:46 1990 John Gilmore (gnu at cygnus.com) - - * Makefile.dist: Roll version to 3.91.8. Add bfd.h and bfdconfig.h - temporarily to the makefile. Add am29k-opcode.h and WHATS.NEW. - Add stuff.c and kdb-start.c to the OTHERS list for tar files. - -Fri Sep 28 19:12:12 1990 John Gilmore (gnu at cygint) - - * Merge Mike Tiemann's multiple inheritance changes from Sun. - Store the baseclasses in a type struct starting from array element - 0 rather than from the unusual array element 1. - - dbxread.c: the above. - (virtual_context): Add - Read new debug information about which virtual function table - a virtual function is from, and store it in fn_field.fcontext. - - symtab.h: Add fcontextt. Fix baseclass indices. Typo in - TYPE_FN_FIELD_STATIC_P. - - symtab.c: the above. - valops.c: the above. Handle pointer casts of object *'s. - (search_struct_method): Add. - (value_struct_elt): First arg is now a pointer to a value, and is - modified on return. - - valprint.c: the above. - values.c (value_virtual_fn_field): Add type arg. Handle - offsetting to the proper object when calling virtual fns. - The above. - (baseclass_addr): Add valuep arg. - - * README: Document the current state of BFD config (missing). - * TODO, ChangeLog, Makefile.dist: Roll version. - * WHATS.NEW: Add summary of changes since 3.5. - -Thu Sep 27 16:23:12 1990 John Gilmore (gnu at cygint) - - * dbxread.c (read_struct_type): Clear bit vectors whenever - we allocate one. - symtab.c (B_CLRALL): define. - - * tm-sparc.h (STORE_RETURN_VALUE): Avoid clobbering types by - using == rather than =. Huh... This fixes the dreaded problem - wherein builtin_type_int becomes TYPE_CODE_FLT. - - * core.c (info_files): Show the inferior pid. - - * config.gdb: Avoid putting "dir" command into .gdbinit. GDB - already knows how to look in the source directory. - - * Remove psymtab hair from many places. Remove duplicated code - for searching symbol tables. Hide psymtabs from most places. - Make it fast to get from a psymtab to its symtab. - - blockframe.c (blockvector_for_pc): Remove psymtab hair. - coffread.c (psymtab_to_symtab): Rename to psymtab_to_symtab2. - mipsread.c (psymtab_to_symtab): Rename to psymtab_to_symtab2. - dbxread.c: export psymtab_to_symtab, make it work if called N times. - (psymtab_to_symtab): Rename to psymtab_to_symtab2. Initialize - new symtab completely. New psymtabs get symtab pointer - initialized to zero. Remove MI warning printf. - symtab.h: Comments. Add psymtab to symtab pointer. - (PSYMTAB_TO_SYMTAB): New macro. - symtab.c: use PSYMTAB_TO_SYMTAB. Add psymtab_to_symtab and export it. - source.c: use PSYMTAB_TO_SYMTAB. Remove symtab version and - compilation fields. - stack.c (backtrace_command): Avoid pre-pass to read symbols, if - verbose is not set. - (print_frame_info): Avoid special-casing symbols that have not yet - been read in. - - * source.c (open_source_file): Quick path if we have already - located the source file by its full name. - - * symtab.c (lookup_symbol): Use find_pc_symtab rather than - find_pc_psymtab. When a name is found in the misc function - vector, search the symbol table for its mangled name, not the - name that the user typed. - - * bfd.h: Fix missing comment terminators, make #endifs match. - - * valarith.c (value_less): Handle unsigned int comparisons. - Add FIXME about pointer compares, which assume host and target - pointers are the same. - - * command.c (do_nothing_command): lint - dbxread.c: lint. Remove sort_syms. Document C++ visibility info, - fix comments on debug symbol format for visibility. Actually set - visibility of symbols. - main.c (echo_command): lint; use . - tm-sparc.h (FRAME_FIND_SAVED_REGS): lint - obstack.h (_obstack_blank): Rearrange pointer math to avoid - pointing past end of allocated memory; saber complains. - obstack.h: Declare the external functions that we use. - valarith.h: use - solib.c (solib_add): lint. - -Fri Sep 21 17:05:19 1990 John Gilmore (gnu at cygint) - - * main.c (initialize_main): Default info_verbose to off, now that - symbol reading is fast. - (quit_command): Avoid clobbering exec_bfd while quitting. - - * Initial BFD (binary file diddling library) merger: - coffread.c: Change AOUTHDR to struct exe_hdr. - dbxread.c: ditto. - core.c: initialize initialized data at compile time. - (core_file_command): Move from coredep.c, convert to bfd. - (xfer_core_file): Convert to bfd. - exec.c (exec_file_command): use bfd routines. - gdbcore.h: BFD. - mips-tdep.c: Remove exec_file_command and friends. - source.c: bfd. - - * coredep.c: (fetch_core_registers) Convert core_file_command to - fetch_core_registers. - mips-xdep.c, sparc-xdep.c, sun3-xdep.c: ditto. - - * utils.c: (error): Bogus crap, FIXME, to print bfd errors. - (my_bfd_read): More bogosity, which I don't think we call. - (program_name): Remove this atrocity asap! - -Wed Sep 19 13:36:41 1990 John Gilmore (gnu at cygint) - - * From Per Bothner: - values.c: allocate_repeat_value was not clearing the - optimized_out field. - (value_static_field): minor stylistic fix (wrong macro was used). - valops.c (value_struct_elt_for_address): didn't work for C++ - static fields. - - * signame.c (_initialize_signame): Initialize signal names once. - - * breakpoint.h, command.c, copying.awk, defs.h, environ.c, - exec.c, frame.h, infcmd.c, inferior.h, main.c, munch, sun3-xdep.c, - symtab.h, tm-29k.h, valprint.c, value.h, values.c: Lint. - - * remote-eb.c: Support user-settable baud rates on the serial port. - - * tm-sun3.h (PREPARE_TO_STORE): fix typo. - -Fri Sep 14 13:28:29 1990 John Gilmore (gnu at cygint) - - * tconfig/sun3os4: Remove warning about native assembler, - since it also occurs in the xconfig file. - - * findvar.c (registers): Allocate some slop after `registers' - to prevent stray accesses from trashing the next variable. - - * tm-68k.h (REGISTER_BYTES): Allocate the right number of bytes - on the sun-3, by changing the #ifdef from `sun3' (which is not - defined by cc) to `sun'. Symptom was trashed builtin_type_XXX - vars, which happened to follow `registers' in the executable. - - * readline/history.c (history_search): Heed gcc-2's advice - and parenthesize && inside ||). - - * am29k-opcode.h, am29k-pinsn.c, am29k-tdep.c, remote-eb.c, - tm-29k.c: Insert FSF copyright headers. - - * remote-eb.c: Better comments. - - * Makefile.dist: Update to 3.91.6. - * TODO: note PREPARE_TO_STORE problem. - -Thu Sep 13 09:52:33 1990 Jim Kingdon (kingdon at cygint) - - * stack.c (frame_info): Only use FRAME_FIND_SAVED_REGS if defined. - - * remote.c: Wrap the whole file in #if !defined (SPECIAL_REMOTE). - - * infrun.c (wait_for_inferior, at end): Don't set up - prev_* if the inferior no longer exists. - - * inferior.h (CALL_DUMMY_LOCATION): New macro, to replace - CANNOT_EXECUTE_STACK. - valops.c (call_function): Use it. - - * tm-convex.h: Add CALL_DUMMY_LENGTH for use by PC_IN_CALL_DUMMY. - - * inferior.h (PC_IN_CALL_DUMMY): New macro. - infrun.c (wait_for_inferior, 2 places): Use it. - - * values.c (value_being_returned): Only use - EXTRACT_STRUCT_VALUE_ADDRESS if defined. - - * Move PREPARE_TO_STORE from xm-sun3.h to tm-sun3.h to do the - right thing for remote-eb.c. - - * sun3-xdep.c: Remove extraneous call to remote_store_registers. - * sun386-xdep.c, hp300hpux-xdep.c, sparc-xdep.c: Ditto. - - * blockframe.c: Put get_frame_saved_regs inside #if !defined - (FRAME_FIND_SAVED_REGS). - - * findvar.c ({fetch,store}_registers): Check for - REMOTE_{FETCH_STORE}_REGISTER macro. - - * findvar.c (get_saved_register): Add argument lval and - change meaning of argument addr. - findvar.c: Change calls to get_saved_register to reflect - new calling convention. - valops.c (value_assign): Use get_saved_register instead of - find_saved_register. - -Sun Sep 2 12:40:20 1990 Jim Kingdon (kingdon at cygint.cygnus.com) - - * coffread.c (read_one_sym): Make temp_aux an AUXENT, not - an (uninitialized) pointer to one. Use "&" when passing it - to fread. - -Fri Aug 31 22:57:54 1990 Jim Kingdon (kingdon at cygint.cygnus.com) - - * coffread.c (getfilename): Use DGUX x_offset and x_name if - defined. - - * coffread.c (symbol_file_command): Put semicolon after - "int from_tty". - Put safe_to_init_tdesc_context in #if defined (TDESC). - Put #ifdef TDESCs in 1st column for non-ANSI cpp's. - coffread.c: #include . - (read_coff_symtab): Typo: in_source_files -> in_source_file. - Add missing ')' in check for "lc%" and friends. Remove - extraneous '}'. - Declare read_one_sym() at top of file. - (read_file_hdr): Put in extra #ifdefs so MC68MAGIC and - MC68WRMAGIC can have the same value without causing a duplicate - case. - -Thu Sep 13 15:55:36 1990 John Gilmore (gnu at cygint) - - * Allow a Makefile to be built without building the - tm and xm file links that screw up builds in subdirectories. - This is done with `config.gdb none', then you can do things - like `make gdb.tar.Z'. - * tconfig/none: Config file for no target system - * xconfig/none: Config file for no host system - * config.gdb: If no TM or XM files are called out by the - host or target file, don't make links for them. - - * cplus-dem.c: Add documentation. - - * dbxread.c (read_ofile_symtab): Turn a fatal error into a - simple error, so the user's gdb doesn't crash due to some object - file problem (e.g. somebody is rebuilding the file out from under - gdb). - - * printcmd.c (print_address_symbolic): demangle the symbol. - - * Makefile.dist (OTHERS): Remove tdesc-lib because it has - Motorola copyrights in it. Make "make gdb.tar.Z" work. - (alldeps.mak): sort and uniq all results from this; duplicates - hose gdb.tar.Z link building. Remove RCS files from - tconfig and xconfig. Add config files for sun386. Add - a few odd files to OTHERS and HFILES. - -Mon Sep 10 21:20:24 1990 John Gilmore (gnu at cygint) - - * Makefile.dist: Pull solib.c to tconfig/sun?os4. - Roll version number to 3.91.5. Make lint work in bindir. - - * README: Document cross-debugging and new file structure. - - * blockframe.c: Lint. Include "value.h" to declare read_register. - (find_pc_partial_function): remove duplicate line. - - * command.h: Lint. Declare error_no_arg and dont_repeat. - - * tm-news.h: Remove inadvertently duplicated stuff. - - * mipsread.c: Remove cache_pc_function stuff, now done cleanly. - Clean up usage of misc_function_type. Declare some CORE_ADDRs. - - * config.gdb: Allow `config.gdb host target' form. Clean - up previous change that printed bogus messages when you just said - `config.gdb'. - - * core.c: #include "command.h" for lint. - * dbxread.c: lint - * eval.c: lint - * main.c: Remove some casts of enums. Lint. - * source.c: lint - * symtab.c: lint - * symtab.h: lint - * expread.y: lint - * valarith.c: lint - - * printcmd.c (initialize_printcmd): Fix thinko in inspect cmd. - - * sparc-tdep.c (isannulled): Take instruction as parameter, don't - read it from memory. This will allow us to save ptrace calls - eventually. Changed caller single_step too. - - * sparc-xdep.c (fetch_inferior_registers): Avoid reading regs - that we aren't going to use, saving many ptrace calls, especially - when watchpointing or single stepping. Use some #define's for - constants. - (store_inferior_registers): Ditto. - (core_file_command): Use some #define's for constants. - - * tm-sparc.h: Add #define's for some register numbers, so we - can eliminate the use of random constants in sparc-xdep.c. - - * stack.c (frame_command, print_frame_info, up_command, - down_command) Remove frame_changed, since it - causes a bug and doesn't seem to do anything useful. In some - places it was used as a flag, in others as a stack level (?). - - * utils.c: Use MISSING_VPRINTF rather than HAVE_VPRINTF, so the - default is to use the portable (vprintf) version rather than the - kludge version. - * xm-news.h (MISSING_VPRINTF): Add. - - * valprint.c (val_print): Demangle fancy vtbl printouts. Lint. - -Sat Sep 8 00:24:12 1990 John Gilmore (gnu at cygint) - - * Remove stuff that forces -Bstatic linking of gdb, and warnings - about linking debugged programs -Bstatic in the sun?os4 config - files in tconfig and xconfig subdirectories. - - * main.c (main): Remove unreached exit(0) now that we exit - via quit_command(). - - * Create TODO file for online bug list. There are too many - "little" bugs to keep track of on paper. - - * Change Projects file to refer to bug-gdb@cygnus.com - rather than kingdon@ai. - -Fri Sep 7 23:35:15 1990 John Gilmore (gnu at cygint) - - * Makefile.dist (VERSION): 3.91.4 now. - - * symtab.c (init_misc_bunches): Rename from init_misc_functions. - (condense_misc_bunches): Add sanity check that misc_count is - the same as the number of symbols in the bunch. - - * coffread.c: rename init_misc_bunches. Pass an argument - to condense_misc_bunches (a zero). - - * dbxread.c (partial_symbol_file_read): Call init_misc_bunches - every time we are called; don't rely on our caller to do it. - (add_file): Remove call to init_misc_bunches. - - * mipsread.c: Only warn, don't error, if unknown symbol types. - This keeps an old gdb from falling on its face if it sees newly - extended symbol info. Rename init_misc_bunches. - -Fri Sep 7 22:58:15 1990 John Gilmore (gnu at cygint) - - * Merge in changes from Per Bothner for DECstations and other - MIPS stuff. The rest is Bothner speaking: - - The next message is a merger of Alessando Forin's mips port with - mine. I've tried to use my good if biased judgment to get - the best of both. It *does* need testing. - - Some of the changes are general, *not* mips-specific. - - param.h: - Didn't believe in little-endian bit order. - There are still inconsistencies about whether flags - like BITS_BIG_ENDIAN are integer (#if ...) or - boolean (#ifdef ...). I tried to paper over them. - - dbxread.c,coffread.c,mipsread.c,symtab.c,symtab.h: - Moved some misc_function code that was common to - {dbx,coff,mips}read.c to symtab.c. - In the process, I think I cleaned things up a bit. - At the same time, moved obsavestring and obconcat to symtab.c. - - dbxread.c: - Removed obsolete condense_addl_misc_bunches (use - condense_misc_bunches(1) instead). - - exec.c: - Needed to include , at least on DECstations. - - valops.c, mips-tdep.c, tm-mips.h: - Added PUSH_ARGUMENTS macro to support funny argument-pushing - conventions (when STACK_ALIGN is insufficient). - Needed on mips, where doubles need 8-byte alignment, - but ints only need 4. - - mips-opcode.h: - Removed cruft that was not being used. - Merged in many fixes (most from Frank Yellin, fy@lucid.com). - - mips-pinsn.c: - Print $ before register-names (I think that makes things a little - more consistent). - Never print two instructions, even if one delays. - Removed hex-disassemble set_cmd. (This is not mips-specific, - so I think the argument is whether it is generally worthwhile or not. - I'm inclined to think not, given how easy it is to - convert between radixes in gdb.) - - mipsread.c: - This is basically Alessando's code. - It doesn't use obstacks; I changed it to use obstacks - in a few minor places where using malloc causes a - memory leak. (Probably, more places could/should be changed.) - I added record_misc_function where it was missing. - In symbol_file_command and add_file_command, I tried - to make the code consistent with more recent versions. - Minor sylistic changes in parse_procedure. - Make a .gdbinfo. psuedo-symbol point back to the real - procedure symbol (using the isym field). - - mips-tdep.c: - This is basically from my port, but with a lot of details - and a number of routines merged in from Alessando's version. - I basically used my code "raw" backtrace (use heuristics - from the actual code, rather than symbol table info) - though - the idea is Alessandro's. I feel my code is a little cleaner - here, particularly in being a little more flexible, such as being - able to handle gcc-produced code (which it now can). - It also doesn't do frame caching (which is not useful - more recent gdb versions). - I also used my code for push_/pop_dummy, more or less. - I tried to incorporate AF's code for testing sigtramp - while backtracing; I probably got it wrong. - Added mips_print_register, which tries to scrunch as much - information as possible on a screen... - Removed the skip-prologue set_cmd. As with hex-disassemble (see - under mips-pinsn.c), I don't see anything mips-specific here, - and I don't see it being all that useful anyway. - - tm-mips.h: - Added a $fp psuedo-reg distinct from $fp (nice for gcc). - Use more register names (rather than hard-cases numbers). - -Thu Sep 6 18:33:15 1990 John Gilmore (gnu at cygint) - - * Hack up 3.90.11 changes: - - * Makefile.dist (depend): parameterize $(GCC). - Add solib.c and solib.o. - (readline): Fix vpath for both absolute or relative SRCDIR. - - * blockframe.c: Fix from Schaefer@asc.slb.com for shared libs. - Also, let the part I didn't understand at least compile so - I can test the rest. FIXME. - - * dbxread.c: Fix thinko using strcmp. - (init_psymbol_list): declare static. - (partial_symbol_file_open): Comment cleanups better, avoid - cleaning up the string table since the caller will do that. - Move the stat for mod time into symbol_file_command, temporarily. - (There should be a mod time for each symbol file, eventually, - to control its rereading. FIXME.) - - * infptrace.c (PT_WRITE_D): use same value as PT_WRITE_I for - SunOS, which gives error for shared libs otherwise. (From - Schaefer, probably FIXME needs work for portability.) - - * solib.c: Move #include "param.h" to work. - Lowercase all the Uppercase Letters In the Messages. - (find_solib): Clean up inferior_so_name for debug printouts. - Allow no argument, to mean all shared libraries. - - * symmisc.c: include param.h to get CLEAR_SOLIB. - -Wed Sep 5 18:00:08 1990 John Gilmore (gnu at cygint) - - * Merge in Kingdon's changes from FSF: the diffs from 3.90.9 - to 3.90.11. ChangeLog entries below are from this. - -Wed Jun 13 09:17:39 1990 Jim Kingdon (kingdon at mole.ai.mit.edu) - - * Version 3.90.11. - - * Makefile.dist (HFILES): Add tm-sunos.h. - -Tue Jun 12 16:15:26 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * Version 3.90.10. - - * Makefile.dist (gdb.tar.Z): Change linking of config so it works. - -Thu Jun 7 16:22:27 EDT 1990 Jay Fenlason (hack@ai.mit.edu) - - * sparc-opcode.h Added single-operand version of rett. - -Mon Jun 4 18:12:31 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * m-sparc.h (REG_STRUCT_HAS_ADDR, STRUCT_ARG_SYM_GARBAGE): - Put parens around gcc_p in expansion. - -Thu May 24 15:44:51 1990 Jim Kingdon (kingdon at mole.ai.mit.edu) - - * utils.c (lines_to_list): Return 10 if lines_per_page == 0. - -Wed May 23 16:36:04 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * Changes for Sun shared libraries: - blockframe.c (find_pc_partial_function): If a non-text symbol - is found, set *address = pc - FUNCTION_START_OFFSET. - breakpoint.c (insert_breakpoints) [DISABLE_UNSETTABLE_BREAK]: - Disable breakpoints instead of giving an error. - source.c (select_source_symtab): Initialize cs_pst. - symmisc.c: Call CLEAR_SOLIB if defined. - symtab.h: Make text{low,high} CORE_ADDR not int. - (psymtab): New field addr. - solib.c: New file. - dbxread.c: Move DECLARE_FILE_HEADERS outside functions. - (record_misc_function): Give correct type for N_DATA symbols. - (condense_misc_bunches): do "misc_function_count = j" regardless - of inclink. - Take code which is shared between symbol_file_command and - add_file_command and put it into partial_symbol_file_{open,read}. - Split add_file_command into add_file_command and add_file. - Make psymtab_to_symtab read in the string table if the file - is not symfile. - Two new parameters to read_dbx_symtab and start_psymtab. - tm-sunos.h: New file. - -Tue May 22 17:43:03 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * infcmd.c: Change cont_command to continue_command and "cont" - to "continue". - -Mon May 21 14:41:41 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * breakpoint.c (enable_breakpoint): Get value of watchpoint. - - * defs.h [sparc]: Use regardless of __GNUC__. - - * values.c (USE_STRUCT_CONVENTION): Check for structures of - size 1,2,4,8 rather than size < 8. - - * dbxread.c (dbx_lookup_type): Do f->length *= 2 as many times - as necessary, not just once. - - * sparc-opcode.h: Add a bunch of new opcodes which Sun as supports. - -Thu May 17 15:04:09 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * {t,x}m-sun386.h, sun386-xdep.c, {x,t}config/sun386 - - * tm-news.h: Add CALL_DUMMY_*. - - * tm-68k.h: Remove duplicate comment at FRAME_FIND_SAVED_REGS. - - * config.gdb: In list_host, list_target, use ${i}, not $i. - -Tue May 15 21:27:12 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * source.c (find_source_lines) [BROKEN_LARGE_ALLOCA]: Use xmalloc. - - * sparc-opcode.h: Change all store floating-point state register - instructions to have the right match & lose fields. - -Sat May 5 12:39:18 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * Makefile.dist: Move -I${srcdir} to GLOBAL_CFLAGS and pass - VPATH to readline. - config.gdb: If srcdir != ., create readline directory and - copy a makefile into it. - - * wait.h, infrun.c: Change WRETCODE to WEXITSTATUS for - consistency with POSIX. - - * breakpoint.c (bpstat_stop_status): Disable watchpoint - when we exit its exp_valid_block. - -Tue Sep 4 11:46:46 1990 John Gilmore (gnu at cygint) - - * Makefile.dist: Bump version to 3.91.3. - - * Clean up handling of breakpoint commands (somewhat). - Prompted by Tiemann bug report "cont 10" doesn't work any more. - - inferior.h: Add breakpoint_proceeded to inferior status struct - and globals; save it and restore it. - (clear_breakpoint_commands): Cleanup, remove old #define. - - infrun.c (clear_proceed_status): Set breakpoint_proceeded. - (save_inferior_status, restore_inferior_status): handle it also. - (proceed): Remove earlier code that set breakpoint_proceeded. - It is now set only in clear_proceed_status. - (clear_proceed_status): Cleanup, use bpstat_clear rather - than clear_breakpoint_commands. No callers need the stop_bpstat - between clear_proceed_status and proceed. - - infcmd.c: Add breakpoint_proceeded definition and comment. - (cont_command, jump_command, signal_command): Move call to - clear_proceed_status right next to call to proceed. - - breakpoint.c (bpstat_do_actions): Avoid clobbering our - caller's argument while running down the chain of breakpoints. - Use new variable "breakpoint_proceeded" to determine when - a command that it executes moves the inferior past the - breakpoint. - (bpstat_clear): Handle NULL argument. - (bpstat_clear_actions): Avoid useless call to - breakpoint_auto_delete. - (delete_breakpoint): Clean up bpstat's that are pointing to - the deleted breakpoint from the stop_bpstat chain. - (breakpoint_auto_delete): Simplify. - - * Clean up handling of EOF, error on stdin, etc. This was - prompted by a network problem that caused gdb to go into an - infinite loop filling up its malloc'd memory. - - main.c (return_to_top_level): Cleanup: call bpstat_clear_actions, - not clear_breakpoints_commands, which is now gone. - (main): If command_loop returns (e.g. from EOF on stdin), do - a quit_command (looping back to command_loop if quit_command - doesn't really quit). - (command_loop): check result from command_line_input and - exit if it returns NULL, rather than passing the NULL to - execute_command. - (gdb_readline): Free malloc'd result space before returning - NULL for EOF. - - * utils.c (query): Handle C-d to mean "yes", just as if the - input was not a terminal. Also avoid infinite loop if EOF - occurs in mid-input-line before newline. This allows - query to be used at EOF on stdin with reasonable results. - - * infrun.c (proceed): Set breakpoint_proceeded. - - * values.c (value_as_long): Avoid infinite recursion for enums. - (_initialize_values): Fix typo in help msg (kingdon). - - * Makefile.dist (RL_LIB): Use RL_LIB_DEP for dependencies, - RL_LIB for linking. This allows -lreadline for linking - and nothing for dependencies, once readline is a real library. - - * config.gdb: Jim Kingdon: give useful error message if the - host or target type is not recognized. - - * defs.h (alloca): SPARC does not declare alloca, - it just defines it. Dumb, but deal with it. - - * Jim Kingdon suggests: - in xconfig/sun3os4, CFLAGS should be XM_CFLAGS. - -Wed Aug 29 18:03:27 1990 John Gilmore (gnu at cygint) - - * Makefile.dist (VERSION): Bump version # to 3.91.2. - - * Clean up Bothner's changes. - - * blockframe.c (clear_pc_function_cache): New function. - * blockframe.c: remake cache_pc_function_* static. - * dbxread.c (symbol_file_command): remove references to - cache_pc_function_* variables. - * dbxread.c (read_struct_type): Use VOFFSET_STATIC. - * printcmd.c: Avoid kludging a global variable (addressprint) - to avoid printing the address of a string twice. Instead, - pass the format letter 's' down low enough that it can be seen - to avoid this problem. - (print_formatted): Pass format arg to value_print. - (restore_addressprint): Remove function. - (do_examine): Avoid hacking addressprint, cleanups and such. - (print_frame_args): Add a comment to a Bothner change. - * symtab.h: define VOFFSET_STATIC and use it instead of "-1". - * symmisc.c (free_all_symtabs): Call clear_pc_function_cache - to wipe out the values cached in blockframe.c. - * symtab.c (find_method): Add comment saying how big you must - allocate to be "big enough". Per being terse again. - * valprint.c (val_print): Handle format letter "s" to print - strings without addresses. Add comment to vtbl printing code - which casts with wild abandon. Rearrange reference-printing - code so it prints: - @0xaddr: value (print w/addressprint) - value (print w/~addressprint) - @0xaddr (parameter lists w/addressprint) - or nothing (parameter lists w/o addressprint) - -Tue Aug 28 10:47:18 1990 John Gilmore (gnu at cygint) - - * Merge more changes from Per Bothner: - -Gdb's handling of TYPE_CODE_REF was so counter-C++ (and otherwise -annoying) that I tried to improve it. Here are my suggestions. - - These patches all attempt to handle TYPE_CODE_REF (as in C++) better. - - findvar.c: - Do automatic de-reference when taking the address of a reference. - printcmd.c: - Don't deref_ref when printing parameter lists. - valops.c: - More attempts at treating refernences properly. - valprint.c: - In val_print, if deref_ref==0, don't print dangling " = ". - value.h: - Add COERCE_REF macro, which de-references an REF. - - * Merge changes from Per Bothner: - -* Fixed (Sony news)-specific configuration problems. -* Fixed other problems with using vanilla pcc and libc (enum problems; -assumption that vsprintf exists). -* Some major speed-ups (finc_pc_partial_function now caches a match; -parsing avoids duplicate symbol_lookup calls). -* Changed handling of baseclasses (no longer use baseclasses field -of struct type, use the first n_baseclasses fields instead). -* Various minor changes/fixes, most C++-related. - -blockframe.c: -Cache the most previous match from find_pc_partial_function. -(Save both low and high ends of matching function's pc range.) -This speeds up the loop of infrun.c:wait_for_inferior quite -a bit, and makes step/next commands much zippier. -command.c: -Added an enum->int cast (otherwise, some compilers barf). -dbxread.c: -No longer set baseclass offset to 0, since multiple -inheritance now mostly works. -Added a number of casts, to shut up compiler warnings -(after stabs where made enums, not ints). -When discarding a symbol table (in symbol_file_command), -must clear the cache introduced in blockframe.c. -Don't convert $vtbl_ptr_type to vtbl any more. -Get rid of TYPE_BASECLASEES and baseclass_vec (see also symtab.h). -Mask off sign bit emitted by g++ for virtual table offset. -Set voffset to -1 (not 1) for static member functions. -expread.y: -Changed parsing/lexing of names to avoid doing symbol lookup twice -(once when lexing to determine symbol class, once for real). -Now only call symbol_lookup once. Fields of 'this' win especially big. -printcmd.c: -Subpress printing addr twice in the case of 'x/s addr'. -symtab.c: -lookup_basetype_type is no longer used. -Add find_methods as recursive helper function to decode_line_1. -This allows multiple inheritance to work. -Also, once one or more matches has been found, do not look in -base-classes. (Baseclass methods would be overridden, anyway.) -symtab.h: -Removed baseclasses array in struct type. -Instead of using baseclasses[i], use fields[i-1]. -Added virtual_field_bits[i] to indicate if the i'th baseclass is virtual. -Changed sign convention of voffset (previous was inconsistent). -tm-news.h: -Some macros (CALL_DUMMY and relatives) were missing. Put them back. -utils.c: -Used to assume existence of vsprintf. Re-written to not need it -if HAVE_VPRINTF is undefined. -valops.c: -typecmp was too pessimistic. Made it less so. -valprint.c: -Don't print space after address. -If vtable points to a misc symbol (with 0 offset), print it, -since that indicates the actual class of the object. -Changed ype_print_derivation_info to use new inheritance -scheme (without baseclasses vector). -values.c: -In value_primitive_field, fixed some bugs left over from previous set of fixes. -Also, changes needed because TYPE_BASECLASSES were removed. -xm-news.h: -REGISTER_U_ADDR didn't work for PC. Rewrote to use an array. - -Tue Aug 21 20:08:54 1990 John Gilmore (gnu at cygint) - - * source.c: - If there is no path set, and the symbols don't indicate what directory - a file was compiled in, look in the current directory. But either - a path or a known compilation directory will prevent this. - - * dbxread.c: - Three independent bug fixes: - * Remove the #if 0 block that breaks some stuff. - * SunOS 4.1 fixed the promoted-parameter-wrong-addr bug in Sun C; - adapt gdb to either SunOS 4.0.* or 4.1. - * MAX_OF_TYPE and MIN_OF_TYPE thinko. By tedg@sun, I think. - - * symtab.c: - Instantiate the class T when looking for methods in it. (Tiemann@sun) - - * valprint.c: - (type_print) Demangle the name being printed. - (type_print_base) Handle botched demangling without coredump (tiemann). - - * values.c: - (check_stub_method): Document routine. - (tiemann) fix bug for no-arg functions - Avoid clobbering beyond end of malloc'd storage. - Terminate the argument list properly. - -Sat Aug 18 01:29:59 1990 Per Bothner (bothner@cs.wisc.edu) - - * Changes merged by John Gilmore: - -breakpoint.c: - In breakpoint_1, use new print_address_symbolic instead - of find_pc_partial_function. (This forces use of assembler-level - addresses, and avoids misleading non-mangled source-level names.) -cplus-dem.c: - Generalize ansi argument such that -1 means skip arglist totally. - Removed global variable print_ansi_qualifiers (which made - code non-reentrant), in favor of extra explicit arguments - to internal routines. -printcmd.c: - Add new helper function print_address_symbolic. - Use find_pc_misc_function instead of find_pc_partial_function - (since we want assembler-level symbols here). -stack.c: - Print unknown function as just "f (...)", not "f (...) (...)". - Use new fputs_demangled explicitly. -symtab.c: - Fixed a typing violation (problem: value.h cannot be imported - without renaming many variable in this file). - lookup_symbol: If no matching misc_func, look for a C++-mangled name. - decode_line_1: Moved forward some never-reached code. - Made decode_line_2 skip function prologues correctly. -utils.c: - fputs_filtered should not demangle by default. - Add new fputs_demangled to demangle on demand.. -valops.c: - Change value_struct_elt to use value_primitive_field (using recursive - utility function search_struct_field). This allows foo.bar to work - for multiple inheritance (so far only for data fields). - Change check_field in the same way (recursive helper function - to support multiple inheritance). - (Note: there are more of these problems that I haven't fixed. - Any code that says TYPE_BASECLASS (t, 1) is probably wrong.) - value_of_this: 'this' symbol name is now just "this", note "$this". -valprint.c: - Don't print static members. - Avoid printing "members of " if there are none. - Simplified type_print_derivation_info by merging duplicate code. - Remove useless blank lines in type_print_base (ptype command). -value.h: - Added declaration of new routine value_primitive_field. -values.c: - Added value_primitive_field which is generalized version of - value_field that can handle multiple inheritance (non-zero offsets etc). - Re-implemented value_field to call value_primitive_field. - -Fri Aug 17 23:33:44 1990 John Gilmore (gnu at cygint) - - * infcmd.c -- insert else to avoid 'delete env' coredump when you - delete the whole environment. Karl Berry reported the bug. - * source.c - fix openp to avoid //'s in filenames, which - trigger an Emacs bug causing it to not be able to find files - when running gdb in a window. - * dbxread.c - zap the #if 0 that botches the add-file code. - It seems to work a lot better without all the code commented out. - -Fri Jul 20 16:58:46 1990 John Gilmore (gnu at cygnus.com) - - * Merge Tiemann's and Ted Goldstein's changes, detailed below, - into gdb-3.90.9. - -Tue Jul 17 19:34:33 1990 Ted Goldstein (tedg at golem) - - * Makefile - added a ${CFLAGS} to a couple of entries, - added remote-sa.sparc.c - * added remote.sa-sparc.c, a modification of remote.c - which conducts a dialog directly with the SparcStation prom. - * breakpoint.c, infrun.c, sparcdep.c added - remote_insert_breakpoint(), and remote_remove_breakpoint() - to breakpoint.c instead of directly writing breakpoint instructions. - * sparcdep.c on remote_debugging,there is no need - to remove signle step breakpoint instructions. - * main.c added "-epoch" flag and "int epoch_interface" to main.c - global variable - * printcmd.c - epoch interface sends lisp expressions to open up - epoch windows on inspection. - * valprint.c - added arrayprint, and addressprint and made adding - format controls easier - * wait.h added a couple of undef's because we were getting - complaints about WSTOPSIG and WTERMSIG begin redefined. - - -Wed Jul 4 05:27:51 1990 Michael Tiemann (tiemann at masham) - - * symtab.c (decode_line_1): Add support for handling method stubs - in the type information. - -Tue Jul 3 09:39:18 1990 Michael Tiemann (tiemann at masham) - - * values.c (baseclass_addr): Run loop from INDEX+1 to - N_BASECLASSES; otherwise, we can still get into a loop. - @@ This should be restructured to use a cleaner search strategy. - -Sun Jul 1 12:28:51 1990 Michael Tiemann (tiemann at masham) - - * dbxread.c (define_symbol,read_type): Grok GNU C++'s new - abbreviation "Tt" for tags which have the same name as their - typedecls. - -Fri Jun 29 01:03:46 1990 Michael Tiemann (tiemann at masham) - - * symtab.c (list_symbols): add ability to set breakpoints on all - the functions which match a particular regular expression. - -Tue Jun 26 04:26:29 1990 Michael Tiemann (tiemann at masham) - - * cplus-dem.c (cplus_demangle): New parameter ANSI says whether we - should print ANSI qualifiers (such as `const' and `volatile'). - All callers changed to call with ANSI == 1, except from - `check_method_stub', which uses old-style syntax. - - * symseg.h (struct fn_field): Remove unneccessary `args' field. - * symtab.h (TYPE_FN_FIELD_ARGS): Redefined. - - * values.c (check_stub_method): New function. - - * cplus-dem.c (do_type): Handle "long long" (encoded as 'x'). - - * dbxread.c (read_type): Handle new GNU C++ method type stubs. - * valprint (type_print_base): Ditto. - - * symtab.c (gdb_mangle_typename): New function. - -Tue Jun 5 00:18:43 1990 Michael Tiemann (tiemann at gzilla) - - * breakpoint.c (catch_command): New function. Provides a - mechanism to set breakpoints based on catch clauses. - (disable_catch): Similar, but disables breakpoints on catch - clauses. - (delete_catch): Similar, but deleted breakpoints on catch clauses. - -Sun Jun 3 22:54:08 1990 Michael Tiemann (tiemann at gzilla) - - * blockframe.c (blockvector_for_pc): New function. - * blockframe.c (block_for_pc): Changed to call - `blockvector_for_pc' and get the block itself. - - * stack.c (catch_info): New function. Prints info about - exceptions which can be caught in the current frame. - * stack.c (print_frame_label_vars): New function. Similar to - `print_frame_local_vars'. - * stack.c (print_block_frame_labels): Prints out labels that are - defined in this frame. These labels are exceptions that can be - caught. - - * dbxread.c: Updated to handle N_CATCH symtab types. - -Thu May 3 22:10:00 1990 Michael Tiemann (tiemann at teacake) - - * valprint.c (everywhere): TYPE_NAME (TYPE) no longer comes in the - form "struct ..." for GNU C++. Don't flush any part of TYPE_NAME - when printing the type. - -Wed May 2 22:43:04 1990 Michael Tiemann (tiemann at teacake) - - * valprint.c (val_print): Use `baseclass_addr' to access the - baseclasses pointed to via the derived class object at VALADDR. - - * values.c (baseclass_addr): New function. Casts derived pointers - to baseclass pointers taking virtual baseclasses and multiple - inheritance into account. - -Sat May 5 12:39:18 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * Version 3.90.9. - -Fri May 4 12:12:55 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * breakpoint.c (watch_command, bpstat_stop_status): Deal with - exp_valid_block field correctly. - - * infrun.c (wait_for_inferior): When checking "don't even think - about breakpoints" if stop_signal == SIGTRAP && trap_expected, - also check step_resume_breakpoint. - Insert breakpoints and continue (not step) if - step_resume_break_address != NULL, even if another_trap. - If trap_expected and we enter sigtramp, then set up a - step_resume_break. - If trap_expected is set when we hit the step_resume_break, - set another_trap. - When calling resume and trap_expected says tell resume to step - (2 places), also check step_resume_break_address. - - * infrun.c (wait_for_inferior): Don't set - prev_{pc,sp,func_{start,name}} before calling wait (). - Do set them after exiting loop. - Move their declarations outside functions. - (start_inferior): Initialize them. - -Thu May 3 00:15:11 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * infrun.c (wait_for_inferior, after check for trap_expected > 1): - Restore old code which distinguishes between trap_expected and - running_in_shell, just make the latter take any non-TRAP signal, - not just SEGV. - - * values.c (allocate_value): Zero VALUE_OPTIMIZED_OUT flag. - - * Makefile.dist (pinsn.o): Use PINSN_CC to compile. - xconfig/3b1 (CC,PINSN_CC): Define. - - * xconfig/altos, altos-dep.c: Rename altos-dep.c to altos-xdep.c. - - * Version 3.90.8 - - * breakpoint.c (bpstat_stop_status), - infrun.c (wait_for_inferior) [SHIFT_INST_REGS]: New code. - - * param.h, tm-88k.h: Define ADDR_BITS_*. - infcmd.c (jump_command, read_pc), infrun.c (wait_for_inferior), - printcmd.c (do_one_display): Use them. - - * utils.c: Split #ifdef USG into a USG_UTILS and a QUEUE_MISSING. - xm-88k.h: Define USG_UTILS. - -Wed May 2 00:05:33 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * printcmd.c (printf_command) [__INT_VARARGS_H]: New code. - (printf_command): Add from_tty parameter. - - * valprint.c (value_print): Check VALUE_OPTIMIZED_OUT flag. - - * value.h: Add optimized_out field and change lazy field to - char. Add macro VALUE_OPTIMIZED_OUT. - - * i386-pinsn.c: Change from Eirik Fuller to write to stream directly - instead of stuffing things in buffers (oappend, etc). - - * breakpoint.c (bpstat_do_actions): If *BSP is set to NULL by - execute_command, exit both loops. - - * Makefile.dist: Don't set TARGET_ARCH. Add .c.o rule. - -Tue May 1 17:07:23 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * Makefile.dist (RAPP_OBS, rapp), - rgdb.c, rserial.c, rudp.c, serial.c, udp.c, xdep.h, - remote.h: Added. - m68k-xdep.c, coredep.c: Wrap in #if !defined (RDB). - - * valops.c (value_struct_elt), values.c (value_static_field): - Change error messages to remove references to `info methods'. - -Tue Apr 24 10:25:10 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * More 88k changes: - infrun.c (start_inferior): Add START_INFERIOR_HOOK. - infcmd.c [SHIFT_INST_REGS]: New code. - findvar.c (read_relative_register_raw_bytes): Return a value. - infcmd.c (do_registers_info): Check value from - read_relative_register_raw_bytes. - - * command.c (delete_cmd): Free the struct cmd_list_element(s) - we are removing. - -Mon Apr 23 10:42:21 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * More 88k changes: - findvar.c (get_saved_register): New function. - findvar.c: Rewrite code which called find_saved_register to - call get_saved_register instead. - -Sun Apr 22 14:47:51 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * valprint.c (val_print): Change error message printed when - the type has TYPE_FLAG_STUB set. - - * valprint.c (val_print): Check for TYPE_CODE_UNDEF. - - * findvar.c (write_register): Set register_valid (regno). - - * valops.c (call_function): Check for NULL return from block_for_pc. - -Fri Apr 20 11:31:23 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * findvar.c (write_register): Add PREPARE_TO_STORE. - {sun3,sparc,symmetry}-xdep.c (PREPARE_TO_STORE): Add. - infptrace.c, {mips,pyr,symmetry,sun3,arm,hp300hpux}-xdep.c - (store_inferior_registers): Don't call read_register_bytes. - symmetry-xdep.c (store_inferior_registers): - #if 0 out code to fetch registers. - - * values.c (value_as_long): Call COERCE_ARRAY. - - * tm-sun3.h: Include tm-68k.h not m-68k.h - - * sparc-tdep.c (single_step): Set next_pc, npc4 within - if (!one_stepped), not outside it. - - * Changes from Data General for 88k: - * coffread.c (read_file_hdr): Add *88*MAGIC. - * coffread.c (have_symbol_file_p): New function. - * coffread.c [COFF_CHECK_X_ZEROES] [TDESC]: New code. - * coffread.c (read_one_sym): If there is more than one - aux entry, don't give an error message, just ignore the - extra ones. - * coffread.c (process_coff_symbol): Replace clipper with - BELIEVE_PCC_PROMOTION in #ifdef's. - * coffread.c: Define L_LNNO32 if not defined. - (enter_linenos): Use it. - * blockframe.c: Add INIT_FRAME_PC hook and use it in - get_prev_frame_info. - m-m88k.h: Use INIT_{FRAME_PC,EXTRA_FRAME_INFO} to do tdesc stuff. - Use dummy versions of FRAME_CHAIN_*. - * Makefile.dist, xconfig/i386*: Rename M_CLIBS to XM_CLIBS and add - TM_CLIBS and CDEPS. - tdesc/libdc.o: New target. - tdesc.{c,h}, tdesc/*, {t,x}config/m88k: New files. - -Thu Apr 12 15:47:00 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * m68k-opcode.h (bras, bsrs): Use "Bw" not "Bg". - -Tue Apr 10 20:50:25 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * Version 3.90.7. - - * xm-mips.h (BYTE_ORDER): If not defined, make it LITTLE_ENDIAN. - - * mips-xdep.c ({fetch,store}_inferior_registers): Remove variable - offset and just use register_addr (regno, 1). - (core_file_command): Remove variable reg_offset and just use - register_addr (regno, 0). - - * gdbcore.h [COFF_FORMAT]: #undef a_magic before redefining it. - - * infrun.c ("if (trap_expected && stop_signal != SIGTRAP)", near end - of wait_for_inferior): Always pass 0 as first arg to resume. - #if 0 out "SIGSEGV in shell" test right above it (now redundant). - - * i386-pinsn.c (oappend_address): New function. - (oappend): Make it "static void" and declare at top of file. - (OP_J, OP_DIR): Use oappend_address. - -Mon Apr 9 15:22:09 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * mips-xdep.c: Include not "mips/inst.h". - - * wait.h [HAVE_WAIT_STRUCT]: Put #defines in #if !defined so that - it's OK if they are defined in . - - * findvar.c (fetch_registers): Pass "registers", not "®isters", - to remote_fetch_registers. - - * mips-tdep.c (_initialize_mipsdep): Remove hex_disassembler - and re-write skip_prologue to use add_set_cmd. - - * Makefile.dist (alldeps.mak): Don't put \ after the last - filename in each list. - -Sun Apr 8 01:59:19 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * Version 3.90.6. - - * Makefile.dist (alldeps.mak): "XM_FILE" -> "XM_FILE=". - - * valarith.c (value_x_{un,bin}op): use "operator" not "operator " - to match dbxread.c change of 16 Mar 90. - - * valarith.c (value_x_unop): Pass &static_memfuncp, - not static_memfuncp. - - * breakpoint.c: Add watchpoint stuff. - breakpoint.h: Add bpstat_should_step. - infrun.c (proceed, wait_for_inferior): Use it. - breakpoint.h: Add bpstat_print (and rename old bpstat_print - to bpstat_should_print). - infrun.c (normal_stop): Use it. - - * value.h: Add value_free. Declare a few functions. - -Sat Apr 7 21:43:43 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * dbxread.c (read_dbx_symtab): Remove PROFILE_TYPES code and - insert comment suggesting easy shell script equivalents. - - * values.c (unpack_long): Give better error messages for - unrecognized sizes of ints and floats. - -Fri Apr 6 00:32:21 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * dbxread.c, gdbcore.h (IS_OBJECT_FILE): Check for a_drsize - nonzero as well as a_trsize. - - * More places: Use SWAP_TARGET_AND_HOST. - - * valops.c (destructor_name_p): Only skip "struct " if present. - - * main.c (gdb_readline): Return NULL on end of file. - - * sparc-opcode.h: Add jmp 1+2, jmp 1+i, jmp i+1. - - * Makefile.dist: Make expread.tab.c unambiguously be in srcdir. - - * main.c: Split source_command into source_command and - read_command_file. - (main): Accept "-" as arg to +command for stdin. - - * dbxread.c (psymtab_to_symtab): Don't read string table. - (symbol_file_command): Save string table size. - - * Version 3.90.5 - - * symtab.c: Remove declaration of lookup_misc_func. - - * mips-pinsn.c: Add use_hex_p stuff (re-worked from Forin stuff). - - * mips-opcode.h: Add bdelay field. - mips-pinsn.c: Various changes from Forin, I think to make it look - like the MIPS assembler format. - mips-tdep.c, mips-xdep.c, mipsread.c: Various changes from Forin. - - * gdbcore.h: Declare register_addr. - - * gdbcore.h: Include , before trying to redefine N_TXTADDR - and friends. - various: Don't include both a.out.h and gdbcore.h. - - * Makefile.dist (HFILES): Add param.h - - * utils.c (init_malloc): Moved here from mcheck.c and modified - to use the standard mcheck.c - Makefile.dist: Modify to reflect new mcheck. - -Thu Apr 5 16:38:28 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * valprint.c (val_print, print_hex_chars): Print integers - larger than LONGEST. - - * valarith.c (value_sub): Give error message if attempt to - subtract something of the wrong type from a pointer. - - * breakpoint.c (bpstat_stop_status): Initialize retval to NULL. - - * i386-tdep.c (i386_pop_frame): Change addr to adr. - -Wed Apr 4 05:21:50 1990 Jim Kingdon (kingdon at teenage-mutant) - - * main.c (command_line_input): return NULL on end of file. - (execute_command): If p is NULL, return almost right away. - (read_command_lines): Treat end of file like "end". - - * printcmd.c (print_frame_args): Change it so num is number - of ints of args, not number of args. - - * xm-*.h: Make sure BYTE_ORDER is defined. - Also fix various #includes of old names of things. - - * main.c (command_line_input): Fix comment code of 2 Apr. - - * values.c (value_from_long, unpack_long): SWAP_TARGET_AND_HOST. - various: Replace {BYTES,WORDS}_BIG_ENDIAN with TARGET_BYTE_ORDER. - valarith.c various: SWAP_TARGET_AND_HOST. - dbxread.c (READ_FILE_HEADERS): SWAP_TARGET_AND_HOST. - (SWAP_SYMBOL): New macro. Use it wherever symbuf_idx is incremented. - exec.c (exec_file_command): SWAP_TARGET_AND_HOST. - - * valarith.c (value_subscripted_rvalue): Just bcopy() the - appropriate bytes rather than playing strange games with - value_from_long. - - * param.h (SWAP_TARGET_AND_HOST): New macro. - - * tm-np1.h (V7_REGNUM): Change from 27 to 26. - (REGISTER_VIRTUAL_TYPE): Return correct result for vector regs. - gould-tdep.c: New file. - - * Move reading of register before store from - findvar.c (write_register) to - infptrace.c, *-xdep.c (store_inferior_register). - - * findvar.c (fetch_registers, store_registers): New functions. - write_register{,_bytes}: Use store_registers regardless of - have_inferior_p. - registers_valid: New variable. - (supply_register, read_register, etc.): Use it. - (read_register_gen): New variable. - various: Use read_register_gen rather than read_register_bytes - where appropriate. - *-xdep.c (fetch_inferior_registers): Remove remote_debugging check. - infrun.c (wait_for_inferior, start_inferior): Call registers_changed - not fetch_inferior_registers. - *-xdep.c (fetch_inferior_registers): Call registers_fetched if - not setting registers via supply_register, and if fetching - all registers. - infptrace.c, *-xdep.c (fetch_inferior_registers): Add param, - # of register to fetch (-1 for all). - infptrace.c, hp300hpux-xdep.c (fetch_inferior_registers): - Actually fetch only those registers needed. - value.h: Declare all the extern register functions from findvar.c. - - * coffread.c (read_coff_symtab): Test for specific kinds of GCC - labels (LI%.*, LPB%.*, etc), not just ??%.*. - - * coffread.c (record_misc_function): Use mf_text not mf_unknown. - - * utils.c,defs.h (lines_to_list): New function. - source.c (select_source_symtab, list_command, forward_search_command, - reverse_search_command), stack.c (print_frame_info): - Use it instead of 10. - - * munch: If MUNCH_NM variable exists, use it. - - * main.c (initialize_main): Set rl_readline_name. - main.c: #include readline.h and #undef savestring. - Remove declarations of things declared in readline.h. - - * main.c (gdb_readline): If instream == 0, read from stdin. - - * main.c (main): Only call clearerr if ISATTY. Exit loop if - feof (instream). - - * infcmd.c (detach_command): Set inferior_pid to 0 after - calling remote_close. - - * main.c (main): If exec and sym files are the same, and there - is an error reading execfile, don't try to read sym file. - - * infcmd.c (detach_command) [ATTACH_DETACH]: Don't try to detach - from inferior when remote debugging. - - * source.c (reverse_search_command): Change while test from 1 to - line > 1. - -Tue Apr 3 18:14:14 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * Version 3.90.4. - - * Makefile.dist (gdb.tar.Z): Use -z option to tar rather than - creating gdb.tar and calling compress separately. - - * breakpoint.c (read_memory_nobpt): Do not treat bcopy as if it - returned an "errno" value. - - * various: Make sure gdbcore.h is not included before a.out.h. - - * Makefile.dist (OPCODES): Add mips-opcode.h. - - * config.gdb: Print lists of {hosts,targets} after finding srcdir. - When parsing +{host,target}=, strip off +{host,target}=, not +{x,t}m=. - - * Makefile.dist (gdb.tar): Do {t,x}config not just config. - -Mon Apr 2 02:42:23 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * sparc-opcode.h (inc): Fix incorrect lose field. - - * valarith.c (value_subscripted_rvalue): Use TARGET_BYTE_ORDER, - rather than checking endianness at runtime. - - * main.c (comand_line_input): Accept comments anywhere, not - just at starts of lines. - -Sat Mar 31 21:59:35 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * symtab.c (check_stub_type): Call lookup_symbol with 5 args. - -Fri Mar 30 15:23:52 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * frame.h: #include param.h. - param.h: Protect against multiple inclusion. - - * i386-tdep.c (i386_get_frame_setup): Fix comment about what - opcode 0x55 is. - If 0x81 or 0x83 is followed by something besides 0xec, - put codestream back where it was and return 0. - [USE_MACHINE_REG_H]: Include not - Move include of a.out.h above . - (i386_frame_find_saved_regs): Make locals signed. - (i386_frame_find_saved_regs, i386_push_dummy_frame, i386_pop_frame): - Use REGISTER_BYTES, REGISTER_RAW_SIZE, etc. to deal with floating - point registers. - -Wed Mar 28 18:33:40 1990 Jim Kingdon (kingdon at mole.ai.mit.edu) - - * Makefile.dist (OTHERS): Add gdb.dvi. - (gdb.dvi): New rule. - - * breakpoint.c (_initialize_breakpoint): Clean up docstrings so - as not to mention subcommands (e.g. auto-display). - Call add_cmd not add_abbrev_cmd for "disable breakpoint" and - put it in class_alias. - - * breakpoint.c (set_breakpoint_count): New function. - (set_breakpoint, break_command_1): Use it. - - * breakpoint.c (get_number): New function. - (*_command, map_breakpoint_numbers): Use it. - - * infptrace.c (write_inferior_memory): Remove remote_debugging - stuff (is handled in core.c). - (read_inferior_memory): Remove #if 0'd out remote_debugging code. - -Tue Mar 27 16:51:27 1990 Jim Kingdon (kingdon at mole.ai.mit.edu) - - * inferior.h: Include frame.h. - - * findvar.c (write_register): Replace sun4 #ifdef with - check of CANNOT_STORE_REGISTER. - xm-sparc.h: Define CANNOT_STORE_REGISTER. - - * sparc-tdep.c: Remove superfluous declaration of - get_breakpoint_commands. - - * breakpoint.{c,h}: Add bpstat stuff. - bpstat_do_action: Re-work do_breakpoint_commands into this. - main.c (command_loop): Call bpstat_do_action not - do_breakpoint_commands. - inferior.h, infrun.c, breakpoint.c, infcmd.c: - Rework breakpoint_commands and stop_breakpoint - stuff to use bpstat instead. - - * infcmd.c (program_info): "info reg"->"info registers". - - * np1-opcode.h: Renamed from npl-opcode.h. - gould-pinsn.c: Include np1-opcode.h. - Makefile.dist (OPCODES): Change npl-opcode.h to np1-opcode.h - - * coffread.c (read_enum_type): Stop reading when we hit .eos. - -Mon Mar 26 15:52:35 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * Version 3.90.3. - - * breakpoint.c (read_memory_nobpt): New function. - gdbcore.h: Declare read_memory_{nobpt,check}. - mips-tdep.c: Use read_memory_nobpt not breakpoint_shadow_val. - -Fri Mar 23 14:26:38 1990 Jim Kingdon (kingdon at mole.ai.mit.edu) - - * inflow.c (terminal_inferior): Reenable commented out - inferior_thisrun_terminal check. - (terminal_ours_1): If inferior_thisrun_terminal is nonzero, - return immediately. - - * Makefile.dist: Rewrite DEPFILES, M_FILE, etc. stuff to deal - with host & target separation. - - * config/*: Split into xconfig/* and tconfig/*. - *-dep.c: Split into *-xdep.c and *-tdep.c. - - * main.c (main): Always pass two args to xrealloc. - -Thu Mar 22 20:29:25 1990 Jim Kingdon (kingdon at mole.ai.mit.edu) - - * Makefile.dist ({,dist}clean): rm {x,t}m.h not param.h - xgdb.o: Remove obsolete dependency (now in depend). - - * arm-pinsn.c: Include arm-opcode.h not opcode.h. - - * mips-pinsn.c, mips-opcode.h: New files from Bothner (from - release of 24 Jan 90 with mips-opcode.h patch from 1 Feb 90). - - * utils.c (xmalloc): Return NULL on request for 0 bytes. - -Wed Mar 21 13:30:08 1990 Jim Kingdon (kingdon at mole.ai.mit.edu) - - * config.gdb: Re-write machine stuff to deal with host & target. - - * xm-altos.h: Don't define HAVE_WAIT_STRUCT. - - * m-*.h: Split into xm-*.h and tm-*.h. - - * infrun.c (wait_for_inferior): Put #ifdef sony_news code - in regardless of machine. - - * symtab.c (decode_line_1): Add quotes and capitalize error - message "no class, struct, or union named". - - * Makefile.dist (cplus-dem.o): Compile with -Dnounderscore. - - * stack.c (print_frame_info): Use print_symbol to print function name. - - * symtab.c (output_source_filename): Don't print a comma if - we are skipping a filename already printed. - -Tue Mar 20 10:48:54 1990 Jim Kingdon (kingdon at mole.ai.mit.edu) - - * symtab.c (output_source_filename): Don't print a filename - more than once. - - * utils.c (fprint_symbol): New function. - defs.h: Decalare it. - various: Use fprint_symbol to print symbol names. - Makefile.dist (SFILES, OBS): Add cplus-dem.{c,o}. - -Mon Mar 19 17:11:03 1990 Jim Kingdon (kingdon at mole.ai.mit.edu) - - * coffread.c (read_file_hdr): Add MC68K??MAGIC. - - * coffread.c (read_coff_symtab): Ignore swbeg and string label - symbols. - - * coffread.c (read_coff_symtab): Increment num_object_files - in case C_STAT not C_FILE. - New variable in_source_file. Set it in case C_FILE. - Check it in case C_STAT. - - * coffread.c [FUNCTION_EPILOGUE_SIZE]: New code. - m-umax.h (FUNCTION_EPILOGUE_SIZE): Define. - - * config/3b1: New file. - - * config/sun*: Print message warning people to use GAS with GCC. - -Sun Mar 18 02:56:40 1990 Jim Kingdon (kingdon at mole.ai.mit.edu) - - * infcmd.c (run_stack_dummy): Change error message. - - * m-68k.h (REGISTER_VIRTUAL_TYPE): Make pc, fp, sp char *. - - * m-mips.h (LONGEST, BUILTIN_TYPE_LONGEST): Remove. - -Sat Mar 17 21:27:49 1990 Jim Kingdon (kingdon at mole.ai.mit.edu) - - * mips-dep.c: Remove infptrace.c stuff. - - * m-bigmips.h: New file. - m-mips.h [MIPSEB]: Remove *_BIG_ENDIAN stuff. - - * m-sparc.h (FIX_CALL_DUMMY): Do not insert unimp instruction - if function was compiled with gcc. - - * m-mips.h: Remove FIX_CALL_DUMMY_ALIGNED and make FIX_CALL_DUMMY - use new args. - - * valops.c (call_function): New args to FIX_CALL_DUMMY. - m-*.h (FIX_CALL_DUMMY): Take new args. - - * values.c (using_struct_return): New parameter gcc_p. - valops.c (call_function): New variable using_gcc. - valops.c (call_function) [REG_STRUCT_HAS_ADDR]: New code. - - * m-mips.h, mips-dep.c: New files from Forin. - m-mips.h: Replace RETURN_STRUCT_BY_REF with USE_STRUCT_CONVENTION. - -Fri Mar 16 13:17:19 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * Makefile.dist: Add some dependencies of m-*.h files. - (HFILES): Add m-68k.h. - - * dbxread.c (read_struct_type): Put "operator+" not "operator +" - in symtab. - - * core.c: Split read_memory into read_memory_check and read_memory. - breakpoint.c (insert_breakpoints): If can't read memory, - tell user that error was due to seting breakpoints. - -Thu Mar 15 11:47:19 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * infrun.c [COFF_ENCAPSULATE]: Include a.out.encap.h. - - * blockframe.c (FRAMELESS_LOOK_FOR_PROLOGUE): Make it a function. - various m-*.h: Call function not macro. - frame.h: Declare the function. - -Wed Mar 14 02:44:51 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * sparc-dep.c: Include signame.h. - - * sparc-pinsn.c (print_insn): When looking for sethi before - delayed branch, call read_memory_noerr not read_memory. - - * m-isi.h, m-sun3.h, m-news.h, m-hp300bsd.h, m-altos.h, - m-hp300hpux.h, m-sun2.h: Merge machine stuff except inferior - function call stuff into new file m-68k.h. Create m-3b1.h. - -Tue Mar 13 21:34:33 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * inflow.c (new_tty): If can't open tty, print error message - before exiting. - - * blockframe.c: Remove declaration of psymtab_to_symtab. - symtab.h: Declare psymtab_to_symtab. - blockframe.c: Remove declarations of block_for_pc and - find_pc_function_start. - frame.h: Add declarations of block_for_pc and find_pc_function_start. - Remove declaration of nonexistent function find_pc_function. - values.c: include frame.h instead of declaring block_for_pc. - - * Version 3.90.2. - -Mon Mar 12 14:20:06 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * main.c (main): Delete superfluous "e" from long_options. - -Sat Mar 10 15:47:23 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * valprint.c (val_print): Print <%d bit integer> not just - . - - * dbxread.c (error_type): Fix loop that finds '\0' so that on - exit, *pp points to the '\0', not the character after. - (read_type): Make sure that places which call read_type and then - try to read more input stop immediately with another error - upon encountering '\0'. - - * dbxread.c (read_range_type): Fix check for large signed - integral type to match comment and reality. Set TYPE_LENGTH based - on n2bits for signed, n3bits for unsigned. - - * infcmd.c (cont_command): Print warning message if we - decide to ignore the argument. - - * gdb.texinfo (attach): @xref{Attach} -> @xref{Remote}. - -Fri Mar 9 16:26:47 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * symtab.h (address_class): Reinstate LOC_EXTERNAL with rewritten - comment. - - * expread.y (yyerror, parse_c_1): Make yyerror take a char * arg. - - * main.c (symbol_completion_function): Don't call error() on - "info jkldskf". - - * m-npl.h (USE_STRUCT_CONVENTION): Change >= to >. - -Thu Mar 8 00:19:01 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * symseg.h: Nuke more symseg references including LOC_EXTERNAL. - Put contents of symseg.h into symtab.h and remove symseg.h. - -Wed Mar 7 18:02:15 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * symtab.h (SYMBOL_LINE): New macro. - symtab.c (decode_line_1): Accept variable as well as function. - Lookup variable/function in selected block if no file specified. - printcmd.c: #if 0 out whereis_command. - - * command.c (do_setshow_command): Call function with additional - argument C. - main.c (set_history_size_command): Take argument C. - (set_verbose): New function to set docstring. - (initialize_main): Put set_verbose in command list. - command.c (lookup_cmd_1): Accept result_list NULL. - - * valprint.c (_initialize_valprint): Change docstring for - "set unionprint" to normal set/show form. - - * command.c (add_show_from_set): Check that docstring starts with - "Set " before assuming it does. - - * main.c (show_history): Call cmd_show_list. - command.{c,h} (cmd_show_list): New function. - command.h: Declare do_setshow_command. - - * command.h (cmd_list_element): New field completer. - main.c (symbol_completion_function): Use it. - symtab.h: Declare make_symbol_completion_list. - command.c (add_cmd): Set completer. - main.c, gdbcmd.h (noop_completer): New function. - infcmd.c: Set completer for environment functions. - - * symtab.c (types_info, _initialize_symtab): #if 0 out. - various: Use fputs_filtered, not fprintf_filtered(%s). - - * valprint.c (type_print_base): Check for integers larger than - LONGEST. - - * sun3-dep.c: Include "signame.h" instead of directly declaring - sys_siglist. - -Tue Mar 6 14:59:34 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * infrun.c (signals_info): Allow argument to be a signal name - as well as an expression. - (handle_command): Check for error from sig_number. - - * main.c (float_handler): Change error message. - - * inflow.c (create_inferior): If getenv ("SHELL") exists, use it - instead of /bin/sh. - - * dbxread.c (read_dbx_symtab, case N_SO): New variable first_symnum. - Pass it to {start,end}_psymtab. - - * dbxread.c (read_ofile_symtab): Increment symbuf_idx and symnum - when calling process_symbol_pair. - - * symtab.c (sources_info, output_source_filename): - Re-write so output_source_filename takes a first parameter - instead of a next one. - - * dbxread.c (read_dbx_symtab, case N_SO): When incrementing - symbuf_idx, increment symnum also. - - * values.c (set_internalvar_component): Use VALUE_CONTENTS, - not VALUE_CONTENTS_RAW. - - * symmisc.c (free_symtab): Don't free filename (now in symbol_obstack). - - * environ.c (init_environ): Copy entire string, including - terminating '\0'. - - * value.h, values.c: Rename value_lazy to value_fetch_lazy. - values.c (value_of_internalvar): Call value_fetch_lazy. - - * dbxread.c (read_huge_number): Return an error on encountering - a large decimal number. - - * dbxread.c (read_huge_number): Reverse sense of overflow test. - - * valprint.c (val_print, case TYPE_CODE_INT): Check for integers - larger than LONGEST. - - * dbxread.c (read_ofile_symtab): When calling process_one_symbol, - call it with desc and value rather than with bufp->n_{desc,value}. - - * defs.h (LONG_MAX): Define. - - * sun3-dep.c: Declare sys_siglist. - - * infptrace.c: Move include of gdbcore.h after a.out.h - - * Makefile.dist (expread.o, mcheck.o): Remove leading "./" not - leading ".". - - * m-hp300hpux.h [!HPUX_VERSION_5]: Define KERNEL_U_ADDR_HPUX. - infptrace.c [KERNEL_U_ADDR_HPUX] [KERNEL_U_ADDR_BSD]: - Set kernel_u_addr using nlist(). - m-hp300bsd.h: Define KERNEL_U_ADDR_BSD. - -Mon Mar 5 16:52:41 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * dbxread.c (read_dbx_symtab): If value of .o symbol is crazy, - don't end psymtab. - - * dbxread.c (read_dbx_symtab): Ignore first of a pair of N_SO - when both appear. - (start_subfile, start_symtab): Extra parameter dirname. - (start_subfile): Use obsavestring, not savestring, for name. - various: Call start_{subfile,symtab} with extra argument. - (end_symtab): Set dirname field in symtab. - (read_ofile_symtab): Call process_symbol_pair on pair of N_SO. - (process_symbol_pair): New function. - symtab.h (symtab): New field dirname. - source.c (open_source_file): New function. - source.c: Use open_source_file instead of openp where appropriate. - - * defs.h (TARGET_CHAR_BIT): Define. - -Sun Mar 4 13:11:48 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * dbxread.c (fill_symbuf): Print error messages nicely. - - * Makefile.dist (SFILES): Put standalone.c at end. - - * Makefile.dist (alldeps.mak): Put out backslash after arm-convert.s. - - * symtab.{c,h} (builtin_type_error): New type. - symseg.h (type_code): Add TYPE_CODE_ERROR. - valprint.c (val_print, type_print_base), - values.c (using_struct_return, set_return_value): - Check for and deal with TYPE_CODE_ERROR. - dbxread.c (error_type): New function - (read_type and subroutines): Call error_type instead of error. - - * dbxread.c (read_huge_number): New function. - (read_range_type): Use read_huge_number and check results - to see if it is a large integral type. - - * symmisc.c: Remove symseg stuff. - - * Gould NP1 changes from (or inspired by) chpmjd@gdr.bath.ac.uk - dbxread.c (read_dbx_symtab) [N_NBSTS]: - Treat this and N_NBLCS like N_LCSYM, etc. - (process_one_symbol) [BLOCK_ADDRESS_ABSOLUTE]: New code. - m-npl.h (USE_STRUCT_CONVENTION): Add. - (IGNORE_SYMBOL): Add 0xa4. - (END_OF_TEXT_DEFAULT): Remove. - (STRING_TABLE_OFFSET): don't add sizeof(int). - [!HAVE_VPRINTF]: Define vprintf to be doprnt, not printf. - (BLOCK_ADDRESS_ABSOLUTE): Define. - (BREAKPOINT): Pad to size of machine word. - (SAVED_PC_AFTER_CALL): Remove ` at start of line (!). - (R2_REGNUM): Define. - (SP_REGNUM, FP_REGNUM): Switch definitions. - (REGISTER_U_ADDR): Use FP_REGNUM in place of SP_REGNUM. - (STORE_STRUCT_RETURN, EXTACT_RETURN_VALUE, STORE_RETURN_VALUE, - call function stuff): - Replace bogus definitions with correct ones for NP1. - (CANNOT_EXECUTE_STACK): Define. - (FRAME_LOCALS_ADDRESS): Don't add 80. - (FRAME_FIND_SAVED_REGS): Also get SP. - gould-pinsn.c (findframe): Move framechain declaration outside #if 0. - infptrace.c (write_inferior_memory): Check addr against text_end - and use PT_WRITE_I or PT_WRITE_D as appropriate. - (store_inferior_registers): Don't try to write registers in - CANNOT_STORE_REGISTER. - m-npl.h (CANNOT_STORE_REGISTER): Define. - npl-opcode.h (lil): 0xf8080000 -> 0xf80b0000. - - * munch: Distinguish between BSD and System V nm by actually - seeing what output from nm looks like. - -Fri Mar 2 13:43:36 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * printcmd.c (print_frame_args): Change highest_offset to point - to next unprinted arg. - - * main.c (main): Print "type help for list of commands" along - with the version. Follow it with a blank line. - -Thu Mar 1 14:49:26 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * valprint.c: Move print_address for function from value_print - to val_print. - -Wed Feb 28 15:06:12 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * Makefile.dist (m-sun4os4.h): Depend on m-sparc.h - - * Makefile.dist (version.c): Depend on Makefile.dist, not Makefile. - - * Makefile.dist: Change MAKEFILES to Makefiles. - - * symtab.h: Declare get_sym_file. - core.c: Include symtab.h. - - * Move signal name stuff from utils.c to signame.c - Move signal name stuff from defs.h to signame.h. - Makefile.dist (SFILES, HFILES, OBS): Add signame.{c,h,o}. - -Mon Feb 26 12:03:12 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * command.c (add_cmd): Don't call savestring on name. - -Sun Feb 25 15:52:18 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * printcmd.c (print_frame_args): Make highest_offset an int. - New variable args_printed. - (print_frame_nameless_args): Remove parameter end and add num - and first. - (print_frame_args): Change call to print_frame_nameless_args. - -Fri Feb 23 21:40:15 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * stack.c (up_command, down_command): - Only print stack frame if from_tty. - -Thu Feb 22 12:01:36 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * expread.y: Inlcude value.h and don't cast return value from - lookup_internalvar. - - * infrun.c: Remove code in #ifdef UMAX_PTRACE. - - * values.c (convenience_info): Print in form "$foo = 5". - Don't print "Debugger convenience variables:" before first one. - - * Makefile.dist: Remove ADD_FILES from CLIBS. - (gdb, kdb, xgdb): Put in ADD_FILES as well as CLIBS. - - * m-pyr.h: #if 0 out call dummy stuff. - Put in POP_FRAME which just calls error(). - valops.c: If CALL_DUMMY is not defined, put in dummy call_function - which just prints an error message. - -Tue Feb 20 22:11:40 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * breakpoint.c (commands_command): Add arg from_tty. - - * main.c (main): Put if (!setjmp (to_top_level)) around calls - to *_command made in response to command line arguments. - -Mon Feb 19 13:58:28 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * main.c (main): Use getopt_long_only. Move one-character options - to long_options. Remove entries which are just unambiguous - abbreviations of other options. - - * command.h: Add types cmd_types and var_types. - Add fields type, var_type, and var to struct cmd_list_element. - command.c (add_set_cmd, add_set_from_show): New functions. - (add_cmd): Set c->var_type. - (add_abbrev_cmd): Call add_cmd instead of duplicating code. - main.c: Add showlist. - Move parse_binary_operation from main.c to command.c. - command.c (do_setshow_command): New function. - gdbcmd.h: New file. - Makefile.dist: Add gdbcmd.h. - many files: Include gdbcmd.h, use add_set_cmd and add_show_from_set. - Replace info * with show * where appropriate. - utils.c (fputs_filtered): Use UINT_MAX in lines_per_page to mean - no paging. - defs.h: Define UINT_MAX. - infcmd.c (run_command): Use execute_command, not set_args_command. - main.c (execute_command): Call do_setshow_command if necessary. - main.c (show_command, show_history): New functions. - main.c (initialize_main): Call add_prefix_cmd - for show and show history. - - * coffread.c (enter_linenos): Print error if - file_offset < linetab_offset. - -Sun Feb 18 15:37:05 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * convex-dep.c (comm_registers_info): Fix typo. ("argc"->"arg"). - -Wed Feb 14 20:45:14 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * config.gdb: Create Makefile with make. - - * Makefile.dist, config.gdb: Move "srcdir=" line from Makefile.dist - to new file Makefile.srcdir. - - * valprint.c: Include . - - * value.h: Declare value_coerce_function. - - * findvar.c: Add missing " after #include "gdbcore.h - - * main.c (main): Re-write command parsing to use getopt. - On "gdb +help" print options with '+' not '-'. - Makefile.dist: Add getopt. - -Tue Feb 13 00:08:27 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * Makefile.dist: Add "srcdir=." - config.gdb: Edit srcdir= rather than adding it to the beginning. - - * pyr-dep.c: Make global_reg_offset, last_frame_offset not static. - Move definition of reg_stack_offset to core.c [REG_STACK_SEGMENT]. - - * config/pyramid: Print message about alloca. - - * breakpoint.c (clear_command): When printing "no breakpoint" - error, only use arg if non-NULL. - - * core.c (read_memory): Rename to read_memory_noerr. - (read_memory): New function which calls read_memory and checks for err. - gdbcore.h: Declare all extern core.c functions. - move myread from core.c to utils.c. - declare it in defs.h. - (read_memory_integer): move from infcmd.c to core.c. - gdbcore.h: Declare it. - Many places: Remove error checking on read_memory, or call - read_memory_noerr instead. Include "gdbcore.h" if calling either. - - * value.h (COERCE_ARRAY): Coerce functions to function pointers. - valops.c (value_coerce_function): New function. - - * core.c, convex-dep.c, arm-dep.c (xfer_core_file): Return EIO - if address out of bounds. - - * m-arm.h, arm-dep.c arm-pinsn.c arm-opcode.h: New files. - dbxread.c, m-convex.h (VARIABLES_INSIDE_BLOCK): Add gcc_p parameter. - Makefile.dist (alldeps.mak): Special case for arm-convert.s. - dbxread.c (define_symbol): Check for local based on it not - being any one of the known deftypes. - values.c (using_struct_return): Use new macro USE_STRUCT_CONVENTION. - - * Makefile.dist, config.gdb: Put in srcdir stuff. - -Mon Feb 12 22:46:16 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * breakpoint.c: Add addr_string and cond_string fields to - struct breakpoint. - (break_command_1): Set them. Use mention (). - (mention): Create with code from break_command_1. - (breakpoint_re_set): New function. - (breakpoint_clear): Remove. - (condition_command): Set cond_string. - (breakpoint_delete): Free cond_string and addr_string. - Declare parse_c_1's type and remove casts to struct expression *. - symmisc.c (free_all_symtabs): Don't call breakpoint_clear. - dbxread.c, coffread.c (reread_symbols): Call breakpoint_re_set, - Include breakpoint.h. - breakpoint.h: New file. - dbxread.c: Move declaration of symmisc.c functions to symtab.h. - -Sun Feb 11 17:29:23 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * symtab.c: Make lookup_block_symtab extern. - symtab.h: Declare it. - valops.c (value_of_this): Use it. - -Fri Feb 9 08:59:37 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * config/hp300hpux: Print message telling people to use gcc. - - * value.h: Declare print_floating. - printcmd.c (print_scalar_formatted, case 'f'): Use print_floating. - valprint.c (val_print, case TYPE_CODE_FLT): Use print_floating. - valprint.c (print_floating): Make this function out of is_nan - and the code which was in val_print. - Put parentheses around high & 0xfffff. - Print sign and fraction for NaN's. - Print 17 digits not 16 for doubles. - (is_nan): Remove. - m-news.h, m-sun3.h: Define IEEE_FLOAT. - - * Rename gld-pinsn.c to gould-pinsn.c. - config/{pn,npl}: Change name of gld-pinsn.c - -Tue Feb 6 00:25:36 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * infptrace.c: Define PT_ATTACH if not defined. - m-hp300hpux.h: Define ATTACH_DETACH. - - * main.c (initialize_main): Change alias class to aliases. - - * dbxread.c: Search and destroy references to symsegs. - Also remove some #if 0'd code. - - * core.c: Remove reread_exec. - dbxread.c (reread_symbols): New function. - dbxread.c (symbol_file_command): Set symfile_mtime. - coffread.c: Same. - infcmd.c (run_command): Call reread_symbols not reread_exec. - - * valprint.c (val_print): When printing string after char *, print - it for "" just like any other string. - - * core.c (reread_exec): New procedure. - infcmd.c (run_command): Call reread_exec. - - * coffread.c (symbol_file_command): Add from_tty. - - * dbxread.c (symbol_file_command): Only ask about loading new - symbol table if from_tty. - -Mon Feb 5 02:25:25 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * inflow.c (inferior_died): Call breakpoint_clear_ignore_counts. - - * Makefile.dist (OBS): Remove dbxread.o and coffread.o. - - * config.gdb: Ignore files ending in '#' in config. - - * stack.c (backtrace_command): Add QUIT to get_prev_frame loops. - -Sat Feb 3 22:25:09 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * Makefile.dist (YACC): Don't use -v. - -Fri Feb 2 19:26:50 1990 Jim Kingdon (kingdon at mole.ai.mit.edu) - - * createtags: Only change .o to .c at end of name. - - * Makefile.dist (alldeps.mak): new target. - (Makefile): add alldeps.mak. - (SOURCES): remove PINSNS. - (TAGFILES: use ALLPARAM. - (gdb.tar): add config/. - - * config.gdb: Check for M_FILE= not #param.h - config/*: Make sure M_FILE= exists with space after M_FILE=. - Makefile.dist (TAGS): Pass M_FILE and DEPFILES. - createtags: Change .o to .c. Remove special tests for dep.c etc. - - * dbxread.c, coffread.c: Don't check COFF_FORMAT and READ_DBX_FORMAT. - Makefile.dist: Move {dbx,coff}read.c from SFILES to ALLDEPFILES. - config/*: add dbxread.o or coffread.o to depfiles. - - * Makefile.dist (depend): Depend on $(SOURCES), not force. - -Thu Feb 1 17:43:54 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * symmisc.c (print_symbol): Print newline after label. - -Wed Jan 31 22:35:38 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * dbxread.c (read_addl_syms): Remove code that checks for - _etext. - Move end_of_text_addr into read_dbx_symtab. - (read_dbx_symtab): #if 0 out code which checks for _etext. - -Tue Jan 30 15:40:19 1990 Jim Kingdon (kingdon at albert.ai.mit.edu) - - * Makefile.dist (gdb.tar): Use readline's "make readline.tar" - instead of having a list of readline files. - - * infrun.c (normal_stop): #if 0 out "you have found a bug in sh". - - * munch (-DSYSV): Check for .text at end of name. - Optionally allow extra underscore before initialize. - Remove space between #! and /bin/sh. - - * m-merlin.h: Put in clarifying comments about SHELL_FILE. - Makefile.dist (install): Execute M_INSTALL. - config/merlin: Define M_INSTALL. - -Mon Jan 29 04:32:09 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * inflow.c: Change all references to signal handlers from - int (*)() to void (*)(). - - * main.c: Declare init_signals before use & make it void. - Declare initialize_all_files. - - * Makefile.dist (config.status): New target. - -Sat Jan 27 00:19:50 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * defs.h (enum command_class): Remove comma after last element. - - * Makefile.dist (gdb.tar.Z): Use compress bar rather - than deleting gdb.tar.Z before starting. - - * dbxread.c (process_one_symbol): Compare context_stack_depth - with !VARIABLES_INSIDE_BLOCK, not VARIABLES_INSIDE_BLOCK. - - * mcheck.c: Put whole file in #if defined MALLOC_RANGE_CHECK. - - * mcheck.c (checkhdr): Call fatal_dump_core not abort. - - * mcheck.c: Copy from malloc distribution. - - * main.c (main): Call init_malloc (). - - * main.c (initialize_signals): Rename to init_signals. - -Fri Jan 26 00:53:23 1990 Jim Kingdon (kingdon at mole.ai.mit.edu) - - * *dep.c: Make core_file_command return void. - - * gdbcore.h [!KERNEL_U_ADDR]: Declare kernel_u_addr. - infptrace.c [!KERNEL_U_ADDR]: Make it extern. - - * altos-dep.c (NBPG, UPAGES): Wrap #define in #if !defined. - - * m-pn.h (GOULD_PN): Define. - *-pinsn.c: Include actual opcode table not just opcode.h - - * main.c [ALIGN_STACK_ON_STARTUP]: New code. - m-i386.h: Define ALIGN_STACK_ON_STARTUP. - - * m-merlin.h (NO_SIGINTERRUPT, SHELL_FILE): Define. - - * Move code from infptrace [USE_PTRACE_GETREGS] to sun3-dep.c. - m-sun{2,3}.h, m-sparc.h: Define FETCH_INFERIOR_REGISTERS. - - * Makefile.dist, config.gdb, config/*: - Re-write to use machine-dependent makefiles instead of cpp. - - * m-hp300hpux.h: Define FETCH_INFERIOR_REGISTERS. - infptrace.c: Put {fetch,store}_inferior_registers inside - #if !defined FETCH_INFERIOR_REGISTERS. - - * Split execcore.c into exec.c and coredep.c. - Move a bunch of stuff from coredep.c and *dep.c to gdbcore.h. - - * infptrace.c ({fetch,store}_inferior_registers): - Use U_REGS_OFFSET to set offset. - m-umax.h: Define U_REGS_OFFSET. - - * m-umax.h: Define PTRACE_{ATTACH,DETACH}. - - * m-i386.h (N_SET_MAGIC): Define. - m-i386gas.h: add #undef N_SET_MAGIC. - -Thu Jan 25 18:39:45 1990 Jim Kingdon (kingdon at mole.ai.mit.edu) - - * m-hp300bsd.h: Remove KERNEL_U_ADDR. - - * infptrace.c [!KERNEL_U_ADDR]: Get address of kernel u area - at runtime. - - * infptrace.c: Replace numbers with PT_KILL, etc. - (store_inferior_registers): Loop for as many words are in the register. - - * infptrace.c [NO_SINGLE_STEP]: Call single_step(). - - * kill_inferior{,_fast}: Declare as returning void. - - * m-sun3.h (USE_PTRACE_GETREGS): Define. - - * execcore.c: Add IS_OBJECT_FILE & related stuff. - - * infptrace.c: Include . - [ATTACH_DETACH] [USE_PTRACE_GETREGS]: New code. - - * Split default-dep.c into infptrace.c and execcore.c. - - * valprint.c [IEEE_FLOAT]: Change void * to char *. - - * breakpoint.c: Change printf_filtered(%s) to fputs_filtered. - -Wed Jan 24 00:35:52 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * dbxread.c (symbol_file_command): When freeing everything, free - the string table too. - - * Makefile.dist (gdb1): add "rm -f gdb1". - - * printcmd.c (print_scalar_formatted): If size is 0, use 'b' - 'h', 'w', or 'g' depending on the type. - - * stack.c (backtrace_command): Read in symbols for frames we'll - print before printing them. - - * valops.c (value_at): Don't print "I/O error" on EIO from - ptrace. Don't print "out of bounds" for any ptrace error - except EIO. - - * valprint.c (type_print_base, case TYPE_CODE_ENUM): - Print "FOO = 5" not "FOO : 5". - - * symtab.{c,h}: Make lookup_misc_func extern. - - * Makefile.dist: Define VERSION in makefile, and generate - version.c automatically. - (gdb.tar): Use gdb-$(VERSION), not dist-gdb. - - * expread.y (yylex): Use lookup_primitive_typename to - cut down on calls to lookup_symbol. - symtab.{c,h} (lookup_primitive_typename): New function. - (lookup_typename): Use it. - - * symtab.{c,h} (check_stub_type): New function. - valprint.c (type_print_base, val_print, type_print_derivation_info), - values.c (allocate_value): Call it. - - * printcmd.c (whereis_command): New function. - symtab.c (lookup_symbol): Add symtab parameter. - various: Pass additional argument to lookup_symbol. - symseg.h (struct symbol): Add line field. - dbxread.c (define_symbol): Set sym->line. - - * dbxread.c (symbol_file_command): Read string table into - malloc'd memory (symfile_string_table) and leave it there. - (psymtab_to_symtab): Use symfile_string_table. - - * utils.c (sig_abbrev): Return NULL if not found. - infrun.c (sig_print_{header,info}): Consolidate duplicated - code from handle_command, signals_info. - (sig_print_info): Just print number if no name from sig_abbrev. - - * Makefile.dist (OTHERS): Add ChangeLog-3.x - - * infrun.c (restore_inferior_status): #if 0 out - "Unable to restore previously selected frame" error message. - - * infrun.c (signals_info, handle_command): Print signal - abbrevs along with numbers. - - * infrun.c (handle_command): Accept symbol signal names. - - * utils.c (sig_{number,abbrev}, init_sig): New functions. - _initialize_utils: Call init_sig for each signal. - defs.h: Declare them. - - * default-dep.c (read_inferior_memory): Check quit_flag in - fetch loop. - - * Changes for lazy fetching (speeds things up for big objects): - value.h (struct value): New field lazy. - VALUE_CONTENTS_RAW, VALUE_LAZY, value_at_lazy: New. - findvar.c (read_var_value): Set lazy instead of fetching. - various: Copy into VALUE_CONTENTS_RAW, not VALUE_CONTENTS. - valops.c: Add value_at_lazy, value_lazy. - various: Call value_at_lazy instead of value_at. - - * symtab.h (LONGEST): Define. - - * m-*.h (LONGEST, BUILTIN_TYPE_LONGEST): Delete (in symtab.h). - - * infrun.c (wait_for_inferior): #if 0 out stop if ABOUT_TO_RETURN - - * version.c: Change version number to 4.0development - -For older changes see ChangeLog-3.x - -Local Variables: -mode: indented-text -left-margin: 8 -fill-column: 74 -version-control: never -End: diff --git a/gdb/ChangeLog-3.x b/gdb/ChangeLog-3.x deleted file mode 100644 index e8dbcd87bb0..00000000000 --- a/gdb/ChangeLog-3.x +++ /dev/null @@ -1,4846 +0,0 @@ -Tue Jan 23 15:49:47 1990 Jim Kingdon (kingdon at pogo.ai.mit.edu) - - * dbxread.c (define_symbol): Deal with deftype 'X'. - - * convex-dep.c (wait): Make it pid_t. - - * convex-dep.c (comm_registers_info): accept decimal comm register - specification, as "i comm 32768". - - * dbxread.c (process_one_symbol): Make VARIABLES_INSIDE_BLOCK - macro say by itself where variables are. Pass it desc. - m-convex.h (VARIABLES_INSIDE_BLOCK): Nonzero for native compiler. - - * m-convex.h (SET_STACK_LIMIT_HUGE): Define. - (IGNORE_SYMBOL): Take out #ifdef N_MONPT and put in 0xc4. - -Fri Jan 19 20:04:15 1990 Jim Kingdon (kingdon at albert.ai.mit.edu) - - * printcmd.c (print_frame_args): Always set highest_offset to - current_offset when former is -1. - - * dbxread.c (read_struct_type): Print nice error message - when encountering multiple inheritance. - -Thu Jan 18 13:43:30 1990 Jim Kingdon (kingdon at mole.ai.mit.edu) - - * dbxread.c (read_dbx_symtab): Always treat N_FN as a potential - source for a x.o or -lx symbol, ignoring OFILE_FN_FLAGGED. - - * printcmd.c (print_frame_args): Cast -1 to (CORE_ADDR). - - * hp300bsd-dep.c (_initialize_hp300_dep): Get kernel_u_addr. - m-hp300bsd.h (KERNEL_U_ADDR): Use kernel_u_addr. - - * infcmd.c (run_command): #if 0 out call to - breakpoint_clear_ignore_counts. - -Thu Jan 11 12:58:12 1990 Jim Kingdon (kingdon at mole) - - * printcmd.c (print_frame_args) [STRUCT_ARG_SYM_GARBAGE]: - Try looking up name of var before giving up & printing '?'. - -Wed Jan 10 14:00:14 1990 Jim Kingdon (kingdon at pogo) - - * many files: Move stdio.h before param.h. - - * sun3-dep.c (store_inferior_registers): Only try to write FP - regs #ifdef FP0_REGNUM. - -Mon Jan 8 17:56:15 1990 Jim Kingdon (kingdon at pogo) - - * symtab.c: #if 0 out "info methods" code. - -Sat Jan 6 12:33:04 1990 Jim Kingdon (kingdon at pogo) - - * dbxread.c (read_struct_type): Set TYPE_NFN_FIELDS_TOTAL - from all baseclasses; remove vestigial variable baseclass. - - * findvar.c (read_var_value): Check REG_STRUCT_HAS_ADDR. - printcmd.c (print_frame_args): Check STRUCT_ARG_SYM_GARBAGE. - m-sparc.h: Define REG_STRUCT_HAS_ADDR and STRUCT_ARG_SYM_GARBAGE. - - * blockframe.c (get_frame_block): Subtract one from pc if not - innermost frame. - -Fri Dec 29 15:26:33 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * printcmd.c (print_frame_args): check highest_offset != -1, not i. - -Thu Dec 28 16:21:02 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * valops.c (value_struct_elt): Clean up error msg. - - * breakpoint.c (describe_other_breakpoints): - Delete extra space before "also set at" and add period at end. - -Tue Dec 19 10:28:42 1989 Jim Kingdon (kingdon at pogo) - - * source.c (print_source_lines): Tell user which line number - was out of range when printing error message. - -Sun Dec 17 14:14:09 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * blockframe.c (find_pc_partial_function): Use - BLOCK_START (SYMBOL_BLOCK_VALUE (f)) instead of - SYMBOL_VALUE (f) to get start of function. - - * dbxread.c: Make xxmalloc just a #define for xmalloc. - -Thu Dec 14 16:13:16 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * m68k-opcode.h (fseq & following fp instructions): - Change @ to $. - -Fri Dec 8 19:06:44 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * breakpoint.c (breakpoint_clear_ignore_counts): New function. - infcmd.c (run_command): Call it. - -Wed Dec 6 15:03:38 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * valprint.c: Change it so "array-max 0" means there is - no limit. - - * expread.y (yylex): Change error message "invalid token in - expression" to "invalid character '%c' in expression". - -Mon Dec 4 16:12:54 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * blockframe.c (find_pc_partial_function): Always return 1 - for success, 0 for failure, and set *NAME and *ADDRESS to - match the return value. - - * dbxread.c (symbol_file_command): Use perror_with_name on - error from stat. - (psymtab_to_symtab, add_file_command), - core.c (validate_files), source.c (find_source_lines), - default-dep.c (exec_file_command): Check for errors from stat, - fstat, and myread. - -Fri Dec 1 05:16:42 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * valops.c (check_field): When following pointers, just get - their types; don't call value_ind. - -Thu Nov 30 14:45:29 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * config.gdb (pyr): New machine. - core.c [REG_STACK_SEGMENT]: New code. - dbxread.c (process_one_symbol): Cast return from copy_pending - to long before casting to enum namespace. - infrun.c: Split registers_info into DO_REGISTERS_INFO - and registers_info. - m-pyr.h, pyr-{dep.c,opcode.h,pinsn.c}: New files. - - * hp300bsd-dep.c: Stay in sync with default-dep.c. - - * m-hp300bsd.h (IN_SIGTRAMP): Define. - -Mon Nov 27 23:48:21 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu) - - * m-sparc.h (EXTRACT_RETURN_VALUE, STORE_RETURN_VALUE): - Return floating point values in %f0. - -Tue Nov 21 00:34:46 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * dbxread.c (read_type): #if 0 out code which skips to - comma following x-ref. - -Sat Nov 18 20:10:54 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * valprint.c (val_print): Undo changes of Nov 11 & 16. - (print_string): Add parameter force_ellipses. - (val_print): Pass force_ellipses true when we stop fetching string - before we get to the end, else pass false. - -Thu Nov 16 11:59:50 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * infrun.c (restore_inferior_status): Don't try to restore - selected frame if the inferior no longer exists. - - * valprint.c (val_print): Rewrite string printing code not to - call print_string. - - * Makefile.dist (clean): Remove xgdb and xgdb.o. - -Tue Nov 14 12:41:47 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * Makefile.dist (XGDB, bindir, xbindir, install, all): New stuff. - -Sat Nov 11 15:29:38 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * valprint.c (val_print): chars_to_get: New variable. - -Thu Nov 9 12:31:47 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * main.c (main): Process "-help" as a switch that doesn't - take an argument. - -Wed Nov 8 13:07:02 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * Makefile.dist (gdb.tar.Z): Add "else true". - -Tue Nov 7 12:25:14 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * infrun.c (restore_inferior_status): Don't dereference fid if NULL. - - * config.gdb (sun3, sun4): Accept "sun3" and "sun4". - -Mon Nov 6 09:49:23 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * Makefile.dist (Makefile): Move comments after commands. - - * *-dep.c [READ_COFF_SYMTAB]: Pass optional header size to - read_section_hdr(). - - * inflow.c: Include regardless of USG. - - * coffread.c (read_section_hdr): Add optional_header_size. - (symbol_file_command): Pass optional header size to - read_section_hdr(). - (read_coff_symtab): Initialize filestring. - - * version.c: Change version to 3.4.xxx. - - * GDB 3.4 released. - -Sun Nov 5 11:39:01 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * version.c: Change version to 3.4. - - * symtab.c (decode_line_1): Only skip past "struct" if it - is there. - - * valops.c (value_ind), eval.c (evaluate_subexp, case UNOP_IND): - Have "*" return an int, not a LONGEST. - - * utils.c (fprintf_filtered): Pass arg{4,5,6} to sprintf. - - * printcmd.c (x_command): Use variable itself rather - than treating it as a pointer only if it is a function. - (See comment "this makes x/i main work"). - - * coffread.c (symbol_file_command): Use error for - "%s does not have a symbol-table.\n". - -Wed Nov 1 19:56:18 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * dbxread.c [BELIEVE_PCC_PROMOTION_TYPE]: New code. - m-sparc.h: Define BELIEVE_PCC_PROMOTION_TYPE. - -Thu Oct 26 12:45:00 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * infrun.c: Include . - - * dbxread.c (read_dbx_symtab, case N_LSYM, case 'T'): - Check for enum types and put constants in psymtab. - -Mon Oct 23 15:02:25 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * dbxread.c (define_symbol, read_dbx_symtab): Handle enum - constants (e.g. "b:c=e6,0"). - -Thu Oct 19 14:57:26 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * stack.c (frame_info): Use FRAME_ARGS_ADDRESS_CORRECT - m-vax.h (FRAME_ARGS_ADDRESS_CORRECT): New macro. - (FRAME_ARGS_ADDRESS): Restore old meaning. - - * frame.h (Frame_unknown): New macro. - stack.c (frame_info): Check for Frame_unknown return from - FRAME_ARGS_ADDRESS. - m-vax.h (FRAME_ARGS_ADDRESS): Sometimes return Frame_unknown. - - * utils.c (fatal_dump_core): Add "internal error" to message. - - * infrun.c (IN_SIGTRAMP): New macro. - (wait_for_inferior): Use IN_SIGTRAMP. - m-vax.h (IN_SIGTRAMP): New macro. - -Wed Oct 18 15:09:22 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * config.gdb, Makefile.dist: Shorten m-i386-sv32.h. - - * coffread.c (symbol_file_command): Pass 0 to select_source_symtab. - -Tue Oct 17 12:24:41 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * i386-dep.c (i386_frame_num_args): Take function from m-i386.h - file. Check for pfi null. - m-i386.h (FRAME_NUM_ARGS): Use i386_frame_num_args. - - * infrun.c (wait_for_inferior): set stop_func_name to 0 - before calling find_pc_partial_function. - -Thu Oct 12 01:08:50 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * breakpoint.c (_initialize_breakpoint): Add "disa". - - * Makefile.dist: Add GLOBAL_CFLAGS and pass to readline. - - * config.gdb (various): "$machine =" -> "machine =". - -Wed Oct 11 11:54:31 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * inflow.c (try_writing_regs): #if 0 out this function. - - * main.c (main): Add "-help" option. - - * dbxread.c (read_dbx_symtab): Merge code for N_FUN with - N_STSYM, etc. - -Mon Oct 9 14:21:55 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * inflow.c (try_writing_regs_command): Don't write past end - of struct user. - - * dbxread.c (read_struct_type): #if 0 out code which checks for - bitpos and bitsize 0. - - * config.gdb: Accept sequent-i386 (not seq386). - (symmetry): Set depfile and paramfile. - - * m-convex.h (IGNORE_SYMBOL): Check for N_MONPT if defined. - -Thu Oct 5 10:14:26 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * default-dep.c (read_inferior_memory): Put #if 0'd out comment - within /* */. - -Wed Oct 4 18:44:41 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu) - - * config.gdb: Change /dev/null to m-i386.h for various - 386 machine "opcodefile" entries. - - * config.gdb: Accept seq386 for sequent symmetry. - -Mon Oct 2 09:59:50 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * hp300bsd-dep.c: Fix copyright notice. - -Sun Oct 1 16:25:30 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * Makefile.dist (DEPFILES): Add isi-dep.c. - - * default-dep.c (read_inferior_memory): Move #endif after else. - -Sat Sep 30 12:50:16 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * version.c: Change version number to 3.3.xxx. - - * GDB 3.3 released. - - * version.c: Change version number to 3.3. - - * Makefile.dist (READLINE): Add vi_mode.c - - * config.gdb (i386): Change /dev/null to m-i386.h - - * config.gdb: Add ';;' before 'esac'. - - * Makefile.dist (gdb.tar.Z): Move comment above dependency. - - * dbxread.c (read_ofile_symtab): Check symbol before start - of source file for GCC_COMPILED_FLAG_SYMBOL. - (start_symtab): Don't clear processing_gcc_compilation. - -Thu Sep 28 22:30:23 1989 Roland McGrath (roland at hobbes.ai.mit.edu) - - * valprint.c (print_string): If LENGTH is zero, print "". - -Wed Sep 27 10:15:10 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu) - - * config.gdb: "rm tmp.c" -> "rm -f tmp.c". - -Tue Sep 26 13:02:10 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * utils.c (_initialize_utils): Use termcap to set lines_per_page - and chars_per_line. - -Mon Sep 25 10:06:43 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * dbxread.c (read_dbx_symtab, N_SOL): Do not add the same file - more than once. - -Thu Sep 21 12:43:18 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * infcmd.c (unset_environment_command): Delete all variables - if called with no arg. - - * remote.c, inferior.h (remote_{read,write}_inferior_memory): - New functions. - core.c ({read,write}_memory): Use remote_{read,write}_inferior_memory. - - * valops.c (call_function): When reserving stack space for - arguments, call value_arg_coerce. - - * m-hp9k320.h: define BROKEN_LARGE_ALLOCA. - - * breakpoint.c (delete_command): Ask for confirmation only - when there are breakpoints. - - * dbxread.c (read_struct_type): If lookup_basetype_type has - copied a stub type, call add_undefined_type. - - * sparc_pinsn.c (compare_opcodes): Check for "1+i" anywhere - in args. - - * val_print.c (type_print_base): Print stub types as - "". - -Wed Sep 20 07:32:00 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * sparc-opcode.h (swapa): Remove i bit from match. - (all alternate space instructions): Delete surplus "foo rs1+0" - patterns. - - * Makefile.dist (LDFLAGS): Set to $(CFLAGS). - - * remote-multi.shar (remote_utils.c, putpkt): Change csum to unsigned. - -Tue Sep 19 14:15:16 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu) - - * sparc-opcode.h: Set i bit in lose for many instructions which - aren't immediate. - - * stack.c (print_frame_info): add "func = 0". - -Mon Sep 18 16:19:48 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * sparc-opcode.h (mov): Add mov to/from %tbr, %psr, %wim. - - * sparc-opcode.h (rett): Fix notation to use suggested assembler - syntax from architecture manual. - - * symmetry-dep.c (I386_REGNO_TO_SYMMETRY): New macro. - (i386_frame_find_saved_regs): Use I386_REGNO_TO_SYMMETRY. - -Sat Sep 16 22:21:17 1989 Jim Kingdon (kingdon at spiff) - - * remote.c (remote_close): Set remote_desc to -1. - - * gdb.texinfo (Output): Fix description of echo to match - reality and ANSI C. - -Fri Sep 15 14:28:59 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu) - - * symtab.c (lookup_symbol): Add comment about "asm". - - * sparc-pinsn.c: Use NUMOPCODES. - - * sparc-opcode.h (NUMOPCODES): Use sparc_opcodes[0] not *sparc_opcodes. - -Thu Sep 14 15:25:20 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu) - - * dbxread.c (xxmalloc): Print error message before calling abort(). - - * infrun.c (wait_for_inferior): Check for {stop,prev}_func_name - null before passing to strcmp. - -Wed Sep 13 12:34:15 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * sparc-opcode.h: New field delayed. - sparc-pinsn.c (is_delayed_branch): New function. - (print_insn): Check for delayed branches. - - * stack.c (print_frame_info): Use misc_function_vector in - case where ar truncates file names. - -Tue Sep 12 00:16:14 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * convex-dep.c (psw_info): Move "struct pswbit *p" with declarations. - -Mon Sep 11 14:59:57 1989 Jim Kingdon (kingdon at spiff) - - * convex-dep.c (core_file_command): Delete redundant printing - of "Program %s". - - * m-convex.h (ENTRY_POINT): New macro. - - * m-convex.h (FRAME_CHAIN_VALID): Change outside_first_object_file - to outside_startup_file - - * main.c: #if 0 out catch_termination and related code. - - * command.c (lookup_cmd_1): Consider underscores part of - command names. - -Sun Sep 10 09:20:12 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * printcmd.c: Change asdump_command to disassemble_command - (_initialize_printcmd): Change asdump to diassemble. - - * main.c (main): Exit with code 0 if we hit the end of a batch - file. - - * Makefile.dist (libreadline.a): Fix syntax of "CC=${CC}". - -Sat Sep 9 01:07:18 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu) - - * values.c (history_info): Renamed to value_history_info. - Command renamed to "info value" (with "info history" still - accepted). - - * sparc-pinsn.c (print_insn): Extend symbolic address printing - to cover "sethi" following by an insn which uses 1+i. - -Fri Sep 8 14:24:01 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * m-hp9k320.h, m-hp300bsd.h, m-altos.h, m-sparc.h, m-sun3.h - (READ_GDB_SYMSEGS): Remove. - dbxread.c [READ_GDB_SYMSEGS]: Remove code to read symsegs. - - * sparc-pinsn.c (print_insn): Detect "sethi-or" pairs and - print symbolic address. - - * sparc-opcode.h (sethi, set): Change lose from 0xc0000000 to - 0xc0c00000000. - - * remote.c (remote_desc): Initialize to -1. - - * Makefile.dist (libreadline.a): Pass CC='${CC}' to readline makefile. - -Thu Sep 7 00:07:17 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu) - - * dbxread.c (read_struct_type): Check for static member functions. - values.c, eval.c, valarith.c, valprint.c, valops.c: Merge changes - from Tiemann for static member functions. - - * sparc-opcode.h (tst): Fix all 3 patterns. - - * Makefile.dist (gdb1): New rule. - - * sparc-opcode.h: Change comment about what the disassembler - does with the order of the opcodes. - - * sparc-pinsn.c (compare_opcodes): Put 1+i before i+1. - Also fix mistaken comment about preserving order of original table. - - * sparc-opcode.h (clr, mov): Fix incorrect lose entries. - - * m-symmetry.h (FRAME_NUM_ARGS): Add check to deal with code that - GCC sometimes generates. - - * config.gdb: Change all occurances of "skip" to "/dev/null". - - * README (about languages other than C): Update comments about - Pascal and FORTRAN. - - * sparc-opcode.h (nop): Change lose from 0xae3fffff to 0xfe3fffff. - - * values.c (value_virtual_fn_field): #if 0-out assignment to - VALUE_TYPE(vtbl). - -Wed Sep 6 12:19:22 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * utils.c (fatal_dump_core): New function. - Makefile.dist (MALLOC_FLAGS): use -Dbotch=fatal_dump_core - -Tue Sep 5 15:47:18 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * breakpoint.c (enable_command): With no arg, enable all bkpts. - - * Makefile.dist (Makefile): Remove \"'s around $(MD). - - * Makefile.dist: In "cd readline; make . . ." change first - SYSV_DEFINE to SYSV. - - * m68k-pinsn.c (_initialize_pinsn): Use alternate assembler - syntax #ifdef HPUX_ASM - -Sat Sep 2 23:24:43 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu) - - * values.c (history_info): Don't check num_exp[0] if num_exp - is nil (just like recent editing_info change). - -Fri Sep 1 19:19:01 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu) - - * gdb.texinfo (inc-history, inc-readline): Copy in the inc-* files - because people might not have makeinfo. - - * README (xgdb): Strengthen nasty comments. - - * gdb.texinfo: Change @setfilename to "gdb.info". - -Thu Aug 31 17:23:50 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu) - - * main.c (editing_info): Don't check arg[0] if arg is null. - - * m-vax.h: Add comment about known sigtramp bug. - - * sun3-dep.c, sparc-dep.c (IS_OBJECT_FILE, exec_file_command): - Get right text & data addresses for .o files. - -Wed Aug 30 13:54:19 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * utils.c (tilde_expand): Remove function (it's in readline). - - * sparc-opcode.h (call): Change "8" to "9" in first two - patterns (%g7->%o7). - -Tue Aug 29 16:44:41 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * printcmd.c (whatis_command): Change 4th arg to type_print - from 1 to -1. - -Mon Aug 28 12:22:41 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * dbxread.c (psymtab_to_symtab_1): In "and %s ..." change - pst->filename to pst->dependencies[i]->filename. - - * blockframe.c (FRAMELESS_LOOK_FOR_PROLOGUE): New macro - made from FRAMELESS_FUNCTION_INVOCATION from m-sun3.h except - that it checks for zero return from get_pc_function_start. - m-hp9k320.h, m-hp300bsd.h, m-i386.h, m-isi.h, m-altos.h, - m-news.h, m-sparc.h, m-sun2.h, m-sun3.h, m-symmetry.h - (FRAMELESS_FUNCTION_INVOCATION): Use FRAMELESS_LOOK_FOR_PROLOGUE. - - * dbxread.c (read_struct_type): Give warning and ignore field - if bitpos and bitsize are zero. - -Sun Aug 27 04:55:20 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu) - - * dbxread.c (psymtab_to_symtab{,_1}): Print message about - reading in symbols before reading stringtab, not after. - -Sat Aug 26 02:01:53 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * dbxread.c (IS_OBJECT_FILE, ADDR_OF_TEXT_SEGMENT): New macros. - (read_dbx_symtab): Use text_addr & text_size to set end_of_text_addr. - (symbol_file_command): pass text_addr & text_size to read_dbx_symtab. - -Fri Aug 25 23:08:13 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * valprint.c (value_print): Try to give the name of function - pointed to when printing a function pointer. - -Thu Aug 24 23:18:40 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * core.c (xfer_core_file): In cases where MEMADDR is above the - largest address that makes sense, set i to len. - -Thu Aug 24 16:04:17 1989 Roland McGrath (roland at hobbes.ai.mit.edu) - - * valprint.c (print_string): New function to print a character - string, doing array-max limiting and repeat count processing. - (val_print, value_print): Use print_string. - (REPEAT_COUNT_THRESHOLD): New #define, the max number of elts to print - without using a repeat count. Set to ten. - (value_print, val_print): Use REPEAT_COUNT_THRESHOLD. - - * utils.c (printchar): Use {fputs,fprintf}_filtered. - - * valprint.c (val_print): Pass the repeat count arg to the - fprintf_filtered call for "" messages. - -Wed Aug 23 22:53:47 1989 Roland McGrath (roland at hobbes.ai.mit.edu) - - * utils.c: Include . - - * main.c: Declare free. - -Wed Aug 23 05:05:59 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu) - - * utils.c, defs.h: Add tilde_expand. - source.c (directory_command), - main.c (cd_command), - main.c (set_history_filename), - dbxread.c (symbol_file_command), - coffread.c (symbol_file_command), - dbxread.c (add_file_command), - symmisc.c (print_symtabs), - *-dep.c (exec_file_command, core_file_command), - main.c (source_command): Use tilde_expand. - - * dbxread.c (read_type): When we get a cross-reference, resolve - it immediately if possible, only calling add_undefined_type if - necessary. - - * gdb.texinfo: Uncomment @includes and put comment at start - of file telling people to use makeinfo. - - * valprint.c (type_print_base): Print the right thing for - bitfields. - - * config.gdb (sun3os3): Set paramfile and depfile. - -Tue Aug 22 05:38:36 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * dbxread.c (symbol_file_command): Pass string table size to - read_dbx_symtab(). - (read_dbx_symtab): Before indexing into string table, check - string table index for reasonableness. - (psymtab_to_symtab{,_1}, read_ofile_symtab): Same. - -Tue Aug 22 04:04:39 1989 Roland McGrath (roland at hobbes.ai.mit.edu) - - * m68k-pinsn.c: Replaced many calls to fprintf and fputs with - calls to fprintf_filtered and fputs_filtered. - (print_insn_arg): Use normal MIT 68k syntax for postincrement, - predecrement, and register indirect addressing modes. - -Mon Aug 21 10:08:02 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * main.c (initialize_signals): Set signal handler for SIGQUIT - and SIGHUP to do_nothing. - - * ns32k-opcode.h (ord): Change 1D1D to 1D2D. - - * ns32k-pinsn.c (print_insn_arg, print_insn): Handle index - bytes correctly. - - * ns32k-opcode.h: Add comments. - - * dbxread.c (read_type): Put enum fields in type.fields in order - that they were found in the debugging symbols (not reverse order). - -Sun Aug 20 21:17:13 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * main.c (source_command): Read .gdbinit if run without argument. - - * source.c (directory_command): Only print "foo already in path" - if from_tty. - - * version.c: Change version number to 3.2.xxx - -Sat Aug 19 00:24:08 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu) - - * m-news.h: Define HAVE_WAIT_STRUCT. - - * m-isi.h, isi-dep.c: Replace with new version from Adam de Boor. - config.gdb: Remove isibsd43. - - * main.c (catch_termination): Don't say we have written - .gdb_history until after we really have. - - * convex-dep.c (attach): Add "sleep (1)". - (write_vector_register): Use "LL" with long long constant. - (wait): Close comment. - (wait): Change "unix 7.1 bug" to "unix 7.1 feature" & related - changes in comment. - (scan_stack): And fp with 0x80000000 in while loop test. - (core_file_command): Move code to set COREFILE. - (many places): Change printf to printf_filtered. - (psw_info): Allow argument giving value to print as a psw. - (_initialize_convex_dep): Update docstrings. - - * m-convex.h (WORDS_BIG_ENDIAN): Correct typo ("WRODS") - define NO_SIGINTERRUPT. - define SET_STACK_LIMIT_HUGE. - add "undef BUILTIN_TYPE_LONGEST" before defining it. - Use "LL" after constants in CALL_DUMMY. - - * dbxread.c: In the 3 places it says error "ridiculous string - table size"... delete extra parameter to error. - - * dbxread.c (scan_file_globals): Check for FORTRAN common block. - Allow multiple references for the sake of common blocks. - - * main.c (initialize_main): Set history_filename to include - current directory. - - * valprint.c (decode_format): Don't return a defaulted size - field if osize is zero. - - * gdb.texinfo (Compilation): Update information on -gg symbols. - Document problem with ar. - -Fri Aug 18 19:45:20 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu) - - * valprint.c (val_print, value_print): Add "" code. - Also put "..." outside quotes for strings. - - * main.c (initialize_main): Add comment about history output file - being different from history input file. - - * m-newsos3.h: Undefine NO_SIGINTERRUPT. Rearrange a few comments. - - * m-newsos3.h (REGISTER_U_ADDR): Use new version from Hikichi. - - * sparc-opcode.h: Add comment clarifying meaning of the order of - the entries in sparc_opcodes. - - * eval.c (evaluate_subexp, case UNOP_IND): Deal with deferencing - things that are not pointers. - - * valops.c (value_ind): Make dereferencing an int give a LONGEST. - - * expprint.c (print_subexp): Add (int) cast in OP_LAST case. - - * dbxread.c (read_array_type): Set lower and upper if adjustable. - - * symtab.c (lookup_symbol): Don't abort if symbol found in psymtab - but not in symtab. - -Thu Aug 17 15:51:20 1989 Randy Smith (randy at hobbes.ai.mit.edu) - - * config.gdb: Changed "Makefile.c" to "Makefile.dist". - -Thu Aug 17 01:58:04 1989 Roland McGrath (roland at apple-gunkies.ai.mit.edu) - - * sparc-opcode.h (or): Removed incorrect lose bit 0x08000000. - [many]: Changed many `lose' entries to have the 0x10 bit set, so - they don't think %l0 is %g0. - -Wed Aug 16 00:30:44 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * m-symmetry.h (STORE_STRUCT_RETURN): Also write reg 0. - (EXTRACT_RETURN_VALUE): Call symmetry_extract_return_value. - symmetry-dep.c (symmetry_extract_return_value): New fn. - - * main.c (symbol_completion_function): Deal with changed - result_list from lookup_cmd_1 for ambiguous return. - command.c (lookup_cmd): Same. - - * inflow.c [TIOCGETC]: Move #include "param.h" back before - system #includes. Change all #ifdef TIOCGETC to - #if defined(TIOCGETC) && !defined(TIOCGETC_BROKEN) - m-i386-sysv3.2.h, m-i386gas-sysv3.2.h: Remove "#undef TIOCGETC" - and add "#define TIOCGETC_BROKEN". - - * command.c (lookup_cmd_1): Give the correct result_list in the - case of an ambiguous return where there is a partial match - (e.g. "info a"). Add comment clarifying what is the correct - result_list. - - * gdb.texinfo (GDB History): Document the two changes below. - - * main.c (command_line_input): Make history expansion not - just occur at the beginning of a line. - - * main.c (initialize_main): Make history expansion off by default. - - * inflow.c: Move #include "param.h" after system #includes. - - * i386-dep.c (i386_float_info): Use U_FPSTATE macro. - - * m-i386-sysv3.2.h, m-i386gas-sysv3.2.h: New files. - Makefile.dist, config.gdb: Know about these new files. - -Tue Aug 15 21:36:11 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * symtab.c (lookup_struct_elt_type): Use type_print rather - than assuming type has a name. - -Tue Aug 15 02:25:43 1989 Roland McGrath (roland at apple-gunkies.ai.mit.edu) - - * sparc-opcode.h (mov): Removed bogus "or i,0,d" pattern. - - * sparc-opcode.h (mov, or): Fixed incorrect `lose' members. - - * sparc-dep.c: Don't include "sparc-opcode.h". - (skip_prologue, isanulled): Declare special types to recognize - instructions, and use them. - - * sparc-pinsn.c (print_insn): Sign-extend 13-bit immediate args. - If they are less than +9, print them in signed decimal instead - of unsigned hex. - - * sparc-opcode.h, sparc-pinsn.c: Completely rewritten to share an - opcode table with gas, and thus produce disassembly that looks - like what the assembler accepts. - -Tue Aug 15 16:20:52 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu) - - * symtab.c (find_pc_psymbol): Move best_pc=psymtab->textlow-1 - after test for psymtab null. - - * main.c (editing_info): Remove variable retval. - - * config.gdb (sun3, isi): Comment out obsolete message about telling - it whether you have an FPU (now that it detects it). - - * config.gdb (sun3): Accept sun3os3. - - * m68k-insn.h: Include . - - * m68k-pinsn.h (convert_{to,from}_68881): Add have_fpu code - - * m-newsos3.h: Undefine USE_PCB. That code didn't seem to work. - - * sparc-dep.c: Put in insn_fmt and other stuff from the old - sparc-opcode.h. - - * sparc-opcode.h, sparc-pinsn.c: Correct copyright notice. - - * sparc-opcode.h, sparc-pinsn.c: Replace the old ones with the new - ones by roland. - -Tue Aug 15 02:25:43 1989 Roland McGrath (roland at apple-gunkies.ai.mit.edu) - - * Makefile.dist: Don't define CC at all. - - * Makefile.dist (Makefile): Remove tmp.c after preprocessing. - Use $(MD) instead of M_MAKEDEFINE in the cc command. - - * Makefile.dist: Don't define RL_LIB as - "${READLINE}/libreadline.a", since READLINE is a list of files. - -Mon Aug 14 23:49:29 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * main.c (print_version): Change 1988 to 1989. - - * main.c (copying_info, initialize_main): Remove #if 0'd code. - -Tue Aug 1 14:44:56 1989 Hikichi (hikichi at sran203) - - * m-newsos3.h - (NO_SIGINTERRUPT): have SIGINTERRUPT on NEWS os 3. - - * m-news.h(FRAME_FIND_SAVED_REGS): use the sun3's instead of old - one. - -Mon Aug 14 15:27:01 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * m-news.h, m-newsos3.h, news-dep.c: Merge additional changes - by Hikichi (ChangeLog entries above). - - * Makefile.dist (READLINE): List readline files individually - so we don't accidently get random files from the readline - directory. - - * m-news.h (STORE_RETURN_VALUE, EXTRACT_RETURN_VALUE): - Expect floating point returns to be in fp0. - - * gdb.texinfo (Format options): New node. - - * gdb.texinfo: Comment out "@include"s until bfox fixes the - readline & history docs. - - * dbxread.c (read_addl_syms): Set startup_file_* if necessary at - the end (as well as when we hit ".o"). - - * printcmd.c (decode_format): Set val.format & val.size to '?' at - start and set defaults at end. - - * symtab.c (decode_line_1): Check for class_name null. - - * valops.c: Each place where it compares against field names, - check for null field names. (new t_field_name variables). - - * utils.c (fputs_filtered): Check for linebuffer null before - checking whether to call fputs. Remove later check for linebuffer - null. - -Sun Aug 13 15:56:50 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * m-isi.h, m-sun3.h ({PUSH,POP}_FP_REGS): New macros. - m-sun3.h (NUM_REGS): Conditionalize on FPU. - config.gdb (sun3, isi): Add message about support for machines - without FPU. - - * main.c (catch_termination, initialize_signals): new functions. - - * main.c (editing_info): Add "info editing n" and "info editing +". - Rewrite much of this function. - gdb.texinfo (GDB Readline): Document it. - - * values.c (history_info): Add "info history +". Also add code to - do "info history +" when command is repeated. - gdb.texinfo (Value History): Document "info history +". - - * expprint.c (print_subexp): Add OP_THIS to case stmt. - - * config.gdb (sun4os4): Put quotes around make define. - - * config.gdb: Canonicalize machine name at beginning. - -Sat Aug 12 00:50:59 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * config.gdb: define M_MAKEDEFINE - Makefile (Makefile, MD): Be able to re-make Makefile. - - * main.c (command_line_input): Add comments to - the command history. - - * Makefile.dist (Makefile): Add /bin/false. - -Fri Aug 11 14:35:33 1989 Jim Kingdon (kingdon at spiff) - - * Makefile.dist: Comment out .c.o rule and add TARGET_ARCH. - - * m-altos.h: Include sys/page.h & sys/net.h - - * m-altos.h (FRAME_CHAIN{,_VALID}): Use outside_startup_file. - - * config.gdb (altos, altosgas): Add M_SYSV & M_BSD_NM and remove - M_ALLOCA=alloca.o from makedefine. - - * coffread.c (complete_symtab): Change a_entry to entry. - - * m-altosgas.h: New file. - - * m-symmetry (REGISTER_BYTE): Fix dumb mistake. - -Fri Aug 11 06:39:49 1989 Roland McGrath (roland at hobbes.ai.mit.edu) - - * utils.c (set_screensize_command): Check for ARG being nil, since - that's what execute_command will pass if there's no argument. - - * expread.y (yylex): Recognize "0x" or "0X" as the beginning of a - number. - -Thu Aug 10 15:43:12 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * config.gdb, Makefile.dist: Rename Makefile.c to Makefile.dist. - - * m-altos.h: Add comment about porting to USGR2. - - * config.gdb (sparc): Add -Usparc. - -Wed Aug 9 14:20:39 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * m-sun3os4.h: Define BROKEN_LARGE_ALLOCA. - - * values.c (modify_field): Check for value too large to fit in - bitfield. - - * utils.c (fputs_filtered): Allow LINEBUFFER to be NULL. - - * breakpoint.c (condition_command): Check for attempt to specify - non-numeric breakpoint number. - - * config.gdb, Makefile, m-altos.h, altos-dep.c: Merge Altos - port. - - * README: Change message about editing Makefile. - - * config.gdb: Edit Makefile. - Copied Makefile to Makefile.c and changed to let config.gdb - run us through the C preprocessor. - - * expread.y (yylex): Test correctly for definition of number. - -Wed Aug 9 11:56:05 1989 Randy Smith (randy at hobbes.ai.mit.edu) - - * dbxread.c (read_dbx_symtab): Put bracketing of entry point in - test case for .o symbols so that it will be correct even without - debugging symbols. - (end_psymtab): Took bracketing out. - - * blockframe.c (outside_startup_file): Reverse the sense of the - return value to make the functionality implied by the name - correct. - -Tue Aug 8 11:48:38 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * coffread.c (symbol_file_command): Do not assume presence of a.out - header. - - * blockframe.c: Replace first_object_file_end with - startup_file_{start,end} - (outside_startup_file): New function. - dbxread.c (read_addl_syms, read_dbx_symtab, end_psymbol): set - startup_file_*. Delete first_object_file_end code. - Add entry_point and ENTRY_POINT - coffread.c (complete_symtab): Set startup_file_*. - (first_object_file_end): Add as static. - m-*.h (FRAME_CHAIN, FRAME_CHAIN_VALID): Call outside_startup_file - instead of comparing with first_object_file_end. - - * breakpoint.c (breakpoint_1): Change -1 to (CORE_ADDR)-1. - - * config.gdb (i386, i386gas): Add missing quotes at end of "echo" - - * source.c (directory_command): Add dont_repeat (); - -Mon Aug 7 18:03:51 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * dbxread.c (read_addl_syms): Change strcmp to strncmp and put 3rd - arg back. - - * command.h (struct cmd_list_element): Add comment clarifying - purpose of abbrev_flag. - -Mon Aug 7 12:51:03 1989 Randy Smith (randy at hobbes.ai.mit.edu) - - * printcmd.c (_initialize_printcmd): Changed "undisplay" not to - have abbrev flag set; it isn't an abbreviation of "delete - display", it's an alias. - -Mon Aug 7 00:25:15 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * symtab.c (lookup_symtab_1): Remove filematch (never used). - - * expread.y [type]: Add second argument to 2 calls to - lookup_member_type which were missing them. - - * dbxread.c (symbol_file_command): Add from_tty arg. - Check it before calling query. - - * infcmd.c (tty_command): Add from_tty arg. - - * eval.c (evaluate_subexp): Remove 3rd argument from - calls to value_x_unop. - - * dbxread.c (read_addl_syms): Remove 3rd argument from - call to strcmp. - - * gdb.texinfo (Command editing): @include inc-readline.texinfo - and inc-history.texinfo and reorganize GDB-specific stuff. - - * Makefile: Add line MAKE=make. - - * README (second paragraph): Fix trivial errors. - - * dbxread.c (read_struct_type): Make sure p is initialized. - - * main.c (symbol_completion_function): Complete correctly - on the empty string. - -Sun Aug 6 21:01:59 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * symmetry-dep.c: Remove "long" from definition of i386_follow_jump. - - * gdb.texinfo (Backtrace): Document "where" and "info stack". - - * dbxread.c (cleanup_undefined_types): Strip off "struct " - or "union " from type names before doing comparison - -Sat Aug 5 02:05:36 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * config.gdb (i386, i386gas): Improve makefile editing instructions. - - * Makefile: Fix typo in CLIBS for SYSV. - - * dbxread.c (read_dbx_symtab): Deal with N_GSYM typedefs. - - * dbxread.c (add_file_command): Do not free name. We didn't - allocate it; it just points into arg_string. - - * Makefile, m-*.h: Change LACK_VPRINTF to HAVE_VPRINTF. - -Fri Jul 28 00:07:48 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * valprint.c (val_print): Made sure that all returns returned a - value (usually 0, indicating no memory printed). - - * core.c (read_memory): Changed "return" to "return 0". - - * expread.y (parse_number): Handle scientific notation when the - string does not contain a '.'. - -Thu Jul 27 15:14:03 1989 Randy Smith (randy at hobbes.ai.mit.edu) - - * infrun.c (signals_info): Error if signal number passed is out of - bounds. - - * defs.h: Define alloca to be __builtin_alloca if compiling with - gcc and localized inclusion of alloca.h on the sparc with the - other alloca stuff. - * command.c: Doesn't need to include alloca.h on the sparc; defs.h - does it for you. - - * printcmd.c (print_frame_args): Changed test for call to - print_frame_nameless_args to check i to tell if any args had been - printed. - -Thu Jul 27 04:40:56 1989 Roland McGrath (roland at hobbes.ai.mit.edu) - - * blockframe.c (find_pc_partial_function): Always check that NAME - and/or ADDRESS are not nil before storing into them. - -Wed Jul 26 23:41:21 1989 Roland McGrath (roland at hobbes.ai.mit.edu) - - * m-newsos3.h: Define BROKEN_LARGE_ALLOCA. - * dbxread.c (symbol_file_command, psymtab_to_symtab): - Use xmalloc #ifdef BROKEN_LARGE_ALLOCA. - -Tue Jul 25 16:28:18 1989 Jay Fenlason (hack at apple-gunkies.ai.mit.edu) - - * m68k-opcode.h: moved some of the fmovem entries so they're - all consecutive. This way the assembler doesn't bomb. - -Mon Jul 24 22:45:54 1989 Randy Smith (randy at hobbes.ai.mit.edu) - - * symtab.c (lookup_symbol): Changed error to an informational (if - not very comforting) message about internal problems. This will - get a null symbol returned to decode_line_1, which should force - things to be looked up in the misc function vector. - -Wed Jul 19 13:47:34 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * symtab.c (lookup_symbol): Changed "fatal" to "error" in - external symbol not found in symtab in which it was supposed to be - found. This can be reached because of a bug in ar. - -Tue Jul 18 22:57:43 1989 Randy Smith (roland at hobbes.ai.mit.edu) - - * m-news.h [REGISTER_U_ADDR]: Decreased the assumed offset of fp0 - by 4 to bring it into (apparently) appropriate alignment with - reality. - -Tue Jul 18 18:14:42 1989 Randy Smith (randy at hobbes.ai.mit.edu) - - * Makefile: pinsn.o should depend on opcode.h - - * m68k-opcode.h: Moved fmovemx with register lists to before other - fmovemx. - -Tue Jul 18 11:21:42 1989 Jim Kingdon (kingdon at susie) - - * Makefile, m*.h: Only #define vprintf (to _doprnt or printf, - depends on the system) if the library lacks it (controlled by - LACK_VPRINTF_DEFINE in makefile). Unpleasant, but necessary to - make this work with the GNU C library. - -Mon Jul 17 15:17:48 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * breakpoint.c (breakpoint_1): Change addr-b->address to - b->address-addr. - -Sun Jul 16 16:23:39 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * eval.c (evaluate_subexp): Change error message printed when - right operand of '@' is not an integer to English. - - * infcmd.c (registers_info): Fix call to print_spaces_filtered - to specify right # of arguments. - - * gdb.texinfo (Command Editing): Document info editing command. - - * coffread.c (read_file_hdr): Add MC68MAGIC. - - * source.c (select_source_symtab): Change MAX to max. - -Fri Jul 14 21:19:11 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu) - - * infcmd.c (registers_info): Clean up display to look good with long - register names, to say "register" instead of "reg", and to put the - "relative to selected stack frame" bit at the top. - -Fri Jul 14 18:23:09 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * dbxread.c (record_misc_function): Put parens around | to force - correct evaluation. - -Wed Jul 12 12:25:53 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * m-newsos3, m-news, infrun.c, Makefile, config.gdb, news-dep.c: - Merge in Hikichi's changes for Sony/News-OS 3 support. - -Tue Jul 11 21:41:32 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu) - - * utils.c (fputs_filtered): Don't do any filtering if output is - not to stdout, or if stdout is not a tty. - (fprintf_filtered): Rely on fputs_filtered's check for whether to - do filtering. - -Tue Jul 11 00:33:58 1989 Randy Smith (randy at hobbes.ai.mit.edu) - - * GDB 3.2 Released. - - * valprint.h: Deleted. - - * utils.c (fputs_filtered): Don't do any filtering if filtering is - disabled (lines_per_page == 0). - -Mon Jul 10 22:27:53 1989 Randy Smith (roland at hobbes.ai.mit.edu) - - * expread.y [typebase]: Added "unsigned long int" and "unsigned - short int" to specs. - -Mon Jul 10 21:44:55 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * main.c (main): Make -cd use cd_command to avoid - current_directory with non-absolute pathname. - -Mon Jul 10 00:34:29 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * dbxread.c (symbol_file_command): Catch errors from stat (even - though they should never happen). - - * source.c (openp): If the path is null, use the current - directory. - - * dbxread.c (read_dbx_symtab): Put N_SETV symbols into the misc - function vector ... - (record_misc_function): ... as data symbols. - - * utils.c (fprintf_filtered): Return after printing if we aren't - going to do filtering. - - * Makefile: Added several things for make clean to take care of. - - * expread.y: Lowered "@" in precedence below +,-,*,/,%. - - * eval.c (evaluate_subexp): Return an error if the rhs of "@" - isn't integral. - - * Makefile: Added removal of core and gdb[0-9] files to clean - target. - - * Makefile: Made a new target "distclean", which cleans things up - correctly for making a distribution. - -Sun Jul 9 23:21:27 1989 Randy Smith (randy at hobbes.ai.mit.edu) - - * dbxread.c: Surrounded define of gnu symbols with an #ifndef - NO_GNU_STABS in case you don't want them on some machines. - * m-npl.h, m-pn.h: Defined NO_GNU_STABS. - -Sun Jul 9 19:25:22 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu) - - * utils.c (fputs_filtered): New function. - (fprintf_filtered): Use fputs_filtered. - utils.c (print_spaces_filtered), - command.c (help_cmd,help_cmd_list), - printcmd.c (print_frame_args), - stack.c (print_block_frame_locals, print_frame_arg_vars), - valprint.c (many functions): Use fputs_filtered instead of - fprintf_filtered to avoid arbitrary limit. - - * utils.c (fprintf_filtered): Fix incorrect comment. - -Sat Jul 8 18:12:01 1989 Randy Smith (randy at hobbes.ai.mit.edu) - - * valprint.c (val_print): Changed assignment of pretty to use - prettyprint as a conditional rather than rely on values of the - enum. - - * Projects: Cleaned up a little for release. - - * main.c (initialize_main): Initialize - rl_completion_entry_function instead of completion_entry_function. - - * Makefile: Modified to use the new readline library setup. - - * breakpoint.c (break_command_1, delete_breakpoint, - enable_breakpoint, disable_breakpoint): Put in new printouts for - xgdb usage triggered off of xgdb_verbose. - * main.c (main): Added check for flag to set xgdb_verbose. - * stack.c (frame_command): Set frame_changed when frame command - used. - -Fri Jul 7 16:20:58 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * Remove valprint.h and move contents to value.h (more logical). - -Fri Jul 7 02:28:06 1989 Randall Smith (randy at rice-chex) - - * m68k-pinsn.c (print_insn): Included a check for register list; - if there is one, make sure to start p after it. - - * breakpoint.c (break_command_1, delete_breakpoint, - enable_breakpoint, disable_breakpoint): #ifdef'd out changes - below; they produce unwanted output in gdb mode in gnu-emacs. - - * gdb.texinfo: Spelled. Also removed index references from - command editing section; the relevance/volume ratio was too low. - Removed all references to the function index. - - * ns32k-opcode.h, ns32k-pinsn.c: Backed out changes of June 24th; - haven't yet received legal papers. - - * .gdbinit: Included message telling the user what it is doing. - - * symmetry-dep.c: Added static decls for i386_get_frame_setup, - i386_follow_jump. - * values.c (unpack_double): Added a return (double)0 at the end to - silence a compiler warning. - - * printcmd.c (containing_function_bounds, asdump_command): Created - to dump the assembly code of a function (support for xgdb and a - useful hack). - (_initialize_printcmd): Added this to command list. - * gdb.texinfo [Memory]: Added documentation for the asdump - command. - * breakpoint.c (break_command_1, delete_breakpoint, - enable_breakpoint, disable_breakpoint): Added extra verbosity for - xgdb conditionalized on the new external frame_full_file_name. - * source.c (identify_source_line): Increase verbosity of fullname - prointout to include pc value. - * stack.c: Added a new variable; "frame_changed" to indicate when - a frame has been changed so that gdb can print out a frame change - message when the frame only changes implicitly. - (print_frame_info): Check the new variable in determining when to - print out a new message and set it to zero when done. - (up_command): Increment it. - (down_command): Decrement it. - - * m68k-pinsn.c (print_insn_arg [lL]): Modified cases for register - lists to reset the point to point to after the word from which the - list is grabbed *if* that would cause point to point farther than - it currently is. - -Thu Jul 6 14:28:11 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu) - - * valprint.c (val_print, value_print): Add parameter to control - prettyprinting. - valprint.h: New file containing constants used for passing - prettyprinting parameter to val{,ue}_print. - expprint.c, infcmd.c, printcmd.c, valprint.c, values.c: - Change all calls to val{,ue}_print to use new parameter. - -Mon Jul 3 22:38:11 1989 Randy Smith (randy at apple-gunkies.ai.mit.edu) - - * dbxread.c (,process_one_symbol): Moved extern declaration for - index out of function to beginning of file. - -Mon Jul 3 18:40:14 1989 Jim Kingdon (kingdon at hobbes.ai.mit.edu) - - * gdb.texinfo (Registers): Add "ps" to list of standard registers. - -Sun Jul 2 23:13:03 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu) - - * printcmd.c (enable_display): Change d->next to d = d->next so - that "enable display" without args works. - -Fri Jun 30 23:42:04 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu) - - * source.c (list_command): Made error message given when no - symtab is loaded clearer. - - * valops.c (value_assign): Make it so that when assigning to an - internal variable, the type of the assignment exp is the type of - the value being assigned. - -Fri Jun 30 12:12:43 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * main.c (verbose_info): Created. - (initialize_main): Put "info verbose" into command list. - - * utils.c (screensize_info): Created. - (_initialize_utils): Defined "info screensize" as a normal command. - - * valprint.c (format_info): Added information about maximum number - of array elements to function. - - * blockframe.c (find_pc_partial_function): Again. - - * blockframe.c (find_pc_partial_function): Replaced a "shouldn't - happen" (which does) with a zero return. - - * main.c (dont_repeat): Moved ahead of first use. - -Thu Jun 29 19:15:08 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * vax-opcode.h: Made minor modifications (moved an instruction and - removed a typo) to bring this into accord with gas' table; also - changed copyright to reflect it being part of both gdb and gas. - - * m68k-opcode.h: Added whole scads and bunches of new stuff for - the m68851 and changed the coptyrightto recognize that the file - was shared between gdb and gas. - - * main.c (stop_sig): Use "dont_repeat ()" instead of *line = 0; - - * core.c (read_memory): Don't do anything if length is 0. - - * Makefile: Added readline.c to the list of files screwed by - having the ansi ioctl.h compilation with gcc. - - * config.gdb: Added sun4os3 & sun4-os3 as availible options. - -Wed Jun 28 02:01:26 1989 Jim Kingdon (kingdon at apple-gunkies.ai.mit.edu) - - * command.c (lookup_cmd): Add ignore_help_classes argument. - (lookup_cmd_1): Add ignore_help_classes argument. - command.c, main.c: Change callers of lookup_cmd{,_1} to supply - value for ignore_help_classes. - -Tue Jun 27 18:01:31 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * utils.c (print_spaces_filtered): Made more efficient. - * defs.h: Declaration. - * valprint.c (val_print): Used in a couple of new places. - -Mon Jun 26 18:27:28 1989 Randall Smith (randy at gluteus.ai.mit.edu) - - * m68k-pinsn.c (print_insn_arg ['#', '^']): Combined them into one - case which always gets the argument from the word immediately - following the instruction. - (print_insn_arg ["[lL]w"]): Make sure to always get the register - mask from the word immediately following the instruction. - -Sun Jun 25 19:14:56 1989 Randall Smith (randy at galapas.ai.mit.edu) - - * Makefile: Added hp-include back in as something to distribute. - - * stack.c (print_block_frame_locals): Return value changed from - void to int; return 1 if values printed. Use _filtered. - (print_frame_local_vars): Use return value from - print_block_frame_locals to mention if nothing printed; mention - lack of symbol table, use _filtered. - (print_frame_arg_vars): Tell the user if no symbol table - or no values printed. Use fprintf_filtered instead of fprintf. - * blockframe.c (get_prev_frame_info): Check for no inferior or - core file before crashing. - - * inflow.c (inferior_died): Set current frame to zero to keep from - looking like we're in start. - -Sat Jun 24 15:50:53 1989 Randall Smith (randy at gluteus.ai.mit.edu) - - * stack.c (frame_command): Added a check to make sure that there - was an inferior or a core file. - - * expread.y (yylex): Allow floating point numbers of the form ".5" - to be parsed. - - Changes by David Taylor at TMC: - * ns32k-pinsn.c: Added define for ?floating point coprocessor? and - tables for register names to be used for each of the possibilities. - (list_search): Created; searches a list of options for a specific - value. - (print_insn_arg): Added 'Q', 'b', 'M', 'P', 'g', and 'G' options - to the value location switch. - * ns32k-opcode.h: Added several new location flags. - [addr, enter, exit, ext[bwd], exts[bwd], lmr, lpr[bwd], restore, - rett, spr[bwd], smr]: Improved insn format output. - - * symtab.c (list_symbols): Rearrange printing to produce readable - output for "info types". - - * eval.c (evaluate_subexp_for_address): Fixed typo. - - * dbxread.c (read_type): Don't output an error message when - there isn't a ',' after a cross-reference. - - * dbxread.c (read_dbx_symtab): #if'd out N_FN case in - read_dbx_symtab if it has the EXT bit set (otherwise multiple - cases with the same value). - -Fri Jun 23 13:12:08 1989 Randall Smith (randy at plantaris.ai.mit.edu) - - * symmisc.c: Changed decl of print_spaces from static to extern - (since it's defined in utils.c). - - * remote.c (remote_open): Close remote_desc if it's already been - opened. - - * Remote_Makefile, remote_gutils.c, remote_inflow.c, - remote_server.c, remote_utils.c: Combined into remote-multi.shar. - * remote-multi.shar: Created (Vikram Koka's remote stub). - * remote-sa.m68k.shar: Created (Glenn Engel's remcom.c). - * README: Updated to reflect new organization of remote stubs. - - * dbxread.c (read_dbx_symtab): Put an N_FN in with N_FN | N_EXT to - account for those machines which don't use the external bit here. - Sigh. - - * m-symmetry.h: Defined NO_SIGINTERRUPT. - -Thu Jun 22 12:51:37 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * printcmd.c (decode_format): Make sure characters are printed - using a byte size. - - * utils.c (error): Added a terminal_ours here. - - * stack.c (locals_info): Added check for selected frame. - - * dbxread.c (read_type): Checked to make sure that a "," was - actually found in the symbol to end a cross reference. - -Wed Jun 21 10:30:01 1989 Randy Smith (randy at tartarus.uchicago.edu) - - * expread.y (parse_number, [exp]): Allowed for the return of a - number marked as unsigned; this will allow inclusion of unsigned - constants. - - * symtab.h: Put in default definitions for BUILTIN_TYPE_LONGEST - and BUILTIN_TYPE_UNSIGNED_LONGEST. - - * expread.y (parse_number): Will now accept integers suffixed with - a 'u' (though does nothing special with it). - - * valarith.c (value_binop): Added cases to deal with unsigned - arithmetic correctly. - -Tue Jun 20 14:25:54 1989 Randy Smith (randy at tartarus.uchicago.edu) - - * dbxread.c (psymtab_to_symtab_1): Changed reading in info message - to go through printf_filtered. - - * symtab.c (list_symbols): Placed header message after all calls - to psymtab_to_symtab. - - * symtab.c (smash_to_{function, reference, pointer}_type): Carried - attribute of permanence for the type being smashed over the bzero - and allowed any type to point at this one if it is permanent. - - * symtab.c (smash_to_{function, reference, pointer}_type): Fix - typo: check flags of to_type instead of type. - - * m-hp9k320.h: Changed check on __GNU__ predefine to __GNUC__. - - * Makefile: Made MUNCH_DEFINE seperate and based on SYSV_DEFINE; - they aren't the same on hp's. - -Mon Jun 19 17:10:16 1989 Randy Smith (randy at tartarus.uchicago.edu) - - * Makefile: Fixed typo. - - * valops.c (call_function): Error if the inferior has not been - started. - - * ns32k-opcode.h [check[wc], cmpm[bwd], movm[bwd], skpsb]: Fixed - typos. - -Fri Jun 9 16:23:04 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * m-news.h [NO_SIGINTERRUPT]: Defined. - - * dbxread.c (read_type): Start copy of undefined structure name - past [sue] defining type of cross ref. - - * dbxread.c (process_one_symbol): Changed strchr to index. - - * ns32k-opcode.h, ns32k-pinsn.c: More changes to number of - operands, addition of all of the set condition opcodes, addition - of several flag letters, all patterned after the gas code. - - * ns32k-opcode.h [mov{su,us}[bwd], or[bwd]]: Changed number of - operands from 1 to 2. - -Wed Jun 7 15:04:24 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * symseg.h [TYPE_FLAG_STUB]: Created. - * dbxread.c (read_type): Set flag bit if type is stub. - (cleanup_undefined_types): Don't mark it as a stub if it's been - defined since we first learned about it. - * valprint.c (val_print): Print out a message to that effect if - this type is encountered. - - * symseg.h, symtab.h: Moved the definition of TYPE_FLAG_PERM over - to symseg.h so that all such definitions would be in the same place. - - * valprint.c (val_print): Print out for a - structure if there aren't any. - - * dbxread.c (read_type): Set type name of a cross reference type - to "struct whatever" or something. - -Tue Jun 6 19:40:52 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * breakpoint.c (breakpoint_1): Print out symbolic location of - breakpoints for which there are no debugging symbols. - -Mon Jun 5 15:14:51 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * command.c (help_cmd_list): Made line_size static. - -Sat Jun 3 17:33:45 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * Makefile: Don't include the binutils hp-include directory in the - distribution anymore; refer the users to the binutils distribution. - -Thu Jun 1 16:33:07 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * printcmd.c (disable_display_command): Fixed loop iteration for - no arg case. - - * printcmd.c (disable_display_command): Added from_tty parameter - to function. - - * valops.c (value_of_variable): Call read_var_value with 0 cast to - FRAME instead of CORE_ADDR. - - * eval.c (evaluate_subexp): Corrected number of args passed to - value_subscript (to 2). - - * infrun.c (wait_for_inferior), symtab.c (decode_line_1), - m-convex.h: Changed name of FIRSTLINE_DEBUG_BROKEN to - PROLOGUE_FIRSTLINE_OVERLAP. - - * m-merlin.h: Fixed typo. - * ns32k-opcode.h: Added ns32381 opcodes and "cinv" insn, and fixed - errors in movm[wd], rett, and sfsr. - - * eval.c (evaluate_subexp, evaluate_subexp_for_address), valops.c - (value_zero): Change value_zero over to taking two arguments - instead of three. - - * eval.c (evaluate_subexp) - [OP_VAR_VALUE]: Get correct lval type for AVOID_SIDE_EFFECTS for - all types of symbols. - [BINOP_DIV]: Don't divide if avoiding side effects; just return - an object of the correct type. - [BINOP_REPEAT]: Don't call value_repeat, just allocate a - repeated value. - (evaluete_subexp_for_address) [OP_VAR_VALUE]: Just return a thing - of the right type (after checking to make sure that we are allowed - to take the address of whatever variable has been passed). - -Mon May 29 11:01:02 1989 Randall Smith (randy at galapas.ai.mit.edu) - - * breakpoint.c (until_break_command): Set the breakpoint with a - frame specification so that it won't trip in inferior calls to the - function. Also set things up so that it works based on selected - frame, not current one. - -Sun May 28 15:05:33 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * eval.c (evalue_subexp): Change subscript case to use value_zero - in EVAL_AVOID_SIDE_EFFECTS case. - -Fri May 26 12:03:56 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * dbxread.c (read_addl_syms, psymtab_to_symtab): Removed - cleanup_undefined_types; this needs to be done on a symtab basis. - (end_symtab): Called cleanup_undefined_types from here. - (cleanup_undefined_types): No longer uses lookup_symbol (brain - dead idea; oh, well), now it searches through file_symbols. - -Wed May 24 15:52:43 1989 Randall Smith (randy at galapas) - - * source.c (select_source_symtab): Only run through - partial_symtab_list if it exists. - - * coffread.c (read_coff_symtab): Don't unrecord a misc function - when a function symbol is seen for it. - - * expread.y [variable]: Make sure to write a type for memvals if - you don't get a mft you recognize. - -Tue May 23 12:15:57 1989 Randall Smith (randy at plantaris.ai.mit.edu) - - * dbxread.c (read_ofile_symtab, psymtab_to_symtab): Moved cleanup - of undefined types to psymtab_to_symtab. That way it will be - called once for all readins (which will, among other things, - help reduce infinite loops). - - * symtab.h [misc_function_type]: Forced mf_unknown to 0. - * dbxread.c (record_misc_function): Cast enum to unsigned char (to - fit). - * expread.y [variable]: Cast unsigned char back to enum to test. - -Mon May 22 13:08:25 1989 Randall Smith (randy at gluteus.ai.mit.edu) - - Patches by John Gilmore for dealing well with floating point: - * findvar.c (value_from_register, locate_var_value): Used - BYTES_BIG_ENDIAN instead of an inline test. - * m-sparc.h [IEEE_FLOAT]: Created to indicate that the sparc is - IEEE compatible. - * printcmd.c (print_scalar_formatted): Use BYTES_BIG_ENDIAN and - the stream argument for printing; also modify default type for - 'f'. Change handling of invalid floats; changed call syntax for - is_nan. - (print_command): Don't print out anything indicating that - something was recorded on the history list if it wasn't. - * valprint.c (val_print): Fixed to deal properley with new format - of is_nan and unpacking doubles without errors occuring. - (is_nan): Changed argument list and how it figures big endianness - (uses macros). - * values.c (record_latest_value): Return -1 and don't record if - it's an invalid float. - (value_as_double): Changed to use new unpack_double calling - convention. - (unpack_double): Changed not to call error if the float was - invalid; simply to set invp and return. Changed calling syntax. - (unpack_field_as_long, modify_field): Changed to use - BITS_BIG_ENDIAN to determine correct action. - - * m-hp9k320.h [HP_OS_BUG]: Created; deals with problem where a - trap happens after a continue. - * infrun.c (wait_for_inferior): Used. - - * m-convex.h [FIRSTLINE_DEBUG_BROKEN]: Defined a flag to indicate - that the debugging symbols output by the compiler for the first - line of a function were broken. - * infrun.c (wait_for_inferior), symtab.c (decode_line_1): Used. - - * gdb.texinfo [Data, Memory]: Minor cleanups of phrasing. - -Fri May 19 00:16:59 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * dbxread.c (add_undefined_type, cleanup_undefined_types): Created - to keep a list of cross references to as yet undefined types. - (read_type): Call add_undefined_type when we run into such a case. - (read_addl_syms, read_ofile_symtab): Call cleanup_undefined_types - when we're done. - - * dbxread.c (psymtab_to_symtab, psymtab_to_symtab_1): Broke - psymtab_to_symtab out into two routines; made sure the string - table was only readin once and the globals were only scanned once, - for any number of dependencies. - -Thu May 18 19:59:18 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * m-*.h: Defined (or not, as appropriate per machine) - BITS_BIG_ENDIAN, BYTES_BIG_ENDIAN, and WORDS_BIG_ENDIAN. - -Wed May 17 13:37:45 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * main.c (symbol_completion_function): Always complete on result - command list, even if exact match found. If it's really an exact - match, it'll find it again; if there's something longer than it, - it'll get the right result. - - * symtab.c (make_symbol_completion_function): Fixed typo; strcmp - ==> strncmp. - - * dbxread.c (read_dbx_symtab): Change 'G' case to mark symbols as - LOC_EXTERNAL. - - * expread.y [variables]: Changed default type of text symbols to - function returning int so that one can use, eg. strcmp. - - * infrun.c (wait_for_inferior): Include a special flag indicating - that one shouldn't insert the breakpoints on the next step for - returning from a sigtramp and forcing at least one move forward. - - * infrun.c (wait_for_inferior): Change test for nexting into a - function to check for current stack pointer inner than previous - stack pointer. - - * infrun.c (wait_for_inferior): Check for step resume break - address before dealing with normal breakpoints. - - * infrun.c (wait_for_inferior): Added a case to deal with taking - and passing along a signal when single stepping past breakpoints - before inserting breakpoints. - - * infrun.c (wait_for_inferior): Inserted special case to keep - going after taking a signal we are supposed to be taking. - -Tue May 16 12:49:55 1989 Randall Smith (randy at gluteus.ai.mit.edu) - - * inflow.c (terminal_ours_1): Cast result of signal to (int - (*)()). - - * gdb.texinfo: Made sure that references to the program were in - upper case. Modify description of the "set prompt" command. - [Running]: Cleaned up introduction. - [Attach]: Cleaned up. - [Stepping]: Change "Proceed" to "Continue running" or "Execute". - Minor cleanup. - [Source Path]: Cleaned up intro. Cleared up distinction between - the executable search path and the source path. Restated effect - of the "directory" command with no arguments. - [Data]: Fixed typos and trivial details. - [Stepping]: Fixed up explanation of "until". - - * source.c (print_source_lines): Print through filter. - - * printcmd.c (x_command): If the format with which to print is - "i", use the address of anything that isn't a pointer instead of - the value. This is for, eg. "x/10i main". - - * gdb.texinfo: Updated last modification date on manual. - -Mon May 15 12:11:33 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * symtab.c (lookup_symtab): Fixed typo (name ==> copy) in call to - lookup_symtab_1. - - * gdb.texinfo: Added documentation for "break [+-]n" and for new - actions of "directory" command (taking multiple directory names at - the same time). - - * m68k-opcode.h: Replaced the version in gdb with an up-to-date - version from the assembler directory. - * m68k-pinsn.c (print_insn_arg): Added cases 'l' & 'L' to switch - to print register lists for movem instructions. - - * dbxread.c, m-convex.h: Moved convex dependent include files over - from dbxread.c to m-convex.h. - - * printcmd.c (disable_display, disable_display_command): Changed - name of first to second, and created first which takes an int as - arg rather than a char pointer. Changed second to use first. - (_initialize_printcmd): Changed to use second as command to call. - (delete_current_display, disable_current_display): Changed name of - first to second, and changed functionality to match. - * infrun.c (normal_stop), main.c (return_to_top_level): Changed to - call disable_current_display. - - * dbxread.c (process_one_symbol, read_dbx_symtab): Changed N_FN to - be N_FN | N_EXT to deal with new Berkeley define; this works with - either the old or the new. - - * Remote_Makefile, remote_gutils.c, remote_inflow.c, - remote_server.c, remote_utils.c: Created. - * Makefile: Included in tag and tar files. - * README: Included a note about them. - - * printcmd.c (print_address): Use find_pc_partial_function to - remove need to readin symtabs for symbolic addresses. - - * source.c (directory_command): Replaced function with new one - that can accept lists of directories seperated by spaces or :'s. - - * inflow.c (new_tty): Replaced calls to dup2 with calls to dup. - -Sun May 14 12:33:16 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * stack.c (args_info): Make sure that you have an inferior or core - file before taking action. - - * ns32k-opcode.h [deiw, deid]: Fixed machine code values for these - opcodes. - - * dbxread.c (scan_file_globals): Modified to use misc function - vector instead of file itself. Killed all arguments to the - funciton; no longer needed. - (psymtab_to_symtab): Changed call for above to reflect new (void) - argument list. - - * dbxread.c (read_dbx_symtab, ): Moved HASH_OFFSET define out of - read_dbx_symtab. - - * expread.y [variable]: Changed default type of misc function in - text space to be (void ()). - - * Makefile: Modified for proper number of s/r conflicts (order is - confusing; the mod that necessitated this change was on May 12th, - not today). - - * expread.y (yylex): Added SIGNED, LONG, SHORT, and INT keywords. - [typename]: Created. - [typebase]: Added rules for LONG, LONG INT, SHORT, SHORT INT, - SIGNED name, and UNSIGNED name (a good approximation of ansi - standard). - - * Makefile: Included .c.o rule to avoid sun's make from throwing - any curves at us. - - * blockframe.c: Included - - * command.c (lookup_cmd): Clear out trailing whitespace. - - * command.c (lookup_cmd_1): Changed malloc to alloca. - -Fri May 12 12:13:12 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * printcmd.c (print_frame_args): Only print nameless args when you - know how many args there are supposed to be and when you've - printed fewer than them. Don't print nameless args between - printed args. - - * symtab.c (make_symbol_completion_function): Fixed typo (= ==> - ==). - - * remote.c (remote_open): ifdef'd out siginterrupt call by #ifndef - NO_SIGINTERRUPT. - * m-umax.h: Defined NO_SIGINTERRUPT. - - * expread.y [ptype, array_mod, func_mod, direct_abs_decl, - abs_decl]: Added rules for parsing and creating arbitrarily - strange types for casts and sizeofs. - - * symtab.c, symtab.h (create_array_type): Created. Some minor - misfeatures; see comments for details (main one being that you - might end up creating two arrays when you only needed one). - -Thu May 11 13:11:49 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * valops.c (value_zero): Add an argument for type of lval. - * eval.c (evaluate_subexp_for_address): Take address properly in - the avoid side affects case (ie. keep track of whether we have an - lval in memory and we can take the address). - (evaluate_subexp): Set the lval type of expressions created with - value_zero properley. - - * valops.c, value.h (value_zero): Created--will return a value of - any type with contents filled with zero. - * symtab.c, symtab.h (lookup_struct_elt_type): Created. - * eval.c (evaluate_subexp): Modified to not read memory when - called with EVAL_AVOID_SIDE_EFFECTS. - - * Makefile: Moved dbxread.c ahead of coffread.c in the list of - source files. - -Wed May 10 11:29:19 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * munch: Make sure that sysv version substitutes for the whole - line. - - * symtab.h: Created an enum misc_function_type to hold the type of - the misc function being recorded. - * dbxread.c (record_misc_function): Branched on dbx symbols to - decide which type to assign to a misc function. - * coffread.c (record_misc_function): Always assign type unknown. - * expread.y [variable]: Now tests based on new values. - -Tue May 9 13:03:54 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * symtab.c: Changed inclusion of (doesn't work on - SYSV) to declaration of index. - - * Makefile: Changed last couple of READLINE_FLAGS SYSV_DEFINE - - * source.c ({forward, reverse}_search_command): Made a default - search file similar to for the list command. - -Mon May 8 18:07:51 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * printcmd.c (print_frame_args): If we don't know how many - arguments there are to this function, don't print the nameless - arguments. We don't know enough to find them. - - * printcmd.c (print_frame_args): Call print_frame_nameless_args - with proper arguments (start & end as offsets from addr). - - * dbxread.c (read_addl_syms): Removed cases to deal with global - symbols; this should all be done in scan_global_symbols. - -Sun May 7 11:36:23 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * Makefile: Added copying.awk to ${OTHERS}. - -Fri May 5 16:49:01 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * valprint.c (type_print_varspec_prefix): Don't pass - passed_a_pointer onto children. - - * valprint.c (type_print_varspec_suffix): Print "array of" with - whatever the "of" is after tha array brackets. - - * valprint.c (type_print_varspec_{prefix,suffix}): Arrange to - parenthesisze pointers to arrays as well as pointers to other - objects. - - * valprint.c (type_print_varspec_suffix): Make sure to print - subscripts of multi-dimensional arrays in the right order. - - * infcmd.c (run_command): Fixed improper usages of variables - within remote debugging branch. - - * Makefile: Added Convex.notes to the list of extra files to carry - around. - - * dbxread.c (symbol_file_command): Made use of alloca or malloc - dependent on macro define. - -Thu May 4 15:47:04 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * Makefile: Changed READLINE_FLAGS to SYSV_DEFINE and called munch - with it also. - * munch: Check first argument for -DSYSV and be looser about - picking up init routines if you find it. - - * coffread.c: Made fclose be of type int. - - * breakpoint.c (_initialize_breakpoint): Put "unset" into class - alias. - -Wed May 3 14:09:12 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * m-sparc.h [STACK_END_ADDR]: Parameterized off of - machine/vmparam.h (as per John Gilmore's suggestion). - - * blockframe.c (get_prev_frame_info): Changed this function back - to checking frameless invocation first before checking frame - chain. This means that a backtrace up from start will produce the - wrong value, but that a backtrace from a frameless function called - in main will show up correctly. - - * breakpoint.c (_initialize_breakpoint): Added entry in help for - delete that indicates that unset is an alias for it. - - * main.c (symbol_completion_function): Modified recognition of - being within a single command. - -Tue May 2 15:13:45 1989 Randy Smith (randy at gnu) - - * expread.y [variable]: Add some parens to get checking of the - misc function vector right. - -Mon May 1 13:07:03 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * default-dep.c (core_file_command): Made reg_offset unsigned. - - * default-dep.c (core_file_command): Improved error messages for - reading in registers. - - * expread.y: Allowed a BLOCKNAME to be ok for a variable name (as - per C syntax). - - * dbxread.c (psymtab_to_symtab): Flushed stdout after printing - starting message about reading in symbols. - - * printcmd.c (print_frame_args): Switched starting place for - printing of frameless args to be sizeof int above last real arg - printed. - - * printcmd.c (print_frame_args): Modified final call to - print_nameless_args to not use frame slots used array if none had - been used. - - * infrun.c (wait_for_inferior): Take FUNCTION_START_OFFSET into - account when dealing with comparison of pc values to function - addresses. - - * Makefile: Added note about compiling gdb on a Vax running 4.3. - -Sun Apr 30 12:59:46 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * command.c (lookup_cmd): Got correct error message on bad - command. - - * m-sun3.h [ABOUT_TO_RETURN]: Modified to allow any of the return - instructions, including trapv and return from interupt. - - * command.c (lookup_cmd): If a command is found, use it's values - for error reporting and determination of needed subcommands. - - * command.c (lookup_cmd): Use null string for error if cmdtype is - null; pass *line to error instead of **. - - * command.c (lookup_cmd_1): End of command marked by anything but - alpha numeric or '-'. Included ctype.h. - -Fri Apr 28 18:30:49 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * source.c (select_source_symtab): Kept line number from ever - being less than 1 in main decode. - -Wed Apr 26 13:03:20 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * default-dep.c (core_file_command): Fixed typo. - - * utils.c (fprintf_filtered): Don't use return value from - numchars. - - * main.c, command.c (complete_on_cmdlist): Moved function to - command.c. - - * command.c (lookup_cmd): Modified to use my new routine. Old - version is still there, ifdef'd out. - - * command.c, command.h (lookup_cmd_1): Added a routine to do all - of the work of lookup_cmd with no error reporting and full return - of information garnered in search. - -Tue Apr 25 12:37:54 1989 Randall Smith (randy at gluteus.ai.mit.edu) - - * breakpoint.c (_initialize_breakpoint): Change "delete - breakpionts" to be in class alias and not have the abbrev flag - set. - - * main.c (symbol_completion_function): Fix to correctly complete - things that correspond to multiword aliases. - - * main.c (complete_on_cmdlist): Don't complete on something if it - isn't a command or prefix (ie. if it's just a help topic). - - * main.c (symbol_completion_function): Set list index to be 0 if - creating a list with just one element. - - * main.c (complete_on_cmdlist): Don't allow things with - abbrev_flag set to be completion values. - (symbol_completion_function): Don't accept an exact match if the - abbrev flag is set. - - * dbxread.c (read_type): Fixed typo in comparision to check if - type number existed. - - * dbxread.c (read_type): Made sure to only call dbx_lookup_type on - typenums if typenums were not -1. - -Mon Apr 24 17:52:12 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * symtab.c: Added strings.h as an include file. - -Fri Apr 21 15:28:38 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * symtab.c (lookup_partial_symtab): Changed to only return a match - if the name match is exact (which is what I want in all cases in - which this is currently used. - -Thu Apr 20 11:12:34 1989 Randall Smith (randy at gluteus.ai.mit.edu) - - * m-isi.h [REGISTER_U_ADDR]: Installed new version from net. - * default-dep.c: Deleted inclusion of fcntl.h; apparently not - necessary. - * Makefile: Added comment about compiling on isi under 4.3. - - * breakpoint.c (break_command_1): Only give decode_line_1 the - default_breakpoint_defaults if there's nothing better (ie. make - the default be off of the current_source notes if at all - possible). - - * blockframe.c (get_prev_frame_info): Clean up comments and - delete code ifdefed out around FRAMELESS_FUNCTION_INVOCATION test. - - * remote.c: Added a "?" message to protocol. - (remote_open): Used at startup. - (putpkt): Read whatever garbage comes over the line until we see a - '+' (ie. don't treat garbage as a timeout). - - * valops.c (call_function): Eliminated no longer appropriate - comment. - - * infrun.c (wait_for_inferior): Changed several convex conditional - compilations to be conditional on CANNOT_EXECUTE_STACK. - -Wed Apr 19 10:18:17 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * printcmd.c (print_frame_args): Added code to attempt to deal - with arguments that are bigger than an int. - - Continuation of Convex/Fortran changes: - * printcmd.c (print_scalar_formatted): Added leading zeros to - printing of large integers. - (address_info, print_frame_args): Added code to deal with - LOC_REF_ARG. - (print_nameless_args): Allow param file to specify a routine with - which to print typeless integers. - (printf_command): Deal with long long values well. - * stack.c (print_frame_arg_vars): Change to deal with LOC_REF_ARG. - * symmisc.c (print_symbol): Change to deal with LOC_REF_ARG. - * symseg.h: Added LOC_REF_ARG to enum address_class. - * symtab.c (lookup_block_symbol): Changed to deal with - LOC_REF_ARG. - * valarith.c (value_subscripted_rvalue): Created. - (value_subscript): Used above when app. - (value_less, value_equal): Change to cast to (char *) before doing - comparison, for machines where that casting does something. - * valops.c (call_function): Setup to deal with machines where you - cannot execute code on the stack segment. - * valprint.c (val_print): Make sure that array element size isn't - zero before printing. Set address of default array to address of - first element. Put in a couple of int cast. Removed some convex - specific code. Added check for endianness of machine in case of a - packed structure. Added code for printing typeless integers and - for LONG LONG's. - (set_maximum_command): Change to use parse_and_eval_address to get - argument (so can use expressions there). - * values.c (value_of_internalvar, set_internalvar_component, - set_internalvar, convenience_info): Add in hooks for trapped - internal vars. - (unpack_long): Deal with LONG_LONG. - (value_field): Remove LONGEST cast. - (using_struct_return): Fixed typo ENUM ==> UNION. - * xgdb.c (_initialize_xgdb): Make sure that specify_exec_file_hook - is not called unless we are setting up a windowing environ. - -Tue Apr 18 13:43:37 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - Various changes involved in 1) getting gdb to work on the convex, - and 2) Getting gdb to work with fortran (due to convex!csmith): - * convex-dep.c, convex-opcode.h, m-convex.h, convex-pinsn.c: - Created (or replaced with new files). - * Makefile: Add convex dependent files. Changed default flags to - gnu malloc to be CFLAGS. - * config.gdb: Added convex to list of machines. - * core.c (files_info): Added a FILES_INFO_HOOK to be used if - defined. - (xfer_core_file): Conditionalized compilation of xfer_core_file on - the macro XFER_CORE_FILE. - * coffread.c (record_misc_function): Made sure it zerod type field - (which is now being used; see next). - * dbxread.c: Included some convex dependent include files. - (copy_pending, fix_common_blocks): Created. - [STAB_REG_REGNUM, BELIEVE_PCC_PROMOTION]: Created default values; - may be overridden in m-*.h. - Included data structures for keeping track of common blocks. - (dbx_alloc_type): Modified; if called with negative 1's will - create a type without putting it into the type vector. - (read_dbx_symtab, read_addl_syms): Modified calls to - record_misc_function to include the new information. - (symbol_file_command, psymtab_to_symtab, add_file_command): - Modified reading in of string table to adapt to machines which - *don't* store the size of the string table in the first four bytes - of the string table. - (read_dbx_symtab, scan_file_globals, read_ofile_symtab, - read_addl_syms): Modified assignment of namestring to accept null - index into symtab as ok. - (read_addl_syms): Modified readin of a new object file to fiddle - with common blocks correctly. - (process_one_symbol): Fixed incorrect comment about convex. Get - symbols local to a lexical context from correct spot on a per - machine basis. Catch a bug in pcc which occaisionally puts an SO - where there should be an SOL. Seperate sections for N_BCOMM & - N_ECOMM. - (define_symbol): Ignore symbols with no ":". Use - STAB_REG_TO_REGNUM. Added support for function args calling by - reference. - (read_type): Only read type number if one is there. Remove old - (#if 0'd out) array code. - (read_array_type): Added code for dealing with adjustable (by - parameter) arrays half-heartedly. - (read_enum_type): Allow a ',' to end a list of values. - (read_range_type): Added code to check for long long. - * expread.y: Modified to use LONGEST instead of long where - necessary. Modified to use a default type of int for objects that - weren't in text space. - * findvar.c (locate_var_value, read_var_value): Modified to deal - with args passed by reference. - * inflow.c (create_inferior): Used CREATE_INFERIOR_HOOK if it - exists. - * infrun.c (attach_program): Run terminal inferior when attaching. - (wait_for_inferior): Removed several convex dependencies. - * main.c (float_handler): Created. - Made whatever signal indicates a stop configurable (via macro - STOP_SIGNAL). - (main): Setup use of above as a signal handler. Added check for - "-nw" in args already processed. - (command_line_input): SIGTSTP ==>STOP_SIGNAL. - - * expread.y: Added token BLOCKNAME to remove reduce/reduce - conflict. - * Makefile: Change message to reflect new grammar. - -Mon Apr 17 13:24:59 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * printcmd.c (compare_ints): Created. - (print_frame_args): Modified to always print arguments in the - order in which they were found in the symbol table. Figure out - what apots are missing on the fly. - - * stack.c (up_command): Error if no inferior or core file. - - * m-i386.h, m-symmetry.h [FRAMELESS_FUNCTION_INVOCATION]: Created; - same as m68k. - - * dbxread.c (define_symbol): Changed "desc==0" test to - "processing_gcc_compilation", which is the correct way to do it. - -Sat Apr 15 17:18:38 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * expread.y: Added precedence rules for arglists, ?:, and sizeof - to eliminate some shift-reduce conflicts. - * Makefile: Modified "Expect" message to conform to new results. - -Thu Apr 13 12:29:26 1989 Randall Smith (randy at plantaris.ai.mit.edu) - - * inflow.c (terminal_init_inferior): Fixed typo in recent diff - installation; TIOGETC ==> TIOCGETC. - - * m-vax.h, m-sun2.h, m-sun3.h, m-sparc.h, m-hp*.h, m-isi.h, - m-news.h [FRAMELESS_FUNCTION_INVOCATION]: Created macro with - appropriate definition. - -Wed Apr 12 15:30:29 1989 Randall Smith (randy at plantaris.ai.mit.edu) - - * blockframe.c (get_prev_frame_info): Added in a macro to specify - when a "frame" is called without a frame pointer being setup. - - * Makefile [clean]: Made sure to delete gnu malloc if it was being - used. - -Mon Apr 10 12:43:49 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * dbxread.c (process_one_symbol): Reset within_function to 0 after - last RBRAC of a function. - - * dbxread.c (read_struct_type): Changed check for filling in of - TYPE_MAIN_VARIANT of type. - - * inflow.c (create_inferior): Conditionalized fork so that it - would be used if USG was defined and HAVE_VFORK was not defined. - - * defs.h: Added comment about enum command_class element - class_alias. - - * dbxread.c (process_one_symbol): Fixed a typo with interesting - implications for associative processing in the brain (':' ==> 'c'). - - * sparc-dep.c (isabranch): Changed name to isannulled, modified to - deal with coprocessor branches, and improved comment. - (single_step): Changed to trap at npc + 4 instead of pc +8 on - annulled branches. Changed name in call to isabranch as above. - - * m-sun4os4.h (STACK_END_ADDRESS): Changed it to 0xf8000000 under - os 4.0. - -Sat Apr 8 17:04:07 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * dbxread.c (process_one_symbol): In the case N_FUN or N_FNAME the - value being refered to is sometimes just a text segment variable. - Catch this case. - - * infrun.c (wait_for_inferior), breakpoint.c - (breakpoint_stop_status): Move the selection of the frame to - inside breakpoint_stop_status so that the frame only gets selected - (and the symbols potentially read in) if the symbols are needed. - - * symtab.c (find_pc_psymbol): Fixed minor misthough (pc >= - fucntion start, not >). - - * breakpoint.c (_initialize_breakpoint): Change "delete" internal - help entry to simply refer to it being a prefix command (since the - list of subcommands is right there on a "help delete"). - -Fri Apr 7 15:22:18 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * blockframe.c (find_pc_partial_function): Created; figures out - what function pc is in (name and address) without reading in any - new symbols. - * symtab.h: Added decl for above. - * infrun.c (wait_for_inferior): Used instead of - find_pc_function_start. - * stack.c (print_frame_info): Used instead of hand coding for same - thing. - - * dbxread.c (psymtab_to_symtab): No longer patch readin pst's out - of the partial_symtab_list; need them there for some checks. - * blockframe.c (block_for_pc), source.c (select_source_symtab), - symtab.c (lookup_symbol, find_pc_symtab, list_symbols): Made extra - sure not to call psymtab_to_symtab with ->readin == 1, since these - psymtab now stay on the list. - * symtab.c (sources_info): Now distinguishes between psymtabs with - readin set and those with it not set. - - * symtab.c (lookup_symtab): Added check through partial symtabs - for name with .c appended. - - * source.c (select_source_symtab): Changed semantics a little so - that the argument means something. - * source.c (list_command), symtab.c (decode_line_1): Changed call - to select_source_symtab to match new conventions. - - * dbxread.c (add_file_command): This command no longer selects a - symbol table to list from. - - * infrun.c (wait_for_inferior): Only call find_pc_function (to - find out if we have debugging symbols for a function and hence if - we should step over or into it) if we are doing a "step". - -Thu Apr 6 12:42:28 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * main.c (command_line_input): Added a local buffer and only - copied information into the global main.c buffer when it is - appropriate for it to be saved (and repeated). - (dont_repeat): Only nail line when we are reading from stdin - (otherwise null lines won't repeat and what's in line needs to be - saved). - (read_command_lines): Fixed typo; you don't what to repeat when - reading command lines from the input stream unless it's standard - input. - - John Gilmore's (gnu@toad.com) mods for USG gdb: - * inflow.c: Removed inclusion of sys/user.h; no longer necessary. - (, terminal_init_inferior, terminal_inferior, terminal_ours_1, - term_status_command, _initialize_inflow) Seperated out declaration - and usage of terminal mode structures based on the existence of - the individual ioctls. - * utils.c (request_quit): Restore signal handler under USG. If - running under USG initialize sys_siglist at run time (too much - variation between systems). - -Wed Apr 5 13:47:24 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - John Gilmore's (gnu@toad.com) mods for USG gdb: - * default-dep.c: Moved include of sys/user.h to after include of - a.out.h. - (store_inferior_registers): Fixed error message. - (core_file_command): Improved error messages from reading in of - u area in core file. Changed calculation of offset of registers - to account for some machines putting it in as an offset rather - than an absolute address. Changed error messages for reading of - registers from core file. - - * coffread.c (read_file_hdr): Added final check for BADMAG macro - to use if couldn't recognize magic number. - * Makefile: Added explicit directions for alloca addition. - Included alloca.c in list of possible library files. Cleaned up - possible library usage. Included additional information on gcc - and include files. - - * source.c, remote.c, inflow.c, dbxread.c, core.c, coffread.c: - Changed include of sys/fcntl.h to an include of fcntl.h (as per - posix; presumably this will break fewer machines. I hopw). - * README: Added a pointer to comments at top of Makefile. - * Makefile: Added a comment about machines which need fcntl.h in - sys. - -Tue Apr 4 11:29:04 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * valprint.c (set_prettyprint_command, set_unionprint_command, - format_info): Created. - (_initialize_valprint): Added to lists of commands. - - * gdb.texinfo [Backtrace]: Added a section describing the format - if symbols have not yet been read in. - - * valprint.c (val_print): Added code to prettyprint structures if - "prettyprint" is set and only to print unions below the top level - if "unionprint" is set. - - * infcmd.c (registers_info), valprint.c (value_print, val_print): - Added argument to call to val_print indicating deptch of recursion. - - * symtab.[ch] (find_pc_psymbol): Created; finds static function - psymbol with value nearest to but under value passed. - * stack.c (print_frame_info): Used above to make sure I have best - fit to pc value. - - * symseg.h (struct partial_symbol): Added value field. - * dbxread.c (read_dbx_symtab): Set value field for partial symbols - saved (so that we can lookup static symbols). - - * symtab.[ch] (find_pc_symtab): Changed to external. - * stack.c (select_frame): Call above to make sure that symbols for - a selected frame is readin. - -Mon Apr 3 12:48:16 1989 Randall Smith (randy at plantaris.ai.mit.edu) - - * stack.c (print_frame_info): Modified to only print out full - stack frame info on symbols whose tables have been read in. - * symtab.c, symtab.h (find_pc_psymtab): Made function external; - above needed it. - - * main.c (,set_verbose_command, initialize_main): Created a - variable "info_verbose" which says to talk it up in various and - sundry places. Added command to set this variable. - * gdb.texinfo (GDB Output): Added documentation on "set verbose" - and changed the name of the "Screen Output" section to "GDB - Output". - * dbxread.c (psymtab_to_symtab): Added information message about - symbol readin. Conditionalized on above. - - * dbxread.c (define_symbol): Made an "i" constant be of class - LOC_CONST and an "r" constant be of class LOC_CONST_BYTES. - - * README: Made a note about modifications which may be necessary - to the manual for this version of gdb. - - * blockframe.c (get_prev_frame_info): Now we get saved address and - check for validity before we check for leafism. This means that - we will catch the fact that we are in start, but we will miss any - fns that start calls without an fp. This should be fine. - - * m-*.h (FRAME_CHAIN): Modified to return 0 if we are in start. - This is usually a test for within the first object file. - * m-sparc.h (FRAME_CHAIN): The test here is simply if the fp saved - off the the start sp is 0. - - * blockframe.c (get_prev_frame_info): Removed check to see if we - were in start. Screws up sparc. - - * m-sparc.h (FRAME_FIND_SAVED_REGISTERS): Changed test for dummy - frame to not need frame to be innermost. - - * gdb.texinfo: Added section on frameless invocations of functions - and when gdb can and can't deal with this. - - * stack.c (frame_info): Disallowed call if no inferior or core - file; fails gracefully if truely bad stack specfication has been - given (ie. parse_frame_specification returns 0). - -Fri Mar 31 13:59:33 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * infrun.c (normal_stop): Changed references to "unset-env" to - "delete env". - - * infcmd.c (_initialize_infcmd): Change reference to set-args in - help run to "set args". - - * remote.c (getpkt): Allow immediate quit when reading from - device; it could be hung. - - * coffread.c (process_coff_symbol): Modify handling of REG - parameter symbols. - -Thu Mar 30 15:27:23 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * dbxread.c (symbol_file_command): Use malloc to allocate the - space for the string table in symbol_file_command (and setup a - cleanup for this). This allows a more graceful error failure if - there isn't any memory availible (and probably allows more memory - to be avail, depending on the machine). - - Additional mods for handling GNU C++ (from Tiemann): - * dbxread.c (read_type): Added case for '#' type (method type, I - believe). - (read_struct_type): If type code is undefined, make the main - variant for the type be itself. Allow recognition of bad format - in reading of structure fields. - * eval.c (evaluate_subexp): Modify evaluation of a member of a - structure and pointer to same to make sure that the syntax is - being used correctly and that the member is being accessed correctly. - * symseg.h: Added TYPE_CODE_METHOD to enum type_code. Add a - pointer to an array of argument types to the type structure. - * symtab.c (lookout_method_type, smash_to_method_type): Created. - * symtab.h (TYPE_ARG_TYPES): Created. - * valops.c (call_function): Modified handling of methods to be the - same as handling of functions; no longer check for members. - * valprint.c (val_print, type_print_varspec_{prefix,suffix}, - type_print_base): Added code to print method args correctly. - * values.c (value_virtual_fn_field): Modify access to virtual - function table. - -Wed Mar 29 13:19:34 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * findvar.c: Special cases for REGISTER_WINDOWS: 1) Return 0 if we - are the innermost frame, and 2) return the next frame in's value - if the SP is being looked for. - - * blockframe.c (get_next_frame): Created; returns the next (inner) - frame of the called frame. - * frame.h: Extern delcaration for above. - - * main.c (command_line_input): Stick null at end before doing - history expansion. - -Tue Mar 28 17:35:50 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * dbxread.c (read_dbx_symtab): Added namestring assignment to - N_DATA/BSS/ABS case. Sigh. - -Sat Mar 25 17:49:07 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * expread.y: Defined YYDEBUG. - -Fri Mar 24 20:46:55 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * symtab.c (make_symbol_completion_list): Completely rewrote to - never call psymtab_to_symtab, to do a correct search (no - duplicates) through the visible symbols, and to include structure - and union fields in the things that it can match. - -Thu Mar 23 15:27:44 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * dbxread.c (dbx_create_type): Created; allocates and inits space - for a type without putting it on the type vector lists. - (dbx_alloc_type): Uses above. - - * Makefile: xgdb.o now produced by default rules for .o.c. - -Fri Mar 17 14:27:50 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * infrun.c: Fixed up inclusion of aouthdr.h on UMAX_PTRACE. - - * Makefile, config.gdb: Added hp300bsd to potential - configurations. - * hp300bsd-dep.c, m-hp300bsd.h: Created. - - * infrun.c (wait_for_inferior): Rewrote to do no access to - inferior until we make sure it's still there. - - * inflow.c (inferior_died): Added a select to force the selected - frame to null when inferior dies. - - * dbxread.c (symbol_file_command): free and zero symfile when - discarding symbols. - - * core.c (xfer_core_file): Extended and cleaned up logic in - interpeting memory address. - - * core.c (xfer_core_file): Extended opening comment. - -Thu Mar 16 15:39:42 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * coffread.c (symbol_file_command): Free symfile name when freeing - contents. - - * blockframe.c (get_prev_frame_info): Added to fatal error message - to indicate that it should never happen. - - * stack.c (frame_info): Printed out value of "saved" sp seperately - to call attention to the fact that it isn't stored in memory - anywhere; the actual previous frames address is printed. - - * m-sparc.h (FRAME_FIND_SAVED_REGS): Set address of sp saved in - frame to value of fp (rather than value of sp in current frame). - - * expread.y: Allow "unsigned" as a type itself, as well as a type - modifier. - - * coffread.c: Added declaration for fclose - -Fri Mar 10 17:22:31 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * main.c (command_line_input): Checked for -1 return from - readline; indicates EOF. - -Fri Mar 3 00:31:27 1989 Randall Smith (randy at gluteus.ai.mit.edu) - - * remote.c (remote_open): Cast return from signal to (void (*)) to - avoid problems on machines where the return type of signal is (int - (*)). - - * Makefile: Removed deletion of version control from it (users - will need it for their changes). - -Thu Mar 2 15:32:21 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * symmetry-dep.c (print_1167_regs): Print out effective doubles on - even number regs. - (fetch_inferior_registers): Get the floating point regs also. - - * xgdb.c (do_command): Copied command before calling execute - command (so that execute_command wouldn't write into text space). - - * copying.awk: Created (will produce copying.c as output when - given COPYING as input). - * Makefile: Used above to create copying.c. - * main.c: Took out info_warranty and info_copying. - - * *.*: Changed copyright notice to use new GNU General Public - License (includes necessary changes to manual). - - * xgdb.c (create_text_widget): Created text_widget before I create - the source and sink. - (print_prompt): Added fflush (stdout). - - * Makefile: Added -lXmu to the compilation line for xgdb. Left - the old one there incase people still had R2. - - * README: Added note about -gg format. - - * remote.c (getpkt): Fixed typo; && ==> &. - - * Makefile: Added new variable READLINE_FLAGS so that I could - force compilation of readline.c and history.c with -DSYSV on - system V machines. Mentioned in Makefile comments at top. - -Wed Mar 1 17:01:01 1989 Randall Smith (randy at gluteus.ai.mit.edu) - - * hp9k320-dep.c (store_inferior_registers): Fixed typo. - -Fri Feb 24 14:58:45 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * hp9k320-dep.c (store_inferior_registers, - fetch_inferior_registers): Added support for remote debugging. - - * remote.c (remote_timer): Created. - (remote_open, readchar): Setup to timeout reads if they take - longer than "timeout". This allows one to debug how long such - things take. - (putpkt): Modified to print a debugging message (if such things - are enabled) each time it resends a packet. - (getpkt): Modified to make the variable CSUM unsigned and read it - CSUM with an & 0xff (presumably to deal with poor sign extension - on some machines). Also made c1 and c2 unsigned. - (remote_wait): Changed buffer to unsigned status. - (remote_store_registers, remote_write_bytes): Puts a null byte at - the end of the control string. - - * infcmd.c (attach_command, detach_command, _initialize_infcmd): - Made attach_command and detach_command always availible, but - modified them to only allow device file attaches if ATTACH_DETACH - is not defined. - - * gdb.texinfo: Added cross reference from attach command to remote - debugging. - -Thu Feb 23 12:37:59 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * remote.c (remote_close): Created to close the remote connection - and set the remote_debugging flag to 0. - * infcmd.c (detach_command): Now calls the above when appropriate. - - * gdb.texinfo: Removed references to the ``Distribution'' section - in the copyright. - - * main.c, utils.c (ISATTY): Created default defintions of this - macro which use isatty and fileno. - * utils.c (fprintf_filtered, print_spaces_filtered), main.c - (command_loop, command_line_input): Used this macro. - * m-news.h: Created a definition to override this one. - - * utils.c (fprintf_filtered): Made line_size static (clueless). - - * utils.c (fprintf_filtered): Changed max length of line printed - to be 255 chars or twice the format length. - - * symmetry-dep.c, m-symmetry: Fixed typo (^L ==> ). - - * printcmd.c (do_examine): Fixed typo (\n ==> \t). - -Wed Feb 22 16:00:33 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - Contributed by Jay Vosburgh (jay@mentor.cc.purdue.edu) - * m-symmetry.h, symmetry-dep.c: Created. - * Makefile: Added above in appropriate lists. - * config.gdb: Added "symmetry" target. - - * utils.c (prompt_for_continue): Zero'd chars_printed also. - - * utils.c (fprintf_filtered): Call prompt for continue instead of - doing it yourself. - - * dbxread.c (read_dbx_symtab): Added code to conditionalize what - symbol type holds to "x.o" or "-lx" symbol that indicates the - beginning of a new file. - -Tue Feb 21 16:22:13 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * gdb.texinfo: Deleted @ignore block at end of file. - - * findvar.c, stack.c: Changed comments that refered to "frame - address" to "frame id". - - * findvar.c (locate_var_value): Modified so that taking the - address of an array generates an object whose type is a pointer to - the elements of the array. - -Sat Feb 18 16:35:14 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * gdb.texinfo: Removed reference to "!" as a shell escape - character. Added a section on controling screen output - (pagination); changing "Input" section to "User Interface" - section. Changed many inappropriate subsubsection nodes into - subsections nodes (in the readline and history expansion - sections). - -Fri Feb 17 11:10:54 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * utils.c (set_screensize_command): Created. - (_initialize_utils): Added above to setlist. - - * main.c (main): Added check to see if ~/.gdbinit and .gdbinit - were the same file; only one gets read if so. Had to include - sys/stat.h for this. - - * valprint.c (type_print_base): Changed calls to print_spaces to - print_spaces_filtered. - - * main.c (command_line_input): Chaned test for command line - editing to check for stdin and isatty. - - * main.c (command_loop): Call reinitialize_more_filter before each - command (if reading from stdin and it's a tty). - utils.c (initialize_more_filter): Changed name to - reinitialize_more_filter; killed arguments. - utils.c (_initialize_utils): Created; initialized lines_per_page - and chars_per_line here. - - * utils.c (fprintf_filtered): Removed printing of "\\\n" after - printing linesize - 1 chars; assume that the screen display will - take care of that. Still watching that overflow. - - * main.c: Created the global variables linesize and pagesize to - describe the number of chars per line and lines per page. - -Thu Feb 16 17:27:43 1989 Randall Smith (randy at gluteus.ai.mit.edu) - - * printcmd.c (do_examine, print_scalar_formatted, print_address, - whatis_command, do_one_display, ptype_command), valprint.c - (value_print, val_print, type_print_method_args, type_print_1, - type_print_derivation_info, type_print_varspec_suffix, - type_print_base), breakpoint.c (breakpoints_info, breakpoint_1), - values.c (history_info), main.c (editing_info, warranty_info, - copying_info), infcmd.c (registers_info), inflow.c - (term_status_command), infrun.c (signals_info), stack.c - (backtrace_command, print_frame_info), symtab.c (list_symbols, - output_source_filename), command.c (help_cmd, help_list, - help_command_list): Replaced calls to printf, fprintf, and putc - with calls to [f]printf_filtered to handle more processing. - Killed local more emulations where I noticed them. - -Wed Feb 15 15:27:36 1989 Randall Smith (randy at gluteus.ai.mit.edu) - - * defs.h, utils.c (initialize_more_filter, fprintf_filtered, - printf_filtered): Created a printf that will also act as a more - filter, prompting the user for a whenever the page length - is overflowed. - - * symtab.c (list_symbols): Elminated some code inside of an #if 0. - -Tue Feb 14 11:11:24 1989 Randall Smith (randy at gluteus.ai.mit.edu) - - * Makefile: Turned off backup versions for this file; it changes - too often. - - * command.c (lookup_cmd, _initialize_command): Changed '!' so that - it was no longer a shell escape. "sh" must be used. - - * main.c (command_line_input, set_history_expansion, - initialize_main): Turned history expansion on, made it the - default, and only execute it if the first character in the line is - a '!'. - - * version.c, gdb.texinfo: Moved version to 3.2 (as usual, jumping - the gun some time before release). - - * gdb.texinfo: Added sections (adapted from Brian's notes) on - command line editing and history expansion. - - * main.c (set_command_editing, initialize_main): Modified name to - set_editing and modified command to "set editing". - - * Makefile: Put in dependencies for READLINEOBJS. - - * main.c (history_info, command_info): Combined into new command - info; deleted history_info. - (initialize_main): Deleted "info history" command; it was - interfering with the value history. - - * coffread.c (enter_linenos): Modified to do bit copy instead of - pointer dereference, since the clipper machine can't handle having - longs on short boundaries. - (read_file_hdr): Added code to get number of syms for clipper. - - * stack.c (return_command): Fixed method for checking when all of - the necessary frames had been popped. - - * dbxread.c (read_dbx_symtab (ADD_PSYMBOL_TO_LIST)): Fixed typo in - allocation length. - -Mon Feb 13 10:03:27 1989 Randall Smith (randy at gluteus.ai.mit.edu) - - * dbxread.c (read_dbx_symtab): Split assignment to namestring into - several different assignments (so that it wouldn't be done except - when it had to be). Shortened switches and duplicated code to - produce the lowest possible execution time. Commented (at top of - switch) which code I duplicated. - - * dbxread.c (read_dbx_symtab): Modified which variables were - register and deleted several variables which weren't used. Also - eliminated 'F' choice from subswitch, broke out strcmp's, reversed - compare on line 1986, and elminated test for !namestring[0]; it is - caught by following test for null index of ':'. - -Sun Feb 12 12:57:56 1989 Randall Smith (randy at plantaris.ai.mit.edu) - - * main.c (gdb_completer_word_break_characters): Turned \~ into ~. - -Sat Feb 11 15:39:06 1989 Randall Smith (randy at plantaris.ai.mit.edu) - - * symtab.c (find_pc_psymtab): Created; checks all psymtab's till - it finds pc. - (find_pc_symtab): Used; fatal error if psymtab found is readin - (should have been caught in symtab loop). - (lookup_symbol): Added check before scan through partial symtab - list for symbol name to be on the misc function vector (only if in - VAR_NAMESPACE). Also made sure that psymtab's weren't fooled with - if they had already been read in. - (list_symbols): Checked through misc_function_vector for matching - names if we were looking for functions. - (make_symbol_completion_list): Checked through - misc_function_vector for matching names. - * dbxread.c (read_dbx_symtab): Don't bother to do processing on - global function types; this will be taken care of by the - misc_function hack. - - * symtab.h: Modified comment on misc_function structure. - -Fri Feb 10 18:09:33 1989 Randall Smith (randy at plantaris.ai.mit.edu) - - * symseg.h, dbxread.c (read_dbx_symtab, init_psymbol_list, - start_psymtab, end_psymtab), coffread.c (_initialize_coff), - symtab.c (lookup_partial_symbol, list_symbols, - make_symbol_completion_list): Changed separate variables for - description of partial symbol allocation into a specific kind of - structure. - - (read_dbx_symtab, process_symbol_for_psymtab): Moved most of - process_symbol_for_psymtab up into read_dbx_symtab, moved a couple - of symbol types down to the ingore section, streamlined (I hope) - code some, modularized access to psymbol lists. - -Thu Feb 9 13:21:19 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * main.c (command_line_input): Made sure that it could recognize - newlines as indications to repeat the last line. - - * symtab.c (_initialize_symtab): Changed size of builtin_type_void - to be 1 for compatibility with gcc. - - * main.c (initialize_main): Made history_expansion the default - when gdb is compiled with HISTORY_EXPANSION. - - * readline.c, readline.h, history.c, history.h, general.h, - emacs_keymap.c, vi_keymap.c, keymaps.c, funmap.c: Made all of - these links to /gp/gnu/bash/* to keep them updated. - * main.c (initialize_main): Made default be command editing on. - -Wed Feb 8 13:32:04 1989 & Smith (randy at hobbes) - - * dbxread.c (read_dbx_symtab): Ignore N_BSLINE on first - readthrough. - - * Makefile: Removed convex-dep.c from list of distribution files. - -Tue Feb 7 14:06:25 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * main.c: Added command lists sethistlist and unsethistlist to - accesible command lists. - (parse_binary_operation): Created to parse a on/1/yes vs. off/0/no - spec. - (set_command_edit, set_history, set_history_expansion, - set_history_write, set_history_size, set_history_filename, - command_info, history_info): Created to allow users to control - various aspects of command line editing. - - * main.c (symbol_creation_function): Created. - (command_line_input, initialize_main): Added rest of stuff - necessary for calling bfox' command editing routines under - run-time control. - * Makefile: Included readline and history source files for command - editing; also made arrangements to make sure that the termcap - library was available. - * symtab.c (make_symbol_completion_list): Created. - -Mon Feb 6 16:25:25 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * main.c: Invented variables to control command editing. - command_editing_p, history_expansion_p, history_size, - write_history_p, history_filename. Initialized them to default - values in initialize_main. - - * infcmd.c (registers_info), infrun.c (signals_info), - * main.c (gdb_read_line): Changed name to command_line_input. - (readline): Changed name to gdb_readline; added second argument - indicating that the read value shouldn't be saved (via malloc). - * infcmd.c (registers_info), infrun.c (signals_info), main.c - (copying_info), symtab.c (output_source_filename, MORE, - list_symbols): Converted to use gdb_readline in place of - gdb_read_line. - - -Sun Feb 5 17:34:38 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * blockframe.c (get_frame_saved_regs): Removed macro expansion - that had accidentally been left in the code. - -Sat Feb 4 17:54:14 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * main.c (gdb_read_line, readline): Added function readline and - converted gdb_read_line to use it. This was a conversion to the - line at a time style of input, in preparation for full command - editing. - -Fri Feb 3 12:39:03 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * dbxread.c (read_dbx_symtab): Call end_psymtab at the end of - read_dbx_symtab if any psymtab still needs to be completed. - - * config.gdb, sun3-dep.c: Brought these into accord with the - actual sun2 status (no floating point period; sun3-dep.c unless - has os > 3.0). - * m-sun2os2.h: Deleted; not needed. - - * config.gdb: Added a couple of aliases for machines in the - script. - - * infrun.c: Added inclusion of aouthdr.h inside of #ifdef UMAX - because ptrace needs to know about the a.out header. - - * Makefile: Made dep.o depend on dep.c and config.status only. - - * expread.y: Added declarations of all of the new write_exp_elt - functions at the include section in the top. - - * Makefile: Added a YACC definition so that people can use bison - if they wish. - - * Makefile: Added rms' XGDB-README to the distribution. - - * Makefile: Added removal of init.o on a "make clean". - -Thu Feb 2 16:27:06 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * *-dep.c: Deleted definition of COFF_FORMAT if AOUTHDR was - defined since 1) We *may* (recent mail message) want to define - AOUTHDR under a basically BSD system, and 2) AOUTHDR is sometimes - a typedef in coff encapsulation setups. Also removed #define's of - AOUTHDR if AOUTHDR is already defined (inside of coff format). - * core.c, dbxread.c: Removed #define's of AOUTHDR if AOUTHDR is - already defined (inside of coff format). - -Tue Jan 31 12:56:01 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * GDB 3.1 released. - - * values.c (modify_field): Changed test for endianness to assign - to integer and reference character (so that all bits would be - defined). - -Mon Jan 30 11:41:21 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * news-dep.c: Deleted inclusion of fcntl.h; just duplicates stuff - found in sys/file.h. - - * i386-dep.c: Included default definition of N_SET_MAGIC for - COFF_FORMAT. - - * config.gdb: Added checks for several different operating - systems. - - * coffread.c (read_struct_type): Put in a flag variable so that - one could tell when you got to the end of a structure. - - * sun3-dep.c (core_file_command): Changed #ifdef based on SUNOS4 - to ifdef based on FPU. - - * infrun.c (restore_inferior_status): Changed error message to - "unable to restore previously selected frame". - - * dbxread.c (read_dbx_symtab): Used intermediate variable in error - message reporting a bad symbol type. (scan_file_globals, - read_ofile_symtab, read_addl_syms): Data type of "type" changed to - unsigned char (which is what it is). - * i386-dep.c: Removed define of COFF_FORMAT if AOUTHDR is defined. - Removed define of a_magic to magic (taken care of by N_MAGIC). - (core_file_command): Zero'd core_aouthdr instead of setting magic - to zero. - * i386-pinsn.c: Changed jcxz == jCcxz in jump table. - (putop): Added a case for 'C'. - (OP_J): Added code to handle possible masking of PC value on - certain kinds of data. - m-i386gas.h: Moved COFF_ENCAPSULATE to before inclusion of - m-i386.h and defined NAMES_HAVE_UNDERSCORE. - - * coffread.c (unrecrod_misc_function, read_coff_symtab): Added - symbol number on which error occured to error output. - -Fri Jan 27 11:55:04 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * Makefile: Removed init.c in make clean. Removed it without -f - and with leading - in make ?gdb. - -Thu Jan 26 15:08:03 1989 Randall Smith (randy at gluteus.ai.mit.edu) - - Changes to get it to work on gould NP1. - * dbxread.c (read_dbx_symtab): Included cases for N_NBDATA and - N_NBBSS. - (psymtab_to_symtab): Changed declaration of hdr to - DECLARE_FILE_HEADERS. Changed access to use STRING_TABLE_SIZE and - SYMBOL_TABLE_SIZE. - * gld-pinsn.c (findframe): Added declaration of framechain() as - FRAME_ADDR. - - * coffread.c (read_coff_symtab): Avoided treating typedefs as - external symbol definitions. - -Wed Jan 25 14:45:43 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * Makefile: Removed reference to alloca.c. If they need it, they - can pull alloca.o from the gnu-emacs directory. - - * version.c, gdb.texinfo: Updated version to 3.1 (jumping the gun - a bit so that I won't forget when I release). - - * m-sun2.h, m-sun2os2.h, m-sun3os4.h, config.gdb: Modified code so - that default includes new sun core, ptrace, and attach-detach. - Added defaults for sun 2 os 2. - - Modifications to reset stack limit back to what it used to be just - before exec. All mods inside of #ifdef SET_STACK_LIMIT_HUGE. - * main.c: Added global variable original_stack_limit. - (main): Set original_stack_limit to original stack limit. - * inflow.c: Added inclusion of necessary files and external - reference to original_stack_limit. - (create_inferior): Reset stack limit to original_stack_limit. - - * dbxread.c (read_dbx_symtab): Killed PROFILE_SYMBOLS ifdef. - - * sparc-dep.c (isabranch): Multiplied offset by 4 before adding it - to addr to get target. - - * Makefile: Added definition of SHELL to Makefile. - - * m-sun2os4.h: Added code to define NEW_SUN_PTRACE, NEW_SUN_CORE, - and ATTACH_DETACH. - * sun3-dep.c: Added code to avoid fp regs if we are on a sun2. - -Tue Jan 24 17:59:14 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * dbxread.c (read_array_type): Added function. - (read_type): Added call to above instead of inline code. - - * Makefile: Added ${GNU_MALLOC} to the list of dependencies for - the executables. - -Mon Jan 23 15:08:51 1989 Randall Smith (randy at plantaris.ai.mit.edu) - - * gdb.texinfo: Added paragraph to summary describing languages - with which gdb can be run. Also added descriptions of the - "info-methods" and "add-file" commands. - - * symseg.h: Commented a range type as having TYPE_TARGET_TYPE - pointing at the containing type for the range (often int). - * dbxread.c (read_range_type): Added code to do actual range types - if they are defined. Assumed that the length of a range type is - the length of the target type; this is a lie, but will do until - somebody gets back to me as to what these silly dbx symbols mean. - - * dbxread.c (read_range_type): Added code to be more picky about - recognizing builtins as range types, to treat types defined as - subranges of themselves to be subranges of int, and to recognize - the char type idiom from dbx as a special case. - -Sun Jan 22 01:00:13 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * m-vax.h: Removed definition of FUNCTION_HAS_FRAME_POINTER. - * blockframe.c (get_prev_frame_info): Removed default definition - and use of above. Instead conditionalized checking for leaf nodes - on FUNCTION_START_OFFSET (see comment in code). - -Sat Jan 21 16:59:19 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * dbxread.c (read_range_type): Fixed assumption that integer was - always type 1. - - * gdb.texinfo: Fixed spelling mistake and added a note in the - running section making it clear that users may invoke subroutines - directly from gdb. - - * blockframe.c: Setup a default definition for the macro - FUNCTION_HAS_FRAME_POINTER. - (get_prev_frame_info): Used this macro instead of checking - SKIP_PROLOGUE directly. - * m-vax.h: Overroad definition; all functions on the vax have - frame pointers. - -Fri Jan 20 12:25:35 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * core.c: Added default definition of N_MAGIC for COFF_FORMAT. - - * xgdb.c: Installed a fix to keep the thing from dying when there - isn't any frame selected. - - * core.c: Made a change for the UMAX system; needs a different - file included if using that core format. - - * Makefile: Deleted duplicate obstack.h in dbxread.c dependency. - - * munch: Modified (much simpler) to cover (I hope) all cases. - - * utils.c (save_cleanups, restore_cleanups): Added functions to - allow you to push and pop the chain of cleanups to be done. - * defs.h: Declared the new functions. - * main.c (catch_errors): Made sure that the only cleanups which - would be done were the ones put on the chain *after* the current - location. - - * m-*.h (FRAME_CHAIN_VALID): Removed check on pc in the current - frame being valid. - * blockframe.c (get_prev_frame_info): Made the assumption that if - a frame's pc value was within the first object file (presumed to - be /lib/crt0.o), that we shouldn't go any higher. - - * infrun.c (wait_for_inferior): Do *not* execute check for stop pc - at step_resume_break if we are proceeding over a breakpoint (ie. - if trap_expected != 0). - - * Makefile: Added -g to LDFLAGS. - - * m-news.h (POP_FRAME) Fixed typo. - - * printcmd.c (print_frame_args): Modified to print out register - params in order by .stabs entry, not by register number. - - * sparc-opcode.h: Changed declaration of (struct - arith_imm_fmt).simm to be signed (as per architecture manual). - * sparc-pinsn.c (fprint_addr1, print_insn): Forced a cast to an - int, so that we really would get signed behaivior (default for sun - cc is unsigned). - - * i386-dep.c (i386_get_frame_setup): Replace function with new - function provided by pace to fix bug in recognizing prologue. - -Thu Jan 19 11:01:22 1989 Randall Smith (randy at plantaris.ai.mit.edu) - - * infcmd.c (run_command): Changed error message to "Program not - restarted." - - * value.h: Changed "frame" field in value structure to be a - FRAME_ADDR (actually CORE_ADDR) so that it could survive across - calls. - - * m-sun.h (FRAME_FIND_SAVED_REGS): Fixed a typo. - - * value.h: Added lval: "lval_reg_frame_relative" to indicate a - register that must be interpeted relative to a frame. Added - single entry to value structure: "frame", used to indicate which - frame a relative regnum is relative to. - * findvar.c (value_from_register): Modified to correctly setup - these fields when needed. Deleted section to fiddle with last - register copied on little endian machine; multi register - structures will always occupy an integral number of registers. - (find_saved_register): Made extern. - * values.c (allocate_value, allocate_repeat_value): Zero frame - field on creation. - * valops.c (value_assign): Added case for lval_reg_frame_relative; - copy value out, modify it, and copy it back. Desclared - find_saved_register as being external. - * value.h: Removed addition of kludgy structure; thoroughly - commented file. - * values.c (free_value, free_all_values, clear_value_history, - set_internalvar, clear_internavars): Killed free_value. - -Wed Jan 18 20:09:39 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * value.h: Deleted struct partial_storage; left over from - yesterday. - - * findvar.c (value_from_register): Added code to create a value of - type lval_reg_partsaved if a value is in seperate registers and - saved in different places. - -Tue Jan 17 13:50:18 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * value.h: Added lval_reg_partsaved to enum lval_type and - commented enum lval_type. Commented value structure. - Added "struct partial_register_saved" to value struct; added - macros to deal with structure to value.h. - * values.c (free_value): Created; special cases lval_reg_partsaved - (which has a pointer to an array which also needs to be free). - (free_all_values, clear_value_history, set_internalvar, - clear_internalvars): Modified to use free_values. - - * m-sunos4.h: Changed name to sun3os4.h. - * m-sun2os4.h, m-sun4os4.h: Created. - * config.gdb: Added configuration entries for each of the above. - * Makefile: Added into correct lists. - - * Makefile: Added dependencies on a.out.encap.h. Made - a.out.encap.h dependent on a.out.gnu.h and dbxread.c dependent on - stab.gnu.h. - - * infrun.c, remote.c: Removed inclusion of any a.out.h files in - these files; they aren't needed. - - * README: Added comment about bug reporting and comment about - xgdb. - - * Makefile: Added note to HPUX dependent section warning about - problems if compiled with gcc and mentioning the need to add - -Ihp-include to CFLAGS if you compile on those systems. Added a - note about needing the GNU nm with compilers *of gdb* that use the - coff encapsulate feature also. * hp-include: Made symbolic link - over to /gp/gnu/binutils. - - * Makefile: Added TSOBS NTSOBS OBSTACK and REGEX to list of things - to delete in "make clean". Also changed "squeakyclean" target as - "realclean". - - * findvar.c (value_from_register): Added assignment of VALUE_LVAL - to be lval_memory when that is appropriate (original code didn't - bother because it assumed that it was working with a pre lval - memoried value). - - * expread.y (yylex): Changed to only return type THIS if the - symbol "$this" is defined in some block superior or equal to the - current expression context block. - -Mon Jan 16 13:56:44 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * m-*.h (FRAME_CHAIN_VALID): On machines which check the relation - of FRAME_SAVED_PC (thisframe) to first_object_file_end (all except - gould), make sure that the pc of the current frame also passes (in - case someone stops in _start). - - * findvar.c (value_of_register): Changed error message in case of - no inferior or core file. - - * infcmd.c (registers_info): Added a check for inferior or core - file; error message if not. - - * main.c (gdb_read_line): Modified to take prompt as argument and - output it to stdout. - * infcmd.c (registers_info, signals_info), main.c (command_loop, - read_command_lines, copying_info), symtab.c (decode_line_2, - output_source_filename, MORE, list_symbols): Changed calling - convention used to call gdb_read_line. - - * infcmd.c, infrun.c, main.c, symtab.c: Changed the name of the - function "read_line" to "gdb_read_line". - * breakpoint.c: Deleted external referenced to function - "read_line" (not needed by code). - -Fri Jan 13 12:22:05 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * i386-dep.c: Include a.out.encap.h if COFF_ENCAPSULATE. - (N_SET_MAGIC): Defined if not defined by include file. - (core_file_command): Used N_SET_MAGIC instead of assignment to - a_magic. - (exec_file_command): Stuck in a HEADER_SEEK_FD. - - * config.gdb: Added i386-dep.c as depfile for i386gas choice. - - * munch: Added -I. to cc to pick up things included by the param - file. - - * stab.gnu.def: Changed name to stab.def (stab.gnu.h needs this name). - * Makefile: Changed name here also. - * dbxread.c: Changed name of gnu-stab.h to stab.gnu.h. - - * gnu-stab.h: Changed name to stab.gnu.h. - * stab.gnu.def: Added as link to binutils. - * Makefile: Put both in in the distribution. - -Thu Jan 12 11:33:49 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * dbxread.c: Made which stab.h is included dependent on - COFF_ENCAPSULATE; either or "gnu-stab.h". - * Makefile: Included gnu-stab.h in the list of files to include in - the distribution. - * gnu-stab.h: Made a link to /gp/gnu/binutils/stab.h - - * Makefile: Included a.out.gnu.h and m-i386gas.h in list of - distribution files. - * m-i386gas.h: Changed to include m-i386.h and fiddle with it - instead of being a whole new file. - * a.out.gnu.h: Made a link to /gp/gnu/binutils/a.out.gnu.h. - - Chris Hanson's changes to gdb for hp Unix. - * Makefile: Modified comments on hpux. - * hp9k320-dep.c: #define'd WOPR & moved inclusion of signal.h - * inflow.c: Moved around declaratiosn of and - inside of USG depends and deleted all SYSV ifdef's - (use USG instead). - * munch: Modified to accept any number of spaces between the T and - the symbol name. - - Pace's changes to gdb to work with COFF_ENCAPSULATE (robotussin): - * config.gdb: Added i386gas to targets. - * default-dep.c: Include a.out.encap.h if COFF_ENCAPSULATE. - (N_SET_MAGIC): Defined if not defined by include file. - (core_file_command): Used N_SET_MAGIC instead of assignment to a_magic. - (exec_file_command): Stuck in a HEADER_SEEK_FD. - * infrun.c, remote.c: Added an include of a.out.encap.h if - COFF_ENCAPSULATE defined. This is commented out in these two - files, I presume because the definitions aren't used. - * m-i386gas.h: Created. - * dbxread.c: Included defintions for USG. - (READ_FILE_HEADERS): Now uses HEADER_SEEK_FD if it exists. - (symbol_file_command): Deleted use of HEADER_SEEK_FD. - * core.c: Deleted extra definition of COFF_FORMAT. - (N_MAGIC): Defined to be a_magic if not already defined. - (validate_files): USed N_MAGIC instead of reading a_magic. - -Wed Jan 11 12:51:00 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * remote.c: Upped PBUFSIZ. - (getpkt): Added zeroing of c inside loop in case of error retry. - - * dbxread.c (read_dbx_symtab, process_symbol_for_psymtab): Removed - code to not put stuff with debugging symbols in the misc function - list. Had been ifdef'd out. - - * gdb.texinfo: Added the fact that the return value for a function - is printed if you use return. - - * infrun.c (wait_for_inferior): Removed test in "Have we hit - step_resume_breakpoint" for sp values in proper orientation. Was - in there for recursive calls in functions without frame pointers - and it was screwing up calls to alloca. - - * dbxread.c: Added #ifdef COFF_ENCAPSULATE to include - a.out.encap.h. - (symbol_file_command): Do HEADER_SEEK_FD when defined. - * dbxread.c, core.c: Deleted #ifdef ROBOTUSSIN stuff. - * robotussin.h: Deleted local copy (was symlink). - * a.out.encap.h: Created symlink to - /gp/gnu/binutils/a.out.encap.h. - * Makefile: Removed robotussin.h and included a.out.encap.h in - list of files. - - * valprint.c (val_print, print_scalar_formatted): Changed default - precision of printing float value; now 6 for a float and 16 for a - double. - - * findvar.c (value_from_register): Added code to deal with the - case where a value is spread over several registers. Still don't - deal with the case when some registers are saved in memory and - some aren't. - -Tue Jan 10 17:04:04 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * xgdb.c (xgdb_create_window): Removed third arg (XtDepth) to - frameArgs. - - * infrun.c (handle_command): Error if signal number is less or - equal to 0 or greater or equal to NSIG or a signal number is not - provided. - - * command.c (lookup_cmd): Modified to not convert command section - of command line to lower case in place (in case it isn't a - subcommand, but an argument to a command). - -Fri Jan 6 17:57:34 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * dbxread.c: Changed "text area" to "data area" in comments on - N_SETV. - -Wed Jan 4 12:29:54 1989 Randall Smith (randy at gluteus.ai.mit.edu) - - * dbxread.c: Added definitions of gnu symbol types after inclusion - of a.out.h and stab.h. - -Mon Jan 2 20:38:31 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * eval.c (evaluate_subexp): Binary logical operations needed to - know type to determine whether second value should be evaluated. - Modified to discover type before binup_user_defined_p branch. - Also commented "enum noside". - - * Makefile: Changed invocations of munch to be "./munch". - - * gdb.texinfo: Updated to refer to current version of gdb with - January 1989 last update. - - * coffread.c (end_symtab): Zero context stack when finishing - lexical contexts. - (read_coff_symtab): error if context stack 0 in ".ef" else case. - - * m-*.h (FRAME_SAVED_PC): Changed name of argument from "frame" to - "FRAME" to avoid problems with replacement of "->frame" part of - macro. - - * i386-dep.c (i386_get_frame_setup): Added codestream_get() to - move codestream pointer up to the correct location in "subl $X, - %esp" case. - -Sun Jan 1 14:24:35 1989 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * valprint.c (val_print): Rewrote routine to print string pointed - to by char pointer; was producing incorrect results when print_max - was 0. - -Fri Dec 30 12:13:35 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * dbxread.c (read_dbx_symtab, process_symbol_for_psymtab): Put - everything on the misc function list. - - * Checkpointed distribution. - - * Makefile: Added expread.tab.c to the list of things slated for - distribution. - -Thu Dec 29 10:06:41 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * stack.c (set_backtrace_limit_command, backtrace_limit_info, - bactrace_command, _initialize_stack): Removed modifications for - limit on backtrace. Piping the backtrace through an interuptable - "more" emulation is a better way to do it. - -Wed Dec 28 11:43:09 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * stack.c - (set_backtrace_limit_command): Added command to set a limit to the - number of frames for a backtrace to print by default. - (backtrace_limit_info): To print the current limit. - (backtrace_command): To use the limit. - (_initialize_stack): To initialize the limit to its default value - (30), and add the set and info commands onto the appropriate - command lists. - - * gdb.texinfo: Documented changes to "backtrace" and "commands" - commands. - - * stack.c (backtrace_command): Altered so that a negative argument - would show the last few frames on the stack instead of the first - few. - (_initialize_stack): Modified help documentation. - - * breakpoint.c (commands_command): Altered so that "commands" with - no argument would refer to the last breakpoint set. - (_initialize_breakpoint): Modified help documentation. - - * infrun.c (wait_for_inferior): Removed ifdef on Sun4; now you can - single step through compiler generated sub calls and will die if - you next off of the end of a function. - - * sparc-dep.c (single_step): Fixed typo; "break_insn" ==> "sizeof - break_insn". - - * m-sparc.h (INIT_EXTRA_FRAME_INFO): Set the bottom of a stack - frame to be the bottom of the stack frame inner from this, if that - inner one is a leaf node. - - * dbxread.c (read_dbx_symtab): Check to make sure we don't add a - psymtab to it's own dependency list. - - * dbxread.c (read_dbx_symtab): Modified check for duplicate - dependencies to catch them correctly. - -Tue Dec 27 17:02:09 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * m-*.h (FRAME_SAVED_PC): Modified macro to take frame info - pointer as argument. - * stack.c (frame_info), blockframe.c (get_prev_frame_info), - gld-pinsn.c (findframe), m-*.h (SAVED_PC_AFTER_CALL, - FRAME_CHAIN_VALID, FRAME_NUM_ARGS): Changed usage of macros to - conform to above. - * m-sparc.h (FRAME_SAVED_PC), sparc-dep.c (frame_saved_pc): - Changed frame_saved_pc to have a frame info pointer as an - argument. - - * m-vax.h, m-umax.h, m-npl.h, infrun.c (wait_for_inferior), - blockframe.c (get_prev_frame_info): Modified SAVED_PC_AFTER_CALL - to take a frame info pointer as an argument. - - * blockframe.c (get_prev_frame_info): Altered the use of the - macros FRAME_CHAIN, FRAME_CHAIN_VALID, and FRAME_CHAIN_COMBINE to - use frame info pointers as arguments instead of frame addresses. - * m-vax.h, m-umax.h, m-sun3.h, m-sun3.h, m-sparc.h, m-pn.h, - m-npl.h, m-news.h, m-merlin.h, m-isi.h, m-hp9k320.h, m-i386.h: - Modified definitions of the above macros to suit. - * m-pn.h, m-npl.h, gould-dep.c (findframe): Modified findframe to - use a frame info argument; also fixed internals (wouldn't work - before). - - * m-sparc.h: Cosmetic changes; reordered some macros and made sure - that nothing went over 80 lines. - -Thu Dec 22 11:49:15 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * Version 3.0 released. - - * README: Deleted note about changing -lobstack to obstack.o. - -Wed Dec 21 11:12:47 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * m-vax.h (SKIP_PROLOGUE): Now recognizes gcc prologue also. - - * blockframe.c (get_prev_frame_info): Added FUNCTION_START_OFFSET - to result of get_pc_function_start. - * infrun.c (wait_for_inferior): Same. - - * gdb.texinfo: Documented new "step" and "next" behavior in - functions without line number information. - -Tue Dec 20 18:00:45 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * infcmd.c (step_1): Changed behavior of "step" or "next" in a - function witout line number information. It now sets the step - range around the function (to single step out of it) using the - misc function vector, warns the user, and continues. - - * symtab.c (find_pc_line): Zero "end" subsection of returned - symtab_and_line if no symtab found. - -Mon Dec 19 17:44:35 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * i386-pinsn.c (OP_REG): Added code from pace to streamline - disassembly and corrected types. - * i386-dep.c - (i386_follow_jump): Code added to follow byte and word offset - branches. - (i386_get_frame_setup): Expanded to deal with more wide ranging - function prologue. - (i386_frame_find_saved_regs, i386_skip_prologue): Changed to use - i386_get_frame_setup. - - -Sun Dec 18 11:15:03 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * m-sparc.h: Deleted definition of SUN4_COMPILER_BUG; was designed - to avoid something that I consider a bug in our code, not theirs, - and which I fixed earlier. Also deleted definition of - CANNOT_USE_ARBITRARY_FRAME; no longer used anywhere. - FRAME_SPECIFICATION_DYADIC used instead. - - * infrun.c (wait_for_inferior): On the sun 4, if a function - doesn't have a prologue, a next over it single steps into it. - This gets around the problem of a "call .stret4" at the end of - functions returning structures. - * m-sparc.h: Defined SUN4_COMPILER_FEATURE. - - * main.c (copying_info): Seperated the last printf into two - printfs. The 386 compiler will now handle it. - - * i386-pinsn.c, i386-dep.c: Moved print_387_control_word, - print_387_status_word, print_387_status, and i386_float_info to - dep.c Also included reg.h in dep.c. - -Sat Dec 17 15:31:38 1988 Randall Smith (randy at gluteus.ai.mit.edu) - - * main.c (source_command): Don't close instream if it's null - (indicating execution of a user-defined command). - (execute_command): Set instream to null before executing - commands and setup clean stuff to put it back on error. - - * inflow.c (terminal_inferior): Went back to not checking the - ioctl returns; there are some systems when this will simply fail. - It seems that, on most of these systems, nothing bad will happen - by that failure. - - * values.c (value_static_field): Fixed dereferencing of null - pointer. - - * i386-dep.c (i386_follow_jump): Modified to deal with - unconditional byte offsets also. - - * dbxread.c (read_type): Fixed typo in function type case of switch. - - * infcmd.c (run_command): Does not prompt to restart if command is - not from a tty. - -Fri Dec 16 15:21:58 1988 Randy Smith (randy at calvin) - - * gdb.texinfo: Added a third option under the "Cannot Insert - Breakpoints" workarounds. - - * printcmd.c (display_command): Don't do the display unless there - is an active inferior; only set it. - - * findvar.c (value_of_register): Added an error check for calling - this when the inferior isn't active and a core file isn't being - read. - - * config.gdb: Added reminder about modifying REGEX in the - makefile for the 386. - - * i386-pinsn.c, i386-dep.c: Moved m-i386.h helper functions over - to i386-dep.c.b - -Thu Dec 15 14:04:25 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * README: Added a couple of notes about compiling gdb with itself. - - * breakpoint.c (set_momentary_breakpoint): Only takes FRAME_FP of - frame if frame is non-zero. - - * printcmd.c (print_scalar_formatted): Implemented /g size for - hexadecimal format on machines without an 8 byte integer type. It - seems to be non-trivial to implement /g for other formats. - (decode_format): Allowed hexadecimal format to make it through /g - fileter. - -Wed Dec 14 13:27:04 1988 Randall Smith (randy at gluteus.ai.mit.edu) - - * expread.y: Converted all calls to write_exp_elt from the parser - to calls to one of write_exp_elt_{opcode, sym, longcst, dblcst, - char, type, intern}. Created all of these routines. This gets - around possible problems in passing one of these things in one ear - and getting something different out the other. Eliminated - SUN4_COMPILER_BUG ifdef's; they are now superfluous. - - * symmisc.c (free_all_psymtabs): Reinited partial_symtab_list to 0. - (_initialize_symmisc): Initialized both symtab_list and - partial_symtab_list. - - * dbxread.c (start_psymtab): Didn't allocate anything on - dependency list. - (end_psymtab): Allocate dependency list on psymbol obstack from - local list. - (add_psymtab_dependency): Deleted. - (read_dbx_symtab): Put dependency on local list if it isn't on it - already. - - * symtab.c: Added definition of psymbol_obstack. - * symtab.h: Added declaration of psymbol_obstack. - * symmisc.c (free_all_psymtabs): Added freeing and - reinitionaliztion of psymbol_obstack. - * dbxread.c (free_all_psymbols): Deleted. - (start_psymtab, end_psymtab, - process_symbol_for_psymtab): Changed most allocation - of partial symbol stuff to be off of psymbol_obstack. - - * symmisc.c (free_psymtab, free_all_psymtabs): Deleted - free_psymtab subroutine. - - * symtab.h: Removed num_includes and includes from partial_symtab - structure; no longer needed now that all include files have their - own psymtab. - * dbxread.c (start_psymtab): Eliminated initialization of above. - (end_psymtab): Eliminated finalization of above; get - includes from seperate list. - (read_dbx_symtab): Moved includes from psymtab list to - their own list; included in call to end_psymtab. - * symmisc.c (free_psymtab): Don't free includes. - -Tue Dec 13 14:48:14 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * i386-pinsn.c: Reformatted entire file to correspond to gnu - software indentation conventions. - - * sparc-dep.c (skip_prologue): Added capability of recognizign - stores of input register parameters into stack slots. - - * sparc-dep.c: Added an include of sparc-opcode.h. - * sparc-pinsn.c, sparc-opcode.h: Moved insn_fmt structures and - unions from pinsn.c to opcode.h. - * sparc-pinsn.c, sparc-dep.c (isabranch, skip_prologue): Moved - this function from pinsn.c to dep.c. - - * Makefile: Put in warnings about compiling with gcc (non-ansi - include files) and compiling with shared libs on Sunos 4.0 (can't - debug something that's been compiled that way). - - * sparc-pinsn.c: Put in a completely new file (provided by - Tiemann) to handle floating point disassembly, load and store - instructions, and etc. better. Made the modifications this file - (ChangeLog) list for sparc-pinsn.c again. - - * symtab.c (output_source_filename): Included "more" emulation hack. - - * symtab.c (output_source_filename): Initialized COLUMN to 0. - (sources_info): Modified to not print out a line for - all of the include files within a partial symtab (since - they have pst's of their own now). Also modified to - make a distinction between those pst's read in and - those not. - - * infrun.c: Included void declaration of single_step() if it's - going to be used. - * sparc-dep.c (single_step): Moved function previous to use of it. - - * Makefile: Took removal of expread.tab.c out of make clean entry - and put it into a new "squeakyclean" entry. - -Mon Dec 12 13:21:02 1988 Randall Smith (randy at gluteus.ai.mit.edu) - - * sparc-pinsn.c (skip_prologue): Changed a struct insn_fmt to a - union insn_fmt. - - * inflow.c (terminal_inferior): Checked *all* return codes from - ioctl's and fcntl's in routine. - - * inflow.c (terminal_inferior): Added check for sucess of - TIOCSPGRP ioctl call. Just notifies if bad. - - * dbxread.c (symbol_file_command): Close was getting called twice; - once directly and once through cleanup. Killed the direct call. - -Sun Dec 11 19:40:40 1988 & Smith (randy at hobbes.ai.mit.edu) - - * valprint.c (val_print): Deleted spurious printing of "=" from - TYPE_CODE_REF case. - -Sat Dec 10 16:41:07 1988 Randall Smith (randy at gluteus.ai.mit.edu) - - * dbxread.c: Changed allocation of psymbols from using malloc and - realloc to using obstacks. This means they aren't realloc'd out - from under the pointers to them. - -Fri Dec 9 10:33:24 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * sparc-dep.c inflow.c core.c expread.y command.c infrun.c - infcmd.c dbxread.c symmisc.c symtab.c printcmd.c valprint.c - values.c source.c stack.c findvar.c breakpoint.c blockframe.c - main.c: Various cleanups inspired by "gcc -Wall" (without checking - for implicit declarations). - - * Makefile: Cleaned up some more. - - * valops.c, m-*.h (FIX_CALL_DUMMY): Modified to take 5 arguments - as per what sparc needs (programming for a superset of needed - args). - - * dbxread.c (process_symbol_for_psymtab): Modified to be slightly - more picky about what it puts on the list of things *not* to be - put on the misc function list. When/if I shift everything over to - being placed on the misc_function_list, this will go away. - - * inferior.h, infrun.c: Added fields to save in inferior_status - structure. - - * maketarfile: Deleted; functionality is in Makefile now. - - * infrun.c (wait_for_inferior): Modified algorithm for determining - whether or not a single-step was through a subroutine call. See - comments at top of file. - - * dbxread.c (read_dbx_symtab): Made sure that the IGNORE_SYMBOL - macro would be checked during initial readin. - - * dbxread.c (read_ofile_symtab): Added macro GCC_COMPILED_FLAG_SYMBOL - into dbxread.c to indicate what string in a local text symbol will - indicate a file compiled with gcc. Defaults to "gcc_compiled.". - -Thu Dec 8 11:46:22 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * m-sparc.h (FRAME_FIND_SAVED_REGS): Cleaned up a little to take - advantage of the new frame cache system. - - * inferior.h, infrun.c, valops.c, valops.c, infcmd.c: Changed - mechanism to save inferior status over calls to inferior (eg. - call_function); implemented save_inferior_info and - restore_inferior_info. - - * blockframe.c (get_prev_frame): Simplified this by a direct call - to get_prev_frame_info. - - * frame.h, stack.c, printcmd.c, m-sparc.h, sparc-dep.c: Removed - all uses of frame_id_from_addr. There are short routines like it - still in frame_saved_pc (m-sparc.h) and parse_frame_spec - (stack.c). Eventually the one in frame_saved_pc will go away. - - * infcmd.c, sparc-dep.c: Implemented a new mechanism for - re-selecting the selected frame on return from a call. - - * blockframe.c, stack.c, findvar.c, printcmd.c, m-*.h: Changed - all routines and macros that took a "struct frame_info" as an - argument to take a "struct frame_info *". Routines: findarg, - framechain, print_frame_args, FRAME_ARGS_ADDRESS, - FRAME_STRUCT_ARGS_ADDRESS, FRAME_LOCALS_ADDRESS, FRAME_NUM_ARGS, - FRAME_FIND_SAVED_REGS. - - * frame.h, stack.c, printcmd.c, infcmd.c, findvar.c, breakpoint.c, - blockframe.c, xgdb.c, i386-pinsn.c, gld-pinsn.c, m-umax.h, - m-sun2.h, m-sun3.h, m-sparc.h, m-pn.h, m-npl.h, m-news.h, - m-merlin.h, m-isi.h, m-i386.h, m-hp9k320.h: Changed routines to - use "struct frame_info *" internally. - -Wed Dec 7 12:07:54 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * frame.h, blockframe.c, m-sparc.h, sparc-dep.c: Changed all calls - to get_[prev_]frame_cache_item to get_[prev_]frame_info. - - * blockframe.c: Elminated get_frame_cache_item and - get_prev_frame_cache_item; functionality now taken care of by - get_frame_info and get_prev_frame_info. - - * blockframe.c: Put allocation on an obstack and eliminated fancy - reallocation routines, several variables, and various nasty - things. - - * frame.h, stack.c, infrun.c, blockframe.c, sparc-dep.c: Changed - type FRAME to be a typedef to "struct frame_info *". Had to also - change routines that returned frame id's to return the pointer - instead of the cache index. - - * infcmd.c (finish_command): Used proper method of getting from - function symbol to start of function. Was treating a symbol as a - value. - - * blockframe.c, breakpoint.c, findvar.c, infcmd.c, stack.c, - xgdb.c, i386-pinsn.c, frame.h, m-hp9k320.h, m-i386.h, m-isi.h, - m-merlin.h, m-news.h, m-npl.h, m-pn.h, m-sparc.h, m-sun2.h, - m-sun3.h, m-umax.h: Changed get_frame_info and get_prev_frame_info - to return pointers instead of structures. - - * blockframe.c (get_pc_function_start): Modified to go to misc - function table instead of bombing if pc was in a block without a - containing function. - - * coffread.c: Dup'd descriptor passed to read_coff_symtab and - fdopen'd it so that there wouldn't be multiple closes on the same - fd. Also put (fclose, stream) on the cleanup list. - - * printcmd.c, stack.c: Changed print_frame_args to take a - frame_info struct as argument instead of the address of the args - to the frame. - - * m-i386.h (STORE_STRUCT_RETURN): Decremented sp by sizeof object - to store (an address) rather than 1. - - * dbxread.c (read_dbx_symtab): Set first_object_file_end in - read_dbx_symtab (oops). - - * coffread.c (fill_in_vptr_fieldno): Rewrote TYPE_BASECLASS as - necessary. - -Tue Dec 6 13:03:43 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * coffread.c: Added fake support for partial_symtabs to allow - compilation and execution without there use. - * inflow.c: Added a couple of minor USG mods. - * munch: Put in appropriate conditionals so that it would work on - USG systems. - * Makefile: Made regex.* handled same as obstack.*; made sure tar - file included everything I wanted it to include (including - malloc.c). - - * dbxread.c (end_psymtab): Create an entry in the - partial_symtab_list for each subfile of the .o file just read in. - This allows a "list expread.y:10" to work when we haven't read in - expread.o's symbol stuff yet. - - * symtab.h, dbxread.c (psymtab_to_symtab): Recognize pst->ldsymlen - == 0 as indicating a dummy psymtab, only in existence to cause the - dependency list to be read in. - - * dbxread.c (sort_symtab_syms): Elminated reversal of symbols to - make sure that register debug symbol decls always come before - parameter symbols. After mod below, this is not needed. - - * symtab.c (lookup_block_symbol): Take parameter type symbols - (LOC_ARG or LOC_REGPARM) after any other symbols which match. - - * dbxread.c (read_type): When defining a type in terms of some - other type and the other type is supposed to have a pointer back - to this specific kind of type (pointer, reference, or function), - check to see if *that* type has been created yet. If it has, use - it and fill in the appropriate slot with a pointer to it. - -Mon Dec 5 11:25:04 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * symmisc.c: Eliminated existence of free_inclink_symtabs and - init_free_inclink_symtabs; they aren't called from anywhere, and - if they were they could disrupt gdb's data structure badly - (elimination of struct type's which values that stick around past - elimination of inclink symtabs). - - * dbxread.c (symbol_file_command): Fixed a return pathway out of - the routine to do_cleanups before it left. - - * infcmd.c (set_environment_command), gdb.texinfo: Added - capability to set environmental variable values to null. - - * gdb.texinfo: Modified doc on "break" without args slightly. - -Sun Dec 4 17:03:16 1988 Randall Smith (randy at gluteus.ai.mit.edu) - - * dbxread.c (symbol_file_command): Added check; if there weren't - any debugging symbols in the file just read, the user is warned. - - * infcmd.c: Commented set_environment_command (a little). - - * createtags: Cleaned up and commented. - - * Makefile: Updated depen_memory and write_inferior_memory in that errno is - checked after each ptrace and returned to the caller. Used in - value_at to detect references to addresses which are out of - bounds. Also core.c (xfer_core_file): return 1 if invalid - address, 0 otherwise. - - * inflow.c, -infdep.c: removed all calls to ptrace from - inflo, m-sun3.h: Cleaned up dealings with - functions returning structu0 19:19:36 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu) - - * symmisc.c: (read_symsegs) Accept only format number 2. Since - the size of the type structure changed when C++ support was added, - format 1 can no longer be used. - - * core.c, m-sunos4.h: (core_file_command) support for SunOS 4.0. - Slight change in the core structure. #ifdef SUNOS4. New file - m-sunos4.h. May want to change config.gdb also. - -Fri Jul 8 19:59:49 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu) - - * breakpoint.c: (break_command_1) Allow `break if condition' - rather than parsing `if' as a function name and returning an - error. - -Thu Jul 7 22:22:47 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu) - - * C++: valops.c, valprint.c, value.h, values.c: merged code to deal - with C++ expressions. - -Wed Jul 6 03:28:18 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu) - - * C++: dbxread.c: (read_dbx_symtab, condense_misc_bunches, - add_file_command) Merged code to read symbol information from - an incrementally linked file. symmisc.c: - (init_free_inclink_symtabs, free_inclink_symtabs) Cleanup - routines. - -Tue Jul 5 02:50:41 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu) - - * C++: symtab.c, breakpoint.c, source.c: Merged code to deal with - ambiguous line specifications. In C++ one can have overloaded - function names, so that `list classname::overloadedfuncname' - refers to several different lines, possibly sure currently configured machine - dependent files come first in e at corn-chex.ai.mit.edu) - - * C++: symtab.c: replaced lookup_symtab_1 and lookup_symtab_2 with - a modified lookup_symbol which checks for fields of the current - implied argument `this'. printcmd.c, source.c, symtab.c, - valops.c: Need to change callers once callers are - installed. - -Wed Jun 29 01:26:56 1988 Peter TerMaat (pete at frosted-flakes.ai.mit.edu) - - * C++: eval.c, expprint.c, expread.y, expression.h, valarith.c, - Merged code to deal with evaluation of user-defined operators, - member functions, and virtual functions. - binop_must_be_user_defined tests for user-defined binops, - value_x_binop calls the appropriate operator function. - -Tue Jun 28 02:56:42 1988 Peter TerMaat (pete at frosted-flakes.ai.mit.edu) - - * C++: Makefile: changed the echo: expect 101 shift/reduce conflicts - and 1 reduce/reduce conflict. - - -Local Variables: -mode: indented-text -eval: (auto-fill-mode 1) -left-margin: 8 -fill-column: 74 -version-control: never -End: -ng destructors and - constructors, and flags being defined via public and via - virtual paths. Added fields NEXT_VARIANT, N_BASECLASSES, - and BASECLASSES to this type (tr: Changed types from - having to be derived from a single baseclass to a multiple - base class). - * symtab.h: Added macros to access new fields defined in symseg.h. - Added decl for lookup_basetype_type. - * dbxread.c - (condense_addl_misc_bunches): Function added to condense the misc - function bunches added by reading in a new .o file. - (read_addl_syms): Function added to read in symbols - from a new .o file (incremental linking). - (add_file_command): Command interface function to indicate - incrmental linking of a new .o file; this now calls - read_addl_syms and condense_addl_misc_bunches. - (define_symbol): Modified code to handle types defined from base - types which were not known when the derived class was - output. - (read_struct_type): Modified to better handle description of - struct types as derived types. Possibly derived from - several different base classes. Also added new code to - mark definitions via virtual paths or via public paths. - Killed seperate code to handle classes with destructors - but without constructors and improved marking of classes - as having destructors and constructors. - * infcmd.c: Modified call to val_print (one more argument). - * symtab.c (lookup_member_type): Modified to deal with new - structure in symseg.h. - (lookup_basetype_type): Function added to find or construct a type - ?derived? from the given type. - (decode_line_1): Modified to deal with new type data structures. - Modified to deal with new number of args for - decode_line_2. - (decode_line_2): Changed number of args (?why?). - (init_type): Added inits for new C++ fields from - symseg.h. - *valarith.c - (value_x_binop, value_binop): Added cases for BINOP_MIN & - BINOP_MAX. - * valops.c - (value_struct_elt, check_field, value_struct_elt_for_address): - Changed to deal with multiple possible baseclasses. - (value_of_this): Made SELECTED_FRAME an extern variable. - * valprint.c - (val_print): Added an argument DEREF_REF to dereference references - automatically, instead of printing them like pointers. - Changed number of arguments in recursive calls to itself. - Changed to deal with varibale numbers of base classes. - (value_print): Changed number of arguments to val_print. Print - type of value also if value is a reference. - (type_print_derivation_info): Added function to print out - derivation info a a type. - (type_print_base): Modified to use type_print_derivation_info and - to handle multiple baseclasses. - -Mon Nov 21 10:32:07 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * inflow.c (term_status_command): Add trailing newline to output. - - * sparc-dep.c (do_save_insn, do_restore_insn): Saved - "stop_registers" over the call for the sake of normal_stop and - run_stack_dummy. - - * m-sparc.h (EXTRACT_RETURN_VALUE): Put in parenthesis to force - addition of 8 to the int pointer, not the char pointer. - - * sparc-pinsn.c (print_addr1): Believe that I have gotten the - syntax right for loads and stores as adb does it. - - * symtab.c (list_symbols): Turned search for match on rexegp into - a single loop. - - * dbxread.c (psymtab_to_symtab): Don't read it in if it's already - been read in. - - * dbxread.c (psymtab_to_symtab): Changed error to fatal in - psymtab_to_symtab. - - * expread.y (parse_number): Fixed bug which treated 'l' at end of - number as '0'. - -Fri Nov 18 13:57:33 1988 Randall Smith (randy at gluteus.ai.mit.edu) - - * dbxread.c (read_dbx_symtab, process_symbol_for_psymtab): Was - being foolish and using pointers into an array I could realloc. - Converted these pointers into integers. - -Wed Nov 16 11:43:10 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * m-sparc.h (POP_FRAME): Made the new frame be PC_ADJUST of the - old frame. - - * i386-pinsn.c, m-hp9k320.h, m-isi.h, m-merlin.h, m-news.h, - m-npl.h, m-pn.h, m-sparc.h, m-sun2.h, m-sun3.h, m-umax.h, m-vax.h: - Modified POP_FRAME to use the current frame instead of - read_register (FP_REGNUM) and to flush_cached_frames before - setting the current frame. Also added a call to set the current - frame in those POP_FRAMEs that didn't have it. - - * infrun.c (wait_for_inferior): Moved call to set_current_frame up - to guarrantee that the current frame will always be set when a - POP_FRAME is done. - - * infrun.c (normal_stop): Added something to reset the pc of the - current frame (was incorrect because of DECR_PC_AFTER_BREAK). - - * valprint.c (val_print): Changed to check to see if a string was - out of bounds when being printed and to indicate this if so. - - * convex-dep.c (read_inferior_memory): Changed to return the value - of errno if the call failed (which will be 0 if the call - suceeded). - -Tue Nov 15 10:17:15 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * infrun.c (wait_for_inferior): Two changes: 1) Added code to - not trigger the step breakpoint on recursive calls to functions - without frame info, and 2) Added calls to distinguish recursive - calls within a function without a frame (which next/nexti might - wish to step over) from jumps to the beginning of a function - (which it generally doesn't). - - * m-sparc.h (INIT_EXTRA_FRAME_INFO): Bottom set correctly for leaf - parents. - - * blockframe.c (get_prev_frame_cache_item): Put in mod to check - for a leaf node (by presence or lack of function prologue). If - there is a leaf node, it is assumed that SAVED_PC_AFTER_CALL is - valid. Otherwise, FRAME_SAVED_PC or read_pc is used. - - * blockframe.c, frame.h: Did final deletion of unused routines and - commented problems with getting a pointer into the frame cache in - the frame_info structure comment. - - * blockframe.c, frame.h, stack.c: Killed use of - frame_id_from_frame_info; used frame_id_from_addr instead. - - * blockframe.c, frame.h, stack.c, others (oops): Combined stack - cache and frame info structures. - - * blockframe.c, sparc-dep.c, stack.c: Created the function - create_new_frame and used it in place of bad calls to - frame_id_from_addr. - - * blockframe.c, inflow.c, infrun.c, i386-pinsn.c, m-hp9k320.h, - m-npl.h, m-pn.h, m-sparc.h, m-sun3.h, m-vax.h, default-dep.c, - convex-dep.c, gould-dep.c, hp9k320-dep.c, news-dep.c, sparc-dep.c, - sun3-dep.c, umax-dep.c: Killed use of - set_current_Frame_by_address. Used set_current_frame - (create_new_frame...) instead. - - * frame.h: Killed use of FRAME_FP_ID. - - * infrun.c, blockframe.c: Killed select_frame_by_address. Used - select_frame (get_current_frame (), 0) (which was correct in all - cases that we need to worry about. - -Mon Nov 14 14:19:32 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * frame.h, blockframe.c, stack.c, m-sparc.h, sparc-dep.c: Added - mechanisms to deal with possible specification of frames - dyadically. - -Sun Nov 13 16:03:32 1988 Richard Stallman (rms at sugar-bombs.ai.mit.edu) - - * ns32k-opcode.h: Add insns acbw, acbd. - -Sun Nov 13 15:09:58 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * breakpoint.c: Changed breakpoint structure to use the address of - a given frame (constant across inferior runs) as the criteria for - stopping instead of the frame ident (which varies across inferior - calls). - -Fri Nov 11 13:00:22 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * gld-pinsn.c (findframe): Modified to work with the new frame - id's. Actually, it looks as if this routine should be called with - an address anyway. - - * findvar.c (find_saved_register): Altered bactrace loop to work - off of frames and not frame infos. - - * frame.h, blockframe.c, stack.c, sparc-dep.c, m-sparc.h: Changed - FRAME from being the address of the frame to being a simple ident - which is an index into the frame_cache_item list. - * convex-dep.c, default-dep.c, gould-dep.c, hp9k320-dep.c, - i386-pinsn.c, inflow.c, infrun.c, news-dep.c, sparc-dep.c, - sun3-dep.c, umax-dep.c, m-hp9k320.h, m-npl.h, m-pn.h, m-sparc.h, - m-sun3.h, m-vax.h: Changed calls of the form set_current_frame - (read_register (FP_REGNUM)) to set_current_frame_by_address (...). - -Thu Nov 10 16:57:57 1988 Randall Smith (randy at gluteus.ai.mit.edu) - - * frame.h, blockframe.c, gld-pinsn.c, sparc-dep.c, stack.c, - infrun.c, findvar.c, m-sparc.h: Changed the FRAME type to be - purely an identifier, using FRAME_FP and FRAME_FP_ID to convert - back and forth between the two. The identifier is *currently* - still the frame pointer value for that frame. - -Wed Nov 9 17:28:14 1988 Chris Hanson (cph at kleph) - - * m-hp9k320.h (FP_REGISTER_ADDR): Redefine this to return - difference between address of given FP register, and beginning of - `struct user' that it occurs in. - - * hp9k320-dep.c (core_file_command): Fix sign error in size - argument to myread. Change buffer argument to pointer; was - copying entire structure. - (fetch_inferior_registers, store_inferior_registers): Replace - occurrences of `FP_REGISTER_ADDR_DIFF' with `FP_REGISTER_ADDR'. - Flush former definition. - -Wed Nov 9 12:11:37 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * xgdb.c: Killed include of initialize.h. - - * Pulled in xgdb.c from the net. - - * Checkpointed distribution (to provide to 3b2 guy). - - * coffread.c, dbxread.c, symmisc.c, symtab.c, symseg.h: Changed - format of table of line number--pc mapping information. Can - handle negative pc's now. - - * command.c: Deleted local copy of savestring; code in utils.c is - identical. - -Tue Nov 8 11:12:16 1988 Randall Smith (randy at plantaris.ai.mit.edu) - - * gdb.texinfo: Added documentation for shell escape. - -Mon Nov 7 12:27:16 1988 Randall Smith (randy at sugar-bombs.ai.mit.edu) - - * command.c: Added commands for shell escape. - - * core.c, dbxread.c: Added ROBOTUSSIN mods. - - * Checkpointed distribution. - - * printcmd.c (x_command): Yanked error if there is no memory to - examine (could be looking at executable straight). - - * sparc-pinsn.c (print_insn): Amount to leftshift sethi imm by is - now 10 (matches adb in output). - - * printcmd.c (x_command): Don't attempt to set $_ & $__ if there - is no last_examine_value (can happen if you did an x/0). - -Fri Nov 4 13:44:49 1988 Randall Smith (randy at gluteus.ai.mit.edu) - - * printcmd.c (x_command): Error if there is no memory to examine. - - * gdb.texinfo: Added "cont" to the command index. - - * sparc-dep.c (do_save_insn): Fixed typo in shift amount. - - * m68k-opcode.h: Fixed opcodes for 68881. - - * breakpoint.c, infcmd.c, source.c: Changed defaults in several - places for decode_line_1 to work off of the default_breakpoint_* - values instead of current_source_* values (the current_source_* - values are off by 5 or so because of listing defaults). - - * stack.c (frame_info): ifdef'd out FRAME_SPECIFCATION_DYADIC in - the stack.c module. If I can't do this right, I don't want to do - it at all. Read the comment there for more info. - -Mon Oct 31 16:23:06 1988 Randall Smith (randy at gluteus.ai.mit.edu) - - * gdb.texinfo: Added documentation on the "until" command. - -Sat Oct 29 17:47:10 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * breakpoint.c, infcmd.c: Added UNTIL_COMMAND and subroutines of - it. - - * breakpoint.c, infcmd.c, infrun.c: Added new field to breakpoint - structure (silent, indicating a silent breakpoint), and modified - breakpoint_stop_status and things that read it's return value to - understand it. - -Fri Oct 28 17:45:33 1988 Randall Smith (randy at gluteus.ai.mit.edu) - - * dbxread.c, symmisc.c: Assorted speedups for readin, including - special casing most common symbols, and doing buffering instead of - calling malloc. - -Thu Oct 27 11:11:15 1988 Randall Smith (randy at gluteus.ai.mit.edu) - - * stack.c, sparc-dep.c, m-sparc.h: Modified to allow "info frame" - to take two arguments on the sparc and do the right thing with - them. - - * dbxread.c (read_dbx_symtab, process_symbol_for_psymtab): Put - stuff to put only symbols that didn't have debugging info on the - misc functions list back in. - -Wed Oct 26 10:10:32 1988 Randall Smith (randy at gluteus.ai.mit.edu) - - * valprint.c (type_print_varspec_suffix): Added check for - TYPE_LENGTH(TYPE_TARGET_TYPE(type)) > 0 to prevent divide by 0. - - * printcmd.c (print_formatted): Added check for VALUE_REPEATED; - value_print needs to be called for that. - - * infrun.c (wait_for_inferior): Added break when you decide to - stop on a null function prologue rather than continue stepping. - - * m-sun3.h: Added explanatory comment to REGISTER_RAW_SIZE. - - * expread.y (parse_c_1): Initialized paren_depth for each parse. - -Tue Oct 25 14:19:38 1988 Randall Smith (randy at gluteus.ai.mit.edu) - - * valprint.c, coffread.c, dbxread.c: Enum constant values in enum - type now accessed through TYPE_FIELD_BITPOS. - - * dbxread.c (process_symbol_for_psymtab): Added code to deal with - possible lack of a ":" in a debugging symbol (do nothing). - - * symtab.c (decode_line_1): Added check in case of all numbers for - complete lack of symbols. - - * source.c (select_source_symtab): Made sure that this wouldn't - bomb on complete lack of symbols. - -Mon Oct 24 12:28:29 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * m-sparc.h, findvar.c: Ditched REGISTER_SAVED_UNIQUELY and based - code on REGISTER_IN_WINDOW_P and HAVE_REGISTER_WINDOWS. This will - break when we find a register window machine which saves the - window registers within the context of an inferior frame. - - * sparc-dep.c (frame_saved_pc): Put PC_ADJUST return back in for - frame_saved_pc. Seems correct. - - * findvar.c, m-sparc.h: Created the macro REGISTER_SAVED_UNIQUELY - to handle register window issues (ie. that find_saved_register - wasn't checking the selected frame itself for shit). - - * sparc-dep.c (core_file_command): Offset target of o & g register - bcopy by 1 to hit correct registers. - - * m-sparc.h: Changed STACK_END_ADDR. - -Sun Oct 23 19:41:51 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * sparc-dep.c (core_file_command): Added in code to get the i & l - registers from the stack in the corefile, and blew away some wrong - code to get i & l from inferior. - -Fri Oct 21 15:09:19 1988 Randall Smith (randy at apple-gunkies.ai.mit.edu) - - * m-sparc.h (PUSH_DUMMY_FRAME): Saved the value of the RP register - in the location reserved for i7 (in the created frame); this way - the rp value won't get lost. The pc (what we put into the rp in - this routine) gets saved seperately, so we loose no information. - - * sparc-dep.c (do_save_insn & do_restore_insn): Added a wrapper to - preserve the proceed status state variables around each call to - proceed (the current frame was getting munged because this wasn't - being done). - - * m-sparc.h (FRAME_FIND_SAVED_REGS): Fix bug: saved registers - addresses were being computed using absolute registers number, - rather than numbers relative to each group of regs. - - * m-sparc.h (POP_FRAME): Fixed a bug (I hope) in the context - within which saved reg numbers were being interpetted. The - values to be restored were being gotten in the inferior frame, and - the restoring was done in the superior frame. This means that i - registers must be restored into o registers. - - * sparc-dep.c (do_restore_insn): Modified to take a pc as an - argument, instead of a raw_buffer. This matches (at least it - appears to match) usage from POP_FRAME, which is the only place - from which do_restore_insn is called. - - * sparc-dep.c (do_save_insn and do_restore_insn): Added comments. - - * m-sparc.h (FRAME_FIND_SAVED_REGS): Modified my code to find the - save addresses of out registers to use the in regs off the stack - pointer when the current frame is 1 from the innermost. - -Thu Oct 20 13:56:15 1988 & Smith (randy at hobbes.ai.mit.edu) - - * blockframe.c, m-sparc.h: Removed code associated with - GET_PREV_FRAME_FROM_CACHE_ITEM. This code was not needed for the - sparc; you can always find the previous frames fp from the fp of - the current frame (which is the sp of the previous). It's getting - the information associated with a given frame (ie. saved - registers) that's a bitch, because that stuff is saved relative to - the stack pointer rather than the frame pointer. - - * m-sparc.h (GET_PREV_FRAME_FROM_CACHE_ITEM): Modified to return - the frame pointer of the previous frame instead of the stack - pointer of same. - - * blockframe.c (flush_cached_frames): Modified call to - obstack_free to free back to frame_cache instead of back to zero. - This leaves the obstack control structure in finite state (and - still frees the entry allocated at frame_cache). - -Sat Oct 15 16:30:47 1988 & Smith (randy at tartarus.uchicago.edu) - - * valops.c (call_function): Suicide material here. Fixed a typo; - CALL_DUMMY_STACK_ADJUST was spelled CAll_DUMMY_STACK_ADJUST on - line 530 of the file. This cost me three days. I'm giving up - typing for lent. - -Fri Oct 14 15:10:43 1988 & Smith (randy at tartarus.uchicago.edu) - - * m-sparc.h: Corrected a minor mistake in the dummy frame code - that was getting the 5th argument and the first argument from the - same place. - -Tue Oct 11 11:49:33 1988 & Smith (randy at tartarus.uchicago.edu) - - * infrun.c: Made stop_after_trap and stop_after_attach extern - instead of static so that code which used proceed from machine - dependent files could fiddle with them. - - * blockframe.c, frame.h, sparc-dep.c, m-sparc.h: Changed sense of - ->prev and ->next in struct frame_cache_item to fit usage in rest - of gdb (oops). - -Mon Oct 10 15:32:42 1988 Randy Smith (randy at gargoyle.uchicago.edu) - - * m-sparc.h, sparc-dep.c, blockframe.c, frame.h: Wrote - get_frame_cache_item. Modified FRAME_SAVED_PC and frame_saved_pc - to take only one argument and do the correct thing with it. Added - the two macros I recently defined in blockframe.c to m-sparc.h. - Have yet to compile this thing on a sparc, but I've now merged in - everything that I received from tiemann, either exactly, or simply - effectively. - - * source.c: Added code to allocated space to sals.sals in the case - where no line was specified. - - * blockframe.c, infrun.c: Modified to cache stack frames requested - to minimize accesses to subprocess. - -Tue Oct 4 15:10:39 1988 Randall Smith (randy at cream-of-wheat.ai.mit.edu) - - * config.gdb: Added sparc. - -Mon Oct 3 23:01:22 1988 Randall Smith (randy at cream-of-wheat.ai.mit.edu) - - * Makefile, blockframe.c, command.c, core.c, dbxread.c, defs.h, - expread.y, findvar.c, infcmd.c, inflow.c, infrun.c, sparc-pinsn.c, - m-sparc.h, sparc-def.c, printcmd.c, stack.c, symmisc.c, symseg.h, - valops.c, values.c: Did initial merge of sparc port. This will - not compile; have to do stack frame caching and finish port. - - * inflow.c, gdb.texinfo: `tty' now resets the controling terminal. - -Fri Sep 30 11:31:16 1988 Randall Smith (randy at gluteus.ai.mit.edu) - - * inferior.h, infcmd.c, infrun.c: Changed the variable - stop_random_signal to stopped_by_random signal to fit in better - with name conventions (variable is not a direction to the - proceed/resume set; it is information from it). - -Thu Sep 29 13:30:46 1988 Randall Smith (randy at cream-of-wheat.ai.mit.edu) - - * infcmd.c (finish_command): Value type of return value is now - whatever the function returns, not the type of the function (fixed - a bug in printing said value). - - * dbxread.c (read_dbx_symtab, process_symbol_for_psymtab): - Put *all* global symbols into misc_functions. This is what was - happening anyway, and we need it for find_pc_misc_function. - - ** This was eventually taken out, but I didn't mark it in the - ChangeLog. Oops. - - * dbxread.c (process_symbol_for_psymtab): Put every debugger - symbol which survives the top case except for constants on the - symchain. This means that all of these *won't* show up in misc - functions (this will be fixed once I make sure it's broken the way - it's supposed to be). - - * dbxread.c: Modified placement of debugger globals onto the hash - list; now we exclude the stuff after the colon and don't skip the - first character (debugger symbols don't have underscores). - - * dbxread.c: Killed debuginfo stuff with ifdef's. - -Wed Sep 28 14:31:51 1988 Randall Smith (randy at cream-of-wheat.ai.mit.edu) - - * symtab.h, dbxread.c: Modified to deal with BINCL, EINCL, and - EXCL symbols produced by the sun loader by adding a list of - pre-requisite partial_symtabs that each partial symtab needs. - - * symtab.h, dbxread.c, symtab.c, symmisc.c: Modified to avoid - doing a qsort on the local (static) psymbols for each file to - speed startup. This feature is not completely debugged, but it's - inclusion has forced the inclusion of another feature (dealing - with EINCL's, BINCL's and EXCL's) and so I'm going to go in and - deal with them. - - * dbxread.c (process_symbol_for_psymtab): Made sure that the class - of the symbol made it into the partial_symbol entry. - -Tue Sep 27 15:10:26 1988 Randall Smith (randy at gluteus.ai.mit.edu) - - * dbxread.c: Fixed bug; init_psymbol_list was not being called - with the right number of arguments (1). - - * dbxread.c: Put ifdef's around N_MAIN, N_M2C, and N_SCOPE to - allow compilation on a microvax. - - * config.gdb: Modified so that "config.gdb vax" would work. - - * dbxread.c, symtab.h, symmisc.h, symtab.c, source.c: Put in many - and varied hacks to speed up gdb startup including: A complete - rewrite of read_dbx_symtab, a modification of the partial_symtab - data type, deletion of select_source_symtab from - symbol_file_command, and optimiztion of the call to strcmp in - compare_psymbols. - -Thu Sep 22 11:08:54 1988 Randall Smith (randy at gluteus.ai.mit.edu) - - * dbxread.c (psymtab_to_symtab): Removed call to - init_misc_functions. - - * dbxread.c: Fixed enumeration type clash (used enum instead of - integer constant). - - * breakpoint.c: Fixed typo; lack of \ at end of line in middle of - string constant. - - * symseg.h: Fixed typo; lack of semicolon after structure - definition. - - * command.c, breakpoint.c, printcmd.c: Added cmdlist editing - functions to add commands with the abbrev flag set. Changed - help_cmd_list to recognize this flag and modified unset, - undisplay, and enable, disable, and delete breakpoints to have - this flag set. - -Wed Sep 21 13:34:19 1988 Randall Smith (randy at plantaris.ai.mit.edu) - - * breakpoint.c, infcmd.c, gdb.texinfo: Created "unset" as an alias - for delete, and changed "unset-environment" to be the - "environment" subcommand of "delete". - - * gdb.texinfo, valprint.c: Added documentation in the manual for - breaking the set-* commands into subcommands of set. Changed "set - maximum" to "set array-max". - - * main.c, printcmd.c, breakpoint.c: Moved the declaration of - command lists into main and setup a function in main initializing - them to guarrantee that they would be initialized before calling - any of the individual files initialize routines. - - * command.c (lookup_cmd): A null string subcommand is treated as - an unknown subcommand rather than an ambiguous one (eg. "set $x = - 1" will now work). - - * infrun.c (wait_for_inferior): Put in ifdef for Sony News in - check for trap by INNER_THAN macro. - - * eval.c (evaluate_subexp): Put in catch to keep the user from - attempting to call a non function as a function. - -Tue Sep 20 10:35:53 1988 Randall Smith (randy at oatmeal.ai.mit.edu) - - * dbxread.c (read_dbx_symtab): Installed code to keep track of - which global symbols did not have debugger symbols refering to - them, and recording these via record_misc_function. - - * dbxread.c: Killed code to check for extra global symbols in the - debugger symbol table. - - * printcmd.c, breakpoint.c: Modified help entries for several - commands to make sure that abbreviations were clearly marked and - that the right commands showed up in the help listings. - - * main.c, command.c, breakpoint.c, infcmd.c, printcmd.c, - valprint.c, defs.h: Modified help system to allow help on a class - name to show subcommands as well as commands and help on a command - to show *all* subcommands of that command. - -Fri Sep 16 16:51:19 1988 Randall Smith (randy at gluteus.ai.mit.edu) - - * breakpoint.c (_initialize_breakpoint): Made "breakpoints" - subcommands of enable, disable, and delete use class 0 (ie. they - show up when you do a help xxx now). - - * infcmd.c,printcmd,c,main.c,valprint.c: Changed the set-* - commands into subcommands of set. Created "set variable" for use - with variables whose names might conflict with other subcommands. - - * blockframe.c, dbxread.c, coffread.c, expread.y, source.c: - Fixed mostly minor (and one major one in block_for_pc) bugs - involving checking the partial_symtab_list when a scan through the - symtab_list fails. - -Wed Sep 14 12:02:05 1988 Randall Smith (randy at sugar-smacks.ai.mit.edu) - - * breakpoint.c, gdb.texinfo: Added enable breakpoints, disable - breakpoints and delete breakpoints as synonyms for enable, - disable, and delete. This seemed reasonable because of the - immeninent arrival of watchpoints & etc. - - * gdb.texinfo: Added enable display, disable display, and delete - display to manual. - -Tue Sep 13 16:53:56 1988 Randall Smith (randy at sugar-smacks.ai.mit.edu) - - * inferior.h, infrun.c, infcmd.c: Added variable - stop_random_signal to indicate when a proceed had been stopped by - an unexpected signal. Used this to determine (in normal_stop) - whether the current display point should be deleted. - - * valops.c: Fix to value_ind to check for reference before doing a - COERCE_ARRAY. - -Sun Jul 31 11:42:36 1988 Richard Stallman (rms at frosted-flakes.ai.mit.edu) - - * breakpoint.c (_initialize_breakpoint): Clean up doc for commands - that can now apply also to auto-displays. - - * coffread.c (record_line): Corrected a spazz in editing. - Also removed the two lines that assume line-numbers appear - only in increasing order. - -Tue Jul 26 22:19:06 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu) - - * expression.h, eval.c, expprint.c, printcmd.c, valarith.c, - valops.c, valprint.c, values.c, m-*.h: Changes for evaluating and - displaying 64-bit `long long' integers. Each machine must define - a LONGEST type, and a BUILTIN_TYPE_LONGEST. - - * symmisc.c: (print_symtab) check the status of the fopen and call - perror_with_name if needed. - -Thu Jul 21 00:56:11 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu) - - * Convex: core.c: changes required by Convex's SOFF format were - isolated in convex-dep.c. - -Wed Jul 20 21:26:10 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu) - - * coffread.c, core.c, expread.y, i386-pinsn.c, infcmd.c, inflow.c, - infrun.c, m-i386.h, main.c, remote.c, source.c, valops.c: - Improvements for the handling of the i386 and other machines - running USG. (Several of these files just needed extra header files - such as types.h.) utils.c: added bcopy, bcmp, bzero, getwd, list - of signals, and queue routines for USG systems. Added vfork macro - to i386 - - * printcmd.c, breakpoint.c: New commands to enable/disable - auto-displays. Also `delete display displaynumber' works like - `undisplay displaynumber'. - -Tue Jul 19 02:17:18 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu) - - * coffread.c: (coff_lookup_type) Wrong portion of type_vector was - being bzero'd after type_vector was reallocated. - - * printcmd.c: (delete_display) Check for a display chain before - attempting to delete a display. - - * core.c, *-dep.c (*-infdep moved to *-dep): machine-dependent - parts of core.c (core_file_command, exec_file_command) moved to - *-dep.c. - -Mon Jul 18 19:45:51 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu) - - * dbxread.c: typo in read_struct_type (missing '=') was causing a - C struct to be parsed as a C++ struct, resulting in a `invalid - character' message. - -Sun Jul 17 22:27:32 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu) - - * printcmd.c, symtab.c, valops.c, expread.y: When an expression is - read, the innermost block required to evaluate the expression is - saved in the global variable `innermost_block'. This information - is saved in the `block' field of an auto-display so that - expressions with inactive variables can be skipped. `info display' - tells the user which displays are active and which are not. New - fn `contained_in' returns nonzero if one block is contained within - another. - -Fri Jul 15 01:53:14 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu) - - * infrun.c, m-i386.h: Use macro TRAPS_EXPECTED to set number of - traps to skip when sh execs the program. Default is 2, m-i386.h - overrides this and sets to 4. - - * coffread.c, infrun.c: minor changes for the i386. May be able - to eliminate them with more general code. - - * default-infdep.c: #ifdef SYSTEMV, include header file types.h. - Also switched the order of signal.h and user.h, since System 5 - requires signal.h to come first. - - * core.c main.c, remote,c, source.c, inflow.c: #ifdef SYSTEMV, - include various header files. Usually types.h and fcntl.h. - - * utils.c: added queue routines needed by the i386 (and other sys - 5 machines). - - * sys5.c, regex.c, regex.h: new files for sys 5 systems. (The - regex files are simply links to /gp/gnu/lib.) - -Thu Jul 14 01:47:14 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu) - - * config.gdb, README: Provide a list of known machines when user - enters an invalid machine. New second arg is operating system, - currently only used with `sunos4' or `os4'. Entry for i386 added. - - * news-infdep.c: new file. - - * m-news.h: new version which deals with new bugs in news800's OS. - -Tue Jul 12 19:52:16 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu) - - * Makefile, *.c, munch, config.gdb, README: New initialization - scheme uses nm to find functions whose names begin with - `_initialize_'. Files `initialize.h', `firstfile.c', - `lastfile.c', `m-*init.h' no longer needed. - - * eval.c, symtab.c, valarith.c, valops.c, value.h, values.c: Bug - fixes from gdb+ 2.5.4. evaluate_subexp takes a new arg, type - expected. New fn value_virtual_fn_field. - -Mon Jul 11 00:48:49 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu) - - * core.c (read_memory): xfer_core_file was being called with an - extra argument (0) by read_memory. - - * core.c (read_memory), *-infdep.c (read_inferior_memory), - valops.c (value_at): read_memory and read_inferior_memory now work - like write_memory and write_inferior_memory in that errno is - checked after each ptrace and returned to the caller. Used in - value_at to detect references to addresses which are out of - bounds. Also core.c (xfer_core_file): return 1 if invalid - address, 0 otherwise. - - * inflow.c, -infdep.c: removed all calls to ptrace from - inflow.c and put them in machine-dependent files *-infdep.c. - -Sun Jul 10 19:19:36 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu) - - * symmisc.c: (read_symsegs) Accept only format number 2. Since - the size of the type structure changed when C++ support was added, - format 1 can no longer be used. - - * core.c, m-sunos4.h: (core_file_command) support for SunOS 4.0. - Slight change in the core structure. #ifdef SUNOS4. New file - m-sunos4.h. May want to change config.gdb also. - -Fri Jul 8 19:59:49 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu) - - * breakpoint.c: (break_command_1) Allow `break if condition' - rather than parsing `if' as a function name and returning an - error. - -Thu Jul 7 22:22:47 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu) - - * C++: valops.c, valprint.c, value.h, values.c: merged code to deal - with C++ expressions. - -Wed Jul 6 03:28:18 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu) - - * C++: dbxread.c: (read_dbx_symtab, condense_misc_bunches, - add_file_command) Merged code to read symbol information from - an incrementally linked file. symmisc.c: - (init_free_inclink_symtabs, free_inclink_symtabs) Cleanup - routines. - -Tue Jul 5 02:50:41 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu) - - * C++: symtab.c, breakpoint.c, source.c: Merged code to deal with - ambiguous line specifications. In C++ one can have overloaded - function names, so that `list classname::overloadedfuncname' - refers to several different lines, possibly in different files. - -Fri Jul 1 02:44:20 1988 Peter TerMaat (pete at corn-chex.ai.mit.edu) - - * C++: symtab.c: replaced lookup_symtab_1 and lookup_symtab_2 with - a modified lookup_symbol which checks for fields of the current - implied argument `this'. printcmd.c, source.c, symtab.c, - valops.c: Need to change callers once callers are - installed. - -Wed Jun 29 01:26:56 1988 Peter TerMaat (pete at frosted-flakes.ai.mit.edu) - - * C++: eval.c, expprint.c, expread.y, expression.h, valarith.c, - Merged code to deal with evaluation of user-defined operators, - member functions, and virtual functions. - binop_must_be_user_defined tests for user-defined binops, - value_x_binop calls the appropriate operator function. - -Tue Jun 28 02:56:42 1988 Peter TerMaat (pete at frosted-flakes.ai.mit.edu) - - * C++: Makefile: changed the echo: expect 101 shift/reduce conflicts - and 1 reduce/reduce conflict. - -Local Variables: -mode: indented-text -left-margin: 8 -fill-column: 74 -version-control: never -End: diff --git a/gdb/Convex.notes b/gdb/Convex.notes deleted file mode 100644 index 28d336bfed8..00000000000 --- a/gdb/Convex.notes +++ /dev/null @@ -1,163 +0,0 @@ - -@node Convex,,, Top -@appendix Convex-specific info -@cindex Convex notes - -Scalar registers are 64 bits long, which is a pain since -left half of an S register frequently contains noise. -Therefore there are two ways to obtain the value of an S register. - -@table @kbd -@item $s0 -returns the low half of the register as an int - -@item $S0 -returns the whole register as a long long -@end table - -You can print the value in floating point by using @samp{p/f $s0} or @samp{p/f $S0} -to print a single or double precision value. - -@cindex vector registers -Vector registers are handled similarly, with @samp{$V0} denoting the whole -64-bit register and @kbd{$v0} denoting the 32-bit low half; @samp{p/f $v0} -or @samp{p/f $V0} can be used to examine the register in floating point. -The length of the vector registers is taken from @samp{$vl}. - -Individual elements of a vector register are denoted in the obvious way; -@samp{print $v3[9]} prints the tenth element of register @kbd{v3}, and -@samp{set $v3[9] = 1234} alters it. - -@kbd{$vl} and @kbd{$vs} are int, and @kbd{$vm} is an int vector. -Elements of @kbd{$vm} can't be assigned to. - -@cindex communication registers -@kindex info comm-registers -Communication registers have names @kbd{$C0 .. $C63}, with @kbd{$c0 .. $c63} -denoting the low-order halves. @samp{info comm-registers} will print them -all out, and tell which are locked. (A communication register is -locked when a value is sent to it, and unlocked when the value is -received.) Communication registers are, of course, global to all -threads, so it does not matter what the currently selected thread is. -@samp{info comm-reg @var{name}} prints just that one communication -register; @samp{name} may also be a communication register number -@samp{nn} or @samp{0xnn}. -@samp{info comm-reg @var{address}} prints the contents of the resource -structure at that address. - -@kindex info psw -The command @samp{info psw} prints the processor status word @kbd{$ps} -bit by bit. - -@kindex set base -GDB normally prints all integers in base 10, but the leading -@kbd{0x80000000} of pointers is intolerable in decimal, so the default -output radix has been changed to try to print addresses appropriately. -The @samp{set base} command can be used to change this. - -@table @code -@item set base 10 -Integer values always print in decimal. - -@item set base 16 -Integer values always print in hex. - -@item set base -Go back to the initial state, which prints integer values in hex if they -look like pointers (specifically, if they start with 0x8 or 0xf in the -stack), otherwise in decimal. -@end table - -@kindex set pipeline -When an exception such as a bus error or overflow happens, usually the PC -is several instructions ahead by the time the exception is detected. -The @samp{set pipe} command will disable this. - -@table @code -@item set pipeline off -Forces serial execution of instructions; no vector chaining and no -scalar instruction overlap. With this, exceptions are detected with -the PC pointing to the instruction after the one in error. - -@item set pipeline on -Returns to normal, fast, execution. This is the default. -@end table - -@cindex parallel -In a parallel program, multiple threads may be executing, each -with its own registers, stack, and local memory. When one of them -hits a breakpoint, that thread is selected. Other threads do -not run while the thread is in the breakpoint. - -@kindex 1cont -The selected thread can be single-stepped, given signals, and so -on. Any other threads remain stopped. When a @samp{cont} command is given, -all threads are resumed. To resume just the selected thread, use -the command @samp{1cont}. - -@kindex thread -The @samp{thread} command will show the active threads and the -instruction they are about to execute. The selected thread is marked -with an asterisk. The command @samp{thread @var{n}} will select thread @var{n}, -shifting the debugger's attention to it for single-stepping, -registers, local memory, and so on. - -@kindex info threads -The @samp{info threads} command will show what threads, if any, have -invisibly hit breakpoints or signals and are waiting to be noticed. - -@kindex set parallel -The @samp{set parallel} command controls how many threads can be active. - -@table @code -@item set parallel off -One thread. Requests by the program that other threads join in -(spawn and pfork instructions) do not cause other threads to start up. -This does the same thing as the @samp{limit concurrency 1} command. - -@item set parallel fixed -All CPUs are assigned to your program whenever it runs. When it -executes a pfork or spawn instruction, it begins parallel execution -immediately. This does the same thing as the @samp{mpa -f} command. - -@item set parallel on -One or more threads. Spawn and pfork cause CPUs to join in when and if -they are free. This is the default. It is very good for system -throughput, but not very good for finding bugs in parallel code. If you -suspect a bug in parallel code, you probably want @samp{set parallel fixed.} -@end table - -@subsection Limitations - -WARNING: Convex GDB evaluates expressions in long long, because S -registers are 64 bits long. However, GDB expression semantics are not -exactly C semantics. This is a bug, strictly speaking, but it's not one I -know how to fix. If @samp{x} is a program variable of type int, then it -is also type int to GDB, but @samp{x + 1} is long long, as is @samp{x + y} -or any other expression requiring computation. So is the expression -@samp{1}, or any other constant. You only really have to watch out for -calls. The innocuous expression @samp{list_node (0x80001234)} has an -argument of type long long. You must explicitly cast it to int. - -It is not possible to continue after an uncaught fatal signal by using -@samp{signal 0}, @samp{return}, @samp{jump}, or anything else. The difficulty is with -Unix, not GDB. - -I have made no big effort to make such things as single-stepping a -@kbd{join} instruction do something reasonable. If the program seems to -hang when doing this, type @kbd{ctrl-c} and @samp{cont}, or use -@samp{thread} to shift to a live thread. Single-stepping a @kbd{spawn} -instruction apparently causes new threads to be born with their T bit set; -this is not handled gracefully. When a thread has hit a breakpoint, other -threads may have invisibly hit the breakpoint in the background; if you -clear the breakpoint gdb will be surprised when threads seem to continue -to stop at it. All of these situations produce spurious signal 5 traps; -if this happens, just type @samp{cont}. If it becomes a nuisance, use -@samp{handle 5 nostop}. (It will ask if you are sure. You are.) - -There is no way in GDB to store a float in a register, as with -@kbd{set $s0 = 3.1416}. The identifier @kbd{$s0} denotes an integer, -and like any C expression which assigns to an integer variable, the -right-hand side is casted to type int. If you should need to do -something like this, you can assign the value to @kbd{@{float@} ($sp-4)} -and then do @kbd{set $s0 = $sp[-4]}. Same deal with @kbd{set $v0[69] = 6.9}. diff --git a/gdb/Makefile b/gdb/Makefile deleted file mode 100755 index 1bec69da6d0..00000000000 --- a/gdb/Makefile +++ /dev/null @@ -1,963 +0,0 @@ -M_MAKEFILE=./tconfig/none ./xconfig/none -srcdir=. -# "no target". -# This can be used to build you a Makefile that only runs administrative -# commands like 'clean', 'gdb.tar.Z', etc. -# Target config file for "no target". This can be used to build you -# a Makefile that only runs administrative commands like 'clean', -# 'gdb.tar.Z', etc. -# -# Copyright (C) 1990 Free Software Foundation, Inc. - -# This file is part of GDB. - -# GDB 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 1, or (at your option) -# any later version. - -# GDB 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 GDB; see the file COPYING. If not, write to -# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -ALLDEPFILES = $(ALLDEPFILES_MAINDIR) $(ALLDEPFILES_SUBDIR) -ALLDEPFILES_MAINDIR=\ -altos-xdep.c\ -am29k-pinsn.c\ -am29k-tdep.c\ -arm-convert.s\ -arm-pinsn.c\ -arm-tdep.c\ -arm-xdep.c\ -convex-pinsn.c\ -convex-tdep.c\ -convex-xdep.c\ -coredep.c\ -exec.c\ -gould-pinsn.c\ -gould-xdep.c\ -hp300ux-xdep.c\ -i386-pinsn.c\ -i386-tdep.c\ -i386-xdep.c\ -i960-pinsn.c\ -i960-tdep.c\ -infptrace.c\ -m68k-pinsn.c\ -m68k-tdep.c\ -m88k-pinsn.c\ -m88k-tdep.c\ -m88k-xdep.c\ -mips-pinsn.c\ -mips-tdep.c\ -mips-xdep.c\ -mipsread.c\ -news-xdep.c\ -nindy-tdep.c\ -ns32k-pinsn.c\ -pyr-pinsn.c\ -pyr-tdep.c\ -pyr-xdep.c\ -remote-eb.c\ -remote-nindy.c\ -remote-vx.c\ -solib.c\ -sparc-pinsn.c\ -sparc-tdep.c\ -sparc-xdep.c\ -sun3-xdep.c\ -sun386-xdep.c\ -symm-tdep.c\ -symm-xdep.c\ -tdesc.c\ -umax-xdep.c\ -vax-pinsn.c - -ALLDEPFILES_SUBDIR=\ -nindy-share/Onindy.c\ -nindy-share/nindy.c\ -nindy-share/ttybreak.c\ -nindy-share/ttyflush.c\ -vx-share/xdr_ld.c\ -vx-share/xdr_ptrace.c\ -vx-share/xdr_rdb.c\ -vx-share/xdr_regs.c - -ALLPARAM=\ -tm-29k.h\ -tm-3b1.h\ -tm-88k.h\ -tm-altos.h\ -tm-altosgas.h\ -tm-arm.h\ -tm-bigmips.h\ -tm-convex.h\ -tm-hp300bsd.h\ -tm-hp300hpux.h\ -tm-i386v-g.h\ -tm-i386v.h\ -tm-isi.h\ -tm-merlin.h\ -tm-mips.h\ -tm-news.h\ -tm-nindy960.h\ -tm-np1.h\ -tm-pn.h\ -tm-pyr.h\ -tm-sparc.h\ -tm-sun2.h\ -tm-sun2os4.h\ -tm-sun3.h\ -tm-sun386.h\ -tm-sun3os4.h\ -tm-sun4os4.h\ -tm-symmetry.h\ -tm-umax.h\ -tm-vax.h\ -tm-vx68.h\ -tm-vx960.h\ -xm-3b1.h\ -xm-88k.h\ -xm-altos.h\ -xm-arm.h\ -xm-bigmips.h\ -xm-convex.h\ -xm-hp300bsd.h\ -xm-hp300hpux.h\ -xm-i386v.h\ -xm-i386v32.h\ -xm-isi.h\ -xm-merlin.h\ -xm-mips.h\ -xm-news.h\ -xm-news1000.h\ -xm-np1.h\ -xm-pn.h\ -xm-pyr.h\ -xm-sparc.h\ -xm-sun2.h\ -xm-sun3.h\ -xm-sun386.h\ -xm-sun3os4.h\ -xm-sun4os4.h\ -xm-symmetry.h\ -xm-umax.h\ -xm-vax.h - -ALLCONFIG=\ -./tconfig/3b1\ -./tconfig/CVS.adm\ -./tconfig/altos\ -./tconfig/altosgas\ -./tconfig/am29k\ -./tconfig/arm\ -./tconfig/bigmips\ -./tconfig/convex\ -./tconfig/hp300bsd\ -./tconfig/hp300hpux\ -./tconfig/i386v\ -./tconfig/i386v-g\ -./tconfig/i386v32\ -./tconfig/i386v32-g\ -./tconfig/i960\ -./tconfig/isi\ -./tconfig/littlemips\ -./tconfig/m88k\ -./tconfig/m88k.orig\ -./tconfig/merlin\ -./tconfig/news\ -./tconfig/news1000\ -./tconfig/nindy960\ -./tconfig/none\ -./tconfig/np1\ -./tconfig/pn\ -./tconfig/pyramid\ -./tconfig/sun2os3\ -./tconfig/sun2os4\ -./tconfig/sun3\ -./tconfig/sun386\ -./tconfig/sun3os3\ -./tconfig/sun3os4\ -./tconfig/sun4\ -./tconfig/sun4os3\ -./tconfig/sun4os4\ -./tconfig/symmetry\ -./tconfig/umax\ -./tconfig/vax\ -./tconfig/vxworks68\ -./tconfig/vxworks960\ -./xconfig/3b1\ -./xconfig/CVS.adm\ -./xconfig/altos\ -./xconfig/altosgas\ -./xconfig/arm\ -./xconfig/bigmips\ -./xconfig/convex\ -./xconfig/hp300bsd\ -./xconfig/hp300hpux\ -./xconfig/i386v\ -./xconfig/i386v-g\ -./xconfig/i386v32\ -./xconfig/i386v32-g\ -./xconfig/isi\ -./xconfig/littlemips\ -./xconfig/m88k\ -./xconfig/m88k.orig\ -./xconfig/merlin\ -./xconfig/news\ -./xconfig/news1000\ -./xconfig/none\ -./xconfig/np1\ -./xconfig/pn\ -./xconfig/pyramid\ -./xconfig/sun2os3\ -./xconfig/sun2os4\ -./xconfig/sun3\ -./xconfig/sun386\ -./xconfig/sun3os3\ -./xconfig/sun3os4\ -./xconfig/sun4\ -./xconfig/sun4os3\ -./xconfig/sun4os4\ -./xconfig/symmetry\ -./xconfig/umax\ -./xconfig/vax - -##Copyright (C) 1989-1991 Free Software Foundation, Inc. - -# This file is part of GDB. - -# GDB 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 1, or (at your option) -# any later version. - -# GDB 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 GDB; see the file COPYING. If not, write to -# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - -# Place to install binaries. -bindir=/usr/local/bin - -# System V: If you compile gdb with a compiler which uses the coff -# encapsulation feature (this is a function of the compiler used, NOT -# of the m-?.h file selected by config.gdb), you must make sure that -# the GNU nm is the one that is used by munch. - -# If you are compiling with GCC, make sure that either 1) You use the -# -traditional flag, or 2) You have the fixed include files where GCC -# can reach them. Otherwise the ioctl calls in inflow.c and readline.c -# will be incorrectly compiled. The "fixincludes" script in the gcc -# distribution will fix your include files up. -#CC=cc -#CC=gcc -traditional -GCC=gcc - -VPATH=$(srcdir) - -# It is also possible that you will need to add -I/usr/include/sys to the -# CFLAGS section if your system doesn't have fcntl.h in /usr/include (which -# is where it should be according to Posix). - -YACC=bison -y -# YACC=yacc -SHELL=/bin/sh -MAKE=make -# We need either GNU m4 or SysV m4; Berkeley/Sun don't have quite enough. -#M4=gm4 -M4=/usr/5bin/m4 - -# Set this up with gcc if you have gnu ld and the loader will print out -# line numbers for undefinded refs. -#CC-LD=gcc -static -CC-LD=${CC} - -# define this to be "gmalloc.o" if you want to use the gnu malloc routine -# (useful for debugging memory allocation problems in gdb). To use your -# system malloc, uncomment the following two lines. -#GNU_MALLOC = -#MALLOC_CFLAGS = -DNO_MALLOC_CHECK -GNU_MALLOC = gmalloc.o mcheck.o mtrace.o -MALLOC_CFLAGS = - -# Where is the "include" directory? Traditionally ../include or ./include -INCLUDE_DIR = ${srcdir}/../include -INCLUDE_DEP = $$(INCLUDE_DIR) - -# Where is the source dir for the BFD library? Traditionally ../bfd or ./bfd -# (When we want the binary library built from it, we use ${BFD_DIR}${subdir}.) -BFD_DIR = ${srcdir}/../bfd -BFD_DEP = $$(BFD_DIR) - -# All the includes used for CFLAGS and for lint. -# -I. for config files. -# -I${srcdir} possibly for regex.h also. -INCLUDE_CFLAGS = -I. -I${srcdir} -I$(INCLUDE_DIR) -I${srcdir}/vx-share - -# {X,T}M_CFLAGS, if defined, has system-dependent CFLAGS. -# CFLAGS for both GDB and readline. -GLOBAL_CFLAGS = -g ${TM_CFLAGS} ${XM_CFLAGS} -#PROFILE_CFLAGS = -pg - -CFLAGS = ${GLOBAL_CFLAGS} ${PROFILE_CFLAGS} ${MALLOC_CFLAGS} ${INCLUDE_CFLAGS} -# None of the things in CFLAGS will do any harm, and on some systems -# (e.g. SunOS4) it is important to use the M_CFLAGS. -LDFLAGS = $(CFLAGS) - -# Where is the "-liberty" library, containing getopt and obstack? -LIBIBERTY_DIR = ${srcdir}/../libiberty -LIBIBERTY = ${LIBIBERTY_DIR}${subdir}/libiberty.a - -# Flags that describe where you can find the termcap library. -# You may need to make other arrangements for USG. -TERMCAP = -ltermcap - -# You must define REGEX and REGEX1 on USG machines. -# If your sysyem is missing alloca(), or, more likely, it's there but -# it doesn't work, define ALLOCA & ALLOCA1 - -# {X,T}M_CLIBS, if defined, has system-dependent libs -# For example, -lPW for System V to get alloca(). -# FIXME STOPGAP FOR BFD LIBRARY: BFD stuff -CLIBS = ${TERMCAP} $(XM_CLIBS) ${TM_CLIBS} ${BFD_DIR}${subdir}/libbfd.a \ - ${LIBIBERTY} -CDEPS = ${XM_CDEPS} ${TM_CDEPS} ${BFD_DIR}/libbfd.a \ - ${LIBIBERTY} - -ADD_FILES = ${REGEX} ${ALLOCA} ${GNU_MALLOC} -ADD_DEPS = ${REGEX1} ${ALLOCA1} ${GNU_MALLOC} - -VERSION = 3.95 -DIST=gdb-$(VERSION) - -LINT=/usr/5bin/lint -LINTFLAGS= - -# Source files in the main directory. -# Files which are included via a tconfig/* or xconfig/* file -# should *not* be specified here; they're in "ALLDEPFILES". -SFILES_MAINDIR = \ - blockframe.c breakpoint.c command.c core.c \ - environ.c eval.c expprint.c findvar.c infcmd.c inflow.c infrun.c \ - main.c printcmd.c \ - remote.c source.c stack.c symmisc.c symtab.c symfile.c \ - utils.c valarith.c valops.c valprint.c values.c expread.y \ - signame.c cplus-dem.c mem-break.c target.c inftarg.c \ - dbxread.c coffread.c \ - ieee-float.c - -# Source files in subdirectories (which will be handled separately by -# 'make gdb.tar.Z'). -# Files which are included via a tconfig/* or xconfig/* file -# should *not* be specified here; they're in "ALLDEPFILES". -SFILES_SUBDIR = \ - ${srcdir}/vx-share/dbgRpcLib.h \ - ${srcdir}/vx-share/ptrace.h \ - ${srcdir}/vx-share/reg.h \ - ${srcdir}/vx-share/vxTypes.h \ - ${srcdir}/vx-share/vxWorks.h \ - ${srcdir}/vx-share/wait.h \ - ${srcdir}/vx-share/xdr_ld.h \ - ${srcdir}/vx-share/xdr_ptrace.h \ - ${srcdir}/vx-share/xdr_rdb.h \ - ${srcdir}/vx-share/xdr_regs.h \ - ${srcdir}/nindy-share/Makefile \ - ${srcdir}/nindy-share/VERSION \ - ${srcdir}/nindy-share/b.out.h \ - ${srcdir}/nindy-share/block_io.h \ - ${srcdir}/nindy-share/coff.h \ - ${srcdir}/nindy-share/demux.h \ - ${srcdir}/nindy-share/env.h \ - ${srcdir}/nindy-share/stop.h \ - ${srcdir}/nindy-share/ttycntl.h - -# All source files that go into linking GDB, except config-specified files. -SFILES = $(SFILES_MAINDIR) $(SFILES_SUBDIR) - -# All source files that lint should look at -LINTFILES = $(SFILES) expread.tab.c init.c - -# Any additional files specified on these lines should also be added to -# the OTHERS = definition below, so they go in the tar files. -SFILES_STAND = $(SFILES) standalone.c -SFILES_KGDB = $(SFILES) stuff.c kdb-start.c - -# Header files that are not named in tconfig/* or xconfig/* go here. -HFILES= breakpoint.h command.h defs.h environ.h \ - expression.h frame.h gdbcmd.h gdbcore.h \ - getpagesize.h ieee-float.h inferior.h param-no-tm.h param.h \ - signals.h signame.h symfile.h symtab.h \ - target.h tdesc.h terminal.h tm-68k.h tm-i960.h tm-sunos.h \ - value.h - -OPCODES = pn-opcode.h np1-opcode.h sparc-opcode.h vax-opcode.h m68k-opcode.h \ - ns32k-opcode.h convx-opcode.h pyr-opcode.h mips-opcode.h \ - am29k-opcode.h - -REMOTE_EXAMPLES = rem-m68k.shar rem-multi.shar - -MALLOCSRC = gmalloc.c mcheck.c mtrace.c mtrace.awk \ - ansidecl.h stdlib.h gmalloc.h stddef.h - -POSSLIBS_MAINDIR = regex.c regex.h alloca.c $(MALLOCSRC) -POSSLIBS = $(POSSLIBS_MAINDIR) - -TESTS = testbpt.c testfun.c testrec.c testreg.c testregs.c - -# tdesc-lib cannot be named simply tdesc, because if if it were GNU make -# would try to make it from tdesc.c. -# tdesc-lib removed from the list due to Motorola copyrights...gnu@cygnus.com -OTHERS = Makefile.dist depend alldeps.mak Makefile.sdir \ - createtags munch config.gdb config.status \ - ChangeLog ChangeLog-3.x \ - README TODO TAGS WHATS.NEW \ - doc \ - .gdbinit COPYING expread.tab.c stab.def \ - copying.c Projects Convex.notes copying.awk \ - saber.suppress standalone.c stuff.c kdb-start.c \ - hp-include # tests - -DEPFILES= ${TDEPFILES} ${XDEPFILES} - -SOURCES=$(SFILES) $(ALLDEPFILES) -TAGFILES = $(SOURCES) ${HFILES} ${OPCODES} ${ALLPARAM} ${POSSLIBS} -TAGFILES_MAINDIR = $(SFILES_MAINDIR) $(ALLDEPFILES_MAINDIR) \ - ${HFILES} ${OPCODES} ${ALLPARAM} ${POSSLIBS_MAINDIR} -TARFILES = ${TAGFILES_MAINDIR} ${OTHERS} ${REMOTE_EXAMPLES} - -OBS = main.o blockframe.o breakpoint.o findvar.o stack.o source.o \ - values.o eval.o valops.o valarith.o valprint.o printcmd.o \ - symtab.o symfile.o symmisc.o infcmd.o infrun.o remote.o \ - command.o utils.o expread.o expprint.o environ.o version.o \ - copying.o $(DEPFILES) signame.o cplus-dem.o mem-break.o target.o \ - inftarg.o ieee-float.o putenv.o \ - dbxread.o coffread.o # mipsread.o - -RAPP_OBS = rgdb.o rudp.o rserial.o serial.o udp.o $(XDEPFILES) - -TSOBS = core.o inflow.o - -NTSOBS = standalone.o - -TSSTART = /lib/crt0.o - -NTSSTART = kdb-start.o - -RL_LIB = readline/libreadline.a -RL_LIB_DEP = $(RL_LIB) - -# 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. -.c.o: - ${CC} -c ${CFLAGS} $< - -all: gdb - -install: gdb - cp gdb $(bindir)/gdb.new - mv $(bindir)/gdb.new $(bindir)/gdb - $(M_INSTALL) - -init.c: $(srcdir)/munch $(MUNCH_DEFINE) $(OBS) $(TSOBS) - $(srcdir)/munch ${MUNCH_DEFINE} $(OBS) $(TSOBS) > init.c - -gdb: $(OBS) $(TSOBS) ${ADD_DEPS} ${RL_LIB_DEP} ${CDEPS} init.o - ${CC-LD} $(LDFLAGS) -o gdb init.o $(OBS) $(TSOBS) $(ADD_FILES) \ - ${RL_LIB} $(CLIBS) - -saber_gdb: $(SFILES) $(DEPFILES) copying.c version.c - #setopt load_flags $(CFLAGS) -I$(BFD_DIR) -DHOST_SYS=SUN4_SYS - #load ./init.c $(SFILES) - #unload ${srcdir}/expread.y ${srcdir}/vx-share/*.h - #unload ${srcdir}/nindy-share/[A-Z]* - #load ${srcdir}/expread.tab.c readline/libreadline.a - #load copying.c version.c - #load `echo " "$(DEPFILES) | sed -e 's/\.o/.c/g' -e 's, , ../,g'` - #load ${LIBIBERTY_DIR}/*.c - #load ${BFD_DIR}/*.c - #load -ltermcap - ##void mcheck(a) void (*a)(); { } - ##void mtrace() { } - - - -# This is useful when debugging GDB, because some Unix's don't let you run GDB -# on itself without copying the executable. So "make gdb1" will make -# gdb and put a copy in gdb1, and you can run it with "gdb gdb1". -# Removing gdb1 before the copy is the right thing if gdb1 is open -# in another process. -gdb1: gdb - rm -f gdb1 - cp gdb gdb1 - -# This is a remote stub which runs under unix and starts up an -# inferior process. This is at least useful for debugging GDB's -# remote support. -rapp: $(RAPP_OBS) - rm -f rapp_init.c - ${srcdir}/munch ${RAPP_OBS} > rapp_init.c - ${CC-LD} $(LDFLAGS) -o $@ rapp_init.c $(RAPP_OBS) - -Makefiles= Makefile.sdir $(M_MAKEFILE) \ - ${srcdir}/alldeps.mak ${srcdir}/Makefile.dist - -MAKE_MAKEFILE= echo "M_MAKEFILE=$(M_MAKEFILE)" | \ - cat - ${Makefiles} ${srcdir}/depend >Makefile - -Makefile: $(Makefiles) - $(MAKE_MAKEFILE) - -alldeps.mak: ${srcdir}/tconfig ${srcdir}/xconfig - rm -f alldeps.mak alldeps.tmp allparam.tmp allconfig.tmp - for i in `ls -d ${srcdir}/tconfig/*[0-9A-Za-z] \ - ${srcdir}/xconfig/*[0-9A-Za-z] | grep -v RCS` ; do \ - echo $$i >>allconfig.tmp; \ - awk <$$i ' \ - $$1 == "TDEPFILES=" || $$1 == "XDEPFILES=" { \ - for (i = 2; i <= NF; i++) \ - print $$i >> "alldeps.tmp" ; \ - } \ - $$1 == "TM_FILE=" || $$1 == "XM_FILE=" { \ - print $$2 >> "allparam.tmp" }' ; \ - done - sort alldeps2.tmp - echo 'ALLDEPFILES = $$(ALLDEPFILES_MAINDIR) $$(ALLDEPFILES_SUBDIR)' \ - >>alldeps.mak; - grep -v / alldeps2.tmp | \ - awk 'BEGIN {printf "ALLDEPFILES_MAINDIR="} \ - NR == 0 {printf $$0;} \ - NR != 0 {printf "\\\n" $$0} \ - END {printf "\n\n"}' >>alldeps.mak; - grep / alldeps2.tmp | \ - awk 'BEGIN {printf "ALLDEPFILES_SUBDIR="} \ - NR == 0 {printf $$0;} \ - NR != 0 {printf "\\\n" $$0} \ - END {printf "\n\n"}' >>alldeps.mak; - sort >alldeps.mak; - sort >alldeps.mak; - rm -f alldeps.tmp alldeps2.tmp allparam.tmp allconfig.tmp - -# The sed script makes everything which depends on {x,t}m.h depend on -# config.status as well, in case someone reconfigures gdb out from -# under an already compiled gdb. -depend: $(SOURCES) Makefile.dist - @echo Ignore errors about non-existent system-supplied include files - @echo for systems other than the one you are using. - @echo "If xm.h and tm.h don't exist, the error messages saying so" - @echo can safely be ignored. - @echo Also ignore parse errors in valops.c, and any errors in - @echo arm-convert.s. - -$(GCC) -MM $(CFLAGS) -I$(BFD_DIR) \ - `ls $(SOURCES) | sort -u` >depend.tmp - depend - $(MAKE_MAKEFILE) - rm depend.tmp - -config.status: - @echo "You must configure gdb. Look at the README file for details." - @false - -# These are not generated by "make depend" because they only are there -# for some machines. -# But these rules don't do what we want; we want to hack the foo.o: tm.h -# dependency to do the right thing. -tm-isi.h tm-sun3.h tm-news.h tm-hp300bsd.h tm-altos.h : tm-68k.h -tm-hp300hpux.h tm-sun2.h tm-3b1.h : tm-68k.h -xm-news1000.h : xm-news.h -xm-i386-sv32.h : xm-i386.h -tm-i386gas.h: tm-i386.h -xm-sun4os4.h : xm-sparc.h -tm-sun4os4.h : tm-sparc.h - -kdb : $(NTSSTART) $(OBS) $(NTSOBS) ${ADD_DEPS} ${RL_LIB_DEP} - rm -f init.c - $(srcdir)/munch ${MUNCH_DEFINE} $(OBS) $(NTSOBS) > init.c - $(CC) $(LDFLAGS) -c init.c $(CLIBS) - ld -o kdb $(NTSSTART) $(OBS) $(NTSOBS) init.o $(ADD_FILES) \ - ${RL_LIB} -lc $(CLIBS) - -# Put the proper machine-specific files first. -# createtags will edit the .o in DEPFILES into .c -TAGS: ${TAGFILES} - $(srcdir)/createtags $(TM_FILE) ${XM_FILE} $(DEPFILES) ${TAGFILES} -tags: TAGS - -# FIXME: Get alldeps.mak up to date, config.gdb none, THEN make gdb.tar.Z! -gdb.tar.Z: ${TARFILES} - rm -f gdb.tar; rm -rf $(DIST) - cd readline ; make readline.tar - mkdir $(DIST) - cd $(DIST) ; for i in ${TARFILES} ; do ln -s ../$$i . ; done - mkdir $(DIST)/readline - cd $(DIST)/readline ; tar xf ../../readline/readline.tar - mkdir $(DIST)/xconfig ${DIST}/tconfig - cd $(DIST)/tconfig ; \ - for i in $(ALLCONFIG) ; do ln -s ../../$$i ../$$i ; done - mkdir $(DIST)/vx-share $(DIST)/nindy-share - cd $(DIST)/tconfig ; \ - for i in $(SFILES_SUBDIR) $(ALLDEPFILES_SUBDIR); \ - do ln -s ../../$$i ../$$i ; done - tar chf - $(DIST) | compress >gdb.tar.Z - rm -rf $(DIST) - -clean: - rm -f ${OBS} ${TSOBS} ${NTSOBS} ${ADD_FILES} - rm -f init.c init.o version.c - rm -f gdb core gdb.tar gdb.tar.Z make.log - rm -f gdb[0-9] - rm -f gdb.dvi gdb-all* - cd readline ; make clean - -distclean: clean expread.tab.c TAGS - rm -f tm.h xm.h config.status - rm -f y.output yacc.acts yacc.tmp - rm -f ${TESTS} Makefile - -realclean: clean - rm -f expread.tab.c TAGS - rm -f tm.h xm.h config.status - rm -f Makefile - -gdb-all.texinfo: ${srcdir}/doc/gdb.texinfo - ${M4} $(srcdir)/doc/pretex.m4 $(srcdir)/doc/none.m4 $(srcdir)/doc/all.m4 $(srcdir)/doc/gdb.texinfo >gdb-all.texinfo - -gdb.dvi : gdb-all.texinfo - tex gdb-all.texinfo - texindex gdb-all.?? - tex gdb-all.texinfo - mv gdb-all.dvi gdb.dvi - rm -f gdb-all.?? gdb-all.??? - -# This should work eventually, but we're using texinfo2, and many makeinfo's -# can't cope with all the markup. In the meantime, we distribute the info -# files as formatted by the elisp texinfo2 code. -#gdb.info: gdb-all.texinfo -# makeinfo gdb-all.texinfo - -# Make copying.c from COPYING -copying.c : COPYING copying.awk - awk -f copying.awk < COPYING > copying.c - -version.c : Makefile.dist - echo 'char *version = "$(VERSION)";' >version.c - -${srcdir}/expread.tab.c : $(srcdir)/expread.y - @echo 'Expect 4 shift/reduce conflict.' - ${YACC} $(srcdir)/expread.y - mv y.tab.c ${srcdir}/expread.tab.c - -expread.o : ${srcdir}/expread.tab.c defs.h param.h symtab.h \ - frame.h expression.h - $(CC) -c ${CFLAGS} `echo ${srcdir}/expread.tab.c | sed 's,^\./,,'` - mv expread.tab.o expread.o - -# dbxread, coffread, mipsread have dependencies on BFD header files. -dbxread.o: ${srcdir}/dbxread.c - ${CC} -c ${CFLAGS} -I$(BFD_DIR) ${srcdir}/dbxread.c - -coffread.o: ${srcdir}/coffread.c - ${CC} -c ${CFLAGS} -I$(BFD_DIR) ${srcdir}/coffread.c - -mipsread.o: ${srcdir}/mipsread.c - ${CC} -c ${CFLAGS} -I$(BFD_DIR) ${srcdir}/mipsread.c - -# Drag in the files that are in another directory. - -xdr_ld.o: ${srcdir}/vx-share/xdr_ld.c - ${CC} -c ${CFLAGS} ${srcdir}/vx-share/xdr_ld.c - -xdr_ptrace.o: ${srcdir}/vx-share/xdr_ptrace.c - ${CC} -c ${CFLAGS} ${srcdir}/vx-share/xdr_ptrace.c - -xdr_rdb.o: ${srcdir}/vx-share/xdr_rdb.c - ${CC} -c ${CFLAGS} ${srcdir}/vx-share/xdr_rdb.c - -xdr_regs.o: ${srcdir}/vx-share/xdr_regs.c - ${CC} -c ${CFLAGS} ${srcdir}/vx-share/xdr_regs.c - -nindy.o: ${srcdir}/nindy-share/nindy.c - ${CC} -c ${CFLAGS} ${srcdir}/nindy-share/nindy.c - -Onindy.o: ${srcdir}/nindy-share/Onindy.c - ${CC} -c ${CFLAGS} ${srcdir}/nindy-share/Onindy.c - -ttybreak.o: ${srcdir}/nindy-share/ttybreak.c - ${CC} -c ${CFLAGS} ${srcdir}/nindy-share/ttybreak.c - -ttyflush.o: ${srcdir}/nindy-share/ttyflush.c - ${CC} -c ${CFLAGS} ${srcdir}/nindy-share/ttyflush.c - -tdesc-lib/libdc.o : force_update - cd tdesc-lib ; ${MAKE} "SYSV_DEFINE=${SYSV_DEFINE}" - -# In LOCAL_INCLUDES, -I${srcdir} is right if srcdir is an absolute path, -# and -I../${srcdir} is right if it is relative (e.g. ".."), so search both. -readline/libreadline.a : force_update - cd readline ; ${MAKE} "SYSV=${SYSV_DEFINE}"\ - "VPATH=${srcdir}/readline:../${srcdir}/readline"\ - "LOCAL_INCLUDES=-I../ -I${srcdir}/ -I../${srcdir}/"\ - "DEBUG_FLAGS=${GLOBAL_CFLAGS}" "CC=${CC}" libreadline.a - -lint: $(LINTFILES) - $(LINT) $(INCLUDE_CFLAGS) $(LINTFLAGS) $(LINTFILES) - -gdb.cxref: $(SFILES) - cxref -I. $(SFILES) >gdb.cxref - -force_update : - -# When used with GDB, the demangler should never look for leading -# underscores because GDB strips them off during symbol read-in. Thus -# -Dnounderscore. - -cplus-dem.o : cplus-dem.c - ${CC} -c ${CFLAGS} -Dnounderscore \ - `echo ${srcdir}/cplus-dem.c | sed 's,^\./,,'` -altos-xdep.o : altos-xdep.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status frame.h \ - inferior.h breakpoint.h value.h symtab.h gdbcore.h $(INCLUDE_DIR)/bfd.h \ - $(INCLUDE_DIR)/ansidecl.h -am29k-pinsn.o : am29k-pinsn.c defs.h target.h am29k-opcode.h -am29k-tdep.o : am29k-tdep.c defs.h gdbcore.h $(INCLUDE_DIR)/bfd.h \ - $(INCLUDE_DIR)/ansidecl.h $(INCLUDE_DIR)/obstack.h frame.h param.h tm.h config.status \ - param-no-tm.h xm.h config.status value.h symtab.h inferior.h breakpoint.h -arm-pinsn.o : arm-pinsn.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status symtab.h \ - arm-opcode.h -arm-tdep.o : arm-tdep.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status frame.h \ - inferior.h breakpoint.h value.h symtab.h arm-opcode.h gdbcore.h \ - $(INCLUDE_DIR)/bfd.h $(INCLUDE_DIR)/ansidecl.h -arm-xdep.o : arm-xdep.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status frame.h \ - inferior.h breakpoint.h value.h symtab.h arm-opcode.h gdbcore.h \ - $(INCLUDE_DIR)/bfd.h $(INCLUDE_DIR)/ansidecl.h -blockframe.o : blockframe.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status symtab.h \ - frame.h gdbcore.h $(INCLUDE_DIR)/bfd.h $(INCLUDE_DIR)/ansidecl.h value.h \ - target.h -breakpoint.o : breakpoint.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status symtab.h \ - frame.h breakpoint.h value.h expression.h gdbcore.h $(INCLUDE_DIR)/bfd.h \ - $(INCLUDE_DIR)/ansidecl.h gdbcmd.h command.h inferior.h target.h -coffread.o : coffread.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status symtab.h \ - breakpoint.h value.h $(INCLUDE_DIR)/bfd.h $(INCLUDE_DIR)/ansidecl.h symfile.h \ - $(BFD_DIR)/libcoff.h -command.o : command.c defs.h command.h symtab.h value.h -convex-pinsn.o : convex-pinsn.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status \ - symtab.h convx-opcode.h -convex-tdep.o : convex-tdep.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status \ - command.h symtab.h value.h frame.h inferior.h breakpoint.h \ - $(INCLUDE_DIR)/wait.h gdbcore.h $(INCLUDE_DIR)/bfd.h $(INCLUDE_DIR)/ansidecl.h \ - gdbcmd.h -convex-xdep.o : convex-xdep.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status \ - command.h symtab.h value.h frame.h inferior.h breakpoint.h \ - $(INCLUDE_DIR)/wait.h gdbcore.h $(INCLUDE_DIR)/bfd.h $(INCLUDE_DIR)/ansidecl.h \ - gdbcmd.h -core.o : core.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status frame.h inferior.h \ - breakpoint.h value.h symtab.h command.h $(INCLUDE_DIR)/bfd.h \ - $(INCLUDE_DIR)/ansidecl.h target.h gdbcore.h -coredep.o : coredep.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status gdbcore.h \ - $(INCLUDE_DIR)/bfd.h $(INCLUDE_DIR)/ansidecl.h $(INCLUDE_DIR)/obstack.h -cplus-dem.o : cplus-dem.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status -dbxread.o : dbxread.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status \ - $(INCLUDE_DIR)/a.out.gnu.h $(INCLUDE_DIR)/reloc.h $(INCLUDE_DIR)/stab.gnu.h \ - $(INCLUDE_DIR)/stab.def symtab.h breakpoint.h value.h command.h target.h \ - gdbcore.h $(INCLUDE_DIR)/bfd.h $(INCLUDE_DIR)/ansidecl.h $(BFD_DIR)/liba.out.h \ - symfile.h -environ.o : environ.c environ.h defs.h -eval.o : eval.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status symtab.h value.h \ - expression.h target.h frame.h -exec.o : exec.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status frame.h inferior.h \ - breakpoint.h value.h symtab.h target.h gdbcore.h $(INCLUDE_DIR)/bfd.h \ - $(INCLUDE_DIR)/ansidecl.h -expprint.o : expprint.c defs.h symtab.h param.h tm.h config.status param-no-tm.h xm.h config.status \ - expression.h value.h -findvar.o : findvar.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status symtab.h \ - frame.h value.h gdbcore.h $(INCLUDE_DIR)/bfd.h $(INCLUDE_DIR)/ansidecl.h \ - inferior.h breakpoint.h target.h -gould-pinsn.o : gould-pinsn.c gdbcore.h $(INCLUDE_DIR)/bfd.h \ - $(INCLUDE_DIR)/ansidecl.h $(INCLUDE_DIR)/obstack.h defs.h param.h tm.h config.status \ - param-no-tm.h xm.h config.status symtab.h frame.h np1-opcode.h -gould-xdep.o : gould-xdep.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status frame.h \ - inferior.h breakpoint.h value.h symtab.h gdbcore.h $(INCLUDE_DIR)/bfd.h \ - $(INCLUDE_DIR)/ansidecl.h -hp300ux-xdep.o : hp300ux-xdep.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status \ - frame.h inferior.h breakpoint.h value.h symtab.h gdbcore.h \ - $(INCLUDE_DIR)/bfd.h $(INCLUDE_DIR)/ansidecl.h -i386-pinsn.o : i386-pinsn.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status \ - gdbcore.h $(INCLUDE_DIR)/bfd.h $(INCLUDE_DIR)/ansidecl.h $(INCLUDE_DIR)/obstack.h -i386-tdep.o : i386-tdep.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status frame.h \ - inferior.h breakpoint.h value.h symtab.h gdbcore.h $(INCLUDE_DIR)/bfd.h \ - $(INCLUDE_DIR)/ansidecl.h -i386-xdep.o : i386-xdep.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status frame.h \ - inferior.h breakpoint.h value.h symtab.h gdbcore.h $(INCLUDE_DIR)/bfd.h \ - $(INCLUDE_DIR)/ansidecl.h -i960-pinsn.o : i960-pinsn.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status frame.h \ - inferior.h breakpoint.h value.h symtab.h -i960-tdep.o : i960-tdep.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status symtab.h \ - value.h frame.h signame.h ieee-float.h -ieee-float.o : ieee-float.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status \ - ieee-float.h -infcmd.o : infcmd.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status symtab.h frame.h \ - inferior.h breakpoint.h value.h environ.h gdbcmd.h command.h gdbcore.h \ - $(INCLUDE_DIR)/bfd.h $(INCLUDE_DIR)/ansidecl.h target.h -inflow.o : inflow.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status frame.h \ - inferior.h breakpoint.h value.h symtab.h command.h signals.h terminal.h \ - target.h -infptrace.o : infptrace.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status frame.h \ - inferior.h breakpoint.h value.h symtab.h target.h gdbcore.h \ - $(INCLUDE_DIR)/bfd.h $(INCLUDE_DIR)/ansidecl.h -infrun.o : infrun.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status symtab.h frame.h \ - inferior.h breakpoint.h value.h $(INCLUDE_DIR)/wait.h gdbcore.h \ - $(INCLUDE_DIR)/bfd.h $(INCLUDE_DIR)/ansidecl.h signame.h command.h terminal.h \ - target.h -inftarg.o : inftarg.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status frame.h \ - inferior.h breakpoint.h value.h symtab.h target.h $(INCLUDE_DIR)/wait.h \ - gdbcore.h $(INCLUDE_DIR)/bfd.h $(INCLUDE_DIR)/ansidecl.h ieee-float.h -m68k-pinsn.o : m68k-pinsn.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status symtab.h \ - m68k-opcode.h gdbcore.h $(INCLUDE_DIR)/bfd.h $(INCLUDE_DIR)/ansidecl.h -m68k-tdep.o : m68k-tdep.c defs.h ieee-float.h -main.o : main.c defs.h gdbcmd.h command.h param.h tm.h config.status param-no-tm.h xm.h config.status \ - symtab.h inferior.h breakpoint.h value.h frame.h signals.h target.h -mem-break.o : mem-break.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status -mips-pinsn.o : mips-pinsn.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status symtab.h \ - mips-opcode.h -mips-tdep.o : mips-tdep.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status frame.h \ - inferior.h breakpoint.h value.h symtab.h gdbcmd.h command.h gdbcore.h \ - $(INCLUDE_DIR)/bfd.h $(INCLUDE_DIR)/ansidecl.h -mips-xdep.o : mips-xdep.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status frame.h \ - inferior.h breakpoint.h value.h symtab.h gdbcore.h $(INCLUDE_DIR)/bfd.h \ - $(INCLUDE_DIR)/ansidecl.h -mipsread.o : mipsread.c param.h tm.h config.status param-no-tm.h xm.h config.status \ - $(INCLUDE_DIR)/obstack.h defs.h symtab.h gdbcore.h $(INCLUDE_DIR)/bfd.h \ - $(INCLUDE_DIR)/ansidecl.h symfile.h $(INCLUDE_DIR)/intel-coff.h -news-xdep.o : news-xdep.c -Onindy.o : ${srcdir}/nindy-share/Onindy.c ${srcdir}/nindy-share/ttycntl.h \ - ${srcdir}/nindy-share/block_io.h $(INCLUDE_DIR)/wait.h ${srcdir}/nindy-share/env.h \ - /usr/include/string.h -nindy.o : ${srcdir}/nindy-share/nindy.c ${srcdir}/nindy-share/ttycntl.h ${srcdir}/nindy-share/block_io.h \ - $(INCLUDE_DIR)/wait.h ${srcdir}/nindy-share/env.h /usr/include/string.h -ttybreak.o : ${srcdir}/nindy-share/ttybreak.c ${srcdir}/nindy-share/ttycntl.h -ttyflush.o : ${srcdir}/nindy-share/ttyflush.c ${srcdir}/nindy-share/ttycntl.h -nindy-tdep.o : nindy-tdep.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status symtab.h \ - frame.h -ns32k-pinsn.o : ns32k-pinsn.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status \ - symtab.h ns32k-opcode.h gdbcore.h $(INCLUDE_DIR)/bfd.h \ - $(INCLUDE_DIR)/ansidecl.h -printcmd.o : printcmd.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status frame.h \ - symtab.h value.h expression.h gdbcore.h $(INCLUDE_DIR)/bfd.h \ - $(INCLUDE_DIR)/ansidecl.h gdbcmd.h command.h target.h -pyr-pinsn.o : pyr-pinsn.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status symtab.h \ - pyr-opcode.h gdbcore.h $(INCLUDE_DIR)/bfd.h $(INCLUDE_DIR)/ansidecl.h -pyr-tdep.o : pyr-tdep.c -pyr-xdep.o : pyr-xdep.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status frame.h \ - inferior.h breakpoint.h value.h symtab.h gdbcore.h $(INCLUDE_DIR)/bfd.h \ - $(INCLUDE_DIR)/ansidecl.h -remote-eb.o : remote-eb.c defs.h tm-29k.h param-no-tm.h xm.h config.status inferior.h \ - breakpoint.h value.h symtab.h frame.h param.h $(INCLUDE_DIR)/wait.h \ - terminal.h target.h -remote-nindy.o : remote-nindy.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status \ - frame.h inferior.h breakpoint.h value.h symtab.h target.h gdbcore.h \ - $(INCLUDE_DIR)/bfd.h $(INCLUDE_DIR)/ansidecl.h command.h ieee-float.h \ - $(INCLUDE_DIR)/wait.h ${srcdir}/nindy-share/ttycntl.h ${srcdir}/nindy-share/demux.h \ - ${srcdir}/nindy-share/env.h ${srcdir}/nindy-share/stop.h -remote-vx.o : remote-vx.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status frame.h \ - inferior.h breakpoint.h value.h symtab.h $(INCLUDE_DIR)/wait.h target.h \ - gdbcore.h $(INCLUDE_DIR)/bfd.h $(INCLUDE_DIR)/ansidecl.h command.h symfile.h \ - ${srcdir}/vx-share/xdr_ptrace.h ${srcdir}/vx-share/xdr_regs.h ${srcdir}/vx-share/reg.h \ - ${srcdir}/vx-share/xdr_ld.h ${srcdir}/vx-share/xdr_rdb.h ${srcdir}/vx-share/dbgRpcLib.h -remote.o : remote.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status frame.h \ - inferior.h breakpoint.h value.h symtab.h target.h $(INCLUDE_DIR)/wait.h \ - terminal.h -signame.o : signame.c signame.h defs.h param.h tm.h config.status param-no-tm.h xm.h config.status -solib.o : solib.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status symtab.h gdbcore.h \ - $(INCLUDE_DIR)/bfd.h $(INCLUDE_DIR)/ansidecl.h command.h target.h frame.h -source.o : source.c defs.h symtab.h param.h tm.h config.status param-no-tm.h xm.h config.status \ - command.h gdbcmd.h frame.h gdbcore.h $(INCLUDE_DIR)/bfd.h \ - $(INCLUDE_DIR)/ansidecl.h regex.h -sparc-pinsn.o : sparc-pinsn.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status \ - symtab.h sparc-opcode.h gdbcore.h $(INCLUDE_DIR)/bfd.h \ - $(INCLUDE_DIR)/ansidecl.h /usr/include/string.h target.h -sparc-tdep.o : sparc-tdep.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status frame.h \ - inferior.h breakpoint.h value.h symtab.h signame.h target.h ieee-float.h \ - gdbcore.h $(INCLUDE_DIR)/bfd.h $(INCLUDE_DIR)/ansidecl.h -sparc-xdep.o : sparc-xdep.c defs.h tm-sparc.h param-no-tm.h xm.h config.status inferior.h \ - breakpoint.h value.h symtab.h frame.h param.h target.h gdbcore.h \ - $(INCLUDE_DIR)/bfd.h $(INCLUDE_DIR)/ansidecl.h -stack.o : stack.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status symtab.h frame.h \ - gdbcmd.h command.h value.h gdbcore.h $(INCLUDE_DIR)/bfd.h \ - $(INCLUDE_DIR)/ansidecl.h target.h breakpoint.h -sun3-xdep.o : sun3-xdep.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status inferior.h \ - breakpoint.h value.h symtab.h frame.h gdbcore.h $(INCLUDE_DIR)/bfd.h \ - $(INCLUDE_DIR)/ansidecl.h -sun386-xdep.o : sun386-xdep.c -symfile.o : symfile.c defs.h symtab.h param.h tm.h config.status param-no-tm.h xm.h config.status \ - gdbcore.h $(INCLUDE_DIR)/bfd.h $(INCLUDE_DIR)/ansidecl.h frame.h target.h \ - value.h symfile.h gdbcmd.h command.h breakpoint.h -symm-tdep.o : symm-tdep.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status frame.h \ - inferior.h breakpoint.h value.h symtab.h gdbcore.h $(INCLUDE_DIR)/bfd.h \ - $(INCLUDE_DIR)/ansidecl.h -symm-xdep.o : symm-xdep.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status frame.h \ - inferior.h breakpoint.h value.h symtab.h gdbcore.h $(INCLUDE_DIR)/bfd.h \ - $(INCLUDE_DIR)/ansidecl.h -symmisc.o : symmisc.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status symtab.h \ - breakpoint.h value.h command.h -symtab.o : symtab.c defs.h symtab.h param.h tm.h config.status param-no-tm.h xm.h config.status \ - gdbcore.h $(INCLUDE_DIR)/bfd.h $(INCLUDE_DIR)/ansidecl.h frame.h target.h \ - value.h symfile.h gdbcmd.h command.h -target.o : target.c defs.h target.h gdbcmd.h command.h symtab.h inferior.h \ - breakpoint.h value.h frame.h param.h tm.h config.status param-no-tm.h xm.h config.status \ - $(INCLUDE_DIR)/bfd.h $(INCLUDE_DIR)/ansidecl.h symfile.h -tdesc.o : tdesc.c -umax-xdep.o : umax-xdep.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status frame.h \ - inferior.h breakpoint.h value.h symtab.h gdbcore.h $(INCLUDE_DIR)/bfd.h \ - $(INCLUDE_DIR)/ansidecl.h -utils.o : utils.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status signals.h gdbcmd.h \ - command.h terminal.h $(INCLUDE_DIR)/bfd.h $(INCLUDE_DIR)/ansidecl.h \ - $(INCLUDE_DIR)/obstack.h target.h -valarith.o : valarith.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status value.h \ - symtab.h expression.h target.h -valops.o : valops.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status symtab.h value.h \ - frame.h inferior.h breakpoint.h gdbcore.h $(INCLUDE_DIR)/bfd.h \ - $(INCLUDE_DIR)/ansidecl.h target.h -valprint.o : valprint.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status symtab.h \ - value.h gdbcore.h $(INCLUDE_DIR)/bfd.h $(INCLUDE_DIR)/ansidecl.h gdbcmd.h \ - command.h target.h -values.o : values.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status symtab.h value.h \ - gdbcore.h $(INCLUDE_DIR)/bfd.h $(INCLUDE_DIR)/ansidecl.h frame.h command.h \ - gdbcmd.h -vax-pinsn.o : vax-pinsn.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status symtab.h \ - vax-opcode.h -xdr_ld.o : ${srcdir}/vx-share/xdr_ld.c ${srcdir}/vx-share/vxWorks.h ${srcdir}/vx-share/vxTypes.h \ - /usr/include/rpc/rpc.h ${srcdir}/vx-share/xdr_ld.h -xdr_ptrace.o : ${srcdir}/vx-share/xdr_ptrace.c -xdr_rdb.o : ${srcdir}/vx-share/xdr_rdb.c ${srcdir}/vx-share/vxWorks.h ${srcdir}/vx-share/vxTypes.h \ - ${srcdir}/vx-share/xdr_rdb.h -xdr_regs.o : ${srcdir}/vx-share/xdr_regs.c diff --git a/gdb/Makefile.dist b/gdb/Makefile.dist deleted file mode 100755 index 94040a59fc2..00000000000 --- a/gdb/Makefile.dist +++ /dev/null @@ -1,575 +0,0 @@ -##Copyright (C) 1989-1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. - -# Destination directory of the software tree build -destdir = /usr/local - -# Place to install binaries in the destination tree. -bindir=$(destdir)/bin - -# System V: If you compile gdb with a compiler which uses the coff -# encapsulation feature (this is a function of the compiler used, NOT -# of the m-?.h file selected by config.gdb), you must make sure that -# the GNU nm is the one that is used by munch. - -# If you are compiling with GCC, make sure that either 1) You use the -# -traditional flag, or 2) You have the fixed include files where GCC -# can reach them. Otherwise the ioctl calls in inflow.c -# will be incorrectly compiled. The "fixincludes" script in the gcc -# distribution will fix your include files up. -#CC=cc -#CC=gcc -traditional -GCC=gcc - -VPATH=$(srcdir) - -# It is also possible that you will need to add -I/usr/include/sys to the -# CFLAGS section if your system doesn't have fcntl.h in /usr/include (which -# is where it should be according to Posix). - -YACC=bison -y -# YACC=yacc -SHELL=/bin/sh -MAKE=make - -# Documentation (gdb.dvi) needs either GNU m4 or SysV m4; -# Berkeley/Sun don't have quite enough. -#M4=/usr/5bin/m4 -M4=gm4 -# where to find texinfo; if you have PostScript fonts you may want to try -# the Cygnus mods (which also have different header/footer layout) -#TEXIDIR=${srcdir}/../texinfo/cygnus -TEXIDIR=${srcdir}/../texinfo/fsf - -# Set this up with gcc if you have gnu ld and the loader will print out -# line numbers for undefinded refs. -#CC-LD=gcc -static -CC-LD=${CC} - -# define this to be "gmalloc.o" if you want to use the gnu malloc routine -# (useful for debugging memory allocation problems in gdb). To use your -# system malloc, uncomment the following two lines. -#GNU_MALLOC = -#MALLOC_CFLAGS = -DNO_MALLOC_CHECK -GNU_MALLOC = gmalloc.o mcheck.o mtrace.o -MALLOC_CFLAGS = - -# Where is the "include" directory? Traditionally ../include or ./include -INCLUDE_DIR = ${srcdir}/../include -INCLUDE_DEP = $$(INCLUDE_DIR) - -# Where is the source dir for the BFD library? Traditionally ../bfd or ./bfd -# (When we want the binary library built from it, we use ${BFD_DIR}${subdir}.) -BFD_DIR = ${srcdir}/../bfd -BFD_DEP = $$(BFD_DIR) -BFD_LIB = $(BFD_DIR)${subdir}/libbfd.a - -# Where is the source dir for the READLINE library? Traditionally in .. or . -# (For the binary library built from it, we use ${READLINE_DIR}${subdir}.) -READLINE_DIR = ${srcdir}/../readline -READLINE_DEP = $$(READLINE_DIR) -RL_LIB = $(READLINE_DIR)${subdir}/libreadline.a - -# All the includes used for CFLAGS and for lint. -# -I. for config files. -# -I${srcdir} possibly for regex.h also. -INCLUDE_CFLAGS = -I. -I${srcdir} -I$(INCLUDE_DIR) -I$(READLINE_DIR) -I${srcdir}/vx-share - -# {X,T}M_CFLAGS, if defined, has system-dependent CFLAGS. -# CFLAGS for GDB -GLOBAL_CFLAGS = -g ${TM_CFLAGS} ${XM_CFLAGS} -#PROFILE_CFLAGS = -pg - -CFLAGS = ${GLOBAL_CFLAGS} ${PROFILE_CFLAGS} ${MALLOC_CFLAGS} ${INCLUDE_CFLAGS} -# None of the things in CFLAGS will do any harm, and on some systems -# (e.g. SunOS4) it is important to use the M_CFLAGS. -LDFLAGS = $(CFLAGS) - -# Where is the "-liberty" library, containing getopt and obstack? -LIBIBERTY_DIR = ${srcdir}/../libiberty -LIBIBERTY = ${LIBIBERTY_DIR}${subdir}/libiberty.a - -# Flags that describe where you can find the termcap library. -# You may need to make other arrangements for USG. -TERMCAP = -ltermcap - -# The xconfig file must define REGEX and REGEX1 on USG machines. -# If your sysyem is missing alloca(), or, more likely, it's there but -# it doesn't work, define ALLOCA & ALLOCA1 too. -# If your system is missing putenv(), add putenv.c to XM_ADD_FILES. - -# Libraries and corresponding dependencies for compiling gdb. -# {X,T}M_CLIBS, defined in *config files, have host- and target-dependent libs. -# TERMCAP comes last, since readline depends on it. -CLIBS = $(XM_CLIBS) ${TM_CLIBS} ${BFD_LIB} ${LIBIBERTY} ${RL_LIB} ${TERMCAP} -CDEPS = ${XM_CDEPS} ${TM_CDEPS} ${BFD_LIB} ${LIBIBERTY} ${RL_LIB} - -ADD_FILES = ${REGEX} ${ALLOCA} ${GNU_MALLOC} ${XM_ADD_FILES} ${TM_ADD_FILES} -ADD_DEPS = ${REGEX1} ${ALLOCA1} ${GNU_MALLOC} ${XM_ADD_FILES} ${TM_ADD_FILES} - -VERSION = 3.96 -DIST=gdb-$(VERSION) - -LINT=/usr/5bin/lint -LINTFLAGS= - -# Source files in the main directory. -# Files which are included via a tconfig/* or xconfig/* file -# should *not* be specified here; they're in "ALLDEPFILES". -SFILES_MAINDIR = \ - blockframe.c breakpoint.c command.c core.c \ - environ.c eval.c expprint.c findvar.c infcmd.c inflow.c infrun.c \ - main.c printcmd.c \ - remote.c source.c stack.c symmisc.c symtab.c symfile.c \ - utils.c valarith.c valops.c valprint.c values.c expread.y \ - signame.c cplus-dem.c mem-break.c target.c inftarg.c \ - dbxread.c coffread.c \ - ieee-float.c - -# Source files in subdirectories (which will be handled separately by -# 'make gdb.tar.Z'). -# Files which are included via a tconfig/* or xconfig/* file -# should *not* be specified here; they're in "ALLDEPFILES". -SFILES_SUBDIR = \ - ${srcdir}/vx-share/dbgRpcLib.h \ - ${srcdir}/vx-share/ptrace.h \ - ${srcdir}/vx-share/reg.h \ - ${srcdir}/vx-share/vxTypes.h \ - ${srcdir}/vx-share/vxWorks.h \ - ${srcdir}/vx-share/wait.h \ - ${srcdir}/vx-share/xdr_ld.h \ - ${srcdir}/vx-share/xdr_ptrace.h \ - ${srcdir}/vx-share/xdr_rdb.h \ - ${srcdir}/vx-share/xdr_regs.h \ - ${srcdir}/nindy-share/Makefile \ - ${srcdir}/nindy-share/VERSION \ - ${srcdir}/nindy-share/b.out.h \ - ${srcdir}/nindy-share/block_io.h \ - ${srcdir}/nindy-share/coff.h \ - ${srcdir}/nindy-share/demux.h \ - ${srcdir}/nindy-share/env.h \ - ${srcdir}/nindy-share/stop.h \ - ${srcdir}/nindy-share/ttycntl.h - -# All source files that go into linking GDB, except config-specified files. -SFILES = $(SFILES_MAINDIR) $(SFILES_SUBDIR) - -# All source files that lint should look at -LINTFILES = $(SFILES) expread.tab.c init.c - -# Documentation source files -SFILES_DOCDIR = \ - ${srcdir}/doc/gdb.texinfo \ - ${srcdir}/doc/pretex.m4 \ - ${srcdir}/doc/none.m4 \ - ${srcdir}/doc/all.m4 \ - ${srcdir}/doc/gdb.alter-m4 \ - ${srcdir}/doc/gdb.bugs-m4 \ - ${srcdir}/doc/gdb.canned-m4 \ - ${srcdir}/doc/gdb.cmds-m4 \ - ${srcdir}/doc/gdb.ctl-m4 \ - ${srcdir}/doc/gdb.data-m4 \ - ${srcdir}/doc/gdb.emacs-m4 \ - ${srcdir}/doc/gdb.files-m4 \ - ${srcdir}/doc/gdb.gpl-m4 \ - ${srcdir}/doc/gdb.install-m4 \ - ${srcdir}/doc/gdb.inv.m-m4 \ - ${srcdir}/doc/gdb.inv.s-m4 \ - ${srcdir}/doc/gdb.invoc-m4 \ - ${srcdir}/doc/gdb.rdln-m4 \ - ${srcdir}/doc/gdb.rename-m4 \ - ${srcdir}/doc/gdb.run-m4 \ - ${srcdir}/doc/gdb.sample-m4 \ - ${srcdir}/doc/gdb.src-m4 \ - ${srcdir}/doc/gdb.stack-m4 \ - ${srcdir}/doc/gdb.stop-m4 \ - ${srcdir}/doc/gdb.symb-m4 \ - ${srcdir}/doc/gdb.tgts-m4 \ - ${srcdir}/doc/gdb.top-m4 - -# Any additional files specified on these lines should also be added to -# the OTHERS = definition below, so they go in the tar files. -SFILES_STAND = $(SFILES) standalone.c -SFILES_KGDB = $(SFILES) stuff.c kdb-start.c - -# Header files that are not named in tconfig/* or xconfig/* go here. -HFILES= breakpoint.h command.h defs.h environ.h \ - expression.h frame.h gdbcmd.h gdbcore.h \ - getpagesize.h ieee-float.h inferior.h param-no-tm.h param.h \ - signals.h signame.h symfile.h symtab.h \ - target.h tdesc.h terminal.h tm-68k.h tm-i960.h tm-sunos.h \ - value.h - -# Header files for machine opcode tables. -# when OPCODE_DIR changes to ../include, remove the whole $(OPCODES) -# business, since they will be included in the separate includes tar file -# rather than in the gdb tar file. -OPCODE_DIR = -OPCODES = $(OPCODE_DIR)pn-opcode.h $(OPCODE_DIR)np1-opcode.h \ - $(OPCODE_DIR)sparc-opcode.h $(OPCODE_DIR)vax-opcode.h \ - $(OPCODE_DIR)m68k-opcode.h $(OPCODE_DIR)ns32k-opcode.h \ - $(OPCODE_DIR)convx-opcode.h $(OPCODE_DIR)pyr-opcode.h \ - $(OPCODE_DIR)mips-opcode.h $(OPCODE_DIR)am29k-opcode.h \ - $(OPCODE_DIR)arm-opcode.h $(OPCODE_DIR)m88k-opcode.h \ - $(OPCODE_DIR)tahoe-opcode.h - -REMOTE_EXAMPLES = m68k-stub.c i386-stub.c rem-multi.shar - -MALLOCSRC = gmalloc.c mcheck.c mtrace.c mtrace.awk \ - ansidecl.h gmalloc.h - -POSSLIBS_MAINDIR = regex.c regex.h alloca.c $(MALLOCSRC) -POSSLIBS = $(POSSLIBS_MAINDIR) - -TESTS = testbpt.c testfun.c testrec.c testreg.c testregs.c - -# tdesc-lib cannot be named simply tdesc, because if it were, GNU make -# would try to make it from tdesc.c. -# tdesc-lib removed from the list due to Motorola copyrights...gnu@cygnus.com -OTHERS = Makefile Makefile.dist depend alldeps.mak Makefile.sdir \ - createtags munch config.gdb config.status \ - ChangeLog ChangeLog-3.x \ - README TODO TAGS WHATS.NEW Projects \ - .gdbinit COPYING expread.tab.c \ - copying.c Convex.notes copying.awk \ - saber.suppress standalone.c stuff.c kdb-start.c \ - putenv.c - -# Subdirectories of gdb, which should be included in their entirety in -# gdb-xxx.tar.Z: -TARDIRS = doc hp-include # tests - -DEPFILES= ${TDEPFILES} ${XDEPFILES} - -SOURCES=$(SFILES) $(ALLDEPFILES) -TAGFILES = $(SOURCES) ${HFILES} ${OPCODES} ${ALLPARAM} ${POSSLIBS} -TAGFILES_MAINDIR = $(SFILES_MAINDIR) $(ALLDEPFILES_MAINDIR) \ - ${HFILES} ${OPCODES} ${ALLPARAM} ${POSSLIBS_MAINDIR} -TARFILES = ${TAGFILES_MAINDIR} ${OTHERS} ${REMOTE_EXAMPLES} - -OBS = main.o blockframe.o breakpoint.o findvar.o stack.o source.o \ - values.o eval.o valops.o valarith.o valprint.o printcmd.o \ - symtab.o symfile.o symmisc.o infcmd.o infrun.o remote.o \ - command.o utils.o expread.o expprint.o environ.o version.o \ - copying.o $(DEPFILES) signame.o cplus-dem.o mem-break.o target.o \ - inftarg.o ieee-float.o putenv.o \ - dbxread.o coffread.o # mipsread.o - -RAPP_OBS = rgdb.o rudp.o rserial.o serial.o udp.o $(XDEPFILES) - -TSOBS = core.o inflow.o - -NTSOBS = standalone.o - -TSSTART = /lib/crt0.o - -NTSSTART = kdb-start.o - -# 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. -.c.o: - ${CC} -c ${CFLAGS} $< - -all: gdb - -install: gdb - cp gdb $(bindir)/gdb.new - mv $(bindir)/gdb.new $(bindir)/gdb - $(M_INSTALL) - -init.c: $(srcdir)/munch $(MUNCH_DEFINE) $(OBS) $(TSOBS) - $(srcdir)/munch ${MUNCH_DEFINE} $(OBS) $(TSOBS) > init.c - -gdb: $(OBS) $(TSOBS) ${ADD_DEPS} ${CDEPS} init.o - ${CC-LD} $(LDFLAGS) -o gdb init.o $(OBS) $(TSOBS) $(ADD_FILES) \ - $(CLIBS) - -saber_gdb: $(SFILES) $(DEPFILES) copying.c version.c - #setopt load_flags $(CFLAGS) -I$(BFD_DIR) -DHOST_SYS=SUN4_SYS - #load ./init.c $(SFILES) - #unload ${srcdir}/expread.y ${srcdir}/vx-share/*.h - #unload ${srcdir}/nindy-share/[A-Z]* - #load ${srcdir}/expread.tab.c - #load copying.c version.c - #load `echo " "$(DEPFILES) | sed -e 's/\.o/.c/g' -e 's, , ../,g'` - #load ${LIBIBERTY_DIR}/*.c - #load ${BFD_DIR}/*.c - #load ${READLINE_DIR}/*.c - #load -ltermcap - ##void mcheck(a) void (*a)(); { } - ##void mtrace() { } - - - -# This is useful when debugging GDB, because some Unix's don't let you run GDB -# on itself without copying the executable. So "make gdb1" will make -# gdb and put a copy in gdb1, and you can run it with "gdb gdb1". -# Removing gdb1 before the copy is the right thing if gdb1 is open -# in another process. -gdb1: gdb - rm -f gdb1 - cp gdb gdb1 - -# This is a remote stub which runs under unix and starts up an -# inferior process. This is at least useful for debugging GDB's -# remote support. -rapp: $(RAPP_OBS) - rm -f rapp_init.c - ${srcdir}/munch ${RAPP_OBS} > rapp_init.c - ${CC-LD} $(LDFLAGS) -o $@ rapp_init.c $(RAPP_OBS) - -# Support for building Makefile out of configured pieces, automatically -# generated dependencies, etc. -Makefiles= Makefile.sdir $(M_MAKEFILE) \ - ${srcdir}/alldeps.mak ${srcdir}/Makefile.dist - -MAKE_MAKEFILE= echo "M_MAKEFILE=$(M_MAKEFILE)" | \ - cat - ${Makefiles} ${srcdir}/depend > Makefile - -Makefile: $(Makefiles) - $(MAKE_MAKEFILE) - -alldeps.mak: ${srcdir}/tconfig ${srcdir}/xconfig - rm -f alldeps.mak alldeps.tmp allparam.tmp allconfig.tmp - for i in `ls -d ${srcdir}/tconfig/*[0-9A-Za-z] \ - ${srcdir}/xconfig/*[0-9A-Za-z] | \ - grep -v RCS | grep -v CVS.adm | grep -v SCCS` ; do \ - echo $$i >>allconfig.tmp; \ - awk <$$i ' \ - $$1 == "TDEPFILES=" || $$1 == "XDEPFILES=" { \ - for (i = 2; i <= NF; i++) \ - print $$i >> "alldeps.tmp" ; \ - } \ - $$1 == "TM_FILE=" || $$1 == "XM_FILE=" { \ - print $$2 >> "allparam.tmp" }' ; \ - done - sort alldeps2.tmp - echo 'ALLDEPFILES = $$(ALLDEPFILES_MAINDIR) $$(ALLDEPFILES_SUBDIR)' \ - >>alldeps.mak; - grep -v / alldeps2.tmp | \ - awk 'BEGIN {printf "ALLDEPFILES_MAINDIR="} \ - NR == 0 {printf $$0;} \ - NR != 0 {printf "\\\n" $$0} \ - END {printf "\n\n"}' >>alldeps.mak; - grep / alldeps2.tmp | \ - awk 'BEGIN {printf "ALLDEPFILES_SUBDIR="} \ - NR == 0 {printf $$0;} \ - NR != 0 {printf "\\\n" $$0} \ - END {printf "\n\n"}' >>alldeps.mak; - sort >alldeps.mak; - sort >alldeps.mak; - rm -f alldeps.tmp alldeps2.tmp allparam.tmp allconfig.tmp - -# The sed script makes everything which depends on {x,t}m.h depend on -# config.status as well, in case someone reconfigures gdb out from -# under an already compiled gdb. -depend: $(SOURCES) Makefile.dist - @echo Ignore errors about non-existent system-supplied include files - @echo for systems other than the one you are using. - @echo "If xm.h and tm.h don't exist, the error messages saying so" - @echo can safely be ignored. - @echo Also ignore parse errors in valops.c, and any errors in - @echo arm-convert.s. - -$(GCC) -MM $(CFLAGS) -I$(BFD_DIR) \ - `ls $(SOURCES) | grep -v \.h$$ |sort -u` >depend.tmp - depend - $(MAKE_MAKEFILE) - rm depend.tmp - -config.status: - @echo "You must configure gdb. Look at the README file for details." - @false - -# These are not generated by "make depend" because they only are there -# for some machines. -# But these rules don't do what we want; we want to hack the foo.o: tm.h -# dependency to do the right thing. -tm-isi.h tm-sun3.h tm-news.h tm-hp300bsd.h tm-altos.h : tm-68k.h -tm-hp300hpux.h tm-sun2.h tm-3b1.h : tm-68k.h -xm-news1000.h : xm-news.h -xm-i386-sv32.h : xm-i386.h -tm-i386gas.h: tm-i386.h -xm-sun4os4.h : xm-sparc.h -tm-sun4os4.h : tm-sparc.h - -kdb : $(NTSSTART) $(OBS) $(NTSOBS) ${ADD_DEPS} ${CDEPS} - rm -f init.c - $(srcdir)/munch ${MUNCH_DEFINE} $(OBS) $(NTSOBS) > init.c - $(CC) $(LDFLAGS) -c init.c $(CLIBS) - ld -o kdb $(NTSSTART) $(OBS) $(NTSOBS) init.o $(ADD_FILES) \ - -lc $(CLIBS) - -# Put the proper machine-specific files first. -# createtags will edit the .o in DEPFILES into .c -TAGS: ${TAGFILES} - $(srcdir)/createtags $(TM_FILE) ${XM_FILE} $(DEPFILES) ${TAGFILES} -tags: TAGS - -# FIXME: Get alldeps.mak up to date, config.gdb none, THEN make gdb.tar.Z! -gdb.tar.Z: ${TARFILES} ${TARDIRS} - rm -f gdb.tar; rm -rf $(DIST) - mkdir $(DIST) - cd $(DIST) ; for i in ${TARFILES} ; do ln -s ../$$i . ; done - cd $(DIST); for i in ${TARDIRS}; do \ - (mkdir $$i; cd $$i; \ - ln -s ../../$$i/* .; \ - rm -rf SCCS CVS.adm RCS); done - mkdir $(DIST)/xconfig ${DIST}/tconfig - cd $(DIST)/tconfig ; \ - for i in $(ALLCONFIG) ; do ln -s ../../$$i ../$$i ; done - mkdir $(DIST)/vx-share $(DIST)/nindy-share - cd $(DIST)/tconfig ; \ - for i in $(SFILES_SUBDIR) $(ALLDEPFILES_SUBDIR); \ - do ln -s ../../$$i ../$$i ; done - tar chf - $(DIST) | compress >gdb.tar.Z - rm -rf $(DIST) - -clean: - rm -f ${OBS} ${TSOBS} ${NTSOBS} ${ADD_FILES} - rm -f init.c init.o version.c - rm -f gdb core gdb.tar gdb.tar.Z make.log - rm -f gdb[0-9] - rm -f gdb.dvi rdl-apps.texinfo gdb-all* - -distclean: clean expread.tab.c TAGS - rm -f tm.h xm.h config.status - rm -f y.output yacc.acts yacc.tmp - rm -f ${TESTS} Makefile - -realclean: clean - rm -f expread.tab.c TAGS - rm -f tm.h xm.h config.status - rm -f Makefile - -rdl-apps.texinfo: ${READLINE_DIR}/inc-readline.texinfo \ - ${READLINE_DIR}/inc-history.texinfo - echo "@include ${READLINE_DIR}/inc-readline.texinfo" >rdl-apps.texinfo - echo "@include ${READLINE_DIR}/inc-history.texinfo" >>rdl-apps.texinfo - -gdb-all.texinfo: ${SFILES_DOCDIR} - ( cd $(srcdir)/doc; \ - ${M4} pretex.m4 none.m4 all.m4 gdb.texinfo ) >gdb-all.texinfo - -gdb.dvi : gdb-all.texinfo rdl-apps.texinfo - TEXINPUTS=${TEXIDIR}:$$TEXINPUTS tex gdb-all.texinfo - texindex gdb-all.?? - TEXINPUTS=${TEXIDIR}:$$TEXINPUTS tex gdb-all.texinfo - mv gdb-all.dvi gdb.dvi - rm -f gdb-all.?? gdb-all.??? - -# This should work eventually, but we're using texinfo2, and many makeinfo's -# can't cope with all the markup. In the meantime, we distribute the info -# files as formatted by the elisp texinfo2 code. -#gdb.info: gdb-all.texinfo -# makeinfo gdb-all.texinfo - -# Make copying.c from COPYING -copying.c : COPYING copying.awk - awk -f copying.awk < COPYING > copying.c - -version.c : Makefile.dist - echo 'char *version = "$(VERSION)";' >version.c - -${srcdir}/expread.tab.c : $(srcdir)/expread.y - @echo 'Expect 4 shift/reduce conflict.' - ${YACC} $(srcdir)/expread.y - mv y.tab.c ${srcdir}/expread.tab.c - -expread.o : ${srcdir}/expread.tab.c defs.h param.h symtab.h \ - frame.h expression.h - $(CC) -c ${CFLAGS} `echo ${srcdir}/expread.tab.c | sed 's,^\./,,'` - mv expread.tab.o expread.o - -# dbxread, coffread, mipsread have dependencies on BFD header files. -dbxread.o: ${srcdir}/dbxread.c - ${CC} -c ${CFLAGS} -I$(BFD_DIR) ${srcdir}/dbxread.c - -coffread.o: ${srcdir}/coffread.c - ${CC} -c ${CFLAGS} -I$(BFD_DIR) ${srcdir}/coffread.c - -mipsread.o: ${srcdir}/mipsread.c - ${CC} -c ${CFLAGS} -I$(BFD_DIR) ${srcdir}/mipsread.c - -# Drag in the files that are in another directory. - -xdr_ld.o: ${srcdir}/vx-share/xdr_ld.c - ${CC} -c ${CFLAGS} ${srcdir}/vx-share/xdr_ld.c - -xdr_ptrace.o: ${srcdir}/vx-share/xdr_ptrace.c - ${CC} -c ${CFLAGS} ${srcdir}/vx-share/xdr_ptrace.c - -xdr_rdb.o: ${srcdir}/vx-share/xdr_rdb.c - ${CC} -c ${CFLAGS} ${srcdir}/vx-share/xdr_rdb.c - -xdr_regs.o: ${srcdir}/vx-share/xdr_regs.c - ${CC} -c ${CFLAGS} ${srcdir}/vx-share/xdr_regs.c - -nindy.o: ${srcdir}/nindy-share/nindy.c - ${CC} -c ${CFLAGS} ${srcdir}/nindy-share/nindy.c - -Onindy.o: ${srcdir}/nindy-share/Onindy.c - ${CC} -c ${CFLAGS} ${srcdir}/nindy-share/Onindy.c - -ttybreak.o: ${srcdir}/nindy-share/ttybreak.c - ${CC} -c ${CFLAGS} ${srcdir}/nindy-share/ttybreak.c - -ttyflush.o: ${srcdir}/nindy-share/ttyflush.c - ${CC} -c ${CFLAGS} ${srcdir}/nindy-share/ttyflush.c - -tdesc-lib/libdc.o : force_update - cd tdesc-lib ; ${MAKE} "SYSV_DEFINE=${SYSV_DEFINE}" - -lint: $(LINTFILES) - $(LINT) $(INCLUDE_CFLAGS) $(LINTFLAGS) $(LINTFILES) - -gdb.cxref: $(SFILES) - cxref -I. $(SFILES) >gdb.cxref - -force_update : - -# When used with GDB, the demangler should never look for leading -# underscores because GDB strips them off during symbol read-in. Thus -# -Dnounderscore. - -cplus-dem.o : cplus-dem.c - ${CC} -c ${CFLAGS} -Dnounderscore \ - `echo ${srcdir}/cplus-dem.c | sed 's,^\./,,'` diff --git a/gdb/Makefile.in b/gdb/Makefile.in deleted file mode 100644 index 11f577bd6c5..00000000000 --- a/gdb/Makefile.in +++ /dev/null @@ -1,732 +0,0 @@ -##Copyright (C) 1989-1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. - -# Host and target-dependent makefile fragments come in here. -#### -# End of host and target-dependent makefile fragments - -# Destination directory of the software tree build -ddestdir = /usr/local - -# Place to install binaries in the destination tree. -bindir=$(ddestdir)/bin - -# System V: If you compile gdb with a compiler which uses the coff -# encapsulation feature (this is a function of the compiler used, NOT -# of the m-?.h file selected by config.gdb), you must make sure that -# the GNU nm is the one that is used by munch. - -# If you are compiling with GCC, make sure that either 1) You use the -# -traditional flag, or 2) You have the fixed include files where GCC -# can reach them. Otherwise the ioctl calls in inflow.c -# will be incorrectly compiled. The "fixincludes" script in the gcc -# distribution will fix your include files up. -#CC=cc -#CC=gcc -traditional -GCC=gcc - -# Directory containing source files. Don't clean up the spacing, -# this exact string is matched for by the "configure" script. -srcdir = . - -# It is also possible that you will need to add -I/usr/include/sys to the -# CFLAGS section if your system doesn't have fcntl.h in /usr/include (which -# is where it should be according to Posix). - -BISON=bison -y -BISONFLAGS= -YACC=$(BISON) $(BISONFLAGS) -# YACC=yacc -SHELL=/bin/sh -MAKE=make - -# Documentation (gdb.dvi) needs either GNU m4 or SysV m4; -# Berkeley/Sun don't have quite enough. -#M4=/usr/5bin/m4 -M4=gm4 - -# where to find texinfo; GDB dist should include a recent one -TEXIDIR=${srcdir}/../texinfo/fsf - -# where to find makeinfo, preferably one designed for texinfo-2 -MAKEINFO=makeinfo - -# Set this up with gcc if you have gnu ld and the loader will print out -# line numbers for undefinded refs. -#CC-LD=gcc -static -CC-LD=${CC} - -# define this to be "gmalloc.o" if you want to use the gnu malloc routine -# (useful for debugging memory allocation problems in gdb). To use your -# system malloc, uncomment the following two lines. -#GNU_MALLOC = -#MALLOC_CFLAGS = -DNO_MALLOC_CHECK -GNU_MALLOC = gmalloc.o mcheck.o mtrace.o -MALLOC_CFLAGS = - -# Where is the "include" directory? Traditionally ../include or ./include -INCLUDE_DIR = ${srcdir}/../include -INCLUDE_DEP = $$(INCLUDE_DIR) - -# Where is the source dir for the BFD library? Traditionally ../bfd or ./bfd -# (When we want the binary library built from it, we use ${BFD_DIR}${subdir}.) -BFD_DIR = ${srcdir}/../bfd -BFD_DEP = $$(BFD_DIR) -BFD_LIB = $(unsubdir)/../bfd${subdir}/libbfd.a - -# Where is the source dir for the READLINE library? Traditionally in .. or . -# (For the binary library built from it, we use ${READLINE_DIR}${subdir}.) -READLINE_DIR = ${srcdir}/../readline -READLINE_DEP = $$(READLINE_DIR) -RL_LIB = $(unsubdir)/../readline${subdir}/libreadline.a - -# All the includes used for CFLAGS and for lint. -# -I. for config files. -# -I${srcdir} possibly for regex.h also. -INCLUDE_CFLAGS = -I. -I${srcdir} -I$(INCLUDE_DIR) -I$(READLINE_DIR) -I${srcdir}/vx-share - -# {X,T}M_CFLAGS, if defined, has system-dependent CFLAGS. -# CFLAGS for GDB -MINUS_G=-g -GLOBAL_CFLAGS = $(MINUS_G) ${TM_CFLAGS} ${XM_CFLAGS} -#PROFILE_CFLAGS = -pg - -CFLAGS = ${GLOBAL_CFLAGS} ${PROFILE_CFLAGS} ${MALLOC_CFLAGS} ${INCLUDE_CFLAGS} -# None of the things in CFLAGS will do any harm, and on some systems -# (e.g. SunOS4) it is important to use the M_CFLAGS. -LDFLAGS = $(CFLAGS) - -# Where is the "-liberty" library, containing getopt and obstack? -LIBIBERTY_DIR = ${srcdir}/../libiberty -LIBIBERTY = $(unsubdir)/../libiberty${subdir}/libiberty.a - -# Flags that describe where you can find the termcap library. -# You may need to make other arrangements for USG. -TERMCAP = -ltermcap - -# The xconfig file must define REGEX and REGEX1 on USG machines. -# If your sysyem is missing alloca(), or, more likely, it's there but -# it doesn't work, define ALLOCA & ALLOCA1 too. -# If your system is missing putenv(), add putenv.c to XM_ADD_FILES. - -# Libraries and corresponding dependencies for compiling gdb. -# {X,T}M_CLIBS, defined in *config files, have host- and target-dependent libs. -# TERMCAP comes after readline, since readline depends on it. -CLIBS = ${BFD_LIB} ${RL_LIB} ${TERMCAP} ${LIBIBERTY} ${XM_CLIBS} ${TM_CLIBS} -CDEPS = ${XM_CDEPS} ${TM_CDEPS} ${BFD_LIB} ${LIBIBERTY} ${RL_LIB} - -ADD_FILES = ${REGEX} ${ALLOCA} ${GNU_MALLOC} ${XM_ADD_FILES} ${TM_ADD_FILES} -ADD_DEPS = ${REGEX1} ${ALLOCA1} ${GNU_MALLOC} ${XM_ADD_FILES} ${TM_ADD_FILES} - -VERSION = 4.2.3 -DIST=gdb - -LINT=/usr/5bin/lint -LINTFLAGS= -I${BFD_DIR} - -# Source files in the main directory. -# Files which are included via a tconfig/* or xconfig/* file -# should *not* be specified here; they're in "ALLDEPFILES". -SFILES_MAINDIR = \ - blockframe.c breakpoint.c command.c core.c \ - environ.c eval.c expprint.c findvar.c infcmd.c inflow.c infrun.c \ - main.c printcmd.c \ - remote.c source.c stack.c symmisc.c symtab.c symfile.c \ - utils.c valarith.c valops.c valprint.c values.c c-exp.y m2-exp.y \ - signame.c cplus-dem.c mem-break.c target.c inftarg.c \ - dbxread.c coffread.c elfread.c dwarfread.c xcoffread.c \ - ieee-float.c language.c parse.c buildsym.c - -# Source files in subdirectories (which will be handled separately by -# 'make gdb.tar.Z'). -# Files which are included via a tconfig/* or xconfig/* file -# should *not* be specified here; they're in "ALLDEPFILES". -SFILES_SUBDIR = \ - ${srcdir}/vx-share/dbgRpcLib.h \ - ${srcdir}/vx-share/ptrace.h \ - ${srcdir}/vx-share/reg.h \ - ${srcdir}/vx-share/vxTypes.h \ - ${srcdir}/vx-share/vxWorks.h \ - ${srcdir}/vx-share/wait.h \ - ${srcdir}/vx-share/xdr_ld.h \ - ${srcdir}/vx-share/xdr_ptrace.h \ - ${srcdir}/vx-share/xdr_rdb.h \ - ${srcdir}/vx-share/xdr_regs.h \ - ${srcdir}/nindy-share/b.out.h \ - ${srcdir}/nindy-share/block_io.h \ - ${srcdir}/nindy-share/coff.h \ - ${srcdir}/nindy-share/demux.h \ - ${srcdir}/nindy-share/env.h \ - ${srcdir}/nindy-share/stop.h \ - ${srcdir}/nindy-share/ttycntl.h - -# Non-source files in subdirs, that should go into gdb.tar.Z. -NONSRC_SUBDIR = \ - ${srcdir}/nindy-share/Makefile \ - ${srcdir}/nindy-share/VERSION - -# All source files that go into linking GDB, except config-specified files. -SFILES = $(SFILES_MAINDIR) $(SFILES_SUBDIR) - -# All source files that lint should look at -LINTFILES = $(SFILES) $(YYFILES) init.c - -# Any additional files specified on these lines should also be added to -# the OTHERS = definition below, so they go in the tar files. -SFILES_STAND = $(SFILES) standalone.c -SFILES_KGDB = $(SFILES) stuff.c kdb-start.c - -# Header files that are not named in tconfig/* or xconfig/* go here. -HFILES= breakpoint.h command.h defs.h environ.h \ - expression.h frame.h gdbcmd.h gdbcore.h getpagesize.h \ - ieee-float.h inferior.h minimon.h param-no-tm.h param.h \ - signals.h signame.h symfile.h symtab.h \ - target.h tdesc.h terminal.h tm-68k.h tm-i960.h tm-sunos.h \ - language.h parser-defs.h value.h - -# Header files for machine opcode tables. -# when OPCODE_DIR changes to ../include, remove the whole $(OPCODES) -# business, since they will be included in the separate includes tar file -# rather than in the gdb tar file. -OPCODE_DIR = -OPCODES = $(OPCODE_DIR)pn-opcode.h $(OPCODE_DIR)np1-opcode.h \ - $(OPCODE_DIR)sparc-opcode.h $(OPCODE_DIR)vax-opcode.h \ - $(OPCODE_DIR)m68k-opcode.h $(OPCODE_DIR)ns32k-opcode.h \ - $(OPCODE_DIR)convx-opcode.h $(OPCODE_DIR)pyr-opcode.h \ - $(OPCODE_DIR)mips-opcode.h $(OPCODE_DIR)am29k-opcode.h \ - $(OPCODE_DIR)arm-opcode.h $(OPCODE_DIR)m88k-opcode.h \ - $(OPCODE_DIR)tahoe-opcode.h - -REMOTE_EXAMPLES = m68k-stub.c i386-stub.c rem-multi.shar - -MALLOCSRC = gmalloc.c mcheck.c mtrace.c mtrace.awk \ - ansidecl.h gmalloc.h - -POSSLIBS_MAINDIR = regex.c regex.h alloca.c $(MALLOCSRC) -POSSLIBS = $(POSSLIBS_MAINDIR) - -TESTS = testbpt.c testfun.c testrec.c testreg.c testregs.c - -# tdesc-lib cannot be named simply tdesc, because if it were, GNU make -# would try to make it from tdesc.c. -OTHERS = Makefile.in depend alldeps.mak createtags munch configure.in \ - ChangeLog ChangeLog-3.x refcard.ps \ - README TODO TAGS WHATS.NEW Projects \ - .gdbinit COPYING $(YYFILES) \ - copying.c Convex.notes copying.awk \ - saber.suppress standalone.c stuff.c tdesc-lib kdb-start.c \ - putenv.c - -# Subdirectories of gdb, which should be included in their entirety in -# gdb-xxx.tar.Z: -TARDIRS = doc # tests - -# GDB "info" files, which should be included in their entirety -INFOFILES = gdb.info* - -DEPFILES= ${TDEPFILES} ${XDEPFILES} - -SOURCES=$(SFILES) $(ALLDEPFILES) $(YYFILES) -TAGFILES = $(SOURCES) ${HFILES} ${OPCODES} ${ALLPARAM} ${POSSLIBS} -TAGFILES_MAINDIR = $(SFILES_MAINDIR) $(ALLDEPFILES_MAINDIR) \ - ${HFILES} ${OPCODES} ${ALLPARAM} ${POSSLIBS_MAINDIR} -TARFILES = ${TAGFILES_MAINDIR} ${OTHERS} ${REMOTE_EXAMPLES} - -OBS = main.o blockframe.o breakpoint.o findvar.o stack.o source.o \ - values.o eval.o valops.o valarith.o valprint.o printcmd.o \ - symtab.o symfile.o symmisc.o infcmd.o infrun.o remote.o \ - command.o utils.o expprint.o environ.o version.o \ - copying.o $(DEPFILES) signame.o cplus-dem.o mem-break.o target.o \ - inftarg.o ieee-float.o putenv.o parse.o language.o $(YYOBJ) \ - buildsym.o \ - dbxread.o coffread.o elfread.o dwarfread.o xcoffread.o # mipsread.o - -RAPP_OBS = rgdb.o rudp.o rserial.o serial.o udp.o $(XDEPFILES) - -TSOBS = core.o inflow.o - -NTSOBS = standalone.o - -TSSTART = /lib/crt0.o - -NTSSTART = kdb-start.o - -SUBDIRS = doc - -# For now, shortcut the "configure GDB for fewer languages" stuff. -YYFILES = c-exp.tab.c m2-exp.tab.c -YYOBJ = c-exp.tab.o m2-exp.tab.o - -# 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. -.c.o: - ${CC} -c ${CFLAGS} $< - -all: gdb - $(MAKE) subdir_do DO=all "DODIRS=$(SUBDIRS)" -all-info: force - $(MAKE) subdir_do DO=all-info "DODIRS=$(SUBDIRS)" -install-info: force - $(MAKE) subdir_do DO=install "DODIRS=$(SUBDIRS)" - -gdb.z:gdb.1 - nroff -man gdb.1 | col -b > gdb.t - pack gdb.t ; rm -f gdb.t - mv gdb.t.z gdb.z - -install: gdb gdb.z - cp gdb $(bindir)/gdb.new - mv $(bindir)/gdb.new $(bindir)/gdb - $(M_INSTALL) - $(MAKE) subdir_do DO=install "DODIRS=$(SUBDIRS)" - -init.c: $(srcdir)/munch $(OBS) $(TSOBS) - $(srcdir)/munch ${MUNCH_DEFINE} $(OBS) $(TSOBS) > init.c - -gdb: $(OBS) $(TSOBS) ${ADD_DEPS} ${CDEPS} init.o - ${CC-LD} $(LDFLAGS) -o gdb init.o $(OBS) $(TSOBS) $(ADD_FILES) \ - $(CLIBS) $(LOADLIBES) - -saber_gdb: $(SFILES) $(DEPFILES) copying.c version.c - #setopt load_flags $(CFLAGS) -I$(BFD_DIR) -DHOST_SYS=SUN4_SYS - #load ./init.c $(SFILES) - #unload ${srcdir}/c-exp.y ${srcdir}/m2-exp.y ${srcdir}/vx-share/*.h - #unload ${srcdir}/nindy-share/[A-Z]* - #load c-exp.tab.c m2-exp.tab.c - #load copying.c version.c - #load `echo " "$(DEPFILES) | sed -e 's/\.o/.c/g' -e 's, , ../,g'` - #load ${LIBIBERTY_DIR}/*.c - #load ${BFD_DIR}/*.c - #load ${READLINE_DIR}/*.c - #load -ltermcap - ##void mcheck(a) void (*a)(); { } - ##void mtrace() { } - - - -# This is useful when debugging GDB, because some Unix's don't let you run GDB -# on itself without copying the executable. So "make gdb1" will make -# gdb and put a copy in gdb1, and you can run it with "gdb gdb1". -# Removing gdb1 before the copy is the right thing if gdb1 is open -# in another process. -gdb1: gdb - rm -f gdb1 - cp gdb gdb1 - -# This is a remote stub which runs under unix and starts up an -# inferior process. This is at least useful for debugging GDB's -# remote support. -rapp: $(RAPP_OBS) - rm -f rapp_init.c - ${srcdir}/munch ${MUNCH_DEFINE} ${RAPP_OBS} > rapp_init.c - ${CC-LD} $(LDFLAGS) -o $@ rapp_init.c $(RAPP_OBS) - -# Support for building Makefile out of configured pieces, automatically -# generated dependencies, etc. alldeps.mak is a file that contains -# "make" variable definitions for all ALLDEPFILES, ALLDEPFILES_MAINDIR, -# ALLDEPFILES_SUBDIR, ALLPARAM, and ALLCONFIG, all cadged from the current -# contents of the xconfig and tconfig subdirectories. - -alldeps.mak: ${srcdir}/tconfig ${srcdir}/xconfig - rm -f alldeps.mak alldeps.tmp allparam.tmp allconfig.tmp - for i in `ls -d ${srcdir}/tconfig/*[0-9A-Za-z] \ - ${srcdir}/xconfig/*[0-9A-Za-z] | \ - grep -v RCS | grep -v CVS.adm | grep -v SCCS` ; do \ - echo $$i >>allconfig.tmp; \ - awk <$$i ' \ - $$1 == "TDEPFILES=" || $$1 == "XDEPFILES=" { \ - for (i = 2; i <= NF; i++) \ - print $$i >> "alldeps.tmp" ; \ - } \ - $$1 == "TM_FILE=" || $$1 == "XM_FILE=" { \ - print $$2 >> "allparam.tmp" }' ; \ - done - sort alldeps2.tmp - echo '# Start of "alldeps.mak" definitions' \ - >>alldeps.mak; - echo 'ALLDEPFILES = $$(ALLDEPFILES_MAINDIR) $$(ALLDEPFILES_SUBDIR)' \ - >>alldeps.mak; - grep -v / alldeps2.tmp | \ - awk 'BEGIN {printf "ALLDEPFILES_MAINDIR="} \ - NR == 0 {printf $$0;} \ - NR != 0 {printf "\\\n" $$0} \ - END {printf "\n\n"}' >>alldeps.mak; - grep / alldeps2.tmp | \ - awk 'BEGIN {printf "ALLDEPFILES_SUBDIR="} \ - NR == 0 {printf $$0;} \ - NR != 0 {printf "\\\n" $$0} \ - END {printf "\n\n"}' >>alldeps.mak; - sort >alldeps.mak; - sort >alldeps.mak; - echo '# End of "alldeps.mak" definitions' \ - >>alldeps.mak; - rm -f alldeps.tmp alldeps2.tmp allparam.tmp allconfig.tmp - -# The sed script makes everything which depends on {x,t}m.h depend on -# config.status as well, in case someone reconfigures gdb out from -# under an already compiled gdb. -depend: $(SOURCES) Makefile.in - @echo Ignore errors about non-existent system-supplied include files - @echo for systems other than the one you are using. - @echo "If xm.h and tm.h don't exist, the error messages saying so" - @echo can safely be ignored. - @echo Also ignore parse errors in valops.c, and any errors in - @echo arm-convert.s. - -$(GCC) -MM $(CFLAGS) -I$(BFD_DIR) \ - `ls $(SOURCES) | grep -v '\.[hy]$$' |sort -u` >depend.tmp -# If running in srcdir, translate "./foo.c" into "$srcdir/foo.c" except -# for xm.h and tm.h. This allows the same "depend" file to be used -# by the various subdirectories. - if [ "${srcdir}" = "." ] ; then \ - depend.tm2; \ - rm depend.tmp; \ - mv depend.tm2 depend.tmp; \ - fi - depend - rm depend.tmp - -config.status: - @echo "You must configure gdb. Look at the README file for details." - @false - -# These are not generated by "make depend" because they only are there -# for some machines. -# But these rules don't do what we want; we want to hack the foo.o: tm.h -# dependency to do the right thing. -tm-isi.h tm-sun3.h tm-news.h tm-hp300bsd.h tm-altos.h : tm-68k.h -tm-hp300hpux.h tm-sun2.h tm-3b1.h : tm-68k.h -xm-news1000.h : xm-news.h -xm-i386-sv32.h : xm-i386.h -tm-i386gas.h: tm-i386.h -xm-sun4os4.h : xm-sparc.h -tm-sun4os4.h : tm-sparc.h - -kdb : $(NTSSTART) $(OBS) $(NTSOBS) ${ADD_DEPS} ${CDEPS} - rm -f init.c - $(srcdir)/munch ${MUNCH_DEFINE} $(OBS) $(NTSOBS) > init.c - $(CC) $(LDFLAGS) -c init.c $(CLIBS) - ld -o kdb $(NTSSTART) $(OBS) $(NTSOBS) init.o $(ADD_FILES) \ - -lc $(CLIBS) - -# Put the proper machine-specific files first. -# createtags will edit the .o in DEPFILES into .c -TAGS: ${TAGFILES} - $(srcdir)/createtags $(TM_FILE) ${XM_FILE} $(DEPFILES) ${TAGFILES} -tags: TAGS - -# Making distributions of GDB and friends. - -# Make a directory `proto-gdb.dir' that contains an image of the GDB -# directory of the distribution, built up with symlinks. -make-proto-gdb.dir: force_update - $(MAKE) $(MFLAGS) -f Makefile.in setup-to-dist - $(MAKE) $(MFLAGS) -f Makefile make-proto-gdb-1 - -# Make a tar file containing the GDB directory of the distribution. -gdb.tar.Z: force_update - $(MAKE) $(MFLAGS) -f Makefile.in setup-to-dist - $(MAKE) $(MFLAGS) -f Makefile.in gdb-$(VERSION).tar.Z - -# Set up the GDB directory for distribution, by building all files that -# are products of other files. -setup-to-dist: force_update - ../configure none - rm -f alldeps.mak - $(MAKE) $(MFLAGS) alldeps.mak - ../configure none - rm -f depend - $(MAKE) $(MFLAGS) depend - ../configure none - (cd doc; $(MAKE) $(MFLAGS) rdl-apps.texi gdbVN.m4) - $(MAKE) $(MFLAGS) gdb.info - $(MAKE) $(MFLAGS) refcard.ps - -# Build a tar file from a proto-gdb.dir. -gdb-$(VERSION).tar.Z: force_update - rm -f gdb.tar gdb-$(VERSION).tar.Z - $(MAKE) $(MFLAGS) -f Makefile make-proto-gdb-1 - ln -s proto-gdb.dir $(DIST) - tar chf - $(DIST) | compress >gdb-$(VERSION).tar.Z - rm -rf $(DIST) proto-gdb.dir - -# Build a proto-gdb.dir after GDB has been set up for distribution. -# This stuff must be run in `Makefile', not `Makefile.in`; we use the makefile -# built in the setup-to-dist process, since it defines things like ALLCONFIG -# and ALLDEPFILES, that we need. -make-proto-gdb-1: ${TARFILES} ${TARDIRS} gdb.info - rm -rf proto-gdb.dir - mkdir proto-gdb.dir - cd proto-gdb.dir ; for i in ${TARFILES} ; do ln -s ../$$i . ; done - cd proto-gdb.dir ; ln -s ../${INFOFILES} . - cd proto-gdb.dir ; for i in ${TARDIRS}; do \ - (mkdir $$i; cd $$i; \ - ln -s ../../$$i/* .; \ - rm -rf SCCS CVS.adm RCS); done - mkdir proto-gdb.dir/xconfig proto-gdb.dir/tconfig - cd proto-gdb.dir/tconfig ; \ - for i in $(ALLCONFIG) ; do ln -s ../../$$i ../$$i ; done - mkdir proto-gdb.dir/vx-share proto-gdb.dir/nindy-share - cd proto-gdb.dir/tconfig ; \ - for i in $(SFILES_SUBDIR) $(NONSRC_SUBDIR) $(ALLDEPFILES_SUBDIR); \ - do ln -s ../../$$i ../$$i ; done - chmod og=u `find . -print` - -clean: - rm -f ${OBS} ${TSOBS} ${NTSOBS} ${ADD_FILES} - rm -f init.c init.o version.c - rm -f gdb core gdb.tar gdb.tar.Z make.log - rm -f gdb[0-9] - $(MAKE) subdir_do DO=clean "DODIRS=$(SUBDIRS)" - -distclean: clean c-exp.tab.c m2-exp.tab.c TAGS - rm -f tm.h xm.h config.status - rm -f y.output yacc.acts yacc.tmp - rm -f ${TESTS} Makefile depend - $(MAKE) subdir_do DO=distclean "DODIRS=$(SUBDIRS)" - -realclean: clean - rm -f c-exp.tab.c m2-exp.tab.c TAGS - rm -f tm.h xm.h config.status - rm -f Makefile depend - $(MAKE) subdir_do DO=realclean "DODIRS=$(SUBDIRS)" - -STAGESTUFF=${OBS} ${TSOBS} ${NTSOBS} ${ADD_FILES} init.c init.o version.c gdb - -subdir_do: force - for i in $(DODIRS); do \ - if [ -d $(unsubdir)/$$i ] ; then \ - if (cd $(unsubdir)/$$i$(subdir); \ - $(MAKE) \ - "against=$(against)" \ - "AR=$(AR)" \ - "CC=$(CC)" \ - "AR_FLAGS=$(AR_FLAGS)" \ - "RANLIB=$(RANLIB)" \ - "BISON=$(BISON)" $(DO)) ; then true ; \ - else exit 1 ; fi ; \ - else true ; fi ; \ - done - -# Copy the object files from a particular stage into a subdirectory. -stage1: force - -mkdir stage1 - -mv -f $(STAGESTUFF) stage1 - $(MAKE) subdir_do DO=stage1 "DODIRS=$(SUBDIRS)" - -stage2: force - -mkdir stage2 - -mv -f $(STAGESTUFF) stage2 - $(MAKE) subdir_do DO=stage2 "DODIRS=$(SUBDIRS)" - -stage3: force - -mkdir stage3 - -mv -f $(STAGESTUFF) stage3 - $(MAKE) subdir_do DO=stage3 "DODIRS=$(SUBDIRS)" - -against=stage2 - -comparison: force - for i in $(STAGESTUFF) ; do cmp $$i $(against)/$$i ; done - $(MAKE) subdir_do DO=comparison "DODIRS=$(SUBDIRS)" - -de-stage1: force - - (cd stage1 ; mv -f * ..) - - rmdir stage1 - $(MAKE) subdir_do DO=de-stage1 "DODIRS=$(SUBDIRS)" - -de-stage2: force - - (cd stage2 ; mv -f * ..) - - rmdir stage2 - $(MAKE) subdir_do DO=de-stage2 "DODIRS=$(SUBDIRS)" - -de-stage3: force - - (cd stage3 ; mv -f * ..) - - rmdir stage3 - $(MAKE) subdir_do DO=de-stage3 "DODIRS=$(SUBDIRS)" - -Makefile: $(srcdir)/Makefile.in $(host_makefile_frag) $(target_makefile_frag) - $(SHELL) ./config.status - -force: - -# Documentation! -# GDB QUICK REFERENCE (TeX dvi file, CM fonts) -refcard.dvi : $(srcdir)/doc/refcard.tex - ( cd $(srcdir)/doc; $(MAKE) refcard.dvi ) - mv $(srcdir)/doc/refcard.dvi . - -# GDB QUICK REFERENCE (PostScript output, common PS fonts) -refcard.ps : $(srcdir)/doc/refcard.tex - ( cd $(srcdir)/doc; $(MAKE) refcard.ps ) - mv $(srcdir)/doc/refcard.ps . - -# GDB MANUAL: TeX dvi file -gdb.dvi : $(srcdir)/doc/gdb-all.texi $(srcdir)/doc/rdl-apps.texi - ( cd $(srcdir)/doc; $(MAKE) M4=$(M4) gdb.dvi ) - mv $(srcdir)/doc/gdb.dvi . - -# GDB MANUAL: info file -gdb.info: $(srcdir)/doc/gdb-all.texi - ( cd $(srcdir)/doc; $(MAKE) M4=$(M4) gdb.info ) - mv $(srcdir)/doc/gdb.info* . - -$(srcdir)/doc/gdb-all.texi: - (cd $(srcdir)/doc; $(MAKE) M4=$(M4) gdb-all.texi) -$(srcdir)/doc/rdl-apps.texi: - (cd $(srcdir)/doc; $(MAKE) rdl-apps.texi) - -# Make copying.c from COPYING -copying.c: ${srcdir}/COPYING ${srcdir}/copying.awk - awk -f ${srcdir}/copying.awk < ${srcdir}/COPYING > copying.c - -version.c : Makefile.in - echo 'char *version = "$(VERSION)";' >version.c - -# c-exp.tab.c is generated in target dir from c-exp.y if it doesn't exist -# in srcdir, then compiled in target dir to c-exp.tab.o. -c-exp.tab.o: c-exp.tab.c -c-exp.tab.c: $(srcdir)/c-exp.y - @echo 'Expect 4 shift/reduce conflicts.' - ${YACC} $(srcdir)/c-exp.y - - mv y.tab.c c-exp.tab.c - -# m2-exp.tab.c is generated in target dir from m2-exp.y if it doesn't exist -# in srcdir, then compiled in target dir to m2-exp.tab.o. -m2-exp.tab.o: m2-exp.tab.c -m2-exp.tab.c: $(srcdir)/m2-exp.y - ${YACC} $(srcdir)/m2-exp.y - - mv y.tab.c m2-exp.tab.c - -# The symbol-file readers have dependencies on BFD header files. -dbxread.o: ${srcdir}/dbxread.c - ${CC} -c ${CFLAGS} -I$(BFD_DIR) ${srcdir}/dbxread.c - -coffread.o: ${srcdir}/coffread.c - ${CC} -c ${CFLAGS} -I$(BFD_DIR) ${srcdir}/coffread.c - -mipsread.o: ${srcdir}/mipsread.c - ${CC} -c ${CFLAGS} -I$(BFD_DIR) ${srcdir}/mipsread.c - -elfread.o: ${srcdir}/elfread.c - ${CC} -c ${CFLAGS} -I$(BFD_DIR) ${srcdir}/elfread.c - -xcoffread.o: ${srcdir}/xcoffread.c - ${CC} -c ${CFLAGS} -I$(BFD_DIR) ${srcdir}/xcoffread.c - -xcoffexec.o: ${srcdir}/xcoffexec.c - ${CC} -c ${CFLAGS} -I$(BFD_DIR) ${srcdir}/xcoffexec.c - -# Drag in the files that are in another directory. - -xdr_ld.o: ${srcdir}/vx-share/xdr_ld.c - ${CC} -c ${CFLAGS} ${srcdir}/vx-share/xdr_ld.c - -xdr_ptrace.o: ${srcdir}/vx-share/xdr_ptrace.c - ${CC} -c ${CFLAGS} ${srcdir}/vx-share/xdr_ptrace.c - -xdr_rdb.o: ${srcdir}/vx-share/xdr_rdb.c - ${CC} -c ${CFLAGS} ${srcdir}/vx-share/xdr_rdb.c - -xdr_regs.o: ${srcdir}/vx-share/xdr_regs.c - ${CC} -c ${CFLAGS} ${srcdir}/vx-share/xdr_regs.c - -nindy.o: ${srcdir}/nindy-share/nindy.c - ${CC} -c ${CFLAGS} ${srcdir}/nindy-share/nindy.c - -Onindy.o: ${srcdir}/nindy-share/Onindy.c - ${CC} -c ${CFLAGS} ${srcdir}/nindy-share/Onindy.c - -ttybreak.o: ${srcdir}/nindy-share/ttybreak.c - ${CC} -c ${CFLAGS} ${srcdir}/nindy-share/ttybreak.c - -ttyflush.o: ${srcdir}/nindy-share/ttyflush.c - ${CC} -c ${CFLAGS} ${srcdir}/nindy-share/ttyflush.c - -disasm.o: $(srcdir)/tdesc-lib/disasm.c - $(CC) -c $(CFLAGS) $(srcdir)/tdesc-lib/disasm.c - -classify.o: $(srcdir)/tdesc-lib/classify.c - $(CC) -c $(CFLAGS) $(srcdir)/tdesc-lib/classify.c - -fcns.o: $(srcdir)/tdesc-lib/fcns.c - $(CC) -c $(CFLAGS) $(srcdir)/tdesc-lib/fcns.c - -table.o: $(TABHDRS) $(srcdir)/tdesc-lib/table.c - $(CC) -c $(CFLAGS) $(srcdir)/tdesc-lib/table.c - -lint: $(LINTFILES) - $(LINT) $(INCLUDE_CFLAGS) $(LINTFLAGS) $(LINTFILES) \ - `echo ${DEPFILES} | sed 's/\.o /\.c /g' - -gdb.cxref: $(SFILES) - cxref -I. $(SFILES) >gdb.cxref - -force_update : - -# When used with GDB, the demangler should never look for leading -# underscores because GDB strips them off during symbol read-in. Thus -# -Dnounderscore. - -cplus-dem.o : cplus-dem.c - ${CC} -c ${CFLAGS} -Dnounderscore \ - `echo ${srcdir}/cplus-dem.c | sed 's,^\./,,'` - -# GNU Make has an annoying habit of putting *all* the Makefile variables -# into the environment, unless you include this target as a circumvention. -# Rumor is that this will be fixed (and this target can be removed) -# in GNU Make 4.0. -.NOEXPORT: - -# This is the end of "Makefile.in". When built into "Makefile" -# by the configure script, two things are added below this point: -# alldeps.mak -- defintions of all files that are used in -# host- or target-dependent configurations -# depend -- what .o files depend on what .c and .h files, -# for all configurations. - - diff --git a/gdb/Makefile.sdir b/gdb/Makefile.sdir deleted file mode 100755 index b5fb6b3f64f..00000000000 --- a/gdb/Makefile.sdir +++ /dev/null @@ -1 +0,0 @@ -srcdir=. diff --git a/gdb/Makefile.srcdir b/gdb/Makefile.srcdir deleted file mode 100755 index b5fb6b3f64f..00000000000 --- a/gdb/Makefile.srcdir +++ /dev/null @@ -1 +0,0 @@ -srcdir=. diff --git a/gdb/Projects b/gdb/Projects deleted file mode 100644 index 2c215df9385..00000000000 --- a/gdb/Projects +++ /dev/null @@ -1,94 +0,0 @@ - - Suggested projects for aspiring or current GDB hackers - ====================================================== - - (You should probably chat with bug-gdb@cygnus.com to make sure that - no one else is doing the project you chose). - -Rewrite proceed, wait_for_inferior, and normal_stop to clean them up. -Suggestions: - - 1) Make each test in wait_for_inferior a seperate subroutine - call. - 2) Combine wait_for_inferior and normal_stop to clean up - communication via global variables. - 3) See if you can find some way to clean up the global - variables that are used; possibly group them by data flow - and information content? - -Work out some kind of way to allow running the inferior to be done as -a sub-execution of, eg. breakpoint command lists. Currently running -the inferior interupts any command list execution. This would require -some rewriting of wait_for_inferior & friends, and hence should -probably be done in concert with the above. - -Add function arguments to gdb user defined functions. - -Add convenience variables that refer to exec file, symbol file, -selected frame source file, selected frame function, selected frame -line number, etc. - -Add a "suspend" subcommand of the "continue" command to suspend gdb -while continuing execution of the subprocess. Useful when you are -debugging servers and you want to dodge out and initiate a connection -to a server running under gdb. - -Work out and implement a reasonably general mechanism for multi-threaded -processies. There are parts of one implemented in convex-dep.c, if -you want an example. - -Add stab information to allow reasonable debugging of inline functions -(possibly they should show up on a stack backtrace? With a note -indicating that they weren't "real"?). - -Implement support for specifying arbitrary locations of stack frames -(in practice, this usually requires specification of both the top and -bottom of the stack frame (fp and sp), since you *must* retrieve the -pc that was saved in the innermost frame). - -Modify the naked "until" command to step until past the current source -line, rather than past the current pc value. This is tricky simply -because the low level routines have no way of specifying a multi-line -step range, and there is no way of saying "don't print stuff when we -stop" from above (otherwise could just call step many times). - -Modify the handling of symbols grouped through BINCL/EINCL stabs to -allocate a partial symtab for each BINCL/EINCL grouping. This will -seriously decrease the size of inter-psymtab dependencies and hence -lessen the amount that needs to be read in when a new source file is -accessed. - -Do an "x/i $pc" after each stepi or nexti. - -Modify all of the disassemblers to use printf_filtered to get correct -more filtering. - -Modify gdb to work correctly with Pascal. - -Rewrite macros that handle frame chaining and frameless functions. -They should be able to tell the difference between start, main, and a -frameless function called from main. - -Work out what information would need to be included in an executable -by the compiler to allow gdb to debug functions which do not have a -frame pointer. Modify gdb and gcc to do this. - -When `attached' to a program (via either OS support or remote -debugging), gdb should arrange to catch signals which the terminal -might send, as it is unlikely that the program will be able to notice -them. SIGINT and SIGTSTP are obvious examples. - -Enhance the gdb manual with extra examples where needed. - -Arrange for list_command not to use decode_line_1 and thus not require -symbols to be read in simply to read a source file. - -Allow patching of executables, a la "adb -w". - -Add a command for searching memory, a la adb. It specifies size, -mask, value, start address. ADB searches until it finds it or hits -an error (or is interrupted). - -# Local Variables: -# mode: text -# End: diff --git a/gdb/README b/gdb/README deleted file mode 100644 index a6e18ebf34e..00000000000 --- a/gdb/README +++ /dev/null @@ -1,591 +0,0 @@ - README for gdb-4.0 release - John Gilmore 23 Aug 91 - -This is GDB, the GNU source-level debugger, presently running under un*x. -A summary of features new since gdb-3.5 is in the file `WHATS.NEW'. - - -Unpacking and Installation -- quick overview -========================== - -This release moves the generic GNU include files, the BFD ("binary file -description") library, the getopt routines, obstacks, and the readline -library into the parent directory of the gdb source files. The idea is -that a variety of GNU tools can share a common copy of these things. - -These generic files are packaged together with the directory containing -the source code for GDB, for now. When you unpack the gdb-4.0.tar.Z -file, you'll get a directory called `gdb-4.0', which contains: - - Makefile.in bfd/ configure.in libiberty/ - README config.sub* gdb/ readline/ - README.configure configure* include/ texinfo/ - -To build GDB, you can just do: - - cd gdb-4.0 - ./configure HOSTNAME - make - cp gdb/gdb /usr/local/bin/gdb (or wherever you want) - -This will configure and build all the libraries as well as GDB. -If you get compiler warnings during this stage, see the `Reporting Bugs' -section below; there are a few known problems. - -GDB can be used as a cross-debugger, running on a machine of one type -while debugging a program running on a machine of another type. See below. - - -More Documentation -================== - - The GDB 4.0 release includes an already-formatted reference card, ready -for printing on a PostScript printer, as `gdb-4.0/gdb/refcard.ps'. It -uses the most common PostScript fonts: the Times family, Courier, -and Symbol. If you have a PostScript printer you can print the -reference card by just sending `refcard.ps' to the printer. - - The release also includes the online Info version of the manual -already formatted: the main Info file is `gdb-4.0/gdb/gdb.info', and -it refers to subordinate files matching `gdb.info*' in the same -directory. - - If you want to make these Info files yourself from the GDB -manual's source, you need the GNU `makeinfo' program. Once you have -it, you can type - - cd gdb-4.0/gdb - make gdb.info - -to make the Info file. - - If you want to format and print copies of this manual, you need -several things: - - * TeX, the public domain typesetting program written by Donald - Knuth, must be installed on your system and available through - your execution path. - - * `gdb-4.0/texinfo': TeX macros defining the GNU Documentation - Format. - - * *A DVI output program.* TeX doesn't actually make marks on - paper; it produces output files called DVI files. If your - system has TeX installed, chances are it has a program for - printing out these files; one popular example is `dvips', which - can print DVI files on PostScript printers. - -Once you have these things, you can type - - cd gdb-4.0/gdb - make gdb.dvi - -to format the text of this manual, and print it with the usual output -method for TeX DVI files at your site. - - If you want to print the reference card, but don't have a PostScript -printer, or want to print using Computer Modern fonts instead, you can -still print it if you have TeX. Format the reference card by typing - - cd gdb-4.0/gdb - make refcard.dvi - -The GDB reference card is designed to print in landscape mode on US -"letter" size paper; that is, on a sheet 11 inches wide by 8.5 -inches high. You will need to specify this form of printing as an -option to your DVI output program. - - -Installing GDB -============== - - GDB comes with a `configure' script that automates the process of -preparing GDB for installation; you can then use `make' to build the -`gdb' program. - - The gdb distribution includes all the source code you need for gdb -in a single directory `gdb-4.0'. That directory in turn contains: - -`gdb-4.0/configure' - Overall script for configuring GDB and all its supporting - libraries. - -`gdb-4.0/gdb' - the source specific to GDB itself - -`gdb-4.0/bfd' - source for the Binary File Descriptor Library - -`gdb-4.0/include' - GNU include files - -`gdb-4.0/libiberty' - source for the `-liberty' free software library - -`gdb-4.0/readline' - source for the GNU command-line interface - -Each of these directories has its own `configure' script, which are -used by the overall `configure' script in `gdb-4.0'. - - It is most convenient to run `configure' from the `gdb-4.0' -directory. The simplest way to configure and build GDB is the -following: - - cd gdb-4.0 - ./configure HOST - make - -where HOST is something like `sun4' or `decstation', that identifies -the platform where GDB will run. This builds the three libraries -`bfd', `readline', and `libiberty', then `gdb' itself. The -configured source files, and the binaries, are left in the -corresponding source directories. - - You can install `gdb' anywhere; it has no hardwired paths. -However, you should make sure that the shell on your path (named by -the `SHELL' environment variable) is publicly readable; some systems -refuse to let GDB debug child processes whose programs are not -readable, and GDB uses the shell to start your program. - -Configuration Subdirectories -============================ - - If you want to run GDB versions for several host or target -machines, you'll need a different gdb compiled for each combination -of host and target. `configure' is designed to make this easy by -allowing you to generate each configuration in a separate -subdirectory. If your `make' program handles the `VPATH' feature -(GNU `make' does), running `make' in each of these directories then -builds the gdb program specified there. - - `configure' creates these subdirectories for you when you -simultaneously specify several configurations; but it's a good habit -even for a single configuration. You can specify the use of -subdirectories using the `+subdirs' option (abbreviated `+sub'). -For example, you can build GDB on a Sun 4 as follows: - - cd gdb-4.0 - ./configure +sub sun4 - cd Host-sparc-sun-sunos4/Target-sparc-sun-sunos4 - make - - When `configure' uses subdirectories to build programs or -libraries, it creates nested directories `Host-HOST/Target-TARGET'. -(As you see in the example, the names used for HOST and TARGET may -be expanded from your `configure' argument; *note Config Names::.). -`configure' uses these two directory levels because GDB can be -configured for cross-compiling: GDB can run on one machine (the -host) while debugging programs that run on another machine (the -target). You specify cross-debugging targets by giving the -`+target=TARGET' option to `configure'. Specifying only hosts still -gives you two levels of subdirectory for each host, with the same -configuration suffix on both; that is, if you give any number of -hosts but no targets, GDB will be configured for native debugging on -each host. On the other hand, whenever you specify both hosts and -targets on the same command line, `configure' creates all -combinations of the hosts and targets you list. - - When you run `make' to build a program or library, you must run it -in a configured directory. If you made a single configuration, -without subdirectories, run `make' in the source directory. If you -have `Host-HOST/Target-TARGET' subdirectories, run `make' in those -subdirectories. - - Each `configure' and `Makefile' under each source directory runs -recursively, so that typing `make' in `gdb-4.0' (or in a -`gdb-4.0/Host-HOST/Target-TARGET' subdirectory) builds all the -required libraries, then GDB. - - If you run `configure' from a directory (such as `gdb-4.0') that -contains source directories for multiple libraries or programs, -`configure' creates the `Host-HOST/Target-TARGET' subdirectories in -each library or program's source directory. For example, typing: - - cd gdb-4.0 - configure sun4 +target=vxworks960 - -creates the following directories: - - gdb-4.0/Host-sparc-sun-sunos4/Target-i960-wrs-vxworks - gdb-4.0/bfd/Host-sparc-sun-sunos4/Target-i960-wrs-vxworks - gdb-4.0/gdb/Host-sparc-sun-sunos4/Target-i960-wrs-vxworks - gdb-4.0/libiberty/Host-sparc-sun-sunos4/Target-i960-wrs-vxworks - gdb-4.0/readline/Host-sparc-sun-sunos4/Target-i960-wrs-vxworks - -The `Makefile' in - - gdb-4.0/Host-sparc-sun-sunos4/Target-i960-wrs-vxworks - -will `cd' to the appropriate lower-level directories, for example: - - gdb-4.0/bfd/Host-sparc-sun-sunos4/Target-i960-wrs-vxworks - -building each in turn. - - When you have multiple hosts or targets configured, you can run -`make' on them in parallel (for example, if they are NFS-mounted on -each of the hosts); they will not interfere with each other. - -Specifying Names for Hosts and Targets -====================================== - - The specifications used for hosts and targets in the `configure' -script are based on a three-part naming scheme, but some short -predefined aliases are also supported. The full naming scheme -encodes three pieces of information in the following pattern: - - ARCHITECTURE-VENDOR-OS - - For example, you can use the alias `sun4' as a HOST argument or in -a `+target='TARGET option, but the full name of that configuration -specifies that the architecture is `sparc', the vendor is `sun', and -the operating system is `sunos4'. - - The following table shows all the architectures, hosts, and OS -prefixes that `configure' recognizes in GDB 4.0. Entries in the "OS -prefix" -column ending in a `*' may be followed by a release number. - - - ARCHITECTURE VENDOR OS prefix - ------------+-------------+------------- - | | - a29k | altos | aix* - alliant | aout | aout - arm | apollo | bout - c1 | att | bsd* - c2 | bout | coff - i386 | coff | ctix* - i860 | convergent | dynix* - i960 | convex | esix* - m68000 | dec | hpux* - m68k | encore | isc* - m88k | gould | mach* - mips | hp | newsos* - ns32k | ibm | nindy* - pyramid | intel | none - rs6000 | isi | osf* - rtpc | little | sco* - sparc | mips | sunos* - tahoe | motorola | sysv* - tron | ncr | ultrix* - vax | next | unos* - | none | v88r* - | sco | vms* - | sequent | vxworks* - | sgi | - | sony | - | sun | - | unicom | - | utek | - | wrs | - - *Warning:* Many combinations of architecture, vendor, and OS are - untested. - - The `configure' script accompanying GDB 4.0 does not provide any -query facility to list all supported host and target names or -aliases. `configure' calls the Bourne shell script `config.sub' to -map abbreviations to full names; you can read the script, if you -wish, or you can use it to test your guesses on abbreviations--for -example: - - % sh config.sub sun4 - sparc-sun-sunos4 - % sh config.sub sun3 - m68k-sun-sunos4 - % sh config.sub decstation - mips-dec-ultrix - % sh config.sub hp300bsd - m68k-hp-bsd - % sh config.sub i386v - i386-none-sysv - % sh config.sub i486v - *** No vendor: configuration `i486v' not recognized - -`configure' Options -=================== - - Here is a summary of all the `configure' options and arguments -that you might use for building GDB: - - configure [+destdir=DIR] [+subdirs] [+norecur] [+rm] - [+target=TARGET...] HOST... - -You may introduce options with the character `-' rather than `+' if -you prefer; but you may abbreviate option names if you use `+'. - -`+destdir=DIR' - DIR is an installation directory *path prefix*. After you - configure with this option, `make install' will install GDB as - `DIR/bin/gdb', and the libraries in `DIR/lib'. If you specify - `+destdir=/usr/local', for example, `make install' creates - `/usr/local/bin/gdb'. - -`+subdirs' - Write configuration specific files in subdirectories of the form - - Host-HOST/Target-TARGET - - (and configure the `Makefile' to write binaries there too). - Without this option, if you specify only one configuration for - GDB, `configure' will use the same directory for source, - configured files, and binaries. This option is used - automatically if you specify more than one HOST or more than - one - `+target=TARGET' option on the `configure' command line. - -`+norecur' - Configure only the directory where `configure' is executed; do - not propagate configuration to subdirectories. - -`+rm' - Remove the configuration that the other arguments specify. - -`+target=TARGET ...' - Configure GDB for cross-debugging programs running on each - specified TARGET. You may specify as many `+target' options as - you wish. Without this option, GDB is configured to debug - programs that run on the same machine (HOST) as GDB itself. - - There is no convenient way to generate a list of all available - targets. - -`HOST ...' - Configure GDB to run on each specified HOST. You may specify as - many host names as you wish. - - There is no convenient way to generate a list of all available - hosts. - -`configure' accepts other options, for compatibility with configuring -other GNU tools recursively; but these are the only options that -affect GDB or its supporting libraries. - - - Languages other than C - -C++ support has been integrated into gdb. GDB should work with FORTRAN -programs. (If you have problems, please send a bug report; you may -have to refer to some FORTRAN variables with a trailing underscore). -Andrew Beers has produced a GDB that works with Modula-2, which will -appear in gdb-4.1. I am not aware of anyone who is working on getting -gdb to use the syntax of any other language. Pascal programs which use -sets, subranges, file variables, or nested functions will not currently -work. - - - Kernel debugging - -I have't done this myself so I can't really offer any advice. -Remote debugging over serial lines works fine, but the kernel debugging -code in here has not been tested in years. Van Jacobson claims to have -better kernel debugging, but won't release it for ordinary mortals. - - - Remote debugging - -The files m68k-stub.c and i386-stub.c contain two examples of remote -stubs to be used with remote.c. They are designeded to run standalone -on a 68k or 386 cpu and communicate properly with the remote.c stub -over a serial line. - -The file rem-multi.shar contains a general stub that can probably -run on various different flavors of unix to allow debugging over a -serial line from one machine to another. - -The files remote-eb.c and remote-nindy.c are two examples of remote -interfaces for talking to existing ROM monitors (for the AMD 29000 and the -Intel 960 repsectively). - -Remote-vx.c and the vx-share subdirectory contain a remote interface for the -VxWorks realtime kernel, which communicates over TCP using the Sun -RPC library. This would be a useful starting point for other remote- -via-ethernet back ends. - -[This section seems to be out of date, I have never seen the "rapp" -program, though I would like to. FIXME.] -`rapp' runs under unix and acts as a remote stub (like rem-multi.shar -distributed with GDB version 3). Currently it just works over UDP -(network), not over a serial line. To get it running -* Compile GDB on the host machine as usual -* Compile rapp on the target machine, giving for both host and target - the type of the target machine -* Install "gdb" in /etc/services on both machines. - - - Reporting Bugs - -The correct address for reporting bugs found in gdb is -"bug-gdb@prep.ai.mit.edu". Please email all bugs to that address. - -GDB can produce warnings about symbols that it does not understand. By -default, these warnings are disabled. You can enable them by executing -`set complaint 10' (which you can put in your ~/.gdbinit if you like). -I recommend doing this if you are working on a compiler, assembler, -linker, or gdb, since it will point out problems that you may be able -to fix. Warnings produced during symbol reading indicate some mismatch -between the object file and GDB's symbol reading code (in many cases, -it's a mismatch between the specs for the object file format, and what -the compiler actually outputs or the debugger actually understands). - -If you port gdb to a new machine, please send the required changes -to bug-gdb@prep.ai.mit.edu. If your changes are more than a few -lines, obtain and send in a copyright assignment from gnu@prep.ai.mit.edu, as -described in the section `Writing Code for GDB'. - - - X Windows versus GDB - -xgdb is obsolete. We are not doing any development or support of it. - -There is an "xxgdb", which shows more promise, which was posted to -comp.sources.x. - -For those intersted in auto display of source and the availability of -an editor while debugging I suggest trying gdb-mode in gnu-emacs -(Try typing M-x gdb RETURN). Comments on this mode are welcome. - - - About the machine-dependent files - -tconfig/ -This contains Makefile stuff for when the target system is . -It also specifies the name of the tm-XXX.h file for this machine. - -xconfig/ -This contains Makefile stuff for when the host system is . -It also specifies the name of the xm-XXX.h file for this machine. - -tm-XXX.h (tm.h is a link to this file, created by configure). -This file contains macro definitions about the target machine's -registers, stack frame format and instructions. - -xm-XXX.h (xm.h is a link to this file, created by configure). -This contains macro definitions describing the host system environment, -such as byte order, host C compiler and library, ptrace support, -and core file structure. - --opcode.h --pinsn.c -These files contain the information necessary to print instructions -for your cpu type. -opcode.h includes some large initialized -data structures, which is strange for a ".h" file, but it's OK since -it is only included in one place. -opcode.h is shared -between the debugger and the assembler (if the GNU assembler has been -ported to that machine), whereas -pinsn.c is specific to GDB. - --tdep.c -This file contains any miscellaneous code required for this machine -as a target. On some machines it doesn't exist at all. Its existence -is specified in the tconfig/XXX file. - --xdep.c -This file contains any miscellaneous code required for this machine -as a host. On some machines it doesn't exist at all. Its existence -is specified in the xconfig/XXX file. - -infptrace.c -This is the low level interface to inferior processes for systems -using the Unix ptrace call in a vanilla way. Some systems have their -own routines in -xdep.c. Whether or not it is used -is specified in the xconfig/XXX file. - -coredep.c -Machine and system-dependent aspects of reading core files. Some -machines use coredep.c; some have the routines in -xdep.c. -Whether or not it is used is specified in the xconfig/XXX file. -Now that BFD is used to read core files, virtually all machines should -use coredep.c and should just provide fetch_core_registers in --xdep.c. - -exec.c -Machine and system-dependent aspects of reading executable files. -Some machines use exec.c; some have the routines in -tdep.c -Since BFD, virtually all machines should use exec.c. - - - Writing Code for GDB - -We appreciate having users contribute code that is of general use, but -for it to be included in future GDB releases it must be cleanly -written. We do not want to include changes that will needlessly make -future maintainance difficult. It is not much harder to do things -right, and in the long term it is worth it to the GNU project, and -probably to you individually as well. - -Please code according to the GNU coding standards. If you do not have -a copy, you can request one by sending mail to gnu@prep.ai.mit.edu. - -If you make substantial changes, you'll have to file a copyright -assignment with the Free Software Foundation before we can produce a -release that includes your changes. Send mail requesting the copyright -assignment to gnu@prep.ai.mit.edu. Do this early, like before the -changes actually work, or even before you start them, because a manager -or lawyer on your end will probably make this a slow process. - -Please try to avoid making machine-specific changes to -machine-independent files. If this is unavoidable, put a hook in the -machine-independent file which calls a (possibly) machine-dependent -macro (for example, the IGNORE_SYMBOL macro can be used for any -symbols which need to be ignored on a specific machine. Calling -IGNORE_SYMBOL in dbxread.c is a lot cleaner than a maze of #if -defined's). The machine-independent code should do whatever "most" -machines want if the macro is not defined in param.h. Using #if -defined can sometimes be OK (e.g. SET_STACK_LIMIT_HUGE) but should be -conditionalized on a specific feature of an operating system (set in -tm.h or xm.h) rather than something like #if defined(vax) or #if -defined(SYSV). If you use an #ifdef on some symbol that is defined -in a header file (e.g. #ifdef TIOCSETP), *please* make sure that you -have #include'd the relevant header file in that module! - -It is better to replace entire routines which may be system-specific, -rather than put in a whole bunch of hooks which are probably not going -to be helpful for any purpose other than your changes. For example, -if you want to modify dbxread.c to deal with DBX debugging symbols -which are in COFF files rather than BSD a.out files, do something -along the lines of a macro GET_NEXT_SYMBOL, which could have -different definitions for COFF and a.out, rather than trying to put -the necessary changes throughout all the code in dbxread.c that -currently assumes BSD format. - -Please avoid duplicating code. For example, in GDB 3.x all the stuff -in infptrace.c was duplicated in *-dep.c, and so changing something -was very painful. In GDB 4.x, these have all been consolidated -into infptrace.c. infptrace.c can deal with variations between -systems the same way any system-independent file would (hooks, #if -defined, etc.), and machines which are radically different don't need -to use infptrace.c at all. The same was true of core_file_command -and exec_file_command. - - - Debugging gdb with itself - -If gdb is limping on your machine, this is the preferred way to get it -fully functional. Be warned that in some ancient Unix systems, like -Ultrix 4.0, a program can't be running in one process while it is being -debugged in another. Rather than doing "./gdb ./gdb", which works on -Suns and such, you can copy gdb to gdb2 and then do "./gdb ./gdb2". - -When you run gdb in this directory, it will read a ".gdbinit" file that -sets up some simple things to make debugging gdb easier. The "info" -command, when executed without a subcommand in a gdb being debugged by -gdb, will pop you back up to the top level gdb. See .gdbinit for details. - -I strongly recommend printing out the reference card and using it. -Send reference-card suggestions to bug-gdb@prep.ai.mit.edu, just like bugs. - -If you use emacs, you will probably want to do a "make TAGS" after you -configure your distribution; this will put the machine dependent -routines for your local machine where they will be accessed first by a -M-period. - -Also, make sure that you've compiled gdb with your local cc or taken -appropriate precautions regarding ansification of include files. See -the Makefile for more information. - -(this is for editing this file with GNU emacs) -Local Variables: -mode: text -End: diff --git a/gdb/TODO b/gdb/TODO deleted file mode 100644 index b67f093ce04..00000000000 --- a/gdb/TODO +++ /dev/null @@ -1,309 +0,0 @@ - - gdb bug list - John Gilmore, gnu@cygnus.com - -This bug list is probably not up to date or accurate, but it reflects -some known bugs in gdb, if you are into bug-hunting. - - -It should be possible to use symbols from shared libraries before we know -exactly where the libraries will be loaded. E.g. "b perror" before running -the program. This could maybe be done as an extension of the "breakpoint -re-evaluation" after new symbols are loaded. - -Make single_step() insert and remove breakpoints in one operation. - -Speed up single stepping by avoiding extraneous ptrace calls. - -Speed up single stepping by not inserting and removing breakpoints -each time the inferior starts and stops. - -Breakpoints should not be inserted and deleted all the time. Only the -one(s) there should be removed when we have to step over one. Support -breakpoints that don't have to be removed to step over them. - -Speed up watchpoints by not single-stepping them, but do something -faster like single-line execution. Speed them up tremendously on -machines that have watchpoint registers. - -Update gdbint.texinfo to include doc on the directory structure and -the various tricks of building gdb. - -Do a tutorial in gdb.texinfo on how to do simple things in gdb. -E.g. how to set a breakpoint that just prints something and continues. -How to break on aborts. Etc. - -Provide "voodoo" debugging of core files. This creates a zombie -process as a child of the debugger, and loads it up with the data, -stack, and regs of the core file. This allows you to call functions -in the executable, to manipulate the data in the core file. - -GDB reopens the source file on every line, as you "next" through it. - -Referencing the vtbl member of a struct doesn't work. It prints OK -if you print the struct, but it gets 0 if you try to deref it. - -Persistent command history: A feature where you could save off a list -of the commands you did, so you can edit it into something that will bring -the target to the same place every time you source it. -This would also be useful for automated fast watchpointing; if you go -past the place where it watchpoints, you just start it over again and -do it more carefully. - -Deal with the SunOS 4.0 and 4.1.1 ptrace bug that loses the registers if -the stack is paged out. - -Finish the C++ exception handling stub routines. Lint points them out -as unused statics functions. - -Perhaps "i source" should take an argument like that of "list". - -See if coredep.c's fetch_core_registers can be used on more machines. -E.g. MIPS (mips-xdep.c). - -unpack_double() does not handle IEEE float on the target unless the host -is also IEEE. Death on a vax. - -Test cross-debugging Unix-to-Unix. - -Check the RAPP remote protocol. What is it? It's in Makefile.in -and one ChangeLog entry. - -Set up interface between GDB and INFO so that you can hop into interactive -INFO and back out again. When running under Emacs, should use Emacs -info, else fork the info program. Installation of GDB should install -its texinfo files into the info tree automagically, including the readline -texinfo files. - -"help address" ought to find the "help set print address" entry. - -Remove the VTBL internal guts from printouts of C++ structs, unless -vtblprint is set. - -Remove "at 0xnnnn" from the "b foo" response, if `print address off' and if -it matches the source line indicated. - -The prompt at end of screen should accept space as well as CR. - -"List" should put you into a pseudo-"more" where you can hit space -to get more, forever to eof. - -Check STORE_RETURN_VALUE on all architectures. Check near it in tm-sparc.h -for other bogosities. - -Check for storage leaks in GDB, I'm sure there are a lot! - -vtblprint of a vtbl should demangle the names it's printing. - -Backtrace should point out what the currently selected frame is, in its -display, perhaps showing "@3 foo (bar, ...)" rather than "#3 foo (bar, ...)". - -"i program" should work for core files, and display more info, like what -actually caused it to die. - -Hitting ^Z to an inferior doesn't work right, it takes several continues -to make it actually go. - -"x/10i" should shorten the long name, if any, on subsequent lines. - -Check through the code for FIXME comments and fix them. dbxread.c, -blockframe.c, and plenty more. - -"next" over a function that longjumps, never stops until next time you happen -to get to that spot by accident. E.g. "n" over execute_command which has -an error. - -Watchpoints seem not entirely reliable, though they haven't failed me recently. - -"set zeroprint off", don't bother printing members of structs which are entirely -zero. Useful for those big structs with few useful members. - -GDB does four ioctl's for every command, probably switching terminal modes -to/from inferior or for readline or something. - -terminal_ours versus terminal_inferior: cache state. Switch should be a noop -if the state is the same, too. - -ptype $i6 = void??! - -Clean up invalid_float handling so gdb doesn't coredump when it tries to -access a NaN. While this might work on SPARC, other machines are not -configured right. - -"b value_at ; commands ; continue ; end" stops EVERY OTHER TIME! -Then once you enter a command, it does the command, runs two more -times, and then stops again! Bizarre... (This behaviour has been -modified, but it is not yet 100% predictable when e.g. the commands -call functions in the child, and while there, the child is interrupted -with a signal, or hits a breakpoint.) - -Symbol completion with TAB does not unmangle names! - -help completion, help history should work. - -Symbol completion doesn't handle e.g. W::f. (symtab.c, -make_symbol_completion_list). - -Check that we can handle stack trace through varargs AND alloca in same -function, on 29K. - -wait_for_inferior loops forever if wait() gives it an error. - -"i frame" shows wrong "arglist at" location, doesn't show where the args -should be found, only their actual values. - -Symbolic display of addrs, (& disassembly prefixes), don't show static -fns, e.g. enable_command in gdb. - -'ptype yylval' ==> "union YYSTYPE { ..... }". However, it is not a -union YYSTYPE, but is simply a YYSTYPE, which is a typedef for an -unnamed union. - -There should be a way for "set" commands to validate the new setting -before it takes effect. - -The "display" command should become the "always" command, e.g. - "always print XXX" - "always p/xxx XXX" - "always echo foo" - "always call XXX" - "always x/i $pc", etc. - -A mess of floating point opcodes are missing from sparc-opcode.h. -Also, a little program should test the table for bits that are -overspecified or underspecified. E.g. if the must-be-ones bits -and the must-be-zeroes bits leave some fields unexamined, and the format -string leaves them unprinted, then point this out. If multiple -non-alias patterns match, point this out too. Finally, there should -be a sparc-optest.s file that tries each pattern out. This file -should end up coming back the same (modulo transformation comments) -if fed to "gas" then the .o is fed to gdb for disassembly. - -Merge the xxx-opcode.h files with gas again... - -Eliminate all the core_file_command's in all the xdep files. -Eliminate separate declarations of registers[] everywhere. - -"ena d" is ambiguous, why? "ena delete" seems to think it is a command! - -Line numbers are off in some spots. In proceed() at 1st "oneproc = 1", -it seems to run that statement, but it doesn't actually. - -Perhaps move the tdep and xdep files, and the tm and xm files, into a config -subdirectory. If not, at least straighten out their names so that -they all start with the machine name. - -inferior_status should include stop_print_frame. It won't need to be -reset in wait_for_inferior after bpstat_stop_status call, then. - -i line VAR produces "Line number not known for symbol ``var''.". I -thought we were stashing that info now! - -Make sure we can handle executables with no symbol info, e.g. /bin/csh. - -We should be able to write to random files at hex offsets like adb. - -Make "target xxx" command interruptible. - -Handle add_file with separate text, data, and bss addresses. Maybe -handle separate addresses for each segment in the object file? - -Handle free_named_symtab to cope with multiply-loaded object files -in a dynamic linking environment. Should remember the last copy loaded, -but not get too snowed if it finds references to the older copy. - -The original BFD core dump reading routine would itself coredump when fed -a garbage file as a core file. Does the current one? - -Generalize and Standardize the RPC interface to a target program, -improve it beyond the "ptrace" interface, and see if it can become a -standard for remote debugging. - -Remove all references to: - text_offset - data_offset - text_data_start - text_end - exec_data_offset - ... -now that we have BFD. All remaining are in machine dependent files. - -When quitting with a running program, if a core file was previously -examined, you get "Couldn't read float regs from core file"...if -indeed it can't. generic_mourn_inferior... - -Check signal argument to remote proceed's and error if set. - -Sort help and info output. - -Re-organize help categories into things that tend to fit on a screen -and hang together. - -renote-nindy.c handles interrupts poorly; it error()s out of badly -chosen places, e.g. leaving current_frame zero, which causes core dumps -on the next command. - -Add in commands like ADB's for searching for patterns, etc. We should -be able to examine and patch raw unsymboled binaries as well in gdb as -we can in adb. (E.g. increase the timeout in /bin/login without source). - -Those xdep files that call register_addr without defining it are -probably simply broken. When reconfiguring this part of gdb, I could -only make guesses about how to redo some of those files, and I -probably guessed wrong, or left them "for later" when I have a -machine that can attempt to build them. - -Use the complain() mechanism for handling all the error() calls in dbxread.c, -and in similar situations in coffread.c and mipsread.c. - -When doing "step" or "next", if a few lines of source are skipped between -the previous line and the current one, print those lines, not just the -last line of a multiline statement. - -When searching for C++ superclasses in value_cast in valops.c, we must -not search the "fields", only the "superclasses". There might be a -struct with a field name that matches the superclass name. This can -happen when the struct was defined before the superclass (before the -name became a typedef). - -Handling of "&" address-of operator needs some serious overhaul -for ANSI C and consistency on arrays and functions. - For "float point[15];": -ptype &point[4] ==> Attempt to take address of non-lvalue. - For "char *malloc();": -ptype malloc ==> "char *()"; should be same as -ptype &malloc ==> "char *(*)()" -call printf ("%x\n", malloc) ==> wierd value, should be same as -call printf ("%x\n", &malloc) ==> correct value - -Fix dbxread.c symbol reading in the presence of interrupts. It currently -leaves a cleanup to blow away the entire symbol table when a QUIT occurs. - -Mipsread.c reads include files depth-first, because the dependencies -in the psymtabs are way too inclusive (it seems to me). Figure out what -really depends on what, to avoid recursing 20 or 30 times while reading -real symtabs. - -value_add() should be subtracting the lower bound of arrays, if known, -and possibly checking against the upper bound for error reporting. - -mipsread.c symbol table allocation and deallocation should be checked. -My suspicion is that it's full of memory leaks. - -SunOS should have a target_lookup_symbol() for common'd things allocated -by the shared library linker ld.so. - -When listing source lines, check for a preceding \n, to verify that -the file hasn't changed out from under us. - -When listing source lines, eat leading whitespace corresponding to the -line-number prefix we print. This avoids long lines wrapping. - -mipsread.c needs to check for old symtabs and psymtabs for the same -files, the way it happens for dbxread.c and coffread.c, for VxWorks -incremental symbol table reloading. - -When attached to a non-child process, ^C or other signals are not -propagated to the child. Do this in the GDB signal handler, using -target_kill(). AMD version: ^C should do ^Ak to stop ebmon. - diff --git a/gdb/WHATS.NEW b/gdb/WHATS.NEW deleted file mode 100755 index 71ba79da1be..00000000000 --- a/gdb/WHATS.NEW +++ /dev/null @@ -1,284 +0,0 @@ - What has changed since GDB-3.5? - (Organized release by release) - -*** Changes in GDB-4.2: - - * Improved configuration - -Only one copy of `configure' exists now, and it is not self-modifying. -Porting BFD is simpler. - - * Stepping improved - -The `step' and `next' commands now only stop at the first instruction -of a source line. This prevents the multiple stops that used to occur -in switch statements, for-loops, etc. `Step' continues to stop if a -function that has debugging information is called within the line. - - * Bug fixing - -Lots of small bugs fixed. More remain. - - * New host supported (not target) - -Intel 386 PC clone running Mach i386-none-mach - - -*** Changes in GDB-4.1: - - * Multiple source language support - -GDB now has internal scaffolding to handle several source languages. -It determines the type of each source file from its filename extension, -and will switch expression parsing and number formatting to match the -language of the function in the currently selected stack frame. -You can also specifically set the language to be used, with -`set language c' or `set language modula-2'. - - * GDB and Modula-2 - -GDB now has preliminary support for the GNU Modula-2 compiler, -currently under development at the State University of New York at -Buffalo. Development of both GDB and the GNU Modula-2 compiler will -continue through the fall of 1991 and into 1992. - -Other Modula-2 compilers are currently not supported, and attempting to -debug programs compiled with them will likely result in an error as the -symbol table is read. Feel free to work on it, though! - -There are hooks in GDB for strict type checking and range checking, -in the `Modula-2 philosophy', but they do not currently work. - - * set write on/off - -GDB can now write to executable and core files (e.g. patch -a variable's value). You must turn this switch on, specify -the file ("exec foo" or "core foo"), *then* modify it, e.g. -by assigning a new value to a variable. Modifications take -effect immediately. - - * Automatic SunOS shared library reading - -When you run your program, GDB automatically determines where its -shared libraries (if any) have been loaded, and reads their symbols. -The `share' command is no longer needed. This also works when -examining core files. - - * set listsize - -You can specify the number of lines that the `list' command shows. -The default is 10. - - * New machines supported (host and target) - -SGI Iris (MIPS) running Irix V3: mips-sgi-irix or iris -Sony NEWS (68K) running NEWSOS 3.x: m68k-sony-sysv or news -Ultracomputer (29K) running Sym1: a29k-nyu-sym1 or ultra3 - - * New hosts supported (not targets) - -IBM RT/PC: romp-ibm-aix or rtpc - - * New targets supported (not hosts) - -AMD 29000 embedded with COFF a29k-none-coff -AMD 29000 embedded with a.out a29k-none-aout -Ultracomputer remote kernel debug a29k-nyu-kern - - * New remote interfaces - -AMD 29000 Adapt -AMD 29000 Minimon - - -*** Changes in GDB-4.0: - - * New Facilities - -Wide output is wrapped at good places to make the output more readable. - -Gdb now supports cross-debugging from a host machine of one type to a -target machine of another type. Communication with the target system -is over serial lines. The ``target'' command handles connecting to the -remote system; the ``load'' command will download a program into the -remote system. Serial stubs for the m68k and i386 are provided. Gdb -also supports debugging of realtime processes running under VxWorks, -using SunRPC Remote Procedure Calls over TCP/IP to talk to a debugger -stub on the target system. - -New CPUs supported include the AMD 29000 and Intel 960. - -GDB now reads object files and symbol tables via a ``binary file'' -library, which allows a single copy of GDB to debug programs of multiple -object file types such as a.out and coff. - -There is now a GDB reference card in "doc/refcard.tex". (Make targets -refcard.dvi and refcard.ps are available to format it). - - - * Control-Variable user interface simplified - -All variables that control the operation of the debugger can be set -by the ``set'' command, and displayed by the ``show'' command. - -For example, ``set prompt new-gdb=>'' will change your prompt to new-gdb=>. -``Show prompt'' produces the response: -Gdb's prompt is new-gdb=>. - -What follows are the NEW set commands. The command ``help set'' will -print a complete list of old and new set commands. ``help set FOO'' -will give a longer description of the variable FOO. ``show'' will show -all of the variable descriptions and their current settings. - -confirm on/off: Enables warning questions for operations that are - hard to recover from, e.g. rerunning the program while - it is already running. Default is ON. - -editing on/off: Enables EMACS style command line editing - of input. Previous lines can be recalled with - control-P, the current line can be edited with control-B, - you can search for commands with control-R, etc. - Default is ON. - -history filename NAME: NAME is where the gdb command history - will be stored. The default is .gdb_history, - or the value of the environment variable - GDBHISTFILE. - -history size N: The size, in commands, of the command history. The - default is 256, or the value of the environment variable - HISTSIZE. - -history save on/off: If this value is set to ON, the history file will - be saved after exiting gdb. If set to OFF, the - file will not be saved. The default is OFF. - -history expansion on/off: If this value is set to ON, then csh-like - history expansion will be performed on - command line input. The default is OFF. - -radix N: Sets the default radix for input and output. It can be set - to 8, 10, or 16. Note that the argument to "radix" is interpreted - in the current radix, so "set radix 10" is always a no-op. - -height N: This integer value is the number of lines on a page. Default - is 24, the current `stty rows'' setting, or the ``li#'' - setting from the termcap entry matching the environment - variable TERM. - -width N: This integer value is the number of characters on a line. - Default is 80, the current `stty cols'' setting, or the ``co#'' - setting from the termcap entry matching the environment - variable TERM. - -Note: ``set screensize'' is obsolete. Use ``set height'' and -``set width'' instead. - -print address on/off: Print memory addresses in various command displays, - such as stack traces and structure values. Gdb looks - more ``symbolic'' if you turn this off; it looks more - ``machine level'' with it on. Default is ON. - -print array on/off: Prettyprint arrays. New convenient format! Default - is OFF. - -print demangle on/off: Print C++ symbols in "source" form if on, - "raw" form if off. - -print asm-demangle on/off: Same, for assembler level printouts - like instructions. - -print vtbl on/off: Prettyprint C++ virtual function tables. Default is OFF. - - - * Support for Epoch Environment. - -The epoch environment is a version of Emacs v18 with windowing. One -new command, ``inspect'', is identical to ``print'', except that if you -are running in the epoch environment, the value is printed in its own -window. - - - * Support for Shared Libraries - -GDB can now debug programs and core files that use SunOS shared libraries. -Symbols from a shared library cannot be referenced -before the shared library has been linked with the program (this -happens after you type ``run'' and before the function main() is entered). -At any time after this linking (including when examining core files -from dynamically linked programs), gdb reads the symbols from each -shared library when you type the ``sharedlibrary'' command. -It can be abbreviated ``share''. - -sharedlibrary REGEXP: Load shared object library symbols for files - matching a unix regular expression. No argument - indicates to load symbols for all shared libraries. - -info sharedlibrary: Status of loaded shared libraries. - - - * Watchpoints - -A watchpoint stops execution of a program whenever the value of an -expression changes. Checking for this slows down execution -tremendously whenever you are in the scope of the expression, but is -quite useful for catching tough ``bit-spreader'' or pointer misuse -problems. Some machines such as the 386 have hardware for doing this -more quickly, and future versions of gdb will use this hardware. - -watch EXP: Set a watchpoint (breakpoint) for an expression. - -info watchpoints: Information about your watchpoints. - -delete N: Deletes watchpoint number N (same as breakpoints). -disable N: Temporarily turns off watchpoint number N (same as breakpoints). -enable N: Re-enables watchpoint number N (same as breakpoints). - - - * C++ multiple inheritance - -When used with a GCC version 2 compiler, GDB supports multiple inheritance -for C++ programs. - - * C++ exception handling - -Gdb now supports limited C++ exception handling. Besides the existing -ability to breakpoint on an exception handler, gdb can breakpoint on -the raising of an exception (before the stack is peeled back to the -handler's context). - -catch FOO: If there is a FOO exception handler in the dynamic scope, - set a breakpoint to catch exceptions which may be raised there. - Multiple exceptions (``catch foo bar baz'') may be caught. - -info catch: Lists all exceptions which may be caught in the - current stack frame. - - - * Minor command changes - -The command ``call func (arg, arg, ...)'' now acts like the print -command, except it does not print or save a value if the function's result -is void. This is similar to dbx usage. - -The ``up'' and ``down'' commands now always print the frame they end up -at; ``up-silently'' and `down-silently'' can be used in scripts to change -frames without printing. - - * New directory command - -'dir' now adds directories to the FRONT of the source search path. -The path starts off empty. Source files that contain debug information -about the directory in which they were compiled can be found even -with an empty path; Sun CC and GCC include this information. If GDB can't -find your source file in the current directory, type "dir .". - - * Configuring GDB for compilation - -For normal use, type ``./configure host''. See README or gdb.texinfo -for more details. - -GDB now handles cross debugging. If you are remotely debugging between -two different machines, type ``./configure host -target=targ''. -Host is the machine where gdb will run; targ is the machine -where the program that you are debugging will run. diff --git a/gdb/alldeps.mak b/gdb/alldeps.mak deleted file mode 100644 index 5563107d031..00000000000 --- a/gdb/alldeps.mak +++ /dev/null @@ -1,221 +0,0 @@ -# Start of "alldeps.mak" definitions -ALLDEPFILES = $(ALLDEPFILES_MAINDIR) $(ALLDEPFILES_SUBDIR) -ALLDEPFILES_MAINDIR=\ -altos-xdep.c\ -am29k-pinsn.c\ -am29k-tdep.c\ -arm-convert.s\ -arm-pinsn.c\ -arm-tdep.c\ -arm-xdep.c\ -convex-pinsn.c\ -convex-tdep.c\ -convex-xdep.c\ -coredep.c\ -exec.c\ -gould-pinsn.c\ -gould-xdep.c\ -hp300ux-xdep.c\ -i386-pinsn.c\ -i386-tdep.c\ -i386-xdep.c\ -i960-pinsn.c\ -i960-tdep.c\ -infptrace.c\ -m68k-pinsn.c\ -m68k-tdep.c\ -m88k-pinsn.c\ -m88k-tdep.c\ -m88k-xdep.c\ -mips-pinsn.c\ -mips-tdep.c\ -mips-xdep.c\ -mipsread.c\ -news-xdep.c\ -nindy-tdep.c\ -ns32k-pinsn.c\ -pyr-pinsn.c\ -pyr-tdep.c\ -pyr-xdep.c\ -remote-adapt.c\ -remote-eb.c\ -remote-mm.c\ -remote-nindy.c\ -remote-vx.c\ -solib.c\ -sparc-pinsn.c\ -sparc-tdep.c\ -sparc-xdep.c\ -sun3-xdep.c\ -sun386-xdep.c\ -symm-tdep.c\ -symm-xdep.c\ -tahoe-pinsn.c\ -tdesc.c\ -ultra3-xdep.c\ -umax-xdep.c\ -vax-pinsn.c - -ALLDEPFILES_SUBDIR=\ -nindy-share/Onindy.c\ -nindy-share/nindy.c\ -nindy-share/ttybreak.c\ -nindy-share/ttyflush.c\ -vx-share/xdr_ld.c\ -vx-share/xdr_ptrace.c\ -vx-share/xdr_rdb.c\ -vx-share/xdr_regs.c - -ALLPARAM=\ -tm-29k.h\ -tm-3b1.h\ -tm-88k.h\ -tm-altos.h\ -tm-altosgas.h\ -tm-arm.h\ -tm-bigmips.h\ -tm-convex.h\ -tm-hp300bsd.h\ -tm-hp300hpux.h\ -tm-i386v-g.h\ -tm-i386v.h\ -tm-isi.h\ -tm-merlin.h\ -tm-mips.h\ -tm-news.h\ -tm-nindy960.h\ -tm-np1.h\ -tm-pn.h\ -tm-pyr.h\ -tm-sparc.h\ -tm-sun2.h\ -tm-sun2os4.h\ -tm-sun3.h\ -tm-sun386.h\ -tm-sun3os4.h\ -tm-sun4os4.h\ -tm-symmetry.h\ -tm-tahoe.h\ -tm-ultra3.h\ -tm-umax.h\ -tm-vax.h\ -tm-vx68.h\ -tm-vx960.h\ -xm-3b1.h\ -xm-88k.h\ -xm-altos.h\ -xm-arm.h\ -xm-bigmips.h\ -xm-convex.h\ -xm-hp300bsd.h\ -xm-hp300hpux.h\ -xm-i386sco.h\ -xm-i386v.h\ -xm-i386v32.h\ -xm-isi.h\ -xm-merlin.h\ -xm-mips.h\ -xm-news.h\ -xm-news1000.h\ -xm-np1.h\ -xm-pn.h\ -xm-pyr.h\ -xm-rtbsd.h\ -xm-sparc.h\ -xm-sun2.h\ -xm-sun3.h\ -xm-sun386.h\ -xm-sun3os4.h\ -xm-sun4os4.h\ -xm-symmetry.h\ -xm-tahoe.h\ -xm-ultra3.h\ -xm-umax.h\ -xm-vax.h - -ALLCONFIG=\ -./tconfig/3b1\ -./tconfig/a29k\ -./tconfig/a29k-kern\ -./tconfig/altos\ -./tconfig/altosgas\ -./tconfig/arm\ -./tconfig/bigmips\ -./tconfig/convex\ -./tconfig/dec3100\ -./tconfig/hp300bsd\ -./tconfig/hp300hpux\ -./tconfig/i386sco\ -./tconfig/i386v\ -./tconfig/i386v-g\ -./tconfig/i386v32\ -./tconfig/i386v32-g\ -./tconfig/i960\ -./tconfig/isi\ -./tconfig/littlemips\ -./tconfig/m88k\ -./tconfig/merlin\ -./tconfig/news\ -./tconfig/news1000\ -./tconfig/nindy960\ -./tconfig/none\ -./tconfig/np1\ -./tconfig/pn\ -./tconfig/pyramid\ -./tconfig/sun2os3\ -./tconfig/sun2os4\ -./tconfig/sun3\ -./tconfig/sun386\ -./tconfig/sun3os3\ -./tconfig/sun3os4\ -./tconfig/sun4\ -./tconfig/sun4os3\ -./tconfig/sun4os4\ -./tconfig/symmetry\ -./tconfig/tahoe\ -./tconfig/ultra3\ -./tconfig/umax\ -./tconfig/vax\ -./tconfig/vxworks68\ -./tconfig/vxworks960\ -./xconfig/3b1\ -./xconfig/altos\ -./xconfig/altosgas\ -./xconfig/arm\ -./xconfig/bigmips\ -./xconfig/convex\ -./xconfig/dec3100\ -./xconfig/hp300bsd\ -./xconfig/hp300hpux\ -./xconfig/i386sco\ -./xconfig/i386v\ -./xconfig/i386v-g\ -./xconfig/i386v32\ -./xconfig/i386v32-g\ -./xconfig/isi\ -./xconfig/littlemips\ -./xconfig/m88k\ -./xconfig/merlin\ -./xconfig/news\ -./xconfig/news1000\ -./xconfig/none\ -./xconfig/np1\ -./xconfig/pn\ -./xconfig/pyramid\ -./xconfig/rtbsd\ -./xconfig/sun2os3\ -./xconfig/sun2os4\ -./xconfig/sun3\ -./xconfig/sun386\ -./xconfig/sun3os3\ -./xconfig/sun3os4\ -./xconfig/sun4\ -./xconfig/sun4os3\ -./xconfig/sun4os4\ -./xconfig/symmetry\ -./xconfig/tahoe\ -./xconfig/ultra3\ -./xconfig/umax\ -./xconfig/vax - -# End of "alldeps.mak" definitions diff --git a/gdb/alloca.c b/gdb/alloca.c deleted file mode 100644 index 60f86e04850..00000000000 --- a/gdb/alloca.c +++ /dev/null @@ -1,191 +0,0 @@ -/* - alloca -- (mostly) portable public-domain implementation -- D A Gwyn - - last edit: 86/05/30 rms - include config.h, since on VMS it renames some symbols. - Use xmalloc instead of malloc. - - This implementation of the PWB library alloca() function, - which is used to allocate space off the run-time stack so - that it is automatically reclaimed upon procedure exit, - was inspired by discussions with J. Q. Johnson of Cornell. - - It should work under any C implementation that uses an - actual procedure stack (as opposed to a linked list of - frames). There are some preprocessor constants that can - be defined when compiling for your specific system, for - improved efficiency; however, the defaults should be okay. - - The general concept of this implementation is to keep - track of all alloca()-allocated blocks, and reclaim any - that are found to be deeper in the stack than the current - invocation. This heuristic does not reclaim storage as - soon as it becomes invalid, but it will do so eventually. - - As a special case, alloca(0) reclaims storage without - allocating any. It is a good idea to use alloca(0) in - your main control loop, etc. to force garbage collection. -*/ -#ifndef lint -static char SCCSid[] = "@(#)alloca.c 1.1"; /* for the "what" utility */ -#endif - -#ifdef emacs -#include "config.h" -#ifdef static -/* actually, only want this if static is defined as "" - -- this is for usg, in which emacs must undefine static - in order to make unexec workable - */ -#ifndef STACK_DIRECTION -you -lose --- must know STACK_DIRECTION at compile-time -#endif /* STACK_DIRECTION undefined */ -#endif /* static */ -#endif /* emacs */ - -#ifdef __STDC__ -typedef void *pointer; /* generic pointer type */ -#else -typedef char *pointer; /* generic pointer type */ -#endif - -#define NULL 0 /* null pointer constant */ - -extern void free(); -extern pointer xmalloc(); - -/* - Define STACK_DIRECTION if you know the direction of stack - growth for your system; otherwise it will be automatically - deduced at run-time. - - STACK_DIRECTION > 0 => grows toward higher addresses - STACK_DIRECTION < 0 => grows toward lower addresses - STACK_DIRECTION = 0 => direction of growth unknown -*/ - -#ifndef STACK_DIRECTION -#define STACK_DIRECTION 0 /* direction unknown */ -#endif - -#if STACK_DIRECTION != 0 - -#define STACK_DIR STACK_DIRECTION /* known at compile-time */ - -#else /* STACK_DIRECTION == 0; need run-time code */ - -static int stack_dir; /* 1 or -1 once known */ -#define STACK_DIR stack_dir - -static void -find_stack_direction (/* void */) -{ - static char *addr = NULL; /* address of first - `dummy', once known */ - auto char dummy; /* to get stack address */ - - if (addr == NULL) - { /* initial entry */ - addr = &dummy; - - find_stack_direction (); /* recurse once */ - } - else /* second entry */ - if (&dummy > addr) - stack_dir = 1; /* stack grew upward */ - else - stack_dir = -1; /* stack grew downward */ -} - -#endif /* STACK_DIRECTION == 0 */ - -/* - An "alloca header" is used to: - (a) chain together all alloca()ed blocks; - (b) keep track of stack depth. - - It is very important that sizeof(header) agree with malloc() - alignment chunk size. The following default should work okay. -*/ - -#ifndef ALIGN_SIZE -#define ALIGN_SIZE sizeof(double) -#endif - -typedef union hdr -{ - char align[ALIGN_SIZE]; /* to force sizeof(header) */ - struct - { - union hdr *next; /* for chaining headers */ - char *deep; /* for stack depth measure */ - } h; -} header; - -/* - alloca( size ) returns a pointer to at least `size' bytes of - storage which will be automatically reclaimed upon exit from - the procedure that called alloca(). Originally, this space - was supposed to be taken from the current stack frame of the - caller, but that method cannot be made to work for some - implementations of C, for example under Gould's UTX/32. -*/ - -static header *last_alloca_header = NULL; /* -> last alloca header */ - -pointer -alloca (size) /* returns pointer to storage */ - unsigned size; /* # bytes to allocate */ -{ - auto char probe; /* probes stack depth: */ - register char *depth = &probe; - -#if STACK_DIRECTION == 0 - if (STACK_DIR == 0) /* unknown growth direction */ - find_stack_direction (); -#endif - - /* Reclaim garbage, defined as all alloca()ed storage that - was allocated from deeper in the stack than currently. */ - - { - register header *hp; /* traverses linked list */ - - for (hp = last_alloca_header; hp != NULL;) - if ( (STACK_DIR > 0 && hp->h.deep > depth) - || (STACK_DIR < 0 && hp->h.deep < depth) ) - { - register header *np = hp->h.next; - - free ((pointer) hp); /* collect garbage */ - - hp = np; /* -> next header */ - } - else - break; /* rest are not deeper */ - - last_alloca_header = hp; /* -> last valid storage */ - } - - if (size == 0) - return NULL; /* no allocation required */ - - /* Allocate combined header + user data storage. */ - - { - register pointer new = xmalloc (sizeof (header) + size); - /* address of header */ - - ((header *)new)->h.next = last_alloca_header; - ((header *)new)->h.deep = depth; - - last_alloca_header = (header *)new; - - /* User storage begins just after header. */ - - return (pointer)((char *)new + sizeof(header)); - } -} - diff --git a/gdb/altos-xdep.c b/gdb/altos-xdep.c deleted file mode 100644 index 8cbdfc9a0d9..00000000000 --- a/gdb/altos-xdep.c +++ /dev/null @@ -1,166 +0,0 @@ -/* Low level interface to ptrace, for GDB when running under m68k SVR2 Unix - on Altos 3068. Report bugs to Jyrki Kuoppala - Copyright (C) 1989, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "defs.h" -#include "param.h" -#include "frame.h" -#include "inferior.h" - -#ifdef USG -#include -#endif - -#include -#include -#include -#include -#include -#ifdef USG -#include -#ifdef ALTOS -#include -#include -#endif -#endif - -#include "gdbcore.h" -#include /* After a.out.h */ -#include -#include - -/* Work with core dump and executable files, for GDB. - This code would be in core.c if it weren't machine-dependent. */ - -void -core_file_command (filename, from_tty) - char *filename; - int from_tty; -{ - int val; - extern char registers[]; - - /* Discard all vestiges of any previous core file - and mark data and stack spaces as empty. */ - - if (corefile) - free (corefile); - corefile = 0; - - if (corechan >= 0) - close (corechan); - corechan = -1; - - data_start = 0; - data_end = 0; - stack_start = STACK_END_ADDR; - stack_end = STACK_END_ADDR; - - /* Now, if a new core file was specified, open it and digest it. */ - - if (filename) - { - filename = tilde_expand (filename); - make_cleanup (free, filename); - - if (have_inferior_p ()) - error ("To look at a core file, you must kill the inferior with \"kill\"."); - corechan = open (filename, O_RDONLY, 0); - if (corechan < 0) - perror_with_name (filename); - /* 4.2-style (and perhaps also sysV-style) core dump file. */ - { - struct user u; - - unsigned int reg_offset; - - val = myread (corechan, &u, sizeof u); - if (val < 0) - perror_with_name ("Not a core file: reading upage"); - if (val != sizeof u) - error ("Not a core file: could only read %d bytes", val); - data_start = exec_data_start; - -#if !defined (NBPG) -#define NBPG NBPP -#endif -#if !defined (UPAGES) -#define UPAGES USIZE -#endif - - data_end = data_start + NBPG * u.u_dsize; - stack_start = stack_end - NBPG * u.u_ssize; - data_offset = NBPG * UPAGES + exec_data_start % NBPG /* Not sure about this //jkp */; - stack_offset = NBPG * (UPAGES + u.u_dsize); - - /* Some machines put an absolute address in here and some put - the offset in the upage of the regs. */ - reg_offset = (int) u.u_state; - if (reg_offset > NBPG * UPAGES) - reg_offset -= KERNEL_U_ADDR; - - bcopy (&u.u_exdata, &core_aouthdr, sizeof (AOUTHDR)); - printf ("Core file is from \"%s\".\n", u.u_comm); - - /* I don't know where to find this info. - So, for now, mark it as not available. */ - N_SET_MAGIC (core_aouthdr, 0); - - /* Read the register values out of the core file and store - them where `read_register' will find them. */ - - { - register int regno; - - for (regno = 0; regno < NUM_REGS; regno++) - { - char buf[MAX_REGISTER_RAW_SIZE]; - - val = lseek (corechan, register_addr (regno, reg_offset), 0); - if (val < 0 - || (val = myread (corechan, buf, sizeof buf)) < 0) - { - char * buffer = (char *) alloca (strlen (reg_names[regno]) - + 30); - strcpy (buffer, "Reading register "); - strcat (buffer, reg_names[regno]); - - perror_with_name (buffer); - } - - supply_register (regno, buf); - } - } - } - if (filename[0] == '/') - corefile = savestring (filename, strlen (filename)); - else - { - corefile = concat (current_directory, "/", filename, NULL); - } - - set_current_frame ( create_new_frame (read_register (FP_REGNUM), - read_pc ())); - select_frame (get_current_frame (), 0); - validate_files (); - } - else if (from_tty) - printf ("No core file now.\n"); -} diff --git a/gdb/am29k-opcode.h b/gdb/am29k-opcode.h deleted file mode 100644 index 3a32e230c62..00000000000 --- a/gdb/am29k-opcode.h +++ /dev/null @@ -1,271 +0,0 @@ -/* Table of opcodes for the AMD 29000 - Copyright (C) 1990, 1991 Free Software Foundation, Inc. - Contributed by Cygnus Support. Written by Jim Kingdon. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -struct am29k_opcode { - /* Name of the instruction. */ - char *name; - - /* Opcode (i.e. most significant byte of the word). */ - unsigned char opcode; - - /* A string of characters which describe the operands. - Valid characters are: - , Itself. The character appears in the assembly code. - a RA. The register number is in bits 8-15 of the instruction. - b RB. The register number is in bits 0-7 of the instruction. - c RC. The register number is in bits 16-23 of the instruction. - i An immediate operand is in bits 0-7 of the instruction. - x Bits 0-7 and 16-23 of the instruction are bits 0-7 and 8-15 - (respectively) of the immediate operand. - h Same as x but the instruction contains bits 16-31 of the - immediate operand. - X Same as x but bits 16-31 of the signed immediate operand - are set to 1 (thus the operand is always negative). - P,A Bits 0-7 and 16-23 of the instruction are bits 2-9 and 10-17 - (respectively) of the immediate operand. - P=PC-relative, sign-extended to 32 bits. - A=Absolute, zero-extended to 32 bits. - e CE bit (bit 23) for a load/store instruction. - n Control field (bits 16-22) for a load/store instruction. - v Immediate operand in bits 16-23 of the instruction. - (used for trap numbers). - s SA. Special-purpose register number in bits 8-15 - of the instruction. - u UI--bit 7 of the instruction. - r RND--bits 4-6 of the instruction. - d FD--bits 2-3 of the instruction. - f FS--bits 0-1 of the instruction. */ - char *args; -}; - -static struct am29k_opcode am29k_opcodes[] = -{ - -{ "add", 0x14, "c,a,b" }, -{ "add", 0x15, "c,a,i" }, -{ "addc", 0x1c, "c,a,b" }, -{ "addc", 0x1d, "c,a,i" }, -{ "addcs", 0x18, "c,a,b" }, -{ "addcs", 0x19, "c,a,i" }, -{ "addcu", 0x1a, "c,a,b" }, -{ "addcu", 0x1b, "c,a,i" }, -{ "adds", 0x10, "c,a,b" }, -{ "adds", 0x11, "c,a,i" }, -{ "addu", 0x12, "c,a,b" }, -{ "addu", 0x13, "c,a,i" }, -{ "and", 0x90, "c,a,b" }, -{ "and", 0x91, "c,a,i" }, -{ "andn", 0x9c, "c,a,b" }, -{ "andn", 0x9d, "c,a,i" }, -{ "aseq", 0x70, "v,a,b" }, -{ "aseq", 0x71, "v,a,i" }, -{ "asge", 0x5c, "v,a,b" }, -{ "asge", 0x5d, "v,a,i" }, -{ "asgeu", 0x5e, "v,a,b" }, -{ "asgeu", 0x5f, "v,a,i" }, -{ "asgt", 0x58, "v,a,b" }, -{ "asgt", 0x59, "v,a,i" }, -{ "asgtu", 0x5a, "v,a,b" }, -{ "asgtu", 0x5b, "v,a,i" }, -{ "asle", 0x54, "v,a,b" }, -{ "asle", 0x55, "v,a,i" }, -{ "asleu", 0x56, "v,a,b" }, -{ "asleu", 0x57, "v,a,i" }, -{ "aslt", 0x50, "v,a,b" }, -{ "aslt", 0x51, "v,a,i" }, -{ "asltu", 0x52, "v,a,b" }, -{ "asltu", 0x53, "v,a,i" }, -{ "asneq", 0x72, "v,a,b" }, -{ "asneq", 0x73, "v,a,i" }, -{ "call", 0xa8, "a,P" }, -{ "call", 0xa9, "a,A" }, -{ "calli", 0xc8, "a,b" }, -{ "class", 0xe6, "c,a,f" }, -{ "clz", 0x08, "c,b" }, -{ "clz", 0x09, "c,i" }, -{ "const", 0x03, "a,x" }, -{ "consth", 0x02, "a,h" }, -{ "consthz", 0x05, "a,h" }, -{ "constn", 0x01, "a,X" }, -{ "convert", 0xe4, "c,a,u,r,d,f" }, -{ "cpbyte", 0x2e, "c,a,b" }, -{ "cpbyte", 0x2f, "c,a,i" }, -{ "cpeq", 0x60, "c,a,b" }, -{ "cpeq", 0x61, "c,a,i" }, -{ "cpge", 0x4c, "c,a,b" }, -{ "cpge", 0x4d, "c,a,i" }, -{ "cpgeu", 0x4e, "c,a,b" }, -{ "cpgeu", 0x4f, "c,a,i" }, -{ "cpgt", 0x48, "c,a,b" }, -{ "cpgt", 0x49, "c,a,i" }, -{ "cpgtu", 0x4a, "c,a,b" }, -{ "cpgtu", 0x4b, "c,a,i" }, -{ "cple", 0x44, "c,a,b" }, -{ "cple", 0x45, "c,a,i" }, -{ "cpleu", 0x46, "c,a,b" }, -{ "cpleu", 0x47, "c,a,i" }, -{ "cplt", 0x40, "c,a,b" }, -{ "cplt", 0x41, "c,a,i" }, -{ "cpltu", 0x42, "c,a,b" }, -{ "cpltu", 0x43, "c,a,i" }, -{ "cpneq", 0x62, "c,a,b" }, -{ "cpneq", 0x63, "c,a,i" }, -{ "dadd", 0xf1, "c,a,b" }, -{ "ddiv", 0xf7, "c,a,b" }, -{ "deq", 0xeb, "c,a,b" }, -{ "dge", 0xef, "c,a,b" }, -{ "dgt", 0xed, "c,a,b" }, -{ "div", 0x6a, "c,a,b" }, -{ "div", 0x6b, "c,a,i" }, -{ "div0", 0x68, "c,b" }, -{ "div0", 0x69, "c,i" }, -{ "divide", 0xe1, "c,a,b" }, -{ "dividu", 0xe3, "c,a,b" }, -{ "divl", 0x6c, "c,a,b" }, -{ "divl", 0x6d, "c,a,i" }, -{ "divrem", 0x6e, "c,a,b" }, -{ "divrem", 0x6f, "c,a,i" }, -{ "dmac", 0xd9, "F,C,a,b" }, -{ "dmsm", 0xdb, "c,a,b" }, -{ "dmul", 0xf5, "c,a,b" }, -{ "dsub", 0xf3, "c,a,b" }, -{ "emulate", 0xd7, "v,a,b" }, -{ "exbyte", 0x0a, "c,a,b" }, -{ "exbyte", 0x0b, "c,a,i" }, -{ "exhw", 0x7c, "c,a,b" }, -{ "exhw", 0x7d, "c,a,i" }, -{ "exhws", 0x7e, "c,a" }, -{ "extract", 0x7a, "c,a,b" }, -{ "extract", 0x7b, "c,a,i" }, -{ "fadd", 0xf0, "c,a,b" }, -{ "fdiv", 0xf6, "c,a,b" }, -{ "fdmul", 0xf9, "c,a,b" }, -{ "feq", 0xea, "c,a,b" }, -{ "fge", 0xee, "c,a,b" }, -{ "fgt", 0xec, "c,a,b" }, -{ "fmac", 0xd8, "F,C,a,b" }, -{ "fmsm", 0xda, "c,a,b" }, -{ "fmul", 0xf4, "c,a,b" }, -{ "fsub", 0xf2, "c,a,b" }, -{ "halt", 0x89, "" }, -{ "inbyte", 0x0c, "c,a,b" }, -{ "inbyte", 0x0d, "c,a,i" }, -{ "inhw", 0x78, "c,a,b" }, -{ "inhw", 0x79, "c,a,i" }, -{ "inv", 0x9f, "" }, -{ "iret", 0x88, "" }, -{ "iretinv", 0x8c, "" }, -{ "jmp", 0xa0, "P" }, -{ "jmp", 0xa1, "A" }, -{ "jmpf", 0xa4, "a,P" }, -{ "jmpf", 0xa5, "a,A" }, -{ "jmpfdec", 0xb4, "a,P" }, -{ "jmpfdec", 0xb5, "a,A" }, -{ "jmpfi", 0xc4, "a,b" }, -{ "jmpi", 0xc0, "b" }, -{ "jmpt", 0xac, "a,P" }, -{ "jmpt", 0xad, "a,A" }, -{ "jmpti", 0xcc, "a,b" }, -{ "load", 0x16, "e,n,a,b" }, -{ "load", 0x17, "e,n,a,i" }, -{ "loadl", 0x06, "e,n,a,b" }, -{ "loadl", 0x07, "e,n,a,i" }, -{ "loadm", 0x36, "e,n,a,b" }, -{ "loadm", 0x37, "e,n,a,i" }, -{ "loadset", 0x26, "e,n,a,b" }, -{ "loadset", 0x27, "e,n,a,i" }, -{ "mfacc", 0xe9, "c,d,f" }, -{ "mfsr", 0xc6, "c,s" }, -{ "mftlb", 0xb6, "c,a" }, -{ "mtacc", 0xe8, "a,d,f" }, -{ "mtsr", 0xce, "s,b" }, -{ "mtsrim", 0x04, "s,x" }, -{ "mttlb", 0xbe, "a,b" }, -{ "mul", 0x64, "c,a,b" }, -{ "mul", 0x65, "c,a,i" }, -{ "mull", 0x66, "c,a,b" }, -{ "mull", 0x67, "c,a,i" }, -{ "multiplu", 0xe2, "c,a,b" }, -{ "multiply", 0xe0, "c,a,b" }, -{ "multm", 0xde, "c,a,b" }, -{ "multmu", 0xdf, "c,a,b" }, -{ "mulu", 0x74, "c,a,b" }, -{ "mulu", 0x75, "c,a,i" }, -{ "nand", 0x9a, "c,a,b" }, -{ "nand", 0x9b, "c,a,i" }, -{ "nor", 0x98, "c,a,b" }, -{ "nor", 0x99, "c,a,i" }, -{ "or", 0x92, "c,a,b" }, -{ "or", 0x93, "c,a,i" }, -{ "orn", 0xaa, "c,a,b" }, -{ "orn", 0xab, "c,a,i" }, - -/* The description of "setip" in Chapter 8 ("instruction set") of the user's - manual claims that these are absolute register numbers. But section - 7.2.1 explains that they are not. The latter is correct, so print - these normally ("lr0", "lr5", etc.). */ -{ "setip", 0x9e, "c,a,b" }, - -{ "sll", 0x80, "c,a,b" }, -{ "sll", 0x81, "c,a,i" }, -{ "sqrt", 0xe5, "c,a,f" }, -{ "sra", 0x86, "c,a,b" }, -{ "sra", 0x87, "c,a,i" }, -{ "srl", 0x82, "c,a,b" }, -{ "srl", 0x83, "c,a,i" }, -{ "store", 0x1e, "e,n,a,b" }, -{ "store", 0x1f, "e,n,a,i" }, -{ "storel", 0x0e, "e,n,a,b" }, -{ "storel", 0x0f, "e,n,a,i" }, -{ "storem", 0x3e, "e,n,a,b" }, -{ "storem", 0x3f, "e,n,a,i" }, -{ "sub", 0x24, "c,a,b" }, -{ "sub", 0x25, "c,a,i" }, -{ "subc", 0x2c, "c,a,b" }, -{ "subc", 0x2d, "c,a,i" }, -{ "subcs", 0x28, "c,a,b" }, -{ "subcs", 0x29, "c,a,i" }, -{ "subcu", 0x2a, "c,a,b" }, -{ "subcu", 0x2b, "c,a,i" }, -{ "subr", 0x34, "c,a,b" }, -{ "subr", 0x35, "c,a,i" }, -{ "subrc", 0x3c, "c,a,b" }, -{ "subrc", 0x3d, "c,a,i" }, -{ "subrcs", 0x38, "c,a,b" }, -{ "subrcs", 0x39, "c,a,i" }, -{ "subrcu", 0x3a, "c,a,b" }, -{ "subrcu", 0x3b, "c,a,i" }, -{ "subrs", 0x30, "c,a,b" }, -{ "subrs", 0x31, "c,a,i" }, -{ "subru", 0x32, "c,a,b" }, -{ "subru", 0x33, "c,a,i" }, -{ "subs", 0x20, "c,a,b" }, -{ "subs", 0x21, "c,a,i" }, -{ "subu", 0x22, "c,a,b" }, -{ "subu", 0x23, "c,a,i" }, -{ "xnor", 0x96, "c,a,b" }, -{ "xnor", 0x97, "c,a,i" }, -{ "xor", 0x94, "c,a,b" }, -{ "xor", 0x95, "c,a,i" } - -}; - -#define NUM_OPCODES ((sizeof am29k_opcodes) / (sizeof am29k_opcodes[0])) - diff --git a/gdb/am29k-pinsn.c b/gdb/am29k-pinsn.c deleted file mode 100644 index d0e18fcb616..00000000000 --- a/gdb/am29k-pinsn.c +++ /dev/null @@ -1,302 +0,0 @@ -/* Instruction printing code for the AMD 29000 - Copyright (C) 1990 Free Software Foundation, Inc. - Contributed by Cygnus Support. Written by Jim Kingdon. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include - -#include "defs.h" -#include "target.h" -#include "am29k-opcode.h" - -/* Print a symbolic representation of a general-purpose - register number NUM on STREAM. - NUM is a number as found in the instruction, not as found in - debugging symbols; it must be in the range 0-255. */ -static void -print_general (num, stream) - int num; - FILE *stream; -{ - if (num < 128) - fprintf_filtered (stream, "gr%d", num); - else - fprintf_filtered (stream, "lr%d", num - 128); -} - -/* Like print_general but a special-purpose register. - - The mnemonics used by the AMD assembler are not quite the same - as the ones in the User's Manual. We use the ones that the - assembler uses. */ -static void -print_special (num, stream) - int num; - FILE *stream; -{ - /* Register names of registers 0-SPEC0_NUM-1. */ - static char *spec0_names[] = { - "vab", "ops", "cps", "cfg", "cha", "chd", "chc", "rbp", "tmc", "tmr", - "pc0", "pc1", "pc2", "mmu", "lru" - }; -#define SPEC0_NUM ((sizeof spec0_names) / (sizeof spec0_names[0])) - - /* Register names of registers 128-128+SPEC128_NUM-1. */ - static char *spec128_names[] = { - "ipc", "ipa", "ipb", "q", "alu", "bp", "fc", "cr" - }; -#define SPEC128_NUM ((sizeof spec128_names) / (sizeof spec128_names[0])) - - /* Register names of registers 160-160+SPEC160_NUM-1. */ - static char *spec160_names[] = { - "fpe", "inte", "fps", "sr163", "exop" - }; -#define SPEC160_NUM ((sizeof spec160_names) / (sizeof spec160_names[0])) - - if (num < SPEC0_NUM) - fprintf_filtered (stream, spec0_names[num]); - else if (num >= 128 && num < 128 + SPEC128_NUM) - fprintf_filtered (stream, spec128_names[num-128]); - else if (num >= 160 && num < 160 + SPEC160_NUM) - fprintf_filtered (stream, spec160_names[num-160]); - else - fprintf_filtered (stream, "sr%d", num); -} - -/* Is an instruction with OPCODE a delayed branch? */ -static int -is_delayed_branch (opcode) - int opcode; -{ - return (opcode == 0xa8 || opcode == 0xa9 || opcode == 0xa0 || opcode == 0xa1 - || opcode == 0xa4 || opcode == 0xa5 - || opcode == 0xb4 || opcode == 0xb5 - || opcode == 0xc4 || opcode == 0xc0 - || opcode == 0xac || opcode == 0xad - || opcode == 0xcc); -} - -/* Now find the four bytes of INSN and put them in *INSN{0,8,16,24}. - Note that the amd can be set up as either - big or little-endian (the tm file says which) and we can't assume - the host machine is the same. */ -static void -find_bytes (insn, insn0, insn8, insn16, insn24) - char *insn; - unsigned char *insn0; - unsigned char *insn8; - unsigned char *insn16; - unsigned char *insn24; -{ -#if TARGET_BYTE_ORDER == BIG_ENDIAN - *insn24 = insn[0]; - *insn16 = insn[1]; - *insn8 = insn[2]; - *insn0 = insn[3]; -#else /* Little-endian. */ - *insn24 = insn[3]; - *insn16 = insn[2]; - *insn8 = insn[1]; - *insn0 = insn[0]; -#endif /* Little-endian. */ -} - -/* Print one instruction from MEMADDR on STREAM. - Return the size of the instruction (always 4 on am29k). */ -int -print_insn (memaddr, stream) - CORE_ADDR memaddr; - FILE *stream; -{ - /* The raw instruction. */ - char insn[4]; - - /* The four bytes of the instruction. */ - unsigned char insn24, insn16, insn8, insn0; - - struct am29k_opcode *opcode; - - read_memory (memaddr, &insn[0], 4); - - find_bytes (insn, &insn0, &insn8, &insn16, &insn24); - - /* Handle the nop (aseq 0x40,gr1,gr1) specially */ - if ((insn24==0x70) && (insn16==0x40) && (insn8==0x01) && (insn0==0x01)) { - fprintf_filtered (stream,"nop"); - return 4; - } - - /* The opcode is always in insn24. */ - for (opcode = &am29k_opcodes[0]; - opcode < &am29k_opcodes[NUM_OPCODES]; - ++opcode) - { - if (insn24 == opcode->opcode) - { - char *s; - - fprintf_filtered (stream, "%s ", opcode->name); - for (s = opcode->args; *s != '\0'; ++s) - { - switch (*s) - { - case 'a': - print_general (insn8, stream); - break; - - case 'b': - print_general (insn0, stream); - break; - - case 'c': - print_general (insn16, stream); - break; - - case 'i': - fprintf_filtered (stream, "%d", insn0); - break; - - case 'x': - fprintf_filtered (stream, "%d", (insn16 << 8) + insn0); - break; - - case 'h': - fprintf_filtered (stream, "0x%x", - (insn16 << 24) + (insn0 << 16)); - break; - - case 'X': - fprintf_filtered (stream, "%d", - ((insn16 << 8) + insn0) | 0xffff0000); - break; - - case 'P': - /* This output looks just like absolute addressing, but - maybe that's OK (it's what the GDB 68k and EBMON - 29k disassemblers do). */ - /* All the shifting is to sign-extend it. p*/ - print_address - (memaddr + - (((int)((insn16 << 10) + (insn0 << 2)) << 14) >> 14), - stream); - break; - - case 'A': - print_address ((insn16 << 10) + (insn0 << 2), stream); - break; - - case 'e': - fprintf_filtered (stream, "%d", insn16 >> 7); - break; - - case 'n': - fprintf_filtered (stream, "0x%x", insn16 & 0x7f); - break; - - case 'v': - fprintf_filtered (stream, "0x%x", insn16); - break; - - case 's': - print_special (insn8, stream); - break; - - case 'u': - fprintf_filtered (stream, "%d", insn0 >> 7); - break; - - case 'r': - fprintf_filtered (stream, "%d", (insn0 >> 4) & 7); - break; - - case 'd': - fprintf_filtered (stream, "%d", (insn0 >> 2) & 3); - break; - - case 'f': - fprintf_filtered (stream, "%d", insn0 & 3); - break; - - case 'F': - fprintf_filtered (stream, "%d", (insn16 >> 2) & 15); - break; - - case 'C': - fprintf_filtered (stream, "%d", insn16 & 3); - break; - - default: - fprintf_filtered (stream, "%c", *s); - } - } - - /* Now we look for a const,consth pair of instructions, - in which case we try to print the symbolic address. */ - if (insn24 == 2) /* consth */ - { - int errcode; - char prev_insn[4]; - unsigned char prev_insn0, prev_insn8, prev_insn16, prev_insn24; - - errcode = target_read_memory (memaddr - 4, - &prev_insn[0], - 4); - if (errcode == 0) - { - /* If it is a delayed branch, we need to look at the - instruction before the delayed brach to handle - things like - - const _foo - call _printf - consth _foo - */ - find_bytes (prev_insn, &prev_insn0, &prev_insn8, - &prev_insn16, &prev_insn24); - if (is_delayed_branch (prev_insn24)) - { - errcode = target_read_memory - (memaddr - 8, &prev_insn[0], 4); - find_bytes (prev_insn, &prev_insn0, &prev_insn8, - &prev_insn16, &prev_insn24); - } - } - - /* If there was a problem reading memory, then assume - the previous instruction was not const. */ - if (errcode == 0) - { - /* Is it const to the same register? */ - if (prev_insn24 == 3 - && prev_insn8 == insn8) - { - fprintf_filtered (stream, "\t; "); - print_address (((insn16 << 24) + (insn0 << 16) - + (prev_insn16 << 8) + (prev_insn0)), - stream); - } - } - } - - return 4; - } - } - fprintf_filtered (stream, ".word 0x%8x", - (insn24 << 24) + (insn16 << 16) + (insn8 << 8) + insn0); - return 4; -} diff --git a/gdb/am29k-tdep.c b/gdb/am29k-tdep.c deleted file mode 100644 index ce1fa8557b5..00000000000 --- a/gdb/am29k-tdep.c +++ /dev/null @@ -1,698 +0,0 @@ -/* Target-machine dependent code for the AMD 29000 - Copyright (C) 1990 Free Software Foundation, Inc. - Contributed by Cygnus Support. Written by Jim Kingdon. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include "defs.h" -#include "gdbcore.h" -#include -#include "frame.h" -#include "value.h" -#include "param.h" -#include "symtab.h" -#include "inferior.h" - -extern CORE_ADDR text_start; /* FIXME, kludge... */ - -/* Structure to hold cached info about function prologues. */ -struct prologue_info -{ - CORE_ADDR pc; /* First addr after fn prologue */ - unsigned rsize, msize; /* register stack frame size, mem stack ditto */ - unsigned mfp_used : 1; /* memory frame pointer used */ - unsigned rsize_valid : 1; /* Validity bits for the above */ - unsigned msize_valid : 1; - unsigned mfp_valid : 1; -}; - -/* Examine the prologue of a function which starts at PC. Return - the first addess past the prologue. If MSIZE is non-NULL, then - set *MSIZE to the memory stack frame size. If RSIZE is non-NULL, - then set *RSIZE to the register stack frame size (not including - incoming arguments and the return address & frame pointer stored - with them). If no prologue is found, *RSIZE is set to zero. - If no prologue is found, or a prologue which doesn't involve - allocating a memory stack frame, then set *MSIZE to zero. - - Note that both msize and rsize are in bytes. This is not consistent - with the _User's Manual_ with respect to rsize, but it is much more - convenient. - - If MFP_USED is non-NULL, *MFP_USED is set to nonzero if a memory - frame pointer is being used. */ -CORE_ADDR -examine_prologue (pc, rsize, msize, mfp_used) - CORE_ADDR pc; - unsigned *msize; - unsigned *rsize; - int *mfp_used; -{ - long insn; - CORE_ADDR p = pc; - int misc_index = find_pc_misc_function (pc); - struct prologue_info *mi = 0; - - if (misc_index >= 0) - mi = (struct prologue_info *)misc_function_vector[misc_index].misc_info; - - if (mi != 0) - { - int valid = 1; - if (rsize != NULL) - { - *rsize = mi->rsize; - valid &= mi->rsize_valid; - } - if (msize != NULL) - { - *msize = mi->msize; - valid &= mi->msize_valid; - } - if (mfp_used != NULL) - { - *mfp_used = mi->mfp_used; - valid &= mi->mfp_valid; - } - if (valid) - return mi->pc; - } - - if (rsize != NULL) - *rsize = 0; - if (msize != NULL) - *msize = 0; - if (mfp_used != NULL) - *mfp_used = 0; - - /* Prologue must start with subtracting a constant from gr1. - Normally this is sub gr1,gr1,. */ - insn = read_memory_integer (p, 4); - if ((insn & 0xffffff00) != 0x25010100) - { - /* If the frame is large, instead of a single instruction it - might be a pair of instructions: - const , - sub gr1,gr1, - */ - int reg; - /* Possible value for rsize. */ - unsigned int rsize0; - - if ((insn & 0xff000000) != 0x03000000) - { - p = pc; - goto done; - } - reg = (insn >> 8) & 0xff; - rsize0 = (((insn >> 8) & 0xff00) | (insn & 0xff)); - p += 4; - insn = read_memory_integer (p, 4); - if ((insn & 0xffffff00) != 0x24010100 - || (insn & 0xff) != reg) - { - p = pc; - goto done; - } - if (rsize != NULL) - *rsize = rsize0; - } - else - { - if (rsize != NULL) - *rsize = (insn & 0xff); - } - p += 4; - - /* Next instruction must be asgeu V_SPILL,gr1,rab. */ - insn = read_memory_integer (p, 4); - if (insn != 0x5e40017e) - { - p = pc; - goto done; - } - p += 4; - - /* Next instruction usually sets the frame pointer (lr1) by adding - from gr1. However, this can (and high C does) be - deferred until anytime before the first function call. So it is - OK if we don't see anything which sets lr1. */ - /* Normally this is just add lr1,gr1,. */ - insn = read_memory_integer (p, 4); - if ((insn & 0xffffff00) == 0x15810100) - p += 4; - else - { - /* However, for large frames it can be - const , - add lr1,gr1, - */ - int reg; - CORE_ADDR q; - - if ((insn & 0xff000000) == 0x03000000) - { - reg = (insn >> 8) & 0xff; - q = p + 4; - insn = read_memory_integer (q, 4); - if ((insn & 0xffffff00) == 0x14810100 - && (insn & 0xff) == reg) - p = q; - } - } - - /* Next comes "add lr{},msp,0", but only if a memory - frame pointer is in use. We just check for add lr,msp,0; - we don't check this rsize against the first instruction, and - we don't check that the trace-back tag indicates a memory frame pointer - is in use. - - The recommended instruction is actually "sll lr,msp,0". - We check for that, too. Originally Jim Kingdon's code seemed - to be looking for a "sub" instruction here, but the mask was set - up to lose all the time. */ - insn = read_memory_integer (p, 4); - if (((insn & 0xff80ffff) == 0x15807d00) /* add */ - || ((insn & 0xff80ffff) == 0x81807d00) ) /* sll */ - { - p += 4; - if (mfp_used != NULL) - *mfp_used = 1; - } - - /* Next comes a subtraction from msp to allocate a memory frame, - but only if a memory frame is - being used. We don't check msize against the trace-back tag. - - Normally this is just - sub msp,msp, - */ - insn = read_memory_integer (p, 4); - if ((insn & 0xffffff00) == 0x257d7d00) - { - p += 4; - if (msize != NULL) - *msize = insn & 0xff; - } - else - { - /* For large frames, instead of a single instruction it might - be - - const , - consth , ; optional - sub msp,msp, - */ - int reg; - unsigned msize0; - CORE_ADDR q = p; - - if ((insn & 0xff000000) == 0x03000000) - { - reg = (insn >> 8) & 0xff; - msize0 = ((insn >> 8) & 0xff00) | (insn & 0xff); - q += 4; - insn = read_memory_integer (q, 4); - /* Check for consth. */ - if ((insn & 0xff000000) == 0x02000000 - && (insn & 0x0000ff00) == reg) - { - msize0 |= (insn << 8) & 0xff000000; - msize0 |= (insn << 16) & 0x00ff0000; - q += 4; - insn = read_memory_integer (q, 4); - } - /* Check for sub msp,msp,. */ - if ((insn & 0xffffff00) == 0x247d7d00 - && (insn & 0xff) == reg) - { - p = q + 4; - if (msize != NULL) - *msize = msize0; - } - } - } - - done: - if (misc_index >= 0) - { - if (mi == 0) - { - /* Add a new cache entry. */ - mi = (struct prologue_info *)xmalloc (sizeof (struct prologue_info)); - misc_function_vector[misc_index].misc_info = (char *)mi; - mi->rsize_valid = 0; - mi->msize_valid = 0; - mi->mfp_valid = 0; - } - /* else, cache entry exists, but info is incomplete. */ - mi->pc = p; - if (rsize != NULL) - { - mi->rsize = *rsize; - mi->rsize_valid = 1; - } - if (msize != NULL) - { - mi->msize = *msize; - mi->msize_valid = 1; - } - if (mfp_used != NULL) - { - mi->mfp_used = *mfp_used; - mi->mfp_valid = 1; - } - } - return p; -} - -/* Advance PC across any function entry prologue instructions - to reach some "real" code. */ - -CORE_ADDR -skip_prologue (pc) - CORE_ADDR pc; -{ - return examine_prologue (pc, (unsigned *)NULL, (unsigned *)NULL, - (int *)NULL); -} - -/* Initialize the frame. In addition to setting "extra" frame info, - we also set ->frame because we use it in a nonstandard way, and ->pc - because we need to know it to get the other stuff. See the diagram - of stacks and the frame cache in tm-29k.h for more detail. */ -static void -init_frame_info (innermost_frame, fci) - int innermost_frame; - struct frame_info *fci; -{ - CORE_ADDR p; - long insn; - unsigned rsize; - unsigned msize; - int mfp_used; - struct symbol *func; - - p = fci->pc; - - if (innermost_frame) - fci->frame = read_register (GR1_REGNUM); - else - fci->frame = fci->next_frame + fci->next->rsize; - -#if CALL_DUMMY_LOCATION == ON_STACK - This wont work; -#else - if (PC_IN_CALL_DUMMY (p, 0, 0)) -#endif - { - fci->rsize = DUMMY_FRAME_RSIZE; - /* This doesn't matter since we never try to get locals or args - from a dummy frame. */ - fci->msize = 0; - /* Dummy frames always use a memory frame pointer. */ - fci->saved_msp = - read_register_stack_integer (fci->frame + DUMMY_FRAME_RSIZE - 4, 4); - return; - } - - func = find_pc_function (p); - if (func != NULL) - p = BLOCK_START (SYMBOL_BLOCK_VALUE (func)); - else - { - /* Search backward to find the trace-back tag. However, - do not trace back beyond the start of the text segment - (just as a sanity check to avoid going into never-never land). */ - while (p >= text_start - && ((insn = read_memory_integer (p, 4)) & 0xff000000) != 0) - p -= 4; - - if (p < text_start) - { - /* Couldn't find the trace-back tag. - Something strange is going on. */ - fci->saved_msp = 0; - fci->rsize = 0; - fci->msize = 0; - return; - } - else - /* Advance to the first word of the function, i.e. the word - after the trace-back tag. */ - p += 4; - } - /* We've found the start of the function. Since High C interchanges - the meanings of bits 23 and 22 (as of Jul 90), and we - need to look at the prologue anyway to figure out - what rsize is, ignore the contents of the trace-back tag. */ - examine_prologue (p, &rsize, &msize, &mfp_used); - fci->rsize = rsize; - fci->msize = msize; - if (innermost_frame) - { - fci->saved_msp = read_register (MSP_REGNUM) + msize; - } - else - { - if (mfp_used) - fci->saved_msp = - read_register_stack_integer (fci->frame + rsize - 1, 4); - else - fci->saved_msp = fci->next->saved_msp + msize; - } -} - -void -init_extra_frame_info (fci) - struct frame_info *fci; -{ - if (fci->next == 0) - /* Assume innermost frame. May produce strange results for "info frame" - but there isn't any way to tell the difference. */ - init_frame_info (1, fci); - else { - /* We're in get_prev_frame_info. - Take care of everything in init_frame_pc. */ - ; - } -} - -void -init_frame_pc (fromleaf, fci) - int fromleaf; - struct frame_info *fci; -{ - fci->pc = (fromleaf ? SAVED_PC_AFTER_CALL (fci->next) : - fci->next ? FRAME_SAVED_PC (fci->next) : read_pc ()); - init_frame_info (0, fci); -} - -/* Local variables (i.e. LOC_LOCAL) are on the memory stack, with their - offsets being relative to the memory stack pointer (high C) or - saved_msp (gcc). */ - -CORE_ADDR -frame_locals_address (fi) - struct frame_info *fi; -{ - struct block *b = block_for_pc (fi->pc); - /* If compiled without -g, assume GCC. */ - if (b == NULL || BLOCK_GCC_COMPILED (b)) - return fi->saved_msp; - else - return fi->saved_msp - fi->msize; -} - -/* Routines for reading the register stack. The caller gets to treat - the register stack as a uniform stack in memory, from address $gr1 - straight through $rfb and beyond. */ - -/* Analogous to read_memory except the length is understood to be 4. - Also, myaddr can be NULL (meaning don't bother to read), and - if actual_mem_addr is non-NULL, store there the address that it - was fetched from (or if from a register the offset within - registers). Set *LVAL to lval_memory or lval_register, depending - on where it came from. */ -void -read_register_stack (memaddr, myaddr, actual_mem_addr, lval) - CORE_ADDR memaddr; - char *myaddr; - CORE_ADDR *actual_mem_addr; - enum lval_type *lval; -{ - long rfb = read_register (RFB_REGNUM); - long rsp = read_register (RSP_REGNUM); - if (memaddr < rfb) - { - /* It's in a register. */ - int regnum = (memaddr - rsp) / 4 + LR0_REGNUM; - if (regnum < LR0_REGNUM || regnum > LR0_REGNUM + 127) - error ("Attempt to read register stack out of range."); - if (myaddr != NULL) - read_register_gen (regnum, myaddr); - if (lval != NULL) - *lval = lval_register; - if (actual_mem_addr != NULL) - *actual_mem_addr = REGISTER_BYTE (regnum); - } - else - { - /* It's in the memory portion of the register stack. */ - if (myaddr != NULL) - read_memory (memaddr, myaddr, 4); - if (lval != NULL) - *lval = lval_memory; - if (actual_mem_addr != NULL) - *actual_mem_addr = memaddr; - } -} - -/* Analogous to read_memory_integer - except the length is understood to be 4. */ -long -read_register_stack_integer (memaddr, len) - CORE_ADDR memaddr; - int len; -{ - long buf; - read_register_stack (memaddr, &buf, NULL, NULL); - SWAP_TARGET_AND_HOST (&buf, 4); - return buf; -} - -/* Copy 4 bytes from GDB memory at MYADDR into inferior memory - at MEMADDR and put the actual address written into in - *ACTUAL_MEM_ADDR. */ -static void -write_register_stack (memaddr, myaddr, actual_mem_addr) - CORE_ADDR memaddr; - char *myaddr; - CORE_ADDR *actual_mem_addr; -{ - long rfb = read_register (RFB_REGNUM); - long rsp = read_register (RSP_REGNUM); - if (memaddr < rfb) - { - /* It's in a register. */ - int regnum = (memaddr - rsp) / 4 + LR0_REGNUM; - if (regnum < LR0_REGNUM || regnum > LR0_REGNUM + 127) - error ("Attempt to read register stack out of range."); - if (myaddr != NULL) - write_register (regnum, *(long *)myaddr); - if (actual_mem_addr != NULL) - *actual_mem_addr = NULL; - } - else - { - /* It's in the memory portion of the register stack. */ - if (myaddr != NULL) - write_memory (memaddr, myaddr, 4); - if (actual_mem_addr != NULL) - *actual_mem_addr = memaddr; - } -} - -/* Find register number REGNUM relative to FRAME and put its - (raw) contents in *RAW_BUFFER. Set *OPTIMIZED if the variable - was optimized out (and thus can't be fetched). If the variable - was fetched from memory, set *ADDRP to where it was fetched from, - otherwise it was fetched from a register. - - The argument RAW_BUFFER must point to aligned memory. */ -void -get_saved_register (raw_buffer, optimized, addrp, frame, regnum, lvalp) - char *raw_buffer; - int *optimized; - CORE_ADDR *addrp; - FRAME frame; - int regnum; - enum lval_type *lvalp; -{ - struct frame_info *fi = get_frame_info (frame); - CORE_ADDR addr; - enum lval_type lval; - - /* Once something has a register number, it doesn't get optimized out. */ - if (optimized != NULL) - *optimized = 0; - if (regnum == RSP_REGNUM) - { - if (raw_buffer != NULL) - *(CORE_ADDR *)raw_buffer = fi->frame; - if (lvalp != NULL) - *lvalp = not_lval; - return; - } - else if (regnum == PC_REGNUM) - { - if (raw_buffer != NULL) - *(CORE_ADDR *)raw_buffer = fi->pc; - - /* Not sure we have to do this. */ - if (lvalp != NULL) - *lvalp = not_lval; - - return; - } - else if (regnum == MSP_REGNUM) - { - if (raw_buffer != NULL) - { - if (fi->next != NULL) - *(CORE_ADDR *)raw_buffer = fi->next->saved_msp; - else - *(CORE_ADDR *)raw_buffer = read_register (MSP_REGNUM); - } - /* The value may have been computed, not fetched. */ - if (lvalp != NULL) - *lvalp = not_lval; - return; - } - else if (regnum < LR0_REGNUM || regnum >= LR0_REGNUM + 128) - { - /* These registers are not saved over procedure calls, - so just print out the current values. */ - if (raw_buffer != NULL) - *(CORE_ADDR *)raw_buffer = read_register (regnum); - if (lvalp != NULL) - *lvalp = lval_register; - if (addrp != NULL) - *addrp = REGISTER_BYTE (regnum); - return; - } - - addr = fi->frame + (regnum - LR0_REGNUM) * 4; - if (raw_buffer != NULL) - read_register_stack (addr, raw_buffer, &addr, &lval); - if (lvalp != NULL) - *lvalp = lval; - if (addrp != NULL) - *addrp = addr; -} - -/* Discard from the stack the innermost frame, - restoring all saved registers. */ - -void -pop_frame () -{ - FRAME frame = get_current_frame (); - struct frame_info *fi = get_frame_info (frame); - CORE_ADDR rfb = read_register (RFB_REGNUM); - CORE_ADDR gr1 = fi->frame + fi->rsize; - CORE_ADDR lr1; - CORE_ADDR ret_addr; - int i; - - /* If popping a dummy frame, need to restore registers. */ - if (PC_IN_CALL_DUMMY (read_register (PC_REGNUM), - read_register (SP_REGNUM), - FRAME_FP (fi))) - { - for (i = 0; i < DUMMY_SAVE_SR128; ++i) - write_register - (SR_REGNUM (i + 128), - read_register (LR0_REGNUM + DUMMY_ARG / 4 + i)); - for (i = 0; i < DUMMY_SAVE_GREGS; ++i) - write_register - (RETURN_REGNUM + i, - read_register (LR0_REGNUM + DUMMY_ARG / 4 + DUMMY_SAVE_SR128 + i)); - } - - /* Restore the memory stack pointer. */ - write_register (MSP_REGNUM, fi->saved_msp); - /* Restore the register stack pointer. */ - write_register (GR1_REGNUM, gr1); - /* Check whether we need to fill registers. */ - lr1 = read_register (LR0_REGNUM + 1); - if (lr1 > rfb) - { - /* Fill. */ - int num_bytes = lr1 - rfb; - int i; - long word; - write_register (RAB_REGNUM, read_register (RAB_REGNUM) + num_bytes); - write_register (RFB_REGNUM, lr1); - for (i = 0; i < num_bytes; i += 4) - { - /* Note: word is in host byte order. */ - word = read_memory_integer (rfb + i, 4); - write_register (LR0_REGNUM + ((rfb - gr1) % 0x80) + i / 4, word); - } - } - ret_addr = read_register (LR0_REGNUM); - write_register (PC_REGNUM, ret_addr); - write_register (NPC_REGNUM, ret_addr + 4); - flush_cached_frames (); - set_current_frame (create_new_frame (0, read_pc())); -} - -/* Push an empty stack frame, to record the current PC, etc. */ - -void -push_dummy_frame () -{ - long w; - CORE_ADDR rab, gr1; - CORE_ADDR msp = read_register (MSP_REGNUM); - int i; - - /* Save the PC. */ - write_register (LR0_REGNUM, read_register (PC_REGNUM)); - - /* Allocate the new frame. */ - gr1 = read_register (GR1_REGNUM) - DUMMY_FRAME_RSIZE; - write_register (GR1_REGNUM, gr1); - - rab = read_register (RAB_REGNUM); - if (gr1 < rab) - { - /* We need to spill registers. */ - int num_bytes = rab - gr1; - CORE_ADDR rfb = read_register (RFB_REGNUM); - int i; - long word; - - write_register (RFB_REGNUM, rfb - num_bytes); - write_register (RAB_REGNUM, gr1); - for (i = 0; i < num_bytes; i += 4) - { - /* Note: word is in target byte order. */ - read_register_gen (LR0_REGNUM + i / 4, &word, 4); - write_memory (rfb - num_bytes + i, &word, 4); - } - } - - /* There are no arguments in to the dummy frame, so we don't need - more than rsize plus the return address and lr1. */ - write_register (LR0_REGNUM + 1, gr1 + DUMMY_FRAME_RSIZE + 2 * 4); - - /* Set the memory frame pointer. */ - write_register (LR0_REGNUM + DUMMY_FRAME_RSIZE / 4 - 1, msp); - - /* Allocate arg_slop. */ - write_register (MSP_REGNUM, msp - 16 * 4); - - /* Save registers. */ - for (i = 0; i < DUMMY_SAVE_SR128; ++i) - write_register (LR0_REGNUM + DUMMY_ARG / 4 + i, - read_register (SR_REGNUM (i + 128))); - for (i = 0; i < DUMMY_SAVE_GREGS; ++i) - write_register (LR0_REGNUM + DUMMY_ARG / 4 + DUMMY_SAVE_SR128 + i, - read_register (RETURN_REGNUM + i)); -} diff --git a/gdb/ansidecl.h b/gdb/ansidecl.h deleted file mode 100755 index aecdb5eeef3..00000000000 --- a/gdb/ansidecl.h +++ /dev/null @@ -1,93 +0,0 @@ -/* Copyright (C) 1989 Free Software Foundation, Inc. -This file is part of the GNU C 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* ANSI and traditional C compatibility macros - - ANSI C is assumed if __STDC__ is #defined. - - Macros - PTR - Generic pointer type - LONG_DOUBLE - `long double' type - CONST - `const' keyword - VOLATILE - `volatile' keyword - SIGNED - `signed' keyword - PTRCONST - Generic const pointer (void *const) - - EXFUN(name, prototype) - declare external function NAME - with prototype PROTOTYPE - DEFUN(name, arglist, args) - define function NAME with - args ARGLIST of types in ARGS - DEFUN_VOID(name) - define function NAME with no args - AND - argument separator for ARGS - NOARGS - null arglist - DOTS - `...' in args - - For example: - extern int EXFUN(printf, (CONST char *format DOTS)); - int DEFUN(fprintf, (stream, format), - FILE *stream AND CONST char *format DOTS) { ... } - void DEFUN_VOID(abort) { ... } -*/ - -#ifndef _ANSIDECL_H - -#define _ANSIDECL_H 1 - - -/* Every source file includes this file, - so they will all get the switch for lint. */ -/* LINTLIBRARY */ - - -#ifdef __STDC__ - -#define PTR void * -#define PTRCONST void *CONST -#define LONG_DOUBLE long double - -#define AND , -#define NOARGS void -#define CONST const -#define VOLATILE volatile -#define SIGNED signed -#define DOTS , ... - -#define EXFUN(name, proto) name proto -#define DEFUN(name, arglist, args) name(args) -#define DEFUN_VOID(name) name(NOARGS) - -#else /* Not ANSI C. */ - -#define PTR char * -#define PTRCONST PTR -#define LONG_DOUBLE double - -#define AND ; -#define NOARGS -#define CONST -#define VOLATILE -#define SIGNED -#define DOTS - -#define EXFUN(name, proto) name() -#define DEFUN(name, arglist, args) name arglist args; -#define DEFUN_VOID(name) name() - -#endif /* ANSI C. */ - - -#endif /* ansidecl.h */ diff --git a/gdb/arm-convert.s b/gdb/arm-convert.s deleted file mode 100644 index 416132b77c7..00000000000 --- a/gdb/arm-convert.s +++ /dev/null @@ -1,16 +0,0 @@ - .text - .global _convert_from_extended - -_convert_from_extended: - - ldfe f0,[a1] - stfd f0,[a2] - movs pc,lr - - .global _convert_to_extended - -_convert_to_extended: - - ldfd f0,[a1] - stfe f0,[a2] - movs pc,lr diff --git a/gdb/arm-opcode.h b/gdb/arm-opcode.h deleted file mode 100755 index d27a54e48a5..00000000000 --- a/gdb/arm-opcode.h +++ /dev/null @@ -1,294 +0,0 @@ -/* ARM opcode list. - Copyright (C) 1989, Free Software Foundation, Inc. - -This file is part of GDB and GAS. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* types of instruction (encoded in bits 26 and 27 of the instruction) */ - -#define TYPE_ARITHMETIC 0 -#define TYPE_LDR_STR 1 -#define TYPE_BLOCK_BRANCH 2 -#define TYPE_SWI 3 - -/* bit 25 decides whether an instruction is a block move or a branch */ -#define SUBTYPE_BLOCK 0 -#define SUBTYPE_BRANCH 1 - -/* codes to distinguish the arithmetic instructions */ - -#define OPCODE_AND 0 -#define OPCODE_EOR 1 -#define OPCODE_SUB 2 -#define OPCODE_RSB 3 -#define OPCODE_ADD 4 -#define OPCODE_ADC 5 -#define OPCODE_SBC 6 -#define OPCODE_RSC 7 -#define OPCODE_TST 8 -#define OPCODE_TEQ 9 -#define OPCODE_CMP 10 -#define OPCODE_CMN 11 -#define OPCODE_ORR 12 -#define OPCODE_MOV 13 -#define OPCODE_BIC 14 -#define OPCODE_MVN 15 - -/* condition codes */ - -#define COND_EQ 0 -#define COND_NE 1 -#define COND_CS 2 -#define COND_CC 3 -#define COND_MI 4 -#define COND_PL 5 -#define COND_VS 6 -#define COND_VC 7 -#define COND_HI 8 -#define COND_LS 9 -#define COND_GE 10 -#define COND_LT 11 -#define COND_GT 12 -#define COND_LE 13 -#define COND_AL 14 -#define COND_NV 15 - -/* Describes the format of an ARM machine instruction */ - -struct generic_fmt { - unsigned rest :25; /* the rest of the instruction */ - unsigned subtype :1; /* used to decide between block and branch */ - unsigned type :2; /* one of TYPE_* */ - unsigned cond :4; /* one of COND_* defined above */ -}; - -struct arith_fmt { - unsigned operand2 :12; /* #nn or rn or rn shift #m or rn shift rm */ - unsigned dest :4; /* place where the answer goes */ - unsigned operand1 :4; /* first operand to instruction */ - unsigned set :1; /* == 1 means set processor flags */ - unsigned opcode :4; /* one of OPCODE_* defined above */ - unsigned immed :1; /* operand2 is an immediate value */ - unsigned type :2; /* == TYPE_ARITHMETIC */ - unsigned cond :4; /* one of COND_* defined above */ -}; - -struct ldr_str_fmt { - unsigned offset :12; /* #nn or rn or rn shift #m */ - unsigned reg :4; /* destination for LDR, source for STR */ - unsigned base :4; /* base register */ - unsigned is_load :1; /* == 1 for LDR */ - unsigned writeback :1; /* == 1 means write back (base+offset) into base */ - unsigned byte :1; /* == 1 means byte access else word */ - unsigned up :1; /* == 1 means add offset else subtract it */ - unsigned pre_index :1; /* == 1 means [a,b] form else [a],b form */ - unsigned immed :1; /* == 0 means immediate offset */ - unsigned type :2; /* == TYPE_LDR_STR */ - unsigned cond :4; /* one of COND_* defined above */ -}; - -struct block_fmt { - unsigned mask :16; /* register mask */ - unsigned base :4; /* register used as base of move */ - unsigned is_load :1; /* == 1 for LDM */ - unsigned writeback :1; /* == 1 means update base after move */ - unsigned set :1; /* == 1 means set flags in pc if included in mask */ - unsigned increment :1; /* == 1 means increment base register */ - unsigned before :1; /* == 1 means inc/dec before each move */ - unsigned is_block :1; /* == SUBTYPE_BLOCK */ - unsigned type :2; /* == TYPE_BLOCK_BRANCH */ - unsigned cond :4; /* one of COND_* defined above */ -}; - -struct branch_fmt { - unsigned dest :24; /* destination of the branch */ - unsigned link :1; /* branch with link (function call) */ - unsigned is_branch :1; /* == SUBTYPE_BRANCH */ - unsigned type :2; /* == TYPE_BLOCK_BRANCH */ - unsigned cond :4; /* one of COND_* defined above */ -}; - -#define ROUND_N 0 -#define ROUND_P 1 -#define ROUND_M 2 -#define ROUND_Z 3 - -#define FLOAT2_MVF 0 -#define FLOAT2_MNF 1 -#define FLOAT2_ABS 2 -#define FLOAT2_RND 3 -#define FLOAT2_SQT 4 -#define FLOAT2_LOG 5 -#define FLOAT2_LGN 6 -#define FLOAT2_EXP 7 -#define FLOAT2_SIN 8 -#define FLOAT2_COS 9 -#define FLOAT2_TAN 10 -#define FLOAT2_ASN 11 -#define FLOAT2_ACS 12 -#define FLOAT2_ATN 13 - -#define FLOAT3_ADF 0 -#define FLOAT3_MUF 1 -#define FLOAT3_SUF 2 -#define FLOAT3_RSF 3 -#define FLOAT3_DVF 4 -#define FLOAT3_RDF 5 -#define FLOAT3_POW 6 -#define FLOAT3_RPW 7 -#define FLOAT3_RMF 8 -#define FLOAT3_FML 9 -#define FLOAT3_FDV 10 -#define FLOAT3_FRD 11 -#define FLOAT3_POL 12 - -struct float2_fmt { - unsigned operand2 :3; /* second operand */ - unsigned immed :1; /* == 1 if second operand is a constant */ - unsigned pad1 :1; /* == 0 */ - unsigned rounding :2; /* ROUND_* */ - unsigned is_double :1; /* == 1 if precision is double (only if not extended) */ - unsigned pad2 :4; /* == 1 */ - unsigned dest :3; /* destination */ - unsigned is_2_op :1; /* == 1 if 2 operand ins */ - unsigned operand1 :3; /* first operand (only of is_2_op == 0) */ - unsigned is_extended :1; /* == 1 if precision is extended */ - unsigned opcode :4; /* FLOAT2_* or FLOAT3_* depending on is_2_op */ - unsigned must_be_2 :2; /* == 2 */ - unsigned type :2; /* == TYPE_SWI */ - unsigned cond :4; /* COND_* */ -}; - -struct swi_fmt { - unsigned argument :24; /* argument to SWI (syscall number) */ - unsigned must_be_3 :2; /* == 3 */ - unsigned type :2; /* == TYPE_SWI */ - unsigned cond :4; /* one of COND_* defined above */ -}; - -union insn_fmt { - struct generic_fmt generic; - struct arith_fmt arith; - struct ldr_str_fmt ldr_str; - struct block_fmt block; - struct branch_fmt branch; - struct swi_fmt swi; - unsigned long ins; -}; - -struct opcode { - unsigned long value, mask; /* recognise instruction if (op&mask)==value */ - char *assembler; /* how to disassemble this instruction */ -}; - -/* format of the assembler string : - - %% % - %d print the bitfield in decimal - %x print the bitfield in hex - %r print as an ARM register - %f print a floating point constant if >7 else an fp register - %c print condition code (always bits 28-31) - %P print floating point precision in arithmetic insn - %Q print floating point precision in ldf/stf insn - %R print floating point rounding mode - %'c print specified char iff bit is one - %`c print specified char iff bit is zero - %?ab print a if bit is one else print b - %p print 'p' iff bits 12-15 are 15 - %o print operand2 (immediate or register + shift) - %a print address for ldr/str instruction - %b print branch destination - %A print address for ldc/stc/ldf/stf instruction - %m print register mask for ldm/stm instruction -*/ - -static struct opcode opcodes[] = { - /* ARM instructions */ - 0x00000090, 0x0fe000f0, "mul%20's %12-15r, %16-19r, %0-3r", - 0x00200090, 0x0fe000f0, "mla%20's %12-15r, %16-19r, %0-3r, %8-11r", - 0x00000000, 0x0de00000, "and%c%20's %12-15r, %16-19r, %o", - 0x00200000, 0x0de00000, "eor%c%20's %12-15r, %16-19r, %o", - 0x00400000, 0x0de00000, "sub%c%20's %12-15r, %16-19r, %o", - 0x00600000, 0x0de00000, "rsb%c%20's %12-15r, %16-19r, %o", - 0x00800000, 0x0de00000, "add%c%20's %12-15r, %16-19r, %o", - 0x00a00000, 0x0de00000, "adc%c%20's %12-15r, %16-19r, %o", - 0x00c00000, 0x0de00000, "sbc%c%20's %12-15r, %16-19r, %o", - 0x00e00000, 0x0de00000, "rsc%c%20's %12-15r, %16-19r, %o", - 0x01000000, 0x0de00000, "tst%c%p %16-19r, %o", - 0x01200000, 0x0de00000, "teq%c%p %16-19r, %o", - 0x01400000, 0x0de00000, "cmp%c%p %16-19r, %o", - 0x01600000, 0x0de00000, "cmn%c%p %16-19r, %o", - 0x01800000, 0x0de00000, "orr%c%20's %12-15r, %16-19r, %o", - 0x01a00000, 0x0de00000, "mov%c%20's %12-15r, %o", - 0x01c00000, 0x0de00000, "bic%c%20's %12-15r, %16-19r, %o", - 0x01e00000, 0x0de00000, "mvn%c%20's %12-15r, %o", - 0x04000000, 0x0c100000, "str%c%22'b %12-15r, %a", - 0x04100000, 0x0c100000, "ldr%c%22'b %12-15r, %a", - 0x08000000, 0x0e100000, "stm%c%23?id%24?ba %16-19r%22`!, %m", - 0x08100000, 0x0e100000, "ldm%c%23?id%24?ba %16-19r%22`!, %m%22'^", - 0x0a000000, 0x0e000000, "b%c%24'l %b", - 0x0f000000, 0x0f000000, "swi%c %0-23x", - /* Floating point coprocessor instructions */ - 0x0e000100, 0x0ff08f10, "adf%c%P%R %12-14f, %16-18f, %0-3f", - 0x0e100100, 0x0ff08f10, "muf%c%P%R %12-14f, %16-18f, %0-3f", - 0x0e200100, 0x0ff08f10, "suf%c%P%R %12-14f, %16-18f, %0-3f", - 0x0e300100, 0x0ff08f10, "rsf%c%P%R %12-14f, %16-18f, %0-3f", - 0x0e400100, 0x0ff08f10, "dvf%c%P%R %12-14f, %16-18f, %0-3f", - 0x0e500100, 0x0ff08f10, "rdf%c%P%R %12-14f, %16-18f, %0-3f", - 0x0e600100, 0x0ff08f10, "pow%c%P%R %12-14f, %16-18f, %0-3f", - 0x0e700100, 0x0ff08f10, "rpw%c%P%R %12-14f, %16-18f, %0-3f", - 0x0e800100, 0x0ff08f10, "rmf%c%P%R %12-14f, %16-18f, %0-3f", - 0x0e900100, 0x0ff08f10, "fml%c%P%R %12-14f, %16-18f, %0-3f", - 0x0ea00100, 0x0ff08f10, "fdv%c%P%R %12-14f, %16-18f, %0-3f", - 0x0eb00100, 0x0ff08f10, "frd%c%P%R %12-14f, %16-18f, %0-3f", - 0x0ec00100, 0x0ff08f10, "pol%c%P%R %12-14f, %16-18f, %0-3f", - 0x0e008100, 0x0ff08f10, "mvf%c%P%R %12-14f, %0-3f", - 0x0e108100, 0x0ff08f10, "mnf%c%P%R %12-14f, %0-3f", - 0x0e208100, 0x0ff08f10, "abs%c%P%R %12-14f, %0-3f", - 0x0e308100, 0x0ff08f10, "rnd%c%P%R %12-14f, %0-3f", - 0x0e408100, 0x0ff08f10, "sqt%c%P%R %12-14f, %0-3f", - 0x0e508100, 0x0ff08f10, "log%c%P%R %12-14f, %0-3f", - 0x0e608100, 0x0ff08f10, "lgn%c%P%R %12-14f, %0-3f", - 0x0e708100, 0x0ff08f10, "exp%c%P%R %12-14f, %0-3f", - 0x0e808100, 0x0ff08f10, "sin%c%P%R %12-14f, %0-3f", - 0x0e908100, 0x0ff08f10, "cos%c%P%R %12-14f, %0-3f", - 0x0ea08100, 0x0ff08f10, "tan%c%P%R %12-14f, %0-3f", - 0x0eb08100, 0x0ff08f10, "asn%c%P%R %12-14f, %0-3f", - 0x0ec08100, 0x0ff08f10, "acs%c%P%R %12-14f, %0-3f", - 0x0ed08100, 0x0ff08f10, "atn%c%P%R %12-14f, %0-3f", - 0x0e000110, 0x0ff00f1f, "flt%c%P%R %16-18f, %12-15r", - 0x0e100110, 0x0fff0f98, "fix%c%R %12-15r, %0-2f", - 0x0e200110, 0x0fff0fff, "wfs%c %12-15r", - 0x0e300110, 0x0fff0fff, "rfs%c %12-15r", - 0x0e400110, 0x0fff0fff, "wfc%c %12-15r", - 0x0e500110, 0x0fff0fff, "rfc%c %12-15r", - 0x0e90f110, 0x0ff8fff0, "cmf%c %16-18f, %0-3f", - 0x0eb0f110, 0x0ff8fff0, "cnf%c %16-18f, %0-3f", - 0x0ed0f110, 0x0ff8fff0, "cmfe%c %16-18f, %0-3f", - 0x0ef0f110, 0x0ff8fff0, "cnfe%c %16-18f, %0-3f", - 0x0c000100, 0x0e100f00, "stf%c%Q %12-14f, %A", - 0x0c100100, 0x0e100f00, "ldf%c%Q %12-14f, %A", - /* Generic coprocessor instructions */ - 0x0e000000, 0x0f000010, "cdp%c %8-11d, %20-23d, cr%12-15d, cr%16-19d, cr%0-3d, {%5-7d}", - 0x0e000010, 0x0f100010, "mrc%c %8-11d, %21-23d, %12-15r, cr%16-19d, cr%0-3d, {%5-7d}", - 0x0e100010, 0x0f100010, "mcr%c %8-11d, %21-23d, %12-15r, cr%16-19d, cr%0-3d, {%5-7d}", - 0x0c000000, 0x0e100000, "stc%c%22`l %8-11d, cr%12-15d, %A", - 0x0c100000, 0x0e100000, "ldc%c%22`l %8-11d, cr%12-15d, %A", - /* the rest */ - 0x00000000, 0x00000000, "undefined instruction %0-31x", -}; -#define N_OPCODES (sizeof opcodes / sizeof opcodes[0]) diff --git a/gdb/arm-pinsn.c b/gdb/arm-pinsn.c deleted file mode 100644 index 5da799716ff..00000000000 --- a/gdb/arm-pinsn.c +++ /dev/null @@ -1,271 +0,0 @@ -/* Print ARM instructions for GDB, the GNU debugger. - Copyright (C) 1986, 1989 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include -#include - -#include "defs.h" -#include "param.h" -#include "symtab.h" -#include "arm-opcode.h" - -extern char *reg_names[]; - -static char *shift_names[] = { - "lsl", "lsr", "asr", "ror", -}; - -static char *cond_names[] = { - "eq", "ne", "cs", "cc", "mi", "pl", "vs", "vc", - "hi", "ls", "ge", "lt", "gt", "le", "", "nv" -}; - -static char float_precision[] = "sdep"; -static char float_rounding[] = " pmz"; -static float float_immed[] = { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 0.5, 10.0 }; - -static void print_ldr_str_offset(); -static void print_ldc_stc_offset(); -static long immediate_value(); - -/* Print the ARM instruction at address MEMADDR in debugged memory, - on STREAM. Returns length of the instruction, in bytes. */ - -int -print_insn (memaddr, stream) - CORE_ADDR memaddr; - FILE *stream; -{ - unsigned long ins; - register struct opcode *op; - register char *p; - register int i, c; - int s, e, val; - - ins = read_memory_integer(memaddr, 4); - for (i = 0, op = opcodes; i < N_OPCODES; i++, op++) - if ((ins & op->mask) == op->value) break; - assert(i != N_OPCODES); - - for (p = op->assembler; *p;) { - c = *p++; - if (c == '%') { - s = e = 0; - while (isdigit(*p)) - s = s*10 + (*p++ - '0'); - if (*p == '-') { - p++; - while (isdigit(*p)) - e = e*10 + (*p++ - '0'); - } else - e = s; - assert(s >= 0 && s <= 31 && e >= 0 && e <= 31); - val = (ins >> s) & ((1 << (e + 1 - s)) - 1); - switch (*p++) { - case '%' : - putc('%', stream); - break; - case 'd' : - fprintf(stream, "%d", val); - break; - case 'x' : - fprintf(stream, "%x", val); - break; - case 'r' : - assert(val >= 0 && val <= 15); - fprintf(stream, "%s", reg_names[val]); - break; - case 'c' : - fprintf(stream, "%s", cond_names[ins >> 28]); - break; - case '\'' : - assert(*p); - c = *p++; - if (val) - putc(c, stream); - break; - case '`' : - assert(*p); - c = *p++; - if (!val) - putc(c, stream); - break; - case '?' : - assert(*p); - c = *p++; - assert(*p); - if (val) - p++; - else - c = *p++; - putc(c, stream); - break; - case 'p' : - if (((ins >> 12) & 0xf) == 0xf) - putc('p', stream); - break; - case 'o' : - if (ins & (1<<25)) { - int immed = immediate_value(ins & 0xfff); - fprintf (stream, "#%d (0x%x)", immed, immed); - } else { - int operand2 = ins & 0xfff; - /* in operand2 : - bits 0-3 are the base register - bits 5-6 are the shift (0=lsl, 1=lsr, 2=asr, 3=ror) - if bit 4 is zero then bits 7-11 are an immediate shift count - else bit 7 must be zero and bits 8-11 are the register - to be used as a shift count. - Note: no shift at all is encoded as "reg lsl #0" */ - fprintf (stream, "%s", reg_names[operand2 & 0xf]); - if (operand2 & 0xff0) { - /* ror #0 is really rrx (rotate right extend) */ - if ((operand2 & 0xff0) == 0x060) - fprintf (stream, ", rrx"); - else { - fprintf (stream, ", %s ", - shift_names[(operand2 >> 5) & 3]); - if (operand2 & (1<<4)) /* register shift */ - fprintf (stream, "%s", - reg_names[operand2 >> 8]); - else /* immediate shift */ - fprintf (stream, "#%d", - operand2 >> 7); - } - } - } - break; - case 'a' : - fprintf (stream, "[%s", reg_names[(ins >> 16) & 0xf]); - if (ins & (1<<24)) { - fprintf (stream, ", "); - print_ldr_str_offset (ins, stream); - putc (']', stream); - if (ins & (1<<21)) putc('!', stream); - /* If it is a pc relative load, then it is probably - a constant so print it */ - if (((ins >> 16) & 0xf) == 15 && - (ins & (1<<25)) == 0 && - (ins & (1<<20))) { - int addr = memaddr + 8 + - (ins & 0xfff) * ((ins & (1<<23)) ? 1 : -1); - fprintf (stream, " (contents="); - print_address (read_memory_integer(addr, 4), stream); - fprintf (stream, ")"); - } - } else { - fprintf (stream, "]," ); - print_ldr_str_offset (ins, stream); - } - break; - case 'b' : - print_address (memaddr + 8 + (((int)ins << 8) >> 6), stream); - break; - case 'A' : - fprintf (stream, "[%s", reg_names[(ins >> 16) & 0xf]); - if (ins & (1<<24)) { - fprintf (stream, ", "); - print_ldc_stc_offset (ins, stream); - putc(']', stream); - if (ins & (1<<21)) - putc('!', stream); - } else { - fprintf (stream, "], "); - print_ldc_stc_offset (ins, stream); - } - break; - case 'm' : - { - int regnum, first = 1; - putc('{', stream); - for (regnum = 0; regnum < 16; regnum++) - if (ins & (1<> 18) & 2) | ((ins >> 7) & 1); - putc(float_precision[val], stream); - break; - case 'Q' : - val = ((ins >> 21) & 2) | ((ins >> 15) & 1); - putc(float_precision[val], stream); - break; - case 'R' : - val = ((ins >> 5) & 3); - if (val) putc(float_rounding[val], stream); - break; - case 'f' : - assert(val >= 0 && val <= 15); - if (val > 7) - fprintf (stream, "#%3.1f", float_immed[val - 8]); - else - fprintf (stream, "f%d", val); - break; - default: - abort(); - } - } else - putc(c, stream); - } - return 4; -} - -static long -immediate_value(operand) -int operand; -{ - int val = operand & 0xff; - int shift = 2*(operand >> 8); - /* immediate value is (val ror shift) */ - return (val >> shift) | (val << (32 - shift)); -} - -static void -print_ldr_str_offset(ins, stream) -unsigned long ins; -FILE *stream; -{ - if ((ins & (1<<25)) == 0) - fprintf (stream, "#%d", - (ins & 0xfff) * ((ins & (1<<23)) ? 1 : -1)); - else { - fprintf (stream, "%s%s", reg_names[ins & 0xf], - (ins & (1<<23)) ? "" : "-"); - if (ins & 0xff0) - fprintf (stream, ", %s #%d", - shift_names[(ins >> 5) & 3], - (ins >> 7) & 0x1f); - } -} - -static void -print_ldc_stc_offset(ins, stream) -unsigned long ins; -FILE *stream; -{ - fprintf (stream, "#%d", - 4 * (ins & 0xff) * ((ins & (1<<23)) ? 1 : -1)); -} diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c deleted file mode 100644 index b4fe1b56937..00000000000 --- a/gdb/arm-tdep.c +++ /dev/null @@ -1,406 +0,0 @@ -/* Copyright (C) 1988, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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 1, or (at your option) -any later version. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include "defs.h" -#include "param.h" -#include "frame.h" -#include "inferior.h" -#include "arm-opcode.h" - -#include -#include -#include -#include -#include -#include -#include - -#define N_TXTADDR(hdr) 0x8000 -#define N_DATADDR(hdr) (hdr.a_text + 0x8000) - -#include "gdbcore.h" -#include /* After a.out.h */ -#include -#include - -#include - - -/* Work with core dump and executable files, for GDB. - This code would be in core.c if it weren't machine-dependent. */ - -/* Structure to describe the chain of shared libraries used - by the execfile. - e.g. prog shares Xt which shares X11 which shares c. */ - -struct shared_library { - struct exec_header header; - char name[SHLIBLEN]; - CORE_ADDR text_start; /* CORE_ADDR of 1st byte of text, this file */ - long data_offset; /* offset of data section in file */ - int chan; /* file descriptor for the file */ - struct shared_library *shares; /* library this one shares */ -}; -static struct shared_library *shlib = 0; - -/* Hook for `exec_file_command' command to call. */ - -extern void (*exec_file_display_hook) (); - -static CORE_ADDR unshared_text_start; - -/* extended header from exec file (for shared library info) */ - -static struct exec_header exec_header; - -void -exec_file_command (filename, from_tty) - char *filename; - int from_tty; -{ - int val; - - /* Eliminate all traces of old exec file. - Mark text segment as empty. */ - - if (execfile) - free (execfile); - execfile = 0; - data_start = 0; - data_end -= exec_data_start; - text_start = 0; - unshared_text_start = 0; - text_end = 0; - exec_data_start = 0; - exec_data_end = 0; - if (execchan >= 0) - close (execchan); - execchan = -1; - if (shlib) { - close_shared_library(shlib); - shlib = 0; - } - - /* Now open and digest the file the user requested, if any. */ - - if (filename) - { - filename = tilde_expand (filename); - make_cleanup (free, filename); - - execchan = openp (getenv ("PATH"), 1, filename, O_RDONLY, 0, - &execfile); - if (execchan < 0) - perror_with_name (filename); - - { - struct stat st_exec; - -#ifdef HEADER_SEEK_FD - HEADER_SEEK_FD (execchan); -#endif - - val = myread (execchan, &exec_header, sizeof exec_header); - exec_aouthdr = exec_header.a_exec; - - if (val < 0) - perror_with_name (filename); - - text_start = 0x8000; - - /* Look for shared library if needed */ - if (exec_header.a_exec.a_magic & MF_USES_SL) - shlib = open_shared_library(exec_header.a_shlibname, text_start); - - text_offset = N_TXTOFF (exec_aouthdr); - exec_data_offset = N_TXTOFF (exec_aouthdr) + exec_aouthdr.a_text; - - if (shlib) { - unshared_text_start = shared_text_end(shlib) & ~0x7fff; - stack_start = shlib->header.a_exec.a_sldatabase; - stack_end = STACK_END_ADDR; - } else - unshared_text_start = 0x8000; - text_end = unshared_text_start + exec_aouthdr.a_text; - - exec_data_start = unshared_text_start + exec_aouthdr.a_text; - exec_data_end = exec_data_start + exec_aouthdr.a_data; - - data_start = exec_data_start; - data_end += exec_data_start; - - fstat (execchan, &st_exec); - exec_mtime = st_exec.st_mtime; - } - - validate_files (); - } - else if (from_tty) - printf ("No exec file now.\n"); - - /* Tell display code (if any) about the changed file name. */ - if (exec_file_display_hook) - (*exec_file_display_hook) (filename); -} - -/* Read from the program's memory (except for inferior processes). - This function is misnamed, since it only reads, never writes; and - since it will use the core file and/or executable file as necessary. - - It should be extended to write as well as read, FIXME, for patching files. - - Return 0 if address could be read, EIO if addresss out of bounds. */ - -int -xfer_core_file (memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - register int i; - register int val; - int xferchan; - char **xferfile; - int fileptr; - int returnval = 0; - - while (len > 0) - { - xferfile = 0; - xferchan = 0; - - /* Determine which file the next bunch of addresses reside in, - and where in the file. Set the file's read/write pointer - to point at the proper place for the desired address - and set xferfile and xferchan for the correct file. - - If desired address is nonexistent, leave them zero. - - i is set to the number of bytes that can be handled - along with the next address. - - We put the most likely tests first for efficiency. */ - - /* Note that if there is no core file - data_start and data_end are equal. */ - if (memaddr >= data_start && memaddr < data_end) - { - i = min (len, data_end - memaddr); - fileptr = memaddr - data_start + data_offset; - xferfile = &corefile; - xferchan = corechan; - } - /* Note that if there is no core file - stack_start and stack_end define the shared library data. */ - else if (memaddr >= stack_start && memaddr < stack_end) - { - if (corechan < 0) { - struct shared_library *lib; - for (lib = shlib; lib; lib = lib->shares) - if (memaddr >= lib->header.a_exec.a_sldatabase && - memaddr < lib->header.a_exec.a_sldatabase + - lib->header.a_exec.a_data) - break; - if (lib) { - i = min (len, lib->header.a_exec.a_sldatabase + - lib->header.a_exec.a_data - memaddr); - fileptr = lib->data_offset + memaddr - - lib->header.a_exec.a_sldatabase; - xferfile = execfile; - xferchan = lib->chan; - } - } else { - i = min (len, stack_end - memaddr); - fileptr = memaddr - stack_start + stack_offset; - xferfile = &corefile; - xferchan = corechan; - } - } - else if (corechan < 0 - && memaddr >= exec_data_start && memaddr < exec_data_end) - { - i = min (len, exec_data_end - memaddr); - fileptr = memaddr - exec_data_start + exec_data_offset; - xferfile = &execfile; - xferchan = execchan; - } - else if (memaddr >= text_start && memaddr < text_end) - { - struct shared_library *lib; - for (lib = shlib; lib; lib = lib->shares) - if (memaddr >= lib->text_start && - memaddr < lib->text_start + lib->header.a_exec.a_text) - break; - if (lib) { - i = min (len, lib->header.a_exec.a_text + - lib->text_start - memaddr); - fileptr = memaddr - lib->text_start + text_offset; - xferfile = &execfile; - xferchan = lib->chan; - } else { - i = min (len, text_end - memaddr); - fileptr = memaddr - unshared_text_start + text_offset; - xferfile = &execfile; - xferchan = execchan; - } - } - else if (memaddr < text_start) - { - i = min (len, text_start - memaddr); - } - else if (memaddr >= text_end - && memaddr < (corechan >= 0? data_start : exec_data_start)) - { - i = min (len, data_start - memaddr); - } - else if (corechan >= 0 - && memaddr >= data_end && memaddr < stack_start) - { - i = min (len, stack_start - memaddr); - } - else if (corechan < 0 && memaddr >= exec_data_end) - { - i = min (len, - memaddr); - } - else if (memaddr >= stack_end && stack_end != 0) - { - i = min (len, - memaddr); - } - else - { - /* Address did not classify into one of the known ranges. - This shouldn't happen; we catch the endpoints. */ - fatal ("Internal: Bad case logic in xfer_core_file."); - } - - /* Now we know which file to use. - Set up its pointer and transfer the data. */ - if (xferfile) - { - if (*xferfile == 0) - if (xferfile == &execfile) - error ("No program file to examine."); - else - error ("No core dump file or running program to examine."); - val = lseek (xferchan, fileptr, 0); - if (val < 0) - perror_with_name (*xferfile); - val = myread (xferchan, myaddr, i); - if (val < 0) - perror_with_name (*xferfile); - } - /* If this address is for nonexistent memory, - read zeros if reading, or do nothing if writing. - Actually, we never right. */ - else - { - bzero (myaddr, i); - returnval = EIO; - } - - memaddr += i; - myaddr += i; - len -= i; - } - return returnval; -} - -/* APCS (ARM procedure call standard) defines the following prologue: - - mov ip, sp - [stmfd sp!, {a1,a2,a3,a4}] - stmfd sp!, {...,fp,ip,lr,pc} - [stfe f7, [sp, #-12]!] - [stfe f6, [sp, #-12]!] - [stfe f5, [sp, #-12]!] - [stfe f4, [sp, #-12]!] - sub fp, ip, #nn // nn == 20 or 4 depending on second ins -*/ - -CORE_ADDR -skip_prologue(pc) -CORE_ADDR pc; -{ - union insn_fmt op; - CORE_ADDR skip_pc = pc; - - op.ins = read_memory_integer(skip_pc, 4); - /* look for the "mov ip,sp" */ - if (op.generic.type != TYPE_ARITHMETIC || - op.arith.opcode != OPCODE_MOV || - op.arith.dest != SPTEMP || - op.arith.operand2 != SP) return pc; - skip_pc += 4; - /* skip the "stmfd sp!,{a1,a2,a3,a4}" if its there */ - op.ins = read_memory_integer(skip_pc, 4); - if (op.generic.type == TYPE_BLOCK_BRANCH && - op.generic.subtype == SUBTYPE_BLOCK && - op.block.mask == 0xf && - op.block.base == SP && - op.block.is_load == 0 && - op.block.writeback == 1 && - op.block.increment == 0 && - op.block.before == 1) skip_pc += 4; - /* skip the "stmfd sp!,{...,fp,ip,lr,pc} */ - op.ins = read_memory_integer(skip_pc, 4); - if (op.generic.type != TYPE_BLOCK_BRANCH || - op.generic.subtype != SUBTYPE_BLOCK || - /* the mask should look like 110110xxxxxx0000 */ - (op.block.mask & 0xd800) != 0xd800 || - op.block.base != SP || - op.block.is_load != 0 || - op.block.writeback != 1 || - op.block.increment != 0 || - op.block.before != 1) return pc; - skip_pc += 4; - /* check for "sub fp,ip,#nn" */ - op.ins = read_memory_integer(skip_pc, 4); - if (op.generic.type != TYPE_ARITHMETIC || - op.arith.opcode != OPCODE_SUB || - op.arith.dest != FP || - op.arith.operand1 != SPTEMP) return pc; - return skip_pc + 4; -} - -static void -print_fpu_flags(flags) -int flags; -{ - if (flags & (1 << 0)) fputs("IVO ", stdout); - if (flags & (1 << 1)) fputs("DVZ ", stdout); - if (flags & (1 << 2)) fputs("OFL ", stdout); - if (flags & (1 << 3)) fputs("UFL ", stdout); - if (flags & (1 << 4)) fputs("INX ", stdout); - putchar('\n'); -} - -void -arm_float_info() -{ - register unsigned long status = read_register(FPS_REGNUM); - int type; - - type = (status >> 24) & 127; - printf("%s FPU type %d\n", - (status & (1<<31)) ? "Hardware" : "Software", - type); - fputs("mask: ", stdout); - print_fpu_flags(status >> 16); - fputs("flags: ", stdout); - print_fpu_flags(status); -} diff --git a/gdb/arm-xdep.c b/gdb/arm-xdep.c deleted file mode 100644 index e03e16d3bf1..00000000000 --- a/gdb/arm-xdep.c +++ /dev/null @@ -1,274 +0,0 @@ -/* Acorn Risc Machine host machine support. - Copyright (C) 1988, 1989, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include "defs.h" -#include "param.h" -#include "frame.h" -#include "inferior.h" -#include "arm-opcode.h" - -#include -#include -#include -#include -#include -#include -#include - -#define N_TXTADDR(hdr) 0x8000 -#define N_DATADDR(hdr) (hdr.a_text + 0x8000) - -#include "gdbcore.h" - -#include /* After a.out.h */ -#include -#include - -#include - -void -fetch_inferior_registers (regno) - int regno; -{ - register int regno; - register unsigned int regaddr; - char buf[MAX_REGISTER_RAW_SIZE]; - register int i; - - struct user u; - unsigned int offset = (char *) &u.u_ar0 - (char *) &u; - offset = ptrace (PT_READ_U, inferior_pid, offset, 0) - KERNEL_U_ADDR; - - registers_fetched (); - - for (regno = 0; regno < 16; regno++) - { - regaddr = offset + regno * 4; - *(int *)&buf[0] = ptrace (PT_READ_U, inferior_pid, regaddr, 0); - if (regno == PC_REGNUM) - *(int *)&buf[0] = GET_PC_PART(*(int *)&buf[0]); - supply_register (regno, buf); - } - *(int *)&buf[0] = ptrace (PT_READ_U, inferior_pid, offset + PC*4); - supply_register (PS_REGNUM, buf); /* set virtual register ps same as pc */ - - /* read the floating point registers */ - offset = (char *) &u.u_fp_regs - (char *)&u; - *(int *)buf = ptrace (PT_READ_U, inferior_pid, offset, 0); - supply_register (FPS_REGNUM, buf); - for (regno = 16; regno < 24; regno++) { - regaddr = offset + 4 + 12 * (regno - 16); - for (i = 0; i < 12; i += sizeof(int)) - *(int *) &buf[i] = ptrace (PT_READ_U, inferior_pid, regaddr + i, 0); - supply_register (regno, buf); - } -} - -/* Store our register values back into the inferior. - If REGNO is -1, do this for all registers. - Otherwise, REGNO specifies which register (so we can save time). */ - -store_inferior_registers (regno) - int regno; -{ - register unsigned int regaddr; - char buf[80]; - - struct user u; - unsigned long value; - unsigned int offset = (char *) &u.u_ar0 - (char *) &u; - offset = ptrace (PT_READ_U, inferior_pid, offset, 0) - KERNEL_U_ADDR; - - if (regno >= 0) { - if (regno >= 16) return; - regaddr = offset + 4 * regno; - errno = 0; - value = read_register(regno); - if (regno == PC_REGNUM) - value = SET_PC_PART(read_register (PS_REGNUM), value); - ptrace (PT_WRITE_U, inferior_pid, regaddr, value); - if (errno != 0) - { - sprintf (buf, "writing register number %d", regno); - perror_with_name (buf); - } - } - else for (regno = 0; regno < 15; regno++) - { - regaddr = offset + regno * 4; - errno = 0; - value = read_register(regno); - if (regno == PC_REGNUM) - value = SET_PC_PART(read_register (PS_REGNUM), value); - ptrace (6, inferior_pid, regaddr, value); - if (errno != 0) - { - sprintf (buf, "writing all regs, number %d", regno); - perror_with_name (buf); - } - } -} - -/* Work with core dump and executable files, for GDB. - This code would be in core.c if it weren't machine-dependent. */ - -/* Structure to describe the chain of shared libraries used - by the execfile. - e.g. prog shares Xt which shares X11 which shares c. */ - -struct shared_library { - struct exec_header header; - char name[SHLIBLEN]; - CORE_ADDR text_start; /* CORE_ADDR of 1st byte of text, this file */ - long data_offset; /* offset of data section in file */ - int chan; /* file descriptor for the file */ - struct shared_library *shares; /* library this one shares */ -}; -static struct shared_library *shlib = 0; - -/* Hook for `exec_file_command' command to call. */ - -extern void (*exec_file_display_hook) (); - -static CORE_ADDR unshared_text_start; - -/* extended header from exec file (for shared library info) */ - -static struct exec_header exec_header; - -void -core_file_command (filename, from_tty) - char *filename; - int from_tty; -{ - int val; - extern char registers[]; - - /* Discard all vestiges of any previous core file - and mark data and stack spaces as empty. */ - - if (corefile) - free (corefile); - corefile = 0; - - if (corechan >= 0) - close (corechan); - corechan = -1; - - data_start = 0; - data_end = 0; - stack_start = STACK_END_ADDR; - stack_end = STACK_END_ADDR; - - /* Now, if a new core file was specified, open it and digest it. */ - - if (filename) - { - filename = tilde_expand (filename); - make_cleanup (free, filename); - - if (have_inferior_p ()) - error ("To look at a core file, you must kill the inferior with \"kill\"."); - corechan = open (filename, O_RDONLY, 0); - if (corechan < 0) - perror_with_name (filename); - /* 4.2-style (and perhaps also sysV-style) core dump file. */ - { - struct user u; - - unsigned int reg_offset, fp_reg_offset; - - val = myread (corechan, &u, sizeof u); - if (val < 0) - perror_with_name ("Not a core file: reading upage"); - if (val != sizeof u) - error ("Not a core file: could only read %d bytes", val); - - /* We are depending on exec_file_command having been called - previously to set exec_data_start. Since the executable - and the core file share the same text segment, the address - of the data segment will be the same in both. */ - data_start = exec_data_start; - - data_end = data_start + NBPG * u.u_dsize; - stack_start = stack_end - NBPG * u.u_ssize; - data_offset = NBPG * UPAGES; - stack_offset = NBPG * (UPAGES + u.u_dsize); - - /* Some machines put an absolute address in here and some put - the offset in the upage of the regs. */ - reg_offset = (int) u.u_ar0; - if (reg_offset > NBPG * UPAGES) - reg_offset -= KERNEL_U_ADDR; - fp_reg_offset = (char *) &u.u_fp_regs - (char *)&u; - - /* I don't know where to find this info. - So, for now, mark it as not available. */ - N_SET_MAGIC (core_aouthdr, 0); - - /* Read the register values out of the core file and store - them where `read_register' will find them. */ - - { - register int regno; - - for (regno = 0; regno < NUM_REGS; regno++) - { - char buf[MAX_REGISTER_RAW_SIZE]; - - if (regno < 16) - val = lseek (corechan, reg_offset + 4 * regno, 0); - else if (regno < 24) - val = lseek (corechan, fp_reg_offset + 4 + 12*(regno - 24), 0); - else if (regno == 24) - val = lseek (corechan, fp_reg_offset, 0); - else if (regno == 25) - val = lseek (corechan, reg_offset + 4 * PC, 0); - if (val < 0 - || (val = myread (corechan, buf, sizeof buf)) < 0) - { - char * buffer = (char *) alloca (strlen (reg_names[regno]) - + 30); - strcpy (buffer, "Reading register "); - strcat (buffer, reg_names[regno]); - - perror_with_name (buffer); - } - - if (regno == PC_REGNUM) - *(int *)buf = GET_PC_PART(*(int *)buf); - supply_register (regno, buf); - } - } - } - if (filename[0] == '/') - corefile = savestring (filename, strlen (filename)); - else - { - corefile = concat (current_directory, "/", filename, NULL); - } - - set_current_frame ( create_new_frame (read_register (FP_REGNUM), - read_pc ())); - select_frame (get_current_frame (), 0); - validate_files (); - } - else if (from_tty) - printf ("No core file now.\n"); -} diff --git a/gdb/blockframe.c b/gdb/blockframe.c deleted file mode 100644 index ee42d7c835c..00000000000 --- a/gdb/blockframe.c +++ /dev/null @@ -1,745 +0,0 @@ -/* Get info from stack frames; - convert between frames, blocks, functions and pc values. - Copyright (C) 1986, 1987, 1988, 1989 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "defs.h" -#include "param.h" -#include "symtab.h" -#include "frame.h" -#include "gdbcore.h" -#include "value.h" /* for read_register */ -#include "target.h" /* for target_has_stack */ - -CORE_ADDR read_pc (); /* In infcmd.c */ - -/* Start and end of object file containing the entry point. - STARTUP_FILE_END is the first address of the next file. - This file is assumed to be a startup file - and frames with pc's inside it - are treated as nonexistent. - - Setting these variables is necessary so that backtraces do not fly off - the bottom of the stack. */ -CORE_ADDR startup_file_start; -CORE_ADDR startup_file_end; - -/* Is ADDR outside the startup file? Note that if your machine - has a way to detect the bottom of the stack, there is no need - to call this function from FRAME_CHAIN_VALID; the reason for - doing so is that some machines have no way of detecting bottom - of stack. */ -int -outside_startup_file (addr) - CORE_ADDR addr; -{ - return !(addr >= startup_file_start && addr < startup_file_end); -} - -/* Support an alternate method to avoid running off the bottom of - the stack (or top, depending upon your stack orientation). - - There are two frames that are "special", the frame for the function - containing the process entry point, since it has no predecessor frame, - and the frame for the function containing the user code entry point - (the main() function), since all the predecessor frames are for the - process startup code. Since we have no guarantee that the linked - in startup modules have any debugging information that gdb can use, - we need to avoid following frame pointers back into frames that might - have been built in the startup code, as we might get hopelessly - confused. However, we almost always have debugging information - available for main(). - - These variables are used to save the range of PC values which are valid - within the main() function and within the function containing the process - entry point. If we always consider the frame for main() as the outermost - frame when debugging user code, and the frame for the process entry - point function as the outermost frame when debugging startup code, then - all we have to do is have FRAME_CHAIN_VALID return false whenever a - frame's current PC is within the range specified by these variables. - In essence, we set "blocks" in the frame chain beyond which we will - not proceed when following the frame chain. - - A nice side effect is that we can still debug startup code without - running off the end of the frame chain, assuming that we have usable - debugging information in the startup modules, and if we choose to not - use the block at main, or can't find it for some reason, everything - still works as before. And if we have no startup code debugging - information but we do have usable information for main(), backtraces - from user code don't go wandering off into the startup code. - - To use this method, define your FRAME_CHAIN_VALID macro like: - - #define FRAME_CHAIN_VALID(chain, thisframe) \ - (chain != 0 \ - && !(inside_main_scope ((thisframe)->pc)) \ - && !(inside_entry_scope ((thisframe)->pc))) - - and add initializations of the four scope controlling variables inside - the object file / debugging information processing modules. */ - -CORE_ADDR entry_scope_lowpc; -CORE_ADDR entry_scope_highpc; -CORE_ADDR main_scope_lowpc; -CORE_ADDR main_scope_highpc; - -/* Test a specified PC value to see if it is in the range of addresses - that correspond to the main() function. See comments above for why - we might want to do this. - - Typically called from FRAME_CHAIN_VALID. */ - -int -inside_main_scope (pc) -CORE_ADDR pc; -{ - return (main_scope_lowpc <= pc && pc < main_scope_highpc); -} - -/* Test a specified PC value to see if it is in the range of addresses - that correspond to the process entry point function. See comments above - for why we might want to do this. - - Typically called from FRAME_CHAIN_VALID. */ - -int -inside_entry_scope (pc) -CORE_ADDR pc; -{ - return (entry_scope_lowpc <= pc && pc < entry_scope_highpc); -} - -/* Address of innermost stack frame (contents of FP register) */ - -static FRAME current_frame; - -/* - * Cache for frame addresses already read by gdb. Valid only while - * inferior is stopped. Control variables for the frame cache should - * be local to this module. - */ -struct obstack frame_cache_obstack; - -/* Return the innermost (currently executing) stack frame. */ - -FRAME -get_current_frame () -{ - /* We assume its address is kept in a general register; - param.h says which register. */ - - return current_frame; -} - -void -set_current_frame (frame) - FRAME frame; -{ - current_frame = frame; -} - -FRAME -create_new_frame (addr, pc) - FRAME_ADDR addr; - CORE_ADDR pc; -{ - struct frame_info *fci; /* Same type as FRAME */ - - fci = (struct frame_info *) - obstack_alloc (&frame_cache_obstack, - sizeof (struct frame_info)); - - /* Arbitrary frame */ - fci->next = (struct frame_info *) 0; - fci->prev = (struct frame_info *) 0; - fci->frame = addr; - fci->next_frame = 0; /* Since arbitrary */ - fci->pc = pc; - -#ifdef INIT_EXTRA_FRAME_INFO - INIT_EXTRA_FRAME_INFO (0, fci); -#endif - - return fci; -} - -/* Return the frame that called FRAME. - If FRAME is the original frame (it has no caller), return 0. */ - -FRAME -get_prev_frame (frame) - FRAME frame; -{ - /* We're allowed to know that FRAME and "struct frame_info *" are - the same */ - return get_prev_frame_info (frame); -} - -/* Return the frame that FRAME calls (0 if FRAME is the innermost - frame). */ - -FRAME -get_next_frame (frame) - FRAME frame; -{ - /* We're allowed to know that FRAME and "struct frame_info *" are - the same */ - return frame->next; -} - -/* - * Flush the entire frame cache. - */ -void -flush_cached_frames () -{ - /* Since we can't really be sure what the first object allocated was */ - obstack_free (&frame_cache_obstack, 0); - obstack_init (&frame_cache_obstack); - - current_frame = (struct frame_info *) 0; /* Invalidate cache */ -} - -/* Flush the frame cache, and start a new one if necessary. */ -void -reinit_frame_cache () -{ - FRAME fr = current_frame; - flush_cached_frames (); - if (fr) - set_current_frame ( create_new_frame (read_register (FP_REGNUM), - read_pc ())); -} - -/* Return a structure containing various interesting information - about a specified stack frame. */ -/* How do I justify including this function? Well, the FRAME - identifier format has gone through several changes recently, and - it's not completely inconceivable that it could happen again. If - it does, have this routine around will help */ - -struct frame_info * -get_frame_info (frame) - FRAME frame; -{ - return frame; -} - -/* If a machine allows frameless functions, it should define a macro - FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) in param.h. FI is the struct - frame_info for the frame, and FRAMELESS should be set to nonzero - if it represents a frameless function invocation. */ - -/* Return nonzero if the function for this frame has a prologue. Many - machines can define FRAMELESS_FUNCTION_INVOCATION to just call this - function. */ - -int -frameless_look_for_prologue (frame) - FRAME frame; -{ - CORE_ADDR func_start, after_prologue; - func_start = (get_pc_function_start (frame->pc) + - FUNCTION_START_OFFSET); - if (func_start) - { - after_prologue = func_start; -#ifdef SKIP_PROLOGUE_FRAMELESS_P - /* This is faster, since only care whether there *is* a prologue, - not how long it is. */ - SKIP_PROLOGUE_FRAMELESS_P (after_prologue); -#else - SKIP_PROLOGUE (after_prologue); -#endif - return after_prologue == func_start; - } - else - /* If we can't find the start of the function, we don't really - know whether the function is frameless, but we should be able - to get a reasonable (i.e. best we can do under the - circumstances) backtrace by saying that it isn't. */ - return 0; -} - -/* Default a few macros that people seldom redefine. */ - -#if !defined (INIT_FRAME_PC) -#define INIT_FRAME_PC(fromleaf, prev) \ - prev->pc = (fromleaf ? SAVED_PC_AFTER_CALL (prev->next) : \ - prev->next ? FRAME_SAVED_PC (prev->next) : read_pc ()); -#endif - -#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. */ - -struct frame_info * -get_prev_frame_info (next_frame) - FRAME next_frame; -{ - FRAME_ADDR address; - struct frame_info *prev; - int fromleaf = 0; - - /* If the requested entry is in the cache, return it. - Otherwise, figure out what the address should be for the entry - we're about to add to the cache. */ - - if (!next_frame) - { - if (!current_frame) - { - error ("You haven't set up a process's stack to examine."); - } - - return current_frame; - } - - /* If we have the prev one, return it */ - if (next_frame->prev) - return next_frame->prev; - - /* On some machines it is possible to call a function without - setting up a stack frame for it. On these machines, we - define this macro to take two args; a frameinfo pointer - identifying a frame and a variable to set or clear if it is - or isn't leafless. */ -#ifdef FRAMELESS_FUNCTION_INVOCATION - /* Still don't want to worry about this except on the innermost - frame. This macro will set FROMLEAF if NEXT_FRAME is a - frameless function invocation. */ - if (!(next_frame->next)) - { - FRAMELESS_FUNCTION_INVOCATION (next_frame, fromleaf); - if (fromleaf) - address = next_frame->frame; - } -#endif - - if (!fromleaf) - { - /* Two macros defined in tm.h specify the machine-dependent - actions to be performed here. - First, get the frame's chain-pointer. - If that is zero, the frame is the outermost frame or a leaf - called by the outermost frame. This means that if start - calls main without a frame, we'll return 0 (which is fine - anyway). - - Nope; there's a problem. This also returns when the current - routine is a leaf of main. This is unacceptable. We move - this to after the ffi test; I'd rather have backtraces from - start go curfluy than have an abort called from main not show - main. */ - 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; - - prev = (struct frame_info *) - obstack_alloc (&frame_cache_obstack, - sizeof (struct frame_info)); - - if (next_frame) - next_frame->prev = prev; - prev->next = next_frame; - prev->prev = (struct frame_info *) 0; - prev->frame = address; - prev->next_frame = prev->next ? prev->next->frame : 0; - -#ifdef INIT_EXTRA_FRAME_INFO - INIT_EXTRA_FRAME_INFO(fromleaf, prev); -#endif - - /* This entry is in the frame queue now, which is good since - FRAME_SAVED_PC may use that queue to figure out it's value - (see tm-sparc.h). We want the pc saved in the inferior frame. */ - INIT_FRAME_PC(fromleaf, prev); - - return prev; -} - -CORE_ADDR -get_frame_pc (frame) - FRAME frame; -{ - struct frame_info *fi; - fi = get_frame_info (frame); - return fi->pc; -} - -#if defined (FRAME_FIND_SAVED_REGS) -/* Find the addresses in which registers are saved in FRAME. */ - -void -get_frame_saved_regs (frame_info_addr, saved_regs_addr) - struct frame_info *frame_info_addr; - struct frame_saved_regs *saved_regs_addr; -{ - FRAME_FIND_SAVED_REGS (frame_info_addr, *saved_regs_addr); -} -#endif - -/* Return the innermost lexical block in execution - in a specified stack frame. The frame address is assumed valid. */ - -struct block * -get_frame_block (frame) - FRAME frame; -{ - struct frame_info *fi; - CORE_ADDR pc; - - fi = get_frame_info (frame); - - pc = fi->pc; - if (fi->next_frame != 0) - /* We are not in the innermost frame. We need to subtract one to - get the correct block, in case the call instruction was the - last instruction of the block. If there are any machines on - which the saved pc does not point to after the call insn, we - probably want to make fi->pc point after the call insn anyway. */ - --pc; - return block_for_pc (pc); -} - -struct block * -get_current_block () -{ - return block_for_pc (read_pc ()); -} - -CORE_ADDR -get_pc_function_start (pc) - CORE_ADDR pc; -{ - register struct block *bl = block_for_pc (pc); - register struct symbol *symbol; - if (bl == 0 || (symbol = block_function (bl)) == 0) - { - register int misc_index = find_pc_misc_function (pc); - if (misc_index >= 0) - return misc_function_vector[misc_index].address; - return 0; - } - bl = SYMBOL_BLOCK_VALUE (symbol); - return BLOCK_START (bl); -} - -/* Return the symbol for the function executing in frame FRAME. */ - -struct symbol * -get_frame_function (frame) - FRAME frame; -{ - register struct block *bl = get_frame_block (frame); - if (bl == 0) - return 0; - return block_function (bl); -} - -/* Return the blockvector immediately containing the innermost lexical block - containing the specified pc value, or 0 if there is none. - PINDEX is a pointer to the index value of the block. If PINDEX - is NULL, we don't pass this information back to the caller. */ - -struct blockvector * -blockvector_for_pc (pc, pindex) - register CORE_ADDR pc; - int *pindex; -{ - register struct block *b; - register int bot, top, half; - register struct symtab *s; - struct blockvector *bl; - - /* First search all symtabs for one whose file contains our pc */ - s = find_pc_symtab (pc); - if (s == 0) - return 0; - - bl = BLOCKVECTOR (s); - b = BLOCKVECTOR_BLOCK (bl, 0); - - /* Then search that symtab for the smallest block that wins. */ - /* Use binary search to find the last block that starts before PC. */ - - bot = 0; - top = BLOCKVECTOR_NBLOCKS (bl); - - while (top - bot > 1) - { - half = (top - bot + 1) >> 1; - b = BLOCKVECTOR_BLOCK (bl, bot + half); - if (BLOCK_START (b) <= pc) - bot += half; - else - top = bot + half; - } - - /* Now search backward for a block that ends after PC. */ - - while (bot >= 0) - { - b = BLOCKVECTOR_BLOCK (bl, bot); - if (BLOCK_END (b) > pc) - { - if (pindex) - *pindex = bot; - return bl; - } - bot--; - } - - return 0; -} - -/* Return the innermost lexical block containing the specified pc value, - or 0 if there is none. */ - -struct block * -block_for_pc (pc) - register CORE_ADDR pc; -{ - register struct blockvector *bl; - int index; - - bl = blockvector_for_pc (pc, &index); - if (bl) - return BLOCKVECTOR_BLOCK (bl, index); - return 0; -} - -/* Return the function containing pc value PC. - Returns 0 if function is not known. */ - -struct symbol * -find_pc_function (pc) - CORE_ADDR pc; -{ - register struct block *b = block_for_pc (pc); - if (b == 0) - return 0; - return block_function (b); -} - -/* These variables are used to cache the most recent result - * of find_pc_partial_function. */ - -static CORE_ADDR cache_pc_function_low = 0; -static CORE_ADDR cache_pc_function_high = 0; -static char *cache_pc_function_name = 0; - -/* Clear cache, e.g. when symbol table is discarded. */ - -void -clear_pc_function_cache() -{ - cache_pc_function_low = 0; - cache_pc_function_high = 0; - cache_pc_function_name = (char *)0; -} - -/* Finds the "function" (text symbol) that is smaller than PC - but greatest of all of the potential text symbols. Sets - *NAME and/or *ADDRESS conditionally if that pointer is non-zero. - Returns 0 if it couldn't find anything, 1 if it did. On a zero - return, *NAME and *ADDRESS are always set to zero. On a 1 return, - *NAME and *ADDRESS contain real information. */ - -int -find_pc_partial_function (pc, name, address) - CORE_ADDR pc; - char **name; - CORE_ADDR *address; -{ - struct partial_symtab *pst; - struct symbol *f; - int miscfunc; - struct partial_symbol *psb; - - if (pc >= cache_pc_function_low && pc < cache_pc_function_high) - { - if (address) - *address = cache_pc_function_low; - if (name) - *name = cache_pc_function_name; - return 1; - } - - pst = find_pc_psymtab (pc); - if (pst) - { - if (pst->readin) - { - /* The information we want has already been read in. - We can go to the already readin symbols and we'll get - the best possible answer. */ - f = find_pc_function (pc); - if (!f) - { - return_error: - /* No available symbol. */ - if (name != 0) - *name = 0; - if (address != 0) - *address = 0; - return 0; - } - - cache_pc_function_low = BLOCK_START (SYMBOL_BLOCK_VALUE (f)); - cache_pc_function_high = BLOCK_END (SYMBOL_BLOCK_VALUE (f)); - cache_pc_function_name = SYMBOL_NAME (f); - if (name) - *name = cache_pc_function_name; - if (address) - *address = cache_pc_function_low; - return 1; - } - - /* Get the information from a combination of the pst - (static symbols), and the misc function vector (extern - symbols). */ - miscfunc = find_pc_misc_function (pc); - psb = find_pc_psymbol (pst, pc); - - if (!psb && miscfunc == -1) - { - goto return_error; - } - if (psb - && (miscfunc == -1 - || (SYMBOL_VALUE_ADDRESS (psb) - >= misc_function_vector[miscfunc].address))) - { - /* This case isn't being cached currently. */ - if (address) - *address = SYMBOL_VALUE_ADDRESS (psb); - if (name) - *name = SYMBOL_NAME (psb); - return 1; - } - } - else - /* Must be in the misc function stuff. */ - { - miscfunc = find_pc_misc_function (pc); - if (miscfunc == -1) - goto return_error; - } - - { - if (misc_function_vector[miscfunc].type == mf_text) - cache_pc_function_low = misc_function_vector[miscfunc].address; - else - /* It is a transfer table for Sun shared libraries. */ - cache_pc_function_low = pc - FUNCTION_START_OFFSET; - } - cache_pc_function_name = misc_function_vector[miscfunc].name; - if (miscfunc < misc_function_count /* && FIXME mf_text again? */ ) - cache_pc_function_high = misc_function_vector[miscfunc+1].address; - else - cache_pc_function_high = cache_pc_function_low + 1; - if (address) - *address = cache_pc_function_low; - if (name) - *name = cache_pc_function_name; - return 1; -} - -/* Find the misc function whose address is the largest - while being less than PC. Return its index in misc_function_vector. - Returns -1 if PC is not in suitable range. */ - -int -find_pc_misc_function (pc) - register CORE_ADDR pc; -{ - register int lo = 0; - register int hi = misc_function_count-1; - register int new; - - /* Note that the last thing in the vector is always _etext. */ - /* Actually, "end", now that non-functions - go on the misc_function_vector. */ - - /* Above statement is not *always* true - fix for case where there are */ - /* no misc functions at all (ie no symbol table has been read). */ - if (hi < 0) return -1; /* no misc functions recorded */ - - /* trivial reject range test */ - if (pc < misc_function_vector[0].address || - pc > misc_function_vector[hi].address) - return -1; - - /* Note that the following search will not return hi if - pc == misc_function_vector[hi].address. If "end" points to the - first unused location, this is correct and the above test - simply needs to be changed to - "pc >= misc_function_vector[hi].address". */ - do { - new = (lo + hi) >> 1; - if (misc_function_vector[new].address == pc) - return new; /* an exact match */ - else if (misc_function_vector[new].address > pc) - hi = new; - else - lo = new; - } while (hi-lo != 1); - - /* if here, we had no exact match, so return the lower choice */ - return lo; -} - -/* Return the innermost stack frame executing inside of the specified block, - or zero if there is no such frame. */ - -FRAME -block_innermost_frame (block) - struct block *block; -{ - struct frame_info *fi; - register FRAME frame; - register CORE_ADDR start = BLOCK_START (block); - register CORE_ADDR end = BLOCK_END (block); - - frame = 0; - while (1) - { - frame = get_prev_frame (frame); - if (frame == 0) - return 0; - fi = get_frame_info (frame); - if (fi->pc >= start && fi->pc < end) - return frame; - } -} - -void -_initialize_blockframe () -{ - obstack_init (&frame_cache_obstack); -} diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c deleted file mode 100644 index f6b136fc9a5..00000000000 --- a/gdb/breakpoint.c +++ /dev/null @@ -1,2448 +0,0 @@ -/* Everything about breakpoints, for GDB. - Copyright (C) 1986, 1987, 1989, 1990 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include -#include "defs.h" -#include "param.h" -#include "symtab.h" -#include "frame.h" -#include "breakpoint.h" -#include "expression.h" -#include "gdbcore.h" -#include "gdbcmd.h" -#include "value.h" -#include "ctype.h" -#include "command.h" -#include "inferior.h" -#include "target.h" -#include "language.h" -#include - -extern int addressprint; /* Print machine addresses? */ -extern int demangle; /* Print de-mangled symbol names? */ - -extern int catch_errors (); -extern void set_next_address (); /* ...for x/ command */ - -/* Are we executing breakpoint commands? */ -static int executing_breakpoint_commands; - -/* States of enablement of breakpoint. - `temporary' means disable when hit. - `delete' means delete when hit. */ - -enum enable { disabled, enabled, temporary, delete}; - -/* Not that the ->silent field is not currently used by any commands - (though the code is in there if it was to be, and set_raw_breakpoint - does set it to 0). I implemented it because I thought it would be - useful for a hack I had to put in; I'm going to leave it in because - I can see how there might be times when it would indeed be useful */ - -/* This is for a breakpoint or a watchpoint. */ - -struct breakpoint -{ - struct breakpoint *next; - /* Number assigned to distinguish breakpoints. */ - int number; - /* Address to break at, or NULL if not a breakpoint. */ - CORE_ADDR address; - /* Line number of this address. Redundant. Only matters if address - is non-NULL. */ - int line_number; - /* Symtab of file of this address. Redundant. Only matters if address - is non-NULL. */ - struct symtab *symtab; - /* Zero means disabled; remember the info but don't break here. */ - enum enable enable; - /* Non-zero means a silent breakpoint (don't print frame info - if we stop here). */ - unsigned char silent; - /* Number of stops at this breakpoint that should - be continued automatically before really stopping. */ - int ignore_count; - /* "Real" contents of byte where breakpoint has been inserted. - Valid only when breakpoints are in the program. Under the complete - control of the target insert_breakpoint and remove_breakpoint routines. - No other code should assume anything about the value(s) here. */ - char shadow_contents[BREAKPOINT_MAX]; - /* Nonzero if this breakpoint is now inserted. Only matters if address - is non-NULL. */ - char inserted; - /* Nonzero if this is not the first breakpoint in the list - for the given address. Only matters if address is non-NULL. */ - char duplicate; - /* Chain of command lines to execute when this breakpoint is hit. */ - struct command_line *commands; - /* Stack depth (address of frame). If nonzero, break only if fp - equals this. */ - FRAME_ADDR frame; - /* Conditional. Break only if this expression's value is nonzero. */ - struct expression *cond; - - /* String we used to set the breakpoint (malloc'd). Only matters if - address is non-NULL. */ - char *addr_string; - /* String form of the breakpoint condition (malloc'd), or NULL if there - is no condition. */ - char *cond_string; - - /* The expression we are watching, or NULL if not a watchpoint. */ - struct expression *exp; - /* The largest block within which it is valid, or NULL if it is - valid anywhere (e.g. consists just of global symbols). */ - struct block *exp_valid_block; - /* Value of the watchpoint the last time we checked it. */ - value val; -}; - -#define ALL_BREAKPOINTS(b) for (b = breakpoint_chain; b; b = b->next) - -/* Chain of all breakpoints defined. */ - -struct breakpoint *breakpoint_chain; - -/* Number of last breakpoint made. */ - -static int breakpoint_count; - -/* Set breakpoint count to NUM. */ -static void -set_breakpoint_count (num) - int num; -{ - breakpoint_count = num; - set_internalvar (lookup_internalvar ("bpnum"), - value_from_longest (builtin_type_int, (LONGEST) num)); -} - -/* Default address, symtab and line to put a breakpoint at - for "break" command with no arg. - if default_breakpoint_valid is zero, the other three are - not valid, and "break" with no arg is an error. - - This set by print_stack_frame, which calls set_default_breakpoint. */ - -int default_breakpoint_valid; -CORE_ADDR default_breakpoint_address; -struct symtab *default_breakpoint_symtab; -int default_breakpoint_line; - -static void delete_breakpoint (); -void breakpoint_auto_delete (); - -/* Flag indicating extra verbosity for xgdb. */ -extern int xgdb_verbose; - -/* *PP is a string denoting a breakpoint. Get the number of the breakpoint. - Advance *PP after the string and any trailing whitespace. - - Currently the string can either be a number or "$" followed by the name - of a convenience variable. Making it an expression wouldn't work well - for map_breakpoint_numbers (e.g. "4 + 5 + 6"). */ -static int -get_number (pp) - char **pp; -{ - int retval; - char *p = *pp; - - if (p == NULL) - /* Empty line means refer to the last breakpoint. */ - return breakpoint_count; - else if (*p == '$') - { - /* Make a copy of the name, so we can null-terminate it - to pass to lookup_internalvar(). */ - char *varname; - char *start = ++p; - value val; - - while (isalnum (*p) || *p == '_') - p++; - varname = (char *) alloca (p - start + 1); - strncpy (varname, start, p - start); - varname[p - start] = '\0'; - val = value_of_internalvar (lookup_internalvar (varname)); - if (TYPE_CODE (VALUE_TYPE (val)) != TYPE_CODE_INT) - error ( -"Convenience variables used to specify breakpoints must have integer values." - ); - retval = (int) value_as_long (val); - } - else - { - while (*p >= '0' && *p <= '9') - ++p; - if (p == *pp) - /* There is no number here. (e.g. "cond a == b"). */ - error_no_arg ("breakpoint number"); - retval = atoi (*pp); - } - if (!(isspace (*p) || *p == '\0')) - error ("breakpoint number expected"); - while (isspace (*p)) - p++; - *pp = p; - return retval; -} - -/* condition N EXP -- set break condition of breakpoint N to EXP. */ - -static void -condition_command (arg, from_tty) - char *arg; - int from_tty; -{ - register struct breakpoint *b; - char *p; - register int bnum; - - if (arg == 0) - error_no_arg ("breakpoint number"); - - p = arg; - bnum = get_number (&p); - - ALL_BREAKPOINTS (b) - if (b->number == bnum) - { - if (b->cond) - { - free (b->cond); - b->cond = 0; - } - if (b->cond_string != NULL) - free (b->cond_string); - - if (*p == 0) - { - b->cond = 0; - b->cond_string = NULL; - if (from_tty) - printf ("Breakpoint %d now unconditional.\n", bnum); - } - else - { - arg = p; - /* I don't know if it matters whether this is the string the user - typed in or the decompiled expression. */ - b->cond_string = savestring (arg, strlen (arg)); - b->cond = parse_exp_1 (&arg, block_for_pc (b->address), 0); - if (*arg) - error ("Junk at end of expression"); - } - return; - } - - error ("No breakpoint number %d.", bnum); -} - -/* ARGSUSED */ -static void -commands_command (arg, from_tty) - char *arg; - int from_tty; -{ - register struct breakpoint *b; - char *p; - register int bnum; - struct command_line *l; - - /* If we allowed this, we would have problems with when to - free the storage, if we change the commands currently - being read from. */ - - if (executing_breakpoint_commands) - error ("Can't use the \"commands\" command among a breakpoint's commands."); - - p = arg; - bnum = get_number (&p); - if (p && *p) - error ("Unexpected extra arguments following breakpoint number."); - - ALL_BREAKPOINTS (b) - if (b->number == bnum) - { - if (from_tty && input_from_terminal_p ()) - { - printf ("Type commands for when breakpoint %d is hit, one per line.\n\ -End with a line saying just \"end\".\n", bnum); - fflush (stdout); - } - l = read_command_lines (); - free_command_lines (&b->commands); - b->commands = l; - return; - } - error ("No breakpoint number %d.", bnum); -} - -extern int memory_breakpoint_size; /* from mem-break.c */ - -/* Like target_read_memory() but if breakpoints are inserted, return - the shadow contents instead of the breakpoints themselves. */ -int -read_memory_nobpt (memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - unsigned len; -{ - int status; - struct breakpoint *b; - - if (memory_breakpoint_size < 0) - /* No breakpoints on this machine. */ - return target_read_memory (memaddr, myaddr, len); - - ALL_BREAKPOINTS (b) - { - if (b->address == NULL || !b->inserted) - continue; - else if (b->address + memory_breakpoint_size <= memaddr) - /* The breakpoint is entirely before the chunk of memory - we are reading. */ - continue; - else if (b->address >= memaddr + len) - /* The breakpoint is entirely after the chunk of memory we - are reading. */ - continue; - else - { - /* Copy the breakpoint from the shadow contents, and recurse - for the things before and after. */ - - /* Addresses and length of the part of the breakpoint that - we need to copy. */ - CORE_ADDR membpt = b->address; - unsigned int bptlen = memory_breakpoint_size; - /* Offset within shadow_contents. */ - int bptoffset = 0; - - if (membpt < memaddr) - { - /* Only copy the second part of the breakpoint. */ - bptlen -= memaddr - membpt; - bptoffset = memaddr - membpt; - membpt = memaddr; - } - - if (membpt + bptlen > memaddr + len) - { - /* Only copy the first part of the breakpoint. */ - bptlen -= (membpt + bptlen) - (memaddr + len); - } - - bcopy (b->shadow_contents + bptoffset, - myaddr + membpt - memaddr, bptlen); - - if (membpt > memaddr) - { - /* Copy the section of memory before the breakpoint. */ - status = read_memory_nobpt (memaddr, myaddr, membpt - memaddr); - if (status != 0) - return status; - } - - if (membpt + bptlen < memaddr + len) - { - /* Copy the section of memory after the breakpoint. */ - status = read_memory_nobpt - (membpt + bptlen, - myaddr + membpt + bptlen - memaddr, - memaddr + len - (membpt + bptlen)); - if (status != 0) - return status; - } - return 0; - } - } - /* Nothing overlaps. Just call read_memory_noerr. */ - return target_read_memory (memaddr, myaddr, len); -} - -/* insert_breakpoints is used when starting or continuing the program. - remove_breakpoints is used when the program stops. - Both return zero if successful, - or an `errno' value if could not write the inferior. */ - -int -insert_breakpoints () -{ - register struct breakpoint *b; - int val = 0; - int disabled_breaks = 0; - - ALL_BREAKPOINTS (b) - if (b->address != NULL - && b->enable != disabled - && ! b->inserted - && ! b->duplicate) - { - val = target_insert_breakpoint(b->address, b->shadow_contents); - if (val) - { - /* Can't set the breakpoint. */ -#if defined (DISABLE_UNSETTABLE_BREAK) - if (DISABLE_UNSETTABLE_BREAK (b->address)) - { - val = 0; - b->enable = disabled; - if (!disabled_breaks) - { - fprintf (stderr, - "Cannot insert breakpoint %d:\n", b->number); - printf_filtered ("Disabling shared library breakpoints:\n"); - } - disabled_breaks = 1; - printf_filtered ("%d ", b->number); - } - else -#endif - { - fprintf (stderr, "Cannot insert breakpoint %d:\n", b->number); -#ifdef ONE_PROCESS_WRITETEXT - fprintf (stderr, - "The same program may be running in another process.\n"); -#endif - memory_error (val, b->address); /* which bombs us out */ - } - } - else - b->inserted = 1; - } - if (disabled_breaks) - printf_filtered ("\n"); - return val; -} - -int -remove_breakpoints () -{ - register struct breakpoint *b; - int val; - -#ifdef BREAKPOINT_DEBUG - printf ("Removing breakpoints.\n"); -#endif /* BREAKPOINT_DEBUG */ - - ALL_BREAKPOINTS (b) - if (b->address != NULL && b->inserted) - { - val = target_remove_breakpoint(b->address, b->shadow_contents); - if (val) - return val; - b->inserted = 0; -#ifdef BREAKPOINT_DEBUG - printf ("Removed breakpoint at %s", - local_hex_string(b->address)); - printf (", shadow %s", - local_hex_string(b->shadow_contents[0])); - printf (", %s.\n", - local_hex_string(b->shadow_contents[1])); -#endif /* BREAKPOINT_DEBUG */ - } - - return 0; -} - -/* Clear the "inserted" flag in all breakpoints. - This is done when the inferior is loaded. */ - -void -mark_breakpoints_out () -{ - register struct breakpoint *b; - - ALL_BREAKPOINTS (b) - b->inserted = 0; -} - -/* breakpoint_here_p (PC) returns 1 if an enabled breakpoint exists at PC. - When continuing from a location with a breakpoint, - we actually single step once before calling insert_breakpoints. */ - -int -breakpoint_here_p (pc) - CORE_ADDR pc; -{ - register struct breakpoint *b; - - ALL_BREAKPOINTS (b) - if (b->enable != disabled && b->address == pc) - return 1; - - return 0; -} - -/* bpstat stuff. External routines' interfaces are documented - in breakpoint.h. */ -void -bpstat_clear (bsp) - bpstat *bsp; -{ - bpstat p; - bpstat q; - - if (bsp == 0) - return; - p = *bsp; - while (p != NULL) - { - q = p->next; - if (p->old_val != NULL) - value_free (p->old_val); - free (p); - p = q; - } - *bsp = NULL; -} - -bpstat -bpstat_copy (bs) - bpstat bs; -{ - bpstat p = NULL; - bpstat tmp; - bpstat retval; - - if (bs == NULL) - return bs; - - for (; bs != NULL; bs = bs->next) - { - tmp = (bpstat) xmalloc (sizeof (*tmp)); - bcopy (bs, tmp, sizeof (*tmp)); - if (p == NULL) - /* This is the first thing in the chain. */ - retval = tmp; - else - p->next = tmp; - p = tmp; - } - p->next = NULL; - return retval; -} - -int -bpstat_num (bsp) - bpstat *bsp; -{ - struct breakpoint *b; - - if ((*bsp) == NULL) - return 0; /* No more breakpoint values */ - else - { - b = (*bsp)->breakpoint_at; - *bsp = (*bsp)->next; - if (b == NULL) - return -1; /* breakpoint that's been deleted since */ - else - return b->number; /* We have its number */ - } -} - -void -bpstat_clear_actions (bs) - bpstat bs; -{ - for (; bs != NULL; bs = bs->next) - { - bs->commands = NULL; - if (bs->old_val != NULL) - { - value_free (bs->old_val); - bs->old_val = NULL; - } - } -} - -/* Stub for cleaning up our state if we error-out of a breakpoint command */ -/* ARGSUSED */ -static void -cleanup_executing_breakpoints (ignore) - int ignore; -{ - executing_breakpoint_commands = 0; -} - -/* Execute all the commands associated with all the breakpoints at this - location. Any of these commands could cause the process to proceed - beyond this point, etc. We look out for such changes by checking - the global "breakpoint_proceeded" after each command. */ -void -bpstat_do_actions (bsp) - bpstat *bsp; -{ - bpstat bs; - struct cleanup *old_chain; - - executing_breakpoint_commands = 1; - old_chain = make_cleanup (cleanup_executing_breakpoints, 0); - -top: - bs = *bsp; - - breakpoint_proceeded = 0; - for (; bs != NULL; bs = bs->next) - { - while (bs->commands) - { - char *line = bs->commands->line; - bs->commands = bs->commands->next; - execute_command (line, 0); - /* If the inferior is proceeded by the command, bomb out now. - The bpstat chain has been blown away by wait_for_inferior. - But since execution has stopped again, there is a new bpstat - to look at, so start over. */ - if (breakpoint_proceeded) - goto top; - } - } - clear_momentary_breakpoints (); - - executing_breakpoint_commands = 0; - discard_cleanups (old_chain); -} - -int -bpstat_print (bs) - bpstat bs; -{ - /* bs->breakpoint_at can be NULL if it was a momentary breakpoint - which has since been deleted. */ - if (bs == NULL || bs->breakpoint_at == NULL) - return 0; - - /* If bpstat_stop_status says don't print, OK, we won't. An example - circumstance is when we single-stepped for both a watchpoint and - for a "stepi" instruction. The bpstat says that the watchpoint - explains the stop, but we shouldn't print because the watchpoint's - value didn't change -- and the real reason we are stopping here - rather than continuing to step (as the watchpoint would've had us do) - is because of the "stepi". */ - if (!bs->print) - return 0; - - if (bs->breakpoint_at->address != NULL) - { - /* I think the user probably only wants to see one breakpoint - number, not all of them. */ - printf_filtered ("\nBreakpoint %d, ", bs->breakpoint_at->number); - return 0; - } - - if (bs->old_val != NULL) - { - printf_filtered ("\nWatchpoint %d, ", bs->breakpoint_at->number); - print_expression (bs->breakpoint_at->exp, stdout); - printf_filtered ("\nOld value = "); - value_print (bs->old_val, stdout, 0, Val_pretty_default); - printf_filtered ("\nNew value = "); - value_print (bs->breakpoint_at->val, stdout, 0, - Val_pretty_default); - printf_filtered ("\n"); - value_free (bs->old_val); - bs->old_val = NULL; - return 1; - } - - /* Maybe another breakpoint in the chain caused us to stop. - (Currently all watchpoints go on the bpstat whether hit or - not. That probably could (should) be changed, provided care is taken - with respect to bpstat_explains_signal). */ - if (bs->next) - return bpstat_print (bs->next); - - fprintf_filtered (stderr, "gdb internal error: in bpstat_print\n"); - return 0; -} - -/* Evaluate the expression EXP and return 1 if value is zero. - This is used inside a catch_errors to evaluate the breakpoint condition. - The argument is a "struct expression *" that has been cast to char * to - make it pass through catch_errors. */ - -static int -breakpoint_cond_eval (exp) - char *exp; -{ - return !value_true (evaluate_expression ((struct expression *)exp)); -} - -/* Allocate a new bpstat and chain it to the current one. */ - -static bpstat -bpstat_alloc (b, cbs) - register struct breakpoint *b; - bpstat cbs; /* Current "bs" value */ -{ - bpstat bs; - - bs = (bpstat) xmalloc (sizeof (*bs)); - cbs->next = bs; - bs->breakpoint_at = b; - /* If the condition is false, etc., don't do the commands. */ - bs->commands = NULL; - bs->momentary = b->number == -3; - bs->old_val = NULL; - return bs; -} - -/* Determine whether we stopped at a breakpoint, etc, or whether we - don't understand this stop. Result is a chain of bpstat's such that: - - if we don't understand the stop, the result is a null pointer. - - if we understand why we stopped, the result is not null, and - the first element of the chain contains summary "stop" and - "print" flags for the whole chain. - - Each element of the chain refers to a particular breakpoint or - watchpoint at which we have stopped. (We may have stopped for - several reasons.) - - Each element of the chain has valid next, breakpoint_at, - commands, FIXME??? fields. - - */ - - -bpstat -bpstat_stop_status (pc, frame_address) - CORE_ADDR *pc; - FRAME_ADDR frame_address; -{ - register struct breakpoint *b; - int stop = 0; - int print = 0; - CORE_ADDR bp_addr; -#if DECR_PC_AFTER_BREAK != 0 || defined (SHIFT_INST_REGS) - /* True if we've hit a breakpoint (as opposed to a watchpoint). */ - int real_breakpoint = 0; -#endif - /* Root of the chain of bpstat's */ - struct bpstat__struct root_bs[1]; - /* Pointer to the last thing in the chain currently. */ - bpstat bs = root_bs; - - /* Get the address where the breakpoint would have been. */ - bp_addr = *pc - DECR_PC_AFTER_BREAK; - - ALL_BREAKPOINTS (b) - { - int this_bp_stop; - int this_bp_print; - - if (b->enable == disabled) - continue; - if (b->address != NULL && b->address != bp_addr) - continue; - - bs = bpstat_alloc (b, bs); /* Alloc a bpstat to explain stop */ - - this_bp_stop = 1; - this_bp_print = 1; - - if (b->exp != NULL) /* Watchpoint */ - { - int within_current_scope; - if (b->exp_valid_block != NULL) - within_current_scope = - contained_in (get_selected_block (), b->exp_valid_block); - else - within_current_scope = 1; - - if (within_current_scope) - { - /* We use value_{,free_to_}mark because it could be a - *long* time before we return to the command level and - call free_all_values. */ - - value mark = value_mark (); - value new_val = evaluate_expression (b->exp); - if (!value_equal (b->val, new_val)) - { - release_value (new_val); - value_free_to_mark (mark); - bs->old_val = b->val; - b->val = new_val; - /* We will stop here */ - } - else - { - /* Nothing changed, don't do anything. */ - value_free_to_mark (mark); - continue; - /* We won't stop here */ - } - } - else - { - /* This seems like the only logical thing to do because - if we temporarily ignored the watchpoint, then when - we reenter the block in which it is valid it contains - garbage (in the case of a function, it may have two - garbage values, one before and one after the prologue). - So we can't even detect the first assignment to it and - watch after that (since the garbage may or may not equal - the first value assigned). */ - b->enable = disabled; - printf_filtered ("\ -Watchpoint %d disabled because the program has left the block in\n\ -which its expression is valid.\n", b->number); - /* We won't stop here */ - /* FIXME, maybe we should stop here!!! */ - continue; - } - } -#if DECR_PC_AFTER_BREAK != 0 || defined (SHIFT_INST_REGS) - else - real_breakpoint = 1; -#endif - - if (b->frame && b->frame != frame_address) - this_bp_stop = 0; - else - { - int value_is_zero; - - if (b->cond) - { - /* Need to select the frame, with all that implies - so that the conditions will have the right context. */ - select_frame (get_current_frame (), 0); - value_is_zero - = catch_errors (breakpoint_cond_eval, (char *)(b->cond), - "Error in testing breakpoint condition:\n"); - /* FIXME-someday, should give breakpoint # */ - free_all_values (); - } - if (b->cond && value_is_zero) - { - this_bp_stop = 0; - } - else if (b->ignore_count > 0) - { - b->ignore_count--; - this_bp_stop = 0; - } - else - { - /* We will stop here */ - if (b->enable == temporary) - b->enable = disabled; - bs->commands = b->commands; - if (b->silent) - this_bp_print = 0; - if (bs->commands && !strcmp ("silent", bs->commands->line)) - { - bs->commands = bs->commands->next; - this_bp_print = 0; - } - } - } - if (this_bp_stop) - stop = 1; - if (this_bp_print) - print = 1; - } - - bs->next = NULL; /* Terminate the chain */ - bs = root_bs->next; /* Re-grab the head of the chain */ - if (bs) - { - bs->stop = stop; - bs->print = print; -#if DECR_PC_AFTER_BREAK != 0 || defined (SHIFT_INST_REGS) - if (real_breakpoint) - { - *pc = bp_addr; -#if defined (SHIFT_INST_REGS) - { - CORE_ADDR pc = read_register (PC_REGNUM); - CORE_ADDR npc = read_register (NPC_REGNUM); - if (pc != npc) - { - write_register (NNPC_REGNUM, npc); - write_register (NPC_REGNUM, pc); - } - } -#else /* No SHIFT_INST_REGS. */ - write_pc (bp_addr); -#endif /* No SHIFT_INST_REGS. */ - } -#endif /* DECR_PC_AFTER_BREAK != 0. */ - } - return bs; -} - -int -bpstat_should_step () -{ - struct breakpoint *b; - ALL_BREAKPOINTS (b) - if (b->enable != disabled && b->exp != NULL) - return 1; - return 0; -} - -/* Print information on breakpoint number BNUM, or -1 if all. - If WATCHPOINTS is zero, process only breakpoints; if WATCHPOINTS - is nonzero, process only watchpoints. */ - -static void -breakpoint_1 (bnum, watchpoints) - int bnum; - int watchpoints; -{ - register struct breakpoint *b; - register struct command_line *l; - register struct symbol *sym; - CORE_ADDR last_addr = (CORE_ADDR)-1; - int header_printed = 0; - - ALL_BREAKPOINTS (b) - if (bnum == -1 || bnum == b->number) - { - if (b->address == NULL && !watchpoints) - { - if (bnum == -1) - continue; - error ("That is a watchpoint, not a breakpoint."); - } - if (b->address != NULL && watchpoints) - { - if (bnum == -1) - continue; - error ("That is a breakpoint, not a watchpoint."); - } - - if (!header_printed) - { - if (watchpoints) - printf_filtered (" Enb Expression\n"); - else if (addressprint) - printf_filtered (" Enb Address Where\n"); - else - printf_filtered (" Enb Where\n"); - header_printed = 1; - } - - printf_filtered ("#%-3d %c ", b->number, "nyod"[(int) b->enable]); - if (b->address == NULL) { - printf_filtered (" "); - print_expression (b->exp, stdout); - } else { - if (addressprint) - printf_filtered (" %s ", local_hex_string_custom(b->address, "08")); - - last_addr = b->address; - if (b->symtab) - { - sym = find_pc_function (b->address); - if (sym) - { - fputs_filtered (" in ", stdout); - fputs_demangled (SYMBOL_NAME (sym), stdout, 1); - fputs_filtered (" at ", stdout); - } - fputs_filtered (b->symtab->filename, stdout); - printf_filtered (":%d", b->line_number); - } - else - print_address_symbolic (b->address, stdout, demangle, " "); - } - - printf_filtered ("\n"); - - if (b->frame) - printf_filtered ("\tstop only in stack frame at %s\n", - local_hex_string(b->frame)); - if (b->cond) - { - printf_filtered ("\tstop only if "); - print_expression (b->cond, stdout); - printf_filtered ("\n"); - } - if (b->ignore_count) - printf_filtered ("\tignore next %d hits\n", b->ignore_count); - if ((l = b->commands)) - while (l) - { - fputs_filtered ("\t", stdout); - fputs_filtered (l->line, stdout); - fputs_filtered ("\n", stdout); - l = l->next; - } - } - - if (!header_printed) - { - char *which = watchpoints ? "watch" : "break"; - if (bnum == -1) - printf_filtered ("No %spoints.\n", which); - else - printf_filtered ("No %spoint numbered %d.\n", which, bnum); - } - - /* Compare against (CORE_ADDR)-1 in case some compiler decides - that a comparison of an unsigned with -1 is always false. */ - if (last_addr != (CORE_ADDR)-1) - set_next_address (last_addr); -} - -/* ARGSUSED */ -static void -breakpoints_info (bnum_exp, from_tty) - char *bnum_exp; - int from_tty; -{ - int bnum = -1; - - if (bnum_exp) - bnum = parse_and_eval_address (bnum_exp); - - breakpoint_1 (bnum, 0); -} - -/* ARGSUSED */ -static void -watchpoints_info (bnum_exp, from_tty) - char *bnum_exp; - int from_tty; -{ - int bnum = -1; - - if (bnum_exp) - bnum = parse_and_eval_address (bnum_exp); - - breakpoint_1 (bnum, 1); -} - -/* Print a message describing any breakpoints set at PC. */ - -static void -describe_other_breakpoints (pc) - register CORE_ADDR pc; -{ - register int others = 0; - register struct breakpoint *b; - - ALL_BREAKPOINTS (b) - if (b->address == pc) - others++; - if (others > 0) - { - printf ("Note: breakpoint%s ", (others > 1) ? "s" : ""); - ALL_BREAKPOINTS (b) - if (b->address == pc) - { - others--; - printf ("%d%s%s ", - b->number, - (b->enable == disabled) ? " (disabled)" : "", - (others > 1) ? "," : ((others == 1) ? " and" : "")); - } - printf ("also set at pc %s.\n", local_hex_string(pc)); - } -} - -/* Set the default place to put a breakpoint - for the `break' command with no arguments. */ - -void -set_default_breakpoint (valid, addr, symtab, line) - int valid; - CORE_ADDR addr; - struct symtab *symtab; - int line; -{ - default_breakpoint_valid = valid; - default_breakpoint_address = addr; - default_breakpoint_symtab = symtab; - default_breakpoint_line = line; -} - -/* Rescan breakpoints at address ADDRESS, - marking the first one as "first" and any others as "duplicates". - This is so that the bpt instruction is only inserted once. */ - -static void -check_duplicates (address) - CORE_ADDR address; -{ - register struct breakpoint *b; - register int count = 0; - - if (address == NULL) /* Watchpoints are uninteresting */ - return; - - ALL_BREAKPOINTS (b) - if (b->enable != disabled && b->address == address) - { - count++; - b->duplicate = count > 1; - } -} - -/* Low level routine to set a breakpoint. - Takes as args the three things that every breakpoint must have. - Returns the breakpoint object so caller can set other things. - Does not set the breakpoint number! - Does not print anything. - - ==> This routine should not be called if there is a chance of later - error(); otherwise it leaves a bogus breakpoint on the chain. Validate - your arguments BEFORE calling this routine! */ - -static struct breakpoint * -set_raw_breakpoint (sal) - struct symtab_and_line sal; -{ - register struct breakpoint *b, *b1; - - b = (struct breakpoint *) xmalloc (sizeof (struct breakpoint)); - bzero (b, sizeof *b); - b->address = sal.pc; - b->symtab = sal.symtab; - b->line_number = sal.line; - b->enable = enabled; - b->next = 0; - b->silent = 0; - b->ignore_count = 0; - b->commands = NULL; - b->frame = NULL; - - /* Add this breakpoint to the end of the chain - so that a list of breakpoints will come out in order - of increasing numbers. */ - - b1 = breakpoint_chain; - if (b1 == 0) - breakpoint_chain = b; - else - { - while (b1->next) - b1 = b1->next; - b1->next = b; - } - - check_duplicates (sal.pc); - - return b; -} - -/* Set a breakpoint that will evaporate an end of command - at address specified by SAL. - Restrict it to frame FRAME if FRAME is nonzero. */ - -void -set_momentary_breakpoint (sal, frame) - struct symtab_and_line sal; - FRAME frame; -{ - register struct breakpoint *b; - b = set_raw_breakpoint (sal); - b->number = -3; - b->enable = delete; - b->frame = (frame ? FRAME_FP (frame) : 0); -} - -void -clear_momentary_breakpoints () -{ - register struct breakpoint *b; - ALL_BREAKPOINTS (b) - if (b->number == -3) - { - delete_breakpoint (b); - break; - } -} - -/* Tell the user we have just set a breakpoint B. */ -static void -mention (b) - struct breakpoint *b; -{ - if (b->exp) - { - printf_filtered ("Watchpoint %d: ", b->number); - print_expression (b->exp, stdout); - } - else - { - printf_filtered ("Breakpoint %d at %s", b->number, - local_hex_string(b->address)); - if (b->symtab) - printf_filtered (": file %s, line %d.", - b->symtab->filename, b->line_number); - } - printf_filtered ("\n"); -} - -#if 0 -/* Nobody calls this currently. */ -/* Set a breakpoint from a symtab and line. - If TEMPFLAG is nonzero, it is a temporary breakpoint. - ADDR_STRING is a malloc'd string holding the name of where we are - setting the breakpoint. This is used later to re-set it after the - program is relinked and symbols are reloaded. - Print the same confirmation messages that the breakpoint command prints. */ - -void -set_breakpoint (s, line, tempflag, addr_string) - struct symtab *s; - int line; - int tempflag; - char *addr_string; -{ - register struct breakpoint *b; - struct symtab_and_line sal; - - sal.symtab = s; - sal.line = line; - sal.pc = find_line_pc (sal.symtab, sal.line); - if (sal.pc == 0) - error ("No line %d in file \"%s\".\n", sal.line, sal.symtab->filename); - else - { - describe_other_breakpoints (sal.pc); - - b = set_raw_breakpoint (sal); - set_breakpoint_count (breakpoint_count + 1); - b->number = breakpoint_count; - b->cond = 0; - b->addr_string = addr_string; - if (tempflag) - b->enable = temporary; - - mention (b); - } -} -#endif - -/* Set a breakpoint according to ARG (function, linenum or *address) - and make it temporary if TEMPFLAG is nonzero. */ - -static void -break_command_1 (arg, tempflag, from_tty) - char *arg; - int tempflag, from_tty; -{ - struct symtabs_and_lines sals; - struct symtab_and_line sal; - register struct expression *cond = 0; - register struct breakpoint *b; - - /* Pointers in arg to the start, and one past the end, of the condition. */ - char *cond_start = NULL; - char *cond_end; - /* Pointers in arg to the start, and one past the end, - of the address part. */ - char *addr_start = NULL; - char *addr_end; - - int i; - CORE_ADDR pc; - - sals.sals = NULL; - sals.nelts = 0; - - sal.line = sal.pc = sal.end = 0; - sal.symtab = 0; - - /* If no arg given, or if first arg is 'if ', use the default breakpoint. */ - - if (!arg || (arg[0] == 'i' && arg[1] == 'f' - && (arg[2] == ' ' || arg[2] == '\t'))) - { - if (default_breakpoint_valid) - { - sals.sals = (struct symtab_and_line *) - xmalloc (sizeof (struct symtab_and_line)); - sal.pc = default_breakpoint_address; - sal.line = default_breakpoint_line; - sal.symtab = default_breakpoint_symtab; - sals.sals[0] = sal; - sals.nelts = 1; - } - else - error ("No default breakpoint address now."); - } - else - { - addr_start = arg; - - /* Force almost all breakpoints to be in terms of the - current_source_symtab (which is decode_line_1's default). This - should produce the results we want almost all of the time while - leaving default_breakpoint_* alone. */ - if (default_breakpoint_valid - && (!current_source_symtab - || (arg && (*arg == '+' || *arg == '-')))) - sals = decode_line_1 (&arg, 1, default_breakpoint_symtab, - default_breakpoint_line); - else - sals = decode_line_1 (&arg, 1, (struct symtab *)NULL, 0); - - addr_end = arg; - } - - if (! sals.nelts) - return; - - for (i = 0; i < sals.nelts; i++) - { - sal = sals.sals[i]; - if (sal.pc == 0 && sal.symtab != 0) - { - pc = find_line_pc (sal.symtab, sal.line); - if (pc == 0) - error ("No line %d in file \"%s\".", - sal.line, sal.symtab->filename); - } - else - pc = sal.pc; - - while (arg && *arg) - { - if (arg[0] == 'i' && arg[1] == 'f' - && (arg[2] == ' ' || arg[2] == '\t')) - { - arg += 2; - cond_start = arg; - cond = parse_exp_1 (&arg, block_for_pc (pc), 0); - cond_end = arg; - } - else - error ("Junk at end of arguments."); - } - sals.sals[i].pc = pc; - } - - for (i = 0; i < sals.nelts; i++) - { - sal = sals.sals[i]; - - if (from_tty) - describe_other_breakpoints (sal.pc); - - b = set_raw_breakpoint (sal); - set_breakpoint_count (breakpoint_count + 1); - b->number = breakpoint_count; - b->cond = cond; - - if (addr_start) - b->addr_string = savestring (addr_start, addr_end - addr_start); - if (cond_start) - b->cond_string = savestring (cond_start, cond_end - cond_start); - - if (tempflag) - b->enable = temporary; - - mention (b); - } - - if (sals.nelts > 1) - { - printf ("Multiple breakpoints were set.\n"); - printf ("Use the \"delete\" command to delete unwanted breakpoints.\n"); - } - free (sals.sals); -} - -void -break_command (arg, from_tty) - char *arg; - int from_tty; -{ - break_command_1 (arg, 0, from_tty); -} - -static void -tbreak_command (arg, from_tty) - char *arg; - int from_tty; -{ - break_command_1 (arg, 1, from_tty); -} - -/* ARGSUSED */ -static void -watch_command (arg, from_tty) - char *arg; - int from_tty; -{ - struct breakpoint *b; - struct symtab_and_line sal; - struct expression *exp; - struct block *exp_valid_block; - struct value *val; - - sal.pc = NULL; - sal.symtab = NULL; - sal.line = 0; - - /* Parse arguments. */ - innermost_block = NULL; - exp = parse_expression (arg); - exp_valid_block = innermost_block; - val = evaluate_expression (exp); - release_value (val); - - /* Now set up the breakpoint. */ - b = set_raw_breakpoint (sal); - set_breakpoint_count (breakpoint_count + 1); - b->number = breakpoint_count; - b->exp = exp; - b->exp_valid_block = exp_valid_block; - b->val = val; - b->cond = 0; - b->cond_string = NULL; - mention (b); -} - -/* - * Helper routine for the until_command routine in infcmd.c. Here - * because it uses the mechanisms of breakpoints. - */ -/* ARGSUSED */ -void -until_break_command (arg, from_tty) - char *arg; - int from_tty; -{ - struct symtabs_and_lines sals; - struct symtab_and_line sal; - FRAME prev_frame = get_prev_frame (selected_frame); - - clear_proceed_status (); - - /* Set a breakpoint where the user wants it and at return from - this function */ - - if (default_breakpoint_valid) - sals = decode_line_1 (&arg, 1, default_breakpoint_symtab, - default_breakpoint_line); - else - sals = decode_line_1 (&arg, 1, (struct symtab *)NULL, 0); - - if (sals.nelts != 1) - error ("Couldn't get information on specified line."); - - sal = sals.sals[0]; - free (sals.sals); /* malloc'd, so freed */ - - if (*arg) - error ("Junk at end of arguments."); - - if (sal.pc == 0 && sal.symtab != 0) - sal.pc = find_line_pc (sal.symtab, sal.line); - - if (sal.pc == 0) - error ("No line %d in file \"%s\".", sal.line, sal.symtab->filename); - - set_momentary_breakpoint (sal, selected_frame); - - /* Keep within the current frame */ - - if (prev_frame) - { - struct frame_info *fi; - - fi = get_frame_info (prev_frame); - sal = find_pc_line (fi->pc, 0); - sal.pc = fi->pc; - set_momentary_breakpoint (sal, prev_frame); - } - - proceed (-1, -1, 0); -} - -#if 0 -/* These aren't used; I don't konw what they were for. */ -/* Set a breakpoint at the catch clause for NAME. */ -static int -catch_breakpoint (name) - char *name; -{ -} - -static int -disable_catch_breakpoint () -{ -} - -static int -delete_catch_breakpoint () -{ -} - -static int -enable_catch_breakpoint () -{ -} -#endif /* 0 */ - -struct sal_chain -{ - struct sal_chain *next; - struct symtab_and_line sal; -}; - -#if 0 -/* This isn't used; I don't know what it was for. */ -/* For each catch clause identified in ARGS, run FUNCTION - with that clause as an argument. */ -static struct symtabs_and_lines -map_catch_names (args, function) - char *args; - int (*function)(); -{ - register char *p = args; - register char *p1; - struct symtabs_and_lines sals; -#if 0 - struct sal_chain *sal_chain = 0; -#endif - - if (p == 0) - error_no_arg ("one or more catch names"); - - sals.nelts = 0; - sals.sals = NULL; - - while (*p) - { - p1 = p; - /* Don't swallow conditional part. */ - if (p1[0] == 'i' && p1[1] == 'f' - && (p1[2] == ' ' || p1[2] == '\t')) - break; - - if (isalpha (*p1)) - { - p1++; - while (isalnum (*p1) || *p1 == '_' || *p1 == '$') - p1++; - } - - if (*p1 && *p1 != ' ' && *p1 != '\t') - error ("Arguments must be catch names."); - - *p1 = 0; -#if 0 - if (function (p)) - { - struct sal_chain *next - = (struct sal_chain *)alloca (sizeof (struct sal_chain)); - next->next = sal_chain; - next->sal = get_catch_sal (p); - sal_chain = next; - goto win; - } -#endif - printf ("No catch clause for exception %s.\n", p); -#if 0 - win: -#endif - p = p1; - while (*p == ' ' || *p == '\t') p++; - } -} -#endif /* 0 */ - -/* This shares a lot of code with `print_frame_label_vars' from stack.c. */ - -static struct symtabs_and_lines -get_catch_sals (this_level_only) - int this_level_only; -{ - extern struct blockvector *blockvector_for_pc (); - register struct blockvector *bl; - register struct block *block; - int index, have_default = 0; - struct frame_info *fi; - CORE_ADDR pc; - struct symtabs_and_lines sals; - struct sal_chain *sal_chain = 0; - char *blocks_searched; - - /* Not sure whether an error message is always the correct response, - but it's better than a core dump. */ - if (selected_frame == NULL) - error ("No selected frame."); - block = get_frame_block (selected_frame); - fi = get_frame_info (selected_frame); - pc = fi->pc; - - sals.nelts = 0; - sals.sals = NULL; - - if (block == 0) - error ("No symbol table info available.\n"); - - bl = blockvector_for_pc (BLOCK_END (block) - 4, &index); - blocks_searched = (char *) alloca (BLOCKVECTOR_NBLOCKS (bl) * sizeof (char)); - bzero (blocks_searched, BLOCKVECTOR_NBLOCKS (bl) * sizeof (char)); - - while (block != 0) - { - CORE_ADDR end = BLOCK_END (block) - 4; - int last_index; - - if (bl != blockvector_for_pc (end, &index)) - error ("blockvector blotch"); - if (BLOCKVECTOR_BLOCK (bl, index) != block) - error ("blockvector botch"); - last_index = BLOCKVECTOR_NBLOCKS (bl); - index += 1; - - /* Don't print out blocks that have gone by. */ - while (index < last_index - && BLOCK_END (BLOCKVECTOR_BLOCK (bl, index)) < pc) - index++; - - while (index < last_index - && BLOCK_END (BLOCKVECTOR_BLOCK (bl, index)) < end) - { - if (blocks_searched[index] == 0) - { - struct block *b = BLOCKVECTOR_BLOCK (bl, index); - int nsyms; - register int i; - register struct symbol *sym; - - nsyms = BLOCK_NSYMS (b); - - for (i = 0; i < nsyms; i++) - { - sym = BLOCK_SYM (b, i); - if (! strcmp (SYMBOL_NAME (sym), "default")) - { - if (have_default) - continue; - have_default = 1; - } - if (SYMBOL_CLASS (sym) == LOC_LABEL) - { - struct sal_chain *next = (struct sal_chain *) - alloca (sizeof (struct sal_chain)); - next->next = sal_chain; - next->sal = find_pc_line (SYMBOL_VALUE_ADDRESS (sym), 0); - sal_chain = next; - } - } - blocks_searched[index] = 1; - } - index++; - } - if (have_default) - break; - if (sal_chain && this_level_only) - break; - - /* After handling the function's top-level block, stop. - Don't continue to its superblock, the block of - per-file symbols. */ - if (BLOCK_FUNCTION (block)) - break; - block = BLOCK_SUPERBLOCK (block); - } - - if (sal_chain) - { - struct sal_chain *tmp_chain; - - /* Count the number of entries. */ - for (index = 0, tmp_chain = sal_chain; tmp_chain; - tmp_chain = tmp_chain->next) - index++; - - sals.nelts = index; - sals.sals = (struct symtab_and_line *) - xmalloc (index * sizeof (struct symtab_and_line)); - for (index = 0; sal_chain; sal_chain = sal_chain->next, index++) - sals.sals[index] = sal_chain->sal; - } - - return sals; -} - -/* Commands to deal with catching exceptions. */ - -void -catch_command_1 (arg, tempflag, from_tty) - char *arg; - int tempflag; - int from_tty; -{ - /* First, translate ARG into something we can deal with in terms - of breakpoints. */ - - struct symtabs_and_lines sals; - struct symtab_and_line sal; - register struct expression *cond = 0; - register struct breakpoint *b; - char *save_arg; - int i; - CORE_ADDR pc; - - sal.line = sal.pc = sal.end = 0; - sal.symtab = 0; - - /* If no arg given, or if first arg is 'if ', all active catch clauses - are breakpointed. */ - - if (!arg || (arg[0] == 'i' && arg[1] == 'f' - && (arg[2] == ' ' || arg[2] == '\t'))) - { - /* Grab all active catch clauses. */ - sals = get_catch_sals (0); - } - else - { - /* Grab selected catch clauses. */ - error ("catch NAME not implemeneted"); -#if 0 - /* This isn't used; I don't know what it was for. */ - sals = map_catch_names (arg, catch_breakpoint); -#endif - } - - if (! sals.nelts) - return; - - save_arg = arg; - for (i = 0; i < sals.nelts; i++) - { - sal = sals.sals[i]; - if (sal.pc == 0 && sal.symtab != 0) - { - pc = find_line_pc (sal.symtab, sal.line); - if (pc == 0) - error ("No line %d in file \"%s\".", - sal.line, sal.symtab->filename); - } - else - pc = sal.pc; - - while (arg && *arg) - { - if (arg[0] == 'i' && arg[1] == 'f' - && (arg[2] == ' ' || arg[2] == '\t')) - cond = (struct expression *) parse_exp_1 ((arg += 2, &arg), - block_for_pc (pc), 0); - else - error ("Junk at end of arguments."); - } - arg = save_arg; - sals.sals[i].pc = pc; - } - - for (i = 0; i < sals.nelts; i++) - { - sal = sals.sals[i]; - - if (from_tty) - describe_other_breakpoints (sal.pc); - - b = set_raw_breakpoint (sal); - b->number = ++breakpoint_count; - b->cond = cond; - if (tempflag) - b->enable = temporary; - - printf ("Breakpoint %d at %s", b->number, local_hex_string(b->address)); - if (b->symtab) - printf (": file %s, line %d.", b->symtab->filename, b->line_number); - printf ("\n"); - } - - if (sals.nelts > 1) - { - printf ("Multiple breakpoints were set.\n"); - printf ("Use the \"delete\" command to delete unwanted breakpoints.\n"); - } - free (sals.sals); -} - -#if 0 -/* These aren't used; I don't know what they were for. */ -/* Disable breakpoints on all catch clauses described in ARGS. */ -static void -disable_catch (args) - char *args; -{ - /* Map the disable command to catch clauses described in ARGS. */ -} - -/* Enable breakpoints on all catch clauses described in ARGS. */ -static void -enable_catch (args) - char *args; -{ - /* Map the disable command to catch clauses described in ARGS. */ -} - -/* Delete breakpoints on all catch clauses in the active scope. */ -static void -delete_catch (args) - char *args; -{ - /* Map the delete command to catch clauses described in ARGS. */ -} -#endif /* 0 */ - -static void -catch_command (arg, from_tty) - char *arg; - int from_tty; -{ - catch_command_1 (arg, 0, from_tty); -} - -static void -clear_command (arg, from_tty) - char *arg; - int from_tty; -{ - register struct breakpoint *b, *b1; - struct symtabs_and_lines sals; - struct symtab_and_line sal; - register struct breakpoint *found; - int i; - - if (arg) - { - sals = decode_line_spec (arg, 1); - } - else - { - sals.sals = (struct symtab_and_line *) xmalloc (sizeof (struct symtab_and_line)); - sal.line = default_breakpoint_line; - sal.symtab = default_breakpoint_symtab; - sal.pc = 0; - if (sal.symtab == 0) - error ("No source file specified."); - - sals.sals[0] = sal; - sals.nelts = 1; - } - - for (i = 0; i < sals.nelts; i++) - { - /* If exact pc given, clear bpts at that pc. - But if sal.pc is zero, clear all bpts on specified line. */ - sal = sals.sals[i]; - found = (struct breakpoint *) 0; - while (breakpoint_chain - && (sal.pc ? breakpoint_chain->address == sal.pc - : (breakpoint_chain->symtab == sal.symtab - && breakpoint_chain->line_number == sal.line))) - { - b1 = breakpoint_chain; - breakpoint_chain = b1->next; - b1->next = found; - found = b1; - } - - ALL_BREAKPOINTS (b) - while (b->next - && b->next->address != NULL - && (sal.pc ? b->next->address == sal.pc - : (b->next->symtab == sal.symtab - && 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); - else - error ("No breakpoint at this line."); - } - - if (found->next) from_tty = 1; /* Always report if deleted more than one */ - if (from_tty) printf ("Deleted breakpoint%s ", found->next ? "s" : ""); - while (found) - { - if (from_tty) printf ("%d ", found->number); - b1 = found->next; - delete_breakpoint (found); - found = b1; - } - if (from_tty) putchar ('\n'); - } - free (sals.sals); -} - -/* Delete breakpoint in BS if they are `delete' breakpoints. - This is called after any breakpoint is hit, or after errors. */ - -void -breakpoint_auto_delete (bs) - bpstat bs; -{ - for (; bs; bs = bs->next) - if (bs->breakpoint_at && bs->breakpoint_at->enable == delete) - delete_breakpoint (bs->breakpoint_at); -} - -/* Delete a breakpoint and clean up all traces of it in the data structures. */ - -static void -delete_breakpoint (bpt) - struct breakpoint *bpt; -{ - register struct breakpoint *b; - register bpstat bs; - - if (bpt->inserted) - target_remove_breakpoint(bpt->address, bpt->shadow_contents); - - if (breakpoint_chain == bpt) - breakpoint_chain = bpt->next; - - ALL_BREAKPOINTS (b) - if (b->next == bpt) - { - b->next = bpt->next; - break; - } - - check_duplicates (bpt->address); - - free_command_lines (&bpt->commands); - if (bpt->cond) - free (bpt->cond); - if (bpt->cond_string != NULL) - free (bpt->cond_string); - if (bpt->addr_string != NULL) - free (bpt->addr_string); - - if (xgdb_verbose && bpt->number >=0) - printf ("breakpoint #%d deleted\n", bpt->number); - - /* Be sure no bpstat's are pointing at it after it's been freed. */ - /* FIXME, how can we find all bpstat's? We just check stop_bpstat for now. */ - for (bs = stop_bpstat; bs; bs = bs->next) - if (bs->breakpoint_at == bpt) - bs->breakpoint_at = NULL; - free (bpt); -} - -static void map_breakpoint_numbers (); - -static void -delete_command (arg, from_tty) - char *arg; - int from_tty; -{ - - if (arg == 0) - { - /* Ask user only if there are some breakpoints to delete. */ - if (!from_tty - || (breakpoint_chain && query ("Delete all breakpoints? ", 0, 0))) - { - /* No arg; clear all breakpoints. */ - while (breakpoint_chain) - delete_breakpoint (breakpoint_chain); - } - } - else - map_breakpoint_numbers (arg, delete_breakpoint); -} - -/* Reset a breakpoint given it's struct breakpoint * BINT. - The value we return ends up being the return value from catch_errors. - Unused in this case. */ - -static int -breakpoint_re_set_one (bint) - char *bint; -{ - struct breakpoint *b = (struct breakpoint *)bint; /* get past catch_errs */ - int i; - struct symtabs_and_lines sals; - struct symtab_and_line sal; - char *s; - - if (b->address != NULL && b->addr_string != NULL) - { - s = b->addr_string; - sals = decode_line_1 (&s, 1, (struct symtab *)NULL, 0); - for (i = 0; i < sals.nelts; i++) - { - sal = sals.sals[i]; - - b->symtab = sal.symtab; - b->line_number = sal.line; - if (sal.pc == 0 && sal.symtab != 0) - { - sal.pc = find_line_pc (sal.symtab, sal.line); - if (sal.pc == 0) - error ("No line %d in file \"%s\".", - sal.line, sal.symtab->filename); - } - b->address = sal.pc; - - if (b->cond_string != NULL) - { - s = b->cond_string; - b->cond = parse_exp_1 (&s, block_for_pc (sal.pc), 0); - } - - check_duplicates (b->address); - - mention (b); - } - free (sals.sals); - } - else - { - /* Anything without a string can't be re-set. */ - delete_breakpoint (b); - } - return 0; -} - -/* Re-set all breakpoints after symbols have been re-loaded. */ -void -breakpoint_re_set () -{ - struct breakpoint *b; - - ALL_BREAKPOINTS (b) - { - b->symtab = 0; /* Be sure we don't point to old dead symtab */ - (void) catch_errors (breakpoint_re_set_one, (char *) b, - "Error in re-setting breakpoint:\n"); - } - - /* Blank line to finish off all those mention() messages we just printed. */ - printf_filtered ("\n"); -} - -/* Set ignore-count of breakpoint number BPTNUM to COUNT. - If from_tty is nonzero, it prints a message to that effect, - which ends with a period (no newline). */ - -void -set_ignore_count (bptnum, count, from_tty) - int bptnum, count, from_tty; -{ - register struct breakpoint *b; - - if (count < 0) - count = 0; - - ALL_BREAKPOINTS (b) - if (b->number == bptnum) - { - b->ignore_count = count; - if (!from_tty) - return; - else if (count == 0) - printf ("Will stop next time breakpoint %d is reached.", bptnum); - else if (count == 1) - printf ("Will ignore next crossing of breakpoint %d.", bptnum); - else - printf ("Will ignore next %d crossings of breakpoint %d.", - count, bptnum); - return; - } - - error ("No breakpoint number %d.", bptnum); -} - -/* Clear the ignore counts of all breakpoints. */ -void -breakpoint_clear_ignore_counts () -{ - struct breakpoint *b; - - ALL_BREAKPOINTS (b) - b->ignore_count = 0; -} - -/* Command to set ignore-count of breakpoint N to COUNT. */ - -static void -ignore_command (args, from_tty) - char *args; - int from_tty; -{ - char *p = args; - register int num; - - if (p == 0) - error_no_arg ("a breakpoint number"); - - num = get_number (&p); - - if (*p == 0) - error ("Second argument (specified ignore-count) is missing."); - - set_ignore_count (num, - longest_to_int (value_as_long (parse_and_eval (p))), - from_tty); - printf ("\n"); -} - -/* Call FUNCTION on each of the breakpoints - whose numbers are given in ARGS. */ - -static void -map_breakpoint_numbers (args, function) - char *args; - void (*function) (); -{ - register char *p = args; - char *p1; - register int num; - register struct breakpoint *b; - - if (p == 0) - error_no_arg ("one or more breakpoint numbers"); - - while (*p) - { - p1 = p; - - num = get_number (&p1); - - ALL_BREAKPOINTS (b) - if (b->number == num) - { - function (b); - goto win; - } - printf ("No breakpoint number %d.\n", num); - win: - p = p1; - } -} - -static void -enable_breakpoint (bpt) - struct breakpoint *bpt; -{ - bpt->enable = enabled; - - if (xgdb_verbose && bpt->number >= 0) - printf ("breakpoint #%d enabled\n", bpt->number); - - check_duplicates (bpt->address); - if (bpt->val != NULL) - { - if (bpt->exp_valid_block != NULL - && !contained_in (get_selected_block (), bpt->exp_valid_block)) - { - printf_filtered ("\ -Cannot enable watchpoint %d because the block in which its expression\n\ -is valid is not currently in scope.\n", bpt->number); - return; - } - - value_free (bpt->val); - - bpt->val = evaluate_expression (bpt->exp); - release_value (bpt->val); - } -} - -/* ARGSUSED */ -static void -enable_command (args, from_tty) - char *args; - int from_tty; -{ - struct breakpoint *bpt; - if (args == 0) - ALL_BREAKPOINTS (bpt) - enable_breakpoint (bpt); - else - map_breakpoint_numbers (args, enable_breakpoint); -} - -static void -disable_breakpoint (bpt) - struct breakpoint *bpt; -{ - bpt->enable = disabled; - - if (xgdb_verbose && bpt->number >= 0) - printf ("breakpoint #%d disabled\n", bpt->number); - - check_duplicates (bpt->address); -} - -/* ARGSUSED */ -static void -disable_command (args, from_tty) - char *args; - int from_tty; -{ - register struct breakpoint *bpt; - if (args == 0) - ALL_BREAKPOINTS (bpt) - disable_breakpoint (bpt); - else - map_breakpoint_numbers (args, disable_breakpoint); -} - -static void -enable_once_breakpoint (bpt) - struct breakpoint *bpt; -{ - bpt->enable = temporary; - - check_duplicates (bpt->address); -} - -/* ARGSUSED */ -static void -enable_once_command (args, from_tty) - char *args; - int from_tty; -{ - map_breakpoint_numbers (args, enable_once_breakpoint); -} - -static void -enable_delete_breakpoint (bpt) - struct breakpoint *bpt; -{ - bpt->enable = delete; - - check_duplicates (bpt->address); -} - -/* ARGSUSED */ -static void -enable_delete_command (args, from_tty) - char *args; - int from_tty; -{ - map_breakpoint_numbers (args, enable_delete_breakpoint); -} - -/* - * Use default_breakpoint_'s, or nothing if they aren't valid. - */ -struct symtabs_and_lines -decode_line_spec_1 (string, funfirstline) - char *string; - int funfirstline; -{ - struct symtabs_and_lines sals; - if (string == 0) - error ("Empty line specification."); - if (default_breakpoint_valid) - sals = decode_line_1 (&string, funfirstline, - default_breakpoint_symtab, default_breakpoint_line); - else - sals = decode_line_1 (&string, funfirstline, (struct symtab *)NULL, 0); - if (*string) - error ("Junk at end of line specification: %s", string); - return sals; -} - - -/* Chain containing all defined enable commands. */ - -extern struct cmd_list_element - *enablelist, *disablelist, - *deletelist, *enablebreaklist; - -extern struct cmd_list_element *cmdlist; - -void -_initialize_breakpoint () -{ - breakpoint_chain = 0; - /* Don't bother to call set_breakpoint_count. $bpnum isn't useful - before a breakpoint is set. */ - breakpoint_count = 0; - - add_com ("ignore", class_breakpoint, ignore_command, - "Set ignore-count of breakpoint number N to COUNT."); - - add_com ("commands", class_breakpoint, commands_command, - "Set commands to be executed when a breakpoint is hit.\n\ -Give breakpoint number as argument after \"commands\".\n\ -With no argument, the targeted breakpoint is the last one set.\n\ -The commands themselves follow starting on the next line.\n\ -Type a line containing \"end\" to indicate the end of them.\n\ -Give \"silent\" as the first line to make the breakpoint silent;\n\ -then no output is printed when it is hit, except what the commands print."); - - add_com ("condition", class_breakpoint, condition_command, - "Specify breakpoint number N to break only if COND is true.\n\ -N is an integer; COND is an expression to be evaluated whenever\n\ -breakpoint N is reached. "); - - add_com ("tbreak", class_breakpoint, tbreak_command, - "Set a temporary breakpoint. Args like \"break\" command.\n\ -Like \"break\" except the breakpoint is only enabled temporarily,\n\ -so it will be disabled when hit. Equivalent to \"break\" followed\n\ -by using \"enable once\" on the breakpoint number."); - - add_prefix_cmd ("enable", class_breakpoint, enable_command, - "Enable some breakpoints.\n\ -Give breakpoint numbers (separated by spaces) as arguments.\n\ -With no subcommand, breakpoints are enabled until you command otherwise.\n\ -This is used to cancel the effect of the \"disable\" command.\n\ -With a subcommand you can enable temporarily.", - &enablelist, "enable ", 1, &cmdlist); - - add_abbrev_prefix_cmd ("breakpoints", class_breakpoint, enable_command, - "Enable some breakpoints.\n\ -Give breakpoint numbers (separated by spaces) as arguments.\n\ -This is used to cancel the effect of the \"disable\" command.\n\ -May be abbreviated to simply \"enable\".\n", - &enablebreaklist, "enable breakpoints ", 1, &enablelist); - - add_cmd ("once", no_class, enable_once_command, - "Enable breakpoints for one hit. Give breakpoint numbers.\n\ -If a breakpoint is hit while enabled in this fashion, it becomes disabled.\n\ -See the \"tbreak\" command which sets a breakpoint and enables it once.", - &enablebreaklist); - - add_cmd ("delete", no_class, enable_delete_command, - "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\ -If a breakpoint is hit while enabled in this fashion, it is deleted.", - &enablebreaklist); - - add_cmd ("delete", no_class, enable_delete_command, - "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\ -If a breakpoint is hit while enabled in this fashion, it is deleted.", - &enablelist); - - add_cmd ("once", no_class, enable_once_command, - "Enable breakpoints for one hit. Give breakpoint numbers.\n\ -If a breakpoint is hit while enabled in this fashion, it becomes disabled.\n\ -See the \"tbreak\" command which sets a breakpoint and enables it once.", - &enablelist); - - add_prefix_cmd ("disable", class_breakpoint, disable_command, - "Disable some breakpoints.\n\ -Arguments are breakpoint numbers with spaces in between.\n\ -To disable all breakpoints, give no argument.\n\ -A disabled breakpoint is not forgotten, but has no effect until reenabled.", - &disablelist, "disable ", 1, &cmdlist); - add_com_alias ("dis", "disable", class_breakpoint, 1); - add_com_alias ("disa", "disable", class_breakpoint, 1); - - add_cmd ("breakpoints", class_alias, disable_command, - "Disable some breakpoints.\n\ -Arguments are breakpoint numbers with spaces in between.\n\ -To disable all breakpoints, give no argument.\n\ -A disabled breakpoint is not forgotten, but has no effect until reenabled.\n\ -This command may be abbreviated \"disable\".", - &disablelist); - - add_prefix_cmd ("delete", class_breakpoint, delete_command, - "Delete some breakpoints or auto-display expressions.\n\ -Arguments are breakpoint numbers with spaces in between.\n\ -To delete all breakpoints, give no argument.\n\ -\n\ -Also a prefix command for deletion of other GDB objects.\n\ -The \"unset\" command is also an alias for \"delete\".", - &deletelist, "delete ", 1, &cmdlist); - add_com_alias ("d", "delete", class_breakpoint, 1); - - add_cmd ("breakpoints", class_alias, delete_command, - "Delete some breakpoints or auto-display expressions.\n\ -Arguments are breakpoint numbers with spaces in between.\n\ -To delete all breakpoints, give no argument.\n\ -This command may be abbreviated \"delete\".", - &deletelist); - - add_com ("clear", class_breakpoint, clear_command, - "Clear breakpoint at specified line or function.\n\ -Argument may be line number, function name, or \"*\" and an address.\n\ -If line number is specified, all breakpoints in that line are cleared.\n\ -If function is specified, breakpoints at beginning of function are cleared.\n\ -If an address is specified, breakpoints at that address are cleared.\n\n\ -With no argument, clears all breakpoints in the line that the selected frame\n\ -is executing in.\n\ -\n\ -See also the \"delete\" command which clears breakpoints by number."); - - add_com ("break", class_breakpoint, break_command, - "Set breakpoint at specified line or function.\n\ -Argument may be line number, function name, or \"*\" and an address.\n\ -If line number is specified, break at start of code for that line.\n\ -If function is specified, break at start of code for that function.\n\ -If an address is specified, break at that exact address.\n\ -With no arg, uses current execution address of selected stack frame.\n\ -This is useful for breaking on return to a stack frame.\n\ -\n\ -Multiple breakpoints at one place are permitted, and useful if conditional.\n\ -\n\ -Do \"help breakpoints\" for info on other commands dealing with breakpoints."); - add_com_alias ("b", "break", class_run, 1); - add_com_alias ("br", "break", class_run, 1); - add_com_alias ("bre", "break", class_run, 1); - add_com_alias ("brea", "break", class_run, 1); - - add_info ("breakpoints", breakpoints_info, - "Status of all breakpoints, or breakpoint number NUMBER.\n\ -Second column is \"y\" for enabled breakpoint, \"n\" for disabled,\n\ -\"o\" for enabled once (disable when hit), \"d\" for enable but delete when hit.\n\ -Then come the address and the file/line number.\n\n\ -Convenience variable \"$_\" and default examine address for \"x\"\n\ -are set to the address of the last breakpoint listed.\n\n\ -Convenience variable \"$bpnum\" contains the number of the last\n\ -breakpoint set."); - - add_com ("catch", class_breakpoint, catch_command, - "Set breakpoints to catch exceptions that are raised.\n\ -Argument may be a single exception to catch, multiple exceptions\n\ -to catch, or the default exception \"default\". If no arguments\n\ -are given, breakpoints are set at all exception handlers catch clauses\n\ -within the current scope.\n\ -\n\ -A condition specified for the catch applies to all breakpoints set\n\ -with this command\n\ -\n\ -Do \"help breakpoints\" for info on other commands dealing with breakpoints."); - - add_com ("watch", class_breakpoint, watch_command, - "Set a watchpoint for an expression.\n\ -A watchpoint stops execution of your program whenever the value of\n\ -an expression changes."); - - add_info ("watchpoints", watchpoints_info, - "Status of all watchpoints, or watchpoint number NUMBER.\n\ -Second column is \"y\" for enabled watchpoints, \"n\" for disabled."); -} diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h deleted file mode 100644 index 00ee8c594df..00000000000 --- a/gdb/breakpoint.h +++ /dev/null @@ -1,129 +0,0 @@ -/* Copyright (C) 1990 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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 1, or (at your option) -any later version. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#if !defined (BREAKPOINT_H) -#define BREAKPOINT_H 1 - -/* This is the maximum number of bytes a breakpoint instruction can take. - Feel free to increase it. It's just used in a few places to size - arrays that should be independent of the target architecture. */ - -#define BREAKPOINT_MAX 10 - -extern void breakpoint_re_set (); -extern void clear_momentary_breakpoints (); -extern void set_momentary_breakpoint (); -extern void set_ignore_count (); -extern void set_default_breakpoint (); - -extern void mark_breakpoints_out (); -extern void breakpoint_auto_delete (); -extern void breakpoint_clear_ignore_counts (); - -/* The following are for displays, which aren't really breakpoints, but - here is as good a place as any for them. */ - -extern void disable_current_display (); -extern void do_displays (); -extern void disable_display (); -extern void clear_displays (); - - -/* The follow stuff is an abstract data type "bpstat" ("breakpoint status"). - This provides the ability to determine whether we have stopped at a - breakpoint, and what we should do about it. */ - -typedef struct bpstat__struct *bpstat; - -/* Interface: */ - -/* Clear a bpstat so that it says we are not at any breakpoint. - Also free any storage that is part of a bpstat. */ -void bpstat_clear(); - -/* Return a copy of a bpstat. Like "bs1 = bs2" but all storage that - is part of the bpstat is copied as well. */ -bpstat bpstat_copy(); - -/* Get a bpstat associated with having just stopped at address *PC - and frame address FRAME_ADDRESS. Update *PC to point at the - breakpoint (if we hit a breakpoint). */ -bpstat bpstat_stop_status (/* CORE_ADDR *pc; FRAME_ADDR frame_address */); - -/* Nonzero if we should print the frame. */ -#define bpstat_should_print(bs) ((bs) != NULL && (bs)->print) - -/* Nonzero if we should stop. */ -#define bpstat_stop(bs) ((bs) != NULL && (bs)->stop) - -/* Nonzero if we hit a momentary breakpoint. */ -#define bpstat_momentary_breakpoint(bs) ((bs) != NULL && (bs)->momentary) - -/* Nonzero if a signal that we got in wait() was due to circumstances - explained by the BS. */ -/* Currently that is true iff we have hit a breakpoint. */ -#define bpstat_explains_signal(bs) ((bs) != NULL) - -/* Nonzero if we should step constantly (e.g. watchpoints on machines - without hardware support). This isn't related to a specific bpstat, - just to things like whether watchpoints are set. */ -int bpstat_should_step (/* void */); - -/* Print a message indicating what happened. Returns nonzero to - say that only the source line should be printed after this (zero - return means print the frame as well as the source line). */ -int bpstat_print (/* bpstat bs */); - -/* Return the breakpoint number of the first breakpoint we are stopped - at. *BSP upon return is a bpstat which points to the remaining - breakpoints stopped at (but which is not guaranteed to be good for - anything but further calls to bpstat_num). - Return 0 if passed a bpstat which does not indicate any breakpoints. */ -int bpstat_num (/* bpstat *bsp; */); - -/* Perform actions associated with having stopped at *BSP. */ -void bpstat_do_actions (/* bpstat bs; */); - -/* Modify BS so that the actions will not be performed. */ -void bpstat_clear_actions (/* bpstat bs; */); - - -/* Implementation: */ -#include "value.h" -struct bpstat__struct -{ - /* Linked list because there can be two breakpoints at the - same place, and a bpstat reflects the fact that both have been hit. */ - bpstat next; - /* Breakpoint that we are at. */ - struct breakpoint *breakpoint_at; - /* Commands left to be done. */ - struct command_line *commands; - /* Old value associated with a watchpoint. */ - value old_val; - /* Nonzero if we should print the frame. Only significant for the first - bpstat in the chain. */ - char print; - /* Nonzero if we should stop. Only significant for the first bpstat in - the chain. */ - char stop; - /* Nonzero if we hit a momentary breakpoint. Only significant for the - first bpstat in the chain. */ - char momentary; -}; -#endif /* breakpoint.h not already included. */ diff --git a/gdb/buildsym.c b/gdb/buildsym.c deleted file mode 100644 index 410417d942e..00000000000 --- a/gdb/buildsym.c +++ /dev/null @@ -1,3097 +0,0 @@ -/* Build symbol tables in GDB's internal format. - Copyright (C) 1986-1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* This module provides subroutines used for creating and adding to - the symbol table. These routines are called from various symbol- - file-reading routines. - - They originated in dbxread.c of gdb-4.2, and were split out to - make xcoffread.c more maintainable by sharing code. */ - -#include "defs.h" -#include "param.h" -#include "obstack.h" -#include "symtab.h" -#include "breakpoint.h" -#include "gdbcore.h" /* for bfd stuff for symfile.h */ -#include "symfile.h" /* Needed for "struct complaint" */ -#include "stab.gnu.h" /* We always use GNU stabs, not native */ -#include -#include -#include - -/* Ask buildsym.h to define the vars it normally declares `extern'. */ -#define EXTERN /**/ -#include "buildsym.h" /* Our own declarations */ -#undef EXTERN - -extern void qsort (); -extern double atof (); - -/* Things we export from outside, and probably shouldn't. FIXME. */ -extern void new_object_header_files (); -extern char *next_symbol_text (); -extern int hashname (); -extern void patch_block_stabs (); /* AIX xcoffread.c */ -extern struct type *builtin_type (); /* AIX xcoffread.c */ - - -static void cleanup_undefined_types (); -static void fix_common_block (); - -static const char vptr_name[] = { '_','v','p','t','r',CPLUS_MARKER,'\0' }; -static const char vb_name[] = { '_','v','b',CPLUS_MARKER,'\0' }; - -/* Define this as 1 if a pcc declaration of a char or short argument - gives the correct address. Otherwise assume pcc gives the - address of the corresponding int, which is not the same on a - big-endian machine. */ - -#ifndef BELIEVE_PCC_PROMOTION -#define BELIEVE_PCC_PROMOTION 0 -#endif - -/* Make a list of forward references which haven't been defined. */ -static struct type **undef_types; -static int undef_types_allocated, undef_types_length; - -/* Initial sizes of data structures. These are realloc'd larger if needed, - and realloc'd down to the size actually used, when completed. */ - -#define INITIAL_CONTEXT_STACK_SIZE 10 -#define INITIAL_TYPE_VECTOR_LENGTH 160 -#define INITIAL_LINE_VECTOR_LENGTH 1000 - -/* Complaints about the symbols we have encountered. */ - -struct complaint innerblock_complaint = - {"inner block not inside outer block in %s", 0, 0}; - -struct complaint blockvector_complaint = - {"block at %x out of order", 0, 0}; - -#if 0 -struct complaint dbx_class_complaint = - {"encountered DBX-style class variable debugging information.\n\ -You seem to have compiled your program with \ -\"g++ -g0\" instead of \"g++ -g\".\n\ -Therefore GDB will not know about your class variables", 0, 0}; -#endif - -struct complaint const_vol_complaint = - {"const/volatile indicator missing (ok if using g++ v1.x), got '%c'", 0, 0}; - -struct complaint error_type_complaint = - {"debug info mismatch between compiler and debugger", 0, 0}; - -struct complaint invalid_member_complaint = - {"invalid (minimal) member type data format at symtab pos %d.", 0, 0}; - -struct complaint range_type_base_complaint = - {"base type %d of range type is not defined", 0, 0}; - -/* Look up a dbx type-number pair. Return the address of the slot - where the type for that number-pair is stored. - The number-pair is in TYPENUMS. - - This can be used for finding the type associated with that pair - or for associating a new type with the pair. */ - -struct type ** -dbx_lookup_type (typenums) - int typenums[2]; -{ - register int filenum = typenums[0], index = typenums[1]; - unsigned old_len; - - if (filenum < 0 || filenum >= n_this_object_header_files) - error ("Invalid symbol data: type number (%d,%d) out of range at symtab pos %d.", - filenum, index, symnum); - - if (filenum == 0) - { - /* Type is defined outside of header files. - Find it in this object file's type vector. */ - if (index >= type_vector_length) - { - old_len = type_vector_length; - if (old_len == 0) { - type_vector_length = INITIAL_TYPE_VECTOR_LENGTH; - type_vector = (struct type **) - malloc (type_vector_length * sizeof (struct type *)); - } - while (index >= type_vector_length) - type_vector_length *= 2; - type_vector = (struct type **) - xrealloc (type_vector, - (type_vector_length * sizeof (struct type *))); - bzero (&type_vector[old_len], - (type_vector_length - old_len) * sizeof (struct type *)); - } - return &type_vector[index]; - } - else - { - register int real_filenum = this_object_header_files[filenum]; - register struct header_file *f; - int f_orig_length; - - if (real_filenum >= n_header_files) - abort (); - - f = &header_files[real_filenum]; - - f_orig_length = f->length; - if (index >= f_orig_length) - { - while (index >= f->length) - f->length *= 2; - f->vector = (struct type **) - xrealloc (f->vector, f->length * sizeof (struct type *)); - bzero (&f->vector[f_orig_length], - (f->length - f_orig_length) * sizeof (struct type *)); - } - return &f->vector[index]; - } -} - -/* Create a type object. Occaisionally used when you need a type - which isn't going to be given a type number. */ - -struct type * -dbx_create_type () -{ - register struct type *type = - (struct type *) obstack_alloc (symbol_obstack, sizeof (struct type)); - - bzero (type, sizeof (struct type)); - TYPE_VPTR_FIELDNO (type) = -1; - TYPE_VPTR_BASETYPE (type) = 0; - return type; -} - -/* Make sure there is a type allocated for type numbers TYPENUMS - and return the type object. - This can create an empty (zeroed) type object. - TYPENUMS may be (-1, -1) to return a new type object that is not - put into the type vector, and so may not be referred to by number. */ - -struct type * -dbx_alloc_type (typenums) - int typenums[2]; -{ - register struct type **type_addr; - register struct type *type; - - if (typenums[0] != -1) - { - type_addr = dbx_lookup_type (typenums); - type = *type_addr; - } - else - { - type_addr = 0; - type = 0; - } - - /* If we are referring to a type not known at all yet, - allocate an empty type for it. - We will fill it in later if we find out how. */ - if (type == 0) - { - type = dbx_create_type (); - if (type_addr) - *type_addr = type; - } - - return type; -} - -/* maintain the lists of symbols and blocks */ - -/* Add a symbol to one of the lists of symbols. */ -void -add_symbol_to_list (symbol, listhead) - struct symbol *symbol; - struct pending **listhead; -{ - /* We keep PENDINGSIZE symbols in each link of the list. - If we don't have a link with room in it, add a new link. */ - if (*listhead == 0 || (*listhead)->nsyms == PENDINGSIZE) - { - register struct pending *link; - if (free_pendings) - { - link = free_pendings; - free_pendings = link->next; - } - else - link = (struct pending *) xmalloc (sizeof (struct pending)); - - link->next = *listhead; - *listhead = link; - link->nsyms = 0; - } - - (*listhead)->symbol[(*listhead)->nsyms++] = symbol; -} - -/* Find a symbol on a pending list. */ -struct symbol * -find_symbol_in_list (list, name, length) - struct pending *list; - char *name; - int length; -{ - int j; - - while (list) { - for (j = list->nsyms; --j >= 0; ) { - char *pp = SYMBOL_NAME (list->symbol[j]); - if (*pp == *name && strncmp (pp, name, length) == 0 && pp[length] == '\0') - return list->symbol[j]; - } - list = list->next; - } - return NULL; -} - -/* At end of reading syms, or in case of quit, - really free as many `struct pending's as we can easily find. */ - -/* ARGSUSED */ -void -really_free_pendings (foo) - int foo; -{ - struct pending *next, *next1; -#if 0 - struct pending_block *bnext, *bnext1; -#endif - - for (next = free_pendings; next; next = next1) - { - next1 = next->next; - free (next); - } - free_pendings = 0; - -#if 0 /* Now we make the links in the symbol_obstack, so don't free them. */ - for (bnext = pending_blocks; bnext; bnext = bnext1) - { - bnext1 = bnext->next; - free (bnext); - } -#endif - pending_blocks = 0; - - for (next = file_symbols; next; next = next1) - { - next1 = next->next; - free (next); - } - file_symbols = 0; - - for (next = global_symbols; next; next = next1) - { - next1 = next->next; - free (next); - } - global_symbols = 0; -} - -/* Take one of the lists of symbols and make a block from it. - Keep the order the symbols have in the list (reversed from the input file). - Put the block on the list of pending blocks. */ - -void -finish_block (symbol, listhead, old_blocks, start, end) - struct symbol *symbol; - struct pending **listhead; - struct pending_block *old_blocks; - CORE_ADDR start, end; -{ - register struct pending *next, *next1; - register struct block *block; - register struct pending_block *pblock; - struct pending_block *opblock; - register int i; - - /* Count the length of the list of symbols. */ - - for (next = *listhead, i = 0; - next; - i += next->nsyms, next = next->next) - /*EMPTY*/; - - block = (struct block *) obstack_alloc (symbol_obstack, - (sizeof (struct block) + ((i - 1) * sizeof (struct symbol *)))); - - /* Copy the symbols into the block. */ - - BLOCK_NSYMS (block) = i; - for (next = *listhead; next; next = next->next) - { - register int j; - for (j = next->nsyms - 1; j >= 0; j--) - BLOCK_SYM (block, --i) = next->symbol[j]; - } - - BLOCK_START (block) = start; - BLOCK_END (block) = end; - BLOCK_SUPERBLOCK (block) = 0; /* Filled in when containing block is made */ - BLOCK_GCC_COMPILED (block) = processing_gcc_compilation; - - /* Put the block in as the value of the symbol that names it. */ - - if (symbol) - { - SYMBOL_BLOCK_VALUE (symbol) = block; - BLOCK_FUNCTION (block) = symbol; - } - else - BLOCK_FUNCTION (block) = 0; - - /* Now "free" the links of the list, and empty the list. */ - - for (next = *listhead; next; next = next1) - { - next1 = next->next; - next->next = free_pendings; - free_pendings = next; - } - *listhead = 0; - - /* Install this block as the superblock - of all blocks made since the start of this scope - that don't have superblocks yet. */ - - opblock = 0; - for (pblock = pending_blocks; pblock != old_blocks; pblock = pblock->next) - { - if (BLOCK_SUPERBLOCK (pblock->block) == 0) { -#if 1 - /* Check to be sure the blocks are nested as we receive them. - If the compiler/assembler/linker work, this just burns a small - amount of time. */ - if (BLOCK_START (pblock->block) < BLOCK_START (block) - || BLOCK_END (pblock->block) > BLOCK_END (block)) { - complain(&innerblock_complaint, symbol? SYMBOL_NAME (symbol): - "(don't know)"); - BLOCK_START (pblock->block) = BLOCK_START (block); - BLOCK_END (pblock->block) = BLOCK_END (block); - } -#endif - BLOCK_SUPERBLOCK (pblock->block) = block; - } - opblock = pblock; - } - - /* Record this block on the list of all blocks in the file. - Put it after opblock, or at the beginning if opblock is 0. - This puts the block in the list after all its subblocks. */ - - /* Allocate in the symbol_obstack to save time. - It wastes a little space. */ - pblock = (struct pending_block *) - obstack_alloc (symbol_obstack, - sizeof (struct pending_block)); - pblock->block = block; - if (opblock) - { - pblock->next = opblock->next; - opblock->next = pblock; - } - else - { - pblock->next = pending_blocks; - pending_blocks = pblock; - } -} - -struct blockvector * -make_blockvector () -{ - register struct pending_block *next; - register struct blockvector *blockvector; - register int i; - - /* Count the length of the list of blocks. */ - - for (next = pending_blocks, i = 0; next; next = next->next, i++); - - blockvector = (struct blockvector *) - obstack_alloc (symbol_obstack, - (sizeof (struct blockvector) - + (i - 1) * sizeof (struct block *))); - - /* Copy the blocks into the blockvector. - This is done in reverse order, which happens to put - the blocks into the proper order (ascending starting address). - finish_block has hair to insert each block into the list - after its subblocks in order to make sure this is true. */ - - BLOCKVECTOR_NBLOCKS (blockvector) = i; - for (next = pending_blocks; next; next = next->next) { - BLOCKVECTOR_BLOCK (blockvector, --i) = next->block; - } - -#if 0 /* Now we make the links in the obstack, so don't free them. */ - /* Now free the links of the list, and empty the list. */ - - for (next = pending_blocks; next; next = next1) - { - next1 = next->next; - free (next); - } -#endif - pending_blocks = 0; - -#if 1 /* FIXME, shut this off after a while to speed up symbol reading. */ - /* Some compilers output blocks in the wrong order, but we depend - on their being in the right order so we can binary search. - Check the order and moan about it. FIXME. */ - if (BLOCKVECTOR_NBLOCKS (blockvector) > 1) - for (i = 1; i < BLOCKVECTOR_NBLOCKS (blockvector); i++) { - if (BLOCK_START(BLOCKVECTOR_BLOCK (blockvector, i-1)) - > BLOCK_START(BLOCKVECTOR_BLOCK (blockvector, i))) { - complain (&blockvector_complaint, - BLOCK_START(BLOCKVECTOR_BLOCK (blockvector, i))); - } - } -#endif - - return blockvector; -} - -/* Start recording information about source code that came from an included - (or otherwise merged-in) source file with a different name. */ - -void -start_subfile (name, dirname) - char *name; - char *dirname; -{ - register struct subfile *subfile; - - /* See if this subfile is already known as a subfile of the - current main source file. */ - - for (subfile = subfiles; subfile; subfile = subfile->next) - { - if (!strcmp (subfile->name, name)) - { - current_subfile = subfile; - return; - } - } - - /* This subfile is not known. Add an entry for it. - Make an entry for this subfile in the list of all subfiles - of the current main source file. */ - - subfile = (struct subfile *) xmalloc (sizeof (struct subfile)); - subfile->next = subfiles; - subfiles = subfile; - current_subfile = subfile; - - /* Save its name and compilation directory name */ - subfile->name = obsavestring (name, strlen (name)); - if (dirname == NULL) - subfile->dirname = NULL; - else - subfile->dirname = obsavestring (dirname, strlen (dirname)); - - /* Initialize line-number recording for this subfile. */ - subfile->line_vector = 0; -} - -/* Handle the N_BINCL and N_EINCL symbol types - that act like N_SOL for switching source files - (different subfiles, as we call them) within one object file, - but using a stack rather than in an arbitrary order. */ - -void -push_subfile () -{ - register struct subfile_stack *tem - = (struct subfile_stack *) xmalloc (sizeof (struct subfile_stack)); - - tem->next = subfile_stack; - subfile_stack = tem; - if (current_subfile == 0 || current_subfile->name == 0) - abort (); - tem->name = current_subfile->name; - tem->prev_index = header_file_prev_index; -} - -char * -pop_subfile () -{ - register char *name; - register struct subfile_stack *link = subfile_stack; - - if (link == 0) - abort (); - - name = link->name; - subfile_stack = link->next; - header_file_prev_index = link->prev_index; - free (link); - - return name; -} - -/* Manage the vector of line numbers for each subfile. */ - -void -record_line (subfile, line, pc) - register struct subfile *subfile; - int line; - CORE_ADDR pc; -{ - struct linetable_entry *e; - /* Ignore the dummy line number in libg.o */ - - if (line == 0xffff) - return; - - /* Make sure line vector exists and is big enough. */ - if (!subfile->line_vector) { - subfile->line_vector_length = INITIAL_LINE_VECTOR_LENGTH; - subfile->line_vector = (struct linetable *) - xmalloc (sizeof (struct linetable) - + subfile->line_vector_length * sizeof (struct linetable_entry)); - subfile->line_vector->nitems = 0; - } - - if (subfile->line_vector->nitems + 1 >= subfile->line_vector_length) - { - subfile->line_vector_length *= 2; - subfile->line_vector = (struct linetable *) - xrealloc (subfile->line_vector, (sizeof (struct linetable) - + subfile->line_vector_length * sizeof (struct linetable_entry))); - } - - e = subfile->line_vector->item + subfile->line_vector->nitems++; - e->line = line; e->pc = pc; -} - - -/* Needed in order to sort line tables from IBM xcoff files. Sigh! */ - -/* static */ -int -compare_line_numbers (ln1, ln2) - struct linetable_entry *ln1, *ln2; -{ - return ln1->line - ln2->line; -} - -/* Start a new symtab for a new source file. - This is called when a dbx symbol of type N_SO is seen; - it indicates the start of data for one original source file. */ - -void -start_symtab (name, dirname, start_addr) - char *name; - char *dirname; - CORE_ADDR start_addr; -{ - - last_source_file = name; - last_source_start_addr = start_addr; - file_symbols = 0; - global_symbols = 0; - global_stabs = 0; /* AIX COFF */ - file_stabs = 0; /* AIX COFF */ - within_function = 0; - - /* Context stack is initially empty. Allocate first one with room for - 10 levels; reuse it forever afterward. */ - if (context_stack == 0) { - context_stack_size = INITIAL_CONTEXT_STACK_SIZE; - context_stack = (struct context_stack *) - xmalloc (context_stack_size * sizeof (struct context_stack)); - } - context_stack_depth = 0; - - new_object_header_files (); - - type_vector_length = 0; - type_vector = (struct type **) 0; - - /* Initialize the list of sub source files with one entry - for this file (the top-level source file). */ - - subfiles = 0; - current_subfile = 0; - start_subfile (name, dirname); -} - -/* Finish the symbol definitions for one main source file, - close off all the lexical contexts for that file - (creating struct block's for them), then make the struct symtab - for that file and put it in the list of all such. - - END_ADDR is the address of the end of the file's text. */ - -struct symtab * -end_symtab (end_addr, sort_pending, sort_linevec, objfile) - CORE_ADDR end_addr; - int sort_pending; - int sort_linevec; - struct objfile *objfile; -{ - register struct symtab *symtab; - register struct blockvector *blockvector; - register struct subfile *subfile; - struct subfile *nextsub; - - /* Finish the lexical context of the last function in the file; - pop the context stack. */ - - if (context_stack_depth > 0) - { - register struct context_stack *cstk; - context_stack_depth--; - cstk = &context_stack[context_stack_depth]; - /* Make a block for the local symbols within. */ - finish_block (cstk->name, &local_symbols, cstk->old_blocks, - cstk->start_addr, end_addr); - - /* Debug: if context stack still has something in it, we are in - trouble. */ - if (context_stack_depth > 0) - abort (); - } - - /* It is unfortunate that in aixcoff, pending blocks might not be ordered - in this stage. Especially, blocks for static functions will show up at - the end. We need to sort them, so tools like `find_pc_function' and - `find_pc_block' can work reliably. */ - if (sort_pending && pending_blocks) { - /* FIXME! Remove this horrid bubble sort and use qsort!!! */ - int swapped; - do { - struct pending_block *pb, *pbnext; - - pb = pending_blocks, pbnext = pb->next; - swapped = 0; - - while ( pbnext ) { - - /* swap blocks if unordered! */ - - if (BLOCK_START(pb->block) < BLOCK_START(pbnext->block)) { - struct block *tmp = pb->block; - pb->block = pbnext->block; - pbnext->block = tmp; - swapped = 1; - } - pb = pbnext; - pbnext = pbnext->next; - } - } while (swapped); - } - - /* Cleanup any undefined types that have been left hanging around - (this needs to be done before the finish_blocks so that - file_symbols is still good). */ - cleanup_undefined_types (); - - /* Hooks for xcoffread.c */ - if (file_stabs) { - patch_block_stabs (file_symbols, file_stabs); - free (file_stabs); - file_stabs = 0; - } - - if (global_stabs) { - patch_block_stabs (global_symbols, global_stabs); - free (global_stabs); - global_stabs = 0; - } - - if (pending_blocks == 0 - && file_symbols == 0 - && global_symbols == 0) { - /* Ignore symtabs that have no functions with real debugging info */ - blockvector = NULL; - } else { - /* Define the STATIC_BLOCK and GLOBAL_BLOCK, and build the blockvector. */ - finish_block (0, &file_symbols, 0, last_source_start_addr, end_addr); - finish_block (0, &global_symbols, 0, last_source_start_addr, end_addr); - blockvector = make_blockvector (); - } - - /* Now create the symtab objects proper, one for each subfile. */ - /* (The main file is the last one on the chain.) */ - - for (subfile = subfiles; subfile; subfile = nextsub) - { - /* If we have blocks of symbols, make a symtab. - Otherwise, just ignore this file and any line number info in it. */ - symtab = 0; - if (blockvector) { - if (subfile->line_vector) { - /* First, shrink the linetable to make more memory. */ - subfile->line_vector = (struct linetable *) - xrealloc (subfile->line_vector, (sizeof (struct linetable) - + subfile->line_vector->nitems * sizeof (struct linetable_entry))); - - if (sort_linevec) - qsort (subfile->line_vector->item, subfile->line_vector->nitems, - sizeof (struct linetable_entry), compare_line_numbers); - } - - /* Now, allocate a symbol table. */ - symtab = allocate_symtab (subfile->name, objfile); - - /* Fill in its components. */ - symtab->blockvector = blockvector; - symtab->linetable = subfile->line_vector; - symtab->dirname = subfile->dirname; - symtab->free_code = free_linetable; - symtab->free_ptr = 0; - - /* Link the new symtab into the list of such. */ - symtab->next = symtab_list; - symtab_list = symtab; - } else { - /* No blocks for this file. Delete any line number info we have - for it. */ - if (subfile->line_vector) - free (subfile->line_vector); - } - - nextsub = subfile->next; - free (subfile); - } - - if (type_vector) - free ((char *) type_vector); - type_vector = 0; - type_vector_length = 0; - - last_source_file = 0; - current_subfile = 0; - - return symtab; -} - - -/* Push a context block. Args are an identifying nesting level (checkable - when you pop it), and the starting PC address of this context. */ - -struct context_stack * -push_context (desc, valu) - int desc; - CORE_ADDR valu; -{ - register struct context_stack *new; - - if (context_stack_depth == context_stack_size) - { - context_stack_size *= 2; - context_stack = (struct context_stack *) - xrealloc (context_stack, - (context_stack_size - * sizeof (struct context_stack))); - } - - new = &context_stack[context_stack_depth++]; - new->depth = desc; - new->locals = local_symbols; - new->old_blocks = pending_blocks; - new->start_addr = valu; - new->name = 0; - - local_symbols = 0; - - return new; -} - -/* Initialize anything that needs initializing when starting to read - a fresh piece of a symbol file, e.g. reading in the stuff corresponding - to a psymtab. */ - -void -buildsym_init () -{ - free_pendings = 0; - file_symbols = 0; - global_symbols = 0; - pending_blocks = 0; -} - -/* Initialize anything that needs initializing when a completely new - symbol file is specified (not just adding some symbols from another - file, e.g. a shared library). */ - -void -buildsym_new_init () -{ - /* Empty the hash table of global syms looking for values. */ - bzero (global_sym_chain, sizeof global_sym_chain); - - buildsym_init (); -} - -/* Scan through all of the global symbols defined in the object file, - assigning values to the debugging symbols that need to be assigned - to. Get these symbols from the misc function list. */ - -void -scan_file_globals () -{ - int hash; - int mf; - - for (mf = 0; mf < misc_function_count; mf++) - { - char *namestring = misc_function_vector[mf].name; - struct symbol *sym, *prev; - - QUIT; - - prev = (struct symbol *) 0; - - /* Get the hash index and check all the symbols - under that hash index. */ - - hash = hashname (namestring); - - for (sym = global_sym_chain[hash]; sym;) - { - if (*namestring == SYMBOL_NAME (sym)[0] - && !strcmp(namestring + 1, SYMBOL_NAME (sym) + 1)) - { - /* Splice this symbol out of the hash chain and - assign the value we have to it. */ - if (prev) - SYMBOL_VALUE_CHAIN (prev) = SYMBOL_VALUE_CHAIN (sym); - else - global_sym_chain[hash] = SYMBOL_VALUE_CHAIN (sym); - - /* Check to see whether we need to fix up a common block. */ - /* Note: this code might be executed several times for - the same symbol if there are multiple references. */ - if (SYMBOL_CLASS (sym) == LOC_BLOCK) - fix_common_block (sym, misc_function_vector[mf].address); - else - SYMBOL_VALUE_ADDRESS (sym) = misc_function_vector[mf].address; - - if (prev) - sym = SYMBOL_VALUE_CHAIN (prev); - else - sym = global_sym_chain[hash]; - } - else - { - prev = sym; - sym = SYMBOL_VALUE_CHAIN (sym); - } - } - } -} - - -/* Read a number by which a type is referred to in dbx data, - or perhaps read a pair (FILENUM, TYPENUM) in parentheses. - Just a single number N is equivalent to (0,N). - Return the two numbers by storing them in the vector TYPENUMS. - TYPENUMS will then be used as an argument to dbx_lookup_type. */ - -void -read_type_number (pp, typenums) - register char **pp; - register int *typenums; -{ - if (**pp == '(') - { - (*pp)++; - typenums[0] = read_number (pp, ','); - typenums[1] = read_number (pp, ')'); - } - else - { - typenums[0] = 0; - typenums[1] = read_number (pp, 0); - } -} - -/* To handle GNU C++ typename abbreviation, we need to be able to - fill in a type's name as soon as space for that type is allocated. - `type_synonym_name' is the name of the type being allocated. - It is cleared as soon as it is used (lest all allocated types - get this name). */ -static char *type_synonym_name; - -/* ARGSUSED */ -struct symbol * -define_symbol (valu, string, desc, type) - unsigned int valu; - char *string; - int desc; - int type; -{ - register struct symbol *sym; - char *p = (char *) strchr (string, ':'); - int deftype; - int synonym = 0; - register int i; - - /* Ignore syms with empty names. */ - if (string[0] == 0) - return 0; - - /* Ignore old-style symbols from cc -go */ - if (p == 0) - return 0; - - sym = (struct symbol *)obstack_alloc (symbol_obstack, sizeof (struct symbol)); - - if (processing_gcc_compilation) { - /* GCC 2.x puts the line number in desc. SunOS apparently puts in the - number of bytes occupied by a type or object, which we ignore. */ - SYMBOL_LINE(sym) = desc; - } else { - SYMBOL_LINE(sym) = 0; /* unknown */ - } - - if (string[0] == CPLUS_MARKER) - { - /* Special GNU C++ names. */ - switch (string[1]) - { - case 't': - SYMBOL_NAME (sym) = "this"; - break; - case 'v': /* $vtbl_ptr_type */ - /* Was: SYMBOL_NAME (sym) = "vptr"; */ - goto normal; - case 'e': - SYMBOL_NAME (sym) = "eh_throw"; - break; - - case '_': - /* This was an anonymous type that was never fixed up. */ - goto normal; - - default: - abort (); - } - } - else - { - normal: - SYMBOL_NAME (sym) - = (char *) obstack_alloc (symbol_obstack, ((p - string) + 1)); - /* Open-coded bcopy--saves function call time. */ - { - register char *p1 = string; - register char *p2 = SYMBOL_NAME (sym); - while (p1 != p) - *p2++ = *p1++; - *p2++ = '\0'; - } - } - p++; - /* Determine the type of name being defined. */ - /* The Acorn RISC machine's compiler can put out locals that don't - start with "234=" or "(3,4)=", so assume anything other than the - deftypes we know how to handle is a local. */ - /* (Peter Watkins @ Computervision) - Handle Sun-style local fortran array types 'ar...' . - (gnu@cygnus.com) -- this strchr() handles them properly? - (tiemann@cygnus.com) -- 'C' is for catch. */ - if (!strchr ("cfFGpPrStTvVXC", *p)) - deftype = 'l'; - else - deftype = *p++; - - /* c is a special case, not followed by a type-number. - SYMBOL:c=iVALUE for an integer constant symbol. - SYMBOL:c=rVALUE for a floating constant symbol. - SYMBOL:c=eTYPE,INTVALUE for an enum constant symbol. - e.g. "b:c=e6,0" for "const b = blob1" - (where type 6 is defined by "blobs:t6=eblob1:0,blob2:1,;"). */ - if (deftype == 'c') - { - if (*p++ != '=') - error ("Invalid symbol data at symtab pos %d.", symnum); - switch (*p++) - { - case 'r': - { - double d = atof (p); - char *dbl_valu; - - SYMBOL_TYPE (sym) = builtin_type_double; - dbl_valu = - (char *) obstack_alloc (symbol_obstack, sizeof (double)); - bcopy (&d, dbl_valu, sizeof (double)); - SWAP_TARGET_AND_HOST (dbl_valu, sizeof (double)); - SYMBOL_VALUE_BYTES (sym) = dbl_valu; - SYMBOL_CLASS (sym) = LOC_CONST_BYTES; - } - break; - case 'i': - { - SYMBOL_TYPE (sym) = builtin_type_int; - SYMBOL_VALUE (sym) = atoi (p); - SYMBOL_CLASS (sym) = LOC_CONST; - } - break; - case 'e': - /* SYMBOL:c=eTYPE,INTVALUE for an enum constant symbol. - e.g. "b:c=e6,0" for "const b = blob1" - (where type 6 is defined by "blobs:t6=eblob1:0,blob2:1,;"). */ - { - int typenums[2]; - - read_type_number (&p, typenums); - if (*p++ != ',') - error ("Invalid symbol data: no comma in enum const symbol"); - - SYMBOL_TYPE (sym) = *dbx_lookup_type (typenums); - SYMBOL_VALUE (sym) = atoi (p); - SYMBOL_CLASS (sym) = LOC_CONST; - } - break; - default: - error ("Invalid symbol data at symtab pos %d.", symnum); - } - SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; - add_symbol_to_list (sym, &file_symbols); - return sym; - } - - /* Now usually comes a number that says which data type, - and possibly more stuff to define the type - (all of which is handled by read_type) */ - - if (deftype == 'p' && *p == 'F') - /* pF is a two-letter code that means a function parameter in Fortran. - The type-number specifies the type of the return value. - Translate it into a pointer-to-function type. */ - { - p++; - SYMBOL_TYPE (sym) - = lookup_pointer_type (lookup_function_type (read_type (&p))); - } - else - { - struct type *type_read; - synonym = *p == 't'; - - if (synonym) - { - p += 1; - type_synonym_name = obsavestring (SYMBOL_NAME (sym), - strlen (SYMBOL_NAME (sym))); - } - - type_read = read_type (&p); - - if ((deftype == 'F' || deftype == 'f') - && TYPE_CODE (type_read) != TYPE_CODE_FUNC) - { -#if 0 -/* This code doesn't work -- it needs to realloc and can't. */ - struct type *new = (struct type *) - obstack_alloc (symbol_obstack, sizeof (struct type)); - - /* Generate a template for the type of this function. The - types of the arguments will be added as we read the symbol - table. */ - *new = *lookup_function_type (type_read); - SYMBOL_TYPE(sym) = new; - in_function_type = new; -#else - SYMBOL_TYPE (sym) = lookup_function_type (type_read); -#endif - } - else - SYMBOL_TYPE (sym) = type_read; - } - - switch (deftype) - { - case 'C': - /* The name of a caught exception. */ - SYMBOL_CLASS (sym) = LOC_LABEL; - SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; - SYMBOL_VALUE_ADDRESS (sym) = valu; - add_symbol_to_list (sym, &local_symbols); - break; - - case 'f': - SYMBOL_CLASS (sym) = LOC_BLOCK; - SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; - add_symbol_to_list (sym, &file_symbols); - break; - - case 'F': - SYMBOL_CLASS (sym) = LOC_BLOCK; - SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; - add_symbol_to_list (sym, &global_symbols); - break; - - case 'G': - /* For a class G (global) symbol, it appears that the - value is not correct. It is necessary to search for the - corresponding linker definition to find the value. - These definitions appear at the end of the namelist. */ - i = hashname (SYMBOL_NAME (sym)); - SYMBOL_VALUE_CHAIN (sym) = global_sym_chain[i]; - global_sym_chain[i] = sym; - SYMBOL_CLASS (sym) = LOC_STATIC; - SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; - add_symbol_to_list (sym, &global_symbols); - break; - - /* This case is faked by a conditional above, - when there is no code letter in the dbx data. - Dbx data never actually contains 'l'. */ - case 'l': - SYMBOL_CLASS (sym) = LOC_LOCAL; - SYMBOL_VALUE (sym) = valu; - SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; - add_symbol_to_list (sym, &local_symbols); - break; - - case 'p': - /* Normally this is a parameter, a LOC_ARG. On the i960, it - can also be a LOC_LOCAL_ARG depending on symbol type. */ -#ifndef DBX_PARM_SYMBOL_CLASS -#define DBX_PARM_SYMBOL_CLASS(type) LOC_ARG -#endif - SYMBOL_CLASS (sym) = DBX_PARM_SYMBOL_CLASS (type); - SYMBOL_VALUE (sym) = valu; - SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; -#if 0 - /* This doesn't work yet. */ - add_param_to_type (&in_function_type, sym); -#endif - add_symbol_to_list (sym, &local_symbols); - - /* If it's gcc-compiled, if it says `short', believe it. */ - if (processing_gcc_compilation || BELIEVE_PCC_PROMOTION) - break; - -#if defined(BELIEVE_PCC_PROMOTION_TYPE) - /* This macro is defined on machines (e.g. sparc) where - we should believe the type of a PCC 'short' argument, - but shouldn't believe the address (the address is - the address of the corresponding int). Note that - this is only different from the BELIEVE_PCC_PROMOTION - case on big-endian machines. - - My guess is that this correction, as opposed to changing - the parameter to an 'int' (as done below, for PCC - on most machines), is the right thing to do - on all machines, but I don't want to risk breaking - something that already works. On most PCC machines, - the sparc problem doesn't come up because the calling - function has to zero the top bytes (not knowing whether - the called function wants an int or a short), so there - is no practical difference between an int and a short - (except perhaps what happens when the GDB user types - "print short_arg = 0x10000;"). - - Hacked for SunOS 4.1 by gnu@cygnus.com. In 4.1, the compiler - actually produces the correct address (we don't need to fix it - up). I made this code adapt so that it will offset the symbol - if it was pointing at an int-aligned location and not - otherwise. This way you can use the same gdb for 4.0.x and - 4.1 systems. */ - - if (0 == SYMBOL_VALUE (sym) % sizeof (int)) - { - if (SYMBOL_TYPE (sym) == builtin_type_char - || SYMBOL_TYPE (sym) == builtin_type_unsigned_char) - SYMBOL_VALUE (sym) += 3; - else if (SYMBOL_TYPE (sym) == builtin_type_short - || SYMBOL_TYPE (sym) == builtin_type_unsigned_short) - SYMBOL_VALUE (sym) += 2; - } - break; - -#else /* no BELIEVE_PCC_PROMOTION_TYPE. */ - - /* If PCC says a parameter is a short or a char, - it is really an int. */ - if (SYMBOL_TYPE (sym) == builtin_type_char - || SYMBOL_TYPE (sym) == builtin_type_short) - SYMBOL_TYPE (sym) = builtin_type_int; - else if (SYMBOL_TYPE (sym) == builtin_type_unsigned_char - || SYMBOL_TYPE (sym) == builtin_type_unsigned_short) - SYMBOL_TYPE (sym) = builtin_type_unsigned_int; - break; - -#endif /* no BELIEVE_PCC_PROMOTION_TYPE. */ - - case 'P': - SYMBOL_CLASS (sym) = LOC_REGPARM; - SYMBOL_VALUE (sym) = STAB_REG_TO_REGNUM (valu); - SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; - add_symbol_to_list (sym, &local_symbols); - break; - - case 'r': - SYMBOL_CLASS (sym) = LOC_REGISTER; - SYMBOL_VALUE (sym) = STAB_REG_TO_REGNUM (valu); - SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; - add_symbol_to_list (sym, &local_symbols); - break; - - case 'S': - /* Static symbol at top level of file */ - SYMBOL_CLASS (sym) = LOC_STATIC; - SYMBOL_VALUE_ADDRESS (sym) = valu; - SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; - add_symbol_to_list (sym, &file_symbols); - break; - - case 't': - SYMBOL_CLASS (sym) = LOC_TYPEDEF; - SYMBOL_VALUE (sym) = valu; - SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; - if (TYPE_NAME (SYMBOL_TYPE (sym)) == 0 - && (TYPE_FLAGS (SYMBOL_TYPE (sym)) & TYPE_FLAG_PERM) == 0) - TYPE_NAME (SYMBOL_TYPE (sym)) = - obsavestring (SYMBOL_NAME (sym), - strlen (SYMBOL_NAME (sym))); - /* C++ vagaries: we may have a type which is derived from - a base type which did not have its name defined when the - derived class was output. We fill in the derived class's - base part member's name here in that case. */ - else if ((TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_STRUCT - || TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_UNION) - && TYPE_N_BASECLASSES (SYMBOL_TYPE (sym))) - { - int j; - for (j = TYPE_N_BASECLASSES (SYMBOL_TYPE (sym)) - 1; j >= 0; j--) - if (TYPE_BASECLASS_NAME (SYMBOL_TYPE (sym), j) == 0) - TYPE_BASECLASS_NAME (SYMBOL_TYPE (sym), j) = - type_name_no_tag (TYPE_BASECLASS (SYMBOL_TYPE (sym), j)); - } - - add_symbol_to_list (sym, &file_symbols); - break; - - case 'T': - SYMBOL_CLASS (sym) = LOC_TYPEDEF; - SYMBOL_VALUE (sym) = valu; - SYMBOL_NAMESPACE (sym) = STRUCT_NAMESPACE; - if (TYPE_NAME (SYMBOL_TYPE (sym)) == 0 - && (TYPE_FLAGS (SYMBOL_TYPE (sym)) & TYPE_FLAG_PERM) == 0) - TYPE_NAME (SYMBOL_TYPE (sym)) - = obconcat ("", - (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_ENUM - ? "enum " - : (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_STRUCT - ? "struct " : "union ")), - SYMBOL_NAME (sym)); - add_symbol_to_list (sym, &file_symbols); - - if (synonym) - { - register struct symbol *typedef_sym - = (struct symbol *) obstack_alloc (symbol_obstack, sizeof (struct symbol)); - SYMBOL_NAME (typedef_sym) = SYMBOL_NAME (sym); - SYMBOL_TYPE (typedef_sym) = SYMBOL_TYPE (sym); - - SYMBOL_CLASS (typedef_sym) = LOC_TYPEDEF; - SYMBOL_VALUE (typedef_sym) = valu; - SYMBOL_NAMESPACE (typedef_sym) = VAR_NAMESPACE; - add_symbol_to_list (typedef_sym, &file_symbols); - } - break; - - case 'V': - /* Static symbol of local scope */ - SYMBOL_CLASS (sym) = LOC_STATIC; - SYMBOL_VALUE_ADDRESS (sym) = valu; - SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; - add_symbol_to_list (sym, &local_symbols); - break; - - case 'v': - /* Reference parameter */ - SYMBOL_CLASS (sym) = LOC_REF_ARG; - SYMBOL_VALUE (sym) = valu; - SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; - add_symbol_to_list (sym, &local_symbols); - break; - - case 'X': - /* This is used by Sun FORTRAN for "function result value". - Sun claims ("dbx and dbxtool interfaces", 2nd ed) - that Pascal uses it too, but when I tried it Pascal used - "x:3" (local symbol) instead. */ - SYMBOL_CLASS (sym) = LOC_LOCAL; - SYMBOL_VALUE (sym) = valu; - SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; - add_symbol_to_list (sym, &local_symbols); - break; - - default: - error ("Invalid symbol data: unknown symbol-type code `%c' at symtab pos %d.", deftype, symnum); - } - return sym; -} - -/* What about types defined as forward references inside of a small lexical - scope? */ -/* Add a type to the list of undefined types to be checked through - once this file has been read in. */ -void -add_undefined_type (type) - struct type *type; -{ - if (undef_types_length == undef_types_allocated) - { - undef_types_allocated *= 2; - undef_types = (struct type **) - xrealloc (undef_types, - undef_types_allocated * sizeof (struct type *)); - } - undef_types[undef_types_length++] = type; -} - -/* Add here something to go through each undefined type, see if it's - still undefined, and do a full lookup if so. */ -static void -cleanup_undefined_types () -{ - struct type **type; - - for (type = undef_types; type < undef_types + undef_types_length; type++) - { - /* Reasonable test to see if it's been defined since. */ - if (TYPE_NFIELDS (*type) == 0) - { - struct pending *ppt; - int i; - /* Name of the type, without "struct" or "union" */ - char *typename = TYPE_NAME (*type); - - if (!strncmp (typename, "struct ", 7)) - typename += 7; - if (!strncmp (typename, "union ", 6)) - typename += 6; - - for (ppt = file_symbols; ppt; ppt = ppt->next) - for (i = 0; i < ppt->nsyms; i++) - { - struct symbol *sym = ppt->symbol[i]; - - if (SYMBOL_CLASS (sym) == LOC_TYPEDEF - && SYMBOL_NAMESPACE (sym) == STRUCT_NAMESPACE - && (TYPE_CODE (SYMBOL_TYPE (sym)) == - TYPE_CODE (*type)) - && !strcmp (SYMBOL_NAME (sym), typename)) - bcopy (SYMBOL_TYPE (sym), *type, sizeof (struct type)); - } - } - else - /* It has been defined; don't mark it as a stub. */ - TYPE_FLAGS (*type) &= ~TYPE_FLAG_STUB; - } - undef_types_length = 0; -} - -/* Skip rest of this symbol and return an error type. - - General notes on error recovery: error_type always skips to the - end of the symbol (modulo cretinous dbx symbol name continuation). - Thus code like this: - - if (*(*pp)++ != ';') - return error_type (pp); - - is wrong because if *pp starts out pointing at '\0' (typically as the - result of an earlier error), it will be incremented to point to the - start of the next symbol, which might produce strange results, at least - if you run off the end of the string table. Instead use - - if (**pp != ';') - return error_type (pp); - ++*pp; - - or - - if (**pp != ';') - foo = error_type (pp); - else - ++*pp; - - And in case it isn't obvious, the point of all this hair is so the compiler - can define new types and new syntaxes, and old versions of the - debugger will be able to read the new symbol tables. */ - -struct type * -error_type (pp) - char **pp; -{ - complain (&error_type_complaint, 0); - while (1) - { - /* Skip to end of symbol. */ - while (**pp != '\0') - (*pp)++; - - /* Check for and handle cretinous dbx symbol name continuation! */ - if ((*pp)[-1] == '\\') - *pp = next_symbol_text (); - else - break; - } - return builtin_type_error; -} - -/* Read a dbx type reference or definition; - return the type that is meant. - This can be just a number, in which case it references - a type already defined and placed in type_vector. - Or the number can be followed by an =, in which case - it means to define a new type according to the text that - follows the =. */ - -struct type * -read_type (pp) - register char **pp; -{ - register struct type *type = 0; - struct type *type1; - int typenums[2]; - int xtypenums[2]; - - /* Read type number if present. The type number may be omitted. - for instance in a two-dimensional array declared with type - "ar1;1;10;ar1;1;10;4". */ - if ((**pp >= '0' && **pp <= '9') - || **pp == '(') - { - read_type_number (pp, typenums); - - /* Type is not being defined here. Either it already exists, - or this is a forward reference to it. dbx_alloc_type handles - both cases. */ - if (**pp != '=') - return dbx_alloc_type (typenums); - - /* Type is being defined here. */ -#if 0 /* Callers aren't prepared for a NULL result! FIXME -- metin! */ - { - struct type *tt; - - /* if such a type already exists, this is an unnecessary duplication - of the stab string, which is common in (RS/6000) xlc generated - objects. In that case, simply return NULL and let the caller take - care of it. */ - - tt = *dbx_lookup_type (typenums); - if (tt && tt->length && tt->code) - return NULL; - } -#endif - - *pp += 2; - } - else - { - /* 'typenums=' not present, type is anonymous. Read and return - the definition, but don't put it in the type vector. */ - typenums[0] = typenums[1] = -1; - *pp += 1; - } - - switch ((*pp)[-1]) - { - case 'x': - { - enum type_code code; - - /* Used to index through file_symbols. */ - struct pending *ppt; - int i; - - /* Name including "struct", etc. */ - char *type_name; - - /* Name without "struct", etc. */ - char *type_name_only; - - { - char *prefix; - char *from, *to; - - /* Set the type code according to the following letter. */ - switch ((*pp)[0]) - { - case 's': - code = TYPE_CODE_STRUCT; - prefix = "struct "; - break; - case 'u': - code = TYPE_CODE_UNION; - prefix = "union "; - break; - case 'e': - code = TYPE_CODE_ENUM; - prefix = "enum "; - break; - default: - return error_type (pp); - } - - to = type_name = (char *) - obstack_alloc (symbol_obstack, - (strlen (prefix) + - ((char *) strchr (*pp, ':') - (*pp)) + 1)); - - /* Copy the prefix. */ - from = prefix; - while (*to++ = *from++) - ; - to--; - - type_name_only = to; - - /* Copy the name. */ - from = *pp + 1; - while ((*to++ = *from++) != ':') - ; - *--to = '\0'; - - /* Set the pointer ahead of the name which we just read. */ - *pp = from; - -#if 0 - /* The following hack is clearly wrong, because it doesn't - check whether we are in a baseclass. I tried to reproduce - the case that it is trying to fix, but I couldn't get - g++ to put out a cross reference to a basetype. Perhaps - it doesn't do it anymore. */ - /* Note: for C++, the cross reference may be to a base type which - has not yet been seen. In this case, we skip to the comma, - which will mark the end of the base class name. (The ':' - at the end of the base class name will be skipped as well.) - But sometimes (ie. when the cross ref is the last thing on - the line) there will be no ','. */ - from = (char *) strchr (*pp, ','); - if (from) - *pp = from; -#endif /* 0 */ - } - - /* Now check to see whether the type has already been declared. */ - /* This is necessary at least in the case where the - program says something like - struct foo bar[5]; - The compiler puts out a cross-reference; we better find - set the length of the structure correctly so we can - set the length of the array. */ - for (ppt = file_symbols; ppt; ppt = ppt->next) - for (i = 0; i < ppt->nsyms; i++) - { - struct symbol *sym = ppt->symbol[i]; - - if (SYMBOL_CLASS (sym) == LOC_TYPEDEF - && SYMBOL_NAMESPACE (sym) == STRUCT_NAMESPACE - && (TYPE_CODE (SYMBOL_TYPE (sym)) == code) - && !strcmp (SYMBOL_NAME (sym), type_name_only)) - { - obstack_free (symbol_obstack, type_name); - type = SYMBOL_TYPE (sym); - return type; - } - } - - /* Didn't find the type to which this refers, so we must - be dealing with a forward reference. Allocate a type - structure for it, and keep track of it so we can - fill in the rest of the fields when we get the full - type. */ - type = dbx_alloc_type (typenums); - TYPE_CODE (type) = code; - TYPE_NAME (type) = type_name; - if (code == TYPE_CODE_STRUCT) - { - TYPE_CPLUS_SPECIFIC (type) - = (struct cplus_struct_type *) obstack_alloc (symbol_obstack, sizeof (struct cplus_struct_type)); - bzero (TYPE_CPLUS_SPECIFIC (type), sizeof (struct cplus_struct_type)); - } - - TYPE_FLAGS (type) |= TYPE_FLAG_STUB; - - add_undefined_type (type); - return type; - } - - case '-': /* RS/6000 built-in type */ - (*pp)--; - type = builtin_type (pp); /* (in xcoffread.c) */ - goto after_digits; - - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case '(': - (*pp)--; - read_type_number (pp, xtypenums); - type = *dbx_lookup_type (xtypenums); - /* fall through */ - - after_digits: - if (type == 0) - type = builtin_type_void; - if (typenums[0] != -1) - *dbx_lookup_type (typenums) = type; - break; - - case '*': - type1 = read_type (pp); -/* FIXME -- we should be doing smash_to_XXX types here. */ -#if 0 - /* postponed type decoration should be allowed. */ - if (typenums[1] > 0 && typenums[1] < type_vector_length && - (type = type_vector[typenums[1]])) { - smash_to_pointer_type (type, type1); - break; - } -#endif - type = lookup_pointer_type (type1); - if (typenums[0] != -1) - *dbx_lookup_type (typenums) = type; - break; - - case '@': - { - struct type *domain = read_type (pp); - struct type *memtype; - - if (**pp != ',') - /* Invalid member type data format. */ - return error_type (pp); - ++*pp; - - memtype = read_type (pp); - type = dbx_alloc_type (typenums); - smash_to_member_type (type, domain, memtype); - } - break; - - case '#': - if ((*pp)[0] == '#') - { - /* We'll get the parameter types from the name. */ - struct type *return_type; - - *pp += 1; - return_type = read_type (pp); - if (*(*pp)++ != ';') - complain (&invalid_member_complaint, symnum); - type = allocate_stub_method (return_type); - if (typenums[0] != -1) - *dbx_lookup_type (typenums) = type; - } - else - { - struct type *domain = read_type (pp); - struct type *return_type; - struct type **args; - - if (*(*pp)++ != ',') - error ("invalid member type data format, at symtab pos %d.", - symnum); - - return_type = read_type (pp); - args = read_args (pp, ';'); - type = dbx_alloc_type (typenums); - smash_to_method_type (type, domain, return_type, args); - } - break; - - case '&': - type1 = read_type (pp); - type = lookup_reference_type (type1); - if (typenums[0] != -1) - *dbx_lookup_type (typenums) = type; - break; - - case 'f': - type1 = read_type (pp); - type = lookup_function_type (type1); - if (typenums[0] != -1) - *dbx_lookup_type (typenums) = type; - break; - - case 'r': - type = read_range_type (pp, typenums); - if (typenums[0] != -1) - *dbx_lookup_type (typenums) = type; - break; - - case 'e': - type = dbx_alloc_type (typenums); - type = read_enum_type (pp, type); - *dbx_lookup_type (typenums) = type; - break; - - case 's': - type = dbx_alloc_type (typenums); - TYPE_NAME (type) = type_synonym_name; - type_synonym_name = 0; - type = read_struct_type (pp, type); - break; - - case 'u': - type = dbx_alloc_type (typenums); - TYPE_NAME (type) = type_synonym_name; - type_synonym_name = 0; - type = read_struct_type (pp, type); - TYPE_CODE (type) = TYPE_CODE_UNION; - break; - - case 'a': - if (**pp != 'r') - return error_type (pp); - ++*pp; - - type = dbx_alloc_type (typenums); - type = read_array_type (pp, type); - break; - - default: - --*pp; /* Go back to the symbol in error */ - /* Particularly important if it was \0! */ - return error_type (pp); - } - - if (type == 0) - abort (); - -#if 0 - /* If this is an overriding temporary alteration for a header file's - contents, and this type number is unknown in the global definition, - put this type into the global definition at this type number. */ - if (header_file_prev_index >= 0) - { - register struct type **tp - = explicit_lookup_type (header_file_prev_index, typenums[1]); - if (*tp == 0) - *tp = type; - } -#endif - return type; -} - -/* This page contains subroutines of read_type. */ - -/* Read the description of a structure (or union type) - and return an object describing the type. */ - -struct type * -read_struct_type (pp, type) - char **pp; - register struct type *type; -{ - /* Total number of methods defined in this class. - If the class defines two `f' methods, and one `g' method, - then this will have the value 3. */ - int total_length = 0; - - struct nextfield - { - struct nextfield *next; - int visibility; /* 0=public, 1=protected, 2=public */ - struct field field; - }; - - struct next_fnfield - { - struct next_fnfield *next; - int visibility; /* 0=public, 1=protected, 2=public */ - struct fn_field fn_field; - }; - - struct next_fnfieldlist - { - struct next_fnfieldlist *next; - struct fn_fieldlist fn_fieldlist; - }; - - register struct nextfield *list = 0; - struct nextfield *new; - register char *p; - int nfields = 0; - register int n; - - register struct next_fnfieldlist *mainlist = 0; - int nfn_fields = 0; - - if (TYPE_MAIN_VARIANT (type) == 0) - TYPE_MAIN_VARIANT (type) = type; - - TYPE_CODE (type) = TYPE_CODE_STRUCT; - TYPE_CPLUS_SPECIFIC (type) - = (struct cplus_struct_type *) obstack_alloc (symbol_obstack, sizeof (struct cplus_struct_type)); - bzero (TYPE_CPLUS_SPECIFIC (type), sizeof (struct cplus_struct_type)); - - /* First comes the total size in bytes. */ - - TYPE_LENGTH (type) = read_number (pp, 0); - - /* C++: Now, if the class is a derived class, then the next character - will be a '!', followed by the number of base classes derived from. - Each element in the list contains visibility information, - the offset of this base class in the derived structure, - and then the base type. */ - if (**pp == '!') - { - int i, n_baseclasses, offset; - struct type *baseclass; - int via_public; - - /* Nonzero if it is a virtual baseclass, i.e., - - struct A{}; - struct B{}; - struct C : public B, public virtual A {}; - - B is a baseclass of C; A is a virtual baseclass for C. This is a C++ - 2.0 language feature. */ - int via_virtual; - - *pp += 1; - - n_baseclasses = read_number (pp, ','); - TYPE_FIELD_VIRTUAL_BITS (type) = - (B_TYPE *) obstack_alloc (symbol_obstack, B_BYTES (n_baseclasses)); - B_CLRALL (TYPE_FIELD_VIRTUAL_BITS (type), n_baseclasses); - - for (i = 0; i < n_baseclasses; i++) - { - if (**pp == '\\') - *pp = next_symbol_text (); - - switch (**pp) - { - case '0': - via_virtual = 0; - break; - case '1': - via_virtual = 1; - break; - default: - /* Bad visibility format. */ - return error_type (pp); - } - ++*pp; - - switch (**pp) - { - case '0': - via_public = 0; - break; - case '2': - via_public = 2; - break; - default: - /* Bad visibility format. */ - return error_type (pp); - } - if (via_virtual) - SET_TYPE_FIELD_VIRTUAL (type, i); - ++*pp; - - /* Offset of the portion of the object corresponding to - this baseclass. Always zero in the absence of - multiple inheritance. */ - offset = read_number (pp, ','); - baseclass = read_type (pp); - *pp += 1; /* skip trailing ';' */ - - /* Make this baseclass visible for structure-printing purposes. */ - new = (struct nextfield *) alloca (sizeof (struct nextfield)); - new->next = list; - list = new; - list->visibility = via_public; - list->field.type = baseclass; - list->field.name = type_name_no_tag (baseclass); - list->field.bitpos = offset; - list->field.bitsize = 0; /* this should be an unpacked field! */ - nfields++; - } - TYPE_N_BASECLASSES (type) = n_baseclasses; - } - - /* Now come the fields, as NAME:?TYPENUM,BITPOS,BITSIZE; for each one. - At the end, we see a semicolon instead of a field. - - In C++, this may wind up being NAME:?TYPENUM:PHYSNAME; for - a static field. - - The `?' is a placeholder for one of '/2' (public visibility), - '/1' (protected visibility), '/0' (private visibility), or nothing - (C style symbol table, public visibility). */ - - /* We better set p right now, in case there are no fields at all... */ - p = *pp; - - while (**pp != ';') - { - /* Check for and handle cretinous dbx symbol name continuation! */ - if (**pp == '\\') *pp = next_symbol_text (); - - /* Get space to record the next field's data. */ - new = (struct nextfield *) alloca (sizeof (struct nextfield)); - new->next = list; - list = new; - - /* Get the field name. */ - p = *pp; - if (*p == CPLUS_MARKER) - { - /* Special GNU C++ name. */ - if (*++p == 'v') - { - const char *prefix; - char *name = 0; - struct type *context; - - switch (*++p) - { - case 'f': - prefix = vptr_name; - break; - case 'b': - prefix = vb_name; - break; - default: - error ("invalid abbreviation at symtab pos %d.", symnum); - } - *pp = p + 1; - context = read_type (pp); - name = type_name_no_tag (context); - if (name == 0) - { - error ("type name unknown at symtab pos %d.", symnum); - TYPE_NAME (context) = name; - } - list->field.name = obconcat (prefix, name, ""); - p = ++(*pp); - if (p[-1] != ':') - error ("invalid abbreviation at symtab pos %d.", symnum); - list->field.type = read_type (pp); - (*pp)++; /* Skip the comma. */ - list->field.bitpos = read_number (pp, ';'); - /* This field is unpacked. */ - list->field.bitsize = 0; - } - /* GNU C++ anonymous type. */ - else if (*p == '_') - break; - else - error ("invalid abbreviation at symtab pos %d.", symnum); - - nfields++; - continue; - } - - while (*p != ':') p++; - list->field.name = obsavestring (*pp, p - *pp); - - /* C++: Check to see if we have hit the methods yet. */ - if (p[1] == ':') - break; - - *pp = p + 1; - - /* This means we have a visibility for a field coming. */ - if (**pp == '/') - { - switch (*++*pp) - { - case '0': - list->visibility = 0; /* private */ - *pp += 1; - break; - - case '1': - list->visibility = 1; /* protected */ - *pp += 1; - break; - - case '2': - list->visibility = 2; /* public */ - *pp += 1; - break; - } - } - else /* normal dbx-style format. */ - list->visibility = 2; /* public */ - - list->field.type = read_type (pp); - if (**pp == ':') - { - /* Static class member. */ - list->field.bitpos = (long)-1; - p = ++(*pp); - while (*p != ';') p++; - list->field.bitsize = (long) savestring (*pp, p - *pp); - *pp = p + 1; - nfields++; - continue; - } - else if (**pp != ',') - /* Bad structure-type format. */ - return error_type (pp); - - (*pp)++; /* Skip the comma. */ - list->field.bitpos = read_number (pp, ','); - list->field.bitsize = read_number (pp, ';'); - -#if 0 - /* FIXME-tiemann: Can't the compiler put out something which - lets us distinguish these? (or maybe just not put out anything - for the field). What is the story here? What does the compiler - really do? Also, patch gdb.texinfo for this case; I document - it as a possible problem there. Search for "DBX-style". */ - - /* This is wrong because this is identical to the symbols - produced for GCC 0-size arrays. For example: - typedef union { - int num; - char str[0]; - } foo; - The code which dumped core in such circumstances should be - fixed not to dump core. */ - - /* g++ -g0 can put out bitpos & bitsize zero for a static - field. This does not give us any way of getting its - class, so we can't know its name. But we can just - ignore the field so we don't dump core and other nasty - stuff. */ - if (list->field.bitpos == 0 - && list->field.bitsize == 0) - { - complain (&dbx_class_complaint, 0); - /* Ignore this field. */ - list = list->next; - } - else -#endif /* 0 */ - { - /* Detect an unpacked field and mark it as such. - dbx gives a bit size for all fields. - Note that forward refs cannot be packed, - and treat enums as if they had the width of ints. */ - if (TYPE_CODE (list->field.type) != TYPE_CODE_INT - && TYPE_CODE (list->field.type) != TYPE_CODE_ENUM) - list->field.bitsize = 0; - if ((list->field.bitsize == 8 * TYPE_LENGTH (list->field.type) - || (TYPE_CODE (list->field.type) == TYPE_CODE_ENUM - && (list->field.bitsize - == 8 * TYPE_LENGTH (builtin_type_int)) - ) - ) - && - list->field.bitpos % 8 == 0) - list->field.bitsize = 0; - nfields++; - } - } - - if (p[1] == ':') - /* chill the list of fields: the last entry (at the head) - is a partially constructed entry which we now scrub. */ - list = list->next; - - /* Now create the vector of fields, and record how big it is. - We need this info to record proper virtual function table information - for this class's virtual functions. */ - - TYPE_NFIELDS (type) = nfields; - TYPE_FIELDS (type) = (struct field *) obstack_alloc (symbol_obstack, - sizeof (struct field) * nfields); - - TYPE_FIELD_PRIVATE_BITS (type) = - (B_TYPE *) obstack_alloc (symbol_obstack, B_BYTES (nfields)); - B_CLRALL (TYPE_FIELD_PRIVATE_BITS (type), nfields); - - TYPE_FIELD_PROTECTED_BITS (type) = - (B_TYPE *) obstack_alloc (symbol_obstack, B_BYTES (nfields)); - B_CLRALL (TYPE_FIELD_PROTECTED_BITS (type), nfields); - - /* Copy the saved-up fields into the field vector. */ - - for (n = nfields; list; list = list->next) - { - n -= 1; - TYPE_FIELD (type, n) = list->field; - if (list->visibility == 0) - SET_TYPE_FIELD_PRIVATE (type, n); - else if (list->visibility == 1) - SET_TYPE_FIELD_PROTECTED (type, n); - } - - /* Now come the method fields, as NAME::methods - where each method is of the form TYPENUM,ARGS,...:PHYSNAME; - At the end, we see a semicolon instead of a field. - - For the case of overloaded operators, the format is - OPERATOR::*.methods, where OPERATOR is the string "operator", - `*' holds the place for an operator name (such as `+=') - and `.' marks the end of the operator name. */ - if (p[1] == ':') - { - /* Now, read in the methods. To simplify matters, we - "unread" the name that has been read, so that we can - start from the top. */ - - /* For each list of method lists... */ - do - { - int i; - struct next_fnfield *sublist = 0; - struct type *look_ahead_type = NULL; - int length = 0; - struct next_fnfieldlist *new_mainlist = - (struct next_fnfieldlist *)alloca (sizeof (struct next_fnfieldlist)); - char *main_fn_name; - - p = *pp; - - /* read in the name. */ - while (*p != ':') p++; -#if 0 - if ((*pp)[0] == 'o' && (*pp)[1] == 'p' && (*pp)[2] == CPLUS_MARKER) - { - /* This lets the user type "break operator+". - We could just put in "+" as the name, but that wouldn't - work for "*". */ - /* I don't understand what this is trying to do. - It seems completely bogus. -Per Bothner. */ - static char opname[32] = {'o', 'p', CPLUS_MARKER}; - char *o = opname + 3; - - /* Skip past '::'. */ - *pp = p + 2; - if (**pp == '\\') *pp = next_symbol_text (); - p = *pp; - while (*p != '.') - *o++ = *p++; - main_fn_name = savestring (opname, o - opname); - /* Skip past '.' */ - *pp = p + 1; - } - else -#endif - main_fn_name = savestring (*pp, p - *pp); - /* Skip past '::'. */ - *pp = p + 2; - new_mainlist->fn_fieldlist.name = main_fn_name; - - do - { - struct next_fnfield *new_sublist = - (struct next_fnfield *)alloca (sizeof (struct next_fnfield)); - - /* Check for and handle cretinous dbx symbol name continuation! */ - if (look_ahead_type == NULL) /* Normal case. */ - { - if (**pp == '\\') *pp = next_symbol_text (); - - new_sublist->fn_field.type = read_type (pp); - if (**pp != ':') - /* Invalid symtab info for method. */ - return error_type (pp); - } - else - { /* g++ version 1 kludge */ - new_sublist->fn_field.type = look_ahead_type; - look_ahead_type = NULL; - } - - *pp += 1; - p = *pp; - while (*p != ';') p++; - /* If this is just a stub, then we don't have the - real name here. */ - new_sublist->fn_field.physname = savestring (*pp, p - *pp); - *pp = p + 1; - new_sublist->visibility = *(*pp)++ - '0'; - if (**pp == '\\') *pp = next_symbol_text (); - switch (**pp) - { - case 'A': /* Normal functions. */ - new_sublist->fn_field.is_const = 0; - new_sublist->fn_field.is_volatile = 0; - (*pp)++; - break; - case 'B': /* `const' member functions. */ - new_sublist->fn_field.is_const = 1; - new_sublist->fn_field.is_volatile = 0; - (*pp)++; - break; - case 'C': /* `volatile' member function. */ - new_sublist->fn_field.is_const = 0; - new_sublist->fn_field.is_volatile = 1; - (*pp)++; - break; - case 'D': /* `const volatile' member function. */ - new_sublist->fn_field.is_const = 1; - new_sublist->fn_field.is_volatile = 1; - (*pp)++; - break; - default: - /* This probably just means we're processing a file compiled - with g++ version 1. */ - complain(&const_vol_complaint, **pp); - } - - switch (*(*pp)++) - { - case '*': - /* virtual member function, followed by index. */ - /* The sign bit is set to distinguish pointers-to-methods - from virtual function indicies. Since the array is - in words, the quantity must be shifted left by 1 - on 16 bit machine, and by 2 on 32 bit machine, forcing - the sign bit out, and usable as a valid index into - the array. Remove the sign bit here. */ - new_sublist->fn_field.voffset = - (0x7fffffff & read_number (pp, ';')) + 2; - - if (**pp == '\\') *pp = next_symbol_text (); - - if (**pp == ';' || **pp == '\0') - /* Must be g++ version 1. */ - new_sublist->fn_field.fcontext = 0; - else - { - /* Figure out from whence this virtual function came. - It may belong to virtual function table of - one of its baseclasses. */ - look_ahead_type = read_type (pp); - if (**pp == ':') - { /* g++ version 1 overloaded methods. */ } - else - { - new_sublist->fn_field.fcontext = look_ahead_type; - if (**pp != ';') - return error_type (pp); - else - ++*pp; - look_ahead_type = NULL; - } - } - break; - - case '?': - /* static member function. */ - new_sublist->fn_field.voffset = VOFFSET_STATIC; - break; - default: - /* **pp == '.'. */ - /* normal member function. */ - new_sublist->fn_field.voffset = 0; - new_sublist->fn_field.fcontext = 0; - break; - } - - new_sublist->next = sublist; - sublist = new_sublist; - length++; - if (**pp == '\\') *pp = next_symbol_text (); - } - while (**pp != ';' && **pp != '\0'); - - *pp += 1; - - new_mainlist->fn_fieldlist.fn_fields = - (struct fn_field *) obstack_alloc (symbol_obstack, - sizeof (struct fn_field) * length); - TYPE_FN_PRIVATE_BITS (new_mainlist->fn_fieldlist) = - (B_TYPE *) obstack_alloc (symbol_obstack, B_BYTES (length)); - B_CLRALL (TYPE_FN_PRIVATE_BITS (new_mainlist->fn_fieldlist), length); - - TYPE_FN_PROTECTED_BITS (new_mainlist->fn_fieldlist) = - (B_TYPE *) obstack_alloc (symbol_obstack, B_BYTES (length)); - B_CLRALL (TYPE_FN_PROTECTED_BITS (new_mainlist->fn_fieldlist), length); - - for (i = length; (i--, sublist); sublist = sublist->next) - { - new_mainlist->fn_fieldlist.fn_fields[i] = sublist->fn_field; - if (sublist->visibility == 0) - B_SET (new_mainlist->fn_fieldlist.private_fn_field_bits, i); - else if (sublist->visibility == 1) - B_SET (new_mainlist->fn_fieldlist.protected_fn_field_bits, i); - } - - new_mainlist->fn_fieldlist.length = length; - new_mainlist->next = mainlist; - mainlist = new_mainlist; - nfn_fields++; - total_length += length; - } - while (**pp != ';'); - } - - *pp += 1; - - TYPE_FN_FIELDLISTS (type) = - (struct fn_fieldlist *) obstack_alloc (symbol_obstack, - sizeof (struct fn_fieldlist) * nfn_fields); - - TYPE_NFN_FIELDS (type) = nfn_fields; - TYPE_NFN_FIELDS_TOTAL (type) = total_length; - - { - int i; - for (i = 0; i < TYPE_N_BASECLASSES (type); ++i) - TYPE_NFN_FIELDS_TOTAL (type) += - TYPE_NFN_FIELDS_TOTAL (TYPE_BASECLASS (type, i)); - } - - for (n = nfn_fields; mainlist; mainlist = mainlist->next) - TYPE_FN_FIELDLISTS (type)[--n] = mainlist->fn_fieldlist; - - if (**pp == '~') - { - *pp += 1; - - if (**pp == '=' || **pp == '+' || **pp == '-') - { - /* Obsolete flags that used to indicate the presence - of constructors and/or destructors. */ - *pp += 1; - } - - /* Read either a '%' or the final ';'. */ - if (*(*pp)++ == '%') - { - /* We'd like to be able to derive the vtable pointer field - from the type information, but when it's inherited, that's - hard. A reason it's hard is because we may read in the - info about a derived class before we read in info about - the base class that provides the vtable pointer field. - Once the base info has been read, we could fill in the info - for the derived classes, but for the fact that by then, - we don't remember who needs what. */ - - int predicted_fieldno = -1; - - /* Now we must record the virtual function table pointer's - field information. */ - - struct type *t; - int i; - - -#if 0 - { - /* In version 2, we derive the vfield ourselves. */ - for (n = 0; n < nfields; n++) - { - if (! strncmp (TYPE_FIELD_NAME (type, n), vptr_name, - sizeof (vptr_name) -1)) - { - predicted_fieldno = n; - break; - } - } - if (predicted_fieldno < 0) - for (n = 0; n < TYPE_N_BASECLASSES (type); n++) - if (! TYPE_FIELD_VIRTUAL (type, n) - && TYPE_VPTR_FIELDNO (TYPE_BASECLASS (type, n)) >= 0) - { - predicted_fieldno = TYPE_VPTR_FIELDNO (TYPE_BASECLASS (type, n)); - break; - } - } -#endif - - t = read_type (pp); - p = (*pp)++; - while (*p != '\0' && *p != ';') - p++; - if (*p == '\0') - /* Premature end of symbol. */ - return error_type (pp); - - TYPE_VPTR_BASETYPE (type) = t; - if (type == t) - { - if (TYPE_FIELD_NAME (t, TYPE_N_BASECLASSES (t)) == 0) - { - /* FIXME-tiemann: what's this? */ -#if 0 - TYPE_VPTR_FIELDNO (type) = i = TYPE_N_BASECLASSES (t); -#else - error_type (pp); -#endif - } - else for (i = TYPE_NFIELDS (t) - 1; i >= TYPE_N_BASECLASSES (t); --i) - if (! strncmp (TYPE_FIELD_NAME (t, i), vptr_name, - sizeof (vptr_name) -1)) - { - TYPE_VPTR_FIELDNO (type) = i; - break; - } - if (i < 0) - /* Virtual function table field not found. */ - return error_type (pp); - } - else - TYPE_VPTR_FIELDNO (type) = TYPE_VPTR_FIELDNO (t); - -#if 0 - if (TYPE_VPTR_FIELDNO (type) != predicted_fieldno) - error ("TYPE_VPTR_FIELDNO miscalculated"); -#endif - - *pp = p + 1; - } - } - - return type; -} - -/* Read a definition of an array type, - and create and return a suitable type object. - Also creates a range type which represents the bounds of that - array. */ -struct type * -read_array_type (pp, type) - register char **pp; - register struct type *type; -{ - struct type *index_type, *element_type, *range_type; - int lower, upper; - int adjustable = 0; - - /* Format of an array type: - "ar;lower;upper;". Put code in - to handle this. - - Fortran adjustable arrays use Adigits or Tdigits for lower or upper; - for these, produce a type like float[][]. */ - - index_type = read_type (pp); - if (**pp != ';') - /* Improper format of array type decl. */ - return error_type (pp); - ++*pp; - - if (!(**pp >= '0' && **pp <= '9')) - { - *pp += 1; - adjustable = 1; - } - lower = read_number (pp, ';'); - - if (!(**pp >= '0' && **pp <= '9')) - { - *pp += 1; - adjustable = 1; - } - upper = read_number (pp, ';'); - - element_type = read_type (pp); - - if (adjustable) - { - lower = 0; - upper = -1; - } - - { - /* Create range type. */ - range_type = (struct type *) obstack_alloc (symbol_obstack, - sizeof (struct type)); - TYPE_CODE (range_type) = TYPE_CODE_RANGE; - TYPE_TARGET_TYPE (range_type) = index_type; - - /* This should never be needed. */ - TYPE_LENGTH (range_type) = sizeof (int); - - TYPE_NFIELDS (range_type) = 2; - TYPE_FIELDS (range_type) = - (struct field *) obstack_alloc (symbol_obstack, - 2 * sizeof (struct field)); - TYPE_FIELD_BITPOS (range_type, 0) = lower; - TYPE_FIELD_BITPOS (range_type, 1) = upper; - } - - TYPE_CODE (type) = TYPE_CODE_ARRAY; - TYPE_TARGET_TYPE (type) = element_type; - TYPE_LENGTH (type) = (upper - lower + 1) * TYPE_LENGTH (element_type); - TYPE_NFIELDS (type) = 1; - TYPE_FIELDS (type) = - (struct field *) obstack_alloc (symbol_obstack, - sizeof (struct field)); - TYPE_FIELD_TYPE (type, 0) = range_type; - - return type; -} - - -/* Read a definition of an enumeration type, - and create and return a suitable type object. - Also defines the symbols that represent the values of the type. */ - -struct type * -read_enum_type (pp, type) - register char **pp; - register struct type *type; -{ - register char *p; - char *name; - register long n; - register struct symbol *sym; - int nsyms = 0; - struct pending **symlist; - struct pending *osyms, *syms; - int o_nsyms; - - if (within_function) - symlist = &local_symbols; - else - symlist = &file_symbols; - osyms = *symlist; - o_nsyms = osyms ? osyms->nsyms : 0; - - /* Read the value-names and their values. - The input syntax is NAME:VALUE,NAME:VALUE, and so on. - A semicolon or comman instead of a NAME means the end. */ - while (**pp && **pp != ';' && **pp != ',') - { - /* Check for and handle cretinous dbx symbol name continuation! */ - if (**pp == '\\') *pp = next_symbol_text (); - - p = *pp; - while (*p != ':') p++; - name = obsavestring (*pp, p - *pp); - *pp = p + 1; - n = read_number (pp, ','); - - sym = (struct symbol *) obstack_alloc (symbol_obstack, sizeof (struct symbol)); - bzero (sym, sizeof (struct symbol)); - SYMBOL_NAME (sym) = name; - SYMBOL_CLASS (sym) = LOC_CONST; - SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; - SYMBOL_VALUE (sym) = n; - add_symbol_to_list (sym, symlist); - nsyms++; - } - - if (**pp == ';') - (*pp)++; /* Skip the semicolon. */ - - /* Now fill in the fields of the type-structure. */ - - TYPE_LENGTH (type) = sizeof (int); - TYPE_CODE (type) = TYPE_CODE_ENUM; - TYPE_NFIELDS (type) = nsyms; - TYPE_FIELDS (type) = (struct field *) obstack_alloc (symbol_obstack, sizeof (struct field) * nsyms); - - /* Find the symbols for the values and put them into the type. - The symbols can be found in the symlist that we put them on - to cause them to be defined. osyms contains the old value - of that symlist; everything up to there was defined by us. */ - /* Note that we preserve the order of the enum constants, so - that in something like "enum {FOO, LAST_THING=FOO}" we print - FOO, not LAST_THING. */ - - for (syms = *symlist, n = 0; syms; syms = syms->next) - { - int j = 0; - if (syms == osyms) - j = o_nsyms; - for (; j < syms->nsyms; j++,n++) - { - struct symbol *xsym = syms->symbol[j]; - SYMBOL_TYPE (xsym) = type; - TYPE_FIELD_NAME (type, n) = SYMBOL_NAME (xsym); - TYPE_FIELD_VALUE (type, n) = 0; - TYPE_FIELD_BITPOS (type, n) = SYMBOL_VALUE (xsym); - TYPE_FIELD_BITSIZE (type, n) = 0; - } - if (syms == osyms) - break; - } - -#if 0 - /* This screws up perfectly good C programs with enums. FIXME. */ - /* Is this Modula-2's BOOLEAN type? Flag it as such if so. */ - if(TYPE_NFIELDS(type) == 2 && - ((!strcmp(TYPE_FIELD_NAME(type,0),"TRUE") && - !strcmp(TYPE_FIELD_NAME(type,1),"FALSE")) || - (!strcmp(TYPE_FIELD_NAME(type,1),"TRUE") && - !strcmp(TYPE_FIELD_NAME(type,0),"FALSE")))) - TYPE_CODE(type) = TYPE_CODE_BOOL; -#endif - - return type; -} - -/* Read a number from the string pointed to by *PP. - The value of *PP is advanced over the number. - If END is nonzero, the character that ends the - number must match END, or an error happens; - and that character is skipped if it does match. - If END is zero, *PP is left pointing to that character. - - If the number fits in a long, set *VALUE and set *BITS to 0. - If not, set *BITS to be the number of bits in the number. - - If encounter garbage, set *BITS to -1. */ - -void -read_huge_number (pp, end, valu, bits) - char **pp; - int end; - long *valu; - int *bits; -{ - char *p = *pp; - int sign = 1; - long n = 0; - int radix = 10; - char overflow = 0; - int nbits = 0; - int c; - long upper_limit; - - if (*p == '-') - { - sign = -1; - p++; - } - - /* Leading zero means octal. GCC uses this to output values larger - than an int (because that would be hard in decimal). */ - if (*p == '0') - { - radix = 8; - p++; - } - - upper_limit = LONG_MAX / radix; - while ((c = *p++) >= '0' && c <= ('0' + radix)) - { - if (n <= upper_limit) - { - n *= radix; - n += c - '0'; /* FIXME this overflows anyway */ - } - else - overflow = 1; - - /* This depends on large values being output in octal, which is - what GCC does. */ - if (radix == 8) - { - if (nbits == 0) - { - if (c == '0') - /* Ignore leading zeroes. */ - ; - else if (c == '1') - nbits = 1; - else if (c == '2' || c == '3') - nbits = 2; - else - nbits = 3; - } - else - nbits += 3; - } - } - if (end) - { - if (c && c != end) - { - if (bits != NULL) - *bits = -1; - return; - } - } - else - --p; - - *pp = p; - if (overflow) - { - if (nbits == 0) - { - /* Large decimal constants are an error (because it is hard to - count how many bits are in them). */ - if (bits != NULL) - *bits = -1; - return; - } - - /* -0x7f is the same as 0x80. So deal with it by adding one to - the number of bits. */ - if (sign == -1) - ++nbits; - if (bits) - *bits = nbits; - } - else - { - if (valu) - *valu = n * sign; - if (bits) - *bits = 0; - } -} - -#define MAX_OF_C_TYPE(t) ((1 << (sizeof (t)*8 - 1)) - 1) -#define MIN_OF_C_TYPE(t) (-(1 << (sizeof (t)*8 - 1))) - -struct type * -read_range_type (pp, typenums) - char **pp; - int typenums[2]; -{ - int rangenums[2]; - long n2, n3; - int n2bits, n3bits; - int self_subrange; - struct type *result_type; - - /* First comes a type we are a subrange of. - In C it is usually 0, 1 or the type being defined. */ - read_type_number (pp, rangenums); - self_subrange = (rangenums[0] == typenums[0] && - rangenums[1] == typenums[1]); - - /* A semicolon should now follow; skip it. */ - if (**pp == ';') - (*pp)++; - - /* The remaining two operands are usually lower and upper bounds - of the range. But in some special cases they mean something else. */ - read_huge_number (pp, ';', &n2, &n2bits); - read_huge_number (pp, ';', &n3, &n3bits); - - if (n2bits == -1 || n3bits == -1) - return error_type (pp); - - /* If limits are huge, must be large integral type. */ - if (n2bits != 0 || n3bits != 0) - { - char got_signed = 0; - char got_unsigned = 0; - /* Number of bits in the type. */ - int nbits; - - /* Range from 0 to is an unsigned large integral type. */ - if ((n2bits == 0 && n2 == 0) && n3bits != 0) - { - got_unsigned = 1; - nbits = n3bits; - } - /* Range from to -1 is a large signed - integral type. */ - else if (n2bits != 0 && n3bits != 0 && n2bits == n3bits + 1) - { - got_signed = 1; - nbits = n2bits; - } - - /* Check for "long long". */ - if (got_signed && nbits == TARGET_LONG_LONG_BIT) - return builtin_type_long_long; - if (got_unsigned && nbits == TARGET_LONG_LONG_BIT) - return builtin_type_unsigned_long_long; - - if (got_signed || got_unsigned) - { - result_type = (struct type *) obstack_alloc (symbol_obstack, - sizeof (struct type)); - bzero (result_type, sizeof (struct type)); - TYPE_LENGTH (result_type) = nbits / TARGET_CHAR_BIT; - TYPE_CODE (result_type) = TYPE_CODE_INT; - if (got_unsigned) - TYPE_FLAGS (result_type) |= TYPE_FLAG_UNSIGNED; - return result_type; - } - else - return error_type (pp); - } - - /* A type defined as a subrange of itself, with bounds both 0, is void. */ - if (self_subrange && n2 == 0 && n3 == 0) - return builtin_type_void; - - /* If n3 is zero and n2 is not, we want a floating type, - and n2 is the width in bytes. - - Fortran programs appear to use this for complex types also, - and they give no way to distinguish between double and single-complex! - We don't have complex types, so we would lose on all fortran files! - So return type `double' for all of those. It won't work right - for the complex values, but at least it makes the file loadable. */ - - if (n3 == 0 && n2 > 0) - { - if (n2 == sizeof (float)) - return builtin_type_float; - return builtin_type_double; - } - - /* If the upper bound is -1, it must really be an unsigned int. */ - - else if (n2 == 0 && n3 == -1) - { - /* FIXME -- this confuses host and target type sizes. */ - if (sizeof (int) == sizeof (long)) - return builtin_type_unsigned_int; - else - return builtin_type_unsigned_long; - } - - /* Special case: char is defined (Who knows why) as a subrange of - itself with range 0-127. */ - else if (self_subrange && n2 == 0 && n3 == 127) - return builtin_type_char; - - /* Assumptions made here: Subrange of self is equivalent to subrange - of int. FIXME: Host and target type-sizes assumed the same. */ - else if (n2 == 0 - && (self_subrange || - *dbx_lookup_type (rangenums) == builtin_type_int)) - { - /* an unsigned type */ -#ifdef LONG_LONG - if (n3 == - sizeof (long long)) - return builtin_type_unsigned_long_long; -#endif - if (n3 == (unsigned int)~0L) - return builtin_type_unsigned_int; - if (n3 == (unsigned long)~0L) - return builtin_type_unsigned_long; - if (n3 == (unsigned short)~0L) - return builtin_type_unsigned_short; - if (n3 == (unsigned char)~0L) - return builtin_type_unsigned_char; - } -#ifdef LONG_LONG - else if (n3 == 0 && n2 == -sizeof (long long)) - return builtin_type_long_long; -#endif - else if (n2 == -n3 -1) - { - /* a signed type */ - if (n3 == (1 << (8 * sizeof (int) - 1)) - 1) - return builtin_type_int; - if (n3 == (1 << (8 * sizeof (long) - 1)) - 1) - return builtin_type_long; - if (n3 == (1 << (8 * sizeof (short) - 1)) - 1) - return builtin_type_short; - if (n3 == (1 << (8 * sizeof (char) - 1)) - 1) - return builtin_type_char; - } - - /* We have a real range type on our hands. Allocate space and - return a real pointer. */ - - /* At this point I don't have the faintest idea how to deal with - a self_subrange type; I'm going to assume that this is used - as an idiom, and that all of them are special cases. So . . . */ - if (self_subrange) - return error_type (pp); - - result_type = (struct type *) obstack_alloc (symbol_obstack, - sizeof (struct type)); - bzero (result_type, sizeof (struct type)); - - TYPE_CODE (result_type) = TYPE_CODE_RANGE; - - TYPE_TARGET_TYPE (result_type) = *dbx_lookup_type(rangenums); - if (TYPE_TARGET_TYPE (result_type) == 0) { - complain (&range_type_base_complaint, rangenums[1]); - TYPE_TARGET_TYPE (result_type) = builtin_type_int; - } - - TYPE_NFIELDS (result_type) = 2; - TYPE_FIELDS (result_type) = - (struct field *) obstack_alloc (symbol_obstack, - 2 * sizeof (struct field)); - bzero (TYPE_FIELDS (result_type), 2 * sizeof (struct field)); - TYPE_FIELD_BITPOS (result_type, 0) = n2; - TYPE_FIELD_BITPOS (result_type, 1) = n3; - -#if 0 -/* Note that TYPE_LENGTH (result_type) is just overridden a few - statements down. What do we really need here? */ - /* We have to figure out how many bytes it takes to hold this - range type. I'm going to assume that anything that is pushing - the bounds of a long was taken care of above. */ - if (n2 >= MIN_OF_C_TYPE(char) && n3 <= MAX_OF_C_TYPE(char)) - TYPE_LENGTH (result_type) = 1; - else if (n2 >= MIN_OF_C_TYPE(short) && n3 <= MAX_OF_C_TYPE(short)) - TYPE_LENGTH (result_type) = sizeof (short); - else if (n2 >= MIN_OF_C_TYPE(int) && n3 <= MAX_OF_C_TYPE(int)) - TYPE_LENGTH (result_type) = sizeof (int); - else if (n2 >= MIN_OF_C_TYPE(long) && n3 <= MAX_OF_C_TYPE(long)) - TYPE_LENGTH (result_type) = sizeof (long); - else - /* Ranged type doesn't fit within known sizes. */ - /* FIXME -- use "long long" here. */ - return error_type (pp); -#endif - - TYPE_LENGTH (result_type) = TYPE_LENGTH (TYPE_TARGET_TYPE (result_type)); - - return result_type; -} - -/* Read a number from the string pointed to by *PP. - The value of *PP is advanced over the number. - If END is nonzero, the character that ends the - number must match END, or an error happens; - and that character is skipped if it does match. - If END is zero, *PP is left pointing to that character. */ - -long -read_number (pp, end) - char **pp; - int end; -{ - register char *p = *pp; - register long n = 0; - register int c; - int sign = 1; - - /* Handle an optional leading minus sign. */ - - if (*p == '-') - { - sign = -1; - p++; - } - - /* Read the digits, as far as they go. */ - - while ((c = *p++) >= '0' && c <= '9') - { - n *= 10; - n += c - '0'; - } - if (end) - { - if (c && c != end) - error ("Invalid symbol data: invalid character \\%03o at symbol pos %d.", c, symnum); - } - else - --p; - - *pp = p; - return n * sign; -} - -/* Read in an argument list. This is a list of types, separated by commas - and terminated with END. Return the list of types read in, or (struct type - **)-1 if there is an error. */ -struct type ** -read_args (pp, end) - char **pp; - int end; -{ - /* FIXME! Remove this arbitrary limit! */ - struct type *types[1024], **rval; /* allow for fns of 1023 parameters */ - int n = 0; - - while (**pp != end) - { - if (**pp != ',') - /* Invalid argument list: no ','. */ - return (struct type **)-1; - *pp += 1; - - /* Check for and handle cretinous dbx symbol name continuation! */ - if (**pp == '\\') - *pp = next_symbol_text (); - - types[n++] = read_type (pp); - } - *pp += 1; /* get past `end' (the ':' character) */ - - if (n == 1) - { - rval = (struct type **) xmalloc (2 * sizeof (struct type *)); - } - else if (TYPE_CODE (types[n-1]) != TYPE_CODE_VOID) - { - rval = (struct type **) xmalloc ((n + 1) * sizeof (struct type *)); - bzero (rval + n, sizeof (struct type *)); - } - else - { - rval = (struct type **) xmalloc (n * sizeof (struct type *)); - } - bcopy (types, rval, n * sizeof (struct type *)); - return rval; -} - -/* Add a common block's start address to the offset of each symbol - declared to be in it (by being between a BCOMM/ECOMM pair that uses - the common block name). */ - -static void -fix_common_block (sym, valu) - struct symbol *sym; - int valu; -{ - struct pending *next = (struct pending *) SYMBOL_NAMESPACE (sym); - for ( ; next; next = next->next) - { - register int j; - for (j = next->nsyms - 1; j >= 0; j--) - SYMBOL_VALUE_ADDRESS (next->symbol[j]) += valu; - } -} - -/* Initializer for this module */ -void -_initialize_buildsym () -{ - undef_types_allocated = 20; - undef_types_length = 0; - undef_types = (struct type **) xmalloc (undef_types_allocated * - sizeof (struct type *)); -} diff --git a/gdb/buildsym.h b/gdb/buildsym.h deleted file mode 100644 index 2722d5b0b95..00000000000 --- a/gdb/buildsym.h +++ /dev/null @@ -1,296 +0,0 @@ -/* Build symbol tables in GDB's internal format. - Copyright (C) 1986-1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* This module provides definitions used for creating and adding to - the symbol table. These routines are called from various symbol- - file-reading routines. - - They originated in dbxread.c of gdb-4.2, and were split out to - make xcoffread.c more maintainable by sharing code. - - Variables declared in this file can be defined by #define-ing - the name EXTERN to null. It is used to declare variables that - are normally extern, but which get defined in a single module - using this technique. */ - -#ifndef EXTERN -#define EXTERN extern -#endif - -extern void add_symbol_to_list (); -struct symbol *find_symbol_in_list (); -extern void read_type_number (); -extern struct type *read_type (); -extern struct type *read_range_type (); -extern struct type *read_enum_type (); -extern struct type *read_struct_type (); -extern struct type *read_array_type (); -extern struct type **read_args (); -extern struct type **dbx_lookup_type (); -extern long read_number (); -extern void finish_block (); -extern struct blockvector *make_blockvector (); -extern void add_undefined_type (); -extern void really_free_pendings (); -extern void start_subfile (); -extern void push_subfile (); -extern char *pop_subfile (); -extern struct symtab *end_symtab (); -extern void scan_file_globals (); -extern void buildsym_new_init (); -extern void buildsym_init (); -extern struct context_stack *push_context (); -extern void record_line (); -extern void start_symtab (); -extern struct symbol *define_symbol (); - -/* Convert stab register number (from `r' declaration) to a gdb REGNUM. */ - -#ifndef STAB_REG_TO_REGNUM -#define STAB_REG_TO_REGNUM(VALUE) (VALUE) -#endif - -/* Name of source file whose symbol data we are now processing. - This comes from a symbol of type N_SO. */ - -EXTERN char *last_source_file; - -/* Core address of start of text of current source file. - This too comes from the N_SO symbol. */ - -EXTERN CORE_ADDR last_source_start_addr; - -/* The list of sub-source-files within the current individual compilation. - Each file gets its own symtab with its own linetable and associated info, - but they all share one blockvector. */ - -struct subfile -{ - struct subfile *next; - char *name; - char *dirname; - struct linetable *line_vector; - int line_vector_length; -}; - -EXTERN struct subfile *subfiles; - -EXTERN struct subfile *current_subfile; - -/* Global variable which, when set, indicates that we are processing a - .o file compiled with gcc */ - -EXTERN unsigned char processing_gcc_compilation; - -/* Count symbols as they are processed, for error messages. */ - -EXTERN unsigned int symnum; - -/* Vector of types defined so far, indexed by their dbx type numbers. - (In newer sun systems, dbx uses a pair of numbers in parens, - as in "(SUBFILENUM,NUMWITHINSUBFILE)". Then these numbers must be - translated through the type_translations hash table to get - the index into the type vector.) */ - -EXTERN struct type **type_vector; - -/* Number of elements allocated for type_vector currently. */ - -EXTERN int type_vector_length; - -/* Hash table of global symbols whose values are not known yet. - They are chained thru the SYMBOL_VALUE_CHAIN, since we don't - have the correct data for that slot yet. */ -/* The use of the LOC_BLOCK code in this chain is nonstandard-- - it refers to a FORTRAN common block rather than the usual meaning. */ - -#define HASHSIZE 127 -EXTERN struct symbol *global_sym_chain[HASHSIZE]; - -/* Record the symbols defined for each context in a list. - We don't create a struct block for the context until we - know how long to make it. */ - -#define PENDINGSIZE 100 - -struct pending -{ - struct pending *next; - int nsyms; - struct symbol *symbol[PENDINGSIZE]; -}; - -/* List of free `struct pending' structures for reuse. */ -EXTERN struct pending *free_pendings; - -/* Here are the three lists that symbols are put on. */ - -EXTERN struct pending *file_symbols; /* static at top level, and types */ - -EXTERN struct pending *global_symbols; /* global functions and variables */ - -EXTERN struct pending *local_symbols; /* everything local to lexic context */ - -/* Kludge for xcoffread.c */ -struct pending_stabs { - int count, length; - char *stab[1]; -}; - -EXTERN struct pending_stabs *global_stabs; -EXTERN struct pending_stabs *file_stabs; - -/* List of symbols declared since the last BCOMM. This list is a tail - of local_symbols. When ECOMM is seen, the symbols on the list - are noted so their proper addresses can be filled in later, - using the common block base address gotten from the assembler - stabs. */ - -EXTERN struct pending *common_block; -EXTERN int common_block_i; - -/* Stack representing unclosed lexical contexts - (that will become blocks, eventually). */ - -struct context_stack -{ - struct pending *locals; /* Outer locals at the time we entered */ - struct pending_block *old_blocks; /* Pointer into blocklist as of entry */ - struct symbol *name; /* Name of function, if any, defining context*/ - CORE_ADDR start_addr; /* PC where this context starts */ - CORE_ADDR end_addr; /* Temp slot for exception handling. */ - int depth; /* For error-checking matching push/pop */ -}; - -EXTERN struct context_stack *context_stack; - -/* Index of first unused entry in context stack. */ -EXTERN int context_stack_depth; - -/* Currently allocated size of context stack. */ - -EXTERN int context_stack_size; - -/* Macro "function" for popping contexts from the stack. Pushing is done - by a real function, push_context. This returns a pointer to a struct - context_stack. */ - -#define pop_context() \ - (&context_stack[--context_stack_depth]); - -/* Nonzero if within a function (so symbols should be local, - if nothing says specifically). */ - -EXTERN int within_function; - -/* List of blocks already made (lexical contexts already closed). - This is used at the end to make the blockvector. */ - -struct pending_block -{ - struct pending_block *next; - struct block *block; -}; - -EXTERN struct pending_block *pending_blocks; - -extern CORE_ADDR startup_file_start; /* From blockframe.c */ -extern CORE_ADDR startup_file_end; /* From blockframe.c */ - -/* Global variable which, when set, indicates that we are processing a - .o file compiled with gcc */ - -EXTERN unsigned char processing_gcc_compilation; - -/* Setup a define to deal cleanly with the underscore problem */ - -#ifdef NAMES_HAVE_UNDERSCORE -#define HASH_OFFSET 1 -#else -#define HASH_OFFSET 0 -#endif - -/* Support for Sun changes to dbx symbol format */ - -/* For each identified header file, we have a table of types defined - in that header file. - - header_files maps header file names to their type tables. - It is a vector of n_header_files elements. - Each element describes one header file. - It contains a vector of types. - - Sometimes it can happen that the same header file produces - different results when included in different places. - This can result from conditionals or from different - things done before including the file. - When this happens, there are multiple entries for the file in this table, - one entry for each distinct set of results. - The entries are distinguished by the INSTANCE field. - The INSTANCE field appears in the N_BINCL and N_EXCL symbol table and is - used to match header-file references to their corresponding data. */ - -struct header_file -{ - char *name; /* Name of header file */ - int instance; /* Numeric code distinguishing instances - of one header file that produced - different results when included. - It comes from the N_BINCL or N_EXCL. */ - struct type **vector; /* Pointer to vector of types */ - int length; /* Allocated length (# elts) of that vector */ -}; - -EXTERN struct header_file *header_files; - -EXTERN int n_header_files; - -EXTERN int n_allocated_header_files; - -/* Within each object file, various header files are assigned numbers. - A type is defined or referred to with a pair of numbers - (FILENUM,TYPENUM) where FILENUM is the number of the header file - and TYPENUM is the number within that header file. - TYPENUM is the index within the vector of types for that header file. - - FILENUM == 1 is special; it refers to the main source of the object file, - and not to any header file. FILENUM != 1 is interpreted by looking it up - in the following table, which contains indices in header_files. */ - -EXTERN int *this_object_header_files; - -EXTERN int n_this_object_header_files; - -EXTERN int n_allocated_this_object_header_files; - -/* When a header file is getting special overriding definitions - for one source file, record here the header_files index - of its normal definition vector. - At other times, this is -1. */ - -EXTERN int header_file_prev_index; - -struct subfile_stack -{ - struct subfile_stack *next; - char *name; - int prev_index; -}; - -EXTERN struct subfile_stack *subfile_stack; diff --git a/gdb/c-exp.y b/gdb/c-exp.y deleted file mode 100644 index bea046322d3..00000000000 --- a/gdb/c-exp.y +++ /dev/null @@ -1,1583 +0,0 @@ -/* YACC parser for C expressions, for GDB. - Copyright (C) 1986, 1989, 1990, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Parse a C expression from text in a string, - and return the result as a struct expression pointer. - That structure contains arithmetic operations in reverse polish, - with constants represented by operations that are followed by special data. - See expression.h for the details of the format. - What is important here is that it can be built up sequentially - during the process of parsing; the lower levels of the tree always - come first in the result. */ - -%{ - -#include -#include -#include "defs.h" -#include "param.h" -#include "symtab.h" -#include "frame.h" -#include "expression.h" -#include "parser-defs.h" -#include "value.h" -#include "language.h" - -/* These MUST be included in any grammar file!!!! - Please choose unique names! */ -#define yyparse c_parse -#define yylex c_lex -#define yyerror c_error -#define yylval c_lval -#define yychar c_char -#define yydebug c_debug -#define yypact c_pact -#define yyr1 c_r1 -#define yyr2 c_r2 -#define yydef c_def -#define yychk c_chk -#define yypgo c_pgo -#define yyact c_act -#define yyexca c_exca -#define yyerrflag c_errflag -#define yynerrs c_nerrs -#define yyps c_ps -#define yypv c_pv -#define yys c_s -#define yystate c_state -#define yytmp c_tmp -#define yyv c_v -#define yyval c_val -#define yylloc c_lloc - -/* Forward decls */ -void yyerror (); -static int parse_number (); -int yyparse (); - -/* #define YYDEBUG 1 */ - -%} - -/* Although the yacc "value" of an expression is not used, - since the result is stored in the structure being created, - other node types do have values. */ - -%union - { - LONGEST lval; - unsigned LONGEST ulval; - double dval; - struct symbol *sym; - struct type *tval; - struct stoken sval; - struct ttype tsym; - struct symtoken ssym; - int voidval; - struct block *bval; - enum exp_opcode opcode; - struct internalvar *ivar; - - struct type **tvec; - int *ivec; - } - -%type exp exp1 type_exp start variable -%type type typebase -%type nonempty_typelist -/* %type block */ - -/* Fancy type parsing. */ -%type func_mod direct_abs_decl abs_decl -%type ptype -%type array_mod - -%token INT CHAR -%token UINT -%token FLOAT - -/* Both NAME and TYPENAME tokens represent symbols in the input, - and both convey their data as strings. - But a TYPENAME is a string that happens to be defined as a typedef - or builtin type name (such as int or char) - and a NAME is any other symbol. - Contexts where this distinction is not important can use the - nonterminal "name", which matches either NAME or TYPENAME. */ - -%token STRING -%token NAME /* BLOCKNAME defined below to give it higher precedence. */ -%token TYPENAME -%type name -%type name_not_typename -%type typename - -/* A NAME_OR_INT is a symbol which is not known in the symbol table, - but which would parse as a valid number in the current input radix. - E.g. "c" when input_radix==16. Depending on the parse, it will be - turned into a name or into a number. NAME_OR_UINT ditto. */ - -%token NAME_OR_INT NAME_OR_UINT - -%token STRUCT UNION ENUM SIZEOF UNSIGNED COLONCOLON -%token TEMPLATE -%token ERROR - -/* Special type cases, put in to allow the parser to distinguish different - legal basetypes. */ -%token SIGNED LONG SHORT INT_KEYWORD - -%token LAST REGNAME - -%token VARIABLE - -%token ASSIGN_MODIFY - -/* C++ */ -%token THIS - -%left ',' -%left ABOVE_COMMA -%right '=' ASSIGN_MODIFY -%right '?' -%left OR -%left AND -%left '|' -%left '^' -%left '&' -%left EQUAL NOTEQUAL -%left '<' '>' LEQ GEQ -%left LSH RSH -%left '@' -%left '+' '-' -%left '*' '/' '%' -%right UNARY INCREMENT DECREMENT -%right ARROW '.' '[' '(' -%token BLOCKNAME -%type block -%left COLONCOLON - -%% - -start : exp1 - | type_exp - ; - -type_exp: type - { write_exp_elt_opcode(OP_TYPE); - write_exp_elt_type($1); - write_exp_elt_opcode(OP_TYPE);} - ; - -/* Expressions, including the comma operator. */ -exp1 : exp - | exp1 ',' exp - { write_exp_elt_opcode (BINOP_COMMA); } - ; - -/* Expressions, not including the comma operator. */ -exp : '*' exp %prec UNARY - { write_exp_elt_opcode (UNOP_IND); } - -exp : '&' exp %prec UNARY - { write_exp_elt_opcode (UNOP_ADDR); } - -exp : '-' exp %prec UNARY - { write_exp_elt_opcode (UNOP_NEG); } - ; - -exp : '!' exp %prec UNARY - { write_exp_elt_opcode (UNOP_ZEROP); } - ; - -exp : '~' exp %prec UNARY - { write_exp_elt_opcode (UNOP_LOGNOT); } - ; - -exp : INCREMENT exp %prec UNARY - { write_exp_elt_opcode (UNOP_PREINCREMENT); } - ; - -exp : DECREMENT exp %prec UNARY - { write_exp_elt_opcode (UNOP_PREDECREMENT); } - ; - -exp : exp INCREMENT %prec UNARY - { write_exp_elt_opcode (UNOP_POSTINCREMENT); } - ; - -exp : exp DECREMENT %prec UNARY - { write_exp_elt_opcode (UNOP_POSTDECREMENT); } - ; - -exp : SIZEOF exp %prec UNARY - { write_exp_elt_opcode (UNOP_SIZEOF); } - ; - -exp : exp ARROW name - { write_exp_elt_opcode (STRUCTOP_PTR); - write_exp_string ($3); - write_exp_elt_opcode (STRUCTOP_PTR); } - ; - -exp : exp ARROW '*' exp - { write_exp_elt_opcode (STRUCTOP_MPTR); } - ; - -exp : exp '.' name - { write_exp_elt_opcode (STRUCTOP_STRUCT); - write_exp_string ($3); - write_exp_elt_opcode (STRUCTOP_STRUCT); } - ; - -exp : exp '.' '*' exp - { write_exp_elt_opcode (STRUCTOP_MEMBER); } - ; - -exp : exp '[' exp1 ']' - { write_exp_elt_opcode (BINOP_SUBSCRIPT); } - ; - -exp : exp '(' - /* This is to save the value of arglist_len - being accumulated by an outer function call. */ - { start_arglist (); } - arglist ')' %prec ARROW - { write_exp_elt_opcode (OP_FUNCALL); - write_exp_elt_longcst ((LONGEST) end_arglist ()); - write_exp_elt_opcode (OP_FUNCALL); } - ; - -arglist : - ; - -arglist : exp - { arglist_len = 1; } - ; - -arglist : arglist ',' exp %prec ABOVE_COMMA - { arglist_len++; } - ; - -exp : '{' type '}' exp %prec UNARY - { write_exp_elt_opcode (UNOP_MEMVAL); - write_exp_elt_type ($2); - write_exp_elt_opcode (UNOP_MEMVAL); } - ; - -exp : '(' type ')' exp %prec UNARY - { write_exp_elt_opcode (UNOP_CAST); - write_exp_elt_type ($2); - write_exp_elt_opcode (UNOP_CAST); } - ; - -exp : '(' exp1 ')' - { } - ; - -/* Binary operators in order of decreasing precedence. */ - -exp : exp '@' exp - { write_exp_elt_opcode (BINOP_REPEAT); } - ; - -exp : exp '*' exp - { write_exp_elt_opcode (BINOP_MUL); } - ; - -exp : exp '/' exp - { write_exp_elt_opcode (BINOP_DIV); } - ; - -exp : exp '%' exp - { write_exp_elt_opcode (BINOP_REM); } - ; - -exp : exp '+' exp - { write_exp_elt_opcode (BINOP_ADD); } - ; - -exp : exp '-' exp - { write_exp_elt_opcode (BINOP_SUB); } - ; - -exp : exp LSH exp - { write_exp_elt_opcode (BINOP_LSH); } - ; - -exp : exp RSH exp - { write_exp_elt_opcode (BINOP_RSH); } - ; - -exp : exp EQUAL exp - { write_exp_elt_opcode (BINOP_EQUAL); } - ; - -exp : exp NOTEQUAL exp - { write_exp_elt_opcode (BINOP_NOTEQUAL); } - ; - -exp : exp LEQ exp - { write_exp_elt_opcode (BINOP_LEQ); } - ; - -exp : exp GEQ exp - { write_exp_elt_opcode (BINOP_GEQ); } - ; - -exp : exp '<' exp - { write_exp_elt_opcode (BINOP_LESS); } - ; - -exp : exp '>' exp - { write_exp_elt_opcode (BINOP_GTR); } - ; - -exp : exp '&' exp - { write_exp_elt_opcode (BINOP_LOGAND); } - ; - -exp : exp '^' exp - { write_exp_elt_opcode (BINOP_LOGXOR); } - ; - -exp : exp '|' exp - { write_exp_elt_opcode (BINOP_LOGIOR); } - ; - -exp : exp AND exp - { write_exp_elt_opcode (BINOP_AND); } - ; - -exp : exp OR exp - { write_exp_elt_opcode (BINOP_OR); } - ; - -exp : exp '?' exp ':' exp %prec '?' - { write_exp_elt_opcode (TERNOP_COND); } - ; - -exp : exp '=' exp - { write_exp_elt_opcode (BINOP_ASSIGN); } - ; - -exp : exp ASSIGN_MODIFY exp - { write_exp_elt_opcode (BINOP_ASSIGN_MODIFY); - write_exp_elt_opcode ($2); - write_exp_elt_opcode (BINOP_ASSIGN_MODIFY); } - ; - -exp : INT - { write_exp_elt_opcode (OP_LONG); - if ($1 == (int) $1 || $1 == (unsigned int) $1) - write_exp_elt_type (builtin_type_int); - else - write_exp_elt_type (BUILTIN_TYPE_LONGEST); - write_exp_elt_longcst ((LONGEST) $1); - write_exp_elt_opcode (OP_LONG); } - ; - -exp : NAME_OR_INT - { YYSTYPE val; - parse_number ($1.stoken.ptr, $1.stoken.length, 0, &val); - write_exp_elt_opcode (OP_LONG); - if (val.lval == (int) val.lval || - val.lval == (unsigned int) val.lval) - write_exp_elt_type (builtin_type_int); - else - write_exp_elt_type (BUILTIN_TYPE_LONGEST); - write_exp_elt_longcst (val.lval); - write_exp_elt_opcode (OP_LONG); } - ; - -exp : UINT - { - write_exp_elt_opcode (OP_LONG); - if ($1 == (unsigned int) $1) - write_exp_elt_type (builtin_type_unsigned_int); - else - write_exp_elt_type (BUILTIN_TYPE_UNSIGNED_LONGEST); - write_exp_elt_longcst ((LONGEST) $1); - write_exp_elt_opcode (OP_LONG); - } - ; - -exp : NAME_OR_UINT - { YYSTYPE val; - parse_number ($1.stoken.ptr, $1.stoken.length, 0, &val); - write_exp_elt_opcode (OP_LONG); - if (val.ulval == (unsigned int) val.ulval) - write_exp_elt_type (builtin_type_unsigned_int); - else - write_exp_elt_type (BUILTIN_TYPE_UNSIGNED_LONGEST); - write_exp_elt_longcst ((LONGEST)val.ulval); - write_exp_elt_opcode (OP_LONG); - } - ; - -exp : CHAR - { write_exp_elt_opcode (OP_LONG); - write_exp_elt_type (builtin_type_char); - write_exp_elt_longcst ((LONGEST) $1); - write_exp_elt_opcode (OP_LONG); } - ; - -exp : FLOAT - { write_exp_elt_opcode (OP_DOUBLE); - write_exp_elt_type (builtin_type_double); - write_exp_elt_dblcst ($1); - write_exp_elt_opcode (OP_DOUBLE); } - ; - -exp : variable - ; - -exp : LAST - { write_exp_elt_opcode (OP_LAST); - write_exp_elt_longcst ((LONGEST) $1); - write_exp_elt_opcode (OP_LAST); } - ; - -exp : REGNAME - { write_exp_elt_opcode (OP_REGISTER); - write_exp_elt_longcst ((LONGEST) $1); - write_exp_elt_opcode (OP_REGISTER); } - ; - -exp : VARIABLE - { write_exp_elt_opcode (OP_INTERNALVAR); - write_exp_elt_intern ($1); - write_exp_elt_opcode (OP_INTERNALVAR); } - ; - -exp : SIZEOF '(' type ')' %prec UNARY - { write_exp_elt_opcode (OP_LONG); - write_exp_elt_type (builtin_type_int); - write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3)); - write_exp_elt_opcode (OP_LONG); } - ; - -exp : STRING - { write_exp_elt_opcode (OP_STRING); - write_exp_string ($1); - write_exp_elt_opcode (OP_STRING); } - ; - -/* C++. */ -exp : THIS - { write_exp_elt_opcode (OP_THIS); - write_exp_elt_opcode (OP_THIS); } - ; - -/* end of C++. */ - -block : BLOCKNAME - { - if ($1.sym != 0) - $$ = SYMBOL_BLOCK_VALUE ($1.sym); - else - { - struct symtab *tem = - lookup_symtab (copy_name ($1.stoken)); - if (tem) - $$ = BLOCKVECTOR_BLOCK - (BLOCKVECTOR (tem), STATIC_BLOCK); - else - error ("No file or function \"%s\".", - copy_name ($1.stoken)); - } - } - ; - -block : block COLONCOLON name - { struct symbol *tem - = lookup_symbol (copy_name ($3), $1, - VAR_NAMESPACE, 0, NULL); - if (!tem || SYMBOL_CLASS (tem) != LOC_BLOCK) - error ("No function \"%s\" in specified context.", - copy_name ($3)); - $$ = SYMBOL_BLOCK_VALUE (tem); } - ; - -variable: block COLONCOLON name - { struct symbol *sym; - sym = lookup_symbol (copy_name ($3), $1, - VAR_NAMESPACE, 0, NULL); - if (sym == 0) - error ("No symbol \"%s\" in specified context.", - copy_name ($3)); - - write_exp_elt_opcode (OP_VAR_VALUE); - write_exp_elt_sym (sym); - write_exp_elt_opcode (OP_VAR_VALUE); } - ; - -variable: typebase COLONCOLON name - { - struct type *type = $1; - if (TYPE_CODE (type) != TYPE_CODE_STRUCT - && TYPE_CODE (type) != TYPE_CODE_UNION) - error ("`%s' is not defined as an aggregate type.", - TYPE_NAME (type)); - - write_exp_elt_opcode (OP_SCOPE); - write_exp_elt_type (type); - write_exp_string ($3); - write_exp_elt_opcode (OP_SCOPE); - } - | typebase COLONCOLON '~' name - { - struct type *type = $1; - if (TYPE_CODE (type) != TYPE_CODE_STRUCT - && TYPE_CODE (type) != TYPE_CODE_UNION) - error ("`%s' is not defined as an aggregate type.", - TYPE_NAME (type)); - - if (strcmp (type_name_no_tag (type), $4.ptr)) - error ("invalid destructor `%s::~%s'", - type_name_no_tag (type), $4.ptr); - - write_exp_elt_opcode (OP_SCOPE); - write_exp_elt_type (type); - write_exp_string ($4); - write_exp_elt_opcode (OP_SCOPE); - write_exp_elt_opcode (UNOP_LOGNOT); - } - | COLONCOLON name - { - char *name = copy_name ($2); - struct symbol *sym; - int i; - - sym = - lookup_symbol (name, 0, VAR_NAMESPACE, 0, NULL); - if (sym) - { - write_exp_elt_opcode (OP_VAR_VALUE); - write_exp_elt_sym (sym); - write_exp_elt_opcode (OP_VAR_VALUE); - break; - } - for (i = 0; i < misc_function_count; i++) - if (!strcmp (misc_function_vector[i].name, name)) - break; - - if (i < misc_function_count) - { - enum misc_function_type mft = - misc_function_vector[i].type; - - write_exp_elt_opcode (OP_LONG); - write_exp_elt_type (builtin_type_int); - write_exp_elt_longcst ((LONGEST) misc_function_vector[i].address); - write_exp_elt_opcode (OP_LONG); - write_exp_elt_opcode (UNOP_MEMVAL); - if (mft == mf_data || mft == mf_bss) - write_exp_elt_type (builtin_type_int); - else if (mft == mf_text) - write_exp_elt_type (lookup_function_type (builtin_type_int)); - else - write_exp_elt_type (builtin_type_char); - write_exp_elt_opcode (UNOP_MEMVAL); - } - else - if (symtab_list == 0 - && partial_symtab_list == 0) - error ("No symbol table is loaded. Use the \"file\" command."); - else - error ("No symbol \"%s\" in current context.", name); - } - ; - -variable: name_not_typename - { struct symbol *sym = $1.sym; - - if (sym) - { - switch (SYMBOL_CLASS (sym)) - { - case LOC_REGISTER: - case LOC_ARG: - case LOC_REF_ARG: - case LOC_REGPARM: - case LOC_LOCAL: - case LOC_LOCAL_ARG: - if (innermost_block == 0 || - contained_in (block_found, - innermost_block)) - innermost_block = block_found; - case LOC_UNDEF: - case LOC_CONST: - case LOC_STATIC: - case LOC_TYPEDEF: - case LOC_LABEL: - case LOC_BLOCK: - case LOC_CONST_BYTES: - - /* In this case the expression can - be evaluated regardless of what - frame we are in, so there is no - need to check for the - innermost_block. These cases are - listed so that gcc -Wall will - report types that may not have - been considered. */ - - break; - } - write_exp_elt_opcode (OP_VAR_VALUE); - write_exp_elt_sym (sym); - write_exp_elt_opcode (OP_VAR_VALUE); - } - else if ($1.is_a_field_of_this) - { - /* C++: it hangs off of `this'. Must - not inadvertently convert from a method call - to data ref. */ - if (innermost_block == 0 || - contained_in (block_found, innermost_block)) - innermost_block = block_found; - write_exp_elt_opcode (OP_THIS); - write_exp_elt_opcode (OP_THIS); - write_exp_elt_opcode (STRUCTOP_PTR); - write_exp_string ($1.stoken); - write_exp_elt_opcode (STRUCTOP_PTR); - } - else - { - register int i; - register char *arg = copy_name ($1.stoken); - - /* FIXME, this search is linear! At least - optimize the strcmp with a 1-char cmp... */ - for (i = 0; i < misc_function_count; i++) - if (!strcmp (misc_function_vector[i].name, arg)) - break; - - if (i < misc_function_count) - { - enum misc_function_type mft = - misc_function_vector[i].type; - - write_exp_elt_opcode (OP_LONG); - write_exp_elt_type (builtin_type_int); - write_exp_elt_longcst ((LONGEST) misc_function_vector[i].address); - write_exp_elt_opcode (OP_LONG); - write_exp_elt_opcode (UNOP_MEMVAL); - if (mft == mf_data || mft == mf_bss) - write_exp_elt_type (builtin_type_int); - else if (mft == mf_text) - write_exp_elt_type (lookup_function_type (builtin_type_int)); - else - write_exp_elt_type (builtin_type_char); - write_exp_elt_opcode (UNOP_MEMVAL); - } - else if (symtab_list == 0 - && partial_symtab_list == 0) - error ("No symbol table is loaded. Use the \"file\" command."); - else - error ("No symbol \"%s\" in current context.", - copy_name ($1.stoken)); - } - } - ; - - -ptype : typebase - | typebase abs_decl - { - /* This is where the interesting stuff happens. */ - int done = 0; - int array_size; - struct type *follow_type = $1; - - while (!done) - switch (pop_type ()) - { - case tp_end: - done = 1; - break; - case tp_pointer: - follow_type = lookup_pointer_type (follow_type); - break; - case tp_reference: - follow_type = lookup_reference_type (follow_type); - break; - case tp_array: - array_size = pop_type_int (); - if (array_size != -1) - follow_type = create_array_type (follow_type, - array_size); - else - follow_type = lookup_pointer_type (follow_type); - break; - case tp_function: - follow_type = lookup_function_type (follow_type); - break; - } - $$ = follow_type; - } - ; - -abs_decl: '*' - { push_type (tp_pointer); $$ = 0; } - | '*' abs_decl - { push_type (tp_pointer); $$ = $2; } - | '&' - { push_type (tp_reference); $$ = 0; } - | '&' abs_decl - { push_type (tp_reference); $$ = $2; } - | direct_abs_decl - ; - -direct_abs_decl: '(' abs_decl ')' - { $$ = $2; } - | direct_abs_decl array_mod - { - push_type_int ($2); - push_type (tp_array); - } - | array_mod - { - push_type_int ($1); - push_type (tp_array); - $$ = 0; - } - | direct_abs_decl func_mod - { push_type (tp_function); } - | func_mod - { push_type (tp_function); } - ; - -array_mod: '[' ']' - { $$ = -1; } - | '[' INT ']' - { $$ = $2; } - ; - -func_mod: '(' ')' - { $$ = 0; } - | '(' nonempty_typelist ')' - { free ($2); $$ = 0; } - ; - -type : ptype - | typebase COLONCOLON '*' - { $$ = lookup_member_type (builtin_type_int, $1); } - | type '(' typebase COLONCOLON '*' ')' - { $$ = lookup_member_type ($1, $3); } - | type '(' typebase COLONCOLON '*' ')' '(' ')' - { $$ = lookup_member_type - (lookup_function_type ($1), $3); } - | type '(' typebase COLONCOLON '*' ')' '(' nonempty_typelist ')' - { $$ = lookup_member_type - (lookup_function_type ($1), $3); - free ($8); } - ; - -typebase - : TYPENAME - { $$ = $1.type; } - | INT_KEYWORD - { $$ = builtin_type_int; } - | LONG - { $$ = builtin_type_long; } - | SHORT - { $$ = builtin_type_short; } - | LONG INT_KEYWORD - { $$ = builtin_type_long; } - | UNSIGNED LONG INT_KEYWORD - { $$ = builtin_type_unsigned_long; } - | LONG LONG - { $$ = builtin_type_long_long; } - | LONG LONG INT_KEYWORD - { $$ = builtin_type_long_long; } - | UNSIGNED LONG LONG - { $$ = builtin_type_unsigned_long_long; } - | UNSIGNED LONG LONG INT_KEYWORD - { $$ = builtin_type_unsigned_long_long; } - | SHORT INT_KEYWORD - { $$ = builtin_type_short; } - | UNSIGNED SHORT INT_KEYWORD - { $$ = builtin_type_unsigned_short; } - | STRUCT name - { $$ = lookup_struct (copy_name ($2), - expression_context_block); } - | UNION name - { $$ = lookup_union (copy_name ($2), - expression_context_block); } - | ENUM name - { $$ = lookup_enum (copy_name ($2), - expression_context_block); } - | UNSIGNED typename - { $$ = lookup_unsigned_typename (TYPE_NAME($2.type)); } - | UNSIGNED - { $$ = builtin_type_unsigned_int; } - | SIGNED typename - { $$ = $2.type; } - | SIGNED - { $$ = builtin_type_int; } - | TEMPLATE name '<' type '>' - { $$ = lookup_template_type(copy_name($2), $4, - expression_context_block); - } - ; - -typename: TYPENAME - | INT_KEYWORD - { - $$.stoken.ptr = "int"; - $$.stoken.length = 3; - $$.type = builtin_type_int; - } - | LONG - { - $$.stoken.ptr = "long"; - $$.stoken.length = 4; - $$.type = builtin_type_long; - } - | SHORT - { - $$.stoken.ptr = "short"; - $$.stoken.length = 5; - $$.type = builtin_type_short; - } - ; - -nonempty_typelist - : type - { $$ = (struct type **)xmalloc (sizeof (struct type *) * 2); - $$[0] = (struct type *)0; - $$[1] = $1; - } - | nonempty_typelist ',' type - { int len = sizeof (struct type *) * ++($1[0]); - $$ = (struct type **)xrealloc ($1, len); - $$[$$[0]] = $3; - } - ; - -name : NAME { $$ = $1.stoken; } - | BLOCKNAME { $$ = $1.stoken; } - | TYPENAME { $$ = $1.stoken; } - | NAME_OR_INT { $$ = $1.stoken; } - | NAME_OR_UINT { $$ = $1.stoken; } - ; - -name_not_typename : NAME - | BLOCKNAME -/* These would be useful if name_not_typename was useful, but it is just - a fake for "variable", so these cause reduce/reduce conflicts because - the parser can't tell whether NAME_OR_INT is a name_not_typename (=variable, - =exp) or just an exp. If name_not_typename was ever used in an lvalue - context where only a name could occur, this might be useful. - | NAME_OR_INT - | NAME_OR_UINT - */ - ; - -%% - -/* Take care of parsing a number (anything that starts with a digit). - Set yylval and return the token type; update lexptr. - LEN is the number of characters in it. */ - -/*** Needs some error checking for the float case ***/ - -static int -parse_number (p, len, parsed_float, putithere) - register char *p; - register int len; - int parsed_float; - YYSTYPE *putithere; -{ - register LONGEST n = 0; - register LONGEST prevn = 0; - register int i; - register int c; - register int base = input_radix; - int unsigned_p = 0; - - extern double atof (); - - if (parsed_float) - { - /* It's a float since it contains a point or an exponent. */ - putithere->dval = atof (p); - return FLOAT; - } - - /* Handle base-switching prefixes 0x, 0t, 0d, 0 */ - if (p[0] == '0') - switch (p[1]) - { - case 'x': - case 'X': - if (len >= 3) - { - p += 2; - base = 16; - len -= 2; - } - break; - - case 't': - case 'T': - case 'd': - case 'D': - if (len >= 3) - { - p += 2; - base = 10; - len -= 2; - } - break; - - default: - base = 8; - break; - } - - while (len-- > 0) - { - c = *p++; - if (c >= 'A' && c <= 'Z') - c += 'a' - 'A'; - if (c != 'l' && c != 'u') - n *= base; - if (c >= '0' && c <= '9') - n += i = c - '0'; - else - { - if (base > 10 && c >= 'a' && c <= 'f') - n += i = c - 'a' + 10; - else if (len == 0 && c == 'l') - ; - else if (len == 0 && c == 'u') - unsigned_p = 1; - else - return ERROR; /* Char not a digit */ - } - if (i >= base) - return ERROR; /* Invalid digit in this base */ - if(!unsigned_p && (prevn >= n)) - unsigned_p=1; /* Try something unsigned */ - /* Don't do the range check if n==i and i==0, since that special - case will give an overflow error. */ - if(RANGE_CHECK && n!=0) - { - if((unsigned_p && (unsigned)prevn >= (unsigned)n)) - range_error("Overflow on numeric constant."); - } - prevn=n; - } - - if (unsigned_p) - { - putithere->ulval = n; - return UINT; - } - else - { - putithere->lval = n; - return INT; - } -} - -struct token -{ - char *operator; - int token; - enum exp_opcode opcode; -}; - -const static struct token tokentab3[] = - { - {">>=", ASSIGN_MODIFY, BINOP_RSH}, - {"<<=", ASSIGN_MODIFY, BINOP_LSH} - }; - -const static struct token tokentab2[] = - { - {"+=", ASSIGN_MODIFY, BINOP_ADD}, - {"-=", ASSIGN_MODIFY, BINOP_SUB}, - {"*=", ASSIGN_MODIFY, BINOP_MUL}, - {"/=", ASSIGN_MODIFY, BINOP_DIV}, - {"%=", ASSIGN_MODIFY, BINOP_REM}, - {"|=", ASSIGN_MODIFY, BINOP_LOGIOR}, - {"&=", ASSIGN_MODIFY, BINOP_LOGAND}, - {"^=", ASSIGN_MODIFY, BINOP_LOGXOR}, - {"++", INCREMENT, BINOP_END}, - {"--", DECREMENT, BINOP_END}, - {"->", ARROW, BINOP_END}, - {"&&", AND, BINOP_END}, - {"||", OR, BINOP_END}, - {"::", COLONCOLON, BINOP_END}, - {"<<", LSH, BINOP_END}, - {">>", RSH, BINOP_END}, - {"==", EQUAL, BINOP_END}, - {"!=", NOTEQUAL, BINOP_END}, - {"<=", LEQ, BINOP_END}, - {">=", GEQ, BINOP_END} - }; - -/* Read one token, getting characters through lexptr. */ - -int -yylex () -{ - register int c; - register int namelen; - register unsigned i; - register char *tokstart; - - retry: - - tokstart = lexptr; - /* See if it is a special token of length 3. */ - for (i = 0; i < sizeof tokentab3 / sizeof tokentab3[0]; i++) - if (!strncmp (tokstart, tokentab3[i].operator, 3)) - { - lexptr += 3; - yylval.opcode = tokentab3[i].opcode; - return tokentab3[i].token; - } - - /* See if it is a special token of length 2. */ - for (i = 0; i < sizeof tokentab2 / sizeof tokentab2[0]; i++) - if (!strncmp (tokstart, tokentab2[i].operator, 2)) - { - lexptr += 2; - yylval.opcode = tokentab2[i].opcode; - return tokentab2[i].token; - } - - switch (c = *tokstart) - { - case 0: - return 0; - - case ' ': - case '\t': - case '\n': - lexptr++; - goto retry; - - case '\'': - lexptr++; - c = *lexptr++; - if (c == '\\') - c = parse_escape (&lexptr); - yylval.lval = c; - c = *lexptr++; - if (c != '\'') - error ("Invalid character constant."); - return CHAR; - - case '(': - paren_depth++; - lexptr++; - return c; - - case ')': - if (paren_depth == 0) - return 0; - paren_depth--; - lexptr++; - return c; - - case ',': - if (comma_terminates && paren_depth == 0) - return 0; - lexptr++; - return c; - - case '.': - /* Might be a floating point number. */ - if (lexptr[1] < '0' || lexptr[1] > '9') - goto symbol; /* Nope, must be a symbol. */ - /* FALL THRU into number case. */ - - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - { - /* It's a number. */ - int got_dot = 0, got_e = 0, toktype; - register char *p = tokstart; - int hex = input_radix > 10; - - if (c == '0' && (p[1] == 'x' || p[1] == 'X')) - { - p += 2; - hex = 1; - } - else if (c == '0' && (p[1]=='t' || p[1]=='T' || p[1]=='d' || p[1]=='D')) - { - p += 2; - hex = 0; - } - - for (;; ++p) - { - if (!hex && !got_e && (*p == 'e' || *p == 'E')) - got_dot = got_e = 1; - else if (!hex && !got_dot && *p == '.') - got_dot = 1; - else if (got_e && (p[-1] == 'e' || p[-1] == 'E') - && (*p == '-' || *p == '+')) - /* This is the sign of the exponent, not the end of the - number. */ - continue; - /* We will take any letters or digits. parse_number will - complain if past the radix, or if L or U are not final. */ - else if ((*p < '0' || *p > '9') - && ((*p < 'a' || *p > 'z') - && (*p < 'A' || *p > 'Z'))) - break; - } - toktype = parse_number (tokstart, p - tokstart, got_dot|got_e, &yylval); - if (toktype == ERROR) - { - char *err_copy = (char *) alloca (p - tokstart + 1); - - bcopy (tokstart, err_copy, p - tokstart); - err_copy[p - tokstart] = 0; - error ("Invalid number \"%s\".", err_copy); - } - lexptr = p; - return toktype; - } - - case '+': - case '-': - case '*': - case '/': - case '%': - case '|': - case '&': - case '^': - case '~': - case '!': - case '@': - case '<': - case '>': - case '[': - case ']': - case '?': - case ':': - case '=': - case '{': - case '}': - symbol: - lexptr++; - return c; - - case '"': - for (namelen = 1; (c = tokstart[namelen]) != '"'; namelen++) - if (c == '\\') - { - c = tokstart[++namelen]; - if (c >= '0' && c <= '9') - { - c = tokstart[++namelen]; - if (c >= '0' && c <= '9') - c = tokstart[++namelen]; - } - } - yylval.sval.ptr = tokstart + 1; - yylval.sval.length = namelen - 1; - lexptr += namelen + 1; - return STRING; - } - - if (!(c == '_' || c == '$' - || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))) - /* We must have come across a bad character (e.g. ';'). */ - error ("Invalid character '%c' in expression.", c); - - /* It's a name. See how long it is. */ - namelen = 0; - for (c = tokstart[namelen]; - (c == '_' || c == '$' || (c >= '0' && c <= '9') - || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')); - c = tokstart[++namelen]) - ; - - /* The token "if" terminates the expression and is NOT - removed from the input stream. */ - if (namelen == 2 && tokstart[0] == 'i' && tokstart[1] == 'f') - { - return 0; - } - - lexptr += namelen; - - /* Handle the tokens $digits; also $ (short for $0) and $$ (short for $$1) - and $$digits (equivalent to $<-digits> if you could type that). - Make token type LAST, and put the number (the digits) in yylval. */ - - if (*tokstart == '$') - { - register int negate = 0; - c = 1; - /* Double dollar means negate the number and add -1 as well. - Thus $$ alone means -1. */ - if (namelen >= 2 && tokstart[1] == '$') - { - negate = 1; - c = 2; - } - if (c == namelen) - { - /* Just dollars (one or two) */ - yylval.lval = - negate; - return LAST; - } - /* Is the rest of the token digits? */ - for (; c < namelen; c++) - if (!(tokstart[c] >= '0' && tokstart[c] <= '9')) - break; - if (c == namelen) - { - yylval.lval = atoi (tokstart + 1 + negate); - if (negate) - yylval.lval = - yylval.lval; - return LAST; - } - } - - /* Handle tokens that refer to machine registers: - $ followed by a register name. */ - - if (*tokstart == '$') { - for (c = 0; c < NUM_REGS; c++) - if (namelen - 1 == strlen (reg_names[c]) - && !strncmp (tokstart + 1, reg_names[c], namelen - 1)) - { - yylval.lval = c; - return REGNAME; - } - for (c = 0; c < num_std_regs; c++) - if (namelen - 1 == strlen (std_regs[c].name) - && !strncmp (tokstart + 1, std_regs[c].name, namelen - 1)) - { - yylval.lval = std_regs[c].regnum; - return REGNAME; - } - } - /* Catch specific keywords. Should be done with a data structure. */ - switch (namelen) - { - case 8: - if (!strncmp (tokstart, "unsigned", 8)) - return UNSIGNED; - if (!strncmp (tokstart, "template", 8)) - return TEMPLATE; - break; - case 6: - if (!strncmp (tokstart, "struct", 6)) - return STRUCT; - if (!strncmp (tokstart, "signed", 6)) - return SIGNED; - if (!strncmp (tokstart, "sizeof", 6)) - return SIZEOF; - break; - case 5: - if (!strncmp (tokstart, "union", 5)) - return UNION; - if (!strncmp (tokstart, "short", 5)) - return SHORT; - break; - case 4: - if (!strncmp (tokstart, "enum", 4)) - return ENUM; - if (!strncmp (tokstart, "long", 4)) - return LONG; - if (!strncmp (tokstart, "this", 4)) - { - static const char this_name[] = - { CPLUS_MARKER, 't', 'h', 'i', 's', '\0' }; - - if (lookup_symbol (this_name, expression_context_block, - VAR_NAMESPACE, 0, NULL)) - return THIS; - } - break; - case 3: - if (!strncmp (tokstart, "int", 3)) - return INT_KEYWORD; - break; - default: - break; - } - - yylval.sval.ptr = tokstart; - yylval.sval.length = namelen; - - /* Any other names starting in $ are debugger internal variables. */ - - if (*tokstart == '$') - { - yylval.ivar = lookup_internalvar (copy_name (yylval.sval) + 1); - return VARIABLE; - } - - /* Use token-type BLOCKNAME for symbols that happen to be defined as - functions or symtabs. If this is not so, then ... - Use token-type TYPENAME for symbols that happen to be defined - currently as names of types; NAME for other symbols. - The caller is not constrained to care about the distinction. */ - { - char *tmp = copy_name (yylval.sval); - struct symbol *sym; - int is_a_field_of_this = 0; - int hextype; - - sym = lookup_symbol (tmp, expression_context_block, - VAR_NAMESPACE, - current_language->la_language == language_cplus - ? &is_a_field_of_this : NULL, - NULL); - if ((sym && SYMBOL_CLASS (sym) == LOC_BLOCK) || - lookup_partial_symtab (tmp)) - { - yylval.ssym.sym = sym; - yylval.ssym.is_a_field_of_this = is_a_field_of_this; - return BLOCKNAME; - } - if (sym && SYMBOL_CLASS (sym) == LOC_TYPEDEF) - { - yylval.tsym.type = SYMBOL_TYPE (sym); - return TYPENAME; - } - if ((yylval.tsym.type = lookup_primitive_typename (tmp)) != 0) - return TYPENAME; - - /* Input names that aren't symbols but ARE valid hex numbers, - when the input radix permits them, can be names or numbers - depending on the parse. Note we support radixes > 16 here. */ - if (!sym && - ((tokstart[0] >= 'a' && tokstart[0] < 'a' + input_radix - 10) || - (tokstart[0] >= 'A' && tokstart[0] < 'A' + input_radix - 10))) - { - YYSTYPE newlval; /* Its value is ignored. */ - hextype = parse_number (tokstart, namelen, 0, &newlval); - if (hextype == INT) - { - yylval.ssym.sym = sym; - yylval.ssym.is_a_field_of_this = is_a_field_of_this; - return NAME_OR_INT; - } - if (hextype == UINT) - { - yylval.ssym.sym = sym; - yylval.ssym.is_a_field_of_this = is_a_field_of_this; - return NAME_OR_UINT; - } - } - - /* Any other kind of symbol */ - yylval.ssym.sym = sym; - yylval.ssym.is_a_field_of_this = is_a_field_of_this; - return NAME; - } -} - -void -yyerror (msg) - char *msg; -{ - error (msg ? msg : "Invalid syntax in expression."); -} - -/* Table mapping opcodes into strings for printing operators - and precedences of the operators. */ - -const static struct op_print c_op_print_tab[] = - { - {",", BINOP_COMMA, PREC_COMMA, 0}, - {"=", BINOP_ASSIGN, PREC_ASSIGN, 1}, - {"||", BINOP_OR, PREC_OR, 0}, - {"&&", BINOP_AND, PREC_AND, 0}, - {"|", BINOP_LOGIOR, PREC_LOGIOR, 0}, - {"&", BINOP_LOGAND, PREC_LOGAND, 0}, - {"^", BINOP_LOGXOR, PREC_LOGXOR, 0}, - {"==", BINOP_EQUAL, PREC_EQUAL, 0}, - {"!=", BINOP_NOTEQUAL, PREC_EQUAL, 0}, - {"<=", BINOP_LEQ, PREC_ORDER, 0}, - {">=", BINOP_GEQ, PREC_ORDER, 0}, - {">", BINOP_GTR, PREC_ORDER, 0}, - {"<", BINOP_LESS, PREC_ORDER, 0}, - {">>", BINOP_RSH, PREC_SHIFT, 0}, - {"<<", BINOP_LSH, PREC_SHIFT, 0}, - {"+", BINOP_ADD, PREC_ADD, 0}, - {"-", BINOP_SUB, PREC_ADD, 0}, - {"*", BINOP_MUL, PREC_MUL, 0}, - {"/", BINOP_DIV, PREC_MUL, 0}, - {"%", BINOP_REM, PREC_MUL, 0}, - {"@", BINOP_REPEAT, PREC_REPEAT, 0}, - {"-", UNOP_NEG, PREC_PREFIX, 0}, - {"!", UNOP_ZEROP, PREC_PREFIX, 0}, - {"~", UNOP_LOGNOT, PREC_PREFIX, 0}, - {"*", UNOP_IND, PREC_PREFIX, 0}, - {"&", UNOP_ADDR, PREC_PREFIX, 0}, - {"sizeof ", UNOP_SIZEOF, PREC_PREFIX, 0}, - {"++", UNOP_PREINCREMENT, PREC_PREFIX, 0}, - {"--", UNOP_PREDECREMENT, PREC_PREFIX, 0}, - /* C++ */ - {"::", BINOP_SCOPE, PREC_PREFIX, 0}, -}; - -/* These variables point to the objects - representing the predefined C data types. */ - -struct type *builtin_type_void; -struct type *builtin_type_char; -struct type *builtin_type_short; -struct type *builtin_type_int; -struct type *builtin_type_long; -struct type *builtin_type_long_long; -struct type *builtin_type_unsigned_char; -struct type *builtin_type_unsigned_short; -struct type *builtin_type_unsigned_int; -struct type *builtin_type_unsigned_long; -struct type *builtin_type_unsigned_long_long; -struct type *builtin_type_float; -struct type *builtin_type_double; -struct type *builtin_type_long_double; -struct type *builtin_type_complex; -struct type *builtin_type_double_complex; - -struct type ** const (c_builtin_types[]) = -{ - &builtin_type_int, - &builtin_type_long, - &builtin_type_short, - &builtin_type_char, - &builtin_type_float, - &builtin_type_double, - &builtin_type_void, - &builtin_type_long_long, - &builtin_type_unsigned_char, - &builtin_type_unsigned_short, - &builtin_type_unsigned_int, - &builtin_type_unsigned_long, - &builtin_type_unsigned_long_long, - &builtin_type_long_double, - &builtin_type_complex, - &builtin_type_double_complex, - 0 -}; - -const struct language_defn c_language_defn = { - "c", /* Language name */ - language_c, - c_builtin_types, - range_check_off, - type_check_off, - c_parse, - c_error, - &BUILTIN_TYPE_LONGEST, /* longest signed integral type */ - &BUILTIN_TYPE_UNSIGNED_LONGEST,/* longest unsigned integral type */ - &builtin_type_double, /* longest floating point type */ /*FIXME*/ - "0x%x", "0x%", "x", /* Hex format, prefix, suffix */ - "0%o", "0%", "o", /* Octal format, prefix, suffix */ - c_op_print_tab, /* expression operators for printing */ - LANG_MAGIC -}; - -const struct language_defn cplus_language_defn = { - "c++", /* Language name */ - language_cplus, - c_builtin_types, - range_check_off, - type_check_off, - c_parse, - c_error, - &BUILTIN_TYPE_LONGEST, /* longest signed integral type */ - &BUILTIN_TYPE_UNSIGNED_LONGEST,/* longest unsigned integral type */ - &builtin_type_double, /* longest floating point type */ /*FIXME*/ - "0x%x", "0x%", "x", /* Hex format, prefix, suffix */ - "0%o", "0%", "o", /* Octal format, prefix, suffix */ - c_op_print_tab, /* expression operators for printing */ - LANG_MAGIC -}; - -void -_initialize_c_exp () -{ - builtin_type_void = - init_type (TYPE_CODE_VOID, 1, 0, - "void"); - builtin_type_char = - init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT, 0, - "char"); - builtin_type_unsigned_char = - init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT, 1, - "unsigned char"); - builtin_type_short = - init_type (TYPE_CODE_INT, TARGET_SHORT_BIT / TARGET_CHAR_BIT, 0, - "short"); - builtin_type_unsigned_short = - init_type (TYPE_CODE_INT, TARGET_SHORT_BIT / TARGET_CHAR_BIT, 1, - "unsigned short"); - builtin_type_int = - init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT, 0, - "int"); - builtin_type_unsigned_int = - init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT, 1, - "unsigned int"); - builtin_type_long = - init_type (TYPE_CODE_INT, TARGET_LONG_BIT / TARGET_CHAR_BIT, 0, - "long"); - builtin_type_unsigned_long = - init_type (TYPE_CODE_INT, TARGET_LONG_BIT / TARGET_CHAR_BIT, 1, - "unsigned long"); - builtin_type_long_long = - init_type (TYPE_CODE_INT, TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT, 0, - "long long"); - builtin_type_unsigned_long_long = - init_type (TYPE_CODE_INT, TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT, 1, - "unsigned long long"); - builtin_type_float = - init_type (TYPE_CODE_FLT, TARGET_FLOAT_BIT / TARGET_CHAR_BIT, 0, - "float"); - builtin_type_double = - init_type (TYPE_CODE_FLT, TARGET_DOUBLE_BIT / TARGET_CHAR_BIT, 0, - "double"); - builtin_type_long_double = - init_type (TYPE_CODE_FLT, TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT, 0, - "long double"); - builtin_type_complex = - init_type (TYPE_CODE_FLT, TARGET_COMPLEX_BIT / TARGET_CHAR_BIT, 0, - "complex"); - builtin_type_double_complex = - init_type (TYPE_CODE_FLT, TARGET_DOUBLE_COMPLEX_BIT / TARGET_CHAR_BIT, 0, - "double complex"); - - add_language (&c_language_defn); - add_language (&cplus_language_defn); -} diff --git a/gdb/coffread.c b/gdb/coffread.c deleted file mode 100644 index 4b9f2451cef..00000000000 --- a/gdb/coffread.c +++ /dev/null @@ -1,2067 +0,0 @@ -/* Read coff symbol tables and convert to internal format, for GDB. - Contributed by David D. Johnson, Brown University (ddj@cs.brown.edu). - Copyright (C) 1987-1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "defs.h" -#include "param.h" -#include "symtab.h" -#include "breakpoint.h" -#include "bfd.h" -#include "symfile.h" - -#include -#include - -#include "internalcoff.h" /* Internal format of COFF symbols in BFD */ -#include "libcoff.h" /* FIXME secret internal data from BFD */ - -static void add_symbol_to_list (); -static void read_coff_symtab (); -static void patch_opaque_types (); -static struct type *decode_function_type (); -static struct type *decode_type (); -static struct type *decode_base_type (); -static struct type *read_enum_type (); -static struct type *read_struct_type (); -static void finish_block (); -static struct blockvector *make_blockvector (); -static struct symbol *process_coff_symbol (); -static int init_stringtab (); -static void free_stringtab (); -static char *getfilename (); -static char *getsymname (); -static int init_lineno (); -static void enter_linenos (); -static void read_one_sym (); - -extern int fclose (); - -/* To be an sdb debug type, type must have at least a basic or primary - derived type. Using this rather than checking against T_NULL is - said to prevent core dumps if we try to operate on Michael Bloom - dbx-in-coff file. */ - -#define SDB_TYPE(type) (BTYPE(type) | (type & N_TMASK)) - -/* - * Convert from an sdb register number to an internal gdb register number. - * This should be defined in tm.h, if REGISTER_NAMES is not set up - * to map one to one onto the sdb register numbers. - */ -#ifndef SDB_REG_TO_REGNUM -# define SDB_REG_TO_REGNUM(value) (value) -#endif - -/* Name of source file whose symbol data we are now processing. - This comes from a symbol named ".file". */ - -static char *last_source_file; - -/* Core address of start and end of text of current source file. - This comes from a ".text" symbol where x_nlinno > 0. */ - -static CORE_ADDR cur_src_start_addr; -static CORE_ADDR cur_src_end_addr; - -/* Core address of the end of the first object file. */ -static CORE_ADDR first_object_file_end; - -/* The addresses of the symbol table stream and number of symbols - of the object file we are reading (as copied into core). */ - -static FILE *nlist_stream_global; -static int nlist_nsyms_global; - -/* The index in the symbol table of the last coff symbol that was processed. */ - -static int symnum; - -/* Vector of types defined so far, indexed by their coff symnum. */ - -static struct type **type_vector; - -/* Number of elements allocated for type_vector currently. */ - -static int type_vector_length; - -/* Vector of line number information. */ - -static struct linetable *line_vector; - -/* Index of next entry to go in line_vector_index. */ - -static int line_vector_index; - -/* Last line number recorded in the line vector. */ - -static int prev_line_number; - -/* Number of elements allocated for line_vector currently. */ - -static int line_vector_length; - -/* Pointers to scratch storage, used for reading raw symbols and auxents. */ - -static char *temp_sym; -static char *temp_aux; - -/* Local variables that hold the shift and mask values for the - COFF file that we are currently reading. These come back to us - from BFD, and are referenced by their macro names, as well as - internally to the BTYPE, ISPTR, ISFCN, ISARY, ISTAG, and DECREF - macros from ../internalcoff.h . */ - -static unsigned local_n_btmask; -static unsigned local_n_btshft; -static unsigned local_n_tmask; -static unsigned local_n_tshift; - -#define N_BTMASK local_n_btmask -#define N_BTSHFT local_n_btshft -#define N_TMASK local_n_tmask -#define N_TSHIFT local_n_tshift - -/* Local variables that hold the sizes in the file of various COFF structures. - (We only need to know this to read them from the file -- BFD will then - translate the data in them, into `internal_xxx' structs in the right - byte order, alignment, etc.) */ - -static unsigned local_linesz; -static unsigned local_symesz; -static unsigned local_auxesz; - - -/* Chain of typedefs of pointers to empty struct/union types. - They are chained thru the SYMBOL_VALUE_CHAIN. */ - -#define HASHSIZE 127 -static struct symbol *opaque_type_chain[HASHSIZE]; - -/* Record the symbols defined for each context in a list. - We don't create a struct block for the context until we - know how long to make it. */ - -struct pending -{ - struct pending *next; - struct symbol *symbol; -}; - -/* Here are the three lists that symbols are put on. */ - -struct pending *file_symbols; /* static at top level, and types */ - -struct pending *global_symbols; /* global functions and variables */ - -struct pending *local_symbols; /* everything local to lexical context */ - -/* List of unclosed lexical contexts - (that will become blocks, eventually). */ - -struct context_stack -{ - struct context_stack *next; - struct pending *locals; - struct pending_block *old_blocks; - struct symbol *name; - CORE_ADDR start_addr; - int depth; -}; - -struct context_stack *context_stack; - -/* Nonzero if within a function (so symbols should be local, - if nothing says specifically). */ - -int within_function; - -#if 0 -/* The type of the function we are currently reading in. This is - used by define_symbol to record the type of arguments to a function. */ - -struct type *in_function_type; -#endif - -/* List of blocks already made (lexical contexts already closed). - This is used at the end to make the blockvector. */ - -struct pending_block -{ - struct pending_block *next; - struct block *block; -}; - -struct pending_block *pending_blocks; - -extern CORE_ADDR startup_file_start; /* From blockframe.c */ -extern CORE_ADDR startup_file_end; /* From blockframe.c */ - -/* Complaints about various problems in the file being read */ - -struct complaint ef_complaint = - {"Unmatched .ef symbol(s) ignored starting at symnum %d", 0, 0}; - -struct complaint no_aux_complaint = - {"symbol %d without one aux entry", 0, 0}; - -struct complaint lineno_complaint = - {"Line number pointer %d lower than start of line numbers", 0, 0}; - - -/* Look up a coff type-number index. Return the address of the slot - where the type for that index is stored. - The type-number is in INDEX. - - This can be used for finding the type associated with that index - or for associating a new type with the index. */ - -static struct type ** -coff_lookup_type (index) - register int index; -{ - if (index >= type_vector_length) - { - int old_vector_length = type_vector_length; - - type_vector_length *= 2; - if (type_vector_length < index) { - type_vector_length = index * 2; - } - type_vector = (struct type **) - xrealloc (type_vector, type_vector_length * sizeof (struct type *)); - bzero (&type_vector[old_vector_length], - (type_vector_length - old_vector_length) * sizeof(struct type *)); - } - return &type_vector[index]; -} - -/* Make sure there is a type allocated for type number index - and return the type object. - This can create an empty (zeroed) type object. */ - -static struct type * -coff_alloc_type (index) - int index; -{ - register struct type **type_addr = coff_lookup_type (index); - register struct type *type = *type_addr; - - /* If we are referring to a type not known at all yet, - allocate an empty type for it. - We will fill it in later if we find out how. */ - if (type == 0) - { - type = (struct type *) obstack_alloc (symbol_obstack, - sizeof (struct type)); - bzero (type, sizeof (struct type)); - TYPE_VPTR_FIELDNO (type) = -1; - *type_addr = type; - } - return type; -} - -/* maintain the lists of symbols and blocks */ - -/* Add a symbol to one of the lists of symbols. */ -static void -add_symbol_to_list (symbol, listhead) - struct symbol *symbol; - struct pending **listhead; -{ - register struct pending *link - = (struct pending *) xmalloc (sizeof (struct pending)); - - link->next = *listhead; - link->symbol = symbol; - *listhead = link; -} - -/* Take one of the lists of symbols and make a block from it. - Put the block on the list of pending blocks. */ - -static void -finish_block (symbol, listhead, old_blocks, start, end) - struct symbol *symbol; - struct pending **listhead; - struct pending_block *old_blocks; - CORE_ADDR start, end; -{ - register struct pending *next, *next1; - register struct block *block; - register struct pending_block *pblock; - struct pending_block *opblock; - register int i; - - /* Count the length of the list of symbols. */ - - for (next = *listhead, i = 0; next; next = next->next, i++); - - block = (struct block *) - obstack_alloc (symbol_obstack, sizeof (struct block) + (i - 1) * sizeof (struct symbol *)); - - /* Copy the symbols into the block. */ - - BLOCK_NSYMS (block) = i; - for (next = *listhead; next; next = next->next) - BLOCK_SYM (block, --i) = next->symbol; - - BLOCK_START (block) = start; - BLOCK_END (block) = end; - BLOCK_SUPERBLOCK (block) = 0; /* Filled in when containing block is made */ - - /* Put the block in as the value of the symbol that names it. */ - - if (symbol) - { - SYMBOL_BLOCK_VALUE (symbol) = block; - BLOCK_FUNCTION (block) = symbol; - } - else - BLOCK_FUNCTION (block) = 0; - - /* Now free the links of the list, and empty the list. */ - - for (next = *listhead; next; next = next1) - { - next1 = next->next; - free (next); - } - *listhead = 0; - - /* Install this block as the superblock - of all blocks made since the start of this scope - that don't have superblocks yet. */ - - opblock = 0; - for (pblock = pending_blocks; pblock != old_blocks; pblock = pblock->next) - { - if (BLOCK_SUPERBLOCK (pblock->block) == 0) - BLOCK_SUPERBLOCK (pblock->block) = block; - opblock = pblock; - } - - /* Record this block on the list of all blocks in the file. - Put it after opblock, or at the beginning if opblock is 0. - This puts the block in the list after all its subblocks. */ - - pblock = (struct pending_block *) xmalloc (sizeof (struct pending_block)); - pblock->block = block; - if (opblock) - { - pblock->next = opblock->next; - opblock->next = pblock; - } - else - { - pblock->next = pending_blocks; - pending_blocks = pblock; - } -} - -static struct blockvector * -make_blockvector () -{ - register struct pending_block *next, *next1; - register struct blockvector *blockvector; - register int i; - - /* Count the length of the list of blocks. */ - - for (next = pending_blocks, i = 0; next; next = next->next, i++); - - blockvector = (struct blockvector *) - obstack_alloc (symbol_obstack, sizeof (struct blockvector) + (i - 1) * sizeof (struct block *)); - - /* Copy the blocks into the blockvector. - This is done in reverse order, which happens to put - the blocks into the proper order (ascending starting address). - finish_block has hair to insert each block into the list - after its subblocks in order to make sure this is true. */ - - BLOCKVECTOR_NBLOCKS (blockvector) = i; - for (next = pending_blocks; next; next = next->next) - BLOCKVECTOR_BLOCK (blockvector, --i) = next->block; - - /* Now free the links of the list, and empty the list. */ - - for (next = pending_blocks; next; next = next1) - { - next1 = next->next; - free (next); - } - pending_blocks = 0; - - return blockvector; -} - -/* Manage the vector of line numbers. */ - -static void -record_line (line, pc) - int line; - CORE_ADDR pc; -{ - struct linetable_entry *e; - /* Make sure line vector is big enough. */ - - if (line_vector_index + 2 >= line_vector_length) - { - line_vector_length *= 2; - line_vector = (struct linetable *) - xrealloc (line_vector, sizeof (struct linetable) - + (line_vector_length - * sizeof (struct linetable_entry))); - } - - e = line_vector->item + line_vector_index++; - e->line = line; e->pc = pc; -} - -/* Start a new symtab for a new source file. - This is called when a COFF ".file" symbol is seen; - it indicates the start of data for one original source file. */ - -static void -start_symtab () -{ - file_symbols = 0; - global_symbols = 0; - context_stack = 0; - within_function = 0; - last_source_file = 0; - - /* Initialize the source file line number information for this file. */ - - if (line_vector) /* Unlikely, but maybe possible? */ - free (line_vector); - line_vector_index = 0; - line_vector_length = 1000; - prev_line_number = -2; /* Force first line number to be explicit */ - line_vector = (struct linetable *) - xmalloc (sizeof (struct linetable) - + line_vector_length * sizeof (struct linetable_entry)); -} - -/* Save the vital information from when starting to read a file, - for use when closing off the current file. - NAME is the file name the symbols came from, START_ADDR is the first - text address for the file, and SIZE is the number of bytes of text. */ - -static void -complete_symtab (name, start_addr, size) - char *name; - CORE_ADDR start_addr; - unsigned int size; -{ - last_source_file = savestring (name, strlen (name)); - cur_src_start_addr = start_addr; - cur_src_end_addr = start_addr + size; - - if (entry_point < cur_src_end_addr - && entry_point >= cur_src_start_addr) - { - startup_file_start = cur_src_start_addr; - startup_file_end = cur_src_end_addr; - } -} - -/* Finish the symbol definitions for one main source file, - close off all the lexical contexts for that file - (creating struct block's for them), then make the - struct symtab for that file and put it in the list of all such. */ - -static void -end_symtab (objfile) - struct objfile *objfile; -{ - register struct symtab *symtab; - register struct context_stack *cstk; - register struct blockvector *blockvector; - register struct linetable *lv; - - /* Finish the lexical context of the last function in the file. */ - - if (context_stack) - { - cstk = context_stack; - context_stack = 0; - /* Make a block for the local symbols within. */ - finish_block (cstk->name, &local_symbols, cstk->old_blocks, - cstk->start_addr, cur_src_end_addr); - free (cstk); - } - - /* Ignore a file that has no functions with real debugging info. */ - if (pending_blocks == 0 && file_symbols == 0 && global_symbols == 0) - { - free (line_vector); - line_vector = 0; - line_vector_length = -1; - last_source_file = 0; - return; - } - - /* Create the two top-level blocks for this file (STATIC_BLOCK and - GLOBAL_BLOCK). */ - finish_block (0, &file_symbols, 0, cur_src_start_addr, cur_src_end_addr); - finish_block (0, &global_symbols, 0, cur_src_start_addr, cur_src_end_addr); - - /* Create the blockvector that points to all the file's blocks. */ - blockvector = make_blockvector (); - - /* Now create the symtab object for this source file. */ - symtab = allocate_symtab (last_source_file, objfile); - - /* Fill in its components. */ - symtab->blockvector = blockvector; - symtab->free_code = free_linetable; - symtab->free_ptr = 0; - symtab->filename = last_source_file; - symtab->dirname = NULL; - lv = line_vector; - lv->nitems = line_vector_index; - symtab->linetable = (struct linetable *) - xrealloc (lv, (sizeof (struct linetable) - + lv->nitems * sizeof (struct linetable_entry))); - - free_named_symtabs (symtab->filename); - - /* Link the new symtab into the list of such. */ - symtab->next = symtab_list; - symtab_list = symtab; - - /* Reinitialize for beginning of new file. */ - line_vector = 0; - line_vector_length = -1; - last_source_file = 0; -} - -static void -record_misc_function (name, address) - char *name; - CORE_ADDR address; -{ - /* We don't want TDESC entry points on the misc_function_vector */ - if (name[0] == '@') return; - - /* mf_text isn't true, but apparently COFF doesn't tell us what it really - is, so this guess is more useful than mf_unknown. */ - prim_record_misc_function (savestring (name, strlen (name)), - address, - (int)mf_text); -} - -/* coff_symfile_init () - is the coff-specific initialization routine for reading symbols. - It is passed a struct sym_fns which contains, among other things, - the BFD for the file whose symbols are being read, and a slot for - a pointer to "private data" which we fill with cookies and other - treats for coff_symfile_read (). - - We will only be called if this is a COFF or COFF-like file. - BFD handles figuring out the format of the file, and code in symtab.c - uses BFD's determination to vector to us. - - The ultimate result is a new symtab (or, FIXME, eventually a psymtab). */ - -struct coff_symfile_info { - file_ptr min_lineno_offset; /* Where in file lowest line#s are */ - file_ptr max_lineno_offset; /* 1+last byte of line#s in file */ -}; - -static int text_bfd_scnum; - -static void -coff_symfile_init (sf) - struct sym_fns *sf; -{ - asection *section; - bfd *abfd = sf->sym_bfd; - - /* Allocate struct to keep track of the symfile */ - /* FIXME memory leak */ - sf->sym_private = xmalloc (sizeof (struct coff_symfile_info)); - - /* Save startup file's range of PC addresses to help blockframe.c - decide where the bottom of the stack is. */ - if (bfd_get_file_flags (abfd) & EXEC_P) - { - /* Executable file -- record its entry point so we'll recognize - the startup file because it contains the entry point. */ - entry_point = bfd_get_start_address (abfd); - } - else - { - /* Examination of non-executable.o files. Short-circuit this stuff. */ - /* ~0 will not be in any file, we hope. */ - entry_point = ~0; - /* set the startup file to be an empty range. */ - startup_file_start = 0; - startup_file_end = 0; - } - /* Save the section number for the text section */ - if (section = bfd_get_section_by_name(abfd,".text")) - text_bfd_scnum = section->index; - else - text_bfd_scnum = -1; -} - -/* This function is called for every section; it finds the outer limits - of the line table (minimum and maximum file offset) so that the - mainline code can read the whole thing for efficiency. */ - -/* ARGSUSED */ -static void -find_linenos (abfd, asect, vpinfo) - bfd *abfd; - sec_ptr asect; - void *vpinfo; -{ - struct coff_symfile_info *info; - int size, count; - file_ptr offset, maxoff; - -/* WARNING WILL ROBINSON! ACCESSING BFD-PRIVATE DATA HERE! FIXME! */ - count = asect->lineno_count; -/* End of warning */ - - if (count == 0) - return; - size = count * local_linesz; - - info = (struct coff_symfile_info *)vpinfo; -/* WARNING WILL ROBINSON! ACCESSING BFD-PRIVATE DATA HERE! FIXME! */ - offset = asect->line_filepos; -/* End of warning */ - - if (offset < info->min_lineno_offset || info->min_lineno_offset == 0) - info->min_lineno_offset = offset; - - maxoff = offset + size; - if (maxoff > info->max_lineno_offset) - info->max_lineno_offset = maxoff; -} - - -/* The BFD for this file -- only good while we're actively reading - symbols into a psymtab or a symtab. */ - -static bfd *symfile_bfd; - -/* Read a symbol file, after initialization by coff_symfile_init. */ -/* FIXME! Addr and Mainline are not used yet -- this will not work for - shared libraries or add_file! */ - -/* ARGSUSED */ -static void -coff_symfile_read (sf, addr, mainline) - struct sym_fns *sf; - CORE_ADDR addr; - int mainline; -{ - struct coff_symfile_info *info = (struct coff_symfile_info *)sf->sym_private; - bfd *abfd = sf->objfile->obfd; - coff_data_type *cdata = coff_data (abfd); - char *name = bfd_get_filename (abfd); - int desc; - register int val; - int num_symbols; - int symtab_offset; - int stringtab_offset; - - symfile_bfd = abfd; /* Kludge for swap routines */ - -/* WARNING WILL ROBINSON! ACCESSING BFD-PRIVATE DATA HERE! FIXME! */ - desc = fileno ((FILE *)(abfd->iostream)); /* File descriptor */ - num_symbols = bfd_get_symcount (abfd); /* How many syms */ - symtab_offset = cdata->sym_filepos; /* Symbol table file offset */ - stringtab_offset = symtab_offset + /* String table file offset */ - num_symbols * cdata->local_symesz; - - /* Set a few file-statics that give us specific information about - the particular COFF file format we're reading. */ - local_linesz = cdata->local_linesz; - local_n_btmask = cdata->local_n_btmask; - local_n_btshft = cdata->local_n_btshft; - local_n_tmask = cdata->local_n_tmask; - local_n_tshift = cdata->local_n_tshift; - local_linesz = cdata->local_linesz; - local_symesz = cdata->local_symesz; - local_auxesz = cdata->local_auxesz; - - /* Allocate space for raw symbol and aux entries, based on their - space requirements as reported by BFD. */ - temp_sym = (char *) xmalloc - (cdata->local_symesz + cdata->local_auxesz); - temp_aux = temp_sym + cdata->local_symesz; - make_cleanup (free_current_contents, &temp_sym); -/* End of warning */ - - /* Read the line number table, all at once. */ - info->min_lineno_offset = 0; - info->max_lineno_offset = 0; - bfd_map_over_sections (abfd, find_linenos, info); - - val = init_lineno (desc, info->min_lineno_offset, - info->max_lineno_offset - info->min_lineno_offset); - if (val < 0) - error ("\"%s\": error reading line numbers\n", name); - - /* Now read the string table, all at once. */ - - val = init_stringtab (desc, stringtab_offset); - if (val < 0) - error ("\"%s\": can't get string table", name); - make_cleanup (free_stringtab, 0); - - /* Position to read the symbol table. Do not read it all at once. */ - val = lseek (desc, (long)symtab_offset, 0); - if (val < 0) - perror_with_name (name); - - init_misc_bunches (); - make_cleanup (discard_misc_bunches, 0); - - /* Now that the executable file is positioned at symbol table, - process it and define symbols accordingly. */ - - read_coff_symtab (desc, num_symbols, sf->objfile); - - patch_opaque_types (); - - /* Sort symbols alphabetically within each block. */ - - sort_all_symtab_syms (); - - /* Go over the misc symbol bunches and install them in vector. */ - - condense_misc_bunches (!mainline); - - /* Make a default for file to list. */ - - select_source_symtab (0); /* FIXME, this might be too slow, see dbxread */ -} - -static void -coff_new_init () -{ - /* Nothin' to do */ -} - -/* Simplified internal version of coff symbol table information */ - -struct coff_symbol { - char *c_name; - int c_symnum; /* symbol number of this entry */ - int c_naux; /* 0 if syment only, 1 if syment + auxent, etc */ - long c_value; - int c_sclass; - int c_secnum; - unsigned int c_type; -}; - -/* Given pointers to a symbol table in coff style exec file, - analyze them and create struct symtab's describing the symbols. - NSYMS is the number of symbols in the symbol table. - We read them one at a time using read_one_sym (). */ - -static void -read_coff_symtab (desc, nsyms, objfile) - int desc; - int nsyms; - struct objfile *objfile; -{ - int newfd; /* Avoid multiple closes on same desc */ - FILE *stream; - register struct context_stack *new; - struct coff_symbol coff_symbol; - register struct coff_symbol *cs = &coff_symbol; - static struct internal_syment main_sym; - static union internal_auxent main_aux; - struct coff_symbol fcn_cs_saved; - static struct internal_syment fcn_sym_saved; - static union internal_auxent fcn_aux_saved; - - /* A .file is open. */ - int in_source_file = 0; - int num_object_files = 0; - int next_file_symnum = -1; - - /* Name of the current file. */ - char *filestring = ""; - int depth; - int fcn_first_line; - int fcn_last_line; - int fcn_start_addr; - long fcn_line_ptr; - struct cleanup *old_chain; - - - newfd = dup (desc); - if (newfd == -1) - fatal ("Too many open files"); - stream = fdopen (newfd, "r"); - - /* These cleanups will be discarded below if we succeed. */ - old_chain = make_cleanup (free_objfile, objfile); - make_cleanup (fclose, stream); - - nlist_stream_global = stream; - nlist_nsyms_global = nsyms; - last_source_file = 0; - bzero (opaque_type_chain, sizeof opaque_type_chain); - - if (type_vector) /* Get rid of previous one */ - free (type_vector); - type_vector_length = 160; - type_vector = (struct type **) - xmalloc (type_vector_length * sizeof (struct type *)); - bzero (type_vector, type_vector_length * sizeof (struct type *)); - - start_symtab (); - - symnum = 0; - while (symnum < nsyms) - { - QUIT; /* Make this command interruptable. */ - read_one_sym (cs, &main_sym, &main_aux); - -#ifdef SEM - temp_sem_val = cs->c_name[0] << 24 | cs->c_name[1] << 16 | - cs->c_name[2] << 8 | cs->c_name[3]; - if (int_sem_val == temp_sem_val) - last_coffsem = (int) strtol (cs->c_name+4, (char **) NULL, 10); -#endif - - if (cs->c_symnum == next_file_symnum && cs->c_sclass != C_FILE) - { - if (last_source_file) - end_symtab (objfile); - - start_symtab (); - complete_symtab ("_globals_", 0, first_object_file_end); - /* done with all files, everything from here on out is globals */ - } - - /* Special case for file with type declarations only, no text. */ - if (!last_source_file && SDB_TYPE (cs->c_type) - && cs->c_secnum == N_DEBUG) - complete_symtab (filestring, 0, 0); - - /* Typedefs should not be treated as symbol definitions. */ - if (ISFCN (cs->c_type) && cs->c_sclass != C_TPDEF) - { - /* record as misc function. if we get '.bf' next, - * then we undo this step - */ - record_misc_function (cs->c_name, cs->c_value); - - fcn_line_ptr = main_aux.x_sym.x_fcnary.x_fcn.x_lnnoptr; - fcn_start_addr = cs->c_value; - fcn_cs_saved = *cs; - fcn_sym_saved = main_sym; - fcn_aux_saved = main_aux; - continue; - } - - switch (cs->c_sclass) - { - case C_EFCN: - case C_EXTDEF: - case C_ULABEL: - case C_USTATIC: - case C_LINE: - case C_ALIAS: - case C_HIDDEN: - printf ("Bad n_sclass = %d\n", cs->c_sclass); - break; - - case C_FILE: - /* - * c_value field contains symnum of next .file entry in table - * or symnum of first global after last .file. - */ - next_file_symnum = cs->c_value; - filestring = getfilename (&main_aux); - /* - * Complete symbol table for last object file - * containing debugging information. - */ - if (last_source_file) - { - end_symtab (objfile); - start_symtab (); - } - in_source_file = 1; - break; - - case C_STAT: - if (cs->c_name[0] == '.') { - if (strcmp (cs->c_name, ".text") == 0) { - /* FIXME: don't wire in ".text" as section name - or symbol name! */ - if (++num_object_files == 1) { - /* last address of startup file */ - first_object_file_end = cs->c_value + - main_aux.x_scn.x_scnlen; - } - /* Check for in_source_file deals with case of - a file with debugging symbols - followed by a later file with no symbols. */ - if (in_source_file) - complete_symtab (filestring, cs->c_value, - main_aux.x_scn.x_scnlen); - in_source_file = 0; - } - /* flush rest of '.' symbols */ - break; - } - else if (!SDB_TYPE (cs->c_type) - && cs->c_name[0] == 'L' - && (strncmp (cs->c_name, "LI%", 3) == 0 - || strncmp (cs->c_name, "LF%", 3) == 0 - || strncmp (cs->c_name,"LC%",3) == 0 - || strncmp (cs->c_name,"LP%",3) == 0 - || strncmp (cs->c_name,"LPB%",4) == 0 - || strncmp (cs->c_name,"LBB%",4) == 0 - || strncmp (cs->c_name,"LBE%",4) == 0 - || strncmp (cs->c_name,"LPBX%",5) == 0)) - /* At least on a 3b1, gcc generates swbeg and string labels - that look like this. Ignore them. */ - break; - /* fall in for static symbols that don't start with '.' */ - case C_EXT: - if (!SDB_TYPE (cs->c_type)) { - /* FIXME: This is BOGUS Will Robinson! - Coff should provide the SEC_CODE flag for executable sections, - then if we could look up sections by section number we - could see if the flags indicate SEC_CODE. If so, then - record this symbol as a miscellaneous function. But why - are absolute syms recorded as functions, anyway? */ - if (cs->c_secnum <= text_bfd_scnum+1) {/* text or abs */ - record_misc_function (cs->c_name, cs->c_value); - break; - } else { - cs->c_type = T_INT; - } - } - (void) process_coff_symbol (cs, &main_aux); - break; - - case C_FCN: - if (strcmp (cs->c_name, ".bf") == 0) - { - within_function = 1; - - /* value contains address of first non-init type code */ - /* main_aux.x_sym.x_misc.x_lnsz.x_lnno - contains line number of '{' } */ - if (cs->c_naux != 1) - complain (no_aux_complaint, cs->c_symnum); - fcn_first_line = main_aux.x_sym.x_misc.x_lnsz.x_lnno; - - new = (struct context_stack *) - xmalloc (sizeof (struct context_stack)); - new->depth = depth = 0; - new->next = 0; - context_stack = new; - new->locals = 0; - new->old_blocks = pending_blocks; - new->start_addr = fcn_start_addr; - fcn_cs_saved.c_name = getsymname (&fcn_sym_saved); - new->name = process_coff_symbol (&fcn_cs_saved, - &fcn_aux_saved); - } - else if (strcmp (cs->c_name, ".ef") == 0) - { - /* the value of .ef is the address of epilogue code; - * not useful for gdb - */ - /* { main_aux.x_sym.x_misc.x_lnsz.x_lnno - contains number of lines to '}' */ - new = context_stack; - if (new == 0) - { - complain (&ef_complaint, cs->c_symnum); - within_function = 0; - break; - } - if (cs->c_naux != 1) { - complain (no_aux_complaint, cs->c_symnum); - fcn_last_line = 0x7FFFFFFF; - } else { - fcn_last_line = main_aux.x_sym.x_misc.x_lnsz.x_lnno; - } - enter_linenos (fcn_line_ptr, fcn_first_line, fcn_last_line); - - finish_block (new->name, &local_symbols, new->old_blocks, - new->start_addr, -#if defined (FUNCTION_EPILOGUE_SIZE) - /* This macro should be defined only on - machines where the - fcn_aux_saved.x_sym.x_misc.x_fsize - field is always zero. - So use the .bf record information that - points to the epilogue and add the size - of the epilogue. */ - cs->c_value + FUNCTION_EPILOGUE_SIZE -#else - fcn_cs_saved.c_value + - fcn_aux_saved.x_sym.x_misc.x_fsize -#endif - ); - context_stack = 0; - within_function = 0; - free (new); - } - break; - - case C_BLOCK: - if (strcmp (cs->c_name, ".bb") == 0) - { - new = (struct context_stack *) - xmalloc (sizeof (struct context_stack)); - depth++; - new->depth = depth; - new->next = context_stack; - context_stack = new; - new->locals = local_symbols; - new->old_blocks = pending_blocks; - new->start_addr = cs->c_value; - new->name = 0; - local_symbols = 0; - } - else if (strcmp (cs->c_name, ".eb") == 0) - { - new = context_stack; - if (new == 0 || depth != new->depth) - error ("Invalid symbol data: .bb/.eb symbol mismatch at symbol %d.", - symnum); - if (local_symbols && context_stack->next) - { - /* Make a block for the local symbols within. */ - finish_block (0, &local_symbols, new->old_blocks, - new->start_addr, cs->c_value); - } - depth--; - local_symbols = new->locals; - context_stack = new->next; - free (new); - } - break; - - default: - (void) process_coff_symbol (cs, &main_aux); - break; - } - } - - if (last_source_file) - end_symtab (objfile); - fclose (stream); - discard_cleanups (old_chain); -} - -/* Routines for reading headers and symbols from executable. */ - -#ifdef FIXME -/* Move these XXXMAGIC symbol defns into BFD! */ - -/* Read COFF file header, check magic number, - and return number of symbols. */ -read_file_hdr (chan, file_hdr) - int chan; - FILHDR *file_hdr; -{ - lseek (chan, 0L, 0); - if (myread (chan, (char *)file_hdr, FILHSZ) < 0) - return -1; - - switch (file_hdr->f_magic) - { -#ifdef MC68MAGIC - case MC68MAGIC: -#endif -#ifdef NS32GMAGIC - case NS32GMAGIC: - case NS32SMAGIC: -#endif -#ifdef I386MAGIC - case I386MAGIC: -#endif -#ifdef CLIPPERMAGIC - case CLIPPERMAGIC: -#endif -#if defined (MC68KWRMAGIC) \ - && (!defined (MC68MAGIC) || MC68KWRMAGIC != MC68MAGIC) - case MC68KWRMAGIC: -#endif -#ifdef MC68KROMAGIC - case MC68KROMAGIC: - case MC68KPGMAGIC: -#endif -#ifdef MC88DGMAGIC - case MC88DGMAGIC: -#endif -#ifdef MC88MAGIC - case MC88MAGIC: -#endif -#ifdef I960ROMAGIC - case I960ROMAGIC: /* Intel 960 */ -#endif -#ifdef I960RWMAGIC - case I960RWMAGIC: /* Intel 960 */ -#endif - return file_hdr->f_nsyms; - - default: -#ifdef BADMAG - if (BADMAG(file_hdr)) - return -1; - else - return file_hdr->f_nsyms; -#else - return -1; -#endif - } -} -#endif - -/* Read the next symbol, swap it, and return it in both internal_syment - form, and coff_symbol form. Also return its first auxent, if any, - in internal_auxent form, and skip any other auxents. */ - -static void -read_one_sym (cs, sym, aux) - register struct coff_symbol *cs; - register struct internal_syment *sym; - register union internal_auxent *aux; -{ - int i; - - cs->c_symnum = symnum; - fread (temp_sym, local_symesz, 1, nlist_stream_global); - bfd_coff_swap_sym_in (symfile_bfd, temp_sym, (char *)sym); - cs->c_naux = sym->n_numaux & 0xff; - if (cs->c_naux >= 1) - { - fread (temp_aux, local_auxesz, 1, nlist_stream_global); - bfd_coff_swap_aux_in (symfile_bfd, temp_aux, sym->n_type, sym->n_sclass, - (char *)aux); - /* If more than one aux entry, read past it (only the first aux - is important). */ - for (i = 1; i < cs->c_naux; i++) - fread (temp_aux, local_auxesz, 1, nlist_stream_global); - } - cs->c_name = getsymname (sym); - cs->c_value = sym->n_value; - cs->c_sclass = (sym->n_sclass & 0xff); - cs->c_secnum = sym->n_scnum; - cs->c_type = (unsigned) sym->n_type; - if (!SDB_TYPE (cs->c_type)) - cs->c_type = 0; - - symnum += 1 + cs->c_naux; -} - -/* Support for string table handling */ - -static char *stringtab = NULL; - -static int -init_stringtab (chan, offset) - int chan; - long offset; -{ - long length; - int val; - unsigned char lengthbuf[4]; - - if (stringtab) - { - free (stringtab); - stringtab = NULL; - } - - if (lseek (chan, offset, 0) < 0) - return -1; - - val = myread (chan, (char *)lengthbuf, sizeof lengthbuf); - length = bfd_h_get_32 (symfile_bfd, lengthbuf); - - /* If no string table is needed, then the file may end immediately - after the symbols. Just return with `stringtab' set to null. */ - if (val != sizeof length || length < sizeof length) - return 0; - - stringtab = (char *) xmalloc (length); - if (stringtab == NULL) - return -1; - - bcopy (&length, stringtab, sizeof length); - if (length == sizeof length) /* Empty table -- just the count */ - return 0; - - val = myread (chan, stringtab + sizeof length, length - sizeof length); - if (val != length - sizeof length || stringtab[length - 1] != '\0') - return -1; - - return 0; -} - -static void -free_stringtab () -{ - if (stringtab) - free (stringtab); - stringtab = NULL; -} - -static char * -getsymname (symbol_entry) - struct internal_syment *symbol_entry; -{ - static char buffer[SYMNMLEN+1]; - char *result; - - if (symbol_entry->_n._n_n._n_zeroes == 0) - { - result = stringtab + symbol_entry->_n._n_n._n_offset; - } - else - { - strncpy (buffer, symbol_entry->_n._n_name, SYMNMLEN); - buffer[SYMNMLEN] = '\0'; - result = buffer; - } - return result; -} - -static char * -getfilename (aux_entry) - union internal_auxent *aux_entry; -{ - static char buffer[BUFSIZ]; - register char *temp; - char *result; - extern char *rindex (); - -#ifndef COFF_NO_LONG_FILE_NAMES -#if defined (x_zeroes) - /* Data General. */ - if (aux_entry->x_zeroes == 0) - strcpy (buffer, stringtab + aux_entry->x_offset); -#else /* no x_zeroes */ - if (aux_entry->x_file.x_n.x_zeroes == 0) - strcpy (buffer, stringtab + aux_entry->x_file.x_n.x_offset); -#endif /* no x_zeroes */ - else -#endif /* COFF_NO_LONG_FILE_NAMES */ - { -#if defined (x_name) - /* Data General. */ - strncpy (buffer, aux_entry->x_name, FILNMLEN); -#else - strncpy (buffer, aux_entry->x_file.x_fname, FILNMLEN); -#endif - buffer[FILNMLEN] = '\0'; - } - result = buffer; - if ((temp = rindex (result, '/')) != NULL) - result = temp + 1; - return (result); -} - -/* Support for line number handling */ -static char *linetab = NULL; -static long linetab_offset; -static unsigned long linetab_size; - -/* Read in all the line numbers for fast lookups later. Leave them in - external (unswapped) format in memory; we'll swap them as we enter - them into GDB's data structures. */ - -static int -init_lineno (chan, offset, size) - int chan; - long offset; - int size; -{ - int val; - - linetab_offset = offset; - linetab_size = size; - - if (size == 0) - return 0; - - if (lseek (chan, offset, 0) < 0) - return -1; - - /* Allocate the desired table, plus a sentinel */ - linetab = (char *) xmalloc (size + local_linesz); - - val = myread (chan, linetab, size); - if (val != size) - return -1; - - /* Terminate it with an all-zero sentinel record */ - bzero (linetab + size, local_linesz); - - make_cleanup (free, linetab); /* Be sure it gets de-allocated. */ - return 0; -} - -#if !defined (L_LNNO32) -#define L_LNNO32(lp) ((lp)->l_lnno) -#endif - -static void -enter_linenos (file_offset, first_line, last_line) - long file_offset; - register int first_line; - register int last_line; -{ - register char *rawptr; - struct internal_lineno lptr; - - if (file_offset < linetab_offset) - { - complain (&lineno_complaint, file_offset); - if (file_offset > linetab_size) /* Too big to be an offset? */ - return; - file_offset += linetab_offset; /* Try reading at that linetab offset */ - } - - rawptr = &linetab[file_offset - linetab_offset]; - - /* skip first line entry for each function */ - rawptr += local_linesz; - /* line numbers start at one for the first line of the function */ - first_line--; - - for (;;) { - bfd_coff_swap_lineno_in (symfile_bfd, rawptr, &lptr); - rawptr += local_linesz; - /* The next function, or the sentinel, will have L_LNNO32 zero; we exit. */ - if (L_LNNO32 (&lptr) && L_LNNO32 (&lptr) <= last_line) - record_line (first_line + L_LNNO32 (&lptr), lptr.l_addr.l_paddr); - else - break; - } -} - -static int -hashname (name) - char *name; -{ - register char *p = name; - register int total = p[0]; - register int c; - - c = p[1]; - total += c << 2; - if (c) - { - c = p[2]; - total += c << 4; - if (c) - total += p[3] << 6; - } - - return total % HASHSIZE; -} - -static void -patch_type (type, real_type) - struct type *type; - struct type *real_type; -{ - register struct type *target = TYPE_TARGET_TYPE (type); - register struct type *real_target = TYPE_TARGET_TYPE (real_type); - int field_size = TYPE_NFIELDS (real_target) * sizeof (struct field); - - TYPE_LENGTH (target) = TYPE_LENGTH (real_target); - TYPE_NFIELDS (target) = TYPE_NFIELDS (real_target); - TYPE_FIELDS (target) = (struct field *) - obstack_alloc (symbol_obstack, field_size); - - bcopy (TYPE_FIELDS (real_target), TYPE_FIELDS (target), field_size); - - if (TYPE_NAME (real_target)) - { - if (TYPE_NAME (target)) - free (TYPE_NAME (target)); - TYPE_NAME (target) = concat (TYPE_NAME (real_target), NULL); - } -} - -/* Patch up all appropriate typdef symbols in the opaque_type_chains - so that they can be used to print out opaque data structures properly */ - -static void -patch_opaque_types () -{ - struct symtab *s; - - /* Look at each symbol in the per-file block of each symtab. */ - for (s = symtab_list; s; s = s->next) - { - register struct block *b; - register int i; - - /* Go through the per-file symbols only */ - b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK); - for (i = BLOCK_NSYMS (b) - 1; i >= 0; i--) - { - register struct symbol *real_sym; - - /* Find completed typedefs to use to fix opaque ones. - Remove syms from the chain when their types are stored, - but search the whole chain, as there may be several syms - from different files with the same name. */ - real_sym = BLOCK_SYM (b, i); - if (SYMBOL_CLASS (real_sym) == LOC_TYPEDEF && - SYMBOL_NAMESPACE (real_sym) == VAR_NAMESPACE && - TYPE_CODE (SYMBOL_TYPE (real_sym)) == TYPE_CODE_PTR && - TYPE_LENGTH (TYPE_TARGET_TYPE (SYMBOL_TYPE (real_sym))) != 0) - { - register char *name = SYMBOL_NAME (real_sym); - register int hash = hashname (name); - register struct symbol *sym, *prev; - - prev = 0; - for (sym = opaque_type_chain[hash]; sym;) - { - if (name[0] == SYMBOL_NAME (sym)[0] && - !strcmp (name + 1, SYMBOL_NAME (sym) + 1)) - { - if (prev) - SYMBOL_VALUE_CHAIN (prev) = SYMBOL_VALUE_CHAIN (sym); - else - opaque_type_chain[hash] = SYMBOL_VALUE_CHAIN (sym); - - patch_type (SYMBOL_TYPE (sym), SYMBOL_TYPE (real_sym)); - - if (prev) - sym = SYMBOL_VALUE_CHAIN (prev); - else - sym = opaque_type_chain[hash]; - } - else - { - prev = sym; - sym = SYMBOL_VALUE_CHAIN (sym); - } - } - } - } - } -} - -#if defined (clipper) -#define BELIEVE_PCC_PROMOTION 1 -#endif - -static struct symbol * -process_coff_symbol (cs, aux) - register struct coff_symbol *cs; - register union internal_auxent *aux; -{ - register struct symbol *sym - = (struct symbol *) obstack_alloc (symbol_obstack, sizeof (struct symbol)); - char *name; -#ifdef NAMES_HAVE_UNDERSCORE - int offset = 1; -#else - int offset = 0; -#endif - - bzero (sym, sizeof (struct symbol)); - name = cs->c_name; - name = (name[0] == '_' ? name + offset : name); - SYMBOL_NAME (sym) = obstack_copy0 (symbol_obstack, name, strlen (name)); - - /* default assumptions */ - SYMBOL_VALUE (sym) = cs->c_value; - SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; - - if (ISFCN (cs->c_type)) - { -#if 0 - /* FIXME: This has NOT been tested. The DBX version has.. */ - /* Generate a template for the type of this function. The - types of the arguments will be added as we read the symbol - table. */ - struct type *new = (struct type *) - obstack_alloc (symbol_obstack, sizeof (struct type)); - - bcopy(lookup_function_type (decode_function_type (cs, cs->c_type, aux)), - new, sizeof(struct type)); - SYMBOL_TYPE (sym) = new; - in_function_type = SYMBOL_TYPE(sym); -#else - SYMBOL_TYPE(sym) = - lookup_function_type (decode_function_type (cs, cs->c_type, aux)); -#endif - - SYMBOL_CLASS (sym) = LOC_BLOCK; - if (cs->c_sclass == C_STAT) - add_symbol_to_list (sym, &file_symbols); - else if (cs->c_sclass == C_EXT) - add_symbol_to_list (sym, &global_symbols); - } - else - { - SYMBOL_TYPE (sym) = decode_type (cs, cs->c_type, aux); - switch (cs->c_sclass) - { - case C_NULL: - break; - - case C_AUTO: - SYMBOL_CLASS (sym) = LOC_LOCAL; - add_symbol_to_list (sym, &local_symbols); - break; - - case C_EXT: - SYMBOL_CLASS (sym) = LOC_STATIC; - SYMBOL_VALUE_ADDRESS (sym) = (CORE_ADDR) cs->c_value; - add_symbol_to_list (sym, &global_symbols); - break; - - case C_STAT: - SYMBOL_CLASS (sym) = LOC_STATIC; - SYMBOL_VALUE_ADDRESS (sym) = (CORE_ADDR) cs->c_value; - if (within_function) { - /* Static symbol of local scope */ - add_symbol_to_list (sym, &local_symbols); - } - else { - /* Static symbol at top level of file */ - add_symbol_to_list (sym, &file_symbols); - } - break; - -#ifdef C_GLBLREG /* AMD coff */ - case C_GLBLREG: -#endif - case C_REG: - SYMBOL_CLASS (sym) = LOC_REGISTER; - SYMBOL_VALUE (sym) = SDB_REG_TO_REGNUM(cs->c_value); - add_symbol_to_list (sym, &local_symbols); - break; - - case C_LABEL: - break; - - case C_ARG: - SYMBOL_CLASS (sym) = LOC_ARG; -#if 0 - /* FIXME: This has not bee tested. */ - /* Add parameter to function. */ - add_param_to_type(&in_function_type,sym); -#endif - add_symbol_to_list (sym, &local_symbols); -#if !defined (BELIEVE_PCC_PROMOTION) - /* If PCC says a parameter is a short or a char, - it is really an int. */ - if (SYMBOL_TYPE (sym) == builtin_type_char - || SYMBOL_TYPE (sym) == builtin_type_short) - SYMBOL_TYPE (sym) = builtin_type_int; - else if (SYMBOL_TYPE (sym) == builtin_type_unsigned_char - || SYMBOL_TYPE (sym) == builtin_type_unsigned_short) - SYMBOL_TYPE (sym) = builtin_type_unsigned_int; -#endif - break; - - case C_REGPARM: - SYMBOL_CLASS (sym) = LOC_REGPARM; - SYMBOL_VALUE (sym) = SDB_REG_TO_REGNUM(cs->c_value); - add_symbol_to_list (sym, &local_symbols); -#if !defined (BELIEVE_PCC_PROMOTION) - /* If PCC says a parameter is a short or a char, - it is really an int. */ - if (SYMBOL_TYPE (sym) == builtin_type_char - || SYMBOL_TYPE (sym) == builtin_type_short) - SYMBOL_TYPE (sym) = builtin_type_int; - else if (SYMBOL_TYPE (sym) == builtin_type_unsigned_char - || SYMBOL_TYPE (sym) == builtin_type_unsigned_short) - SYMBOL_TYPE (sym) = builtin_type_unsigned_int; -#endif - break; - - case C_TPDEF: - SYMBOL_CLASS (sym) = LOC_TYPEDEF; - SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; - - /* If type has no name, give it one */ - if (TYPE_NAME (SYMBOL_TYPE (sym)) == 0 - && (TYPE_FLAGS (SYMBOL_TYPE (sym)) & TYPE_FLAG_PERM) == 0) - TYPE_NAME (SYMBOL_TYPE (sym)) - = concat (SYMBOL_NAME (sym), NULL); - - /* Keep track of any type which points to empty structured type, - so it can be filled from a definition from another file */ - if (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_PTR && - TYPE_LENGTH (TYPE_TARGET_TYPE (SYMBOL_TYPE (sym))) == 0) - { - register int i = hashname (SYMBOL_NAME (sym)); - - SYMBOL_VALUE_CHAIN (sym) = opaque_type_chain[i]; - opaque_type_chain[i] = sym; - } - add_symbol_to_list (sym, &file_symbols); - break; - - case C_STRTAG: - case C_UNTAG: - case C_ENTAG: - SYMBOL_CLASS (sym) = LOC_TYPEDEF; - SYMBOL_NAMESPACE (sym) = STRUCT_NAMESPACE; - if (TYPE_NAME (SYMBOL_TYPE (sym)) == 0 - && (TYPE_FLAGS (SYMBOL_TYPE (sym)) & TYPE_FLAG_PERM) == 0) - TYPE_NAME (SYMBOL_TYPE (sym)) - = concat ("", - (cs->c_sclass == C_ENTAG - ? "enum " - : (cs->c_sclass == C_STRTAG - ? "struct " : "union ")), - SYMBOL_NAME (sym), NULL); - add_symbol_to_list (sym, &file_symbols); - break; - - default: - break; - } - } - return sym; -} - -/* Decode a coff type specifier; - return the type that is meant. */ - -static -struct type * -decode_type (cs, c_type, aux) - register struct coff_symbol *cs; - unsigned int c_type; - register union internal_auxent *aux; -{ - register struct type *type = 0; - unsigned int new_c_type; - - if (c_type & ~N_BTMASK) - { - new_c_type = DECREF (c_type); - if (ISPTR (c_type)) - { - type = decode_type (cs, new_c_type, aux); - type = lookup_pointer_type (type); - } - else if (ISFCN (c_type)) - { - type = decode_type (cs, new_c_type, aux); - type = lookup_function_type (type); - } - else if (ISARY (c_type)) - { - int i, n; - register unsigned short *dim; - struct type *base_type; - - /* Define an array type. */ - /* auxent refers to array, not base type */ - if (aux->x_sym.x_tagndx.l == 0) - cs->c_naux = 0; - - /* shift the indices down */ - dim = &aux->x_sym.x_fcnary.x_ary.x_dimen[0]; - i = 1; - n = dim[0]; - for (i = 0; *dim && i < DIMNUM - 1; i++, dim++) - *dim = *(dim + 1); - *dim = 0; - - type = (struct type *) - obstack_alloc (symbol_obstack, sizeof (struct type)); - bzero (type, sizeof (struct type)); - - base_type = decode_type (cs, new_c_type, aux); - - TYPE_CODE (type) = TYPE_CODE_ARRAY; - TYPE_TARGET_TYPE (type) = base_type; - TYPE_LENGTH (type) = n * TYPE_LENGTH (base_type); - } - return type; - } - - /* Reference to existing type */ - if (cs->c_naux > 0 && aux->x_sym.x_tagndx.l != 0) - { - type = coff_alloc_type (aux->x_sym.x_tagndx.l); - return type; - } - - return decode_base_type (cs, BTYPE (c_type), aux); -} - -/* Decode a coff type specifier for function definition; - return the type that the function returns. */ - -static -struct type * -decode_function_type (cs, c_type, aux) - register struct coff_symbol *cs; - unsigned int c_type; - register union internal_auxent *aux; -{ - if (aux->x_sym.x_tagndx.l == 0) - cs->c_naux = 0; /* auxent refers to function, not base type */ - - return decode_type (cs, DECREF (c_type), aux); -} - -/* basic C types */ - -static -struct type * -decode_base_type (cs, c_type, aux) - register struct coff_symbol *cs; - unsigned int c_type; - register union internal_auxent *aux; -{ - struct type *type; - - switch (c_type) - { - case T_NULL: - /* shows up with "void (*foo)();" structure members */ - return builtin_type_void; - -#if 0 -/* DGUX actually defines both T_ARG and T_VOID to the same value. */ -#ifdef T_ARG - case T_ARG: - /* Shows up in DGUX, I think. Not sure where. */ - return builtin_type_void; /* shouldn't show up here */ -#endif -#endif /* 0 */ - -#ifdef T_VOID - case T_VOID: - /* Intel 960 COFF has this symbol and meaning. */ - return builtin_type_void; -#endif - - case T_CHAR: - return builtin_type_char; - - case T_SHORT: - return builtin_type_short; - - case T_INT: - return builtin_type_int; - - case T_LONG: - return builtin_type_long; - - case T_FLOAT: - return builtin_type_float; - - case T_DOUBLE: - return builtin_type_double; - - case T_STRUCT: - if (cs->c_naux != 1) - { - /* anonymous structure type */ - type = coff_alloc_type (cs->c_symnum); - TYPE_CODE (type) = TYPE_CODE_STRUCT; - TYPE_NAME (type) = concat ("struct ", "", NULL); - TYPE_CPLUS_SPECIFIC (type) - = (struct cplus_struct_type *) obstack_alloc (symbol_obstack, sizeof (struct cplus_struct_type)); - bzero (TYPE_CPLUS_SPECIFIC (type), sizeof (struct cplus_struct_type)); - TYPE_LENGTH (type) = 0; - TYPE_FIELDS (type) = 0; - TYPE_NFIELDS (type) = 0; - } - else - { - type = read_struct_type (cs->c_symnum, - aux->x_sym.x_misc.x_lnsz.x_size, - aux->x_sym.x_fcnary.x_fcn.x_endndx); - } - return type; - - case T_UNION: - if (cs->c_naux != 1) - { - /* anonymous union type */ - type = coff_alloc_type (cs->c_symnum); - TYPE_NAME (type) = concat ("union ", "", NULL); - TYPE_LENGTH (type) = 0; - TYPE_FIELDS (type) = 0; - TYPE_NFIELDS (type) = 0; - } - else - { - type = read_struct_type (cs->c_symnum, - aux->x_sym.x_misc.x_lnsz.x_size, - aux->x_sym.x_fcnary.x_fcn.x_endndx); - } - TYPE_CODE (type) = TYPE_CODE_UNION; - return type; - - case T_ENUM: - return read_enum_type (cs->c_symnum, - aux->x_sym.x_misc.x_lnsz.x_size, - aux->x_sym.x_fcnary.x_fcn.x_endndx); - - case T_MOE: - /* shouldn't show up here */ - break; - - case T_UCHAR: - return builtin_type_unsigned_char; - - case T_USHORT: - return builtin_type_unsigned_short; - - case T_UINT: - return builtin_type_unsigned_int; - - case T_ULONG: - return builtin_type_unsigned_long; - } - printf ("unexpected type %d at symnum %d\n", c_type, cs->c_symnum); - return builtin_type_void; -} - -/* This page contains subroutines of read_type. */ - -/* Read the description of a structure (or union type) - and return an object describing the type. */ - -static struct type * -read_struct_type (index, length, lastsym) - int index; - int length; - int lastsym; -{ - struct nextfield - { - struct nextfield *next; - struct field field; - }; - - register struct type *type; - register struct nextfield *list = 0; - struct nextfield *new; - int nfields = 0; - register int n; - char *name; -#ifdef NAMES_HAVE_UNDERSCORE - int offset = 1; -#else - int offset = 0; -#endif - struct coff_symbol member_sym; - register struct coff_symbol *ms = &member_sym; - struct internal_syment sub_sym; - union internal_auxent sub_aux; - int done = 0; - - type = coff_alloc_type (index); - TYPE_CODE (type) = TYPE_CODE_STRUCT; - TYPE_CPLUS_SPECIFIC (type) - = (struct cplus_struct_type *) obstack_alloc (symbol_obstack, sizeof (struct cplus_struct_type)); - bzero (TYPE_CPLUS_SPECIFIC (type), sizeof (struct cplus_struct_type)); - TYPE_LENGTH (type) = length; - - while (!done && symnum < lastsym && symnum < nlist_nsyms_global) - { - read_one_sym (ms, &sub_sym, &sub_aux); - name = ms->c_name; - name = (name[0] == '_' ? name + offset : name); - - switch (ms->c_sclass) - { - case C_MOS: - case C_MOU: - - /* Get space to record the next field's data. */ - new = (struct nextfield *) alloca (sizeof (struct nextfield)); - new->next = list; - list = new; - - /* Save the data. */ - list->field.name = savestring (name, strlen (name)); - list->field.type = decode_type (ms, ms->c_type, &sub_aux); - list->field.bitpos = 8 * ms->c_value; - list->field.bitsize = 0; - nfields++; - break; - - case C_FIELD: - - /* Get space to record the next field's data. */ - new = (struct nextfield *) alloca (sizeof (struct nextfield)); - new->next = list; - list = new; - - /* Save the data. */ - list->field.name = savestring (name, strlen (name)); - list->field.type = decode_type (ms, ms->c_type, &sub_aux); - list->field.bitpos = ms->c_value; - list->field.bitsize = sub_aux.x_sym.x_misc.x_lnsz.x_size; - nfields++; - break; - - case C_EOS: - done = 1; - break; - } - } - /* Now create the vector of fields, and record how big it is. */ - - TYPE_NFIELDS (type) = nfields; - TYPE_FIELDS (type) = (struct field *) - obstack_alloc (symbol_obstack, sizeof (struct field) * nfields); - - /* Copy the saved-up fields into the field vector. */ - - for (n = nfields; list; list = list->next) - TYPE_FIELD (type, --n) = list->field; - - return type; -} - -/* Read a definition of an enumeration type, - and create and return a suitable type object. - Also defines the symbols that represent the values of the type. */ -/* Currently assumes it's sizeof (int) and doesn't use length. */ - -/* ARGSUSED */ -static struct type * -read_enum_type (index, length, lastsym) - int index; - int length; - int lastsym; -{ - register struct symbol *sym; - register struct type *type; - int nsyms = 0; - int done = 0; - struct pending **symlist; - struct coff_symbol member_sym; - register struct coff_symbol *ms = &member_sym; - struct internal_syment sub_sym; - union internal_auxent sub_aux; - struct pending *osyms, *syms; - register int n; - char *name; -#ifdef NAMES_HAVE_UNDERSCORE - int offset = 1; -#else - int offset = 0; -#endif - - type = coff_alloc_type (index); - if (within_function) - symlist = &local_symbols; - else - symlist = &file_symbols; - osyms = *symlist; - - while (!done && symnum < lastsym && symnum < nlist_nsyms_global) - { - read_one_sym (ms, &sub_sym, &sub_aux); - name = ms->c_name; - name = (name[0] == '_' ? name + offset : name); - - switch (ms->c_sclass) - { - case C_MOE: - sym = (struct symbol *) xmalloc (sizeof (struct symbol)); - bzero (sym, sizeof (struct symbol)); - - SYMBOL_NAME (sym) = savestring (name, strlen (name)); - SYMBOL_CLASS (sym) = LOC_CONST; - SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; - SYMBOL_VALUE (sym) = ms->c_value; - add_symbol_to_list (sym, symlist); - nsyms++; - break; - - case C_EOS: - /* Sometimes the linker (on 386/ix 2.0.2 at least) screws - up the count of how many symbols to read. So stop - on .eos. */ - done = 1; - break; - } - } - - /* Now fill in the fields of the type-structure. */ - - /* FIXME: Should be sizeof (int) on target, not host. */ - TYPE_LENGTH (type) = sizeof (int); - TYPE_CODE (type) = TYPE_CODE_ENUM; - TYPE_NFIELDS (type) = nsyms; - TYPE_FIELDS (type) = (struct field *) - obstack_alloc (symbol_obstack, sizeof (struct field) * nsyms); - - /* Find the symbols for the values and put them into the type. - The symbols can be found in the symlist that we put them on - to cause them to be defined. osyms contains the old value - of that symlist; everything up to there was defined by us. */ - - for (syms = *symlist, n = nsyms; syms != osyms; syms = syms->next) - { - SYMBOL_TYPE (syms->symbol) = type; - TYPE_FIELD_NAME (type, --n) = SYMBOL_NAME (syms->symbol); - TYPE_FIELD_VALUE (type, n) = 0; - TYPE_FIELD_BITPOS (type, n) = SYMBOL_VALUE (syms->symbol); - TYPE_FIELD_BITSIZE (type, n) = 0; - } - /* Is this Modula-2's BOOLEAN type? Flag it as such if so. */ - if(TYPE_NFIELDS(type) == 2 && - ((!strcmp(TYPE_FIELD_NAME(type,0),"TRUE") && - !strcmp(TYPE_FIELD_NAME(type,1),"FALSE")) || - (!strcmp(TYPE_FIELD_NAME(type,1),"TRUE") && - !strcmp(TYPE_FIELD_NAME(type,0),"FALSE")))) - TYPE_CODE(type) = TYPE_CODE_BOOL; - return type; -} - -/* Register our ability to parse symbols for coff BFD files */ - -static struct sym_fns coff_sym_fns = -{ - "coff", 4, - coff_new_init, coff_symfile_init, coff_symfile_read, -}; - -void -_initialize_coffread () -{ - add_symtab_fns(&coff_sym_fns); -} diff --git a/gdb/command.c b/gdb/command.c deleted file mode 100644 index d8839401cd2..00000000000 --- a/gdb/command.c +++ /dev/null @@ -1,1213 +0,0 @@ -/* Library for reading command lines and decoding commands. - Copyright (C) 1986, 1989, 1990 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "defs.h" -#include "param.h" -#include "command.h" -#include "symtab.h" -#include "value.h" -#include -#include - -extern char *getenv (); - -/* Add element named NAME to command list *LIST. - FUN should be the function to execute the command; - it will get a character string as argument, with leading - and trailing blanks already eliminated. - - DOC is a documentation string for the command. - Its first line should be a complete sentence. - It should start with ? for a command that is an abbreviation - or with * for a command that most users don't need to know about. */ - -struct cmd_list_element * -add_cmd (name, class, fun, doc, list) - char *name; - enum command_class class; - void (*fun) (); - char *doc; - struct cmd_list_element **list; -{ - register struct cmd_list_element *c - = (struct cmd_list_element *) xmalloc (sizeof (struct cmd_list_element)); - - delete_cmd (name, list); - c->next = *list; - c->name = name; - c->class = class; - c->function = fun; - c->doc = doc; - c->prefixlist = 0; - c->prefixname = (char *)NULL; - c->allow_unknown = 0; - c->abbrev_flag = 0; - c->aux = 0; - c->type = not_set_cmd; - c->completer = make_symbol_completion_list; - c->var = 0; - c->var_type = var_boolean; - c->user_commands = 0; - *list = c; - return c; -} - -/* Same as above, except that the abbrev_flag is set. */ - -struct cmd_list_element * -add_abbrev_cmd (name, class, fun, doc, list) - char *name; - enum command_class class; - void (*fun) (); - char *doc; - struct cmd_list_element **list; -{ - register struct cmd_list_element *c - = add_cmd (name, class, fun, doc, list); - - c->abbrev_flag = 1; - return c; -} - -struct cmd_list_element * -add_alias_cmd (name, oldname, class, abbrev_flag, list) - char *name; - char *oldname; - enum command_class class; - int abbrev_flag; - struct cmd_list_element **list; -{ - /* Must do this since lookup_cmd tries to side-effect its first arg */ - char *copied_name; - register struct cmd_list_element *old; - register struct cmd_list_element *c; - copied_name = (char *) alloca (strlen (oldname) + 1); - strcpy (copied_name, oldname); - old = lookup_cmd (&copied_name, *list, "", 1, 1); - - if (old == 0) - { - delete_cmd (name, list); - return 0; - } - - c = add_cmd (name, class, old->function, old->doc, list); - c->prefixlist = old->prefixlist; - c->prefixname = old->prefixname; - c->allow_unknown = old->allow_unknown; - c->abbrev_flag = abbrev_flag; - c->aux = old->aux; - return c; -} - -/* Like add_cmd but adds an element for a command prefix: - a name that should be followed by a subcommand to be looked up - in another command list. PREFIXLIST should be the address - of the variable containing that list. */ - -struct cmd_list_element * -add_prefix_cmd (name, class, fun, doc, prefixlist, prefixname, - allow_unknown, list) - char *name; - enum command_class class; - void (*fun) (); - char *doc; - struct cmd_list_element **prefixlist; - char *prefixname; - int allow_unknown; - struct cmd_list_element **list; -{ - register struct cmd_list_element *c = add_cmd (name, class, fun, doc, list); - c->prefixlist = prefixlist; - c->prefixname = prefixname; - c->allow_unknown = allow_unknown; - return c; -} - -/* Like add_prefix_cmd butsets the abbrev_flag on the new command. */ - -struct cmd_list_element * -add_abbrev_prefix_cmd (name, class, fun, doc, prefixlist, prefixname, - allow_unknown, list) - char *name; - enum command_class class; - void (*fun) (); - char *doc; - struct cmd_list_element **prefixlist; - char *prefixname; - int allow_unknown; - struct cmd_list_element **list; -{ - register struct cmd_list_element *c = add_cmd (name, class, fun, doc, list); - c->prefixlist = prefixlist; - c->prefixname = prefixname; - c->allow_unknown = allow_unknown; - c->abbrev_flag = 1; - return c; -} - -/* ARGSUSED */ -void -not_just_help_class_command (args, from_tty, c) - char *args; - int from_tty; - struct cmd_list_element *c; -{ -} - -/* Add element named NAME to command list LIST (the list for set - or some sublist thereof). - 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. */ -struct cmd_list_element * -add_set_cmd (name, class, var_type, var, doc, list) - char *name; - enum command_class class; - var_types var_type; - char *var; - char *doc; - struct cmd_list_element **list; -{ - /* For set/show, we have to call do_setshow_command - differently than an ordinary function (take commandlist as - well as arg), so the function field isn't helpful. However, - function == NULL means that it's a help class, so set the function - to not_just_help_class_command. */ - struct cmd_list_element *c - = add_cmd (name, class, not_just_help_class_command, doc, list); - - c->type = set_cmd; - c->var_type = var_type; - c->var = var; - return c; -} - -/* Where SETCMD has already been added, add the corresponding show - command to LIST and return a pointer to it. */ -struct cmd_list_element * -add_show_from_set (setcmd, list) - 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)); - - bcopy (setcmd, showcmd, sizeof (struct cmd_list_element)); - delete_cmd (showcmd->name, list); - showcmd->type = show_cmd; - - /* 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 (stderr, "GDB internal error: Bad docstring for set command\n"); - - showcmd->next = *list; - *list = showcmd; - return showcmd; -} - -/* Remove the command named NAME from the command list. */ - -void -delete_cmd (name, list) - char *name; - struct cmd_list_element **list; -{ - register struct cmd_list_element *c; - struct cmd_list_element *p; - - while (*list && !strcmp ((*list)->name, name)) - { - p = (*list)->next; - free (*list); - *list = p; - } - - if (*list) - for (c = *list; c->next;) - { - if (!strcmp (c->next->name, name)) - { - p = c->next->next; - free (c->next); - c->next = p; - } - else - c = c->next; - } -} - -/* This command really has to deal with two things: - * 1) I want documentation on *this string* (usually called by - * "help commandname"). - * 2) I want documentation on *this list* (usually called by - * giving a command that requires subcommands. Also called by saying - * just "help".) - * - * I am going to split this into two seperate comamnds, help_cmd and - * help_list. - */ - -void -help_cmd (command, stream) - char *command; - FILE *stream; -{ - struct cmd_list_element *c; - extern struct cmd_list_element *cmdlist; - - if (!command) - { - help_list (cmdlist, "", all_classes, stream); - return; - } - - c = lookup_cmd (&command, cmdlist, "", 0, 0); - - if (c == 0) - return; - - /* There are three cases here. - If c->prefixlist is nonzero, we have a prefix command. - Print its documentation, then list its subcommands. - - If c->function is nonzero, we really have a command. - Print its documentation and return. - - If c->function is zero, we have a class name. - Print its documentation (as if it were a command) - and then set class to the number of this class - so that the commands in the class will be listed. */ - - fputs_filtered (c->doc, stream); - fputs_filtered ("\n", stream); - - if (c->prefixlist == 0 && c->function != 0) - return; - fprintf_filtered (stream, "\n"); - - /* If this is a prefix command, print it's subcommands */ - if (c->prefixlist) - help_list (*c->prefixlist, c->prefixname, all_commands, stream); - - /* If this is a class name, print all of the commands in the class */ - if (c->function == 0) - help_list (cmdlist, "", c->class, stream); -} - -/* - * Get a specific kind of help on a command list. - * - * LIST is the list. - * CMDTYPE is the prefix to use in the title string. - * CLASS is the class with which to list the nodes of this list (see - * documentation for help_cmd_list below), As usual, ALL_COMMANDS for - * everything, ALL_CLASSES for just classes, and non-negative for only things - * in a specific class. - * and STREAM is the output stream on which to print things. - * If you call this routine with a class >= 0, it recurses. - */ -void -help_list (list, cmdtype, class, stream) - struct cmd_list_element *list; - char *cmdtype; - enum command_class class; - FILE *stream; -{ - int len; - char *cmdtype1, *cmdtype2; - - /* If CMDTYPE is "foo ", CMDTYPE1 gets " foo" and CMDTYPE2 gets "foo sub" */ - len = strlen (cmdtype); - cmdtype1 = (char *) alloca (len + 1); - cmdtype1[0] = 0; - cmdtype2 = (char *) alloca (len + 4); - cmdtype2[0] = 0; - if (len) - { - cmdtype1[0] = ' '; - strncpy (cmdtype1 + 1, cmdtype, len - 1); - cmdtype1[len] = 0; - strncpy (cmdtype2, cmdtype, len - 1); - strcpy (cmdtype2 + len - 1, " sub"); - } - - if (class == all_classes) - fprintf_filtered (stream, "List of classes of %scommands:\n\n", cmdtype2); - else - fprintf_filtered (stream, "List of %scommands:\n\n", cmdtype2); - - 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 %scommand name for full documentation.\n\ -Command name abbreviations are allowed if unambiguous.\n", - cmdtype1, cmdtype2); -} - -/* Print only the first line of STR on STREAM. */ -static void -print_doc_line (stream, str) - FILE *stream; - char *str; -{ - static char *line_buffer = 0; - static int line_size; - register char *p; - - if (!line_buffer) - { - line_size = 80; - line_buffer = (char *) xmalloc (line_size); - } - - p = str; - while (*p && *p != '\n' && *p != '.' && *p != ',') - p++; - if (p - str > line_size - 1) - { - line_size = p - str + 1; - free (line_buffer); - line_buffer = (char *) xmalloc (line_size); - } - strncpy (line_buffer, str, p - str); - line_buffer[p - str] = '\0'; - if (islower (line_buffer[0])) - line_buffer[0] = toupper (line_buffer[0]); - fputs_filtered (line_buffer, stream); -} - -/* - * Implement a help command on command list LIST. - * RECURSE should be non-zero if this should be done recursively on - * all sublists of LIST. - * PREFIX is the prefix to print before each command name. - * STREAM is the stream upon which the output should be written. - * CLASS should be: - * A non-negative class number to list only commands in that - * class. - * ALL_COMMANDS to list all commands in list. - * ALL_CLASSES to list all classes in list. - * - * Note that RECURSE will be active on *all* sublists, not just the - * ones seclected by the criteria above (ie. the selection mechanism - * is at the low level, not the high-level). - */ -void -help_cmd_list (list, class, prefix, recurse, stream) - struct cmd_list_element *list; - enum command_class class; - char *prefix; - int recurse; - FILE *stream; -{ - register struct cmd_list_element *c; - - for (c = list; c; c = c->next) - { - if (c->abbrev_flag == 0 && - (class == all_commands - || (class == all_classes && c->function == 0) - || (class == c->class && c->function != 0))) - { - fprintf_filtered (stream, "%s%s -- ", prefix, c->name); - print_doc_line (stream, c->doc); - fputs_filtered ("\n", stream); - } - if (recurse - && c->prefixlist != 0 - && c->abbrev_flag == 0) - help_cmd_list (*c->prefixlist, class, c->prefixname, 1, stream); - } -} - -/* This routine takes a line of TEXT and a CLIST in which to - start the lookup. When it returns it will have incremented the text - pointer past the section of text it matched, set *RESULT_LIST to - the list in which the last word was matched, and will return the - cmd list element which the text matches. It will return 0 if no - match at all was possible. It will return -1 if ambigous matches are - possible; in this case *RESULT_LIST will be set to the list in which - there are ambiguous choices (and text will be set to the ambiguous - text string). - - It does no error reporting whatsoever; control will always return - to the superior routine. - - In the case of an ambiguous return (-1), *RESULT_LIST will be set to - point at the prefix_command (ie. the best match) *or* (special - case) will be 0 if no prefix command was ever found. For example, - in the case of "info a", "info" matches without ambiguity, but "a" - could be "args" or "address", so *RESULT_LIST is set to - the cmd_list_element for "info". So in this case - result list should not be interpeted as a pointer to the beginning - of a list; it simply points to a specific command. - - If RESULT_LIST is NULL, don't set *RESULT_LIST (but don't otherwise - affect the operation). - - This routine does *not* modify the text pointed to by TEXT. - - If IGNORE_HELP_CLASSES is nonzero, ignore any command list - elements which are actually help classes rather than commands (i.e. - the function field of the struct cmd_list_element is 0). */ - -struct cmd_list_element * -lookup_cmd_1 (text, clist, result_list, ignore_help_classes) - char **text; - struct cmd_list_element *clist, **result_list; - int ignore_help_classes; -{ - char *p, *command; - int len, tmp, nfound; - struct cmd_list_element *found, *c; - - while (**text == ' ' || **text == '\t') - (*text)++; - - /* Treating underscores as part of command words is important - so that "set args_foo()" doesn't get interpreted as - "set args _foo()". */ - for (p = *text; - *p && (isalnum(*p) || *p == '-' || *p == '_'); - p++) - ; - - /* If nothing but whitespace, return 0. */ - if (p == *text) - return 0; - - len = p - *text; - - /* *text and p now bracket the first command word to lookup (and - it's length is len). We copy this into a local temporary, - converting to lower case as we go. */ - - command = (char *) alloca (len + 1); - for (tmp = 0; tmp < len; tmp++) - { - char x = (*text)[tmp]; - command[tmp] = (x >= 'A' && x <= 'Z') ? x - 'A' + 'a' : x; - } - command[len] = '\0'; - - /* Look it up. */ - found = 0; - nfound = 0; - for (c = clist; c; c = c->next) - if (!strncmp (command, c->name, len) - && (!ignore_help_classes || c->function)) - { - found = c; - nfound++; - if (c->name[len] == '\0') - { - nfound = 1; - break; - } - } - - /* If nothing matches, we have a simple failure. */ - if (nfound == 0) - return 0; - - if (nfound > 1) - { - if (result_list != NULL) - /* Will be modified in calling routine - if we know what the prefix command is. */ - *result_list = 0; - return (struct cmd_list_element *) -1; /* Ambiguous. */ - } - - /* We've matched something on this list. Move text pointer forward. */ - - *text = p; - if (found->prefixlist) - { - c = lookup_cmd_1 (text, *found->prefixlist, result_list, - ignore_help_classes); - if (!c) - { - /* Didn't find anything; this is as far as we got. */ - if (result_list != NULL) - *result_list = clist; - return found; - } - else if (c == (struct cmd_list_element *) -1) - { - /* We've gotten this far properley, but the next step - is ambiguous. We need to set the result list to the best - we've found (if an inferior hasn't already set it). */ - if (result_list != NULL) - if (!*result_list) - /* This used to say *result_list = *found->prefixlist - If that was correct, need to modify the documentation - at the top of this function to clarify what is supposed - to be going on. */ - *result_list = found; - return c; - } - else - { - /* We matched! */ - return c; - } - } - else - { - if (result_list != NULL) - *result_list = clist; - return found; - } -} - -/* All this hair to move the space to the front of cmdtype */ - -void -undef_cmd_error (cmdtype, q) - char *cmdtype, *q; -{ - error ("Undefined %scommand: \"%s\". Try \"help%s%.*s\".", - cmdtype, - q, - *cmdtype? " ": "", - strlen(cmdtype)-1, - cmdtype); -} - -/* Look up the contents of *LINE as a command in the command list LIST. - LIST is a chain of struct cmd_list_element's. - If it is found, return the struct cmd_list_element for that command - and update *LINE to point after the command name, at the first argument. - If not found, call error if ALLOW_UNKNOWN is zero - otherwise (or if error returns) return zero. - Call error if specified command is ambiguous, - unless ALLOW_UNKNOWN is negative. - CMDTYPE precedes the word "command" in the error message. - - If INGNORE_HELP_CLASSES is nonzero, ignore any command list - elements which are actually help classes rather than commands (i.e. - the function field of the struct cmd_list_element is 0). */ - -struct cmd_list_element * -lookup_cmd (line, list, cmdtype, allow_unknown, ignore_help_classes) - char **line; - struct cmd_list_element *list; - char *cmdtype; - int allow_unknown; - int ignore_help_classes; -{ - struct cmd_list_element *last_list = 0; - struct cmd_list_element *c = - lookup_cmd_1 (line, list, &last_list, ignore_help_classes); - char *ptr = (*line) + strlen (*line) - 1; - - /* Clear off trailing whitespace. */ - while (ptr >= *line && (*ptr == ' ' || *ptr == '\t')) - ptr--; - *(ptr + 1) = '\0'; - - if (!c) - { - if (!allow_unknown) - { - if (!*line) - error ("Lack of needed %scommand", cmdtype); - else - { - char *p = *line, *q; - - while (isalnum(*p) || *p == '-') - p++; - - q = (char *) alloca (p - *line + 1); - strncpy (q, *line, p - *line); - q[p-*line] = '\0'; - undef_cmd_error (cmdtype, q); - } - } - else - return 0; - } - else if (c == (struct cmd_list_element *) -1) - { - /* Ambigous. Local values should be off prefixlist or called - values. */ - int local_allow_unknown = (last_list ? last_list->allow_unknown : - allow_unknown); - char *local_cmdtype = last_list ? last_list->prefixname : cmdtype; - struct cmd_list_element *local_list = - (last_list ? *(last_list->prefixlist) : list); - - if (local_allow_unknown < 0) - { - if (last_list) - return last_list; /* Found something. */ - else - return 0; /* Found nothing. */ - } - else - { - /* Report as error. */ - int amb_len; - char ambbuf[100]; - - for (amb_len = 0; - ((*line)[amb_len] && (*line)[amb_len] != ' ' - && (*line)[amb_len] != '\t'); - amb_len++) - ; - - ambbuf[0] = 0; - for (c = local_list; c; c = c->next) - if (!strncmp (*line, c->name, amb_len)) - { - if (strlen (ambbuf) + strlen (c->name) + 6 < (int)sizeof ambbuf) - { - if (strlen (ambbuf)) - strcat (ambbuf, ", "); - strcat (ambbuf, c->name); - } - else - { - strcat (ambbuf, ".."); - break; - } - } - error ("Ambiguous %scommand \"%s\": %s.", local_cmdtype, - *line, ambbuf); - return 0; /* lint */ - } - } - else - { - /* We've got something. It may still not be what the caller - wants (if this command *needs* a subcommand). */ - while (**line == ' ' || **line == '\t') - (*line)++; - - if (c->prefixlist && **line && !c->allow_unknown) - undef_cmd_error (c->prefixname, *line); - - /* Seems to be what he wants. Return it. */ - return c; - } - return 0; -} - -#if 0 -/* Look up the contents of *LINE as a command in the command list LIST. - LIST is a chain of struct cmd_list_element's. - If it is found, return the struct cmd_list_element for that command - and update *LINE to point after the command name, at the first argument. - If not found, call error if ALLOW_UNKNOWN is zero - otherwise (or if error returns) return zero. - Call error if specified command is ambiguous, - unless ALLOW_UNKNOWN is negative. - CMDTYPE precedes the word "command" in the error message. */ - -struct cmd_list_element * -lookup_cmd (line, list, cmdtype, allow_unknown) - char **line; - struct cmd_list_element *list; - char *cmdtype; - int allow_unknown; -{ - register char *p; - register struct cmd_list_element *c, *found; - int nfound; - char ambbuf[100]; - char *processed_cmd; - int i, cmd_len; - - /* Skip leading whitespace. */ - - while (**line == ' ' || **line == '\t') - (*line)++; - - /* Clear out trailing whitespace. */ - - p = *line + strlen (*line); - while (p != *line && (p[-1] == ' ' || p[-1] == '\t')) - p--; - *p = 0; - - /* Find end of command name. */ - - p = *line; - while (*p == '-' - || (*p >= 'a' && *p <= 'z') - || (*p >= 'A' && *p <= 'Z') - || (*p >= '0' && *p <= '9')) - p++; - - /* Look up the command name. - If exact match, keep that. - Otherwise, take command abbreviated, if unique. Note that (in my - opinion) a null string does *not* indicate ambiguity; simply the - end of the argument. */ - - if (p == *line) - { - if (!allow_unknown) - error ("Lack of needed %scommand", cmdtype); - return 0; - } - - /* Copy over to a local buffer, converting to lowercase on the way. - This is in case the command being parsed is a subcommand which - doesn't match anything, and that's ok. We want the original - untouched for the routine of the original command. */ - - processed_cmd = (char *) alloca (p - *line + 1); - for (cmd_len = 0; cmd_len < p - *line; cmd_len++) - { - char x = (*line)[cmd_len]; - if (x >= 'A' && x <= 'Z') - processed_cmd[cmd_len] = x - 'A' + 'a'; - else - processed_cmd[cmd_len] = x; - } - processed_cmd[cmd_len] = '\0'; - - /* Check all possibilities in the current command list. */ - found = 0; - nfound = 0; - for (c = list; c; c = c->next) - { - if (!strncmp (processed_cmd, c->name, cmd_len)) - { - found = c; - nfound++; - if (c->name[cmd_len] == 0) - { - nfound = 1; - break; - } - } - } - - /* Report error for undefined command name. */ - - if (nfound != 1) - { - if (nfound > 1 && allow_unknown >= 0) - { - ambbuf[0] = 0; - for (c = list; c; c = c->next) - if (!strncmp (processed_cmd, c->name, cmd_len)) - { - if (strlen (ambbuf) + strlen (c->name) + 6 < sizeof ambbuf) - { - if (strlen (ambbuf)) - strcat (ambbuf, ", "); - strcat (ambbuf, c->name); - } - else - { - strcat (ambbuf, ".."); - break; - } - } - error ("Ambiguous %scommand \"%s\": %s.", cmdtype, - processed_cmd, ambbuf); - } - else if (!allow_unknown) - error ("Undefined %scommand: \"%s\".", cmdtype, processed_cmd); - return 0; - } - - /* Skip whitespace before the argument. */ - - while (*p == ' ' || *p == '\t') p++; - *line = p; - - if (found->prefixlist && *p) - { - c = lookup_cmd (line, *found->prefixlist, found->prefixname, - found->allow_unknown); - if (c) - return c; - } - - return found; -} -#endif - -/* Helper function for SYMBOL_COMPLETION_FUNCTION. */ - -/* Return a vector of char pointers which point to the different - possible completions in LIST of TEXT. */ - -char ** -complete_on_cmdlist (list, text) - struct cmd_list_element *list; - char *text; -{ - struct cmd_list_element *ptr; - char **matchlist; - int sizeof_matchlist; - int matches; - int textlen = strlen (text); - - sizeof_matchlist = 10; - matchlist = (char **) xmalloc (sizeof_matchlist * sizeof (char *)); - matches = 0; - - for (ptr = list; ptr; ptr = ptr->next) - if (!strncmp (ptr->name, text, textlen) - && !ptr->abbrev_flag - && (ptr->function - || ptr->prefixlist)) - { - if (matches == sizeof_matchlist) - { - sizeof_matchlist *= 2; - matchlist = (char **) xrealloc ((char *)matchlist, - (sizeof_matchlist - * sizeof (char *))); - } - - matchlist[matches] = (char *) - xmalloc (strlen (ptr->name) + 1); - strcpy (matchlist[matches++], ptr->name); - } - - if (matches == 0) - { - free (matchlist); - matchlist = 0; - } - else - { - matchlist = (char **) xrealloc ((char *)matchlist, ((matches + 1) - * sizeof (char *))); - matchlist[matches] = (char *) 0; - } - - return matchlist; -} - -static int -parse_binary_operation (arg) - char *arg; -{ - int length; - - if (!arg || !*arg) - return 1; - - length = strlen (arg); - - while (arg[length - 1] == ' ' || arg[length - 1] == '\t') - length--; - - if (!strncmp (arg, "on", length) - || !strncmp (arg, "1", length) - || !strncmp (arg, "yes", length)) - return 1; - else - if (!strncmp (arg, "off", length) - || !strncmp (arg, "0", length) - || !strncmp (arg, "no", length)) - return 0; - else - { - error ("\"on\" or \"off\" expected."); - return 0; - } -} - -/* Do a "set" or "show" command. ARG is NULL if no argument, or the text - of the argument, and FROM_TTY is nonzero if this command is being entered - directly by the user (i.e. these are just like any other - command). C is the command list element for the command. */ -void -do_setshow_command (arg, from_tty, c) - char *arg; - int from_tty; - struct cmd_list_element *c; -{ - if (c->type == set_cmd) - { - switch (c->var_type) - { - case var_string: - { - char *new; - char *p; - char *q; - int ch; - - if (arg == NULL) - arg = ""; - new = (char *) xmalloc (strlen (arg) + 2); - p = arg; q = new; - while (ch = *p++) - { - if (ch == '\\') - { - /* \ at end of argument is used after spaces - so they won't be lost. */ - if (*p == 0) - break; - ch = parse_escape (&p); - if (ch == 0) - break; /* C loses */ - else if (ch > 0) - *q++ = ch; - } - else - *q++ = ch; - } - if (*(p - 1) != '\\') - *q++ = ' '; - *q++ = '\0'; - new = (char *) xrealloc (new, q - new); - if (*(char **)c->var != NULL) - free (*(char **)c->var); - *(char **) c->var = new; - } - break; - case var_string_noescape: - if (arg == NULL) - arg = ""; - if (*(char **)c->var != NULL) - free (*(char **)c->var); - *(char **) c->var = savestring (arg, strlen (arg)); - break; - case var_filename: - if (arg == NULL) - error_no_arg ("filename to set it to."); - if (*(char **)c->var != NULL) - free (*(char **)c->var); - *(char **)c->var = tilde_expand (arg); - break; - case var_boolean: - *(int *) c->var = parse_binary_operation (arg); - break; - case var_uinteger: - if (arg == NULL) - error_no_arg ("integer to set it to."); - *(int *) c->var = parse_and_eval_address (arg); - if (*(int *) c->var == 0) - *(int *) c->var = UINT_MAX; - break; - case var_zinteger: - if (arg == NULL) - error_no_arg ("integer to set it to."); - *(int *) c->var = parse_and_eval_address (arg); - break; - default: - error ("gdb internal error: bad var_type in do_setshow_command"); - } - } - else if (c->type == show_cmd) - { - /* Print doc minus "show" at start. */ - print_doc_line (stdout, c->doc + 5); - - fputs_filtered (" is ", stdout); - wrap_here (" "); - switch (c->var_type) - { - case var_string: - { - unsigned char *p; - fputs_filtered ("\"", stdout); - for (p = *(unsigned char **) c->var; *p != '\0'; p++) - printchar (*p, stdout, '"'); - fputs_filtered ("\"", stdout); - } - break; - case var_string_noescape: - case var_filename: - fputs_filtered ("\"", stdout); - fputs_filtered (*(char **) c->var, stdout); - fputs_filtered ("\"", stdout); - break; - case var_boolean: - fputs_filtered (*(int *) c->var ? "on" : "off", stdout); - break; - case var_uinteger: - if (*(unsigned int *) c->var == UINT_MAX) { - fputs_filtered ("unlimited", stdout); - break; - } - /* else fall through */ - case var_zinteger: - fprintf_filtered (stdout, "%d", *(unsigned int *) c->var); - break; - default: - error ("gdb internal error: bad var_type in do_setshow_command"); - } - fputs_filtered (".\n", stdout); - } - else - error ("gdb internal error: bad cmd_type in do_setshow_command"); - (*c->function) (NULL, from_tty, c); -} - -/* Show all the settings in a list of show commands. */ - -void -cmd_show_list (list, from_tty, prefix) - struct cmd_list_element *list; - int from_tty; - char *prefix; -{ - for (; list != NULL; list = list->next) { - /* If we find a prefix, run its list, prefixing our output by its - prefix (with "show " skipped). */ - if (list->prefixlist && !list->abbrev_flag) - cmd_show_list (*list->prefixlist, from_tty, list->prefixname + 5); - if (list->type == show_cmd) - { - fputs_filtered (prefix, stdout); - fputs_filtered (list->name, stdout); - fputs_filtered (": ", stdout); - do_setshow_command ((char *)NULL, from_tty, list); - } - } -} - -/* ARGSUSED */ -static void -shell_escape (arg, from_tty) - char *arg; - int from_tty; -{ - int rc, status, pid; - char *p, *user_shell; - extern char *rindex (); - - if ((user_shell = (char *) getenv ("SHELL")) == NULL) - user_shell = "/bin/sh"; - - /* Get the name of the shell for arg0 */ - if ((p = rindex (user_shell, '/')) == NULL) - p = user_shell; - else - p++; /* Get past '/' */ - - if ((pid = fork()) == 0) - { - if (!arg) - execl (user_shell, p, 0); - else - execl (user_shell, p, "-c", arg, 0); - - fprintf (stderr, "Exec of shell failed\n"); - exit (0); - } - - if (pid != -1) - while ((rc = wait (&status)) != pid && rc != -1) - ; - else - error ("Fork failed"); -} - -static void -make_command (arg, from_tty) - char *arg; - int from_tty; -{ - char *p; - - if (arg == 0) - p = "make"; - else - { - p = xmalloc (sizeof("make ") + strlen(arg)); - strcpy (p, "make "); - strcpy (p + sizeof("make ")-1, arg); - } - - shell_escape (p, from_tty); -} - -static void -user_info_1 (c, stream) - struct cmd_list_element *c; - FILE *stream; -{ - register struct command_line *cmdlines; - - cmdlines = c->user_commands; - if (!cmdlines) - return; - fprintf_filtered (stream, "User command %s:\n", c->name); - while (cmdlines) - { - fprintf_filtered (stream, "%s\n", cmdlines->line); - cmdlines = cmdlines->next; - } - fputs_filtered ("\n", stream); -} - -/* ARGSUSED */ -static void -user_info (args, from_tty) - char *args; - int from_tty; -{ - struct cmd_list_element *c; - extern struct cmd_list_element *cmdlist; - - if (args) - { - c = lookup_cmd (&args, cmdlist, "", 0, 1); - if (c->class != class_user) - error ("Not a user command."); - user_info_1 (c, stdout); - } - else - { - for (c = cmdlist; c; c = c->next) - { - if (c->class == class_user) - user_info_1 (c, stdout); - } - } -} - -void -_initialize_command () -{ - add_com ("shell", class_support, shell_escape, - "Execute the rest of the line as a shell command. \n\ -With no arguments, run an inferior shell."); - - add_com ("make", class_support, make_command, - "Run the ``make'' program using the rest of the line as arguments."); - - add_info ("user", user_info, "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."); -} diff --git a/gdb/command.h b/gdb/command.h deleted file mode 100644 index aa907fd9d1a..00000000000 --- a/gdb/command.h +++ /dev/null @@ -1,151 +0,0 @@ -/* Header file for command-reading library command.c. - Copyright (C) 1986, 1989, 1990 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifndef _COMMAND_H_INCLUDED -#define _COMMAND_H_INCLUDED - -/* 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. */ -typedef enum cmd_types { - not_set_cmd, - set_cmd, - show_cmd, -} cmd_types; - -/* 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, - /* 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, - /* 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, -} var_types; - -/* This structure records one command'd definition. */ - -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. - Zero for command class names and for help topics that - are not really commands. */ - void (*function) (); -# define NO_FUNCTION ((void (*)()) 0 ) - - /* 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; - - /* Auxiliary information. - It is up to the calling program to decide what this means. */ - char *aux; - - /* 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" to complete to "break", which it - otherwise wouldn't. */ - char abbrev_flag; - - /* Completion routine for this command. */ - char **(*completer)(); - - /* 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. */ - char *var; - - /* What kind of variable is *VAR? */ - var_types var_type; - - /* Pointer to command strings of user-defined commands */ - struct command_line *user_commands; - }; - -/* Forward-declarations of the entry-points of command.c. */ - -extern struct cmd_list_element *add_cmd (); -extern struct cmd_list_element *add_alias_cmd (); -extern struct cmd_list_element *add_prefix_cmd (); -extern struct cmd_list_element *add_abbrev_prefix_cmd (); -extern struct cmd_list_element *lookup_cmd (), *lookup_cmd_1 (); -extern void add_com (); -extern void add_com_alias (); -extern void add_info (); -extern void add_info_alias (); -extern char **complete_on_cmdlist (); -extern void delete_cmd (); -extern void help_cmd (); -extern struct cmd_list_element *add_set_cmd (); -extern struct cmd_list_element *add_show_from_set (); - -/* Do a "set" or "show" command. ARG is NULL if no argument, or the text - of the argument, and FROM_TTY is nonzero if this command is being entered - directly by the user (i.e. these are just like any other - command). C is the command list element for the command. */ -extern void do_setshow_command (); - -/* Do a "show" command for each thing on a command list. */ -extern void cmd_show_list (); - -extern void error_no_arg (); /* Print error for missing argument */ -extern void dont_repeat (); /* Avoid auto-repeat of command */ - -#endif /* _COMMAND_H_INCLUDED */ diff --git a/gdb/config.gdb b/gdb/config.gdb deleted file mode 100755 index c380fe45772..00000000000 --- a/gdb/config.gdb +++ /dev/null @@ -1,180 +0,0 @@ -#!/bin/sh - -# Shell script to do machine-dependent things in -# preparation for compiling gdb. -# -# Usage: config.gdb machine -# -# If config.gdb succeeds, it leaves its status in config.status. -# If config.gdb fails after disturbing the status quo, -# config.status is removed. - -progname=$0 -host= -target= -list_hosts= -list_targets= -srcdir= - -for arg in $*; do - case $arg in - -srcdir=*|+srcdir=*) - srcdir=`echo $arg | sed 's/[+-]srcdir=//'` - ;; - -host|+host) - list_hosts=true - ;; - -target|+target) - list_targets=true - ;; - -host=*|+host=*) - if [ "$host" = "" ]; then - host=`echo $arg | sed 's/[+-]host=//'` - else - echo Error: Attempt to specify host machine twice - bad=true - fi - ;; - -target=*|+target=*) - if [ "$target" = "" ]; then - target=`echo $arg | sed 's/[+-]target=//'` - else - echo Error: Attempt to specify target machine twice - bad=true - fi - ;; - *) - if [ "$host" = "" ]; then - host=$arg - else - if [ "$target" = "" ]; then - target=$arg - else - echo Error: More arguments than host and target machine names - bad=true - fi - fi - ;; - esac -done - -if [ "$target" = "" ]; then target=$host; fi -if [ "$host" = "" ]; then bad=true; fi - -# Find the source files, if location was not specified -if [ "$srcdir" = "" ]; then - srcdirdefaulted=true - srcdir=. - if [ ! -r main.c ]; then - srcdir=.. - fi -fi -if [ ! -r ${srcdir}/main.c ]; then - if [ "$srcdirdefaulted" != "true" ]; then - echo "$progname: Can't find debugger sources in \`${srcdir}'." 1>&2 - else - echo "$progname: Can't find debugger sources in \`.' or \`..'." 1>&2 - fi - exit 1 -fi - -if [ "$list_hosts" = "true" ]; then - cd $srcdir/xconfig - for i in * ; do -# The {} in ${i} are required or else /bin/sh in sony newsos 3.2 removes -# the quote after it. - awk <$i "NR == 1 { lastchar = substr(\"${i}\", length(\"${i}\"), 1) -if (lastchar != \"~\" && lastchar != \"#\") \ -printf \"%-12s %s\n\", \"${i}\", substr(\$0,2) }" - done -fi - -if [ "$list_targets" = "true" ]; then - cd $srcdir/tconfig - for i in * ; do - awk <$i "NR == 1 { lastchar = substr(\"${i}\", length(\"${i}\"), 1) -if (lastchar != \"~\" && lastchar != \"#\") \ -printf \"%-12s %s\n\", \"${i}\", substr(\$0,2) }" - done -fi - -if [ "$list_hosts" = "true" -o "$list_targets" = "true" ]; then - exit 0 -fi - -if [ "$host" != "" -a ! -f $srcdir/xconfig/$host ]; then - echo "No such host $host" - bad=true -fi - -if [ "$target" != "" -a ! -f $srcdir/tconfig/$target ]; then - echo "No such target $target" - bad=true -fi - -if [ "$bad" = "true" ] ; then - echo "Usage: " - echo " $progname [+srcdir=\`dir'] machine" - echo " For normal usage" - echo " $progname [+srcdir=\`dir'] \`host' \`target'" - echo " $progname [+srcdir=\`dir'] +host=\`host' +target=\`target'" - echo " If you are doing remote debugging between machines of two" - echo " different types (cross-debugging). \`host' is the type of" - echo " machine on which GDB will be running. \`target' is the" - echo " machine that the program you are debugging will be" - echo " running on." - echo " $progname +host" - echo " Print a list of valid host machine types." - echo " $progname +target" - echo " Print a list of valid target machine types." - echo - echo " +srcdir=\`dir' means that the sources are in \`dir'. For" - echo " example, \`cd /obj/hp300; config.gdb +srcdir=/src/gdb hp300'" - echo " If +srcdir is not specified, sources can either be in \`.'" - echo " or \`..'." - echo - - if [ -r config.status ] - then - cat config.status - fi - exit 1 -fi - -rm -f tm.h xm.h - -cat $srcdir/xconfig/$host $srcdir/tconfig/$target | awk '$1 == "#msg" { - print substr($0,6)}' -paramfile=${srcdir}/`awk ' - $1 == "TM_FILE=" { print $2 }' <$srcdir/tconfig/$target` -if [ "$paramfile" != "${srcdir}/" ] ; then - # Make a symlink if possible, otherwise try a hard link - ln -s $paramfile tm.h 2>/dev/null || ln $paramfile tm.h -fi - -paramfile=${srcdir}/`awk ' - $1 == "XM_FILE=" { print $2 }' <$srcdir/xconfig/$host` -if [ "$paramfile" != "${srcdir}/" ] ; then - # Make a symlink if possible, otherwise try a hard link - ln -s $paramfile xm.h 2>/dev/null || ln $paramfile xm.h -fi - -rm -f config.status - -case ${srcdir} in - .) - ;; - *) - echo "srcdir=${srcdir}" >./Makefile.sdir - grep -s "source ${srcdir}/.gdbinit" .gdbinit 2>/dev/null || \ - echo "source ${srcdir}/.gdbinit" >> .gdbinit -esac - -rm -f Makefile -make "srcdir=${srcdir}" \ - "M_MAKEFILE=$srcdir/tconfig/$target $srcdir/xconfig/$host" \ - -f $srcdir/Makefile.dist Makefile - -echo "GDB is now set up for host machine $host and target machine $target." \ - | tee config.status -exit 0 diff --git a/gdb/config.status b/gdb/config.status deleted file mode 100755 index ec871762a22..00000000000 --- a/gdb/config.status +++ /dev/null @@ -1 +0,0 @@ -GDB is now set up for host machine none and target machine none. diff --git a/gdb/config.sub b/gdb/config.sub deleted file mode 100755 index dac9ab89d4f..00000000000 --- a/gdb/config.sub +++ /dev/null @@ -1,446 +0,0 @@ -#!/bin/sh - -# Configuration subroutine to validate and canonicalize a configuration type. -# Supply the specified configuration type as an argument. -# If it is invalid, we print an error message on stderr and exit with code 1. -# Otherwise, we print the canonical config type on stdout and succeed. - -# This file is supposed to be the same for all GNU packages -# and recognize all the CPU types, system types and aliases -# that are meaningful with *any* GNU software. -# Each package is responsible for reporting which valid configurations -# it does not support. The user should be able to distinguish -# a failure to support a valid configuration from a meaningless -# configuration (e.g. a typo). - -# Please email any bugs, comments, and/or additions to this file to: -# configure@cygnus.com - -# decode aliases into canonical names - -case "$1" in -# cpu alone is a valid alias for cpu-none-none. -vax | tahoe | i386 | i860 | m68k | m68000 | m88k | sparc | ns32k \ - | alliant | arm | c1 | c2 | mips | pyramid | tron | a29k \ - | romp | rs6000 | i960 | h8300) - cpu=$1 - vendor=none - os=none - ;; -altos | altos3068) - cpu=m68k - vendor=altos - os=sysv # maybe? - ;; -altosgas) - cpu=m68k - vendor=altos - os=gas - ;; -am29k) - cpu=a29k - vendor=none - os=bsd - ;; -amdahl) - cpu=580 - vendor=amdahl - os=uts - ;; -amigados) - cpu=m68k - vendor=cbm - os=amigados # Native AmigaDOS - ;; -amigaunix | amix) - cpu=m68k - vendor=cbm - os=svr4 # System V Release 4 (svr4 is an industry recognized acronym) - ;; -apollo68) - cpu=m68k - vendor=apollo - os=sysv # maybe? - ;; -balance) - cpu=ns32k - vendor=sequent - os=dynix - ;; -convex-c1) - cpu=c1 - vendor=convex - os=sysv # maybe? - ;; -convex-c2) - cpu=c2 - vendor=convex - os=sysv # maybe? - ;; -cray | ymp) - cpu=ymp - vendor=cray - os=unicos - ;; -cray2) - cpu=cray2 - vendor=cray - os=unicos - ;; -dec3100 | decstatn | decstation | decstation-3100 | pmax | pmin) - cpu=mips - vendor=dec - os=ultrix - ;; -delta | 3300 | motorola-3300 | motorola-delta \ - | 3300-motorola | delta-motorola) - cpu=m68k - vendor=motorola - os=sysv # maybe? - ;; - -delta88) - cpu=m88k - vendor=motorola - os=m88kbcs - ;; - -gmicro) - cpu=tron - vendor=gmicro - os=sysv # maybe? - ;; - -h8300hds) - cpu=h8300 - vendor=hitachi - os=hds - ;; - -# start-sanitize-v9 -hal-32 | hal32) - cpu=sparc64 - vendor=hal - os=hal32 - ;; -hal-64 | hal64) - cpu=sparc64 - vendor=hal - os=hal64 - ;; -sparc64) - cpu=sparc64 - vendor=sun - os=v9 - ;; -sparc64-v7 | sparc64v7) - cpu=sparc64 - vendor=sun - os=v7 - ;; -# end-sanitize-v9 -hp300bsd) - cpu=m68k - vendor=hp - os=bsd - ;; -hp300hpux | hpux | hp9k3[2-9][0-9]) - cpu=m68k - vendor=hp - os=hpux - ;; -hp9k31[0-9] | hp9k2[0-9][0-9]) - cpu=m68000 - vendor=hp - os=hpux - ;; -i386sco) - cpu=i386 - vendor=sco - os=sysv # maybe? - ;; -i386v) - cpu=i386 - vendor=none - os=sysv - ;; -i386v32) - cpu=i386 - vendor=none - os=sysv32 - ;; -iris | iris4d) - cpu=mips - vendor=sgi - os=irix # maybe? - ;; - -dpx2) - vendor=bull - cpu=m68k - os=sysv - ;; -isi | isi68) - cpu=m68k - vendor=isi - os=sysv # maybe? - ;; -littlemips) - cpu=mips - vendor=little - os=bsd - ;; -magnum | m3230) - cpu=mips - vendor=mips - os=sysv # maybe? - ;; -merlin) - cpu=ns32k - vendor=utek - os=sysv # maybe? - ;; -miniframe) - cpu=m68000 - vendor=convergent - os=sysv # maybe? - ;; -mmax) - cpu=ns32k - vendor=encore - os=sysv # maybe? - ;; -news | news700 | news800 | news900) - cpu=m68k - vendor=sony - os=newsos3 # Based on bsd-4.3 - ;; -news1000) - cpu=m68030 - vendor=sony - os=newsos3 # ? - ;; -news-3600 | bigmips | risc-news) - cpu=mips - vendor=sony - os=newsos4 # Presumably? - ;; -next) - cpu=m68k - vendor=next - os=sysv # maybe? - ;; -nindy960) - cpu=i960 - vendor=intel - os=nindy - ;; -none) - cpu=none - vendor=none - os=none - ;; -np1) - cpu=np1 - vendor=gould - os=sysv # maybe? - ;; -rtpc) - cpu=romp - vendor=ibm - os=aix # maybe? - ;; -pbd) - cpu=sparc - vendor=unicom - os=sysv - ;; -pn) - cpu=pn - vendor=gould - os=sysv # maybe? - ;; -ps2) - cpu=i386 - vendor=ibm - os=sysv # maybe? - ;; -sun2) - cpu=m68000 - vendor=sun - os=sunos4 - ;; -sun2os3) - cpu=m68000 - vendor=sun - os=sunos3 - ;; -sun2os4) - cpu=m68000 - vendor=sun - os=sunos4 - ;; -sun3) - cpu=m68k - vendor=sun - os=sunos4 - ;; -sun3os3) - cpu=m68k - vendor=sun - os=sunos3 - ;; -sun3os4) - cpu=m68k - vendor=sun - os=sunos4 - ;; -sun386 | roadrunner | sun386i) - cpu=i386 - vendor=sun - os=sunos - ;; -sun4) - cpu=sparc - vendor=sun - os=sunos4 - ;; -sun4os3) - cpu=sparc - vendor=sun - os=sunos3 - ;; -sun4os4) - cpu=sparc - vendor=sun - os=sunos4 - ;; -symmetry) - cpu=i386 - vendor=sequent - os=dynix - ;; -tower | tower-32) - cpu=m68k - vendor=ncr - os=sysv # maybe? - ;; -ultra3) - cpu=a29k - vendor=nyu - os=sym1 - ;; -umax) - cpu=ns32k - vendor=encore - os=sysv # maybe? - ;; -unixpc | safari | pc7300 | 3b1 | 7300 | 7300-att | att-7300) - cpu=m68k - vendor=att - os=sysv # maybe? - ;; -vax-dec) - cpu=vax - vendor=dec - os=ultrix # maybe? - ;; -vxworks68) - cpu=m68k - vendor=wrs - os=vxworks - ;; -vxworks960) - cpu=i960 - vendor=wrs - os=vxworks - ;; -xmp) - cpu=xmp - vendor=cray - os=unicos - ;; -# not an alias. parse what we expect to be a canonical name. -*) - cpu=`echo $1 | sed 's/-.*$//'` - - if [ "${cpu}" = "$1" ] ; then - # no vendor so this is an invalid name. - echo '***' No vendor: configuration \`$1\' not recognized 1>&2 - exit 1 - else - # parse out vendor - rest=`echo $1 | sed "s/${cpu}-//"` - vendor=`echo ${rest} | sed 's/-.*$//'` - - if [ "${vendor}" = "${rest}" ] ; then - # a missing os is acceptable - os=none - else - os=`echo ${rest} | sed "s/${vendor}-//"` - fi - fi - ;; -esac - -# At this point we should have three parts of a canonical name in cpu, -# vendor, and os. - -# verify that the cpu is known. - -case "${cpu}" in -none | vax | tahoe | i386 | i860 | m68k | m68000 | m88k | sparc \ - | ns32k | alliant | arm | c1 | c2 | mips | pyramid | tron \ - | a29k | romp | rs6000 | i960 | xmp | ymp | cray2 | 580 | h8300) - ;; - -# start-sanitize-v9 -sparc64) ;; -# end-sanitize-v9 - -*) - echo '***' Invalid cpu \`${cpu}\': configuration \`$1\' not recognized 1>&2 - exit 1 - ;; -esac - -# verify that the vendor is known. - -case "${vendor}" in - altos | amdahl | aout | apollo | att | bcs | bout |\ - cbm | convergent | convex | coff | cray | dec | encore |\ - gould | hitachi | intel | isi | hp | ibm | little | mips | motorola |\ - ncr | next | none | nyu | sco | sequent | sgi | sony | sun |\ - unicom | utek | wrs | bull ) ;; - -# start-sanitize-v9 -hal) ;; -# end-sanitize-v9 - -*) - echo '***' Invalid vendor \`${vendor}\': configuration \`$1\' not recognized 1>&2 - exit 1 - ;; -esac - -# verify that the os is known, if it exists. - -case "${os}" in -aix* | aout | bout | bsd* | coff | ctix* | dynix* | esix* | hpux* \ - | hds | irix* | isc* | kern | mach* | newsos* | nindy* | none \ - | osf* | sco* | sunos* | sysv* | ultrix* | unos* | v88r* \ - | vms* | vxworks* | sym[1-9]* | unicos* | uts | svr4 \ - | amigados) - ;; - -# start-sanitize-v9 -hal32 | hal64 | v7 | v9) ;; -# end-sanitize-v9 - -*) - echo '***' Invalid os \`${os}\': configuration \`$1\' not recognized 1>&2 - exit 1 - ;; -esac - -echo ${cpu}-${vendor}-${os} diff --git a/gdb/config/.Sanitize b/gdb/config/.Sanitize deleted file mode 100644 index 92cdbdf2303..00000000000 --- a/gdb/config/.Sanitize +++ /dev/null @@ -1,83 +0,0 @@ -# Sanitize.in for devo. -# $Id$ -# - -# Each directory to survive it's way into a release will need a file -# like this one called "./.Sanitize". All keyword lines must exist, -# and must exist in the order specified by this file. Each directory -# in the tree will be processed, top down, in the following order. - -# Hash started lines like this one are comments and will be deleted -# before anything else is done. Blank lines will also be squashed -# out. - -# The lines between the "Do-first:" line and the "Things-to-keep:" -# line are executed as a /bin/sh shell script before anything else is -# done in this - -Do-first: - -echo Sanitizing `pwd`... - -# All files listed between the "Things-to-keep:" line and the -# "Files-to-sed:" line will be kept. All other files will be removed. -# Directories listed in this section will have their own Sanitize -# called. Directories not listed will be removed in their entirety -# with rm -rf. - -Things-to-keep: - -3b1 -a29k -a29k-kern -altos -altosgas -amix -arm -bigmips -convex -decstation -delta88 -hp300bsd -hp300hpux -i386sco -i386aout -i386v -i386v-g -i386v32 -i386v32-g -i960 -irix3 -isi -littlemips -m88k -merlin -news -news1000 -nindy960 -none -np1 -pn -pyramid -sun2os3 -sun2os4 -sun3 -sun386 -sun3os3 -sun3os4 -sun4 -sun4os3 -sun4os4 -symmetry -tahoe -ultra3 -umax -vax -vxworks68 -vxworks960 - -Do-last: - -echo Done in `pwd`. - -# End of file. diff --git a/gdb/config/3b1.mh b/gdb/config/3b1.mh deleted file mode 100644 index 1dc2893ee55..00000000000 --- a/gdb/config/3b1.mh +++ /dev/null @@ -1,12 +0,0 @@ -# Host: AT&T 3b1/Unix pc -# I don't think cc has been tried. -traditional for -# (not sure whether necessary). -CC= gcc -traditional -# GCC runs out of virtual memory. -# A separate CC for pinsn routines is no longer supported, though. -# FIXME -- someone unlucky enough to have a 3B1, let bug-gcc@prep.ai.mit.edu -# know what works and what fails on the 3B1. -#PINSN_CC= cc - -XDEPFILES= infptrace.o coredep.o -XM_FILE= xm-3b1.h diff --git a/gdb/config/3b1.mt b/gdb/config/3b1.mt deleted file mode 100644 index bba2ed1e661..00000000000 --- a/gdb/config/3b1.mt +++ /dev/null @@ -1,3 +0,0 @@ -# Target: AT&T 3b1/Unix pc -TDEPFILES= exec.o m68k-pinsn.o -TM_FILE= tm-3b1.h diff --git a/gdb/config/a29k-kern.mt b/gdb/config/a29k-kern.mt deleted file mode 100644 index bdc9490a83c..00000000000 --- a/gdb/config/a29k-kern.mt +++ /dev/null @@ -1,10 +0,0 @@ -# Target: Remote AMD 29000 that runs Unix kernel on NYU Ultra3 processor board. -# This builds a gdb that should run on a host (we use sun3os4) that -# then communicates over the serial line to either an Adapt or MiniMon, -# for use in debugging Unix kernels. -# As compared to ordinary remote 29K debugging, this changes the register -# numbering a bit, to hold kernel regs, and adds support for looking at -# the upage. -TDEPFILES= exec.o am29k-pinsn.o am29k-tdep.o remote-mm.o remote-adapt.o -TM_FILE= tm-ultra3.h -TM_CFLAGS = -DKERNEL_DEBUGGING -DNO_HIF_SUPPORT diff --git a/gdb/config/a29k.mt b/gdb/config/a29k.mt deleted file mode 100644 index aa1db16b74c..00000000000 --- a/gdb/config/a29k.mt +++ /dev/null @@ -1,10 +0,0 @@ -# Target: AMD 29000. -# These defines should give you a gdb running on ? (sun3os4 if you like) -# that will be able to communicate over a serial line with either an -# EB board (remote-eb.c), -# Adapt (remote-adapt.c), -# or a MiniMon debugger (remote-mm.c). -# Or run native on an Ultracomputer. -TDEPFILES= exec.o am29k-pinsn.o am29k-tdep.o remote-eb.o remote-mm.o remote-adapt.o -TM_FILE= tm-29k.h -TM_CFLAGS = -DNO_HIF_SUPPORT diff --git a/gdb/config/altos.mh b/gdb/config/altos.mh deleted file mode 100644 index c88f65730ae..00000000000 --- a/gdb/config/altos.mh +++ /dev/null @@ -1,6 +0,0 @@ -# Host: Altos 3068 (68k, System V release 2) -XDEPFILES= infptrace.o altos-xdep.o -XM_FILE= xm-altos.h -REGEX=regex.o -REGEX1=regex.o -SYSV_DEFINE=-DSYSV diff --git a/gdb/config/altos.mt b/gdb/config/altos.mt deleted file mode 100644 index d156615f655..00000000000 --- a/gdb/config/altos.mt +++ /dev/null @@ -1,3 +0,0 @@ -# Target: Altos 3068 (68k, System V release 2) -TDEPFILES= m68k-pinsn.o exec.o -TM_FILE= tm-altos.h diff --git a/gdb/config/altosgas.mh b/gdb/config/altosgas.mh deleted file mode 100644 index b9b231af5d4..00000000000 --- a/gdb/config/altosgas.mh +++ /dev/null @@ -1,9 +0,0 @@ -# Host: Altos 3068 (68k, System V release 2), using COFF encapsulation -#msg Use of the coff encapsulation features require the GNU binutils utilities -#msg To be ahead of their System V counterparts in your path. - -XDEPFILES= infptrace.o altos-xdep.o -XM_FILE= xm-altos.h -REGEX=regex.o -REGEX1=regex.o -SYSV_DEFINE=-DSYSV diff --git a/gdb/config/altosgas.mt b/gdb/config/altosgas.mt deleted file mode 100644 index 7c2912e9d4a..00000000000 --- a/gdb/config/altosgas.mt +++ /dev/null @@ -1,7 +0,0 @@ -# Target: Altos 3068 (68k, System V release 2), using COFF encapsulation - -#msg Use of the coff encapsulation features require the GNU binutils utilities -#msg To be ahead of their System V counterparts in your path. - -TDEPFILES= m68k-pinsn.o exec.o -TM_FILE= tm-altosgas.h diff --git a/gdb/config/am29k b/gdb/config/am29k deleted file mode 100755 index 562e43f71d4..00000000000 --- a/gdb/config/am29k +++ /dev/null @@ -1,5 +0,0 @@ -# Target: AMD 29000 on EB29K board over a serial line. -TDEPFILES= exec.o am29k-pinsn.o remote-eb.o am29k-tdep.o -TM_FILE= tm-29k.h -# The following is for ../include/a.out.encap.h -TM_CFLAGS = -DCOFF_ENCAPSULATE -DTARGET=TARGET_AM29K diff --git a/gdb/config/amix.mh b/gdb/config/amix.mh deleted file mode 100644 index f110dccee6b..00000000000 --- a/gdb/config/amix.mh +++ /dev/null @@ -1,6 +0,0 @@ -# Host: Commodore Amiga running SVR4. -XDEPFILES= procfs.o -XM_FILE= xm-amix.h -SYSV_DEFINE=-DSYSV -REGEX=regex.o -REGEX1=regex.o diff --git a/gdb/config/amix.mt b/gdb/config/amix.mt deleted file mode 100644 index ea92eef9947..00000000000 --- a/gdb/config/amix.mt +++ /dev/null @@ -1,3 +0,0 @@ -# Target: Commodore Amiga running SVR4 -TDEPFILES= m68k-pinsn.o exec.o m68k-tdep.o -TM_FILE= tm-amix.h diff --git a/gdb/config/arm.mh b/gdb/config/arm.mh deleted file mode 100644 index 3f144f0f11f..00000000000 --- a/gdb/config/arm.mh +++ /dev/null @@ -1,3 +0,0 @@ -# Host: Acorn RISC machine running RISCiX (4.3bsd) -XDEPFILES= infptrace.o arm-xdep.o arm-convert.o -XM_FILE= xm-arm.h diff --git a/gdb/config/arm.mt b/gdb/config/arm.mt deleted file mode 100644 index 146995b69cb..00000000000 --- a/gdb/config/arm.mt +++ /dev/null @@ -1,3 +0,0 @@ -# Target: Acorn RISC machine running RISCiX (4.3bsd) -TDEPFILES= arm-tdep.o arm-pinsn.o -TM_FILE= tm-arm.h diff --git a/gdb/config/bigmips.mh b/gdb/config/bigmips.mh deleted file mode 100644 index 2dafb6e17b3..00000000000 --- a/gdb/config/bigmips.mh +++ /dev/null @@ -1,3 +0,0 @@ -# Host: Big-endian MIPS machine such as Sony News -XDEPFILES= infptrace.o mips-xdep.o coredep.o -XM_FILE= xm-bigmips.h diff --git a/gdb/config/bigmips.mt b/gdb/config/bigmips.mt deleted file mode 100644 index c52e39b1bed..00000000000 --- a/gdb/config/bigmips.mt +++ /dev/null @@ -1,3 +0,0 @@ -# Target: Big-endian MIPS machine such as Sony News -TDEPFILES= mips-pinsn.o mips-tdep.o mipsread.o exec.o -TM_FILE= tm-bigmips.h diff --git a/gdb/config/convex.mh b/gdb/config/convex.mh deleted file mode 100644 index 35a121fdcf0..00000000000 --- a/gdb/config/convex.mh +++ /dev/null @@ -1,3 +0,0 @@ -# Host: Convex Unix (4bsd) -XDEPFILES= convex-xdep.o -XM_FILE= xm-convex.h diff --git a/gdb/config/convex.mt b/gdb/config/convex.mt deleted file mode 100644 index aa8dfc5c64e..00000000000 --- a/gdb/config/convex.mt +++ /dev/null @@ -1,3 +0,0 @@ -# Target: Convex Unix (4bsd) -TDEPFILES= convex-tdep.o convex-pinsn.o -TM_FILE= tm-convex.h diff --git a/gdb/config/decstation.mh b/gdb/config/decstation.mh deleted file mode 100644 index 28fcc1eb855..00000000000 --- a/gdb/config/decstation.mh +++ /dev/null @@ -1,3 +0,0 @@ -# Host: Little-endian MIPS machine such as DECstation. -XDEPFILES= infptrace.o mips-xdep.o coredep.o -XM_FILE= xm-mips.h diff --git a/gdb/config/decstation.mt b/gdb/config/decstation.mt deleted file mode 100644 index 8025b9c4335..00000000000 --- a/gdb/config/decstation.mt +++ /dev/null @@ -1,3 +0,0 @@ -# Target: Little-endian MIPS machine such as DECstation. -TDEPFILES= mips-pinsn.o mips-tdep.o mipsread.o exec.o -TM_FILE= tm-mips.h diff --git a/gdb/config/delta88.mh b/gdb/config/delta88.mh deleted file mode 100644 index ce4f37c1389..00000000000 --- a/gdb/config/delta88.mh +++ /dev/null @@ -1,10 +0,0 @@ -# Host: Motorola 88000 running DGUX -XDEPFILES= infptrace.o m88k-xdep.o -XM_FILE= xm-delta88.h -REGEX=regex.o -REGEX1=regex.o -ALLOCA=alloca.o -ALLOCA1=alloca.o -# Have to use /bin/nm because a bfd nm won't do the right thing -MUNCH_DEFINE=MUNCH_NM=/bin/nm -M_INSTALL=cp gdb.z $(ddestdir)/man/man1 diff --git a/gdb/config/delta88.mt b/gdb/config/delta88.mt deleted file mode 100644 index 7dbb1746bcd..00000000000 --- a/gdb/config/delta88.mt +++ /dev/null @@ -1,3 +0,0 @@ -# Target: Motorola 88000 -TDEPFILES= m88k-tdep.o m88k-pinsn.o exec.o coredep.o -TM_FILE= tm-delta88.h diff --git a/gdb/config/hp300bsd.mh b/gdb/config/hp300bsd.mh deleted file mode 100644 index 273be90d625..00000000000 --- a/gdb/config/hp300bsd.mh +++ /dev/null @@ -1,3 +0,0 @@ -# Host: Hewlett-Packard 9000 series 300, running BSD -XDEPFILES= infptrace.o coredep.o -XM_FILE= xm-hp300bsd.h diff --git a/gdb/config/hp300bsd.mt b/gdb/config/hp300bsd.mt deleted file mode 100644 index 2a730ce4d76..00000000000 --- a/gdb/config/hp300bsd.mt +++ /dev/null @@ -1,3 +0,0 @@ -# Target: Hewlett-Packard 9000 series 300, running BSD -TDEPFILES= exec.o m68k-pinsn.o m68k-tdep.o -TM_FILE= tm-hp300bsd.h diff --git a/gdb/config/hp300hpux.mh b/gdb/config/hp300hpux.mh deleted file mode 100644 index 18dc1b83c87..00000000000 --- a/gdb/config/hp300hpux.mh +++ /dev/null @@ -1,15 +0,0 @@ -# Host: Hewlett-Packard 9000 series 300, running HPUX -# The following is true because gcc uses a different .o file format -# than the native HPUX compiler -#msg If you compile GDB with GCC on HPUX, you must make sure -#msg that the `nm' used in `munch' is GNU nm -#msg - -# The headers in the directory hp-include override system headers -# and tell GDB to use BSD executable file format (hence -Ihp-include) -XDEPFILES= infptrace.o hp300ux-xdep.o -XM_FILE= xm-hp300hpux.h -SYSV_DEFINE=-DSYSV -REGEX=regex.o -REGEX1=regex.o -ALLOCA=alloca.o diff --git a/gdb/config/hp300hpux.mt b/gdb/config/hp300hpux.mt deleted file mode 100644 index d061486ad15..00000000000 --- a/gdb/config/hp300hpux.mt +++ /dev/null @@ -1,11 +0,0 @@ -# Target: Hewlett-Packard 9000 series 300, running HPUX - -#msg Note that GDB can only read symbols from programs that were -#msg compiled with GCC -#msg - -# The headers in the directory hp-include override system headers -# and tell GDB to use BSD executable file format (hence -Ihp-include) -TM_CFLAGS=-Ihp-include -TDEPFILES= exec.o m68k-pinsn.o -TM_FILE= tm-hp300hpux.h diff --git a/gdb/config/i386aout.mt b/gdb/config/i386aout.mt deleted file mode 100644 index 1025038f556..00000000000 --- a/gdb/config/i386aout.mt +++ /dev/null @@ -1,4 +0,0 @@ -# Target: Intel 386 with a.out - -TDEPFILES= exec.o i386-tdep.o i386-pinsn.o -TM_FILE= tm-i386v-g.h diff --git a/gdb/config/i386mach.mh b/gdb/config/i386mach.mh deleted file mode 100644 index f880b8909a3..00000000000 --- a/gdb/config/i386mach.mh +++ /dev/null @@ -1,4 +0,0 @@ -# Host: Intel 386 running Mach - -XDEPFILES= infptrace.o mach386-xdep.o -XM_FILE= xm-i386mach.h diff --git a/gdb/config/i386sco.mh b/gdb/config/i386sco.mh deleted file mode 100644 index 1cbeb636f66..00000000000 --- a/gdb/config/i386sco.mh +++ /dev/null @@ -1,7 +0,0 @@ -# Host: Intel 386 running SCO Unix (pre-SVR4) -XDEPFILES= infptrace.o coredep.o i386-xdep.o i387-tdep.o -XM_FILE= xm-i386sco.h -XM_CLIBS= -lPW -SYSV_DEFINE=-DSYSV -REGEX=regex.o -REGEX1=regex.o diff --git a/gdb/config/i386sco.mt b/gdb/config/i386sco.mt deleted file mode 100644 index 720eea2a21a..00000000000 --- a/gdb/config/i386sco.mt +++ /dev/null @@ -1,3 +0,0 @@ -# Target: Intel 386 running SCO Unix (pre-SVR4) -TDEPFILES= exec.o i386-tdep.o i386-pinsn.o -TM_FILE= tm-i386v.h diff --git a/gdb/config/i386v-g.mh b/gdb/config/i386v-g.mh deleted file mode 100644 index 2316ffb6b8c..00000000000 --- a/gdb/config/i386v-g.mh +++ /dev/null @@ -1,7 +0,0 @@ -# Host: Intel 386 running System V, using COFF encapsulation -XDEPFILES= infptrace.o coredep.o i386-xdep.o i387-tdep.o -XM_FILE= xm-i386v.h -XM_CLIBS= -lPW -SYSV_DEFINE=-DSYSV -REGEX=regex.o -REGEX1=regex.o diff --git a/gdb/config/i386v-g.mt b/gdb/config/i386v-g.mt deleted file mode 100644 index cd07b5cb664..00000000000 --- a/gdb/config/i386v-g.mt +++ /dev/null @@ -1,7 +0,0 @@ -# Target: Intel 386 running System V, using COFF encapsulation - -#msg Use of the COFF encapsulation features requires the GNU binary utilities -#msg to be ahead of their System V counterparts in your path. - -TDEPFILES= exec.o i386-tdep.o i386-pinsn.o -TM_FILE= tm-i386v-g.h diff --git a/gdb/config/i386v.mh b/gdb/config/i386v.mh deleted file mode 100644 index 86dd4c283b9..00000000000 --- a/gdb/config/i386v.mh +++ /dev/null @@ -1,7 +0,0 @@ -# Host: Intel 386 running System V -XDEPFILES= infptrace.o coredep.o i386-xdep.o i387-tdep.o -XM_FILE= xm-i386v.h -XM_CLIBS= -lPW -SYSV_DEFINE=-DSYSV -REGEX=regex.o -REGEX1=regex.o diff --git a/gdb/config/i386v.mt b/gdb/config/i386v.mt deleted file mode 100644 index d595f7ec0da..00000000000 --- a/gdb/config/i386v.mt +++ /dev/null @@ -1,3 +0,0 @@ -# Target: Intel 386 running System V -TDEPFILES= exec.o i386-tdep.o i386-pinsn.o -TM_FILE= tm-i386v.h diff --git a/gdb/config/i386v32-g.mh b/gdb/config/i386v32-g.mh deleted file mode 100644 index 034951234eb..00000000000 --- a/gdb/config/i386v32-g.mh +++ /dev/null @@ -1,7 +0,0 @@ -# Host: Intel 386 running System V release 3.2, using COFF encapsulation -XDEPFILES= infptrace.o coredep.o i386-xdep.o i387-tdep.o -XM_FILE= xm-i386v32.h -XM_CLIBS= -lPW -SYSV_DEFINE=-DSYSV -REGEX=regex.o -REGEX1=regex.o diff --git a/gdb/config/i386v32-g.mt b/gdb/config/i386v32-g.mt deleted file mode 100644 index e2cd6b4f600..00000000000 --- a/gdb/config/i386v32-g.mt +++ /dev/null @@ -1,7 +0,0 @@ -# Target: Intel 386 running System V release 3.2, using COFF encapsulation - -#msg Use of the COFF encapsulation features requires the GNU binary utilities -#msg to be ahead of their System V counterparts in your path. - -TDEPFILES= exec.o i386-tdep.o i386-pinsn.o -TM_FILE= tm-i386v-g.h diff --git a/gdb/config/i386v32.mh b/gdb/config/i386v32.mh deleted file mode 100644 index 691b6984c7a..00000000000 --- a/gdb/config/i386v32.mh +++ /dev/null @@ -1,7 +0,0 @@ -# Host: Intel 386 running System V release 3.2 -XDEPFILES= infptrace.o coredep.o i386-xdep.o i387-tdep.o -XM_FILE= xm-i386v32.h -XM_CLIBS= -lPW -SYSV_DEFINE=-DSYSV -REGEX=regex.o -REGEX1=regex.o diff --git a/gdb/config/i386v32.mt b/gdb/config/i386v32.mt deleted file mode 100644 index 48d6abfbeae..00000000000 --- a/gdb/config/i386v32.mt +++ /dev/null @@ -1,3 +0,0 @@ -# Target: Intel 386 running System V release 3.2 -TDEPFILES= exec.o i386-tdep.o i386-pinsn.o -TM_FILE= tm-i386v.h diff --git a/gdb/config/i960.mt b/gdb/config/i960.mt deleted file mode 100644 index f6a7556b2a0..00000000000 --- a/gdb/config/i960.mt +++ /dev/null @@ -1,5 +0,0 @@ -# Target: Intel 80960, under NINDY or under VxWorks, selected at runtime. -#msg -#msg You must specify either "nindy960" or "vxworks960"; there is no -#msg generic i960 target any more. -#msg diff --git a/gdb/config/irix3.mh b/gdb/config/irix3.mh deleted file mode 100644 index 55dae08c2e3..00000000000 --- a/gdb/config/irix3.mh +++ /dev/null @@ -1,6 +0,0 @@ -# Host: SGI Iris running irix 3.x -XDEPFILES= infptrace.o coredep.o -XM_FILE= xm-irix3.h -ALLOCA=alloca.o -ALLOCA1=alloca.o -MUNCH_DEFINE=-B diff --git a/gdb/config/irix3.mt b/gdb/config/irix3.mt deleted file mode 100644 index 3cd05bb1e9d..00000000000 --- a/gdb/config/irix3.mt +++ /dev/null @@ -1,3 +0,0 @@ -# Target: Big-endian MIPS machine such as Sony News -TDEPFILES= mips-pinsn.o mips-tdep.o mipsread.o exec.o -TM_FILE= tm-irix3.h diff --git a/gdb/config/isi.mh b/gdb/config/isi.mh deleted file mode 100644 index 08bce4a6f20..00000000000 --- a/gdb/config/isi.mh +++ /dev/null @@ -1,3 +0,0 @@ -# Host: ISI Optimum V (3.05) under 4.3bsd. -XDEPFILES= infptrace.o coredep.o -XM_FILE= xm-isi.h diff --git a/gdb/config/isi.mt b/gdb/config/isi.mt deleted file mode 100644 index fb4d83f9d07..00000000000 --- a/gdb/config/isi.mt +++ /dev/null @@ -1,3 +0,0 @@ -# Target: ISI Optimum V (3.05) under 4.3bsd. -TDEPFILES= exec.o m68k-pinsn.o -TM_FILE= tm-isi.h diff --git a/gdb/config/littlemips.mh b/gdb/config/littlemips.mh deleted file mode 100644 index 28fcc1eb855..00000000000 --- a/gdb/config/littlemips.mh +++ /dev/null @@ -1,3 +0,0 @@ -# Host: Little-endian MIPS machine such as DECstation. -XDEPFILES= infptrace.o mips-xdep.o coredep.o -XM_FILE= xm-mips.h diff --git a/gdb/config/littlemips.mt b/gdb/config/littlemips.mt deleted file mode 100644 index 8025b9c4335..00000000000 --- a/gdb/config/littlemips.mt +++ /dev/null @@ -1,3 +0,0 @@ -# Target: Little-endian MIPS machine such as DECstation. -TDEPFILES= mips-pinsn.o mips-tdep.o mipsread.o exec.o -TM_FILE= tm-mips.h diff --git a/gdb/config/m88k.mh b/gdb/config/m88k.mh deleted file mode 100644 index 5d396aaecdd..00000000000 --- a/gdb/config/m88k.mh +++ /dev/null @@ -1,3 +0,0 @@ -# Host: Motorola 88000 running DGUX -XDEPFILES= infptrace.o m88k-xdep.o -XM_FILE= xm-m88k.h diff --git a/gdb/config/m88k.mt b/gdb/config/m88k.mt deleted file mode 100644 index abb8c85c32f..00000000000 --- a/gdb/config/m88k.mt +++ /dev/null @@ -1,3 +0,0 @@ -# Target: Motorola 88000 Binary Compatability Standard -TDEPFILES= m88k-tdep.o m88k-pinsn.o exec.o coredep.o -TM_FILE= tm-m88k.h diff --git a/gdb/config/merlin.mh b/gdb/config/merlin.mh deleted file mode 100644 index 7cd492e449a..00000000000 --- a/gdb/config/merlin.mh +++ /dev/null @@ -1,6 +0,0 @@ -# Host: Merlin running utek 2.1 -XDEPFILES= infptrace.o coredep.o -XM_FILE= xm-merlin.h -# See SHELL_FILE in m-merlin.h for a explanation of this. -M_INSTALL=cp /bin/sh /usr/local/lib/gdb-sh; \ -chmod ogu+rw /usr/local/lib/gdb-sh diff --git a/gdb/config/merlin.mt b/gdb/config/merlin.mt deleted file mode 100644 index 25460e23b93..00000000000 --- a/gdb/config/merlin.mt +++ /dev/null @@ -1,3 +0,0 @@ -# Target: Merlin running utek 2.1 -TDEPFILES= exec.o ns32k-pinsn.o -TM_FILE= tm-merlin.h diff --git a/gdb/config/mh-vax b/gdb/config/mh-vax deleted file mode 100755 index cee0da1416a..00000000000 --- a/gdb/config/mh-vax +++ /dev/null @@ -1,10 +0,0 @@ -# Host: DEC VAX running BSD or Ultrix -# The following types of /bin/cc failures have been observed: -# 1. Something in readline.c which I have never seen -# 2. ``"values.c", line 816: compiler error: schain botch'' -#msg /bin/cc has been known to fail on VAXen running BSD4.3 -#msg If this occurs, use gcc -#msg (but see comments in Makefile.dist about compiling with gcc). - -XDEPFILES= infptrace.o coredep.o -XM_FILE= xm-vax.h diff --git a/gdb/config/news.mh b/gdb/config/news.mh deleted file mode 100644 index 3b7c950d59b..00000000000 --- a/gdb/config/news.mh +++ /dev/null @@ -1,3 +0,0 @@ -# Host: Sony news series 700/800/900 (68020) running NewsOS version 3. -XDEPFILES= infptrace.o coredep.o news-xdep.o -XM_FILE= xm-news.h diff --git a/gdb/config/news.mt b/gdb/config/news.mt deleted file mode 100644 index f00779a5b6f..00000000000 --- a/gdb/config/news.mt +++ /dev/null @@ -1,3 +0,0 @@ -# Target: Sony news series 700/800/900 (68020) running NewsOS version 3. -TDEPFILES= m68k-pinsn.o exec.o m68k-tdep.o -TM_FILE= tm-news.h diff --git a/gdb/config/news1000.mh b/gdb/config/news1000.mh deleted file mode 100644 index 8388b359c81..00000000000 --- a/gdb/config/news1000.mh +++ /dev/null @@ -1,3 +0,0 @@ -# Host: Sony news series 1000 (68030) running NewsOS version 3. -XDEPFILES= infptrace.o coredep.o news-xdep.o -XM_FILE= xm-news1000.h diff --git a/gdb/config/news1000.mt b/gdb/config/news1000.mt deleted file mode 100644 index ca16e590ef3..00000000000 --- a/gdb/config/news1000.mt +++ /dev/null @@ -1,3 +0,0 @@ -# Target: Sony news series 1000 (68030) running NewsOS version 3. -TDEPFILES= m68k-pinsn.o exec.o -TM_FILE= tm-news.h diff --git a/gdb/config/nindy960.mt b/gdb/config/nindy960.mt deleted file mode 100644 index 0751bd6fb7c..00000000000 --- a/gdb/config/nindy960.mt +++ /dev/null @@ -1,4 +0,0 @@ -# Target: Intel 80960, in an embedded system under the NINDY monitor -TDEPFILES= exec.o i960-pinsn.o i960-tdep.o nindy-tdep.o remote-nindy.o nindy.o Onindy.o ttybreak.o ttyflush.o -TM_FILE= tm-nindy960.h -TM_CFLAGS= diff --git a/gdb/config/none.mh b/gdb/config/none.mh deleted file mode 100644 index 2a833479e15..00000000000 --- a/gdb/config/none.mh +++ /dev/null @@ -1,3 +0,0 @@ -# Host: "no target". This can be used to build you -# a Makefile that only runs administrative commands like 'clean', -# 'gdb.tar.Z', etc. diff --git a/gdb/config/none.mt b/gdb/config/none.mt deleted file mode 100644 index 9917e2b7ce1..00000000000 --- a/gdb/config/none.mt +++ /dev/null @@ -1,3 +0,0 @@ -# Target: "no target". -# This can be used to build you a Makefile that only runs administrative -# commands like 'clean', 'gdb.tar.Z', etc. diff --git a/gdb/config/np1.mh b/gdb/config/np1.mh deleted file mode 100644 index 8afa094c77f..00000000000 --- a/gdb/config/np1.mh +++ /dev/null @@ -1,3 +0,0 @@ -# Host: Gould NP1 -XDEPFILES= infptrace.o gould-xdep.o -XM_FILE= xm-np1.h diff --git a/gdb/config/np1.mt b/gdb/config/np1.mt deleted file mode 100644 index 1a5d68bb396..00000000000 --- a/gdb/config/np1.mt +++ /dev/null @@ -1,3 +0,0 @@ -# Target: Gould NP1 -TDEPFILES= exec.o gould-pinsn.o -TM_FILE= tm-np1.h diff --git a/gdb/config/pn.mh b/gdb/config/pn.mh deleted file mode 100644 index 56c58f968f2..00000000000 --- a/gdb/config/pn.mh +++ /dev/null @@ -1,3 +0,0 @@ -# Host: Gould Powernode -XDEPFILES= infptrace.o coredep.o -XM_FILE= xm-pn.h diff --git a/gdb/config/pn.mt b/gdb/config/pn.mt deleted file mode 100644 index e53ab9efa7c..00000000000 --- a/gdb/config/pn.mt +++ /dev/null @@ -1,3 +0,0 @@ -# Target: Gould Powernode -TDEPFILES= exec.o gould-pinsn.o -TM_FILE= tm-pn.h diff --git a/gdb/config/pyramid.mh b/gdb/config/pyramid.mh deleted file mode 100644 index 362a878772c..00000000000 --- a/gdb/config/pyramid.mh +++ /dev/null @@ -1,8 +0,0 @@ -# Host: Pyramid under OSx 4.0 (4.2bsd). - -#msg If you don't compile GDB with GCC, you'll need to add -#msg ALLOCA=alloca.o and ALLOCA1=alloca.o to the Makefile. -#msg - -XDEPFILES= pyr-xdep.o infptrace.o -XM_FILE= xm-pyr.h diff --git a/gdb/config/pyramid.mt b/gdb/config/pyramid.mt deleted file mode 100644 index 40c87861ee6..00000000000 --- a/gdb/config/pyramid.mt +++ /dev/null @@ -1,7 +0,0 @@ -# Target: Pyramid under OSx 4.0 (4.2bsd). - -#msg Note that GDB on Pyramids only works with GCC, -#msg at least for some programs. - -TDEPFILES= pyr-pinsn.o pyr-tdep.o exec.o -TM_FILE= tm-pyr.h diff --git a/gdb/config/rs6000.mh b/gdb/config/rs6000.mh deleted file mode 100644 index 6f644b5f64b..00000000000 --- a/gdb/config/rs6000.mh +++ /dev/null @@ -1,22 +0,0 @@ -# Host machine: IBM RS/6000 running AIX 3.1. -# Copyright (C) 1990, 1991 Free Software Foundation, Inc. - -# This file is part of GDB. - -# GDB 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 1, or (at your option) -# any later version. - -# GDB 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 GDB; see the file COPYING. If not, write to -# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - -XDEPFILES= xcoffexec.o infptrace.o rs6000-xdep.o -XM_FILE= xm-rs6000.h -XM_CFLAGS = -bnodelcsect diff --git a/gdb/config/rs6000.mt b/gdb/config/rs6000.mt deleted file mode 100644 index 85441c78d90..00000000000 --- a/gdb/config/rs6000.mt +++ /dev/null @@ -1,22 +0,0 @@ -# Target machine: AIX 3.1 on IBM RS/6000. -# Copyright (C) 1991 Free Software Foundation, Inc. - -# This file is part of GDB. - -# GDB 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 1, or (at your option) -# any later version. - -# GDB 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 GDB; see the file COPYING. If not, write to -# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - -#TDEPFILES= exec.o rs6k-pinsn.o rs6k-tdep.o -TDEPFILES= rs6000-pinsn.o rs6000-tdep.o -TM_FILE= tm-rs6000.h diff --git a/gdb/config/rtbsd.mh b/gdb/config/rtbsd.mh deleted file mode 100644 index d6310db9971..00000000000 --- a/gdb/config/rtbsd.mh +++ /dev/null @@ -1,8 +0,0 @@ -# IBM RT/PC running BSD unix. -# This file contributed at NYU, where we are using the RT to remote -# debug a 29k running unix. No attempt, as of 7/16/91, has been made -# to support debugging of RT executables. -XDEPFILES=coredep.o infptrace.o -XM_CFLAGS=-DHOSTING_ONLY # No debugging of RT executables -XM_FILE= xm-rtbsd.h -CC=gcc -traditional # hc/pcc just can't cut it. diff --git a/gdb/config/sun2os3.mh b/gdb/config/sun2os3.mh deleted file mode 100644 index ea2fee64d49..00000000000 --- a/gdb/config/sun2os3.mh +++ /dev/null @@ -1,3 +0,0 @@ -# Host: Sun 2, running SunOS 3 -XDEPFILES= infptrace.o sun3-xdep.o -XM_FILE= xm-sun2.h diff --git a/gdb/config/sun2os3.mt b/gdb/config/sun2os3.mt deleted file mode 100644 index bee830dd960..00000000000 --- a/gdb/config/sun2os3.mt +++ /dev/null @@ -1,8 +0,0 @@ -# Target: Sun 2, running SunOS 3 -# The system-supplied assembler re-orders the symbols so that gdb -# can't find "gcc_compiled.". -#msg If you compile your program with GCC, use the GNU assembler. -#msg - -TDEPFILES= exec.o m68k-pinsn.o m68k-tdep.o -TM_FILE= tm-sun2.h diff --git a/gdb/config/sun2os4.mh b/gdb/config/sun2os4.mh deleted file mode 100644 index ec614a6734d..00000000000 --- a/gdb/config/sun2os4.mh +++ /dev/null @@ -1,3 +0,0 @@ -# Host: Sun 2, running SunOS 4 -XDEPFILES= infptrace.o sun3-xdep.o -XM_FILE= xm-sun2.h diff --git a/gdb/config/sun2os4.mt b/gdb/config/sun2os4.mt deleted file mode 100644 index 4443c5bcc2d..00000000000 --- a/gdb/config/sun2os4.mt +++ /dev/null @@ -1,3 +0,0 @@ -# Target: Sun 2, running SunOS 4 -TDEPFILES= exec.o m68k-pinsn.o solib.o m68k-tdep.o -TM_FILE= tm-sun2os4.h diff --git a/gdb/config/sun3.mh b/gdb/config/sun3.mh deleted file mode 100644 index 4ec8d548570..00000000000 --- a/gdb/config/sun3.mh +++ /dev/null @@ -1,3 +0,0 @@ -# Host: Sun 3, running SunOS 4 -XDEPFILES= infptrace.o sun3-xdep.o -XM_FILE= xm-sun3os4.h diff --git a/gdb/config/sun3.mt b/gdb/config/sun3.mt deleted file mode 100644 index 9c93c56eded..00000000000 --- a/gdb/config/sun3.mt +++ /dev/null @@ -1,8 +0,0 @@ -# Target: Sun 3, running SunOS 4, as a target system -# The system-supplied assembler re-orders the symbols so that gdb -# can't find "gcc_compiled.". -#msg If you compile your program with GCC, use the GNU assembler. -#msg - -TDEPFILES= exec.o m68k-pinsn.o solib.o m68k-tdep.o -TM_FILE= tm-sun3os4.h diff --git a/gdb/config/sun386.mh b/gdb/config/sun386.mh deleted file mode 100644 index d03a06eeb6e..00000000000 --- a/gdb/config/sun386.mh +++ /dev/null @@ -1,3 +0,0 @@ -# Host: Sun 386i -XDEPFILES= infptrace.o sun386-xdep.o -XM_FILE= xm-sun386.h diff --git a/gdb/config/sun386.mt b/gdb/config/sun386.mt deleted file mode 100644 index 614df414ba8..00000000000 --- a/gdb/config/sun386.mt +++ /dev/null @@ -1,3 +0,0 @@ -# Target: Sun 386i target configuration file. -TDEPFILES= exec.o i386-pinsn.o solib.o -TM_FILE= tm-sun386.h diff --git a/gdb/config/sun3os3.mh b/gdb/config/sun3os3.mh deleted file mode 100644 index adb908ad539..00000000000 --- a/gdb/config/sun3os3.mh +++ /dev/null @@ -1,3 +0,0 @@ -# Host: Sun 3, running SunOS 3 -XDEPFILES= infptrace.o sun3-xdep.o -XM_FILE= xm-sun3.h diff --git a/gdb/config/sun3os3.mt b/gdb/config/sun3os3.mt deleted file mode 100644 index fa3c66268f5..00000000000 --- a/gdb/config/sun3os3.mt +++ /dev/null @@ -1,8 +0,0 @@ -# Target: Sun 3, running SunOS 3 -# The system-supplied assembler re-orders the symbols so that gdb -# can't find "gcc_compiled.". -#msg If you compile your program with GCC, use the GNU assembler. -#msg - -TDEPFILES= exec.o m68k-pinsn.o m68k-tdep.o -TM_FILE= tm-sun3.h diff --git a/gdb/config/sun3os4.mh b/gdb/config/sun3os4.mh deleted file mode 100644 index 4ec8d548570..00000000000 --- a/gdb/config/sun3os4.mh +++ /dev/null @@ -1,3 +0,0 @@ -# Host: Sun 3, running SunOS 4 -XDEPFILES= infptrace.o sun3-xdep.o -XM_FILE= xm-sun3os4.h diff --git a/gdb/config/sun3os4.mt b/gdb/config/sun3os4.mt deleted file mode 100644 index c249002376f..00000000000 --- a/gdb/config/sun3os4.mt +++ /dev/null @@ -1,3 +0,0 @@ -# Target: Sun 3, running SunOS 4, as a target system -TDEPFILES= exec.o m68k-pinsn.o solib.o m68k-tdep.o -TM_FILE= tm-sun3os4.h diff --git a/gdb/config/sun4.mh b/gdb/config/sun4.mh deleted file mode 100644 index d83d0edcbcc..00000000000 --- a/gdb/config/sun4.mh +++ /dev/null @@ -1,3 +0,0 @@ -# Host: Sun 4 or Sparcstation, running SunOS 4 -XDEPFILES= infptrace.o sparc-xdep.o -XM_FILE= xm-sun4os4.h diff --git a/gdb/config/sun4.mt b/gdb/config/sun4.mt deleted file mode 100644 index 39928b89012..00000000000 --- a/gdb/config/sun4.mt +++ /dev/null @@ -1,3 +0,0 @@ -# Target: Sun 4 or Sparcstation, running SunOS 4 -TDEPFILES= exec.o sparc-tdep.o sparc-pinsn.o solib.o -TM_FILE= tm-sun4os4.h diff --git a/gdb/config/sun4os3.mh b/gdb/config/sun4os3.mh deleted file mode 100644 index 742c9cbeabb..00000000000 --- a/gdb/config/sun4os3.mh +++ /dev/null @@ -1,3 +0,0 @@ -# Host: Sun 4 or Sparcstation, running SunOS 3 -XDEPFILES= infptrace.o sparc-xdep.o -XM_FILE= xm-sparc.h diff --git a/gdb/config/sun4os3.mt b/gdb/config/sun4os3.mt deleted file mode 100644 index b1890e80e3f..00000000000 --- a/gdb/config/sun4os3.mt +++ /dev/null @@ -1,8 +0,0 @@ -# Target: Sun 4 or Sparcstation, running SunOS 3 -# The system-supplied assembler re-orders the symbols so that gdb -# can't find "gcc_compiled.". -#msg If you compile your program with GCC, use the GNU assembler. -#msg - -TDEPFILES= exec.o sparc-tdep.o sparc-pinsn.o -TM_FILE= tm-sparc.h diff --git a/gdb/config/sun4os4.mh b/gdb/config/sun4os4.mh deleted file mode 100644 index d83d0edcbcc..00000000000 --- a/gdb/config/sun4os4.mh +++ /dev/null @@ -1,3 +0,0 @@ -# Host: Sun 4 or Sparcstation, running SunOS 4 -XDEPFILES= infptrace.o sparc-xdep.o -XM_FILE= xm-sun4os4.h diff --git a/gdb/config/sun4os4.mt b/gdb/config/sun4os4.mt deleted file mode 100644 index 39928b89012..00000000000 --- a/gdb/config/sun4os4.mt +++ /dev/null @@ -1,3 +0,0 @@ -# Target: Sun 4 or Sparcstation, running SunOS 4 -TDEPFILES= exec.o sparc-tdep.o sparc-pinsn.o solib.o -TM_FILE= tm-sun4os4.h diff --git a/gdb/config/symmetry.mh b/gdb/config/symmetry.mh deleted file mode 100644 index 562afa6531d..00000000000 --- a/gdb/config/symmetry.mh +++ /dev/null @@ -1,3 +0,0 @@ -# Host: Sequent Symmetry running Dynix 3.0, with Weitek 1167 or i387. -XDEPFILES= infptrace.o symm-xdep.o -XM_FILE= xm-symmetry.h diff --git a/gdb/config/symmetry.mt b/gdb/config/symmetry.mt deleted file mode 100644 index e241993d043..00000000000 --- a/gdb/config/symmetry.mt +++ /dev/null @@ -1,3 +0,0 @@ -# Target: Sequent Symmetry running Dynix 3.0, with Weitek 1167 or i387. -TDEPFILES= symm-tdep.o i386-pinsn.o -TM_FILE= tm-symmetry.h diff --git a/gdb/config/tahoe.mh b/gdb/config/tahoe.mh deleted file mode 100644 index 6b3a6bb5502..00000000000 --- a/gdb/config/tahoe.mh +++ /dev/null @@ -1,5 +0,0 @@ -# Host: CCI or Harris Tahoe running BSD Unix -XDEPFILES= infptrace.o coredep.o -REGEX=regex.o -REGEX1=regex.o -XM_FILE= xm-tahoe.h diff --git a/gdb/config/tahoe.mt b/gdb/config/tahoe.mt deleted file mode 100644 index 9527900e0f3..00000000000 --- a/gdb/config/tahoe.mt +++ /dev/null @@ -1,3 +0,0 @@ -# Target: CCI or Harris Tahoe running BSD Unix -TDEPFILES= tahoe-pinsn.o exec.o -TM_FILE= tm-tahoe.h diff --git a/gdb/config/ultra3.mh b/gdb/config/ultra3.mh deleted file mode 100644 index d7b227ffa05..00000000000 --- a/gdb/config/ultra3.mh +++ /dev/null @@ -1,7 +0,0 @@ -# Host: NYU Ultracomputer (AMD 29000 running Unix) -CC=u3cc -MUNCH_DEFINE="MUNCH_NM=u3nm" -XDEPFILES= ultra3-xdep.o infptrace.o -XM_FILE= xm-ultra3.h -XM_CFLAGS = -DSYM1 -XM_CLIBS = -lsysv -ljobs -ltermlib diff --git a/gdb/config/ultra3.mt b/gdb/config/ultra3.mt deleted file mode 100644 index d2d3876b3e0..00000000000 --- a/gdb/config/ultra3.mt +++ /dev/null @@ -1,5 +0,0 @@ -# Target: AMD 29000 running Unix on New York Univerisity processor board. -TDEPFILES= exec.o am29k-pinsn.o am29k-tdep.o -TM_FILE= tm-ultra3.h -# SYM1 is some OS they have. -TM_CFLAGS = -DSYM1 diff --git a/gdb/config/umax.mh b/gdb/config/umax.mh deleted file mode 100644 index 77eebaaa55c..00000000000 --- a/gdb/config/umax.mh +++ /dev/null @@ -1,3 +0,0 @@ -# Host: Encore running umax 4.2 -XDEPFILES= infptrace.o umax-xdep.o -XM_FILE= xm-umax.h diff --git a/gdb/config/umax.mt b/gdb/config/umax.mt deleted file mode 100644 index afaaeaae3ce..00000000000 --- a/gdb/config/umax.mt +++ /dev/null @@ -1,3 +0,0 @@ -# Target: Encore running umax 4.2 -TDEPFILES= exec.o ns32k-pinsn.o -TM_FILE= tm-umax.h diff --git a/gdb/config/vax.mt b/gdb/config/vax.mt deleted file mode 100644 index ca4d36b2328..00000000000 --- a/gdb/config/vax.mt +++ /dev/null @@ -1,3 +0,0 @@ -# Target: DEC VAX running BSD or Ultrix -TDEPFILES= vax-pinsn.o exec.o -TM_FILE= tm-vax.h diff --git a/gdb/config/vxworks68.mt b/gdb/config/vxworks68.mt deleted file mode 100644 index 92791c53680..00000000000 --- a/gdb/config/vxworks68.mt +++ /dev/null @@ -1,3 +0,0 @@ -# Target: VxWorks running on a 68000 -TDEPFILES= exec.o m68k-pinsn.o m68k-tdep.o remote-vx.o xdr_ld.o xdr_ptrace.o xdr_rdb.o xdr_regs.o -TM_FILE= tm-vx68.h diff --git a/gdb/config/vxworks960.mt b/gdb/config/vxworks960.mt deleted file mode 100644 index 3f3c059fd03..00000000000 --- a/gdb/config/vxworks960.mt +++ /dev/null @@ -1,5 +0,0 @@ -# Target: VxWorks running on an Intel 960 -TDEPFILES= exec.o i960-pinsn.o i960-tdep.o remote-vx.o xdr_ld.o xdr_ptrace.o xdr_rdb.o xdr_regs.o -TM_FILE= tm-vx960.h -# Define this for the vx-share routines, which don't see param.h. -TM_CFLAGS= -DI80960 diff --git a/gdb/configure b/gdb/configure deleted file mode 100755 index 5b73541ba08..00000000000 --- a/gdb/configure +++ /dev/null @@ -1,882 +0,0 @@ -#!/bin/sh - -# Configuration script -# Copyright (C) 1988, 1990, 1991 Free Software Foundation, Inc. - -#This file is part of GNU. - -# 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -# $Id$ - -# -# Shell script to create proper links to machine-dependent files in -# preparation for compilation. -# -# If configure succeeds, it leaves its status in config.status. -# If configure fails after disturbing the status quo, -# config.status is removed. -# - -remove=rm -hard_link=ln -symbolic_link='ln -s' - -#for Test -#remove="echo rm" -#hard_link="echo ln" -#symbolic_link="echo ln -s" - -progname=$0 - -# clear some things potentially inherited from environment. -ansi= -arguments=$* -defaulttargets= -destdir= -fatal= -hostsubdir= -Makefile=Makefile -Makefile_in=Makefile.in -norecursion= -recurring= -removing= -srcdir= -srctrigger= -target= -targets= -commontargets= -configdirs= -targetsubdir= -template= -verbose= - -for arg in $*; -do - case ${arg} in - -ansi | +a*) - ansi=true - clib=clib - ;; - -destdir=* | +destdir=* | +destdi=* | +destd=* | +dest=* | +des=* | +de=* | +d=*) - destdir=`echo ${arg} | sed 's/[+-]d[a-z]*=//'` - ;; - -languages=* | +languages=* | +language=* | +languag=* \ - | +langua=* | +langu=* | +lang=* | +lan=* | +la=* \ - | +l=*) - languages="${languages} `echo ${arg} | sed 's/[+-]l[a-z]*=//'`" - ;; - -gas | +g*) - gas=yes - ;; - -help | +h*) - fatal=true - ;; - -nfp | +nf*) - nfp=yes - ;; - -norecursion | +no*) - norecursion=true - ;; - -recurring | +recurring | +recurrin | +recurri | +recurr | +recur | +recu | +rec | +re) - recurring=true - ;; - -rm | +rm) - removing=${arg} - ;; -# -srcdir=* | +srcdir=* | +srcdi=* | +srcd=* | +src=* | +sr=* | +s=*) -# srcdir=`echo ${arg} | sed 's/[+-]s[a-z]*=//'` -# ;; - -subdirs | +f* | +su*) - subdirs=${arg} - ;; - -target=* | +target=* | +targe=* | +targ=* | +tar=* | +ta=*) - if [ -n "${targets}" ] ; then - subdirs="+subdirs" - fi - - newtargets="${targets} `echo ${arg} | sed 's/[+-]t[a-z]*=//'`" - targets="${newtargets}" - ;; - -template=* | +template=* | +templat=* | +templa=* | +templ=* | +temp=* | +tem=* | +te=*) - template=`echo ${arg} | sed 's/[+-]template=//'` - ;; - -v | -verbose | +v*) - verbose=${arg} - ;; - -* | +*) - (echo ; - echo "Unrecognized option: \"${arg}\"". ; - echo) 1>&2 - fatal=true - ;; - *) - if [ -n "${hosts}" ] ; then - subdirs="+subdirs" - fi - - newhosts="${hosts} ${arg}" - hosts=${newhosts} - ;; - esac -done - -if [ -n "${verbose}" ] ; then - echo `pwd`/configure $* -fi - -# process host and target only if not rebuilding configure itself or removing. -if [ -z "${template}" -a -z "${removing}" -a -z "${fatal}" ] ; then - # Complain if an arg is missing - if [ -z "${hosts}" ] ; then - (echo ; - echo "configure: No HOST specified." ; - echo) 1>&2 - fatal=true - fi -fi - -if [ -n "${fatal}" -o "${hosts}" = "help" ] ; then - (echo "Usage: configure HOST" ; - echo ; - echo "Options: [defaults in brackets]" ; - echo " +ansi configure w/ANSI library. [no ansi lib]" ; - echo " +destdir=MYDIR configure for installation into MYDIR. [/usr/local]" ; - echo " +subdirs configure in subdirectories. [in source directories]" ; - echo " +lang=LANG configure to build LANG. [gcc]" ; - echo " +help print this message. [normal config]" ; - echo " +gas configure the compilers for use with gas. [native as]" ; - echo " +nfp configure the compilers default to soft floating point. [hard float]" ; - echo " +norecursion configure this directory only. [recurse]" ; - echo " +rm remove this configuration. [build a configuration]" ; - echo " +target=TARGET configure for TARGET. [TARGET = HOST]" ; - echo " +template=TEM rebuild configure using TEM. [normal config]" ; - echo ; - echo "Where HOST and TARGET are something like \"vax\", \"sun3\", \"encore\", etc." ; - echo "Asking for more than one \"+target\" implies \"+subdirs\". Any other" ; - echo "options given will apply to all targets.") 1>&2 - - if [ -r config.status ] ; then - cat config.status - fi - - exit 1 -fi - -#### configure.in common parts come in here. -srcname="GDB" -srctrigger=main.c - -## end of common part. - -# are we rebuilding config itself? -if [ -n "${template}" ] ; then - if [ ! -r ${template} ] ; then - echo '***' "Can't find template ${template}." 1>&2 - exit 1 - fi - -# prep the template - sed -e '/^#### configure.in common parts come in here.$/,/^## end of common part.$/c\ -#### configure.in common parts come in here.\ -## end of common part.' \ - -e '/^#### configure.in per-host parts come in here.$/,/^## end of per-host part.$/c\ -#### configure.in per-host parts come in here.\ -## end of per-host part.' \ - -e '/^#### configure.in per-target parts come in here.$/,/^## end of per-target part.$/c\ -#### configure.in per-target parts come in here.\ -## end of per-target part.' \ - -e '/^#### configure.in post-target parts come in here.$/,/^## end of post-target part.$/c\ -#### configure.in post-target parts come in here.\ -## end of post-target part.' \ - < ${template} > template.new - - if [ -r configure.in ] ; then - if [ -z "`grep '^# per\-host:' configure.in`" ] ; then - echo '***' `pwd`/configure.in has no "per-host:" line. 1>&2 - exit 1 - fi - - if [ -z "`grep '^# per\-target:' configure.in`" ] ; then - echo '***' `pwd`/configure.in has no "per-target:" line. 1>&2 - exit 1 - fi - - # split configure.in into common, per-host, per-target, - # and post-target parts. Post-target is optional. - sed -e '/^# per\-host:/,$d' configure.in > configure.com - sed -e '1,/^# per\-host:/d' -e '/^# per\-target:/,$d' configure.in > configure.hst - if grep -s '^# post-target:' configure.in ; then - sed -e '1,/^# per\-target:/d' -e '/^# post\-target:/,$d' configure.in > configure.tgt - sed -e '1,/^# post\-target:/d' configure.in > configure.pos - else - sed -e '1,/^# per\-target:/d' configure.in > configure.tgt - echo >configure.pos - fi - - # and insert them - sed -e '/^#### configure.in common parts come in here.$/ r configure.com' \ - -e '/^#### configure.in per\-host parts come in here.$/ r configure.hst' \ - -e '/^#### configure.in per\-target parts come in here.$/ r configure.tgt' \ - -e '/^#### configure.in post\-target parts come in here.$/ r configure.pos' \ - template.new > configure.new - - rm -f configure.com configure.tgt configure.hst configure.pos - else - echo Warning: no configure.in in `pwd` - cat ${template} >> configure - fi - - chmod a+x configure.new - rm template.new -# mv configure configure.old - mv configure.new configure - - if [ -n "${verbose}" ] ; then - echo Rebuilt configure in `pwd` - fi - - # Now update config.sub from the template directory. - if echo "$template" | grep -s 'configure$' ; then - cp `echo "$template" | sed s/configure$/config.sub/` ./config.sub.new - # mv config.sub config.sub.old - mv config.sub.new config.sub - - if [ -n "${verbose}" ] ; then - echo Rebuilt config.sub in `pwd` - fi - fi - - if [ -z "${norecursion}" ] ; then - # If template is relative path, make it absolute for recurring. - if echo "${template}" | grep -s '^/' ; then - true - else - template=`pwd`/${template} - fi - - while [ -n "${configdirs}" ] ; do - # set configdir to car of configdirs, configdirs to cdr of configdirs - set ${configdirs}; configdir=$1; shift; configdirs=$* - - if [ "`echo ${configdir}.*`" != "${configdir}.*" ] ; then - targetspecificdirs=${configdir}.* - else - targetspecificdirs= - fi - - for i in ${configdir} ${targetspecificdirs} ; do - if [ -d $i ] ; then - if [ -r $i/configure ] ; then - (cd $i ; - ./configure +template=${template} ${verbose}) - else - echo Warning: No configure script in `pwd`/$i - fi - else - if [ -n "${verbose}" ] ; then - echo Warning: directory $i is missing. - fi - fi - done - done - fi - - exit 0 -fi - -# some sanity checks on configure.in -if [ -z "${srctrigger}" ] ; then - echo Warning: srctrigger not set in configure.in. `pwd` not configured. - exit 1 -fi - -for host in ${hosts} ; do - # Default other arg - if [ -z "${targets}" -o -n "${defaulttargets}" ] ; then - targets=${host} - defaulttargets=true - fi - - host_alias=${host} - - result=`/bin/sh ./config.sub ${host}` - host_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'` - host_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'` - host_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'` - host=${host_cpu}-${host_vendor}-${host_os} - host_makefile_frag=config/hmake-${host} - -#### configure.in per-host parts come in here. - -# map host info into gdb names. - -case "${host_cpu}" in - -m68k) - case "${host_vendor}" in - att) gdb_host=3b1 ;; - altos) - case "${host_os}" in - gas) gdb_host=altosgas ;; - *) gdb_host=altos ;; - esac - ;; - hp) - case ${host_os} in - hpux) gdb_host=hp300hpux ;; - bsd) gdb_host=hp300bsd ;; - esac - ;; - - isi) gdb_host=isi ;; - sony) gdb_host=news ;; - sun) - case "${host_os}" in - sunos3) gdb_host=sun3os3 ;; - sunos4) gdb_host=sun3os4 ;; - *) gdb_host=sun3 ;; - esac - ;; - esac - ;; - -m68000) - case "${host_vendor}" in - sun) - case "${host_os}" in - sunos3) gdb_host=sun2os3 ;; - sunos4) gdb_host=sun2os4 ;; - *) gdb_host=sun2 ;; - esac - esac - ;; - -sparc) - case "${host_os}" in - sunos3) gdb_host=sun4os3 ;; - sunos4) gdb_host=sun4os4 ;; - *) gdb_host=sun4 ;; - esac - ;; - -m68030) - case "${host_vendor}" in - sony) gdb_host=news1000 ;; - esac - ;; - -mips) - case "${host_vendor}" in - sony) gdb_host=bigmips ;; - dec) gdb_host=dec3100 ;; - little) gdb_host=littlemips ;; - sgi) gdb_host=irix3 ;; - esac - ;; - -i386) - case "${host_vendor}" in - sun) gdb_host=sun386 ;; - sco) gdb_host=i386sco ;; - sequent) gdb_host=symmetry ;; - *) - case "${host_os}" in - sysv) gdb_host=i386v ;; - sysv32) gdb_host=i386v32 ;; - esac - ;; - esac - ;; - -c1 | c2) gdb_host=convex ;; - -ns32k) - case "${host_vendor}" in - umax) gdb_host=umax ;; - esac - ;; - -romp) - gdb_host=rtbsd - ;; - -a29k) - gdb_host=ultra3 - ;; - -arm | vax | m88k | merlin | none | np1 | pn | pyramid | tahoe) - gdb_host=${host_cpu} - ;; - -### unhandled hosts -#altosgas -#i386v-g -#i386v32-g - -esac - -if [ ! -f xconfig/${gdb_host} ]; then - echo '***' "Gdb does not support host ${host}" 1>&2 - exit 1 -fi - -# We really shouldn't depend on there being a space after XM_FILE= ... -hostfile=`awk '$1 == "XM_FILE=" { print $2 }' &2 - exit 1 -fi - -if [ -z "${removing}" ] ; then - cat xconfig/${gdb_host} tconfig/${gdb_target} | awk '$1 == "#msg" { - print substr($0,6)}' -fi - -# We really shouldn't depend on there being a space after TM_FILE= ... -targetfile=`awk '$1 == "TM_FILE=" { print $2 }' &1 | grep Target- | grep -v Target-independent`" ] ; then - rm -rf ${hostsubdir} - fi - else - echo Warning: no `pwd`/${hostsubdir} to remove. - fi - else - rm -f ${Makefile} config.status ${links} - fi - else - if [ -n "${subdirs}" ] ; then - # check for existing status before allowing forced subdirs. - if [ -f ${Makefile} ] ; then - echo '***' "${Makefile} already exists in source directory. `pwd` not configured." 1>&2 - exit 1 - fi - - if [ ! -d ${hostsubdir} ] ; then mkdir ${hostsubdir} ; fi - cd ${hostsubdir} - - if [ ! -d ${targetsubdir} ] ; then - if [ -z "${commontargets}" ] ; then - mkdir ${targetsubdir} - else - if [ ! -d Target-independent ] ; then - mkdir Target-independent - fi - - ${symbolic_link} Target-independent ${targetsubdir} - fi # if target independent - fi # if no target dir yet - - cd ${targetsubdir} - - srcdir=../.. - else - # if not subdir builds, then make sure none exist. - if [ -n "`(ls .) 2>&1 | grep Host-`" ] ; then - echo '***' "Configured subdirs exist. `pwd` not configured." 1>&2 - exit 1 - fi - fi - - # Find the source files, if location was not specified. - if [ -z "${srcdir}" ] ; then - srcdirdefaulted=1 - srcdir=. - if [ -n "${srctrigger}" -a ! -r ${srctrigger} ] ; then - srcdir=.. - fi - fi - - if [ -n "${srctrigger}" -a ! -r ${srcdir}/${srctrigger} ] ; then - if [ -z "${srcdirdefaulted}" ] ; then - echo '***' "${progname}: Can't find ${srcname} sources in `pwd`/${srcdir}" 1>&2 - else - echo '***' "${progname}: Can't find ${srcname} sources in `pwd`/. or `pwd`/.." 1>&2 - fi - - echo '***' \(At least ${srctrigger} is missing.\) 1>&2 - exit 1 - fi - - # Set up the list of links to be made. - # ${links} is the list of link names, and ${files} is the list of names to link to. - - # Make the links. - while [ -n "${files}" ] ; do - # set file to car of files, files to cdr of files - set ${files}; file=$1; shift; files=$* - set ${links}; link=$1; shift; links=$* - - if [ ! -r ${srcdir}/${file} ] ; then - echo '***' "${progname}: cannot create a link \"${link}\"," 1>&2 - echo '***' "since the file \"${file}\" does not exist." 1>&2 - exit 1 - fi - - ${remove} -f ${link} - rm -f config.status - # Make a symlink if possible, otherwise try a hard link - ${symbolic_link} ${srcdir}/${file} ${link} 2>/dev/null || ${hard_link} ${srcdir}/${file} ${link} - - if [ ! -r ${link} ] ; then - echo '***' "${progname}: unable to link \"${link}\" to \"${srcdir}/${file}\"." 1>&2 - exit 1 - fi - - if [ -n "${verbose}" ] ; then - echo "Linked \"${link}\" to \"${srcdir}/${file}\"." - fi - done - - # Create a .gdbinit file which runs the one in srcdir - # and tells GDB to look there for source files. - - case ${srcdir} in - .) - ;; - *) - echo "dir ." > .gdbinit - echo "dir ${srcdir}" >> .gdbinit - echo "source ${srcdir}/.gdbinit" >> .gdbinit - ;; - esac - - # Install a makefile, and make it set VPATH - # if necessary so that the sources are found. - # Also change its value of srcdir. - - # FIXME-someday: This business of always writing to .tem and mv back - # is so that I don't screw things up while developing. Once this - # template is stable, these should be optimized. xoxorich. - - # Define macro CROSS_COMPILE in compilation if this is a cross-compiler. - if [ "${host}" != "${target}" ] ; then - echo "CROSS=-DCROSS_COMPILE" > ${Makefile} - echo "ALL=start.encap" >> ${Makefile} - else - echo "ALL=all.internal" > ${Makefile} - fi - - # set target, host, VPATH - echo "host_alias = ${host_alias}" >> ${Makefile} - echo "host_cpu = ${host_cpu}" >> ${Makefile} - echo "host_vendor = ${host_vendor}" >> ${Makefile} - echo "host_os = ${host_os}" >> ${Makefile} - - echo "target_alias = ${target_alias}" >> ${Makefile} - echo "target_cpu = ${target_cpu}" >> ${Makefile} - echo "target_vendor = ${target_vendor}" >> ${Makefile} - echo "target_os = ${target_os}" >> ${Makefile} - - if [ -n "${subdirs}" ] ; then - echo "subdir = /${hostsubdir}/${targetsubdir}" >> ${Makefile} - else - echo "subdir =" >> ${Makefile} - fi - - # echo "workdir = `pwd`" >> ${Makefile} - echo "VPATH = ${srcdir}" >> ${Makefile} - - # add "Makefile.in" (or whatever it's called) - cat ${srcdir}/${Makefile_in} >> ${Makefile} - - # Conditionalize the makefile for this host. - if [ -f ${srcdir}/${host_makefile_frag} ] ; then - (echo "host_makefile_frag = ${srcdir}/${host_makefile_frag}" ; - sed -e "/^####/ r ${srcdir}/${host_makefile_frag}" ${Makefile}) > Makefile.tem - mv Makefile.tem ${Makefile} - fi - - # Conditionalize the makefile for this target. - if [ -f ${srcdir}/${target_makefile_frag} ] ; then - (echo "target_makefile_frag = ${srcdir}/${target_makefile_frag}" ; - sed -e "/^####/ r ${srcdir}/${target_makefile_frag}" ${Makefile}) > Makefile.tem - mv Makefile.tem ${Makefile} - fi - - # set srcdir - sed "s@^srcdir = \.@srcdir = ${srcdir}@" ${Makefile} > Makefile.tem - mv Makefile.tem ${Makefile} - - # set destdir - if [ -n "${destdir}" ] ; then - sed "s:^destdir =.*$:destdir = ${destdir}:" ${Makefile} > Makefile.tem - mv Makefile.tem ${Makefile} - fi - - # reset SUBDIRS - sed "s:^SUBDIRS =.*$:SUBDIRS = ${configdirs}:" ${Makefile} > Makefile.tem - mv Makefile.tem ${Makefile} - - # reset NONSUBDIRS - sed "s:^NONSUBDIRS =.*$:NONSUBDIRS = ${noconfigdirs}:" ${Makefile} > Makefile.tem - mv Makefile.tem ${Makefile} - - using= - if [ -f ${srcdir}/${host_makefile_frag} ] ; then - using=" using \"${host_makefile_frag}\"" - fi - - # remove any form feeds. - sed -e "s/ //" ${Makefile} > Makefile.tem - mv Makefile.tem ${Makefile} - - if [ -f ${srcdir}/${target_makefile_frag} ] ; then - if [ -z "${using}" ] ; then - andusing=" using \"${target_makefile_frag}\"" - else - andusing="${using} and \"${target_makefile_frag}\"" - fi - else - andusing=${using} - fi - - if [ -n "${verbose}" -o -z "${recurring}" ] ; then - echo "Created \"${Makefile}\"" in `pwd`${andusing}. - fi - -#### configure.in post-target parts come in here. - -case ${srcdir} in - .) - ;; - *) - grep -s "source ${srcdir}/.gdbinit" .gdbinit 2>/dev/null || \ - echo "source ${srcdir}/.gdbinit" >> .gdbinit -esac - -cat ${srcdir}/alldeps.mak ${srcdir}/depend >>Makefile -## end of post-target part. - - # describe the chosen configuration in config.status. - # Make that file a shellscript which will reestablish - # the same configuration. Used in Makefiles to rebuild - # Makefiles. - - echo "#!/bin/sh -# ${srcname} was configured as follows: -${srcdir}/configure" ${arguments} `if [ -z "${norecursion}" ] ; then echo +norecursion ; else true ; fi` > config.status - chmod a+x config.status - - originaldir=`pwd` - cd ${srcdir} - fi - - # If there are subdirectories, then recurse. - if [ -z "${norecursion}" -a -n "${configdirs}" ] ; then - for configdir in ${configdirs} ; do - if [ -n "${verbose}" ] ; then - echo Configuring ${configdir}... - fi - - if [ -d ${configdir} ] ; then - (cd ${configdir} ; - ./configure +recurring ${host_alias} +target=${target_alias} \ - ${verbose} ${subdirs} ${removing} +destdir=${destdir}) \ - | sed 's/^/ /' - else - if [ -n "${verbose}" ] ; then - echo Warning: directory \"${configdir}\" is missing. - fi - fi - done - fi - done # for each target - - # Now build a Makefile for this host. - if [ -n "${subdirs}" -a ! -n "${removing}" ] ; then - cd ${hostsubdir} - cat > GNUmakefile << E!O!F -# Makefile generated by configure for host ${host_alias}. - -ALL := $(shell ls -d Target-*) - -%: - $(foreach subdir,$(ALL),$(MAKE) -C $(subdir) \$@ &&) true - -all: -E!O!F - cd .. - fi -done # for each host - -exit 0 - -# -# Local Variables: -# fill-column: 131 -# End: -# - -# end of configure diff --git a/gdb/configure.in b/gdb/configure.in deleted file mode 100644 index ce82cf2c559..00000000000 --- a/gdb/configure.in +++ /dev/null @@ -1,319 +0,0 @@ -configdirs="doc" -srcname="GDB" -srctrigger=main.c -# per-host: - -# map host info into gdb names. - -case "${host_cpu}" in - -m68k) - case "${host_vendor}" in - att) gdb_host=3b1 ;; - altos) - case "${host_os}" in - gas) gdb_host=altosgas ;; - *) gdb_host=altos ;; - esac - ;; - - cbm) - case ${host_os} in - amigados) gdb_host=amigados ;; - svr4) gdb_host=amix ;; - esac - ;; - - hp) - case ${host_os} in - hpux) gdb_host=hp300hpux ;; - bsd) gdb_host=hp300bsd ;; - esac - ;; - - isi) gdb_host=isi ;; - sony) gdb_host=news ;; - sun) - case "${host_os}" in - sunos3) gdb_host=sun3os3 ;; - sunos4) gdb_host=sun3os4 ;; - *) gdb_host=sun3 ;; - esac - ;; - esac - ;; - -m68000) - case "${host_vendor}" in - sun) - case "${host_os}" in - sunos3) gdb_host=sun2os3 ;; - sunos4) gdb_host=sun2os4 ;; - *) gdb_host=sun2 ;; - esac - esac - ;; - -sparc) - case "${host_os}" in - sunos3) gdb_host=sun4os3 ;; - sunos4) gdb_host=sun4os4 ;; - *) gdb_host=sun4 ;; - esac - ;; - -m68030) - case "${host_vendor}" in - sony) gdb_host=news1000 ;; - esac - ;; - -mips) - case "${host_vendor}" in - sony) gdb_host=bigmips ;; - dec) gdb_host=decstation ;; - little) gdb_host=littlemips ;; - sgi) gdb_host=irix3 ;; - esac - ;; - -i386) - case "${host_vendor}" in - sun) gdb_host=sun386 ;; - sco) gdb_host=i386sco ;; - sequent) gdb_host=symmetry ;; - *) - case "${host_os}" in - sysv) gdb_host=i386v ;; - sysv32) gdb_host=i386v32 ;; - mach) gdb_host=i386mach ;; - esac - ;; - esac - ;; - -c1 | c2) gdb_host=convex ;; - -ns32k) - case "${host_vendor}" in - umax) gdb_host=umax ;; - esac - ;; - -romp) - gdb_host=rtbsd - ;; - -rs6000) - gdb_host=rs6000 - ;; - -a29k) - gdb_host=ultra3 - ;; - -m88k) - case "${host_vendor}" in - motorola) - gdb_host=delta88 ;; - *) - gdb_host=m88k ;; - esac - ;; - -arm | vax | merlin | none | np1 | pn | pyramid | tahoe) - gdb_host=${host_cpu} - ;; - -### unhandled hosts -#altosgas -#i386v-g -#i386v32-g - -esac - - -if [ ! -f xconfig/${gdb_host} ]; then - echo '***' "Gdb does not support host ${host}" 1>&2 - exit 1 -fi - -# We really shouldn't depend on there being a space after XM_FILE= ... -hostfile=`awk '$1 == "XM_FILE=" { print $2 }' &2 - exit 1 -fi - -if [ -z "${removing}" ] ; then - cat xconfig/${gdb_host} tconfig/${gdb_target} | awk '$1 == "#msg" { - print substr($0,6)}' -fi - -# We really shouldn't depend on there being a space after TM_FILE= ... -targetfile=`awk '$1 == "TM_FILE=" { print $2 }' /dev/null || \ - echo "source ${srcdir}/.gdbinit" >> .gdbinit -esac - -cat ${srcdir}/alldeps.mak ${srcdir}/depend >>Makefile diff --git a/gdb/convex-opcode.h b/gdb/convex-opcode.h deleted file mode 100755 index 523c8744c28..00000000000 --- a/gdb/convex-opcode.h +++ /dev/null @@ -1,1677 +0,0 @@ -/* Include information for instruction dissasembly on the Convex. - Copyright (C) 1989, Free Software Foundation. - -This file is part of GDB. - -GDB 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 1, or (at your option) -any later version. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#define xxx 0 -#define rrr 1 -#define rr 2 -#define rxr 3 -#define r 4 -#define nops 5 -#define nr 6 -#define pcrel 7 -#define lr 8 -#define rxl 9 -#define rlr 10 -#define rrl 11 -#define iml 12 -#define imr 13 -#define a1r 14 -#define a1l 15 -#define a2r 16 -#define a2l 17 -#define a3 18 -#define a4 19 -#define a5 20 -#define V 1 -#define S 2 -#define VM 3 -#define A 4 -#define VL 5 -#define VS 6 -#define VLS 7 -#define PSW 8 -/* Prevent an error during "make depend". */ -#if !defined (PC) -#define PC 9 -#endif -#define ITR 10 -#define VV 11 -#define ITSR 12 -#define TOC 13 -#define CIR 14 -#define TTR 15 -#define VMU 16 -#define VML 17 -#define ICR 18 -#define TCPU 19 -#define CPUID 20 -#define TID 21 -char *op[] = { - "", - "v0\0v1\0v2\0v3\0v4\0v5\0v6\0v7", - "s0\0s1\0s2\0s3\0s4\0s5\0s6\0s7", - "vm", - "sp\0a1\0a2\0a3\0a4\0a5\0ap\0fp", - "vl", - "vs", - "vls", - "psw", - "pc", - "itr", - "vv", - "itsr", - "toc", - "cir", - "ttr", - "vmu", - "vml", - "icr", - "tcpu", - "cpuid", - "tid", -}; -struct formstr format0[] = { - {0,0,rrr,V,S,S}, /* mov */ - {0,0,rrr,S,S,V}, /* mov */ - {1,1,rrr,V,V,V}, /* merg.t */ - {2,1,rrr,V,V,V}, /* mask.t */ - {1,2,rrr,V,S,V}, /* merg.f */ - {2,2,rrr,V,S,V}, /* mask.f */ - {1,1,rrr,V,S,V}, /* merg.t */ - {2,1,rrr,V,S,V}, /* mask.t */ - {3,3,rrr,V,V,V}, /* mul.s */ - {3,4,rrr,V,V,V}, /* mul.d */ - {4,3,rrr,V,V,V}, /* div.s */ - {4,4,rrr,V,V,V}, /* div.d */ - {3,3,rrr,V,S,V}, /* mul.s */ - {3,4,rrr,V,S,V}, /* mul.d */ - {4,3,rrr,V,S,V}, /* div.s */ - {4,4,rrr,V,S,V}, /* div.d */ - {5,0,rrr,V,V,V}, /* and */ - {6,0,rrr,V,V,V}, /* or */ - {7,0,rrr,V,V,V}, /* xor */ - {8,0,rrr,V,V,V}, /* shf */ - {5,0,rrr,V,S,V}, /* and */ - {6,0,rrr,V,S,V}, /* or */ - {7,0,rrr,V,S,V}, /* xor */ - {8,0,rrr,V,S,V}, /* shf */ - {9,3,rrr,V,V,V}, /* add.s */ - {9,4,rrr,V,V,V}, /* add.d */ - {10,3,rrr,V,V,V}, /* sub.s */ - {10,4,rrr,V,V,V}, /* sub.d */ - {9,3,rrr,V,S,V}, /* add.s */ - {9,4,rrr,V,S,V}, /* add.d */ - {10,3,rrr,V,S,V}, /* sub.s */ - {10,4,rrr,V,S,V}, /* sub.d */ - {9,5,rrr,V,V,V}, /* add.b */ - {9,6,rrr,V,V,V}, /* add.h */ - {9,7,rrr,V,V,V}, /* add.w */ - {9,8,rrr,V,V,V}, /* add.l */ - {9,5,rrr,V,S,V}, /* add.b */ - {9,6,rrr,V,S,V}, /* add.h */ - {9,7,rrr,V,S,V}, /* add.w */ - {9,8,rrr,V,S,V}, /* add.l */ - {10,5,rrr,V,V,V}, /* sub.b */ - {10,6,rrr,V,V,V}, /* sub.h */ - {10,7,rrr,V,V,V}, /* sub.w */ - {10,8,rrr,V,V,V}, /* sub.l */ - {10,5,rrr,V,S,V}, /* sub.b */ - {10,6,rrr,V,S,V}, /* sub.h */ - {10,7,rrr,V,S,V}, /* sub.w */ - {10,8,rrr,V,S,V}, /* sub.l */ - {3,5,rrr,V,V,V}, /* mul.b */ - {3,6,rrr,V,V,V}, /* mul.h */ - {3,7,rrr,V,V,V}, /* mul.w */ - {3,8,rrr,V,V,V}, /* mul.l */ - {3,5,rrr,V,S,V}, /* mul.b */ - {3,6,rrr,V,S,V}, /* mul.h */ - {3,7,rrr,V,S,V}, /* mul.w */ - {3,8,rrr,V,S,V}, /* mul.l */ - {4,5,rrr,V,V,V}, /* div.b */ - {4,6,rrr,V,V,V}, /* div.h */ - {4,7,rrr,V,V,V}, /* div.w */ - {4,8,rrr,V,V,V}, /* div.l */ - {4,5,rrr,V,S,V}, /* div.b */ - {4,6,rrr,V,S,V}, /* div.h */ - {4,7,rrr,V,S,V}, /* div.w */ - {4,8,rrr,V,S,V}, /* div.l */ -}; -struct formstr format1[] = { - {11,0,xxx,0,0,0}, /* exit */ - {12,0,a3,0,0,0}, /* jmp */ - {13,2,a3,0,0,0}, /* jmpi.f */ - {13,1,a3,0,0,0}, /* jmpi.t */ - {14,2,a3,0,0,0}, /* jmpa.f */ - {14,1,a3,0,0,0}, /* jmpa.t */ - {15,2,a3,0,0,0}, /* jmps.f */ - {15,1,a3,0,0,0}, /* jmps.t */ - {16,0,a3,0,0,0}, /* tac */ - {17,0,a1r,A,0,0}, /* ldea */ - {18,8,a1l,VLS,0,0}, /* ld.l */ - {18,9,a1l,VM,0,0}, /* ld.x */ - {19,0,a3,0,0,0}, /* tas */ - {20,0,a3,0,0,0}, /* pshea */ - {21,8,a2l,VLS,0,0}, /* st.l */ - {21,9,a2l,VM,0,0}, /* st.x */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {22,0,a3,0,0,0}, /* call */ - {23,0,a3,0,0,0}, /* calls */ - {24,0,a3,0,0,0}, /* callq */ - {25,0,a1r,A,0,0}, /* pfork */ - {26,5,a2r,S,0,0}, /* ste.b */ - {26,6,a2r,S,0,0}, /* ste.h */ - {26,7,a2r,S,0,0}, /* ste.w */ - {26,8,a2r,S,0,0}, /* ste.l */ - {18,5,a1r,A,0,0}, /* ld.b */ - {18,6,a1r,A,0,0}, /* ld.h */ - {18,7,a1r,A,0,0}, /* ld.w */ - {27,7,a1r,A,0,0}, /* incr.w */ - {21,5,a2r,A,0,0}, /* st.b */ - {21,6,a2r,A,0,0}, /* st.h */ - {21,7,a2r,A,0,0}, /* st.w */ - {27,8,a1r,S,0,0}, /* incr.l */ - {18,5,a1r,S,0,0}, /* ld.b */ - {18,6,a1r,S,0,0}, /* ld.h */ - {18,7,a1r,S,0,0}, /* ld.w */ - {18,8,a1r,S,0,0}, /* ld.l */ - {21,5,a2r,S,0,0}, /* st.b */ - {21,6,a2r,S,0,0}, /* st.h */ - {21,7,a2r,S,0,0}, /* st.w */ - {21,8,a2r,S,0,0}, /* st.l */ - {18,5,a1r,V,0,0}, /* ld.b */ - {18,6,a1r,V,0,0}, /* ld.h */ - {18,7,a1r,V,0,0}, /* ld.w */ - {18,8,a1r,V,0,0}, /* ld.l */ - {21,5,a2r,V,0,0}, /* st.b */ - {21,6,a2r,V,0,0}, /* st.h */ - {21,7,a2r,V,0,0}, /* st.w */ - {21,8,a2r,V,0,0}, /* st.l */ -}; -struct formstr format2[] = { - {28,5,rr,A,A,0}, /* cvtw.b */ - {28,6,rr,A,A,0}, /* cvtw.h */ - {29,7,rr,A,A,0}, /* cvtb.w */ - {30,7,rr,A,A,0}, /* cvth.w */ - {28,5,rr,S,S,0}, /* cvtw.b */ - {28,6,rr,S,S,0}, /* cvtw.h */ - {29,7,rr,S,S,0}, /* cvtb.w */ - {30,7,rr,S,S,0}, /* cvth.w */ - {28,3,rr,S,S,0}, /* cvtw.s */ - {31,7,rr,S,S,0}, /* cvts.w */ - {32,3,rr,S,S,0}, /* cvtd.s */ - {31,4,rr,S,S,0}, /* cvts.d */ - {31,8,rr,S,S,0}, /* cvts.l */ - {32,8,rr,S,S,0}, /* cvtd.l */ - {33,3,rr,S,S,0}, /* cvtl.s */ - {33,4,rr,S,S,0}, /* cvtl.d */ - {34,0,rr,A,A,0}, /* ldpa */ - {8,0,nr,A,0,0}, /* shf */ - {18,6,nr,A,0,0}, /* ld.h */ - {18,7,nr,A,0,0}, /* ld.w */ - {33,7,rr,S,S,0}, /* cvtl.w */ - {28,8,rr,S,S,0}, /* cvtw.l */ - {35,1,rr,S,S,0}, /* plc.t */ - {36,0,rr,S,S,0}, /* tzc */ - {37,6,rr,A,A,0}, /* eq.h */ - {37,7,rr,A,A,0}, /* eq.w */ - {37,6,nr,A,0,0}, /* eq.h */ - {37,7,nr,A,0,0}, /* eq.w */ - {37,5,rr,S,S,0}, /* eq.b */ - {37,6,rr,S,S,0}, /* eq.h */ - {37,7,rr,S,S,0}, /* eq.w */ - {37,8,rr,S,S,0}, /* eq.l */ - {38,6,rr,A,A,0}, /* leu.h */ - {38,7,rr,A,A,0}, /* leu.w */ - {38,6,nr,A,0,0}, /* leu.h */ - {38,7,nr,A,0,0}, /* leu.w */ - {38,5,rr,S,S,0}, /* leu.b */ - {38,6,rr,S,S,0}, /* leu.h */ - {38,7,rr,S,S,0}, /* leu.w */ - {38,8,rr,S,S,0}, /* leu.l */ - {39,6,rr,A,A,0}, /* ltu.h */ - {39,7,rr,A,A,0}, /* ltu.w */ - {39,6,nr,A,0,0}, /* ltu.h */ - {39,7,nr,A,0,0}, /* ltu.w */ - {39,5,rr,S,S,0}, /* ltu.b */ - {39,6,rr,S,S,0}, /* ltu.h */ - {39,7,rr,S,S,0}, /* ltu.w */ - {39,8,rr,S,S,0}, /* ltu.l */ - {40,6,rr,A,A,0}, /* le.h */ - {40,7,rr,A,A,0}, /* le.w */ - {40,6,nr,A,0,0}, /* le.h */ - {40,7,nr,A,0,0}, /* le.w */ - {40,5,rr,S,S,0}, /* le.b */ - {40,6,rr,S,S,0}, /* le.h */ - {40,7,rr,S,S,0}, /* le.w */ - {40,8,rr,S,S,0}, /* le.l */ - {41,6,rr,A,A,0}, /* lt.h */ - {41,7,rr,A,A,0}, /* lt.w */ - {41,6,nr,A,0,0}, /* lt.h */ - {41,7,nr,A,0,0}, /* lt.w */ - {41,5,rr,S,S,0}, /* lt.b */ - {41,6,rr,S,S,0}, /* lt.h */ - {41,7,rr,S,S,0}, /* lt.w */ - {41,8,rr,S,S,0}, /* lt.l */ - {9,7,rr,S,A,0}, /* add.w */ - {8,0,rr,A,A,0}, /* shf */ - {0,0,rr,A,A,0}, /* mov */ - {0,0,rr,S,A,0}, /* mov */ - {0,7,rr,S,S,0}, /* mov.w */ - {8,0,rr,S,S,0}, /* shf */ - {0,0,rr,S,S,0}, /* mov */ - {0,0,rr,A,S,0}, /* mov */ - {5,0,rr,A,A,0}, /* and */ - {6,0,rr,A,A,0}, /* or */ - {7,0,rr,A,A,0}, /* xor */ - {42,0,rr,A,A,0}, /* not */ - {5,0,rr,S,S,0}, /* and */ - {6,0,rr,S,S,0}, /* or */ - {7,0,rr,S,S,0}, /* xor */ - {42,0,rr,S,S,0}, /* not */ - {40,3,rr,S,S,0}, /* le.s */ - {40,4,rr,S,S,0}, /* le.d */ - {41,3,rr,S,S,0}, /* lt.s */ - {41,4,rr,S,S,0}, /* lt.d */ - {9,3,rr,S,S,0}, /* add.s */ - {9,4,rr,S,S,0}, /* add.d */ - {10,3,rr,S,S,0}, /* sub.s */ - {10,4,rr,S,S,0}, /* sub.d */ - {37,3,rr,S,S,0}, /* eq.s */ - {37,4,rr,S,S,0}, /* eq.d */ - {43,6,rr,A,A,0}, /* neg.h */ - {43,7,rr,A,A,0}, /* neg.w */ - {3,3,rr,S,S,0}, /* mul.s */ - {3,4,rr,S,S,0}, /* mul.d */ - {4,3,rr,S,S,0}, /* div.s */ - {4,4,rr,S,S,0}, /* div.d */ - {9,6,rr,A,A,0}, /* add.h */ - {9,7,rr,A,A,0}, /* add.w */ - {9,6,nr,A,0,0}, /* add.h */ - {9,7,nr,A,0,0}, /* add.w */ - {9,5,rr,S,S,0}, /* add.b */ - {9,6,rr,S,S,0}, /* add.h */ - {9,7,rr,S,S,0}, /* add.w */ - {9,8,rr,S,S,0}, /* add.l */ - {10,6,rr,A,A,0}, /* sub.h */ - {10,7,rr,A,A,0}, /* sub.w */ - {10,6,nr,A,0,0}, /* sub.h */ - {10,7,nr,A,0,0}, /* sub.w */ - {10,5,rr,S,S,0}, /* sub.b */ - {10,6,rr,S,S,0}, /* sub.h */ - {10,7,rr,S,S,0}, /* sub.w */ - {10,8,rr,S,S,0}, /* sub.l */ - {3,6,rr,A,A,0}, /* mul.h */ - {3,7,rr,A,A,0}, /* mul.w */ - {3,6,nr,A,0,0}, /* mul.h */ - {3,7,nr,A,0,0}, /* mul.w */ - {3,5,rr,S,S,0}, /* mul.b */ - {3,6,rr,S,S,0}, /* mul.h */ - {3,7,rr,S,S,0}, /* mul.w */ - {3,8,rr,S,S,0}, /* mul.l */ - {4,6,rr,A,A,0}, /* div.h */ - {4,7,rr,A,A,0}, /* div.w */ - {4,6,nr,A,0,0}, /* div.h */ - {4,7,nr,A,0,0}, /* div.w */ - {4,5,rr,S,S,0}, /* div.b */ - {4,6,rr,S,S,0}, /* div.h */ - {4,7,rr,S,S,0}, /* div.w */ - {4,8,rr,S,S,0}, /* div.l */ -}; -struct formstr format3[] = { - {32,3,rr,V,V,0}, /* cvtd.s */ - {31,4,rr,V,V,0}, /* cvts.d */ - {33,4,rr,V,V,0}, /* cvtl.d */ - {32,8,rr,V,V,0}, /* cvtd.l */ - {0,0,rrl,S,S,VM}, /* mov */ - {0,0,rlr,S,VM,S}, /* mov */ - {0,0,0,0,0,0}, - {44,0,rr,S,S,0}, /* lop */ - {36,0,rr,V,V,0}, /* tzc */ - {44,0,rr,V,V,0}, /* lop */ - {0,0,0,0,0,0}, - {42,0,rr,V,V,0}, /* not */ - {8,0,rr,S,V,0}, /* shf */ - {35,1,rr,V,V,0}, /* plc.t */ - {45,2,rr,V,V,0}, /* cprs.f */ - {45,1,rr,V,V,0}, /* cprs.t */ - {37,3,rr,V,V,0}, /* eq.s */ - {37,4,rr,V,V,0}, /* eq.d */ - {43,3,rr,V,V,0}, /* neg.s */ - {43,4,rr,V,V,0}, /* neg.d */ - {37,3,rr,S,V,0}, /* eq.s */ - {37,4,rr,S,V,0}, /* eq.d */ - {43,3,rr,S,S,0}, /* neg.s */ - {43,4,rr,S,S,0}, /* neg.d */ - {40,3,rr,V,V,0}, /* le.s */ - {40,4,rr,V,V,0}, /* le.d */ - {41,3,rr,V,V,0}, /* lt.s */ - {41,4,rr,V,V,0}, /* lt.d */ - {40,3,rr,S,V,0}, /* le.s */ - {40,4,rr,S,V,0}, /* le.d */ - {41,3,rr,S,V,0}, /* lt.s */ - {41,4,rr,S,V,0}, /* lt.d */ - {37,5,rr,V,V,0}, /* eq.b */ - {37,6,rr,V,V,0}, /* eq.h */ - {37,7,rr,V,V,0}, /* eq.w */ - {37,8,rr,V,V,0}, /* eq.l */ - {37,5,rr,S,V,0}, /* eq.b */ - {37,6,rr,S,V,0}, /* eq.h */ - {37,7,rr,S,V,0}, /* eq.w */ - {37,8,rr,S,V,0}, /* eq.l */ - {40,5,rr,V,V,0}, /* le.b */ - {40,6,rr,V,V,0}, /* le.h */ - {40,7,rr,V,V,0}, /* le.w */ - {40,8,rr,V,V,0}, /* le.l */ - {40,5,rr,S,V,0}, /* le.b */ - {40,6,rr,S,V,0}, /* le.h */ - {40,7,rr,S,V,0}, /* le.w */ - {40,8,rr,S,V,0}, /* le.l */ - {41,5,rr,V,V,0}, /* lt.b */ - {41,6,rr,V,V,0}, /* lt.h */ - {41,7,rr,V,V,0}, /* lt.w */ - {41,8,rr,V,V,0}, /* lt.l */ - {41,5,rr,S,V,0}, /* lt.b */ - {41,6,rr,S,V,0}, /* lt.h */ - {41,7,rr,S,V,0}, /* lt.w */ - {41,8,rr,S,V,0}, /* lt.l */ - {43,5,rr,V,V,0}, /* neg.b */ - {43,6,rr,V,V,0}, /* neg.h */ - {43,7,rr,V,V,0}, /* neg.w */ - {43,8,rr,V,V,0}, /* neg.l */ - {43,5,rr,S,S,0}, /* neg.b */ - {43,6,rr,S,S,0}, /* neg.h */ - {43,7,rr,S,S,0}, /* neg.w */ - {43,8,rr,S,S,0}, /* neg.l */ -}; -struct formstr format4[] = { - {46,0,nops,0,0,0}, /* nop */ - {47,0,pcrel,0,0,0}, /* br */ - {48,2,pcrel,0,0,0}, /* bri.f */ - {48,1,pcrel,0,0,0}, /* bri.t */ - {49,2,pcrel,0,0,0}, /* bra.f */ - {49,1,pcrel,0,0,0}, /* bra.t */ - {50,2,pcrel,0,0,0}, /* brs.f */ - {50,1,pcrel,0,0,0}, /* brs.t */ -}; -struct formstr format5[] = { - {51,5,rr,V,V,0}, /* ldvi.b */ - {51,6,rr,V,V,0}, /* ldvi.h */ - {51,7,rr,V,V,0}, /* ldvi.w */ - {51,8,rr,V,V,0}, /* ldvi.l */ - {28,3,rr,V,V,0}, /* cvtw.s */ - {31,7,rr,V,V,0}, /* cvts.w */ - {28,8,rr,V,V,0}, /* cvtw.l */ - {33,7,rr,V,V,0}, /* cvtl.w */ - {52,5,rxr,V,V,0}, /* stvi.b */ - {52,6,rxr,V,V,0}, /* stvi.h */ - {52,7,rxr,V,V,0}, /* stvi.w */ - {52,8,rxr,V,V,0}, /* stvi.l */ - {52,5,rxr,S,V,0}, /* stvi.b */ - {52,6,rxr,S,V,0}, /* stvi.h */ - {52,7,rxr,S,V,0}, /* stvi.w */ - {52,8,rxr,S,V,0}, /* stvi.l */ -}; -struct formstr format6[] = { - {53,0,r,A,0,0}, /* ldsdr */ - {54,0,r,A,0,0}, /* ldkdr */ - {55,3,r,S,0,0}, /* ln.s */ - {55,4,r,S,0,0}, /* ln.d */ - {56,0,nops,0,0,0}, /* patu */ - {57,0,r,A,0,0}, /* pate */ - {58,0,nops,0,0,0}, /* pich */ - {59,0,nops,0,0,0}, /* plch */ - {0,0,lr,PSW,A,0}, /* mov */ - {0,0,rxl,A,PSW,0}, /* mov */ - {0,0,lr,PC,A,0}, /* mov */ - {60,0,r,S,0,0}, /* idle */ - {0,0,lr,ITR,S,0}, /* mov */ - {0,0,rxl,S,ITR,0}, /* mov */ - {0,0,0,0,0,0}, - {0,0,rxl,S,ITSR,0}, /* mov */ - {61,0,nops,0,0,0}, /* rtnq */ - {62,0,nops,0,0,0}, /* cfork */ - {63,0,nops,0,0,0}, /* rtn */ - {64,0,nops,0,0,0}, /* wfork */ - {65,0,nops,0,0,0}, /* join */ - {66,0,nops,0,0,0}, /* rtnc */ - {67,3,r,S,0,0}, /* exp.s */ - {67,4,r,S,0,0}, /* exp.d */ - {68,3,r,S,0,0}, /* sin.s */ - {68,4,r,S,0,0}, /* sin.d */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {69,3,r,S,0,0}, /* cos.s */ - {69,4,r,S,0,0}, /* cos.d */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {70,7,r,A,0,0}, /* psh.w */ - {0,0,0,0,0,0}, - {71,7,r,A,0,0}, /* pop.w */ - {0,0,0,0,0,0}, - {70,7,r,S,0,0}, /* psh.w */ - {70,8,r,S,0,0}, /* psh.l */ - {71,7,r,S,0,0}, /* pop.w */ - {71,8,r,S,0,0}, /* pop.l */ - {72,0,nops,0,0,0}, /* eni */ - {73,0,nops,0,0,0}, /* dsi */ - {74,0,nops,0,0,0}, /* bkpt */ - {75,0,nops,0,0,0}, /* msync */ - {76,0,r,S,0,0}, /* mski */ - {77,0,r,S,0,0}, /* xmti */ - {0,0,rxl,S,VV,0}, /* mov */ - {78,0,nops,0,0,0}, /* tstvv */ - {0,0,lr,VS,A,0}, /* mov */ - {0,0,rxl,A,VS,0}, /* mov */ - {0,0,lr,VL,A,0}, /* mov */ - {0,0,rxl,A,VL,0}, /* mov */ - {0,7,lr,VS,S,0}, /* mov.w */ - {0,7,rxl,S,VS,0}, /* mov.w */ - {0,7,lr,VL,S,0}, /* mov.w */ - {0,7,rxl,S,VL,0}, /* mov.w */ - {79,0,r,A,0,0}, /* diag */ - {80,0,nops,0,0,0}, /* pbkpt */ - {81,3,r,S,0,0}, /* sqrt.s */ - {81,4,r,S,0,0}, /* sqrt.d */ - {82,0,nops,0,0,0}, /* casr */ - {0,0,0,0,0,0}, - {83,3,r,S,0,0}, /* atan.s */ - {83,4,r,S,0,0}, /* atan.d */ -}; -struct formstr format7[] = { - {84,5,r,V,0,0}, /* sum.b */ - {84,6,r,V,0,0}, /* sum.h */ - {84,7,r,V,0,0}, /* sum.w */ - {84,8,r,V,0,0}, /* sum.l */ - {85,0,r,V,0,0}, /* all */ - {86,0,r,V,0,0}, /* any */ - {87,0,r,V,0,0}, /* parity */ - {0,0,0,0,0,0}, - {88,5,r,V,0,0}, /* max.b */ - {88,6,r,V,0,0}, /* max.h */ - {88,7,r,V,0,0}, /* max.w */ - {88,8,r,V,0,0}, /* max.l */ - {89,5,r,V,0,0}, /* min.b */ - {89,6,r,V,0,0}, /* min.h */ - {89,7,r,V,0,0}, /* min.w */ - {89,8,r,V,0,0}, /* min.l */ - {84,3,r,V,0,0}, /* sum.s */ - {84,4,r,V,0,0}, /* sum.d */ - {90,3,r,V,0,0}, /* prod.s */ - {90,4,r,V,0,0}, /* prod.d */ - {88,3,r,V,0,0}, /* max.s */ - {88,4,r,V,0,0}, /* max.d */ - {89,3,r,V,0,0}, /* min.s */ - {89,4,r,V,0,0}, /* min.d */ - {90,5,r,V,0,0}, /* prod.b */ - {90,6,r,V,0,0}, /* prod.h */ - {90,7,r,V,0,0}, /* prod.w */ - {90,8,r,V,0,0}, /* prod.l */ - {35,2,lr,VM,S,0}, /* plc.f */ - {35,1,lr,VM,S,0}, /* plc.t */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, -}; -struct formstr formatx[] = { - {0,0,0,0,0,0}, -}; -struct formstr format1a[] = { - {91,0,imr,A,0,0}, /* halt */ - {92,0,a4,0,0,0}, /* sysc */ - {18,6,imr,A,0,0}, /* ld.h */ - {18,7,imr,A,0,0}, /* ld.w */ - {5,0,imr,A,0,0}, /* and */ - {6,0,imr,A,0,0}, /* or */ - {7,0,imr,A,0,0}, /* xor */ - {8,0,imr,A,0,0}, /* shf */ - {9,6,imr,A,0,0}, /* add.h */ - {9,7,imr,A,0,0}, /* add.w */ - {10,6,imr,A,0,0}, /* sub.h */ - {10,7,imr,A,0,0}, /* sub.w */ - {3,6,imr,A,0,0}, /* mul.h */ - {3,7,imr,A,0,0}, /* mul.w */ - {4,6,imr,A,0,0}, /* div.h */ - {4,7,imr,A,0,0}, /* div.w */ - {18,7,iml,VL,0,0}, /* ld.w */ - {18,7,iml,VS,0,0}, /* ld.w */ - {0,0,0,0,0,0}, - {8,7,imr,S,0,0}, /* shf.w */ - {93,0,a5,0,0,0}, /* trap */ - {0,0,0,0,0,0}, - {37,6,imr,A,0,0}, /* eq.h */ - {37,7,imr,A,0,0}, /* eq.w */ - {38,6,imr,A,0,0}, /* leu.h */ - {38,7,imr,A,0,0}, /* leu.w */ - {39,6,imr,A,0,0}, /* ltu.h */ - {39,7,imr,A,0,0}, /* ltu.w */ - {40,6,imr,A,0,0}, /* le.h */ - {40,7,imr,A,0,0}, /* le.w */ - {41,6,imr,A,0,0}, /* lt.h */ - {41,7,imr,A,0,0}, /* lt.w */ -}; -struct formstr format1b[] = { - {18,4,imr,S,0,0}, /* ld.d */ - {18,10,imr,S,0,0}, /* ld.u */ - {18,8,imr,S,0,0}, /* ld.l */ - {18,7,imr,S,0,0}, /* ld.w */ - {5,0,imr,S,0,0}, /* and */ - {6,0,imr,S,0,0}, /* or */ - {7,0,imr,S,0,0}, /* xor */ - {8,0,imr,S,0,0}, /* shf */ - {9,6,imr,S,0,0}, /* add.h */ - {9,7,imr,S,0,0}, /* add.w */ - {10,6,imr,S,0,0}, /* sub.h */ - {10,7,imr,S,0,0}, /* sub.w */ - {3,6,imr,S,0,0}, /* mul.h */ - {3,7,imr,S,0,0}, /* mul.w */ - {4,6,imr,S,0,0}, /* div.h */ - {4,7,imr,S,0,0}, /* div.w */ - {9,3,imr,S,0,0}, /* add.s */ - {10,3,imr,S,0,0}, /* sub.s */ - {3,3,imr,S,0,0}, /* mul.s */ - {4,3,imr,S,0,0}, /* div.s */ - {40,3,imr,S,0,0}, /* le.s */ - {41,3,imr,S,0,0}, /* lt.s */ - {37,6,imr,S,0,0}, /* eq.h */ - {37,7,imr,S,0,0}, /* eq.w */ - {38,6,imr,S,0,0}, /* leu.h */ - {38,7,imr,S,0,0}, /* leu.w */ - {39,6,imr,S,0,0}, /* ltu.h */ - {39,7,imr,S,0,0}, /* ltu.w */ - {40,6,imr,S,0,0}, /* le.h */ - {40,7,imr,S,0,0}, /* le.w */ - {41,6,imr,S,0,0}, /* lt.h */ - {41,7,imr,S,0,0}, /* lt.w */ -}; -struct formstr e0_format0[] = { - {10,3,rrr,S,V,V}, /* sub.s */ - {10,4,rrr,S,V,V}, /* sub.d */ - {4,3,rrr,S,V,V}, /* div.s */ - {4,4,rrr,S,V,V}, /* div.d */ - {10,11,rrr,S,V,V}, /* sub.s.f */ - {10,12,rrr,S,V,V}, /* sub.d.f */ - {4,11,rrr,S,V,V}, /* div.s.f */ - {4,12,rrr,S,V,V}, /* div.d.f */ - {3,11,rrr,V,V,V}, /* mul.s.f */ - {3,12,rrr,V,V,V}, /* mul.d.f */ - {4,11,rrr,V,V,V}, /* div.s.f */ - {4,12,rrr,V,V,V}, /* div.d.f */ - {3,11,rrr,V,S,V}, /* mul.s.f */ - {3,12,rrr,V,S,V}, /* mul.d.f */ - {4,11,rrr,V,S,V}, /* div.s.f */ - {4,12,rrr,V,S,V}, /* div.d.f */ - {5,2,rrr,V,V,V}, /* and.f */ - {6,2,rrr,V,V,V}, /* or.f */ - {7,2,rrr,V,V,V}, /* xor.f */ - {8,2,rrr,V,V,V}, /* shf.f */ - {5,2,rrr,V,S,V}, /* and.f */ - {6,2,rrr,V,S,V}, /* or.f */ - {7,2,rrr,V,S,V}, /* xor.f */ - {8,2,rrr,V,S,V}, /* shf.f */ - {9,11,rrr,V,V,V}, /* add.s.f */ - {9,12,rrr,V,V,V}, /* add.d.f */ - {10,11,rrr,V,V,V}, /* sub.s.f */ - {10,12,rrr,V,V,V}, /* sub.d.f */ - {9,11,rrr,V,S,V}, /* add.s.f */ - {9,12,rrr,V,S,V}, /* add.d.f */ - {10,11,rrr,V,S,V}, /* sub.s.f */ - {10,12,rrr,V,S,V}, /* sub.d.f */ - {9,13,rrr,V,V,V}, /* add.b.f */ - {9,14,rrr,V,V,V}, /* add.h.f */ - {9,15,rrr,V,V,V}, /* add.w.f */ - {9,16,rrr,V,V,V}, /* add.l.f */ - {9,13,rrr,V,S,V}, /* add.b.f */ - {9,14,rrr,V,S,V}, /* add.h.f */ - {9,15,rrr,V,S,V}, /* add.w.f */ - {9,16,rrr,V,S,V}, /* add.l.f */ - {10,13,rrr,V,V,V}, /* sub.b.f */ - {10,14,rrr,V,V,V}, /* sub.h.f */ - {10,15,rrr,V,V,V}, /* sub.w.f */ - {10,16,rrr,V,V,V}, /* sub.l.f */ - {10,13,rrr,V,S,V}, /* sub.b.f */ - {10,14,rrr,V,S,V}, /* sub.h.f */ - {10,15,rrr,V,S,V}, /* sub.w.f */ - {10,16,rrr,V,S,V}, /* sub.l.f */ - {3,13,rrr,V,V,V}, /* mul.b.f */ - {3,14,rrr,V,V,V}, /* mul.h.f */ - {3,15,rrr,V,V,V}, /* mul.w.f */ - {3,16,rrr,V,V,V}, /* mul.l.f */ - {3,13,rrr,V,S,V}, /* mul.b.f */ - {3,14,rrr,V,S,V}, /* mul.h.f */ - {3,15,rrr,V,S,V}, /* mul.w.f */ - {3,16,rrr,V,S,V}, /* mul.l.f */ - {4,13,rrr,V,V,V}, /* div.b.f */ - {4,14,rrr,V,V,V}, /* div.h.f */ - {4,15,rrr,V,V,V}, /* div.w.f */ - {4,16,rrr,V,V,V}, /* div.l.f */ - {4,13,rrr,V,S,V}, /* div.b.f */ - {4,14,rrr,V,S,V}, /* div.h.f */ - {4,15,rrr,V,S,V}, /* div.w.f */ - {4,16,rrr,V,S,V}, /* div.l.f */ -}; -struct formstr e0_format1[] = { - {0,0,0,0,0,0}, - {94,0,a3,0,0,0}, /* tst */ - {95,0,a3,0,0,0}, /* lck */ - {96,0,a3,0,0,0}, /* ulk */ - {17,0,a1r,S,0,0}, /* ldea */ - {97,0,a1r,A,0,0}, /* spawn */ - {98,0,a1r,A,0,0}, /* ldcmr */ - {99,0,a2r,A,0,0}, /* stcmr */ - {100,0,a1r,A,0,0}, /* popr */ - {101,0,a2r,A,0,0}, /* pshr */ - {102,7,a1r,A,0,0}, /* rcvr.w */ - {103,7,a2r,A,0,0}, /* matm.w */ - {104,7,a2r,A,0,0}, /* sndr.w */ - {104,8,a2r,S,0,0}, /* sndr.l */ - {102,8,a1r,S,0,0}, /* rcvr.l */ - {103,8,a2r,S,0,0}, /* matm.l */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {105,7,a2r,A,0,0}, /* putr.w */ - {105,8,a2r,S,0,0}, /* putr.l */ - {106,7,a1r,A,0,0}, /* getr.w */ - {106,8,a1r,S,0,0}, /* getr.l */ - {26,13,a2r,S,0,0}, /* ste.b.f */ - {26,14,a2r,S,0,0}, /* ste.h.f */ - {26,15,a2r,S,0,0}, /* ste.w.f */ - {26,16,a2r,S,0,0}, /* ste.l.f */ - {107,7,a2r,A,0,0}, /* matr.w */ - {108,7,a2r,A,0,0}, /* mat.w */ - {109,7,a1r,A,0,0}, /* get.w */ - {110,7,a1r,A,0,0}, /* rcv.w */ - {0,0,0,0,0,0}, - {111,7,a1r,A,0,0}, /* inc.w */ - {112,7,a2r,A,0,0}, /* put.w */ - {113,7,a2r,A,0,0}, /* snd.w */ - {107,8,a2r,S,0,0}, /* matr.l */ - {108,8,a2r,S,0,0}, /* mat.l */ - {109,8,a1r,S,0,0}, /* get.l */ - {110,8,a1r,S,0,0}, /* rcv.l */ - {0,0,0,0,0,0}, - {111,8,a1r,S,0,0}, /* inc.l */ - {112,8,a2r,S,0,0}, /* put.l */ - {113,8,a2r,S,0,0}, /* snd.l */ - {18,13,a1r,V,0,0}, /* ld.b.f */ - {18,14,a1r,V,0,0}, /* ld.h.f */ - {18,15,a1r,V,0,0}, /* ld.w.f */ - {18,16,a1r,V,0,0}, /* ld.l.f */ - {21,13,a2r,V,0,0}, /* st.b.f */ - {21,14,a2r,V,0,0}, /* st.h.f */ - {21,15,a2r,V,0,0}, /* st.w.f */ - {21,16,a2r,V,0,0}, /* st.l.f */ -}; -struct formstr e0_format2[] = { - {28,5,rr,V,V,0}, /* cvtw.b */ - {28,6,rr,V,V,0}, /* cvtw.h */ - {29,7,rr,V,V,0}, /* cvtb.w */ - {30,7,rr,V,V,0}, /* cvth.w */ - {28,13,rr,V,V,0}, /* cvtw.b.f */ - {28,14,rr,V,V,0}, /* cvtw.h.f */ - {29,15,rr,V,V,0}, /* cvtb.w.f */ - {30,15,rr,V,V,0}, /* cvth.w.f */ - {31,8,rr,V,V,0}, /* cvts.l */ - {32,7,rr,V,V,0}, /* cvtd.w */ - {33,3,rr,V,V,0}, /* cvtl.s */ - {28,4,rr,V,V,0}, /* cvtw.d */ - {31,16,rr,V,V,0}, /* cvts.l.f */ - {32,15,rr,V,V,0}, /* cvtd.w.f */ - {33,11,rr,V,V,0}, /* cvtl.s.f */ - {28,12,rr,V,V,0}, /* cvtw.d.f */ - {114,0,rr,S,S,0}, /* enal */ - {8,7,rr,S,S,0}, /* shf.w */ - {115,0,rr,S,S,0}, /* enag */ - {0,0,0,0,0,0}, - {28,4,rr,S,S,0}, /* cvtw.d */ - {32,7,rr,S,S,0}, /* cvtd.w */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {116,3,rr,S,S,0}, /* frint.s */ - {116,4,rr,S,S,0}, /* frint.d */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {116,3,rr,V,V,0}, /* frint.s */ - {116,4,rr,V,V,0}, /* frint.d */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {116,11,rr,V,V,0}, /* frint.s.f */ - {116,12,rr,V,V,0}, /* frint.d.f */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {81,3,rr,V,V,0}, /* sqrt.s */ - {81,4,rr,V,V,0}, /* sqrt.d */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {81,11,rr,V,V,0}, /* sqrt.s.f */ - {81,12,rr,V,V,0}, /* sqrt.d.f */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, -}; -struct formstr e0_format3[] = { - {32,11,rr,V,V,0}, /* cvtd.s.f */ - {31,12,rr,V,V,0}, /* cvts.d.f */ - {33,12,rr,V,V,0}, /* cvtl.d.f */ - {32,16,rr,V,V,0}, /* cvtd.l.f */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {36,2,rr,V,V,0}, /* tzc.f */ - {44,2,rr,V,V,0}, /* lop.f */ - {117,2,rr,V,V,0}, /* xpnd.f */ - {42,2,rr,V,V,0}, /* not.f */ - {8,2,rr,S,V,0}, /* shf.f */ - {35,17,rr,V,V,0}, /* plc.t.f */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {37,11,rr,V,V,0}, /* eq.s.f */ - {37,12,rr,V,V,0}, /* eq.d.f */ - {43,11,rr,V,V,0}, /* neg.s.f */ - {43,12,rr,V,V,0}, /* neg.d.f */ - {37,11,rr,S,V,0}, /* eq.s.f */ - {37,12,rr,S,V,0}, /* eq.d.f */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {40,11,rr,V,V,0}, /* le.s.f */ - {40,12,rr,V,V,0}, /* le.d.f */ - {41,11,rr,V,V,0}, /* lt.s.f */ - {41,12,rr,V,V,0}, /* lt.d.f */ - {40,11,rr,S,V,0}, /* le.s.f */ - {40,12,rr,S,V,0}, /* le.d.f */ - {41,11,rr,S,V,0}, /* lt.s.f */ - {41,12,rr,S,V,0}, /* lt.d.f */ - {37,13,rr,V,V,0}, /* eq.b.f */ - {37,14,rr,V,V,0}, /* eq.h.f */ - {37,15,rr,V,V,0}, /* eq.w.f */ - {37,16,rr,V,V,0}, /* eq.l.f */ - {37,13,rr,S,V,0}, /* eq.b.f */ - {37,14,rr,S,V,0}, /* eq.h.f */ - {37,15,rr,S,V,0}, /* eq.w.f */ - {37,16,rr,S,V,0}, /* eq.l.f */ - {40,13,rr,V,V,0}, /* le.b.f */ - {40,14,rr,V,V,0}, /* le.h.f */ - {40,15,rr,V,V,0}, /* le.w.f */ - {40,16,rr,V,V,0}, /* le.l.f */ - {40,13,rr,S,V,0}, /* le.b.f */ - {40,14,rr,S,V,0}, /* le.h.f */ - {40,15,rr,S,V,0}, /* le.w.f */ - {40,16,rr,S,V,0}, /* le.l.f */ - {41,13,rr,V,V,0}, /* lt.b.f */ - {41,14,rr,V,V,0}, /* lt.h.f */ - {41,15,rr,V,V,0}, /* lt.w.f */ - {41,16,rr,V,V,0}, /* lt.l.f */ - {41,13,rr,S,V,0}, /* lt.b.f */ - {41,14,rr,S,V,0}, /* lt.h.f */ - {41,15,rr,S,V,0}, /* lt.w.f */ - {41,16,rr,S,V,0}, /* lt.l.f */ - {43,13,rr,V,V,0}, /* neg.b.f */ - {43,14,rr,V,V,0}, /* neg.h.f */ - {43,15,rr,V,V,0}, /* neg.w.f */ - {43,16,rr,V,V,0}, /* neg.l.f */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, -}; -struct formstr e0_format4[] = { - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, -}; -struct formstr e0_format5[] = { - {51,13,rr,V,V,0}, /* ldvi.b.f */ - {51,14,rr,V,V,0}, /* ldvi.h.f */ - {51,15,rr,V,V,0}, /* ldvi.w.f */ - {51,16,rr,V,V,0}, /* ldvi.l.f */ - {28,11,rr,V,V,0}, /* cvtw.s.f */ - {31,15,rr,V,V,0}, /* cvts.w.f */ - {28,16,rr,V,V,0}, /* cvtw.l.f */ - {33,15,rr,V,V,0}, /* cvtl.w.f */ - {52,13,rxr,V,V,0}, /* stvi.b.f */ - {52,14,rxr,V,V,0}, /* stvi.h.f */ - {52,15,rxr,V,V,0}, /* stvi.w.f */ - {52,16,rxr,V,V,0}, /* stvi.l.f */ - {52,13,rxr,S,V,0}, /* stvi.b.f */ - {52,14,rxr,S,V,0}, /* stvi.h.f */ - {52,15,rxr,S,V,0}, /* stvi.w.f */ - {52,16,rxr,S,V,0}, /* stvi.l.f */ -}; -struct formstr e0_format6[] = { - {0,0,rxl,S,CIR,0}, /* mov */ - {0,0,lr,CIR,S,0}, /* mov */ - {0,0,lr,TOC,S,0}, /* mov */ - {0,0,lr,CPUID,S,0}, /* mov */ - {0,0,rxl,S,TTR,0}, /* mov */ - {0,0,lr,TTR,S,0}, /* mov */ - {118,0,nops,0,0,0}, /* ctrsl */ - {119,0,nops,0,0,0}, /* ctrsg */ - {0,0,rxl,S,VMU,0}, /* mov */ - {0,0,lr,VMU,S,0}, /* mov */ - {0,0,rxl,S,VML,0}, /* mov */ - {0,0,lr,VML,S,0}, /* mov */ - {0,0,rxl,S,ICR,0}, /* mov */ - {0,0,lr,ICR,S,0}, /* mov */ - {0,0,rxl,S,TCPU,0}, /* mov */ - {0,0,lr,TCPU,S,0}, /* mov */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {120,0,nops,0,0,0}, /* stop */ - {0,0,0,0,0,0}, - {0,0,rxl,S,TID,0}, /* mov */ - {0,0,lr,TID,S,0}, /* mov */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, -}; -struct formstr e0_format7[] = { - {84,13,r,V,0,0}, /* sum.b.f */ - {84,14,r,V,0,0}, /* sum.h.f */ - {84,15,r,V,0,0}, /* sum.w.f */ - {84,16,r,V,0,0}, /* sum.l.f */ - {85,2,r,V,0,0}, /* all.f */ - {86,2,r,V,0,0}, /* any.f */ - {87,2,r,V,0,0}, /* parity.f */ - {0,0,0,0,0,0}, - {88,13,r,V,0,0}, /* max.b.f */ - {88,14,r,V,0,0}, /* max.h.f */ - {88,15,r,V,0,0}, /* max.w.f */ - {88,16,r,V,0,0}, /* max.l.f */ - {89,13,r,V,0,0}, /* min.b.f */ - {89,14,r,V,0,0}, /* min.h.f */ - {89,15,r,V,0,0}, /* min.w.f */ - {89,16,r,V,0,0}, /* min.l.f */ - {84,11,r,V,0,0}, /* sum.s.f */ - {84,12,r,V,0,0}, /* sum.d.f */ - {90,11,r,V,0,0}, /* prod.s.f */ - {90,12,r,V,0,0}, /* prod.d.f */ - {88,11,r,V,0,0}, /* max.s.f */ - {88,12,r,V,0,0}, /* max.d.f */ - {89,11,r,V,0,0}, /* min.s.f */ - {89,12,r,V,0,0}, /* min.d.f */ - {90,13,r,V,0,0}, /* prod.b.f */ - {90,14,r,V,0,0}, /* prod.h.f */ - {90,15,r,V,0,0}, /* prod.w.f */ - {90,16,r,V,0,0}, /* prod.l.f */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, -}; -struct formstr e1_format0[] = { - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {10,18,rrr,S,V,V}, /* sub.s.t */ - {10,19,rrr,S,V,V}, /* sub.d.t */ - {4,18,rrr,S,V,V}, /* div.s.t */ - {4,19,rrr,S,V,V}, /* div.d.t */ - {3,18,rrr,V,V,V}, /* mul.s.t */ - {3,19,rrr,V,V,V}, /* mul.d.t */ - {4,18,rrr,V,V,V}, /* div.s.t */ - {4,19,rrr,V,V,V}, /* div.d.t */ - {3,18,rrr,V,S,V}, /* mul.s.t */ - {3,19,rrr,V,S,V}, /* mul.d.t */ - {4,18,rrr,V,S,V}, /* div.s.t */ - {4,19,rrr,V,S,V}, /* div.d.t */ - {5,1,rrr,V,V,V}, /* and.t */ - {6,1,rrr,V,V,V}, /* or.t */ - {7,1,rrr,V,V,V}, /* xor.t */ - {8,1,rrr,V,V,V}, /* shf.t */ - {5,1,rrr,V,S,V}, /* and.t */ - {6,1,rrr,V,S,V}, /* or.t */ - {7,1,rrr,V,S,V}, /* xor.t */ - {8,1,rrr,V,S,V}, /* shf.t */ - {9,18,rrr,V,V,V}, /* add.s.t */ - {9,19,rrr,V,V,V}, /* add.d.t */ - {10,18,rrr,V,V,V}, /* sub.s.t */ - {10,19,rrr,V,V,V}, /* sub.d.t */ - {9,18,rrr,V,S,V}, /* add.s.t */ - {9,19,rrr,V,S,V}, /* add.d.t */ - {10,18,rrr,V,S,V}, /* sub.s.t */ - {10,19,rrr,V,S,V}, /* sub.d.t */ - {9,20,rrr,V,V,V}, /* add.b.t */ - {9,21,rrr,V,V,V}, /* add.h.t */ - {9,22,rrr,V,V,V}, /* add.w.t */ - {9,23,rrr,V,V,V}, /* add.l.t */ - {9,20,rrr,V,S,V}, /* add.b.t */ - {9,21,rrr,V,S,V}, /* add.h.t */ - {9,22,rrr,V,S,V}, /* add.w.t */ - {9,23,rrr,V,S,V}, /* add.l.t */ - {10,20,rrr,V,V,V}, /* sub.b.t */ - {10,21,rrr,V,V,V}, /* sub.h.t */ - {10,22,rrr,V,V,V}, /* sub.w.t */ - {10,23,rrr,V,V,V}, /* sub.l.t */ - {10,20,rrr,V,S,V}, /* sub.b.t */ - {10,21,rrr,V,S,V}, /* sub.h.t */ - {10,22,rrr,V,S,V}, /* sub.w.t */ - {10,23,rrr,V,S,V}, /* sub.l.t */ - {3,20,rrr,V,V,V}, /* mul.b.t */ - {3,21,rrr,V,V,V}, /* mul.h.t */ - {3,22,rrr,V,V,V}, /* mul.w.t */ - {3,23,rrr,V,V,V}, /* mul.l.t */ - {3,20,rrr,V,S,V}, /* mul.b.t */ - {3,21,rrr,V,S,V}, /* mul.h.t */ - {3,22,rrr,V,S,V}, /* mul.w.t */ - {3,23,rrr,V,S,V}, /* mul.l.t */ - {4,20,rrr,V,V,V}, /* div.b.t */ - {4,21,rrr,V,V,V}, /* div.h.t */ - {4,22,rrr,V,V,V}, /* div.w.t */ - {4,23,rrr,V,V,V}, /* div.l.t */ - {4,20,rrr,V,S,V}, /* div.b.t */ - {4,21,rrr,V,S,V}, /* div.h.t */ - {4,22,rrr,V,S,V}, /* div.w.t */ - {4,23,rrr,V,S,V}, /* div.l.t */ -}; -struct formstr e1_format1[] = { - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {26,20,a2r,S,0,0}, /* ste.b.t */ - {26,21,a2r,S,0,0}, /* ste.h.t */ - {26,22,a2r,S,0,0}, /* ste.w.t */ - {26,23,a2r,S,0,0}, /* ste.l.t */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {18,20,a1r,V,0,0}, /* ld.b.t */ - {18,21,a1r,V,0,0}, /* ld.h.t */ - {18,22,a1r,V,0,0}, /* ld.w.t */ - {18,23,a1r,V,0,0}, /* ld.l.t */ - {21,20,a2r,V,0,0}, /* st.b.t */ - {21,21,a2r,V,0,0}, /* st.h.t */ - {21,22,a2r,V,0,0}, /* st.w.t */ - {21,23,a2r,V,0,0}, /* st.l.t */ -}; -struct formstr e1_format2[] = { - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {28,20,rr,V,V,0}, /* cvtw.b.t */ - {28,21,rr,V,V,0}, /* cvtw.h.t */ - {29,22,rr,V,V,0}, /* cvtb.w.t */ - {30,22,rr,V,V,0}, /* cvth.w.t */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {31,23,rr,V,V,0}, /* cvts.l.t */ - {32,22,rr,V,V,0}, /* cvtd.w.t */ - {33,18,rr,V,V,0}, /* cvtl.s.t */ - {28,19,rr,V,V,0}, /* cvtw.d.t */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {116,18,rr,V,V,0}, /* frint.s.t */ - {116,19,rr,V,V,0}, /* frint.d.t */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {81,18,rr,V,V,0}, /* sqrt.s.t */ - {81,19,rr,V,V,0}, /* sqrt.d.t */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, -}; -struct formstr e1_format3[] = { - {32,18,rr,V,V,0}, /* cvtd.s.t */ - {31,19,rr,V,V,0}, /* cvts.d.t */ - {33,19,rr,V,V,0}, /* cvtl.d.t */ - {32,23,rr,V,V,0}, /* cvtd.l.t */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {36,1,rr,V,V,0}, /* tzc.t */ - {44,1,rr,V,V,0}, /* lop.t */ - {117,1,rr,V,V,0}, /* xpnd.t */ - {42,1,rr,V,V,0}, /* not.t */ - {8,1,rr,S,V,0}, /* shf.t */ - {35,24,rr,V,V,0}, /* plc.t.t */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {37,18,rr,V,V,0}, /* eq.s.t */ - {37,19,rr,V,V,0}, /* eq.d.t */ - {43,18,rr,V,V,0}, /* neg.s.t */ - {43,19,rr,V,V,0}, /* neg.d.t */ - {37,18,rr,S,V,0}, /* eq.s.t */ - {37,19,rr,S,V,0}, /* eq.d.t */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {40,18,rr,V,V,0}, /* le.s.t */ - {40,19,rr,V,V,0}, /* le.d.t */ - {41,18,rr,V,V,0}, /* lt.s.t */ - {41,19,rr,V,V,0}, /* lt.d.t */ - {40,18,rr,S,V,0}, /* le.s.t */ - {40,19,rr,S,V,0}, /* le.d.t */ - {41,18,rr,S,V,0}, /* lt.s.t */ - {41,19,rr,S,V,0}, /* lt.d.t */ - {37,20,rr,V,V,0}, /* eq.b.t */ - {37,21,rr,V,V,0}, /* eq.h.t */ - {37,22,rr,V,V,0}, /* eq.w.t */ - {37,23,rr,V,V,0}, /* eq.l.t */ - {37,20,rr,S,V,0}, /* eq.b.t */ - {37,21,rr,S,V,0}, /* eq.h.t */ - {37,22,rr,S,V,0}, /* eq.w.t */ - {37,23,rr,S,V,0}, /* eq.l.t */ - {40,20,rr,V,V,0}, /* le.b.t */ - {40,21,rr,V,V,0}, /* le.h.t */ - {40,22,rr,V,V,0}, /* le.w.t */ - {40,23,rr,V,V,0}, /* le.l.t */ - {40,20,rr,S,V,0}, /* le.b.t */ - {40,21,rr,S,V,0}, /* le.h.t */ - {40,22,rr,S,V,0}, /* le.w.t */ - {40,23,rr,S,V,0}, /* le.l.t */ - {41,20,rr,V,V,0}, /* lt.b.t */ - {41,21,rr,V,V,0}, /* lt.h.t */ - {41,22,rr,V,V,0}, /* lt.w.t */ - {41,23,rr,V,V,0}, /* lt.l.t */ - {41,20,rr,S,V,0}, /* lt.b.t */ - {41,21,rr,S,V,0}, /* lt.h.t */ - {41,22,rr,S,V,0}, /* lt.w.t */ - {41,23,rr,S,V,0}, /* lt.l.t */ - {43,20,rr,V,V,0}, /* neg.b.t */ - {43,21,rr,V,V,0}, /* neg.h.t */ - {43,22,rr,V,V,0}, /* neg.w.t */ - {43,23,rr,V,V,0}, /* neg.l.t */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, -}; -struct formstr e1_format4[] = { - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, -}; -struct formstr e1_format5[] = { - {51,20,rr,V,V,0}, /* ldvi.b.t */ - {51,21,rr,V,V,0}, /* ldvi.h.t */ - {51,22,rr,V,V,0}, /* ldvi.w.t */ - {51,23,rr,V,V,0}, /* ldvi.l.t */ - {28,18,rr,V,V,0}, /* cvtw.s.t */ - {31,22,rr,V,V,0}, /* cvts.w.t */ - {28,23,rr,V,V,0}, /* cvtw.l.t */ - {33,22,rr,V,V,0}, /* cvtl.w.t */ - {52,20,rxr,V,V,0}, /* stvi.b.t */ - {52,21,rxr,V,V,0}, /* stvi.h.t */ - {52,22,rxr,V,V,0}, /* stvi.w.t */ - {52,23,rxr,V,V,0}, /* stvi.l.t */ - {52,20,rxr,S,V,0}, /* stvi.b.t */ - {52,21,rxr,S,V,0}, /* stvi.h.t */ - {52,22,rxr,S,V,0}, /* stvi.w.t */ - {52,23,rxr,S,V,0}, /* stvi.l.t */ -}; -struct formstr e1_format6[] = { - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, -}; -struct formstr e1_format7[] = { - {84,20,r,V,0,0}, /* sum.b.t */ - {84,21,r,V,0,0}, /* sum.h.t */ - {84,22,r,V,0,0}, /* sum.w.t */ - {84,23,r,V,0,0}, /* sum.l.t */ - {85,1,r,V,0,0}, /* all.t */ - {86,1,r,V,0,0}, /* any.t */ - {87,1,r,V,0,0}, /* parity.t */ - {0,0,0,0,0,0}, - {88,20,r,V,0,0}, /* max.b.t */ - {88,21,r,V,0,0}, /* max.h.t */ - {88,22,r,V,0,0}, /* max.w.t */ - {88,23,r,V,0,0}, /* max.l.t */ - {89,20,r,V,0,0}, /* min.b.t */ - {89,21,r,V,0,0}, /* min.h.t */ - {89,22,r,V,0,0}, /* min.w.t */ - {89,23,r,V,0,0}, /* min.l.t */ - {84,18,r,V,0,0}, /* sum.s.t */ - {84,19,r,V,0,0}, /* sum.d.t */ - {90,18,r,V,0,0}, /* prod.s.t */ - {90,19,r,V,0,0}, /* prod.d.t */ - {88,18,r,V,0,0}, /* max.s.t */ - {88,19,r,V,0,0}, /* max.d.t */ - {89,18,r,V,0,0}, /* min.s.t */ - {89,19,r,V,0,0}, /* min.d.t */ - {90,20,r,V,0,0}, /* prod.b.t */ - {90,21,r,V,0,0}, /* prod.h.t */ - {90,22,r,V,0,0}, /* prod.w.t */ - {90,23,r,V,0,0}, /* prod.l.t */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, -}; -char *lop[] = { - "mov", /* 0 */ - "merg", /* 1 */ - "mask", /* 2 */ - "mul", /* 3 */ - "div", /* 4 */ - "and", /* 5 */ - "or", /* 6 */ - "xor", /* 7 */ - "shf", /* 8 */ - "add", /* 9 */ - "sub", /* 10 */ - "exit", /* 11 */ - "jmp", /* 12 */ - "jmpi", /* 13 */ - "jmpa", /* 14 */ - "jmps", /* 15 */ - "tac", /* 16 */ - "ldea", /* 17 */ - "ld", /* 18 */ - "tas", /* 19 */ - "pshea", /* 20 */ - "st", /* 21 */ - "call", /* 22 */ - "calls", /* 23 */ - "callq", /* 24 */ - "pfork", /* 25 */ - "ste", /* 26 */ - "incr", /* 27 */ - "cvtw", /* 28 */ - "cvtb", /* 29 */ - "cvth", /* 30 */ - "cvts", /* 31 */ - "cvtd", /* 32 */ - "cvtl", /* 33 */ - "ldpa", /* 34 */ - "plc", /* 35 */ - "tzc", /* 36 */ - "eq", /* 37 */ - "leu", /* 38 */ - "ltu", /* 39 */ - "le", /* 40 */ - "lt", /* 41 */ - "not", /* 42 */ - "neg", /* 43 */ - "lop", /* 44 */ - "cprs", /* 45 */ - "nop", /* 46 */ - "br", /* 47 */ - "bri", /* 48 */ - "bra", /* 49 */ - "brs", /* 50 */ - "ldvi", /* 51 */ - "stvi", /* 52 */ - "ldsdr", /* 53 */ - "ldkdr", /* 54 */ - "ln", /* 55 */ - "patu", /* 56 */ - "pate", /* 57 */ - "pich", /* 58 */ - "plch", /* 59 */ - "idle", /* 60 */ - "rtnq", /* 61 */ - "cfork", /* 62 */ - "rtn", /* 63 */ - "wfork", /* 64 */ - "join", /* 65 */ - "rtnc", /* 66 */ - "exp", /* 67 */ - "sin", /* 68 */ - "cos", /* 69 */ - "psh", /* 70 */ - "pop", /* 71 */ - "eni", /* 72 */ - "dsi", /* 73 */ - "bkpt", /* 74 */ - "msync", /* 75 */ - "mski", /* 76 */ - "xmti", /* 77 */ - "tstvv", /* 78 */ - "diag", /* 79 */ - "pbkpt", /* 80 */ - "sqrt", /* 81 */ - "casr", /* 82 */ - "atan", /* 83 */ - "sum", /* 84 */ - "all", /* 85 */ - "any", /* 86 */ - "parity", /* 87 */ - "max", /* 88 */ - "min", /* 89 */ - "prod", /* 90 */ - "halt", /* 91 */ - "sysc", /* 92 */ - "trap", /* 93 */ - "tst", /* 94 */ - "lck", /* 95 */ - "ulk", /* 96 */ - "spawn", /* 97 */ - "ldcmr", /* 98 */ - "stcmr", /* 99 */ - "popr", /* 100 */ - "pshr", /* 101 */ - "rcvr", /* 102 */ - "matm", /* 103 */ - "sndr", /* 104 */ - "putr", /* 105 */ - "getr", /* 106 */ - "matr", /* 107 */ - "mat", /* 108 */ - "get", /* 109 */ - "rcv", /* 110 */ - "inc", /* 111 */ - "put", /* 112 */ - "snd", /* 113 */ - "enal", /* 114 */ - "enag", /* 115 */ - "frint", /* 116 */ - "xpnd", /* 117 */ - "ctrsl", /* 118 */ - "ctrsg", /* 119 */ - "stop", /* 120 */ -}; -char *rop[] = { - "", /* 0 */ - ".t", /* 1 */ - ".f", /* 2 */ - ".s", /* 3 */ - ".d", /* 4 */ - ".b", /* 5 */ - ".h", /* 6 */ - ".w", /* 7 */ - ".l", /* 8 */ - ".x", /* 9 */ - ".u", /* 10 */ - ".s.f", /* 11 */ - ".d.f", /* 12 */ - ".b.f", /* 13 */ - ".h.f", /* 14 */ - ".w.f", /* 15 */ - ".l.f", /* 16 */ - ".t.f", /* 17 */ - ".s.t", /* 18 */ - ".d.t", /* 19 */ - ".b.t", /* 20 */ - ".h.t", /* 21 */ - ".w.t", /* 22 */ - ".l.t", /* 23 */ - ".t.t", /* 24 */ -}; diff --git a/gdb/convex-pinsn.c b/gdb/convex-pinsn.c deleted file mode 100644 index ca9e9ca4e11..00000000000 --- a/gdb/convex-pinsn.c +++ /dev/null @@ -1,314 +0,0 @@ -/* Print Convex instructions for GDB, the GNU debugger. - Copyright (C) 1989 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include - -#include "defs.h" -#include "param.h" -#include "symtab.h" - -/* reg (fmt_field, inst_field) -- - the {first,second,third} operand of instruction as fmt_field = [ijk] - gets the value of the field from the [ijk] position of the instruction */ - -#define reg(a,b) ((char (*)[3])(op[fmt->a]))[inst.f0.b] - -/* lit (fmt_field) -- field [ijk] is a literal (PSW, VL, eg) */ - -#define lit(i) op[fmt->i] - -/* aj[j] -- name for A register j */ - -#define aj ((char (*)[3])(op[A])) - -union inst { - struct { - unsigned : 7; - unsigned i : 3; - unsigned j : 3; - unsigned k : 3; - unsigned : 16; - unsigned : 32; - } f0; - struct { - unsigned : 8; - unsigned indir : 1; - unsigned len : 1; - unsigned j : 3; - unsigned k : 3; - unsigned : 16; - unsigned : 32; - } f1; - unsigned char byte[8]; - unsigned short half[4]; - char signed_byte[8]; - short signed_half[4]; -}; - -struct opform { - int mask; /* opcode mask */ - int shift; /* opcode align */ - struct formstr *formstr[3]; /* ST, E0, E1 */ -}; - -struct formstr { - unsigned lop:8, rop:5; /* opcode */ - unsigned fmt:5; /* inst format */ - unsigned i:5, j:5, k:2; /* operand formats */ -}; - -#include "convx-opcode.h" - -unsigned char formdecode [] = { - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, - 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, - 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, - 4,4,4,4,4,4,4,4,5,5,5,5,6,6,7,8, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -}; - -struct opform opdecode[] = { - 0x7e00, 9, format0, e0_format0, e1_format0, - 0x3f00, 8, format1, e0_format1, e1_format1, - 0x1fc0, 6, format2, e0_format2, e1_format2, - 0x0fc0, 6, format3, e0_format3, e1_format3, - 0x0700, 8, format4, e0_format4, e1_format4, - 0x03c0, 6, format5, e0_format5, e1_format5, - 0x01f8, 3, format6, e0_format6, e1_format6, - 0x00f8, 3, format7, e0_format7, e1_format7, - 0x0000, 0, formatx, formatx, formatx, - 0x0f80, 7, formatx, formatx, formatx, - 0x0f80, 7, formatx, formatx, formatx, -}; - -/* Print the instruction at address MEMADDR in debugged memory, - on STREAM. Returns length of the instruction, in bytes. */ - -int -print_insn (memaddr, stream) - CORE_ADDR memaddr; - FILE *stream; -{ - union inst inst; - struct formstr *fmt; - register int format, op1, pfx; - int l; - - read_memory (memaddr, &inst, sizeof inst); - - /* Remove and note prefix, if present */ - - pfx = inst.half[0]; - if ((pfx & 0xfff0) == 0x7ef0) - { - pfx = ((pfx >> 3) & 1) + 1; - *(long long *) &inst = *(long long *) &inst.half[1]; - } - else pfx = 0; - - /* Split opcode into format.op1 and look up in appropriate table */ - - format = formdecode[inst.byte[0]]; - op1 = (inst.half[0] & opdecode[format].mask) >> opdecode[format].shift; - if (format == 9) - { - if (pfx) - fmt = formatx; - else if (inst.f1.j == 0) - fmt = &format1a[op1]; - else if (inst.f1.j == 1) - fmt = &format1b[op1]; - else - fmt = formatx; - } - else - fmt = &opdecode[format].formstr[pfx][op1]; - - /* Print it */ - - if (fmt->fmt == xxx) - { - /* noninstruction */ - fprintf (stream, "0x%04x", pfx ? pfx : inst.half[0]); - return 2; - } - - if (pfx) - pfx = 2; - - fprintf (stream, "%s%s%s", lop[fmt->lop], rop[fmt->rop], - &" "[strlen(lop[fmt->lop]) + strlen(rop[fmt->rop])]); - - switch (fmt->fmt) - { - case rrr: /* three register */ - fprintf (stream, "%s,%s,%s", reg(i,i), reg(j,j), reg(k,k)); - return pfx + 2; - - case rr: /* two register */ - fprintf (stream, "%s,%s", reg(i,j), reg(j,k)); - return pfx + 2; - - case rxr: /* two register, reversed i and j fields */ - fprintf (stream, "%s,%s", reg(i,k), reg(j,j)); - return pfx + 2; - - case r: /* one register */ - fprintf (stream, "%s", reg(i,k)); - return pfx + 2; - - case nops: /* no operands */ - return pfx + 2; - - case nr: /* short immediate, one register */ - fprintf (stream, "#%d,%s", inst.f0.j, reg(i,k)); - return pfx + 2; - - case pcrel: /* pc relative */ - print_address (memaddr + 2 * inst.signed_byte[1], stream); - return pfx + 2; - - case lr: /* literal, one register */ - fprintf (stream, "%s,%s", lit(i), reg(j,k)); - return pfx + 2; - - case rxl: /* one register, literal */ - fprintf (stream, "%s,%s", reg(i,k), lit(j)); - return pfx + 2; - - case rlr: /* register, literal, register */ - fprintf (stream, "%s,%s,%s", reg(i,j), lit(j), reg(k,k)); - return pfx + 2; - - case rrl: /* register, register, literal */ - fprintf (stream, "%s,%s,%s", reg(i,j), reg(j,k), lit(k)); - return pfx + 2; - - case iml: /* immediate, literal */ - if (inst.f1.len) - { - fprintf (stream, "#%#x,%s", - (inst.signed_half[1] << 16) + inst.half[2], lit(i)); - return pfx + 6; - } - else - { - fprintf (stream, "#%d,%s", inst.signed_half[1], lit(i)); - return pfx + 4; - } - - case imr: /* immediate, register */ - if (inst.f1.len) - { - fprintf (stream, "#%#x,%s", - (inst.signed_half[1] << 16) + inst.half[2], reg(i,k)); - return pfx + 6; - } - else - { - fprintf (stream, "#%d,%s", inst.signed_half[1], reg(i,k)); - return pfx + 4; - } - - case a1r: /* memory, register */ - l = print_effa (inst, stream); - fprintf (stream, ",%s", reg(i,k)); - return pfx + l; - - case a1l: /* memory, literal */ - l = print_effa (inst, stream); - fprintf (stream, ",%s", lit(i)); - return pfx + l; - - case a2r: /* register, memory */ - fprintf (stream, "%s,", reg(i,k)); - return pfx + print_effa (inst, stream); - - case a2l: /* literal, memory */ - fprintf (stream, "%s,", lit(i)); - return pfx + print_effa (inst, stream); - - case a3: /* memory */ - return pfx + print_effa (inst, stream); - - case a4: /* system call */ - l = 29; goto a4a5; - case a5: /* trap */ - l = 27; - a4a5: - if (inst.f1.len) - { - unsigned int m = (inst.signed_half[1] << 16) + inst.half[2]; - fprintf (stream, "#%d,#%d", m >> l, m & (-1 >> (32-l))); - return pfx + 6; - } - else - { - unsigned int m = inst.signed_half[1]; - fprintf (stream, "#%d,#%d", m >> l, m & (-1 >> (32-l))); - return pfx + 4; - } - } -} - - -/* print effective address @nnn(aj), return instruction length */ - -int print_effa (inst, stream) - union inst inst; - FILE *stream; -{ - int n, l; - - if (inst.f1.len) - { - n = (inst.signed_half[1] << 16) + inst.half[2]; - l = 6; - } - else - { - n = inst.signed_half[1]; - l = 4; - } - - if (inst.f1.indir) - printf ("@"); - - if (!inst.f1.j) - { - print_address (n, stream); - return l; - } - - fprintf (stream, (n & 0xf0000000) == 0x80000000 ? "%#x(%s)" : "%d(%s)", - n, aj[inst.f1.j]); - - return l; -} diff --git a/gdb/convex-tdep.c b/gdb/convex-tdep.c deleted file mode 100644 index ce6382b9480..00000000000 --- a/gdb/convex-tdep.c +++ /dev/null @@ -1,931 +0,0 @@ -/* Convex stuff for GDB. - Copyright (C) 1990, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "defs.h" -#include "param.h" -#include "command.h" -#include "symtab.h" -#include "value.h" -#include "frame.h" -#include "inferior.h" -#include "wait.h" - -#include -#include - -#include "gdbcore.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "gdbcmd.h" - -exec_file_command (filename, from_tty) - char *filename; - int from_tty; -{ - int val; - int n; - struct stat st_exec; - - /* Eliminate all traces of old exec file. - Mark text segment as empty. */ - - if (execfile) - free (execfile); - execfile = 0; - data_start = 0; - data_end = 0; - text_start = 0; - text_end = 0; - exec_data_start = 0; - exec_data_end = 0; - if (execchan >= 0) - close (execchan); - execchan = -1; - - n_exec = 0; - - /* Now open and digest the file the user requested, if any. */ - - if (filename) - { - filename = tilde_expand (filename); - make_cleanup (free, filename); - - execchan = openp (getenv ("PATH"), 1, filename, O_RDONLY, 0, - &execfile); - if (execchan < 0) - perror_with_name (filename); - - if (myread (execchan, &filehdr, sizeof filehdr) < 0) - perror_with_name (filename); - - if (! IS_SOFF_MAGIC (filehdr.h_magic)) - error ("%s: not an executable file.", filename); - - if (myread (execchan, &opthdr, filehdr.h_opthdr) <= 0) - perror_with_name (filename); - - /* Read through the section headers. - For text, data, etc, record an entry in the exec file map. - Record text_start and text_end. */ - - lseek (execchan, (long) filehdr.h_scnptr, 0); - - for (n = 0; n < filehdr.h_nscns; n++) - { - if (myread (execchan, &scnhdr, sizeof scnhdr) < 0) - perror_with_name (filename); - - if ((scnhdr.s_flags & S_TYPMASK) >= S_TEXT - && (scnhdr.s_flags & S_TYPMASK) <= S_COMON) - { - exec_map[n_exec].mem_addr = scnhdr.s_vaddr; - exec_map[n_exec].mem_end = scnhdr.s_vaddr + scnhdr.s_size; - exec_map[n_exec].file_addr = scnhdr.s_scnptr; - exec_map[n_exec].type = scnhdr.s_flags & S_TYPMASK; - n_exec++; - - if ((scnhdr.s_flags & S_TYPMASK) == S_TEXT) - { - text_start = scnhdr.s_vaddr; - text_end = scnhdr.s_vaddr + scnhdr.s_size; - } - } - } - - fstat (execchan, &st_exec); - exec_mtime = st_exec.st_mtime; - - validate_files (); - } - else if (from_tty) - printf_filtered ("No exec file now.\n"); - - /* Tell display code (if any) about the changed file name. */ - if (exec_file_display_hook) - (*exec_file_display_hook) (filename); -} - -/* Read data from SOFF exec or core file. - Return 0 on success, EIO if address out of bounds. */ - -int -xfer_core_file (memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - register int i; - register int n; - register int val; - int xferchan; - char **xferfile; - int fileptr; - int returnval = 0; - - while (len > 0) - { - xferfile = 0; - xferchan = 0; - - /* Determine which file the next bunch of addresses reside in, - and where in the file. Set the file's read/write pointer - to point at the proper place for the desired address - and set xferfile and xferchan for the correct file. - If desired address is nonexistent, leave them zero. - i is set to the number of bytes that can be handled - along with the next address. */ - - i = len; - - for (n = 0; n < n_core; n++) - { - if (memaddr >= core_map[n].mem_addr && memaddr < core_map[n].mem_end - && (core_map[n].thread == -1 - || core_map[n].thread == inferior_thread)) - { - i = min (len, core_map[n].mem_end - memaddr); - fileptr = core_map[n].file_addr + memaddr - core_map[n].mem_addr; - if (core_map[n].file_addr) - { - xferfile = &corefile; - xferchan = corechan; - } - break; - } - else if (core_map[n].mem_addr >= memaddr - && core_map[n].mem_addr < memaddr + i) - i = core_map[n].mem_addr - memaddr; - } - - if (!xferfile) - for (n = 0; n < n_exec; n++) - { - if (memaddr >= exec_map[n].mem_addr - && memaddr < exec_map[n].mem_end) - { - i = min (len, exec_map[n].mem_end - memaddr); - fileptr = exec_map[n].file_addr + memaddr - - exec_map[n].mem_addr; - if (exec_map[n].file_addr) - { - xferfile = &execfile; - xferchan = execchan; - } - break; - } - else if (exec_map[n].mem_addr >= memaddr - && exec_map[n].mem_addr < memaddr + i) - i = exec_map[n].mem_addr - memaddr; - } - - /* Now we know which file to use. - Set up its pointer and transfer the data. */ - if (xferfile) - { - if (*xferfile == 0) - if (xferfile == &execfile) - error ("No program file to examine."); - else - error ("No core dump file or running program to examine."); - val = lseek (xferchan, fileptr, 0); - if (val < 0) - perror_with_name (*xferfile); - val = myread (xferchan, myaddr, i); - if (val < 0) - perror_with_name (*xferfile); - } - /* If this address is for nonexistent memory, - read zeros if reading, or do nothing if writing. */ - else - { - bzero (myaddr, i); - returnval = EIO; - } - - memaddr += i; - myaddr += i; - len -= i; - } - return returnval; -} - - -/* Here from info files command to print an address map. */ - -print_maps () -{ - struct pmap ptrs[200]; - int n; - - /* ID strings for core and executable file sections */ - - static char *idstr[] = - { - "0", "text", "data", "tdata", "bss", "tbss", - "common", "ttext", "ctx", "tctx", "10", "11", "12", - }; - - for (n = 0; n < n_core; n++) - { - core_map[n].which = 0; - ptrs[n] = core_map[n]; - } - for (n = 0; n < n_exec; n++) - { - exec_map[n].which = 1; - ptrs[n_core+n] = exec_map[n]; - } - - qsort (ptrs, n_core + n_exec, sizeof *ptrs, ptr_cmp); - - for (n = 0; n < n_core + n_exec; n++) - { - struct pmap *p = &ptrs[n]; - if (n > 0) - { - if (p->mem_addr < ptrs[n-1].mem_end) - p->mem_addr = ptrs[n-1].mem_end; - if (p->mem_addr >= p->mem_end) - continue; - } - printf_filtered ("%08x .. %08x %-6s %s\n", - p->mem_addr, p->mem_end, idstr[p->type], - p->which ? execfile : corefile); - } -} - -/* Compare routine to put file sections in order. - Sort into increasing order on address, and put core file sections - before exec file sections if both files contain the same addresses. */ - -static ptr_cmp (a, b) - struct pmap *a, *b; -{ - if (a->mem_addr != b->mem_addr) return a->mem_addr - b->mem_addr; - return a->which - b->which; -} - -/* Trapped internal variables are used to handle special registers. - A trapped i.v. calls a hook here every time it is dereferenced, - to provide a new value for the variable, and it calls a hook here - when a new value is assigned, to do something with the value. - - The vector registers are $vl, $vs, $vm, $vN, $VN (N in 0..7). - The communication registers are $cN, $CN (N in 0..63). - They not handled as regular registers because it's expensive to - read them, and their size varies, and they have too many names. */ - - -/* Return 1 if NAME is a trapped internal variable, else 0. */ - -int -is_trapped_internalvar (name) - char *name; -{ - if ((name[0] == 'c' || name[0] == 'C') - && name[1] >= '0' && name[1] <= '9' - && (name[2] == '\0' - || (name[2] >= '0' && name[2] <= '9' - && name[3] == '\0' && name[1] != '0')) - && atoi (&name[1]) < 64) return 1; - - if ((name[0] == 'v' || name[0] == 'V') - && (((name[1] & -8) == '0' && name[2] == '\0') - || !strcmp (name, "vl") - || !strcmp (name, "vs") - || !strcmp (name, "vm"))) - return 1; - else return 0; -} - -/* Return the value of trapped internal variable VAR */ - -value -value_of_trapped_internalvar (var) - struct internalvar *var; -{ - char *name = var->name; - value val; - struct type *type; - long len = *read_vector_register (VL_REGNUM); - if (len <= 0 || len > 128) len = 128; - - if (!strcmp (name, "vl")) - { - val = value_from_longest (builtin_type_int, - (LONGEST) *read_vector_register_1 (VL_REGNUM)); - } - else if (!strcmp (name, "vs")) - { - val = value_from_longest (builtin_type_int, - (LONGEST) *read_vector_register_1 (VS_REGNUM)); - } - else if (!strcmp (name, "vm")) - { - long vm[4]; - long i, *p; - bcopy (read_vector_register_1 (VM_REGNUM), vm, sizeof vm); - type = vector_type (builtin_type_int, len); - val = allocate_value (type); - p = (long *) VALUE_CONTENTS (val); - for (i = 0; i < len; i++) - *p++ = !! (vm[3 - (i >> 5)] & (1 << (i & 037))); - } - else if (name[0] == 'V') - { - type = vector_type (builtin_type_long_long, len); - val = allocate_value (type); - bcopy (read_vector_register_1 (name[1] - '0'), - VALUE_CONTENTS (val), TYPE_LENGTH (type)); - } - else if (name[0] == 'v') - { - long *p1, *p2; - type = vector_type (builtin_type_long, len); - val = allocate_value (type); - p1 = read_vector_register_1 (name[1] - '0'); - p2 = (long *) VALUE_CONTENTS (val); - while (--len >= 0) {p1++; *p2++ = *p1++;} - } - - else if (name[0] == 'c') - val = value_from_longest (builtin_type_int, - read_comm_register (atoi (&name[1]))); - else if (name[0] == 'C') - val = value_from_longest (builtin_type_long_long, - read_comm_register (atoi (&name[1]))); - - VALUE_LVAL (val) = lval_internalvar; - VALUE_INTERNALVAR (val) = var; - return val; -} - -/* Construct the type for a vector register's value -- - array[LENGTH] of ELEMENT_TYPE. */ - -static struct type * -vector_type (element_type, length) - struct type *element_type; - long length; -{ - struct type *type = (struct type *) xmalloc (sizeof (struct type)); - bzero (type, sizeof type); - TYPE_CODE (type) = TYPE_CODE_ARRAY; - TYPE_TARGET_TYPE (type) = element_type; - TYPE_LENGTH (type) = length * TYPE_LENGTH (TYPE_TARGET_TYPE (type)); - return type; -} - -/* Handle a new value assigned to a trapped internal variable */ - -void -set_trapped_internalvar (var, val, bitpos, bitsize, offset) - struct internalvar *var; - value val; - int bitpos, bitsize, offset; -{ - char *name = var->name; - long long newval = value_as_long (val); - - if (!strcmp (name, "vl")) - write_vector_register (VL_REGNUM, 0, newval); - else if (!strcmp (name, "vs")) - write_vector_register (VS_REGNUM, 0, newval); - else if (name[0] == 'c' || name[0] == 'C') - write_comm_register (atoi (&name[1]), newval); - else if (!strcmp (name, "vm")) - error ("can't assign to $vm"); - else - { - offset /= bitsize / 8; - write_vector_register (name[1] - '0', offset, newval); - } -} - -/* Print an integer value when no format was specified. gdb normally - prints these values in decimal, but the the leading 0x80000000 of - pointers produces intolerable 10-digit negative numbers. - If it looks like an address, print it in hex instead. */ - -decout (stream, type, val) - FILE *stream; - struct type *type; - LONGEST val; -{ - long lv = val; - - switch (output_radix) - { - case 0: - if ((lv == val || (unsigned) lv == val) - && ((lv & 0xf0000000) == 0x80000000 - || ((lv & 0xf0000000) == 0xf0000000 && lv < STACK_END_ADDR))) - { - fprintf_filtered (stream, "%#x", lv); - return; - } - - case 10: - fprintf_filtered (stream, TYPE_UNSIGNED (type) ? "%llu" : "%lld", val); - return; - - case 8: - if (TYPE_LENGTH (type) <= sizeof lv) - fprintf_filtered (stream, "%#o", lv); - else - fprintf_filtered (stream, "%#llo", val); - return; - - case 16: - if (TYPE_LENGTH (type) <= sizeof lv) - fprintf_filtered (stream, "%#x", lv); - else - fprintf_filtered (stream, "%#llx", val); - return; - } -} - -/* Change the default output radix to 10 or 16, or set it to 0 (heuristic). - This command is mostly obsolete now that the print command allows - formats to apply to aggregates, but is still handy occasionally. */ - -static void -set_base_command (arg) - char *arg; -{ - int new_radix; - - if (!arg) - output_radix = 0; - else - { - new_radix = atoi (arg); - if (new_radix != 10 && new_radix != 16 && new_radix != 8) - error ("base must be 8, 10 or 16, or null"); - else output_radix = new_radix; - } -} - -/* Turn pipelining on or off in the inferior. */ - -static void -set_pipelining_command (arg) - char *arg; -{ - if (!arg) - { - sequential = !sequential; - printf_filtered ("%s\n", sequential ? "off" : "on"); - } - else if (!strcmp (arg, "on")) - sequential = 0; - else if (!strcmp (arg, "off")) - sequential = 1; - else error ("valid args are `on', to allow instructions to overlap, or\n\ -`off', to prevent it and thereby pinpoint exceptions."); -} - -/* Enable, disable, or force parallel execution in the inferior. */ - -static void -set_parallel_command (arg) - char *arg; -{ - struct rlimit rl; - int prevparallel = parallel; - - if (!strncmp (arg, "fixed", strlen (arg))) - parallel = 2; - else if (!strcmp (arg, "on")) - parallel = 1; - else if (!strcmp (arg, "off")) - parallel = 0; - else error ("valid args are `on', to allow multiple threads, or\n\ -`fixed', to force multiple threads, or\n\ -`off', to run with one thread only."); - - if ((prevparallel == 0) != (parallel == 0) && inferior_pid) - printf_filtered ("will take effect at next run.\n"); - - getrlimit (RLIMIT_CONCUR, &rl); - rl.rlim_cur = parallel ? rl.rlim_max : 1; - setrlimit (RLIMIT_CONCUR, &rl); - - if (inferior_pid) - set_fixed_scheduling (inferior_pid, parallel == 2); -} - -/* Add a new name for an existing command. */ - -static void -alias_command (arg) - char *arg; -{ - static char *aliaserr = "usage is `alias NEW OLD', no args allowed"; - char *newname = arg; - struct cmd_list_element *new, *old; - - if (!arg) - error_no_arg ("newname oldname"); - - new = lookup_cmd (&arg, cmdlist, "", -1); - if (new && !strncmp (newname, new->name, strlen (new->name))) - { - newname = new->name; - if (!(*arg == '-' - || (*arg >= 'a' && *arg <= 'z') - || (*arg >= 'A' && *arg <= 'Z') - || (*arg >= '0' && *arg <= '9'))) - error (aliaserr); - } - else - { - arg = newname; - while (*arg == '-' - || (*arg >= 'a' && *arg <= 'z') - || (*arg >= 'A' && *arg <= 'Z') - || (*arg >= '0' && *arg <= '9')) - arg++; - if (*arg != ' ' && *arg != '\t') - error (aliaserr); - *arg = '\0'; - arg++; - } - - old = lookup_cmd (&arg, cmdlist, "", 0); - - if (*arg != '\0') - error (aliaserr); - - if (new && !strncmp (newname, new->name, strlen (new->name))) - { - char *tem; - if (new->class == (int) class_user || new->class == (int) class_alias) - tem = "Redefine command \"%s\"? "; - else - tem = "Really redefine built-in command \"%s\"? "; - if (!query (tem, new->name)) - error ("Command \"%s\" not redefined.", new->name); - } - - add_com (newname, class_alias, old->function, old->doc); -} - - - -/* Print the current thread number, and any threads with signals in the - queue. */ - -thread_info () -{ - struct threadpid *p; - - if (have_inferior_p ()) - { - ps.pi_buffer = (char *) &comm_registers; - ps.pi_nbytes = sizeof comm_registers; - ps.pi_offset = 0; - ps.pi_thread = inferior_thread; - ioctl (inferior_fd, PIXRDCREGS, &ps); - } - - printf_filtered ("Current thread %d stopped with signal %d.%d (%s).\n", - inferior_thread, stop_signal, stop_sigcode, - subsig_name (stop_signal, stop_sigcode)); - - for (p = signal_stack; p->pid; p--) - printf_filtered ("Thread %d stopped with signal %d.%d (%s).\n", - p->thread, p->signo, p->subsig, - subsig_name (p->signo, p->subsig)); - - if (iscrlbit (comm_registers.crctl.lbits.cc, 64+13)) - printf_filtered ("New thread start pc %#x\n", - (long) (comm_registers.crreg.pcpsw >> 32)); -} - -/* Return string describing a signal.subcode number */ - -static char * -subsig_name (signo, subcode) - int signo, subcode; -{ - static char *subsig4[] = { - "error exit", "privileged instruction", "unknown", - "unknown", "undefined opcode", - 0}; - static char *subsig5[] = {0, - "breakpoint", "single step", "fork trap", "exec trap", "pfork trap", - "join trap", "idle trap", "last thread", "wfork trap", - "process breakpoint", "trap instruction", - 0}; - static char *subsig8[] = {0, - "int overflow", "int divide check", "float overflow", - "float divide check", "float underflow", "reserved operand", - "sqrt error", "exp error", "ln error", "sin error", "cos error", - 0}; - static char *subsig10[] = {0, - "invalid inward ring address", "invalid outward ring call", - "invalid inward ring return", "invalid syscall gate", - "invalid rtn frame length", "invalid comm reg address", - "invalid trap gate", - 0}; - static char *subsig11[] = {0, - "read access denied", "write access denied", "execute access denied", - "segment descriptor fault", "page table fault", "data reference fault", - "i/o access denied", "levt pte invalid", - 0}; - - static char **subsig_list[] = - {0, 0, 0, 0, subsig4, subsig5, 0, 0, subsig8, 0, subsig10, subsig11, 0}; - - int i; - char *p = signo < NSIG ? sys_siglist[signo] : "unknown"; - - if (signo >= (sizeof subsig_list / sizeof *subsig_list) - || !subsig_list[signo]) - return p; - for (i = 1; subsig_list[signo][i]; i++) - if (i == subcode) - return subsig_list[signo][subcode]; - return p; -} - - -/* Print a compact display of thread status, essentially x/i $pc - for all active threads. */ - -static void -threadstat () -{ - int t; - - for (t = 0; t < n_threads; t++) - if (thread_state[t] == PI_TALIVE) - { - printf_filtered ("%d%c %08x%c %d.%d ", t, - (t == inferior_thread ? '*' : ' '), thread_pc[t], - (thread_is_in_kernel[t] ? '#' : ' '), - thread_signal[t], thread_sigcode[t]); - print_insn (thread_pc[t], stdout); - printf_filtered ("\n"); - } -} - -/* Change the current thread to ARG. */ - -set_thread_command (arg) - char *arg; -{ - int thread; - - if (!arg) - { - threadstat (); - return; - } - - thread = parse_and_eval_address (arg); - - if (thread < 0 || thread > n_threads || thread_state[thread] != PI_TALIVE) - error ("no such thread."); - - select_thread (thread); - - stop_pc = read_pc (); - flush_cached_frames (); - set_current_frame (create_new_frame (read_register (FP_REGNUM), - read_pc ())); - select_frame (get_current_frame (), 0); - print_stack_frame (selected_frame, selected_frame_level, -1); -} - -/* Here on CONT command; gdb's dispatch address is changed to come here. - Set global variable ALL_CONTINUE to tell resume() that it should - start up all threads, and that a thread switch will not blow gdb's - mind. */ - -static void -convex_cont_command (proc_count_exp, from_tty) - char *proc_count_exp; - int from_tty; -{ - all_continue = 1; - cont_command (proc_count_exp, from_tty); -} - -/* Here on 1CONT command. Resume only the current thread. */ - -one_cont_command (proc_count_exp, from_tty) - char *proc_count_exp; - int from_tty; -{ - cont_command (proc_count_exp, from_tty); -} - -/* Print the contents and lock bits of all communication registers, - or just register ARG if ARG is a communication register, - or the 3-word resource structure in memory at address ARG. */ - -comm_registers_info (arg) - char *arg; -{ - int i, regnum; - - if (arg) - { - if (sscanf (arg, "$c%d", ®num) == 1) { - ; - } else if (sscanf (arg, "$C%d", ®num) == 1) { - ; - } else { - regnum = parse_and_eval_address (arg); - if (regnum > 0) - regnum &= ~0x8000; - } - - if (regnum >= 64) - error ("%s: invalid register name.", arg); - - /* if we got a (user) address, examine the resource struct there */ - - if (regnum < 0) - { - static int buf[3]; - read_memory (regnum, buf, sizeof buf); - printf_filtered ("%08x %08x%08x%s\n", regnum, buf[1], buf[2], - buf[0] & 0xff ? " locked" : ""); - return; - } - } - - ps.pi_buffer = (char *) &comm_registers; - ps.pi_nbytes = sizeof comm_registers; - ps.pi_offset = 0; - ps.pi_thread = inferior_thread; - ioctl (inferior_fd, PIXRDCREGS, &ps); - - for (i = 0; i < 64; i++) - if (!arg || i == regnum) - printf_filtered ("%2d 0x8%03x %016llx%s\n", i, i, - comm_registers.crreg.r4[i], - (iscrlbit (comm_registers.crctl.lbits.cc, i) - ? " locked" : "")); -} - -/* Print the psw */ - -static void -psw_info (arg) - char *arg; -{ - struct pswbit - { - int bit; - int pos; - char *text; - }; - - static struct pswbit pswbit[] = - { - { 0x80000000, -1, "A carry" }, - { 0x40000000, -1, "A integer overflow" }, - { 0x20000000, -1, "A zero divide" }, - { 0x10000000, -1, "Integer overflow enable" }, - { 0x08000000, -1, "Trace" }, - { 0x06000000, 25, "Frame length" }, - { 0x01000000, -1, "Sequential" }, - { 0x00800000, -1, "S carry" }, - { 0x00400000, -1, "S integer overflow" }, - { 0x00200000, -1, "S zero divide" }, - { 0x00100000, -1, "Zero divide enable" }, - { 0x00080000, -1, "Floating underflow" }, - { 0x00040000, -1, "Floating overflow" }, - { 0x00020000, -1, "Floating reserved operand" }, - { 0x00010000, -1, "Floating zero divide" }, - { 0x00008000, -1, "Floating error enable" }, - { 0x00004000, -1, "Floating underflow enable" }, - { 0x00002000, -1, "IEEE" }, - { 0x00001000, -1, "Sequential stores" }, - { 0x00000800, -1, "Intrinsic error" }, - { 0x00000400, -1, "Intrinsic error enable" }, - { 0x00000200, -1, "Trace thread creates" }, - { 0x00000100, -1, "Thread init trap" }, - { 0x000000e0, 5, "Reserved" }, - { 0x0000001f, 0, "Intrinsic error code" }, - {0, 0, 0}, - }; - - long psw; - struct pswbit *p; - - if (arg) - psw = parse_and_eval_address (arg); - else - psw = read_register (PS_REGNUM); - - for (p = pswbit; p->bit; p++) - { - if (p->pos < 0) - printf_filtered ("%08x %s %s\n", p->bit, - (psw & p->bit) ? "yes" : "no ", p->text); - else - printf_filtered ("%08x %3d %s\n", p->bit, - (psw & p->bit) >> p->pos, p->text); - } -} - -_initialize_convex_dep () -{ - add_com ("alias", class_support, alias_command, - "Add a new name for an existing command."); - - add_cmd ("base", class_vars, set_base_command, - "Change the integer output radix to 8, 10 or 16\n\ -or use just `set base' with no args to return to the ad-hoc default,\n\ -which is 16 for integers that look like addresses, 10 otherwise.", - &setlist); - - add_cmd ("pipeline", class_run, set_pipelining_command, - "Enable or disable overlapped execution of instructions.\n\ -With `set pipe off', exceptions are reported with\n\ -$pc pointing at the instruction after the faulting one.\n\ -The default is `set pipe on', which runs faster.", - &setlist); - - add_cmd ("parallel", class_run, set_parallel_command, - "Enable or disable multi-threaded execution of parallel code.\n\ -`set parallel off' means run the program on a single CPU.\n\ -`set parallel fixed' means run the program with all CPUs assigned to it.\n\ -`set parallel on' means run the program on any CPUs that are available.", - &setlist); - - add_com ("1cont", class_run, one_cont_command, - "Continue the program, activating only the current thread.\n\ -Args are the same as the `cont' command."); - - add_com ("thread", class_run, set_thread_command, - "Change the current thread, the one under scrutiny and control.\n\ -With no arg, show the active threads, the current one marked with *."); - - add_info ("threads", thread_info, - "List status of active threads."); - - add_info ("comm-registers", comm_registers_info, - "List communication registers and their contents.\n\ -A communication register name as argument means describe only that register.\n\ -An address as argument means describe the resource structure at that address.\n\ -`Locked' means that the register has been sent to but not yet received from."); - - add_info ("psw", psw_info, - "Display $ps, the processor status word, bit by bit.\n\ -An argument means display that value's interpretation as a psw."); - - add_cmd ("convex", no_class, 0, "Convex-specific commands.\n\ -32-bit registers $pc $ps $sp $ap $fp $a1-5 $s0-7 $v0-7 $vl $vs $vm $c0-63\n\ -64-bit registers $S0-7 $V0-7 $C0-63\n\ -\n\ -info threads display info on stopped threads waiting to signal\n\ -thread display list of active threads\n\ -thread N select thread N (its registers, stack, memory, etc.)\n\ -step, next, etc step selected thread only\n\ -1cont continue selected thread only\n\ -cont continue all threads\n\ -info comm-registers display contents of comm register(s) or a resource struct\n\ -info psw display processor status word $ps\n\ -set base N change integer radix used by `print' without a format\n\ -set pipeline off exceptions are precise, $pc points after the faulting insn\n\ -set pipeline on normal mode, $pc is somewhere ahead of faulting insn\n\ -set parallel off program runs on a single CPU\n\ -set parallel fixed all CPUs are assigned to the program\n\ -set parallel on normal mode, parallel execution on random available CPUs\n\ -", - &cmdlist); - -} diff --git a/gdb/convex-xdep.c b/gdb/convex-xdep.c deleted file mode 100644 index bfce6ebd6f6..00000000000 --- a/gdb/convex-xdep.c +++ /dev/null @@ -1,983 +0,0 @@ -/* Convex stuff for GDB. - Copyright (C) 1990-1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "defs.h" -#include "param.h" -#include "command.h" -#include "symtab.h" -#include "value.h" -#include "frame.h" -#include "inferior.h" -#include "wait.h" - -#include -#include -#include "gdbcore.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -/* Per-thread data, read from the inferior at each stop and written - back at each resume. */ - -/* Number of active threads. - Tables are valid for thread numbers less than this. */ - -static int n_threads; - -#define MAXTHREADS 8 - -/* Thread state. The remaining data is valid only if this is PI_TALIVE. */ - -static int thread_state[MAXTHREADS]; - -/* Stop pc, signal, signal subcode */ - -static int thread_pc[MAXTHREADS]; -static int thread_signal[MAXTHREADS]; -static int thread_sigcode[MAXTHREADS]; - -/* Thread registers. - If thread is selected, the regs are in registers[] instead. */ - -static char thread_regs[MAXTHREADS][REGISTER_BYTES]; - -/* 1 if the top frame on the thread's stack was a context frame, - meaning that the kernel is up to something and we should not - touch the thread at all except to resume it. */ - -static char thread_is_in_kernel[MAXTHREADS]; - -/* The currently selected thread's number. */ - -static int inferior_thread; - -/* Inferior process's file handle and a process control block - to feed args to ioctl with. */ - -static int inferior_fd; -static struct pcntl ps; - -/* SOFF file headers for exec or core file. */ - -static FILEHDR filehdr; -static OPTHDR opthdr; -static SCNHDR scnhdr; - -/* Address maps constructed from section headers of exec and core files. - Defines process address -> file address translation. */ - -struct pmap -{ - long mem_addr; /* process start address */ - long mem_end; /* process end+1 address */ - long file_addr; /* file start address */ - long thread; /* -1 shared; 0,1,... thread-local */ - long type; /* S_TEXT S_DATA S_BSS S_TBSS etc */ - long which; /* used to sort map for info files */ -}; - -static int n_exec, n_core; -static struct pmap exec_map[100]; -static struct pmap core_map[100]; - -/* Offsets in the core file of core_context and core_tcontext blocks. */ - -static int context_offset; -static int tcontext_offset[MAXTHREADS]; - -/* Core file control blocks. */ - -static struct core_context_v70 c; -static struct core_tcontext_v70 tc; -static struct user u; -static thread_t th; -static proc_t pr; - -/* The registers of the currently selected thread. */ - -extern char registers[REGISTER_BYTES]; - -/* Vector and communication registers from core dump or from inferior. - These are read on demand, ie, not normally valid. */ - -static struct vecst vector_registers; -static struct creg_ctx comm_registers; - -/* Flag, set on a vanilla CONT command and cleared when the inferior - is continued. */ - -static int all_continue; - -/* Flag, set when the inferior is continued by a vanilla CONT command, - cleared if it is continued for any other purpose. */ - -static int thread_switch_ok; - -/* Stack of signals recieved from threads but not yet delivered to gdb. */ - -struct threadpid -{ - int pid; - int thread; - int signo; - int subsig; - int pc; -}; - -static struct threadpid signal_stack_bot[100]; -static struct threadpid *signal_stack = signal_stack_bot; - -/* How to detect empty stack -- bottom frame is all zero. */ - -#define signal_stack_is_empty() (signal_stack->pid == 0) - -/* Mode controlled by SET PIPE command, controls the psw SEQ bit - which forces each instruction to complete before the next one starts. */ - -static int sequential = 0; - -/* Mode controlled by the SET PARALLEL command. Values are: - 0 concurrency limit 1 thread, dynamic scheduling - 1 no concurrency limit, dynamic scheduling - 2 no concurrency limit, fixed scheduling */ - -static int parallel = 1; - -/* Mode controlled by SET BASE command, output radix for unformatted - integer typeout, as in argument lists, aggregates, and so on. - Zero means guess whether it's an address (hex) or not (decimal). */ - -static int output_radix = 0; - -/* Signal subcode at last thread stop. */ - -static int stop_sigcode; - -/* Hack, see wait() below. */ - -static int exec_trap_timer; - -#include "gdbcmd.h" - -/* Nonzero if we are debugging an attached outside process - rather than an inferior. */ - -extern int attach_flag; - - - -static struct type *vector_type (); -static long *read_vector_register (); -static long *read_vector_register_1 (); -static void write_vector_register (); -static REGISTER_TYPE read_comm_register (); -static void write_comm_register (); -static void convex_cont_command (); -static void thread_continue (); -static void select_thread (); -static void scan_stack (); -static void set_fixed_scheduling (); -static char *subsig_name (); -static void psw_info (); -static sig_noop (); -static ptr_cmp (); - -extern char *sys_siglist[]; - -/* Execute ptrace. Convex V7 replaced ptrace with pattach. - Allow ptrace (0) as a no-op. */ - -int -call_ptrace (request, pid, procaddr, buf) - int request, pid, procaddr, buf; -{ - if (request == 0) - return; - error ("no ptrace"); -} - -/* Replacement for system execle routine. - Convert it to an equivalent exect, which pattach insists on. */ - -execle (name, argv) - char *name, *argv; -{ - char ***envp = (char ***) &argv; - while (*envp++) ; - - signal (SIGTRAP, sig_noop); - exect (name, &argv, *envp); -} - -/* Stupid handler for stupid trace trap that otherwise causes - startup to stupidly hang. */ - -static sig_noop () -{} - -/* Read registers from inferior into registers[] array. - For convex, they are already there, read in when the inferior stops. */ - -void -fetch_inferior_registers (regno) - int regno; -{ -} - -/* Store our register values back into the inferior. - For Convex, do this only once, right before resuming inferior. */ - -store_inferior_registers (regno) - int regno; -{ -} - -/* Copy LEN bytes from inferior's memory starting at MEMADDR - to debugger memory starting at MYADDR. - On failure (cannot read from inferior, usually because address is out - of bounds) returns the value of errno. */ - -int -read_inferior_memory (memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - errno = 0; - while (len > 0) - { - /* little-known undocumented max request size */ - int i = (len < 12288) ? len : 12288; - - lseek (inferior_fd, memaddr, 0); - read (inferior_fd, myaddr, i); - - memaddr += i; - myaddr += i; - len -= i; - } - if (errno) - bzero (myaddr, len); - return errno; -} - -/* Copy LEN bytes of data from debugger memory at MYADDR - to inferior's memory at MEMADDR. - Returns errno on failure (cannot write the inferior) */ - -int -write_inferior_memory (memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - errno = 0; - lseek (inferior_fd, memaddr, 0); - write (inferior_fd, myaddr, len); - return errno; -} - -/* Here from create_inferior when the inferior process has been created - and started up. We must do a pattach to grab it for debugging. - - Also, intercept the CONT command by altering its dispatch address. */ - -create_inferior_hook (pid) - int pid; -{ - static char cont[] = "cont"; - static char cont1[] = "c"; - char *linep = cont; - char *linep1 = cont1; - char **line = &linep; - char **line1 = &linep1; - struct cmd_list_element *c; - - c = lookup_cmd (line, cmdlist, "", 0); - c->function = convex_cont_command; - c = lookup_cmd (line1, cmdlist, "", 0); - c->function = convex_cont_command; - - inferior_fd = pattach (pid, O_EXCL); - if (inferior_fd < 0) - perror_with_name ("pattach"); - inferior_thread = 0; - set_fixed_scheduling (pid, parallel == 2); -} - -/* Attach process PID for debugging. */ - -attach (pid) - int pid; -{ - int fd = pattach (pid, O_EXCL); - if (fd < 0) - perror_with_name ("pattach"); - attach_flag = 1; - /* wait for strange kernel reverberations to go away */ - sleep (1); - - setpgrp (pid, pid); - - inferior_fd = fd; - inferior_thread = 0; - return pid; -} - -/* Stop debugging the process whose number is PID - and continue it with signal number SIGNAL. - SIGNAL = 0 means just continue it. */ - -void -detach (signal) - int signal; -{ - signal_stack = signal_stack_bot; - thread_continue (-1, 0, signal); - ioctl (inferior_fd, PIXDETACH, &ps); - close (inferior_fd); - inferior_fd = 0; - attach_flag = 0; -} - -/* Kill off the inferior process. */ - -kill_inferior () -{ - if (inferior_pid == 0) - return; - ioctl (inferior_fd, PIXTERMINATE, 0); - wait (0); - target_mourn_inferior (); -} - -/* This is used when GDB is exiting. It gives less chance of error.*/ - -kill_inferior_fast () -{ - if (inferior_pid == 0) - return; - ioctl (inferior_fd, PIXTERMINATE, 0); - wait (0); -} - -/* Read vector register REG, and return a pointer to the value. */ - -static long * -read_vector_register (reg) - int reg; -{ - if (have_inferior_p ()) - { - errno = 0; - ps.pi_buffer = (char *) &vector_registers; - ps.pi_nbytes = sizeof vector_registers; - ps.pi_offset = 0; - ps.pi_thread = inferior_thread; - ioctl (inferior_fd, PIXRDVREGS, &ps); - if (errno) - bzero (&vector_registers, sizeof vector_registers); - } - else if (corechan >= 0) - { - lseek (corechan, tcontext_offset[inferior_thread], 0); - if (myread (corechan, &tc, sizeof tc) < 0) - perror_with_name (corefile); - lseek (corechan, tc.core_thread_p, 0); - if (myread (corechan, &th, sizeof th) < 0) - perror_with_name (corefile); - lseek (corechan, tc.core_vregs_p, 0); - if (myread (corechan, &vector_registers, 16*128) < 0) - perror_with_name (corefile); - vector_registers.vm[0] = th.t_vect_ctx.vc_vm[0]; - vector_registers.vm[1] = th.t_vect_ctx.vc_vm[1]; - vector_registers.vls = th.t_vect_ctx.vc_vls; - } - - return read_vector_register_1 (reg); -} - -/* Return a pointer to vector register REG, which must already have been - fetched from the inferior or core file. */ - -static long * -read_vector_register_1 (reg) - int reg; -{ - switch (reg) - { - case VM_REGNUM: - return (long *) vector_registers.vm; - case VS_REGNUM: - return (long *) &vector_registers.vls; - case VL_REGNUM: - return 1 + (long *) &vector_registers.vls; - default: - return (long *) &vector_registers.vr[reg]; - } -} - -/* Write vector register REG, element ELEMENT, new value VAL. - NB: must use read-modify-write on the entire vector state, - since pattach does not do offsetted writes correctly. */ - -static void -write_vector_register (reg, element, val) - int reg, element; - REGISTER_TYPE val; -{ - if (have_inferior_p ()) - { - errno = 0; - ps.pi_thread = inferior_thread; - ps.pi_offset = 0; - ps.pi_buffer = (char *) &vector_registers; - ps.pi_nbytes = sizeof vector_registers; - - ioctl (inferior_fd, PIXRDVREGS, &ps); - - switch (reg) - { - case VL_REGNUM: - vector_registers.vls = - (vector_registers.vls & 0xffffffff00000000LL) - + (unsigned long) val; - break; - - case VS_REGNUM: - vector_registers.vls = - (val << 32) + (unsigned long) vector_registers.vls; - break; - - default: - vector_registers.vr[reg].el[element] = val; - break; - } - - ioctl (inferior_fd, PIXWRVREGS, &ps); - - if (errno) - perror_with_name ("writing vector register"); - } -} - -/* Return the contents of communication register NUM. */ - -static REGISTER_TYPE -read_comm_register (num) - int num; -{ - if (have_inferior_p ()) - { - ps.pi_buffer = (char *) &comm_registers; - ps.pi_nbytes = sizeof comm_registers; - ps.pi_offset = 0; - ps.pi_thread = inferior_thread; - ioctl (inferior_fd, PIXRDCREGS, &ps); - } - return comm_registers.crreg.r4[num]; -} - -/* Store a new value VAL into communication register NUM. - NB: Must use read-modify-write on the whole comm register set - since pattach does not do offsetted writes correctly. */ - -static void -write_comm_register (num, val) - int num; - REGISTER_TYPE val; -{ - if (have_inferior_p ()) - { - ps.pi_buffer = (char *) &comm_registers; - ps.pi_nbytes = sizeof comm_registers; - ps.pi_offset = 0; - ps.pi_thread = inferior_thread; - ioctl (inferior_fd, PIXRDCREGS, &ps); - comm_registers.crreg.r4[num] = val; - ioctl (inferior_fd, PIXWRCREGS, &ps); - } -} - -/* Resume execution of the inferior process. - If STEP is nonzero, single-step it. - If SIGNAL is nonzero, give it that signal. */ - -void -resume (step, signal) - int step; - int signal; -{ - errno = 0; - if (step || signal) - thread_continue (inferior_thread, step, signal); - else - thread_continue (-1, 0, 0); -} - -/* Maybe resume some threads. - THREAD is which thread to resume, or -1 to resume them all. - STEP and SIGNAL are as in resume. - - Global variable ALL_CONTINUE is set when we are here to do a - `cont' command; otherwise we may be doing `finish' or a call or - something else that will not tolerate an automatic thread switch. - - If there are stopped threads waiting to deliver signals, and - ALL_CONTINUE, do not actually resume anything. gdb will do a wait - and see one of the stopped threads in the queue. */ - -static void -thread_continue (thread, step, signal) - int thread, step, signal; -{ - int n; - - /* If we are to continue all threads, but not for the CONTINUE command, - pay no attention and continue only the selected thread. */ - - if (thread < 0 && ! all_continue) - thread = inferior_thread; - - /* If we are not stepping, we have now executed the continue part - of a CONTINUE command. */ - - if (! step) - all_continue = 0; - - /* Allow wait() to switch threads if this is an all-out continue. */ - - thread_switch_ok = thread < 0; - - /* If there are threads queued up, don't resume. */ - - if (thread_switch_ok && ! signal_stack_is_empty ()) - return; - - /* OK, do it. */ - - for (n = 0; n < n_threads; n++) - if (thread_state[n] == PI_TALIVE) - { - select_thread (n); - - if ((thread < 0 || n == thread) && ! thread_is_in_kernel[n]) - { - /* Blam the trace bits in the stack's saved psws to match - the desired step mode. This is required so that - single-stepping a return doesn't restore a psw with a - clear trace bit and fly away, and conversely, - proceeding through a return in a routine that was - stepped into doesn't cause a phantom break by restoring - a psw with the trace bit set. */ - scan_stack (PSW_T_BIT, step); - scan_stack (PSW_S_BIT, sequential); - } - - ps.pi_buffer = registers; - ps.pi_nbytes = REGISTER_BYTES; - ps.pi_offset = 0; - ps.pi_thread = n; - if (! thread_is_in_kernel[n]) - if (ioctl (inferior_fd, PIXWRREGS, &ps)) - perror_with_name ("PIXWRREGS"); - - if (thread < 0 || n == thread) - { - ps.pi_pc = 1; - ps.pi_signo = signal; - if (ioctl (inferior_fd, step ? PIXSTEP : PIXCONTINUE, &ps) < 0) - perror_with_name ("PIXCONTINUE"); - } - } - - if (ioctl (inferior_fd, PIXRUN, &ps) < 0) - perror_with_name ("PIXRUN"); -} - -/* Replacement for system wait routine. - - The system wait returns with one or more threads stopped by - signals. Put stopped threads on a stack and return them one by - one, so that it appears that wait returns one thread at a time. - - Global variable THREAD_SWITCH_OK is set when gdb can tolerate wait - returning a new thread. If it is false, then only one thread is - running; we will do a real wait, the thread will do something, and - we will return that. */ - -pid_t -wait (w) - union wait *w; -{ - int pid; - - if (!w) - return wait3 (0, 0, 0); - - /* Do a real wait if we were told to, or if there are no queued threads. */ - - if (! thread_switch_ok || signal_stack_is_empty ()) - { - int thread; - - pid = wait3 (w, 0, 0); - - if (!WIFSTOPPED (*w) || pid != inferior_pid) - return pid; - - /* The inferior has done something and stopped. Read in all the - threads' registers, and queue up any signals that happened. */ - - if (ioctl (inferior_fd, PIXGETTHCOUNT, &ps) < 0) - perror_with_name ("PIXGETTHCOUNT"); - - n_threads = ps.pi_othdcnt; - for (thread = 0; thread < n_threads; thread++) - { - ps.pi_thread = thread; - if (ioctl (inferior_fd, PIXGETSUBCODE, &ps) < 0) - perror_with_name ("PIXGETSUBCODE"); - thread_state[thread] = ps.pi_otstate; - - if (ps.pi_otstate == PI_TALIVE) - { - select_thread (thread); - ps.pi_buffer = registers; - ps.pi_nbytes = REGISTER_BYTES; - ps.pi_offset = 0; - ps.pi_thread = thread; - if (ioctl (inferior_fd, PIXRDREGS, &ps) < 0) - perror_with_name ("PIXRDREGS"); - - registers_fetched (); - - thread_pc[thread] = read_pc (); - thread_signal[thread] = ps.pi_osigno; - thread_sigcode[thread] = ps.pi_osigcode; - - /* If the thread's stack has a context frame - on top, something fucked is going on. I do not - know what, but do I know this: the only thing you - can do with such a thread is continue it. */ - - thread_is_in_kernel[thread] = - ((read_register (PS_REGNUM) >> 25) & 3) == 0; - - /* Signals push an extended frame and then fault - with a ridiculous pc. Pop the frame. */ - - if (thread_pc[thread] > STACK_END_ADDR) - { - POP_FRAME; - if (is_break_pc (thread_pc[thread])) - thread_pc[thread] = read_pc () - 2; - else - thread_pc[thread] = read_pc (); - write_register (PC_REGNUM, thread_pc[thread]); - } - - if (ps.pi_osigno || ps.pi_osigcode) - { - signal_stack++; - signal_stack->pid = pid; - signal_stack->thread = thread; - signal_stack->signo = thread_signal[thread]; - signal_stack->subsig = thread_sigcode[thread]; - signal_stack->pc = thread_pc[thread]; - } - - /* The following hackery is caused by a unix 7.1 feature: - the inferior's fixed scheduling mode is cleared when - it execs the shell (since the shell is not a parallel - program). So, note the 5.4 trap we get when - the shell does its exec, then catch the 5.0 trap - that occurs when the debuggee starts, and set fixed - scheduling mode properly. */ - - if (ps.pi_osigno == 5 && ps.pi_osigcode == 4) - exec_trap_timer = 1; - else - exec_trap_timer--; - - if (ps.pi_osigno == 5 && exec_trap_timer == 0) - set_fixed_scheduling (pid, parallel == 2); - } - } - - if (signal_stack_is_empty ()) - error ("no active threads?!"); - } - - /* Select the thread that stopped, and return *w saying why. */ - - select_thread (signal_stack->thread); - - stop_signal = signal_stack->signo; - stop_sigcode = signal_stack->subsig; - - WSETSTOP (*w, signal_stack->signo); - w->w_thread = signal_stack->thread; - return (signal_stack--)->pid; -} - -/* Select thread THREAD -- its registers, stack, per-thread memory. - This is the only routine that may assign to inferior_thread - or thread_regs[]. */ - -static void -select_thread (thread) - int thread; -{ - if (thread == inferior_thread) - return; - - bcopy (registers, thread_regs[inferior_thread], REGISTER_BYTES); - ps.pi_thread = inferior_thread = thread; - if (have_inferior_p ()) - ioctl (inferior_fd, PISETRWTID, &ps); - bcopy (thread_regs[thread], registers, REGISTER_BYTES); -} - -/* Routine to set or clear a psw bit in the psw and also all psws - saved on the stack. Quits when we get to a frame in which the - saved psw is correct. */ - -static void -scan_stack (bit, val) - long bit, val; -{ - long ps = read_register (PS_REGNUM); - long fp; - if (val ? !(ps & bit) : (ps & bit)) - { - ps ^= bit; - write_register (PS_REGNUM, ps); - - fp = read_register (FP_REGNUM); - while (fp & 0x80000000) - { - ps = read_memory_integer (fp + 4, 4); - if (val ? (ps & bit) : !(ps & bit)) - break; - ps ^= bit; - write_memory (fp + 4, &ps, 4); - fp = read_memory_integer (fp + 8, 4); - } - } -} - -/* Set fixed scheduling (alliant mode) of process PID to ARG (0 or 1). */ - -static void -set_fixed_scheduling (pid, arg) - int arg; -{ - struct pattributes pattr; - getpattr (pid, &pattr); - pattr.pattr_pfixed = arg; - setpattr (pid, &pattr); -} - -void -core_file_command (filename, from_tty) - char *filename; - int from_tty; -{ - int n; - - /* Discard all vestiges of any previous core file - and mark data and stack spaces as empty. */ - - if (corefile) - free (corefile); - corefile = 0; - - if (corechan >= 0) - close (corechan); - corechan = -1; - - data_start = 0; - data_end = 0; - stack_start = STACK_END_ADDR; - stack_end = STACK_END_ADDR; - n_core = 0; - - /* Now, if a new core file was specified, open it and digest it. */ - - if (filename) - { - filename = tilde_expand (filename); - make_cleanup (free, filename); - - if (have_inferior_p ()) - error ("To look at a core file, you must kill the inferior with \"kill\"."); - corechan = open (filename, O_RDONLY, 0); - if (corechan < 0) - perror_with_name (filename); - - if (myread (corechan, &filehdr, sizeof filehdr) < 0) - perror_with_name (filename); - - if (!IS_CORE_SOFF_MAGIC (filehdr.h_magic)) - error ("%s: not a core file.\n", filename); - - if (myread (corechan, &opthdr, filehdr.h_opthdr) < 0) - perror_with_name (filename); - - /* Read through the section headers. - For text, data, etc, record an entry in the core file map. - For context and tcontext, record the file address of - the context blocks. */ - - lseek (corechan, (long) filehdr.h_scnptr, 0); - - n_threads = 0; - for (n = 0; n < filehdr.h_nscns; n++) - { - if (myread (corechan, &scnhdr, sizeof scnhdr) < 0) - perror_with_name (filename); - if ((scnhdr.s_flags & S_TYPMASK) >= S_TEXT - && (scnhdr.s_flags & S_TYPMASK) <= S_COMON) - { - core_map[n_core].mem_addr = scnhdr.s_vaddr; - core_map[n_core].mem_end = scnhdr.s_vaddr + scnhdr.s_size; - core_map[n_core].file_addr = scnhdr.s_scnptr; - core_map[n_core].type = scnhdr.s_flags & S_TYPMASK; - if (core_map[n_core].type != S_TBSS - && core_map[n_core].type != S_TDATA - && core_map[n_core].type != S_TTEXT) - core_map[n_core].thread = -1; - else if (n_core == 0 - || core_map[n_core-1].mem_addr != scnhdr.s_vaddr) - core_map[n_core].thread = 0; - else - core_map[n_core].thread = core_map[n_core-1].thread + 1; - n_core++; - } - else if ((scnhdr.s_flags & S_TYPMASK) == S_CONTEXT) - context_offset = scnhdr.s_scnptr; - else if ((scnhdr.s_flags & S_TYPMASK) == S_TCONTEXT) - tcontext_offset[n_threads++] = scnhdr.s_scnptr; - } - - /* Read the context block, struct user, struct proc, - and the comm regs. */ - - lseek (corechan, context_offset, 0); - if (myread (corechan, &c, sizeof c) < 0) - perror_with_name (filename); - lseek (corechan, c.core_user_p, 0); - if (myread (corechan, &u, sizeof u) < 0) - perror_with_name (filename); - lseek (corechan, c.core_proc_p, 0); - if (myread (corechan, &pr, sizeof pr) < 0) - perror_with_name (filename); - comm_registers = pr.p_creg; - - /* Core file apparently is really there. Make it really exist - for xfer_core_file so we can do read_memory on it. */ - - if (filename[0] == '/') - corefile = savestring (filename, strlen (filename)); - else - corefile = concat (current_directory, "/", filename, NULL); - - printf_filtered ("Program %s ", u.u_comm); - - /* Read the thread registers and fill in the thread_xxx[] data. */ - - for (n = 0; n < n_threads; n++) - { - select_thread (n); - - lseek (corechan, tcontext_offset[n], 0); - if (myread (corechan, &tc, sizeof tc) < 0) - perror_with_name (corefile); - lseek (corechan, tc.core_thread_p, 0); - if (myread (corechan, &th, sizeof th) < 0) - perror_with_name (corefile); - - lseek (corechan, tc.core_syscall_context_p, 0); - if (myread (corechan, registers, REGISTER_BYTES) < 0) - perror_with_name (corefile); - - thread_signal[n] = th.t_cursig; - thread_sigcode[n] = th.t_code; - thread_state[n] = th.t_state; - thread_pc[n] = read_pc (); - - if (thread_pc[n] > STACK_END_ADDR) - { - POP_FRAME; - if (is_break_pc (thread_pc[n])) - thread_pc[n] = read_pc () - 2; - else - thread_pc[n] = read_pc (); - write_register (PC_REGNUM, thread_pc[n]); - } - - printf_filtered ("thread %d received signal %d, %s\n", - n, thread_signal[n], - thread_signal[n] < NSIG - ? sys_siglist[thread_signal[n]] - : "(undocumented)"); - } - - /* Select an interesting thread -- also-rans died with SIGKILL, - so find one that didn't. */ - - for (n = 0; n < n_threads; n++) - if (thread_signal[n] != 0 && thread_signal[n] != SIGKILL) - { - select_thread (n); - stop_signal = thread_signal[n]; - stop_sigcode = thread_sigcode[n]; - break; - } - - core_aouthdr.a_magic = 0; - - flush_cached_frames (); - set_current_frame (create_new_frame (read_register (FP_REGNUM), - read_pc ())); - select_frame (get_current_frame (), 0); - validate_files (); - - print_stack_frame (selected_frame, selected_frame_level, -1); - } - else if (from_tty) - printf_filtered ("No core file now.\n"); -} diff --git a/gdb/convx-opcode.h b/gdb/convx-opcode.h deleted file mode 100644 index 75e6f7c345d..00000000000 --- a/gdb/convx-opcode.h +++ /dev/null @@ -1,1677 +0,0 @@ -/* Include information for instruction dissasembly on the Convex. - Copyright (C) 1989, Free Software Foundation. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#define xxx 0 -#define rrr 1 -#define rr 2 -#define rxr 3 -#define r 4 -#define nops 5 -#define nr 6 -#define pcrel 7 -#define lr 8 -#define rxl 9 -#define rlr 10 -#define rrl 11 -#define iml 12 -#define imr 13 -#define a1r 14 -#define a1l 15 -#define a2r 16 -#define a2l 17 -#define a3 18 -#define a4 19 -#define a5 20 -#define V 1 -#define S 2 -#define VM 3 -#define A 4 -#define VL 5 -#define VS 6 -#define VLS 7 -#define PSW 8 -/* Prevent an error during "make depend". */ -#if !defined (PC) -#define PC 9 -#endif -#define ITR 10 -#define VV 11 -#define ITSR 12 -#define TOC 13 -#define CIR 14 -#define TTR 15 -#define VMU 16 -#define VML 17 -#define ICR 18 -#define TCPU 19 -#define CPUID 20 -#define TID 21 -char *op[] = { - "", - "v0\0v1\0v2\0v3\0v4\0v5\0v6\0v7", - "s0\0s1\0s2\0s3\0s4\0s5\0s6\0s7", - "vm", - "sp\0a1\0a2\0a3\0a4\0a5\0ap\0fp", - "vl", - "vs", - "vls", - "psw", - "pc", - "itr", - "vv", - "itsr", - "toc", - "cir", - "ttr", - "vmu", - "vml", - "icr", - "tcpu", - "cpuid", - "tid", -}; -struct formstr format0[] = { - {0,0,rrr,V,S,S}, /* mov */ - {0,0,rrr,S,S,V}, /* mov */ - {1,1,rrr,V,V,V}, /* merg.t */ - {2,1,rrr,V,V,V}, /* mask.t */ - {1,2,rrr,V,S,V}, /* merg.f */ - {2,2,rrr,V,S,V}, /* mask.f */ - {1,1,rrr,V,S,V}, /* merg.t */ - {2,1,rrr,V,S,V}, /* mask.t */ - {3,3,rrr,V,V,V}, /* mul.s */ - {3,4,rrr,V,V,V}, /* mul.d */ - {4,3,rrr,V,V,V}, /* div.s */ - {4,4,rrr,V,V,V}, /* div.d */ - {3,3,rrr,V,S,V}, /* mul.s */ - {3,4,rrr,V,S,V}, /* mul.d */ - {4,3,rrr,V,S,V}, /* div.s */ - {4,4,rrr,V,S,V}, /* div.d */ - {5,0,rrr,V,V,V}, /* and */ - {6,0,rrr,V,V,V}, /* or */ - {7,0,rrr,V,V,V}, /* xor */ - {8,0,rrr,V,V,V}, /* shf */ - {5,0,rrr,V,S,V}, /* and */ - {6,0,rrr,V,S,V}, /* or */ - {7,0,rrr,V,S,V}, /* xor */ - {8,0,rrr,V,S,V}, /* shf */ - {9,3,rrr,V,V,V}, /* add.s */ - {9,4,rrr,V,V,V}, /* add.d */ - {10,3,rrr,V,V,V}, /* sub.s */ - {10,4,rrr,V,V,V}, /* sub.d */ - {9,3,rrr,V,S,V}, /* add.s */ - {9,4,rrr,V,S,V}, /* add.d */ - {10,3,rrr,V,S,V}, /* sub.s */ - {10,4,rrr,V,S,V}, /* sub.d */ - {9,5,rrr,V,V,V}, /* add.b */ - {9,6,rrr,V,V,V}, /* add.h */ - {9,7,rrr,V,V,V}, /* add.w */ - {9,8,rrr,V,V,V}, /* add.l */ - {9,5,rrr,V,S,V}, /* add.b */ - {9,6,rrr,V,S,V}, /* add.h */ - {9,7,rrr,V,S,V}, /* add.w */ - {9,8,rrr,V,S,V}, /* add.l */ - {10,5,rrr,V,V,V}, /* sub.b */ - {10,6,rrr,V,V,V}, /* sub.h */ - {10,7,rrr,V,V,V}, /* sub.w */ - {10,8,rrr,V,V,V}, /* sub.l */ - {10,5,rrr,V,S,V}, /* sub.b */ - {10,6,rrr,V,S,V}, /* sub.h */ - {10,7,rrr,V,S,V}, /* sub.w */ - {10,8,rrr,V,S,V}, /* sub.l */ - {3,5,rrr,V,V,V}, /* mul.b */ - {3,6,rrr,V,V,V}, /* mul.h */ - {3,7,rrr,V,V,V}, /* mul.w */ - {3,8,rrr,V,V,V}, /* mul.l */ - {3,5,rrr,V,S,V}, /* mul.b */ - {3,6,rrr,V,S,V}, /* mul.h */ - {3,7,rrr,V,S,V}, /* mul.w */ - {3,8,rrr,V,S,V}, /* mul.l */ - {4,5,rrr,V,V,V}, /* div.b */ - {4,6,rrr,V,V,V}, /* div.h */ - {4,7,rrr,V,V,V}, /* div.w */ - {4,8,rrr,V,V,V}, /* div.l */ - {4,5,rrr,V,S,V}, /* div.b */ - {4,6,rrr,V,S,V}, /* div.h */ - {4,7,rrr,V,S,V}, /* div.w */ - {4,8,rrr,V,S,V}, /* div.l */ -}; -struct formstr format1[] = { - {11,0,xxx,0,0,0}, /* exit */ - {12,0,a3,0,0,0}, /* jmp */ - {13,2,a3,0,0,0}, /* jmpi.f */ - {13,1,a3,0,0,0}, /* jmpi.t */ - {14,2,a3,0,0,0}, /* jmpa.f */ - {14,1,a3,0,0,0}, /* jmpa.t */ - {15,2,a3,0,0,0}, /* jmps.f */ - {15,1,a3,0,0,0}, /* jmps.t */ - {16,0,a3,0,0,0}, /* tac */ - {17,0,a1r,A,0,0}, /* ldea */ - {18,8,a1l,VLS,0,0}, /* ld.l */ - {18,9,a1l,VM,0,0}, /* ld.x */ - {19,0,a3,0,0,0}, /* tas */ - {20,0,a3,0,0,0}, /* pshea */ - {21,8,a2l,VLS,0,0}, /* st.l */ - {21,9,a2l,VM,0,0}, /* st.x */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {22,0,a3,0,0,0}, /* call */ - {23,0,a3,0,0,0}, /* calls */ - {24,0,a3,0,0,0}, /* callq */ - {25,0,a1r,A,0,0}, /* pfork */ - {26,5,a2r,S,0,0}, /* ste.b */ - {26,6,a2r,S,0,0}, /* ste.h */ - {26,7,a2r,S,0,0}, /* ste.w */ - {26,8,a2r,S,0,0}, /* ste.l */ - {18,5,a1r,A,0,0}, /* ld.b */ - {18,6,a1r,A,0,0}, /* ld.h */ - {18,7,a1r,A,0,0}, /* ld.w */ - {27,7,a1r,A,0,0}, /* incr.w */ - {21,5,a2r,A,0,0}, /* st.b */ - {21,6,a2r,A,0,0}, /* st.h */ - {21,7,a2r,A,0,0}, /* st.w */ - {27,8,a1r,S,0,0}, /* incr.l */ - {18,5,a1r,S,0,0}, /* ld.b */ - {18,6,a1r,S,0,0}, /* ld.h */ - {18,7,a1r,S,0,0}, /* ld.w */ - {18,8,a1r,S,0,0}, /* ld.l */ - {21,5,a2r,S,0,0}, /* st.b */ - {21,6,a2r,S,0,0}, /* st.h */ - {21,7,a2r,S,0,0}, /* st.w */ - {21,8,a2r,S,0,0}, /* st.l */ - {18,5,a1r,V,0,0}, /* ld.b */ - {18,6,a1r,V,0,0}, /* ld.h */ - {18,7,a1r,V,0,0}, /* ld.w */ - {18,8,a1r,V,0,0}, /* ld.l */ - {21,5,a2r,V,0,0}, /* st.b */ - {21,6,a2r,V,0,0}, /* st.h */ - {21,7,a2r,V,0,0}, /* st.w */ - {21,8,a2r,V,0,0}, /* st.l */ -}; -struct formstr format2[] = { - {28,5,rr,A,A,0}, /* cvtw.b */ - {28,6,rr,A,A,0}, /* cvtw.h */ - {29,7,rr,A,A,0}, /* cvtb.w */ - {30,7,rr,A,A,0}, /* cvth.w */ - {28,5,rr,S,S,0}, /* cvtw.b */ - {28,6,rr,S,S,0}, /* cvtw.h */ - {29,7,rr,S,S,0}, /* cvtb.w */ - {30,7,rr,S,S,0}, /* cvth.w */ - {28,3,rr,S,S,0}, /* cvtw.s */ - {31,7,rr,S,S,0}, /* cvts.w */ - {32,3,rr,S,S,0}, /* cvtd.s */ - {31,4,rr,S,S,0}, /* cvts.d */ - {31,8,rr,S,S,0}, /* cvts.l */ - {32,8,rr,S,S,0}, /* cvtd.l */ - {33,3,rr,S,S,0}, /* cvtl.s */ - {33,4,rr,S,S,0}, /* cvtl.d */ - {34,0,rr,A,A,0}, /* ldpa */ - {8,0,nr,A,0,0}, /* shf */ - {18,6,nr,A,0,0}, /* ld.h */ - {18,7,nr,A,0,0}, /* ld.w */ - {33,7,rr,S,S,0}, /* cvtl.w */ - {28,8,rr,S,S,0}, /* cvtw.l */ - {35,1,rr,S,S,0}, /* plc.t */ - {36,0,rr,S,S,0}, /* tzc */ - {37,6,rr,A,A,0}, /* eq.h */ - {37,7,rr,A,A,0}, /* eq.w */ - {37,6,nr,A,0,0}, /* eq.h */ - {37,7,nr,A,0,0}, /* eq.w */ - {37,5,rr,S,S,0}, /* eq.b */ - {37,6,rr,S,S,0}, /* eq.h */ - {37,7,rr,S,S,0}, /* eq.w */ - {37,8,rr,S,S,0}, /* eq.l */ - {38,6,rr,A,A,0}, /* leu.h */ - {38,7,rr,A,A,0}, /* leu.w */ - {38,6,nr,A,0,0}, /* leu.h */ - {38,7,nr,A,0,0}, /* leu.w */ - {38,5,rr,S,S,0}, /* leu.b */ - {38,6,rr,S,S,0}, /* leu.h */ - {38,7,rr,S,S,0}, /* leu.w */ - {38,8,rr,S,S,0}, /* leu.l */ - {39,6,rr,A,A,0}, /* ltu.h */ - {39,7,rr,A,A,0}, /* ltu.w */ - {39,6,nr,A,0,0}, /* ltu.h */ - {39,7,nr,A,0,0}, /* ltu.w */ - {39,5,rr,S,S,0}, /* ltu.b */ - {39,6,rr,S,S,0}, /* ltu.h */ - {39,7,rr,S,S,0}, /* ltu.w */ - {39,8,rr,S,S,0}, /* ltu.l */ - {40,6,rr,A,A,0}, /* le.h */ - {40,7,rr,A,A,0}, /* le.w */ - {40,6,nr,A,0,0}, /* le.h */ - {40,7,nr,A,0,0}, /* le.w */ - {40,5,rr,S,S,0}, /* le.b */ - {40,6,rr,S,S,0}, /* le.h */ - {40,7,rr,S,S,0}, /* le.w */ - {40,8,rr,S,S,0}, /* le.l */ - {41,6,rr,A,A,0}, /* lt.h */ - {41,7,rr,A,A,0}, /* lt.w */ - {41,6,nr,A,0,0}, /* lt.h */ - {41,7,nr,A,0,0}, /* lt.w */ - {41,5,rr,S,S,0}, /* lt.b */ - {41,6,rr,S,S,0}, /* lt.h */ - {41,7,rr,S,S,0}, /* lt.w */ - {41,8,rr,S,S,0}, /* lt.l */ - {9,7,rr,S,A,0}, /* add.w */ - {8,0,rr,A,A,0}, /* shf */ - {0,0,rr,A,A,0}, /* mov */ - {0,0,rr,S,A,0}, /* mov */ - {0,7,rr,S,S,0}, /* mov.w */ - {8,0,rr,S,S,0}, /* shf */ - {0,0,rr,S,S,0}, /* mov */ - {0,0,rr,A,S,0}, /* mov */ - {5,0,rr,A,A,0}, /* and */ - {6,0,rr,A,A,0}, /* or */ - {7,0,rr,A,A,0}, /* xor */ - {42,0,rr,A,A,0}, /* not */ - {5,0,rr,S,S,0}, /* and */ - {6,0,rr,S,S,0}, /* or */ - {7,0,rr,S,S,0}, /* xor */ - {42,0,rr,S,S,0}, /* not */ - {40,3,rr,S,S,0}, /* le.s */ - {40,4,rr,S,S,0}, /* le.d */ - {41,3,rr,S,S,0}, /* lt.s */ - {41,4,rr,S,S,0}, /* lt.d */ - {9,3,rr,S,S,0}, /* add.s */ - {9,4,rr,S,S,0}, /* add.d */ - {10,3,rr,S,S,0}, /* sub.s */ - {10,4,rr,S,S,0}, /* sub.d */ - {37,3,rr,S,S,0}, /* eq.s */ - {37,4,rr,S,S,0}, /* eq.d */ - {43,6,rr,A,A,0}, /* neg.h */ - {43,7,rr,A,A,0}, /* neg.w */ - {3,3,rr,S,S,0}, /* mul.s */ - {3,4,rr,S,S,0}, /* mul.d */ - {4,3,rr,S,S,0}, /* div.s */ - {4,4,rr,S,S,0}, /* div.d */ - {9,6,rr,A,A,0}, /* add.h */ - {9,7,rr,A,A,0}, /* add.w */ - {9,6,nr,A,0,0}, /* add.h */ - {9,7,nr,A,0,0}, /* add.w */ - {9,5,rr,S,S,0}, /* add.b */ - {9,6,rr,S,S,0}, /* add.h */ - {9,7,rr,S,S,0}, /* add.w */ - {9,8,rr,S,S,0}, /* add.l */ - {10,6,rr,A,A,0}, /* sub.h */ - {10,7,rr,A,A,0}, /* sub.w */ - {10,6,nr,A,0,0}, /* sub.h */ - {10,7,nr,A,0,0}, /* sub.w */ - {10,5,rr,S,S,0}, /* sub.b */ - {10,6,rr,S,S,0}, /* sub.h */ - {10,7,rr,S,S,0}, /* sub.w */ - {10,8,rr,S,S,0}, /* sub.l */ - {3,6,rr,A,A,0}, /* mul.h */ - {3,7,rr,A,A,0}, /* mul.w */ - {3,6,nr,A,0,0}, /* mul.h */ - {3,7,nr,A,0,0}, /* mul.w */ - {3,5,rr,S,S,0}, /* mul.b */ - {3,6,rr,S,S,0}, /* mul.h */ - {3,7,rr,S,S,0}, /* mul.w */ - {3,8,rr,S,S,0}, /* mul.l */ - {4,6,rr,A,A,0}, /* div.h */ - {4,7,rr,A,A,0}, /* div.w */ - {4,6,nr,A,0,0}, /* div.h */ - {4,7,nr,A,0,0}, /* div.w */ - {4,5,rr,S,S,0}, /* div.b */ - {4,6,rr,S,S,0}, /* div.h */ - {4,7,rr,S,S,0}, /* div.w */ - {4,8,rr,S,S,0}, /* div.l */ -}; -struct formstr format3[] = { - {32,3,rr,V,V,0}, /* cvtd.s */ - {31,4,rr,V,V,0}, /* cvts.d */ - {33,4,rr,V,V,0}, /* cvtl.d */ - {32,8,rr,V,V,0}, /* cvtd.l */ - {0,0,rrl,S,S,VM}, /* mov */ - {0,0,rlr,S,VM,S}, /* mov */ - {0,0,0,0,0,0}, - {44,0,rr,S,S,0}, /* lop */ - {36,0,rr,V,V,0}, /* tzc */ - {44,0,rr,V,V,0}, /* lop */ - {0,0,0,0,0,0}, - {42,0,rr,V,V,0}, /* not */ - {8,0,rr,S,V,0}, /* shf */ - {35,1,rr,V,V,0}, /* plc.t */ - {45,2,rr,V,V,0}, /* cprs.f */ - {45,1,rr,V,V,0}, /* cprs.t */ - {37,3,rr,V,V,0}, /* eq.s */ - {37,4,rr,V,V,0}, /* eq.d */ - {43,3,rr,V,V,0}, /* neg.s */ - {43,4,rr,V,V,0}, /* neg.d */ - {37,3,rr,S,V,0}, /* eq.s */ - {37,4,rr,S,V,0}, /* eq.d */ - {43,3,rr,S,S,0}, /* neg.s */ - {43,4,rr,S,S,0}, /* neg.d */ - {40,3,rr,V,V,0}, /* le.s */ - {40,4,rr,V,V,0}, /* le.d */ - {41,3,rr,V,V,0}, /* lt.s */ - {41,4,rr,V,V,0}, /* lt.d */ - {40,3,rr,S,V,0}, /* le.s */ - {40,4,rr,S,V,0}, /* le.d */ - {41,3,rr,S,V,0}, /* lt.s */ - {41,4,rr,S,V,0}, /* lt.d */ - {37,5,rr,V,V,0}, /* eq.b */ - {37,6,rr,V,V,0}, /* eq.h */ - {37,7,rr,V,V,0}, /* eq.w */ - {37,8,rr,V,V,0}, /* eq.l */ - {37,5,rr,S,V,0}, /* eq.b */ - {37,6,rr,S,V,0}, /* eq.h */ - {37,7,rr,S,V,0}, /* eq.w */ - {37,8,rr,S,V,0}, /* eq.l */ - {40,5,rr,V,V,0}, /* le.b */ - {40,6,rr,V,V,0}, /* le.h */ - {40,7,rr,V,V,0}, /* le.w */ - {40,8,rr,V,V,0}, /* le.l */ - {40,5,rr,S,V,0}, /* le.b */ - {40,6,rr,S,V,0}, /* le.h */ - {40,7,rr,S,V,0}, /* le.w */ - {40,8,rr,S,V,0}, /* le.l */ - {41,5,rr,V,V,0}, /* lt.b */ - {41,6,rr,V,V,0}, /* lt.h */ - {41,7,rr,V,V,0}, /* lt.w */ - {41,8,rr,V,V,0}, /* lt.l */ - {41,5,rr,S,V,0}, /* lt.b */ - {41,6,rr,S,V,0}, /* lt.h */ - {41,7,rr,S,V,0}, /* lt.w */ - {41,8,rr,S,V,0}, /* lt.l */ - {43,5,rr,V,V,0}, /* neg.b */ - {43,6,rr,V,V,0}, /* neg.h */ - {43,7,rr,V,V,0}, /* neg.w */ - {43,8,rr,V,V,0}, /* neg.l */ - {43,5,rr,S,S,0}, /* neg.b */ - {43,6,rr,S,S,0}, /* neg.h */ - {43,7,rr,S,S,0}, /* neg.w */ - {43,8,rr,S,S,0}, /* neg.l */ -}; -struct formstr format4[] = { - {46,0,nops,0,0,0}, /* nop */ - {47,0,pcrel,0,0,0}, /* br */ - {48,2,pcrel,0,0,0}, /* bri.f */ - {48,1,pcrel,0,0,0}, /* bri.t */ - {49,2,pcrel,0,0,0}, /* bra.f */ - {49,1,pcrel,0,0,0}, /* bra.t */ - {50,2,pcrel,0,0,0}, /* brs.f */ - {50,1,pcrel,0,0,0}, /* brs.t */ -}; -struct formstr format5[] = { - {51,5,rr,V,V,0}, /* ldvi.b */ - {51,6,rr,V,V,0}, /* ldvi.h */ - {51,7,rr,V,V,0}, /* ldvi.w */ - {51,8,rr,V,V,0}, /* ldvi.l */ - {28,3,rr,V,V,0}, /* cvtw.s */ - {31,7,rr,V,V,0}, /* cvts.w */ - {28,8,rr,V,V,0}, /* cvtw.l */ - {33,7,rr,V,V,0}, /* cvtl.w */ - {52,5,rxr,V,V,0}, /* stvi.b */ - {52,6,rxr,V,V,0}, /* stvi.h */ - {52,7,rxr,V,V,0}, /* stvi.w */ - {52,8,rxr,V,V,0}, /* stvi.l */ - {52,5,rxr,S,V,0}, /* stvi.b */ - {52,6,rxr,S,V,0}, /* stvi.h */ - {52,7,rxr,S,V,0}, /* stvi.w */ - {52,8,rxr,S,V,0}, /* stvi.l */ -}; -struct formstr format6[] = { - {53,0,r,A,0,0}, /* ldsdr */ - {54,0,r,A,0,0}, /* ldkdr */ - {55,3,r,S,0,0}, /* ln.s */ - {55,4,r,S,0,0}, /* ln.d */ - {56,0,nops,0,0,0}, /* patu */ - {57,0,r,A,0,0}, /* pate */ - {58,0,nops,0,0,0}, /* pich */ - {59,0,nops,0,0,0}, /* plch */ - {0,0,lr,PSW,A,0}, /* mov */ - {0,0,rxl,A,PSW,0}, /* mov */ - {0,0,lr,PC,A,0}, /* mov */ - {60,0,r,S,0,0}, /* idle */ - {0,0,lr,ITR,S,0}, /* mov */ - {0,0,rxl,S,ITR,0}, /* mov */ - {0,0,0,0,0,0}, - {0,0,rxl,S,ITSR,0}, /* mov */ - {61,0,nops,0,0,0}, /* rtnq */ - {62,0,nops,0,0,0}, /* cfork */ - {63,0,nops,0,0,0}, /* rtn */ - {64,0,nops,0,0,0}, /* wfork */ - {65,0,nops,0,0,0}, /* join */ - {66,0,nops,0,0,0}, /* rtnc */ - {67,3,r,S,0,0}, /* exp.s */ - {67,4,r,S,0,0}, /* exp.d */ - {68,3,r,S,0,0}, /* sin.s */ - {68,4,r,S,0,0}, /* sin.d */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {69,3,r,S,0,0}, /* cos.s */ - {69,4,r,S,0,0}, /* cos.d */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {70,7,r,A,0,0}, /* psh.w */ - {0,0,0,0,0,0}, - {71,7,r,A,0,0}, /* pop.w */ - {0,0,0,0,0,0}, - {70,7,r,S,0,0}, /* psh.w */ - {70,8,r,S,0,0}, /* psh.l */ - {71,7,r,S,0,0}, /* pop.w */ - {71,8,r,S,0,0}, /* pop.l */ - {72,0,nops,0,0,0}, /* eni */ - {73,0,nops,0,0,0}, /* dsi */ - {74,0,nops,0,0,0}, /* bkpt */ - {75,0,nops,0,0,0}, /* msync */ - {76,0,r,S,0,0}, /* mski */ - {77,0,r,S,0,0}, /* xmti */ - {0,0,rxl,S,VV,0}, /* mov */ - {78,0,nops,0,0,0}, /* tstvv */ - {0,0,lr,VS,A,0}, /* mov */ - {0,0,rxl,A,VS,0}, /* mov */ - {0,0,lr,VL,A,0}, /* mov */ - {0,0,rxl,A,VL,0}, /* mov */ - {0,7,lr,VS,S,0}, /* mov.w */ - {0,7,rxl,S,VS,0}, /* mov.w */ - {0,7,lr,VL,S,0}, /* mov.w */ - {0,7,rxl,S,VL,0}, /* mov.w */ - {79,0,r,A,0,0}, /* diag */ - {80,0,nops,0,0,0}, /* pbkpt */ - {81,3,r,S,0,0}, /* sqrt.s */ - {81,4,r,S,0,0}, /* sqrt.d */ - {82,0,nops,0,0,0}, /* casr */ - {0,0,0,0,0,0}, - {83,3,r,S,0,0}, /* atan.s */ - {83,4,r,S,0,0}, /* atan.d */ -}; -struct formstr format7[] = { - {84,5,r,V,0,0}, /* sum.b */ - {84,6,r,V,0,0}, /* sum.h */ - {84,7,r,V,0,0}, /* sum.w */ - {84,8,r,V,0,0}, /* sum.l */ - {85,0,r,V,0,0}, /* all */ - {86,0,r,V,0,0}, /* any */ - {87,0,r,V,0,0}, /* parity */ - {0,0,0,0,0,0}, - {88,5,r,V,0,0}, /* max.b */ - {88,6,r,V,0,0}, /* max.h */ - {88,7,r,V,0,0}, /* max.w */ - {88,8,r,V,0,0}, /* max.l */ - {89,5,r,V,0,0}, /* min.b */ - {89,6,r,V,0,0}, /* min.h */ - {89,7,r,V,0,0}, /* min.w */ - {89,8,r,V,0,0}, /* min.l */ - {84,3,r,V,0,0}, /* sum.s */ - {84,4,r,V,0,0}, /* sum.d */ - {90,3,r,V,0,0}, /* prod.s */ - {90,4,r,V,0,0}, /* prod.d */ - {88,3,r,V,0,0}, /* max.s */ - {88,4,r,V,0,0}, /* max.d */ - {89,3,r,V,0,0}, /* min.s */ - {89,4,r,V,0,0}, /* min.d */ - {90,5,r,V,0,0}, /* prod.b */ - {90,6,r,V,0,0}, /* prod.h */ - {90,7,r,V,0,0}, /* prod.w */ - {90,8,r,V,0,0}, /* prod.l */ - {35,2,lr,VM,S,0}, /* plc.f */ - {35,1,lr,VM,S,0}, /* plc.t */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, -}; -struct formstr formatx[] = { - {0,0,0,0,0,0}, -}; -struct formstr format1a[] = { - {91,0,imr,A,0,0}, /* halt */ - {92,0,a4,0,0,0}, /* sysc */ - {18,6,imr,A,0,0}, /* ld.h */ - {18,7,imr,A,0,0}, /* ld.w */ - {5,0,imr,A,0,0}, /* and */ - {6,0,imr,A,0,0}, /* or */ - {7,0,imr,A,0,0}, /* xor */ - {8,0,imr,A,0,0}, /* shf */ - {9,6,imr,A,0,0}, /* add.h */ - {9,7,imr,A,0,0}, /* add.w */ - {10,6,imr,A,0,0}, /* sub.h */ - {10,7,imr,A,0,0}, /* sub.w */ - {3,6,imr,A,0,0}, /* mul.h */ - {3,7,imr,A,0,0}, /* mul.w */ - {4,6,imr,A,0,0}, /* div.h */ - {4,7,imr,A,0,0}, /* div.w */ - {18,7,iml,VL,0,0}, /* ld.w */ - {18,7,iml,VS,0,0}, /* ld.w */ - {0,0,0,0,0,0}, - {8,7,imr,S,0,0}, /* shf.w */ - {93,0,a5,0,0,0}, /* trap */ - {0,0,0,0,0,0}, - {37,6,imr,A,0,0}, /* eq.h */ - {37,7,imr,A,0,0}, /* eq.w */ - {38,6,imr,A,0,0}, /* leu.h */ - {38,7,imr,A,0,0}, /* leu.w */ - {39,6,imr,A,0,0}, /* ltu.h */ - {39,7,imr,A,0,0}, /* ltu.w */ - {40,6,imr,A,0,0}, /* le.h */ - {40,7,imr,A,0,0}, /* le.w */ - {41,6,imr,A,0,0}, /* lt.h */ - {41,7,imr,A,0,0}, /* lt.w */ -}; -struct formstr format1b[] = { - {18,4,imr,S,0,0}, /* ld.d */ - {18,10,imr,S,0,0}, /* ld.u */ - {18,8,imr,S,0,0}, /* ld.l */ - {18,7,imr,S,0,0}, /* ld.w */ - {5,0,imr,S,0,0}, /* and */ - {6,0,imr,S,0,0}, /* or */ - {7,0,imr,S,0,0}, /* xor */ - {8,0,imr,S,0,0}, /* shf */ - {9,6,imr,S,0,0}, /* add.h */ - {9,7,imr,S,0,0}, /* add.w */ - {10,6,imr,S,0,0}, /* sub.h */ - {10,7,imr,S,0,0}, /* sub.w */ - {3,6,imr,S,0,0}, /* mul.h */ - {3,7,imr,S,0,0}, /* mul.w */ - {4,6,imr,S,0,0}, /* div.h */ - {4,7,imr,S,0,0}, /* div.w */ - {9,3,imr,S,0,0}, /* add.s */ - {10,3,imr,S,0,0}, /* sub.s */ - {3,3,imr,S,0,0}, /* mul.s */ - {4,3,imr,S,0,0}, /* div.s */ - {40,3,imr,S,0,0}, /* le.s */ - {41,3,imr,S,0,0}, /* lt.s */ - {37,6,imr,S,0,0}, /* eq.h */ - {37,7,imr,S,0,0}, /* eq.w */ - {38,6,imr,S,0,0}, /* leu.h */ - {38,7,imr,S,0,0}, /* leu.w */ - {39,6,imr,S,0,0}, /* ltu.h */ - {39,7,imr,S,0,0}, /* ltu.w */ - {40,6,imr,S,0,0}, /* le.h */ - {40,7,imr,S,0,0}, /* le.w */ - {41,6,imr,S,0,0}, /* lt.h */ - {41,7,imr,S,0,0}, /* lt.w */ -}; -struct formstr e0_format0[] = { - {10,3,rrr,S,V,V}, /* sub.s */ - {10,4,rrr,S,V,V}, /* sub.d */ - {4,3,rrr,S,V,V}, /* div.s */ - {4,4,rrr,S,V,V}, /* div.d */ - {10,11,rrr,S,V,V}, /* sub.s.f */ - {10,12,rrr,S,V,V}, /* sub.d.f */ - {4,11,rrr,S,V,V}, /* div.s.f */ - {4,12,rrr,S,V,V}, /* div.d.f */ - {3,11,rrr,V,V,V}, /* mul.s.f */ - {3,12,rrr,V,V,V}, /* mul.d.f */ - {4,11,rrr,V,V,V}, /* div.s.f */ - {4,12,rrr,V,V,V}, /* div.d.f */ - {3,11,rrr,V,S,V}, /* mul.s.f */ - {3,12,rrr,V,S,V}, /* mul.d.f */ - {4,11,rrr,V,S,V}, /* div.s.f */ - {4,12,rrr,V,S,V}, /* div.d.f */ - {5,2,rrr,V,V,V}, /* and.f */ - {6,2,rrr,V,V,V}, /* or.f */ - {7,2,rrr,V,V,V}, /* xor.f */ - {8,2,rrr,V,V,V}, /* shf.f */ - {5,2,rrr,V,S,V}, /* and.f */ - {6,2,rrr,V,S,V}, /* or.f */ - {7,2,rrr,V,S,V}, /* xor.f */ - {8,2,rrr,V,S,V}, /* shf.f */ - {9,11,rrr,V,V,V}, /* add.s.f */ - {9,12,rrr,V,V,V}, /* add.d.f */ - {10,11,rrr,V,V,V}, /* sub.s.f */ - {10,12,rrr,V,V,V}, /* sub.d.f */ - {9,11,rrr,V,S,V}, /* add.s.f */ - {9,12,rrr,V,S,V}, /* add.d.f */ - {10,11,rrr,V,S,V}, /* sub.s.f */ - {10,12,rrr,V,S,V}, /* sub.d.f */ - {9,13,rrr,V,V,V}, /* add.b.f */ - {9,14,rrr,V,V,V}, /* add.h.f */ - {9,15,rrr,V,V,V}, /* add.w.f */ - {9,16,rrr,V,V,V}, /* add.l.f */ - {9,13,rrr,V,S,V}, /* add.b.f */ - {9,14,rrr,V,S,V}, /* add.h.f */ - {9,15,rrr,V,S,V}, /* add.w.f */ - {9,16,rrr,V,S,V}, /* add.l.f */ - {10,13,rrr,V,V,V}, /* sub.b.f */ - {10,14,rrr,V,V,V}, /* sub.h.f */ - {10,15,rrr,V,V,V}, /* sub.w.f */ - {10,16,rrr,V,V,V}, /* sub.l.f */ - {10,13,rrr,V,S,V}, /* sub.b.f */ - {10,14,rrr,V,S,V}, /* sub.h.f */ - {10,15,rrr,V,S,V}, /* sub.w.f */ - {10,16,rrr,V,S,V}, /* sub.l.f */ - {3,13,rrr,V,V,V}, /* mul.b.f */ - {3,14,rrr,V,V,V}, /* mul.h.f */ - {3,15,rrr,V,V,V}, /* mul.w.f */ - {3,16,rrr,V,V,V}, /* mul.l.f */ - {3,13,rrr,V,S,V}, /* mul.b.f */ - {3,14,rrr,V,S,V}, /* mul.h.f */ - {3,15,rrr,V,S,V}, /* mul.w.f */ - {3,16,rrr,V,S,V}, /* mul.l.f */ - {4,13,rrr,V,V,V}, /* div.b.f */ - {4,14,rrr,V,V,V}, /* div.h.f */ - {4,15,rrr,V,V,V}, /* div.w.f */ - {4,16,rrr,V,V,V}, /* div.l.f */ - {4,13,rrr,V,S,V}, /* div.b.f */ - {4,14,rrr,V,S,V}, /* div.h.f */ - {4,15,rrr,V,S,V}, /* div.w.f */ - {4,16,rrr,V,S,V}, /* div.l.f */ -}; -struct formstr e0_format1[] = { - {0,0,0,0,0,0}, - {94,0,a3,0,0,0}, /* tst */ - {95,0,a3,0,0,0}, /* lck */ - {96,0,a3,0,0,0}, /* ulk */ - {17,0,a1r,S,0,0}, /* ldea */ - {97,0,a1r,A,0,0}, /* spawn */ - {98,0,a1r,A,0,0}, /* ldcmr */ - {99,0,a2r,A,0,0}, /* stcmr */ - {100,0,a1r,A,0,0}, /* popr */ - {101,0,a2r,A,0,0}, /* pshr */ - {102,7,a1r,A,0,0}, /* rcvr.w */ - {103,7,a2r,A,0,0}, /* matm.w */ - {104,7,a2r,A,0,0}, /* sndr.w */ - {104,8,a2r,S,0,0}, /* sndr.l */ - {102,8,a1r,S,0,0}, /* rcvr.l */ - {103,8,a2r,S,0,0}, /* matm.l */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {105,7,a2r,A,0,0}, /* putr.w */ - {105,8,a2r,S,0,0}, /* putr.l */ - {106,7,a1r,A,0,0}, /* getr.w */ - {106,8,a1r,S,0,0}, /* getr.l */ - {26,13,a2r,S,0,0}, /* ste.b.f */ - {26,14,a2r,S,0,0}, /* ste.h.f */ - {26,15,a2r,S,0,0}, /* ste.w.f */ - {26,16,a2r,S,0,0}, /* ste.l.f */ - {107,7,a2r,A,0,0}, /* matr.w */ - {108,7,a2r,A,0,0}, /* mat.w */ - {109,7,a1r,A,0,0}, /* get.w */ - {110,7,a1r,A,0,0}, /* rcv.w */ - {0,0,0,0,0,0}, - {111,7,a1r,A,0,0}, /* inc.w */ - {112,7,a2r,A,0,0}, /* put.w */ - {113,7,a2r,A,0,0}, /* snd.w */ - {107,8,a2r,S,0,0}, /* matr.l */ - {108,8,a2r,S,0,0}, /* mat.l */ - {109,8,a1r,S,0,0}, /* get.l */ - {110,8,a1r,S,0,0}, /* rcv.l */ - {0,0,0,0,0,0}, - {111,8,a1r,S,0,0}, /* inc.l */ - {112,8,a2r,S,0,0}, /* put.l */ - {113,8,a2r,S,0,0}, /* snd.l */ - {18,13,a1r,V,0,0}, /* ld.b.f */ - {18,14,a1r,V,0,0}, /* ld.h.f */ - {18,15,a1r,V,0,0}, /* ld.w.f */ - {18,16,a1r,V,0,0}, /* ld.l.f */ - {21,13,a2r,V,0,0}, /* st.b.f */ - {21,14,a2r,V,0,0}, /* st.h.f */ - {21,15,a2r,V,0,0}, /* st.w.f */ - {21,16,a2r,V,0,0}, /* st.l.f */ -}; -struct formstr e0_format2[] = { - {28,5,rr,V,V,0}, /* cvtw.b */ - {28,6,rr,V,V,0}, /* cvtw.h */ - {29,7,rr,V,V,0}, /* cvtb.w */ - {30,7,rr,V,V,0}, /* cvth.w */ - {28,13,rr,V,V,0}, /* cvtw.b.f */ - {28,14,rr,V,V,0}, /* cvtw.h.f */ - {29,15,rr,V,V,0}, /* cvtb.w.f */ - {30,15,rr,V,V,0}, /* cvth.w.f */ - {31,8,rr,V,V,0}, /* cvts.l */ - {32,7,rr,V,V,0}, /* cvtd.w */ - {33,3,rr,V,V,0}, /* cvtl.s */ - {28,4,rr,V,V,0}, /* cvtw.d */ - {31,16,rr,V,V,0}, /* cvts.l.f */ - {32,15,rr,V,V,0}, /* cvtd.w.f */ - {33,11,rr,V,V,0}, /* cvtl.s.f */ - {28,12,rr,V,V,0}, /* cvtw.d.f */ - {114,0,rr,S,S,0}, /* enal */ - {8,7,rr,S,S,0}, /* shf.w */ - {115,0,rr,S,S,0}, /* enag */ - {0,0,0,0,0,0}, - {28,4,rr,S,S,0}, /* cvtw.d */ - {32,7,rr,S,S,0}, /* cvtd.w */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {116,3,rr,S,S,0}, /* frint.s */ - {116,4,rr,S,S,0}, /* frint.d */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {116,3,rr,V,V,0}, /* frint.s */ - {116,4,rr,V,V,0}, /* frint.d */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {116,11,rr,V,V,0}, /* frint.s.f */ - {116,12,rr,V,V,0}, /* frint.d.f */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {81,3,rr,V,V,0}, /* sqrt.s */ - {81,4,rr,V,V,0}, /* sqrt.d */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {81,11,rr,V,V,0}, /* sqrt.s.f */ - {81,12,rr,V,V,0}, /* sqrt.d.f */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, -}; -struct formstr e0_format3[] = { - {32,11,rr,V,V,0}, /* cvtd.s.f */ - {31,12,rr,V,V,0}, /* cvts.d.f */ - {33,12,rr,V,V,0}, /* cvtl.d.f */ - {32,16,rr,V,V,0}, /* cvtd.l.f */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {36,2,rr,V,V,0}, /* tzc.f */ - {44,2,rr,V,V,0}, /* lop.f */ - {117,2,rr,V,V,0}, /* xpnd.f */ - {42,2,rr,V,V,0}, /* not.f */ - {8,2,rr,S,V,0}, /* shf.f */ - {35,17,rr,V,V,0}, /* plc.t.f */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {37,11,rr,V,V,0}, /* eq.s.f */ - {37,12,rr,V,V,0}, /* eq.d.f */ - {43,11,rr,V,V,0}, /* neg.s.f */ - {43,12,rr,V,V,0}, /* neg.d.f */ - {37,11,rr,S,V,0}, /* eq.s.f */ - {37,12,rr,S,V,0}, /* eq.d.f */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {40,11,rr,V,V,0}, /* le.s.f */ - {40,12,rr,V,V,0}, /* le.d.f */ - {41,11,rr,V,V,0}, /* lt.s.f */ - {41,12,rr,V,V,0}, /* lt.d.f */ - {40,11,rr,S,V,0}, /* le.s.f */ - {40,12,rr,S,V,0}, /* le.d.f */ - {41,11,rr,S,V,0}, /* lt.s.f */ - {41,12,rr,S,V,0}, /* lt.d.f */ - {37,13,rr,V,V,0}, /* eq.b.f */ - {37,14,rr,V,V,0}, /* eq.h.f */ - {37,15,rr,V,V,0}, /* eq.w.f */ - {37,16,rr,V,V,0}, /* eq.l.f */ - {37,13,rr,S,V,0}, /* eq.b.f */ - {37,14,rr,S,V,0}, /* eq.h.f */ - {37,15,rr,S,V,0}, /* eq.w.f */ - {37,16,rr,S,V,0}, /* eq.l.f */ - {40,13,rr,V,V,0}, /* le.b.f */ - {40,14,rr,V,V,0}, /* le.h.f */ - {40,15,rr,V,V,0}, /* le.w.f */ - {40,16,rr,V,V,0}, /* le.l.f */ - {40,13,rr,S,V,0}, /* le.b.f */ - {40,14,rr,S,V,0}, /* le.h.f */ - {40,15,rr,S,V,0}, /* le.w.f */ - {40,16,rr,S,V,0}, /* le.l.f */ - {41,13,rr,V,V,0}, /* lt.b.f */ - {41,14,rr,V,V,0}, /* lt.h.f */ - {41,15,rr,V,V,0}, /* lt.w.f */ - {41,16,rr,V,V,0}, /* lt.l.f */ - {41,13,rr,S,V,0}, /* lt.b.f */ - {41,14,rr,S,V,0}, /* lt.h.f */ - {41,15,rr,S,V,0}, /* lt.w.f */ - {41,16,rr,S,V,0}, /* lt.l.f */ - {43,13,rr,V,V,0}, /* neg.b.f */ - {43,14,rr,V,V,0}, /* neg.h.f */ - {43,15,rr,V,V,0}, /* neg.w.f */ - {43,16,rr,V,V,0}, /* neg.l.f */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, -}; -struct formstr e0_format4[] = { - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, -}; -struct formstr e0_format5[] = { - {51,13,rr,V,V,0}, /* ldvi.b.f */ - {51,14,rr,V,V,0}, /* ldvi.h.f */ - {51,15,rr,V,V,0}, /* ldvi.w.f */ - {51,16,rr,V,V,0}, /* ldvi.l.f */ - {28,11,rr,V,V,0}, /* cvtw.s.f */ - {31,15,rr,V,V,0}, /* cvts.w.f */ - {28,16,rr,V,V,0}, /* cvtw.l.f */ - {33,15,rr,V,V,0}, /* cvtl.w.f */ - {52,13,rxr,V,V,0}, /* stvi.b.f */ - {52,14,rxr,V,V,0}, /* stvi.h.f */ - {52,15,rxr,V,V,0}, /* stvi.w.f */ - {52,16,rxr,V,V,0}, /* stvi.l.f */ - {52,13,rxr,S,V,0}, /* stvi.b.f */ - {52,14,rxr,S,V,0}, /* stvi.h.f */ - {52,15,rxr,S,V,0}, /* stvi.w.f */ - {52,16,rxr,S,V,0}, /* stvi.l.f */ -}; -struct formstr e0_format6[] = { - {0,0,rxl,S,CIR,0}, /* mov */ - {0,0,lr,CIR,S,0}, /* mov */ - {0,0,lr,TOC,S,0}, /* mov */ - {0,0,lr,CPUID,S,0}, /* mov */ - {0,0,rxl,S,TTR,0}, /* mov */ - {0,0,lr,TTR,S,0}, /* mov */ - {118,0,nops,0,0,0}, /* ctrsl */ - {119,0,nops,0,0,0}, /* ctrsg */ - {0,0,rxl,S,VMU,0}, /* mov */ - {0,0,lr,VMU,S,0}, /* mov */ - {0,0,rxl,S,VML,0}, /* mov */ - {0,0,lr,VML,S,0}, /* mov */ - {0,0,rxl,S,ICR,0}, /* mov */ - {0,0,lr,ICR,S,0}, /* mov */ - {0,0,rxl,S,TCPU,0}, /* mov */ - {0,0,lr,TCPU,S,0}, /* mov */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {120,0,nops,0,0,0}, /* stop */ - {0,0,0,0,0,0}, - {0,0,rxl,S,TID,0}, /* mov */ - {0,0,lr,TID,S,0}, /* mov */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, -}; -struct formstr e0_format7[] = { - {84,13,r,V,0,0}, /* sum.b.f */ - {84,14,r,V,0,0}, /* sum.h.f */ - {84,15,r,V,0,0}, /* sum.w.f */ - {84,16,r,V,0,0}, /* sum.l.f */ - {85,2,r,V,0,0}, /* all.f */ - {86,2,r,V,0,0}, /* any.f */ - {87,2,r,V,0,0}, /* parity.f */ - {0,0,0,0,0,0}, - {88,13,r,V,0,0}, /* max.b.f */ - {88,14,r,V,0,0}, /* max.h.f */ - {88,15,r,V,0,0}, /* max.w.f */ - {88,16,r,V,0,0}, /* max.l.f */ - {89,13,r,V,0,0}, /* min.b.f */ - {89,14,r,V,0,0}, /* min.h.f */ - {89,15,r,V,0,0}, /* min.w.f */ - {89,16,r,V,0,0}, /* min.l.f */ - {84,11,r,V,0,0}, /* sum.s.f */ - {84,12,r,V,0,0}, /* sum.d.f */ - {90,11,r,V,0,0}, /* prod.s.f */ - {90,12,r,V,0,0}, /* prod.d.f */ - {88,11,r,V,0,0}, /* max.s.f */ - {88,12,r,V,0,0}, /* max.d.f */ - {89,11,r,V,0,0}, /* min.s.f */ - {89,12,r,V,0,0}, /* min.d.f */ - {90,13,r,V,0,0}, /* prod.b.f */ - {90,14,r,V,0,0}, /* prod.h.f */ - {90,15,r,V,0,0}, /* prod.w.f */ - {90,16,r,V,0,0}, /* prod.l.f */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, -}; -struct formstr e1_format0[] = { - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {10,18,rrr,S,V,V}, /* sub.s.t */ - {10,19,rrr,S,V,V}, /* sub.d.t */ - {4,18,rrr,S,V,V}, /* div.s.t */ - {4,19,rrr,S,V,V}, /* div.d.t */ - {3,18,rrr,V,V,V}, /* mul.s.t */ - {3,19,rrr,V,V,V}, /* mul.d.t */ - {4,18,rrr,V,V,V}, /* div.s.t */ - {4,19,rrr,V,V,V}, /* div.d.t */ - {3,18,rrr,V,S,V}, /* mul.s.t */ - {3,19,rrr,V,S,V}, /* mul.d.t */ - {4,18,rrr,V,S,V}, /* div.s.t */ - {4,19,rrr,V,S,V}, /* div.d.t */ - {5,1,rrr,V,V,V}, /* and.t */ - {6,1,rrr,V,V,V}, /* or.t */ - {7,1,rrr,V,V,V}, /* xor.t */ - {8,1,rrr,V,V,V}, /* shf.t */ - {5,1,rrr,V,S,V}, /* and.t */ - {6,1,rrr,V,S,V}, /* or.t */ - {7,1,rrr,V,S,V}, /* xor.t */ - {8,1,rrr,V,S,V}, /* shf.t */ - {9,18,rrr,V,V,V}, /* add.s.t */ - {9,19,rrr,V,V,V}, /* add.d.t */ - {10,18,rrr,V,V,V}, /* sub.s.t */ - {10,19,rrr,V,V,V}, /* sub.d.t */ - {9,18,rrr,V,S,V}, /* add.s.t */ - {9,19,rrr,V,S,V}, /* add.d.t */ - {10,18,rrr,V,S,V}, /* sub.s.t */ - {10,19,rrr,V,S,V}, /* sub.d.t */ - {9,20,rrr,V,V,V}, /* add.b.t */ - {9,21,rrr,V,V,V}, /* add.h.t */ - {9,22,rrr,V,V,V}, /* add.w.t */ - {9,23,rrr,V,V,V}, /* add.l.t */ - {9,20,rrr,V,S,V}, /* add.b.t */ - {9,21,rrr,V,S,V}, /* add.h.t */ - {9,22,rrr,V,S,V}, /* add.w.t */ - {9,23,rrr,V,S,V}, /* add.l.t */ - {10,20,rrr,V,V,V}, /* sub.b.t */ - {10,21,rrr,V,V,V}, /* sub.h.t */ - {10,22,rrr,V,V,V}, /* sub.w.t */ - {10,23,rrr,V,V,V}, /* sub.l.t */ - {10,20,rrr,V,S,V}, /* sub.b.t */ - {10,21,rrr,V,S,V}, /* sub.h.t */ - {10,22,rrr,V,S,V}, /* sub.w.t */ - {10,23,rrr,V,S,V}, /* sub.l.t */ - {3,20,rrr,V,V,V}, /* mul.b.t */ - {3,21,rrr,V,V,V}, /* mul.h.t */ - {3,22,rrr,V,V,V}, /* mul.w.t */ - {3,23,rrr,V,V,V}, /* mul.l.t */ - {3,20,rrr,V,S,V}, /* mul.b.t */ - {3,21,rrr,V,S,V}, /* mul.h.t */ - {3,22,rrr,V,S,V}, /* mul.w.t */ - {3,23,rrr,V,S,V}, /* mul.l.t */ - {4,20,rrr,V,V,V}, /* div.b.t */ - {4,21,rrr,V,V,V}, /* div.h.t */ - {4,22,rrr,V,V,V}, /* div.w.t */ - {4,23,rrr,V,V,V}, /* div.l.t */ - {4,20,rrr,V,S,V}, /* div.b.t */ - {4,21,rrr,V,S,V}, /* div.h.t */ - {4,22,rrr,V,S,V}, /* div.w.t */ - {4,23,rrr,V,S,V}, /* div.l.t */ -}; -struct formstr e1_format1[] = { - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {26,20,a2r,S,0,0}, /* ste.b.t */ - {26,21,a2r,S,0,0}, /* ste.h.t */ - {26,22,a2r,S,0,0}, /* ste.w.t */ - {26,23,a2r,S,0,0}, /* ste.l.t */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {18,20,a1r,V,0,0}, /* ld.b.t */ - {18,21,a1r,V,0,0}, /* ld.h.t */ - {18,22,a1r,V,0,0}, /* ld.w.t */ - {18,23,a1r,V,0,0}, /* ld.l.t */ - {21,20,a2r,V,0,0}, /* st.b.t */ - {21,21,a2r,V,0,0}, /* st.h.t */ - {21,22,a2r,V,0,0}, /* st.w.t */ - {21,23,a2r,V,0,0}, /* st.l.t */ -}; -struct formstr e1_format2[] = { - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {28,20,rr,V,V,0}, /* cvtw.b.t */ - {28,21,rr,V,V,0}, /* cvtw.h.t */ - {29,22,rr,V,V,0}, /* cvtb.w.t */ - {30,22,rr,V,V,0}, /* cvth.w.t */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {31,23,rr,V,V,0}, /* cvts.l.t */ - {32,22,rr,V,V,0}, /* cvtd.w.t */ - {33,18,rr,V,V,0}, /* cvtl.s.t */ - {28,19,rr,V,V,0}, /* cvtw.d.t */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {116,18,rr,V,V,0}, /* frint.s.t */ - {116,19,rr,V,V,0}, /* frint.d.t */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {81,18,rr,V,V,0}, /* sqrt.s.t */ - {81,19,rr,V,V,0}, /* sqrt.d.t */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, -}; -struct formstr e1_format3[] = { - {32,18,rr,V,V,0}, /* cvtd.s.t */ - {31,19,rr,V,V,0}, /* cvts.d.t */ - {33,19,rr,V,V,0}, /* cvtl.d.t */ - {32,23,rr,V,V,0}, /* cvtd.l.t */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {36,1,rr,V,V,0}, /* tzc.t */ - {44,1,rr,V,V,0}, /* lop.t */ - {117,1,rr,V,V,0}, /* xpnd.t */ - {42,1,rr,V,V,0}, /* not.t */ - {8,1,rr,S,V,0}, /* shf.t */ - {35,24,rr,V,V,0}, /* plc.t.t */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {37,18,rr,V,V,0}, /* eq.s.t */ - {37,19,rr,V,V,0}, /* eq.d.t */ - {43,18,rr,V,V,0}, /* neg.s.t */ - {43,19,rr,V,V,0}, /* neg.d.t */ - {37,18,rr,S,V,0}, /* eq.s.t */ - {37,19,rr,S,V,0}, /* eq.d.t */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {40,18,rr,V,V,0}, /* le.s.t */ - {40,19,rr,V,V,0}, /* le.d.t */ - {41,18,rr,V,V,0}, /* lt.s.t */ - {41,19,rr,V,V,0}, /* lt.d.t */ - {40,18,rr,S,V,0}, /* le.s.t */ - {40,19,rr,S,V,0}, /* le.d.t */ - {41,18,rr,S,V,0}, /* lt.s.t */ - {41,19,rr,S,V,0}, /* lt.d.t */ - {37,20,rr,V,V,0}, /* eq.b.t */ - {37,21,rr,V,V,0}, /* eq.h.t */ - {37,22,rr,V,V,0}, /* eq.w.t */ - {37,23,rr,V,V,0}, /* eq.l.t */ - {37,20,rr,S,V,0}, /* eq.b.t */ - {37,21,rr,S,V,0}, /* eq.h.t */ - {37,22,rr,S,V,0}, /* eq.w.t */ - {37,23,rr,S,V,0}, /* eq.l.t */ - {40,20,rr,V,V,0}, /* le.b.t */ - {40,21,rr,V,V,0}, /* le.h.t */ - {40,22,rr,V,V,0}, /* le.w.t */ - {40,23,rr,V,V,0}, /* le.l.t */ - {40,20,rr,S,V,0}, /* le.b.t */ - {40,21,rr,S,V,0}, /* le.h.t */ - {40,22,rr,S,V,0}, /* le.w.t */ - {40,23,rr,S,V,0}, /* le.l.t */ - {41,20,rr,V,V,0}, /* lt.b.t */ - {41,21,rr,V,V,0}, /* lt.h.t */ - {41,22,rr,V,V,0}, /* lt.w.t */ - {41,23,rr,V,V,0}, /* lt.l.t */ - {41,20,rr,S,V,0}, /* lt.b.t */ - {41,21,rr,S,V,0}, /* lt.h.t */ - {41,22,rr,S,V,0}, /* lt.w.t */ - {41,23,rr,S,V,0}, /* lt.l.t */ - {43,20,rr,V,V,0}, /* neg.b.t */ - {43,21,rr,V,V,0}, /* neg.h.t */ - {43,22,rr,V,V,0}, /* neg.w.t */ - {43,23,rr,V,V,0}, /* neg.l.t */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, -}; -struct formstr e1_format4[] = { - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, -}; -struct formstr e1_format5[] = { - {51,20,rr,V,V,0}, /* ldvi.b.t */ - {51,21,rr,V,V,0}, /* ldvi.h.t */ - {51,22,rr,V,V,0}, /* ldvi.w.t */ - {51,23,rr,V,V,0}, /* ldvi.l.t */ - {28,18,rr,V,V,0}, /* cvtw.s.t */ - {31,22,rr,V,V,0}, /* cvts.w.t */ - {28,23,rr,V,V,0}, /* cvtw.l.t */ - {33,22,rr,V,V,0}, /* cvtl.w.t */ - {52,20,rxr,V,V,0}, /* stvi.b.t */ - {52,21,rxr,V,V,0}, /* stvi.h.t */ - {52,22,rxr,V,V,0}, /* stvi.w.t */ - {52,23,rxr,V,V,0}, /* stvi.l.t */ - {52,20,rxr,S,V,0}, /* stvi.b.t */ - {52,21,rxr,S,V,0}, /* stvi.h.t */ - {52,22,rxr,S,V,0}, /* stvi.w.t */ - {52,23,rxr,S,V,0}, /* stvi.l.t */ -}; -struct formstr e1_format6[] = { - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, -}; -struct formstr e1_format7[] = { - {84,20,r,V,0,0}, /* sum.b.t */ - {84,21,r,V,0,0}, /* sum.h.t */ - {84,22,r,V,0,0}, /* sum.w.t */ - {84,23,r,V,0,0}, /* sum.l.t */ - {85,1,r,V,0,0}, /* all.t */ - {86,1,r,V,0,0}, /* any.t */ - {87,1,r,V,0,0}, /* parity.t */ - {0,0,0,0,0,0}, - {88,20,r,V,0,0}, /* max.b.t */ - {88,21,r,V,0,0}, /* max.h.t */ - {88,22,r,V,0,0}, /* max.w.t */ - {88,23,r,V,0,0}, /* max.l.t */ - {89,20,r,V,0,0}, /* min.b.t */ - {89,21,r,V,0,0}, /* min.h.t */ - {89,22,r,V,0,0}, /* min.w.t */ - {89,23,r,V,0,0}, /* min.l.t */ - {84,18,r,V,0,0}, /* sum.s.t */ - {84,19,r,V,0,0}, /* sum.d.t */ - {90,18,r,V,0,0}, /* prod.s.t */ - {90,19,r,V,0,0}, /* prod.d.t */ - {88,18,r,V,0,0}, /* max.s.t */ - {88,19,r,V,0,0}, /* max.d.t */ - {89,18,r,V,0,0}, /* min.s.t */ - {89,19,r,V,0,0}, /* min.d.t */ - {90,20,r,V,0,0}, /* prod.b.t */ - {90,21,r,V,0,0}, /* prod.h.t */ - {90,22,r,V,0,0}, /* prod.w.t */ - {90,23,r,V,0,0}, /* prod.l.t */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, -}; -char *lop[] = { - "mov", /* 0 */ - "merg", /* 1 */ - "mask", /* 2 */ - "mul", /* 3 */ - "div", /* 4 */ - "and", /* 5 */ - "or", /* 6 */ - "xor", /* 7 */ - "shf", /* 8 */ - "add", /* 9 */ - "sub", /* 10 */ - "exit", /* 11 */ - "jmp", /* 12 */ - "jmpi", /* 13 */ - "jmpa", /* 14 */ - "jmps", /* 15 */ - "tac", /* 16 */ - "ldea", /* 17 */ - "ld", /* 18 */ - "tas", /* 19 */ - "pshea", /* 20 */ - "st", /* 21 */ - "call", /* 22 */ - "calls", /* 23 */ - "callq", /* 24 */ - "pfork", /* 25 */ - "ste", /* 26 */ - "incr", /* 27 */ - "cvtw", /* 28 */ - "cvtb", /* 29 */ - "cvth", /* 30 */ - "cvts", /* 31 */ - "cvtd", /* 32 */ - "cvtl", /* 33 */ - "ldpa", /* 34 */ - "plc", /* 35 */ - "tzc", /* 36 */ - "eq", /* 37 */ - "leu", /* 38 */ - "ltu", /* 39 */ - "le", /* 40 */ - "lt", /* 41 */ - "not", /* 42 */ - "neg", /* 43 */ - "lop", /* 44 */ - "cprs", /* 45 */ - "nop", /* 46 */ - "br", /* 47 */ - "bri", /* 48 */ - "bra", /* 49 */ - "brs", /* 50 */ - "ldvi", /* 51 */ - "stvi", /* 52 */ - "ldsdr", /* 53 */ - "ldkdr", /* 54 */ - "ln", /* 55 */ - "patu", /* 56 */ - "pate", /* 57 */ - "pich", /* 58 */ - "plch", /* 59 */ - "idle", /* 60 */ - "rtnq", /* 61 */ - "cfork", /* 62 */ - "rtn", /* 63 */ - "wfork", /* 64 */ - "join", /* 65 */ - "rtnc", /* 66 */ - "exp", /* 67 */ - "sin", /* 68 */ - "cos", /* 69 */ - "psh", /* 70 */ - "pop", /* 71 */ - "eni", /* 72 */ - "dsi", /* 73 */ - "bkpt", /* 74 */ - "msync", /* 75 */ - "mski", /* 76 */ - "xmti", /* 77 */ - "tstvv", /* 78 */ - "diag", /* 79 */ - "pbkpt", /* 80 */ - "sqrt", /* 81 */ - "casr", /* 82 */ - "atan", /* 83 */ - "sum", /* 84 */ - "all", /* 85 */ - "any", /* 86 */ - "parity", /* 87 */ - "max", /* 88 */ - "min", /* 89 */ - "prod", /* 90 */ - "halt", /* 91 */ - "sysc", /* 92 */ - "trap", /* 93 */ - "tst", /* 94 */ - "lck", /* 95 */ - "ulk", /* 96 */ - "spawn", /* 97 */ - "ldcmr", /* 98 */ - "stcmr", /* 99 */ - "popr", /* 100 */ - "pshr", /* 101 */ - "rcvr", /* 102 */ - "matm", /* 103 */ - "sndr", /* 104 */ - "putr", /* 105 */ - "getr", /* 106 */ - "matr", /* 107 */ - "mat", /* 108 */ - "get", /* 109 */ - "rcv", /* 110 */ - "inc", /* 111 */ - "put", /* 112 */ - "snd", /* 113 */ - "enal", /* 114 */ - "enag", /* 115 */ - "frint", /* 116 */ - "xpnd", /* 117 */ - "ctrsl", /* 118 */ - "ctrsg", /* 119 */ - "stop", /* 120 */ -}; -char *rop[] = { - "", /* 0 */ - ".t", /* 1 */ - ".f", /* 2 */ - ".s", /* 3 */ - ".d", /* 4 */ - ".b", /* 5 */ - ".h", /* 6 */ - ".w", /* 7 */ - ".l", /* 8 */ - ".x", /* 9 */ - ".u", /* 10 */ - ".s.f", /* 11 */ - ".d.f", /* 12 */ - ".b.f", /* 13 */ - ".h.f", /* 14 */ - ".w.f", /* 15 */ - ".l.f", /* 16 */ - ".t.f", /* 17 */ - ".s.t", /* 18 */ - ".d.t", /* 19 */ - ".b.t", /* 20 */ - ".h.t", /* 21 */ - ".w.t", /* 22 */ - ".l.t", /* 23 */ - ".t.t", /* 24 */ -}; diff --git a/gdb/copying.awk b/gdb/copying.awk deleted file mode 100644 index 378d62031ec..00000000000 --- a/gdb/copying.awk +++ /dev/null @@ -1,55 +0,0 @@ -BEGIN { - FS="\""; - print "/* Do not modify this file; it is created automatically"; - print " by copying.awk. */"; - print "#include \"defs.h\"" - print "#include \"command.h\"" - print "extern int immediate_quit;"; - print "static void"; - print "copying_info ()"; - print "{"; - print " immediate_quit++;"; - } -NR == 1,/^[ ]*NO WARRANTY[ ]*$/ { - if (! ($0 ~ /^[ ]*NO WARRANTY[ ]*$/)) - { - printf " printf_filtered (\""; - for (i = 1; i < NF; i++) - printf "%s\\\"", $i; - printf "%s\\n\");\n", $NF; - } - } -/^[ ]*NO WARRANTY[ ]*$/ { - print " immediate_quit--;"; - print "}"; - print ""; - print "static void"; - print "warranty_info ()"; - print "{"; - print " immediate_quit++;"; - } -/^[ ]*NO WARRANTY[ ]*$/, /^[ ]*END OF TERMS AND CONDITIONS[ ]*$/{ - if (! ($0 ~ /^[ ]*END OF TERMS AND CONDITIONS[ ]*$/)) - { - printf " printf_filtered (\""; - for (i = 1; i < NF; i++) - printf "%s\\\"", $i; - printf "%s\\n\");\n", $NF; - } - } -END { - print " immediate_quit--;"; - print "}"; - print ""; - print "void" - print "_initialize_copying ()"; - print "{"; - print " add_info (\"copying\", copying_info,"; - print " \"Conditions for redistributing copies of GDB.\");"; - print " add_info (\"warranty\", warranty_info,"; - print " \"Various kinds of warranty you do not have.\");"; - print "}"; - } - - - diff --git a/gdb/copying.c b/gdb/copying.c deleted file mode 100644 index c31c280c79e..00000000000 --- a/gdb/copying.c +++ /dev/null @@ -1,220 +0,0 @@ -/* Do not modify this file; it is created automatically - by copying.awk. */ -#include "defs.h" -#include "command.h" -#include "gdbcmd.h" -extern int immediate_quit; -static void -show_copying () -{ - immediate_quit++; - printf_filtered ("\n"); - printf_filtered (" GNU GENERAL PUBLIC LICENSE\n"); - printf_filtered (" Version 1, February 1989\n"); - printf_filtered ("\n"); - printf_filtered (" Copyright (C) 1989 Free Software Foundation, Inc.\n"); - printf_filtered (" 675 Mass Ave, Cambridge, MA 02139, USA\n"); - printf_filtered (" Everyone is permitted to copy and distribute verbatim copies\n"); - printf_filtered (" of this license document, but changing it is not allowed.\n"); - printf_filtered ("\n"); - printf_filtered (" Preamble\n"); - printf_filtered ("\n"); - printf_filtered (" The license agreements of most software companies try to keep users\n"); - printf_filtered ("at the mercy of those companies. By contrast, our General Public\n"); - printf_filtered ("License is intended to guarantee your freedom to share and change free\n"); - printf_filtered ("software--to make sure the software is free for all its users. The\n"); - printf_filtered ("General Public License applies to the Free Software Foundation's\n"); - printf_filtered ("software and to any other program whose authors commit to using it.\n"); - printf_filtered ("You can use it for your programs, too.\n"); - printf_filtered ("\n"); - printf_filtered (" When we speak of free software, we are referring to freedom, not\n"); - printf_filtered ("price. Specifically, the General Public License is designed to make\n"); - printf_filtered ("sure that you have the freedom to give away or sell copies of free\n"); - printf_filtered ("software, that you receive source code or can get it if you want it,\n"); - printf_filtered ("that you can change the software or use pieces of it in new free\n"); - printf_filtered ("programs; and that you know you can do these things.\n"); - printf_filtered ("\n"); - printf_filtered (" To protect your rights, we need to make restrictions that forbid\n"); - printf_filtered ("anyone to deny you these rights or to ask you to surrender the rights.\n"); - printf_filtered ("These restrictions translate to certain responsibilities for you if you\n"); - printf_filtered ("distribute copies of the software, or if you modify it.\n"); - printf_filtered ("\n"); - printf_filtered (" For example, if you distribute copies of a such a program, whether\n"); - printf_filtered ("gratis or for a fee, you must give the recipients all the rights that\n"); - printf_filtered ("you have. You must make sure that they, too, receive or can get the\n"); - printf_filtered ("source code. And you must tell them their rights.\n"); - printf_filtered ("\n"); - printf_filtered (" We protect your rights with two steps: (1) copyright the software, and\n"); - printf_filtered ("(2) offer you this license which gives you legal permission to copy,\n"); - printf_filtered ("distribute and/or modify the software.\n"); - printf_filtered ("\n"); - printf_filtered (" Also, for each author's protection and ours, we want to make certain\n"); - printf_filtered ("that everyone understands that there is no warranty for this free\n"); - printf_filtered ("software. If the software is modified by someone else and passed on, we\n"); - printf_filtered ("want its recipients to know that what they have is not the original, so\n"); - printf_filtered ("that any problems introduced by others will not reflect on the original\n"); - printf_filtered ("authors' reputations.\n"); - printf_filtered ("\n"); - printf_filtered (" The precise terms and conditions for copying, distribution and\n"); - printf_filtered ("modification follow.\n"); - printf_filtered (" \n"); - printf_filtered (" GNU GENERAL PUBLIC LICENSE\n"); - printf_filtered (" TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION\n"); - printf_filtered ("\n"); - printf_filtered (" 0. This License Agreement applies to any program or other work which\n"); - printf_filtered ("contains a notice placed by the copyright holder saying it may be\n"); - printf_filtered ("distributed under the terms of this General Public License. The\n"); - printf_filtered ("\"Program\", below, refers to any such program or work, and a \"work based\n"); - printf_filtered ("on the Program\" means either the Program or any work containing the\n"); - printf_filtered ("Program or a portion of it, either verbatim or with modifications. Each\n"); - printf_filtered ("licensee is addressed as \"you\".\n"); - printf_filtered ("\n"); - printf_filtered (" 1. You may copy and distribute verbatim copies of the Program's source\n"); - printf_filtered ("code as you receive it, in any medium, provided that you conspicuously and\n"); - printf_filtered ("appropriately publish on each copy an appropriate copyright notice and\n"); - printf_filtered ("disclaimer of warranty; keep intact all the notices that refer to this\n"); - printf_filtered ("General Public License and to the absence of any warranty; and give any\n"); - printf_filtered ("other recipients of the Program a copy of this General Public License\n"); - printf_filtered ("along with the Program. You may charge a fee for the physical act of\n"); - printf_filtered ("transferring a copy.\n"); - printf_filtered ("\n"); - printf_filtered (" 2. You may modify your copy or copies of the Program or any portion of\n"); - printf_filtered ("it, and copy and distribute such modifications under the terms of Paragraph\n"); - printf_filtered ("1 above, provided that you also do the following:\n"); - printf_filtered ("\n"); - printf_filtered (" a) cause the modified files to carry prominent notices stating that\n"); - printf_filtered (" you changed the files and the date of any change; and\n"); - printf_filtered ("\n"); - printf_filtered (" b) cause the whole of any work that you distribute or publish, that\n"); - printf_filtered (" in whole or in part contains the Program or any part thereof, either\n"); - printf_filtered (" with or without modifications, to be licensed at no charge to all\n"); - printf_filtered (" third parties under the terms of this General Public License (except\n"); - printf_filtered (" that you may choose to grant warranty protection to some or all\n"); - printf_filtered (" third parties, at your option).\n"); - printf_filtered ("\n"); - printf_filtered (" c) If the modified program normally reads commands interactively when\n"); - printf_filtered (" run, you must cause it, when started running for such interactive use\n"); - printf_filtered (" in the simplest and most usual way, to print or display an\n"); - printf_filtered (" announcement including an appropriate copyright notice and a notice\n"); - printf_filtered (" that there is no warranty (or else, saying that you provide a\n"); - printf_filtered (" warranty) and that users may redistribute the program under these\n"); - printf_filtered (" conditions, and telling the user how to view a copy of this General\n"); - printf_filtered (" Public License.\n"); - printf_filtered ("\n"); - printf_filtered (" d) You may charge a fee for the physical act of transferring a\n"); - printf_filtered (" copy, and you may at your option offer warranty protection in\n"); - printf_filtered (" exchange for a fee.\n"); - printf_filtered ("\n"); - printf_filtered ("Mere aggregation of another independent work with the Program (or its\n"); - printf_filtered ("derivative) on a volume of a storage or distribution medium does not bring\n"); - printf_filtered ("the other work under the scope of these terms.\n"); - printf_filtered (" \n"); - printf_filtered (" 3. You may copy and distribute the Program (or a portion or derivative of\n"); - printf_filtered ("it, under Paragraph 2) in object code or executable form under the terms of\n"); - printf_filtered ("Paragraphs 1 and 2 above provided that you also do one of the following:\n"); - printf_filtered ("\n"); - printf_filtered (" a) accompany it with the complete corresponding machine-readable\n"); - printf_filtered (" source code, which must be distributed under the terms of\n"); - printf_filtered (" Paragraphs 1 and 2 above; or,\n"); - printf_filtered ("\n"); - printf_filtered (" b) accompany it with a written offer, valid for at least three\n"); - printf_filtered (" years, to give any third party free (except for a nominal charge\n"); - printf_filtered (" for the cost of distribution) a complete machine-readable copy of the\n"); - printf_filtered (" corresponding source code, to be distributed under the terms of\n"); - printf_filtered (" Paragraphs 1 and 2 above; or,\n"); - printf_filtered ("\n"); - printf_filtered (" c) accompany it with the information you received as to where the\n"); - printf_filtered (" corresponding source code may be obtained. (This alternative is\n"); - printf_filtered (" allowed only for noncommercial distribution and only if you\n"); - printf_filtered (" received the program in object code or executable form alone.)\n"); - printf_filtered ("\n"); - printf_filtered ("Source code for a work means the preferred form of the work for making\n"); - printf_filtered ("modifications to it. For an executable file, complete source code means\n"); - printf_filtered ("all the source code for all modules it contains; but, as a special\n"); - printf_filtered ("exception, it need not include source code for modules which are standard\n"); - printf_filtered ("libraries that accompany the operating system on which the executable\n"); - printf_filtered ("file runs, or for standard header files or definitions files that\n"); - printf_filtered ("accompany that operating system.\n"); - printf_filtered ("\n"); - printf_filtered (" 4. You may not copy, modify, sublicense, distribute or transfer the\n"); - printf_filtered ("Program except as expressly provided under this General Public License.\n"); - printf_filtered ("Any attempt otherwise to copy, modify, sublicense, distribute or transfer\n"); - printf_filtered ("the Program is void, and will automatically terminate your rights to use\n"); - printf_filtered ("the Program under this License. However, parties who have received\n"); - printf_filtered ("copies, or rights to use copies, from you under this General Public\n"); - printf_filtered ("License will not have their licenses terminated so long as such parties\n"); - printf_filtered ("remain in full compliance.\n"); - printf_filtered ("\n"); - printf_filtered (" 5. By copying, distributing or modifying the Program (or any work based\n"); - printf_filtered ("on the Program) you indicate your acceptance of this license to do so,\n"); - printf_filtered ("and all its terms and conditions.\n"); - printf_filtered ("\n"); - printf_filtered (" 6. Each time you redistribute the Program (or any work based on the\n"); - printf_filtered ("Program), the recipient automatically receives a license from the original\n"); - printf_filtered ("licensor to copy, distribute or modify the Program subject to these\n"); - printf_filtered ("terms and conditions. You may not impose any further restrictions on the\n"); - printf_filtered ("recipients' exercise of the rights granted herein.\n"); - printf_filtered (" \n"); - printf_filtered (" 7. The Free Software Foundation may publish revised and/or new versions\n"); - printf_filtered ("of the General Public License from time to time. Such new versions will\n"); - printf_filtered ("be similar in spirit to the present version, but may differ in detail to\n"); - printf_filtered ("address new problems or concerns.\n"); - printf_filtered ("\n"); - printf_filtered ("Each version is given a distinguishing version number. If the Program\n"); - printf_filtered ("specifies a version number of the license which applies to it and \"any\n"); - printf_filtered ("later version\", you have the option of following the terms and conditions\n"); - printf_filtered ("either of that version or of any later version published by the Free\n"); - printf_filtered ("Software Foundation. If the Program does not specify a version number of\n"); - printf_filtered ("the license, you may choose any version ever published by the Free Software\n"); - printf_filtered ("Foundation.\n"); - printf_filtered ("\n"); - printf_filtered (" 8. If you wish to incorporate parts of the Program into other free\n"); - printf_filtered ("programs whose distribution conditions are different, write to the author\n"); - printf_filtered ("to ask for permission. For software which is copyrighted by the Free\n"); - printf_filtered ("Software Foundation, write to the Free Software Foundation; we sometimes\n"); - printf_filtered ("make exceptions for this. Our decision will be guided by the two goals\n"); - printf_filtered ("of preserving the free status of all derivatives of our free software and\n"); - printf_filtered ("of promoting the sharing and reuse of software generally.\n"); - printf_filtered ("\n"); - immediate_quit--; -} - -static void -show_warranty () -{ - immediate_quit++; - printf_filtered (" NO WARRANTY\n"); - printf_filtered ("\n"); - printf_filtered (" 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY\n"); - printf_filtered ("FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN\n"); - printf_filtered ("OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES\n"); - printf_filtered ("PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED\n"); - printf_filtered ("OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n"); - printf_filtered ("MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS\n"); - printf_filtered ("TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE\n"); - printf_filtered ("PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,\n"); - printf_filtered ("REPAIR OR CORRECTION.\n"); - printf_filtered ("\n"); - printf_filtered (" 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\n"); - printf_filtered ("WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR\n"); - printf_filtered ("REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,\n"); - printf_filtered ("INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING\n"); - printf_filtered ("OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED\n"); - printf_filtered ("TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY\n"); - printf_filtered ("YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER\n"); - printf_filtered ("PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE\n"); - printf_filtered ("POSSIBILITY OF SUCH DAMAGES.\n"); - printf_filtered ("\n"); - immediate_quit--; -} - -void -_initialize_copying () -{ - add_cmd ("copying", no_class, show_copying, - "Conditions for redistributing copies of GDB.", - &showlist); - add_cmd ("warranty", no_class, show_warranty, - "Various kinds of warranty you do not have.", - &showlist); -} diff --git a/gdb/core.c b/gdb/core.c deleted file mode 100644 index 8b6895d323c..00000000000 --- a/gdb/core.c +++ /dev/null @@ -1,464 +0,0 @@ -/* Work with core dump and executable files, for GDB. - Copyright (C) 1986, 1987, 1989 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include -#include -#include -#include "defs.h" -#include "param.h" -#include "frame.h" /* required by inferior.h */ -#include "inferior.h" -#include "symtab.h" -#include "command.h" -#include "bfd.h" -#include "target.h" -#include "gdbcore.h" - -extern int xfer_memory (); -extern void child_attach (), child_create_inferior (); - -extern int sys_nerr; -extern char *sys_errlist[]; -extern char *sys_siglist[]; - -extern char registers[]; - -/* Hook for `exec_file_command' command to call. */ - -void (*exec_file_display_hook) () = NULL; - -/* Binary file diddling handle for the core file. */ - -bfd *core_bfd = NULL; - -/* Forward decl */ -extern struct target_ops core_ops; - - -/* Discard all vestiges of any previous core file - and mark data and stack spaces as empty. */ - -/* ARGSUSED */ -void -core_close (quitting) - int quitting; -{ - if (core_bfd) { - free (bfd_get_filename (core_bfd)); - bfd_close (core_bfd); - core_bfd = NULL; -#ifdef CLEAR_SOLIB - CLEAR_SOLIB (); -#endif - if (core_ops.sections) { - free (core_ops.sections); - core_ops.sections = NULL; - core_ops.sections_end = NULL; - } - } -} - -#ifdef SOLIB_ADD -/* Stub function for catch_errors around shared library hacking. */ - -int -solib_add_stub (from_tty) - char *from_tty; -{ - SOLIB_ADD (NULL, (int)from_tty, &core_ops); - return 0; -} -#endif /* SOLIB_ADD */ - -/* This routine opens and sets up the core file bfd */ - -void -core_open (filename, from_tty) - char *filename; - int from_tty; -{ - const char *p; - int siggy; - struct cleanup *old_chain; - char *temp; - bfd *temp_bfd; - int ontop; - int scratch_chan; - - target_preopen (from_tty); - if (!filename) - { - error (core_bfd? - "No core file specified. (Use `detach' to stop debugging a core file.)" - : "No core file specified."); - } - - filename = tilde_expand (filename); - if (filename[0] != '/') { - temp = concat (current_directory, "/", filename, NULL); - free (filename); - filename = temp; - } - - old_chain = make_cleanup (free, filename); - - scratch_chan = open (filename, write_files? O_RDWR: O_RDONLY, 0); - if (scratch_chan < 0) - perror_with_name (filename); - - temp_bfd = bfd_fdopenr (filename, NULL, scratch_chan); - if (temp_bfd == NULL) - { - perror_with_name (filename); - } - - if (!bfd_check_format (temp_bfd, bfd_core)) - { - make_cleanup (bfd_close, temp_bfd); /* Do it after the err msg */ - error ("\"%s\" is not a core dump: %s", filename, bfd_errmsg(bfd_error)); - } - - /* Looks semi-reasonable. Toss the old core file and work on the new. */ - - discard_cleanups (old_chain); /* Don't free filename any more */ - unpush_target (&core_ops); - core_bfd = temp_bfd; - old_chain = make_cleanup (core_close, core_bfd); - - validate_files (); - - /* Find the data section */ - if (build_section_table (core_bfd, &core_ops.sections, - &core_ops.sections_end)) - error ("Can't find sections in `%s': %s", bfd_get_filename(core_bfd), - bfd_errmsg (bfd_error)); - - ontop = !push_target (&core_ops); - discard_cleanups (old_chain); - - p = bfd_core_file_failing_command (core_bfd); - if (p) - printf ("Core was generated by `%s'.\n", p); - - siggy = bfd_core_file_failing_signal (core_bfd); - if (siggy > 0) - printf ("Program terminated with signal %d, %s.\n", siggy, - siggy < NSIG ? sys_siglist[siggy] : "(undocumented)"); - - if (ontop) { - /* Fetch all registers from core file */ - target_fetch_registers (-1); - - /* Add symbols and section mappings for any shared libraries */ -#ifdef SOLIB_ADD - (void) catch_errors (solib_add_stub, (char *)from_tty, (char *)0); -#endif - - /* Now, set up the frame cache, and print the top of stack */ - set_current_frame (create_new_frame (read_register (FP_REGNUM), - read_pc ())); - select_frame (get_current_frame (), 0); - print_stack_frame (selected_frame, selected_frame_level, 1); - } else { - printf ( -"Warning: you won't be able to access this core file until you terminate\n\ -your %s; do ``info files''\n", current_target->to_longname); - } -} - -void -core_detach (args, from_tty) - char *args; - int from_tty; -{ - if (args) - error ("Too many arguments"); - unpush_target (&core_ops); - if (from_tty) - printf ("No core file now.\n"); -} - -/* Backward compatability with old way of specifying core files. */ - -void -core_file_command (filename, from_tty) - char *filename; - int from_tty; -{ - dont_repeat (); /* Either way, seems bogus. */ - if (!filename) - core_detach (filename, from_tty); - else - core_open (filename, from_tty); -} - - -/* Call this to specify the hook for exec_file_command to call back. - This is called from the x-window display code. */ - -void -specify_exec_file_hook (hook) - void (*hook) (); -{ - exec_file_display_hook = hook; -} - -/* The exec file must be closed before running an inferior. - If it is needed again after the inferior dies, it must - be reopened. */ - -void -close_exec_file () -{ -#ifdef FIXME - if (exec_bfd) - bfd_tempclose (exec_bfd); -#endif -} - -void -reopen_exec_file () -{ -#ifdef FIXME - if (exec_bfd) - bfd_reopen (exec_bfd); -#endif -} - -/* If we have both a core file and an exec file, - print a warning if they don't go together. */ - -void -validate_files () -{ - if (exec_bfd && core_bfd) - { - if (!core_file_matches_executable_p (core_bfd, exec_bfd)) - printf ("Warning: core file may not match specified executable file.\n"); - else if (bfd_get_mtime(exec_bfd) > bfd_get_mtime(core_bfd)) - printf ("Warning: exec file is newer than core file.\n"); - } -} - -/* Return the name of the executable file as a string. - ERR nonzero means get error if there is none specified; - otherwise return 0 in that case. */ - -char * -get_exec_file (err) - int err; -{ - if (exec_bfd) return bfd_get_filename(exec_bfd); - if (!err) return NULL; - - error ("No executable file specified.\n\ -Use the \"file\" or \"exec-file\" command."); - return NULL; -} - -static void -core_files_info (t) - struct target_ops *t; -{ - struct section_table *p; - - printf_filtered ("\t`%s', ", bfd_get_filename(core_bfd)); - wrap_here (" "); - printf_filtered ("file type %s.\n", bfd_get_target(core_bfd)); - - for (p = t->sections; p < t->sections_end; p++) { - printf_filtered ("\t%s", local_hex_string_custom (p->addr, "08")); - printf_filtered (" - %s is %s", - local_hex_string_custom (p->endaddr, "08"), - bfd_section_name (p->bfd, p->sec_ptr)); - if (p->bfd != core_bfd) { - printf_filtered (" in %s", bfd_get_filename (p->bfd)); - } - printf_filtered ("\n"); - } -} - -void -memory_error (status, memaddr) - int status; - CORE_ADDR memaddr; -{ - - if (status == EIO) - { - /* Actually, address between memaddr and memaddr + len - was out of bounds. */ - error ("Cannot access memory at address %s.", local_hex_string(memaddr)); - } - else - { - if (status >= sys_nerr || status < 0) - error ("Error accessing memory address %s: unknown error (%d).", - local_hex_string(memaddr), status); - else - error ("Error accessing memory address %s: %s.", - local_hex_string(memaddr), sys_errlist[status]); - } -} - -/* Same as target_read_memory, but report an error if can't read. */ -void -read_memory (memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - int status; - status = target_read_memory (memaddr, myaddr, len); - if (status != 0) - memory_error (status, memaddr); -} - -/* Same as target_write_memory, but report an error if can't write. */ -void -write_memory (memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - int status; - - status = target_write_memory (memaddr, myaddr, len); - if (status != 0) - memory_error (status, memaddr); -} - -/* Read an integer from debugged memory, given address and number of bytes. */ - -long -read_memory_integer (memaddr, len) - CORE_ADDR memaddr; - int len; -{ - char cbuf; - short sbuf; - int ibuf; - long lbuf; - - if (len == sizeof (char)) - { - read_memory (memaddr, &cbuf, len); - return cbuf; - } - if (len == sizeof (short)) - { - read_memory (memaddr, (char *)&sbuf, len); - SWAP_TARGET_AND_HOST (&sbuf, sizeof (short)); - return sbuf; - } - if (len == sizeof (int)) - { - read_memory (memaddr, (char *)&ibuf, len); - SWAP_TARGET_AND_HOST (&ibuf, sizeof (int)); - return ibuf; - } - if (len == sizeof (lbuf)) - { - read_memory (memaddr, (char *)&lbuf, len); - SWAP_TARGET_AND_HOST (&lbuf, sizeof (lbuf)); - return lbuf; - } - error ("Cannot handle integers of %d bytes.", len); - return -1; /* for lint */ -} - -/* Get the registers out of a core file. This is the machine- - independent part. Fetch_core_registers is the machine-dependent - part, typically implemented in the xm-file for each architecture. */ - -/* We just get all the registers, so we don't use regno. */ -/* ARGSUSED */ -static void -get_core_registers (regno) - int regno; -{ - sec_ptr reg_sec; - unsigned size; - char *the_regs; - - reg_sec = bfd_get_section_by_name (core_bfd, ".reg"); - if (!reg_sec) goto cant; - size = bfd_section_size (core_bfd, reg_sec); - the_regs = alloca (size); - if (bfd_get_section_contents (core_bfd, reg_sec, the_regs, (file_ptr)0, size)) - { - fetch_core_registers (the_regs, size, 0, - (unsigned) bfd_section_vma (abfd,reg_sec)); - } - else - { -cant: - fprintf (stderr, "Couldn't fetch registers from core file: %s\n", - bfd_errmsg (bfd_error)); - } - - /* Now do it again for the float registers, if they exist. */ - reg_sec = bfd_get_section_by_name (core_bfd, ".reg2"); - if (reg_sec) { - size = bfd_section_size (core_bfd, reg_sec); - the_regs = alloca (size); - if (bfd_get_section_contents (core_bfd, reg_sec, the_regs, (file_ptr)0, - size)) - { - fetch_core_registers (the_regs, size, 2, - (unsigned) bfd_section_vma (abfd,reg_sec)); - } - else - { - fprintf (stderr, "Couldn't fetch register set 2 from core file: %s\n", - bfd_errmsg (bfd_error)); - } - } - registers_fetched(); -} - -struct target_ops core_ops = { - "core", "Local core dump file", - "Use a core file as a target. Specify the filename of the core file.", - core_open, core_close, - child_attach, core_detach, 0, 0, /* resume, wait */ - get_core_registers, - 0, 0, 0, 0, /* store_regs, prepare_to_store, conv_to, conv_from */ - xfer_memory, core_files_info, - 0, 0, /* core_insert_breakpoint, core_remove_breakpoint, */ - 0, 0, 0, 0, 0, /* terminal stuff */ - 0, 0, 0, 0, /* kill, load, call fn, lookup sym */ - child_create_inferior, 0, /* mourn_inferior */ - core_stratum, 0, /* next */ - 0, 1, 1, 1, 0, /* all mem, mem, stack, regs, exec */ - 0, 0, /* section pointers */ - OPS_MAGIC, /* Always the last thing */ -}; - -void -_initialize_core() -{ - - add_com ("core-file", class_files, core_file_command, - "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."); - add_target (&core_ops); -} diff --git a/gdb/coredep.c b/gdb/coredep.c deleted file mode 100644 index 87be34992aa..00000000000 --- a/gdb/coredep.c +++ /dev/null @@ -1,113 +0,0 @@ -/* Extract registers from a "standard" core file, for GDB. - Copyright (C) 1988-1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* core.c is supposed to be the more machine-independent aspects of this; - this file is more machine-specific. */ - -#include "defs.h" -#include "param.h" -#include "gdbcore.h" -#include - -/* These are needed on various systems to expand REGISTER_U_ADDR. */ -#include -#include -#ifndef USG -#include -#include -#include -#include -#include -#endif - - -/* Extract the register values out of the core file and store - them where `read_register' will find them. - - CORE_REG_SECT points to the register values themselves, read into memory. - CORE_REG_SIZE is the size of that area. - WHICH says which set of registers we are handling (0 = int, 2 = float - on machines where they are discontiguous). - REG_ADDR is the offset from u.u_ar0 to the register values relative to - core_reg_sect. This is used with old-fashioned core files to - locate the registers in a large upage-plus-stack ".reg" section. - Original upage address X is at location core_reg_sect+x+reg_addr. - */ - -void -fetch_core_registers (core_reg_sect, core_reg_size, which, reg_addr) - char *core_reg_sect; - unsigned core_reg_size; - int which; - unsigned reg_addr; -{ - register int regno; - register unsigned int addr; - int bad_reg = -1; - register reg_ptr = -reg_addr; /* Original u.u_ar0 is -reg_addr. */ - - /* If u.u_ar0 was an absolute address in the core file, relativize it now, - so we can use it as an offset into core_reg_sect. When we're done, - "register 0" will be at core_reg_sect+reg_ptr, and we can use - register_addr to offset to the other registers. If this is a modern - core file without a upage, reg_ptr will be zero and this is all a big - NOP. */ - if (reg_ptr > core_reg_size) - reg_ptr -= KERNEL_U_ADDR; - if (reg_ptr > core_reg_size) - fprintf (stderr, "Can't find registers in core file\n"); - - for (regno = 0; regno < NUM_REGS; regno++) - { - addr = register_addr (regno, reg_ptr); - if (addr >= core_reg_size) { - if (bad_reg < 0) - bad_reg = regno; - } else { - supply_register (regno, core_reg_sect + addr); - } - } - if (bad_reg > 0) - { - error ("Register %s not found in core file.", reg_names[bad_reg]); - } -} - - -#ifdef REGISTER_U_ADDR - -/* Return the address in the core dump or inferior of register REGNO. - BLOCKEND is the address of the end of the user structure. */ - -unsigned int -register_addr (regno, blockend) - int regno; - int blockend; -{ - int addr; - - if (regno < 0 || regno >= NUM_REGS) - error ("Invalid register number %d.", regno); - - REGISTER_U_ADDR (addr, blockend, regno); - - return addr; -} - -#endif /* REGISTER_U_ADDR */ diff --git a/gdb/cplus-dem.c b/gdb/cplus-dem.c deleted file mode 100644 index 6800f3ffd32..00000000000 --- a/gdb/cplus-dem.c +++ /dev/null @@ -1,1369 +0,0 @@ -/* Demangler for GNU C++ - Copyright (C) 1989 Free Software Foundation, Inc. - written by James Clark (jjc@jclark.uucp) - - 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* This is for g++ 1.36.1 (November 6 version). It will probably - require changes for any other version. - - Modified for g++ 1.36.2 (November 18 version). - - Modified for g++ 1.90.06 (December 31 version). - - Modified for g++ 1.95.03 (November 13 verison). */ - -/* This file exports one function - - char *cplus_demangle (const char *name, int mode) - - If NAME is a mangled function name produced by GNU C++, then - a pointer to a malloced string giving a C++ representation - of the name will be returned; otherwise NULL will be returned. - It is the caller's responsibility to free the string which - is returned. - - If MODE > 0, then ANSI qualifiers such as `const' and `void' are output. - Otherwise they are not. - If MODE >= 0, parameters are emitted; otherwise not. - - For example, - - cplus_demangle ("foo__1Ai", 0) => "A::foo(int)" - cplus_demangle ("foo__1Ai", 1) => "A::foo(int)" - cplus_demangle ("foo__1Ai", -1) => "A::foo" - - cplus_demangle ("foo__1Afe", 0) => "A::foo(float,...)" - cplus_demangle ("foo__1Afe", 1) => "A::foo(float,...)" - cplus_demangle ("foo__1Afe", -1) => "A::foo" - - This file imports xmalloc and xrealloc, which are like malloc and - realloc except that they generate a fatal error if there is no - available memory. */ - -/* define this if names don't start with _ */ -/* #define nounderscore 1 */ - -#include -#include - -/* GDB-specific, FIXME. */ -#include "defs.h" -#include "param.h" - -#ifdef USG -#include -#include -#else -#include -#define memcpy(s1, s2, n) bcopy ((s2), (s1), (n)) -#define memcmp(s1, s2, n) bcmp ((s2), (s1), (n)) -#define strchr index -#define strrchr rindex -#endif - -/* This is '$' on systems where the assembler can deal with that. - Where the assembler can't, it's '.' (but on many systems '.' is - used for other things). */ -#if !defined (CPLUS_MARKER) -#define CPLUS_MARKER '$' -#endif - -#ifndef __STDC__ -#define const -#endif - -#ifdef __STDC__ -extern char *cplus_demangle (const char *type, int mode); -#else -extern char *cplus_demangle (); -#endif - -#ifdef __STDC__ -/* GDB prototypes these as void* in defs.h, so we better too, at least - as long as we're including defs.h. */ -extern void *xmalloc (int); -extern void *xrealloc (char *, int); -extern void free (void *); -#else -extern char *xmalloc (); -extern char *xrealloc (); -extern void free (); -#endif - -static char **typevec = 0; -static int ntypes = 0; -static int typevec_size = 0; - -const static struct optable { - const char *in; - const char *out; - int ansi; -} optable[] = { - "nw", " new", 1, /* new (1.92, ansi) */ - "dl", " delete", 1, /* new (1.92, ansi) */ - "new", " new", 0, /* old (1.91, and 1.x) */ - "delete", " delete", 0, /* old (1.91, and 1.x) */ - "as", "=", 1, /* ansi */ - "ne", "!=", 1, /* old, ansi */ - "eq", "==", 1, /* old, ansi */ - "ge", ">=", 1, /* old, ansi */ - "gt", ">", 1, /* old, ansi */ - "le", "<=", 1, /* old, ansi */ - "lt", "<", 1, /* old, ansi */ - "plus", "+", 0, /* old */ - "pl", "+", 1, /* ansi */ - "apl", "+=", 1, /* ansi */ - "minus", "-", 0, /* old */ - "mi", "-", 1, /* ansi */ - "ami", "-=", 1, /* ansi */ - "mult", "*", 0, /* old */ - "ml", "*", 1, /* ansi */ - "aml", "*=", 1, /* ansi */ - "convert", "+", 0, /* old (unary +) */ - "negate", "-", 0, /* old (unary -) */ - "trunc_mod", "%", 0, /* old */ - "md", "%", 1, /* ansi */ - "amd", "%=", 1, /* ansi */ - "trunc_div", "/", 0, /* old */ - "dv", "/", 1, /* ansi */ - "adv", "/=", 1, /* ansi */ - "truth_andif", "&&", 0, /* old */ - "aa", "&&", 1, /* ansi */ - "truth_orif", "||", 0, /* old */ - "oo", "||", 1, /* ansi */ - "truth_not", "!", 0, /* old */ - "nt", "!", 1, /* ansi */ - "postincrement", "++", 0, /* old */ - "pp", "++", 1, /* ansi */ - "postdecrement", "--", 0, /* old */ - "mm", "--", 1, /* ansi */ - "bit_ior", "|", 0, /* old */ - "or", "|", 1, /* ansi */ - "aor", "|=", 1, /* ansi */ - "bit_xor", "^", 0, /* old */ - "er", "^", 1, /* ansi */ - "aer", "^=", 1, /* ansi */ - "bit_and", "&", 0, /* old */ - "ad", "&", 1, /* ansi */ - "aad", "&=", 1, /* ansi */ - "bit_not", "~", 0, /* old */ - "co", "~", 1, /* ansi */ - "call", "()", 0, /* old */ - "cl", "()", 1, /* ansi */ - "alshift", "<<", 0, /* old */ - "ls", "<<", 1, /* ansi */ - "als", "<<=", 1, /* ansi */ - "arshift", ">>", 0, /* old */ - "rs", ">>", 1, /* ansi */ - "ars", ">>=", 1, /* ansi */ - "component", "->", 0, /* old */ - "rf", "->", 1, /* ansi */ - "indirect", "*", 0, /* old */ - "method_call", "->()", 0, /* old */ - "addr", "&", 0, /* old (unary &) */ - "array", "[]", 0, /* old */ - "vc", "[]", 1, /* ansi */ - "compound", ",", 0, /* old */ - "cm", ",", 1, /* ansi */ - "cond", "?:", 0, /* old */ - "cn", "?:", 1, /* psuedo-ansi */ - "max", ">?", 0, /* old */ - "mx", ">?", 1, /* psuedo-ansi */ - "min", " 0) -# define print_arg_types (arg_mode >= 0) - - if (type == NULL || *type == '\0') - return NULL; -#ifndef nounderscore - if (*type++ != '_') - return NULL; -#endif - p = type; - while (*p != '\0' && !(*p == '_' && p[1] == '_')) - p++; - if (*p == '\0') - { - /* destructor */ - if (type[0] == '_' && type[1] == CPLUS_MARKER && type[2] == '_') - { - int n = (strlen (type) - 3)*2 + 3 + 2 + 1; - char *tem = (char *) xmalloc (n); - strcpy (tem, type + 3); - strcat (tem, "::~"); - strcat (tem, type + 3); - if (print_arg_types) - strcat (tem, "()"); - return tem; - } - /* static data member */ - if (*type != '_' && (p = strchr (type, CPLUS_MARKER)) != NULL) - { - int n = strlen (type) + 2; - char *tem = (char *) xmalloc (n); - memcpy (tem, type, p - type); - strcpy (tem + (p - type), "::"); - strcpy (tem + (p - type) + 2, p + 1); - return tem; - } - /* virtual table "_vt$" */ - if (type[0] == '_' && type[1] == 'v' && type[2] == 't' && type[3] == CPLUS_MARKER) - { - int n = strlen (type + 4) + 14 + 1; - char *tem = (char *) xmalloc (n); - strcpy (tem, type + 4); - strcat (tem, " virtual table"); - return tem; - } - return NULL; - } - - string_init (&decl); - - if (static_type) - { - if (!isdigit (p[0]) && ('t' != p[0])) - { - string_delete (&decl); - return NULL; - } - } - else if (p == type) - { - if (!isdigit (p[2]) && ('t' != p[2])) - { - p += 1; - while (*p != '\0' && !(*p == '_' && p[1] == '_')) - p++; - string_appendn (&decl, type, p - type); - *(decl.p) = '\0'; - munge_function_name (&decl, 1); - if (decl.b[0] == '_') - { - string_delete (&decl); - return NULL; - } - else - p += 2; - } - else - { - constructor = 1; - p += 2; - } - } - else - { - string_appendn (&decl, type, p - type); - *(decl.p) = '\0'; - munge_function_name (&decl, arg_mode); - p += 2; - } - -#ifndef LONGERNAMES - premangle = p; -#endif - switch (*p) - { - case 'C': - /* a const member function */ - if (!isdigit (p[1])) - { - string_delete (&decl); - return NULL; - } - p += 1; - const_flag = 1; - /* fall through */ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - n = 0; - do - { - n *= 10; - n += *p - '0'; - p += 1; - } - while (isdigit (*p)); - if (strlen (p) < n) - { - string_delete (&decl); - return NULL; - } - if (constructor || destructor) - { - string_appendn (&decl, p, n); - string_append (&decl, "::"); - if (destructor) - string_append(&decl, "~"); - string_appendn (&decl, p, n); - } - else - { - string_prepend (&decl, "::"); - string_prependn (&decl, p, n); - } - p += n; -#ifndef LONGERNAMES - remember_type (premangle, p - premangle); -#endif - if (static_type) - { - string_append(&decl, p+1); - p += strlen(p); - success = 1; - } - else - success = do_args (&p, &decl, arg_mode); - if (const_flag && print_arg_types) - string_append (&decl, " const"); - break; - case 'F': - p += 1; - success = do_args (&p, &decl, arg_mode); - break; - /* template additions */ - case 't': - p += 1; - { - int r, i; - int non_empty = 0; - string tname; - string trawname; - - string temp; - int need_comma = 0; - - string_init(&tname); - string_init(&trawname); - - /* get template name */ - if (!get_count (&p, &r)) - return 0; - string_appendn (&tname, p, r); - string_appendn (&trawname, p, r); - string_appendn (&trawname, "", 1); - p += r; - string_append (&tname, "<"); - /* get size of template parameter list */ - if (!get_count (&p, &r)) - return 0; - for (i = 0; i < r; i++) - { - if (need_comma) - string_append (&tname, ", "); - /* Z for type parameters */ - if (*p == 'Z') - { - p += 1; - - success = do_type (&p, &temp, arg_mode); - string_appendn (&temp, "", 1); - if (success) - string_append (&tname, temp.b); - string_delete(&temp); - if (!success) - break; - } - /* otherwise, value parameter */ - else - { - const char *old_p = p; - int is_pointer = 0; - int is_real = 0; - int is_integral = 0; - int done = 0; - - success = do_type (&p, &temp, arg_mode); - string_appendn (&temp, "", 1); - if (success) - string_append (&tname, temp.b); - string_delete(&temp); - if (!success) - break; - string_append (&tname, "="); - while (*old_p && !done) - { - switch (*old_p) - { - case 'P': - case 'R': - done = is_pointer = 1; - break; - case 'C': /* const */ - case 'U': /* unsigned */ - case 'V': /* volatile */ - case 'F': /* function */ - case 'M': /* member function */ - case 'O': /* ??? */ - old_p++; - continue; - case 'Q': /* repetition of following */ - case 'T': /* remembered type */ - abort(); - break; - case 'v': /* void */ - abort(); - break; - case 'x': /* long long */ - case 'l': /* long */ - case 'i': /* int */ - case 's': /* short */ - case 'c': /* char */ - done = is_integral = 1; - break; - case 'r': /* long double */ - case 'd': /* double */ - case 'f': /* float */ - done = is_real = 1; - break; - default: - abort(); - } - } - if (is_integral) - { - if (*p == 'm') - { - string_appendn (&tname, "-", 1); - p++; - } - while (isdigit (*p)) - { - string_appendn (&tname, p, 1); - p++; - } - } - else if (is_real) - { - if (*p == 'm') - { - string_appendn (&tname, "-", 1); - p++; - } - while (isdigit (*p)) - { - string_appendn (&tname, p, 1); - p++; - } - if (*p == '.') /* fraction */ - { - string_appendn (&tname, ".", 1); - p++; - while (isdigit (*p)) - { - string_appendn (&tname, p, 1); - p++; - } - } - if (*p == 'e') /* exponent */ - { - string_appendn (&tname, "e", 1); - p++; - while (isdigit (*p)) - { - string_appendn (&tname, p, 1); - p++; - } - } - } - else if (is_pointer) - { - int symbol_len; - - if (!get_count (&p, &symbol_len)) - { - success = 0; - break; - } - string_appendn (&tname, p, symbol_len); - p += symbol_len; - } - } - need_comma = 1; - } - string_append (&tname, ">::"); - if (destructor) - string_append(&tname, "~"); - if (constructor || destructor) { - string_append (&tname, trawname.b); - } - string_delete(&trawname); - - if (!success) { - string_delete(&tname); - return 0; - } - string_prepend (&decl, tname.b); - string_delete(&tname); - - if (static_type) - { - string_append(&decl, p+1); - p += strlen(p); - success = 1; - } - else - success = do_args (&p, &decl, arg_mode); - break; - } - } - - for (i = 0; i < ntypes; i++) - if (typevec[i] != NULL) - free (typevec[i]); - ntypes = 0; - if (typevec != NULL) - { - free ((char *)typevec); - typevec = NULL; - typevec_size = 0; - } - - if (success) - { - string_appendn (&decl, "", 1); - return decl.b; - } - else - { - string_delete (&decl); - return NULL; - } -} - -static int -get_count (type, count) - const char **type; - int *count; -{ - if (!isdigit (**type)) - return 0; - *count = **type - '0'; - *type += 1; - /* see flush_repeats in cplus-method.c */ - if (isdigit (**type)) - { - const char *p = *type; - int n = *count; - do - { - n *= 10; - n += *p - '0'; - p += 1; - } - while (isdigit (*p)); - if (*p == '_') - { - *type = p + 1; - *count = n; - } - } - return 1; -} - -/* result will be initialised here; it will be freed on failure */ - -static int -do_type (type, result, arg_mode) - const char **type; - string *result; - int arg_mode; -{ - int n; - int done; - int non_empty = 0; - int success; - string decl; - const char *remembered_type; - - string_init (&decl); - string_init (result); - - done = 0; - success = 1; - while (success && !done) - { - int member; - switch (**type) - { - case 'Q': - n = (*type)[1] - '0'; - if (n < 0 || n > 9) - success = 0; - *type += 2; - while (n-- > 0) - do_type (type, result, arg_mode); - break; - - case 'P': - *type += 1; - string_prepend (&decl, "*"); - break; - - case 'R': - *type += 1; - string_prepend (&decl, "&"); - break; - - case 'T': - *type += 1; - if (!get_count (type, &n) || n >= ntypes) - success = 0; - else - { - remembered_type = typevec[n]; - type = &remembered_type; - } - break; - - case 'F': - *type += 1; - if (!string_empty (&decl) && decl.b[0] == '*') - { - string_prepend (&decl, "("); - string_append (&decl, ")"); - } - if (!do_args (type, &decl, arg_mode) || **type != '_') - success = 0; - else - *type += 1; - break; - - case 'M': - case 'O': - { - int constp = 0; - int volatilep = 0; - - member = **type == 'M'; - *type += 1; - if (!isdigit (**type)) - { - success = 0; - break; - } - n = 0; - do - { - n *= 10; - n += **type - '0'; - *type += 1; - } - while (isdigit (**type)); - if (strlen (*type) < n) - { - success = 0; - break; - } - string_append (&decl, ")"); - string_prepend (&decl, "::"); - string_prependn (&decl, *type, n); - string_prepend (&decl, "("); - *type += n; - if (member) - { - if (**type == 'C') - { - *type += 1; - constp = 1; - } - if (**type == 'V') - { - *type += 1; - volatilep = 1; - } - if (*(*type)++ != 'F') - { - success = 0; - break; - } - } - if ((member && !do_args (type, &decl, arg_mode)) || **type != '_') - { - success = 0; - break; - } - *type += 1; - if (! print_ansi_qualifiers) - break; - if (constp) - { - if (non_empty) - string_append (&decl, " "); - else - non_empty = 1; - string_append (&decl, "const"); - } - if (volatilep) - { - if (non_empty) - string_append (&decl, " "); - else - non_empty = 1; - string_append (&decl, "volatile"); - } - break; - } - - case 'C': - if ((*type)[1] == 'P') - { - *type += 1; - if (print_ansi_qualifiers) - { - if (!string_empty (&decl)) - string_prepend (&decl, " "); - string_prepend (&decl, "const"); - } - break; - } - - /* fall through */ - default: - done = 1; - break; - } - } - - done = 0; - non_empty = 0; - while (success && !done) - { - switch (**type) - { - case 'C': - *type += 1; - if (print_ansi_qualifiers) - { - if (non_empty) - string_append (result, " "); - else - non_empty = 1; - string_append (result, "const"); - } - break; - case 'U': - *type += 1; - if (non_empty) - string_append (result, " "); - else - non_empty = 1; - string_append (result, "unsigned"); - break; - case 'V': - *type += 1; - if (print_ansi_qualifiers) - { - if (non_empty) - string_append (result, " "); - else - non_empty = 1; - string_append (result, "volatile"); - } - break; - default: - done = 1; - break; - } - } - - if (success) - switch (**type) - { - case '\0': - case '_': - break; - case 'v': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "void"); - break; - case 'x': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "long long"); - break; - case 'l': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "long"); - break; - case 'i': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "int"); - break; - case 's': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "short"); - break; - case 'c': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "char"); - break; - case 'r': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "long double"); - break; - case 'd': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "double"); - break; - case 'f': - *type += 1; - if (non_empty) - string_append (result, " "); - string_append (result, "float"); - break; - case 'G': - *type += 1; - if (!isdigit (**type)) - { - success = 0; - break; - } - /* fall through */ - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - n = 0; - do - { - n *= 10; - n += **type - '0'; - *type += 1; - } - while (isdigit (**type)); - if (strlen (*type) < n) - { - success = 0; - break; - } - if (non_empty) - string_append (result, " "); - string_appendn (result, *type, n); - *type += n; - break; - default: - success = 0; - break; - } - - if (success) - { - if (!string_empty (&decl)) - { - string_append (result, " "); - string_appends (result, &decl); - } - string_delete (&decl); - return 1; - } - else - { - string_delete (&decl); - string_delete (result); - return 0; - } -} - -/* `result' will be initialised in do_type; it will be freed on failure */ - -static int -do_arg (type, result, arg_mode) - const char **type; - string *result; - int arg_mode; -{ - const char *start = *type; - - if (!do_type (type, result, arg_mode)) - return 0; - remember_type (start, *type - start); - return 1; -} - -static void -remember_type (start, len) - const char *start; - int len; -{ - char *tem; - - if (ntypes >= typevec_size) - { - if (typevec_size == 0) - { - typevec_size = 3; - typevec = (char **) xmalloc (sizeof (char*)*typevec_size); - } - else - { - typevec_size *= 2; - typevec = (char **) xrealloc ((char *)typevec, sizeof (char*)*typevec_size); - } - } - tem = (char *) xmalloc (len + 1); - memcpy (tem, start, len); - tem[len] = '\0'; - typevec[ntypes++] = tem; -} - -/* `decl' must be already initialised, usually non-empty; - it won't be freed on failure */ - -static int -do_args (type, decl, arg_mode) - const char **type; - string *decl; - int arg_mode; -{ - string arg; - int need_comma = 0; - - if (print_arg_types) - string_append (decl, "("); - - while (**type != '_' && **type != '\0' && **type != 'e' && **type != 'v') - { - if (**type == 'N') - { - int r; - int t; - *type += 1; - if (!get_count (type, &r) || !get_count (type, &t) || t >= ntypes) - return 0; - while (--r >= 0) - { - const char *tem = typevec[t]; - if (need_comma && print_arg_types) - string_append (decl, ", "); - if (!do_arg (&tem, &arg, arg_mode)) - return 0; - if (print_arg_types) - string_appends (decl, &arg); - string_delete (&arg); - need_comma = 1; - } - } - else - { - if (need_comma & print_arg_types) - string_append (decl, ", "); - if (!do_arg (type, &arg, arg_mode)) - return 0; - if (print_arg_types) - string_appends (decl, &arg); - string_delete (&arg); - need_comma = 1; - } - } - - if (**type == 'v') - *type += 1; - else if (**type == 'e') - { - *type += 1; - if (print_arg_types) - { - if (need_comma) - string_append (decl, ","); - string_append (decl, "..."); - } - } - - if (print_arg_types) - string_append (decl, ")"); - return 1; -} - -static void -munge_function_name (name, arg_mode) - string *name; - int arg_mode; -{ - if (string_empty (name)) - return; - - if (name->p - name->b >= 3 - && name->b[0] == 'o' && name->b[1] == 'p' && name->b[2] == CPLUS_MARKER) - { - int i; - /* see if it's an assignment expression */ - if (name->p - name->b >= 10 /* op$assign_ */ - && memcmp (name->b + 3, "assign_", 7) == 0) - { - for (i = 0; i < sizeof (optable)/sizeof (optable[0]); i++) - { - int len = name->p - name->b - 10; - if (strlen (optable[i].in) == len - && memcmp (optable[i].in, name->b + 10, len) == 0) - { - string_clear (name); - string_append (name, "operator"); - string_append (name, optable[i].out); - string_append (name, "="); - return; - } - } - } - else - { - for (i = 0; i < sizeof (optable)/sizeof (optable[0]); i++) - { - int len = name->p - name->b - 3; - if (strlen (optable[i].in) == len - && memcmp (optable[i].in, name->b + 3, len) == 0) - { - string_clear (name); - string_append (name, "operator"); - string_append (name, optable[i].out); - return; - } - } - } - return; - } - else if (name->p - name->b >= 5 && memcmp (name->b, "type$", 5) == 0) - { - /* type conversion operator */ - string type; - const char *tem = name->b + 5; - if (do_type (&tem, &type, arg_mode)) - { - string_clear (name); - string_append (name, "operator "); - string_appends (name, &type); - string_delete (&type); - return; - } - } - /* ANSI. */ - else if (name->b[2] == 'o' && name->b[3] == 'p') - { - /* type conversion operator. */ - string type; - const char *tem = name->b + 4; - if (do_type (&tem, &type, arg_mode)) - { - string_clear (name); - string_append (name, "operator "); - string_appends (name, &type); - string_delete (&type); - return; - } - } - else if (name->b[0] == '_' && name->b[1] == '_' - && name->b[2] >= 'a' && name->b[2] <= 'z' - && name->b[3] >= 'a' && name->b[3] <= 'z') - { - int i; - - if (name->b[4] == '\0') - { - /* Operator. */ - for (i = 0; i < sizeof (optable)/sizeof (optable[0]); i++) - { - if (strlen (optable[i].in) == 2 - && memcmp (optable[i].in, name->b + 2, 2) == 0) - { - string_clear (name); - string_append (name, "operator"); - string_append (name, optable[i].out); - return; - } - } - } - else - { - if (name->b[2] != 'a' || name->b[5] != '\0') - return; - /* Assignment. */ - for (i = 0; i < sizeof (optable)/sizeof (optable[0]); i++) - { - if (strlen (optable[i].in) == 3 - && memcmp (optable[i].in, name->b + 2, 3) == 0) - { - string_clear (name); - string_append (name, "operator"); - string_append (name, optable[i].out); - return; - } - } - } - } -} - -/* a mini string-handling package */ - -static void -string_need (s, n) - string *s; - int n; -{ - if (s->b == NULL) - { - if (n < 32) - n = 32; - s->p = s->b = (char *) xmalloc (n); - s->e = s->b + n; - } - else if (s->e - s->p < n) - { - int tem = s->p - s->b; - n += tem; - n *= 2; - s->b = (char *) xrealloc (s->b, n); - s->p = s->b + tem; - s->e = s->b + n; - } -} - -static void -string_delete (s) - string *s; -{ - if (s->b != NULL) - { - free (s->b); - s->b = s->e = s->p = NULL; - } -} - -static void -string_init (s) - string *s; -{ - s->b = s->p = s->e = NULL; -} - -static void -string_clear (s) - string *s; -{ - s->p = s->b; -} - -static int -string_empty (s) - string *s; -{ - return s->b == s->p; -} - -static void -string_append (p, s) - string *p; - const char *s; -{ - int n; - if (s == NULL || *s == '\0') - return; - n = strlen (s); - string_need (p, n); - memcpy (p->p, s, n); - p->p += n; -} - -static void -string_appends (p, s) - string *p, *s; -{ - int n; - if (s->b == s->p) - return; - n = s->p - s->b; - string_need (p, n); - memcpy (p->p, s->b, n); - p->p += n; -} - -static void -string_appendn (p, s, n) - string *p; - const char *s; - int n; -{ - if (n == 0) - return; - string_need (p, n); - memcpy (p->p, s, n); - p->p += n; -} - -static void -string_prepend (p, s) - string *p; - const char *s; -{ - if (s == NULL || *s == '\0') - return; - string_prependn (p, s, strlen (s)); -} - -#if 0 -static void -string_prepends (p, s) - string *p, *s; -{ - if (s->b == s->p) - return; - string_prependn (p, s->b, s->p - s->b); -} -#endif - -static void -string_prependn (p, s, n) - string *p; - const char *s; - int n; -{ - char *q; - - if (n == 0) - return; - string_need (p, n); - for (q = p->p - 1; q >= p->b; q--) - q[n] = q[0]; - memcpy (p->b, s, n); - p->p += n; -} diff --git a/gdb/createtags b/gdb/createtags deleted file mode 100755 index 6f02ff23f70..00000000000 --- a/gdb/createtags +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh -# -# Here we check to see if we are compiling in a directory that contains -# symlinks to the source files instead of the actual files. If this is so, -# we setup the TAGS entries to point to the actual source directory. -# -filelist="" -if test "`find main.c -type l -print `" != "" ; then - prefix=`ls -l main.c | awk '{print $11}' | sed 's;main.c$;;'` -else - prefix="" -fi - -# Replace .o at end of filename with .c -for i in $@ ; do - file=`echo $i-x- | sed -e 's/\.o-x-/\.c-x-/' | sed -e 's/-x-//'` - filelist="$filelist $prefix$file" -done - -etags $filelist diff --git a/gdb/dbxread.c b/gdb/dbxread.c deleted file mode 100644 index c7741abe98c..00000000000 --- a/gdb/dbxread.c +++ /dev/null @@ -1,2847 +0,0 @@ -/* Read dbx symbol tables and convert to internal format, for GDB. - Copyright (C) 1986-1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* This module provides three functions: dbx_symfile_init, - which initializes to read a symbol file; dbx_new_init, which - discards existing cached information when all symbols are being - discarded; and dbx_symfile_read, which reads a symbol table - from a file. - - dbx_symfile_read only does the minimum work necessary for letting the - user "name" things symbolically; it does not read the entire symtab. - Instead, it reads the external and static symbols and puts them in partial - symbol tables. When more extensive information is requested of a - file, the corresponding partial symbol table is mutated into a full - fledged symbol table by going back and reading the symbols - for real. dbx_psymtab_to_symtab() is the function that does this */ - -#include -#include -#include "defs.h" -#include "param.h" - -#ifdef USG -#include -#include -#define L_SET 0 -#define L_INCR 1 -#endif - -#include -#include -#include -#include -#include -#include "symtab.h" -#include "breakpoint.h" -#include "command.h" -#include "target.h" -#include "gdbcore.h" /* for bfd stuff */ -#include "libaout.h" /* FIXME Secret internal BFD stuff for a.out */ -#include "symfile.h" -#include "buildsym.h" - -#include "aout64.h" -#include "stab.gnu.h" /* We always use GNU stabs, not native, now */ - -/* Information is passed among various dbxread routines for accessing - symbol files. A pointer to this structure is kept in the sym_private - field of the struct sym_fns passed in by symfile.h. */ - -struct dbx_symfile_info { - asection *text_sect; /* Text section accessor */ - int symcount; /* How many symbols are there in the file */ - char *stringtab; /* The actual string table */ - int stringtab_size; /* Its size */ - off_t symtab_offset; /* Offset in file to symbol table */ - int desc; /* File descriptor of symbol file */ -}; - - -/* Each partial symbol table entry contains a pointer to private data for the - read_symtab() function to use when expanding a partial symbol table entry - to a full symbol table entry. - - For dbxread this structure contains the offset within the file symbol table - of first local symbol for this file, and length (in bytes) of the section - of the symbol table devoted to this file's symbols (actually, the section - bracketed may contain more than just this file's symbols). If ldsymlen is - 0, the only reason for this thing's existence is the dependency list. - Nothing else will happen when it is read in. */ - -#define LDSYMOFF(p) (((struct symloc *)((p)->read_symtab_private))->ldsymoff) -#define LDSYMLEN(p) (((struct symloc *)((p)->read_symtab_private))->ldsymlen) - -struct symloc { - int ldsymoff; - int ldsymlen; -}; - -extern void qsort (); -extern double atof (); - -/* Forward declarations */ - -static void read_dbx_symtab (); -static void init_psymbol_list (); -static void process_one_symbol (); -static struct symbol *define_symbol (); -void start_subfile (); -int hashname (); -static struct pending *copy_pending (); -static struct symtab *read_ofile_symtab (); -static void dbx_psymtab_to_symtab (); - -static const char vptr_name[] = { '_','v','p','t','r',CPLUS_MARKER,'\0' }; -static const char vb_name[] = { '_','v','b',CPLUS_MARKER,'\0' }; - -/* Macro to determine which symbols to ignore when reading the first symbol - of a file. Some machines override this definition. */ -#ifndef IGNORE_SYMBOL -/* This code is used on Ultrix systems. Ignore it */ -#define IGNORE_SYMBOL(type) (type == (int)N_NSYMS) -#endif - -/* Macro for name of symbol to indicate a file compiled with gcc. */ -#ifndef GCC_COMPILED_FLAG_SYMBOL -#define GCC_COMPILED_FLAG_SYMBOL "gcc_compiled." -#endif - -/* Define this as 1 if a pcc declaration of a char or short argument - gives the correct address. Otherwise assume pcc gives the - address of the corresponding int, which is not the same on a - big-endian machine. */ - -#ifndef BELIEVE_PCC_PROMOTION -#define BELIEVE_PCC_PROMOTION 0 -#endif - -/* Nonzero means give verbose info on gdb action. From main.c. */ -extern int info_verbose; - -/* The BFD for this file -- only good while we're actively reading - symbols into a psymtab or a symtab. */ - -static bfd *symfile_bfd; - -/* String table for the main symbol file. It is kept in memory - permanently, to speed up symbol reading. Other files' symbol tables - are read in on demand. FIXME, this should be cleaner. */ - -static char *symfile_string_table; -static int symfile_string_table_size; - -/* The size of each symbol in the symbol file (in external form). - This is set by dbx_symfile_read when building psymtabs, and by - dbx_psymtab_to_symtab when building symtabs. */ - -static unsigned symbol_size; - -/* Complaints about the symbols we have encountered. */ - -struct complaint lbrac_complaint = - {"bad block start address patched", 0, 0}; - -struct complaint string_table_offset_complaint = - {"bad string table offset in symbol %d", 0, 0}; - -struct complaint unknown_symtype_complaint = - {"unknown symbol type %s", 0, 0}; - -struct complaint lbrac_rbrac_complaint = - {"block start larger than block end", 0, 0}; - -/* During initial symbol readin, we need to have a structure to keep - track of which psymtabs have which bincls in them. This structure - is used during readin to setup the list of dependencies within each - partial symbol table. */ - -struct header_file_location -{ - char *name; /* Name of header file */ - int instance; /* See above */ - struct partial_symtab *pst; /* Partial symtab that has the - BINCL/EINCL defs for this file */ -}; - -/* The actual list and controling variables */ -static struct header_file_location *bincl_list, *next_bincl; -static int bincls_allocated; - -/* When a header file is getting special overriding definitions - for one source file, record here the header_files index - of its normal definition vector. - At other times, this is -1. */ - -static int header_file_prev_index; - -/* Free up old header file tables, and allocate new ones. - We're reading a new symbol file now. */ - -void -free_and_init_header_files () -{ - register int i; - for (i = 0; i < n_header_files; i++) - free (header_files[i].name); - if (header_files) /* First time null */ - free (header_files); - if (this_object_header_files) /* First time null */ - free (this_object_header_files); - - n_allocated_header_files = 10; - header_files = (struct header_file *) xmalloc (10 * sizeof (struct header_file)); - n_header_files = 0; - - n_allocated_this_object_header_files = 10; - this_object_header_files = (int *) xmalloc (10 * sizeof (int)); -} - -/* Called at the start of each object file's symbols. - Clear out the mapping of header file numbers to header files. */ - -void -new_object_header_files () -{ - /* Leave FILENUM of 0 free for builtin types and this file's types. */ - n_this_object_header_files = 1; - header_file_prev_index = -1; -} - -/* Add header file number I for this object file - at the next successive FILENUM. */ - -static void -add_this_object_header_file (i) - int i; -{ - if (n_this_object_header_files == n_allocated_this_object_header_files) - { - n_allocated_this_object_header_files *= 2; - this_object_header_files - = (int *) xrealloc (this_object_header_files, - n_allocated_this_object_header_files * sizeof (int)); - } - - this_object_header_files[n_this_object_header_files++] = i; -} - -/* Add to this file an "old" header file, one already seen in - a previous object file. NAME is the header file's name. - INSTANCE is its instance code, to select among multiple - symbol tables for the same header file. */ - -static void -add_old_header_file (name, instance) - char *name; - int instance; -{ - register struct header_file *p = header_files; - register int i; - - for (i = 0; i < n_header_files; i++) - if (!strcmp (p[i].name, name) && instance == p[i].instance) - { - add_this_object_header_file (i); - return; - } - error ("Invalid symbol data: \"repeated\" header file that hasn't been seen before, at symtab pos %d.", - symnum); -} - -/* Add to this file a "new" header file: definitions for its types follow. - NAME is the header file's name. - Most often this happens only once for each distinct header file, - but not necessarily. If it happens more than once, INSTANCE has - a different value each time, and references to the header file - use INSTANCE values to select among them. - - dbx output contains "begin" and "end" markers for each new header file, - but at this level we just need to know which files there have been; - so we record the file when its "begin" is seen and ignore the "end". */ - -static void -add_new_header_file (name, instance) - char *name; - int instance; -{ - register int i; - header_file_prev_index = -1; - - /* Make sure there is room for one more header file. */ - - if (n_header_files == n_allocated_header_files) - { - n_allocated_header_files *= 2; - header_files = (struct header_file *) - xrealloc (header_files, - (n_allocated_header_files - * sizeof (struct header_file))); - } - - /* Create an entry for this header file. */ - - i = n_header_files++; - header_files[i].name = savestring (name, strlen(name)); - header_files[i].instance = instance; - header_files[i].length = 10; - header_files[i].vector - = (struct type **) xmalloc (10 * sizeof (struct type *)); - bzero (header_files[i].vector, 10 * sizeof (struct type *)); - - add_this_object_header_file (i); -} - -#if 0 -static struct type ** -explicit_lookup_type (real_filenum, index) - int real_filenum, index; -{ - register struct header_file *f = &header_files[real_filenum]; - - if (index >= f->length) - { - f->length *= 2; - f->vector = (struct type **) - xrealloc (f->vector, f->length * sizeof (struct type *)); - bzero (&f->vector[f->length / 2], - f->length * sizeof (struct type *) / 2); - } - return &f->vector[index]; -} -#endif - -/* Handle the N_BINCL and N_EINCL symbol types - that act like N_SOL for switching source files - (different subfiles, as we call them) within one object file, - but using a stack rather than in an arbitrary order. */ - -struct subfile_stack -{ - struct subfile_stack *next; - char *name; - int prev_index; -}; - -struct subfile_stack *subfile_stack; - -static void -push_subfile () -{ - register struct subfile_stack *tem - = (struct subfile_stack *) xmalloc (sizeof (struct subfile_stack)); - - tem->next = subfile_stack; - subfile_stack = tem; - if (current_subfile == 0 || current_subfile->name == 0) - abort (); - tem->name = current_subfile->name; - tem->prev_index = header_file_prev_index; -} - -static char * -pop_subfile () -{ - register char *name; - register struct subfile_stack *link = subfile_stack; - - if (link == 0) - abort (); - - name = link->name; - subfile_stack = link->next; - header_file_prev_index = link->prev_index; - free (link); - - return name; -} - -static void -record_misc_function (name, address, type) - char *name; - CORE_ADDR address; - int type; -{ - enum misc_function_type misc_type; - - switch (type &~ N_EXT) { - case N_TEXT: misc_type = mf_text; break; - case N_DATA: misc_type = mf_data; break; - case N_BSS: misc_type = mf_bss; break; - case N_ABS: misc_type = mf_abs; break; -#ifdef N_SETV - case N_SETV: misc_type = mf_data; break; -#endif - default: misc_type = mf_unknown; break; - } - - prim_record_misc_function (obsavestring (name, strlen (name)), - address, misc_type); -} - -/* Scan and build partial symbols for a symbol file. - We have been initialized by a call to dbx_symfile_init, which - put all the relevant info into a "struct dbx_symfile_info" - hung off the struct sym_fns SF. - - ADDR is the address relative to which the symbols in it are (e.g. - the base address of the text segment). - MAINLINE is true if we are reading the main symbol - table (as opposed to a shared lib or dynamically loaded file). */ - -static void -dbx_symfile_read (sf, addr, mainline) - struct sym_fns *sf; - CORE_ADDR addr; - int mainline; /* FIXME comments above */ -{ - struct dbx_symfile_info *info = (struct dbx_symfile_info *) (sf->sym_private); - bfd *sym_bfd = sf->sym_bfd; - int val; - char *filename = bfd_get_filename (sym_bfd); - - val = lseek (info->desc, info->symtab_offset, L_SET); - if (val < 0) - perror_with_name (filename); - - /* If mainline, set global string table pointers, and reinitialize global - partial symbol list. */ - if (mainline) { - symfile_string_table = info->stringtab; - symfile_string_table_size = info->stringtab_size; - } - - /* If we are reinitializing, or if we have never loaded syms yet, init */ - if (mainline || global_psymbols.size == 0 || static_psymbols.size == 0) - init_psymbol_list (info->symcount); - - symfile_bfd = sym_bfd; /* Kludge for SWAP_SYMBOL */ - - /* FIXME POKING INSIDE BFD DATA STRUCTURES */ - symbol_size = obj_symbol_entry_size (sym_bfd); - - pending_blocks = 0; - make_cleanup (really_free_pendings, 0); - - init_misc_bunches (); - make_cleanup (discard_misc_bunches, 0); - - /* Now that the symbol table data of the executable file are all in core, - process them and define symbols accordingly. */ - - read_dbx_symtab (filename, - addr - bfd_section_vma (sym_bfd, info->text_sect), /*offset*/ - info->desc, info->stringtab, info->stringtab_size, - info->symcount, - bfd_section_vma (sym_bfd, info->text_sect), - bfd_section_size (sym_bfd, info->text_sect)); - - /* Go over the misc symbol bunches and install them in vector. */ - - condense_misc_bunches (!mainline); - - /* Free up any memory we allocated for ourselves. */ - - if (!mainline) { - free (info->stringtab); /* Stringtab is only saved for mainline */ - } - free (info); - sf->sym_private = 0; /* Zap pointer to our (now gone) info struct */ - - if (!partial_symtab_list) { - wrap_here (""); - printf_filtered ("(no debugging symbols found)..."); - wrap_here (""); - } -} - -/* Initialize anything that needs initializing when a completely new - symbol file is specified (not just adding some symbols from another - file, e.g. a shared library). */ - -static void -dbx_new_init () -{ - buildsym_new_init (); - - /* Don't put these on the cleanup chain; they need to stick around - until the next call to dbx_new_init. *Then* we'll free them. */ - if (symfile_string_table) - { - free (symfile_string_table); - symfile_string_table = 0; - symfile_string_table_size = 0; - } - free_and_init_header_files (); -} - - -/* dbx_symfile_init () - is the dbx-specific initialization routine for reading symbols. - It is passed a struct sym_fns which contains, among other things, - the BFD for the file whose symbols are being read, and a slot for a pointer - to "private data" which we fill with goodies. - - We read the string table into malloc'd space and stash a pointer to it. - - Since BFD doesn't know how to read debug symbols in a format-independent - way (and may never do so...), we have to do it ourselves. We will never - be called unless this is an a.out (or very similar) file. - FIXME, there should be a cleaner peephole into the BFD environment here. */ - -static void -dbx_symfile_init (sf) - struct sym_fns *sf; -{ - int val; - int desc; - struct stat statbuf; - bfd *sym_bfd = sf->sym_bfd; - char *name = bfd_get_filename (sym_bfd); - struct dbx_symfile_info *info; - unsigned char size_temp[4]; - - /* Allocate struct to keep track of the symfile */ - sf->sym_private = xmalloc (sizeof (*info)); - info = (struct dbx_symfile_info *)sf->sym_private; - - /* FIXME POKING INSIDE BFD DATA STRUCTURES */ - desc = fileno ((FILE *)(sym_bfd->iostream)); /* Raw file descriptor */ -#define STRING_TABLE_OFFSET (sym_bfd->origin + obj_str_filepos (sym_bfd)) -#define SYMBOL_TABLE_OFFSET (sym_bfd->origin + obj_sym_filepos (sym_bfd)) - /* FIXME POKING INSIDE BFD DATA STRUCTURES */ - - info->desc = desc; - info->text_sect = bfd_get_section_by_name (sym_bfd, ".text"); - if (!info->text_sect) - abort(); - info->symcount = bfd_get_symcount (sym_bfd); - - /* Read the string table size and check it for bogosity. */ - val = lseek (desc, STRING_TABLE_OFFSET, L_SET); - if (val < 0) - perror_with_name (name); - if (fstat (desc, &statbuf) == -1) - perror_with_name (name); - - val = myread (desc, size_temp, sizeof (long)); - if (val < 0) - perror_with_name (name); - info->stringtab_size = bfd_h_get_32 (sym_bfd, size_temp); - - if (info->stringtab_size >= 0 && info->stringtab_size < statbuf.st_size) - { - info->stringtab = (char *) xmalloc (info->stringtab_size); - /* Caller is responsible for freeing the string table. No cleanup. */ - } - else - info->stringtab = NULL; - if (info->stringtab == NULL && info->stringtab_size != 0) - error ("ridiculous string table size: %d bytes", info->stringtab_size); - - /* Now read in the string table in one big gulp. */ - - val = lseek (desc, STRING_TABLE_OFFSET, L_SET); - if (val < 0) - perror_with_name (name); - val = myread (desc, info->stringtab, info->stringtab_size); - if (val < 0) - perror_with_name (name); - - /* Record the position of the symbol table for later use. */ - - info->symtab_offset = SYMBOL_TABLE_OFFSET; -} - -/* Buffer for reading the symbol table entries. */ -static struct internal_nlist symbuf[4096]; -static int symbuf_idx; -static int symbuf_end; - -/* I/O descriptor for reading the symbol table. */ -static int symtab_input_desc; - -/* The address in memory of the string table of the object file we are - reading (which might not be the "main" object file, but might be a - shared library or some other dynamically loaded thing). This is set - by read_dbx_symtab when building psymtabs, and by read_ofile_symtab - when building symtabs, and is used only by next_symbol_text. */ -static char *stringtab_global; - -/* Refill the symbol table input buffer - and set the variables that control fetching entries from it. - Reports an error if no data available. - This function can read past the end of the symbol table - (into the string table) but this does no harm. */ - -static int -fill_symbuf () -{ - int nbytes = myread (symtab_input_desc, symbuf, sizeof (symbuf)); - if (nbytes < 0) - perror_with_name (""); - else if (nbytes == 0) - error ("Premature end of file reading symbol table"); - symbuf_end = nbytes / symbol_size; - symbuf_idx = 0; - return 1; -} - -#define SWAP_SYMBOL(symp) \ - { \ - (symp)->n_strx = bfd_h_get_32(symfile_bfd, \ - (unsigned char *)&(symp)->n_strx); \ - (symp)->n_desc = bfd_h_get_16 (symfile_bfd, \ - (unsigned char *)&(symp)->n_desc); \ - (symp)->n_value = bfd_h_get_32 (symfile_bfd, \ - (unsigned char *)&(symp)->n_value); \ - } - -/* Invariant: The symbol pointed to by symbuf_idx is the first one - that hasn't been swapped. Swap the symbol at the same time - that symbuf_idx is incremented. */ - -/* dbx allows the text of a symbol name to be continued into the - next symbol name! When such a continuation is encountered - (a \ at the end of the text of a name) - call this function to get the continuation. */ - -char * -next_symbol_text () -{ - if (symbuf_idx == symbuf_end) - fill_symbuf (); - symnum++; - SWAP_SYMBOL(&symbuf[symbuf_idx]); - return symbuf[symbuf_idx++].n_strx + stringtab_global; -} - -/* Initializes storage for all of the partial symbols that will be - created by read_dbx_symtab and subsidiaries. */ - -static void -init_psymbol_list (total_symbols) - int total_symbols; -{ - /* Free any previously allocated psymbol lists. */ - if (global_psymbols.list) - free (global_psymbols.list); - if (static_psymbols.list) - free (static_psymbols.list); - - /* Current best guess is that there are approximately a twentieth - of the total symbols (in a debugging file) are global or static - oriented symbols */ - global_psymbols.size = total_symbols / 10; - static_psymbols.size = total_symbols / 10; - global_psymbols.next = global_psymbols.list = (struct partial_symbol *) - xmalloc (global_psymbols.size * sizeof (struct partial_symbol)); - static_psymbols.next = static_psymbols.list = (struct partial_symbol *) - xmalloc (static_psymbols.size * sizeof (struct partial_symbol)); -} - -/* Initialize the list of bincls to contain none and have some - allocated. */ - -static void -init_bincl_list (number) - int number; -{ - bincls_allocated = number; - next_bincl = bincl_list = (struct header_file_location *) - xmalloc (bincls_allocated * sizeof(struct header_file_location)); -} - -/* Add a bincl to the list. */ - -static void -add_bincl_to_list (pst, name, instance) - struct partial_symtab *pst; - char *name; - int instance; -{ - if (next_bincl >= bincl_list + bincls_allocated) - { - int offset = next_bincl - bincl_list; - bincls_allocated *= 2; - bincl_list = (struct header_file_location *) - xrealloc ((char *)bincl_list, - bincls_allocated * sizeof (struct header_file_location)); - next_bincl = bincl_list + offset; - } - next_bincl->pst = pst; - next_bincl->instance = instance; - next_bincl++->name = name; -} - -/* Given a name, value pair, find the corresponding - bincl in the list. Return the partial symtab associated - with that header_file_location. */ - -static struct partial_symtab * -find_corresponding_bincl_psymtab (name, instance) - char *name; - int instance; -{ - struct header_file_location *bincl; - - for (bincl = bincl_list; bincl < next_bincl; bincl++) - if (bincl->instance == instance - && !strcmp (name, bincl->name)) - return bincl->pst; - - return (struct partial_symtab *) 0; -} - -/* Free the storage allocated for the bincl list. */ - -static void -free_bincl_list () -{ - free (bincl_list); - bincls_allocated = 0; -} - -static struct partial_symtab *start_psymtab (); -static void end_psymtab(); - -#ifdef DEBUG -/* This is normally a macro defined in read_dbx_symtab, but this - is a lot easier to debug. */ - -ADD_PSYMBOL_TO_PLIST(NAME, NAMELENGTH, NAMESPACE, CLASS, PLIST, VALUE) - char *NAME; - int NAMELENGTH; - enum namespace NAMESPACE; - enum address_class CLASS; - struct psymbol_allocation_list *PLIST; - unsigned long VALUE; -{ - register struct partial_symbol *psym; - -#define LIST *PLIST - do { - if ((LIST).next >= - (LIST).list + (LIST).size) - { - (LIST).list = (struct partial_symbol *) - xrealloc ((LIST).list, - ((LIST).size * 2 - * sizeof (struct partial_symbol))); - /* Next assumes we only went one over. Should be good if - program works correctly */ - (LIST).next = - (LIST).list + (LIST).size; - (LIST).size *= 2; - } - psym = (LIST).next++; -#undef LIST - - SYMBOL_NAME (psym) = (char *) obstack_alloc (psymbol_obstack, - (NAMELENGTH) + 1); - strncpy (SYMBOL_NAME (psym), (NAME), (NAMELENGTH)); - SYMBOL_NAME (psym)[(NAMELENGTH)] = '\0'; - SYMBOL_NAMESPACE (psym) = (NAMESPACE); - SYMBOL_CLASS (psym) = (CLASS); - SYMBOL_VALUE (psym) = (VALUE); - } while (0); -} - -/* Since one arg is a struct, we have to pass in a ptr and deref it (sigh) */ -#define ADD_PSYMBOL_TO_LIST(NAME, NAMELENGTH, NAMESPACE, CLASS, LIST, VALUE) \ - ADD_PSYMBOL_TO_PLIST(NAME, NAMELENGTH, NAMESPACE, CLASS, &LIST, VALUE) - -#endif /* DEBUG */ - -/* Given pointers to an a.out symbol table in core containing dbx - style data, setup partial_symtab's describing each source file for - which debugging information is available. NLISTLEN is the number - of symbols in the symbol table. All symbol names are given as - offsets relative to STRINGTAB. STRINGTAB_SIZE is the size of - STRINGTAB. SYMFILE_NAME is the name of the file we are reading from - and ADDR is its relocated address (if incremental) or 0 (if not). */ - -static void -read_dbx_symtab (symfile_name, addr, - desc, stringtab, stringtab_size, nlistlen, - text_addr, text_size) - char *symfile_name; - CORE_ADDR addr; - int desc; - register char *stringtab; - register long stringtab_size; - register int nlistlen; - CORE_ADDR text_addr; - int text_size; -{ - register struct internal_nlist *bufp; - register char *namestring; - register struct partial_symbol *psym; - int nsl; - int past_first_source_file = 0; - CORE_ADDR last_o_file_start = 0; - struct cleanup *old_chain; - char *p; - - /* End of the text segment of the executable file. */ - CORE_ADDR end_of_text_addr; - - /* Current partial symtab */ - struct partial_symtab *pst; - - /* List of current psymtab's include files */ - char **psymtab_include_list; - int includes_allocated; - int includes_used; - - /* Index within current psymtab dependency list */ - struct partial_symtab **dependency_list; - int dependencies_used, dependencies_allocated; - - stringtab_global = stringtab; - - pst = (struct partial_symtab *) 0; - - includes_allocated = 30; - includes_used = 0; - psymtab_include_list = (char **) alloca (includes_allocated * - sizeof (char *)); - - dependencies_allocated = 30; - dependencies_used = 0; - dependency_list = - (struct partial_symtab **) alloca (dependencies_allocated * - sizeof (struct partial_symtab *)); - - /* FIXME!! If an error occurs, this blows away the whole symbol table! - It should only blow away the psymtabs created herein. We could - be reading a shared library or a dynloaded file! */ - old_chain = make_cleanup (free_all_psymtabs, 0); - - /* Init bincl list */ - init_bincl_list (20); - make_cleanup (free_bincl_list, 0); - - last_source_file = 0; - -#ifdef END_OF_TEXT_DEFAULT - end_of_text_addr = END_OF_TEXT_DEFAULT; -#else - end_of_text_addr = text_addr + addr + text_size; /* Relocate */ -#endif - - symtab_input_desc = desc; /* This is needed for fill_symbuf below */ - symbuf_end = symbuf_idx = 0; - - for (symnum = 0; symnum < nlistlen; symnum++) - { - /* Get the symbol for this run and pull out some info */ - QUIT; /* allow this to be interruptable */ - if (symbuf_idx == symbuf_end) - fill_symbuf (); - bufp = &symbuf[symbuf_idx++]; - - /* - * Special case to speed up readin. - */ - if (bufp->n_type == (unsigned char)N_SLINE) continue; - - SWAP_SYMBOL (bufp); - - /* Ok. There is a lot of code duplicated in the rest of this - switch statement (for efficiency reasons). Since I don't - like duplicating code, I will do my penance here, and - describe the code which is duplicated: - - *) The assignment to namestring. - *) The call to strchr. - *) The addition of a partial symbol the the two partial - symbol lists. This last is a large section of code, so - I've imbedded it in the following macro. - */ - -/* Set namestring based on bufp. If the string table index is invalid, - give a fake name, and print a single error message per symbol file read, - rather than abort the symbol reading or flood the user with messages. */ -#define SET_NAMESTRING()\ - if (bufp->n_strx < 0 || bufp->n_strx >= stringtab_size) { \ - complain (&string_table_offset_complaint, symnum); \ - namestring = "foo"; \ - } else \ - namestring = bufp->n_strx + stringtab - -/* Add a symbol with an integer value to a psymtab. */ -/* This is a macro unless we're debugging. See above this function. */ -#ifndef DEBUG -# define ADD_PSYMBOL_TO_LIST(NAME, NAMELENGTH, NAMESPACE, CLASS, LIST, VALUE) \ - ADD_PSYMBOL_VT_TO_LIST(NAME, NAMELENGTH, NAMESPACE, CLASS, LIST, VALUE, \ - SYMBOL_VALUE) -#endif /* DEBUG */ - -/* Add a symbol with a CORE_ADDR value to a psymtab. */ -#define ADD_PSYMBOL_ADDR_TO_LIST(NAME, NAMELENGTH, NAMESPACE, CLASS, LIST, VALUE) \ - ADD_PSYMBOL_VT_TO_LIST(NAME, NAMELENGTH, NAMESPACE, CLASS, LIST, VALUE, \ - SYMBOL_VALUE_ADDRESS) - -/* Add any kind of symbol to a psymtab. */ -#define ADD_PSYMBOL_VT_TO_LIST(NAME, NAMELENGTH, NAMESPACE, CLASS, LIST, VALUE, VT)\ - do { \ - if ((LIST).next >= \ - (LIST).list + (LIST).size) \ - { \ - (LIST).list = (struct partial_symbol *) \ - xrealloc ((LIST).list, \ - ((LIST).size * 2 \ - * sizeof (struct partial_symbol))); \ - /* Next assumes we only went one over. Should be good if \ - program works correctly */ \ - (LIST).next = \ - (LIST).list + (LIST).size; \ - (LIST).size *= 2; \ - } \ - psym = (LIST).next++; \ - \ - SYMBOL_NAME (psym) = (char *) obstack_alloc (psymbol_obstack, \ - (NAMELENGTH) + 1); \ - strncpy (SYMBOL_NAME (psym), (NAME), (NAMELENGTH)); \ - SYMBOL_NAME (psym)[(NAMELENGTH)] = '\0'; \ - SYMBOL_NAMESPACE (psym) = (NAMESPACE); \ - SYMBOL_CLASS (psym) = (CLASS); \ - VT (psym) = (VALUE); \ - } while (0); - -/* End of macro definitions, now let's handle them symbols! */ - - switch (bufp->n_type) - { - /* - * Standard, external, non-debugger, symbols - */ - - case N_TEXT | N_EXT: - case N_NBTEXT | N_EXT: - case N_NBDATA | N_EXT: - case N_NBBSS | N_EXT: - case N_SETV | N_EXT: - case N_ABS | N_EXT: - case N_DATA | N_EXT: - case N_BSS | N_EXT: - - bufp->n_value += addr; /* Relocate */ - - SET_NAMESTRING(); - - bss_ext_symbol: - record_misc_function (namestring, bufp->n_value, - bufp->n_type); /* Always */ - - continue; - - /* Standard, local, non-debugger, symbols */ - - case N_NBTEXT: - - /* We need to be able to deal with both N_FN or N_TEXT, - because we have no way of knowing whether the sys-supplied ld - or GNU ld was used to make the executable. Sequents throw - in another wrinkle -- they renumbered N_FN. */ - case N_FN: - case N_FN_SEQ: - case N_TEXT: - bufp->n_value += addr; /* Relocate */ - SET_NAMESTRING(); - if ((namestring[0] == '-' && namestring[1] == 'l') - || (namestring [(nsl = strlen (namestring)) - 1] == 'o' - && namestring [nsl - 2] == '.')) - { - if (entry_point < bufp->n_value - && entry_point >= last_o_file_start - && addr == 0) /* FIXME nogood nomore */ - { - startup_file_start = last_o_file_start; - startup_file_end = bufp->n_value; - } - if (past_first_source_file && pst - /* The gould NP1 uses low values for .o and -l symbols - which are not the address. */ - && bufp->n_value > pst->textlow) - { - end_psymtab (pst, psymtab_include_list, includes_used, - symnum * symbol_size, bufp->n_value, - dependency_list, dependencies_used, - global_psymbols.next, static_psymbols.next); - pst = (struct partial_symtab *) 0; - includes_used = 0; - dependencies_used = 0; - } - else - past_first_source_file = 1; - last_o_file_start = bufp->n_value; - } - continue; - - case N_DATA: - bufp->n_value += addr; /* Relocate */ - SET_NAMESTRING (); - /* Check for __DYNAMIC, which is used by Sun shared libraries. - Record it even if it's local, not global, so we can find it. - Same with virtual function tables, both global and static. */ - if ((namestring[8] == 'C' && (strcmp ("__DYNAMIC", namestring) == 0)) - || VTBL_PREFIX_P ((namestring+HASH_OFFSET))) - { - /* Not really a function here, but... */ - record_misc_function (namestring, bufp->n_value, - bufp->n_type); /* Always */ - } - continue; - - case N_UNDF | N_EXT: - if (bufp->n_value != 0) { - /* This is a "Fortran COMMON" symbol. See if the target - environment knows where it has been relocated to. */ - - CORE_ADDR reladdr; - - SET_NAMESTRING(); - if (target_lookup_symbol (namestring, &reladdr)) { - continue; /* Error in lookup; ignore symbol for now. */ - } - bufp->n_type ^= (N_BSS^N_UNDF); /* Define it as a bss-symbol */ - bufp->n_value = reladdr; - goto bss_ext_symbol; - } - continue; /* Just undefined, not COMMON */ - - /* Lots of symbol types we can just ignore. */ - - case N_UNDF: - case N_ABS: - case N_BSS: - case N_NBDATA: - case N_NBBSS: - continue; - - /* Keep going . . .*/ - - /* - * Special symbol types for GNU - */ - case N_INDR: - case N_INDR | N_EXT: - case N_SETA: - case N_SETA | N_EXT: - case N_SETT: - case N_SETT | N_EXT: - case N_SETD: - case N_SETD | N_EXT: - case N_SETB: - case N_SETB | N_EXT: - case N_SETV: - continue; - - /* - * Debugger symbols - */ - - case N_SO: { - unsigned long valu = bufp->n_value; - /* Symbol number of the first symbol of this file (i.e. the N_SO - if there is just one, or the first if we have a pair). */ - int first_symnum = symnum; - - /* End the current partial symtab and start a new one */ - - SET_NAMESTRING(); - - /* Peek at the next symbol. If it is also an N_SO, the - first one just indicates the directory. */ - if (symbuf_idx == symbuf_end) - fill_symbuf (); - bufp = &symbuf[symbuf_idx]; - /* n_type is only a char, so swapping swapping is irrelevant. */ - if (bufp->n_type == (unsigned char)N_SO) - { - SWAP_SYMBOL (bufp); - SET_NAMESTRING (); - valu = bufp->n_value; - symbuf_idx++; - symnum++; - } - valu += addr; /* Relocate */ - - if (pst && past_first_source_file) - { - end_psymtab (pst, psymtab_include_list, includes_used, - first_symnum * symbol_size, valu, - dependency_list, dependencies_used, - global_psymbols.next, static_psymbols.next); - pst = (struct partial_symtab *) 0; - includes_used = 0; - dependencies_used = 0; - } - else - past_first_source_file = 1; - - pst = start_psymtab (symfile_name, addr, - namestring, valu, - first_symnum * symbol_size, - global_psymbols.next, static_psymbols.next); - continue; - } - - case N_BINCL: - /* Add this bincl to the bincl_list for future EXCLs. No - need to save the string; it'll be around until - read_dbx_symtab function returns */ - - SET_NAMESTRING(); - - add_bincl_to_list (pst, namestring, bufp->n_value); - - /* Mark down an include file in the current psymtab */ - - psymtab_include_list[includes_used++] = namestring; - if (includes_used >= includes_allocated) - { - char **orig = psymtab_include_list; - - psymtab_include_list = (char **) - alloca ((includes_allocated *= 2) * - sizeof (char *)); - bcopy (orig, psymtab_include_list, - includes_used * sizeof (char *)); - } - - continue; - - case N_SOL: - /* Mark down an include file in the current psymtab */ - - SET_NAMESTRING(); - - /* In C++, one may expect the same filename to come round many - times, when code is coming alternately from the main file - and from inline functions in other files. So I check to see - if this is a file we've seen before -- either the main - source file, or a previously included file. - - This seems to be a lot of time to be spending on N_SOL, but - things like "break c-exp.y:435" need to work (I - suppose the psymtab_include_list could be hashed or put - in a binary tree, if profiling shows this is a major hog). */ - if (pst && !strcmp (namestring, pst->filename)) - continue; - { - register int i; - for (i = 0; i < includes_used; i++) - if (!strcmp (namestring, psymtab_include_list[i])) - { - i = -1; - break; - } - if (i == -1) - continue; - } - - psymtab_include_list[includes_used++] = namestring; - if (includes_used >= includes_allocated) - { - char **orig = psymtab_include_list; - - psymtab_include_list = (char **) - alloca ((includes_allocated *= 2) * - sizeof (char *)); - bcopy (orig, psymtab_include_list, - includes_used * sizeof (char *)); - } - continue; - - case N_LSYM: /* Typedef or automatic variable. */ - case N_STSYM: /* Data seg var -- static */ - case N_LCSYM: /* BSS " */ - case N_NBSTS: /* Gould nobase. */ - case N_NBLCS: /* symbols. */ - - SET_NAMESTRING(); - - p = (char *) strchr (namestring, ':'); - - /* Skip if there is no :. */ - if (!p) continue; - - switch (p[1]) - { - case 'T': - ADD_PSYMBOL_TO_LIST (namestring, p - namestring, - STRUCT_NAMESPACE, LOC_TYPEDEF, - static_psymbols, bufp->n_value); - if (p[2] == 't') - { - /* Also a typedef with the same name. */ - ADD_PSYMBOL_TO_LIST (namestring, p - namestring, - VAR_NAMESPACE, LOC_TYPEDEF, - static_psymbols, bufp->n_value); - p += 1; - } - goto check_enum; - case 't': - ADD_PSYMBOL_TO_LIST (namestring, p - namestring, - VAR_NAMESPACE, LOC_TYPEDEF, - static_psymbols, bufp->n_value); - check_enum: - /* If this is an enumerated type, we need to - add all the enum constants to the partial symbol - table. This does not cover enums without names, e.g. - "enum {a, b} c;" in C, but fortunately those are - rare. There is no way for GDB to find those from the - enum type without spending too much time on it. Thus - to solve this problem, the compiler needs to put out separate - constant symbols ('c' N_LSYMS) for enum constants in - enums without names, or put out a dummy type. */ - - /* We are looking for something of the form - ":" ("t" | "T") [ "="] "e" - { ":" ","} ";". */ - - /* Skip over the colon and the 't' or 'T'. */ - p += 2; - /* This type may be given a number. Skip over it. */ - while ((*p >= '0' && *p <= '9') - || *p == '=') - p++; - - if (*p++ == 'e') - { - /* We have found an enumerated type. */ - /* According to comments in read_enum_type - a comma could end it instead of a semicolon. - I don't know where that happens. - Accept either. */ - while (*p && *p != ';' && *p != ',') - { - char *q; - - /* Check for and handle cretinous dbx symbol name - continuation! */ - if (*p == '\\') - p = next_symbol_text (); - - /* Point to the character after the name - of the enum constant. */ - for (q = p; *q && *q != ':'; q++) - ; - /* Note that the value doesn't matter for - enum constants in psymtabs, just in symtabs. */ - ADD_PSYMBOL_TO_LIST (p, q - p, - VAR_NAMESPACE, LOC_CONST, - static_psymbols, 0); - /* Point past the name. */ - p = q; - /* Skip over the value. */ - while (*p && *p != ',') - p++; - /* Advance past the comma. */ - if (*p) - p++; - } - } - - continue; - case 'c': - /* Constant, e.g. from "const" in Pascal. */ - ADD_PSYMBOL_TO_LIST (namestring, p - namestring, - VAR_NAMESPACE, LOC_CONST, - static_psymbols, bufp->n_value); - continue; - default: - /* Skip if the thing following the : is - not a letter (which indicates declaration of a local - variable, which we aren't interested in). */ - continue; - } - - case N_FUN: - case N_GSYM: /* Global (extern) variable; can be - data or bss (sigh). */ - - /* Following may probably be ignored; I'll leave them here - for now (until I do Pascal and Modula 2 extensions). */ - - case N_PC: /* I may or may not need this; I - suspect not. */ - case N_M2C: /* I suspect that I can ignore this here. */ - case N_SCOPE: /* Same. */ - - SET_NAMESTRING(); - - p = (char *) strchr (namestring, ':'); - if (!p) - continue; /* Not a debugging symbol. */ - - - - /* Main processing section for debugging symbols which - the initial read through the symbol tables needs to worry - about. If we reach this point, the symbol which we are - considering is definitely one we are interested in. - p must also contain the (valid) index into the namestring - which indicates the debugging type symbol. */ - - switch (p[1]) - { - case 'c': - ADD_PSYMBOL_TO_LIST (namestring, p - namestring, - VAR_NAMESPACE, LOC_CONST, - static_psymbols, bufp->n_value); - continue; - case 'S': - bufp->n_value += addr; /* Relocate */ - ADD_PSYMBOL_ADDR_TO_LIST (namestring, p - namestring, - VAR_NAMESPACE, LOC_STATIC, - static_psymbols, bufp->n_value); - continue; - case 'G': - bufp->n_value += addr; /* Relocate */ - /* The addresses in these entries are reported to be - wrong. See the code that reads 'G's for symtabs. */ - ADD_PSYMBOL_ADDR_TO_LIST (namestring, p - namestring, - VAR_NAMESPACE, LOC_STATIC, - global_psymbols, bufp->n_value); - continue; - - case 't': - ADD_PSYMBOL_TO_LIST (namestring, p - namestring, - VAR_NAMESPACE, LOC_TYPEDEF, - static_psymbols, bufp->n_value); - continue; - - case 'f': - ADD_PSYMBOL_TO_LIST (namestring, p - namestring, - VAR_NAMESPACE, LOC_BLOCK, - static_psymbols, bufp->n_value); - continue; - - /* Global functions were ignored here, but now they - are put into the global psymtab like one would expect. - They're also in the misc fn vector... - FIXME, why did it used to ignore these? That broke - "i fun" on these functions. */ - case 'F': - ADD_PSYMBOL_TO_LIST (namestring, p - namestring, - VAR_NAMESPACE, LOC_BLOCK, - global_psymbols, bufp->n_value); - continue; - - /* Two things show up here (hopefully); static symbols of - local scope (static used inside braces) or extensions - of structure symbols. We can ignore both. */ - case 'V': - case '(': - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - continue; - - default: - /* Unexpected symbol. Ignore it; perhaps it is an extension - that we don't know about. - - Someone says sun cc puts out symbols like - /foo/baz/maclib::/usr/local/bin/maclib, - which would get here with a symbol type of ':'. */ - continue; - } - - case N_EXCL: - - SET_NAMESTRING(); - - /* Find the corresponding bincl and mark that psymtab on the - psymtab dependency list */ - { - struct partial_symtab *needed_pst = - find_corresponding_bincl_psymtab (namestring, bufp->n_value); - - /* If this include file was defined earlier in this file, - leave it alone. */ - if (needed_pst == pst) continue; - - if (needed_pst) - { - int i; - int found = 0; - - for (i = 0; i < dependencies_used; i++) - if (dependency_list[i] == needed_pst) - { - found = 1; - break; - } - - /* If it's already in the list, skip the rest. */ - if (found) continue; - - dependency_list[dependencies_used++] = needed_pst; - if (dependencies_used >= dependencies_allocated) - { - struct partial_symtab **orig = dependency_list; - dependency_list = - (struct partial_symtab **) - alloca ((dependencies_allocated *= 2) - * sizeof (struct partial_symtab *)); - bcopy (orig, dependency_list, - (dependencies_used - * sizeof (struct partial_symtab *))); -#ifdef DEBUG_INFO - fprintf (stderr, "Had to reallocate dependency list.\n"); - fprintf (stderr, "New dependencies allocated: %d\n", - dependencies_allocated); -#endif - } - } - else - error ("Invalid symbol data: \"repeated\" header file not previously seen, at symtab pos %d.", - symnum); - } - continue; - - case N_EINCL: - case N_DSLINE: - case N_BSLINE: - case N_SSYM: /* Claim: Structure or union element. - Hopefully, I can ignore this. */ - case N_ENTRY: /* Alternate entry point; can ignore. */ - case N_MAIN: /* Can definitely ignore this. */ - case N_CATCH: /* These are GNU C++ extensions */ - case N_EHDECL: /* that can safely be ignored here. */ - case N_LENG: - case N_BCOMM: - case N_ECOMM: - case N_ECOML: - case N_FNAME: - case N_SLINE: - case N_RSYM: - case N_PSYM: - case N_LBRAC: - case N_RBRAC: - case N_NSYMS: /* Ultrix 4.0: symbol count */ - case N_DEFD: /* GNU Modula-2 */ - /* These symbols aren't interesting; don't worry about them */ - - continue; - - default: - /* If we haven't found it yet, ignore it. It's probably some - new type we don't know about yet. */ - complain (&unknown_symtype_complaint, local_hex_string(bufp->n_type)); - continue; - } - } - - /* If there's stuff to be cleaned up, clean it up. */ - if (nlistlen > 0 /* We have some syms */ - && entry_point < bufp->n_value - && entry_point >= last_o_file_start) - { - startup_file_start = last_o_file_start; - startup_file_end = bufp->n_value; - } - - if (pst) - { - end_psymtab (pst, psymtab_include_list, includes_used, - symnum * symbol_size, end_of_text_addr, - dependency_list, dependencies_used, - global_psymbols.next, static_psymbols.next); - includes_used = 0; - dependencies_used = 0; - pst = (struct partial_symtab *) 0; - } - - free_bincl_list (); - discard_cleanups (old_chain); -} - -/* Allocate and partially fill a partial symtab. It will be - completely filled at the end of the symbol list. - - SYMFILE_NAME is the name of the symbol-file we are reading from, and ADDR - is the address relative to which its symbols are (incremental) or 0 - (normal). */ - - -static struct partial_symtab * -start_psymtab (symfile_name, addr, - filename, textlow, ldsymoff, global_syms, static_syms) - char *symfile_name; - CORE_ADDR addr; - char *filename; - CORE_ADDR textlow; - int ldsymoff; - struct partial_symbol *global_syms; - struct partial_symbol *static_syms; -{ - struct partial_symtab *result = - (struct partial_symtab *) obstack_alloc (psymbol_obstack, - sizeof (struct partial_symtab)); - - result->addr = addr; - - result->symfile_name = - (char *) obstack_alloc (psymbol_obstack, - strlen (symfile_name) + 1); - strcpy (result->symfile_name, symfile_name); - - result->filename = - (char *) obstack_alloc (psymbol_obstack, - strlen (filename) + 1); - strcpy (result->filename, filename); - - result->textlow = textlow; - result->read_symtab_private = (char *) obstack_alloc (psymbol_obstack, - sizeof (struct symloc)); - LDSYMOFF(result) = ldsymoff; - - result->readin = 0; - result->symtab = 0; - result->read_symtab = dbx_psymtab_to_symtab; - - result->globals_offset = global_syms - global_psymbols.list; - result->statics_offset = static_syms - static_psymbols.list; - - result->n_global_syms = 0; - result->n_static_syms = 0; - - - return result; -} - -static int -compare_psymbols (s1, s2) - register struct partial_symbol *s1, *s2; -{ - register char - *st1 = SYMBOL_NAME (s1), - *st2 = SYMBOL_NAME (s2); - - if (st1[0] - st2[0]) - return st1[0] - st2[0]; - if (st1[1] - st2[1]) - return st1[1] - st2[1]; - return strcmp (st1 + 1, st2 + 1); -} - - -/* Close off the current usage of a partial_symbol table entry. This - involves setting the correct number of includes (with a realloc), - setting the high text mark, setting the symbol length in the - executable, and setting the length of the global and static lists - of psymbols. - - The global symbols and static symbols are then seperately sorted. - - Then the partial symtab is put on the global list. - *** List variables and peculiarities of same. *** - */ -static void -end_psymtab (pst, include_list, num_includes, capping_symbol_offset, - capping_text, dependency_list, number_dependencies, - capping_global, capping_static) - struct partial_symtab *pst; - char **include_list; - int num_includes; - int capping_symbol_offset; - CORE_ADDR capping_text; - struct partial_symtab **dependency_list; - int number_dependencies; - struct partial_symbol *capping_global, *capping_static; -{ - int i; - - LDSYMLEN(pst) = capping_symbol_offset - LDSYMOFF(pst); - pst->texthigh = capping_text; - - pst->n_global_syms = - capping_global - (global_psymbols.list + pst->globals_offset); - pst->n_static_syms = - capping_static - (static_psymbols.list + pst->statics_offset); - - pst->number_of_dependencies = number_dependencies; - if (number_dependencies) - { - pst->dependencies = (struct partial_symtab **) - obstack_alloc (psymbol_obstack, - number_dependencies * sizeof (struct partial_symtab *)); - bcopy (dependency_list, pst->dependencies, - number_dependencies * sizeof (struct partial_symtab *)); - } - else - pst->dependencies = 0; - - for (i = 0; i < num_includes; i++) - { - /* Eventually, put this on obstack */ - struct partial_symtab *subpst = - (struct partial_symtab *) - obstack_alloc (psymbol_obstack, - sizeof (struct partial_symtab)); - - subpst->filename = - (char *) obstack_alloc (psymbol_obstack, - strlen (include_list[i]) + 1); - strcpy (subpst->filename, include_list[i]); - - subpst->symfile_name = pst->symfile_name; - subpst->addr = pst->addr; - subpst->read_symtab_private = (char *) obstack_alloc (psymbol_obstack, - sizeof (struct symloc)); - LDSYMOFF(subpst) = - LDSYMLEN(subpst) = - subpst->textlow = - subpst->texthigh = 0; - - /* We could save slight bits of space by only making one of these, - shared by the entire set of include files. FIXME-someday. */ - subpst->dependencies = (struct partial_symtab **) - obstack_alloc (psymbol_obstack, - sizeof (struct partial_symtab *)); - subpst->dependencies[0] = pst; - subpst->number_of_dependencies = 1; - - subpst->globals_offset = - subpst->n_global_syms = - subpst->statics_offset = - subpst->n_static_syms = 0; - - subpst->readin = 0; - subpst->symtab = 0; - subpst->read_symtab = dbx_psymtab_to_symtab; - - subpst->next = partial_symtab_list; - partial_symtab_list = subpst; - } - - /* Sort the global list; don't sort the static list */ - qsort (global_psymbols.list + pst->globals_offset, pst->n_global_syms, - sizeof (struct partial_symbol), compare_psymbols); - - /* If there is already a psymtab or symtab for a file of this name, remove it. - (If there is a symtab, more drastic things also happen.) - This happens in VxWorks. */ - free_named_symtabs (pst->filename); - - /* Put the psymtab on the psymtab list */ - pst->next = partial_symtab_list; - partial_symtab_list = pst; -} - -static void -psymtab_to_symtab_1 (pst, desc, stringtab, stringtab_size, sym_offset) - struct partial_symtab *pst; - int desc; - char *stringtab; - int stringtab_size; - int sym_offset; -{ - struct cleanup *old_chain; - int i; - - if (!pst) - return; - - if (pst->readin) - { - fprintf (stderr, "Psymtab for %s already read in. Shouldn't happen.\n", - pst->filename); - return; - } - - /* Read in all partial symtabs on which this one is dependent */ - for (i = 0; i < pst->number_of_dependencies; i++) - if (!pst->dependencies[i]->readin) - { - /* Inform about additional files that need to be read in. */ - if (info_verbose) - { - fputs_filtered (" ", stdout); - wrap_here (""); - fputs_filtered ("and ", stdout); - wrap_here (""); - printf_filtered ("%s...", pst->dependencies[i]->filename); - wrap_here (""); /* Flush output */ - fflush (stdout); - } - psymtab_to_symtab_1 (pst->dependencies[i], desc, - stringtab, stringtab_size, sym_offset); - } - - if (LDSYMLEN(pst)) /* Otherwise it's a dummy */ - { - /* Init stuff necessary for reading in symbols */ - buildsym_init (); - old_chain = make_cleanup (really_free_pendings, 0); - - /* Read in this files symbols */ - lseek (desc, sym_offset, L_SET); - pst->symtab = - read_ofile_symtab (desc, stringtab, stringtab_size, - LDSYMOFF(pst), - LDSYMLEN(pst), pst->textlow, - pst->texthigh - pst->textlow, pst->addr); - sort_symtab_syms (pst->symtab); - - do_cleanups (old_chain); - } - - pst->readin = 1; -} - -/* - * Read in all of the symbols for a given psymtab for real. - * Be verbose about it if the user wants that. - */ -static void -dbx_psymtab_to_symtab (pst) - struct partial_symtab *pst; -{ - int desc; - char *stringtab; - int stsize, val; - struct stat statbuf; - struct cleanup *old_chain; - bfd *sym_bfd; - long st_temp; - - if (!pst) - return; - - if (pst->readin) - { - fprintf (stderr, "Psymtab for %s already read in. Shouldn't happen.\n", - pst->filename); - return; - } - - if (LDSYMLEN(pst) || pst->number_of_dependencies) - { - /* Print the message now, before reading the string table, - to avoid disconcerting pauses. */ - if (info_verbose) - { - printf_filtered ("Reading in symbols for %s...", pst->filename); - fflush (stdout); - } - - /* Open symbol file and read in string table. Symbol_file_command - guarantees that the symbol file name will be absolute, so there is - no need for openp. */ - desc = open(pst->symfile_name, O_RDONLY, 0); - - if (desc < 0) - perror_with_name (pst->symfile_name); - - sym_bfd = bfd_fdopenr (pst->symfile_name, NULL, desc); - if (!sym_bfd) - { - (void)close (desc); - error ("Could not open `%s' to read symbols: %s", - pst->symfile_name, bfd_errmsg (bfd_error)); - } - old_chain = make_cleanup (bfd_close, sym_bfd); - if (!bfd_check_format (sym_bfd, bfd_object)) - error ("\"%s\": can't read symbols: %s.", - pst->symfile_name, bfd_errmsg (bfd_error)); - - /* We keep the string table for symfile resident in memory, but - not the string table for any other symbol files. */ - if ((symfile == 0) || 0 != strcmp(pst->symfile_name, symfile)) - { - /* Read in the string table */ - - /* FIXME, this uses internal BFD variables. See above in - dbx_symbol_file_open where the macro is defined! */ - lseek (desc, STRING_TABLE_OFFSET, L_SET); - - val = myread (desc, &st_temp, sizeof st_temp); - if (val < 0) - perror_with_name (pst->symfile_name); - stsize = bfd_h_get_32 (sym_bfd, (unsigned char *)&st_temp); - if (fstat (desc, &statbuf) < 0) - perror_with_name (pst->symfile_name); - - if (stsize >= 0 && stsize < statbuf.st_size) - { -#ifdef BROKEN_LARGE_ALLOCA - stringtab = (char *) xmalloc (stsize); - make_cleanup (free, stringtab); -#else - stringtab = (char *) alloca (stsize); -#endif - } - else - stringtab = NULL; - if (stringtab == NULL && stsize != 0) - error ("ridiculous string table size: %d bytes", stsize); - - /* FIXME, this uses internal BFD variables. See above in - dbx_symbol_file_open where the macro is defined! */ - val = lseek (desc, STRING_TABLE_OFFSET, L_SET); - if (val < 0) - perror_with_name (pst->symfile_name); - val = myread (desc, stringtab, stsize); - if (val < 0) - perror_with_name (pst->symfile_name); - } - else - { - stringtab = symfile_string_table; - stsize = symfile_string_table_size; - } - - symfile_bfd = sym_bfd; /* Kludge for SWAP_SYMBOL */ - /* FIXME POKING INSIDE BFD DATA STRUCTURES */ - symbol_size = obj_symbol_entry_size (sym_bfd); - - /* FIXME, this uses internal BFD variables. See above in - dbx_symbol_file_open where the macro is defined! */ - psymtab_to_symtab_1 (pst, desc, stringtab, stsize, - SYMBOL_TABLE_OFFSET); - - /* Match with global symbols. This only needs to be done once, - after all of the symtabs and dependencies have been read in. */ - scan_file_globals (); - - do_cleanups (old_chain); - - /* Finish up the debug error message. */ - if (info_verbose) - printf_filtered ("done.\n"); - } -} - -/* Process a pair of symbols. Currently they must both be N_SO's. */ -/* ARGSUSED */ -static void -process_symbol_pair (type1, desc1, value1, name1, - type2, desc2, value2, name2) - int type1; - int desc1; - CORE_ADDR value1; - char *name1; - int type2; - int desc2; - CORE_ADDR value2; - char *name2; -{ - /* No need to check PCC_SOL_BROKEN, on the assumption that such - broken PCC's don't put out N_SO pairs. */ - if (last_source_file) - (void)end_symtab (value2, 0, 0); - start_symtab (name2, name1, value2); -} - -/* - * Read in a defined section of a specific object file's symbols. - * - * DESC is the file descriptor for the file, positioned at the - * beginning of the symtab - * STRINGTAB is a pointer to the files string - * table, already read in - * SYM_OFFSET is the offset within the file of - * the beginning of the symbols we want to read, NUM_SUMBOLS is the - * number of symbols to read - * TEXT_OFFSET is the beginning of the text segment we are reading symbols for - * TEXT_SIZE is the size of the text segment read in. - * OFFSET is a relocation offset which gets added to each symbol - */ - -static struct symtab * -read_ofile_symtab (desc, stringtab, stringtab_size, sym_offset, - sym_size, text_offset, text_size, offset) - int desc; - register char *stringtab; - unsigned int stringtab_size; - int sym_offset; - int sym_size; - CORE_ADDR text_offset; - int text_size; - int offset; -{ - register char *namestring; - struct internal_nlist *bufp; - unsigned char type; - unsigned max_symnum; - subfile_stack = 0; - - stringtab_global = stringtab; - last_source_file = 0; - - symtab_input_desc = desc; - symbuf_end = symbuf_idx = 0; - - /* It is necessary to actually read one symbol *before* the start - of this symtab's symbols, because the GCC_COMPILED_FLAG_SYMBOL - occurs before the N_SO symbol. - - Detecting this in read_dbx_symtab - would slow down initial readin, so we look for it here instead. */ - if (sym_offset >= (int)symbol_size) - { - lseek (desc, sym_offset - symbol_size, L_INCR); - fill_symbuf (); - bufp = &symbuf[symbuf_idx++]; - SWAP_SYMBOL (bufp); - - SET_NAMESTRING (); - - processing_gcc_compilation = - (bufp->n_type == N_TEXT - && !strcmp (namestring, GCC_COMPILED_FLAG_SYMBOL)); - /* FIXME!!! Check for gcc2_compiled... */ - } - else - { - /* The N_SO starting this symtab is the first symbol, so we - better not check the symbol before it. I'm not this can - happen, but it doesn't hurt to check for it. */ - lseek(desc, sym_offset, L_INCR); - processing_gcc_compilation = 0; - } - - if (symbuf_idx == symbuf_end) - fill_symbuf(); - bufp = &symbuf[symbuf_idx]; - if (bufp->n_type != (unsigned char)N_SO) - error("First symbol in segment of executable not a source symbol"); - - max_symnum = sym_size / symbol_size; - - for (symnum = 0; - symnum < max_symnum; - symnum++) - { - QUIT; /* Allow this to be interruptable */ - if (symbuf_idx == symbuf_end) - fill_symbuf(); - bufp = &symbuf[symbuf_idx++]; - SWAP_SYMBOL (bufp); - - type = bufp->n_type; - if (type == (unsigned char)N_CATCH) - { - /* N_CATCH is not fixed up by the linker, and unfortunately, - there's no other place to put it in the .stab map. */ - bufp->n_value += text_offset + offset; - } - else { - type &= ~N_EXT; /* Ignore external-bit */ - if (type == N_TEXT || type == N_DATA || type == N_BSS) - bufp->n_value += offset; - type = bufp->n_type; - } - - SET_NAMESTRING (); - - if (type & N_STAB) - { - short bufp_n_desc = bufp->n_desc; - unsigned long valu = bufp->n_value; - - /* Check for a pair of N_SO symbols. */ - if (type == (unsigned char)N_SO) - { - if (symbuf_idx == symbuf_end) - fill_symbuf (); - bufp = &symbuf[symbuf_idx]; - if (bufp->n_type == (unsigned char)N_SO) - { - char *namestring1 = namestring; - - SWAP_SYMBOL (bufp); - bufp->n_value += offset; /* Relocate */ - symbuf_idx++; - symnum++; - SET_NAMESTRING (); - - process_symbol_pair (N_SO, bufp_n_desc, valu, namestring1, - N_SO, bufp->n_desc, bufp->n_value, - namestring); - } - else - process_one_symbol(type, bufp_n_desc, valu, namestring); - } - else - process_one_symbol (type, bufp_n_desc, valu, namestring); - } - /* We skip checking for a new .o or -l file; that should never - happen in this routine. */ - else if (type == N_TEXT - && !strcmp (namestring, GCC_COMPILED_FLAG_SYMBOL)) - /* I don't think this code will ever be executed, because - the GCC_COMPILED_FLAG_SYMBOL usually is right before - the N_SO symbol which starts this source file. - However, there is no reason not to accept - the GCC_COMPILED_FLAG_SYMBOL anywhere. */ - processing_gcc_compilation = 1; - else if (type & N_EXT || type == (unsigned char)N_TEXT - || type == (unsigned char)N_NBTEXT - ) { - /* Global symbol: see if we came across a dbx defintion for - a corresponding symbol. If so, store the value. Remove - syms from the chain when their values are stored, but - search the whole chain, as there may be several syms from - different files with the same name. */ - /* This is probably not true. Since the files will be read - in one at a time, each reference to a global symbol will - be satisfied in each file as it appears. So we skip this - section. */ - ; - } - } - - return end_symtab (text_offset + text_size, 0, 0); -} - -int -hashname (name) - char *name; -{ - register char *p = name; - register int total = p[0]; - register int c; - - c = p[1]; - total += c << 2; - if (c) - { - c = p[2]; - total += c << 4; - if (c) - total += p[3] << 6; - } - - /* Ensure result is positive. */ - if (total < 0) total += (1000 << 6); - return total % HASHSIZE; -} - - -static void -process_one_symbol (type, desc, valu, name) - int type, desc; - CORE_ADDR valu; - char *name; -{ -#ifndef SUN_FIXED_LBRAC_BUG - /* This records the last pc address we've seen. We depend on their being - an SLINE or FUN or SO before the first LBRAC, since the variable does - not get reset in between reads of different symbol files. */ - static CORE_ADDR last_pc_address; -#endif - register struct context_stack *new; - char *colon_pos; - - /* Something is wrong if we see real data before - seeing a source file name. */ - - if (last_source_file == 0 && type != (unsigned char)N_SO) - { - /* Currently this ignores N_ENTRY on Gould machines, N_NSYM on machines - where that code is defined. */ - if (IGNORE_SYMBOL (type)) - return; - - /* FIXME, this should not be an error, since it precludes extending - the symbol table information in this way... */ - error ("Invalid symbol data: does not start by identifying a source file."); - } - - switch (type) - { - case N_FUN: - case N_FNAME: - /* Either of these types of symbols indicates the start of - a new function. We must process its "name" normally for dbx, - but also record the start of a new lexical context, and possibly - also the end of the lexical context for the previous function. */ - /* This is not always true. This type of symbol may indicate a - text segment variable. */ - -#ifndef SUN_FIXED_LBRAC_BUG - last_pc_address = valu; /* Save for SunOS bug circumcision */ -#endif - - colon_pos = strchr (name, ':'); - if (!colon_pos++ - || (*colon_pos != 'f' && *colon_pos != 'F')) - { - define_symbol (valu, name, desc, type); - break; - } - - within_function = 1; - if (context_stack_depth > 0) - { - new = &context_stack[--context_stack_depth]; - /* Make a block for the local symbols within. */ - finish_block (new->name, &local_symbols, new->old_blocks, - new->start_addr, valu); - } - /* Stack must be empty now. */ - if (context_stack_depth != 0) - error ("Invalid symbol data: unmatched N_LBRAC before symtab pos %d.", - symnum); - - new = &context_stack[context_stack_depth++]; - new->old_blocks = pending_blocks; - new->start_addr = valu; - new->name = define_symbol (valu, name, desc, type); - local_symbols = 0; - break; - - case N_CATCH: - /* Record the address at which this catch takes place. */ - define_symbol (valu, name, desc, type); - break; - - case N_EHDECL: - /* Don't know what to do with these yet. */ - error ("action uncertain for eh extensions"); - break; - - case N_LBRAC: - /* This "symbol" just indicates the start of an inner lexical - context within a function. */ - -#if !defined (BLOCK_ADDRESS_ABSOLUTE) - /* On most machines, the block addresses are relative to the - N_SO, the linker did not relocate them (sigh). */ - valu += last_source_start_addr; -#endif - -#ifndef SUN_FIXED_LBRAC_BUG - if (valu < last_pc_address) { - /* Patch current LBRAC pc value to match last handy pc value */ - complain (&lbrac_complaint, 0); - valu = last_pc_address; - } -#endif - if (context_stack_depth == context_stack_size) - { - context_stack_size *= 2; - context_stack = (struct context_stack *) - xrealloc (context_stack, - (context_stack_size - * sizeof (struct context_stack))); - } - - new = &context_stack[context_stack_depth++]; - new->depth = desc; - new->locals = local_symbols; - new->old_blocks = pending_blocks; - new->start_addr = valu; - new->name = 0; - local_symbols = 0; - break; - - case N_RBRAC: - /* This "symbol" just indicates the end of an inner lexical - context that was started with N_LBRAC. */ - -#if !defined (BLOCK_ADDRESS_ABSOLUTE) - /* On most machines, the block addresses are relative to the - N_SO, the linker did not relocate them (sigh). */ - valu += last_source_start_addr; -#endif - - new = &context_stack[--context_stack_depth]; - if (desc != new->depth) - error ("Invalid symbol data: N_LBRAC/N_RBRAC symbol mismatch, symtab pos %d.", symnum); - - /* Some compilers put the variable decls inside of an - LBRAC/RBRAC block. This macro should be nonzero if this - is true. DESC is N_DESC from the N_RBRAC symbol. - GCC_P is true if we've detected the GCC_COMPILED_SYMBOL. */ -#if !defined (VARIABLES_INSIDE_BLOCK) -#define VARIABLES_INSIDE_BLOCK(desc, gcc_p) 0 -#endif - - /* Can only use new->locals as local symbols here if we're in - gcc or on a machine that puts them before the lbrack. */ - if (!VARIABLES_INSIDE_BLOCK(desc, processing_gcc_compilation)) - local_symbols = new->locals; - - /* If this is not the outermost LBRAC...RBRAC pair in the - function, its local symbols preceded it, and are the ones - just recovered from the context stack. Defined the block for them. - - If this is the outermost LBRAC...RBRAC pair, there is no - need to do anything; leave the symbols that preceded it - to be attached to the function's own block. However, if - it is so, we need to indicate that we just moved outside - of the function. */ - if (local_symbols - && (context_stack_depth - > !VARIABLES_INSIDE_BLOCK(desc, processing_gcc_compilation))) - { - /* FIXME Muzzle a compiler bug that makes end < start. */ - if (new->start_addr > valu) - { - complain(&lbrac_rbrac_complaint, 0); - new->start_addr = valu; - } - /* Make a block for the local symbols within. */ - finish_block (0, &local_symbols, new->old_blocks, - new->start_addr, valu); - } - else - { - within_function = 0; - } - if (VARIABLES_INSIDE_BLOCK(desc, processing_gcc_compilation)) - /* Now pop locals of block just finished. */ - local_symbols = new->locals; - break; - - case N_FN: - case N_FN_SEQ: - /* This kind of symbol indicates the start of an object file. */ - break; - - case N_SO: - /* This type of symbol indicates the start of data - for one source file. - Finish the symbol table of the previous source file - (if any) and start accumulating a new symbol table. */ -#ifndef SUN_FIXED_LBRAC_BUG - last_pc_address = valu; /* Save for SunOS bug circumcision */ -#endif - -#ifdef PCC_SOL_BROKEN - /* pcc bug, occasionally puts out SO for SOL. */ - if (context_stack_depth > 0) - { - start_subfile (name, NULL); - break; - } -#endif - if (last_source_file) - (void)end_symtab (valu, 0, 0); - start_symtab (name, NULL, valu); - break; - - case N_SOL: - /* This type of symbol indicates the start of data for - a sub-source-file, one whose contents were copied or - included in the compilation of the main source file - (whose name was given in the N_SO symbol.) */ - start_subfile (name, NULL); - break; - - case N_BINCL: - push_subfile (); - add_new_header_file (name, valu); - start_subfile (name, NULL); - break; - - case N_EINCL: - start_subfile (pop_subfile (), NULL); - break; - - case N_EXCL: - add_old_header_file (name, valu); - break; - - case N_SLINE: - /* This type of "symbol" really just records - one line-number -- core-address correspondence. - Enter it in the line list for this symbol table. */ -#ifndef SUN_FIXED_LBRAC_BUG - last_pc_address = valu; /* Save for SunOS bug circumcision */ -#endif - record_line (current_subfile, desc, valu); - break; - - case N_BCOMM: - if (common_block) - error ("Invalid symbol data: common within common at symtab pos %d", - symnum); - common_block = local_symbols; - common_block_i = local_symbols ? local_symbols->nsyms : 0; - break; - - case N_ECOMM: - /* Symbols declared since the BCOMM are to have the common block - start address added in when we know it. common_block points to - the first symbol after the BCOMM in the local_symbols list; - copy the list and hang it off the symbol for the common block name - for later fixup. */ - { - int i; - struct symbol *sym = - (struct symbol *) xmalloc (sizeof (struct symbol)); - bzero (sym, sizeof *sym); - SYMBOL_NAME (sym) = savestring (name, strlen (name)); - SYMBOL_CLASS (sym) = LOC_BLOCK; - SYMBOL_NAMESPACE (sym) = (enum namespace)((long) - copy_pending (local_symbols, common_block_i, common_block)); - i = hashname (SYMBOL_NAME (sym)); - SYMBOL_VALUE_CHAIN (sym) = global_sym_chain[i]; - global_sym_chain[i] = sym; - common_block = 0; - break; - } - - case N_ECOML: - case N_LENG: - case N_DEFD: /* GNU Modula-2 symbol */ - break; - - default: - if (name) - define_symbol (valu, name, desc, type); - } -} - -/* To handle GNU C++ typename abbreviation, we need to be able to - fill in a type's name as soon as space for that type is allocated. - `type_synonym_name' is the name of the type being allocated. - It is cleared as soon as it is used (lest all allocated types - get this name). */ -static char *type_synonym_name; - -/* ARGSUSED */ -static struct symbol * -define_symbol (valu, string, desc, type) - unsigned int valu; - char *string; - int desc; - int type; -{ - register struct symbol *sym; - char *p = (char *) strchr (string, ':'); - int deftype; - int synonym = 0; - register int i; - - /* Ignore syms with empty names. */ - if (string[0] == 0) - return 0; - - /* Ignore old-style symbols from cc -go */ - if (p == 0) - return 0; - - sym = (struct symbol *)obstack_alloc (symbol_obstack, sizeof (struct symbol)); - - if (processing_gcc_compilation) { - /* GCC 2.x puts the line number in desc. SunOS apparently puts in the - number of bytes occupied by a type or object, which we ignore. */ - SYMBOL_LINE(sym) = desc; - } else { - SYMBOL_LINE(sym) = 0; /* unknown */ - } - - if (string[0] == CPLUS_MARKER) - { - /* Special GNU C++ names. */ - switch (string[1]) - { - case 't': - SYMBOL_NAME (sym) = "this"; - break; - case 'v': /* $vtbl_ptr_type */ - /* Was: SYMBOL_NAME (sym) = "vptr"; */ - goto normal; - case 'e': - SYMBOL_NAME (sym) = "eh_throw"; - break; - - case '_': - /* This was an anonymous type that was never fixed up. */ - goto normal; - - default: - abort (); - } - } - else - { - normal: - SYMBOL_NAME (sym) - = (char *) obstack_alloc (symbol_obstack, ((p - string) + 1)); - /* Open-coded bcopy--saves function call time. */ - { - register char *p1 = string; - register char *p2 = SYMBOL_NAME (sym); - while (p1 != p) - *p2++ = *p1++; - *p2++ = '\0'; - } - } - p++; - /* Determine the type of name being defined. */ - /* The Acorn RISC machine's compiler can put out locals that don't - start with "234=" or "(3,4)=", so assume anything other than the - deftypes we know how to handle is a local. */ - /* (Peter Watkins @ Computervision) - Handle Sun-style local fortran array types 'ar...' . - (gnu@cygnus.com) -- this strchr() handles them properly? - (tiemann@cygnus.com) -- 'C' is for catch. */ - if (!strchr ("cfFGpPrStTvVXC", *p)) - deftype = 'l'; - else - deftype = *p++; - - /* c is a special case, not followed by a type-number. - SYMBOL:c=iVALUE for an integer constant symbol. - SYMBOL:c=rVALUE for a floating constant symbol. - SYMBOL:c=eTYPE,INTVALUE for an enum constant symbol. - e.g. "b:c=e6,0" for "const b = blob1" - (where type 6 is defined by "blobs:t6=eblob1:0,blob2:1,;"). */ - if (deftype == 'c') - { - if (*p++ != '=') - error ("Invalid symbol data at symtab pos %d.", symnum); - switch (*p++) - { - case 'r': - { - double d = atof (p); - char *dbl_valu; - - SYMBOL_TYPE (sym) = builtin_type_double; - dbl_valu = - (char *) obstack_alloc (symbol_obstack, sizeof (double)); - bcopy (&d, dbl_valu, sizeof (double)); - SWAP_TARGET_AND_HOST (dbl_valu, sizeof (double)); - SYMBOL_VALUE_BYTES (sym) = dbl_valu; - SYMBOL_CLASS (sym) = LOC_CONST_BYTES; - } - break; - case 'i': - { - SYMBOL_TYPE (sym) = builtin_type_int; - SYMBOL_VALUE (sym) = atoi (p); - SYMBOL_CLASS (sym) = LOC_CONST; - } - break; - case 'e': - /* SYMBOL:c=eTYPE,INTVALUE for an enum constant symbol. - e.g. "b:c=e6,0" for "const b = blob1" - (where type 6 is defined by "blobs:t6=eblob1:0,blob2:1,;"). */ - { - int typenums[2]; - - read_type_number (&p, typenums); - if (*p++ != ',') - error ("Invalid symbol data: no comma in enum const symbol"); - - SYMBOL_TYPE (sym) = *dbx_lookup_type (typenums); - SYMBOL_VALUE (sym) = atoi (p); - SYMBOL_CLASS (sym) = LOC_CONST; - } - break; - default: - error ("Invalid symbol data at symtab pos %d.", symnum); - } - SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; - add_symbol_to_list (sym, &file_symbols); - return sym; - } - - /* Now usually comes a number that says which data type, - and possibly more stuff to define the type - (all of which is handled by read_type) */ - - if (deftype == 'p' && *p == 'F') - /* pF is a two-letter code that means a function parameter in Fortran. - The type-number specifies the type of the return value. - Translate it into a pointer-to-function type. */ - { - p++; - SYMBOL_TYPE (sym) - = lookup_pointer_type (lookup_function_type (read_type (&p))); - } - else - { - struct type *type_read; - synonym = *p == 't'; - - if (synonym) - { - p += 1; - type_synonym_name = obsavestring (SYMBOL_NAME (sym), - strlen (SYMBOL_NAME (sym))); - } - - type_read = read_type (&p); - - if ((deftype == 'F' || deftype == 'f') - && TYPE_CODE (type_read) != TYPE_CODE_FUNC) - { -#if 0 -/* This code doesn't work -- it needs to realloc and can't. */ - struct type *new = (struct type *) - obstack_alloc (symbol_obstack, sizeof (struct type)); - - /* Generate a template for the type of this function. The - types of the arguments will be added as we read the symbol - table. */ - *new = *lookup_function_type (type_read); - SYMBOL_TYPE(sym) = new; - in_function_type = new; -#else - SYMBOL_TYPE (sym) = lookup_function_type (type_read); -#endif - } - else - SYMBOL_TYPE (sym) = type_read; - } - - switch (deftype) - { - case 'C': - /* The name of a caught exception. */ - SYMBOL_CLASS (sym) = LOC_LABEL; - SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; - SYMBOL_VALUE_ADDRESS (sym) = valu; - add_symbol_to_list (sym, &local_symbols); - break; - - case 'f': - SYMBOL_CLASS (sym) = LOC_BLOCK; - SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; - add_symbol_to_list (sym, &file_symbols); - break; - - case 'F': - SYMBOL_CLASS (sym) = LOC_BLOCK; - SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; - add_symbol_to_list (sym, &global_symbols); - break; - - case 'G': - /* For a class G (global) symbol, it appears that the - value is not correct. It is necessary to search for the - corresponding linker definition to find the value. - These definitions appear at the end of the namelist. */ - i = hashname (SYMBOL_NAME (sym)); - SYMBOL_VALUE_CHAIN (sym) = global_sym_chain[i]; - global_sym_chain[i] = sym; - SYMBOL_CLASS (sym) = LOC_STATIC; - SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; - add_symbol_to_list (sym, &global_symbols); - break; - - /* This case is faked by a conditional above, - when there is no code letter in the dbx data. - Dbx data never actually contains 'l'. */ - case 'l': - SYMBOL_CLASS (sym) = LOC_LOCAL; - SYMBOL_VALUE (sym) = valu; - SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; - add_symbol_to_list (sym, &local_symbols); - break; - - case 'p': - /* Normally this is a parameter, a LOC_ARG. On the i960, it - can also be a LOC_LOCAL_ARG depending on symbol type. */ -#ifndef DBX_PARM_SYMBOL_CLASS -#define DBX_PARM_SYMBOL_CLASS(type) LOC_ARG -#endif - SYMBOL_CLASS (sym) = DBX_PARM_SYMBOL_CLASS (type); - SYMBOL_VALUE (sym) = valu; - SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; -#if 0 - /* This doesn't work yet. */ - add_param_to_type (&in_function_type, sym); -#endif - add_symbol_to_list (sym, &local_symbols); - - /* If it's gcc-compiled, if it says `short', believe it. */ - if (processing_gcc_compilation || BELIEVE_PCC_PROMOTION) - break; - -#if defined(BELIEVE_PCC_PROMOTION_TYPE) - /* This macro is defined on machines (e.g. sparc) where - we should believe the type of a PCC 'short' argument, - but shouldn't believe the address (the address is - the address of the corresponding int). Note that - this is only different from the BELIEVE_PCC_PROMOTION - case on big-endian machines. - - My guess is that this correction, as opposed to changing - the parameter to an 'int' (as done below, for PCC - on most machines), is the right thing to do - on all machines, but I don't want to risk breaking - something that already works. On most PCC machines, - the sparc problem doesn't come up because the calling - function has to zero the top bytes (not knowing whether - the called function wants an int or a short), so there - is no practical difference between an int and a short - (except perhaps what happens when the GDB user types - "print short_arg = 0x10000;"). - - Hacked for SunOS 4.1 by gnu@cygnus.com. In 4.1, the compiler - actually produces the correct address (we don't need to fix it - up). I made this code adapt so that it will offset the symbol - if it was pointing at an int-aligned location and not - otherwise. This way you can use the same gdb for 4.0.x and - 4.1 systems. */ - - if (0 == SYMBOL_VALUE (sym) % sizeof (int)) - { - if (SYMBOL_TYPE (sym) == builtin_type_char - || SYMBOL_TYPE (sym) == builtin_type_unsigned_char) - SYMBOL_VALUE (sym) += 3; - else if (SYMBOL_TYPE (sym) == builtin_type_short - || SYMBOL_TYPE (sym) == builtin_type_unsigned_short) - SYMBOL_VALUE (sym) += 2; - } - break; - -#else /* no BELIEVE_PCC_PROMOTION_TYPE. */ - - /* If PCC says a parameter is a short or a char, - it is really an int. */ - if (SYMBOL_TYPE (sym) == builtin_type_char - || SYMBOL_TYPE (sym) == builtin_type_short) - SYMBOL_TYPE (sym) = builtin_type_int; - else if (SYMBOL_TYPE (sym) == builtin_type_unsigned_char - || SYMBOL_TYPE (sym) == builtin_type_unsigned_short) - SYMBOL_TYPE (sym) = builtin_type_unsigned_int; - break; - -#endif /* no BELIEVE_PCC_PROMOTION_TYPE. */ - - case 'P': - SYMBOL_CLASS (sym) = LOC_REGPARM; - SYMBOL_VALUE (sym) = STAB_REG_TO_REGNUM (valu); - SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; - add_symbol_to_list (sym, &local_symbols); - break; - - case 'r': - SYMBOL_CLASS (sym) = LOC_REGISTER; - SYMBOL_VALUE (sym) = STAB_REG_TO_REGNUM (valu); - SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; - add_symbol_to_list (sym, &local_symbols); - break; - - case 'S': - /* Static symbol at top level of file */ - SYMBOL_CLASS (sym) = LOC_STATIC; - SYMBOL_VALUE_ADDRESS (sym) = valu; - SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; - add_symbol_to_list (sym, &file_symbols); - break; - - case 't': - SYMBOL_CLASS (sym) = LOC_TYPEDEF; - SYMBOL_VALUE (sym) = valu; - SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; - if (TYPE_NAME (SYMBOL_TYPE (sym)) == 0 - && (TYPE_FLAGS (SYMBOL_TYPE (sym)) & TYPE_FLAG_PERM) == 0) - TYPE_NAME (SYMBOL_TYPE (sym)) = - obsavestring (SYMBOL_NAME (sym), - strlen (SYMBOL_NAME (sym))); - /* C++ vagaries: we may have a type which is derived from - a base type which did not have its name defined when the - derived class was output. We fill in the derived class's - base part member's name here in that case. */ - else if ((TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_STRUCT - || TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_UNION) - && TYPE_N_BASECLASSES (SYMBOL_TYPE (sym))) - { - int j; - for (j = TYPE_N_BASECLASSES (SYMBOL_TYPE (sym)) - 1; j >= 0; j--) - if (TYPE_BASECLASS_NAME (SYMBOL_TYPE (sym), j) == 0) - TYPE_BASECLASS_NAME (SYMBOL_TYPE (sym), j) = - type_name_no_tag (TYPE_BASECLASS (SYMBOL_TYPE (sym), j)); - } - - add_symbol_to_list (sym, &file_symbols); - break; - - case 'T': - SYMBOL_CLASS (sym) = LOC_TYPEDEF; - SYMBOL_VALUE (sym) = valu; - SYMBOL_NAMESPACE (sym) = STRUCT_NAMESPACE; - if (TYPE_NAME (SYMBOL_TYPE (sym)) == 0 - && (TYPE_FLAGS (SYMBOL_TYPE (sym)) & TYPE_FLAG_PERM) == 0) - TYPE_NAME (SYMBOL_TYPE (sym)) - = obconcat ("", - (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_ENUM - ? "enum " - : (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_STRUCT - ? "struct " : "union ")), - SYMBOL_NAME (sym)); - add_symbol_to_list (sym, &file_symbols); - - if (synonym) - { - register struct symbol *typedef_sym - = (struct symbol *) obstack_alloc (symbol_obstack, sizeof (struct symbol)); - SYMBOL_NAME (typedef_sym) = SYMBOL_NAME (sym); - SYMBOL_TYPE (typedef_sym) = SYMBOL_TYPE (sym); - - SYMBOL_CLASS (typedef_sym) = LOC_TYPEDEF; - SYMBOL_VALUE (typedef_sym) = valu; - SYMBOL_NAMESPACE (typedef_sym) = VAR_NAMESPACE; - add_symbol_to_list (typedef_sym, &file_symbols); - } - break; - - case 'V': - /* Static symbol of local scope */ - SYMBOL_CLASS (sym) = LOC_STATIC; - SYMBOL_VALUE_ADDRESS (sym) = valu; - SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; - add_symbol_to_list (sym, &local_symbols); - break; - - case 'v': - /* Reference parameter */ - SYMBOL_CLASS (sym) = LOC_REF_ARG; - SYMBOL_VALUE (sym) = valu; - SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; - add_symbol_to_list (sym, &local_symbols); - break; - - case 'X': - /* This is used by Sun FORTRAN for "function result value". - Sun claims ("dbx and dbxtool interfaces", 2nd ed) - that Pascal uses it too, but when I tried it Pascal used - "x:3" (local symbol) instead. */ - SYMBOL_CLASS (sym) = LOC_LOCAL; - SYMBOL_VALUE (sym) = valu; - SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; - add_symbol_to_list (sym, &local_symbols); - break; - - default: - error ("Invalid symbol data: unknown symbol-type code `%c' at symtab pos %d.", deftype, symnum); - } - return sym; -} - -#if 0 -/* This would be a good idea, but it doesn't really work. The problem - is that in order to get the virtual context for a particular type, - you need to know the virtual info from all of its basetypes, - and you need to have processed its methods. Since GDB reads - symbols on a file-by-file basis, this means processing the symbols - of all the files that are needed for each baseclass, which - means potentially reading in all the debugging info just to fill - in information we may never need. */ - -/* This page contains subroutines of read_type. */ - -/* FOR_TYPE is a struct type defining a virtual function NAME with type - FN_TYPE. The `virtual context' for this virtual function is the - first base class of FOR_TYPE in which NAME is defined with signature - matching FN_TYPE. OFFSET serves as a hash on matches here. - - TYPE is the current type in which we are searching. */ - -static struct type * -virtual_context (for_type, type, name, fn_type, offset) - struct type *for_type, *type; - char *name; - struct type *fn_type; - int offset; -{ - struct type *basetype = 0; - int i; - - if (for_type != type) - { - /* Check the methods of TYPE. */ - /* Need to do a check_stub_type here, but that breaks - things because we can get infinite regress. */ - for (i = TYPE_NFN_FIELDS (type) - 1; i >= 0; --i) - if (!strcmp (TYPE_FN_FIELDLIST_NAME (type, i), name)) - break; - if (i >= 0) - { - int j = TYPE_FN_FIELDLIST_LENGTH (type, i); - struct fn_field *f = TYPE_FN_FIELDLIST1 (type, i); - - while (--j >= 0) - if (TYPE_FN_FIELD_VOFFSET (f, j) == offset-1) - return TYPE_FN_FIELD_FCONTEXT (f, j); - } - } - for (i = TYPE_N_BASECLASSES (type) - 1; i >= 0; i--) - { - basetype = virtual_context (for_type, TYPE_BASECLASS (type, i), name, - fn_type, offset); - if (basetype != for_type) - return basetype; - } - return for_type; -} -#endif - -/* Copy a pending list, used to record the contents of a common - block for later fixup. */ -static struct pending * -copy_pending (beg, begi, end) - struct pending *beg, *end; - int begi; -{ - struct pending *new = 0; - struct pending *next; - - for (next = beg; next != 0 && (next != end || begi < end->nsyms); - next = next->next, begi = 0) - { - register int j; - for (j = begi; j < next->nsyms; j++) - add_symbol_to_list (next->symbol[j], &new); - } - return new; -} - -/* Register our willingness to decode symbols for SunOS and a.out and - b.out files handled by BFD... */ -static struct sym_fns sunos_sym_fns = {"sunOs", 6, - dbx_new_init, dbx_symfile_init, dbx_symfile_read}; - -static struct sym_fns aout_sym_fns = {"a.out", 5, - dbx_new_init, dbx_symfile_init, dbx_symfile_read}; - -static struct sym_fns bout_sym_fns = {"b.out", 5, - dbx_new_init, dbx_symfile_init, dbx_symfile_read}; - -void -_initialize_dbxread () -{ - add_symtab_fns(&sunos_sym_fns); - add_symtab_fns(&aout_sym_fns); - add_symtab_fns(&bout_sym_fns); -} diff --git a/gdb/defs.h b/gdb/defs.h deleted file mode 100644 index 52d84960202..00000000000 --- a/gdb/defs.h +++ /dev/null @@ -1,296 +0,0 @@ -/* Basic definitions for GDB, the GNU debugger. - Copyright (C) 1986, 1989, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#if !defined (DEFS_H) -#define DEFS_H - -/* An address in the program being debugged. Host byte order. */ -typedef unsigned int CORE_ADDR; - -#define min(a, b) ((a) < (b) ? (a) : (b)) -#define max(a, b) ((a) > (b) ? (a) : (b)) - -/* The character C++ uses to build identifiers that must be unique from - the program's identifiers (such as $this and $$vptr). */ -#define CPLUS_MARKER '$' /* May be overridden to '.' for SysV */ - -/* - * Allow things in gdb to be declared "const". If compiling ANSI, it - * just works. If compiling with gcc but non-ansi, redefine to __const__. - * If non-ansi, non-gcc, then eliminate "const" entirely, making those - * objects be read-write rather than read-only. - */ -#ifndef const -#ifndef __STDC__ -# ifdef __GNUC__ -# define const __const__ -# else -# define const /*nothing*/ -# endif /* GNUC */ -#endif /* STDC */ -#endif /* const */ - -#ifndef volatile -#ifndef __STDC__ -# ifdef __GNUC__ -# define volatile __volatile__ -# else -# define volatile /*nothing*/ -# endif /* GNUC */ -#endif /* STDC */ -#endif /* volatile */ - -extern char *savestring (); -extern char *strsave (); -extern char *concat (); -#ifdef __STDC__ -extern void *xmalloc (), *xrealloc (); -#else -extern char *xmalloc (), *xrealloc (); -#endif -extern void free (); -extern int parse_escape (); -extern char *reg_names[]; -/* Indicate that these routines do not return to the caller. */ -extern volatile void error(), fatal(); - -/* Various possibilities for alloca. */ -#ifndef alloca -# ifdef __GNUC__ -# define alloca __builtin_alloca -# else -# ifdef sparc -# include -# endif - extern char *alloca (); -# endif -#endif - -extern int errno; /* System call error return status */ - -extern int quit_flag; -extern int immediate_quit; -extern void quit (); - -#define QUIT { if (quit_flag) quit (); } - -/* Notes on classes: class_alias is for alias commands which are not - abbreviations of the original command. */ - -enum command_class -{ - /* Special args to help_list */ - 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_alias, class_obscure, class_user -}; - -/* 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 - argument to give it. - - Use make_cleanup to add an element to the cleanup chain. - Use do_cleanups to do all cleanup actions back to a given - point in the chain. Use discard_cleanups to remove cleanups - from the chain back to a given point, not doing them. */ - -struct cleanup -{ - struct cleanup *next; - void (*function) (); - int arg; -}; - -/* From utils.c. */ -extern void do_cleanups (); -extern void discard_cleanups (); -extern struct cleanup *make_cleanup (); -extern struct cleanup *save_cleanups (); -extern void restore_cleanups (); -extern void free_current_contents (); -extern int myread (); -extern int query (); -extern void wrap_here ( -#ifdef __STDC__ - char * -#endif - ); -extern void reinitialize_more_filter (); -extern void fputs_filtered (); -extern void puts_filtered (); -extern void fprintf_filtered (); -extern void printf_filtered (); -extern void print_spaces (); -extern void print_spaces_filtered (); -extern char *n_spaces (); -extern void printchar (); -extern void fprint_symbol (); -extern void fputs_demangled (); -extern void perror_with_name (); -extern void print_sys_errmsg (); - -/* From printcmd.c */ -extern void print_address_symbolic (); -extern void print_address (); - -/* From source.c */ -void mod_path ( -#ifdef __STDC__ - char *, char ** -#endif - ); - -/* From readline (but not in any readline .h files). */ -extern char *tilde_expand (); - -/* Structure for saved commands lines - (for breakpoints, defined commands, etc). */ - -struct command_line -{ - struct command_line *next; - char *line; -}; - -extern struct command_line *read_command_lines (); -extern void free_command_lines (); - -/* String containing the current directory (what getwd would return). */ - -char *current_directory; - -/* Default radixes for input and output. Only some values supported. */ -extern unsigned input_radix; -extern unsigned output_radix; - -/* Baud rate specified for communication with serial target systems. */ -char *baud_rate; - -#if !defined (UINT_MAX) -#define UINT_MAX 0xffffffff -#endif - -#if !defined (LONG_MAX) -#define LONG_MAX 0x7fffffff -#endif - -#if !defined (INT_MAX) -#define INT_MAX 0x7fffffff -#endif - -#if !defined (INT_MIN) -/* Two's complement, 32 bit. */ -#define INT_MIN -0x80000000 -#endif - -/* Number of bits in a char or unsigned char for the target machine. - Just like CHAR_BIT in but describes the target machine. */ -#if !defined (TARGET_CHAR_BIT) -#define TARGET_CHAR_BIT 8 -#endif - -/* Number of bits in a short or unsigned short for the target machine. */ -#if !defined (TARGET_SHORT_BIT) -#define TARGET_SHORT_BIT (sizeof (short) * TARGET_CHAR_BIT) -#endif - -/* Number of bits in an int or unsigned int for the target machine. */ -#if !defined (TARGET_INT_BIT) -#define TARGET_INT_BIT (sizeof (int) * TARGET_CHAR_BIT) -#endif - -/* Number of bits in a long or unsigned long for the target machine. */ -#if !defined (TARGET_LONG_BIT) -#define TARGET_LONG_BIT (sizeof (long) * TARGET_CHAR_BIT) -#endif - -/* Number of bits in a long long or unsigned long long for the target machine. */ -#if !defined (TARGET_LONG_LONG_BIT) -#define TARGET_LONG_LONG_BIT (2 * TARGET_LONG_BIT) -#endif - -/* Number of bits in a float for the target machine. */ -#if !defined (TARGET_FLOAT_BIT) -#define TARGET_FLOAT_BIT (sizeof (float) * TARGET_CHAR_BIT) -#endif - -/* Number of bits in a double for the target machine. */ -#if !defined (TARGET_DOUBLE_BIT) -#define TARGET_DOUBLE_BIT (sizeof (double) * TARGET_CHAR_BIT) -#endif - -/* Number of bits in a long double for the target machine. */ -#if !defined (TARGET_LONG_DOUBLE_BIT) -#define TARGET_LONG_DOUBLE_BIT (2 * TARGET_DOUBLE_BIT) -#endif - -/* Number of bits in a "complex" for the target machine. */ -#if !defined (TARGET_COMPLEX_BIT) -#define TARGET_COMPLEX_BIT (2 * TARGET_FLOAT_BIT) -#endif - -/* Number of bits in a "double complex" for the target machine. */ -#if !defined (TARGET_DOUBLE_COMPLEX_BIT) -#define TARGET_DOUBLE_COMPLEX_BIT (2 * TARGET_DOUBLE_BIT) -#endif - -/* Convert a LONGEST to an int. This is used in contexts (e.g. number - of arguments to a function, number in a value history, register - number, etc.) where the value must not be larger than can fit - in an int. */ -#if !defined (longest_to_int) -#if defined (LONG_LONG) -#define longest_to_int(x) (((x) > INT_MAX || (x) < INT_MIN) \ - ? error ("Value out of range.") : (int) (x)) -#else /* No LONG_LONG. */ -/* Assume sizeof (int) == sizeof (long). */ -#define longest_to_int(x) ((int) (x)) -#endif /* No LONG_LONG. */ -#endif /* No longest_to_int. */ - -/* Languages represented in the symbol table and elsewhere. */ - -enum language -{ - language_unknown, /* Language not known */ - language_auto, /* Placeholder for automatic setting */ - language_c, /* C */ - language_m2, /* Modula-2 */ -}; - -/* Return a format string for printf that will print a number in the local - (language-specific) hexadecimal format. Result is static and is - overwritten by the next call. local_hex_format_custom takes printf - options like "08" or "l" (to produce e.g. %08x or %lx). */ - -#define local_hex_format() (current_language->la_hex_format) -char *local_hex_format_custom(); /* language.c */ - -/* Return a string that contains a number formatted in the local - (language-specific) hexadecimal format. Result is static and is - overwritten by the next call. local_hex_string_custom takes printf - options like "08" or "l". */ - -char *local_hex_string (); /* language.c */ -char *local_hex_string_custom (); /* language.c */ - -#endif /* no DEFS_H */ diff --git a/gdb/depend b/gdb/depend deleted file mode 100755 index 73bff51ca8d..00000000000 --- a/gdb/depend +++ /dev/null @@ -1,12 +0,0 @@ -blockframe.o : blockframe.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status symtab.h \ - frame.h gdbcore.h ${srcdir}/../include/bfd.h ${srcdir}/../include/ansidecl.h value.h \ - target.h -breakpoint.o : breakpoint.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status symtab.h \ - frame.h breakpoint.h value.h expression.h gdbcore.h ${srcdir}/../include/bfd.h \ - ${srcdir}/../include/ansidecl.h gdbcmd.h command.h inferior.h target.h language.h -buildsym.o : buildsym.c defs.h param.h tm.h config.status param-no-tm.h xm.h config.status \ - ${srcdir}/../include/obstack.h symtab.h breakpoint.h value.h gdbcore.h \ - ${srcdir}/../include/bfd.h ${srcdir}/../include/ansidecl.h symfile.h \ - ${srcdir}/../include/stab.gnu.h ${srcdir}/../include/stab.def buildsym.h -c-exp.tab.o : c-exp.tab.c ${srcdir}/defs.h ${srcdir}/param.h tm.h config.status ${srcdir}/param-no-tm.h xm.h config.status \ - ${srcdir}/symtab.h ${srcdir}/frame.h ${srcdir}/expression.h ${srcdir}/parser-defs.h ${srcdir}/value.h ${srcdir}/language.h diff --git a/gdb/doc/.Sanitize b/gdb/doc/.Sanitize deleted file mode 100644 index de85865ab05..00000000000 --- a/gdb/doc/.Sanitize +++ /dev/null @@ -1,85 +0,0 @@ -# Sanitize.in for devo. -# $Id$ -# - -# Each directory to survive it's way into a release will need a file -# like this one called "./.Sanitize". All keyword lines must exist, -# and must exist in the order specified by this file. Each directory -# in the tree will be processed, top down, in the following order. - -# Hash started lines like this one are comments and will be deleted -# before anything else is done. Blank lines will also be squashed -# out. - -# The lines between the "Do-first:" line and the "Things-to-keep:" -# line are executed as a /bin/sh shell script before anything else is -# done in this - -Do-first: - -echo Sanitizing `pwd`... - -# All files listed between the "Things-to-keep:" line and the -# "Files-to-sed:" line will be kept. All other files will be removed. -# Directories listed in this section will have their own Sanitize -# called. Directories not listed will be removed in their entirety -# with rm -rf. - -Things-to-keep: - -Makefile -all.m4 -amd29k.m4 -gdbinv-m.m4 -gdbinv-s.m4 -gdb.texinfo -gdbint.texinfo -gen.m4 -i80386.m4 -i960.m4 -m680x0.m4 -none.m4 -pretex.m4 -rc-cm.tex -rc-ps.tex -rc-pslong.tex -rdl-apps.texi -refcard.tex -sparc.m4 -threecol.tex -vax.m4 - -Do-last: - -echo Done in `pwd`. - -# -# -# $Log$ -# Revision 2.6 1991/08/23 22:35:41 pesch -# * rdl-apps.texi: renamed from rdl-apps.texinfo -# -# * Makefile, .Sanitize, gdb.texinfo: reflect above name change -# -# Revision 2.5 1991/08/22 07:59:45 gnu -# Keep rdl-apps.texi for users who don't read the doc on how to build the doc. -# -# Revision 2.4 1991/08/07 00:15:02 pesch -# Makefile: GDB documentation nos has its own Makefile -# .Sanitize: add Makefile; recognize renamed refcard.tex (formerly gdbrc.tex) -# gdbint.texinfo: add markup in "Cleanups" chapter -# -# Revision 2.3 1991/08/01 22:34:55 pesch -# *** empty log message *** -# -# Revision 2.2 1991/07/29 22:38:53 pesch -# Updated list of files to keep to reflect reintegration of most fragments -# into gdb.texinfo. -# -# Revision 2.1 1991/05/23 21:57:03 rich -# First cut. -# -# -# - -# End of file. diff --git a/gdb/doc/Makefile b/gdb/doc/Makefile deleted file mode 100755 index db880a61b75..00000000000 --- a/gdb/doc/Makefile +++ /dev/null @@ -1,111 +0,0 @@ -##Copyright (C) 1991 Free Software Foundation, Inc. - -# Makefile for GDB documentation. -# 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., 675 Mass Ave, Cambridge, MA 02139, USA. - -# main GDB source directory -srcdir = .. - -# Documentation (gdb.dvi) needs either GNU m4 or SysV m4; -# Berkeley/Sun don't have quite enough. -#M4=/usr/5bin/m4 -M4=gm4 - -# where to find texinfo; GDB dist should include a recent one -TEXIDIR=${srcdir}/../texinfo/fsf - -# where to find makeinfo, preferably one designed for texinfo-2 -MAKEINFO=makeinfo - -# Where is the source dir for the READLINE library? Traditionally in .. or . -# (For the binary library built from it, we use ${READLINE_DIR}${subdir}.) -READLINE_DIR = ${srcdir}/../readline - -# Main GDB manual's source files -SFILES_DOCDIR = \ - gdb.texinfo pretex.m4 none.m4 all.m4 gdbinv-m.m4 gdbinv-s.m4 gdbVN.m4 - -all: gdb.info gdb.dvi refcard.dvi gdb-internals gdbint.dvi - -clean: - rm -f gdb.dvi rdl-apps.texi gdb-all* gdb.info* gdbVN.m4 - rm -f gdb-internals gdbint.?? gdbint.??? - rm -f refcard.ps refcard.dvi rcfonts.tex refcard.log *~ - -# GDB QUICK REFERENCE (TeX dvi file, CM fonts) -refcard.dvi : refcard.tex - rm -f rcfonts.tex; cp rc-cm.tex rcfonts.tex - TEXINPUTS=.:$$TEXINPUTS tex refcard.tex; rm -f refcard.log - rm -f rcfonts.tex - -# GDB QUICK REFERENCE (PostScript output, common PS fonts) -refcard.ps : refcard.tex - rm -f rcfonts.tex; cp rc-ps.tex rcfonts.tex - TEXINPUTS=.:$$TEXINPUTS tex refcard.tex - dvips -t landscape refcard -o; rm -f refcard.dvi refcard.log - rm -f rcfonts.tex - -# Cover file for "Readline" appendices -rdl-apps.texi: ${READLINE_DIR}/inc-readline.texinfo \ - ${READLINE_DIR}/inc-history.texinfo - rm -f rdl-apps.texi - echo "@include ${READLINE_DIR}/inc-readline.texinfo" >rdl-apps.texi - echo "@include ${READLINE_DIR}/inc-history.texinfo" >>rdl-apps.texi - -# File to record current GDB version number (copied from main dir Makefile.in) -gdbVN.m4 : ${srcdir}/Makefile.in - ( VER=`sed <${srcdir}/Makefile.in -n 's/VERSION = //p'` ;\ - echo "_define__(<_GDB_VN__>,$$VER)" > gdbVN.m4 ) - -# GDB MANUAL: texinfo source, created by preprocessing w/m4 -# Be sure to not create a bad gdb-all.texi if ${M4} is missing or aborts... -gdb-all.texi: ${SFILES_DOCDIR} - rm -f foobus.texinfo - ${M4} pretex.m4 none.m4 all.m4 gdb.texinfo >foobus.texinfo - rm -f gdb-all.texi - mv foobus.texinfo gdb-all.texi - -# GDB MANUAL: TeX dvi file -gdb.dvi : gdb-all.texi rdl-apps.texi - TEXINPUTS=${TEXIDIR}:.:$$TEXINPUTS tex gdb-all.texi - texindex gdb-all.?? - TEXINPUTS=${TEXIDIR}:.:$$TEXINPUTS tex gdb-all.texi - mv gdb-all.dvi gdb.dvi - rm -f gdb-all.?? gdb-all.??? - -# GDB MANUAL: info file -# We're using texinfo2, and older makeinfo's may not be able to -# cope with all the markup. In the meantime, we distribute the info -# files -gdb.info: gdb-all.texi - ${MAKEINFO} gdb-all.texi - -# GDB INTERNALS MANUAL: TeX dvi file -gdbint.dvi : gdbint.texinfo - TEXINPUTS=${TEXIDIR}:.:$$TEXINPUTS tex gdbint.texinfo - texindex gdbint.?? - TEXINPUTS=${TEXIDIR}:.:$$TEXINPUTS tex gdbint.texinfo - rm -f gdbint.?? gdbint.aux gdbint.cps gdbint.fns gdbint.kys \ - gdbint.log gdbint.pgs gdbint.toc gdbint.tps gdbint.vrs - -# GDB INTERNALS MANUAL: info file -gdb-internals : gdbint.texinfo - ${MAKEINFO} gdbint.texinfo - - - - diff --git a/gdb/doc/Makefile.in b/gdb/doc/Makefile.in deleted file mode 100644 index 628c1ccbcce..00000000000 --- a/gdb/doc/Makefile.in +++ /dev/null @@ -1,202 +0,0 @@ -##Copyright (C) 1991 Free Software Foundation, Inc. - -# Makefile for GDB documentation. -# 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., 675 Mass Ave, Cambridge, MA 02139, USA. - -srcdir = . - -ddestdir = /usr/local -idestdir = $(ddestdir) - -SHELL = /bin/sh - -# main GDB source directory -gdbdir = .. - -# Documentation (gdb.dvi) needs either GNU m4 or SysV m4; -# Berkeley/Sun don't have quite enough. -#M4=/usr/5bin/m4 -M4=gm4 - -# where to find texinfo; GDB dist should include a recent one -TEXIDIR=$(srcdir)/${gdbdir}/../texinfo/fsf - -# where to find makeinfo, preferably one designed for texinfo-2 -MAKEINFO=makeinfo - -# where to find texi2roff, ditto -TEXI2ROFF=texi2roff - -# Where is the source dir for the READLINE library? Traditionally in .. or . -# (For the binary library built from it, we use ${READLINE_DIR}${subdir}.) -READLINE_DIR = $(srcdir)/${gdbdir}/../readline - -# Main GDB manual's source files -SFILES_DOCDIR = \ - $(srcdir)/gdb.texinfo $(srcdir)/pretex.m4 $(srcdir)/none.m4 \ - $(srcdir)/all.m4 gdbinv-m.m4 gdbinv-s.m4 gdbVN.m4 - -# Which version of GDB manual? default includes everything -CONFIG=all - -all install: - -all-info: gdb.info gdbint.info -#all: gdb.info gdb.dvi refcard.dvi gdb-internals gdbint.dvi - -install-info: all-info - for i in *.info* ; do \ - echo Installing $$i... ; \ - (cp $$i $(idestdir)/info/$$i.n \ - && mv -f $(idestdir)/info/$$i.n $(idestdir)/info/$$i) \ - || exit 1 ; \ - done - -clean: - rm -f gdb.dvi rdl-apps.texi gdb-all* gdb.info* gdbVN.m4 - rm -f gdb-internals gdbint.?? gdbint.??? gdbint.info - rm -f refcard.ps refcard.dvi rcfonts.tex refcard.log *~ - -# GDB QUICK REFERENCE (TeX dvi file, CM fonts) -refcard.dvi : refcard.tex - rm -f rcfonts.tex; cp rc-cm.tex rcfonts.tex - TEXINPUTS=.:$$TEXINPUTS tex refcard.tex; rm -f refcard.log - rm -f rcfonts.tex - -# GDB QUICK REFERENCE (PostScript output, common PS fonts) -refcard.ps : refcard.tex - rm -f rcfonts.tex; cp rc-ps.tex rcfonts.tex - TEXINPUTS=.:$$TEXINPUTS tex refcard.tex - dvips -t landscape refcard -o; rm -f refcard.dvi refcard.log - rm -f rcfonts.tex - -# Cover file for "Readline" appendices -rdl-apps.texi: ${READLINE_DIR}/inc-read.texi \ - ${READLINE_DIR}/inc-hist.texi - rm -f rdl-apps.texi - echo "@include ${READLINE_DIR}/inc-read.texi" >rdl-apps.texi - echo "@include ${READLINE_DIR}/inc-hist.texi" >>rdl-apps.texi - -# File to record current GDB version number (copied from main dir Makefile.in) -gdbVN.m4 : ${gdbdir}/Makefile.in - ( VER=`sed <$(srcdir)/${gdbdir}/Makefile.in -n 's/VERSION = //p'` ;\ - echo "_define__(<_GDB_VN__>,$$VER)" > gdbVN.m4 ) - -# GDB MANUAL: texinfo source, created by preprocessing w/m4 -# If you want other configs in the makefile, add or modify instructions for -# building source here, then change CONFIG (that way you get info, dvi, -# roff targets automatically for your config). -# Be sure to not create a bad gdb-all.texi if ${M4} is missing or aborts... -gdb-all.texi: ${SFILES_DOCDIR} - rm -f foobus.texinfo - ${M4} $(srcdir)/pretex.m4 $(srcdir)/none.m4 $(srcdir)/all.m4 $(srcdir)/gdb.texinfo >foobus.texinfo - rm -f gdb-all.texi - mv foobus.texinfo gdb-all.texi - -# GDB MANUAL: TeX dvi file -gdb.dvi : gdb-${CONFIG}.texi rdl-apps.texi - TEXINPUTS=${TEXIDIR}:.:$$TEXINPUTS tex gdb-${CONFIG}.texi - texindex gdb-${CONFIG}.?? - TEXINPUTS=${TEXIDIR}:.:$$TEXINPUTS tex gdb-${CONFIG}.texi - mv gdb-${CONFIG}.dvi gdb.dvi - rm -f gdb-${CONFIG}.?? gdb-${CONFIG}.??? - -# GDB MANUAL: info file -# We're using texinfo2, and older makeinfo's may not be able to -# cope with all the markup. In the meantime, we distribute the info -# files -gdb.info: gdb-${CONFIG}.texi - $(MAKEINFO) -o gdb.info gdb-${CONFIG}.texi - -# GDB MANUAL: roff translations -# Try to use a recent texi2roff. v2 was put on prep in jan91. -# If you want an index, see texi2roff doc for postprocessing -# and add -i to texi2roff invocations below. -# Workarounds for texi2roff-2 (probably fixed in later texi2roff's, delete -# correspondint -e lines when later texi2roff's are current) -# + @ifinfo's deleted explicitly due to texi2roff-2 bug w nested constructs. -# + @c's deleted explicitly because texi2roff sees texinfo commands in them -# + @ (that's at-BLANK) not recognized by texi2roff, turned into blank -# + @alphaenumerate is ridiculously new, turned into @enumerate - - -# gdb manual suitable for [tn]roff -mm -# '@noindent's removed due to texi2roff-2 mm bug; if yours is newer, -# try leaving them in -gdb.mm: gdb-${CONFIG}.texi - sed -e '/\\input texinfo/d' \ - -e '/@c TEXI2ROFF-KILL/,/@c END TEXI2ROFF-KILL/d' \ - -e '/^@ifinfo/,/^@end ifinfo/d' \ - -e '/^@c/d' \ - -e 's/{.*,,/{/' \ - -e '/@noindent/d' \ - -e 's/@ / /g' \ - -e 's/^@alphaenumerate/@enumerate/g' \ - -e 's/^@end alphaenumerate/@end enumerate/g' \ - gdb-${CONFIG}.texi | \ - $(TEXI2ROFF) -mm | \ - sed -e 's/---/\\(em/g' \ - >gdb.mm - -# gdb manual suitable for [gtn]roff -me -gdb.me: gdb-${CONFIG}.texi - sed -e '/\\input texinfo/d' \ - -e '/@c TEXI2ROFF-KILL/,/@c END TEXI2ROFF-KILL/d' \ - -e '/^@ifinfo/,/^@end ifinfo/d' \ - -e '/^@c/d' \ - -e 's/{.*,,/{/' \ - -e 's/@ / /g' \ - -e 's/^@alphaenumerate/@enumerate/g' \ - -e 's/^@end alphaenumerate/@end enumerate/g' \ - gdb-${CONFIG}.texi | \ - $(TEXI2ROFF) -me | \ - sed -e 's/---/\\(em/g' \ - >gdb.me - -# gdb manual suitable for [gtn]roff -ms -gdb.ms: gdb-${CONFIG}.texi - sed -e '/\\input texinfo/d' \ - -e '/@c TEXI2ROFF-KILL/,/@c END TEXI2ROFF-KILL/d' \ - -e '/^@ifinfo/,/^@end ifinfo/d' \ - -e '/^@c/d' \ - -e 's/{.*,,/{/' \ - -e 's/@ / /g' \ - -e 's/^@alphaenumerate/@enumerate/g' \ - -e 's/^@end alphaenumerate/@end enumerate/g' \ - gdb-${CONFIG}.texi | \ - $(TEXI2ROFF) -ms | \ - sed -e 's/---/\\(em/g' \ - >gdb.ms - -# GDB INTERNALS MANUAL: TeX dvi file -gdbint.dvi : gdbint.texinfo - TEXINPUTS=${TEXIDIR}:.:$$TEXINPUTS tex gdbint.texinfo - texindex gdbint.?? - TEXINPUTS=${TEXIDIR}:.:$$TEXINPUTS tex gdbint.texinfo - rm -f gdbint.?? gdbint.aux gdbint.cps gdbint.fns gdbint.kys \ - gdbint.log gdbint.pgs gdbint.toc gdbint.tps gdbint.vrs - -# GDB INTERNALS MANUAL: info file -gdb-internals: gdbint.info - -gdbint.info: gdbint.texinfo - $(MAKEINFO) -o gdbint.info $(srcdir)/gdbint.texinfo - -force: - -Makefile: $(srcdir)/Makefile.in $(host_makefile_frag) $(target_makefile_frag) - $(SHELL) ./config.status diff --git a/gdb/doc/all.m4 b/gdb/doc/all.m4 deleted file mode 100644 index 4d97fbee6ce..00000000000 --- a/gdb/doc/all.m4 +++ /dev/null @@ -1,18 +0,0 @@ -_divert__(-1) -_define__(<_ALL_ARCH__>,<1>) -_define__(<_GENERIC__>,<1>) In case none.m4 changes its mind abt default - -_define__(<_AOUT__>,<1>) -_define__(<_BOUT__>,<1>) -_define__(<_COFF__>,<1>) -_define__(<_ELF__>,<1>) - -_define__(<_AMD29K__>,<1>) -_define__(<_I80386__>,<1>) -_define__(<_I960__>,<1>) -_define__(<_M680X0__>,<1>) -_define__(<_SPARC__>,<1>) -_define__(<_VAX__>,<1>) -_define__(<_VXWORKS__>,<1>) - -_divert__<> \ No newline at end of file diff --git a/gdb/doc/amd29k.m4 b/gdb/doc/amd29k.m4 deleted file mode 100644 index cf3ba386c26..00000000000 --- a/gdb/doc/amd29k.m4 +++ /dev/null @@ -1,5 +0,0 @@ -_divert__(-1) -_define__(<_AMD29K__>,<1>) -_define__(<_HOST__>,) -_define__(<_MACH_DEP__>, -_divert__<> \ No newline at end of file diff --git a/gdb/doc/configure.in b/gdb/doc/configure.in deleted file mode 100644 index a03a968ba37..00000000000 --- a/gdb/doc/configure.in +++ /dev/null @@ -1,8 +0,0 @@ -srcname="GDB doc" -srctrigger=gdb.texinfo -# per-host: - -# per-target: - -files="gdbinv-m.m4.in gdbinv-s.m4.in" -links="gdbinv-m.m4 gdbinv-s.m4" diff --git a/gdb/doc/gdb.alter-m4 b/gdb/doc/gdb.alter-m4 deleted file mode 100755 index 56007dd9650..00000000000 --- a/gdb/doc/gdb.alter-m4 +++ /dev/null @@ -1,205 +0,0 @@ -_dnl__ Copyright (c) 1988 1989 1990 1991 Free Software Foundation, Inc. -_dnl__ This file is part of the source for the GDB manual. -@c M4 FRAGMENT: $Id$ -@node Altering, _GDBN__ Files, Symbols, Top -@chapter Altering Execution - -Once you think you have found an error in the program, you might want to -find out for certain whether correcting the apparent error would lead to -correct results in the rest of the run. You can find the answer by -experiment, using the _GDBN__ features for altering execution of the -program. - -For example, you can store new values into variables or memory -locations, give the program a signal, restart it at a different address, -or even return prematurely from a function to its caller. - -@menu -* Assignment:: Assignment to Variables -* Jumping:: Continuing at a Different Address -* Signaling:: Giving the Program a Signal -* Returning:: Returning from a Function -* Calling:: Calling your Program's Functions -@end menu - -@node Assignment, Jumping, Altering, Altering -@section Assignment to Variables - -@cindex assignment -@cindex setting variables -To alter the value of a variable, evaluate an assignment expression. -@xref{Expressions}. For example, - -@example -print x=4 -@end example - -@noindent -would store the value 4 into the variable @code{x}, and then print the -value of the assignment expression (which is 4). All the assignment -operators of C are supported, including the increment operators -@samp{++} and @samp{--}, and combining assignments such as @samp{+=} and -_0__@samp{<<=}_1__. - -@kindex set -@kindex set variable -@cindex variables, setting -If you are not interested in seeing the value of the assignment, use the -@code{set} command instead of the @code{print} command. @code{set} is -really the same as @code{print} except that the expression's value is not -printed and is not put in the value history (@pxref{Value History}). The -expression is evaluated only for its effects. - -If the beginning of the argument string of the @code{set} command -appears identical to a @code{set} subcommand, use the @code{set -variable} command instead of just @code{set}. This command is identical -to @code{set} except for its lack of subcommands. For example, a -program might well have a variable @code{width}---which leads to -an error if we try to set a new value with just @samp{set width=13}, as -we might if @code{set width} didn't happen to be a _GDBN__ command: -@example -(_GDBP__) whatis width -type = double -(_GDBP__) p width -$4 = 13 -(_GDBP__) set width=47 -Invalid syntax in expression. -@end example -@noindent -The invalid expression, of course, is @samp{=47}. What we can do in -order to actually set our program's variable @code{width} is -@example -(_GDBP__) set var width=47 -@end example - -_GDBN__ allows more implicit conversions in assignments than C does; you can -freely store an integer value into a pointer variable or vice versa, and -any structure can be converted to any other structure that is the same -length or shorter. -@comment FIXME: how do structs align/pad in these conversions? -@comment /pesch@cygnus.com 18dec1990 - -To store values into arbitrary places in memory, use the @samp{@{@dots{}@}} -construct to generate a value of specified type at a specified address -(@pxref{Expressions}). For example, @code{@{int@}0x83040} refers -to memory location @code{0x83040} as an integer (which implies a certain size -and representation in memory), and - -@example -set @{int@}0x83040 = 4 -@end example - -@noindent -stores the value 4 into that memory location. - -@node Jumping, Signaling, Assignment, Altering -@section Continuing at a Different Address - -Ordinarily, when you continue the program, you do so at the place where -it stopped, with the @code{continue} command. You can instead continue at -an address of your own choosing, with the following commands: - -@table @code -@item jump @var{linespec} -@kindex jump -Resume execution at line @var{linespec}. Execution will stop -immediately if there is a breakpoint there. @xref{List} for a -description of the different forms of @var{linespec}. - -The @code{jump} command does not change the current stack frame, or -the stack pointer, or the contents of any memory location or any -register other than the program counter. If line @var{linespec} is in -a different function from the one currently executing, the results may -be bizarre if the two functions expect different patterns of arguments or -of local variables. For this reason, the @code{jump} command requests -confirmation if the specified line is not in the function currently -executing. However, even bizarre results are predictable if you are -well acquainted with the machine-language code of the program. - -@item jump *@var{address} -Resume execution at the instruction at address @var{address}. -@end table - -You can get much the same effect as the @code{jump} command by storing a -new value into the register @code{$pc}. The difference is that this -does not start the program running; it only changes the address where it -@emph{will} run when it is continued. For example, - -@example -set $pc = 0x485 -@end example - -@noindent -causes the next @code{continue} command or stepping command to execute at -address 0x485, rather than at the address where the program stopped. -@xref{Stepping}. - -The most common occasion to use the @code{jump} command is to back up, -perhaps with more breakpoints set, over a portion of a program that has -already executed, in order to examine its execution in more detail. - -@node Signaling, Returning, Jumping, Altering -@c @group -@section Giving the Program a Signal - -@table @code -@item signal @var{signalnum} -@kindex signal -Resume execution where the program stopped, but give it immediately the -signal number @var{signalnum}. - -Alternatively, if @var{signalnum} is zero, continue execution without -giving a signal. This is useful when the program stopped on account of -a signal and would ordinary see the signal when resumed with the -@code{continue} command; @samp{signal 0} causes it to resume without a -signal. - -@code{signal} does not repeat when you press @key{RET} a second time -after executing the command. -@end table -@c @end group - -@node Returning, Calling, Signaling, Altering -@section Returning from a Function - -@table @code -@item return -@itemx return @var{expression} -@cindex returning from a function -@kindex return -You can cancel execution of a function call with the @code{return} -command. If you give an -@var{expression} argument, its value is used as the function's return -value. -@end table - -When you use @code{return}, _GDBN__ discards the selected stack frame -(and all frames within it). You can think of this as making the -discarded frame return prematurely. If you wish to specify a value to -be returned, give that value as the argument to @code{return}. - -This pops the selected stack frame (@pxref{Selection}), and any other -frames inside of it, leaving its caller as the innermost remaining -frame. That frame becomes selected. The specified value is stored in -the registers used for returning values of functions. - -The @code{return} command does not resume execution; it leaves the -program stopped in the state that would exist if the function had just -returned. In contrast, the @code{finish} command (@pxref{Stepping}) -resumes execution until the selected stack frame returns naturally. - -@node Calling, , Returning, Altering -@section Calling your Program's Functions - -@cindex calling functions -@kindex call -@table @code -@item call @var{expr} -Evaluate the expression @var{expr} without displaying @code{void} -returned values. -@end table - -You can use this variant of the @code{print} command if you want to -execute a function from your program, but without cluttering the output -with @code{void} returned values. The result is printed and saved in -the value history, if it is not void. diff --git a/gdb/doc/gdb.bugs-m4 b/gdb/doc/gdb.bugs-m4 deleted file mode 100755 index 96479269fd5..00000000000 --- a/gdb/doc/gdb.bugs-m4 +++ /dev/null @@ -1,221 +0,0 @@ -_dnl__ Copyright (c) 1990 1991 Free Software Foundation, Inc. -_dnl__ This file is part of the source for the GDB manual. -@c M4 FRAGMENT: $Id$ -@node _GDBN__ Bugs, Renamed Commands, Emacs, Top -@chapter Reporting Bugs in _GDBN__ -@cindex Bugs in _GDBN__ -@cindex Reporting Bugs in _GDBN__ - -Your bug reports play an essential role in making _GDBN__ reliable. - -Reporting a bug may help you by bringing a solution to your problem, or it -may not. But in any case the principal function of a bug report is to help -the entire community by making the next version of _GDBN__ work better. Bug -reports are your contribution to the maintenance of _GDBN__. - -In order for a bug report to serve its purpose, you must include the -information that enables us to fix the bug. - -@menu -* Bug Criteria:: Have You Found a Bug? -* Bug Reporting:: How to Report Bugs -@end menu - -@node Bug Criteria, Bug Reporting, _GDBN__ Bugs, _GDBN__ Bugs -@section Have You Found a Bug? -@cindex Bug Criteria - -If you are not sure whether you have found a bug, here are some guidelines: - -@itemize @bullet -@item -@cindex Fatal Signal -@cindex Core Dump -If the debugger gets a fatal signal, for any input whatever, that is a -_GDBN__ bug. Reliable debuggers never crash. - -@item -@cindex error on Valid Input -If _GDBN__ produces an error message for valid input, that is a bug. - -@item -@cindex Invalid Input -If _GDBN__ does not produce an error message for invalid input, -that is a bug. However, you should note that your idea of -``invalid input'' might be our idea of ``an extension'' or ``support -for traditional practice''. - -@item -If you are an experienced user of debugging tools, your suggestions -for improvement of _GDBN__ are welcome in any case. -@end itemize - -@node Bug Reporting, , Bug Criteria, _GDBN__ Bugs -@section How to Report Bugs -@cindex Bug Reports -@cindex Compiler Bugs, Reporting - -A number of companies and individuals offer support for GNU products. -If you obtained _GDBN__ from a support organization, we recommend you -contact that organization first. - -Contact information for many support companies and individuals is -available in the file @file{etc/SERVICE} in the GNU Emacs distribution. - -In any event, we also recommend that you send bug reports for _GDBN__ to one -of these addresses: - -@example -bug-gdb@@prep.ai.mit.edu -@{ucbvax|mit-eddie|uunet@}!prep.ai.mit.edu!bug-gdb -@end example - -@strong{Do not send bug reports to @samp{info-gdb}, or to -@samp{help-gdb}, or to any newsgroups.} Most users of _GDBN__ do not want to -receive bug reports. Those that do, have arranged to receive @samp{bug-gdb}. - -The mailing list @samp{bug-gdb} has a newsgroup which serves as a -repeater. The mailing list and the newsgroup carry exactly the same -messages. Often people think of posting bug reports to the newsgroup -instead of mailing them. This appears to work, but it has one problem -which can be crucial: a newsgroup posting often lacks a mail path -back to the sender. Thus, if we need to ask for more information, 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 -GNU Debugger Bugs -545 Tech Square -Cambridge, MA 02139 -@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! - -Often people omit facts because they think they know what causes the -problem and assume that some details don't matter. Thus, you might -assume that the name of the variable you use in an example does not matter. -Well, probably it doesn't, but one cannot be sure. Perhaps the bug is a -stray memory reference which happens to fetch from the location where that -name is stored in memory; perhaps, if the name were different, the contents -of that location would fool the debugger into doing the right thing despite -the bug. Play it safe and give a specific, complete example. That is the -easiest thing for you to do, and the most helpful. - -Keep in mind that the purpose of a bug report is to enable us to fix -the bug if it is new to us. It isn't as important what happens if -the bug is already known. Therefore, always write your bug reports on -the assumption that the bug has not been reported previously. - -Sometimes people give a few sketchy facts and ask, ``Does this ring a -bell?'' Those bug reports are useless, and we urge everyone to -@emph{refuse to respond to them} except to chide the sender to report -bugs properly. - -To enable us to fix the bug, you should include all these things: - -@itemize @bullet -@item -The version of _GDBN__. _GDBN__ announces it if you start with no -arguments; you can also print it at any time using @code{show version}. - -Without this, we won't know whether there is any point in looking for -the bug in the current version of _GDBN__. - -@item -A complete input script, and all necessary source files, that will -reproduce the bug. - -@item -What compiler (and its version) was used to compile _GDBN__---e.g. -``_GCC__-1.37.1''. - -@item -The command arguments you gave the compiler to compile your example and -observe the bug. For example, did you use @samp{-O}? To guarantee -you won't omit something important, list them all. - -If we were to try to guess the arguments, we would probably guess wrong -and then we might not encounter the bug. - -@item -The type of machine you are using, and the operating system name and -version number. - -@item -A description of what behavior you observe that you believe is -incorrect. For example, ``It gets a fatal signal.'' - -Of course, if the bug is that _GDBN__ gets a fatal signal, then we will -certainly notice it. But if the bug is incorrect output, we might not -notice unless it is glaringly wrong. We are human, after all. You -might as well not give us a chance to make a mistake. - -Even if the problem you experience is a fatal signal, you should still -say so explicitly. Suppose something strange is going on, such as, -your copy of _GDBN__ is out of synch, or you have encountered a -bug in the C library on your system. (This has happened!) Your copy -might crash and ours would not. If you told us to expect a crash, -then when ours fails to crash, we would know that the bug was not -happening for us. If you had not told us to expect a crash, then we -would not be able to draw any conclusion from our observations. - -@item -If you wish to suggest changes to the _GDBN__ source, send us context -diffs. If you even discuss something in the _GDBN__ source, refer to -it by context, not by line number. - -The line numbers in our development sources won't match those in your -sources. Your line numbers would convey no useful information to us. - -@end itemize - -Here are some things that are not necessary: - -@itemize @bullet -@item -A description of the envelope of the bug. - -Often people who encounter a bug spend a lot of time investigating -which changes to the input file will make the bug go away and which -changes will not affect it. - -This is often time consuming and not very useful, because the way we -will find the bug is by running a single example under the debugger -with breakpoints, not by pure deduction from a series of examples. -We recommend that you save your time for something else. - -Of course, if you can find a simpler example to report @emph{instead} -of the original one, that is a convenience for us. Errors in the -output will be easier to spot, running under the debugger will take -less time, etc. - -However, simplification is not vital; if you don't want to do this, -report the bug anyway and send us the entire test case you used. - -@item -A patch for the bug. - -A patch for the bug does help us if it is a good one. But don't omit -the necessary information, such as the test case, on the assumption that -a patch is all we need. We might see problems with your patch and decide -to fix the problem another way, or we might not understand it at all. - -Sometimes with a program as complicated as _GDBN__ it is very hard to -construct an example that will make the program follow a certain path -through the code. If you don't send us the example, we won't be able -to construct one, so we won't be able to verify that the bug is fixed. - -And if we can't understand what bug you are trying to fix, or why your -patch should be an improvement, we won't install it. A test case will -help us to understand. - -@item -A guess about what the bug is or what it depends on. - -Such guesses are usually wrong. Even we can't guess right about such -things without first using the debugger to find the facts. -@end itemize diff --git a/gdb/doc/gdb.canned-m4 b/gdb/doc/gdb.canned-m4 deleted file mode 100755 index 4cbb8f4d5e2..00000000000 --- a/gdb/doc/gdb.canned-m4 +++ /dev/null @@ -1,178 +0,0 @@ -_dnl__ Copyright (c) 1988 1989 1990 1991 Free Software Foundation, Inc. -_dnl__ This file is part of the source for the GDB manual. -@c M4 FRAGMENT: $Id$ -@node Sequences, Emacs, Controlling _GDBN__, Top -@chapter Canned Sequences of Commands - -Aside from breakpoint commands (@pxref{Break Commands}), _GDBN__ provides two -ways to store sequences of commands for execution as a unit: -user-defined commands and command files. - -@menu -* Define:: User-Defined Commands -* Command Files:: Command Files -* Output:: Commands for Controlled Output -@end menu - -@node Define, Command Files, Sequences, Sequences -@section User-Defined Commands - -@cindex user-defined command -A @dfn{user-defined command} is a sequence of _GDBN__ commands to which you -assign a new name as a command. This is done with the @code{define} -command. - -@table @code -@item define @var{commandname} -@kindex define -Define a command named @var{commandname}. If there is already a command -by that name, you are asked to confirm that you want to redefine it. - -The definition of the command is made up of other _GDBN__ command lines, -which are given following the @code{define} command. The end of these -commands is marked by a line containing @code{end}. - -@item document @var{commandname} -@kindex document -Give documentation to the user-defined command @var{commandname}. The -command @var{commandname} must already be defined. This command reads -lines of documentation just as @code{define} reads the lines of the -command definition, ending with @code{end}. After the @code{document} -command is finished, @code{help} on command @var{commandname} will print -the documentation you have specified. - -You may use the @code{document} command again to change the -documentation of a command. Redefining the command with @code{define} -does not change the documentation. - -@item help user-defined -@kindex help user-defined -List all user-defined commands, with the first line of the documentation -(if any) for each. - -@item info user -@itemx info user @var{commandname} -@kindex info user -Display the _GDBN__ commands used to define @var{commandname} (but not its -documentation). If no @var{commandname} is given, display the -definitions for all user-defined commands. -@end table - -User-defined commands do not take arguments. When they are executed, the -commands of the definition are not printed. An error in any command -stops execution of the user-defined command. - -Commands that would ask for confirmation if used interactively proceed -without asking when used inside a user-defined command. Many _GDBN__ commands -that normally print messages to say what they are doing omit the messages -when used in a user-defined command. - -@node Command Files, Output, Define, Sequences -@section Command Files - -@cindex command files -A command file for _GDBN__ is a file of lines that are _GDBN__ commands. Comments -(lines starting with @kbd{#}) may also be included. An empty line in a -command file does nothing; it does not mean to repeat the last command, as -it would from the terminal. - -@cindex init file -@cindex @file{_GDBINIT__} -When you start _GDBN__, it automatically executes commands from its -@dfn{init files}. These are files named @file{_GDBINIT__}. _GDBN__ -reads the init file (if any) in your home directory and then the init -file (if any) in the current working directory. (The init files are not -executed if you use the @samp{-nx} option; @pxref{Mode Options}.) You -can also request the execution of a command file with the @code{source} -command: - -@table @code -@item source @var{filename} -@kindex source -Execute the command file @var{filename}. -@end table - -The lines in a command file are executed sequentially. They are not -printed as they are executed. An error in any command terminates execution -of the command file. - -Commands that would ask for confirmation if used interactively proceed -without asking when used in a command file. Many _GDBN__ commands that -normally print messages to say what they are doing omit the messages -when called from command files. - -@node Output, , Command Files, Sequences -@section Commands for Controlled Output - -During the execution of a command file or a user-defined command, normal -_GDBN__ output is suppressed; the only output that appears is what is -explicitly printed by the commands in the definition. This section -describes three commands useful for generating exactly the output you -want. - -@table @code -@item echo @var{text} -@kindex echo -@c I don't consider backslash-space a standard C escape sequence -@c because it's not in ANSI. -Print @var{text}. Nonprinting characters can be included in @var{text} -using C escape sequences, such as @samp{\n} to print a newline. @b{No -newline will be printed unless you specify one.} In addition to the -standard C escape sequences, a backslash followed by a space stands for a -space. This is useful for outputting a string with spaces at the -beginning or the end, since leading and trailing spaces are otherwise -trimmed from all arguments. Thus, to print @samp{@ and foo =@ }, use the -command @samp{echo \@ and foo = \@ }. -@c FIXME: verify hard copy actually issues enspaces for '@ '! Will this -@c confuse texinfo? - -A backslash at the end of @var{text} can be used, as in C, to continue -the command onto subsequent lines. For example, - -@example -echo This is some text\n\ -which is continued\n\ -onto several lines.\n -@end example - -produces the same output as - -@example -echo This is some text\n -echo which is continued\n -echo onto several lines.\n -@end example - -@item output @var{expression} -@kindex output -Print the value of @var{expression} and nothing but that value: no -newlines, no @samp{$@var{nn} = }. The value is not entered in the -value history either. @xref{Expressions} for more information on -expressions. - -@item output/@var{fmt} @var{expression} -Print the value of @var{expression} in format @var{fmt}. You can use -the same formats as for @code{print}; @pxref{Output formats}, for more -information. - -@item printf @var{string}, @var{expressions}@dots{} -@kindex printf -Print the values of the @var{expressions} under the control of -@var{string}. The @var{expressions} are separated by commas and may -be either numbers or pointers. Their values are printed as specified -by @var{string}, exactly as if the program were to execute - -@example -printf (@var{string}, @var{expressions}@dots{}); -@end example - -For example, you can print two values in hex like this: - -@example -printf "foo, bar-foo = 0x%x, 0x%x\n", foo, bar-foo -@end example - -The only backslash-escape sequences that you can use in the format -string are the simple ones that consist of backslash followed by a -letter. -@end table diff --git a/gdb/doc/gdb.cmds-m4 b/gdb/doc/gdb.cmds-m4 deleted file mode 100755 index 1020258b248..00000000000 --- a/gdb/doc/gdb.cmds-m4 +++ /dev/null @@ -1,160 +0,0 @@ -_dnl__ Copyright (c) 1988 1989 1990 1991 Free Software Foundation, Inc. -_dnl__ This file is part of the source for the GDB manual. -@c M4 FRAGMENT: $Id$ -@node Commands, Running, Invocation, Top -@chapter _GDBN__ Commands - -@menu -* Command Syntax:: Command Syntax -* Help:: Getting Help -@end menu - -@node Command Syntax, Help, Commands, Commands -@section Command Syntax -A _GDBN__ command is a single line of input. There is no limit on how long -it can be. It starts with a command name, which is followed by arguments -whose meaning depends on the command name. For example, the command -@code{step} accepts an argument which is the number of times to step, -as in @samp{step 5}. You can also use the @code{step} command with -no arguments. Some command names do not allow any arguments. - -@cindex abbreviation -_GDBN__ command names may always be truncated if that abbreviation is -unambiguous. Other possible command abbreviations are listed in the -documentation for individual commands. Sometimes even ambiguous -abbreviations are allowed; for example, @code{s} is specially defined as -equivalent to @code{step} even though there are other commands whose -names start with @code{s}. - -@cindex repeating commands -A blank line as input to _GDBN__ means to repeat the previous command. -Certain commands (for example, @code{run}) will not repeat this way; -these are commands for which unintentional repetition might cause -trouble and which you are unlikely to want to repeat. - -The @code{list} and @code{x} commands construct new arguments when -repeated, rather than repeating exactly as typed, to permit easy -scanning of source or memory. - -@kindex # -@cindex comment -A line of input starting with @kbd{#} is a comment; it does nothing. -This is useful mainly in command files (@xref{Command Files}). - -@node Help, , Command Syntax, Commands -@section Getting Help -@cindex online documentation -@kindex help -You can always ask _GDBN__ itself for information on its commands, using the -command @code{help}. - -@table @code -@item help -@itemx h -@kindex h -You can use @code{help} (abbreviated @code{h}) with no arguments to -display a short list of named categories of commands: -@smallexample -(_GDBP__) help -List of classes of commands: - -running -- Running the program -stack -- Examining the stack -data -- Examining data -breakpoints -- Making program stop at certain points -files -- Specifying and examining files -status -- Status inquiries -support -- Support facilities -user-defined -- User-defined commands -aliases -- Aliases of other commands -obscure -- Obscure features - -Type "help" followed by a class name for a list of commands in that class. -Type "help" followed by command name for full documentation. -Command name abbreviations are allowed if unambiguous. -(_GDBP__) -@end smallexample - -@item help @var{category} -Using one of the general help categories as an argument, you can get a -list of the individual commands in a category. For example, here is the -help display for category @code{status}: -@smallexample -(_GDBP__) help status -Status inquiries. - -List of commands: - -show -- Generic command for showing things set with "set" -info -- Generic command for printing status - -Type "help" followed by command name for full documentation. -Command name abbreviations are allowed if unambiguous. -(_GDBP__) -@end smallexample - -@item help @var{command} -With a command name as @code{help} argument, _GDBN__ will display a -short paragraph on how to use that command. -@end table - -In addition to @code{help}, you can use the _GDBN__ commands @code{info} -and @code{show} to inquire about the state of your program, or the state -of _GDBN__ itself. Both commands support many topics of inquiry; this -manual introduces each of them in the appropriate context. The listings -under @code{info} and under @code{show} in the Index point to -all the sub-commands. -@c FIXME: @pxref{Index} used to be here, but even though it shows up in -@c FIXME...the 'aux' file with a pageno the xref can't find it. - -@c @group -@table @code -@item info -@kindex info -@kindex i -This command (abbreviated @code{i}) is for describing the state of your -program; for example, it can list the arguments given to your program -(@code{info args}), the registers currently in use (@code{info -registers}), or the breakpoints you've set (@code{info breakpoints}). -You can get a complete list of the @code{info} sub-commands with -@w{@code{help info}}. - -@kindex show -@item show -In contrast, @code{show} is for describing the state of _GDBN__ itself. -You can change most of the things you can @code{show}, by using the -related command @code{set}; for example, you can control what number -system is used for displays with @code{set radix}, or simply inquire -which is currently in use with @code{show radix}. - -@kindex info set -To display all the settable parameters and their current -values, you can use @code{show} with no arguments; you may also use -@code{info set}. Both commands produce the same display. -@c FIXME: "info set" violates the rule that "info" is for state of -@c FIXME...program. Ck w/ GNU: "info set" to be called something else, -@c FIXME...or change desc of rule---eg "state of prog and debugging session"? -@end table -@c @end group - -Here are three miscellaneous @code{show} subcommands, all of which are -exceptional in lacking corresponding @code{set} commands: - -@table @code -@kindex show version -@item show version -Show what version of _GDBN__ is running. You should include this -information in _GDBN__ bug-reports. If multiple versions of _GDBN__ are -in use at your site, you may occasionally want to make sure what version -of _GDBN__ you're running; as _GDBN__ evolves, new commands are -introduced, and old ones may wither away. The version number is also -announced when you start _GDBN__ with no arguments. - -@kindex show copying -@item show copying -Display information about permission for copying _GDBN__. - -@kindex show warranty -@item show warranty -Display the GNU ``NO WARRANTY'' statement. -@end table diff --git a/gdb/doc/gdb.ctl-m4 b/gdb/doc/gdb.ctl-m4 deleted file mode 100755 index 4ff4a168c75..00000000000 --- a/gdb/doc/gdb.ctl-m4 +++ /dev/null @@ -1,306 +0,0 @@ -_dnl__ Copyright (c) 1988 1989 1990 1991 Free Software Foundation, Inc. -_dnl__ This file is part of the source for the GDB manual. -@c M4 FRAGMENT: $Id$ -@node Controlling _GDBN__, Sequences, Targets, Top -@chapter Controlling _GDBN__ - -You can alter many aspects of _GDBN__'s interaction with you by using -the @code{set} command. For commands controlling how _GDBN__ displays -data, @pxref{Print Settings}; other settings are described here. - -@menu -* Prompt:: Prompt -* Editing:: Command Editing -* History:: Command History -* Screen Size:: Screen Size -* Numbers:: Numbers -* Messages/Warnings:: Optional Warnings and Messages -@end menu - -@node Prompt, Editing, Controlling _GDBN__, Controlling _GDBN__ -@section Prompt -@cindex prompt -_GDBN__ indicates its readiness to read a command by printing a string -called the @dfn{prompt}. This string is normally @samp{(_GDBP__)}. You -can change the prompt string with the @code{set prompt} command. For -instance, when debugging _GDBN__ with _GDBN__, it is useful to change -the prompt in one of the _GDBN__<>s so that you can always tell which -one you are talking to. - -@table @code -@item set prompt @var{newprompt} -@kindex set prompt -Directs _GDBN__ to use @var{newprompt} as its prompt string henceforth. -@kindex show prompt -@item show prompt -Prints a line of the form: @samp{Gdb's prompt is: @var{your-prompt}} -@end table - -@node Editing, History, Prompt, Controlling _GDBN__ -@section Command Editing -@cindex readline -@cindex command line editing -_GDBN__ reads its input commands via the @dfn{readline} interface. This -GNU library provides consistent behavior for programs which provide a -command line interface to the user. Advantages are @code{emacs}-style -or @code{vi}-style inline editing of commands, @code{csh}-like history -substitution, and a storage and recall of command history across -debugging sessions. - -You may control the behavior of command line editing in _GDBN__ with the -command @code{set}. - -@table @code -@kindex set editing -@cindex editing -@item set editing -@itemx set editing on -Enable command line editing (enabled by default). - -@item set editing off -Disable command line editing. - -@kindex show editing -@item show editing -Show whether command line editing is enabled. -@end table - -@node History, Screen Size, Editing, Controlling _GDBN__ -@section Command History -@table @code -@cindex history substitution -@cindex history file -@kindex set history filename -@item set history filename @var{fname} -Set the name of the _GDBN__ command history file to @var{fname}. This is -the file from which _GDBN__ will read an initial command history -list or to which it will write this list when it exits. This list is -accessed through history expansion or through the history -command editing characters listed below. This file defaults to the -value of the environment variable @code{GDBHISTFILE}, or to -@file{./.gdb_history} if this variable is not set. - -@cindex history save -@kindex set history save -@item set history save -@itemx set history save on -Record command history in a file, whose name may be specified with the -@code{set history filename} command. By default, this option is disabled. - -@item set history save off -Stop recording command history in a file. - -@cindex history size -@kindex set history size -@item set history size @var{size} -Set the number of commands which _GDBN__ will keep in its history list. -This defaults to the value of the environment variable -@code{HISTSIZE}, or to 256 if this variable is not set. -@end table - -@cindex history expansion -History expansion assigns special meaning to the character @kbd{!}. -@iftex -(@xref{Event Designators}.) -@end iftex -Since @kbd{!} is also the logical not operator in C, history expansion -is off by default. If you decide to enable history expansion with the -@code{set history expansion on} command, you may sometimes need to -follow @kbd{!} (when it is used as logical not, in an expression) with -a space or a tab to prevent it from being expanded. The readline -history facilities will not attempt substitution on the strings -@kbd{!=} and @kbd{!(}, even when history expansion is enabled. - -The commands to control history expansion are: - -@table @code - -@kindex set history expansion -@item set history expansion on -@itemx set history expansion -Enable history expansion. History expansion is off by default. - -@item set history expansion off -Disable history expansion. - -The readline code comes with more complete documentation of -editing and history expansion features. Users unfamiliar with @code{emacs} -or @code{vi} may wish to read it. -@iftex -@xref{Command Line Editing}. -@end iftex - -@c @group -@kindex show history -@item show history -@itemx show history filename -@itemx show history save -@itemx show history size -@itemx show history expansion -These commands display the state of the _GDBN__ history parameters. -@code{show history} by itself displays all four states. -@c @end group - -@end table - -@table @code -@kindex show commands -@item show commands -Display the last ten commands in the command history. - -@item show commands @var{n} -Print ten commands centered on command number @var{n}. - -@item show commands + -Print ten commands just after the commands last printed. - -@end table - -@node Screen Size, Numbers, History, Controlling _GDBN__ -@section Screen Size -@cindex size of screen -@cindex pauses in output -Certain commands to _GDBN__ may produce large amounts of information -output to the screen. To help you read all of it, _GDBN__ pauses and -asks you for input at the end of each page of output. Type @key{RET} -when you want to continue the output. _GDBN__ also uses the screen -width setting to determine when to wrap lines of output. Depending on -what is being printed, it tries to break the line at a readable place, -rather than simply letting it overflow onto the following line. - -Normally _GDBN__ knows the size of the screen from the termcap data base -together with the value of the @code{TERM} environment variable and the -@code{stty rows} and @code{stty cols} settings. If this is not correct, -you can override it with the @code{set height} and @code{set -width} commands: - -@table @code -@item set height @var{lpp} -@itemx show height -@itemx set width @var{cpl} -@itemx show width -@kindex set height -@kindex set width -@kindex show width -@kindex show height -These @code{set} commands specify a screen height of @var{lpp} lines and -a screen width of @var{cpl} characters. The associated @code{show} -commands display the current settings. - -If you specify a height of zero lines, _GDBN__ will not pause during output -no matter how long the output is. This is useful if output is to a file -or to an editor buffer. -@end table - -@node Numbers, Messages/Warnings, Screen Size, Controlling _GDBN__ -@section Numbers -@cindex number representation -@cindex entering numbers -You can always enter numbers in octal, decimal, or hexadecimal in _GDBN__ by -the usual conventions: octal numbers begin with @samp{0}, decimal -numbers end with @samp{.}, and hexadecimal numbers begin with @samp{0x}. -Numbers that begin with none of these are, by default, entered in base -10; likewise, the default display for numbers---when no particular -format is specified---is base 10. You can change the default base for -both input and output with the @code{set radix} command. - -@table @code -@kindex set radix -@item set radix @var{base} -Set the default base for numeric input and display. Supported choices -for @var{base} are decimal 8, 10, 16. @var{base} must itself be -specified either unambiguously or using the current default radix; for -example, any of - -@example -set radix 012 -set radix 10. -set radix 0xa -@end example - -@noindent -will set the base to decimal. On the other hand, @samp{set radix 10} -will leave the radix unchanged no matter what it was. - -@kindex show radix -@item show radix -Display the current default base for numeric input and display. - -@end table - -@node Messages/Warnings, , Numbers, Controlling _GDBN__ -@section Optional Warnings and Messages -By default, _GDBN__ is silent about its inner workings. If you are running -on a slow machine, you may want to use the @code{set verbose} command. -It will make _GDBN__ tell you when it does a lengthy internal operation, so -you won't think it has crashed. - -Currently, the messages controlled by @code{set verbose} are those which -announce that the symbol table for a source file is being read -(@pxref{Files}, in the description of the command -@code{symbol-file}). -@c The following is the right way to do it, but emacs 18.55 doesn't support -@c @ref, and neither the emacs lisp manual version of texinfmt or makeinfo -@c is released. -@ignore -see @code{symbol-file} in @ref{Files}). -@end ignore - -@table @code -@kindex set verbose -@item set verbose on -Enables _GDBN__'s output of certain informational messages. - -@item set verbose off -Disables _GDBN__'s output of certain informational messages. - -@kindex show verbose -@item show verbose -Displays whether @code{set verbose} is on or off. -@end table - -By default, if _GDBN__ encounters bugs in the symbol table of an object file, -it prints a single message about each type of problem it finds, then -shuts up (@pxref{Symbol Errors}). You can suppress these messages, or allow more than one such -message to be printed if you want to see how frequent the problems are. - -@table @code -@kindex set complaints -@item set complaints @var{limit} -Permits _GDBN__ to output @var{limit} complaints about each type of unusual -symbols before becoming silent about the problem. Set @var{limit} to -zero to suppress all complaints; set it to a large number to prevent -complaints from being suppressed. - -@kindex show complaints -@item show complaints -Displays how many symbol complaints _GDBN__ is permitted to produce. -@end table - -By default, _GDBN__ is cautious, and asks what sometimes seem to be a -lot of stupid questions to confirm certain commands. For example, if -you try to run a program which is already running: -@example -(_GDBP__) run -The program being debugged has been started already. -Start it from the beginning? (y or n) -@end example - -If you're willing to unflinchingly face the consequences of your own -commands, you can disable this ``feature'': - -@table @code -@kindex set confirm -@cindex flinching -@cindex confirmation -@cindex stupid questions -@item set confirm off -Disables confirmation requests. - -@item set confirm on -Enables confirmation requests (the default). - -@item show confirm -@kindex show confirm -Displays state of confirmation requests. -@end table diff --git a/gdb/doc/gdb.data-m4 b/gdb/doc/gdb.data-m4 deleted file mode 100755 index 9c74f60613e..00000000000 --- a/gdb/doc/gdb.data-m4 +++ /dev/null @@ -1,926 +0,0 @@ -_dnl__ Copyright (c) 1988 1989 1990 1991 Free Software Foundation, Inc. -_dnl__ This file is part of the source for the GDB manual. -@c M4 FRAGMENT: $Id$ -@node Data, Symbols, Source, Top -@chapter Examining Data - -@cindex printing data -@cindex examining data -@kindex print -@kindex inspect -@c "inspect" isn't quite a synonym if you're using Epoch, which we don't -@c document because it's nonstandard... Under Epoch it displays in a -@c different window or something like that. -The usual way to examine data in your program is with the @code{print} -command (abbreviated @code{p}), or its synonym @code{inspect}. It -evaluates and prints the value of any valid expression of the language -the program is written in (for now, C or C++). You type - -@example -print @var{exp} -@end example - -@noindent -where @var{exp} is any valid expression (in the source language), and -the value of @var{exp} is printed in a format appropriate to its data -type. - -A more low-level way of examining data is with the @code{x} command. -It examines data in memory at a specified address and prints it in a -specified format. @xref{Memory}. - -@menu -* Expressions:: Expressions -* Variables:: Program Variables -* Arrays:: Artificial Arrays -* Output formats:: Output formats -* Memory:: Examining Memory -* Auto Display:: Automatic Display -* Print Settings:: Print Settings -* Value History:: Value History -* Convenience Vars:: Convenience Variables -* Registers:: Registers -* Floating Point Hardware:: Floating Point Hardware -@end menu - -@node Expressions, Variables, Data, Data -@section Expressions - -@cindex expressions -@code{print} and many other _GDBN__ commands accept an expression and -compute its value. Any kind of constant, variable or operator defined -by the programming language you are using is legal in an expression in -_GDBN__. This includes conditional expressions, function calls, casts -and string constants. It unfortunately does not include symbols defined -by preprocessor @code{#define} commands, or C++ expressions involving -@samp{::}, the name resolution operator. -@c FIXME: actually C++ a::b works except in obscure circumstances where it -@c FIXME...can conflict with GDB's own name scope resolution. - -Casts are supported in all languages, not just in C, because it is so -useful to cast a number into a pointer so as to examine a structure -at that address in memory. - -_GDBN__ supports three kinds of operator in addition to those of programming -languages: - -@table @code -@item @@ -@samp{@@} is a binary operator for treating parts of memory as arrays. -@xref{Arrays}, for more information. - -@item :: -@samp{::} allows you to specify a variable in terms of the file or -function where it is defined. @xref{Variables}. - -@item @{@var{type}@} @var{addr} -Refers to an object of type @var{type} stored at address @var{addr} in -memory. @var{addr} may be any expression whose value is an integer or -pointer (but parentheses are required around binary operators, just as in -a cast). This construct is allowed regardless of what kind of data is -normally supposed to reside at @var{addr}.@refill -@end table - -@node Variables, Arrays, Expressions, Data -@section Program Variables - -The most common kind of expression to use is the name of a variable -in your program. - -Variables in expressions are understood in the selected stack frame -(@pxref{Selection}); they must either be global (or static) or be visible -according to the scope rules of the programming language from the point of -execution in that frame. This means that in the function - -@example -foo (a) - int a; -@{ - bar (a); - @{ - int b = test (); - bar (b); - @} -@} -@end example - -@noindent -the variable @code{a} is usable whenever the program is executing -within the function @code{foo}, but the variable @code{b} is visible -only while the program is executing inside the block in which @code{b} -is declared. - -@cindex variable name conflict -There is an exception: you can refer to a variable or function whose -scope is a single source file even if the current execution point is not -in this file. But it is possible to have more than one such variable or -function with the same name (in different source files). If that happens, -referring to that name has unpredictable effects. If you wish, you can -specify a variable in a particular file, using the colon-colon notation: - -@cindex colon-colon -@kindex :: -@example -@var{file}::@var{variable} -@end example - -@noindent -Here @var{file} is the name of the source file whose variable you want. - -@cindex C++ name resolution -This use of @samp{::} is very rarely in conflict with the very similar -use of the same notation in C++. _GDBN__ also supports use of the C++ -name resolution operator in _GDBN__ expressions. - -@node Arrays, Output formats, Variables, Data -@section Artificial Arrays - -@cindex artificial array -@kindex @@ -It is often useful to print out several successive objects of the -same type in memory; a section of an array, or an array of -dynamically determined size for which only a pointer exists in the -program. - -This can be done by constructing an @dfn{artificial array} with the -binary operator @samp{@@}. The left operand of @samp{@@} should be -the first element of the desired array, as an individual object. -The right operand should be the desired length of the array. The result is -an array value whose elements are all of the type of the left argument. -The first element is actually the left argument; the second element -comes from bytes of memory immediately following those that hold the -first element, and so on. Here is an example. If a program says - -@example -int *array = (int *) malloc (len * sizeof (int)); -@end example - -@noindent -you can print the contents of @code{array} with - -@example -p *array@@len -@end example - -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 -subscripting, and are coerced to pointers when used in expressions. -Artificial arrays most often appear in expressions via the value history -(@pxref{Value History}), after printing one out.) - -@node Output formats, Memory, Arrays, Data -@section Output formats - -@cindex formatted output -@cindex output formats -By default, _GDBN__ prints a value according to its data type. Sometimes -this is not what you want. For example, you might want to print a number -in hex, or a pointer in decimal. Or you might want to view data in memory -at a certain address as a character string or as an instruction. To do -these things, specify an @dfn{output format} when you print a value. - -The simplest use of output formats is to say how to print a value -already computed. This is done by starting the arguments of the -@code{print} command with a slash and a format letter. The format -letters supported are: - -@table @code -@item x -Regard the bits of the value as an integer, and print the integer in -hexadecimal. - -@item d -Print as integer in signed decimal. - -@item u -Print as integer in unsigned decimal. - -@item o -Print as integer in octal. - -@item t -Print as integer in binary. The letter @samp{t} stands for ``two''. - -@item a -Print as an address, both absolute in hex and as an offset from the -nearest preceding symbol. This format can be used to discover where (in -what function) an unknown address is located: -@example -(_GDBP__) p/a 0x54320 -_0__$3 = 0x54320 <_initialize_vx+396>_1__ -@end example - - -@item c -Regard as an integer and print it as a character constant. - -@item f -Regard the bits of the value as a floating point number and print -using typical floating point syntax. -@end table - -For example, to print the program counter in hex (@pxref{Registers}), type - -@example -p/x $pc -@end example - -@noindent -Note that no space is required before the slash; this is because command -names in _GDBN__ cannot contain a slash. - -To reprint the last value in the value history with a different format, -you can use the @code{print} command with just a format and no -expression. For example, @samp{p/x} reprints the last value in hex. - -@node Memory, Auto Display, Output formats, Data -@section Examining Memory - -@cindex examining memory -@table @code -@kindex x -@item x/@var{nfu} @var{expr} -The command @code{x} (for `examine') can be used to examine memory -without being constrained by your program's data types. You can specify -the unit size @var{u} of memory to inspect, and a repeat count @var{n} of how -many of those units to display. @code{x} understands the formats -@var{f} used by @code{print}; two additional formats, @samp{s} (string) -and @samp{i} (machine instruction) can be used without specifying a unit -size. -@end table - -For example, @samp{x/3uh 0x54320} is a request to display three halfwords -(@code{h}) of memory, formatted as unsigned decimal integers (@samp{u}), -starting at address @code{0x54320}. @samp{x/4xw $sp} prints the four -words (@samp{w}) of memory above the stack pointer (here, @samp{$sp}; -@pxref{Registers}) in hexadecimal (@samp{x}). - -Since the letters indicating unit sizes are all distinct from the -letters specifying output formats, you don't have to remember whether -unit size or format comes first; either order will work. The output -specifications @samp{4xw} and @samp{4wx} mean exactly the same thing. - -After the format specification, you supply an expression for the address -where _GDBN__ is to begin reading from memory. The expression need not -have a pointer value (though it may); it is always interpreted as an -integer address of a byte of memory. @xref{Expressions} for more -information on expressions. - -These are the memory units @var{u} you can specify with the @code{x} -command: - -@table @code -@item b -Examine individual bytes. - -@item h -Examine halfwords (two bytes each). - -@item w -Examine words (four bytes each). - -@cindex word -Many assemblers and cpu designers still use `word' for a 16-bit quantity, -as a holdover from specific predecessor machines of the 1970's that really -did use two-byte words. But more generally the term `word' has always -referred to the size of quantity that a machine normally operates on and -stores in its registers. This is 32 bits for all the machines that _GDBN__ -runs on. - -@item g -Examine giant words (8 bytes). -@end table - -You can combine these unit specifications with any of the formats -described for @code{print}. @xref{Output formats}. - -@code{x} has two additional output specifications which derive the unit -size from the data inspected: - -@table @code -@item s -Print a null-terminated string of characters. Any explicitly specified -unit size is ignored; instead, the unit is however many bytes it takes -to reach a null character (including the null character). - -@item i -Print a machine instruction in assembler syntax (or nearly). Any -specified unit size is ignored; the number of bytes in an instruction -varies depending on the type of machine, the opcode and the addressing -modes used. The command @code{disassemble} gives an alternative way of -inspecting machine instructions. @xref{Machine Code}. -@end table - -If you omit either the format @var{f} or the unit size @var{u}, @code{x} -will use the same one that was used last. If you don't use any letters -or digits after the slash, you can omit the slash as well. - -You can also omit the address to examine. Then the address used is just -after the last unit examined. This is why string and instruction -formats actually compute a unit-size based on the data: so that the next -string or instruction examined will start in the right place. - -When the @code{print} command shows a value that resides in memory, -@code{print} also sets the default address for the @code{x} command. -@code{info line} also sets the default for @code{x}, to the address of -the start of the machine code for the specified line (@pxref{Machine -Code}), and @code{info breakpoints} sets it to the address of the last -breakpoint listed (@pxref{Set Breaks}). - -When you use @key{RET} to repeat an @code{x} command, the address -specified previously (if any) is ignored, so that the repeated command -examines the successive locations in memory rather than the same ones. - -You can examine several consecutive units of memory with one command by -writing a repeat-count after the slash (before the format letters, if -any). Omitting the repeat count @var{n} displays one unit of the -appropriate size. The repeat count must be a decimal integer. It has -the same effect as repeating the @code{x} command @var{n} times except -that the output may be more compact, with several units per line. For -example, - -@example -x/10i $pc -@end example - -@noindent -prints ten instructions starting with the one to be executed next in the -selected frame. After doing this, you could print a further seven -instructions with - -@example -x/7 -@end example - -@noindent ----where the format and address are allowed to default. - -@kindex $_ -@kindex $__ -The addresses and contents printed by the @code{x} command are not put -in the value history because there is often too much of them and they -would get in the way. Instead, _GDBN__ makes these values available for -subsequent use in expressions as values of the convenience variables -@code{$_} and @code{$__}. After an @code{x} command, the last address -examined is available for use in expressions in the convenience variable -@code{$_}. The contents of that address, as examined, are available in -the convenience variable @code{$__}. - -If the @code{x} command has a repeat count, the address and contents saved -are from the last memory unit printed; this is not the same as the last -address printed if several units were printed on the last line of output. - -@node Auto Display, Print Settings, Memory, Data -@section Automatic Display -@cindex automatic display -@cindex display of expressions - -If you find that you want to print the value of an expression frequently -(to see how it changes), you might want to add it to the @dfn{automatic -display list} so that _GDBN__ will print its value each time the program stops. -Each expression added to the list is given a number to identify it; -to remove an expression from the list, you specify that number. -The automatic display looks like this: - -@example -2: foo = 38 -3: bar[5] = (struct hack *) 0x3804 -@end example - -@noindent -showing item numbers, expressions and their current values. As with -displays you request manually using @code{x} or @code{print}, you can -specify the output format you prefer; in fact, @code{display} decides -whether to use @code{print} or @code{x} depending on how elaborate your -format specification is---it uses @code{x} if you specify a unit size, -or one of the two formats (@samp{i} and @samp{s}) that are only -supported by @code{x}; otherwise it uses @code{print}. - -@table @code -@item display @var{exp} -@kindex display -Add the expression @var{exp} to the list of expressions to display -each time the program stops. @xref{Expressions}. - -@code{display} will not repeat if you press @key{RET} again after using it. - -@item display/@var{fmt} @var{exp} -For @var{fmt} specifying only a display format and not a size or -count, add the expression @var{exp} to the auto-display list but -arranges to display it each time in the specified format @var{fmt}. -@xref{Output formats}. - -@item display/@var{fmt} @var{addr} -For @var{fmt} @samp{i} or @samp{s}, or including a unit-size or a -number of units, add the expression @var{addr} as a memory address to -be examined each time the program stops. Examining means in effect -doing @samp{x/@var{fmt} @var{addr}}. @xref{Memory}. -@end table - -For example, @samp{display/i $pc} can be helpful, to see the machine -instruction about to be executed each time execution stops (@samp{$pc} -is a common name for the program counter; @pxref{Registers}). - -@table @code -@item undisplay @var{dnums}@dots{} -@itemx delete display @var{dnums}@dots{} -@kindex delete display -@kindex undisplay -Remove item numbers @var{dnums} from the list of expressions to display. - -@code{undisplay} will not repeat if you press @key{RET} after using it. -(Otherwise you would just get the error @samp{No display number @dots{}}.) - -@item disable display @var{dnums}@dots{} -@kindex disable display -Disable the display of item numbers @var{dnums}. A disabled display -item is not printed automatically, but is not forgotten. It may be -enabled again later. - -@item enable display @var{dnums}@dots{} -@kindex enable display -Enable display of item numbers @var{dnums}. It becomes effective once -again in auto display of its expression, until you specify otherwise. - -@item display -Display the current values of the expressions on the list, just as is -done when the program stops. - -@item info display -@kindex info display -Print the list of expressions previously set up to display -automatically, each one with its item number, but without showing the -values. This includes disabled expressions, which are marked as such. -It also includes expressions which would not be displayed right now -because they refer to automatic variables not currently available. -@end table - -If a display expression refers to local variables, then it does not make -sense outside the lexical context for which it was set up. Such an -expression is disabled when execution enters a context where one of its -variables is not defined. For example, if you give the command -@code{display last_char} while inside a function with an argument -@code{last_char}, then this argument will be displayed while the program -continues to stop inside that function. When it stops elsewhere---where -there is no variable @code{last_char}---display is disabled. The next time -your program stops where @code{last_char} is meaningful, you can enable the -display expression once again. - -@node Print Settings, Value History, Auto Display, Data -@section Print Settings - -@cindex format options -@cindex print settings -_GDBN__ provides the following ways to control how arrays, structures, -and symbols are printed. - -@noindent -These settings are useful for debugging programs in any language: - -@table @code -@item set print address -@item set print address on -@kindex set print address -_GDBN__ will print memory addresses showing the location of stack -traces, structure values, pointer values, breakpoints, and so forth, -even when it also displays the contents of those addresses. The default -is on. For example, this is what a stack frame display looks like, with -@code{set print address on}: -@smallexample -(_GDBP__) f -#0 set_quotes (lq=0x34c78 "<<", rq=0x34c88 ">>") - at input.c:530 -530 if (lquote != def_lquote) -@end smallexample - -@item set print address off -Do not print addresses when displaying their contents. For example, -this is the same stack frame displayed with @code{set print address off}: -@example -(_GDBP__) set print addr off -(_GDBP__) f -#0 set_quotes (lq="<<", rq=">>") at input.c:530 -530 if (lquote != def_lquote) -@end example - -@item show print address -@kindex show print address -Show whether or not addresses are to be printed. - -@item set print array -@itemx set print array on -@kindex set print array -_GDBN__ will pretty print arrays. This format is more convenient to read, -but uses more space. The default is off. - -@item set print array off. -Return to compressed format for arrays. - -@item show print array -@kindex show print array -Show whether compressed or pretty format is selected for displaying -arrays. - -@item set print elements @var{number-of-elements} -@kindex set print elements -If _GDBN__ is printing a large array, it will stop printing after it has -printed the number of elements set by the @code{set print elements} command. -This limit also applies to the display of strings. - -@item show print elements -@kindex show print elements -Display the number of elements of a large array that _GDBN__ will print -before losing patience. - -@item set print pretty on -@kindex set print pretty -Cause _GDBN__ to print structures in an indented format with one member per -line, like this: - -@example -$1 = @{ - next = 0x0, - flags = @{ - sweet = 1, - sour = 1 - @}, - meat = 0x54 "Pork" -@} -@end example - -@item set print pretty off -Cause _GDBN__ to print structures in a compact format, like this: - -@smallexample -$1 = @{next = 0x0, flags = @{sweet = 1, sour = 1@}, meat \ -= 0x54 "Pork"@} -@end smallexample - -@noindent -This is the default format. - -@item show print pretty -@kindex show print pretty -Show which format _GDBN__ will use to print structures. - -@item set print sevenbit-strings on -Print using only seven-bit characters; if this option is set, -_GDBN__ will display any eight-bit characters (in strings or character -values) using the notation @code{\}@var{nnn}. For example, @kbd{M-a} is -displayed as @code{\341}. - -@item set print sevenbit-strings off -Print using either seven-bit or eight-bit characters, as required. This -is the default. - -@item show print sevenbit-strings -Show whether or not _GDBN__ will print only seven-bit characters. - -@item set print union on -@kindex set print union -Tell _GDBN__ to print unions which are contained in structures. This is the -default setting. - -@item set print union off -Tell _GDBN__ not to print unions which are contained in structures. - -@item show print union -@kindex show print union -Ask _GDBN__ whether or not it will print unions which are contained in -structures. - -For example, given the declarations - -@smallexample -typedef enum @{Tree, Bug@} Species; -typedef enum @{Big_tree, Acorn, Seedling@} Tree_forms; -typedef enum @{Caterpillar, Cocoon, Butterfly@} Bug_forms; - -struct thing @{ - Species it; - union @{ - Tree_forms tree; - Bug_forms bug; - @} form; -@}; - -struct thing foo = @{Tree, @{Acorn@}@}; -@end smallexample - -@noindent -with @code{set print union on} in effect @samp{p foo} would print - -@smallexample -$1 = @{it = Tree, form = @{tree = Acorn, bug = Cocoon@}@} -@end smallexample - -@noindent -and with @code{set print union off} in effect it would print - -@smallexample -$1 = @{it = Tree, form = @{...@}@} -@end smallexample -@end table - -@noindent -These settings are of interest when debugging C++ programs: - -@table @code -@item set print demangle -@itemx set print demangle on -@kindex set print demangle -Print C++ names in their source form rather than in the mangled form -in which they are passed to the assembler and linker for type-safe linkage. -The default is on. - -@item show print demangle -@kindex show print demangle -Show whether C++ names will be printed in mangled or demangled form. - -@item set print asm-demangle -@itemx set print asm-demangle on -@kindex set print asm-demangle -Print C++ names in their source form rather than their mangled form, even -in assembler code printouts such as instruction disassemblies. -The default is off. - -@item show print asm-demangle -@kindex show print asm-demangle -Show whether C++ names in assembly listings will be printed in mangled -or demangled form. - -@item set print object -@itemx set print object on -@kindex set print object -When displaying a pointer to an object, identify the @emph{actual} -(derived) type of the object rather than the @emph{declared} type, using -the virtual function table. - -@item set print object off -Display only the declared type of objects, without reference to the -virtual function table. This is the default setting. - -@item show print object -@kindex show print object -Show whether actual, or declared, object types will be displayed. - -@item set print vtbl -@itemx set print vtbl on -@kindex set print vtbl -Pretty print C++ virtual function tables. The default is off. - -@item set print vtbl off -Do not pretty print C++ virtual function tables. - -@item show print vtbl -@kindex show print vtbl -Show whether C++ virtual function tables are pretty printed, or not. - -@end table - -@node Value History, Convenience Vars, Print Settings, Data -@section Value History - -@cindex value history -Values printed by the @code{print} command are saved in _GDBN__'s @dfn{value -history} so that you can refer to them in other expressions. Values are -kept until the symbol table is re-read or discarded (for example with -the @code{file} or @code{symbol-file} commands). When the symbol table -changes, the value history is discarded, since the values may contain -pointers back to the types defined in the symbol table. - -@cindex @code{$} -@cindex @code{$$} -@cindex history number -The values printed are given @dfn{history numbers} for you to refer to them -by. These are successive integers starting with one. @code{print} shows you -the history number assigned to a value by printing @samp{$@var{num} = } -before the value; here @var{num} is the history number. - -To refer to any previous value, use @samp{$} followed by the value's -history number. The way @code{print} labels its output is designed to -remind you of this. Just @code{$} refers to the most recent value in -the history, and @code{$$} refers to the value before that. -@code{$$@var{n}} refers to the @var{n}th value from the end; @code{$$2} -is the value just prior to @code{$$}, @code{$$1} is equivalent to -@code{$$}, and @code{$$0} is equivalent to @code{$}. - -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 -p *$ -@end example - -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 -p *$.next -@end example - -@noindent -You can print successive links in the chain by repeating this -command---which you can do by just typing @key{RET}. - -Note that the history records values, not expressions. If the value of -@code{x} is 4 and you type these commands: - -@example -print x -set x=5 -@end example - -@noindent -then the value recorded in the value history by the @code{print} command -remains 4 even though the value of @code{x} has changed. - -@table @code -@kindex show values -@item show values -Print the last ten values in the value history, with their item numbers. -This is like @samp{p@ $$9} repeated ten times, except that @code{show -values} does not change the history. - -@item show values @var{n} -Print ten history values centered on history item number @var{n}. - -@item show values + -Print ten history values just after the values last printed. If no more -values are available, produces no display. -@end table - -Pressing @key{RET} to repeat @code{show values @var{n}} has exactly the -same effect as @samp{show values +}. - -@node Convenience Vars, Registers, Value History, Data -@section Convenience Variables - -@cindex convenience variables -_GDBN__ provides @dfn{convenience variables} that you can use within -_GDBN__ to hold on to a value and refer to it later. These variables -exist entirely within _GDBN__; they are not part of your program, and -setting a convenience variable has no direct effect on further execution -of your program. That's why you can use them freely. - -Convenience variables are prefixed with @samp{$}. Any name preceded by -@samp{$} can be used for a convenience variable, unless it is one of -the predefined machine-specific register names (@pxref{Registers}). -(Value history references, in contrast, are @emph{numbers} preceded -by @samp{$}. @xref{Value History}.) - -You can save a value in a convenience variable with an assignment -expression, just as you would set a variable in your program. Example: - -@example -set $foo = *object_ptr -@end example - -@noindent -would save in @code{$foo} the value contained in the object pointed to by -@code{object_ptr}. - -Using a convenience variable for the first time creates it; but its value -is @code{void} until you assign a new value. You can alter the value with -another assignment at any time. - -Convenience variables have no fixed types. You can assign a convenience -variable any type of value, including structures and arrays, even if -that variable already has a value of a different type. The convenience -variable, when used as an expression, has the type of its current value. - -@table @code -@item show convenience -@kindex show convenience -Print a list of convenience variables used so far, and their values. -Abbreviated @code{show con}. -@end table - -One of the ways to use a convenience variable is as a counter to be -incremented or a pointer to be advanced. For example, to print -a field from successive elements of an array of structures: - -_0__@example -set $i = 0 -print bar[$i++]->contents -@i{@dots{} repeat that command by typing @key{RET}.} -_1__@end example - -Some convenience variables are created automatically by _GDBN__ and given -values likely to be useful. - -@table @code -@item $_ -The variable @code{$_} is automatically set by the @code{x} command to -the last address examined (@pxref{Memory}). Other commands which -provide a default address for @code{x} to examine also set @code{$_} -to that address; these commands include @code{info line} and @code{info -breakpoint}. - -@item $__ -The variable @code{$__} is automatically set by the @code{x} command -to the value found in the last address examined. -@end table - -@node Registers, Floating Point Hardware, Convenience Vars, Data -@section Registers - -@cindex registers -Machine register contents can be referred to in expressions as variables -with names starting with @samp{$}. The names of registers are different -for each machine; use @code{info registers} to see the names used on -your machine. - -@table @code -@item info registers -@kindex info registers -Print the names and values of all registers (in the selected stack frame). - -@item info registers @var{regname} -Print the relativized value of register @var{regname}. @var{regname} -may be any register name valid on the machine you are using, with -or without the initial @samp{$}. -@end table - -The register names @code{$pc} and @code{$sp} are used on most machines -for the program counter register and the stack pointer. For example, -you could print the program counter in hex with -@example -p/x $pc -@end example - -@noindent -or print the instruction to be executed next with -@example -x/i $pc -@end example - -@noindent -or add four to the stack pointer with -@example -set $sp += 4 -@end example - -@noindent -The last is a way of removing one word from the stack, on machines where -stacks grow downward in memory (most machines, nowadays). This assumes -that the innermost stack frame is selected; setting @code{$sp} is -not allowed when other stack frames are selected. (To pop entire frames -off the stack, regardless of machine architecture, use @code{return}; -@pxref{Returning}.) - -Often @code{$fp} is used for a register that contains a pointer to the -current stack frame, and @code{$ps} is sometimes used for a register -that contains the processor status. These standard register names may -be available on your machine even though the @code{info registers} -command shows other names. For example, on the SPARC, @code{info -registers} displays the processor status register as @code{$psr} but you -can also refer to it as @code{$ps}. - -_GDBN__ always considers the contents of an ordinary register as an -integer when the register is examined in this way. Some machines have -special registers which can hold nothing but floating point; these -registers are considered to have floating point values. There is no way -to refer to the contents of an ordinary register as floating point value -(although you can @emph{print} it as a floating point value with -@samp{print/f $@var{regname}}). - -Some registers have distinct ``raw'' and ``virtual'' data formats. This -means that the data format in which the register contents are saved by -the operating system is not the same one that your program normally -sees. For example, the registers of the 68881 floating point -coprocessor are always saved in ``extended'' (raw) format, but all C -programs expect to work with ``double'' (virtual) format. In such -cases, _GDBN__ normally works with the virtual format only (the format that -makes sense for your program), but the @code{info registers} command -prints the data in both formats. - -Normally, register values are relative to the selected stack frame -(@pxref{Selection}). This means that you get the value that the -register would contain if all stack frames farther in were exited and -their saved registers restored. In order to see the true contents of -hardware registers, you must select the innermost frame (with -@samp{frame 0}). - -However, _GDBN__ must deduce where registers are saved, from the machine -code generated by your compiler. If some registers are not saved, or if -_GDBN__ is unable to locate the saved registers, the selected stack -frame will make no difference. - -@node Floating Point Hardware, , Registers, Data -@section Floating Point Hardware -@cindex floating point -Depending on the host machine architecture, _GDBN__ may be able to give -you more information about the status of the floating point hardware. - -@table @code -@item info float -@kindex info float -If available, provides hardware-dependent information about the floating -point unit. The exact contents and layout vary depending on the -floating point chip. -@end table -@c FIXME: this is a cop-out. Try to get examples, explanations. Only -@c FIXME...supported currently on arm's and 386's. Mark properly with -@c FIXME... m4 macros to isolate general statements from hardware-dep, -@c FIXME... at that point. diff --git a/gdb/doc/gdb.emacs-m4 b/gdb/doc/gdb.emacs-m4 deleted file mode 100755 index 855371eac49..00000000000 --- a/gdb/doc/gdb.emacs-m4 +++ /dev/null @@ -1,166 +0,0 @@ -_dnl__ -*- Texinfo -*- -_dnl__ Copyright (c) 1988 1989 1990 1991 Free Software Foundation, Inc. -_dnl__ This file is part of the source for the GDB manual. -@c M4 FRAGMENT: $Id$ -@node Emacs, _GDBN__ Bugs, Sequences, Top -@chapter Using _GDBN__ under GNU Emacs - -@cindex emacs -A special interface allows you to use GNU Emacs to view (and -edit) the source files for the program you are debugging with -_GDBN__. - -To use this interface, use the command @kbd{M-x gdb} in Emacs. Give the -executable file you want to debug as an argument. This command starts -_GDBN__ as a subprocess of Emacs, with input and output through a newly -created Emacs buffer. - -Using _GDBN__ under Emacs is just like using _GDBN__ normally except for two -things: - -@itemize @bullet -@item -All ``terminal'' input and output goes through the Emacs buffer. -@end itemize - -This applies both to _GDBN__ commands and their output, and to the input -and output done by the program you are debugging. - -This is useful because it means that you can copy the text of previous -commands and input them again; you can even use parts of the output -in this way. - -All the facilities of Emacs' Shell mode are available for this purpose. - -@itemize @bullet -@item -_GDBN__ displays source code through Emacs. -@end itemize - -Each time _GDBN__ displays a stack frame, Emacs automatically finds the -source file for that frame and puts an arrow (_0__@samp{=>}_1__) at the -left margin of the current line. Emacs uses a separate buffer for -source display, and splits the window to show both your _GDBN__ session -and the source. - -Explicit _GDBN__ @code{list} or search commands still produce output as -usual, but you probably will have no reason to use them. - -@quotation -@emph{Warning:} If the directory where your program resides is not your -current directory, it can be easy to confuse Emacs about the location of -the source files, in which case the auxiliary display buffer will not -appear to show your source. _GDBN__ can find programs by searching your -environment's @code{PATH} variable, so the _GDBN__ input and output -session will proceed normally; but Emacs doesn't get enough information -back from _GDBN__ to locate the source files in this situation. To -avoid this problem, either start _GDBN__ mode from the directory where -your program resides, or specify a full path name when prompted for the -@kbd{M-x gdb} argument. - -A similar confusion can result if you use the _GDBN__ @code{file} command to -switch to debugging a program in some other location, from an existing -_GDBN__ buffer in Emacs. -@end quotation - -By default, @kbd{M-x gdb} calls the program called @file{gdb}. If -you need to call _GDBN__ by a different name (for example, if you keep -several configurations around, with different names) you can set the -Emacs variable @code{gdb-command-name}; for example, -@example -(setq gdb-command-name "mygdb") -@end example -@noindent -(preceded by @kbd{ESC ESC}, or typed in the @code{*scratch*} buffer, or -in your @file{.emacs} file) will make Emacs call the program named -``@code{mygdb}'' instead. - -In the _GDBN__ I/O buffer, you can use these special Emacs commands in -addition to the standard Shell mode commands: - -@table @kbd -@item C-h m -Describe the features of Emacs' _GDBN__ Mode. - -@item M-s -Execute to another source line, like the _GDBN__ @code{step} command; also -update the display window to show the current file and location. - -@item M-n -Execute to next source line in this function, skipping all function -calls, like the _GDBN__ @code{next} command. Then update the display window -to show the current file and location. - -@item M-i -Execute one instruction, like the _GDBN__ @code{stepi} command; update -display window accordingly. - -@item M-x gdb-nexti -Execute to next instruction, using the _GDBN__ @code{nexti} command; update -display window accordingly. - -@item C-c C-f -Execute until exit from the selected stack frame, like the _GDBN__ -@code{finish} command. - -@item M-c -Continue execution of the program, like the _GDBN__ @code{continue} -command. @emph{Warning:} In Emacs v19, this command is @kbd{C-c C-p}. - -@item M-u -Go up the number of frames indicated by the numeric argument -(@pxref{Arguments, , Numeric Arguments, emacs, The GNU Emacs Manual}), -like the _GDBN__ @code{up} command. @emph{Warning:} In Emacs v19, this -command is @kbd{C-c C-u}.@refill - -@item M-d -Go down the number of frames indicated by the numeric argument, like the -_GDBN__ @code{down} command. @emph{Warning:} In Emacs v19, this command -is @kbd{C-c C-d}. - -@item C-x & -Read the number where the cursor is positioned, and insert it at the end -of the _GDBN__ I/O buffer. For example, if you wish to disassemble code -around an address that was displayed earlier, type @kbd{disassemble}; -then move the cursor to the address display, and pick up the -argument for @code{disassemble} by typing @kbd{C-x &}. - -You can customize this further on the fly by defining elements of the list -@code{gdb-print-command}; once it is defined, you can format or -otherwise process numbers picked up by @kbd{C-x &} before they are -inserted. A numeric argument to @kbd{C-x &} will both flag that you -wish special formatting, and act as an index to pick an element of the -list. If the list element is a string, the number to be inserted is -formatted using the Emacs function @code{format}; otherwise the number -is passed as an argument to the corresponding list element. - -@end table - -In any source file, the Emacs command @kbd{C-x SPC} (@code{gdb-break}) -tells _GDBN__ to set a breakpoint on the source line point is on. - -If you accidentally delete the source-display buffer, an easy way to get -it back is to type the command @code{f} in the _GDBN__ buffer, to -request a frame display; when you run under Emacs, this will recreate -the source buffer if necessary to show you the context of the current -frame. - -The source files displayed in Emacs are in ordinary Emacs buffers -which are visiting the source files in the usual way. You can edit -the files with these buffers if you wish; but keep in mind that _GDBN__ -communicates with Emacs in terms of line numbers. If you add or -delete lines from the text, the line numbers that _GDBN__ knows will cease -to correspond properly to the code. - -@c The following dropped because Epoch is nonstandard. Reactivate -@c if/when v19 does something similar. ---pesch@cygnus.com 19dec1990 -@ignore -@kindex emacs epoch environment -@kindex epoch -@kindex inspect - -Version 18 of Emacs has a built-in window system called the @code{epoch} -environment. Users of this environment can use a new command, -@code{inspect} which performs identically to @code{print} except that -each value is printed in its own window. -@end ignore diff --git a/gdb/doc/gdb.files-m4 b/gdb/doc/gdb.files-m4 deleted file mode 100755 index c71a315fc37..00000000000 --- a/gdb/doc/gdb.files-m4 +++ /dev/null @@ -1,300 +0,0 @@ -_dnl__ -*- Texinfo -*- -_dnl__ Copyright (c) 1988 1989 1990 1991 Free Software Foundation, Inc. -_dnl__ This file is part of the source for the GDB manual. -@c M4 FRAGMENT: $Id$ -@node _GDBN__ Files, Targets, Altering, Top -@chapter _GDBN__'s Files - -@menu -* Files:: Commands to Specify Files -* Symbol Errors:: Errors Reading Symbol Files -@end menu - -@node Files, Symbol Errors, _GDBN__ Files, _GDBN__ Files -@section Commands to Specify Files -@cindex core dump file -@cindex symbol table -_GDBN__ needs to know the file name of the program to be debugged, both in -order to read its symbol table and in order to start the program. To -debug a core dump of a previous run, _GDBN__ must be told the file name of -the core dump. - -The usual way to specify the executable and core dump file names is with -the command arguments given when you start _GDBN__, as discussed in -@pxref{Invocation}. - -Occasionally it is necessary to change to a different file during a -_GDBN__ session. Or you may run _GDBN__ and forget to specify the files you -want to use. In these situations the _GDBN__ commands to specify new files -are useful. - -@table @code -@item file @var{filename} -@cindex executable file -@kindex file -Use @var{filename} as the program to be debugged. It is read for its -symbols and for the contents of pure memory. It is also the program -executed when you use the @code{run} command. If you do not specify a -directory and the file is not found in _GDBN__'s working directory, - -_GDBN__ uses the environment variable @code{PATH} as a list of -directories to search, just as the shell does when looking for a program -to run. You can change the value of this variable, for both _GDBN__ and -your program, using the @code{path} command. - -@code{file} with no argument makes _GDBN__ discard any information it -has on both executable file and the symbol table. - -@item exec-file @var{filename} -@kindex exec-file -Specify that the program to be run (but not the symbol table) is found -in @var{filename}. _GDBN__ will search the environment variable @code{PATH} -if necessary to locate the program. - -@item symbol-file @var{filename} -@kindex symbol-file -Read symbol table information from file @var{filename}. @code{PATH} is -searched when necessary. Use the @code{file} command to get both symbol -table and program to run from the same file. - -@code{symbol-file} with no argument clears out _GDBN__'s information on your -program's symbol table. - -The @code{symbol-file} command causes _GDBN__ to forget the contents of its -convenience variables, the value history, and all breakpoints and -auto-display expressions. This is because they may contain pointers to -the internal data recording symbols and data types, which are part of -the old symbol table data being discarded inside _GDBN__. - -@code{symbol-file} will not repeat if you press @key{RET} again after -executing it once. - -On some kinds of object files, the @code{symbol-file} command does not -actually read the symbol table in full right away. Instead, it scans -the symbol table quickly to find which source files and which symbols -are present. The details are read later, one source file at a time, -when they are needed. - -The purpose of this two-stage reading strategy is to make _GDBN__ start up -faster. For the most part, it is invisible except for occasional pauses -while the symbol table details for a particular source file are being -read. (The @code{set verbose} command can turn these pauses into -messages if desired. @xref{Messages/Warnings}). - -When the symbol table is stored in COFF format, @code{symbol-file} does -read the symbol table data in full right away. We haven't implemented -the two-stage strategy for COFF yet. - -When _GDBN__ is configured for a particular environment, it will -understand debugging information in whatever format is the standard -generated for that environment; you may use either a GNU compiler, or -other compilers that adhere to the local conventions. Best results are -usually obtained from GNU compilers; for example, using @code{_GCC__} -you can generate debugging information for optimized code. - -@item core-file @var{filename} -@itemx core @var{filename} -@kindex core -@kindex core-file -Specify the whereabouts of a core dump file to be used as the ``contents -of memory''. Traditionally, core files contain only some parts of the -address space of the process that generated them; _GDBN__ can access the -executable file itself for other parts. - -@code{core-file} with no argument specifies that no core file is -to be used. - -Note that the core file is ignored when your program is actually running -under _GDBN__. So, if you have been running the program and you wish to -debug a core file instead, you must kill the subprocess in which the -program is running. To do this, use the @code{kill} command -(@pxref{Kill Process}). - -@item load @var{filename} -@kindex load -_if__(_GENERIC__) -Depending on what remote debugging facilities are configured into -_GDBN__, the @code{load} command may be available. Where it exists, it -is meant to make @var{filename} (an executable) available for debugging -on the remote system---by downloading, or dynamic linking, for example. -@code{load} also records @var{filename}'s symbol table in _GDBN__, like -the @code{add-symbol-file} command. - -If @code{load} is not available on your _GDBN__, attempting to execute -it gets the error message ``@code{You can't do that when your target is -@dots{}}'' -_fi__(_GENERIC__) - -_if__(_VXWORKS__) -On VxWorks, @code{load} will dynamically link @var{filename} on the -current target system as well as adding its symbols in _GDBN__. -_fi__(_VXWORKS__) - -_if__(_I960__) -@cindex download to Nindy-960 -With the Nindy interface to an Intel 960 board, @code{load} will -download @var{filename} to the 960 as well as adding its symbols in -_GDBN__. -_fi__(_I960__) - -@code{load} will not repeat if you press @key{RET} again after using it. - -@item add-symbol-file @var{filename} @var{address} -@kindex add-symbol-file -@cindex dynamic linking -The @code{add-symbol-file} command reads additional symbol table information -from the file @var{filename}. You would use this command when that file -has been dynamically loaded (by some other means) into the program that -is running. @var{address} should be the memory address at which the -file has been loaded; _GDBN__ cannot figure this out for itself. - -The symbol table of the file @var{filename} is added to the symbol table -originally read with the @code{symbol-file} command. You can use the -@code{add-symbol-file} command any number of times; the new symbol data thus -read keeps adding to the old. To discard all old symbol data instead, -use the @code{symbol-file} command. - -@code{add-symbol-file} will not repeat if you press @key{RET} after using it. - -@item info files -@itemx info target -@kindex info files -@kindex info target -@code{info files} and @code{info target} are synonymous; both print the -current targets (@pxref{Targets}), including the names of the executable -and core dump files currently in use by _GDBN__, and the files from -which symbols were loaded. The command @code{help targets} lists all -possible targets rather than current ones. - -@end table - -All file-specifying commands allow both absolute and relative file names -as arguments. _GDBN__ always converts the file name to an absolute path -name and remembers it that way. - -@kindex sharedlibrary -@kindex share -@cindex shared libraries - -_GDBN__ supports the SunOS shared library format. Symbols from a shared -library cannot be referenced before the shared library has been linked -with the program. (That is to say, until after you type @code{run} and -the function @code{main} has been entered; or when examining core -files.) Once the shared library has been linked in, you can use the -following commands: - -@table @code -@item sharedlibrary @var{regex} -@itemx share @var{regex} -Load shared object library symbols for files matching a UNIX regular -expression. - -@item share -@itemx sharedlibrary -Load symbols for all shared libraries. - -@item info share -@itemx info sharedlibrary -@kindex info sharedlibrary -@kindex info share -Print the names of the shared libraries which you have loaded with the -@code{sharedlibrary} command. -@end table - -@code{sharedlibrary} does not repeat automatically when you press -@key{RET} after using it once. - -@node Symbol Errors, , Files, _GDBN__ Files -@section Errors Reading Symbol Files -While a symbol file is being read, _GDBN__ will occasionally encounter -problems, such as symbol types it does not recognize, or known bugs in -compiler output. By default, it prints one message about each such -type of problem, no matter how many times the problem occurs. You can -ask it to print more messages, to see how many times the problems occur, -or can shut the messages off entirely, with the @code{set -complaints} command (@xref{Messages/Warnings}). - -The messages currently printed, and their meanings, are: - -@table @code -@item inner block not inside outer block in @var{symbol} - -The symbol information shows where symbol scopes begin and end -(such as at the start of a function or a block of statements). This -error indicates that an inner scope block is not fully contained -in its outer scope blocks. - -_GDBN__ circumvents the problem by treating the inner block as if it had -the same scope as the outer block. In the error message, @var{symbol} -may be shown as ``@code{(don't know)}'' if the outer block is not a -function. - -@item block at @var{address} out of order - -The symbol information for symbol scope blocks should occur in -order of increasing addresses. This error indicates that it does not -do so. - -_GDBN__ does not circumvent this problem, and will have trouble locating -symbols in the source file whose symbols being read. (You can often -determine what source file is affected by specifying @code{set verbose -on}. @xref{Messages/Warnings}.) - -@item bad block start address patched - -The symbol information for a symbol scope block has a start address -smaller than the address of the preceding source line. This is known -to occur in the SunOS 4.1.1 (and earlier) C compiler. - -_GDBN__ circumvents the problem by treating the symbol scope block as -starting on the previous source line. - -@c @item{encountered DBX-style class variable debugging information. -@c You seem to have compiled your program with "g++ -g0" instead of "g++ -g". -@c Therefore _GDBN__ will not know about your class variables} -@c -@c This error indicates that the symbol information produced for a C++ -@c program includes zero-size fields, which indicated static fields in -@c a previous release of the G++ compiler. This message is probably -@c obsolete. -@c -@item bad string table offset in symbol @var{n} - -@cindex foo -Symbol number @var{n} contains a pointer into the string table which is -larger than the size of the string table. - -_GDBN__ circumvents the problem by considering the symbol to have the -name @code{foo}, which may cause other problems if many symbols end up -with this name. - -@item unknown symbol type @code{0x@var{nn}} - -The symbol information contains new data types that _GDBN__ does not yet -know how to read. @code{0x@var{nn}} is the symbol type of the misunderstood -information, in hexadecimal. - -_GDBN__ circumvents the error by ignoring this symbol information. This -will usually allow the program to be debugged, though certain symbols -will not be accessible. If you encounter such a problem and feel like -debugging it, you can debug @code{_GDBP__} with itself, breakpoint on -@code{complain}, then go up to the function @code{read_dbx_symtab} and -examine @code{*bufp} to see the symbol. - -@item stub type has NULL name -_GDBN__ could not find the full definition for a struct or class. - -@ignore -@c this is #if 0'd in dbxread.c as of (at least!) 17 may 1991 -@item const/volatile indicator missing, got '@var{X}' - -The symbol information for a C++ member function is missing some -information that the compiler should have output for it. -@end ignore - -@item C++ type mismatch between compiler and debugger - -The debugger could not parse a type specification output by the compiler -for some C++ object. - -@end table diff --git a/gdb/doc/gdb.gpl-m4 b/gdb/doc/gdb.gpl-m4 deleted file mode 100755 index 9925f838863..00000000000 --- a/gdb/doc/gdb.gpl-m4 +++ /dev/null @@ -1,308 +0,0 @@ -_dnl__ -*- Texinfo -*- -_dnl__ Copyright (c) 1988 1989 1990 1991 Free Software Foundation, Inc. -_dnl__ This file is part of the source for the GDB manual. -@c M4 FRAGMENT: $Id$ -@node Copying, Index, Installing _GDBN__, Top -@appendix Copying GDB -@c this is an attempt to kluge around what may be a bug in texinfo; -@c @xrefs to this node came out pointing several pages further down when -@c the @node was immediately followed by @unnumbered. -@c While we're at it, might as well give an Appendix heading that -@c matches RMS' preferred nodename "Copying". - -@unnumbered GNU GENERAL PUBLIC LICENSE -@center Version 1, February 1989 - -@display -Copyright @copyright{} 1989 Free Software Foundation, Inc. -675 Mass Ave, Cambridge, MA 02139, USA - -Everyone is permitted to copy and distribute verbatim copies -of this license document, but changing it is not allowed. -@end display - -@unnumberedsec Preamble - - The license agreements of most software companies try to keep users -at the mercy of those companies. By contrast, our General Public -License is intended to guarantee your freedom to share and change free -software---to make sure the software is free for all its users. The -General Public License applies to the Free Software Foundation's -software and to any other program whose authors commit to using it. -You can use it for your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Specifically, the General Public License is designed to make -sure that you have the freedom to give away or sell copies of free -software, that you receive source code or can get it if you want it, -that you can change the software or use pieces of it in new free -programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of a such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must tell them their rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - The precise terms and conditions for copying, distribution and -modification follow. - -@iftex -@unnumberedsec TERMS AND CONDITIONS -@end iftex -@ifinfo -@center TERMS AND CONDITIONS -@end ifinfo - -@enumerate -@item -This License Agreement applies to any program or other work which -contains a notice placed by the copyright holder saying it may be -distributed under the terms of this General Public License. The -``Program'', below, refers to any such program or work, and a ``work based -on the Program'' means either the Program or any work containing the -Program or a portion of it, either verbatim or with modifications. Each -licensee is addressed as ``you''. - -@item -You may copy and distribute verbatim copies of the Program's source -code as you receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice and -disclaimer of warranty; keep intact all the notices that refer to this -General Public License and to the absence of any warranty; and give any -other recipients of the Program a copy of this General Public License -along with the Program. You may charge a fee for the physical act of -transferring a copy. - -@item -You may modify your copy or copies of the Program or any portion of -it, and copy and distribute such modifications under the terms of Paragraph -1 above, provided that you also do the following: - -@itemize @bullet -@item -cause the modified files to carry prominent notices stating that -you changed the files and the date of any change; and - -@item -cause the whole of any work that you distribute or publish, that -in whole or in part contains the Program or any part thereof, either -with or without modifications, to be licensed at no charge to all -third parties under the terms of this General Public License (except -that you may choose to grant warranty protection to some or all -third parties, at your option). - -@item -If the modified program normally reads commands interactively when -run, you must cause it, when started running for such interactive use -in the simplest and most usual way, to print or display an -announcement including an appropriate copyright notice and a notice -that there is no warranty (or else, saying that you provide a -warranty) and that users may redistribute the program under these -conditions, and telling the user how to view a copy of this General -Public License. - -@item -You may charge a fee for the physical act of transferring a -copy, and you may at your option offer warranty protection in -exchange for a fee. -@end itemize - -Mere aggregation of another independent work with the Program (or its -derivative) on a volume of a storage or distribution medium does not bring -the other work under the scope of these terms. - -@item -You may copy and distribute the Program (or a portion or derivative of -it, under Paragraph 2) in object code or executable form under the terms of -Paragraphs 1 and 2 above provided that you also do one of the following: - -@itemize @bullet -@item -accompany it with the complete corresponding machine-readable -source code, which must be distributed under the terms of -Paragraphs 1 and 2 above; or, - -@item -accompany it with a written offer, valid for at least three -years, to give any third party free (except for a nominal charge -for the cost of distribution) a complete machine-readable copy of the -corresponding source code, to be distributed under the terms of -Paragraphs 1 and 2 above; or, - -@item -accompany it with the information you received as to where the -corresponding source code may be obtained. (This alternative is -allowed only for noncommercial distribution and only if you -received the program in object code or executable form alone.) -@end itemize - -Source code for a work means the preferred form of the work for making -modifications to it. For an executable file, complete source code means -all the source code for all modules it contains; but, as a special -exception, it need not include source code for modules which are standard -libraries that accompany the operating system on which the executable -file runs, or for standard header files or definitions files that -accompany that operating system. - -@item -You may not copy, modify, sublicense, distribute or transfer the -Program except as expressly provided under this General Public License. -Any attempt otherwise to copy, modify, sublicense, distribute or transfer -the Program is void, and will automatically terminate your rights to use -the Program under this License. However, parties who have received -copies, or rights to use copies, from you under this General Public -License will not have their licenses terminated so long as such parties -remain in full compliance. - -@item -By copying, distributing or modifying the Program (or any work based -on the Program) you indicate your acceptance of this license to do so, -and all its terms and conditions. - -@item -Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the original -licensor to copy, distribute or modify the Program subject to these -terms and conditions. You may not impose any further restrictions on the -recipients' exercise of the rights granted herein. - -@item -The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of the license which applies to it and ``any -later version'', you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -the license, you may choose any version ever published by the Free Software -Foundation. - -@item -If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - -@iftex -@heading NO WARRANTY -@end iftex -@ifinfo -@center NO WARRANTY -@end ifinfo - -@item -BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM ``AS IS'' WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - -@item -IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL -ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES -ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT -LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES -SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE -WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN -ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -@end enumerate - -@iftex -@heading END OF TERMS AND CONDITIONS -@end iftex -@ifinfo -@center END OF TERMS AND CONDITIONS -@end ifinfo - -@page -@unnumberedsec Applying These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to humanity, the best way to achieve this is to make it -free software which everyone can redistribute and change under these -terms. - - To do so, attach the following notices to the program. It is safest to -attach them to the start of each source file to most effectively convey -the exclusion of warranty; and each file should have at least the -``copyright'' line and a pointer to where the full notice is found. - -@smallexample -@var{one line to give the program's name and a brief idea of what it does.} -Copyright (C) 19@var{yy} @var{name of author} - -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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. -@end smallexample - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - -@smallexample -Gnomovision version 69, Copyright (C) 19@var{yy} @var{name of author} -Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. -This is free software, and you are welcome to redistribute it -under certain conditions; type `show c' for details. -@end smallexample - -The hypothetical commands `show w' and `show c' should show the -appropriate parts of the General Public License. Of course, the -commands you use may be called something other than `show w' and `show -c'; they could even be mouse-clicks or menu items---whatever suits your -program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a ``copyright disclaimer'' for the program, if -necessary. Here is a sample; alter the names: - -@smallexample -Yoyodyne, Inc., hereby disclaims all copyright interest in the -program `Gnomovision' (a program to direct compilers to make passes -at assemblers) written by James Hacker. - -@var{signature of Ty Coon}, 1 April 1989 -Ty Coon, President of Vice -@end smallexample - -That's all there is to it! diff --git a/gdb/doc/gdb.install-m4 b/gdb/doc/gdb.install-m4 deleted file mode 100755 index 651c8d07009..00000000000 --- a/gdb/doc/gdb.install-m4 +++ /dev/null @@ -1,57 +0,0 @@ -_dnl__ -*- Texinfo -*- -_dnl__ Copyright (c) 1990 1991 Free Software Foundation, Inc. -_dnl__ This file is part of the source for the GDB manual. -@c M4 FRAGMENT: $Id$ -@node Installing _GDBN__, Copying, Renamed Commands, Top -@appendix Installing _GDBN__ -@cindex configuring _GDBN__ -@cindex installation - -The script @code{config.gdb} automates the process of preparing _GDBN__ -for installation; you can then use @code{make} to actually build it. -The best way to build _GDBN__ is in a subdirectory that records the -configuration options used; this gives you a clean way of building -_GDBN__ binaries with several different configuration options. -@code{config.gdb} doesn't depend on this---it's just a good habit. For -example, assuming the _GDBN__ source is in a directory called -``@code{gdb-4.0}'': - -@example -cd gdb-4.0 -mkdir =sun3os4 -cd =sun3os4 -../config.gdb sun3os4 -make -@end example - -@noindent -will install _GDBN__ on a Sun 3 running SunOS 4. - -@table @code -@kindex config.gdb -@item config.gdb @var{machine} -@itemx config.gdb -srcdir=@var{dir} @var{machine} -This is the most usual way of configuring _GDBN__; to debug programs running -on the same machine as _GDBN__ itself. If you wish to build the _GDBN__ binaries -in a completely different directory from the sources, specify a path to -the source directory using the @samp{-srcdir} option. - -@item config.gdb -host -@cindex host environments -Display a list of supported host environments for _GDBN__. - -@item config.gdb @var{host} @var{target} -@itemx config.gdb -srcdir=@var{dir} @var{host} @var{target} -@cindex cross-debugging -_GDBN__ can also be used as a cross-debugger, running on a machine of one -type while debugging a program running on a machine of another type. -You configure it this way by specifying first the @var{host}, then the -@var{target} environment on the @code{config.gdb} argument list; the -@var{host} is where _GDBN__ runs, and the @var{target} is where your program -runs. @xref{Remote}. Again, you can use @samp{-srcdir} to specify a -path to the _GDBN__ source. - -@item config.gdb -target -@cindex target environments -Display a list of supported target environments for _GDBN__. -@end table diff --git a/gdb/doc/gdb.invoc-m4 b/gdb/doc/gdb.invoc-m4 deleted file mode 100755 index 1ff32def53d..00000000000 --- a/gdb/doc/gdb.invoc-m4 +++ /dev/null @@ -1,207 +0,0 @@ -_dnl__ -*- Texinfo -*- -_dnl__ Copyright (c) 1988 1989 1990 1991 Free Software Foundation, Inc. -_dnl__ This file is part of the source for the GDB manual. -@c M4 FRAGMENT: $Id$ -@node Invocation, Commands, Sample Session, Top -@chapter Getting In and Out of _GDBN__ - -@menu -* Starting _GDBN__:: Starting _GDBN__ -* Leaving _GDBN__:: Leaving _GDBN__ -* Shell Commands:: Shell Commands -@end menu - -@node Starting _GDBN__, Leaving _GDBN__, Invocation, Invocation -@section Starting _GDBN__ - -_GDBN__ is invoked with the shell command @code{_GDBP__}. Once started, -it reads commands from the terminal until you tell it to exit. - -You can run @code{_GDBP__} with no arguments or options; but the most -usual way to start _GDBN__ is with one argument or two, specifying an -executable program as the argument: -@example -_GDBP__ program -@end example -@noindent -You can also start with both an executable program and a core file specified: -@example -_GDBP__ program core -@end example - -@noindent -You can further control how _GDBN__ starts up by using command-line -options. _GDBN__ itself can remind you of the options available: -@example -_GDBP__ -help -@end example -@noindent -will display all available options and briefly describe their use -(@samp{_GDBP__ -h} is a shorter equivalent). - -All options and command line arguments you give are processed -in sequential order. The order makes a difference when the -@samp{-x} option is used. - -@menu -* File Options:: Choosing Files -* Mode Options:: Choosing Modes -_if__(!_GENERIC__) -_include__(gdb.inv.m-m4)_dnl__ -_fi__(!_GENERIC__) -@end menu - -@node File Options, Mode Options, Starting _GDBN__, Starting _GDBN__ -@subsection Choosing Files - -As shown above, any arguments other than options specify an executable -file and core file; that is, the first argument encountered with no -associated option flag is equivalent to a @samp{-se} option, and the -second, if any, is equivalent to a @samp{-c} option. Many options have -both long and short forms; both are shown here. The long forms are also -recognized if you truncate them, so long as enough of the option is -present to be unambiguous. (If you prefer, you can flag option -arguments with @samp{+} rather than @samp{-}, though we illustrate the -more usual convention.) - -@table @code -@item -symbols=@var{file} -@itemx -s @var{file} -Read symbol table from file @var{file}. - -@item -exec=@var{file} -@itemx -e @var{file} -Use file @var{file} as the executable file to execute when -appropriate, and for examining pure data in conjunction with a core -dump. - -@item -se @var{file} -Read symbol table from file @var{file} and use it as the executable -file. - -@item -core=@var{file} -@itemx -c @var{file} -Use file @var{file} as a core dump to examine. - -@item -command=@var{file} -@itemx -x @var{file} -Execute _GDBN__ commands from file @var{file}. @xref{Command Files}. - -@item -directory=@var{directory} -@itemx -d @var{directory} -Add @var{directory} to the path to search for source files. -@end table - -_if__(!_GENERIC__) -@node Mode Options, i960-Nindy Remote, File Options, Starting _GDBN__ -_fi__(!_GENERIC__) -_if__(_GENERIC__) -@node Mode Options, , File Options, Starting _GDBN__ -_fi__(_GENERIC__) -@subsection Choosing Modes - -@table @code -@item -nx -@itemx -n -Do not execute commands from any @file{_GDBINIT__} initialization files. -Normally, the commands in these files are executed after all the -command options and arguments have been processed. @xref{Command -Files}. - -@item -quiet -@itemx -q -``Quiet''. Do not print the introductory and copyright messages. These -messages are also suppressed in batch mode, or if an executable file name is -specified on the _GDBN__ command line. - -@item -batch -Run in batch mode. Exit with status @code{0} after processing all the command -files specified with @samp{-x} (and @file{_GDBINIT__}, if not inhibited). -Exit with nonzero status if an error occurs in executing the _GDBN__ -commands in the command files. - -Batch mode may be useful for running _GDBN__ as a filter, for example to -download and run a program on another computer; in order to make this -more useful, the message -@example -Program exited normally. -@end example -@noindent -(which is ordinarily issued whenever a program running under _GDBN__ control -terminates) is not issued when running in batch mode. - -@item -cd @var{directory} -Run _GDBN__ using @var{directory} as its working directory, -instead of the current directory. - -@item -fullname -@itemx -f -This option is used when Emacs runs _GDBN__ as a subprocess. It tells _GDBN__ -to output the full file name and line number in a standard, -recognizable fashion each time a stack frame is displayed (which -includes each time the program stops). This recognizable format looks -like two @samp{\032} characters, followed by the file name, line number -and character position separated by colons, and a newline. The -Emacs-to-_GDBN__ interface program uses the two @samp{\032} characters as -a signal to display the source code for the frame. - -@item -b @var{bps} -Set the line speed (baud rate or bits per second) of any serial -interface used by _GDBN__ for remote debugging. - -@item -tty @var{device} -Run using @var{device} for your program's standard input and output. -@c FIXME: kingdon thinks there's more to -tty. Investigate. -@end table - -_if__(!_GENERIC__) -_include__(gdb.inv.s-m4) -_fi__(!_GENERIC__) - -@node Leaving _GDBN__, Shell Commands, Starting _GDBN__, Invocation -@section Leaving _GDBN__ -@cindex exiting _GDBN__ -@table @code -@item quit -@kindex quit -@kindex q -To exit _GDBN__, use the @code{quit} command (abbreviated @code{q}), or type -an end-of-file character (usually @kbd{C-d}). -@end table - -@cindex interrupt -An interrupt (often @kbd{C-c}) will not exit from _GDBN__, but rather -will terminate the action of any _GDBN__ command that is in progress and -return to _GDBN__ command level. It is safe to type the interrupt -character at any time because _GDBN__ does not allow it to take effect -until a time when it is safe. - -If you've been using _GDBN__ to control an attached process or device, -you can release it with the @code{detach} command; @pxref{Attach}. - -@node Shell Commands, , Leaving _GDBN__, Invocation -@section Shell Commands -If you just need to execute occasional shell commands during your -debugging session, there's no need to leave or suspend _GDBN__; you can -just use the @code{shell} command. - -@table @code -@item shell @var{command string} -@kindex shell -@cindex shell escape -Directs _GDBN__ to invoke an inferior shell to execute @var{command -string}. If it exists, the environment variable @code{SHELL} is used -for the name of the shell to run. Otherwise _GDBN__ uses -@code{/bin/sh}. -@end table - -The utility @code{make} is often needed in development environments. -You don't have to use the @code{shell} command for this purpose in _GDBN__: - -@table @code -@item make @var{make-args} -@kindex make -@cindex calling make -Causes _GDBN__ to execute an inferior @code{make} program with the specified -arguments. This is equivalent to @samp{shell make @var{make-args}}. -@end table diff --git a/gdb/doc/gdb.rdln-m4 b/gdb/doc/gdb.rdln-m4 deleted file mode 100755 index 7248efa5e15..00000000000 --- a/gdb/doc/gdb.rdln-m4 +++ /dev/null @@ -1,7 +0,0 @@ -_dnl__ -*- Texinfo -*- -_dnl__ Copyright (c) 1991 Free Software Foundation, Inc. -_dnl__ This file is part of the source for the GDB manual. -@c M4 FRAGMENT: $Id$ -@iftex -@include rdl-apps.texinfo -@end iftex diff --git a/gdb/doc/gdb.rename-m4 b/gdb/doc/gdb.rename-m4 deleted file mode 100755 index 7731a4155dc..00000000000 --- a/gdb/doc/gdb.rename-m4 +++ /dev/null @@ -1,112 +0,0 @@ -_dnl__ -*- Texinfo -*- -_dnl__ Copyright (c) 1991 Free Software Foundation, Inc. -_dnl__ This file is part of the source for the GDB manual. -@c M4 FRAGMENT: $Id$ -@node Renamed Commands, Installing _GDBN__, _GDBN__ Bugs, Top -@appendix Renamed Commands - -The following commands were renamed in _GDBN__ 4.0, in order to make the -command set as a whole more consistent and easier to use and remember: - -@kindex add-syms -@kindex delete environment -@kindex info copying -@kindex info convenience -@kindex info directories -@kindex info editing -@kindex info history -@kindex info targets -@kindex info values -@kindex info version -@kindex info warranty -@kindex set addressprint -@kindex set arrayprint -@kindex set prettyprint -@kindex set screen-height -@kindex set screen-width -@kindex set unionprint -@kindex set vtblprint -@kindex set demangle -@kindex set asm-demangle -@kindex set sevenbit-strings -@kindex set array-max -@kindex set caution -@kindex set history write -@kindex show addressprint -@kindex show arrayprint -@kindex show prettyprint -@kindex show screen-height -@kindex show screen-width -@kindex show unionprint -@kindex show vtblprint -@kindex show demangle -@kindex show asm-demangle -@kindex show sevenbit-strings -@kindex show array-max -@kindex show caution -@kindex show history write -@kindex unset - -@ifinfo -OLD COMMAND NEW COMMAND ---------------- ---------------------------------- -add-syms add-symbol-file -delete environment unset environment -info convenience show convenience -info copying show copying -info directories show directories -info editing show commands -info history show values -info targets help target -info values show values -info version show version -info warranty show warranty -set/show addressprint set/show print address -set/show array-max set/show print elements -set/show arrayprint set/show print array -set/show asm-demangle set/show print asm-demangle -set/show caution set/show confirm -set/show demangle set/show print demangle -set/show history write set/show history save -set/show prettyprint set/show print pretty -set/show screen-height set/show height -set/show screen-width set/show width -set/show sevenbit-strings set/show print sevenbit-strings -set/show unionprint set/show print union -set/show vtblprint set/show print vtbl - -unset [ No longer an alias for delete ] -@end ifinfo - -@tex -\vskip \parskip\vskip \baselineskip -\halign{\tt #\hfil &\qquad#&\tt #\hfil\cr -{\bf Old Command} &&{\bf New Command}\cr -add-syms &&add-symbol-file\cr -delete environment &&unset environment\cr -info convenience &&show convenience\cr -info copying &&show copying\cr -info directories &&show directories \cr -info editing &&show commands\cr -info history &&show values\cr -info targets &&help target\cr -info values &&show values\cr -info version &&show version\cr -info warranty &&show warranty\cr -set{\rm / }show addressprint &&set{\rm / }show print address\cr -set{\rm / }show array-max &&set{\rm / }show print elements\cr -set{\rm / }show arrayprint &&set{\rm / }show print array\cr -set{\rm / }show asm-demangle &&set{\rm / }show print asm-demangle\cr -set{\rm / }show caution &&set{\rm / }show confirm\cr -set{\rm / }show demangle &&set{\rm / }show print demangle\cr -set{\rm / }show history write &&set{\rm / }show history save\cr -set{\rm / }show prettyprint &&set{\rm / }show print pretty\cr -set{\rm / }show screen-height &&set{\rm / }show height\cr -set{\rm / }show screen-width &&set{\rm / }show width\cr -set{\rm / }show sevenbit-strings &&set{\rm / }show print sevenbit-strings\cr -set{\rm / }show unionprint &&set{\rm / }show print union\cr -set{\rm / }show vtblprint &&set{\rm / }show print vtbl\cr -\cr -unset &&\rm(No longer an alias for delete)\cr -} -@end tex diff --git a/gdb/doc/gdb.run-m4 b/gdb/doc/gdb.run-m4 deleted file mode 100755 index 09df60bf017..00000000000 --- a/gdb/doc/gdb.run-m4 +++ /dev/null @@ -1,390 +0,0 @@ -_dnl__ -*- Texinfo -*- -_dnl__ Copyright (c) 1988 1989 1990 1991 Free Software Foundation, Inc. -_dnl__ This file is part of the source for the GDB manual. -@c M4 FRAGMENT: $Id$ -@node Running, Stopping, Commands, Top -@chapter Running Programs Under _GDBN__ - -@menu -* Compilation:: Compiling for Debugging -* Starting:: Starting your Program -* Arguments:: Your Program's Arguments -* Environment:: Your Program's Environment -* Working Directory:: Your Program's Working Directory -* Input/Output:: Your Program's Input and Output -* Attach:: Debugging an Already-Running Process -* Kill Process:: Killing the Child Process -@end menu - -@node Compilation, Starting, Running, Running -@section Compiling for Debugging - -In order to debug a program effectively, you need to generate -debugging information when you compile it. This debugging information -is stored in the object file; it describes the data type of each -variable or function and the correspondence between source line numbers -and addresses in the executable code. - -To request debugging information, specify the @samp{-g} option when you run -the compiler. - -Many C compilers are unable to handle the @samp{-g} and @samp{-O} -options together. Using those compilers, you cannot generate optimized -executables containing debugging information. - -The GNU C compiler supports @samp{-g} with or without @samp{-O}, making it -possible to debug optimized code. We recommend that you @emph{always} use -@samp{-g} whenever you compile a program. You may think the program is -correct, but there's no sense in pushing your luck. - -Some things do not work as well with @samp{-g -O} as with just -@samp{-g}, particularly on machines with instruction scheduling. If in -doubt, recompile with @samp{-g} alone, and if this fixes the problem, -please report it as a bug (including a test case!). - -Older versions of the GNU C compiler permitted a variant option -@samp{-gg} for debugging information. _GDBN__ no longer supports this -format; if your GNU C compiler has this option, do not use it. - -@ignore -@comment As far as I know, there are no cases in which _GDBN__ will -@comment produce strange output in this case. (but no promises). -If your program includes archives made with the @code{ar} program, and -if the object files used as input to @code{ar} were compiled without the -@samp{-g} option and have names longer than 15 characters, _GDBN__ will get -confused reading the program's symbol table. No error message will be -given, but _GDBN__ may behave strangely. The reason for this problem is a -deficiency in the Unix archive file format, which cannot represent file -names longer than 15 characters. - -To avoid this problem, compile the archive members with the @samp{-g} -option or use shorter file names. Alternatively, use a version of GNU -@code{ar} dated more recently than August 1989. -@end ignore - - -@node Starting, Arguments, Compilation, Running -@section Starting your Program -@cindex starting -@cindex running -@table @code -@item run -@itemx r -@kindex run -Use the @code{run} command to start your program under _GDBN__. -_if__(_VXWORKS__) -Except on VxWorks, you -_fi__(_VXWORKS__) -_if__(!_VXWORKS__) -You -_fi__(!_VXWORKS__) -must first specify the program name with an argument to _GDBN__ -(@pxref{Invocation}), or using the @code{file} or @code{exec-file} -command (@pxref{Files}).@refill -@end table - -On targets that support processes, @code{run} creates an inferior -process and makes that process run your program. On other targets, -@code{run} jumps to the start of the program. - -The execution of a program is affected by certain information it -receives from its superior. _GDBN__ provides ways to specify this -information, which you must do @i{before} starting the program. (You -can change it after starting the program, but such changes will only affect -the program the next time you start it.) This information may be -divided into four categories: - -@table @asis -@item The @i{arguments.} -You specify the arguments to give your program as the arguments of the -@code{run} command. If a shell is available on your target, the shell -is used to pass the arguments, so that you may use normal conventions -(such as wildcard expansion or variable substitution) in -describing the arguments. In Unix systems, you can control which shell -is used with the @code{SHELL} environment variable. @xref{Arguments}.@refill - -@item The @i{environment.} -Your program normally inherits its environment from _GDBN__, but you can -use the _GDBN__ commands @code{set environment} and @code{unset -environment} to change parts of the environment that will be given to -the program. @xref{Environment}.@refill - -@item The @i{working directory.} -Your program inherits its working directory from _GDBN__. You can set -_GDBN__'s working directory with the @code{cd} command in _GDBN__. -@xref{Working Directory}. - -@item The @i{standard input and output.} -Your program normally uses the same device for standard input and -standard output as _GDBN__ is using. You can redirect input and output -in the @code{run} command line, or you can use the @code{tty} command to -set a different device for your program. -@xref{Input/Output}. -@end table - -When you issue the @code{run} command, your program begins to execute -immediately. @xref{Stopping}, for discussion of how to arrange for your -program to stop. Once your program has been started by the @code{run} -command (and then stopped), you may evaluate expressions that involve -calls to functions in the inferior, using the @code{print} or -@code{call} commands. @xref{Data}. - -If the modification time of your symbol file has changed since the last -time _GDBN__ read its symbols, _GDBN__ will discard its symbol table and re-read -it. In this process, it tries to retain your current breakpoints. - -@node Arguments, Environment, Starting, Running -@section Your Program's Arguments - -@cindex arguments (to your program) -The arguments to your program can be specified by the arguments of the -@code{run} command. They are passed to a shell, which expands wildcard -characters and performs redirection of I/O, and thence to the program. -_GDBN__ uses the shell indicated by your environment variable -@code{SHELL} if it exists; otherwise, _GDBN__ uses @code{/bin/sh}. - -@code{run} with no arguments uses the same arguments used by the previous -@code{run}, or those set by the @code{set args} command. - -@kindex set args -@table @code -@item set args -Specify the arguments to be used the next time your program is run. If -@code{set args} has no arguments, @code{run} will execute your program -with no arguments. Once you have run your program with arguments, this -is the only way to run it again without arguments. - -@item show args -@kindex show args -Show the arguments to give your program when it is started. -@end table - -@node Environment, Working Directory, Arguments, Running -@section Your Program's Environment - -@cindex environment (of your program) -The @dfn{environment} consists of a set of environment variables and -their values. Environment variables conventionally record such things as -your user name, your home directory, your terminal type, and your search -path for programs to run. Usually you set up environment variables with -the shell and they are inherited by all the other programs you run. When -debugging, it can be useful to try running the program with a modified -environment without having to start _GDBN__ over again. - -@table @code -@item path @var{directory} -@kindex path -Add @var{directory} to the front of the @code{PATH} environment variable -(the search path for executables), for both _GDBN__ and your program. -You may specify several directory names, separated by @samp{:} or -whitespace. If @var{directory} is already in the path, it is moved to -the front, so it will be searched sooner. You can use the string -@samp{$cwd} to refer to whatever is the current working directory at the -time _GDBN__ searches the path. @footnote{If you use @samp{.} instead, -it refers to the directory where you executed the @code{path} command. -_GDBN__ fills in the current path where needed in the @var{directory} -argument, before adding it to the search path.} -@c 'path' is explicitly nonrepeatable, but RMS points out it's silly to -@c document that, since repeating it would be a no-op. - -@item show paths -@kindex show paths -Display the list of search paths for executables (the @code{PATH} -environment variable). - -@item show environment @var{varname} -@kindex show environment -Print the value of environment variable @var{varname} to be given to -your program when it starts. - -@item show environment -Print the names and values of all environment variables to be given to -your program. - -@item set environment @var{varname} @var{value} -@itemx set environment @var{varname} = @var{value} -@kindex set environment -Sets environment variable @var{varname} to @var{value}. The value -changes for your program only, not for _GDBN__ itself. @var{value} may -be any string; the values of environment variables are just strings, and -any interpretation is supplied by your program itself. The @var{value} -parameter is optional; if it is eliminated, the variable is set to a -null value. -@c "any string" here doesn't include leading, trailing -@c blanks. Gnu asks: does anyone care? - -For example, this command: - -@example -set env USER = foo -@end example - -@noindent -tells a Unix program, when subsequently run, that its user is named -@samp{foo}. (The spaces around @samp{=} are used for clarity here; they -are not actually required.) - -@item unset environment @var{varname} -@kindex unset environment -Remove variable @var{varname} from the environment to be passed to your -program. This is different from @samp{set env @var{varname} =}; -@code{unset environment} removes the variable from the environment, -rather than assigning it an empty value. -@end table - -@node Working Directory, Input/Output, Environment, Running -@section Your Program's Working Directory - -@cindex working directory (of your program) -Each time you start your program with @code{run}, it inherits its -working directory from the current working directory of _GDBN__. _GDBN__'s -working directory is initially whatever it inherited from its parent -process (typically the shell), but you can specify a new working -directory in _GDBN__ with the @code{cd} command. - -The _GDBN__ working directory also serves as a default for the commands -that specify files for _GDBN__ to operate on. @xref{Files}. - -@table @code -@item cd @var{directory} -@kindex cd -Set _GDBN__'s working directory to @var{directory}. - -@item pwd -@kindex pwd -Print _GDBN__'s working directory. -@end table - -@node Input/Output, Attach, Working Directory, Running -@section Your Program's Input and Output - -@cindex redirection -@cindex i/o -@cindex terminal -@cindex controlling terminal -By default, the program you run under _GDBN__ does input and output to -the same terminal that _GDBN__ uses. _GDBN__ switches the terminal to -its own terminal modes to interact with you, but it records the terminal -modes your program was using and switches back to them when you continue -running your program. - -@table @code -@item info terminal -@kindex info terminal -Displays _GDBN__'s recorded information about the terminal modes your -program is using. -@end table - -You can redirect the program's input and/or output using shell -redirection with the @code{run} command. For example, - -_0__@example -run > outfile -_1__@end example - -@noindent -starts the program, diverting its output to the file @file{outfile}. - -@kindex tty -Another way to specify where the program should do input and output is -with the @code{tty} command. This command accepts a file name as -argument, and causes this file to be the default for future @code{run} -commands. It also resets the controlling terminal for the child -process, for future @code{run} commands. For example, - -@example -tty /dev/ttyb -@end example - -@noindent -directs that processes started with subsequent @code{run} commands -default to do input and output on the terminal @file{/dev/ttyb} and have -that as their controlling terminal. - -An explicit redirection in @code{run} overrides the @code{tty} command's -effect on the input/output device, but not its effect on the controlling -terminal. - -When you use the @code{tty} command or redirect input in the @code{run} -command, only the input @emph{for your program} is affected. The input -for _GDBN__ still comes from your terminal. - -@node Attach, Kill Process, Input/Output, Running -@section Debugging an Already-Running Process -@kindex attach -@cindex attach - -@table @code -@item attach @var{process-id} -This command -attaches to a running process---one that was started outside _GDBN__. -(@code{info files} will show your active targets.) The command takes as -argument a process ID. The usual way to find out the process-id of -a Unix process is with the @code{ps} utility, or with the @samp{jobs -l} -shell command. - -@code{attach} will not repeat if you press @key{RET} a second time after -executing the command. -@end table - -To use @code{attach}, you must be debugging in an environment which -supports processes. You must also have permission to send the process a -signal, and it must have the same effective user ID as the _GDBN__ -process. - -When using @code{attach}, you should first use the @code{file} command -to specify the program running in the process and load its symbol table. -@xref{Files}. - -The first thing _GDBN__ does after arranging to debug the specified -process is to stop it. You can examine and modify an attached process -with all the _GDBN__ commands that ordinarily available when you start -processes with @code{run}. You can insert breakpoints; you can step and -continue; you can modify storage. If you would rather the process -continue running, you may use the @code{continue} command after -attaching _GDBN__ to the process. - -@table @code -@item detach -@kindex detach -When you have finished debugging the attached process, you can use the -@code{detach} command to release it from _GDBN__'s control. Detaching -the process continues its execution. After the @code{detach} command, -that process and _GDBN__ become completely independent once more, and you -are ready to @code{attach} another process or start one with @code{run}. -@code{detach} will not repeat if you press @key{RET} again after -executing the command. -@end table - -If you exit _GDBN__ or use the @code{run} command while you have an attached -process, you kill that process. By default, you will be asked for -confirmation if you try to do either of these things; you can control -whether or not you need to confirm by using the @code{set confirm} command -(@pxref{Messages/Warnings}). - -@node Kill Process, , Attach, Running -@c @group -@section Killing the Child Process - -@table @code -@item kill -@kindex kill -Kill the child process in which your program is running under _GDBN__. -@end table - -This command is useful if you wish to debug a core dump instead of a -running process. _GDBN__ ignores any core dump file while your program -is running. -@c @end group - -On some operating systems, you can't execute your program in another -process while breakpoints are active inside _GDBN__. You can use the -@code{kill} command in this situation to permit running the program -outside the debugger. - -The @code{kill} command is also useful if you wish to recompile and -relink the program, since on many systems it is impossible to modify an -executable file which is running in a process. In this case, when you -next type @code{run}, _GDBN__ will notice that the file has changed, and -will re-read the symbol table (while trying to preserve your current -breakpoint settings). diff --git a/gdb/doc/gdb.sample-m4 b/gdb/doc/gdb.sample-m4 deleted file mode 100755 index ae258ad69f2..00000000000 --- a/gdb/doc/gdb.sample-m4 +++ /dev/null @@ -1,263 +0,0 @@ -_dnl__ -*- Texinfo -*- -_dnl__ Copyright (c) 1991 Free Software Foundation, Inc. -_dnl__ This file is part of the source for the GDB manual. -@c M4 FRAGMENT: $Id$ -@node Sample Session, Invocation, New Features, Top -@chapter A Sample _GDBN__ Session - -You can use this manual at your leisure to read all about _GDBN__. -However, a handful of commands are enough to get started using the -debugger. This chapter illustrates these commands. - -@iftex -In this sample session, we emphasize user input like this: @i{input}, -to make it easier to pick out from the surrounding output. -@end iftex - -@c FIXME: this example may not be appropriate for some configs, where -@c FIXME...primary interest is in remote use. -_0__ -One of the preliminary versions of GNU @code{m4} (a generic macro -processor) exhibits the following bug: sometimes, when we change its -quote strings from the default, the commands used to capture one macro's -definition in another stop working. In the following short @code{m4} -session, we define a macro @code{foo} which expands to @code{0000}; we -then use the @code{m4} builtin @code{defn} to define @code{bar} as the -same thing. However, when we change the open quote string to -@code{} and the close quote string to @code{}, the same -procedure fails to define a new synonym @code{baz}: - -@smallexample -$ @i{cd gnu/m4} -$ @i{./m4} -@i{define(foo,0000)} - -@i{foo} -0000 -@i{define(bar,defn(`foo'))} - -@i{bar} -0000 -@i{changequote(,)} - -@i{define(baz,defn(foo))} -@i{baz} -@i{C-D} -m4: End of input: 0: fatal error: EOF in string -@end smallexample - -@noindent -Let's use _GDBN__ to try to see what's going on. - -@smallexample -$ @i{_GDBP__ m4} -Reading symbol data from m4...done. -(_GDBP__) -@end smallexample - -@noindent -_GDBN__ only reads enough symbol data to know where to find the rest -when needed; as a result, the first prompt comes up very quickly. We -then tell _GDBN__ to use a narrower display width than usual, so -that examples will fit in this manual. - -@smallexample -(_GDBP__) @i{set width 70} -@end smallexample - -@noindent -Let's see how the @code{m4} builtin @code{changequote} works. -Having looked at the source, we know the relevant subroutine is -@code{m4_changequote}, so we set a breakpoint there with _GDBN__'s -@code{break} command. - -@smallexample -(_GDBP__) @i{break m4_changequote} -Breakpoint 1 at 0x62f4: file builtin.c, line 879. -@end smallexample - -@noindent -Using the @code{run} command, we start @code{m4} running under _GDBN__ -control; as long as control does not reach the @code{m4_changequote} -subroutine, the program runs as usual: - -@smallexample -(_GDBP__) @i{run} -Starting program: /work/Editorial/gdb/gnu/m4/m4 -@i{define(foo,0000)} - -@i{foo} -0000 -@end smallexample - -@noindent -To trigger the breakpoint, we call @code{changequote}. _GDBN__ -suspends execution of @code{m4}, displaying information about the -context where it stops. - -@smallexample -@i{changequote(,)} - -Breakpoint 1, m4_changequote (argc=3, argv=0x33c70) at builtin.c:879 -879 if (bad_argc(TOKEN_DATA_TEXT(argv[0]), argc, 1, 3)) -@end smallexample - -@noindent -Now we use the command @code{n} (@code{next}) to advance execution to -the next line of the current function. - -@smallexample -(_GDBP__) @i{n} -882 set_quotes((argc >= 2) ? TOKEN_DATA_TEXT(argv[1]) : nil, -@end smallexample - -@noindent -@code{set_quotes} looks like a promising subroutine. We can go into it -by using the command @code{s} (@code{step}) instead of @code{next}. -@code{step} goes to the next line to be executed in @emph{any} -subroutine, so it steps into @code{set_quotes}. - -@smallexample -(_GDBP__) @i{s} -set_quotes (lq=0x34c78 "", rq=0x34c88 "") - at input.c:530 -530 if (lquote != def_lquote) -@end smallexample - -@noindent -The summary display showing the subroutine where @code{m4} is now -suspended (and its arguments) is called a stack frame display. We can -use the @code{backtrace} command (which can also be spelled @code{bt}), -to see where we are in the stack: it displays a stack frame for each -active subroutine. - -@smallexample -(_GDBP__) @i{bt} -#0 set_quotes (lq=0x34c78 "", rq=0x34c88 "") - at input.c:530 -#1 0x6344 in m4_changequote (argc=3, argv=0x33c70) at builtin.c:882 -#2 0x8174 in expand_macro (sym=0x33320) at macro.c:242 -#3 0x7a88 in expand_token (obs=0x0, t=209696, td=0xf7fffa30) - at macro.c:71 -#4 0x79dc in expand_input () at macro.c:40 -#5 0x2930 in main (argc=0, argv=0xf7fffb20) at m4.c:195 -@end smallexample - -@noindent -Let's step through a few more lines to see what happens. The first two -times, we can use @samp{s}; the next two times we use @code{n} to avoid -falling into the @code{xstrdup} subroutine. -@smallexample -(_GDBP__) @i{s} -0x3b5c 532 if (rquote != def_rquote) -(_GDBP__) @i{s} -0x3b80 535 lquote = (lq == nil || *lq == '\0') ? def_lquote :\ - xstrdup(lq); -(_GDBP__) @i{n} -536 rquote = (rq == nil || *rq == '\0') ? def_rquote : xstrdup\ -(rq); -(_GDBP__) @i{n} -538 len_lquote = strlen(rquote); -@end smallexample - -@noindent -The last line displayed looks a little odd; let's examine the variables -@code{lquote} and @code{rquote} to see if they are in fact the new left -and right quotes we specified. We can use the command @code{p} -(@code{print}) to see their values. - -@smallexample -(_GDBP__) @i{p lquote} -$1 = 0x35d40 "" -(_GDBP__) @i{p rquote} -$2 = 0x35d50 "" -@end smallexample - -@noindent -@code{lquote} and @code{rquote} are indeed the new left and right quotes. -Let's look at some context; we can display ten lines of source -surrounding the current line, with the @code{l} (@code{list}) command. - -@smallexample -(_GDBP__) @i{l} -533 xfree(rquote); -534 -535 lquote = (lq == nil || *lq == '\0') ? def_lquote : xstrdup\ -(lq); -536 rquote = (rq == nil || *rq == '\0') ? def_rquote : xstrdup\ -(rq); -537 -538 len_lquote = strlen(rquote); -539 len_rquote = strlen(lquote); -540 @} -541 -542 void -@end smallexample - -@noindent -Let's step past the two lines that set @code{len_lquote} and -@code{len_rquote}, and then examine the values of those variables. - -@smallexample -(_GDBP__) @i{n} -539 len_rquote = strlen(lquote); -(_GDBP__) @i{n} -540 @} -(_GDBP__) @i{p len_lquote} -$3 = 9 -(_GDBP__) @i{p len_rquote} -$4 = 7 -@end smallexample - -@noindent -That certainly looks wrong, assuming @code{len_lquote} and -@code{len_rquote} are meant to be the lengths of @code{lquote} and -@code{rquote} respectively. Let's try setting them to better values. -We can use the @code{p} command for this, since it'll print the value of -any expression---and that expression can include subroutine calls and -assignments. - -@smallexample -(_GDBP__) p len_lquote=strlen(lquote) -$5 = 7 -(_GDBP__) p len_rquote=strlen(rquote) -$6 = 9 -@end smallexample - -@noindent -Let's see if that fixes the problem of using the new quotes with the -@code{m4} built-in @code{defn}. We can allow @code{m4} to continue -executing with the @code{c} (@code{continue}) command, and then try the -example that caused trouble initially: - -@smallexample -(_GDBP__) @i{c} -Continuing. - -@i{define(baz,defn(foo))} - -baz -0000 -@end smallexample - -@noindent -Success! The new quotes now work just as well as the default ones. The -problem seems to have been just the two typos defining the wrong -lengths. We'll let @code{m4} exit by giving it an EOF as input. - -@smallexample -@i{C-D} -Program exited normally. -@end smallexample - -@noindent -The message @samp{Program exited normally.} is from _GDBN__; it -indicates @code{m4} has finished executing. We can end our _GDBN__ -session with the _GDBN__ @code{quit} command. - -@smallexample -(_GDBP__) @i{quit} - -$ -_1__@end smallexample - diff --git a/gdb/doc/gdb.src-m4 b/gdb/doc/gdb.src-m4 deleted file mode 100755 index fdc6e3382a6..00000000000 --- a/gdb/doc/gdb.src-m4 +++ /dev/null @@ -1,288 +0,0 @@ -_dnl__ -*- Texinfo -*- -_dnl__ Copyright (c) 1988 1989 1990 1991 Free Software Foundation, Inc. -_dnl__ This file is part of the source for the GDB manual. -@c M4 FRAGMENT: $Id$ -@node Source, Data, Stack, Top -@chapter Examining Source Files - -_GDBN__ can print parts of your program's source, since the debugging -information recorded in your program tells _GDBN__ what source files -were used to built it. When your program stops, _GDBN__ spontaneously -prints the line where it stopped. Likewise, when you select a stack -frame (@pxref{Selection}), _GDBN__ prints the line where execution in -that frame has stopped. You can print other portions of source files by -explicit command. - -If you use _GDBN__ through its GNU Emacs interface, you may prefer to -use Emacs facilities to view source; @pxref{Emacs}. - -@menu -* List:: Printing Source Lines -* Search:: Searching Source Files -* Source Path:: Specifying Source Directories -* Machine Code:: Source and Machine Code -@end menu - -@node List, Search, Source, Source -@section Printing Source Lines - -@kindex list -@kindex l -To print lines from a source file, use the @code{list} command -(abbreviated @code{l}). There are several ways to specify what part -of the file you want to print. - -Here are the forms of the @code{list} command most commonly used: - -@table @code -@item list @var{linenum} -Print ten lines centered around line number @var{linenum} in the -current source file. - -@item list @var{function} -Print ten lines centered around the beginning of function -@var{function}. - -@item list -Print ten more lines. If the last lines printed were printed with a -@code{list} command, this prints ten lines following the last lines -printed; however, if the last line printed was a solitary line printed -as part of displaying a stack frame (@pxref{Stack}), this prints ten -lines centered around that line. - -@item list - -Print ten lines just before the lines last printed. -@end table - -Repeating a @code{list} command with @key{RET} discards the argument, -so it is equivalent to typing just @code{list}. This is more useful -than listing the same lines again. An exception is made for an -argument of @samp{-}; that argument is preserved in repetition so that -each repetition moves up in the source file. - -@cindex linespec -In general, the @code{list} command expects you to supply zero, one or two -@dfn{linespecs}. Linespecs specify source lines; there are several ways -of writing them but the effect is always to specify some source line. -Here is a complete description of the possible arguments for @code{list}: - -@table @code -@item list @var{linespec} -Print ten lines centered around the line specified by @var{linespec}. - -@item list @var{first},@var{last} -Print lines from @var{first} to @var{last}. Both arguments are -linespecs. - -@item list ,@var{last} -Print ten lines ending with @var{last}. - -@item list @var{first}, -Print ten lines starting with @var{first}. - -@item list + -Print ten lines just after the lines last printed. - -@item list - -Print ten lines just before the lines last printed. - -@item list -As described in the preceding table. -@end table - -Here are the ways of specifying a single source line---all the -kinds of linespec. - -@table @code -@item @var{number} -Specifies line @var{number} of the current source file. -When a @code{list} command has two linespecs, this refers to -the same source file as the first linespec. - -@item +@var{offset} -Specifies the line @var{offset} lines after the last line printed. -When used as the second linespec in a @code{list} command that has -two, this specifies the line @var{offset} lines down from the -first linespec. - -@item -@var{offset} -Specifies the line @var{offset} lines before the last line printed. - -@item @var{filename}:@var{number} -Specifies line @var{number} in the source file @var{filename}. - -@item @var{function} -@c FIXME: "of the open-brace" is C-centric. When we add other langs... -Specifies the line of the open-brace that begins the body of the -function @var{function}. - -@item @var{filename}:@var{function} -Specifies the line of the open-brace that begins the body of the -function @var{function} in the file @var{filename}. You only need the -file name with a function name to avoid ambiguity when there are -identically named functions in different source files. - -@item *@var{address} -Specifies the line containing the program address @var{address}. -@var{address} may be any expression. -@end table - -@node Search, Source Path, List, Source -@section Searching Source Files -@cindex searching -@kindex reverse-search - -There are two commands for searching through the current source file for a -regular expression. - -@table @code -@item forward-search @var{regexp} -@itemx search @var{regexp} -@kindex search -@kindex forward-search -The command @samp{forward-search @var{regexp}} checks each line, starting -with the one following the last line listed, for a match for @var{regexp}. -It lists the line that is found. You can abbreviate the command name -as @code{fo}. The synonym @samp{search @var{regexp}} is also supported. - -@item reverse-search @var{regexp} -The command @samp{reverse-search @var{regexp}} checks each line, starting -with the one before the last line listed and going backward, for a match -for @var{regexp}. It lists the line that is found. You can abbreviate -this command as @code{rev}. -@end table - -@node Source Path, Machine Code, Search, Source -@section Specifying Source Directories - -@cindex source path -@cindex directories for source files -Executable programs sometimes do not record the directories of the source -files from which they were compiled, just the names. Even when they do, -the directories could be moved between the compilation and your debugging -session. _GDBN__ has a list of directories to search for source files; -this is called the @dfn{source path}. Each time _GDBN__ wants a source file, -it tries all the directories in the list, in the order they are present -in the list, until it finds a file with the desired name. Note that -the executable search path is @emph{not} used for this purpose. Neither is -the current working directory, unless it happens to be in the source -path. - -If _GDBN__ can't find a source file in the source path, and the object -program records a directory, _GDBN__ tries that directory too. If the -source path is empty, and there is no record of the compilation -directory, _GDBN__ will, as a last resort, look in the current -directory. - -Whenever you reset or rearrange the source path, _GDBN__ will clear out -any information it has cached about where source files are found, where -each line is in the file, etc. - -@kindex directory -When you start _GDBN__, its source path is empty. -To add other directories, use the @code{directory} command. - -@table @code -@item directory @var{dirname} @dots{} -Add directory @var{dirname} to the front of the source path. Several -directory names may be given to this command, separated by @samp{:} or -whitespace. You may specify a directory that is already in the source -path; this moves it forward, so it will be searched sooner. You can use -the string @samp{$cdir} to refer to the compilation directory (if one is -recorded), and @samp{$cwd} to refer to the current working directory. -@footnote{@samp{$cwd} is not the same as @samp{.}---the former tracks -the current working directory as it changes during your _GDBN__ session, -while the latter is immediately expanded to the current directory at the -time you add an entry to the source path.} - -@item directory -Reset the source path to empty again. This requires confirmation. - -@c RET-repeat for @code{directory} is explicitly disabled, but since -@c repeating it would be a no-op we don't say that. (thanks to RMS) - -@item show directories -@kindex show directories -Print the source path: show which directories it contains. -@end table - -If your source path is cluttered with directories that are no longer of -interest, _GDBN__ may sometimes cause confusion by finding the wrong -versions of source. You can correct the situation as follows: - -@enumerate -@item -Use @code{directory} with no argument to reset the source path to empty. - -@item -Use @code{directory} with suitable arguments to reinstall the -directories you want in the source path. You can add all the -directories in one command. -@end enumerate - -@node Machine Code, , Source Path, Source -@section Source and Machine Code -You can use the command @code{info line} to map source lines to program -addresses (and viceversa), and the command @code{disassemble} to display -a range of addresses as machine instructions. - -@table @code -@item info line @var{linespec} -@kindex info line -Print the starting and ending addresses of the compiled code for -source line @var{linespec}. You can specify source lines in any of the -ways understood by the @code{list} command (@pxref{List}). -@end table - -For example, we can use @code{info line} to inquire on where the object -code for the first line of function @code{m4_changequote} lies: -@smallexample -(_GDBP__) info line m4_changecom -Line 895 of "builtin.c" starts at pc 0x634c and ends at 0x6350. -@end smallexample - -@noindent -We can also inquire (using @code{*@var{addr}} as the form for -@var{linespec}) what source line covers a particular address: -@smallexample -(_GDBP__) info line *0x63ff -Line 926 of "builtin.c" starts at pc 0x63e4 and ends at 0x6404. -@end smallexample - -@kindex $_ -After @code{info line}, the default address for the @code{x} -command is changed to the starting address of the line, so that -@samp{x/i} is sufficient to begin examining the machine code -(@pxref{Memory}). Also, this address is saved as the value of the -convenience variable @code{$_} (@pxref{Convenience Vars}). - -@table @code -@kindex disassemble -@item disassemble -This specialized command is provided to dump a range of memory as -machine instructions. The default memory range is the function -surrounding the program counter of the selected frame. A single -argument to this command is a program counter value; the function -surrounding this value will be dumped. Two arguments (separated by one -or more spaces) specify a range of addresses (first inclusive, second -exclusive) to be dumped. -@end table - -We can use @code{disassemble} to inspect the object code -range shown in the last @code{info line} example: - -@smallexample -(_GDBP__) disas 0x63e4 0x6404 -Dump of assembler code from 0x63e4 to 0x6404: -0x63e4 : ble 0x63f8 -0x63e8 : sethi %hi(0x4c00), %o0 -0x63ec : ld [%i1+4], %o0 -0x63f0 : b 0x63fc -0x63f4 : ld [%o0+4], %o0 -0x63f8 : or %o0, 0x1a4, %o0 -0x63fc : call 0x9288 -0x6400 : nop -End of assembler dump. -(_GDBP__) - -@end smallexample diff --git a/gdb/doc/gdb.stack-m4 b/gdb/doc/gdb.stack-m4 deleted file mode 100755 index 4bed2f59070..00000000000 --- a/gdb/doc/gdb.stack-m4 +++ /dev/null @@ -1,279 +0,0 @@ -_dnl__ -*- Texinfo -*- -_dnl__ Copyright (c) 1988 1989 1990 1991 Free Software Foundation, Inc. -_dnl__ This file is part of the source for the GDB manual. -@c M4 FRAGMENT: $Id$ -@node Stack, Source, Stopping, Top -@chapter Examining the Stack - -When your program has stopped, the first thing you need to know is where it -stopped and how it got there. - -@cindex call stack -Each time your program performs a function call, the information about -where in the program the call was made from is saved in a block of data -called a @dfn{stack frame}. The frame also contains the arguments of the -call and the local variables of the function that was called. All the -stack frames are allocated in a region of memory called the @dfn{call -stack}. - -When your program stops, the _GDBN__ commands for examining the stack allow you -to see all of this information. - -@cindex selected frame -One of the stack frames is @dfn{selected} by _GDBN__ and many _GDBN__ commands -refer implicitly to the selected frame. In particular, whenever you ask -_GDBN__ for the value of a variable in the program, the value is found in the -selected frame. There are special _GDBN__ commands to select whichever frame -you are interested in. - -When the program stops, _GDBN__ automatically selects the currently executing -frame and describes it briefly as the @code{frame} command does -(@pxref{Frame Info, Info}). - -@menu -* Frames:: Stack Frames -* Backtrace:: Backtraces -* Selection:: Selecting a Frame -* Frame Info:: Information on a Frame -@end menu - -@node Frames, Backtrace, Stack, Stack -@section Stack Frames - -@cindex frame -@cindex stack frame -The call stack is divided up into contiguous pieces called @dfn{stack -frames}, or @dfn{frames} for short; each frame is the data associated -with one call to one function. The frame contains the arguments given -to the function, the function's local variables, and the address at -which the function is executing. - -@cindex initial frame -@cindex outermost frame -@cindex innermost frame -When your program is started, the stack has only one frame, that of the -function @code{main}. This is called the @dfn{initial} frame or the -@dfn{outermost} frame. Each time a function is called, a new frame is -made. Each time a function returns, the frame for that function invocation -is eliminated. If a function is recursive, there can be many frames for -the same function. The frame for the function in which execution is -actually occurring is called the @dfn{innermost} frame. This is the most -recently created of all the stack frames that still exist. - -@cindex frame pointer -Inside your program, stack frames are identified by their addresses. A -stack frame consists of many bytes, each of which has its own address; each -kind of computer has a convention for choosing one of those bytes whose -address serves as the address of the frame. Usually this address is kept -in a register called the @dfn{frame pointer register} while execution is -going on in that frame. - -@cindex frame number -_GDBN__ assigns numbers to all existing stack frames, starting with -zero for the innermost frame, one for the frame that called it, -and so on upward. These numbers do not really exist in your program; -they are assigned by _GDBN__ to give you a way of designating stack -frames in _GDBN__ commands. - -@cindex frameless execution -Some compilers allow functions to be compiled so that they operate -without stack frames. (For example, the @code{_GCC__} option -@samp{-fomit-frame-pointer} will generate functions without a frame.) -This is occasionally done with heavily used library functions to save -the frame setup time. _GDBN__ has limited facilities for dealing with -these function invocations. If the innermost function invocation has no -stack frame, _GDBN__ will nevertheless regard it as though it had a -separate frame, which is numbered zero as usual, allowing correct -tracing of the function call chain. However, _GDBN__ has no provision -for frameless functions elsewhere in the stack. - -@node Backtrace, Selection, Frames, Stack -@section Backtraces - -A backtrace is a summary of how the program got where it is. It shows one -line per frame, for many frames, starting with the currently executing -frame (frame zero), followed by its caller (frame one), and on up the -stack. - -@table @code -@item backtrace -@itemx bt -@kindex backtrace -@kindex bt -Print a backtrace of the entire stack: one line per frame for all -frames in the stack. - -You can stop the backtrace at any time by typing the system interrupt -character, normally @kbd{Control-C}. - -@item backtrace @var{n} -@itemx bt @var{n} -Similar, but print only the innermost @var{n} frames. - -@item backtrace -@var{n} -@itemx bt -@var{n} -Similar, but print only the outermost @var{n} frames. -@end table - -@kindex where -@kindex info stack -@kindex info s -The names @code{where} and @code{info stack} (abbreviated @code{info s}) -are additional aliases for @code{backtrace}. - -Each line in the backtrace shows the frame number and the function name. -The program counter value is also shown---unless you use @code{set -print address off}. The backtrace also shows the source file name and -line number, as well as the arguments to the function. The program -counter value is omitted if it is at the beginning of the code for that -line number. - -Here is an example of a backtrace. It was made with the command -@samp{bt 3}, so it shows the innermost three frames. - -@smallexample -@group -#0 m4_traceon (obs=0x24eb0, argc=1, argv=0x2b8c8) at builtin.c:993 -#1 0x6e38 in expand_macro (sym=0x2b600) at macro.c:242 -#2 0x6840 in expand_token (obs=0x0, t=177664, td=0xf7fffb08) - at macro.c:71 -(More stack frames follow...) -@end group -@end smallexample - -@noindent -The display for frame zero doesn't begin with a program counter -value, indicating that the program has stopped at the beginning of the -code for line @code{993} of @code{builtin.c}. - -@node Selection, Frame Info, Backtrace, Stack -@section Selecting a Frame - -Most commands for examining the stack and other data in the program work on -whichever stack frame is selected at the moment. Here are the commands for -selecting a stack frame; all of them finish by printing a brief description -of the stack frame just selected. - -@table @code -@item frame @var{n} -@itemx f @var{n} -@kindex frame -@kindex f -Select frame number @var{n}. Recall that frame zero is the innermost -(currently executing) frame, frame one is the frame that called the -innermost one, and so on. The highest-numbered frame is @code{main}'s -frame. - -@item frame @var{addr} -@itemx f @var{addr} -Select the frame at address @var{addr}. This is useful mainly if the -chaining of stack frames has been damaged by a bug, making it -impossible for _GDBN__ to assign numbers properly to all frames. In -addition, this can be useful when the program has multiple stacks and -switches between them. - -_if_(_SPARC__) -On the SPARC architecture, @code{frame} needs two addresses to -select an arbitrary frame: a frame pointer and a stack pointer. -@c note to future updaters: this is conditioned on a flag -@c FRAME_SPECIFICATION_DYADIC in the tm-*.h files, currently only used -@c by SPARC, hence the specific attribution. Generalize or list all -@c possibilities if more supported machines start doing this. -_fi_(_SPARC__) - -@item up @var{n} -@kindex up -Move @var{n} frames up the stack. For positive numbers @var{n}, this -advances toward the outermost frame, to higher frame numbers, to frames -that have existed longer. @var{n} defaults to one. - -@item down @var{n} -@kindex down -@kindex do -Move @var{n} frames down the stack. For positive numbers @var{n}, this -advances toward the innermost frame, to lower frame numbers, to frames -that were created more recently. @var{n} defaults to one. You may -abbreviate @code{down} as @code{do}. -@end table - -All of these commands end by printing two lines of output describing the -frame. The first line shows the frame number, the function name, the -arguments, and the source file and line number of execution in that -frame. The second line shows the text of that source line. For -example: - -@smallexample -(_GDBP__) up -#1 0x22f0 in main (argc=1, argv=0xf7fffbf4, env=0xf7fffbfc) at env.c:10 -10 read_input_file (argv[i]); -@end smallexample - -After such a printout, the @code{list} command with no arguments will print -ten lines centered on the point of execution in the frame. @xref{List}. - -@table @code -@item up-silently @var{n} -@itemx down-silently @var{n} -@kindex down-silently -@kindex up-silently -These two commands are variants of @code{up} and @code{down}, -respectively; they differ in that they do their work silently, without -causing display of the new frame. They are intended primarily for use -in _GDBN__ command scripts, where the output might be unnecessary and -distracting. - -@end table - -@node Frame Info, , Selection, Stack -@section Information About a Frame - -There are several other commands to print information about the selected -stack frame. - -@table @code -@item frame -@itemx f -When used without any argument, this command does not change which frame -is selected, but prints a brief description of the currently -selected stack frame. It can be abbreviated @code{f}. With an -argument, this command is used to select a stack frame (@pxref{Selection}). - -@item info frame -@kindex info frame -@itemx info f -@kindex info f -This command prints a verbose description of the selected stack frame, -including the address of the frame, the addresses of the next frame down -(called by this frame) and the next frame up (caller of this frame), -the address of the frame's arguments, the program counter saved in it -(the address of execution in the caller frame), and which registers -were saved in the frame. The verbose description is useful when -something has gone wrong that has made the stack format fail to fit -the usual conventions. - -@item info frame @var{addr} -@itemx info f @var{addr} -Print a verbose description of the frame at address @var{addr}, -without selecting that frame. The selected frame remains unchanged by -this command. - -@item info args -@kindex info args -Print the arguments of the selected frame, each on a separate line. - -@item info locals -@kindex info locals -Print the local variables of the selected frame, each on a separate -line. These are all variables declared static or automatic within all -program blocks that execution in this frame is currently inside of. - -@item info catch -@kindex info catch -@cindex catch exceptions -@cindex exception handlers -Print a list of all the exception handlers that are active in the -current stack frame at the current point of execution. To see other -exception handlers, visit the associated frame (using the @code{up}, -@code{down}, or @code{frame} commands); then type @code{info catch}. -@xref{Exception Handling}. -@end table diff --git a/gdb/doc/gdb.stop-m4 b/gdb/doc/gdb.stop-m4 deleted file mode 100755 index 934d7867edc..00000000000 --- a/gdb/doc/gdb.stop-m4 +++ /dev/null @@ -1,920 +0,0 @@ -_dnl__ -*- Texinfo -*- -_dnl__ Copyright (c) 1988 1989 1990 1991 Free Software Foundation, Inc. -_dnl__ This file is part of the source for the GDB manual. -@c M4 FRAGMENT: $Id$ -@node Stopping, Stack, Running, Top -@chapter Stopping and Continuing - -When you run a program normally, it runs until it terminates. The -principal purpose of using a debugger is so that you can stop your -program before it terminates; or so that, if the program runs into -trouble, you can investigate and find out why. - -Inside _GDBN__, your program may stop for any of several reasons, such -as a signal, a breakpoint, or reaching a new line after a _GDBN__ -command such as @code{step}. Usually, the messages shown by _GDBN__ -provide ample explanation of the status of your program---but you can -also explicitly request this information at any time. - -@table @code -@item info program -@kindex info program -Display information about the status of your program: whether it is -running or not, what process it is, and why it stopped. -@end table - -@menu -* Breakpoints:: Breakpoints, Watchpoints, and Exceptions -* Stepping:: Stepping -* Continuing:: Continuing -* Signals:: Signals -@end menu - -@node Breakpoints, Stepping, Stopping, Stopping -@section Breakpoints, Watchpoints, and Exceptions - -@cindex breakpoints -A @dfn{breakpoint} makes your program stop whenever a certain point in -the program is reached. For each breakpoint, you can add various -conditions to control in finer detail whether the program will stop. -You can set breakpoints with the @code{break} command and its variants -(@pxref{Set Breaks}), to specify the place where the program should stop -by line number, function name or exact address in the program. In -languages with exception handling (such as GNU C++), you can also set -breakpoints where an execption is raised (@pxref{Exception Handling}). - -@cindex watchpoints -A @dfn{watchpoint} is a special breakpoint that stops your program when -the value of an expression changes. You must use a different command to -set watchpoints (@pxref{Set Watchpoints}), but aside from that, you can -manage a watchpoint exactly like any other breakpoint: you enable, disable, and -delete both breakpoints and watchpoints using exactly the same commands. - -Each breakpoint or watchpoint is assigned a number when it is created; -these numbers are successive integers starting with one. In many of the -commands for controlling various features of breakpoints you use the -breakpoint number to say which breakpoint you want to change. Each -breakpoint may be @dfn{enabled} or @dfn{disabled}; if disabled, it has -no effect on the program until you enable it again. - -@menu -* Set Breaks:: Setting Breakpoints -* Set Watchpoints:: Setting Watchpoints -* Exception Handling:: Breakpoints and Exceptions -* Delete Breaks:: Deleting Breakpoints -* Disabling:: Disabling Breakpoints -* Conditions:: Break Conditions -* Break Commands:: Breakpoint Command Lists -* Breakpoint Menus:: Breakpoint Menus -* Error in Breakpoints:: -@end menu - -@node Set Breaks, Set Watchpoints, Breakpoints, Breakpoints -@subsection Setting Breakpoints - -@kindex break -@kindex b -Breakpoints are set with the @code{break} command (abbreviated @code{b}). - -You have several ways to say where the breakpoint should go. - -@table @code -@item break @var{function} -Set a breakpoint at entry to function @var{function}. When using source -languages that permit overloading of symbols, such as C++, -@var{function} may refer to more than one possible place to break. -@xref{Breakpoint Menus}, for a discussion of that situation. - -@item break +@var{offset} -@itemx break -@var{offset} -Set a breakpoint some number of lines forward or back from the position -at which execution stopped in the currently selected frame. - -@item break @var{linenum} -Set a breakpoint at line @var{linenum} in the current source file. -That file is the last file whose source text was printed. This -breakpoint will stop the program just before it executes any of the -code on that line. - -@item break @var{filename}:@var{linenum} -Set a breakpoint at line @var{linenum} in source file @var{filename}. - -@item break @var{filename}:@var{function} -Set a breakpoint at entry to function @var{function} found in file -@var{filename}. Specifying a file name as well as a function name is -superfluous except when multiple files contain similarly named -functions. - -@item break *@var{address} -Set a breakpoint at address @var{address}. You can use this to set -breakpoints in parts of the program which do not have debugging -information or source files. - -@item break -When called without any arguments, @code{break} sets a breakpoint at the -next instruction to be executed in the selected stack frame -(@pxref{Stack}). In any selected frame but the innermost, this will -cause the program to stop as soon as control returns to that frame. -This is similar to the effect of a @code{finish} command in the frame -inside the selected frame---except that @code{finish} doesn't leave an -active breakpoint. If you use @code{break} without an argument in the -innermost frame, _GDBN__ will stop the next time it reaches the current -location; this may be useful inside loops. - -_GDBN__ normally ignores breakpoints when it resumes execution, until at -least one instruction has been executed. If it did not do this, you -would be unable to proceed past a breakpoint without first disabling the -breakpoint. This rule applies whether or not the breakpoint already -existed when the program stopped. - -@item break @dots{} if @var{cond} -Set a breakpoint with condition @var{cond}; evaluate the expression -@var{cond} each time the breakpoint is reached, and stop only if the -value is nonzero. @samp{@dots{}} stands for one of the possible -arguments described above (or no argument) specifying where to break. -@xref{Conditions}, for more information on breakpoint conditions. - -@item tbreak @var{args} -@kindex tbreak -Set a breakpoint enabled only for one stop. @var{args} are the -same as in the @code{break} command, and the breakpoint is set in the same -way, but the breakpoint is automatically disabled the first time it -is hit. @xref{Disabling}. - -@item rbreak @var{regex} -@kindex rbreak -Set a breakpoint on all functions matching @var{regex}. This is -useful for setting breakpoints on overloaded functions that are not -members of any special classes. This command sets an unconditional -breakpoint on all matches, printing a list of all breakpoints it set. -Once these breakpoints are set, they are treated just like the -breakpoints set with the @code{break} command. They can be deleted, -disabled, made conditional, etc., in the standard ways. - -@kindex info breakpoints -@kindex $_ -@item info breakpoints -The command @code{info breakpoints} prints a list of all breakpoints -(but not watchpoints) set and not deleted, showing their numbers, where -in the program they are, and any special features in use for them. -Disabled breakpoints are included in the list, but marked as disabled. -@code{info break} with a breakpoint number as argument lists only that -breakpoint. The convenience variable @code{$_} and the default -examining-address for the @code{x} command are set to the address of the -last breakpoint listed (@pxref{Memory}). The equivalent command for -watchpoints is @code{info watch}. -@end table - -_GDBN__ allows you to set any number of breakpoints at the same place in the -program. There is nothing silly or meaningless about this. When the -breakpoints are conditional, this is even useful (@pxref{Conditions}). - -@node Set Watchpoints, Exception Handling, Set Breaks, Breakpoints -@subsection Setting Watchpoints -@cindex setting watchpoints -You can use a watchpoint to stop execution whenever the value of an -expression changes, without having to predict a particular place in the -inferior process where this may happen. - -Watchpoints currently execute two orders of magnitude more slowly than -other breakpoints, but this can well be worth it to catch errors where -you have no clue what part of your program is the culprit. Some -processors provide special hardware to implement this feature; future -releases of _GDBN__ will use such hardware if it is available. - -@table @code -@kindex watch -@item watch @var{expr} -Set a watchpoint for an expression. - -@kindex info watchpoints -@item info watchpoints -This command prints a list of watchpoints; it is otherwise similar to -@code{info break}. -@end table - -@node Exception Handling, Delete Breaks, Set Watchpoints, Breakpoints -@subsection Breakpoints and Exceptions -@cindex exception handlers - -Some languages, such as GNU C++, implement exception handling. _GDBN__ -can be used to examine what caused the program to raise an exception -and to list the exceptions the program is prepared to handle at a -given point in time. - -@table @code -@item catch @var{exceptions} -@kindex catch - -You can set breakpoints at active exception handlers by using the -@code{catch} command. @var{exceptions} is a list of names of exceptions -to catch. -@end table - -You can use @code{info catch} to list active exception handlers; -@pxref{Frame Info}. - -There are currently some limitations to exception handling in _GDBN__. -These will be corrected in a future release. - -@itemize @bullet -@item -If you call a function interactively, _GDBN__ normally returns -control to you when the function has finished executing. If the call -raises an exception, however, the call may bypass the mechanism that -returns control to the user and cause the program to simply continue -running until it hits a breakpoint, catches a signal that _GDBN__ is -listening for, or exits. -@item -You cannot raise an exception interactively. -@item -You cannot interactively install an exception handler. -@end itemize - -@cindex raise exceptions -Sometimes @code{catch} is not the best way to debug exception handling: -if you need to know exactly where an exception is raised, it's better to -stop @emph{before} the exception handler is called, since that way you -can see the stack before any unwinding takes place. If you set a -breakpoint in an exception handler instead, it may not be easy to find -out where the exception was raised. - -To stop just before an exception handler is called, you need some -knowledge of the implementation. In the case of GNU C++ exception are -raised by calling a library function named @code{__raise_exception} -which has the following ANSI C interface: - -@example - /* ADDR is where the exception identifier is stored. - ID is the exception identifier. */ - void __raise_exception (void **@var{addr}, void *@var{id}); -@end example - -@noindent -To make the debugger catch all exceptions before any stack -unwinding takes place, set a breakpoint on @code{__raise_exception} -(@pxref{Breakpoints}). - -With a conditional breakpoint (@xref{Conditions}) that depends on the -value of @var{id}, you can stop your program when a specific exception -is raised. You can use multiple conditional breakpoints to stop the -program when any of a number of exceptions are raised. - -@node Delete Breaks, Disabling, Exception Handling, Breakpoints -@subsection Deleting Breakpoints - -@cindex clearing breakpoints, watchpoints -@cindex deleting breakpoints, watchpoints -It is often necessary to eliminate a breakpoint or watchpoint once it -has done its job and you no longer want the program to stop there. This -is called @dfn{deleting} the breakpoint. A breakpoint that has been -deleted no longer exists in any sense; it is forgotten. - -With the @code{clear} command you can delete breakpoints according to -where they are in the program. With the @code{delete} command you can -delete individual breakpoints or watchpoints by specifying their -breakpoint numbers. - -It is not necessary to delete a breakpoint to proceed past it. _GDBN__ -automatically ignores breakpoints on the first instruction to be executed -when you continue execution without changing the execution address. - -@table @code -@item clear -@kindex clear -Delete any breakpoints at the next instruction to be executed in the -selected stack frame (@pxref{Selection}). When the innermost frame -is selected, this is a good way to delete a breakpoint that the program -just stopped at. - -@item clear @var{function} -@itemx clear @var{filename}:@var{function} -Delete any breakpoints set at entry to the function @var{function}. - -@item clear @var{linenum} -@itemx clear @var{filename}:@var{linenum} -Delete any breakpoints set at or within the code of the specified line. - -@item delete breakpoints @var{bnums}@dots{} -@itemx delete @var{bnums}@dots{} -@itemx delete -@cindex delete breakpoints -@kindex delete -@kindex d -Delete the breakpoints or watchpoints of the numbers specified as -arguments. If no argument is specified, delete all breakpoints. You -can abbreviate this command as @code{d}. -@end table - -@node Disabling, Conditions, Delete Breaks, Breakpoints -@subsection Disabling Breakpoints - -@cindex disabled breakpoints -@cindex enabled breakpoints -Rather than deleting a breakpoint or watchpoint, you might prefer to -@dfn{disable} it. This makes the breakpoint inoperative as if it had -been deleted, but remembers the information on the breakpoint so that -you can @dfn{enable} it again later. - -You disable and enable breakpoints and watchpoints with the -@code{enable} and @code{disable} commands, optionally specifying one or -more breakpoint numbers as arguments. Use @code{info break} or -@code{info watch} to print a list of breakpoints or watchpoints if you -don't know which numbers to use. - -A breakpoint or watchpoint can have any of four different states of -enablement: - -@itemize @bullet -@item -Enabled. The breakpoint will stop the program. A breakpoint made -with the @code{break} command starts out in this state. -@item -Disabled. The breakpoint has no effect on the program. -@item -Enabled once. The breakpoint will stop the program, but -when it does so it will become disabled. A breakpoint made -with the @code{tbreak} command starts out in this state. -@item -Enabled for deletion. The breakpoint will stop the program, but -immediately after it does so it will be deleted permanently. -@end itemize - -You can use the following commands to enable or disable breakpoints and -watchpoints: - -@table @code -@item disable breakpoints @var{bnums}@dots{} -@itemx disable @var{bnums}@dots{} -@itemx disable -@kindex disable breakpoints -@kindex disable -@kindex dis -Disable the specified breakpoints---or all breakpoints, if none are -listed. A disabled breakpoint has no effect but is not forgotten. All -options such as ignore-counts, conditions and commands are remembered in -case the breakpoint is enabled again later. You may abbreviate -@code{disable} as @code{dis}. - -@item enable breakpoints @var{bnums}@dots{} -@itemx enable @var{bnums}@dots{} -@itemx enable -@kindex enable breakpoints -@kindex enable -Enable the specified breakpoints (or all defined breakpoints). They -become effective once again in stopping the program, until you specify -otherwise. - -@item enable breakpoints once @var{bnums}@dots{} -@itemx enable once @var{bnums}@dots{} -Enable the specified breakpoints temporarily. Each will be disabled -again the next time it stops the program (unless you have used one of -these commands to specify a different state before that time comes). - -@item enable breakpoints delete @var{bnums}@dots{} -@itemx enable delete @var{bnums}@dots{} -Enable the specified breakpoints to work once and then die. Each of -the breakpoints will be deleted the next time it stops the program -(unless you have used one of these commands to specify a different -state before that time comes). -@end table - -Save for a breakpoint set with @code{tbreak} (@pxref{Set Breaks}), -breakpoints that you set initially enabled; subsequently, they become -disabled or enabled only when you use one of the commands above. (The -command @code{until} can set and delete a breakpoint of its own, but it -will not change the state of your other breakpoints; -@pxref{Stepping}.) - -@node Conditions, Break Commands, Disabling, Breakpoints -@subsection Break Conditions -@cindex conditional breakpoints -@cindex breakpoint conditions - -The simplest sort of breakpoint breaks every time the program reaches a -specified place. You can also specify a @dfn{condition} for a -breakpoint. A condition is just a Boolean expression in your -programming language. (@xref{Expressions}). A breakpoint with a -condition evaluates the expression each time the program reaches it, and -the program stops only if the condition is true. - -Conditions are also accepted for watchpoints; you may not need them, -since a watchpoint is inspecting the value of an expression anyhow---but -it might be simpler, say, to just set a watchpoint on a variable name, -then have a condition that tests whether the new value is an interesting -one. - -Break conditions may have side effects, and may even call functions in your -program. These may sound like strange things to do, but their effects are -completely predictable unless there is another enabled breakpoint at the -same address. (In that case, _GDBN__ might see the other breakpoint first and -stop the program without checking the condition of this one.) Note that -breakpoint commands are usually more convenient and flexible for the -purpose of performing side effects when a breakpoint is reached -(@pxref{Break Commands}). - -Break conditions can be specified when a breakpoint is set, by using -@samp{if} in the arguments to the @code{break} command. @xref{Set Breaks}. -They can also be changed at any time with the @code{condition} command. -The @code{watch} command doesn't recognize the @code{if} keyword; -@code{condition} is the only way to impose a further condition on a -watchpoint. - -@table @code -@item condition @var{bnum} @var{expression} -@kindex condition -Specify @var{expression} as the break condition for breakpoint or -watchpoint number @var{bnum}. From now on, this breakpoint will stop -the program only if the value of @var{expression} is true (nonzero, in -C). When you call @code{condition}, the expression you specify is -checked immediately for syntactic correctness, and to determine whether -symbols in it have referents in the context of your breakpoint. _GDBN__ -does not actually evaluate @var{expression} at the time the -@code{condition} command is given, however. @xref{Expressions}. - -@item condition @var{bnum} -Remove the condition from breakpoint number @var{bnum}. It becomes -an ordinary unconditional breakpoint. -@end table - -@cindex ignore count (of breakpoint) -A special case of a breakpoint condition is to stop only when the -breakpoint has been reached a certain number of times. This is so -useful that there is a special way to do it, using the @dfn{ignore -count} of the breakpoint. Every breakpoint has an ignore count, which -is an integer. Most of the time, the ignore count is zero, and -therefore has no effect. But if the program reaches a breakpoint whose -ignore count is positive, then instead of stopping, it just decrements -the ignore count by one and continues. As a result, if the ignore count -value is @var{n}, the breakpoint will not stop the next @var{n} times it -is reached. - -@table @code -@item ignore @var{bnum} @var{count} -@kindex ignore -Set the ignore count of breakpoint number @var{bnum} to @var{count}. -The next @var{count} times the breakpoint is reached, your program's -execution will not stop; other than to decrement the ignore count, _GDBN__ -takes no action. - -To make the breakpoint stop the next time it is reached, specify -a count of zero. - -@item continue @var{count} -@itemx c @var{count} -@itemx fg @var{count} -@kindex continue @var{count} -Continue execution of the program, setting the ignore count of the -breakpoint that the program stopped at to @var{count} minus one. -Thus, the program will not stop at this breakpoint until the -@var{count}'th time it is reached. - -An argument to this command is meaningful only when the program stopped -due to a breakpoint. At other times, the argument to @code{continue} is -ignored. - -The synonym @code{fg} is provided purely for convenience, and has -exactly the same behavior as other forms of the command. -@end table - -If a breakpoint has a positive ignore count and a condition, the condition -is not checked. Once the ignore count reaches zero, the condition will -be checked. - -You could achieve the effect of the ignore count with a -condition such as _0__@w{@samp{$foo-- <= 0}}_1__ using a debugger convenience -variable that is decremented each time. @xref{Convenience Vars}. - -@node Break Commands, Breakpoint Menus, Conditions, Breakpoints -@subsection Breakpoint Command Lists - -@cindex breakpoint commands -You can give any breakpoint (or watchpoint) a series of commands to -execute when the program stops due to that breakpoint. For example, you -might want to print the values of certain expressions, or enable other -breakpoints. - -@table @code -@item commands @var{bnum} -@itemx @dots{} @var{command-list} @dots{} -@itemx end -@kindex commands -@kindex end -Specify a list of commands for breakpoint number @var{bnum}. The commands -themselves appear on the following lines. Type a line containing just -@code{end} to terminate the commands. - -To remove all commands from a breakpoint, use the command -@code{commands} and follow it immediately by @code{end}; that is, give -no commands. - -With no @var{bnum} argument, @code{commands} refers to the last -breakpoint or watchpoint set (not to the breakpoint most recently -encountered). -@end table - -Pressing @key{RET} as a means of repeating the last _GDBN__ command is -disabled from the time you enter @code{commands} to just after the -corresponding @code{end}. - -You can use breakpoint commands to start the program up again. Simply -use the @code{continue} command, or @code{step}, or any other command to -resume execution. However, if you do this, any further commands in the -same breakpoint's command list are ignored. When the program stops -again, _GDBN__ will act according to the cause of that stop. - -@kindex silent -If the first command specified is @code{silent}, the usual message about -stopping at a breakpoint is not printed. This may be desirable for -breakpoints that are to print a specific message and then continue. -If the remaining commands too print nothing, you will see no sign that -the breakpoint was reached at all. @code{silent} is not really a command; -it is meaningful only at the beginning of the commands for a breakpoint. - -The commands @code{echo} and @code{output} that allow you to print precisely -controlled output are often useful in silent breakpoints. @xref{Output}. - -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. - -_0__@example -break foo if x>0 -commands -silent -echo x is\040 -output x -echo \n -cont -end -_1__@end example - -One application for breakpoint commands is to correct one bug so you can -test another. Put a breakpoint just after the erroneous line of code, give -it a condition to detect the case in which something erroneous has been -done, and give it commands to assign correct values to any variables that -need them. End with the @code{continue} command so that the program does not -stop, and start with the @code{silent} command so that no output is -produced. Here is an example: - -@example -break 403 -commands -silent -set x = y + 4 -cont -end -@end example - -@cindex lost output -One deficiency in the operation of automatically continuing breakpoints -under Unix appears when your program uses raw mode for the terminal. -_GDBN__ switches back to its own terminal modes (not raw) before executing -commands, and then must switch back to raw mode when your program is -continued. This causes any pending terminal input to be lost. -In the GNU system, this will be fixed by changing the behavior of -terminal modes. - -Under Unix, when you have this problem, you might be able to get around -it by putting your actions into the breakpoint condition instead of -commands. For example - -@example -condition 5 (x = y + 4), 0 -@end example - -@noindent -specifies a condition expression (@xref{Expressions}) that will change -@code{x} as needed, then always have the value zero so the program will not -stop. Loss of input is avoided here because break conditions are -evaluated without changing the terminal modes. When you want to have -nontrivial conditions for performing the side effects, the operators -@samp{&&}, @samp{||} and @samp{?@dots{}:} may be useful. - -@node Breakpoint Menus, Error in Breakpoints, Break Commands, Breakpoints -@subsection Breakpoint Menus -@cindex C++ overloading -@cindex symbol overloading - -Some programming languages (notably C++) permit a single function name -to be defined several times, for application in different contexts. -This is called @dfn{overloading}. When a function name is overloaded, -@samp{break @var{function}} is not enough to tell _GDBN__ where you want -a breakpoint. _GDBN__ responds to this situation by offering you a menu -of numbered choices for different possible breakpoints, and waiting for -your selection with the prompt @samp{>}. The first two -options are always @samp{[0] cancel} and @samp{[1] all}. Typing @kbd{1} -will set a breakpoint at all the definitions available for -@var{function}, and typing @kbd{0} will abort the @code{break} command -without setting any new breakpoints. - -For example, the following session excerpt shows an attempt to set a -breakpoint at the overloaded symbol @code{String::after}. In the -example, we choose three particular definitions of the function: - -@example -(_GDBP__) b String::after -[0] cancel -[1] all -[2] file:String.cc; line number:867 -[3] file:String.cc; line number:860 -[4] file:String.cc; line number:875 -[5] file:String.cc; line number:853 -[6] file:String.cc; line number:846 -[7] file:String.cc; line number:735 -> 2 4 6 -Breakpoint 1 at 0xb26c: file String.cc, line 867. -Breakpoint 2 at 0xb344: file String.cc, line 875. -Breakpoint 3 at 0xafcc: file String.cc, line 846. -Multiple breakpoints were set. -Use the "delete" command to delete unwanted breakpoints. -(_GDBP__) -@end example - - -@node Error in Breakpoints, , Breakpoint Menus, Breakpoints -@subsection ``Cannot Insert Breakpoints'' - -@c FIXME: "cannot insert breakpoints" error, v unclear. -@c Q in pending mail to Gilmore. ---pesch@cygnus.com, 26mar91 -Under some operating systems, breakpoints cannot be used in a program if -any other process is running that program. In this situation, -attempting to run or continue a program with a breakpoint will cause _GDBN__ -to stop the other process. - -When this happens, you have three ways to proceed: - -@enumerate -@item -Remove or disable the breakpoints, then continue. - -@item -Suspend _GDBN__, and copy the file containing the program to a new name. -Resume _GDBN__ and use the @code{exec-file} command to specify that _GDBN__ -should run the program under that name. Then start the program again. - -@c FIXME: RMS commented here "Show example". Maybe when someone -@c explains the first FIXME: in this section... - -@item -Relink the program so that the text segment is nonsharable, using the -linker option @samp{-N}. The operating system limitation may not apply -to nonsharable executables. -@end enumerate - -@node Stepping, Continuing, Breakpoints, Stopping -@section Stepping - -@cindex stepping -@dfn{Stepping} means setting your program in motion for a limited time, -so that control will return automatically to _GDBN__ after one line of -code or one machine instruction. @footnote{Your program might stop even -sooner, during stepping, since a signal may arrive before your program -reaches the next source line. Also, since breakpoints are active during -stepping, your program will stop for them even if it has not gone as far -as the stepping command specifies.} - -A typical technique for using stepping is to put a breakpoint -(@pxref{Breakpoints}) at the beginning of the function or the section of -the program in which a problem is believed to lie, run the program until -it stops at that breakpoint, and then step through the suspect area, -examining the variables that are interesting, until you see the problem -happen. - -@table @code -@item step -@kindex step -@kindex s -Continue running the program until control reaches a different source -line, then stop it and return control to the debugger. This command is -abbreviated @code{s}. - -You may use the @code{step} command when control is within a function -for which there is no debugging information. In that case, execution -will proceed until control reaches a different function, or is about to -return from this function. - -@item step @var{count} -Continue running as in @code{step}, but do so @var{count} times. If a -breakpoint is reached or a signal not related to stepping occurs before -@var{count} steps, stepping stops right away. - -@item next -@kindex next -@kindex n -Continue to the next source line in the current stack frame. Similar to -@code{step}, but any function calls appearing within the line of code -are executed without stopping. Execution stops when control reaches a -different line of code at the stack level which was executing when the -@code{next} command was given. This command is abbreviated @code{n}. - -An argument is a repeat count, as in @code{step}. - -@code{next} within a function that lacks debugging information acts like -@code{step}, but any function calls appearing within the code of the -function are executed without stopping. - -@item finish -@kindex finish -Continue running until just after the selected stack frame returns (or -until there is some other reason to stop, such as a fatal signal or a -breakpoint). Print the value returned by the selected stack frame (if -any). - -Contrast this with the @code{return} command (@pxref{Returning}). - -@item until -@kindex until -@item u -@kindex u -Continue running until a source line past the current line, in the -current stack frame, is reached. This command is used to avoid single -stepping through a loop more than once. It is like the @code{next} -command, except that when @code{until} encounters a jump, it -automatically continues execution until the program counter is greater -than the address of the jump. - -This means that when you reach the end of a loop after single stepping -though it, @code{until} will cause the program to continue execution -until the loop is exited. In contrast, a @code{next} command at the end -of a loop will simply step back to the beginning of the loop, which -would force you to step through the next iteration. - -@code{until} always stops the program if it attempts to exit the current -stack frame. - -@code{until} may produce somewhat counterintuitive results if the order -of the source lines does not match the actual order of execution. For -example, in the following excerpt from a debugging session, the @code{f} -(@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 -(_GDBP__) f -#0 main (argc=4, argv=0xf7fffae8) at m4.c:206 -206 expand_input(); -(_GDBP__) until -195 for ( ; argc > 0; NEXTARG) @{ -@end example - -In this case, (as for any C @code{for}-loop), the loop-step expression -(here, @samp{argc > 0}) is executed @emph{after} the statements in the -body of the loop, but is written before them. Therefore, the -@code{until} command appeared to step back to the beginning of the loop -when it advanced to this expression. However, it has not really gone to -an earlier statement---not in terms of the actual machine code. - -@code{until} with no argument works by means of single -instruction stepping, and hence is slower than @code{until} with an -argument. - -@item until @var{location} -@item u @var{location} -Continue running the program until either the specified location is -reached, or the current (innermost) stack frame returns. @var{location} -is any of the forms of argument acceptable to @code{break} (@pxref{Set -Breaks}). This form of the command uses breakpoints, and hence is -quicker than @code{until} without an argument. - -@item stepi -@itemx si -@kindex stepi -@kindex si -Execute one machine instruction, then stop and return to the debugger. - -It is often useful to do @samp{display/i $pc} when stepping by machine -instructions. This will cause the next instruction to be executed to -be displayed automatically at each stop. @xref{Auto Display}. - -An argument is a repeat count, as in @code{step}. - -@item nexti -@itemx ni -@kindex nexti -@kindex ni -Execute one machine instruction, but if it is a function call, -proceed until the function returns. - -An argument is a repeat count, as in @code{next}. -@end table - -The @code{continue} command can be used after stepping to resume execution -until the next breakpoint or signal. - -@node Continuing, Signals, Stepping, Stopping -@section Continuing - -After your program stops, most likely you will want it to run some more if -the bug you are looking for has not happened yet. - -@table @code -@item continue -@kindex continue -Continue running the program at the place where it stopped. -@end table - -If the program stopped at a breakpoint, the place to continue running -is the address of the breakpoint. You might expect that continuing would -just stop at the same breakpoint immediately. In fact, @code{continue} -takes special care to prevent that from happening. You do not need -to disable the breakpoint to proceed through it after stopping there. -You can, however, specify an ignore-count for the breakpoint that the -program stopped at, by means of an argument to the @code{continue} command. -@xref{Conditions}. - -If the program stopped because of a signal other than @code{SIGINT} or -@code{SIGTRAP}, continuing will cause the program to see that signal. -You may not want this to happen. For example, if the program stopped -due to some sort of memory reference error, you might store correct -values into the erroneous variables and continue, hoping to see more -execution; but the program would probably terminate immediately as -a result of the fatal signal once it sees the signal. To prevent this, -you can continue with @samp{signal 0}. @xref{Signaling}. You can -also act in advance to control what signals your program will see, using -the @code{handle} command (@pxref{Signals}). - -@node Signals, , Continuing, Stopping -@section Signals -@cindex signals - -A signal is an asynchronous event that can happen in a program. The -operating system defines the possible kinds of signals, and gives each -kind a name and a number. For example, in Unix @code{SIGINT} is the -signal a program gets when you type an interrupt (often @kbd{C-c}); -@code{SIGSEGV} is the signal a program gets from referencing a place in -memory far away from all the areas in use; @code{SIGALRM} occurs when -the alarm clock timer goes off (which happens only if the program has -requested an alarm). - -@cindex fatal signals -Some signals, including @code{SIGALRM}, are a normal part of the -functioning of the program. Others, such as @code{SIGSEGV}, indicate -errors; these signals are @dfn{fatal} (kill the program immediately) if the -program has not specified in advance some other way to handle the signal. -@code{SIGINT} does not indicate an error in the program, but it is normally -fatal so it can carry out the purpose of the interrupt: to kill the program. - -_GDBN__ has the ability to detect any occurrence of a signal in the program -running under _GDBN__'s control. You can tell _GDBN__ in advance what to do for -each kind of signal. - -@cindex handling signals -Normally, _GDBN__ is set up to ignore non-erroneous signals like @code{SIGALRM} -(so as not to interfere with their role in the functioning of the program) -but to stop the program immediately whenever an error signal happens. -You can change these settings with the @code{handle} command. - -@table @code -@item info signals -@kindex info signals -Print a table of all the kinds of signals and how _GDBN__ has been told to -handle each one. You can use this to see the signal numbers of all -the defined types of signals. - -@item handle @var{signal} @var{keywords}@dots{} -@kindex handle -Change the way _GDBN__ handles signal @var{signal}. @var{signal} can be the -number of a signal or its name (with or without the @samp{SIG} at the -beginning). The @var{keywords} say what change to make. -@end table - -@c @group -The keywords allowed by the @code{handle} command can be abbreviated. -Their full names are: - -@table @code -@item nostop -_GDBN__ should not stop the program when this signal happens. It may -still print a message telling you that the signal has come in. - -@item stop -_GDBN__ should stop the program when this signal happens. This implies -the @code{print} keyword as well. - -@item print -_GDBN__ should print a message when this signal happens. - -@item noprint -_GDBN__ should not mention the occurrence of the signal at all. This -implies the @code{nostop} keyword as well. - -@item pass -_GDBN__ should allow the program to see this signal; the program will be -able to handle the signal, or may be terminated if the signal is fatal -and not handled. - -@item nopass -_GDBN__ should not allow the program to see this signal. -@end table -@c @end group - -When a signal has been set to stop the program, the program cannot see the -signal until you continue. It will see the signal then, if @code{pass} is -in effect for the signal in question @i{at that time}. In other words, -after _GDBN__ reports a signal, you can use the @code{handle} command with -@code{pass} or @code{nopass} to control whether that signal will be seen by -the program when you later continue it. - -You can also use the @code{signal} command to prevent the program from -seeing a signal, or cause it to see a signal it normally would not see, -or to give it any signal at any time. @xref{Signaling}. - diff --git a/gdb/doc/gdb.symb-m4 b/gdb/doc/gdb.symb-m4 deleted file mode 100755 index e257d31c1b3..00000000000 --- a/gdb/doc/gdb.symb-m4 +++ /dev/null @@ -1,132 +0,0 @@ -_dnl__ -*- Texinfo -*- -_dnl__ Copyright (c) 1988 1989 1990 1991 Free Software Foundation, Inc. -_dnl__ This file is part of the source for the GDB manual. -@c M4 FRAGMENT: $Id$ -@node Symbols, Altering, Data, Top -@chapter Examining the Symbol Table - -The commands described in this section allow you to inquire about the -symbols (names of variables, functions and types) defined in your -program. This information is inherent in the text of your program and -does not change as the program executes. _GDBN__ finds it in your -program's symbol table, in the file indicated when you started _GDBN__ -(@pxref{File Options}), or by one of the file-management commands -(@pxref{Files}). - -@table @code -@item info address @var{symbol} -@kindex info address -Describe where the data for @var{symbol} is stored. For a register -variable, this says which register it is kept in. For a non-register -local variable, this prints the stack-frame offset at which the variable -is always stored. - -Note the contrast with @samp{print &@var{symbol}}, which does not work -at all for a register variables, and for a stack local variable prints -the exact address of the current instantiation of the variable. - -@item whatis @var{exp} -@kindex whatis -Print the data type of expression @var{exp}. @var{exp} is not -actually evaluated, and any side-effecting operations (such as -assignments or function calls) inside it do not take place. -@xref{Expressions}. - -@item whatis -Print the data type of @code{$}, the last value in the value history. - -@item ptype @var{typename} -@kindex ptype -Print a description of data type @var{typename}. @var{typename} may be -the name of a type, or for C code it may have the form -@samp{struct @var{struct-tag}}, @samp{union @var{union-tag}} or -@samp{enum @var{enum-tag}}.@refill - -@item ptype @var{exp} -Print a description of the type of expression @var{exp}. @code{ptype} -differs from @code{whatis} by printing a detailed description, instead of just -the name of the type. For example, if your program declares a variable -as -@example -struct complex @{double real; double imag;@} v; -@end example -@noindent -compare the output of the two commands: -@example -(_GDBP__) whatis v -type = struct complex -(_GDBP__) ptype v -type = struct complex @{ - double real; - double imag; -@} -@end example - -@item info types @var{regexp} -@itemx info types -@kindex info types -Print a brief description of all types whose name matches @var{regexp} -(or all types in your program, if you supply no argument). Each -complete typename is matched as though it were a complete line; thus, -@samp{i type value} gives information on all types in your program whose -name includes the string @code{value}, but @samp{i type ^value$} gives -information only on types whose complete name is @code{value}. - -This command differs from @code{ptype} in two ways: first, like -@code{whatis}, it does not print a detailed description; second, it -lists all source files where a type is defined. - -@item info source -@kindex info source -Show the name of the current source file---that is, the source file for -the function containing the current point of execution. - -@item info sources -@kindex info sources -Print the names of all source files in the program for which there is -debugging information, organized into two lists: those for which symbols -have been read in, and those for which symbols will be read in on -demand. -@c FIXME: above passive AND awkward! - -@item info functions -@kindex info functions -Print the names and data types of all defined functions. - -@item info functions @var{regexp} -Print the names and data types of all defined functions -whose names contain a match for regular expression @var{regexp}. -Thus, @samp{info fun step} finds all functions whose names -include @code{step}; @samp{info fun ^step} finds those whose names -start with @code{step}. - -@item info variables -@kindex info variables -Print the names and data types of all variables that are declared -outside of functions (i.e., excluding local variables). - -@item info variables @var{regexp} -Print the names and data types of all variables (except for local -variables) whose names contain a match for regular expression -@var{regexp}. - - -@ignore -This was never implemented. -@item info methods -@itemx info methods @var{regexp} -@kindex info methods -The @code{info methods} command permits the user to examine all defined -methods within C++ program, or (with the @var{regexp} argument) a -specific set of methods found in the various C++ classes. Many -C++ classes provide a large number of methods. Thus, the output -from the @code{ptype} command can be overwhelming and hard to use. The -@code{info-methods} command filters the methods, printing only those -which match the regular-expression @var{regexp}. -@end ignore - -@item printsyms @var{filename} -@kindex printsyms -Write a complete dump of the debugger's symbol data into the -file @var{filename}. -@end table diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo deleted file mode 100644 index 4c4dfd5c00b..00000000000 --- a/gdb/doc/gdb.texinfo +++ /dev/null @@ -1,7934 +0,0 @@ -_dnl__ -*-Texinfo-*- -_dnl__ Copyright (c) 1988 1989 1990 1991 Free Software Foundation, Inc. -\input texinfo -@setfilename _GDBP__.info -@c $Id$ -@c THIS MANUAL REQUIRES TEXINFO-2 macros and info-makers to format properly. -@c -@c NOTE: this manual is marked up for preprocessing with a collection -@c of m4 macros called "pretex.m4". If you see <_if__> and <_fi__> -@c scattered around the source, you have the full source before -@c preprocessing; if you don't, you have the source configured for -@c _HOST__ architectures (and you can of course get the full source, -@c with all configurations, from wherever you got this). - -@ifinfo -@format -START-INFO-DIR-ENTRY -* Gdb: (gdb). The GNU debugger. -END-INFO-DIR-ENTRY -@end format -@end ifinfo - -_if__(0) - -THIS IS THE SOURCE PRIOR TO PREPROCESSING. The full source needs to -be run through m4 before either tex- or info- formatting: for example, -_0__ - m4 pretex.m4 none.m4 all.m4 gdb.texinfo >gdb-all.texinfo -_1__ -will produce (assuming your path finds either GNU m4 >= 0.84, or SysV -m4; Berkeley won't do) a file suitable for formatting. See the text in -"pretex.m4" for a fuller explanation (and the macro definitions). - -_fi__(0) -_include__(gdbVN.m4) -@c @smallbook -@c @cropmarks -@tex -\def\$#1${{#1}} % Kluge: collect RCS revision info without $...$ -\xdef\manvers{\$Revision$} % For use in headers, footers too -@end tex -@c -@syncodeindex ky cp -@c FOR UPDATES LEADING TO THIS DRAFT, GDB CHANGELOG CONSULTED BETWEEN: -@c Fri Oct 11 23:27:06 1991 John Gilmore (gnu at cygnus.com) -@c Sat Dec 22 02:51:40 1990 John Gilmore (gnu at cygint) -@ifinfo -This file documents the GNU debugger _GDBN__. - -Copyright (C) 1988, 1989, 1990, 1991 Free Software Foundation, Inc. - -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. - -@ignore -Permission is granted to process this file through TeX and print the -results, provided the printed document carries copying permission -notice identical to this one except for the removal of this paragraph -(this paragraph not being relevant to the printed manual). - -@end ignore -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided also that the -section entitled ``GNU General Public License'' is included exactly as -in the original, and provided that the entire resulting derived work is -distributed under the terms of a permission notice identical to this -one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions, -except that the section entitled ``GNU General Public License'' may be -included in a translation approved by the Free Software Foundation -instead of in the original English. -@end ifinfo -@c @smallbook -@setchapternewpage odd -_if__(_GENERIC__) -@settitle Using _GDBN__ (_GDB_VN__) -_fi__(_GENERIC__) -_if__(!_GENERIC__) -@settitle Using _GDBN__ _GDB_VN__ (_HOST__) -_fi__(!_GENERIC__) -@iftex -@finalout -@end iftex -@titlepage -@title Using _GDBN__ -@subtitle A Guide to the GNU Source-Level Debugger -_if__(!_GENERIC__) -@subtitle On _HOST__ Systems -_fi__(!_GENERIC__) -@sp 1 -@subtitle _GDBN__ version _GDB_VN__ -@subtitle November 1991 -@c TEXI2ROFF-KILL -@c let's be nice to texi2roff, it can't be expected to know about hfill... -@author Richard M. Stallman@qquad @hfill Free Software Foundation -@author Roland H. Pesch@qquad @hfill Cygnus Support -@ignore -@c END TEXI2ROFF-KILL -@c sneaky, eh? -@author Richard M. Stallman, Free Software Foundation -@author Roland H. Pesch, Cygnus Support -@c TEXI2ROFF-KILL -@end ignore -@c END TEXI2ROFF-KILL -@page -@tex -{\parskip=0pt -\hfill rms\@ai.mit.edu, pesch\@cygnus.com\par -\hfill {\it Using _GDBN__}, \manvers\par -\hfill \TeX{}info \texinfoversion\par -} -@end tex - -@vskip 0pt plus 1filll -Copyright @copyright{} 1988, 1989, 1990, 1991 Free Software Foundation, Inc. - -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. - -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided also that the -section entitled ``GNU General Public License'' is included exactly as -in the original, and provided that the entire resulting derived work is -distributed under the terms of a permission notice identical to this -one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions, -except that the section entitled ``GNU General Public License'' may be -included in a translation approved by the Free Software Foundation -instead of in the original English. -@end titlepage -@page - -@node Top, Summary, (dir), (dir) -@ifinfo -This file describes version _GDB_VN__ of GDB, the GNU symbolic debugger. -@end ifinfo - -@menu -* Summary:: Summary of _GDBN__ -* New Features:: New Features in _GDBN__ version _GDB_VN__ -* Sample Session:: A Sample _GDBN__ Session -* Invocation:: Getting In and Out of _GDBN__ -* Commands:: _GDBN__ Commands -* Running:: Running Programs Under _GDBN__ -* Stopping:: Stopping and Continuing -* Stack:: Examining the Stack -* Source:: Examining Source Files -* Data:: Examining Data -* Languages:: Using _GDBN__ with Different Languages -* Symbols:: Examining the Symbol Table -* Altering:: Altering Execution -* _GDBN__ Files:: _GDBN__'s Files -* Targets:: Specifying a Debugging Target -* Controlling _GDBN__:: Controlling _GDBN__ -* Sequences:: Canned Sequences of Commands -* Emacs:: Using _GDBN__ under GNU Emacs -* _GDBN__ Bugs:: Reporting Bugs in _GDBN__ -* Renamed Commands:: -* Installing _GDBN__:: Installing _GDBN__ -* Copying:: GNU GENERAL PUBLIC LICENSE -* Index:: Index - - --- The Detailed Node Listing --- - -Summary of _GDBN__ - -* Free Software:: Free Software -* Contributors:: Contributors to _GDBN__ - -Getting In and Out of _GDBN__ - -* Starting _GDBN__:: Starting _GDBN__ -* Leaving _GDBN__:: Leaving _GDBN__ -* Shell Commands:: Shell Commands - -Starting _GDBN__ - -* File Options:: Choosing Files -* Mode Options:: Choosing Modes - -_GDBN__ Commands - -* Command Syntax:: Command Syntax -* Help:: Getting Help - -Running Programs Under _GDBN__ - -* Compilation:: Compiling for Debugging -* Starting:: Starting your Program -* Arguments:: Your Program's Arguments -* Environment:: Your Program's Environment -* Working Directory:: Your Program's Working Directory -* Input/Output:: Your Program's Input and Output -* Attach:: Debugging an Already-Running Process -* Kill Process:: Killing the Child Process - -Stopping and Continuing - -* Breakpoints:: Breakpoints, Watchpoints, and Exceptions -* Continuing and Stepping:: Resuming Execution -* Signals:: Signals - -Breakpoints, Watchpoints, and Exceptions - -* Set Breaks:: Setting Breakpoints -* Set Watchpoints:: Setting Watchpoints -* Exception Handling:: Breakpoints and Exceptions -* Delete Breaks:: Deleting Breakpoints -* Disabling:: Disabling Breakpoints -* Conditions:: Break Conditions -* Break Commands:: Breakpoint Command Lists -* Breakpoint Menus:: Breakpoint Menus -* Error in Breakpoints:: ``Cannot insert breakpoints'' - -Examining the Stack - -* Frames:: Stack Frames -* Backtrace:: Backtraces -* Selection:: Selecting a Frame -* Frame Info:: Information on a Frame - -Examining Source Files - -* List:: Printing Source Lines -* Search:: Searching Source Files -* Source Path:: Specifying Source Directories -* Machine Code:: Source and Machine Code - -Examining Data - -* Expressions:: Expressions -* Variables:: Program Variables -* Arrays:: Artificial Arrays -* Output formats:: Output formats -* Memory:: Examining Memory -* Auto Display:: Automatic Display -* Print Settings:: Print Settings -* Value History:: Value History -* Convenience Vars:: Convenience Variables -* Registers:: Registers -* Floating Point Hardware:: Floating Point Hardware - -Using GDB with Different Languages - -* Setting:: Switching between source languages -* Show:: Displaying the language -* Checks:: Type and Range checks -* Support:: Supported languages - -Switching between source languages - -* Manually:: Setting the working language manually -* Automatically:: Having GDB infer the source language - -Type and range Checking - -* Type Checking:: An overview of type checking -* Range Checking:: An overview of range checking - -Supported Languages - -* C:: C and C++ -* Modula-2:: Modula-2 - -C and C++ - -* C Operators:: C and C++ Operators -* C Constants:: C and C++ Constants -* Cplusplus expressions:: C++ Expressions -* C Defaults:: Default settings for C and C++ -* C Checks:: C and C++ Type and Range Checks -* Debugging C:: _GDBN__ and C -* Debugging C plus plus:: Special features for C++ - -Modula-2 - -* M2 Operators:: Built-in operators -* Builtin Func/Proc:: Built-in Functions and Procedures -* M2 Constants:: Modula-2 Constants -* M2 Defaults:: Default settings for Modula-2 -* Deviations:: Deviations from standard Modula-2 -* M2 Checks:: Modula-2 Type and Range Checks -* M2 Scope:: The scope operators @code{::} and @code{.} -* GDB/M2:: GDB and Modula-2 - -Altering Execution - -* Assignment:: Assignment to Variables -* Jumping:: Continuing at a Different Address -* Signaling:: Giving the Program a Signal -* Returning:: Returning from a Function -* Calling:: Calling your Program's Functions -* Patching:: Patching your Program - -_GDBN__'s Files - -* Files:: Commands to Specify Files -* Symbol Errors:: Errors Reading Symbol Files - -Specifying a Debugging Target - -* Active Targets:: Active Targets -* Target Commands:: Commands for Managing Targets -* Remote:: Remote Debugging - -Remote Debugging - -* i960-Nindy Remote:: _GDBN__ with a Remote i960 (Nindy) -* EB29K Remote:: _GDBN__ with a Remote EB29K -* VxWorks Remote:: _GDBN__ and VxWorks - -_GDBN__ with a Remote i960 (Nindy) - -* Nindy Startup:: Startup with Nindy -* Nindy Options:: Options for Nindy -* Nindy reset:: Nindy Reset Command - -_GDBN__ with a Remote EB29K - -* Comms (EB29K):: Communications Setup -* gdb-EB29K:: EB29K cross-debugging -* Remote Log:: Remote Log - -_GDBN__ and VxWorks - -* VxWorks connection:: Connecting to VxWorks -* VxWorks download:: VxWorks Download -* VxWorks attach:: Running Tasks - -Controlling _GDBN__ - -* Prompt:: Prompt -* Editing:: Command Editing -* History:: Command History -* Screen Size:: Screen Size -* Numbers:: Numbers -* Messages/Warnings:: Optional Warnings and Messages - -Canned Sequences of Commands - -* Define:: User-Defined Commands -* Command Files:: Command Files -* Output:: Commands for Controlled Output - -Reporting Bugs in _GDBN__ - -* Bug Criteria:: Have You Found a Bug? -* Bug Reporting:: How to Report Bugs - -Installing GDB - -* Subdirectories:: Configuration subdirectories -* Config Names:: Specifying names for hosts and targets -* configure Options:: Summary of options for configure -* Formatting Documentation:: How to format and print GDB documentation -@end menu - -@node Summary, New Features, Top, Top -@unnumbered Summary of _GDBN__ - -The purpose of a debugger such as _GDBN__ is to allow you to see what is -going on ``inside'' another program while it executes---or what another -program was doing at the moment it crashed. - -_GDBN__ can do four main kinds of things (plus other things in support of -these) to help you catch bugs in the act: - -@itemize @bullet -@item -Start your program, specifying anything that might affect its behavior. - -@item -Make your program stop on specified conditions. - -@item -Examine what has happened, when your program has stopped. - -@item -Change things in your program, so you can experiment with correcting the -effects of one bug and go on to learn about another. -@end itemize - -You can use _GDBN__ to debug programs written in C, C++, and Modula-2. -Fortran support will be added when a GNU Fortran compiler is ready. - -@menu -* Free Software:: Free Software -* Contributors:: Contributors to GDB -@end menu - -@node Free Software, Contributors, Summary, Summary -@unnumberedsec Free Software -_GDBN__ is @dfn{free software}, protected by the GNU General Public License (GPL). -The GPL gives you the freedom to copy or adapt a licensed -program---but every person getting a copy also gets with it the -freedom to modify that copy (which means that they must get access to -the source code), and the freedom to distribute further copies. -Typical software companies use copyrights to limit your freedoms; the -Free Software Foundation uses the GPL to preserve these freedoms. - -Fundamentally, the General Public License is a license which says that -you have these freedoms and that you can't take these freedoms away -from anyone else. - -@c FIXME: (passim) go through all xrefs, expanding to use text headings -For full details, @pxref{Copying}. -@node Contributors, , Free Software, Summary -@unnumberedsec Contributors to GDB - -Richard Stallman was the original author of GDB, and of many other GNU -programs. Many others have contributed to its development. This -section attempts to credit major contributors. One of the virtues of -free software is that everyone is free to contribute to it; with -regret, we cannot actually acknowledge everyone here. The file -@file{ChangeLog} in the GDB distribution approximates a blow-by-blow -account. - -Changes much prior to version 2.0 are lost in the mists of time. - -@quotation -@emph{Plea:} Additions to this section are particularly welcome. If you -or your friends (or enemies; let's be evenhanded) have been unfairly -omitted from this list, we would like to add your names! -@end quotation - -So that they may not regard their long labor as thankless, we -particularly thank those who shepherded GDB through major releases: John -Gilmore (releases _GDB_VN__, 4.1, 4.0); Jim Kingdon (releases 3.9, 3.5, -3.4, 3.3); and Randy Smith (releases 3.2, 3.1, 3.0). As major -maintainer of GDB for some period, each contributed significantly to the -structure, stability, and capabilities of the entire debugger. - -Richard Stallman, assisted at various times by Pete TerMaat, Chris -Hanson, and Richard Mlynarik, handled releases through 2.8. - -Michael Tiemann is the author of most of the GNU C++ support in GDB, -with significant additional contributions from Per Bothner. James -Clark wrote the GNU C++ demangler. Early work on C++ was by Peter -TerMaat (who also did much general update work leading to release 3.0). - -GDB _GDB_VN__ uses the BFD subroutine library to examine multiple -object-file formats; BFD was a joint project of V. Gumby -Henkel-Wallace, Rich Pixley, Steve Chamberlain, and John Gilmore. - -David Johnson wrote the original COFF support; Pace Willison did -the original support for encapsulated COFF. - -Adam de Boor and Bradley Davis contributed the ISI Optimum V support. -Per Bothner, Noboyuki Hikichi, and Alessandro Forin contributed MIPS -support. Jean-Daniel Fekete contributed Sun 386i support. Chris -Hanson improved the HP9000 support. Noboyuki Hikichi and Tomoyuki -Hasei contributed Sony/News OS 3 support. David Johnson contributed -Encore Umax support. Jyrki Kuoppala contributed Altos 3068 support. -Keith Packard contributed NS32K support. Doug Rabson contributed -Acorn Risc Machine support. Chris Smith contributed Convex support -(and Fortran debugging). Jonathan Stone contributed Pyramid support. -Michael Tiemann contributed SPARC support. Tim Tucker contributed -support for the Gould NP1 and Gould Powernode. Pace Willison -contributed Intel 386 support. Jay Vosburgh contributed Symmetry -support. - -Rich Schaefer and Peter Schauer helped with support of SunOS shared -libraries. - -Jay Fenlason and Roland McGrath ensured that GDB and GAS agree about -several machine instruction sets. - -Patrick Duval, Ted Goldstein, Vikram Koka and Glenn Engel helped -develop remote debugging. Intel Corporation and Wind River Systems -contributed remote debugging modules for their products. - -Brian Fox is the author of the readline libraries providing -command-line editing and command history. - -Andrew Beers of SUNY Buffalo wrote the language-switching code and -the Modula-2 support, and contributed the Languages chapter of this -manual. - -@node New Features, Sample Session, Summary, Top -@unnumbered New Features since _GDBN__ version 3.5 - -@table @emph -@item Targets -Using the new command @code{target}, you can select at runtime whether -you are debugging local files, local processes, standalone systems over -a serial port, realtime systems over a TCP/IP connection, etc. The -command @code{load} can download programs into a remote system. Serial -stubs are available for Motorola 680x0 and Intel 80386 remote systems; -_GDBN__ also supports debugging realtime processes running under -VxWorks, using SunRPC Remote Procedure Calls over TCP/IP to talk to a -debugger stub on the target system. Internally, _GDBN__ now uses a -function vector to mediate access to different targets; if you need to -add your own support for a remote protocol, this makes it much easier. - -@item Watchpoints -_GDBN__ now sports watchpoints as well as breakpoints. You can use a -watchpoint to stop execution whenever the value of an expression -changes, without having to predict a particular place in your program -where this may happen. - -@item Wide Output -Commands that issue wide output now insert newlines at places designed -to make the output more readable. - -@item Object Code Formats -_GDBN__ uses a new library called the Binary File Descriptor (BFD) -Library to permit it to switch dynamically, without reconfiguration or -recompilation, between different object-file formats. Formats currently -supported are COFF, a.out, and the Intel 960 b.out; files may be read as -.o's, archive libraries, or core dumps. BFD is available as a -subroutine library so that other programs may take advantage of it, and -the other GNU binary utilities are being converted to use it. - -@item Configuration and Ports -Compile-time configuration (to select a particular architecture and -operating system) is much easier. The script @code{configure} now -allows you to configure _GDBN__ as either a native debugger or a -cross-debugger. @xref{Installing _GDBN__} for details on how to -configure and on what architectures are now available. - -@item Interaction -The user interface to _GDBN__'s control variables has been simplified -and consolidated in two commands, @code{set} and @code{show}. Output -lines are now broken at readable places, rather than overflowing onto -the next line. You can suppress output of machine-level addresses, -displaying only source language information. - - -@item C++ -_GDBN__ now supports C++ multiple inheritance (if used with a GCC -version 2 compiler), and also has limited support for C++ exception -handling, with the commands @code{catch} and @code{info catch}: _GDBN__ -can break when an exception is raised, before the stack is peeled back -to the exception handler's context. - -@item Modula-2 -_GDBN__ now has preliminary support for the GNU Modula-2 compiler, -currently under development at the State University of New York at -Buffalo. Coordinated development of both _GDBN__ and the GNU Modula-2 -compiler will continue through the fall of 1991 and into 1992. Other -Modula-2 compilers are currently not supported, and attempting to debug -programs compiled with them will likely result in an error as the symbol -table of the executable is read in. - -@item Command Rationalization -Many _GDBN__ commands have been renamed to make them easier to remember -and use. In particular, the subcommands of @code{info} and -@code{show}/@code{set} are grouped to make the former refer to the state -of your program, and the latter refer to the state of _GDBN__ itself. -@xref{Renamed Commands}, for details on what commands were renamed. - -@item Shared Libraries -_GDBN__ _GDB_VN__ can debug programs and core files that use SunOS shared -libraries. - -@item Reference Card -_GDBN__ _GDB_VN__ has a reference card; @xref{Formatting Documentation} for -instructions on printing it. - -@item Work in Progress -Kernel debugging for BSD and Mach systems; Tahoe and HPPA architecture -support. - -@end table - -@node Sample Session, Invocation, New Features, Top -@chapter A Sample _GDBN__ Session - -You can use this manual at your leisure to read all about _GDBN__. -However, a handful of commands are enough to get started using the -debugger. This chapter illustrates these commands. - -@iftex -In this sample session, we emphasize user input like this: @i{input}, -to make it easier to pick out from the surrounding output. -@end iftex - -@c FIXME: this example may not be appropriate for some configs, where -@c FIXME...primary interest is in remote use. -_0__ -One of the preliminary versions of GNU @code{m4} (a generic macro -processor) exhibits the following bug: sometimes, when we change its -quote strings from the default, the commands used to capture one macro's -definition in another stop working. In the following short @code{m4} -session, we define a macro @code{foo} which expands to @code{0000}; we -then use the @code{m4} builtin @code{defn} to define @code{bar} as the -same thing. However, when we change the open quote string to -@code{} and the close quote string to @code{}, the same -procedure fails to define a new synonym @code{baz}: - -@smallexample -$ @i{cd gnu/m4} -$ @i{./m4} -@i{define(foo,0000)} - -@i{foo} -0000 -@i{define(bar,defn(`foo'))} - -@i{bar} -0000 -@i{changequote(,)} - -@i{define(baz,defn(foo))} -@i{baz} -@i{C-d} -m4: End of input: 0: fatal error: EOF in string -@end smallexample - -@noindent -Let's use _GDBN__ to try to see what's going on. - -@smallexample -$ @i{_GDBP__ m4} -@c FIXME: this falsifies the exact text played out, to permit smallbook -@c FIXME... format to come out better. -GDB is free software and you are welcome to distribute copies - of it under certain conditions; type "show copying" to see - the conditions. -There is absolutely no warranty for GDB; type "show warranty" -for details. -GDB _GDB_VN__, Copyright 1991 Free Software Foundation, Inc... -(_GDBP__) -@end smallexample - -@noindent -_GDBN__ reads only enough symbol data to know where to find the rest -when needed; as a result, the first prompt comes up very quickly. We -then tell _GDBN__ to use a narrower display width than usual, so -that examples will fit in this manual. - -@smallexample -(_GDBP__) @i{set width 70} -@end smallexample - -@noindent -Let's see how the @code{m4} builtin @code{changequote} works. -Having looked at the source, we know the relevant subroutine is -@code{m4_changequote}, so we set a breakpoint there with _GDBN__'s -@code{break} command. - -@smallexample -(_GDBP__) @i{break m4_changequote} -Breakpoint 1 at 0x62f4: file builtin.c, line 879. -@end smallexample - -@noindent -Using the @code{run} command, we start @code{m4} running under _GDBN__ -control; as long as control does not reach the @code{m4_changequote} -subroutine, the program runs as usual: - -@smallexample -(_GDBP__) @i{run} -Starting program: /work/Editorial/gdb/gnu/m4/m4 -@i{define(foo,0000)} - -@i{foo} -0000 -@end smallexample - -@noindent -To trigger the breakpoint, we call @code{changequote}. _GDBN__ -suspends execution of @code{m4}, displaying information about the -context where it stops. - -@smallexample -@i{changequote(,)} - -Breakpoint 1, m4_changequote (argc=3, argv=0x33c70) - at builtin.c:879 -879 if (bad_argc(TOKEN_DATA_TEXT(argv[0]), argc, 1, 3)) -@end smallexample - -@noindent -Now we use the command @code{n} (@code{next}) to advance execution to -the next line of the current function. - -@smallexample -(_GDBP__) @i{n} -882 set_quotes((argc >= 2) ? TOKEN_DATA_TEXT(argv[1])\ - : nil, -@end smallexample - -@noindent -@code{set_quotes} looks like a promising subroutine. We can go into it -by using the command @code{s} (@code{step}) instead of @code{next}. -@code{step} goes to the next line to be executed in @emph{any} -subroutine, so it steps into @code{set_quotes}. - -@smallexample -(_GDBP__) @i{s} -set_quotes (lq=0x34c78 "", rq=0x34c88 "") - at input.c:530 -530 if (lquote != def_lquote) -@end smallexample - -@noindent -The summary display showing the subroutine where @code{m4} is now -suspended (and its arguments) is called a stack frame display. We can -use the @code{backtrace} command (which can also be spelled @code{bt}), -to see where we are in the stack: it displays a stack frame for each -active subroutine. - -@smallexample -(_GDBP__) @i{bt} -#0 set_quotes (lq=0x34c78 "", rq=0x34c88 "") - at input.c:530 -#1 0x6344 in m4_changequote (argc=3, argv=0x33c70) - at builtin.c:882 -#2 0x8174 in expand_macro (sym=0x33320) at macro.c:242 -#3 0x7a88 in expand_token (obs=0x0, t=209696, td=0xf7fffa30) - at macro.c:71 -#4 0x79dc in expand_input () at macro.c:40 -#5 0x2930 in main (argc=0, argv=0xf7fffb20) at m4.c:195 -@end smallexample - -@noindent -Let's step through a few more lines to see what happens. The first two -times, we can use @samp{s}; the next two times we use @code{n} to avoid -falling into the @code{xstrdup} subroutine. -@smallexample -(_GDBP__) @i{s} -0x3b5c 532 if (rquote != def_rquote) -(_GDBP__) @i{s} -0x3b80 535 lquote = (lq == nil || *lq == '\0') ? \ -def_lquote : xstrdup(lq); -(_GDBP__) @i{n} -536 rquote = (rq == nil || *rq == '\0') ? def_rquote\ - : xstrdup(rq); -(_GDBP__) @i{n} -538 len_lquote = strlen(rquote); -@end smallexample - -@noindent -The last line displayed looks a little odd; let's examine the variables -@code{lquote} and @code{rquote} to see if they are in fact the new left -and right quotes we specified. We can use the command @code{p} -(@code{print}) to see their values. - -@smallexample -(_GDBP__) @i{p lquote} -$1 = 0x35d40 "" -(_GDBP__) @i{p rquote} -$2 = 0x35d50 "" -@end smallexample - -@noindent -@code{lquote} and @code{rquote} are indeed the new left and right quotes. -Let's look at some context; we can display ten lines of source -surrounding the current line, with the @code{l} (@code{list}) command. - -@smallexample -(_GDBP__) @i{l} -533 xfree(rquote); -534 -535 lquote = (lq == nil || *lq == '\0') ? def_lquote\ - : xstrdup (lq); -536 rquote = (rq == nil || *rq == '\0') ? def_rquote\ - : xstrdup (rq); -537 -538 len_lquote = strlen(rquote); -539 len_rquote = strlen(lquote); -540 @} -541 -542 void -@end smallexample - -@noindent -Let's step past the two lines that set @code{len_lquote} and -@code{len_rquote}, and then examine the values of those variables. - -@smallexample -(_GDBP__) @i{n} -539 len_rquote = strlen(lquote); -(_GDBP__) @i{n} -540 @} -(_GDBP__) @i{p len_lquote} -$3 = 9 -(_GDBP__) @i{p len_rquote} -$4 = 7 -@end smallexample - -@noindent -That certainly looks wrong, assuming @code{len_lquote} and -@code{len_rquote} are meant to be the lengths of @code{lquote} and -@code{rquote} respectively. Let's try setting them to better values. -We can use the @code{p} command for this, since it'll print the value of -any expression---and that expression can include subroutine calls and -assignments. - -@smallexample -(_GDBP__) p len_lquote=strlen(lquote) -$5 = 7 -(_GDBP__) p len_rquote=strlen(rquote) -$6 = 9 -@end smallexample - -@noindent -Let's see if that fixes the problem of using the new quotes with the -@code{m4} built-in @code{defn}. We can allow @code{m4} to continue -executing with the @code{c} (@code{continue}) command, and then try the -example that caused trouble initially: - -@smallexample -(_GDBP__) @i{c} -Continuing. - -@i{define(baz,defn(foo))} - -baz -0000 -@end smallexample - -@noindent -Success! The new quotes now work just as well as the default ones. The -problem seems to have been just the two typos defining the wrong -lengths. We'll let @code{m4} exit by giving it an EOF as input. - -@smallexample -@i{C-d} -Program exited normally. -@end smallexample - -@noindent -The message @samp{Program exited normally.} is from _GDBN__; it -indicates @code{m4} has finished executing. We can end our _GDBN__ -session with the _GDBN__ @code{quit} command. - -@smallexample -(_GDBP__) @i{quit} -_1__@end smallexample - -@node Invocation, Commands, Sample Session, Top -@chapter Getting In and Out of _GDBN__ - -@menu -* Starting _GDBN__:: Starting _GDBN__ -* Leaving _GDBN__:: Leaving _GDBN__ -* Shell Commands:: Shell Commands -@end menu - -@node Starting _GDBN__, Leaving _GDBN__, Invocation, Invocation -@section Starting _GDBN__ - -_GDBN__ is invoked with the shell command @code{_GDBP__}. Once started, -it reads commands from the terminal until you tell it to exit. - -You can run @code{_GDBP__} with no arguments or options; but the most -usual way to start _GDBN__ is with one argument or two, specifying an -executable program as the argument: -@example -_GDBP__ program -@end example -@noindent -You can also start with both an executable program and a core file specified: -@example -_GDBP__ program core -@end example - -You can, instead, specify a process ID as a second argument, if you want -to debug a running process: -@example -_GDBP__ program 1234 -@end example -@noindent -would attach _GDBN__ to process @code{1234} (unless you also have a file -named @file{1234}; _GDBN__ does check for a core file first). - -@noindent -You can further control how _GDBN__ starts up by using command-line -options. _GDBN__ itself can remind you of the options available: -@example -_GDBP__ -help -@end example -@noindent -will display all available options and briefly describe their use -(@samp{_GDBP__ -h} is a shorter equivalent). - -All options and command line arguments you give are processed -in sequential order. The order makes a difference when the -@samp{-x} option is used. - -@menu -* File Options:: Choosing Files -* Mode Options:: Choosing Modes -_if__(!_GENERIC__) -_include__(gdbinv-m.m4)_dnl__ -_fi__(!_GENERIC__) -@end menu - -@node File Options, Mode Options, Starting _GDBN__, Starting _GDBN__ -@subsection Choosing Files - -As shown above, any arguments other than options specify an executable -file and core file (or process ID); that is, the first argument -encountered with no associated option flag is equivalent to a @samp{-se} -option, and the second, if any, is equivalent to a @samp{-c} option if -it's the name of a file. -Many options have both long and short forms; both are shown here. The -long forms are also recognized if you truncate them, so long as enough -of the option is present to be unambiguous. (If you prefer, you can -flag option arguments with @samp{+} rather than @samp{-}, though we -illustrate the more usual convention.) - -@table @code -@item -symbols=@var{file} -@itemx -s @var{file} -Read symbol table from file @var{file}. - -@item -exec=@var{file} -@itemx -e @var{file} -Use file @var{file} as the executable file to execute when -appropriate, and for examining pure data in conjunction with a core -dump. - -@item -se=@var{file} -Read symbol table from file @var{file} and use it as the executable -file. - -@item -core=@var{file} -@itemx -c @var{file} -Use file @var{file} as a core dump to examine. - -@item -command=@var{file} -@itemx -x @var{file} -Execute _GDBN__ commands from file @var{file}. @xref{Command Files}. - -@item -directory=@var{directory} -@itemx -d @var{directory} -Add @var{directory} to the path to search for source files. -@end table - -_if__(!_GENERIC__) -@node Mode Options, Mode Options, File Options, Starting _GDBN__ -_fi__(!_GENERIC__) -_if__(_GENERIC__) -@node Mode Options, , File Options, Starting _GDBN__ -_fi__(_GENERIC__) -@subsection Choosing Modes - -@table @code -@item -nx -@itemx -n -Do not execute commands from any @file{_GDBINIT__} initialization files. -Normally, the commands in these files are executed after all the -command options and arguments have been processed. -@xref{Command Files}. - -@item -quiet -@itemx -q -``Quiet''. Do not print the introductory and copyright messages. These -messages are also suppressed in batch mode. - -@item -batch -Run in batch mode. Exit with status @code{0} after processing all the command -files specified with @samp{-x} (and @file{_GDBINIT__}, if not inhibited). -Exit with nonzero status if an error occurs in executing the _GDBN__ -commands in the command files. - -Batch mode may be useful for running _GDBN__ as a filter, for example to -download and run a program on another computer; in order to make this -more useful, the message -@example -Program exited normally. -@end example -@noindent -(which is ordinarily issued whenever a program running under _GDBN__ control -terminates) is not issued when running in batch mode. - -@item -cd=@var{directory} -Run _GDBN__ using @var{directory} as its working directory, -instead of the current directory. - -@item -fullname -@itemx -f -Emacs sets this option when it runs _GDBN__ as a subprocess. It tells _GDBN__ -to output the full file name and line number in a standard, -recognizable fashion each time a stack frame is displayed (which -includes each time the program stops). This recognizable format looks -like two @samp{\032} characters, followed by the file name, line number -and character position separated by colons, and a newline. The -Emacs-to-_GDBN__ interface program uses the two @samp{\032} characters as -a signal to display the source code for the frame. - -@item -b @var{bps} -Set the line speed (baud rate or bits per second) of any serial -interface used by _GDBN__ for remote debugging. - -@item -tty=@var{device} -Run using @var{device} for your program's standard input and output. -@c FIXME: kingdon thinks there's more to -tty. Investigate. -@end table - -_if__(!_GENERIC__) -_include__(gdbinv-s.m4) -_fi__(!_GENERIC__) - -@node Leaving _GDBN__, Shell Commands, Starting _GDBN__, Invocation -@section Leaving _GDBN__ -@cindex exiting _GDBN__ -@table @code -@item quit -@kindex quit -@kindex q -To exit _GDBN__, use the @code{quit} command (abbreviated @code{q}), or type -an end-of-file character (usually @kbd{C-d}). -@end table - -@cindex interrupt -An interrupt (often @kbd{C-c}) will not exit from _GDBN__, but rather -will terminate the action of any _GDBN__ command that is in progress and -return to _GDBN__ command level. It is safe to type the interrupt -character at any time because _GDBN__ does not allow it to take effect -until a time when it is safe. - -If you've been using _GDBN__ to control an attached process or device, -you can release it with the @code{detach} command; @pxref{Attach}. - -@node Shell Commands, , Leaving _GDBN__, Invocation -@section Shell Commands -If you need to execute occasional shell commands during your -debugging session, there's no need to leave or suspend _GDBN__; you can -just use the @code{shell} command. - -@table @code -@item shell @var{command string} -@kindex shell -@cindex shell escape -Directs _GDBN__ to invoke an inferior shell to execute @var{command -string}. If it exists, the environment variable @code{SHELL} is used -for the name of the shell to run. Otherwise _GDBN__ uses -@code{/bin/sh}. -@end table - -The utility @code{make} is often needed in development environments. -You don't have to use the @code{shell} command for this purpose in _GDBN__: - -@table @code -@item make @var{make-args} -@kindex make -@cindex calling make -Causes _GDBN__ to execute an inferior @code{make} program with the specified -arguments. This is equivalent to @samp{shell make @var{make-args}}. -@end table - -@node Commands, Running, Invocation, Top -@chapter _GDBN__ Commands - -@menu -* Command Syntax:: Command Syntax -* Help:: Getting Help -@end menu - -@node Command Syntax, Help, Commands, Commands -@section Command Syntax -A _GDBN__ command is a single line of input. There is no limit on how long -it can be. It starts with a command name, which is followed by arguments -whose meaning depends on the command name. For example, the command -@code{step} accepts an argument which is the number of times to step, -as in @samp{step 5}. You can also use the @code{step} command with -no arguments. Some command names do not allow any arguments. - -@cindex abbreviation -_GDBN__ command names may always be truncated if that abbreviation is -unambiguous. Other possible command abbreviations are listed in the -documentation for individual commands. In some cases, even ambiguous -abbreviations are allowed; for example, @code{s} is specially defined as -equivalent to @code{step} even though there are other commands whose -names start with @code{s}. You can test abbreviations by using them as -arguments to the @code{help} command. - -@cindex repeating commands -@kindex RET -A blank line as input to _GDBN__ (typing just @key{RET}) means to -repeat the previous command. Certain commands (for example, @code{run}) -will not repeat this way; these are commands for which unintentional -repetition might cause trouble and which you are unlikely to want to -repeat. - -The @code{list} and @code{x} commands, when you repeat them with -@key{RET}, construct new arguments rather than repeating -exactly as typed. This permits easy scanning of source or memory. - -_GDBN__ can also use @key{RET} in another way: to partition lengthy -output, in a way similar to the common utility @code{more} -(@pxref{Screen Size}). Since it's easy to press one @key{RET} too many -in this situation, _GDBN__ disables command repetition after any command -that generates this sort of display. - -@kindex # -@cindex comment -A line of input starting with @kbd{#} is a comment; it does nothing. -This is useful mainly in command files (@xref{Command Files}). - -@node Help, , Command Syntax, Commands -@section Getting Help -@cindex online documentation -@kindex help -You can always ask _GDBN__ itself for information on its commands, using the -command @code{help}. - -@table @code -@item help -@itemx h -@kindex h -You can use @code{help} (abbreviated @code{h}) with no arguments to -display a short list of named classes of commands: -@smallexample -(_GDBP__) help -List of classes of commands: - -running -- Running the program -stack -- Examining the stack -data -- Examining data -breakpoints -- Making program stop at certain points -files -- Specifying and examining files -status -- Status inquiries -support -- Support facilities -user-defined -- User-defined commands -aliases -- Aliases of other commands -obscure -- Obscure features - -Type "help" followed by a class name for a list of -commands in that class. -Type "help" followed by command name for full -documentation. -Command name abbreviations are allowed if unambiguous. -(_GDBP__) -@end smallexample - -@item help @var{class} -Using one of the general help classes as an argument, you can get a -list of the individual commands in that class. For example, here is the -help display for the class @code{status}: -@smallexample -(_GDBP__) help status -Status inquiries. - -List of commands: - -show -- Generic command for showing things set with "set" -info -- Generic command for printing status - -Type "help" followed by command name for full -documentation. -Command name abbreviations are allowed if unambiguous. -(_GDBP__) -@end smallexample - -@item help @var{command} -With a command name as @code{help} argument, _GDBN__ will display a -short paragraph on how to use that command. -@end table - -In addition to @code{help}, you can use the _GDBN__ commands @code{info} -and @code{show} to inquire about the state of your program, or the state -of _GDBN__ itself. Each command supports many topics of inquiry; this -manual introduces each of them in the appropriate context. The listings -under @code{info} and under @code{show} in the Index point to -all the sub-commands. -@c FIXME: @pxref{Index} used to be here, but even though it shows up in -@c FIXME...the 'aux' file with a pageno the xref can't find it. - -@c @group -@table @code -@item info -@kindex info -@kindex i -This command (abbreviated @code{i}) is for describing the state of your -program; for example, it can list the arguments given to your program -(@code{info args}), the registers currently in use (@code{info -registers}), or the breakpoints you've set (@code{info breakpoints}). -You can get a complete list of the @code{info} sub-commands with -@w{@code{help info}}. - -@kindex show -@item show -In contrast, @code{show} is for describing the state of _GDBN__ itself. -You can change most of the things you can @code{show}, by using the -related command @code{set}; for example, you can control what number -system is used for displays with @code{set radix}, or simply inquire -which is currently in use with @code{show radix}. - -@kindex info set -To display all the settable parameters and their current -values, you can use @code{show} with no arguments; you may also use -@code{info set}. Both commands produce the same display. -@c FIXME: "info set" violates the rule that "info" is for state of -@c FIXME...program. Ck w/ GNU: "info set" to be called something else, -@c FIXME...or change desc of rule---eg "state of prog and debugging session"? -@end table -@c @end group - -Here are three miscellaneous @code{show} subcommands, all of which are -exceptional in lacking corresponding @code{set} commands: - -@table @code -@kindex show version -@cindex version number -@item show version -Show what version of _GDBN__ is running. You should include this -information in _GDBN__ bug-reports. If multiple versions of _GDBN__ are -in use at your site, you may occasionally want to make sure what version -of _GDBN__ you're running; as _GDBN__ evolves, new commands are -introduced, and old ones may wither away. The version number is also -announced when you start _GDBN__ with no arguments. - -@kindex show copying -@item show copying -Display information about permission for copying _GDBN__. - -@kindex show warranty -@item show warranty -Display the GNU ``NO WARRANTY'' statement. -@end table - -@node Running, Stopping, Commands, Top -@chapter Running Programs Under _GDBN__ - -@menu -* Compilation:: Compiling for Debugging -* Starting:: Starting your Program -* Arguments:: Your Program's Arguments -* Environment:: Your Program's Environment -* Working Directory:: Your Program's Working Directory -* Input/Output:: Your Program's Input and Output -* Attach:: Debugging an Already-Running Process -* Kill Process:: Killing the Child Process -@end menu - -@node Compilation, Starting, Running, Running -@section Compiling for Debugging - -In order to debug a program effectively, you need to generate -debugging information when you compile it. This debugging information -is stored in the object file; it describes the data type of each -variable or function and the correspondence between source line numbers -and addresses in the executable code. - -To request debugging information, specify the @samp{-g} option when you run -the compiler. - -Many C compilers are unable to handle the @samp{-g} and @samp{-O} -options together. Using those compilers, you cannot generate optimized -executables containing debugging information. - -The GNU C compiler supports @samp{-g} with or without @samp{-O}, making it -possible to debug optimized code. We recommend that you @emph{always} use -@samp{-g} whenever you compile a program. You may think the program is -correct, but there's no sense in pushing your luck. - -Some things do not work as well with @samp{-g -O} as with just -@samp{-g}, particularly on machines with instruction scheduling. If in -doubt, recompile with @samp{-g} alone, and if this fixes the problem, -please report it as a bug (including a test case!). - -Older versions of the GNU C compiler permitted a variant option -@samp{-gg} for debugging information. _GDBN__ no longer supports this -format; if your GNU C compiler has this option, do not use it. - -@ignore -@comment As far as I know, there are no cases in which _GDBN__ will -@comment produce strange output in this case. (but no promises). -If your program includes archives made with the @code{ar} program, and -if the object files used as input to @code{ar} were compiled without the -@samp{-g} option and have names longer than 15 characters, _GDBN__ will get -confused reading the program's symbol table. No error message will be -given, but _GDBN__ may behave strangely. The reason for this problem is a -deficiency in the Unix archive file format, which cannot represent file -names longer than 15 characters. - -To avoid this problem, compile the archive members with the @samp{-g} -option or use shorter file names. Alternatively, use a version of GNU -@code{ar} dated more recently than August 1989. -@end ignore - - -@node Starting, Arguments, Compilation, Running -@section Starting your Program -@cindex starting -@cindex running -@table @code -@item run -@itemx r -@kindex run -Use the @code{run} command to start your program under _GDBN__. You -must first specify the program name -_if__(_VXWORKS__) -(except on VxWorks) -_fi__(_VXWORKS__) -with an argument to _GDBN__ -(@pxref{Invocation}), or using the @code{file} or @code{exec-file} -command (@pxref{Files}). -@refill -@end table - -@c FIXME explain or avoid "target" here? -On targets that support processes, @code{run} creates an inferior -process and makes that process run your program. On other targets, -@code{run} jumps to the start of the program. - -The execution of a program is affected by certain information it -receives from its superior. _GDBN__ provides ways to specify this -information, which you must do @i{before} starting the program. (You -can change it after starting the program, but such changes will only affect -the program the next time you start it.) This information may be -divided into four categories: - -@table @asis -@item The @i{arguments.} -You specify the arguments to give your program as the arguments of the -@code{run} command. If a shell is available on your target, the shell -is used to pass the arguments, so that you may use normal conventions -(such as wildcard expansion or variable substitution) in -describing the arguments. In Unix systems, you can control which shell -is used with the @code{SHELL} environment variable. @xref{Arguments}.@refill - -@item The @i{environment.} -Your program normally inherits its environment from _GDBN__, but you can -use the _GDBN__ commands @code{set environment} and @code{unset -environment} to change parts of the environment that will be given to -the program. @xref{Environment}.@refill - -@item The @i{working directory.} -Your program inherits its working directory from _GDBN__. You can set -_GDBN__'s working directory with the @code{cd} command in _GDBN__. -@xref{Working Directory}. - -@item The @i{standard input and output.} -Your program normally uses the same device for standard input and -standard output as _GDBN__ is using. You can redirect input and output -in the @code{run} command line, or you can use the @code{tty} command to -set a different device for your program. -@xref{Input/Output}. - -@cindex pipes -@emph{Warning:} While input and output redirection work, you can't use -pipes to pass the output of the program you're debugging to another -program; if you attempt this, _GDBN__ is likely to wind up debugging the -wrong program. -@end table - -When you issue the @code{run} command, your program begins to execute -immediately. @xref{Stopping}, for discussion of how to arrange for your -program to stop. Once your program has been started by the @code{run} -command (and then stopped), you may evaluate expressions that involve -calls to functions in the inferior, using the @code{print} or -@code{call} commands. @xref{Data}. - -If the modification time of your symbol file has changed since the last -time _GDBN__ read its symbols, _GDBN__ will discard its symbol table and re-read -it. In this process, it tries to retain your current breakpoints. - -@node Arguments, Environment, Starting, Running -@section Your Program's Arguments - -@cindex arguments (to your program) -The arguments to your program can be specified by the arguments of the -@code{run} command. They are passed to a shell, which expands wildcard -characters and performs redirection of I/O, and thence to the program. -_GDBN__ uses the shell indicated by your environment variable -@code{SHELL} if it exists; otherwise, _GDBN__ uses @code{/bin/sh}. - -@code{run} with no arguments uses the same arguments used by the previous -@code{run}, or those set by the @code{set args} command. - -@kindex set args -@table @code -@item set args -Specify the arguments to be used the next time your program is run. If -@code{set args} has no arguments, @code{run} will execute your program -with no arguments. Once you have run your program with arguments, -using @code{set args} before the next @code{run} is the only way to run -it again without arguments. - -@item show args -@kindex show args -Show the arguments to give your program when it is started. -@end table - -@node Environment, Working Directory, Arguments, Running -@section Your Program's Environment - -@cindex environment (of your program) -The @dfn{environment} consists of a set of environment variables and -their values. Environment variables conventionally record such things as -your user name, your home directory, your terminal type, and your search -path for programs to run. Usually you set up environment variables with -the shell and they are inherited by all the other programs you run. When -debugging, it can be useful to try running the program with a modified -environment without having to start _GDBN__ over again. - -@table @code -@item path @var{directory} -@kindex path -Add @var{directory} to the front of the @code{PATH} environment variable -(the search path for executables), for both _GDBN__ and your program. -You may specify several directory names, separated by @samp{:} or -whitespace. If @var{directory} is already in the path, it is moved to -the front, so it will be searched sooner. - -You can use the string @samp{$cwd} to refer to whatever is the current -working directory at the time _GDBN__ searches the path. If you use -@samp{.} instead, it refers to the directory where you executed the -@code{path} command. _GDBN__ fills in the current path where needed in -the @var{directory} argument, before adding it to the search path. -@c 'path' is explicitly nonrepeatable, but RMS points out it's silly to -@c document that, since repeating it would be a no-op. - -@item show paths -@kindex show paths -Display the list of search paths for executables (the @code{PATH} -environment variable). - -@item show environment @r{[}@var{varname}@r{]} -@kindex show environment -Print the value of environment variable @var{varname} to be given to -your program when it starts. If you don't supply @var{varname}, -print the names and values of all environment variables to be given to -your program. You can abbreviate @code{environment} as @code{env}. - -@item set environment @var{varname} @r{[}=@r{]} @var{value} -@kindex set environment -Sets environment variable @var{varname} to @var{value}. The value -changes for your program only, not for _GDBN__ itself. @var{value} may -be any string; the values of environment variables are just strings, and -any interpretation is supplied by your program itself. The @var{value} -parameter is optional; if it is eliminated, the variable is set to a -null value. -@c "any string" here doesn't include leading, trailing -@c blanks. Gnu asks: does anyone care? - -For example, this command: - -@example -set env USER = foo -@end example - -@noindent -tells a Unix program, when subsequently run, that its user is named -@samp{foo}. (The spaces around @samp{=} are used for clarity here; they -are not actually required.) - -@item unset environment @var{varname} -@kindex unset environment -Remove variable @var{varname} from the environment to be passed to your -program. This is different from @samp{set env @var{varname} =}; -@code{unset environment} removes the variable from the environment, -rather than assigning it an empty value. -@end table - -@node Working Directory, Input/Output, Environment, Running -@section Your Program's Working Directory - -@cindex working directory (of your program) -Each time you start your program with @code{run}, it inherits its -working directory from the current working directory of _GDBN__. _GDBN__'s -working directory is initially whatever it inherited from its parent -process (typically the shell), but you can specify a new working -directory in _GDBN__ with the @code{cd} command. - -The _GDBN__ working directory also serves as a default for the commands -that specify files for _GDBN__ to operate on. @xref{Files}. - -@table @code -@item cd @var{directory} -@kindex cd -Set _GDBN__'s working directory to @var{directory}. - -@item pwd -@kindex pwd -Print _GDBN__'s working directory. -@end table - -@node Input/Output, Attach, Working Directory, Running -@section Your Program's Input and Output - -@cindex redirection -@cindex i/o -@cindex terminal -By default, the program you run under _GDBN__ does input and output to -the same terminal that _GDBN__ uses. _GDBN__ switches the terminal to -its own terminal modes to interact with you, but it records the terminal -modes your program was using and switches back to them when you continue -running your program. - -@table @code -@item info terminal -@kindex info terminal -Displays _GDBN__'s recorded information about the terminal modes your -program is using. -@end table - -You can redirect the program's input and/or output using shell -redirection with the @code{run} command. For example, - -_0__@example -run > outfile -_1__@end example - -@noindent -starts the program, diverting its output to the file @file{outfile}. - -@kindex tty -@cindex controlling terminal -Another way to specify where the program should do input and output is -with the @code{tty} command. This command accepts a file name as -argument, and causes this file to be the default for future @code{run} -commands. It also resets the controlling terminal for the child -process, for future @code{run} commands. For example, - -@example -tty /dev/ttyb -@end example - -@noindent -directs that processes started with subsequent @code{run} commands -default to do input and output on the terminal @file{/dev/ttyb} and have -that as their controlling terminal. - -An explicit redirection in @code{run} overrides the @code{tty} command's -effect on the input/output device, but not its effect on the controlling -terminal. - -When you use the @code{tty} command or redirect input in the @code{run} -command, only the input @emph{for your program} is affected. The input -for _GDBN__ still comes from your terminal. - -@node Attach, Kill Process, Input/Output, Running -@section Debugging an Already-Running Process -@kindex attach -@cindex attach - -@table @code -@item attach @var{process-id} -This command -attaches to a running process---one that was started outside _GDBN__. -(@code{info files} will show your active targets.) The command takes as -argument a process ID. The usual way to find out the process-id of -a Unix process is with the @code{ps} utility, or with the @samp{jobs -l} -shell command. - -@code{attach} will not repeat if you press @key{RET} a second time after -executing the command. -@end table - -To use @code{attach}, you must be debugging in an environment which -supports processes. You must also have permission to send the process a -signal, and it must have the same effective user ID as the _GDBN__ -process. - -When using @code{attach}, you should first use the @code{file} command -to specify the program running in the process and load its symbol table. -@xref{Files}. - -The first thing _GDBN__ does after arranging to debug the specified -process is to stop it. You can examine and modify an attached process -with all the _GDBN__ commands that are ordinarily available when you start -processes with @code{run}. You can insert breakpoints; you can step and -continue; you can modify storage. If you would rather the process -continue running, you may use the @code{continue} command after -attaching _GDBN__ to the process. - -@table @code -@item detach -@kindex detach -When you have finished debugging the attached process, you can use the -@code{detach} command to release it from _GDBN__'s control. Detaching -the process continues its execution. After the @code{detach} command, -that process and _GDBN__ become completely independent once more, and you -are ready to @code{attach} another process or start one with @code{run}. -@code{detach} will not repeat if you press @key{RET} again after -executing the command. -@end table - -If you exit _GDBN__ or use the @code{run} command while you have an attached -process, you kill that process. By default, you will be asked for -confirmation if you try to do either of these things; you can control -whether or not you need to confirm by using the @code{set confirm} command -(@pxref{Messages/Warnings}). - -@node Kill Process, , Attach, Running -@c @group -@section Killing the Child Process - -@table @code -@item kill -@kindex kill -Kill the child process in which your program is running under _GDBN__. -@end table - -This command is useful if you wish to debug a core dump instead of a -running process. _GDBN__ ignores any core dump file while your program -is running. -@c @end group - -On some operating systems, a program can't be executed outside _GDBN__ -while you have breakpoints set on it inside _GDBN__. You can use the -@code{kill} command in this situation to permit running the program -outside the debugger. - -The @code{kill} command is also useful if you wish to recompile and -relink the program, since on many systems it is impossible to modify an -executable file while it is running in a process. In this case, when you -next type @code{run}, _GDBN__ will notice that the file has changed, and -will re-read the symbol table (while trying to preserve your current -breakpoint settings). - -@node Stopping, Stack, Running, Top -@chapter Stopping and Continuing - -The principal purpose of using a debugger is so that you can stop your -program before it terminates; or so that, if the program runs into -trouble, you can investigate and find out why. - -Inside _GDBN__, your program may stop for any of several reasons, such -as a signal, a breakpoint, or reaching a new line after a _GDBN__ -command such as @code{step}. You may then examine and change -variables, set new breakpoints or remove old ones, and then continue -execution. Usually, the messages shown by _GDBN__ provide ample -explanation of the status of your program---but you can also explicitly -request this information at any time. - -@table @code -@item info program -@kindex info program -Display information about the status of your program: whether it is -running or not, what process it is, and why it stopped. -@end table - -@menu -* Breakpoints:: Breakpoints, Watchpoints, and Exceptions -* Continuing and Stepping:: Resuming Execution -* Signals:: Signals -@end menu - -@node Breakpoints, Continuing and Stepping, Stopping, Stopping -@section Breakpoints, Watchpoints, and Exceptions - -@cindex breakpoints -A @dfn{breakpoint} makes your program stop whenever a certain point in -the program is reached. For each breakpoint, you can add various -conditions to control in finer detail whether the program will stop. -You can set breakpoints with the @code{break} command and its variants -(@pxref{Set Breaks}), to specify the place where the program should stop -by line number, function name or exact address in the program. In -languages with exception handling (such as GNU C++), you can also set -breakpoints where an exception is raised (@pxref{Exception Handling}). - -@cindex watchpoints -A @dfn{watchpoint} is a special breakpoint that stops your program when -the value of an expression changes. You must use a different command to -set watchpoints (@pxref{Set Watchpoints}), but aside from that, you can -manage a watchpoint like any other breakpoint: you enable, disable, and -delete both breakpoints and watchpoints using the same commands. - -Each breakpoint or watchpoint is assigned a number when it is created; -these numbers are successive integers starting with one. In many of the -commands for controlling various features of breakpoints you use the -breakpoint number to say which breakpoint you want to change. Each -breakpoint may be @dfn{enabled} or @dfn{disabled}; if disabled, it has -no effect on the program until you enable it again. - -@menu -* Set Breaks:: Setting Breakpoints -* Set Watchpoints:: Setting Watchpoints -* Exception Handling:: Breakpoints and Exceptions -* Delete Breaks:: Deleting Breakpoints -* Disabling:: Disabling Breakpoints -* Conditions:: Break Conditions -* Break Commands:: Breakpoint Command Lists -* Breakpoint Menus:: Breakpoint Menus -* Error in Breakpoints:: -@end menu - -@node Set Breaks, Set Watchpoints, Breakpoints, Breakpoints -@subsection Setting Breakpoints - -@c FIXME LMB what does GDB do if no code on line of breakpt? -@c consider in particular declaration with/without initialization. -@c -@c FIXME 2 is there stuff on this already? break at fun start, already init? - -@kindex break -@kindex b -Breakpoints are set with the @code{break} command (abbreviated @code{b}). - -You have several ways to say where the breakpoint should go. - -@table @code -@item break @var{function} -Set a breakpoint at entry to function @var{function}. When using source -languages that permit overloading of symbols, such as C++, -@var{function} may refer to more than one possible place to break. -@xref{Breakpoint Menus}, for a discussion of that situation. - -@item break +@var{offset} -@itemx break -@var{offset} -Set a breakpoint some number of lines forward or back from the position -at which execution stopped in the currently selected frame. - -@item break @var{linenum} -Set a breakpoint at line @var{linenum} in the current source file. -That file is the last file whose source text was printed. This -breakpoint will stop the program just before it executes any of the -code on that line. - -@item break @var{filename}:@var{linenum} -Set a breakpoint at line @var{linenum} in source file @var{filename}. - -@item break @var{filename}:@var{function} -Set a breakpoint at entry to function @var{function} found in file -@var{filename}. Specifying a file name as well as a function name is -superfluous except when multiple files contain similarly named -functions. - -@item break *@var{address} -Set a breakpoint at address @var{address}. You can use this to set -breakpoints in parts of the program which do not have debugging -information or source files. - -@item break -When called without any arguments, @code{break} sets a breakpoint at the -next instruction to be executed in the selected stack frame -(@pxref{Stack}). In any selected frame but the innermost, this will -cause the program to stop as soon as control returns to that frame. -This is similar to the effect of a @code{finish} command in the frame -inside the selected frame---except that @code{finish} doesn't leave an -active breakpoint. If you use @code{break} without an argument in the -innermost frame, _GDBN__ will stop the next time it reaches the current -location; this may be useful inside loops. - -_GDBN__ normally ignores breakpoints when it resumes execution, until at -least one instruction has been executed. If it did not do this, you -would be unable to proceed past a breakpoint without first disabling the -breakpoint. This rule applies whether or not the breakpoint already -existed when the program stopped. - -@item break @dots{} if @var{cond} -Set a breakpoint with condition @var{cond}; evaluate the expression -@var{cond} each time the breakpoint is reached, and stop only if the -value is nonzero---that is, if @var{cond} evaluates as true. -@samp{@dots{}} stands for one of the possible arguments described above -(or no argument) specifying where to break. @xref{Conditions}, for more -information on breakpoint conditions. - -@item tbreak @var{args} -@kindex tbreak -Set a breakpoint enabled only for one stop. @var{args} are the -same as for the @code{break} command, and the breakpoint is set in the same -way, but the breakpoint is automatically disabled the first time it -is hit. @xref{Disabling}. - -@item rbreak @var{regex} -@kindex rbreak -@cindex regular expression -@c FIXME what kind of regexp? -Set breakpoints on all functions matching the regular expression -@var{regex}. This command -sets an unconditional breakpoint on all matches, printing a list of all -breakpoints it set. Once these breakpoints are set, they are treated -just like the breakpoints set with the @code{break} command. They can -be deleted, disabled, made conditional, etc., in the standard ways. - -When debugging C++ programs, @code{rbreak} is useful for setting -breakpoints on overloaded functions that are not members of any special -classes. - -@kindex info breakpoints -@cindex @code{$_} and @code{info breakpoints} -@item info breakpoints @r{[}@var{n}@r{]} -@item info break @r{[}@var{n}@r{]} -Print a list of all breakpoints (but not watchpoints) set and not -deleted, showing their numbers, where in the program they are, and any -special features in use for them. Disabled breakpoints are included in -the list, but marked as disabled. @code{info break} with a breakpoint -number @var{n} as argument lists only that breakpoint. The convenience -variable @code{$_} and the default examining-address for the @code{x} -command are set to the address of the last breakpoint listed -(@pxref{Memory}). The equivalent command for watchpoints is @code{info -watch}. @end table - -_GDBN__ allows you to set any number of breakpoints at the same place in the -program. There is nothing silly or meaningless about this. When the -breakpoints are conditional, this is even useful (@pxref{Conditions}). - -@node Set Watchpoints, Exception Handling, Set Breaks, Breakpoints -@subsection Setting Watchpoints -@cindex setting watchpoints -You can use a watchpoint to stop execution whenever the value of an -expression changes, without having to predict a particular place -where this may happen. - -Watchpoints currently execute two orders of magnitude more slowly than -other breakpoints, but this can well be worth it to catch errors where -you have no clue what part of your program is the culprit. Some -processors provide special hardware to support watchpoint evaluation; future -releases of _GDBN__ will use such hardware if it is available. - -@table @code -@kindex watch -@item watch @var{expr} -Set a watchpoint for an expression. - -@kindex info watchpoints -@item info watchpoints -This command prints a list of watchpoints; it is otherwise similar to -@code{info break}. -@end table - -@node Exception Handling, Delete Breaks, Set Watchpoints, Breakpoints -@subsection Breakpoints and Exceptions -@cindex exception handlers - -Some languages, such as GNU C++, implement exception handling. You can -use _GDBN__ to examine what caused the program to raise an exception, -and to list the exceptions the program is prepared to handle at a -given point in time. - -@table @code -@item catch @var{exceptions} -@kindex catch -You can set breakpoints at active exception handlers by using the -@code{catch} command. @var{exceptions} is a list of names of exceptions -to catch. -@end table - -You can use @code{info catch} to list active exception handlers; -@pxref{Frame Info}. - -There are currently some limitations to exception handling in _GDBN__. -These will be corrected in a future release. - -@itemize @bullet -@item -If you call a function interactively, _GDBN__ normally returns -control to you when the function has finished executing. If the call -raises an exception, however, the call may bypass the mechanism that -returns control to the user and cause the program to simply continue -running until it hits a breakpoint, catches a signal that _GDBN__ is -listening for, or exits. -@item -You cannot raise an exception interactively. -@item -You cannot interactively install an exception handler. -@end itemize - -@cindex raise exceptions -Sometimes @code{catch} is not the best way to debug exception handling: -if you need to know exactly where an exception is raised, it's better to -stop @emph{before} the exception handler is called, since that way you -can see the stack before any unwinding takes place. If you set a -breakpoint in an exception handler instead, it may not be easy to find -out where the exception was raised. - -To stop just before an exception handler is called, you need some -knowledge of the implementation. In the case of GNU C++, exceptions are -raised by calling a library function named @code{__raise_exception} -which has the following ANSI C interface: - -@example - /* @var{addr} is where the exception identifier is stored. - ID is the exception identifier. */ - void __raise_exception (void **@var{addr}, void *@var{id}); -@end example - -@noindent -To make the debugger catch all exceptions before any stack -unwinding takes place, set a breakpoint on @code{__raise_exception} -(@pxref{Breakpoints}). - -With a conditional breakpoint (@xref{Conditions}) that depends on the -value of @var{id}, you can stop your program when a specific exception -is raised. You can use multiple conditional breakpoints to stop the -program when any of a number of exceptions are raised. - -@node Delete Breaks, Disabling, Exception Handling, Breakpoints -@subsection Deleting Breakpoints - -@cindex clearing breakpoints, watchpoints -@cindex deleting breakpoints, watchpoints -It is often necessary to eliminate a breakpoint or watchpoint once it -has done its job and you no longer want the program to stop there. This -is called @dfn{deleting} the breakpoint. A breakpoint that has been -deleted no longer exists; it is forgotten. - -With the @code{clear} command you can delete breakpoints according to -where they are in the program. With the @code{delete} command you can -delete individual breakpoints or watchpoints by specifying their -breakpoint numbers. - -It is not necessary to delete a breakpoint to proceed past it. _GDBN__ -automatically ignores breakpoints on the first instruction to be executed -when you continue execution without changing the execution address. - -@table @code -@item clear -@kindex clear -Delete any breakpoints at the next instruction to be executed in the -selected stack frame (@pxref{Selection}). When the innermost frame -is selected, this is a good way to delete a breakpoint that the program -just stopped at. - -@item clear @var{function} -@itemx clear @var{filename}:@var{function} -Delete any breakpoints set at entry to the function @var{function}. - -@item clear @var{linenum} -@itemx clear @var{filename}:@var{linenum} -Delete any breakpoints set at or within the code of the specified line. - -@item delete @r{[}breakpoints@r{]} @r{[}@var{bnums}@dots{}@r{]} -@cindex delete breakpoints -@kindex delete -@kindex d -Delete the breakpoints or watchpoints of the numbers specified as -arguments. If no argument is specified, delete all breakpoints (_GDBN__ -asks confirmation, unless you've @code{set confirm off}). You -can abbreviate this command as @code{d}. -@end table - -@node Disabling, Conditions, Delete Breaks, Breakpoints -@subsection Disabling Breakpoints - -@cindex disabled breakpoints -@cindex enabled breakpoints -Rather than deleting a breakpoint or watchpoint, you might prefer to -@dfn{disable} it. This makes the breakpoint inoperative as if it had -been deleted, but remembers the information on the breakpoint so that -you can @dfn{enable} it again later. - -You disable and enable breakpoints and watchpoints with the -@code{enable} and @code{disable} commands, optionally specifying one or -more breakpoint numbers as arguments. Use @code{info break} or -@code{info watch} to print a list of breakpoints or watchpoints if you -don't know which numbers to use. - -A breakpoint or watchpoint can have any of four different states of -enablement: - -@itemize @bullet -@item -Enabled. The breakpoint will stop the program. A breakpoint set -with the @code{break} command starts out in this state. -@item -Disabled. The breakpoint has no effect on the program. -@item -Enabled once. The breakpoint will stop the program, but -when it does so it will become disabled. A breakpoint set -with the @code{tbreak} command starts out in this state. -@item -Enabled for deletion. The breakpoint will stop the program, but -immediately after it does so it will be deleted permanently. -@end itemize - -You can use the following commands to enable or disable breakpoints and -watchpoints: - -@table @code -@item disable @r{[}breakpoints@r{]} @r{[}@var{bnums}@dots{}@r{]} -@kindex disable breakpoints -@kindex disable -@kindex dis -Disable the specified breakpoints---or all breakpoints, if none are -listed. A disabled breakpoint has no effect but is not forgotten. All -options such as ignore-counts, conditions and commands are remembered in -case the breakpoint is enabled again later. You may abbreviate -@code{disable} as @code{dis}. - -@item enable @r{[}breakpoints@r{]} @r{[}@var{bnums}@dots{}@r{]} -@kindex enable breakpoints -@kindex enable -Enable the specified breakpoints (or all defined breakpoints). They -become effective once again in stopping the program. - -@item enable @r{[}breakpoints@r{]} once @var{bnums}@dots{} -Enable the specified breakpoints temporarily. Each will be disabled -again the next time it stops the program. - -@item enable @r{[}breakpoints@r{]} delete @var{bnums}@dots{} -Enable the specified breakpoints to work once and then die. Each of -the breakpoints will be deleted the next time it stops the program. -@end table - -Save for a breakpoint set with @code{tbreak} (@pxref{Set Breaks}), -breakpoints that you set are initially enabled; subsequently, they become -disabled or enabled only when you use one of the commands above. (The -command @code{until} can set and delete a breakpoint of its own, but it -will not change the state of your other breakpoints; -@pxref{Continuing and Stepping}.) - -@node Conditions, Break Commands, Disabling, Breakpoints -@subsection Break Conditions -@cindex conditional breakpoints -@cindex breakpoint conditions - -@c FIXME what is scope of break condition expr? Context where wanted? -@c in particular for a watchpoint? -The simplest sort of breakpoint breaks every time the program reaches a -specified place. You can also specify a @dfn{condition} for a -breakpoint. A condition is just a Boolean expression in your -programming language. (@xref{Expressions}). A breakpoint with a condition -evaluates the expression each time the program reaches it, and the -program stops only if the condition is @emph{true}. - -This is the converse of using assertions for program validation; in that -situation, you want to stop when the assertion is violated---that is, -when the condition is false. In C, if you want to test an assertion expressed -by the condition @var{assert}, you should set the condition -@samp{! @var{assert}} on the appropriate breakpoint. - -Conditions are also accepted for watchpoints; you may not need them, -since a watchpoint is inspecting the value of an expression anyhow---but -it might be simpler, say, to just set a watchpoint on a variable name, -and specify a condition that tests whether the new value is an interesting -one. - -Break conditions ca have side effects, and may even call functions in -your program. This can be useful, for example, to activate functions -that log program progress, or to use your own print functions to format -special data structures. The effects are completely predictable unless -there is another enabled breakpoint at the same address. (In that -case, _GDBN__ might see the other breakpoint first and stop the program -without checking the condition of this one.) Note that breakpoint -commands are usually more convenient and flexible for the purpose of -performing side effects when a breakpoint is reached -(@pxref{Break Commands}). - -Break conditions can be specified when a breakpoint is set, by using -@samp{if} in the arguments to the @code{break} command. @xref{Set Breaks}. -They can also be changed at any time with the @code{condition} command. -The @code{watch} command doesn't recognize the @code{if} keyword; -@code{condition} is the only way to impose a further condition on a -watchpoint. - -@table @code -@item condition @var{bnum} @var{expression} -@kindex condition -Specify @var{expression} as the break condition for breakpoint or -watchpoint number @var{bnum}. From now on, this breakpoint will stop -the program only if the value of @var{expression} is true (nonzero, in -C). When you use @code{condition}, _GDBN__ checks @var{expression} -immediately for syntactic correctness, and to determine whether symbols -in it have referents in the context of your breakpoint. -@c FIXME so what does GDB do if there's no referent? Moreover, what -@c about watchpoints? -_GDBN__ does -not actually evaluate @var{expression} at the time the @code{condition} -command is given, however. @xref{Expressions}. - -@item condition @var{bnum} -Remove the condition from breakpoint number @var{bnum}. It becomes -an ordinary unconditional breakpoint. -@end table - -@cindex ignore count (of breakpoint) -A special case of a breakpoint condition is to stop only when the -breakpoint has been reached a certain number of times. This is so -useful that there is a special way to do it, using the @dfn{ignore -count} of the breakpoint. Every breakpoint has an ignore count, which -is an integer. Most of the time, the ignore count is zero, and -therefore has no effect. But if the program reaches a breakpoint whose -ignore count is positive, then instead of stopping, it just decrements -the ignore count by one and continues. As a result, if the ignore count -value is @var{n}, the breakpoint will not stop the next @var{n} times it -is reached. - -@table @code -@item ignore @var{bnum} @var{count} -@kindex ignore -Set the ignore count of breakpoint number @var{bnum} to @var{count}. -The next @var{count} times the breakpoint is reached, your program's -execution will not stop; other than to decrement the ignore count, _GDBN__ -takes no action. - -To make the breakpoint stop the next time it is reached, specify -a count of zero. - -@item continue @var{count} -@itemx c @var{count} -@itemx fg @var{count} -@kindex continue @var{count} -Continue execution of the program, setting the ignore count of the -breakpoint that the program stopped at to @var{count} minus one. -Thus, the program will not stop at this breakpoint until the -@var{count}'th time it is reached. - -An argument to this command is meaningful only when the program stopped -due to a breakpoint. At other times, the argument to @code{continue} is -ignored. - -The synonym @code{fg} is provided purely for convenience, and has -exactly the same behavior as other forms of the command. -@end table - -If a breakpoint has a positive ignore count and a condition, the condition -is not checked. Once the ignore count reaches zero, the condition will -be checked. - -You could achieve the effect of the ignore count with a -condition such as _0__@w{@samp{$foo-- <= 0}}_1__ using a debugger convenience -variable that is decremented each time. @xref{Convenience Vars}. - -@node Break Commands, Breakpoint Menus, Conditions, Breakpoints -@subsection Breakpoint Command Lists - -@cindex breakpoint commands -You can give any breakpoint (or watchpoint) a series of commands to -execute when the program stops due to that breakpoint. For example, you -might want to print the values of certain expressions, or enable other -breakpoints. - -@table @code -@item commands @r{[}@var{bnum}@r{]} -@itemx @dots{} @var{command-list} @dots{} -@itemx end -@kindex commands -@kindex end -Specify a list of commands for breakpoint number @var{bnum}. The commands -themselves appear on the following lines. Type a line containing just -@code{end} to terminate the commands. - -To remove all commands from a breakpoint, type @code{commands} and -follow it immediately with @code{end}; that is, give no commands. - -With no @var{bnum} argument, @code{commands} refers to the last -breakpoint or watchpoint set (not to the breakpoint most recently -encountered). -@end table - -Pressing @key{RET} as a means of repeating the last _GDBN__ command is -disabled within a @var{command-list}. - -You can use breakpoint commands to start the program up again. Simply -use the @code{continue} command, or @code{step}, or any other command -that resumes execution. Subsequent commands in the command list are -ignored. - -@kindex silent -If the first command specified is @code{silent}, the usual message about -stopping at a breakpoint is not printed. This may be desirable for -breakpoints that are to print a specific message and then continue. -If the remaining commands too print nothing, you will see no sign that -the breakpoint was reached at all. @code{silent} is meaningful only -at the beginning of a breakpoint command list. - -The commands @code{echo} and @code{output} that allow you to print precisely -controlled output are often useful in silent breakpoints. @xref{Output}. - -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. - -_0__@example -break foo if x>0 -commands -silent -echo x is\040 -output x -echo \n -cont -end -_1__@end example - -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 -of code, give it a condition to detect the case in which something -erroneous has been done, and give it commands to assign correct values -to any variables that need them. End with the @code{continue} command -so that the program does not stop, and start with the @code{silent} -command so that no output is produced. Here is an example: - -@example -break 403 -commands -silent -set x = y + 4 -cont -end -@end example - -@cindex lost output -One deficiency in the operation of automatically continuing breakpoints -under Unix appears when your program uses raw mode for the terminal. -_GDBN__ switches back to its own terminal modes (not raw) before executing -commands, and then must switch back to raw mode when your program is -continued. This causes any pending terminal input to be lost. -@c FIXME: revisit below when GNU sys avail. -@c In the GNU system, this will be fixed by changing the behavior of -@c terminal modes. - -Under Unix, you can get around this problem by writing actions into -the breakpoint condition rather than in commands. For example - -@example -condition 5 (x = y + 4), 0 -@end example - -@noindent -specifies a condition expression (@xref{Expressions}) that will change -@code{x} as needed, then always have the value zero so the program will -not stop. No input is lost here, because _GDBN__ evaluates break -conditions without changing the terminal modes. When you want to have -nontrivial conditions for performing the side effects, the operators -@samp{&&}, @samp{||} and @samp{?@dots{}:} may be useful. - -@node Breakpoint Menus, Error in Breakpoints, Break Commands, Breakpoints -@subsection Breakpoint Menus -@cindex overloading -@cindex symbol overloading - -Some programming languages (notably C++) permit a single function name -to be defined several times, for application in different contexts. -This is called @dfn{overloading}. When a function name is overloaded, -@samp{break @var{function}} is not enough to tell _GDBN__ where you -want a breakpoint. _GDBN__ offers you a menu of numbered choices for -different possible breakpoints, and waits for your selection with the -prompt @samp{>}. The first two options are always @samp{[0] cancel} -and @samp{[1] all}. Typing @kbd{1} sets a breakpoint at each -definition of @var{function}, and typing @kbd{0} aborts the -@code{break} command without setting any new breakpoints. - -For example, the following session excerpt shows an attempt to set a -breakpoint at the overloaded symbol @code{String::after}. -We choose three particular definitions of that function name: - -@example -(_GDBP__) b String::after -[0] cancel -[1] all -[2] file:String.cc; line number:867 -[3] file:String.cc; line number:860 -[4] file:String.cc; line number:875 -[5] file:String.cc; line number:853 -[6] file:String.cc; line number:846 -[7] file:String.cc; line number:735 -> 2 4 6 -Breakpoint 1 at 0xb26c: file String.cc, line 867. -Breakpoint 2 at 0xb344: file String.cc, line 875. -Breakpoint 3 at 0xafcc: file String.cc, line 846. -Multiple breakpoints were set. -Use the "delete" command to delete unwanted breakpoints. -(_GDBP__) -@end example - - -@node Error in Breakpoints, , Breakpoint Menus, Breakpoints -@subsection ``Cannot Insert Breakpoints'' - -@c FIXME: "cannot insert breakpoints" error, v unclear. -@c Q in pending mail to Gilmore. ---pesch@cygnus.com, 26mar91 -@c some light may be shed by looking at instances of -@c ONE_PROCESS_WRITETEXT. But error seems possible otherwise -@c too. pesch, 20sep91 -Under some operating systems, breakpoints cannot be used in a program if -any other process is running that program. In this situation, -attempting to run or continue a program with a breakpoint causes _GDBN__ -to stop the other process. - -When this happens, you have three ways to proceed: - -@enumerate -@item -Remove or disable the breakpoints, then continue. - -@item -Suspend _GDBN__, and copy the file containing the program to a new name. -Resume _GDBN__ and use the @code{exec-file} command to specify that _GDBN__ -should run the program under that name. Then start the program again. - -@c FIXME: RMS commented here "Show example". Maybe when someone -@c explains the first FIXME: in this section... - -@item -Relink the program so that the text segment is nonsharable, using the -linker option @samp{-N}. The operating system limitation may not apply -to nonsharable executables. -@end enumerate - -@node Continuing and Stepping, Signals, Breakpoints, Stopping -@section Continuing and Stepping - -@cindex stepping -@cindex continuing -@cindex resuming execution -@dfn{Continuing} means resuming program execution until your program -completes normally. In contrast, @dfn{stepping} means executing just -one more ``step'' of your program, where ``step'' may mean either one -line of source code, or one machine instruction (depending on what -particular command you use). Either when continuing -or when stepping, the program may stop even sooner, due to a breakpoint -or to a signal. (If due to a signal, you may want to use @code{handle}, -or use @samp{signal 0} to resume execution; @pxref{Signals}.) - -@table @code -@item continue @r{[}@var{ignore-count}@r{]} -@kindex continue -Resume program execution, at the address where the program last stopped; -any breakpoints set at that address are bypassed. The optional argument -@var{ignore-count} allows you to specify a further number of times to -ignore a breakpoint at this location; its effect is like that of -@code{ignore} (@pxref{Conditions}). - -To resume execution at a different place, you can use @code{return} -(@pxref{Returning}) to go back to the calling function; or @code{jump} -(@pxref{Jumping}) to go to an arbitrary location in your program. - -@end table - -A typical technique for using stepping is to set a breakpoint -(@pxref{Breakpoints}) at the beginning of the function or the section of -the program in which a problem is believed to lie, run the program until -it stops at that breakpoint, and then step through the suspect area, -examining the variables that are interesting, until you see the problem -happen. - -@table @code -@item step -@kindex step -@kindex s -Continue running the program until control reaches a different source -line, then stop it and return control to _GDBN__. This command is -abbreviated @code{s}. - -@quotation -@emph{Warning:} If you use the @code{step} command while control is -within a function that was compiled without debugging information, -execution will proceed until control reaches another function. -@end quotation - -@item step @var{count} -Continue running as in @code{step}, but do so @var{count} times. If a -breakpoint is reached or a signal not related to stepping occurs before -@var{count} steps, stepping stops right away. - -@item next @r{[}@var{count}@r{]} -@kindex next -@kindex n -Continue to the next source line in the current (innermost) stack frame. -Similar to @code{step}, but any function calls appearing within the line -of code are executed without stopping. Execution stops when control -reaches a different line of code at the stack level which was executing -when the @code{next} command was given. This command is abbreviated -@code{n}. - -An argument @var{count} is a repeat count, as for @code{step}. - -@code{next} within a function that lacks debugging information acts like -@code{step}, but any function calls appearing within the code of the -function are executed without stopping. - -@item finish -@kindex finish -Continue running until just after function in the selected stack frame -returns. Print the returned value (if any). - -Contrast this with the @code{return} command (@pxref{Returning}). - -@item until -@kindex until -@item u -@kindex u -Continue running until a source line past the current line, in the -current stack frame, is reached. This command is used to avoid single -stepping through a loop more than once. It is like the @code{next} -command, except that when @code{until} encounters a jump, it -automatically continues execution until the program counter is greater -than the address of the jump. - -This means that when you reach the end of a loop after single stepping -though it, @code{until} will cause the program to continue execution -until the loop is exited. In contrast, a @code{next} command at the end -of a loop will simply step back to the beginning of the loop, which -would force you to step through the next iteration. - -@code{until} always stops the program if it attempts to exit the current -stack frame. - -@code{until} may produce somewhat counterintuitive results if the order -of machine code does not match the order of the source lines. For -example, in the following excerpt from a debugging session, the @code{f} -(@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 -(_GDBP__) f -#0 main (argc=4, argv=0xf7fffae8) at m4.c:206 -206 expand_input(); -(_GDBP__) until -195 for ( ; argc > 0; NEXTARG) @{ -@end example - -This happened because, for execution efficiency, the compiler had -generated code for the loop closure test at the end, rather than the -start, of the loop---even though the test in a C @code{for}-loop is -written before the body of the loop. The @code{until} command appeared -to step back to the beginning of the loop when it advanced to this -expression; however, it has not really gone to an earlier -statement---not in terms of the actual machine code. - -@code{until} with no argument works by means of single -instruction stepping, and hence is slower than @code{until} with an -argument. - -@item until @var{location} -@item u @var{location} -Continue running the program until either the specified location is -reached, or the current stack frame returns. @var{location} -is any of the forms of argument acceptable to @code{break} -(@pxref{Set Breaks}). This form of the command uses breakpoints, and -hence is quicker than @code{until} without an argument. - -@item stepi -@itemx si -@kindex stepi -@kindex si -Execute one machine instruction, then stop and return to the debugger. - -It is often useful to do @samp{display/i $pc} when stepping by machine -instructions. This will cause the next instruction to be executed to -be displayed automatically at each stop. @xref{Auto Display}. - -An argument is a repeat count, as in @code{step}. - -@item nexti -@itemx ni -@kindex nexti -@kindex ni -Execute one machine instruction, but if it is a function call, -proceed until the function returns. - -An argument is a repeat count, as in @code{next}. -@end table - - -@node Signals, , Continuing and Stepping, Stopping -@section Signals -@cindex signals - -A signal is an asynchronous event that can happen in a program. The -operating system defines the possible kinds of signals, and gives each -kind a name and a number. For example, in Unix @code{SIGINT} is the -signal a program gets when you type an interrupt (often @kbd{C-c}); -@code{SIGSEGV} is the signal a program gets from referencing a place in -memory far away from all the areas in use; @code{SIGALRM} occurs when -the alarm clock timer goes off (which happens only if the program has -requested an alarm). - -@cindex fatal signals -Some signals, including @code{SIGALRM}, are a normal part of the -functioning of the program. Others, such as @code{SIGSEGV}, indicate -errors; these signals are @dfn{fatal} (kill the program immediately) if the -program has not specified in advance some other way to handle the signal. -@code{SIGINT} does not indicate an error in the program, but it is normally -fatal so it can carry out the purpose of the interrupt: to kill the program. - -_GDBN__ has the ability to detect any occurrence of a signal in the program -running under _GDBN__'s control. You can tell _GDBN__ in advance what to do for -each kind of signal. - -@cindex handling signals -Normally, _GDBN__ is set up to ignore non-erroneous signals like @code{SIGALRM} -(so as not to interfere with their role in the functioning of the program) -but to stop the program immediately whenever an error signal happens. -You can change these settings with the @code{handle} command. - -@table @code -@item info signals -@kindex info signals -Print a table of all the kinds of signals and how _GDBN__ has been told to -handle each one. You can use this to see the signal numbers of all -the defined types of signals. - -@item handle @var{signal} @var{keywords}@dots{} -@kindex handle -Change the way _GDBN__ handles signal @var{signal}. @var{signal} can be the -number of a signal or its name (with or without the @samp{SIG} at the -beginning). The @var{keywords} say what change to make. -@end table - -@c @group -The keywords allowed by the @code{handle} command can be abbreviated. -Their full names are: - -@table @code -@item nostop -_GDBN__ should not stop the program when this signal happens. It may -still print a message telling you that the signal has come in. - -@item stop -_GDBN__ should stop the program when this signal happens. This implies -the @code{print} keyword as well. - -@item print -_GDBN__ should print a message when this signal happens. - -@item noprint -_GDBN__ should not mention the occurrence of the signal at all. This -implies the @code{nostop} keyword as well. - -@item pass -_GDBN__ should allow the program to see this signal; the program will be -able to handle the signal, or may be terminated if the signal is fatal -and not handled. - -@item nopass -_GDBN__ should not allow the program to see this signal. -@end table -@c @end group - -When a signal has been set to stop the program, the program cannot see the -signal until you continue. It will see the signal then, if @code{pass} is -in effect for the signal in question @i{at that time}. In other words, -after _GDBN__ reports a signal, you can use the @code{handle} command with -@code{pass} or @code{nopass} to control whether that signal will be seen by -the program when you later continue it. - -You can also use the @code{signal} command to prevent the program from -seeing a signal, or cause it to see a signal it normally would not see, -or to give it any signal at any time. For example, if the program stopped -due to some sort of memory reference error, you might store correct -values into the erroneous variables and continue, hoping to see more -execution; but the program would probably terminate immediately as -a result of the fatal signal once it sees the signal. To prevent this, -you can continue with @samp{signal 0}. @xref{Signaling}. - -@node Stack, Source, Stopping, Top -@chapter Examining the Stack - -When your program has stopped, the first thing you need to know is where it -stopped and how it got there. - -@cindex call stack -Each time your program performs a function call, the information about -where in the program the call was made from is saved in a block of data -called a @dfn{stack frame}. The frame also contains the arguments of the -call and the local variables of the function that was called. All the -stack frames are allocated in a region of memory called the @dfn{call -stack}. - -When your program stops, the _GDBN__ commands for examining the stack allow you -to see all of this information. - -@cindex selected frame -One of the stack frames is @dfn{selected} by _GDBN__ and many _GDBN__ commands -refer implicitly to the selected frame. In particular, whenever you ask -_GDBN__ for the value of a variable in the program, the value is found in the -selected frame. There are special _GDBN__ commands to select whichever frame -you are interested in. - -When the program stops, _GDBN__ automatically selects the currently executing -frame and describes it briefly as the @code{frame} command does -(@pxref{Frame Info}). - -@menu -* Frames:: Stack Frames -* Backtrace:: Backtraces -* Selection:: Selecting a Frame -* Frame Info:: Information on a Frame -@end menu - -@node Frames, Backtrace, Stack, Stack -@section Stack Frames - -@cindex frame -@cindex stack frame -The call stack is divided up into contiguous pieces called @dfn{stack -frames}, or @dfn{frames} for short; each frame is the data associated -with one call to one function. The frame contains the arguments given -to the function, the function's local variables, and the address at -which the function is executing. - -@cindex initial frame -@cindex outermost frame -@cindex innermost frame -When your program is started, the stack has only one frame, that of the -function @code{main}. This is called the @dfn{initial} frame or the -@dfn{outermost} frame. Each time a function is called, a new frame is -made. Each time a function returns, the frame for that function invocation -is eliminated. If a function is recursive, there can be many frames for -the same function. The frame for the function in which execution is -actually occurring is called the @dfn{innermost} frame. This is the most -recently created of all the stack frames that still exist. - -@cindex frame pointer -Inside your program, stack frames are identified by their addresses. A -stack frame consists of many bytes, each of which has its own address; each -kind of computer has a convention for choosing one of those bytes whose -address serves as the address of the frame. Usually this address is kept -in a register called the @dfn{frame pointer register} while execution is -going on in that frame. - -@cindex frame number -_GDBN__ assigns numbers to all existing stack frames, starting with -zero for the innermost frame, one for the frame that called it, -and so on upward. These numbers do not really exist in your program; -they are assigned by _GDBN__ to give you a way of designating stack -frames in _GDBN__ commands. - -@cindex frameless execution -Some compilers allow functions to be compiled so that they operate -without stack frames. (For example, the @code{_GCC__} option -@samp{-fomit-frame-pointer} will generate functions without a frame.) -This is occasionally done with heavily used library functions to save -the frame setup time. _GDBN__ has limited facilities for dealing with -these function invocations. If the innermost function invocation has no -stack frame, _GDBN__ will nevertheless regard it as though it had a -separate frame, which is numbered zero as usual, allowing correct -tracing of the function call chain. However, _GDBN__ has no provision -for frameless functions elsewhere in the stack. - -@node Backtrace, Selection, Frames, Stack -@section Backtraces - -A backtrace is a summary of how the program got where it is. It shows one -line per frame, for many frames, starting with the currently executing -frame (frame zero), followed by its caller (frame one), and on up the -stack. - -@table @code -@item backtrace -@itemx bt -@kindex backtrace -@kindex bt -Print a backtrace of the entire stack: one line per frame for all -frames in the stack. - -You can stop the backtrace at any time by typing the system interrupt -character, normally @kbd{C-c}. - -@item backtrace @var{n} -@itemx bt @var{n} -Similar, but print only the innermost @var{n} frames. - -@item backtrace -@var{n} -@itemx bt -@var{n} -Similar, but print only the outermost @var{n} frames. -@end table - -@kindex where -@kindex info stack -@kindex info s -The names @code{where} and @code{info stack} (abbreviated @code{info s}) -are additional aliases for @code{backtrace}. - -Each line in the backtrace shows the frame number and the function name. -The program counter value is also shown---unless you use @code{set -print address off}. The backtrace also shows the source file name and -line number, as well as the arguments to the function. The program -counter value is omitted if it is at the beginning of the code for that -line number. - -Here is an example of a backtrace. It was made with the command -@samp{bt 3}, so it shows the innermost three frames. - -@smallexample -@group -#0 m4_traceon (obs=0x24eb0, argc=1, argv=0x2b8c8) - at builtin.c:993 -#1 0x6e38 in expand_macro (sym=0x2b600) at macro.c:242 -#2 0x6840 in expand_token (obs=0x0, t=177664, td=0xf7fffb08) - at macro.c:71 -(More stack frames follow...) -@end group -@end smallexample - -@noindent -The display for frame zero doesn't begin with a program counter -value, indicating that the program has stopped at the beginning of the -code for line @code{993} of @code{builtin.c}. - -@node Selection, Frame Info, Backtrace, Stack -@section Selecting a Frame - -Most commands for examining the stack and other data in the program work on -whichever stack frame is selected at the moment. Here are the commands for -selecting a stack frame; all of them finish by printing a brief description -of the stack frame just selected. - -@table @code -@item frame @var{n} -@itemx f @var{n} -@kindex frame -@kindex f -Select frame number @var{n}. Recall that frame zero is the innermost -(currently executing) frame, frame one is the frame that called the -innermost one, and so on. The highest-numbered frame is @code{main}'s -frame. - -@item frame @var{addr} -@itemx f @var{addr} -Select the frame at address @var{addr}. This is useful mainly if the -chaining of stack frames has been damaged by a bug, making it -impossible for _GDBN__ to assign numbers properly to all frames. In -addition, this can be useful when the program has multiple stacks and -switches between them. - -_if__(_SPARC__) -On the SPARC architecture, @code{frame} needs two addresses to -select an arbitrary frame: a frame pointer and a stack pointer. -@c note to future updaters: this is conditioned on a flag -@c FRAME_SPECIFICATION_DYADIC in the tm-*.h files, currently only used -@c by SPARC, hence the specific attribution. Generalize or list all -@c possibilities if more supported machines start doing this. -_fi__(_SPARC__) - -@item up @var{n} -@kindex up -Move @var{n} frames up the stack. For positive numbers @var{n}, this -advances toward the outermost frame, to higher frame numbers, to frames -that have existed longer. @var{n} defaults to one. - -@item down @var{n} -@kindex down -@kindex do -Move @var{n} frames down the stack. For positive numbers @var{n}, this -advances toward the innermost frame, to lower frame numbers, to frames -that were created more recently. @var{n} defaults to one. You may -abbreviate @code{down} as @code{do}. -@end table - -All of these commands end by printing two lines of output describing the -frame. The first line shows the frame number, the function name, the -arguments, and the source file and line number of execution in that -frame. The second line shows the text of that source line. For -example: - -@smallexample -(_GDBP__) up -#1 0x22f0 in main (argc=1, argv=0xf7fffbf4, env=0xf7fffbfc) - at env.c:10 -10 read_input_file (argv[i]); -@end smallexample - -After such a printout, the @code{list} command with no arguments will print -ten lines centered on the point of execution in the frame. @xref{List}. - -@table @code -@item up-silently @var{n} -@itemx down-silently @var{n} -@kindex down-silently -@kindex up-silently -These two commands are variants of @code{up} and @code{down}, -respectively; they differ in that they do their work silently, without -causing display of the new frame. They are intended primarily for use -in _GDBN__ command scripts, where the output might be unnecessary and -distracting. - -@end table - -@node Frame Info, , Selection, Stack -@section Information About a Frame - -There are several other commands to print information about the selected -stack frame. - -@table @code -@item frame -@itemx f -When used without any argument, this command does not change which frame -is selected, but prints a brief description of the currently -selected stack frame. It can be abbreviated @code{f}. With an -argument, this command is used to select a stack frame (@pxref{Selection}). - -@item info frame -@kindex info frame -@itemx info f -@kindex info f -This command prints a verbose description of the selected stack frame, -including the address of the frame, the addresses of the next frame down -(called by this frame) and the next frame up (caller of this frame), the -language that the source code corresponding to this frame was written in, -the address of the frame's arguments, the program counter saved in it -(the address of execution in the caller frame), and which registers -were saved in the frame. The verbose description is useful when -something has gone wrong that has made the stack format fail to fit -the usual conventions. - -@item info frame @var{addr} -@itemx info f @var{addr} -Print a verbose description of the frame at address @var{addr}, -without selecting that frame. The selected frame remains unchanged by -this command. - -@item info args -@kindex info args -Print the arguments of the selected frame, each on a separate line. - -@item info locals -@kindex info locals -Print the local variables of the selected frame, each on a separate -line. These are all variables declared static or automatic within all -program blocks that execution in this frame is currently inside of. - -@item info catch -@kindex info catch -@cindex catch exceptions -@cindex exception handlers -Print a list of all the exception handlers that are active in the -current stack frame at the current point of execution. To see other -exception handlers, visit the associated frame (using the @code{up}, -@code{down}, or @code{frame} commands); then type @code{info catch}. -@xref{Exception Handling}. -@end table - -@node Source, Data, Stack, Top -@chapter Examining Source Files - -_GDBN__ can print parts of your program's source, since the debugging -information recorded in your program tells _GDBN__ what source files -were used to built it. When your program stops, _GDBN__ spontaneously -prints the line where it stopped. Likewise, when you select a stack -frame (@pxref{Selection}), _GDBN__ prints the line where execution in -that frame has stopped. You can print other portions of source files by -explicit command. - -If you use _GDBN__ through its GNU Emacs interface, you may prefer to -use Emacs facilities to view source; @pxref{Emacs}. - -@menu -* List:: Printing Source Lines -* Search:: Searching Source Files -* Source Path:: Specifying Source Directories -* Machine Code:: Source and Machine Code -@end menu - -@node List, Search, Source, Source -@section Printing Source Lines - -@kindex list -@kindex l -To print lines from a source file, use the @code{list} command -(abbreviated @code{l}). There are several ways to specify what part -of the file you want to print. - -Here are the forms of the @code{list} command most commonly used: - -@table @code -@item list @var{linenum} -Print lines centered around line number @var{linenum} in the -current source file. - -@item list @var{function} -Print lines centered around the beginning of function -@var{function}. - -@item list -Print more lines. If the last lines printed were printed with a -@code{list} command, this prints lines following the last lines -printed; however, if the last line printed was a solitary line printed -as part of displaying a stack frame (@pxref{Stack}), this prints -lines centered around that line. - -@item list - -Print lines just before the lines last printed. -@end table - -By default, _GDBN__ prints ten source lines with any of these forms of -the @code{list} command. You can change this using @code{set listsize}: - -@table @code -@item set listsize @var{count} -@kindex set listsize -Make the @code{list} command display @var{count} source lines (unless -the @code{list} argument explicitly specifies some other number). - -@item show listsize -@kindex show listsize -Display the number of lines that @code{list} will currently display by -default. -@end table - -Repeating a @code{list} command with @key{RET} discards the argument, -so it is equivalent to typing just @code{list}. This is more useful -than listing the same lines again. An exception is made for an -argument of @samp{-}; that argument is preserved in repetition so that -each repetition moves up in the source file. - -@cindex linespec -In general, the @code{list} command expects you to supply zero, one or two -@dfn{linespecs}. Linespecs specify source lines; there are several ways -of writing them but the effect is always to specify some source line. -Here is a complete description of the possible arguments for @code{list}: - -@table @code -@item list @var{linespec} -Print lines centered around the line specified by @var{linespec}. - -@item list @var{first},@var{last} -Print lines from @var{first} to @var{last}. Both arguments are -linespecs. - -@item list ,@var{last} -Print lines ending with @var{last}. - -@item list @var{first}, -Print lines starting with @var{first}. - -@item list + -Print lines just after the lines last printed. - -@item list - -Print lines just before the lines last printed. - -@item list -As described in the preceding table. -@end table - -Here are the ways of specifying a single source line---all the -kinds of linespec. - -@table @code -@item @var{number} -Specifies line @var{number} of the current source file. -When a @code{list} command has two linespecs, this refers to -the same source file as the first linespec. - -@item +@var{offset} -Specifies the line @var{offset} lines after the last line printed. -When used as the second linespec in a @code{list} command that has -two, this specifies the line @var{offset} lines down from the -first linespec. - -@item -@var{offset} -Specifies the line @var{offset} lines before the last line printed. - -@item @var{filename}:@var{number} -Specifies line @var{number} in the source file @var{filename}. - -@item @var{function} -@c FIXME: "of the open-brace" is C-centric. When we add other langs... -Specifies the line of the open-brace that begins the body of the -function @var{function}. - -@item @var{filename}:@var{function} -Specifies the line of the open-brace that begins the body of the -function @var{function} in the file @var{filename}. You only need the -file name with a function name to avoid ambiguity when there are -identically named functions in different source files. - -@item *@var{address} -Specifies the line containing the program address @var{address}. -@var{address} may be any expression. -@end table - -@node Search, Source Path, List, Source -@section Searching Source Files -@cindex searching -@kindex reverse-search - -There are two commands for searching through the current source file for a -regular expression. - -@table @code -@item forward-search @var{regexp} -@itemx search @var{regexp} -@kindex search -@kindex forward-search -The command @samp{forward-search @var{regexp}} checks each line, starting -with the one following the last line listed, for a match for @var{regexp}. -It lists the line that is found. You can abbreviate the command name -as @code{fo}. The synonym @samp{search @var{regexp}} is also supported. - -@item reverse-search @var{regexp} -The command @samp{reverse-search @var{regexp}} checks each line, starting -with the one before the last line listed and going backward, for a match -for @var{regexp}. It lists the line that is found. You can abbreviate -this command as @code{rev}. -@end table - -@node Source Path, Machine Code, Search, Source -@section Specifying Source Directories - -@cindex source path -@cindex directories for source files -Executable programs sometimes do not record the directories of the source -files from which they were compiled, just the names. Even when they do, -the directories could be moved between the compilation and your debugging -session. _GDBN__ has a list of directories to search for source files; -this is called the @dfn{source path}. Each time _GDBN__ wants a source file, -it tries all the directories in the list, in the order they are present -in the list, until it finds a file with the desired name. Note that -the executable search path is @emph{not} used for this purpose. Neither is -the current working directory, unless it happens to be in the source -path. - -If _GDBN__ can't find a source file in the source path, and the object -program records a directory, _GDBN__ tries that directory too. If the -source path is empty, and there is no record of the compilation -directory, _GDBN__ will, as a last resort, look in the current -directory. - -Whenever you reset or rearrange the source path, _GDBN__ will clear out -any information it has cached about where source files are found, where -each line is in the file, etc. - -@kindex directory -When you start _GDBN__, its source path is empty. -To add other directories, use the @code{directory} command. - -@table @code -@item directory @var{dirname} @dots{} -Add directory @var{dirname} to the front of the source path. Several -directory names may be given to this command, separated by @samp{:} or -whitespace. You may specify a directory that is already in the source -path; this moves it forward, so it will be searched sooner. - -You can use the string @samp{$cdir} to refer to the compilation -directory (if one is recorded), and @samp{$cwd} to refer to the current -working directory. @samp{$cwd} is not the same as @samp{.}---the former -tracks the current working directory as it changes during your _GDBN__ -session, while the latter is immediately expanded to the current -directory at the time you add an entry to the source path. - -@item directory -Reset the source path to empty again. This requires confirmation. - -@c RET-repeat for @code{directory} is explicitly disabled, but since -@c repeating it would be a no-op we don't say that. (thanks to RMS) - -@item show directories -@kindex show directories -Print the source path: show which directories it contains. -@end table - -If your source path is cluttered with directories that are no longer of -interest, _GDBN__ may sometimes cause confusion by finding the wrong -versions of source. You can correct the situation as follows: - -@enumerate -@item -Use @code{directory} with no argument to reset the source path to empty. - -@item -Use @code{directory} with suitable arguments to reinstall the -directories you want in the source path. You can add all the -directories in one command. -@end enumerate - -@node Machine Code, , Source Path, Source -@section Source and Machine Code -You can use the command @code{info line} to map source lines to program -addresses (and viceversa), and the command @code{disassemble} to display -a range of addresses as machine instructions. - -@table @code -@item info line @var{linespec} -@kindex info line -Print the starting and ending addresses of the compiled code for -source line @var{linespec}. You can specify source lines in any of the -ways understood by the @code{list} command (@pxref{List}). -@end table - -For example, we can use @code{info line} to inquire on where the object -code for the first line of function @code{m4_changequote} lies: -@smallexample -(_GDBP__) info line m4_changecom -Line 895 of "builtin.c" starts at pc 0x634c and ends at 0x6350. -@end smallexample - -@noindent -We can also inquire (using @code{*@var{addr}} as the form for -@var{linespec}) what source line covers a particular address: -@smallexample -(_GDBP__) info line *0x63ff -Line 926 of "builtin.c" starts at pc 0x63e4 and ends at 0x6404. -@end smallexample - -@cindex @code{$_} and @code{info line} -After @code{info line}, the default address for the @code{x} -command is changed to the starting address of the line, so that -@samp{x/i} is sufficient to begin examining the machine code -(@pxref{Memory}). Also, this address is saved as the value of the -convenience variable @code{$_} (@pxref{Convenience Vars}). - -@table @code -@kindex disassemble -@item disassemble -This specialized command is provided to dump a range of memory as -machine instructions. The default memory range is the function -surrounding the program counter of the selected frame. A single -argument to this command is a program counter value; the function -surrounding this value will be dumped. Two arguments (separated by one -or more spaces) specify a range of addresses (first inclusive, second -exclusive) to be dumped. -@end table - -We can use @code{disassemble} to inspect the object code -range shown in the last @code{info line} example: - -@smallexample -(_GDBP__) disas 0x63e4 0x6404 -Dump of assembler code from 0x63e4 to 0x6404: -0x63e4 : ble 0x63f8 -0x63e8 : sethi %hi(0x4c00), %o0 -0x63ec : ld [%i1+4], %o0 -0x63f0 : b 0x63fc -0x63f4 : ld [%o0+4], %o0 -0x63f8 : or %o0, 0x1a4, %o0 -0x63fc : call 0x9288 -0x6400 : nop -End of assembler dump. -(_GDBP__) - -@end smallexample - -@node Data, Languages, Source, Top -@chapter Examining Data - -@cindex printing data -@cindex examining data -@kindex print -@kindex inspect -@c "inspect" isn't quite a synonym if you're using Epoch, which we don't -@c document because it's nonstandard... Under Epoch it displays in a -@c different window or something like that. -The usual way to examine data in your program is with the @code{print} -command (abbreviated @code{p}), or its synonym @code{inspect}. It -evaluates and prints the value of an expression of the language your -program is written in (@pxref{Languages}). - -@table @code -@item print @var{exp} -@itemx print /@var{f} @var{exp} -@var{exp} is an expression (in the source language). By default -the value of @var{exp} is printed in a format appropriate to its data -type; you can choose a different format by specifying @samp{/@var{f}}, -where @var{f} is a letter specifying the format; @pxref{Output formats}. - -@item print -@itemx print /@var{f} -If you omit @var{exp}, _GDBN__ displays the last value again (from the -@dfn{value history}; @pxref{Value History}). This allows you to -conveniently inspect the same value in an alternative format. -@end table - -A more low-level way of examining data is with the @code{x} command. -It examines data in memory at a specified address and prints it in a -specified format. @xref{Memory}. - -If you're interested in information about types, or about how the fields -of a struct or class are declared, use the @code{ptype @var{exp}} -command rather than @code{print}. @xref{Symbols}. - -@menu -* Expressions:: Expressions -* Variables:: Program Variables -* Arrays:: Artificial Arrays -* Output formats:: Output formats -* Memory:: Examining Memory -* Auto Display:: Automatic Display -* Print Settings:: Print Settings -* Value History:: Value History -* Convenience Vars:: Convenience Variables -* Registers:: Registers -* Floating Point Hardware:: Floating Point Hardware -@end menu - -@node Expressions, Variables, Data, Data -@section Expressions - -@cindex expressions -@code{print} and many other _GDBN__ commands accept an expression and -compute its value. Any kind of constant, variable or operator defined -by the programming language you are using is legal in an expression in -_GDBN__. This includes conditional expressions, function calls, casts -and string constants. It unfortunately does not include symbols defined -by preprocessor @code{#define} commands. - -Because C is so widespread, most of the expressions shown in examples in -this manual are in C. @xref{Languages,, Using _GDBN__ with Different -Languages}, for information on how to use expressions in other -languages. - -In this section, we discuss operators that you can use in _GDBN__ -expressions regardless of your programming language. - -Casts are supported in all languages, not just in C, because it is so -useful to cast a number into a pointer so as to examine a structure -at that address in memory. -@c FIXME: casts supported---Mod2 true? - -_GDBN__ supports these operators in addition to those of programming -languages: - -@table @code -@item @@ -@samp{@@} is a binary operator for treating parts of memory as arrays. -@xref{Arrays}, for more information. - -@item :: -@samp{::} allows you to specify a variable in terms of the file or -function where it is defined. @xref{Variables}. - -@item @{@var{type}@} @var{addr} -Refers to an object of type @var{type} stored at address @var{addr} in -memory. @var{addr} may be any expression whose value is an integer or -pointer (but parentheses are required around binary operators, just as in -a cast). This construct is allowed regardless of what kind of data is -normally supposed to reside at @var{addr}.@refill -@end table - -@node Variables, Arrays, Expressions, Data -@section Program Variables - -The most common kind of expression to use is the name of a variable -in your program. - -Variables in expressions are understood in the selected stack frame -(@pxref{Selection}); they must either be global (or static) or be visible -according to the scope rules of the programming language from the point of -execution in that frame. This means that in the function - -@example -foo (a) - int a; -@{ - bar (a); - @{ - int b = test (); - bar (b); - @} -@} -@end example - -@noindent -the variable @code{a} is usable whenever the program is executing -within the function @code{foo}, but the variable @code{b} is visible -only while the program is executing inside the block in which @code{b} -is declared. - -@cindex variable name conflict -There is an exception: you can refer to a variable or function whose -scope is a single source file even if the current execution point is not -in this file. But it is possible to have more than one such variable or -function with the same name (in different source files). If that happens, -referring to that name has unpredictable effects. If you wish, you can -specify a variable in a particular file, using the colon-colon notation: - -@cindex colon-colon -@kindex :: -@example -@var{file}::@var{variable} -@end example - -@noindent -Here @var{file} is the name of the source file whose variable you want. - -@cindex C++ scope resolution -This use of @samp{::} is very rarely in conflict with the very similar -use of the same notation in C++. _GDBN__ also supports use of the C++ -scope resolution operator in _GDBN__ expressions. - -@cindex wrong values -@cindex variable values, wrong -@quotation -@emph{Warning:} Occasionally, a local variable may appear to have the -wrong value at certain points in a function---just after entry to the -function, and just before exit. You may see this problem when you're -stepping by machine instructions. This is because on most machines, it -takes more than one instruction to set up a stack frame (including local -variable definitions); if you're stepping by machine instructions, -variables may appear to have the wrong values until the stack frame is -completely built. On function exit, it usually also takes more than one -machine instruction to destroy a stack frame; after you begin stepping -through that group of instructions, local variable definitions may be -gone. -@end quotation - -@node Arrays, Output formats, Variables, Data -@section Artificial Arrays - -@cindex artificial array -@kindex @@ -It is often useful to print out several successive objects of the -same type in memory; a section of an array, or an array of -dynamically determined size for which only a pointer exists in the -program. - -This can be done by constructing an @dfn{artificial array} with the -binary operator @samp{@@}. The left operand of @samp{@@} should be -the first element of the desired array, as an individual object. -The right operand should be the desired length of the array. The result is -an array value whose elements are all of the type of the left argument. -The first element is actually the left argument; the second element -comes from bytes of memory immediately following those that hold the -first element, and so on. Here is an example. If a program says - -@example -int *array = (int *) malloc (len * sizeof (int)); -@end example - -@noindent -you can print the contents of @code{array} with - -@example -p *array@@len -@end example - -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 -subscripting, and are coerced to pointers when used in expressions. -Artificial arrays most often appear in expressions via the value history -(@pxref{Value History}), after printing one out.) - -Sometimes the artificial array mechanism isn't quite enough; in -moderately complex data structures, the elements of interest may not -actually be adjacent---for example, if you're interested in the values -of pointers in an array. One useful work-around in this situation is to -use a convenience variable (@pxref{Convenience Vars}) as a counter in an -expression that prints the first interesting value, and then repeat that -expression via @key{RET}. For instance, suppose you have an array -@code{dtab} of pointers to structures, and you're interested in the -values of a field @code{fv} in each structure. Here's an example of -what you might type: -@example -set $i = 0 -p dtab[$i++]->fv -@key{RET} -@key{RET} -@dots{} -@end example - -@node Output formats, Memory, Arrays, Data -@section Output formats - -@cindex formatted output -@cindex output formats -By default, _GDBN__ prints a value according to its data type. Sometimes -this is not what you want. For example, you might want to print a number -in hex, or a pointer in decimal. Or you might want to view data in memory -at a certain address as a character string or as an instruction. To do -these things, specify an @dfn{output format} when you print a value. - -The simplest use of output formats is to say how to print a value -already computed. This is done by starting the arguments of the -@code{print} command with a slash and a format letter. The format -letters supported are: - -@table @code -@item x -Regard the bits of the value as an integer, and print the integer in -hexadecimal. - -@item d -Print as integer in signed decimal. - -@item u -Print as integer in unsigned decimal. - -@item o -Print as integer in octal. - -@item t -Print as integer in binary. The letter @samp{t} stands for ``two''. - -@item a -Print as an address, both absolute in hex and as an offset from the -nearest preceding symbol. This format can be used to discover where (in -what function) an unknown address is located: -@example -(_GDBP__) p/a 0x54320 -_0__$3 = 0x54320 <_initialize_vx+396>_1__ -@end example - - -@item c -Regard as an integer and print it as a character constant. - -@item f -Regard the bits of the value as a floating point number and print -using typical floating point syntax. -@end table - -For example, to print the program counter in hex (@pxref{Registers}), type - -@example -p/x $pc -@end example - -@noindent -Note that no space is required before the slash; this is because command -names in _GDBN__ cannot contain a slash. - -To reprint the last value in the value history with a different format, -you can use the @code{print} command with just a format and no -expression. For example, @samp{p/x} reprints the last value in hex. - -@node Memory, Auto Display, Output formats, Data -@section Examining Memory - -@cindex examining memory -@table @code -@kindex x -@item x/@var{nfu} @var{addr} -@itemx x @var{addr} -@itemx x -You can use the command @code{x} (for `examine') to examine memory in -any of several formats, independently of your program's data types. -@var{n}, @var{f}, and @var{u} are all optional parameters to specify how -much memory to display, and how to format it; @var{addr} is an -expression giving the address where you want to start displaying memory. -If you use defaults for @var{nfu}, you need not type the slash @samp{/}. -Several commands set convenient defaults for @var{addr}. -@end table - -@var{n}, the repeat count, is a decimal integer; the default is 1. It -specifies how much memory (counting by units @var{u}) to display. -@c This really is **decimal**; unaffected by 'set radix' as of GDB -@c 4.1.2. - -@var{f}, the display format, is one of the formats used by @code{print}, -or @samp{s} (null-terminated string) or @samp{i} (machine instruction). -The default is @samp{x} (hexadecimal) initially, or the format from the -last time you used either @code{x} or @code{print}. - -@var{u}, the unit size, is any of -@table @code -@item b -Bytes. -@item h -Halfwords (two bytes). -@item w -Words (four bytes). This is the initial default. -@item g -Giant words (eight bytes). -@end table - -@noindent -Each time you specify a unit size with @code{x}, that size becomes the -default unit the next time you use @code{x}. (For the @samp{s} and -@samp{i} formats, the unit size is ignored and is normally not written.) - -@var{addr} is the address where you want _GDBN__ to begin displaying -memory. The expression need not have a pointer value (though it may); -it is always interpreted as an integer address of a byte of memory. -@xref{Expressions} for more information on expressions. The default for -@var{addr} is usually just after the last address examined---but several -other commands also set the default address: @code{info breakpoints} (to -the address of the last breakpoint listed), @code{info line} (to the -starting address of a line), and @code{print} (if you use it to display -a value from memory). - -For example, @samp{x/3uh 0x54320} is a request to display three halfwords -(@code{h}) of memory, formatted as unsigned decimal integers (@samp{u}), -starting at address @code{0x54320}. @samp{x/4xw $sp} prints the four -words (@samp{w}) of memory above the stack pointer (here, @samp{$sp}; -@pxref{Registers}) in hexadecimal (@samp{x}). - -Since the letters indicating unit sizes are all distinct from the -letters specifying output formats, you don't have to remember whether -unit size or format comes first; either order will work. The output -specifications @samp{4xw} and @samp{4wx} mean exactly the same thing. -(However, the count @var{n} must come first; @samp{wx4} will not work.) - -Even though the unit size @var{u} is ignored for the formats @samp{s} -and @samp{i}, you might still want to use a count @var{n}; for example, -@samp{3i} specifies that you want to see three machine instructions, -including any operands. The command @code{disassemble} gives an -alternative way of inspecting machine instructions; @pxref{Machine -Code}. - -All the defaults for the arguments to @code{x} are designed to make it -easy to continue scanning memory with minimal specifications each time -you use @code{x}. For example, after you've inspected three machine -instructions with @samp{x/3i @var{addr}}, you can inspect the next seven -with just @samp{x/7}. If you use @key{RET} to repeat the @code{x} command, -the repeat count @var{n} is used again; the other arguments default as -for successive uses of @code{x}. - -@cindex @code{$_}, @code{$__}, and value history -The addresses and contents printed by the @code{x} command are not saved -in the value history because there is often too much of them and they -would get in the way. Instead, _GDBN__ makes these values available for -subsequent use in expressions as values of the convenience variables -@code{$_} and @code{$__}. After an @code{x} command, the last address -examined is available for use in expressions in the convenience variable -@code{$_}. The contents of that address, as examined, are available in -the convenience variable @code{$__}. - -If the @code{x} command has a repeat count, the address and contents saved -are from the last memory unit printed; this is not the same as the last -address printed if several units were printed on the last line of output. - -@node Auto Display, Print Settings, Memory, Data -@section Automatic Display -@cindex automatic display -@cindex display of expressions - -If you find that you want to print the value of an expression frequently -(to see how it changes), you might want to add it to the @dfn{automatic -display list} so that _GDBN__ will print its value each time the program stops. -Each expression added to the list is given a number to identify it; -to remove an expression from the list, you specify that number. -The automatic display looks like this: - -@example -2: foo = 38 -3: bar[5] = (struct hack *) 0x3804 -@end example - -@noindent -showing item numbers, expressions and their current values. As with -displays you request manually using @code{x} or @code{print}, you can -specify the output format you prefer; in fact, @code{display} decides -whether to use @code{print} or @code{x} depending on how elaborate your -format specification is---it uses @code{x} if you specify a unit size, -or one of the two formats (@samp{i} and @samp{s}) that are only -supported by @code{x}; otherwise it uses @code{print}. - -@table @code -@item display @var{exp} -@kindex display -Add the expression @var{exp} to the list of expressions to display -each time the program stops. @xref{Expressions}. - -@code{display} will not repeat if you press @key{RET} again after using it. - -@item display/@var{fmt} @var{exp} -For @var{fmt} specifying only a display format and not a size or -count, add the expression @var{exp} to the auto-display list but -arranges to display it each time in the specified format @var{fmt}. -@xref{Output formats}. - -@item display/@var{fmt} @var{addr} -For @var{fmt} @samp{i} or @samp{s}, or including a unit-size or a -number of units, add the expression @var{addr} as a memory address to -be examined each time the program stops. Examining means in effect -doing @samp{x/@var{fmt} @var{addr}}. @xref{Memory}. -@end table - -For example, @samp{display/i $pc} can be helpful, to see the machine -instruction about to be executed each time execution stops (@samp{$pc} -is a common name for the program counter; @pxref{Registers}). - -@table @code -@item undisplay @var{dnums}@dots{} -@itemx delete display @var{dnums}@dots{} -@kindex delete display -@kindex undisplay -Remove item numbers @var{dnums} from the list of expressions to display. - -@code{undisplay} will not repeat if you press @key{RET} after using it. -(Otherwise you would just get the error @samp{No display number @dots{}}.) - -@item disable display @var{dnums}@dots{} -@kindex disable display -Disable the display of item numbers @var{dnums}. A disabled display -item is not printed automatically, but is not forgotten. It may be -enabled again later. - -@item enable display @var{dnums}@dots{} -@kindex enable display -Enable display of item numbers @var{dnums}. It becomes effective once -again in auto display of its expression, until you specify otherwise. - -@item display -Display the current values of the expressions on the list, just as is -done when the program stops. - -@item info display -@kindex info display -Print the list of expressions previously set up to display -automatically, each one with its item number, but without showing the -values. This includes disabled expressions, which are marked as such. -It also includes expressions which would not be displayed right now -because they refer to automatic variables not currently available. -@end table - -If a display expression refers to local variables, then it does not make -sense outside the lexical context for which it was set up. Such an -expression is disabled when execution enters a context where one of its -variables is not defined. For example, if you give the command -@code{display last_char} while inside a function with an argument -@code{last_char}, then this argument will be displayed while the program -continues to stop inside that function. When it stops elsewhere---where -there is no variable @code{last_char}---display is disabled. The next time -your program stops where @code{last_char} is meaningful, you can enable the -display expression once again. - -@node Print Settings, Value History, Auto Display, Data -@section Print Settings - -@cindex format options -@cindex print settings -_GDBN__ provides the following ways to control how arrays, structures, -and symbols are printed. - -@noindent -These settings are useful for debugging programs in any language: - -@table @code -@item set print address -@item set print address on -@kindex set print address -_GDBN__ will print memory addresses showing the location of stack -traces, structure values, pointer values, breakpoints, and so forth, -even when it also displays the contents of those addresses. The default -is on. For example, this is what a stack frame display looks like, with -@code{set print address on}: -@smallexample -(_GDBP__) f -#0 set_quotes (lq=0x34c78 "<<", rq=0x34c88 ">>") - at input.c:530 -530 if (lquote != def_lquote) -@end smallexample - -@item set print address off -Do not print addresses when displaying their contents. For example, -this is the same stack frame displayed with @code{set print address off}: -@example -(_GDBP__) set print addr off -(_GDBP__) f -#0 set_quotes (lq="<<", rq=">>") at input.c:530 -530 if (lquote != def_lquote) -@end example - -@item show print address -@kindex show print address -Show whether or not addresses are to be printed. - -@item set print array -@itemx set print array on -@kindex set print array -_GDBN__ will pretty print arrays. This format is more convenient to read, -but uses more space. The default is off. - -@item set print array off. -Return to compressed format for arrays. - -@item show print array -@kindex show print array -Show whether compressed or pretty format is selected for displaying -arrays. - -@item set print elements @var{number-of-elements} -@kindex set print elements -If _GDBN__ is printing a large array, it will stop printing after it has -printed the number of elements set by the @code{set print elements} command. -This limit also applies to the display of strings. - -@item show print elements -@kindex show print elements -Display the number of elements of a large array that _GDBN__ will print -before losing patience. - -@item set print pretty on -@kindex set print pretty -Cause _GDBN__ to print structures in an indented format with one member per -line, like this: - -@example -$1 = @{ - next = 0x0, - flags = @{ - sweet = 1, - sour = 1 - @}, - meat = 0x54 "Pork" -@} -@end example - -@item set print pretty off -Cause _GDBN__ to print structures in a compact format, like this: - -@smallexample -$1 = @{next = 0x0, flags = @{sweet = 1, sour = 1@}, meat \ -= 0x54 "Pork"@} -@end smallexample - -@noindent -This is the default format. - -@item show print pretty -@kindex show print pretty -Show which format _GDBN__ will use to print structures. - -@item set print sevenbit-strings on -@kindex set print sevenbit-strings -Print using only seven-bit characters; if this option is set, -_GDBN__ will display any eight-bit characters (in strings or character -values) using the notation @code{\}@var{nnn}. For example, @kbd{M-a} is -displayed as @code{\341}. - -@item set print sevenbit-strings off -Print using either seven-bit or eight-bit characters, as required. This -is the default. - -@item show print sevenbit-strings -@kindex show print sevenbit-strings -Show whether or not _GDBN__ will print only seven-bit characters. - -@item set print union on -@kindex set print union -Tell _GDBN__ to print unions which are contained in structures. This is the -default setting. - -@item set print union off -Tell _GDBN__ not to print unions which are contained in structures. - -@item show print union -@kindex show print union -Ask _GDBN__ whether or not it will print unions which are contained in -structures. - -For example, given the declarations - -@smallexample -typedef enum @{Tree, Bug@} Species; -typedef enum @{Big_tree, Acorn, Seedling@} Tree_forms; -typedef enum @{Caterpillar, Cocoon, Butterfly@} - Bug_forms; - -struct thing @{ - Species it; - union @{ - Tree_forms tree; - Bug_forms bug; - @} form; -@}; - -struct thing foo = @{Tree, @{Acorn@}@}; -@end smallexample - -@noindent -with @code{set print union on} in effect @samp{p foo} would print - -@smallexample -$1 = @{it = Tree, form = @{tree = Acorn, bug = Cocoon@}@} -@end smallexample - -@noindent -and with @code{set print union off} in effect it would print - -@smallexample -$1 = @{it = Tree, form = @{...@}@} -@end smallexample -@end table - -@noindent -These settings are of interest when debugging C++ programs: - -@table @code -@item set print demangle -@itemx set print demangle on -@kindex set print demangle -Print C++ names in their source form rather than in the mangled form -in which they are passed to the assembler and linker for type-safe linkage. -The default is on. - -@item show print demangle -@kindex show print demangle -Show whether C++ names will be printed in mangled or demangled form. - -@item set print asm-demangle -@itemx set print asm-demangle on -@kindex set print asm-demangle -Print C++ names in their source form rather than their mangled form, even -in assembler code printouts such as instruction disassemblies. -The default is off. - -@item show print asm-demangle -@kindex show print asm-demangle -Show whether C++ names in assembly listings will be printed in mangled -or demangled form. - -@item set print object -@itemx set print object on -@kindex set print object -When displaying a pointer to an object, identify the @emph{actual} -(derived) type of the object rather than the @emph{declared} type, using -the virtual function table. - -@item set print object off -Display only the declared type of objects, without reference to the -virtual function table. This is the default setting. - -@item show print object -@kindex show print object -Show whether actual, or declared, object types will be displayed. - -@item set print vtbl -@itemx set print vtbl on -@kindex set print vtbl -Pretty print C++ virtual function tables. The default is off. - -@item set print vtbl off -Do not pretty print C++ virtual function tables. - -@item show print vtbl -@kindex show print vtbl -Show whether C++ virtual function tables are pretty printed, or not. - -@end table - -@node Value History, Convenience Vars, Print Settings, Data -@section Value History - -@cindex value history -Values printed by the @code{print} command are saved in _GDBN__'s @dfn{value -history} so that you can refer to them in other expressions. Values are -kept until the symbol table is re-read or discarded (for example with -the @code{file} or @code{symbol-file} commands). When the symbol table -changes, the value history is discarded, since the values may contain -pointers back to the types defined in the symbol table. - -@cindex @code{$} -@cindex @code{$$} -@cindex history number -The values printed are given @dfn{history numbers} for you to refer to them -by. These are successive integers starting with one. @code{print} shows you -the history number assigned to a value by printing @samp{$@var{num} = } -before the value; here @var{num} is the history number. - -To refer to any previous value, use @samp{$} followed by the value's -history number. The way @code{print} labels its output is designed to -remind you of this. Just @code{$} refers to the most recent value in -the history, and @code{$$} refers to the value before that. -@code{$$@var{n}} refers to the @var{n}th value from the end; @code{$$2} -is the value just prior to @code{$$}, @code{$$1} is equivalent to -@code{$$}, and @code{$$0} is equivalent to @code{$}. - -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 -p *$ -@end example - -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 -p *$.next -@end example - -@noindent -You can print successive links in the chain by repeating this -command---which you can do by just typing @key{RET}. - -Note that the history records values, not expressions. If the value of -@code{x} is 4 and you type these commands: - -@example -print x -set x=5 -@end example - -@noindent -then the value recorded in the value history by the @code{print} command -remains 4 even though the value of @code{x} has changed. - -@table @code -@kindex show values -@item show values -Print the last ten values in the value history, with their item numbers. -This is like @samp{p@ $$9} repeated ten times, except that @code{show -values} does not change the history. - -@item show values @var{n} -Print ten history values centered on history item number @var{n}. - -@item show values + -Print ten history values just after the values last printed. If no more -values are available, produces no display. -@end table - -Pressing @key{RET} to repeat @code{show values @var{n}} has exactly the -same effect as @samp{show values +}. - -@node Convenience Vars, Registers, Value History, Data -@section Convenience Variables - -@cindex convenience variables -_GDBN__ provides @dfn{convenience variables} that you can use within -_GDBN__ to hold on to a value and refer to it later. These variables -exist entirely within _GDBN__; they are not part of your program, and -setting a convenience variable has no direct effect on further execution -of your program. That's why you can use them freely. - -Convenience variables are prefixed with @samp{$}. Any name preceded by -@samp{$} can be used for a convenience variable, unless it is one of -the predefined machine-specific register names (@pxref{Registers}). -(Value history references, in contrast, are @emph{numbers} preceded -by @samp{$}. @xref{Value History}.) - -You can save a value in a convenience variable with an assignment -expression, just as you would set a variable in your program. Example: - -@example -set $foo = *object_ptr -@end example - -@noindent -would save in @code{$foo} the value contained in the object pointed to by -@code{object_ptr}. - -Using a convenience variable for the first time creates it; but its value -is @code{void} until you assign a new value. You can alter the value with -another assignment at any time. - -Convenience variables have no fixed types. You can assign a convenience -variable any type of value, including structures and arrays, even if -that variable already has a value of a different type. The convenience -variable, when used as an expression, has the type of its current value. - -@table @code -@item show convenience -@kindex show convenience -Print a list of convenience variables used so far, and their values. -Abbreviated @code{show con}. -@end table - -One of the ways to use a convenience variable is as a counter to be -incremented or a pointer to be advanced. For example, to print -a field from successive elements of an array of structures: - -_0__@example -set $i = 0 -print bar[$i++]->contents -@i{@dots{} repeat that command by typing @key{RET}.} -_1__@end example - -Some convenience variables are created automatically by _GDBN__ and given -values likely to be useful. - -@table @code -@item $_ -@kindex $_ -The variable @code{$_} is automatically set by the @code{x} command to -the last address examined (@pxref{Memory}). Other commands which -provide a default address for @code{x} to examine also set @code{$_} -to that address; these commands include @code{info line} and @code{info -breakpoint}. The type of @code{$_} is @code{void *} except when set by the -@code{x} command, in which case it is a pointer to the type of @code{$__}. - -@item $__ -@kindex $__ -The variable @code{$__} is automatically set by the @code{x} command -to the value found in the last address examined. Its type is chosen -to match the format in which the data was printed. -@end table - -@node Registers, Floating Point Hardware, Convenience Vars, Data -@section Registers - -@cindex registers -You can refer to machine register contents, in expressions, as variables -with names starting with @samp{$}. The names of registers are different -for each machine; use @code{info registers} to see the names used on -your machine. - -@table @code -@item info registers -@kindex info registers -Print the names and values of all registers except floating-point -registers (in the selected stack frame). - -@item info all-registers -@kindex info all-registers -@cindex floating point registers -Print the names and values of all registers, including floating-point -registers. - -@item info registers @var{regname} -Print the relativized value of register @var{regname}. @var{regname} -may be any register name valid on the machine you are using, with -or without the initial @samp{$}. -@end table - -_GDBN__ has four ``standard'' register names that are available (in -expressions) on most machines---whenever they don't conflict with an -architecture's canonical mnemonics for registers. The register names -@code{$pc} and @code{$sp} are used for the program counter register and -the stack pointer. @code{$fp} is used for a register that contains a -pointer to the current stack frame, and @code{$ps} is used for a -register that contains the processor status. For example, -you could print the program counter in hex with -@example -p/x $pc -@end example - -@noindent -or print the instruction to be executed next with -@example -x/i $pc -@end example - -@noindent -or add four to the stack pointer @footnote{This is a way of removing one -word from the stack, on machines where stacks grow downward in memory -(most machines, nowadays). This assumes that the innermost stack frame -is selected; setting @code{$sp} is not allowed when other stack frames -are selected. To pop entire frames off the stack, regardless of -machine architecture, use @code{return}; @pxref{Returning}.} with -@example -set $sp += 4 -@end example - -Whenever possible, these four standard register names are available on -your machine even though the machine has different canonical mnemonics, -so long as there is no conflict. The @code{info registers} command -shows the canonical names. For example, on the SPARC, @code{info -registers} displays the processor status register as @code{$psr} but you -can also refer to it as @code{$ps}. - -_GDBN__ always considers the contents of an ordinary register as an -integer when the register is examined in this way. Some machines have -special registers which can hold nothing but floating point; these -registers are considered to have floating point values. There is no way -to refer to the contents of an ordinary register as floating point value -(although you can @emph{print} it as a floating point value with -@samp{print/f $@var{regname}}). - -Some registers have distinct ``raw'' and ``virtual'' data formats. This -means that the data format in which the register contents are saved by -the operating system is not the same one that your program normally -sees. For example, the registers of the 68881 floating point -coprocessor are always saved in ``extended'' (raw) format, but all C -programs expect to work with ``double'' (virtual) format. In such -cases, _GDBN__ normally works with the virtual format only (the format that -makes sense for your program), but the @code{info registers} command -prints the data in both formats. - -Normally, register values are relative to the selected stack frame -(@pxref{Selection}). This means that you get the value that the -register would contain if all stack frames farther in were exited and -their saved registers restored. In order to see the true contents of -hardware registers, you must select the innermost frame (with -@samp{frame 0}). - -However, _GDBN__ must deduce where registers are saved, from the machine -code generated by your compiler. If some registers are not saved, or if -_GDBN__ is unable to locate the saved registers, the selected stack -frame will make no difference. - -@node Floating Point Hardware, , Registers, Data -@section Floating Point Hardware -@cindex floating point -Depending on the host machine architecture, _GDBN__ may be able to give -you more information about the status of the floating point hardware. - -@table @code -@item info float -@kindex info float -If available, provides hardware-dependent information about the floating -point unit. The exact contents and layout vary depending on the -floating point chip. -@end table -@c FIXME: this is a cop-out. Try to get examples, explanations. Only -@c FIXME...supported currently on arm's and 386's. Mark properly with -@c FIXME... m4 macros to isolate general statements from hardware-dep, -@c FIXME... at that point. - -@node Languages, Symbols, Data, Top -@chapter Using _GDBN__ with Different Languages -@cindex languages - -Although programming languages generally have common aspects, they are -rarely expressed in the same manner. For instance, in ANSI C, -dereferencing a pointer @code{p} is accomplished by @code{*p}, but in -Modula-2, it is accomplished by @code{p^}. Values can also be -represented (and displayed) differently. Hex numbers in C are written -like @samp{0x1ae}, while in Modula-2 they appear as @samp{1AEH}. - -@cindex working language -Language-specific information is built into _GDBN__ for some languages, -allowing you to express operations like the above in the program's -native language, and allowing _GDBN__ to output values in a manner -consistent with the syntax of the program's native language. The -language you use to build expressions, called the @dfn{working -language}, can be selected manually, or _GDBN__ can set it -automatically. - -@menu -* Setting:: Switching between source languages -* Show:: Displaying the language -* Checks:: Type and Range checks -* Support:: Supported languages -@end menu - -@node Setting, Show, Languages, Languages -@section Switching between source languages - -There are two ways to control the working language---either have _GDBN__ -set it automatically, or select it manually yourself. You can use the -@code{set language} command for either purpose. On startup, _GDBN__ -defaults to setting the language automatically. - -@menu -* Manually:: Setting the working language manually -* Automatically:: Having _GDBN__ infer the source language -@end menu - -@node Manually, Automatically, Setting, Setting -@subsection Setting the working language - -@kindex set language -To set the language, issue the command @samp{set language @var{lang}}, -where @var{lang} is the name of a language: @code{c} or @code{modula-2}. -For a list of the supported languages, type @samp{set language}. - -Setting the language manually prevents _GDBN__ from updating the working -language automatically. This can lead to confusion if you try -to debug a program when the working language is not the same as the -source language, when an expression is acceptable to both -languages---but means different things. For instance, if the current -source file were written in C, and _GDBN__ was parsing Modula-2, a -command such as: - -@example -print a = b + c -@end example - -@noindent -might not have the effect you intended. In C, this means to add -@code{b} and @code{c} and place the result in @code{a}. The result -printed would be the value of @code{a}. In Modula-2, this means to compare -@code{a} to the result of @code{b+c}, yielding a @code{BOOLEAN} value. - -If you allow _GDBN__ to set the language automatically, then -you can count on expressions evaluating the same way in your debugging -session and in your program. - -@node Automatically, , Manually, Setting -@subsection Having _GDBN__ infer the source language - -To have _GDBN__ set the working language automatically, use @samp{set -language local} or @samp{set language auto}. _GDBN__ then infers the -language that a program was written in by looking at the name of its -source files, and examining their extensions: - -@table @file -@item *.mod -Modula-2 source file - -@item *.c -@itemx *.cc -C or C++ source file. -@end table - -This information is recorded for each function or procedure in a source -file. When your program stops in a frame (usually by encountering a -breakpoint), _GDBN__ sets the working language to the language recorded -for the function in that frame. If the language for a frame is unknown -(that is, if the function or block corresponding to the frame was -defined in a source file that does not have a recognized extension), the -current working language is not changed, and _GDBN__ issues a warning. - -This may not seem necessary for most programs, which are written -entirely in one source language. However, program modules and libraries -written in one source language can be used by a main program written in -a different source language. Using @samp{set language auto} in this -case frees you from having to set the working language manually. - -@node Show, Checks, Setting, Languages -@section Displaying the language - -The following commands will help you find out which language is the -working language, and also what language source files were written in. - -@kindex show language -@kindex info frame -@kindex info source -@table @code -@item show language -Display the current working language. This is the -language you can use with commands such as @code{print} to -build and compute expressions that may involve variables in the program. - -@item info frame -Among the other information listed here (@pxref{Frame Info,,Information -about a Frame}) is the source language for this frame. This is the -language that will become the working language if you ever use an -identifier that is in this frame. - -@item info source -Among the other information listed here (@pxref{Symbols,,Examining the -Symbol Table}) is the source language of this source file. - -@end table - -@node Checks, Support, Show, Languages -@section Type and range Checking - -@quotation -@emph{Warning:} In this release, the _GDBN__ commands for type and range -checking are included, but they do not yet have any effect. This -section documents the intended facilities. -@end quotation -@c FIXME remove warning when type/range code added - -Some languages are designed to guard you against making seemingly common -errors through a series of compile- and run-time checks. These include -checking the type of arguments to functions and operators, and making -sure mathematical overflows are caught at run time. Checks such as -these help to ensure a program's correctness once it has been compiled -by eliminating type mismatches, and providing active checks for range -errors when the program is running. - -_GDBN__ can check for conditions like the above if you wish. -Although _GDBN__ will not check the statements in your program, it -can check expressions entered directly into _GDBN__ for evaluation via -the @code{print} command, for example. As with the working language, -_GDBN__ can also decide whether or not to check automatically based on -the source language of the program being debugged. -@xref{Support,,Supported Languages}, for the default settings -of supported languages. - -@menu -* Type Checking:: An overview of type checking -* Range Checking:: An overview of range checking -@end menu - -@cindex type checking -@cindex checks, type -@node Type Checking, Range Checking, Checks, Checks -@subsection An overview of type checking - -Some languages, such as Modula-2, are strongly typed, meaning that the -arguments to operators and functions have to be of the correct type, -otherwise an error occurs. These checks prevent type mismatch -errors from ever causing any run-time problems. For example, - -@example -1 + 2 @result{} 3 -@error{} 1 + 2.3 -@end example - -The second example fails because the @code{CARDINAL} 1 is not -type-compatible with the @code{REAL} 2.3. - -For expressions you use in _GDBN__ commands, you can tell the _GDBN__ -type checker to skip checking; to treat any mismatches as errors and -abandon the expression; or only issue warnings when type mismatches -occur, but evaluate the expression anyway. When you choose the last of -these, _GDBN__ evaluates expressions like the second example above, but -also issues a warning. - -Even though you may turn type checking off, other type-based reasons may -prevent _GDBN__ from evaluating an expression. For instance, _GDBN__ does not -know how to add an @code{int} and a @code{struct foo}. These particular -type errors have nothing to do with the language in use, and usually -arise from expressions, such as the one described above, which make -little sense to evaluate anyway. - -Each language defines to what degree it is strict about type. For -instance, both Modula-2 and C require the arguments to arithmetical -operators to be numbers. In C, enumerated types and pointers can be -represented as numbers, so that they are valid arguments to mathematical -operators. @xref{Support,,Supported Languages}, for futher -details on specific languages. - -_GDBN__ provides some additional commands for controlling the type checker: - -@kindex set check -@kindex set check type -@kindex show check type -@table @code -@item set check type auto -Set type checking on or off based on the current working language. -@xref{Support,,Supported Languages}, for the default settings for -each language. - -@item set check type on -@itemx set check type off -Set type checking on or off, overriding the default setting for the -current working language. Issue a warning if the setting does not -match the language's default. If any type mismatches occur in -evaluating an expression while typechecking is on, _GDBN__ prints a -message and aborts evaluation of the expression. - -@item set check type warn -Cause the type checker to issue warnings, but to always attempt to -evaluate the expression. Evaluating the expression may still -be impossible for other reasons. For example, _GDBN__ cannot add -numbers and structures. - -@item show type -Show the current setting of the type checker, and whether or not _GDBN__ is -setting it automatically. -@end table - -@cindex range checking -@cindex checks, range -@node Range Checking, , Type Checking, Checks -@subsection An overview of Range Checking - -In some languages (such as Modula-2), it is an error to exceed the -bounds of a type; this is enforced with run-time checks. Such range -checking is meant to ensure program correctness by making sure -computations do not overflow, or indices on an array element access do -not exceed the bounds of the array. - -For expressions you use in _GDBN__ commands, you can tell _GDBN__ to -ignore range errors; to always treat them as errors and abandon the -expression; or to issue warnings when a range error occurs but evaluate -the expression anyway. - -A range error can result from numerical overflow, from exceeding an -array index bound, or when you type in a constant that is not a member -of any type. Some languages, however, do not treat overflows as an -error. In many implementations of C, mathematical overflow causes the -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 -@var{m} + 1 @result{} @var{s} -@end example - -This, too, is specific to individual languages, and in some cases -specific to individual compilers or machines. @xref{Support,, -Supported Languages}, for further details on specific languages. - -_GDBN__ provides some additional commands for controlling the range checker: - -@kindex set check -@kindex set check range -@kindex show check range -@table @code -@item set check range auto -Set range checking on or off based on the current working language. -@xref{Support,,Supported Languages}, for the default settings for -each language. - -@item set check range on -@itemx set check range off -Set range checking on or off, overriding the default setting for the -current working language. A warning is issued if the setting does not -match the language's default. If a range error occurs, then a message -is printed and evaluation of the expression is aborted. - -@item set check range warn -Output messages when the _GDBN__ range checker detects a range error, -but attempt to evaluate the expression anyway. Evaluating the -expression may still be impossible for other reasons, such as accessing -memory that the process does not own (a typical example from many UNIX -systems). - -@item show range -Show the current setting of the range checker, and whether or not it is -being set automatically by _GDBN__. -@end table - -@node Support, , Checks, Languages -@section Supported Languages - -_GDBN__ _GDB_VN__ supports C, C++, and Modula-2. The syntax for C and C++ is -so closely related that _GDBN__ does not distinguish the two. Some -_GDBN__ features may be used in expressions regardless of the language -you use: the _GDBN__ @code{@@} and @code{::} operators, and the -@samp{@{type@}addr} construct (@pxref{Expressions}) can be used with the constructs of -any of the supported languages. - -The following sections detail to what degree each of these -source languages is supported by _GDBN__. These sections are -not meant to be language tutorials or references, but serve only as a -reference guide to what the _GDBN__ expression parser will accept, and -what input and output formats should look like for different languages. -There are many good books written on each of these languages; please -look to these for a language reference or tutorial. - -@menu -* C:: C and C++ -* Modula-2:: Modula-2 -@end menu - -@node C, Modula-2, Support, Support -@subsection C and C++ -@cindex C and C++ - -@cindex expressions in C or C++ -Since C and C++ are so closely related, _GDBN__ does not distinguish -between them when interpreting the expressions recognized in _GDBN__ -commands. - -@cindex C++ -@kindex g++ -@cindex GNU C++ -The C++ debugging facilities are jointly implemented by the GNU C++ -compiler and _GDBN__. Therefore, to debug your C++ code effectively, -you must compile your C++ programs with the GNU C++ compiler, -@code{g++}. - - -@menu -* C Operators:: C and C++ Operators -* C Constants:: C and C++ Constants -* Cplusplus expressions:: C++ Expressions -* C Defaults:: Default settings for C and C++ -* C Checks:: C and C++ Type and Range Checks -* Debugging C:: _GDBN__ and C -* Debugging C plus plus:: Special features for C++ -@end menu - -@cindex C and C++ operators -@node C Operators, C Constants, C, C -@subsubsection C and C++ Operators - -Operators must be defined on values of specific types. For instance, -@code{+} is defined on numbers, but not on structures. Operators are -often defined on groups of types. For the purposes of C and C++, the -following definitions hold: - -@itemize @bullet -@item -@emph{Integral types} include @code{int} with any of its storage-class -specifiers, @code{char}, and @code{enum}s. - -@item -@emph{Floating-point types} include @code{float} and @code{double}. - -@item -@emph{Pointer types} include all types defined as @code{(@var{type} -*)}. - -@item -@emph{Scalar types} include all of the above. - -@end itemize - -@noindent -The following operators are supported. They are listed here -in order of increasing precedence: - -@table @code -_0__ -@item , -The comma or sequencing operator. Expressions in a comma-separated list -are evaluated from left to right, with the result of the entire -expression being the last expression evaluated. - -@item = -Assignment. The value of an assignment expression is the value -assigned. Defined on scalar types. - -@item @var{op}= -Used in an expression of the form @var{a} @var{op}@code{=} @var{b}, and -translated to @var{a} @code{=} @var{a op b}. @var{op}@code{=} and -@code{=} have the same precendence. @var{op} is any one of the -operators @code{|}, @code{^}, @code{&}, @code{<<}, @code{>>}, @code{+}, -@code{-}, @code{*}, @code{/}, @code{%}. - -@item ?: -The ternary operator. @code{@var{a} ? @var{b} : @var{c}} can be thought -of as: if @var{a} then @var{b} else @var{c}. @var{a} should be of an -integral type. - -@item || -Logical OR. Defined on integral types. - -@item && -Logical AND. Defined on integral types. - -@item | -Bitwise OR. Defined on integral types. - -@item ^ -Bitwise exclusive-OR. Defined on integral types. - -@item & -Bitwise AND. Defined on integral types. - -@item ==@r{, }!= -Equality and inequality. Defined on scalar types. The value of these -expressions is 0 for false and non-zero for true. - -@item <@r{, }>@r{, }<=@r{, }>= -Less than, greater than, less than or equal, greater than or equal. -Defined on scalar types. The value of these expressions is 0 for false -and non-zero for true. - -@item <<@r{, }>> -left shift, and right shift. Defined on integral types. - -@item @@ -The _GDBN__ ``artificial array'' operator (@pxref{Expressions}). - -@item +@r{, }- -Addition and subtraction. Defined on integral types, floating-point types and -pointer types. - -@item *@r{, }/@r{, }% -Multiplication, division, and modulus. Multiplication and division are -defined on integral and floating-point types. Modulus is defined on -integral types. - -@item ++@r{, }-- -Increment and decrement. When appearing before a variable, the -operation is performed before the variable is used in an expression; -when appearing after it, the variable's value is used before the -operation takes place. - -@item * -Pointer dereferencing. Defined on pointer types. Same precedence as -@code{++}. - -@item & -Address operator. Defined on variables. Same precedence as @code{++}. - -@item - -Negative. Defined on integral and floating-point types. Same -precedence as @code{++}. - -@item ! -Logical negation. Defined on integral types. Same precedence as -@code{++}. - -@item ~ -Bitwise complement operator. Defined on integral types. Same precedence as -@code{++}. - -@item .@r{, }-> -Structure member, and pointer-to-structure member. For convenience, -_GDBN__ regards the two as equivalent, choosing whether to dereference a -pointer based on the stored type information. -Defined on @code{struct}s and @code{union}s. - -@item [] -Array indexing. @code{@var{a}[@var{i}]} is defined as -@code{*(@var{a}+@var{i})}. Same precedence as @code{->}. - -@item () -Function parameter list. Same precedence as @code{->}. - -@item :: -C++ scope resolution operator. Defined on -@code{struct}, @code{union}, and @code{class} types. - -@item :: -The _GDBN__ scope operator (@pxref{Expressions}). Same precedence as -@code{::}, above. _1__ -@end table - -@cindex C and C++ constants -@node C Constants, Cplusplus expressions, C Operators, C -@subsubsection C and C++ Constants - -_GDBN__ allows you to express the constants of C and C++ in the -following ways: - -@itemize @bullet - -@item -Integer constants are a sequence of digits. Octal constants are -specified by a leading @samp{0} (ie. zero), and hexadecimal constants by -a leading @samp{0x} or @samp{0X}. Constants may also end with an -@samp{l}, specifying that the constant should be treated as a -@code{long} value. - -@item -Floating point constants are a sequence of digits, followed by a decimal -point, followed by a sequence of digits, and optionally followed by an -exponent. An exponent is of the form: -@samp{@w{e@r{[[}+@r{]|}-@r{]}@var{nnn}}}, where @var{nnn} is another -sequence of digits. The @samp{+} is optional for positive exponents. - -@item -Enumerated constants consist of enumerated identifiers, or their -integral equivalents. - -@item -Character constants are a single character surrounded by single quotes -(@code{'}), or a number---the ordinal value of the corresponding character -(usually its @sc{ASCII} value). Within quotes, the single character may -be represented by a letter or by @dfn{escape sequences}, which are of -the form @samp{\@var{nnn}}, where @var{nnn} is the octal representation -of the character's ordinal value; or of the form @samp{\@var{x}}, where -@samp{@var{x}} is a predefined special character---for example, -@samp{\n} for newline. - -@item -String constants are a sequence of character constants surrounded -by double quotes (@code{"}). - -@item -Pointer constants are an integral value. - -@end itemize - - -@node Cplusplus expressions, C Defaults, C Constants, C -@subsubsection C++ Expressions - -@cindex expressions in C++ -_GDBN__'s expression handling has the following extensions to -interpret a significant subset of C++ expressions: - -@enumerate - -@cindex member functions -@item -Member function calls are allowed; you can use expressions like -@example -count = aml->GetOriginal(x, y) -@end example - -@kindex this -@cindex namespace in C++ -@item -While a member function is active (in the selected stack frame), your -expressions have the same namespace available as the member function; -that is, _GDBN__ allows implicit references to the class instance -pointer @code{this} following the same rules as C++. - -@cindex call overloaded functions -@cindex type conversions in C++ -@item -You can call overloaded functions; _GDBN__ will resolve the function -call to the right definition, with one restriction---you must use -arguments of the type required by the function that you want to call. -_GDBN__ will not perform conversions requiring constructors or -user-defined type operators. - -@cindex reference declarations -@item -_GDBN__ understands variables declared as C++ references; you can use them in -expressions just as you do in C++ source---they are automatically -dereferenced. - -In the parameter list shown when _GDBN__ displays a frame, the values of -reference variables are not displayed (unlike other variables); this -avoids clutter, since references are often used for large structures. -The @emph{address} of a reference variable is always shown, unless -you've specified @samp{set print address off}. - - -@item -_GDBN__ supports the C++ name resolution operator @code{::}---your -expressions can use it just as expressions in your program do. Since -one scope may be defined in another, you can use @code{::} repeatedly if -necessary, for example in an expression like -@samp{@var{scope1}::@var{scope2}::@var{name}}. _GDBN__ also allows -resolving name scope by reference to source files, in both C and C++ -debugging; @pxref{Variables}. - -@end enumerate - - -@node C Defaults, C Checks, Cplusplus expressions, C -@subsubsection C and C++ Defaults -@cindex C and C++ defaults - -If you allow _GDBN__ to set type and range checking automatically, they -both default to @code{off} whenever the working language changes to -C/C++. This happens regardless of whether you, or _GDBN__, -selected the working language. - -If you allow _GDBN__ to set the language automatically, it sets the -working language to C/C++ on entering code compiled from a source file -whose name ends with @file{.c} or @file{.cc}. -@xref{Automatically,,Having _GDBN__ infer the source language}, for -further details. - -@node C Checks, Debugging C, C Defaults, C -@subsubsection C and C++ Type and Range Checks -@cindex C and C++ checks - -@quotation -@emph{Warning:} in this release, _GDBN__ does not yet perform type or -range checking. -@end quotation -@c FIXME remove warning when type/range checks added - -By default, when _GDBN__ parses C or C++ expressions, type checking -is not used. However, if you turn type checking on, _GDBN__ will -consider two variables type equivalent if: - -@itemize @bullet -@item -The two variables are structured and have the same structure, union, or -enumerated tag. - -@item -Two two variables have the same type name, or types that have been -declared equivalent through @code{typedef}. - -@ignore -@c leaving this out because neither J Gilmore nor R Pesch understand it. -@c FIXME--beers? -@item -The two @code{struct}, @code{union}, or @code{enum} variables are -declared in the same declaration. (Note: this may not be true for all C -compilers.) -@end ignore - -@end itemize - -Range checking, if turned on, is done on mathematical operations. Array -indices are not checked, since they are often used to index a pointer -that is not itself an array. - -@node Debugging C, Debugging C plus plus, C Checks, C -@subsubsection _GDBN__ and C - -The @code{set print union} and @code{show print union} commands apply to -the @code{union} type. When set to @samp{on}, any @code{union} that is -inside a @code{struct} or @code{class} will also be printed. -Otherwise, it will appear as @samp{@{...@}}. - -The @code{@@} operator aids in the debugging of dynamic arrays, formed -with pointers and a memory allocation function. (@pxref{Expressions}) - -@node Debugging C plus plus, , Debugging C, C -@subsubsection _GDBN__ Commands for C++ - -@cindex commands for C++ -Some _GDBN__ commands are particularly useful with C++, and some are -designed specifically for use with C++. Here is a summary: - -@table @code -@cindex break in overloaded functions -@item @r{breakpoint menus} -When you want a breakpoint in a function whose name is overloaded, -_GDBN__'s breakpoint menus help you specify which function definition -you want. @xref{Breakpoint Menus}. - -@cindex overloading in C++ -@item rbreak @var{regex} -Setting breakpoints using regular expressions is helpful for setting -breakpoints on overloaded functions that are not members of any special -classes. -@xref{Set Breaks}. - -@cindex C++ exception handling -@item catch @var{exceptions} -@itemx info catch -Debug C++ exception handling using these commands. @xref{Exception Handling}. - -@cindex inheritance -@item ptype @var{typename} -Print inheritance relationships as well as other information for type -@var{typename}. -@xref{Symbols}. - -@cindex C++ symbol display -@item set print demangle -@itemx show print demangle -@itemx set print asm-demangle -@itemx show print asm-demangle -Control whether C++ symbols display in their source form, both when -displaying code as C++ source and when displaying disassemblies. -@xref{Print Settings}. - -@item set print object -@itemx show print object -Choose whether to print derived (actual) or declared types of objects. -@xref{Print Settings}. - -@item set print vtbl -@itemx show print vtbl -Control the format for printing virtual function tables. -@xref{Print Settings}. - -@end table - - -@node Modula-2, , C, Support -@subsection Modula-2 -@cindex Modula-2 - -The extensions made to _GDBN__ to support Modula-2 support output -from the GNU Modula-2 compiler (which is currently being developed). -Other Modula-2 compilers are not currently supported, and attempting to -debug executables produced by them will most likely result in an error -as _GDBN__ reads in the executable's symbol table. - -@cindex expressions in Modula-2 -@menu -* M2 Operators:: Built-in operators -* Builtin Func/Proc:: Built-in Functions and Procedures -* M2 Constants:: Modula-2 Constants -* M2 Defaults:: Default settings for Modula-2 -* Deviations:: Deviations from standard Modula-2 -* M2 Checks:: Modula-2 Type and Range Checks -* M2 Scope:: The scope operators @code{::} and @code{.} -* GDB/M2:: _GDBN__ and Modula-2 -@end menu - -@node M2 Operators, Builtin Func/Proc, Modula-2, Modula-2 -@subsubsection Operators -@cindex Modula-2 operators - -Operators must be defined on values of specific types. For instance, -@code{+} is defined on numbers, but not on structures. Operators are -often defined on groups of types. For the purposes of Modula-2, the -following definitions hold: - -@itemize @bullet - -@item -@emph{Integral types} consist of @code{INTEGER}, @code{CARDINAL}, and -their subranges. - -@item -@emph{Character types} consist of @code{CHAR} and its subranges. - -@item -@emph{Floating-point types} consist of @code{REAL}. - -@item -@emph{Pointer types} consist of anything declared as @code{POINTER TO -@var{type}}. - -@item -@emph{Scalar types} consist of all of the above. - -@item -@emph{Set types} consist of @code{SET}s and @code{BITSET}s. - -@item -@emph{Boolean types} consist of @code{BOOLEAN}. - -@end itemize - -@noindent -The following operators are supported, and appear in order of -increasing precedence: - -@table @code -_0__ -@item , -Function argument or array index separator. - -@item := -Assignment. The value of @var{var} @code{:=} @var{value} is -@var{value}. - -@item <@r{, }> -Less than, greater than on integral, floating-point, or enumerated -types. - -@item <=@r{, }>= -Less than, greater than, less than or equal to, greater than or equal to -on integral, floating-point and enumerated types, or set inclusion on -set types. Same precedence as @code{<}. - -@item =@r{, }<>@r{, }# -Equality and two ways of expressing inequality, valid on scalar types. -Same precedence as @code{<}. In _GDBN__ scripts, only @code{<>} is -available for inequality, since @code{#} conflicts with the script -comment character. - -@item IN -Set membership. Defined on set types and the types of their members. -Same precedence as @code{<}. - -@item OR -Boolean disjunction. Defined on boolean types. - -@item AND@r{, }& -Boolean conjuction. Defined on boolean types. - -@item @@ -The _GDBN__ ``artificial array'' operator (@pxref{Expressions}). - -@item +@r{, }- -Addition and subtraction on integral and floating-point types, or union -and difference on set types. - -@item * -Multiplication on integral and floating-point types, or set intersection -on set types. - -@item / -Division on floating-point types, or symmetric set difference on set -types. Same precedence as @code{*}. - -@item DIV@r{, }MOD -Integer division and remainder. Defined on integral types. Same -precedence as @code{*}. - -@item - -Negative. Defined on @code{INTEGER}s and @code{REAL}s. - -@item ^ -Pointer dereferencing. Defined on pointer types. - -@item NOT -Boolean negation. Defined on boolean types. Same precedence as -@code{^}. - -@item . -@code{RECORD} field selector. Defined on @code{RECORD}s. Same -precedence as @code{^}. - -@item [] -Array indexing. Defined on @code{ARRAY}s. Same precedence as @code{^}. - -@item () -Procedure argument list. Defined on @code{PROCEDURE}s. Same precedence -as @code{^}. - -@item ::@r{, }. -_GDBN__ and Modula-2 scope operators. - -@end table - -@quotation -@emph{Warning:} Sets and their operations are not yet supported, so _GDBN__ -will treat the use of the operator @code{IN}, or the use of operators -@code{+}, @code{-}, @code{*}, @code{/}, @code{=}, , @code{<>}, @code{#}, -@code{<=}, and @code{>=} on sets as an error. -@end quotation -_1__ - -@cindex Modula-2 builtins -@node Builtin Func/Proc, M2 Constants, M2 Operators, Modula-2 -@subsubsection Built-in Functions and Procedures - -Modula-2 also makes available several built-in procedures and functions. -In describing these, the following metavariables are used: - -@table @var - -@item a -represents an @code{ARRAY} variable. - -@item c -represents a @code{CHAR} constant or variable. - -@item i -represents a variable or constant of integral type. - -@item m -represents an identifier that belongs to a set. Generally used in the -same function with the metavariable @var{s}. The type of @var{s} should -be @code{SET OF @var{mtype}} (where @var{mtype} is the type of @var{m}. - -@item n -represents a variable or constant of integral or floating-point type. - -@item r -represents a variable or constant of floating-point type. - -@item t -represents a type. - -@item v -represents a variable. - -@item x -represents a variable or constant of one of many types. See the -explanation of the function for details. - -@end table - -All Modula-2 built-in procedures also return a result, described below. - -@table @code -@item ABS(@var{n}) -Returns the absolute value of @var{n}. - -@item CAP(@var{c}) -If @var{c} is a lower case letter, it returns its upper case -equivalent, otherwise it returns its argument - -@item CHR(@var{i}) -Returns the character whose ordinal value is @var{i}. - -@item DEC(@var{v}) -Decrements the value in the variable @var{v}. Returns the new value. - -@item DEC(@var{v},@var{i}) -Decrements the value in the variable @var{v} by @var{i}. Returns the -new value. - -@item EXCL(@var{m},@var{s}) -Removes the element @var{m} from the set @var{s}. Returns the new -set. - -@item FLOAT(@var{i}) -Returns the floating point equivalent of the integer @var{i}. - -@item HIGH(@var{a}) -Returns the index of the last member of @var{a}. - -@item INC(@var{v}) -Increments the value in the variable @var{v}. Returns the new value. - -@item INC(@var{v},@var{i}) -Increments the value in the variable @var{v} by @var{i}. Returns the -new value. - -@item INCL(@var{m},@var{s}) -Adds the element @var{m} to the set @var{s} if it is not already -there. Returns the new set. - -@item MAX(@var{t}) -Returns the maximum value of the type @var{t}. - -@item MIN(@var{t}) -Returns the minimum value of the type @var{t}. - -@item ODD(@var{i}) -Returns boolean TRUE if @var{i} is an odd number. - -@item ORD(@var{x}) -Returns the ordinal value of its argument. For example, the ordinal -value of a character is its ASCII value (on machines supporting the -ASCII character set). @var{x} must be of an ordered type, which include -integral, character and enumerated types. - -@item SIZE(@var{x}) -Returns the size of its argument. @var{x} can be a variable or a type. - -@item TRUNC(@var{r}) -Returns the integral part of @var{r}. - -@item VAL(@var{t},@var{i}) -Returns the member of the type @var{t} whose ordinal value is @var{i}. -@end table - -@quotation -@emph{Warning:} Sets and their operations are not yet supported, so -_GDBN__ will treat the use of procedures @code{INCL} and @code{EXCL} as -an error. -@end quotation - -@cindex Modula-2 constants -@node M2 Constants, M2 Defaults, Builtin Func/Proc, Modula-2 -@subsubsection Constants - -_GDBN__ allows you to express the constants of Modula-2 in the following -ways: - -@itemize @bullet - -@item -Integer constants are simply a sequence of digits. When used in an -expression, a constant is interpreted to be type-compatible with the -rest of the expression. Hexadecimal integers are specified by a -trailing @samp{H}, and octal integers by a trailing @samp{B}. - -@item -Floating point constants appear as a sequence of digits, followed by a -decimal point and another sequence of digits. An optional exponent can -then be specified, in the form @samp{E@r{[}+@r{|}-@r{]}@var{nnn}}, where -@samp{@r{[}+@r{|}-@r{]}@var{nnn}} is the desired exponent. All of the -digits of the floating point constant must be valid decimal (base 10) -digits. - -@item -Character constants consist of a single character enclosed by a pair of -like quotes, either single (@code{'}) or double (@code{"}). They may -also be expressed by their ordinal value (their ASCII value, usually) -followed by a @samp{C}. - -@item -String constants consist of a sequence of characters enclosed by a pair -of like quotes, either single (@code{'}) or double (@code{"}). Escape -sequences in the style of C are also allowed. @xref{C Constants}, for a -brief explanation of escape sequences. - -@item -Enumerated constants consist of an enumerated identifier. - -@item -Boolean constants consist of the identifiers @code{TRUE} and -@code{FALSE}. - -@item -Pointer constants consist of integral values only. - -@item -Set constants are not yet supported. - -@end itemize - -@node M2 Defaults, Deviations, M2 Constants, Modula-2 -@subsubsection Modula-2 Defaults -@cindex Modula-2 defaults - -If type and range checking are set automatically by _GDBN__, they -both default to @code{on} whenever the working language changes to -Modula-2. This happens regardless of whether you, or _GDBN__, -selected the working language. - -If you allow _GDBN__ to set the language automatically, then entering -code compiled from a file whose name ends with @file{.mod} will set the -working language to Modula-2. @xref{Automatically,,Having _GDBN__ set -the language automatically}, for further details. - -@node Deviations, M2 Checks, M2 Defaults, Modula-2 -@subsubsection Deviations from Standard Modula-2 -@cindex Modula-2, deviations from - -A few changes have been made to make Modula-2 programs easier to debug. -This is done primarily via loosening its type strictness: - -@itemize @bullet -@item -Unlike in standard Modula-2, pointer constants can be formed by -integers. This allows you to modify pointer variables during -debugging. (In standard Modula-2, the actual address contained in a -pointer variable is hidden from you; it can only be modified -through direct assignment to another pointer variable or expression that -returned a pointer.) - -@item -C escape sequences can be used in strings and characters to represent -non-printable characters. _GDBN__ will print out strings with these -escape sequences embedded. Single non-printable characters are -printed using the @samp{CHR(@var{nnn})} format. - -@item -The assignment operator (@code{:=}) returns the value of its right-hand -argument. - -@item -All builtin procedures both modify @emph{and} return their argument. - -@end itemize - -@node M2 Checks, M2 Scope, Deviations, Modula-2 -@subsubsection Modula-2 Type and Range Checks -@cindex Modula-2 checks - -@quotation -@emph{Warning:} in this release, _GDBN__ does not yet perform type or -range checking. -@end quotation -@c FIXME remove warning when type/range checks added - -_GDBN__ considers two Modula-2 variables type equivalent if: - -@itemize @bullet -@item -They are of types that have been declared equivalent via a @code{TYPE -@var{t1} = @var{t2}} statement - -@item -They have been declared on the same line. (Note: This is true of the -GNU Modula-2 compiler, but it may not be true of other compilers.) - -@end itemize - -As long as type checking is enabled, any attempt to combine variables -whose types are not equivalent is an error. - -Range checking is done on all mathematical operations, assignment, array -index bounds, and all builtin functions and procedures. - -@node M2 Scope, GDB/M2, M2 Checks, Modula-2 -@subsubsection The scope operators @code{::} and @code{.} -@cindex scope -@kindex . -@kindex :: - -There are a few subtle differences between the Modula-2 scope operator -(@code{.}) and the _GDBN__ scope operator (@code{::}). The two have -similar syntax: - -@example - -@var{module} . @var{id} -@var{scope} :: @var{id} - -@end example - -@noindent -where @var{scope} is the name of a module or a procedure, -@var{module} the name of a module, and @var{id} is any delcared -identifier within the program, except another module. - -Using the @code{::} operator makes _GDBN__ search the scope -specified by @var{scope} for the identifier @var{id}. If it is not -found in the specified scope, then _GDBN__ will search all scopes -enclosing the one specified by @var{scope}. - -Using the @code{.} operator makes _GDBN__ search the current scope for -the identifier specified by @var{id} that was imported from the -definition module specified by @var{module}. With this operator, it is -an error if the identifier @var{id} was not imported from definition -module @var{module}, or if @var{id} is not an identifier in -@var{module}. - -@node GDB/M2, , M2 Scope, Modula-2 -@subsubsection _GDBN__ and Modula-2 - -Some _GDBN__ commands have little use when debugging Modula-2 programs. -Five subcommands of @code{set print} and @code{show print} apply -specifically to C and C++: @samp{vtbl}, @samp{demangle}, -@samp{asm-demangle}, @samp{object}, and @samp{union}. The first four -apply to C++, and the last to C's @code{union} type, which has no direct -analogue in Modula-2. - -The @code{@@} operator (@pxref{Expressions}), while available -while using any language, is not useful with Modula-2. Its -intent is to aid the debugging of @dfn{dynamic arrays}, which cannot be -created in Modula-2 as they can in C or C++. However, because an -address can be specified by an integral constant, the construct -@samp{@{@var{type}@}@var{adrexp}} is still useful. (@pxref{Expressions}) - -_0__ -@cindex @code{#} in Modula-2 -In _GDBN__ scripts, the Modula-2 inequality operator @code{#} is -interpreted as the beginning of a comment. Use @code{<>} instead. -_1__ - - -@node Symbols, Altering, Languages, Top -@chapter Examining the Symbol Table - -The commands described in this section allow you to inquire about the -symbols (names of variables, functions and types) defined in your -program. This information is inherent in the text of your program and -does not change as the program executes. _GDBN__ finds it in your -program's symbol table, in the file indicated when you started _GDBN__ -(@pxref{File Options}), or by one of the file-management commands -(@pxref{Files}). - -@table @code -@item info address @var{symbol} -@kindex info address -Describe where the data for @var{symbol} is stored. For a register -variable, this says which register it is kept in. For a non-register -local variable, this prints the stack-frame offset at which the variable -is always stored. - -Note the contrast with @samp{print &@var{symbol}}, which does not work -at all for a register variables, and for a stack local variable prints -the exact address of the current instantiation of the variable. - -@item whatis @var{exp} -@kindex whatis -Print the data type of expression @var{exp}. @var{exp} is not -actually evaluated, and any side-effecting operations (such as -assignments or function calls) inside it do not take place. -@xref{Expressions}. - -@item whatis -Print the data type of @code{$}, the last value in the value history. - -@item ptype @var{typename} -@kindex ptype -Print a description of data type @var{typename}. @var{typename} may be -the name of a type, or for C code it may have the form -@samp{struct @var{struct-tag}}, @samp{union @var{union-tag}} or -@samp{enum @var{enum-tag}}.@refill - -@item ptype @var{exp} -@itemx ptype -Print a description of the type of expression @var{exp}. @code{ptype} -differs from @code{whatis} by printing a detailed description, instead of just -the name of the type. For example, if your program declares a variable -as -@example -struct complex @{double real; double imag;@} v; -@end example -@noindent -compare the output of the two commands: -@example -(_GDBP__) whatis v -type = struct complex -(_GDBP__) ptype v -type = struct complex @{ - double real; - double imag; -@} -@end example -@noindent -As with @code{whatis}, using @code{ptype} without an argument refers to -the type of @code{$}, the last value in the value history. - -@item info types @var{regexp} -@itemx info types -@kindex info types -Print a brief description of all types whose name matches @var{regexp} -(or all types in your program, if you supply no argument). Each -complete typename is matched as though it were a complete line; thus, -@samp{i type value} gives information on all types in your program whose -name includes the string @code{value}, but @samp{i type ^value$} gives -information only on types whose complete name is @code{value}. - -This command differs from @code{ptype} in two ways: first, like -@code{whatis}, it does not print a detailed description; second, it -lists all source files where a type is defined. - -@item info source -@kindex info source -Show the name of the current source file---that is, the source file for -the function containing the current point of execution---and the language -it was written in. - -@item info sources -@kindex info sources -Print the names of all source files in the program for which there is -debugging information, organized into two lists: files whose symbols -have already been read, and files whose symbols will be read when needed. - -@item info functions -@kindex info functions -Print the names and data types of all defined functions. - -@item info functions @var{regexp} -Print the names and data types of all defined functions -whose names contain a match for regular expression @var{regexp}. -Thus, @samp{info fun step} finds all functions whose names -include @code{step}; @samp{info fun ^step} finds those whose names -start with @code{step}. - -@item info variables -@kindex info variables -Print the names and data types of all variables that are declared -outside of functions (i.e., excluding local variables). - -@item info variables @var{regexp} -Print the names and data types of all variables (except for local -variables) whose names contain a match for regular expression -@var{regexp}. - - -@ignore -This was never implemented. -@item info methods -@itemx info methods @var{regexp} -@kindex info methods -The @code{info methods} command permits the user to examine all defined -methods within C++ program, or (with the @var{regexp} argument) a -specific set of methods found in the various C++ classes. Many -C++ classes provide a large number of methods. Thus, the output -from the @code{ptype} command can be overwhelming and hard to use. The -@code{info-methods} command filters the methods, printing only those -which match the regular-expression @var{regexp}. -@end ignore - -@item printsyms @var{filename} -@itemx printpsyms @var{filename} -@kindex printsyms -@cindex symbol dump -@kindex printsyms -@cindex partial symbol dump -Write a dump of debugging symbol data into the file @var{filename}. -These commands are used to debug the _GDBN__ symbol-reading code. Only -symbols with debugging data are included. If you use @code{printsyms}, -_GDBN__ includes all the symbols for which it has already collected full -details: that is, @var{filename} reflects symbols for only those files -whose symbols _GDBN__ has read. You can use the command @code{info -sources} to find out which files these are. If you use -@code{printpsyms}, the dump also shows information about symbols that -_GDBN__ only knows partially---that is, symbols defined in files that -_GDBN__ has skimmed, but not yet read completely. The description of -@code{symbol-file} describes how _GDBN__ reads symbols; both commands -are described under @ref{Files}. - -@end table - -@node Altering, _GDBN__ Files, Symbols, Top -@chapter Altering Execution - -Once you think you have found an error in the program, you might want to -find out for certain whether correcting the apparent error would lead to -correct results in the rest of the run. You can find the answer by -experiment, using the _GDBN__ features for altering execution of the -program. - -For example, you can store new values into variables or memory -locations, give the program a signal, restart it at a different address, -or even return prematurely from a function to its caller. - -@menu -* Assignment:: Assignment to Variables -* Jumping:: Continuing at a Different Address -* Signaling:: Giving the Program a Signal -* Returning:: Returning from a Function -* Calling:: Calling your Program's Functions -* Patching:: Patching your Program -@end menu - -@node Assignment, Jumping, Altering, Altering -@section Assignment to Variables - -@cindex assignment -@cindex setting variables -To alter the value of a variable, evaluate an assignment expression. -@xref{Expressions}. For example, - -@example -print x=4 -@end example - -@noindent -would store the value 4 into the variable @code{x}, and then print the -value of the assignment expression (which is 4). @xref{Languages}, for -more information on operators in supported languages. - -@kindex set variable -@cindex variables, setting -If you are not interested in seeing the value of the assignment, use the -@code{set} command instead of the @code{print} command. @code{set} is -really the same as @code{print} except that the expression's value is not -printed and is not put in the value history (@pxref{Value History}). The -expression is evaluated only for its effects. - -If the beginning of the argument string of the @code{set} command -appears identical to a @code{set} subcommand, use the @code{set -variable} command instead of just @code{set}. This command is identical -to @code{set} except for its lack of subcommands. For example, a -program might well have a variable @code{width}---which leads to -an error if we try to set a new value with just @samp{set width=13}, as -we might if @code{set width} didn't happen to be a _GDBN__ command: -@example -(_GDBP__) whatis width -type = double -(_GDBP__) p width -$4 = 13 -(_GDBP__) set width=47 -Invalid syntax in expression. -@end example -@noindent -The invalid expression, of course, is @samp{=47}. What we can do in -order to actually set our program's variable @code{width} is -@example -(_GDBP__) set var width=47 -@end example - -_GDBN__ allows more implicit conversions in assignments than C does; you can -freely store an integer value into a pointer variable or vice versa, and -any structure can be converted to any other structure that is the same -length or shorter. -@comment FIXME: how do structs align/pad in these conversions? -@comment /pesch@cygnus.com 18dec1990 - -To store values into arbitrary places in memory, use the @samp{@{@dots{}@}} -construct to generate a value of specified type at a specified address -(@pxref{Expressions}). For example, @code{@{int@}0x83040} refers -to memory location @code{0x83040} as an integer (which implies a certain size -and representation in memory), and - -@example -set @{int@}0x83040 = 4 -@end example - -@noindent -stores the value 4 into that memory location. - -@node Jumping, Signaling, Assignment, Altering -@section Continuing at a Different Address - -Ordinarily, when you continue the program, you do so at the place where -it stopped, with the @code{continue} command. You can instead continue at -an address of your own choosing, with the following commands: - -@table @code -@item jump @var{linespec} -@kindex jump -Resume execution at line @var{linespec}. Execution will stop -immediately if there is a breakpoint there. @xref{List} for a -description of the different forms of @var{linespec}. - -The @code{jump} command does not change the current stack frame, or -the stack pointer, or the contents of any memory location or any -register other than the program counter. If line @var{linespec} is in -a different function from the one currently executing, the results may -be bizarre if the two functions expect different patterns of arguments or -of local variables. For this reason, the @code{jump} command requests -confirmation if the specified line is not in the function currently -executing. However, even bizarre results are predictable if you are -well acquainted with the machine-language code of the program. - -@item jump *@var{address} -Resume execution at the instruction at address @var{address}. -@end table - -You can get much the same effect as the @code{jump} command by storing a -new value into the register @code{$pc}. The difference is that this -does not start the program running; it only changes the address where it -@emph{will} run when it is continued. For example, - -@example -set $pc = 0x485 -@end example - -@noindent -causes the next @code{continue} command or stepping command to execute at -address 0x485, rather than at the address where the program stopped. -@xref{Continuing and Stepping}. - -The most common occasion to use the @code{jump} command is to back up, -perhaps with more breakpoints set, over a portion of a program that has -already executed, in order to examine its execution in more detail. - -@node Signaling, Returning, Jumping, Altering -@c @group -@section Giving the Program a Signal - -@table @code -@item signal @var{signalnum} -@kindex signal -Resume execution where the program stopped, but give it immediately the -signal number @var{signalnum}. - -Alternatively, if @var{signalnum} is zero, continue execution without -giving a signal. This is useful when the program stopped on account of -a signal and would ordinary see the signal when resumed with the -@code{continue} command; @samp{signal 0} causes it to resume without a -signal. - -@code{signal} does not repeat when you press @key{RET} a second time -after executing the command. -@end table -@c @end group - -@node Returning, Calling, Signaling, Altering -@section Returning from a Function - -@table @code -@item return -@itemx return @var{expression} -@cindex returning from a function -@kindex return -You can cancel execution of a function call with the @code{return} -command. If you give an -@var{expression} argument, its value is used as the function's return -value. -@end table - -When you use @code{return}, _GDBN__ discards the selected stack frame -(and all frames within it). You can think of this as making the -discarded frame return prematurely. If you wish to specify a value to -be returned, give that value as the argument to @code{return}. - -This pops the selected stack frame (@pxref{Selection}), and any other -frames inside of it, leaving its caller as the innermost remaining -frame. That frame becomes selected. The specified value is stored in -the registers used for returning values of functions. - -The @code{return} command does not resume execution; it leaves the -program stopped in the state that would exist if the function had just -returned. In contrast, the @code{finish} command -(@pxref{Continuing and Stepping}) -resumes execution until the selected stack frame returns naturally.@refill - -@node Calling, Patching, Returning, Altering -@section Calling your Program's Functions - -@cindex calling functions -@kindex call -@table @code -@item call @var{expr} -Evaluate the expression @var{expr} without displaying @code{void} -returned values. -@end table - -You can use this variant of the @code{print} command if you want to -execute a function from your program, but without cluttering the output -with @code{void} returned values. The result is printed and saved in -the value history, if it is not void. - -@node Patching, , Calling, Altering -@section Patching your Program -@cindex patching binaries -@cindex writing into executables -@cindex writing into corefiles -By default, _GDBN__ opens the file containing your program's executable -code (or the corefile) read-only. This prevents accidental alterations -to machine code; but it also prevents you from intentionally patching -your program's binary. - -If you'd like to be able to patch the binary, you can specify that -explicitly with the @code{set write} command. For example, you might -want to turn on internal debugging flags, or even to make emergency -repairs. - -@table @code -@item set write on -@itemx set write off -@kindex set write -If you specify @samp{set write on}, _GDBN__ will open executable and -core files for both reading and writing; if you specify @samp{set write -off} (the default), _GDBN__ will open them read-only. - -If you've already loaded a file, you must load it -again (using the @code{exec-file} or @code{core-file} command) after -changing @code{set write}, for your new setting to take effect. - -@item show write -@kindex show write -Display whether executable files and core files will be opened for -writing as well as reading. - -@end table - -@node _GDBN__ Files, Targets, Altering, Top -@chapter _GDBN__'s Files - -@menu -* Files:: Commands to Specify Files -* Symbol Errors:: Errors Reading Symbol Files -@end menu - -@node Files, Symbol Errors, _GDBN__ Files, _GDBN__ Files -@section Commands to Specify Files -@cindex core dump file -@cindex symbol table -_GDBN__ needs to know the file name of the program to be debugged, both in -order to read its symbol table and in order to start the program. To -debug a core dump of a previous run, _GDBN__ must be told the file name of -the core dump. - -The usual way to specify the executable and core dump file names is with -the command arguments given when you start _GDBN__, as discussed in -@pxref{Invocation}. - -Occasionally it is necessary to change to a different file during a -_GDBN__ session. Or you may run _GDBN__ and forget to specify the files you -want to use. In these situations the _GDBN__ commands to specify new files -are useful. - -@table @code -@item file @var{filename} -@cindex executable file -@kindex file -Use @var{filename} as the program to be debugged. It is read for its -symbols and for the contents of pure memory. It is also the program -executed when you use the @code{run} command. If you do not specify a -directory and the file is not found in _GDBN__'s working directory, - -_GDBN__ uses the environment variable @code{PATH} as a list of -directories to search, just as the shell does when looking for a program -to run. You can change the value of this variable, for both _GDBN__ and -your program, using the @code{path} command. - -@item file -@code{file} with no argument makes _GDBN__ discard any information it -has on both executable file and the symbol table. - -@item exec-file @r{[} @var{filename} @r{]} -@kindex exec-file -Specify that the program to be run (but not the symbol table) is found -in @var{filename}. _GDBN__ will search the environment variable @code{PATH} -if necessary to locate the program. Omitting @var{filename} means to -discard information on the executable file. - -@item symbol-file @r{[} @var{filename} @r{]} -@kindex symbol-file -Read symbol table information from file @var{filename}. @code{PATH} is -searched when necessary. Use the @code{file} command to get both symbol -table and program to run from the same file. - -@code{symbol-file} with no argument clears out _GDBN__'s information on your -program's symbol table. - -The @code{symbol-file} command causes _GDBN__ to forget the contents of its -convenience variables, the value history, and all breakpoints and -auto-display expressions. This is because they may contain pointers to -the internal data recording symbols and data types, which are part of -the old symbol table data being discarded inside _GDBN__. - -@code{symbol-file} will not repeat if you press @key{RET} again after -executing it once. - -On some kinds of object files, the @code{symbol-file} command does not -actually read the symbol table in full right away. Instead, it scans -the symbol table quickly to find which source files and which symbols -are present. The details are read later, one source file at a time, -when they are needed. - -The purpose of this two-stage reading strategy is to make _GDBN__ start up -faster. For the most part, it is invisible except for occasional pauses -while the symbol table details for a particular source file are being -read. (The @code{set verbose} command can turn these pauses into -messages if desired. @xref{Messages/Warnings}). - -When the symbol table is stored in COFF format, @code{symbol-file} does -read the symbol table data in full right away. We haven't implemented -the two-stage strategy for COFF yet. - -When _GDBN__ is configured for a particular environment, it will -understand debugging information in whatever format is the standard -generated for that environment; you may use either a GNU compiler, or -other compilers that adhere to the local conventions. Best results are -usually obtained from GNU compilers; for example, using @code{_GCC__} -you can generate debugging information for optimized code. - -@item core-file @r{[} @var{filename} @r{]} -@kindex core -@kindex core-file -Specify the whereabouts of a core dump file to be used as the ``contents -of memory''. Traditionally, core files contain only some parts of the -address space of the process that generated them; _GDBN__ can access the -executable file itself for other parts. - -@code{core-file} with no argument specifies that no core file is -to be used. - -Note that the core file is ignored when your program is actually running -under _GDBN__. So, if you have been running the program and you wish to -debug a core file instead, you must kill the subprocess in which the -program is running. To do this, use the @code{kill} command -(@pxref{Kill Process}). - -@item load @var{filename} -@kindex load -_if__(_GENERIC__) -Depending on what remote debugging facilities are configured into -_GDBN__, the @code{load} command may be available. Where it exists, it -is meant to make @var{filename} (an executable) available for debugging -on the remote system---by downloading, or dynamic linking, for example. -@code{load} also records @var{filename}'s symbol table in _GDBN__, like -the @code{add-symbol-file} command. - -If @code{load} is not available on your _GDBN__, attempting to execute -it gets the error message ``@code{You can't do that when your target is -@dots{}}'' -_fi__(_GENERIC__) - -_if__(_VXWORKS__) -On VxWorks, @code{load} will dynamically link @var{filename} on the -current target system as well as adding its symbols in _GDBN__. -_fi__(_VXWORKS__) - -_if__(_I960__) -@cindex download to Nindy-960 -With the Nindy interface to an Intel 960 board, @code{load} will -download @var{filename} to the 960 as well as adding its symbols in -_GDBN__. -_fi__(_I960__) - -@code{load} will not repeat if you press @key{RET} again after using it. - -@item add-symbol-file @var{filename} @var{address} -@kindex add-symbol-file -@cindex dynamic linking -The @code{add-symbol-file} command reads additional symbol table information -from the file @var{filename}. You would use this command when @var{filename} -has been dynamically loaded (by some other means) into the program that -is running. @var{address} should be the memory address at which the -file has been loaded; _GDBN__ cannot figure this out for itself. - -The symbol table of the file @var{filename} is added to the symbol table -originally read with the @code{symbol-file} command. You can use the -@code{add-symbol-file} command any number of times; the new symbol data thus -read keeps adding to the old. To discard all old symbol data instead, -use the @code{symbol-file} command. - -@code{add-symbol-file} will not repeat if you press @key{RET} after using it. - -@item info files -@itemx info target -@kindex info files -@kindex info target -@code{info files} and @code{info target} are synonymous; both print the -current targets (@pxref{Targets}), including the names of the executable -and core dump files currently in use by _GDBN__, and the files from -which symbols were loaded. The command @code{help targets} lists all -possible targets rather than current ones. - -@end table - -All file-specifying commands allow both absolute and relative file names -as arguments. _GDBN__ always converts the file name to an absolute path -name and remembers it that way. - -@cindex shared libraries - -_GDBN__ supports the SunOS shared library format. _GDBN__ automatically -loads symbol definitions from shared libraries when you use the -@code{run} command, or when you examine a core file. (Before you issue -the @code{run} command, _GDBN__ won't understand references to a -function in a shared library, however---unless you're debugging a core -file). -@c FIXME: next _GDBN__ release should permit some refs to undef -@c FIXME...symbols---eg in a break cmd---assuming they're from a shared lib - -@table @code -@item info share -@itemx info sharedlibrary -@kindex info sharedlibrary -@kindex info share -Print the names of the shared libraries which are currently loaded. - -@item sharedlibrary @var{regex} -@itemx share @var{regex} -@kindex sharedlibrary -@kindex share -This is an obsolescent command; you can use it to explicitly -load shared object library symbols for files matching a UNIX regular -expression, but as with files loaded automatically, it will only load -shared libraries required by your program for a core file or after -typing @code{run}. If @var{regex} is omitted all shared libraries -required by your program are loaded. -@end table - -@node Symbol Errors, , Files, _GDBN__ Files -@section Errors Reading Symbol Files -While reading a symbol file, _GDBN__ will occasionally encounter -problems, such as symbol types it does not recognize, or known bugs in -compiler output. By default, _GDBN__ does not notify you of such -problems, since they're relatively common and primarily of interest to -people debugging compilers. If you are interested in seeing information -about ill-constructed symbol tables, you can either ask _GDBN__ to print -only one message about each such type of problem, no matter how many -times the problem occurs; or you can ask _GDBN__ to print more messages, -to see how many times the problems occur, with the @code{set complaints} -command (@xref{Messages/Warnings}). - -The messages currently printed, and their meanings, are: - -@table @code -@item inner block not inside outer block in @var{symbol} - -The symbol information shows where symbol scopes begin and end -(such as at the start of a function or a block of statements). This -error indicates that an inner scope block is not fully contained -in its outer scope blocks. - -_GDBN__ circumvents the problem by treating the inner block as if it had -the same scope as the outer block. In the error message, @var{symbol} -may be shown as ``@code{(don't know)}'' if the outer block is not a -function. - -@item block at @var{address} out of order - -The symbol information for symbol scope blocks should occur in -order of increasing addresses. This error indicates that it does not -do so. - -_GDBN__ does not circumvent this problem, and will have trouble locating -symbols in the source file whose symbols being read. (You can often -determine what source file is affected by specifying @code{set verbose -on}. @xref{Messages/Warnings}.) - -@item bad block start address patched - -The symbol information for a symbol scope block has a start address -smaller than the address of the preceding source line. This is known -to occur in the SunOS 4.1.1 (and earlier) C compiler. - -_GDBN__ circumvents the problem by treating the symbol scope block as -starting on the previous source line. - -@item bad string table offset in symbol @var{n} - -@cindex foo -Symbol number @var{n} contains a pointer into the string table which is -larger than the size of the string table. - -_GDBN__ circumvents the problem by considering the symbol to have the -name @code{foo}, which may cause other problems if many symbols end up -with this name. - -@item unknown symbol type @code{0x@var{nn}} - -The symbol information contains new data types that _GDBN__ does not yet -know how to read. @code{0x@var{nn}} is the symbol type of the misunderstood -information, in hexadecimal. - -_GDBN__ circumvents the error by ignoring this symbol information. This -will usually allow the program to be debugged, though certain symbols -will not be accessible. If you encounter such a problem and feel like -debugging it, you can debug @code{_GDBP__} with itself, breakpoint on -@code{complain}, then go up to the function @code{read_dbx_symtab} and -examine @code{*bufp} to see the symbol. - -@item stub type has NULL name -_GDBN__ could not find the full definition for a struct or class. - -@item const/volatile indicator missing (ok if using g++ v1.x), got@dots{} - -The symbol information for a C++ member function is missing some -information that recent versions of the compiler should have output -for it. - -@item info mismatch between compiler and debugger - -_GDBN__ could not parse a type specification output by the compiler. - -@end table - -@node Targets, Controlling _GDBN__, _GDBN__ Files, Top -@chapter Specifying a Debugging Target -@cindex debugging target -@kindex target -A @dfn{target} is the execution environment occupied by your program. -Often, _GDBN__ runs in the same host environment as the program you are -debugging; in that case, the debugging target is specified as a side -effect when you use the @code{file} or @code{core} commands. When you -need more flexibility---for example, running _GDBN__ on a physically -separate host, or controlling a standalone system over a serial port or -a realtime system over a TCP/IP connection---you can use the -@code{target} command to specify one of the target types configured for -_GDBN__ (@pxref{Target Commands}). - -@menu -* Active Targets:: Active Targets -* Target Commands:: Commands for Managing Targets -* Remote:: Remote Debugging -@end menu - -@node Active Targets, Target Commands, Targets, Targets -@section Active Targets -@cindex stacking targets -@cindex active targets -@cindex multiple targets - -There are three classes of targets: processes, core files, and -executable files. _GDBN__ can work concurrently on up to three active -targets, one in each class. This allows you to (for example) start a -process and inspect its activity without abandoning your work on a core -file. - -If, for example, you execute @samp{gdb a.out}, then the executable file -@code{a.out} is the only active target. If you designate a core file as -well---presumably from a prior run that crashed and coredumped---then -_GDBN__ has two active targets and will use them in tandem, looking -first in the corefile target, then in the executable file, to satisfy -requests for memory addresses. (Typically, these two classes of target -are complementary, since core files contain only the program's -read-write memory---variables and so on---plus machine status, while -executable files contain only the program text and initialized data.) - -When you type @code{run}, your executable file becomes an active process -target as well. When a process target is active, all _GDBN__ commands -requesting memory addresses refer to that target; addresses in an active -core file or executable file target are obscured while the process -target is active. - -Use the @code{core-file}, and @code{exec-file} commands to select a new -core file or executable target (@pxref{Files}). To specify as a target -a process that's already running, use the @code{attach} command -(@pxref{Attach}). - -@node Target Commands, Remote, Active Targets, Targets -@section Commands for Managing Targets - -@table @code -@item target @var{type} @var{parameters} -Connects the _GDBN__ host environment to a target machine or process. A -target is typically a protocol for talking to debugging facilities. You -use the argument @var{type} to specify the type or protocol of the -target machine. - -Further @var{parameters} are interpreted by the target protocol, but -typically include things like device names or host names to connect -with, process numbers, and baud rates. - -The @code{target} command will not repeat if you press @key{RET} again -after executing the command. - -@item help target -@kindex help target -Displays the names of all targets available. To display targets -currently selected, use either @code{info target} or @code{info files} -(@pxref{Files}). - -@item help target @var{name} -Describe a particular target, including any parameters necessary to -select it. -@end table - -Here are some common targets (available, or not, depending on the _GDBN__ -configuration): - -@table @code -@item target exec @var{prog} -@kindex target exec -An executable file. @samp{target exec @var{prog}} is the same as -@samp{exec-file @var{prog}}. - -@item target core @var{filename} -@kindex target core -A core dump file. @samp{target core @var{filename}} is the same as -@samp{core-file @var{filename}}. - -@item target remote @var{dev} -@kindex target remote -Remote serial target in _GDBN__-specific protocol. The argument @var{dev} -specifies what serial device to use for the connection (e.g. -@file{/dev/ttya}). @xref{Remote}. - -_if__(_AMD29K__) -@item target amd-eb @var{dev} @var{speed} @var{PROG} -@kindex target amd-eb -@cindex AMD EB29K -Remote PC-resident AMD EB29K board, attached over serial lines. -@var{dev} is the serial device, as for @code{target remote}; -@var{speed} allows you to specify the linespeed; and @var{PROG} is the -name of the program to be debugged, as it appears to DOS on the PC. -@xref{EB29K Remote}. - -_fi__(_AMD29K__) -_if__(_I960__) -@item target nindy @var{devicename} -@kindex target nindy -An Intel 960 board controlled by a Nindy Monitor. @var{devicename} is -the name of the serial device to use for the connection, e.g. -@file{/dev/ttya}. @xref{i960-Nindy Remote}. - -_fi__(_I960__) -_if__(_VXWORKS__) -@item target vxworks @var{machinename} -@kindex target vxworks -A VxWorks system, attached via TCP/IP. The argument @var{machinename} -is the target system's machine name or IP address. -@xref{VxWorks Remote}. -_fi__(_VXWORKS__) -@end table - -_if__(_GENERIC__) -Different targets are available on different configurations of _GDBN__; your -configuration may have more or fewer targets. -_fi__(_GENERIC__) - -@node Remote, , Target Commands, Targets -@section Remote Debugging -@cindex remote debugging - -_if__(_GENERIC__) -@menu -_include__(gdbinv-m.m4)<>_dnl__ -@end menu -_fi__(_GENERIC__) - -If you are trying to debug a program running on a machine that can't run -_GDBN__ in the usual way, it is often useful to use remote debugging. For -example, you might use remote debugging on an operating system kernel, or on -a small system which does not have a general purpose operating system -powerful enough to run a full-featured debugger. - -Some configurations of _GDBN__ have special serial or TCP/IP interfaces -to make this work with particular debugging targets. In addition, -_GDBN__ comes with a generic serial protocol (specific to _GDBN__, but -not specific to any particular target system) which you can use if you -write the remote stubs---the code that will run on the remote system to -communicate with _GDBN__. - -To use the _GDBN__ remote serial protocol, the program to be debugged on -the remote machine needs to contain a debugging stub which talks to -_GDBN__ over the serial line. Several working remote stubs are -distributed with _GDBN__; see the @file{README} file in the _GDBN__ -distribution for more information. - -For details of this communication protocol, see the comments in the -_GDBN__ source file @file{remote.c}. - -To start remote debugging, first run _GDBN__ and specify as an executable file -the program that is running in the remote machine. This tells _GDBN__ how -to find the program's symbols and the contents of its pure text. Then -establish communication using the @code{target remote} command with a device -name as an argument. For example: - -@example -target remote /dev/ttyb -@end example - -@noindent -if the serial line is connected to the device named @file{/dev/ttyb}. This -will stop the remote machine if it is not already stopped. - -Now you can use all the usual commands to examine and change data and to -step and continue the remote program. - -To resume the remote program and stop debugging it, use the @code{detach} -command. - -Other remote targets may be available in your -configuration of _GDBN__; use @code{help targets} to list them. - -_if__(_GENERIC__) -@c Text on starting up GDB in various specific cases; it goes up front -@c in manuals configured for any of those particular situations, here -@c otherwise. -_include__(gdbinv-s.m4) -_fi__(_GENERIC__) - -@node Controlling _GDBN__, Sequences, Targets, Top -@chapter Controlling _GDBN__ - -You can alter many aspects of _GDBN__'s interaction with you by using -the @code{set} command. For commands controlling how _GDBN__ displays -data, @pxref{Print Settings}; other settings are described here. - -@menu -* Prompt:: Prompt -* Editing:: Command Editing -* History:: Command History -* Screen Size:: Screen Size -* Numbers:: Numbers -* Messages/Warnings:: Optional Warnings and Messages -@end menu - -@node Prompt, Editing, Controlling _GDBN__, Controlling _GDBN__ -@section Prompt -@cindex prompt -_GDBN__ indicates its readiness to read a command by printing a string -called the @dfn{prompt}. This string is normally @samp{(_GDBP__)}. You -can change the prompt string with the @code{set prompt} command. For -instance, when debugging _GDBN__ with _GDBN__, it is useful to change -the prompt in one of the _GDBN__<>s so that you can always tell which -one you are talking to. - -@table @code -@item set prompt @var{newprompt} -@kindex set prompt -Directs _GDBN__ to use @var{newprompt} as its prompt string henceforth. -@kindex show prompt -@item show prompt -Prints a line of the form: @samp{Gdb's prompt is: @var{your-prompt}} -@end table - -@node Editing, History, Prompt, Controlling _GDBN__ -@section Command Editing -@cindex readline -@cindex command line editing -_GDBN__ reads its input commands via the @dfn{readline} interface. This -GNU library provides consistent behavior for programs which provide a -command line interface to the user. Advantages are @code{emacs}-style -or @code{vi}-style inline editing of commands, @code{csh}-like history -substitution, and a storage and recall of command history across -debugging sessions. - -You may control the behavior of command line editing in _GDBN__ with the -command @code{set}. - -@table @code -@kindex set editing -@cindex editing -@item set editing -@itemx set editing on -Enable command line editing (enabled by default). - -@item set editing off -Disable command line editing. - -@kindex show editing -@item show editing -Show whether command line editing is enabled. -@end table - -@node History, Screen Size, Editing, Controlling _GDBN__ -@section Command History -@table @code -@cindex history substitution -@cindex history file -@kindex set history filename -@item set history filename @var{fname} -Set the name of the _GDBN__ command history file to @var{fname}. This is -the file from which _GDBN__ will read an initial command history -list or to which it will write this list when it exits. This list is -accessed through history expansion or through the history -command editing characters listed below. This file defaults to the -value of the environment variable @code{GDBHISTFILE}, or to -@file{./.gdb_history} if this variable is not set. - -@cindex history save -@kindex set history save -@item set history save -@itemx set history save on -Record command history in a file, whose name may be specified with the -@code{set history filename} command. By default, this option is disabled. - -@item set history save off -Stop recording command history in a file. - -@cindex history size -@kindex set history size -@item set history size @var{size} -Set the number of commands which _GDBN__ will keep in its history list. -This defaults to the value of the environment variable -@code{HISTSIZE}, or to 256 if this variable is not set. -@end table - -@cindex history expansion -History expansion assigns special meaning to the character @kbd{!}. -@iftex -(@xref{Event Designators}.) -@end iftex -Since @kbd{!} is also the logical not operator in C, history expansion -is off by default. If you decide to enable history expansion with the -@code{set history expansion on} command, you may sometimes need to -follow @kbd{!} (when it is used as logical not, in an expression) with -a space or a tab to prevent it from being expanded. The readline -history facilities will not attempt substitution on the strings -@kbd{!=} and @kbd{!(}, even when history expansion is enabled. - -The commands to control history expansion are: - -@table @code - -@kindex set history expansion -@item set history expansion on -@itemx set history expansion -Enable history expansion. History expansion is off by default. - -@item set history expansion off -Disable history expansion. - -The readline code comes with more complete documentation of -editing and history expansion features. Users unfamiliar with @code{emacs} -or @code{vi} may wish to read it. -@iftex -@xref{Command Line Editing}. -@end iftex - -@c @group -@kindex show history -@item show history -@itemx show history filename -@itemx show history save -@itemx show history size -@itemx show history expansion -These commands display the state of the _GDBN__ history parameters. -@code{show history} by itself displays all four states. -@c @end group - -@end table - -@table @code -@kindex show commands -@item show commands -Display the last ten commands in the command history. - -@item show commands @var{n} -Print ten commands centered on command number @var{n}. - -@item show commands + -Print ten commands just after the commands last printed. - -@end table - -@node Screen Size, Numbers, History, Controlling _GDBN__ -@section Screen Size -@cindex size of screen -@cindex pauses in output -Certain commands to _GDBN__ may produce large amounts of information -output to the screen. To help you read all of it, _GDBN__ pauses and -asks you for input at the end of each page of output. Type @key{RET} -when you want to continue the output. _GDBN__ also uses the screen -width setting to determine when to wrap lines of output. Depending on -what is being printed, it tries to break the line at a readable place, -rather than simply letting it overflow onto the following line. - -Normally _GDBN__ knows the size of the screen from the termcap data base -together with the value of the @code{TERM} environment variable and the -@code{stty rows} and @code{stty cols} settings. If this is not correct, -you can override it with the @code{set height} and @code{set -width} commands: - -@table @code -@item set height @var{lpp} -@itemx show height -@itemx set width @var{cpl} -@itemx show width -@kindex set height -@kindex set width -@kindex show width -@kindex show height -These @code{set} commands specify a screen height of @var{lpp} lines and -a screen width of @var{cpl} characters. The associated @code{show} -commands display the current settings. - -If you specify a height of zero lines, _GDBN__ will not pause during output -no matter how long the output is. This is useful if output is to a file -or to an editor buffer. -@end table - -@node Numbers, Messages/Warnings, Screen Size, Controlling _GDBN__ -@section Numbers -@cindex number representation -@cindex entering numbers -You can always enter numbers in octal, decimal, or hexadecimal in _GDBN__ by -the usual conventions: octal numbers begin with @samp{0}, decimal -numbers end with @samp{.}, and hexadecimal numbers begin with @samp{0x}. -Numbers that begin with none of these are, by default, entered in base -10; likewise, the default display for numbers---when no particular -format is specified---is base 10. You can change the default base for -both input and output with the @code{set radix} command. - -@table @code -@kindex set radix -@item set radix @var{base} -Set the default base for numeric input and display. Supported choices -for @var{base} are decimal 2, 8, 10, 16. @var{base} must itself be -specified either unambiguously or using the current default radix; for -example, any of - -@example -set radix 1010 -set radix 012 -set radix 10. -set radix 0xa -@end example - -@noindent -will set the base to decimal. On the other hand, @samp{set radix 10} -will leave the radix unchanged no matter what it was. - -@kindex show radix -@item show radix -Display the current default base for numeric input and display. - -@end table - -@node Messages/Warnings, , Numbers, Controlling _GDBN__ -@section Optional Warnings and Messages -By default, _GDBN__ is silent about its inner workings. If you are running -on a slow machine, you may want to use the @code{set verbose} command. -It will make _GDBN__ tell you when it does a lengthy internal operation, so -you won't think it has crashed. - -Currently, the messages controlled by @code{set verbose} are those which -announce that the symbol table for a source file is being read -(@pxref{Files}, in the description of the command -@code{symbol-file}). -@c The following is the right way to do it, but emacs 18.55 doesn't support -@c @ref, and neither the emacs lisp manual version of texinfmt or makeinfo -@c is released. -@ignore -see @code{symbol-file} in @ref{Files}). -@end ignore - -@table @code -@kindex set verbose -@item set verbose on -Enables _GDBN__'s output of certain informational messages. - -@item set verbose off -Disables _GDBN__'s output of certain informational messages. - -@kindex show verbose -@item show verbose -Displays whether @code{set verbose} is on or off. -@end table - -By default, if _GDBN__ encounters bugs in the symbol table of an object -file, it is silent; but if you are debugging a compiler, you may find -this information useful (@pxref{Symbol Errors}). - -@table @code -@kindex set complaints -@item set complaints @var{limit} -Permits _GDBN__ to output @var{limit} complaints about each type of unusual -symbols before becoming silent about the problem. Set @var{limit} to -zero to suppress all complaints; set it to a large number to prevent -complaints from being suppressed. - -@kindex show complaints -@item show complaints -Displays how many symbol complaints _GDBN__ is permitted to produce. -@end table - -By default, _GDBN__ is cautious, and asks what sometimes seem to be a -lot of stupid questions to confirm certain commands. For example, if -you try to run a program which is already running: -@example -(_GDBP__) run -The program being debugged has been started already. -Start it from the beginning? (y or n) -@end example - -If you're willing to unflinchingly face the consequences of your own -commands, you can disable this ``feature'': - -@table @code -@kindex set confirm -@cindex flinching -@cindex confirmation -@cindex stupid questions -@item set confirm off -Disables confirmation requests. - -@item set confirm on -Enables confirmation requests (the default). - -@item show confirm -@kindex show confirm -Displays state of confirmation requests. -@end table - -@c FIXME this doesn't really belong here. But where *does* it belong? -@cindex reloading symbols -Some systems allow individual object files that make up your program to -be replaced without stopping and restarting your program. -_if__(_VXWORKS__) -For example, in VxWorks you can simply recompile a defective object file -and keep on running. -_fi__(_VXWORKS__) -If you're running on one of these systems, you can allow _GDBN__ to -reload the symbols for automatically relinked modules:@refill -@table @code -@kindex set symbol-reloading -@item set symbol-reloading on -Replace symbol definitions for the corresponding source file when an -object file with a particular name is seen again. - -@item set symbol-reloading off -Don't replace symbol definitions when re-encountering object files of -the same name. This is the default state; if you're not running on a -system that permits automatically relinking modules, you should leave -@code{symbol-reloading} off, since otherwise _GDBN__ may discard symbols -when linking large programs, that may contain several modules (from -different directories or libraries) with the same name. - -@item show symbol-reloading -Show the current @code{on} or @code{off} setting. -@end table - -@node Sequences, Emacs, Controlling _GDBN__, Top -@chapter Canned Sequences of Commands - -Aside from breakpoint commands (@pxref{Break Commands}), _GDBN__ provides two -ways to store sequences of commands for execution as a unit: -user-defined commands and command files. - -@menu -* Define:: User-Defined Commands -* Command Files:: Command Files -* Output:: Commands for Controlled Output -@end menu - -@node Define, Command Files, Sequences, Sequences -@section User-Defined Commands - -@cindex user-defined command -A @dfn{user-defined command} is a sequence of _GDBN__ commands to which you -assign a new name as a command. This is done with the @code{define} -command. - -@table @code -@item define @var{commandname} -@kindex define -Define a command named @var{commandname}. If there is already a command -by that name, you are asked to confirm that you want to redefine it. - -The definition of the command is made up of other _GDBN__ command lines, -which are given following the @code{define} command. The end of these -commands is marked by a line containing @code{end}. - -@item document @var{commandname} -@kindex document -Give documentation to the user-defined command @var{commandname}. The -command @var{commandname} must already be defined. This command reads -lines of documentation just as @code{define} reads the lines of the -command definition, ending with @code{end}. After the @code{document} -command is finished, @code{help} on command @var{commandname} will print -the documentation you have specified. - -You may use the @code{document} command again to change the -documentation of a command. Redefining the command with @code{define} -does not change the documentation. - -@item help user-defined -@kindex help user-defined -List all user-defined commands, with the first line of the documentation -(if any) for each. - -@item info user -@itemx info user @var{commandname} -@kindex info user -Display the _GDBN__ commands used to define @var{commandname} (but not its -documentation). If no @var{commandname} is given, display the -definitions for all user-defined commands. -@end table - -User-defined commands do not take arguments. When they are executed, the -commands of the definition are not printed. An error in any command -stops execution of the user-defined command. - -Commands that would ask for confirmation if used interactively proceed -without asking when used inside a user-defined command. Many _GDBN__ commands -that normally print messages to say what they are doing omit the messages -when used in a user-defined command. - -@node Command Files, Output, Define, Sequences -@section Command Files - -@cindex command files -A command file for _GDBN__ is a file of lines that are _GDBN__ commands. Comments -(lines starting with @kbd{#}) may also be included. An empty line in a -command file does nothing; it does not mean to repeat the last command, as -it would from the terminal. - -@cindex init file -@cindex @file{_GDBINIT__} -When you start _GDBN__, it automatically executes commands from its -@dfn{init files}. These are files named @file{_GDBINIT__}. _GDBN__ -reads the init file (if any) in your home directory and then the init -file (if any) in the current working directory. (The init files are not -executed if you use the @samp{-nx} option; @pxref{Mode Options}.) You -can also request the execution of a command file with the @code{source} -command: - -@table @code -@item source @var{filename} -@kindex source -Execute the command file @var{filename}. -@end table - -The lines in a command file are executed sequentially. They are not -printed as they are executed. An error in any command terminates execution -of the command file. - -Commands that would ask for confirmation if used interactively proceed -without asking when used in a command file. Many _GDBN__ commands that -normally print messages to say what they are doing omit the messages -when called from command files. - -@node Output, , Command Files, Sequences -@section Commands for Controlled Output - -During the execution of a command file or a user-defined command, normal -_GDBN__ output is suppressed; the only output that appears is what is -explicitly printed by the commands in the definition. This section -describes three commands useful for generating exactly the output you -want. - -@table @code -@item echo @var{text} -@kindex echo -@c I don't consider backslash-space a standard C escape sequence -@c because it's not in ANSI. -Print @var{text}. Nonprinting characters can be included in @var{text} -using C escape sequences, such as @samp{\n} to print a newline. @b{No -newline will be printed unless you specify one.} In addition to the -standard C escape sequences, a backslash followed by a space stands for a -space. This is useful for outputting a string with spaces at the -beginning or the end, since leading and trailing spaces are otherwise -trimmed from all arguments. Thus, to print @samp{@ and foo =@ }, use the -command @samp{echo \@ and foo = \@ }. -@c FIXME? '@ ' works in tex and info, but confuses texi2roff[-2]. - -A backslash at the end of @var{text} can be used, as in C, to continue -the command onto subsequent lines. For example, - -@example -echo This is some text\n\ -which is continued\n\ -onto several lines.\n -@end example - -produces the same output as - -@example -echo This is some text\n -echo which is continued\n -echo onto several lines.\n -@end example - -@item output @var{expression} -@kindex output -Print the value of @var{expression} and nothing but that value: no -newlines, no @samp{$@var{nn} = }. The value is not entered in the -value history either. @xref{Expressions} for more information on -expressions. - -@item output/@var{fmt} @var{expression} -Print the value of @var{expression} in format @var{fmt}. You can use -the same formats as for @code{print}; @pxref{Output formats}, for more -information. - -@item printf @var{string}, @var{expressions}@dots{} -@kindex printf -Print the values of the @var{expressions} under the control of -@var{string}. The @var{expressions} are separated by commas and may -be either numbers or pointers. Their values are printed as specified -by @var{string}, exactly as if the program were to execute - -@example -printf (@var{string}, @var{expressions}@dots{}); -@end example - -For example, you can print two values in hex like this: - -@example -printf "foo, bar-foo = 0x%x, 0x%x\n", foo, bar-foo -@end example - -The only backslash-escape sequences that you can use in the format -string are the simple ones that consist of backslash followed by a -letter. -@end table - -@node Emacs, _GDBN__ Bugs, Sequences, Top -@chapter Using _GDBN__ under GNU Emacs - -@cindex emacs -A special interface allows you to use GNU Emacs to view (and -edit) the source files for the program you are debugging with -_GDBN__. - -To use this interface, use the command @kbd{M-x gdb} in Emacs. Give the -executable file you want to debug as an argument. This command starts -_GDBN__ as a subprocess of Emacs, with input and output through a newly -created Emacs buffer. - -Using _GDBN__ under Emacs is just like using _GDBN__ normally except for two -things: - -@itemize @bullet -@item -All ``terminal'' input and output goes through the Emacs buffer. -@end itemize - -This applies both to _GDBN__ commands and their output, and to the input -and output done by the program you are debugging. - -This is useful because it means that you can copy the text of previous -commands and input them again; you can even use parts of the output -in this way. - -All the facilities of Emacs' Shell mode are available for interacting -with your program. In particular, you can send signals the usual -way---for example, @kbd{C-c C-c} for an interrupt, @kbd{C-c C-z} for a -stop. - -@itemize @bullet -@item -_GDBN__ displays source code through Emacs. -@end itemize - -Each time _GDBN__ displays a stack frame, Emacs automatically finds the -source file for that frame and puts an arrow (_0__@samp{=>}_1__) at the -left margin of the current line. Emacs uses a separate buffer for -source display, and splits the window to show both your _GDBN__ session -and the source. - -Explicit _GDBN__ @code{list} or search commands still produce output as -usual, but you probably will have no reason to use them. - -@quotation -@emph{Warning:} If the directory where your program resides is not your -current directory, it can be easy to confuse Emacs about the location of -the source files, in which case the auxiliary display buffer will not -appear to show your source. _GDBN__ can find programs by searching your -environment's @code{PATH} variable, so the _GDBN__ input and output -session will proceed normally; but Emacs doesn't get enough information -back from _GDBN__ to locate the source files in this situation. To -avoid this problem, either start _GDBN__ mode from the directory where -your program resides, or specify a full path name when prompted for the -@kbd{M-x gdb} argument. - -A similar confusion can result if you use the _GDBN__ @code{file} command to -switch to debugging a program in some other location, from an existing -_GDBN__ buffer in Emacs. -@end quotation - -By default, @kbd{M-x gdb} calls the program called @file{gdb}. If -you need to call _GDBN__ by a different name (for example, if you keep -several configurations around, with different names) you can set the -Emacs variable @code{gdb-command-name}; for example, -@example -(setq gdb-command-name "mygdb") -@end example -@noindent -(preceded by @kbd{ESC ESC}, or typed in the @code{*scratch*} buffer, or -in your @file{.emacs} file) will make Emacs call the program named -``@code{mygdb}'' instead. - -In the _GDBN__ I/O buffer, you can use these special Emacs commands in -addition to the standard Shell mode commands: - -@table @kbd -@item C-h m -Describe the features of Emacs' _GDBN__ Mode. - -@item M-s -Execute to another source line, like the _GDBN__ @code{step} command; also -update the display window to show the current file and location. - -@item M-n -Execute to next source line in this function, skipping all function -calls, like the _GDBN__ @code{next} command. Then update the display window -to show the current file and location. - -@item M-i -Execute one instruction, like the _GDBN__ @code{stepi} command; update -display window accordingly. - -@item M-x gdb-nexti -Execute to next instruction, using the _GDBN__ @code{nexti} command; update -display window accordingly. - -@item C-c C-f -Execute until exit from the selected stack frame, like the _GDBN__ -@code{finish} command. - -@item M-c -Continue execution of the program, like the _GDBN__ @code{continue} -command. - -@emph{Warning:} In Emacs v19, this command is @kbd{C-c C-p}. - -@item M-u -Go up the number of frames indicated by the numeric argument -(@pxref{Arguments, , Numeric Arguments, emacs, The GNU Emacs Manual}), -like the _GDBN__ @code{up} command. - -@emph{Warning:} In Emacs v19, this command is @kbd{C-c C-u}.@refill - -@item M-d -Go down the number of frames indicated by the numeric argument, like the -_GDBN__ @code{down} command. - -@emph{Warning:} In Emacs v19, this command is @kbd{C-c C-d}. - -@item C-x & -Read the number where the cursor is positioned, and insert it at the end -of the _GDBN__ I/O buffer. For example, if you wish to disassemble code -around an address that was displayed earlier, type @kbd{disassemble}; -then move the cursor to the address display, and pick up the -argument for @code{disassemble} by typing @kbd{C-x &}. - -You can customize this further on the fly by defining elements of the list -@code{gdb-print-command}; once it is defined, you can format or -otherwise process numbers picked up by @kbd{C-x &} before they are -inserted. A numeric argument to @kbd{C-x &} will both indicate that you -wish special formatting, and act as an index to pick an element of the -list. If the list element is a string, the number to be inserted is -formatted using the Emacs function @code{format}; otherwise the number -is passed as an argument to the corresponding list element. - -@end table - -In any source file, the Emacs command @kbd{C-x SPC} (@code{gdb-break}) -tells _GDBN__ to set a breakpoint on the source line point is on. - -If you accidentally delete the source-display buffer, an easy way to get -it back is to type the command @code{f} in the _GDBN__ buffer, to -request a frame display; when you run under Emacs, this will recreate -the source buffer if necessary to show you the context of the current -frame. - -The source files displayed in Emacs are in ordinary Emacs buffers -which are visiting the source files in the usual way. You can edit -the files with these buffers if you wish; but keep in mind that _GDBN__ -communicates with Emacs in terms of line numbers. If you add or -delete lines from the text, the line numbers that _GDBN__ knows will cease -to correspond properly to the code. - -@c The following dropped because Epoch is nonstandard. Reactivate -@c if/when v19 does something similar. ---pesch@cygnus.com 19dec1990 -@ignore -@kindex emacs epoch environment -@kindex epoch -@kindex inspect - -Version 18 of Emacs has a built-in window system called the @code{epoch} -environment. Users of this environment can use a new command, -@code{inspect} which performs identically to @code{print} except that -each value is printed in its own window. -@end ignore - -@node _GDBN__ Bugs, Renamed Commands, Emacs, Top -@chapter Reporting Bugs in _GDBN__ -@cindex Bugs in _GDBN__ -@cindex Reporting Bugs in _GDBN__ - -Your bug reports play an essential role in making _GDBN__ reliable. - -Reporting a bug may help you by bringing a solution to your problem, or it -may not. But in any case the principal function of a bug report is to help -the entire community by making the next version of _GDBN__ work better. Bug -reports are your contribution to the maintenance of _GDBN__. - -In order for a bug report to serve its purpose, you must include the -information that enables us to fix the bug. - -@menu -* Bug Criteria:: Have You Found a Bug? -* Bug Reporting:: How to Report Bugs -@end menu - -@node Bug Criteria, Bug Reporting, _GDBN__ Bugs, _GDBN__ Bugs -@section Have You Found a Bug? -@cindex Bug Criteria - -If you are not sure whether you have found a bug, here are some guidelines: - -@itemize @bullet -@item -@cindex Fatal Signal -@cindex Core Dump -If the debugger gets a fatal signal, for any input whatever, that is a -_GDBN__ bug. Reliable debuggers never crash. - -@item -@cindex error on Valid Input -If _GDBN__ produces an error message for valid input, that is a bug. - -@item -@cindex Invalid Input -If _GDBN__ does not produce an error message for invalid input, -that is a bug. However, you should note that your idea of -``invalid input'' might be our idea of ``an extension'' or ``support -for traditional practice''. - -@item -If you are an experienced user of debugging tools, your suggestions -for improvement of _GDBN__ are welcome in any case. -@end itemize - -@node Bug Reporting, , Bug Criteria, _GDBN__ Bugs -@section How to Report Bugs -@cindex Bug Reports -@cindex _GDBN__ Bugs, Reporting - -A number of companies and individuals offer support for GNU products. -If you obtained _GDBN__ from a support organization, we recommend you -contact that organization first. - -Contact information for many support companies and individuals is -available in the file @file{etc/SERVICE} in the GNU Emacs distribution. - -In any event, we also recommend that you send bug reports for _GDBN__ to one -of these addresses: - -@example -bug-gdb@@prep.ai.mit.edu -@{ucbvax|mit-eddie|uunet@}!prep.ai.mit.edu!bug-gdb -@end example - -@strong{Do not send bug reports to @samp{info-gdb}, or to -@samp{help-gdb}, or to any newsgroups.} Most users of _GDBN__ do not want to -receive bug reports. Those that do, have arranged to receive @samp{bug-gdb}. - -The mailing list @samp{bug-gdb} has a newsgroup @samp{gnu.gdb.bug} which -serves as a repeater. The mailing list and the newsgroup carry exactly -the same messages. Often people think of posting bug reports to the -newsgroup instead of mailing them. This appears to work, but it has one -problem which can be crucial: a newsgroup posting often lacks a mail -path back to the sender. Thus, if we need to ask for more information, -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 -GNU Debugger Bugs -Free Software Foundation -545 Tech Square -Cambridge, MA 02139 -@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! - -Often people omit facts because they think they know what causes the -problem and assume that some details don't matter. Thus, you might -assume that the name of the variable you use in an example does not matter. -Well, probably it doesn't, but one cannot be sure. Perhaps the bug is a -stray memory reference which happens to fetch from the location where that -name is stored in memory; perhaps, if the name were different, the contents -of that location would fool the debugger into doing the right thing despite -the bug. Play it safe and give a specific, complete example. That is the -easiest thing for you to do, and the most helpful. - -Keep in mind that the purpose of a bug report is to enable us to fix -the bug if it is new to us. It isn't as important what happens if -the bug is already known. Therefore, always write your bug reports on -the assumption that the bug has not been reported previously. - -Sometimes people give a few sketchy facts and ask, ``Does this ring a -bell?'' Those bug reports are useless, and we urge everyone to -@emph{refuse to respond to them} except to chide the sender to report -bugs properly. - -To enable us to fix the bug, you should include all these things: - -@itemize @bullet -@item -The version of _GDBN__. _GDBN__ announces it if you start with no -arguments; you can also print it at any time using @code{show version}. - -Without this, we won't know whether there is any point in looking for -the bug in the current version of _GDBN__. - -@item -A complete input script, and all necessary source files, that will -reproduce the bug. - -@item -What compiler (and its version) was used to compile _GDBN__---e.g. -``_GCC__-1.37.1''. - -@item -The command arguments you gave the compiler to compile your example and -observe the bug. For example, did you use @samp{-O}? To guarantee -you won't omit something important, list them all. - -If we were to try to guess the arguments, we would probably guess wrong -and then we might not encounter the bug. - -@item -The type of machine you are using, and the operating system name and -version number. - -@item -A description of what behavior you observe that you believe is -incorrect. For example, ``It gets a fatal signal.'' - -Of course, if the bug is that _GDBN__ gets a fatal signal, then we will -certainly notice it. But if the bug is incorrect output, we might not -notice unless it is glaringly wrong. We are human, after all. You -might as well not give us a chance to make a mistake. - -Even if the problem you experience is a fatal signal, you should still -say so explicitly. Suppose something strange is going on, such as, -your copy of _GDBN__ is out of synch, or you have encountered a -bug in the C library on your system. (This has happened!) Your copy -might crash and ours would not. If you told us to expect a crash, -then when ours fails to crash, we would know that the bug was not -happening for us. If you had not told us to expect a crash, then we -would not be able to draw any conclusion from our observations. - -@item -If you wish to suggest changes to the _GDBN__ source, send us context -diffs. If you even discuss something in the _GDBN__ source, refer to -it by context, not by line number. - -The line numbers in our development sources won't match those in your -sources. Your line numbers would convey no useful information to us. - -@end itemize - -Here are some things that are not necessary: - -@itemize @bullet -@item -A description of the envelope of the bug. - -Often people who encounter a bug spend a lot of time investigating -which changes to the input file will make the bug go away and which -changes will not affect it. - -This is often time consuming and not very useful, because the way we -will find the bug is by running a single example under the debugger -with breakpoints, not by pure deduction from a series of examples. -We recommend that you save your time for something else. - -Of course, if you can find a simpler example to report @emph{instead} -of the original one, that is a convenience for us. Errors in the -output will be easier to spot, running under the debugger will take -less time, etc. - -However, simplification is not vital; if you don't want to do this, -report the bug anyway and send us the entire test case you used. - -@item -A patch for the bug. - -A patch for the bug does help us if it is a good one. But don't omit -the necessary information, such as the test case, on the assumption that -a patch is all we need. We might see problems with your patch and decide -to fix the problem another way, or we might not understand it at all. - -Sometimes with a program as complicated as _GDBN__ it is very hard to -construct an example that will make the program follow a certain path -through the code. If you don't send us the example, we won't be able -to construct one, so we won't be able to verify that the bug is fixed. - -And if we can't understand what bug you are trying to fix, or why your -patch should be an improvement, we won't install it. A test case will -help us to understand. - -@item -A guess about what the bug is or what it depends on. - -Such guesses are usually wrong. Even we can't guess right about such -things without first using the debugger to find the facts. -@end itemize - -@iftex -@include rdl-apps.texi -@end iftex - -@node Renamed Commands, Installing _GDBN__, _GDBN__ Bugs, Top -@appendix Renamed Commands - -The following commands were renamed in _GDBN__ 4.0, in order to make the -command set as a whole more consistent and easier to use and remember: - -@kindex add-syms -@kindex delete environment -@kindex info copying -@kindex info convenience -@kindex info directories -@kindex info editing -@kindex info history -@kindex info targets -@kindex info values -@kindex info version -@kindex info warranty -@kindex set addressprint -@kindex set arrayprint -@kindex set prettyprint -@kindex set screen-height -@kindex set screen-width -@kindex set unionprint -@kindex set vtblprint -@kindex set demangle -@kindex set asm-demangle -@kindex set sevenbit-strings -@kindex set array-max -@kindex set caution -@kindex set history write -@kindex show addressprint -@kindex show arrayprint -@kindex show prettyprint -@kindex show screen-height -@kindex show screen-width -@kindex show unionprint -@kindex show vtblprint -@kindex show demangle -@kindex show asm-demangle -@kindex show sevenbit-strings -@kindex show array-max -@kindex show caution -@kindex show history write -@kindex unset - -@c TEXI2ROFF-KILL -@ifinfo -@c END TEXI2ROFF-KILL -@example -OLD COMMAND NEW COMMAND -@c TEXI2ROFF-KILL ---------------- ------------------------------- -@c END TEXI2ROFF-KILL -add-syms add-symbol-file -delete environment unset environment -info convenience show convenience -info copying show copying -info directories show directories -info editing show commands -info history show values -info targets help target -info values show values -info version show version -info warranty show warranty -set/show addressprint set/show print address -set/show array-max set/show print elements -set/show arrayprint set/show print array -set/show asm-demangle set/show print asm-demangle -set/show caution set/show confirm -set/show demangle set/show print demangle -set/show history write set/show history save -set/show prettyprint set/show print pretty -set/show screen-height set/show height -set/show screen-width set/show width -set/show sevenbit-strings set/show print sevenbit-strings -set/show unionprint set/show print union -set/show vtblprint set/show print vtbl - -unset [No longer an alias for delete] -@end example -@c TEXI2ROFF-KILL -@end ifinfo - -@tex -\vskip \parskip\vskip \baselineskip -\halign{\tt #\hfil &\qquad#&\tt #\hfil\cr -{\bf Old Command} &&{\bf New Command}\cr -add-syms &&add-symbol-file\cr -delete environment &&unset environment\cr -info convenience &&show convenience\cr -info copying &&show copying\cr -info directories &&show directories \cr -info editing &&show commands\cr -info history &&show values\cr -info targets &&help target\cr -info values &&show values\cr -info version &&show version\cr -info warranty &&show warranty\cr -set{\rm / }show addressprint &&set{\rm / }show print address\cr -set{\rm / }show array-max &&set{\rm / }show print elements\cr -set{\rm / }show arrayprint &&set{\rm / }show print array\cr -set{\rm / }show asm-demangle &&set{\rm / }show print asm-demangle\cr -set{\rm / }show caution &&set{\rm / }show confirm\cr -set{\rm / }show demangle &&set{\rm / }show print demangle\cr -set{\rm / }show history write &&set{\rm / }show history save\cr -set{\rm / }show prettyprint &&set{\rm / }show print pretty\cr -set{\rm / }show screen-height &&set{\rm / }show height\cr -set{\rm / }show screen-width &&set{\rm / }show width\cr -set{\rm / }show sevenbit-strings &&set{\rm / }show print sevenbit-strings\cr -set{\rm / }show unionprint &&set{\rm / }show print union\cr -set{\rm / }show vtblprint &&set{\rm / }show print vtbl\cr -\cr -unset &&\rm(No longer an alias for delete)\cr -} -@end tex -@c END TEXI2ROFF-KILL - -@node Installing _GDBN__, Copying, Renamed Commands, Top -@appendix Installing _GDBN__ -@cindex configuring _GDBN__ -@cindex installation - -_GDBN__ comes with a @code{configure} script that automates the process -of preparing _GDBN__ for installation; you can then use @code{make} to -build the @code{_GDBP__} program. - -The _GDBP__ distribution includes all the source code you need for -_GDBP__ in a single directory @file{gdb-_GDB_VN__}. That directory in turn -contains: - -@table @code -@item gdb-_GDB_VN__/configure @r{(and supporting files)} -script for configuring _GDBN__ and all its supporting libraries. - -@item gdb-_GDB_VN__/gdb -the source specific to _GDBN__ itself - -@item gdb-_GDB_VN__/bfd -source for the Binary File Descriptor Library - -@item gdb-_GDB_VN__/include -GNU include files - -@item gdb-_GDB_VN__/libiberty -source for the @samp{-liberty} free software library - -@item gdb-_GDB_VN__/readline -source for the GNU command-line interface -@end table -@noindent -It is most convenient to run @code{configure} from the @file{gdb-_GDB_VN__} -directory. The simplest way to configure and build _GDBN__ is the -following: -@example -cd gdb-_GDB_VN__ -./configure @var{host} -make -@end example -@noindent -where @var{host} is something like @samp{sun4} or @samp{decstation}, that -identifies the platform where _GDBN__ will run. This builds the three -libraries @file{bfd}, @file{readline}, and @file{libiberty}, then -@code{gdb} itself. The configured source files, and the binaries, are -left in the corresponding source directories. - -@code{configure} is a Bourne-shell (@code{/bin/sh}) script; if your -system doesn't recognize this automatically when you run a different -shell, you may need to run @code{sh} on it explicitly: -@samp{sh configure @var{host}}. - -You can @emph{run} the @code{configure} script from any of the -subordinate directories in the _GDBN__ distribution (if you only want to -configure that subdirectory); but be sure to specify a path to it. For -example, to configure only the @code{bfd} subdirectory, -@example -@group -cd gdb-_GDB_VN__/bfd -../configure @var{host} -@end group -@end example - -You can install @code{_GDBP__} anywhere; it has no hardwired paths. However, -you should make sure that the shell on your path (named by the -@samp{SHELL} environment variable) is publicly readable; some systems -refuse to let _GDBN__ debug child processes whose programs are not -readable, and _GDBN__ uses the shell to start your program. - -@menu -* Subdirectories:: Configuration subdirectories -* Config Names:: Specifying names for hosts and targets -* configure Options:: Summary of options for configure -* Formatting Documentation:: How to format and print _GDBN__ documentation -@end menu - - -@node Subdirectories, Config Names, Installing _GDBN__, Installing _GDBN__ -@section Configuration Subdirectories -If you want to run _GDBN__ versions for several host or target machines, -you'll need a different _GDBP__ compiled for each combination of host -and target. @code{configure} is designed to make this easy by allowing -you to generate each configuration in a separate subdirectory. If your -@code{make} program handles the @samp{VPATH} feature (GNU @code{make} -does), running @code{make} in each of these directories then builds the -_GDBP__ program specified there. - -@code{configure} creates these subdirectories for you when you -simultaneously specify several configurations; but it's a good habit -even for a single configuration. You can specify the use of -subdirectories using the @samp{+subdirs} option (abbreviated -@samp{+sub}). For example, you can build _GDBN__ this way on a Sun 4 as -follows: - -@example -@group -cd gdb-_GDB_VN__ -./configure +sub sun4 -cd H-sun4/T-sun4 -make -@end group -@end example - -When @code{configure} uses subdirectories to build programs or -libraries, it creates nested directories -@file{H-@var{host}/T-@var{target}}. @code{configure} uses these two -directory levels because _GDBN__ can be configured for cross-compiling: -_GDBN__ can run on one machine (the host) while debugging programs that -run on another machine (the target). You specify cross-debugging -targets by giving the @samp{+target=@var{target}} option to -@code{configure}. Specifying only hosts still gives you two levels of -subdirectory for each host, with the same configuration suffix on both; -that is, if you give any number of hosts but no targets, _GDBN__ will be -configured for native debugging on each host. On the other hand, -whenever you specify both hosts and targets on the same command line, -@code{configure} creates all combinations of the hosts and targets you -list.@refill - -If you run @code{configure} from a directory (notably, -@file{gdb-_GDB_VN__}) that contains source directories for multiple -libraries or programs, @code{configure} creates the -@file{H-@var{host}/T-@var{target}} subdirectories in each library or -program's source directory. For example, typing: -@example -cd gdb-_GDB_VN__ -configure sun4 +target=vxworks960 -@end example -@noindent -creates the following directories: -@example -gdb-_GDB_VN__/H-sun4/T-vxworks960 -gdb-_GDB_VN__/bfd/H-sun4/T-vxworks960 -gdb-_GDB_VN__/gdb/H-sun4/T-vxworks960 -gdb-_GDB_VN__/libiberty/H-sun4/T-vxworks960 -gdb-_GDB_VN__/readline/H-sun4/T-vxworks960 -@end example - -When you run @code{make} to build a program or library, you must run it -in a configured directory. If you made a single configuration, -without subdirectories, run @code{make} in the source directory. -If you have @file{H-@var{host}/T-@var{target}} subdirectories, -run @code{make} in those subdirectories. - -The @code{Makefile} generated by @code{configure} for each source -directory runs recursively, so that typing @code{make} in -@file{gdb-_GDB_VN__} (or in a -@file{gdb-_GDB_VN__/H-@var{host}/T-@var{target}} subdirectory) builds -all the required libraries, then _GDBN__.@refill - -When you have multiple hosts or targets configured, you can run -@code{make} on them in parallel (for example, if they are NFS-mounted on -each of the hosts); they will not interfere with each other. - -You can also use the @samp{+objdir=@var{altroot}} option to have the -configured files placed in a parallel directory structure rather than -alongside the source files; @pxref{configure Options}. - -@node Config Names, configure Options, Subdirectories, Installing _GDBN__ -@section Specifying Names for Hosts and Targets - -The specifications used for hosts and targets in the @code{configure} -script are based on a three-part naming scheme, but some short predefined -aliases are also supported. The full naming scheme encodes three pieces -of information in the following pattern: -@example -@var{architecture}-@var{vendor}-@var{os} -@end example - -For example, you can use the alias @code{sun4} as a @var{host} argument -or in a @code{+target=@var{target}} option, but the equivalent full name -is @samp{sparc-sun-sunos4}. - -The following table shows all the architectures, hosts, and OS prefixes -that @code{configure} recognizes in _GDBN__ _GDB_VN__. Entries in the ``OS -prefix'' column ending in a @samp{*} may be followed by a release number. - -@c TEXI2ROFF-KILL -@ifinfo -@c END TEXI2ROFF-KILL -@example - -ARCHITECTURE VENDOR OS prefix -@c TEXI2ROFF-KILL -------------+--------------------------+--------------------------- -@c END TEXI2ROFF-KILL - | | - 580 | altos hp | aix* msdos* - a29k | amd ibm | amigados newsos* - alliant | amdahl intel | aout nindy* - arm | aout isi | bout osf* - c1 | apollo little | bsd* sco* - c2 | att mips | coff sunos* - cray2 | bcs motorola | ctix* svr4 - h8300 | bout ncr | dgux* sym* - i386 | bull next | dynix* sysv* - i860 | cbm nyu | ebmon ultrix* - i960 | coff sco | esix* unicos* - m68000 | convergent sequent | hds unos* - m68k | convex sgi | hpux* uts - m88k | cray sony | irix* v88r* - mips | dec sun | isc* vms* - ns32k | encore unicom | kern vxworks* - pyramid | gould utek | mach* - romp | hitachi wrs | - rs6000 | | - sparc | | - tahoe | | - tron | | - vax | | - xmp | | - ymp | | -@end example -@c TEXI2ROFF-KILL -@end ifinfo -@tex -%\vskip\parskip -\vskip \baselineskip -\hfil\vbox{\offinterlineskip -\halign{\strut\tt #\hfil\ &\vrule#&\strut\ \tt #\hfil\ &\strut\ \tt #\hfil -\ &\vrule#&\strut\ \tt #\hfil\ &\strut\ \tt #\hfil \cr -{\bf Architecture} &&{\bf Vendor} &&&{\bf OS prefix}\cr -\multispan7\hrulefill\cr - 580 && altos & hp && aix* & msdos* \cr - a29k && amd & ibm && amigados & newsos* \cr - alliant && amdahl & intel && aout & nindy* \cr - arm && aout & isi && bout & osf* \cr - c1 && apollo & little && bsd* & sco* \cr - c2 && att & mips && coff & sunos* \cr - cray2 && bcs & motorola && ctix* & svr4 \cr - h8300 && bout & ncr && dgux* & sym* \cr - i386 && bull & next && dynix* & sysv* \cr - i860 && cbm & nyu && ebmon & ultrix* \cr - i960 && coff & sco && esix* & unicos* \cr - m68000 && convergent& sequent && hds & unos* \cr - m68k && convex & sgi && hpux* & uts \cr - m88k && cray & sony && irix* & v88r* \cr - mips && dec & sun && isc* & vms* \cr - ns32k && encore & unicom && kern & vxworks* \cr - pyramid && gould & utek && mach* & \cr - romp && hitachi & wrs && & \cr - rs6000 && & && & \cr - sparc && & && & \cr - tahoe && & && & \cr - tron && & && & \cr - vax && & && & \cr - xmp && & && & \cr - ymp && & && & \cr -}\hfil} -@end tex -@c END TEXI2ROFF-KILL -@quotation -@emph{Warning:} Many combinations of architecture, vendor, and OS are -untested. -@end quotation - -The @code{configure} script accompanying _GDBN__ _GDB_VN__ does not provide -any query facility to list all supported host and target names or -aliases. @code{configure} calls the Bourne shell script -@code{config.sub} to map abbreviations to full names; you can read the -script, if you wish, or you can use it to test your guesses on -abbreviations---for example: -@example -% sh config.sub sun4 -sparc-sun-sunos4 -% sh config.sub sun3 -m68k-sun-sunos4 -% sh config.sub decstation -mips-dec-ultrix -% sh config.sub hp300bsd -m68k-hp-bsd -% sh config.sub i386v -i386-none-sysv -% sh config.sub i486v -*** Configuration "i486v" not recognized -@end example -@noindent -@code{config.sub} is also distributed in the directory @file{gdb-_GDB_VN__}. - -@node configure Options, Formatting Documentation, Config Names, Installing _GDBN__ -@section @code{configure} Options - -Here is a summary of all the @code{configure} options and arguments that -you might use for building _GDBN__: - -@example -configure @r{[}+destdir=@var{dir}@r{]} @r{[}+subdirs@r{]} - @r{[}+objdir=@var{altroot}@r{]} @r{[}+norecursion@r{]} @r{[}+rm@r{]} - @r{[}+target=@var{target}@dots{}@r{]} @var{host}@dots{} -@end example -@noindent -You may introduce options with the character @samp{-} rather than -@samp{+} if you prefer; but you may abbreviate option names if you use -@samp{+}. - -@table @code -@item +destdir=@var{dir} -@var{dir} is an installation directory @emph{path prefix}. After you -configure with this option, @code{make install} will install _GDBN__ as -@file{@var{dir}/bin/_GDBP__}, and the libraries in @file{@var{dir}/lib}. -If you specify @samp{+destdir=/usr/local}, for example, @code{make -install} creates @file{/usr/local/bin/gdb}.@refill - -@item +subdirs -Write configuration specific files in subdirectories of the form -@example -H-@var{host}/T-@var{target} -@end example -@noindent -(and configure the @code{Makefile} to generate object code in -subdirectories of this form as well). Without this option, if you -specify only one configuration for _GDBN__, @code{configure} will use -the same directory for source, configured files, and binaries. This -option is used automatically if you specify more than one @var{host} or -more than one @samp{+target=@var{target}} option on the @code{configure} -command line. - -@item +norecursion -Configure only the directory where @code{configure} is executed; do not -propagate configuration to subdirectories. - -@item +objdir=@var{altroot} -@var{altroot} is an alternative directory used as the root for -configured files. @code{configure} will create directories under -@var{altroot} in parallel to the source directories. If you use -@samp{+objdir=@var{altroot}} with @samp{+subdirs}, @code{configure} also -builds the @samp{H-@var{host}/T-@var{target}} subdirectories in the -directory tree rooted in @var{altroot}. - - -@item +rm -Remove the configuration that the other arguments specify. - -@c This doesn't work (yet if ever). FIXME. -@c @item +parse=@var{lang} @dots{} -@c Configure the _GDBN__ expression parser to parse the listed languages. -@c @samp{all} configures _GDBN__ for all supported languages. To get a -@c list of all supported languages, omit the argument. Without this -@c option, _GDBN__ is configured to parse all supported languages. - -@item +target=@var{target} @dots{} -Configure _GDBN__ for cross-debugging programs running on each specified -@var{target}. You may specify as many @samp{+target} options as you -wish. Without this option, _GDBN__ is configured to debug programs that -run on the same machine (@var{host}) as _GDBN__ itself. - -There is no convenient way to generate a list of all available targets. - -@item @var{host} @dots{} -Configure _GDBN__ to run on each specified @var{host}. You may specify as -many host names as you wish. - -There is no convenient way to generate a list of all available hosts. -@end table - -@noindent -@code{configure} accepts other options, for compatibility with -configuring other GNU tools recursively; but these are the only -options that affect _GDBN__ or its supporting libraries. - -@node Formatting Documentation, , configure Options, Installing _GDBN__ -@section Formatting the Documentation - -@cindex _GDBN__ reference card -@cindex reference card -The _GDBN__ _GDB_VN__ release includes an already-formatted reference card, -ready for printing on a PostScript printer, as @file{gdb-_GDB_VN__/gdb/refcard.ps}. -It uses the most common PostScript fonts: the Times family, Courier, and -Symbol. If you have a PostScript printer, you can print the reference -card by just sending @file{refcard.ps} to the printer. - -The release also includes the online Info version of this manual already -formatted: the main Info file is @file{gdb-_GDB_VN__/gdb/gdb.info}, and it -refers to subordinate files matching @samp{gdb.info*} in the same -directory. - -If you want to make these Info files yourself from the _GDBN__ manual's -source, you need the GNU @code{makeinfo} program. Once you have it, you -can type -@example -cd gdb-_GDB_VN__/gdb -make gdb.info -@end example -@noindent -to make the Info file. - -If you want to format and print copies of the manual, you need several -things: -@itemize @bullet -@item -@TeX{}, the public domain typesetting program written by Donald Knuth, -must be installed on your system and available through your execution -path. -@item -@file{gdb-_GDB_VN__/texinfo}: @TeX{} macros defining the GNU -Documentation Format. -@item -@emph{A @sc{dvi} output program.} @TeX{} doesn't actually make marks on -paper; it produces output files called @sc{dvi} files. If your system -has @TeX{} installed, chances are it has a program for printing out -these files; one popular example is @code{dvips}, which can print -@sc{dvi} files on PostScript printers. -@end itemize -@noindent -Once you have these things, you can type -@example -cd gdb-_GDB_VN__/gdb -make gdb.dvi -@end example -@noindent -to format the text of this manual, and print it with the usual output -method for @TeX{} @sc{dvi} files at your site. - -If you want to print the reference card, but don't have a PostScript -printer, or you want to use Computer Modern fonts instead, -you can still print it if you have @TeX{}. Format the reference card by typing -@example -cd gdb-_GDB_VN__/gdb -make refcard.dvi -@end example -@noindent - -The _GDBN__ reference card is designed to print in landscape mode on US -``letter'' size paper; that is, on a sheet 11 inches wide by 8.5 inches -high. You will need to specify this form of printing as an option to -your @sc{dvi} output program. - - -@node Copying, Index, Installing _GDBN__, Top -@unnumbered GNU GENERAL PUBLIC LICENSE -@center Version 2, June 1991 - -@display -Copyright @copyright{} 1989, 1991 Free Software Foundation, Inc. -675 Mass Ave, Cambridge, MA 02139, USA - -Everyone is permitted to copy and distribute verbatim copies -of this license document, but changing it is not allowed. -@end display - -@unnumberedsec Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software---to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - -@iftex -@unnumberedsec TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION -@end iftex -@ifinfo -@center TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION -@end ifinfo - -@enumerate -@item -This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The ``Program'', below, -refers to any such program or work, and a ``work based on the Program'' -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term ``modification''.) Each licensee is addressed as ``you''. - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - -@item -You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - -@item -You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - -@alphaenumerate -@item -You must cause the modified files to carry prominent notices -stating that you changed the files and the date of any change. - -@item -You must cause any work that you distribute or publish, that in -whole or in part contains or is derived from the Program or any -part thereof, to be licensed as a whole at no charge to all third -parties under the terms of this License. - -@item -If the modified program normally reads commands interactively -when run, you must cause it, when started running for such -interactive use in the most ordinary way, to print or display an -announcement including an appropriate copyright notice and a -notice that there is no warranty (or else, saying that you provide -a warranty) and that users may redistribute the program under -these conditions, and telling the user how to view a copy of this -License. (Exception: if the Program itself is interactive but -does not normally print such an announcement, your work based on -the Program is not required to print an announcement.) -@end alphaenumerate - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - -@item -You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - -@alphaenumerate -@item -Accompany it with the complete corresponding machine-readable -source code, which must be distributed under the terms of Sections -1 and 2 above on a medium customarily used for software interchange; or, - -@item -Accompany it with a written offer, valid for at least three -years, to give any third party, for a charge no more than your -cost of physically performing source distribution, a complete -machine-readable copy of the corresponding source code, to be -distributed under the terms of Sections 1 and 2 above on a medium -customarily used for software interchange; or, - -@item -Accompany it with the information you received as to the offer -to distribute corresponding source code. (This alternative is -allowed only for noncommercial distribution and only if you -received the program in object code or executable form with such -an offer, in accord with Subsection b above.) -@end alphaenumerate - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - -@item -You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - -@item -You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - -@item -Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - -@item -If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - -@item -If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - -@item -The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and ``any -later version'', you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - -@item -If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - -@iftex -@heading NO WARRANTY -@end iftex -@ifinfo -@center NO WARRANTY -@end ifinfo - -@item -BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM ``AS IS'' WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - -@item -IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. -@end enumerate - -@iftex -@heading END OF TERMS AND CONDITIONS -@end iftex -@ifinfo -@center END OF TERMS AND CONDITIONS -@end ifinfo - -@page -@unnumberedsec Applying These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the ``copyright'' line and a pointer to where the full notice is found. - -@smallexample -@var{one line to give the program's name and an idea of what it does.} -Copyright (C) 19@var{yy} @var{name of author} - -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., 675 Mass Ave, -Cambridge, MA 02139, USA. -@end smallexample - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - -@smallexample -Gnomovision version 69, Copyright (C) 19@var{yy} @var{name of author} -Gnomovision comes with ABSOLUTELY NO WARRANTY; for details -type `show w'. This is free software, and you are welcome -to redistribute it under certain conditions; type `show c' -for details. -@end smallexample - -The hypothetical commands @samp{show w} and @samp{show c} should show -the appropriate parts of the General Public License. Of course, the -commands you use may be called something other than @samp{show w} and -@samp{show c}; they could even be mouse-clicks or menu items---whatever -suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a ``copyright disclaimer'' for the program, if -necessary. Here is a sample; alter the names: - -@smallexample -Yoyodyne, Inc., hereby disclaims all copyright interest in -the program `Gnomovision' (which makes passes at compilers) -written by James Hacker. - -@var{signature of Ty Coon}, 1 April 1989 -Ty Coon, President of Vice -@end smallexample - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. - - -@node Index, , Copying, Top -@unnumbered Index - -@printindex cp - -@tex -% I think something like @colophon should be in texinfo. In the -% meantime: -\long\def\colophon{\hbox to0pt{}\vfill -\centerline{The body of this manual is set in} -\centerline{\fontname\tenrm,} -\centerline{with headings in {\bf\fontname\tenbf}} -\centerline{and examples in {\tt\fontname\tentt}.} -\centerline{{\it\fontname\tenit\/} and} -\centerline{{\sl\fontname\tensl\/}} -\centerline{are used for emphasis.}\vfill} -\page\colophon -% Blame: pesch@cygnus.com, 28mar91. -@end tex - -@contents -@bye diff --git a/gdb/doc/gdb.tgts-m4 b/gdb/doc/gdb.tgts-m4 deleted file mode 100755 index f3bee50a0f2..00000000000 --- a/gdb/doc/gdb.tgts-m4 +++ /dev/null @@ -1,192 +0,0 @@ -_dnl__ -*- Texinfo -*- -_dnl__ Copyright (c) 1988 1989 1990 1991 Free Software Foundation, Inc. -_dnl__ This file is part of the source for the GDB manual. -@c M4 FRAGMENT: $Id$ -@node Targets, Controlling _GDBN__, _GDBN__ Files, Top -@chapter Specifying a Debugging Target -@cindex debugging target -@kindex target -A @dfn{target} is an interface between the debugger and a particular -kind of file or process. - -Often, you will be able to run _GDBN__ in the same host environment as the -program you are debugging; in that case, the debugging target can just be -specified as a side effect of the @code{file} or @code{core} commands. -When you need more flexibility---for example, running _GDBN__ on a -physically separate host, controlling standalone systems over a -serial port, or realtime systems over a TCP/IP connection---you can use -the @code{target} command. - -@menu -* Active Targets:: Active Targets -* Target Commands:: Commands for Managing Targets -* Remote:: Remote Debugging -@end menu - -@node Active Targets, Target Commands, Targets, Targets -@section Active Targets -@cindex stacking targets -@cindex active targets -@cindex multiple targets - -Targets are managed in three @dfn{strata} that correspond to different -classes of target: processes, core files, and executable files. This -allows you to (for example) start a process and inspect its activity -without abandoning your work on a core file. - -More than one target can potentially respond to a request. In -particular, when you access memory _GDBN__ will examine the three strata of -targets until it finds a target that can handle that particular address. -Strata are always examined in a fixed order: first a process if there is -one, then a core file if there is one, and finally an executable file if -there is one of those. - -When you specify a new target in a given stratum, it replaces any target -previously in that stratum. - -To get rid of a target without replacing it, use the @code{detach} -command. The related command @code{attach} provides you with a way of -choosing a particular running process as a new target. @xref{Attach}. - -@node Target Commands, Remote, Active Targets, Targets -@section Commands for Managing Targets - -@table @code -@item target @var{type} @var{parameters} -Connects the _GDBN__ host environment to a target machine or process. A -target is typically a protocol for talking to debugging facilities. You -use the argument @var{type} to specify the type or protocol of the -target machine. - -Further @var{parameters} are interpreted by the target protocol, but -typically include things like device names or host names to connect -with, process numbers, and baud rates. - -The @code{target} command will not repeat if you press @key{RET} again -after executing the command. - -@item help target -@kindex help target -Displays the names of all targets available. To display targets -currently selected, use either @code{info target} or @code{info files} -(@pxref{Files}). - -@item help target @var{name} -Describe a particular target, including any parameters necessary to -select it. -@end table - -Here are some common targets (available, or not, depending on the _GDBN__ -configuration): - -@table @code -@item target exec @var{prog} -@kindex target exec -An executable file. @samp{target exec @var{prog}} is the same as -@samp{exec-file @var{prog}}. - -@item target core @var{filename} -@kindex target core -A core dump file. @samp{target core @var{filename}} is the same as -@samp{core-file @var{filename}}. - -@item target remote @var{dev} -@kindex target remote -Remote serial target in _GDBN__-specific protocol. The argument @var{dev} -specifies what serial device to use for the connection (e.g. -@file{/dev/ttya}). @xref{Remote}. - -_if__(_AMD29K__) -@item target amd-eb @var{dev} @var{speed} @var{PROG} -@kindex target amd-eb -@cindex AMD EB29K -Remote PC-resident AMD EB29K board, attached over serial lines. -@var{dev} is the serial device, as for @code{target remote}; -@var{speed} allows you to specify the linespeed; and @var{PROG} is the -name of the program to be debugged, as it appears to DOS on the PC. -@xref{EB29K Remote}. - -_fi__(_AMD29K__) -_if__(_I960__) -@item target nindy @var{devicename} -@kindex target nindy -An Intel 960 board controlled by a Nindy Monitor. @var{devicename} is -the name of the serial device to use for the connection, e.g. -@file{/dev/ttya}. @xref{i960-Nindy Remote}. - -_fi__(_I960__) -_if__(_VXWORKS__) -@item target vxworks @var{machinename} -@kindex target vxworks -A VxWorks system, attached via TCP/IP. The argument @var{machinename} -is the target system's machine name or IP address. -@xref{VxWorks Remote}. -_fi__(_VXWORKS__) -@end table - -_if__(_GENERIC__) -Different targets are available on different configurations of _GDBN__; your -configuration may have more or fewer targets. -_fi__(_GENERIC__) - -@node Remote, , Target Commands, Targets -@section Remote Debugging -@cindex remote debugging - -_if__(_GENERIC__) -@menu -_include__(gdb.inv.m-m4)<>_dnl__ -@end menu -_fi__(_GENERIC__) - -If you are trying to debug a program running on a machine that can't run -_GDBN__ in the usual way, it is often useful to use remote debugging. For -example, you might use remote debugging on an operating system kernel, or on -a small system which does not have a general purpose operating system -powerful enough to run a full-featured debugger. - -Some configurations of _GDBN__ have special serial or TCP/IP interfaces -to make this work with particular debugging targets. In addition, -_GDBN__ comes with a generic serial protocol (specific to _GDBN__, but -not specific to any particular target system) which you can use if you -write the remote stubs---the code that will run on the remote system to -communicate with _GDBN__. - -To use the _GDBN__ remote serial protocol, the program to be debugged on -the remote machine needs to contain a debugging stub which talks to -_GDBN__ over the serial line. Several working remote stubs are -distributed with _GDBN__; see the @file{README} file in the _GDBN__ -distribution for more information. - -For details of this communication protocol, see the comments in the -_GDBN__ source file @file{remote.c}. - -To start remote debugging, first run _GDBN__ and specify as an executable file -the program that is running in the remote machine. This tells _GDBN__ how -to find the program's symbols and the contents of its pure text. Then -establish communication using the @code{target remote} command with a device -name as an argument. For example: - -@example -target remote /dev/ttyb -@end example - -@noindent -if the serial line is connected to the device named @file{/dev/ttyb}. This -will stop the remote machine if it is not already stopped. - -Now you can use all the usual commands to examine and change data and to -step and continue the remote program. - -To resume the remote program and stop debugging it, use the @code{detach} -command. - -Other remote targets may be available in your -configuration of _GDBN__; use @code{help targets} to list them. - -_if__(_GENERIC__) -_include__(gdb.inv.s-m4) -@c Text on starting up GDB in various specific cases; it goes up front -@c in manuals configured for any of those particular situations, here -@c otherwise. -_fi__(_GENERIC__) diff --git a/gdb/doc/gdb.top-m4 b/gdb/doc/gdb.top-m4 deleted file mode 100755 index f17e3051cb8..00000000000 --- a/gdb/doc/gdb.top-m4 +++ /dev/null @@ -1,451 +0,0 @@ -_dnl__ -*- Texinfo -*- -_dnl__ Copyright (c) 1988 1989 1990 1991 Free Software Foundation, Inc. -_dnl__ This file is part of the source for the GDB manual. -@c M4 FRAGMENT: $Id$ -@c -@syncodeindex ky cp -@c FOR UPDATES LEADING TO THIS DRAFT, GDB CHANGELOG CONSULTED BETWEEN: -@c Sun May 19 05:36:59 1991 John Gilmore (gnu at cygint.cygnus.com) -@c Sat Dec 22 02:51:40 1990 John Gilmore (gnu at cygint) -@ifinfo -This file documents the GNU debugger _GDBN__. - -Copyright (C) 1988, 1989, 1990, 1991 Free Software Foundation, Inc. - -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. - -@ignore -Permission is granted to process this file through TeX and print the -results, provided the printed document carries copying permission -notice identical to this one except for the removal of this paragraph -(this paragraph not being relevant to the printed manual). - -@end ignore -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided also that the -section entitled ``GNU General Public License'' is included exactly as -in the original, and provided that the entire resulting derived work is -distributed under the terms of a permission notice identical to this -one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions, -except that the section entitled ``GNU General Public License'' may be -included in a translation approved by the Free Software Foundation -instead of in the original English. -@end ifinfo -@smallbook -@setchapternewpage odd -_if__(_GENERIC__) -@settitle Using _GDBN__ (v4.0) -_fi__(_GENERIC__) -_if__(!_GENERIC__) -@settitle Using _GDBN__ v4.0 (_HOST__) -_fi__(!_GENERIC__) -@iftex -@finalout -@end iftex -@titlepage -@title{Using _GDBN__} -@subtitle{A Guide to the GNU Source-Level Debugger} -_if__(!_GENERIC__) -@subtitle{On _HOST__ Systems} -_fi__(!_GENERIC__) -@sp 1 -@c Maybe crank this up to "Fourth Edition" when released at FSF -@c @subtitle Third Edition---_GDBN__ version 4.0 -@subtitle _GDBN__ version 4.0 -@subtitle May 1991 -@author{Richard M. Stallman@qquad @hfill Free Software Foundation} -@author{Roland H. Pesch@qquad @hfill Cygnus Support} -@page -@tex -{\parskip=0pt -\hfill rms\@ai.mit.edu, pesch\@cygnus.com\par -\hfill {\it Using _GDBN__}, \manvers\par -\hfill \TeX{}info \texinfoversion\par -} -@end tex - -@vskip 0pt plus 1filll -Copyright @copyright{} 1988, 1989, 1990, 1991 Free Software Foundation, Inc. - -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. - -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided also that the -section entitled ``GNU General Public License'' is included exactly as -in the original, and provided that the entire resulting derived work is -distributed under the terms of a permission notice identical to this -one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions, -except that the section entitled ``GNU General Public License'' may be -included in a translation approved by the Free Software Foundation -instead of in the original English. -@end titlepage -@page - -@node Top, Summary, (dir), (dir) -@ifinfo -This file describes version 4.0 of GDB, the GNU symbolic debugger. -@end ifinfo - -@menu -* Summary:: Summary of _GDBN__ -* New Features:: New Features in _GDBN__ version 4.0 -* Sample Session:: A Sample _GDBN__ Session -* Invocation:: Getting In and Out of _GDBN__ -* Commands:: -* Running:: Running Programs Under _GDBN__ -* Stopping:: Stopping and Continuing -* Stack:: Examining the Stack -* Source:: Examining Source Files -* Data:: Examining Data -* Symbols:: Examining the Symbol Table -* Altering:: Altering Execution -* _GDBN__ Files:: -* Targets:: Specifying a Debugging Target -* Controlling _GDBN__:: Controlling _GDBN__ -* Sequences:: Canned Sequences of Commands -* Emacs:: Using _GDBN__ under GNU Emacs -* _GDBN__ Bugs:: Reporting Bugs in _GDBN__ -* Renamed Commands:: -* Installing _GDBN__:: Installing _GDBN__ -* Copying:: GNU GENERAL PUBLIC LICENSE -* Index:: Index - --- The Detailed Node Listing --- - -Summary of _GDBN__ - -* Free Software:: Free Software -* Contributors:: Contributors to _GDBN__ - -Getting In and Out of _GDBN__ - -* Starting _GDBN__:: Starting _GDBN__ -* Leaving _GDBN__:: Leaving _GDBN__ -* Shell Commands:: Shell Commands - -Starting _GDBN__ - -* File Options:: Choosing Files -* Mode Options:: Choosing Modes - -_GDBN__ Commands - -* Command Syntax:: Command Syntax -* Help:: Getting Help - -Running Programs Under _GDBN__ - -* Compilation:: Compiling for Debugging -* Starting:: Starting your Program -* Arguments:: Your Program's Arguments -* Environment:: Your Program's Environment -* Working Directory:: Your Program's Working Directory -* Input/Output:: Your Program's Input and Output -* Attach:: Debugging an Already-Running Process -* Kill Process:: Killing the Child Process - -Stopping and Continuing - -* Breakpoints:: Breakpoints, Watchpoints, and Exceptions -* Stepping:: Stepping -* Continuing:: Continuing -* Signals:: Signals - -Breakpoints, Watchpoints, and Exceptions - -* Set Breaks:: Setting Breakpoints -* Set Watchpoints:: Setting Watchpoints -* Exception Handling:: Breakpoints and Exceptions -* Delete Breaks:: Deleting Breakpoints -* Disabling:: Disabling Breakpoints -* Conditions:: Break Conditions -* Break Commands:: Breakpoint Command Lists -* Breakpoint Menus:: Breakpoint Menus -* Error in Breakpoints:: - -Examining the Stack - -* Frames:: Stack Frames -* Backtrace:: Backtraces -* Selection:: Selecting a Frame -* Frame Info:: Information on a Frame - -Examining Source Files - -* List:: Printing Source Lines -* Search:: Searching Source Files -* Source Path:: Specifying Source Directories -* Machine Code:: Source and Machine Code - -Examining Data - -* Expressions:: Expressions -* Variables:: Program Variables -* Arrays:: Artificial Arrays -* Output formats:: Output formats -* Memory:: Examining Memory -* Auto Display:: Automatic Display -* Print Settings:: Print Settings -* Value History:: Value History -* Convenience Vars:: Convenience Variables -* Registers:: Registers -* Floating Point Hardware:: Floating Point Hardware - -Altering Execution - -* Assignment:: Assignment to Variables -* Jumping:: Continuing at a Different Address -* Signaling:: Giving the Program a Signal -* Returning:: Returning from a Function -* Calling:: Calling your Program's Functions - -_GDBN__'s Files - -* Files:: Commands to Specify Files -* Symbol Errors:: Errors Reading Symbol Files - -Specifying a Debugging Target - -* Active Targets:: Active Targets -* Target Commands:: Commands for Managing Targets -* Remote:: Remote Debugging - -Remote Debugging - -* i960-Nindy Remote:: -* EB29K Remote:: -* VxWorks Remote:: - -_GDBN__ with a Remote i960 (Nindy) - -* Nindy Startup:: Startup with Nindy -* Nindy Options:: Options for Nindy -* Nindy reset:: Nindy Reset Command - -_GDBN__ with a Remote EB29K - -* Comms (EB29K):: Communications Setup -* gdb-EB29K:: EB29K cross-debugging -* Remote Log:: Remote Log - -_GDBN__ and VxWorks - -* VxWorks connection:: Connecting to VxWorks -* VxWorks download:: VxWorks Download -* VxWorks attach:: Running Tasks - -Controlling _GDBN__ - -* Prompt:: Prompt -* Editing:: Command Editing -* History:: Command History -* Screen Size:: Screen Size -* Numbers:: Numbers -* Messages/Warnings:: Optional Warnings and Messages - -Canned Sequences of Commands - -* Define:: User-Defined Commands -* Command Files:: Command Files -* Output:: Commands for Controlled Output - -Reporting Bugs in _GDBN__ - -* Bug Criteria:: Have You Found a Bug? -* Bug Reporting:: How to Report Bugs -@end menu - -@node Summary, New Features, Top, Top -@unnumbered Summary of _GDBN__ - -The purpose of a debugger such as _GDBN__ is to allow you to see what is -going on ``inside'' another program while it executes---or what another -program was doing at the moment it crashed. - -_GDBN__ can do four main kinds of things (plus other things in support of -these) to help you catch bugs in the act: - -@itemize @bullet -@item -Start your program, specifying anything that might affect its behavior. - -@item -Make your program stop on specified conditions. - -@item -Examine what has happened, when your program has stopped. - -@item -Change things in your program, so you can experiment with correcting the -effects of one bug and go on to learn about another. -@end itemize - -_GDBN__ can be used to debug programs written in C and C++. Pascal support -is being implemented, and Fortran support will be added when a GNU -Fortran compiler is ready. - -@menu -* Free Software:: Free Software -* Contributors:: Contributors to GDB -@end menu - -@node Free Software, Contributors, Summary, Summary -@unnumberedsec Free Software -_GDBN__ is @dfn{free software}, protected by the GNU General Public License (GPL). -The GPL gives you the freedom to copy or adapt a licensed -program---but every person getting a copy also gets with it the -freedom to modify that copy (which means that they must get access to -the source code), and the freedom to distribute further copies. -Typical software companies use copyrights to limit your freedoms; the -Free Software Foundation uses the GPL to preserve these freedoms. - -Fundamentally, the General Public License is a license which says that -you have these freedoms and that you can't take these freedoms away -from anyone else. - -@c FIXME: (passim) go through all xrefs, expanding to use text headings -For full details, @pxref{Copying}. -@node Contributors, , Free Software, Summary -@unnumberedsec Contributors to GDB - -Richard Stallman was the original author of GDB, as with many GNU -programs. Many others have contributed to its development. This -section attempts to credit major contributors. One of the virtues of -free software is that everyone is free to contribute to it; with -regret, we cannot actually acknowledge everyone here. The file -@file{ChangeLog} in the GDB distribution approximates a blow-by-blow -account. - -Changes much prior to version 2.0 are lost in the mists of time. - -@quotation -@emph{Plea:} Additions to this section are particularly welcome. If you -or your friends (or enemies; let's be evenhanded) have been unfairly -omitted from this list, we would like to add your names! -@end quotation - -So that they may not regard their long labor as thankless, we -particularly thank those who shepherded GDB through major releases: -John Gilmore (release 4.0); Jim Kingdon (releases 3.9, 3.5, 3.4, 3.3); -and Randy Smith (releases 3.2, 3.1, 3.0). As major maintainer of GDB -for some period, each contributed significantly to the structure, -stability, and capabilities of the entire debugger. - -Richard Stallman, assisted at various times by Pete TerMaat, Chris -Hanson, and Richard Mlynarik, handled releases through 2.8. - -Michael Tiemann is the author of most of the GNU C++ support in GDB, -with significant additional contributions from Per Bothner. James -Clark wrote the GNU C++ demangler. Early work on C++ was by Peter -TerMaat (who also did much general update work leading to release 3.0). - -GDB 4.0 uses the BFD subroutine library to examine multiple -object-file formats; BFD was a joint project of V. Gumby -Henkel-Wallace, Rich Pixley, Steve Chamberlain, and John Gilmore. - -David Johnson wrote the original COFF support; Pace Willison did -the original support for encapsulated COFF. - -Adam de Boor and Bradley Davis contributed the ISI Optimum V support. -Per Bothner, Noboyuki Hikichi, and Alessandro Forin contributed MIPS -support. Jean-Daniel Fekete contributed Sun 386i support. Chris -Hanson improved the HP9000 support. Noboyuki Hikichi and Tomoyuki -Hasei contributed Sony/News OS 3 support. David Johnson contributed -Encore Umax support. Jyrki Kuoppala contributed Altos 3068 support. -Keith Packard contributed NS32K support. Doug Rabson contributed -Acorn Risc Machine support. Chris Smith contributed Convex support -(and Fortran debugging). Jonathan Stone contributed Pyramid support. -Michael Tiemann contributed SPARC support. Tim Tucker contributed -support for the Gould NP1 and Gould Powernode. Pace Willison -contributed Intel 386 support. Jay Vosburgh contributed Symmetry -support. - -Rich Schaefer helped with support of SunOS shared libraries. - -Jay Fenlason and Roland McGrath ensured that GDB and GAS agree about -several machine instruction sets. - -Patrick Duval, Ted Goldstein, Vikram Koka and Glenn Engel helped -develop remote debugging. Intel Corporation and Wind River Systems -contributed remote debugging modules for their products. - -Brian Fox is the author of the readline libraries providing -command-line editing and command history. - -@node New Features, Sample Session, Summary, Top -@unnumbered New Features since _GDBN__ version 3.5 - -@table @emph -@item Targets -Using the new command @code{target}, you can select at runtime whether -you are debugging local files, local processes, standalone systems over -a serial port, realtime systems over a TCP/IP connection, etc. -Internally, _GDBN__ now uses a function vector to mediate access to -different targets; if you need to add your own support for a remote -protocol, this makes it much easier. - -@item Watchpoints -_GDBN__ now sports watchpoints as well as breakpoints. You can use a -watchpoint to stop execution whenever the value of an expression -changes, without having to predict a particular place in your program -where this may happen. - -@item Object Code Formats -_GDBN__ uses a new scheme called Binary File Descriptors (BFD) to permit -it to switch dynamically, without reconfiguration or recompilation, -between different object-file formats. Formats currently supported are -COFF, a.out, and the Intel 960 b.out; files may be read as .o's, archive -libraries, or core dumps. BFD is available as a subroutine library so -that other programs may take advantage of it, and the other GNU binary -utilities are being converted to use it. - -@item Configuration -Compile-time configuration (to select a particular architecture and -operating system) is much easier. The script @code{config.gdb} now -handles specification of separate host and target configurations. - -@item Interaction -The user interface to _GDBN__'s control variables has been simplified -and consolidated in two commands, @code{set} and @code{show}. Output -lines are now broken at readable places, rather than overflowing onto -the next line. You can suppress output of machine-level addresses, -displaying only source language information. - - -@item Source Language -_GDBN__ now has limited support for C++ exception handling: _GDBN__ can -break when an exception is raised, before the stack is peeled back to -the exception handler's context. - -@item Command Rationalization -Many _GDBN__ commands have been renamed to make them easier to remember -and use. In particular, the subcommands of @code{info} and -@code{show}/@code{set} are grouped to make the former refer to the state -of your program, and the latter refer to the state of _GDBN__ itself. -@xref{Renamed Commands}, for details on what commands were renamed. - -@item Ports -_GDBN__ has been ported to the following new architectures: AT&T 3b1, -Acorn RISC machine, HP300 running HPUX, big- and little-endian MIPS -machines, Motorola 88k, Sun 386i, and Sun 3 running SunOS 4. In -addition, the following are supported as targets only: AMD 29k, Intel -960, and Wind River's VxWorks. - -@item Shared Libraries -_GDBN__ 4.0 supports SunOS shared libraries. - -@item Work in Progress -Kernel debugging for BSD and Mach systems; Tahoe and HPPA architecture -support. - -@end table - diff --git a/gdb/doc/gdbint.texinfo b/gdb/doc/gdbint.texinfo deleted file mode 100644 index a7ce163cae0..00000000000 --- a/gdb/doc/gdbint.texinfo +++ /dev/null @@ -1,802 +0,0 @@ -\input texinfo -@setfilename gdbint.info -@c $Id$ - -@ifinfo -@format -START-INFO-DIR-ENTRY -* Gdb Internals: (gdbint). The GNU debugger internals. -END-INFO-DIR-ENTRY -@end format -@end ifinfo - -@ifinfo -This file documents the internals of the GNU debugger GDB. - -Copyright (C) 1990, 1991 Free Software Foundation, Inc. -Contributed by Cygnus Support. Written by John Gilmore. - -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. - -@ignore -Permission is granted to process this file through Tex and print the -results, provided the printed document carries copying permission -notice identical to this one except for the removal of this paragraph -(this paragraph not being relevant to the printed manual). - -@end ignore -Permission is granted to copy or distribute modified versions of this -manual under the terms of the GPL (for which purpose this text may be -regarded as a program in the language TeX). -@end ifinfo - -@setchapternewpage off -@settitle GDB Internals -@titlepage -@title{Working in GDB} -@subtitle{A guide to the internals of the GNU debugger} -@author John Gilmore -@author Cygnus Support -@page -@tex -\def\$#1${{#1}} % Kluge: collect RCS revision info without $...$ -\xdef\manvers{\$Revision$} % For use in headers, footers too -{\parskip=0pt -\hfill Cygnus Support\par -\hfill \manvers\par -\hfill \TeX{}info \texinfoversion\par -} -@end tex - -@vskip 0pt plus 1filll -Copyright @copyright{} 1990, 1991 Free Software Foundation, Inc. - -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. - -@end titlepage - -@node Top, README, (dir), (dir) - -@menu -* README:: The README File -* New Architectures:: Defining a New Host or Target Architecture -* Config:: Adding a New Configuration -* Host:: Adding a New Host -* Target:: Adding a New Target -* Languages:: Defining New Source Languages -* Releases:: Configuring GDB for Release -* BFD support for GDB:: How BFD and GDB interface -* Symbol Reading:: Defining New Symbol Readers -* Cleanups:: Cleanups -* Wrapping:: Wrapping Output Lines - -@end menu - -@node README, New Architectures, Top, Top -@chapter The @file{README} File - -Check the @file{README} file, it often has useful information that does not -appear anywhere else in the directory. - - -@node New Architectures, Config, README, Top -@chapter Defining a New Host or Target Architecture - -When building support for a new host and/or target, much of the work you -need to do is handled by specifying configuration files; -@pxref{Config,,Adding a New Configuration}. Further work can be -divided into ``host-dependent'' (@pxref{Host,,Adding a New Host}) and -``target-dependent'' (@pxref{Target,,Adding a New Target}). The -following discussion is meant to explain the difference between hosts -and targets. - -@heading What is considered ``host-dependent'' versus ``target-dependent''? - -@dfn{Host} refers to attributes of the system where GDB runs. -@dfn{Target} refers to the system where the program being debugged -executes. In most cases they are the same machine; unfortunately, that -means you must add @emph{both} host and target support for new machines -in this category. - -The @file{xconfig/*}, @file{xm-*.h} and @file{*-xdep.c} files are for -host support. Similarly, the @file{tconfig/*}, @file{tm-*.h} and -@file{*-tdep.c} files are for target support. The question is, what -features or aspects of a debugging or cross-debugging environment are -considered to be ``host'' support? - -Defines and include files needed to build on the host are host support. -Examples are tty support, system defined types, host byte order, host -float format. - -Unix child process support is considered an aspect of the host. Since -when you fork on the host you are still on the host, the various macros -needed for finding the registers in the upage, running @code{ptrace}, and such -are all in the host-dependent files. - -@c FIXME so what kinds of things are target support? - -This is still somewhat of a grey area; I (John Gilmore) didn't do the -@file{xm-*} and @file{tm-*} split for gdb (it was done by Jim Kingdon) -so I have had to figure out the grounds on which it was split, and make -my own choices as I evolve it. I have moved many things out of the xdep -files actually, partly as a result of BFD and partly by removing -duplicated code. - - -@node Config, Host, New Architectures, Top -@chapter Adding a New Configuration - -Most of the work in making GDB compile on a new machine is in specifying -the configuration of the machine. This is done in a dizzying variety of -header files and configuration scripts, which we hope to make more -sensible soon. Let's say your new host is called an @var{xxx} (e.g. -@samp{sun4}), and its full three-part configuration name is -@code{@var{xarch}-@var{xvend}-@var{xos}} (e.g. @samp{sparc-sun-sunos4}). In -particular: - -In the top level directory, edit @file{config.sub} and add @var{xarch}, -@var{xvend}, and @var{xos} to the lists of supported architectures, -vendors, and operating systems near the bottom of the file. Also, add -@var{xxx} as an alias that maps to -@code{@var{xarch}-@var{xvend}-@var{xos}}. You can test your changes by -running - -@example -./config.sub @var{xxx} -@end example -@noindent -and -@example -./config.sub @code{@var{xarch}-@var{xvend}-@var{xos}} -@end example -@noindent -which should both respond with @code{@var{xarch}-@var{xvend}-@var{xos}} -and no error messages. - -Now, go to the @file{bfd} directory and -create a new file @file{bfd/hosts/h-@var{xxx}.h}. Examine the -other @file{h-*.h} files as templates, and create one that brings in the -right include files for your system, and defines any host-specific -macros needed by GDB. - -Then edit @file{bfd/configure.in}. Add shell script code to recognize your -@code{@var{xarch}-@var{xvend}-@var{xos}} configuration, and set -@code{my_host} to @var{xxx} when you recognize it. This will cause your -file @file{h-@var{xxx}.h} to be linked to @file{sysdep.h} at configuration -time. - -Also, if this host requires any changes to the Makefile, create a file -@file{bfd/config/hm-@var{xxx}}, which includes the required lines. - -(If you have the binary utilities and/or GNU ld in the same tree, -you'll also have to edit @file{binutils/configure.in} or -@file{ld/configure.in} to match what you've done in the @file{bfd} -directory.) - -It's likely that the @file{libiberty} and @file{readline} directories -won't need any changes for your configuration, but if they do, you can -change the @file{configure.in} file there to recognize your system and -map to an @file{hm-@var{xxx}} file. Then add @file{hm-@var{xxx}} -to the @file{config/} subdirectory, to set any makefile variables you -need. The only current options in there are things like @samp{-DSYSV}. - -Aha! Now to configure GDB itself! Edit -@file{gdb/configure.in} to recognize your system and set @code{gdb_host} -to @var{xxx}, and (unless your desired target is already available) also -set @code{gdb_target} to something appropriate (for instance, -@var{xxx}). To handle new hosts, modify the segment after the comment -@samp{# per-host}; to handle new targets, modify after @samp{# -per-target}. -@c Would it be simpler to just use different per-host and per-target -@c *scripts*, and call them from {configure} ? - -Finally, you'll need to specify and define GDB's host- and -target-dependent files used for your configuration; the next two -chapters discuss those. - - -@node Host, Target, Config, Top -@chapter Adding a New Host - -Once you have specified a new configuration for your host -(@pxref{Config,,Adding a New Configuration}), there are two remaining -pieces to making GDB work on a new machine. First, you have to make it -host on the new machine (compile there, handle that machine's terminals -properly, etc). If you will be cross-debugging to some other kind of -system that's already supported, you are done. - -If you want to use GDB to debug programs that run on the new machine, -you have to get it to understand the machine's object files, symbol -files, and interfaces to processes. @pxref{Target,,Adding a New Target} - -Several files control GDB's configuration for host systems: - -@table @file -@item gdb/xconfig/@var{xxx} -Specifies what object files are needed when hosting on machine @var{xxx}, -by defining the makefile macro @samp{XDEPFILES=@dots{}}. Also -specifies the header file which describes @var{xxx}, by defining -@samp{XM_FILE= xm-@var{xxx}.h}. You can also define @samp{CC}, -@samp{REGEX} and @samp{REGEX1}, @samp{SYSV_DEFINE}, @samp{XM_CFLAGS}, -@samp{XM_ADD_FILES}, @samp{XM_CLIBS}, @samp{XM_CDEPS}, -etc.; see @file{Makefile.in}. - -@item gdb/xm-@var{xxx}.h -(@file{xm.h} is a link to this file, created by configure). -Contains C macro definitions describing the host system environment, -such as byte order, host C compiler and library, ptrace support, -and core file structure. Crib from existing @file{xm-*.h} files -to create a new one. - -@item gdb/@var{xxx}-xdep.c -Contains any miscellaneous C code required for this machine -as a host. On some machines it doesn't exist at all. -@end table - -There are some ``generic'' versions of routines that can be used by -various host systems. These can be customized in various ways by macros -defined in your @file{xm-@var{xxx}.h} file. If these routines work for -the @var{xxx} host, you can just include the generic file's name (with -@samp{.o}, not @samp{.c}) in @code{XDEPFILES}. - -Otherwise, if your machine needs custom support routines, you will need -to write routines that perform the same functions as the generic file. -Put them into @code{@var{xxx}-xdep.c}, and put @code{@var{xxx}-xdep.o} -into @code{XDEPFILES}. - -@subheading Generic Host Support Files - -@table @file - -@item infptrace.c -This is the low level interface to inferior processes for systems -using the Unix @code{ptrace} call in a vanilla way. - -@item coredep.c::fetch_core_registers() -Support for reading registers out of a core file. This routine calls -@code{register_addr()}, see below. -Now that BFD is used to read core files, virtually all machines should -use @code{coredep.c}, and should just provide @code{fetch_core_registers} in -@code{@var{xxx}-xdep.c}. - -@item coredep.c::register_addr() -If your @code{xm-@var{xxx}.h} file defines the macro -@code{REGISTER_U_ADDR(reg)} to be the offset within the @samp{user} -struct of a register (represented as a GDB register number), -@file{coredep.c} will define the @code{register_addr()} function and use -the macro in it. If you do not define @code{REGISTER_U_ADDR}, but you -are using the standard @code{fetch_core_registers()}, you will need to -define your own version of @code{register_addr()}, put it into your -@code{@var{xxx}-xdep.c} file, and be sure @code{@var{xxx}-xdep.o} is in -the @code{XDEPFILES} list. If you have your own -@code{fetch_core_registers()}, you may not need a separate -@code{register_addr()}. Many custom @code{fetch_core_registers()} -implementations simply locate the registers themselves.@refill -@end table - -Object files needed when the target system is an @var{xxx} are listed -in the file @file{tconfig/@var{xxx}}, in the makefile macro -@samp{TDEPFILES = }@dots{}. The header file that defines the target -system should be called @file{tm-@var{xxx}.h}, and should be specified -as the value of @samp{TM_FILE} in @file{tconfig/@var{xxx}}. You can -also define @samp{TM_CFLAGS}, @samp{TM_CLIBS}, and @samp{TM_CDEPS} in -there; see @file{Makefile.in}. - -Now, you are now ready to try configuring GDB to compile for your system. -From the top level (above @file{bfd}, @file{gdb}, etc), do: - -@example -./configure @var{xxx} +target=vxworks960 -@end example - -This will configure your system to cross-compile for VxWorks on -the Intel 960, which is probably not what you really want, but it's -a test case that works at this stage. (You haven't set up to be -able to debug programs that run @emph{on} @var{xxx} yet.) - -If this succeeds, you can try building it all with: - -@example -make -@end example - -Good luck! Comments and suggestions about this section are particularly -welcome; send them to @samp{bug-gdb@@prep.ai.mit.edu}. - -When hosting GDB on a new operating system, to make it possible to debug -core files, you will need to either write specific code for parsing your -OS's core files, or customize @file{bfd/trad-core.c}. First, use -whatever @code{#include} files your machine uses to define the struct of -registers that is accessible (possibly in the u-area) in a core file -(rather than @file{machine/reg.h}), and an include file that defines whatever -header exists on a core file (e.g. the u-area or a @samp{struct core}). Then -modify @code{trad_unix_core_file_p()} to use these values to set up the -section information for the data segment, stack segment, any other -segments in the core file (perhaps shared library contents or control -information), ``registers'' segment, and if there are two discontiguous -sets of registers (e.g. integer and float), the ``reg2'' segment. This -section information basically delimits areas in the core file in a -standard way, which the section-reading routines in BFD know how to seek -around in. - -Then back in GDB, you need a matching routine called -@code{fetch_core_registers()}. If you can use the generic one, it's in -@file{core-dep.c}; if not, it's in your @file{@var{xxx}-xdep.c} file. -It will be passed a char pointer to the entire ``registers'' segment, -its length, and a zero; or a char pointer to the entire ``regs2'' -segment, its length, and a 2. The routine should suck out the supplied -register values and install them into GDB's ``registers'' array. -(@xref{New Architectures,,Defining a New Host or Target Architecture}, -for more info about this.) - - -@node Target, Languages, Host, Top -@chapter Adding a New Target - -For a new target called @var{ttt}, first specify the configuration as -described in @ref{Config,,Adding a New Configuration}. If your new -target is the same as your new host, you've probably already done that. - -A variety of files specify attributes of the target environment: - -@table @file -@item gdb/tconfig/@var{ttt} -Specifies what object files are needed for target @var{ttt}, by -defining the makefile macro @samp{TDEPFILES=@dots{}}. -Also specifies the header file which describes @var{ttt}, by defining -@samp{TM_FILE= tm-@var{ttt}.h}. You can also define @samp{CC}, -@samp{REGEX} and @samp{REGEX1}, @samp{SYSV_DEFINE}, @samp{TM_CFLAGS}, -and other Makefile variables here; see @file{Makefile.in}. - -@item gdb/tm-@var{ttt}.h -(@file{tm.h} is a link to this file, created by configure). -Contains macro definitions about the target machine's -registers, stack frame format and instructions. -Crib from existing @file{tm-*.h} files when building a new one. - -@item gdb/@var{ttt}-tdep.c -Contains any miscellaneous code required for this target machine. -On some machines it doesn't exist at all. Sometimes the macros -in @file{tm-@var{ttt}.h} become very complicated, so they are -implemented as functions here instead, and the macro is simply -defined to call the function. - -@item gdb/exec.c -Defines functions for accessing files that are -executable on the target system. These functions open and examine an -exec file, extract data from one, write data to one, print information -about one, etc. Now that executable files are handled with BFD, every -target should be able to use the generic exec.c rather than its -own custom code. - -@item gdb/@var{arch}-pinsn.c -Prints (disassembles) the target machine's instructions. -This file is usually shared with other target machines which use the -same processor, which is why it is @file{@var{arch}-pinsn.c} rather -than @file{@var{ttt}-pinsn.c}. - -@item gdb/@var{arch}-opcode.h -Contains some large initialized -data structures describing the target machine's instructions. -This is a bit strange for a @file{.h} file, but it's OK since -it is only included in one place. @file{@var{arch}-opcode.h} is shared -between the debugger and the assembler, if the GNU assembler has been -ported to the target machine. - -@item gdb/tm-@var{arch}.h -This often exists to describe the basic layout of the target machine's -processor chip (registers, stack, etc). -If used, it is included by @file{tm-@var{xxx}.h}. It can -be shared among many targets that use the same processor. - -@item gdb/@var{arch}-tdep.c -Similarly, there are often common subroutines that are shared by all -target machines that use this particular architecture. -@end table - -When adding support for a new target machine, there are various areas -of support that might need change, or might be OK. - -If you are using an existing object file format (a.out or COFF), -there is probably little to be done. See @file{bfd/doc/bfd.texinfo} -for more information on writing new a.out or COFF versions. - -If you need to add a new object file format, you are beyond the scope -of this document right now. Look at the structure of the a.out -and COFF support, build a transfer vector (@code{xvec}) for your new format, -and start populating it with routines. Add it to the list in -@file{bfd/targets.c}. - -If you are adding a new operating system for an existing CPU chip, add a -@file{tm-@var{xos}.h} file that describes the operating system -facilities that are unusual (extra symbol table info; the breakpoint -instruction needed; etc). Then write a -@file{tm-@var{xarch}-@var{xos}.h} that just @code{#include}s -@file{tm-@var{xarch}.h} and @file{tm-@var{xos}.h}. (Now that we have -three-part configuration names, this will probably get revised to -separate the @var{xos} configuration from the @var{xarch} -configuration.) - - -@node Languages, Releases, Target, Top -@chapter Adding a Source Language to GDB - -To add other languages to GDB's expression parser, follow the following steps: - -@table @emph -@item Create the expression parser. - -This should reside in a file @file{@var{lang}-exp.y}. Routines for building -parsed expressions into a @samp{union exp_element} list are in @file{parse.c}. - -Since we can't depend upon everyone having Bison, and YACC produces -parsers that define a bunch of global names, the following lines -@emph{must} be included at the top of the YACC parser, to prevent -the various parsers from defining the same global names: - -@example -#define yyparse @var{lang}_parse -#define yylex @var{lang}_lex -#define yyerror @var{lang}_error -#define yylval @var{lang}_lval -#define yychar @var{lang}_char -#define yydebug @var{lang}_debug -#define yypact @var{lang}_pact -#define yyr1 @var{lang}_r1 -#define yyr2 @var{lang}_r2 -#define yydef @var{lang}_def -#define yychk @var{lang}_chk -#define yypgo @var{lang}_pgo -#define yyact @var{lang}_act -#define yyexca @var{lang}_exca -#define yyerrflag @var{lang}_errflag -#define yynerrs @var{lang}_nerrs -@end example - -At the bottom of your parser, define a @code{struct language_defn} and -initialize it with the right values for your language. Define an -@code{initialize_@var{lang}} routine and have it call -@samp{add_language(@var{lang}_language_defn)} to tell the rest of GDB -that your language exists. You'll need some other supporting variables -and functions, which will be used via pointers from your -@code{@var{lang}_language_defn}. See the declaration of @code{struct -language_defn} in @file{language.h}, and the other @file{*-exp.y} files, -for more information. - -@item Add any evaluation routines, if necessary - -If you need new opcodes (that represent the operations of the language), -add them to the enumerated type in @file{expression.h}. Add support -code for these operations in @code{eval.c:evaluate_subexp()}. Add cases -for new opcodes in two functions from @file{parse.c}: -@code{prefixify_subexp()} and @code{length_of_subexp()}. These compute -the number of @code{exp_element}s that a given operation takes up. - -@item Update some existing code - -Add an enumerated identifier for your language to the enumerated type -@code{enum language} in @file{defs.h}. - -Update the routines in @file{language.c} so your language is included. These -routines include type predicates and such, which (in some cases) are -language dependent. If your language does not appear in the switch -statement, an error is reported. - -Also included in @file{language.c} is the code that updates the variable -@code{current_language}, and the routines that translate the -@code{language_@var{lang}} enumerated identifier into a printable -string. - -Update the function @code{_initialize_language} to include your language. This -function picks the default language upon startup, so is dependent upon -which languages that GDB is built for. - -Update @code{allocate_symtab} in @file{symfile.c} and/or symbol-reading -code so that the language of each symtab (source file) is set properly. -This is used to determine the language to use at each stack frame level. -Currently, the language is set based upon the extension of the source -file. If the language can be better inferred from the symbol -information, please set the language of the symtab in the symbol-reading -code. - -Add helper code to @code{expprint.c:print_subexp()} to handle any new -expression opcodes you have added to @file{expression.h}. Also, add the -printed representations of your operators to @code{op_print_tab}. - -@item Add a place of call - -Add a call to @code{@var{lang}_parse()} and @code{@var{lang}_error} in -@code{parse.c:parse_exp_1()}. - -@item Use macros to trim code - -The user has the option of building GDB for some or all of the -languages. If the user decides to build GDB for the language -@var{lang}, then every file dependent on @file{language.h} will have the -macro @code{_LANG_@var{lang}} defined in it. Use @code{#ifdef}s to -leave out large routines that the user won't need if he or she is not -using your language. - -Note that you do not need to do this in your YACC parser, since if GDB -is not build for @var{lang}, then @file{@var{lang}-exp.tab.o} (the -compiled form of your parser) is not linked into GDB at all. - -See the file @file{configure.in} for how GDB is configured for different -languages. - -@item Edit @file{Makefile.in} - -Add dependencies in @file{Makefile.in}. Make sure you update the macro -variables such as @code{HFILES} and @code{OBJS}, otherwise your code may -not get linked in, or, worse yet, it may not get @code{tar}red into the -distribution! -@end table - - -@node Releases, BFD support for GDB, Languages, Top -@chapter Configuring GDB for Release - -From the top level directory (containing @file{gdb}, @file{bfd}, -@file{libiberty}, and so on): -@example -make gdb.tar.Z -@end example - -This will properly configure, clean, rebuild any files that are -distributed pre-built (e.g. @file{c-exp.tab.c} or @file{refcard.ps}), -and will then make a tarfile. - -This procedure requires: -@itemize @bullet -@item symbolic links -@item @code{makeinfo} (texinfo2 level) -@item @TeX{} -@item @code{dvips} -@item @code{yacc} or @code{bison} -@end itemize -@noindent -@dots{} and the usual slew of utilities (@code{sed}, @code{tar}, etc.). - -@subheading TEMPORARY RELEASE PROCEDURE FOR DOCUMENTATION - -@file{gdb.texinfo} is currently marked up using the texinfo-2 macros, -which are not yet a default for anything (but we have to start using -them sometime). - -For making paper, the only thing this implies is the right generation of -@file{texinfo.tex} needs to be included in the distribution. - -For making info files, however, rather than duplicating the texinfo2 -distribution, generate @file{gdb-all.texinfo} locally, and include the files -@file{gdb.info*} in the distribution. Note the plural; @code{makeinfo} will -split the document into one overall file and five or so included files. - - -@node BFD support for GDB, Symbol Reading, Releases, Top -@chapter Binary File Descriptor Library Support for GDB - -BFD provides support for GDB in several ways: - -@table @emph -@item identifying executable and core files -BFD will identify a variety of file types, including a.out, coff, and -several variants thereof, as well as several kinds of core files. - -@item access to sections of files -BFD parses the file headers to determine the names, virtual addresses, -sizes, and file locations of all the various named sections in files -(such as the text section or the data section). GDB simply calls -BFD to read or write section X at byte offset Y for length Z. - -@item specialized core file support -BFD provides routines to determine the failing command name stored -in a core file, the signal with which the program failed, and whether -a core file matches (i.e. could be a core dump of) a particular executable -file. - -@item locating the symbol information -GDB uses an internal interface of BFD to determine where to find the -symbol information in an executable file or symbol-file. GDB itself -handles the reading of symbols, since BFD does not ``understand'' debug -symbols, but GDB uses BFD's cached information to find the symbols, -string table, etc. -@end table - -@c The interface for symbol reading is described in @ref{Symbol -@c Reading,,Symbol Reading}. - - -@node Symbol Reading, Cleanups, BFD support for GDB, Top -@chapter Symbol Reading - -GDB reads symbols from "symbol files". The usual symbol file is the -file containing the program which gdb is debugging. GDB can be directed -to use a different file for symbols (with the ``symbol-file'' -command), and it can also read more symbols via the ``add-file'' and ``load'' -commands, or while reading symbols from shared libraries. - -Symbol files are initially opened by @file{symfile.c} using the BFD -library. BFD identifies the type of the file by examining its header. -@code{symfile_init} then uses this identification to locate a -set of symbol-reading functions. - -Symbol reading modules identify themselves to GDB by calling -@code{add_symtab_fns} during their module initialization. The argument -to @code{add_symtab_fns} is a @code{struct sym_fns} which contains -the name (or name prefix) of the symbol format, the length of the prefix, -and pointers to four functions. These functions are called at various -times to process symbol-files whose identification matches the specified -prefix. - -The functions supplied by each module are: - -@table @code -@item @var{xxx}_symfile_init(struct sym_fns *sf) - -Called from @code{symbol_file_add} when we are about to read a new -symbol file. This function should clean up any internal state -(possibly resulting from half-read previous files, for example) -and prepare to read a new symbol file. Note that the symbol file -which we are reading might be a new "main" symbol file, or might -be a secondary symbol file whose symbols are being added to the -existing symbol table. - -The argument to @code{@var{xxx}_symfile_init} is a newly allocated -@code{struct sym_fns} whose @code{bfd} field contains the BFD -for the new symbol file being read. Its @code{private} field -has been zeroed, and can be modified as desired. Typically, -a struct of private information will be @code{malloc}'d, and -a pointer to it will be placed in the @code{private} field. - -There is no result from @code{@var{xxx}_symfile_init}, but it can call -@code{error} if it detects an unavoidable problem. - -@item @var{xxx}_new_init() - -Called from @code{symbol_file_add} when discarding existing symbols. -This function need only handle -the symbol-reading module's internal state; the symbol table data -structures visible to the rest of GDB will be discarded by -@code{symbol_file_add}. It has no arguments and no result. -It may be called after @code{@var{xxx}_symfile_init}, if a new symbol -table is being read, or may be called alone if all symbols are -simply being discarded. - -@item @var{xxx}_symfile_read(struct sym_fns *sf, CORE_ADDR addr, int mainline) - -Called from @code{symbol_file_add} to actually read the symbols from a -symbol-file into a set of psymtabs or symtabs. - -@code{sf} points to the struct sym_fns originally passed to -@code{@var{xxx}_sym_init} for possible initialization. @code{addr} is the -offset between the file's specified start address and its true address -in memory. @code{mainline} is 1 if this is the main symbol table being -read, and 0 if a secondary symbol file (e.g. shared library or -dynamically loaded file) is being read.@refill -@end table - -In addition, if a symbol-reading module creates psymtabs when -@var{xxx}_symfile_read is called, these psymtabs will contain a pointer to -a function @code{@var{xxx}_psymtab_to_symtab}, which can be called from -any point in the GDB symbol-handling code. - -@table @code -@item @var{xxx}_psymtab_to_symtab (struct partial_symtab *pst) - -Called from @code{psymtab_to_symtab} (or the PSYMTAB_TO_SYMTAB -macro) if the psymtab has not already been read in and had its -@code{pst->symtab} pointer set. The argument is the psymtab -to be fleshed-out into a symtab. Upon return, pst->readin -should have been set to 1, and pst->symtab should contain a -pointer to the new corresponding symtab, or zero if there -were no symbols in that part of the symbol file. -@end table - - -@node Cleanups, Wrapping, Symbol Reading, Top -@chapter Cleanups - -Cleanups are a structured way to deal with things that need to be done -later. When your code does something (like @code{malloc} some memory, or open -a file) that needs to be undone later (e.g. free the memory or close -the file), it can make a cleanup. The cleanup will be done at some -future point: when the command is finished, when an error occurs, or -when your code decides it's time to do cleanups. - -You can also discard cleanups, that is, throw them away without doing -what they say. This is only done if you ask that it be done. - -Syntax: - -@table @code -@item @var{old_chain} = make_cleanup (@var{function}, @var{arg}); -Make a cleanup which will cause @var{function} to be called with @var{arg} -(a @code{char *}) later. The result, @var{old_chain}, is a handle that can be -passed to @code{do_cleanups} or @code{discard_cleanups} later. Unless you are -going to call @code{do_cleanups} or @code{discard_cleanups} yourself, -you can ignore the result from @code{make_cleanup}. - - -@item do_cleanups (@var{old_chain}); -Perform all cleanups done since @code{make_cleanup} returned @var{old_chain}. -E.g.: -@example -make_cleanup (a, 0); -old = make_cleanup (b, 0); -do_cleanups (old); -@end example -@noindent -will call @code{b()} but will not call @code{a()}. The cleanup that calls @code{a()} will remain -in the cleanup chain, and will be done later unless otherwise discarded.@refill - -@item discard_cleanups (@var{old_chain}); -Same as @code{do_cleanups} except that it just removes the cleanups from the -chain and does not call the specified functions. - -@end table - -Some functions, e.g. @code{fputs_filtered()} or @code{error()}, specify that they -``should not be called when cleanups are not in place''. This means -that any actions you need to reverse in the case of an error or -interruption must be on the cleanup chain before you call these functions, -since they might never return to your code (they @samp{longjmp} instead). - - -@node Wrapping, Frames, Cleanups, Top -@chapter Wrapping Output Lines - -Output that goes through @code{printf_filtered} or @code{fputs_filtered} or -@code{fputs_demangled} needs only to have calls to @code{wrap_here} added -in places that would be good breaking points. The utility routines -will take care of actually wrapping if the line width is exceeded. - -The argument to @code{wrap_here} is an indentation string which is printed -@emph{only} if the line breaks there. This argument is saved away and used -later. It must remain valid until the next call to @code{wrap_here} or -until a newline has been printed through the @code{*_filtered} functions. -Don't pass in a local variable and then return! - -It is usually best to call @code{wrap_here()} after printing a comma or space. -If you call it before printing a space, make sure that your indentation -properly accounts for the leading space that will print if the line wraps -there. - -Any function or set of functions that produce filtered output must finish -by printing a newline, to flush the wrap buffer, before switching to -unfiltered (``@code{printf}'') output. Symbol reading routines that print -warnings are a good example. - - -@node Frames, , Cleanups, Top -@chapter Frames - -A frame is a construct that GDB uses to keep track of calling and called -functions. - -FRAME_FP in the machine description has no meaning to the machine-independent -part of GDB, 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 - -Other than that, all the meaning imparted to FP_REGNUM is imparted by -the machine-dependent code. So, FP_REGNUM can have any value that -is convenient for the code that creates new frames. (create_new_frame -calls INIT_EXTRA_FRAME_INFO if it is defined; that is where you should -use the FP_REGNUM value, if your frames are nonstandard.) - -FRAME_CHAIN: - -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. - -@contents -@bye - diff --git a/gdb/doc/gdbinv-m.m4 b/gdb/doc/gdbinv-m.m4 deleted file mode 100755 index 8fe5f91c909..00000000000 --- a/gdb/doc/gdbinv-m.m4 +++ /dev/null @@ -1,13 +0,0 @@ -_dnl__ -*- Texinfo -*- -_dnl__ Copyright (c) 1991 Free Software Foundation, Inc. -_dnl__ This file is part of the source for the GDB manual. -_dnl__ M4 FRAGMENT: $Id$ -_if__(_I960__) -* i960-Nindy Remote:: _GDBN__ with a Remote i960 (Nindy) -_fi__(_I960__) -_if__(_AMD29K__) -* EB29K Remote:: _GDBN__ with a Remote EB29K -_fi__(_AMD29K__) -_if__(_VXWORKS__) -* VxWorks Remote:: _GDBN__ and VxWorks -_fi__(_VXWORKS__) diff --git a/gdb/doc/gdbinv-m.m4.in b/gdb/doc/gdbinv-m.m4.in deleted file mode 100644 index 8fe5f91c909..00000000000 --- a/gdb/doc/gdbinv-m.m4.in +++ /dev/null @@ -1,13 +0,0 @@ -_dnl__ -*- Texinfo -*- -_dnl__ Copyright (c) 1991 Free Software Foundation, Inc. -_dnl__ This file is part of the source for the GDB manual. -_dnl__ M4 FRAGMENT: $Id$ -_if__(_I960__) -* i960-Nindy Remote:: _GDBN__ with a Remote i960 (Nindy) -_fi__(_I960__) -_if__(_AMD29K__) -* EB29K Remote:: _GDBN__ with a Remote EB29K -_fi__(_AMD29K__) -_if__(_VXWORKS__) -* VxWorks Remote:: _GDBN__ and VxWorks -_fi__(_VXWORKS__) diff --git a/gdb/doc/gdbinv-s.m4 b/gdb/doc/gdbinv-s.m4 deleted file mode 100755 index e0814be89c5..00000000000 --- a/gdb/doc/gdbinv-s.m4 +++ /dev/null @@ -1,427 +0,0 @@ -_dnl__ -*- Texinfo -*- -_dnl__ Copyright (c) 1990 1991 Free Software Foundation, Inc. -_dnl__ This file is part of the source for the GDB manual. -@c M4 FRAGMENT $Id$ -@c This text diverted to "Remote Debugging" section in general case; -@c however, if we're doing a manual specifically for one of these, it -@c belongs up front (in "Getting In and Out" chapter). -_if__(_I960__) -_if__(!_GENERIC__) -@node i960-Nindy Remote, EB29K Remote, Mode Options, Starting _GDBN__ -_fi__(!_GENERIC__) -_if__(_GENERIC__) -@node i960-Nindy Remote, EB29K Remote, Remote, Remote -_fi__(_GENERIC__) -@subsection _GDBN__ with a Remote i960 (Nindy) - -@cindex Nindy -@cindex i960 -@dfn{Nindy} is a ROM Monitor program for Intel 960 target systems. When -_GDBN__ is configured to control a remote Intel 960 using Nindy, you can -tell _GDBN__ how to connect to the 960 in several ways: - -@itemize @bullet -@item -Through command line options specifying serial port, version of the -Nindy protocol, and communications speed; - -@item -By responding to a prompt on startup; - -@item -By using the @code{target} command at any point during your _GDBN__ -session. @xref{Target Commands}. - -@end itemize - -@menu -* Nindy Startup:: Startup with Nindy -* Nindy Options:: Options for Nindy -* Nindy reset:: Nindy Reset Command -@end menu - -@node Nindy Startup, Nindy Options, i960-Nindy Remote, i960-Nindy Remote -@subsubsection Startup with Nindy - -If you simply start @code{_GDBN__} without using any command-line -options, you are prompted for what serial port to use, @emph{before} you -reach the ordinary _GDBN__ prompt: -@example -Attach /dev/ttyNN -- specify NN, or "quit" to quit: -@end example -@noindent -Respond to the prompt with whatever suffix (after @samp{/dev/tty}) -identifies the serial port you want to use. You can, if you choose, -simply start up with no Nindy connection by responding to the prompt -with an empty line. If you do this, and later wish to attach to Nindy, -use @code{target} (@pxref{Target Commands}). - -@node Nindy Options, Nindy reset, Nindy Startup, i960-Nindy Remote -@subsubsection Options for Nindy - -These are the startup options for beginning your _GDBN__ session with a -Nindy-960 board attached: - -@table @code -@item -r @var{port} -Specify the serial port name of a serial interface to be used to connect -to the target system. This option is only available when _GDBN__ is -configured for the Intel 960 target architecture. You may specify -@var{port} as any of: a full pathname (e.g. @samp{-r /dev/ttya}), a -device name in @file{/dev} (e.g. @samp{-r ttya}), or simply the unique -suffix for a specific @code{tty} (e.g. @samp{-r a}). - -@item -O -(An uppercase letter ``O'', not a zero.) Specify that _GDBN__ should use -the ``old'' Nindy monitor protocol to connect to the target system. -This option is only available when _GDBN__ is configured for the Intel 960 -target architecture. - -@quotation -@emph{Warning:} if you specify @samp{-O}, but are actually trying to -connect to a target system that expects the newer protocol, the connection -will fail, appearing to be a speed mismatch. _GDBN__ will repeatedly -attempt to reconnect at several different line speeds. You can abort -this process with an interrupt. -@end quotation - -@item -brk -Specify that _GDBN__ should first send a @code{BREAK} signal to the target -system, in an attempt to reset it, before connecting to a Nindy target. - -@quotation -@emph{Warning:} Many target systems do not have the hardware that this -requires; it only works with a few boards. -@end quotation - -@end table - -The standard @samp{-b} option controls the line speed used on the serial -port. - -@node Nindy reset, , Nindy Options, i960-Nindy Remote -@c @group -@subsubsection Nindy Reset Command -@table @code -@item reset -@kindex reset -For a Nindy target, this command sends a ``break'' to the remote target -system; this is only useful if the target has been equipped with a -circuit to perform a hard reset (or some other interesting action) when -a break is detected. -@end table -@c @end group -_fi__(_I960__) - -_if__(_AMD29K__) -_if__(!_GENERIC__) -@node EB29K Remote, VxWorks Remote, i960-Nindy Remote, Starting _GDBN__ -_fi__(!_GENERIC__) -_if__(_GENERIC__) -@node EB29K Remote, VxWorks Remote, i960-Nindy Remote, Remote -_fi__(_GENERIC__) -@subsection _GDBN__ with a Remote EB29K - -@cindex EB29K board -@cindex running 29K programs - -To use _GDBN__ from a Unix system to run programs on AMD's EB29K -board in a PC, you must first connect a serial cable between the PC -and a serial port on the Unix system. In the following, we assume -you've hooked the cable between the PC's @file{COM1} port and -@file{/dev/ttya} on the Unix system. - -@menu -* Comms (EB29K):: Communications Setup -* _GDBP__-EB29K:: EB29K cross-debugging -* Remote Log:: Remote Log -@end menu - -@node Comms (EB29K), _GDBP__-EB29K, EB29K Remote, EB29K Remote -@subsubsection Communications Setup -The next step is to set up the PC's port, by doing something like the -following in DOS on the PC: -_0__@example -C:\> MODE com1:9600,n,8,1,none -_1__@end example -@noindent -This example---run on an MS DOS 4.0 system---sets the PC port to 9600 -bps, no parity, eight data bits, one stop bit, and no ``retry'' action; -you must match the communications parameters when establishing the Unix -end of the connection as well. -@c FIXME: Who knows what this "no retry action" crud from the DOS manual may -@c mean? It's optional; leave it out? ---pesch@cygnus.com, 25feb91 - -To give control of the PC to the Unix side of the serial line, type -the following at the DOS console: -_0__@example -C:\> CTTY com1 -_1__@end example -@noindent -(Later, if you wish to return control to the DOS console, you can use -the command @code{CTTY con}---but you must send it over the device that -had control, in our example over the @file{COM1} serial line). - -From the Unix host, use a communications program such as @code{tip} or -@code{cu} to communicate with the PC; for example, -@example -cu -s 9600 -l /dev/ttya -@end example -@noindent -The @code{cu} options shown specify, respectively, the linespeed and the -serial port to use. If you use @code{tip} instead, your command line -may look something like the following: -@example -tip -9600 /dev/ttya -@end example -@noindent -Your system may define a different name where our example uses -@file{/dev/ttya} as the argument to @code{tip}. The communications -parameters, including what port to use, are associated with the -@code{tip} argument in the ``remote'' descriptions file---normally the -system table @file{/etc/remote}. -@c FIXME: What if anything needs doing to match the "n,8,1,none" part of -@c the DOS side's comms setup? cu can support -o (odd -@c parity), -e (even parity)---apparently no settings for no parity or -@c for character size. Taken from stty maybe...? John points out tip -@c can set these as internal variables, eg ~s parity=none; man stty -@c suggests that it *might* work to stty these options with stdin or -@c stdout redirected... ---pesch@cygnus.com, 25feb91 - -@kindex EBMON -Using the @code{tip} or @code{cu} connection, change the DOS working -directory to the directory containing a copy of your 29K program, then -start the PC program @code{EBMON} (an EB29K control program supplied -with your board by AMD). You should see an initial display from -@code{EBMON} similar to the one that follows, ending with the -@code{EBMON} prompt @samp{#}--- -_0__@example -C:\> G: - -G:\> CD \usr\joe\work29k - -G:\USR\JOE\WORK29K> EBMON -Am29000 PC Coprocessor Board Monitor, version 3.0-18 -Copyright 1990 Advanced Micro Devices, Inc. -Written by Gibbons and Associates, Inc. - -Enter '?' or 'H' for help - -PC Coprocessor Type = EB29K -I/O Base = 0x208 -Memory Base = 0xd0000 - -Data Memory Size = 2048KB -Available I-RAM Range = 0x8000 to 0x1fffff -Available D-RAM Range = 0x80002000 to 0x801fffff - -PageSize = 0x400 -Register Stack Size = 0x800 -Memory Stack Size = 0x1800 - -CPU PRL = 0x3 -Am29027 Available = No -Byte Write Available = Yes - -# ~. -_1__@end example - -Then exit the @code{cu} or @code{tip} program (done in the example by -typing @code{~.} at the @code{EBMON} prompt). @code{EBMON} will keep -running, ready for _GDBN__ to take over. - -For this example, we've assumed what is probably the most convenient -way to make sure the same 29K program is on both the PC and the Unix -system: a PC/NFS connection that establishes ``drive @code{G:}'' on the -PC as a file system on the Unix host. If you don't have PC/NFS or -something similar connecting the two systems, you must arrange some -other way---perhaps floppy-disk transfer---of getting the 29K program -from the Unix system to the PC; _GDBN__ will @emph{not} download it over the -serial line. - -@node _GDBP__-EB29K, Remote Log, Comms (EB29K), EB29K Remote -@subsubsection EB29K cross-debugging -Finally, @code{cd} to the directory containing an image of your 29K -program on the Unix system, and start _GDBN__---specifying as argument the -name of your 29K program: -@example -cd /usr/joe/work29k -_GDBP__ myfoo -@end example -Now you can use the @code{target} command: -@example -target amd-eb /dev/ttya 9600 MYFOO -@end example -@c FIXME: test above 'target amd-eb' as spelled, with caps! caps are meant to -@c emphasize that this is the name as seen by DOS (since I think DOS is -@c single-minded about case of letters). ---pesch@cygnus.com, 25feb91 - -@noindent -In this example, we've assumed your program is in a file called -@file{myfoo}. Note that the filename given as the last argument to -@code{target amd-eb} should be the name of the program as it appears to DOS. -In our example this is simply @code{MYFOO}, but in general it can include -a DOS path, and depending on your transfer mechanism may not resemble -the name on the Unix side. - -At this point, you can set any breakpoints you wish; when you're ready -to see your program run on the 29K board, use the _GDBN__ command -@code{run}. - -To stop debugging the remote program, use the _GDBN__ @code{detach} -command. - -To return control of the PC to its console, use @code{tip} or @code{cu} -once again, after your _GDBN__ session has concluded, to attach to -@code{EBMON}. You can then type the command @code{q} to shut down -@code{EBMON}, returning control to the DOS command-line interpreter. -Type @code{CTTY con} to return command input to the main DOS console, -and type @kbd{~.} to leave @code{tip} or @code{cu}. - -@node Remote Log, , _GDBP__-EB29K, EB29K Remote -@subsubsection Remote Log -@kindex eb.log -@cindex log file for EB29K -The @code{target amd-eb} command creates a file @file{eb.log} in the -current working directory, to help debug problems with the connection. -@file{eb.log} records all the output from @code{EBMON}, including echoes -of the commands sent to it. Running @samp{tail -f} on this file in -another window often helps to understand trouble with @code{EBMON}, or -unexpected events on the PC side of the connection. -_fi__(_AMD29K__) - -_if__(_VXWORKS__) -_if__(!_GENERIC__) -@node VxWorks Remote, , EB29K Remote, Starting _GDBN__ -_fi__(!_GENERIC__) -_if__(_GENERIC__) -@node VxWorks Remote, , EB29K Remote, Remote -_fi__(_GENERIC__) -@subsection _GDBN__ and VxWorks -@cindex VxWorks -_GDBN__ enables developers to spawn and debug tasks running on networked -VxWorks targets from a Unix host. Already-running tasks spawned from -the VxWorks shell can also be debugged. _GDBN__ uses code that runs on -both the UNIX host and on the VxWorks target. The program -@code{_GDBP__} is installed and executed on the UNIX host. - -The remote debugging interface (RDB) routines are installed and executed -on the VxWorks target. These routines are included in the VxWorks library -@file{rdb.a} and are incorporated into the system image when source-level -debugging is enabled in the VxWorks configuration. - -@kindex INCLUDE_RDB -You can define @code{INCLUDE_RDB} in the VxWorks configuration file -@file{configAll.h} to include the RDB interface routines and spawn the -source debugging task @code{tRdbTask} when VxWorks is booted. For more -information on configuring and remaking VxWorks, see the @cite{VxWorks -Programmer's Guide}. - -Once you have included the RDB interface in your VxWorks system image -and set your Unix execution search path to find _GDBN__, you are ready -to run _GDBN__. From your UNIX host, type: - -@smallexample -% _GDBP__ -@end smallexample - -_GDBN__ will come up showing the prompt: - -@smallexample -(_GDBP__) -@end smallexample - -@menu -* VxWorks connection:: Connecting to VxWorks -* VxWorks download:: VxWorks Download -* VxWorks attach:: Running Tasks -@end menu - -@node VxWorks connection, VxWorks download, VxWorks Remote, VxWorks Remote -@subsubsection Connecting to VxWorks - -The _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: - -@smallexample -(_GDBP__) target vxworks tt -@end smallexample - -_GDBN__ will display a message similar to the following: - -@smallexample -Attaching remote machine across net... Success! -@end smallexample - -_GDBN__ will then attempt to read the symbol tables of any object -modules loaded into the VxWorks target since it was last booted. -_GDBN__ locates these files by searching the directories listed in the -command search path (@pxref{Environment}); if it fails to find an -object file, it will display a message such as: - -@smallexample -prog.o: No such file or directory. -@end smallexample - -This will cause the @code{target} command to abort. When this happens, -you should add the appropriate directory to the search path, with the -_GDBN__ command @code{path}, and execute the @code{target} command -again. - -@node VxWorks download, VxWorks attach, VxWorks connection, VxWorks Remote -@subsubsection VxWorks Download - -@cindex download to VxWorks -If you have connected to the VxWorks target and you want to debug an -object that has not yet been loaded, you can use the _GDBN__ @code{load} -command to download a file from UNIX to VxWorks incrementally. The -object file given as an argument to the @code{load} command is actually -opened twice: first by the VxWorks target in order to download the code, -then by _GDBN__ in order to read the symbol table. This can lead to -problems if the current working directories on the two systems differ. -It is simplest to set the working directory on both systems to the -directory in which the object file resides, and then to reference the -file by its name, without any path. Thus, to load a program -@file{prog.o}, residing in @file{wherever/vw/demo/rdb}, on VxWorks type: - -@smallexample --> cd "wherever/vw/demo/rdb" -@end smallexample - -On _GDBN__ type: - -@smallexample -(_GDBP__) cd wherever/vw/demo/rdb -(_GDBP__) load prog.o -@end smallexample - -_GDBN__ will display a response similar to the following: - -@smallexample -Reading symbol data from wherever/vw/demo/rdb/prog.o... done. -@end smallexample - -You can also use the @code{load} command to reload an object module -after editing and recompiling the corresponding source file. Note that -this will cause _GDBN__ to delete all currently-defined breakpoints, -auto-displays, and convenience variables, and to clear the value -history. (This is necessary in order to preserve the integrity of -debugger data structures that reference the target system's symbol -table.) - -@node VxWorks attach, , VxWorks download, VxWorks Remote -@subsubsection Running Tasks - -@cindex running VxWorks tasks -You can also attach to an existing task using the @code{attach} command as -follows: - -@smallexample -(_GDBP__) attach @var{task} -@end smallexample - -where @var{task} is the VxWorks hexadecimal task ID. The task can be running -or suspended when you attach to it. If running, it will be suspended at -the time of attachment. - -_fi__(_VXWORKS__) diff --git a/gdb/doc/gdbinv-s.m4.in b/gdb/doc/gdbinv-s.m4.in deleted file mode 100644 index e0814be89c5..00000000000 --- a/gdb/doc/gdbinv-s.m4.in +++ /dev/null @@ -1,427 +0,0 @@ -_dnl__ -*- Texinfo -*- -_dnl__ Copyright (c) 1990 1991 Free Software Foundation, Inc. -_dnl__ This file is part of the source for the GDB manual. -@c M4 FRAGMENT $Id$ -@c This text diverted to "Remote Debugging" section in general case; -@c however, if we're doing a manual specifically for one of these, it -@c belongs up front (in "Getting In and Out" chapter). -_if__(_I960__) -_if__(!_GENERIC__) -@node i960-Nindy Remote, EB29K Remote, Mode Options, Starting _GDBN__ -_fi__(!_GENERIC__) -_if__(_GENERIC__) -@node i960-Nindy Remote, EB29K Remote, Remote, Remote -_fi__(_GENERIC__) -@subsection _GDBN__ with a Remote i960 (Nindy) - -@cindex Nindy -@cindex i960 -@dfn{Nindy} is a ROM Monitor program for Intel 960 target systems. When -_GDBN__ is configured to control a remote Intel 960 using Nindy, you can -tell _GDBN__ how to connect to the 960 in several ways: - -@itemize @bullet -@item -Through command line options specifying serial port, version of the -Nindy protocol, and communications speed; - -@item -By responding to a prompt on startup; - -@item -By using the @code{target} command at any point during your _GDBN__ -session. @xref{Target Commands}. - -@end itemize - -@menu -* Nindy Startup:: Startup with Nindy -* Nindy Options:: Options for Nindy -* Nindy reset:: Nindy Reset Command -@end menu - -@node Nindy Startup, Nindy Options, i960-Nindy Remote, i960-Nindy Remote -@subsubsection Startup with Nindy - -If you simply start @code{_GDBN__} without using any command-line -options, you are prompted for what serial port to use, @emph{before} you -reach the ordinary _GDBN__ prompt: -@example -Attach /dev/ttyNN -- specify NN, or "quit" to quit: -@end example -@noindent -Respond to the prompt with whatever suffix (after @samp{/dev/tty}) -identifies the serial port you want to use. You can, if you choose, -simply start up with no Nindy connection by responding to the prompt -with an empty line. If you do this, and later wish to attach to Nindy, -use @code{target} (@pxref{Target Commands}). - -@node Nindy Options, Nindy reset, Nindy Startup, i960-Nindy Remote -@subsubsection Options for Nindy - -These are the startup options for beginning your _GDBN__ session with a -Nindy-960 board attached: - -@table @code -@item -r @var{port} -Specify the serial port name of a serial interface to be used to connect -to the target system. This option is only available when _GDBN__ is -configured for the Intel 960 target architecture. You may specify -@var{port} as any of: a full pathname (e.g. @samp{-r /dev/ttya}), a -device name in @file{/dev} (e.g. @samp{-r ttya}), or simply the unique -suffix for a specific @code{tty} (e.g. @samp{-r a}). - -@item -O -(An uppercase letter ``O'', not a zero.) Specify that _GDBN__ should use -the ``old'' Nindy monitor protocol to connect to the target system. -This option is only available when _GDBN__ is configured for the Intel 960 -target architecture. - -@quotation -@emph{Warning:} if you specify @samp{-O}, but are actually trying to -connect to a target system that expects the newer protocol, the connection -will fail, appearing to be a speed mismatch. _GDBN__ will repeatedly -attempt to reconnect at several different line speeds. You can abort -this process with an interrupt. -@end quotation - -@item -brk -Specify that _GDBN__ should first send a @code{BREAK} signal to the target -system, in an attempt to reset it, before connecting to a Nindy target. - -@quotation -@emph{Warning:} Many target systems do not have the hardware that this -requires; it only works with a few boards. -@end quotation - -@end table - -The standard @samp{-b} option controls the line speed used on the serial -port. - -@node Nindy reset, , Nindy Options, i960-Nindy Remote -@c @group -@subsubsection Nindy Reset Command -@table @code -@item reset -@kindex reset -For a Nindy target, this command sends a ``break'' to the remote target -system; this is only useful if the target has been equipped with a -circuit to perform a hard reset (or some other interesting action) when -a break is detected. -@end table -@c @end group -_fi__(_I960__) - -_if__(_AMD29K__) -_if__(!_GENERIC__) -@node EB29K Remote, VxWorks Remote, i960-Nindy Remote, Starting _GDBN__ -_fi__(!_GENERIC__) -_if__(_GENERIC__) -@node EB29K Remote, VxWorks Remote, i960-Nindy Remote, Remote -_fi__(_GENERIC__) -@subsection _GDBN__ with a Remote EB29K - -@cindex EB29K board -@cindex running 29K programs - -To use _GDBN__ from a Unix system to run programs on AMD's EB29K -board in a PC, you must first connect a serial cable between the PC -and a serial port on the Unix system. In the following, we assume -you've hooked the cable between the PC's @file{COM1} port and -@file{/dev/ttya} on the Unix system. - -@menu -* Comms (EB29K):: Communications Setup -* _GDBP__-EB29K:: EB29K cross-debugging -* Remote Log:: Remote Log -@end menu - -@node Comms (EB29K), _GDBP__-EB29K, EB29K Remote, EB29K Remote -@subsubsection Communications Setup -The next step is to set up the PC's port, by doing something like the -following in DOS on the PC: -_0__@example -C:\> MODE com1:9600,n,8,1,none -_1__@end example -@noindent -This example---run on an MS DOS 4.0 system---sets the PC port to 9600 -bps, no parity, eight data bits, one stop bit, and no ``retry'' action; -you must match the communications parameters when establishing the Unix -end of the connection as well. -@c FIXME: Who knows what this "no retry action" crud from the DOS manual may -@c mean? It's optional; leave it out? ---pesch@cygnus.com, 25feb91 - -To give control of the PC to the Unix side of the serial line, type -the following at the DOS console: -_0__@example -C:\> CTTY com1 -_1__@end example -@noindent -(Later, if you wish to return control to the DOS console, you can use -the command @code{CTTY con}---but you must send it over the device that -had control, in our example over the @file{COM1} serial line). - -From the Unix host, use a communications program such as @code{tip} or -@code{cu} to communicate with the PC; for example, -@example -cu -s 9600 -l /dev/ttya -@end example -@noindent -The @code{cu} options shown specify, respectively, the linespeed and the -serial port to use. If you use @code{tip} instead, your command line -may look something like the following: -@example -tip -9600 /dev/ttya -@end example -@noindent -Your system may define a different name where our example uses -@file{/dev/ttya} as the argument to @code{tip}. The communications -parameters, including what port to use, are associated with the -@code{tip} argument in the ``remote'' descriptions file---normally the -system table @file{/etc/remote}. -@c FIXME: What if anything needs doing to match the "n,8,1,none" part of -@c the DOS side's comms setup? cu can support -o (odd -@c parity), -e (even parity)---apparently no settings for no parity or -@c for character size. Taken from stty maybe...? John points out tip -@c can set these as internal variables, eg ~s parity=none; man stty -@c suggests that it *might* work to stty these options with stdin or -@c stdout redirected... ---pesch@cygnus.com, 25feb91 - -@kindex EBMON -Using the @code{tip} or @code{cu} connection, change the DOS working -directory to the directory containing a copy of your 29K program, then -start the PC program @code{EBMON} (an EB29K control program supplied -with your board by AMD). You should see an initial display from -@code{EBMON} similar to the one that follows, ending with the -@code{EBMON} prompt @samp{#}--- -_0__@example -C:\> G: - -G:\> CD \usr\joe\work29k - -G:\USR\JOE\WORK29K> EBMON -Am29000 PC Coprocessor Board Monitor, version 3.0-18 -Copyright 1990 Advanced Micro Devices, Inc. -Written by Gibbons and Associates, Inc. - -Enter '?' or 'H' for help - -PC Coprocessor Type = EB29K -I/O Base = 0x208 -Memory Base = 0xd0000 - -Data Memory Size = 2048KB -Available I-RAM Range = 0x8000 to 0x1fffff -Available D-RAM Range = 0x80002000 to 0x801fffff - -PageSize = 0x400 -Register Stack Size = 0x800 -Memory Stack Size = 0x1800 - -CPU PRL = 0x3 -Am29027 Available = No -Byte Write Available = Yes - -# ~. -_1__@end example - -Then exit the @code{cu} or @code{tip} program (done in the example by -typing @code{~.} at the @code{EBMON} prompt). @code{EBMON} will keep -running, ready for _GDBN__ to take over. - -For this example, we've assumed what is probably the most convenient -way to make sure the same 29K program is on both the PC and the Unix -system: a PC/NFS connection that establishes ``drive @code{G:}'' on the -PC as a file system on the Unix host. If you don't have PC/NFS or -something similar connecting the two systems, you must arrange some -other way---perhaps floppy-disk transfer---of getting the 29K program -from the Unix system to the PC; _GDBN__ will @emph{not} download it over the -serial line. - -@node _GDBP__-EB29K, Remote Log, Comms (EB29K), EB29K Remote -@subsubsection EB29K cross-debugging -Finally, @code{cd} to the directory containing an image of your 29K -program on the Unix system, and start _GDBN__---specifying as argument the -name of your 29K program: -@example -cd /usr/joe/work29k -_GDBP__ myfoo -@end example -Now you can use the @code{target} command: -@example -target amd-eb /dev/ttya 9600 MYFOO -@end example -@c FIXME: test above 'target amd-eb' as spelled, with caps! caps are meant to -@c emphasize that this is the name as seen by DOS (since I think DOS is -@c single-minded about case of letters). ---pesch@cygnus.com, 25feb91 - -@noindent -In this example, we've assumed your program is in a file called -@file{myfoo}. Note that the filename given as the last argument to -@code{target amd-eb} should be the name of the program as it appears to DOS. -In our example this is simply @code{MYFOO}, but in general it can include -a DOS path, and depending on your transfer mechanism may not resemble -the name on the Unix side. - -At this point, you can set any breakpoints you wish; when you're ready -to see your program run on the 29K board, use the _GDBN__ command -@code{run}. - -To stop debugging the remote program, use the _GDBN__ @code{detach} -command. - -To return control of the PC to its console, use @code{tip} or @code{cu} -once again, after your _GDBN__ session has concluded, to attach to -@code{EBMON}. You can then type the command @code{q} to shut down -@code{EBMON}, returning control to the DOS command-line interpreter. -Type @code{CTTY con} to return command input to the main DOS console, -and type @kbd{~.} to leave @code{tip} or @code{cu}. - -@node Remote Log, , _GDBP__-EB29K, EB29K Remote -@subsubsection Remote Log -@kindex eb.log -@cindex log file for EB29K -The @code{target amd-eb} command creates a file @file{eb.log} in the -current working directory, to help debug problems with the connection. -@file{eb.log} records all the output from @code{EBMON}, including echoes -of the commands sent to it. Running @samp{tail -f} on this file in -another window often helps to understand trouble with @code{EBMON}, or -unexpected events on the PC side of the connection. -_fi__(_AMD29K__) - -_if__(_VXWORKS__) -_if__(!_GENERIC__) -@node VxWorks Remote, , EB29K Remote, Starting _GDBN__ -_fi__(!_GENERIC__) -_if__(_GENERIC__) -@node VxWorks Remote, , EB29K Remote, Remote -_fi__(_GENERIC__) -@subsection _GDBN__ and VxWorks -@cindex VxWorks -_GDBN__ enables developers to spawn and debug tasks running on networked -VxWorks targets from a Unix host. Already-running tasks spawned from -the VxWorks shell can also be debugged. _GDBN__ uses code that runs on -both the UNIX host and on the VxWorks target. The program -@code{_GDBP__} is installed and executed on the UNIX host. - -The remote debugging interface (RDB) routines are installed and executed -on the VxWorks target. These routines are included in the VxWorks library -@file{rdb.a} and are incorporated into the system image when source-level -debugging is enabled in the VxWorks configuration. - -@kindex INCLUDE_RDB -You can define @code{INCLUDE_RDB} in the VxWorks configuration file -@file{configAll.h} to include the RDB interface routines and spawn the -source debugging task @code{tRdbTask} when VxWorks is booted. For more -information on configuring and remaking VxWorks, see the @cite{VxWorks -Programmer's Guide}. - -Once you have included the RDB interface in your VxWorks system image -and set your Unix execution search path to find _GDBN__, you are ready -to run _GDBN__. From your UNIX host, type: - -@smallexample -% _GDBP__ -@end smallexample - -_GDBN__ will come up showing the prompt: - -@smallexample -(_GDBP__) -@end smallexample - -@menu -* VxWorks connection:: Connecting to VxWorks -* VxWorks download:: VxWorks Download -* VxWorks attach:: Running Tasks -@end menu - -@node VxWorks connection, VxWorks download, VxWorks Remote, VxWorks Remote -@subsubsection Connecting to VxWorks - -The _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: - -@smallexample -(_GDBP__) target vxworks tt -@end smallexample - -_GDBN__ will display a message similar to the following: - -@smallexample -Attaching remote machine across net... Success! -@end smallexample - -_GDBN__ will then attempt to read the symbol tables of any object -modules loaded into the VxWorks target since it was last booted. -_GDBN__ locates these files by searching the directories listed in the -command search path (@pxref{Environment}); if it fails to find an -object file, it will display a message such as: - -@smallexample -prog.o: No such file or directory. -@end smallexample - -This will cause the @code{target} command to abort. When this happens, -you should add the appropriate directory to the search path, with the -_GDBN__ command @code{path}, and execute the @code{target} command -again. - -@node VxWorks download, VxWorks attach, VxWorks connection, VxWorks Remote -@subsubsection VxWorks Download - -@cindex download to VxWorks -If you have connected to the VxWorks target and you want to debug an -object that has not yet been loaded, you can use the _GDBN__ @code{load} -command to download a file from UNIX to VxWorks incrementally. The -object file given as an argument to the @code{load} command is actually -opened twice: first by the VxWorks target in order to download the code, -then by _GDBN__ in order to read the symbol table. This can lead to -problems if the current working directories on the two systems differ. -It is simplest to set the working directory on both systems to the -directory in which the object file resides, and then to reference the -file by its name, without any path. Thus, to load a program -@file{prog.o}, residing in @file{wherever/vw/demo/rdb}, on VxWorks type: - -@smallexample --> cd "wherever/vw/demo/rdb" -@end smallexample - -On _GDBN__ type: - -@smallexample -(_GDBP__) cd wherever/vw/demo/rdb -(_GDBP__) load prog.o -@end smallexample - -_GDBN__ will display a response similar to the following: - -@smallexample -Reading symbol data from wherever/vw/demo/rdb/prog.o... done. -@end smallexample - -You can also use the @code{load} command to reload an object module -after editing and recompiling the corresponding source file. Note that -this will cause _GDBN__ to delete all currently-defined breakpoints, -auto-displays, and convenience variables, and to clear the value -history. (This is necessary in order to preserve the integrity of -debugger data structures that reference the target system's symbol -table.) - -@node VxWorks attach, , VxWorks download, VxWorks Remote -@subsubsection Running Tasks - -@cindex running VxWorks tasks -You can also attach to an existing task using the @code{attach} command as -follows: - -@smallexample -(_GDBP__) attach @var{task} -@end smallexample - -where @var{task} is the VxWorks hexadecimal task ID. The task can be running -or suspended when you attach to it. If running, it will be suspended at -the time of attachment. - -_fi__(_VXWORKS__) diff --git a/gdb/doc/gen.m4 b/gdb/doc/gen.m4 deleted file mode 100644 index be995bf5b79..00000000000 --- a/gdb/doc/gen.m4 +++ /dev/null @@ -1,13 +0,0 @@ -_divert__(-1) -_define__(<_GENERIC__>,<1>) In case none.m4 changes its mind abt default - -_define__(<_AOUT__>,<1>) -_define__(<_COFF__>,<1>) -_define__(<_ELF__>,<1>) - -_define__(<_I80386__>,<1>) -_define__(<_M680X0__>,<1>) -_define__(<_SPARC__>,<1>) -_define__(<_VAX__>,<1>) - -_divert__<> \ No newline at end of file diff --git a/gdb/doc/i80386.m4 b/gdb/doc/i80386.m4 deleted file mode 100644 index d8293d1479c..00000000000 --- a/gdb/doc/i80386.m4 +++ /dev/null @@ -1,5 +0,0 @@ -_divert__(-1) -_define__(<_I80386__>,<1>) -_define__(<_HOST__>,) -_define__(<_MACH_DEP__>,<80386 Dependent> -_divert__<> \ No newline at end of file diff --git a/gdb/doc/i960.m4 b/gdb/doc/i960.m4 deleted file mode 100644 index e98155df6cb..00000000000 --- a/gdb/doc/i960.m4 +++ /dev/null @@ -1,12 +0,0 @@ -_divert__(-1) -_define__(<_I960__>,<1>) -_define__(<_AOUT__>,<0>) -_define__(<_BOUT__>,<1>) -_define__(<_COFF__>,<1>) -_define__(<_AS__>,) -_define__(<_GCC__>,) -_define__(<_LD__>,) -_define__(<_GDB__>,) -_define__(<_HOST__>,) -_define__(<_MACH_DEP__>,) -_divert__<> \ No newline at end of file diff --git a/gdb/doc/interim-gdb.texinfo b/gdb/doc/interim-gdb.texinfo deleted file mode 100755 index 53a01e4e2a3..00000000000 --- a/gdb/doc/interim-gdb.texinfo +++ /dev/null @@ -1,7901 +0,0 @@ -_dnl__ -*-Texinfo-*- -_dnl__ Copyright (c) 1988 1989 1990 1991 Free Software Foundation, Inc. -\input texinfo -@setfilename _GDBP__.info -@c $Id$ -@c THIS MANUAL REQUIRES TEXINFO-2 macros and info-makers to format properly. -@c -@c NOTE: this manual is marked up for preprocessing with a collection -@c of m4 macros called "pretex.m4". If you see <_if__> and <_fi__> -@c scattered around the source, you have the full source before -@c preprocessing; if you don't, you have the source configured for -@c _HOST__ architectures (and you can of course get the full source, -@c with all configurations, from wherever you got this). -_if__(0) - -THIS IS THE SOURCE PRIOR TO PREPROCESSING. The full source needs to -be run through m4 before either tex- or info- formatting: for example, -_0__ - m4 pretex.m4 none.m4 all.m4 gdb.texinfo >gdb-all.texinfo -_1__ -will produce (assuming your path finds either GNU m4 >= 0.84, or SysV -m4; Berkeley won't do) a file suitable for formatting. See the text in -"pretex.m4" for a fuller explanation (and the macro definitions). - -_fi__(0) -_include__(gdbVN.m4) -@tex -\def\$#1${{#1}} % Kluge: collect RCS revision info without $...$ -\xdef\manvers{\$Revision$} % For use in headers, footers too -@end tex -@c -@syncodeindex ky cp -@c FOR UPDATES LEADING TO THIS DRAFT, GDB CHANGELOG CONSULTED BETWEEN: -@c Fri Sep 20 16:10:52 1991 John Gilmore (gnu at cygnus.com) -@c Sat Dec 22 02:51:40 1990 John Gilmore (gnu at cygint) -@ifinfo -This file documents the GNU debugger _GDBN__. - -Copyright (C) 1988, 1989, 1990, 1991 Free Software Foundation, Inc. - -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. - -@ignore -Permission is granted to process this file through TeX and print the -results, provided the printed document carries copying permission -notice identical to this one except for the removal of this paragraph -(this paragraph not being relevant to the printed manual). - -@end ignore -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided also that the -section entitled ``GNU General Public License'' is included exactly as -in the original, and provided that the entire resulting derived work is -distributed under the terms of a permission notice identical to this -one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions, -except that the section entitled ``GNU General Public License'' may be -included in a translation approved by the Free Software Foundation -instead of in the original English. -@end ifinfo -@c @smallbook -@setchapternewpage odd -_if__(_GENERIC__) -@settitle Using _GDBN__ (_GDB_VN__) -_fi__(_GENERIC__) -_if__(!_GENERIC__) -@settitle Using _GDBN__ _GDB_VN__ (_HOST__) -_fi__(!_GENERIC__) -@iftex -@finalout -@end iftex -@titlepage -@title{Using _GDBN__} -@subtitle{A Guide to the GNU Source-Level Debugger} -_if__(!_GENERIC__) -@subtitle{On _HOST__ Systems} -_fi__(!_GENERIC__) -@sp 1 -@c Maybe crank this up to "Fourth Edition" when released at FSF -@c @subtitle Third Edition---_GDBN__ version _GDB_VN__ -@subtitle _GDBN__ version _GDB_VN__ -@subtitle July 1991 -@author{Richard M. Stallman@qquad @hfill Free Software Foundation} -@author{Roland H. Pesch@qquad @hfill Cygnus Support} -@page -@tex -{\parskip=0pt -\hfill rms\@ai.mit.edu, pesch\@cygnus.com\par -\hfill {\it Using _GDBN__}, \manvers\par -\hfill \TeX{}info \texinfoversion\par -} -@end tex - -@vskip 0pt plus 1filll -Copyright @copyright{} 1988, 1989, 1990, 1991 Free Software Foundation, Inc. - -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. - -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided also that the -section entitled ``GNU General Public License'' is included exactly as -in the original, and provided that the entire resulting derived work is -distributed under the terms of a permission notice identical to this -one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions, -except that the section entitled ``GNU General Public License'' may be -included in a translation approved by the Free Software Foundation -instead of in the original English. -@end titlepage -@page - -@node Top, Summary, (dir), (dir) -@ifinfo -This file describes version _GDB_VN__ of GDB, the GNU symbolic debugger. -@end ifinfo - -@menu -* Summary:: Summary of _GDBN__ -* New Features:: New Features in _GDBN__ version _GDB_VN__ -* Sample Session:: A Sample _GDBN__ Session -* Invocation:: Getting In and Out of _GDBN__ -* Commands:: _GDBN__ Commands -* Running:: Running Programs Under _GDBN__ -* Stopping:: Stopping and Continuing -* Stack:: Examining the Stack -* Source:: Examining Source Files -* Data:: Examining Data -* Languages:: Using _GDBN__ with Different Languages -* Symbols:: Examining the Symbol Table -* Altering:: Altering Execution -* _GDBN__ Files:: _GDBN__'s Files -* Targets:: Specifying a Debugging Target -* Controlling _GDBN__:: Controlling _GDBN__ -* Sequences:: Canned Sequences of Commands -* Emacs:: Using _GDBN__ under GNU Emacs -* _GDBN__ Bugs:: Reporting Bugs in _GDBN__ -* Renamed Commands:: -* Installing _GDBN__:: Installing _GDBN__ -* Copying:: GNU GENERAL PUBLIC LICENSE -* Index:: Index - - --- The Detailed Node Listing --- - -Summary of _GDBN__ - -* Free Software:: Free Software -* Contributors:: Contributors to _GDBN__ - -Getting In and Out of _GDBN__ - -* Starting _GDBN__:: Starting _GDBN__ -* Leaving _GDBN__:: Leaving _GDBN__ -* Shell Commands:: Shell Commands - -Starting _GDBN__ - -* File Options:: Choosing Files -* Mode Options:: Choosing Modes - -_GDBN__ Commands - -* Command Syntax:: Command Syntax -* Help:: Getting Help - -Running Programs Under _GDBN__ - -* Compilation:: Compiling for Debugging -* Starting:: Starting your Program -* Arguments:: Your Program's Arguments -* Environment:: Your Program's Environment -* Working Directory:: Your Program's Working Directory -* Input/Output:: Your Program's Input and Output -* Attach:: Debugging an Already-Running Process -* Kill Process:: Killing the Child Process - -Stopping and Continuing - -* Breakpoints:: Breakpoints, Watchpoints, and Exceptions -* Continuing and Stepping:: Resuming Execution -* Signals:: Signals - -Breakpoints, Watchpoints, and Exceptions - -* Set Breaks:: Setting Breakpoints -* Set Watchpoints:: Setting Watchpoints -* Exception Handling:: Breakpoints and Exceptions -* Delete Breaks:: Deleting Breakpoints -* Disabling:: Disabling Breakpoints -* Conditions:: Break Conditions -* Break Commands:: Breakpoint Command Lists -* Breakpoint Menus:: Breakpoint Menus -* Error in Breakpoints:: ``Cannot insert breakpoints'' - -Examining the Stack - -* Frames:: Stack Frames -* Backtrace:: Backtraces -* Selection:: Selecting a Frame -* Frame Info:: Information on a Frame - -Examining Source Files - -* List:: Printing Source Lines -* Search:: Searching Source Files -* Source Path:: Specifying Source Directories -* Machine Code:: Source and Machine Code - -Examining Data - -* Expressions:: Expressions -* Variables:: Program Variables -* Arrays:: Artificial Arrays -* Output formats:: Output formats -* Memory:: Examining Memory -* Auto Display:: Automatic Display -* Print Settings:: Print Settings -* Value History:: Value History -* Convenience Vars:: Convenience Variables -* Registers:: Registers -* Floating Point Hardware:: Floating Point Hardware - -Using GDB with Different Languages - -* Setting:: Switching between source languages -* Show:: Displaying the language -* Checks:: Type and Range checks -* Support:: Supported languages - -Switching between source languages - -* Manually:: Setting the working language manually -* Automatically:: Having GDB infer the source language - -Type and range Checking - -* Type Checking:: An overview of type checking -* Range Checking:: An overview of range checking - -Supported Languages - -* C:: C and C++ -* Modula-2:: Modula-2 - -C and C++ - -* C Operators:: C and C++ Operators -* C Constants:: C and C++ Constants -* Cplusplus expressions:: C++ Expressions -* C Defaults:: Default settings for C and C++ -* C Checks:: C and C++ Type and Range Checks -* Debugging C:: _GDBN__ and C -* Debugging C plus plus:: Special features for C++ - -Modula-2 - -* M2 Operators:: Built-in operators -* Builtin Func/Proc:: Built-in Functions and Procedures -* M2 Constants:: Modula-2 Constants -* M2 Defaults:: Default settings for Modula-2 -* Deviations:: Deviations from standard Modula-2 -* M2 Checks:: Modula-2 Type and Range Checks -* M2 Scope:: The scope operators @code{::} and @code{.} -* GDB/M2:: GDB and Modula-2 - -Altering Execution - -* Assignment:: Assignment to Variables -* Jumping:: Continuing at a Different Address -* Signaling:: Giving the Program a Signal -* Returning:: Returning from a Function -* Calling:: Calling your Program's Functions -* Patching:: Patching your Program - -_GDBN__'s Files - -* Files:: Commands to Specify Files -* Symbol Errors:: Errors Reading Symbol Files - -Specifying a Debugging Target - -* Active Targets:: Active Targets -* Target Commands:: Commands for Managing Targets -* Remote:: Remote Debugging - -Remote Debugging - -* i960-Nindy Remote:: _GDBN__ with a Remote i960 (Nindy) -* EB29K Remote:: _GDBN__ with a Remote EB29K -* VxWorks Remote:: _GDBN__ and VxWorks - -_GDBN__ with a Remote i960 (Nindy) - -* Nindy Startup:: Startup with Nindy -* Nindy Options:: Options for Nindy -* Nindy reset:: Nindy Reset Command - -_GDBN__ with a Remote EB29K - -* Comms (EB29K):: Communications Setup -* gdb-EB29K:: EB29K cross-debugging -* Remote Log:: Remote Log - -_GDBN__ and VxWorks - -* VxWorks connection:: Connecting to VxWorks -* VxWorks download:: VxWorks Download -* VxWorks attach:: Running Tasks - -Controlling _GDBN__ - -* Prompt:: Prompt -* Editing:: Command Editing -* History:: Command History -* Screen Size:: Screen Size -* Numbers:: Numbers -* Messages/Warnings:: Optional Warnings and Messages - -Canned Sequences of Commands - -* Define:: User-Defined Commands -* Command Files:: Command Files -* Output:: Commands for Controlled Output - -Reporting Bugs in _GDBN__ - -* Bug Criteria:: Have You Found a Bug? -* Bug Reporting:: How to Report Bugs - -Installing GDB - -* Subdirectories:: Configuration subdirectories -* Config Names:: Specifying names for hosts and targets -* configure Options:: Summary of options for configure -* Formatting Documentation:: How to format and print GDB documentation -@end menu - -@node Summary, New Features, Top, Top -@unnumbered Summary of _GDBN__ - -The purpose of a debugger such as _GDBN__ is to allow you to see what is -going on ``inside'' another program while it executes---or what another -program was doing at the moment it crashed. - -_GDBN__ can do four main kinds of things (plus other things in support of -these) to help you catch bugs in the act: - -@itemize @bullet -@item -Start your program, specifying anything that might affect its behavior. - -@item -Make your program stop on specified conditions. - -@item -Examine what has happened, when your program has stopped. - -@item -Change things in your program, so you can experiment with correcting the -effects of one bug and go on to learn about another. -@end itemize - -You can use _GDBN__ to debug programs written in C, C++, and Modula-2. -Fortran support will be added when a GNU Fortran compiler is ready. - -@menu -* Free Software:: Free Software -* Contributors:: Contributors to GDB -@end menu - -@node Free Software, Contributors, Summary, Summary -@unnumberedsec Free Software -_GDBN__ is @dfn{free software}, protected by the GNU General Public License (GPL). -The GPL gives you the freedom to copy or adapt a licensed -program---but every person getting a copy also gets with it the -freedom to modify that copy (which means that they must get access to -the source code), and the freedom to distribute further copies. -Typical software companies use copyrights to limit your freedoms; the -Free Software Foundation uses the GPL to preserve these freedoms. - -Fundamentally, the General Public License is a license which says that -you have these freedoms and that you can't take these freedoms away -from anyone else. - -@c FIXME: (passim) go through all xrefs, expanding to use text headings -For full details, @pxref{Copying}. -@node Contributors, , Free Software, Summary -@unnumberedsec Contributors to GDB - -Richard Stallman was the original author of GDB, and of many other GNU -programs. Many others have contributed to its development. This -section attempts to credit major contributors. One of the virtues of -free software is that everyone is free to contribute to it; with -regret, we cannot actually acknowledge everyone here. The file -@file{ChangeLog} in the GDB distribution approximates a blow-by-blow -account. - -Changes much prior to version 2.0 are lost in the mists of time. - -@quotation -@emph{Plea:} Additions to this section are particularly welcome. If you -or your friends (or enemies; let's be evenhanded) have been unfairly -omitted from this list, we would like to add your names! -@end quotation - -So that they may not regard their long labor as thankless, we -particularly thank those who shepherded GDB through major releases: John -Gilmore (releases _GDB_VN__, 4.0); Jim Kingdon (releases 3.9, 3.5, 3.4, 3.3); -and Randy Smith (releases 3.2, 3.1, 3.0). As major maintainer of GDB -for some period, each contributed significantly to the structure, -stability, and capabilities of the entire debugger. - -Richard Stallman, assisted at various times by Pete TerMaat, Chris -Hanson, and Richard Mlynarik, handled releases through 2.8. - -Michael Tiemann is the author of most of the GNU C++ support in GDB, -with significant additional contributions from Per Bothner. James -Clark wrote the GNU C++ demangler. Early work on C++ was by Peter -TerMaat (who also did much general update work leading to release 3.0). - -GDB _GDB_VN__ uses the BFD subroutine library to examine multiple -object-file formats; BFD was a joint project of V. Gumby -Henkel-Wallace, Rich Pixley, Steve Chamberlain, and John Gilmore. - -David Johnson wrote the original COFF support; Pace Willison did -the original support for encapsulated COFF. - -Adam de Boor and Bradley Davis contributed the ISI Optimum V support. -Per Bothner, Noboyuki Hikichi, and Alessandro Forin contributed MIPS -support. Jean-Daniel Fekete contributed Sun 386i support. Chris -Hanson improved the HP9000 support. Noboyuki Hikichi and Tomoyuki -Hasei contributed Sony/News OS 3 support. David Johnson contributed -Encore Umax support. Jyrki Kuoppala contributed Altos 3068 support. -Keith Packard contributed NS32K support. Doug Rabson contributed -Acorn Risc Machine support. Chris Smith contributed Convex support -(and Fortran debugging). Jonathan Stone contributed Pyramid support. -Michael Tiemann contributed SPARC support. Tim Tucker contributed -support for the Gould NP1 and Gould Powernode. Pace Willison -contributed Intel 386 support. Jay Vosburgh contributed Symmetry -support. - -Rich Schaefer and Peter Schauer helped with support of SunOS shared -libraries. - -Jay Fenlason and Roland McGrath ensured that GDB and GAS agree about -several machine instruction sets. - -Patrick Duval, Ted Goldstein, Vikram Koka and Glenn Engel helped -develop remote debugging. Intel Corporation and Wind River Systems -contributed remote debugging modules for their products. - -Brian Fox is the author of the readline libraries providing -command-line editing and command history. - -Andrew Beers of SUNY Buffalo wrote the language-switching code and -the Modula-2 support, and contributed the Languages chapter of this -manual. - -@node New Features, Sample Session, Summary, Top -@unnumbered New Features since _GDBN__ version 3.5 - -@table @emph -@item Targets -Using the new command @code{target}, you can select at runtime whether -you are debugging local files, local processes, standalone systems over -a serial port, realtime systems over a TCP/IP connection, etc. The -command @code{load} can download programs into a remote system. Serial -stubs are available for Motorola 680x0 and Intel 80386 remote systems; -_GDBN__ also supports debugging realtime processes running under -VxWorks, using SunRPC Remote Procedure Calls over TCP/IP to talk to a -debugger stub on the target system. Internally, _GDBN__ now uses a -function vector to mediate access to different targets; if you need to -add your own support for a remote protocol, this makes it much easier. - -@item Watchpoints -_GDBN__ now sports watchpoints as well as breakpoints. You can use a -watchpoint to stop execution whenever the value of an expression -changes, without having to predict a particular place in your program -where this may happen. - -@item Wide Output -Commands that issue wide output now insert newlines at places designed -to make the output more readable. - -@item Object Code Formats -_GDBN__ uses a new library called the Binary File Descriptor (BFD) -Library to permit it to switch dynamically, without reconfiguration or -recompilation, between different object-file formats. Formats currently -supported are COFF, a.out, and the Intel 960 b.out; files may be read as -.o's, archive libraries, or core dumps. BFD is available as a -subroutine library so that other programs may take advantage of it, and -the other GNU binary utilities are being converted to use it. - -@item Configuration and Ports -Compile-time configuration (to select a particular architecture and -operating system) is much easier. The script @code{configure} now -allows you to configure _GDBN__ as either a native debugger or a -cross-debugger. @xref{Installing _GDBN__} for details on how to -configure and on what architectures are now available. - -@item Interaction -The user interface to _GDBN__'s control variables has been simplified -and consolidated in two commands, @code{set} and @code{show}. Output -lines are now broken at readable places, rather than overflowing onto -the next line. You can suppress output of machine-level addresses, -displaying only source language information. - - -@item C++ -_GDBN__ now supports C++ multiple inheritance (if used with a GCC -version 2 compiler), and also has limited support for C++ exception -handling, with the commands @code{catch} and @code{info catch}: _GDBN__ -can break when an exception is raised, before the stack is peeled back -to the exception handler's context. - -@item Modula-2 -_GDBN__ now has preliminary support for the GNU Modula-2 compiler, -currently under development at the State University of New York at -Buffalo. Coordinated development of both _GDBN__ and the GNU Modula-2 -compiler will continue through the fall of 1991 and into 1992. Other -Modula-2 compilers are currently not supported, and attempting to debug -programs compiled with them will likely result in an error as the symbol -table of the executable is read in. - -@item Command Rationalization -Many _GDBN__ commands have been renamed to make them easier to remember -and use. In particular, the subcommands of @code{info} and -@code{show}/@code{set} are grouped to make the former refer to the state -of your program, and the latter refer to the state of _GDBN__ itself. -@xref{Renamed Commands}, for details on what commands were renamed. - -@item Shared Libraries -_GDBN__ _GDB_VN__ can debug programs and core files that use SunOS shared -libraries. - -@item Reference Card -_GDBN__ _GDB_VN__ has a reference card; @xref{Formatting Documentation} for -instructions on printing it. - -@item Work in Progress -Kernel debugging for BSD and Mach systems; Tahoe and HPPA architecture -support. - -@end table - -@node Sample Session, Invocation, New Features, Top -@chapter A Sample _GDBN__ Session - -You can use this manual at your leisure to read all about _GDBN__. -However, a handful of commands are enough to get started using the -debugger. This chapter illustrates these commands. - -@iftex -In this sample session, we emphasize user input like this: @i{input}, -to make it easier to pick out from the surrounding output. -@end iftex - -@c FIXME: this example may not be appropriate for some configs, where -@c FIXME...primary interest is in remote use. -_0__ -One of the preliminary versions of GNU @code{m4} (a generic macro -processor) exhibits the following bug: sometimes, when we change its -quote strings from the default, the commands used to capture one macro's -definition in another stop working. In the following short @code{m4} -session, we define a macro @code{foo} which expands to @code{0000}; we -then use the @code{m4} builtin @code{defn} to define @code{bar} as the -same thing. However, when we change the open quote string to -@code{} and the close quote string to @code{}, the same -procedure fails to define a new synonym @code{baz}: - -@smallexample -$ @i{cd gnu/m4} -$ @i{./m4} -@i{define(foo,0000)} - -@i{foo} -0000 -@i{define(bar,defn(`foo'))} - -@i{bar} -0000 -@i{changequote(,)} - -@i{define(baz,defn(foo))} -@i{baz} -@i{C-d} -m4: End of input: 0: fatal error: EOF in string -@end smallexample - -@noindent -Let's use _GDBN__ to try to see what's going on. - -@smallexample -$ @i{_GDBP__ m4} -GDB is free software and you are welcome to distribute copies of it - under certain conditions; type "info copying" to see the conditions. -There is absolutely no warranty for GDB; type "info warranty" for details. -GDB _GDB_VN__, Copyright 1991 Free Software Foundation, Inc... -(_GDBP__) -@end smallexample - -@noindent -_GDBN__ reads only enough symbol data to know where to find the rest -when needed; as a result, the first prompt comes up very quickly. We -then tell _GDBN__ to use a narrower display width than usual, so -that examples will fit in this manual. - -@smallexample -(_GDBP__) @i{set width 70} -@end smallexample - -@noindent -Let's see how the @code{m4} builtin @code{changequote} works. -Having looked at the source, we know the relevant subroutine is -@code{m4_changequote}, so we set a breakpoint there with _GDBN__'s -@code{break} command. - -@smallexample -(_GDBP__) @i{break m4_changequote} -Breakpoint 1 at 0x62f4: file builtin.c, line 879. -@end smallexample - -@noindent -Using the @code{run} command, we start @code{m4} running under _GDBN__ -control; as long as control does not reach the @code{m4_changequote} -subroutine, the program runs as usual: - -@smallexample -(_GDBP__) @i{run} -Starting program: /work/Editorial/gdb/gnu/m4/m4 -@i{define(foo,0000)} - -@i{foo} -0000 -@end smallexample - -@noindent -To trigger the breakpoint, we call @code{changequote}. _GDBN__ -suspends execution of @code{m4}, displaying information about the -context where it stops. - -@smallexample -@i{changequote(,)} - -Breakpoint 1, m4_changequote (argc=3, argv=0x33c70) at builtin.c:879 -879 if (bad_argc(TOKEN_DATA_TEXT(argv[0]), argc, 1, 3)) -@end smallexample - -@noindent -Now we use the command @code{n} (@code{next}) to advance execution to -the next line of the current function. - -@smallexample -(_GDBP__) @i{n} -882 set_quotes((argc >= 2) ? TOKEN_DATA_TEXT(argv[1]) : nil, -@end smallexample - -@noindent -@code{set_quotes} looks like a promising subroutine. We can go into it -by using the command @code{s} (@code{step}) instead of @code{next}. -@code{step} goes to the next line to be executed in @emph{any} -subroutine, so it steps into @code{set_quotes}. - -@smallexample -(_GDBP__) @i{s} -set_quotes (lq=0x34c78 "", rq=0x34c88 "") - at input.c:530 -530 if (lquote != def_lquote) -@end smallexample - -@noindent -The summary display showing the subroutine where @code{m4} is now -suspended (and its arguments) is called a stack frame display. We can -use the @code{backtrace} command (which can also be spelled @code{bt}), -to see where we are in the stack: it displays a stack frame for each -active subroutine. - -@smallexample -(_GDBP__) @i{bt} -#0 set_quotes (lq=0x34c78 "", rq=0x34c88 "") - at input.c:530 -#1 0x6344 in m4_changequote (argc=3, argv=0x33c70) at builtin.c:882 -#2 0x8174 in expand_macro (sym=0x33320) at macro.c:242 -#3 0x7a88 in expand_token (obs=0x0, t=209696, td=0xf7fffa30) - at macro.c:71 -#4 0x79dc in expand_input () at macro.c:40 -#5 0x2930 in main (argc=0, argv=0xf7fffb20) at m4.c:195 -@end smallexample - -@noindent -Let's step through a few more lines to see what happens. The first two -times, we can use @samp{s}; the next two times we use @code{n} to avoid -falling into the @code{xstrdup} subroutine. -@smallexample -(_GDBP__) @i{s} -0x3b5c 532 if (rquote != def_rquote) -(_GDBP__) @i{s} -0x3b80 535 lquote = (lq == nil || *lq == '\0') ? def_lquote :\ - xstrdup(lq); -(_GDBP__) @i{n} -536 rquote = (rq == nil || *rq == '\0') ? def_rquote : xstrdup\ -(rq); -(_GDBP__) @i{n} -538 len_lquote = strlen(rquote); -@end smallexample - -@noindent -The last line displayed looks a little odd; let's examine the variables -@code{lquote} and @code{rquote} to see if they are in fact the new left -and right quotes we specified. We can use the command @code{p} -(@code{print}) to see their values. - -@smallexample -(_GDBP__) @i{p lquote} -$1 = 0x35d40 "" -(_GDBP__) @i{p rquote} -$2 = 0x35d50 "" -@end smallexample - -@noindent -@code{lquote} and @code{rquote} are indeed the new left and right quotes. -Let's look at some context; we can display ten lines of source -surrounding the current line, with the @code{l} (@code{list}) command. - -@smallexample -(_GDBP__) @i{l} -533 xfree(rquote); -534 -535 lquote = (lq == nil || *lq == '\0') ? def_lquote : xstrdup\ -(lq); -536 rquote = (rq == nil || *rq == '\0') ? def_rquote : xstrdup\ -(rq); -537 -538 len_lquote = strlen(rquote); -539 len_rquote = strlen(lquote); -540 @} -541 -542 void -@end smallexample - -@noindent -Let's step past the two lines that set @code{len_lquote} and -@code{len_rquote}, and then examine the values of those variables. - -@smallexample -(_GDBP__) @i{n} -539 len_rquote = strlen(lquote); -(_GDBP__) @i{n} -540 @} -(_GDBP__) @i{p len_lquote} -$3 = 9 -(_GDBP__) @i{p len_rquote} -$4 = 7 -@end smallexample - -@noindent -That certainly looks wrong, assuming @code{len_lquote} and -@code{len_rquote} are meant to be the lengths of @code{lquote} and -@code{rquote} respectively. Let's try setting them to better values. -We can use the @code{p} command for this, since it'll print the value of -any expression---and that expression can include subroutine calls and -assignments. - -@smallexample -(_GDBP__) p len_lquote=strlen(lquote) -$5 = 7 -(_GDBP__) p len_rquote=strlen(rquote) -$6 = 9 -@end smallexample - -@noindent -Let's see if that fixes the problem of using the new quotes with the -@code{m4} built-in @code{defn}. We can allow @code{m4} to continue -executing with the @code{c} (@code{continue}) command, and then try the -example that caused trouble initially: - -@smallexample -(_GDBP__) @i{c} -Continuing. - -@i{define(baz,defn(foo))} - -baz -0000 -@end smallexample - -@noindent -Success! The new quotes now work just as well as the default ones. The -problem seems to have been just the two typos defining the wrong -lengths. We'll let @code{m4} exit by giving it an EOF as input. - -@smallexample -@i{C-d} -Program exited normally. -@end smallexample - -@noindent -The message @samp{Program exited normally.} is from _GDBN__; it -indicates @code{m4} has finished executing. We can end our _GDBN__ -session with the _GDBN__ @code{quit} command. - -@smallexample -(_GDBP__) @i{quit} -_1__@end smallexample - -@node Invocation, Commands, Sample Session, Top -@chapter Getting In and Out of _GDBN__ - -@menu -* Starting _GDBN__:: Starting _GDBN__ -* Leaving _GDBN__:: Leaving _GDBN__ -* Shell Commands:: Shell Commands -@end menu - -@node Starting _GDBN__, Leaving _GDBN__, Invocation, Invocation -@section Starting _GDBN__ - -_GDBN__ is invoked with the shell command @code{_GDBP__}. Once started, -it reads commands from the terminal until you tell it to exit. - -You can run @code{_GDBP__} with no arguments or options; but the most -usual way to start _GDBN__ is with one argument or two, specifying an -executable program as the argument: -@example -_GDBP__ program -@end example -@noindent -You can also start with both an executable program and a core file specified: -@example -_GDBP__ program core -@end example - -You can, instead, specify a process ID as a second argument, if you want -to debug a running process: -@example -_GDBP__ program 1234 -@end example -@noindent -would attach _GDBN__ to process @code{1234} (unless you also have a file -named @file{1234}; _GDBN__ does check for a core file first). - -@noindent -You can further control how _GDBN__ starts up by using command-line -options. _GDBN__ itself can remind you of the options available: -@example -_GDBP__ -help -@end example -@noindent -will display all available options and briefly describe their use -(@samp{_GDBP__ -h} is a shorter equivalent). - -All options and command line arguments you give are processed -in sequential order. The order makes a difference when the -@samp{-x} option is used. - -@menu -* File Options:: Choosing Files -* Mode Options:: Choosing Modes -_if__(!_GENERIC__) -_include__(gdbinv-m.m4)_dnl__ -_fi__(!_GENERIC__) -@end menu - -@node File Options, Mode Options, Starting _GDBN__, Starting _GDBN__ -@subsection Choosing Files - -As shown above, any arguments other than options specify an executable -file and core file; that is, the first argument encountered with no -associated option flag is equivalent to a @samp{-se} option, and the -second, if any, is equivalent to a @samp{-c} option. Many options have -both long and short forms; both are shown here. The long forms are also -recognized if you truncate them, so long as enough of the option is -present to be unambiguous. (If you prefer, you can flag option -arguments with @samp{+} rather than @samp{-}, though we illustrate the -more usual convention.) - -@table @code -@item -symbols=@var{file} -@itemx -s @var{file} -Read symbol table from file @var{file}. - -@item -exec=@var{file} -@itemx -e @var{file} -Use file @var{file} as the executable file to execute when -appropriate, and for examining pure data in conjunction with a core -dump. - -@item -se=@var{file} -Read symbol table from file @var{file} and use it as the executable -file. - -@item -core=@var{file} -@itemx -c @var{file} -Use file @var{file} as a core dump to examine. - -@item -command=@var{file} -@itemx -x @var{file} -Execute _GDBN__ commands from file @var{file}. @xref{Command Files}. - -@item -directory=@var{directory} -@itemx -d @var{directory} -Add @var{directory} to the path to search for source files. -@end table - -_if__(!_GENERIC__) -@node Mode Options, Mode Options, File Options, Starting _GDBN__ -_fi__(!_GENERIC__) -_if__(_GENERIC__) -@node Mode Options, , File Options, Starting _GDBN__ -_fi__(_GENERIC__) -@subsection Choosing Modes - -@table @code -@item -nx -@itemx -n -Do not execute commands from any @file{_GDBINIT__} initialization files. -Normally, the commands in these files are executed after all the -command options and arguments have been processed. -@xref{Command Files}. - -@item -quiet -@itemx -q -``Quiet''. Do not print the introductory and copyright messages. These -messages are also suppressed in batch mode. - -@item -batch -Run in batch mode. Exit with status @code{0} after processing all the command -files specified with @samp{-x} (and @file{_GDBINIT__}, if not inhibited). -Exit with nonzero status if an error occurs in executing the _GDBN__ -commands in the command files. - -Batch mode may be useful for running _GDBN__ as a filter, for example to -download and run a program on another computer; in order to make this -more useful, the message -@example -Program exited normally. -@end example -@noindent -(which is ordinarily issued whenever a program running under _GDBN__ control -terminates) is not issued when running in batch mode. - -@item -cd=@var{directory} -Run _GDBN__ using @var{directory} as its working directory, -instead of the current directory. - -@item -fullname -@itemx -f -Emacs sets this option when it runs _GDBN__ as a subprocess. It tells _GDBN__ -to output the full file name and line number in a standard, -recognizable fashion each time a stack frame is displayed (which -includes each time the program stops). This recognizable format looks -like two @samp{\032} characters, followed by the file name, line number -and character position separated by colons, and a newline. The -Emacs-to-_GDBN__ interface program uses the two @samp{\032} characters as -a signal to display the source code for the frame. - -@item -b @var{bps} -Set the line speed (baud rate or bits per second) of any serial -interface used by _GDBN__ for remote debugging. - -@item -tty=@var{device} -Run using @var{device} for your program's standard input and output. -@c FIXME: kingdon thinks there's more to -tty. Investigate. -@end table - -_if__(!_GENERIC__) -_include__(gdbinv-s.m4) -_fi__(!_GENERIC__) - -@node Leaving _GDBN__, Shell Commands, Starting _GDBN__, Invocation -@section Leaving _GDBN__ -@cindex exiting _GDBN__ -@table @code -@item quit -@kindex quit -@kindex q -To exit _GDBN__, use the @code{quit} command (abbreviated @code{q}), or type -an end-of-file character (usually @kbd{C-d}). -@end table - -@cindex interrupt -An interrupt (often @kbd{C-c}) will not exit from _GDBN__, but rather -will terminate the action of any _GDBN__ command that is in progress and -return to _GDBN__ command level. It is safe to type the interrupt -character at any time because _GDBN__ does not allow it to take effect -until a time when it is safe. - -If you've been using _GDBN__ to control an attached process or device, -you can release it with the @code{detach} command; @pxref{Attach}. - -@node Shell Commands, , Leaving _GDBN__, Invocation -@section Shell Commands -If you need to execute occasional shell commands during your -debugging session, there's no need to leave or suspend _GDBN__; you can -just use the @code{shell} command. - -@table @code -@item shell @var{command string} -@kindex shell -@cindex shell escape -Directs _GDBN__ to invoke an inferior shell to execute @var{command -string}. If it exists, the environment variable @code{SHELL} is used -for the name of the shell to run. Otherwise _GDBN__ uses -@code{/bin/sh}. -@end table - -The utility @code{make} is often needed in development environments. -You don't have to use the @code{shell} command for this purpose in _GDBN__: - -@table @code -@item make @var{make-args} -@kindex make -@cindex calling make -Causes _GDBN__ to execute an inferior @code{make} program with the specified -arguments. This is equivalent to @samp{shell make @var{make-args}}. -@end table - -@node Commands, Running, Invocation, Top -@chapter _GDBN__ Commands - -@menu -* Command Syntax:: Command Syntax -* Help:: Getting Help -@end menu - -@node Command Syntax, Help, Commands, Commands -@section Command Syntax -A _GDBN__ command is a single line of input. There is no limit on how long -it can be. It starts with a command name, which is followed by arguments -whose meaning depends on the command name. For example, the command -@code{step} accepts an argument which is the number of times to step, -as in @samp{step 5}. You can also use the @code{step} command with -no arguments. Some command names do not allow any arguments. - -@cindex abbreviation -_GDBN__ command names may always be truncated if that abbreviation is -unambiguous. Other possible command abbreviations are listed in the -documentation for individual commands. In some cases, even ambiguous -abbreviations are allowed; for example, @code{s} is specially defined as -equivalent to @code{step} even though there are other commands whose -names start with @code{s}. You can test abbreviations by using them as -arguments to the @code{help} command. - -@cindex repeating commands -@kindex RET -A blank line as input to _GDBN__ (typing just @key{RET}) means to -repeat the previous command. Certain commands (for example, @code{run}) -will not repeat this way; these are commands for which unintentional -repetition might cause trouble and which you are unlikely to want to -repeat. - -The @code{list} and @code{x} commands, when you repeat them with -@key{RET}, construct new arguments rather than repeating -exactly as typed. This permits easy scanning of source or memory. - -_GDBN__ can also use @key{RET} in another way: to partition lengthy -output, in a way similar to the common utility @code{more} -(@pxref{Screen Size}). Since it's easy to press one @key{RET} too many -in this situation, _GDBN__ disables command repetition after any command -that generates this sort of display. - -@kindex # -@cindex comment -A line of input starting with @kbd{#} is a comment; it does nothing. -This is useful mainly in command files (@xref{Command Files}). - -@node Help, , Command Syntax, Commands -@section Getting Help -@cindex online documentation -@kindex help -You can always ask _GDBN__ itself for information on its commands, using the -command @code{help}. - -@table @code -@item help -@itemx h -@kindex h -You can use @code{help} (abbreviated @code{h}) with no arguments to -display a short list of named classes of commands: -@smallexample -(_GDBP__) help -List of classes of commands: - -running -- Running the program -stack -- Examining the stack -data -- Examining data -breakpoints -- Making program stop at certain points -files -- Specifying and examining files -status -- Status inquiries -support -- Support facilities -user-defined -- User-defined commands -aliases -- Aliases of other commands -obscure -- Obscure features - -Type "help" followed by a class name for a list of commands in that class. -Type "help" followed by command name for full documentation. -Command name abbreviations are allowed if unambiguous. -(_GDBP__) -@end smallexample - -@item help @var{class} -Using one of the general help classes as an argument, you can get a -list of the individual commands in that class. For example, here is the -help display for the class @code{status}: -@smallexample -(_GDBP__) help status -Status inquiries. - -List of commands: - -show -- Generic command for showing things set with "set" -info -- Generic command for printing status - -Type "help" followed by command name for full documentation. -Command name abbreviations are allowed if unambiguous. -(_GDBP__) -@end smallexample - -@item help @var{command} -With a command name as @code{help} argument, _GDBN__ will display a -short paragraph on how to use that command. -@end table - -In addition to @code{help}, you can use the _GDBN__ commands @code{info} -and @code{show} to inquire about the state of your program, or the state -of _GDBN__ itself. Each command supports many topics of inquiry; this -manual introduces each of them in the appropriate context. The listings -under @code{info} and under @code{show} in the Index point to -all the sub-commands. -@c FIXME: @pxref{Index} used to be here, but even though it shows up in -@c FIXME...the 'aux' file with a pageno the xref can't find it. - -@c @group -@table @code -@item info -@kindex info -@kindex i -This command (abbreviated @code{i}) is for describing the state of your -program; for example, it can list the arguments given to your program -(@code{info args}), the registers currently in use (@code{info -registers}), or the breakpoints you've set (@code{info breakpoints}). -You can get a complete list of the @code{info} sub-commands with -@w{@code{help info}}. - -@kindex show -@item show -In contrast, @code{show} is for describing the state of _GDBN__ itself. -You can change most of the things you can @code{show}, by using the -related command @code{set}; for example, you can control what number -system is used for displays with @code{set radix}, or simply inquire -which is currently in use with @code{show radix}. - -@kindex info set -To display all the settable parameters and their current -values, you can use @code{show} with no arguments; you may also use -@code{info set}. Both commands produce the same display. -@c FIXME: "info set" violates the rule that "info" is for state of -@c FIXME...program. Ck w/ GNU: "info set" to be called something else, -@c FIXME...or change desc of rule---eg "state of prog and debugging session"? -@end table -@c @end group - -Here are three miscellaneous @code{show} subcommands, all of which are -exceptional in lacking corresponding @code{set} commands: - -@table @code -@kindex show version -@cindex version number -@item show version -Show what version of _GDBN__ is running. You should include this -information in _GDBN__ bug-reports. If multiple versions of _GDBN__ are -in use at your site, you may occasionally want to make sure what version -of _GDBN__ you're running; as _GDBN__ evolves, new commands are -introduced, and old ones may wither away. The version number is also -announced when you start _GDBN__ with no arguments. - -@kindex show copying -@item show copying -Display information about permission for copying _GDBN__. - -@kindex show warranty -@item show warranty -Display the GNU ``NO WARRANTY'' statement. -@end table - -@node Running, Stopping, Commands, Top -@chapter Running Programs Under _GDBN__ - -@menu -* Compilation:: Compiling for Debugging -* Starting:: Starting your Program -* Arguments:: Your Program's Arguments -* Environment:: Your Program's Environment -* Working Directory:: Your Program's Working Directory -* Input/Output:: Your Program's Input and Output -* Attach:: Debugging an Already-Running Process -* Kill Process:: Killing the Child Process -@end menu - -@node Compilation, Starting, Running, Running -@section Compiling for Debugging - -In order to debug a program effectively, you need to generate -debugging information when you compile it. This debugging information -is stored in the object file; it describes the data type of each -variable or function and the correspondence between source line numbers -and addresses in the executable code. - -To request debugging information, specify the @samp{-g} option when you run -the compiler. - -Many C compilers are unable to handle the @samp{-g} and @samp{-O} -options together. Using those compilers, you cannot generate optimized -executables containing debugging information. - -The GNU C compiler supports @samp{-g} with or without @samp{-O}, making it -possible to debug optimized code. We recommend that you @emph{always} use -@samp{-g} whenever you compile a program. You may think the program is -correct, but there's no sense in pushing your luck. - -Some things do not work as well with @samp{-g -O} as with just -@samp{-g}, particularly on machines with instruction scheduling. If in -doubt, recompile with @samp{-g} alone, and if this fixes the problem, -please report it as a bug (including a test case!). - -Older versions of the GNU C compiler permitted a variant option -@samp{-gg} for debugging information. _GDBN__ no longer supports this -format; if your GNU C compiler has this option, do not use it. - -@ignore -@comment As far as I know, there are no cases in which _GDBN__ will -@comment produce strange output in this case. (but no promises). -If your program includes archives made with the @code{ar} program, and -if the object files used as input to @code{ar} were compiled without the -@samp{-g} option and have names longer than 15 characters, _GDBN__ will get -confused reading the program's symbol table. No error message will be -given, but _GDBN__ may behave strangely. The reason for this problem is a -deficiency in the Unix archive file format, which cannot represent file -names longer than 15 characters. - -To avoid this problem, compile the archive members with the @samp{-g} -option or use shorter file names. Alternatively, use a version of GNU -@code{ar} dated more recently than August 1989. -@end ignore - - -@node Starting, Arguments, Compilation, Running -@section Starting your Program -@cindex starting -@cindex running -@table @code -@item run -@itemx r -@kindex run -Use the @code{run} command to start your program under _GDBN__. You -must first specify the program name -_if__(_VXWORKS__) -(except on VxWorks) -_fi__(_VXWORKS__) -with an argument to _GDBN__ -(@pxref{Invocation}), or using the @code{file} or @code{exec-file} -command (@pxref{Files}). -@refill -@end table - -On targets that support processes, @code{run} creates an inferior -process and makes that process run your program. On other targets, -@code{run} jumps to the start of the program. - -The execution of a program is affected by certain information it -receives from its superior. _GDBN__ provides ways to specify this -information, which you must do @i{before} starting the program. (You -can change it after starting the program, but such changes will only affect -the program the next time you start it.) This information may be -divided into four categories: - -@table @asis -@item The @i{arguments.} -You specify the arguments to give your program as the arguments of the -@code{run} command. If a shell is available on your target, the shell -is used to pass the arguments, so that you may use normal conventions -(such as wildcard expansion or variable substitution) in -describing the arguments. In Unix systems, you can control which shell -is used with the @code{SHELL} environment variable. @xref{Arguments}.@refill - -@item The @i{environment.} -Your program normally inherits its environment from _GDBN__, but you can -use the _GDBN__ commands @code{set environment} and @code{unset -environment} to change parts of the environment that will be given to -the program. @xref{Environment}.@refill - -@item The @i{working directory.} -Your program inherits its working directory from _GDBN__. You can set -_GDBN__'s working directory with the @code{cd} command in _GDBN__. -@xref{Working Directory}. - -@item The @i{standard input and output.} -Your program normally uses the same device for standard input and -standard output as _GDBN__ is using. You can redirect input and output -in the @code{run} command line, or you can use the @code{tty} command to -set a different device for your program. -@xref{Input/Output}. - -@cindex pipes -@emph{Warning:} While input and output redirection work, you can't use -pipes to pass the output of the program you're debugging to another -program; if you attempt this, _GDBN__ is likely to wind up debugging the -wrong program. -@end table - -When you issue the @code{run} command, your program begins to execute -immediately. @xref{Stopping}, for discussion of how to arrange for your -program to stop. Once your program has been started by the @code{run} -command (and then stopped), you may evaluate expressions that involve -calls to functions in the inferior, using the @code{print} or -@code{call} commands. @xref{Data}. - -If the modification time of your symbol file has changed since the last -time _GDBN__ read its symbols, _GDBN__ will discard its symbol table and re-read -it. In this process, it tries to retain your current breakpoints. - -@node Arguments, Environment, Starting, Running -@section Your Program's Arguments - -@cindex arguments (to your program) -The arguments to your program can be specified by the arguments of the -@code{run} command. They are passed to a shell, which expands wildcard -characters and performs redirection of I/O, and thence to the program. -_GDBN__ uses the shell indicated by your environment variable -@code{SHELL} if it exists; otherwise, _GDBN__ uses @code{/bin/sh}. - -@code{run} with no arguments uses the same arguments used by the previous -@code{run}, or those set by the @code{set args} command. - -@kindex set args -@table @code -@item set args -Specify the arguments to be used the next time your program is run. If -@code{set args} has no arguments, @code{run} will execute your program -with no arguments. Once you have run your program with arguments, -using @code{set args} before the next @code{run} is the only way to run -it again without arguments. - -@item show args -@kindex show args -Show the arguments to give your program when it is started. -@end table - -@node Environment, Working Directory, Arguments, Running -@section Your Program's Environment - -@cindex environment (of your program) -The @dfn{environment} consists of a set of environment variables and -their values. Environment variables conventionally record such things as -your user name, your home directory, your terminal type, and your search -path for programs to run. Usually you set up environment variables with -the shell and they are inherited by all the other programs you run. When -debugging, it can be useful to try running the program with a modified -environment without having to start _GDBN__ over again. - -@table @code -@item path @var{directory} -@kindex path -Add @var{directory} to the front of the @code{PATH} environment variable -(the search path for executables), for both _GDBN__ and your program. -You may specify several directory names, separated by @samp{:} or -whitespace. If @var{directory} is already in the path, it is moved to -the front, so it will be searched sooner. - -You can use the string @samp{$cwd} to refer to whatever is the current -working directory at the time _GDBN__ searches the path. If you use -@samp{.} instead, it refers to the directory where you executed the -@code{path} command. _GDBN__ fills in the current path where needed in -the @var{directory} argument, before adding it to the search path. -@c 'path' is explicitly nonrepeatable, but RMS points out it's silly to -@c document that, since repeating it would be a no-op. - -@item show paths -@kindex show paths -Display the list of search paths for executables (the @code{PATH} -environment variable). - -@item show environment @r{[}@var{varname}@r{]} -@kindex show environment -Print the value of environment variable @var{varname} to be given to -your program when it starts. If you don't supply @var{varname}, -print the names and values of all environment variables to be given to -your program. You can abbreviate @code{environment} as @code{env}. - -@item set environment @var{varname} @r{[}=@r{]} @var{value} -@kindex set environment -Sets environment variable @var{varname} to @var{value}. The value -changes for your program only, not for _GDBN__ itself. @var{value} may -be any string; the values of environment variables are just strings, and -any interpretation is supplied by your program itself. The @var{value} -parameter is optional; if it is eliminated, the variable is set to a -null value. -@c "any string" here doesn't include leading, trailing -@c blanks. Gnu asks: does anyone care? - -For example, this command: - -@example -set env USER = foo -@end example - -@noindent -tells a Unix program, when subsequently run, that its user is named -@samp{foo}. (The spaces around @samp{=} are used for clarity here; they -are not actually required.) - -@item unset environment @var{varname} -@kindex unset environment -Remove variable @var{varname} from the environment to be passed to your -program. This is different from @samp{set env @var{varname} =}; -@code{unset environment} removes the variable from the environment, -rather than assigning it an empty value. -@end table - -@node Working Directory, Input/Output, Environment, Running -@section Your Program's Working Directory - -@cindex working directory (of your program) -Each time you start your program with @code{run}, it inherits its -working directory from the current working directory of _GDBN__. _GDBN__'s -working directory is initially whatever it inherited from its parent -process (typically the shell), but you can specify a new working -directory in _GDBN__ with the @code{cd} command. - -The _GDBN__ working directory also serves as a default for the commands -that specify files for _GDBN__ to operate on. @xref{Files}. - -@table @code -@item cd @var{directory} -@kindex cd -Set _GDBN__'s working directory to @var{directory}. - -@item pwd -@kindex pwd -Print _GDBN__'s working directory. -@end table - -@node Input/Output, Attach, Working Directory, Running -@section Your Program's Input and Output - -@cindex redirection -@cindex i/o -@cindex terminal -By default, the program you run under _GDBN__ does input and output to -the same terminal that _GDBN__ uses. _GDBN__ switches the terminal to -its own terminal modes to interact with you, but it records the terminal -modes your program was using and switches back to them when you continue -running your program. - -@table @code -@item info terminal -@kindex info terminal -Displays _GDBN__'s recorded information about the terminal modes your -program is using. -@end table - -You can redirect the program's input and/or output using shell -redirection with the @code{run} command. For example, - -_0__@example -run > outfile -_1__@end example - -@noindent -starts the program, diverting its output to the file @file{outfile}. - -@kindex tty -@cindex controlling terminal -Another way to specify where the program should do input and output is -with the @code{tty} command. This command accepts a file name as -argument, and causes this file to be the default for future @code{run} -commands. It also resets the controlling terminal for the child -process, for future @code{run} commands. For example, - -@example -tty /dev/ttyb -@end example - -@noindent -directs that processes started with subsequent @code{run} commands -default to do input and output on the terminal @file{/dev/ttyb} and have -that as their controlling terminal. - -An explicit redirection in @code{run} overrides the @code{tty} command's -effect on the input/output device, but not its effect on the controlling -terminal. - -When you use the @code{tty} command or redirect input in the @code{run} -command, only the input @emph{for your program} is affected. The input -for _GDBN__ still comes from your terminal. - -@node Attach, Kill Process, Input/Output, Running -@section Debugging an Already-Running Process -@kindex attach -@cindex attach - -@table @code -@item attach @var{process-id} -This command -attaches to a running process---one that was started outside _GDBN__. -(@code{info files} will show your active targets.) The command takes as -argument a process ID. The usual way to find out the process-id of -a Unix process is with the @code{ps} utility, or with the @samp{jobs -l} -shell command. - -@code{attach} will not repeat if you press @key{RET} a second time after -executing the command. -@end table - -To use @code{attach}, you must be debugging in an environment which -supports processes. You must also have permission to send the process a -signal, and it must have the same effective user ID as the _GDBN__ -process. - -When using @code{attach}, you should first use the @code{file} command -to specify the program running in the process and load its symbol table. -@xref{Files}. - -The first thing _GDBN__ does after arranging to debug the specified -process is to stop it. You can examine and modify an attached process -with all the _GDBN__ commands that are ordinarily available when you start -processes with @code{run}. You can insert breakpoints; you can step and -continue; you can modify storage. If you would rather the process -continue running, you may use the @code{continue} command after -attaching _GDBN__ to the process. - -@table @code -@item detach -@kindex detach -When you have finished debugging the attached process, you can use the -@code{detach} command to release it from _GDBN__'s control. Detaching -the process continues its execution. After the @code{detach} command, -that process and _GDBN__ become completely independent once more, and you -are ready to @code{attach} another process or start one with @code{run}. -@code{detach} will not repeat if you press @key{RET} again after -executing the command. -@end table - -If you exit _GDBN__ or use the @code{run} command while you have an attached -process, you kill that process. By default, you will be asked for -confirmation if you try to do either of these things; you can control -whether or not you need to confirm by using the @code{set confirm} command -(@pxref{Messages/Warnings}). - -@node Kill Process, , Attach, Running -@c @group -@section Killing the Child Process - -@table @code -@item kill -@kindex kill -Kill the child process in which your program is running under _GDBN__. -@end table - -This command is useful if you wish to debug a core dump instead of a -running process. _GDBN__ ignores any core dump file while your program -is running. -@c @end group - -On some operating systems, a program can't be executed outside _GDBN__ -while you have breakpoints set on it inside _GDBN__. You can use the -@code{kill} command in this situation to permit running the program -outside the debugger. - -The @code{kill} command is also useful if you wish to recompile and -relink the program, since on many systems it is impossible to modify an -executable file while it is running in a process. In this case, when you -next type @code{run}, _GDBN__ will notice that the file has changed, and -will re-read the symbol table (while trying to preserve your current -breakpoint settings). - -@node Stopping, Stack, Running, Top -@chapter Stopping and Continuing - -The principal purpose of using a debugger is so that you can stop your -program before it terminates; or so that, if the program runs into -trouble, you can investigate and find out why. - -Inside _GDBN__, your program may stop for any of several reasons, such -as a signal, a breakpoint, or reaching a new line after a _GDBN__ -command such as @code{step}. You may then examine and change -variables, set new breakpoints or remove old ones, and then continue -execution. Usually, the messages shown by _GDBN__ provide ample -explanation of the status of your program---but you can also explicitly -request this information at any time. - -@table @code -@item info program -@kindex info program -Display information about the status of your program: whether it is -running or not, what process it is, and why it stopped. -@end table - -@menu -* Breakpoints:: Breakpoints, Watchpoints, and Exceptions -* Continuing and Stepping:: Resuming Execution -* Signals:: Signals -@end menu - -@node Breakpoints, Continuing and Stepping, Stopping, Stopping -@section Breakpoints, Watchpoints, and Exceptions - -@cindex breakpoints -A @dfn{breakpoint} makes your program stop whenever a certain point in -the program is reached. For each breakpoint, you can add various -conditions to control in finer detail whether the program will stop. -You can set breakpoints with the @code{break} command and its variants -(@pxref{Set Breaks}), to specify the place where the program should stop -by line number, function name or exact address in the program. In -languages with exception handling (such as GNU C++), you can also set -breakpoints where an exception is raised (@pxref{Exception Handling}). - -@cindex watchpoints -A @dfn{watchpoint} is a special breakpoint that stops your program when -the value of an expression changes. You must use a different command to -set watchpoints (@pxref{Set Watchpoints}), but aside from that, you can -manage a watchpoint like any other breakpoint: you enable, disable, and -delete both breakpoints and watchpoints using the same commands. - -Each breakpoint or watchpoint is assigned a number when it is created; -these numbers are successive integers starting with one. In many of the -commands for controlling various features of breakpoints you use the -breakpoint number to say which breakpoint you want to change. Each -breakpoint may be @dfn{enabled} or @dfn{disabled}; if disabled, it has -no effect on the program until you enable it again. - -@menu -* Set Breaks:: Setting Breakpoints -* Set Watchpoints:: Setting Watchpoints -* Exception Handling:: Breakpoints and Exceptions -* Delete Breaks:: Deleting Breakpoints -* Disabling:: Disabling Breakpoints -* Conditions:: Break Conditions -* Break Commands:: Breakpoint Command Lists -* Breakpoint Menus:: Breakpoint Menus -* Error in Breakpoints:: -@end menu - -@node Set Breaks, Set Watchpoints, Breakpoints, Breakpoints -@subsection Setting Breakpoints - -@kindex break -@kindex b -Breakpoints are set with the @code{break} command (abbreviated @code{b}). - -You have several ways to say where the breakpoint should go. - -@table @code -@item break @var{function} -Set a breakpoint at entry to function @var{function}. When using source -languages that permit overloading of symbols, such as C++, -@var{function} may refer to more than one possible place to break. -@xref{Breakpoint Menus}, for a discussion of that situation. - -@item break +@var{offset} -@itemx break -@var{offset} -Set a breakpoint some number of lines forward or back from the position -at which execution stopped in the currently selected frame. - -@item break @var{linenum} -Set a breakpoint at line @var{linenum} in the current source file. -That file is the last file whose source text was printed. This -breakpoint will stop the program just before it executes any of the -code on that line. - -@item break @var{filename}:@var{linenum} -Set a breakpoint at line @var{linenum} in source file @var{filename}. - -@item break @var{filename}:@var{function} -Set a breakpoint at entry to function @var{function} found in file -@var{filename}. Specifying a file name as well as a function name is -superfluous except when multiple files contain similarly named -functions. - -@item break *@var{address} -Set a breakpoint at address @var{address}. You can use this to set -breakpoints in parts of the program which do not have debugging -information or source files. - -@item break -When called without any arguments, @code{break} sets a breakpoint at the -next instruction to be executed in the selected stack frame -(@pxref{Stack}). In any selected frame but the innermost, this will -cause the program to stop as soon as control returns to that frame. -This is similar to the effect of a @code{finish} command in the frame -inside the selected frame---except that @code{finish} doesn't leave an -active breakpoint. If you use @code{break} without an argument in the -innermost frame, _GDBN__ will stop the next time it reaches the current -location; this may be useful inside loops. - -_GDBN__ normally ignores breakpoints when it resumes execution, until at -least one instruction has been executed. If it did not do this, you -would be unable to proceed past a breakpoint without first disabling the -breakpoint. This rule applies whether or not the breakpoint already -existed when the program stopped. - -@item break @dots{} if @var{cond} -Set a breakpoint with condition @var{cond}; evaluate the expression -@var{cond} each time the breakpoint is reached, and stop only if the -value is nonzero---that is, if @var{cond} evaluates as true. -@samp{@dots{}} stands for one of the possible arguments described above -(or no argument) specifying where to break. @xref{Conditions}, for more -information on breakpoint conditions. - -@item tbreak @var{args} -@kindex tbreak -Set a breakpoint enabled only for one stop. @var{args} are the -same as for the @code{break} command, and the breakpoint is set in the same -way, but the breakpoint is automatically disabled the first time it -is hit. @xref{Disabling}. - -@item rbreak @var{regex} -@kindex rbreak -@cindex regular expression -Set breakpoints on all functions matching the regular expression -@var{regex}. This command -sets an unconditional breakpoint on all matches, printing a list of all -breakpoints it set. Once these breakpoints are set, they are treated -just like the breakpoints set with the @code{break} command. They can -be deleted, disabled, made conditional, etc., in the standard ways. - -When debugging C++ programs, @code{rbreak} is useful for setting -breakpoints on overloaded functions that are not members of any special -classes. - -@kindex info breakpoints -@cindex @code{$_} and @code{info breakpoints} -@item info breakpoints @r{[}@var{n}@r{]} -@item info break @r{[}@var{n}@r{]} -Print a list of all breakpoints (but not watchpoints) set and not -deleted, showing their numbers, where in the program they are, and any -special features in use for them. Disabled breakpoints are included in -the list, but marked as disabled. @code{info break} with a breakpoint -number @var{n} as argument lists only that breakpoint. The convenience -variable @code{$_} and the default examining-address for the @code{x} -command are set to the address of the last breakpoint listed -(@pxref{Memory}). The equivalent command for watchpoints is @code{info -watch}. @end table - -_GDBN__ allows you to set any number of breakpoints at the same place in the -program. There is nothing silly or meaningless about this. When the -breakpoints are conditional, this is even useful (@pxref{Conditions}). - -@node Set Watchpoints, Exception Handling, Set Breaks, Breakpoints -@subsection Setting Watchpoints -@cindex setting watchpoints -You can use a watchpoint to stop execution whenever the value of an -expression changes, without having to predict a particular place -where this may happen. - -Watchpoints currently execute two orders of magnitude more slowly than -other breakpoints, but this can well be worth it to catch errors where -you have no clue what part of your program is the culprit. Some -processors provide special hardware to support watchpoint evaluation; future -releases of _GDBN__ will use such hardware if it is available. - -@table @code -@kindex watch -@item watch @var{expr} -Set a watchpoint for an expression. - -@kindex info watchpoints -@item info watchpoints -This command prints a list of watchpoints; it is otherwise similar to -@code{info break}. -@end table - -@node Exception Handling, Delete Breaks, Set Watchpoints, Breakpoints -@subsection Breakpoints and Exceptions -@cindex exception handlers - -Some languages, such as GNU C++, implement exception handling. You can -use _GDBN__ to examine what caused the program to raise an exception, -and to list the exceptions the program is prepared to handle at a -given point in time. - -@table @code -@item catch @var{exceptions} -@kindex catch -You can set breakpoints at active exception handlers by using the -@code{catch} command. @var{exceptions} is a list of names of exceptions -to catch. -@end table - -You can use @code{info catch} to list active exception handlers; -@pxref{Frame Info}. - -There are currently some limitations to exception handling in _GDBN__. -These will be corrected in a future release. - -@itemize @bullet -@item -If you call a function interactively, _GDBN__ normally returns -control to you when the function has finished executing. If the call -raises an exception, however, the call may bypass the mechanism that -returns control to the user and cause the program to simply continue -running until it hits a breakpoint, catches a signal that _GDBN__ is -listening for, or exits. -@item -You cannot raise an exception interactively. -@item -You cannot interactively install an exception handler. -@end itemize - -@cindex raise exceptions -Sometimes @code{catch} is not the best way to debug exception handling: -if you need to know exactly where an exception is raised, it's better to -stop @emph{before} the exception handler is called, since that way you -can see the stack before any unwinding takes place. If you set a -breakpoint in an exception handler instead, it may not be easy to find -out where the exception was raised. - -To stop just before an exception handler is called, you need some -knowledge of the implementation. In the case of GNU C++, exceptions are -raised by calling a library function named @code{__raise_exception} -which has the following ANSI C interface: - -@example - /* @var{addr} is where the exception identifier is stored. - ID is the exception identifier. */ - void __raise_exception (void **@var{addr}, void *@var{id}); -@end example - -@noindent -To make the debugger catch all exceptions before any stack -unwinding takes place, set a breakpoint on @code{__raise_exception} -(@pxref{Breakpoints}). - -With a conditional breakpoint (@xref{Conditions}) that depends on the -value of @var{id}, you can stop your program when a specific exception -is raised. You can use multiple conditional breakpoints to stop the -program when any of a number of exceptions are raised. - -@node Delete Breaks, Disabling, Exception Handling, Breakpoints -@subsection Deleting Breakpoints - -@cindex clearing breakpoints, watchpoints -@cindex deleting breakpoints, watchpoints -It is often necessary to eliminate a breakpoint or watchpoint once it -has done its job and you no longer want the program to stop there. This -is called @dfn{deleting} the breakpoint. A breakpoint that has been -deleted no longer exists; it is forgotten. - -With the @code{clear} command you can delete breakpoints according to -where they are in the program. With the @code{delete} command you can -delete individual breakpoints or watchpoints by specifying their -breakpoint numbers. - -It is not necessary to delete a breakpoint to proceed past it. _GDBN__ -automatically ignores breakpoints on the first instruction to be executed -when you continue execution without changing the execution address. - -@table @code -@item clear -@kindex clear -Delete any breakpoints at the next instruction to be executed in the -selected stack frame (@pxref{Selection}). When the innermost frame -is selected, this is a good way to delete a breakpoint that the program -just stopped at. - -@item clear @var{function} -@itemx clear @var{filename}:@var{function} -Delete any breakpoints set at entry to the function @var{function}. - -@item clear @var{linenum} -@itemx clear @var{filename}:@var{linenum} -Delete any breakpoints set at or within the code of the specified line. - -@item delete @r{[}breakpoints@r{]} @r{[}@var{bnums}@dots{}@r{]} -@cindex delete breakpoints -@kindex delete -@kindex d -Delete the breakpoints or watchpoints of the numbers specified as -arguments. If no argument is specified, delete all breakpoints (_GDBN__ -asks confirmation, unless you've @code{set confirm off}). You -can abbreviate this command as @code{d}. -@end table - -@node Disabling, Conditions, Delete Breaks, Breakpoints -@subsection Disabling Breakpoints - -@cindex disabled breakpoints -@cindex enabled breakpoints -Rather than deleting a breakpoint or watchpoint, you might prefer to -@dfn{disable} it. This makes the breakpoint inoperative as if it had -been deleted, but remembers the information on the breakpoint so that -you can @dfn{enable} it again later. - -You disable and enable breakpoints and watchpoints with the -@code{enable} and @code{disable} commands, optionally specifying one or -more breakpoint numbers as arguments. Use @code{info break} or -@code{info watch} to print a list of breakpoints or watchpoints if you -don't know which numbers to use. - -A breakpoint or watchpoint can have any of four different states of -enablement: - -@itemize @bullet -@item -Enabled. The breakpoint will stop the program. A breakpoint set -with the @code{break} command starts out in this state. -@item -Disabled. The breakpoint has no effect on the program. -@item -Enabled once. The breakpoint will stop the program, but -when it does so it will become disabled. A breakpoint set -with the @code{tbreak} command starts out in this state. -@item -Enabled for deletion. The breakpoint will stop the program, but -immediately after it does so it will be deleted permanently. -@end itemize - -You can use the following commands to enable or disable breakpoints and -watchpoints: - -@table @code -@item disable @r{[}breakpoints@r{]} @r{[}@var{bnums}@dots{}@r{]} -@kindex disable breakpoints -@kindex disable -@kindex dis -Disable the specified breakpoints---or all breakpoints, if none are -listed. A disabled breakpoint has no effect but is not forgotten. All -options such as ignore-counts, conditions and commands are remembered in -case the breakpoint is enabled again later. You may abbreviate -@code{disable} as @code{dis}. - -@item enable @r{[}breakpoints@r{]} @r{[}@var{bnums}@dots{}@r{]} -@kindex enable breakpoints -@kindex enable -Enable the specified breakpoints (or all defined breakpoints). They -become effective once again in stopping the program. - -@item enable @r{[}breakpoints@r{]} once @var{bnums}@dots{} -Enable the specified breakpoints temporarily. Each will be disabled -again the next time it stops the program. - -@item enable @r{[}breakpoints@r{]} delete @var{bnums}@dots{} -Enable the specified breakpoints to work once and then die. Each of -the breakpoints will be deleted the next time it stops the program. -@end table - -Save for a breakpoint set with @code{tbreak} (@pxref{Set Breaks}), -breakpoints that you set are initially enabled; subsequently, they become -disabled or enabled only when you use one of the commands above. (The -command @code{until} can set and delete a breakpoint of its own, but it -will not change the state of your other breakpoints; -@pxref{Continuing and Stepping}.) - -@node Conditions, Break Commands, Disabling, Breakpoints -@subsection Break Conditions -@cindex conditional breakpoints -@cindex breakpoint conditions - -The simplest sort of breakpoint breaks every time the program reaches a -specified place. You can also specify a @dfn{condition} for a -breakpoint. A condition is just a Boolean expression in your -programming language. (@xref{Expressions}). A breakpoint with a condition -evaluates the expression each time the program reaches it, and the -program stops only if the condition is @emph{true}. - -This is the converse of using assertions for program validation; in that -situation, you want to stop when the assertion is violated---that is, -when the condition is false. In C, if you want to test an assertion expressed -by the condition @var{assert}, you should set the condition -@samp{! @var{assert}} on the appropriate breakpoint. - -Conditions are also accepted for watchpoints; you may not need them, -since a watchpoint is inspecting the value of an expression anyhow---but -it might be simpler, say, to just set a watchpoint on a variable name, -and specify a condition that tests whether the new value is an interesting -one. - -Break conditions ca have side effects, and may even call functions in -your program. This can be useful, for example, to activate functions -that log program progress, or to use your own print functions to format -special data structures. The effects are completely predictable unless -there is another enabled breakpoint at the same address. (In that -case, _GDBN__ might see the other breakpoint first and stop the program -without checking the condition of this one.) Note that breakpoint -commands are usually more convenient and flexible for the purpose of -performing side effects when a breakpoint is reached -(@pxref{Break Commands}). - -Break conditions can be specified when a breakpoint is set, by using -@samp{if} in the arguments to the @code{break} command. @xref{Set Breaks}. -They can also be changed at any time with the @code{condition} command. -The @code{watch} command doesn't recognize the @code{if} keyword; -@code{condition} is the only way to impose a further condition on a -watchpoint. - -@table @code -@item condition @var{bnum} @var{expression} -@kindex condition -Specify @var{expression} as the break condition for breakpoint or -watchpoint number @var{bnum}. From now on, this breakpoint will stop -the program only if the value of @var{expression} is true (nonzero, in -C). When you use @code{condition}, _GDBN__ checks @var{expression} -immediately for syntactic correctness, and to determine whether symbols -in it have referents in the context of your breakpoint. _GDBN__ does -not actually evaluate @var{expression} at the time the @code{condition} -command is given, however. @xref{Expressions}. - -@item condition @var{bnum} -Remove the condition from breakpoint number @var{bnum}. It becomes -an ordinary unconditional breakpoint. -@end table - -@cindex ignore count (of breakpoint) -A special case of a breakpoint condition is to stop only when the -breakpoint has been reached a certain number of times. This is so -useful that there is a special way to do it, using the @dfn{ignore -count} of the breakpoint. Every breakpoint has an ignore count, which -is an integer. Most of the time, the ignore count is zero, and -therefore has no effect. But if the program reaches a breakpoint whose -ignore count is positive, then instead of stopping, it just decrements -the ignore count by one and continues. As a result, if the ignore count -value is @var{n}, the breakpoint will not stop the next @var{n} times it -is reached. - -@table @code -@item ignore @var{bnum} @var{count} -@kindex ignore -Set the ignore count of breakpoint number @var{bnum} to @var{count}. -The next @var{count} times the breakpoint is reached, your program's -execution will not stop; other than to decrement the ignore count, _GDBN__ -takes no action. - -To make the breakpoint stop the next time it is reached, specify -a count of zero. - -@item continue @var{count} -@itemx c @var{count} -@itemx fg @var{count} -@kindex continue @var{count} -Continue execution of the program, setting the ignore count of the -breakpoint that the program stopped at to @var{count} minus one. -Thus, the program will not stop at this breakpoint until the -@var{count}'th time it is reached. - -An argument to this command is meaningful only when the program stopped -due to a breakpoint. At other times, the argument to @code{continue} is -ignored. - -The synonym @code{fg} is provided purely for convenience, and has -exactly the same behavior as other forms of the command. -@end table - -If a breakpoint has a positive ignore count and a condition, the condition -is not checked. Once the ignore count reaches zero, the condition will -be checked. - -You could achieve the effect of the ignore count with a -condition such as _0__@w{@samp{$foo-- <= 0}}_1__ using a debugger convenience -variable that is decremented each time. @xref{Convenience Vars}. - -@node Break Commands, Breakpoint Menus, Conditions, Breakpoints -@subsection Breakpoint Command Lists - -@cindex breakpoint commands -You can give any breakpoint (or watchpoint) a series of commands to -execute when the program stops due to that breakpoint. For example, you -might want to print the values of certain expressions, or enable other -breakpoints. - -@table @code -@item commands @r{[}@var{bnum}@r{]} -@itemx @dots{} @var{command-list} @dots{} -@itemx end -@kindex commands -@kindex end -Specify a list of commands for breakpoint number @var{bnum}. The commands -themselves appear on the following lines. Type a line containing just -@code{end} to terminate the commands. - -To remove all commands from a breakpoint, type @code{commands} followed -immediately by @code{end}; that is, give no commands. - -With no @var{bnum} argument, @code{commands} refers to the last -breakpoint or watchpoint set (not to the breakpoint most recently -encountered). -@end table - -Pressing @key{RET} as a means of repeating the last _GDBN__ command is -disabled within a @var{command-list}. - -You can use breakpoint commands to start the program up again. Simply -use the @code{continue} command, or @code{step}, or any other command -that resumes execution. Subsequent commands in the command list are -ignored. - -@kindex silent -If the first command specified is @code{silent}, the usual message about -stopping at a breakpoint is not printed. This may be desirable for -breakpoints that are to print a specific message and then continue. -If the remaining commands too print nothing, you will see no sign that -the breakpoint was reached at all. @code{silent} is meaningful only -at the beginning of a breakpoint command list. - -The commands @code{echo} and @code{output} that allow you to print precisely -controlled output are often useful in silent breakpoints. @xref{Output}. - -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. - -_0__@example -break foo if x>0 -commands -silent -echo x is\040 -output x -echo \n -cont -end -_1__@end example - -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 -of code, give it a condition to detect the case in which something -erroneous has been done, and give it commands to assign correct values -to any variables that need them. End with the @code{continue} command -so that the program does not stop, and start with the @code{silent} -command so that no output is produced. Here is an example: - -@example -break 403 -commands -silent -set x = y + 4 -cont -end -@end example - -@cindex lost output -One deficiency in the operation of automatically continuing breakpoints -under Unix appears when your program uses raw mode for the terminal. -_GDBN__ switches back to its own terminal modes (not raw) before executing -commands, and then must switch back to raw mode when your program is -continued. This causes any pending terminal input to be lost. -@c FIXME: revisit below when GNU sys avail. -@c In the GNU system, this will be fixed by changing the behavior of -@c terminal modes. - -Under Unix, you can get around this problem by writing actions into -the breakpoint condition rather than in commands. For example - -@example -condition 5 (x = y + 4), 0 -@end example - -@noindent -specifies a condition expression (@xref{Expressions}) that will change -@code{x} as needed, then always have the value zero so the program will -not stop. No input is lost here, because _GDBN__ evaluates break -conditions without changing the terminal modes. When you want to have -nontrivial conditions for performing the side effects, the operators -@samp{&&}, @samp{||} and @samp{?@dots{}:} may be useful. - -@node Breakpoint Menus, Error in Breakpoints, Break Commands, Breakpoints -@subsection Breakpoint Menus -@cindex overloading -@cindex symbol overloading - -Some programming languages (notably C++) permit a single function name -to be defined several times, for application in different contexts. -This is called @dfn{overloading}. When a function name is overloaded, -@samp{break @var{function}} is not enough to tell _GDBN__ where you -want a breakpoint. _GDBN__ offers you a menu of numbered choices for -different possible breakpoints, and waits for your selection with the -prompt @samp{>}. The first two options are always @samp{[0] cancel} -and @samp{[1] all}. Typing @kbd{1} sets a breakpoint at each -definition of @var{function}, and typing @kbd{0} aborts the -@code{break} command without setting any new breakpoints. - -For example, the following session excerpt shows an attempt to set a -breakpoint at the overloaded symbol @code{String::after}. -We choose three particular definitions of that function name: - -@example -(_GDBP__) b String::after -[0] cancel -[1] all -[2] file:String.cc; line number:867 -[3] file:String.cc; line number:860 -[4] file:String.cc; line number:875 -[5] file:String.cc; line number:853 -[6] file:String.cc; line number:846 -[7] file:String.cc; line number:735 -> 2 4 6 -Breakpoint 1 at 0xb26c: file String.cc, line 867. -Breakpoint 2 at 0xb344: file String.cc, line 875. -Breakpoint 3 at 0xafcc: file String.cc, line 846. -Multiple breakpoints were set. -Use the "delete" command to delete unwanted breakpoints. -(_GDBP__) -@end example - - -@node Error in Breakpoints, , Breakpoint Menus, Breakpoints -@subsection ``Cannot Insert Breakpoints'' - -@c FIXME: "cannot insert breakpoints" error, v unclear. -@c Q in pending mail to Gilmore. ---pesch@cygnus.com, 26mar91 -@c some light may be shed by looking at instances of -@c ONE_PROCESS_WRITETEXT. But error seems possible otherwise -@c too. pesch, 20sep91 -Under some operating systems, breakpoints cannot be used in a program if -any other process is running that program. In this situation, -attempting to run or continue a program with a breakpoint causes _GDBN__ -to stop the other process. - -When this happens, you have three ways to proceed: - -@enumerate -@item -Remove or disable the breakpoints, then continue. - -@item -Suspend _GDBN__, and copy the file containing the program to a new name. -Resume _GDBN__ and use the @code{exec-file} command to specify that _GDBN__ -should run the program under that name. Then start the program again. - -@c FIXME: RMS commented here "Show example". Maybe when someone -@c explains the first FIXME: in this section... - -@item -Relink the program so that the text segment is nonsharable, using the -linker option @samp{-N}. The operating system limitation may not apply -to nonsharable executables. -@end enumerate - -@node Continuing and Stepping, Signals, Breakpoints, Stopping -@section Continuing and Stepping - -@cindex stepping -@cindex continuing -@cindex resuming execution -@dfn{Continuing} means resuming program execution until your program -completes normally. In contrast, @dfn{stepping} means resuming program -execution for a very limited time: one line of source code, or one -machine instruction. Either when continuing or when stepping, the -program may stop even sooner, due to a breakpoint or to a signal. (If -due to a signal, you may want to use @code{handle}, or use @samp{signal -0} to resume execution; @pxref{Signals}.) - -@table @code -@item continue @r{[}@var{ignore-count}@r{]} -@kindex continue -Resume program execution, at the address where the program last stopped; -any breakpoints set at that address are bypassed. The optional argument -@var{ignore-count} allows you to specify a further number of times to -ignore a breakpoint at this location; its effect is like that of -@code{ignore} (@pxref{Conditions}). - -To resume execution at a different place, you can use @code{return} -(@pxref{Returning}) to go back to the calling function; or @code{jump} -(@pxref{Jumping}) to go to an arbitrary location in your program. - -@end table - -A typical technique for using stepping is to set a breakpoint -(@pxref{Breakpoints}) at the beginning of the function or the section of -the program in which a problem is believed to lie, run the program until -it stops at that breakpoint, and then step through the suspect area, -examining the variables that are interesting, until you see the problem -happen. - -@table @code -@item step -@kindex step -@kindex s -Continue running the program until control reaches a different source -line, then stop it and return control to _GDBN__. This command is -abbreviated @code{s}. - -@quotation -@emph{Warning:} If you use the @code{step} command while control is -within a function that was compiled without debugging information, -execution will proceed until control reaches another function. -@end quotation - -@item step @var{count} -Continue running as in @code{step}, but do so @var{count} times. If a -breakpoint is reached or a signal not related to stepping occurs before -@var{count} steps, stepping stops right away. - -@item next @r{[}@var{count}@r{]} -@kindex next -@kindex n -Continue to the next source line in the current (innermost) stack frame. -Similar to @code{step}, but any function calls appearing within the line -of code are executed without stopping. Execution stops when control -reaches a different line of code at the stack level which was executing -when the @code{next} command was given. This command is abbreviated -@code{n}. - -An argument @var{count} is a repeat count, as for @code{step}. - -@code{next} within a function that lacks debugging information acts like -@code{step}, but any function calls appearing within the code of the -function are executed without stopping. - -@item finish -@kindex finish -Continue running until just after function in the selected stack frame -returns. Print the returned value (if any). - -Contrast this with the @code{return} command (@pxref{Returning}). - -@item until -@kindex until -@item u -@kindex u -Continue running until a source line past the current line, in the -current stack frame, is reached. This command is used to avoid single -stepping through a loop more than once. It is like the @code{next} -command, except that when @code{until} encounters a jump, it -automatically continues execution until the program counter is greater -than the address of the jump. - -This means that when you reach the end of a loop after single stepping -though it, @code{until} will cause the program to continue execution -until the loop is exited. In contrast, a @code{next} command at the end -of a loop will simply step back to the beginning of the loop, which -would force you to step through the next iteration. - -@code{until} always stops the program if it attempts to exit the current -stack frame. - -@code{until} may produce somewhat counterintuitive results if the order -of machine code does not match the order of the source lines. For -example, in the following excerpt from a debugging session, the @code{f} -(@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 -(_GDBP__) f -#0 main (argc=4, argv=0xf7fffae8) at m4.c:206 -206 expand_input(); -(_GDBP__) until -195 for ( ; argc > 0; NEXTARG) @{ -@end example - -This happened because, for execution efficiency, the compiler had -generated code for the loop closure test at the end, rather than the -start, of the loop---even though the test in a C @code{for}-loop is -written before the body of the loop. The @code{until} command appeared -to step back to the beginning of the loop when it advanced to this -expression; however, it has not really gone to an earlier -statement---not in terms of the actual machine code. - -@code{until} with no argument works by means of single -instruction stepping, and hence is slower than @code{until} with an -argument. - -@item until @var{location} -@item u @var{location} -Continue running the program until either the specified location is -reached, or the current stack frame returns. @var{location} -is any of the forms of argument acceptable to @code{break} -(@pxref{Set Breaks}). This form of the command uses breakpoints, and -hence is quicker than @code{until} without an argument. - -@item stepi -@itemx si -@kindex stepi -@kindex si -Execute one machine instruction, then stop and return to the debugger. - -It is often useful to do @samp{display/i $pc} when stepping by machine -instructions. This will cause the next instruction to be executed to -be displayed automatically at each stop. @xref{Auto Display}. - -An argument is a repeat count, as in @code{step}. - -@item nexti -@itemx ni -@kindex nexti -@kindex ni -Execute one machine instruction, but if it is a function call, -proceed until the function returns. - -An argument is a repeat count, as in @code{next}. -@end table - - -@node Signals, , Continuing and Stepping, Stopping -@section Signals -@cindex signals - -A signal is an asynchronous event that can happen in a program. The -operating system defines the possible kinds of signals, and gives each -kind a name and a number. For example, in Unix @code{SIGINT} is the -signal a program gets when you type an interrupt (often @kbd{C-c}); -@code{SIGSEGV} is the signal a program gets from referencing a place in -memory far away from all the areas in use; @code{SIGALRM} occurs when -the alarm clock timer goes off (which happens only if the program has -requested an alarm). - -@cindex fatal signals -Some signals, including @code{SIGALRM}, are a normal part of the -functioning of the program. Others, such as @code{SIGSEGV}, indicate -errors; these signals are @dfn{fatal} (kill the program immediately) if the -program has not specified in advance some other way to handle the signal. -@code{SIGINT} does not indicate an error in the program, but it is normally -fatal so it can carry out the purpose of the interrupt: to kill the program. - -_GDBN__ has the ability to detect any occurrence of a signal in the program -running under _GDBN__'s control. You can tell _GDBN__ in advance what to do for -each kind of signal. - -@cindex handling signals -Normally, _GDBN__ is set up to ignore non-erroneous signals like @code{SIGALRM} -(so as not to interfere with their role in the functioning of the program) -but to stop the program immediately whenever an error signal happens. -You can change these settings with the @code{handle} command. - -@table @code -@item info signals -@kindex info signals -Print a table of all the kinds of signals and how _GDBN__ has been told to -handle each one. You can use this to see the signal numbers of all -the defined types of signals. - -@item handle @var{signal} @var{keywords}@dots{} -@kindex handle -Change the way _GDBN__ handles signal @var{signal}. @var{signal} can be the -number of a signal or its name (with or without the @samp{SIG} at the -beginning). The @var{keywords} say what change to make. -@end table - -@c @group -The keywords allowed by the @code{handle} command can be abbreviated. -Their full names are: - -@table @code -@item nostop -_GDBN__ should not stop the program when this signal happens. It may -still print a message telling you that the signal has come in. - -@item stop -_GDBN__ should stop the program when this signal happens. This implies -the @code{print} keyword as well. - -@item print -_GDBN__ should print a message when this signal happens. - -@item noprint -_GDBN__ should not mention the occurrence of the signal at all. This -implies the @code{nostop} keyword as well. - -@item pass -_GDBN__ should allow the program to see this signal; the program will be -able to handle the signal, or may be terminated if the signal is fatal -and not handled. - -@item nopass -_GDBN__ should not allow the program to see this signal. -@end table -@c @end group - -When a signal has been set to stop the program, the program cannot see the -signal until you continue. It will see the signal then, if @code{pass} is -in effect for the signal in question @i{at that time}. In other words, -after _GDBN__ reports a signal, you can use the @code{handle} command with -@code{pass} or @code{nopass} to control whether that signal will be seen by -the program when you later continue it. - -You can also use the @code{signal} command to prevent the program from -seeing a signal, or cause it to see a signal it normally would not see, -or to give it any signal at any time. For example, if the program stopped -due to some sort of memory reference error, you might store correct -values into the erroneous variables and continue, hoping to see more -execution; but the program would probably terminate immediately as -a result of the fatal signal once it sees the signal. To prevent this, -you can continue with @samp{signal 0}. @xref{Signaling}. - -@node Stack, Source, Stopping, Top -@chapter Examining the Stack - -When your program has stopped, the first thing you need to know is where it -stopped and how it got there. - -@cindex call stack -Each time your program performs a function call, the information about -where in the program the call was made from is saved in a block of data -called a @dfn{stack frame}. The frame also contains the arguments of the -call and the local variables of the function that was called. All the -stack frames are allocated in a region of memory called the @dfn{call -stack}. - -When your program stops, the _GDBN__ commands for examining the stack allow you -to see all of this information. - -@cindex selected frame -One of the stack frames is @dfn{selected} by _GDBN__ and many _GDBN__ commands -refer implicitly to the selected frame. In particular, whenever you ask -_GDBN__ for the value of a variable in the program, the value is found in the -selected frame. There are special _GDBN__ commands to select whichever frame -you are interested in. - -When the program stops, _GDBN__ automatically selects the currently executing -frame and describes it briefly as the @code{frame} command does -(@pxref{Frame Info}). - -@menu -* Frames:: Stack Frames -* Backtrace:: Backtraces -* Selection:: Selecting a Frame -* Frame Info:: Information on a Frame -@end menu - -@node Frames, Backtrace, Stack, Stack -@section Stack Frames - -@cindex frame -@cindex stack frame -The call stack is divided up into contiguous pieces called @dfn{stack -frames}, or @dfn{frames} for short; each frame is the data associated -with one call to one function. The frame contains the arguments given -to the function, the function's local variables, and the address at -which the function is executing. - -@cindex initial frame -@cindex outermost frame -@cindex innermost frame -When your program is started, the stack has only one frame, that of the -function @code{main}. This is called the @dfn{initial} frame or the -@dfn{outermost} frame. Each time a function is called, a new frame is -made. Each time a function returns, the frame for that function invocation -is eliminated. If a function is recursive, there can be many frames for -the same function. The frame for the function in which execution is -actually occurring is called the @dfn{innermost} frame. This is the most -recently created of all the stack frames that still exist. - -@cindex frame pointer -Inside your program, stack frames are identified by their addresses. A -stack frame consists of many bytes, each of which has its own address; each -kind of computer has a convention for choosing one of those bytes whose -address serves as the address of the frame. Usually this address is kept -in a register called the @dfn{frame pointer register} while execution is -going on in that frame. - -@cindex frame number -_GDBN__ assigns numbers to all existing stack frames, starting with -zero for the innermost frame, one for the frame that called it, -and so on upward. These numbers do not really exist in your program; -they are assigned by _GDBN__ to give you a way of designating stack -frames in _GDBN__ commands. - -@cindex frameless execution -Some compilers allow functions to be compiled so that they operate -without stack frames. (For example, the @code{_GCC__} option -@samp{-fomit-frame-pointer} will generate functions without a frame.) -This is occasionally done with heavily used library functions to save -the frame setup time. _GDBN__ has limited facilities for dealing with -these function invocations. If the innermost function invocation has no -stack frame, _GDBN__ will nevertheless regard it as though it had a -separate frame, which is numbered zero as usual, allowing correct -tracing of the function call chain. However, _GDBN__ has no provision -for frameless functions elsewhere in the stack. - -@node Backtrace, Selection, Frames, Stack -@section Backtraces - -A backtrace is a summary of how the program got where it is. It shows one -line per frame, for many frames, starting with the currently executing -frame (frame zero), followed by its caller (frame one), and on up the -stack. - -@table @code -@item backtrace -@itemx bt -@kindex backtrace -@kindex bt -Print a backtrace of the entire stack: one line per frame for all -frames in the stack. - -You can stop the backtrace at any time by typing the system interrupt -character, normally @kbd{C-c}. - -@item backtrace @var{n} -@itemx bt @var{n} -Similar, but print only the innermost @var{n} frames. - -@item backtrace -@var{n} -@itemx bt -@var{n} -Similar, but print only the outermost @var{n} frames. -@end table - -@kindex where -@kindex info stack -@kindex info s -The names @code{where} and @code{info stack} (abbreviated @code{info s}) -are additional aliases for @code{backtrace}. - -Each line in the backtrace shows the frame number and the function name. -The program counter value is also shown---unless you use @code{set -print address off}. The backtrace also shows the source file name and -line number, as well as the arguments to the function. The program -counter value is omitted if it is at the beginning of the code for that -line number. - -Here is an example of a backtrace. It was made with the command -@samp{bt 3}, so it shows the innermost three frames. - -@smallexample -@group -#0 m4_traceon (obs=0x24eb0, argc=1, argv=0x2b8c8) at builtin.c:993 -#1 0x6e38 in expand_macro (sym=0x2b600) at macro.c:242 -#2 0x6840 in expand_token (obs=0x0, t=177664, td=0xf7fffb08) - at macro.c:71 -(More stack frames follow...) -@end group -@end smallexample - -@noindent -The display for frame zero doesn't begin with a program counter -value, indicating that the program has stopped at the beginning of the -code for line @code{993} of @code{builtin.c}. - -@node Selection, Frame Info, Backtrace, Stack -@section Selecting a Frame - -Most commands for examining the stack and other data in the program work on -whichever stack frame is selected at the moment. Here are the commands for -selecting a stack frame; all of them finish by printing a brief description -of the stack frame just selected. - -@table @code -@item frame @var{n} -@itemx f @var{n} -@kindex frame -@kindex f -Select frame number @var{n}. Recall that frame zero is the innermost -(currently executing) frame, frame one is the frame that called the -innermost one, and so on. The highest-numbered frame is @code{main}'s -frame. - -@item frame @var{addr} -@itemx f @var{addr} -Select the frame at address @var{addr}. This is useful mainly if the -chaining of stack frames has been damaged by a bug, making it -impossible for _GDBN__ to assign numbers properly to all frames. In -addition, this can be useful when the program has multiple stacks and -switches between them. - -_if__(_SPARC__) -On the SPARC architecture, @code{frame} needs two addresses to -select an arbitrary frame: a frame pointer and a stack pointer. -@c note to future updaters: this is conditioned on a flag -@c FRAME_SPECIFICATION_DYADIC in the tm-*.h files, currently only used -@c by SPARC, hence the specific attribution. Generalize or list all -@c possibilities if more supported machines start doing this. -_fi__(_SPARC__) - -@item up @var{n} -@kindex up -Move @var{n} frames up the stack. For positive numbers @var{n}, this -advances toward the outermost frame, to higher frame numbers, to frames -that have existed longer. @var{n} defaults to one. - -@item down @var{n} -@kindex down -@kindex do -Move @var{n} frames down the stack. For positive numbers @var{n}, this -advances toward the innermost frame, to lower frame numbers, to frames -that were created more recently. @var{n} defaults to one. You may -abbreviate @code{down} as @code{do}. -@end table - -All of these commands end by printing two lines of output describing the -frame. The first line shows the frame number, the function name, the -arguments, and the source file and line number of execution in that -frame. The second line shows the text of that source line. For -example: - -@smallexample -(_GDBP__) up -#1 0x22f0 in main (argc=1, argv=0xf7fffbf4, env=0xf7fffbfc) at env.c:10 -10 read_input_file (argv[i]); -@end smallexample - -After such a printout, the @code{list} command with no arguments will print -ten lines centered on the point of execution in the frame. @xref{List}. - -@table @code -@item up-silently @var{n} -@itemx down-silently @var{n} -@kindex down-silently -@kindex up-silently -These two commands are variants of @code{up} and @code{down}, -respectively; they differ in that they do their work silently, without -causing display of the new frame. They are intended primarily for use -in _GDBN__ command scripts, where the output might be unnecessary and -distracting. - -@end table - -@node Frame Info, , Selection, Stack -@section Information About a Frame - -There are several other commands to print information about the selected -stack frame. - -@table @code -@item frame -@itemx f -When used without any argument, this command does not change which frame -is selected, but prints a brief description of the currently -selected stack frame. It can be abbreviated @code{f}. With an -argument, this command is used to select a stack frame (@pxref{Selection}). - -@item info frame -@kindex info frame -@itemx info f -@kindex info f -This command prints a verbose description of the selected stack frame, -including the address of the frame, the addresses of the next frame down -(called by this frame) and the next frame up (caller of this frame), the -language that the source code corresponding to this frame was written in, -the address of the frame's arguments, the program counter saved in it -(the address of execution in the caller frame), and which registers -were saved in the frame. The verbose description is useful when -something has gone wrong that has made the stack format fail to fit -the usual conventions. - -@item info frame @var{addr} -@itemx info f @var{addr} -Print a verbose description of the frame at address @var{addr}, -without selecting that frame. The selected frame remains unchanged by -this command. - -@item info args -@kindex info args -Print the arguments of the selected frame, each on a separate line. - -@item info locals -@kindex info locals -Print the local variables of the selected frame, each on a separate -line. These are all variables declared static or automatic within all -program blocks that execution in this frame is currently inside of. - -@item info catch -@kindex info catch -@cindex catch exceptions -@cindex exception handlers -Print a list of all the exception handlers that are active in the -current stack frame at the current point of execution. To see other -exception handlers, visit the associated frame (using the @code{up}, -@code{down}, or @code{frame} commands); then type @code{info catch}. -@xref{Exception Handling}. -@end table - -@node Source, Data, Stack, Top -@chapter Examining Source Files - -_GDBN__ can print parts of your program's source, since the debugging -information recorded in your program tells _GDBN__ what source files -were used to built it. When your program stops, _GDBN__ spontaneously -prints the line where it stopped. Likewise, when you select a stack -frame (@pxref{Selection}), _GDBN__ prints the line where execution in -that frame has stopped. You can print other portions of source files by -explicit command. - -If you use _GDBN__ through its GNU Emacs interface, you may prefer to -use Emacs facilities to view source; @pxref{Emacs}. - -@menu -* List:: Printing Source Lines -* Search:: Searching Source Files -* Source Path:: Specifying Source Directories -* Machine Code:: Source and Machine Code -@end menu - -@node List, Search, Source, Source -@section Printing Source Lines - -@kindex list -@kindex l -To print lines from a source file, use the @code{list} command -(abbreviated @code{l}). There are several ways to specify what part -of the file you want to print. - -Here are the forms of the @code{list} command most commonly used: - -@table @code -@item list @var{linenum} -Print lines centered around line number @var{linenum} in the -current source file. - -@item list @var{function} -Print lines centered around the beginning of function -@var{function}. - -@item list -Print more lines. If the last lines printed were printed with a -@code{list} command, this prints lines following the last lines -printed; however, if the last line printed was a solitary line printed -as part of displaying a stack frame (@pxref{Stack}), this prints -lines centered around that line. - -@item list - -Print lines just before the lines last printed. -@end table - -By default, _GDBN__ prints ten source lines with any of these forms of -the @code{list} command. You can change this using @code{set listsize}: - -@table @code -@item set listsize @var{count} -@kindex set listsize -Make the @code{list} command display @var{count} source lines (unless -the @code{list} argument explicitly specifies some other number). - -@item show listsize -@kindex show listsize -Display the number of lines that @code{list} will currently display by -default. -@end table - -Repeating a @code{list} command with @key{RET} discards the argument, -so it is equivalent to typing just @code{list}. This is more useful -than listing the same lines again. An exception is made for an -argument of @samp{-}; that argument is preserved in repetition so that -each repetition moves up in the source file. - -@cindex linespec -In general, the @code{list} command expects you to supply zero, one or two -@dfn{linespecs}. Linespecs specify source lines; there are several ways -of writing them but the effect is always to specify some source line. -Here is a complete description of the possible arguments for @code{list}: - -@table @code -@item list @var{linespec} -Print lines centered around the line specified by @var{linespec}. - -@item list @var{first},@var{last} -Print lines from @var{first} to @var{last}. Both arguments are -linespecs. - -@item list ,@var{last} -Print lines ending with @var{last}. - -@item list @var{first}, -Print lines starting with @var{first}. - -@item list + -Print lines just after the lines last printed. - -@item list - -Print lines just before the lines last printed. - -@item list -As described in the preceding table. -@end table - -Here are the ways of specifying a single source line---all the -kinds of linespec. - -@table @code -@item @var{number} -Specifies line @var{number} of the current source file. -When a @code{list} command has two linespecs, this refers to -the same source file as the first linespec. - -@item +@var{offset} -Specifies the line @var{offset} lines after the last line printed. -When used as the second linespec in a @code{list} command that has -two, this specifies the line @var{offset} lines down from the -first linespec. - -@item -@var{offset} -Specifies the line @var{offset} lines before the last line printed. - -@item @var{filename}:@var{number} -Specifies line @var{number} in the source file @var{filename}. - -@item @var{function} -@c FIXME: "of the open-brace" is C-centric. When we add other langs... -Specifies the line of the open-brace that begins the body of the -function @var{function}. - -@item @var{filename}:@var{function} -Specifies the line of the open-brace that begins the body of the -function @var{function} in the file @var{filename}. You only need the -file name with a function name to avoid ambiguity when there are -identically named functions in different source files. - -@item *@var{address} -Specifies the line containing the program address @var{address}. -@var{address} may be any expression. -@end table - -@node Search, Source Path, List, Source -@section Searching Source Files -@cindex searching -@kindex reverse-search - -There are two commands for searching through the current source file for a -regular expression. - -@table @code -@item forward-search @var{regexp} -@itemx search @var{regexp} -@kindex search -@kindex forward-search -The command @samp{forward-search @var{regexp}} checks each line, starting -with the one following the last line listed, for a match for @var{regexp}. -It lists the line that is found. You can abbreviate the command name -as @code{fo}. The synonym @samp{search @var{regexp}} is also supported. - -@item reverse-search @var{regexp} -The command @samp{reverse-search @var{regexp}} checks each line, starting -with the one before the last line listed and going backward, for a match -for @var{regexp}. It lists the line that is found. You can abbreviate -this command as @code{rev}. -@end table - -@node Source Path, Machine Code, Search, Source -@section Specifying Source Directories - -@cindex source path -@cindex directories for source files -Executable programs sometimes do not record the directories of the source -files from which they were compiled, just the names. Even when they do, -the directories could be moved between the compilation and your debugging -session. _GDBN__ has a list of directories to search for source files; -this is called the @dfn{source path}. Each time _GDBN__ wants a source file, -it tries all the directories in the list, in the order they are present -in the list, until it finds a file with the desired name. Note that -the executable search path is @emph{not} used for this purpose. Neither is -the current working directory, unless it happens to be in the source -path. - -If _GDBN__ can't find a source file in the source path, and the object -program records a directory, _GDBN__ tries that directory too. If the -source path is empty, and there is no record of the compilation -directory, _GDBN__ will, as a last resort, look in the current -directory. - -Whenever you reset or rearrange the source path, _GDBN__ will clear out -any information it has cached about where source files are found, where -each line is in the file, etc. - -@kindex directory -When you start _GDBN__, its source path is empty. -To add other directories, use the @code{directory} command. - -@table @code -@item directory @var{dirname} @dots{} -Add directory @var{dirname} to the front of the source path. Several -directory names may be given to this command, separated by @samp{:} or -whitespace. You may specify a directory that is already in the source -path; this moves it forward, so it will be searched sooner. - -You can use the string @samp{$cdir} to refer to the compilation -directory (if one is recorded), and @samp{$cwd} to refer to the current -working directory. @samp{$cwd} is not the same as @samp{.}---the former -tracks the current working directory as it changes during your _GDBN__ -session, while the latter is immediately expanded to the current -directory at the time you add an entry to the source path. - -@item directory -Reset the source path to empty again. This requires confirmation. - -@c RET-repeat for @code{directory} is explicitly disabled, but since -@c repeating it would be a no-op we don't say that. (thanks to RMS) - -@item show directories -@kindex show directories -Print the source path: show which directories it contains. -@end table - -If your source path is cluttered with directories that are no longer of -interest, _GDBN__ may sometimes cause confusion by finding the wrong -versions of source. You can correct the situation as follows: - -@enumerate -@item -Use @code{directory} with no argument to reset the source path to empty. - -@item -Use @code{directory} with suitable arguments to reinstall the -directories you want in the source path. You can add all the -directories in one command. -@end enumerate - -@node Machine Code, , Source Path, Source -@section Source and Machine Code -You can use the command @code{info line} to map source lines to program -addresses (and viceversa), and the command @code{disassemble} to display -a range of addresses as machine instructions. - -@table @code -@item info line @var{linespec} -@kindex info line -Print the starting and ending addresses of the compiled code for -source line @var{linespec}. You can specify source lines in any of the -ways understood by the @code{list} command (@pxref{List}). -@end table - -For example, we can use @code{info line} to inquire on where the object -code for the first line of function @code{m4_changequote} lies: -@smallexample -(_GDBP__) info line m4_changecom -Line 895 of "builtin.c" starts at pc 0x634c and ends at 0x6350. -@end smallexample - -@noindent -We can also inquire (using @code{*@var{addr}} as the form for -@var{linespec}) what source line covers a particular address: -@smallexample -(_GDBP__) info line *0x63ff -Line 926 of "builtin.c" starts at pc 0x63e4 and ends at 0x6404. -@end smallexample - -@cindex @code{$_} and @code{info line} -After @code{info line}, the default address for the @code{x} -command is changed to the starting address of the line, so that -@samp{x/i} is sufficient to begin examining the machine code -(@pxref{Memory}). Also, this address is saved as the value of the -convenience variable @code{$_} (@pxref{Convenience Vars}). - -@table @code -@kindex disassemble -@item disassemble -This specialized command is provided to dump a range of memory as -machine instructions. The default memory range is the function -surrounding the program counter of the selected frame. A single -argument to this command is a program counter value; the function -surrounding this value will be dumped. Two arguments (separated by one -or more spaces) specify a range of addresses (first inclusive, second -exclusive) to be dumped. -@end table - -We can use @code{disassemble} to inspect the object code -range shown in the last @code{info line} example: - -@smallexample -(_GDBP__) disas 0x63e4 0x6404 -Dump of assembler code from 0x63e4 to 0x6404: -0x63e4 : ble 0x63f8 -0x63e8 : sethi %hi(0x4c00), %o0 -0x63ec : ld [%i1+4], %o0 -0x63f0 : b 0x63fc -0x63f4 : ld [%o0+4], %o0 -0x63f8 : or %o0, 0x1a4, %o0 -0x63fc : call 0x9288 -0x6400 : nop -End of assembler dump. -(_GDBP__) - -@end smallexample - -@node Data, Languages, Source, Top -@chapter Examining Data - -@cindex printing data -@cindex examining data -@kindex print -@kindex inspect -@c "inspect" isn't quite a synonym if you're using Epoch, which we don't -@c document because it's nonstandard... Under Epoch it displays in a -@c different window or something like that. -The usual way to examine data in your program is with the @code{print} -command (abbreviated @code{p}), or its synonym @code{inspect}. It -evaluates and prints the value of an expression of the language your -program is written in (@pxref{Languages}). You type - -@example -print @var{exp} -@end example - -@noindent -where @var{exp} is an expression (in the source language), and -the value of @var{exp} is printed in a format appropriate to its data -type. - -A more low-level way of examining data is with the @code{x} command. -It examines data in memory at a specified address and prints it in a -specified format. @xref{Memory}. - -If you're interested in information about types, or about how the fields -of a struct or class are declared, use the @code{ptype @var{exp}} -command rather than @code{print}. @xref{Symbols}. - -@menu -* Expressions:: Expressions -* Variables:: Program Variables -* Arrays:: Artificial Arrays -* Output formats:: Output formats -* Memory:: Examining Memory -* Auto Display:: Automatic Display -* Print Settings:: Print Settings -* Value History:: Value History -* Convenience Vars:: Convenience Variables -* Registers:: Registers -* Floating Point Hardware:: Floating Point Hardware -@end menu - -@node Expressions, Variables, Data, Data -@section Expressions - -@cindex expressions -@code{print} and many other _GDBN__ commands accept an expression and -compute its value. Any kind of constant, variable or operator defined -by the programming language you are using is legal in an expression in -_GDBN__. This includes conditional expressions, function calls, casts -and string constants. It unfortunately does not include symbols defined -by preprocessor @code{#define} commands. - -Because C is so widespread, most of the expressions shown in examples in -this manual are in C. @xref{Languages,, Using _GDBN__ with Different -Languages}, for information on how to use expressions in other -languages. - -In this section, we discuss operators that you can use in _GDBN__ -expressions regardless of your programming language. - -Casts are supported in all languages, not just in C, because it is so -useful to cast a number into a pointer so as to examine a structure -at that address in memory. -@c FIXME: casts supported---Mod2 true? - -_GDBN__ supports these operators in addition to those of programming -languages: - -@table @code -@item @@ -@samp{@@} is a binary operator for treating parts of memory as arrays. -@xref{Arrays}, for more information. - -@item :: -@samp{::} allows you to specify a variable in terms of the file or -function where it is defined. @xref{Variables}. - -@item @{@var{type}@} @var{addr} -Refers to an object of type @var{type} stored at address @var{addr} in -memory. @var{addr} may be any expression whose value is an integer or -pointer (but parentheses are required around binary operators, just as in -a cast). This construct is allowed regardless of what kind of data is -normally supposed to reside at @var{addr}.@refill -@end table - -@node Variables, Arrays, Expressions, Data -@section Program Variables - -The most common kind of expression to use is the name of a variable -in your program. - -Variables in expressions are understood in the selected stack frame -(@pxref{Selection}); they must either be global (or static) or be visible -according to the scope rules of the programming language from the point of -execution in that frame. This means that in the function - -@example -foo (a) - int a; -@{ - bar (a); - @{ - int b = test (); - bar (b); - @} -@} -@end example - -@noindent -the variable @code{a} is usable whenever the program is executing -within the function @code{foo}, but the variable @code{b} is visible -only while the program is executing inside the block in which @code{b} -is declared. - -@cindex variable name conflict -There is an exception: you can refer to a variable or function whose -scope is a single source file even if the current execution point is not -in this file. But it is possible to have more than one such variable or -function with the same name (in different source files). If that happens, -referring to that name has unpredictable effects. If you wish, you can -specify a variable in a particular file, using the colon-colon notation: - -@cindex colon-colon -@kindex :: -@example -@var{file}::@var{variable} -@end example - -@noindent -Here @var{file} is the name of the source file whose variable you want. - -@cindex C++ scope resolution -This use of @samp{::} is very rarely in conflict with the very similar -use of the same notation in C++. _GDBN__ also supports use of the C++ -scope resolution operator in _GDBN__ expressions. - -@cindex wrong values -@cindex variable values, wrong -@quotation -@emph{Warning:} Occasionally, a local variable may appear to have the -wrong value at certain points in a function---just after entry to the -function, and just before exit. You may see this problem when you're -stepping by machine instructions. This is because on most machines, it -takes more than one instruction to set up a stack frame (including local -variable definitions); if you're stepping by machine instructions, -variables may appear to have the wrong values until the stack frame is -completely built. On function exit, it usually also takes more than one -machine instruction to destroy a stack frame; after you begin stepping -through that group of instructions, local variable definitions may be -gone. -@end quotation - -@node Arrays, Output formats, Variables, Data -@section Artificial Arrays - -@cindex artificial array -@kindex @@ -It is often useful to print out several successive objects of the -same type in memory; a section of an array, or an array of -dynamically determined size for which only a pointer exists in the -program. - -This can be done by constructing an @dfn{artificial array} with the -binary operator @samp{@@}. The left operand of @samp{@@} should be -the first element of the desired array, as an individual object. -The right operand should be the desired length of the array. The result is -an array value whose elements are all of the type of the left argument. -The first element is actually the left argument; the second element -comes from bytes of memory immediately following those that hold the -first element, and so on. Here is an example. If a program says - -@example -int *array = (int *) malloc (len * sizeof (int)); -@end example - -@noindent -you can print the contents of @code{array} with - -@example -p *array@@len -@end example - -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 -subscripting, and are coerced to pointers when used in expressions. -Artificial arrays most often appear in expressions via the value history -(@pxref{Value History}), after printing one out.) - -Sometimes the artificial array mechanism isn't quite enough; in -moderately complex data structures, the elements of interest may not -actually be adjacent---for example, if you're interested in the values -of pointers in an array. One useful work-around in this situation is to -use a convenience variable (@pxref{Convenience Vars}) as a counter in an -expression that prints the first interesting value, and then repeat that -expression via @key{RET}. For instance, suppose you have an array -@code{dtab} of pointers to structures, and you're interested in the -values of a field @code{fv} in each structure. Here's an example of -what you might type: -@example -set $i = 0 -p dtab[$i++]->fv -@key{RET} -@key{RET} -@dots{} -@end example - -@node Output formats, Memory, Arrays, Data -@section Output formats - -@cindex formatted output -@cindex output formats -By default, _GDBN__ prints a value according to its data type. Sometimes -this is not what you want. For example, you might want to print a number -in hex, or a pointer in decimal. Or you might want to view data in memory -at a certain address as a character string or as an instruction. To do -these things, specify an @dfn{output format} when you print a value. - -The simplest use of output formats is to say how to print a value -already computed. This is done by starting the arguments of the -@code{print} command with a slash and a format letter. The format -letters supported are: - -@table @code -@item x -Regard the bits of the value as an integer, and print the integer in -hexadecimal. - -@item d -Print as integer in signed decimal. - -@item u -Print as integer in unsigned decimal. - -@item o -Print as integer in octal. - -@item t -Print as integer in binary. The letter @samp{t} stands for ``two''. - -@item a -Print as an address, both absolute in hex and as an offset from the -nearest preceding symbol. This format can be used to discover where (in -what function) an unknown address is located: -@example -(_GDBP__) p/a 0x54320 -_0__$3 = 0x54320 <_initialize_vx+396>_1__ -@end example - - -@item c -Regard as an integer and print it as a character constant. - -@item f -Regard the bits of the value as a floating point number and print -using typical floating point syntax. -@end table - -For example, to print the program counter in hex (@pxref{Registers}), type - -@example -p/x $pc -@end example - -@noindent -Note that no space is required before the slash; this is because command -names in _GDBN__ cannot contain a slash. - -To reprint the last value in the value history with a different format, -you can use the @code{print} command with just a format and no -expression. For example, @samp{p/x} reprints the last value in hex. - -@node Memory, Auto Display, Output formats, Data -@section Examining Memory - -@cindex examining memory -@table @code -@kindex x -@item x/@var{nfu} @var{expr} -The command @code{x} (for `examine') can be used to examine memory -without being constrained by your program's data types. You can specify -the unit size @var{u} of memory to inspect, and a repeat count @var{n} of how -many of those units to display. @code{x} understands the formats -@var{f} used by @code{print}; two additional formats, @samp{s} (string) -and @samp{i} (machine instruction) can be used without specifying a unit -size. -@end table - -For example, @samp{x/3uh 0x54320} is a request to display three halfwords -(@code{h}) of memory, formatted as unsigned decimal integers (@samp{u}), -starting at address @code{0x54320}. @samp{x/4xw $sp} prints the four -words (@samp{w}) of memory above the stack pointer (here, @samp{$sp}; -@pxref{Registers}) in hexadecimal (@samp{x}). - -Since the letters indicating unit sizes are all distinct from the -letters specifying output formats, you don't have to remember whether -unit size or format comes first; either order will work. The output -specifications @samp{4xw} and @samp{4wx} mean exactly the same thing. - -After the format specification, you supply an expression for the address -where _GDBN__ is to begin reading from memory. The expression need not -have a pointer value (though it may); it is always interpreted as an -integer address of a byte of memory. @xref{Expressions} for more -information on expressions. - -These are the memory units @var{u} you can specify with the @code{x} -command: - -@table @code -@item b -Examine individual bytes. - -@item h -Examine halfwords (two bytes each). - -@item w -Examine words (four bytes each). - -@cindex word -Many assemblers and cpu designers still use `word' for a 16-bit quantity, -as a holdover from specific predecessor machines of the 1970's that really -did use two-byte words. But more generally the term `word' has always -referred to the size of quantity that a machine normally operates on and -stores in its registers. This is 32 bits for all the machines that _GDBN__ -runs on. - -@item g -Examine giant words (8 bytes). -@end table - -You can combine these unit specifications with any of the formats -described for @code{print}. @xref{Output formats}. - -@code{x} has two additional output specifications which derive the unit -size from the data inspected: - -@table @code -@item s -Print a null-terminated string of characters. Any explicitly specified -unit size is ignored; instead, the unit is however many bytes it takes -to reach a null character (including the null character). - -@item i -Print a machine instruction in assembler syntax (or nearly). Any -specified unit size is ignored; the number of bytes in an instruction -varies depending on the type of machine, the opcode and the addressing -modes used. The command @code{disassemble} gives an alternative way of -inspecting machine instructions. @xref{Machine Code}. -@end table - -If you omit either the format @var{f} or the unit size @var{u}, @code{x} -will use the same one that was used last. If you don't use any letters -or digits after the slash, you can omit the slash as well. - -You can also omit the address to examine. Then the address used is just -after the last unit examined. This is why string and instruction -formats actually compute a unit-size based on the data: so that the next -string or instruction examined will start in the right place. - -When the @code{print} command shows a value that resides in memory, -@code{print} also sets the default address for the @code{x} command. -@code{info line} also sets the default for @code{x}, to the address of -the start of the machine code for the specified line -(@pxref{Machine Code}), -and @code{info breakpoints} sets it to the address of the last -breakpoint listed (@pxref{Set Breaks}).@refill - -When you use @key{RET} to repeat an @code{x} command, the address -specified previously (if any) is ignored, so that the repeated command -examines the successive locations in memory rather than the same ones. - -You can examine several consecutive units of memory with one command by -writing a repeat-count after the slash (before the format letters, if -any). Omitting the repeat count @var{n} displays one unit of the -appropriate size. The repeat count must be a decimal integer. It has -the same effect as repeating the @code{x} command @var{n} times except -that the output may be more compact, with several units per line. For -example, - -@example -x/10i $pc -@end example - -@noindent -prints ten instructions starting with the one to be executed next in the -selected frame. After doing this, you could print a further seven -instructions with - -@example -x/7 -@end example - -@noindent ----where the format and address are allowed to default. - -@cindex @code{$_}, @code{$__}, and value history -The addresses and contents printed by the @code{x} command are not put -in the value history because there is often too much of them and they -would get in the way. Instead, _GDBN__ makes these values available for -subsequent use in expressions as values of the convenience variables -@code{$_} and @code{$__}. After an @code{x} command, the last address -examined is available for use in expressions in the convenience variable -@code{$_}. The contents of that address, as examined, are available in -the convenience variable @code{$__}. - -If the @code{x} command has a repeat count, the address and contents saved -are from the last memory unit printed; this is not the same as the last -address printed if several units were printed on the last line of output. - -@node Auto Display, Print Settings, Memory, Data -@section Automatic Display -@cindex automatic display -@cindex display of expressions - -If you find that you want to print the value of an expression frequently -(to see how it changes), you might want to add it to the @dfn{automatic -display list} so that _GDBN__ will print its value each time the program stops. -Each expression added to the list is given a number to identify it; -to remove an expression from the list, you specify that number. -The automatic display looks like this: - -@example -2: foo = 38 -3: bar[5] = (struct hack *) 0x3804 -@end example - -@noindent -showing item numbers, expressions and their current values. As with -displays you request manually using @code{x} or @code{print}, you can -specify the output format you prefer; in fact, @code{display} decides -whether to use @code{print} or @code{x} depending on how elaborate your -format specification is---it uses @code{x} if you specify a unit size, -or one of the two formats (@samp{i} and @samp{s}) that are only -supported by @code{x}; otherwise it uses @code{print}. - -@table @code -@item display @var{exp} -@kindex display -Add the expression @var{exp} to the list of expressions to display -each time the program stops. @xref{Expressions}. - -@code{display} will not repeat if you press @key{RET} again after using it. - -@item display/@var{fmt} @var{exp} -For @var{fmt} specifying only a display format and not a size or -count, add the expression @var{exp} to the auto-display list but -arranges to display it each time in the specified format @var{fmt}. -@xref{Output formats}. - -@item display/@var{fmt} @var{addr} -For @var{fmt} @samp{i} or @samp{s}, or including a unit-size or a -number of units, add the expression @var{addr} as a memory address to -be examined each time the program stops. Examining means in effect -doing @samp{x/@var{fmt} @var{addr}}. @xref{Memory}. -@end table - -For example, @samp{display/i $pc} can be helpful, to see the machine -instruction about to be executed each time execution stops (@samp{$pc} -is a common name for the program counter; @pxref{Registers}). - -@table @code -@item undisplay @var{dnums}@dots{} -@itemx delete display @var{dnums}@dots{} -@kindex delete display -@kindex undisplay -Remove item numbers @var{dnums} from the list of expressions to display. - -@code{undisplay} will not repeat if you press @key{RET} after using it. -(Otherwise you would just get the error @samp{No display number @dots{}}.) - -@item disable display @var{dnums}@dots{} -@kindex disable display -Disable the display of item numbers @var{dnums}. A disabled display -item is not printed automatically, but is not forgotten. It may be -enabled again later. - -@item enable display @var{dnums}@dots{} -@kindex enable display -Enable display of item numbers @var{dnums}. It becomes effective once -again in auto display of its expression, until you specify otherwise. - -@item display -Display the current values of the expressions on the list, just as is -done when the program stops. - -@item info display -@kindex info display -Print the list of expressions previously set up to display -automatically, each one with its item number, but without showing the -values. This includes disabled expressions, which are marked as such. -It also includes expressions which would not be displayed right now -because they refer to automatic variables not currently available. -@end table - -If a display expression refers to local variables, then it does not make -sense outside the lexical context for which it was set up. Such an -expression is disabled when execution enters a context where one of its -variables is not defined. For example, if you give the command -@code{display last_char} while inside a function with an argument -@code{last_char}, then this argument will be displayed while the program -continues to stop inside that function. When it stops elsewhere---where -there is no variable @code{last_char}---display is disabled. The next time -your program stops where @code{last_char} is meaningful, you can enable the -display expression once again. - -@node Print Settings, Value History, Auto Display, Data -@section Print Settings - -@cindex format options -@cindex print settings -_GDBN__ provides the following ways to control how arrays, structures, -and symbols are printed. - -@noindent -These settings are useful for debugging programs in any language: - -@table @code -@item set print address -@item set print address on -@kindex set print address -_GDBN__ will print memory addresses showing the location of stack -traces, structure values, pointer values, breakpoints, and so forth, -even when it also displays the contents of those addresses. The default -is on. For example, this is what a stack frame display looks like, with -@code{set print address on}: -@smallexample -(_GDBP__) f -#0 set_quotes (lq=0x34c78 "<<", rq=0x34c88 ">>") - at input.c:530 -530 if (lquote != def_lquote) -@end smallexample - -@item set print address off -Do not print addresses when displaying their contents. For example, -this is the same stack frame displayed with @code{set print address off}: -@example -(_GDBP__) set print addr off -(_GDBP__) f -#0 set_quotes (lq="<<", rq=">>") at input.c:530 -530 if (lquote != def_lquote) -@end example - -@item show print address -@kindex show print address -Show whether or not addresses are to be printed. - -@item set print array -@itemx set print array on -@kindex set print array -_GDBN__ will pretty print arrays. This format is more convenient to read, -but uses more space. The default is off. - -@item set print array off. -Return to compressed format for arrays. - -@item show print array -@kindex show print array -Show whether compressed or pretty format is selected for displaying -arrays. - -@item set print elements @var{number-of-elements} -@kindex set print elements -If _GDBN__ is printing a large array, it will stop printing after it has -printed the number of elements set by the @code{set print elements} command. -This limit also applies to the display of strings. - -@item show print elements -@kindex show print elements -Display the number of elements of a large array that _GDBN__ will print -before losing patience. - -@item set print pretty on -@kindex set print pretty -Cause _GDBN__ to print structures in an indented format with one member per -line, like this: - -@example -$1 = @{ - next = 0x0, - flags = @{ - sweet = 1, - sour = 1 - @}, - meat = 0x54 "Pork" -@} -@end example - -@item set print pretty off -Cause _GDBN__ to print structures in a compact format, like this: - -@smallexample -$1 = @{next = 0x0, flags = @{sweet = 1, sour = 1@}, meat \ -= 0x54 "Pork"@} -@end smallexample - -@noindent -This is the default format. - -@item show print pretty -@kindex show print pretty -Show which format _GDBN__ will use to print structures. - -@item set print sevenbit-strings on -@kindex set print sevenbit-strings -Print using only seven-bit characters; if this option is set, -_GDBN__ will display any eight-bit characters (in strings or character -values) using the notation @code{\}@var{nnn}. For example, @kbd{M-a} is -displayed as @code{\341}. - -@item set print sevenbit-strings off -Print using either seven-bit or eight-bit characters, as required. This -is the default. - -@item show print sevenbit-strings -@kindex show print sevenbit-strings -Show whether or not _GDBN__ will print only seven-bit characters. - -@item set print union on -@kindex set print union -Tell _GDBN__ to print unions which are contained in structures. This is the -default setting. - -@item set print union off -Tell _GDBN__ not to print unions which are contained in structures. - -@item show print union -@kindex show print union -Ask _GDBN__ whether or not it will print unions which are contained in -structures. - -For example, given the declarations - -@smallexample -typedef enum @{Tree, Bug@} Species; -typedef enum @{Big_tree, Acorn, Seedling@} Tree_forms; -typedef enum @{Caterpillar, Cocoon, Butterfly@} Bug_forms; - -struct thing @{ - Species it; - union @{ - Tree_forms tree; - Bug_forms bug; - @} form; -@}; - -struct thing foo = @{Tree, @{Acorn@}@}; -@end smallexample - -@noindent -with @code{set print union on} in effect @samp{p foo} would print - -@smallexample -$1 = @{it = Tree, form = @{tree = Acorn, bug = Cocoon@}@} -@end smallexample - -@noindent -and with @code{set print union off} in effect it would print - -@smallexample -$1 = @{it = Tree, form = @{...@}@} -@end smallexample -@end table - -@noindent -These settings are of interest when debugging C++ programs: - -@table @code -@item set print demangle -@itemx set print demangle on -@kindex set print demangle -Print C++ names in their source form rather than in the mangled form -in which they are passed to the assembler and linker for type-safe linkage. -The default is on. - -@item show print demangle -@kindex show print demangle -Show whether C++ names will be printed in mangled or demangled form. - -@item set print asm-demangle -@itemx set print asm-demangle on -@kindex set print asm-demangle -Print C++ names in their source form rather than their mangled form, even -in assembler code printouts such as instruction disassemblies. -The default is off. - -@item show print asm-demangle -@kindex show print asm-demangle -Show whether C++ names in assembly listings will be printed in mangled -or demangled form. - -@item set print object -@itemx set print object on -@kindex set print object -When displaying a pointer to an object, identify the @emph{actual} -(derived) type of the object rather than the @emph{declared} type, using -the virtual function table. - -@item set print object off -Display only the declared type of objects, without reference to the -virtual function table. This is the default setting. - -@item show print object -@kindex show print object -Show whether actual, or declared, object types will be displayed. - -@item set print vtbl -@itemx set print vtbl on -@kindex set print vtbl -Pretty print C++ virtual function tables. The default is off. - -@item set print vtbl off -Do not pretty print C++ virtual function tables. - -@item show print vtbl -@kindex show print vtbl -Show whether C++ virtual function tables are pretty printed, or not. - -@end table - -@node Value History, Convenience Vars, Print Settings, Data -@section Value History - -@cindex value history -Values printed by the @code{print} command are saved in _GDBN__'s @dfn{value -history} so that you can refer to them in other expressions. Values are -kept until the symbol table is re-read or discarded (for example with -the @code{file} or @code{symbol-file} commands). When the symbol table -changes, the value history is discarded, since the values may contain -pointers back to the types defined in the symbol table. - -@cindex @code{$} -@cindex @code{$$} -@cindex history number -The values printed are given @dfn{history numbers} for you to refer to them -by. These are successive integers starting with one. @code{print} shows you -the history number assigned to a value by printing @samp{$@var{num} = } -before the value; here @var{num} is the history number. - -To refer to any previous value, use @samp{$} followed by the value's -history number. The way @code{print} labels its output is designed to -remind you of this. Just @code{$} refers to the most recent value in -the history, and @code{$$} refers to the value before that. -@code{$$@var{n}} refers to the @var{n}th value from the end; @code{$$2} -is the value just prior to @code{$$}, @code{$$1} is equivalent to -@code{$$}, and @code{$$0} is equivalent to @code{$}. - -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 -p *$ -@end example - -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 -p *$.next -@end example - -@noindent -You can print successive links in the chain by repeating this -command---which you can do by just typing @key{RET}. - -Note that the history records values, not expressions. If the value of -@code{x} is 4 and you type these commands: - -@example -print x -set x=5 -@end example - -@noindent -then the value recorded in the value history by the @code{print} command -remains 4 even though the value of @code{x} has changed. - -@table @code -@kindex show values -@item show values -Print the last ten values in the value history, with their item numbers. -This is like @samp{p@ $$9} repeated ten times, except that @code{show -values} does not change the history. - -@item show values @var{n} -Print ten history values centered on history item number @var{n}. - -@item show values + -Print ten history values just after the values last printed. If no more -values are available, produces no display. -@end table - -Pressing @key{RET} to repeat @code{show values @var{n}} has exactly the -same effect as @samp{show values +}. - -@node Convenience Vars, Registers, Value History, Data -@section Convenience Variables - -@cindex convenience variables -_GDBN__ provides @dfn{convenience variables} that you can use within -_GDBN__ to hold on to a value and refer to it later. These variables -exist entirely within _GDBN__; they are not part of your program, and -setting a convenience variable has no direct effect on further execution -of your program. That's why you can use them freely. - -Convenience variables are prefixed with @samp{$}. Any name preceded by -@samp{$} can be used for a convenience variable, unless it is one of -the predefined machine-specific register names (@pxref{Registers}). -(Value history references, in contrast, are @emph{numbers} preceded -by @samp{$}. @xref{Value History}.) - -You can save a value in a convenience variable with an assignment -expression, just as you would set a variable in your program. Example: - -@example -set $foo = *object_ptr -@end example - -@noindent -would save in @code{$foo} the value contained in the object pointed to by -@code{object_ptr}. - -Using a convenience variable for the first time creates it; but its value -is @code{void} until you assign a new value. You can alter the value with -another assignment at any time. - -Convenience variables have no fixed types. You can assign a convenience -variable any type of value, including structures and arrays, even if -that variable already has a value of a different type. The convenience -variable, when used as an expression, has the type of its current value. - -@table @code -@item show convenience -@kindex show convenience -Print a list of convenience variables used so far, and their values. -Abbreviated @code{show con}. -@end table - -One of the ways to use a convenience variable is as a counter to be -incremented or a pointer to be advanced. For example, to print -a field from successive elements of an array of structures: - -_0__@example -set $i = 0 -print bar[$i++]->contents -@i{@dots{} repeat that command by typing @key{RET}.} -_1__@end example - -Some convenience variables are created automatically by _GDBN__ and given -values likely to be useful. - -@table @code -@item $_ -@kindex $_ -The variable @code{$_} is automatically set by the @code{x} command to -the last address examined (@pxref{Memory}). Other commands which -provide a default address for @code{x} to examine also set @code{$_} -to that address; these commands include @code{info line} and @code{info -breakpoint}. The type of @code{$_} is @code{void *} except when set by the -@code{x} command, in which case it is a pointer to the type of @code{$__}. - -@item $__ -@kindex $__ -The variable @code{$__} is automatically set by the @code{x} command -to the value found in the last address examined. Its type is chosen -to match the format in which the data was printed. -@end table - -@node Registers, Floating Point Hardware, Convenience Vars, Data -@section Registers - -@cindex registers -You can refer to machine register contents, in expressions, as variables -with names starting with @samp{$}. The names of registers are different -for each machine; use @code{info registers} to see the names used on -your machine. - -@table @code -@item info registers -@kindex info registers -Print the names and values of all registers except floating-point -registers (in the selected stack frame). - -@item info all-registers -@kindex info all-registers -@cindex floating point registers -Print the names and values of all registers, including floating-point -registers. - -@item info registers @var{regname} -Print the relativized value of register @var{regname}. @var{regname} -may be any register name valid on the machine you are using, with -or without the initial @samp{$}. -@end table - -The register names @code{$pc} and @code{$sp} are used on most machines -for the program counter register and the stack pointer. For example, -you could print the program counter in hex with -@example -p/x $pc -@end example - -@noindent -or print the instruction to be executed next with -@example -x/i $pc -@end example - -@noindent -or add four to the stack pointer with -@example -set $sp += 4 -@end example - -@noindent -The last is a way of removing one word from the stack, on machines where -stacks grow downward in memory (most machines, nowadays). This assumes -that the innermost stack frame is selected; setting @code{$sp} is -not allowed when other stack frames are selected. (To pop entire frames -off the stack, regardless of machine architecture, use @code{return}; -@pxref{Returning}.) - -Often @code{$fp} is used for a register that contains a pointer to the -current stack frame, and @code{$ps} is sometimes used for a register -that contains the processor status. These standard register names may -be available on your machine even though the @code{info registers} -command shows other names. For example, on the SPARC, @code{info -registers} displays the processor status register as @code{$psr} but you -can also refer to it as @code{$ps}. - -_GDBN__ always considers the contents of an ordinary register as an -integer when the register is examined in this way. Some machines have -special registers which can hold nothing but floating point; these -registers are considered to have floating point values. There is no way -to refer to the contents of an ordinary register as floating point value -(although you can @emph{print} it as a floating point value with -@samp{print/f $@var{regname}}). - -Some registers have distinct ``raw'' and ``virtual'' data formats. This -means that the data format in which the register contents are saved by -the operating system is not the same one that your program normally -sees. For example, the registers of the 68881 floating point -coprocessor are always saved in ``extended'' (raw) format, but all C -programs expect to work with ``double'' (virtual) format. In such -cases, _GDBN__ normally works with the virtual format only (the format that -makes sense for your program), but the @code{info registers} command -prints the data in both formats. - -Normally, register values are relative to the selected stack frame -(@pxref{Selection}). This means that you get the value that the -register would contain if all stack frames farther in were exited and -their saved registers restored. In order to see the true contents of -hardware registers, you must select the innermost frame (with -@samp{frame 0}). - -However, _GDBN__ must deduce where registers are saved, from the machine -code generated by your compiler. If some registers are not saved, or if -_GDBN__ is unable to locate the saved registers, the selected stack -frame will make no difference. - -@node Floating Point Hardware, , Registers, Data -@section Floating Point Hardware -@cindex floating point -Depending on the host machine architecture, _GDBN__ may be able to give -you more information about the status of the floating point hardware. - -@table @code -@item info float -@kindex info float -If available, provides hardware-dependent information about the floating -point unit. The exact contents and layout vary depending on the -floating point chip. -@end table -@c FIXME: this is a cop-out. Try to get examples, explanations. Only -@c FIXME...supported currently on arm's and 386's. Mark properly with -@c FIXME... m4 macros to isolate general statements from hardware-dep, -@c FIXME... at that point. - -@node Languages, Symbols, Data, Top -@chapter Using _GDBN__ with Different Languages -@cindex languages - -Although programming languages generally have common aspects, they are -rarely expressed in the same manner. For instance, in ANSI C, -dereferencing a pointer @code{p} is accomplished by @code{*p}, but in -Modula-2, it is accomplished by @code{p^}. Values can also be -represented (and displayed) differently. Hex numbers in C are written -like @samp{0x1ae}, while in Modula-2 they appear as @samp{1AEH}. - -@cindex working language -Language-specific information is built into _GDBN__ for some languages, -allowing you to express operations like the above in the program's -native language, and allowing _GDBN__ to output values in a manner -consistent with the syntax of the program's native language. The -language you use to build expressions, called the @dfn{working -language}, can be selected manually, or _GDBN__ can set it -automatically. - -@menu -* Setting:: Switching between source languages -* Show:: Displaying the language -* Checks:: Type and Range checks -* Support:: Supported languages -@end menu - -@node Setting, Show, Languages, Languages -@section Switching between source languages - -There are two ways to control the working language---either have _GDBN__ -set it automatically, or select it manually yourself. You can use the -@code{set language} command for either purpose. On startup, _GDBN__ -defaults to setting the language automatically. - -@menu -* Manually:: Setting the working language manually -* Automatically:: Having _GDBN__ infer the source language -@end menu - -@node Manually, Automatically, Setting, Setting -@subsection Setting the working language - -@kindex set language -To set the language, issue the command @samp{set language @var{lang}}, -where @var{lang} is the name of a language: @code{c} or @code{modula-2}. -For a list of the supported languages, type @samp{set language}. - -Setting the language manually prevents _GDBN__ from updating the working -language automatically. This can lead to confusion if you try -to debug a program when the working language is not the same as the -source language, when an expression is acceptable to both -languages---but means different things. For instance, if the current -source file were written in C, and _GDBN__ was parsing Modula-2, a -command such as: - -@example -print a = b + c -@end example - -@noindent -might not have the effect you intended. In C, this means to add -@code{b} and @code{c} and place the result in @code{a}. The result -printed would be the value of @code{a}. In Modula-2, this means to compare -@code{a} to the result of @code{b+c}, yielding a @code{BOOLEAN} value. - -If you allow _GDBN__ to set the language automatically, then -you can count on expressions evaluating the same way in your debugging -session and in your program. - -@node Automatically, , Manually, Setting -@subsection Having _GDBN__ infer the source language - -To have _GDBN__ set the working language automatically, use @samp{set -language local} or @samp{set language auto}. _GDBN__ then infers the -language that a program was written in by looking at the name of its -source files, and examining their extensions: - -@table @file -@item *.mod -Modula-2 source file - -@item *.c -@itemx *.cc -C or C++ source file. -@end table - -This information is recorded for each function or procedure in a source -file. When your program stops in a frame (usually by encountering a -breakpoint), _GDBN__ sets the working language to the language recorded -for the function in that frame. If the language for a frame is unknown -(that is, if the function or block corresponding to the frame was -defined in a source file that does not have a recognized extension), the -current working language is not changed, and _GDBN__ issues a warning. - -This may not seem necessary for most programs, which are written -entirely in one source language. However, program modules and libraries -written in one source language can be used by a main program written in -a different source language. Using @samp{set language auto} in this -case frees you from having to set the working language manually. - -@node Show, Checks, Setting, Languages -@section Displaying the language - -The following commands will help you find out which language is the -working language, and also what language source files were written in. - -@kindex show language -@kindex info frame -@kindex info source -@table @code -@item show language -Display the current working language. This is the -language you can use with commands such as @code{print} to -build and compute expressions that may involve variables in the program. - -@item info frame -Among the other information listed here (@pxref{Frame Info,,Information -about a Frame}) is the source language for this frame. This is the -language that will become the working language if you ever use an -identifier that is in this frame. - -@item info source -Among the other information listed here (@pxref{Symbols,,Examining the -Symbol Table}) is the source language of this source file. - -@end table - -@node Checks, Support, Show, Languages -@section Type and range Checking - -@quotation -@emph{Warning:} In this release, the _GDBN__ commands for type and range -checking are included, but they do not yet have any effect. This -section documents the intended facilities. -@end quotation -@c FIXME remove warning when type/range code added - -Some languages are designed to guard you against making seemingly common -errors through a series of compile- and run-time checks. These include -checking the type of arguments to functions and operators, and making -sure mathematical overflows are caught at run time. Checks such as -these help to ensure a program's correctness once it has been compiled -by eliminating type mismatches, and providing active checks for range -errors when the program is running. - -_GDBN__ can check for conditions like the above if you wish. -Although _GDBN__ will not check the statements in your program, it -can check expressions entered directly into _GDBN__ for evaluation via -the @code{print} command, for example. As with the working language, -_GDBN__ can also decide whether or not to check automatically based on -the source language of the program being debugged. -@xref{Support,,Supported Languages}, for the default settings -of supported languages. - -@menu -* Type Checking:: An overview of type checking -* Range Checking:: An overview of range checking -@end menu - -@cindex type checking -@cindex checks, type -@node Type Checking, Range Checking, Checks, Checks -@subsection An overview of type checking - -Some languages, such as Modula-2, are strongly typed, meaning that the -arguments to operators and functions have to be of the correct type, -otherwise an error occurs. These checks prevent type mismatch -errors from ever causing any run-time problems. For example, - -@example -1 + 2 @result{} 3 -@error{} 1 + 2.3 -@end example - -The second example fails because the @code{CARDINAL} 1 is not -type-compatible with the @code{REAL} 2.3. - -For expressions you use in _GDBN__ commands, you can tell the _GDBN__ -type checker to skip checking; to treat any mismatches as errors and -abandon the expression; or only issue warnings when type mismatches -occur, but evaluate the expression anyway. When you choose the last of -these, _GDBN__ evaluates expressions like the second example above, but -also issues a warning. - -Even though you may turn type checking off, other type-based reasons may -prevent _GDBN__ from evaluating an expression. For instance, _GDBN__ does not -know how to add an @code{int} and a @code{struct foo}. These particular -type errors have nothing to do with the language in use, and usually -arise from expressions, such as the one described above, which make -little sense to evaluate anyway. - -Each language defines to what degree it is strict about type. For -instance, both Modula-2 and C require the arguments to arithmetical -operators to be numbers. In C, enumerated types and pointers can be -represented as numbers, so that they are valid arguments to mathematical -operators. @xref{Support,,Supported Languages}, for futher -details on specific languages. - -_GDBN__ provides some additional commands for controlling the type checker: - -@kindex set check -@kindex set check type -@kindex show check type -@table @code -@item set check type auto -Set type checking on or off based on the current working language. -@xref{Support,,Supported Languages}, for the default settings for -each language. - -@item set check type on -@itemx set check type off -Set type checking on or off, overriding the default setting for the -current working language. Issue a warning if the setting does not -match the language's default. If any type mismatches occur in -evaluating an expression while typechecking is on, _GDBN__ prints a -message and aborts evaluation of the expression. - -@item set check type warn -Cause the type checker to issue warnings, but to always attempt to -evaluate the expression. Evaluating the expression may still -be impossible for other reasons. For example, _GDBN__ cannot add -numbers and structures. - -@item show type -Show the current setting of the type checker, and whether or not _GDBN__ is -setting it automatically. -@end table - -@cindex range checking -@cindex checks, range -@node Range Checking, , Type Checking, Checks -@subsection An overview of Range Checking - -In some languages (such as Modula-2), it is an error to exceed the -bounds of a type; this is enforced with run-time checks. Such range -checking is meant to ensure program correctness by making sure -computations do not overflow, or indices on an array element access do -not exceed the bounds of the array. - -For expressions you use in _GDBN__ commands, you can tell _GDBN__ to -ignore range errors; to always treat them as errors and abandon the -expression; or to issue warnings when a range error occurs but evaluate -the expression anyway. - -A range error can result from numerical overflow, from exceeding an -array index bound, or when you type in a constant that is not a member -of any type. Some languages, however, do not treat overflows as an -error. In many implementations of C, mathematical overflow causes the -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 -@var{m} + 1 @result{} @var{s} -@end example - -This, too, is specific to individual languages, and in some cases -specific to individual compilers or machines. @xref{Support,, -Supported Languages}, for further details on specific languages. - -_GDBN__ provides some additional commands for controlling the range checker: - -@kindex set check -@kindex set check range -@kindex show check range -@table @code -@item set check range auto -Set range checking on or off based on the current working language. -@xref{Support,,Supported Languages}, for the default settings for -each language. - -@item set check range on -@itemx set check range off -Set range checking on or off, overriding the default setting for the -current working language. A warning is issued if the setting does not -match the language's default. If a range error occurs, then a message -is printed and evaluation of the expression is aborted. - -@item set check range warn -Output messages when the _GDBN__ range checker detects a range error, -but attempt to evaluate the expression anyway. Evaluating the -expression may still be impossible for other reasons, such as accessing -memory that the process does not own (a typical example from many UNIX -systems). - -@item show range -Show the current setting of the range checker, and whether or not it is -being set automatically by _GDBN__. -@end table - -@node Support, , Checks, Languages -@section Supported Languages - -_GDBN__ _GDB_VN__ supports C, C++, and Modula-2. The syntax for C and C++ is -so closely related that _GDBN__ does not distinguish the two. Some -_GDBN__ features may be used in expressions regardless of the language -you use: the _GDBN__ @code{@@} and @code{::} operators, and the -@samp{@{type@}addr} construct (@pxref{Expressions}) can be used with the constructs of -any of the supported languages. - -The following sections detail to what degree each of these -source languages is supported by _GDBN__. These sections are -not meant to be language tutorials or references, but serve only as a -reference guide to what the _GDBN__ expression parser will accept, and -what input and output formats should look like for different languages. -There are many good books written on each of these languages; please -look to these for a language reference or tutorial. - -@menu -* C:: C and C++ -* Modula-2:: Modula-2 -@end menu - -@node C, Modula-2, Support, Support -@subsection C and C++ -@cindex C and C++ - -@cindex expressions in C or C++ -Since C and C++ are so closely related, _GDBN__ does not distinguish -between them when interpreting the expressions recognized in _GDBN__ -commands. - -@cindex C++ -@kindex g++ -@cindex GNU C++ -The C++ debugging facilities are jointly implemented by the GNU C++ -compiler and _GDBN__. Therefore, to debug your C++ code effectively, -you must compile your C++ programs with the GNU C++ compiler, -@code{g++}. - - -@menu -* C Operators:: C and C++ Operators -* C Constants:: C and C++ Constants -* Cplusplus expressions:: C++ Expressions -* C Defaults:: Default settings for C and C++ -* C Checks:: C and C++ Type and Range Checks -* Debugging C:: _GDBN__ and C -* Debugging C plus plus:: Special features for C++ -@end menu - -@cindex C and C++ operators -@node C Operators, C Constants, C, C -@subsubsection C and C++ Operators - -Operators must be defined on values of specific types. For instance, -@code{+} is defined on numbers, but not on structures. Operators are -often defined on groups of types. For the purposes of C and C++, the -following definitions hold: - -@itemize @bullet -@item -@emph{Integral types} include @code{int} with any of its storage-class -specifiers, @code{char}, and @code{enum}s. - -@item -@emph{Floating-point types} include @code{float} and @code{double}. - -@item -@emph{Pointer types} include all types defined as @code{(@var{type} -*)}. - -@item -@emph{Scalar types} include all of the above. - -@end itemize - -@noindent -The following operators are supported. They are listed here -in order of increasing precedence: - -@table @code -_0__ -@item , -The comma or sequencing operator. Expressions in a comma-separated list -are evaluated from left to right, with the result of the entire -expression being the last expression evaluated. - -@item = -Assignment. The value of an assignment expression is the value -assigned. Defined on scalar types. - -@item @var{op}= -Used in an expression of the form @var{a} @var{op}@code{=} @var{b}, and -translated to @var{a} @code{=} @var{a op b}. @var{op}@code{=} and -@code{=} have the same precendence. @var{op} is any one of the -operators @code{|}, @code{^}, @code{&}, @code{<<}, @code{>>}, @code{+}, -@code{-}, @code{*}, @code{/}, @code{%}. - -@item ?: -The ternary operator. @code{@var{a} ? @var{b} : @var{c}} can be thought -of as: if @var{a} then @var{b} else @var{c}. @var{a} should be of an -integral type. - -@item || -Logical OR. Defined on integral types. - -@item && -Logical AND. Defined on integral types. - -@item | -Bitwise OR. Defined on integral types. - -@item ^ -Bitwise exclusive-OR. Defined on integral types. - -@item & -Bitwise AND. Defined on integral types. - -@item ==@r{, }!= -Equality and inequality. Defined on scalar types. The value of these -expressions is 0 for false and non-zero for true. - -@item <@r{, }>@r{, }<=@r{, }>= -Less than, greater than, less than or equal, greater than or equal. -Defined on scalar types. The value of these expressions is 0 for false -and non-zero for true. - -@item <<@r{, }>> -left shift, and right shift. Defined on integral types. - -@item @@ -The _GDBN__ ``artificial array'' operator (@pxref{Expressions}). - -@item +@r{, }- -Addition and subtraction. Defined on integral types, floating-point types and -pointer types. - -@item *@r{, }/@r{, }% -Multiplication, division, and modulus. Multiplication and division are -defined on integral and floating-point types. Modulus is defined on -integral types. - -@item ++@r{, }-- -Increment and decrement. When appearing before a variable, the -operation is performed before the variable is used in an expression; -when appearing after it, the variable's value is used before the -operation takes place. - -@item * -Pointer dereferencing. Defined on pointer types. Same precedence as -@code{++}. - -@item & -Address operator. Defined on variables. Same precedence as @code{++}. - -@item - -Negative. Defined on integral and floating-point types. Same -precedence as @code{++}. - -@item ! -Logical negation. Defined on integral types. Same precedence as -@code{++}. - -@item ~ -Bitwise complement operator. Defined on integral types. Same precedence as -@code{++}. - -@item .@r{, }-> -Structure member, and pointer-to-structure member. For convenience, -_GDBN__ regards the two as equivalent, choosing whether to dereference a -pointer based on the stored type information. -Defined on @code{struct}s and @code{union}s. - -@item [] -Array indexing. @code{@var{a}[@var{i}]} is defined as -@code{*(@var{a}+@var{i})}. Same precedence as @code{->}. - -@item () -Function parameter list. Same precedence as @code{->}. - -@item :: -C++ scope resolution operator. Defined on -@code{struct}, @code{union}, and @code{class} types. - -@item :: -The _GDBN__ scope operator (@pxref{Expressions}). Same precedence as -@code{::}, above. _1__ -@end table - -@cindex C and C++ constants -@node C Constants, Cplusplus expressions, C Operators, C -@subsubsection C and C++ Constants - -_GDBN__ allows you to express the constants of C and C++ in the -following ways: - -@itemize @bullet - -@item -Integer constants are a sequence of digits. Octal constants are -specified by a leading @samp{0} (ie. zero), and hexadecimal constants by -a leading @samp{0x} or @samp{0X}. Constants may also end with an -@samp{l}, specifying that the constant should be treated as a -@code{long} value. - -@item -Floating point constants are a sequence of digits, followed by a decimal -point, followed by a sequence of digits, and optionally followed by an -exponent. An exponent is of the form: -@samp{@w{e@r{[[}+@r{]|}-@r{]}@var{nnn}}}, where @var{nnn} is another -sequence of digits. The @samp{+} is optional for positive exponents. - -@item -Enumerated constants consist of enumerated identifiers, or their -integral equivalents. - -@item -Character constants are a single character surrounded by single quotes -(@code{'}), or a number---the ordinal value of the corresponding character -(usually its @sc{ASCII} value). Within quotes, the single character may -be represented by a letter or by @dfn{escape sequences}, which are of -the form @samp{\@var{nnn}}, where @var{nnn} is the octal representation -of the character's ordinal value; or of the form @samp{\@var{x}}, where -@samp{@var{x}} is a predefined special character---for example, -@samp{\n} for newline. - -@item -String constants are a sequence of character constants surrounded -by double quotes (@code{"}). - -@item -Pointer constants are an integral value. - -@end itemize - - -@node Cplusplus expressions, C Defaults, C Constants, C -@subsubsection C++ Expressions - -@cindex expressions in C++ -_GDBN__'s expression handling has the following extensions to -interpret a significant subset of C++ expressions: - -@enumerate - -@cindex member functions -@item -Member function calls are allowed; you can use expressions like -@example -count = aml->GetOriginal(x, y) -@end example - -@kindex this -@cindex namespace in C++ -@item -While a member function is active (in the selected stack frame), your -expressions have the same namespace available as the member function; -that is, _GDBN__ allows implicit references to the class instance -pointer @code{this} following the same rules as C++. - -@cindex call overloaded functions -@cindex type conversions in C++ -@item -You can call overloaded functions; _GDBN__ will resolve the function -call to the right definition, with one restriction---you must use -arguments of the type required by the function that you want to call. -_GDBN__ will not perform conversions requiring constructors or -user-defined type operators. - -@cindex reference declarations -@item -_GDBN__ understands variables declared as C++ references; you can use them in -expressions just as you do in C++ source---they are automatically -dereferenced. - -In the parameter list shown when _GDBN__ displays a frame, the values of -reference variables are not displayed (unlike other variables); this -avoids clutter, since references are often used for large structures. -The @emph{address} of a reference variable is always shown, unless -you've specified @samp{set print address off}. - - -@item -_GDBN__ supports the C++ name resolution operator @code{::}---your -expressions can use it just as expressions in your program do. Since -one scope may be defined in another, you can use @code{::} repeatedly if -necessary, for example in an expression like -@samp{@var{scope1}::@var{scope2}::@var{name}}. _GDBN__ also allows -resolving name scope by reference to source files, in both C and C++ -debugging; @pxref{Variables}. - -@end enumerate - - -@node C Defaults, C Checks, Cplusplus expressions, C -@subsubsection C and C++ Defaults -@cindex C and C++ defaults - -If you allow _GDBN__ to set type and range checking automatically, they -both default to @code{off} whenever the working language changes to -C/C++. This happens regardless of whether you, or _GDBN__, -selected the working language. - -If you allow _GDBN__ to set the language automatically, it sets the -working language to C/C++ on entering code compiled from a source file -whose name ends with @file{.c} or @file{.cc}. -@xref{Automatically,,Having _GDBN__ infer the source language}, for -further details. - -@node C Checks, Debugging C, C Defaults, C -@subsubsection C and C++ Type and Range Checks -@cindex C and C++ checks - -@quotation -@emph{Warning:} in this release, _GDBN__ does not yet perform type or -range checking. -@end quotation -@c FIXME remove warning when type/range checks added - -By default, when _GDBN__ parses C or C++ expressions, type checking -is not used. However, if you turn type checking on, _GDBN__ will -consider two variables type equivalent if: - -@itemize @bullet -@item -The two variables are structured and have the same structure, union, or -enumerated tag. - -@item -Two two variables have the same type name, or types that have been -declared equivalent through @code{typedef}. - -@ignore -@c leaving this out because neither J Gilmore nor R Pesch understand it. -@c FIXME--beers? -@item -The two @code{struct}, @code{union}, or @code{enum} variables are -declared in the same declaration. (Note: this may not be true for all C -compilers.) -@end ignore - -@end itemize - -Range checking, if turned on, is done on mathematical operations. Array -indices are not checked, since they are often used to index a pointer -that is not itself an array. - -@node Debugging C, Debugging C plus plus, C Checks, C -@subsubsection _GDBN__ and C - -The @code{set print union} and @code{show print union} commands apply to -the @code{union} type. When set to @samp{on}, any @code{union} that is -inside a @code{struct} or @code{class} will also be printed. -Otherwise, it will appear as @samp{@{...@}}. - -The @code{@@} operator aids in the debugging of dynamic arrays, formed -with pointers and a memory allocation function. (@pxref{Expressions}) - -@node Debugging C plus plus, , Debugging C, C -@subsubsection _GDBN__ Commands for C++ - -@cindex commands for C++ -Some _GDBN__ commands are particularly useful with C++, and some are -designed specifically for use with C++. Here is a summary: - -@table @code -@cindex break in overloaded functions -@item @r{breakpoint menus} -When you want a breakpoint in a function whose name is overloaded, -_GDBN__'s breakpoint menus help you specify which function definition -you want. @xref{Breakpoint Menus}. - -@cindex overloading in C++ -@item rbreak @var{regex} -Setting breakpoints using regular expressions is helpful for setting -breakpoints on overloaded functions that are not members of any special -classes. -@xref{Set Breaks}. - -@cindex C++ exception handling -@item catch @var{exceptions} -@itemx info catch -Debug C++ exception handling using these commands. @xref{Exception Handling}. - -@cindex inheritance -@item ptype @var{typename} -Print inheritance relationships as well as other information for type -@var{typename}. -@xref{Symbols}. - -@cindex C++ symbol display -@item set print demangle -@itemx show print demangle -@itemx set print asm-demangle -@itemx show print asm-demangle -Control whether C++ symbols display in their source form, both when -displaying code as C++ source and when displaying disassemblies. -@xref{Print Settings}. - -@item set print object -@itemx show print object -Choose whether to print derived (actual) or declared types of objects. -@xref{Print Settings}. - -@item set print vtbl -@itemx show print vtbl -Control the format for printing virtual function tables. -@xref{Print Settings}. - -@end table - - -@node Modula-2, , C, Support -@subsection Modula-2 -@cindex Modula-2 - -The extensions made to _GDBN__ to support Modula-2 support output -from the GNU Modula-2 compiler (which is currently being developed). -Other Modula-2 compilers are not currently supported, and attempting to -debug executables produced by them will most likely result in an error -as _GDBN__ reads in the executable's symbol table. - -@cindex expressions in Modula-2 -@menu -* M2 Operators:: Built-in operators -* Builtin Func/Proc:: Built-in Functions and Procedures -* M2 Constants:: Modula-2 Constants -* M2 Defaults:: Default settings for Modula-2 -* Deviations:: Deviations from standard Modula-2 -* M2 Checks:: Modula-2 Type and Range Checks -* M2 Scope:: The scope operators @code{::} and @code{.} -* GDB/M2:: _GDBN__ and Modula-2 -@end menu - -@node M2 Operators, Builtin Func/Proc, Modula-2, Modula-2 -@subsubsection Operators -@cindex Modula-2 operators - -Operators must be defined on values of specific types. For instance, -@code{+} is defined on numbers, but not on structures. Operators are -often defined on groups of types. For the purposes of Modula-2, the -following definitions hold: - -@itemize @bullet - -@item -@emph{Integral types} consist of @code{INTEGER}, @code{CARDINAL}, and -their subranges. - -@item -@emph{Character types} consist of @code{CHAR} and its subranges. - -@item -@emph{Floating-point types} consist of @code{REAL}. - -@item -@emph{Pointer types} consist of anything declared as @code{POINTER TO -@var{type}}. - -@item -@emph{Scalar types} consist of all of the above. - -@item -@emph{Set types} consist of @code{SET}s and @code{BITSET}s. - -@item -@emph{Boolean types} consist of @code{BOOLEAN}. - -@end itemize - -@noindent -The following operators are supported, and appear in order of -increasing precedence: - -@table @code -_0__ -@item , -Function argument or array index separator. - -@item := -Assignment. The value of @var{var} @code{:=} @var{value} is -@var{value}. - -@item <@r{, }> -Less than, greater than on integral, floating-point, or enumerated -types. - -@item <=@r{, }>= -Less than, greater than, less than or equal to, greater than or equal to -on integral, floating-point and enumerated types, or set inclusion on -set types. Same precedence as @code{<}. - -@item =@r{, }<>@r{, }# -Equality and two ways of expressing inequality, valid on scalar types. -Same precedence as @code{<}. In _GDBN__ scripts, only @code{<>} is -available for inequality, since @code{#} conflicts with the script -comment character. - -@item IN -Set membership. Defined on set types and the types of their members. -Same precedence as @code{<}. - -@item OR -Boolean disjunction. Defined on boolean types. - -@item AND@r{, }& -Boolean conjuction. Defined on boolean types. - -@item @@ -The _GDBN__ ``artificial array'' operator (@pxref{Expressions}). - -@item +@r{, }- -Addition and subtraction on integral and floating-point types, or union -and difference on set types. - -@item * -Multiplication on integral and floating-point types, or set intersection -on set types. - -@item / -Division on floating-point types, or symmetric set difference on set -types. Same precedence as @code{*}. - -@item DIV@r{, }MOD -Integer division and remainder. Defined on integral types. Same -precedence as @code{*}. - -@item - -Negative. Defined on @code{INTEGER}s and @code{REAL}s. - -@item ^ -Pointer dereferencing. Defined on pointer types. - -@item NOT -Boolean negation. Defined on boolean types. Same precedence as -@code{^}. - -@item . -@code{RECORD} field selector. Defined on @code{RECORD}s. Same -precedence as @code{^}. - -@item [] -Array indexing. Defined on @code{ARRAY}s. Same precedence as @code{^}. - -@item () -Procedure argument list. Defined on @code{PROCEDURE}s. Same precedence -as @code{^}. - -@item ::@r{, }. -_GDBN__ and Modula-2 scope operators. - -@end table - -@quotation -@emph{Warning:} Sets and their operations are not yet supported, so _GDBN__ -will treat the use of the operator @code{IN}, or the use of operators -@code{+}, @code{-}, @code{*}, @code{/}, @code{=}, , @code{<>}, @code{#}, -@code{<=}, and @code{>=} on sets as an error. -@end quotation -_1__ - -@cindex Modula-2 builtins -@node Builtin Func/Proc, M2 Constants, M2 Operators, Modula-2 -@subsubsection Built-in Functions and Procedures - -Modula-2 also makes available several built-in procedures and functions. -In describing these, the following metavariables are used: - -@table @var - -@item a -represents an @code{ARRAY} variable. - -@item c -represents a @code{CHAR} constant or variable. - -@item i -represents a variable or constant of integral type. - -@item m -represents an identifier that belongs to a set. Generally used in the -same function with the metavariable @var{s}. The type of @var{s} should -be @code{SET OF @var{mtype}} (where @var{mtype} is the type of @var{m}. - -@item n -represents a variable or constant of integral or floating-point type. - -@item r -represents a variable or constant of floating-point type. - -@item t -represents a type. - -@item v -represents a variable. - -@item x -represents a variable or constant of one of many types. See the -explanation of the function for details. - -@end table - -All Modula-2 built-in procedures also return a result, described below. - -@table @code -@item ABS(@var{n}) -Returns the absolute value of @var{n}. - -@item CAP(@var{c}) -If @var{c} is a lower case letter, it returns its upper case -equivalent, otherwise it returns its argument - -@item CHR(@var{i}) -Returns the character whose ordinal value is @var{i}. - -@item DEC(@var{v}) -Decrements the value in the variable @var{v}. Returns the new value. - -@item DEC(@var{v},@var{i}) -Decrements the value in the variable @var{v} by @var{i}. Returns the -new value. - -@item EXCL(@var{m},@var{s}) -Removes the element @var{m} from the set @var{s}. Returns the new -set. - -@item FLOAT(@var{i}) -Returns the floating point equivalent of the integer @var{i}. - -@item HIGH(@var{a}) -Returns the index of the last member of @var{a}. - -@item INC(@var{v}) -Increments the value in the variable @var{v}. Returns the new value. - -@item INC(@var{v},@var{i}) -Increments the value in the variable @var{v} by @var{i}. Returns the -new value. - -@item INCL(@var{m},@var{s}) -Adds the element @var{m} to the set @var{s} if it is not already -there. Returns the new set. - -@item MAX(@var{t}) -Returns the maximum value of the type @var{t}. - -@item MIN(@var{t}) -Returns the minimum value of the type @var{t}. - -@item ODD(@var{i}) -Returns boolean TRUE if @var{i} is an odd number. - -@item ORD(@var{x}) -Returns the ordinal value of its argument. For example, the ordinal -value of a character is its ASCII value (on machines supporting the -ASCII character set). @var{x} must be of an ordered type, which include -integral, character and enumerated types. - -@item SIZE(@var{x}) -Returns the size of its argument. @var{x} can be a variable or a type. - -@item TRUNC(@var{r}) -Returns the integral part of @var{r}. - -@item VAL(@var{t},@var{i}) -Returns the member of the type @var{t} whose ordinal value is @var{i}. -@end table - -@quotation -@emph{Warning:} Sets and their operations are not yet supported, so -_GDBN__ will treat the use of procedures @code{INCL} and @code{EXCL} as -an error. -@end quotation - -@cindex Modula-2 constants -@node M2 Constants, M2 Defaults, Builtin Func/Proc, Modula-2 -@subsubsection Constants - -_GDBN__ allows you to express the constants of Modula-2 in the following -ways: - -@itemize @bullet - -@item -Integer constants are simply a sequence of digits. When used in an -expression, a constant is interpreted to be type-compatible with the -rest of the expression. Hexadecimal integers are specified by a -trailing @samp{H}, and octal integers by a trailing @samp{B}. - -@item -Floating point constants appear as a sequence of digits, followed by a -decimal point and another sequence of digits. An optional exponent can -then be specified, in the form @samp{E@r{[}+@r{|}-@r{]}@var{nnn}}, where -@samp{@r{[}+@r{|}-@r{]}@var{nnn}} is the desired exponent. All of the -digits of the floating point constant must be valid decimal (base 10) -digits. - -@item -Character constants consist of a single character enclosed by a pair of -like quotes, either single (@code{'}) or double (@code{"}). They may -also be expressed by their ordinal value (their ASCII value, usually) -followed by a @samp{C}. - -@item -String constants consist of a sequence of characters enclosed by a pair -of like quotes, either single (@code{'}) or double (@code{"}). Escape -sequences in the style of C are also allowed. @xref{C Constants}, for a -brief explanation of escape sequences. - -@item -Enumerated constants consist of an enumerated identifier. - -@item -Boolean constants consist of the identifiers @code{TRUE} and -@code{FALSE}. - -@item -Pointer constants consist of integral values only. - -@item -Set constants are not yet supported. - -@end itemize - -@node M2 Defaults, Deviations, M2 Constants, Modula-2 -@subsubsection Modula-2 Defaults -@cindex Modula-2 defaults - -If type and range checking are set automatically by _GDBN__, they -both default to @code{on} whenever the working language changes to -Modula-2. This happens regardless of whether you, or _GDBN__, -selected the working language. - -If you allow _GDBN__ to set the language automatically, then entering -code compiled from a file whose name ends with @file{.mod} will set the -working language to Modula-2. @xref{Automatically,,Having _GDBN__ set -the language automatically}, for further details. - -@node Deviations, M2 Checks, M2 Defaults, Modula-2 -@subsubsection Deviations from Standard Modula-2 -@cindex Modula-2, deviations from - -A few changes have been made to make Modula-2 programs easier to debug. -This is done primarily via loosening its type strictness: - -@itemize @bullet -@item -Unlike in standard Modula-2, pointer constants can be formed by -integers. This allows you to modify pointer variables during -debugging. (In standard Modula-2, the actual address contained in a -pointer variable is hidden from you; it can only be modified -through direct assignment to another pointer variable or expression that -returned a pointer.) - -@item -C escape sequences can be used in strings and characters to represent -non-printable characters. _GDBN__ will print out strings with these -escape sequences embedded. Single non-printable characters are -printed using the @samp{CHR(@var{nnn})} format. - -@item -The assignment operator (@code{:=}) returns the value of its right-hand -argument. - -@item -All builtin procedures both modify @emph{and} return their argument. - -@end itemize - -@node M2 Checks, M2 Scope, Deviations, Modula-2 -@subsubsection Modula-2 Type and Range Checks -@cindex Modula-2 checks - -@quotation -@emph{Warning:} in this release, _GDBN__ does not yet perform type or -range checking. -@end quotation -@c FIXME remove warning when type/range checks added - -_GDBN__ considers two Modula-2 variables type equivalent if: - -@itemize @bullet -@item -They are of types that have been declared equivalent via a @code{TYPE -@var{t1} = @var{t2}} statement - -@item -They have been declared on the same line. (Note: This is true of the -GNU Modula-2 compiler, but it may not be true of other compilers.) - -@end itemize - -As long as type checking is enabled, any attempt to combine variables -whose types are not equivalent is an error. - -Range checking is done on all mathematical operations, assignment, array -index bounds, and all builtin functions and procedures. - -@node M2 Scope, GDB/M2, M2 Checks, Modula-2 -@subsubsection The scope operators @code{::} and @code{.} -@cindex scope -@kindex . -@kindex :: - -There are a few subtle differences between the Modula-2 scope operator -(@code{.}) and the _GDBN__ scope operator (@code{::}). The two have -similar syntax: - -@example - -@var{module} . @var{id} -@var{scope} :: @var{id} - -@end example - -@noindent -where @var{scope} is the name of a module or a procedure, -@var{module} the name of a module, and @var{id} is any delcared -identifier within the program, except another module. - -Using the @code{::} operator makes _GDBN__ search the scope -specified by @var{scope} for the identifier @var{id}. If it is not -found in the specified scope, then _GDBN__ will search all scopes -enclosing the one specified by @var{scope}. - -Using the @code{.} operator makes _GDBN__ search the current scope for -the identifier specified by @var{id} that was imported from the -definition module specified by @var{module}. With this operator, it is -an error if the identifier @var{id} was not imported from definition -module @var{module}, or if @var{id} is not an identifier in -@var{module}. - -@node GDB/M2, , M2 Scope, Modula-2 -@subsubsection _GDBN__ and Modula-2 - -Some _GDBN__ commands have little use when debugging Modula-2 programs. -Five subcommands of @code{set print} and @code{show print} apply -specifically to C and C++: @samp{vtbl}, @samp{demangle}, -@samp{asm-demangle}, @samp{object}, and @samp{union}. The first four -apply to C++, and the last to C's @code{union} type, which has no direct -analogue in Modula-2. - -The @code{@@} operator (@pxref{Expressions}), while available -while using any language, is not useful with Modula-2. Its -intent is to aid the debugging of @dfn{dynamic arrays}, which cannot be -created in Modula-2 as they can in C or C++. However, because an -address can be specified by an integral constant, the construct -@samp{@{@var{type}@}@var{adrexp}} is still useful. (@pxref{Expressions}) - -_0__ -@cindex @code{#} in Modula-2 -In _GDBN__ scripts, the Modula-2 inequality operator @code{#} is -interpreted as the beginning of a comment. Use @code{<>} instead. -_1__ - - -@node Symbols, Altering, Languages, Top -@chapter Examining the Symbol Table - -The commands described in this section allow you to inquire about the -symbols (names of variables, functions and types) defined in your -program. This information is inherent in the text of your program and -does not change as the program executes. _GDBN__ finds it in your -program's symbol table, in the file indicated when you started _GDBN__ -(@pxref{File Options}), or by one of the file-management commands -(@pxref{Files}). - -@table @code -@item info address @var{symbol} -@kindex info address -Describe where the data for @var{symbol} is stored. For a register -variable, this says which register it is kept in. For a non-register -local variable, this prints the stack-frame offset at which the variable -is always stored. - -Note the contrast with @samp{print &@var{symbol}}, which does not work -at all for a register variables, and for a stack local variable prints -the exact address of the current instantiation of the variable. - -@item whatis @var{exp} -@kindex whatis -Print the data type of expression @var{exp}. @var{exp} is not -actually evaluated, and any side-effecting operations (such as -assignments or function calls) inside it do not take place. -@xref{Expressions}. - -@item whatis -Print the data type of @code{$}, the last value in the value history. - -@item ptype @var{typename} -@kindex ptype -Print a description of data type @var{typename}. @var{typename} may be -the name of a type, or for C code it may have the form -@samp{struct @var{struct-tag}}, @samp{union @var{union-tag}} or -@samp{enum @var{enum-tag}}.@refill - -@item ptype @var{exp} -Print a description of the type of expression @var{exp}. @code{ptype} -differs from @code{whatis} by printing a detailed description, instead of just -the name of the type. For example, if your program declares a variable -as -@example -struct complex @{double real; double imag;@} v; -@end example -@noindent -compare the output of the two commands: -@example -(_GDBP__) whatis v -type = struct complex -(_GDBP__) ptype v -type = struct complex @{ - double real; - double imag; -@} -@end example - -@item info types @var{regexp} -@itemx info types -@kindex info types -Print a brief description of all types whose name matches @var{regexp} -(or all types in your program, if you supply no argument). Each -complete typename is matched as though it were a complete line; thus, -@samp{i type value} gives information on all types in your program whose -name includes the string @code{value}, but @samp{i type ^value$} gives -information only on types whose complete name is @code{value}. - -This command differs from @code{ptype} in two ways: first, like -@code{whatis}, it does not print a detailed description; second, it -lists all source files where a type is defined. - -@item info source -@kindex info source -Show the name of the current source file---that is, the source file for -the function containing the current point of execution---and the language -it was written in. - -@item info sources -@kindex info sources -Print the names of all source files in the program for which there is -debugging information, organized into two lists: files whose symbols -have already been read, and files whose symbols will be read when needed. - -@item info functions -@kindex info functions -Print the names and data types of all defined functions. - -@item info functions @var{regexp} -Print the names and data types of all defined functions -whose names contain a match for regular expression @var{regexp}. -Thus, @samp{info fun step} finds all functions whose names -include @code{step}; @samp{info fun ^step} finds those whose names -start with @code{step}. - -@item info variables -@kindex info variables -Print the names and data types of all variables that are declared -outside of functions (i.e., excluding local variables). - -@item info variables @var{regexp} -Print the names and data types of all variables (except for local -variables) whose names contain a match for regular expression -@var{regexp}. - - -@ignore -This was never implemented. -@item info methods -@itemx info methods @var{regexp} -@kindex info methods -The @code{info methods} command permits the user to examine all defined -methods within C++ program, or (with the @var{regexp} argument) a -specific set of methods found in the various C++ classes. Many -C++ classes provide a large number of methods. Thus, the output -from the @code{ptype} command can be overwhelming and hard to use. The -@code{info-methods} command filters the methods, printing only those -which match the regular-expression @var{regexp}. -@end ignore - -@item printsyms @var{filename} -@kindex printsyms -Write a dump of debugging symbol data into the file -@var{filename}. Only symbols with debugging data are included. _GDBN__ -includes all the symbols it already knows about: that is, @var{filename} -reflects symbols for only those files whose symbols _GDBN__ has read. -You can find out which files these are using the command @code{info -files}. The description of @code{symbol-file} describes how _GDBN__ -reads symbols; both commands are described under @ref{Files}. -@end table - -@node Altering, _GDBN__ Files, Symbols, Top -@chapter Altering Execution - -Once you think you have found an error in the program, you might want to -find out for certain whether correcting the apparent error would lead to -correct results in the rest of the run. You can find the answer by -experiment, using the _GDBN__ features for altering execution of the -program. - -For example, you can store new values into variables or memory -locations, give the program a signal, restart it at a different address, -or even return prematurely from a function to its caller. - -@menu -* Assignment:: Assignment to Variables -* Jumping:: Continuing at a Different Address -* Signaling:: Giving the Program a Signal -* Returning:: Returning from a Function -* Calling:: Calling your Program's Functions -* Patching:: Patching your Program -@end menu - -@node Assignment, Jumping, Altering, Altering -@section Assignment to Variables - -@cindex assignment -@cindex setting variables -To alter the value of a variable, evaluate an assignment expression. -@xref{Expressions}. For example, - -@example -print x=4 -@end example - -@noindent -would store the value 4 into the variable @code{x}, and then print the -value of the assignment expression (which is 4). @xref{Languages}, for -more information on operators in supported languages. - -@kindex set variable -@cindex variables, setting -If you are not interested in seeing the value of the assignment, use the -@code{set} command instead of the @code{print} command. @code{set} is -really the same as @code{print} except that the expression's value is not -printed and is not put in the value history (@pxref{Value History}). The -expression is evaluated only for its effects. - -If the beginning of the argument string of the @code{set} command -appears identical to a @code{set} subcommand, use the @code{set -variable} command instead of just @code{set}. This command is identical -to @code{set} except for its lack of subcommands. For example, a -program might well have a variable @code{width}---which leads to -an error if we try to set a new value with just @samp{set width=13}, as -we might if @code{set width} didn't happen to be a _GDBN__ command: -@example -(_GDBP__) whatis width -type = double -(_GDBP__) p width -$4 = 13 -(_GDBP__) set width=47 -Invalid syntax in expression. -@end example -@noindent -The invalid expression, of course, is @samp{=47}. What we can do in -order to actually set our program's variable @code{width} is -@example -(_GDBP__) set var width=47 -@end example - -_GDBN__ allows more implicit conversions in assignments than C does; you can -freely store an integer value into a pointer variable or vice versa, and -any structure can be converted to any other structure that is the same -length or shorter. -@comment FIXME: how do structs align/pad in these conversions? -@comment /pesch@cygnus.com 18dec1990 - -To store values into arbitrary places in memory, use the @samp{@{@dots{}@}} -construct to generate a value of specified type at a specified address -(@pxref{Expressions}). For example, @code{@{int@}0x83040} refers -to memory location @code{0x83040} as an integer (which implies a certain size -and representation in memory), and - -@example -set @{int@}0x83040 = 4 -@end example - -@noindent -stores the value 4 into that memory location. - -@node Jumping, Signaling, Assignment, Altering -@section Continuing at a Different Address - -Ordinarily, when you continue the program, you do so at the place where -it stopped, with the @code{continue} command. You can instead continue at -an address of your own choosing, with the following commands: - -@table @code -@item jump @var{linespec} -@kindex jump -Resume execution at line @var{linespec}. Execution will stop -immediately if there is a breakpoint there. @xref{List} for a -description of the different forms of @var{linespec}. - -The @code{jump} command does not change the current stack frame, or -the stack pointer, or the contents of any memory location or any -register other than the program counter. If line @var{linespec} is in -a different function from the one currently executing, the results may -be bizarre if the two functions expect different patterns of arguments or -of local variables. For this reason, the @code{jump} command requests -confirmation if the specified line is not in the function currently -executing. However, even bizarre results are predictable if you are -well acquainted with the machine-language code of the program. - -@item jump *@var{address} -Resume execution at the instruction at address @var{address}. -@end table - -You can get much the same effect as the @code{jump} command by storing a -new value into the register @code{$pc}. The difference is that this -does not start the program running; it only changes the address where it -@emph{will} run when it is continued. For example, - -@example -set $pc = 0x485 -@end example - -@noindent -causes the next @code{continue} command or stepping command to execute at -address 0x485, rather than at the address where the program stopped. -@xref{Continuing and Stepping}. - -The most common occasion to use the @code{jump} command is to back up, -perhaps with more breakpoints set, over a portion of a program that has -already executed, in order to examine its execution in more detail. - -@node Signaling, Returning, Jumping, Altering -@c @group -@section Giving the Program a Signal - -@table @code -@item signal @var{signalnum} -@kindex signal -Resume execution where the program stopped, but give it immediately the -signal number @var{signalnum}. - -Alternatively, if @var{signalnum} is zero, continue execution without -giving a signal. This is useful when the program stopped on account of -a signal and would ordinary see the signal when resumed with the -@code{continue} command; @samp{signal 0} causes it to resume without a -signal. - -@code{signal} does not repeat when you press @key{RET} a second time -after executing the command. -@end table -@c @end group - -@node Returning, Calling, Signaling, Altering -@section Returning from a Function - -@table @code -@item return -@itemx return @var{expression} -@cindex returning from a function -@kindex return -You can cancel execution of a function call with the @code{return} -command. If you give an -@var{expression} argument, its value is used as the function's return -value. -@end table - -When you use @code{return}, _GDBN__ discards the selected stack frame -(and all frames within it). You can think of this as making the -discarded frame return prematurely. If you wish to specify a value to -be returned, give that value as the argument to @code{return}. - -This pops the selected stack frame (@pxref{Selection}), and any other -frames inside of it, leaving its caller as the innermost remaining -frame. That frame becomes selected. The specified value is stored in -the registers used for returning values of functions. - -The @code{return} command does not resume execution; it leaves the -program stopped in the state that would exist if the function had just -returned. In contrast, the @code{finish} command -(@pxref{Continuing and Stepping}) -resumes execution until the selected stack frame returns naturally.@refill - -@node Calling, Patching, Returning, Altering -@section Calling your Program's Functions - -@cindex calling functions -@kindex call -@table @code -@item call @var{expr} -Evaluate the expression @var{expr} without displaying @code{void} -returned values. -@end table - -You can use this variant of the @code{print} command if you want to -execute a function from your program, but without cluttering the output -with @code{void} returned values. The result is printed and saved in -the value history, if it is not void. - -@node Patching, , Calling, Altering -@section Patching your Program -@cindex patching binaries -@cindex writing into executables -@cindex writing into corefiles -By default, _GDBN__ opens the file containing your program's executable -code (or the corefile) read-only. This prevents accidental alterations -to machine code; but it also prevents you from intentionally patching -your program's binary. - -If you'd like to be able to patch the binary, you can specify that -explicitly with the @code{set write} command. For example, you might -want to turn on internal debugging flags, or even to make emergency -repairs. - -@table @code -@item set write on -@itemx set write off -@kindex set write -If you specify @samp{set write on}, _GDBN__ will open executable and -core files for both reading and writing; if you specify @samp{set write -off} (the default), _GDBN__ will open them read-only. - -If you've already loaded a file, you must load it -again (using the @code{exec-file} or @code{core-file} command) after -changing @code{set write}, for your new setting to take effect. - -@item show write -@kindex show write -Display whether executable files and core files will be opened for -writing as well as reading. - -@end table - -@node _GDBN__ Files, Targets, Altering, Top -@chapter _GDBN__'s Files - -@menu -* Files:: Commands to Specify Files -* Symbol Errors:: Errors Reading Symbol Files -@end menu - -@node Files, Symbol Errors, _GDBN__ Files, _GDBN__ Files -@section Commands to Specify Files -@cindex core dump file -@cindex symbol table -_GDBN__ needs to know the file name of the program to be debugged, both in -order to read its symbol table and in order to start the program. To -debug a core dump of a previous run, _GDBN__ must be told the file name of -the core dump. - -The usual way to specify the executable and core dump file names is with -the command arguments given when you start _GDBN__, as discussed in -@pxref{Invocation}. - -Occasionally it is necessary to change to a different file during a -_GDBN__ session. Or you may run _GDBN__ and forget to specify the files you -want to use. In these situations the _GDBN__ commands to specify new files -are useful. - -@table @code -@item file @var{filename} -@cindex executable file -@kindex file -Use @var{filename} as the program to be debugged. It is read for its -symbols and for the contents of pure memory. It is also the program -executed when you use the @code{run} command. If you do not specify a -directory and the file is not found in _GDBN__'s working directory, - -_GDBN__ uses the environment variable @code{PATH} as a list of -directories to search, just as the shell does when looking for a program -to run. You can change the value of this variable, for both _GDBN__ and -your program, using the @code{path} command. - -@code{file} with no argument makes _GDBN__ discard any information it -has on both executable file and the symbol table. - -@item exec-file @var{filename} -@kindex exec-file -Specify that the program to be run (but not the symbol table) is found -in @var{filename}. _GDBN__ will search the environment variable @code{PATH} -if necessary to locate the program. - -@item symbol-file @var{filename} -@kindex symbol-file -Read symbol table information from file @var{filename}. @code{PATH} is -searched when necessary. Use the @code{file} command to get both symbol -table and program to run from the same file. - -@code{symbol-file} with no argument clears out _GDBN__'s information on your -program's symbol table. - -The @code{symbol-file} command causes _GDBN__ to forget the contents of its -convenience variables, the value history, and all breakpoints and -auto-display expressions. This is because they may contain pointers to -the internal data recording symbols and data types, which are part of -the old symbol table data being discarded inside _GDBN__. - -@code{symbol-file} will not repeat if you press @key{RET} again after -executing it once. - -On some kinds of object files, the @code{symbol-file} command does not -actually read the symbol table in full right away. Instead, it scans -the symbol table quickly to find which source files and which symbols -are present. The details are read later, one source file at a time, -when they are needed. - -The purpose of this two-stage reading strategy is to make _GDBN__ start up -faster. For the most part, it is invisible except for occasional pauses -while the symbol table details for a particular source file are being -read. (The @code{set verbose} command can turn these pauses into -messages if desired. @xref{Messages/Warnings}). - -When the symbol table is stored in COFF format, @code{symbol-file} does -read the symbol table data in full right away. We haven't implemented -the two-stage strategy for COFF yet. - -When _GDBN__ is configured for a particular environment, it will -understand debugging information in whatever format is the standard -generated for that environment; you may use either a GNU compiler, or -other compilers that adhere to the local conventions. Best results are -usually obtained from GNU compilers; for example, using @code{_GCC__} -you can generate debugging information for optimized code. - -@item core-file @var{filename} -@itemx core @var{filename} -@kindex core -@kindex core-file -Specify the whereabouts of a core dump file to be used as the ``contents -of memory''. Traditionally, core files contain only some parts of the -address space of the process that generated them; _GDBN__ can access the -executable file itself for other parts. - -@code{core-file} with no argument specifies that no core file is -to be used. - -Note that the core file is ignored when your program is actually running -under _GDBN__. So, if you have been running the program and you wish to -debug a core file instead, you must kill the subprocess in which the -program is running. To do this, use the @code{kill} command -(@pxref{Kill Process}). - -@item load @var{filename} -@kindex load -_if__(_GENERIC__) -Depending on what remote debugging facilities are configured into -_GDBN__, the @code{load} command may be available. Where it exists, it -is meant to make @var{filename} (an executable) available for debugging -on the remote system---by downloading, or dynamic linking, for example. -@code{load} also records @var{filename}'s symbol table in _GDBN__, like -the @code{add-symbol-file} command. - -If @code{load} is not available on your _GDBN__, attempting to execute -it gets the error message ``@code{You can't do that when your target is -@dots{}}'' -_fi__(_GENERIC__) - -_if__(_VXWORKS__) -On VxWorks, @code{load} will dynamically link @var{filename} on the -current target system as well as adding its symbols in _GDBN__. -_fi__(_VXWORKS__) - -_if__(_I960__) -@cindex download to Nindy-960 -With the Nindy interface to an Intel 960 board, @code{load} will -download @var{filename} to the 960 as well as adding its symbols in -_GDBN__. -_fi__(_I960__) - -@code{load} will not repeat if you press @key{RET} again after using it. - -@item add-symbol-file @var{filename} @var{address} -@kindex add-symbol-file -@cindex dynamic linking -The @code{add-symbol-file} command reads additional symbol table information -from the file @var{filename}. You would use this command when @var{filename} -has been dynamically loaded (by some other means) into the program that -is running. @var{address} should be the memory address at which the -file has been loaded; _GDBN__ cannot figure this out for itself. - -The symbol table of the file @var{filename} is added to the symbol table -originally read with the @code{symbol-file} command. You can use the -@code{add-symbol-file} command any number of times; the new symbol data thus -read keeps adding to the old. To discard all old symbol data instead, -use the @code{symbol-file} command. - -@code{add-symbol-file} will not repeat if you press @key{RET} after using it. - -@item info files -@itemx info target -@kindex info files -@kindex info target -@code{info files} and @code{info target} are synonymous; both print the -current targets (@pxref{Targets}), including the names of the executable -and core dump files currently in use by _GDBN__, and the files from -which symbols were loaded. The command @code{help targets} lists all -possible targets rather than current ones. - -@end table - -All file-specifying commands allow both absolute and relative file names -as arguments. _GDBN__ always converts the file name to an absolute path -name and remembers it that way. - -@cindex shared libraries - -_GDBN__ supports the SunOS shared library format. _GDBN__ automatically -loads symbol definitions from shared libraries when you use the -@code{run} command, or when you examine a core file. (Before you issue -the @code{run} command, _GDBN__ won't understand references to a -function in a shared library, however---unless you're debugging a core -file). -@c FIXME: next _GDBN__ release should permit some refs to undef -@c FIXME...symbols---eg in a break cmd---assuming they're from a shared lib - -@table @code -@item info share -@itemx info sharedlibrary -@kindex info sharedlibrary -@kindex info share -Print the names of the shared libraries which are currently loaded. - -@item sharedlibrary @var{regex} -@itemx share @var{regex} -@kindex sharedlibrary -@kindex share -This is an obsolescent command; you can use it to explicitly -load shared object library symbols for files matching a UNIX regular -expression, but as with files loaded automatically, it will only load -shared libraries required by your program for a core file or after -typing @code{run}. If @var{regex} is omitted all shared libraries -required by your program are loaded. -@end table - -@node Symbol Errors, , Files, _GDBN__ Files -@section Errors Reading Symbol Files -While reading a symbol file, _GDBN__ will occasionally encounter -problems, such as symbol types it does not recognize, or known bugs in -compiler output. By default, _GDBN__ does not notify you of such -problems, since they're relatively common and primarily of interest to -people debugging compilers. If you are interested in seeing information -about ill-constructed symbol tables, you can either ask _GDBN__ to print -only one message about each such type of problem, no matter how many -times the problem occurs; or you can ask _GDBN__ to print more messages, -to see how many times the problems occur, with the @code{set complaints} -command (@xref{Messages/Warnings}). - -The messages currently printed, and their meanings, are: - -@table @code -@item inner block not inside outer block in @var{symbol} - -The symbol information shows where symbol scopes begin and end -(such as at the start of a function or a block of statements). This -error indicates that an inner scope block is not fully contained -in its outer scope blocks. - -_GDBN__ circumvents the problem by treating the inner block as if it had -the same scope as the outer block. In the error message, @var{symbol} -may be shown as ``@code{(don't know)}'' if the outer block is not a -function. - -@item block at @var{address} out of order - -The symbol information for symbol scope blocks should occur in -order of increasing addresses. This error indicates that it does not -do so. - -_GDBN__ does not circumvent this problem, and will have trouble locating -symbols in the source file whose symbols being read. (You can often -determine what source file is affected by specifying @code{set verbose -on}. @xref{Messages/Warnings}.) - -@item bad block start address patched - -The symbol information for a symbol scope block has a start address -smaller than the address of the preceding source line. This is known -to occur in the SunOS 4.1.1 (and earlier) C compiler. - -_GDBN__ circumvents the problem by treating the symbol scope block as -starting on the previous source line. - -@item bad string table offset in symbol @var{n} - -@cindex foo -Symbol number @var{n} contains a pointer into the string table which is -larger than the size of the string table. - -_GDBN__ circumvents the problem by considering the symbol to have the -name @code{foo}, which may cause other problems if many symbols end up -with this name. - -@item unknown symbol type @code{0x@var{nn}} - -The symbol information contains new data types that _GDBN__ does not yet -know how to read. @code{0x@var{nn}} is the symbol type of the misunderstood -information, in hexadecimal. - -_GDBN__ circumvents the error by ignoring this symbol information. This -will usually allow the program to be debugged, though certain symbols -will not be accessible. If you encounter such a problem and feel like -debugging it, you can debug @code{_GDBP__} with itself, breakpoint on -@code{complain}, then go up to the function @code{read_dbx_symtab} and -examine @code{*bufp} to see the symbol. - -@item stub type has NULL name -_GDBN__ could not find the full definition for a struct or class. - -@ignore -@c this is #if 0'd in dbxread.c as of (at least!) 17 may 1991 -@item const/volatile indicator missing, got '@var{X}' - -The symbol information for a C++ member function is missing some -information that the compiler should have output for it. -@end ignore - -@item C++ type mismatch between compiler and debugger - -_GDBN__ could not parse a type specification output by the compiler -for some C++ object. - -@end table - -@node Targets, Controlling _GDBN__, _GDBN__ Files, Top -@chapter Specifying a Debugging Target -@cindex debugging target -@kindex target -A @dfn{target} is an interface between the debugger and a particular -kind of file or process. - -Often, you will be able to run _GDBN__ in the same host environment as the -program you are debugging; in that case, the debugging target can just be -specified as a side effect of the @code{file} or @code{core} commands. -When you need more flexibility---for example, running _GDBN__ on a -physically separate host, controlling standalone systems over a -serial port, or realtime systems over a TCP/IP connection---you can use -the @code{target} command. - -@menu -* Active Targets:: Active Targets -* Target Commands:: Commands for Managing Targets -* Remote:: Remote Debugging -@end menu - -@node Active Targets, Target Commands, Targets, Targets -@section Active Targets -@cindex stacking targets -@cindex active targets -@cindex multiple targets - -Targets are managed in three @dfn{strata} that correspond to different -classes of target: processes, core files, and executable files. This -allows you to (for example) start a process and inspect its activity -without abandoning your work on a core file. - -More than one target can potentially respond to a request. In -particular, when you access memory _GDBN__ will examine the three strata of -targets until it finds a target that can handle that particular address. -Strata are always examined in a fixed order: first a process if there is -one, then a core file if there is one, and finally an executable file if -there is one of those. - -When you specify a new target in a given stratum, it replaces any target -previously in that stratum. - -To get rid of a target without replacing it, use the @code{detach} -command. The related command @code{attach} provides you with a way of -choosing a particular running process as a new target. @xref{Attach}. - -@node Target Commands, Remote, Active Targets, Targets -@section Commands for Managing Targets - -@table @code -@item target @var{type} @var{parameters} -Connects the _GDBN__ host environment to a target machine or process. A -target is typically a protocol for talking to debugging facilities. You -use the argument @var{type} to specify the type or protocol of the -target machine. - -Further @var{parameters} are interpreted by the target protocol, but -typically include things like device names or host names to connect -with, process numbers, and baud rates. - -The @code{target} command will not repeat if you press @key{RET} again -after executing the command. - -@item help target -@kindex help target -Displays the names of all targets available. To display targets -currently selected, use either @code{info target} or @code{info files} -(@pxref{Files}). - -@item help target @var{name} -Describe a particular target, including any parameters necessary to -select it. -@end table - -Here are some common targets (available, or not, depending on the _GDBN__ -configuration): - -@table @code -@item target exec @var{prog} -@kindex target exec -An executable file. @samp{target exec @var{prog}} is the same as -@samp{exec-file @var{prog}}. - -@item target core @var{filename} -@kindex target core -A core dump file. @samp{target core @var{filename}} is the same as -@samp{core-file @var{filename}}. - -@item target remote @var{dev} -@kindex target remote -Remote serial target in _GDBN__-specific protocol. The argument @var{dev} -specifies what serial device to use for the connection (e.g. -@file{/dev/ttya}). @xref{Remote}. - -_if__(_AMD29K__) -@item target amd-eb @var{dev} @var{speed} @var{PROG} -@kindex target amd-eb -@cindex AMD EB29K -Remote PC-resident AMD EB29K board, attached over serial lines. -@var{dev} is the serial device, as for @code{target remote}; -@var{speed} allows you to specify the linespeed; and @var{PROG} is the -name of the program to be debugged, as it appears to DOS on the PC. -@xref{EB29K Remote}. - -_fi__(_AMD29K__) -_if__(_I960__) -@item target nindy @var{devicename} -@kindex target nindy -An Intel 960 board controlled by a Nindy Monitor. @var{devicename} is -the name of the serial device to use for the connection, e.g. -@file{/dev/ttya}. @xref{i960-Nindy Remote}. - -_fi__(_I960__) -_if__(_VXWORKS__) -@item target vxworks @var{machinename} -@kindex target vxworks -A VxWorks system, attached via TCP/IP. The argument @var{machinename} -is the target system's machine name or IP address. -@xref{VxWorks Remote}. -_fi__(_VXWORKS__) -@end table - -_if__(_GENERIC__) -Different targets are available on different configurations of _GDBN__; your -configuration may have more or fewer targets. -_fi__(_GENERIC__) - -@node Remote, , Target Commands, Targets -@section Remote Debugging -@cindex remote debugging - -_if__(_GENERIC__) -@menu -_include__(gdbinv-m.m4)<>_dnl__ -@end menu -_fi__(_GENERIC__) - -If you are trying to debug a program running on a machine that can't run -_GDBN__ in the usual way, it is often useful to use remote debugging. For -example, you might use remote debugging on an operating system kernel, or on -a small system which does not have a general purpose operating system -powerful enough to run a full-featured debugger. - -Some configurations of _GDBN__ have special serial or TCP/IP interfaces -to make this work with particular debugging targets. In addition, -_GDBN__ comes with a generic serial protocol (specific to _GDBN__, but -not specific to any particular target system) which you can use if you -write the remote stubs---the code that will run on the remote system to -communicate with _GDBN__. - -To use the _GDBN__ remote serial protocol, the program to be debugged on -the remote machine needs to contain a debugging stub which talks to -_GDBN__ over the serial line. Several working remote stubs are -distributed with _GDBN__; see the @file{README} file in the _GDBN__ -distribution for more information. - -For details of this communication protocol, see the comments in the -_GDBN__ source file @file{remote.c}. - -To start remote debugging, first run _GDBN__ and specify as an executable file -the program that is running in the remote machine. This tells _GDBN__ how -to find the program's symbols and the contents of its pure text. Then -establish communication using the @code{target remote} command with a device -name as an argument. For example: - -@example -target remote /dev/ttyb -@end example - -@noindent -if the serial line is connected to the device named @file{/dev/ttyb}. This -will stop the remote machine if it is not already stopped. - -Now you can use all the usual commands to examine and change data and to -step and continue the remote program. - -To resume the remote program and stop debugging it, use the @code{detach} -command. - -Other remote targets may be available in your -configuration of _GDBN__; use @code{help targets} to list them. - -_if__(_GENERIC__) -@c Text on starting up GDB in various specific cases; it goes up front -@c in manuals configured for any of those particular situations, here -@c otherwise. -_include__(gdbinv-s.m4) -_fi__(_GENERIC__) - -@node Controlling _GDBN__, Sequences, Targets, Top -@chapter Controlling _GDBN__ - -You can alter many aspects of _GDBN__'s interaction with you by using -the @code{set} command. For commands controlling how _GDBN__ displays -data, @pxref{Print Settings}; other settings are described here. - -@menu -* Prompt:: Prompt -* Editing:: Command Editing -* History:: Command History -* Screen Size:: Screen Size -* Numbers:: Numbers -* Messages/Warnings:: Optional Warnings and Messages -@end menu - -@node Prompt, Editing, Controlling _GDBN__, Controlling _GDBN__ -@section Prompt -@cindex prompt -_GDBN__ indicates its readiness to read a command by printing a string -called the @dfn{prompt}. This string is normally @samp{(_GDBP__)}. You -can change the prompt string with the @code{set prompt} command. For -instance, when debugging _GDBN__ with _GDBN__, it is useful to change -the prompt in one of the _GDBN__<>s so that you can always tell which -one you are talking to. - -@table @code -@item set prompt @var{newprompt} -@kindex set prompt -Directs _GDBN__ to use @var{newprompt} as its prompt string henceforth. -@kindex show prompt -@item show prompt -Prints a line of the form: @samp{Gdb's prompt is: @var{your-prompt}} -@end table - -@node Editing, History, Prompt, Controlling _GDBN__ -@section Command Editing -@cindex readline -@cindex command line editing -_GDBN__ reads its input commands via the @dfn{readline} interface. This -GNU library provides consistent behavior for programs which provide a -command line interface to the user. Advantages are @code{emacs}-style -or @code{vi}-style inline editing of commands, @code{csh}-like history -substitution, and a storage and recall of command history across -debugging sessions. - -You may control the behavior of command line editing in _GDBN__ with the -command @code{set}. - -@table @code -@kindex set editing -@cindex editing -@item set editing -@itemx set editing on -Enable command line editing (enabled by default). - -@item set editing off -Disable command line editing. - -@kindex show editing -@item show editing -Show whether command line editing is enabled. -@end table - -@node History, Screen Size, Editing, Controlling _GDBN__ -@section Command History -@table @code -@cindex history substitution -@cindex history file -@kindex set history filename -@item set history filename @var{fname} -Set the name of the _GDBN__ command history file to @var{fname}. This is -the file from which _GDBN__ will read an initial command history -list or to which it will write this list when it exits. This list is -accessed through history expansion or through the history -command editing characters listed below. This file defaults to the -value of the environment variable @code{GDBHISTFILE}, or to -@file{./.gdb_history} if this variable is not set. - -@cindex history save -@kindex set history save -@item set history save -@itemx set history save on -Record command history in a file, whose name may be specified with the -@code{set history filename} command. By default, this option is disabled. - -@item set history save off -Stop recording command history in a file. - -@cindex history size -@kindex set history size -@item set history size @var{size} -Set the number of commands which _GDBN__ will keep in its history list. -This defaults to the value of the environment variable -@code{HISTSIZE}, or to 256 if this variable is not set. -@end table - -@cindex history expansion -History expansion assigns special meaning to the character @kbd{!}. -@iftex -(@xref{Event Designators}.) -@end iftex -Since @kbd{!} is also the logical not operator in C, history expansion -is off by default. If you decide to enable history expansion with the -@code{set history expansion on} command, you may sometimes need to -follow @kbd{!} (when it is used as logical not, in an expression) with -a space or a tab to prevent it from being expanded. The readline -history facilities will not attempt substitution on the strings -@kbd{!=} and @kbd{!(}, even when history expansion is enabled. - -The commands to control history expansion are: - -@table @code - -@kindex set history expansion -@item set history expansion on -@itemx set history expansion -Enable history expansion. History expansion is off by default. - -@item set history expansion off -Disable history expansion. - -The readline code comes with more complete documentation of -editing and history expansion features. Users unfamiliar with @code{emacs} -or @code{vi} may wish to read it. -@iftex -@xref{Command Line Editing}. -@end iftex - -@c @group -@kindex show history -@item show history -@itemx show history filename -@itemx show history save -@itemx show history size -@itemx show history expansion -These commands display the state of the _GDBN__ history parameters. -@code{show history} by itself displays all four states. -@c @end group - -@end table - -@table @code -@kindex show commands -@item show commands -Display the last ten commands in the command history. - -@item show commands @var{n} -Print ten commands centered on command number @var{n}. - -@item show commands + -Print ten commands just after the commands last printed. - -@end table - -@node Screen Size, Numbers, History, Controlling _GDBN__ -@section Screen Size -@cindex size of screen -@cindex pauses in output -Certain commands to _GDBN__ may produce large amounts of information -output to the screen. To help you read all of it, _GDBN__ pauses and -asks you for input at the end of each page of output. Type @key{RET} -when you want to continue the output. _GDBN__ also uses the screen -width setting to determine when to wrap lines of output. Depending on -what is being printed, it tries to break the line at a readable place, -rather than simply letting it overflow onto the following line. - -Normally _GDBN__ knows the size of the screen from the termcap data base -together with the value of the @code{TERM} environment variable and the -@code{stty rows} and @code{stty cols} settings. If this is not correct, -you can override it with the @code{set height} and @code{set -width} commands: - -@table @code -@item set height @var{lpp} -@itemx show height -@itemx set width @var{cpl} -@itemx show width -@kindex set height -@kindex set width -@kindex show width -@kindex show height -These @code{set} commands specify a screen height of @var{lpp} lines and -a screen width of @var{cpl} characters. The associated @code{show} -commands display the current settings. - -If you specify a height of zero lines, _GDBN__ will not pause during output -no matter how long the output is. This is useful if output is to a file -or to an editor buffer. -@end table - -@node Numbers, Messages/Warnings, Screen Size, Controlling _GDBN__ -@section Numbers -@cindex number representation -@cindex entering numbers -You can always enter numbers in octal, decimal, or hexadecimal in _GDBN__ by -the usual conventions: octal numbers begin with @samp{0}, decimal -numbers end with @samp{.}, and hexadecimal numbers begin with @samp{0x}. -Numbers that begin with none of these are, by default, entered in base -10; likewise, the default display for numbers---when no particular -format is specified---is base 10. You can change the default base for -both input and output with the @code{set radix} command. - -@table @code -@kindex set radix -@item set radix @var{base} -Set the default base for numeric input and display. Supported choices -for @var{base} are decimal 2, 8, 10, 16. @var{base} must itself be -specified either unambiguously or using the current default radix; for -example, any of - -@example -set radix 1010 -set radix 012 -set radix 10. -set radix 0xa -@end example - -@noindent -will set the base to decimal. On the other hand, @samp{set radix 10} -will leave the radix unchanged no matter what it was. - -@kindex show radix -@item show radix -Display the current default base for numeric input and display. - -@end table - -@node Messages/Warnings, , Numbers, Controlling _GDBN__ -@section Optional Warnings and Messages -By default, _GDBN__ is silent about its inner workings. If you are running -on a slow machine, you may want to use the @code{set verbose} command. -It will make _GDBN__ tell you when it does a lengthy internal operation, so -you won't think it has crashed. - -Currently, the messages controlled by @code{set verbose} are those which -announce that the symbol table for a source file is being read -(@pxref{Files}, in the description of the command -@code{symbol-file}). -@c The following is the right way to do it, but emacs 18.55 doesn't support -@c @ref, and neither the emacs lisp manual version of texinfmt or makeinfo -@c is released. -@ignore -see @code{symbol-file} in @ref{Files}). -@end ignore - -@table @code -@kindex set verbose -@item set verbose on -Enables _GDBN__'s output of certain informational messages. - -@item set verbose off -Disables _GDBN__'s output of certain informational messages. - -@kindex show verbose -@item show verbose -Displays whether @code{set verbose} is on or off. -@end table - -By default, if _GDBN__ encounters bugs in the symbol table of an object -file, it is silent; but if you are debugging a compiler, you may find -this information useful (@pxref{Symbol Errors}). - -@table @code -@kindex set complaints -@item set complaints @var{limit} -Permits _GDBN__ to output @var{limit} complaints about each type of unusual -symbols before becoming silent about the problem. Set @var{limit} to -zero to suppress all complaints; set it to a large number to prevent -complaints from being suppressed. - -@kindex show complaints -@item show complaints -Displays how many symbol complaints _GDBN__ is permitted to produce. -@end table - -By default, _GDBN__ is cautious, and asks what sometimes seem to be a -lot of stupid questions to confirm certain commands. For example, if -you try to run a program which is already running: -@example -(_GDBP__) run -The program being debugged has been started already. -Start it from the beginning? (y or n) -@end example - -If you're willing to unflinchingly face the consequences of your own -commands, you can disable this ``feature'': - -@table @code -@kindex set confirm -@cindex flinching -@cindex confirmation -@cindex stupid questions -@item set confirm off -Disables confirmation requests. - -@item set confirm on -Enables confirmation requests (the default). - -@item show confirm -@kindex show confirm -Displays state of confirmation requests. -@end table - -@c FIXME this doesn't really belong here. But where *does* it belong? -@cindex reloading symbols -Some systems allow individual object files that make up your program to -be replaced without stopping and restarting your program. -_if__(_VXWORKS__) -For example, in VxWorks you can simply recompile a defective object file -and keep on running. -_fi__(_VXWORKS__) -If you're running on one of these systems, you can allow _GDBN__ to -reload the symbols for automatically relinked modules:@refill -@table @code -@kindex set symbol-reloading -@item set symbol-reloading on -Replace symbol definitions for the corresponding source file when an -object file with a particular name is seen again. - -@item set symbol-reloading off -Don't replace symbol definitions when re-encountering object files of -the same name. This is the default state; if you're not running on a -system that permits automatically relinking modules, you should leave -@code{symbol-reloading} off, since otherwise _GDBN__ may discard symbols -when linking large programs, that may contain several modules (from -different directories or libraries) with the same name. - -@item show symbol-reloading -Show the current @code{on} or @code{off} setting. -@end table - -@node Sequences, Emacs, Controlling _GDBN__, Top -@chapter Canned Sequences of Commands - -Aside from breakpoint commands (@pxref{Break Commands}), _GDBN__ provides two -ways to store sequences of commands for execution as a unit: -user-defined commands and command files. - -@menu -* Define:: User-Defined Commands -* Command Files:: Command Files -* Output:: Commands for Controlled Output -@end menu - -@node Define, Command Files, Sequences, Sequences -@section User-Defined Commands - -@cindex user-defined command -A @dfn{user-defined command} is a sequence of _GDBN__ commands to which you -assign a new name as a command. This is done with the @code{define} -command. - -@table @code -@item define @var{commandname} -@kindex define -Define a command named @var{commandname}. If there is already a command -by that name, you are asked to confirm that you want to redefine it. - -The definition of the command is made up of other _GDBN__ command lines, -which are given following the @code{define} command. The end of these -commands is marked by a line containing @code{end}. - -@item document @var{commandname} -@kindex document -Give documentation to the user-defined command @var{commandname}. The -command @var{commandname} must already be defined. This command reads -lines of documentation just as @code{define} reads the lines of the -command definition, ending with @code{end}. After the @code{document} -command is finished, @code{help} on command @var{commandname} will print -the documentation you have specified. - -You may use the @code{document} command again to change the -documentation of a command. Redefining the command with @code{define} -does not change the documentation. - -@item help user-defined -@kindex help user-defined -List all user-defined commands, with the first line of the documentation -(if any) for each. - -@item info user -@itemx info user @var{commandname} -@kindex info user -Display the _GDBN__ commands used to define @var{commandname} (but not its -documentation). If no @var{commandname} is given, display the -definitions for all user-defined commands. -@end table - -User-defined commands do not take arguments. When they are executed, the -commands of the definition are not printed. An error in any command -stops execution of the user-defined command. - -Commands that would ask for confirmation if used interactively proceed -without asking when used inside a user-defined command. Many _GDBN__ commands -that normally print messages to say what they are doing omit the messages -when used in a user-defined command. - -@node Command Files, Output, Define, Sequences -@section Command Files - -@cindex command files -A command file for _GDBN__ is a file of lines that are _GDBN__ commands. Comments -(lines starting with @kbd{#}) may also be included. An empty line in a -command file does nothing; it does not mean to repeat the last command, as -it would from the terminal. - -@cindex init file -@cindex @file{_GDBINIT__} -When you start _GDBN__, it automatically executes commands from its -@dfn{init files}. These are files named @file{_GDBINIT__}. _GDBN__ -reads the init file (if any) in your home directory and then the init -file (if any) in the current working directory. (The init files are not -executed if you use the @samp{-nx} option; @pxref{Mode Options}.) You -can also request the execution of a command file with the @code{source} -command: - -@table @code -@item source @var{filename} -@kindex source -Execute the command file @var{filename}. -@end table - -The lines in a command file are executed sequentially. They are not -printed as they are executed. An error in any command terminates execution -of the command file. - -Commands that would ask for confirmation if used interactively proceed -without asking when used in a command file. Many _GDBN__ commands that -normally print messages to say what they are doing omit the messages -when called from command files. - -@node Output, , Command Files, Sequences -@section Commands for Controlled Output - -During the execution of a command file or a user-defined command, normal -_GDBN__ output is suppressed; the only output that appears is what is -explicitly printed by the commands in the definition. This section -describes three commands useful for generating exactly the output you -want. - -@table @code -@item echo @var{text} -@kindex echo -@c I don't consider backslash-space a standard C escape sequence -@c because it's not in ANSI. -Print @var{text}. Nonprinting characters can be included in @var{text} -using C escape sequences, such as @samp{\n} to print a newline. @b{No -newline will be printed unless you specify one.} In addition to the -standard C escape sequences, a backslash followed by a space stands for a -space. This is useful for outputting a string with spaces at the -beginning or the end, since leading and trailing spaces are otherwise -trimmed from all arguments. Thus, to print @samp{@ and foo =@ }, use the -command @samp{echo \@ and foo = \@ }. -@c FIXME: verify hard copy actually issues enspaces for '@ '! Will this -@c confuse texinfo? - -A backslash at the end of @var{text} can be used, as in C, to continue -the command onto subsequent lines. For example, - -@example -echo This is some text\n\ -which is continued\n\ -onto several lines.\n -@end example - -produces the same output as - -@example -echo This is some text\n -echo which is continued\n -echo onto several lines.\n -@end example - -@item output @var{expression} -@kindex output -Print the value of @var{expression} and nothing but that value: no -newlines, no @samp{$@var{nn} = }. The value is not entered in the -value history either. @xref{Expressions} for more information on -expressions. - -@item output/@var{fmt} @var{expression} -Print the value of @var{expression} in format @var{fmt}. You can use -the same formats as for @code{print}; @pxref{Output formats}, for more -information. - -@item printf @var{string}, @var{expressions}@dots{} -@kindex printf -Print the values of the @var{expressions} under the control of -@var{string}. The @var{expressions} are separated by commas and may -be either numbers or pointers. Their values are printed as specified -by @var{string}, exactly as if the program were to execute - -@example -printf (@var{string}, @var{expressions}@dots{}); -@end example - -For example, you can print two values in hex like this: - -@example -printf "foo, bar-foo = 0x%x, 0x%x\n", foo, bar-foo -@end example - -The only backslash-escape sequences that you can use in the format -string are the simple ones that consist of backslash followed by a -letter. -@end table - -@node Emacs, _GDBN__ Bugs, Sequences, Top -@chapter Using _GDBN__ under GNU Emacs - -@cindex emacs -A special interface allows you to use GNU Emacs to view (and -edit) the source files for the program you are debugging with -_GDBN__. - -To use this interface, use the command @kbd{M-x gdb} in Emacs. Give the -executable file you want to debug as an argument. This command starts -_GDBN__ as a subprocess of Emacs, with input and output through a newly -created Emacs buffer. - -Using _GDBN__ under Emacs is just like using _GDBN__ normally except for two -things: - -@itemize @bullet -@item -All ``terminal'' input and output goes through the Emacs buffer. -@end itemize - -This applies both to _GDBN__ commands and their output, and to the input -and output done by the program you are debugging. - -This is useful because it means that you can copy the text of previous -commands and input them again; you can even use parts of the output -in this way. - -All the facilities of Emacs' Shell mode are available for interacting -with your program. In particular, you can send signals the usual -way---for example, @kbd{C-c C-c} for an interrupt, @kbd{C-c C-z} for a -stop. - -@itemize @bullet -@item -_GDBN__ displays source code through Emacs. -@end itemize - -Each time _GDBN__ displays a stack frame, Emacs automatically finds the -source file for that frame and puts an arrow (_0__@samp{=>}_1__) at the -left margin of the current line. Emacs uses a separate buffer for -source display, and splits the window to show both your _GDBN__ session -and the source. - -Explicit _GDBN__ @code{list} or search commands still produce output as -usual, but you probably will have no reason to use them. - -@quotation -@emph{Warning:} If the directory where your program resides is not your -current directory, it can be easy to confuse Emacs about the location of -the source files, in which case the auxiliary display buffer will not -appear to show your source. _GDBN__ can find programs by searching your -environment's @code{PATH} variable, so the _GDBN__ input and output -session will proceed normally; but Emacs doesn't get enough information -back from _GDBN__ to locate the source files in this situation. To -avoid this problem, either start _GDBN__ mode from the directory where -your program resides, or specify a full path name when prompted for the -@kbd{M-x gdb} argument. - -A similar confusion can result if you use the _GDBN__ @code{file} command to -switch to debugging a program in some other location, from an existing -_GDBN__ buffer in Emacs. -@end quotation - -By default, @kbd{M-x gdb} calls the program called @file{gdb}. If -you need to call _GDBN__ by a different name (for example, if you keep -several configurations around, with different names) you can set the -Emacs variable @code{gdb-command-name}; for example, -@example -(setq gdb-command-name "mygdb") -@end example -@noindent -(preceded by @kbd{ESC ESC}, or typed in the @code{*scratch*} buffer, or -in your @file{.emacs} file) will make Emacs call the program named -``@code{mygdb}'' instead. - -In the _GDBN__ I/O buffer, you can use these special Emacs commands in -addition to the standard Shell mode commands: - -@table @kbd -@item C-h m -Describe the features of Emacs' _GDBN__ Mode. - -@item M-s -Execute to another source line, like the _GDBN__ @code{step} command; also -update the display window to show the current file and location. - -@item M-n -Execute to next source line in this function, skipping all function -calls, like the _GDBN__ @code{next} command. Then update the display window -to show the current file and location. - -@item M-i -Execute one instruction, like the _GDBN__ @code{stepi} command; update -display window accordingly. - -@item M-x gdb-nexti -Execute to next instruction, using the _GDBN__ @code{nexti} command; update -display window accordingly. - -@item C-c C-f -Execute until exit from the selected stack frame, like the _GDBN__ -@code{finish} command. - -@item M-c -Continue execution of the program, like the _GDBN__ @code{continue} -command. @emph{Warning:} In Emacs v19, this command is @kbd{C-c C-p}. - -@item M-u -Go up the number of frames indicated by the numeric argument -(@pxref{Arguments, , Numeric Arguments, emacs, The GNU Emacs Manual}), -like the _GDBN__ @code{up} command. @emph{Warning:} In Emacs v19, this -command is @kbd{C-c C-u}.@refill - -@item M-d -Go down the number of frames indicated by the numeric argument, like the -_GDBN__ @code{down} command. @emph{Warning:} In Emacs v19, this command -is @kbd{C-c C-d}. - -@item C-x & -Read the number where the cursor is positioned, and insert it at the end -of the _GDBN__ I/O buffer. For example, if you wish to disassemble code -around an address that was displayed earlier, type @kbd{disassemble}; -then move the cursor to the address display, and pick up the -argument for @code{disassemble} by typing @kbd{C-x &}. - -You can customize this further on the fly by defining elements of the list -@code{gdb-print-command}; once it is defined, you can format or -otherwise process numbers picked up by @kbd{C-x &} before they are -inserted. A numeric argument to @kbd{C-x &} will both indicate that you -wish special formatting, and act as an index to pick an element of the -list. If the list element is a string, the number to be inserted is -formatted using the Emacs function @code{format}; otherwise the number -is passed as an argument to the corresponding list element. - -@end table - -In any source file, the Emacs command @kbd{C-x SPC} (@code{gdb-break}) -tells _GDBN__ to set a breakpoint on the source line point is on. - -If you accidentally delete the source-display buffer, an easy way to get -it back is to type the command @code{f} in the _GDBN__ buffer, to -request a frame display; when you run under Emacs, this will recreate -the source buffer if necessary to show you the context of the current -frame. - -The source files displayed in Emacs are in ordinary Emacs buffers -which are visiting the source files in the usual way. You can edit -the files with these buffers if you wish; but keep in mind that _GDBN__ -communicates with Emacs in terms of line numbers. If you add or -delete lines from the text, the line numbers that _GDBN__ knows will cease -to correspond properly to the code. - -@c The following dropped because Epoch is nonstandard. Reactivate -@c if/when v19 does something similar. ---pesch@cygnus.com 19dec1990 -@ignore -@kindex emacs epoch environment -@kindex epoch -@kindex inspect - -Version 18 of Emacs has a built-in window system called the @code{epoch} -environment. Users of this environment can use a new command, -@code{inspect} which performs identically to @code{print} except that -each value is printed in its own window. -@end ignore - -@node _GDBN__ Bugs, Renamed Commands, Emacs, Top -@chapter Reporting Bugs in _GDBN__ -@cindex Bugs in _GDBN__ -@cindex Reporting Bugs in _GDBN__ - -Your bug reports play an essential role in making _GDBN__ reliable. - -Reporting a bug may help you by bringing a solution to your problem, or it -may not. But in any case the principal function of a bug report is to help -the entire community by making the next version of _GDBN__ work better. Bug -reports are your contribution to the maintenance of _GDBN__. - -In order for a bug report to serve its purpose, you must include the -information that enables us to fix the bug. - -@menu -* Bug Criteria:: Have You Found a Bug? -* Bug Reporting:: How to Report Bugs -@end menu - -@node Bug Criteria, Bug Reporting, _GDBN__ Bugs, _GDBN__ Bugs -@section Have You Found a Bug? -@cindex Bug Criteria - -If you are not sure whether you have found a bug, here are some guidelines: - -@itemize @bullet -@item -@cindex Fatal Signal -@cindex Core Dump -If the debugger gets a fatal signal, for any input whatever, that is a -_GDBN__ bug. Reliable debuggers never crash. - -@item -@cindex error on Valid Input -If _GDBN__ produces an error message for valid input, that is a bug. - -@item -@cindex Invalid Input -If _GDBN__ does not produce an error message for invalid input, -that is a bug. However, you should note that your idea of -``invalid input'' might be our idea of ``an extension'' or ``support -for traditional practice''. - -@item -If you are an experienced user of debugging tools, your suggestions -for improvement of _GDBN__ are welcome in any case. -@end itemize - -@node Bug Reporting, , Bug Criteria, _GDBN__ Bugs -@section How to Report Bugs -@cindex Bug Reports -@cindex _GDBN__ Bugs, Reporting - -A number of companies and individuals offer support for GNU products. -If you obtained _GDBN__ from a support organization, we recommend you -contact that organization first. - -Contact information for many support companies and individuals is -available in the file @file{etc/SERVICE} in the GNU Emacs distribution. - -In any event, we also recommend that you send bug reports for _GDBN__ to one -of these addresses: - -@example -bug-gdb@@prep.ai.mit.edu -@{ucbvax|mit-eddie|uunet@}!prep.ai.mit.edu!bug-gdb -@end example - -@strong{Do not send bug reports to @samp{info-gdb}, or to -@samp{help-gdb}, or to any newsgroups.} Most users of _GDBN__ do not want to -receive bug reports. Those that do, have arranged to receive @samp{bug-gdb}. - -The mailing list @samp{bug-gdb} has a newsgroup @samp{gnu.gdb.bug} which -serves as a repeater. The mailing list and the newsgroup carry exactly -the same messages. Often people think of posting bug reports to the -newsgroup instead of mailing them. This appears to work, but it has one -problem which can be crucial: a newsgroup posting often lacks a mail -path back to the sender. Thus, if we need to ask for more information, -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 -GNU Debugger Bugs -Free Software Foundation -545 Tech Square -Cambridge, MA 02139 -@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! - -Often people omit facts because they think they know what causes the -problem and assume that some details don't matter. Thus, you might -assume that the name of the variable you use in an example does not matter. -Well, probably it doesn't, but one cannot be sure. Perhaps the bug is a -stray memory reference which happens to fetch from the location where that -name is stored in memory; perhaps, if the name were different, the contents -of that location would fool the debugger into doing the right thing despite -the bug. Play it safe and give a specific, complete example. That is the -easiest thing for you to do, and the most helpful. - -Keep in mind that the purpose of a bug report is to enable us to fix -the bug if it is new to us. It isn't as important what happens if -the bug is already known. Therefore, always write your bug reports on -the assumption that the bug has not been reported previously. - -Sometimes people give a few sketchy facts and ask, ``Does this ring a -bell?'' Those bug reports are useless, and we urge everyone to -@emph{refuse to respond to them} except to chide the sender to report -bugs properly. - -To enable us to fix the bug, you should include all these things: - -@itemize @bullet -@item -The version of _GDBN__. _GDBN__ announces it if you start with no -arguments; you can also print it at any time using @code{show version}. - -Without this, we won't know whether there is any point in looking for -the bug in the current version of _GDBN__. - -@item -A complete input script, and all necessary source files, that will -reproduce the bug. - -@item -What compiler (and its version) was used to compile _GDBN__---e.g. -``_GCC__-1.37.1''. - -@item -The command arguments you gave the compiler to compile your example and -observe the bug. For example, did you use @samp{-O}? To guarantee -you won't omit something important, list them all. - -If we were to try to guess the arguments, we would probably guess wrong -and then we might not encounter the bug. - -@item -The type of machine you are using, and the operating system name and -version number. - -@item -A description of what behavior you observe that you believe is -incorrect. For example, ``It gets a fatal signal.'' - -Of course, if the bug is that _GDBN__ gets a fatal signal, then we will -certainly notice it. But if the bug is incorrect output, we might not -notice unless it is glaringly wrong. We are human, after all. You -might as well not give us a chance to make a mistake. - -Even if the problem you experience is a fatal signal, you should still -say so explicitly. Suppose something strange is going on, such as, -your copy of _GDBN__ is out of synch, or you have encountered a -bug in the C library on your system. (This has happened!) Your copy -might crash and ours would not. If you told us to expect a crash, -then when ours fails to crash, we would know that the bug was not -happening for us. If you had not told us to expect a crash, then we -would not be able to draw any conclusion from our observations. - -@item -If you wish to suggest changes to the _GDBN__ source, send us context -diffs. If you even discuss something in the _GDBN__ source, refer to -it by context, not by line number. - -The line numbers in our development sources won't match those in your -sources. Your line numbers would convey no useful information to us. - -@end itemize - -Here are some things that are not necessary: - -@itemize @bullet -@item -A description of the envelope of the bug. - -Often people who encounter a bug spend a lot of time investigating -which changes to the input file will make the bug go away and which -changes will not affect it. - -This is often time consuming and not very useful, because the way we -will find the bug is by running a single example under the debugger -with breakpoints, not by pure deduction from a series of examples. -We recommend that you save your time for something else. - -Of course, if you can find a simpler example to report @emph{instead} -of the original one, that is a convenience for us. Errors in the -output will be easier to spot, running under the debugger will take -less time, etc. - -However, simplification is not vital; if you don't want to do this, -report the bug anyway and send us the entire test case you used. - -@item -A patch for the bug. - -A patch for the bug does help us if it is a good one. But don't omit -the necessary information, such as the test case, on the assumption that -a patch is all we need. We might see problems with your patch and decide -to fix the problem another way, or we might not understand it at all. - -Sometimes with a program as complicated as _GDBN__ it is very hard to -construct an example that will make the program follow a certain path -through the code. If you don't send us the example, we won't be able -to construct one, so we won't be able to verify that the bug is fixed. - -And if we can't understand what bug you are trying to fix, or why your -patch should be an improvement, we won't install it. A test case will -help us to understand. - -@item -A guess about what the bug is or what it depends on. - -Such guesses are usually wrong. Even we can't guess right about such -things without first using the debugger to find the facts. -@end itemize - -@iftex -@include rdl-apps.texi -@end iftex - -@node Renamed Commands, Installing _GDBN__, _GDBN__ Bugs, Top -@appendix Renamed Commands - -The following commands were renamed in _GDBN__ 4.0, in order to make the -command set as a whole more consistent and easier to use and remember: - -@kindex add-syms -@kindex delete environment -@kindex info copying -@kindex info convenience -@kindex info directories -@kindex info editing -@kindex info history -@kindex info targets -@kindex info values -@kindex info version -@kindex info warranty -@kindex set addressprint -@kindex set arrayprint -@kindex set prettyprint -@kindex set screen-height -@kindex set screen-width -@kindex set unionprint -@kindex set vtblprint -@kindex set demangle -@kindex set asm-demangle -@kindex set sevenbit-strings -@kindex set array-max -@kindex set caution -@kindex set history write -@kindex show addressprint -@kindex show arrayprint -@kindex show prettyprint -@kindex show screen-height -@kindex show screen-width -@kindex show unionprint -@kindex show vtblprint -@kindex show demangle -@kindex show asm-demangle -@kindex show sevenbit-strings -@kindex show array-max -@kindex show caution -@kindex show history write -@kindex unset - -@ifinfo -@example -OLD COMMAND NEW COMMAND ---------------- ------------------------------- -add-syms add-symbol-file -delete environment unset environment -info convenience show convenience -info copying show copying -info directories show directories -info editing show commands -info history show values -info targets help target -info values show values -info version show version -info warranty show warranty -set/show addressprint set/show print address -set/show array-max set/show print elements -set/show arrayprint set/show print array -set/show asm-demangle set/show print asm-demangle -set/show caution set/show confirm -set/show demangle set/show print demangle -set/show history write set/show history save -set/show prettyprint set/show print pretty -set/show screen-height set/show height -set/show screen-width set/show width -set/show sevenbit-strings set/show print sevenbit-strings -set/show unionprint set/show print union -set/show vtblprint set/show print vtbl - -unset [No longer an alias for delete] -@end example -@end ifinfo - -@tex -\vskip \parskip\vskip \baselineskip -\halign{\tt #\hfil &\qquad#&\tt #\hfil\cr -{\bf Old Command} &&{\bf New Command}\cr -add-syms &&add-symbol-file\cr -delete environment &&unset environment\cr -info convenience &&show convenience\cr -info copying &&show copying\cr -info directories &&show directories \cr -info editing &&show commands\cr -info history &&show values\cr -info targets &&help target\cr -info values &&show values\cr -info version &&show version\cr -info warranty &&show warranty\cr -set{\rm / }show addressprint &&set{\rm / }show print address\cr -set{\rm / }show array-max &&set{\rm / }show print elements\cr -set{\rm / }show arrayprint &&set{\rm / }show print array\cr -set{\rm / }show asm-demangle &&set{\rm / }show print asm-demangle\cr -set{\rm / }show caution &&set{\rm / }show confirm\cr -set{\rm / }show demangle &&set{\rm / }show print demangle\cr -set{\rm / }show history write &&set{\rm / }show history save\cr -set{\rm / }show prettyprint &&set{\rm / }show print pretty\cr -set{\rm / }show screen-height &&set{\rm / }show height\cr -set{\rm / }show screen-width &&set{\rm / }show width\cr -set{\rm / }show sevenbit-strings &&set{\rm / }show print sevenbit-strings\cr -set{\rm / }show unionprint &&set{\rm / }show print union\cr -set{\rm / }show vtblprint &&set{\rm / }show print vtbl\cr -\cr -unset &&\rm(No longer an alias for delete)\cr -} -@end tex - -@node Installing _GDBN__, Copying, Renamed Commands, Top -@appendix Installing _GDBN__ -@cindex configuring _GDBN__ -@cindex installation - -_GDBN__ comes with a @code{configure} script that automates the process -of preparing _GDBN__ for installation; you can then use @code{make} to -build the @code{_GDBP__} program. - -The _GDBP__ distribution includes all the source code you need for -_GDBP__ in a single directory @file{gdb-_GDB_VN__}. That directory in turn -contains: - -@table @code -@item gdb-_GDB_VN__/configure -Overall script for configuring _GDBN__ and all its supporting libraries. - -@item gdb-_GDB_VN__/gdb -the source specific to _GDBN__ itself - -@item gdb-_GDB_VN__/bfd -source for the Binary File Descriptor Library - -@item gdb-_GDB_VN__/include -GNU include files - -@item gdb-_GDB_VN__/libiberty -source for the @samp{-liberty} free software library - -@item gdb-_GDB_VN__/readline -source for the GNU command-line interface -@end table -@noindent -Each of these directories has its own @code{configure} script, which are -used by the overall @code{configure} script in @file{gdb-_GDB_VN__}. - -It is most convenient to run @code{configure} from the @file{gdb-_GDB_VN__} -directory. The simplest way to configure and build _GDBN__ is the -following: -@example -cd gdb-_GDB_VN__ -./configure @var{host} -make -@end example -@noindent -where @var{host} is something like @samp{sun4} or @samp{decstation}, that -identifies the platform where _GDBN__ will run. This builds the three -libraries @file{bfd}, @file{readline}, and @file{libiberty}, then -@code{gdb} itself. The configured source files, and the binaries, are -left in the corresponding source directories. - -You can install @code{_GDBP__} anywhere; it has no hardwired paths. However, -you should make sure that the shell on your path (named by the -@samp{SHELL} environment variable) is publicly readable; some systems -refuse to let _GDBN__ debug child processes whose programs are not -readable, and _GDBN__ uses the shell to start your program. - -@menu -* Subdirectories:: Configuration subdirectories -* Config Names:: Specifying names for hosts and targets -* configure Options:: Summary of options for configure -* Formatting Documentation:: How to format and print _GDBN__ documentation -@end menu - - -@node Subdirectories, Config Names, Installing _GDBN__, Installing _GDBN__ -@section Configuration Subdirectories -If you want to run _GDBN__ versions for several host or target machines, -you'll need a different _GDBP__ compiled for each combination of host -and target. @code{configure} is designed to make this easy by allowing -you to generate each configuration in a separate subdirectory. If your -@code{make} program handles the @samp{VPATH} feature (GNU @code{make} -does), running @code{make} in each of these directories then builds the -_GDBP__ program specified there. - -@code{configure} creates these subdirectories for you when you -simultaneously specify several configurations; but it's a good habit -even for a single configuration. You can specify the use of -subdirectories using the @samp{+subdirs} option (abbreviated -@samp{+sub}). For example, you can build _GDBN__ on a Sun 4 as follows: - -@example -@group -cd gdb-_GDB_VN__ -./configure +sub sun4 -cd Host-sparc-sun-sunos4/Target-sparc-sun-sunos4 -make -@end group -@end example - -When @code{configure} uses subdirectories to build programs or -libraries, it creates nested directories -@file{Host-@var{host}/Target-@var{target}}. (As you see in the example, -the names used for @var{host} and @var{target} may be expanded from your -@code{configure} argument; @pxref{Config Names}). @code{configure} uses -these two directory levels because _GDBN__ can be configured for -cross-compiling: _GDBN__ can run on one machine (the host) while -debugging programs that run on another machine (the target). You -specify cross-debugging targets by giving the -@samp{+target=@var{target}} option to @code{configure}. Specifying only -hosts still gives you two levels of subdirectory for each host, with the -same configuration suffix on both; that is, if you give any number of -hosts but no targets, _GDBN__ will be configured for native debugging on -each host. On the other hand, whenever you specify both hosts and -targets on the same command line, @code{configure} creates all -combinations of the hosts and targets you list.@refill - -When you run @code{make} to build a program or library, you must run it -in a configured directory. If you made a single configuration, -without subdirectories, run @code{make} in the source directory. -If you have @file{Host-@var{host}/Target-@var{target}} subdirectories, -run @code{make} in those subdirectories. - -Each @code{configure} and @code{Makefile} under each source directory -runs recursively, so that typing @code{make} in @file{gdb-_GDB_VN__} (or in a -@file{gdb-_GDB_VN__/Host-@var{host}/Target-@var{target}} subdirectory) -builds all the required libraries, then _GDBN__.@refill - -If you run @code{configure} from a directory (such as @file{gdb-_GDB_VN__}) that -contains source directories for multiple libraries or programs, -@code{configure} creates the @file{Host-@var{host}/Target-@var{target}} -subdirectories in each library or program's source directory. For -example, typing: -@example -cd gdb-_GDB_VN__ -configure sun4 +target=vxworks960 -@end example -@noindent -creates the following directories: -@smallexample -gdb-_GDB_VN__/Host-sparc-sun-sunos4/Target-i960-wrs-vxworks -gdb-_GDB_VN__/bfd/Host-sparc-sun-sunos4/Target-i960-wrs-vxworks -gdb-_GDB_VN__/gdb/Host-sparc-sun-sunos4/Target-i960-wrs-vxworks -gdb-_GDB_VN__/libiberty/Host-sparc-sun-sunos4/Target-i960-wrs-vxworks -gdb-_GDB_VN__/readline/Host-sparc-sun-sunos4/Target-i960-wrs-vxworks -@end smallexample -@noindent -The @code{Makefile} in -@smallexample -gdb-_GDB_VN__/Host-sparc-sun-sunos4/Target-i960-wrs-vxworks -@end smallexample -@noindent -will @code{cd} to the appropriate lower-level directories, for example: -@smallexample -gdb-_GDB_VN__/bfd/Host-sparc-sun-sunos4/Target-i960-wrs-vxworks -@end smallexample -@noindent -building each in turn. - -When you have multiple hosts or targets configured, you can run -@code{make} on them in parallel (for example, if they are NFS-mounted on -each of the hosts); they will not interfere with each other. - - -@iftex -@c FIXME isn't there something kinder, gentler than @page? -@page -@end iftex -@node Config Names, configure Options, Subdirectories, Installing _GDBN__ -@section Specifying Names for Hosts and Targets - -The specifications used for hosts and targets in the @code{configure} -script are based on a three-part naming scheme, but some short predefined -aliases are also supported. The full naming scheme encodes three pieces -of information in the following pattern: -@example -@var{architecture}-@var{vendor}-@var{os} -@end example - -For example, you can use the alias @code{sun4} as a @var{host} argument -or in a @code{+target=@var{target}} option, but the full name of that -configuration specifies that the architecture is @samp{sparc}, the -vendor is @samp{sun}, and the operating system is @samp{sunos4}. - -@iftex -@c I know this is ugly, but @group is useless except in examples now... -@c (using texinfo 2.52 or so) -@page -@end iftex - -The following table shows all the architectures, hosts, and OS prefixes -that @code{configure} recognizes in _GDBN__ _GDB_VN__. Entries in the ``OS -prefix'' column ending in a @samp{*} may be followed by a release number. - -@ifinfo -@example - -ARCHITECTURE VENDOR OS prefix -------------+-------------+------------- - | | - 580 | altos | aix* - a29k | amdahl | amigados - alliant | aout | aout - arm | apollo | bout - c1 | att | bsd* - c2 | bull | coff - cray2 | bcs | ctix* - h8300 | bout | dynix* - i386 | cbm | esix* - i860 | coff | hpux* - i960 | convergent | irix* - m68000 | convex | isc* - m68k | cray | kern - m88k | dec | mach* - mips | encore | newsos* - ns32k | gould | nindy* - pyramid | hp | none - romp | ibm | osf* - rs6000 | intel | sco* - rtpc | isi | sunos* - sparc | little | svr4 - tahoe | mips | sym* - tron | motorola | sysv* - vax | ncr | ultrix* - xmp | next | unicos - ymp | none | unos* - | nyu | uts - | sco | v88r* - | sequent | vms* - | sgi | vxworks* - | sony | - | sun | - | unicom | - | utek | - | wrs | - -@end example -@quotation -@emph{Warning:} Many combinations of architecture, vendor, and OS are -untested. -@end quotation -@end ifinfo -@c FIXME: this table is probably screwed in @smallbook. Try setting -@c FIXME...smallbook fonts? -@tex -%\vskip\parskip -\vskip \baselineskip -\halign{\hskip\parindent\tt #\hfil &\qquad#&\tt #\hfil &\qquad#&\tt -#\hfil &\qquad\qquad\it #\hfil\cr -{\bf Architecture} &&{\bf Vendor} &&{\bf OS prefix}\cr -\multispan5\hrulefill\cr - 580 && altos && aix* \cr - a29k && amdahl && amigados\cr - alliant && aout && aout \cr - arm && apollo && bout \cr - c1 && att && bsd* \cr - c2 && bull && coff \cr - cray2 && bcs && ctix* \cr - h8300 && bout && dynix* \cr - i386 && cbm && esix* \cr - i860 && coff && hpux* &Warning: \cr - i960 && convergent && irix* &Many combinations \cr - m68000 && convex && isc* &of architecture, vendor \cr - m68k && cray && kern &and OS are untested. \cr - m88k && dec && mach* \cr - mips && encore && newsos* \cr - ns32k && gould && nindy* \cr - pyramid && hp && none \cr - romp && ibm && osf* \cr - rs6000 && intel && sco* \cr - rtpc && isi && sunos* \cr - sparc && little && svr4 \cr - tahoe && mips && sym* \cr - tron && motorola && sysv* \cr - vax && ncr && ultrix* \cr - xmp && next && unicos \cr - ymp && none && unos* \cr - && nyu && uts \cr - && sco && v88r* \cr - && sequent && vms* \cr - && sgi && vxworks*\cr - && sony &&\cr - && sun &&\cr - && unicom &&\cr - && utek &&\cr - && wrs &&\cr -} -@end tex - -The @code{configure} script accompanying _GDBN__ _GDB_VN__ does not provide -any query facility to list all supported host and target names or -aliases. @code{configure} calls the Bourne shell script -@code{config.sub} to map abbreviations to full names; you can read the -script, if you wish, or you can use it to test your guesses on -abbreviations---for example: -@example -% sh config.sub sun4 -sparc-sun-sunos4 -% sh config.sub sun3 -m68k-sun-sunos4 -% sh config.sub decstation -mips-dec-ultrix -% sh config.sub hp300bsd -m68k-hp-bsd -% sh config.sub i386v -i386-none-sysv -% sh config.sub i486v -*** No vendor: configuration `i486v' not recognized -@end example - -@node configure Options, Formatting Documentation, Config Names, Installing _GDBN__ -@section @code{configure} Options - -Here is a summary of all the @code{configure} options and arguments that -you might use for building _GDBN__: - -@example -configure @r{[}+destdir=@var{dir}@r{]} @r{[}+subdirs@r{]} @r{[}+norecur@r{]} @r{[}+rm@r{]} - @r{[}+target=@var{target}@dots{}@r{]} @var{host}@dots{} -@end example -@noindent -You may introduce options with the character @samp{-} rather than -@samp{+} if you prefer; but you may abbreviate option names if you use -@samp{+}. - -@table @code -@item +destdir=@var{dir} -@var{dir} is an installation directory @emph{path prefix}. After you -configure with this option, @code{make install} will install _GDBN__ as -@file{@var{dir}/bin/_GDBP__}, and the libraries in @file{@var{dir}/lib}. -If you specify @samp{+destdir=/usr/local}, for example, @code{make -install} creates @file{/usr/local/bin/gdb}.@refill - -@item +subdirs -Write configuration specific files in subdirectories of the form -@example -Host-@var{host}/Target-@var{target} -@end example -@noindent -(and configure the @code{Makefile} to write binaries there too). -Without this option, if you specify only one configuration for _GDBN__, -@code{configure} will use the same directory for source, configured -files, and binaries. This option is used automatically if you specify -more than one @var{host} or more than one @samp{+target=@var{target}} -option on the @code{configure} command line. - -@item +norecur -Configure only the directory where @code{configure} is executed; do not -propagate configuration to subdirectories. - -@item +rm -Remove the configuration that the other arguments specify. - -@c This doesn't work (yet if ever). FIXME. -@c @item +parse=@var{lang} @dots{} -@c Configure the _GDBN__ expression parser to parse the listed languages. -@c @samp{all} configures _GDBN__ for all supported languages. To get a -@c list of all supported languages, omit the argument. Without this -@c option, _GDBN__ is configured to parse all supported languages. - -@item +target=@var{target} @dots{} -Configure _GDBN__ for cross-debugging programs running on each specified -@var{target}. You may specify as many @samp{+target} options as you -wish. Without this option, _GDBN__ is configured to debug programs that -run on the same machine (@var{host}) as _GDBN__ itself. - -There is no convenient way to generate a list of all available targets. - -@item @var{host} @dots{} -Configure _GDBN__ to run on each specified @var{host}. You may specify as -many host names as you wish. - -There is no convenient way to generate a list of all available hosts. -@end table - -@noindent -@code{configure} accepts other options, for compatibility with -configuring other GNU tools recursively; but these are the only -options that affect _GDBN__ or its supporting libraries. - -@node Formatting Documentation, , configure Options, Installing _GDBN__ -@section Formatting the Documentation - -@cindex _GDBN__ reference card -@cindex reference card -The _GDBN__ _GDB_VN__ release includes an already-formatted reference card, -ready for printing on a PostScript printer, as @file{gdb-_GDB_VN__/gdb/refcard.ps}. -It uses the most common PostScript fonts: the Times family, Courier, and -Symbol. If you have a PostScript printer, you can print the reference -card by just sending @file{refcard.ps} to the printer. - -The release also includes the online Info version of this manual already -formatted: the main Info file is @file{gdb-_GDB_VN__/gdb/gdb.info}, and it -refers to subordinate files matching @samp{gdb.info*} in the same -directory. - -If you want to make these Info files yourself from the _GDBN__ manual's -source, you need the GNU @code{makeinfo} program. Once you have it, you -can type -@example -cd gdb-_GDB_VN__/gdb -make gdb.info -@end example -@noindent -to make the Info file. - -If you want to format and print copies of the manual, you need several -things: -@itemize @bullet -@item -@TeX{}, the public domain typesetting program written by Donald Knuth, -must be installed on your system and available through your execution -path. -@item -@file{gdb-_GDB_VN__/texinfo}: @TeX{} macros defining the GNU -Documentation Format. -@item -@emph{A @sc{dvi} output program.} @TeX{} doesn't actually make marks on -paper; it produces output files called @sc{dvi} files. If your system -has @TeX{} installed, chances are it has a program for printing out -these files; one popular example is @code{dvips}, which can print -@sc{dvi} files on PostScript printers. -@end itemize -@noindent -Once you have these things, you can type -@example -cd gdb-_GDB_VN__/gdb -make gdb.dvi -@end example -@noindent -to format the text of this manual, and print it with the usual output -method for @TeX{} @sc{dvi} files at your site. - -If you want to print the reference card, but don't have a PostScript -printer, or you want to use Computer Modern fonts instead, -you can still print it if you have @TeX{}. Format the reference card by typing -@example -cd gdb-_GDB_VN__/gdb -make refcard.dvi -@end example -@noindent - -The _GDBN__ reference card is designed to print in landscape mode on US -``letter'' size paper; that is, on a sheet 11 inches wide by 8.5 inches -high. You will need to specify this form of printing as an option to -your @sc{dvi} output program. - - -@node Copying, Index, Installing _GDBN__, Top -@unnumbered GNU GENERAL PUBLIC LICENSE -@center Version 2, June 1991 - -@display -Copyright @copyright{} 1989, 1991 Free Software Foundation, Inc. -675 Mass Ave, Cambridge, MA 02139, USA - -Everyone is permitted to copy and distribute verbatim copies -of this license document, but changing it is not allowed. -@end display - -@unnumberedsec Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software---to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - -@iftex -@unnumberedsec TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION -@end iftex -@ifinfo -@center TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION -@end ifinfo - -@enumerate -@item -This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The ``Program'', below, -refers to any such program or work, and a ``work based on the Program'' -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term ``modification''.) Each licensee is addressed as ``you''. - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - -@item -You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - -@item -You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - -@alphaenumerate -@item -You must cause the modified files to carry prominent notices -stating that you changed the files and the date of any change. - -@item -You must cause any work that you distribute or publish, that in -whole or in part contains or is derived from the Program or any -part thereof, to be licensed as a whole at no charge to all third -parties under the terms of this License. - -@item -If the modified program normally reads commands interactively -when run, you must cause it, when started running for such -interactive use in the most ordinary way, to print or display an -announcement including an appropriate copyright notice and a -notice that there is no warranty (or else, saying that you provide -a warranty) and that users may redistribute the program under -these conditions, and telling the user how to view a copy of this -License. (Exception: if the Program itself is interactive but -does not normally print such an announcement, your work based on -the Program is not required to print an announcement.) -@end alphaenumerate - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - -@item -You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - -@alphaenumerate -@item -Accompany it with the complete corresponding machine-readable -source code, which must be distributed under the terms of Sections -1 and 2 above on a medium customarily used for software interchange; or, - -@item -Accompany it with a written offer, valid for at least three -years, to give any third party, for a charge no more than your -cost of physically performing source distribution, a complete -machine-readable copy of the corresponding source code, to be -distributed under the terms of Sections 1 and 2 above on a medium -customarily used for software interchange; or, - -@item -Accompany it with the information you received as to the offer -to distribute corresponding source code. (This alternative is -allowed only for noncommercial distribution and only if you -received the program in object code or executable form with such -an offer, in accord with Subsection b above.) -@end alphaenumerate - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - -@item -You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - -@item -You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - -@item -Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - -@item -If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - -@item -If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - -@item -The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and ``any -later version'', you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - -@item -If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - -@iftex -@heading NO WARRANTY -@end iftex -@ifinfo -@center NO WARRANTY -@end ifinfo - -@item -BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM ``AS IS'' WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - -@item -IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. -@end enumerate - -@iftex -@heading END OF TERMS AND CONDITIONS -@end iftex -@ifinfo -@center END OF TERMS AND CONDITIONS -@end ifinfo - -@page -@unnumberedsec Applying These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the ``copyright'' line and a pointer to where the full notice is found. - -@smallexample -@var{one line to give the program's name and a brief idea of what it does.} -Copyright (C) 19@var{yy} @var{name of author} - -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., 675 Mass Ave, Cambridge, MA 02139, USA. -@end smallexample - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - -@smallexample -Gnomovision version 69, Copyright (C) 19@var{yy} @var{name of author} -Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. -This is free software, and you are welcome to redistribute it -under certain conditions; type `show c' for details. -@end smallexample - -The hypothetical commands @samp{show w} and @samp{show c} should show -the appropriate parts of the General Public License. Of course, the -commands you use may be called something other than @samp{show w} and -@samp{show c}; they could even be mouse-clicks or menu items---whatever -suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a ``copyright disclaimer'' for the program, if -necessary. Here is a sample; alter the names: - -@example -Yoyodyne, Inc., hereby disclaims all copyright interest in the program -`Gnomovision' (which makes passes at compilers) written by James Hacker. - -@var{signature of Ty Coon}, 1 April 1989 -Ty Coon, President of Vice -@end example - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. - - -@node Index, , Copying, Top -@unnumbered Index - -@printindex cp - -@tex -% I think something like @colophon should be in texinfo. In the -% meantime: -\long\def\colophon{\hbox to0pt{}\vfill -\centerline{The body of this manual is set in} -\centerline{\fontname\tenrm,} -\centerline{with headings in {\bf\fontname\tenbf}} -\centerline{and examples in {\tt\fontname\tentt}.} -\centerline{{\it\fontname\tenit\/} and} -\centerline{{\sl\fontname\tensl\/}} -\centerline{are used for emphasis.}\vfill} -\page\colophon -% Blame: pesch@cygnus.com, 28mar91. -@end tex - -@contents -@bye diff --git a/gdb/doc/interim-gdbinv-m.m4 b/gdb/doc/interim-gdbinv-m.m4 deleted file mode 100755 index 8fe5f91c909..00000000000 --- a/gdb/doc/interim-gdbinv-m.m4 +++ /dev/null @@ -1,13 +0,0 @@ -_dnl__ -*- Texinfo -*- -_dnl__ Copyright (c) 1991 Free Software Foundation, Inc. -_dnl__ This file is part of the source for the GDB manual. -_dnl__ M4 FRAGMENT: $Id$ -_if__(_I960__) -* i960-Nindy Remote:: _GDBN__ with a Remote i960 (Nindy) -_fi__(_I960__) -_if__(_AMD29K__) -* EB29K Remote:: _GDBN__ with a Remote EB29K -_fi__(_AMD29K__) -_if__(_VXWORKS__) -* VxWorks Remote:: _GDBN__ and VxWorks -_fi__(_VXWORKS__) diff --git a/gdb/doc/interim-gdbinv-s.m4 b/gdb/doc/interim-gdbinv-s.m4 deleted file mode 100755 index 82de97a9bff..00000000000 --- a/gdb/doc/interim-gdbinv-s.m4 +++ /dev/null @@ -1,427 +0,0 @@ -_dnl__ -*- Texinfo -*- -_dnl__ Copyright (c) 1990 1991 Free Software Foundation, Inc. -_dnl__ This file is part of the source for the GDB manual. -@c M4 FRAGMENT $Id$ -@c This text diverted to "Remote Debugging" section in general case; -@c however, if we're doing a manual specifically for one of these, it -@c belongs up front (in "Getting In and Out" chapter). -_if__(_I960__) -_if__(!_GENERIC__) -@node i960-Nindy Remote, EB29K Remote, Mode Options, Starting _GDBN__ -_fi__(!_GENERIC__) -_if__(_GENERIC__) -@node i960-Nindy Remote, EB29K Remote, Remote, Remote -_fi__(_GENERIC__) -@subsection _GDBN__ with a Remote i960 (Nindy) - -@cindex Nindy -@cindex i960 -@dfn{Nindy} is a ROM Monitor program for Intel 960 target systems. When -_GDBN__ is configured to control a remote Intel 960 using Nindy, you can -tell _GDBN__ how to connect to the 960 in several ways: - -@itemize @bullet -@item -Through command line options specifying serial port, version of the -Nindy protocol, and communications speed; - -@item -By responding to a prompt on startup; - -@item -By using the @code{target} command at any point during your _GDBN__ -session. @xref{Target Commands}. - -@end itemize - -@menu -* Nindy Startup:: Startup with Nindy -* Nindy Options:: Options for Nindy -* Nindy reset:: Nindy Reset Command -@end menu - -@node Nindy Startup, Nindy Options, i960-Nindy Remote, i960-Nindy Remote -@subsubsection Startup with Nindy - -If you simply start @code{_GDBN__} without using any command-line -options, you are prompted for what serial port to use, @emph{before} you -reach the ordinary _GDBN__ prompt: -@example -Attach /dev/ttyNN -- specify NN, or "quit" to quit: -@end example -@noindent -Respond to the prompt with whatever suffix (after @samp{/dev/tty}) -identifies the serial port you want to use. You can, if you choose, -simply start up with no Nindy connection by responding to the prompt -with an empty line. If you do this, and later wish to attach to Nindy, -use @code{target} (@pxref{Target Commands}). - -@node Nindy Options, Nindy reset, Nindy Startup, i960-Nindy Remote -@subsubsection Options for Nindy - -These are the startup options for beginning your _GDBN__ session with a -Nindy-960 board attached: - -@table @code -@item -r @var{port} -Specify the serial port name of a serial interface to be used to connect -to the target system. This option is only available when _GDBN__ is -configured for the Intel 960 target architecture. You may specify -@var{port} as any of: a full pathname (e.g. @samp{-r /dev/ttya}), a -device name in @file{/dev} (e.g. @samp{-r ttya}), or simply the unique -suffix for a specific @code{tty} (e.g. @samp{-r a}). - -@item -O -(An uppercase letter ``O'', not a zero.) Specify that _GDBN__ should use -the ``old'' Nindy monitor protocol to connect to the target system. -This option is only available when _GDBN__ is configured for the Intel 960 -target architecture. - -@quotation -@emph{Warning:} if you specify @samp{-O}, but are actually trying to -connect to a target system that expects the newer protocol, the connection -will fail, appearing to be a speed mismatch. _GDBN__ will repeatedly -attempt to reconnect at several different line speeds. You can abort -this process with an interrupt. -@end quotation - -@item -brk -Specify that _GDBN__ should first send a @code{BREAK} signal to the target -system, in an attempt to reset it, before connecting to a Nindy target. - -@quotation -@emph{Warning:} Many target systems do not have the hardware that this -requires; it only works with a few boards. -@end quotation - -@end table - -The standard @samp{-b} option controls the line speed used on the serial -port. - -@node Nindy reset, , Nindy Options, i960-Nindy Remote -@c @group -@subsubsection Nindy Reset Command -@table @code -@item reset -@kindex reset -For a Nindy target, this command sends a ``break'' to the remote target -system; this is only useful if the target has been equipped with a -circuit to perform a hard reset (or some other interesting action) when -a break is detected. -@end table -@c @end group -_fi__(_I960__) - -_if__(_AMD29K__) -_if__(!_GENERIC__) -@node EB29K Remote, VxWorks Remote, i960-Nindy Remote, Starting _GDBN__ -_fi__(!_GENERIC__) -_if__(_GENERIC__) -@node EB29K Remote, VxWorks Remote, i960-Nindy Remote, Remote -_fi__(_GENERIC__) -@subsection _GDBN__ with a Remote EB29K - -@cindex EB29K board -@cindex running 29K programs - -To use _GDBN__ from a Unix system to run programs on AMD's EB29K -board in a PC, you must first connect a serial cable between the PC -and a serial port on the Unix system. In the following, we assume -you've hooked the cable between the PC's @file{COM1} port and -@file{/dev/ttya} on the Unix system. - -@menu -* Comms (EB29K):: Communications Setup -* _GDBP__-EB29K:: EB29K cross-debugging -* Remote Log:: Remote Log -@end menu - -@node Comms (EB29K), _GDBP__-EB29K, EB29K Remote, EB29K Remote -@subsubsection Communications Setup -The next step is to set up the PC's port, by doing something like the -following in DOS on the PC: -_0__@example -C:\> MODE com1:9600,n,8,1,none -_1__@end example -@noindent -This example---run on an MS DOS 4.0 system---sets the PC port to 9600 -bps, no parity, eight data bits, one stop bit, and no ``retry'' action; -you must match the communications parameters when establishing the Unix -end of the connection as well. -@c FIXME: Who knows what this "no retry action" crud from the DOS manual may -@c mean? It's optional; leave it out? ---pesch@cygnus.com, 25feb91 - -To give control of the PC to the Unix side of the serial line, type -the following at the DOS console: -_0__@example -C:\> CTTY com1 -_1__@end example -@noindent -(Later, if you wish to return control to the DOS console, you can use -the command @code{CTTY con}---but you must send it over the device that -had control, in our example over the @file{COM1} serial line). - -From the Unix host, use a communications program such as @code{tip} or -@code{cu} to communicate with the PC; for example, -@example -cu -s 9600 -l /dev/ttya -@end example -@noindent -The @code{cu} options shown specify, respectively, the linespeed and the -serial port to use. If you use @code{tip} instead, your command line -may look something like the following: -@example -tip -9600 /dev/ttya -@end example -@noindent -Your system may define a different name where our example uses -@file{/dev/ttya} as the argument to @code{tip}. The communications -parameters, including what port to use, are associated with the -@code{tip} argument in the ``remote'' descriptions file---normally the -system table @file{/etc/remote}. -@c FIXME: What if anything needs doing to match the "n,8,1,none" part of -@c the DOS side's comms setup? cu can support -o (odd -@c parity), -e (even parity)---apparently no settings for no parity or -@c for character size. Taken from stty maybe...? John points out tip -@c can set these as internal variables, eg ~s parity=none; man stty -@c suggests that it *might* work to stty these options with stdin or -@c stdout redirected... ---pesch@cygnus.com, 25feb91 - -@kindex EBMON -Using the @code{tip} or @code{cu} connection, change the DOS working -directory to the directory containing a copy of your 29K program, then -start the PC program @code{EBMON} (an EB29K control program supplied -with your board by AMD). You should see an initial display from -@code{EBMON} similar to the one that follows, ending with the -@code{EBMON} prompt @samp{#}--- -_0__@example -C:\> G: - -G:\> CD \usr\joe\work29k - -G:\USR\JOE\WORK29K> EBMON -Am29000 PC Coprocessor Board Monitor, version 3.0-18 -Copyright 1990 Advanced Micro Devices, Inc. -Written by Gibbons and Associates, Inc. - -Enter '?' or 'H' for help - -PC Coprocessor Type = EB29K -I/O Base = 0x208 -Memory Base = 0xd0000 - -Data Memory Size = 2048KB -Available I-RAM Range = 0x8000 to 0x1fffff -Available D-RAM Range = 0x80002000 to 0x801fffff - -PageSize = 0x400 -Register Stack Size = 0x800 -Memory Stack Size = 0x1800 - -CPU PRL = 0x3 -Am29027 Available = No -Byte Write Available = Yes - -# ~. -_1__@end example - -Then exit the @code{cu} or @code{tip} program (done in the example by -typing @code{~.} at the @code{EBMON} prompt). @code{EBMON} will keep -running, ready for _GDBN__ to take over. - -For this example, we've assumed what is probably the most convenient -way to make sure the same 29K program is on both the PC and the Unix -system: a PC/NFS connection that establishes ``drive @code{G:}'' on the -PC as a file system on the Unix host. If you don't have PC/NFS or -something similar connecting the two systems, you must arrange some -other way---perhaps floppy-disk transfer---of getting the 29K program -from the Unix system to the PC; _GDBN__ will @emph{not} download it over the -serial line. - -@node _GDBP__-EB29K, Remote Log, Comms (EB29K), EB29K Remote -@subsubsection EB29K cross-debugging -Finally, @code{cd} to the directory containing an image of your 29K -program on the Unix system, and start _GDBN__---specifying as argument the -name of your 29K program: -@example -cd /usr/joe/work29k -_GDBP__ myfoo -@end example -Now you can use the @code{target} command: -@example -target amd-eb /dev/ttya 9600 MYFOO -@end example -@c FIXME: test above 'target amd-eb' as spelled, with caps! caps are meant to -@c emphasize that this is the name as seen by DOS (since I think DOS is -@c single-minded about case of letters). ---pesch@cygnus.com, 25feb91 - -@noindent -In this example, we've assumed your program is in a file called -@file{myfoo}. Note that the filename given as the last argument to -@code{target amd-eb} should be the name of the program as it appears to DOS. -In our example this is simply @code{MYFOO}, but in general it can include -a DOS path, and depending on your transfer mechanism may not resemble -the name on the Unix side. - -At this point, you can set any breakpoints you wish; when you're ready -to see your program run on the 29K board, use the _GDBN__ command -@code{run}. - -To stop debugging the remote program, use the _GDBN__ @code{detach} -command. - -To return control of the PC to its console, use @code{tip} or @code{cu} -once again, after your _GDBN__ session has concluded, to attach to -@code{EBMON}. You can then type the command @code{q} to shut down -@code{EBMON}, returning control to the DOS command-line interpreter. -Type @code{CTTY con} to return command input to the main DOS console, -and type @kbd{~.} to leave @code{tip} or @code{cu}. - -@node Remote Log, , _GDBP__-EB29K, EB29K Remote -@subsubsection Remote Log -@kindex eb.log -@cindex log file for EB29K -The @code{target amd-eb} command creates a file @file{eb.log} in the -current working directory, to help debug problems with the connection. -@file{eb.log} records all the output from @code{EBMON}, including echoes -of the commands sent to it. Running @samp{tail -f} on this file in -another window often helps to understand trouble with @code{EBMON}, or -unexpected events on the PC side of the connection. -_fi__(_AMD29K__) - -_if__(_VXWORKS__) -_if__(!_GENERIC__) -@node VxWorks Remote, , EB29K Remote, Starting _GDBN__ -_fi__(!_GENERIC__) -_if__(_GENERIC__) -@node VxWorks Remote, , EB29K Remote, Remote -_fi__(_GENERIC__) -@subsection _GDBN__ and VxWorks -@cindex VxWorks -_GDBN__ enables developers to spawn and debug tasks running on networked -VxWorks targets from a Unix host. Already-running tasks spawned from -the VxWorks shell can also be debugged. _GDBN__ uses code that runs on -both the UNIX host and on the VxWorks target. The program -@code{_GDBP__} is installed and executed on the UNIX host. - -The remote debugging interface (RDB) routines are installed and executed -on the VxWorks target. These routines are included in the VxWorks library -@file{rdb.a} and are incorporated into the system image when source-level -debugging is enabled in the VxWorks configuration. - -@kindex INCLUDE_RDB -Defining @code{INCLUDE_RDB} in the VxWorks configuration file -@file{configAll.h} includes the RDB interface routines and spawns the -source debugging task @code{tRdbTask} when VxWorks is booted. For more -information on configuring and remaking VxWorks, see the @cite{VxWorks -Programmer's Guide}. - -Once you have included the RDB interface in your VxWorks system image -and set your Unix execution search path to find _GDBN__, you are ready -to run _GDBN__. From your UNIX host, type: - -@smallexample -% _GDBP__ -@end smallexample - -_GDBN__ will come up showing the prompt: - -@smallexample -(_GDBP__) -@end smallexample - -@menu -* VxWorks connection:: Connecting to VxWorks -* VxWorks download:: VxWorks Download -* VxWorks attach:: Running Tasks -@end menu - -@node VxWorks connection, VxWorks download, VxWorks Remote, VxWorks Remote -@subsubsection Connecting to VxWorks - -The _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: - -@smallexample -(_GDBP__) target vxworks tt -@end smallexample - -_GDBN__ will display a message similar to the following: - -@smallexample -Attaching remote machine across net... Success! -@end smallexample - -_GDBN__ will then attempt to read the symbol tables of any object -modules loaded into the VxWorks target since it was last booted. -_GDBN__ locates these files by searching the directories listed in the -command search path (@pxref{Environment}); if it fails to find an -object file, it will display a message such as: - -@smallexample -prog.o: No such file or directory. -@end smallexample - -This will cause the @code{target} command to abort. When this happens, -you should add the appropriate directory to the search path, with the -_GDBN__ command @code{path}, and execute the @code{target} command -again. - -@node VxWorks download, VxWorks attach, VxWorks connection, VxWorks Remote -@subsubsection VxWorks Download - -@cindex download to VxWorks -If you have connected to the VxWorks target and you want to debug an -object that has not yet been loaded, you can use the _GDBN__ @code{load} -command to download a file from UNIX to VxWorks incrementally. The -object file given as an argument to the @code{load} command is actually -opened twice: first by the VxWorks target in order to download the code, -then by _GDBN__ in order to read the symbol table. This can lead to -problems if the current working directories on the two systems differ. -It is simplest to set the working directory on both systems to the -directory in which the object file resides, and then to reference the -file by its name, without any path. Thus, to load a program -@file{prog.o}, residing in @file{wherever/vw/demo/rdb}, on VxWorks type: - -@smallexample --> cd "wherever/vw/demo/rdb" -@end smallexample - -On _GDBN__ type: - -@smallexample -(_GDBP__) cd wherever/vw/demo/rdb -(_GDBP__) load prog.o -@end smallexample - -_GDBN__ will display a response similar to the following: - -@smallexample -Reading symbol data from wherever/vw/demo/rdb/prog.o... done. -@end smallexample - -You can also use the @code{load} command to reload an object module -after editing and recompiling the corresponding source file. Note that -this will cause _GDBN__ to delete all currently-defined breakpoints, -auto-displays, and convenience variables, and to clear the value -history. (This is necessary in order to preserve the integrity of -debugger data structures that reference the target system's symbol -table.) - -@node VxWorks attach, , VxWorks download, VxWorks Remote -@subsubsection Running Tasks - -@cindex running VxWorks tasks -You can also attach to an existing task using the @code{attach} command as -follows: - -@smallexample -(_GDBP__) attach @var{task} -@end smallexample - -where @var{task} is the VxWorks hexadecimal task ID. The task can be running -or suspended when you attach to it. If running, it will be suspended at -the time of attachment. - -_fi__(_VXWORKS__) diff --git a/gdb/doc/m680x0.m4 b/gdb/doc/m680x0.m4 deleted file mode 100644 index e5f83b6f116..00000000000 --- a/gdb/doc/m680x0.m4 +++ /dev/null @@ -1,5 +0,0 @@ -_divert__(-1) -_define__(<_M680X0__>,<1>) -_define__(<_HOST__>,) -_define__(<_MACH_DEP__>,) -_divert__<> \ No newline at end of file diff --git a/gdb/doc/none.m4 b/gdb/doc/none.m4 deleted file mode 100644 index 940245c04b7..00000000000 --- a/gdb/doc/none.m4 +++ /dev/null @@ -1,49 +0,0 @@ -_divert__(-1) - -Switches: - -_define__(<_ALL_ARCH__>,<0>) (Meant as most inclusive; file turning - it on is expected to also turn on - all arch-related switches including - "_GENERIC__") -_define__(<_GENERIC__>,<1>) (may not be quite all configs; - meant for "most vanilla" manual) -_define__(<_INTERNALS__>,<0>) - -_define__(<_AOUT__>,<1>) Object formats. Note we turn on one. -_define__(<_BOUT__>,<0>) -_define__(<_COFF__>,<0>) -_define__(<_ELF__>,<0>) - -_define__(<_AMD29K__>,<0>) Specific architectures. Note none -_define__(<_I80386__>,<0>) starts out on. -_define__(<_I960__>,<0>) -_define__(<_M680X0__>,<0>) -_define__(<_SPARC__>,<0>) -_define__(<_VAX__>,<0>) -_define__(<_VXWORKS__>,<0>) - -Text: - -Default names; individual configs may override -Assembler: -_define__(<_AS__>,) -C Compiler: -_define__(<_GCC__>,) -Linker: -_define__(<_LD__>,) -Debugger name: -_define__(<_GDBN__>,) -Debugger program: -_define__(<_GDBP__>,) -Debugger init file: -_define__(<_GDBINIT__>,<.gdbinit>) - -Text for host; individual configs *should* override, but this may -catch some flubs -_define__(<_HOST__>,) - -"Machine Dependent" nodename -_define__(<_MACH_DEP__>,) - -_divert__<> \ No newline at end of file diff --git a/gdb/doc/pretex.m4 b/gdb/doc/pretex.m4 deleted file mode 100644 index 40c3d263453..00000000000 --- a/gdb/doc/pretex.m4 +++ /dev/null @@ -1,268 +0,0 @@ -divert(-1) -*-Text-*- -` Copyright (c) 1991 Free Software Foundation, Inc.' -` This file defines and documents the M4 macros used ' -` to preprocess some GNU manuals' -` $Id$' - -I. INTRODUCTION - -This collection of M4 macros is meant to help in pre-processing texinfo -files to allow configuring them by hosts; for example, the reader of an -as manual who only has access to a 386 may not really want to see crud about -VAXen. - -A preprocessor is used, rather than extending texinfo, because this -way we can hack the conditionals in only one place; otherwise we would -have to write TeX macros, update makeinfo, and update the Emacs -info-formatting functions. - -II. COMPATIBILITY - -These macros should work with GNU m4 and System V m4; they do not work -with Sun or Berkeley M4. - -III. USAGE - -A. M4 INVOCATION -Assume this file is called "pretex.m4". Then, to preprocess a -document "mybook.texinfo" you might do something like the following: - - m4 pretex.m4 none.m4 PARTIC.m4 mybook.texinfo >mybook-PARTIC.texinfo - ----where your path is set to find GNU or SysV "m4", and the other m4 -files mentioned are as follows: - - none.m4: A file that defines, as 0, all the options you might - want to turn on using the conditionals defined below. - Unlike the C preprocessor, m4 does not default - undefined macros to 0. For example, here is a "none.m4" - I have been using: - _divert__(-1) - - _define__(<_ALL_ARCH__>,<0>) - _define__(<_INTERNALS__>,<0>) - - _define__(<_AMD29K__>,<0>) - _define__(<_I80386__>,<0>) - _define__(<_I960__>,<0>) - _define__(<_M680X0__>,<0>) - _define__(<_SPARC__>,<0>) - _define__(<_VAX__>,<0>) - - _divert__<> - - PARTIC.m4: A file that turns on whichever options you actually - want the manual configured for, in this particular - instance. Its contents are similar to one or more of - the lines in "none.m4", but of course the second - argument to _define__ is <1> rather than <0>. - - This is also a convenient place to _define__ any macros - that you want to expand to different text for - different configurations---for example, the name of - the program being described. - -Naturally, these are just suggested conventions; you could put your macro -definitions in any files or combinations of files you like. - -These macros use the characters < and > as m4 quotes; if you need -these characters in your text, you will also want to use the macros -_0__ and _1__ from this package---see the description of "Quote -Handling" in the "Implementation" section below. - -B. WHAT GOES IN THE PRE-TEXINFO SOURCE - -For the most part, the text of your book. In addition, you can -have text that is included only conditionally, using the macros -_if__ and _fi__ defined below. They BOTH take an argument! This is -primarily meant for readability (so a human can more easily see what -conditional end matches what conditional beginning), but the argument -is actually used in the _fi__ as well as the _if__ implementation. -You should always give a _fi__ the same argument as its matching -_if__. Other arguments may appear to work for a while, but are almost -certain to produce the wrong output for some configurations. - -For example, here is an excerpt from the very beginning of the -documentation for GNU as, to name the info file appropriately for -different configurations: - _if__(_ALL_ARCH__) - @setfilename as.info - _fi__(_ALL_ARCH__) - _if__(_M680X0__ && !_ALL_ARCH__) - @setfilename as-m680x0.info - _fi__(_M680X0__ && !_ALL_ARCH__) - _if__(_AMD29K__ && !_ALL_ARCH__) - @setfilename as-29k.info - _fi__(_AMD29K__ && !_ALL_ARCH__) - -Note that you can use Boolean expressions in the arguments; the -expression language is that of the built-in m4 macro `eval', described -in the m4 manual. - -IV. IMPLEMENTATION - -A.PRIMITIVE RENAMING -First, we redefine m4's built-ins to avoid conflict with plain text. -The naming convention used is that our macros all begin with a single -underbar and end with two underbars. The asymmetry is meant to avoid -conflict with some other conventions (which we may want to document) that -are intended to avoid conflict, like ANSI C predefined macros. - -define(`_undefine__',defn(`undefine')) -define(`_define__',defn(`define')) -define(`_defn__',defn(`defn')) -define(`_ppf__',`_define__(`_$1__',_defn__(`$1'))_undefine__(`$1')') -_ppf__(`builtin') -_ppf__(`changecom') -_ppf__(`changequote') -_ppf__(`decr') -_ppf__(`define') -_ppf__(`defn') -_ppf__(`divert') -_ppf__(`divnum') -_ppf__(`dnl') -_ppf__(`dumpdef') -_ppf__(`errprint') -_ppf__(`esyscmd') -_ppf__(`eval') -_ppf__(`format') -_ppf__(`ifdef') -_ppf__(`ifelse') -_ppf__(`include') -_ppf__(`incr') -_ppf__(`index') -_ppf__(`len') -_ppf__(`m4exit') -_ppf__(`m4wrap') -_ppf__(`maketemp') -_ppf__(`patsubst') -_ppf__(`popdef') -_ppf__(`pushdef') -_ppf__(`regexp') -_ppf__(`shift') -_ppf__(`sinclude') -_ppf__(`substr') -_ppf__(`syscmd') -_ppf__(`sysval') -_ppf__(`traceoff') -_ppf__(`traceon') -_ppf__(`translit') -_ppf__(`undefine') -_ppf__(`undivert') -_ppf__(`unix') - -B. QUOTE HANDLING. - -The characters used as quotes by M4, by default, are unfortunately -quite likely to occur in ordinary text. To avoid surprises, we will -use the characters <> ---which are just as suggestive (more so to -Francophones, perhaps) but a little less common in text (save for -those poor Francophones. You win some, you lose some). Still, we -expect also to have to set < and > occasionally in text; to do that, -we define a macro to turn off quote handling (_0__) and a macro to -turn it back on (_1__), according to our convention. - - BEWARE: This seems to make < and > unusable as relational operations - in calls to the builtin "eval". So far I've gotten - along without; but a better choice may be possible. - -Note that we postponed this for a while, for convenience in discussing -the issue and in the primitive renaming---not to mention in defining -_0__ and _1__ themselves! However, the quote redefinitions MUST -precede the _if__ / _fi__ definitions, because M4 will expand the text -as given---if we use the wrong quotes here, we will get the wrong -quotes when we use the conditionals. - -_define__(_0__,`_changequote__(,)')_define__(_1__,`_changequote__(<,>)') -_1__ - -C. CONDITIONALS - -We define two macros, _if__ and _fi__. BOTH take arguments! This is -meant both to help the human reader match up a _fi__ with its -corresponding _if__ and to aid in the implementation. You may use the -full expression syntax supported by M4 (see docn of `eval' builtin in -the m4 manual). - -The conditional macros are carefully defined to avoid introducing -extra whitespace (i.e., blank lines or blank characters). One side -effect exists--- - - BEWARE: text following an `_if__' on the same line is - DISCARDED even if the condition is true; text - following a `_fi__' on the same line is also - always discarded. - -The recommended convention is to always place _if__ and _fi__ on a -line by themselves. This will also aid the human reader. TeX won't -care about the line breaks; as for info, you may want to insert calls -to `@refill' at the end of paragraphs containing conditionalized text, -where you don't want line breaks separating unconditional from -conditional text. info formatting will then give you nice looking -paragraphs in the info file. - -Nesting: conditionals are designed to nest, in the following way: -*nothing* is output between an outer pair of false conditionals, even -if there are true conditionals inside. A false conditional "defeats" -all conditionals within it. The counter _IF_FS__ is used to -implement this; kindly avoid redefining it directly. - -_define__(<_IF_FS__>,<0>) - -NOTE: The definitions for our "pushf" and "popf" macros use eval -rather than incr and decr, because GNU m4 (0.75) tries to call eval -for us when we say "incr" or "decr"---but doesn't notice we've changed -eval's name. - -_define__( - <_pushf__>, - <_define__(<_IF_FS__>, - _eval__((_IF_FS__)+1))>) -_define__( - <_popf__>, - <_ifelse__(0,_IF_FS__, - <<>_dnl__<>>, - <_define__(<_IF_FS__>,_eval__((_IF_FS__)-1))>)>) - -_define__( - <_if__>, - <_ifelse__(1,_eval__( ($1) ), - <<>_dnl__<>>, - <_pushf__<>_divert__(-1)>)>) -_define__( - <_fi__>, - <_ifelse__(1,_eval__( ($1) ), - <<>_dnl__<>>, - <_popf__<>_ifelse__(0,_IF_FS__, - <_divert__<>_dnl__<>>,<>)>)>) - -D. CHAPTER/SECTION MACRO -In a parametrized manual, the heading level may need to be calculated; -for example, a manual that has a chapter on machine dependencies -should be conditionally structured as follows: - - IF the manual is configured for a SINGLE machine type, use -the chapter heading for that machine type, and run headings down -from there (top level for a particular machine is chapter, then within -that we have section, subsection etc); - - ELSE, if MANY machine types are described in the chapter, -use a generic chapter heading such as "@chapter Machine Dependencies", -use "section" for the top level description of EACH machine, and run -headings down from there (top level for a particular machine is -section, then within that we have subsection, subsubsection etc). - -The macro <_CHAPSEC__> is for this purpose: its argument is evaluated (so -you can construct expressions to express choices such as above), then -expands as follows: - 0: @chapter - 1: @section - 2: @subsection - 3: @subsubsection - ...and so on. - -_define__(<_CHAPSEC__>,<@_cs__(_eval__($1))>) -_define__(<_cs__>,<_ifelse__( - 0, $1, , - 1, $1,
, - _cs__(_eval__($1 - 1))>)>) - -_divert__<>_dnl__<> diff --git a/gdb/doc/rc-cm.tex b/gdb/doc/rc-cm.tex deleted file mode 100755 index 1b44a074192..00000000000 --- a/gdb/doc/rc-cm.tex +++ /dev/null @@ -1,22 +0,0 @@ -% $Id$ -% To choose CM (Computer Modern) fonts for the refcard, link -% or copy this file to rcfonts.tex -% -%The Times-Roman family is both more attractive and more compact than -%Computer Modern. On the other hand, while common, it is not free. -%There are three sets of font definitions: -% 1) rc-cm.tex uses the free (Computer Modern) fonts -% 2) rc-ps.tex uses common PostScript fonts, with fontnames from the -% Karl Berry scheme recommended in the documentation for dvips. -% 3) rc-pslong.tex uses common PostScript fonts, with the long names -% used by PostScript programs directly. -% -%-------------------- Computer Modern font defs: -------------------- -\font\bbf=cmbx10 -\font\vbbf=cmbx12 -\font\smrm=cmr5 -\font\brm=cmr10 -\font\rm=cmr7 -\font\it=cmti7 -\font\tt=cmtt8 -%-------------------- end font defs --------------------------------- diff --git a/gdb/doc/rc-ps.tex b/gdb/doc/rc-ps.tex deleted file mode 100755 index 1a0e9703725..00000000000 --- a/gdb/doc/rc-ps.tex +++ /dev/null @@ -1,30 +0,0 @@ -% $Id$ -% To choose PS fonts (Karl Berry TeX fontnames) for the refcard, link -% or copy this file to rcfonts.tex -% -%The Times-Roman family is both more attractive and more compact than -%Computer Modern. On the other hand, while common, it is not free. -%There are three sets of font definitions: -% 1) rc-cm.tex uses the free (Computer Modern) fonts -% 2) rc-ps.tex uses common PostScript fonts, with fontnames from the -% Karl Berry scheme recommended in the documentation for dvips. -% 3) rc-pslong.tex uses common PostScript fonts, with the long names -% used by PostScript programs directly. -% -% One caution: due to differing character ordering between TeX and PS, -%if your TeX is pre-3.0, or if you don't have virtual Courier -%matching the TeX character positions, you might want to use CMtt for -%\tt even if you switch to PostScript fonts for the rest of the text. -% -%-------------------- PostScript fonts (K Berry names) -------------- -\font\bbf=ptmb at 10pt -\font\vbbf=ptmb at 12pt -\font\smrm=ptmr at 6pt -\font\brm=ptmr at 10pt -\font\rm=ptmr at 8pt -\font\it=ptmri at 8pt -\font\tt=pcrr at 8pt -% Used only for \copyright, replacing plain TeX macro. -\font\sym=psyr at 7pt -\def\copyright{{\sym\char'323}} -%-------------------- end font defs --------------------------------- diff --git a/gdb/doc/rc-pslong.tex b/gdb/doc/rc-pslong.tex deleted file mode 100755 index 24643d1d7ef..00000000000 --- a/gdb/doc/rc-pslong.tex +++ /dev/null @@ -1,30 +0,0 @@ -% $Id$ -% To choose PS fonts (long PS fontnames) for the refcard, link -% or copy this file to rcfonts.tex -% -%The Times-Roman family is both more attractive and more compact than -%Computer Modern. On the other hand, while common, it is not free. -%There are three sets of font definitions: -% 1) rc-cm.tex uses the free (Computer Modern) fonts -% 2) rc-ps.tex uses common PostScript fonts, with fontnames from the -% Karl Berry scheme recommended in the documentation for dvips. -% 3) rc-pslong.tex uses common PostScript fonts, with the long names -% used by PostScript programs directly. -% -% One caution: due to differing character ordering between TeX and PS, -%if your TeX is pre-3.0, or if you don't have virtual Courier -%matching the TeX character positions, you might want to use CMtt for -%\tt even if you switch to PostScript fonts for the rest of the text. -% -%-------------------- PostScript fonts (long names) ----------------- -\font\bbf=Times-Bold at 10pt -\font\vbbf=Times-Bold at 12pt -\font\smrm=Times-Roman at 6pt -\font\brm=Times-Roman at 10pt -\font\rm=Times-Roman at 8pt -\font\it=Times-Italic at 8pt -\font\tt=Courier at 8pt -% Used only for \copyright, replacing plain TeX macro. -\font\sym=Symbol at 7pt -\def\copyright{{\sym\char'323}} -%-------------------- end font defs --------------------------------- diff --git a/gdb/doc/rdl-apps.texi b/gdb/doc/rdl-apps.texi deleted file mode 100755 index 28fd2ba3120..00000000000 --- a/gdb/doc/rdl-apps.texi +++ /dev/null @@ -1,2 +0,0 @@ -@include ./../../readline/inc-read.texi -@include ./../../readline/inc-hist.texi diff --git a/gdb/doc/refcard.tex b/gdb/doc/refcard.tex deleted file mode 100644 index 0c24e8f0b11..00000000000 --- a/gdb/doc/refcard.tex +++ /dev/null @@ -1,465 +0,0 @@ -%This file is TeX source for a reference card describing GDB, the GNU debugger. -%$Id$ -%Copyright (C) 1991 Free Software Foundation, Inc. -%Permission is granted to make and distribute verbatim copies of -%this reference provided the copyright notices and permission notices -%are preserved on all copies. -% -%TeX markup is a programming language; accordingly this file is source -%for a program to generate a reference. -% -%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 1, 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 can find a copy of the GNU General Public License in the GDB -%manual; or write to the Free Software Foundation, Inc., -%675 Mass Ave, Cambridge, MA 02139, USA. -% -%You can contact the author as: pesch@cygnus.com -% -% Roland Pesch -% Cygnus Support -% 814 University Ave. -% Palo Alto, CA 94301 USA -% -% +1 415 322 3811 -% -% Cygnus Support is an organization devoted to commercial -% support of free software. For general information -% contact ``info@cygnus.com'' -% -% NOTE ON INTENTIONAL OMISSIONS: This reference card includes most GDB -% commands, but due to space constraints there are some things I chose -% to omit. In general, not all synonyms for commands are covered. -% The GDB-under-Emacs section omits gdb-mode functions without default -% keybindings. GDB startup options are not described. -% set print sevenbit-strings, set symbol-reloading omitted. -% set check range/type omitted at least til code is in GDB. -% -{% -\def\$#1${{#1}}% Kluge: collect RCS revision info without $...$ -\xdef\manvers{\$Revision$}% -}% -\input threecol -\input rcfonts -% -\vsize=8in -\hyphenpenalty=5000\tolerance=2000\raggedright\raggedbottom -\normalbaselineskip=9pt\baselineskip=9pt -% -\parindent=0pt -\parskip=0pt -\footline={\vbox to0pt{\hss}} -% -\def\ctl#1{{\tt C-#1}} -\def\opt#1{{\brm[{\rm #1}]}} -\def\xtra#1{\noalign{\smallskip{\tt#1}}} -% -\long\def\sec#1;#2\endsec{\vskip 1pc -\halign{% -%COL 1 (of halign): -\vtop{\hsize=1.1in\tt -##\par\vskip 2pt }\hfil -%COL 2 (of halign): -&\vtop{\hsize=2.1in\hangafter=1\hangindent=0.5em -\rm ##\par\vskip 2pt}\cr -%Tail of \long\def fills in halign body with \sec args: -\noalign{{\bbf #1}\vskip 2pt} -#2 -} -} - -{\vbbf GDB QUICK REFERENCE} -\vskip 5pt -{\smrm GDB Version 4.2---Cygnus Support 1991} - -\sec Essential Commands; -gdb {\it program} \opt{{\it core}}&debug {\it program} \opt{using -coredump {\it core}}\cr -b \opt{\it file\tt:}{\it function}&set breakpoint at {\it function} \opt{in \it file}\cr -run \opt{{\it arglist}}&start your program \opt{with {\it arglist}}\cr -bt& backtrace: display program stack\cr -p {\it expr}&display the value of an expression\cr -c &continue running your program\cr -n &next line, stepping over function calls\cr -s &next line, stepping into function calls\cr -\endsec - -\sec Starting GDB; -gdb&starts GDB, with no debugging files\cr -gdb {\it program}&begin debugging {\it program}\cr -gdb {\it program core}&debug coredump {\it core} produced by {\it program}\cr -\endsec - -\sec Stopping GDB; -quit&exit GDB; also {\tt q} or {\tt EOF} (eg \ctl{d})\cr -INTERRUPT&(eg \ctl{c}) terminate current command, or send to running process\cr -\endsec - -\sec Getting Help; -help&list classes of commands\cr -help {\it class}&one-line descriptions for commands in {\it class}\cr -help {\it command}&describe {\it command}\cr -\endsec - -\sec Executing your Program; -run {\it arglist}&start your program with {\it arglist}\cr -run&start your program with current argument list\cr -run $\ldots$ <{\it inf} >{\it outf}&start program with input, output -redirected\cr -\cr -kill&kill running program\cr -\cr -tty {\it dev}&use {\it dev} as stdin and stdout for next {\tt run}\cr -set args {\it arglist}&specify {\it arglist} for next -{\tt run}\cr -set args&specify empty argument list\cr -show args&display argument list\cr -\cr -show environment&show all environment variables\cr -show env {\it var}&show value of environment variable {\it var}\cr -set env {\it var} {\it string}&set environment variable {\it var}\cr -unset env {\it var}&remove {\it var} from environment\cr -\endsec - -\sec Shell Commands; -cd {\it dir}&change working directory to {\it dir}\cr -pwd&Print working directory\cr -make $\ldots$&call ``{\tt make}''\cr -shell {\it cmd}&execute arbitrary shell command string\cr -\endsec - -\vfill -\centerline{\smrm \copyright 1991 Free Software Foundation, Inc.\qquad Permissions on back} -\eject -\sec Breakpoints and Watchpoints; -break \opt{\it file\tt:}{\it line}\par -b \opt{\it file\tt:}{\it line}&set breakpoint at {\it line} number \opt{in \it file}\par -eg:\quad{\tt break main.c:37}\quad\cr -break \opt{\it file\tt:}{\it function}&set breakpoint at {\it -function} \opt{in \it file}\cr -break +{\it offset}\par -break -{\it offset}&set break at {\it offset} lines from current stop\cr -break *{\it addr}&set breakpoint at address {\it addr}\cr -break&set breakpoint at next instruction\cr -break $\ldots$ if {\it expr}&break conditionally on nonzero {\it expr}\cr -cond {\it n} \opt{\it expr}&new conditional expression on breakpoint -{\it n}; make unconditional if no {\it expr}\cr -tbreak $\ldots$&temporary break; disable when reached\cr -rbreak {\it regex}&break on all functions matching {\it regex}\cr -watch {\it expr}&set a watchpoint for expression {\it expr}\cr -catch {\it x}&break at C++ handler for exception {\it x}\cr -\cr -info break&show defined breakpoints\cr -info watch&show defined watchpoints\cr -\cr -clear&delete breakpoints at next instruction\cr -clear \opt{\it file\tt:}{\it fun}&delete breakpoints at entry to {\it fun}()\cr -clear \opt{\it file\tt:}{\it line}&delete breakpoints on source line \cr -delete \opt{{\it n}}&delete breakpoints {\it n}; -\opt{or all breakpoints}\cr -\cr -disable \opt{{\it n}}&disable breakpoints {\it n} \opt{or all}\cr -enable \opt{{\it n}}&enable breakpoints {\it n} \opt{or all}\cr -enable once \opt{{\it n}}&enable breakpoints; disable again when -reached\cr -enable del \opt{{\it n}}&enable breakpoints; delete when reached\cr -\cr -ignore {\it n} {\it count}&ignore breakpoint {\it n}, {\it count} -times\cr -\cr -commands {\it n}\par -\qquad {\it command list}&execute GDB {\it command list} every time breakpoint {\it n} is reached\cr -end&end of {\it command list}\cr -\endsec - -\sec Program Stack; -backtrace \opt{\it n}\par -bt \opt{\it n}&print trace of all frames in stack; or of {\it n} -frames---innermost if {\it n}{\tt >0}, outermost if {\it n}{\tt <0}\cr -frame \opt{\it n}&select frame number {\it n} or frame at address {\it -n}; if no {\it n}, display current frame\cr -up {\it n}&select frame {\it n} frames up\cr -down {\it n}&select frame {\it n} frames down\cr -info frame \opt{\it addr}&describe selected frame, or frame at -{\it addr}\cr -info args&arguments of selected frame\cr -info locals&local variables of selected frame\cr -info reg \opt{\it{rn}}®ister values \opt{for reg {\it rn\/}} in selected frame\cr -info catch&exception handlers active in selected frame\cr -\endsec - -\vfill\eject -\sec Execution Control; -continue \opt{\it count}\par -c \opt{\it count}&continue running; if {\it count} specified, ignore -this breakpoint next {\it count} times\cr -\cr -step \opt{\it count}\par -s \opt{\it count}&execute until another line reached; repeat {\it count} times if -specified\cr -\cr -stepi \opt{\it count}\par -si \opt{\it count}&step by machine instructions rather than source -lines\cr -\cr -next \opt{\it count}\par -n \opt{\it count}&execute next line, including any function calls\cr -\cr -nexti \opt{\it count}\par -ni \opt{\it count}&next machine instruction rather than source -line\cr -\cr -until \opt{\it location}&run until next instruction (or {\it -location})\cr -finish&run until selected stack frame returns\cr -return \opt{\it expr}&pop selected stack frame without executing -\opt{setting return value}\cr -signal {\it num}&resume execution with signal {\it s} (none if {\tt 0})\cr -jump {\it line}\par -jump *{\it address}&resume execution at specified {\it line} number or -{\it address}\cr -set var={\it expr}&evaluate {\it expr} without displaying it; use for -altering program variables\cr -\endsec - -\sec Display; -print \opt{\tt/{\it f}\/} {\it expr}\par -p \opt{\tt/{\it f}\/} {\it expr}&show value of {\it expr} according to format {\it f}:\cr -\qquad x&hexadecimal\cr -\qquad d&signed decimal\cr -\qquad u&unsigned decimal\cr -\qquad o&octal\cr -\qquad a&address, absolute and relative\cr -\qquad c&character\cr -\qquad f&floating point\cr -call \opt{\tt /{\it f}\/} {\it expr}&like {\tt print} but does not display -{\tt void}\cr -x \opt{\tt/{\it Nuf}\/} {\it expr}&examine memory at address {\it expr}; -optional format spec follows slash\cr -\quad {\it N}&count of how many units to display\cr -\quad {\it u}&unit size; one of\cr -&{\tt\qquad b}\ individual bytes\cr -&{\tt\qquad h}\ halfwords (two bytes)\cr -&{\tt\qquad w}\ words (four bytes)\cr -&{\tt\qquad g}\ giant words (eight bytes)\cr -\quad {\it f}&printing format. Any {\tt print} format, or\cr -&{\tt\qquad s}\ null-terminated string\cr -&{\tt\qquad i}\ machine instructions\cr -disassem \opt{\it addr}&display memory as machine instructions\cr -\endsec - -\sec Automatic Display; -display \opt{\tt/\it f\/} {\it expr}&show value of {\it expr} each time -program stops \opt{according to format {\it f}\/}\cr -display&display all enabled expressions on list\cr -undisplay {\it n}&remove number(s) {\it n} from list of -automatically displayed expressions\cr -disable disp {\it n}&disable display for expression(s) number {\it -n}\cr -enable disp {\it n}&enable display for expression(s) number {\it -n}\cr -info display&numbered list of display expressions\cr -\endsec - -\vfill\eject - -\sec Expressions; -{\it expr}&an expression in C, C++, or Modula-2 (including function calls), or:\cr -{\it addr\/}@{\it len}&an array of {\it len} elements beginning at {\it -addr}\cr -{\it file}::{\it nm}&a variable or function {\it nm} defined in {\it -file}\cr -$\tt\{${\it type}$\tt\}${\it addr}&read memory at {\it addr} as specified -{\it type}\cr -\$&most recent displayed value\cr -\${\it n}&{\it n}th displayed value\cr -\$\$&displayed value previous to \$\cr -\$\${\it n}&{\it n}th displayed value back from \$\cr -\$\_&last address examined with {\tt x}\cr -\$\_\_&value at address \$\_\cr -\${\it var}&convenience variable; assign any value\cr -\cr -show values \opt{{\it n}}&show last 10 values \opt{or surrounding -\${\it n}}\cr -show convenience&display all convenience variables\cr -\endsec - -\sec Symbol Table; -info address {\it s}&show where symbol {\it s} is stored\cr -info func \opt{\it regex}&show names, types of defined functions -(all, or matching {\it regex})\cr -info var \opt{\it regex}&show names, types of global variables (all, -or matching {\it regex})\cr -whatis {\it expr}\par -ptype {\it expr}&show data type of {\it expr} without evaluating; {\tt -ptype} gives more detail\cr -ptype {\it type}&describe type, struct, union, or enum\cr -\endsec - -\sec GDB Scripts; -source {\it script}&read, execute GDB commands from file {\it -script}\cr -\cr -define {\it cmd}\par -\qquad {\it command list}&new GDB command {\it cmd}, executes script -defined by {\it command list} \cr -end&end of {\it command list}\cr -document {\it cmd}\par -\qquad {\it help text}&new online documentation for GDB command {\it -cmd}\cr -end&end of {\it help text}\cr -\endsec - -\sec Signals; -handle {\it signal} {\it act}&specify GDB actions for {\it signal}:\cr -\quad print&announce signal\cr -\quad noprint&be silent for signal\cr -\quad stop&halt execution on signal\cr -\quad nostop&do not halt execution\cr -\quad pass&allow your program to handle signal\cr -\quad nopass&do not allow your program to see signal\cr -info signals&show table of signals, GDB action for each\cr -\endsec - -\sec Debugging Targets; -target {\it type} {\it param}&connect to target machine, process, or file\cr -help target&display available targets\cr -attach {\it param}&connect to another process\cr -detach&release target from GDB control\cr -\endsec - -\vfill\eject -\sec Controlling GDB; -set {\it param} {\it value}&set one of GDB's internal parameters\cr -show {\it param}&display current setting of a GDB parameter\cr -\xtra{\rm Parameters understood by {\tt set} and {\tt show}:} -\quad complaints {\it limit}&number of messages on unusual symbols\cr -\quad confirm {\it on/off}&enable or disable cautionary queries\cr -\quad editing {\it on/off}&control {\tt readline} command-line editing\cr -\quad height {\it lpp}&number of lines before pause in display\cr -\quad language {\it lang}&Language for GDB expressions ({\tt auto}, {\tt c} or -{\tt modula-2})\cr -\quad listsize {\it n}&number of lines shown by {\tt list}\cr -\quad prompt {\it str}&use {\it str} as GDB prompt\cr -\quad radix {\it base}&octal, decimal, or hex number representation\cr -\quad verbose {\it on/off}&control messages when loading -symbol table\cr -\quad width {\it cpl}&number of characters before line folded\cr -\quad write {\it on/off}&Allow or forbid patching binary, core files -(when reopened with {\tt exec} or {\tt core}) -\cr -\quad history $\ldots$&({\tt h}) groups the following options:\cr -\quad h exp {\it off/on}&disable or enable {\tt readline} history expansion\cr -\quad h file {\it filename}&file for recording GDB command history\cr -\quad h size {\it size}&number of commands kept in history list\cr -\quad h save {\it off/on}&control use of external file for -command history\cr -\cr -\quad print $\ldots$&({\tt p}) groups the following options:\cr -\quad p address {\it on/off}&print memory addresses in stacks, -values\cr -\quad p array {\it off/on}&compact or attractive format for -arrays\cr -\quad p demangl {\it on/off}&source (demangled) or internal form for C++ -symbols\cr -\quad p asm-dem {\it on/off}&demangle C++ symbols in -machine-instruction output\cr -\quad p elements {\it limit}&number of elements to display from an -array\cr -\quad p object {\it on/off}&print C++ derived types for objects\cr -\quad p pretty {\it off/on}&struct display: compact or indented\cr -\quad p union {\it on/off}&enable or disable display of union members\cr -\quad p vtbl {\it off/on}&display of C++ virtual function -tables\cr -\cr -show commands&show last 10 commands\cr -show commands {\it n}&show 10 commands around number {\it n}\cr -show commands +&show next 10 commands\cr -\endsec - -\sec Working Files; -file {\it file}&use {\it file} for symbols and executable\cr -core {\it file}&read {\it file} as coredump\cr -exec {\it file}&use {\it file} as executable only\cr -symbol {\it file}&use only symbol table from {\it file}\cr -load {\it file}&dynamically link {\it file\/} and add its symbols\cr -add-sym {\it file} {\it addr}&read additional symbols from {\it file}, -dynamically loaded at {\it addr}\cr -info files&display working files and targets in use\cr -path {\it dirs}&add {\it dirs} to front of path searched for -executable and symbol files\cr -show path&display executable and symbol file path\cr -info share&list names of shared libraries currently loaded\cr -\endsec - -\vfill\eject -\sec Source Files; -dir {\it names}&add directory {\it names} to front of source path\cr -dir&clear source path\cr -show dir&show current source path\cr -\cr -list&show next ten lines of source\cr -list -&show previous ten lines\cr -list {\it lines}&display source centered around {\it lines}, -specified as one of:\cr -\quad{\opt{\it file\tt:}\it num}&line number \opt{in named file}\cr -\quad{\opt{\it file\tt:}\it function}&beginning of function \opt{in -named file}\cr -\quad{\tt +\it off}&{\it off} lines after last printed\cr -\quad{\tt -\it off}&{\it off} lines previous to last printed\cr -\quad{\tt*\it address}&line containing {\it address}\cr -list {\it f},{\it l}&from line {\it f} to line {\it l}\cr -info line {\it num}&show starting, ending addresses of compiled code for -source line {\it num}\cr -info source&show name of current source file\cr -info sources&list all source files in use\cr -forw {\it regex}&search following source lines for {\it regex}\cr -rev {\it regex}&search preceding source lines for {\it regex}\cr -\endsec - -\sec GDB under GNU Emacs; -M-x gdb&run GDB under Emacs\cr -\ctl{h} m&describe GDB mode\cr -M-s&step one line ({\tt step})\cr -M-n&next line ({\tt next})\cr -M-i&step one instruction ({\tt stepi})\cr -\ctl{c} \ctl{f}&finish current stack frame ({\tt finish})\cr -M-c&continue ({\tt cont})\cr -M-u&up {\it arg} frames ({\tt up})\cr -M-d&down {\it arg} frames ({\tt down})\cr -\ctl{x} \&© number from point, insert at end\cr -\ctl{x} SPC&(in source file) set break at point\cr -\endsec - -\sec GDB License; -info copying&Display GNU General Public License\cr -info warranty&There is NO WARRANTY for GDB. Display full no-warranty -statement.\cr -\endsec - - -\vfill -{\smrm\parskip=6pt -\centerline{Copyright \copyright 1991 Free Software Foundation, Inc.} -\centerline{Roland Pesch (pesch@cygnus.com), September 1991---\manvers} -\centerline{The author assumes no responsibility for any errors on this card.} - -This card may be freely distributed under the terms of the GNU -General Public License. - -\centerline{Please contribute to development of this card by -annotating it.} - -GDB itself is free software; you are welcome to distribute copies of -it under the terms of the GNU General Public License. There is -absolutely no warranty for GDB. -} -\end diff --git a/gdb/doc/sparc.m4 b/gdb/doc/sparc.m4 deleted file mode 100644 index 8cc6a3e46d9..00000000000 --- a/gdb/doc/sparc.m4 +++ /dev/null @@ -1,5 +0,0 @@ -_divert__(-1) -_define__(<_SPARC__>,<1>) -_define__(<_HOST__>,) -_define__(<_MACH_DEP__>,) -_divert__<> \ No newline at end of file diff --git a/gdb/doc/threecol.tex b/gdb/doc/threecol.tex deleted file mode 100755 index 604101e2e7e..00000000000 --- a/gdb/doc/threecol.tex +++ /dev/null @@ -1,28 +0,0 @@ -%Three-column format for landscape printing on 8.5x11 paper -%pesch 1990 december 31 -%We want output .25 inch *from paper edge*; i.e. -.75in from TeX default -\hoffset=-0.8in \voffset=-0.75in -\newdimen\fullhsize -\fullhsize=10.5in \hsize=3.3in -\def\fulline{\hbox to \fullhsize} -\let\lcr=L \newbox\leftcolumn\newbox\centercolumn -\output={\if L\lcr - \global\setbox\leftcolumn=\columnbox \global\let\lcr=C - \else - \if C\lcr - \global\setbox\centercolumn=\columnbox \global\let\lcr=R - \else \tripleformat \global\let\lcr=L - \fi - \fi -% \ifnum\outputpenalty>-20000 \else\dosupereject\fi - } -\def\tripleformat{\shipout\vbox{\fulline{\box\leftcolumn\hskip .2in plus1fil - \box\centercolumn\hskip .2in plus1fil - \columnbox} - } - \advancepageno} -\def\columnbox{\leftline{\pagebody}} -\def\bye{\par\vfill - \supereject - \if R\lcr \null\vfill\eject\fi - \end} diff --git a/gdb/doc/vax.m4 b/gdb/doc/vax.m4 deleted file mode 100644 index 59cb2ab1263..00000000000 --- a/gdb/doc/vax.m4 +++ /dev/null @@ -1,5 +0,0 @@ -_divert__(-1) -_define__(<_VAX__>,<1>) -_define__(<_HOST__>,) -_define__(<_MACH_DEP__>,) -_divert__<> \ No newline at end of file diff --git a/gdb/dwarfread.c b/gdb/dwarfread.c deleted file mode 100644 index 98cb95b594b..00000000000 --- a/gdb/dwarfread.c +++ /dev/null @@ -1,3545 +0,0 @@ -/* DWARF debugging format support for GDB. - Copyright (C) 1991 Free Software Foundation, Inc. - Written by Fred Fish at Cygnus Support, portions based on dbxread.c, - mipsread.c, coffread.c, and dwarfread.c from a Data General SVR4 gdb port. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - -FIXME: Figure out how to get the frame pointer register number in the -execution environment of the target. Remove R_FP kludge - -FIXME: Add generation of dependencies list to partial symtab code. - -FIXME: Currently we ignore host/target byte ordering and integer size -differences. Should remap data from external form to an internal form -before trying to use it. - -FIXME: Resolve minor differences between what information we put in the -partial symbol table and what dbxread puts in. For example, we don't yet -put enum constants there. And dbxread seems to invent a lot of typedefs -we never see. Use the new printpsym command to see the partial symbol table -contents. - -FIXME: Change forward declarations of static functions to allow for compilers -without prototypes. - -FIXME: Figure out a better way to tell gdb (all the debug reading routines) -the names of the gccX_compiled flags. - -FIXME: Figure out a better way to tell gdb about the name of the function -contain the user's entry point (I.E. main()) - -FIXME: The current DWARF specification has a very strong bias towards -machines with 32-bit integers, as it assumes that many attributes of the -program (such as an address) will fit in such an integer. There are many -references in the spec to things that are 2, 4, or 8 bytes long. Given that -we will probably run into problems on machines where some of these assumptions -are invalid (64-bit ints for example), we don't bother at this time to try to -make this code more flexible and just use shorts, ints, and longs (and their -sizes) where it seems appropriate. I.E. we use a short int to hold DWARF -tags, and assume that the tag size in the file is the same as sizeof(short). - -FIXME: Figure out how to get the name of the symbol indicating that a module -has been compiled with gcc (gcc_compiledXX) in a more portable way than -hardcoding it into the object file readers. - -FIXME: See other FIXME's and "ifdef 0" scattered throughout the code for -other things to work on, if you get bored. :-) - -*/ -#include -#ifdef __STDC__ -#include -#else -#include -#endif -#include - -#include "defs.h" -#include "param.h" -#include "bfd.h" -#include "symtab.h" -#include "symfile.h" -#include "dwarf.h" -#include "ansidecl.h" - -#ifdef MAINTENANCE /* Define to 1 to compile in some maintenance stuff */ -#define SQUAWK(stuff) dwarfwarn stuff -#else -#define SQUAWK(stuff) -#endif - -#ifndef R_FP /* FIXME */ -#define R_FP 14 /* Kludge to get frame pointer register number */ -#endif - -typedef unsigned int DIEREF; /* Reference to a DIE */ - -#define GCC_COMPILED_FLAG_SYMBOL "gcc_compiled%" /* FIXME */ -#define GCC2_COMPILED_FLAG_SYMBOL "gcc2_compiled%" /* FIXME */ - -#define STREQ(a,b) (strcmp(a,b)==0) - -extern CORE_ADDR startup_file_start; /* From blockframe.c */ -extern CORE_ADDR startup_file_end; /* From blockframe.c */ -extern CORE_ADDR entry_scope_lowpc; /* From blockframe.c */ -extern CORE_ADDR entry_scope_highpc; /* From blockframc.c */ -extern CORE_ADDR main_scope_lowpc; /* From blockframe.c */ -extern CORE_ADDR main_scope_highpc; /* From blockframc.c */ -extern int info_verbose; /* From main.c; nonzero => verbose */ - - -/* The DWARF debugging information consists of two major pieces, - one is a block of DWARF Information Entries (DIE's) and the other - is a line number table. The "struct dieinfo" structure contains - the information for a single DIE, the one currently being processed. - - In order to make it easier to randomly access the attribute fields - of the current DIE, which are specifically unordered within the DIE - each DIE is scanned and an instance of the "struct dieinfo" - structure is initialized. - - Initialization is done in two levels. The first, done by basicdieinfo(), - just initializes those fields that are vital to deciding whether or not - to use this DIE, how to skip past it, etc. The second, done by the - function completedieinfo(), fills in the rest of the information. - - Attributes which have block forms are not interpreted at the time - the DIE is scanned, instead we just save pointers to the start - of their value fields. - - Some fields have a flag _p that is set when the value of the - field is valid (I.E. we found a matching attribute in the DIE). Since - we may want to test for the presence of some attributes in the DIE, - such as AT_low_pc, without restricting the values of the field, - we need someway to note that we found such an attribute. - - */ - -typedef char BLOCK; - -struct dieinfo { - char * die; /* Pointer to the raw DIE data */ - long dielength; /* Length of the raw DIE data */ - DIEREF dieref; /* Offset of this DIE */ - short dietag; /* Tag for this DIE */ - long at_padding; - long at_sibling; - BLOCK * at_location; - char * at_name; - unsigned short at_fund_type; - BLOCK * at_mod_fund_type; - long at_user_def_type; - BLOCK * at_mod_u_d_type; - short at_ordering; - BLOCK * at_subscr_data; - long at_byte_size; - short at_bit_offset; - long at_bit_size; - BLOCK * at_element_list; - long at_stmt_list; - long at_low_pc; - long at_high_pc; - long at_language; - long at_member; - long at_discr; - BLOCK * at_discr_value; - short at_visibility; - long at_import; - BLOCK * at_string_length; - char * at_comp_dir; - char * at_producer; - long at_frame_base; - long at_start_scope; - long at_stride_size; - long at_src_info; - short at_prototyped; - unsigned int has_at_low_pc:1; - unsigned int has_at_stmt_list:1; -}; - -static int diecount; /* Approximate count of dies for compilation unit */ -static struct dieinfo *curdie; /* For warnings and such */ - -static char *dbbase; /* Base pointer to dwarf info */ -static int dbroff; /* Relative offset from start of .debug section */ -static char *lnbase; /* Base pointer to line section */ -static int isreg; /* Kludge to identify register variables */ - -static CORE_ADDR baseaddr; /* Add to each symbol value */ - -/* Each partial symbol table entry contains a pointer to private data for the - read_symtab() function to use when expanding a partial symbol table entry - to a full symbol table entry. For DWARF debugging info, this data is - contained in the following structure and macros are provided for easy - access to the members given a pointer to a partial symbol table entry. - - dbfoff Always the absolute file offset to the start of the ".debug" - section for the file containing the DIE's being accessed. - - dbroff Relative offset from the start of the ".debug" access to the - first DIE to be accessed. When building the partial symbol - table, this value will be zero since we are accessing the - entire ".debug" section. When expanding a partial symbol - table entry, this value will be the offset to the first - DIE for the compilation unit containing the symbol that - triggers the expansion. - - dblength The size of the chunk of DIE's being examined, in bytes. - - lnfoff The absolute file offset to the line table fragment. Ignored - when building partial symbol tables, but used when expanding - them, and contains the absolute file offset to the fragment - of the ".line" section containing the line numbers for the - current compilation unit. - */ - -struct dwfinfo { - int dbfoff; /* Absolute file offset to start of .debug section */ - int dbroff; /* Relative offset from start of .debug section */ - int dblength; /* Size of the chunk of DIE's being examined */ - int lnfoff; /* Absolute file offset to line table fragment */ -}; - -#define DBFOFF(p) (((struct dwfinfo *)((p)->read_symtab_private))->dbfoff) -#define DBROFF(p) (((struct dwfinfo *)((p)->read_symtab_private))->dbroff) -#define DBLENGTH(p) (((struct dwfinfo *)((p)->read_symtab_private))->dblength) -#define LNFOFF(p) (((struct dwfinfo *)((p)->read_symtab_private))->lnfoff) - -/* Record the symbols defined for each context in a linked list. We don't - create a struct block for the context until we know how long to make it. - Global symbols for each file are maintained in the global_symbols list. */ - -struct pending_symbol { - struct pending_symbol *next; /* Next pending symbol */ - struct symbol *symbol; /* The actual symbol */ -}; - -static struct pending_symbol *global_symbols; /* global funcs and vars */ -static struct block *global_symbol_block; - -/* Line number entries are read into a dynamically expandable vector before - being added to the symbol table section. Once we know how many there are - we can add them. */ - -static struct linetable *line_vector; /* Vector of line numbers. */ -static int line_vector_index; /* Index of next entry. */ -static int line_vector_length; /* Current allocation limit */ - -/* Scope information is kept in a scope tree, one node per scope. Each time - a new scope is started, a child node is created under the current node - and set to the current scope. Each time a scope is closed, the current - scope moves back up the tree to the parent of the current scope. - - Each scope contains a pointer to the list of symbols defined in the scope, - a pointer to the block vector for the scope, a pointer to the symbol - that names the scope (if any), and the range of PC values that mark - the start and end of the scope. */ - -struct scopenode { - struct scopenode *parent; - struct scopenode *child; - struct scopenode *sibling; - struct pending_symbol *symbols; - struct block *block; - struct symbol *namesym; - CORE_ADDR lowpc; - CORE_ADDR highpc; -}; - -static struct scopenode *scopetree; -static struct scopenode *scope; - -/* DIES which have user defined types or modified user defined types refer to - other DIES for the type information. Thus we need to associate the offset - of a DIE for a user defined type with a pointer to the type information. - - Originally this was done using a simple but expensive algorithm, with an - array of unsorted structures, each containing an offset/type-pointer pair. - This array was scanned linearly each time a lookup was done. The result - was that gdb was spending over half it's startup time munging through this - array of pointers looking for a structure that had the right offset member. - - The second attempt used the same array of structures, but the array was - sorted using qsort each time a new offset/type was recorded, and a binary - search was used to find the type pointer for a given DIE offset. This was - even slower, due to the overhead of sorting the array each time a new - offset/type pair was entered. - - The third attempt uses a fixed size array of type pointers, indexed by a - value derived from the DIE offset. Since the minimum DIE size is 4 bytes, - we can divide any DIE offset by 4 to obtain a unique index into this fixed - size array. Since each element is a 4 byte pointer, it takes exactly as - much memory to hold this array as to hold the DWARF info for a given - compilation unit. But it gets freed as soon as we are done with it. */ - -static struct type **utypes; /* Pointer to array of user type pointers */ -static int numutypes; /* Max number of user type pointers */ - -/* Forward declarations of static functions so we don't have to worry - about ordering within this file. The EXFUN macro may be slightly - misleading. Should probably be called DCLFUN instead, or something - more intuitive, since it can be used for both static and external - definitions. */ - -static void -EXFUN (dwarfwarn, (char *fmt DOTS)); - -static void -EXFUN (scan_partial_symbols, (char *thisdie AND char *enddie)); - -static void -EXFUN (scan_compilation_units, - (char *filename AND CORE_ADDR addr AND char *thisdie AND char *enddie - AND unsigned int dbfoff AND unsigned int lnoffset - AND struct objfile *objfile)); - -static struct partial_symtab * -EXFUN(start_psymtab, (struct objfile *objfile AND CORE_ADDR addr - AND char *filename AND CORE_ADDR textlow - AND CORE_ADDR texthigh AND int dbfoff - AND int curoff AND int culength AND int lnfoff - AND struct partial_symbol *global_syms - AND struct partial_symbol *static_syms)); -static void -EXFUN(add_partial_symbol, (struct dieinfo *dip)); - -static void -EXFUN(add_psymbol_to_list, - (struct psymbol_allocation_list *listp AND char *name - AND enum namespace space AND enum address_class class - AND CORE_ADDR value)); - -static void -EXFUN(init_psymbol_list, (int total_symbols)); - -static void -EXFUN(basicdieinfo, (struct dieinfo *dip AND char *diep)); - -static void -EXFUN(completedieinfo, (struct dieinfo *dip)); - -static void -EXFUN(dwarf_psymtab_to_symtab, (struct partial_symtab *pst)); - -static void -EXFUN(psymtab_to_symtab_1, (struct partial_symtab *pst)); - -static struct symtab * -EXFUN(read_ofile_symtab, (struct partial_symtab *pst)); - -static void -EXFUN(process_dies, - (char *thisdie AND char *enddie AND struct objfile *objfile)); - -static void -EXFUN(read_structure_scope, - (struct dieinfo *dip AND char *thisdie AND char *enddie)); - -static struct type * -EXFUN(decode_array_element_type, (char *scan AND char *end)); - -static struct type * -EXFUN(decode_subscr_data, (char *scan AND char *end)); - -static void -EXFUN(read_array_type, (struct dieinfo *dip)); - -static void -EXFUN(read_subroutine_type, - (struct dieinfo *dip AND char *thisdie AND char *enddie)); - -static void -EXFUN(read_enumeration, - (struct dieinfo *dip AND char *thisdie AND char *enddie)); - -static struct type * -EXFUN(struct_type, - (struct dieinfo *dip AND char *thisdie AND char *enddie)); - -static struct type * -EXFUN(enum_type, (struct dieinfo *dip)); - -static void -EXFUN(start_symtab, (void)); - -static void -EXFUN(end_symtab, - (char *filename AND long language AND struct objfile *objfile)); - -static int -EXFUN(scopecount, (struct scopenode *node)); - -static void -EXFUN(openscope, - (struct symbol *namesym AND CORE_ADDR lowpc AND CORE_ADDR highpc)); - -static void -EXFUN(freescope, (struct scopenode *node)); - -static struct block * -EXFUN(buildblock, (struct pending_symbol *syms)); - -static void -EXFUN(closescope, (void)); - -static void -EXFUN(record_line, (int line AND CORE_ADDR pc)); - -static void -EXFUN(decode_line_numbers, (char *linetable)); - -static struct type * -EXFUN(decode_die_type, (struct dieinfo *dip)); - -static struct type * -EXFUN(decode_mod_fund_type, (char *typedata)); - -static struct type * -EXFUN(decode_mod_u_d_type, (char *typedata)); - -static struct type * -EXFUN(decode_modified_type, - (unsigned char *modifiers AND unsigned short modcount AND int mtype)); - -static struct type * -EXFUN(decode_fund_type, (unsigned short fundtype)); - -static char * -EXFUN(create_name, (char *name AND struct obstack *obstackp)); - -static void -EXFUN(add_symbol_to_list, - (struct symbol *symbol AND struct pending_symbol **listhead)); - -static struct block ** -EXFUN(gatherblocks, (struct block **dest AND struct scopenode *node)); - -static struct blockvector * -EXFUN(make_blockvector, (void)); - -static struct type * -EXFUN(lookup_utype, (DIEREF dieref)); - -static struct type * -EXFUN(alloc_utype, (DIEREF dieref AND struct type *usetype)); - -static struct symbol * -EXFUN(new_symbol, (struct dieinfo *dip)); - -static int -EXFUN(locval, (char *loc)); - -static void -EXFUN(record_misc_function, (char *name AND CORE_ADDR address AND - enum misc_function_type)); - -static int -EXFUN(compare_psymbols, - (struct partial_symbol *s1 AND struct partial_symbol *s2)); - - -/* - -GLOBAL FUNCTION - - dwarf_build_psymtabs -- build partial symtabs from DWARF debug info - -SYNOPSIS - - void dwarf_build_psymtabs (int desc, char *filename, CORE_ADDR addr, - int mainline, unsigned int dbfoff, unsigned int dbsize, - unsigned int lnoffset, unsigned int lnsize, - struct objfile *objfile) - -DESCRIPTION - - This function is called upon to build partial symtabs from files - containing DIE's (Dwarf Information Entries) and DWARF line numbers. - - It is passed a file descriptor for an open file containing the DIES - and line number information, the corresponding filename for that - file, a base address for relocating the symbols, a flag indicating - whether or not this debugging information is from a "main symbol - table" rather than a shared library or dynamically linked file, - and file offset/size pairs for the DIE information and line number - information. - -RETURNS - - No return value. - - */ - -void -DEFUN(dwarf_build_psymtabs, - (desc, filename, addr, mainline, dbfoff, dbsize, lnoffset, lnsize, - objfile), - int desc AND - char *filename AND - CORE_ADDR addr AND - int mainline AND - unsigned int dbfoff AND - unsigned int dbsize AND - unsigned int lnoffset AND - unsigned int lnsize AND - struct objfile *objfile) -{ - struct cleanup *back_to; - - dbbase = xmalloc (dbsize); - dbroff = 0; - if ((lseek (desc, dbfoff, 0) != dbfoff) || - (read (desc, dbbase, dbsize) != dbsize)) - { - free (dbbase); - error ("can't read DWARF data from '%s'", filename); - } - back_to = make_cleanup (free, dbbase); - - /* If we are reinitializing, or if we have never loaded syms yet, init. - Since we have no idea how many DIES we are looking at, we just guess - some arbitrary value. */ - - if (mainline || global_psymbols.size == 0 || static_psymbols.size == 0) - { - init_psymbol_list (1024); - } - - /* Follow the compilation unit sibling chain, building a partial symbol - table entry for each one. Save enough information about each compilation - unit to locate the full DWARF information later. */ - - scan_compilation_units (filename, addr, dbbase, dbbase + dbsize, - dbfoff, lnoffset, objfile); - - do_cleanups (back_to); -} - - -/* - -LOCAL FUNCTION - - record_misc_function -- add entry to miscellaneous function vector - -SYNOPSIS - - static void record_misc_function (char *name, CORE_ADDR address, - enum misc_function_type mf_type) - -DESCRIPTION - - Given a pointer to the name of a symbol that should be added to the - miscellaneous function vector, and the address associated with that - symbol, records this information for later use in building the - miscellaneous function vector. - - */ - -static void -DEFUN(record_misc_function, (name, address, mf_type), - char *name AND CORE_ADDR address AND enum misc_function_type mf_type) -{ - prim_record_misc_function (obsavestring (name, strlen (name)), address, - mf_type); -} - -/* - -LOCAL FUNCTION - - dwarfwarn -- issue a DWARF related warning - -DESCRIPTION - - Issue warnings about DWARF related things that aren't serious enough - to warrant aborting with an error, but should not be ignored either. - This includes things like detectable corruption in DIE's, missing - DIE's, unimplemented features, etc. - - In general, running across tags or attributes that we don't recognize - is not considered to be a problem and we should not issue warnings - about such. - -NOTES - - We mostly follow the example of the error() routine, but without - returning to command level. It is arguable about whether warnings - should be issued at all, and if so, where they should go (stdout or - stderr). - - We assume that curdie is valid and contains at least the basic - information for the DIE where the problem was noticed. -*/ - -#ifdef __STDC__ -static void -DEFUN(dwarfwarn, (fmt), char *fmt DOTS) -{ - va_list ap; - - va_start (ap, fmt); - warning_setup (); - fprintf (stderr, "DWARF warning (ref 0x%x): ", curdie -> dieref); - if (curdie -> at_name) - { - fprintf (stderr, "'%s': ", curdie -> at_name); - } - vfprintf (stderr, fmt, ap); - fprintf (stderr, "\n"); - fflush (stderr); - va_end (ap); -} -#else - -static void -dwarfwarn (va_alist) - va_dcl -{ - va_list ap; - char *fmt; - - va_start (ap); - fmt = va_arg (ap, char *); - warning_setup (); - fprintf (stderr, "DWARF warning (ref 0x%x): ", curdie -> dieref); - if (curdie -> at_name) - { - fprintf (stderr, "'%s': ", curdie -> at_name); - } - vfprintf (stderr, fmt, ap); - fprintf (stderr, "\n"); - fflush (stderr); - va_end (ap); -} -#endif -/* - -LOCAL FUNCTION - - compare_psymbols -- compare two partial symbols by name - -DESCRIPTION - - Given pointer to two partial symbol table entries, compare - them by name and return -N, 0, or +N (ala strcmp). Typically - used by sorting routines like qsort(). - -NOTES - - This is a copy from dbxread.c. It should be moved to a generic - gdb file and made available for all psymtab builders (FIXME). - - Does direct compare of first two characters before punting - and passing to strcmp for longer compares. Note that the - original version had a bug whereby two null strings or two - identically named one character strings would return the - comparison of memory following the null byte. - - */ - -static int -DEFUN(compare_psymbols, (s1, s2), - struct partial_symbol *s1 AND - struct partial_symbol *s2) -{ - register char *st1 = SYMBOL_NAME (s1); - register char *st2 = SYMBOL_NAME (s2); - - if ((st1[0] - st2[0]) || !st1[0]) - { - return (st1[0] - st2[0]); - } - else if ((st1[1] - st2[1]) || !st1[1]) - { - return (st1[1] - st2[1]); - } - else - { - return (strcmp (st1 + 2, st2 + 2)); - } -} - -/* - -LOCAL FUNCTION - - read_lexical_block_scope -- process all dies in a lexical block - -SYNOPSIS - - static void read_lexical_block_scope (struct dieinfo *dip, - char *thisdie, char *enddie) - -DESCRIPTION - - Process all the DIES contained within a lexical block scope. - Start a new scope, process the dies, and then close the scope. - - */ - -static void -DEFUN(read_lexical_block_scope, (dip, thisdie, enddie, objfile), - struct dieinfo *dip AND - char *thisdie AND - char *enddie AND - struct objfile *objfile) -{ - openscope (NULL, dip -> at_low_pc, dip -> at_high_pc); - process_dies (thisdie + dip -> dielength, enddie, objfile); - closescope (); -} - -/* - -LOCAL FUNCTION - - lookup_utype -- look up a user defined type from die reference - -SYNOPSIS - - static type *lookup_utype (DIEREF dieref) - -DESCRIPTION - - Given a DIE reference, lookup the user defined type associated with - that DIE, if it has been registered already. If not registered, then - return NULL. Alloc_utype() can be called to register an empty - type for this reference, which will be filled in later when the - actual referenced DIE is processed. - */ - -static struct type * -DEFUN(lookup_utype, (dieref), DIEREF dieref) -{ - struct type *type = NULL; - int utypeidx; - - utypeidx = (dieref - dbroff) / 4; - if ((utypeidx < 0) || (utypeidx >= numutypes)) - { - dwarfwarn ("reference to DIE (0x%x) outside compilation unit", dieref); - } - else - { - type = *(utypes + utypeidx); - } - return (type); -} - - -/* - -LOCAL FUNCTION - - alloc_utype -- add a user defined type for die reference - -SYNOPSIS - - static type *alloc_utype (DIEREF dieref, struct type *utypep) - -DESCRIPTION - - Given a die reference DIEREF, and a possible pointer to a user - defined type UTYPEP, register that this reference has a user - defined type and either use the specified type in UTYPEP or - make a new empty type that will be filled in later. - - We should only be called after calling lookup_utype() to verify that - there is not currently a type registered for DIEREF. - */ - -static struct type * -DEFUN(alloc_utype, (dieref, utypep), - DIEREF dieref AND - struct type *utypep) -{ - struct type **typep; - int utypeidx; - - utypeidx = (dieref - dbroff) / 4; - typep = utypes + utypeidx; - if ((utypeidx < 0) || (utypeidx >= numutypes)) - { - utypep = builtin_type_int; - dwarfwarn ("reference to DIE (0x%x) outside compilation unit", dieref); - } - else if (*typep != NULL) - { - utypep = *typep; - SQUAWK (("internal error: dup user type allocation")); - } - else - { - if (utypep == NULL) - { - utypep = (struct type *) - obstack_alloc (symbol_obstack, sizeof (struct type)); - (void) memset (utypep, 0, sizeof (struct type)); - } - *typep = utypep; - } - return (utypep); -} - -/* - -LOCAL FUNCTION - - decode_die_type -- return a type for a specified die - -SYNOPSIS - - static struct type *decode_die_type (struct dieinfo *dip) - -DESCRIPTION - - Given a pointer to a die information structure DIP, decode the - type of the die and return a pointer to the decoded type. All - dies without specific types default to type int. - */ - -static struct type * -DEFUN(decode_die_type, (dip), struct dieinfo *dip) -{ - struct type *type = NULL; - - if (dip -> at_fund_type != 0) - { - type = decode_fund_type (dip -> at_fund_type); - } - else if (dip -> at_mod_fund_type != NULL) - { - type = decode_mod_fund_type (dip -> at_mod_fund_type); - } - else if (dip -> at_user_def_type) - { - if ((type = lookup_utype (dip -> at_user_def_type)) == NULL) - { - type = alloc_utype (dip -> at_user_def_type, NULL); - } - } - else if (dip -> at_mod_u_d_type) - { - type = decode_mod_u_d_type (dip -> at_mod_u_d_type); - } - else - { - type = builtin_type_int; - } - return (type); -} - -/* - -LOCAL FUNCTION - - struct_type -- compute and return the type for a struct or union - -SYNOPSIS - - static struct type *struct_type (struct dieinfo *dip, char *thisdie, - char *enddie) - -DESCRIPTION - - Given pointer to a die information structure for a die which - defines a union or structure, and pointers to the raw die data - that define the range of dies which define the members, compute - and return the user defined type for the structure or union. - */ - -static struct type * -DEFUN(struct_type, (dip, thisdie, enddie), - struct dieinfo *dip AND - char *thisdie AND - char *enddie) -{ - struct type *type; - struct nextfield { - struct nextfield *next; - struct field field; - }; - struct nextfield *list = NULL; - struct nextfield *new; - int nfields = 0; - int n; - char *tpart1; - char *tpart2; - char *tpart3; - struct dieinfo mbr; - - if ((type = lookup_utype (dip -> dieref)) == NULL) - { - type = alloc_utype (dip -> dieref, NULL); - } - switch (dip -> dietag) - { - case TAG_structure_type: - TYPE_CODE (type) = TYPE_CODE_STRUCT; - TYPE_CPLUS_SPECIFIC (type) - = (struct cplus_struct_type *) obstack_alloc (symbol_obstack, sizeof (struct cplus_struct_type)); - bzero (TYPE_CPLUS_SPECIFIC (type), sizeof (struct cplus_struct_type)); - tpart1 = "struct "; - break; - case TAG_union_type: - TYPE_CODE (type) = TYPE_CODE_UNION; - tpart1 = "union "; - break; - default: - tpart1 = ""; - SQUAWK (("missing structure or union tag")); - TYPE_CODE (type) = TYPE_CODE_UNDEF; - break; - } - if (dip -> at_name == NULL) - { - tpart2 = "{...}"; - } - else - { - tpart2 = dip -> at_name; - } - if (dip -> at_byte_size == 0) - { - tpart3 = " "; - } else { - TYPE_LENGTH (type) = dip -> at_byte_size; - tpart3 = ""; - } - TYPE_NAME (type) = concat (tpart1, tpart2, tpart3, NULL); - thisdie += dip -> dielength; - while (thisdie < enddie) - { - basicdieinfo (&mbr, thisdie); - completedieinfo (&mbr); - if (mbr.dielength <= sizeof (long)) - { - break; - } - switch (mbr.dietag) - { - case TAG_member: - /* Get space to record the next field's data. */ - new = (struct nextfield *) alloca (sizeof (struct nextfield)); - new -> next = list; - list = new; - /* Save the data. */ - list -> field.name = savestring (mbr.at_name, strlen (mbr.at_name)); - list -> field.type = decode_die_type (&mbr); - list -> field.bitpos = 8 * locval (mbr.at_location); - list -> field.bitsize = 0; - nfields++; - break; - default: - SQUAWK (("bad member of '%s'", TYPE_NAME (type))); - break; - } - thisdie += mbr.dielength; - } - /* Now create the vector of fields, and record how big it is. */ - TYPE_NFIELDS (type) = nfields; - TYPE_FIELDS (type) = (struct field *) - obstack_alloc (symbol_obstack, sizeof (struct field) * nfields); - /* Copy the saved-up fields into the field vector. */ - for (n = nfields; list; list = list -> next) - { - TYPE_FIELD (type, --n) = list -> field; - } - return (type); -} - -/* - -LOCAL FUNCTION - - read_structure_scope -- process all dies within struct or union - -SYNOPSIS - - static void read_structure_scope (struct dieinfo *dip, - char *thisdie, char *enddie) - -DESCRIPTION - - Called when we find the DIE that starts a structure or union - scope (definition) to process all dies that define the members - of the structure or union. DIP is a pointer to the die info - struct for the DIE that names the structure or union. - -NOTES - - Note that we need to call struct_type regardless of whether or not - we have a symbol, since we might have a structure or union without - a tag name (thus no symbol for the tagname). - */ - -static void -DEFUN(read_structure_scope, (dip, thisdie, enddie), - struct dieinfo *dip AND - char *thisdie AND - char *enddie) -{ - struct type *type; - struct symbol *sym; - - type = struct_type (dip, thisdie, enddie); - if ((sym = new_symbol (dip)) != NULL) - { - SYMBOL_TYPE (sym) = type; - } -} - -/* - -LOCAL FUNCTION - - decode_array_element_type -- decode type of the array elements - -SYNOPSIS - - static struct type *decode_array_element_type (char *scan, char *end) - -DESCRIPTION - - As the last step in decoding the array subscript information for an - array DIE, we need to decode the type of the array elements. We are - passed a pointer to this last part of the subscript information and - must return the appropriate type. If the type attribute is not - recognized, just warn about the problem and return type int. - */ - -static struct type * -DEFUN(decode_array_element_type, (scan, end), char *scan AND char *end) -{ - struct type *typep; - short attribute; - DIEREF dieref; - unsigned short fundtype; - - (void) memcpy (&attribute, scan, sizeof (short)); - scan += sizeof (short); - switch (attribute) - { - case AT_fund_type: - (void) memcpy (&fundtype, scan, sizeof (short)); - typep = decode_fund_type (fundtype); - break; - case AT_mod_fund_type: - typep = decode_mod_fund_type (scan); - break; - case AT_user_def_type: - (void) memcpy (&dieref, scan, sizeof (DIEREF)); - if ((typep = lookup_utype (dieref)) == NULL) - { - typep = alloc_utype (dieref, NULL); - } - break; - case AT_mod_u_d_type: - typep = decode_mod_u_d_type (scan); - break; - default: - SQUAWK (("bad array element type attribute 0x%x", attribute)); - typep = builtin_type_int; - break; - } - return (typep); -} - -/* - -LOCAL FUNCTION - - decode_subscr_data -- decode array subscript and element type data - -SYNOPSIS - - static struct type *decode_subscr_data (char *scan, char *end) - -DESCRIPTION - - The array subscripts and the data type of the elements of an - array are described by a list of data items, stored as a block - of contiguous bytes. There is a data item describing each array - dimension, and a final data item describing the element type. - The data items are ordered the same as their appearance in the - source (I.E. leftmost dimension first, next to leftmost second, - etc). - - We are passed a pointer to the start of the block of bytes - containing the data items, and a pointer to the first byte past - the data. This function decodes the data and returns a type. - -BUGS - FIXME: This code only implements the forms currently used - by the AT&T and GNU C compilers. - - The end pointer is supplied for error checking, maybe we should - use it for that... - */ - -static struct type * -DEFUN(decode_subscr_data, (scan, end), char *scan AND char *end) -{ - struct type *typep = NULL; - struct type *nexttype; - int format; - short fundtype; - long lowbound; - long highbound; - - format = *scan++; - switch (format) - { - case FMT_ET: - typep = decode_array_element_type (scan, end); - break; - case FMT_FT_C_C: - (void) memcpy (&fundtype, scan, sizeof (short)); - scan += sizeof (short); - if (fundtype != FT_integer && fundtype != FT_signed_integer - && fundtype != FT_unsigned_integer) - { - SQUAWK (("array subscripts must be integral types, not type 0x%x", - fundtype)); - } - else - { - (void) memcpy (&lowbound, scan, sizeof (long)); - scan += sizeof (long); - (void) memcpy (&highbound, scan, sizeof (long)); - scan += sizeof (long); - nexttype = decode_subscr_data (scan, end); - if (nexttype != NULL) - { - typep = (struct type *) - obstack_alloc (symbol_obstack, sizeof (struct type)); - (void) memset (typep, 0, sizeof (struct type)); - TYPE_CODE (typep) = TYPE_CODE_ARRAY; - TYPE_LENGTH (typep) = TYPE_LENGTH (nexttype); - TYPE_LENGTH (typep) *= lowbound + highbound + 1; - TYPE_TARGET_TYPE (typep) = nexttype; - } - } - break; - case FMT_FT_C_X: - case FMT_FT_X_C: - case FMT_FT_X_X: - case FMT_UT_C_C: - case FMT_UT_C_X: - case FMT_UT_X_C: - case FMT_UT_X_X: - SQUAWK (("array subscript format 0x%x not handled yet", format)); - break; - default: - SQUAWK (("unknown array subscript format %x", format)); - break; - } - return (typep); -} - -/* - -LOCAL FUNCTION - - read_array_type -- read TAG_array_type DIE - -SYNOPSIS - - static void read_array_type (struct dieinfo *dip) - -DESCRIPTION - - Extract all information from a TAG_array_type DIE and add to - the user defined type vector. - */ - -static void -DEFUN(read_array_type, (dip), struct dieinfo *dip) -{ - struct type *type; - char *sub; - char *subend; - short temp; - - if (dip -> at_ordering != ORD_row_major) - { - /* FIXME: Can gdb even handle column major arrays? */ - SQUAWK (("array not row major; not handled correctly")); - } - if ((sub = dip -> at_subscr_data) != NULL) - { - (void) memcpy (&temp, sub, sizeof (short)); - subend = sub + sizeof (short) + temp; - sub += sizeof (short); - type = decode_subscr_data (sub, subend); - if (type == NULL) - { - type = alloc_utype (dip -> dieref, NULL); - TYPE_CODE (type) = TYPE_CODE_ARRAY; - TYPE_TARGET_TYPE (type) = builtin_type_int; - TYPE_LENGTH (type) = 1 * TYPE_LENGTH (TYPE_TARGET_TYPE (type)); - } - else - { - type = alloc_utype (dip -> dieref, type); - } - } -} - -/* - -LOCAL FUNCTION - - read_subroutine_type -- process TAG_subroutine_type dies - -SYNOPSIS - - static void read_subroutine_type (struct dieinfo *dip, char thisdie, - char *enddie) - -DESCRIPTION - - Handle DIES due to C code like: - - struct foo { - int (*funcp)(int a, long l); (Generates TAG_subroutine_type DIE) - int b; - }; - -NOTES - - The parameter DIES are currently ignored. See if gdb has a way to - include this info in it's type system, and decode them if so. Is - this what the type structure's "arg_types" field is for? (FIXME) - */ - -static void -DEFUN(read_subroutine_type, (dip, thisdie, enddie), - struct dieinfo *dip AND - char *thisdie AND - char *enddie) -{ - struct type *type; - - type = decode_die_type (dip); - type = lookup_function_type (type); - type = alloc_utype (dip -> dieref, type); -} - -/* - -LOCAL FUNCTION - - read_enumeration -- process dies which define an enumeration - -SYNOPSIS - - static void read_enumeration (struct dieinfo *dip, char *thisdie, - char *enddie) - -DESCRIPTION - - Given a pointer to a die which begins an enumeration, process all - the dies that define the members of the enumeration. - -NOTES - - Note that we need to call enum_type regardless of whether or not we - have a symbol, since we might have an enum without a tag name (thus - no symbol for the tagname). - */ - -static void -DEFUN(read_enumeration, (dip, thisdie, enddie), - struct dieinfo *dip AND - char *thisdie AND - char *enddie) -{ - struct type *type; - struct symbol *sym; - - type = enum_type (dip); - if ((sym = new_symbol (dip)) != NULL) - { - SYMBOL_TYPE (sym) = type; - } -} - -/* - -LOCAL FUNCTION - - enum_type -- decode and return a type for an enumeration - -SYNOPSIS - - static type *enum_type (struct dieinfo *dip) - -DESCRIPTION - - Given a pointer to a die information structure for the die which - starts an enumeration, process all the dies that define the members - of the enumeration and return a type pointer for the enumeration. - */ - -static struct type * -DEFUN(enum_type, (dip), struct dieinfo *dip) -{ - struct type *type; - struct nextfield { - struct nextfield *next; - struct field field; - }; - struct nextfield *list = NULL; - struct nextfield *new; - int nfields = 0; - int n; - char *tpart1; - char *tpart2; - char *tpart3; - char *scan; - char *listend; - long temp; - - if ((type = lookup_utype (dip -> dieref)) == NULL) - { - type = alloc_utype (dip -> dieref, NULL); - } - TYPE_CODE (type) = TYPE_CODE_ENUM; - tpart1 = "enum "; - if (dip -> at_name == NULL) - { - tpart2 = "{...}"; - } else { - tpart2 = dip -> at_name; - } - if (dip -> at_byte_size == 0) - { - tpart3 = " "; - } - else - { - TYPE_LENGTH (type) = dip -> at_byte_size; - tpart3 = ""; - } - TYPE_NAME (type) = concat (tpart1, tpart2, tpart3, NULL); - if ((scan = dip -> at_element_list) != NULL) - { - (void) memcpy (&temp, scan, sizeof (temp)); - listend = scan + temp + sizeof (temp); - scan += sizeof (temp); - while (scan < listend) - { - new = (struct nextfield *) alloca (sizeof (struct nextfield)); - new -> next = list; - list = new; - list -> field.type = NULL; - list -> field.bitsize = 0; - (void) memcpy (&list -> field.bitpos, scan, sizeof (long)); - scan += sizeof (long); - list -> field.name = savestring (scan, strlen (scan)); - scan += strlen (scan) + 1; - nfields++; - } - } - /* Now create the vector of fields, and record how big it is. */ - TYPE_NFIELDS (type) = nfields; - TYPE_FIELDS (type) = (struct field *) - obstack_alloc (symbol_obstack, sizeof (struct field) * nfields); - /* Copy the saved-up fields into the field vector. */ - for (n = nfields; list; list = list -> next) - { - TYPE_FIELD (type, --n) = list -> field; - } - return (type); -} - -/* - -LOCAL FUNCTION - - read_func_scope -- process all dies within a function scope - -DESCRIPTION - - Process all dies within a given function scope. We are passed - a die information structure pointer DIP for the die which - starts the function scope, and pointers into the raw die data - that define the dies within the function scope. - - For now, we ignore lexical block scopes within the function. - The problem is that AT&T cc does not define a DWARF lexical - block scope for the function itself, while gcc defines a - lexical block scope for the function. We need to think about - how to handle this difference, or if it is even a problem. - (FIXME) - */ - -static void -DEFUN(read_func_scope, (dip, thisdie, enddie, objfile), - struct dieinfo *dip AND - char *thisdie AND - char *enddie AND - struct objfile *objfile) -{ - struct symbol *sym; - - if (entry_point >= dip -> at_low_pc && entry_point < dip -> at_high_pc) - { - entry_scope_lowpc = dip -> at_low_pc; - entry_scope_highpc = dip -> at_high_pc; - } - if (strcmp (dip -> at_name, "main") == 0) /* FIXME: hardwired name */ - { - main_scope_lowpc = dip -> at_low_pc; - main_scope_highpc = dip -> at_high_pc; - } - sym = new_symbol (dip); - openscope (sym, dip -> at_low_pc, dip -> at_high_pc); - process_dies (thisdie + dip -> dielength, enddie, objfile); - closescope (); -} - -/* - -LOCAL FUNCTION - - read_file_scope -- process all dies within a file scope - -DESCRIPTION - - Process all dies within a given file scope. We are passed a - pointer to the die information structure for the die which - starts the file scope, and pointers into the raw die data which - mark the range of dies within the file scope. - - When the partial symbol table is built, the file offset for the line - number table for each compilation unit is saved in the partial symbol - table entry for that compilation unit. As the symbols for each - compilation unit are read, the line number table is read into memory - and the variable lnbase is set to point to it. Thus all we have to - do is use lnbase to access the line number table for the current - compilation unit. - */ - -static void -DEFUN(read_file_scope, (dip, thisdie, enddie, objfile), - struct dieinfo *dip AND - char *thisdie AND - char *enddie AND - struct objfile *objfile) -{ - struct cleanup *back_to; - - if (entry_point >= dip -> at_low_pc && entry_point < dip -> at_high_pc) - { - startup_file_start = dip -> at_low_pc; - startup_file_end = dip -> at_high_pc; - } - numutypes = (enddie - thisdie) / 4; - utypes = (struct type **) xmalloc (numutypes * sizeof (struct type *)); - back_to = make_cleanup (free, utypes); - (void) memset (utypes, 0, numutypes * sizeof (struct type *)); - start_symtab (); - openscope (NULL, dip -> at_low_pc, dip -> at_high_pc); - decode_line_numbers (lnbase); - process_dies (thisdie + dip -> dielength, enddie, objfile); - closescope (); - end_symtab (dip -> at_name, dip -> at_language, objfile); - do_cleanups (back_to); - utypes = NULL; - numutypes = 0; -} - -/* - -LOCAL FUNCTION - - start_symtab -- do initialization for starting new symbol table - -SYNOPSIS - - static void start_symtab (void) - -DESCRIPTION - - Called whenever we are starting to process dies for a new - compilation unit, to perform initializations. Right now - the only thing we really have to do is initialize storage - space for the line number vector. - - */ - -static void -DEFUN_VOID (start_symtab) -{ - int nbytes; - - line_vector_index = 0; - line_vector_length = 1000; - nbytes = sizeof (struct linetable); - nbytes += line_vector_length * sizeof (struct linetable_entry); - line_vector = (struct linetable *) xmalloc (nbytes); -} - -/* - -LOCAL FUNCTION - - process_dies -- process a range of DWARF Information Entries - -SYNOPSIS - - static void process_dies (char *thisdie, char *enddie) - -DESCRIPTION - - Process all DIE's in a specified range. May be (and almost - certainly will be) called recursively. - */ - -static void -DEFUN(process_dies, (thisdie, enddie, objfile), - char *thisdie AND char *enddie AND struct objfile *objfile) -{ - char *nextdie; - struct dieinfo di; - - while (thisdie < enddie) - { - basicdieinfo (&di, thisdie); - if (di.dielength < sizeof (long)) - { - break; - } - else if (di.dietag == TAG_padding) - { - nextdie = thisdie + di.dielength; - } - else - { - completedieinfo (&di); - if (di.at_sibling != 0) - { - nextdie = dbbase + di.at_sibling - dbroff; - } - else - { - nextdie = thisdie + di.dielength; - } - switch (di.dietag) - { - case TAG_compile_unit: - read_file_scope (&di, thisdie, nextdie, objfile); - break; - case TAG_global_subroutine: - case TAG_subroutine: - if (di.has_at_low_pc) - { - read_func_scope (&di, thisdie, nextdie, objfile); - } - break; - case TAG_lexical_block: - read_lexical_block_scope (&di, thisdie, nextdie, objfile); - break; - case TAG_structure_type: - case TAG_union_type: - read_structure_scope (&di, thisdie, nextdie); - break; - case TAG_enumeration_type: - read_enumeration (&di, thisdie, nextdie); - break; - case TAG_subroutine_type: - read_subroutine_type (&di, thisdie, nextdie); - break; - case TAG_array_type: - read_array_type (&di); - break; - default: - (void) new_symbol (&di); - break; - } - } - thisdie = nextdie; - } -} - -/* - -LOCAL FUNCTION - - end_symtab -- finish processing for a compilation unit - -SYNOPSIS - - static void end_symtab (char *filename, long language) - -DESCRIPTION - - Complete the symbol table entry for the current compilation - unit. Make the struct symtab and put it on the list of all - such symtabs. - - */ - -static void -DEFUN(end_symtab, (filename, language, objfile), - char *filename AND long language AND struct objfile *objfile) -{ - struct symtab *symtab; - struct blockvector *blockvector; - int nbytes; - - /* Ignore a file that has no functions with real debugging info. */ - if (global_symbols == NULL && scopetree -> block == NULL) - { - free (line_vector); - line_vector = NULL; - line_vector_length = -1; - freescope (scopetree); - scope = scopetree = NULL; - } - - /* Create the blockvector that points to all the file's blocks. */ - - blockvector = make_blockvector (); - - /* Now create the symtab object for this source file. */ - - symtab = allocate_symtab (savestring (filename, strlen (filename)), - objfile); - - symtab -> free_ptr = 0; - - /* Fill in its components. */ - symtab -> blockvector = blockvector; - symtab -> free_code = free_linetable; - - /* Save the line number information. */ - - line_vector -> nitems = line_vector_index; - nbytes = sizeof (struct linetable); - if (line_vector_index > 1) - { - nbytes += (line_vector_index - 1) * sizeof (struct linetable_entry); - } - symtab -> linetable = (struct linetable *) xrealloc (line_vector, nbytes); - - /* FIXME: The following may need to be expanded for other languages */ - switch (language) - { - case LANG_C89: - case LANG_C: - symtab -> language = language_c; - break; - case LANG_C_PLUS_PLUS: - symtab -> language = language_cplus; - break; - default: - ; - } - - /* Link the new symtab into the list of such. */ - symtab -> next = symtab_list; - symtab_list = symtab; - - /* Recursively free the scope tree */ - freescope (scopetree); - scope = scopetree = NULL; - - /* Reinitialize for beginning of new file. */ - line_vector = 0; - line_vector_length = -1; -} - -/* - -LOCAL FUNCTION - - scopecount -- count the number of enclosed scopes - -SYNOPSIS - - static int scopecount (struct scopenode *node) - -DESCRIPTION - - Given pointer to a node, compute the size of the subtree which is - rooted in this node, which also happens to be the number of scopes - to the subtree. - */ - -static int -DEFUN(scopecount, (node), struct scopenode *node) -{ - int count = 0; - - if (node != NULL) - { - count += scopecount (node -> child); - count += scopecount (node -> sibling); - count++; - } - return (count); -} - -/* - -LOCAL FUNCTION - - openscope -- start a new lexical block scope - -SYNOPSIS - - static void openscope (struct symbol *namesym, CORE_ADDR lowpc, - CORE_ADDR highpc) - -DESCRIPTION - - Start a new scope by allocating a new scopenode, adding it as the - next child of the current scope (if any) or as the root of the - scope tree, and then making the new node the current scope node. - */ - -static void -DEFUN(openscope, (namesym, lowpc, highpc), - struct symbol *namesym AND - CORE_ADDR lowpc AND - CORE_ADDR highpc) -{ - struct scopenode *new; - struct scopenode *child; - - new = (struct scopenode *) xmalloc (sizeof (*new)); - (void) memset (new, 0, sizeof (*new)); - new -> namesym = namesym; - new -> lowpc = lowpc; - new -> highpc = highpc; - if (scope == NULL) - { - scopetree = new; - } - else if ((child = scope -> child) == NULL) - { - scope -> child = new; - new -> parent = scope; - } - else - { - while (child -> sibling != NULL) - { - child = child -> sibling; - } - child -> sibling = new; - new -> parent = scope; - } - scope = new; -} - -/* - -LOCAL FUNCTION - - freescope -- free a scope tree rooted at the given node - -SYNOPSIS - - static void freescope (struct scopenode *node) - -DESCRIPTION - - Given a pointer to a node in the scope tree, free the subtree - rooted at that node. First free all the children and sibling - nodes, and then the node itself. Used primarily for cleaning - up after ourselves and returning memory to the system. - */ - -static void -DEFUN(freescope, (node), struct scopenode *node) -{ - if (node != NULL) - { - freescope (node -> child); - freescope (node -> sibling); - free (node); - } -} - -/* - -LOCAL FUNCTION - - buildblock -- build a new block from pending symbols list - -SYNOPSIS - - static struct block *buildblock (struct pending_symbol *syms) - -DESCRIPTION - - Given a pointer to a list of symbols, build a new block and free - the symbol list structure. Also check each symbol to see if it - is the special symbol that flags that this block was compiled by - gcc, and if so, mark the block appropriately. - */ - -static struct block * -DEFUN(buildblock, (syms), struct pending_symbol *syms) -{ - struct pending_symbol *next, *next1; - int i; - struct block *newblock; - int nbytes; - - for (next = syms, i = 0 ; next ; next = next -> next, i++) {;} - - /* Allocate a new block */ - - nbytes = sizeof (struct block); - if (i > 1) - { - nbytes += (i - 1) * sizeof (struct symbol *); - } - newblock = (struct block *) obstack_alloc (symbol_obstack, nbytes); - (void) memset (newblock, 0, nbytes); - - /* Copy the symbols into the block. */ - - BLOCK_NSYMS (newblock) = i; - for (next = syms ; next ; next = next -> next) - { - BLOCK_SYM (newblock, --i) = next -> symbol; - if (STREQ (GCC_COMPILED_FLAG_SYMBOL, SYMBOL_NAME (next -> symbol)) || - STREQ (GCC2_COMPILED_FLAG_SYMBOL, SYMBOL_NAME (next -> symbol))) - { - BLOCK_GCC_COMPILED (newblock) = 1; - } - } - - /* Now free the links of the list, and empty the list. */ - - for (next = syms ; next ; next = next1) - { - next1 = next -> next; - free (next); - } - - return (newblock); -} - -/* - -LOCAL FUNCTION - - closescope -- close a lexical block scope - -SYNOPSIS - - static void closescope (void) - -DESCRIPTION - - Close the current lexical block scope. Closing the current scope - is as simple as moving the current scope pointer up to the parent - of the current scope pointer. But we also take this opportunity - to build the block for the current scope first, since we now have - all of it's symbols. - */ - -static void -DEFUN_VOID(closescope) -{ - struct scopenode *child; - - if (scope == NULL) - { - error ("DWARF parse error, too many close scopes"); - } - else - { - if (scope -> parent == NULL) - { - global_symbol_block = buildblock (global_symbols); - global_symbols = NULL; - BLOCK_START (global_symbol_block) = scope -> lowpc + baseaddr; - BLOCK_END (global_symbol_block) = scope -> highpc + baseaddr; - } - scope -> block = buildblock (scope -> symbols); - scope -> symbols = NULL; - BLOCK_START (scope -> block) = scope -> lowpc + baseaddr; - BLOCK_END (scope -> block) = scope -> highpc + baseaddr; - - /* Put the local block in as the value of the symbol that names it. */ - - if (scope -> namesym) - { - SYMBOL_BLOCK_VALUE (scope -> namesym) = scope -> block; - BLOCK_FUNCTION (scope -> block) = scope -> namesym; - } - - /* Install this scope's local block as the superblock of all child - scope blocks. */ - - for (child = scope -> child ; child ; child = child -> sibling) - { - BLOCK_SUPERBLOCK (child -> block) = scope -> block; - } - - scope = scope -> parent; - } -} - -/* - -LOCAL FUNCTION - - record_line -- record a line number entry in the line vector - -SYNOPSIS - - static void record_line (int line, CORE_ADDR pc) - -DESCRIPTION - - Given a line number and the corresponding pc value, record - this pair in the line number vector, expanding the vector as - necessary. - */ - -static void -DEFUN(record_line, (line, pc), int line AND CORE_ADDR pc) -{ - struct linetable_entry *e; - int nbytes; - - /* Make sure line vector is big enough. */ - - if (line_vector_index + 2 >= line_vector_length) - { - line_vector_length *= 2; - nbytes = sizeof (struct linetable); - nbytes += (line_vector_length * sizeof (struct linetable_entry)); - line_vector = (struct linetable *) xrealloc (line_vector, nbytes); - } - e = line_vector -> item + line_vector_index++; - e -> line = line; - e -> pc = pc; -} - -/* - -LOCAL FUNCTION - - decode_line_numbers -- decode a line number table fragment - -SYNOPSIS - - static void decode_line_numbers (char *tblscan, char *tblend, - long length, long base, long line, long pc) - -DESCRIPTION - - Translate the DWARF line number information to gdb form. - - The ".line" section contains one or more line number tables, one for - each ".line" section from the objects that were linked. - - The AT_stmt_list attribute for each TAG_source_file entry in the - ".debug" section contains the offset into the ".line" section for the - start of the table for that file. - - The table itself has the following structure: - - - 4 bytes 4 bytes 10 bytes - - The table length is the total size of the table, including the 4 bytes - for the length information. - - The base address is the address of the first instruction generated - for the source file. - - Each source statement entry has the following structure: - -
- 4 bytes 2 bytes 4 bytes - - The line number is relative to the start of the file, starting with - line 1. - - The statement position either -1 (0xFFFF) or the number of characters - from the beginning of the line to the beginning of the statement. - - The address delta is the difference between the base address and - the address of the first instruction for the statement. - - Note that we must copy the bytes from the packed table to our local - variables before attempting to use them, to avoid alignment problems - on some machines, particularly RISC processors. - -BUGS - - Does gdb expect the line numbers to be sorted? They are now by - chance/luck, but are not required to be. (FIXME) - - The line with number 0 is unused, gdb apparently can discover the - span of the last line some other way. How? (FIXME) - */ - -static void -DEFUN(decode_line_numbers, (linetable), char *linetable) -{ - char *tblscan; - char *tblend; - long length; - long base; - long line; - long pc; - - if (linetable != NULL) - { - tblscan = tblend = linetable; - (void) memcpy (&length, tblscan, sizeof (long)); - tblscan += sizeof (long); - tblend += length; - (void) memcpy (&base, tblscan, sizeof (long)); - base += baseaddr; - tblscan += sizeof (long); - while (tblscan < tblend) - { - (void) memcpy (&line, tblscan, sizeof (long)); - tblscan += sizeof (long) + sizeof (short); - (void) memcpy (&pc, tblscan, sizeof (long)); - tblscan += sizeof (long); - pc += base; - if (line > 0) - { - record_line (line, pc); - } - } - } -} - -/* - -LOCAL FUNCTION - - add_symbol_to_list -- add a symbol to head of current symbol list - -SYNOPSIS - - static void add_symbol_to_list (struct symbol *symbol, struct - pending_symbol **listhead) - -DESCRIPTION - - Given a pointer to a symbol and a pointer to a pointer to a - list of symbols, add this symbol as the current head of the - list. Typically used for example to add a symbol to the - symbol list for the current scope. - - */ - -static void -DEFUN(add_symbol_to_list, (symbol, listhead), - struct symbol *symbol AND struct pending_symbol **listhead) -{ - struct pending_symbol *link; - - if (symbol != NULL) - { - link = (struct pending_symbol *) xmalloc (sizeof (*link)); - link -> next = *listhead; - link -> symbol = symbol; - *listhead = link; - } -} - -/* - -LOCAL FUNCTION - - gatherblocks -- walk a scope tree and build block vectors - -SYNOPSIS - - static struct block **gatherblocks (struct block **dest, - struct scopenode *node) - -DESCRIPTION - - Recursively walk a scope tree rooted in the given node, adding blocks - to the array pointed to by DEST, in preorder. I.E., first we add the - block for the current scope, then all the blocks for child scopes, - and finally all the blocks for sibling scopes. - */ - -static struct block ** -DEFUN(gatherblocks, (dest, node), - struct block **dest AND struct scopenode *node) -{ - if (node != NULL) - { - *dest++ = node -> block; - dest = gatherblocks (dest, node -> child); - dest = gatherblocks (dest, node -> sibling); - } - return (dest); -} - -/* - -LOCAL FUNCTION - - make_blockvector -- make a block vector from current scope tree - -SYNOPSIS - - static struct blockvector *make_blockvector (void) - -DESCRIPTION - - Make a blockvector from all the blocks in the current scope tree. - The first block is always the global symbol block, followed by the - block for the root of the scope tree which is the local symbol block, - followed by all the remaining blocks in the scope tree, which are all - local scope blocks. - -NOTES - - Note that since the root node of the scope tree is created at the time - each file scope is entered, there are always at least two blocks, - neither of which may have any symbols, but always contribute a block - to the block vector. So the test for number of blocks greater than 1 - below is unnecessary given bug free code. - - The resulting block structure varies slightly from that produced - by dbxread.c, in that block 0 and block 1 are sibling blocks while - with dbxread.c, block 1 is a child of block 0. This does not - seem to cause any problems, but probably should be fixed. (FIXME) - */ - -static struct blockvector * -DEFUN_VOID(make_blockvector) -{ - struct blockvector *blockvector = NULL; - int i; - int nbytes; - - /* Recursively walk down the tree, counting the number of blocks. - Then add one to account for the global's symbol block */ - - i = scopecount (scopetree) + 1; - nbytes = sizeof (struct blockvector); - if (i > 1) - { - nbytes += (i - 1) * sizeof (struct block *); - } - blockvector = (struct blockvector *) - obstack_alloc (symbol_obstack, nbytes); - - /* Copy the blocks into the blockvector. */ - - BLOCKVECTOR_NBLOCKS (blockvector) = i; - BLOCKVECTOR_BLOCK (blockvector, 0) = global_symbol_block; - gatherblocks (&BLOCKVECTOR_BLOCK (blockvector, 1), scopetree); - - return (blockvector); -} - -/* - -LOCAL FUNCTION - - locval -- compute the value of a location attribute - -SYNOPSIS - - static int locval (char *loc) - -DESCRIPTION - - Given pointer to a string of bytes that define a location, compute - the location and return the value. - - When computing values involving the current value of the frame pointer, - the value zero is used, which results in a value relative to the frame - pointer, rather than the absolute value. This is what GDB wants - anyway. - - When the result is a register number, the global isreg flag is set, - otherwise it is cleared. This is a kludge until we figure out a better - way to handle the problem. Gdb's design does not mesh well with the - DWARF notion of a location computing interpreter, which is a shame - because the flexibility goes unused. - -NOTES - - Note that stack[0] is unused except as a default error return. - Note that stack overflow is not yet handled. - */ - -static int -DEFUN(locval, (loc), char *loc) -{ - unsigned short nbytes; - auto int stack[64]; - int stacki; - char *end; - long regno; - - (void) memcpy (&nbytes, loc, sizeof (short)); - end = loc + sizeof (short) + nbytes; - stacki = 0; - stack[stacki] = 0; - isreg = 0; - for (loc += sizeof (short); loc < end; loc += sizeof (long)) - { - switch (*loc++) { - case 0: - /* error */ - loc = end; - break; - case OP_REG: - /* push register (number) */ - (void) memcpy (&stack[++stacki], loc, sizeof (long)); - isreg = 1; - break; - case OP_BASEREG: - /* push value of register (number) */ - /* Actually, we compute the value as if register has 0 */ - (void) memcpy (®no, loc, sizeof (long)); - if (regno == R_FP) - { - stack[++stacki] = 0; - } - else - { - stack[++stacki] = 0; - SQUAWK (("BASEREG %d not handled!", regno)); - } - break; - case OP_ADDR: - /* push address (relocated address) */ - (void) memcpy (&stack[++stacki], loc, sizeof (long)); - break; - case OP_CONST: - /* push constant (number) */ - (void) memcpy (&stack[++stacki], loc, sizeof (long)); - break; - case OP_DEREF2: - /* pop, deref and push 2 bytes (as a long) */ - SQUAWK (("OP_DEREF2 address %#x not handled", stack[stacki])); - break; - case OP_DEREF4: /* pop, deref and push 4 bytes (as a long) */ - SQUAWK (("OP_DEREF4 address %#x not handled", stack[stacki])); - break; - case OP_ADD: /* pop top 2 items, add, push result */ - stack[stacki - 1] += stack[stacki]; - stacki--; - break; - } - } - return (stack[stacki]); -} - -/* - -LOCAL FUNCTION - - read_ofile_symtab -- build a full symtab entry from chunk of DIE's - -SYNOPSIS - - static struct symtab *read_ofile_symtab (struct partial_symtab *pst) - -DESCRIPTION - - OFFSET is a relocation offset which gets added to each symbol (FIXME). - */ - -static struct symtab * -DEFUN(read_ofile_symtab, (pst), - struct partial_symtab *pst) -{ - struct cleanup *back_to; - long lnsize; - int foffset; - bfd *abfd = pst->objfile->obfd; - - /* Allocate a buffer for the entire chunk of DIE's for this compilation - unit, seek to the location in the file, and read in all the DIE's. */ - - diecount = 0; - dbbase = xmalloc (DBLENGTH(pst)); - dbroff = DBROFF(pst); - foffset = DBFOFF(pst) + dbroff; - if (bfd_seek (abfd, foffset, 0) || - (bfd_read (dbbase, DBLENGTH(pst), 1, abfd) != DBLENGTH(pst))) - { - free (dbbase); - error ("can't read DWARF data"); - } - back_to = make_cleanup (free, dbbase); - - /* If there is a line number table associated with this compilation unit - then read the first long word from the line number table fragment, which - contains the size of the fragment in bytes (including the long word - itself). Allocate a buffer for the fragment and read it in for future - processing. */ - - lnbase = NULL; - if (LNFOFF (pst)) - { - if (bfd_seek (abfd, LNFOFF (pst), 0) || - (bfd_read (&lnsize, sizeof(long), 1, abfd) != sizeof(long))) - { - error ("can't read DWARF line number table size"); - } - lnbase = xmalloc (lnsize); - if (bfd_seek (abfd, LNFOFF (pst), 0) || - (bfd_read (lnbase, lnsize, 1, abfd) != lnsize)) - { - free (lnbase); - error ("can't read DWARF line numbers"); - } - make_cleanup (free, lnbase); - } - - process_dies (dbbase, dbbase + DBLENGTH(pst), pst->objfile); - do_cleanups (back_to); - return (symtab_list); -} - -/* - -LOCAL FUNCTION - - psymtab_to_symtab_1 -- do grunt work for building a full symtab entry - -SYNOPSIS - - static void psymtab_to_symtab_1 (struct partial_symtab *pst) - -DESCRIPTION - - Called once for each partial symbol table entry that needs to be - expanded into a full symbol table entry. - -*/ - -static void -DEFUN(psymtab_to_symtab_1, - (pst), - struct partial_symtab *pst) -{ - int i; - - if (!pst) - { - return; - } - if (pst->readin) - { - fprintf (stderr, "Psymtab for %s already read in. Shouldn't happen.\n", - pst -> filename); - return; - } - - /* Read in all partial symtabs on which this one is dependent */ - for (i = 0; i < pst -> number_of_dependencies; i++) - if (!pst -> dependencies[i] -> readin) - { - /* Inform about additional files that need to be read in. */ - if (info_verbose) - { - fputs_filtered (" ", stdout); - wrap_here (""); - fputs_filtered ("and ", stdout); - wrap_here (""); - printf_filtered ("%s...", pst -> dependencies[i] -> filename); - wrap_here (""); /* Flush output */ - fflush (stdout); - } - psymtab_to_symtab_1 (pst -> dependencies[i]); - } - - if (DBLENGTH(pst)) /* Otherwise it's a dummy */ - { - /* Init stuff necessary for reading in symbols */ - pst -> symtab = read_ofile_symtab (pst); - if (info_verbose) - { - printf_filtered ("%d DIE's, sorting...", diecount); - fflush (stdout); - } - sort_symtab_syms (pst -> symtab); - } - pst -> readin = 1; -} - -/* - -LOCAL FUNCTION - - dwarf_psymtab_to_symtab -- build a full symtab entry from partial one - -SYNOPSIS - - static void dwarf_psymtab_to_symtab (struct partial_symtab *pst) - -DESCRIPTION - - This is the DWARF support entry point for building a full symbol - table entry from a partial symbol table entry. We are passed a - pointer to the partial symbol table entry that needs to be expanded. - -*/ - -static void -DEFUN(dwarf_psymtab_to_symtab, (pst), struct partial_symtab *pst) -{ - int desc; - bfd *sym_bfd; - - if (!pst) - { - return; - } - if (pst -> readin) - { - fprintf (stderr, "Psymtab for %s already read in. Shouldn't happen.\n", - pst -> filename); - return; - } - - if (DBLENGTH(pst) || pst -> number_of_dependencies) - { - /* Print the message now, before starting serious work, to avoid - disconcerting pauses. */ - if (info_verbose) - { - printf_filtered ("Reading in symbols for %s...", pst -> filename); - fflush (stdout); - } - - psymtab_to_symtab_1 (pst); - -#if 0 /* FIXME: Check to see what dbxread is doing here and see if - we need to do an equivalent or is this something peculiar to - stabs/a.out format. */ - /* Match with global symbols. This only needs to be done once, - after all of the symtabs and dependencies have been read in. */ - scan_file_globals (); -#endif - - /* Finish up the debug error message. */ - if (info_verbose) - { - printf_filtered ("done.\n"); - } - } -} - -/* - -LOCAL FUNCTION - - init_psymbol_list -- initialize storage for partial symbols - -SYNOPSIS - - static void init_psymbol_list (int total_symbols) - -DESCRIPTION - - Initializes storage for all of the partial symbols that will be - created by dwarf_build_psymtabs and subsidiaries. - */ - -static void -DEFUN(init_psymbol_list, (total_symbols), int total_symbols) -{ - /* Free any previously allocated psymbol lists. */ - - if (global_psymbols.list) - { - free (global_psymbols.list); - } - if (static_psymbols.list) - { - free (static_psymbols.list); - } - - /* Current best guess is that there are approximately a twentieth - of the total symbols (in a debugging file) are global or static - oriented symbols */ - - global_psymbols.size = total_symbols / 10; - static_psymbols.size = total_symbols / 10; - global_psymbols.next = global_psymbols.list = (struct partial_symbol *) - xmalloc (global_psymbols.size * sizeof (struct partial_symbol)); - static_psymbols.next = static_psymbols.list = (struct partial_symbol *) - xmalloc (static_psymbols.size * sizeof (struct partial_symbol)); -} - -/* - -LOCAL FUNCTION - - start_psymtab -- allocate and partially fill a partial symtab entry - -DESCRIPTION - - Allocate and partially fill a partial symtab. It will be completely - filled at the end of the symbol list. - - SYMFILE_NAME is the name of the symbol-file we are reading from, and - ADDR is the address relative to which its symbols are (incremental) - or 0 (normal). FILENAME is the name of the compilation unit that - these symbols were defined in, and they appear starting a address - TEXTLOW. DBROFF is the absolute file offset in SYMFILE_NAME where - the full symbols can be read for compilation unit FILENAME. - GLOBAL_SYMS and STATIC_SYMS are pointers to the current end of the - psymtab vector. - - */ - -static struct partial_symtab * -DEFUN(start_psymtab, - (objfile, addr, filename, textlow, texthigh, dbfoff, curoff, - culength, lnfoff, global_syms, static_syms), - struct objfile *objfile AND - CORE_ADDR addr AND - char *filename AND - CORE_ADDR textlow AND - CORE_ADDR texthigh AND - int dbfoff AND - int curoff AND - int culength AND - int lnfoff AND - struct partial_symbol *global_syms AND - struct partial_symbol *static_syms) -{ - struct partial_symtab *result; - - result = (struct partial_symtab *) - obstack_alloc (psymbol_obstack, sizeof (struct partial_symtab)); - (void) memset (result, 0, sizeof (struct partial_symtab)); - result -> addr = addr; - result -> objfile = objfile; - result -> filename = create_name (filename, psymbol_obstack); - result -> textlow = textlow; - result -> texthigh = texthigh; - result -> read_symtab_private = (char *) obstack_alloc (psymbol_obstack, - sizeof (struct dwfinfo)); - DBFOFF (result) = dbfoff; - DBROFF (result) = curoff; - DBLENGTH (result) = culength; - LNFOFF (result) = lnfoff; - result -> readin = 0; - result -> symtab = NULL; - result -> read_symtab = dwarf_psymtab_to_symtab; - result -> globals_offset = global_syms - global_psymbols.list; - result -> statics_offset = static_syms - static_psymbols.list; - - result->n_global_syms = 0; - result->n_static_syms = 0; - - return result; -} - -/* - -LOCAL FUNCTION - - add_psymbol_to_list -- add a partial symbol to given list - -DESCRIPTION - - Add a partial symbol to one of the partial symbol vectors (pointed to - by listp). The vector is grown as necessary. - - */ - -static void -DEFUN(add_psymbol_to_list, - (listp, name, space, class, value), - struct psymbol_allocation_list *listp AND - char *name AND - enum namespace space AND - enum address_class class AND - CORE_ADDR value) -{ - struct partial_symbol *psym; - int newsize; - - if (listp -> next >= listp -> list + listp -> size) - { - newsize = listp -> size * 2; - listp -> list = (struct partial_symbol *) - xrealloc (listp -> list, (newsize * sizeof (struct partial_symbol))); - /* Next assumes we only went one over. Should be good if program works - correctly */ - listp -> next = listp -> list + listp -> size; - listp -> size = newsize; - } - psym = listp -> next++; - SYMBOL_NAME (psym) = create_name (name, psymbol_obstack); - SYMBOL_NAMESPACE (psym) = space; - SYMBOL_CLASS (psym) = class; - SYMBOL_VALUE (psym) = value; -} - -/* - -LOCAL FUNCTION - - add_partial_symbol -- add symbol to partial symbol table - -DESCRIPTION - - Given a DIE, if it is one of the types that we want to - add to a partial symbol table, finish filling in the die info - and then add a partial symbol table entry for it. - -*/ - -static void -DEFUN(add_partial_symbol, (dip), struct dieinfo *dip) -{ - switch (dip -> dietag) - { - case TAG_global_subroutine: - record_misc_function (dip -> at_name, dip -> at_low_pc, mf_text); - add_psymbol_to_list (&global_psymbols, dip -> at_name, VAR_NAMESPACE, - LOC_BLOCK, dip -> at_low_pc); - break; - case TAG_global_variable: - record_misc_function (dip -> at_name, locval (dip -> at_location), - mf_data); - add_psymbol_to_list (&global_psymbols, dip -> at_name, VAR_NAMESPACE, - LOC_STATIC, 0); - break; - case TAG_subroutine: - add_psymbol_to_list (&static_psymbols, dip -> at_name, VAR_NAMESPACE, - LOC_BLOCK, dip -> at_low_pc); - break; - case TAG_local_variable: - add_psymbol_to_list (&static_psymbols, dip -> at_name, VAR_NAMESPACE, - LOC_STATIC, 0); - break; - case TAG_typedef: - add_psymbol_to_list (&static_psymbols, dip -> at_name, VAR_NAMESPACE, - LOC_TYPEDEF, 0); - break; - case TAG_structure_type: - case TAG_union_type: - case TAG_enumeration_type: - add_psymbol_to_list (&static_psymbols, dip -> at_name, STRUCT_NAMESPACE, - LOC_TYPEDEF, 0); - break; - } -} - -/* - -LOCAL FUNCTION - - scan_partial_symbols -- scan DIE's within a single compilation unit - -DESCRIPTION - - Process the DIE's within a single compilation unit, looking for - interesting DIE's that contribute to the partial symbol table entry - for this compilation unit. Since we cannot follow any sibling - chains without reading the complete DIE info for every DIE, - it is probably faster to just sequentially check each one to - see if it is one of the types we are interested in, and if - so, then extracting all the attributes info and generating a - partial symbol table entry. - -NOTES - - Don't attempt to add anonymous structures, unions, or enumerations - since they have no name. Also, for variables and subroutines, - check that this is the place where the actual definition occurs, - rather than just a reference to an external. - - */ - -static void -DEFUN(scan_partial_symbols, (thisdie, enddie), char *thisdie AND char *enddie) -{ - char *nextdie; - struct dieinfo di; - - while (thisdie < enddie) - { - basicdieinfo (&di, thisdie); - if (di.dielength < sizeof (long)) - { - break; - } - else - { - nextdie = thisdie + di.dielength; - switch (di.dietag) - { - case TAG_global_subroutine: - case TAG_subroutine: - case TAG_global_variable: - case TAG_local_variable: - completedieinfo (&di); - if (di.at_name && (di.has_at_low_pc || di.at_location)) - { - add_partial_symbol (&di); - } - break; - case TAG_typedef: - case TAG_structure_type: - case TAG_union_type: - case TAG_enumeration_type: - completedieinfo (&di); - if (di.at_name) - { - add_partial_symbol (&di); - } - break; - } - } - thisdie = nextdie; - } -} - -/* - -LOCAL FUNCTION - - scan_compilation_units -- build a psymtab entry for each compilation - -DESCRIPTION - - This is the top level dwarf parsing routine for building partial - symbol tables. - - It scans from the beginning of the DWARF table looking for the first - TAG_compile_unit DIE, and then follows the sibling chain to locate - each additional TAG_compile_unit DIE. - - For each TAG_compile_unit DIE it creates a partial symtab structure, - calls a subordinate routine to collect all the compilation unit's - global DIE's, file scope DIEs, typedef DIEs, etc, and then links the - new partial symtab structure into the partial symbol table. It also - records the appropriate information in the partial symbol table entry - to allow the chunk of DIE's and line number table for this compilation - unit to be located and re-read later, to generate a complete symbol - table entry for the compilation unit. - - Thus it effectively partitions up a chunk of DIE's for multiple - compilation units into smaller DIE chunks and line number tables, - and associates them with a partial symbol table entry. - -NOTES - - If any compilation unit has no line number table associated with - it for some reason (a missing at_stmt_list attribute, rather than - just one with a value of zero, which is valid) then we ensure that - the recorded file offset is zero so that the routine which later - reads line number table fragments knows that there is no fragment - to read. - -RETURNS - - Returns no value. - - */ - -static void -DEFUN(scan_compilation_units, - (filename, addr, thisdie, enddie, dbfoff, lnoffset, objfile), - char *filename AND - CORE_ADDR addr AND - char *thisdie AND - char *enddie AND - unsigned int dbfoff AND - unsigned int lnoffset AND - struct objfile *objfile) -{ - char *nextdie; - struct dieinfo di; - struct partial_symtab *pst; - int culength; - int curoff; - int curlnoffset; - - while (thisdie < enddie) - { - basicdieinfo (&di, thisdie); - if (di.dielength < sizeof (long)) - { - break; - } - else if (di.dietag != TAG_compile_unit) - { - nextdie = thisdie + di.dielength; - } - else - { - completedieinfo (&di); - if (di.at_sibling != 0) - { - nextdie = dbbase + di.at_sibling - dbroff; - } - else - { - nextdie = thisdie + di.dielength; - } - curoff = thisdie - dbbase; - culength = nextdie - thisdie; - curlnoffset = di.has_at_stmt_list ? lnoffset + di.at_stmt_list : 0; - pst = start_psymtab (objfile, addr, di.at_name, - di.at_low_pc, di.at_high_pc, - dbfoff, curoff, culength, curlnoffset, - global_psymbols.next, - static_psymbols.next); - scan_partial_symbols (thisdie + di.dielength, nextdie); - pst -> n_global_syms = global_psymbols.next - - (global_psymbols.list + pst -> globals_offset); - pst -> n_static_syms = static_psymbols.next - - (static_psymbols.list + pst -> statics_offset); - /* Sort the global list; don't sort the static list */ - qsort (global_psymbols.list + pst -> globals_offset, - pst -> n_global_syms, sizeof (struct partial_symbol), - compare_psymbols); - /* If there is already a psymtab or symtab for a file of this name, - remove it. (If there is a symtab, more drastic things also - happen.) This happens in VxWorks. */ - free_named_symtabs (pst -> filename); - /* Place the partial symtab on the partial symtab list */ - pst -> next = partial_symtab_list; - partial_symtab_list = pst; - } - thisdie = nextdie; - } -} - -/* - -LOCAL FUNCTION - - new_symbol -- make a symbol table entry for a new symbol - -SYNOPSIS - - static struct symbol *new_symbol (struct dieinfo *dip) - -DESCRIPTION - - Given a pointer to a DWARF information entry, figure out if we need - to make a symbol table entry for it, and if so, create a new entry - and return a pointer to it. - */ - -static struct symbol * -DEFUN(new_symbol, (dip), struct dieinfo *dip) -{ - struct symbol *sym = NULL; - - if (dip -> at_name != NULL) - { - sym = (struct symbol *) obstack_alloc (symbol_obstack, - sizeof (struct symbol)); - (void) memset (sym, 0, sizeof (struct symbol)); - SYMBOL_NAME (sym) = create_name (dip -> at_name, symbol_obstack); - /* default assumptions */ - SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; - SYMBOL_CLASS (sym) = LOC_STATIC; - SYMBOL_TYPE (sym) = decode_die_type (dip); - switch (dip -> dietag) - { - case TAG_label: - SYMBOL_VALUE (sym) = dip -> at_low_pc + baseaddr; - SYMBOL_CLASS (sym) = LOC_LABEL; - break; - case TAG_global_subroutine: - case TAG_subroutine: - SYMBOL_VALUE (sym) = dip -> at_low_pc + baseaddr; - SYMBOL_TYPE (sym) = lookup_function_type (SYMBOL_TYPE (sym)); - SYMBOL_CLASS (sym) = LOC_BLOCK; - if (dip -> dietag == TAG_global_subroutine) - { - add_symbol_to_list (sym, &global_symbols); - } - else - { - add_symbol_to_list (sym, &scope -> symbols); - } - break; - case TAG_global_variable: - case TAG_local_variable: - if (dip -> at_location != NULL) - { - SYMBOL_VALUE (sym) = locval (dip -> at_location); - } - if (dip -> dietag == TAG_global_variable) - { - add_symbol_to_list (sym, &global_symbols); - SYMBOL_CLASS (sym) = LOC_STATIC; - SYMBOL_VALUE (sym) += baseaddr; - } - else - { - add_symbol_to_list (sym, &scope -> symbols); - if (scope -> parent != NULL) - { - if (isreg) - { - SYMBOL_CLASS (sym) = LOC_REGISTER; - } - else - { - SYMBOL_CLASS (sym) = LOC_LOCAL; - } - } - else - { - SYMBOL_CLASS (sym) = LOC_STATIC; - SYMBOL_VALUE (sym) += baseaddr; - } - } - break; - case TAG_formal_parameter: - if (dip -> at_location != NULL) - { - SYMBOL_VALUE (sym) = locval (dip -> at_location); - } - add_symbol_to_list (sym, &scope -> symbols); - if (isreg) - { - SYMBOL_CLASS (sym) = LOC_REGPARM; - } - else - { - SYMBOL_CLASS (sym) = LOC_ARG; - } - break; - case TAG_unspecified_parameters: - /* From varargs functions; gdb doesn't seem to have any interest in - this information, so just ignore it for now. (FIXME?) */ - break; - case TAG_structure_type: - case TAG_union_type: - case TAG_enumeration_type: - SYMBOL_CLASS (sym) = LOC_TYPEDEF; - SYMBOL_NAMESPACE (sym) = STRUCT_NAMESPACE; - add_symbol_to_list (sym, &scope -> symbols); - break; - case TAG_typedef: - SYMBOL_CLASS (sym) = LOC_TYPEDEF; - SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; - add_symbol_to_list (sym, &scope -> symbols); - break; - default: - /* Not a tag we recognize. Hopefully we aren't processing trash - data, but since we must specifically ignore things we don't - recognize, there is nothing else we should do at this point. */ - break; - } - } - return (sym); -} - -/* - -LOCAL FUNCTION - - decode_mod_fund_type -- decode a modified fundamental type - -SYNOPSIS - - static struct type *decode_mod_fund_type (char *typedata) - -DESCRIPTION - - Decode a block of data containing a modified fundamental - type specification. TYPEDATA is a pointer to the block, - which consists of a two byte length, containing the size - of the rest of the block. At the end of the block is a - two byte value that gives the fundamental type. Everything - in between are type modifiers. - - We simply compute the number of modifiers and call the general - function decode_modified_type to do the actual work. -*/ - -static struct type * -DEFUN(decode_mod_fund_type, (typedata), char *typedata) -{ - struct type *typep = NULL; - unsigned short modcount; - unsigned char *modifiers; - - /* Get the total size of the block, exclusive of the size itself */ - (void) memcpy (&modcount, typedata, sizeof (short)); - /* Deduct the size of the fundamental type bytes at the end of the block. */ - modcount -= sizeof (short); - /* Skip over the two size bytes at the beginning of the block. */ - modifiers = (unsigned char *) typedata + sizeof (short); - /* Now do the actual decoding */ - typep = decode_modified_type (modifiers, modcount, AT_mod_fund_type); - return (typep); -} - -/* - -LOCAL FUNCTION - - decode_mod_u_d_type -- decode a modified user defined type - -SYNOPSIS - - static struct type *decode_mod_u_d_type (char *typedata) - -DESCRIPTION - - Decode a block of data containing a modified user defined - type specification. TYPEDATA is a pointer to the block, - which consists of a two byte length, containing the size - of the rest of the block. At the end of the block is a - four byte value that gives a reference to a user defined type. - Everything in between are type modifiers. - - We simply compute the number of modifiers and call the general - function decode_modified_type to do the actual work. -*/ - -static struct type * -DEFUN(decode_mod_u_d_type, (typedata), char *typedata) -{ - struct type *typep = NULL; - unsigned short modcount; - unsigned char *modifiers; - - /* Get the total size of the block, exclusive of the size itself */ - (void) memcpy (&modcount, typedata, sizeof (short)); - /* Deduct the size of the reference type bytes at the end of the block. */ - modcount -= sizeof (long); - /* Skip over the two size bytes at the beginning of the block. */ - modifiers = (unsigned char *) typedata + sizeof (short); - /* Now do the actual decoding */ - typep = decode_modified_type (modifiers, modcount, AT_mod_u_d_type); - return (typep); -} - -/* - -LOCAL FUNCTION - - decode_modified_type -- decode modified user or fundamental type - -SYNOPSIS - - static struct type *decode_modified_type (unsigned char *modifiers, - unsigned short modcount, int mtype) - -DESCRIPTION - - Decode a modified type, either a modified fundamental type or - a modified user defined type. MODIFIERS is a pointer to the - block of bytes that define MODCOUNT modifiers. Immediately - following the last modifier is a short containing the fundamental - type or a long containing the reference to the user defined - type. Which one is determined by MTYPE, which is either - AT_mod_fund_type or AT_mod_u_d_type to indicate what modified - type we are generating. - - We call ourself recursively to generate each modified type,` - until MODCOUNT reaches zero, at which point we have consumed - all the modifiers and generate either the fundamental type or - user defined type. When the recursion unwinds, each modifier - is applied in turn to generate the full modified type. - -NOTES - - If we find a modifier that we don't recognize, and it is not one - of those reserved for application specific use, then we issue a - warning and simply ignore the modifier. - -BUGS - - We currently ignore MOD_const and MOD_volatile. (FIXME) - - */ - -static struct type * -DEFUN(decode_modified_type, - (modifiers, modcount, mtype), - unsigned char *modifiers AND unsigned short modcount AND int mtype) -{ - struct type *typep = NULL; - unsigned short fundtype; - DIEREF dieref; - unsigned char modifier; - - if (modcount == 0) - { - switch (mtype) - { - case AT_mod_fund_type: - (void) memcpy (&fundtype, modifiers, sizeof (short)); - typep = decode_fund_type (fundtype); - break; - case AT_mod_u_d_type: - (void) memcpy (&dieref, modifiers, sizeof (DIEREF)); - if ((typep = lookup_utype (dieref)) == NULL) - { - typep = alloc_utype (dieref, NULL); - } - break; - default: - SQUAWK (("botched modified type decoding (mtype 0x%x)", mtype)); - typep = builtin_type_int; - break; - } - } - else - { - modifier = *modifiers++; - typep = decode_modified_type (modifiers, --modcount, mtype); - switch (modifier) - { - case MOD_pointer_to: - typep = lookup_pointer_type (typep); - break; - case MOD_reference_to: - typep = lookup_reference_type (typep); - break; - case MOD_const: - SQUAWK (("type modifier 'const' ignored")); /* FIXME */ - break; - case MOD_volatile: - SQUAWK (("type modifier 'volatile' ignored")); /* FIXME */ - break; - default: - if (!(MOD_lo_user <= modifier && modifier <= MOD_hi_user)) - { - SQUAWK (("unknown type modifier %u", modifier)); - } - break; - } - } - return (typep); -} - -/* - -LOCAL FUNCTION - - decode_fund_type -- translate basic DWARF type to gdb base type - -DESCRIPTION - - Given an integer that is one of the fundamental DWARF types, - translate it to one of the basic internal gdb types and return - a pointer to the appropriate gdb type (a "struct type *"). - -NOTES - - If we encounter a fundamental type that we are unprepared to - deal with, and it is not in the range of those types defined - as application specific types, then we issue a warning and - treat the type as builtin_type_int. -*/ - -static struct type * -DEFUN(decode_fund_type, (fundtype), unsigned short fundtype) -{ - struct type *typep = NULL; - - switch (fundtype) - { - - case FT_void: - typep = builtin_type_void; - break; - - case FT_pointer: /* (void *) */ - typep = lookup_pointer_type (builtin_type_void); - break; - - case FT_char: - case FT_signed_char: - typep = builtin_type_char; - break; - - case FT_short: - case FT_signed_short: - typep = builtin_type_short; - break; - - case FT_integer: - case FT_signed_integer: - case FT_boolean: /* Was FT_set in AT&T version */ - typep = builtin_type_int; - break; - - case FT_long: - case FT_signed_long: - typep = builtin_type_long; - break; - - case FT_float: - typep = builtin_type_float; - break; - - case FT_dbl_prec_float: - typep = builtin_type_double; - break; - - case FT_unsigned_char: - typep = builtin_type_unsigned_char; - break; - - case FT_unsigned_short: - typep = builtin_type_unsigned_short; - break; - - case FT_unsigned_integer: - typep = builtin_type_unsigned_int; - break; - - case FT_unsigned_long: - typep = builtin_type_unsigned_long; - break; - - case FT_ext_prec_float: - typep = builtin_type_long_double; - break; - - case FT_complex: - typep = builtin_type_complex; - break; - - case FT_dbl_prec_complex: - typep = builtin_type_double_complex; - break; - - case FT_long_long: - case FT_signed_long_long: - typep = builtin_type_long_long; - break; - - case FT_unsigned_long_long: - typep = builtin_type_unsigned_long_long; - break; - - } - - if ((typep == NULL) && !(FT_lo_user <= fundtype && fundtype <= FT_hi_user)) - { - SQUAWK (("unexpected fundamental type 0x%x", fundtype)); - typep = builtin_type_void; - } - - return (typep); -} - -/* - -LOCAL FUNCTION - - create_name -- allocate a fresh copy of a string on an obstack - -DESCRIPTION - - Given a pointer to a string and a pointer to an obstack, allocates - a fresh copy of the string on the specified obstack. - -*/ - -static char * -DEFUN(create_name, (name, obstackp), char *name AND struct obstack *obstackp) -{ - int length; - char *newname; - - length = strlen (name) + 1; - newname = (char *) obstack_alloc (obstackp, length); - (void) strcpy (newname, name); - return (newname); -} - -/* - -LOCAL FUNCTION - - basicdieinfo -- extract the minimal die info from raw die data - -SYNOPSIS - - void basicdieinfo (char *diep, struct dieinfo *dip) - -DESCRIPTION - - Given a pointer to raw DIE data, and a pointer to an instance of a - die info structure, this function extracts the basic information - from the DIE data required to continue processing this DIE, along - with some bookkeeping information about the DIE. - - The information we absolutely must have includes the DIE tag, - and the DIE length. If we need the sibling reference, then we - will have to call completedieinfo() to process all the remaining - DIE information. - - Note that since there is no guarantee that the data is properly - aligned in memory for the type of access required (indirection - through anything other than a char pointer), we use memcpy to - shuffle data items larger than a char. Possibly inefficient, but - quite portable. - - We also take care of some other basic things at this point, such - as ensuring that the instance of the die info structure starts - out completely zero'd and that curdie is initialized for use - in error reporting if we have a problem with the current die. - -NOTES - - All DIE's must have at least a valid length, thus the minimum - DIE size is sizeof (long). In order to have a valid tag, the - DIE size must be at least sizeof (short) larger, otherwise they - are forced to be TAG_padding DIES. - - Padding DIES must be at least sizeof(long) in length, implying that - if a padding DIE is used for alignment and the amount needed is less - than sizeof(long) then the padding DIE has to be big enough to align - to the next alignment boundry. - */ - -static void -DEFUN(basicdieinfo, (dip, diep), struct dieinfo *dip AND char *diep) -{ - curdie = dip; - (void) memset (dip, 0, sizeof (struct dieinfo)); - dip -> die = diep; - dip -> dieref = dbroff + (diep - dbbase); - (void) memcpy (&dip -> dielength, diep, sizeof (long)); - if (dip -> dielength < sizeof (long)) - { - dwarfwarn ("malformed DIE, bad length (%d bytes)", dip -> dielength); - } - else if (dip -> dielength < (sizeof (long) + sizeof (short))) - { - dip -> dietag = TAG_padding; - } - else - { - (void) memcpy (&dip -> dietag, diep + sizeof (long), sizeof (short)); - } -} - -/* - -LOCAL FUNCTION - - completedieinfo -- finish reading the information for a given DIE - -SYNOPSIS - - void completedieinfo (struct dieinfo *dip) - -DESCRIPTION - - Given a pointer to an already partially initialized die info structure, - scan the raw DIE data and finish filling in the die info structure - from the various attributes found. - - Note that since there is no guarantee that the data is properly - aligned in memory for the type of access required (indirection - through anything other than a char pointer), we use memcpy to - shuffle data items larger than a char. Possibly inefficient, but - quite portable. - -NOTES - - Each time we are called, we increment the diecount variable, which - keeps an approximate count of the number of dies processed for - each compilation unit. This information is presented to the user - if the info_verbose flag is set. - - */ - -static void -DEFUN(completedieinfo, (dip), struct dieinfo *dip) -{ - char *diep; /* Current pointer into raw DIE data */ - char *end; /* Terminate DIE scan here */ - unsigned short attr; /* Current attribute being scanned */ - unsigned short form; /* Form of the attribute */ - short block2sz; /* Size of a block2 attribute field */ - long block4sz; /* Size of a block4 attribute field */ - - diecount++; - diep = dip -> die; - end = diep + dip -> dielength; - diep += sizeof (long) + sizeof (short); - while (diep < end) - { - (void) memcpy (&attr, diep, sizeof (short)); - diep += sizeof (short); - switch (attr) - { - case AT_fund_type: - (void) memcpy (&dip -> at_fund_type, diep, sizeof (short)); - break; - case AT_ordering: - (void) memcpy (&dip -> at_ordering, diep, sizeof (short)); - break; - case AT_bit_offset: - (void) memcpy (&dip -> at_bit_offset, diep, sizeof (short)); - break; - case AT_visibility: - (void) memcpy (&dip -> at_visibility, diep, sizeof (short)); - break; - case AT_sibling: - (void) memcpy (&dip -> at_sibling, diep, sizeof (long)); - break; - case AT_stmt_list: - (void) memcpy (&dip -> at_stmt_list, diep, sizeof (long)); - dip -> has_at_stmt_list = 1; - break; - case AT_low_pc: - (void) memcpy (&dip -> at_low_pc, diep, sizeof (long)); - dip -> has_at_low_pc = 1; - break; - case AT_high_pc: - (void) memcpy (&dip -> at_high_pc, diep, sizeof (long)); - break; - case AT_language: - (void) memcpy (&dip -> at_language, diep, sizeof (long)); - break; - case AT_user_def_type: - (void) memcpy (&dip -> at_user_def_type, diep, sizeof (long)); - break; - case AT_byte_size: - (void) memcpy (&dip -> at_byte_size, diep, sizeof (long)); - break; - case AT_bit_size: - (void) memcpy (&dip -> at_bit_size, diep, sizeof (long)); - break; - case AT_member: - (void) memcpy (&dip -> at_member, diep, sizeof (long)); - break; - case AT_discr: - (void) memcpy (&dip -> at_discr, diep, sizeof (long)); - break; - case AT_import: - (void) memcpy (&dip -> at_import, diep, sizeof (long)); - break; - case AT_location: - dip -> at_location = diep; - break; - case AT_mod_fund_type: - dip -> at_mod_fund_type = diep; - break; - case AT_subscr_data: - dip -> at_subscr_data = diep; - break; - case AT_mod_u_d_type: - dip -> at_mod_u_d_type = diep; - break; - case AT_element_list: - dip -> at_element_list = diep; - break; - case AT_discr_value: - dip -> at_discr_value = diep; - break; - case AT_string_length: - dip -> at_string_length = diep; - break; - case AT_name: - dip -> at_name = diep; - break; - case AT_comp_dir: - dip -> at_comp_dir = diep; - break; - case AT_producer: - dip -> at_producer = diep; - break; - case AT_frame_base: - (void) memcpy (&dip -> at_frame_base, diep, sizeof (long)); - break; - case AT_start_scope: - (void) memcpy (&dip -> at_start_scope, diep, sizeof (long)); - break; - case AT_stride_size: - (void) memcpy (&dip -> at_stride_size, diep, sizeof (long)); - break; - case AT_src_info: - (void) memcpy (&dip -> at_src_info, diep, sizeof (long)); - break; - case AT_prototyped: - (void) memcpy (&dip -> at_prototyped, diep, sizeof (short)); - break; - default: - /* Found an attribute that we are unprepared to handle. However - it is specifically one of the design goals of DWARF that - consumers should ignore unknown attributes. As long as the - form is one that we recognize (so we know how to skip it), - we can just ignore the unknown attribute. */ - break; - } - form = attr & 0xF; - switch (form) - { - case FORM_DATA2: - diep += sizeof (short); - break; - case FORM_DATA4: - diep += sizeof (long); - break; - case FORM_DATA8: - diep += 8 * sizeof (char); /* sizeof (long long) ? */ - break; - case FORM_ADDR: - case FORM_REF: - diep += sizeof (long); - break; - case FORM_BLOCK2: - (void) memcpy (&block2sz, diep, sizeof (short)); - block2sz += sizeof (short); - diep += block2sz; - break; - case FORM_BLOCK4: - (void) memcpy (&block4sz, diep, sizeof (long)); - block4sz += sizeof (long); - diep += block4sz; - break; - case FORM_STRING: - diep += strlen (diep) + 1; - break; - default: - SQUAWK (("unknown attribute form (0x%x), skipped rest", form)); - diep = end; - break; - } - } -} diff --git a/gdb/elfread.c b/gdb/elfread.c deleted file mode 100644 index d203e2e9b58..00000000000 --- a/gdb/elfread.c +++ /dev/null @@ -1,293 +0,0 @@ -/* Read ELF (Executable and Linking Format) object files for GDB. - Copyright (C) 1991 Free Software Foundation, Inc. - Written by Fred Fish at 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/************************************************************************ - * * - * NOTICE * - * * - * This file is still under construction. When it is complete, this * - * notice will be removed. Until then, direct any questions or changes * - * to Fred Fish at Cygnus Support (fnf@cygint) * - * * - * FIXME Still needs support for shared libraries. * - * FIXME Still needs support for core files. * - * FIXME The ".debug" and ".line" section names are hardwired. * - * FIXME Still needs support ELF symbol tables (as distinct * - * from DWARF support). Can use them to build the misc * - * function vector at least. This is fairly trivial once * - * bfd is extended to handle ELF symbol tables. * - * * - ************************************************************************/ - -#include - -#include "defs.h" -#include "param.h" -#include "elf-common.h" -#include "elf-external.h" -#include "elf-internal.h" -#include "bfd.h" -#include "symfile.h" -#include "symtab.h" -#include "ansidecl.h" - -extern int EXFUN (strcmp, (CONST char *a, CONST char *b)); -extern int EXFUN (dwarf_build_psymtabs, - (int desc, char *filename, CORE_ADDR addr, int mainline, - unsigned int dbfoff, unsigned int dbsize, unsigned int lnoffset, - unsigned int lnsize, struct objfile *objfile)); - -#define STREQ(a,b) (strcmp((a),(b))==0) - -struct elfinfo { - unsigned int dboffset; /* Offset to dwarf debug section */ - unsigned int dbsize; /* Size of dwarf debug section */ - unsigned int lnoffset; /* Offset to dwarf line number section */ - unsigned int lnsize; /* Size of dwarf line number section */ -}; - -/* We are called once per section from elf_symfile_read. We - need to examine each section we are passed, check to see - if it is something we are interested in processing, and - if so, stash away some access information for the section. - - For now we recognize the dwarf debug information sections and - line number sections from matching their section names. The - ELF definition is no real help here since it has no direct - knowledge of DWARF (by design, so any debugging format can be - used). - - FIXME: The section names should not be hardwired strings. */ - -static void -DEFUN(elf_locate_sections, (abfd, sectp, ei), - bfd *abfd AND - asection *sectp AND - struct elfinfo *ei) -{ - if (STREQ (sectp -> name, ".debug")) - { - ei -> dboffset = sectp -> filepos; - ei -> dbsize = sectp -> size; - } - else if (STREQ (sectp -> name, ".line")) - { - ei -> lnoffset = sectp -> filepos; - ei -> lnsize = sectp -> size; - } -} - -/* - -LOCAL FUNCTION - - record_misc_function -- add entry to miscellaneous function vector - -SYNOPSIS - - static void record_misc_function (char *name, CORE_ADDR address) - -DESCRIPTION - - Given a pointer to the name of a symbol that should be added to the - miscellaneous function vector, and the address associated with that - symbol, records this information for later use in building the - miscellaneous function vector. - -NOTES - - FIXME: For now we just use mf_unknown as the type. This should be - fixed. - */ - -static void -DEFUN(record_misc_function, (name, address), char *name AND CORE_ADDR address) -{ - prim_record_misc_function (obsavestring (name, strlen (name)), address, - mf_unknown); -} - -static void -DEFUN (elf_symtab_read, (abfd, addr), - bfd *abfd AND - CORE_ADDR addr) -{ - unsigned int storage_needed; - asymbol *sym; - asymbol **symbol_table; - unsigned int number_of_symbols; - unsigned int i; - struct cleanup *back_to; - - storage_needed = get_symtab_upper_bound (abfd); - - if (storage_needed > 0) - { - symbol_table = (asymbol **) bfd_xmalloc (storage_needed); - back_to = make_cleanup (free, symbol_table); - number_of_symbols = bfd_canonicalize_symtab (abfd, symbol_table); - - for (i = 0; i < number_of_symbols; i++) - { - sym = *symbol_table++; - /* Select global symbols that are defined in a specific section - or are absolute. */ - if (sym -> flags & BSF_GLOBAL - && ((sym -> section != NULL) || (sym -> flags & BSF_ABSOLUTE))) - { - record_misc_function ((char *) sym -> name, sym -> value); - } - } - do_cleanups (back_to); - } -} - -/* Scan and build partial symbols for a symbol file. - We have been initialized by a call to elf_symfile_init, which - currently does nothing. - - ADDR is the address relative to which the symbols in it are (e.g. - the base address of the text segment). - - MAINLINE is true if we are reading the main symbol - table (as opposed to a shared lib or dynamically loaded file). - - This function only does the minimum work necessary for letting the - user "name" things symbolically; it does not read the entire symtab. - Instead, it reads the external and static symbols and puts them in partial - symbol tables. When more extensive information is requested of a - file, the corresponding partial symbol table is mutated into a full - fledged symbol table by going back and reading the symbols - for real. The function dwarf_psymtab_to_symtab() is the function that - does this for DWARF symbols. - - Note that ELF files have a "minimal" symbol table, which looks a lot - like a COFF symbol table, but has only the minimal information necessary - for linking. We process this also, and just use the information to - add to the misc function vector. This gives us some minimal debugging - capability even for files compiled without -g. - */ - -static void -DEFUN(elf_symfile_read, (sf, addr, mainline), - struct sym_fns *sf AND - CORE_ADDR addr AND - int mainline) -{ - bfd *abfd = sf->objfile->obfd; - struct elfinfo ei; - struct cleanup *back_to; - - init_misc_bunches (); - back_to = make_cleanup (discard_misc_bunches, 0); - - /* Process the normal ELF symbol table first. */ - - elf_symtab_read (abfd, addr); - - /* Now process the DWARF debugging information, which is contained in - special ELF sections. We first have to find them... */ - - (void) memset ((char *) &ei, 0, sizeof (ei)); - bfd_map_over_sections (abfd, elf_locate_sections, &ei); - if (ei.dboffset && ei.lnoffset) - { - addr = 0; /* FIXME: force address base to zero for now */ - dwarf_build_psymtabs (fileno ((FILE *)(abfd -> iostream)), - bfd_get_filename (abfd), - addr, mainline, - ei.dboffset, ei.dbsize, - ei.lnoffset, ei.lnsize, sf->objfile); - } - - if (!partial_symtab_list) - { - wrap_here (""); - printf_filtered ("(no debugging symbols found)..."); - wrap_here (""); - } - - /* Go over the miscellaneous functions and install them in the - miscellaneous function vector. */ - - condense_misc_bunches (!mainline); - do_cleanups (back_to); -} - -/* Initialize anything that needs initializing when a completely new symbol - file is specified (not just adding some symbols from another file, e.g. a - shared library). - - For now at least, we have nothing in particular to do, so this function is - just a stub. */ - -static void -DEFUN_VOID (elf_new_init) -{ -} - -/* ELF specific initialization routine for reading symbols. - - It is passed a pointer to a struct sym_fns which contains, among other - things, the BFD for the file whose symbols are being read, and a slot for - a pointer to "private data" which we can fill with goodies. - - For now at least, we have nothing in particular to do, so this function is - just a stub. */ - -static void -DEFUN(elf_symfile_init, (sf), - struct sym_fns *sf) -{ -} - - -/* Register that we are able to handle ELF object file formats and DWARF - debugging formats. - - Unlike other object file formats, where the debugging information format - is implied by the object file format, the ELF object file format and the - DWARF debugging information format are two distinct, and potentially - separate entities. I.E. it is perfectly possible to have ELF objects - with debugging formats other than DWARF. And it is conceivable that the - DWARF debugging format might be used with another object file format, - like COFF, by simply using COFF's custom section feature. - - GDB, and to a lesser extent BFD, should support the notion of separate - object file formats and debugging information formats. For now, we just - use "elf" in the same sense as "a.out" or "coff", to imply both the ELF - object file format and the DWARF debugging format. */ - -static struct sym_fns elf_sym_fns = { - "elf", /* sym_name: name or name prefix of BFD target type */ - 3, /* sym_namelen: number of significant sym_name chars */ - elf_new_init, /* sym_new_init: init anything gbl to entire symtab */ - elf_symfile_init, /* sym_init: read initial info, setup for sym_read() */ - elf_symfile_read, /* sym_read: read a symbol file into symtab */ - NULL, /* sym_bfd: accessor for symbol file being read */ - NULL, /* sym_private: sym_init & sym_read shared info */ - NULL /* next: pointer to next struct sym_fns */ -}; - -void -DEFUN_VOID (_initialize_elfread) -{ - add_symtab_fns (&elf_sym_fns); -} diff --git a/gdb/environ.c b/gdb/environ.c deleted file mode 100644 index 45767e50536..00000000000 --- a/gdb/environ.c +++ /dev/null @@ -1,188 +0,0 @@ -/* environ.c -- library for manipulating environments for GNU. - Copyright (C) 1986, 1989 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#define min(a, b) ((a) < (b) ? (a) : (b)) -#define max(a, b) ((a) > (b) ? (a) : (b)) - -#include "environ.h" -#include - -extern char *xmalloc (); -extern char *xrealloc (); -extern void free (); - -/* Return a new environment object. */ - -struct environ * -make_environ () -{ - register struct environ *e; - - e = (struct environ *) xmalloc (sizeof (struct environ)); - - e->allocated = 10; - e->vector = (char **) xmalloc ((e->allocated + 1) * sizeof (char *)); - e->vector[0] = 0; - return e; -} - -/* Free an environment and all the strings in it. */ - -void -free_environ (e) - register struct environ *e; -{ - register char **vector = e->vector; - - while (*vector) - free (*vector++); - - free (e); -} - -/* Copy the environment given to this process into E. - Also copies all the strings in it, so we can be sure - that all strings in these environments are safe to free. */ - -void -init_environ (e) - register struct environ *e; -{ - extern char **environ; - register int i; - - for (i = 0; environ[i]; i++) /*EMPTY*/; - - if (e->allocated < i) - { - e->allocated = max (i, e->allocated + 10); - e->vector = (char **) xrealloc ((char *)e->vector, - (e->allocated + 1) * sizeof (char *)); - } - - bcopy (environ, e->vector, (i + 1) * sizeof (char *)); - - while (--i >= 0) - { - register int len = strlen (e->vector[i]); - register char *new = (char *) xmalloc (len + 1); - bcopy (e->vector[i], new, len + 1); - e->vector[i] = new; - } -} - -/* Return the vector of environment E. - This is used to get something to pass to execve. */ - -char ** -environ_vector (e) - struct environ *e; -{ - return e->vector; -} - -/* Return the value in environment E of variable VAR. */ - -char * -get_in_environ (e, var) - struct environ *e; - char *var; -{ - register int len = strlen (var); - register char **vector = e->vector; - register char *s; - - for (; s = *vector; vector++) - if (!strncmp (s, var, len) - && s[len] == '=') - return &s[len + 1]; - - return 0; -} - -/* Store the value in E of VAR as VALUE. */ - -void -set_in_environ (e, var, value) - struct environ *e; - char *var; - char *value; -{ - register int i; - register int len = strlen (var); - register char **vector = e->vector; - register char *s; - - for (i = 0; s = vector[i]; i++) - if (!strncmp (s, var, len) - && s[len] == '=') - break; - - if (s == 0) - { - if (i == e->allocated) - { - e->allocated += 10; - vector = (char **) xrealloc ((char *)vector, - (e->allocated + 1) * sizeof (char *)); - e->vector = vector; - } - vector[i + 1] = 0; - } - else - free (s); - - s = (char *) xmalloc (len + strlen (value) + 2); - strcpy (s, var); - strcat (s, "="); - strcat (s, value); - vector[i] = s; - - /* Certain variables get exported back to the parent (e.g. our) - environment, too. */ - if (!strcmp(var, "PATH") /* Object file location */ - || !strcmp (var, "G960BASE") /* Intel 960 downloads */ - || !strcmp (var, "G960BIN") /* Intel 960 downloads */ - || !strcmp (var, "GNUTARGET") /* BFD object file type */ - ) { - putenv (strsave (s)); - } - return; -} - -/* Remove the setting for variable VAR from environment E. */ - -void -unset_in_environ (e, var) - struct environ *e; - char *var; -{ - register int len = strlen (var); - register char **vector = e->vector; - register char *s; - - for (; s = *vector; vector++) - if (!strncmp (s, var, len) - && s[len] == '=') - { - free (s); - bcopy (vector + 1, vector, - (e->allocated - (vector - e->vector)) * sizeof (char *)); - e->vector[e->allocated - 1] = 0; - return; - } -} diff --git a/gdb/environ.h b/gdb/environ.h deleted file mode 100644 index 13f31f470a5..00000000000 --- a/gdb/environ.h +++ /dev/null @@ -1,39 +0,0 @@ -/* Header for environment manipulation library. - Copyright (C) 1989, Free Software Foundation. - - 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* We manipulate environments represented as these structures. */ - -struct environ -{ - /* Number of usable slots allocated in VECTOR. - VECTOR always has one slot not counted here, - to hold the terminating zero. */ - int allocated; - /* A vector of slots, ALLOCATED + 1 of them. - The first few slots contain strings "VAR=VALUE" - and the next one contains zero. - Then come some unused slots. */ - char **vector; -}; - -struct environ *make_environ (); -void free_environ (); -void init_environ (); -char *get_in_environ (); -void set_in_environ (); -void unset_in_environ (); -char **environ_vector (); diff --git a/gdb/eval.c b/gdb/eval.c deleted file mode 100644 index 0694d15de5d..00000000000 --- a/gdb/eval.c +++ /dev/null @@ -1,1054 +0,0 @@ -/* Evaluate expressions for GDB. - Copyright (C) 1986, 1987, 1989 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "defs.h" -#include "param.h" -#include "symtab.h" -#include "value.h" -#include "expression.h" -#include "target.h" -#include "frame.h" - -#define NULL_TYPE ((struct type *)0) - - -/* Parse the string EXP as a C expression, evaluate it, - and return the result as a number. */ - -CORE_ADDR -parse_and_eval_address (exp) - char *exp; -{ - struct expression *expr = parse_expression (exp); - register CORE_ADDR addr; - register struct cleanup *old_chain - = make_cleanup (free_current_contents, &expr); - - addr = value_as_pointer (evaluate_expression (expr)); - do_cleanups (old_chain); - return addr; -} - -/* Like parse_and_eval_address but takes a pointer to a char * variable - and advanced that variable across the characters parsed. */ - -CORE_ADDR -parse_and_eval_address_1 (expptr) - char **expptr; -{ - 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); - - addr = value_as_pointer (evaluate_expression (expr)); - do_cleanups (old_chain); - return addr; -} - -value -parse_and_eval (exp) - char *exp; -{ - struct expression *expr = parse_expression (exp); - register value val; - register struct cleanup *old_chain - = make_cleanup (free_current_contents, &expr); - - val = evaluate_expression (expr); - do_cleanups (old_chain); - return val; -} - -/* Parse up to a comma (or to a closeparen) - in the string EXPP as an expression, evaluate it, and return the value. - EXPP is advanced to point to the comma. */ - -value -parse_to_comma_and_eval (expp) - char **expp; -{ - struct expression *expr = parse_exp_1 (expp, (struct block *) 0, 1); - register value val; - register struct cleanup *old_chain - = make_cleanup (free_current_contents, &expr); - - val = evaluate_expression (expr); - do_cleanups (old_chain); - return val; -} - -/* Evaluate an expression in internal prefix form - such as is constructed by expread.y. - - See expression.h for info on the format of an expression. */ - -static value evaluate_subexp (); -static value evaluate_subexp_for_address (); -static value evaluate_subexp_for_sizeof (); -static value evaluate_subexp_with_coercion (); - -/* Values of NOSIDE argument to eval_subexp. */ -enum noside -{ EVAL_NORMAL, - EVAL_SKIP, /* Only effect is to increment pos. */ - EVAL_AVOID_SIDE_EFFECTS, /* Don't modify any variables or - call any functions. The value - returned will have the correct - type, and will have an - approximately correct lvalue - type (inaccuracy: anything that is - listed as being in a register in - the function in which it was - declared will be lval_register). */ -}; - -value -evaluate_expression (exp) - struct expression *exp; -{ - int pc = 0; - return evaluate_subexp (NULL_TYPE, exp, &pc, EVAL_NORMAL); -} - -/* Evaluate an expression, avoiding all memory references - and getting a value whose type alone is correct. */ - -value -evaluate_type (exp) - struct expression *exp; -{ - int pc = 0; - return evaluate_subexp (NULL_TYPE, exp, &pc, EVAL_AVOID_SIDE_EFFECTS); -} - -static value -evaluate_subexp (expect_type, exp, pos, noside) - struct type *expect_type; - register struct expression *exp; - register int *pos; - enum noside noside; -{ - enum exp_opcode op; - int tem; - register int pc, pc2, oldpos; - register value arg1, arg2, arg3; - int nargs; - value *argvec; - - pc = (*pos)++; - op = exp->elts[pc].opcode; - - switch (op) - { - case OP_SCOPE: - tem = strlen (&exp->elts[pc + 2].string); - (*pos) += 3 + ((tem + sizeof (union exp_element)) - / sizeof (union exp_element)); - arg1 = value_static_field (exp->elts[pc + 1].type, - &exp->elts[pc + 2].string, -1); - if (arg1 == NULL) - error ("There is no field named %s", &exp->elts[pc + 2].string); - return arg1; - - case OP_LONG: - (*pos) += 3; - return value_from_longest (exp->elts[pc + 1].type, - exp->elts[pc + 2].longconst); - - case OP_DOUBLE: - (*pos) += 3; - return value_from_double (exp->elts[pc + 1].type, - exp->elts[pc + 2].doubleconst); - - case OP_VAR_VALUE: - (*pos) += 2; - if (noside == EVAL_SKIP) - goto nosideret; - if (noside == EVAL_AVOID_SIDE_EFFECTS) - { - struct symbol * sym = exp->elts[pc + 1].symbol; - enum lval_type lv; - - switch (SYMBOL_CLASS (sym)) - { - case LOC_CONST: - case LOC_LABEL: - case LOC_CONST_BYTES: - lv = not_lval; - break; - - case LOC_REGISTER: - case LOC_REGPARM: - lv = lval_register; - break; - - default: - lv = lval_memory; - break; - } - - return value_zero (SYMBOL_TYPE (sym), lv); - } - else - return value_of_variable (exp->elts[pc + 1].symbol); - - case OP_LAST: - (*pos) += 2; - return - access_value_history (longest_to_int (exp->elts[pc + 1].longconst)); - - case OP_REGISTER: - (*pos) += 2; - return value_of_register (longest_to_int (exp->elts[pc + 1].longconst)); - - case OP_INTERNALVAR: - (*pos) += 2; - return value_of_internalvar (exp->elts[pc + 1].internalvar); - - case OP_STRING: - tem = strlen (&exp->elts[pc + 1].string); - (*pos) += 2 + ((tem + sizeof (union exp_element)) - / sizeof (union exp_element)); - if (noside == EVAL_SKIP) - goto nosideret; - return value_string (&exp->elts[pc + 1].string, tem); - - case TERNOP_COND: - /* Skip third and second args to evaluate the first one. */ - arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside); - if (value_zerop (arg1)) - { - evaluate_subexp (NULL_TYPE, exp, pos, EVAL_SKIP); - return evaluate_subexp (NULL_TYPE, exp, pos, noside); - } - else - { - arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside); - evaluate_subexp (NULL_TYPE, exp, pos, EVAL_SKIP); - return arg2; - } - - case OP_FUNCALL: - (*pos) += 2; - op = exp->elts[*pos].opcode; - if (op == STRUCTOP_MEMBER || op == STRUCTOP_MPTR) - { - int fnptr; - - nargs = longest_to_int (exp->elts[pc + 1].longconst) + 1; - /* First, evaluate the structure into arg2 */ - pc2 = (*pos)++; - - if (noside == EVAL_SKIP) - goto nosideret; - - if (op == STRUCTOP_MEMBER) - { - arg2 = evaluate_subexp_for_address (exp, pos, noside); - } - else - { - arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside); - } - - /* If the function is a virtual function, then the - aggregate value (providing the structure) plays - its part by providing the vtable. Otherwise, - it is just along for the ride: call the function - directly. */ - - arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside); - - fnptr = longest_to_int (value_as_long (arg1)); - /* FIXME-tiemann: this is way obsolete. */ - if (fnptr < 128) - { - struct type *basetype; - int i, j; - basetype = TYPE_TARGET_TYPE (VALUE_TYPE (arg2)); - basetype = TYPE_VPTR_BASETYPE (basetype); - for (i = TYPE_NFN_FIELDS (basetype) - 1; i >= 0; i--) - { - struct fn_field *f = TYPE_FN_FIELDLIST1 (basetype, i); - /* If one is virtual, then all are virtual. */ - if (TYPE_FN_FIELD_VIRTUAL_P (f, 0)) - for (j = TYPE_FN_FIELDLIST_LENGTH (basetype, i) - 1; j >= 0; --j) - if (TYPE_FN_FIELD_VOFFSET (f, j) == fnptr) - { - value vtbl; - value base = value_ind (arg2); - struct type *fntype = lookup_pointer_type (TYPE_FN_FIELD_TYPE (f, j)); - - if (TYPE_VPTR_FIELDNO (basetype) < 0) - fill_in_vptr_fieldno (basetype); - - VALUE_TYPE (base) = basetype; - vtbl = value_field (base, TYPE_VPTR_FIELDNO (basetype)); - VALUE_TYPE (vtbl) = lookup_pointer_type (fntype); - VALUE_TYPE (arg1) = builtin_type_int; - arg1 = value_subscript (vtbl, arg1); - VALUE_TYPE (arg1) = fntype; - goto got_it; - } - } - if (i < 0) - error ("virtual function at index %d not found", fnptr); - } - else - { - VALUE_TYPE (arg1) = lookup_pointer_type (TYPE_TARGET_TYPE (VALUE_TYPE (arg1))); - } - got_it: - - /* Now, say which argument to start evaluating from */ - tem = 2; - } - else if (op == STRUCTOP_STRUCT || op == STRUCTOP_PTR) - { - /* Hair for method invocations */ - int tem2; - - nargs = longest_to_int (exp->elts[pc + 1].longconst) + 1; - /* First, evaluate the structure into arg2 */ - pc2 = (*pos)++; - tem2 = strlen (&exp->elts[pc2 + 1].string); - *pos += 2 + (tem2 + sizeof (union exp_element)) / sizeof (union exp_element); - if (noside == EVAL_SKIP) - goto nosideret; - - if (op == STRUCTOP_STRUCT) - { - arg2 = evaluate_subexp_for_address (exp, pos, noside); - } - else - { - arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside); - } - /* Now, say which argument to start evaluating from */ - tem = 2; - } - else - { - nargs = longest_to_int (exp->elts[pc + 1].longconst); - tem = 0; - } - argvec = (value *) alloca (sizeof (value) * (nargs + 2)); - for (; tem <= nargs; tem++) - /* Ensure that array expressions are coerced into pointer objects. */ - argvec[tem] = evaluate_subexp_with_coercion (exp, pos, noside); - - /* signal end of arglist */ - argvec[tem] = 0; - - if (op == STRUCTOP_STRUCT || op == STRUCTOP_PTR) - { - int static_memfuncp; - value temp = arg2; - - argvec[1] = arg2; - argvec[0] = - value_struct_elt (&temp, argvec+1, &exp->elts[pc2 + 1].string, - &static_memfuncp, - op == STRUCTOP_STRUCT - ? "structure" : "structure pointer"); - if (VALUE_OFFSET (temp)) - { - arg2 = value_from_longest (lookup_pointer_type (VALUE_TYPE (temp)), - value_as_long (arg2)+VALUE_OFFSET (temp)); - argvec[1] = arg2; - } - if (static_memfuncp) - { - argvec[1] = argvec[0]; - nargs--; - argvec++; - } - } - else if (op == STRUCTOP_MEMBER || op == STRUCTOP_MPTR) - { - argvec[1] = arg2; - argvec[0] = arg1; - } - - if (noside == EVAL_SKIP) - goto nosideret; - if (noside == EVAL_AVOID_SIDE_EFFECTS) - { - /* If the return type doesn't look like a function type, call an - error. This can happen if somebody tries to turn a variable into - a function call. This is here because people often want to - call, eg, strcmp, which gdb doesn't know is a function. If - gdb isn't asked for it's opinion (ie. through "whatis"), - it won't offer it. */ - - struct type *ftype = - TYPE_TARGET_TYPE (VALUE_TYPE (argvec[0])); - - if (ftype) - return allocate_value (TYPE_TARGET_TYPE (VALUE_TYPE (argvec[0]))); - else - error ("Expression of type other than \"Function returning ...\" used as function"); - } - return target_call_function (argvec[0], nargs, argvec + 1); - - case STRUCTOP_STRUCT: - tem = strlen (&exp->elts[pc + 1].string); - (*pos) += 2 + ((tem + sizeof (union exp_element)) - / sizeof (union exp_element)); - arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside); - if (noside == EVAL_SKIP) - goto nosideret; - if (noside == EVAL_AVOID_SIDE_EFFECTS) - return value_zero (lookup_struct_elt_type (VALUE_TYPE (arg1), - &exp->elts[pc + 1].string, - 1), - lval_memory); - else - { - value temp = arg1; - return value_struct_elt (&temp, (value *)0, &exp->elts[pc + 1].string, - (int *) 0, "structure"); - } - - case STRUCTOP_PTR: - tem = strlen (&exp->elts[pc + 1].string); - (*pos) += 2 + (tem + sizeof (union exp_element)) / sizeof (union exp_element); - arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside); - if (noside == EVAL_SKIP) - goto nosideret; - if (noside == EVAL_AVOID_SIDE_EFFECTS) - return value_zero (lookup_struct_elt_type (TYPE_TARGET_TYPE - (VALUE_TYPE (arg1)), - &exp->elts[pc + 1].string, - 1), - lval_memory); - else - { - value temp = arg1; - return value_struct_elt (&temp, (value *)0, &exp->elts[pc + 1].string, - (int *) 0, "structure pointer"); - } - - case STRUCTOP_MEMBER: - arg1 = evaluate_subexp_for_address (exp, pos, noside); - arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside); - if (noside == EVAL_SKIP) - goto nosideret; - /* Now, convert these values to an address. */ - if (TYPE_CODE (VALUE_TYPE (arg2)) != TYPE_CODE_PTR - || ((TYPE_CODE (TYPE_TARGET_TYPE (VALUE_TYPE (arg2))) - != TYPE_CODE_MEMBER) - && (TYPE_CODE (TYPE_TARGET_TYPE (VALUE_TYPE (arg2))) - != TYPE_CODE_METHOD))) - error ("non-pointer-to-member value used in pointer-to-member construct"); - arg3 = value_from_longest ( - lookup_pointer_type (TYPE_TARGET_TYPE (TYPE_TARGET_TYPE (VALUE_TYPE (arg2)))), - value_as_long (arg1) + value_as_long (arg2)); - return value_ind (arg3); - - case STRUCTOP_MPTR: - arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside); - arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside); - if (noside == EVAL_SKIP) - goto nosideret; - /* Now, convert these values to an address. */ - if (TYPE_CODE (VALUE_TYPE (arg2)) != TYPE_CODE_PTR - || (TYPE_CODE (TYPE_TARGET_TYPE (VALUE_TYPE (arg2))) != TYPE_CODE_MEMBER - && TYPE_CODE (TYPE_TARGET_TYPE (VALUE_TYPE (arg2))) != TYPE_CODE_METHOD)) - error ("non-pointer-to-member value used in pointer-to-member construct"); - arg3 = value_from_longest ( - lookup_pointer_type (TYPE_TARGET_TYPE (TYPE_TARGET_TYPE (VALUE_TYPE (arg2)))), - value_as_long (arg1) + value_as_long (arg2)); - return value_ind (arg3); - - case BINOP_ASSIGN: - arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside); - arg2 = evaluate_subexp (VALUE_TYPE (arg1), exp, pos, noside); - if (noside == EVAL_SKIP || noside == EVAL_AVOID_SIDE_EFFECTS) - return arg1; - if (binop_user_defined_p (op, arg1, arg2)) - return value_x_binop (arg1, arg2, op, OP_NULL); - else - return value_assign (arg1, arg2); - - case BINOP_ASSIGN_MODIFY: - (*pos) += 2; - arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside); - arg2 = evaluate_subexp (VALUE_TYPE (arg1), exp, pos, noside); - if (noside == EVAL_SKIP || noside == EVAL_AVOID_SIDE_EFFECTS) - return arg1; - op = exp->elts[pc + 1].opcode; - if (binop_user_defined_p (op, arg1, arg2)) - return value_x_binop (arg1, arg2, BINOP_ASSIGN_MODIFY, op); - else if (op == BINOP_ADD) - arg2 = value_add (arg1, arg2); - else if (op == BINOP_SUB) - arg2 = value_sub (arg1, arg2); - else - arg2 = value_binop (arg1, arg2, op); - return value_assign (arg1, arg2); - - case BINOP_ADD: - arg1 = evaluate_subexp_with_coercion (exp, pos, noside); - arg2 = evaluate_subexp_with_coercion (exp, pos, noside); - if (noside == EVAL_SKIP) - goto nosideret; - if (binop_user_defined_p (op, arg1, arg2)) - return value_x_binop (arg1, arg2, op, OP_NULL); - else - return value_add (arg1, arg2); - - case BINOP_SUB: - arg1 = evaluate_subexp_with_coercion (exp, pos, noside); - arg2 = evaluate_subexp_with_coercion (exp, pos, noside); - if (noside == EVAL_SKIP) - goto nosideret; - if (binop_user_defined_p (op, arg1, arg2)) - return value_x_binop (arg1, arg2, op, OP_NULL); - else - return value_sub (arg1, arg2); - - case BINOP_MUL: - case BINOP_DIV: - case BINOP_REM: - case BINOP_LSH: - case BINOP_RSH: - case BINOP_LOGAND: - case BINOP_LOGIOR: - case BINOP_LOGXOR: - arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside); - arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside); - if (noside == EVAL_SKIP) - goto nosideret; - if (binop_user_defined_p (op, arg1, arg2)) - return value_x_binop (arg1, arg2, op, OP_NULL); - else - if (noside == EVAL_AVOID_SIDE_EFFECTS - && op == BINOP_DIV) - return value_zero (VALUE_TYPE (arg1), not_lval); - else - return value_binop (arg1, arg2, op); - - case BINOP_SUBSCRIPT: - arg1 = evaluate_subexp_with_coercion (exp, pos, noside); - arg2 = evaluate_subexp_with_coercion (exp, pos, noside); - if (noside == EVAL_SKIP) - goto nosideret; - if (noside == EVAL_AVOID_SIDE_EFFECTS) - return value_zero (TYPE_TARGET_TYPE (VALUE_TYPE (arg1)), - VALUE_LVAL (arg1)); - - if (binop_user_defined_p (op, arg1, arg2)) - return value_x_binop (arg1, arg2, op, OP_NULL); - else - return value_subscript (arg1, arg2); - - case BINOP_AND: - arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside); - if (noside == EVAL_SKIP) - { - arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside); - goto nosideret; - } - - oldpos = *pos; - arg2 = evaluate_subexp (NULL_TYPE, exp, pos, EVAL_AVOID_SIDE_EFFECTS); - *pos = oldpos; - - if (binop_user_defined_p (op, arg1, arg2)) - { - arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside); - return value_x_binop (arg1, arg2, op, OP_NULL); - } - else - { - tem = value_zerop (arg1); - arg2 = evaluate_subexp (NULL_TYPE, exp, pos, - (tem ? EVAL_SKIP : noside)); - return value_from_longest (builtin_type_int, - (LONGEST) (!tem && !value_zerop (arg2))); - } - - case BINOP_OR: - arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside); - if (noside == EVAL_SKIP) - { - arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside); - goto nosideret; - } - - oldpos = *pos; - arg2 = evaluate_subexp (NULL_TYPE, exp, pos, EVAL_AVOID_SIDE_EFFECTS); - *pos = oldpos; - - if (binop_user_defined_p (op, arg1, arg2)) - { - arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside); - return value_x_binop (arg1, arg2, op, OP_NULL); - } - else - { - tem = value_zerop (arg1); - arg2 = evaluate_subexp (NULL_TYPE, exp, pos, - (!tem ? EVAL_SKIP : noside)); - return value_from_longest (builtin_type_int, - (LONGEST) (!tem || !value_zerop (arg2))); - } - - case BINOP_EQUAL: - arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside); - arg2 = evaluate_subexp (VALUE_TYPE (arg1), exp, pos, noside); - if (noside == EVAL_SKIP) - goto nosideret; - if (binop_user_defined_p (op, arg1, arg2)) - { - return value_x_binop (arg1, arg2, op, OP_NULL); - } - else - { - tem = value_equal (arg1, arg2); - return value_from_longest (builtin_type_int, (LONGEST) tem); - } - - case BINOP_NOTEQUAL: - arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside); - arg2 = evaluate_subexp (VALUE_TYPE (arg1), exp, pos, noside); - if (noside == EVAL_SKIP) - goto nosideret; - if (binop_user_defined_p (op, arg1, arg2)) - { - return value_x_binop (arg1, arg2, op, OP_NULL); - } - else - { - tem = value_equal (arg1, arg2); - return value_from_longest (builtin_type_int, (LONGEST) ! tem); - } - - case BINOP_LESS: - arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside); - arg2 = evaluate_subexp (VALUE_TYPE (arg1), exp, pos, noside); - if (noside == EVAL_SKIP) - goto nosideret; - if (binop_user_defined_p (op, arg1, arg2)) - { - return value_x_binop (arg1, arg2, op, OP_NULL); - } - else - { - tem = value_less (arg1, arg2); - return value_from_longest (builtin_type_int, (LONGEST) tem); - } - - case BINOP_GTR: - arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside); - arg2 = evaluate_subexp (VALUE_TYPE (arg1), exp, pos, noside); - if (noside == EVAL_SKIP) - goto nosideret; - if (binop_user_defined_p (op, arg1, arg2)) - { - return value_x_binop (arg1, arg2, op, OP_NULL); - } - else - { - tem = value_less (arg2, arg1); - return value_from_longest (builtin_type_int, (LONGEST) tem); - } - - case BINOP_GEQ: - arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside); - arg2 = evaluate_subexp (VALUE_TYPE (arg1), exp, pos, noside); - if (noside == EVAL_SKIP) - goto nosideret; - if (binop_user_defined_p (op, arg1, arg2)) - { - return value_x_binop (arg1, arg2, op, OP_NULL); - } - else - { - tem = value_less (arg1, arg2); - return value_from_longest (builtin_type_int, (LONGEST) ! tem); - } - - case BINOP_LEQ: - arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside); - arg2 = evaluate_subexp (VALUE_TYPE (arg1), exp, pos, noside); - if (noside == EVAL_SKIP) - goto nosideret; - if (binop_user_defined_p (op, arg1, arg2)) - { - return value_x_binop (arg1, arg2, op, OP_NULL); - } - else - { - tem = value_less (arg2, arg1); - return value_from_longest (builtin_type_int, (LONGEST) ! tem); - } - - case BINOP_REPEAT: - arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside); - arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside); - if (noside == EVAL_SKIP) - goto nosideret; - if (TYPE_CODE (VALUE_TYPE (arg2)) != TYPE_CODE_INT) - error ("Non-integral right operand for \"@\" operator."); - if (noside == EVAL_AVOID_SIDE_EFFECTS) - return allocate_repeat_value (VALUE_TYPE (arg1), - longest_to_int (value_as_long (arg2))); - else - return value_repeat (arg1, longest_to_int (value_as_long (arg2))); - - case BINOP_COMMA: - evaluate_subexp (NULL_TYPE, exp, pos, noside); - return evaluate_subexp (NULL_TYPE, exp, pos, noside); - - case UNOP_NEG: - arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside); - if (noside == EVAL_SKIP) - goto nosideret; - if (unop_user_defined_p (op, arg1)) - return value_x_unop (arg1, op); - else - return value_neg (arg1); - - case UNOP_LOGNOT: - /* C++: check for and handle destructor names. */ - op = exp->elts[*pos].opcode; - - /* FIXME-tiemann: this is a cop-out. */ - if (op == OP_SCOPE) - error ("destructor in eval"); - - arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside); - if (noside == EVAL_SKIP) - goto nosideret; - if (unop_user_defined_p (UNOP_LOGNOT, arg1)) - return value_x_unop (arg1, UNOP_LOGNOT); - else - return value_lognot (arg1); - - case UNOP_ZEROP: - arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside); - if (noside == EVAL_SKIP) - goto nosideret; - if (unop_user_defined_p (op, arg1)) - return value_x_unop (arg1, op); - else - return value_from_longest (builtin_type_int, - (LONGEST) value_zerop (arg1)); - - case UNOP_IND: - if (expect_type && TYPE_CODE (expect_type) == TYPE_CODE_PTR) - expect_type = TYPE_TARGET_TYPE (expect_type); - arg1 = evaluate_subexp (expect_type, exp, pos, noside); - if (noside == EVAL_SKIP) - goto nosideret; - if (noside == EVAL_AVOID_SIDE_EFFECTS) - { - if (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_PTR - || TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_REF - /* In C you can dereference an array to get the 1st elt. */ - || TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_ARRAY - ) - return value_zero (TYPE_TARGET_TYPE (VALUE_TYPE (arg1)), - lval_memory); - else if (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_INT) - /* GDB allows dereferencing an int. */ - return value_zero (builtin_type_int, lval_memory); - else - error ("Attempt to take contents of a non-pointer value."); - } - return value_ind (arg1); - - case UNOP_ADDR: - /* C++: check for and handle pointer to members. */ - - op = exp->elts[*pos].opcode; - - if (noside == EVAL_SKIP) - { - if (op == OP_SCOPE) - { - char *name = &exp->elts[pc+3].string; - int temm = strlen (name); - (*pos) += 2 + (temm + sizeof (union exp_element)) / sizeof (union exp_element); - } - else - evaluate_subexp (expect_type, exp, pos, EVAL_SKIP); - goto nosideret; - } - - if (op == OP_SCOPE) - { - char *name = &exp->elts[pc+3].string; - int temm = strlen (name); - struct type *domain = exp->elts[pc+2].type; - (*pos) += 2 + (temm + sizeof (union exp_element)) / sizeof (union exp_element); - arg1 = value_struct_elt_for_address (domain, expect_type, name); - if (arg1) - return arg1; - error ("no field `%s' in structure", name); - } - else - return evaluate_subexp_for_address (exp, pos, noside); - - case UNOP_SIZEOF: - if (noside == EVAL_SKIP) - { - evaluate_subexp (NULL_TYPE, exp, pos, EVAL_SKIP); - goto nosideret; - } - return evaluate_subexp_for_sizeof (exp, pos); - - case UNOP_CAST: - (*pos) += 2; - arg1 = evaluate_subexp (expect_type, exp, pos, noside); - if (noside == EVAL_SKIP) - goto nosideret; - return value_cast (exp->elts[pc + 1].type, arg1); - - case UNOP_MEMVAL: - (*pos) += 2; - arg1 = evaluate_subexp (expect_type, exp, pos, noside); - if (noside == EVAL_SKIP) - goto nosideret; - if (noside == EVAL_AVOID_SIDE_EFFECTS) - return value_zero (exp->elts[pc + 1].type, lval_memory); - else - return value_at_lazy (exp->elts[pc + 1].type, - value_as_pointer (arg1)); - - case UNOP_PREINCREMENT: - arg1 = evaluate_subexp (expect_type, exp, pos, noside); - if (noside == EVAL_SKIP || noside == EVAL_AVOID_SIDE_EFFECTS) - return arg1; - else if (unop_user_defined_p (op, arg1)) - { - return value_x_unop (arg1, op); - } - else - { - arg2 = value_add (arg1, value_from_longest (builtin_type_char, - (LONGEST) 1)); - return value_assign (arg1, arg2); - } - - case UNOP_PREDECREMENT: - arg1 = evaluate_subexp (expect_type, exp, pos, noside); - if (noside == EVAL_SKIP || noside == EVAL_AVOID_SIDE_EFFECTS) - return arg1; - else if (unop_user_defined_p (op, arg1)) - { - return value_x_unop (arg1, op); - } - else - { - arg2 = value_sub (arg1, value_from_longest (builtin_type_char, - (LONGEST) 1)); - return value_assign (arg1, arg2); - } - - case UNOP_POSTINCREMENT: - arg1 = evaluate_subexp (expect_type, exp, pos, noside); - if (noside == EVAL_SKIP || noside == EVAL_AVOID_SIDE_EFFECTS) - return arg1; - else if (unop_user_defined_p (op, arg1)) - { - return value_x_unop (arg1, op); - } - else - { - arg2 = value_add (arg1, value_from_longest (builtin_type_char, - (LONGEST) 1)); - value_assign (arg1, arg2); - return arg1; - } - - case UNOP_POSTDECREMENT: - arg1 = evaluate_subexp (expect_type, exp, pos, noside); - if (noside == EVAL_SKIP || noside == EVAL_AVOID_SIDE_EFFECTS) - return arg1; - else if (unop_user_defined_p (op, arg1)) - { - return value_x_unop (arg1, op); - } - else - { - arg2 = value_sub (arg1, value_from_longest (builtin_type_char, - (LONGEST) 1)); - value_assign (arg1, arg2); - return arg1; - } - - case OP_THIS: - (*pos) += 1; - return value_of_this (1); - - default: - error ("internal error: I do not know how to evaluate what you gave me"); - } - - nosideret: - return value_from_longest (builtin_type_long, (LONGEST) 1); -} - -/* Evaluate a subexpression of EXP, at index *POS, - and return the address of that subexpression. - Advance *POS over the subexpression. - If the subexpression isn't an lvalue, get an error. - NOSIDE may be EVAL_AVOID_SIDE_EFFECTS; - then only the type of the result need be correct. */ - -static value -evaluate_subexp_for_address (exp, pos, noside) - register struct expression *exp; - register int *pos; - enum noside noside; -{ - enum exp_opcode op; - register int pc; - - pc = (*pos); - op = exp->elts[pc].opcode; - - switch (op) - { - case UNOP_IND: - (*pos)++; - return evaluate_subexp (NULL_TYPE, exp, pos, noside); - - case UNOP_MEMVAL: - (*pos) += 3; - return value_cast (lookup_pointer_type (exp->elts[pc + 1].type), - evaluate_subexp (NULL_TYPE, exp, pos, noside)); - - case OP_VAR_VALUE: - (*pos) += 3; - if (noside == EVAL_AVOID_SIDE_EFFECTS) - { - struct type *type = - lookup_pointer_type (SYMBOL_TYPE (exp->elts[pc + 1].symbol)); - enum address_class sym_class = - SYMBOL_CLASS (exp->elts[pc + 1].symbol); - - if (sym_class == LOC_CONST - || sym_class == LOC_CONST_BYTES - || sym_class == LOC_REGISTER - || sym_class == LOC_REGPARM) - error ("Attempt to take address of register or constant."); - - return - value_zero (type, not_lval); - } - else - return locate_var_value (exp->elts[pc + 1].symbol, (FRAME) 0); - - default: - if (noside == EVAL_AVOID_SIDE_EFFECTS) - { - value x = evaluate_subexp (NULL_TYPE, exp, pos, noside); - if (VALUE_LVAL (x) == lval_memory) - return value_zero (TYPE_POINTER_TYPE (VALUE_TYPE (x)), - not_lval); - else - error ("Attempt to take address of non-lval"); - } - return value_addr (evaluate_subexp (NULL_TYPE, exp, pos, noside)); - } -} - -/* Evaluate like `evaluate_subexp' except coercing arrays to pointers. - When used in contexts where arrays will be coerced anyway, - this is equivalent to `evaluate_subexp' - but much faster because it avoids actually fetching array contents. */ - -static value -evaluate_subexp_with_coercion (exp, pos, noside) - register struct expression *exp; - register int *pos; - enum noside noside; -{ - register enum exp_opcode op; - register int pc; - register value val; - - pc = (*pos); - op = exp->elts[pc].opcode; - - switch (op) - { - case OP_VAR_VALUE: - if (TYPE_CODE (SYMBOL_TYPE (exp->elts[pc + 1].symbol)) == TYPE_CODE_ARRAY) - { - (*pos) += 3; - val = locate_var_value (exp->elts[pc + 1].symbol, (FRAME) 0); - return value_cast (lookup_pointer_type (TYPE_TARGET_TYPE (SYMBOL_TYPE (exp->elts[pc + 1].symbol))), - val); - } - default: - return evaluate_subexp (NULL_TYPE, exp, pos, noside); - } -} - -/* Evaluate a subexpression of EXP, at index *POS, - and return a value for the size of that subexpression. - Advance *POS over the subexpression. */ - -static value -evaluate_subexp_for_sizeof (exp, pos) - register struct expression *exp; - register int *pos; -{ - enum exp_opcode op; - register int pc; - value val; - - pc = (*pos); - op = exp->elts[pc].opcode; - - switch (op) - { - /* This case is handled specially - so that we avoid creating a value for the result type. - If the result type is very big, it's desirable not to - create a value unnecessarily. */ - case UNOP_IND: - (*pos)++; - val = evaluate_subexp (NULL_TYPE, exp, pos, EVAL_AVOID_SIDE_EFFECTS); - return value_from_longest (builtin_type_int, (LONGEST) - TYPE_LENGTH (TYPE_TARGET_TYPE (VALUE_TYPE (val)))); - - case UNOP_MEMVAL: - (*pos) += 3; - return value_from_longest (builtin_type_int, - (LONGEST) TYPE_LENGTH (exp->elts[pc + 1].type)); - - case OP_VAR_VALUE: - (*pos) += 3; - return value_from_longest (builtin_type_int, - (LONGEST) TYPE_LENGTH (SYMBOL_TYPE (exp->elts[pc + 1].symbol))); - - default: - val = evaluate_subexp (NULL_TYPE, exp, pos, EVAL_AVOID_SIDE_EFFECTS); - return value_from_longest (builtin_type_int, - (LONGEST) TYPE_LENGTH (VALUE_TYPE (val))); - } -} diff --git a/gdb/exec.c b/gdb/exec.c deleted file mode 100644 index 0c645f226a3..00000000000 --- a/gdb/exec.c +++ /dev/null @@ -1,427 +0,0 @@ -/* Work with executable files, for GDB. - Copyright (C) 1988, 1989 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "defs.h" -#include "param.h" -#include "frame.h" -#include "inferior.h" -#include "target.h" -#include "gdbcmd.h" - -#ifdef USG -#include -#endif - -#include -#include -#include - -#include "gdbcore.h" - -#include -#include - -extern char *getenv(); -extern void child_create_inferior (), child_attach (); -extern void symbol_file_command (); - -/* The Binary File Descriptor handle for the executable file. */ - -bfd *exec_bfd = NULL; - -/* Whether to open exec and core files read-only or read-write. */ - -int write_files = 0; - -/* Text start and end addresses (KLUDGE) if needed */ - -#ifdef NEED_TEXT_START_END -CORE_ADDR text_start = 0; -CORE_ADDR text_end = 0; -#endif - -/* Forward decl */ - -extern struct target_ops exec_ops; - -/* ARGSUSED */ -void -exec_close (quitting) - int quitting; -{ - if (exec_bfd) { - bfd_close (exec_bfd); - exec_bfd = NULL; - } - if (exec_ops.sections) { - free (exec_ops.sections); - exec_ops.sections = NULL; - exec_ops.sections_end = NULL; - } -} - -void -exec_file_command (filename, from_tty) - char *filename; - int from_tty; -{ - target_preopen (from_tty); - - /* Remove any previous exec file. */ - unpush_target (&exec_ops); - - /* Now open and digest the file the user requested, if any. */ - - if (filename) - { - char *scratch_pathname; - int scratch_chan; - - filename = tilde_expand (filename); - make_cleanup (free, filename); - - scratch_chan = openp (getenv ("PATH"), 1, filename, - write_files? O_RDWR: O_RDONLY, 0, - &scratch_pathname); - if (scratch_chan < 0) - perror_with_name (filename); - - exec_bfd = bfd_fdopenr (scratch_pathname, NULL, scratch_chan); - if (!exec_bfd) - error ("Could not open `%s' as an executable file: %s", - scratch_pathname, bfd_errmsg (bfd_error)); - if (!bfd_check_format (exec_bfd, bfd_object)) - error ("\"%s\": not in executable format: %s.", - scratch_pathname, bfd_errmsg (bfd_error)); - -#if FIXME -/* This code needs to be incorporated into BFD */ -#ifdef COFF_ENCAPSULATE - /* If we have a coff header, it can give us better values for - text_start and exec_data_start. This is particularly useful - for remote debugging of embedded systems. */ - if (N_FLAGS(exec_aouthdr) & N_FLAGS_COFF_ENCAPSULATE) - { - struct coffheader ch; - int val; - val = lseek (execchan, -(sizeof (AOUTHDR) + sizeof (ch)), 1); - if (val == -1) - perror_with_name (filename); - val = myread (execchan, &ch, sizeof (ch)); - if (val < 0) - perror_with_name (filename); - text_start = ch.text_start; - exec_data_start = ch.data_start; - } else -#endif - { - text_start = - IS_OBJECT_FILE (exec_aouthdr) ? 0 : N_TXTADDR (exec_aouthdr); - exec_data_start = IS_OBJECT_FILE (exec_aouthdr) - ? exec_aouthdr.a_text : N_DATADDR (exec_aouthdr); - } -#endif FIXME - - if (build_section_table (exec_bfd, &exec_ops.sections, - &exec_ops.sections_end)) - error ("Can't find the file sections in `%s': %s", - exec_bfd->filename, bfd_errmsg (bfd_error)); - -#ifdef NEED_TEXT_START_END - /* This is a KLUDGE (FIXME) because a few places in a few ports - (29K springs to mind) need this info for now. */ - { - struct section_table *p; - for (p = exec_ops.sections; p < exec_ops.sections_end; p++) - if (!strcmp (".text", bfd_section_name (p->bfd, p->sec_ptr))) - { - text_start = p->addr; - text_end = p->endaddr; - break; - } - } -#endif - - validate_files (); - - push_target (&exec_ops); - - /* Tell display code (if any) about the changed file name. */ - if (exec_file_display_hook) - (*exec_file_display_hook) (filename); - } - else if (from_tty) - printf ("No exec file now.\n"); -} - -/* Set both the exec file and the symbol file, in one command. - What a novelty. Why did GDB go through four major releases before this - command was added? */ - -void -file_command (arg, from_tty) - char *arg; - int from_tty; -{ - /* FIXME, if we lose on reading the symbol file, we should revert - the exec file, but that's rough. */ - exec_file_command (arg, from_tty); - symbol_file_command (arg, from_tty); -} - - -/* Locate all mappable sections of a BFD file. - table_pp_char is a char * to get it through bfd_map_over_sections; - we cast it back to its proper type. */ - -void -add_to_section_table (abfd, asect, table_pp_char) - bfd *abfd; - sec_ptr asect; - char *table_pp_char; -{ - struct section_table **table_pp = (struct section_table **)table_pp_char; - flagword aflag; - - aflag = bfd_get_section_flags (abfd, asect); - /* FIXME, we need to handle BSS segment here...it alloc's but doesn't load */ - if (!(aflag & SEC_LOAD)) - return; - if (0 == bfd_section_size (abfd, asect)) - return; - (*table_pp)->bfd = abfd; - (*table_pp)->sec_ptr = asect; - (*table_pp)->addr = bfd_section_vma (abfd, asect); - (*table_pp)->endaddr = (*table_pp)->addr + bfd_section_size (abfd, asect); - (*table_pp)++; -} - -int -build_section_table (some_bfd, start, end) - bfd *some_bfd; - struct section_table **start, **end; -{ - unsigned count; - - count = bfd_count_sections (some_bfd); - if (count == 0) - abort(); /* return 1? */ - if (*start) - free (*start); - *start = (struct section_table *) xmalloc (count * sizeof (**start)); - *end = *start; - bfd_map_over_sections (some_bfd, add_to_section_table, (char *)end); - if (*end > *start + count) - abort(); - /* We could realloc the table, but it probably loses for most files. */ - return 0; -} - -/* Read or write the exec file. - - Args are address within a BFD file, address within gdb address-space, - length, and a flag indicating whether to read or write. - - Result is a length: - - 0: We cannot handle this address and length. - > 0: We have handled N bytes starting at this address. - (If N == length, we did it all.) We might be able - to handle more bytes beyond this length, but no - promises. - < 0: We cannot handle this address, but if somebody - else handles (-N) bytes, we can start from there. - - The same routine is used to handle both core and exec files; - we just tail-call it with more arguments to select between them. */ - -int -xfer_memory (memaddr, myaddr, len, write, target) - CORE_ADDR memaddr; - char *myaddr; - int len; - int write; - struct target_ops *target; -{ - boolean res; - struct section_table *p; - CORE_ADDR nextsectaddr, memend; - boolean (*xfer_fn) (); - - if (len <= 0) - abort(); - - memend = memaddr + len; - xfer_fn = write? bfd_set_section_contents: bfd_get_section_contents; - nextsectaddr = memend; - - for (p = target->sections; p < target->sections_end; p++) - { - if (p->addr <= memaddr) - if (p->endaddr >= memend) - { - /* Entire transfer is within this section. */ - res = xfer_fn (p->bfd, p->sec_ptr, myaddr, memaddr - p->addr, len); - return (res != false)? len: 0; - } - else if (p->endaddr <= memaddr) - { - /* This section ends before the transfer starts. */ - continue; - } - else - { - /* This section overlaps the transfer. Just do half. */ - len = p->endaddr - memaddr; - res = xfer_fn (p->bfd, p->sec_ptr, myaddr, memaddr - p->addr, len); - return (res != false)? len: 0; - } - else if (p->addr < nextsectaddr) - nextsectaddr = p->addr; - } - - if (nextsectaddr >= memend) - return 0; /* We can't help */ - else - return - (nextsectaddr - memaddr); /* Next boundary where we can help */ -} - -#ifdef FIXME -#ifdef REG_STACK_SEGMENT -/* MOVE TO BFD... */ - /* Pyramids and AM29000s have an extra segment in the virtual address space - for the (control) stack of register-window frames. The AM29000 folk - call it the "register stack" rather than the "memory stack". */ - else if (memaddr >= reg_stack_start && memaddr < reg_stack_end) - { - i = min (len, reg_stack_end - memaddr); - fileptr = memaddr - reg_stack_start + reg_stack_offset; - wanna_xfer = coredata; - } -#endif /* REG_STACK_SEGMENT */ -#endif FIXME - -static void -exec_files_info () -{ - struct section_table *p; - - printf ("\tExecutable file `%s'.\n", bfd_get_filename(exec_bfd)); - - for (p = exec_ops.sections; p < exec_ops.sections_end; p++) { - printf("\t%s", local_hex_string_custom (p->addr, "08")); - printf(" - %s is %s\n", local_hex_string_custom (p->endaddr, "08"), - bfd_section_name (exec_bfd, p->sec_ptr)); - } -} - -static void -set_section_command (args, from_tty) - char *args; - int from_tty; -{ - struct section_table *p; - char *secname; - unsigned seclen; - unsigned long secaddr; - char secprint[100]; - long offset; - - if (args == 0) - error ("Must specify section name and its virtual address"); - - /* Parse out section name */ - for (secname = args; !isspace(*args); args++) ; - seclen = args - secname; - - /* Parse out new virtual address */ - secaddr = parse_and_eval_address (args); - - for (p = exec_ops.sections; p < exec_ops.sections_end; p++) { - if (!strncmp (secname, bfd_section_name (exec_bfd, p->sec_ptr), seclen) - && bfd_section_name (exec_bfd, p->sec_ptr)[seclen] == '\0') { - offset = secaddr - p->addr; - p->addr += offset; - p->endaddr += offset; - exec_files_info(); - return; - } - } - if (seclen >= sizeof (secprint)) - seclen = sizeof (secprint) - 1; - strncpy (secprint, secname, seclen); - secprint[seclen] = '\0'; - error ("Section %s not found", secprint); -} - -struct target_ops exec_ops = { - "exec", "Local exec file", - "Use an executable file as a target.\n\ -Specify the filename of the executable file.", - exec_file_command, exec_close, /* open, close */ - child_attach, 0, 0, 0, /* attach, detach, resume, wait, */ - 0, 0, /* fetch_registers, store_registers, */ - 0, 0, 0, /* prepare_to_store, conv_to, conv_from, */ - xfer_memory, exec_files_info, - 0, 0, /* insert_breakpoint, remove_breakpoint, */ - 0, 0, 0, 0, 0, /* terminal stuff */ - 0, 0, /* kill, load */ - 0, 0, /* call fn, lookup sym */ - child_create_inferior, - 0, /* mourn_inferior */ - file_stratum, 0, /* next */ - 0, 1, 0, 0, 0, /* all mem, mem, stack, regs, exec */ - 0, 0, /* section pointers */ - OPS_MAGIC, /* Always the last thing */ -}; - -void -_initialize_exec() -{ - - add_com ("file", class_files, file_command, - "Use FILE as program to be debugged.\n\ -It is read for its symbols, for getting the contents of pure memory,\n\ -and it is the program executed when you use the `run' command.\n\ -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."); - - add_com ("exec-file", class_files, exec_file_command, - "Use FILE as program for getting contents of pure memory.\n\ -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."); - - add_com ("section", class_files, set_section_command, - "Change the base address of section SECTION of the exec file to ADDR.\n\ -This can be used if the exec file does not contain section addresses,\n\ -(such as in the a.out format), or when the addresses specified in the\n\ -file itself are wrong. Each section must be changed separately. The\n\ -``info files'' command lists all the sections and their addresses."); - - add_show_from_set - (add_set_cmd ("write", class_support, var_boolean, (char *)&write_files, - "Set writing into executable and core files.", - &setlist), - &showlist); - - add_target (&exec_ops); -} diff --git a/gdb/expprint.c b/gdb/expprint.c deleted file mode 100644 index e96dc7fe94f..00000000000 --- a/gdb/expprint.c +++ /dev/null @@ -1,332 +0,0 @@ -/* Print in infix form a struct expression. - Copyright (C) 1986, 1989 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "defs.h" -#include "symtab.h" -#include "param.h" -#include "expression.h" -#include "value.h" - - -/* These codes indicate operator precedences, least tightly binding first. */ -/* Adding 1 to a precedence value is done for binary operators, - on the operand which is more tightly bound, so that operators - of equal precedence within that operand will get parentheses. */ -/* PREC_HYPER and PREC_ABOVE_COMMA are not the precedence of any operator; - they are used as the "surrounding precedence" to force - various kinds of things to be parenthesized. */ -enum precedence -{ PREC_NULL, PREC_COMMA, PREC_ABOVE_COMMA, PREC_ASSIGN, PREC_OR, PREC_AND, - PREC_LOGIOR, PREC_LOGAND, PREC_LOGXOR, PREC_EQUAL, PREC_ORDER, - PREC_SHIFT, PREC_ADD, PREC_MUL, PREC_REPEAT, - PREC_HYPER, PREC_PREFIX, PREC_SUFFIX }; - -/* Table mapping opcodes into strings for printing operators - and precedences of the operators. */ - -struct op_print -{ - char *string; - enum exp_opcode opcode; - /* Precedence of operator. These values are used only by comparisons. */ - enum precedence precedence; - int right_assoc; -}; - -const static struct op_print op_print_tab[] = - { - {",", BINOP_COMMA, PREC_COMMA, 0}, - {"=", BINOP_ASSIGN, PREC_ASSIGN, 1}, - {"||", BINOP_OR, PREC_OR, 0}, - {"&&", BINOP_AND, PREC_AND, 0}, - {"|", BINOP_LOGIOR, PREC_LOGIOR, 0}, - {"&", BINOP_LOGAND, PREC_LOGAND, 0}, - {"^", BINOP_LOGXOR, PREC_LOGXOR, 0}, - {"==", BINOP_EQUAL, PREC_EQUAL, 0}, - {"!=", BINOP_NOTEQUAL, PREC_EQUAL, 0}, - {"<=", BINOP_LEQ, PREC_ORDER, 0}, - {">=", BINOP_GEQ, PREC_ORDER, 0}, - {">", BINOP_GTR, PREC_ORDER, 0}, - {"<", BINOP_LESS, PREC_ORDER, 0}, - {">>", BINOP_RSH, PREC_SHIFT, 0}, - {"<<", BINOP_LSH, PREC_SHIFT, 0}, - {"+", BINOP_ADD, PREC_ADD, 0}, - {"-", BINOP_SUB, PREC_ADD, 0}, - {"*", BINOP_MUL, PREC_MUL, 0}, - {"/", BINOP_DIV, PREC_MUL, 0}, - {"%", BINOP_REM, PREC_MUL, 0}, - {"@", BINOP_REPEAT, PREC_REPEAT, 0}, - {"-", UNOP_NEG, PREC_PREFIX, 0}, - {"!", UNOP_ZEROP, PREC_PREFIX, 0}, - {"~", UNOP_LOGNOT, PREC_PREFIX, 0}, - {"*", UNOP_IND, PREC_PREFIX, 0}, - {"&", UNOP_ADDR, PREC_PREFIX, 0}, - {"sizeof ", UNOP_SIZEOF, PREC_PREFIX, 0}, - {"++", UNOP_PREINCREMENT, PREC_PREFIX, 0}, - {"--", UNOP_PREDECREMENT, PREC_PREFIX, 0}, - /* C++ */ - {"::", BINOP_SCOPE, PREC_PREFIX, 0}, - }; - -static void print_subexp (); - -void -print_expression (exp, stream) - struct expression *exp; - FILE *stream; -{ - int pc = 0; - print_subexp (exp, &pc, stream, PREC_NULL); -} - -/* Print the subexpression of EXP that starts in position POS, on STREAM. - PREC is the precedence of the surrounding operator; - if the precedence of the main operator of this subexpression is less, - parentheses are needed here. */ - -static void -print_subexp (exp, pos, stream, prec) - register struct expression *exp; - register int *pos; - FILE *stream; - enum precedence prec; -{ - register unsigned tem; - register int pc; - unsigned nargs; - register char *op_str; - int assign_modify = 0; - enum exp_opcode opcode; - enum precedence myprec; - /* Set to 1 for a right-associative operator. */ - int assoc; - - pc = (*pos)++; - opcode = exp->elts[pc].opcode; - switch (opcode) - { - case OP_SCOPE: - myprec = PREC_PREFIX; - assoc = 0; - (*pos) += 2; - print_subexp (exp, pos, stream, - (enum precedence) ((int) myprec + assoc)); - fputs_filtered (" :: ", stream); - nargs = strlen (&exp->elts[pc + 2].string); - (*pos) += 1 + (nargs + sizeof (union exp_element)) / sizeof (union exp_element); - - fputs_filtered (&exp->elts[pc + 2].string, stream); - return; - - case OP_LONG: - (*pos) += 3; - value_print (value_from_long (exp->elts[pc + 1].type, - exp->elts[pc + 2].longconst), - stream, 0, Val_no_prettyprint); - return; - - case OP_DOUBLE: - (*pos) += 3; - value_print (value_from_double (exp->elts[pc + 1].type, - exp->elts[pc + 2].doubleconst), - stream, 0, Val_no_prettyprint); - return; - - case OP_VAR_VALUE: - (*pos) += 2; - fputs_filtered (SYMBOL_NAME (exp->elts[pc + 1].symbol), stream); - return; - - case OP_LAST: - (*pos) += 2; - fprintf_filtered (stream, "$%d", - longest_to_int (exp->elts[pc + 1].longconst)); - return; - - case OP_REGISTER: - (*pos) += 2; - fprintf_filtered (stream, "$%s", - longest_to_int (reg_names[exp->elts[pc + 1].longconst])); - return; - - case OP_INTERNALVAR: - (*pos) += 2; - fprintf_filtered (stream, "$%s", - internalvar_name (exp->elts[pc + 1].internalvar)); - return; - - case OP_FUNCALL: - (*pos) += 2; - nargs = longest_to_int (exp->elts[pc + 1].longconst); - print_subexp (exp, pos, stream, PREC_SUFFIX); - fputs_filtered (" (", stream); - for (tem = 0; tem < nargs; tem++) - { - if (tem != 0) - fputs_filtered (", ", stream); - print_subexp (exp, pos, stream, PREC_ABOVE_COMMA); - } - fputs_filtered (")", stream); - return; - - case OP_STRING: - nargs = strlen (&exp->elts[pc + 1].string); - (*pos) += 2 + (nargs + sizeof (union exp_element)) / sizeof (union exp_element); - fputs_filtered ("\"", stream); - for (tem = 0; tem < nargs; tem++) - printchar ((&exp->elts[pc + 1].string)[tem], stream, '"'); - fputs_filtered ("\"", stream); - return; - - case TERNOP_COND: - if ((int) prec > (int) PREC_COMMA) - fputs_filtered ("(", stream); - /* Print the subexpressions, forcing parentheses - around any binary operations within them. - This is more parentheses than are strictly necessary, - but it looks clearer. */ - print_subexp (exp, pos, stream, PREC_HYPER); - fputs_filtered (" ? ", stream); - print_subexp (exp, pos, stream, PREC_HYPER); - fputs_filtered (" : ", stream); - print_subexp (exp, pos, stream, PREC_HYPER); - if ((int) prec > (int) PREC_COMMA) - fputs_filtered (")", stream); - return; - - case STRUCTOP_STRUCT: - tem = strlen (&exp->elts[pc + 1].string); - (*pos) += 2 + (tem + sizeof (union exp_element)) / sizeof (union exp_element); - print_subexp (exp, pos, stream, PREC_SUFFIX); - fputs_filtered (".", stream); - fputs_filtered (&exp->elts[pc + 1].string, stream); - return; - - case STRUCTOP_PTR: - tem = strlen (&exp->elts[pc + 1].string); - (*pos) += 2 + (tem + sizeof (union exp_element)) / sizeof (union exp_element); - print_subexp (exp, pos, stream, PREC_SUFFIX); - fputs_filtered ("->", stream); - fputs_filtered (&exp->elts[pc + 1].string, stream); - return; - - case BINOP_SUBSCRIPT: - print_subexp (exp, pos, stream, PREC_SUFFIX); - fputs_filtered ("[", stream); - print_subexp (exp, pos, stream, PREC_ABOVE_COMMA); - fputs_filtered ("]", stream); - return; - - case UNOP_POSTINCREMENT: - print_subexp (exp, pos, stream, PREC_SUFFIX); - fputs_filtered ("++", stream); - return; - - case UNOP_POSTDECREMENT: - print_subexp (exp, pos, stream, PREC_SUFFIX); - fputs_filtered ("--", stream); - return; - - case UNOP_CAST: - (*pos) += 2; - if ((int) prec > (int) PREC_PREFIX) - fputs_filtered ("(", stream); - fputs_filtered ("(", stream); - type_print (exp->elts[pc + 1].type, "", stream, 0); - fputs_filtered (") ", stream); - print_subexp (exp, pos, stream, PREC_PREFIX); - if ((int) prec > (int) PREC_PREFIX) - fputs_filtered (")", stream); - return; - - case UNOP_MEMVAL: - (*pos) += 2; - if ((int) prec > (int) PREC_PREFIX) - fputs_filtered ("(", stream); - fputs_filtered ("{", stream); - type_print (exp->elts[pc + 1].type, "", stream, 0); - fputs_filtered ("} ", stream); - print_subexp (exp, pos, stream, PREC_PREFIX); - if ((int) prec > (int) PREC_PREFIX) - fputs_filtered (")", stream); - return; - - case BINOP_ASSIGN_MODIFY: - opcode = exp->elts[pc + 1].opcode; - (*pos) += 2; - myprec = PREC_ASSIGN; - assoc = 1; - assign_modify = 1; - for (tem = 0; tem < sizeof op_print_tab / sizeof op_print_tab[0]; tem++) - if (op_print_tab[tem].opcode == opcode) - { - op_str = op_print_tab[tem].string; - break; - } - break; - - case OP_THIS: - ++(*pos); - fputs_filtered ("this", stream); - return; - - default: - for (tem = 0; tem < sizeof op_print_tab / sizeof op_print_tab[0]; tem++) - if (op_print_tab[tem].opcode == opcode) - { - op_str = op_print_tab[tem].string; - myprec = op_print_tab[tem].precedence; - assoc = op_print_tab[tem].right_assoc; - break; - } - } - - if ((int) myprec < (int) prec) - fputs_filtered ("(", stream); - if ((int) opcode > (int) BINOP_END) - { - /* Unary prefix operator. */ - fputs_filtered (op_str, stream); - print_subexp (exp, pos, stream, PREC_PREFIX); - } - else - { - /* Binary operator. */ - /* Print left operand. - If operator is right-associative, - increment precedence for this operand. */ - print_subexp (exp, pos, stream, - (enum precedence) ((int) myprec + assoc)); - /* Print the operator itself. */ - if (assign_modify) - fprintf_filtered (stream, " %s= ", op_str); - else if (op_str[0] == ',') - fprintf_filtered (stream, "%s ", op_str); - else - fprintf_filtered (stream, " %s ", op_str); - /* Print right operand. - If operator is left-associative, - increment precedence for this operand. */ - print_subexp (exp, pos, stream, - (enum precedence) ((int) myprec + !assoc)); - } - if ((int) myprec < (int) prec) - fputs_filtered (")", stream); -} diff --git a/gdb/expread.tab.c b/gdb/expread.tab.c deleted file mode 100755 index bb9894c9c86..00000000000 --- a/gdb/expread.tab.c +++ /dev/null @@ -1,2948 +0,0 @@ - -/* A Bison parser, made from ./expread.y */ - -#define INT 258 -#define CHAR 259 -#define UINT 260 -#define FLOAT 261 -#define STRING 262 -#define NAME 263 -#define BLOCKNAME 264 -#define TYPENAME 265 -#define NAME_OR_INT 266 -#define NAME_OR_UINT 267 -#define STRUCT 268 -#define UNION 269 -#define ENUM 270 -#define SIZEOF 271 -#define UNSIGNED 272 -#define COLONCOLON 273 -#define ERROR 274 -#define SIGNED 275 -#define LONG 276 -#define SHORT 277 -#define INT_KEYWORD 278 -#define LAST 279 -#define REGNAME 280 -#define VARIABLE 281 -#define ASSIGN_MODIFY 282 -#define THIS 283 -#define ABOVE_COMMA 284 -#define OR 285 -#define AND 286 -#define EQUAL 287 -#define NOTEQUAL 288 -#define LEQ 289 -#define GEQ 290 -#define LSH 291 -#define RSH 292 -#define UNARY 293 -#define INCREMENT 294 -#define DECREMENT 295 -#define ARROW 296 - -#line 29 "./expread.y" - -#include -#include "defs.h" -#include "param.h" -#include "symtab.h" -#include "frame.h" -#include "expression.h" -#include "value.h" -#include "command.h" - -static struct expression *expout; -static int expout_size; -static int expout_ptr; - -static int yylex (); -static void yyerror (); -static void write_exp_elt (); -static void write_exp_elt_opcode (); -static void write_exp_elt_sym (); -static void write_exp_elt_longcst (); -static void write_exp_elt_dblcst (); -static void write_exp_elt_type (); -static void write_exp_elt_intern (); -static void write_exp_string (); -static void start_arglist (); -static int end_arglist (); -static void free_funcalls (); -static char *copy_name (); -static int parse_number (); - -/* If this is nonzero, this block is used as the lexical context - for symbol names. */ - -static struct block *expression_context_block; - -/* The innermost context required by the stack and register variables - we've encountered so far. */ -struct block *innermost_block; - -/* The block in which the most recently discovered symbol was found. */ -struct block *block_found; - -/* Number of arguments seen so far in innermost function call. */ -static int arglist_len; - -/* Data structure for saving values of arglist_len - for function calls whose arguments contain other function calls. */ - -struct funcall - { - struct funcall *next; - int arglist_len; - }; - -struct funcall *funcall_chain; - -/* This kind of datum is used to represent the name - of a symbol token. */ - -struct stoken - { - char *ptr; - int length; - }; - -struct ttype - { - struct stoken stoken; - struct type *type; - }; - -struct symtoken - { - struct stoken stoken; - struct symbol *sym; - int is_a_field_of_this; - }; - -/* For parsing of complicated types. - An array should be preceded in the list by the size of the array. */ -enum type_pieces - {tp_end = -1, tp_pointer, tp_reference, tp_array, tp_function}; -/* The stack can contain either an enum type_pieces or an int. */ -union type_stack_elt { - enum type_pieces piece; - int int_val; -}; -static union type_stack_elt *type_stack; -static int type_stack_depth, type_stack_size; - -static void push_type (); -static void push_type_int (); -static enum type_pieces pop_type (); -static int pop_type_int (); - -/* Allow debugging of parsing. */ -#define YYDEBUG 1 - -#line 132 "./expread.y" -typedef union - { - LONGEST lval; - unsigned LONGEST ulval; - double dval; - struct symbol *sym; - struct type *tval; - struct stoken sval; - struct ttype tsym; - struct symtoken ssym; - int voidval; - struct block *bval; - enum exp_opcode opcode; - struct internalvar *ivar; - - struct type **tvec; - int *ivec; - } YYSTYPE; - -#ifndef YYLTYPE -typedef - struct yyltype - { - int timestamp; - int first_line; - int first_column; - int last_line; - int last_column; - char *text; - } - yyltype; - -#define YYLTYPE yyltype -#endif - -#include - -#ifndef __STDC__ -#define const -#endif - - - -#define YYFINAL 197 -#define YYFLAG -32768 -#define YYNTBASE 66 - -#define YYTRANSLATE(x) ((unsigned)(x) <= 296 ? yytranslate[x] : 84) - -static const char yytranslate[] = { 0, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 59, 2, 2, 2, 51, 37, 2, 58, - 62, 49, 47, 29, 48, 56, 50, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 65, 2, 40, - 31, 41, 32, 46, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 57, 2, 61, 36, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 63, 35, 64, 60, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, - 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, - 26, 27, 28, 30, 33, 34, 38, 39, 42, 43, - 44, 45, 52, 53, 54, 55 -}; - -static const short yyprhs[] = { 0, - 0, 2, 4, 8, 11, 14, 17, 20, 23, 26, - 29, 32, 35, 38, 42, 47, 51, 56, 61, 62, - 68, 69, 71, 75, 80, 85, 89, 93, 97, 101, - 105, 109, 113, 117, 121, 125, 129, 133, 137, 141, - 145, 149, 153, 157, 161, 165, 171, 175, 179, 181, - 183, 185, 187, 189, 191, 193, 195, 197, 199, 204, - 206, 208, 210, 214, 218, 222, 227, 230, 232, 234, - 237, 239, 242, 244, 247, 249, 253, 256, 258, 261, - 263, 266, 270, 273, 275, 279, 286, 295, 305, 307, - 309, 311, 313, 316, 320, 323, 327, 331, 336, 339, - 343, 346, 349, 352, 355, 357, 360, 362, 364, 366, - 368, 370, 372, 376, 378, 380, 382, 384, 386, 388 -}; - -static const short yyrhs[] = { 67, - 0, 68, 0, 67, 29, 68, 0, 49, 68, 0, - 37, 68, 0, 48, 68, 0, 59, 68, 0, 60, - 68, 0, 53, 68, 0, 54, 68, 0, 68, 53, - 0, 68, 54, 0, 16, 68, 0, 68, 55, 82, - 0, 68, 55, 49, 68, 0, 68, 56, 82, 0, - 68, 56, 49, 68, 0, 68, 57, 67, 61, 0, - 0, 68, 58, 69, 70, 62, 0, 0, 68, 0, - 70, 29, 68, 0, 63, 78, 64, 68, 0, 58, - 78, 62, 68, 0, 58, 67, 62, 0, 68, 46, - 68, 0, 68, 49, 68, 0, 68, 50, 68, 0, - 68, 51, 68, 0, 68, 47, 68, 0, 68, 48, - 68, 0, 68, 44, 68, 0, 68, 45, 68, 0, - 68, 38, 68, 0, 68, 39, 68, 0, 68, 42, - 68, 0, 68, 43, 68, 0, 68, 40, 68, 0, - 68, 41, 68, 0, 68, 37, 68, 0, 68, 36, - 68, 0, 68, 35, 68, 0, 68, 34, 68, 0, - 68, 33, 68, 0, 68, 32, 68, 65, 68, 0, - 68, 31, 68, 0, 68, 27, 68, 0, 3, 0, - 11, 0, 5, 0, 12, 0, 4, 0, 6, 0, - 72, 0, 24, 0, 25, 0, 26, 0, 16, 58, - 78, 62, 0, 7, 0, 28, 0, 9, 0, 71, - 18, 82, 0, 71, 18, 82, 0, 79, 18, 82, - 0, 79, 18, 60, 82, 0, 18, 82, 0, 83, - 0, 79, 0, 79, 74, 0, 49, 0, 49, 74, - 0, 37, 0, 37, 74, 0, 75, 0, 58, 74, - 62, 0, 75, 76, 0, 76, 0, 75, 77, 0, - 77, 0, 57, 61, 0, 57, 3, 61, 0, 58, - 62, 0, 73, 0, 79, 18, 49, 0, 78, 58, - 79, 18, 49, 62, 0, 78, 58, 79, 18, 49, - 62, 58, 62, 0, 78, 58, 79, 18, 49, 62, - 58, 81, 62, 0, 10, 0, 23, 0, 21, 0, - 22, 0, 21, 23, 0, 17, 21, 23, 0, 21, - 21, 0, 21, 21, 23, 0, 17, 21, 21, 0, - 17, 21, 21, 23, 0, 22, 23, 0, 17, 22, - 23, 0, 13, 82, 0, 14, 82, 0, 15, 82, - 0, 17, 80, 0, 17, 0, 20, 80, 0, 20, - 0, 10, 0, 23, 0, 21, 0, 22, 0, 78, - 0, 81, 29, 78, 0, 8, 0, 9, 0, 10, - 0, 11, 0, 12, 0, 8, 0, 9, 0 -}; - -#if YYDEBUG != 0 -static const short yyrline[] = { 0, - 225, 229, 230, 235, 238, 241, 245, 249, 253, 257, - 261, 265, 269, 273, 279, 283, 289, 293, 297, 301, - 307, 310, 314, 318, 324, 330, 336, 340, 344, 348, - 352, 356, 360, 364, 368, 372, 376, 380, 384, 388, - 392, 396, 400, 404, 408, 412, 416, 420, 426, 436, - 449, 461, 474, 481, 488, 491, 497, 503, 509, 516, - 523, 530, 548, 558, 570, 583, 601, 647, 741, 742, - 777, 779, 781, 783, 785, 788, 790, 795, 801, 803, - 807, 809, 813, 817, 818, 820, 822, 825, 832, 834, - 836, 838, 840, 842, 844, 846, 848, 850, 852, 854, - 856, 859, 862, 865, 867, 869, 871, 875, 876, 882, - 888, 897, 902, 909, 910, 911, 912, 913, 916, 917 -}; - -static const char * const yytname[] = { "$", -"error","$illegal.","INT","CHAR","UINT","FLOAT","STRING","NAME","BLOCKNAME","TYPENAME", -"NAME_OR_INT","NAME_OR_UINT","STRUCT","UNION","ENUM","SIZEOF","UNSIGNED","COLONCOLON","ERROR","SIGNED", -"LONG","SHORT","INT_KEYWORD","LAST","REGNAME","VARIABLE","ASSIGN_MODIFY","THIS","','","ABOVE_COMMA", -"'='","'?'","OR","AND","'|'","'^'","'&'","EQUAL","NOTEQUAL","'<'", -"'>'","LEQ","GEQ","LSH","RSH","'@'","'+'","'-'","'*'","'/'", -"'%'","UNARY","INCREMENT","DECREMENT","ARROW","'.'","'['","'('","'!'","'~'", -"']'","')'","'{'","'}'","':'","start","exp1","exp","@1","arglist", -"block","variable","ptype","abs_decl","direct_abs_decl","array_mod","func_mod","type","typebase","typename", -"nonempty_typelist","name","name_not_typename","" -}; -#endif - -static const short yyr1[] = { 0, - 66, 67, 67, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 69, 68, - 70, 70, 70, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 71, 71, 72, 72, 72, 72, 72, 73, 73, - 74, 74, 74, 74, 74, 75, 75, 75, 75, 75, - 76, 76, 77, 78, 78, 78, 78, 78, 79, 79, - 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, - 79, 79, 79, 79, 79, 79, 79, 80, 80, 80, - 80, 81, 81, 82, 82, 82, 82, 82, 83, 83 -}; - -static const short yyr2[] = { 0, - 1, 1, 3, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 3, 4, 3, 4, 4, 0, 5, - 0, 1, 3, 4, 4, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 5, 3, 3, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 4, 1, - 1, 1, 3, 3, 3, 4, 2, 1, 1, 2, - 1, 2, 1, 2, 1, 3, 2, 1, 2, 1, - 2, 3, 2, 1, 3, 6, 8, 9, 1, 1, - 1, 1, 2, 3, 2, 3, 3, 4, 2, 3, - 2, 2, 2, 2, 1, 2, 1, 1, 1, 1, - 1, 1, 3, 1, 1, 1, 1, 1, 1, 1 -}; - -static const short yydefact[] = { 0, - 49, 53, 51, 54, 60, 119, 120, 89, 50, 52, - 0, 0, 0, 0, 105, 0, 107, 91, 92, 90, - 56, 57, 58, 61, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 1, 2, 0, 55, 0, 68, 114, - 115, 116, 117, 118, 101, 102, 103, 0, 13, 108, - 110, 111, 109, 104, 67, 110, 111, 106, 95, 93, - 99, 5, 6, 4, 9, 10, 0, 84, 0, 69, - 7, 8, 0, 69, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 11, 12, 0, - 0, 0, 19, 0, 0, 0, 97, 94, 100, 96, - 26, 0, 0, 0, 73, 71, 0, 0, 70, 75, - 78, 80, 0, 0, 3, 48, 47, 0, 45, 44, - 43, 42, 41, 35, 36, 39, 40, 37, 38, 33, - 34, 27, 31, 32, 28, 29, 30, 0, 14, 0, - 16, 0, 21, 64, 0, 65, 59, 98, 0, 25, - 85, 74, 72, 0, 81, 83, 0, 0, 77, 79, - 24, 0, 15, 17, 18, 22, 0, 66, 0, 82, - 76, 46, 0, 20, 0, 23, 86, 0, 87, 112, - 0, 0, 88, 113, 0, 0, 0 -}; - -static const short yydefgoto[] = { 195, - 67, 35, 153, 177, 36, 37, 68, 119, 120, 121, - 122, 69, 38, 54, 191, 156, 39 -}; - -static const short yypact[] = { 167, --32768,-32768,-32768,-32768,-32768,-32768, 7,-32768,-32768,-32768, - 22, 22, 22, 228, 190, 22, 245, 119, -7,-32768, --32768,-32768,-32768,-32768, 167, 167, 167, 167, 167, 167, - 167, 167, 528, 60, 303, 33,-32768, 76,-32768,-32768, --32768,-32768,-32768,-32768,-32768,-32768,-32768, 167, 216,-32768, - 134, 77,-32768,-32768,-32768,-32768,-32768,-32768, 78,-32768, --32768, 216, 216, 216, 216, 216, 59,-32768, -52, 75, - 216, 216, -55, 80, 167, 167, 167, 167, 167, 167, - 167, 167, 167, 167, 167, 167, 167, 167, 167, 167, - 167, 167, 167, 167, 167, 167, 167,-32768,-32768, 198, - 249, 167,-32768, 22, 138, -34, 90,-32768,-32768,-32768, --32768, 528, 167, 96, 165, 165, 26, 104,-32768, -50, --32768,-32768, 167, 47, 303, 303, 303, 268, 355, 379, - 402, 424, 445, 464, 464, 479, 479, 479, 479, 506, - 506, 518, 529, 529, 216, 216, 216, 167,-32768, 167, --32768, -2, 167, 98, 22,-32768, 32,-32768, 113, 216, --32768,-32768,-32768, 62,-32768,-32768, 82, 106,-32768,-32768, - 216, 167, 216, 216,-32768, 303, 68,-32768, 137,-32768, --32768, 330, 167,-32768, 132, 303, 139, 105,-32768, 141, - 73, 528,-32768, 141, 196, 201,-32768 -}; - -static const short yypgoto[] = {-32768, - 1, -14,-32768,-32768,-32768,-32768,-32768, 36,-32768, 83, - 85, -29, -28, 200,-32768, 10,-32768 -}; - - -#define YYLAST 587 - - -static const short yytable[] = { 49, - 34, 70, 112, 73, 74, 112, 117, 168, 123, 113, - 62, 63, 64, 65, 66, 61, 71, 72, 106, 70, - 45, 46, 47, 112, -62, 55, 75, 157, 164, 40, - 41, 42, 43, 44, 1, 2, 3, 4, 5, 6, - 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, - 104, 17, 18, 19, 20, 21, 22, 23, 175, 24, - 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, - 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, - 145, 146, 147, 159, 28, 29, 165, 75, 75, 30, - 31, 32, 114, 105, 33, 161, 183, 124, 160, 109, - 110, 192, 152, 40, 41, 42, 43, 44, 171, 149, - 151, 115, 158, 154, 8, -63, 115, 11, 12, 13, - 111, 15, 180, 116, 17, 18, 19, 20, 116, 184, - 179, 117, 118, 173, 193, 174, 117, 118, 176, 59, - 115, 60, 160, 181, 161, 40, 41, 42, 43, 44, - 162, 163, 116, 167, 107, 155, 108, 182, 190, 74, - 117, 118, 194, 74, 178, 166, 189, 166, 186, 1, - 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, - 12, 13, 14, 15, 16, 185, 17, 18, 19, 20, - 21, 22, 23, 187, 24, 196, 188, 155, 112, 50, - 197, 115, 169, 25, 170, 40, 41, 42, 43, 44, - 51, 52, 53, 116, 26, 27, 58, 0, 0, 28, - 29, 117, 118, 0, 30, 31, 32, 0, 0, 33, - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - 11, 12, 13, 14, 15, 16, 148, 17, 18, 19, - 20, 21, 22, 23, 50, 24, 40, 41, 42, 43, - 44, 0, 0, 0, 25, 56, 57, 53, 98, 99, - 100, 101, 102, 103, 0, 26, 27, 0, 0, 0, - 28, 29, 0, 0, 0, 48, 31, 32, 0, 0, - 33, 0, 0, 0, 76, 0, 0, 150, 77, 78, - 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, - 89, 90, 91, 92, 93, 94, 95, 96, 97, 0, - 98, 99, 100, 101, 102, 103, 0, 0, 0, 76, - 0, 0, 172, 77, 78, 79, 80, 81, 82, 83, - 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, - 94, 95, 96, 97, 0, 98, 99, 100, 101, 102, - 103, 78, 79, 80, 81, 82, 83, 84, 85, 86, - 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, - 97, 0, 98, 99, 100, 101, 102, 103, 80, 81, - 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, - 92, 93, 94, 95, 96, 97, 0, 98, 99, 100, - 101, 102, 103, 81, 82, 83, 84, 85, 86, 87, - 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, - 0, 98, 99, 100, 101, 102, 103, 82, 83, 84, - 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, - 95, 96, 97, 0, 98, 99, 100, 101, 102, 103, - 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, - 93, 94, 95, 96, 97, 0, 98, 99, 100, 101, - 102, 103, 84, 85, 86, 87, 88, 89, 90, 91, - 92, 93, 94, 95, 96, 97, 0, 98, 99, 100, - 101, 102, 103, 86, 87, 88, 89, 90, 91, 92, - 93, 94, 95, 96, 97, 0, 98, 99, 100, 101, - 102, 103, 90, 91, 92, 93, 94, 95, 96, 97, - 0, 98, 99, 100, 101, 102, 103, 8, 0, 0, - 11, 12, 13, 0, 15, 0, 0, 17, 18, 19, - 20, 92, 93, 94, 95, 96, 97, 0, 98, 99, - 100, 101, 102, 103, 93, 94, 95, 96, 97, 0, - 98, 99, 100, 101, 102, 103, 0, 95, 96, 97, - 0, 98, 99, 100, 101, 102, 103 -}; - -static const short yycheck[] = { 14, - 0, 30, 58, 33, 33, 58, 57, 58, 64, 62, - 25, 26, 27, 28, 29, 23, 31, 32, 48, 48, - 11, 12, 13, 58, 18, 16, 29, 62, 3, 8, - 9, 10, 11, 12, 3, 4, 5, 6, 7, 8, - 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, - 18, 20, 21, 22, 23, 24, 25, 26, 61, 28, - 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, - 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, - 95, 96, 97, 112, 53, 54, 61, 29, 29, 58, - 59, 60, 18, 18, 63, 49, 29, 18, 113, 23, - 23, 29, 102, 8, 9, 10, 11, 12, 123, 100, - 101, 37, 23, 104, 10, 18, 37, 13, 14, 15, - 62, 17, 61, 49, 20, 21, 22, 23, 49, 62, - 18, 57, 58, 148, 62, 150, 57, 58, 153, 21, - 37, 23, 157, 62, 49, 8, 9, 10, 11, 12, - 115, 116, 49, 118, 21, 60, 23, 172, 188, 188, - 57, 58, 192, 192, 155, 62, 62, 62, 183, 3, - 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, - 14, 15, 16, 17, 18, 49, 20, 21, 22, 23, - 24, 25, 26, 62, 28, 0, 58, 60, 58, 10, - 0, 37, 120, 37, 120, 8, 9, 10, 11, 12, - 21, 22, 23, 49, 48, 49, 17, -1, -1, 53, - 54, 57, 58, -1, 58, 59, 60, -1, -1, 63, - 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, - 13, 14, 15, 16, 17, 18, 49, 20, 21, 22, - 23, 24, 25, 26, 10, 28, 8, 9, 10, 11, - 12, -1, -1, -1, 37, 21, 22, 23, 53, 54, - 55, 56, 57, 58, -1, 48, 49, -1, -1, -1, - 53, 54, -1, -1, -1, 58, 59, 60, -1, -1, - 63, -1, -1, -1, 27, -1, -1, 49, 31, 32, - 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, - 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, - 53, 54, 55, 56, 57, 58, -1, -1, -1, 27, - -1, -1, 65, 31, 32, 33, 34, 35, 36, 37, - 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, -1, 53, 54, 55, 56, 57, - 58, 32, 33, 34, 35, 36, 37, 38, 39, 40, - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, - 51, -1, 53, 54, 55, 56, 57, 58, 34, 35, - 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, - 46, 47, 48, 49, 50, 51, -1, 53, 54, 55, - 56, 57, 58, 35, 36, 37, 38, 39, 40, 41, - 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, - -1, 53, 54, 55, 56, 57, 58, 36, 37, 38, - 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, - 49, 50, 51, -1, 53, 54, 55, 56, 57, 58, - 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, - 47, 48, 49, 50, 51, -1, 53, 54, 55, 56, - 57, 58, 38, 39, 40, 41, 42, 43, 44, 45, - 46, 47, 48, 49, 50, 51, -1, 53, 54, 55, - 56, 57, 58, 40, 41, 42, 43, 44, 45, 46, - 47, 48, 49, 50, 51, -1, 53, 54, 55, 56, - 57, 58, 44, 45, 46, 47, 48, 49, 50, 51, - -1, 53, 54, 55, 56, 57, 58, 10, -1, -1, - 13, 14, 15, -1, 17, -1, -1, 20, 21, 22, - 23, 46, 47, 48, 49, 50, 51, -1, 53, 54, - 55, 56, 57, 58, 47, 48, 49, 50, 51, -1, - 53, 54, 55, 56, 57, 58, -1, 49, 50, 51, - -1, 53, 54, 55, 56, 57, 58 -}; -/* -*-C-*- Note some compilers choke on comments on `#line' lines. */ -#line 3 "/usr/latest/lib/bison.simple" - -/* Skeleton output parser for bison, - Copyright (C) 1984, 1989, 1990 Bob Corbett and Richard Stallman - - 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - - -#ifndef alloca -#ifdef __GNUC__ -#define alloca __builtin_alloca -#else /* Not GNU C. */ -#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) -#include -#else /* Not sparc */ -#ifdef MSDOS -#include -#endif /* MSDOS */ -#endif /* Not sparc. */ -#endif /* Not GNU C. */ -#endif /* alloca not defined. */ - -/* This is the parser code that is written into each bison parser - when the %semantic_parser declaration is not specified in the grammar. - It was written by Richard Stallman by simplifying the hairy parser - used when %semantic_parser is specified. */ - -/* Note: there must be only one dollar sign in this file. - It is replaced by the list of actions, each action - as one case of the switch. */ - -#define yyerrok (yyerrstatus = 0) -#define yyclearin (yychar = YYEMPTY) -#define YYEMPTY -2 -#define YYEOF 0 -#define YYACCEPT return(0) -#define YYABORT return(1) -#define YYERROR goto yyerrlab1 -/* Like YYERROR except do call yyerror. - This remains here temporarily to ease the - transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. */ -#define YYFAIL goto yyerrlab -#define YYRECOVERING() (!!yyerrstatus) -#define YYBACKUP(token, value) \ -do \ - if (yychar == YYEMPTY && yylen == 1) \ - { yychar = (token), yylval = (value); \ - yychar1 = YYTRANSLATE (yychar); \ - YYPOPSTACK; \ - goto yybackup; \ - } \ - else \ - { yyerror ("syntax error: cannot back up"); YYERROR; } \ -while (0) - -#define YYTERROR 1 -#define YYERRCODE 256 - -#ifndef YYPURE -#define YYLEX yylex() -#endif - -#ifdef YYPURE -#ifdef YYLSP_NEEDED -#define YYLEX yylex(&yylval, &yylloc) -#else -#define YYLEX yylex(&yylval) -#endif -#endif - -/* If nonreentrant, generate the variables here */ - -#ifndef YYPURE - -int yychar; /* the lookahead symbol */ -YYSTYPE yylval; /* the semantic value of the */ - /* lookahead symbol */ - -#ifdef YYLSP_NEEDED -YYLTYPE yylloc; /* location data for the lookahead */ - /* symbol */ -#endif - -int yynerrs; /* number of parse errors so far */ -#endif /* not YYPURE */ - -#if YYDEBUG != 0 -int yydebug; /* nonzero means print parse trace */ -/* Since this is uninitialized, it does not stop multiple parsers - from coexisting. */ -#endif - -/* YYINITDEPTH indicates the initial size of the parser's stacks */ - -#ifndef YYINITDEPTH -#define YYINITDEPTH 200 -#endif - -/* YYMAXDEPTH is the maximum size the stacks can grow to - (effective only if the built-in stack extension method is used). */ - -#if YYMAXDEPTH == 0 -#undef YYMAXDEPTH -#endif - -#ifndef YYMAXDEPTH -#define YYMAXDEPTH 10000 -#endif - -#ifndef __cplusplus - -/* This is the most reliable way to avoid incompatibilities - in available built-in functions on various systems. */ -static void -__yy_bcopy (from, to, count) - char *from; - char *to; - int count; -{ - register char *f = from; - register char *t = to; - register int i = count; - - while (i-- > 0) - *t++ = *f++; -} - -#else /* __cplusplus */ - -/* This is the most reliable way to avoid incompatibilities - in available built-in functions on various systems. */ -static void -__yy_bcopy (char *from, char *to, int count) -{ - register char *f = from; - register char *t = to; - register int i = count; - - while (i-- > 0) - *t++ = *f++; -} - -#endif - -#line 160 "/usr/latest/lib/bison.simple" -int -yyparse() -{ - register int yystate; - register int yyn; - register short *yyssp; - register YYSTYPE *yyvsp; - int yyerrstatus; /* number of tokens to shift before error messages enabled */ - int yychar1; /* lookahead token as an internal (translated) token number */ - - short yyssa[YYINITDEPTH]; /* the state stack */ - YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ - - short *yyss = yyssa; /* refer to the stacks thru separate pointers */ - YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ - -#ifdef YYLSP_NEEDED - YYLTYPE *yyls = yylsa; - YYLTYPE *yylsp; - YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */ - -#define YYPOPSTACK (yyvsp--, yysp--, yylsp--) -#else -#define YYPOPSTACK (yyvsp--, yysp--) -#endif - - int yystacksize = YYINITDEPTH; - -#ifdef YYPURE - int yychar; - YYSTYPE yylval; - int yynerrs; -#ifdef YYLSP_NEEDED - YYLTYPE yylloc; -#endif -#endif - - YYSTYPE yyval; /* the variable used to return */ - /* semantic values from the action */ - /* routines */ - - int yylen; - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Starting parse\n"); -#endif - - yystate = 0; - yyerrstatus = 0; - yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ - - /* Initialize stack pointers. - Waste one element of value and location stack - so that they stay on the same level as the state stack. */ - - yyssp = yyss - 1; - yyvsp = yyvs; -#ifdef YYLSP_NEEDED - yylsp = yyls; -#endif - -/* Push a new state, which is found in yystate . */ -/* In all cases, when you get here, the value and location stacks - have just been pushed. so pushing a state here evens the stacks. */ -yynewstate: - - *++yyssp = yystate; - - if (yyssp >= yyss + yystacksize - 1) - { - /* Give user a chance to reallocate the stack */ - /* Use copies of these so that the &'s don't force the real ones into memory. */ - YYSTYPE *yyvs1 = yyvs; - short *yyss1 = yyss; -#ifdef YYLSP_NEEDED - YYLTYPE *yyls1 = yyls; -#endif - - /* Get the current used size of the three stacks, in elements. */ - int size = yyssp - yyss + 1; - -#ifdef yyoverflow - /* Each stack pointer address is followed by the size of - the data in use in that stack, in bytes. */ - yyoverflow("parser stack overflow", - &yyss1, size * sizeof (*yyssp), - &yyvs1, size * sizeof (*yyvsp), -#ifdef YYLSP_NEEDED - &yyls1, size * sizeof (*yylsp), -#endif - &yystacksize); - - yyss = yyss1; yyvs = yyvs1; -#ifdef YYLSP_NEEDED - yyls = yyls1; -#endif -#else /* no yyoverflow */ - /* Extend the stack our own way. */ - if (yystacksize >= YYMAXDEPTH) - { - yyerror("parser stack overflow"); - return 2; - } - yystacksize *= 2; - if (yystacksize > YYMAXDEPTH) - yystacksize = YYMAXDEPTH; - yyss = (short *) alloca (yystacksize * sizeof (*yyssp)); - __yy_bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp)); - yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp)); - __yy_bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp)); -#ifdef YYLSP_NEEDED - yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp)); - __yy_bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp)); -#endif -#endif /* no yyoverflow */ - - yyssp = yyss + size - 1; - yyvsp = yyvs + size - 1; -#ifdef YYLSP_NEEDED - yylsp = yyls + size - 1; -#endif - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Stack size increased to %d\n", yystacksize); -#endif - - if (yyssp >= yyss + yystacksize - 1) - YYABORT; - } - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Entering state %d\n", yystate); -#endif - - yybackup: - -/* Do appropriate processing given the current state. */ -/* Read a lookahead token if we need one and don't already have one. */ -/* yyresume: */ - - /* First try to decide what to do without reference to lookahead token. */ - - yyn = yypact[yystate]; - if (yyn == YYFLAG) - goto yydefault; - - /* Not known => get a lookahead token if don't already have one. */ - - /* yychar is either YYEMPTY or YYEOF - or a valid token in external form. */ - - if (yychar == YYEMPTY) - { -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Reading a token: "); -#endif - yychar = YYLEX; - } - - /* Convert token to internal form (in yychar1) for indexing tables with */ - - if (yychar <= 0) /* This means end of input. */ - { - yychar1 = 0; - yychar = YYEOF; /* Don't call YYLEX any more */ - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Now at end of input.\n"); -#endif - } - else - { - yychar1 = YYTRANSLATE(yychar); - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Next token is %d (%s)\n", yychar, yytname[yychar1]); -#endif - } - - yyn += yychar1; - if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) - goto yydefault; - - yyn = yytable[yyn]; - - /* yyn is what to do for this token type in this state. - Negative => reduce, -yyn is rule number. - Positive => shift, yyn is new state. - New state is final state => don't bother to shift, - just return success. - 0, or most negative number => error. */ - - if (yyn < 0) - { - if (yyn == YYFLAG) - goto yyerrlab; - yyn = -yyn; - goto yyreduce; - } - else if (yyn == 0) - goto yyerrlab; - - if (yyn == YYFINAL) - YYACCEPT; - - /* Shift the lookahead token. */ - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); -#endif - - /* Discard the token being shifted unless it is eof. */ - if (yychar != YYEOF) - yychar = YYEMPTY; - - *++yyvsp = yylval; -#ifdef YYLSP_NEEDED - *++yylsp = yylloc; -#endif - - /* count tokens shifted since error; after three, turn off error status. */ - if (yyerrstatus) yyerrstatus--; - - yystate = yyn; - goto yynewstate; - -/* Do the default action for the current state. */ -yydefault: - - yyn = yydefact[yystate]; - if (yyn == 0) - goto yyerrlab; - -/* Do a reduction. yyn is the number of a rule to reduce with. */ -yyreduce: - yylen = yyr2[yyn]; - yyval = yyvsp[1-yylen]; /* implement default value of the action */ - -#if YYDEBUG != 0 - if (yydebug) - { - int i; - - fprintf (stderr, "Reducing via rule %d (line %d), ", - yyn, yyrline[yyn]); - - /* Print the symboles being reduced, and their result. */ - for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) - fprintf (stderr, "%s ", yytname[yyrhs[i]]); - fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); - } -#endif - - - switch (yyn) { - -case 3: -#line 231 "./expread.y" -{ write_exp_elt_opcode (BINOP_COMMA); ; - break;} -case 4: -#line 236 "./expread.y" -{ write_exp_elt_opcode (UNOP_IND); ; - break;} -case 5: -#line 239 "./expread.y" -{ write_exp_elt_opcode (UNOP_ADDR); ; - break;} -case 6: -#line 242 "./expread.y" -{ write_exp_elt_opcode (UNOP_NEG); ; - break;} -case 7: -#line 246 "./expread.y" -{ write_exp_elt_opcode (UNOP_ZEROP); ; - break;} -case 8: -#line 250 "./expread.y" -{ write_exp_elt_opcode (UNOP_LOGNOT); ; - break;} -case 9: -#line 254 "./expread.y" -{ write_exp_elt_opcode (UNOP_PREINCREMENT); ; - break;} -case 10: -#line 258 "./expread.y" -{ write_exp_elt_opcode (UNOP_PREDECREMENT); ; - break;} -case 11: -#line 262 "./expread.y" -{ write_exp_elt_opcode (UNOP_POSTINCREMENT); ; - break;} -case 12: -#line 266 "./expread.y" -{ write_exp_elt_opcode (UNOP_POSTDECREMENT); ; - break;} -case 13: -#line 270 "./expread.y" -{ write_exp_elt_opcode (UNOP_SIZEOF); ; - break;} -case 14: -#line 274 "./expread.y" -{ write_exp_elt_opcode (STRUCTOP_PTR); - write_exp_string (yyvsp[0].sval); - write_exp_elt_opcode (STRUCTOP_PTR); ; - break;} -case 15: -#line 280 "./expread.y" -{ write_exp_elt_opcode (STRUCTOP_MPTR); ; - break;} -case 16: -#line 284 "./expread.y" -{ write_exp_elt_opcode (STRUCTOP_STRUCT); - write_exp_string (yyvsp[0].sval); - write_exp_elt_opcode (STRUCTOP_STRUCT); ; - break;} -case 17: -#line 290 "./expread.y" -{ write_exp_elt_opcode (STRUCTOP_MEMBER); ; - break;} -case 18: -#line 294 "./expread.y" -{ write_exp_elt_opcode (BINOP_SUBSCRIPT); ; - break;} -case 19: -#line 300 "./expread.y" -{ start_arglist (); ; - break;} -case 20: -#line 302 "./expread.y" -{ write_exp_elt_opcode (OP_FUNCALL); - write_exp_elt_longcst ((LONGEST) end_arglist ()); - write_exp_elt_opcode (OP_FUNCALL); ; - break;} -case 22: -#line 311 "./expread.y" -{ arglist_len = 1; ; - break;} -case 23: -#line 315 "./expread.y" -{ arglist_len++; ; - break;} -case 24: -#line 319 "./expread.y" -{ write_exp_elt_opcode (UNOP_MEMVAL); - write_exp_elt_type (yyvsp[-2].tval); - write_exp_elt_opcode (UNOP_MEMVAL); ; - break;} -case 25: -#line 325 "./expread.y" -{ write_exp_elt_opcode (UNOP_CAST); - write_exp_elt_type (yyvsp[-2].tval); - write_exp_elt_opcode (UNOP_CAST); ; - break;} -case 26: -#line 331 "./expread.y" -{ ; - break;} -case 27: -#line 337 "./expread.y" -{ write_exp_elt_opcode (BINOP_REPEAT); ; - break;} -case 28: -#line 341 "./expread.y" -{ write_exp_elt_opcode (BINOP_MUL); ; - break;} -case 29: -#line 345 "./expread.y" -{ write_exp_elt_opcode (BINOP_DIV); ; - break;} -case 30: -#line 349 "./expread.y" -{ write_exp_elt_opcode (BINOP_REM); ; - break;} -case 31: -#line 353 "./expread.y" -{ write_exp_elt_opcode (BINOP_ADD); ; - break;} -case 32: -#line 357 "./expread.y" -{ write_exp_elt_opcode (BINOP_SUB); ; - break;} -case 33: -#line 361 "./expread.y" -{ write_exp_elt_opcode (BINOP_LSH); ; - break;} -case 34: -#line 365 "./expread.y" -{ write_exp_elt_opcode (BINOP_RSH); ; - break;} -case 35: -#line 369 "./expread.y" -{ write_exp_elt_opcode (BINOP_EQUAL); ; - break;} -case 36: -#line 373 "./expread.y" -{ write_exp_elt_opcode (BINOP_NOTEQUAL); ; - break;} -case 37: -#line 377 "./expread.y" -{ write_exp_elt_opcode (BINOP_LEQ); ; - break;} -case 38: -#line 381 "./expread.y" -{ write_exp_elt_opcode (BINOP_GEQ); ; - break;} -case 39: -#line 385 "./expread.y" -{ write_exp_elt_opcode (BINOP_LESS); ; - break;} -case 40: -#line 389 "./expread.y" -{ write_exp_elt_opcode (BINOP_GTR); ; - break;} -case 41: -#line 393 "./expread.y" -{ write_exp_elt_opcode (BINOP_LOGAND); ; - break;} -case 42: -#line 397 "./expread.y" -{ write_exp_elt_opcode (BINOP_LOGXOR); ; - break;} -case 43: -#line 401 "./expread.y" -{ write_exp_elt_opcode (BINOP_LOGIOR); ; - break;} -case 44: -#line 405 "./expread.y" -{ write_exp_elt_opcode (BINOP_AND); ; - break;} -case 45: -#line 409 "./expread.y" -{ write_exp_elt_opcode (BINOP_OR); ; - break;} -case 46: -#line 413 "./expread.y" -{ write_exp_elt_opcode (TERNOP_COND); ; - break;} -case 47: -#line 417 "./expread.y" -{ write_exp_elt_opcode (BINOP_ASSIGN); ; - break;} -case 48: -#line 421 "./expread.y" -{ write_exp_elt_opcode (BINOP_ASSIGN_MODIFY); - write_exp_elt_opcode (yyvsp[-1].opcode); - write_exp_elt_opcode (BINOP_ASSIGN_MODIFY); ; - break;} -case 49: -#line 427 "./expread.y" -{ write_exp_elt_opcode (OP_LONG); - if (yyvsp[0].lval == (int) yyvsp[0].lval || yyvsp[0].lval == (unsigned int) yyvsp[0].lval) - write_exp_elt_type (builtin_type_int); - else - write_exp_elt_type (BUILTIN_TYPE_LONGEST); - write_exp_elt_longcst ((LONGEST) yyvsp[0].lval); - write_exp_elt_opcode (OP_LONG); ; - break;} -case 50: -#line 437 "./expread.y" -{ YYSTYPE val; - parse_number (yyvsp[0].ssym.stoken.ptr, yyvsp[0].ssym.stoken.length, 0, &val); - write_exp_elt_opcode (OP_LONG); - if (val.lval == (int) val.lval || - val.lval == (unsigned int) val.lval) - write_exp_elt_type (builtin_type_int); - else - write_exp_elt_type (BUILTIN_TYPE_LONGEST); - write_exp_elt_longcst (val.lval); - write_exp_elt_opcode (OP_LONG); ; - break;} -case 51: -#line 450 "./expread.y" -{ - write_exp_elt_opcode (OP_LONG); - if (yyvsp[0].ulval == (unsigned int) yyvsp[0].ulval) - write_exp_elt_type (builtin_type_unsigned_int); - else - write_exp_elt_type (BUILTIN_TYPE_UNSIGNED_LONGEST); - write_exp_elt_longcst ((LONGEST) yyvsp[0].ulval); - write_exp_elt_opcode (OP_LONG); - ; - break;} -case 52: -#line 462 "./expread.y" -{ YYSTYPE val; - parse_number (yyvsp[0].ssym.stoken.ptr, yyvsp[0].ssym.stoken.length, 0, &val); - write_exp_elt_opcode (OP_LONG); - if (val.ulval == (unsigned int) val.ulval) - write_exp_elt_type (builtin_type_unsigned_int); - else - write_exp_elt_type (BUILTIN_TYPE_UNSIGNED_LONGEST); - write_exp_elt_longcst ((LONGEST)val.ulval); - write_exp_elt_opcode (OP_LONG); - ; - break;} -case 53: -#line 475 "./expread.y" -{ write_exp_elt_opcode (OP_LONG); - write_exp_elt_type (builtin_type_char); - write_exp_elt_longcst ((LONGEST) yyvsp[0].lval); - write_exp_elt_opcode (OP_LONG); ; - break;} -case 54: -#line 482 "./expread.y" -{ write_exp_elt_opcode (OP_DOUBLE); - write_exp_elt_type (builtin_type_double); - write_exp_elt_dblcst (yyvsp[0].dval); - write_exp_elt_opcode (OP_DOUBLE); ; - break;} -case 56: -#line 492 "./expread.y" -{ write_exp_elt_opcode (OP_LAST); - write_exp_elt_longcst ((LONGEST) yyvsp[0].lval); - write_exp_elt_opcode (OP_LAST); ; - break;} -case 57: -#line 498 "./expread.y" -{ write_exp_elt_opcode (OP_REGISTER); - write_exp_elt_longcst ((LONGEST) yyvsp[0].lval); - write_exp_elt_opcode (OP_REGISTER); ; - break;} -case 58: -#line 504 "./expread.y" -{ write_exp_elt_opcode (OP_INTERNALVAR); - write_exp_elt_intern (yyvsp[0].ivar); - write_exp_elt_opcode (OP_INTERNALVAR); ; - break;} -case 59: -#line 510 "./expread.y" -{ write_exp_elt_opcode (OP_LONG); - write_exp_elt_type (builtin_type_int); - write_exp_elt_longcst ((LONGEST) TYPE_LENGTH (yyvsp[-1].tval)); - write_exp_elt_opcode (OP_LONG); ; - break;} -case 60: -#line 517 "./expread.y" -{ write_exp_elt_opcode (OP_STRING); - write_exp_string (yyvsp[0].sval); - write_exp_elt_opcode (OP_STRING); ; - break;} -case 61: -#line 524 "./expread.y" -{ write_exp_elt_opcode (OP_THIS); - write_exp_elt_opcode (OP_THIS); ; - break;} -case 62: -#line 531 "./expread.y" -{ - if (yyvsp[0].ssym.sym != 0) - yyval.bval = SYMBOL_BLOCK_VALUE (yyvsp[0].ssym.sym); - else - { - struct symtab *tem = - lookup_symtab (copy_name (yyvsp[0].ssym.stoken)); - if (tem) - yyval.bval = BLOCKVECTOR_BLOCK - (BLOCKVECTOR (tem), STATIC_BLOCK); - else - error ("No file or function \"%s\".", - copy_name (yyvsp[0].ssym.stoken)); - } - ; - break;} -case 63: -#line 549 "./expread.y" -{ struct symbol *tem - = lookup_symbol (copy_name (yyvsp[0].sval), yyvsp[-2].bval, - VAR_NAMESPACE, 0, NULL); - if (!tem || SYMBOL_CLASS (tem) != LOC_BLOCK) - error ("No function \"%s\" in specified context.", - copy_name (yyvsp[0].sval)); - yyval.bval = SYMBOL_BLOCK_VALUE (tem); ; - break;} -case 64: -#line 559 "./expread.y" -{ struct symbol *sym; - sym = lookup_symbol (copy_name (yyvsp[0].sval), yyvsp[-2].bval, - VAR_NAMESPACE, 0, NULL); - if (sym == 0) - error ("No symbol \"%s\" in specified context.", - copy_name (yyvsp[0].sval)); - write_exp_elt_opcode (OP_VAR_VALUE); - write_exp_elt_sym (sym); - write_exp_elt_opcode (OP_VAR_VALUE); ; - break;} -case 65: -#line 571 "./expread.y" -{ - struct type *type = yyvsp[-2].tval; - if (TYPE_CODE (type) != TYPE_CODE_STRUCT - && TYPE_CODE (type) != TYPE_CODE_UNION) - error ("`%s' is not defined as an aggregate type.", - TYPE_NAME (type)); - - write_exp_elt_opcode (OP_SCOPE); - write_exp_elt_type (type); - write_exp_string (yyvsp[0].sval); - write_exp_elt_opcode (OP_SCOPE); - ; - break;} -case 66: -#line 584 "./expread.y" -{ - struct type *type = yyvsp[-3].tval; - if (TYPE_CODE (type) != TYPE_CODE_STRUCT - && TYPE_CODE (type) != TYPE_CODE_UNION) - error ("`%s' is not defined as an aggregate type.", - TYPE_NAME (type)); - - if (strcmp (type_name_no_tag (type), yyvsp[0].sval.ptr)) - error ("invalid destructor `%s::~%s'", - type_name_no_tag (type), yyvsp[0].sval.ptr); - - write_exp_elt_opcode (OP_SCOPE); - write_exp_elt_type (type); - write_exp_string (yyvsp[0].sval); - write_exp_elt_opcode (OP_SCOPE); - write_exp_elt_opcode (UNOP_LOGNOT); - ; - break;} -case 67: -#line 602 "./expread.y" -{ - char *name = copy_name (yyvsp[0].sval); - struct symbol *sym; - int i; - - sym = - lookup_symbol (name, 0, VAR_NAMESPACE, 0, NULL); - if (sym) - { - write_exp_elt_opcode (OP_VAR_VALUE); - write_exp_elt_sym (sym); - write_exp_elt_opcode (OP_VAR_VALUE); - break; - } - for (i = 0; i < misc_function_count; i++) - if (!strcmp (misc_function_vector[i].name, name)) - break; - - if (i < misc_function_count) - { - enum misc_function_type mft = - misc_function_vector[i].type; - - write_exp_elt_opcode (OP_LONG); - write_exp_elt_type (builtin_type_int); - write_exp_elt_longcst ((LONGEST) misc_function_vector[i].address); - write_exp_elt_opcode (OP_LONG); - write_exp_elt_opcode (UNOP_MEMVAL); - if (mft == mf_data || mft == mf_bss) - write_exp_elt_type (builtin_type_int); - else if (mft == mf_text) - write_exp_elt_type (lookup_function_type (builtin_type_int)); - else - write_exp_elt_type (builtin_type_char); - write_exp_elt_opcode (UNOP_MEMVAL); - } - else - if (symtab_list == 0 - && partial_symtab_list == 0) - error ("No symbol table is loaded. Use the \"file\" command."); - else - error ("No symbol \"%s\" in current context.", name); - ; - break;} -case 68: -#line 648 "./expread.y" -{ struct symbol *sym = yyvsp[0].ssym.sym; - - if (sym) - { - switch (sym->class) - { - case LOC_REGISTER: - case LOC_ARG: - case LOC_REF_ARG: - case LOC_REGPARM: - case LOC_LOCAL: - case LOC_LOCAL_ARG: - if (innermost_block == 0 || - contained_in (block_found, - innermost_block)) - innermost_block = block_found; - case LOC_UNDEF: - case LOC_CONST: - case LOC_STATIC: - case LOC_TYPEDEF: - case LOC_LABEL: - case LOC_BLOCK: - case LOC_CONST_BYTES: - - /* In this case the expression can - be evaluated regardless of what - frame we are in, so there is no - need to check for the - innermost_block. These cases are - listed so that gcc -Wall will - report types that may not have - been considered. */ - - break; - } - write_exp_elt_opcode (OP_VAR_VALUE); - write_exp_elt_sym (sym); - write_exp_elt_opcode (OP_VAR_VALUE); - } - else if (yyvsp[0].ssym.is_a_field_of_this) - { - /* C++: it hangs off of `this'. Must - not inadvertently convert from a method call - to data ref. */ - if (innermost_block == 0 || - contained_in (block_found, innermost_block)) - innermost_block = block_found; - write_exp_elt_opcode (OP_THIS); - write_exp_elt_opcode (OP_THIS); - write_exp_elt_opcode (STRUCTOP_PTR); - write_exp_string (yyvsp[0].ssym.stoken); - write_exp_elt_opcode (STRUCTOP_PTR); - } - else - { - register int i; - register char *arg = copy_name (yyvsp[0].ssym.stoken); - - /* FIXME, this search is linear! At least - optimize the strcmp with a 1-char cmp... */ - for (i = 0; i < misc_function_count; i++) - if (!strcmp (misc_function_vector[i].name, arg)) - break; - - if (i < misc_function_count) - { - enum misc_function_type mft = - misc_function_vector[i].type; - - write_exp_elt_opcode (OP_LONG); - write_exp_elt_type (builtin_type_int); - write_exp_elt_longcst ((LONGEST) misc_function_vector[i].address); - write_exp_elt_opcode (OP_LONG); - write_exp_elt_opcode (UNOP_MEMVAL); - if (mft == mf_data || mft == mf_bss) - write_exp_elt_type (builtin_type_int); - else if (mft == mf_text) - write_exp_elt_type (lookup_function_type (builtin_type_int)); - else - write_exp_elt_type (builtin_type_char); - write_exp_elt_opcode (UNOP_MEMVAL); - } - else if (symtab_list == 0 - && partial_symtab_list == 0) - error ("No symbol table is loaded. Use the \"file\" command."); - else - error ("No symbol \"%s\" in current context.", - copy_name (yyvsp[0].ssym.stoken)); - } - ; - break;} -case 70: -#line 743 "./expread.y" -{ - /* This is where the interesting stuff happens. */ - int done = 0; - int array_size; - struct type *follow_type = yyvsp[-1].tval; - - while (!done) - switch (pop_type ()) - { - case tp_end: - done = 1; - break; - case tp_pointer: - follow_type = lookup_pointer_type (follow_type); - break; - case tp_reference: - follow_type = lookup_reference_type (follow_type); - break; - case tp_array: - array_size = pop_type_int (); - if (array_size != -1) - follow_type = create_array_type (follow_type, - array_size); - else - follow_type = lookup_pointer_type (follow_type); - break; - case tp_function: - follow_type = lookup_function_type (follow_type); - break; - } - yyval.tval = follow_type; - ; - break;} -case 71: -#line 778 "./expread.y" -{ push_type (tp_pointer); yyval.voidval = 0; ; - break;} -case 72: -#line 780 "./expread.y" -{ push_type (tp_pointer); yyval.voidval = yyvsp[0].voidval; ; - break;} -case 73: -#line 782 "./expread.y" -{ push_type (tp_reference); yyval.voidval = 0; ; - break;} -case 74: -#line 784 "./expread.y" -{ push_type (tp_reference); yyval.voidval = yyvsp[0].voidval; ; - break;} -case 76: -#line 789 "./expread.y" -{ yyval.voidval = yyvsp[-1].voidval; ; - break;} -case 77: -#line 791 "./expread.y" -{ - push_type_int (yyvsp[0].lval); - push_type (tp_array); - ; - break;} -case 78: -#line 796 "./expread.y" -{ - push_type_int (yyvsp[0].lval); - push_type (tp_array); - yyval.voidval = 0; - ; - break;} -case 79: -#line 802 "./expread.y" -{ push_type (tp_function); ; - break;} -case 80: -#line 804 "./expread.y" -{ push_type (tp_function); ; - break;} -case 81: -#line 808 "./expread.y" -{ yyval.lval = -1; ; - break;} -case 82: -#line 810 "./expread.y" -{ yyval.lval = yyvsp[-1].lval; ; - break;} -case 83: -#line 814 "./expread.y" -{ yyval.voidval = 0; ; - break;} -case 85: -#line 819 "./expread.y" -{ yyval.tval = lookup_member_type (builtin_type_int, yyvsp[-2].tval); ; - break;} -case 86: -#line 821 "./expread.y" -{ yyval.tval = lookup_member_type (yyvsp[-5].tval, yyvsp[-3].tval); ; - break;} -case 87: -#line 823 "./expread.y" -{ yyval.tval = lookup_member_type - (lookup_function_type (yyvsp[-7].tval), yyvsp[-5].tval); ; - break;} -case 88: -#line 826 "./expread.y" -{ yyval.tval = lookup_member_type - (lookup_function_type (yyvsp[-8].tval), yyvsp[-6].tval); - free (yyvsp[-1].tvec); ; - break;} -case 89: -#line 833 "./expread.y" -{ yyval.tval = yyvsp[0].tsym.type; ; - break;} -case 90: -#line 835 "./expread.y" -{ yyval.tval = builtin_type_int; ; - break;} -case 91: -#line 837 "./expread.y" -{ yyval.tval = builtin_type_long; ; - break;} -case 92: -#line 839 "./expread.y" -{ yyval.tval = builtin_type_short; ; - break;} -case 93: -#line 841 "./expread.y" -{ yyval.tval = builtin_type_long; ; - break;} -case 94: -#line 843 "./expread.y" -{ yyval.tval = builtin_type_unsigned_long; ; - break;} -case 95: -#line 845 "./expread.y" -{ yyval.tval = builtin_type_long_long; ; - break;} -case 96: -#line 847 "./expread.y" -{ yyval.tval = builtin_type_long_long; ; - break;} -case 97: -#line 849 "./expread.y" -{ yyval.tval = builtin_type_unsigned_long_long; ; - break;} -case 98: -#line 851 "./expread.y" -{ yyval.tval = builtin_type_unsigned_long_long; ; - break;} -case 99: -#line 853 "./expread.y" -{ yyval.tval = builtin_type_short; ; - break;} -case 100: -#line 855 "./expread.y" -{ yyval.tval = builtin_type_unsigned_short; ; - break;} -case 101: -#line 857 "./expread.y" -{ yyval.tval = lookup_struct (copy_name (yyvsp[0].sval), - expression_context_block); ; - break;} -case 102: -#line 860 "./expread.y" -{ yyval.tval = lookup_union (copy_name (yyvsp[0].sval), - expression_context_block); ; - break;} -case 103: -#line 863 "./expread.y" -{ yyval.tval = lookup_enum (copy_name (yyvsp[0].sval), - expression_context_block); ; - break;} -case 104: -#line 866 "./expread.y" -{ yyval.tval = lookup_unsigned_typename (TYPE_NAME(yyvsp[0].tsym.type)); ; - break;} -case 105: -#line 868 "./expread.y" -{ yyval.tval = builtin_type_unsigned_int; ; - break;} -case 106: -#line 870 "./expread.y" -{ yyval.tval = yyvsp[0].tsym.type; ; - break;} -case 107: -#line 872 "./expread.y" -{ yyval.tval = builtin_type_int; ; - break;} -case 109: -#line 877 "./expread.y" -{ - yyval.tsym.stoken.ptr = "int"; - yyval.tsym.stoken.length = 3; - yyval.tsym.type = builtin_type_int; - ; - break;} -case 110: -#line 883 "./expread.y" -{ - yyval.tsym.stoken.ptr = "long"; - yyval.tsym.stoken.length = 4; - yyval.tsym.type = builtin_type_long; - ; - break;} -case 111: -#line 889 "./expread.y" -{ - yyval.tsym.stoken.ptr = "short"; - yyval.tsym.stoken.length = 5; - yyval.tsym.type = builtin_type_short; - ; - break;} -case 112: -#line 898 "./expread.y" -{ yyval.tvec = (struct type **)xmalloc (sizeof (struct type *) * 2); - yyval.tvec[0] = (struct type *)0; - yyval.tvec[1] = yyvsp[0].tval; - ; - break;} -case 113: -#line 903 "./expread.y" -{ int len = sizeof (struct type *) * ++(yyvsp[-2].ivec[0]); - yyval.tvec = (struct type **)xrealloc (yyvsp[-2].tvec, len); - yyval.tvec[yyval.ivec[0]] = yyvsp[0].tval; - ; - break;} -case 114: -#line 909 "./expread.y" -{ yyval.sval = yyvsp[0].ssym.stoken; ; - break;} -case 115: -#line 910 "./expread.y" -{ yyval.sval = yyvsp[0].ssym.stoken; ; - break;} -case 116: -#line 911 "./expread.y" -{ yyval.sval = yyvsp[0].tsym.stoken; ; - break;} -case 117: -#line 912 "./expread.y" -{ yyval.sval = yyvsp[0].ssym.stoken; ; - break;} -case 118: -#line 913 "./expread.y" -{ yyval.sval = yyvsp[0].ssym.stoken; ; - break;} -} - /* the action file gets copied in in place of this dollarsign */ -#line 423 "/usr/latest/lib/bison.simple" - - yyvsp -= yylen; - yyssp -= yylen; -#ifdef YYLSP_NEEDED - yylsp -= yylen; -#endif - -#if YYDEBUG != 0 - if (yydebug) - { - short *ssp1 = yyss - 1; - fprintf (stderr, "state stack now"); - while (ssp1 != yyssp) - fprintf (stderr, " %d", *++ssp1); - fprintf (stderr, "\n"); - } -#endif - - *++yyvsp = yyval; - -#ifdef YYLSP_NEEDED - yylsp++; - if (yylen == 0) - { - yylsp->first_line = yylloc.first_line; - yylsp->first_column = yylloc.first_column; - yylsp->last_line = (yylsp-1)->last_line; - yylsp->last_column = (yylsp-1)->last_column; - yylsp->text = 0; - } - else - { - yylsp->last_line = (yylsp+yylen-1)->last_line; - yylsp->last_column = (yylsp+yylen-1)->last_column; - } -#endif - - /* Now "shift" the result of the reduction. - Determine what state that goes to, - based on the state we popped back to - and the rule number reduced by. */ - - yyn = yyr1[yyn]; - - yystate = yypgoto[yyn - YYNTBASE] + *yyssp; - if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) - yystate = yytable[yystate]; - else - yystate = yydefgoto[yyn - YYNTBASE]; - - goto yynewstate; - -yyerrlab: /* here on detecting error */ - - if (! yyerrstatus) - /* If not already recovering from an error, report this error. */ - { - ++yynerrs; - -#ifdef YYERROR_VERBOSE - yyn = yypact[yystate]; - - if (yyn > YYFLAG && yyn < YYLAST) - { - int size = 0; - char *msg; - int x, count; - - count = 0; - for (x = 0; x < (sizeof(yytname) / sizeof(char *)); x++) - if (yycheck[x + yyn] == x) - size += strlen(yytname[x]) + 15, count++; - msg = (char *) xmalloc(size + 15); - strcpy(msg, "parse error"); - - if (count < 5) - { - count = 0; - for (x = 0; x < (sizeof(yytname) / sizeof(char *)); x++) - if (yycheck[x + yyn] == x) - { - strcat(msg, count == 0 ? ", expecting `" : " or `"); - strcat(msg, yytname[x]); - strcat(msg, "'"); - count++; - } - } - yyerror(msg); - free(msg); - } - else -#endif /* YYERROR_VERBOSE */ - yyerror("parse error"); - } - -yyerrlab1: /* here on error raised explicitly by an action */ - - if (yyerrstatus == 3) - { - /* if just tried and failed to reuse lookahead token after an error, discard it. */ - - /* return failure if at end of input */ - if (yychar == YYEOF) - YYABORT; - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); -#endif - - yychar = YYEMPTY; - } - - /* Else will try to reuse lookahead token - after shifting the error token. */ - - yyerrstatus = 3; /* Each real token shifted decrements this */ - - goto yyerrhandle; - -yyerrdefault: /* current state does not do anything special for the error token. */ - -#if 0 - /* This is wrong; only states that explicitly want error tokens - should shift them. */ - yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ - if (yyn) goto yydefault; -#endif - -yyerrpop: /* pop the current state because it cannot handle the error token */ - - if (yyssp == yyss) YYABORT; - yyvsp--; - yystate = *--yyssp; -#ifdef YYLSP_NEEDED - yylsp--; -#endif - -#if YYDEBUG != 0 - if (yydebug) - { - short *ssp1 = yyss - 1; - fprintf (stderr, "Error: state stack now"); - while (ssp1 != yyssp) - fprintf (stderr, " %d", *++ssp1); - fprintf (stderr, "\n"); - } -#endif - -yyerrhandle: - - yyn = yypact[yystate]; - if (yyn == YYFLAG) - goto yyerrdefault; - - yyn += YYTERROR; - if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) - goto yyerrdefault; - - yyn = yytable[yyn]; - if (yyn < 0) - { - if (yyn == YYFLAG) - goto yyerrpop; - yyn = -yyn; - goto yyreduce; - } - else if (yyn == 0) - goto yyerrpop; - - if (yyn == YYFINAL) - YYACCEPT; - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Shifting error token, "); -#endif - - *++yyvsp = yylval; -#ifdef YYLSP_NEEDED - *++yylsp = yylloc; -#endif - - yystate = yyn; - goto yynewstate; -} -#line 928 "./expread.y" - - -/* Begin counting arguments for a function call, - saving the data about any containing call. */ - -static void -start_arglist () -{ - register struct funcall *new = (struct funcall *) xmalloc (sizeof (struct funcall)); - - new->next = funcall_chain; - new->arglist_len = arglist_len; - arglist_len = 0; - funcall_chain = new; -} - -/* Return the number of arguments in a function call just terminated, - and restore the data for the containing function call. */ - -static int -end_arglist () -{ - register int val = arglist_len; - register struct funcall *call = funcall_chain; - funcall_chain = call->next; - arglist_len = call->arglist_len; - free (call); - return val; -} - -/* Free everything in the funcall chain. - Used when there is an error inside parsing. */ - -static void -free_funcalls () -{ - register struct funcall *call, *next; - - for (call = funcall_chain; call; call = next) - { - next = call->next; - free (call); - } -} - -/* This page contains the functions for adding data to the struct expression - being constructed. */ - -/* Add one element to the end of the expression. */ - -/* To avoid a bug in the Sun 4 compiler, we pass things that can fit into - a register through here */ - -static void -write_exp_elt (expelt) - union exp_element expelt; -{ - if (expout_ptr >= expout_size) - { - expout_size *= 2; - expout = (struct expression *) xrealloc (expout, - sizeof (struct expression) - + expout_size * sizeof (union exp_element)); - } - expout->elts[expout_ptr++] = expelt; -} - -static void -write_exp_elt_opcode (expelt) - enum exp_opcode expelt; -{ - union exp_element tmp; - - tmp.opcode = expelt; - - write_exp_elt (tmp); -} - -static void -write_exp_elt_sym (expelt) - struct symbol *expelt; -{ - union exp_element tmp; - - tmp.symbol = expelt; - - write_exp_elt (tmp); -} - -static void -write_exp_elt_longcst (expelt) - LONGEST expelt; -{ - union exp_element tmp; - - tmp.longconst = expelt; - - write_exp_elt (tmp); -} - -static void -write_exp_elt_dblcst (expelt) - double expelt; -{ - union exp_element tmp; - - tmp.doubleconst = expelt; - - write_exp_elt (tmp); -} - -static void -write_exp_elt_type (expelt) - struct type *expelt; -{ - union exp_element tmp; - - tmp.type = expelt; - - write_exp_elt (tmp); -} - -static void -write_exp_elt_intern (expelt) - struct internalvar *expelt; -{ - union exp_element tmp; - - tmp.internalvar = expelt; - - write_exp_elt (tmp); -} - -/* Add a string constant to the end of the expression. - Follow it by its length in bytes, as a separate exp_element. */ - -static void -write_exp_string (str) - struct stoken str; -{ - register int len = str.length; - register int lenelt - = (len + sizeof (union exp_element)) / sizeof (union exp_element); - - expout_ptr += lenelt; - - if (expout_ptr >= expout_size) - { - expout_size = max (expout_size * 2, expout_ptr + 10); - expout = (struct expression *) - xrealloc (expout, (sizeof (struct expression) - + (expout_size * sizeof (union exp_element)))); - } - bcopy (str.ptr, (char *) &expout->elts[expout_ptr - lenelt], len); - ((char *) &expout->elts[expout_ptr - lenelt])[len] = 0; - write_exp_elt_longcst ((LONGEST) len); -} - -/* During parsing of a C expression, the pointer to the next character - is in this variable. */ - -static char *lexptr; - -/* Tokens that refer to names do so with explicit pointer and length, - so they can share the storage that lexptr is parsing. - - When it is necessary to pass a name to a function that expects - a null-terminated string, the substring is copied out - into a block of storage that namecopy points to. - - namecopy is allocated once, guaranteed big enough, for each parsing. */ - -static char *namecopy; - -/* Current depth in parentheses within the expression. */ - -static int paren_depth; - -/* Nonzero means stop parsing on first comma (if not within parentheses). */ - -static int comma_terminates; - -/* Take care of parsing a number (anything that starts with a digit). - Set yylval and return the token type; update lexptr. - LEN is the number of characters in it. */ - -/*** Needs some error checking for the float case ***/ - -static int -parse_number (p, len, parsed_float, putithere) - register char *p; - register int len; - int parsed_float; - YYSTYPE *putithere; -{ - register LONGEST n = 0; - register int i; - register int c; - register int base = input_radix; - int unsigned_p = 0; - - extern double atof (); - - if (parsed_float) - { - /* It's a float since it contains a point or an exponent. */ - putithere->dval = atof (p); - return FLOAT; - } - - /* Handle base-switching prefixes 0x, 0t, 0d, 0 */ - if (p[0] == '0') - switch (p[1]) - { - case 'x': - case 'X': - if (len >= 3) - { - p += 2; - base = 16; - len -= 2; - } - break; - - case 't': - case 'T': - case 'd': - case 'D': - if (len >= 3) - { - p += 2; - base = 10; - len -= 2; - } - break; - - default: - base = 8; - break; - } - - while (len-- > 0) - { - c = *p++; - if (c >= 'A' && c <= 'Z') - c += 'a' - 'A'; - if (c != 'l' && c != 'u') - n *= base; - if (c >= '0' && c <= '9') - n += i = c - '0'; - else - { - if (base > 10 && c >= 'a' && c <= 'f') - n += i = c - 'a' + 10; - else if (len == 0 && c == 'l') - ; - else if (len == 0 && c == 'u') - unsigned_p = 1; - else - return ERROR; /* Char not a digit */ - } - if (i >= base) - return ERROR; /* Invalid digit in this base */ - } - - if (unsigned_p) - { - putithere->ulval = n; - return UINT; - } - else - { - putithere->lval = n; - return INT; - } -} - -struct token -{ - char *operator; - int token; - enum exp_opcode opcode; -}; - -const static struct token tokentab3[] = - { - {">>=", ASSIGN_MODIFY, BINOP_RSH}, - {"<<=", ASSIGN_MODIFY, BINOP_LSH} - }; - -const static struct token tokentab2[] = - { - {"+=", ASSIGN_MODIFY, BINOP_ADD}, - {"-=", ASSIGN_MODIFY, BINOP_SUB}, - {"*=", ASSIGN_MODIFY, BINOP_MUL}, - {"/=", ASSIGN_MODIFY, BINOP_DIV}, - {"%=", ASSIGN_MODIFY, BINOP_REM}, - {"|=", ASSIGN_MODIFY, BINOP_LOGIOR}, - {"&=", ASSIGN_MODIFY, BINOP_LOGAND}, - {"^=", ASSIGN_MODIFY, BINOP_LOGXOR}, - {"++", INCREMENT, BINOP_END}, - {"--", DECREMENT, BINOP_END}, - {"->", ARROW, BINOP_END}, - {"&&", AND, BINOP_END}, - {"||", OR, BINOP_END}, - {"::", COLONCOLON, BINOP_END}, - {"<<", LSH, BINOP_END}, - {">>", RSH, BINOP_END}, - {"==", EQUAL, BINOP_END}, - {"!=", NOTEQUAL, BINOP_END}, - {"<=", LEQ, BINOP_END}, - {">=", GEQ, BINOP_END} - }; - -/* assign machine-independent names to certain registers - * (unless overridden by the REGISTER_NAMES table) - */ -struct std_regs { - char *name; - int regnum; -} std_regs[] = { -#ifdef PC_REGNUM - { "pc", PC_REGNUM }, -#endif -#ifdef FP_REGNUM - { "fp", FP_REGNUM }, -#endif -#ifdef SP_REGNUM - { "sp", SP_REGNUM }, -#endif -#ifdef PS_REGNUM - { "ps", PS_REGNUM }, -#endif -}; - -#define NUM_STD_REGS (sizeof std_regs / sizeof std_regs[0]) - -/* Read one token, getting characters through lexptr. */ - -static int -yylex () -{ - register int c; - register int namelen; - register unsigned i; - register char *tokstart; - - retry: - - tokstart = lexptr; - /* See if it is a special token of length 3. */ - for (i = 0; i < sizeof tokentab3 / sizeof tokentab3[0]; i++) - if (!strncmp (tokstart, tokentab3[i].operator, 3)) - { - lexptr += 3; - yylval.opcode = tokentab3[i].opcode; - return tokentab3[i].token; - } - - /* See if it is a special token of length 2. */ - for (i = 0; i < sizeof tokentab2 / sizeof tokentab2[0]; i++) - if (!strncmp (tokstart, tokentab2[i].operator, 2)) - { - lexptr += 2; - yylval.opcode = tokentab2[i].opcode; - return tokentab2[i].token; - } - - switch (c = *tokstart) - { - case 0: - return 0; - - case ' ': - case '\t': - case '\n': - lexptr++; - goto retry; - - case '\'': - lexptr++; - c = *lexptr++; - if (c == '\\') - c = parse_escape (&lexptr); - yylval.lval = c; - c = *lexptr++; - if (c != '\'') - error ("Invalid character constant."); - return CHAR; - - case '(': - paren_depth++; - lexptr++; - return c; - - case ')': - if (paren_depth == 0) - return 0; - paren_depth--; - lexptr++; - return c; - - case ',': - if (comma_terminates && paren_depth == 0) - return 0; - lexptr++; - return c; - - case '.': - /* Might be a floating point number. */ - if (lexptr[1] < '0' || lexptr[1] > '9') - goto symbol; /* Nope, must be a symbol. */ - /* FALL THRU into number case. */ - - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - { - /* It's a number. */ - int got_dot = 0, got_e = 0, toktype; - register char *p = tokstart; - int hex = input_radix > 10; - - if (c == '0' && (p[1] == 'x' || p[1] == 'X')) - { - p += 2; - hex = 1; - } - else if (c == '0' && (p[1]=='t' || p[1]=='T' || p[1]=='d' || p[1]=='D')) - { - p += 2; - hex = 0; - } - - for (;; ++p) - { - if (!hex && !got_e && (*p == 'e' || *p == 'E')) - got_dot = got_e = 1; - else if (!hex && !got_dot && *p == '.') - got_dot = 1; - else if (got_e && (p[-1] == 'e' || p[-1] == 'E') - && (*p == '-' || *p == '+')) - /* This is the sign of the exponent, not the end of the - number. */ - continue; - /* We will take any letters or digits. parse_number will - complain if past the radix, or if L or U are not final. */ - else if ((*p < '0' || *p > '9') - && ((*p < 'a' || *p > 'z') - && (*p < 'A' || *p > 'Z'))) - break; - } - toktype = parse_number (tokstart, p - tokstart, got_dot|got_e, &yylval); - if (toktype == ERROR) - { - char *err_copy = (char *) alloca (p - tokstart + 1); - - bcopy (tokstart, err_copy, p - tokstart); - err_copy[p - tokstart] = 0; - error ("Invalid number \"%s\".", err_copy); - } - lexptr = p; - return toktype; - } - - case '+': - case '-': - case '*': - case '/': - case '%': - case '|': - case '&': - case '^': - case '~': - case '!': - case '@': - case '<': - case '>': - case '[': - case ']': - case '?': - case ':': - case '=': - case '{': - case '}': - symbol: - lexptr++; - return c; - - case '"': - for (namelen = 1; (c = tokstart[namelen]) != '"'; namelen++) - if (c == '\\') - { - c = tokstart[++namelen]; - if (c >= '0' && c <= '9') - { - c = tokstart[++namelen]; - if (c >= '0' && c <= '9') - c = tokstart[++namelen]; - } - } - yylval.sval.ptr = tokstart + 1; - yylval.sval.length = namelen - 1; - lexptr += namelen + 1; - return STRING; - } - - if (!(c == '_' || c == '$' - || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))) - /* We must have come across a bad character (e.g. ';'). */ - error ("Invalid character '%c' in expression.", c); - - /* It's a name. See how long it is. */ - namelen = 0; - for (c = tokstart[namelen]; - (c == '_' || c == '$' || (c >= '0' && c <= '9') - || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')); - c = tokstart[++namelen]) - ; - - /* The token "if" terminates the expression and is NOT - removed from the input stream. */ - if (namelen == 2 && tokstart[0] == 'i' && tokstart[1] == 'f') - { - return 0; - } - - lexptr += namelen; - - /* Handle the tokens $digits; also $ (short for $0) and $$ (short for $$1) - and $$digits (equivalent to $<-digits> if you could type that). - Make token type LAST, and put the number (the digits) in yylval. */ - - if (*tokstart == '$') - { - register int negate = 0; - c = 1; - /* Double dollar means negate the number and add -1 as well. - Thus $$ alone means -1. */ - if (namelen >= 2 && tokstart[1] == '$') - { - negate = 1; - c = 2; - } - if (c == namelen) - { - /* Just dollars (one or two) */ - yylval.lval = - negate; - return LAST; - } - /* Is the rest of the token digits? */ - for (; c < namelen; c++) - if (!(tokstart[c] >= '0' && tokstart[c] <= '9')) - break; - if (c == namelen) - { - yylval.lval = atoi (tokstart + 1 + negate); - if (negate) - yylval.lval = - yylval.lval; - return LAST; - } - } - - /* Handle tokens that refer to machine registers: - $ followed by a register name. */ - - if (*tokstart == '$') { - for (c = 0; c < NUM_REGS; c++) - if (namelen - 1 == strlen (reg_names[c]) - && !strncmp (tokstart + 1, reg_names[c], namelen - 1)) - { - yylval.lval = c; - return REGNAME; - } - for (c = 0; c < NUM_STD_REGS; c++) - if (namelen - 1 == strlen (std_regs[c].name) - && !strncmp (tokstart + 1, std_regs[c].name, namelen - 1)) - { - yylval.lval = std_regs[c].regnum; - return REGNAME; - } - } - /* Catch specific keywords. Should be done with a data structure. */ - switch (namelen) - { - case 8: - if (!strncmp (tokstart, "unsigned", 8)) - return UNSIGNED; - break; - case 6: - if (!strncmp (tokstart, "struct", 6)) - return STRUCT; - if (!strncmp (tokstart, "signed", 6)) - return SIGNED; - if (!strncmp (tokstart, "sizeof", 6)) - return SIZEOF; - break; - case 5: - if (!strncmp (tokstart, "union", 5)) - return UNION; - if (!strncmp (tokstart, "short", 5)) - return SHORT; - break; - case 4: - if (!strncmp (tokstart, "enum", 4)) - return ENUM; - if (!strncmp (tokstart, "long", 4)) - return LONG; - if (!strncmp (tokstart, "this", 4)) - { - static const char this_name[] = - { CPLUS_MARKER, 't', 'h', 'i', 's', '\0' }; - - if (lookup_symbol (this_name, expression_context_block, - VAR_NAMESPACE, 0, NULL)) - return THIS; - } - break; - case 3: - if (!strncmp (tokstart, "int", 3)) - return INT_KEYWORD; - break; - default: - break; - } - - yylval.sval.ptr = tokstart; - yylval.sval.length = namelen; - - /* Any other names starting in $ are debugger internal variables. */ - - if (*tokstart == '$') - { - yylval.ivar = lookup_internalvar (copy_name (yylval.sval) + 1); - return VARIABLE; - } - - /* Use token-type BLOCKNAME for symbols that happen to be defined as - functions or symtabs. If this is not so, then ... - Use token-type TYPENAME for symbols that happen to be defined - currently as names of types; NAME for other symbols. - The caller is not constrained to care about the distinction. */ - { - char *tmp = copy_name (yylval.sval); - struct symbol *sym; - int is_a_field_of_this = 0; - int hextype; - - sym = lookup_symbol (tmp, expression_context_block, - VAR_NAMESPACE, &is_a_field_of_this, NULL); - if ((sym && SYMBOL_CLASS (sym) == LOC_BLOCK) || - lookup_partial_symtab (tmp)) - { - yylval.ssym.sym = sym; - yylval.ssym.is_a_field_of_this = is_a_field_of_this; - return BLOCKNAME; - } - if (sym && SYMBOL_CLASS (sym) == LOC_TYPEDEF) - { - yylval.tsym.type = SYMBOL_TYPE (sym); - return TYPENAME; - } - if ((yylval.tsym.type = lookup_primitive_typename (tmp)) != 0) - return TYPENAME; - - /* Input names that aren't symbols but ARE valid hex numbers, - when the input radix permits them, can be names or numbers - depending on the parse. Note we support radixes > 16 here. */ - if (!sym && - ((tokstart[0] >= 'a' && tokstart[0] < 'a' + input_radix - 10) || - (tokstart[0] >= 'A' && tokstart[0] < 'A' + input_radix - 10))) - { - YYSTYPE newlval; /* Its value is ignored. */ - hextype = parse_number (tokstart, namelen, 0, &newlval); - if (hextype == INT) - { - yylval.ssym.sym = sym; - yylval.ssym.is_a_field_of_this = is_a_field_of_this; - return NAME_OR_INT; - } - if (hextype == UINT) - { - yylval.ssym.sym = sym; - yylval.ssym.is_a_field_of_this = is_a_field_of_this; - return NAME_OR_UINT; - } - } - - /* Any other kind of symbol */ - yylval.ssym.sym = sym; - yylval.ssym.is_a_field_of_this = is_a_field_of_this; - return NAME; - } -} - -static void -yyerror (msg) - char *msg; -{ - error ("Invalid syntax in expression."); -} - -/* Return a null-terminated temporary copy of the name - of a string token. */ - -static char * -copy_name (token) - struct stoken token; -{ - bcopy (token.ptr, namecopy, token.length); - namecopy[token.length] = 0; - return namecopy; -} - -/* Reverse an expression from suffix form (in which it is constructed) - to prefix form (in which we can conveniently print or execute it). */ - -static void prefixify_subexp (); - -static void -prefixify_expression (expr) - register struct expression *expr; -{ - register int len = sizeof (struct expression) + - expr->nelts * sizeof (union exp_element); - register struct expression *temp; - register int inpos = expr->nelts, outpos = 0; - - temp = (struct expression *) alloca (len); - - /* Copy the original expression into temp. */ - bcopy (expr, temp, len); - - prefixify_subexp (temp, expr, inpos, outpos); -} - -/* Return the number of exp_elements in the subexpression of EXPR - whose last exp_element is at index ENDPOS - 1 in EXPR. */ - -static int -length_of_subexp (expr, endpos) - register struct expression *expr; - register int endpos; -{ - register int oplen = 1; - register int args = 0; - register int i; - - if (endpos < 0) - error ("?error in length_of_subexp"); - - i = (int) expr->elts[endpos - 1].opcode; - - switch (i) - { - /* C++ */ - case OP_SCOPE: - oplen = 4 + ((expr->elts[endpos - 2].longconst - + sizeof (union exp_element)) - / sizeof (union exp_element)); - break; - - case OP_LONG: - case OP_DOUBLE: - oplen = 4; - break; - - case OP_VAR_VALUE: - case OP_LAST: - case OP_REGISTER: - case OP_INTERNALVAR: - oplen = 3; - break; - - case OP_FUNCALL: - oplen = 3; - args = 1 + expr->elts[endpos - 2].longconst; - break; - - case UNOP_CAST: - case UNOP_MEMVAL: - oplen = 3; - args = 1; - break; - - case STRUCTOP_STRUCT: - case STRUCTOP_PTR: - args = 1; - case OP_STRING: - oplen = 3 + ((expr->elts[endpos - 2].longconst - + sizeof (union exp_element)) - / sizeof (union exp_element)); - break; - - case TERNOP_COND: - args = 3; - break; - - case BINOP_ASSIGN_MODIFY: - oplen = 3; - args = 2; - break; - - /* C++ */ - case OP_THIS: - oplen = 2; - break; - - default: - args = 1 + (i < (int) BINOP_END); - } - - while (args > 0) - { - oplen += length_of_subexp (expr, endpos - oplen); - args--; - } - - return oplen; -} - -/* Copy the subexpression ending just before index INEND in INEXPR - into OUTEXPR, starting at index OUTBEG. - In the process, convert it from suffix to prefix form. */ - -static void -prefixify_subexp (inexpr, outexpr, inend, outbeg) - register struct expression *inexpr; - struct expression *outexpr; - register int inend; - int outbeg; -{ - register int oplen = 1; - register int args = 0; - register int i; - int *arglens; - enum exp_opcode opcode; - - /* Compute how long the last operation is (in OPLEN), - and also how many preceding subexpressions serve as - arguments for it (in ARGS). */ - - opcode = inexpr->elts[inend - 1].opcode; - switch (opcode) - { - /* C++ */ - case OP_SCOPE: - oplen = 4 + ((inexpr->elts[inend - 2].longconst - + sizeof (union exp_element)) - / sizeof (union exp_element)); - break; - - case OP_LONG: - case OP_DOUBLE: - oplen = 4; - break; - - case OP_VAR_VALUE: - case OP_LAST: - case OP_REGISTER: - case OP_INTERNALVAR: - oplen = 3; - break; - - case OP_FUNCALL: - oplen = 3; - args = 1 + inexpr->elts[inend - 2].longconst; - break; - - case UNOP_CAST: - case UNOP_MEMVAL: - oplen = 3; - args = 1; - break; - - case STRUCTOP_STRUCT: - case STRUCTOP_PTR: - args = 1; - case OP_STRING: - oplen = 3 + ((inexpr->elts[inend - 2].longconst - + sizeof (union exp_element)) - / sizeof (union exp_element)); - - break; - - case TERNOP_COND: - args = 3; - break; - - case BINOP_ASSIGN_MODIFY: - oplen = 3; - args = 2; - break; - - /* C++ */ - case OP_THIS: - oplen = 2; - break; - - default: - args = 1 + ((int) opcode < (int) BINOP_END); - } - - /* Copy the final operator itself, from the end of the input - to the beginning of the output. */ - inend -= oplen; - bcopy (&inexpr->elts[inend], &outexpr->elts[outbeg], - oplen * sizeof (union exp_element)); - outbeg += oplen; - - /* Find the lengths of the arg subexpressions. */ - arglens = (int *) alloca (args * sizeof (int)); - for (i = args - 1; i >= 0; i--) - { - oplen = length_of_subexp (inexpr, inend); - arglens[i] = oplen; - inend -= oplen; - } - - /* Now copy each subexpression, preserving the order of - the subexpressions, but prefixifying each one. - In this loop, inend starts at the beginning of - the expression this level is working on - and marches forward over the arguments. - outbeg does similarly in the output. */ - for (i = 0; i < args; i++) - { - oplen = arglens[i]; - inend += oplen; - prefixify_subexp (inexpr, outexpr, inend, outbeg); - outbeg += oplen; - } -} - -/* This page contains the two entry points to this file. */ - -/* Read a C expression from the string *STRINGPTR points to, - parse it, and return a pointer to a struct expression that we malloc. - Use block BLOCK as the lexical context for variable names; - if BLOCK is zero, use the block of the selected stack frame. - Meanwhile, advance *STRINGPTR to point after the expression, - at the first nonwhite character that is not part of the expression - (possibly a null character). - - If COMMA is nonzero, stop if a comma is reached. */ - -struct expression * -parse_c_1 (stringptr, block, comma) - char **stringptr; - struct block *block; - int comma; -{ - struct cleanup *old_chain; - - lexptr = *stringptr; - - paren_depth = 0; - type_stack_depth = 0; - - comma_terminates = comma; - - if (lexptr == 0 || *lexptr == 0) - error_no_arg ("expression to compute"); - - old_chain = make_cleanup (free_funcalls, 0); - funcall_chain = 0; - - expression_context_block = block ? block : get_selected_block (); - - namecopy = (char *) alloca (strlen (lexptr) + 1); - expout_size = 10; - expout_ptr = 0; - expout = (struct expression *) - xmalloc (sizeof (struct expression) - + expout_size * sizeof (union exp_element)); - make_cleanup (free_current_contents, &expout); - if (yyparse ()) - yyerror (NULL); - discard_cleanups (old_chain); - expout->nelts = expout_ptr; - expout = (struct expression *) - xrealloc (expout, - sizeof (struct expression) - + expout_ptr * sizeof (union exp_element)); - prefixify_expression (expout); - *stringptr = lexptr; - return expout; -} - -/* Parse STRING as an expression, and complain if this fails - to use up all of the contents of STRING. */ - -struct expression * -parse_c_expression (string) - char *string; -{ - register struct expression *exp; - exp = parse_c_1 (&string, 0, 0); - if (*string) - error ("Junk after end of expression."); - return exp; -} - -static void -push_type (tp) - enum type_pieces tp; -{ - if (type_stack_depth == type_stack_size) - { - type_stack_size *= 2; - type_stack = (union type_stack_elt *) - xrealloc (type_stack, type_stack_size * sizeof (*type_stack)); - } - type_stack[type_stack_depth++].piece = tp; -} - -static void -push_type_int (n) - int n; -{ - if (type_stack_depth == type_stack_size) - { - type_stack_size *= 2; - type_stack = (union type_stack_elt *) - xrealloc (type_stack, type_stack_size * sizeof (*type_stack)); - } - type_stack[type_stack_depth++].int_val = n; -} - -static enum type_pieces -pop_type () -{ - if (type_stack_depth) - return type_stack[--type_stack_depth].piece; - return tp_end; -} - -static int -pop_type_int () -{ - if (type_stack_depth) - return type_stack[--type_stack_depth].int_val; - /* "Can't happen". */ - return 0; -} - -void -_initialize_expread () -{ - type_stack_size = 80; - type_stack_depth = 0; - type_stack = (union type_stack_elt *) - xmalloc (type_stack_size * sizeof (*type_stack)); -} diff --git a/gdb/expread.y b/gdb/expread.y deleted file mode 100755 index cc625541023..00000000000 --- a/gdb/expread.y +++ /dev/null @@ -1,1989 +0,0 @@ -/* Parse C expressions for GDB. - Copyright (C) 1986, 1989, 1990, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Parse a C expression from text in a string, - and return the result as a struct expression pointer. - That structure contains arithmetic operations in reverse polish, - with constants represented by operations that are followed by special data. - See expression.h for the details of the format. - What is important here is that it can be built up sequentially - during the process of parsing; the lower levels of the tree always - come first in the result. */ - -%{ -#include -#include "defs.h" -#include "param.h" -#include "symtab.h" -#include "frame.h" -#include "expression.h" -#include "value.h" -#include "command.h" - -static struct expression *expout; -static int expout_size; -static int expout_ptr; - -static int yylex (); -static void yyerror (); -static void write_exp_elt (); -static void write_exp_elt_opcode (); -static void write_exp_elt_sym (); -static void write_exp_elt_longcst (); -static void write_exp_elt_dblcst (); -static void write_exp_elt_type (); -static void write_exp_elt_intern (); -static void write_exp_string (); -static void start_arglist (); -static int end_arglist (); -static void free_funcalls (); -static char *copy_name (); -static int parse_number (); - -/* If this is nonzero, this block is used as the lexical context - for symbol names. */ - -static struct block *expression_context_block; - -/* The innermost context required by the stack and register variables - we've encountered so far. */ -struct block *innermost_block; - -/* The block in which the most recently discovered symbol was found. */ -struct block *block_found; - -/* Number of arguments seen so far in innermost function call. */ -static int arglist_len; - -/* Data structure for saving values of arglist_len - for function calls whose arguments contain other function calls. */ - -struct funcall - { - struct funcall *next; - int arglist_len; - }; - -struct funcall *funcall_chain; - -/* This kind of datum is used to represent the name - of a symbol token. */ - -struct stoken - { - char *ptr; - int length; - }; - -struct ttype - { - struct stoken stoken; - struct type *type; - }; - -struct symtoken - { - struct stoken stoken; - struct symbol *sym; - int is_a_field_of_this; - }; - -/* For parsing of complicated types. - An array should be preceded in the list by the size of the array. */ -enum type_pieces - {tp_end = -1, tp_pointer, tp_reference, tp_array, tp_function}; -/* The stack can contain either an enum type_pieces or an int. */ -union type_stack_elt { - enum type_pieces piece; - int int_val; -}; -static union type_stack_elt *type_stack; -static int type_stack_depth, type_stack_size; - -static void push_type (); -static void push_type_int (); -static enum type_pieces pop_type (); -static int pop_type_int (); - -/* Allow debugging of parsing. */ -#define YYDEBUG 1 -%} - -/* Although the yacc "value" of an expression is not used, - since the result is stored in the structure being created, - other node types do have values. */ - -%union - { - LONGEST lval; - unsigned LONGEST ulval; - double dval; - struct symbol *sym; - struct type *tval; - struct stoken sval; - struct ttype tsym; - struct symtoken ssym; - int voidval; - struct block *bval; - enum exp_opcode opcode; - struct internalvar *ivar; - - struct type **tvec; - int *ivec; - } - -%type exp exp1 start variable -%type type typebase -%type nonempty_typelist -%type block - -/* Fancy type parsing. */ -%type func_mod direct_abs_decl abs_decl -%type ptype -%type array_mod - -%token INT CHAR -%token UINT -%token FLOAT - -/* Both NAME and TYPENAME tokens represent symbols in the input, - and both convey their data as strings. - But a TYPENAME is a string that happens to be defined as a typedef - or builtin type name (such as int or char) - and a NAME is any other symbol. - - Contexts where this distinction is not important can use the - nonterminal "name", which matches either NAME or TYPENAME. */ - -%token STRING -%token NAME BLOCKNAME -%token TYPENAME -%type name -%type name_not_typename -%type typename - -/* A NAME_OR_INT is a symbol which is not known in the symbol table, - but which would parse as a valid number in the current input radix. - E.g. "c" when input_radix==16. Depending on the parse, it will be - turned into a name or into a number. NAME_OR_UINT ditto. */ - -%token NAME_OR_INT NAME_OR_UINT - -%token STRUCT UNION ENUM SIZEOF UNSIGNED COLONCOLON -%token ERROR - -/* Special type cases, put in to allow the parser to distinguish different - legal basetypes. */ -%token SIGNED LONG SHORT INT_KEYWORD - -%token LAST REGNAME - -%token VARIABLE - -%token ASSIGN_MODIFY - -/* C++ */ -%token THIS - -%left ',' -%left ABOVE_COMMA -%right '=' ASSIGN_MODIFY -%right '?' -%left OR -%left AND -%left '|' -%left '^' -%left '&' -%left EQUAL NOTEQUAL -%left '<' '>' LEQ GEQ -%left LSH RSH -%left '@' -%left '+' '-' -%left '*' '/' '%' -%right UNARY INCREMENT DECREMENT -%right ARROW '.' '[' '(' -%left COLONCOLON - -%% - -start : exp1 - ; - -/* Expressions, including the comma operator. */ -exp1 : exp - | exp1 ',' exp - { write_exp_elt_opcode (BINOP_COMMA); } - ; - -/* Expressions, not including the comma operator. */ -exp : '*' exp %prec UNARY - { write_exp_elt_opcode (UNOP_IND); } - -exp : '&' exp %prec UNARY - { write_exp_elt_opcode (UNOP_ADDR); } - -exp : '-' exp %prec UNARY - { write_exp_elt_opcode (UNOP_NEG); } - ; - -exp : '!' exp %prec UNARY - { write_exp_elt_opcode (UNOP_ZEROP); } - ; - -exp : '~' exp %prec UNARY - { write_exp_elt_opcode (UNOP_LOGNOT); } - ; - -exp : INCREMENT exp %prec UNARY - { write_exp_elt_opcode (UNOP_PREINCREMENT); } - ; - -exp : DECREMENT exp %prec UNARY - { write_exp_elt_opcode (UNOP_PREDECREMENT); } - ; - -exp : exp INCREMENT %prec UNARY - { write_exp_elt_opcode (UNOP_POSTINCREMENT); } - ; - -exp : exp DECREMENT %prec UNARY - { write_exp_elt_opcode (UNOP_POSTDECREMENT); } - ; - -exp : SIZEOF exp %prec UNARY - { write_exp_elt_opcode (UNOP_SIZEOF); } - ; - -exp : exp ARROW name - { write_exp_elt_opcode (STRUCTOP_PTR); - write_exp_string ($3); - write_exp_elt_opcode (STRUCTOP_PTR); } - ; - -exp : exp ARROW '*' exp - { write_exp_elt_opcode (STRUCTOP_MPTR); } - ; - -exp : exp '.' name - { write_exp_elt_opcode (STRUCTOP_STRUCT); - write_exp_string ($3); - write_exp_elt_opcode (STRUCTOP_STRUCT); } - ; - -exp : exp '.' '*' exp - { write_exp_elt_opcode (STRUCTOP_MEMBER); } - ; - -exp : exp '[' exp1 ']' - { write_exp_elt_opcode (BINOP_SUBSCRIPT); } - ; - -exp : exp '(' - /* This is to save the value of arglist_len - being accumulated by an outer function call. */ - { start_arglist (); } - arglist ')' %prec ARROW - { write_exp_elt_opcode (OP_FUNCALL); - write_exp_elt_longcst ((LONGEST) end_arglist ()); - write_exp_elt_opcode (OP_FUNCALL); } - ; - -arglist : - ; - -arglist : exp - { arglist_len = 1; } - ; - -arglist : arglist ',' exp %prec ABOVE_COMMA - { arglist_len++; } - ; - -exp : '{' type '}' exp %prec UNARY - { write_exp_elt_opcode (UNOP_MEMVAL); - write_exp_elt_type ($2); - write_exp_elt_opcode (UNOP_MEMVAL); } - ; - -exp : '(' type ')' exp %prec UNARY - { write_exp_elt_opcode (UNOP_CAST); - write_exp_elt_type ($2); - write_exp_elt_opcode (UNOP_CAST); } - ; - -exp : '(' exp1 ')' - { } - ; - -/* Binary operators in order of decreasing precedence. */ - -exp : exp '@' exp - { write_exp_elt_opcode (BINOP_REPEAT); } - ; - -exp : exp '*' exp - { write_exp_elt_opcode (BINOP_MUL); } - ; - -exp : exp '/' exp - { write_exp_elt_opcode (BINOP_DIV); } - ; - -exp : exp '%' exp - { write_exp_elt_opcode (BINOP_REM); } - ; - -exp : exp '+' exp - { write_exp_elt_opcode (BINOP_ADD); } - ; - -exp : exp '-' exp - { write_exp_elt_opcode (BINOP_SUB); } - ; - -exp : exp LSH exp - { write_exp_elt_opcode (BINOP_LSH); } - ; - -exp : exp RSH exp - { write_exp_elt_opcode (BINOP_RSH); } - ; - -exp : exp EQUAL exp - { write_exp_elt_opcode (BINOP_EQUAL); } - ; - -exp : exp NOTEQUAL exp - { write_exp_elt_opcode (BINOP_NOTEQUAL); } - ; - -exp : exp LEQ exp - { write_exp_elt_opcode (BINOP_LEQ); } - ; - -exp : exp GEQ exp - { write_exp_elt_opcode (BINOP_GEQ); } - ; - -exp : exp '<' exp - { write_exp_elt_opcode (BINOP_LESS); } - ; - -exp : exp '>' exp - { write_exp_elt_opcode (BINOP_GTR); } - ; - -exp : exp '&' exp - { write_exp_elt_opcode (BINOP_LOGAND); } - ; - -exp : exp '^' exp - { write_exp_elt_opcode (BINOP_LOGXOR); } - ; - -exp : exp '|' exp - { write_exp_elt_opcode (BINOP_LOGIOR); } - ; - -exp : exp AND exp - { write_exp_elt_opcode (BINOP_AND); } - ; - -exp : exp OR exp - { write_exp_elt_opcode (BINOP_OR); } - ; - -exp : exp '?' exp ':' exp %prec '?' - { write_exp_elt_opcode (TERNOP_COND); } - ; - -exp : exp '=' exp - { write_exp_elt_opcode (BINOP_ASSIGN); } - ; - -exp : exp ASSIGN_MODIFY exp - { write_exp_elt_opcode (BINOP_ASSIGN_MODIFY); - write_exp_elt_opcode ($2); - write_exp_elt_opcode (BINOP_ASSIGN_MODIFY); } - ; - -exp : INT - { write_exp_elt_opcode (OP_LONG); - if ($1 == (int) $1 || $1 == (unsigned int) $1) - write_exp_elt_type (builtin_type_int); - else - write_exp_elt_type (BUILTIN_TYPE_LONGEST); - write_exp_elt_longcst ((LONGEST) $1); - write_exp_elt_opcode (OP_LONG); } - ; - -exp : NAME_OR_INT - { YYSTYPE val; - parse_number ($1.stoken.ptr, $1.stoken.length, 0, &val); - write_exp_elt_opcode (OP_LONG); - if (val.lval == (int) val.lval || - val.lval == (unsigned int) val.lval) - write_exp_elt_type (builtin_type_int); - else - write_exp_elt_type (BUILTIN_TYPE_LONGEST); - write_exp_elt_longcst (val.lval); - write_exp_elt_opcode (OP_LONG); } - ; - -exp : UINT - { - write_exp_elt_opcode (OP_LONG); - if ($1 == (unsigned int) $1) - write_exp_elt_type (builtin_type_unsigned_int); - else - write_exp_elt_type (BUILTIN_TYPE_UNSIGNED_LONGEST); - write_exp_elt_longcst ((LONGEST) $1); - write_exp_elt_opcode (OP_LONG); - } - ; - -exp : NAME_OR_UINT - { YYSTYPE val; - parse_number ($1.stoken.ptr, $1.stoken.length, 0, &val); - write_exp_elt_opcode (OP_LONG); - if (val.ulval == (unsigned int) val.ulval) - write_exp_elt_type (builtin_type_unsigned_int); - else - write_exp_elt_type (BUILTIN_TYPE_UNSIGNED_LONGEST); - write_exp_elt_longcst ((LONGEST)val.ulval); - write_exp_elt_opcode (OP_LONG); - } - ; - -exp : CHAR - { write_exp_elt_opcode (OP_LONG); - write_exp_elt_type (builtin_type_char); - write_exp_elt_longcst ((LONGEST) $1); - write_exp_elt_opcode (OP_LONG); } - ; - -exp : FLOAT - { write_exp_elt_opcode (OP_DOUBLE); - write_exp_elt_type (builtin_type_double); - write_exp_elt_dblcst ($1); - write_exp_elt_opcode (OP_DOUBLE); } - ; - -exp : variable - ; - -exp : LAST - { write_exp_elt_opcode (OP_LAST); - write_exp_elt_longcst ((LONGEST) $1); - write_exp_elt_opcode (OP_LAST); } - ; - -exp : REGNAME - { write_exp_elt_opcode (OP_REGISTER); - write_exp_elt_longcst ((LONGEST) $1); - write_exp_elt_opcode (OP_REGISTER); } - ; - -exp : VARIABLE - { write_exp_elt_opcode (OP_INTERNALVAR); - write_exp_elt_intern ($1); - write_exp_elt_opcode (OP_INTERNALVAR); } - ; - -exp : SIZEOF '(' type ')' %prec UNARY - { write_exp_elt_opcode (OP_LONG); - write_exp_elt_type (builtin_type_int); - write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3)); - write_exp_elt_opcode (OP_LONG); } - ; - -exp : STRING - { write_exp_elt_opcode (OP_STRING); - write_exp_string ($1); - write_exp_elt_opcode (OP_STRING); } - ; - -/* C++. */ -exp : THIS - { write_exp_elt_opcode (OP_THIS); - write_exp_elt_opcode (OP_THIS); } - ; - -/* end of C++. */ - -block : BLOCKNAME - { - if ($1.sym != 0) - $$ = SYMBOL_BLOCK_VALUE ($1.sym); - else - { - struct symtab *tem = - lookup_symtab (copy_name ($1.stoken)); - if (tem) - $$ = BLOCKVECTOR_BLOCK - (BLOCKVECTOR (tem), STATIC_BLOCK); - else - error ("No file or function \"%s\".", - copy_name ($1.stoken)); - } - } - ; - -block : block COLONCOLON name - { struct symbol *tem - = lookup_symbol (copy_name ($3), $1, - VAR_NAMESPACE, 0, NULL); - if (!tem || SYMBOL_CLASS (tem) != LOC_BLOCK) - error ("No function \"%s\" in specified context.", - copy_name ($3)); - $$ = SYMBOL_BLOCK_VALUE (tem); } - ; - -variable: block COLONCOLON name - { struct symbol *sym; - sym = lookup_symbol (copy_name ($3), $1, - VAR_NAMESPACE, 0, NULL); - if (sym == 0) - error ("No symbol \"%s\" in specified context.", - copy_name ($3)); - write_exp_elt_opcode (OP_VAR_VALUE); - write_exp_elt_sym (sym); - write_exp_elt_opcode (OP_VAR_VALUE); } - ; - -variable: typebase COLONCOLON name - { - struct type *type = $1; - if (TYPE_CODE (type) != TYPE_CODE_STRUCT - && TYPE_CODE (type) != TYPE_CODE_UNION) - error ("`%s' is not defined as an aggregate type.", - TYPE_NAME (type)); - - write_exp_elt_opcode (OP_SCOPE); - write_exp_elt_type (type); - write_exp_string ($3); - write_exp_elt_opcode (OP_SCOPE); - } - | typebase COLONCOLON '~' name - { - struct type *type = $1; - if (TYPE_CODE (type) != TYPE_CODE_STRUCT - && TYPE_CODE (type) != TYPE_CODE_UNION) - error ("`%s' is not defined as an aggregate type.", - TYPE_NAME (type)); - - if (strcmp (type_name_no_tag (type), $4.ptr)) - error ("invalid destructor `%s::~%s'", - type_name_no_tag (type), $4.ptr); - - write_exp_elt_opcode (OP_SCOPE); - write_exp_elt_type (type); - write_exp_string ($4); - write_exp_elt_opcode (OP_SCOPE); - write_exp_elt_opcode (UNOP_LOGNOT); - } - | COLONCOLON name - { - char *name = copy_name ($2); - struct symbol *sym; - int i; - - sym = - lookup_symbol (name, 0, VAR_NAMESPACE, 0, NULL); - if (sym) - { - write_exp_elt_opcode (OP_VAR_VALUE); - write_exp_elt_sym (sym); - write_exp_elt_opcode (OP_VAR_VALUE); - break; - } - for (i = 0; i < misc_function_count; i++) - if (!strcmp (misc_function_vector[i].name, name)) - break; - - if (i < misc_function_count) - { - enum misc_function_type mft = - misc_function_vector[i].type; - - write_exp_elt_opcode (OP_LONG); - write_exp_elt_type (builtin_type_int); - write_exp_elt_longcst ((LONGEST) misc_function_vector[i].address); - write_exp_elt_opcode (OP_LONG); - write_exp_elt_opcode (UNOP_MEMVAL); - if (mft == mf_data || mft == mf_bss) - write_exp_elt_type (builtin_type_int); - else if (mft == mf_text) - write_exp_elt_type (lookup_function_type (builtin_type_int)); - else - write_exp_elt_type (builtin_type_char); - write_exp_elt_opcode (UNOP_MEMVAL); - } - else - if (symtab_list == 0 - && partial_symtab_list == 0) - error ("No symbol table is loaded. Use the \"file\" command."); - else - error ("No symbol \"%s\" in current context.", name); - } - ; - -variable: name_not_typename - { struct symbol *sym = $1.sym; - - if (sym) - { - switch (sym->class) - { - case LOC_REGISTER: - case LOC_ARG: - case LOC_REF_ARG: - case LOC_REGPARM: - case LOC_LOCAL: - case LOC_LOCAL_ARG: - if (innermost_block == 0 || - contained_in (block_found, - innermost_block)) - innermost_block = block_found; - case LOC_UNDEF: - case LOC_CONST: - case LOC_STATIC: - case LOC_TYPEDEF: - case LOC_LABEL: - case LOC_BLOCK: - case LOC_CONST_BYTES: - - /* In this case the expression can - be evaluated regardless of what - frame we are in, so there is no - need to check for the - innermost_block. These cases are - listed so that gcc -Wall will - report types that may not have - been considered. */ - - break; - } - write_exp_elt_opcode (OP_VAR_VALUE); - write_exp_elt_sym (sym); - write_exp_elt_opcode (OP_VAR_VALUE); - } - else if ($1.is_a_field_of_this) - { - /* C++: it hangs off of `this'. Must - not inadvertently convert from a method call - to data ref. */ - if (innermost_block == 0 || - contained_in (block_found, innermost_block)) - innermost_block = block_found; - write_exp_elt_opcode (OP_THIS); - write_exp_elt_opcode (OP_THIS); - write_exp_elt_opcode (STRUCTOP_PTR); - write_exp_string ($1.stoken); - write_exp_elt_opcode (STRUCTOP_PTR); - } - else - { - register int i; - register char *arg = copy_name ($1.stoken); - - /* FIXME, this search is linear! At least - optimize the strcmp with a 1-char cmp... */ - for (i = 0; i < misc_function_count; i++) - if (!strcmp (misc_function_vector[i].name, arg)) - break; - - if (i < misc_function_count) - { - enum misc_function_type mft = - misc_function_vector[i].type; - - write_exp_elt_opcode (OP_LONG); - write_exp_elt_type (builtin_type_int); - write_exp_elt_longcst ((LONGEST) misc_function_vector[i].address); - write_exp_elt_opcode (OP_LONG); - write_exp_elt_opcode (UNOP_MEMVAL); - if (mft == mf_data || mft == mf_bss) - write_exp_elt_type (builtin_type_int); - else if (mft == mf_text) - write_exp_elt_type (lookup_function_type (builtin_type_int)); - else - write_exp_elt_type (builtin_type_char); - write_exp_elt_opcode (UNOP_MEMVAL); - } - else if (symtab_list == 0 - && partial_symtab_list == 0) - error ("No symbol table is loaded. Use the \"file\" command."); - else - error ("No symbol \"%s\" in current context.", - copy_name ($1.stoken)); - } - } - ; - - -ptype : typebase - | typebase abs_decl - { - /* This is where the interesting stuff happens. */ - int done = 0; - int array_size; - struct type *follow_type = $1; - - while (!done) - switch (pop_type ()) - { - case tp_end: - done = 1; - break; - case tp_pointer: - follow_type = lookup_pointer_type (follow_type); - break; - case tp_reference: - follow_type = lookup_reference_type (follow_type); - break; - case tp_array: - array_size = pop_type_int (); - if (array_size != -1) - follow_type = create_array_type (follow_type, - array_size); - else - follow_type = lookup_pointer_type (follow_type); - break; - case tp_function: - follow_type = lookup_function_type (follow_type); - break; - } - $$ = follow_type; - } - ; - -abs_decl: '*' - { push_type (tp_pointer); $$ = 0; } - | '*' abs_decl - { push_type (tp_pointer); $$ = $2; } - | '&' - { push_type (tp_reference); $$ = 0; } - | '&' abs_decl - { push_type (tp_reference); $$ = $2; } - | direct_abs_decl - ; - -direct_abs_decl: '(' abs_decl ')' - { $$ = $2; } - | direct_abs_decl array_mod - { - push_type_int ($2); - push_type (tp_array); - } - | array_mod - { - push_type_int ($1); - push_type (tp_array); - $$ = 0; - } - | direct_abs_decl func_mod - { push_type (tp_function); } - | func_mod - { push_type (tp_function); } - ; - -array_mod: '[' ']' - { $$ = -1; } - | '[' INT ']' - { $$ = $2; } - ; - -func_mod: '(' ')' - { $$ = 0; } - ; - -type : ptype - | typebase COLONCOLON '*' - { $$ = lookup_member_type (builtin_type_int, $1); } - | type '(' typebase COLONCOLON '*' ')' - { $$ = lookup_member_type ($1, $3); } - | type '(' typebase COLONCOLON '*' ')' '(' ')' - { $$ = lookup_member_type - (lookup_function_type ($1), $3); } - | type '(' typebase COLONCOLON '*' ')' '(' nonempty_typelist ')' - { $$ = lookup_member_type - (lookup_function_type ($1), $3); - free ($8); } - ; - -typebase - : TYPENAME - { $$ = $1.type; } - | INT_KEYWORD - { $$ = builtin_type_int; } - | LONG - { $$ = builtin_type_long; } - | SHORT - { $$ = builtin_type_short; } - | LONG INT_KEYWORD - { $$ = builtin_type_long; } - | UNSIGNED LONG INT_KEYWORD - { $$ = builtin_type_unsigned_long; } - | LONG LONG - { $$ = builtin_type_long_long; } - | LONG LONG INT_KEYWORD - { $$ = builtin_type_long_long; } - | UNSIGNED LONG LONG - { $$ = builtin_type_unsigned_long_long; } - | UNSIGNED LONG LONG INT_KEYWORD - { $$ = builtin_type_unsigned_long_long; } - | SHORT INT_KEYWORD - { $$ = builtin_type_short; } - | UNSIGNED SHORT INT_KEYWORD - { $$ = builtin_type_unsigned_short; } - | STRUCT name - { $$ = lookup_struct (copy_name ($2), - expression_context_block); } - | UNION name - { $$ = lookup_union (copy_name ($2), - expression_context_block); } - | ENUM name - { $$ = lookup_enum (copy_name ($2), - expression_context_block); } - | UNSIGNED typename - { $$ = lookup_unsigned_typename (TYPE_NAME($2.type)); } - | UNSIGNED - { $$ = builtin_type_unsigned_int; } - | SIGNED typename - { $$ = $2.type; } - | SIGNED - { $$ = builtin_type_int; } - ; - -typename: TYPENAME - | INT_KEYWORD - { - $$.stoken.ptr = "int"; - $$.stoken.length = 3; - $$.type = builtin_type_int; - } - | LONG - { - $$.stoken.ptr = "long"; - $$.stoken.length = 4; - $$.type = builtin_type_long; - } - | SHORT - { - $$.stoken.ptr = "short"; - $$.stoken.length = 5; - $$.type = builtin_type_short; - } - ; - -nonempty_typelist - : type - { $$ = (struct type **)xmalloc (sizeof (struct type *) * 2); - $$[0] = (struct type *)0; - $$[1] = $1; - } - | nonempty_typelist ',' type - { int len = sizeof (struct type *) * ++($1[0]); - $$ = (struct type **)xrealloc ($1, len); - $$[$$[0]] = $3; - } - ; - -name : NAME { $$ = $1.stoken; } - | BLOCKNAME { $$ = $1.stoken; } - | TYPENAME { $$ = $1.stoken; } - | NAME_OR_INT { $$ = $1.stoken; } - | NAME_OR_UINT { $$ = $1.stoken; } - ; - -name_not_typename : NAME - | BLOCKNAME -/* These would be useful if name_not_typename was useful, but it is just - a fake for "variable", so these cause reduce/reduce conflicts because - the parser can't tell whether NAME_OR_INT is a name_not_typename (=variable, - =exp) or just an exp. If name_not_typename was ever used in an lvalue - context where only a name could occur, this might be useful. - | NAME_OR_INT - | NAME_OR_UINT - */ - ; - -%% - -/* Begin counting arguments for a function call, - saving the data about any containing call. */ - -static void -start_arglist () -{ - register struct funcall *new = (struct funcall *) xmalloc (sizeof (struct funcall)); - - new->next = funcall_chain; - new->arglist_len = arglist_len; - arglist_len = 0; - funcall_chain = new; -} - -/* Return the number of arguments in a function call just terminated, - and restore the data for the containing function call. */ - -static int -end_arglist () -{ - register int val = arglist_len; - register struct funcall *call = funcall_chain; - funcall_chain = call->next; - arglist_len = call->arglist_len; - free (call); - return val; -} - -/* Free everything in the funcall chain. - Used when there is an error inside parsing. */ - -static void -free_funcalls () -{ - register struct funcall *call, *next; - - for (call = funcall_chain; call; call = next) - { - next = call->next; - free (call); - } -} - -/* This page contains the functions for adding data to the struct expression - being constructed. */ - -/* Add one element to the end of the expression. */ - -/* To avoid a bug in the Sun 4 compiler, we pass things that can fit into - a register through here */ - -static void -write_exp_elt (expelt) - union exp_element expelt; -{ - if (expout_ptr >= expout_size) - { - expout_size *= 2; - expout = (struct expression *) xrealloc (expout, - sizeof (struct expression) - + expout_size * sizeof (union exp_element)); - } - expout->elts[expout_ptr++] = expelt; -} - -static void -write_exp_elt_opcode (expelt) - enum exp_opcode expelt; -{ - union exp_element tmp; - - tmp.opcode = expelt; - - write_exp_elt (tmp); -} - -static void -write_exp_elt_sym (expelt) - struct symbol *expelt; -{ - union exp_element tmp; - - tmp.symbol = expelt; - - write_exp_elt (tmp); -} - -static void -write_exp_elt_longcst (expelt) - LONGEST expelt; -{ - union exp_element tmp; - - tmp.longconst = expelt; - - write_exp_elt (tmp); -} - -static void -write_exp_elt_dblcst (expelt) - double expelt; -{ - union exp_element tmp; - - tmp.doubleconst = expelt; - - write_exp_elt (tmp); -} - -static void -write_exp_elt_type (expelt) - struct type *expelt; -{ - union exp_element tmp; - - tmp.type = expelt; - - write_exp_elt (tmp); -} - -static void -write_exp_elt_intern (expelt) - struct internalvar *expelt; -{ - union exp_element tmp; - - tmp.internalvar = expelt; - - write_exp_elt (tmp); -} - -/* Add a string constant to the end of the expression. - Follow it by its length in bytes, as a separate exp_element. */ - -static void -write_exp_string (str) - struct stoken str; -{ - register int len = str.length; - register int lenelt - = (len + sizeof (union exp_element)) / sizeof (union exp_element); - - expout_ptr += lenelt; - - if (expout_ptr >= expout_size) - { - expout_size = max (expout_size * 2, expout_ptr + 10); - expout = (struct expression *) - xrealloc (expout, (sizeof (struct expression) - + (expout_size * sizeof (union exp_element)))); - } - bcopy (str.ptr, (char *) &expout->elts[expout_ptr - lenelt], len); - ((char *) &expout->elts[expout_ptr - lenelt])[len] = 0; - write_exp_elt_longcst ((LONGEST) len); -} - -/* During parsing of a C expression, the pointer to the next character - is in this variable. */ - -static char *lexptr; - -/* Tokens that refer to names do so with explicit pointer and length, - so they can share the storage that lexptr is parsing. - - When it is necessary to pass a name to a function that expects - a null-terminated string, the substring is copied out - into a block of storage that namecopy points to. - - namecopy is allocated once, guaranteed big enough, for each parsing. */ - -static char *namecopy; - -/* Current depth in parentheses within the expression. */ - -static int paren_depth; - -/* Nonzero means stop parsing on first comma (if not within parentheses). */ - -static int comma_terminates; - -/* Take care of parsing a number (anything that starts with a digit). - Set yylval and return the token type; update lexptr. - LEN is the number of characters in it. */ - -/*** Needs some error checking for the float case ***/ - -static int -parse_number (p, len, parsed_float, putithere) - register char *p; - register int len; - int parsed_float; - YYSTYPE *putithere; -{ - register LONGEST n = 0; - register int i; - register int c; - register int base = input_radix; - int unsigned_p = 0; - - extern double atof (); - - if (parsed_float) - { - /* It's a float since it contains a point or an exponent. */ - putithere->dval = atof (p); - return FLOAT; - } - - /* Handle base-switching prefixes 0x, 0t, 0d, 0 */ - if (p[0] == '0') - switch (p[1]) - { - case 'x': - case 'X': - if (len >= 3) - { - p += 2; - base = 16; - len -= 2; - } - break; - - case 't': - case 'T': - case 'd': - case 'D': - if (len >= 3) - { - p += 2; - base = 10; - len -= 2; - } - break; - - default: - base = 8; - break; - } - - while (len-- > 0) - { - c = *p++; - if (c >= 'A' && c <= 'Z') - c += 'a' - 'A'; - if (c != 'l' && c != 'u') - n *= base; - if (c >= '0' && c <= '9') - n += i = c - '0'; - else - { - if (base > 10 && c >= 'a' && c <= 'f') - n += i = c - 'a' + 10; - else if (len == 0 && c == 'l') - ; - else if (len == 0 && c == 'u') - unsigned_p = 1; - else - return ERROR; /* Char not a digit */ - } - if (i >= base) - return ERROR; /* Invalid digit in this base */ - } - - if (unsigned_p) - { - putithere->ulval = n; - return UINT; - } - else - { - putithere->lval = n; - return INT; - } -} - -struct token -{ - char *operator; - int token; - enum exp_opcode opcode; -}; - -const static struct token tokentab3[] = - { - {">>=", ASSIGN_MODIFY, BINOP_RSH}, - {"<<=", ASSIGN_MODIFY, BINOP_LSH} - }; - -const static struct token tokentab2[] = - { - {"+=", ASSIGN_MODIFY, BINOP_ADD}, - {"-=", ASSIGN_MODIFY, BINOP_SUB}, - {"*=", ASSIGN_MODIFY, BINOP_MUL}, - {"/=", ASSIGN_MODIFY, BINOP_DIV}, - {"%=", ASSIGN_MODIFY, BINOP_REM}, - {"|=", ASSIGN_MODIFY, BINOP_LOGIOR}, - {"&=", ASSIGN_MODIFY, BINOP_LOGAND}, - {"^=", ASSIGN_MODIFY, BINOP_LOGXOR}, - {"++", INCREMENT, BINOP_END}, - {"--", DECREMENT, BINOP_END}, - {"->", ARROW, BINOP_END}, - {"&&", AND, BINOP_END}, - {"||", OR, BINOP_END}, - {"::", COLONCOLON, BINOP_END}, - {"<<", LSH, BINOP_END}, - {">>", RSH, BINOP_END}, - {"==", EQUAL, BINOP_END}, - {"!=", NOTEQUAL, BINOP_END}, - {"<=", LEQ, BINOP_END}, - {">=", GEQ, BINOP_END} - }; - -/* assign machine-independent names to certain registers - * (unless overridden by the REGISTER_NAMES table) - */ -struct std_regs { - char *name; - int regnum; -} std_regs[] = { -#ifdef PC_REGNUM - { "pc", PC_REGNUM }, -#endif -#ifdef FP_REGNUM - { "fp", FP_REGNUM }, -#endif -#ifdef SP_REGNUM - { "sp", SP_REGNUM }, -#endif -#ifdef PS_REGNUM - { "ps", PS_REGNUM }, -#endif -}; - -#define NUM_STD_REGS (sizeof std_regs / sizeof std_regs[0]) - -/* Read one token, getting characters through lexptr. */ - -static int -yylex () -{ - register int c; - register int namelen; - register unsigned i; - register char *tokstart; - - retry: - - tokstart = lexptr; - /* See if it is a special token of length 3. */ - for (i = 0; i < sizeof tokentab3 / sizeof tokentab3[0]; i++) - if (!strncmp (tokstart, tokentab3[i].operator, 3)) - { - lexptr += 3; - yylval.opcode = tokentab3[i].opcode; - return tokentab3[i].token; - } - - /* See if it is a special token of length 2. */ - for (i = 0; i < sizeof tokentab2 / sizeof tokentab2[0]; i++) - if (!strncmp (tokstart, tokentab2[i].operator, 2)) - { - lexptr += 2; - yylval.opcode = tokentab2[i].opcode; - return tokentab2[i].token; - } - - switch (c = *tokstart) - { - case 0: - return 0; - - case ' ': - case '\t': - case '\n': - lexptr++; - goto retry; - - case '\'': - lexptr++; - c = *lexptr++; - if (c == '\\') - c = parse_escape (&lexptr); - yylval.lval = c; - c = *lexptr++; - if (c != '\'') - error ("Invalid character constant."); - return CHAR; - - case '(': - paren_depth++; - lexptr++; - return c; - - case ')': - if (paren_depth == 0) - return 0; - paren_depth--; - lexptr++; - return c; - - case ',': - if (comma_terminates && paren_depth == 0) - return 0; - lexptr++; - return c; - - case '.': - /* Might be a floating point number. */ - if (lexptr[1] < '0' || lexptr[1] > '9') - goto symbol; /* Nope, must be a symbol. */ - /* FALL THRU into number case. */ - - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - { - /* It's a number. */ - int got_dot = 0, got_e = 0, toktype; - register char *p = tokstart; - int hex = input_radix > 10; - - if (c == '0' && (p[1] == 'x' || p[1] == 'X')) - { - p += 2; - hex = 1; - } - else if (c == '0' && (p[1]=='t' || p[1]=='T' || p[1]=='d' || p[1]=='D')) - { - p += 2; - hex = 0; - } - - for (;; ++p) - { - if (!hex && !got_e && (*p == 'e' || *p == 'E')) - got_dot = got_e = 1; - else if (!hex && !got_dot && *p == '.') - got_dot = 1; - else if (got_e && (p[-1] == 'e' || p[-1] == 'E') - && (*p == '-' || *p == '+')) - /* This is the sign of the exponent, not the end of the - number. */ - continue; - /* We will take any letters or digits. parse_number will - complain if past the radix, or if L or U are not final. */ - else if ((*p < '0' || *p > '9') - && ((*p < 'a' || *p > 'z') - && (*p < 'A' || *p > 'Z'))) - break; - } - toktype = parse_number (tokstart, p - tokstart, got_dot|got_e, &yylval); - if (toktype == ERROR) - { - char *err_copy = (char *) alloca (p - tokstart + 1); - - bcopy (tokstart, err_copy, p - tokstart); - err_copy[p - tokstart] = 0; - error ("Invalid number \"%s\".", err_copy); - } - lexptr = p; - return toktype; - } - - case '+': - case '-': - case '*': - case '/': - case '%': - case '|': - case '&': - case '^': - case '~': - case '!': - case '@': - case '<': - case '>': - case '[': - case ']': - case '?': - case ':': - case '=': - case '{': - case '}': - symbol: - lexptr++; - return c; - - case '"': - for (namelen = 1; (c = tokstart[namelen]) != '"'; namelen++) - if (c == '\\') - { - c = tokstart[++namelen]; - if (c >= '0' && c <= '9') - { - c = tokstart[++namelen]; - if (c >= '0' && c <= '9') - c = tokstart[++namelen]; - } - } - yylval.sval.ptr = tokstart + 1; - yylval.sval.length = namelen - 1; - lexptr += namelen + 1; - return STRING; - } - - if (!(c == '_' || c == '$' - || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))) - /* We must have come across a bad character (e.g. ';'). */ - error ("Invalid character '%c' in expression.", c); - - /* It's a name. See how long it is. */ - namelen = 0; - for (c = tokstart[namelen]; - (c == '_' || c == '$' || (c >= '0' && c <= '9') - || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')); - c = tokstart[++namelen]) - ; - - /* The token "if" terminates the expression and is NOT - removed from the input stream. */ - if (namelen == 2 && tokstart[0] == 'i' && tokstart[1] == 'f') - { - return 0; - } - - lexptr += namelen; - - /* Handle the tokens $digits; also $ (short for $0) and $$ (short for $$1) - and $$digits (equivalent to $<-digits> if you could type that). - Make token type LAST, and put the number (the digits) in yylval. */ - - if (*tokstart == '$') - { - register int negate = 0; - c = 1; - /* Double dollar means negate the number and add -1 as well. - Thus $$ alone means -1. */ - if (namelen >= 2 && tokstart[1] == '$') - { - negate = 1; - c = 2; - } - if (c == namelen) - { - /* Just dollars (one or two) */ - yylval.lval = - negate; - return LAST; - } - /* Is the rest of the token digits? */ - for (; c < namelen; c++) - if (!(tokstart[c] >= '0' && tokstart[c] <= '9')) - break; - if (c == namelen) - { - yylval.lval = atoi (tokstart + 1 + negate); - if (negate) - yylval.lval = - yylval.lval; - return LAST; - } - } - - /* Handle tokens that refer to machine registers: - $ followed by a register name. */ - - if (*tokstart == '$') { - for (c = 0; c < NUM_REGS; c++) - if (namelen - 1 == strlen (reg_names[c]) - && !strncmp (tokstart + 1, reg_names[c], namelen - 1)) - { - yylval.lval = c; - return REGNAME; - } - for (c = 0; c < NUM_STD_REGS; c++) - if (namelen - 1 == strlen (std_regs[c].name) - && !strncmp (tokstart + 1, std_regs[c].name, namelen - 1)) - { - yylval.lval = std_regs[c].regnum; - return REGNAME; - } - } - /* Catch specific keywords. Should be done with a data structure. */ - switch (namelen) - { - case 8: - if (!strncmp (tokstart, "unsigned", 8)) - return UNSIGNED; - break; - case 6: - if (!strncmp (tokstart, "struct", 6)) - return STRUCT; - if (!strncmp (tokstart, "signed", 6)) - return SIGNED; - if (!strncmp (tokstart, "sizeof", 6)) - return SIZEOF; - break; - case 5: - if (!strncmp (tokstart, "union", 5)) - return UNION; - if (!strncmp (tokstart, "short", 5)) - return SHORT; - break; - case 4: - if (!strncmp (tokstart, "enum", 4)) - return ENUM; - if (!strncmp (tokstart, "long", 4)) - return LONG; - if (!strncmp (tokstart, "this", 4)) - { - static const char this_name[] = - { CPLUS_MARKER, 't', 'h', 'i', 's', '\0' }; - - if (lookup_symbol (this_name, expression_context_block, - VAR_NAMESPACE, 0, NULL)) - return THIS; - } - break; - case 3: - if (!strncmp (tokstart, "int", 3)) - return INT_KEYWORD; - break; - default: - break; - } - - yylval.sval.ptr = tokstart; - yylval.sval.length = namelen; - - /* Any other names starting in $ are debugger internal variables. */ - - if (*tokstart == '$') - { - yylval.ivar = lookup_internalvar (copy_name (yylval.sval) + 1); - return VARIABLE; - } - - /* Use token-type BLOCKNAME for symbols that happen to be defined as - functions or symtabs. If this is not so, then ... - Use token-type TYPENAME for symbols that happen to be defined - currently as names of types; NAME for other symbols. - The caller is not constrained to care about the distinction. */ - { - char *tmp = copy_name (yylval.sval); - struct symbol *sym; - int is_a_field_of_this = 0; - int hextype; - - sym = lookup_symbol (tmp, expression_context_block, - VAR_NAMESPACE, &is_a_field_of_this, NULL); - if ((sym && SYMBOL_CLASS (sym) == LOC_BLOCK) || - lookup_partial_symtab (tmp)) - { - yylval.ssym.sym = sym; - yylval.ssym.is_a_field_of_this = is_a_field_of_this; - return BLOCKNAME; - } - if (sym && SYMBOL_CLASS (sym) == LOC_TYPEDEF) - { - yylval.tsym.type = SYMBOL_TYPE (sym); - return TYPENAME; - } - if ((yylval.tsym.type = lookup_primitive_typename (tmp)) != 0) - return TYPENAME; - - /* Input names that aren't symbols but ARE valid hex numbers, - when the input radix permits them, can be names or numbers - depending on the parse. Note we support radixes > 16 here. */ - if (!sym && - ((tokstart[0] >= 'a' && tokstart[0] < 'a' + input_radix - 10) || - (tokstart[0] >= 'A' && tokstart[0] < 'A' + input_radix - 10))) - { - YYSTYPE newlval; /* Its value is ignored. */ - hextype = parse_number (tokstart, namelen, 0, &newlval); - if (hextype == INT) - { - yylval.ssym.sym = sym; - yylval.ssym.is_a_field_of_this = is_a_field_of_this; - return NAME_OR_INT; - } - if (hextype == UINT) - { - yylval.ssym.sym = sym; - yylval.ssym.is_a_field_of_this = is_a_field_of_this; - return NAME_OR_UINT; - } - } - - /* Any other kind of symbol */ - yylval.ssym.sym = sym; - yylval.ssym.is_a_field_of_this = is_a_field_of_this; - return NAME; - } -} - -/* ARGSUSED */ -static void -yyerror (msg) - char *msg; -{ - error ("Invalid syntax in expression."); -} - -/* Return a null-terminated temporary copy of the name - of a string token. */ - -static char * -copy_name (token) - struct stoken token; -{ - bcopy (token.ptr, namecopy, token.length); - namecopy[token.length] = 0; - return namecopy; -} - -/* Reverse an expression from suffix form (in which it is constructed) - to prefix form (in which we can conveniently print or execute it). */ - -static void prefixify_subexp (); - -static void -prefixify_expression (expr) - register struct expression *expr; -{ - register int len = sizeof (struct expression) + - expr->nelts * sizeof (union exp_element); - register struct expression *temp; - register int inpos = expr->nelts, outpos = 0; - - temp = (struct expression *) alloca (len); - - /* Copy the original expression into temp. */ - bcopy (expr, temp, len); - - prefixify_subexp (temp, expr, inpos, outpos); -} - -/* Return the number of exp_elements in the subexpression of EXPR - whose last exp_element is at index ENDPOS - 1 in EXPR. */ - -static int -length_of_subexp (expr, endpos) - register struct expression *expr; - register int endpos; -{ - register int oplen = 1; - register int args = 0; - register int i; - - if (endpos < 0) - error ("?error in length_of_subexp"); - - i = (int) expr->elts[endpos - 1].opcode; - - switch (i) - { - /* C++ */ - case OP_SCOPE: - oplen = 4 + ((expr->elts[endpos - 2].longconst - + sizeof (union exp_element)) - / sizeof (union exp_element)); - break; - - case OP_LONG: - case OP_DOUBLE: - oplen = 4; - break; - - case OP_VAR_VALUE: - case OP_LAST: - case OP_REGISTER: - case OP_INTERNALVAR: - oplen = 3; - break; - - case OP_FUNCALL: - oplen = 3; - args = 1 + expr->elts[endpos - 2].longconst; - break; - - case UNOP_CAST: - case UNOP_MEMVAL: - oplen = 3; - args = 1; - break; - - case STRUCTOP_STRUCT: - case STRUCTOP_PTR: - args = 1; - case OP_STRING: - oplen = 3 + ((expr->elts[endpos - 2].longconst - + sizeof (union exp_element)) - / sizeof (union exp_element)); - break; - - case TERNOP_COND: - args = 3; - break; - - case BINOP_ASSIGN_MODIFY: - oplen = 3; - args = 2; - break; - - /* C++ */ - case OP_THIS: - oplen = 2; - break; - - default: - args = 1 + (i < (int) BINOP_END); - } - - while (args > 0) - { - oplen += length_of_subexp (expr, endpos - oplen); - args--; - } - - return oplen; -} - -/* Copy the subexpression ending just before index INEND in INEXPR - into OUTEXPR, starting at index OUTBEG. - In the process, convert it from suffix to prefix form. */ - -static void -prefixify_subexp (inexpr, outexpr, inend, outbeg) - register struct expression *inexpr; - struct expression *outexpr; - register int inend; - int outbeg; -{ - register int oplen = 1; - register int args = 0; - register int i; - int *arglens; - enum exp_opcode opcode; - - /* Compute how long the last operation is (in OPLEN), - and also how many preceding subexpressions serve as - arguments for it (in ARGS). */ - - opcode = inexpr->elts[inend - 1].opcode; - switch (opcode) - { - /* C++ */ - case OP_SCOPE: - oplen = 4 + ((inexpr->elts[inend - 2].longconst - + sizeof (union exp_element)) - / sizeof (union exp_element)); - break; - - case OP_LONG: - case OP_DOUBLE: - oplen = 4; - break; - - case OP_VAR_VALUE: - case OP_LAST: - case OP_REGISTER: - case OP_INTERNALVAR: - oplen = 3; - break; - - case OP_FUNCALL: - oplen = 3; - args = 1 + inexpr->elts[inend - 2].longconst; - break; - - case UNOP_CAST: - case UNOP_MEMVAL: - oplen = 3; - args = 1; - break; - - case STRUCTOP_STRUCT: - case STRUCTOP_PTR: - args = 1; - case OP_STRING: - oplen = 3 + ((inexpr->elts[inend - 2].longconst - + sizeof (union exp_element)) - / sizeof (union exp_element)); - - break; - - case TERNOP_COND: - args = 3; - break; - - case BINOP_ASSIGN_MODIFY: - oplen = 3; - args = 2; - break; - - /* C++ */ - case OP_THIS: - oplen = 2; - break; - - default: - args = 1 + ((int) opcode < (int) BINOP_END); - } - - /* Copy the final operator itself, from the end of the input - to the beginning of the output. */ - inend -= oplen; - bcopy (&inexpr->elts[inend], &outexpr->elts[outbeg], - oplen * sizeof (union exp_element)); - outbeg += oplen; - - /* Find the lengths of the arg subexpressions. */ - arglens = (int *) alloca (args * sizeof (int)); - for (i = args - 1; i >= 0; i--) - { - oplen = length_of_subexp (inexpr, inend); - arglens[i] = oplen; - inend -= oplen; - } - - /* Now copy each subexpression, preserving the order of - the subexpressions, but prefixifying each one. - In this loop, inend starts at the beginning of - the expression this level is working on - and marches forward over the arguments. - outbeg does similarly in the output. */ - for (i = 0; i < args; i++) - { - oplen = arglens[i]; - inend += oplen; - prefixify_subexp (inexpr, outexpr, inend, outbeg); - outbeg += oplen; - } -} - -/* This page contains the two entry points to this file. */ - -/* Read a C expression from the string *STRINGPTR points to, - parse it, and return a pointer to a struct expression that we malloc. - Use block BLOCK as the lexical context for variable names; - if BLOCK is zero, use the block of the selected stack frame. - Meanwhile, advance *STRINGPTR to point after the expression, - at the first nonwhite character that is not part of the expression - (possibly a null character). - - If COMMA is nonzero, stop if a comma is reached. */ - -struct expression * -parse_c_1 (stringptr, block, comma) - char **stringptr; - struct block *block; - int comma; -{ - struct cleanup *old_chain; - - lexptr = *stringptr; - - paren_depth = 0; - type_stack_depth = 0; - - comma_terminates = comma; - - if (lexptr == 0 || *lexptr == 0) - error_no_arg ("expression to compute"); - - old_chain = make_cleanup (free_funcalls, 0); - funcall_chain = 0; - - expression_context_block = block ? block : get_selected_block (); - - namecopy = (char *) alloca (strlen (lexptr) + 1); - expout_size = 10; - expout_ptr = 0; - expout = (struct expression *) - xmalloc (sizeof (struct expression) - + expout_size * sizeof (union exp_element)); - make_cleanup (free_current_contents, &expout); - if (yyparse ()) - yyerror (NULL); - discard_cleanups (old_chain); - expout->nelts = expout_ptr; - expout = (struct expression *) - xrealloc (expout, - sizeof (struct expression) - + expout_ptr * sizeof (union exp_element)); - prefixify_expression (expout); - *stringptr = lexptr; - return expout; -} - -/* Parse STRING as an expression, and complain if this fails - to use up all of the contents of STRING. */ - -struct expression * -parse_c_expression (string) - char *string; -{ - register struct expression *exp; - exp = parse_c_1 (&string, 0, 0); - if (*string) - error ("Junk after end of expression."); - return exp; -} - -static void -push_type (tp) - enum type_pieces tp; -{ - if (type_stack_depth == type_stack_size) - { - type_stack_size *= 2; - type_stack = (union type_stack_elt *) - xrealloc (type_stack, type_stack_size * sizeof (*type_stack)); - } - type_stack[type_stack_depth++].piece = tp; -} - -static void -push_type_int (n) - int n; -{ - if (type_stack_depth == type_stack_size) - { - type_stack_size *= 2; - type_stack = (union type_stack_elt *) - xrealloc (type_stack, type_stack_size * sizeof (*type_stack)); - } - type_stack[type_stack_depth++].int_val = n; -} - -static enum type_pieces -pop_type () -{ - if (type_stack_depth) - return type_stack[--type_stack_depth].piece; - return tp_end; -} - -static int -pop_type_int () -{ - if (type_stack_depth) - return type_stack[--type_stack_depth].int_val; - /* "Can't happen". */ - return 0; -} - -void -_initialize_expread () -{ - type_stack_size = 80; - type_stack_depth = 0; - type_stack = (union type_stack_elt *) - xmalloc (type_stack_size * sizeof (*type_stack)); -} diff --git a/gdb/expression.h b/gdb/expression.h deleted file mode 100644 index b7a6fff4794..00000000000 --- a/gdb/expression.h +++ /dev/null @@ -1,200 +0,0 @@ -/* Definitions for expressions stored in reversed prefix form, for GDB. - Copyright (C) 1986, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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 1, or (at your option) -any later version. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Definitions for saved C expressions. */ - -/* An expression is represented as a vector of union exp_element's. - Each exp_element is an opcode, except that some opcodes cause - the following exp_element to be treated as a long or double constant - or as a variable. The opcodes are obeyed, using a stack for temporaries. - The value is left on the temporary stack at the end. */ - -/* When it is necessary to include a string, - it can occupy as many exp_elements as it needs. - We find the length of the string using strlen, - divide to find out how many exp_elements are used up, - and skip that many. Strings, like numbers, are indicated - by the preceding opcode. */ - -enum exp_opcode -{ -/* BINOP_... operate on two values computed by following subexpressions, - replacing them by one result value. They take no immediate arguments. */ - BINOP_ADD, /* + */ - BINOP_SUB, /* - */ - BINOP_MUL, /* * */ - BINOP_DIV, /* / */ - BINOP_REM, /* % */ - BINOP_LSH, /* << */ - BINOP_RSH, /* >> */ - BINOP_AND, /* && */ - BINOP_OR, /* || */ - BINOP_LOGAND, /* & */ - BINOP_LOGIOR, /* | */ - BINOP_LOGXOR, /* ^ */ - BINOP_EQUAL, /* == */ - BINOP_NOTEQUAL, /* != */ - BINOP_LESS, /* < */ - BINOP_GTR, /* > */ - BINOP_LEQ, /* <= */ - BINOP_GEQ, /* >= */ - BINOP_REPEAT, /* @ */ - BINOP_ASSIGN, /* = */ - BINOP_COMMA, /* , */ - BINOP_SUBSCRIPT, /* x[y] */ - BINOP_EXP, /* Exponentiation */ - -/* C++. */ - BINOP_MIN, /* ? */ - BINOP_SCOPE, /* :: */ - - /* STRUCTOP_MEMBER is used for pointer-to-member constructs. - X . * Y translates into X STRUCTOP_MEMBER Y. */ - STRUCTOP_MEMBER, - /* STRUCTOP_MPTR is used for pointer-to-member constructs - when X is a pointer instead of an aggregate. */ - STRUCTOP_MPTR, -/* end of C++. */ - - BINOP_END, - - BINOP_ASSIGN_MODIFY, /* +=, -=, *=, and so on. - The following exp_element is another opcode, - a BINOP_, saying how to modify. - Then comes another BINOP_ASSIGN_MODIFY, - making three exp_elements in total. */ - -/* Operates on three values computed by following subexpressions. */ - TERNOP_COND, /* ?: */ - -/* The OP_... series take immediate following arguments. - After the arguments come another OP_... (the same one) - so that the grouping can be recognized from the end. */ - -/* OP_LONG is followed by a type pointer in the next exp_element - and the long constant value in the following exp_element. - Then comes another OP_LONG. - Thus, the operation occupies four exp_elements. */ - - OP_LONG, -/* OP_DOUBLE is similar but takes a double constant instead of a long one. */ - OP_DOUBLE, -/* OP_VAR_VALUE takes one struct symbol * in the following exp_element, - followed by another OP_VAR_VALUE, making three exp_elements. */ - OP_VAR_VALUE, -/* OP_LAST is followed by an integer in the next exp_element. - The integer is zero for the last value printed, - or it is the absolute number of a history element. - With another OP_LAST at the end, this makes three exp_elements. */ - OP_LAST, -/* OP_REGISTER is followed by an integer in the next exp_element. - This is the number of a register to fetch (as an int). - With another OP_REGISTER at the end, this makes three exp_elements. */ - OP_REGISTER, -/* OP_INTERNALVAR is followed by an internalvar ptr in the next exp_element. - With another OP_INTERNALVAR at the end, this makes three exp_elements. */ - OP_INTERNALVAR, -/* OP_FUNCALL is followed by an integer in the next exp_element. - The integer is the number of args to the function call. - That many plus one values from following subexpressions - are used, the first one being the function. - The integer is followed by a repeat of OP_FUNCALL, - making three exp_elements. */ - OP_FUNCALL, -/* OP_STRING represents a string constant. - Its format is the same as that of a STRUCTOP, but the string - data is just made into a string constant when the operation - is executed. */ - OP_STRING, - -/* UNOP_CAST is followed by a type pointer in the next exp_element. - With another UNOP_CAST at the end, this makes three exp_elements. - It casts the value of the following subexpression. */ - UNOP_CAST, -/* UNOP_MEMVAL is followed by a type pointer in the next exp_element - With another UNOP_MEMVAL at the end, this makes three exp_elements. - It casts the contents of the word addressed by the value of the - following subexpression. */ - UNOP_MEMVAL, -/* UNOP_... operate on one value from a following subexpression - and replace it with a result. They take no immediate arguments. */ - UNOP_NEG, /* Unary - */ - UNOP_ZEROP, /* Unary ! */ - UNOP_LOGNOT, /* Unary ~ */ - UNOP_IND, /* Unary * */ - UNOP_ADDR, /* Unary & */ - UNOP_PREINCREMENT, /* ++ before an expression */ - UNOP_POSTINCREMENT, /* ++ after an expression */ - UNOP_PREDECREMENT, /* -- before an expression */ - UNOP_POSTDECREMENT, /* -- after an expression */ - UNOP_SIZEOF, /* Unary sizeof (followed by expression) */ - -/* STRUCTOP_... operate on a value from a following subexpression - by extracting a structure component specified by a string - that appears in the following exp_elements (as many as needed). - STRUCTOP_STRUCT is used for "." and STRUCTOP_PTR for "->". - They differ only in the error message given in case the value is - not suitable or the structure component specified is not found. - - The length of the string follows in the next exp_element, - (after the string), followed by another STRUCTOP_... code. */ - STRUCTOP_STRUCT, - STRUCTOP_PTR, - -/* C++ */ - /* OP_THIS is just a placeholder for the class instance variable. - It just comes in a tight (OP_THIS, OP_THIS) pair. */ - OP_THIS, - - /* OP_SCOPE surrounds a type name and a field name. The type - name is encoded as one element, but the field name stays as - a string, which, of course, is variable length. */ - OP_SCOPE, - -}; - -union exp_element -{ - enum exp_opcode opcode; - struct symbol *symbol; - LONGEST longconst; - double doubleconst; - char string; - struct type *type; - struct internalvar *internalvar; -}; - -struct expression -{ - int nelts; - union exp_element elts[1]; -}; - -/* From expread.y. */ -struct expression *parse_c_expression (); -struct expression *parse_c_1 (); - -/* The innermost context required by the stack and register variables - we've encountered so far. To use this, set it to NULL, then call - parse_c_, then look at it. */ -extern struct block *innermost_block; - -/* From expprint.c. */ -void print_expression (); diff --git a/gdb/findvar.c b/gdb/findvar.c deleted file mode 100644 index 58da6b6a3fb..00000000000 --- a/gdb/findvar.c +++ /dev/null @@ -1,700 +0,0 @@ -/* Find a variable's value in memory, for GDB, the GNU debugger. - Copyright (C) 1986, 1987, 1989 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "defs.h" -#include "param.h" -#include "symtab.h" -#include "frame.h" -#include "value.h" -#include "gdbcore.h" -#include "inferior.h" -#include "target.h" - -#if !defined (GET_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. */ - -CORE_ADDR -find_saved_register (frame, regnum) - FRAME frame; - int regnum; -{ - struct frame_info *fi; - struct frame_saved_regs saved_regs; - - register FRAME frame1 = 0; - register CORE_ADDR addr = 0; - - if (frame == 0) /* 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; - - fi = get_frame_info (frame1); - get_frame_saved_regs (fi, &saved_regs); - return saved_regs.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 - above macro takes care of it, so we should be all right. */ - while (1) - { - QUIT; - frame1 = get_prev_frame (frame1); - if (frame1 == 0 || frame1 == frame) - break; - fi = get_frame_info (frame1); - get_frame_saved_regs (fi, &saved_regs); - if (saved_regs.regs[regnum]) - addr = saved_regs.regs[regnum]; - } - - return addr; -} - -/* Find register number REGNUM relative to FRAME and put its - (raw) 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 -get_saved_register (raw_buffer, optimized, addrp, frame, regnum, lval) - char *raw_buffer; - int *optimized; - CORE_ADDR *addrp; - FRAME frame; - int regnum; - enum lval_type *lval; -{ - CORE_ADDR addr; - /* Normal systems don't optimize out things with register numbers. */ - if (optimized != NULL) - *optimized = 0; - addr = find_saved_register (frame, regnum); - if (addr != NULL) - { - if (lval != NULL) - *lval = lval_memory; - if (regnum == SP_REGNUM) - { - if (raw_buffer != NULL) - *(CORE_ADDR *)raw_buffer = addr; - if (addrp != NULL) - *addrp = 0; - return; - } - if (raw_buffer != NULL) - 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; -} -#endif /* GET_SAVED_REGISTER. */ - -/* 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 (regnum, myaddr) - int regnum; - char *myaddr; -{ - int optim; - if (regnum == FP_REGNUM && selected_frame) - { - bcopy (&FRAME_FP(selected_frame), myaddr, sizeof (CORE_ADDR)); - SWAP_TARGET_AND_HOST (myaddr, sizeof (CORE_ADDR)); /* in target order */ - return 0; - } - - get_saved_register (myaddr, &optim, (CORE_ADDR *) NULL, selected_frame, - regnum, (enum lval_type *)NULL); - return optim; -} - -/* Return a `value' with the contents of register REGNUM - in its virtual format, with the type specified by - REGISTER_VIRTUAL_TYPE. */ - -value -value_of_register (regnum) - int regnum; -{ - CORE_ADDR addr; - int optim; - register value val; - char raw_buffer[MAX_REGISTER_RAW_SIZE]; - char virtual_buffer[MAX_REGISTER_VIRTUAL_SIZE]; - enum lval_type lval; - - get_saved_register (raw_buffer, &optim, &addr, - selected_frame, regnum, &lval); - - target_convert_to_virtual (regnum, raw_buffer, virtual_buffer); - val = allocate_value (REGISTER_VIRTUAL_TYPE (regnum)); - bcopy (virtual_buffer, VALUE_CONTENTS_RAW (val), - REGISTER_VIRTUAL_SIZE (regnum)); - VALUE_LVAL (val) = lval; - VALUE_ADDRESS (val) = addr; - VALUE_REGNO (val) = regnum; - VALUE_OPTIMIZED_OUT (val) = optim; - return val; -} - -/* Low level examining and depositing of registers. - - The caller is responsible for making - sure that the inferior is stopped before calling the fetching routines, - or it will get garbage. (a change from GDB version 3, in which - the caller got the value from the last stop). */ - -/* Contents of the registers in target byte order. - We allocate some extra slop since we do a lot of bcopy's around `registers', - and failing-soft is better than failing hard. */ -char registers[REGISTER_BYTES + /* SLOP */ 256]; - -/* Nonzero if that register has been fetched. */ -char register_valid[NUM_REGS]; - -/* Indicate that registers may have changed, so invalidate the cache. */ -void -registers_changed () -{ - int i; - for (i = 0; i < NUM_REGS; i++) - register_valid[i] = 0; -} - -/* Indicate that all registers have been fetched, so mark them all valid. */ -void -registers_fetched () -{ - int i; - for (i = 0; i < NUM_REGS; i++) - register_valid[i] = 1; -} - -/* Copy LEN bytes of consecutive data from registers - starting with the REGBYTE'th byte of register data - into memory at MYADDR. */ - -void -read_register_bytes (regbyte, myaddr, len) - int regbyte; - char *myaddr; - int len; -{ - /* Fetch all registers. */ - int i; - for (i = 0; i < NUM_REGS; i++) - if (!register_valid[i]) - { - target_fetch_registers (-1); - break; - } - if (myaddr != NULL) - bcopy (®isters[regbyte], myaddr, len); -} - -/* Read register REGNO into memory at MYADDR, which must be large enough - for REGISTER_RAW_BYTES (REGNO). Target byte-order. - If the register is known to be the size of a CORE_ADDR or smaller, - read_register can be used instead. */ -void -read_register_gen (regno, myaddr) - int regno; - char *myaddr; -{ - if (!register_valid[regno]) - target_fetch_registers (regno); - bcopy (®isters[REGISTER_BYTE (regno)], myaddr, REGISTER_RAW_SIZE (regno)); -} - -/* Copy LEN bytes of consecutive data from memory at MYADDR - into registers starting with the REGBYTE'th byte of register data. */ - -void -write_register_bytes (regbyte, myaddr, len) - int regbyte; - char *myaddr; - int len; -{ - /* Make sure the entire registers array is valid. */ - read_register_bytes (0, (char *)NULL, REGISTER_BYTES); - bcopy (myaddr, ®isters[regbyte], len); - target_store_registers (-1); -} - -/* Return the contents of register REGNO, regarding it as an integer. */ - -CORE_ADDR -read_register (regno) - int regno; -{ - int reg; - if (!register_valid[regno]) - target_fetch_registers (regno); - /* FIXME, this loses when REGISTER_RAW_SIZE (regno) != sizeof (int) */ - reg = *(int *) ®isters[REGISTER_BYTE (regno)]; - SWAP_TARGET_AND_HOST (®, sizeof (int)); - return reg; -} - -/* Registers we shouldn't try to store. */ -#if !defined (CANNOT_STORE_REGISTER) -#define CANNOT_STORE_REGISTER(regno) 0 -#endif - -/* Store VALUE in the register number REGNO, regarded as an integer. */ - -void -write_register (regno, val) - int regno, val; -{ - /* On the sparc, writing %g0 is a no-op, so we don't even want to change - the registers array if something writes to this register. */ - if (CANNOT_STORE_REGISTER (regno)) - return; - - SWAP_TARGET_AND_HOST (&val, sizeof (int)); - - target_prepare_to_store (); - - register_valid [regno] = 1; - /* FIXME, this loses when REGISTER_RAW_SIZE (regno) != sizeof (int) */ - /* FIXME, this depends on REGISTER_BYTE (regno) being aligned for host */ - *(int *) ®isters[REGISTER_BYTE (regno)] = val; - - target_store_registers (regno); -} - -/* Record that register REGNO contains VAL. - This is used when the value is obtained from the inferior or core dump, - so there is no need to store the value there. */ - -void -supply_register (regno, val) - int regno; - char *val; -{ - register_valid[regno] = 1; - bcopy (val, ®isters[REGISTER_BYTE (regno)], REGISTER_RAW_SIZE (regno)); -} - -/* Given a struct symbol for a variable, - and a stack frame id, read the value of the variable - and return a (pointer to a) struct value containing the value. - If the variable cannot be found, return a zero pointer. - If FRAME is NULL, use the selected_frame. */ - -value -read_var_value (var, frame) - register struct symbol *var; - FRAME frame; -{ - register value v; - struct frame_info *fi; - struct type *type = SYMBOL_TYPE (var); - CORE_ADDR addr; - register int len; - - v = allocate_value (type); - VALUE_LVAL (v) = lval_memory; /* The most likely possibility. */ - len = TYPE_LENGTH (type); - - if (frame == 0) frame = selected_frame; - - switch (SYMBOL_CLASS (var)) - { - case LOC_CONST: - bcopy (&SYMBOL_VALUE (var), VALUE_CONTENTS_RAW (v), len); - SWAP_TARGET_AND_HOST (VALUE_CONTENTS_RAW (v), len); - VALUE_LVAL (v) = not_lval; - return v; - - case LOC_LABEL: - addr = SYMBOL_VALUE_ADDRESS (var); - bcopy (&addr, VALUE_CONTENTS_RAW (v), len); - SWAP_TARGET_AND_HOST (VALUE_CONTENTS_RAW (v), len); - VALUE_LVAL (v) = not_lval; - return v; - - case LOC_CONST_BYTES: - { - char *bytes_addr; - bytes_addr = SYMBOL_VALUE_BYTES (var); - bcopy (bytes_addr, VALUE_CONTENTS_RAW (v), len); - VALUE_LVAL (v) = not_lval; - return v; - } - - case LOC_STATIC: - case LOC_EXTERNAL: - addr = SYMBOL_VALUE_ADDRESS (var); - break; - -/* Nonzero if a struct which is located in a register or a LOC_ARG - really contains - the address of the struct, not the struct itself. GCC_P is nonzero - if the function was compiled with GCC. */ -#if !defined (REG_STRUCT_HAS_ADDR) -#define REG_STRUCT_HAS_ADDR(gcc_p) 0 -#endif - - case LOC_ARG: - fi = get_frame_info (frame); - if (fi == NULL) - return 0; - addr = FRAME_ARGS_ADDRESS (fi); - if (!addr) { - return 0; - } - addr += SYMBOL_VALUE (var); - break; - - case LOC_REF_ARG: - fi = get_frame_info (frame); - if (fi == NULL) - return 0; - addr = FRAME_ARGS_ADDRESS (fi); - if (!addr) { - return 0; - } - addr += SYMBOL_VALUE (var); - read_memory (addr, &addr, sizeof (CORE_ADDR)); - break; - - case LOC_LOCAL: - case LOC_LOCAL_ARG: - fi = get_frame_info (frame); - if (fi == NULL) - return 0; - addr = SYMBOL_VALUE (var) + FRAME_LOCALS_ADDRESS (fi); - break; - - case LOC_TYPEDEF: - error ("Cannot look up value of a typedef"); - break; - - case LOC_BLOCK: - VALUE_ADDRESS (v) = BLOCK_START (SYMBOL_BLOCK_VALUE (var)); - return v; - - case LOC_REGISTER: - case LOC_REGPARM: - { - struct block *b; - - if (frame == NULL) - return 0; - b = get_frame_block (frame); - - v = value_from_register (type, SYMBOL_VALUE (var), frame); - - if (REG_STRUCT_HAS_ADDR (BLOCK_GCC_COMPILED (b)) - && TYPE_CODE (type) == TYPE_CODE_STRUCT) - addr = *(CORE_ADDR *)VALUE_CONTENTS (v); - else - return v; - } - break; - - default: - error ("Cannot look up value of a botched symbol."); - break; - } - - VALUE_ADDRESS (v) = addr; - VALUE_LAZY (v) = 1; - return v; -} - -/* Return a value of type TYPE, stored in register REGNUM, in frame - FRAME. */ - -value -value_from_register (type, regnum, frame) - struct type *type; - int regnum; - FRAME frame; -{ - char raw_buffer [MAX_REGISTER_RAW_SIZE]; - char virtual_buffer[MAX_REGISTER_VIRTUAL_SIZE]; - CORE_ADDR addr; - int optim; - value v = allocate_value (type); - int len = TYPE_LENGTH (type); - char *value_bytes = 0; - int value_bytes_copied = 0; - int num_storage_locs; - enum lval_type lval; - - VALUE_REGNO (v) = regnum; - - num_storage_locs = (len > REGISTER_VIRTUAL_SIZE (regnum) ? - ((len - 1) / REGISTER_RAW_SIZE (regnum)) + 1 : - 1); - - if (num_storage_locs > 1) - { - /* Value spread across multiple storage locations. */ - - int local_regnum; - int mem_stor = 0, reg_stor = 0; - int mem_tracking = 1; - CORE_ADDR last_addr = 0; - CORE_ADDR first_addr; - - value_bytes = (char *) alloca (len + MAX_REGISTER_RAW_SIZE); - - /* Copy all of the data out, whereever it may be. */ - - for (local_regnum = regnum; - value_bytes_copied < len; - (value_bytes_copied += REGISTER_RAW_SIZE (local_regnum), - ++local_regnum)) - { - get_saved_register (value_bytes + value_bytes_copied, - &optim, - &addr, - frame, - local_regnum, - &lval); - if (lval == lval_register) - reg_stor++; - else - { - mem_stor++; - - if (regnum == local_regnum) - first_addr = addr; - - mem_tracking = - (mem_tracking - && (regnum == local_regnum - || addr == last_addr)); - } - last_addr = addr; - } - - if ((reg_stor && mem_stor) - || (mem_stor && !mem_tracking)) - /* Mixed storage; all of the hassle we just went through was - for some good purpose. */ - { - VALUE_LVAL (v) = lval_reg_frame_relative; - VALUE_FRAME (v) = FRAME_FP (frame); - VALUE_FRAME_REGNUM (v) = regnum; - } - else if (mem_stor) - { - VALUE_LVAL (v) = lval_memory; - VALUE_ADDRESS (v) = first_addr; - } - else if (reg_stor) - { - VALUE_LVAL (v) = lval_register; - VALUE_ADDRESS (v) = first_addr; - } - else - fatal ("value_from_register: Value not stored anywhere!"); - - VALUE_OPTIMIZED_OUT (v) = optim; - - /* Any structure stored in more than one register will always be - an integral number of registers. Otherwise, you'd need to do - some fiddling with the last register copied here for little - endian machines. */ - - /* Copy into the contents section of the value. */ - bcopy (value_bytes, VALUE_CONTENTS_RAW (v), len); - - return v; - } - - /* Data is completely contained within a single register. Locate the - register's contents in a real register or in core; - read the data in raw format. */ - - get_saved_register (raw_buffer, &optim, &addr, frame, regnum, &lval); - VALUE_OPTIMIZED_OUT (v) = optim; - VALUE_LVAL (v) = lval; - VALUE_ADDRESS (v) = addr; - - /* Convert the raw contents to virtual contents. - (Just copy them if the formats are the same.) */ - - target_convert_to_virtual (regnum, raw_buffer, virtual_buffer); - - if (REGISTER_CONVERTIBLE (regnum)) - { - /* When the raw and virtual formats differ, the virtual format - corresponds to a specific data type. If we want that type, - copy the data into the value. - Otherwise, do a type-conversion. */ - - if (type != REGISTER_VIRTUAL_TYPE (regnum)) - { - /* eg a variable of type `float' in a 68881 register - with raw type `extended' and virtual type `double'. - Fetch it as a `double' and then convert to `float'. */ - v = allocate_value (REGISTER_VIRTUAL_TYPE (regnum)); - bcopy (virtual_buffer, VALUE_CONTENTS_RAW (v), len); - v = value_cast (type, v); - } - else - bcopy (virtual_buffer, VALUE_CONTENTS_RAW (v), len); - } - else - { - /* Raw and virtual formats are the same for this register. */ - -#if TARGET_BYTE_ORDER == BIG_ENDIAN - if (len < REGISTER_RAW_SIZE (regnum)) - { - /* Big-endian, and we want less than full size. */ - VALUE_OFFSET (v) = REGISTER_RAW_SIZE (regnum) - len; - } -#endif - - bcopy (virtual_buffer + VALUE_OFFSET (v), - VALUE_CONTENTS_RAW (v), len); - } - - return v; -} - -/* Given a struct symbol for a variable or function, - and a stack frame id, - return a (pointer to a) struct value containing the properly typed - address. */ - -value -locate_var_value (var, frame) - register struct symbol *var; - FRAME frame; -{ - CORE_ADDR addr = 0; - struct type *type = SYMBOL_TYPE (var); - struct type *result_type; - value lazy_value; - - /* Evaluate it first; if the result is a memory address, we're fine. - Lazy evaluation pays off here. */ - - lazy_value = read_var_value (var, frame); - if (lazy_value == 0) - error ("Address of \"%s\" is unknown.", SYMBOL_NAME (var)); - - if (VALUE_LAZY (lazy_value) - || TYPE_CODE (type) == TYPE_CODE_FUNC) - { - addr = VALUE_ADDRESS (lazy_value); - - /* C++: The "address" of a reference should yield the address - * of the object pointed to. So force an extra de-reference. */ - - if (TYPE_CODE (type) == TYPE_CODE_REF) - { - char *buf = alloca (TYPE_LENGTH (type)); - read_memory (addr, buf, TYPE_LENGTH (type)); - addr = unpack_pointer (type, buf); - type = TYPE_TARGET_TYPE (type); - } - - /* Address of an array is of the type of address of it's elements. */ - /* FIXME, this is probably wrong now for ANSI C. */ - result_type = - lookup_pointer_type (TYPE_CODE (type) == TYPE_CODE_ARRAY ? - TYPE_TARGET_TYPE (type) : type); - - return value_cast (result_type, - value_from_long (builtin_type_long, (LONGEST) addr)); - } - - /* Not a memory address; check what the problem was. */ - switch (VALUE_LVAL (lazy_value)) - { - case lval_register: - case lval_reg_frame_relative: - error ("Address requested for identifier \"%s\" which is in a register.", - SYMBOL_NAME (var)); - break; - - default: - error ("Can't take address of \"%s\" which isn't an lvalue.", - SYMBOL_NAME (var)); - break; - } - return 0; /* For lint -- never reached */ -} diff --git a/gdb/frame.h b/gdb/frame.h deleted file mode 100644 index 5c98c9c7baf..00000000000 --- a/gdb/frame.h +++ /dev/null @@ -1,128 +0,0 @@ -/* Definitions for dealing with stack frames, for GDB, the GNU debugger. - Copyright (C) 1986, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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 1, or (at your option) -any later version. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#if !defined (FRAME_H) -#define FRAME_H 1 -#include "param.h" - -/* - * FRAME is the type of the identifier of a specific stack frame. It - * is a pointer to the frame cache item corresponding to this frame. - * Please note that frame id's are *not* constant over calls to the - * inferior. Use frame addresses, which are. - * - * FRAME_ADDR is the type of the address of a specific frame. I - * cannot imagine a case in which this would not be CORE_ADDR, so - * maybe it's silly to give it it's own type. Life's rough. - * - * FRAME_FP is a macro which converts from a frame identifier into a - * frame_address. - * - * FRAME_INFO_ID is a macro which "converts" from a frame info pointer - * to a frame id. This is here in case I or someone else decides to - * change the FRAME type again. - * - * This file and blockframe.c are the only places which are allowed to - * use the equivalence between FRAME and struct frame_info *. EXCEPTION: - * value.h uses CORE_ADDR instead of FRAME_ADDR because the compiler - * will accept that in the absense of this file. - */ -typedef struct frame_info *FRAME; -typedef CORE_ADDR FRAME_ADDR; -#define FRAME_FP(fr) ((fr)->frame) -#define FRAME_INFO_ID(f) (f) - -/* - * Caching structure for stack frames. This is also the structure - * used for extended info about stack frames. May add more to this - * structure as it becomes necessary. - * - * Note that the first entry in the cache will always refer to the - * innermost executing frame. This value should be set (is it? - * Check) in something like normal_stop. - */ -struct frame_info - { - /* Nominal address of the frame described. */ - FRAME_ADDR frame; - /* Address at which execution is occurring in this frame. - For the innermost frame, it's the current pc. - For other frames, it is a pc saved in the next frame. */ - CORE_ADDR pc; - /* The frame called by the frame we are describing, or 0. - This may be set even if there isn't a frame called by the one - we are describing (.->next == 0); in that case it is simply the - bottom of this frame */ - FRAME_ADDR next_frame; - /* Anything extra for this structure that may have been defined - in the machine depedent files. */ -#ifdef EXTRA_FRAME_INFO - EXTRA_FRAME_INFO -#endif - /* Pointers to the next and previous frame_info's in this stack. */ - FRAME next, prev; - }; - -/* Describe the saved registers of a frame. */ - -struct frame_saved_regs - { - /* For each register, address of where it was saved on entry to the frame, - or zero if it was not saved on entry to this frame. */ - CORE_ADDR regs[NUM_REGS]; - }; - -/* The stack frame that the user has specified for commands to act on. - Note that one cannot assume this is the address of valid data. */ - -extern FRAME selected_frame; - -extern struct frame_info *get_frame_info (); -extern struct frame_info *get_prev_frame_info (); - -extern FRAME create_new_frame (); -extern void flush_cached_frames (); - -extern void get_frame_saved_regs (); - -extern void set_current_frame (); -extern FRAME get_prev_frame (); -extern FRAME get_current_frame (); -extern FRAME get_next_frame (); - -extern struct block *get_frame_block (); -extern struct block *get_current_block (); -extern struct block *get_selected_block (); -extern struct symbol *get_frame_function (); -extern CORE_ADDR get_frame_pc (); -extern CORE_ADDR get_pc_function_start (); -struct block *block_for_pc (); - -int frameless_look_for_prologue (); - -void print_frame_args (); - -/* In stack.c */ -extern FRAME find_relative_frame (); -extern void print_selected_frame (); -extern void print_sel_frame (); -extern void select_frame (); -extern void record_selected_frame (); - -#endif /* frame.h not already included. */ diff --git a/gdb/gdb-int.texinfo b/gdb/gdb-int.texinfo deleted file mode 100755 index cc1b1880e2b..00000000000 --- a/gdb/gdb-int.texinfo +++ /dev/null @@ -1,242 +0,0 @@ -\input texinfo -@setfilename gdb-internals -@ifinfo -This file documents the internals of the GNU debugger GDB. - -Copyright (C) 1990, 1991 Free Software Foundation, Inc. -Contributed by Cygnus Support. Written by John Gilmore. - -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. - -@ignore -Permission is granted to process this file through Tex and print the -results, provided the printed document carries copying permission -notice identical to this one except for the removal of this paragraph -(this paragraph not being relevant to the printed manual). - -@end ignore -Permission is granted to copy or distribute modified versions of this -manual under the terms of the GPL (for which purpose this text may be -regarded as a program in the language TeX). -@end ifinfo - -@setchapternewpage odd -@settitle GDB Internals -@titlepage -@title{Working in GDB} -@subtitle{A guide to the internals of the GNU debugger} -@author John Gilmore -@author Cygnus Support -@page -@tex -\def\$#1${{#1}} % Kluge: collect RCS revision info without $...$ -\xdef\manvers{\$Revision$} % For use in headers, footers too -{\parskip=0pt -\hfill Cygnus Support\par -\hfill \manvers\par -\hfill \TeX{}info \texinfoversion\par -} -@end tex - -@vskip 0pt plus 1filll -Copyright @copyright{} 1990, 1991 Free Software Foundation, Inc. - -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. - -@end titlepage - -@node Top, Cleanups, (dir), (dir) - -@menu -* Cleanups:: Cleanups -* Wrapping:: Wrapping output lines -* Releases:: Configuring GDB for release -* README:: The README file -* New Architectures:: Defining a new host or target architecture -* Host versus Targt:: What features are in which files - -@end menu - -@node Cleanups, Wrapping, Top, Top -@chapter Cleanups - -Cleanups are a structured way to deal with things that need to be done -later. When your code does something (like malloc some memory, or open -a file) that needs to be undone later (e.g. free the memory or close -the file), it can make a cleanup. The cleanup will be done at some -future point: when the command is finished, when an error occurs, or -when your code decides it's time to do cleanups. - -You can also discard cleanups, that is, throw them away without doing -what they say. This is only done if you ask that it be done. - -Syntax: - -@table @code -@item old_chain = make_cleanup (function, arg); -This makes a cleanup which will cause FUNCTION to be called with ARG -(a char *) later. The result, OLD_CHAIN, is a handle that can be -passed to do_cleanups or discard_cleanups later. Unless you are -going to call do_cleanups or discard_cleanups yourself, -you can ignore the result from make_cleanup. - - -@item do_cleanups (old_chain); -Performs all cleanups done since make_cleanup returned OLD_CHAIN. -E.g.: make_cleanup (a, 0); old = make_cleanup (b, 0); do_cleanups (old); -will call b() but will not call a(). The cleanup that calls a() will remain -in the cleanup chain, and will be done later unless otherwise discarded. - -@item discard_cleanups (old_chain); -Same as do_cleanups except that it just removes the cleanups from the -chain and does not call the specified functions. - -@end table - -Some functions, e.g. @code{fputs_filtered()} or @code{error()}, specify that they -``should not be called when cleanups are not in place''. This means -that any actions you need to reverse in the case of an error or -interruption must be on the cleanup chain before you call these functions, -since they might never return to your code (they @samp{longjmp} instead). - - -@node Wrapping, Releases, Cleanups, Top -@chapter Wrapping output lines - -Output that goes through printf_filtered or fputs_filtered or -fputs_demangled needs only to have calls to wrap_here() added -in places that would be good breaking points. The utility routines -will take care of actually wrapping if the line width is exceeded. - -The argument to wrap_here() is an indentation string which is printed -ONLY if the line breaks there. This argument is saved away and used -later. It must remain valid until the next call to wrap_here() or -until a newline has been printed through the *_filtered functions. -Don't pass in a local variable and then return! - -It is usually best to call wrap_here() after printing a comma or space. -If you call it before printing a space, make sure that your indentation -properly accounts for the leading space that will print if the line wraps -there. - -Any function or set of functions that produce filtered output must finish -by printing a newline, to flush the wrap buffer, before switching to -unfiltered ("printf") output. Symbol reading routines that print -warnings are a good example. - - -@node Releases, README, Wrapping, Top -@chapter Configuring GDB for release - - -GDB should be released after doing @samp{config.gdb none} in the top level -directory. This will leave a makefile there, but no tm- or xm- files. -The makefile is needed, for example, for @samp{make gdb.tar.Z}@dots{} If you -have tm- or xm-files in the main source directory, C's include rules -cause them to be used in preference to tm- and xm-files in the -subdirectories where the user will actually configure and build the -binaries. - -@samp{config.gdb none} is also a good way to rebuild the top level Makefile -after changing Makefile.dist, alldeps.mak, etc. - - - -@node README, New Architectures, Releases, Top -@chapter The README file - - -Check the README file, it often has useful information that does not -appear anywhere else in the directory. - - - -@node New Architectures, Host versus Target, README, Top -@chapter Defining a new host or target architecture - - -When building support for a new host and/or target, this will help you -organize where to put the various parts. @var{ARCH} stands for the -architecture involved. - -Object files needed when the host system is an @var{ARCH} are listed in -the file @file{xconfig/@var{ARCH}}, in the Makefile macro @samp{XDEPFILES -= }@dots{}. You can also define XXXXXX in there. - -There are some ``generic'' versions of routines that can be used by -various host systems. If these routines work for the @var{ARCH} host, -you can just include the generic file's name (with .o, not .c) in -@code{XDEPFILES}. Otherwise, you will need to write routines that -perform the same functions as the generic file, put them into -@code{@var{ARCH}-xdep.c}, and put @code{@var{ARCH}-xdep.o} into -@code{XDEPFILES}. These generic host support files include: - -@example - coredep.c, coredep.o -@end example - -@table @code -@item fetch_core_registers() -Support for reading registers out of a core file. This routine calls -@code{register_addr(}), see below. - -@item register_addr() -If your @code{xm-@var{ARCH}.h} file defines the macro @code{REGISTER_U_ADDR(reg)} to be the -offset within the @samp{user} struct of a register (represented as a GDB -register number), @file{coredep.c} will define the @code{register_addr()} function -and use the macro in it. If you do not define @code{REGISTER_U_ADDR}, but -you are using the standard @code{fetch_core_registers}, you -will need to define your own version of @code{register_addr}, put it into -your @code{@var{ARCH}-xdep.c} file, and be sure @code{@var{ARCH}-xdep.o} is in the @code{XDEPFILES} list. -If you have your own @code{fetch_core_registers}, you only need to define -@code{register_addr} if your @code{fetch_core_registers} calls it. Many custom -@code{fetch_core_registers} implementations simply locate the registers -themselves. -@end table - -Files needed when the target system is an @var{ARCH} are listed in the file -@file{tconfig/@var{ARCH}}, in the @code{Makefile} macro @samp{TDEPFILES = }@dots{}. You can also -define XXXXXX in there. - -Similar generic support files for target systems are: - -@example - exec.c, exec.o: -@end example - -This file defines functions for accessing files that are executable -on the target system. These functions open and examine an exec file, -extract data from one, write data to one, print information about one, -etc. Now that executable files are handled with BFD, every architecture -should be able to use the generic exec.c rather than its own custom code. - -@node Host versus Target, , README, Top -@chapter What is considered ``host-dependent'' versus ``target-dependent''? - -The xconfig/*, xm-*.h and *-xdep.c files are for host support. The -question is, what features or aspects of a debugging or cross-debugging -environment are considered to be ``host'' support. - -Defines and include files needed to build on the host are host support. -Examples are tty support, system defined types, host byte order, host -float format. - -Unix child process support is considered an aspect of the host. Since -when you fork on the host you are still on the host, the various macros -needed for finding the registers in the upage, running ptrace, and such -are all in the host-dependent files. - -This is still somewhat of a grey area; I (John Gilmore) didn't do the -xm- and tm- split for gdb (it was done by Jim Kingdon) so I have had to -figure out the grounds on which it was split, and make my own choices -as I evolve it. I have moved many things out of the xdep files -actually, partly as a result of BFD and partly by removing duplicated -code. - -@contents -@bye - diff --git a/gdb/gdbcmd.h b/gdb/gdbcmd.h deleted file mode 100644 index 39151f575df..00000000000 --- a/gdb/gdbcmd.h +++ /dev/null @@ -1,63 +0,0 @@ -/* Header file for GDB-specific command-line stuff. - Copyright (C) 1986, 1989, 1990 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include "command.h" - -/* Chain containing all defined commands. */ - -extern struct cmd_list_element *cmdlist; - -/* Chain containing all defined info subcommands. */ - -extern struct cmd_list_element *infolist; - -/* Chain containing all defined enable subcommands. */ - -extern struct cmd_list_element *enablelist; - -/* Chain containing all defined disable subcommands. */ - -extern struct cmd_list_element *disablelist; - -/* Chain containing all defined delete subcommands. */ - -extern struct cmd_list_element *deletelist; - -/* Chain containing all defined "enable breakpoint" subcommands. */ - -extern struct cmd_list_element *enablebreaklist; - -/* Chain containing all defined set subcommands */ - -extern struct cmd_list_element *setlist; - -/* Chain containing all defined show subcommands. */ -extern struct cmd_list_element *showlist; - -/* Chain containing all defined \"set history\". */ - -extern struct cmd_list_element *sethistlist; - -/* Chain containing all defined \"show history\". */ -extern struct cmd_list_element *showhistlist; - -/* Chain containing all defined \"unset history\". */ - -extern struct cmd_list_element *unsethistlist; - -void execute_command (); -char **noop_completer (); diff --git a/gdb/gdbcore.h b/gdb/gdbcore.h deleted file mode 100644 index 0be67bbaa25..00000000000 --- a/gdb/gdbcore.h +++ /dev/null @@ -1,88 +0,0 @@ -/* Machine independent variables that describe the core file under GDB. - Copyright (C) 1986, 1987, 1989, 1990 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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 1, or (at your option) -any later version. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Interface routines for core, executable, etc. */ - -#include "bfd.h" /* Binary File Description */ - -/* Return the name of the executable file as a string. - ERR nonzero means get error if there is none specified; - otherwise return 0 in that case. */ -char *get_exec_file (); - -/* Nonzero if there is a core file. */ -int have_core_file_p (); - -/* Read "memory data" from whatever target or inferior we have. - Returns zero if successful, errno value if not. EIO is used - for address out of bounds. If breakpoints are inserted, returns - shadow contents, not the breakpoints themselves. From breakpoint.c. */ -int read_memory_nobpt (); - -/* Report a memory error with error(). */ - -void memory_error (); - -/* Like target_read_memory, but report an error if can't read. */ -void read_memory (); - -/* Read an integer from debugged memory, given address and number of bytes. */ -long read_memory_integer (); - -void write_memory ( -#ifdef __STDC__ - CORE_ADDR, char *, int -#endif - ); - -/* Hook for `exec_file_command' command to call. */ - -extern void (*exec_file_display_hook) (); - -/* Binary File Diddlers for the exec and core files */ -extern bfd *core_bfd; -extern bfd *exec_bfd; - -void core_file_command (); -void exec_file_command (); -void validate_files (); -unsigned int register_addr (); -int xfer_core_file (); -void fetch_core_registers (); -void registers_fetched (); - -#if !defined (KERNEL_U_ADDR) -extern CORE_ADDR kernel_u_addr; -#define KERNEL_U_ADDR kernel_u_addr -#endif - -/* Struct section_table maps address ranges to file sections. It is - mostly used with BFD files, but can be used without (e.g. for handling - raw disks, or files not in formats handled by BFD). */ - -struct section_table { - CORE_ADDR addr; /* Lowest address in section */ - CORE_ADDR endaddr; /* 1+highest address in section */ - sec_ptr sec_ptr; /* BFD section pointer */ -}; - -/* Builds a section table, given args BFD, SECTABLE_PTR, SECEND_PTR. - Returns 0 if OK, 1 on error. */ - -int build_section_table (); diff --git a/gdb/getpagesize.h b/gdb/getpagesize.h deleted file mode 100755 index 32adae61efa..00000000000 --- a/gdb/getpagesize.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifdef BSD -#ifndef BSD4_1 -#define HAVE_GETPAGESIZE -#endif -#endif - -#ifndef HAVE_GETPAGESIZE - -#include - -#ifdef EXEC_PAGESIZE -#define getpagesize() EXEC_PAGESIZE -#else -#ifdef NBPG -#define getpagesize() NBPG * CLSIZE -#ifndef CLSIZE -#define CLSIZE 1 -#endif /* no CLSIZE */ -#else /* no NBPG */ -#define getpagesize() NBPC -#endif /* no NBPG */ -#endif /* no EXEC_PAGESIZE */ - -#endif /* not HAVE_GETPAGESIZE */ - diff --git a/gdb/gmalloc.c b/gdb/gmalloc.c deleted file mode 100755 index d533eaa4960..00000000000 --- a/gdb/gmalloc.c +++ /dev/null @@ -1,1152 +0,0 @@ - -/* gmalloc.c - THIS FILE IS AUTOMAGICALLY GENERATED SO DON'T EDIT IT. */ - -/* Single-file skeleton for GNU malloc. - Copyright 1989 Free Software Foundation - Written May 1989 by Mike Haertel. - - The author may be reached (Email) at the address mike@ai.mit.edu, - or (US mail) as Mike Haertel c/o Free Software Foundation. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#define __ONEFILE - -/* DO NOT DELETE THIS LINE -- ansidecl.h INSERTED HERE. */ -/* Copyright (C) 1989 Free Software Foundation, Inc. -This file is part of the GNU C 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* ANSI and traditional C compatibility macros - - ANSI C is assumed if __STDC__ is #defined. - - Macros - PTR - Generic pointer type - LONG_DOUBLE - `long double' type - CONST - `const' keyword - VOLATILE - `volatile' keyword - SIGNED - `signed' keyword - PTRCONST - Generic const pointer (void *const) - - EXFUN(name, prototype) - declare external function NAME - with prototype PROTOTYPE - DEFUN(name, arglist, args) - define function NAME with - args ARGLIST of types in ARGS - DEFUN_VOID(name) - define function NAME with no args - AND - argument separator for ARGS - NOARGS - null arglist - DOTS - `...' in args - - For example: - extern int EXFUN(printf, (CONST char *format DOTS)); - int DEFUN(fprintf, (stream, format), - FILE *stream AND CONST char *format DOTS) { ... } - void DEFUN_VOID(abort) { ... } -*/ - -#ifndef _ANSIDECL_H - -#define _ANSIDECL_H 1 - - -/* Every source file includes this file, - so they will all get the switch for lint. */ -/* LINTLIBRARY */ - - -#ifdef __STDC__ - -#define PTR void * -#define PTRCONST void *CONST -#define LONG_DOUBLE long double - -#define AND , -#define NOARGS void -#define CONST const -#define VOLATILE volatile -#define SIGNED signed -#define DOTS , ... - -#define EXFUN(name, proto) name proto -#define DEFUN(name, arglist, args) name(args) -#define DEFUN_VOID(name) name(NOARGS) - -#else /* Not ANSI C. */ - -#define PTR char * -#define PTRCONST PTR -#define LONG_DOUBLE double - -#define AND ; -#define NOARGS -#define CONST -#define VOLATILE -#define SIGNED -#define DOTS - -#define EXFUN(name, proto) name() -#define DEFUN(name, arglist, args) name arglist args; -#define DEFUN_VOID(name) name() - -#endif /* ANSI C. */ - - -#endif /* ansidecl.h */ - -#ifdef __STDC__ -#include -#else -/* DO NOT DELETE THIS LINE -- limits.h INSERTED HERE. */ -/* Number of bits in a `char'. */ -#define CHAR_BIT 8 - -/* No multibyte characters supported yet. */ -#define MB_LEN_MAX 1 - -/* Minimum and maximum values a `signed char' can hold. */ -#define SCHAR_MIN -128 -#define SCHAR_MAX 127 - -/* Maximum value an `unsigned char' can hold. (Minimum is 0). */ -#define UCHAR_MAX 255U - -/* Minimum and maximum values a `char' can hold. */ -#ifdef __CHAR_UNSIGNED__ -#define CHAR_MIN 0 -#define CHAR_MAX 255U -#else -#define CHAR_MIN -128 -#define CHAR_MAX 127 -#endif - -/* Minimum and maximum values a `signed short int' can hold. */ -#define SHRT_MIN -32768 -#define SHRT_MAX 32767 - -/* Maximum value an `unsigned short int' can hold. (Minimum is 0). */ -#define USHRT_MAX 65535U - -/* Minimum and maximum values a `signed int' can hold. */ -#define INT_MIN -2147483648 -#define INT_MAX 2147483647 - -/* Maximum value an `unsigned int' can hold. (Minimum is 0). */ -#define UINT_MAX 4294967295U - -/* Minimum and maximum values a `signed long int' can hold. - (Same as `int'). */ -#define LONG_MIN (-LONG_MAX-1) -#define LONG_MAX 2147483647 - -/* Maximum value an `unsigned long int' can hold. (Minimum is 0). */ -#define ULONG_MAX 4294967295U -#endif - -#ifdef __STDC__ -#include -#else -/* DO NOT DELETE THIS LINE -- stddef.h INSERTED HERE. */ -#ifndef _STDDEF_H -#define _STDDEF_H - -/* Signed type of difference of two pointers. */ - -typedef long ptrdiff_t; - -/* Unsigned type of `sizeof' something. */ - -#ifndef _SIZE_T /* in case has defined it. */ -#define _SIZE_T -typedef unsigned long size_t; -#endif /* _SIZE_T */ - -/* A null pointer constant. */ - -#undef NULL /* in case has defined it. */ -#define NULL 0 - -/* Offset of member MEMBER in a struct of type TYPE. */ - -#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) - -#endif /* _STDDEF_H */ -#endif - -/* DO NOT DELETE THIS LINE -- stdlib.h INSERTED HERE. */ -/* Fake stdlib.h supplying the stuff needed by malloc. */ - -#ifndef __ONEFILE -#include -#endif - -extern void EXFUN(abort, (void)); -extern void EXFUN(free, (PTR)); -extern PTR EXFUN(malloc, (size_t)); -extern PTR EXFUN(realloc, (PTR, size_t)); - -/* DO NOT DELETE THIS LINE -- string.h INSERTED HERE. */ -/* Fake string.h supplying stuff used by malloc. */ -#ifndef __ONEFILE -#include -#endif - -extern PTR EXFUN(memcpy, (PTR, CONST PTR, size_t)); -extern PTR EXFUN(memset, (PTR, int, size_t)); -#define memmove memcpy - -#define _MALLOC_INTERNAL -/* DO NOT DELETE THIS LINE -- malloc.h INSERTED HERE. */ -/* Declarations for `malloc' and friends. - Copyright 1990 Free Software Foundation - Written May 1989 by Mike Haertel. - - The author may be reached (Email) at the address mike@ai.mit.edu, - or (US mail) as Mike Haertel c/o Free Software Foundation. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifndef _MALLOC_H - -#define _MALLOC_H 1 - -#ifndef __ONEFILE -#define __need_NULL -#define __need_size_t -#define __need_ptrdiff_t -#include -#endif - -#ifdef _MALLOC_INTERNAL - -#ifndef __ONEFILE -#include -#endif - -/* The allocator divides the heap into blocks of fixed size; large - requests receive one or more whole blocks, and small requests - receive a fragment of a block. Fragment sizes are powers of two, - and all fragments of a block are the same size. When all the - fragments in a block have been freed, the block itself is freed. */ -#define INT_BIT (CHAR_BIT * sizeof(int)) -#define BLOCKLOG (INT_BIT > 16 ? 12 : 9) -#define BLOCKSIZE (1 << BLOCKLOG) -#define BLOCKIFY(SIZE) (((SIZE) + BLOCKSIZE - 1) / BLOCKSIZE) - -/* Determine the amount of memory spanned by the initial heap table - (not an absolute limit). */ -#define HEAP (INT_BIT > 16 ? 4194304 : 65536) - -/* Number of contiguous free blocks allowed to build up at the end of - memory before they will be returned to the system. */ -#define FINAL_FREE_BLOCKS 8 - -/* Where to start searching the free list when looking for new memory. - The two possible values are 0 and _heapindex. Starting at 0 seems - to reduce total memory usage, while starting at _heapindex seems to - run faster. */ -#define MALLOC_SEARCH_START _heapindex - -/* Data structure giving per-block information. */ -typedef union - { - /* Heap information for a busy block. */ - struct - { - /* Zero for a large block, or positive giving the - logarithm to the base two of the fragment size. */ - int type; - union - { - struct - { - size_t nfree; /* Free fragments in a fragmented block. */ - size_t first; /* First free fragment of the block. */ - } frag; - /* Size (in blocks) of a large cluster. */ - size_t size; - } info; - } busy; - /* Heap information for a free block (that may be the first of - a free cluster). */ - struct - { - size_t size; /* Size (in blocks) of a free cluster. */ - size_t next; /* Index of next free cluster. */ - size_t prev; /* Index of previous free cluster. */ - } free; - } malloc_info; - -/* Pointer to first block of the heap. */ -extern char *_heapbase; - -/* Table indexed by block number giving per-block information. */ -extern malloc_info *_heapinfo; - -/* Address to block number and vice versa. */ -#define BLOCK(A) (((char *) (A) - _heapbase) / BLOCKSIZE + 1) -#define ADDRESS(B) ((PTR) (((B) - 1) * BLOCKSIZE + _heapbase)) - -/* Current search index for the heap table. */ -extern size_t _heapindex; - -/* Limit of valid info table indices. */ -extern size_t _heaplimit; - -/* Doubly linked lists of free fragments. */ -struct list - { - struct list *next; - struct list *prev; - }; - -/* Free list headers for each fragment size. */ -extern struct list _fraghead[]; - -/* Instrumentation. */ -extern size_t _chunks_used; -extern size_t _bytes_used; -extern size_t _chunks_free; -extern size_t _bytes_free; - -/* Internal version of free() used in morecore(). */ -extern void EXFUN(__free, (PTR __ptr)); - -#endif /* _MALLOC_INTERNAL. */ - -/* Underlying allocation function; successive calls should - return contiguous pieces of memory. */ -extern PTR EXFUN((*__morecore), (ptrdiff_t __size)); - -/* Default value of previous. */ -extern PTR EXFUN(__default_morecore, (ptrdiff_t __size)); - -/* Flag whether malloc has been called. */ -extern int __malloc_initialized; - -/* Hooks for debugging versions. */ -extern void EXFUN((*__free_hook), (PTR __ptr)); -extern PTR EXFUN((*__malloc_hook), (size_t __size)); -extern PTR EXFUN((*__realloc_hook), (PTR __ptr, size_t __size)); - -/* Activate a standard collection of debugging hooks. */ -extern void EXFUN(mcheck, (void EXFUN((*func), (void)))); - -/* Statistics available to the user. */ -struct mstats - { - size_t bytes_total; /* Total size of the heap. */ - size_t chunks_used; /* Chunks allocated by the user. */ - size_t bytes_used; /* Byte total of user-allocated chunks. */ - size_t chunks_free; /* Chunks in the free list. */ - size_t bytes_free; /* Byte total of chunks in the free list. */ - }; - -/* Pick up the current statistics. */ -extern struct mstats EXFUN(mstats, (NOARGS)); - -#endif /* malloc.h */ - -/* DO NOT DELETE THIS LINE -- free.c INSERTED HERE. */ -/* Free a block of memory allocated by `malloc'. - Copyright 1990 Free Software Foundation - Written May 1989 by Mike Haertel. - - The author may be reached (Email) at the address mike@ai.mit.edu, - or (US mail) as Mike Haertel c/o Free Software Foundation. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifndef __ONEFILE -#include "ansidecl.h" -#include -#include - -#define _MALLOC_INTERNAL -#include "malloc.h" -#endif /* __ONEFILE */ - -/* Debugging hook for free. */ -void EXFUN((*__free_hook), (PTR __ptr)); - -/* Return memory to the heap. Like free() but don't call a __free_hook - if there is one. */ -void -DEFUN(__free, (ptr), PTR ptr) -{ - int type; - size_t block, blocks; - register size_t i; - struct list *prev, *next; - - block = BLOCK(ptr); - - type = _heapinfo[block].busy.type; - switch (type) - { - case 0: - /* Get as many statistics as early as we can. */ - --_chunks_used; - _bytes_used -= _heapinfo[block].busy.info.size * BLOCKSIZE; - _bytes_free += _heapinfo[block].busy.info.size * BLOCKSIZE; - - /* Find the free cluster previous to this one in the free list. - Start searching at the last block referenced; this may benefit - programs with locality of allocation. */ - i = _heapindex; - if (i > block) - while (i > block) - i = _heapinfo[i].free.prev; - else - { - do - i = _heapinfo[i].free.next; - while (i > 0 && i < block); - i = _heapinfo[i].free.prev; - } - - /* Determine how to link this block into the free list. */ - if (block == i + _heapinfo[i].free.size) - { - /* Coalesce this block with its predecessor. */ - _heapinfo[i].free.size += _heapinfo[block].busy.info.size; - block = i; - } - else - { - /* Really link this block back into the free list. */ - _heapinfo[block].free.size = _heapinfo[block].busy.info.size; - _heapinfo[block].free.next = _heapinfo[i].free.next; - _heapinfo[block].free.prev = i; - _heapinfo[i].free.next = block; - _heapinfo[_heapinfo[block].free.next].free.prev = block; - ++_chunks_free; - } - - /* Now that the block is linked in, see if we can coalesce it - with its successor (by deleting its successor from the list - and adding in its size). */ - if (block + _heapinfo[block].free.size == _heapinfo[block].free.next) - { - _heapinfo[block].free.size - += _heapinfo[_heapinfo[block].free.next].free.size; - _heapinfo[block].free.next - = _heapinfo[_heapinfo[block].free.next].free.next; - _heapinfo[_heapinfo[block].free.next].free.prev = block; - --_chunks_free; - } - - /* Now see if we can return stuff to the system. */ - blocks = _heapinfo[block].free.size; - if (blocks >= FINAL_FREE_BLOCKS && block + blocks == _heaplimit - && (*__morecore)(0) == ADDRESS(block + blocks)) - { - register size_t bytes = blocks * BLOCKSIZE; - _heaplimit -= blocks; - (*__morecore)(- bytes); - _heapinfo[_heapinfo[block].free.prev].free.next - = _heapinfo[block].free.next; - _heapinfo[_heapinfo[block].free.next].free.prev - = _heapinfo[block].free.prev; - block = _heapinfo[block].free.prev; - --_chunks_free; - _bytes_free -= bytes; - } - - /* Set the next search to begin at this block. */ - _heapindex = block; - break; - - default: - /* Do some of the statistics. */ - --_chunks_used; - _bytes_used -= 1 << type; - ++_chunks_free; - _bytes_free += 1 << type; - - /* Get the address of the first free fragment in this block. */ - prev = (struct list *) ((char *) ADDRESS(block) + - (_heapinfo[block].busy.info.frag.first << type)); - - if (_heapinfo[block].busy.info.frag.nfree == (BLOCKSIZE >> type) - 1) - { - /* If all fragments of this block are free, remove them - from the fragment list and free the whole block. */ - next = prev; - for (i = 1; i < BLOCKSIZE >> type; ++i) - next = next->next; - prev->prev->next = next; - if (next != NULL) - next->prev = prev->prev; - _heapinfo[block].busy.type = 0; - _heapinfo[block].busy.info.size = 1; - - /* Keep the statistics accurate. */ - ++_chunks_used; - _bytes_used += BLOCKSIZE; - _chunks_free -= BLOCKSIZE >> type; - _bytes_free -= BLOCKSIZE; - - free(ADDRESS(block)); - } - else if (_heapinfo[block].busy.info.frag.nfree != 0) - { - /* If some fragments of this block are free, link this - fragment into the fragment list after the first free - fragment of this block. */ - next = (struct list *) ptr; - next->next = prev->next; - next->prev = prev; - prev->next = next; - if (next->next != NULL) - next->next->prev = next; - ++_heapinfo[block].busy.info.frag.nfree; - } - else - { - /* No fragments of this block are free, so link this - fragment into the fragment list and announce that - it is the first free fragment of this block. */ - prev = (struct list *) ptr; - _heapinfo[block].busy.info.frag.nfree = 1; - _heapinfo[block].busy.info.frag.first = (unsigned int) - (((char *) ptr - (char *) NULL) % BLOCKSIZE >> type); - prev->next = _fraghead[type].next; - prev->prev = &_fraghead[type]; - prev->prev->next = prev; - if (prev->next != NULL) - prev->next->prev = prev; - } - break; - } -} - -/* Return memory to the heap. */ -void -DEFUN(free, (ptr), PTR ptr) -{ - if (ptr == NULL) - return; - - if (__free_hook != NULL) - (*__free_hook)(ptr); - else - __free (ptr); -} - -/* DO NOT DELETE THIS LINE -- malloc.c INSERTED HERE. */ -/* Memory allocator `malloc'. - Copyright 1990 Free Software Foundation - Written May 1989 by Mike Haertel. - - The author may be reached (Email) at the address mike@ai.mit.edu, - or (US mail) as Mike Haertel c/o Free Software Foundation. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifndef __ONEFILE -#include "ansidecl.h" -#include -#include -#include - -#define _MALLOC_INTERNAL -#include "malloc.h" -#endif /* __ONEFILE */ - -/* How to really get more memory. */ -PTR EXFUN((*__morecore), (ptrdiff_t __size)) = __default_morecore; - -/* Debugging hook for `malloc'. */ -PTR EXFUN((*__malloc_hook), (size_t __size)); - -/* Pointer to the base of the first block. */ -char *_heapbase; - -/* Block information table. Allocated with align/__free (not malloc/free). */ -malloc_info *_heapinfo; - -/* Number of info entries. */ -static size_t heapsize; - -/* Search index in the info table. */ -size_t _heapindex; - -/* Limit of valid info table indices. */ -size_t _heaplimit; - -/* Free lists for each fragment size. */ -struct list _fraghead[BLOCKLOG]; - -/* Instrumentation. */ -size_t _chunks_used; -size_t _bytes_used; -size_t _chunks_free; -size_t _bytes_free; - -/* Are you experienced? */ -int __malloc_initialized; - -/* Aligned allocation. */ -static PTR -DEFUN(align, (size), size_t size) -{ - PTR result; - unsigned int adj; - - result = (*__morecore)(size); - adj = (unsigned int) ((char *) result - (char *) NULL) % BLOCKSIZE; - if (adj != 0) - { - adj = BLOCKSIZE - adj; - (void) (*__morecore)(adj); - result = (char *) result + adj; - } - return result; -} - -/* Set everything up and remember that we have. */ -static int -DEFUN_VOID(initialize) -{ - heapsize = HEAP / BLOCKSIZE; - _heapinfo = (malloc_info *) align(heapsize * sizeof(malloc_info)); - if (_heapinfo == NULL) - return 0; - memset(_heapinfo, 0, heapsize * sizeof(malloc_info)); - _heapinfo[0].free.size = 0; - _heapinfo[0].free.next = _heapinfo[0].free.prev = 0; - _heapindex = 0; - _heapbase = (char *) _heapinfo; - __malloc_initialized = 1; - return 1; -} - -/* Get neatly aligned memory, initializing or - growing the heap info table as necessary. */ -static PTR -DEFUN(morecore, (size), size_t size) -{ - PTR result; - malloc_info *newinfo, *oldinfo; - size_t newsize; - - result = align(size); - if (result == NULL) - return NULL; - - /* Check if we need to grow the info table. */ - if (BLOCK((char *) result + size) > heapsize) - { - newsize = heapsize; - while (BLOCK((char *) result + size) > newsize) - newsize *= 2; - newinfo = (malloc_info *) align(newsize * sizeof(malloc_info)); - if (newinfo == NULL) - { - (*__morecore)(- size); - return NULL; - } - memset(newinfo, 0, newsize * sizeof(malloc_info)); - memcpy(newinfo, _heapinfo, heapsize * sizeof(malloc_info)); - oldinfo = _heapinfo; - newinfo[BLOCK(oldinfo)].busy.type = 0; - newinfo[BLOCK(oldinfo)].busy.info.size - = BLOCKIFY(heapsize * sizeof(malloc_info)); - _heapinfo = newinfo; - __free(oldinfo); - heapsize = newsize; - } - - _heaplimit = BLOCK((char *) result + size); - return result; -} - -/* Allocate memory from the heap. */ -PTR -DEFUN(malloc, (size), size_t size) -{ - PTR result; - size_t block, blocks, lastblocks, start; - register size_t i; - struct list *next; - - if (size == 0) - return NULL; - - if (__malloc_hook != NULL) - return (*__malloc_hook)(size); - - if (!__malloc_initialized) - if (!initialize()) - return NULL; - - if (size < sizeof(struct list)) - size = sizeof(struct list); - - /* Determine the allocation policy based on the request size. */ - if (size <= BLOCKSIZE / 2) - { - /* Small allocation to receive a fragment of a block. - Determine the logarithm to base two of the fragment size. */ - register size_t log = 1; - --size; - while ((size /= 2) != 0) - ++log; - - /* Look in the fragment lists for a - free fragment of the desired size. */ - next = _fraghead[log].next; - if (next != NULL) - { - /* There are free fragments of this size. - Pop a fragment out of the fragment list and return it. - Update the block's nfree and first counters. */ - result = (PTR) next; - next->prev->next = next->next; - if (next->next != NULL) - next->next->prev = next->prev; - block = BLOCK(result); - if (--_heapinfo[block].busy.info.frag.nfree != 0) - _heapinfo[block].busy.info.frag.first = (unsigned int) - (((char *) next->next - (char *) NULL) % BLOCKSIZE) >> log; - - /* Update the statistics. */ - ++_chunks_used; - _bytes_used += 1 << log; - --_chunks_free; - _bytes_free -= 1 << log; - } - else - { - /* No free fragments of the desired size, so get a new block - and break it into fragments, returning the first. */ - result = malloc(BLOCKSIZE); - if (result == NULL) - return NULL; - - /* Link all fragments but the first into the free list. */ - for (i = 1; i < BLOCKSIZE >> log; ++i) - { - next = (struct list *) ((char *) result + (i << log)); - next->next = _fraghead[log].next; - next->prev = &_fraghead[log]; - next->prev->next = next; - if (next->next != NULL) - next->next->prev = next; - } - - /* Initialize the nfree and first counters for this block. */ - block = BLOCK(result); - _heapinfo[block].busy.type = log; - _heapinfo[block].busy.info.frag.nfree = i - 1; - _heapinfo[block].busy.info.frag.first = i - 1; - - _chunks_free += (BLOCKSIZE >> log) - 1; - _bytes_free += BLOCKSIZE - (1 << log); - } - } - else - { - /* Large allocation to receive one or more blocks. - Search the free list in a circle starting at the last place visited. - If we loop completely around without finding a large enough - space we will have to get more memory from the system. */ - blocks = BLOCKIFY(size); - start = block = MALLOC_SEARCH_START; - while (_heapinfo[block].free.size < blocks) - { - block = _heapinfo[block].free.next; - if (block == start) - { - /* Need to get more from the system. Check to see if - the new core will be contiguous with the final free - block; if so we don't need to get as much. */ - block = _heapinfo[0].free.prev; - lastblocks = _heapinfo[block].free.size; - if (_heaplimit != 0 && block + lastblocks == _heaplimit && - (*__morecore)(0) == ADDRESS(block + lastblocks) && - (morecore((blocks - lastblocks) * BLOCKSIZE)) != NULL) - { - _heapinfo[block].free.size = blocks; - _bytes_free += (blocks - lastblocks) * BLOCKSIZE; - continue; - } - result = morecore(blocks * BLOCKSIZE); - if (result == NULL) - return NULL; - block = BLOCK(result); - _heapinfo[block].busy.type = 0; - _heapinfo[block].busy.info.size = blocks; - ++_chunks_used; - _bytes_used += blocks * BLOCKSIZE; - return result; - } - } - - /* At this point we have found a suitable free list entry. - Figure out how to remove what we need from the list. */ - result = ADDRESS(block); - if (_heapinfo[block].free.size > blocks) - { - /* The block we found has a bit left over, - so relink the tail end back into the free list. */ - _heapinfo[block + blocks].free.size - = _heapinfo[block].free.size - blocks; - _heapinfo[block + blocks].free.next - = _heapinfo[block].free.next; - _heapinfo[block + blocks].free.prev - = _heapinfo[block].free.prev; - _heapinfo[_heapinfo[block].free.prev].free.next - = _heapinfo[_heapinfo[block].free.next].free.prev - = _heapindex = block + blocks; - } - else - { - /* The block exactly matches our requirements, - so just remove it from the list. */ - _heapinfo[_heapinfo[block].free.next].free.prev - = _heapinfo[block].free.prev; - _heapinfo[_heapinfo[block].free.prev].free.next - = _heapindex = _heapinfo[block].free.next; - --_chunks_free; - } - - _heapinfo[block].busy.type = 0; - _heapinfo[block].busy.info.size = blocks; - ++_chunks_used; - _bytes_used += blocks * BLOCKSIZE; - _bytes_free -= blocks * BLOCKSIZE; - } - - return result; -} - -/* DO NOT DELETE THIS LINE -- realloc.c INSERTED HERE. */ -/* Change the size of a block allocated by `malloc'. - Copyright 1990 Free Software Foundation - Written May 1989 by Mike Haertel. - - The author may be reached (Email) at the address mike@ai.mit.edu, - or (US mail) as Mike Haertel c/o Free Software Foundation. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifndef __ONEFILE -#include "ansidecl.h" -#include -#include - -#define _MALLOC_INTERNAL -#include "malloc.h" -#endif /* __ONEFILE */ - -#define MIN(A, B) ((A) < (B) ? (A) : (B)) - -/* Debugging hook for realloc. */ -PTR EXFUN((*__realloc_hook), (PTR __ptr, size_t __size)); - -/* Resize the given region to the new size, returning a pointer - to the (possibly moved) region. This is optimized for speed; - some benchmarks seem to indicate that greater compactness is - achieved by unconditionally allocating and copying to a - new region. This module has incestuous knowledge of the - internals of both free and malloc. */ -PTR -DEFUN(realloc, (ptr, size), PTR ptr AND size_t size) -{ - PTR result; - int type; - size_t block, blocks, oldlimit; - - if (size == 0) - { - free(ptr); - return NULL; - } - else if (ptr == NULL) - return malloc(size); - - if (__realloc_hook != NULL) - return (*__realloc_hook)(ptr, size); - - block = BLOCK(ptr); - - type = _heapinfo[block].busy.type; - switch (type) - { - case 0: - /* Maybe reallocate a large block to a small fragment. */ - if (size <= BLOCKSIZE / 2) - { - result = malloc(size); - if (result != NULL) - { - memcpy(result, ptr, size); - free(ptr); - return result; - } - } - - /* The new size is a large allocation as well; - see if we can hold it in place. */ - blocks = BLOCKIFY(size); - if (blocks < _heapinfo[block].busy.info.size) - { - /* The new size is smaller; return - excess memory to the free list. */ - _heapinfo[block + blocks].busy.type = 0; - _heapinfo[block + blocks].busy.info.size - = _heapinfo[block].busy.info.size - blocks; - _heapinfo[block].busy.info.size = blocks; - free(ADDRESS(block + blocks)); - result = ptr; - } - else if (blocks == _heapinfo[block].busy.info.size) - /* No size change necessary. */ - result = ptr; - else - { - /* Won't fit, so allocate a new region that will. - Free the old region first in case there is sufficient - adjacent free space to grow without moving. */ - blocks = _heapinfo[block].busy.info.size; - /* Prevent free from actually returning memory to the system. */ - oldlimit = _heaplimit; - _heaplimit = 0; - free(ptr); - _heaplimit = oldlimit; - result = malloc(size); - if (result == NULL) - { - (void) malloc(blocks * BLOCKSIZE); - return NULL; - } - if (ptr != result) - memmove(result, ptr, blocks * BLOCKSIZE); - } - break; - - default: - /* Old size is a fragment; type is logarithm - to base two of the fragment size. */ - if (size > 1 << (type - 1) && size <= 1 << type) - /* The new size is the same kind of fragment. */ - result = ptr; - else - { - /* The new size is different; allocate a new space, - and copy the lesser of the new size and the old. */ - result = malloc(size); - if (result == NULL) - return NULL; - memcpy(result, ptr, MIN(size, 1 << type)); - free(ptr); - } - break; - } - - return result; -} - -/* DO NOT DELETE THIS LINE -- unix.c INSERTED HERE. */ -/* unix.c - get more memory with a UNIX system call. - Copyright 1990 Free Software Foundation - Written May 1989 by Mike Haertel. - - The author may be reached (Email) at the address mike@ai.mit.edu, - or (US mail) as Mike Haertel c/o Free Software Foundation. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifndef __ONEFILE -#include "ansidecl.h" -#include - -#define _MALLOC_INTERNAL -#include "malloc.h" -#endif /* __ONEFILE */ - -extern PTR EXFUN(sbrk, (ptrdiff_t size)); - -PTR -DEFUN(__default_morecore, (size), ptrdiff_t size) -{ - PTR result; - - result = sbrk(size); - if (result == (PTR) -1) - return NULL; - return result; -} - -#define __getpagesize getpagesize -/* DO NOT DELETE THIS LINE -- valloc.c INSERTED HERE. */ -/* Allocate memory on a page boundary. - Copyright 1990 Free Software Foundation - Written May 1989 by Mike Haertel. - - The author may be reached (Email) at the address mike@ai.mit.edu, - or (US mail) as Mike Haertel c/o Free Software Foundation. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifndef __ONEFILE -#include "ansidecl.h" -#include -#endif /* __ONEFILE */ - -#if defined(M_UNIX) -/* - * M_UNIX is defined by the SCO compilers, including the port of gcc. - */ - -/* On SunOS 4.1.1, typedefs size_t, which is bad since - we typedef it above. Maybe it's better just to have people compile - -Dgetpagesize()=4096. */ -/* Deal with page size. */ -#ifndef HAVE_GETPAGESIZE - -#include - -#if !defined (PAGESIZE) -#ifdef EXEC_PAGESIZE -#define PAGESIZE EXEC_PAGESIZE -#else -#ifdef NBPG -#define PAGESIZE NBPG * CLSIZE -#ifndef CLSIZE -#define CLSIZE 1 -#endif /* no CLSIZE */ -#else /* no NBPG */ -#define PAGESIZE NBPC -#endif /* no NBPG */ -#endif /* no EXEC_PAGESIZE */ -#endif /* no PAGESIZE */ - -size_t -DEFUN_VOID(__getpagesize) -{ - return PAGESIZE; -} -#endif /* not HAVE_GETPAGESIZE */ -#endif /* M_UNIX */ - -extern size_t EXFUN(__getpagesize, (NOARGS)); - -static size_t pagesize; - -PTR -DEFUN(valloc, (size), size_t size) -{ - PTR result; - unsigned int adj; - - if (pagesize == 0) - pagesize = __getpagesize(); - - result = malloc(size + pagesize); - if (result == NULL) - return NULL; - adj = (unsigned int) ((char *) result - (char *) NULL) % pagesize; - if (adj != 0) - result = (char *) result + pagesize - adj; - return result; -} diff --git a/gdb/gmalloc.h b/gdb/gmalloc.h deleted file mode 100755 index 93fef5e1843..00000000000 --- a/gdb/gmalloc.h +++ /dev/null @@ -1,161 +0,0 @@ -/* Declarations for `malloc' and friends. - Copyright 1990 Free Software Foundation - Written May 1989 by Mike Haertel. - - The author may be reached (Email) at the address mike@ai.mit.edu, - or (US mail) as Mike Haertel c/o Free Software Foundation. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifndef _MALLOC_H - -#define _MALLOC_H 1 - -#ifndef __ONEFILE -#define __need_NULL -#define __need_size_t -#define __need_ptrdiff_t -#include -#endif - -#ifdef _MALLOC_INTERNAL - -#ifndef __ONEFILE -#include -#endif - -/* The allocator divides the heap into blocks of fixed size; large - requests receive one or more whole blocks, and small requests - receive a fragment of a block. Fragment sizes are powers of two, - and all fragments of a block are the same size. When all the - fragments in a block have been freed, the block itself is freed. */ -#define INT_BIT (CHAR_BIT * sizeof(int)) -#define BLOCKLOG (INT_BIT > 16 ? 12 : 9) -#define BLOCKSIZE (1 << BLOCKLOG) -#define BLOCKIFY(SIZE) (((SIZE) + BLOCKSIZE - 1) / BLOCKSIZE) - -/* Determine the amount of memory spanned by the initial heap table - (not an absolute limit). */ -#define HEAP (INT_BIT > 16 ? 4194304 : 65536) - -/* Number of contiguous free blocks allowed to build up at the end of - memory before they will be returned to the system. */ -#define FINAL_FREE_BLOCKS 8 - -/* Where to start searching the free list when looking for new memory. - The two possible values are 0 and _heapindex. Starting at 0 seems - to reduce total memory usage, while starting at _heapindex seems to - run faster. */ -#define MALLOC_SEARCH_START _heapindex - -/* Data structure giving per-block information. */ -typedef union - { - /* Heap information for a busy block. */ - struct - { - /* Zero for a large block, or positive giving the - logarithm to the base two of the fragment size. */ - int type; - union - { - struct - { - size_t nfree; /* Free fragments in a fragmented block. */ - size_t first; /* First free fragment of the block. */ - } frag; - /* Size (in blocks) of a large cluster. */ - size_t size; - } info; - } busy; - /* Heap information for a free block (that may be the first of - a free cluster). */ - struct - { - size_t size; /* Size (in blocks) of a free cluster. */ - size_t next; /* Index of next free cluster. */ - size_t prev; /* Index of previous free cluster. */ - } free; - } malloc_info; - -/* Pointer to first block of the heap. */ -extern char *_heapbase; - -/* Table indexed by block number giving per-block information. */ -extern malloc_info *_heapinfo; - -/* Address to block number and vice versa. */ -#define BLOCK(A) (((char *) (A) - _heapbase) / BLOCKSIZE + 1) -#define ADDRESS(B) ((PTR) (((B) - 1) * BLOCKSIZE + _heapbase)) - -/* Current search index for the heap table. */ -extern size_t _heapindex; - -/* Limit of valid info table indices. */ -extern size_t _heaplimit; - -/* Doubly linked lists of free fragments. */ -struct list - { - struct list *next; - struct list *prev; - }; - -/* Free list headers for each fragment size. */ -extern struct list _fraghead[]; - -/* Instrumentation. */ -extern size_t _chunks_used; -extern size_t _bytes_used; -extern size_t _chunks_free; -extern size_t _bytes_free; - -/* Internal version of free() used in morecore(). */ -extern void EXFUN(__free, (PTR __ptr)); - -#endif /* _MALLOC_INTERNAL. */ - -/* Underlying allocation function; successive calls should - return contiguous pieces of memory. */ -extern PTR EXFUN((*__morecore), (ptrdiff_t __size)); - -/* Default value of previous. */ -extern PTR EXFUN(__default_morecore, (ptrdiff_t __size)); - -/* Flag whether malloc has been called. */ -extern int __malloc_initialized; - -/* Hooks for debugging versions. */ -extern void EXFUN((*__free_hook), (PTR __ptr)); -extern PTR EXFUN((*__malloc_hook), (size_t __size)); -extern PTR EXFUN((*__realloc_hook), (PTR __ptr, size_t __size)); - -/* Activate a standard collection of debugging hooks. */ -extern void EXFUN(mcheck, (void EXFUN((*func), (void)))); - -/* Statistics available to the user. */ -struct mstats - { - size_t bytes_total; /* Total size of the heap. */ - size_t chunks_used; /* Chunks allocated by the user. */ - size_t bytes_used; /* Byte total of user-allocated chunks. */ - size_t chunks_free; /* Chunks in the free list. */ - size_t bytes_free; /* Byte total of chunks in the free list. */ - }; - -/* Pick up the current statistics. */ -extern struct mstats EXFUN(mstats, (NOARGS)); - -#endif /* malloc.h */ diff --git a/gdb/gould-pinsn.c b/gdb/gould-pinsn.c deleted file mode 100644 index 0ad9f3eafba..00000000000 --- a/gdb/gould-pinsn.c +++ /dev/null @@ -1,294 +0,0 @@ -/* Print GOULD RISC instructions for GDB, the GNU debugger. - Copyright (C) 1986, 1987, 1989 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "gdbcore.h" - -#include "defs.h" -#include "param.h" -#include "symtab.h" -#include "frame.h" -#if defined GOULD_PN -#include "pn-opcode.h" -#else -#include "np1-opcode.h" -#endif - -/* GOULD RISC instructions are never longer than this many bytes. */ -#define MAXLEN 4 - -/* Number of elements in the opcode table. */ -#define NOPCODES (sizeof gld_opcodes / sizeof gld_opcodes[0]) - - -/* Print the GOULD instruction at address MEMADDR in debugged memory, - on STREAM. Returns length of the instruction, in bytes. */ - -int -print_insn (memaddr, stream) - CORE_ADDR memaddr; - FILE *stream; -{ - unsigned char buffer[MAXLEN]; - register int i; - register char *d; - register int bestmask; - unsigned best; - int temp, index, bestlen; - - read_memory (memaddr, buffer, MAXLEN); - - bestmask = 0; - index = -1; - best = 0xffffffff; - for (i = 0; i < NOPCODES; i++) - { - register unsigned int opcode = gld_opcodes[i].opcode; - register unsigned int mask = gld_opcodes[i].mask; - register unsigned int len = gld_opcodes[i].length; - register unsigned int test; - - /* Get possible opcode bytes into integer */ - test = buffer[0] << 24; - test |= buffer[1] << 16; - test |= buffer[2] << 8; - test |= buffer[3]; - - /* Mask with opcode and see if match */ - if ((opcode & mask) == (test & mask)) - { - /* See if second or third match */ - if (index >= 0) - { - /* Take new one if it looks good */ - if (bestlen == MAXLEN && len == MAXLEN) - { - /* See if lower bits matched */ - if (((bestmask & 3) == 0) && - ((mask & 3) != 0)) - { - bestmask = mask; - bestlen = len; - best = test; - index = i; - } - } - } - else - { - /* First match, save it */ - bestmask = mask; - bestlen = len; - best = test; - index = i; - } - } - } - - /* Handle undefined instructions. */ - if (index < 0) - { - fprintf (stream, "undefined 0%o",(buffer[0]<<8)+buffer[1]); - return 2; - } - - /* Print instruction name */ - fprintf (stream, "%-12s", gld_opcodes[index].name); - - /* Adjust if short instruction */ - if (gld_opcodes[index].length < 4) - { - best >>= 16; - i = 0; - } - else - { - i = 16; - } - - /* Dump out instruction arguments */ - for (d = gld_opcodes[index].args; *d; ++d) - { - switch (*d) - { - case 'f': - fprintf (stream, "%d", (best >> (7 + i)) & 7); - break; - case 'r': - fprintf (stream, "r%d", (best >> (7 + i)) & 7); - break; - case 'R': - fprintf (stream, "r%d", (best >> (4 + i)) & 7); - break; - case 'b': - fprintf (stream, "b%d", (best >> (7 + i)) & 7); - break; - case 'B': - fprintf (stream, "b%d", (best >> (4 + i)) & 7); - break; - case 'v': - fprintf (stream, "b%d", (best >> (7 + i)) & 7); - break; - case 'V': - fprintf (stream, "b%d", (best >> (4 + i)) & 7); - break; - case 'X': - temp = (best >> 20) & 7; - if (temp) - fprintf (stream, "r%d", temp); - else - putc ('0', stream); - break; - case 'A': - temp = (best >> 16) & 7; - if (temp) - fprintf (stream, "(b%d)", temp); - break; - case 'S': - fprintf (stream, "#%d", best & 0x1f); - break; - case 'I': - fprintf (stream, "#%x", best & 0xffff); - break; - case 'O': - fprintf (stream, "%x", best & 0xffff); - break; - case 'h': - fprintf (stream, "%d", best & 0xfffe); - break; - case 'd': - fprintf (stream, "%d", best & 0xfffc); - break; - case 'T': - fprintf (stream, "%d", (best >> 8) & 0xff); - break; - case 'N': - fprintf (stream, "%d", best & 0xff); - break; - default: - putc (*d, stream); - break; - } - } - - /* Return length of instruction */ - return (gld_opcodes[index].length); -} - -/* - * Find the number of arguments to a function. - */ -findarg(frame) - struct frame_info *frame; -{ - register struct symbol *func; - register unsigned pc; - -#ifdef notdef - /* find starting address of frame function */ - pc = get_pc_function_start (frame->pc); - - /* find function symbol info */ - func = find_pc_function (pc); - - /* call blockframe code to look for match */ - if (func != NULL) - return (func->value.block->nsyms / sizeof(int)); -#endif - - return (-1); -} - -/* - * In the case of the NPL, the frame's norminal address is Br2 and the - * previous routines frame is up the stack X bytes. Finding out what - * 'X' is can be tricky. - * - * 1.) stored in the code function header xA(Br1). - * 2.) must be careful of recurssion. - */ -FRAME_ADDR -findframe(thisframe) - FRAME thisframe; -{ - register FRAME_ADDR pointer; - FRAME_ADDR framechain(); -#if 0 - struct frame_info *frame; - - /* Setup toplevel frame structure */ - frame->pc = read_pc(); - frame->next_frame = 0; - frame->frame = read_register (SP_REGNUM); /* Br2 */ - - /* Search for this frame (start at current Br2) */ - do - { - pointer = framechain(frame); - frame->next_frame = frame->frame; - frame->frame = pointer; - frame->pc = FRAME_SAVED_PC(frame); - } - while (frame->next_frame != thisframe); -#endif - - pointer = framechain (thisframe); - - /* stop gap for now, end at __base3 */ - if (thisframe->pc == 0) - return 0; - - return pointer; -} - -/* - * Gdb front-end and internal framechain routine. - * Go back up stack one level. Tricky... - */ -FRAME_ADDR -framechain(frame) - register struct frame_info *frame; -{ - register CORE_ADDR func, prevsp; - register unsigned value; - - /* Get real function start address from internal frame address */ - func = get_pc_function_start(frame->pc); - - /* If no stack given, read register Br1 "(sp)" */ - if (!frame->frame) - prevsp = read_register (SP_REGNUM); - else - prevsp = frame->frame; - - /* Check function header, case #2 */ - value = read_memory_integer (func, 4); - if (value) - { - /* 32bit call push value stored in function header */ - prevsp += value; - } - else - { - /* read half-word from suabr at start of function */ - prevsp += read_memory_integer (func + 10, 2); - } - - return (prevsp); -} diff --git a/gdb/gould-xdep.c b/gdb/gould-xdep.c deleted file mode 100644 index bd6276dbb50..00000000000 --- a/gdb/gould-xdep.c +++ /dev/null @@ -1,132 +0,0 @@ -/* Low level interface to ptrace, for GDB when running under Unix. - Copyright (C) 1986, 1987, 1989, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "defs.h" -#include "param.h" -#include "frame.h" -#include "inferior.h" - -#include -#include -#include -#include -#include -#include - -#include "gdbcore.h" - -#include -#include - -/* Work with core dump and executable files, for GDB. - This code would be in core.c if it weren't machine-dependent. */ - -void -core_file_command (filename, from_tty) - char *filename; - int from_tty; -{ - int val; - extern char registers[]; - - /* Discard all vestiges of any previous core file - and mark data and stack spaces as empty. */ - - if (corefile) - free (corefile); - corefile = 0; - - if (corechan >= 0) - close (corechan); - corechan = -1; - - data_start = 0; - data_end = 0; - stack_start = STACK_END_ADDR; - stack_end = STACK_END_ADDR; - - /* Now, if a new core file was specified, open it and digest it. */ - - if (filename) - { - filename = tilde_expand (filename); - make_cleanup (free, filename); - - if (have_inferior_p ()) - error ("To look at a core file, you must kill the inferior with \"kill\"."); - corechan = open (filename, O_RDONLY, 0); - if (corechan < 0) - perror_with_name (filename); - /* 4.2-style (and perhaps also sysV-style) core dump file. */ - { - struct user u; - int reg_offset; - - val = myread (corechan, &u, sizeof u); - if (val < 0) - perror_with_name (filename); - data_start = exec_data_start; - - data_end = data_start + NBPG * u.u_dsize; - stack_start = stack_end - NBPG * u.u_ssize; - data_offset = NBPG * UPAGES; - stack_offset = NBPG * (UPAGES + u.u_dsize); - reg_offset = (int) u.u_ar0 - KERNEL_U_ADDR; - - /* I don't know where to find this info. - So, for now, mark it as not available. */ - core_aouthdr.a_magic = 0; - - /* Read the register values out of the core file and store - them where `read_register' will find them. */ - - { - register int regno; - - for (regno = 0; regno < NUM_REGS; regno++) - { - char buf[MAX_REGISTER_RAW_SIZE]; - - val = lseek (corechan, register_addr (regno, reg_offset), 0); - if (val < 0) - perror_with_name (filename); - - val = myread (corechan, buf, sizeof buf); - if (val < 0) - perror_with_name (filename); - supply_register (regno, buf); - } - } - } - if (filename[0] == '/') - corefile = savestring (filename, strlen (filename)); - else - { - corefile = concat (current_directory, "/", filename, NULL); - } - - set_current_frame ( create_new_frame (read_register (FP_REGNUM), - read_pc ())); - select_frame (get_current_frame (), 0); - validate_files (); - } - else if (from_tty) - printf ("No core file now.\n"); -} diff --git a/gdb/hp300hpux-xdep.c b/gdb/hp300hpux-xdep.c deleted file mode 100755 index f7f1cf08102..00000000000 --- a/gdb/hp300hpux-xdep.c +++ /dev/null @@ -1,230 +0,0 @@ -/* HP/UX interface for HP 300's, for GDB when running under Unix. - Copyright (C) 1986, 1987, 1989, 1991 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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 1, or (at your option) -any later version. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "defs.h" -#include "param.h" -#include "frame.h" -#include "inferior.h" - -/* Defining this means some system include files define some extra stuff. */ -#define WOPR -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "gdbcore.h" - -#include -#include - -#define INFERIOR_AR0(u) \ - ((ptrace \ - (PT_RUAREA, inferior_pid, ((char *) &u.u_ar0 - (char *) &u), 0)) \ - - KERNEL_U_ADDR) - -static void -fetch_inferior_register (regno, regaddr) - register int regno; - register unsigned int regaddr; -{ -#ifndef HPUX_VERSION_5 - if (regno == PS_REGNUM) - { - union { int i; short s[2]; } ps_val; - int regval; - - ps_val.i = (ptrace (PT_RUAREA, inferior_pid, regaddr, 0)); - regval = ps_val.s[0]; - supply_register (regno, ®val); - } - else -#endif /* not HPUX_VERSION_5 */ - { - char buf[MAX_REGISTER_RAW_SIZE]; - register int i; - - for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int)) - { - *(int *) &buf[i] = ptrace (PT_RUAREA, inferior_pid, regaddr, 0); - regaddr += sizeof (int); - } - supply_register (regno, buf); - } - return; -} - -static void -store_inferior_register_1 (regno, regaddr, value) - int regno; - unsigned int regaddr; - int value; -{ - errno = 0; - ptrace (PT_WUAREA, inferior_pid, regaddr, value); -#if 0 - /* HP-UX randomly sets errno to non-zero for regno == 25. - However, the value is correctly written, so ignore errno. */ - if (errno != 0) - { - char string_buf[64]; - - sprintf (string_buf, "writing register number %d", regno); - perror_with_name (string_buf); - } -#endif - return; -} - -static void -store_inferior_register (regno, regaddr) - register int regno; - register unsigned int regaddr; -{ -#ifndef HPUX_VERSION_5 - if (regno == PS_REGNUM) - { - union { int i; short s[2]; } ps_val; - - ps_val.i = (ptrace (PT_RUAREA, inferior_pid, regaddr, 0)); - ps_val.s[0] = (read_register (regno)); - store_inferior_register_1 (regno, regaddr, ps_val.i); - } - else -#endif /* not HPUX_VERSION_5 */ - { - char buf[MAX_REGISTER_RAW_SIZE]; - register int i; - extern char registers[]; - - for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int)) - { - store_inferior_register_1 - (regno, regaddr, - (*(int *) ®isters[(REGISTER_BYTE (regno)) + i])); - regaddr += sizeof (int); - } - } - return; -} - -void -fetch_inferior_registers (regno) - int regno; -{ - struct user u; - register int regno; - register unsigned int ar0_offset; - - ar0_offset = (INFERIOR_AR0 (u)); - if (regno == -1) - { - for (regno = 0; (regno < FP0_REGNUM); regno++) - fetch_inferior_register (regno, (REGISTER_ADDR (ar0_offset, regno))); - for (; (regno < NUM_REGS); regno++) - fetch_inferior_register (regno, (FP_REGISTER_ADDR (u, regno))); - } - else - fetch_inferior_register (regno, - (regno < FP0_REGNUM - ? REGISTER_ADDR (ar0_offset, regno) - : FP_REGISTER_ADDR (u, regno))); -} - -/* Store our register values back into the inferior. - If REGNO is -1, do this for all registers. - Otherwise, REGNO specifies which register (so we can save time). */ - -store_inferior_registers (regno) - register int regno; -{ - struct user u; - register unsigned int ar0_offset; - extern char registers[]; - - if (regno >= FP0_REGNUM) - { - store_inferior_register (regno, (FP_REGISTER_ADDR (u, regno))); - return; - } - - ar0_offset = (INFERIOR_AR0 (u)); - if (regno >= 0) - { - store_inferior_register (regno, (REGISTER_ADDR (ar0_offset, regno))); - return; - } - - for (regno = 0; (regno < FP0_REGNUM); regno++) - store_inferior_register (regno, (REGISTER_ADDR (ar0_offset, regno))); - for (; (regno < NUM_REGS); regno++) - store_inferior_register (regno, (FP_REGISTER_ADDR (u, regno))); - return; -} - - -/* Take the register values out of a core file and store - them where `read_register' will find them. */ - -#ifdef HPUX_VERSION_5 -#define e_PS e_regs[PS] -#define e_PC e_regs[PC] -#endif /* HPUX_VERSION_5 */ - -void -fetch_core_registers (core_reg_sect, core_reg_size, which) - char *core_reg_sect; - int core_reg_size; - int which; -{ - int val, regno; - struct user u; - struct exception_stack *pes = (struct exception_stack *) core_reg_sect; -#define es (*pes) - char *buf; - - if (which == 0) { - if (core_reg_size < - ((char *) &es.e_offset - (char *) &es.e_regs[R0])) - error ("Not enough registers in core file"); - for (regno = 0; (regno < PS_REGNUM); regno++) - supply_register (regno, &es.e_regs[regno + R0]); - val = es.e_PS; - supply_register (regno++, &val); - supply_register (regno++, &es.e_PC); - - } else if (which == 2) { - - /* FIXME: This may not work if the float regs and control regs are - discontinuous. */ - for (regno = FP0_REGNUM, buf = core_reg_sect; - (regno < NUM_REGS); - buf += REGISTER_RAW_SIZE (regno), regno++) - { - supply_register (regno, buf); - } - } -} diff --git a/gdb/hp300ux-xdep.c b/gdb/hp300ux-xdep.c deleted file mode 100644 index 7b2c12b8724..00000000000 --- a/gdb/hp300ux-xdep.c +++ /dev/null @@ -1,230 +0,0 @@ -/* HP/UX interface for HP 300's, for GDB when running under Unix. - Copyright (C) 1986, 1987, 1989, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "defs.h" -#include "param.h" -#include "frame.h" -#include "inferior.h" - -/* Defining this means some system include files define some extra stuff. */ -#define WOPR -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "gdbcore.h" - -#include -#include - -#define INFERIOR_AR0(u) \ - ((ptrace \ - (PT_RUAREA, inferior_pid, ((char *) &u.u_ar0 - (char *) &u), 0)) \ - - KERNEL_U_ADDR) - -static void -fetch_inferior_register (regno, regaddr) - register int regno; - register unsigned int regaddr; -{ -#ifndef HPUX_VERSION_5 - if (regno == PS_REGNUM) - { - union { int i; short s[2]; } ps_val; - int regval; - - ps_val.i = (ptrace (PT_RUAREA, inferior_pid, regaddr, 0)); - regval = ps_val.s[0]; - supply_register (regno, ®val); - } - else -#endif /* not HPUX_VERSION_5 */ - { - char buf[MAX_REGISTER_RAW_SIZE]; - register int i; - - for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int)) - { - *(int *) &buf[i] = ptrace (PT_RUAREA, inferior_pid, regaddr, 0); - regaddr += sizeof (int); - } - supply_register (regno, buf); - } - return; -} - -static void -store_inferior_register_1 (regno, regaddr, value) - int regno; - unsigned int regaddr; - int value; -{ - errno = 0; - ptrace (PT_WUAREA, inferior_pid, regaddr, value); -#if 0 - /* HP-UX randomly sets errno to non-zero for regno == 25. - However, the value is correctly written, so ignore errno. */ - if (errno != 0) - { - char string_buf[64]; - - sprintf (string_buf, "writing register number %d", regno); - perror_with_name (string_buf); - } -#endif - return; -} - -static void -store_inferior_register (regno, regaddr) - register int regno; - register unsigned int regaddr; -{ -#ifndef HPUX_VERSION_5 - if (regno == PS_REGNUM) - { - union { int i; short s[2]; } ps_val; - - ps_val.i = (ptrace (PT_RUAREA, inferior_pid, regaddr, 0)); - ps_val.s[0] = (read_register (regno)); - store_inferior_register_1 (regno, regaddr, ps_val.i); - } - else -#endif /* not HPUX_VERSION_5 */ - { - char buf[MAX_REGISTER_RAW_SIZE]; - register int i; - extern char registers[]; - - for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int)) - { - store_inferior_register_1 - (regno, regaddr, - (*(int *) ®isters[(REGISTER_BYTE (regno)) + i])); - regaddr += sizeof (int); - } - } - return; -} - -void -fetch_inferior_registers (regno) - int regno; -{ - struct user u; - register int regno; - register unsigned int ar0_offset; - - ar0_offset = (INFERIOR_AR0 (u)); - if (regno == -1) - { - for (regno = 0; (regno < FP0_REGNUM); regno++) - fetch_inferior_register (regno, (REGISTER_ADDR (ar0_offset, regno))); - for (; (regno < NUM_REGS); regno++) - fetch_inferior_register (regno, (FP_REGISTER_ADDR (u, regno))); - } - else - fetch_inferior_register (regno, - (regno < FP0_REGNUM - ? REGISTER_ADDR (ar0_offset, regno) - : FP_REGISTER_ADDR (u, regno))); -} - -/* Store our register values back into the inferior. - If REGNO is -1, do this for all registers. - Otherwise, REGNO specifies which register (so we can save time). */ - -store_inferior_registers (regno) - register int regno; -{ - struct user u; - register unsigned int ar0_offset; - extern char registers[]; - - if (regno >= FP0_REGNUM) - { - store_inferior_register (regno, (FP_REGISTER_ADDR (u, regno))); - return; - } - - ar0_offset = (INFERIOR_AR0 (u)); - if (regno >= 0) - { - store_inferior_register (regno, (REGISTER_ADDR (ar0_offset, regno))); - return; - } - - for (regno = 0; (regno < FP0_REGNUM); regno++) - store_inferior_register (regno, (REGISTER_ADDR (ar0_offset, regno))); - for (; (regno < NUM_REGS); regno++) - store_inferior_register (regno, (FP_REGISTER_ADDR (u, regno))); - return; -} - - -/* Take the register values out of a core file and store - them where `read_register' will find them. */ - -#ifdef HPUX_VERSION_5 -#define e_PS e_regs[PS] -#define e_PC e_regs[PC] -#endif /* HPUX_VERSION_5 */ - -void -fetch_core_registers (core_reg_sect, core_reg_size, which) - char *core_reg_sect; - int core_reg_size; - int which; -{ - int val, regno; - struct user u; - struct exception_stack *pes = (struct exception_stack *) core_reg_sect; -#define es (*pes) - char *buf; - - if (which == 0) { - if (core_reg_size < - ((char *) &es.e_offset - (char *) &es.e_regs[R0])) - error ("Not enough registers in core file"); - for (regno = 0; (regno < PS_REGNUM); regno++) - supply_register (regno, &es.e_regs[regno + R0]); - val = es.e_PS; - supply_register (regno++, &val); - supply_register (regno++, &es.e_PC); - - } else if (which == 2) { - - /* FIXME: This may not work if the float regs and control regs are - discontinuous. */ - for (regno = FP0_REGNUM, buf = core_reg_sect; - (regno < NUM_REGS); - buf += REGISTER_RAW_SIZE (regno), regno++) - { - supply_register (regno, buf); - } - } -} diff --git a/gdb/i386-pinsn.c b/gdb/i386-pinsn.c deleted file mode 100644 index 88b171a6e7b..00000000000 --- a/gdb/i386-pinsn.c +++ /dev/null @@ -1,1831 +0,0 @@ -/* Print i386 instructions for GDB, the GNU debugger. - Copyright (C) 1988, 1989, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - * 80386 instruction printer by Pace Willisson (pace@prep.ai.mit.edu) - * July 1988 - */ - -/* - * The main tables describing the instructions is essentially a copy - * of the "Opcode Map" chapter (Appendix A) of the Intel 80386 - * Programmers Manual. Usually, there is a capital letter, followed - * by a small letter. The capital letter tell the addressing mode, - * and the small letter tells about the operand size. Refer to - * the Intel manual for details. - */ - -#include -#include - -/* For the GDB interface at the bottom of the file... */ -#include "defs.h" -#include "param.h" -#include "gdbcore.h" - -#define Eb OP_E, b_mode -#define indirEb OP_indirE, b_mode -#define Gb OP_G, b_mode -#define Ev OP_E, v_mode -#define indirEv OP_indirE, v_mode -#define Ew OP_E, w_mode -#define Ma OP_E, v_mode -#define M OP_E, 0 -#define Mp OP_E, 0 /* ? */ -#define Gv OP_G, v_mode -#define Gw OP_G, w_mode -#define Rw OP_rm, w_mode -#define Rd OP_rm, d_mode -#define Ib OP_I, b_mode -#define sIb OP_sI, b_mode /* sign extened byte */ -#define Iv OP_I, v_mode -#define Iw OP_I, w_mode -#define Jb OP_J, b_mode -#define Jv OP_J, v_mode -#define ONE OP_ONE, 0 -#define Cd OP_C, d_mode -#define Dd OP_D, d_mode -#define Td OP_T, d_mode - -#define eAX OP_REG, eAX_reg -#define eBX OP_REG, eBX_reg -#define eCX OP_REG, eCX_reg -#define eDX OP_REG, eDX_reg -#define eSP OP_REG, eSP_reg -#define eBP OP_REG, eBP_reg -#define eSI OP_REG, eSI_reg -#define eDI OP_REG, eDI_reg -#define AL OP_REG, al_reg -#define CL OP_REG, cl_reg -#define DL OP_REG, dl_reg -#define BL OP_REG, bl_reg -#define AH OP_REG, ah_reg -#define CH OP_REG, ch_reg -#define DH OP_REG, dh_reg -#define BH OP_REG, bh_reg -#define AX OP_REG, ax_reg -#define DX OP_REG, dx_reg -#define indirDX OP_REG, indir_dx_reg - -#define Sw OP_SEG, w_mode -#define Ap OP_DIR, lptr -#define Av OP_DIR, v_mode -#define Ob OP_OFF, b_mode -#define Ov OP_OFF, v_mode -#define Xb OP_DSSI, b_mode -#define Xv OP_DSSI, v_mode -#define Yb OP_ESDI, b_mode -#define Yv OP_ESDI, v_mode - -#define es OP_REG, es_reg -#define ss OP_REG, ss_reg -#define cs OP_REG, cs_reg -#define ds OP_REG, ds_reg -#define fs OP_REG, fs_reg -#define gs OP_REG, gs_reg - -int OP_E(), OP_indirE(), OP_G(), OP_I(), OP_sI(), OP_REG(); -int OP_J(), OP_SEG(); -int OP_DIR(), OP_OFF(), OP_DSSI(), OP_ESDI(), OP_ONE(), OP_C(); -int OP_D(), OP_T(), OP_rm(); - - -#define b_mode 1 -#define v_mode 2 -#define w_mode 3 -#define d_mode 4 - -#define es_reg 100 -#define cs_reg 101 -#define ss_reg 102 -#define ds_reg 103 -#define fs_reg 104 -#define gs_reg 105 -#define eAX_reg 107 -#define eCX_reg 108 -#define eDX_reg 109 -#define eBX_reg 110 -#define eSP_reg 111 -#define eBP_reg 112 -#define eSI_reg 113 -#define eDI_reg 114 - -#define lptr 115 - -#define al_reg 116 -#define cl_reg 117 -#define dl_reg 118 -#define bl_reg 119 -#define ah_reg 120 -#define ch_reg 121 -#define dh_reg 122 -#define bh_reg 123 - -#define ax_reg 124 -#define cx_reg 125 -#define dx_reg 126 -#define bx_reg 127 -#define sp_reg 128 -#define bp_reg 129 -#define si_reg 130 -#define di_reg 131 - -#define indir_dx_reg 150 - -#define GRP1b NULL, NULL, 0 -#define GRP1S NULL, NULL, 1 -#define GRP1Ss NULL, NULL, 2 -#define GRP2b NULL, NULL, 3 -#define GRP2S NULL, NULL, 4 -#define GRP2b_one NULL, NULL, 5 -#define GRP2S_one NULL, NULL, 6 -#define GRP2b_cl NULL, NULL, 7 -#define GRP2S_cl NULL, NULL, 8 -#define GRP3b NULL, NULL, 9 -#define GRP3S NULL, NULL, 10 -#define GRP4 NULL, NULL, 11 -#define GRP5 NULL, NULL, 12 -#define GRP6 NULL, NULL, 13 -#define GRP7 NULL, NULL, 14 -#define GRP8 NULL, NULL, 15 - -#define FLOATCODE 50 -#define FLOAT NULL, NULL, FLOATCODE - -struct dis386 { - char *name; - int (*op1)(); - int bytemode1; - int (*op2)(); - int bytemode2; - int (*op3)(); - int bytemode3; -}; - -struct dis386 dis386[] = { - /* 00 */ - { "addb", Eb, Gb }, - { "addS", Ev, Gv }, - { "addb", Gb, Eb }, - { "addS", Gv, Ev }, - { "addb", AL, Ib }, - { "addS", eAX, Iv }, - { "pushl", es }, - { "popl", es }, - /* 08 */ - { "orb", Eb, Gb }, - { "orS", Ev, Gv }, - { "orb", Gb, Eb }, - { "orS", Gv, Ev }, - { "orb", AL, Ib }, - { "orS", eAX, Iv }, - { "pushl", cs }, - { "(bad)" }, /* 0x0f extended opcode escape */ - /* 10 */ - { "adcb", Eb, Gb }, - { "adcS", Ev, Gv }, - { "adcb", Gb, Eb }, - { "adcS", Gv, Ev }, - { "adcb", AL, Ib }, - { "adcS", eAX, Iv }, - { "pushl", ss }, - { "popl", ss }, - /* 18 */ - { "sbbb", Eb, Gb }, - { "sbbS", Ev, Gv }, - { "sbbb", Gb, Eb }, - { "sbbS", Gv, Ev }, - { "sbbb", AL, Ib }, - { "sbbS", eAX, Iv }, - { "pushl", ds }, - { "popl", ds }, - /* 20 */ - { "andb", Eb, Gb }, - { "andS", Ev, Gv }, - { "andb", Gb, Eb }, - { "andS", Gv, Ev }, - { "andb", AL, Ib }, - { "andS", eAX, Iv }, - { "(bad)" }, /* SEG ES prefix */ - { "daa" }, - /* 28 */ - { "subb", Eb, Gb }, - { "subS", Ev, Gv }, - { "subb", Gb, Eb }, - { "subS", Gv, Ev }, - { "subb", AL, Ib }, - { "subS", eAX, Iv }, - { "(bad)" }, /* SEG CS prefix */ - { "das" }, - /* 30 */ - { "xorb", Eb, Gb }, - { "xorS", Ev, Gv }, - { "xorb", Gb, Eb }, - { "xorS", Gv, Ev }, - { "xorb", AL, Ib }, - { "xorS", eAX, Iv }, - { "(bad)" }, /* SEG SS prefix */ - { "aaa" }, - /* 38 */ - { "cmpb", Eb, Gb }, - { "cmpS", Ev, Gv }, - { "cmpb", Gb, Eb }, - { "cmpS", Gv, Ev }, - { "cmpb", AL, Ib }, - { "cmpS", eAX, Iv }, - { "(bad)" }, /* SEG DS prefix */ - { "aas" }, - /* 40 */ - { "incS", eAX }, - { "incS", eCX }, - { "incS", eDX }, - { "incS", eBX }, - { "incS", eSP }, - { "incS", eBP }, - { "incS", eSI }, - { "incS", eDI }, - /* 48 */ - { "decS", eAX }, - { "decS", eCX }, - { "decS", eDX }, - { "decS", eBX }, - { "decS", eSP }, - { "decS", eBP }, - { "decS", eSI }, - { "decS", eDI }, - /* 50 */ - { "pushS", eAX }, - { "pushS", eCX }, - { "pushS", eDX }, - { "pushS", eBX }, - { "pushS", eSP }, - { "pushS", eBP }, - { "pushS", eSI }, - { "pushS", eDI }, - /* 58 */ - { "popS", eAX }, - { "popS", eCX }, - { "popS", eDX }, - { "popS", eBX }, - { "popS", eSP }, - { "popS", eBP }, - { "popS", eSI }, - { "popS", eDI }, - /* 60 */ - { "pusha" }, - { "popa" }, - { "boundS", Gv, Ma }, - { "arpl", Ew, Gw }, - { "(bad)" }, /* seg fs */ - { "(bad)" }, /* seg gs */ - { "(bad)" }, /* op size prefix */ - { "(bad)" }, /* adr size prefix */ - /* 68 */ - { "pushS", Iv }, /* 386 book wrong */ - { "imulS", Gv, Ev, Iv }, - { "pushl", sIb }, /* push of byte really pushes 4 bytes */ - { "imulS", Gv, Ev, Ib }, - { "insb", Yb, indirDX }, - { "insS", Yv, indirDX }, - { "outsb", indirDX, Xb }, - { "outsS", indirDX, Xv }, - /* 70 */ - { "jo", Jb }, - { "jno", Jb }, - { "jb", Jb }, - { "jae", Jb }, - { "je", Jb }, - { "jne", Jb }, - { "jbe", Jb }, - { "ja", Jb }, - /* 78 */ - { "js", Jb }, - { "jns", Jb }, - { "jp", Jb }, - { "jnp", Jb }, - { "jl", Jb }, - { "jnl", Jb }, - { "jle", Jb }, - { "jg", Jb }, - /* 80 */ - { GRP1b }, - { GRP1S }, - { "(bad)" }, - { GRP1Ss }, - { "testb", Eb, Gb }, - { "testS", Ev, Gv }, - { "xchgb", Eb, Gb }, - { "xchgS", Ev, Gv }, - /* 88 */ - { "movb", Eb, Gb }, - { "movS", Ev, Gv }, - { "movb", Gb, Eb }, - { "movS", Gv, Ev }, - { "movw", Ew, Sw }, - { "leaS", Gv, M }, - { "movw", Sw, Ew }, - { "popS", Ev }, - /* 90 */ - { "nop" }, - { "xchgS", eCX, eAX }, - { "xchgS", eDX, eAX }, - { "xchgS", eBX, eAX }, - { "xchgS", eSP, eAX }, - { "xchgS", eBP, eAX }, - { "xchgS", eSI, eAX }, - { "xchgS", eDI, eAX }, - /* 98 */ - { "cwtl" }, - { "cltd" }, - { "lcall", Ap }, - { "(bad)" }, /* fwait */ - { "pushf" }, - { "popf" }, - { "sahf" }, - { "lahf" }, - /* a0 */ - { "movb", AL, Ob }, - { "movS", eAX, Ov }, - { "movb", Ob, AL }, - { "movS", Ov, eAX }, - { "movsb", Yb, Xb }, - { "movsS", Yv, Xv }, - { "cmpsb", Yb, Xb }, - { "cmpsS", Yv, Xv }, - /* a8 */ - { "testb", AL, Ib }, - { "testS", eAX, Iv }, - { "stosb", Yb, AL }, - { "stosS", Yv, eAX }, - { "lodsb", AL, Xb }, - { "lodsS", eAX, Xv }, - { "scasb", AL, Xb }, - { "scasS", eAX, Xv }, - /* b0 */ - { "movb", AL, Ib }, - { "movb", CL, Ib }, - { "movb", DL, Ib }, - { "movb", BL, Ib }, - { "movb", AH, Ib }, - { "movb", CH, Ib }, - { "movb", DH, Ib }, - { "movb", BH, Ib }, - /* b8 */ - { "movS", eAX, Iv }, - { "movS", eCX, Iv }, - { "movS", eDX, Iv }, - { "movS", eBX, Iv }, - { "movS", eSP, Iv }, - { "movS", eBP, Iv }, - { "movS", eSI, Iv }, - { "movS", eDI, Iv }, - /* c0 */ - { GRP2b }, - { GRP2S }, - { "ret", Iw }, - { "ret" }, - { "lesS", Gv, Mp }, - { "ldsS", Gv, Mp }, - { "movb", Eb, Ib }, - { "movS", Ev, Iv }, - /* c8 */ - { "enter", Iw, Ib }, - { "leave" }, - { "lret", Iw }, - { "lret" }, - { "int3" }, - { "int", Ib }, - { "into" }, - { "iret" }, - /* d0 */ - { GRP2b_one }, - { GRP2S_one }, - { GRP2b_cl }, - { GRP2S_cl }, - { "aam", Ib }, - { "aad", Ib }, - { "(bad)" }, - { "xlat" }, - /* d8 */ - { FLOAT }, - { FLOAT }, - { FLOAT }, - { FLOAT }, - { FLOAT }, - { FLOAT }, - { FLOAT }, - { FLOAT }, - /* e0 */ - { "loopne", Jb }, - { "loope", Jb }, - { "loop", Jb }, - { "jCcxz", Jb }, - { "inb", AL, Ib }, - { "inS", eAX, Ib }, - { "outb", Ib, AL }, - { "outS", Ib, eAX }, - /* e8 */ - { "call", Av }, - { "jmp", Jv }, - { "ljmp", Ap }, - { "jmp", Jb }, - { "inb", AL, indirDX }, - { "inS", eAX, indirDX }, - { "outb", indirDX, AL }, - { "outS", indirDX, eAX }, - /* f0 */ - { "(bad)" }, /* lock prefix */ - { "(bad)" }, - { "(bad)" }, /* repne */ - { "(bad)" }, /* repz */ - { "hlt" }, - { "cmc" }, - { GRP3b }, - { GRP3S }, - /* f8 */ - { "clc" }, - { "stc" }, - { "cli" }, - { "sti" }, - { "cld" }, - { "std" }, - { GRP4 }, - { GRP5 }, -}; - -struct dis386 dis386_twobyte[] = { - /* 00 */ - { GRP6 }, - { GRP7 }, - { "larS", Gv, Ew }, - { "lslS", Gv, Ew }, - { "(bad)" }, - { "(bad)" }, - { "clts" }, - { "(bad)" }, - /* 08 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 10 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 18 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 20 */ - /* these are all backward in appendix A of the intel book */ - { "movl", Rd, Cd }, - { "movl", Rd, Dd }, - { "movl", Cd, Rd }, - { "movl", Dd, Rd }, - { "movl", Rd, Td }, - { "(bad)" }, - { "movl", Td, Rd }, - { "(bad)" }, - /* 28 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 30 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 38 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 40 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 48 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 50 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 58 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 60 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 68 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 70 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 78 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* 80 */ - { "jo", Jv }, - { "jno", Jv }, - { "jb", Jv }, - { "jae", Jv }, - { "je", Jv }, - { "jne", Jv }, - { "jbe", Jv }, - { "ja", Jv }, - /* 88 */ - { "js", Jv }, - { "jns", Jv }, - { "jp", Jv }, - { "jnp", Jv }, - { "jl", Jv }, - { "jge", Jv }, - { "jle", Jv }, - { "jg", Jv }, - /* 90 */ - { "seto", Eb }, - { "setno", Eb }, - { "setb", Eb }, - { "setae", Eb }, - { "sete", Eb }, - { "setne", Eb }, - { "setbe", Eb }, - { "seta", Eb }, - /* 98 */ - { "sets", Eb }, - { "setns", Eb }, - { "setp", Eb }, - { "setnp", Eb }, - { "setl", Eb }, - { "setge", Eb }, - { "setle", Eb }, - { "setg", Eb }, - /* a0 */ - { "pushl", fs }, - { "popl", fs }, - { "(bad)" }, - { "btS", Ev, Gv }, - { "shldS", Ev, Gv, Ib }, - { "shldS", Ev, Gv, CL }, - { "(bad)" }, - { "(bad)" }, - /* a8 */ - { "pushl", gs }, - { "popl", gs }, - { "(bad)" }, - { "btsS", Ev, Gv }, - { "shrdS", Ev, Gv, Ib }, - { "shrdS", Ev, Gv, CL }, - { "(bad)" }, - { "imulS", Gv, Ev }, - /* b0 */ - { "(bad)" }, - { "(bad)" }, - { "lssS", Gv, Mp }, /* 386 lists only Mp */ - { "btrS", Ev, Gv }, - { "lfsS", Gv, Mp }, /* 386 lists only Mp */ - { "lgsS", Gv, Mp }, /* 386 lists only Mp */ - { "movzbS", Gv, Eb }, - { "movzwS", Gv, Ew }, - /* b8 */ - { "(bad)" }, - { "(bad)" }, - { GRP8 }, - { "btcS", Ev, Gv }, - { "bsfS", Gv, Ev }, - { "bsrS", Gv, Ev }, - { "movsbS", Gv, Eb }, - { "movswS", Gv, Ew }, - /* c0 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* c8 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* d0 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* d8 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* e0 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* e8 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* f0 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - /* f8 */ - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, - { "(bad)" }, { "(bad)" }, { "(bad)" }, { "(bad)" }, -}; - -static char obuf[100]; -static char *obufp; -static char scratchbuf[100]; -static unsigned char *start_codep; -static unsigned char *codep; -static int mod; -static int rm; -static int reg; -static void oappend (); - -static char *names32[]={ - "%eax","%ecx","%edx","%ebx", "%esp","%ebp","%esi","%edi", -}; -static char *names16[] = { - "%ax","%cx","%dx","%bx","%sp","%bp","%si","%di", -}; -static char *names8[] = { - "%al","%cl","%dl","%bl","%ah","%ch","%dh","%bh", -}; -static char *names_seg[] = { - "%es","%cs","%ss","%ds","%fs","%gs","%?","%?", -}; - -struct dis386 grps[][8] = { - /* GRP1b */ - { - { "addb", Eb, Ib }, - { "orb", Eb, Ib }, - { "adcb", Eb, Ib }, - { "sbbb", Eb, Ib }, - { "andb", Eb, Ib }, - { "subb", Eb, Ib }, - { "xorb", Eb, Ib }, - { "cmpb", Eb, Ib } - }, - /* GRP1S */ - { - { "addS", Ev, Iv }, - { "orS", Ev, Iv }, - { "adcS", Ev, Iv }, - { "sbbS", Ev, Iv }, - { "andS", Ev, Iv }, - { "subS", Ev, Iv }, - { "xorS", Ev, Iv }, - { "cmpS", Ev, Iv } - }, - /* GRP1Ss */ - { - { "addS", Ev, sIb }, - { "orS", Ev, sIb }, - { "adcS", Ev, sIb }, - { "sbbS", Ev, sIb }, - { "andS", Ev, sIb }, - { "subS", Ev, sIb }, - { "xorS", Ev, sIb }, - { "cmpS", Ev, sIb } - }, - /* GRP2b */ - { - { "rolb", Eb, Ib }, - { "rorb", Eb, Ib }, - { "rclb", Eb, Ib }, - { "rcrb", Eb, Ib }, - { "shlb", Eb, Ib }, - { "shrb", Eb, Ib }, - { "(bad)" }, - { "sarb", Eb, Ib }, - }, - /* GRP2S */ - { - { "rolS", Ev, Ib }, - { "rorS", Ev, Ib }, - { "rclS", Ev, Ib }, - { "rcrS", Ev, Ib }, - { "shlS", Ev, Ib }, - { "shrS", Ev, Ib }, - { "(bad)" }, - { "sarS", Ev, Ib }, - }, - /* GRP2b_one */ - { - { "rolb", Eb }, - { "rorb", Eb }, - { "rclb", Eb }, - { "rcrb", Eb }, - { "shlb", Eb }, - { "shrb", Eb }, - { "(bad)" }, - { "sarb", Eb }, - }, - /* GRP2S_one */ - { - { "rolS", Ev }, - { "rorS", Ev }, - { "rclS", Ev }, - { "rcrS", Ev }, - { "shlS", Ev }, - { "shrS", Ev }, - { "(bad)" }, - { "sarS", Ev }, - }, - /* GRP2b_cl */ - { - { "rolb", Eb, CL }, - { "rorb", Eb, CL }, - { "rclb", Eb, CL }, - { "rcrb", Eb, CL }, - { "shlb", Eb, CL }, - { "shrb", Eb, CL }, - { "(bad)" }, - { "sarb", Eb, CL }, - }, - /* GRP2S_cl */ - { - { "rolS", Ev, CL }, - { "rorS", Ev, CL }, - { "rclS", Ev, CL }, - { "rcrS", Ev, CL }, - { "shlS", Ev, CL }, - { "shrS", Ev, CL }, - { "(bad)" }, - { "sarS", Ev, CL } - }, - /* GRP3b */ - { - { "testb", Eb, Ib }, - { "(bad)", Eb }, - { "notb", Eb }, - { "negb", Eb }, - { "mulb", AL, Eb }, - { "imulb", AL, Eb }, - { "divb", AL, Eb }, - { "idivb", AL, Eb } - }, - /* GRP3S */ - { - { "testS", Ev, Iv }, - { "(bad)" }, - { "notS", Ev }, - { "negS", Ev }, - { "mulS", eAX, Ev }, - { "imulS", eAX, Ev }, - { "divS", eAX, Ev }, - { "idivS", eAX, Ev }, - }, - /* GRP4 */ - { - { "incb", Eb }, - { "decb", Eb }, - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - }, - /* GRP5 */ - { - { "incS", Ev }, - { "decS", Ev }, - { "call", indirEv }, - { "lcall", indirEv }, - { "jmp", indirEv }, - { "ljmp", indirEv }, - { "pushS", Ev }, - { "(bad)" }, - }, - /* GRP6 */ - { - { "sldt", Ew }, - { "str", Ew }, - { "lldt", Ew }, - { "ltr", Ew }, - { "verr", Ew }, - { "verw", Ew }, - { "(bad)" }, - { "(bad)" } - }, - /* GRP7 */ - { - { "sgdt", Ew }, - { "sidt", Ew }, - { "lgdt", Ew }, - { "lidt", Ew }, - { "smsw", Ew }, - { "(bad)" }, - { "lmsw", Ew }, - { "(bad)" }, - }, - /* GRP8 */ - { - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - { "btS", Ev, Ib }, - { "btsS", Ev, Ib }, - { "btrS", Ev, Ib }, - { "btcS", Ev, Ib }, - } -}; - -#define PREFIX_REPZ 1 -#define PREFIX_REPNZ 2 -#define PREFIX_LOCK 4 -#define PREFIX_CS 8 -#define PREFIX_SS 0x10 -#define PREFIX_DS 0x20 -#define PREFIX_ES 0x40 -#define PREFIX_FS 0x80 -#define PREFIX_GS 0x100 -#define PREFIX_DATA 0x200 -#define PREFIX_ADR 0x400 -#define PREFIX_FWAIT 0x800 - -static int prefixes; - -ckprefix () -{ - prefixes = 0; - while (1) - { - switch (*codep) - { - case 0xf3: - prefixes |= PREFIX_REPZ; - break; - case 0xf2: - prefixes |= PREFIX_REPNZ; - break; - case 0xf0: - prefixes |= PREFIX_LOCK; - break; - case 0x2e: - prefixes |= PREFIX_CS; - break; - case 0x36: - prefixes |= PREFIX_SS; - break; - case 0x3e: - prefixes |= PREFIX_DS; - break; - case 0x26: - prefixes |= PREFIX_ES; - break; - case 0x64: - prefixes |= PREFIX_FS; - break; - case 0x65: - prefixes |= PREFIX_GS; - break; - case 0x66: - prefixes |= PREFIX_DATA; - break; - case 0x67: - prefixes |= PREFIX_ADR; - break; - case 0x9b: - prefixes |= PREFIX_FWAIT; - break; - default: - return; - } - codep++; - } -} - -static int dflag; -static int aflag; - -static char op1out[100], op2out[100], op3out[100]; -static int op_address[3], op_ad, op_index[3]; -static int start_pc; -extern void fputs_filtered (); - -/* - * disassemble the first instruction in 'inbuf'. You have to make - * sure all of the bytes of the instruction are filled in. - * On the 386's of 1988, the maximum length of an instruction is 15 bytes. - * (see topic "Redundant prefixes" in the "Differences from 8086" - * section of the "Virtual 8086 Mode" chapter.) - * 'pc' should be the address of this instruction, it will - * be used to print the target address if this is a relative jump or call - * 'outbuf' gets filled in with the disassembled instruction. it should - * be long enough to hold the longest disassembled instruction. - * 100 bytes is certainly enough, unless symbol printing is added later - * The function returns the length of this instruction in bytes. - */ -i386dis (pc, inbuf, stream) - int pc; - unsigned char *inbuf; - FILE *stream; -{ - struct dis386 *dp; - char *p; - int i; - int enter_instruction; - char *first, *second, *third; - int needcomma; - - obuf[0] = 0; - op1out[0] = 0; - op2out[0] = 0; - op3out[0] = 0; - - op_index[0] = op_index[1] = op_index[2] = -1; - - start_pc = pc; - start_codep = inbuf; - codep = inbuf; - - ckprefix (); - - if (*codep == 0xc8) - enter_instruction = 1; - else - enter_instruction = 0; - - obufp = obuf; - - if (prefixes & PREFIX_REPZ) - oappend ("repz "); - if (prefixes & PREFIX_REPNZ) - oappend ("repnz "); - if (prefixes & PREFIX_LOCK) - oappend ("lock "); - - if ((prefixes & PREFIX_FWAIT) - && ((*codep < 0xd8) || (*codep > 0xdf))) - { - /* fwait not followed by floating point instruction */ - fputs_filtered ("fwait", stream); - return (1); - } - - /* these would be initialized to 0 if disassembling for 8086 or 286 */ - dflag = 1; - aflag = 1; - - if (prefixes & PREFIX_DATA) - dflag ^= 1; - - if (prefixes & PREFIX_ADR) - { - aflag ^= 1; - oappend ("addr16 "); - } - - if (*codep == 0x0f) - dp = &dis386_twobyte[*++codep]; - else - dp = &dis386[*codep]; - codep++; - mod = (*codep >> 6) & 3; - reg = (*codep >> 3) & 7; - rm = *codep & 7; - - if (dp->name == NULL && dp->bytemode1 == FLOATCODE) - { - dofloat (); - } - else - { - if (dp->name == NULL) - dp = &grps[dp->bytemode1][reg]; - - putop (dp->name); - - obufp = op1out; - op_ad = 2; - if (dp->op1) - (*dp->op1)(dp->bytemode1); - - obufp = op2out; - op_ad = 1; - if (dp->op2) - (*dp->op2)(dp->bytemode2); - - obufp = op3out; - op_ad = 0; - if (dp->op3) - (*dp->op3)(dp->bytemode3); - } - - obufp = obuf + strlen (obuf); - for (i = strlen (obuf); i < 6; i++) - oappend (" "); - oappend (" "); - fputs_filtered (obuf, stream); - - /* enter instruction is printed with operands in the - * same order as the intel book; everything else - * is printed in reverse order - */ - if (enter_instruction) - { - first = op1out; - second = op2out; - third = op3out; - op_ad = op_index[0]; - op_index[0] = op_index[2]; - op_index[2] = op_ad; - } - else - { - first = op3out; - second = op2out; - third = op1out; - } - needcomma = 0; - if (*first) - { - if (op_index[0] != -1) - print_address (op_address[op_index[0]], stream); - else - fputs_filtered (first, stream); - needcomma = 1; - } - if (*second) - { - if (needcomma) - fputs_filtered (",", stream); - if (op_index[1] != -1) - print_address (op_address[op_index[1]], stream); - else - fputs_filtered (second, stream); - needcomma = 1; - } - if (*third) - { - if (needcomma) - fputs_filtered (",", stream); - if (op_index[2] != -1) - print_address (op_address[op_index[2]], stream); - else - fputs_filtered (third, stream); - } - return (codep - inbuf); -} - -char *float_mem[] = { - /* d8 */ - "fadds", - "fmuls", - "fcoms", - "fcomps", - "fsubs", - "fsubrs", - "fdivs", - "fdivrs", - /* d9 */ - "flds", - "(bad)", - "fsts", - "fstps", - "fldenv", - "fldcw", - "fNstenv", - "fNstcw", - /* da */ - "fiaddl", - "fimull", - "ficoml", - "ficompl", - "fisubl", - "fisubrl", - "fidivl", - "fidivrl", - /* db */ - "fildl", - "(bad)", - "fistl", - "fistpl", - "(bad)", - "fldt", - "(bad)", - "fstpt", - /* dc */ - "faddl", - "fmull", - "fcoml", - "fcompl", - "fsubl", - "fsubrl", - "fdivl", - "fdivrl", - /* dd */ - "fldl", - "(bad)", - "fstl", - "fstpl", - "frstor", - "(bad)", - "fNsave", - "fNstsw", - /* de */ - "fiadd", - "fimul", - "ficom", - "ficomp", - "fisub", - "fisubr", - "fidiv", - "fidivr", - /* df */ - "fild", - "(bad)", - "fist", - "fistp", - "fbld", - "fildll", - "fbstp", - "fistpll", -}; - -#define ST OP_ST, 0 -#define STi OP_STi, 0 -int OP_ST(), OP_STi(); - -#define FGRPd9_2 NULL, NULL, 0 -#define FGRPd9_4 NULL, NULL, 1 -#define FGRPd9_5 NULL, NULL, 2 -#define FGRPd9_6 NULL, NULL, 3 -#define FGRPd9_7 NULL, NULL, 4 -#define FGRPda_5 NULL, NULL, 5 -#define FGRPdb_4 NULL, NULL, 6 -#define FGRPde_3 NULL, NULL, 7 -#define FGRPdf_4 NULL, NULL, 8 - -struct dis386 float_reg[][8] = { - /* d8 */ - { - { "fadd", ST, STi }, - { "fmul", ST, STi }, - { "fcom", STi }, - { "fcomp", STi }, - { "fsub", ST, STi }, - { "fsubr", ST, STi }, - { "fdiv", ST, STi }, - { "fdivr", ST, STi }, - }, - /* d9 */ - { - { "fld", STi }, - { "fxch", STi }, - { FGRPd9_2 }, - { "(bad)" }, - { FGRPd9_4 }, - { FGRPd9_5 }, - { FGRPd9_6 }, - { FGRPd9_7 }, - }, - /* da */ - { - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - { FGRPda_5 }, - { "(bad)" }, - { "(bad)" }, - }, - /* db */ - { - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - { FGRPdb_4 }, - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - }, - /* dc */ - { - { "fadd", STi, ST }, - { "fmul", STi, ST }, - { "(bad)" }, - { "(bad)" }, - { "fsub", STi, ST }, - { "fsubr", STi, ST }, - { "fdiv", STi, ST }, - { "fdivr", STi, ST }, - }, - /* dd */ - { - { "ffree", STi }, - { "(bad)" }, - { "fst", STi }, - { "fstp", STi }, - { "fucom", STi }, - { "fucomp", STi }, - { "(bad)" }, - { "(bad)" }, - }, - /* de */ - { - { "faddp", STi, ST }, - { "fmulp", STi, ST }, - { "(bad)" }, - { FGRPde_3 }, - { "fsubp", STi, ST }, - { "fsubrp", STi, ST }, - { "fdivp", STi, ST }, - { "fdivrp", STi, ST }, - }, - /* df */ - { - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - { FGRPdf_4 }, - { "(bad)" }, - { "(bad)" }, - { "(bad)" }, - }, -}; - - -char *fgrps[][8] = { - /* d9_2 0 */ - { - "fnop","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)", - }, - - /* d9_4 1 */ - { - "fchs","fabs","(bad)","(bad)","ftst","fxam","(bad)","(bad)", - }, - - /* d9_5 2 */ - { - "fld1","fldl2t","fldl2e","fldpi","fldlg2","fldln2","fldz","(bad)", - }, - - /* d9_6 3 */ - { - "f2xm1","fyl2x","fptan","fpatan","fxtract","fprem1","fdecstp","fincstp", - }, - - /* d9_7 4 */ - { - "fprem","fyl2xp1","fsqrt","fsincos","frndint","fscale","fsin","fcos", - }, - - /* da_5 5 */ - { - "(bad)","fucompp","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)", - }, - - /* db_4 6 */ - { - "feni(287 only)","fdisi(287 only)","fNclex","fNinit", - "fNsetpm(287 only)","(bad)","(bad)","(bad)", - }, - - /* de_3 7 */ - { - "(bad)","fcompp","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)", - }, - - /* df_4 8 */ - { - "fNstsw","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)","(bad)", - }, -}; - - -dofloat () -{ - struct dis386 *dp; - unsigned char floatop; - - floatop = codep[-1]; - - if (mod != 3) - { - putop (float_mem[(floatop - 0xd8) * 8 + reg]); - obufp = op1out; - OP_E (v_mode); - return; - } - codep++; - - dp = &float_reg[floatop - 0xd8][reg]; - if (dp->name == NULL) - { - putop (fgrps[dp->bytemode1][rm]); - /* instruction fnstsw is only one with strange arg */ - if (floatop == 0xdf && *codep == 0xe0) - strcpy (op1out, "%eax"); - } - else - { - putop (dp->name); - obufp = op1out; - if (dp->op1) - (*dp->op1)(dp->bytemode1); - obufp = op2out; - if (dp->op2) - (*dp->op2)(dp->bytemode2); - } -} - -/* ARGSUSED */ -OP_ST (ignore) -{ - oappend ("%st"); -} - -/* ARGSUSED */ -OP_STi (ignore) -{ - sprintf (scratchbuf, "%%st(%d)", rm); - oappend (scratchbuf); -} - - -/* capital letters in template are macros */ -putop (template) - char *template; -{ - char *p; - - for (p = template; *p; p++) - { - switch (*p) - { - default: - *obufp++ = *p; - break; - case 'C': /* For jcxz/jecxz */ - if (aflag == 0) - *obufp++ = 'e'; - break; - case 'N': - if ((prefixes & PREFIX_FWAIT) == 0) - *obufp++ = 'n'; - break; - case 'S': - /* operand size flag */ - if (dflag) - *obufp++ = 'l'; - else - *obufp++ = 'w'; - break; - } - } - *obufp = 0; -} - -static void -oappend (s) -char *s; -{ - strcpy (obufp, s); - obufp += strlen (s); - *obufp = 0; -} - -append_prefix () -{ - if (prefixes & PREFIX_CS) - oappend ("%cs:"); - if (prefixes & PREFIX_DS) - oappend ("%ds:"); - if (prefixes & PREFIX_SS) - oappend ("%ss:"); - if (prefixes & PREFIX_ES) - oappend ("%es:"); - if (prefixes & PREFIX_FS) - oappend ("%fs:"); - if (prefixes & PREFIX_GS) - oappend ("%gs:"); -} - -OP_indirE (bytemode) -{ - oappend ("*"); - OP_E (bytemode); -} - -OP_E (bytemode) -{ - int disp; - int havesib; - int didoutput = 0; - int base; - int index; - int scale; - int havebase; - - /* skip mod/rm byte */ - codep++; - - havesib = 0; - havebase = 0; - disp = 0; - - if (mod == 3) - { - switch (bytemode) - { - case b_mode: - oappend (names8[rm]); - break; - case w_mode: - oappend (names16[rm]); - break; - case v_mode: - if (dflag) - oappend (names32[rm]); - else - oappend (names16[rm]); - break; - default: - oappend (""); - break; - } - return; - } - - append_prefix (); - if (rm == 4) - { - havesib = 1; - havebase = 1; - scale = (*codep >> 6) & 3; - index = (*codep >> 3) & 7; - base = *codep & 7; - codep++; - } - - switch (mod) - { - case 0: - switch (rm) - { - case 4: - /* implies havesib and havebase */ - if (base == 5) { - havebase = 0; - disp = get32 (); - } - break; - case 5: - disp = get32 (); - break; - default: - havebase = 1; - base = rm; - break; - } - break; - case 1: - disp = *(char *)codep++; - if (rm != 4) - { - havebase = 1; - base = rm; - } - break; - case 2: - disp = get32 (); - if (rm != 4) - { - havebase = 1; - base = rm; - } - break; - } - - if (mod != 0 || rm == 5 || (havesib && base == 5)) - { - sprintf (scratchbuf, "0x%x", disp); - oappend (scratchbuf); - } - - if (havebase || havesib) - { - oappend ("("); - if (havebase) - oappend (names32[base]); - if (havesib) - { - if (index != 4) - { - sprintf (scratchbuf, ",%s", names32[index]); - oappend (scratchbuf); - } - sprintf (scratchbuf, ",%d", 1 << scale); - oappend (scratchbuf); - } - oappend (")"); - } -} - -OP_G (bytemode) -{ - switch (bytemode) - { - case b_mode: - oappend (names8[reg]); - break; - case w_mode: - oappend (names16[reg]); - break; - case d_mode: - oappend (names32[reg]); - break; - case v_mode: - if (dflag) - oappend (names32[reg]); - else - oappend (names16[reg]); - break; - default: - oappend (""); - break; - } -} - -get32 () -{ - int x = 0; - - x = *codep++ & 0xff; - x |= (*codep++ & 0xff) << 8; - x |= (*codep++ & 0xff) << 16; - x |= (*codep++ & 0xff) << 24; - return (x); -} - -get16 () -{ - int x = 0; - - x = *codep++ & 0xff; - x |= (*codep++ & 0xff) << 8; - return (x); -} - -set_op (op) -int op; -{ - op_index[op_ad] = op_ad; - op_address[op_ad] = op; -} - -OP_REG (code) -{ - char *s; - - switch (code) - { - case indir_dx_reg: s = "(%dx)"; break; - case ax_reg: case cx_reg: case dx_reg: case bx_reg: - case sp_reg: case bp_reg: case si_reg: case di_reg: - s = names16[code - ax_reg]; - break; - case es_reg: case ss_reg: case cs_reg: - case ds_reg: case fs_reg: case gs_reg: - s = names_seg[code - es_reg]; - break; - case al_reg: case ah_reg: case cl_reg: case ch_reg: - case dl_reg: case dh_reg: case bl_reg: case bh_reg: - s = names8[code - al_reg]; - break; - case eAX_reg: case eCX_reg: case eDX_reg: case eBX_reg: - case eSP_reg: case eBP_reg: case eSI_reg: case eDI_reg: - if (dflag) - s = names32[code - eAX_reg]; - else - s = names16[code - eAX_reg]; - break; - default: - s = ""; - break; - } - oappend (s); -} - -OP_I (bytemode) -{ - int op; - - switch (bytemode) - { - case b_mode: - op = *codep++ & 0xff; - break; - case v_mode: - if (dflag) - op = get32 (); - else - op = get16 (); - break; - case w_mode: - op = get16 (); - break; - default: - oappend (""); - return; - } - sprintf (scratchbuf, "$0x%x", op); - oappend (scratchbuf); -} - -OP_sI (bytemode) -{ - int op; - - switch (bytemode) - { - case b_mode: - op = *(char *)codep++; - break; - case v_mode: - if (dflag) - op = get32 (); - else - op = (short)get16(); - break; - case w_mode: - op = (short)get16 (); - break; - default: - oappend (""); - return; - } - sprintf (scratchbuf, "$0x%x", op); - oappend (scratchbuf); -} - -OP_J (bytemode) -{ - int disp; - int mask = -1; - - switch (bytemode) - { - case b_mode: - disp = *(char *)codep++; - break; - case v_mode: - if (dflag) - disp = get32 (); - else - { - disp = (short)get16 (); - /* for some reason, a data16 prefix on a jump instruction - means that the pc is masked to 16 bits after the - displacement is added! */ - mask = 0xffff; - } - break; - default: - oappend (""); - return; - } - disp = (start_pc + codep - start_codep + disp) & mask; - set_op (disp); - sprintf (scratchbuf, "0x%x", disp); - oappend (scratchbuf); -} - -/* ARGSUSED */ -OP_SEG (dummy) -{ - static char *sreg[] = { - "%es","%cs","%ss","%ds","%fs","%gs","%?","%?", - }; - - oappend (sreg[reg]); -} - -OP_DIR (size) -{ - int seg, offset; - - switch (size) - { - case lptr: - if (aflag) - { - offset = get32 (); - seg = get16 (); - } - else - { - offset = get16 (); - seg = get16 (); - } - sprintf (scratchbuf, "0x%x,0x%x", seg, offset); - oappend (scratchbuf); - break; - case v_mode: - if (aflag) - offset = get32 (); - else - offset = (short)get16 (); - - offset = start_pc + codep - start_codep + offset; - set_op (offset); - sprintf (scratchbuf, "0x%x", offset); - oappend (scratchbuf); - break; - default: - oappend (""); - break; - } -} - -/* ARGSUSED */ -OP_OFF (bytemode) -{ - int off; - - if (aflag) - off = get32 (); - else - off = get16 (); - - sprintf (scratchbuf, "0x%x", off); - oappend (scratchbuf); -} - -/* ARGSUSED */ -OP_ESDI (dummy) -{ - oappend ("%es:("); - oappend (aflag ? "%edi" : "%di"); - oappend (")"); -} - -/* ARGSUSED */ -OP_DSSI (dummy) -{ - oappend ("%ds:("); - oappend (aflag ? "%esi" : "%si"); - oappend (")"); -} - -/* ARGSUSED */ -OP_ONE (dummy) -{ - oappend ("1"); -} - -/* ARGSUSED */ -OP_C (dummy) -{ - codep++; /* skip mod/rm */ - sprintf (scratchbuf, "%%cr%d", reg); - oappend (scratchbuf); -} - -/* ARGSUSED */ -OP_D (dummy) -{ - codep++; /* skip mod/rm */ - sprintf (scratchbuf, "%%db%d", reg); - oappend (scratchbuf); -} - -/* ARGSUSED */ -OP_T (dummy) -{ - codep++; /* skip mod/rm */ - sprintf (scratchbuf, "%%tr%d", reg); - oappend (scratchbuf); -} - -OP_rm (bytemode) -{ - switch (bytemode) - { - case d_mode: - oappend (names32[rm]); - break; - case w_mode: - oappend (names16[rm]); - break; - } -} - -#define MAXLEN 20 -print_insn (memaddr, stream) - CORE_ADDR memaddr; - FILE *stream; -{ - unsigned char buffer[MAXLEN]; - - read_memory (memaddr, buffer, MAXLEN); - - return (i386dis ((int)memaddr, buffer, stream)); -} - diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c deleted file mode 100644 index 98dd25add78..00000000000 --- a/gdb/i386-tdep.c +++ /dev/null @@ -1,490 +0,0 @@ -/* Intel 386 target-dependent stuff. - Copyright (C) 1988, 1989, 1991 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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 1, or (at your option) -any later version. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "defs.h" -#include "param.h" -#include "frame.h" -#include "inferior.h" -#include "gdbcore.h" - -#ifdef USG -#include -#endif - -#include -#include -#include -#include -#include -#include - -#ifndef N_SET_MAGIC -#ifdef COFF_FORMAT -#define N_SET_MAGIC(exec, val) ((exec).magic = (val)) -#else -#define N_SET_MAGIC(exec, val) ((exec).a_magic = (val)) -#endif -#endif - -#include -#include - -/* helper functions for tm-i386.h */ - -/* stdio style buffering to minimize calls to ptrace */ -static CORE_ADDR codestream_next_addr; -static CORE_ADDR codestream_addr; -static unsigned char codestream_buf[sizeof (int)]; -static int codestream_off; -static int codestream_cnt; - -#define codestream_tell() (codestream_addr + codestream_off) -#define codestream_peek() (codestream_cnt == 0 ? \ - codestream_fill(1): codestream_buf[codestream_off]) -#define codestream_get() (codestream_cnt-- == 0 ? \ - codestream_fill(0) : codestream_buf[codestream_off++]) - -static unsigned char -codestream_fill (peek_flag) -{ - codestream_addr = codestream_next_addr; - codestream_next_addr += sizeof (int); - codestream_off = 0; - codestream_cnt = sizeof (int); - read_memory (codestream_addr, - (unsigned char *)codestream_buf, - sizeof (int)); - - if (peek_flag) - return (codestream_peek()); - else - return (codestream_get()); -} - -static void -codestream_seek (place) -{ - codestream_next_addr = place & -sizeof (int); - codestream_cnt = 0; - codestream_fill (1); - while (codestream_tell() != place) - codestream_get (); -} - -static void -codestream_read (buf, count) - unsigned char *buf; -{ - unsigned char *p; - int i; - p = buf; - for (i = 0; i < count; i++) - *p++ = codestream_get (); -} - -/* next instruction is a jump, move to target */ -static -i386_follow_jump () -{ - int long_delta; - short short_delta; - char byte_delta; - int data16; - int pos; - - pos = codestream_tell (); - - data16 = 0; - if (codestream_peek () == 0x66) - { - codestream_get (); - data16 = 1; - } - - switch (codestream_get ()) - { - case 0xe9: - /* relative jump: if data16 == 0, disp32, else disp16 */ - if (data16) - { - codestream_read ((unsigned char *)&short_delta, 2); - - /* include size of jmp inst (including the 0x66 prefix). */ - pos += short_delta + 4; - } - else - { - codestream_read ((unsigned char *)&long_delta, 4); - pos += long_delta + 5; - } - break; - case 0xeb: - /* relative jump, disp8 (ignore data16) */ - codestream_read ((unsigned char *)&byte_delta, 1); - pos += byte_delta + 2; - break; - } - codestream_seek (pos); -} - -/* - * find & return amound a local space allocated, and advance codestream to - * first register push (if any) - * - * if entry sequence doesn't make sense, return -1, and leave - * codestream pointer random - */ -static long -i386_get_frame_setup (pc) -{ - unsigned char op; - - codestream_seek (pc); - - i386_follow_jump (); - - op = codestream_get (); - - if (op == 0x58) /* popl %eax */ - { - /* - * this function must start with - * - * popl %eax 0x58 - * xchgl %eax, (%esp) 0x87 0x04 0x24 - * or xchgl %eax, 0(%esp) 0x87 0x44 0x24 0x00 - * - * (the system 5 compiler puts out the second xchg - * inst, and the assembler doesn't try to optimize it, - * so the 'sib' form gets generated) - * - * this sequence is used to get the address of the return - * buffer for a function that returns a structure - */ - int pos; - unsigned char buf[4]; - static unsigned char proto1[3] = { 0x87,0x04,0x24 }; - static unsigned char proto2[4] = { 0x87,0x44,0x24,0x00 }; - pos = codestream_tell (); - codestream_read (buf, 4); - if (bcmp (buf, proto1, 3) == 0) - pos += 3; - else if (bcmp (buf, proto2, 4) == 0) - pos += 4; - - codestream_seek (pos); - op = codestream_get (); /* update next opcode */ - } - - if (op == 0x55) /* pushl %ebp */ - { - /* check for movl %esp, %ebp - can be written two ways */ - switch (codestream_get ()) - { - case 0x8b: - if (codestream_get () != 0xec) - return (-1); - break; - case 0x89: - if (codestream_get () != 0xe5) - return (-1); - break; - default: - return (-1); - } - /* check for stack adjustment - * - * subl $XXX, %esp - * - * note: you can't subtract a 16 bit immediate - * from a 32 bit reg, so we don't have to worry - * about a data16 prefix - */ - op = codestream_peek (); - if (op == 0x83) - { - /* subl with 8 bit immed */ - codestream_get (); - if (codestream_get () != 0xec) - /* Some instruction starting with 0x83 other than subl. */ - { - codestream_seek (codestream_tell () - 2); - return 0; - } - /* subl with signed byte immediate - * (though it wouldn't make sense to be negative) - */ - return (codestream_get()); - } - else if (op == 0x81) - { - /* subl with 32 bit immed */ - int locals; - codestream_get(); - if (codestream_get () != 0xec) - /* Some instruction starting with 0x81 other than subl. */ - { - codestream_seek (codestream_tell () - 2); - return 0; - } - /* subl with 32 bit immediate */ - codestream_read ((unsigned char *)&locals, 4); - SWAP_TARGET_AND_HOST (&locals, 4); - return (locals); - } - else - { - return (0); - } - } - else if (op == 0xc8) - { - /* enter instruction: arg is 16 bit unsigned immed */ - unsigned short slocals; - codestream_read ((unsigned char *)&slocals, 2); - SWAP_TARGET_AND_HOST (&slocals, 2); - codestream_get (); /* flush final byte of enter instruction */ - return (slocals); - } - return (-1); -} - -/* Return number of args passed to a frame. - Can return -1, meaning no way to tell. */ - -/* on the 386, the instruction following the call could be: - * popl %ecx - one arg - * addl $imm, %esp - imm/4 args; imm may be 8 or 32 bits - * anything else - zero args - */ - -int -i386_frame_num_args (fi) - struct frame_info fi; -{ - int retpc; - unsigned char op; - struct frame_info *pfi; - - int frameless; - - FRAMELESS_FUNCTION_INVOCATION (fi, frameless); - if (frameless) - /* In the absence of a frame pointer, GDB doesn't get correct values - for nameless arguments. Return -1, so it doesn't print any - nameless arguments. */ - return -1; - - pfi = get_prev_frame_info ((fi)); - if (pfi == 0) - { - /* Note: this can happen if we are looking at the frame for - main, because FRAME_CHAIN_VALID won't let us go into - start. If we have debugging symbols, that's not really - a big deal; it just means it will only show as many arguments - to main as are declared. */ - return -1; - } - else - { - retpc = pfi->pc; - op = read_memory_integer (retpc, 1); - if (op == 0x59) - /* pop %ecx */ - return 1; - else if (op == 0x83) - { - op = read_memory_integer (retpc+1, 1); - if (op == 0xc4) - /* addl $, %esp */ - return (read_memory_integer (retpc+2,1)&0xff)/4; - else - return 0; - } - else if (op == 0x81) - { /* add with 32 bit immediate */ - op = read_memory_integer (retpc+1, 1); - if (op == 0xc4) - /* addl $, %esp */ - return read_memory_integer (retpc+2, 4) / 4; - else - return 0; - } - else - { - return 0; - } - } -} - -/* - * parse the first few instructions of the function to see - * what registers were stored. - * - * We handle these cases: - * - * The startup sequence can be at the start of the function, - * or the function can start with a branch to startup code at the end. - * - * %ebp can be set up with either the 'enter' instruction, or - * 'pushl %ebp, movl %esp, %ebp' (enter is too slow to be useful, - * but was once used in the sys5 compiler) - * - * Local space is allocated just below the saved %ebp by either the - * 'enter' instruction, or by 'subl $, %esp'. 'enter' has - * a 16 bit unsigned argument for space to allocate, and the - * 'addl' instruction could have either a signed byte, or - * 32 bit immediate. - * - * Next, the registers used by this function are pushed. In - * the sys5 compiler they will always be in the order: %edi, %esi, %ebx - * (and sometimes a harmless bug causes it to also save but not restore %eax); - * however, the code below is willing to see the pushes in any order, - * and will handle up to 8 of them. - * - * If the setup sequence is at the end of the function, then the - * next instruction will be a branch back to the start. - */ - -i386_frame_find_saved_regs (fip, fsrp) - struct frame_info *fip; - struct frame_saved_regs *fsrp; -{ - long locals; - unsigned char *p; - unsigned char op; - CORE_ADDR dummy_bottom; - CORE_ADDR adr; - int i; - - bzero (fsrp, sizeof *fsrp); - - /* if frame is the end of a dummy, compute where the - * beginning would be - */ - dummy_bottom = fip->frame - 4 - REGISTER_BYTES - CALL_DUMMY_LENGTH; - - /* check if the PC is in the stack, in a dummy frame */ - if (dummy_bottom <= fip->pc && fip->pc <= fip->frame) - { - /* all regs were saved by push_call_dummy () */ - adr = fip->frame; - for (i = 0; i < NUM_REGS; i++) - { - adr -= REGISTER_RAW_SIZE (i); - fsrp->regs[i] = adr; - } - return; - } - - locals = i386_get_frame_setup (get_pc_function_start (fip->pc)); - - if (locals >= 0) - { - adr = fip->frame - 4 - locals; - for (i = 0; i < 8; i++) - { - op = codestream_get (); - if (op < 0x50 || op > 0x57) - break; - fsrp->regs[op - 0x50] = adr; - adr -= 4; - } - } - - fsrp->regs[PC_REGNUM] = fip->frame + 4; - fsrp->regs[FP_REGNUM] = fip->frame; -} - -/* return pc of first real instruction */ -i386_skip_prologue (pc) -{ - unsigned char op; - int i; - - if (i386_get_frame_setup (pc) < 0) - return (pc); - - /* found valid frame setup - codestream now points to - * start of push instructions for saving registers - */ - - /* skip over register saves */ - for (i = 0; i < 8; i++) - { - op = codestream_peek (); - /* break if not pushl inst */ - if (op < 0x50 || op > 0x57) - break; - codestream_get (); - } - - i386_follow_jump (); - - return (codestream_tell ()); -} - -i386_push_dummy_frame () -{ - CORE_ADDR sp = read_register (SP_REGNUM); - int regnum; - char regbuf[MAX_REGISTER_RAW_SIZE]; - - sp = push_word (sp, read_register (PC_REGNUM)); - sp = push_word (sp, read_register (FP_REGNUM)); - write_register (FP_REGNUM, sp); - for (regnum = 0; regnum < NUM_REGS; regnum++) - { - read_register_gen (regnum, regbuf); - sp = push_bytes (sp, regbuf, REGISTER_RAW_SIZE (regnum)); - } - write_register (SP_REGNUM, sp); -} - -i386_pop_frame () -{ - FRAME frame = get_current_frame (); - CORE_ADDR fp; - int regnum; - struct frame_saved_regs fsr; - struct frame_info *fi; - char regbuf[MAX_REGISTER_RAW_SIZE]; - - fi = get_frame_info (frame); - fp = fi->frame; - get_frame_saved_regs (fi, &fsr); - for (regnum = 0; regnum < NUM_REGS; regnum++) - { - CORE_ADDR adr; - adr = fsr.regs[regnum]; - if (adr) - { - read_memory (adr, regbuf, REGISTER_RAW_SIZE (regnum)); - write_register_bytes (REGISTER_BYTE (regnum), regbuf, - REGISTER_RAW_SIZE (regnum)); - } - } - write_register (FP_REGNUM, read_memory_integer (fp, 4)); - write_register (PC_REGNUM, read_memory_integer (fp + 4, 4)); - write_register (SP_REGNUM, fp + 8); - flush_cached_frames (); - set_current_frame ( create_new_frame (read_register (FP_REGNUM), - read_pc ())); -} diff --git a/gdb/i386-xdep.c b/gdb/i386-xdep.c deleted file mode 100644 index 2d69d1dcdca..00000000000 --- a/gdb/i386-xdep.c +++ /dev/null @@ -1,251 +0,0 @@ -/* Intel 386 stuff. - Copyright (C) 1988, 1989, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "defs.h" -#include "param.h" -#include "frame.h" -#include "inferior.h" -#include "language.h" -#include "gdbcore.h" - -#ifdef USG -#include -#endif - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include "ieee-float.h" - -#include "target.h" - -extern void print_387_control_word (); /* i387-tdep.h */ -extern void print_387_status_word (); - -extern struct ext_format ext_format_i387; - -/* this table must line up with REGISTER_NAMES in m-i386.h */ -/* symbols like 'EAX' come from */ -static int regmap[] = -{ - EAX, ECX, EDX, EBX, - UESP, EBP, ESI, EDI, - EIP, EFL, CS, SS, - DS, ES, FS, GS, -}; - -/* blockend is the value of u.u_ar0, and points to the - * place where GS is stored - */ -i386_register_u_addr (blockend, regnum) -{ -#if 0 - /* this will be needed if fp registers are reinstated */ - /* for now, you can look at them with 'info float' - * sys5 wont let you change them with ptrace anyway - */ - if (regnum >= FP0_REGNUM && regnum <= FP7_REGNUM) - { - int ubase, fpstate; - struct user u; - ubase = blockend + 4 * (SS + 1) - KSTKSZ; - fpstate = ubase + ((char *)&u.u_fpstate - (char *)&u); - return (fpstate + 0x1c + 10 * (regnum - FP0_REGNUM)); - } - else -#endif - return (blockend + 4 * regmap[regnum]); - -} - -#if 0 -/* mauro@olympus 1991.10.20 -- compiling the following code causes - undefined symbols at link time, specifically: corechan, have_inferior_p */ -struct env387 -{ - unsigned short control; - unsigned short r0; - unsigned short status; - unsigned short r1; - unsigned short tag; - unsigned short r2; - unsigned long eip; - unsigned short code_seg; - unsigned short opcode; - unsigned long operand; - unsigned short operand_seg; - unsigned short r3; - unsigned char regs[8][10]; -}; - -static -print_387_status (status, ep) - unsigned short status; - struct env387 *ep; -{ - int i; - int bothstatus; - int top; - int fpreg; - unsigned char *p; - - bothstatus = ((status != 0) && (ep->status != 0)); - if (status != 0) - { - if (bothstatus) - printf ("u: "); - print_387_status_word (status); - } - - if (ep->status != 0) - { - if (bothstatus) - printf ("e: "); - print_387_status_word (ep->status); - } - - print_387_control_word (ep->control); - printf ("last exception: "); - printf ("opcode %s; ", local_hex_string(ep->opcode)); - printf ("pc %s:", local_hex_string(ep->code_seg)); - printf ("%s; ", local_hex_string(ep->eip)); - printf ("operand %s", local_hex_string(ep->operand_seg)); - printf (":%s\n", local_hex_string(ep->operand)); - - top = (ep->status >> 11) & 7; - - printf ("regno tag msb lsb value\n"); - for (fpreg = 7; fpreg >= 0; fpreg--) - { - double val; - - printf ("%s %d: ", fpreg == top ? "=>" : " ", fpreg); - - switch ((ep->tag >> (fpreg * 2)) & 3) - { - case 0: printf ("valid "); break; - case 1: printf ("zero "); break; - case 2: printf ("trap "); break; - case 3: printf ("empty "); break; - } - for (i = 9; i >= 0; i--) - printf ("%02x", ep->regs[fpreg][i]); - - ieee_extended_to_double (&ext_format_i387, (char *)ep->regs[fpreg], - &val); - printf (" %g\n", val); - } - if (ep->r0) - printf ("warning: reserved0 is %s\n", local_hex_string(ep->r0)); - if (ep->r1) - printf ("warning: reserved1 is %s\n", local_hex_string(ep->r1)); - if (ep->r2) - printf ("warning: reserved2 is %s\n", local_hex_string(ep->r2)); - if (ep->r3) - printf ("warning: reserved3 is %s\n", local_hex_string(ep->r3)); -} - -#ifndef U_FPSTATE -#define U_FPSTATE(u) u.u_fpstate -#endif - -i386_float_info () -{ - struct user u; /* just for address computations */ - int i; - /* fpstate defined in */ - struct fpstate *fpstatep; - char buf[sizeof (struct fpstate) + 2 * sizeof (int)]; - unsigned int uaddr; - char fpvalid = 0; - unsigned int rounded_addr; - unsigned int rounded_size; - extern int corechan; - int skip; - - uaddr = (char *)&u.u_fpvalid - (char *)&u; - if (target_has_execution) - { - unsigned int data; - unsigned int mask; - - rounded_addr = uaddr & -sizeof (int); - data = ptrace (3, inferior_pid, rounded_addr, 0); - mask = 0xff << ((uaddr - rounded_addr) * 8); - - fpvalid = ((data & mask) != 0); - } -#if 0 - else - { - if (lseek (corechan, uaddr, 0) < 0) - perror ("seek on core file"); - if (myread (corechan, &fpvalid, 1) < 0) - perror ("read on core file"); - - } -#endif /* no core support yet */ - - if (fpvalid == 0) - { - printf ("no floating point status saved\n"); - return; - } - - uaddr = (char *)&U_FPSTATE(u) - (char *)&u; - if (target_has_execution) - { - int *ip; - - rounded_addr = uaddr & -sizeof (int); - rounded_size = (((uaddr + sizeof (struct fpstate)) - uaddr) + - sizeof (int) - 1) / sizeof (int); - skip = uaddr - rounded_addr; - - ip = (int *)buf; - for (i = 0; i < rounded_size; i++) - { - *ip++ = ptrace (3, inferior_pid, rounded_addr, 0); - rounded_addr += sizeof (int); - } - } -#if 0 - else - { - if (lseek (corechan, uaddr, 0) < 0) - perror_with_name ("seek on core file"); - if (myread (corechan, buf, sizeof (struct fpstate)) < 0) - perror_with_name ("read from core file"); - skip = 0; - } - #endif /* 0 */ - - fpstatep = (struct fpstate *)(buf + skip); - print_387_status (fpstatep->status, (struct env387 *)fpstatep->state); -} -#endif /* mauro@olympus 1991.10.20 */ diff --git a/gdb/i387-tdep.c b/gdb/i387-tdep.c deleted file mode 100644 index e2e55576ffe..00000000000 --- a/gdb/i387-tdep.c +++ /dev/null @@ -1,127 +0,0 @@ -/* Intel 387 floating point stuff. - Copyright (C) 1988, 1989, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "defs.h" -#include "param.h" -#include "frame.h" -#include "inferior.h" -#include "language.h" -#include "gdbcore.h" -#include "ieee-float.h" - -#ifdef USG -#include -#endif - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - -struct ext_format ext_format_i387 = { -/* tot sbyte smask expbyte manbyte */ - 10, 9, 0x80, 9,8, 4,0 /* i387 */ -}; - -/* FIXME: Eliminate these routines when we have the time to change all - the callers. */ -void -i387_to_double (from, to) - char *from, *to; -{ - ieee_extended_to_double (&ext_format_i387, from, (double *)to); -} - -void -double_to_i387 (from, to) - char *from, *to; -{ - double_to_ieee_extended (&ext_format_i387, (double *)from, to); -} - -void -print_387_control_word (control) -unsigned short control; -{ - printf ("control %s: ", local_hex_string(control)); - printf ("compute to "); - switch ((control >> 8) & 3) - { - case 0: printf ("24 bits; "); break; - case 1: printf ("(bad); "); break; - case 2: printf ("53 bits; "); break; - case 3: printf ("64 bits; "); break; - } - printf ("round "); - switch ((control >> 10) & 3) - { - case 0: printf ("NEAREST; "); break; - case 1: printf ("DOWN; "); break; - case 2: printf ("UP; "); break; - case 3: printf ("CHOP; "); break; - } - if (control & 0x3f) - { - printf ("mask:"); - if (control & 0x0001) printf (" INVALID"); - if (control & 0x0002) printf (" DENORM"); - if (control & 0x0004) printf (" DIVZ"); - if (control & 0x0008) printf (" OVERF"); - if (control & 0x0010) printf (" UNDERF"); - if (control & 0x0020) printf (" LOS"); - printf (";"); - } - printf ("\n"); - if (control & 0xe080) printf ("warning: reserved bits on: %s\n", - local_hex_string(control & 0xe080)); -} - -void -print_387_status_word (status) - unsigned short status; -{ - printf ("status %s: ", local_hex_string (status)); - if (status & 0xff) - { - printf ("exceptions:"); - if (status & 0x0001) printf (" INVALID"); - if (status & 0x0002) printf (" DENORM"); - if (status & 0x0004) printf (" DIVZ"); - if (status & 0x0008) printf (" OVERF"); - if (status & 0x0010) printf (" UNDERF"); - if (status & 0x0020) printf (" LOS"); - if (status & 0x0040) printf (" FPSTACK"); - printf ("; "); - } - printf ("flags: %d%d%d%d; ", - (status & 0x4000) != 0, - (status & 0x0400) != 0, - (status & 0x0200) != 0, - (status & 0x0100) != 0); - - printf ("top %d\n", (status >> 11) & 7); -} diff --git a/gdb/i960-pinsn.c b/gdb/i960-pinsn.c deleted file mode 100644 index a651c48c5f6..00000000000 --- a/gdb/i960-pinsn.c +++ /dev/null @@ -1,863 +0,0 @@ -/* i80960 instruction disassembler for GDB. - Copyright (C) 1990-1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "defs.h" -#include "param.h" -#include "frame.h" -#include "inferior.h" - -extern char *reg_names[]; - -static FILE *stream; /* Output goes here */ -static void print_addr(); -static void ctrl(); -static void cobr(); -static void reg(); -static int mem(); -static void ea(); -static void dstop(); -static void regop(); -static void invalid(); -static int pinsn(); -static void put_abs(); - - -/* Print the i960 instruction at address 'memaddr' in debugged memory, - on stream 's'. Returns length of the instruction, in bytes. */ -int -print_insn( memaddr, s ) - CORE_ADDR memaddr; - FILE *s; -{ - unsigned int word1, word2; - - stream = s; - word1 = read_memory_integer( memaddr, 4 ); - word2 = read_memory_integer( memaddr+4, 4 ); - return pinsn( memaddr, word1, word2 ); -} - - -/* Read the i960 instruction at 'memaddr' and return the address of - the next instruction after that, or 0 if 'memaddr' is not the - address of a valid instruction. The first word of the instruction - is stored at 'pword1', and the second word, if any, is stored at - 'pword2'. */ - -CORE_ADDR -next_insn (memaddr, pword1, pword2) - unsigned long *pword1, *pword2; - CORE_ADDR memaddr; -{ - int len; - unsigned long buf[2]; - - /* Read the two (potential) words of the instruction at once, - to eliminate the overhead of two calls to read_memory (). - TODO: read more instructions at once and cache them. */ - - read_memory (memaddr, buf, sizeof (buf)); - *pword1 = buf[0]; - SWAP_TARGET_AND_HOST (pword1, sizeof (long)); - *pword2 = buf[1]; - SWAP_TARGET_AND_HOST (pword2, sizeof (long)); - - /* Divide instruction set into classes based on high 4 bits of opcode*/ - - switch ((*pword1 >> 28) & 0xf) - { - case 0x0: - case 0x1: /* ctrl */ - - case 0x2: - case 0x3: /* cobr */ - - case 0x5: - case 0x6: - case 0x7: /* reg */ - len = 4; - break; - - case 0x8: - case 0x9: - case 0xa: - case 0xb: - case 0xc: - len = mem (memaddr, *pword1, *pword2, 1); - break; - - default: /* invalid instruction */ - len = 0; - break; - } - - if (len) - return memaddr + len; - else - return 0; -} - -#define IN_GDB - -/***************************************************************************** - * All code below this point should be identical with that of - * the disassembler in gdmp960. - *****************************************************************************/ - -struct tabent { - char *name; - char numops; -}; - -static int -pinsn( memaddr, word1, word2 ) - unsigned long memaddr; - unsigned long word1, word2; -{ - int instr_len; - - instr_len = 4; - put_abs( word1, word2 ); - - /* Divide instruction set into classes based on high 4 bits of opcode*/ - - switch ( (word1 >> 28) & 0xf ){ - case 0x0: - case 0x1: - ctrl( memaddr, word1, word2 ); - break; - case 0x2: - case 0x3: - cobr( memaddr, word1, word2 ); - break; - case 0x5: - case 0x6: - case 0x7: - reg( word1 ); - break; - case 0x8: - case 0x9: - case 0xa: - case 0xb: - case 0xc: - instr_len = mem( memaddr, word1, word2, 0 ); - break; - default: - /* invalid instruction, print as data word */ - invalid( word1 ); - break; - } - return instr_len; -} - -/****************************************/ -/* CTRL format */ -/****************************************/ -static void -ctrl( memaddr, word1, word2 ) - unsigned long memaddr; - unsigned long word1, word2; -{ - int i; - static struct tabent ctrl_tab[] = { - NULL, 0, /* 0x00 */ - NULL, 0, /* 0x01 */ - NULL, 0, /* 0x02 */ - NULL, 0, /* 0x03 */ - NULL, 0, /* 0x04 */ - NULL, 0, /* 0x05 */ - NULL, 0, /* 0x06 */ - NULL, 0, /* 0x07 */ - "b", 1, /* 0x08 */ - "call", 1, /* 0x09 */ - "ret", 0, /* 0x0a */ - "bal", 1, /* 0x0b */ - NULL, 0, /* 0x0c */ - NULL, 0, /* 0x0d */ - NULL, 0, /* 0x0e */ - NULL, 0, /* 0x0f */ - "bno", 1, /* 0x10 */ - "bg", 1, /* 0x11 */ - "be", 1, /* 0x12 */ - "bge", 1, /* 0x13 */ - "bl", 1, /* 0x14 */ - "bne", 1, /* 0x15 */ - "ble", 1, /* 0x16 */ - "bo", 1, /* 0x17 */ - "faultno", 0, /* 0x18 */ - "faultg", 0, /* 0x19 */ - "faulte", 0, /* 0x1a */ - "faultge", 0, /* 0x1b */ - "faultl", 0, /* 0x1c */ - "faultne", 0, /* 0x1d */ - "faultle", 0, /* 0x1e */ - "faulto", 0, /* 0x1f */ - }; - - i = (word1 >> 24) & 0xff; - if ( (ctrl_tab[i].name == NULL) || ((word1 & 1) != 0) ){ - invalid( word1 ); - return; - } - - fputs( ctrl_tab[i].name, stream ); - if ( word1 & 2 ){ /* Predicts branch not taken */ - fputs( ".f", stream ); - } - - if ( ctrl_tab[i].numops == 1 ){ - /* EXTRACT DISPLACEMENT AND CONVERT TO ADDRESS */ - word1 &= 0x00ffffff; - if ( word1 & 0x00800000 ){ /* Sign bit is set */ - word1 |= (-1 & ~0xffffff); /* Sign extend */ - } - putc( '\t', stream ); - print_addr( word1 + memaddr ); - } -} - -/****************************************/ -/* COBR format */ -/****************************************/ -static void -cobr( memaddr, word1, word2 ) - unsigned long memaddr; - unsigned long word1, word2; -{ - int src1; - int src2; - int i; - - static struct tabent cobr_tab[] = { - "testno", 1, /* 0x20 */ - "testg", 1, /* 0x21 */ - "teste", 1, /* 0x22 */ - "testge", 1, /* 0x23 */ - "testl", 1, /* 0x24 */ - "testne", 1, /* 0x25 */ - "testle", 1, /* 0x26 */ - "testo", 1, /* 0x27 */ - NULL, 0, /* 0x28 */ - NULL, 0, /* 0x29 */ - NULL, 0, /* 0x2a */ - NULL, 0, /* 0x2b */ - NULL, 0, /* 0x2c */ - NULL, 0, /* 0x2d */ - NULL, 0, /* 0x2e */ - NULL, 0, /* 0x2f */ - "bbc", 3, /* 0x30 */ - "cmpobg", 3, /* 0x31 */ - "cmpobe", 3, /* 0x32 */ - "cmpobge", 3, /* 0x33 */ - "cmpobl", 3, /* 0x34 */ - "cmpobne", 3, /* 0x35 */ - "cmpoble", 3, /* 0x36 */ - "bbs", 3, /* 0x37 */ - "cmpibno", 3, /* 0x38 */ - "cmpibg", 3, /* 0x39 */ - "cmpibe", 3, /* 0x3a */ - "cmpibge", 3, /* 0x3b */ - "cmpibl", 3, /* 0x3c */ - "cmpibne", 3, /* 0x3d */ - "cmpible", 3, /* 0x3e */ - "cmpibo", 3, /* 0x3f */ - }; - - i = ((word1 >> 24) & 0xff) - 0x20; - if ( cobr_tab[i].name == NULL ){ - invalid( word1 ); - return; - } - - fputs( cobr_tab[i].name, stream ); - if ( word1 & 2 ){ /* Predicts branch not taken */ - fputs( ".f", stream ); - } - putc( '\t', stream ); - - src1 = (word1 >> 19) & 0x1f; - src2 = (word1 >> 14) & 0x1f; - - if ( word1 & 0x02000 ){ /* M1 is 1 */ - fprintf( stream, "%d", src1 ); - } else { /* M1 is 0 */ - fputs( reg_names[src1], stream ); - } - - if ( cobr_tab[i].numops > 1 ){ - if ( word1 & 1 ){ /* S2 is 1 */ - fprintf( stream, ",sf%d,", src2 ); - } else { /* S1 is 0 */ - fprintf( stream, ",%s,", reg_names[src2] ); - } - - /* Extract displacement and convert to address - */ - word1 &= 0x00001ffc; - if ( word1 & 0x00001000 ){ /* Negative displacement */ - word1 |= (-1 & ~0x1fff); /* Sign extend */ - } - print_addr( memaddr + word1 ); - } -} - -/****************************************/ -/* MEM format */ -/****************************************/ -static int /* returns instruction length: 4 or 8 */ -mem( memaddr, word1, word2, noprint ) - unsigned long memaddr; - unsigned long word1, word2; - int noprint; /* If TRUE, return instruction length, but - don't output any text. */ -{ - int i, j; - int len; - int mode; - int offset; - char *reg1, *reg2, *reg3; - - /* This lookup table is too sparse to make it worth typing in, but not - * so large as to make a sparse array necessary. We allocate the - * table at runtime, initialize all entries to empty, and copy the - * real ones in from an initialization table. - * - * NOTE: In this table, the meaning of 'numops' is: - * 1: single operand - * 2: 2 operands, load instruction - * -2: 2 operands, store instruction - */ - static struct tabent *mem_tab = NULL; - static struct { int opcode; char *name; char numops; } mem_init[] = { -#define MEM_MIN 0x80 - 0x80, "ldob", 2, - 0x82, "stob", -2, - 0x84, "bx", 1, - 0x85, "balx", 2, - 0x86, "callx", 1, - 0x88, "ldos", 2, - 0x8a, "stos", -2, - 0x8c, "lda", 2, - 0x90, "ld", 2, - 0x92, "st", -2, - 0x98, "ldl", 2, - 0x9a, "stl", -2, - 0xa0, "ldt", 2, - 0xa2, "stt", -2, - 0xb0, "ldq", 2, - 0xb2, "stq", -2, - 0xc0, "ldib", 2, - 0xc2, "stib", -2, - 0xc8, "ldis", 2, - 0xca, "stis", -2, -#define MEM_MAX 0xca -#define MEM_SIZ ((MEM_MAX-MEM_MIN+1) * sizeof(struct tabent)) - 0, NULL, 0 - }; - - if ( mem_tab == NULL ){ - mem_tab = (struct tabent *) xmalloc( MEM_SIZ ); - bzero( mem_tab, MEM_SIZ ); - for ( i = 0; mem_init[i].opcode != 0; i++ ){ - j = mem_init[i].opcode - MEM_MIN; - mem_tab[j].name = mem_init[i].name; - mem_tab[j].numops = mem_init[i].numops; - } - } - - i = ((word1 >> 24) & 0xff) - MEM_MIN; - mode = (word1 >> 10) & 0xf; - - if ( (mem_tab[i].name != NULL) /* Valid instruction */ - && ((mode == 5) || (mode >=12)) ){ /* With 32-bit displacement */ - len = 8; - } else { - len = 4; - } - - if ( noprint ){ - return len; - } - - if ( (mem_tab[i].name == NULL) || (mode == 6) ){ - invalid( word1 ); - return len; - } - - fprintf( stream, "%s\t", mem_tab[i].name ); - - reg1 = reg_names[ (word1 >> 19) & 0x1f ]; /* MEMB only */ - reg2 = reg_names[ (word1 >> 14) & 0x1f ]; - reg3 = reg_names[ word1 & 0x1f ]; /* MEMB only */ - offset = word1 & 0xfff; /* MEMA only */ - - switch ( mem_tab[i].numops ){ - - case 2: /* LOAD INSTRUCTION */ - if ( mode & 4 ){ /* MEMB FORMAT */ - ea( memaddr, mode, reg2, reg3, word1, word2 ); - fprintf( stream, ",%s", reg1 ); - } else { /* MEMA FORMAT */ - fprintf( stream, "0x%x", offset ); - if (mode & 8) { - fprintf( stream, "(%s)", reg2 ); - } - fprintf( stream, ",%s", reg1 ); - } - break; - - case -2: /* STORE INSTRUCTION */ - if ( mode & 4 ){ /* MEMB FORMAT */ - fprintf( stream, "%s,", reg1 ); - ea( memaddr, mode, reg2, reg3, word1, word2 ); - } else { /* MEMA FORMAT */ - fprintf( stream, "%s,0x%x", reg1, offset ); - if (mode & 8) { - fprintf( stream, "(%s)", reg2 ); - } - } - break; - - case 1: /* BX/CALLX INSTRUCTION */ - if ( mode & 4 ){ /* MEMB FORMAT */ - ea( memaddr, mode, reg2, reg3, word1, word2 ); - } else { /* MEMA FORMAT */ - fprintf( stream, "0x%x", offset ); - if (mode & 8) { - fprintf( stream, "(%s)", reg2 ); - } - } - break; - } - - return len; -} - -/****************************************/ -/* REG format */ -/****************************************/ -static void -reg( word1 ) - unsigned long word1; -{ - int i, j; - int opcode; - int fp; - int m1, m2, m3; - int s1, s2; - int src, src2, dst; - char *mnemp; - - /* This lookup table is too sparse to make it worth typing in, but not - * so large as to make a sparse array necessary. We allocate the - * table at runtime, initialize all entries to empty, and copy the - * real ones in from an initialization table. - * - * NOTE: In this table, the meaning of 'numops' is: - * 1: single operand, which is NOT a destination. - * -1: single operand, which IS a destination. - * 2: 2 operands, the 2nd of which is NOT a destination. - * -2: 2 operands, the 2nd of which IS a destination. - * 3: 3 operands - * - * If an opcode mnemonic begins with "F", it is a floating-point - * opcode (the "F" is not printed). - */ - - static struct tabent *reg_tab = NULL; - static struct { int opcode; char *name; char numops; } reg_init[] = { -#define REG_MIN 0x580 - 0x580, "notbit", 3, - 0x581, "and", 3, - 0x582, "andnot", 3, - 0x583, "setbit", 3, - 0x584, "notand", 3, - 0x586, "xor", 3, - 0x587, "or", 3, - 0x588, "nor", 3, - 0x589, "xnor", 3, - 0x58a, "not", -2, - 0x58b, "ornot", 3, - 0x58c, "clrbit", 3, - 0x58d, "notor", 3, - 0x58e, "nand", 3, - 0x58f, "alterbit", 3, - 0x590, "addo", 3, - 0x591, "addi", 3, - 0x592, "subo", 3, - 0x593, "subi", 3, - 0x598, "shro", 3, - 0x59a, "shrdi", 3, - 0x59b, "shri", 3, - 0x59c, "shlo", 3, - 0x59d, "rotate", 3, - 0x59e, "shli", 3, - 0x5a0, "cmpo", 2, - 0x5a1, "cmpi", 2, - 0x5a2, "concmpo", 2, - 0x5a3, "concmpi", 2, - 0x5a4, "cmpinco", 3, - 0x5a5, "cmpinci", 3, - 0x5a6, "cmpdeco", 3, - 0x5a7, "cmpdeci", 3, - 0x5ac, "scanbyte", 2, - 0x5ae, "chkbit", 2, - 0x5b0, "addc", 3, - 0x5b2, "subc", 3, - 0x5cc, "mov", -2, - 0x5d8, "eshro", 3, - 0x5dc, "movl", -2, - 0x5ec, "movt", -2, - 0x5fc, "movq", -2, - 0x600, "synmov", 2, - 0x601, "synmovl", 2, - 0x602, "synmovq", 2, - 0x603, "cmpstr", 3, - 0x604, "movqstr", 3, - 0x605, "movstr", 3, - 0x610, "atmod", 3, - 0x612, "atadd", 3, - 0x613, "inspacc", -2, - 0x614, "ldphy", -2, - 0x615, "synld", -2, - 0x617, "fill", 3, - 0x630, "sdma", 3, - 0x631, "udma", 0, - 0x640, "spanbit", -2, - 0x641, "scanbit", -2, - 0x642, "daddc", 3, - 0x643, "dsubc", 3, - 0x644, "dmovt", -2, - 0x645, "modac", 3, - 0x646, "condrec", -2, - 0x650, "modify", 3, - 0x651, "extract", 3, - 0x654, "modtc", 3, - 0x655, "modpc", 3, - 0x656, "receive", -2, - 0x659, "sysctl", 3, - 0x660, "calls", 1, - 0x662, "send", 3, - 0x663, "sendserv", 1, - 0x664, "resumprcs", 1, - 0x665, "schedprcs", 1, - 0x666, "saveprcs", 0, - 0x668, "condwait", 1, - 0x669, "wait", 1, - 0x66a, "signal", 1, - 0x66b, "mark", 0, - 0x66c, "fmark", 0, - 0x66d, "flushreg", 0, - 0x66f, "syncf", 0, - 0x670, "emul", 3, - 0x671, "ediv", 3, - 0x673, "ldtime", -1, - 0x674, "Fcvtir", -2, - 0x675, "Fcvtilr", -2, - 0x676, "Fscalerl", 3, - 0x677, "Fscaler", 3, - 0x680, "Fatanr", 3, - 0x681, "Flogepr", 3, - 0x682, "Flogr", 3, - 0x683, "Fremr", 3, - 0x684, "Fcmpor", 2, - 0x685, "Fcmpr", 2, - 0x688, "Fsqrtr", -2, - 0x689, "Fexpr", -2, - 0x68a, "Flogbnr", -2, - 0x68b, "Froundr", -2, - 0x68c, "Fsinr", -2, - 0x68d, "Fcosr", -2, - 0x68e, "Ftanr", -2, - 0x68f, "Fclassr", 1, - 0x690, "Fatanrl", 3, - 0x691, "Flogeprl", 3, - 0x692, "Flogrl", 3, - 0x693, "Fremrl", 3, - 0x694, "Fcmporl", 2, - 0x695, "Fcmprl", 2, - 0x698, "Fsqrtrl", -2, - 0x699, "Fexprl", -2, - 0x69a, "Flogbnrl", -2, - 0x69b, "Froundrl", -2, - 0x69c, "Fsinrl", -2, - 0x69d, "Fcosrl", -2, - 0x69e, "Ftanrl", -2, - 0x69f, "Fclassrl", 1, - 0x6c0, "Fcvtri", -2, - 0x6c1, "Fcvtril", -2, - 0x6c2, "Fcvtzri", -2, - 0x6c3, "Fcvtzril", -2, - 0x6c9, "Fmovr", -2, - 0x6d9, "Fmovrl", -2, - 0x6e1, "Fmovre", -2, - 0x6e2, "Fcpysre", 3, - 0x6e3, "Fcpyrsre", 3, - 0x701, "mulo", 3, - 0x708, "remo", 3, - 0x70b, "divo", 3, - 0x741, "muli", 3, - 0x748, "remi", 3, - 0x749, "modi", 3, - 0x74b, "divi", 3, - 0x78b, "Fdivr", 3, - 0x78c, "Fmulr", 3, - 0x78d, "Fsubr", 3, - 0x78f, "Faddr", 3, - 0x79b, "Fdivrl", 3, - 0x79c, "Fmulrl", 3, - 0x79d, "Fsubrl", 3, - 0x79f, "Faddrl", 3, -#define REG_MAX 0x79f -#define REG_SIZ ((REG_MAX-REG_MIN+1) * sizeof(struct tabent)) - 0, NULL, 0 - }; - - if ( reg_tab == NULL ){ - reg_tab = (struct tabent *) xmalloc( REG_SIZ ); - bzero( reg_tab, REG_SIZ ); - for ( i = 0; reg_init[i].opcode != 0; i++ ){ - j = reg_init[i].opcode - REG_MIN; - reg_tab[j].name = reg_init[i].name; - reg_tab[j].numops = reg_init[i].numops; - } - } - - opcode = ((word1 >> 20) & 0xff0) | ((word1 >> 7) & 0xf); - i = opcode - REG_MIN; - - if ( (opcodeREG_MAX) || (reg_tab[i].name==NULL) ){ - invalid( word1 ); - return; - } - - mnemp = reg_tab[i].name; - if ( *mnemp == 'F' ){ - fp = 1; - mnemp++; - } else { - fp = 0; - } - - fputs( mnemp, stream ); - - s1 = (word1 >> 5) & 1; - s2 = (word1 >> 6) & 1; - m1 = (word1 >> 11) & 1; - m2 = (word1 >> 12) & 1; - m3 = (word1 >> 13) & 1; - src = word1 & 0x1f; - src2 = (word1 >> 14) & 0x1f; - dst = (word1 >> 19) & 0x1f; - - if ( reg_tab[i].numops != 0 ){ - putc( '\t', stream ); - - switch ( reg_tab[i].numops ){ - case 1: - regop( m1, s1, src, fp ); - break; - case -1: - dstop( m3, dst, fp ); - break; - case 2: - regop( m1, s1, src, fp ); - putc( ',', stream ); - regop( m2, s2, src2, fp ); - break; - case -2: - regop( m1, s1, src, fp ); - putc( ',', stream ); - dstop( m3, dst, fp ); - break; - case 3: - regop( m1, s1, src, fp ); - putc( ',', stream ); - regop( m2, s2, src2, fp ); - putc( ',', stream ); - dstop( m3, dst, fp ); - break; - } - } -} - - -/* - * Print out effective address for memb instructions. - */ -static void -ea( memaddr, mode, reg2, reg3, word1, word2 ) - unsigned long memaddr; - int mode; - char *reg2, *reg3; - unsigned int word2; -{ - int scale; - static int scale_tab[] = { 1, 2, 4, 8, 16 }; - - scale = (word1 >> 7) & 0x07; - if ( (scale > 4) || ((word1 >> 5) & 0x03 != 0) ){ - invalid( word1 ); - return; - } - scale = scale_tab[scale]; - - switch (mode) { - case 4: /* (reg) */ - fprintf( stream, "(%s)", reg2 ); - break; - case 5: /* displ+8(ip) */ - print_addr( word2+8+memaddr ); - break; - case 7: /* (reg)[index*scale] */ - if (scale == 1) { - fprintf( stream, "(%s)[%s]", reg2, reg3 ); - } else { - fprintf( stream, "(%s)[%s*%d]",reg2,reg3,scale); - } - break; - case 12: /* displacement */ - print_addr( word2 ); - break; - case 13: /* displ(reg) */ - print_addr( word2 ); - fprintf( stream, "(%s)", reg2 ); - break; - case 14: /* displ[index*scale] */ - print_addr( word2 ); - if (scale == 1) { - fprintf( stream, "[%s]", reg3 ); - } else { - fprintf( stream, "[%s*%d]", reg3, scale ); - } - break; - case 15: /* displ(reg)[index*scale] */ - print_addr( word2 ); - if (scale == 1) { - fprintf( stream, "(%s)[%s]", reg2, reg3 ); - } else { - fprintf( stream, "(%s)[%s*%d]",reg2,reg3,scale ); - } - break; - default: - invalid( word1 ); - return; - } -} - - -/************************************************/ -/* Register Instruction Operand */ -/************************************************/ -static void -regop( mode, spec, reg, fp ) - int mode, spec, reg, fp; -{ - if ( fp ){ /* FLOATING POINT INSTRUCTION */ - if ( mode == 1 ){ /* FP operand */ - switch ( reg ){ - case 0: fputs( "fp0", stream ); break; - case 1: fputs( "fp1", stream ); break; - case 2: fputs( "fp2", stream ); break; - case 3: fputs( "fp3", stream ); break; - case 16: fputs( "0f0.0", stream ); break; - case 22: fputs( "0f1.0", stream ); break; - default: putc( '?', stream ); break; - } - } else { /* Non-FP register */ - fputs( reg_names[reg], stream ); - } - } else { /* NOT FLOATING POINT */ - if ( mode == 1 ){ /* Literal */ - fprintf( stream, "%d", reg ); - } else { /* Register */ - if ( spec == 0 ){ - fputs( reg_names[reg], stream ); - } else { - fprintf( stream, "sf%d", reg ); - } - } - } -} - -/************************************************/ -/* Register Instruction Destination Operand */ -/************************************************/ -static void -dstop( mode, reg, fp ) - int mode, reg, fp; -{ - /* 'dst' operand can't be a literal. On non-FP instructions, register - * mode is assumed and "m3" acts as if were "s3"; on FP-instructions, - * sf registers are not allowed so m3 acts normally. - */ - if ( fp ){ - regop( mode, 0, reg, fp ); - } else { - regop( 0, mode, reg, fp ); - } -} - - -static void -invalid( word1 ) - int word1; -{ - fprintf( stream, ".word\t0x%08x", word1 ); -} - -static void -print_addr(a) -{ - fprintf( stream, "0x%x", a ); -} - -static void -put_abs( word1, word2 ) - unsigned long word1, word2; -{ -#ifdef IN_GDB - return; -#else - int len; - - switch ( (word1 >> 28) & 0xf ){ - case 0x8: - case 0x9: - case 0xa: - case 0xb: - case 0xc: - /* MEM format instruction */ - len = mem( 0, word1, word2, 1 ); - break; - default: - len = 4; - break; - } - - if ( len == 8 ){ - fprintf( stream, "%08x %08x\t", word1, word2 ); - } else { - fprintf( stream, "%08x \t", word1 ); - } -; - -#endif -} diff --git a/gdb/i960-tdep.c b/gdb/i960-tdep.c deleted file mode 100644 index 27fde37634b..00000000000 --- a/gdb/i960-tdep.c +++ /dev/null @@ -1,646 +0,0 @@ -/* Target-machine dependent code for the Intel 960 - Copyright (C) 1991 Free Software Foundation, Inc. - Contributed by Intel Corporation. - examine_prologue and other parts contributed by Wind River Systems. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Miscellaneous i80960-dependent routines. - Most are called from macros defined in "tm-i960.h". */ - -#include -#include -#include "defs.h" -#include "param.h" -#include "symtab.h" -#include "value.h" -#include "frame.h" -#include "signame.h" -#include "ieee-float.h" - -/* Structure of i960 extended floating point format. */ - -const struct ext_format ext_format_i960 = { -/* tot sbyte smask expbyte manbyte */ - 12, 9, 0x80, 9,8, 4,0, /* i960 */ -}; - -/* gdb960 is always running on a non-960 host. Check its characteristics. - This routine must be called as part of gdb initialization. */ - -static void -check_host() -{ - int i; - - static struct typestruct { - int hostsize; /* Size of type on host */ - int i960size; /* Size of type on i960 */ - char *typename; /* Name of type, for error msg */ - } types[] = { - { sizeof(short), 2, "short" }, - { sizeof(int), 4, "int" }, - { sizeof(long), 4, "long" }, - { sizeof(float), 4, "float" }, - { sizeof(double), 8, "double" }, - { sizeof(char *), 4, "pointer" }, - }; -#define TYPELEN (sizeof(types) / sizeof(struct typestruct)) - - /* Make sure that host type sizes are same as i960 - */ - for ( i = 0; i < TYPELEN; i++ ){ - if ( types[i].hostsize != types[i].i960size ){ - printf("sizeof(%s) != %d: PROCEED AT YOUR OWN RISK!\n", - types[i].typename, types[i].i960size ); - } - - } -} - -/* 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 - after the instruction at address LIMIT, as explained below). - - LIMIT places an upper bound on addresses of the instructions to be - examined. If the prologue code scan reaches LIMIT, the scan is - aborted and LIMIT is returned. This is used, when examining the - prologue for the current frame, to keep examine_prologue () from - claiming that a given register has been saved when in fact the - instruction that saves it has not yet been executed. LIMIT is used - at other times to stop the scan when we hit code after the true - function prologue (e.g. for the first source line) which might - otherwise be mistaken for function prologue. - - The format of the function prologue matched by this routine is - derived from examination of the source to gcc960 1.21, particularly - the routine i960_function_prologue (). A "regular expression" for - the function prologue is given below: - - (lda LRn, g14 - mov g14, g[0-7] - (mov 0, g14) | (lda 0, g14))? - - (mov[qtl]? g[0-15], r[4-15])* - ((addo [1-31], sp, sp) | (lda n(sp), sp))? - (st[qtl]? g[0-15], n(fp))* - - (cmpobne 0, g14, LFn - mov sp, g14 - lda 0x30(sp), sp - LFn: stq g0, (g14) - stq g4, 0x10(g14) - stq g8, 0x20(g14))? - - (st g14, n(fp))? - (mov g13,r[4-15])? -*/ - -/* Macros for extracting fields from i960 instructions. */ - -#define BITMASK(pos, width) (((0x1 << (width)) - 1) << (pos)) -#define EXTRACT_FIELD(val, pos, width) ((val) >> (pos) & BITMASK (0, width)) - -#define REG_SRC1(insn) EXTRACT_FIELD (insn, 0, 5) -#define REG_SRC2(insn) EXTRACT_FIELD (insn, 14, 5) -#define REG_SRCDST(insn) EXTRACT_FIELD (insn, 19, 5) -#define MEM_SRCDST(insn) EXTRACT_FIELD (insn, 19, 5) -#define MEMA_OFFSET(insn) EXTRACT_FIELD (insn, 0, 12) - -/* Fetch the instruction at ADDR, returning 0 if ADDR is beyond LIM or - is not the address of a valid instruction, the address of the next - instruction beyond ADDR otherwise. *PWORD1 receives the first word - of the instruction, and (for two-word instructions), *PWORD2 receives - the second. */ - -#define NEXT_PROLOGUE_INSN(addr, lim, pword1, pword2) \ - (((addr) < (lim)) ? next_insn (addr, pword1, pword2) : 0) - -static CORE_ADDR -examine_prologue (ip, limit, frame_addr, fsr) - register CORE_ADDR ip; - register CORE_ADDR limit; - FRAME_ADDR frame_addr; - struct frame_saved_regs *fsr; -{ - register CORE_ADDR next_ip; - register int src, dst; - register unsigned int *pcode; - unsigned int insn1, insn2; - int size; - int within_leaf_prologue; - CORE_ADDR save_addr; - static unsigned int varargs_prologue_code [] = - { - 0x3507a00c, /* cmpobne 0x0, g14, LFn */ - 0x5cf01601, /* mov sp, g14 */ - 0x8c086030, /* lda 0x30(sp), sp */ - 0xb2879000, /* LFn: stq g0, (g14) */ - 0xb2a7a010, /* stq g4, 0x10(g14) */ - 0xb2c7a020 /* stq g8, 0x20(g14) */ - }; - - /* Accept a leaf procedure prologue code fragment if present. - Note that ip might point to either the leaf or non-leaf - entry point; we look for the non-leaf entry point first: */ - - within_leaf_prologue = 0; - if ((next_ip = NEXT_PROLOGUE_INSN (ip, limit, &insn1, &insn2)) - && ((insn1 & 0xfffff000) == 0x8cf00000 /* lda LRx, g14 (MEMA) */ - || (insn1 & 0xfffffc60) == 0x8cf03000)) /* lda LRx, g14 (MEMB) */ - { - within_leaf_prologue = 1; - next_ip = NEXT_PROLOGUE_INSN (next_ip, limit, &insn1, &insn2); - } - - /* Now look for the prologue code at a leaf entry point: */ - - if (next_ip - && (insn1 & 0xff87ffff) == 0x5c80161e /* mov g14, gx */ - && REG_SRCDST (insn1) <= G0_REGNUM + 7) - { - within_leaf_prologue = 1; - if ((next_ip = NEXT_PROLOGUE_INSN (next_ip, limit, &insn1, &insn2)) - && (insn1 == 0x8cf00000 /* lda 0, g14 */ - || insn1 == 0x5cf01e00)) /* mov 0, g14 */ - { - ip = next_ip; - next_ip = NEXT_PROLOGUE_INSN (ip, limit, &insn1, &insn2); - within_leaf_prologue = 0; - } - } - - /* If something that looks like the beginning of a leaf prologue - has been seen, but the remainder of the prologue is missing, bail. - We don't know what we've got. */ - - if (within_leaf_prologue) - return (ip); - - /* Accept zero or more instances of "mov[qtl]? gx, ry", where y >= 4. - This may cause us to mistake the moving of a register - parameter to a local register for the saving of a callee-saved - register, but that can't be helped, since with the - "-fcall-saved" flag, any register can be made callee-saved. */ - - while (next_ip - && (insn1 & 0xfc802fb0) == 0x5c000610 - && (dst = REG_SRCDST (insn1)) >= (R0_REGNUM + 4)) - { - src = REG_SRC1 (insn1); - size = EXTRACT_FIELD (insn1, 24, 2) + 1; - save_addr = frame_addr + ((dst - R0_REGNUM) * 4); - while (size--) - { - fsr->regs[src++] = save_addr; - save_addr += 4; - } - ip = next_ip; - next_ip = NEXT_PROLOGUE_INSN (ip, limit, &insn1, &insn2); - } - - /* Accept an optional "addo n, sp, sp" or "lda n(sp), sp". */ - - if (next_ip && - ((insn1 & 0xffffffe0) == 0x59084800 /* addo n, sp, sp */ - || (insn1 & 0xfffff000) == 0x8c086000 /* lda n(sp), sp (MEMA) */ - || (insn1 & 0xfffffc60) == 0x8c087400)) /* lda n(sp), sp (MEMB) */ - { - ip = next_ip; - next_ip = NEXT_PROLOGUE_INSN (ip, limit, &insn1, &insn2); - } - - /* Accept zero or more instances of "st[qtl]? gx, n(fp)". - This may cause us to mistake the copying of a register - parameter to the frame for the saving of a callee-saved - register, but that can't be helped, since with the - "-fcall-saved" flag, any register can be made callee-saved. - We can, however, refuse to accept a save of register g14, - since that is matched explicitly below. */ - - while (next_ip && - ((insn1 & 0xf787f000) == 0x9287e000 /* stl? gx, n(fp) (MEMA) */ - || (insn1 & 0xf787fc60) == 0x9287f400 /* stl? gx, n(fp) (MEMB) */ - || (insn1 & 0xef87f000) == 0xa287e000 /* st[tq] gx, n(fp) (MEMA) */ - || (insn1 & 0xef87fc60) == 0xa287f400) /* st[tq] gx, n(fp) (MEMB) */ - && ((src = MEM_SRCDST (insn1)) != G14_REGNUM)) - { - save_addr = frame_addr + ((insn1 & BITMASK (12, 1)) - ? insn2 : MEMA_OFFSET (insn1)); - size = (insn1 & BITMASK (29, 1)) ? ((insn1 & BITMASK (28, 1)) ? 4 : 3) - : ((insn1 & BITMASK (27, 1)) ? 2 : 1); - while (size--) - { - fsr->regs[src++] = save_addr; - save_addr += 4; - } - ip = next_ip; - next_ip = NEXT_PROLOGUE_INSN (ip, limit, &insn1, &insn2); - } - - /* Accept the varargs prologue code if present. */ - - size = sizeof (varargs_prologue_code) / sizeof (int); - pcode = varargs_prologue_code; - while (size-- && next_ip && *pcode++ == insn1) - { - ip = next_ip; - next_ip = NEXT_PROLOGUE_INSN (ip, limit, &insn1, &insn2); - } - - /* Accept an optional "st g14, n(fp)". */ - - if (next_ip && - ((insn1 & 0xfffff000) == 0x92f7e000 /* st g14, n(fp) (MEMA) */ - || (insn1 & 0xfffffc60) == 0x92f7f400)) /* st g14, n(fp) (MEMB) */ - { - fsr->regs[G14_REGNUM] = frame_addr + ((insn1 & BITMASK (12, 1)) - ? insn2 : MEMA_OFFSET (insn1)); - ip = next_ip; - next_ip = NEXT_PROLOGUE_INSN (ip, limit, &insn1, &insn2); - } - - /* Accept zero or one instance of "mov g13, ry", where y >= 4. - This is saving the address where a struct should be returned. */ - - if (next_ip - && (insn1 & 0xff802fbf) == 0x5c00061d - && (dst = REG_SRCDST (insn1)) >= (R0_REGNUM + 4)) - { - save_addr = frame_addr + ((dst - R0_REGNUM) * 4); - fsr->regs[G0_REGNUM+13] = save_addr; - ip = next_ip; -#if 0 /* We'll need this once there is a subsequent instruction examined. */ - next_ip = NEXT_PROLOGUE_INSN (ip, limit, &insn1, &insn2); -#endif - } - - return (ip); -} - -/* Given an ip value corresponding to the start of a function, - return the ip of the first instruction after the function - prologue. */ - -CORE_ADDR -skip_prologue (ip) - CORE_ADDR (ip); -{ - struct frame_saved_regs saved_regs_dummy; - struct symtab_and_line sal; - CORE_ADDR limit; - - sal = find_pc_line (ip, 0); - limit = (sal.end) ? sal.end : 0xffffffff; - - return (examine_prologue (ip, limit, (FRAME_ADDR) 0, &saved_regs_dummy)); -} - -/* 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. - - We cache the result of doing this in the frame_cache_obstack, since - it is fairly expensive. */ - -void -frame_find_saved_regs (fi, fsr) - struct frame_info *fi; - struct frame_saved_regs *fsr; -{ - register CORE_ADDR next_addr; - register CORE_ADDR *saved_regs; - register int regnum; - register struct frame_saved_regs *cache_fsr; - extern struct obstack frame_cache_obstack; - CORE_ADDR ip; - struct symtab_and_line sal; - CORE_ADDR limit; - - if (!fi->fsr) - { - cache_fsr = (struct frame_saved_regs *) - obstack_alloc (&frame_cache_obstack, - sizeof (struct frame_saved_regs)); - bzero (cache_fsr, sizeof (struct frame_saved_regs)); - fi->fsr = cache_fsr; - - /* Find the start and end of the function prologue. If the PC - is in the function prologue, we only consider the part that - has executed already. */ - - ip = get_pc_function_start (fi->pc); - sal = find_pc_line (ip, 0); - limit = (sal.end && sal.end < fi->pc) ? sal.end: fi->pc; - - examine_prologue (ip, limit, fi->frame, cache_fsr); - - /* Record the addresses at which the local registers are saved. - Strictly speaking, we should only do this for non-leaf procedures, - but no one will ever look at these values if it is a leaf procedure, - since local registers are always caller-saved. */ - - next_addr = (CORE_ADDR) fi->frame; - saved_regs = cache_fsr->regs; - for (regnum = R0_REGNUM; regnum <= R15_REGNUM; regnum++) - { - *saved_regs++ = next_addr; - next_addr += 4; - } - - cache_fsr->regs[FP_REGNUM] = cache_fsr->regs[PFP_REGNUM]; - } - - *fsr = *fi->fsr; - - /* Fetch the value of the sp from memory every time, since it - is conceivable that it has changed since the cache was flushed. - This unfortunately undoes much of the savings from caching the - saved register values. I suggest adding an argument to - get_frame_saved_regs () specifying the register number we're - interested in (or -1 for all registers). This would be passed - through to FRAME_FIND_SAVED_REGS (), permitting more efficient - computation of saved register addresses (e.g., on the i960, - we don't have to examine the prologue to find local registers). - -- markf@wrs.com - FIXME, we don't need to refetch this, since the cache is cleared - every time the child process is restarted. If GDB itself - modifies SP, it has to clear the cache by hand (does it?). -gnu */ - - fsr->regs[SP_REGNUM] = read_memory_integer (fsr->regs[SP_REGNUM], 4); -} - -/* Return the address of the argument block for the frame - described by FI. Returns 0 if the address is unknown. */ - -CORE_ADDR -frame_args_address (fi, must_be_correct) - struct frame_info *fi; -{ - register FRAME frame; - struct frame_saved_regs fsr; - CORE_ADDR ap; - - /* If g14 was saved in the frame by the function prologue code, return - the saved value. If the frame is current and we are being sloppy, - return the value of g14. Otherwise, return zero. */ - - frame = FRAME_INFO_ID (fi); - get_frame_saved_regs (fi, &fsr); - if (fsr.regs[G14_REGNUM]) - ap = read_memory_integer (fsr.regs[G14_REGNUM],4); - else { - if (must_be_correct) - return 0; /* Don't cache this result */ - if (get_next_frame (frame)) - ap = 0; - else - ap = read_register (G14_REGNUM); - } - fi->arg_pointer = ap; /* Cache it for next time */ - return ap; -} - -/* Return the address of the return struct for the frame - described by FI. Returns 0 if the address is unknown. */ - -CORE_ADDR -frame_struct_result_address (fi) - struct frame_info *fi; -{ - register FRAME frame; - struct frame_saved_regs fsr; - CORE_ADDR ap; - - /* If the frame is non-current, check to see if g14 was saved in the - frame by the function prologue code; return the saved value if so, - zero otherwise. If the frame is current, return the value of g14. - - FIXME, shouldn't this use the saved value as long as we are past - the function prologue, and only use the current value if we have - no saved value and are at TOS? -- gnu@cygnus.com */ - - frame = FRAME_INFO_ID (fi); - if (get_next_frame (frame)) { - get_frame_saved_regs (fi, &fsr); - if (fsr.regs[G13_REGNUM]) - ap = read_memory_integer (fsr.regs[G13_REGNUM],4); - else - ap = 0; - } else { - ap = read_register (G13_REGNUM); - } - return ap; -} - -/* Return address to which the currently executing leafproc will return, - or 0 if ip is not in a leafproc (or if we can't tell if it is). - - Do this by finding the starting address of the routine in which ip lies. - If the instruction there is "mov g14, gx" (where x is in [0,7]), this - is a leafproc and the return address is in register gx. Well, this is - true unless the return address points at a RET instruction in the current - procedure, which indicates that we have a 'dual entry' routine that - has been entered through the CALL entry point. */ - -CORE_ADDR -leafproc_return (ip) - CORE_ADDR ip; /* ip from currently executing function */ -{ - int i; - register struct misc_function *mf; - char *p; - int dst; - unsigned int insn1, insn2; - CORE_ADDR return_addr; - char *index (); - - if ((i = find_pc_misc_function (ip)) >= 0) - { - mf = &misc_function_vector[i]; - if ((p = index (mf->name, '.')) && !strcmp (p, ".lf")) - { - if (next_insn (mf->address, &insn1, &insn2) - && (insn1 & 0xff87ffff) == 0x5c80161e /* mov g14, gx */ - && (dst = REG_SRCDST (insn1)) <= G0_REGNUM + 7) - { - /* Get the return address. If the "mov g14, gx" - instruction hasn't been executed yet, read - the return address from g14; otherwise, read it - from the register into which g14 was moved. */ - - return_addr = read_register ((ip == mf->address) - ? G14_REGNUM : dst); - - /* We know we are in a leaf procedure, but we don't know - whether the caller actually did a "bal" to the ".lf" - entry point, or a normal "call" to the non-leaf entry - point one instruction before. In the latter case, the - return address will be the address of a "ret" - instruction within the procedure itself. We test for - this below. */ - - if (!next_insn (return_addr, &insn1, &insn2) - || (insn1 & 0xff000000) != 0xa000000 /* ret */ - || find_pc_misc_function (return_addr) != i) - return (return_addr); - } - } - } - - return (0); -} - -/* 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 - some instructions. - On the i960, the frame *is* set up immediately after the call, - unless the function is a leaf procedure. */ - -CORE_ADDR -saved_pc_after_call (frame) - FRAME frame; -{ - CORE_ADDR saved_pc; - CORE_ADDR get_frame_pc (); - - saved_pc = leafproc_return (get_frame_pc (frame)); - if (!saved_pc) - saved_pc = FRAME_SAVED_PC (frame); - - return (saved_pc); -} - -/* Discard from the stack the innermost frame, - restoring all saved registers. */ - -pop_frame () -{ - register struct frame_info *current_fi, *prev_fi; - register int i; - CORE_ADDR save_addr; - CORE_ADDR leaf_return_addr; - struct frame_saved_regs fsr; - char local_regs_buf[16 * 4]; - - current_fi = get_frame_info (get_current_frame ()); - - /* First, undo what the hardware does when we return. - If this is a non-leaf procedure, restore local registers from - the save area in the calling frame. Otherwise, load the return - address obtained from leafproc_return () into the rip. */ - - leaf_return_addr = leafproc_return (current_fi->pc); - if (!leaf_return_addr) - { - /* Non-leaf procedure. Restore local registers, incl IP. */ - prev_fi = get_frame_info (get_prev_frame (FRAME_INFO_ID (current_fi))); - read_memory (prev_fi->frame, local_regs_buf, sizeof (local_regs_buf)); - write_register_bytes (REGISTER_BYTE (R0_REGNUM), local_regs_buf, - sizeof (local_regs_buf)); - - /* Restore frame pointer. */ - write_register (FP_REGNUM, prev_fi->frame); - } - else - { - /* Leaf procedure. Just restore the return address into the IP. */ - write_register (RIP_REGNUM, leaf_return_addr); - } - - /* Now restore any global regs that the current function had saved. */ - get_frame_saved_regs (current_fi, &fsr); - for (i = G0_REGNUM; i < G14_REGNUM; i++) - { - if (save_addr = fsr.regs[i]) - write_register (i, read_memory_integer (save_addr, 4)); - } - - /* Flush the frame cache, create a frame for the new innermost frame, - and make it the current frame. */ - - flush_cached_frames (); - set_current_frame (create_new_frame (read_register (FP_REGNUM), read_pc ())); -} - -/* Print out text describing a "signal number" with which the i80960 halted. - - See the file "fault.c" in the nindy monitor source code for a list - of stop codes. */ - -void -print_fault( siggnal ) - int siggnal; /* Signal number, as returned by target_wait() */ -{ - static char unknown[] = "Unknown fault or trace"; - static char *sigmsgs[] = { - /* FAULTS */ - "parallel fault", /* 0x00 */ - unknown, /* 0x01 */ - "operation fault", /* 0x02 */ - "arithmetic fault", /* 0x03 */ - "floating point fault", /* 0x04 */ - "constraint fault", /* 0x05 */ - "virtual memory fault", /* 0x06 */ - "protection fault", /* 0x07 */ - "machine fault", /* 0x08 */ - "structural fault", /* 0x09 */ - "type fault", /* 0x0a */ - "reserved (0xb) fault", /* 0x0b */ - "process fault", /* 0x0c */ - "descriptor fault", /* 0x0d */ - "event fault", /* 0x0e */ - "reserved (0xf) fault", /* 0x0f */ - - /* TRACES */ - "single-step trace", /* 0x10 */ - "branch trace", /* 0x11 */ - "call trace", /* 0x12 */ - "return trace", /* 0x13 */ - "pre-return trace", /* 0x14 */ - "supervisor call trace",/* 0x15 */ - "breakpoint trace", /* 0x16 */ - }; -# define NUMMSGS ((int)( sizeof(sigmsgs) / sizeof(sigmsgs[0]) )) - - if (siggnal < NSIG) { - printf ("\nProgram received signal %d, %s\n", - siggnal, - sys_siglist[siggnal]); - } else { - /* The various target_wait()s bias the 80960 "signal number" - by adding NSIG to it, so it won't get confused with any - of the Unix signals elsewhere in GDB. We need to - "unbias" it before using it. */ - siggnal -= NSIG; - - printf("Program stopped for reason #%d: %s.\n", siggnal, - (siggnal < NUMMSGS && siggnal >= 0)? - sigmsgs[siggnal] : unknown ); - } -} - -/* Initialization stub */ - -_initialize_i960_tdep () -{ - check_host (); -} diff --git a/gdb/ieee-float.c b/gdb/ieee-float.c deleted file mode 100644 index 69a60f2e4c8..00000000000 --- a/gdb/ieee-float.c +++ /dev/null @@ -1,150 +0,0 @@ -/* IEEE floating point support routines, for GDB, the GNU Debugger. - Copyright (C) 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include "defs.h" -#include "param.h" -#include "ieee-float.h" -#include /* ldexp */ - -/* Convert an IEEE extended float to a double. - FROM is the address of the extended float. - Store the double in *TO. */ - -void -ieee_extended_to_double (ext_format, from, to) - struct ext_format *ext_format; - char *from; - double *to; -{ - unsigned char *ufrom = (unsigned char *)from; - double dto; - unsigned long mant0, mant1, exponent; - - bcopy (&from[MANBYTE_H], &mant0, 4); - bcopy (&from[MANBYTE_L], &mant1, 4); - exponent = ((ufrom[EXPBYTE_H] & (unsigned char)~SIGNMASK) << 8) | ufrom[EXPBYTE_L]; - -#if 0 - /* We can't do anything useful with a NaN anyway, so ignore its - difference. It will end up as Infinity or something close. */ - if (exponent == EXT_EXP_NAN) { - /* We have a NaN source. */ - dto = 0.123456789; /* Not much else useful to do -- we don't know if - the host system even *has* NaNs, nor how to - generate an innocuous one if it does. */ - } else -#endif - if (exponent == 0 && mant0 == 0 && mant1 == 0) { - dto = 0; - } else { - /* Build the result algebraically. Might go infinite, underflow, etc; - who cares. */ - mant0 |= 0x80000000; - dto = ldexp ((double)mant0, exponent - EXT_EXP_BIAS - 31); - dto += ldexp ((double)mant1, exponent - EXT_EXP_BIAS - 31 - 32); - if (ufrom[EXPBYTE_H] & SIGNMASK) /* If negative... */ - dto = -dto; /* ...negate. */ - } - *to = dto; -} - -/* The converse: convert the double *FROM to an extended float - and store where TO points. */ - -void -double_to_ieee_extended (ext_format, from, to) - struct ext_format *ext_format; - double *from; - char *to; -{ - double dfrom = *from; - unsigned long twolongs[2]; - unsigned long mant0, mant1, exponent; - unsigned char tobytes[8]; - - bzero (to, TOTALSIZE); - if (dfrom == 0) - return; /* Result is zero */ - if (dfrom != dfrom) { - /* From is NaN */ - to[EXPBYTE_H] = (unsigned char)(EXT_EXP_NAN >> 8); - to[EXPBYTE_L] = (unsigned char)EXT_EXP_NAN; - to[MANBYTE_H] = 1; /* Be sure it's not infinity, but NaN value is irrel */ - return; /* Result is NaN */ - } - if (dfrom < 0) - to[SIGNBYTE] |= SIGNMASK; /* Set negative sign */ - /* How to tell an infinity from an ordinary number? FIXME-someday */ - - /* The following code assumes that the host has IEEE doubles. FIXME-someday. - It also assumes longs are 32 bits! FIXME-someday. */ - bcopy (from, twolongs, 8); - bcopy (from, tobytes, 8); -#if HOST_BYTE_ORDER == BIG_ENDIAN - exponent = ((tobytes[1] & 0xF0) >> 4) | (tobytes[0] & 0x7F) << 4; - mant0 = (twolongs[0] << 11) | twolongs[1] >> 21; - mant1 = (twolongs[1] << 11); -#else - exponent = ((tobytes[6] & 0xF0) >> 4) | (tobytes[7] & 0x7F) << 4; - mant0 = (twolongs[1] << 11) | twolongs[0] >> 21; - mant1 = (twolongs[0] << 11); -#endif - - /* Fiddle with leading 1-bit, implied in double, explicit in extended. */ - if (exponent == 0) - mant0 &= 0x7FFFFFFF; - else - mant0 |= 0x80000000; - - exponent -= DBL_EXP_BIAS; /* Get integer exp */ - exponent += EXT_EXP_BIAS; /* Offset for extended */ - - /* OK, now store it in extended format. */ - to[EXPBYTE_H] |= (unsigned char)(exponent >> 8); /* Retain sign */ - to[EXPBYTE_L] = (unsigned char) exponent; - - bcopy (&mant0, &to[MANBYTE_H], 4); - bcopy (&mant1, &to[MANBYTE_L], 4); -} - - -#ifdef DEBUG - -/* Test some numbers to see that extended/double conversion works for them. */ - -ieee_test (n) - int n; -{ - union { double d; int i[2]; } di; - double result; - int i; - char exten[16]; - extern struct ext_format ext_format_68881; - - for (i = 0; i < n; i++) { - di.i[0] = (random() << 16) | (random() & 0xffff); - di.i[1] = (random() << 16) | (random() & 0xffff); - double_to_ieee_extended (&ext_format_68881, &di.d, exten); - ieee_extended_to_double (&ext_format_68881, exten, &result); - if (di.d != result) - printf ("Differ: %x %x %g => %x %x %g\n", di.d, di.d, result, result); - } -} - -#endif diff --git a/gdb/ieee-float.h b/gdb/ieee-float.h deleted file mode 100644 index bbe9e033756..00000000000 --- a/gdb/ieee-float.h +++ /dev/null @@ -1,66 +0,0 @@ -/* IEEE floating point support declarations, for GDB, the GNU Debugger. - Copyright (C) 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Parameters for extended float format: */ - -struct ext_format { - unsigned totalsize; /* Total size of extended number */ - unsigned signbyte; /* Byte number of sign bit */ - unsigned char signmask; /* Mask for sign bit */ - unsigned expbyte_h; /* High byte of exponent */ - unsigned expbyte_l; /* Low byte of exponent */ - unsigned manbyte_h; /* High byte of mantissa */ - unsigned manbyte_l; /* Low byte of mantissa */ -}; - -#define TOTALSIZE ext_format->totalsize -#define SIGNBYTE ext_format->signbyte -#define SIGNMASK ext_format->signmask -#define EXPBYTE_H ext_format->expbyte_h -#define EXPBYTE_L ext_format->expbyte_l -#define MANBYTE_H ext_format->manbyte_h -#define MANBYTE_L ext_format->manbyte_l - -/* Actual ext_format structs for various machines are in the *-tdep.c file - for each machine. */ - -#define EXT_EXP_NAN 0x7FFF /* Exponent value that indicates NaN */ -#define EXT_EXP_BIAS 0x3FFF /* Amount added to "true" exponent for ext */ -#define DBL_EXP_BIAS 0x3FF /* Ditto, for doubles */ - -/* Convert an IEEE extended float to a double. - FROM is the address of the extended float. - Store the double in *TO. */ - -extern void -ieee_extended_to_double ( -#ifdef __STDC__ - struct ext_format *ext_format, char *from, double *to -#endif -); - -/* The converse: convert the double *FROM to an extended float - and store where TO points. */ - -void -double_to_ieee_extended ( -#ifdef __STDC__ - struct ext_format *ext_format, double *from, char *to -#endif -); diff --git a/gdb/infcmd.c b/gdb/infcmd.c deleted file mode 100644 index f387ba0308c..00000000000 --- a/gdb/infcmd.c +++ /dev/null @@ -1,1116 +0,0 @@ -/* Memory-access and commands for inferior process, for GDB. - Copyright (C) 1986, 1987, 1988, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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 1, or (at your option) -any later version. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include -#include -#include -#include "defs.h" -#include "param.h" -#include "symtab.h" -#include "frame.h" -#include "inferior.h" -#include "environ.h" -#include "value.h" -#include "gdbcmd.h" -#include "gdbcore.h" -#include "target.h" - -extern char *sys_siglist[]; - -extern void until_break_command (); /* breakpoint.c */ - -#define ERROR_NO_INFERIOR \ - if (!target_has_execution) error ("The program is not being run."); - -/* String containing arguments to give to the program, separated by spaces. - Empty string (pointer to '\0') means no args. */ - -static char *inferior_args; - -/* File name for default use for standard in/out in the inferior. */ - -char *inferior_io_terminal; - -/* Pid of our debugged inferior, or 0 if no inferior now. - Since various parts of infrun.c test this to see whether there is a program - being debugged it should be nonzero (currently 3 is used) for remote - debugging. */ - -int inferior_pid; - -/* Last signal that the inferior received (why it stopped). */ - -int stop_signal; - -/* Address at which inferior stopped. */ - -CORE_ADDR stop_pc; - -/* Stack frame when program stopped. */ - -FRAME_ADDR stop_frame_address; - -/* Chain containing status of breakpoint(s) that we have stopped at. */ - -bpstat stop_bpstat; - -/* Flag indicating that a command has proceeded the inferior past the - current breakpoint. */ - -int breakpoint_proceeded; - -/* Nonzero if stopped due to a step command. */ - -int stop_step; - -/* Nonzero if stopped due to completion of a stack dummy routine. */ - -int stop_stack_dummy; - -/* Nonzero if stopped due to a random (unexpected) signal in inferior - process. */ - -int stopped_by_random_signal; - -/* Range to single step within. - If this is nonzero, respond to a single-step signal - by continuing to step if the pc is in this range. */ - -CORE_ADDR step_range_start; /* Inclusive */ -CORE_ADDR step_range_end; /* Exclusive */ - -/* Stack frame address as of when stepping command was issued. - This is how we know when we step into a subroutine call, - and how to set the frame for the breakpoint used to step out. */ - -FRAME_ADDR step_frame_address; - -/* 1 means step over all subroutine calls. - -1 means step over calls to undebuggable functions. */ - -int step_over_calls; - -/* If stepping, nonzero means step count is > 1 - so don't print frame next time inferior stops - if it stops due to stepping. */ - -int step_multi; - -/* Environment to use for running inferior, - in format described in environ.h. */ - -struct environ *inferior_environ; - -CORE_ADDR read_pc (); -void breakpoint_clear_ignore_counts (); - - -/* ARGSUSED */ -void -tty_command (file, from_tty) - char *file; - int from_tty; -{ - if (file == 0) - error_no_arg ("terminal name for running target process"); - - inferior_io_terminal = savestring (file, strlen (file)); -} - -static void -run_command (args, from_tty) - char *args; - int from_tty; -{ - char *exec_file; - - dont_repeat (); - - if (inferior_pid) - { - if ( - !query ("The program being debugged has been started already.\n\ -Start it from the beginning? ")) - error ("Program not restarted."); - target_kill ((char *)0, 0); - } - - exec_file = (char *) get_exec_file (0); - - /* The exec file is re-read every time we do an inferior_died, so - we just have to worry about the symbol file. */ - reread_symbols (); - - if (args) - { - char *cmd; - cmd = concat ("set args ", args, ""); - make_cleanup (free, cmd); - execute_command (cmd, from_tty); - } - - if (from_tty) - { - printf ("Starting program: %s %s\n", - exec_file? exec_file: "", inferior_args); - fflush (stdout); - } - - target_create_inferior (exec_file, inferior_args, - environ_vector (inferior_environ)); -} - -void -continue_command (proc_count_exp, from_tty) - char *proc_count_exp; - int from_tty; -{ - ERROR_NO_INFERIOR; - - /* If have argument, set proceed count of breakpoint we stopped at. */ - - if (proc_count_exp != NULL) - { - bpstat bs = stop_bpstat; - int num = bpstat_num (&bs); - if (num == 0 && from_tty) - { - printf_filtered - ("Not stopped at any breakpoint; argument ignored.\n"); - } - while (num != 0) - { - set_ignore_count (num, - parse_and_eval_address (proc_count_exp) - 1, - from_tty); - /* set_ignore_count prints a message ending with a period. - So print two spaces before "Continuing.". */ - if (from_tty) - printf (" "); - num = bpstat_num (&bs); - } - } - - if (from_tty) - printf ("Continuing.\n"); - - clear_proceed_status (); - - proceed ((CORE_ADDR) -1, -1, 0); -} - -/* Step until outside of current statement. */ -static void step_1 (); - -/* ARGSUSED */ -static void -step_command (count_string, from_tty) - char * count_string; - int from_tty; -{ - step_1 (0, 0, count_string); -} - -/* Likewise, but skip over subroutine calls as if single instructions. */ - -/* ARGSUSED */ -static void -next_command (count_string, from_tty) - char * count_string; - int from_tty; -{ - step_1 (1, 0, count_string); -} - -/* Likewise, but step only one instruction. */ - -/* ARGSUSED */ -static void -stepi_command (count_string, from_tty) - char * count_string; - int from_tty; -{ - step_1 (0, 1, count_string); -} - -/* ARGSUSED */ -static void -nexti_command (count_string, from_tty) - char * count_string; - int from_tty; -{ - step_1 (1, 1, count_string); -} - -static void -step_1 (skip_subroutines, single_inst, count_string) - int skip_subroutines; - int single_inst; - char *count_string; -{ - register int count = 1; - FRAME fr; - - ERROR_NO_INFERIOR; - count = count_string ? parse_and_eval_address (count_string) : 1; - - for (; count > 0; count--) - { - clear_proceed_status (); - - - fr = get_current_frame (); - if (!fr) /* Avoid coredump here. Why tho? */ - error ("No current frame"); - step_frame_address = FRAME_FP (fr); - - if (! single_inst) - { - find_pc_line_pc_range (stop_pc, &step_range_start, &step_range_end); - if (step_range_end == 0) - { - int misc; - - misc = find_pc_misc_function (stop_pc); - target_terminal_ours (); - printf ("Current function has no line number information.\n"); - fflush (stdout); - - /* No info or after _etext ("Can't happen") */ - if (misc == -1 || misc == misc_function_count - 1) - error ("No data available on pc function."); - - printf ("Single stepping until function exit.\n"); - fflush (stdout); - - step_range_start = misc_function_vector[misc].address; - step_range_end = misc_function_vector[misc + 1].address; - } - } - else - { - /* Say we are stepping, but stop after one insn whatever it does. - Don't step through subroutine calls even to undebuggable - functions. */ - step_range_start = step_range_end = 1; - if (!skip_subroutines) - step_over_calls = 0; - } - - if (skip_subroutines) - step_over_calls = 1; - - step_multi = (count > 1); - proceed ((CORE_ADDR) -1, -1, 1); - if (! stop_step) - break; -#if defined (SHIFT_INST_REGS) - write_register (NNPC_REGNUM, read_register (NPC_REGNUM)); - write_register (NPC_REGNUM, read_register (PC_REGNUM)); -#endif - } -} - -/* Continue program at specified address. */ - -static void -jump_command (arg, from_tty) - char *arg; - int from_tty; -{ - register CORE_ADDR addr; - struct symtabs_and_lines sals; - struct symtab_and_line sal; - - ERROR_NO_INFERIOR; - - if (!arg) - error_no_arg ("starting address"); - - sals = decode_line_spec_1 (arg, 1); - if (sals.nelts != 1) - { - error ("Unreasonable jump request"); - } - - sal = sals.sals[0]; - free (sals.sals); - - if (sal.symtab == 0 && sal.pc == 0) - error ("No source file has been specified."); - - if (sal.pc == 0) - sal.pc = find_line_pc (sal.symtab, sal.line); - - { - struct symbol *fn = get_frame_function (get_current_frame ()); - struct symbol *sfn = find_pc_function (sal.pc); - if (fn != 0 && sfn != fn - && ! query ("Line %d is not in `%s'. Jump anyway? ", - sal.line, SYMBOL_NAME (fn))) - error ("Not confirmed."); - } - - if (sal.pc == 0) - error ("No line %d in file \"%s\".", sal.line, sal.symtab->filename); - - addr = ADDR_BITS_SET (sal.pc); - - if (from_tty) - printf ("Continuing at 0x%x.\n", addr); - - clear_proceed_status (); - proceed (addr, 0, 0); -} - -/* Continue program giving it specified signal. */ - -static void -signal_command (signum_exp, from_tty) - char *signum_exp; - int from_tty; -{ - register int signum; - - dont_repeat (); /* Too dangerous. */ - ERROR_NO_INFERIOR; - - if (!signum_exp) - error_no_arg ("signal number"); - - signum = parse_and_eval_address (signum_exp); - - if (from_tty) - printf ("Continuing with signal %d.\n", signum); - - clear_proceed_status (); - proceed (stop_pc, signum, 0); -} - -/* Execute a "stack dummy", a piece of code stored in the stack - by the debugger to be executed in the inferior. - - To call: first, do PUSH_DUMMY_FRAME. - Then push the contents of the dummy. It should end with a breakpoint insn. - Then call here, passing address at which to start the dummy. - - The contents of all registers are saved before the dummy frame is popped - and copied into the buffer BUFFER. - - The dummy's frame is automatically popped whenever that break is hit. - If that is the first time the program stops, run_stack_dummy - returns to its caller with that frame already gone. - Otherwise, the caller never gets returned to. */ - -/* 4 => return instead of letting the stack dummy run. */ - -static int stack_dummy_testing = 0; - -void -run_stack_dummy (addr, buffer) - CORE_ADDR addr; - char buffer[REGISTER_BYTES]; -{ - /* Now proceed, having reached the desired place. */ - clear_proceed_status (); - if (stack_dummy_testing & 4) - { - POP_FRAME; - return; - } - proceed_to_finish = 1; /* We want stop_registers, please... */ - proceed (addr, 0, 0); - - if (!stop_stack_dummy) - /* This used to say - "Cannot continue previously requested operation". */ - error ("\ -The program being debugged stopped while in a function called from GDB.\n\ -The expression which contained the function call has been discarded."); - - /* On return, the stack dummy has been popped already. */ - - bcopy (stop_registers, buffer, sizeof stop_registers); -} - -/* Proceed until we reach a different source line with pc greater than - our current one or exit the function. We skip calls in both cases. - - Note that eventually this command should probably be changed so - that only source lines are printed out when we hit the breakpoint - we set. I'm going to postpone this until after a hopeful rewrite - of wait_for_inferior and the proceed status code. -- randy */ - -/* ARGSUSED */ -void -until_next_command (from_tty) - int from_tty; -{ - FRAME frame; - CORE_ADDR pc; - struct symbol *func; - struct symtab_and_line sal; - - clear_proceed_status (); - - frame = get_current_frame (); - - /* Step until either exited from this function or greater - than the current line (if in symbolic section) or pc (if - not). */ - - pc = read_pc (); - func = find_pc_function (pc); - - if (!func) - { - int misc_func = find_pc_misc_function (pc); - - if (misc_func != -1) - error ("Execution is not within a known function."); - - step_range_start = misc_function_vector[misc_func].address; - step_range_end = pc; - } - else - { - sal = find_pc_line (pc, 0); - - step_range_start = BLOCK_START (SYMBOL_BLOCK_VALUE (func)); - step_range_end = sal.end; - } - - step_over_calls = 1; - step_frame_address = FRAME_FP (frame); - - step_multi = 0; /* Only one call to proceed */ - - proceed ((CORE_ADDR) -1, -1, 1); -} - -void -until_command (arg, from_tty) - char *arg; - int from_tty; -{ - if (!target_has_execution) - error ("The program is not running."); - if (arg) - until_break_command (arg, from_tty); - else - until_next_command (from_tty); -} - -/* "finish": Set a temporary breakpoint at the place - the selected frame will return to, then continue. */ - -static void -finish_command (arg, from_tty) - char *arg; - int from_tty; -{ - struct symtab_and_line sal; - register FRAME frame; - struct frame_info *fi; - register struct symbol *function; - - if (arg) - error ("The \"finish\" command does not take any arguments."); - if (!target_has_execution) - error ("The program is not running."); - if (selected_frame == NULL) - error ("No selected frame."); - - frame = get_prev_frame (selected_frame); - if (frame == 0) - error ("\"finish\" not meaningful in the outermost frame."); - - clear_proceed_status (); - - fi = get_frame_info (frame); - sal = find_pc_line (fi->pc, 0); - sal.pc = fi->pc; - set_momentary_breakpoint (sal, frame); - - /* Find the function we will return from. */ - - fi = get_frame_info (selected_frame); - function = find_pc_function (fi->pc); - - if (from_tty) - { - printf ("Run till exit from "); - print_selected_frame (); - } - - proceed_to_finish = 1; /* We want stop_registers, please... */ - proceed ((CORE_ADDR) -1, -1, 0); - - if (bpstat_momentary_breakpoint (stop_bpstat) && function != 0) - { - struct type *value_type; - register value val; - CORE_ADDR funcaddr; - - value_type = TYPE_TARGET_TYPE (SYMBOL_TYPE (function)); - if (!value_type) - fatal ("internal: finish_command: function has no target type"); - - if (TYPE_CODE (value_type) == TYPE_CODE_VOID) - return; - - funcaddr = BLOCK_START (SYMBOL_BLOCK_VALUE (function)); - - val = value_being_returned (value_type, stop_registers, - using_struct_return (value_of_variable (function), - funcaddr, - value_type, - BLOCK_GCC_COMPILED (SYMBOL_BLOCK_VALUE (function)))); - - printf ("Value returned is $%d = ", record_latest_value (val)); - value_print (val, stdout, 0, Val_no_prettyprint); - putchar ('\n'); - } -} - -/* ARGSUSED */ -static void -program_info (args, from_tty) - char *args; - int from_tty; -{ - bpstat bs = stop_bpstat; - int num = bpstat_num (&bs); - - if (!target_has_execution) - { - printf ("The program being debugged is not being run.\n"); - return; - } - - target_files_info (); - printf ("Program stopped at 0x%x.\n", stop_pc); - if (stop_step) - printf ("It stopped after being stepped.\n"); - else if (num != 0) - { - /* There may be several breakpoints in the same place, so this - isn't as strange as it seems. */ - while (num != 0) - { - if (num < 0) - printf ("It stopped at a breakpoint that has since been deleted.\n"); - else - printf ("It stopped at breakpoint %d.\n", num); - num = bpstat_num (&bs); - } - } - else if (stop_signal) { -#ifdef PRINT_RANDOM_SIGNAL - PRINT_RANDOM_SIGNAL (stop_signal); -#else - printf ("It stopped with signal %d (%s).\n", - stop_signal, - (stop_signal > NSIG)? "unknown": sys_siglist[stop_signal]); -#endif - } - - if (!from_tty) - printf ("Type \"info stack\" or \"info registers\" for more information.\n"); -} - -static void -environment_info (var) - char *var; -{ - if (var) - { - register char *val = get_in_environ (inferior_environ, var); - if (val) - printf ("%s = %s\n", var, val); - else - printf ("Environment variable \"%s\" not defined.\n", var); - } - else - { - register char **vector = environ_vector (inferior_environ); - while (*vector) - printf ("%s\n", *vector++); - } -} - -static void -set_environment_command (arg) - char *arg; -{ - register char *p, *val, *var; - int nullset = 0; - - if (arg == 0) - error_no_arg ("environment variable and value"); - - /* Find seperation between variable name and value */ - p = (char *) strchr (arg, '='); - val = (char *) strchr (arg, ' '); - - if (p != 0 && val != 0) - { - /* We have both a space and an equals. If the space is before the - equals and the only thing between the two is more space, use - the equals */ - if (p > val) - while (*val == ' ') - val++; - - /* Take the smaller of the two. If there was space before the - "=", they will be the same right now. */ - p = arg + min (p - arg, val - arg); - } - else if (val != 0 && p == 0) - p = val; - - if (p == arg) - error_no_arg ("environment variable to set"); - - if (p == 0 || p[1] == 0) - { - nullset = 1; - if (p == 0) - p = arg + strlen (arg); /* So that savestring below will work */ - } - else - { - /* Not setting variable value to null */ - val = p + 1; - while (*val == ' ' || *val == '\t') - val++; - } - - while (p != arg && (p[-1] == ' ' || p[-1] == '\t')) p--; - - var = savestring (arg, p - arg); - if (nullset) - { - printf ("Setting environment variable \"%s\" to null value.\n", var); - set_in_environ (inferior_environ, var, ""); - } - else - set_in_environ (inferior_environ, var, val); - free (var); -} - -static void -unset_environment_command (var, from_tty) - char *var; - int from_tty; -{ - if (var == 0) - { - /* If there is no argument, delete all environment variables. - Ask for confirmation if reading from the terminal. */ - if (!from_tty || query ("Delete all environment variables? ")) - { - free_environ (inferior_environ); - inferior_environ = make_environ (); - } - } - else - unset_in_environ (inferior_environ, var); -} - -/* Handle the execution path (PATH variable) */ - -const static char path_var_name[] = "PATH"; - -/* ARGSUSED */ -void -path_info (args, from_tty) - char *args; - int from_tty; -{ - printf ("Executable and object file path: %s\n", - get_in_environ (inferior_environ, path_var_name)); -} - -/* Add zero or more directories to the front of the execution path. */ - -void -path_command (dirname, from_tty) - char *dirname; - int from_tty; -{ - char *exec_path; - - dont_repeat (); - exec_path = strsave (get_in_environ (inferior_environ, path_var_name)); - mod_path (dirname, &exec_path); - set_in_environ (inferior_environ, path_var_name, exec_path); - free (exec_path); - if (from_tty) - path_info ((char *)NULL, from_tty); -} - -CORE_ADDR -read_pc () -{ - return ADDR_BITS_REMOVE ((CORE_ADDR) read_register (PC_REGNUM)); -} - -void -write_pc (val) - CORE_ADDR val; -{ - write_register (PC_REGNUM, (long) val); -#ifdef NPC_REGNUM - write_register (NPC_REGNUM, (long) val+4); -#endif - pc_changed = 0; -} - -char *reg_names[] = REGISTER_NAMES; - -/* Print out the machine register regnum. If regnum is -1, - print all registers. - For most machines, having all_registers_info() print the - register(s) one per line is good enough. If a different format - is required, (eg, for SPARC or Pyramid 90x, which both have - lots of regs), or there is an existing convention for showing - all the registers, define the macro DO_REGISTERS_INFO(regnum) - to provide that format. */ -#if !defined (DO_REGISTERS_INFO) -#define DO_REGISTERS_INFO(regnum) do_registers_info(regnum) -static void do_registers_info (regnum) - int regnum; -{ - register int i; - - if (regnum == -1) - printf_filtered ( - "Register Contents (relative to selected stack frame)\n\n"); - - for (i = 0; i < NUM_REGS; i++) - { - char raw_buffer[MAX_REGISTER_RAW_SIZE]; - char virtual_buffer[MAX_REGISTER_VIRTUAL_SIZE]; - - if (regnum != -1 && i != regnum) - continue; - - fputs_filtered (reg_names[i], stdout); - print_spaces_filtered (15 - strlen (reg_names[i]), stdout); - - /* Get the data in raw format, then convert also to virtual format. */ - if (read_relative_register_raw_bytes (i, raw_buffer)) - { - printf_filtered ("Invalid register contents\n"); - continue; - } - - target_convert_to_virtual (i, raw_buffer, virtual_buffer); - - /* If virtual format is floating, print it that way, and in raw hex. */ - if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (i)) == TYPE_CODE_FLT - && ! INVALID_FLOAT (virtual_buffer, REGISTER_VIRTUAL_SIZE (i))) - { - register int j; - - val_print (REGISTER_VIRTUAL_TYPE (i), virtual_buffer, 0, - stdout, 0, 1, 0, Val_pretty_default); - - printf_filtered ("\t(raw 0x"); - for (j = 0; j < REGISTER_RAW_SIZE (i); j++) - printf_filtered ("%02x", (unsigned char)raw_buffer[j]); - printf_filtered (")"); - } - -/* FIXME! val_print probably can handle all of these cases now... */ - - /* Else if virtual format is too long for printf, - print in hex a byte at a time. */ - else if (REGISTER_VIRTUAL_SIZE (i) > sizeof (long)) - { - register int j; - printf_filtered ("0x"); - for (j = 0; j < REGISTER_VIRTUAL_SIZE (i); j++) - printf_filtered ("%02x", (unsigned char)virtual_buffer[j]); - } - /* Else print as integer in hex and in decimal. */ - else - { - val_print (REGISTER_VIRTUAL_TYPE (i), raw_buffer, 0, - stdout, 'x', 1, 0, Val_pretty_default); - printf_filtered ("\t"); - val_print (REGISTER_VIRTUAL_TYPE (i), raw_buffer, 0, - stdout, 0, 1, 0, Val_pretty_default); - } - - /* The SPARC wants to print even-numbered float regs as doubles - in addition to printing them as floats. */ -#ifdef PRINT_REGISTER_HOOK - PRINT_REGISTER_HOOK (i); -#endif - - printf_filtered ("\n"); - } -} -#endif /* no DO_REGISTERS_INFO. */ - -static void -registers_info (addr_exp) - char *addr_exp; -{ - int regnum; - - if (!target_has_registers) - error ("The program has no registers now."); - - if (addr_exp) - { - if (*addr_exp >= '0' && *addr_exp <= '9') - regnum = atoi (addr_exp); - else - { - register char *p = addr_exp; - if (p[0] == '$') - p++; - for (regnum = 0; regnum < NUM_REGS; regnum++) - if (!strcmp (p, reg_names[regnum])) - break; - if (regnum == NUM_REGS) - error ("%s: invalid register name.", addr_exp); - } - } - else - regnum = -1; - - DO_REGISTERS_INFO(regnum); -} - -/* - * TODO: - * Should save/restore the tty state since it might be that the - * program to be debugged was started on this tty and it wants - * the tty in some state other than what we want. If it's running - * on another terminal or without a terminal, then saving and - * restoring the tty state is a harmless no-op. - * This only needs to be done if we are attaching to a process. - */ - -/* - * attach_command -- - * takes a program started up outside of gdb and ``attaches'' to it. - * This stops it cold in its tracks and allows us to start tracing it. - * For this to work, we must be able to send the process a - * signal and we must have the same effective uid as the program. - */ -void -attach_command (args, from_tty) - char *args; - int from_tty; -{ - dont_repeat (); /* Not for the faint of heart */ - target_attach (args, from_tty); -} - -/* - * detach_command -- - * takes a program previously attached to and detaches it. - * The program resumes execution and will no longer stop - * on signals, etc. We better not have left any breakpoints - * in the program or it'll die when it hits one. For this - * to work, it may be necessary for the process to have been - * previously attached. It *might* work if the program was - * started via the normal ptrace (PTRACE_TRACEME). - */ - -static void -detach_command (args, from_tty) - char *args; - int from_tty; -{ - dont_repeat (); /* Not for the faint of heart */ - target_detach (args, from_tty); -} - -/* ARGSUSED */ -static void -float_info (addr_exp) - char *addr_exp; -{ -#ifdef FLOAT_INFO - FLOAT_INFO; -#else - printf ("No floating point info available for this processor.\n"); -#endif -} - -struct cmd_list_element *unsetlist = NULL; - -/* ARGSUSED */ -static void -unset_command (args, from_tty) - char *args; - int from_tty; -{ - printf ("\"unset\" must be followed by the name of an unset subcommand.\n"); - help_list (unsetlist, "unset ", -1, stdout); -} - -void -_initialize_infcmd () -{ - struct cmd_list_element *c; - - add_com ("tty", class_run, tty_command, - "Set terminal for future runs of program being debugged."); - - add_show_from_set - (add_set_cmd ("args", class_run, var_string_noescape, (char *)&inferior_args, - -"Set arguments 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), - &showlist); - - c = add_cmd - ("environment", no_class, environment_info, - "The environment to give the program, or one variable's value.\n\ -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; - - add_prefix_cmd ("unset", no_class, unset_command, - "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; - - c = add_cmd ("environment", class_run, set_environment_command, - "Set environment variable value to give the program.\n\ -Arguments are VAR VALUE where VAR is variable name and VALUE is value.\n\ -VALUES of environment variables are uninterpreted strings.\n\ -This does not affect the program until the next \"run\" command.", - &setlist); - c->completer = noop_completer; - - add_com ("path", class_files, path_command, - "Add directory DIR(s) to beginning of search path for object files.\n\ -$cwd in the path means the current working directory.\n\ -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."); - - add_info ("path", path_info, - "Current search path for finding object files.\n\ -$cwd in the path means the current working directory.\n\ -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."); - - add_com ("attach", class_run, attach_command, - "Attach to a process or file outside of GDB.\n\ -This command attaches to another target, of the same type as your last\n\ -`target' command (`info files' will show your target stack).\n\ -The command may take as argument a process id or a device file.\n\ -For a process id, you must have permission to send the process a signal,\n\ -and it must have the same effective uid as the debugger.\n\ -When using \"attach\", you should use the \"file\" command to specify\n\ -the program running in the process, and to load its symbol table."); - - add_com ("detach", class_run, detach_command, - "Detach a process or file previously attached.\n\ -If a process, it is no longer traced, and it continues its execution. If you\n\ -were debugging a file, the file is closed and gdb no longer accesses it."); - - add_com ("signal", class_run, signal_command, - "Continue program giving it signal number SIGNUMBER."); - - add_com ("stepi", class_run, stepi_command, - "Step one instruction exactly.\n\ -Argument N means do this N times (or till program stops for another reason)."); - add_com_alias ("si", "stepi", class_alias, 0); - - add_com ("nexti", class_run, nexti_command, - "Step one instruction, but proceed through subroutine calls.\n\ -Argument N means do this N times (or till program stops for another reason)."); - add_com_alias ("ni", "nexti", class_alias, 0); - - add_com ("finish", class_run, finish_command, - "Execute until selected stack frame returns.\n\ -Upon return, the value returned is printed and put in the value history."); - - add_com ("next", class_run, next_command, - "Step program, proceeding through subroutine calls.\n\ -Like the \"step\" command as long as subroutine calls do not happen;\n\ -when they do, the call is treated as one instruction.\n\ -Argument N means do this N times (or till program stops for another reason)."); - add_com_alias ("n", "next", class_run, 1); - - add_com ("step", class_run, step_command, - "Step program until it reaches a different source line.\n\ -Argument N means do this N times (or till program stops for another reason)."); - add_com_alias ("s", "step", class_run, 1); - - add_com ("until", class_run, until_command, - "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."); - add_com_alias ("u", "until", class_run, 1); - - 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."); - - add_com ("continue", class_run, continue_command, - "Continue program being debugged, after signal or breakpoint.\n\ -If proceeding from breakpoint, a number N may be used as an argument:\n\ -then the same breakpoint won't break until the Nth time it is reached."); - add_com_alias ("c", "cont", class_run, 1); - add_com_alias ("fg", "cont", class_run, 1); - - add_com ("run", class_run, run_command, - "Start debugged program. You may specify arguments to give it.\n\ -Args may include \"*\", or \"[...]\"; they are expanded using \"sh\".\n\ -Input and output redirection with \">\", \"<\", or \">>\" are also allowed.\n\n\ -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."); - add_com_alias ("r", "run", class_run, 1); - - add_info ("registers", registers_info, - "List of registers and their contents, for selected stack frame.\n\ -Register name as argument means describe only that register."); - - add_info ("program", program_info, - "Execution status of the program."); - - add_info ("float", float_info, - "Print the status of the floating point unit\n"); - - inferior_args = savestring ("", 1); /* Initially no args */ - inferior_environ = make_environ (); - init_environ (inferior_environ); -} diff --git a/gdb/inferior.h b/gdb/inferior.h deleted file mode 100644 index eed848ceffa..00000000000 --- a/gdb/inferior.h +++ /dev/null @@ -1,211 +0,0 @@ -/* Variables that describe the inferior process running under GDB: - Where it is, why it stopped, and how to step it. - Copyright (C) 1986, 1989 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* For bpstat. */ -#include "breakpoint.h" - -/* For FRAME_ADDR. */ -#include "frame.h" - -/* - * Structure in which to save the status of the inferior. Save - * through "save_inferior_status", restore through - * "restore_inferior_status". - * This pair of routines should be called around any transfer of - * control to the inferior which you don't want showing up in your - * control variables. - */ -struct inferior_status { - int pc_changed; - int stop_signal; - int stop_pc; - FRAME_ADDR stop_frame_address; - bpstat stop_bpstat; - int stop_step; - int stop_stack_dummy; - int stopped_by_random_signal; - int trap_expected; - CORE_ADDR step_range_start; - CORE_ADDR step_range_end; - FRAME_ADDR step_frame_address; - int step_over_calls; - CORE_ADDR step_resume_break_address; - int stop_after_trap; - int stop_soon_quietly; - FRAME_ADDR selected_frame_address; - int selected_level; - char stop_registers[REGISTER_BYTES]; - int breakpoint_proceeded; - int restore_stack_info; - int proceed_to_finish; -}; - -void save_inferior_status (), restore_inferior_status (); - -/* File name for default use for standard in/out in the inferior. */ - -extern char *inferior_io_terminal; - -/* Pid of our debugged inferior, or 0 if no inferior now. */ - -extern int inferior_pid; - -/* Character array containing an image of the inferior programs' registers. */ - -extern char registers[]; - -extern void clear_proceed_status (); -extern void start_inferior (); -extern void proceed (); -extern void kill_inferior (); -extern void kill_inferior_fast (); -extern void generic_mourn_inferior (); -extern void terminal_ours (); -extern void detach (); -extern void run_stack_dummy (); -extern CORE_ADDR read_pc (); -extern void write_pc (); -extern void wait_for_inferior (); -extern void init_wait_for_inferior (); -extern void close_exec_file (); -extern void reopen_exec_file (); - -/* From infcmd.c */ -void attach_command ( -#ifdef __STDC__ - char *arg, int from_tty -#endif - ); - -/* Last signal that the inferior received (why it stopped). */ - -extern int stop_signal; - -/* Address at which inferior stopped. */ - -extern CORE_ADDR stop_pc; - -/* Stack frame when program stopped. */ - -extern FRAME_ADDR stop_frame_address; - -/* Chain containing status of breakpoint(s) that we have stopped at. */ - -extern bpstat stop_bpstat; - -/* Flag indicating that a command has proceeded the inferior past the - current breakpoint. */ - -extern int breakpoint_proceeded; - -/* Nonzero if stopped due to a step command. */ - -extern int stop_step; - -/* Nonzero if stopped due to completion of a stack dummy routine. */ - -extern int stop_stack_dummy; - -/* Nonzero if program stopped due to a random (unexpected) signal in - inferior process. */ - -extern int stopped_by_random_signal; - -/* Range to single step within. - If this is nonzero, respond to a single-step signal - by continuing to step if the pc is in this range. */ - -extern CORE_ADDR step_range_start; /* Inclusive */ -extern CORE_ADDR step_range_end; /* Exclusive */ - -/* Stack frame address as of when stepping command was issued. - This is how we know when we step into a subroutine call, - and how to set the frame for the breakpoint used to step out. */ - -extern FRAME_ADDR step_frame_address; - -/* 1 means step over all subroutine calls. - -1 means step over calls to undebuggable functions. */ - -extern int step_over_calls; - -/* If stepping, nonzero means step count is > 1 - so don't print frame next time inferior stops - if it stops due to stepping. */ - -extern int step_multi; - -/* Nonzero means expecting a trap and caller will handle it themselves. - It is used after attach, due to attaching to a process; - when running in the shell before the child program has been exec'd; - and when running some kinds of remote stuff (FIXME?). */ - -int stop_soon_quietly; - -/* Nonzero if proceed is being used for a "finish" command or a similar - situation when stop_registers should be saved. */ - -extern int proceed_to_finish; - -/* Save register contents here when about to pop a stack dummy frame, - if-and-only-if proceed_to_finish is set. - Thus this contains the return value from the called function (assuming - values are returned in a register). */ - -extern char stop_registers[REGISTER_BYTES]; - -/* Nonzero if pc has been changed by the debugger - since the inferior stopped. */ - -extern int pc_changed; - -/* Nonzero if the child process in inferior_pid was attached rather - than forked. */ - -int attach_flag; - -/* Possible values for CALL_DUMMY_LOCATION. */ -#define ON_STACK 1 -#define BEFORE_TEXT_END 2 -#define AFTER_TEXT_END 3 - -#if !defined (CALL_DUMMY_LOCATION) -#define CALL_DUMMY_LOCATION ON_STACK -#endif /* No CALL_DUMMY_LOCATION. */ - -/* Are we in a call dummy? The code below which allows DECR_PC_AFTER_BREAK - below is for infrun.c, which may give the macro a pc without that - subtracted out. */ -#if !defined (PC_IN_CALL_DUMMY) -#if CALL_DUMMY_LOCATION == BEFORE_TEXT_END -#define PC_IN_CALL_DUMMY(pc, sp, frame_address) \ - ((pc) >= text_end - CALL_DUMMY_LENGTH \ - && (pc) < text_end + DECR_PC_AFTER_BREAK) -#else /* Not before text_end. */ -#if CALL_DUMMY_LOCATION == AFTER_TEXT_END -#define PC_IN_CALL_DUMMY(pc, sp, frame_address) \ - ((pc) >= text_end \ - && (pc) < text_end + CALL_DUMMY_LENGTH + DECR_PC_AFTER_BREAK) -#else /* On stack. */ -#define PC_IN_CALL_DUMMY(pc, sp, frame_address) \ - ((sp) INNER_THAN (pc) && (pc) INNER_THAN (frame_address)) -#endif /* On stack. */ -#endif /* Not before text_end. */ -#endif /* No PC_IN_CALL_DUMMY. */ diff --git a/gdb/inflow.c b/gdb/inflow.c deleted file mode 100644 index fd8f0b84ecb..00000000000 --- a/gdb/inflow.c +++ /dev/null @@ -1,499 +0,0 @@ -/* Low level interface to ptrace, for GDB when running under Unix. - Copyright (C) 1986, 1987, 1989, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "defs.h" -#include "param.h" -#include "frame.h" -#include "inferior.h" -#include "command.h" -#include "signals.h" -#include "terminal.h" -#include "target.h" - -#ifdef USG -#include -#endif - -/* Some USG-esque systems (some of which are BSD-esque enough so that USG - is not defined) want this header, and it won't do any harm. */ -#include - -#include -#include -#include - -extern struct target_ops child_ops; - -/* Nonzero if we are debugging an attached outside process - rather than an inferior. */ - -int attach_flag; - - -/* Record terminal status separately for debugger and inferior. */ - -static TERMINAL sg_inferior; -static TERMINAL sg_ours; - -static int tflags_inferior; -static int tflags_ours; - -#if defined(TIOCGETC) && !defined(TIOCGETC_BROKEN) -static struct tchars tc_inferior; -static struct tchars tc_ours; -#endif - -#ifdef TIOCGLTC -static struct ltchars ltc_inferior; -static struct ltchars ltc_ours; -#endif - -#ifdef TIOCLGET -static int lmode_inferior; -static int lmode_ours; -#endif - -#ifdef TIOCGPGRP -static int pgrp_inferior; -static int pgrp_ours; -#else -static void (*sigint_ours) (); -static void (*sigquit_ours) (); -#endif /* TIOCGPGRP */ - -/* Copy of inferior_io_terminal when inferior was last started. */ -static char *inferior_thisrun_terminal; - -static void terminal_ours_1 (); - -/* Nonzero if our terminal settings are in effect. - Zero if the inferior's settings are in effect. */ -static int terminal_is_ours; - -/* Initialize the terminal settings we record for the inferior, - before we actually run the inferior. */ - -void -terminal_init_inferior () -{ - sg_inferior = sg_ours; - tflags_inferior = tflags_ours; - -#if defined(TIOCGETC) && !defined(TIOCGETC_BROKEN) - tc_inferior = tc_ours; -#endif - -#ifdef TIOCGLTC - ltc_inferior = ltc_ours; -#endif - -#ifdef TIOCLGET - lmode_inferior = lmode_ours; -#endif - -#ifdef TIOCGPGRP - pgrp_inferior = inferior_pid; -#endif /* TIOCGPGRP */ - - terminal_is_ours = 1; -} - -/* Put the inferior's terminal settings into effect. - This is preparation for starting or resuming the inferior. */ - -void -terminal_inferior () -{ - if (terminal_is_ours && inferior_thisrun_terminal == 0) - { - fcntl (0, F_SETFL, tflags_inferior); - fcntl (0, F_SETFL, tflags_inferior); - ioctl (0, TIOCSETN, &sg_inferior); - -#if defined(TIOCGETC) && !defined(TIOCGETC_BROKEN) - ioctl (0, TIOCSETC, &tc_inferior); -#endif -#ifdef TIOCGLTC - ioctl (0, TIOCSLTC, <c_inferior); -#endif -#ifdef TIOCLGET - ioctl (0, TIOCLSET, &lmode_inferior); -#endif - -#ifdef TIOCGPGRP - ioctl (0, TIOCSPGRP, &pgrp_inferior); -#else - sigint_ours = (void (*) ()) signal (SIGINT, SIG_IGN); - sigquit_ours = (void (*) ()) signal (SIGQUIT, SIG_IGN); -#endif /* TIOCGPGRP */ - } - terminal_is_ours = 0; -} - -/* Put some of our terminal settings into effect, - enough to get proper results from our output, - but do not change into or out of RAW mode - so that no input is discarded. - - After doing this, either terminal_ours or terminal_inferior - should be called to get back to a normal state of affairs. */ - -void -terminal_ours_for_output () -{ - terminal_ours_1 (1); -} - -/* Put our terminal settings into effect. - First record the inferior's terminal settings - so they can be restored properly later. */ - -void -terminal_ours () -{ - terminal_ours_1 (0); -} - -static void -terminal_ours_1 (output_only) - int output_only; -{ -#ifdef TIOCGPGRP - /* Ignore this signal since it will happen when we try to set the pgrp. */ - void (*osigttou) (); -#endif /* TIOCGPGRP */ - - /* The check for inferior_thisrun_terminal had been commented out - when the call to ioctl (TIOCNOTTY) was commented out. - Checking inferior_thisrun_terminal is necessary so that - if GDB is running in the background, it won't block trying - to do the ioctl()'s below. */ - if (inferior_thisrun_terminal != 0) - return; - - if (!terminal_is_ours) - { - terminal_is_ours = 1; - -#ifdef TIOCGPGRP - osigttou = (void (*) ()) signal (SIGTTOU, SIG_IGN); - - ioctl (0, TIOCGPGRP, &pgrp_inferior); - ioctl (0, TIOCSPGRP, &pgrp_ours); - - signal (SIGTTOU, osigttou); -#else - signal (SIGINT, sigint_ours); - signal (SIGQUIT, sigquit_ours); -#endif /* TIOCGPGRP */ - - tflags_inferior = fcntl (0, F_GETFL, 0); - ioctl (0, TIOCGETP, &sg_inferior); - -#if defined(TIOCGETC) && !defined(TIOCGETC_BROKEN) - ioctl (0, TIOCGETC, &tc_inferior); -#endif -#ifdef TIOCGLTC - ioctl (0, TIOCGLTC, <c_inferior); -#endif -#ifdef TIOCLGET - ioctl (0, TIOCLGET, &lmode_inferior); -#endif - } - -#ifdef HAVE_TERMIO - sg_ours.c_lflag |= ICANON; - if (output_only && !(sg_inferior.c_lflag & ICANON)) - sg_ours.c_lflag &= ~ICANON; -#else /* not HAVE_TERMIO */ - sg_ours.sg_flags &= ~RAW & ~CBREAK; - if (output_only) - sg_ours.sg_flags |= (RAW | CBREAK) & sg_inferior.sg_flags; -#endif /* not HAVE_TERMIO */ - - fcntl (0, F_SETFL, tflags_ours); - fcntl (0, F_SETFL, tflags_ours); - ioctl (0, TIOCSETN, &sg_ours); - -#if defined(TIOCGETC) && !defined(TIOCGETC_BROKEN) - ioctl (0, TIOCSETC, &tc_ours); -#endif -#ifdef TIOCGLTC - ioctl (0, TIOCSLTC, <c_ours); -#endif -#ifdef TIOCLGET - ioctl (0, TIOCLSET, &lmode_ours); -#endif - -#ifdef HAVE_TERMIO - sg_ours.c_lflag |= ICANON; -#else /* not HAVE_TERMIO */ - sg_ours.sg_flags &= ~RAW & ~CBREAK; -#endif /* not HAVE_TERMIO */ -} - -/* ARGSUSED */ -void -term_info (arg, from_tty) - char *arg; - int from_tty; -{ - target_terminal_info (arg, from_tty); -} - -/* ARGSUSED */ -void -child_terminal_info (args, from_tty) - char *args; - int from_tty; -{ - register int i; - - printf_filtered ("Inferior's terminal status (currently saved by GDB):\n"); - -#ifdef HAVE_TERMIO - - printf_filtered ("fcntl flags = 0x%x, c_iflag = 0x%x, c_oflag = 0x%x,\n", - tflags_inferior, sg_inferior.c_iflag, sg_inferior.c_oflag); - printf_filtered ("c_cflag = 0x%x, c_lflag = 0x%x, c_line = 0x%x.\n", - sg_inferior.c_cflag, sg_inferior.c_lflag, sg_inferior.c_line); - printf_filtered ("c_cc: "); - for (i = 0; (i < NCC); i += 1) - printf_filtered ("0x%x ", sg_inferior.c_cc[i]); - printf_filtered ("\n"); - -#else /* not HAVE_TERMIO */ - - printf_filtered ("fcntl flags = 0x%x, sgttyb.sg_flags = 0x%x, owner pid = %d.\n", - tflags_inferior, sg_inferior.sg_flags, pgrp_inferior); - -#endif /* not HAVE_TERMIO */ - -#if defined(TIOCGETC) && !defined(TIOCGETC_BROKEN) - printf_filtered ("tchars: "); - for (i = 0; i < (int)sizeof (struct tchars); i++) - printf_filtered ("0x%x ", ((char *)&tc_inferior)[i]); - printf_filtered ("\n"); -#endif - -#ifdef TIOCGLTC - printf_filtered ("ltchars: "); - for (i = 0; i < (int)sizeof (struct ltchars); i++) - printf_filtered ("0x%x ", ((char *)<c_inferior)[i]); - printf_filtered ("\n"); -#endif - -#ifdef TIOCLGET - printf_filtered ("lmode: 0x%x\n", lmode_inferior); -#endif -} - -/* NEW_TTY_PREFORK is called before forking a new child process, - so we can record the state of ttys in the child to be formed. - TTYNAME is null if we are to share the terminal with gdb; - or points to a string containing the name of the desired tty. - - NEW_TTY is called in new child processes under Unix, which will - become debugger target processes. This actually switches to - the terminal specified in the NEW_TTY_PREFORK call. */ - -new_tty_prefork (ttyname) - char *ttyname; -{ - /* Save the name for later, for determining whether we and the child - are sharing a tty. */ - inferior_thisrun_terminal = ttyname; -} - -void -new_tty () -{ - register int tty; - - if (inferior_thisrun_terminal == 0) - return; - -#ifdef TIOCNOTTY - /* Disconnect the child process from our controlling terminal. */ - tty = open("/dev/tty", O_RDWR); - if (tty > 0) - { - ioctl(tty, TIOCNOTTY, 0); - close(tty); - } -#endif - - /* Now open the specified new terminal. */ - - tty = open(inferior_thisrun_terminal, O_RDWR); - if (tty == -1) - { - print_sys_errmsg (inferior_thisrun_terminal, errno); - _exit(1); - } - - /* Avoid use of dup2; doesn't exist on all systems. */ - if (tty != 0) - { close (0); dup (tty); } - if (tty != 1) - { close (1); dup (tty); } - if (tty != 2) - { close (2); dup (tty); } - if (tty > 2) - close(tty); -} - -/* Kill the inferior process. Make us have no inferior. */ - -/* ARGSUSED */ -static void -kill_command (arg, from_tty) - char *arg; - int from_tty; -{ - if (inferior_pid == 0) - error ("The program is not being run."); - if (!query ("Kill the inferior process? ")) - error ("Not confirmed."); - target_kill (arg, from_tty); - - /* Killing off the inferior can leave us with a core file. If so, - print the state we are left in. */ - if (target_has_stack) { - printf_filtered ("In %s,\n", current_target->to_longname); - if (selected_frame == NULL) - fputs_filtered ("No selected stack frame.\n", stdout); - else - print_stack_frame (selected_frame, selected_frame_level, 1); - } -} - -/* The inferior process has died. Long live the inferior! */ - -void -generic_mourn_inferior () -{ - inferior_pid = 0; - attach_flag = 0; - mark_breakpoints_out (); - registers_changed (); - -#ifdef CLEAR_DEFERRED_STORES - /* Delete any pending stores to the inferior... */ - CLEAR_DEFERRED_STORES; -#endif - - reopen_exec_file (); - if (target_has_stack) { - set_current_frame ( create_new_frame (read_register (FP_REGNUM), - read_pc ())); - select_frame (get_current_frame (), 0); - } else { - set_current_frame (0); - select_frame ((FRAME) 0, -1); - } - /* It is confusing to the user for ignore counts to stick around - from previous runs of the inferior. So clear them. */ - breakpoint_clear_ignore_counts (); -} - -void -child_mourn_inferior () -{ - unpush_target (&child_ops); - generic_mourn_inferior (); -} - -#if 0 -/* This function is just for testing, and on some systems (Sony NewsOS - 3.2) also includes which leads to errors - (since on this system at least sys/time.h is not protected against - multiple inclusion). */ -/* ARGSUSED */ -static void -try_writing_regs_command (arg, from_tty) - char *arg; - int from_tty; -{ - register int i; - register int value; - - if (inferior_pid == 0) - error ("There is no inferior process now."); - - /* A Sun 3/50 or 3/60 (at least) running SunOS 4.0.3 will have a - kernel panic if we try to write past the end of the user area. - Presumably Sun will fix this bug (it has been reported), but it - is tacky to crash the system, so at least on SunOS4 we need to - stop writing when we hit the end of the user area. */ - for (i = 0; i < sizeof (struct user); i += 2) - { - QUIT; - errno = 0; - value = call_ptrace (3, inferior_pid, i, 0); - call_ptrace (6, inferior_pid, i, value); - if (errno == 0) - { - printf (" Succeeded with address 0x%x; value 0x%x (%d).\n", - i, value, value); - } - else if ((i & 0377) == 0) - printf (" Failed at 0x%x.\n", i); - } -} -#endif - -void -_initialize_inflow () -{ - add_info ("terminal", term_info, - "Print inferior's saved terminal status."); - -#if 0 - add_com ("try-writing-regs", class_obscure, try_writing_regs_command, - "Try writing all locations in inferior's system block.\n\ -Report which ones can be written."); -#endif - - add_com ("kill", class_run, kill_command, - "Kill execution of program being debugged."); - - inferior_pid = 0; - - ioctl (0, TIOCGETP, &sg_ours); - tflags_ours = fcntl (0, F_GETFL, 0); - -#if defined(TIOCGETC) && !defined(TIOCGETC_BROKEN) - ioctl (0, TIOCGETC, &tc_ours); -#endif -#ifdef TIOCGLTC - ioctl (0, TIOCGLTC, <c_ours); -#endif -#ifdef TIOCLGET - ioctl (0, TIOCLGET, &lmode_ours); -#endif - -#ifdef TIOCGPGRP - ioctl (0, TIOCGPGRP, &pgrp_ours); -#endif /* TIOCGPGRP */ - - terminal_is_ours = 1; -} - diff --git a/gdb/infptrace.c b/gdb/infptrace.c deleted file mode 100644 index 014576b05d6..00000000000 --- a/gdb/infptrace.c +++ /dev/null @@ -1,396 +0,0 @@ -/* Low level Unix child interface to ptrace, for GDB when running under Unix. - Copyright (C) 1988, 1989, 1990, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "defs.h" -#include "param.h" -#include "frame.h" -#include "inferior.h" -#include "target.h" - -#ifdef USG -#include -#endif - -#include -#include -#include -#include -#ifndef USG -#include -#endif - -#if !defined (PT_KILL) -#define PT_KILL 8 -#define PT_STEP 9 -#define PT_CONTINUE 7 -#define PT_READ_U 3 -#define PT_WRITE_U 6 -#define PT_READ_I 1 -#define PT_READ_D 2 -#define PT_WRITE_I 4 -#define PT_WRITE_D 5 -#endif /* No PT_KILL. */ - -#ifndef PT_ATTACH -#define PT_ATTACH PTRACE_ATTACH -#endif -#ifndef PT_DETACH -#define PT_DETACH PTRACE_DETACH -#endif - -#include "gdbcore.h" -#include /* After a.out.h */ -#include -#include - -/* This function simply calls ptrace with the given arguments. - It exists so that all calls to ptrace are isolated in this - machine-dependent file. */ -int -call_ptrace (request, pid, addr, data) - int request, pid, *addr, data; -{ - return ptrace (request, pid, addr, data); -} - -#ifdef DEBUG_PTRACE -/* For the rest of the file, use an extra level of indirection */ -/* This lets us breakpoint usefully on call_ptrace. */ -#define ptrace call_ptrace -#endif - -/* This is used when GDB is exiting. It gives less chance of error.*/ - -void -kill_inferior_fast () -{ - if (inferior_pid == 0) - return; - ptrace (PT_KILL, inferior_pid, 0, 0); - wait ((int *)0); -} - -void -kill_inferior (args, from_tty) - char *args; - int from_tty; -{ - kill_inferior_fast (); - target_mourn_inferior (); -} - -/* Resume execution of the inferior process. - If STEP is nonzero, single-step it. - If SIGNAL is nonzero, give it that signal. */ - -void -child_resume (step, signal) - int step; - int signal; -{ - errno = 0; - - /* An address of (int *)1 tells ptrace to continue from where it was. - (If GDB wanted it to start some other way, we have already written - a new PC value to the child.) */ - - if (step) - ptrace (PT_STEP, inferior_pid, (int *)1, signal); - else - ptrace (PT_CONTINUE, inferior_pid, (int *)1, signal); - - if (errno) - perror_with_name ("ptrace"); -} - -#ifdef ATTACH_DETACH -/* Nonzero if we are debugging an attached process rather than - an inferior. */ -extern int attach_flag; - -/* Start debugging the process whose number is PID. */ -int -attach (pid) - int pid; -{ - errno = 0; - ptrace (PT_ATTACH, pid, 0, 0); - if (errno) - perror_with_name ("ptrace"); - attach_flag = 1; - return pid; -} - -/* Stop debugging the process whose number is PID - and continue it with signal number SIGNAL. - SIGNAL = 0 means just continue it. */ - -void -detach (signal) - int signal; -{ - errno = 0; - ptrace (PT_DETACH, inferior_pid, 1, signal); - if (errno) - perror_with_name ("ptrace"); - attach_flag = 0; -} -#endif /* ATTACH_DETACH */ - -#if !defined (FETCH_INFERIOR_REGISTERS) - -/* KERNEL_U_ADDR is the amount to subtract from u.u_ar0 - to get the offset in the core file of the register values. */ -#if defined (KERNEL_U_ADDR_BSD) -/* Get kernel_u_addr using BSD-style nlist(). */ -CORE_ADDR kernel_u_addr; - -void -_initialize_kernel_u_addr () -{ - struct nlist names[2]; - - names[0].n_un.n_name = "_u"; - names[1].n_un.n_name = NULL; - if (nlist ("/vmunix", names) == 0) - kernel_u_addr = names[0].n_value; - else - fatal ("Unable to get kernel u area address."); -} -#endif /* KERNEL_U_ADDR_BSD. */ - -#if defined (KERNEL_U_ADDR_HPUX) -/* Get kernel_u_addr using HPUX-style nlist(). */ -CORE_ADDR kernel_u_addr; - -struct hpnlist { - char * n_name; - long n_value; - unsigned char n_type; - unsigned char n_length; - short n_almod; - short n_unused; -}; -static struct hpnlist nl[] = {{ "_u", -1, }, { (char *) 0, }}; - -/* read the value of the u area from the hp-ux kernel */ -void _initialize_kernel_u_addr () -{ - struct user u; - nlist ("/hp-ux", &nl); - kernel_u_addr = nl[0].n_value; -} -#endif /* KERNEL_U_ADDR_HPUX. */ - -#if !defined (offsetof) -#define offsetof(TYPE, MEMBER) ((unsigned long) &((TYPE *)0)->MEMBER) -#endif - -/* U_REGS_OFFSET is the offset of the registers within the u area. */ -#if !defined (U_REGS_OFFSET) -#define U_REGS_OFFSET \ - ptrace (PT_READ_U, inferior_pid, \ - (int *)(offsetof (struct user, u_ar0)), 0) - KERNEL_U_ADDR -#endif - -/* Fetch one register. */ -static void -fetch_register (regno) - int regno; -{ - register unsigned int regaddr; - char buf[MAX_REGISTER_RAW_SIZE]; - register int i; - - /* Offset of registers within the u area. */ - unsigned int offset = U_REGS_OFFSET; - - regaddr = register_addr (regno, offset); - for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int)) - { - *(int *) &buf[i] = ptrace (PT_READ_U, inferior_pid, (int *)regaddr, 0); - regaddr += sizeof (int); - } - supply_register (regno, buf); -} - -/* Fetch all registers, or just one, from the child process. */ - -void -fetch_inferior_registers (regno) - int regno; -{ - if (regno == -1) - for (regno = 0; regno < NUM_REGS; regno++) - fetch_register (regno); - else - fetch_register (regno); -} - -/* Registers we shouldn't try to store. */ -#if !defined (CANNOT_STORE_REGISTER) -#define CANNOT_STORE_REGISTER(regno) 0 -#endif - -/* Store our register values back into the inferior. - If REGNO is -1, do this for all registers. - Otherwise, REGNO specifies which register (so we can save time). */ - -int -store_inferior_registers (regno) - int regno; -{ - register unsigned int regaddr; - char buf[80]; - extern char registers[]; - register int i; - int result = 0; - - unsigned int offset = U_REGS_OFFSET; - - if (regno >= 0) - { - regaddr = register_addr (regno, offset); - for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof(int)) - { - errno = 0; - ptrace (PT_WRITE_U, inferior_pid, (int *)regaddr, - *(int *) ®isters[REGISTER_BYTE (regno) + i]); - if (errno != 0) - { - sprintf (buf, "writing register number %d(%d)", regno, i); - perror_with_name (buf); - result = -1; - } - regaddr += sizeof(int); - } - } - else - { - for (regno = 0; regno < NUM_REGS; regno++) - { - if (CANNOT_STORE_REGISTER (regno)) - continue; - regaddr = register_addr (regno, offset); - for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof(int)) - { - errno = 0; - ptrace (PT_WRITE_U, inferior_pid, (int *)regaddr, - *(int *) ®isters[REGISTER_BYTE (regno) + i]); - if (errno != 0) - { - sprintf (buf, "writing register number %d(%d)", regno, i); - perror_with_name (buf); - result = -1; - } - regaddr += sizeof(int); - } - } - } - return result; -} -#endif /* !defined (FETCH_INFERIOR_REGISTERS). */ - -/* NOTE! I tried using PTRACE_READDATA, etc., to read and write memory - in the NEW_SUN_PTRACE case. - It ought to be straightforward. But it appears that writing did - not write the data that I specified. I cannot understand where - it got the data that it actually did write. */ - -/* 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. - - 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 (memaddr, myaddr, len, write, target) - CORE_ADDR memaddr; - char *myaddr; - int len; - int write; - struct target_ops target; /* ignored */ -{ - register int i; - /* Round starting address down to longword boundary. */ - register CORE_ADDR addr = memaddr & - sizeof (int); - /* Round ending address up; get number of longwords that makes. */ - register int count - = (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (int); - /* Allocate buffer of that many longwords. */ - register int *buffer = (int *) alloca (count * sizeof (int)); - - if (write) - { - /* Fill start and end extra bytes of buffer with existing memory data. */ - - if (addr != memaddr || len < (int)sizeof (int)) { - /* Need part of initial word -- fetch it. */ - buffer[0] = ptrace (PT_READ_I, inferior_pid, (int *)addr, 0); - } - - if (count > 1) /* FIXME, avoid if even boundary */ - { - buffer[count - 1] - = ptrace (PT_READ_I, inferior_pid, - (int *)(addr + (count - 1) * sizeof (int)), 0); - } - - /* Copy data to be written over corresponding part of buffer */ - - bcopy (myaddr, (char *) buffer + (memaddr & (sizeof (int) - 1)), len); - - /* Write the entire buffer. */ - - for (i = 0; i < count; i++, addr += sizeof (int)) - { - errno = 0; - ptrace (PT_WRITE_D, inferior_pid, (int *)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, inferior_pid, (int *)addr, buffer[i]); - } - if (errno) - return 0; - } - } - else - { - /* Read all the longwords */ - for (i = 0; i < count; i++, addr += sizeof (int)) - { - errno = 0; - buffer[i] = ptrace (PT_READ_I, inferior_pid, (int *)addr, 0); - if (errno) - return 0; - QUIT; - } - - /* Copy appropriate bytes out of the buffer. */ - bcopy ((char *) buffer + (memaddr & (sizeof (int) - 1)), myaddr, len); - } - return len; -} diff --git a/gdb/infrun.c b/gdb/infrun.c deleted file mode 100644 index 3ca563f7331..00000000000 --- a/gdb/infrun.c +++ /dev/null @@ -1,1803 +0,0 @@ -/* Start (run) and stop the inferior process, for GDB. - Copyright (C) 1986, 1987, 1988, 1989, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Notes on the algorithm used in wait_for_inferior to determine if we - just did a subroutine call when stepping. We have the following - information at that point: - - Current and previous (just before this step) pc. - Current and previous sp. - Current and previous start of current function. - - If the starts of the functions don't match, then - - a) We did a subroutine call. - - In this case, the pc will be at the beginning of a function. - - b) We did a subroutine return. - - Otherwise. - - c) We did a longjmp. - - If we did a longjump, we were doing "nexti", since a next would - have attempted to skip over the assembly language routine in which - the longjmp is coded and would have simply been the equivalent of a - continue. I consider this ok behaivior. We'd like one of two - things to happen if we are doing a nexti through the longjmp() - routine: 1) It behaves as a stepi, or 2) It acts like a continue as - above. Given that this is a special case, and that anybody who - thinks that the concept of sub calls is meaningful in the context - of a longjmp, I'll take either one. Let's see what happens. - - Acts like a subroutine return. I can handle that with no problem - at all. - - -->So: If the current and previous beginnings of the current - function don't match, *and* the pc is at the start of a function, - we've done a subroutine call. If the pc is not at the start of a - function, we *didn't* do a subroutine call. - - -->If the beginnings of the current and previous function do match, - either: - - a) We just did a recursive call. - - In this case, we would be at the very beginning of a - function and 1) it will have a prologue (don't jump to - before prologue, or 2) (we assume here that it doesn't have - a prologue) there will have been a change in the stack - pointer over the last instruction. (Ie. it's got to put - the saved pc somewhere. The stack is the usual place. In - a recursive call a register is only an option if there's a - prologue to do something with it. This is even true on - register window machines; the prologue sets up the new - window. It might not be true on a register window machine - where the call instruction moved the register window - itself. Hmmm. One would hope that the stack pointer would - also change. If it doesn't, somebody send me a note, and - I'll work out a more general theory. - bug-gdb@prep.ai.mit.edu). This is true (albeit slipperly - so) on all machines I'm aware of: - - m68k: Call changes stack pointer. Regular jumps don't. - - sparc: Recursive calls must have frames and therefor, - prologues. - - vax: All calls have frames and hence change the - stack pointer. - - b) We did a return from a recursive call. I don't see that we - have either the ability or the need to distinguish this - from an ordinary jump. The stack frame will be printed - when and if the frame pointer changes; if we are in a - function without a frame pointer, it's the users own - lookout. - - c) We did a jump within a function. We assume that this is - true if we didn't do a recursive call. - - d) We are in no-man's land ("I see no symbols here"). We - don't worry about this; it will make calls look like simple - jumps (and the stack frames will be printed when the frame - pointer moves), which is a reasonably non-violent response. - -#if 0 - We skip this; it causes more problems than it's worth. -#ifdef SUN4_COMPILER_FEATURE - We do a special ifdef for the sun 4, forcing it to single step - into calls which don't have prologues. This means that we can't - nexti over leaf nodes, we can probably next over them (since they - won't have debugging symbols, usually), and we can next out of - functions returning structures (with a "call .stret4" at the end). -#endif -#endif -*/ - - - - - -#include -#include -#include "defs.h" -#include "param.h" -#include "symtab.h" -#include "frame.h" -#include "inferior.h" -#include "breakpoint.h" -#include "wait.h" -#include "gdbcore.h" -#include "signame.h" -#include "command.h" -#include "terminal.h" /* For #ifdef TIOCGPGRP and new_tty */ -#include "target.h" - -#include - -/* unistd.h is needed to #define X_OK */ -#ifdef USG -#include -#else -#include -#endif - -#ifdef SET_STACK_LIMIT_HUGE -#include -#include - -extern int original_stack_limit; -#endif /* SET_STACK_LIMIT_HUGE */ - -extern char *getenv (); -extern char **environ; - -extern struct target_ops child_ops; /* In inftarg.c */ - - -/* 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) -#define IN_SIGTRAMP(pc, name) \ - (name && !strcmp ("_sigtramp", name)) -#endif - -/* Tables of how to react to signals; the user sets them. */ - -static char signal_stop[NSIG]; -static char signal_print[NSIG]; -static char signal_program[NSIG]; - -/* Nonzero if breakpoints are now inserted in the inferior. */ -/* Nonstatic for initialization during xxx_create_inferior. FIXME. */ - -/*static*/ int breakpoints_inserted; - -/* Function inferior was in as of last step command. */ - -static struct symbol *step_start_function; - -/* Nonzero => address for special breakpoint for resuming stepping. */ - -static CORE_ADDR step_resume_break_address; - -/* Pointer to orig contents of the byte where the special breakpoint is. */ - -static char step_resume_break_shadow[BREAKPOINT_MAX]; - -/* Nonzero means the special breakpoint is a duplicate - so it has not itself been inserted. */ - -static int step_resume_break_duplicate; - -/* Nonzero if we are expecting a trace trap and should proceed from it. */ - -static int trap_expected; - -/* Nonzero if the next time we try to continue the inferior, it will - step one instruction and generate a spurious trace trap. - This is used to compensate for a bug in HP-UX. */ - -static int trap_expected_after_continue; - -/* Nonzero means expecting a trace trap - and should stop the inferior and return silently when it happens. */ - -int stop_after_trap; - -/* Nonzero means expecting a trap and caller will handle it themselves. - It is used after attach, due to attaching to a process; - when running in the shell before the child program has been exec'd; - and when running some kinds of remote stuff (FIXME?). */ - -int stop_soon_quietly; - -/* Nonzero if pc has been changed by the debugger - since the inferior stopped. */ - -int pc_changed; - -/* Nonzero if proceed is being used for a "finish" command or a similar - situation when stop_registers should be saved. */ - -int proceed_to_finish; - -/* Save register contents here when about to pop a stack dummy frame, - if-and-only-if proceed_to_finish is set. - Thus this contains the return value from the called function (assuming - values are returned in a register). */ - -char stop_registers[REGISTER_BYTES]; - -/* Nonzero if program stopped due to error trying to insert breakpoints. */ - -static int breakpoints_failed; - -/* Nonzero after stop if current stack frame should be printed. */ - -static int stop_print_frame; - -#ifdef NO_SINGLE_STEP -extern int one_stepped; /* From machine dependent code */ -extern void single_step (); /* Same. */ -#endif /* NO_SINGLE_STEP */ - -static void insert_step_breakpoint (); -static void remove_step_breakpoint (); -/*static*/ void wait_for_inferior (); -void init_wait_for_inferior (); -void normal_stop (); - - -/* Things to clean up if we QUIT out of resume (). */ -/* ARGSUSED */ -static void -resume_cleanups (arg) - int arg; -{ - normal_stop (); -} - -/* Resume the inferior, but allow a QUIT. This is useful if the user - wants to interrupt some lengthy single-stepping operation - (for child processes, the SIGINT goes to the inferior, and so - we get a SIGINT random_signal, but for remote debugging and perhaps - other targets, that's not true). - - STEP nonzero if we should step (zero to continue instead). - SIG is the signal to give the inferior (zero for none). */ -static void -resume (step, sig) - int step; - int sig; -{ - struct cleanup *old_cleanups = make_cleanup (resume_cleanups, 0); - QUIT; - -#ifdef NO_SINGLE_STEP - if (step) { - single_step(); /* Do it the hard way, w/temp breakpoints */ - step = 0; /* ...and don't ask hardware to do it. */ - } -#endif - - /* Handle any optimized stores to the inferior NOW... */ -#ifdef DO_DEFERRED_STORES - DO_DEFERRED_STORES; -#endif - - target_resume (step, sig); - discard_cleanups (old_cleanups); -} - - -/* Clear out all variables saying what to do when inferior is continued. - First do this, then set the ones you want, then call `proceed'. */ - -void -clear_proceed_status () -{ - trap_expected = 0; - step_range_start = 0; - step_range_end = 0; - step_frame_address = 0; - step_over_calls = -1; - step_resume_break_address = 0; - stop_after_trap = 0; - stop_soon_quietly = 0; - proceed_to_finish = 0; - breakpoint_proceeded = 1; /* We're about to proceed... */ - - /* Discard any remaining commands or status from previous stop. */ - bpstat_clear (&stop_bpstat); -} - -/* Basic routine for continuing the program in various fashions. - - ADDR is the address to resume at, or -1 for resume where stopped. - SIGGNAL is the signal to give it, or 0 for none, - or -1 for act according to how it stopped. - STEP is nonzero if should trap after one instruction. - -1 means return after that and print nothing. - You should probably set various step_... variables - before calling here, if you are stepping. - - You should call clear_proceed_status before calling proceed. */ - -void -proceed (addr, siggnal, step) - CORE_ADDR addr; - int siggnal; - int step; -{ - int oneproc = 0; - - if (step > 0) - step_start_function = find_pc_function (read_pc ()); - if (step < 0) - stop_after_trap = 1; - - if (addr == (CORE_ADDR)-1) - { - /* If there is a breakpoint at the address we will resume at, - step one instruction before inserting breakpoints - so that we do not stop right away. */ - - if (!pc_changed && breakpoint_here_p (read_pc ())) - oneproc = 1; - } - else - { - write_register (PC_REGNUM, addr); -#ifdef NPC_REGNUM - write_register (NPC_REGNUM, addr + 4); -#ifdef NNPC_REGNUM - write_register (NNPC_REGNUM, addr + 8); -#endif -#endif - } - - if (trap_expected_after_continue) - { - /* If (step == 0), a trap will be automatically generated after - the first instruction is executed. Force step one - instruction to clear this condition. This should not occur - if step is nonzero, but it is harmless in that case. */ - oneproc = 1; - trap_expected_after_continue = 0; - } - - if (oneproc) - /* We will get a trace trap after one instruction. - Continue it automatically and insert breakpoints then. */ - trap_expected = 1; - else - { - int temp = insert_breakpoints (); - if (temp) - { - print_sys_errmsg ("ptrace", temp); - error ("Cannot insert breakpoints.\n\ -The same program may be running in another process."); - } - breakpoints_inserted = 1; - } - - /* Install inferior's terminal modes. */ - target_terminal_inferior (); - - if (siggnal >= 0) - stop_signal = siggnal; - /* If this signal should not be seen by program, - give it zero. Used for debugging signals. */ - else if (stop_signal < NSIG && !signal_program[stop_signal]) - stop_signal= 0; - - /* Resume inferior. */ - resume (oneproc || step || bpstat_should_step (), stop_signal); - - /* Wait for it to stop (if not standalone) - and in any case decode why it stopped, and act accordingly. */ - - wait_for_inferior (); - normal_stop (); -} - -#if 0 -/* This might be useful (not sure), but isn't currently used. See also - write_pc(). */ -/* Writing the inferior pc as a register calls this function - to inform infrun that the pc has been set in the debugger. */ - -void -writing_pc (val) - CORE_ADDR val; -{ - stop_pc = val; - pc_changed = 1; -} -#endif - -/* Record the pc and sp of the program the last time it stopped. - These are just used internally by wait_for_inferior, but need - to be preserved over calls to it and cleared when the inferior - is started. */ -static CORE_ADDR prev_pc; -static CORE_ADDR prev_sp; -static CORE_ADDR prev_func_start; -static char *prev_func_name; - - -/* Start an inferior Unix child process and sets inferior_pid to its pid. - EXEC_FILE is the file to run. - ALLARGS is a string containing the arguments to the program. - ENV is the environment vector to pass. Errors reported with error(). */ - -#ifndef SHELL_FILE -#define SHELL_FILE "/bin/sh" -#endif - -void -child_create_inferior (exec_file, allargs, env) - char *exec_file; - char *allargs; - char **env; -{ - int pid; - char *shell_command; - extern int sys_nerr; - extern char *sys_errlist[]; - char *shell_file; - static char default_shell_file[] = SHELL_FILE; - int len; - int pending_execs; - /* Set debug_fork then attach to the child while it sleeps, to debug. */ - static int debug_fork = 0; - /* This is set to the result of setpgrp, which if vforked, will be visible - to you in the parent process. It's only used by humans for debugging. */ - static int debug_setpgrp = 657473; - char **save_our_env; - - /* The user might want tilde-expansion, and in general probably wants - the program to behave the same way as if run from - his/her favorite shell. So we let the shell run it for us. - FIXME, this should probably search the local environment (as - modified by the setenv command), not the env gdb inherited. */ - shell_file = getenv ("SHELL"); - if (shell_file == NULL) - shell_file = default_shell_file; - - len = 5 + strlen (exec_file) + 1 + strlen (allargs) + 1 + /*slop*/ 10; - /* If desired, concat something onto the front of ALLARGS. - SHELL_COMMAND is the result. */ -#ifdef SHELL_COMMAND_CONCAT - shell_command = (char *) alloca (strlen (SHELL_COMMAND_CONCAT) + len); - strcpy (shell_command, SHELL_COMMAND_CONCAT); -#else - shell_command = (char *) alloca (len); - shell_command[0] = '\0'; -#endif - strcat (shell_command, "exec "); - strcat (shell_command, exec_file); - strcat (shell_command, " "); - strcat (shell_command, allargs); - - /* exec is said to fail if the executable is open. */ - close_exec_file (); - - /* Retain a copy of our environment variables, since the child will - replace the value of environ and if we're vforked, we have to - restore it. */ - save_our_env = environ; - - /* Tell the terminal handling subsystem what tty we plan to run on; - it will just record the information for later. */ - - new_tty_prefork (inferior_io_terminal); - - /* It is generally good practice to flush any possible pending stdio - output prior to doing a fork, to avoid the possibility of both the - parent and child flushing the same data after the fork. */ - - fflush (stdout); - fflush (stderr); - -#if defined(USG) && !defined(HAVE_VFORK) - pid = fork (); -#else - if (debug_fork) - pid = fork (); - else - pid = vfork (); -#endif - - if (pid < 0) - perror_with_name ("vfork"); - - if (pid == 0) - { - if (debug_fork) - sleep (debug_fork); - -#ifdef TIOCGPGRP - /* Run inferior in a separate process group. */ -#ifdef USG - debug_setpgrp = setpgrp (); -#else - debug_setpgrp = setpgrp (getpid (), getpid ()); -#endif - if (debug_setpgrp == -1) - perror("setpgrp failed in child"); -#endif /* TIOCGPGRP */ - -#ifdef SET_STACK_LIMIT_HUGE - /* Reset the stack limit back to what it was. */ - { - struct rlimit rlim; - - getrlimit (RLIMIT_STACK, &rlim); - rlim.rlim_cur = original_stack_limit; - setrlimit (RLIMIT_STACK, &rlim); - } -#endif /* SET_STACK_LIMIT_HUGE */ - - /* Ask the tty subsystem to switch to the one we specified earlier - (or to share the current terminal, if none was specified). */ - - new_tty (); - - /* Changing the signal handlers for the inferior after - a vfork can also change them for the superior, so we don't mess - with signals here. See comments in - initialize_signals for how we get the right signal handlers - for the inferior. */ - -#ifdef USE_PROC_FS - proc_set_exec_trap (); /* Use SVR4 /proc interface */ -#else - call_ptrace (0, 0, 0, 0); /* "Trace me, Dr. Memory!" */ -#endif - - /* There is no execlpe call, so we have to set the environment - for our child in the global variable. If we've vforked, this - clobbers the parent, but environ is restored a few lines down - in the parent. By the way, yes we do need to look down the - path to find $SHELL. Rich Pixley says so, and I agree. */ - environ = env; - execlp (shell_file, shell_file, "-c", shell_command, (char *)0); - - fprintf (stderr, "Cannot exec %s: %s.\n", shell_file, - errno < sys_nerr ? sys_errlist[errno] : "unknown error"); - fflush (stderr); - _exit (0177); - } - - /* Restore our environment in case a vforked child clob'd it. */ - environ = save_our_env; - - /* Now that we have a child process, make it our target. */ - push_target (&child_ops); - -#ifdef CREATE_INFERIOR_HOOK - CREATE_INFERIOR_HOOK (pid); -#endif - -/* The process was started by the fork that created it, - but it will have stopped one instruction after execing the shell. - Here we must get it up to actual execution of the real program. */ - - inferior_pid = pid; /* Needed for wait_for_inferior stuff below */ - - clear_proceed_status (); - -#if defined (START_INFERIOR_HOOK) - START_INFERIOR_HOOK (); -#endif - - /* We will get a trace trap after one instruction. - Continue it automatically. Eventually (after shell does an exec) - it will get another trace trap. Then insert breakpoints and continue. */ - -#ifdef START_INFERIOR_TRAPS_EXPECTED - pending_execs = START_INFERIOR_TRAPS_EXPECTED; -#else - pending_execs = 2; -#endif - - init_wait_for_inferior (); - - /* Set up the "saved terminal modes" of the inferior - based on what modes we are starting it with. */ - target_terminal_init (); - - /* Install inferior's terminal modes. */ - target_terminal_inferior (); - - while (1) - { - stop_soon_quietly = 1; /* Make wait_for_inferior be quiet */ - wait_for_inferior (); - if (stop_signal != SIGTRAP) - { - /* Let shell child handle its own signals in its own way */ - /* FIXME, what if child has exit()ed? Must exit loop somehow */ - resume (0, stop_signal); - } - else - { - /* We handle SIGTRAP, however; it means child did an exec. */ - if (0 == --pending_execs) - break; - resume (0, 0); /* Just make it go on */ - } - } - stop_soon_quietly = 0; - - /* We are now in the child process of interest, having exec'd the - correct program, and are poised at the first instruction of the - new program. */ -#ifdef SOLIB_CREATE_INFERIOR_HOOK - SOLIB_CREATE_INFERIOR_HOOK (); -#endif - - /* Should this perhaps just be a "proceed" call? FIXME */ - insert_step_breakpoint (); - breakpoints_failed = insert_breakpoints (); - if (!breakpoints_failed) - { - breakpoints_inserted = 1; - target_terminal_inferior(); - /* Start the child program going on its first instruction, single- - stepping if we need to. */ - resume (bpstat_should_step (), 0); - wait_for_inferior (); - normal_stop (); - } -} - -/* Start remote-debugging of a machine over a serial link. */ - -void -start_remote () -{ - init_wait_for_inferior (); - clear_proceed_status (); - stop_soon_quietly = 1; - trap_expected = 0; - wait_for_inferior (); - normal_stop (); -} - -/* Initialize static vars when a new inferior begins. */ - -void -init_wait_for_inferior () -{ - /* These are meaningless until the first time through wait_for_inferior. */ - prev_pc = 0; - prev_sp = 0; - prev_func_start = 0; - prev_func_name = NULL; - - trap_expected_after_continue = 0; - breakpoints_inserted = 0; - mark_breakpoints_out (); - stop_signal = 0; /* Don't confuse first call to proceed(). */ -} - - -/* Attach to process PID, then initialize for debugging it - and wait for the trace-trap that results from attaching. */ - -void -child_attach (args, from_tty) - char *args; - int from_tty; -{ - char *exec_file; - int pid; - - dont_repeat(); - - if (!args) - error_no_arg ("process-id to attach"); - -#ifndef ATTACH_DETACH - error ("Can't attach to a process on this machine."); -#else - pid = atoi (args); - - if (target_has_execution) - { - if (query ("A program is being debugged already. Kill it? ")) - target_kill ((char *)0, from_tty); - else - error ("Inferior not killed."); - } - - exec_file = (char *) get_exec_file (1); - - if (from_tty) - { - printf ("Attaching program: %s pid %d\n", - exec_file, pid); - fflush (stdout); - } - - attach (pid); - inferior_pid = pid; - push_target (&child_ops); - - mark_breakpoints_out (); - target_terminal_init (); - clear_proceed_status (); - stop_soon_quietly = 1; - /*proceed (-1, 0, -2);*/ - target_terminal_inferior (); - wait_for_inferior (); -#ifdef SOLIB_ADD - SOLIB_ADD ((char *)0, from_tty, (struct target_ops *)0); -#endif - normal_stop (); -#endif /* ATTACH_DETACH */ -} - -/* 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 GDB should read more commands. */ - -void -wait_for_inferior () -{ - WAITTYPE w; - int another_trap; - int random_signal; - CORE_ADDR stop_sp; - CORE_ADDR stop_func_start; - char *stop_func_name; - CORE_ADDR prologue_pc; - int stop_step_resume_break; - struct symtab_and_line sal; - int remove_breakpoints_on_following_step = 0; - int current_line; - -#if 0 - /* This no longer works now that read_register is lazy; - it might try to ptrace when the process is not stopped. */ - prev_pc = read_pc (); - (void) find_pc_partial_function (prev_pc, &prev_func_name, - &prev_func_start); - prev_func_start += FUNCTION_START_OFFSET; - prev_sp = read_register (SP_REGNUM); -#endif /* 0 */ - - sal = find_pc_line(prev_pc, 0); - current_line = sal.line; - - while (1) - { - /* Clean up saved state that will become invalid. */ - pc_changed = 0; - flush_cached_frames (); - registers_changed (); - - target_wait (&w); - - /* See if the process still exists; clean up if it doesn't. */ - if (WIFEXITED (w)) - { - target_terminal_ours (); /* Must do this before mourn anyway */ - if (WEXITSTATUS (w)) - printf ("\nProgram exited with code 0%o.\n", - (unsigned int)WEXITSTATUS (w)); - else - if (!batch_mode()) - printf ("\nProgram exited normally.\n"); - fflush (stdout); - target_mourn_inferior (); -#ifdef NO_SINGLE_STEP - one_stepped = 0; -#endif - stop_print_frame = 0; - break; - } - else if (!WIFSTOPPED (w)) - { - stop_print_frame = 0; - stop_signal = WTERMSIG (w); - target_terminal_ours (); /* Must do this before mourn anyway */ - target_kill ((char *)0, 0); /* kill mourns as well */ -#ifdef PRINT_RANDOM_SIGNAL - printf ("\nProgram terminated: "); - PRINT_RANDOM_SIGNAL (stop_signal); -#else - printf ("\nProgram terminated with signal %d, %s\n", - stop_signal, - stop_signal < NSIG - ? sys_siglist[stop_signal] - : "(undocumented)"); -#endif - printf ("The inferior process no longer exists.\n"); - fflush (stdout); -#ifdef NO_SINGLE_STEP - one_stepped = 0; -#endif - break; - } - -#ifdef NO_SINGLE_STEP - if (one_stepped) - single_step (0); /* This actually cleans up the ss */ -#endif /* NO_SINGLE_STEP */ - - stop_pc = read_pc (); - set_current_frame ( create_new_frame (read_register (FP_REGNUM), - read_pc ())); - - stop_frame_address = FRAME_FP (get_current_frame ()); - stop_sp = read_register (SP_REGNUM); - stop_func_start = 0; - stop_func_name = 0; - /* Don't care about return value; stop_func_start and stop_func_name - will both be 0 if it doesn't work. */ - (void) find_pc_partial_function (stop_pc, &stop_func_name, - &stop_func_start); - stop_func_start += FUNCTION_START_OFFSET; - another_trap = 0; - bpstat_clear (&stop_bpstat); - stop_step = 0; - stop_stack_dummy = 0; - stop_print_frame = 1; - stop_step_resume_break = 0; - random_signal = 0; - stopped_by_random_signal = 0; - breakpoints_failed = 0; - - /* Look at the cause of the stop, and decide what to do. - The alternatives are: - 1) break; to really stop and return to the debugger, - 2) drop through to start up again - (set another_trap to 1 to single step once) - 3) set random_signal to 1, and the decision between 1 and 2 - will be made according to the signal handling tables. */ - - stop_signal = WSTOPSIG (w); - - /* First, distinguish signals caused by the debugger from signals - that have to do with the program's own actions. - Note that breakpoint insns may cause SIGTRAP or SIGILL - or SIGEMT, depending on the operating system version. - Here we detect when a SIGILL or SIGEMT is really a breakpoint - and change it to SIGTRAP. */ - - if (stop_signal == SIGTRAP - || (breakpoints_inserted && - (stop_signal == SIGILL - || stop_signal == SIGEMT)) - || stop_soon_quietly) - { - if (stop_signal == SIGTRAP && stop_after_trap) - { - stop_print_frame = 0; - break; - } - if (stop_soon_quietly) - break; - - /* Don't even think about breakpoints - if just proceeded over a breakpoint. - - However, if we are trying to proceed over a breakpoint - and end up in sigtramp, then step_resume_break_address - will be set and we should check whether we've hit the - step breakpoint. */ - if (stop_signal == SIGTRAP && trap_expected - && step_resume_break_address == NULL) - bpstat_clear (&stop_bpstat); - else - { - /* See if there is a breakpoint at the current PC. */ -#if DECR_PC_AFTER_BREAK - /* Notice the case of stepping through a jump - that leads just after a breakpoint. - Don't confuse that with hitting the breakpoint. - What we check for is that 1) stepping is going on - and 2) the pc before the last insn does not match - the address of the breakpoint before the current pc. */ - if (!(prev_pc != stop_pc - DECR_PC_AFTER_BREAK - && step_range_end && !step_resume_break_address)) -#endif /* DECR_PC_AFTER_BREAK not zero */ - { - /* See if we stopped at the special breakpoint for - stepping over a subroutine call. If both are zero, - this wasn't the reason for the stop. */ - if (stop_pc - DECR_PC_AFTER_BREAK - == step_resume_break_address - && step_resume_break_address) - { - stop_step_resume_break = 1; - if (DECR_PC_AFTER_BREAK) - { - stop_pc -= DECR_PC_AFTER_BREAK; - write_register (PC_REGNUM, stop_pc); - pc_changed = 0; - } - } - else - { - stop_bpstat = - bpstat_stop_status (&stop_pc, stop_frame_address); - /* Following in case break condition called a - function. */ - stop_print_frame = 1; - } - } - } - - if (stop_signal == SIGTRAP) - random_signal - = !(bpstat_explains_signal (stop_bpstat) - || trap_expected - || stop_step_resume_break - || PC_IN_CALL_DUMMY (stop_pc, stop_sp, stop_frame_address) - || (step_range_end && !step_resume_break_address)); - else - { - random_signal - = !(bpstat_explains_signal (stop_bpstat) - || stop_step_resume_break - /* End of a stack dummy. Some systems (e.g. Sony - news) give another signal besides SIGTRAP, - so check here as well as above. */ - || (stop_sp INNER_THAN stop_pc - && stop_pc INNER_THAN stop_frame_address) - ); - if (!random_signal) - stop_signal = SIGTRAP; - } - } - else - random_signal = 1; - - /* For the program's own signals, act according to - the signal handling tables. */ - - if (random_signal) - { - /* Signal not for debugging purposes. */ - int printed = 0; - - stopped_by_random_signal = 1; - - if (stop_signal >= NSIG - || signal_print[stop_signal]) - { - printed = 1; - target_terminal_ours_for_output (); -#ifdef PRINT_RANDOM_SIGNAL - PRINT_RANDOM_SIGNAL (stop_signal); -#else - printf ("\nProgram received signal %d, %s\n", - stop_signal, - stop_signal < NSIG - ? sys_siglist[stop_signal] - : "(undocumented)"); -#endif /* PRINT_RANDOM_SIGNAL */ - fflush (stdout); - } - if (stop_signal >= NSIG - || signal_stop[stop_signal]) - break; - /* If not going to stop, give terminal back - if we took it away. */ - else if (printed) - target_terminal_inferior (); - - /* Note that virtually all the code below does `if !random_signal'. - Perhaps this code should end with a goto or continue. At least - one (now fixed) bug was caused by this -- a !random_signal was - missing in one of the tests below. */ - } - - /* Handle cases caused by hitting a breakpoint. */ - - if (!random_signal - && (bpstat_explains_signal (stop_bpstat) || stop_step_resume_break)) - { - /* Does a breakpoint want us to stop? */ - if (bpstat_stop (stop_bpstat)) - { - stop_print_frame = bpstat_should_print (stop_bpstat); - break; - } - /* But if we have hit the step-resumption breakpoint, - remove it. It has done its job getting us here. - The sp test is to make sure that we don't get hung - up in recursive calls in functions without frame - pointers. If the stack pointer isn't outside of - where the breakpoint was set (within a routine to be - stepped over), we're in the middle of a recursive - call. Not true for reg window machines (sparc) - because the must change frames to call things and - the stack pointer doesn't have to change if it - the bp was set in a routine without a frame (pc can - be stored in some other window). - - The removal of the sp test is to allow calls to - alloca. Nasty things were happening. Oh, well, - gdb can only handle one level deep of lack of - frame pointer. */ - if (stop_step_resume_break - && (step_frame_address == 0 - || (stop_frame_address == step_frame_address))) - { - remove_step_breakpoint (); - step_resume_break_address = 0; - - /* If were waiting for a trap, hitting the step_resume_break - doesn't count as getting it. */ - if (trap_expected) - another_trap = 1; - } - /* Otherwise, must remove breakpoints and single-step - to get us past the one we hit. */ - else - { - remove_breakpoints (); - remove_step_breakpoint (); - breakpoints_inserted = 0; - another_trap = 1; - } - - /* We come here if we hit a breakpoint but should not - stop for it. Possibly we also were stepping - and should stop for that. So fall through and - test for stepping. But, if not stepping, - do not stop. */ - } - - /* If this is the breakpoint at the end of a stack dummy, - just stop silently. */ - if (!random_signal - && PC_IN_CALL_DUMMY (stop_pc, stop_sp, stop_frame_address)) - { - stop_print_frame = 0; - stop_stack_dummy = 1; -#ifdef HP_OS_BUG - trap_expected_after_continue = 1; -#endif - break; - } - - if (step_resume_break_address) - /* Having a step-resume breakpoint overrides anything - else having to do with stepping commands until - that breakpoint is reached. */ - ; - /* If stepping through a line, keep going if still within it. */ - else if (!random_signal - && step_range_end - && stop_pc >= step_range_start - && stop_pc < step_range_end - /* The step range might include the start of the - function, so if we are at the start of the - step range and either the stack or frame pointers - just changed, we've stepped outside */ - && !(stop_pc == step_range_start - && stop_frame_address - && (stop_sp INNER_THAN prev_sp - || stop_frame_address != step_frame_address))) - { -#if 0 - /* When "next"ing through a function, - This causes an extra stop at the end. - Is there any reason for this? - It's confusing to the user. */ - /* Don't step through the return from a function - unless that is the first instruction stepped through. */ - if (ABOUT_TO_RETURN (stop_pc)) - { - stop_step = 1; - break; - } -#endif - } - - /* We stepped out of the stepping range. See if that was due - to a subroutine call that we should proceed to the end of. */ - else if (!random_signal && step_range_end) - { - if (stop_func_start) - { - prologue_pc = stop_func_start; - SKIP_PROLOGUE (prologue_pc); - } - - /* Did we just take a signal? */ - if (IN_SIGTRAMP (stop_pc, stop_func_name) - && !IN_SIGTRAMP (prev_pc, prev_func_name)) - { - /* This code is needed at least in the following case: - The user types "next" and then a signal arrives (before - the "next" is done). */ - /* We've just taken a signal; go until we are back to - the point where we took it and one more. */ - step_resume_break_address = prev_pc; - step_resume_break_duplicate = - breakpoint_here_p (step_resume_break_address); - if (breakpoints_inserted) - insert_step_breakpoint (); - /* Make sure that the stepping range gets us past - that instruction. */ - if (step_range_end == 1) - step_range_end = (step_range_start = prev_pc) + 1; - remove_breakpoints_on_following_step = 1; - } - - /* ==> See comments at top of file on this algorithm. <==*/ - - else if (stop_pc == stop_func_start - && (stop_func_start != prev_func_start - || prologue_pc != stop_func_start - || stop_sp != prev_sp)) - { - /* It's a subroutine call */ - if (step_over_calls > 0 - || (step_over_calls && find_pc_function (stop_pc) == 0)) - { - /* A subroutine call has happened. */ - /* Set a special breakpoint after the return */ - step_resume_break_address = - ADDR_BITS_REMOVE - (SAVED_PC_AFTER_CALL (get_current_frame ())); - step_resume_break_duplicate - = breakpoint_here_p (step_resume_break_address); - if (breakpoints_inserted) - insert_step_breakpoint (); - } - /* Subroutine call with source code we should not step over. - Do step to the first line of code in it. */ - else if (step_over_calls) - { - SKIP_PROLOGUE (stop_func_start); - sal = find_pc_line (stop_func_start, 0); - /* Use the step_resume_break to step until - the end of the prologue, even if that involves jumps - (as it seems to on the vax under 4.2). */ - /* If the prologue ends in the middle of a source line, - continue to the end of that source line. - Otherwise, just go to end of prologue. */ -#ifdef PROLOGUE_FIRSTLINE_OVERLAP - /* no, don't either. It skips any code that's - legitimately on the first line. */ -#else - if (sal.end && sal.pc != stop_func_start) - stop_func_start = sal.end; -#endif - - if (stop_func_start == stop_pc) - { - /* We are already there: stop now. */ - stop_step = 1; - break; - } - else - /* Put the step-breakpoint there and go until there. */ - { - step_resume_break_address = stop_func_start; - - step_resume_break_duplicate - = breakpoint_here_p (step_resume_break_address); - if (breakpoints_inserted) - insert_step_breakpoint (); - /* Do not specify what the fp should be when we stop - since on some machines the prologue - is where the new fp value is established. */ - step_frame_address = 0; - /* And make sure stepping stops right away then. */ - step_range_end = step_range_start; - } - } - else - { - /* We get here only if step_over_calls is 0 and we - just stepped into a subroutine. I presume - that step_over_calls is only 0 when we're - supposed to be stepping at the assembly - language level.*/ - stop_step = 1; - break; - } - } - /* No subroutine call; stop now. */ - else - { - /* We've wandered out of the step range (but we haven't done a - subroutine call or return (that's handled elsewhere)). We - don't really want to stop until we encounter the start of a - new statement. If so, we stop. Otherwise, we reset - step_range_start and step_range_end, and just continue. */ - sal = find_pc_line(stop_pc, 0); - - if (step_range_end == 1 || /* Don't do this for stepi/nexti */ - sal.line == 0 || /* Stop now if no line # info */ - (current_line != sal.line - && stop_pc == sal.pc)) { - stop_step = 1; - break; - } else { - /* This is probably not necessary, but it probably makes - stepping more efficient, as we avoid calling find_pc_line() - for each instruction we step over. */ - step_range_start = sal.pc; - step_range_end = sal.end; - } - } - } - - else if (trap_expected - && IN_SIGTRAMP (stop_pc, stop_func_name) - && !IN_SIGTRAMP (prev_pc, prev_func_name)) - { - /* What has happened here is that we have just stepped the inferior - with a signal (because it is a signal which shouldn't make - us stop), thus stepping into sigtramp. - - So we need to set a step_resume_break_address breakpoint - and continue until we hit it, and then step. */ - step_resume_break_address = prev_pc; - /* Always 1, I think, but it's probably easier to have - the step_resume_break as usual rather than trying to - re-use the breakpoint which is already there. */ - step_resume_break_duplicate = - breakpoint_here_p (step_resume_break_address); - if (breakpoints_inserted) - insert_step_breakpoint (); - remove_breakpoints_on_following_step = 1; - another_trap = 1; - } - - /* Save the pc before execution, to compare with pc after stop. */ - prev_pc = read_pc (); /* Might have been DECR_AFTER_BREAK */ - prev_func_start = stop_func_start; /* Ok, since if DECR_PC_AFTER - BREAK is defined, the - original pc would not have - been at the start of a - function. */ - prev_func_name = stop_func_name; - prev_sp = stop_sp; - - /* If we did not do break;, it means we should keep - running the inferior and not return to debugger. */ - - if (trap_expected && stop_signal != SIGTRAP) - { - /* We took a signal (which we are supposed to pass through to - the inferior, else we'd have done a break above) and we - haven't yet gotten our trap. Simply continue. */ - resume ((step_range_end && !step_resume_break_address) - || (trap_expected && !step_resume_break_address) - || bpstat_should_step (), - stop_signal); - } - else - { - /* Either the trap was not expected, but we are continuing - anyway (the user asked that this signal be passed to the - child) - -- or -- - The signal was SIGTRAP, e.g. it was our signal, but we - decided we should resume from it. - - We're going to run this baby now! - - Insert breakpoints now, unless we are trying - to one-proceed past a breakpoint. */ - /* If we've just finished a special step resume and we don't - want to hit a breakpoint, pull em out. */ - if (!step_resume_break_address && - remove_breakpoints_on_following_step) - { - remove_breakpoints_on_following_step = 0; - remove_breakpoints (); - breakpoints_inserted = 0; - } - else if (!breakpoints_inserted && - (step_resume_break_address != NULL || !another_trap)) - { - insert_step_breakpoint (); - breakpoints_failed = insert_breakpoints (); - if (breakpoints_failed) - break; - breakpoints_inserted = 1; - } - - trap_expected = another_trap; - - if (stop_signal == SIGTRAP) - stop_signal = 0; - -#ifdef SHIFT_INST_REGS - /* I'm not sure when this following segment applies. I do know, now, - that we shouldn't rewrite the regs when we were stopped by a - random signal from the inferior process. */ - - if (!bpstat_explains_signal (stop_bpstat) - && (stop_signal != SIGCLD) - && !stopped_by_random_signal) - { - CORE_ADDR pc_contents = read_register (PC_REGNUM); - CORE_ADDR npc_contents = read_register (NPC_REGNUM); - if (pc_contents != npc_contents) - { - write_register (NNPC_REGNUM, npc_contents); - write_register (NPC_REGNUM, pc_contents); - } - } -#endif /* SHIFT_INST_REGS */ - - resume ((step_range_end && !step_resume_break_address) - || (trap_expected && !step_resume_break_address) - || bpstat_should_step (), - stop_signal); - } - } - if (target_has_execution) - { - /* Assuming the inferior still exists, set these up for next - time, just like we did above if we didn't break out of the - loop. */ - prev_pc = read_pc (); - prev_func_start = stop_func_start; - prev_func_name = stop_func_name; - prev_sp = stop_sp; - } -} - -/* Here to return control to GDB when the inferior stops for real. - Print appropriate messages, remove breakpoints, give terminal our modes. - - STOP_PRINT_FRAME nonzero means print the executing frame - (pc, function, args, file, line number and line text). - BREAKPOINTS_FAILED nonzero means stop was due to error - attempting to insert breakpoints. */ - -void -normal_stop () -{ - /* Make sure that the current_frame's pc is correct. This - is a correction for setting up the frame info before doing - DECR_PC_AFTER_BREAK */ - if (target_has_execution) - (get_current_frame ())->pc = read_pc (); - - if (breakpoints_failed) - { - target_terminal_ours_for_output (); - print_sys_errmsg ("ptrace", breakpoints_failed); - printf ("Stopped; cannot insert breakpoints.\n\ -The same program may be running in another process.\n"); - } - - if (target_has_execution) - remove_step_breakpoint (); - - if (target_has_execution && breakpoints_inserted) - if (remove_breakpoints ()) - { - target_terminal_ours_for_output (); - printf ("Cannot remove breakpoints because program is no longer writable.\n\ -It might be running in another process.\n\ -Further execution is probably impossible.\n"); - } - - breakpoints_inserted = 0; - - /* Delete the breakpoint we stopped at, if it wants to be deleted. - Delete any breakpoint that is to be deleted at the next stop. */ - - breakpoint_auto_delete (stop_bpstat); - - /* If an auto-display called a function and that got a signal, - delete that auto-display to avoid an infinite recursion. */ - - if (stopped_by_random_signal) - disable_current_display (); - - if (step_multi && stop_step) - return; - - target_terminal_ours (); - - if (!target_has_stack) - return; - - /* Select innermost stack frame except on return from a stack dummy routine, - or if the program has exited. Print it without a level number if - we have changed functions or hit a breakpoint. Print source line - if we have one. */ - if (!stop_stack_dummy) - { - select_frame (get_current_frame (), 0); - - if (stop_print_frame) - { - int source_only; - - source_only = bpstat_print (stop_bpstat); - source_only = source_only || - ( stop_step - && step_frame_address == stop_frame_address - && step_start_function == find_pc_function (stop_pc)); - - print_stack_frame (selected_frame, -1, source_only? -1: 1); - - /* Display the auto-display expressions. */ - do_displays (); - } - } - - /* Save the function value return registers, if we care. - We might be about to restore their previous contents. */ - if (proceed_to_finish) - read_register_bytes (0, stop_registers, REGISTER_BYTES); - - if (stop_stack_dummy) - { - /* Pop the empty frame that contains the stack dummy. - POP_FRAME ends with a setting of the current frame, so we - can use that next. */ - POP_FRAME; - select_frame (get_current_frame (), 0); - } -} - -static void -insert_step_breakpoint () -{ - if (step_resume_break_address && !step_resume_break_duplicate) - target_insert_breakpoint (step_resume_break_address, - step_resume_break_shadow); -} - -static void -remove_step_breakpoint () -{ - if (step_resume_break_address && !step_resume_break_duplicate) - target_remove_breakpoint (step_resume_break_address, - step_resume_break_shadow); -} - -static void -sig_print_header () -{ - printf_filtered ("Signal\t\tStop\tPrint\tPass to program\tDescription\n"); -} - -static void -sig_print_info (number) - int number; -{ - char *abbrev = sig_abbrev(number); - if (abbrev == NULL) - printf_filtered ("%d\t\t", number); - else - printf_filtered ("SIG%s (%d)\t", abbrev, number); - printf_filtered ("%s\t", signal_stop[number] ? "Yes" : "No"); - printf_filtered ("%s\t", signal_print[number] ? "Yes" : "No"); - printf_filtered ("%s\t\t", signal_program[number] ? "Yes" : "No"); - printf_filtered ("%s\n", sys_siglist[number]); -} - -/* Specify how various signals in the inferior should be handled. */ - -static void -handle_command (args, from_tty) - char *args; - int from_tty; -{ - register char *p = args; - int signum = 0; - register int digits, wordlen; - char *nextarg; - - if (!args) - error_no_arg ("signal to handle"); - - while (*p) - { - /* Find the end of the next word in the args. */ - for (wordlen = 0; - p[wordlen] && p[wordlen] != ' ' && p[wordlen] != '\t'; - wordlen++); - /* Set nextarg to the start of the word after the one we just - found, and null-terminate this one. */ - if (p[wordlen] == '\0') - nextarg = p + wordlen; - else - { - p[wordlen] = '\0'; - nextarg = p + wordlen + 1; - } - - - for (digits = 0; p[digits] >= '0' && p[digits] <= '9'; digits++); - - if (signum == 0) - { - /* It is the first argument--must be the signal to operate on. */ - if (digits == wordlen) - { - /* Numeric. */ - signum = atoi (p); - if (signum <= 0 || signum >= NSIG) - { - p[wordlen] = '\0'; - error ("Invalid signal %s given as argument to \"handle\".", p); - } - } - else - { - /* Symbolic. */ - signum = sig_number (p); - if (signum == -1) - error ("No such signal \"%s\"", p); - } - - if (signum == SIGTRAP || signum == SIGINT) - { - if (!query ("SIG%s is used by the debugger.\nAre you sure you want to change it? ", sig_abbrev (signum))) - error ("Not confirmed."); - } - } - /* Else, if already got a signal number, look for flag words - saying what to do for it. */ - else if (!strncmp (p, "stop", wordlen)) - { - signal_stop[signum] = 1; - signal_print[signum] = 1; - } - else if (wordlen >= 2 && !strncmp (p, "print", wordlen)) - signal_print[signum] = 1; - else if (wordlen >= 2 && !strncmp (p, "pass", wordlen)) - signal_program[signum] = 1; - else if (!strncmp (p, "ignore", wordlen)) - signal_program[signum] = 0; - else if (wordlen >= 3 && !strncmp (p, "nostop", wordlen)) - signal_stop[signum] = 0; - else if (wordlen >= 4 && !strncmp (p, "noprint", wordlen)) - { - signal_print[signum] = 0; - signal_stop[signum] = 0; - } - else if (wordlen >= 4 && !strncmp (p, "nopass", wordlen)) - signal_program[signum] = 0; - else if (wordlen >= 3 && !strncmp (p, "noignore", wordlen)) - signal_program[signum] = 1; - /* Not a number and not a recognized flag word => complain. */ - else - { - error ("Unrecognized flag word: \"%s\".", p); - } - - /* Find start of next word. */ - p = nextarg; - while (*p == ' ' || *p == '\t') p++; - } - - if (from_tty) - { - /* Show the results. */ - sig_print_header (); - sig_print_info (signum); - } -} - -/* Print current contents of the tables set by the handle command. */ - -static void -signals_info (signum_exp) - char *signum_exp; -{ - register int i; - sig_print_header (); - - if (signum_exp) - { - /* First see if this is a symbol name. */ - i = sig_number (signum_exp); - if (i == -1) - { - /* Nope, maybe it's an address which evaluates to a signal - number. */ - i = parse_and_eval_address (signum_exp); - if (i >= NSIG || i < 0) - error ("Signal number out of bounds."); - } - sig_print_info (i); - return; - } - - printf_filtered ("\n"); - for (i = 0; i < NSIG; i++) - { - QUIT; - - sig_print_info (i); - } - - printf_filtered ("\nUse the \"handle\" command to change these tables.\n"); -} - -/* Save all of the information associated with the inferior<==>gdb - connection. INF_STATUS is a pointer to a "struct inferior_status" - (defined in inferior.h). */ - -void -save_inferior_status (inf_status, restore_stack_info) - struct inferior_status *inf_status; - int restore_stack_info; -{ - inf_status->pc_changed = pc_changed; - inf_status->stop_signal = stop_signal; - inf_status->stop_pc = stop_pc; - inf_status->stop_frame_address = stop_frame_address; - inf_status->stop_step = stop_step; - inf_status->stop_stack_dummy = stop_stack_dummy; - inf_status->stopped_by_random_signal = stopped_by_random_signal; - inf_status->trap_expected = trap_expected; - inf_status->step_range_start = step_range_start; - inf_status->step_range_end = step_range_end; - inf_status->step_frame_address = step_frame_address; - inf_status->step_over_calls = step_over_calls; - inf_status->step_resume_break_address = step_resume_break_address; - inf_status->stop_after_trap = stop_after_trap; - inf_status->stop_soon_quietly = stop_soon_quietly; - /* Save original bpstat chain here; replace it with copy of chain. - If caller's caller is walking the chain, they'll be happier if we - hand them back the original chain when restore_i_s is called. */ - inf_status->stop_bpstat = stop_bpstat; - stop_bpstat = bpstat_copy (stop_bpstat); - inf_status->breakpoint_proceeded = breakpoint_proceeded; - inf_status->restore_stack_info = restore_stack_info; - inf_status->proceed_to_finish = proceed_to_finish; - - bcopy (stop_registers, inf_status->stop_registers, REGISTER_BYTES); - - record_selected_frame (&(inf_status->selected_frame_address), - &(inf_status->selected_level)); - return; -} - -void -restore_inferior_status (inf_status) - struct inferior_status *inf_status; -{ - FRAME fid; - int level = inf_status->selected_level; - - pc_changed = inf_status->pc_changed; - stop_signal = inf_status->stop_signal; - stop_pc = inf_status->stop_pc; - stop_frame_address = inf_status->stop_frame_address; - stop_step = inf_status->stop_step; - stop_stack_dummy = inf_status->stop_stack_dummy; - stopped_by_random_signal = inf_status->stopped_by_random_signal; - trap_expected = inf_status->trap_expected; - step_range_start = inf_status->step_range_start; - step_range_end = inf_status->step_range_end; - step_frame_address = inf_status->step_frame_address; - step_over_calls = inf_status->step_over_calls; - step_resume_break_address = inf_status->step_resume_break_address; - stop_after_trap = inf_status->stop_after_trap; - stop_soon_quietly = inf_status->stop_soon_quietly; - bpstat_clear (&stop_bpstat); - stop_bpstat = inf_status->stop_bpstat; - breakpoint_proceeded = inf_status->breakpoint_proceeded; - proceed_to_finish = inf_status->proceed_to_finish; - - bcopy (inf_status->stop_registers, stop_registers, REGISTER_BYTES); - - /* The inferior can be gone if the user types "print exit(0)" - (and perhaps other times). */ - if (target_has_stack && inf_status->restore_stack_info) - { - fid = find_relative_frame (get_current_frame (), - &level); - - /* If inf_status->selected_frame_address is NULL, there was no - previously selected frame. */ - if (fid == 0 || - FRAME_FP (fid) != inf_status->selected_frame_address || - level != 0) - { -#if 0 - /* I'm not sure this error message is a good idea. I have - only seen it occur after "Can't continue previously - requested operation" (we get called from do_cleanups), in - which case it just adds insult to injury (one confusing - error message after another. Besides which, does the - user really care if we can't restore the previously - selected frame? */ - fprintf (stderr, "Unable to restore previously selected frame.\n"); -#endif - select_frame (get_current_frame (), 0); - return; - } - - select_frame (fid, inf_status->selected_level); - } -} - - -void -_initialize_infrun () -{ - register int i; - - add_info ("signals", signals_info, - "What debugger does when program gets various signals.\n\ -Specify a signal number as argument to print info on that signal only."); - - add_com ("handle", class_run, handle_command, - "Specify how to handle a signal.\n\ -Args are signal number followed by flags.\n\ -Flags allowed are \"stop\", \"print\", \"pass\",\n\ - \"nostop\", \"noprint\" or \"nopass\".\n\ -Print means print a message if this signal happens.\n\ -Stop means reenter debugger if this signal happens (implies print).\n\ -Pass means let program see this signal; otherwise program doesn't know.\n\ -Pass and Stop may be combined."); - - for (i = 0; i < NSIG; i++) - { - signal_stop[i] = 1; - signal_print[i] = 1; - signal_program[i] = 1; - } - - /* Signals caused by debugger's own actions - should not be given to the program afterwards. */ - signal_program[SIGTRAP] = 0; - signal_program[SIGINT] = 0; - - /* Signals that are not errors should not normally enter the debugger. */ -#ifdef SIGALRM - signal_stop[SIGALRM] = 0; - signal_print[SIGALRM] = 0; -#endif /* SIGALRM */ -#ifdef SIGVTALRM - signal_stop[SIGVTALRM] = 0; - signal_print[SIGVTALRM] = 0; -#endif /* SIGVTALRM */ -#ifdef SIGPROF - signal_stop[SIGPROF] = 0; - signal_print[SIGPROF] = 0; -#endif /* SIGPROF */ -#ifdef SIGCHLD - signal_stop[SIGCHLD] = 0; - signal_print[SIGCHLD] = 0; -#endif /* SIGCHLD */ -#ifdef SIGCLD - signal_stop[SIGCLD] = 0; - signal_print[SIGCLD] = 0; -#endif /* SIGCLD */ -#ifdef SIGIO - signal_stop[SIGIO] = 0; - signal_print[SIGIO] = 0; -#endif /* SIGIO */ -#ifdef SIGURG - signal_stop[SIGURG] = 0; - signal_print[SIGURG] = 0; -#endif /* SIGURG */ -} - diff --git a/gdb/infrun.hacked.c b/gdb/infrun.hacked.c deleted file mode 100644 index d38bd067a79..00000000000 --- a/gdb/infrun.hacked.c +++ /dev/null @@ -1,1707 +0,0 @@ -/* Start and stop the inferior process, for GDB. - Copyright (C) 1986, 1987, 1988, 1989 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Notes on the algorithm used in wait_for_inferior to determine if we - just did a subroutine call when stepping. We have the following - information at that point: - - Current and previous (just before this step) pc. - Current and previous sp. - Current and previous start of current function. - - If the start's of the functions don't match, then - - a) We did a subroutine call. - - In this case, the pc will be at the beginning of a function. - - b) We did a subroutine return. - - Otherwise. - - c) We did a longjmp. - - If we did a longjump, we were doing "nexti", since a next would - have attempted to skip over the assembly language routine in which - the longjmp is coded and would have simply been the equivalent of a - continue. I consider this ok behaivior. We'd like one of two - things to happen if we are doing a nexti through the longjmp() - routine: 1) It behaves as a stepi, or 2) It acts like a continue as - above. Given that this is a special case, and that anybody who - thinks that the concept of sub calls is meaningful in the context - of a longjmp, I'll take either one. Let's see what happens. - - Acts like a subroutine return. I can handle that with no problem - at all. - - -->So: If the current and previous beginnings of the current - function don't match, *and* the pc is at the start of a function, - we've done a subroutine call. If the pc is not at the start of a - function, we *didn't* do a subroutine call. - - -->If the beginnings of the current and previous function do match, - either: - - a) We just did a recursive call. - - In this case, we would be at the very beginning of a - function and 1) it will have a prologue (don't jump to - before prologue, or 2) (we assume here that it doesn't have - a prologue) there will have been a change in the stack - pointer over the last instruction. (Ie. it's got to put - the saved pc somewhere. The stack is the usual place. In - a recursive call a register is only an option if there's a - prologue to do something with it. This is even true on - register window machines; the prologue sets up the new - window. It might not be true on a register window machine - where the call instruction moved the register window - itself. Hmmm. One would hope that the stack pointer would - also change. If it doesn't, somebody send me a note, and - I'll work out a more general theory. - bug-gdb@prep.ai.mit.edu). This is true (albeit slipperly - so) on all machines I'm aware of: - - m68k: Call changes stack pointer. Regular jumps don't. - - sparc: Recursive calls must have frames and therefor, - prologues. - - vax: All calls have frames and hence change the - stack pointer. - - b) We did a return from a recursive call. I don't see that we - have either the ability or the need to distinguish this - from an ordinary jump. The stack frame will be printed - when and if the frame pointer changes; if we are in a - function without a frame pointer, it's the users own - lookout. - - c) We did a jump within a function. We assume that this is - true if we didn't do a recursive call. - - d) We are in no-man's land ("I see no symbols here"). We - don't worry about this; it will make calls look like simple - jumps (and the stack frames will be printed when the frame - pointer moves), which is a reasonably non-violent response. - -#if 0 - We skip this; it causes more problems than it's worth. -#ifdef SUN4_COMPILER_FEATURE - We do a special ifdef for the sun 4, forcing it to single step - into calls which don't have prologues. This means that we can't - nexti over leaf nodes, we can probably next over them (since they - won't have debugging symbols, usually), and we can next out of - functions returning structures (with a "call .stret4" at the end). -#endif -#endif -*/ - - - - - -#include -#include -#include "defs.h" -#include "param.h" -#include "symtab.h" -#include "frame.h" -#include "inferior.h" -#include "breakpoint.h" -#include "wait.h" -#include "gdbcore.h" -#include "signame.h" -#include "command.h" -#include "terminal.h" /* For #ifdef TIOCGPGRP and new_tty */ -#include "target.h" - -#include - -/* unistd.h is needed to #define X_OK */ -#ifdef USG -#include -#else -#include -#endif - -#ifdef SET_STACK_LIMIT_HUGE -extern int original_stack_limit; -#endif /* SET_STACK_LIMIT_HUGE */ - -/* Required by . */ -#include -/* Required by , at least on system V. */ -#include -/* Needed by IN_SIGTRAMP on some machines (e.g. vax). */ -#include -/* Needed by IN_SIGTRAMP on some machines (e.g. vax). */ -#include - -extern int errno; -extern char *getenv (); - -extern struct target_ops child_ops; /* In inftarg.c */ - -/* Copy of inferior_io_terminal when inferior was last started. */ - -extern char *inferior_thisrun_terminal; - - -/* 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) -#define IN_SIGTRAMP(pc, name) \ - name && !strcmp ("_sigtramp", name) -#endif - -/* Tables of how to react to signals; the user sets them. */ - -static char signal_stop[NSIG]; -static char signal_print[NSIG]; -static char signal_program[NSIG]; - -/* Nonzero if breakpoints are now inserted in the inferior. */ -/* Nonstatic for initialization during xxx_create_inferior. FIXME. */ - -/*static*/ int breakpoints_inserted; - -/* Function inferior was in as of last step command. */ - -static struct symbol *step_start_function; - -/* Nonzero => address for special breakpoint for resuming stepping. */ - -static CORE_ADDR step_resume_break_address; - -/* Pointer to orig contents of the byte where the special breakpoint is. */ - -static char step_resume_break_shadow[BREAKPOINT_MAX]; - -/* Nonzero means the special breakpoint is a duplicate - so it has not itself been inserted. */ - -static int step_resume_break_duplicate; - -/* Nonzero if we are expecting a trace trap and should proceed from it. */ - -static int trap_expected; - -/* Nonzero if the next time we try to continue the inferior, it will - step one instruction and generate a spurious trace trap. - This is used to compensate for a bug in HP-UX. */ - -static int trap_expected_after_continue; - -/* Nonzero means expecting a trace trap - and should stop the inferior and return silently when it happens. */ - -int stop_after_trap; - -/* Nonzero means expecting a trap and caller will handle it themselves. - It is used after attach, due to attaching to a process; - when running in the shell before the child program has been exec'd; - and when running some kinds of remote stuff (FIXME?). */ - -int stop_soon_quietly; - -/* Nonzero if pc has been changed by the debugger - since the inferior stopped. */ - -int pc_changed; - -/* Nonzero if proceed is being used for a "finish" command or a similar - situation when stop_registers should be saved. */ - -int proceed_to_finish; - -/* Save register contents here when about to pop a stack dummy frame, - if-and-only-if proceed_to_finish is set. - Thus this contains the return value from the called function (assuming - values are returned in a register). */ - -char stop_registers[REGISTER_BYTES]; - -/* Nonzero if program stopped due to error trying to insert breakpoints. */ - -static int breakpoints_failed; - -/* Nonzero after stop if current stack frame should be printed. */ - -static int stop_print_frame; - -#ifdef NO_SINGLE_STEP -extern int one_stepped; /* From machine dependent code */ -extern void single_step (); /* Same. */ -#endif /* NO_SINGLE_STEP */ - -static void insert_step_breakpoint (); -static void remove_step_breakpoint (); -/*static*/ void wait_for_inferior (); -void init_wait_for_inferior (); -static void normal_stop (); - - -/* Clear out all variables saying what to do when inferior is continued. - First do this, then set the ones you want, then call `proceed'. */ - -void -clear_proceed_status () -{ - trap_expected = 0; - step_range_start = 0; - step_range_end = 0; - step_frame_address = 0; - step_over_calls = -1; - step_resume_break_address = 0; - stop_after_trap = 0; - stop_soon_quietly = 0; - proceed_to_finish = 0; - breakpoint_proceeded = 1; /* We're about to proceed... */ - - /* Discard any remaining commands or status from previous stop. */ - bpstat_clear (&stop_bpstat); -} - -/* Basic routine for continuing the program in various fashions. - - ADDR is the address to resume at, or -1 for resume where stopped. - SIGGNAL is the signal to give it, or 0 for none, - or -1 for act according to how it stopped. - STEP is nonzero if should trap after one instruction. - -1 means return after that and print nothing. - You should probably set various step_... variables - before calling here, if you are stepping. - - You should call clear_proceed_status before calling proceed. */ - -void -proceed (addr, siggnal, step) - CORE_ADDR addr; - int siggnal; - int step; -{ - int oneproc = 0; - - if (step > 0) - step_start_function = find_pc_function (read_pc ()); - if (step < 0) - stop_after_trap = 1; - - if (addr == -1) - { - /* If there is a breakpoint at the address we will resume at, - step one instruction before inserting breakpoints - so that we do not stop right away. */ - - if (!pc_changed && breakpoint_here_p (read_pc ())) - oneproc = 1; - } - else - { - write_register (PC_REGNUM, addr); -#ifdef NPC_REGNUM - write_register (NPC_REGNUM, addr + 4); -#ifdef NNPC_REGNUM - write_register (NNPC_REGNUM, addr + 8); -#endif -#endif - } - - if (trap_expected_after_continue) - { - /* If (step == 0), a trap will be automatically generated after - the first instruction is executed. Force step one - instruction to clear this condition. This should not occur - if step is nonzero, but it is harmless in that case. */ - oneproc = 1; - trap_expected_after_continue = 0; - } - - if (oneproc) - /* We will get a trace trap after one instruction. - Continue it automatically and insert breakpoints then. */ - trap_expected = 1; - else - { - int temp = insert_breakpoints (); - if (temp) - { - print_sys_errmsg ("ptrace", temp); - error ("Cannot insert breakpoints.\n\ -The same program may be running in another process."); - } - breakpoints_inserted = 1; - } - - /* Install inferior's terminal modes. */ - target_terminal_inferior (); - - if (siggnal >= 0) - stop_signal = siggnal; - /* If this signal should not be seen by program, - give it zero. Used for debugging signals. */ - else if (stop_signal < NSIG && !signal_program[stop_signal]) - stop_signal= 0; - - /* Handle any optimized stores to the inferior NOW... */ -#ifdef DO_DEFERRED_STORES - DO_DEFERRED_STORES; -#endif - - /* Resume inferior. */ - target_resume (oneproc || step || bpstat_should_step (), stop_signal); - - /* Wait for it to stop (if not standalone) - and in any case decode why it stopped, and act accordingly. */ - - wait_for_inferior (); - normal_stop (); -} - -#if 0 -/* This might be useful (not sure), but isn't currently used. See also - write_pc(). */ -/* Writing the inferior pc as a register calls this function - to inform infrun that the pc has been set in the debugger. */ - -void -writing_pc (val) - CORE_ADDR val; -{ - stop_pc = val; - pc_changed = 1; -} -#endif - -/* Record the pc and sp of the program the last time it stopped. - These are just used internally by wait_for_inferior, but need - to be preserved over calls to it and cleared when the inferior - is started. */ -static CORE_ADDR prev_pc; -static CORE_ADDR prev_sp; -static CORE_ADDR prev_func_start; -static char *prev_func_name; - -/* Start an inferior Unix child process and sets inferior_pid to its pid. - EXEC_FILE is the file to run. - ALLARGS is a string containing the arguments to the program. - ENV is the environment vector to pass. Errors reported with error(). */ - -#ifndef SHELL_FILE -#define SHELL_FILE "/bin/sh" -#endif - -void -child_create_inferior (exec_file, allargs, env) - char *exec_file; - char *allargs; - char **env; -{ - int pid; - char *shell_command; - extern int sys_nerr; - extern char *sys_errlist[]; - extern int errno; - char *shell_file; - static char default_shell_file[] = SHELL_FILE; - int len; - int pending_execs; - /* Set debug_fork then attach to the child while it sleeps, to debug. */ - static int debug_fork = 0; - /* This is set to the result of setpgrp, which if vforked, will be visible - to you in the parent process. It's only used by humans for debugging. */ - static int debug_setpgrp = 657473; - - /* The user might want tilde-expansion, and in general probably wants - the program to behave the same way as if run from - his/her favorite shell. So we let the shell run it for us. - FIXME, this should probably search the local environment (as - modified by the setenv command), not the env gdb inherited. */ - shell_file = getenv ("SHELL"); - if (shell_file == NULL) - shell_file = default_shell_file; - - len = 5 + strlen (exec_file) + 1 + strlen (allargs) + 1 + /*slop*/ 10; - /* If desired, concat something onto the front of ALLARGS. - SHELL_COMMAND is the result. */ -#ifdef SHELL_COMMAND_CONCAT - shell_command = (char *) alloca (strlen (SHELL_COMMAND_CONCAT) + len); - strcpy (shell_command, SHELL_COMMAND_CONCAT); -#else - shell_command = (char *) alloca (len); - shell_command[0] = '\0'; -#endif - strcat (shell_command, "exec "); - strcat (shell_command, exec_file); - strcat (shell_command, " "); - strcat (shell_command, allargs); - - /* exec is said to fail if the executable is open. */ - close_exec_file (); - -#if defined(USG) && !defined(HAVE_VFORK) - pid = fork (); -#else - if (debug_fork) - pid = fork (); - else - pid = vfork (); -#endif - - if (pid < 0) - perror_with_name ("vfork"); - - if (pid == 0) - { - if (debug_fork) - sleep (debug_fork); - -#ifdef TIOCGPGRP - /* Run inferior in a separate process group. */ - debug_setpgrp = setpgrp (getpid (), getpid ()); - if (0 != debug_setpgrp) - perror("setpgrp failed in child"); -#endif /* TIOCGPGRP */ - -#ifdef SET_STACK_LIMIT_HUGE - /* Reset the stack limit back to what it was. */ - { - struct rlimit rlim; - - getrlimit (RLIMIT_STACK, &rlim); - rlim.rlim_cur = original_stack_limit; - setrlimit (RLIMIT_STACK, &rlim); - } -#endif /* SET_STACK_LIMIT_HUGE */ - - /* Tell the terminal handling subsystem what tty we plan to run on; - it will now switch to that one if non-null. */ - - new_tty (inferior_io_terminal); - - /* Changing the signal handlers for the inferior after - a vfork can also change them for the superior, so we don't mess - with signals here. See comments in - initialize_signals for how we get the right signal handlers - for the inferior. */ - - call_ptrace (0, 0, 0, 0); /* "Trace me, Dr. Memory!" */ - execle (shell_file, shell_file, "-c", shell_command, (char *)0, env); - - fprintf (stderr, "Cannot exec %s: %s.\n", shell_file, - errno < sys_nerr ? sys_errlist[errno] : "unknown error"); - fflush (stderr); - _exit (0177); - } - - /* Now that we have a child process, make it our target. */ - push_target (&child_ops); - -#ifdef CREATE_INFERIOR_HOOK - CREATE_INFERIOR_HOOK (pid); -#endif - -/* The process was started by the fork that created it, - but it will have stopped one instruction after execing the shell. - Here we must get it up to actual execution of the real program. */ - - inferior_pid = pid; /* Needed for wait_for_inferior stuff below */ - - clear_proceed_status (); - -#if defined (START_INFERIOR_HOOK) - START_INFERIOR_HOOK (); -#endif - - /* We will get a trace trap after one instruction. - Continue it automatically. Eventually (after shell does an exec) - it will get another trace trap. Then insert breakpoints and continue. */ - -#ifdef START_INFERIOR_TRAPS_EXPECTED - pending_execs = START_INFERIOR_TRAPS_EXPECTED; -#else - pending_execs = 2; -#endif - - init_wait_for_inferior (); - - /* Set up the "saved terminal modes" of the inferior - based on what modes we are starting it with. */ - target_terminal_init (); - - /* Install inferior's terminal modes. */ - target_terminal_inferior (); - - while (1) - { - stop_soon_quietly = 1; /* Make wait_for_inferior be quiet */ - wait_for_inferior (); - if (stop_signal != SIGTRAP) - { - /* Let shell child handle its own signals in its own way */ - /* FIXME, what if child has exit()ed? Must exit loop somehow */ - target_resume (0, stop_signal); - } - else - { - /* We handle SIGTRAP, however; it means child did an exec. */ - if (0 == --pending_execs) - break; - target_resume (0, 0); /* Just make it go on */ - } - } - stop_soon_quietly = 0; - - /* Should this perhaps just be a "proceed" call? FIXME */ - insert_step_breakpoint (); - breakpoints_failed = insert_breakpoints (); - if (!breakpoints_failed) - { - breakpoints_inserted = 1; - target_terminal_inferior(); - /* Start the child program going on its first instruction, single- - stepping if we need to. */ - target_resume (bpstat_should_step (), 0); - wait_for_inferior (); - normal_stop (); - } -} - -/* Start remote-debugging of a machine over a serial link. */ - -void -start_remote () -{ - init_wait_for_inferior (); - clear_proceed_status (); - stop_soon_quietly = 1; - trap_expected = 0; -} - -/* Initialize static vars when a new inferior begins. */ - -void -init_wait_for_inferior () -{ - /* These are meaningless until the first time through wait_for_inferior. */ - prev_pc = 0; - prev_sp = 0; - prev_func_start = 0; - prev_func_name = NULL; - - trap_expected_after_continue = 0; - breakpoints_inserted = 0; - mark_breakpoints_out (); -} - - -/* Attach to process PID, then initialize for debugging it - and wait for the trace-trap that results from attaching. */ - -void -child_open (args, from_tty) - char *args; - int from_tty; -{ - char *exec_file; - int pid; - - dont_repeat(); - - if (!args) - error_no_arg ("process-id to attach"); - -#ifndef ATTACH_DETACH - error ("Can't attach to a process on this machine."); -#else - pid = atoi (args); - - if (target_has_execution) - { - if (query ("A program is being debugged already. Kill it? ")) - target_kill ((char *)0, from_tty); - else - error ("Inferior not killed."); - } - - exec_file = (char *) get_exec_file (1); - - if (from_tty) - { - printf ("Attaching program: %s pid %d\n", - exec_file, pid); - fflush (stdout); - } - - attach (pid); - inferior_pid = pid; - push_target (&child_ops); - - mark_breakpoints_out (); - target_terminal_init (); - clear_proceed_status (); - stop_soon_quietly = 1; - /*proceed (-1, 0, -2);*/ - target_terminal_inferior (); - wait_for_inferior (); - normal_stop (); -#endif /* ATTACH_DETACH */ -} - -/* 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 GDB should read more commands. */ - -void -wait_for_inferior () -{ - WAITTYPE w; - int another_trap; - int random_signal; - CORE_ADDR stop_sp; - CORE_ADDR stop_func_start; - char *stop_func_name; - CORE_ADDR prologue_pc; - int stop_step_resume_break; - struct symtab_and_line sal; - int remove_breakpoints_on_following_step = 0; - -#if 0 - /* This no longer works now that read_register is lazy; - it might try to ptrace when the process is not stopped. */ - prev_pc = read_pc (); - (void) find_pc_partial_function (prev_pc, &prev_func_name, - &prev_func_start); - prev_func_start += FUNCTION_START_OFFSET; - prev_sp = read_register (SP_REGNUM); -#endif /* 0 */ - - while (1) - { - /* Clean up saved state that will become invalid. */ - pc_changed = 0; - flush_cached_frames (); - registers_changed (); - - target_wait (&w); - - /* See if the process still exists; clean up if it doesn't. */ - if (WIFEXITED (w)) - { - target_terminal_ours_for_output (); - if (WEXITSTATUS (w)) - printf ("\nProgram exited with code 0%o.\n", - (unsigned int)WEXITSTATUS (w)); - else - if (!batch_mode()) - printf ("\nProgram exited normally.\n"); - fflush (stdout); - target_mourn_inferior (); -#ifdef NO_SINGLE_STEP - one_stepped = 0; -#endif - stop_print_frame = 0; - break; - } - else if (!WIFSTOPPED (w)) - { - target_kill ((char *)0, 0); - stop_print_frame = 0; - stop_signal = WTERMSIG (w); - target_terminal_ours_for_output (); - printf ("\nProgram terminated with signal %d, %s\n", - stop_signal, - stop_signal < NSIG - ? sys_siglist[stop_signal] - : "(undocumented)"); - printf ("The inferior process no longer exists.\n"); - fflush (stdout); -#ifdef NO_SINGLE_STEP - one_stepped = 0; -#endif - break; - } - -#ifdef NO_SINGLE_STEP - if (one_stepped) - single_step (0); /* This actually cleans up the ss */ -#endif /* NO_SINGLE_STEP */ - - stop_pc = read_pc (); - set_current_frame ( create_new_frame (read_register (FP_REGNUM), - read_pc ())); - - stop_frame_address = FRAME_FP (get_current_frame ()); - stop_sp = read_register (SP_REGNUM); - stop_func_start = 0; - stop_func_name = 0; - /* Don't care about return value; stop_func_start and stop_func_name - will both be 0 if it doesn't work. */ - (void) find_pc_partial_function (stop_pc, &stop_func_name, - &stop_func_start); - stop_func_start += FUNCTION_START_OFFSET; - another_trap = 0; - bpstat_clear (&stop_bpstat); - stop_step = 0; - stop_stack_dummy = 0; - stop_print_frame = 1; - stop_step_resume_break = 0; - random_signal = 0; - stopped_by_random_signal = 0; - breakpoints_failed = 0; - - /* Look at the cause of the stop, and decide what to do. - The alternatives are: - 1) break; to really stop and return to the debugger, - 2) drop through to start up again - (set another_trap to 1 to single step once) - 3) set random_signal to 1, and the decision between 1 and 2 - will be made according to the signal handling tables. */ - - stop_signal = WSTOPSIG (w); - - /* First, distinguish signals caused by the debugger from signals - that have to do with the program's own actions. - Note that breakpoint insns may cause SIGTRAP or SIGILL - or SIGEMT, depending on the operating system version. - Here we detect when a SIGILL or SIGEMT is really a breakpoint - and change it to SIGTRAP. */ - - if (stop_signal == SIGTRAP - || (breakpoints_inserted && - (stop_signal == SIGILL - || stop_signal == SIGEMT)) - || stop_soon_quietly) - { - if (stop_signal == SIGTRAP && stop_after_trap) - { - stop_print_frame = 0; - break; - } - if (stop_soon_quietly) - break; - - /* Don't even think about breakpoints - if just proceeded over a breakpoint. - - However, if we are trying to proceed over a breakpoint - and end up in sigtramp, then step_resume_break_address - will be set and we should check whether we've hit the - step breakpoint. */ - if (stop_signal == SIGTRAP && trap_expected - && step_resume_break_address == NULL) - bpstat_clear (&stop_bpstat); - else - { - /* See if there is a breakpoint at the current PC. */ -#if DECR_PC_AFTER_BREAK - /* Notice the case of stepping through a jump - that leads just after a breakpoint. - Don't confuse that with hitting the breakpoint. - What we check for is that 1) stepping is going on - and 2) the pc before the last insn does not match - the address of the breakpoint before the current pc. */ - if (!(prev_pc != stop_pc - DECR_PC_AFTER_BREAK - && step_range_end && !step_resume_break_address)) -#endif /* DECR_PC_AFTER_BREAK not zero */ - { - /* See if we stopped at the special breakpoint for - stepping over a subroutine call. */ - if (stop_pc - DECR_PC_AFTER_BREAK - == step_resume_break_address) - { - stop_step_resume_break = 1; - if (DECR_PC_AFTER_BREAK) - { - stop_pc -= DECR_PC_AFTER_BREAK; - write_register (PC_REGNUM, stop_pc); - pc_changed = 0; - } - } - else - { - stop_bpstat = - bpstat_stop_status (&stop_pc, stop_frame_address); - /* Following in case break condition called a - function. */ - stop_print_frame = 1; - } - } - } - - if (stop_signal == SIGTRAP) - random_signal - = !(bpstat_explains_signal (stop_bpstat) - || trap_expected - || stop_step_resume_break - || PC_IN_CALL_DUMMY (stop_pc, stop_sp, stop_frame_address) - || (step_range_end && !step_resume_break_address)); - else - { - random_signal - = !(bpstat_explains_signal (stop_bpstat) - || stop_step_resume_break - /* End of a stack dummy. Some systems (e.g. Sony - news) give another signal besides SIGTRAP, - so check here as well as above. */ - || (stop_sp INNER_THAN stop_pc - && stop_pc INNER_THAN stop_frame_address) - ); - if (!random_signal) - stop_signal = SIGTRAP; - } - } - else - random_signal = 1; - - /* For the program's own signals, act according to - the signal handling tables. */ - - if (random_signal) - { - /* Signal not for debugging purposes. */ - int printed = 0; - - stopped_by_random_signal = 1; - - if (stop_signal >= NSIG - || signal_print[stop_signal]) - { - printed = 1; - target_terminal_ours_for_output (); -#ifdef PRINT_RANDOM_SIGNAL - PRINT_RANDOM_SIGNAL (stop_signal); -#else - printf ("\nProgram received signal %d, %s\n", - stop_signal, - stop_signal < NSIG - ? sys_siglist[stop_signal] - : "(undocumented)"); -#endif /* PRINT_RANDOM_SIGNAL */ - fflush (stdout); - } - if (stop_signal >= NSIG - || signal_stop[stop_signal]) - break; - /* If not going to stop, give terminal back - if we took it away. */ - else if (printed) - target_terminal_inferior (); - } - - /* Handle cases caused by hitting a user breakpoint. */ - - if (!random_signal && bpstat_explains_signal (stop_bpstat)) - { - /* Does a breakpoint want us to stop? */ - if (bpstat_stop (stop_bpstat)) - { - stop_print_frame = bpstat_should_print (stop_bpstat); - break; - } - - /* Otherwise we continue. Must remove breakpoints and single-step - to get us past the one we hit. Possibly we also were stepping - and should stop for that. So fall through and - test for stepping. But, if not stepping, - do not stop. */ - else - { - remove_breakpoints (); - remove_step_breakpoint (); /* FIXME someday, do we need this? */ - breakpoints_inserted = 0; - another_trap = 1; - } - } - - /* Handle cases caused by hitting a step-resumption breakpoint. */ - - else if (!random_signal && stop_step_resume_break) - { - /* We have hit the step-resumption breakpoint. - If we aren't in a recursive call that hit it again - before returning from the original call, remove it; - it has done its job getting us here. We then resume - the stepping we were doing before the function call. - - If we are in a recursive call, just proceed from this - breakpoint as usual, keeping it around to catch the final - return of interest. - - There used to be an sp test to make sure that we don't get hung - up in recursive calls in functions without frame - pointers. If the stack pointer isn't outside of - where the breakpoint was set (within a routine to be - stepped over), we're in the middle of a recursive - call. Not true for reg window machines (sparc) - because they must change frames to call things and - the stack pointer doesn't have to change if - the bp was set in a routine without a frame (pc can - be stored in some other window). - - The removal of the sp test is to allow calls to - alloca. Nasty things were happening. Oh, well, - gdb can only handle one level deep of lack of - frame pointer. */ - if (step_frame_address == 0 - || (stop_frame_address == step_frame_address)) - { - /* We really hit it: not a recursive call. */ - remove_step_breakpoint (); - step_resume_break_address = 0; - - /* If we're waiting for a trap, hitting the step_resume_break - doesn't count as getting it. */ - if (trap_expected) - another_trap = 1; - /* Fall through to resume stepping... */ - } - else - { - /* Otherwise, it's the recursive call case. */ - remove_breakpoints (); - remove_step_breakpoint (); - breakpoints_inserted = 0; - another_trap = 1; - /* Fall through to continue executing at full speed - (with a possible single-step lurch over the step-resumption - breakpoint as we start.) */ - } - } - - /* If this is the breakpoint at the end of a stack dummy, - just stop silently. */ - if (PC_IN_CALL_DUMMY (stop_pc, stop_sp, stop_frame_address)) - { - stop_print_frame = 0; - stop_stack_dummy = 1; -#ifdef HP_OS_BUG - trap_expected_after_continue = 1; -#endif - break; - } - - if (step_resume_break_address) - /* Having a step-resume breakpoint overrides anything - else having to do with stepping commands until - that breakpoint is reached. */ - ; - /* If stepping through a line, keep going if still within it. */ - else if (!random_signal - && step_range_end - && stop_pc >= step_range_start - && stop_pc < step_range_end - /* The step range might include the start of the - function, so if we are at the start of the - step range and either the stack or frame pointers - just changed, we've stepped outside */ - && !(stop_pc == step_range_start - && stop_frame_address - && (stop_sp INNER_THAN prev_sp - || stop_frame_address != step_frame_address))) - { -#if 0 - /* When "next"ing through a function, - This causes an extra stop at the end. - Is there any reason for this? - It's confusing to the user. */ - /* Don't step through the return from a function - unless that is the first instruction stepped through. */ - if (ABOUT_TO_RETURN (stop_pc)) - { - stop_step = 1; - break; - } -#endif - } - - /* We stepped out of the stepping range. See if that was due - to a subroutine call that we should proceed to the end of. */ - else if (!random_signal && step_range_end) - { - if (stop_func_start) - { - prologue_pc = stop_func_start; - SKIP_PROLOGUE (prologue_pc); - } - - /* Did we just take a signal? */ - if (IN_SIGTRAMP (stop_pc, stop_func_name) - && !IN_SIGTRAMP (prev_pc, prev_func_name)) - { - /* This code is needed at least in the following case: - The user types "next" and then a signal arrives (before - the "next" is done). */ - /* We've just taken a signal; go until we are back to - the point where we took it and one more. */ - step_resume_break_address = prev_pc; - step_resume_break_duplicate = - breakpoint_here_p (step_resume_break_address); - if (breakpoints_inserted) - insert_step_breakpoint (); - /* Make sure that the stepping range gets us past - that instruction. */ - if (step_range_end == 1) - step_range_end = (step_range_start = prev_pc) + 1; - remove_breakpoints_on_following_step = 1; - } - - /* ==> See comments at top of file on this algorithm. <==*/ - - else if (stop_pc == stop_func_start - && (stop_func_start != prev_func_start - || prologue_pc != stop_func_start - || stop_sp != prev_sp)) - { - /* It's a subroutine call */ - if (step_over_calls > 0 - || (step_over_calls && find_pc_function (stop_pc) == 0)) - { - /* A subroutine call has happened. */ - /* Set a special breakpoint after the return */ - step_resume_break_address = - ADDR_BITS_REMOVE - (SAVED_PC_AFTER_CALL (get_current_frame ())); - step_resume_break_duplicate - = breakpoint_here_p (step_resume_break_address); - if (breakpoints_inserted) - insert_step_breakpoint (); - } - /* Subroutine call with source code we should not step over. - Do step to the first line of code in it. */ - else if (step_over_calls) - { - SKIP_PROLOGUE (stop_func_start); - sal = find_pc_line (stop_func_start, 0); - /* Use the step_resume_break to step until - the end of the prologue, even if that involves jumps - (as it seems to on the vax under 4.2). */ - /* If the prologue ends in the middle of a source line, - continue to the end of that source line. - Otherwise, just go to end of prologue. */ -#ifdef PROLOGUE_FIRSTLINE_OVERLAP - /* no, don't either. It skips any code that's - legitimately on the first line. */ -#else - if (sal.end && sal.pc != stop_func_start) - stop_func_start = sal.end; -#endif - - if (stop_func_start == stop_pc) - { - /* We are already there: stop now. */ - stop_step = 1; - break; - } - else - /* Put the step-breakpoint there and go until there. */ - { - step_resume_break_address = stop_func_start; - - step_resume_break_duplicate - = breakpoint_here_p (step_resume_break_address); - if (breakpoints_inserted) - insert_step_breakpoint (); - /* Do not specify what the fp should be when we stop - since on some machines the prologue - is where the new fp value is established. */ - step_frame_address = 0; - /* And make sure stepping stops right away then. */ - step_range_end = step_range_start; - } - } - else - { - /* We get here only if step_over_calls is 0 and we - just stepped into a subroutine. I presume - that step_over_calls is only 0 when we're - supposed to be stepping at the assembly - language level.*/ - stop_step = 1; - break; - } - } - /* No subroutine call; stop now. */ - else - { - stop_step = 1; - break; - } - } - - else if (trap_expected - && IN_SIGTRAMP (stop_pc, stop_func_name) - && !IN_SIGTRAMP (prev_pc, prev_func_name)) - { - /* What has happened here is that we have just stepped the inferior - with a signal (because it is a signal which shouldn't make - us stop), thus stepping into sigtramp. - - So we need to set a step_resume_break_address breakpoint - and continue until we hit it, and then step. */ - step_resume_break_address = prev_pc; - /* Always 1, I think, but it's probably easier to have - the step_resume_break as usual rather than trying to - re-use the breakpoint which is already there. */ - step_resume_break_duplicate = - breakpoint_here_p (step_resume_break_address); - if (breakpoints_inserted) - insert_step_breakpoint (); - remove_breakpoints_on_following_step = 1; - another_trap = 1; - } - - /* Save the pc before execution, to compare with pc after stop. */ - prev_pc = read_pc (); /* Might have been DECR_AFTER_BREAK */ - prev_func_start = stop_func_start; /* Ok, since if DECR_PC_AFTER - BREAK is defined, the - original pc would not have - been at the start of a - function. */ - prev_func_name = stop_func_name; - prev_sp = stop_sp; - - /* If we did not do break;, it means we should keep - running the inferior and not return to debugger. */ - - if (trap_expected && stop_signal != SIGTRAP) - { - /* We took a signal (which we are supposed to pass through to - the inferior, else we'd have done a break above) and we - haven't yet gotten our trap. Simply continue. */ - target_resume ((step_range_end && !step_resume_break_address) - || (trap_expected && !step_resume_break_address) - || bpstat_should_step (), - stop_signal); - } - else - { - /* Either the trap was not expected, but we are continuing - anyway (the user asked that this signal be passed to the - child) - -- or -- - The signal was SIGTRAP, e.g. it was our signal, but we - decided we should resume from it. - - We're going to run this baby now! - - Insert breakpoints now, unless we are trying - to one-proceed past a breakpoint. */ - /* If we've just finished a special step resume and we don't - want to hit a breakpoint, pull em out. */ - if (!step_resume_break_address && - remove_breakpoints_on_following_step) - { - remove_breakpoints_on_following_step = 0; - remove_breakpoints (); - breakpoints_inserted = 0; - } - else if (!breakpoints_inserted && - (step_resume_break_address != NULL || !another_trap)) - { - insert_step_breakpoint (); - breakpoints_failed = insert_breakpoints (); - if (breakpoints_failed) - break; - breakpoints_inserted = 1; - } - - trap_expected = another_trap; - - if (stop_signal == SIGTRAP) - stop_signal = 0; - -#ifdef SHIFT_INST_REGS - /* I'm not sure when this following segment applies. I do know, now, - that we shouldn't rewrite the regs when we were stopped by a - random signal from the inferior process. */ - - if (!stop_breakpoint && (stop_signal != SIGCLD) - && !stopped_by_random_signal) - { - CORE_ADDR pc_contents = read_register (PC_REGNUM); - CORE_ADDR npc_contents = read_register (NPC_REGNUM); - if (pc_contents != npc_contents) - { - write_register (NNPC_REGNUM, npc_contents); - write_register (NPC_REGNUM, pc_contents); - } - } -#endif /* SHIFT_INST_REGS */ - - target_resume ((step_range_end && !step_resume_break_address) - || (trap_expected && !step_resume_break_address) - || bpstat_should_step (), - stop_signal); - } - } - if (target_has_execution) - { - /* Assuming the inferior still exists, set these up for next - time, just like we did above if we didn't break out of the - loop. */ - prev_pc = read_pc (); - prev_func_start = stop_func_start; - prev_func_name = stop_func_name; - prev_sp = stop_sp; - } -} - -/* Here to return control to GDB when the inferior stops for real. - Print appropriate messages, remove breakpoints, give terminal our modes. - - STOP_PRINT_FRAME nonzero means print the executing frame - (pc, function, args, file, line number and line text). - BREAKPOINTS_FAILED nonzero means stop was due to error - attempting to insert breakpoints. */ - -static void -normal_stop () -{ - /* Make sure that the current_frame's pc is correct. This - is a correction for setting up the frame info before doing - DECR_PC_AFTER_BREAK */ - if (target_has_execution) - (get_current_frame ())->pc = read_pc (); - - if (breakpoints_failed) - { - target_terminal_ours_for_output (); - print_sys_errmsg ("ptrace", breakpoints_failed); - printf ("Stopped; cannot insert breakpoints.\n\ -The same program may be running in another process.\n"); - } - - if (target_has_execution) - remove_step_breakpoint (); - - if (target_has_execution && breakpoints_inserted) - if (remove_breakpoints ()) - { - target_terminal_ours_for_output (); - printf ("Cannot remove breakpoints because program is no longer writable.\n\ -It must be running in another process.\n\ -Further execution is probably impossible.\n"); - } - - breakpoints_inserted = 0; - - /* Delete the breakpoint we stopped at, if it wants to be deleted. - Delete any breakpoint that is to be deleted at the next stop. */ - - breakpoint_auto_delete (stop_bpstat); - - /* If an auto-display called a function and that got a signal, - delete that auto-display to avoid an infinite recursion. */ - - if (stopped_by_random_signal) - disable_current_display (); - - if (step_multi && stop_step) - return; - - target_terminal_ours (); - - if (!target_has_stack) - return; - - /* Select innermost stack frame except on return from a stack dummy routine, - or if the program has exited. */ - if (!stop_stack_dummy) - { - select_frame (get_current_frame (), 0); - - if (stop_print_frame) - { - int source_only = bpstat_print (stop_bpstat); - print_sel_frame - (source_only - || (stop_step - && step_frame_address == stop_frame_address - && step_start_function == find_pc_function (stop_pc))); - - /* Display the auto-display expressions. */ - do_displays (); - } - } - - /* Save the function value return registers, if we care. - We might be about to restore their previous contents. */ - if (proceed_to_finish) - read_register_bytes (0, stop_registers, REGISTER_BYTES); - - if (stop_stack_dummy) - { - /* Pop the empty frame that contains the stack dummy. - POP_FRAME ends with a setting of the current frame, so we - can use that next. */ - POP_FRAME; - select_frame (get_current_frame (), 0); - } -} - -static void -insert_step_breakpoint () -{ - if (step_resume_break_address && !step_resume_break_duplicate) - target_insert_breakpoint (step_resume_break_address, - step_resume_break_shadow); -} - -static void -remove_step_breakpoint () -{ - if (step_resume_break_address && !step_resume_break_duplicate) - target_remove_breakpoint (step_resume_break_address, - step_resume_break_shadow); -} - -static void -sig_print_header () -{ - printf_filtered ("Signal\t\tStop\tPrint\tPass to program\tDescription\n"); -} - -static void -sig_print_info (number) - int number; -{ - char *abbrev = sig_abbrev(number); - if (abbrev == NULL) - printf_filtered ("%d\t\t", number); - else - printf_filtered ("SIG%s (%d)\t", abbrev, number); - printf_filtered ("%s\t", signal_stop[number] ? "Yes" : "No"); - printf_filtered ("%s\t", signal_print[number] ? "Yes" : "No"); - printf_filtered ("%s\t\t", signal_program[number] ? "Yes" : "No"); - printf_filtered ("%s\n", sys_siglist[number]); -} - -/* Specify how various signals in the inferior should be handled. */ - -static void -handle_command (args, from_tty) - char *args; - int from_tty; -{ - register char *p = args; - int signum = 0; - register int digits, wordlen; - char *nextarg; - - if (!args) - error_no_arg ("signal to handle"); - - while (*p) - { - /* Find the end of the next word in the args. */ - for (wordlen = 0; - p[wordlen] && p[wordlen] != ' ' && p[wordlen] != '\t'; - wordlen++); - /* Set nextarg to the start of the word after the one we just - found, and null-terminate this one. */ - if (p[wordlen] == '\0') - nextarg = p + wordlen; - else - { - p[wordlen] = '\0'; - nextarg = p + wordlen + 1; - } - - - for (digits = 0; p[digits] >= '0' && p[digits] <= '9'; digits++); - - if (signum == 0) - { - /* It is the first argument--must be the signal to operate on. */ - if (digits == wordlen) - { - /* Numeric. */ - signum = atoi (p); - if (signum <= 0 || signum >= NSIG) - { - p[wordlen] = '\0'; - error ("Invalid signal %s given as argument to \"handle\".", p); - } - } - else - { - /* Symbolic. */ - signum = sig_number (p); - if (signum == -1) - error ("No such signal \"%s\"", p); - } - - if (signum == SIGTRAP || signum == SIGINT) - { - if (!query ("SIG%s is used by the debugger.\nAre you sure you want to change it? ", sig_abbrev (signum))) - error ("Not confirmed."); - } - } - /* Else, if already got a signal number, look for flag words - saying what to do for it. */ - else if (!strncmp (p, "stop", wordlen)) - { - signal_stop[signum] = 1; - signal_print[signum] = 1; - } - else if (wordlen >= 2 && !strncmp (p, "print", wordlen)) - signal_print[signum] = 1; - else if (wordlen >= 2 && !strncmp (p, "pass", wordlen)) - signal_program[signum] = 1; - else if (!strncmp (p, "ignore", wordlen)) - signal_program[signum] = 0; - else if (wordlen >= 3 && !strncmp (p, "nostop", wordlen)) - signal_stop[signum] = 0; - else if (wordlen >= 4 && !strncmp (p, "noprint", wordlen)) - { - signal_print[signum] = 0; - signal_stop[signum] = 0; - } - else if (wordlen >= 4 && !strncmp (p, "nopass", wordlen)) - signal_program[signum] = 0; - else if (wordlen >= 3 && !strncmp (p, "noignore", wordlen)) - signal_program[signum] = 1; - /* Not a number and not a recognized flag word => complain. */ - else - { - error ("Unrecognized flag word: \"%s\".", p); - } - - /* Find start of next word. */ - p = nextarg; - while (*p == ' ' || *p == '\t') p++; - } - - if (from_tty) - { - /* Show the results. */ - sig_print_header (); - sig_print_info (signum); - } -} - -/* Print current contents of the tables set by the handle command. */ - -static void -signals_info (signum_exp) - char *signum_exp; -{ - register int i; - sig_print_header (); - - if (signum_exp) - { - /* First see if this is a symbol name. */ - i = sig_number (signum_exp); - if (i == -1) - { - /* Nope, maybe it's an address which evaluates to a signal - number. */ - i = parse_and_eval_address (signum_exp); - if (i >= NSIG || i < 0) - error ("Signal number out of bounds."); - } - sig_print_info (i); - return; - } - - printf_filtered ("\n"); - for (i = 0; i < NSIG; i++) - { - QUIT; - - sig_print_info (i); - } - - printf_filtered ("\nUse the \"handle\" command to change these tables.\n"); -} - -/* Save all of the information associated with the inferior<==>gdb - connection. INF_STATUS is a pointer to a "struct inferior_status" - (defined in inferior.h). */ - -void -save_inferior_status (inf_status, restore_stack_info) - struct inferior_status *inf_status; - int restore_stack_info; -{ - inf_status->pc_changed = pc_changed; - inf_status->stop_signal = stop_signal; - inf_status->stop_pc = stop_pc; - inf_status->stop_frame_address = stop_frame_address; - inf_status->stop_step = stop_step; - inf_status->stop_stack_dummy = stop_stack_dummy; - inf_status->stopped_by_random_signal = stopped_by_random_signal; - inf_status->trap_expected = trap_expected; - inf_status->step_range_start = step_range_start; - inf_status->step_range_end = step_range_end; - inf_status->step_frame_address = step_frame_address; - inf_status->step_over_calls = step_over_calls; - inf_status->step_resume_break_address = step_resume_break_address; - inf_status->stop_after_trap = stop_after_trap; - inf_status->stop_soon_quietly = stop_soon_quietly; - /* Save original bpstat chain here; replace it with copy of chain. - If caller's caller is walking the chain, they'll be happier if we - hand them back the original chain when restore_i_s is called. */ - inf_status->stop_bpstat = stop_bpstat; - stop_bpstat = bpstat_copy (stop_bpstat); - inf_status->breakpoint_proceeded = breakpoint_proceeded; - inf_status->restore_stack_info = restore_stack_info; - inf_status->proceed_to_finish = proceed_to_finish; - - bcopy (stop_registers, inf_status->stop_registers, REGISTER_BYTES); - - record_selected_frame (&(inf_status->selected_frame_address), - &(inf_status->selected_level)); - return; -} - -void -restore_inferior_status (inf_status) - struct inferior_status *inf_status; -{ - FRAME fid; - int level = inf_status->selected_level; - - pc_changed = inf_status->pc_changed; - stop_signal = inf_status->stop_signal; - stop_pc = inf_status->stop_pc; - stop_frame_address = inf_status->stop_frame_address; - stop_step = inf_status->stop_step; - stop_stack_dummy = inf_status->stop_stack_dummy; - stopped_by_random_signal = inf_status->stopped_by_random_signal; - trap_expected = inf_status->trap_expected; - step_range_start = inf_status->step_range_start; - step_range_end = inf_status->step_range_end; - step_frame_address = inf_status->step_frame_address; - step_over_calls = inf_status->step_over_calls; - step_resume_break_address = inf_status->step_resume_break_address; - stop_after_trap = inf_status->stop_after_trap; - stop_soon_quietly = inf_status->stop_soon_quietly; - bpstat_clear (&stop_bpstat); - stop_bpstat = inf_status->stop_bpstat; - breakpoint_proceeded = inf_status->breakpoint_proceeded; - proceed_to_finish = inf_status->proceed_to_finish; - - bcopy (inf_status->stop_registers, stop_registers, REGISTER_BYTES); - - /* The inferior can be gone if the user types "print exit(0)" - (and perhaps other times). */ - if (target_has_stack && inf_status->restore_stack_info) - { - fid = find_relative_frame (get_current_frame (), - &level); - - if (fid == 0 || - FRAME_FP (fid) != inf_status->selected_frame_address || - level != 0) - { -#if 0 - /* I'm not sure this error message is a good idea. I have - only seen it occur after "Can't continue previously - requested operation" (we get called from do_cleanups), in - which case it just adds insult to injury (one confusing - error message after another. Besides which, does the - user really care if we can't restore the previously - selected frame? */ - fprintf (stderr, "Unable to restore previously selected frame.\n"); -#endif - select_frame (get_current_frame (), 0); - return; - } - - select_frame (fid, inf_status->selected_level); - } -} - - -void -_initialize_infrun () -{ - register int i; - - add_info ("signals", signals_info, - "What debugger does when program gets various signals.\n\ -Specify a signal number as argument to print info on that signal only."); - - add_com ("handle", class_run, handle_command, - "Specify how to handle a signal.\n\ -Args are signal number followed by flags.\n\ -Flags allowed are \"stop\", \"print\", \"pass\",\n\ - \"nostop\", \"noprint\" or \"nopass\".\n\ -Print means print a message if this signal happens.\n\ -Stop means reenter debugger if this signal happens (implies print).\n\ -Pass means let program see this signal; otherwise program doesn't know.\n\ -Pass and Stop may be combined."); - - for (i = 0; i < NSIG; i++) - { - signal_stop[i] = 1; - signal_print[i] = 1; - signal_program[i] = 1; - } - - /* Signals caused by debugger's own actions - should not be given to the program afterwards. */ - signal_program[SIGTRAP] = 0; - signal_program[SIGINT] = 0; - - /* Signals that are not errors should not normally enter the debugger. */ -#ifdef SIGALRM - signal_stop[SIGALRM] = 0; - signal_print[SIGALRM] = 0; -#endif /* SIGALRM */ -#ifdef SIGVTALRM - signal_stop[SIGVTALRM] = 0; - signal_print[SIGVTALRM] = 0; -#endif /* SIGVTALRM */ -#ifdef SIGPROF - signal_stop[SIGPROF] = 0; - signal_print[SIGPROF] = 0; -#endif /* SIGPROF */ -#ifdef SIGCHLD - signal_stop[SIGCHLD] = 0; - signal_print[SIGCHLD] = 0; -#endif /* SIGCHLD */ -#ifdef SIGCLD - signal_stop[SIGCLD] = 0; - signal_print[SIGCLD] = 0; -#endif /* SIGCLD */ -#ifdef SIGIO - signal_stop[SIGIO] = 0; - signal_print[SIGIO] = 0; -#endif /* SIGIO */ -#ifdef SIGURG - signal_stop[SIGURG] = 0; - signal_print[SIGURG] = 0; -#endif /* SIGURG */ -} - diff --git a/gdb/inftarg.c b/gdb/inftarg.c deleted file mode 100644 index 9e3f72980b1..00000000000 --- a/gdb/inftarg.c +++ /dev/null @@ -1,195 +0,0 @@ -/* Subroutines for handling an "inferior" (child) process as a target - for debugging, in GDB. - Copyright 1990, 1991 Free Software Foundation, Inc. - Contributed by Cygnus Support. - -This file is part of GDB. - -GDB 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 1, or (at your option) -any later version. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "defs.h" -#include "param.h" -#include "frame.h" /* required by inferior.h */ -#include "inferior.h" -#include "target.h" -#include "wait.h" -#include "gdbcore.h" -#include "ieee-float.h" /* Required by REGISTER_CONVERT_TO_XXX */ - -extern int fetch_inferior_registers(); -extern int store_inferior_registers(); -extern int child_xfer_memory(); -extern int memory_insert_breakpoint(), memory_remove_breakpoint(); -extern void terminal_init_inferior(), terminal_ours(), terminal_inferior(); -extern void terminal_ours_for_output(), child_terminal_info(); -extern void kill_inferior(), add_syms_addr_command(); -extern struct value *call_function_by_hand(); -extern void child_resume(); -extern void child_create_inferior(); -extern void child_mourn_inferior(); -extern void child_attach (); - -/* Forward declaration */ -extern struct target_ops child_ops; - -/* Wait for child to do something. Return pid of child, or -1 in case - of error; store status through argument pointer STATUS. */ - -int -child_wait (status) - int *status; -{ - int pid; - - do { - pid = wait (status); - if (pid == -1) /* No more children to wait for */ - { - fprintf (stderr, "Child process unexpectedly missing.\n"); - *status = 42; /* Claim it exited with signal 42 */ - return -1; - } - } while (pid != inferior_pid); /* Some other child died or stopped */ - return pid; -} - - -/* - * child_detach() - * takes a program previously attached to and detaches it. - * The program resumes execution and will no longer stop - * on signals, etc. We better not have left any breakpoints - * in the program or it'll die when it hits one. For this - * to work, it may be necessary for the process to have been - * previously attached. It *might* work if the program was - * started via the normal ptrace (PTRACE_TRACEME). - */ - -static void -child_detach (args, from_tty) - char *args; - int from_tty; -{ - int siggnal = 0; - -#ifdef ATTACH_DETACH - if (from_tty) - { - char *exec_file = get_exec_file (0); - if (exec_file == 0) - exec_file = ""; - printf ("Detaching program: %s pid %d\n", - exec_file, inferior_pid); - fflush (stdout); - } - if (args) - siggnal = atoi (args); - - detach (siggnal); - inferior_pid = 0; - unpush_target (&child_ops); /* Pop out of handling an inferior */ -#else - error ("This version of Unix does not support detaching a process."); -#endif -} - -/* Get ready to modify the registers array. On machines which store - individual registers, this doesn't need to do anything. On machines - which store all the registers in one fell swoop, this makes sure - that registers contains all the registers from the program being - debugged. */ - -void -child_prepare_to_store () -{ -#ifdef CHILD_PREPARE_TO_STORE - CHILD_PREPARE_TO_STORE (); -#endif -} - -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ - -/* Some machines won't need to use regnum. */ -/* ARGSUSED */ -void -host_convert_to_virtual (regnum, from, to) - int regnum; - char *from; - char *to; -{ - REGISTER_CONVERT_TO_VIRTUAL (regnum, from, to); -} - -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ - -/* ARGSUSED */ -void -host_convert_from_virtual (regnum, from, to) - int regnum; - char *from; - char *to; -{ - REGISTER_CONVERT_TO_RAW (regnum, from, to); -} - -/* Print status information about what we're accessing. */ - -static void -child_files_info () -{ - printf ("\tUsing the running image of %s process %d.\n", - attach_flag? "attached": "child", inferior_pid); -} - -/* ARGSUSED */ -static void -child_open (arg, from_tty) - char *arg; - int from_tty; -{ - error ("Use the \"run\" command to start a Unix child process."); -} - -struct target_ops child_ops = { - "child", "Unix child process", - "Unix child process (started by the \"run\" command).", - child_open, 0, /* open, close */ - child_attach, child_detach, - child_resume, - child_wait, - fetch_inferior_registers, store_inferior_registers, - child_prepare_to_store, - host_convert_to_virtual, host_convert_from_virtual, - child_xfer_memory, child_files_info, - memory_insert_breakpoint, memory_remove_breakpoint, - terminal_init_inferior, terminal_inferior, - terminal_ours_for_output, terminal_ours, child_terminal_info, - kill_inferior, 0, add_syms_addr_command, /* load */ - call_function_by_hand, - 0, /* lookup_symbol */ - child_create_inferior, child_mourn_inferior, - process_stratum, 0, /* next */ - 1, 1, 1, 1, 1, /* all mem, mem, stack, regs, exec */ - OPS_MAGIC, /* Always the last thing */ -}; - -void -_initialize_inftarg () -{ - add_target (&child_ops); -} diff --git a/gdb/kdb-start.c b/gdb/kdb-start.c deleted file mode 100644 index 50e2fa91deb..00000000000 --- a/gdb/kdb-start.c +++ /dev/null @@ -1,40 +0,0 @@ -/* Main loop for the standalone kernel debugger. - Copyright (C) 1989, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include "defs.h" -#include "param.h" - -static char *args[] = {"kdb", "kdb-symbols", 0}; - -static char *environment[] = {0}; - -char **environ; - -start () -{ -#ifdef NAMES_HAVE_UNDERSCORE - INIT_STACK (_kdb_stack_beg, _kdb_stack_end); -#else /* not NAMES_HAVE_UNDERSCORE */ - INIT_STACK (kdb_stack_beg, kdb_stack_end); -#endif /* not NAMES_HAVE_UNDERSCORE */ - - environ = environment; - - main (2, args, environment); -} diff --git a/gdb/language.c b/gdb/language.c deleted file mode 100644 index c584d4efc63..00000000000 --- a/gdb/language.c +++ /dev/null @@ -1,1106 +0,0 @@ -/* Multiple source language support for GDB. - Copyright 1991 Free Software Foundation, Inc. - Contributed by the Department of Computer Science at the State University - of New York at Buffalo. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* This file contains functions that return things that are specific - to languages. Each function should examine current_language if necessary, - and return the appropriate result. */ - -/* FIXME: Most of these would be better organized as macros which - return data out of a "language-specific" struct pointer that is set - whenever the working language changes. That would be a lot faster. */ - -#include -#include -#include - -#include "defs.h" -#include "symtab.h" -#include "value.h" -#include "gdbcmd.h" -#include "frame.h" -#include "language.h" -#include "expression.h" -#include "target.h" -#include "parser-defs.h" - -extern volatile void return_to_top_level (); - -/* Forward function declarations */ -static void set_type_range (); - -/* Forward declaration */ -extern struct language_defn unknown_language_defn; - -/* The current (default at startup) state of type and range checking. - (If the modes are set to "auto", though, these are changed based - on the default language at startup, and then again based on the - language of the first source file. */ - -enum range_mode range_mode = range_mode_auto; -enum range_check range_check = range_check_off; -enum type_mode type_mode = type_mode_auto; -enum type_check type_check = type_check_off; - -/* The current language and language_mode (see language.h) */ - -struct language_defn *current_language = &unknown_language_defn; -enum language_mode language_mode = language_mode_auto; - -/* The list of supported languages. The list itself is malloc'd. */ - -static struct language_defn **languages; -static unsigned languages_size; -static unsigned languages_allocsize; -#define DEFAULT_ALLOCSIZE 3 - -/* The "set language/type/range" commands all put stuff in these - buffers. This is to make them work as set/show commands. The - user's string is copied here, then the set_* commands look at - them and update them to something that looks nice when it is - printed out. */ - -static char *language; -static char *type; -static char *range; - -/* Warning issued when current_language and the language of the current - frame do not match. */ -char lang_frame_mismatch_warn[] = - "Warning: the current language does not match this frame."; - -void set_lang_str(); -void set_type_str(); -void set_range_str(); - -/* This page contains the functions corresponding to GDB commands - and their helpers. */ - -/* Show command. Display a warning if the language set - does not match the frame. */ -void -show_language_command (ignore, from_tty) - char *ignore; - int from_tty; -{ - enum language flang; /* The language of the current frame */ - - flang = get_frame_language(); - if (flang != language_unknown && - language_mode == language_mode_manual && - current_language->la_language != flang) - printf_filtered("%s\n",lang_frame_mismatch_warn); -} - -/* Set command. Change the current working language. */ -void -set_language_command (ignore, from_tty) - char *ignore; - int from_tty; -{ - int i; - enum language flang; - char *err_lang; - - /* FIXME -- do this from the list, with HELP. */ - if (!language || !language[0]) { - printf("The currently understood settings are:\n\n\ -local or auto Automatic setting based on source file\n\ -c Use the C language\n\ -c++ Use the C++ language\n\ -modula-2 Use the Modula-2 language\n"); - /* Restore the silly string. */ - set_language(current_language->la_language); - return; - } - - /* Search the list of languages for a match. */ - for (i = 0; i < languages_size; i++) { - if (!strcmp (languages[i]->la_name, language)) { - /* Found it! Go into manual mode, and use this language. */ - if (languages[i]->la_language == language_auto) { - /* Enter auto mode. Set to the current frame's language, if known. */ - language_mode = language_mode_auto; - flang = get_frame_language(); - if (flang!=language_unknown) - set_language(flang); - return; - } else { - /* Enter manual mode. Set the specified language. */ - language_mode = language_mode_manual; - current_language = languages[i]; - set_type_range (); - set_lang_str(); - return; - } - } - } - - /* Reset the language (esp. the global string "language") to the - correct values. */ - err_lang=savestring(language,strlen(language)); - make_cleanup (free, err_lang); /* Free it after error */ - set_language(current_language->la_language); - error ("Unknown language `%s'.",err_lang); -} - -/* Show command. Display a warning if the type setting does - not match the current language. */ -void -show_type_command(ignore, from_tty) - char *ignore; - int from_tty; -{ - if (type_check != current_language->la_type_check) - printf( -"Warning: the current type check setting does not match the language.\n"); -} - -/* Set command. Change the setting for type checking. */ -void -set_type_command(ignore, from_tty) - char *ignore; - int from_tty; -{ - if (!strcmp(type,"on")) - { - type_check = type_check_on; - type_mode = type_mode_manual; - } - else if (!strcmp(type,"warn")) - { - type_check = type_check_warn; - type_mode = type_mode_manual; - } - else if (!strcmp(type,"off")) - { - type_check = type_check_off; - type_mode = type_mode_manual; - } - else if (!strcmp(type,"auto")) - { - type_mode = type_mode_auto; - set_type_range(); - /* Avoid hitting the set_type_str call below. We - did it in set_type_range. */ - return; - } - set_type_str(); - show_type_command((char *)NULL, from_tty); -} - -/* Show command. Display a warning if the range setting does - not match the current language. */ -void -show_range_command(ignore, from_tty) - char *ignore; - int from_tty; -{ - - if (range_check != current_language->la_range_check) - printf( -"Warning: the current range check setting does not match the language.\n"); -} - -/* Set command. Change the setting for range checking. */ -void -set_range_command(ignore, from_tty) - char *ignore; - int from_tty; -{ - if (!strcmp(range,"on")) - { - range_check = range_check_on; - range_mode = range_mode_manual; - } - else if (!strcmp(range,"warn")) - { - range_check = range_check_warn; - range_mode = range_mode_manual; - } - else if (!strcmp(range,"off")) - { - range_check = range_check_off; - range_mode = range_mode_manual; - } - else if (!strcmp(range,"auto")) - { - range_mode = range_mode_auto; - set_type_range(); - /* Avoid hitting the set_range_str call below. We - did it in set_type_range. */ - return; - } - set_range_str(); - show_range_command((char *)0, from_tty); -} - -/* Set the status of range and type checking based on - the current modes and the current language. - If SHOW is non-zero, then print out the current language, - type and range checking status. */ -static void -set_type_range() -{ - - if (range_mode == range_mode_auto) - range_check = current_language->la_range_check; - - if (type_mode == type_mode_auto) - type_check = current_language->la_type_check; - - set_type_str(); - set_range_str(); -} - -/* Set current language to (enum language) LANG. */ - -void -set_language(lang) - enum language lang; -{ - int i; - - for (i = 0; i < languages_size; i++) { - if (languages[i]->la_language == lang) { - current_language = languages[i]; - set_type_range (); - set_lang_str(); - break; - } - } -} - -/* This page contains functions that update the global vars - language, type and range. */ -void -set_lang_str() -{ - char *prefix = ""; - - free (language); - if (language_mode == language_mode_auto) - prefix = "auto; currently "; - - language = concat(prefix, current_language->la_name, NULL); -} - -void -set_type_str() -{ - char *tmp, *prefix = ""; - - free (type); - if (type_mode==type_mode_auto) - prefix = "auto; currently "; - - switch(type_check) - { - case type_check_on: - tmp = "on"; - break; - case type_check_off: - tmp = "off"; - break; - case type_check_warn: - tmp = "warn"; - break; - default: - error ("Unrecognized type check setting."); - } - - type = concat(prefix,tmp,NULL); -} - -void -set_range_str() -{ - char *tmp, *pref = ""; - - free (range); - if (range_mode==range_mode_auto) - pref = "auto; currently "; - - switch(range_check) - { - case range_check_on: - tmp = "on"; - break; - case range_check_off: - tmp = "off"; - break; - case range_check_warn: - tmp = "warn"; - break; - default: - error ("Unrecognized range check setting."); - } - - range = concat(pref,tmp,NULL); -} - - -/* Print out the current language settings: language, range and - type checking. */ -void -language_info () -{ - printf("Current Language: %s\n",language); - show_language_command((char *)0, 1); - printf("Type checking: %s\n",type); - show_type_command((char *)0, 1); - printf("Range checking: %s\n",range); - show_range_command((char *)0, 1); -} - -/* Return the result of a binary operation. */ -struct type * -binop_result_type(v1,v2) - value v1,v2; -{ - int l1,l2,size,uns; - - l1 = TYPE_LENGTH(VALUE_TYPE(v1)); - l2 = TYPE_LENGTH(VALUE_TYPE(v2)); - - switch(current_language->la_language) - { - case language_c: - case language_cplus: - if (TYPE_CODE(VALUE_TYPE(v1))==TYPE_CODE_FLT) - return TYPE_CODE(VALUE_TYPE(v2)) == TYPE_CODE_FLT && l2 > l1 ? - VALUE_TYPE(v2) : VALUE_TYPE(v1); - else if (TYPE_CODE(VALUE_TYPE(v2))==TYPE_CODE_FLT) - return TYPE_CODE(VALUE_TYPE(v1)) == TYPE_CODE_FLT && l1 > l2 ? - VALUE_TYPE(v1) : VALUE_TYPE(v2); - else if (TYPE_UNSIGNED(VALUE_TYPE(v1)) && l1 > l2) - return VALUE_TYPE(v1); - else if (TYPE_UNSIGNED(VALUE_TYPE(v2)) && l2 > l1) - return VALUE_TYPE(v2); - else /* Both are signed. Result is the longer type */ - return l1 > l2 ? VALUE_TYPE(v1) : VALUE_TYPE(v2); - break; - case language_m2: - /* If we are doing type-checking, l1 should equal l2, so this is - not needed. */ - return l1 > l2 ? VALUE_TYPE(v1) : VALUE_TYPE(v2); - break; - } - abort(); - return (struct type *)0; /* For lint */ -} - -/* This page contains functions that return format strings for - printf for printing out numbers in different formats */ - -/* Returns the appropriate printf format for hexadecimal - numbers. */ -char * -local_hex_format_custom(pre) - char *pre; -{ - static char form[50]; - - strcpy (form, current_language->la_hex_format_pre); - strcat (form, pre); - strcat (form, current_language->la_hex_format_suf); - return form; -} - -/* Converts a number to hexadecimal and stores it in a static - string. Returns a pointer to this string. */ -char * -local_hex_string (num) - int num; -{ - static char res[50]; - - sprintf (res, current_language->la_hex_format, num); - return res; -} - -/* Converts a number to custom hexadecimal and stores it in a static - string. Returns a pointer to this string. */ -char * -local_hex_string_custom(num,pre) - int num; - char *pre; -{ - static char res[50]; - - sprintf (res, local_hex_format_custom(pre), num); - return res; -} - -/* Returns the appropriate printf format for octal - numbers. */ -char * -local_octal_format_custom(pre) - char *pre; -{ - static char form[50]; - - strcpy (form, current_language->la_octal_format_pre); - strcat (form, pre); - strcat (form, current_language->la_octal_format_suf); - return form; -} - -/* This page contains functions that are used in type/range checking. - They all return zero if the type/range check fails. - - It is hoped that these will make extending GDB to parse different - languages a little easier. These are primarily used in eval.c when - evaluating expressions and making sure that their types are correct. - Instead of having a mess of conjucted/disjuncted expressions in an "if", - the ideas of type can be wrapped up in the following functions. - - Note that some of them are not currently dependent upon which language - is currently being parsed. For example, floats are the same in - C and Modula-2 (ie. the only floating point type has TYPE_CODE of - TYPE_CODE_FLT), while booleans are different. */ - -/* Returns non-zero if its argument is a simple type. This is the same for - both Modula-2 and for C. In the C case, TYPE_CODE_CHAR will never occur, - and thus will never cause the failure of the test. */ -int -simple_type(type) - struct type *type; -{ - switch (TYPE_CODE (type)) { - case TYPE_CODE_INT: - case TYPE_CODE_CHAR: - case TYPE_CODE_ENUM: - case TYPE_CODE_FLT: - case TYPE_CODE_RANGE: - case TYPE_CODE_BOOL: - return 1; - - default: - return 0; - } -} - -/* Returns non-zero if its argument is of an ordered type. */ -int -ordered_type (type) - struct type *type; -{ - switch (TYPE_CODE (type)) { - case TYPE_CODE_INT: - case TYPE_CODE_CHAR: - case TYPE_CODE_ENUM: - case TYPE_CODE_FLT: - case TYPE_CODE_RANGE: - return 1; - - default: - return 0; - } -} - -/* Returns non-zero if the two types are the same */ -int -same_type (arg1, arg2) - struct type *arg1, *arg2; -{ - if (structured_type(arg1) ? !structured_type(arg2) : structured_type(arg2)) - /* One is structured and one isn't */ - return 0; - else if (structured_type(arg1) && structured_type(arg2)) - return arg1 == arg2; - else if (numeric_type(arg1) && numeric_type(arg2)) - return (TYPE_CODE(arg2) == TYPE_CODE(arg1)) && - (TYPE_UNSIGNED(arg1) == TYPE_UNSIGNED(arg2)) - ? 1 : 0; - else - return arg1==arg2; -} - -/* Returns non-zero if the type is integral */ -int -integral_type (type) - struct type *type; -{ - switch(current_language->la_language) - { - case language_c: - case language_cplus: - return (TYPE_CODE(type) != TYPE_CODE_INT) && - (TYPE_CODE(type) != TYPE_CODE_ENUM) ? 0 : 1; - case language_m2: - return TYPE_CODE(type) != TYPE_CODE_INT ? 0 : 1; - default: - error ("Language not supported."); - } -} - -/* Returns non-zero if the value is numeric */ -int -numeric_type (type) - struct type *type; -{ - switch (TYPE_CODE (type)) { - case TYPE_CODE_INT: - case TYPE_CODE_FLT: - return 1; - - default: - return 0; - } -} - -/* Returns non-zero if the value is a character type */ -int -character_type (type) - struct type *type; -{ - switch(current_language->la_language) - { - case language_m2: - return TYPE_CODE(type) != TYPE_CODE_CHAR ? 0 : 1; - - case language_c: - case language_cplus: - return (TYPE_CODE(type) == TYPE_CODE_INT) && - TYPE_LENGTH(type) == sizeof(char) - ? 1 : 0; - } -} - -/* Returns non-zero if the value is a boolean type */ -int -boolean_type (type) - struct type *type; -{ - switch(current_language->la_language) - { - case language_m2: - return TYPE_CODE(type) != TYPE_CODE_BOOL ? 0 : 1; - - case language_c: - case language_cplus: - return TYPE_CODE(type) != TYPE_CODE_INT ? 0 : 1; - } -} - -/* Returns non-zero if the value is a floating-point type */ -int -float_type (type) - struct type *type; -{ - return TYPE_CODE(type) == TYPE_CODE_FLT; -} - -/* Returns non-zero if the value is a pointer type */ -int -pointer_type(type) - struct type *type; -{ - return TYPE_CODE(type) == TYPE_CODE_PTR || - TYPE_CODE(type) == TYPE_CODE_REF; -} - -/* Returns non-zero if the value is a structured type */ -int -structured_type(type) - struct type *type; -{ - switch(current_language->la_language) - { - case language_c: - case language_cplus: - return (TYPE_CODE(type) == TYPE_CODE_STRUCT) || - (TYPE_CODE(type) == TYPE_CODE_UNION) || - (TYPE_CODE(type) == TYPE_CODE_ARRAY); - case language_m2: - return (TYPE_CODE(type) == TYPE_CODE_STRUCT) || - (TYPE_CODE(type) == TYPE_CODE_SET) || - (TYPE_CODE(type) == TYPE_CODE_ARRAY); - } -} - -/* This page contains functions that return info about - (struct value) values used in GDB. */ - -/* Returns non-zero if the value VAL represents a true value. */ -int -value_true(val) - value val; -{ - int len, i; - struct type *type; - LONGEST v; - - switch (current_language->la_language) { - - case language_c: - case language_cplus: - return !value_zerop (val); - - case language_m2: - type = VALUE_TYPE(val); - if (TYPE_CODE (type) != TYPE_CODE_BOOL) - return 0; /* Not a BOOLEAN at all */ - /* Search the fields for one that matches the current value. */ - len = TYPE_NFIELDS (type); - v = value_as_long (val); - for (i = 0; i < len; i++) - { - QUIT; - if (v == TYPE_FIELD_BITPOS (type, i)) - break; - } - if (i >= len) - return 0; /* Not a valid BOOLEAN value */ - if (!strcmp ("TRUE", TYPE_FIELD_NAME(VALUE_TYPE(val), i))) - return 1; /* BOOLEAN with value TRUE */ - else - return 0; /* BOOLEAN with value FALSE */ - break; - - default: - error ("Language not supported."); - } -} - -/* Returns non-zero if the operator OP is defined on - the values ARG1 and ARG2. */ -void -binop_type_check(arg1,arg2,op) - value arg1,arg2; - int op; -{ - struct type *t1, *t2; - - /* If we're not checking types, always return success. */ - if (!STRICT_TYPE) - return; - - t1=VALUE_TYPE(arg1); - if (arg2!=(value)NULL) - t2=VALUE_TYPE(arg2); - else - t2=NULL; - - switch(op) - { - case BINOP_ADD: - case BINOP_SUB: - if ((numeric_type(t1) && pointer_type(t2)) || - (pointer_type(t1) && numeric_type(t2))) - { - printf("warning: combining pointer and integer.\n"); - break; - } - case BINOP_MUL: - case BINOP_LSH: - case BINOP_RSH: - if (!numeric_type(t1) || !numeric_type(t2)) - type_op_error ("Arguments to %s must be numbers.",op); - else if (!same_type(t1,t2)) - type_op_error ("Arguments to %s must be of the same type.",op); - break; - - case BINOP_AND: - case BINOP_OR: - if (!boolean_type(t1) || !boolean_type(t2)) - type_op_error ("Arguments to %s must be of boolean type.",op); - break; - - case BINOP_EQUAL: - if ((pointer_type(t1) && !(pointer_type(t2) || integral_type(t2))) || - (pointer_type(t2) && !(pointer_type(t1) || integral_type(t1)))) - type_op_error ("A pointer can only be compared to an integer or pointer.",op); - else if ((pointer_type(t1) && integral_type(t2)) || - (integral_type(t1) && pointer_type(t2))) - { - printf("warning: combining integer and pointer.\n"); - break; - } - else if (!simple_type(t1) || !simple_type(t2)) - type_op_error ("Arguments to %s must be of simple type.",op); - else if (!same_type(t1,t2)) - type_op_error ("Arguments to %s must be of the same type.",op); - break; - - case BINOP_REM: - if (!integral_type(t1) || !integral_type(t2)) - type_op_error ("Arguments to %s must be of integral type.",op); - break; - - case BINOP_LESS: - case BINOP_GTR: - case BINOP_LEQ: - case BINOP_GEQ: - if (!ordered_type(t1) || !ordered_type(t2)) - type_op_error ("Arguments to %s must be of ordered type.",op); - else if (!same_type(t1,t2)) - type_op_error ("Arguments to %s must be of the same type.",op); - break; - - case BINOP_ASSIGN: - if (pointer_type(t1) && !integral_type(t2)) - type_op_error ("A pointer can only be assigned an integer.",op); - else if (pointer_type(t1) && integral_type(t2)) - { - printf("warning: combining integer and pointer."); - break; - } - else if (!simple_type(t1) || !simple_type(t2)) - type_op_error ("Arguments to %s must be of simple type.",op); - else if (!same_type(t1,t2)) - type_op_error ("Arguments to %s must be of the same type.",op); - break; - - /* Unary checks -- arg2 is null */ - - case UNOP_ZEROP: - if (!boolean_type(t1)) - type_op_error ("Argument to %s must be of boolean type.",op); - break; - - case UNOP_PLUS: - case UNOP_NEG: - if (!numeric_type(t1)) - type_op_error ("Argument to %s must be of numeric type.",op); - break; - - case UNOP_IND: - if (integral_type(t1)) - { - printf("warning: combining pointer and integer.\n"); - break; - } - else if (!pointer_type(t1)) - type_op_error ("Argument to %s must be a pointer.",op); - break; - - case UNOP_PREINCREMENT: - case UNOP_POSTINCREMENT: - case UNOP_PREDECREMENT: - case UNOP_POSTDECREMENT: - if (!ordered_type(t1)) - type_op_error ("Argument to %s must be of an ordered type.",op); - break; - - default: - /* Ok. The following operators have different meanings in - different languages. */ - switch(current_language->la_language) - { -#ifdef _LANG_c - case language_c: - case language_cplus: - switch(op) - { - case BINOP_DIV: - if (!numeric_type(t1) || !numeric_type(t2)) - type_op_error ("Arguments to %s must be numbers.",op); - break; - } - break; -#endif - -#ifdef _LANG_m2 - case language_m2: - switch(op) - { - case BINOP_DIV: - if (!float_type(t1) || !float_type(t2)) - type_op_error ("Arguments to %s must be floating point numbers.",op); - break; - case BINOP_INTDIV: - if (!integral_type(t1) || !integral_type(t2)) - type_op_error ("Arguments to %s must be of integral type.",op); - break; - } -#endif - } - } -} - -/* This page contains functions for the printing out of - error messages that occur during type- and range- - checking. */ - -/* Prints the format string FMT with the operator as a string - corresponding to the opcode OP. If FATAL is non-zero, then - this is an error and error () is called. Otherwise, it is - a warning and printf() is called. */ -void -op_error (fmt,op,fatal) - char *fmt; - enum exp_opcode op; - int fatal; -{ - if (fatal) - error (fmt,op_string(op)); - else - { - printf("warning: "); - printf(fmt,op_string(op)); - printf("\n"); - } -} - -/* These are called when a language fails a type- or range-check. - The first argument should be a printf()-style format string, and - the rest of the arguments should be its arguments. If - [type|range]_check is [type|range]_check_on, then return_to_top_level() - is called in the style of error (). Otherwise, the message is prefixed - by "warning: " and we do not return to the top level. */ -void -type_error (va_alist) - va_dcl -{ - va_list args; - char *string; - - if (type_check==type_check_warn) - fprintf(stderr,"warning: "); - else - target_terminal_ours(); - - va_start (args); - string = va_arg (args, char *); - vfprintf (stderr, string, args); - fprintf (stderr, "\n"); - va_end (args); - if (type_check==type_check_on) - return_to_top_level(); -} - -void -range_error (va_alist) - va_dcl -{ - va_list args; - char *string; - - if (range_check==range_check_warn) - fprintf(stderr,"warning: "); - else - target_terminal_ours(); - - va_start (args); - string = va_arg (args, char *); - vfprintf (stderr, string, args); - fprintf (stderr, "\n"); - va_end (args); - if (range_check==range_check_on) - return_to_top_level(); -} - - -/* This page contains miscellaneous functions */ - -/* Return the language as a string */ -char * -language_str(lang) - enum language lang; -{ - int i; - - for (i = 0; i < languages_size; i++) { - if (languages[i]->la_language == lang) { - return languages[i]->la_name; - } - } - return "Unknown"; -} - -struct cmd_list_element *setchecklist = NULL; -struct cmd_list_element *showchecklist = NULL; - -static void -set_check (ignore, from_tty) - char *ignore; - int from_tty; -{ - printf( -"\"set check\" must be followed by the name of a check subcommand.\n"); - help_list(setchecklist, "set check ", -1, stdout); -} - -static void -show_check (arg, from_tty) - char *arg; - int from_tty; -{ - cmd_show_list(showchecklist, from_tty, ""); -} - -/* Add a language to the set of known languages. */ - -void -add_language (lang) - struct language_defn *lang; -{ - if (lang->la_magic != LANG_MAGIC) - { - fprintf(stderr, "Magic number of %s language struct wrong\n", - lang->la_name); - abort(); - } - - if (!languages) - { - languages_allocsize = DEFAULT_ALLOCSIZE; - languages = (struct language_defn **) xmalloc - (languages_allocsize * sizeof (*languages)); - } - if (languages_size >= languages_allocsize) - { - languages_allocsize *= 2; - languages = (struct language_defn **) xrealloc (languages, - languages_allocsize * sizeof (*languages)); - } - languages[languages_size++] = lang; -} - -/* Define the language that is no language. */ - -int -unk_lang_parser () -{ - return 1; -} - -void -unk_lang_error () -{ - error ("Attempted to parse an expression with unknown language"); -} - -static struct type ** const (unknown_builtin_types[]) = { 0 }; -static const struct op_print unk_op_print_tab[] = { 0 }; - -const struct language_defn unknown_language_defn = { - "unknown", - language_unknown, - &unknown_builtin_types[0], - range_check_off, - type_check_off, - unk_lang_parser, - unk_lang_error, - &builtin_type_error, /* longest signed integral type */ - &builtin_type_error, /* longest unsigned integral type */ - &builtin_type_error, /* longest floating point type */ - "0x%x", "0x%", "x", /* Hex format, prefix, suffix */ - "0%o", "0%", "o", /* Octal format, prefix, suffix */ - unk_op_print_tab, /* expression operators for printing */ - LANG_MAGIC -}; - -/* These two structs define fake entries for the "local" and "auto" options. */ -const struct language_defn auto_language_defn = { - "auto", - language_auto, - &unknown_builtin_types[0], - range_check_off, - type_check_off, - unk_lang_parser, - unk_lang_error, - &builtin_type_error, /* longest signed integral type */ - &builtin_type_error, /* longest unsigned integral type */ - &builtin_type_error, /* longest floating point type */ - "0x%x", "0x%", "x", /* Hex format, prefix, suffix */ - "0%o", "0%", "o", /* Octal format, prefix, suffix */ - unk_op_print_tab, /* expression operators for printing */ - LANG_MAGIC -}; - -const struct language_defn local_language_defn = { - "local", - language_auto, - &unknown_builtin_types[0], - range_check_off, - type_check_off, - unk_lang_parser, - unk_lang_error, - &builtin_type_error, /* longest signed integral type */ - &builtin_type_error, /* longest unsigned integral type */ - &builtin_type_error, /* longest floating point type */ - "0x%x", "0x%", "x", /* Hex format, prefix, suffix */ - "0%o", "0%", "o", /* Octal format, prefix, suffix */ - unk_op_print_tab, /* expression operators for printing */ - LANG_MAGIC -}; - -/* Initialize the language routines */ - -void -_initialize_language() -{ - struct cmd_list_element *set, *show; - - /* GDB commands for language specific stuff */ - - set = add_set_cmd ("language", class_support, var_string_noescape, - (char *)&language, - "Set the current source language.", - &setlist); - show = add_show_from_set (set, &showlist); - set->function = set_language_command; - show->function = show_language_command; - - add_prefix_cmd ("check", no_class, set_check, - "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", - &showchecklist, "show check ", 0, &showlist); - add_alias_cmd ("c", "check", no_class, 1, &showlist); - add_alias_cmd ("ch", "check", no_class, 1, &showlist); - - set = add_set_cmd ("type", class_support, var_string_noescape, - (char *)&type, - "Set type checking. (on/warn/off/auto)", - &setchecklist); - show = add_show_from_set (set, &showchecklist); - set->function = set_type_command; - show->function = show_type_command; - - set = add_set_cmd ("range", class_support, var_string_noescape, - (char *)&range, - "Set range checking. (on/warn/off/auto)", - &setchecklist); - show = add_show_from_set (set, &showchecklist); - set->function = set_range_command; - show->function = show_range_command; - - add_language (&unknown_language_defn); - add_language (&local_language_defn); - add_language (&auto_language_defn); - - language = savestring ("auto",strlen("auto")); - range = savestring ("auto",strlen("auto")); - type = savestring ("auto",strlen("auto")); - - /* Have the above take effect */ - - set_language_command (language, 0); - set_type_command (NULL, 0); - set_range_command (NULL, 0); -} diff --git a/gdb/language.h b/gdb/language.h deleted file mode 100644 index d09d4d355e5..00000000000 --- a/gdb/language.h +++ /dev/null @@ -1,170 +0,0 @@ -/* Source-language-related definitions for GDB. - Copyright 1991 Free Software Foundation, Inc. - Contributed by the Department of Computer Science at the State University - of New York at Buffalo. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* This used to be included to configure GDB for one or more specific - languages. Now it is shortcutted to configure for all of them. FIXME. */ -/* #include "lang_def.h" */ -#define _LANG_c -#define _LANG_m2 - -/* range_mode == - range_mode_auto: range_check set automatically to default of language. - range_mode_manual: range_check set manually by user. */ - -extern enum range_mode {range_mode_auto, range_mode_manual} range_mode; - -/* range_check == - range_check_on: Ranges are checked in GDB expressions, producing errors. - range_check_warn: Ranges are checked, producing warnings. - range_check_off: Ranges are not checked in GDB expressions. */ - -extern enum range_check - {range_check_off, range_check_warn, range_check_on} range_check; - -/* type_mode == - type_mode_auto: type_check set automatically to default of language - type_mode_manual: type_check set manually by user. */ - -extern enum type_mode {type_mode_auto, type_mode_manual} type_mode; - -/* type_check == - type_check_on: Types are checked in GDB expressions, producing errors. - type_check_warn: Types are checked, producing warnings. - type_check_off: Types are not checked in GDB expressions. */ - -extern enum type_check - {type_check_off, type_check_warn, type_check_on} type_check; - -/* Structure tying together assorted information about a language. */ - -struct language_defn { - char * la_name; /* Name of the language */ - enum language la_language; /* its symtab language-enum (defs.h) */ - struct type ** const - *la_builtin_type_vector; /* Its builtin types */ - enum range_check la_range_check; /* Default range checking */ - enum type_check la_type_check; /* Default type checking */ - int (*la_parser)(); /* Parser function */ - void (*la_error)(); /* Parser error function */ - struct type **la_longest_int; /* Longest signed integral type */ - struct type **la_longest_unsigned_int; /* Longest uns integral type */ - struct type **la_longest_float; /* Longest floating point type */ - char *la_hex_format; /* Hexadecimal printf format str */ - char *la_hex_format_pre; /* Prefix for custom format string */ - char *la_hex_format_suf; /* Suffix for custom format string */ - char *la_octal_format; /* Octal printf format str */ - char *la_octal_format_pre; /* Prefix for custom format string */ - char *la_octal_format_suf; /* Suffix for custom format string */ -const struct op_print - *la_op_print_tab; /* Table for printing expressions */ -/* Add fields above this point, so the magic number is always last. */ - long la_magic; /* Magic number for compat checking */ -}; - -#define LANG_MAGIC 910823L - -/* Pointer to the language_defn for our current language. This pointer - always points to *some* valid struct; it can be used without checking - it for validity. */ - -extern struct language_defn *current_language; - -/* language_mode == - language_mode_auto: current_language automatically set upon selection - of scope (e.g. stack frame) - language_mode_manual: current_language set only by user. */ - -extern enum language_mode - {language_mode_auto, language_mode_manual} language_mode; - -/* These macros define the behaviour of the expression - evaluator. */ - -/* Should we strictly type check expressions? */ -#define STRICT_TYPE (type_check != range_check_off) - -/* Should we range check values against the domain of their type? */ -#define RANGE_CHECK (range_check != type_check_off) - -/* "cast" really means conversion */ -/* FIXME -- should be a setting in language_defn */ -#define CAST_IS_CONVERSION (current_language->la_language == language_c) - -void language_info(); -void set_language(); - -/* This page contains functions that return things that are - specific to languages. Each of these functions is based on - the current setting of working_lang, which the user sets - with the "set language" command. */ - -/* Returns some built-in types */ -#define longest_int() (*current_language->la_longest_int) -#define longest_unsigned_int() (*current_language->la_longest_unsigned_int) -#define longest_float() (*current_language->la_longest_float) -struct type *binop_result_type(); - -/* Hexadecimal number formatting is in defs.h because it is so common - throughout GDB. */ - -/* Return a format string for printf that will print a number in the local - (language-specific) octal format. Result is static and is - overwritten by the next call. local_octal_format_custom takes printf - options like "08" or "l" (to produce e.g. %08x or %lx). */ - -#define local_octal_format() (current_language->la_octal_format) -char *local_octal_format_custom(); - -/* Type predicates */ -int simple_type(); -int ordered_type(); -int same_type(); -int integral_type(); -int numeric_type(); -int character_type(); -int boolean_type(); -int float_type(); -int pointer_type(); -int structured_type(); - -/* Checks Binary and Unary operations for semantic type correctness */ -void binop_type_check(); -#define unop_type_check(v,o) binop_type_check((v),NULL,(o)) - -/* Error messages */ -void op_error(); -#define type_op_error(f,o) \ - op_error((f),(o),type_check==type_check_on ? 1 : 0) -#define range_op_error(f,o) \ - op_error((f),(o),range_check==range_check_on ? 1 : 0) -void type_error(); -void range_error(); - -/* Data: Does this value represent "truth" to the current language? */ -int value_true(); - -/* Misc: The string representing a particular enum language. */ -char *language_str(); - -/* Add a language to the set known by GDB (at initialization time). */ -void add_language (); /* Arg is &language_defn */ - -extern enum language get_frame_language (); /* In stack.c */ diff --git a/gdb/m2-exp.y b/gdb/m2-exp.y deleted file mode 100644 index 2c5cf4b9a50..00000000000 --- a/gdb/m2-exp.y +++ /dev/null @@ -1,1226 +0,0 @@ -/* YACC grammar for Modula-2 expressions, for GDB. - Copyright (C) 1986, 1989, 1990, 1991 Free Software Foundation, Inc. - Generated from expread.y (now c-exp.y) and contributed by the Department - of Computer Science at the State University of New York at Buffalo, 1991. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Parse a Modula-2 expression from text in a string, - and return the result as a struct expression pointer. - That structure contains arithmetic operations in reverse polish, - with constants represented by operations that are followed by special data. - See expression.h for the details of the format. - What is important here is that it can be built up sequentially - during the process of parsing; the lower levels of the tree always - come first in the result. */ - -%{ -#include -#include -#include "defs.h" -#include "param.h" -#include "symtab.h" -#include "frame.h" -#include "expression.h" -#include "language.h" -#include "value.h" -#include "parser-defs.h" - -/* These MUST be included in any grammar file!!!! - Please choose unique names! */ -#define yyparse m2_parse -#define yylex m2_lex -#define yyerror m2_error -#define yylval m2_lval -#define yychar m2_char -#define yydebug m2_debug -#define yypact m2_pact -#define yyr1 m2_r1 -#define yyr2 m2_r2 -#define yydef m2_def -#define yychk m2_chk -#define yypgo m2_pgo -#define yyact m2_act -#define yyexca m2_exca -#define yyerrflag m2_errflag -#define yynerrs m2_nerrs -#define yyps m2_ps -#define yypv m2_pv -#define yys m2_s -#define yystate m2_state -#define yytmp m2_tmp -#define yyv m2_v -#define yyval m2_val -#define yylloc m2_lloc - -/* Forward decl's */ -void yyerror (); -static int yylex (); -int yyparse (); - -/* The sign of the number being parsed. */ -int number_sign = 1; - -/* The block that the module specified by the qualifer on an identifer is - contained in, */ -struct block *modblock=0; - -char *make_qualname(); - -/* #define YYDEBUG 1 */ - -%} - -/* Although the yacc "value" of an expression is not used, - since the result is stored in the structure being created, - other node types do have values. */ - -%union - { - LONGEST lval; - unsigned LONGEST ulval; - double dval; - struct symbol *sym; - struct type *tval; - struct stoken sval; - int voidval; - struct block *bval; - enum exp_opcode opcode; - struct internalvar *ivar; - - struct type **tvec; - int *ivec; - } - -%type exp type_exp start set -%type variable -%type type -%type block -%type fblock - -%token INT HEX ERROR -%token UINT TRUE FALSE CHAR -%token FLOAT - -/* Both NAME and TYPENAME tokens represent symbols in the input, - and both convey their data as strings. - But a TYPENAME is a string that happens to be defined as a typedef - or builtin type name (such as int or char) - and a NAME is any other symbol. - - Contexts where this distinction is not important can use the - nonterminal "name", which matches either NAME or TYPENAME. */ - -%token STRING -%token NAME BLOCKNAME IDENT CONST VARNAME -%token TYPENAME - -%token SIZE CAP ORD HIGH ABS MIN MAX FLOAT_FUNC VAL CHR ODD TRUNC -%token INC DEC INCL EXCL - -/* The GDB scope operator */ -%token COLONCOLON - -%token LAST REGNAME - -%token INTERNAL_VAR - -/* M2 tokens */ -%left ',' -%left ABOVE_COMMA -%nonassoc ASSIGN -%left '<' '>' LEQ GEQ '=' NOTEQUAL '#' IN -%left OR -%left AND '&' -%left '@' -%left '+' '-' -%left '*' '/' DIV MOD -%right UNARY -%right '^' DOT '[' '(' -%right NOT '~' -%left COLONCOLON QID -/* This is not an actual token ; it is used for precedence. -%right QID -*/ -%% - -start : exp - | type_exp - ; - -type_exp: type - { write_exp_elt_opcode(OP_TYPE); - write_exp_elt_type($1); - write_exp_elt_opcode(OP_TYPE); - } - ; - -/* Expressions */ - -exp : exp '^' %prec UNARY - { write_exp_elt_opcode (UNOP_IND); } - -exp : '-' - { number_sign = -1; } - exp %prec UNARY - { number_sign = 1; - write_exp_elt_opcode (UNOP_NEG); } - ; - -exp : '+' exp %prec UNARY - { write_exp_elt_opcode(UNOP_PLUS); } - ; - -exp : not_exp exp %prec UNARY - { write_exp_elt_opcode (UNOP_ZEROP); } - ; - -not_exp : NOT - | '~' - ; - -exp : CAP '(' exp ')' - { write_exp_elt_opcode (UNOP_CAP); } - ; - -exp : ORD '(' exp ')' - { write_exp_elt_opcode (UNOP_ORD); } - ; - -exp : ABS '(' exp ')' - { write_exp_elt_opcode (UNOP_ABS); } - ; - -exp : HIGH '(' exp ')' - { write_exp_elt_opcode (UNOP_HIGH); } - ; - -exp : MIN '(' type ')' - { write_exp_elt_opcode (UNOP_MIN); - write_exp_elt_type ($3); - write_exp_elt_opcode (UNOP_MIN); } - ; - -exp : MAX '(' type ')' - { write_exp_elt_opcode (UNOP_MAX); - write_exp_elt_type ($3); - write_exp_elt_opcode (UNOP_MIN); } - ; - -exp : FLOAT_FUNC '(' exp ')' - { write_exp_elt_opcode (UNOP_FLOAT); } - ; - -exp : VAL '(' type ',' exp ')' - { write_exp_elt_opcode (BINOP_VAL); - write_exp_elt_type ($3); - write_exp_elt_opcode (BINOP_VAL); } - ; - -exp : CHR '(' exp ')' - { write_exp_elt_opcode (UNOP_CHR); } - ; - -exp : ODD '(' exp ')' - { write_exp_elt_opcode (UNOP_ODD); } - ; - -exp : TRUNC '(' exp ')' - { write_exp_elt_opcode (UNOP_TRUNC); } - ; - -exp : SIZE exp %prec UNARY - { write_exp_elt_opcode (UNOP_SIZEOF); } - ; - - -exp : INC '(' exp ')' - { write_exp_elt_opcode(UNOP_PREINCREMENT); } - ; - -exp : INC '(' exp ',' exp ')' - { write_exp_elt_opcode(BINOP_ASSIGN_MODIFY); - write_exp_elt_opcode(BINOP_ADD); - write_exp_elt_opcode(BINOP_ASSIGN_MODIFY); } - ; - -exp : DEC '(' exp ')' - { write_exp_elt_opcode(UNOP_PREDECREMENT);} - ; - -exp : DEC '(' exp ',' exp ')' - { write_exp_elt_opcode(BINOP_ASSIGN_MODIFY); - write_exp_elt_opcode(BINOP_SUB); - write_exp_elt_opcode(BINOP_ASSIGN_MODIFY); } - ; - -exp : exp DOT NAME - { write_exp_elt_opcode (STRUCTOP_STRUCT); - write_exp_string ($3); - write_exp_elt_opcode (STRUCTOP_STRUCT); } - ; - -exp : set - ; - -exp : exp IN set - { error("Sets are not implemented.");} - ; - -exp : INCL '(' exp ',' exp ')' - { error("Sets are not implemented.");} - ; - -exp : EXCL '(' exp ',' exp ')' - { error("Sets are not implemented.");} - -set : '{' arglist '}' - { error("Sets are not implemented.");} - | type '{' arglist '}' - { error("Sets are not implemented.");} - ; - - -/* Modula-2 array subscript notation [a,b,c...] */ -exp : exp '[' - /* This function just saves the number of arguments - that follow in the list. It is *not* specific to - function types */ - { start_arglist(); } - non_empty_arglist ']' %prec DOT - { write_exp_elt_opcode (BINOP_MULTI_SUBSCRIPT); - write_exp_elt_longcst ((LONGEST) end_arglist()); - write_exp_elt_opcode (BINOP_MULTI_SUBSCRIPT); } - ; - -exp : exp '(' - /* This is to save the value of arglist_len - being accumulated by an outer function call. */ - { start_arglist (); } - arglist ')' %prec DOT - { write_exp_elt_opcode (OP_FUNCALL); - write_exp_elt_longcst ((LONGEST) end_arglist ()); - write_exp_elt_opcode (OP_FUNCALL); } - ; - -arglist : - ; - -arglist : exp - { arglist_len = 1; } - ; - -arglist : arglist ',' exp %prec ABOVE_COMMA - { arglist_len++; } - ; - -non_empty_arglist - : exp - { arglist_len = 1; } - ; - -non_empty_arglist - : non_empty_arglist ',' exp %prec ABOVE_COMMA - { arglist_len++; } - ; - -/* GDB construct */ -exp : '{' type '}' exp %prec UNARY - { write_exp_elt_opcode (UNOP_MEMVAL); - write_exp_elt_type ($2); - write_exp_elt_opcode (UNOP_MEMVAL); } - ; - -exp : type '(' exp ')' %prec UNARY - { write_exp_elt_opcode (UNOP_CAST); - write_exp_elt_type ($1); - write_exp_elt_opcode (UNOP_CAST); } - ; - -exp : '(' exp ')' - { } - ; - -/* Binary operators in order of decreasing precedence. Note that some - of these operators are overloaded! (ie. sets) */ - -/* GDB construct */ -exp : exp '@' exp - { write_exp_elt_opcode (BINOP_REPEAT); } - ; - -exp : exp '*' exp - { write_exp_elt_opcode (BINOP_MUL); } - ; - -exp : exp '/' exp - { write_exp_elt_opcode (BINOP_DIV); } - ; - -exp : exp DIV exp - { write_exp_elt_opcode (BINOP_INTDIV); } - ; - -exp : exp MOD exp - { write_exp_elt_opcode (BINOP_REM); } - ; - -exp : exp '+' exp - { write_exp_elt_opcode (BINOP_ADD); } - ; - -exp : exp '-' exp - { write_exp_elt_opcode (BINOP_SUB); } - ; - -exp : exp '=' exp - { write_exp_elt_opcode (BINOP_EQUAL); } - ; - -exp : exp NOTEQUAL exp - { write_exp_elt_opcode (BINOP_NOTEQUAL); } - | exp '#' exp - { write_exp_elt_opcode (BINOP_NOTEQUAL); } - ; - -exp : exp LEQ exp - { write_exp_elt_opcode (BINOP_LEQ); } - ; - -exp : exp GEQ exp - { write_exp_elt_opcode (BINOP_GEQ); } - ; - -exp : exp '<' exp - { write_exp_elt_opcode (BINOP_LESS); } - ; - -exp : exp '>' exp - { write_exp_elt_opcode (BINOP_GTR); } - ; - -exp : exp AND exp - { write_exp_elt_opcode (BINOP_AND); } - ; - -exp : exp '&' exp - { write_exp_elt_opcode (BINOP_AND); } - ; - -exp : exp OR exp - { write_exp_elt_opcode (BINOP_OR); } - ; - -exp : exp ASSIGN exp - { write_exp_elt_opcode (BINOP_ASSIGN); } - ; - - -/* Constants */ - -exp : TRUE - { write_exp_elt_opcode (OP_BOOL); - write_exp_elt_longcst ((LONGEST) $1); - write_exp_elt_opcode (OP_BOOL); } - ; - -exp : FALSE - { write_exp_elt_opcode (OP_BOOL); - write_exp_elt_longcst ((LONGEST) $1); - write_exp_elt_opcode (OP_BOOL); } - ; - -exp : INT - { write_exp_elt_opcode (OP_LONG); - write_exp_elt_type (builtin_type_m2_int); - write_exp_elt_longcst ((LONGEST) $1); - write_exp_elt_opcode (OP_LONG); } - ; - -exp : UINT - { - write_exp_elt_opcode (OP_LONG); - write_exp_elt_type (builtin_type_m2_card); - write_exp_elt_longcst ((LONGEST) $1); - write_exp_elt_opcode (OP_LONG); - } - ; - -exp : CHAR - { write_exp_elt_opcode (OP_LONG); - write_exp_elt_type (builtin_type_m2_char); - write_exp_elt_longcst ((LONGEST) $1); - write_exp_elt_opcode (OP_LONG); } - ; - - -exp : FLOAT - { write_exp_elt_opcode (OP_DOUBLE); - write_exp_elt_type (builtin_type_m2_real); - write_exp_elt_dblcst ($1); - write_exp_elt_opcode (OP_DOUBLE); } - ; - -exp : variable - ; - -/* The GDB internal variable $$, et al. */ -exp : LAST - { write_exp_elt_opcode (OP_LAST); - write_exp_elt_longcst ((LONGEST) $1); - write_exp_elt_opcode (OP_LAST); } - ; - -exp : REGNAME - { write_exp_elt_opcode (OP_REGISTER); - write_exp_elt_longcst ((LONGEST) $1); - write_exp_elt_opcode (OP_REGISTER); } - ; - -exp : SIZE '(' type ')' %prec UNARY - { write_exp_elt_opcode (OP_LONG); - write_exp_elt_type (builtin_type_int); - write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3)); - write_exp_elt_opcode (OP_LONG); } - ; - -exp : STRING - { write_exp_elt_opcode (OP_M2_STRING); - write_exp_string ($1); - write_exp_elt_opcode (OP_M2_STRING); } - ; - -/* This will be used for extensions later. Like adding modules. */ -block : fblock - { $$ = SYMBOL_BLOCK_VALUE($1); } - ; - -fblock : BLOCKNAME - { struct symbol *sym - = lookup_symbol (copy_name ($1), expression_context_block, - VAR_NAMESPACE, 0, NULL); - $$ = sym;} - ; - - -/* GDB scope operator */ -fblock : block COLONCOLON BLOCKNAME - { struct symbol *tem - = lookup_symbol (copy_name ($3), $1, - VAR_NAMESPACE, 0, NULL); - if (!tem || SYMBOL_CLASS (tem) != LOC_BLOCK) - error ("No function \"%s\" in specified context.", - copy_name ($3)); - $$ = tem; - } - ; - -/* Useful for assigning to PROCEDURE variables */ -variable: fblock - { write_exp_elt_opcode(OP_VAR_VALUE); - write_exp_elt_sym ($1); - write_exp_elt_opcode (OP_VAR_VALUE); } - ; - -/* GDB internal ($foo) variable */ -variable: INTERNAL_VAR - { write_exp_elt_opcode (OP_INTERNALVAR); - write_exp_elt_intern ($1); - write_exp_elt_opcode (OP_INTERNALVAR); } - ; - -/* GDB scope operator */ -variable: block COLONCOLON NAME - { struct symbol *sym; - sym = lookup_symbol (copy_name ($3), $1, - VAR_NAMESPACE, 0, NULL); - if (sym == 0) - error ("No symbol \"%s\" in specified context.", - copy_name ($3)); - - write_exp_elt_opcode (OP_VAR_VALUE); - write_exp_elt_sym (sym); - write_exp_elt_opcode (OP_VAR_VALUE); } - ; - -/* Base case for variables. */ -variable: NAME - { struct symbol *sym; - int is_a_field_of_this; - - sym = lookup_symbol (copy_name ($1), - expression_context_block, - VAR_NAMESPACE, - &is_a_field_of_this, - NULL); - if (sym) - { - switch (sym->class) - { - case LOC_REGISTER: - case LOC_ARG: - case LOC_LOCAL: - if (innermost_block == 0 || - contained_in (block_found, - innermost_block)) - innermost_block = block_found; - } - write_exp_elt_opcode (OP_VAR_VALUE); - write_exp_elt_sym (sym); - write_exp_elt_opcode (OP_VAR_VALUE); - } - else - { - register int i; - register char *arg = copy_name ($1); - - for (i = 0; i < misc_function_count; i++) - if (!strcmp (misc_function_vector[i].name, arg)) - break; - - if (i < misc_function_count) - { - enum misc_function_type mft = - (enum misc_function_type) - misc_function_vector[i].type; - - write_exp_elt_opcode (OP_LONG); - write_exp_elt_type (builtin_type_int); - write_exp_elt_longcst ((LONGEST) misc_function_vector[i].address); - write_exp_elt_opcode (OP_LONG); - write_exp_elt_opcode (UNOP_MEMVAL); - if (mft == mf_data || mft == mf_bss) - write_exp_elt_type (builtin_type_int); - else if (mft == mf_text) - write_exp_elt_type (lookup_function_type (builtin_type_int)); - else - write_exp_elt_type (builtin_type_char); - write_exp_elt_opcode (UNOP_MEMVAL); - } - else if (symtab_list == 0 - && partial_symtab_list == 0) - error ("No symbol table is loaded. Use the \"symbol-file\" command."); - else - error ("No symbol \"%s\" in current context.", - copy_name ($1)); - } - } - ; - -type - : TYPENAME - { $$ = lookup_typename (copy_name ($1), - expression_context_block, 0); } - - ; - -%% - -#if 0 /* FIXME! */ -int -overflow(a,b) - long a,b; -{ - return (MAX_OF_TYPE(builtin_type_m2_int) - b) < a; -} - -int -uoverflow(a,b) - unsigned long a,b; -{ - return (MAX_OF_TYPE(builtin_type_m2_card) - b) < a; -} -#endif /* FIXME */ - -/* Take care of parsing a number (anything that starts with a digit). - Set yylval and return the token type; update lexptr. - LEN is the number of characters in it. */ - -/*** Needs some error checking for the float case ***/ - -static int -parse_number (olen) - int olen; -{ - register char *p = lexptr; - register LONGEST n = 0; - register LONGEST prevn = 0; - register int c,i,ischar=0; - register int base = input_radix; - register int len = olen; - int unsigned_p = number_sign == 1 ? 1 : 0; - - extern double atof (); - - if(p[len-1] == 'H') - { - base = 16; - len--; - } - else if(p[len-1] == 'C' || p[len-1] == 'B') - { - base = 8; - ischar = p[len-1] == 'C'; - len--; - } - - /* Scan the number */ - for (c = 0; c < len; c++) - { - if (p[c] == '.' && base == 10) - { - /* It's a float since it contains a point. */ - yylval.dval = atof (p); - lexptr += len; - return FLOAT; - } - if (p[c] == '.' && base != 10) - error("Floating point numbers must be base 10."); - if (base == 10 && (p[c] < '0' || p[c] > '9')) - error("Invalid digit \'%c\' in number.",p[c]); - } - - while (len-- > 0) - { - c = *p++; - n *= base; - if( base == 8 && (c == '8' || c == '9')) - error("Invalid digit \'%c\' in octal number.",c); - if (c >= '0' && c <= '9') - i = c - '0'; - else - { - if (base == 16 && c >= 'A' && c <= 'F') - i = c - 'A' + 10; - else - return ERROR; - } - n+=i; - if(i >= base) - return ERROR; - if(!unsigned_p && number_sign == 1 && (prevn >= n)) - unsigned_p=1; /* Try something unsigned */ - /* Don't do the range check if n==i and i==0, since that special - case will give an overflow error. */ - if(RANGE_CHECK && n!=i && i) - { - if((unsigned_p && (unsigned)prevn >= (unsigned)n) || - ((!unsigned_p && number_sign==-1) && -prevn <= -n)) - range_error("Overflow on numeric constant."); - } - prevn=n; - } - - lexptr = p; - if(*p == 'B' || *p == 'C' || *p == 'H') - lexptr++; /* Advance past B,C or H */ - - if (ischar) - { - yylval.ulval = n; - return CHAR; - } - else if ( unsigned_p && number_sign == 1) - { - yylval.ulval = n; - return UINT; - } - else if((unsigned_p && (n<0))) { - range_error("Overflow on numeric constant -- number too large."); - /* But, this can return if range_check == range_warn. */ - } - yylval.lval = n; - return INT; -} - - -/* Some tokens */ - -static struct -{ - char name[2]; - int token; -} tokentab2[] = -{ - {"<>", NOTEQUAL }, - {":=", ASSIGN }, - {"<=", LEQ }, - {">=", GEQ }, - {"::", COLONCOLON }, - -}; - -/* Some specific keywords */ - -struct keyword { - char keyw[10]; - int token; -}; - -static struct keyword keytab[] = -{ - {"OR" , OR }, - {"IN", IN },/* Note space after IN */ - {"AND", AND }, - {"ABS", ABS }, - {"CHR", CHR }, - {"DEC", DEC }, - {"NOT", NOT }, - {"DIV", DIV }, - {"INC", INC }, - {"MAX", MAX }, - {"MIN", MIN }, - {"MOD", MOD }, - {"ODD", ODD }, - {"CAP", CAP }, - {"ORD", ORD }, - {"VAL", VAL }, - {"EXCL", EXCL }, - {"HIGH", HIGH }, - {"INCL", INCL }, - {"SIZE", SIZE }, - {"FLOAT", FLOAT_FUNC }, - {"TRUNC", TRUNC }, -}; - - -/* Read one token, getting characters through lexptr. */ - -/* This is where we will check to make sure that the language and the operators used are - compatible */ - -static int -yylex () -{ - register int c; - register int namelen; - register int i; - register char *tokstart; - register char quote; - - retry: - - tokstart = lexptr; - - - /* See if it is a special token of length 2 */ - for( i = 0 ; i < sizeof tokentab2 / sizeof tokentab2[0] ; i++) - if(!strncmp(tokentab2[i].name, tokstart, 2)) - { - lexptr += 2; - return tokentab2[i].token; - } - - switch (c = *tokstart) - { - case 0: - return 0; - - case ' ': - case '\t': - case '\n': - lexptr++; - goto retry; - - case '(': - paren_depth++; - lexptr++; - return c; - - case ')': - if (paren_depth == 0) - return 0; - paren_depth--; - lexptr++; - return c; - - case ',': - if (comma_terminates && paren_depth == 0) - return 0; - lexptr++; - return c; - - case '.': - /* Might be a floating point number. */ - if (lexptr[1] >= '0' && lexptr[1] <= '9') - break; /* Falls into number code. */ - else - { - lexptr++; - return DOT; - } - -/* These are character tokens that appear as-is in the YACC grammar */ - case '+': - case '-': - case '*': - case '/': - case '^': - case '<': - case '>': - case '[': - case ']': - case '=': - case '{': - case '}': - case '#': - case '@': - case '~': - case '&': - lexptr++; - return c; - - case '\'' : - case '"': - quote = c; - for (namelen = 1; (c = tokstart[namelen]) != quote && c != '\0'; namelen++) - if (c == '\\') - { - c = tokstart[++namelen]; - if (c >= '0' && c <= '9') - { - c = tokstart[++namelen]; - if (c >= '0' && c <= '9') - c = tokstart[++namelen]; - } - } - if(c != quote) - error("Unterminated string or character constant."); - yylval.sval.ptr = tokstart + 1; - yylval.sval.length = namelen - 1; - lexptr += namelen + 1; - - if(namelen == 2) /* Single character */ - { - yylval.ulval = tokstart[1]; - return CHAR; - } - else - return STRING; - } - - /* Is it a number? */ - /* Note: We have already dealt with the case of the token '.'. - See case '.' above. */ - if ((c >= '0' && c <= '9')) - { - /* It's a number. */ - int got_dot = 0, got_e = 0; - register char *p = tokstart; - int toktype; - - for (++p ;; ++p) - { - if (!got_e && (*p == 'e' || *p == 'E')) - got_dot = got_e = 1; - else if (!got_dot && *p == '.') - got_dot = 1; - else if (got_e && (p[-1] == 'e' || p[-1] == 'E') - && (*p == '-' || *p == '+')) - /* This is the sign of the exponent, not the end of the - number. */ - continue; - else if ((*p < '0' || *p > '9') && - (*p < 'A' || *p > 'F') && - (*p != 'H')) /* Modula-2 hexadecimal number */ - break; - } - toktype = parse_number (p - tokstart); - if (toktype == ERROR) - { - char *err_copy = (char *) alloca (p - tokstart + 1); - - bcopy (tokstart, err_copy, p - tokstart); - err_copy[p - tokstart] = 0; - error ("Invalid number \"%s\".", err_copy); - } - lexptr = p; - return toktype; - } - - if (!(c == '_' || c == '$' - || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))) - /* We must have come across a bad character (e.g. ';'). */ - error ("Invalid character '%c' in expression.", c); - - /* It's a name. See how long it is. */ - namelen = 0; - for (c = tokstart[namelen]; - (c == '_' || c == '$' || (c >= '0' && c <= '9') - || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')); - c = tokstart[++namelen]) - ; - - /* The token "if" terminates the expression and is NOT - removed from the input stream. */ - if (namelen == 2 && tokstart[0] == 'i' && tokstart[1] == 'f') - { - return 0; - } - - lexptr += namelen; - - /* Handle the tokens $digits; also $ (short for $0) and $$ (short for $$1) - and $$digits (equivalent to $<-digits> if you could type that). - Make token type LAST, and put the number (the digits) in yylval. */ - - if (*tokstart == '$') - { - register int negate = 0; - c = 1; - /* Double dollar means negate the number and add -1 as well. - Thus $$ alone means -1. */ - if (namelen >= 2 && tokstart[1] == '$') - { - negate = 1; - c = 2; - } - if (c == namelen) - { - /* Just dollars (one or two) */ - yylval.lval = - negate; - return LAST; - } - /* Is the rest of the token digits? */ - for (; c < namelen; c++) - if (!(tokstart[c] >= '0' && tokstart[c] <= '9')) - break; - if (c == namelen) - { - yylval.lval = atoi (tokstart + 1 + negate); - if (negate) - yylval.lval = - yylval.lval; - return LAST; - } - } - - /* Handle tokens that refer to machine registers: - $ followed by a register name. */ - - if (*tokstart == '$') { - for (c = 0; c < NUM_REGS; c++) - if (namelen - 1 == strlen (reg_names[c]) - && !strncmp (tokstart + 1, reg_names[c], namelen - 1)) - { - yylval.lval = c; - return REGNAME; - } - for (c = 0; c < num_std_regs; c++) - if (namelen - 1 == strlen (std_regs[c].name) - && !strncmp (tokstart + 1, std_regs[c].name, namelen - 1)) - { - yylval.lval = std_regs[c].regnum; - return REGNAME; - } - } - - - /* Lookup special keywords */ - for(i = 0 ; i < sizeof(keytab) / sizeof(keytab[0]) ; i++) - if(namelen == strlen(keytab[i].keyw) && !strncmp(tokstart,keytab[i].keyw,namelen)) - return keytab[i].token; - - yylval.sval.ptr = tokstart; - yylval.sval.length = namelen; - - /* Any other names starting in $ are debugger internal variables. */ - - if (*tokstart == '$') - { - yylval.ivar = (struct internalvar *) lookup_internalvar (copy_name (yylval.sval) + 1); - return INTERNAL_VAR; - } - - - /* Use token-type BLOCKNAME for symbols that happen to be defined as - functions. If this is not so, then ... - Use token-type TYPENAME for symbols that happen to be defined - currently as names of types; NAME for other symbols. - The caller is not constrained to care about the distinction. */ - { - - - char *tmp = copy_name (yylval.sval); - struct symbol *sym; - - if (lookup_partial_symtab (tmp)) - return BLOCKNAME; - sym = lookup_symbol (tmp, expression_context_block, - VAR_NAMESPACE, 0, NULL); - if (sym && SYMBOL_CLASS (sym) == LOC_BLOCK) - return BLOCKNAME; - if (lookup_typename (copy_name (yylval.sval), expression_context_block, 1)) - return TYPENAME; - - if(sym) - { - switch(sym->class) - { - case LOC_STATIC: - case LOC_REGISTER: - case LOC_ARG: - case LOC_REF_ARG: - case LOC_REGPARM: - case LOC_LOCAL: - case LOC_LOCAL_ARG: - case LOC_CONST: - case LOC_CONST_BYTES: - return NAME; - - case LOC_TYPEDEF: - return TYPENAME; - - case LOC_BLOCK: - return BLOCKNAME; - - case LOC_UNDEF: - error("internal: Undefined class in m2lex()"); - - case LOC_LABEL: - error("internal: Unforseen case in m2lex()"); - } - } - else - { - /* Built-in BOOLEAN type. This is sort of a hack. */ - if(!strncmp(tokstart,"TRUE",4)) - { - yylval.ulval = 1; - return TRUE; - } - else if(!strncmp(tokstart,"FALSE",5)) - { - yylval.ulval = 0; - return FALSE; - } - } - - /* Must be another type of name... */ - return NAME; - } -} - -char * -make_qualname(mod,ident) - char *mod, *ident; -{ - char *new = xmalloc(strlen(mod)+strlen(ident)+2); - - strcpy(new,mod); - strcat(new,"."); - strcat(new,ident); - return new; -} - - -void -yyerror() -{ - printf("Parsing: %s\n",lexptr); - if (yychar < 256) - error("Invalid syntax in expression near character '%c'.",yychar); - else - error("Invalid syntax in expression"); -} - -/* Table of operators and their precedences for printing expressions. */ - -const static struct op_print m2_op_print_tab[] = { - {"+", BINOP_ADD, PREC_ADD, 0}, - {"+", UNOP_PLUS, PREC_PREFIX, 0}, - {"-", BINOP_SUB, PREC_ADD, 0}, - {"-", UNOP_NEG, PREC_PREFIX, 0}, - {"*", BINOP_MUL, PREC_MUL, 0}, - {"/", BINOP_DIV, PREC_MUL, 0}, - {"DIV", BINOP_INTDIV, PREC_MUL, 0}, - {"MOD", BINOP_REM, PREC_MUL, 0}, - {":=", BINOP_ASSIGN, PREC_ASSIGN, 1}, - {"OR", BINOP_OR, PREC_OR, 0}, - {"AND", BINOP_AND, PREC_AND, 0}, - {"NOT", UNOP_ZEROP, PREC_PREFIX, 0}, - {"=", BINOP_EQUAL, PREC_EQUAL, 0}, - {"<>", BINOP_NOTEQUAL, PREC_EQUAL, 0}, - {"<=", BINOP_LEQ, PREC_ORDER, 0}, - {">=", BINOP_GEQ, PREC_ORDER, 0}, - {">", BINOP_GTR, PREC_ORDER, 0}, - {"<", BINOP_LESS, PREC_ORDER, 0}, - {"^", UNOP_IND, PREC_PREFIX, 0}, - {"@", BINOP_REPEAT, PREC_REPEAT, 0}, -}; - -/* The built-in types of Modula-2. */ - -struct type *builtin_type_m2_char; -struct type *builtin_type_m2_int; -struct type *builtin_type_m2_card; -struct type *builtin_type_m2_real; -struct type *builtin_type_m2_bool; - -struct type ** const (m2_builtin_types[]) = -{ - &builtin_type_m2_char, - &builtin_type_m2_int, - &builtin_type_m2_card, - &builtin_type_m2_real, - &builtin_type_m2_bool, - 0 -}; - -const struct language_defn m2_language_defn = { - "modula-2", - language_m2, - m2_builtin_types, - range_check_on, - type_check_on, - m2_parse, /* parser */ - m2_error, /* parser error function */ - &builtin_type_m2_int, /* longest signed integral type */ - &builtin_type_m2_card, /* longest unsigned integral type */ - &builtin_type_m2_real, /* longest floating point type */ - "0%XH", "0%", "XH", /* Hex format string, prefix, suffix */ - "%oB", "%", "oB", /* Octal format string, prefix, suffix */ - m2_op_print_tab, /* expression operators for printing */ - LANG_MAGIC -}; - -/* Initialization for Modula-2 */ - -void -_initialize_m2_exp () -{ - /* FIXME: The code below assumes that the sizes of the basic data - types are the same on the host and target machines!!! */ - - /* Modula-2 "pervasive" types. NOTE: these can be redefined!!! */ - builtin_type_m2_int = init_type (TYPE_CODE_INT, sizeof(int), 0, "INTEGER"); - builtin_type_m2_card = init_type (TYPE_CODE_INT, sizeof(int), 1, "CARDINAL"); - builtin_type_m2_real = init_type (TYPE_CODE_FLT, sizeof(float), 0, "REAL"); - builtin_type_m2_char = init_type (TYPE_CODE_CHAR, sizeof(char), 1, "CHAR"); - - builtin_type_m2_bool = init_type (TYPE_CODE_BOOL, sizeof(int), 1, "BOOLEAN"); - TYPE_NFIELDS(builtin_type_m2_bool) = 2; - TYPE_FIELDS(builtin_type_m2_bool) = - (struct field *) malloc (sizeof (struct field) * 2); - TYPE_FIELD_BITPOS(builtin_type_m2_bool,0) = 0; - TYPE_FIELD_NAME(builtin_type_m2_bool,0) = (char *)malloc(6); - strcpy(TYPE_FIELD_NAME(builtin_type_m2_bool,0),"FALSE"); - TYPE_FIELD_BITPOS(builtin_type_m2_bool,1) = 1; - TYPE_FIELD_NAME(builtin_type_m2_bool,1) = (char *)malloc(5); - strcpy(TYPE_FIELD_NAME(builtin_type_m2_bool,1),"TRUE"); - - add_language (&m2_language_defn); -} diff --git a/gdb/m68k-opcode.h b/gdb/m68k-opcode.h deleted file mode 100755 index 1a8f7d2feba..00000000000 --- a/gdb/m68k-opcode.h +++ /dev/null @@ -1,1679 +0,0 @@ -/* Opcode table for m68000/m68020 and m68881. - Copyright (C) 1989, Free Software Foundation. - -This file is part of GDB, the GNU Debugger and GAS, the GNU Assembler. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -struct m68k_opcode -{ - char *name; - unsigned long opcode; - unsigned long match; - char *args; -}; - -/* We store four bytes of opcode for all opcodes because that - is the most any of them need. The actual length of an instruction - is always at least 2 bytes, and is as much longer as necessary to - hold the operands it has. - - The match component is a mask saying which bits must match - particular opcode in order for an instruction to be an instance - of that opcode. - - The args component is a string containing two characters - for each operand of the instruction. The first specifies - the kind of operand; the second, the place it is stored. */ - -/* Kinds of operands: - D data register only. Stored as 3 bits. - A address register only. Stored as 3 bits. - R either kind of register. Stored as 4 bits. - F floating point coprocessor register only. Stored as 3 bits. - O an offset (or width): immediate data 0-31 or data register. - Stored as 6 bits in special format for BF... insns. - + autoincrement only. Stored as 3 bits (number of the address register). - - autodecrement only. Stored as 3 bits (number of the address register). - Q quick immediate data. Stored as 3 bits. - This matches an immediate operand only when value is in range 1 .. 8. - M moveq immediate data. Stored as 8 bits. - This matches an immediate operand only when value is in range -128..127 - T trap vector immediate data. Stored as 4 bits. - - k K-factor for fmove.p instruction. Stored as a 7-bit constant or - a three bit register offset, depending on the field type. - - # immediate data. Stored in special places (b, w or l) - which say how many bits to store. - ^ immediate data for floating point instructions. Special places - are offset by 2 bytes from '#'... - B pc-relative address, converted to an offset - that is treated as immediate data. - d displacement and register. Stores the register as 3 bits - and stores the displacement in the entire second word. - - C the CCR. No need to store it; this is just for filtering validity. - S the SR. No need to store, just as with CCR. - U the USP. No need to store, just as with CCR. - - I Coprocessor ID. Not printed if 1. The Coprocessor ID is always - extracted from the 'd' field of word one, which means that an extended - coprocessor opcode can be skipped using the 'i' place, if needed. - - s System Control register for the floating point coprocessor. - S List of system control registers for floating point coprocessor. - - J Misc register for movec instruction, stored in 'j' format. - Possible values: - 000 SFC Source Function Code reg - 001 DFC Data Function Code reg - 002 CACR Cache Control Register - 800 USP User Stack Pointer - 801 VBR Vector Base reg - 802 CAAR Cache Address Register - 803 MSP Master Stack Pointer - 804 ISP Interrupt Stack Pointer - - L Register list of the type d0-d7/a0-a7 etc. - (New! Improved! Can also hold fp0-fp7, as well!) - The assembler tries to see if the registers match the insn by - looking at where the insn wants them stored. - - l Register list like L, but with all the bits reversed. - Used for going the other way. . . - - They are all stored as 6 bits using an address mode and a register number; - they differ in which addressing modes they match. - - * all (modes 0-6,7.*) - ~ alterable memory (modes 2-6,7.0,7.1)(not 0,1,7.~) - % alterable (modes 0-6,7.0,7.1)(not 7.~) - ; data (modes 0,2-6,7.*)(not 1) - @ data, but not immediate (modes 0,2-6,7.? ? ?)(not 1,7.?) This may really be ;, the 68020 book says it is - ! control (modes 2,5,6,7.*-)(not 0,1,3,4,7.4) - & alterable control (modes 2,5,6,7.0,7.1)(not 0,1,7.? ? ?) - $ alterable data (modes 0,2-6,7.0,7.1)(not 1,7.~) - ? alterable control, or data register (modes 0,2,5,6,7.0,7.1)(not 1,3,4,7.~) - / control, or data register (modes 0,2,5,6,7.0,7.1,7.2,7.3)(not 1,3,4,7.4) -*/ - -/* JF: for the 68851 */ -/* - I didn't use much imagination in choosing the - following codes, so many of them aren't very - mnemonic. -rab - - P pmmu register - Possible values: - 000 TC Translation Control reg - 100 CAL Current Access Level - 101 VAL Validate Access Level - 110 SCC Stack Change Control - 111 AC Access Control - - W wide pmmu registers - Possible values: - 001 DRP Dma Root Pointer - 010 SRP Supervisor Root Pointer - 011 CRP Cpu Root Pointer - - f function code register - 0 SFC - 1 DFC - - V VAL register only - - X BADx, BACx - 100 BAD Breakpoint Acknowledge Data - 101 BAC Breakpoint Acknowledge Control - - Y PSR - Z PCSR - - | memory (modes 2-6, 7.*) - -*/ - -/* Places to put an operand, for non-general operands: - s source, low bits of first word. - d dest, shifted 9 in first word - 1 second word, shifted 12 - 2 second word, shifted 6 - 3 second word, shifted 0 - 4 third word, shifted 12 - 5 third word, shifted 6 - 6 third word, shifted 0 - 7 second word, shifted 7 - 8 second word, shifted 10 - D store in both place 1 and place 3; for divul and divsl. - b second word, low byte - w second word (entire) - l second and third word (entire) - g branch offset for bra and similar instructions. - The place to store depends on the magnitude of offset. - t store in both place 7 and place 8; for floating point operations - c branch offset for cpBcc operations. - The place to store is word two if bit six of word one is zero, - and words two and three if bit six of word one is one. - i Increment by two, to skip over coprocessor extended operands. Only - works with the 'I' format. - k Dynamic K-factor field. Bits 6-4 of word 2, used as a register number. - Also used for dynamic fmovem instruction. - C floating point coprocessor constant - 7 bits. Also used for static - K-factors... - j Movec register #, stored in 12 low bits of second word. - - Places to put operand, for general operands: - d destination, shifted 6 bits in first word - b source, at low bit of first word, and immediate uses one byte - w source, at low bit of first word, and immediate uses two bytes - l source, at low bit of first word, and immediate uses four bytes - s source, at low bit of first word. - Used sometimes in contexts where immediate is not allowed anyway. - f single precision float, low bit of 1st word, immediate uses 4 bytes - F double precision float, low bit of 1st word, immediate uses 8 bytes - x extended precision float, low bit of 1st word, immediate uses 12 bytes - p packed float, low bit of 1st word, immediate uses 12 bytes -*/ - -#define one(x) ((x) << 16) -#define two(x, y) (((x) << 16) + y) - -/* - *** DANGER WILL ROBINSON *** - - The assembler requires that all instances of the same mnemonic must be - consecutive. If they aren't, the assembler will bomb at runtime - */ -struct m68k_opcode m68k_opcodes[] = -{ -{"abcd", one(0140400), one(0170770), "DsDd"}, -{"abcd", one(0140410), one(0170770), "-s-d"}, - - /* Add instructions */ -{"addal", one(0150700), one(0170700), "*lAd"}, -{"addaw", one(0150300), one(0170700), "*wAd"}, -{"addib", one(0003000), one(0177700), "#b$b"}, -{"addil", one(0003200), one(0177700), "#l$l"}, -{"addiw", one(0003100), one(0177700), "#w$w"}, -{"addqb", one(0050000), one(0170700), "Qd$b"}, -{"addql", one(0050200), one(0170700), "Qd%l"}, -{"addqw", one(0050100), one(0170700), "Qd%w"}, - -{"addb", one(0050000), one(0170700), "Qd$b"}, /* addq written as add */ -{"addb", one(0003000), one(0177700), "#b$b"}, /* addi written as add */ -{"addb", one(0150000), one(0170700), ";bDd"}, /* addb , Dd */ -{"addb", one(0150400), one(0170700), "Dd~b"}, /* addb Dd, */ - -{"addw", one(0050100), one(0170700), "Qd%w"}, /* addq written as add */ -{"addw", one(0003100), one(0177700), "#w$w"}, /* addi written as add */ -{"addw", one(0150300), one(0170700), "*wAd"}, /* adda written as add */ -{"addw", one(0150100), one(0170700), "*wDd"}, /* addw , Dd */ -{"addw", one(0150500), one(0170700), "Dd~w"}, /* addw Dd, */ - -{"addl", one(0050200), one(0170700), "Qd%l"}, /* addq written as add */ -{"addl", one(0003200), one(0177700), "#l$l"}, /* addi written as add */ -{"addl", one(0150700), one(0170700), "*lAd"}, /* adda written as add */ -{"addl", one(0150200), one(0170700), "*lDd"}, /* addl , Dd */ -{"addl", one(0150600), one(0170700), "Dd~l"}, /* addl Dd, */ - -{"addxb", one(0150400), one(0170770), "DsDd"}, -{"addxb", one(0150410), one(0170770), "-s-d"}, -{"addxl", one(0150600), one(0170770), "DsDd"}, -{"addxl", one(0150610), one(0170770), "-s-d"}, -{"addxw", one(0150500), one(0170770), "DsDd"}, -{"addxw", one(0150510), one(0170770), "-s-d"}, - -{"andib", one(0001000), one(0177700), "#b$b"}, -{"andib", one(0001074), one(0177777), "#bCb"}, /* andi to ccr */ -{"andiw", one(0001100), one(0177700), "#w$w"}, -{"andiw", one(0001174), one(0177777), "#wSw"}, /* andi to sr */ -{"andil", one(0001200), one(0177700), "#l$l"}, - -{"andb", one(0001000), one(0177700), "#b$b"}, /* andi written as or */ -{"andb", one(0001074), one(0177777), "#bCb"}, /* andi to ccr */ -{"andb", one(0140000), one(0170700), ";bDd"}, /* memory to register */ -{"andb", one(0140400), one(0170700), "Dd~b"}, /* register to memory */ -{"andw", one(0001100), one(0177700), "#w$w"}, /* andi written as or */ -{"andw", one(0001174), one(0177777), "#wSw"}, /* andi to sr */ -{"andw", one(0140100), one(0170700), ";wDd"}, /* memory to register */ -{"andw", one(0140500), one(0170700), "Dd~w"}, /* register to memory */ -{"andl", one(0001200), one(0177700), "#l$l"}, /* andi written as or */ -{"andl", one(0140200), one(0170700), ";lDd"}, /* memory to register */ -{"andl", one(0140600), one(0170700), "Dd~l"}, /* register to memory */ - -{"aslb", one(0160400), one(0170770), "QdDs"}, -{"aslb", one(0160440), one(0170770), "DdDs"}, -{"asll", one(0160600), one(0170770), "QdDs"}, -{"asll", one(0160640), one(0170770), "DdDs"}, -{"aslw", one(0160500), one(0170770), "QdDs"}, -{"aslw", one(0160540), one(0170770), "DdDs"}, -{"aslw", one(0160700), one(0177700), "~s"}, /* Shift memory */ -{"asrb", one(0160000), one(0170770), "QdDs"}, -{"asrb", one(0160040), one(0170770), "DdDs"}, -{"asrl", one(0160200), one(0170770), "QdDs"}, -{"asrl", one(0160240), one(0170770), "DdDs"}, -{"asrw", one(0160100), one(0170770), "QdDs"}, -{"asrw", one(0160140), one(0170770), "DdDs"}, -{"asrw", one(0160300), one(0177700), "~s"}, /* Shift memory */ - -{"bhi", one(0061000), one(0177400), "Bg"}, -{"bls", one(0061400), one(0177400), "Bg"}, -{"bcc", one(0062000), one(0177400), "Bg"}, -{"bcs", one(0062400), one(0177400), "Bg"}, -{"bne", one(0063000), one(0177400), "Bg"}, -{"beq", one(0063400), one(0177400), "Bg"}, -{"bvc", one(0064000), one(0177400), "Bg"}, -{"bvs", one(0064400), one(0177400), "Bg"}, -{"bpl", one(0065000), one(0177400), "Bg"}, -{"bmi", one(0065400), one(0177400), "Bg"}, -{"bge", one(0066000), one(0177400), "Bg"}, -{"blt", one(0066400), one(0177400), "Bg"}, -{"bgt", one(0067000), one(0177400), "Bg"}, -{"ble", one(0067400), one(0177400), "Bg"}, - -{"bchg", one(0000500), one(0170700), "Dd$s"}, -{"bchg", one(0004100), one(0177700), "#b$s"}, -{"bclr", one(0000600), one(0170700), "Dd$s"}, -{"bclr", one(0004200), one(0177700), "#b$s"}, -{"bfchg", two(0165300, 0), two(0177700, 0170000), "?sO2O3"}, -{"bfclr", two(0166300, 0), two(0177700, 0170000), "?sO2O3"}, -{"bfexts", two(0165700, 0), two(0177700, 0100000), "/sO2O3D1"}, -{"bfextu", two(0164700, 0), two(0177700, 0100000), "/sO2O3D1"}, -{"bfffo", two(0166700, 0), two(0177700, 0100000), "/sO2O3D1"}, -{"bfins", two(0167700, 0), two(0177700, 0100000), "D1?sO2O3"}, -{"bfset", two(0167300, 0), two(0177700, 0170000), "?sO2O3"}, -{"bftst", two(0164300, 0), two(0177700, 0170000), "/sO2O3"}, -{"bset", one(0000700), one(0170700), "Dd$s"}, -{"bset", one(0004300), one(0177700), "#b$s"}, -{"btst", one(0000400), one(0170700), "Dd@s"}, -{"btst", one(0004000), one(0177700), "#b@s"}, - -{"bkpt", one(0044110), one(0177770), "Qs"}, -{"bra", one(0060000), one(0177400), "Bg"}, -{"bras", one(0060000), one(0177400), "Bw"}, -{"bsr", one(0060400), one(0177400), "Bg"}, -{"bsrs", one(0060400), one(0177400), "Bw"}, - -{"callm", one(0003300), one(0177700), "#b!s"}, -{"cas2l", two(0007374, 0), two(0177777, 0107070), "D3D6D2D5R1R4"}, /* JF FOO this is really a 3 word ins */ -{"cas2w", two(0006374, 0), two(0177777, 0107070), "D3D6D2D5R1R4"}, /* JF ditto */ -{"casb", two(0005300, 0), two(0177700, 0177070), "D3D2~s"}, -{"casl", two(0007300, 0), two(0177700, 0177070), "D3D2~s"}, -{"casw", two(0006300, 0), two(0177700, 0177070), "D3D2~s"}, - -/* {"chk", one(0040600), one(0170700), ";wDd"}, JF FOO this looks wrong */ -{"chk2b", two(0000300, 0004000), two(0177700, 07777), "!sR1"}, -{"chk2l", two(0002300, 0004000), two(0177700, 07777), "!sR1"}, -{"chk2w", two(0001300, 0004000), two(0177700, 07777), "!sR1"}, -{"chkl", one(0040400), one(0170700), ";lDd"}, -{"chkw", one(0040600), one(0170700), ";wDd"}, -{"clrb", one(0041000), one(0177700), "$s"}, -{"clrl", one(0041200), one(0177700), "$s"}, -{"clrw", one(0041100), one(0177700), "$s"}, - -{"cmp2b", two(0000300, 0), two(0177700, 07777), "!sR1"}, -{"cmp2l", two(0002300, 0), two(0177700, 07777), "!sR1"}, -{"cmp2w", two(0001300, 0), two(0177700, 07777), "!sR1"}, -{"cmpal", one(0130700), one(0170700), "*lAd"}, -{"cmpaw", one(0130300), one(0170700), "*wAd"}, -{"cmpib", one(0006000), one(0177700), "#b;b"}, -{"cmpil", one(0006200), one(0177700), "#l;l"}, -{"cmpiw", one(0006100), one(0177700), "#w;w"}, -{"cmpb", one(0006000), one(0177700), "#b;b"}, /* cmpi written as cmp */ -{"cmpb", one(0130000), one(0170700), ";bDd"}, -{"cmpw", one(0006100), one(0177700), "#w;w"}, -{"cmpw", one(0130100), one(0170700), "*wDd"}, -{"cmpw", one(0130300), one(0170700), "*wAd"}, /* cmpa written as cmp */ -{"cmpl", one(0006200), one(0177700), "#l;l"}, -{"cmpl", one(0130200), one(0170700), "*lDd"}, -{"cmpl", one(0130700), one(0170700), "*lAd"}, -{"cmpmb", one(0130410), one(0170770), "+s+d"}, -{"cmpml", one(0130610), one(0170770), "+s+d"}, -{"cmpmw", one(0130510), one(0170770), "+s+d"}, - -{"dbcc", one(0052310), one(0177770), "DsBw"}, -{"dbcs", one(0052710), one(0177770), "DsBw"}, -{"dbeq", one(0053710), one(0177770), "DsBw"}, -{"dbf", one(0050710), one(0177770), "DsBw"}, -{"dbge", one(0056310), one(0177770), "DsBw"}, -{"dbgt", one(0057310), one(0177770), "DsBw"}, -{"dbhi", one(0051310), one(0177770), "DsBw"}, -{"dble", one(0057710), one(0177770), "DsBw"}, -{"dbls", one(0051710), one(0177770), "DsBw"}, -{"dblt", one(0056710), one(0177770), "DsBw"}, -{"dbmi", one(0055710), one(0177770), "DsBw"}, -{"dbne", one(0053310), one(0177770), "DsBw"}, -{"dbpl", one(0055310), one(0177770), "DsBw"}, -{"dbra", one(0050710), one(0177770), "DsBw"}, -{"dbt", one(0050310), one(0177770), "DsBw"}, -{"dbvc", one(0054310), one(0177770), "DsBw"}, -{"dbvs", one(0054710), one(0177770), "DsBw"}, - -{"divsl", two(0046100, 0006000), two(0177700, 0107770), ";lD3D1"}, -{"divsl", two(0046100, 0004000), two(0177700, 0107770), ";lDD"}, -{"divsll", two(0046100, 0004000), two(0177700, 0107770), ";lD3D1"}, -{"divsw", one(0100700), one(0170700), ";wDd"}, -{"divs", one(0100700), one(0170700), ";wDd"}, -{"divul", two(0046100, 0002000), two(0177700, 0107770), ";lD3D1"}, -{"divul", two(0046100, 0000000), two(0177700, 0107770), ";lDD"}, -{"divull", two(0046100, 0000000), two(0177700, 0107770), ";lD3D1"}, -{"divuw", one(0100300), one(0170700), ";wDd"}, -{"divu", one(0100300), one(0170700), ";wDd"}, -{"eorb", one(0005000), one(0177700), "#b$s"}, /* eori written as or */ -{"eorb", one(0005074), one(0177777), "#bCs"}, /* eori to ccr */ -{"eorb", one(0130400), one(0170700), "Dd$s"}, /* register to memory */ -{"eorib", one(0005000), one(0177700), "#b$s"}, -{"eorib", one(0005074), one(0177777), "#bCs"}, /* eori to ccr */ -{"eoril", one(0005200), one(0177700), "#l$s"}, -{"eoriw", one(0005100), one(0177700), "#w$s"}, -{"eoriw", one(0005174), one(0177777), "#wSs"}, /* eori to sr */ -{"eorl", one(0005200), one(0177700), "#l$s"}, -{"eorl", one(0130600), one(0170700), "Dd$s"}, -{"eorw", one(0005100), one(0177700), "#w$s"}, -{"eorw", one(0005174), one(0177777), "#wSs"}, /* eori to sr */ -{"eorw", one(0130500), one(0170700), "Dd$s"}, - -{"exg", one(0140500), one(0170770), "DdDs"}, -{"exg", one(0140510), one(0170770), "AdAs"}, -{"exg", one(0140610), one(0170770), "DdAs"}, -{"exg", one(0140610), one(0170770), "AsDd"}, - -{"extw", one(0044200), one(0177770), "Ds"}, -{"extl", one(0044300), one(0177770), "Ds"}, -{"extbl", one(0044700), one(0177770), "Ds"}, -{"extb.l", one(0044700), one(0177770), "Ds"}, /* Not sure we should support this one*/ - -{"illegal", one(0045374), one(0177777), ""}, -{"jmp", one(0047300), one(0177700), "!s"}, -{"jsr", one(0047200), one(0177700), "!s"}, -{"lea", one(0040700), one(0170700), "!sAd"}, -{"linkw", one(0047120), one(0177770), "As#w"}, -{"linkl", one(0044010), one(0177770), "As#l"}, -{"link", one(0047120), one(0177770), "As#w"}, -{"link", one(0044010), one(0177770), "As#l"}, - -{"lslb", one(0160410), one(0170770), "QdDs"}, /* lsrb #Q, Ds */ -{"lslb", one(0160450), one(0170770), "DdDs"}, /* lsrb Dd, Ds */ -{"lslw", one(0160510), one(0170770), "QdDs"}, /* lsrb #Q, Ds */ -{"lslw", one(0160550), one(0170770), "DdDs"}, /* lsrb Dd, Ds */ -{"lslw", one(0161700), one(0177700), "~s"}, /* Shift memory */ -{"lsll", one(0160610), one(0170770), "QdDs"}, /* lsrb #Q, Ds */ -{"lsll", one(0160650), one(0170770), "DdDs"}, /* lsrb Dd, Ds */ - -{"lsrb", one(0160010), one(0170770), "QdDs"} /* lsrb #Q, Ds */, -{"lsrb", one(0160050), one(0170770), "DdDs"}, /* lsrb Dd, Ds */ -{"lsrl", one(0160210), one(0170770), "QdDs"}, /* lsrb #Q, Ds */ -{"lsrl", one(0160250), one(0170770), "DdDs"}, /* lsrb #Q, Ds */ -{"lsrw", one(0160110), one(0170770), "QdDs"}, /* lsrb #Q, Ds */ -{"lsrw", one(0160150), one(0170770), "DdDs"}, /* lsrb #Q, Ds */ -{"lsrw", one(0161300), one(0177700), "~s"}, /* Shift memory */ - -{"moveal", one(0020100), one(0170700), "*lAd"}, -{"moveaw", one(0030100), one(0170700), "*wAd"}, -{"moveb", one(0010000), one(0170000), ";b$d"}, /* move */ -{"movel", one(0070000), one(0170400), "MsDd"}, /* moveq written as move */ -{"movel", one(0020000), one(0170000), "*l$d"}, -{"movel", one(0020100), one(0170700), "*lAd"}, -{"movel", one(0047140), one(0177770), "AsUd"}, /* move to USP */ -{"movel", one(0047150), one(0177770), "UdAs"}, /* move from USP */ - -{"movec", one(0047173), one(0177777), "R1Jj"}, -{"movec", one(0047173), one(0177777), "R1#j"}, -{"movec", one(0047172), one(0177777), "JjR1"}, -{"movec", one(0047172), one(0177777), "#jR1"}, - -/* JF added these next four for the assembler */ -{"moveml", one(0044300), one(0177700), "Lw&s"}, /* movem reg to mem. */ -{"moveml", one(0044340), one(0177770), "lw-s"}, /* movem reg to autodecrement. */ -{"moveml", one(0046300), one(0177700), "!sLw"}, /* movem mem to reg. */ -{"moveml", one(0046330), one(0177770), "+sLw"}, /* movem autoinc to reg. */ - -{"moveml", one(0044300), one(0177700), "#w&s"}, /* movem reg to mem. */ -{"moveml", one(0044340), one(0177770), "#w-s"}, /* movem reg to autodecrement. */ -{"moveml", one(0046300), one(0177700), "!s#w"}, /* movem mem to reg. */ -{"moveml", one(0046330), one(0177770), "+s#w"}, /* movem autoinc to reg. */ - -/* JF added these next four for the assembler */ -{"movemw", one(0044200), one(0177700), "Lw&s"}, /* movem reg to mem. */ -{"movemw", one(0044240), one(0177770), "lw-s"}, /* movem reg to autodecrement. */ -{"movemw", one(0046200), one(0177700), "!sLw"}, /* movem mem to reg. */ -{"movemw", one(0046230), one(0177770), "+sLw"}, /* movem autoinc to reg. */ - -{"movemw", one(0044200), one(0177700), "#w&s"}, /* movem reg to mem. */ -{"movemw", one(0044240), one(0177770), "#w-s"}, /* movem reg to autodecrement. */ -{"movemw", one(0046200), one(0177700), "!s#w"}, /* movem mem to reg. */ -{"movemw", one(0046230), one(0177770), "+s#w"}, /* movem autoinc to reg. */ - -{"movepl", one(0000510), one(0170770), "dsDd"}, /* memory to register */ -{"movepl", one(0000710), one(0170770), "Ddds"}, /* register to memory */ -{"movepw", one(0000410), one(0170770), "dsDd"}, /* memory to register */ -{"movepw", one(0000610), one(0170770), "Ddds"}, /* register to memory */ -{"moveq", one(0070000), one(0170400), "MsDd"}, -{"movew", one(0030000), one(0170000), "*w$d"}, -{"movew", one(0030100), one(0170700), "*wAd"}, /* movea, written as move */ -{"movew", one(0040300), one(0177700), "Ss$s"}, /* Move from sr */ -{"movew", one(0041300), one(0177700), "Cs$s"}, /* Move from ccr */ -{"movew", one(0042300), one(0177700), ";wCd"}, /* move to ccr */ -{"movew", one(0043300), one(0177700), ";wSd"}, /* move to sr */ - -{"movesb", two(0007000, 0), two(0177700, 07777), "~sR1"}, /* moves from memory */ -{"movesb", two(0007000, 04000), two(0177700, 07777), "R1~s"}, /* moves to memory */ -{"movesl", two(0007200, 0), two(0177700, 07777), "~sR1"}, /* moves from memory */ -{"movesl", two(0007200, 04000), two(0177700, 07777), "R1~s"}, /* moves to memory */ -{"movesw", two(0007100, 0), two(0177700, 07777), "~sR1"}, /* moves from memory */ -{"movesw", two(0007100, 04000), two(0177700, 07777), "R1~s"}, /* moves to memory */ - -{"mulsl", two(0046000, 004000), two(0177700, 0107770), ";lD1"}, -{"mulsl", two(0046000, 006000), two(0177700, 0107770), ";lD3D1"}, -{"mulsw", one(0140700), one(0170700), ";wDd"}, -{"muls", one(0140700), one(0170700), ";wDd"}, -{"mulul", two(0046000, 000000), two(0177700, 0107770), ";lD1"}, -{"mulul", two(0046000, 002000), two(0177700, 0107770), ";lD3D1"}, -{"muluw", one(0140300), one(0170700), ";wDd"}, -{"mulu", one(0140300), one(0170700), ";wDd"}, -{"nbcd", one(0044000), one(0177700), "$s"}, -{"negb", one(0042000), one(0177700), "$s"}, -{"negl", one(0042200), one(0177700), "$s"}, -{"negw", one(0042100), one(0177700), "$s"}, -{"negxb", one(0040000), one(0177700), "$s"}, -{"negxl", one(0040200), one(0177700), "$s"}, -{"negxw", one(0040100), one(0177700), "$s"}, -{"nop", one(0047161), one(0177777), ""}, -{"notb", one(0043000), one(0177700), "$s"}, -{"notl", one(0043200), one(0177700), "$s"}, -{"notw", one(0043100), one(0177700), "$s"}, - -{"orb", one(0000000), one(0177700), "#b$s"}, /* ori written as or */ -{"orb", one(0000074), one(0177777), "#bCs"}, /* ori to ccr */ -{"orb", one(0100000), one(0170700), ";bDd"}, /* memory to register */ -{"orb", one(0100400), one(0170700), "Dd~s"}, /* register to memory */ -{"orib", one(0000000), one(0177700), "#b$s"}, -{"orib", one(0000074), one(0177777), "#bCs"}, /* ori to ccr */ -{"oril", one(0000200), one(0177700), "#l$s"}, -{"oriw", one(0000100), one(0177700), "#w$s"}, -{"oriw", one(0000174), one(0177777), "#wSs"}, /* ori to sr */ -{"orl", one(0000200), one(0177700), "#l$s"}, -{"orl", one(0100200), one(0170700), ";lDd"}, /* memory to register */ -{"orl", one(0100600), one(0170700), "Dd~s"}, /* register to memory */ -{"orw", one(0000100), one(0177700), "#w$s"}, -{"orw", one(0000174), one(0177777), "#wSs"}, /* ori to sr */ -{"orw", one(0100100), one(0170700), ";wDd"}, /* memory to register */ -{"orw", one(0100500), one(0170700), "Dd~s"}, /* register to memory */ - -{"pack", one(0100500), one(0170770), "DsDd#w"}, /* pack Ds, Dd, #w */ -{"pack", one(0100510), one(0170770), "-s-d#w"}, /* pack -(As), -(Ad), #w */ -{"pea", one(0044100), one(0177700), "!s"}, -{"reset", one(0047160), one(0177777), ""}, - -{"rolb", one(0160430), one(0170770), "QdDs"}, /* rorb #Q, Ds */ -{"rolb", one(0160470), one(0170770), "DdDs"}, /* rorb Dd, Ds */ -{"roll", one(0160630), one(0170770), "QdDs"}, /* rorb #Q, Ds */ -{"roll", one(0160670), one(0170770), "DdDs"}, /* rorb Dd, Ds */ -{"rolw", one(0160530), one(0170770), "QdDs"}, /* rorb #Q, Ds */ -{"rolw", one(0160570), one(0170770), "DdDs"}, /* rorb Dd, Ds */ -{"rolw", one(0163700), one(0177700), "~s"}, /* Rotate memory */ -{"rorb", one(0160030), one(0170770), "QdDs"}, /* rorb #Q, Ds */ -{"rorb", one(0160070), one(0170770), "DdDs"}, /* rorb Dd, Ds */ -{"rorl", one(0160230), one(0170770), "QdDs"}, /* rorb #Q, Ds */ -{"rorl", one(0160270), one(0170770), "DdDs"}, /* rorb Dd, Ds */ -{"rorw", one(0160130), one(0170770), "QdDs"}, /* rorb #Q, Ds */ -{"rorw", one(0160170), one(0170770), "DdDs"}, /* rorb Dd, Ds */ -{"rorw", one(0163300), one(0177700), "~s"}, /* Rotate memory */ - -{"roxlb", one(0160420), one(0170770), "QdDs"}, /* roxrb #Q, Ds */ -{"roxlb", one(0160460), one(0170770), "DdDs"}, /* roxrb Dd, Ds */ -{"roxll", one(0160620), one(0170770), "QdDs"}, /* roxrb #Q, Ds */ -{"roxll", one(0160660), one(0170770), "DdDs"}, /* roxrb Dd, Ds */ -{"roxlw", one(0160520), one(0170770), "QdDs"}, /* roxrb #Q, Ds */ -{"roxlw", one(0160560), one(0170770), "DdDs"}, /* roxrb Dd, Ds */ -{"roxlw", one(0162700), one(0177700), "~s"}, /* Rotate memory */ -{"roxrb", one(0160020), one(0170770), "QdDs"}, /* roxrb #Q, Ds */ -{"roxrb", one(0160060), one(0170770), "DdDs"}, /* roxrb Dd, Ds */ -{"roxrl", one(0160220), one(0170770), "QdDs"}, /* roxrb #Q, Ds */ -{"roxrl", one(0160260), one(0170770), "DdDs"}, /* roxrb Dd, Ds */ -{"roxrw", one(0160120), one(0170770), "QdDs"}, /* roxrb #Q, Ds */ -{"roxrw", one(0160160), one(0170770), "DdDs"}, /* roxrb Dd, Ds */ -{"roxrw", one(0162300), one(0177700), "~s"}, /* Rotate memory */ - -{"rtd", one(0047164), one(0177777), "#w"}, -{"rte", one(0047163), one(0177777), ""}, -{"rtm", one(0003300), one(0177760), "Rs"}, -{"rtr", one(0047167), one(0177777), ""}, -{"rts", one(0047165), one(0177777), ""}, - -{"scc", one(0052300), one(0177700), "$s"}, -{"scs", one(0052700), one(0177700), "$s"}, -{"seq", one(0053700), one(0177700), "$s"}, -{"sf", one(0050700), one(0177700), "$s"}, -{"sge", one(0056300), one(0177700), "$s"}, -{"sgt", one(0057300), one(0177700), "$s"}, -{"shi", one(0051300), one(0177700), "$s"}, -{"sle", one(0057700), one(0177700), "$s"}, -{"sls", one(0051700), one(0177700), "$s"}, -{"slt", one(0056700), one(0177700), "$s"}, -{"smi", one(0055700), one(0177700), "$s"}, -{"sne", one(0053300), one(0177700), "$s"}, -{"spl", one(0055300), one(0177700), "$s"}, -{"st", one(0050300), one(0177700), "$s"}, -{"svc", one(0054300), one(0177700), "$s"}, -{"svs", one(0054700), one(0177700), "$s"}, - -{"sbcd", one(0100400), one(0170770), "DsDd"}, -{"sbcd", one(0100410), one(0170770), "-s-d"}, -{"stop", one(0047162), one(0177777), "#w"}, - -{"subal", one(0110700), one(0170700), "*lAd"}, -{"subaw", one(0110300), one(0170700), "*wAd"}, -{"subb", one(0050400), one(0170700), "Qd%s"}, /* subq written as sub */ -{"subb", one(0002000), one(0177700), "#b$s"}, /* subi written as sub */ -{"subb", one(0110000), one(0170700), ";bDd"}, /* subb ? ?, Dd */ -{"subb", one(0110400), one(0170700), "Dd~s"}, /* subb Dd, ? ? */ -{"subib", one(0002000), one(0177700), "#b$s"}, -{"subil", one(0002200), one(0177700), "#l$s"}, -{"subiw", one(0002100), one(0177700), "#w$s"}, -{"subl", one(0050600), one(0170700), "Qd%s"}, -{"subl", one(0002200), one(0177700), "#l$s"}, -{"subl", one(0110700), one(0170700), "*lAd"}, -{"subl", one(0110200), one(0170700), "*lDd"}, -{"subl", one(0110600), one(0170700), "Dd~s"}, -{"subqb", one(0050400), one(0170700), "Qd%s"}, -{"subql", one(0050600), one(0170700), "Qd%s"}, -{"subqw", one(0050500), one(0170700), "Qd%s"}, -{"subw", one(0050500), one(0170700), "Qd%s"}, -{"subw", one(0002100), one(0177700), "#w$s"}, -{"subw", one(0110100), one(0170700), "*wDd"}, -{"subw", one(0110300), one(0170700), "*wAd"}, /* suba written as sub */ -{"subw", one(0110500), one(0170700), "Dd~s"}, -{"subxb", one(0110400), one(0170770), "DsDd"}, /* subxb Ds, Dd */ -{"subxb", one(0110410), one(0170770), "-s-d"}, /* subxb -(As), -(Ad) */ -{"subxl", one(0110600), one(0170770), "DsDd"}, -{"subxl", one(0110610), one(0170770), "-s-d"}, -{"subxw", one(0110500), one(0170770), "DsDd"}, -{"subxw", one(0110510), one(0170770), "-s-d"}, - -{"swap", one(0044100), one(0177770), "Ds"}, - -{"tas", one(0045300), one(0177700), "$s"}, -{"trap", one(0047100), one(0177760), "Ts"}, - -{"trapcc", one(0052374), one(0177777), ""}, -{"trapcs", one(0052774), one(0177777), ""}, -{"trapeq", one(0053774), one(0177777), ""}, -{"trapf", one(0050774), one(0177777), ""}, -{"trapge", one(0056374), one(0177777), ""}, -{"trapgt", one(0057374), one(0177777), ""}, -{"traphi", one(0051374), one(0177777), ""}, -{"traple", one(0057774), one(0177777), ""}, -{"trapls", one(0051774), one(0177777), ""}, -{"traplt", one(0056774), one(0177777), ""}, -{"trapmi", one(0055774), one(0177777), ""}, -{"trapne", one(0053374), one(0177777), ""}, -{"trappl", one(0055374), one(0177777), ""}, -{"trapt", one(0050374), one(0177777), ""}, -{"trapvc", one(0054374), one(0177777), ""}, -{"trapvs", one(0054774), one(0177777), ""}, - -{"trapcc.w", one(0052372), one(0177777), ""}, -{"trapcs.w", one(0052772), one(0177777), ""}, -{"trapeq.w", one(0053772), one(0177777), ""}, -{"trapf.w", one(0050772), one(0177777), ""}, -{"trapge.w", one(0056372), one(0177777), ""}, -{"trapgt.w", one(0057372), one(0177777), ""}, -{"traphi.w", one(0051372), one(0177777), ""}, -{"traple.w", one(0057772), one(0177777), ""}, -{"trapls.w", one(0051772), one(0177777), ""}, -{"traplt.w", one(0056772), one(0177777), ""}, -{"trapmi.w", one(0055772), one(0177777), ""}, -{"trapne.w", one(0053372), one(0177777), ""}, -{"trappl.w", one(0055372), one(0177777), ""}, -{"trapt.w", one(0050372), one(0177777), ""}, -{"trapvc.w", one(0054372), one(0177777), ""}, -{"trapvs.w", one(0054772), one(0177777), ""}, - -{"trapcc.l", one(0052373), one(0177777), ""}, -{"trapcs.l", one(0052773), one(0177777), ""}, -{"trapeq.l", one(0053773), one(0177777), ""}, -{"trapf.l", one(0050773), one(0177777), ""}, -{"trapge.l", one(0056373), one(0177777), ""}, -{"trapgt.l", one(0057373), one(0177777), ""}, -{"traphi.l", one(0051373), one(0177777), ""}, -{"traple.l", one(0057773), one(0177777), ""}, -{"trapls.l", one(0051773), one(0177777), ""}, -{"traplt.l", one(0056773), one(0177777), ""}, -{"trapmi.l", one(0055773), one(0177777), ""}, -{"trapne.l", one(0053373), one(0177777), ""}, -{"trappl.l", one(0055373), one(0177777), ""}, -{"trapt.l", one(0050373), one(0177777), ""}, -{"trapvc.l", one(0054373), one(0177777), ""}, -{"trapvs.l", one(0054773), one(0177777), ""}, - -{"trapv", one(0047166), one(0177777), ""}, - -{"tstb", one(0045000), one(0177700), ";b"}, -{"tstw", one(0045100), one(0177700), "*w"}, -{"tstl", one(0045200), one(0177700), "*l"}, - -{"unlk", one(0047130), one(0177770), "As"}, -{"unpk", one(0100600), one(0170770), "DsDd#w"}, -{"unpk", one(0100610), one(0170770), "-s-d#w"}, - /* JF floating pt stuff moved down here */ - -{"fabsb", two(0xF000, 0x5818), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fabsd", two(0xF000, 0x5418), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fabsl", two(0xF000, 0x4018), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fabsp", two(0xF000, 0x4C18), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fabss", two(0xF000, 0x4418), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fabsw", two(0xF000, 0x5018), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fabsx", two(0xF000, 0x0018), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fabsx", two(0xF000, 0x4818), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fabsx", two(0xF000, 0x0018), two(0xF1C0, 0xE07F), "IiFt"}, - -{"facosb", two(0xF000, 0x581C), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"facosd", two(0xF000, 0x541C), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"facosl", two(0xF000, 0x401C), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"facosp", two(0xF000, 0x4C1C), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"facoss", two(0xF000, 0x441C), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"facosw", two(0xF000, 0x501C), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"facosx", two(0xF000, 0x001C), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"facosx", two(0xF000, 0x481C), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"facosx", two(0xF000, 0x001C), two(0xF1C0, 0xE07F), "IiFt"}, - -{"faddb", two(0xF000, 0x5822), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"faddd", two(0xF000, 0x5422), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"faddl", two(0xF000, 0x4022), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"faddp", two(0xF000, 0x4C22), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fadds", two(0xF000, 0x4422), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"faddw", two(0xF000, 0x5022), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"faddx", two(0xF000, 0x0022), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"faddx", two(0xF000, 0x4822), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -/* {"faddx", two(0xF000, 0x0022), two(0xF1C0, 0xE07F), "IiFt"}, JF removed */ - -{"fasinb", two(0xF000, 0x580C), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fasind", two(0xF000, 0x540C), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fasinl", two(0xF000, 0x400C), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fasinp", two(0xF000, 0x4C0C), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fasins", two(0xF000, 0x440C), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fasinw", two(0xF000, 0x500C), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fasinx", two(0xF000, 0x000C), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fasinx", two(0xF000, 0x480C), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fasinx", two(0xF000, 0x000C), two(0xF1C0, 0xE07F), "IiFt"}, - -{"fatanb", two(0xF000, 0x580A), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fatand", two(0xF000, 0x540A), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fatanl", two(0xF000, 0x400A), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fatanp", two(0xF000, 0x4C0A), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fatans", two(0xF000, 0x440A), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fatanw", two(0xF000, 0x500A), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fatanx", two(0xF000, 0x000A), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fatanx", two(0xF000, 0x480A), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fatanx", two(0xF000, 0x000A), two(0xF1C0, 0xE07F), "IiFt"}, - -{"fatanhb", two(0xF000, 0x580D), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fatanhd", two(0xF000, 0x540D), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fatanhl", two(0xF000, 0x400D), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fatanhp", two(0xF000, 0x4C0D), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fatanhs", two(0xF000, 0x440D), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fatanhw", two(0xF000, 0x500D), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fatanhx", two(0xF000, 0x000D), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fatanhx", two(0xF000, 0x480D), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fatanhx", two(0xF000, 0x000D), two(0xF1C0, 0xE07F), "IiFt"}, - -{"fbeq", one(0xF081), one(0xF1BF), "IdBc"}, -{"fbf", one(0xF080), one(0xF1BF), "IdBc"}, -{"fbge", one(0xF093), one(0xF1BF), "IdBc"}, -{"fbgl", one(0xF096), one(0xF1BF), "IdBc"}, -{"fbgle", one(0xF097), one(0xF1BF), "IdBc"}, -{"fbgt", one(0xF092), one(0xF1BF), "IdBc"}, -{"fble", one(0xF095), one(0xF1BF), "IdBc"}, -{"fblt", one(0xF094), one(0xF1BF), "IdBc"}, -{"fbne", one(0xF08E), one(0xF1BF), "IdBc"}, -{"fbnge", one(0xF09C), one(0xF1BF), "IdBc"}, -{"fbngl", one(0xF099), one(0xF1BF), "IdBc"}, -{"fbngle", one(0xF098), one(0xF1BF), "IdBc"}, -{"fbngt", one(0xF09D), one(0xF1BF), "IdBc"}, -{"fbnle", one(0xF09A), one(0xF1BF), "IdBc"}, -{"fbnlt", one(0xF09B), one(0xF1BF), "IdBc"}, -{"fboge", one(0xF083), one(0xF1BF), "IdBc"}, -{"fbogl", one(0xF086), one(0xF1BF), "IdBc"}, -{"fbogt", one(0xF082), one(0xF1BF), "IdBc"}, -{"fbole", one(0xF085), one(0xF1BF), "IdBc"}, -{"fbolt", one(0xF084), one(0xF1BF), "IdBc"}, -{"fbor", one(0xF087), one(0xF1BF), "IdBc"}, -{"fbseq", one(0xF091), one(0xF1BF), "IdBc"}, -{"fbsf", one(0xF090), one(0xF1BF), "IdBc"}, -{"fbsne", one(0xF09E), one(0xF1BF), "IdBc"}, -{"fbst", one(0xF09F), one(0xF1BF), "IdBc"}, -{"fbt", one(0xF08F), one(0xF1BF), "IdBc"}, -{"fbueq", one(0xF089), one(0xF1BF), "IdBc"}, -{"fbuge", one(0xF08B), one(0xF1BF), "IdBc"}, -{"fbugt", one(0xF08A), one(0xF1BF), "IdBc"}, -{"fbule", one(0xF08D), one(0xF1BF), "IdBc"}, -{"fbult", one(0xF08C), one(0xF1BF), "IdBc"}, -{"fbun", one(0xF088), one(0xF1BF), "IdBc"}, - -{"fcmpb", two(0xF000, 0x5838), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fcmpd", two(0xF000, 0x5438), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fcmpl", two(0xF000, 0x4038), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fcmpp", two(0xF000, 0x4C38), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fcmps", two(0xF000, 0x4438), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fcmpw", two(0xF000, 0x5038), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fcmpx", two(0xF000, 0x0038), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fcmpx", two(0xF000, 0x4838), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -/* {"fcmpx", two(0xF000, 0x0038), two(0xF1C0, 0xE07F), "IiFt"}, JF removed */ - -{"fcosb", two(0xF000, 0x581D), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fcosd", two(0xF000, 0x541D), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fcosl", two(0xF000, 0x401D), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fcosp", two(0xF000, 0x4C1D), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fcoss", two(0xF000, 0x441D), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fcosw", two(0xF000, 0x501D), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fcosx", two(0xF000, 0x001D), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fcosx", two(0xF000, 0x481D), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fcosx", two(0xF000, 0x001D), two(0xF1C0, 0xE07F), "IiFt"}, - -{"fcoshb", two(0xF000, 0x5819), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fcoshd", two(0xF000, 0x5419), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fcoshl", two(0xF000, 0x4019), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fcoshp", two(0xF000, 0x4C19), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fcoshs", two(0xF000, 0x4419), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fcoshw", two(0xF000, 0x5019), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fcoshx", two(0xF000, 0x0019), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fcoshx", two(0xF000, 0x4819), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fcoshx", two(0xF000, 0x0019), two(0xF1C0, 0xE07F), "IiFt"}, - -{"fdbeq", two(0xF048, 0x0001), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbf", two(0xF048, 0x0000), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbge", two(0xF048, 0x0013), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbgl", two(0xF048, 0x0016), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbgle", two(0xF048, 0x0017), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbgt", two(0xF048, 0x0012), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdble", two(0xF048, 0x0015), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdblt", two(0xF048, 0x0014), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbne", two(0xF048, 0x000E), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbnge", two(0xF048, 0x001C), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbngl", two(0xF048, 0x0019), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbngle", two(0xF048, 0x0018), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbngt", two(0xF048, 0x001D), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbnle", two(0xF048, 0x001A), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbnlt", two(0xF048, 0x001B), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdboge", two(0xF048, 0x0003), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbogl", two(0xF048, 0x0006), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbogt", two(0xF048, 0x0002), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbole", two(0xF048, 0x0005), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbolt", two(0xF048, 0x0004), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbor", two(0xF048, 0x0007), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbseq", two(0xF048, 0x0011), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbsf", two(0xF048, 0x0010), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbsne", two(0xF048, 0x001E), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbst", two(0xF048, 0x001F), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbt", two(0xF048, 0x000F), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbueq", two(0xF048, 0x0009), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbuge", two(0xF048, 0x000B), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbugt", two(0xF048, 0x000A), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbule", two(0xF048, 0x000D), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbult", two(0xF048, 0x000C), two(0xF1F8, 0xFFFF), "IiDsBw"}, -{"fdbun", two(0xF048, 0x0008), two(0xF1F8, 0xFFFF), "IiDsBw"}, - -{"fdivb", two(0xF000, 0x5820), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fdivd", two(0xF000, 0x5420), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fdivl", two(0xF000, 0x4020), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fdivp", two(0xF000, 0x4C20), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fdivs", two(0xF000, 0x4420), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fdivw", two(0xF000, 0x5020), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fdivx", two(0xF000, 0x0020), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fdivx", two(0xF000, 0x4820), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -/* {"fdivx", two(0xF000, 0x0020), two(0xF1C0, 0xE07F), "IiFt"}, JF */ - -{"fetoxb", two(0xF000, 0x5810), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fetoxd", two(0xF000, 0x5410), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fetoxl", two(0xF000, 0x4010), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fetoxp", two(0xF000, 0x4C10), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fetoxs", two(0xF000, 0x4410), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fetoxw", two(0xF000, 0x5010), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fetoxx", two(0xF000, 0x0010), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fetoxx", two(0xF000, 0x4810), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fetoxx", two(0xF000, 0x0010), two(0xF1C0, 0xE07F), "IiFt"}, - -{"fetoxm1b", two(0xF000, 0x5808), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fetoxm1d", two(0xF000, 0x5408), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fetoxm1l", two(0xF000, 0x4008), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fetoxm1p", two(0xF000, 0x4C08), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fetoxm1s", two(0xF000, 0x4408), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fetoxm1w", two(0xF000, 0x5008), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fetoxm1x", two(0xF000, 0x0008), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fetoxm1x", two(0xF000, 0x4808), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fetoxm1x", two(0xF000, 0x0008), two(0xF1C0, 0xE07F), "IiFt"}, - -{"fgetexpb", two(0xF000, 0x581E), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fgetexpd", two(0xF000, 0x541E), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fgetexpl", two(0xF000, 0x401E), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fgetexpp", two(0xF000, 0x4C1E), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fgetexps", two(0xF000, 0x441E), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fgetexpw", two(0xF000, 0x501E), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fgetexpx", two(0xF000, 0x001E), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fgetexpx", two(0xF000, 0x481E), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fgetexpx", two(0xF000, 0x001E), two(0xF1C0, 0xE07F), "IiFt"}, - -{"fgetmanb", two(0xF000, 0x581F), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fgetmand", two(0xF000, 0x541F), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fgetmanl", two(0xF000, 0x401F), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fgetmanp", two(0xF000, 0x4C1F), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fgetmans", two(0xF000, 0x441F), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fgetmanw", two(0xF000, 0x501F), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fgetmanx", two(0xF000, 0x001F), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fgetmanx", two(0xF000, 0x481F), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fgetmanx", two(0xF000, 0x001F), two(0xF1C0, 0xE07F), "IiFt"}, - -{"fintb", two(0xF000, 0x5801), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fintd", two(0xF000, 0x5401), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fintl", two(0xF000, 0x4001), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fintp", two(0xF000, 0x4C01), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fints", two(0xF000, 0x4401), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fintw", two(0xF000, 0x5001), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fintx", two(0xF000, 0x0001), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fintx", two(0xF000, 0x4801), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fintx", two(0xF000, 0x0001), two(0xF1C0, 0xE07F), "IiFt"}, - -{"fintrzb", two(0xF000, 0x5803), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fintrzd", two(0xF000, 0x5403), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fintrzl", two(0xF000, 0x4003), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fintrzp", two(0xF000, 0x4C03), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fintrzs", two(0xF000, 0x4403), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fintrzw", two(0xF000, 0x5003), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fintrzx", two(0xF000, 0x0003), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fintrzx", two(0xF000, 0x4803), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fintrzx", two(0xF000, 0x0003), two(0xF1C0, 0xE07F), "IiFt"}, - -{"flog10b", two(0xF000, 0x5815), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"flog10d", two(0xF000, 0x5415), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"flog10l", two(0xF000, 0x4015), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"flog10p", two(0xF000, 0x4C15), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"flog10s", two(0xF000, 0x4415), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"flog10w", two(0xF000, 0x5015), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"flog10x", two(0xF000, 0x0015), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"flog10x", two(0xF000, 0x4815), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"flog10x", two(0xF000, 0x0015), two(0xF1C0, 0xE07F), "IiFt"}, - -{"flog2b", two(0xF000, 0x5816), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"flog2d", two(0xF000, 0x5416), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"flog2l", two(0xF000, 0x4016), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"flog2p", two(0xF000, 0x4C16), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"flog2s", two(0xF000, 0x4416), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"flog2w", two(0xF000, 0x5016), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"flog2x", two(0xF000, 0x0016), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"flog2x", two(0xF000, 0x4816), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"flog2x", two(0xF000, 0x0016), two(0xF1C0, 0xE07F), "IiFt"}, - -{"flognb", two(0xF000, 0x5814), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"flognd", two(0xF000, 0x5414), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"flognl", two(0xF000, 0x4014), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"flognp", two(0xF000, 0x4C14), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"flogns", two(0xF000, 0x4414), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"flognw", two(0xF000, 0x5014), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"flognx", two(0xF000, 0x0014), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"flognx", two(0xF000, 0x4814), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"flognx", two(0xF000, 0x0014), two(0xF1C0, 0xE07F), "IiFt"}, - -{"flognp1b", two(0xF000, 0x5806), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"flognp1d", two(0xF000, 0x5406), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"flognp1l", two(0xF000, 0x4006), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"flognp1p", two(0xF000, 0x4C06), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"flognp1s", two(0xF000, 0x4406), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"flognp1w", two(0xF000, 0x5006), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"flognp1x", two(0xF000, 0x0006), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"flognp1x", two(0xF000, 0x4806), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"flognp1x", two(0xF000, 0x0006), two(0xF1C0, 0xE07F), "IiFt"}, - -{"fmodb", two(0xF000, 0x5821), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fmodd", two(0xF000, 0x5421), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fmodl", two(0xF000, 0x4021), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fmodp", two(0xF000, 0x4C21), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fmods", two(0xF000, 0x4421), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fmodw", two(0xF000, 0x5021), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fmodx", two(0xF000, 0x0021), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fmodx", two(0xF000, 0x4821), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -/* {"fmodx", two(0xF000, 0x0021), two(0xF1C0, 0xE07F), "IiFt"}, JF */ - -{"fmoveb", two(0xF000, 0x5800), two(0xF1C0, 0xFC7F), "Ii;bF7"}, /* fmove from to fp */ -{"fmoveb", two(0xF000, 0x7800), two(0xF1C0, 0xFC7F), "IiF7@b"}, /* fmove from fp to */ -{"fmoved", two(0xF000, 0x5400), two(0xF1C0, 0xFC7F), "Ii;FF7"}, /* fmove from to fp */ -{"fmoved", two(0xF000, 0x7400), two(0xF1C0, 0xFC7F), "IiF7@F"}, /* fmove from fp to */ -{"fmovel", two(0xF000, 0x4000), two(0xF1C0, 0xFC7F), "Ii;lF7"}, /* fmove from to fp */ -{"fmovel", two(0xF000, 0x6000), two(0xF1C0, 0xFC7F), "IiF7@l"}, /* fmove from fp to */ -/* Warning: The addressing modes on these are probably not right: - esp, Areg direct is only allowed for FPI */ - /* fmove.l from/to system control registers: */ -{"fmovel", two(0xF000, 0xA000), two(0xF1C0, 0xE3FF), "Iis8@s"}, -{"fmovel", two(0xF000, 0x8000), two(0xF1C0, 0xE3FF), "Ii*ls8"}, - -/* {"fmovel", two(0xF000, 0xA000), two(0xF1C0, 0xE3FF), "Iis8@s"}, -{"fmovel", two(0xF000, 0x8000), two(0xF2C0, 0xE3FF), "Ii*ss8"}, */ - -{"fmovep", two(0xF000, 0x4C00), two(0xF1C0, 0xFC7F), "Ii;pF7"}, /* fmove from to fp */ -{"fmovep", two(0xF000, 0x6C00), two(0xF1C0, 0xFC00), "IiF7@pkC"}, /* fmove.p with k-factors: */ -{"fmovep", two(0xF000, 0x7C00), two(0xF1C0, 0xFC0F), "IiF7@pDk"}, /* fmove.p with k-factors: */ - -{"fmoves", two(0xF000, 0x4400), two(0xF1C0, 0xFC7F), "Ii;fF7"}, /* fmove from to fp */ -{"fmoves", two(0xF000, 0x6400), two(0xF1C0, 0xFC7F), "IiF7@f"}, /* fmove from fp to */ -{"fmovew", two(0xF000, 0x5000), two(0xF1C0, 0xFC7F), "Ii;wF7"}, /* fmove from to fp */ -{"fmovew", two(0xF000, 0x7000), two(0xF1C0, 0xFC7F), "IiF7@w"}, /* fmove from fp to */ -{"fmovex", two(0xF000, 0x0000), two(0xF1C0, 0xE07F), "IiF8F7"}, /* fmove from to fp */ -{"fmovex", two(0xF000, 0x4800), two(0xF1C0, 0xFC7F), "Ii;xF7"}, /* fmove from to fp */ -{"fmovex", two(0xF000, 0x6800), two(0xF1C0, 0xFC7F), "IiF7@x"}, /* fmove from fp to */ -/* JF removed {"fmovex", two(0xF000, 0x0000), two(0xF1C0, 0xE07F), "IiFt"}, / * fmove from to fp */ - -{"fmovecrx", two(0xF000, 0x5C00), two(0xF1FF, 0xFC00), "Ii#CF7"}, /* fmovecr.x #ccc, FPn */ -{"fmovecr", two(0xF000, 0x5C00), two(0xF1FF, 0xFC00), "Ii#CF7"}, - -/* Other fmovemx. */ -{"fmovemx", two(0xF020, 0xE000), two(0xF1F8, 0xFF00), "IdL3-s"}, /* fmovem.x to autodecrement, static and dynamic */ -{"fmovemx", two(0xF020, 0xE000), two(0xF1F8, 0xFF00), "Id#3-s"}, /* fmovem.x to autodecrement, static and dynamic */ - -{"fmovemx", two(0xF020, 0xE800), two(0xF1F8, 0xFF8F), "IiDk-s"}, /* fmovem.x to autodecrement, static and dynamic */ - -{"fmovemx", two(0xF000, 0xF000), two(0xF1C0, 0xFF00), "Id#3&s"}, /* fmovem.x to control, static and dynamic: */ -{"fmovemx", two(0xF000, 0xF800), two(0xF1C0, 0xFF8F), "IiDk&s"}, /* fmovem.x to control, static and dynamic: */ -{"fmovemx", two(0xF000, 0xD000), two(0xF1C0, 0xFF00), "Id&s#3"}, /* fmovem.x from control, static and dynamic: */ -{"fmovemx", two(0xF000, 0xD800), two(0xF1C0, 0xFF8F), "Ii&sDk"}, /* fmovem.x from control, static and dynamic: */ -{"fmovemx", two(0xF000, 0xF000), two(0xF1C0, 0xFF00), "Idl3&s"}, /* fmovem.x to control, static and dynamic: */ -{"fmovemx", two(0xF000, 0xD000), two(0xF1C0, 0xFF00), "Id&sl3"}, /* fmovem.x from control, static and dynamic: */ - -{"fmovemx", two(0xF018, 0xD000), two(0xF1F8, 0xFF00), "Id+sl3"}, /* fmovem.x from autoincrement, static and dynamic: */ -{"fmovemx", two(0xF018, 0xD000), two(0xF1F8, 0xFF00), "Id+s#3"}, /* fmovem.x from autoincrement, static and dynamic: */ -{"fmovemx", two(0xF018, 0xD800), two(0xF1F8, 0xFF8F), "Ii+sDk"}, /* fmovem.x from autoincrement, static and dynamic: */ - -{"fmoveml", two(0xF000, 0xA000), two(0xF1C0, 0xE3FF), "IiL8@s"}, -{"fmoveml", two(0xF000, 0xA000), two(0xF1C0, 0xE3FF), "Ii#8@s"}, -{"fmoveml", two(0xF000, 0xA000), two(0xF1C0, 0xE3FF), "Iis8@s"}, - -{"fmoveml", two(0xF000, 0x8000), two(0xF2C0, 0xE3FF), "Ii*sL8"}, -{"fmoveml", two(0xF000, 0x8000), two(0xF1C0, 0xE3FF), "Ii*s#8"}, -{"fmoveml", two(0xF000, 0x8000), two(0xF1C0, 0xE3FF), "Ii*ss8"}, - -/* fmovemx with register lists */ -{"fmovem", two(0xF020, 0xE000), two(0xF1F8, 0xFF00), "IdL3-s"}, /* fmovem.x to autodecrement, static and dynamic */ -{"fmovem", two(0xF000, 0xF000), two(0xF1C0, 0xFF00), "Idl3&s"}, /* fmovem.x to control, static and dynamic: */ -{"fmovem", two(0xF018, 0xD000), two(0xF1F8, 0xFF00), "Id+sl3"}, /* fmovem.x from autoincrement, static and dynamic: */ -{"fmovem", two(0xF000, 0xD000), two(0xF1C0, 0xFF00), "Id&sl3"}, /* fmovem.x from control, static and dynamic: */ - - /* Alternate mnemonics for GNU as and GNU CC */ -{"fmovem", two(0xF020, 0xE000), two(0xF1F8, 0xFF00), "Id#3-s"}, /* fmovem.x to autodecrement, static and dynamic */ -{"fmovem", two(0xF020, 0xE800), two(0xF1F8, 0xFF8F), "IiDk-s"}, /* fmovem.x to autodecrement, static and dynamic */ - -{"fmovem", two(0xF000, 0xF000), two(0xF1C0, 0xFF00), "Id#3&s"}, /* fmovem.x to control, static and dynamic: */ -{"fmovem", two(0xF000, 0xF800), two(0xF1C0, 0xFF8F), "IiDk&s"}, /* fmovem.x to control, static and dynamic: */ - -{"fmovem", two(0xF018, 0xD000), two(0xF1F8, 0xFF00), "Id+s#3"}, /* fmovem.x from autoincrement, static and dynamic: */ -{"fmovem", two(0xF018, 0xD800), two(0xF1F8, 0xFF8F), "Ii+sDk"}, /* fmovem.x from autoincrement, static and dynamic: */ - -{"fmovem", two(0xF000, 0xD000), two(0xF1C0, 0xFF00), "Id&s#3"}, /* fmovem.x from control, static and dynamic: */ -{"fmovem", two(0xF000, 0xD800), two(0xF1C0, 0xFF8F), "Ii&sDk"}, /* fmovem.x from control, static and dynamic: */ - -/* fmoveml a FP-control register */ -{"fmovem", two(0xF000, 0xA000), two(0xF1C0, 0xE3FF), "Iis8@s"}, -{"fmovem", two(0xF000, 0x8000), two(0xF1C0, 0xE3FF), "Ii*ss8"}, - -/* fmoveml a FP-control reglist */ -{"fmovem", two(0xF000, 0xA000), two(0xF1C0, 0xE3FF), "IiL8@s"}, -{"fmovem", two(0xF000, 0x8000), two(0xF2C0, 0xE3FF), "Ii*sL8"}, - -{"fmulb", two(0xF000, 0x5823), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fmuld", two(0xF000, 0x5423), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fmull", two(0xF000, 0x4023), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fmulp", two(0xF000, 0x4C23), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fmuls", two(0xF000, 0x4423), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fmulw", two(0xF000, 0x5023), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fmulx", two(0xF000, 0x0023), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fmulx", two(0xF000, 0x4823), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -/* {"fmulx", two(0xF000, 0x0023), two(0xF1C0, 0xE07F), "IiFt"}, JF */ - -{"fnegb", two(0xF000, 0x581A), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fnegd", two(0xF000, 0x541A), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fnegl", two(0xF000, 0x401A), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fnegp", two(0xF000, 0x4C1A), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fnegs", two(0xF000, 0x441A), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fnegw", two(0xF000, 0x501A), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fnegx", two(0xF000, 0x001A), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fnegx", two(0xF000, 0x481A), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fnegx", two(0xF000, 0x001A), two(0xF1C0, 0xE07F), "IiFt"}, - -{"fnop", two(0xF280, 0x0000), two(0xFFFF, 0xFFFF), "Ii"}, - -{"fremb", two(0xF000, 0x5825), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fremd", two(0xF000, 0x5425), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"freml", two(0xF000, 0x4025), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fremp", two(0xF000, 0x4C25), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"frems", two(0xF000, 0x4425), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fremw", two(0xF000, 0x5025), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fremx", two(0xF000, 0x0025), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fremx", two(0xF000, 0x4825), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -/* {"fremx", two(0xF000, 0x0025), two(0xF1C0, 0xE07F), "IiFt"}, JF */ - -{"frestore", one(0xF140), one(0xF1C0), "Id&s"}, -{"frestore", one(0xF158), one(0xF1F8), "Id+s"}, -{"fsave", one(0xF100), one(0xF1C0), "Id&s"}, -{"fsave", one(0xF120), one(0xF1F8), "Id-s"}, - -{"fsincosb", two(0xF000, 0x5830), two(0xF1C0, 0xFC78), "Ii;bF7FC"}, -{"fsincosd", two(0xF000, 0x5430), two(0xF1C0, 0xFC78), "Ii;FF7FC"}, -{"fsincosl", two(0xF000, 0x4030), two(0xF1C0, 0xFC78), "Ii;lF7FC"}, -{"fsincosp", two(0xF000, 0x4C30), two(0xF1C0, 0xFC78), "Ii;pF7FC"}, -{"fsincoss", two(0xF000, 0x4430), two(0xF1C0, 0xFC78), "Ii;fF7FC"}, -{"fsincosw", two(0xF000, 0x5030), two(0xF1C0, 0xFC78), "Ii;wF7FC"}, -{"fsincosx", two(0xF000, 0x0030), two(0xF1C0, 0xE078), "IiF8F7FC"}, -{"fsincosx", two(0xF000, 0x4830), two(0xF1C0, 0xFC78), "Ii;xF7FC"}, - -{"fscaleb", two(0xF000, 0x5826), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fscaled", two(0xF000, 0x5426), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fscalel", two(0xF000, 0x4026), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fscalep", two(0xF000, 0x4C26), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fscales", two(0xF000, 0x4426), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fscalew", two(0xF000, 0x5026), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fscalex", two(0xF000, 0x0026), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fscalex", two(0xF000, 0x4826), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -/* {"fscalex", two(0xF000, 0x0026), two(0xF1C0, 0xE07F), "IiFt"}, JF */ - -/* $ is necessary to prevent the assembler from using PC-relative. - If @ were used, "label: fseq label" could produce "ftrapeq", - because "label" became "pc@label". */ -{"fseq", two(0xF040, 0x0001), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsf", two(0xF040, 0x0000), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsge", two(0xF040, 0x0013), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsgl", two(0xF040, 0x0016), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsgle", two(0xF040, 0x0017), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsgt", two(0xF040, 0x0012), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsle", two(0xF040, 0x0015), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fslt", two(0xF040, 0x0014), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsne", two(0xF040, 0x000E), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsnge", two(0xF040, 0x001C), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsngl", two(0xF040, 0x0019), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsngle", two(0xF040, 0x0018), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsngt", two(0xF040, 0x001D), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsnle", two(0xF040, 0x001A), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsnlt", two(0xF040, 0x001B), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsoge", two(0xF040, 0x0003), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsogl", two(0xF040, 0x0006), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsogt", two(0xF040, 0x0002), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsole", two(0xF040, 0x0005), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsolt", two(0xF040, 0x0004), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsor", two(0xF040, 0x0007), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsseq", two(0xF040, 0x0011), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fssf", two(0xF040, 0x0010), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fssne", two(0xF040, 0x001E), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsst", two(0xF040, 0x001F), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fst", two(0xF040, 0x000F), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsueq", two(0xF040, 0x0009), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsuge", two(0xF040, 0x000B), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsugt", two(0xF040, 0x000A), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsule", two(0xF040, 0x000D), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsult", two(0xF040, 0x000C), two(0xF1C0, 0xFFFF), "Ii$s"}, -{"fsun", two(0xF040, 0x0008), two(0xF1C0, 0xFFFF), "Ii$s"}, - -{"fsgldivb", two(0xF000, 0x5824), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fsgldivd", two(0xF000, 0x5424), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fsgldivl", two(0xF000, 0x4024), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fsgldivp", two(0xF000, 0x4C24), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fsgldivs", two(0xF000, 0x4424), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fsgldivw", two(0xF000, 0x5024), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fsgldivx", two(0xF000, 0x0024), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fsgldivx", two(0xF000, 0x4824), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fsgldivx", two(0xF000, 0x0024), two(0xF1C0, 0xE07F), "IiFt"}, - -{"fsglmulb", two(0xF000, 0x5827), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fsglmuld", two(0xF000, 0x5427), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fsglmull", two(0xF000, 0x4027), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fsglmulp", two(0xF000, 0x4C27), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fsglmuls", two(0xF000, 0x4427), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fsglmulw", two(0xF000, 0x5027), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fsglmulx", two(0xF000, 0x0027), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fsglmulx", two(0xF000, 0x4827), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fsglmulx", two(0xF000, 0x0027), two(0xF1C0, 0xE07F), "IiFt"}, - -{"fsinb", two(0xF000, 0x580E), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fsind", two(0xF000, 0x540E), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fsinl", two(0xF000, 0x400E), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fsinp", two(0xF000, 0x4C0E), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fsins", two(0xF000, 0x440E), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fsinw", two(0xF000, 0x500E), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fsinx", two(0xF000, 0x000E), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fsinx", two(0xF000, 0x480E), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fsinx", two(0xF000, 0x000E), two(0xF1C0, 0xE07F), "IiFt"}, - -{"fsinhb", two(0xF000, 0x5802), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fsinhd", two(0xF000, 0x5402), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fsinhl", two(0xF000, 0x4002), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fsinhp", two(0xF000, 0x4C02), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fsinhs", two(0xF000, 0x4402), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fsinhw", two(0xF000, 0x5002), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fsinhx", two(0xF000, 0x0002), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fsinhx", two(0xF000, 0x4802), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fsinhx", two(0xF000, 0x0002), two(0xF1C0, 0xE07F), "IiFt"}, - -{"fsqrtb", two(0xF000, 0x5804), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fsqrtd", two(0xF000, 0x5404), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fsqrtl", two(0xF000, 0x4004), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fsqrtp", two(0xF000, 0x4C04), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fsqrts", two(0xF000, 0x4404), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fsqrtw", two(0xF000, 0x5004), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fsqrtx", two(0xF000, 0x0004), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fsqrtx", two(0xF000, 0x4804), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fsqrtx", two(0xF000, 0x0004), two(0xF1C0, 0xE07F), "IiFt"}, - -{"fsubb", two(0xF000, 0x5828), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"fsubd", two(0xF000, 0x5428), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"fsubl", two(0xF000, 0x4028), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"fsubp", two(0xF000, 0x4C28), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"fsubs", two(0xF000, 0x4428), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"fsubw", two(0xF000, 0x5028), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"fsubx", two(0xF000, 0x0028), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"fsubx", two(0xF000, 0x4828), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"fsubx", two(0xF000, 0x0028), two(0xF1C0, 0xE07F), "IiFt"}, - -{"ftanb", two(0xF000, 0x580F), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"ftand", two(0xF000, 0x540F), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"ftanl", two(0xF000, 0x400F), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"ftanp", two(0xF000, 0x4C0F), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"ftans", two(0xF000, 0x440F), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"ftanw", two(0xF000, 0x500F), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"ftanx", two(0xF000, 0x000F), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"ftanx", two(0xF000, 0x480F), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"ftanx", two(0xF000, 0x000F), two(0xF1C0, 0xE07F), "IiFt"}, - -{"ftanhb", two(0xF000, 0x5809), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"ftanhd", two(0xF000, 0x5409), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"ftanhl", two(0xF000, 0x4009), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"ftanhp", two(0xF000, 0x4C09), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"ftanhs", two(0xF000, 0x4409), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"ftanhw", two(0xF000, 0x5009), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"ftanhx", two(0xF000, 0x0009), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"ftanhx", two(0xF000, 0x4809), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"ftanhx", two(0xF000, 0x0009), two(0xF1C0, 0xE07F), "IiFt"}, - -{"ftentoxb", two(0xF000, 0x5812), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"ftentoxd", two(0xF000, 0x5412), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"ftentoxl", two(0xF000, 0x4012), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"ftentoxp", two(0xF000, 0x4C12), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"ftentoxs", two(0xF000, 0x4412), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"ftentoxw", two(0xF000, 0x5012), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"ftentoxx", two(0xF000, 0x0012), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"ftentoxx", two(0xF000, 0x4812), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"ftentoxx", two(0xF000, 0x0012), two(0xF1C0, 0xE07F), "IiFt"}, - -{"ftrapeq", two(0xF07C, 0x0001), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapf", two(0xF07C, 0x0000), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapge", two(0xF07C, 0x0013), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapgl", two(0xF07C, 0x0016), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapgle", two(0xF07C, 0x0017), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapgt", two(0xF07C, 0x0012), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftraple", two(0xF07C, 0x0015), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftraplt", two(0xF07C, 0x0014), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapne", two(0xF07C, 0x000E), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapnge", two(0xF07C, 0x001C), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapngl", two(0xF07C, 0x0019), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapngle", two(0xF07C, 0x0018), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapngt", two(0xF07C, 0x001D), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapnle", two(0xF07C, 0x001A), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapnlt", two(0xF07C, 0x001B), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapoge", two(0xF07C, 0x0003), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapogl", two(0xF07C, 0x0006), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapogt", two(0xF07C, 0x0002), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapole", two(0xF07C, 0x0005), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapolt", two(0xF07C, 0x0004), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapor", two(0xF07C, 0x0007), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapseq", two(0xF07C, 0x0011), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapsf", two(0xF07C, 0x0010), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapsne", two(0xF07C, 0x001E), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapst", two(0xF07C, 0x001F), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapt", two(0xF07C, 0x000F), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapueq", two(0xF07C, 0x0009), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapuge", two(0xF07C, 0x000B), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapugt", two(0xF07C, 0x000A), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapule", two(0xF07C, 0x000D), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapult", two(0xF07C, 0x000C), two(0xF1FF, 0xFFFF), "Ii"}, -{"ftrapun", two(0xF07C, 0x0008), two(0xF1FF, 0xFFFF), "Ii"}, - -{"ftrapeqw", two(0xF07A, 0x0001), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapfw", two(0xF07A, 0x0000), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapgew", two(0xF07A, 0x0013), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapglw", two(0xF07A, 0x0016), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapglew", two(0xF07A, 0x0017), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapgtw", two(0xF07A, 0x0012), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftraplew", two(0xF07A, 0x0015), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapltw", two(0xF07A, 0x0014), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapnew", two(0xF07A, 0x000E), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapngew", two(0xF07A, 0x001C), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapnglw", two(0xF07A, 0x0019), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapnglew", two(0xF07A, 0x0018), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapngtw", two(0xF07A, 0x001D), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapnlew", two(0xF07A, 0x001A), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapnltw", two(0xF07A, 0x001B), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapogew", two(0xF07A, 0x0003), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapoglw", two(0xF07A, 0x0006), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapogtw", two(0xF07A, 0x0002), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapolew", two(0xF07A, 0x0005), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapoltw", two(0xF07A, 0x0004), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftraporw", two(0xF07A, 0x0007), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapseqw", two(0xF07A, 0x0011), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapsfw", two(0xF07A, 0x0010), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapsnew", two(0xF07A, 0x001E), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapstw", two(0xF07A, 0x001F), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftraptw", two(0xF07A, 0x000F), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapueqw", two(0xF07A, 0x0009), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapugew", two(0xF07A, 0x000B), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapugtw", two(0xF07A, 0x000A), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapulew", two(0xF07A, 0x000D), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapultw", two(0xF07A, 0x000C), two(0xF1FF, 0xFFFF), "Ii^w"}, -{"ftrapunw", two(0xF07A, 0x0008), two(0xF1FF, 0xFFFF), "Ii^w"}, - -{"ftrapeql", two(0xF07B, 0x0001), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapfl", two(0xF07B, 0x0000), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapgel", two(0xF07B, 0x0013), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapgll", two(0xF07B, 0x0016), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapglel", two(0xF07B, 0x0017), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapgtl", two(0xF07B, 0x0012), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftraplel", two(0xF07B, 0x0015), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapltl", two(0xF07B, 0x0014), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapnel", two(0xF07B, 0x000E), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapngel", two(0xF07B, 0x001C), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapngll", two(0xF07B, 0x0019), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapnglel", two(0xF07B, 0x0018), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapngtl", two(0xF07B, 0x001D), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapnlel", two(0xF07B, 0x001A), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapnltl", two(0xF07B, 0x001B), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapogel", two(0xF07B, 0x0003), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapogll", two(0xF07B, 0x0006), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapogtl", two(0xF07B, 0x0002), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapolel", two(0xF07B, 0x0005), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapoltl", two(0xF07B, 0x0004), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftraporl", two(0xF07B, 0x0007), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapseql", two(0xF07B, 0x0011), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapsfl", two(0xF07B, 0x0010), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapsnel", two(0xF07B, 0x001E), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapstl", two(0xF07B, 0x001F), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftraptl", two(0xF07B, 0x000F), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapueql", two(0xF07B, 0x0009), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapugel", two(0xF07B, 0x000B), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapugtl", two(0xF07B, 0x000A), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapulel", two(0xF07B, 0x000D), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapultl", two(0xF07B, 0x000C), two(0xF1FF, 0xFFFF), "Ii^l"}, -{"ftrapunl", two(0xF07B, 0x0008), two(0xF1FF, 0xFFFF), "Ii^l"}, - -{"ftstb", two(0xF000, 0x583A), two(0xF1C0, 0xFC7F), "Ii;b"}, -{"ftstd", two(0xF000, 0x543A), two(0xF1C0, 0xFC7F), "Ii;F"}, -{"ftstl", two(0xF000, 0x403A), two(0xF1C0, 0xFC7F), "Ii;l"}, -{"ftstp", two(0xF000, 0x4C3A), two(0xF1C0, 0xFC7F), "Ii;p"}, -{"ftsts", two(0xF000, 0x443A), two(0xF1C0, 0xFC7F), "Ii;f"}, -{"ftstw", two(0xF000, 0x503A), two(0xF1C0, 0xFC7F), "Ii;w"}, -{"ftstx", two(0xF000, 0x003A), two(0xF1C0, 0xE07F), "IiF8"}, -{"ftstx", two(0xF000, 0x483A), two(0xF1C0, 0xFC7F), "Ii;x"}, - -{"ftwotoxb", two(0xF000, 0x5811), two(0xF1C0, 0xFC7F), "Ii;bF7"}, -{"ftwotoxd", two(0xF000, 0x5411), two(0xF1C0, 0xFC7F), "Ii;FF7"}, -{"ftwotoxl", two(0xF000, 0x4011), two(0xF1C0, 0xFC7F), "Ii;lF7"}, -{"ftwotoxp", two(0xF000, 0x4C11), two(0xF1C0, 0xFC7F), "Ii;pF7"}, -{"ftwotoxs", two(0xF000, 0x4411), two(0xF1C0, 0xFC7F), "Ii;fF7"}, -{"ftwotoxw", two(0xF000, 0x5011), two(0xF1C0, 0xFC7F), "Ii;wF7"}, -{"ftwotoxx", two(0xF000, 0x0011), two(0xF1C0, 0xE07F), "IiF8F7"}, -{"ftwotoxx", two(0xF000, 0x4811), two(0xF1C0, 0xFC7F), "Ii;xF7"}, -{"ftwotoxx", two(0xF000, 0x0011), two(0xF1C0, 0xE07F), "IiFt"}, - - -{"fjeq", one(0xF081), one(0xF1FF), "IdBc"}, -{"fjf", one(0xF080), one(0xF1FF), "IdBc"}, -{"fjge", one(0xF093), one(0xF1FF), "IdBc"}, -{"fjgl", one(0xF096), one(0xF1FF), "IdBc"}, -{"fjgle", one(0xF097), one(0xF1FF), "IdBc"}, -{"fjgt", one(0xF092), one(0xF1FF), "IdBc"}, -{"fjle", one(0xF095), one(0xF1FF), "IdBc"}, -{"fjlt", one(0xF094), one(0xF1FF), "IdBc"}, -{"fjne", one(0xF08E), one(0xF1FF), "IdBc"}, -{"fjnge", one(0xF09C), one(0xF1FF), "IdBc"}, -{"fjngl", one(0xF099), one(0xF1FF), "IdBc"}, -{"fjngle", one(0xF098), one(0xF1FF), "IdBc"}, -{"fjngt", one(0xF09D), one(0xF1FF), "IdBc"}, -{"fjnle", one(0xF09A), one(0xF1FF), "IdBc"}, -{"fjnlt", one(0xF09B), one(0xF1FF), "IdBc"}, -{"fjoge", one(0xF083), one(0xF1FF), "IdBc"}, -{"fjogl", one(0xF086), one(0xF1FF), "IdBc"}, -{"fjogt", one(0xF082), one(0xF1FF), "IdBc"}, -{"fjole", one(0xF085), one(0xF1FF), "IdBc"}, -{"fjolt", one(0xF084), one(0xF1FF), "IdBc"}, -{"fjor", one(0xF087), one(0xF1FF), "IdBc"}, -{"fjseq", one(0xF091), one(0xF1FF), "IdBc"}, -{"fjsf", one(0xF090), one(0xF1FF), "IdBc"}, -{"fjsne", one(0xF09E), one(0xF1FF), "IdBc"}, -{"fjst", one(0xF09F), one(0xF1FF), "IdBc"}, -{"fjt", one(0xF08F), one(0xF1FF), "IdBc"}, -{"fjueq", one(0xF089), one(0xF1FF), "IdBc"}, -{"fjuge", one(0xF08B), one(0xF1FF), "IdBc"}, -{"fjugt", one(0xF08A), one(0xF1FF), "IdBc"}, -{"fjule", one(0xF08D), one(0xF1FF), "IdBc"}, -{"fjult", one(0xF08C), one(0xF1FF), "IdBc"}, -{"fjun", one(0xF088), one(0xF1FF), "IdBc"}, - -/* The assembler will ignore attempts to force a short offset */ - -{"bhis", one(0061000), one(0177400), "Bg"}, -{"blss", one(0061400), one(0177400), "Bg"}, -{"bccs", one(0062000), one(0177400), "Bg"}, -{"bcss", one(0062400), one(0177400), "Bg"}, -{"bnes", one(0063000), one(0177400), "Bg"}, -{"beqs", one(0063400), one(0177400), "Bg"}, -{"bvcs", one(0064000), one(0177400), "Bg"}, -{"bvss", one(0064400), one(0177400), "Bg"}, -{"bpls", one(0065000), one(0177400), "Bg"}, -{"bmis", one(0065400), one(0177400), "Bg"}, -{"bges", one(0066000), one(0177400), "Bg"}, -{"blts", one(0066400), one(0177400), "Bg"}, -{"bgts", one(0067000), one(0177400), "Bg"}, -{"bles", one(0067400), one(0177400), "Bg"}, - -/* Alternate mnemonics for SUN */ - -{"jbsr", one(0060400), one(0177400), "Bg"}, -{"jbsr", one(0047200), one(0177700), "!s"}, -{"jra", one(0060000), one(0177400), "Bg"}, -{"jra", one(0047300), one(0177700), "!s"}, - -{"jhi", one(0061000), one(0177400), "Bg"}, -{"jls", one(0061400), one(0177400), "Bg"}, -{"jcc", one(0062000), one(0177400), "Bg"}, -{"jcs", one(0062400), one(0177400), "Bg"}, -{"jne", one(0063000), one(0177400), "Bg"}, -{"jeq", one(0063400), one(0177400), "Bg"}, -{"jvc", one(0064000), one(0177400), "Bg"}, -{"jvs", one(0064400), one(0177400), "Bg"}, -{"jpl", one(0065000), one(0177400), "Bg"}, -{"jmi", one(0065400), one(0177400), "Bg"}, -{"jge", one(0066000), one(0177400), "Bg"}, -{"jlt", one(0066400), one(0177400), "Bg"}, -{"jgt", one(0067000), one(0177400), "Bg"}, -{"jle", one(0067400), one(0177400), "Bg"}, - -/* Short offsets are ignored */ - -{"jbsrs", one(0060400), one(0177400), "Bg"}, -{"jras", one(0060000), one(0177400), "Bg"}, -{"jhis", one(0061000), one(0177400), "Bg"}, -{"jlss", one(0061400), one(0177400), "Bg"}, -{"jccs", one(0062000), one(0177400), "Bg"}, -{"jcss", one(0062400), one(0177400), "Bg"}, -{"jnes", one(0063000), one(0177400), "Bg"}, -{"jeqs", one(0063400), one(0177400), "Bg"}, -{"jvcs", one(0064000), one(0177400), "Bg"}, -{"jvss", one(0064400), one(0177400), "Bg"}, -{"jpls", one(0065000), one(0177400), "Bg"}, -{"jmis", one(0065400), one(0177400), "Bg"}, -{"jges", one(0066000), one(0177400), "Bg"}, -{"jlts", one(0066400), one(0177400), "Bg"}, -{"jgts", one(0067000), one(0177400), "Bg"}, -{"jles", one(0067400), one(0177400), "Bg"}, - -{"movql", one(0070000), one(0170400), "MsDd"}, -{"moveql", one(0070000), one(0170400), "MsDd"}, -{"moval", one(0020100), one(0170700), "*lAd"}, -{"movaw", one(0030100), one(0170700), "*wAd"}, -{"movb", one(0010000), one(0170000), ";b$d"}, /* mov */ -{"movl", one(0070000), one(0170400), "MsDd"}, /* movq written as mov */ -{"movl", one(0020000), one(0170000), "*l$d"}, -{"movl", one(0020100), one(0170700), "*lAd"}, -{"movl", one(0047140), one(0177770), "AsUd"}, /* mov to USP */ -{"movl", one(0047150), one(0177770), "UdAs"}, /* mov from USP */ -{"movc", one(0047173), one(0177777), "R1Jj"}, -{"movc", one(0047173), one(0177777), "R1#j"}, -{"movc", one(0047172), one(0177777), "JjR1"}, -{"movc", one(0047172), one(0177777), "#jR1"}, -{"movml", one(0044300), one(0177700), "#w&s"}, /* movm reg to mem. */ -{"movml", one(0044340), one(0177770), "#w-s"}, /* movm reg to autodecrement. */ -{"movml", one(0046300), one(0177700), "!s#w"}, /* movm mem to reg. */ -{"movml", one(0046330), one(0177770), "+s#w"}, /* movm autoinc to reg. */ -{"movml", one(0044300), one(0177700), "Lw&s"}, /* movm reg to mem. */ -{"movml", one(0044340), one(0177770), "lw-s"}, /* movm reg to autodecrement. */ -{"movml", one(0046300), one(0177700), "!sLw"}, /* movm mem to reg. */ -{"movml", one(0046330), one(0177770), "+sLw"}, /* movm autoinc to reg. */ -{"movmw", one(0044200), one(0177700), "#w&s"}, /* movm reg to mem. */ -{"movmw", one(0044240), one(0177770), "#w-s"}, /* movm reg to autodecrement. */ -{"movmw", one(0046200), one(0177700), "!s#w"}, /* movm mem to reg. */ -{"movmw", one(0046230), one(0177770), "+s#w"}, /* movm autoinc to reg. */ -{"movmw", one(0044200), one(0177700), "Lw&s"}, /* movm reg to mem. */ -{"movmw", one(0044240), one(0177770), "lw-s"}, /* movm reg to autodecrement. */ -{"movmw", one(0046200), one(0177700), "!sLw"}, /* movm mem to reg. */ -{"movmw", one(0046230), one(0177770), "+sLw"}, /* movm autoinc to reg. */ -{"movpl", one(0000510), one(0170770), "dsDd"}, /* memory to register */ -{"movpl", one(0000710), one(0170770), "Ddds"}, /* register to memory */ -{"movpw", one(0000410), one(0170770), "dsDd"}, /* memory to register */ -{"movpw", one(0000610), one(0170770), "Ddds"}, /* register to memory */ -{"movq", one(0070000), one(0170400), "MsDd"}, -{"movw", one(0030000), one(0170000), "*w$d"}, -{"movw", one(0030100), one(0170700), "*wAd"}, /* mova, written as mov */ -{"movw", one(0040300), one(0177700), "Ss$s"}, /* Move from sr */ -{"movw", one(0041300), one(0177700), "Cs$s"}, /* Move from ccr */ -{"movw", one(0042300), one(0177700), ";wCd"}, /* mov to ccr */ -{"movw", one(0043300), one(0177700), ";wSd"}, /* mov to sr */ - -{"movsb", two(0007000, 0), two(0177700, 07777), "~sR1"}, -{"movsb", two(0007000, 04000), two(0177700, 07777), "R1~s"}, -{"movsl", two(0007200, 0), two(0177700, 07777), "~sR1"}, -{"movsl", two(0007200, 04000), two(0177700, 07777), "R1~s"}, -{"movsw", two(0007100, 0), two(0177700, 07777), "~sR1"}, -{"movsw", two(0007100, 04000), two(0177700, 07777), "R1~s"}, - -#ifdef m68851 - /* name */ /* opcode */ /* match */ /* args */ - -{"pbac", one(0xf0c7), one(0xffbf), "Bc"}, -{"pbacw", one(0xf087), one(0xffbf), "Bc"}, -{"pbas", one(0xf0c6), one(0xffbf), "Bc"}, -{"pbasw", one(0xf086), one(0xffbf), "Bc"}, -{"pbbc", one(0xf0c1), one(0xffbf), "Bc"}, -{"pbbcw", one(0xf081), one(0xffbf), "Bc"}, -{"pbbs", one(0xf0c0), one(0xffbf), "Bc"}, -{"pbbsw", one(0xf080), one(0xffbf), "Bc"}, -{"pbcc", one(0xf0cf), one(0xffbf), "Bc"}, -{"pbccw", one(0xf08f), one(0xffbf), "Bc"}, -{"pbcs", one(0xf0ce), one(0xffbf), "Bc"}, -{"pbcsw", one(0xf08e), one(0xffbf), "Bc"}, -{"pbgc", one(0xf0cd), one(0xffbf), "Bc"}, -{"pbgcw", one(0xf08d), one(0xffbf), "Bc"}, -{"pbgs", one(0xf0cc), one(0xffbf), "Bc"}, -{"pbgsw", one(0xf08c), one(0xffbf), "Bc"}, -{"pbic", one(0xf0cb), one(0xffbf), "Bc"}, -{"pbicw", one(0xf08b), one(0xffbf), "Bc"}, -{"pbis", one(0xf0ca), one(0xffbf), "Bc"}, -{"pbisw", one(0xf08a), one(0xffbf), "Bc"}, -{"pblc", one(0xf0c3), one(0xffbf), "Bc"}, -{"pblcw", one(0xf083), one(0xffbf), "Bc"}, -{"pbls", one(0xf0c2), one(0xffbf), "Bc"}, -{"pblsw", one(0xf082), one(0xffbf), "Bc"}, -{"pbsc", one(0xf0c5), one(0xffbf), "Bc"}, -{"pbscw", one(0xf085), one(0xffbf), "Bc"}, -{"pbss", one(0xf0c4), one(0xffbf), "Bc"}, -{"pbssw", one(0xf084), one(0xffbf), "Bc"}, -{"pbwc", one(0xf0c9), one(0xffbf), "Bc"}, -{"pbwcw", one(0xf089), one(0xffbf), "Bc"}, -{"pbws", one(0xf0c8), one(0xffbf), "Bc"}, -{"pbwsw", one(0xf088), one(0xffbf), "Bc"}, - - -{"pdbac", two(0xf048, 0x0007), two(0xfff8, 0xffff), "DsBw"}, -{"pdbas", two(0xf048, 0x0006), two(0xfff8, 0xffff), "DsBw"}, -{"pdbbc", two(0xf048, 0x0001), two(0xfff8, 0xffff), "DsBw"}, -{"pdbbs", two(0xf048, 0x0000), two(0xfff8, 0xffff), "DsBw"}, -{"pdbcc", two(0xf048, 0x000f), two(0xfff8, 0xffff), "DsBw"}, -{"pdbcs", two(0xf048, 0x000e), two(0xfff8, 0xffff), "DsBw"}, -{"pdbgc", two(0xf048, 0x000d), two(0xfff8, 0xffff), "DsBw"}, -{"pdbgs", two(0xf048, 0x000c), two(0xfff8, 0xffff), "DsBw"}, -{"pdbic", two(0xf048, 0x000b), two(0xfff8, 0xffff), "DsBw"}, -{"pdbis", two(0xf048, 0x000a), two(0xfff8, 0xffff), "DsBw"}, -{"pdblc", two(0xf048, 0x0003), two(0xfff8, 0xffff), "DsBw"}, -{"pdbls", two(0xf048, 0x0002), two(0xfff8, 0xffff), "DsBw"}, -{"pdbsc", two(0xf048, 0x0005), two(0xfff8, 0xffff), "DsBw"}, -{"pdbss", two(0xf048, 0x0004), two(0xfff8, 0xffff), "DsBw"}, -{"pdbwc", two(0xf048, 0x0009), two(0xfff8, 0xffff), "DsBw"}, -{"pdbws", two(0xf048, 0x0008), two(0xfff8, 0xffff), "DsBw"}, - -{"pflusha", two(0xf000, 0x2400), two(0xffff, 0xffff), "" }, - -{"pflush", two(0xf000, 0x3010), two(0xffc0, 0xfe10), "T3T9" }, -{"pflush", two(0xf000, 0x3810), two(0xffc0, 0xfe10), "T3T9&s" }, -{"pflush", two(0xf000, 0x3008), two(0xffc0, 0xfe18), "D3T9" }, -{"pflush", two(0xf000, 0x3808), two(0xffc0, 0xfe18), "D3T9&s" }, -{"pflush", two(0xf000, 0x3000), two(0xffc0, 0xfe1e), "f3T9" }, -{"pflush", two(0xf000, 0x3800), two(0xffc0, 0xfe1e), "f3T9&s" }, - -{"pflushs", two(0xf000, 0x3410), two(0xfff8, 0xfe10), "T3T9" }, -{"pflushs", two(0xf000, 0x3c00), two(0xfff8, 0xfe00), "T3T9&s" }, -{"pflushs", two(0xf000, 0x3408), two(0xfff8, 0xfe18), "D3T9" }, -{"pflushs", two(0xf000, 0x3c08), two(0xfff8, 0xfe18), "D3T9&s" }, -{"pflushs", two(0xf000, 0x3400), two(0xfff8, 0xfe1e), "f3T9" }, -{"pflushs", two(0xf000, 0x3c00), two(0xfff8, 0xfe1e), "f3T9&s"}, - -{"pflushr", two(0xf000, 0xa000), two(0xffc0, 0xffff), "|s" }, - -{"ploadr", two(0xf000, 0x2210), two(0xffc0, 0xfff0), "T3&s" }, -{"ploadr", two(0xf000, 0x2208), two(0xffc0, 0xfff8), "D3&s" }, -{"ploadr", two(0xf000, 0x2200), two(0xffc0, 0xfffe), "f3&s" }, -{"ploadw", two(0xf000, 0x2010), two(0xffc0, 0xfff0), "T3&s" }, -{"ploadw", two(0xf000, 0x2008), two(0xffc0, 0xfff8), "D3&s" }, -{"ploadw", two(0xf000, 0x2000), two(0xffc0, 0xfffe), "f3&s" }, - -/* TC, CRP, DRP, SRP, CAL, VAL, SCC, AC */ -{"pmove", two(0xf000, 0x4000), two(0xffc0, 0xe3ff), "*sP8" }, -{"pmove", two(0xf000, 0x4200), two(0xffc0, 0xe3ff), "P8%s" }, -{"pmove", two(0xf000, 0x4000), two(0xffc0, 0xe3ff), "|sW8" }, -{"pmove", two(0xf000, 0x4200), two(0xffc0, 0xe3ff), "W8~s" }, - -/* BADx, BACx */ -{"pmove", two(0xf000, 0x6200), two(0xffc0, 0xe3e3), "*sX3" }, -{"pmove", two(0xf000, 0x6000), two(0xffc0, 0xe3e3), "X3%s" }, - -/* PSR, PCSR */ -/* {"pmove", two(0xf000, 0x6100), two(oxffc0, oxffff), "*sZ8" }, */ -{"pmove", two(0xf000, 0x6000), two(0xffc0, 0xffff), "*sY8" }, -{"pmove", two(0xf000, 0x6200), two(0xffc0, 0xffff), "Y8%s" }, -{"pmove", two(0xf000, 0x6600), two(0xffc0, 0xffff), "Z8%s" }, - -{"prestore", one(0xf140), one(0xffc0), "&s"}, -{"prestore", one(0xf158), one(0xfff8), "+s"}, -{"psave", one(0xf100), one(0xffc0), "&s"}, -{"psave", one(0xf100), one(0xffc0), "+s"}, - -{"psac", two(0xf040, 0x0007), two(0xffc0, 0xffff), "@s"}, -{"psas", two(0xf040, 0x0006), two(0xffc0, 0xffff), "@s"}, -{"psbc", two(0xf040, 0x0001), two(0xffc0, 0xffff), "@s"}, -{"psbs", two(0xf040, 0x0000), two(0xffc0, 0xffff), "@s"}, -{"pscc", two(0xf040, 0x000f), two(0xffc0, 0xffff), "@s"}, -{"pscs", two(0xf040, 0x000e), two(0xffc0, 0xffff), "@s"}, -{"psgc", two(0xf040, 0x000d), two(0xffc0, 0xffff), "@s"}, -{"psgs", two(0xf040, 0x000c), two(0xffc0, 0xffff), "@s"}, -{"psic", two(0xf040, 0x000b), two(0xffc0, 0xffff), "@s"}, -{"psis", two(0xf040, 0x000a), two(0xffc0, 0xffff), "@s"}, -{"pslc", two(0xf040, 0x0003), two(0xffc0, 0xffff), "@s"}, -{"psls", two(0xf040, 0x0002), two(0xffc0, 0xffff), "@s"}, -{"pssc", two(0xf040, 0x0005), two(0xffc0, 0xffff), "@s"}, -{"psss", two(0xf040, 0x0004), two(0xffc0, 0xffff), "@s"}, -{"pswc", two(0xf040, 0x0009), two(0xffc0, 0xffff), "@s"}, -{"psws", two(0xf040, 0x0008), two(0xffc0, 0xffff), "@s"}, - -{"ptestr", two(0xf000, 0x8210), two(0xffc0, 0xe3f0), "T3&sQ8" }, -{"ptestr", two(0xf000, 0x8310), two(0xffc0, 0xe310), "T3&sQ8A9" }, -{"ptestr", two(0xf000, 0x8208), two(0xffc0, 0xe3f8), "D3&sQ8" }, -{"ptestr", two(0xf000, 0x8308), two(0xffc0, 0xe318), "D3&sQ8A9" }, -{"ptestr", two(0xf000, 0x8200), two(0xffc0, 0xe3fe), "f3&sQ8" }, -{"ptestr", two(0xf000, 0x8300), two(0xffc0, 0xe31e), "f3&sQ8A9" }, - -{"ptestw", two(0xf000, 0x8010), two(0xffc0, 0xe3f0), "T3&sQ8" }, -{"ptestw", two(0xf000, 0x8110), two(0xffc0, 0xe310), "T3&sQ8A9" }, -{"ptestw", two(0xf000, 0x8008), two(0xffc0, 0xe3f8), "D3&sQ8" }, -{"ptestw", two(0xf000, 0x8108), two(0xffc0, 0xe318), "D3&sQ8A9" }, -{"ptestw", two(0xf000, 0x8000), two(0xffc0, 0xe3fe), "f3&sQ8" }, -{"ptestw", two(0xf000, 0x8100), two(0xffc0, 0xe31e), "f3&sQ8A9" }, - -{"ptrapacw", two(0xf07a, 0x0007), two(0xffff, 0xffff), "#w"}, -{"ptrapacl", two(0xf07b, 0x0007), two(0xffff, 0xffff), "#l"}, -{"ptrapac", two(0xf07c, 0x0007), two(0xffff, 0xffff), ""}, - -{"ptrapasw", two(0xf07a, 0x0006), two(0xffff, 0xffff), "#w"}, -{"ptrapasl", two(0xf07b, 0x0006), two(0xffff, 0xffff), "#l"}, -{"ptrapas", two(0xf07c, 0x0006), two(0xffff, 0xffff), ""}, - -{"ptrapbcw", two(0xf07a, 0x0001), two(0xffff, 0xffff), "#w"}, -{"ptrapbcl", two(0xf07b, 0x0001), two(0xffff, 0xffff), "#l"}, -{"ptrapbc", two(0xf07c, 0x0001), two(0xffff, 0xffff), ""}, - -{"ptrapbsw", two(0xf07a, 0x0000), two(0xffff, 0xffff), "#w"}, -{"ptrapbsl", two(0xf07b, 0x0000), two(0xffff, 0xffff), "#l"}, -{"ptrapbs", two(0xf07c, 0x0000), two(0xffff, 0xffff), ""}, - -{"ptrapccw", two(0xf07a, 0x000f), two(0xffff, 0xffff), "#w"}, -{"ptrapccl", two(0xf07b, 0x000f), two(0xffff, 0xffff), "#l"}, -{"ptrapcc", two(0xf07c, 0x000f), two(0xffff, 0xffff), ""}, - -{"ptrapcsw", two(0xf07a, 0x000e), two(0xffff, 0xffff), "#w"}, -{"ptrapcsl", two(0xf07b, 0x000e), two(0xffff, 0xffff), "#l"}, -{"ptrapcs", two(0xf07c, 0x000e), two(0xffff, 0xffff), ""}, - -{"ptrapgcw", two(0xf07a, 0x000d), two(0xffff, 0xffff), "#w"}, -{"ptrapgcl", two(0xf07b, 0x000d), two(0xffff, 0xffff), "#l"}, -{"ptrapgc", two(0xf07c, 0x000d), two(0xffff, 0xffff), ""}, - -{"ptrapgsw", two(0xf07a, 0x000c), two(0xffff, 0xffff), "#w"}, -{"ptrapgsl", two(0xf07b, 0x000c), two(0xffff, 0xffff), "#l"}, -{"ptrapgs", two(0xf07c, 0x000c), two(0xffff, 0xffff), ""}, - -{"ptrapicw", two(0xf07a, 0x000b), two(0xffff, 0xffff), "#w"}, -{"ptrapicl", two(0xf07b, 0x000b), two(0xffff, 0xffff), "#l"}, -{"ptrapic", two(0xf07c, 0x000b), two(0xffff, 0xffff), ""}, - -{"ptrapisw", two(0xf07a, 0x000a), two(0xffff, 0xffff), "#w"}, -{"ptrapisl", two(0xf07b, 0x000a), two(0xffff, 0xffff), "#l"}, -{"ptrapis", two(0xf07c, 0x000a), two(0xffff, 0xffff), ""}, - -{"ptraplcw", two(0xf07a, 0x0003), two(0xffff, 0xffff), "#w"}, -{"ptraplcl", two(0xf07b, 0x0003), two(0xffff, 0xffff), "#l"}, -{"ptraplc", two(0xf07c, 0x0003), two(0xffff, 0xffff), ""}, - -{"ptraplsw", two(0xf07a, 0x0002), two(0xffff, 0xffff), "#w"}, -{"ptraplsl", two(0xf07b, 0x0002), two(0xffff, 0xffff), "#l"}, -{"ptrapls", two(0xf07c, 0x0002), two(0xffff, 0xffff), ""}, - -{"ptrapscw", two(0xf07a, 0x0005), two(0xffff, 0xffff), "#w"}, -{"ptrapscl", two(0xf07b, 0x0005), two(0xffff, 0xffff), "#l"}, -{"ptrapsc", two(0xf07c, 0x0005), two(0xffff, 0xffff), ""}, - -{"ptrapssw", two(0xf07a, 0x0004), two(0xffff, 0xffff), "#w"}, -{"ptrapssl", two(0xf07b, 0x0004), two(0xffff, 0xffff), "#l"}, -{"ptrapss", two(0xf07c, 0x0004), two(0xffff, 0xffff), ""}, - -{"ptrapwcw", two(0xf07a, 0x0009), two(0xffff, 0xffff), "#w"}, -{"ptrapwcl", two(0xf07b, 0x0009), two(0xffff, 0xffff), "#l"}, -{"ptrapwc", two(0xf07c, 0x0009), two(0xffff, 0xffff), ""}, - -{"ptrapwsw", two(0xf07a, 0x0008), two(0xffff, 0xffff), "#w"}, -{"ptrapwsl", two(0xf07b, 0x0008), two(0xffff, 0xffff), "#l"}, -{"ptrapws", two(0xf07c, 0x0008), two(0xffff, 0xffff), ""}, - -{"pvalid", two(0xf000, 0x2800), two(0xffc0, 0xffff), "Vs&s"}, -{"pvalid", two(0xf000, 0x2c00), two(0xffc0, 0xfff8), "A3&s" }, - -#endif /* m68851 */ - -}; - -int numopcodes=sizeof(m68k_opcodes)/sizeof(m68k_opcodes[0]); - -struct m68k_opcode *endop = m68k_opcodes+sizeof(m68k_opcodes)/sizeof(m68k_opcodes[0]); diff --git a/gdb/m68k-pinsn.c b/gdb/m68k-pinsn.c deleted file mode 100644 index b648abbada5..00000000000 --- a/gdb/m68k-pinsn.c +++ /dev/null @@ -1,776 +0,0 @@ -/* Print m68k instructions for GDB, the GNU debugger. - Copyright (C) 1986, 1987, 1989 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include - -#include "defs.h" -#include "param.h" -#include "symtab.h" -#include "m68k-opcode.h" -#include "gdbcore.h" - -/* 68k instructions are never longer than this many bytes. */ -#define MAXLEN 22 - -/* Number of elements in the opcode table. */ -#define NOPCODES (sizeof m68k_opcodes / sizeof m68k_opcodes[0]) - -extern char *reg_names[]; -char *fpcr_names[] = { "", "fpiar", "fpsr", "fpiar/fpsr", "fpcr", - "fpiar/fpcr", "fpsr/fpcr", "fpiar-fpcr"}; - -static unsigned char *print_insn_arg (); -static unsigned char *print_indexed (); -static void print_base (); -static int fetch_arg (); - -#define NEXTBYTE(p) (p += 2, ((char *)p)[-1]) - -#define NEXTWORD(p) \ - (p += 2, ((((char *)p)[-2]) << 8) + p[-1]) - -#define NEXTLONG(p) \ - (p += 4, (((((p[-4] << 8) + p[-3]) << 8) + p[-2]) << 8) + p[-1]) - -#define NEXTSINGLE(p) \ - (p += 4, *((float *)(p - 4))) - -#define NEXTDOUBLE(p) \ - (p += 8, *((double *)(p - 8))) - -#define NEXTEXTEND(p) \ - (p += 12, 0.0) /* Need a function to convert from extended to double - precision... */ - -#define NEXTPACKED(p) \ - (p += 12, 0.0) /* Need a function to convert from packed to double - precision. Actually, it's easier to print a - packed number than a double anyway, so maybe - there should be a special case to handle this... */ - -/* Print the m68k instruction at address MEMADDR in debugged memory, - on STREAM. Returns length of the instruction, in bytes. */ - -int -print_insn (memaddr, stream) - CORE_ADDR memaddr; - FILE *stream; -{ - unsigned char buffer[MAXLEN]; - register int i; - register unsigned char *p; - register char *d; - register int bestmask; - int best; - - read_memory (memaddr, buffer, MAXLEN); - - bestmask = 0; - best = -1; - for (i = 0; i < NOPCODES; i++) - { - register unsigned int opcode = m68k_opcodes[i].opcode; - register unsigned int match = m68k_opcodes[i].match; - if (((0xff & buffer[0] & (match >> 24)) == (0xff & (opcode >> 24))) - && ((0xff & buffer[1] & (match >> 16)) == (0xff & (opcode >> 16))) - && ((0xff & buffer[2] & (match >> 8)) == (0xff & (opcode >> 8))) - && ((0xff & buffer[3] & match) == (0xff & opcode))) - { - /* Don't use for printout the variants of divul and divsl - that have the same register number in two places. - The more general variants will match instead. */ - for (d = m68k_opcodes[i].args; *d; d += 2) - if (d[1] == 'D') - break; - - /* Don't use for printout the variants of most floating - point coprocessor instructions which use the same - register number in two places, as above. */ - if (*d == 0) - for (d = m68k_opcodes[i].args; *d; d += 2) - if (d[1] == 't') - break; - - if (*d == 0 && match > bestmask) - { - best = i; - bestmask = match; - } - } - } - - /* Handle undefined instructions. */ - if (best < 0) - { - fprintf_filtered (stream, "0%o", (buffer[0] << 8) + buffer[1]); - return 2; - } - - fprintf_filtered (stream, "%s", m68k_opcodes[best].name); - - /* Point at first word of argument data, - and at descriptor for first argument. */ - p = buffer + 2; - - /* Why do this this way? -MelloN */ - for (d = m68k_opcodes[best].args; *d; d += 2) - { - if (d[0] == '#') - { - if (d[1] == 'l' && p - buffer < 6) - p = buffer + 6; - else if (p - buffer < 4 && d[1] != 'C' && d[1] != '8' ) - p = buffer + 4; - } - if (d[1] >= '1' && d[1] <= '3' && p - buffer < 4) - p = buffer + 4; - if (d[1] >= '4' && d[1] <= '6' && p - buffer < 6) - p = buffer + 6; - if ((d[0] == 'L' || d[0] == 'l') && d[1] == 'w' && p - buffer < 4) - p = buffer + 4; - } - - d = m68k_opcodes[best].args; - - if (*d) - fputs_filtered (" ", stream); - - while (*d) - { - p = print_insn_arg (d, buffer, p, memaddr + p - buffer, stream); - d += 2; - if (*d && *(d - 2) != 'I' && *d != 'k') - fputs_filtered (",", stream); - } - return p - buffer; -} - -static unsigned char * -print_insn_arg (d, buffer, p, addr, stream) - char *d; - unsigned char *buffer; - register unsigned char *p; - CORE_ADDR addr; /* PC for this arg to be relative to */ - FILE *stream; -{ - register int val; - register int place = d[1]; - int regno; - register char *regname; - register unsigned char *p1; - register double flval; - int flt_p; - - switch (*d) - { - case 'C': - fprintf_filtered (stream, "ccr"); - break; - - case 'S': - fprintf_filtered (stream, "sr"); - break; - - case 'U': - fprintf_filtered (stream, "usp"); - break; - - case 'J': - { - static struct { char *name; int value; } names[] - = {{"sfc", 0x000}, {"dfc", 0x001}, {"cacr", 0x002}, - {"usp", 0x800}, {"vbr", 0x801}, {"caar", 0x802}, - {"msp", 0x803}, {"isp", 0x804}}; - - val = fetch_arg (buffer, place, 12); - for (regno = sizeof names / sizeof names[0] - 1; regno >= 0; regno--) - if (names[regno].value == val) - { - fprintf_filtered (stream, names[regno].name); - break; - } - if (regno < 0) - fprintf_filtered (stream, "%d", val); - } - break; - - case 'Q': - val = fetch_arg (buffer, place, 3); - /* 0 means 8, except for the bkpt instruction... */ - if (val == 0 && d[1] != 's') - val = 8; - fprintf_filtered (stream, "#%d", val); - break; - - case 'M': - val = fetch_arg (buffer, place, 8); - if (val & 0x80) - val = val - 0x100; - fprintf_filtered (stream, "#%d", val); - break; - - case 'T': - val = fetch_arg (buffer, place, 4); - fprintf_filtered (stream, "#%d", val); - break; - - case 'D': - fprintf_filtered (stream, "%s", reg_names[fetch_arg (buffer, place, 3)]); - break; - - case 'A': - fprintf_filtered (stream, "%s", - reg_names[fetch_arg (buffer, place, 3) + 010]); - break; - - case 'R': - fprintf_filtered (stream, "%s", reg_names[fetch_arg (buffer, place, 4)]); - break; - - case 'F': - fprintf_filtered (stream, "fp%d", fetch_arg (buffer, place, 3)); - break; - - case 'O': - val = fetch_arg (buffer, place, 6); - if (val & 0x20) - fprintf_filtered (stream, "%s", reg_names [val & 7]); - else - fprintf_filtered (stream, "%d", val); - break; - - case '+': - fprintf_filtered (stream, "%s@+", - reg_names[fetch_arg (buffer, place, 3) + 8]); - break; - - case '-': - fprintf_filtered (stream, "%s@-", - reg_names[fetch_arg (buffer, place, 3) + 8]); - break; - - case 'k': - if (place == 'k') - fprintf_filtered (stream, "{%s}", reg_names[fetch_arg (buffer, place, 3)]); - else if (place == 'C') - { - val = fetch_arg (buffer, place, 7); - if ( val > 63 ) /* This is a signed constant. */ - val -= 128; - fprintf_filtered (stream, "{#%d}", val); - } - else - error ("Invalid arg format in opcode table: \"%c%c\".", - *d, place); - break; - - case '#': - case '^': - p1 = buffer + (*d == '#' ? 2 : 4); - if (place == 's') - val = fetch_arg (buffer, place, 4); - else if (place == 'C') - val = fetch_arg (buffer, place, 7); - else if (place == '8') - val = fetch_arg (buffer, place, 3); - else if (place == '3') - val = fetch_arg (buffer, place, 8); - else if (place == 'b') - val = NEXTBYTE (p1); - else if (place == 'w') - val = NEXTWORD (p1); - else if (place == 'l') - val = NEXTLONG (p1); - else - error ("Invalid arg format in opcode table: \"%c%c\".", - *d, place); - fprintf_filtered (stream, "#%d", val); - break; - - case 'B': - if (place == 'b') - val = NEXTBYTE (p); - else if (place == 'B') - val = buffer[1]; - else if (place == 'w' || place == 'W') - val = NEXTWORD (p); - else if (place == 'l' || place == 'L') - val = NEXTLONG (p); - else if (place == 'g') - { - val = ((char *)buffer)[1]; - if (val == 0) - val = NEXTWORD (p); - else if (val == -1) - val = NEXTLONG (p); - } - else if (place == 'c') - { - if (buffer[1] & 0x40) /* If bit six is one, long offset */ - val = NEXTLONG (p); - else - val = NEXTWORD (p); - } - else - error ("Invalid arg format in opcode table: \"%c%c\".", - *d, place); - - print_address (addr + val, stream); - break; - - case 'd': - val = NEXTWORD (p); - fprintf_filtered (stream, "%s@(%d)", - reg_names[fetch_arg (buffer, place, 3)], val); - break; - - case 's': - fprintf_filtered (stream, "%s", - fpcr_names[fetch_arg (buffer, place, 3)]); - break; - - case 'I': - val = fetch_arg (buffer, 'd', 3); /* Get coprocessor ID... */ - if (val != 1) /* Unusual coprocessor ID? */ - fprintf_filtered (stream, "(cpid=%d) ", val); - if (place == 'i') - p += 2; /* Skip coprocessor extended operands */ - break; - - case '*': - case '~': - case '%': - case ';': - case '@': - case '!': - case '$': - case '?': - case '/': - case '&': - - if (place == 'd') - { - val = fetch_arg (buffer, 'x', 6); - val = ((val & 7) << 3) + ((val >> 3) & 7); - } - else - val = fetch_arg (buffer, 's', 6); - - /* Get register number assuming address register. */ - regno = (val & 7) + 8; - regname = reg_names[regno]; - switch (val >> 3) - { - case 0: - fprintf_filtered (stream, "%s", reg_names[val]); - break; - - case 1: - fprintf_filtered (stream, "%s", regname); - break; - - case 2: - fprintf_filtered (stream, "%s@", regname); - break; - - case 3: - fprintf_filtered (stream, "%s@+", regname); - break; - - case 4: - fprintf_filtered (stream, "%s@-", regname); - break; - - case 5: - val = NEXTWORD (p); - fprintf_filtered (stream, "%s@(%d)", regname, val); - break; - - case 6: - p = print_indexed (regno, p, addr, stream); - break; - - case 7: - switch (val & 7) - { - case 0: - val = NEXTWORD (p); - fprintf_filtered (stream, "@#"); - print_address (val, stream); - break; - - case 1: - val = NEXTLONG (p); - fprintf_filtered (stream, "@#"); - print_address (val, stream); - break; - - case 2: - val = NEXTWORD (p); - print_address (addr + val, stream); - break; - - case 3: - p = print_indexed (-1, p, addr, stream); - break; - - case 4: - flt_p = 1; /* Assume it's a float... */ - switch( place ) - { - case 'b': - val = NEXTBYTE (p); - flt_p = 0; - break; - - case 'w': - val = NEXTWORD (p); - flt_p = 0; - break; - - case 'l': - val = NEXTLONG (p); - flt_p = 0; - break; - - case 'f': - flval = NEXTSINGLE(p); - break; - - case 'F': - flval = NEXTDOUBLE(p); - break; - - case 'x': - flval = NEXTEXTEND(p); - break; - - case 'p': - flval = NEXTPACKED(p); - break; - - default: - error ("Invalid arg format in opcode table: \"%c%c\".", - *d, place); - } - if ( flt_p ) /* Print a float? */ - fprintf_filtered (stream, "#%g", flval); - else - fprintf_filtered (stream, "#%d", val); - break; - - default: - fprintf_filtered (stream, "", val); - } - } - break; - - case 'L': - case 'l': - if (place == 'w') - { - char doneany; - p1 = buffer + 2; - val = NEXTWORD (p1); - /* Move the pointer ahead if this point is farther ahead - than the last. */ - p = p1 > p ? p1 : p; - if (val == 0) - { - fputs_filtered ("#0", stream); - break; - } - if (*d == 'l') - { - register int newval = 0; - for (regno = 0; regno < 16; ++regno) - if (val & (0x8000 >> regno)) - newval |= 1 << regno; - val = newval; - } - val &= 0xffff; - doneany = 0; - for (regno = 0; regno < 16; ++regno) - if (val & (1 << regno)) - { - int first_regno; - if (doneany) - fputs_filtered ("/", stream); - doneany = 1; - fprintf_filtered (stream, "%s", reg_names[regno]); - first_regno = regno; - while (val & (1 << (regno + 1))) - ++regno; - if (regno > first_regno) - fprintf_filtered (stream, "-%s", reg_names[regno]); - } - } - else if (place == '3') - { - /* `fmovem' insn. */ - char doneany; - val = fetch_arg (buffer, place, 8); - if (val == 0) - { - fputs_filtered ("#0", stream); - break; - } - if (*d == 'l') - { - register int newval = 0; - for (regno = 0; regno < 8; ++regno) - if (val & (0x80 >> regno)) - newval |= 1 << regno; - val = newval; - } - val &= 0xff; - doneany = 0; - for (regno = 0; regno < 8; ++regno) - if (val & (1 << regno)) - { - int first_regno; - if (doneany) - fputs_filtered ("/", stream); - doneany = 1; - fprintf_filtered (stream, "fp%d", regno); - first_regno = regno; - while (val & (1 << (regno + 1))) - ++regno; - if (regno > first_regno) - fprintf_filtered (stream, "-fp%d", regno); - } - } - else - abort (); - break; - - default: - error ("Invalid arg format in opcode table: \"%c\".", *d); - } - - return (unsigned char *) p; -} - -/* Fetch BITS bits from a position in the instruction specified by CODE. - CODE is a "place to put an argument", or 'x' for a destination - that is a general address (mode and register). - BUFFER contains the instruction. */ - -static int -fetch_arg (buffer, code, bits) - unsigned char *buffer; - char code; - int bits; -{ - register int val; - switch (code) - { - case 's': - val = buffer[1]; - break; - - case 'd': /* Destination, for register or quick. */ - val = (buffer[0] << 8) + buffer[1]; - val >>= 9; - break; - - case 'x': /* Destination, for general arg */ - val = (buffer[0] << 8) + buffer[1]; - val >>= 6; - break; - - case 'k': - val = (buffer[3] >> 4); - break; - - case 'C': - val = buffer[3]; - break; - - case '1': - val = (buffer[2] << 8) + buffer[3]; - val >>= 12; - break; - - case '2': - val = (buffer[2] << 8) + buffer[3]; - val >>= 6; - break; - - case '3': - case 'j': - val = (buffer[2] << 8) + buffer[3]; - break; - - case '4': - val = (buffer[4] << 8) + buffer[5]; - val >>= 12; - break; - - case '5': - val = (buffer[4] << 8) + buffer[5]; - val >>= 6; - break; - - case '6': - val = (buffer[4] << 8) + buffer[5]; - break; - - case '7': - val = (buffer[2] << 8) + buffer[3]; - val >>= 7; - break; - - case '8': - val = (buffer[2] << 8) + buffer[3]; - val >>= 10; - break; - - default: - abort (); - } - - switch (bits) - { - case 3: - return val & 7; - case 4: - return val & 017; - case 5: - return val & 037; - case 6: - return val & 077; - case 7: - return val & 0177; - case 8: - return val & 0377; - case 12: - return val & 07777; - default: - abort (); - } -} - -/* Print an indexed argument. The base register is BASEREG (-1 for pc). - P points to extension word, in buffer. - ADDR is the nominal core address of that extension word. */ - -static unsigned char * -print_indexed (basereg, p, addr, stream) - int basereg; - unsigned char *p; - FILE *stream; - CORE_ADDR addr; -{ - register int word; - static char *scales[] = {"", "*2", "*4", "*8"}; - register int base_disp; - register int outer_disp; - char buf[40]; - - word = NEXTWORD (p); - - /* Generate the text for the index register. - Where this will be output is not yet determined. */ - sprintf (buf, "[%s.%c%s]", - reg_names[(word >> 12) & 0xf], - (word & 0x800) ? 'l' : 'w', - scales[(word >> 9) & 3]); - - /* Handle the 68000 style of indexing. */ - - if ((word & 0x100) == 0) - { - print_base (basereg, - ((word & 0x80) ? word | 0xff00 : word & 0xff) - + ((basereg == -1) ? addr : 0), - stream); - fputs_filtered (buf, stream); - return p; - } - - /* Handle the generalized kind. */ - /* First, compute the displacement to add to the base register. */ - - if (word & 0200) - basereg = -2; - if (word & 0100) - buf[0] = 0; - base_disp = 0; - switch ((word >> 4) & 3) - { - case 2: - base_disp = NEXTWORD (p); - break; - case 3: - base_disp = NEXTLONG (p); - } - if (basereg == -1) - base_disp += addr; - - /* Handle single-level case (not indirect) */ - - if ((word & 7) == 0) - { - print_base (basereg, base_disp, stream); - fputs_filtered (buf, stream); - return p; - } - - /* Two level. Compute displacement to add after indirection. */ - - outer_disp = 0; - switch (word & 3) - { - case 2: - outer_disp = NEXTWORD (p); - break; - case 3: - outer_disp = NEXTLONG (p); - } - - fprintf_filtered (stream, "%d(", outer_disp); - print_base (basereg, base_disp, stream); - - /* If postindexed, print the closeparen before the index. */ - if (word & 4) - fprintf_filtered (stream, ")%s", buf); - /* If preindexed, print the closeparen after the index. */ - else - fprintf_filtered (stream, "%s)", buf); - - return p; -} - -/* Print a base register REGNO and displacement DISP, on STREAM. - REGNO = -1 for pc, -2 for none (suppressed). */ - -static void -print_base (regno, disp, stream) - int regno; - int disp; - FILE *stream; -{ - if (regno == -2) - fprintf_filtered (stream, "%d", disp); - else if (regno == -1) - fprintf_filtered (stream, "0x%x", disp); - else - fprintf_filtered (stream, "%d(%s)", disp, reg_names[regno]); -} diff --git a/gdb/m68k-stub.c b/gdb/m68k-stub.c deleted file mode 100644 index ae7553ac25a..00000000000 --- a/gdb/m68k-stub.c +++ /dev/null @@ -1,980 +0,0 @@ -/**************************************************************************** - - THIS SOFTWARE IS NOT COPYRIGHTED - - HP offers the following for use in the public domain. HP makes no - warranty with regard to the software or it's performance and the - user accepts the software "AS IS" with all faults. - - HP 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. - -****************************************************************************/ - -/**************************************************************************** - * $Header$ - * - * $Module name: remcom.c $ - * $Revision$ - * $Date$ - * $Contributor: Lake Stevens Instrument Division$ - * - * $Description: low level support for gdb debugger. $ - * - * $Considerations: only works on target hardware $ - * - * $Written by: Glenn Engel $ - * $ModuleState: Experimental $ - * - * $NOTES: See Below $ - * - * To enable debugger support, two things need to happen. One, a - * call to set_debug_traps() is necessary in order to allow any breakpoints - * or error conditions to be properly intercepted and reported to gdb. - * Two, a breakpoint needs to be generated to begin communication. This - * is most easily accomplished by a call to breakpoint(). Breakpoint() - * simulates a breakpoint by executing a trap #1. - * - * Some explanation is probably necessary to explain how exceptions are - * handled. When an exception is encountered the 68000 pushes the current - * program counter and status register onto the supervisor stack and then - * transfers execution to a location specified in it's vector table. - * The handlers for the exception vectors are hardwired to jmp to an address - * given by the relation: (exception - 256) * 6. These are decending - * addresses starting from -6, -12, -18, ... By allowing 6 bytes for - * each entry, a jsr, jmp, bsr, ... can be used to enter the exception - * handler. Using a jsr to handle an exception has an added benefit of - * allowing a single handler to service several exceptions and use the - * return address as the key differentiation. The vector number can be - * computed from the return address by [ exception = (addr + 1530) / 6 ]. - * The sole purpose of the routine _catchException is to compute the - * exception number and push it on the stack in place of the return address. - * The external function exceptionHandler() is - * used to attach a specific handler to a specific 68k exception. - * For 68020 machines, the ability to have a return address around just - * so the vector can be determined is not necessary because the '020 pushes an - * extra word onto the stack containing the vector offset - * - * Because gdb will sometimes write to the stack area to execute function - * calls, this program cannot rely on using the supervisor stack so it - * uses it's own stack area reserved in the int array remcomStack. - * - ************* - * - * The following gdb commands are supported: - * - * command function Return value - * - * g return the value of the CPU registers hex data or ENN - * G set the value of the CPU registers OK or ENN - * - * mAA..AA,LLLL Read LLLL bytes at address AA..AA hex data or ENN - * MAA..AA,LLLL: Write LLLL bytes at address AA.AA OK or ENN - * - * c Resume at current address SNN ( signal NN) - * cAA..AA Continue at address AA..AA SNN - * - * s Step one instruction SNN - * sAA..AA Step one instruction from AA..AA SNN - * - * k kill - * - * ? What was the last sigval ? SNN (signal NN) - * - * All commands and responses are sent with a packet which includes a - * checksum. A packet consists of - * - * $#. - * - * where - * :: - * :: < two hex digits computed as modulo 256 sum of > - * - * When a packet is received, it is first acknowledged with either '+' or '-'. - * '+' indicates a successful transfer. '-' indicates a failed transfer. - * - * Example: - * - * Host: Reply: - * $m0,10#2a +$00010203040506070809101112131415#42 - * - ****************************************************************************/ - -#include -#include -#include - -/************************************************************************ - * - * external low-level support routines - */ -typedef void (*ExceptionHook)(int); /* pointer to function with int parm */ -typedef void (*Function)(); /* pointer to a function */ - -extern putDebugChar(); /* write a single character */ -extern getDebugChar(); /* read and return a single char */ - -extern Function exceptionHandler(); /* assign an exception handler */ -extern ExceptionHook exceptionHook; /* hook variable for errors/exceptions */ - -/************************/ -/* FORWARD DECLARATIONS */ -/************************/ -void initializeRemcomErrorFrame(void); - -/************************************************************************/ -/* BUFMAX defines the maximum number of characters in inbound/outbound buffers*/ -/* at least NUMREGBYTES*2 are needed for register packets */ -#define BUFMAX 400 - -static char initialized; /* boolean flag. != 0 means we've been initialized */ - -int remote_debug; -/* debug > 0 prints ill-formed commands in valid packets & checksum errors */ - -static const char hexchars[]="0123456789abcdef"; - -/* there are 180 bytes of registers on a 68020 w/68881 */ -/* many of the fpa registers are 12 byte (96 bit) registers */ -#define NUMREGBYTES 180 -enum regnames {D0,D1,D2,D3,D4,D5,D6,D7, - A0,A1,A2,A3,A4,A5,A6,A7, - PS,PC, - FP0,FP1,FP2,FP3,FP4,FP5,FP6,FP7, - FPCONTROL,FPSTATUS,FPIADDR - }; - -typedef struct FrameStruct -{ - struct FrameStruct *previous; - int exceptionPC; /* pc value when this frame created */ - int exceptionVector; /* cpu vector causing exception */ - short frameSize; /* size of cpu frame in words */ - short sr; /* for 68000, this not always sr */ - int pc; - short format; - int fsaveHeader; - int morejunk[0]; /* exception frame, fp save... */ -} Frame; - -#define FRAMESIZE 500 -int gdbFrameStack[FRAMESIZE]; -static Frame *lastFrame; - -/* - * these should not be static cuz they can be used outside this module - */ -int registers[NUMREGBYTES/4]; -int superStack; - -#define STACKSIZE 10000 -int remcomStack[STACKSIZE/sizeof(int)]; -static int* stackPtr = &remcomStack[STACKSIZE/sizeof(int) - 1]; - -/* - * In many cases, the system will want to continue exception processing - * when a continue command is given. - * oldExceptionHook is a function to invoke in this case. - */ - -static ExceptionHook oldExceptionHook; - -/* the size of the exception stack on the 68020 varies with the type of - * exception. The following table is the number of WORDS used - * for each exception format. - */ -const short exceptionSize[] = { 4,4,6,4,4,4,4,4,29,10,16,46,12,4,4,4 }; - -/************* jump buffer used for setjmp/longjmp **************************/ -jmp_buf remcomEnv; - -/*************************** ASSEMBLY CODE MACROS *************************/ -/* */ - -#ifdef __HAVE_68881__ -/* do an fsave, then remember the address to begin a restore from */ -#define SAVE_FP_REGS() asm(" fsave a0@-"); \ - asm(" fmovemx fp0-fp7,_registers+72"); \ - asm(" fmoveml fpcr/fpsr/fpi,_registers+168"); -#define RESTORE_FP_REGS() \ -asm(" \n\ - fmoveml _registers+168,fpcr/fpsr/fpi \n\ - fmovemx _registers+72,fp0-fp7 \n\ - cmpl #-1,a0@ | skip frestore flag set ? \n\ - beq skip_frestore \n\ - frestore a0@+ \n\ -skip_frestore: \n\ -"); - -#else -#define SAVE_FP_REGS() -#define RESTORE_FP_REGS() -#endif /* __HAVE_68881__ */ - -void return_to_super(void); -void return_to_user(void); - -asm(" -.text -.globl _return_to_super -_return_to_super: - movel _registers+60,sp /* get new stack pointer */ - movel _lastFrame,a0 /* get last frame info */ - bra return_to_any - -.globl _return_to_user -_return_to_user: - movel _registers+60,a0 /* get usp */ - movel a0,usp /* set usp */ - movel _superStack,sp /* get original stack pointer */ - -return_to_any: - movel _lastFrame,a0 /* get last frame info */ - movel a0@+,_lastFrame /* link in previous frame */ - addql #8,a0 /* skip over pc, vector#*/ - movew a0@+,d0 /* get # of words in cpu frame */ - addw d0,a0 /* point to end of data */ - addw d0,a0 /* point to end of data */ - movel a0,a1 -# -# copy the stack frame - subql #1,d0 -copyUserLoop: - movew a1@-,sp@- - dbf d0,copyUserLoop -"); - RESTORE_FP_REGS() - asm(" moveml _registers,d0-d7/a0-a6"); - asm(" rte"); /* pop and go! */ - -#define DISABLE_INTERRUPTS() asm(" oriw #0x0700,sr"); -#define BREAKPOINT() asm(" trap #1"); - -/* this function is called immediately when a level 7 interrupt occurs */ -/* if the previous interrupt level was 7 then we're already servicing */ -/* this interrupt and an rte is in order to return to the debugger. */ -/* For the 68000, the offset for sr is 6 due to the jsr return address */ -asm(" -.text -.globl __debug_level7 -__debug_level7: - movew d0,sp@-"); -#ifdef mc68020 -asm(" movew sp@(2),d0"); -#else -asm(" movew sp@(6),d0"); -#endif -asm(" andiw #0x700,d0 - cmpiw #0x700,d0 - beq _already7 - movew sp@+,d0 - bra __catchException -_already7: - movew sp@+,d0"); -#ifndef mc68020 -asm(" lea sp@(4),sp"); /* pull off 68000 return address */ -#endif -asm(" rte"); - -extern void _catchException(); - -#ifdef mc68020 -/* This function is called when a 68020 exception occurs. It saves - * all the cpu and fpcp regs in the _registers array, creates a frame on a - * linked list of frames which has the cpu and fpcp stack frames needed - * to properly restore the context of these processors, and invokes - * an exception handler (remcom_handler). - * - * stack on entry: stack on exit: - * N bytes of junk exception # MSWord - * Exception Format Word exception # MSWord - * Program counter LSWord - * Program counter MSWord - * Status Register - * - * - */ -asm(" -.text -.globl __catchException -__catchException:"); -DISABLE_INTERRUPTS(); -asm(" - moveml d0-d7/a0-a6,_registers /* save registers */ - movel _lastFrame,a0 /* last frame pointer */ -"); -SAVE_FP_REGS(); -asm(" - lea _registers,a5 /* get address of registers */ - movew sp@,d1 /* get status register */ - movew d1,a5@(66) /* save sr */ - movel sp@(2),a4 /* save pc in a4 for later use */ - movel a4,a5@(68) /* save pc in _regisers[] */ - -# -# figure out how many bytes in the stack frame - movew sp@(6),d0 /* get '020 exception format */ - movew d0,d2 /* make a copy of format word */ - andiw #0xf000,d0 /* mask off format type */ - rolw #5,d0 /* rotate into the low byte *2 */ - lea _exceptionSize,a1 - addw d0,a1 /* index into the table */ - movew a1@,d0 /* get number of words in frame */ - movew d0,d3 /* save it */ - subw d0,a0 /* adjust save pointer */ - subw d0,a0 /* adjust save pointer(bytes) */ - movel a0,a1 /* copy save pointer */ - subql #1,d0 /* predecrement loop counter */ -# -# copy the frame -saveFrameLoop: - movew sp@+,a1@+ - dbf d0,saveFrameLoop -# -# now that the stack has been clenaed, -# save the a7 in use at time of exception - movel sp,_superStack /* save supervisor sp */ - andiw #0x2000,d1 /* were we in supervisor mode ? */ - beq userMode - movel a7,a5@(60) /* save a7 */ - bra a7saveDone -userMode: - movel usp,a1 - movel a1,a5@(60) /* save user stack pointer */ -a7saveDone: - -# -# save size of frame - movew d3,a0@- - -# -# compute exception number - andl #0xfff,d2 /* mask off vector offset */ - lsrw #2,d2 /* divide by 4 to get vect num */ - movel d2,a0@- /* save it */ -# -# save pc causing exception - movel a4,a0@- -# -# save old frame link and set the new value - movel _lastFrame,a1 /* last frame pointer */ - movel a1,a0@- /* save pointer to prev frame */ - movel a0,_lastFrame - - movel d2,sp@- /* push exception num */ - movel _exceptionHook,a0 /* get address of handler */ - jbsr a0@ /* and call it */ - clrl sp@ /* replace exception num parm with frame ptr */ - jbsr __returnFromException /* jbsr, but never returns */ -"); -#else /* mc68000 */ -/* This function is called when an exception occurs. It translates the - * return address found on the stack into an exception vector # which - * is then handled by either handle_exception or a system handler. - * _catchException provides a front end for both. - * - * stack on entry: stack on exit: - * Program counter MSWord exception # MSWord - * Program counter LSWord exception # MSWord - * Status Register - * Return Address MSWord - * Return Address LSWord - */ -asm(" -.text -.globl __catchException -__catchException:"); -DISABLE_INTERRUPTS(); -asm(" - moveml d0-d7/a0-a6,_registers /* save registers */ - movel _lastFrame,a0 /* last frame pointer */ -"); -SAVE_FP_REGS(); -asm(" - lea _registers,a5 /* get address of registers */ - movel sp@+,d2 /* pop return address */ - addl #1530,d2 /* convert return addr to */ - divs #6,d2 /* exception number */ - extl d2 - - moveql #3,d3 /* assume a three word frame */ - - cmpiw #3,d2 /* bus error or address error ? */ - bgt normal /* if >3 then normal error */ - movel sp@+,a0@- /* copy error info to frame buff*/ - movel sp@+,a0@- /* these are never used */ - moveql #7,d3 /* this is a 7 word frame */ - -normal: - movew sp@+,d1 /* pop status register */ - movel sp@+,a4 /* pop program counter */ - movew d1,a5@(66) /* save sr */ - movel a4,a5@(68) /* save pc in _regisers[] */ - movel a4,a0@- /* copy pc to frame buffer */ - movew d1,a0@- /* copy sr to frame buffer */ - - movel sp,_superStack /* save supervisor sp */ - - andiw #0x2000,d1 /* were we in supervisor mode ? */ - beq userMode - movel a7,a5@(60) /* save a7 */ - bra saveDone -userMode: - movel usp,a1 /* save user stack pointer */ - movel a1,a5@(60) /* save user stack pointer */ -saveDone: - - movew d3,a0@- /* push frame size in words */ - movel d2,a0@- /* push vector number */ - movel a4,a0@- /* push exception pc */ - -# -# save old frame link and set the new value - movel _lastFrame,a1 /* last frame pointer */ - movel a1,a0@- /* save pointer to prev frame */ - movel a0,_lastFrame - - movel d2,sp@- /* push exception num */ - movel _exceptionHook,a0 /* get address of handler */ - jbsr a0@ /* and call it */ - clrl sp@ /* replace exception num parm with frame ptr */ - jbsr __returnFromException /* jbsr, but never returns */ -"); -#endif - - -/* - * remcomHandler is a front end for handle_exception. It moves the - * stack pointer into an area reserved for debugger use in case the - * breakpoint happened in supervisor mode. - */ -asm("_remcomHandler:"); -asm(" addl #4,sp"); /* pop off return address */ -asm(" movel sp@+,d0"); /* get the exception number */ -asm(" movel _stackPtr,sp"); /* move to remcom stack area */ -asm(" movel d0,sp@-"); /* push exception onto stack */ -asm(" jbsr _handle_exception"); /* this never returns */ -asm(" rts"); /* return */ - -void _returnFromException( Frame *frame ) -{ - /* if no passed in frame, use the last one */ - if (! frame) - { - frame = lastFrame; - frame->frameSize = 4; - frame->format = 0; - frame->fsaveHeader = -1; /* restore regs, but we dont have fsave info*/ - } - -#ifndef mc68020 - /* a 68000 cannot use the internal info pushed onto a bus error - * or address error frame when doing an RTE so don't put this info - * onto the stack or the stack will creep every time this happens. - */ - frame->frameSize=3; -#endif - - /* throw away any frames in the list after this frame */ - lastFrame = frame; - - frame->sr = registers[(int) PS]; - frame->pc = registers[(int) PC]; - - if (registers[(int) PS] & 0x2000) - { - /* return to supervisor mode... */ - return_to_super(); - } - else - { /* return to user mode */ - return_to_user(); - } -} - -int hex(ch) -char ch; -{ - if ((ch >= 'a') && (ch <= 'f')) return (ch-'a'+10); - if ((ch >= '0') && (ch <= '9')) return (ch-'0'); - if ((ch >= 'A') && (ch <= 'F')) return (ch-'A'+10); - return (-1); -} - - -/* scan for the sequence $# */ -void getpacket(buffer) -char * buffer; -{ - unsigned char checksum; - unsigned char xmitcsum; - int i; - int count; - char ch; - - do { - /* wait around for the start character, ignore all other characters */ - while ((ch = getDebugChar()) != '$'); - checksum = 0; - xmitcsum = -1; - - count = 0; - - /* now, read until a # or end of buffer is found */ - while (count < BUFMAX) { - ch = getDebugChar(); - if (ch == '#') break; - checksum = checksum + ch; - buffer[count] = ch; - count = count + 1; - } - buffer[count] = 0; - - if (ch == '#') { - xmitcsum = hex(getDebugChar()) << 4; - xmitcsum += hex(getDebugChar()); - if ((remote_debug ) && (checksum != xmitcsum)) { - fprintf(stderr,"bad checksum. My count = 0x%x, sent=0x%x. buf=%s\n", - checksum,xmitcsum,buffer); - } - - if (checksum != xmitcsum) putDebugChar('-'); /* failed checksum */ - else { - putDebugChar('+'); /* successful transfer */ - /* if a sequence char is present, reply the sequence ID */ - if (buffer[2] == ':') { - putDebugChar( buffer[0] ); - putDebugChar( buffer[1] ); - /* remove sequence chars from buffer */ - count = strlen(buffer); - for (i=3; i <= count; i++) buffer[i-3] = buffer[i]; - } - } - } - } while (checksum != xmitcsum); - -} - -/* send the packet in buffer. The host get's one chance to read it. - This routine does not wait for a positive acknowledge. */ - - -void putpacket(buffer) -char * buffer; -{ - unsigned char checksum; - int count; - char ch; - - /* $#. */ - do { - putDebugChar('$'); - checksum = 0; - count = 0; - - while (ch=buffer[count]) { - if (! putDebugChar(ch)) return; - checksum += ch; - count += 1; - } - - putDebugChar('#'); - putDebugChar(hexchars[checksum >> 4]); - putDebugChar(hexchars[checksum % 16]); - - } while (1 == 0); /* (getDebugChar() != '+'); */ - -} - -char remcomInBuffer[BUFMAX]; -char remcomOutBuffer[BUFMAX]; -static short error; - - -void debug_error(format, parm) -char * format; -char * parm; -{ - if (remote_debug) fprintf(stderr,format,parm); -} - -/* convert the memory pointed to by mem into hex, placing result in buf */ -/* return a pointer to the last char put in buf (null) */ -char* mem2hex(mem, buf, count) -char* mem; -char* buf; -int count; -{ - int i; - unsigned char ch; - for (i=0;i> 4]; - *buf++ = hexchars[ch % 16]; - } - *buf = 0; - return(buf); -} - -/* convert the hex array pointed to by buf into binary to be placed in mem */ -/* return a pointer to the character AFTER the last byte written */ -char* hex2mem(buf, mem, count) -char* buf; -char* mem; -int count; -{ - int i; - unsigned char ch; - for (i=0;i=0) - { - *intValue = (*intValue <<4) | hexValue; - numChars ++; - } - else - break; - - (*ptr)++; - } - - return (numChars); -} - -/* - * This function does all command procesing for interfacing to gdb. - */ -void handle_exception(int exceptionVector) -{ - int sigval; - int addr, length; - char * ptr; - int newPC; - Frame *frame; - - if (remote_debug) printf("vector=%d, sr=0x%x, pc=0x%x\n", - exceptionVector, - registers[ PS ], - registers[ PC ]); - - /* reply to host that an exception has occurred */ - sigval = computeSignal( exceptionVector ); - remcomOutBuffer[0] = 'S'; - remcomOutBuffer[1] = hexchars[sigval >> 4]; - remcomOutBuffer[2] = hexchars[sigval % 16]; - remcomOutBuffer[3] = 0; - - putpacket(remcomOutBuffer); - - while (1==1) { - error = 0; - remcomOutBuffer[0] = 0; - getpacket(remcomInBuffer); - switch (remcomInBuffer[0]) { - case '?' : remcomOutBuffer[0] = 'S'; - remcomOutBuffer[1] = hexchars[sigval >> 4]; - remcomOutBuffer[2] = hexchars[sigval % 16]; - remcomOutBuffer[3] = 0; - break; - case 'd' : remote_debug = !(remote_debug); /* toggle debug flag */ - break; - case 'g' : /* return the value of the CPU registers */ - mem2hex((char*) registers, remcomOutBuffer, NUMREGBYTES); - break; - case 'G' : /* set the value of the CPU registers - return OK */ - hex2mem(&remcomInBuffer[1], (char*) registers, NUMREGBYTES); - strcpy(remcomOutBuffer,"OK"); - break; - - /* mAA..AA,LLLL Read LLLL bytes at address AA..AA */ - case 'm' : - if (setjmp(remcomEnv) == 0) - { - exceptionHandler(2,handle_buserror); - - /* TRY TO READ %x,%x. IF SUCCEED, SET PTR = 0 */ - ptr = &remcomInBuffer[1]; - if (hexToInt(&ptr,&addr)) - if (*(ptr++) == ',') - if (hexToInt(&ptr,&length)) - { - ptr = 0; - mem2hex((char*) addr, remcomOutBuffer, length); - } - - if (ptr) - { - strcpy(remcomOutBuffer,"E01"); - debug_error("malformed read memory command: %s",remcomInBuffer); - } - } - else { - exceptionHandler(2,_catchException); - strcpy(remcomOutBuffer,"E03"); - debug_error("bus error"); - } - - /* restore handler for bus error */ - exceptionHandler(2,_catchException); - break; - - /* MAA..AA,LLLL: Write LLLL bytes at address AA.AA return OK */ - case 'M' : - if (setjmp(remcomEnv) == 0) { - exceptionHandler(2,handle_buserror); - - /* TRY TO READ '%x,%x:'. IF SUCCEED, SET PTR = 0 */ - ptr = &remcomInBuffer[1]; - if (hexToInt(&ptr,&addr)) - if (*(ptr++) == ',') - if (hexToInt(&ptr,&length)) - if (*(ptr++) == ':') - { - hex2mem(ptr, (char*) addr, length); - ptr = 0; - strcpy(remcomOutBuffer,"OK"); - } - if (ptr) - { - strcpy(remcomOutBuffer,"E02"); - debug_error("malformed write memory command: %s",remcomInBuffer); - } - } - else { - exceptionHandler(2,_catchException); - strcpy(remcomOutBuffer,"E03"); - debug_error("bus error"); - } - - /* restore handler for bus error */ - exceptionHandler(2,_catchException); - break; - - /* cAA..AA Continue at address AA..AA(optional) */ - /* sAA..AA Step one instruction from AA..AA(optional) */ - case 'c' : - case 's' : - /* try to read optional parameter, pc unchanged if no parm */ - ptr = &remcomInBuffer[1]; - if (hexToInt(&ptr,&addr)) - registers[ PC ] = addr; - - newPC = registers[ PC]; - - /* clear the trace bit */ - registers[ PS ] &= 0x7fff; - - /* set the trace bit if we're stepping */ - if (remcomInBuffer[0] == 's') registers[ PS ] |= 0x8000; - - /* - * look for newPC in the linked list of exception frames. - * if it is found, use the old frame it. otherwise, - * fake up a dummy frame in returnFromException(). - */ - if (remote_debug) printf("new pc = 0x%x\n",newPC); - frame = lastFrame; - while (frame) - { - if (remote_debug) - printf("frame at 0x%x has pc=0x%x, except#=%d\n", - frame,frame->exceptionPC, - frame->exceptionVector); - if (frame->exceptionPC == newPC) break; /* bingo! a match */ - /* - * for a breakpoint instruction, the saved pc may - * be off by two due to re-executing the instruction - * replaced by the trap instruction. Check for this. - */ - if ((frame->exceptionVector == 33) && - (frame->exceptionPC == (newPC+2))) break; - if (frame == frame->previous) - { - frame = 0; /* no match found */ - break; - } - frame = frame->previous; - } - - /* - * If we found a match for the PC AND we are not returning - * as a result of a breakpoint (33), - * trace exception (9), nmi (31), jmp to - * the old exception handler as if this code never ran. - */ - if (frame) - { - if ((frame->exceptionVector != 9) && - (frame->exceptionVector != 31) && - (frame->exceptionVector != 33)) - { - /* - * invoke the previous handler. - */ - if (oldExceptionHook) - (*oldExceptionHook) (frame->exceptionVector); - newPC = registers[ PC ]; /* pc may have changed */ - if (newPC != frame->exceptionPC) - { - if (remote_debug) - printf("frame at 0x%x has pc=0x%x, except#=%d\n", - frame,frame->exceptionPC, - frame->exceptionVector); - /* re-use the last frame, we're skipping it (longjump?)*/ - frame = (Frame *) 0; - _returnFromException( frame ); /* this is a jump */ - } - } - } - - /* if we couldn't find a frame, create one */ - if (frame == 0) - { - frame = lastFrame -1 ; - - /* by using a bunch of print commands with breakpoints, - it's possible for the frame stack to creep down. If it creeps - too far, give up and reset it to the top. Normal use should - not see this happen. - */ - if ((unsigned int) (frame-2) < (unsigned int) &gdbFrameStack) - { - initializeRemcomErrorFrame(); - frame = lastFrame; - } - frame->previous = lastFrame; - lastFrame = frame; - frame = 0; /* null so _return... will properly initialize it */ - } - - _returnFromException( frame ); /* this is a jump */ - - break; - - /* kill the program */ - case 'k' : /* do nothing */ - break; - } /* switch */ - - /* reply to the request */ - putpacket(remcomOutBuffer); - } -} - - -void initializeRemcomErrorFrame(void) -{ - lastFrame = ((Frame *) &gdbFrameStack[FRAMESIZE-1]) - 1; - lastFrame->previous = lastFrame; -} - -/* this function is used to set up exception handlers for tracing and - breakpoints */ -void set_debug_traps() -{ -extern void _debug_level7(); -extern void remcomHandler(); -int exception; - - initializeRemcomErrorFrame(); - stackPtr = &remcomStack[STACKSIZE/sizeof(int) - 1]; - - for (exception = 2; exception <= 23; exception++) - exceptionHandler(exception,_catchException); - - /* level 7 interrupt */ - exceptionHandler(31,_debug_level7); - - /* breakpoint exception (trap #1) */ - exceptionHandler(33,_catchException); - - /* floating point error (trap #8) */ - exceptionHandler(40,_catchException); - - /* 48 to 54 are floating point coprocessor errors */ - for (exception = 48; exception <= 54; exception++) - exceptionHandler(exception,_catchException); - - if (oldExceptionHook != remcomHandler) - { - oldExceptionHook = exceptionHook; - exceptionHook = remcomHandler; - } - - initialized = 1; - -} - -/* This function will generate a breakpoint exception. It is used at the - beginning of a program to sync up with a debugger and can be used - otherwise as a quick means to stop program execution and "break" into - the debugger. */ - -void breakpoint() -{ - if (initialized) BREAKPOINT(); -} - diff --git a/gdb/m68k-tdep.c b/gdb/m68k-tdep.c deleted file mode 100644 index 240871850db..00000000000 --- a/gdb/m68k-tdep.c +++ /dev/null @@ -1,337 +0,0 @@ -/* Target dependent code for the Motorola 68000 series. - Copyright (C) 1990 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include "defs.h" -#include "ieee-float.h" -#include "param.h" -#include "frame.h" -#include "symtab.h" - -const struct ext_format ext_format_68881 = { -/* tot sbyte smask expbyte manbyte */ - 12, 0, 0x80, 0,1, 4,8 /* mc68881 */ -}; - - -/* Things needed for making the inferior call functions. - It seems like every m68k based machine has almost identical definitions - in the individual machine's configuration files. Most other cpu types - (mips, i386, etc) have routines in their *-tdep.c files to handle this - for most configurations. The m68k family should be able to do this as - well. These macros can still be overridden when necessary. */ - -/* Push an empty stack frame, to record the current PC, etc. */ - -void -m68k_push_dummy_frame () -{ - register CORE_ADDR sp = read_register (SP_REGNUM); - register int regnum; - char raw_buffer[12]; - - sp = push_word (sp, read_register (PC_REGNUM)); - sp = push_word (sp, read_register (FP_REGNUM)); - write_register (FP_REGNUM, sp); -#if defined (HAVE_68881) - for (regnum = FP0_REGNUM + 7; regnum >= FP0_REGNUM; regnum--) - { - read_register_bytes (REGISTER_BYTE (regnum), raw_buffer, 12); - sp = push_bytes (sp, raw_buffer, 12); - } -#endif - for (regnum = FP_REGNUM - 1; regnum >= 0; regnum--) - { - sp = push_word (sp, read_register (regnum)); - } - sp = push_word (sp, read_register (PS_REGNUM)); - write_register (SP_REGNUM, sp); -} - -/* Discard from the stack the innermost frame, - restoring all saved registers. */ - -void -m68k_pop_frame () -{ - register FRAME frame = get_current_frame (); - register CORE_ADDR fp; - register int regnum; - struct frame_saved_regs fsr; - struct frame_info *fi; - char raw_buffer[12]; - - fi = get_frame_info (frame); - fp = fi -> frame; - get_frame_saved_regs (fi, &fsr); -#if defined (HAVE_68881) - for (regnum = FP0_REGNUM + 7 ; regnum >= FP0_REGNUM ; regnum--) - { - if (fsr.regs[regnum]) - { - read_memory (fsr.regs[regnum], raw_buffer, 12); - write_register_bytes (REGISTER_BYTE (regnum), raw_buffer, 12); - } - } -#endif - for (regnum = FP_REGNUM - 1 ; regnum >= 0 ; regnum--) - { - if (fsr.regs[regnum]) - { - write_register (regnum, read_memory_integer (fsr.regs[regnum], 4)); - } - } - if (fsr.regs[PS_REGNUM]) - { - write_register (PS_REGNUM, read_memory_integer (fsr.regs[PS_REGNUM], 4)); - } - write_register (FP_REGNUM, read_memory_integer (fp, 4)); - write_register (PC_REGNUM, read_memory_integer (fp + 4, 4)); - write_register (SP_REGNUM, fp + 8); - flush_cached_frames (); - set_current_frame (create_new_frame (read_register (FP_REGNUM), - read_pc ())); -} - - -/* Given an ip value corresponding to the start of a function, - return the ip of the first instruction after the function - prologue. This is the generic m68k support. Machines which - require something different can override the SKIP_PROLOGUE - macro to point elsewhere. - - Some instructions which typically may appear in a function - prologue include: - - A link instruction, word form: - - link.w %a6,&0 4e56 XXXX - - A link instruction, long form: - - link.l %fp,&F%1 480e XXXX XXXX - - A movm instruction to preserve integer regs: - - movm.l &M%1,(4,%sp) 48ef XXXX XXXX - - A fmovm instruction to preserve float regs: - - fmovm &FPM%1,(FPO%1,%sp) f237 XXXX XXXX XXXX XXXX - - Some profiling setup code (FIXME, not recognized yet): - - lea.l (.L3,%pc),%a1 43fb XXXX XXXX XXXX - bsr _mcount 61ff XXXX XXXX - - */ - -#define P_LINK_L 0x480e -#define P_LINK_W 0x4e56 -#define P_MOV_L 0x207c -#define P_JSR 0x4eb9 -#define P_BSR 0x61ff -#define P_LEA_L 0x43fb -#define P_MOVM_L 0x48ef -#define P_FMOVM 0xf237 - -CORE_ADDR -m68k_skip_prologue (ip) -CORE_ADDR ip; -{ - register CORE_ADDR limit; - struct symtab_and_line sal; - register int op; - - /* Find out if there is a known limit for the extent of the prologue. - If so, ensure we don't go past it. If not, assume "infinity". */ - - sal = find_pc_line (ip, 0); - limit = (sal.end) ? sal.end : (CORE_ADDR) ~0; - - while (ip < limit) - { - op = read_memory_integer (ip, 2); - op &= 0xFFFF; - - if (op == P_LINK_W) - { - ip += 4; /* Skip link.w */ - } - else if (op == P_LINK_L) - { - ip += 6; /* Skip link.l */ - } - else if (op == P_MOVM_L) - { - ip += 6; /* Skip movm.l */ - } - else if (op == P_FMOVM) - { - ip += 10; /* Skip fmovm */ - } - else - { - break; /* Found unknown code, bail out. */ - } - } - return (ip); -} - -#ifdef USE_PROC_FS /* Target dependent support for /proc */ - -#include - -/* The /proc interface divides the target machine's register set up into - two different sets, the general register set (gregset) and the floating - point register set (fpregset). For each set, there is an ioctl to get - the current register set and another ioctl to set the current values. - - The actual structure passed through the ioctl interface is, of course, - naturally machine dependent, and is different for each set of registers. - For the m68k for example, the general register set is typically defined - by: - - typedef int gregset_t[18]; - - #define R_D0 0 - ... - #define R_PS 17 - - and the floating point set by: - - typedef struct fpregset { - int f_pcr; - int f_psr; - int f_fpiaddr; - int f_fpregs[8][3]; (8 regs, 96 bits each) - } fpregset_t; - - These routines provide the packing and unpacking of gregset_t and - fpregset_t formatted data. - - */ - - -/* Given a pointer to a general register set in /proc format (gregset_t *), - unpack the register contents and supply them as gdb's idea of the current - register values. */ - -void -supply_gregset (gregsetp) -gregset_t *gregsetp; -{ - register int regno; - register greg_t *regp = (greg_t *) gregsetp; - - for (regno = 0 ; regno < R_PC ; regno++) - { - supply_register (regno, (char *) (regp + regno)); - } - supply_register (PS_REGNUM, (char *) (regp + R_PS)); - supply_register (PC_REGNUM, (char *) (regp + R_PC)); -} - -void -fill_gregset (gregsetp, regno) -gregset_t *gregsetp; -int regno; -{ - int regi; - register greg_t *regp = (greg_t *) gregsetp; - extern char registers[]; - - for (regi = 0 ; regi < R_PC ; regi++) - { - if ((regno == -1) || (regno == regi)) - { - *(regp + regno) = *(int *) ®isters[REGISTER_BYTE (regi)]; - } - } - if ((regno == -1) || (regno == PS_REGNUM)) - { - *(regp + R_PS) = *(int *) ®isters[REGISTER_BYTE (PS_REGNUM)]; - } - if ((regno == -1) || (regno == PC_REGNUM)) - { - *(regp + R_PC) = *(int *) ®isters[REGISTER_BYTE (PC_REGNUM)]; - } -} - -#if defined (FP0_REGNUM) - -/* Given a pointer to a floating point register set in /proc format - (fpregset_t *), unpack the register contents and supply them as gdb's - idea of the current floating point register values. */ - -void -supply_fpregset (fpregsetp) -fpregset_t *fpregsetp; -{ - register int regno; - - for (regno = FP0_REGNUM ; regno < FPC_REGNUM ; regno++) - { - supply_register (regno, (char *) &(fpregsetp -> f_fpregs[regno][0])); - } - supply_register (FPC_REGNUM, (char *) &(fpregsetp -> f_pcr)); - supply_register (FPS_REGNUM, (char *) &(fpregsetp -> f_psr)); - supply_register (FPI_REGNUM, (char *) &(fpregsetp -> f_fpiaddr)); -} - -/* Given a pointer to a floating point register set in /proc format - (fpregset_t *), update the register specified by REGNO from gdb's idea - of the current floating point register set. If REGNO is -1, update - them all. */ - -void -fill_fpregset (fpregsetp, regno) -fpregset_t *fpregsetp; -int regno; -{ - int regi; - char *to; - char *from; - extern char registers[]; - - for (regi = FP0_REGNUM ; regi < FPC_REGNUM ; regi++) - { - if ((regno == -1) || (regno == regi)) - { - from = (char *) ®isters[REGISTER_BYTE (regi)]; - to = (char *) &(fpregsetp -> f_fpregs[regi][0]); - bcopy (from, to, REGISTER_RAW_SIZE (regno)); - } - } - if ((regno == -1) || (regno == FPC_REGNUM)) - { - fpregsetp -> f_pcr = *(int *) ®isters[REGISTER_BYTE (FPC_REGNUM)]; - } - if ((regno == -1) || (regno == FPS_REGNUM)) - { - fpregsetp -> f_psr = *(int *) ®isters[REGISTER_BYTE (FPS_REGNUM)]; - } - if ((regno == -1) || (regno == FPI_REGNUM)) - { - fpregsetp -> f_fpiaddr = *(int *) ®isters[REGISTER_BYTE (FPI_REGNUM)]; - } -} - -#endif /* defined (FP0_REGNUM) */ - -#endif /* USE_PROC_FS */ diff --git a/gdb/m88k-opcode.h b/gdb/m88k-opcode.h deleted file mode 100755 index c5e643a1ff9..00000000000 --- a/gdb/m88k-opcode.h +++ /dev/null @@ -1,585 +0,0 @@ -/* This file has been modified by Data General Corporation, November 1989. */ - - -/* -* Disassembler Instruction Table -* -* The first field of the table is the opcode field. If an opcode -* is specified which has any non-opcode bits on, a system error -* will occur when the system attempts the install it into the -* instruction table. The second parameter is a pointer to the -* instruction mnemonic. Each operand is specified by offset, width, -* and type. The offset is the bit number of the least significant -* bit of the operand with bit 0 being the least significant bit of -* the instruction. The width is the number of bits used to specify -* the operand. The type specifies the output format to be used for -* the operand. The valid formats are: register, register indirect, -* hex constant, and bit field specification. The last field is a -* pointer to the next instruction in the linked list. These pointers -* are initialized by init_disasm(). -* -* Structure Format -* -* struct INSTAB { -* UPINT opcode; -* char *mnemonic; -* struct OPSPEC op1,op2,op3; -* struct SIM_FLAGS flgs; -* struct INSTAB *next; -* } -* -* struct OPSPEC { -* UPINT offset:5; -* UPINT width:6; -* UPINT type:5; -* } -* -* Revision History -* -* Revision 1.0 11/08/85 Creation date -* 1.1 02/05/86 Updated instruction mnemonic table MD -* 1.2 06/16/86 Updated SIM_FLAGS for floating point -* 1.3 09/20/86 Updated for new encoding -* 05/11/89 R. Trawick adapted from Motorola disassembler -*/ - -#include - - -/* - * This file contains the structures and constants needed to build the M88000 - * simulator. It is the main include file, containing all the - * structures, macros and definitions except for the floating point - * instruction set. - */ - -/* - * The following flag informs the Simulator as to what type of byte ordering - * will be used. For instance, a BOFLAG = 1 indicates a DEC VAX and IBM type - * of ordering shall be used. -*/ - -/* # define BOFLAG 1 /* BYTE ORDERING FLAG */ - -/* define the number of bits in the primary opcode field of the instruction, - * the destination field, the source 1 and source 2 fields. - */ -# define OP 8 /* size of opcode field */ -# define DEST 6 /* size of destination */ -# define SOURCE1 6 /* size of source1 */ -# define SOURCE2 6 /* size of source2 */ - -# define REGs 32 /* number of registers */ - -# define WORD long -# define FLAG unsigned -# define STATE short - -# define TRUE 1 -# define FALSE 0 - -# define READ 0 -# define WRITE 1 - -/* The next four equates define the priorities that the various classes - * of instructions have regarding writing results back into registers and - * signalling exceptions. - */ - -# define PINT 0 /* Integer Priority */ -# define PFLT 1 /* Floating Point Priority */ -# define PMEM 2 /* Memory Priority */ -# define NA 3 /* Not Applicable, instruction doesnt write to regs */ -# define HIPRI 3 /* highest of these priorities */ - -/* The instruction registers are an artificial mechanism to speed up - * simulator execution. In the real processor, an instruction register - * is 32 bits wide. In the simulator, the 32 bit instruction is kept in - * a structure field called rawop, and the instruction is partially decoded, - * and split into various fields and flags which make up the other fields - * of the structure. - * The partial decode is done when the instructions are initially loaded - * into simulator memory. The simulator code memory is not an array of - * 32 bit words, but is an array of instruction register structures. - * Yes this wastes memory, but it executes much quicker. - */ - -struct IR_FIELDS { - unsigned long op:OP, - dest: DEST, - src1: SOURCE1, - src2: SOURCE2; - int ltncy, - extime, - wb_pri; /* writeback priority */ - unsigned short imm_flags:2,/* immediate size */ - rs1_used:1, /* register source 1 used */ - rs2_used:1, /* register source 2 used */ - rsd_used:1, /* register source/dest. used */ - c_flag:1, /* complement */ - u_flag:1, /* upper half word */ - n_flag:1, /* execute next */ - wb_flag:1, /* uses writeback slot */ - dest_64:1, /* dest size */ - s1_64:1, /* source 1 size */ - s2_64:1, /* source 2 size */ - scale_flag:1, /* scaled register */ - brk_flg:1; - }; - -struct mem_segs { - struct mem_wrd *seg; /* pointer (returned by calloc) to segment */ - unsigned long baseaddr; /* base load address from file headers */ - unsigned long endaddr; /* Ending address of segment */ - int flags; /* segment control flags (none defined 12/5/86) */ -}; - -#define MAXSEGS (10) /* max number of segment allowed */ -#define MEMSEGSIZE (sizeof(struct mem_segs))/* size of mem_segs structure */ - - -#define BRK_RD (0x01) /* break on memory read */ -#define BRK_WR (0x02) /* break on memory write */ -#define BRK_EXEC (0x04) /* break on execution */ -#define BRK_CNT (0x08) /* break on terminal count */ - - -struct mem_wrd { - struct IR_FIELDS opcode; /* simulator instruction break down */ - union { - unsigned long l; /* memory element break down */ - unsigned short s[2]; - unsigned char c[4]; - } mem; -}; - -#define MEMWRDSIZE (sizeof(struct mem_wrd)) /* size of each 32 bit memory model */ - -/* External declarations */ - -extern struct mem_segs memory[]; -extern struct PROCESSOR m78000; - -struct PROCESSOR { - unsigned WORD - ip, /* execute instruction pointer */ - vbr, /* vector base register */ - psr; /* processor status register */ - - WORD S1bus, /* source 1 */ - S2bus, /* source 2 */ - Dbus, /* destination */ - DAbus, /* data address bus */ - ALU, - Regs[REGs], /* data registers */ - time_left[REGs], /* max clocks before reg is available */ - wb_pri[REGs], /* writeback priority of reg */ - SFU0_regs[REGs], /* integer unit control regs */ - SFU1_regs[REGs], /* floating point control regs */ - Scoreboard[REGs], - Vbr; - unsigned WORD scoreboard, - Psw, - Tpsw; - FLAG jump_pending:1; /* waiting for a jump instr. */ - }; - -# define i26bit 1 /* size of immediate field */ -# define i16bit 2 -# define i10bit 3 - -/* Definitions for fields in psr */ - -# define mode 31 -# define rbo 30 -# define ser 29 -# define carry 28 -# define sf7m 11 -# define sf6m 10 -# define sf5m 9 -# define sf4m 8 -# define sf3m 7 -# define sf2m 6 -# define sf1m 5 -# define mam 4 -# define inm 3 -# define exm 2 -# define trm 1 -# define ovfm 0 - -#define MODEMASK (1<<(mode-1)) -# define SILENT 0 /* simulate without output to crt */ -# define VERBOSE 1 /* simulate in verbose mode */ -# define PR_INSTR 2 /* only print instructions */ - -# define RESET 16 /* reset phase */ - -# define PHASE1 0 /* data path phases */ -# define PHASE2 1 - -/* the 1 clock operations */ - -# define ADDU 1 -# define ADDC 2 -# define ADDUC 3 -# define ADD 4 - -# define SUBU ADD+1 -# define SUBB ADD+2 -# define SUBUB ADD+3 -# define SUB ADD+4 - -# define AND ADD+5 -# define OR ADD+6 -# define XOR ADD+7 -# define CMP ADD+8 - -/* the LOADS */ - -# define LDAB CMP+1 -# define LDAH CMP+2 -# define LDA CMP+3 -# define LDAD CMP+4 - -# define LDB LDAD+1 -# define LDH LDAD+2 -# define LD LDAD+3 -# define LDD LDAD+4 -# define LDBU LDAD+5 -# define LDHU LDAD+6 - -/* the STORES */ - -# define STB LDHU+1 -# define STH LDHU+2 -# define ST LDHU+3 -# define STD LDHU+4 - -/* the exchange */ - -# define XMEMBU LDHU+5 -# define XMEM LDHU+6 - -/* the branches */ -# define JSR STD+1 -# define BSR STD+2 -# define BR STD+3 -# define JMP STD+4 -# define BB1 STD+5 -# define BB0 STD+6 -# define RTN STD+7 -# define BCND STD+8 - -/* the TRAPS */ -# define TB1 BCND+1 -# define TB0 BCND+2 -# define TCND BCND+3 -# define RTE BCND+4 -# define TBND BCND+5 - -/* the MISC instructions */ -# define MUL TBND + 1 -# define DIV MUL +2 -# define DIVU MUL +3 -# define MASK MUL +4 -# define FF0 MUL +5 -# define FF1 MUL +6 -# define CLR MUL +7 -# define SET MUL +8 -# define EXT MUL +9 -# define EXTU MUL +10 -# define MAK MUL +11 -# define ROT MUL +12 - -/* control register manipulations */ - -# define LDCR ROT +1 -# define STCR ROT +2 -# define XCR ROT +3 - -# define FLDCR ROT +4 -# define FSTCR ROT +5 -# define FXCR ROT +6 - - -# define NOP XCR +1 - -/* floating point instructions */ - -# define FADD NOP +1 -# define FSUB NOP +2 -# define FMUL NOP +3 -# define FDIV NOP +4 -# define FSQRT NOP +5 -# define FCMP NOP +6 -# define FIP NOP +7 -# define FLT NOP +8 -# define INT NOP +9 -# define NINT NOP +10 -# define TRNC NOP +11 -# define FLDC NOP +12 -# define FSTC NOP +13 -# define FXC NOP +14 - -# define UEXT(src,off,wid) ((((unsigned int)(src))>>(off)) & ((1<<(wid)) - 1)) -# define SEXT(src,off,wid) (((((int)(src))<<(32-((off)+(wid)))) >>(32-(wid))) ) -# define MAKE(src,off,wid) \ - ((((unsigned int)(src)) & ((1<<(wid)) - 1)) << (off)) - -# define opword(n) (unsigned long) (memaddr->mem.l) - -/* Constants and Masks */ - -#define SFU0 0x80000000 -#define SFU1 0x84000000 -#define SFU7 0x9c000000 -#define RRI10 0xf0000000 -#define RRR 0xf4000000 -#define SFUMASK 0xfc00ffe0 -#define RRRMASK 0xfc00ffe0 -#define RRI10MASK 0xfc00fc00 -#define DEFMASK 0xfc000000 -#define CTRL 0x0000f000 -#define CTRLMASK 0xfc00f800 - -/* Operands types */ - -#define HEX 1 -#define REG 2 -#define IND 3 -#define CONT 3 -#define IND 3 -#define BF 4 -#define REGSC 5 /* scaled register */ -#define CRREG 6 /* control register */ -#define FCRREG 7 /* floating point control register */ -#define PCREL 8 -#define CONDMASK 9 - -/* Hashing Specification */ - -#define HASHVAL 79 - -/* Type definitions */ - -typedef unsigned int UINT; - -/* Structure templates */ - -typedef struct { - unsigned int offset:5; - unsigned int width:6; - unsigned int type:5; -} OPSPEC; - - struct SIM_FLAGS { - int ltncy, /* latency (max number of clocks needed to execute) */ - extime, /* execution time (min number of clocks needed to execute) */ - wb_pri; /* writeback slot priority */ - unsigned long op:OP, /* simulator version of opcode */ - imm_flags:2, /* 10,16 or 26 bit immediate flags */ - rs1_used:1, /* register source 1 used */ - rs2_used:1, /* register source 2 used */ - rsd_used:1, /* register source/dest used */ - c_flag:1, /* complement */ - u_flag:1, /* upper half word */ - n_flag:1, /* execute next */ - wb_flag:1, /* uses writeback slot */ - dest_64:1, /* double precision dest */ - s1_64:1, /* double precision source 1 */ - s2_64:1, /* double precision source 2 */ - scale_flag:1; /* register is scaled */ -}; - -typedef struct INSTRUCTAB { - unsigned int opcode; - char *mnemonic; - OPSPEC op1,op2,op3; - struct SIM_FLAGS flgs; - struct INSTRUCTAB *next; -} INSTAB; - - -/* Opcode Mnemonic Op 1 Spec Op 2 Spec Op 3 Spec Simflags Next */ - -static INSTAB instructions[] = -{0xf400c800,"jsr ",{0,5,REG} ,{0,0,0} ,{0,0,0} , {2,2,NA,JSR , 0,0,1,0,0,0,0,1,0,0,0,0}, NULL, - 0xf400cc00,"jsr.n ",{0,5,REG} ,{0,0,0} ,{0,0,0} , {1,1,NA,JSR , 0,0,1,0,0,0,1,1,0,0,0,0}, NULL, - 0xf400c000,"jmp ",{0,5,REG} ,{0,0,0} ,{0,0,0} , {2,2,NA,JMP , 0,0,1,0,0,0,0,1,0,0,0,0}, NULL, - 0xf400c400,"jmp.n ",{0,5,REG} ,{0,0,0} ,{0,0,0} , {1,1,NA,JMP , 0,0,1,0,0,0,1,1,0,0,0,0}, NULL, - 0xc8000000,"bsr ",{0,26,PCREL},{0,0,0} ,{0,0,0} , {2,2,NA,BSR , i26bit,0,0,0,0,0,0,1,0,0,0,0}, NULL, - 0xcc000000,"bsr.n ",{0,26,PCREL},{0,0,0} ,{0,0,0} , {1,1,NA,BSR , i26bit,0,0,0,0,0,1,1,0,0,0,0}, NULL, - 0xc0000000,"br ",{0,26,PCREL},{0,0,0} ,{0,0,0} , {2,2,NA,BR , i26bit,0,0,0,0,0,0,1,0,0,0,0}, NULL, - 0xc4000000,"br.n ",{0,26,PCREL},{0,0,0} ,{0,0,0} , {1,1,NA,BR , i26bit,0,0,0,0,0,1,1,0,0,0,0}, NULL, - 0xd0000000,"bb0 ",{21,5,HEX} ,{16,5,REG} ,{0,16,PCREL},{2,2,NA,BB0, i16bit,0,1,0,0,0,0,1,0,0,0,0}, NULL, - 0xd4000000,"bb0.n ",{21,5,HEX} ,{16,5,REG} ,{0,16,PCREL},{1,1,NA,BB0, i16bit,0,1,0,0,0,1,1,0,0,0,0}, NULL, - 0xd8000000,"bb1 ",{21,5,HEX},{16,5,REG} ,{0,16,PCREL},{2,2,NA,BB1, i16bit,0,1,0,0,0,0,1,0,0,0,0}, NULL, - 0xdc000000,"bb1.n ",{21,5,HEX},{16,5,REG} ,{0,16,PCREL},{1,1,NA,BB1, i16bit,0,1,0,0,0,1,1,0,0,0,0}, NULL, - 0xf000d000,"tb0 ",{21,5,HEX} ,{16,5,REG} ,{0,10,HEX}, {2,2,NA,TB0 , i10bit,0,1,0,0,0,0,1,0,0,0,0}, NULL, - 0xf000d800,"tb1 ",{21,5,HEX} ,{16,5,REG} ,{0,10,HEX}, {2,2,NA,TB1 , i10bit,0,1,0,0,0,0,1,0,0,0,0}, NULL, - 0xe8000000,"bcnd ",{21,5,CONDMASK},{16,5,REG},{0,16,PCREL},{2,2,NA,BCND, i16bit,0,1,0,0,0,0,1,0,0,0,0}, NULL, - 0xec000000,"bcnd.n ",{21,5,CONDMASK},{16,5,REG},{0,16,PCREL},{1,1,NA,BCND, i16bit,0,1,0,0,0,1,1,0,0,0,0}, NULL, - 0xf000e800,"tcnd ",{21,5,CONDMASK},{16,5,REG},{0,10,HEX}, {2,2,NA,TCND, i10bit,0,1,0,0,0,0,1,0,0,0,0}, NULL, - 0xf8000000,"tbnd ",{16,5,REG} ,{0,16,HEX} ,{0,0,0} , {2,2,NA,TBND, i10bit,1,0,0,0,0,0,1,0,0,0,0}, NULL, - 0xf400f800,"tbnd ",{16,5,REG} ,{0,5,REG} ,{0,0,0} , {2,2,NA,TBND, 0,1,1,0,0,0,0,1,0,0,0,0}, NULL, - 0xf400fc00,"rte ",{0,0,0} ,{0,0,0} ,{0,0,0} , {2,2,NA,RTE , 0,0,0,0,0,0,0,1,0,0,0,0}, NULL, - 0x1c000000,"ld.b ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {3,1,PMEM,LDB ,i16bit,1,0,1,0,0,0,1,0,0,0,0}, NULL, - 0xf4001c00,"ld.b ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {3,1,PMEM,LDB , 0,1,1,1,0,0,0,1,0,0,0,0}, NULL, - 0x0c000000,"ld.bu ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {3,1,PMEM,LDBU, i16bit,1,0,1,0,0,0,1,0,0,0,0}, NULL, - 0xf4000c00,"ld.bu ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {3,1,PMEM,LDBU ,0,1,1,1,0,0,0,1,0,0,0,0}, NULL, - 0x18000000,"ld.h ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {3,1,PMEM,LDH ,i16bit,1,0,1,0,0,0,1,0,0,0,0}, NULL, - 0xf4001800,"ld.h ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {3,1,PMEM,LDH ,0,1,1,1,0,0,0,1,0,0,0,0}, NULL, - 0xf4001a00,"ld.h ",{21,5,REG} ,{16,5,REG} ,{0,5,REGSC},{3,1,PMEM,LDH ,0,1,1,1,0,0,0,1,0,0,0,1}, NULL, - 0x08000000,"ld.hu ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {3,1,PMEM,LDHU, i16bit,1,0,1,0,0,0,1,0,0,0,0}, NULL, - 0xf4000800,"ld.hu ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {3,1,PMEM,LDHU ,0,1,1,1,0,0,0,1,0,0,0,0}, NULL, - 0xf4000a00,"ld.hu ",{21,5,REG} ,{16,5,REG} ,{0,5,REGSC},{3,1,PMEM,LDHU ,0,1,1,1,0,0,0,1,0,0,0,1}, NULL, - 0x14000000,"ld ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {3,1,PMEM,LD ,i16bit,1,0,1,0,0,0,1,0,0,0,0}, NULL, - 0xf4001400,"ld ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {3,1,PMEM,LD ,0,1,1,1,0,0,0,1,0,0,0,0}, NULL, - 0xf4001600,"ld ",{21,5,REG} ,{16,5,REG} ,{0,5,REGSC},{3,1,PMEM,LD ,0,1,1,1,0,0,0,1,0,0,0,1}, NULL, - 0x10000000,"ld.d ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {3,1,PMEM,LDD ,i16bit,1,0,1,0,0,0,1,0,0,0,0}, NULL, - 0xf4001000,"ld.d ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {3,1,PMEM,LDD ,0,1,1,1,0,0,0,1,0,0,0,0}, NULL, - 0xf4001200,"ld.d ",{21,5,REG} ,{16,5,REG} ,{0,5,REGSC},{3,1,PMEM,LDD ,0,1,1,1,0,0,0,1,0,0,0,1}, NULL, - 0xf4001500,"ld.usr ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {3,1,PMEM,LD ,0,1,1,1,0,0,0,1,0,0,0,0}, NULL, - 0xf4001700,"ld.usr ",{21,5,REG} ,{16,5,REG} ,{0,5,REGSC},{3,1,PMEM,LD ,0,1,1,1,0,0,0,1,0,0,0,1}, NULL, - 0x2c000000,"st.b ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {1,1,NA,STB ,i16bit,1,0,1,0,0,0,1,0,0,0,0}, NULL, - 0xf4002c00,"st.b ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,NA,STB ,0,1,1,1,0,0,0,1,0,0,0,0}, NULL, - 0x28000000,"st.h ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {1,1,NA,STH ,i16bit,1,0,1,0,0,0,1,0,0,0,0}, NULL, - 0xf4002800,"st.h ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,NA,STH ,0,1,1,1,0,0,0,1,0,0,0,0}, NULL, - 0xf4002a00,"st.h ",{21,5,REG} ,{16,5,REG} ,{0,5,REGSC},{1,1,NA,STH ,0,1,1,1,0,0,0,1,0,0,0,1}, NULL, - 0x24000000,"st ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {1,1,NA,ST ,i16bit,1,0,1,0,0,0,1,0,0,0,0}, NULL, - 0xf4002400,"st ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,NA,ST ,0,1,1,1,0,0,0,1,0,0,0,0} ,NULL, - 0xf4002600,"st ",{21,5,REG} ,{16,5,REG} ,{0,5,REGSC},{1,1,NA,ST ,0,1,1,1,0,0,0,1,0,0,0,1} ,NULL, - 0x20000000,"st.d ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {1,1,NA,STD ,i16bit,0,1,0,0,0,0,1,0,0,0,0} ,NULL, - 0xf4002000,"st.d ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,NA,STD ,0,1,1,1,0,0,0,1,0,0,0,0} ,NULL, - 0xf4002200,"st.d ",{21,5,REG} ,{16,5,REG} ,{0,5,REGSC},{1,1,NA,STD ,0,1,1,1,0,0,0,1,0,0,0,1} ,NULL, - 0xf4002500,"st.usr ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,NA,ST ,0,1,1,1,0,0,0,1,0,0,0,0} ,NULL, - 0xf4002700,"st.usr ",{21,5,REG} ,{16,5,REG} ,{0,5,REGSC},{1,1,NA,ST ,0,1,1,1,0,0,0,1,0,0,0,1} ,NULL, - 0x00000000,"xmem.bu ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {3,1,PMEM,XMEMBU ,i16bit,1,1,1,0,0,0,1,0,0,0,0} ,NULL, - 0xf4000000,"xmem.bu ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {3,1,PMEM,XMEM ,0,1,1,1,0,0,0,1,0,0,0,0} ,NULL, - 0x04000000,"xmem ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {3,1,PMEM,XMEM ,i16bit,1,1,1,0,0,0,1,0,0,0,0} ,NULL, - 0xf4000400,"xmem ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {3,1,PMEM,XMEM ,0,1,1,1,0,0,0,1,0,0,0,0} ,NULL, - 0xf4000600,"xmem ",{21,5,REG} ,{16,5,REG} ,{0,5,REGSC},{3,1,PMEM,XMEM ,0,1,1,1,0,0,0,1,0,0,0,1} ,NULL, - 0xf4000500,"xmem.usr ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {3,1,PMEM,XMEM ,0,1,1,1,0,0,0,1,0,0,0,0} ,NULL, - 0xf4000700,"xmem.usr ",{21,5,REG} ,{16,5,REG} ,{0,5,REGSC},{3,1,PMEM,XMEM ,0,1,1,1,0,0,0,1,0,0,0,1} ,NULL, - 0xf4003e00,"lda.b ",{21,5,REG} ,{16,5,REG} ,{0,5,REGSC},{1,1,PINT,LDAH, 0,1,1,1,0,0,0,0,0,0,0,1} ,NULL, - 0xf4003a00,"lda.h ",{21,5,REG} ,{16,5,REG} ,{0,5,REGSC},{1,1,PINT,LDAH, 0,1,1,1,0,0,0,0,0,0,0,1} ,NULL, - 0xf4003600,"lda ",{21,5,REG} ,{16,5,REG} ,{0,5,REGSC},{1,1,PINT,LDA , 0,1,1,1,0,0,0,0,0,0,0,1} ,NULL, - 0xf4003200,"lda.d ",{21,5,REG} ,{16,5,REG} ,{0,5,REGSC},{1,1,PINT,LDAD, 0,1,1,1,0,0,0,0,0,0,0,1} ,NULL, - - 0x80004000,"ldcr ",{21,5,REG} ,{5,6,CRREG} ,{0,0,0} ,{1,1,PINT,LDCR, 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0x80008000,"stcr ",{16,5,REG} ,{5,6,CRREG} ,{0,0,0} ,{1,1,PINT,STCR, 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0x8000c000,"xcr ",{21,5,REG} ,{16,5,REG} ,{5,6,CRREG},{1,1,PINT,XCR, 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - - 0xf4006000,"addu ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,ADDU, 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf4006200,"addu.ci ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,ADDU, 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf4006100,"addu.co ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,ADDU, 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf4006300,"addu.cio ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,ADDU, 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf4006400,"subu ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,SUBU, 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf4006600,"subu.ci ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,SUBU, 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf4006500,"subu.co ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,SUBU, 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf4006700,"subu.cio ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,SUBU, 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf4006900,"divu ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {32,32,PINT,DIVU, 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf4006d00,"mul ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,4,PINT,MUL, 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf4007000,"add ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,ADD , 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf4007200,"add.ci ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,ADD , 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf4007100,"add.co ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,ADD , 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf4007300,"add.cio ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,ADD , 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf4007400,"sub ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,SUB , 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf4007600,"sub.ci ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,SUB , 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf4007500,"sub.co ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,SUB , 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf4007700,"sub.cio ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,SUB , 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf4007900,"div ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {32,32,PINT,DIV , 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf4007d00,"cmp ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,CMP, 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - - 0x60000000,"addu ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {1,1,PINT,ADDU, i16bit,1,0,1,0,0,0,0,0,0,0,0} ,NULL, - 0x64000000,"subu ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {1,1,PINT,SUBU, i16bit,1,0,1,0,0,0,0,0,0,0,0} ,NULL, - - 0x68000000,"divu ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {32,32,PINT,DIVU, i16bit,1,0,1,0,0,0,0,0,0,0,0} ,NULL, - 0x6c000000,"mul ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {4,1,PINT,MUL, i16bit,1,0,1,0,0,0,0,0,0,0,0} ,NULL, - 0x70000000,"add ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {1,1,PINT,ADD, i16bit,1,0,1,0,0,0,0,0,0,0,0} ,NULL, - 0x74000000,"sub ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {1,1,PINT,SUB, i16bit,1,0,1,0,0,0,0,0,0,0,0} ,NULL, - 0x78000000,"div ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {32,32,PINT,DIV, i16bit,1,0,1,0,0,0,0,0,0,0,0} ,NULL, - 0x7c000000,"cmp ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {1,1,PINT,CMP, i16bit,1,0,1,0,0,0,0,0,0,0,0} ,NULL, - - 0xf4004000,"and ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,AND ,0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf4004400,"and.c ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,AND ,0,1,1,1,1,0,0,0,0,0,0,0} ,NULL, - 0xf4005800,"or ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,OR ,0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf4005c00,"or.c ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,OR ,0,1,1,1,1,0,0,0,0,0,0,0} ,NULL, - 0xf4005000,"xor ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,XOR ,0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf4005400,"xor.c ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,XOR ,0,1,1,1,1,0,0,0,0,0,0,0} ,NULL, - 0x40000000,"and ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {1,1,PINT,AND ,i16bit,1,0,1,0,0,0,0,0,0,0,0} ,NULL, - 0x44000000,"and.u ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {1,1,PINT,AND ,i16bit,1,0,1,0,1,0,0,0,0,0,0} ,NULL, - 0x58000000,"or ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {1,1,PINT,OR ,i16bit,1,0,1,0,0,0,0,0,0,0,0} ,NULL, - 0x5c000000,"or.u ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {1,1,PINT,OR ,i16bit,1,0,1,0,1,0,0,0,0,0,0} ,NULL, - 0x50000000,"xor ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {1,1,PINT,XOR ,i16bit,1,0,1,0,0,0,0,0,0,0,0} ,NULL, - 0x54000000,"xor.u ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {1,1,PINT,XOR ,i16bit,1,0,1,0,1,0,0,0,0,0,0} ,NULL, - 0x48000000,"mask ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {1,1,PINT,MASK ,i16bit,1,0,1,0,0,0,0,0,0,0,0} ,NULL, - 0x4c000000,"mask.u ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {1,1,PINT,MASK ,i16bit,1,0,1,0,1,0,0,0,0,0,0} ,NULL, - 0xf400ec00,"ff0 ",{21,5,REG} ,{0,5,REG} ,{0,0,0} , {1,1,PINT,FF0 ,0,0,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf400e800,"ff1 ",{21,5,REG} ,{0,5,REG} ,{0,0,0} , {1,1,PINT,FF1 ,0,0,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf0008000,"clr ",{21,5,REG} ,{16,5,REG} ,{0,10,BF} , {1,1,PINT,CLR ,i10bit,1,0,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf0008800,"set ",{21,5,REG} ,{16,5,REG} ,{0,10,BF} , {1,1,PINT,SET ,i10bit,1,0,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf0009000,"ext ",{21,5,REG} ,{16,5,REG} ,{0,10,BF} , {1,1,PINT,EXT ,i10bit,1,0,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf0009800,"extu ",{21,5,REG} ,{16,5,REG} ,{0,10,BF} , {1,1,PINT,EXTU ,i10bit,1,0,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf000a000,"mak ",{21,5,REG} ,{16,5,REG} ,{0,10,BF} , {1,1,PINT,MAK ,i10bit,1,0,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf000a800,"rot ",{21,5,REG} ,{16,5,REG} ,{0,10,BF} , {1,1,PINT,ROT ,i10bit,1,0,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf4008000,"clr ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,CLR ,0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf4008800,"set ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,SET ,0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf4009000,"ext ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,EXT ,0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf4009800,"extu ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,EXTU ,0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf400a000,"mak ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,MAK ,0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf400a800,"rot ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,ROT ,0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - - 0x84002800,"fadd.sss ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {5,1,PFLT,FADD ,0,1,1,1,0,0,0,1,0,0,0,0} ,NULL, - 0x84002880,"fadd.ssd ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {6,2,PFLT,FADD ,0,1,1,1,0,0,0,1,0,0,1,0} ,NULL, - 0x84002a00,"fadd.sds ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {6,2,PFLT,FADD ,0,1,1,1,0,0,0,1,0,1,0,0} ,NULL, - 0x84002a80,"fadd.sdd ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {6,2,PFLT,FADD ,0,1,1,1,0,0,0,1,0,1,1,0} ,NULL, - 0x84002820,"fadd.dss ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {6,2,PFLT,FADD ,0,1,1,1,0,0,0,1,1,0,0,0} ,NULL, - 0x840028a0,"fadd.dsd ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {6,2,PFLT,FADD ,0,1,1,1,0,0,0,1,1,0,1,0} ,NULL, - 0x84002a20,"fadd.dds ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {6,2,PFLT,FADD ,0,1,1,1,0,0,0,1,1,1,0,0} ,NULL, - 0x84002aa0,"fadd.ddd ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {6,2,PFLT,FADD ,0,1,1,1,0,0,0,1,1,1,1,0} ,NULL, - 0x84003000,"fsub.sss ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {5,1,PFLT,FSUB ,0,1,1,1,0,0,0,1,0,0,0,0} ,NULL, - 0x84003080,"fsub.ssd ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {6,2,PFLT,FSUB ,0,1,1,1,0,0,0,1,0,0,1,0} ,NULL, - 0x84003200,"fsub.sds ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {6,2,PFLT,FSUB ,0,1,1,1,0,0,0,1,0,1,0,0} ,NULL, - 0x84003280,"fsub.sdd ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {6,2,PFLT,FSUB ,0,1,1,1,0,0,0,1,0,1,1,0} ,NULL, - 0x84003020,"fsub.dss ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {6,2,PFLT,FSUB ,0,1,1,1,0,0,0,1,1,0,0,0} ,NULL, - 0x840030a0,"fsub.dsd ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {6,2,PFLT,FSUB ,0,1,1,1,0,0,0,1,1,0,1,0} ,NULL, - 0x84003220,"fsub.dds ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {6,2,PFLT,FSUB ,0,1,1,1,0,0,0,1,1,1,0,0} ,NULL, - 0x840032a0,"fsub.ddd ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {6,2,PFLT,FSUB ,0,1,1,1,0,0,0,1,1,1,1,0} ,NULL, - 0x84000000,"fmul.sss ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {6,1,PFLT,FMUL ,0,1,1,1,0,0,0,1,0,0,0,0} ,NULL, - 0x84000080,"fmul.ssd ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {9,2,PFLT,FMUL ,0,1,1,1,0,0,0,1,0,0,1,0} ,NULL, - 0x84000200,"fmul.sds ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {9,2,PFLT,FMUL ,0,1,1,1,0,0,0,1,0,1,0,0} ,NULL, - 0x84000280,"fmul.sdd ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {9,2,PFLT,FMUL ,0,1,1,1,0,0,0,1,0,1,1,0} ,NULL, - 0x84000020,"fmul.dss ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {9,2,PFLT,FMUL ,0,1,1,1,0,0,0,1,1,0,0,0} ,NULL, - 0x840000a0,"fmul.dsd ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {9,2,PFLT,FMUL ,0,1,1,1,0,0,0,1,1,0,1,0} ,NULL, - 0x84000220,"fmul.dds ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {9,2,PFLT,FMUL ,0,1,1,1,0,0,0,1,1,1,0,0} ,NULL, - 0x840002a0,"fmul.ddd ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {9,2,PFLT,FMUL ,0,1,1,1,0,0,0,1,1,1,1,0} ,NULL, - 0x84007000,"fdiv.sss ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {30,30,PFLT,FDIV ,0,1,1,1,0,0,0,1,0,0,0,0} ,NULL, - 0x84007080,"fdiv.ssd ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {60,60,PFLT,FDIV ,0,1,1,1,0,0,0,1,0,0,1,0} ,NULL, - 0x84007200,"fdiv.sds ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {60,60,PFLT,FDIV ,0,1,1,1,0,0,0,1,0,1,0,0} ,NULL, - 0x84007280,"fdiv.sdd ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {60,60,PFLT,FDIV ,0,1,1,1,0,0,0,1,0,1,1,0} ,NULL, - 0x84007020,"fdiv.dss ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {60,60,PFLT,FDIV ,0,1,1,1,0,0,0,1,1,0,0,0} ,NULL, - 0x840070a0,"fdiv.dsd ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {60,60,PFLT,FDIV ,0,1,1,1,0,0,0,1,1,0,1,0} ,NULL, - 0x84007220,"fdiv.dds ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {60,60,PFLT,FDIV ,0,1,1,1,0,0,0,1,1,1,0,0} ,NULL, - 0x840072a0,"fdiv.ddd ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {60,60,PFLT,FDIV ,0,1,1,1,0,0,0,1,1,1,1,0} ,NULL, - 0x84007800,"fsqrt.ss ",{21,5,REG} ,{0,5,REG} ,{0,0,0} , {5,1,PFLT,FLT ,0,0,1,1,0,0,0,1,0,0,0,0} ,NULL, - 0x84007880,"fsqrt.sd ",{21,5,REG} ,{0,5,REG} ,{0,0,0} , {5,1,PFLT,FLT ,0,0,1,1,0,0,0,1,0,0,0,0} ,NULL, - 0x84007820,"fsqrt.ds ",{21,5,REG} ,{0,5,REG} ,{0,0,0} , {5,1,PFLT,FLT ,0,0,1,1,0,0,0,1,0,0,0,0} ,NULL, - 0x840078a0,"fsqrt.dd ",{21,5,REG} ,{0,5,REG} ,{0,0,0} , {6,1,PFLT,FLT ,0,0,1,1,0,0,0,1,1,0,0,0} ,NULL, - 0x84003800,"fcmp.ss ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {5,1,PFLT,FCMP ,0,1,1,1,0,0,0,1,0,0,0,0} ,NULL, - 0x84003880,"fcmp.sd ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {6,1,PFLT,FCMP ,0,1,1,1,0,0,0,1,0,1,0,0} ,NULL, - 0x84003a00,"fcmp.ds ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {6,1,PFLT,FCMP ,0,1,1,1,0,0,0,1,1,0,0,0} ,NULL, - 0x84003a80,"fcmp.dd ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {6,1,PFLT,FCMP ,0,1,1,1,0,0,0,1,1,1,0,0} ,NULL, - 0x84002000,"flt.s ",{21,5,REG} ,{0,5,REG} ,{0,0,0} , {5,1,PFLT,FLT ,0,0,1,1,0,0,0,1,0,0,0,0} ,NULL, - 0x84002020,"flt.d ",{21,5,REG} ,{0,5,REG} ,{0,0,0} , {6,1,PFLT,FLT ,0,0,1,1,0,0,0,1,1,0,0,0} ,NULL, - 0x84004800,"int.s ",{21,5,REG} ,{0,5,REG} ,{0,0,0} , {5,1,PFLT,INT ,0,0,1,1,0,0,0,1,0,0,0,0} ,NULL, - 0x84004880,"int.d ",{21,5,REG} ,{0,5,REG} ,{0,0,0} , {6,1,PFLT,INT ,0,0,1,1,0,0,0,1,1,0,0,0} ,NULL, - 0x84005000,"nint.s ",{21,5,REG} ,{0,5,REG} ,{0,0,0} , {5,1,PFLT,INT ,0,0,1,1,0,0,0,1,0,0,0,0} ,NULL, - 0x84005080,"nint.d ",{21,5,REG} ,{0,5,REG} ,{0,0,0} , {6,1,PFLT,INT ,0,0,1,1,0,0,0,1,1,0,0,0} ,NULL, - 0x84005800,"trnc.s ",{21,5,REG} ,{0,5,REG} ,{0,0,0} , {5,1,PFLT,TRNC ,0,0,1,1,0,0,0,1,0,0,0,0} ,NULL, - 0x84005880,"trnc.d ",{21,5,REG} ,{0,5,REG} ,{0,0,0} , {6,1,PFLT,TRNC ,0,0,1,1,0,0,0,1,1,0,0,0} ,NULL, - - 0x80004800,"fldcr ",{21,5,REG} ,{5,6,FCRREG} ,{0,0,0} , {1,1,PFLT,FLDC ,0,0,1,1,0,0,0,1,0,0,0,0} ,NULL, - 0x80008800,"fstcr ",{16,5,REG} ,{5,6,FCRREG} ,{0,0,0} , {1,1,PFLT,FSTC ,0,0,1,1,0,0,0,1,0,0,0,0} ,NULL, - 0x8000c800,"fxcr ",{21,5,REG} ,{16,5,REG} ,{5,6,FCRREG} , {1,1,PFLT,FXC ,0,0,1,1,0,0,0,1,0,0,0,0} ,NULL}; - diff --git a/gdb/m88k-pinsn.c b/gdb/m88k-pinsn.c deleted file mode 100644 index bede269b0af..00000000000 --- a/gdb/m88k-pinsn.c +++ /dev/null @@ -1,343 +0,0 @@ -/* This file has been modified by Data General Corporation, November 1989. */ - -#include -#include "m88k-opcode.h" -#include "defs.h" -#include "symtab.h" - -void sprint_address (); - -/* Changed hashtab to hashtable to avoid naming conflict - with libdc.o (used for tdesc) for m88k. -*/ - -INSTAB *hashtable[HASHVAL] = {0}; - -/* -* Disassemble an M88000 Instruction -* -* -* This module decodes the first instruction in inbuf. It uses the pc -* to display pc-relative displacements. It writes the disassembled -* instruction in outbuf. -* -* Revision History -* -* Revision 1.0 11/08/85 Creation date by Motorola -* 05/11/89 R. Trawick adapted to GDB interface. -*/ -#define MAXLEN 20 - -print_insn (memaddr, stream) - CORE_ADDR memaddr; - FILE *stream; -{ - unsigned char buffer[MAXLEN]; - /* should be expanded if disassembler prints symbol names */ - char outbuf[100]; - int n; - - /* Instruction addresses may have low two bits set. Clear them. */ - memaddr&= 0xfffffffc; - read_memory (memaddr, buffer, MAXLEN); - - n = m88kdis ((int)memaddr, buffer, outbuf); - - fputs (outbuf, stream); - - return (n); -} - -/* - * disassemble the first instruction in 'inbuf'. - * 'pc' should be the address of this instruction, it will - * be used to print the target address if this is a relative jump or call - * 'outbuf' gets filled in with the disassembled instruction. It should - * be long enough to hold the longest disassembled instruction. - * 100 bytes is certainly enough, unless symbol printing is added later - * The function returns the length of this instruction in bytes. - */ - -int m88kdis( pc, inbuf, outbuf ) - - int pc; - int *inbuf; - char *outbuf; - -{ static ihashtab_initialized = 0; - int instruction; - unsigned int opcode; - INSTAB *entry_ptr; - int opmask; - int class; - - instruction= *inbuf; - - if (!ihashtab_initialized) { - init_disasm(); - } - - /* create a the appropriate mask to isolate the opcode */ - opmask= DEFMASK; - class= instruction & DEFMASK; - if ((class >= SFU0) && (class <= SFU7)) { - if (instruction < SFU1) { - opmask= CTRLMASK; - } else { - opmask= SFUMASK; - } - } else if (class == RRR) { - opmask= RRRMASK; - } else if (class == RRI10) { - opmask= RRI10MASK; - } - - /* isolate the opcode */ - opcode= instruction & opmask; - - /* search the hash table with the isolated opcode */ - for (entry_ptr= hashtable[ opcode % HASHVAL ]; - (entry_ptr != NULL) && (entry_ptr->opcode != opcode); - entry_ptr= entry_ptr->next) { - } - - if (entry_ptr == NULL) { - sprintf( outbuf, "word\t%08x", instruction ); - } else { - sprintf( outbuf, "%s\t", entry_ptr->mnemonic ); - sprintop( &outbuf[strlen(outbuf)], &(entry_ptr->op1), instruction, pc, 1 ); - sprintop( &outbuf[strlen(outbuf)], &(entry_ptr->op2), instruction, pc, 0 ); - sprintop( &outbuf[strlen(outbuf)], &(entry_ptr->op3), instruction, pc, 0 ); - } - - - return 4; -} - - -/* -* Decode an Operand of an Instruction -* -* Functional Description -* -* This module formats and writes an operand of an instruction to buf -* based on the operand specification. When the first flag is set this -* is the first operand of an instruction. Undefined operand types -* cause a message. -* -* Parameters -* char *buf buffer where the operand may be printed -* OPSPEC *opptr Pointer to an operand specification -* UINT inst Instruction from which operand is extracted -* UINT pc PC of instruction; used for pc-relative disp. -* int first Flag which if nonzero indicates the first -* operand of an instruction -* -* Output -* -* The operand specified is extracted from the instruction and is -* written to buf in the format specified. The operand is preceded -* by a comma if it is not the first operand of an instruction and it -* is not a register indirect form. Registers are preceded by 'r' and -* hex values by '0x'. -* -* Revision History -* -* Revision 1.0 11/08/85 Creation date -*/ - -sprintop( buf, opptr, inst, pc, first ) - - char *buf; - OPSPEC *opptr; - UINT inst; - int pc; - int first; - -{ int extracted_field; - char *cond_mask_sym; - char cond_mask_sym_buf[6]; - - if (opptr->width == 0) - return; - - switch(opptr->type) { - case CRREG: - if (!first) - *buf++= ','; - sprintf( buf, "cr%d", UEXT(inst,opptr->offset,opptr->width)); - break; - - case FCRREG: - if (!first) - *buf++= ','; - sprintf( buf, "fcr%d", UEXT(inst,opptr->offset,opptr->width)); - break; - - case REGSC: - sprintf( buf, "[r%d]", UEXT(inst,opptr->offset,opptr->width)); - break; - - case REG: - if (!first) - *buf++= ','; - sprintf( buf, "r%d", UEXT(inst,opptr->offset,opptr->width)); - break; - - case HEX: - if (!first) - *buf++= ','; - extracted_field= UEXT(inst, opptr->offset, opptr->width); - if (extracted_field == 0) { - sprintf( buf, "0" ); - } else { - sprintf( buf, "0x%02x", extracted_field ); - } - break; - - case CONDMASK: - if (!first) - *buf++= ','; - extracted_field= UEXT(inst, opptr->offset, opptr->width); - switch (extracted_field & 0x0f) { - case 0x1: cond_mask_sym= "gt0"; - break; - case 0x2: cond_mask_sym= "eq0"; - break; - case 0x3: cond_mask_sym= "ge0"; - break; - case 0xc: cond_mask_sym= "lt0"; - break; - case 0xd: cond_mask_sym= "ne0"; - break; - case 0xe: cond_mask_sym= "le0"; - break; - default: cond_mask_sym= cond_mask_sym_buf; - sprintf( cond_mask_sym_buf, - "%x", - extracted_field ); - break; - } - strcpy( buf, cond_mask_sym ); - break; - - case PCREL: - if (!first) - *buf++= ','; - sprint_address( pc + 4*(SEXT(inst,opptr->offset,opptr->width)), - buf ); - break; - - case CONT: - sprintf( buf, - "%d,r%d", - UEXT(inst,opptr->offset,5), - UEXT(inst,(opptr->offset)+5,5) ); - break; - - case BF: - if (!first) - *buf++= ','; - sprintf( buf, - "%d<%d>", - UEXT(inst,(opptr->offset)+5,5), - UEXT(inst,opptr->offset,5)); - break; - - default: - sprintf( buf, "", inst ); - } - -} - -/* -* Initialize the Disassembler Instruction Table -* -* Initialize the hash table and instruction table for the disassembler. -* This should be called once before the first call to disasm(). -* -* Parameters -* -* Output -* -* If the debug option is selected, certain statistics about the hashing -* distribution are written to stdout. -* -* Revision History -* -* Revision 1.0 11/08/85 Creation date -*/ - -init_disasm() -{ - int i,size; - - for (i=0 ; i < HASHVAL ; i++) - hashtable[i] = NULL; - - for (i=0, size = sizeof(instructions) / sizeof(INSTAB) ; i < size ; - install(&instructions[i++])); - -} - -/* -* Insert an instruction into the disassembler table by hashing the -* opcode and inserting it into the linked list for that hash value. -* -* Parameters -* -* INSTAB *instptr Pointer to the entry in the instruction table -* to be installed -* -* Revision 1.0 11/08/85 Creation date -* 05/11/89 R. TRAWICK ADAPTED FROM MOTOROLA -*/ - -install(instptr) - INSTAB *instptr; -{ - UINT i; - - i = (instptr->opcode) % HASHVAL; - instptr->next = hashtable[i]; - hashtable[i] = instptr; -} - - -/* adapted from print_address in printcmd by R. Trawick 5/15/89. The two should - be combined. - */ - -void sprint_address (addr, buffer) - - CORE_ADDR addr; - char *buffer; - -{ - register int i; - struct symbol *fs; - char *name; - int name_location; - - sprintf ( buffer, "0x%x", addr); - - fs = find_pc_function (addr); - - if (!fs) { - i = find_pc_misc_function (addr); - - if (i < 0) return; /* If nothing comes through, don't - print anything symbolic */ - - name = misc_function_vector[i].name; - name_location = misc_function_vector[i].address; - } else { - name = fs->name; - name_location = BLOCK_START (SYMBOL_BLOCK_VALUE (fs)); - } - - if (addr - name_location) - sprintf (buffer, " <%s+%d>", name, addr - name_location); - else - sprintf (buffer, " <%s>", name); -} diff --git a/gdb/m88k-tdep.c b/gdb/m88k-tdep.c deleted file mode 100644 index 594bd49b1a0..00000000000 --- a/gdb/m88k-tdep.c +++ /dev/null @@ -1,858 +0,0 @@ -/* Target-machine dependent code for Motorola 88000 series, for GDB. - Copyright (C) 1988, 1990, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "defs.h" -#include "param.h" -#include "frame.h" -#include "inferior.h" -#include "value.h" - -#ifdef USG -#include -#endif - -#include -#include -#include -#include "gdbcore.h" -#include -#ifndef USER /* added to support BCS ptrace_user */ - -#define USER ptrace_user -#endif -#include -#include - -#include -#include - -#include "symtab.h" -#include "setjmp.h" -#include "value.h" - -void frame_find_saved_regs (); - - -/* 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. */ - -FRAME_ADDR -frame_chain (thisframe) - FRAME thisframe; -{ - - frame_find_saved_regs (thisframe, (struct frame_saved_regs *) 0); - /* NOTE: this depends on frame_find_saved_regs returning the VALUE, not - the ADDRESS, of SP_REGNUM. It also depends on the cache of - frame_find_saved_regs results. */ - if (thisframe->fsr->regs[SP_REGNUM]) - return thisframe->fsr->regs[SP_REGNUM]; - else - return thisframe->frame; /* Leaf fn -- next frame up has same SP. */ -} - -int -frameless_function_invocation (frame) - FRAME frame; -{ - - frame_find_saved_regs (frame, (struct frame_saved_regs *) 0); - /* NOTE: this depends on frame_find_saved_regs returning the VALUE, not - the ADDRESS, of SP_REGNUM. It also depends on the cache of - frame_find_saved_regs results. */ - if (frame->fsr->regs[SP_REGNUM]) - return 0; /* Frameful -- return addr saved somewhere */ - else - return 1; /* Frameless -- no saved return address */ -} - -int -frame_chain_valid (chain, thisframe) - CORE_ADDR chain; - struct frame_info *thisframe; -{ - return (chain != 0 - && outside_startup_file (FRAME_SAVED_PC (thisframe))); -} - -void -init_extra_frame_info (fromleaf, fi) - int fromleaf; - struct frame_info *fi; -{ - fi->fsr = 0; /* Not yet allocated */ - fi->args_pointer = 0; /* Unknown */ - fi->locals_pointer = 0; /* Unknown */ -} - -/* Examine an m88k 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 - after the instruction at address LIMIT, as explained below). - - LIMIT places an upper bound on addresses of the instructions to be - examined. If the prologue code scan reaches LIMIT, the scan is - aborted and LIMIT is returned. This is used, when examining the - prologue for the current frame, to keep examine_prologue () from - claiming that a given register has been saved when in fact the - instruction that saves it has not yet been executed. LIMIT is used - at other times to stop the scan when we hit code after the true - function prologue (e.g. for the first source line) which might - otherwise be mistaken for function prologue. - - The format of the function prologue matched by this routine is - derived from examination of the source to gcc 1.95, particularly - the routine output_prologue () in config/out-m88k.c. - - subu r31,r31,n # stack pointer update - - (st rn,r31,offset)? # save incoming regs - (st.d rn,r31,offset)? - - (addu r30,r31,n)? # frame pointer update - - (pic sequence)? # PIC code prologue - - (or rn,rm,0)? # Move parameters to other regs -*/ - -/* Macros for extracting fields from instructions. */ - -#define BITMASK(pos, width) (((0x1 << (width)) - 1) << (pos)) -#define EXTRACT_FIELD(val, pos, width) ((val) >> (pos) & BITMASK (0, width)) - -/* Prologue code that handles position-independent-code setup. */ - -struct pic_prologue_code { - unsigned long insn, mask; -}; - -static struct pic_prologue_code pic_prologue_code [] = { -/* FIXME -- until this is translated to hex, we won't match it... */ - 0xffffffff, 0, - /* or r10,r1,0 (if not saved) */ - /* bsr.n LabN */ - /* or.u r25,r0,const */ - /*LabN: or r25,r25,const2 */ - /* addu r25,r25,1 */ - /* or r1,r10,0 (if not saved) */ -}; - -/* Fetch the instruction at ADDR, returning 0 if ADDR is beyond LIM or - is not the address of a valid instruction, the address of the next - instruction beyond ADDR otherwise. *PWORD1 receives the first word - of the instruction. PWORD2 is ignored -- a remnant of the original - i960 version. */ - -#define NEXT_PROLOGUE_INSN(addr, lim, pword1, pword2) \ - (((addr) < (lim)) ? next_insn (addr, pword1) : 0) - -/* Read the m88k instruction at 'memaddr' and return the address of - the next instruction after that, or 0 if 'memaddr' is not the - address of a valid instruction. The instruction - is stored at 'pword1'. */ - -CORE_ADDR -next_insn (memaddr, pword1) - unsigned long *pword1; - CORE_ADDR memaddr; -{ - unsigned long buf[1]; - - read_memory (memaddr, buf, sizeof (buf)); - *pword1 = buf[0]; - SWAP_TARGET_AND_HOST (pword1, sizeof (long)); - - return memaddr + 4; -} - -/* Read a register from frames called by us (or from the hardware regs). */ - -int -read_next_frame_reg(fi, regno) - FRAME fi; - int regno; -{ - for (; fi; fi = fi->next) { - if (regno == SP_REGNUM) return fi->frame; - else if (fi->fsr->regs[regno]) - return read_memory_integer(fi->fsr->regs[regno], 4); - } - return read_register(regno); -} - -/* Examine the prologue of a function. `ip' points to the first instruction. - `limit' is the limit of the prologue (e.g. the addr of the first - linenumber, or perhaps the program counter if we're stepping through). - `frame_sp' is the stack pointer value in use in this frame. - `fsr' is a pointer to a frame_saved_regs structure into which we put - info about the registers saved by this frame. - `fi' is a struct frame_info pointer; we fill in various fields in it - to reflect the offsets of the arg pointer and the locals pointer. */ - -static CORE_ADDR -examine_prologue (ip, limit, frame_sp, fsr, fi) - register CORE_ADDR ip; - register CORE_ADDR limit; - FRAME_ADDR frame_sp; - struct frame_saved_regs *fsr; - struct frame_info *fi; -{ - register CORE_ADDR next_ip; - register int src; - register struct pic_prologue_code *pcode; - unsigned int insn1, insn2; - int size, offset; - char must_adjust[32]; /* If set, must adjust offsets in fsr */ - int sp_offset = -1; /* -1 means not set (valid must be mult of 8) */ - int fp_offset = -1; /* -1 means not set */ - CORE_ADDR frame_fp; - - bzero (must_adjust, sizeof (must_adjust)); - next_ip = NEXT_PROLOGUE_INSN (ip, limit, &insn1, &insn2); - - /* Accept move of incoming registers to other registers, using - "or rd,rs,0" or "or.u rd,rs,0" or "or rd,r0,rs" or "or rd,rs,r0". - We don't have to worry about walking into the first lines of code, - since the first line number will stop us (assuming we have symbols). - What we have actually seen is "or r10,r0,r12". */ - -#define OR_MOVE_INSN 0x58000000 /* or/or.u with immed of 0 */ -#define OR_MOVE_MASK 0xF800FFFF -#define OR_REG_MOVE1_INSN 0xF4005800 /* or rd,r0,rs */ -#define OR_REG_MOVE1_MASK 0xFC1FFFE0 -#define OR_REG_MOVE2_INSN 0xF4005800 /* or rd,rs,r0 */ -#define OR_REG_MOVE2_MASK 0xFC00FFFF - while (next_ip && - ((insn1 & OR_MOVE_MASK) == OR_MOVE_INSN || - (insn1 & OR_REG_MOVE1_MASK) == OR_REG_MOVE1_INSN || - (insn1 & OR_REG_MOVE2_MASK) == OR_REG_MOVE2_INSN - ) - ) - { - /* We don't care what moves to where. The result of the moves - has already been reflected in what the compiler tells us is the - location of these parameters. */ - ip = next_ip; - next_ip = NEXT_PROLOGUE_INSN (ip, limit, &insn1, &insn2); - } - - /* Accept an optional "subu sp,sp,n" to set up the stack pointer. */ - -#define SUBU_SP_INSN 0x67ff0000 -#define SUBU_SP_MASK 0xffff0007 /* Note offset must be mult. of 8 */ -#define SUBU_OFFSET(x) ((unsigned)(x & 0xFFFF)) - if (next_ip && - ((insn1 & SUBU_SP_MASK) == SUBU_SP_INSN)) /* subu r31, r31, N */ - { - sp_offset = -SUBU_OFFSET (insn1); - ip = next_ip; - next_ip = NEXT_PROLOGUE_INSN (ip, limit, &insn1, &insn2); - } - - /* The function must start with a stack-pointer adjustment, or - we don't know WHAT'S going on... */ - if (sp_offset == -1) - return ip; - - /* Accept zero or more instances of "st rx,sp,n" or "st.d rx,sp,n". - This may cause us to mistake the copying of a register - parameter to the frame for the saving of a callee-saved - register, but that can't be helped, since with the - "-fcall-saved" flag, any register can be made callee-saved. - This probably doesn't matter, since the ``saved'' caller's values of - non-callee-saved registers are not relevant anyway. */ - -#define STD_STACK_INSN 0x201f0000 -#define STD_STACK_MASK 0xfc1f0000 -#define ST_STACK_INSN 0x241f0000 -#define ST_STACK_MASK 0xfc1f0000 -#define ST_OFFSET(x) ((unsigned)((x) & 0xFFFF)) -#define ST_SRC(x) EXTRACT_FIELD ((x), 21, 5) - - while (next_ip) - { - if ((insn1 & ST_STACK_MASK) == ST_STACK_INSN) - size = 1; - else if ((insn1 & STD_STACK_MASK) == STD_STACK_INSN) - size = 2; - else - break; - - src = ST_SRC (insn1); - offset = ST_OFFSET (insn1); - while (size--) - { - must_adjust[src] = 1; - fsr->regs[src++] = offset; /* Will be adjusted later */ - offset += 4; - } - ip = next_ip; - next_ip = NEXT_PROLOGUE_INSN (ip, limit, &insn1, &insn2); - } - - /* Accept an optional "addu r30,r31,n" to set up the frame pointer. */ - -#define ADDU_FP_INSN 0x63df0000 -#define ADDU_FP_MASK 0xffff0000 -#define ADDU_OFFSET(x) ((unsigned)(x & 0xFFFF)) - if (next_ip && - ((insn1 & ADDU_FP_MASK) == ADDU_FP_INSN)) /* addu r30, r31, N */ - { - fp_offset = ADDU_OFFSET (insn1); - ip = next_ip; - next_ip = NEXT_PROLOGUE_INSN (ip, limit, &insn1, &insn2); - } - - /* Accept the PIC prologue code if present. */ - - pcode = pic_prologue_code; - size = sizeof (pic_prologue_code) / sizeof (*pic_prologue_code); - /* If return addr is saved, we don't use first or last insn of PICstuff. */ - if (fsr->regs[SRP_REGNUM]) { - pcode++; - size-=2; - } - - while (size-- && next_ip && (pcode->insn == (pcode->mask & insn1))) - { - pcode++; - ip = next_ip; - next_ip = NEXT_PROLOGUE_INSN (ip, limit, &insn1, &insn2); - } - - /* Accept moves of parameter registers to other registers, using - "or rd,rs,0" or "or.u rd,rs,0" or "or rd,r0,rs" or "or rd,rs,r0". - We don't have to worry about walking into the first lines of code, - since the first line number will stop us (assuming we have symbols). - What gcc actually seems to produce is "or rd,r0,rs". */ - -#define OR_MOVE_INSN 0x58000000 /* or/or.u with immed of 0 */ -#define OR_MOVE_MASK 0xF800FFFF -#define OR_REG_MOVE1_INSN 0xF4005800 /* or rd,r0,rs */ -#define OR_REG_MOVE1_MASK 0xFC1FFFE0 -#define OR_REG_MOVE2_INSN 0xF4005800 /* or rd,rs,r0 */ -#define OR_REG_MOVE2_MASK 0xFC00FFFF - while (next_ip && - ((insn1 & OR_MOVE_MASK) == OR_MOVE_INSN || - (insn1 & OR_REG_MOVE1_MASK) == OR_REG_MOVE1_INSN || - (insn1 & OR_REG_MOVE2_MASK) == OR_REG_MOVE2_INSN - ) - ) - { - /* We don't care what moves to where. The result of the moves - has already been reflected in what the compiler tells us is the - location of these parameters. */ - ip = next_ip; - next_ip = NEXT_PROLOGUE_INSN (ip, limit, &insn1, &insn2); - } - - /* We're done with the prologue. If we don't care about the stack - frame itself, just return. (Note that fsr->regs has been trashed, - but the one caller who calls with fi==0 passes a dummy there.) */ - - if (fi == 0) - return ip; - - /* OK, now we have: - sp_offset original negative displacement of SP - fp_offset positive displacement between new SP and new FP, or -1 - fsr->regs[0..31] offset from original SP where reg is stored - must_adjust[0..31] set if corresp. offset was set - - The current SP (frame_sp) might not be the original new SP as set - by the function prologue, if alloca has been called. This can - only occur if fp_offset is set, though (the compiler allocates an - FP when it sees alloca). In that case, we have the FP, - and can calculate the original new SP from the FP. - - Then, we figure out where the arguments and locals are, and - relocate the offsets in fsr->regs to absolute addresses. */ - - if (fp_offset != -1) { - /* We have a frame pointer, so get it, and base our calc's on it. */ - frame_fp = (CORE_ADDR) read_next_frame_reg (fi->next, FP_REGNUM); - frame_sp = frame_fp - fp_offset; - } else { - /* We have no frame pointer, therefore frame_sp is still the same value - as set by prologue. But where is the frame itself? */ - if (must_adjust[SRP_REGNUM]) { - /* Function header saved SRP (r1), the return address. Frame starts - 4 bytes down from where it was saved. */ - frame_fp = frame_sp + fsr->regs[SRP_REGNUM] - 4; - fi->locals_pointer = frame_fp; - } else { - /* Function header didn't save SRP (r1), so we are in a leaf fn or - are otherwise confused. */ - frame_fp = -1; - } - } - - /* The locals are relative to the FP (whether it exists as an allocated - register, or just as an assumed offset from the SP) */ - fi->locals_pointer = frame_fp; - - /* The arguments are just above the SP as it was before we adjusted it - on entry. */ - fi->args_pointer = frame_sp - sp_offset; - - /* Now that we know the SP value used by the prologue, we know where - it saved all the registers. */ - for (src = 0; src < 32; src++) - if (must_adjust[src]) - fsr->regs[src] += frame_sp; - - /* The saved value of the SP is always known. */ - /* (we hope...) */ - if (fsr->regs[SP_REGNUM] != 0 - && fsr->regs[SP_REGNUM] != frame_sp - sp_offset) - fprintf(stderr, "Bad saved SP value %x != %x, offset %x!\n", - fsr->regs[SP_REGNUM], - frame_sp - sp_offset, sp_offset); - - fsr->regs[SP_REGNUM] = frame_sp - sp_offset; - - return (ip); -} - -/* Given an ip value corresponding to the start of a function, - return the ip of the first instruction after the function - prologue. */ - -CORE_ADDR -skip_prologue (ip) - CORE_ADDR (ip); -{ - struct frame_saved_regs saved_regs_dummy; - struct symtab_and_line sal; - CORE_ADDR limit; - - sal = find_pc_line (ip, 0); - limit = (sal.end) ? sal.end : 0xffffffff; - - return (examine_prologue (ip, limit, (FRAME_ADDR) 0, &saved_regs_dummy, - (struct frame_info *)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. - - We cache the result of doing this in the frame_cache_obstack, since - it is fairly expensive. */ - -void -frame_find_saved_regs (fi, fsr) - struct frame_info *fi; - struct frame_saved_regs *fsr; -{ - register CORE_ADDR next_addr; - register CORE_ADDR *saved_regs; - register int regnum; - register struct frame_saved_regs *cache_fsr; - extern struct obstack frame_cache_obstack; - CORE_ADDR ip; - struct symtab_and_line sal; - CORE_ADDR limit; - - if (!fi->fsr) - { - cache_fsr = (struct frame_saved_regs *) - obstack_alloc (&frame_cache_obstack, - sizeof (struct frame_saved_regs)); - bzero (cache_fsr, sizeof (struct frame_saved_regs)); - fi->fsr = cache_fsr; - - /* Find the start and end of the function prologue. If the PC - is in the function prologue, we only consider the part that - has executed already. */ - - ip = get_pc_function_start (fi->pc); - sal = find_pc_line (ip, 0); - limit = (sal.end && sal.end < fi->pc) ? sal.end: fi->pc; - - /* This will fill in fields in *fi as well as in cache_fsr. */ - examine_prologue (ip, limit, fi->frame, cache_fsr, fi); - } - - if (fsr) - *fsr = *fi->fsr; -} - -/* Return the address of the locals block for the frame - described by FI. Returns 0 if the address is unknown. - NOTE! Frame locals are referred to by negative offsets from the - argument pointer, so this is the same as frame_args_address(). */ - -CORE_ADDR -frame_locals_address (fi) - struct frame_info *fi; -{ - register FRAME frame; - struct frame_saved_regs fsr; - CORE_ADDR ap; - - if (fi->args_pointer) /* Cached value is likely there. */ - return fi->args_pointer; - - /* Nope, generate it. */ - - get_frame_saved_regs (fi, &fsr); - - return fi->args_pointer; -} - -/* Return the address of the argument block for the frame - described by FI. Returns 0 if the address is unknown. */ - -CORE_ADDR -frame_args_address (fi) - struct frame_info *fi; -{ - register FRAME frame; - struct frame_saved_regs fsr; - CORE_ADDR ap; - - if (fi->args_pointer) /* Cached value is likely there. */ - return fi->args_pointer; - - /* Nope, generate it. */ - - get_frame_saved_regs (fi, &fsr); - - return fi->args_pointer; -} - -/* Return the saved PC from this frame. - - If the frame has a memory copy of SRP_REGNUM, use that. If not, - just use the register SRP_REGNUM itself. */ - -CORE_ADDR -frame_saved_pc (frame) - FRAME frame; -{ - return read_next_frame_reg(frame, SRP_REGNUM); -} - - -#if TARGET_BYTE_ORDER != HOST_BYTE_ORDER -you lose -#else /* Host and target byte order the same. */ -#define SINGLE_EXP_BITS 8 -#define DOUBLE_EXP_BITS 11 -int -IEEE_isNAN(fp, len) - int *fp, len; - /* fp points to a single precision OR double precision - * floating point value; len is the number of bytes, either 4 or 8. - * Returns 1 iff fp points to a valid IEEE floating point number. - * Returns 0 if fp points to a denormalized number or a NaN - */ -{ - int exponent; - if (len == 4) - { - exponent = *fp; - exponent = exponent << 1 >> (32 - SINGLE_EXP_BITS - 1); - return ((exponent == -1) || (! exponent && *fp)); - } - else if (len == 8) - { - exponent = *(fp+1); - exponent = exponent << 1 >> (32 - DOUBLE_EXP_BITS - 1); - return ((exponent == -1) || (! exponent && *fp * *(fp+1))); - } - else return 1; -} -#endif /* Host and target byte order the same. */ - -static int -pushed_size (prev_words, v) - int prev_words; - struct value *v; -{ - switch (TYPE_CODE (VALUE_TYPE (v))) - { - case TYPE_CODE_VOID: /* Void type (values zero length) */ - - return 0; /* That was easy! */ - - case TYPE_CODE_PTR: /* Pointer type */ - case TYPE_CODE_ENUM: /* Enumeration type */ - case TYPE_CODE_INT: /* Integer type */ - case TYPE_CODE_REF: /* C++ Reference types */ - case TYPE_CODE_ARRAY: /* Array type, lower bound zero */ - - return 1; - - case TYPE_CODE_FLT: /* Floating type */ - - if (TYPE_LENGTH (VALUE_TYPE (v)) == 4) - return 1; - else - /* Assume that it must be a double. */ - if (prev_words & 1) /* at an odd-word boundary */ - return 3; /* round to 8-byte boundary */ - else - return 2; - - case TYPE_CODE_STRUCT: /* C struct or Pascal record */ - case TYPE_CODE_UNION: /* C union or Pascal variant part */ - - return (((TYPE_LENGTH (VALUE_TYPE (v)) + 3) / 4) * 4); - - case TYPE_CODE_FUNC: /* Function type */ - case TYPE_CODE_SET: /* Pascal sets */ - case TYPE_CODE_RANGE: /* Range (integers within bounds) */ - case TYPE_CODE_PASCAL_ARRAY: /* Array with explicit type of index */ - case TYPE_CODE_MEMBER: /* Member type */ - case TYPE_CODE_METHOD: /* Method type */ - /* Don't know how to pass these yet. */ - - case TYPE_CODE_UNDEF: /* Not used; catches errors */ - default: - abort (); - } -} - -static void -store_parm_word (address, val) - CORE_ADDR address; - int val; -{ - write_memory (address, &val, 4); -} - -static int -store_parm (prev_words, left_parm_addr, v) - unsigned int prev_words; - CORE_ADDR left_parm_addr; - struct value *v; -{ - CORE_ADDR start = left_parm_addr + (prev_words * 4); - int *val_addr = (int *)VALUE_CONTENTS(v); - - switch (TYPE_CODE (VALUE_TYPE (v))) - { - case TYPE_CODE_VOID: /* Void type (values zero length) */ - - return 0; - - case TYPE_CODE_PTR: /* Pointer type */ - case TYPE_CODE_ENUM: /* Enumeration type */ - case TYPE_CODE_INT: /* Integer type */ - case TYPE_CODE_ARRAY: /* Array type, lower bound zero */ - case TYPE_CODE_REF: /* C++ Reference types */ - - store_parm_word (start, *val_addr); - return 1; - - case TYPE_CODE_FLT: /* Floating type */ - - if (TYPE_LENGTH (VALUE_TYPE (v)) == 4) - { - store_parm_word (start, *val_addr); - return 1; - } - else - { - store_parm_word (start + ((prev_words & 1) * 4), val_addr[0]); - store_parm_word (start + ((prev_words & 1) * 4) + 4, val_addr[1]); - return 2 + (prev_words & 1); - } - - case TYPE_CODE_STRUCT: /* C struct or Pascal record */ - case TYPE_CODE_UNION: /* C union or Pascal variant part */ - - { - unsigned int words = (((TYPE_LENGTH (VALUE_TYPE (v)) + 3) / 4) * 4); - unsigned int word; - - for (word = 0; word < words; word++) - store_parm_word (start + (word * 4), val_addr[word]); - return words; - } - - default: - abort (); - } -} - - /* This routine sets up all of the parameter values needed to make a pseudo - call. The name "push_parameters" is a misnomer on some archs, - because (on the m88k) most parameters generally end up being passed in - registers rather than on the stack. In this routine however, we do - end up storing *all* parameter values onto the stack (even if we will - realize later that some of these stores were unnecessary). */ - -#define FIRST_PARM_REGNUM 2 - -void -push_parameters (return_type, struct_conv, nargs, args) - struct type *return_type; - int struct_conv; - int nargs; - value *args; -{ - int parm_num; - unsigned int p_words = 0; - CORE_ADDR left_parm_addr; - - /* Start out by creating a space for the return value (if need be). We - only need to do this if the return value is a struct or union. If we - do make a space for a struct or union return value, then we must also - arrange for the base address of that space to go into r12, which is the - standard place to pass the address of the return value area to the - callee. Note that only structs and unions are returned in this fashion. - Ints, enums, pointers, and floats are returned into r2. Doubles are - returned into the register pair {r2,r3}. Note also that the space - reserved for a struct or union return value only has to be word aligned - (not double-word) but it is double-word aligned here anyway (just in - case that becomes important someday). */ - - switch (TYPE_CODE (return_type)) - { - case TYPE_CODE_STRUCT: - case TYPE_CODE_UNION: - { - int return_bytes = ((TYPE_LENGTH (return_type) + 7) / 8) * 8; - CORE_ADDR rv_addr; - - rv_addr = read_register (SP_REGNUM) - return_bytes; - - write_register (SP_REGNUM, rv_addr); /* push space onto the stack */ - write_register (SRA_REGNUM, rv_addr);/* set return value register */ - } - } - - /* Here we make a pre-pass on the whole parameter list to figure out exactly - how many words worth of stuff we are going to pass. */ - - for (p_words = 0, parm_num = 0; parm_num < nargs; parm_num++) - p_words += pushed_size (p_words, value_arg_coerce (args[parm_num])); - - /* Now, check to see if we have to round up the number of parameter words - to get up to the next 8-bytes boundary. This may be necessary because - of the software convention to always keep the stack aligned on an 8-byte - boundary. */ - - if (p_words & 1) - p_words++; /* round to 8-byte boundary */ - - /* Now figure out the absolute address of the leftmost parameter, and update - the stack pointer to point at that address. */ - - left_parm_addr = read_register (SP_REGNUM) - (p_words * 4); - write_register (SP_REGNUM, left_parm_addr); - - /* Now we can go through all of the parameters (in left-to-right order) - and write them to their parameter stack slots. Note that we are not - really "pushing" the parameter values. The stack space for these values - was already allocated above. Now we are just filling it up. */ - - for (p_words = 0, parm_num = 0; parm_num < nargs; parm_num++) - p_words += - store_parm (p_words, left_parm_addr, value_arg_coerce (args[parm_num])); - - /* Now that we are all done storing the parameter values into the stack, we - must go back and load up the parameter registers with the values from the - corresponding stack slots. Note that in the two cases of (a) gaps in the - parameter word sequence causes by (otherwise) misaligned doubles, and (b) - slots correcponding to structs or unions, the work we do here in loading - some parameter registers may be unnecessary, but who cares? */ - - for (p_words = 0; p_words < 8; p_words++) - { - write_register (FIRST_PARM_REGNUM + p_words, - read_memory_integer (left_parm_addr + (p_words * 4), 4)); - } -} - -void -pop_frame () -{ - error ("Feature not implemented for the m88k yet."); - return; -} - -void -collect_returned_value (rval, value_type, struct_return, nargs, args) - value *rval; - struct type *value_type; - int struct_return; - int nargs; - value *args; -{ - char retbuf[REGISTER_BYTES]; - - bcopy (registers, retbuf, REGISTER_BYTES); - *rval = value_being_returned (value_type, retbuf, struct_return); - return; -} - -#if 0 -/* Now handled in a machine independent way with CALL_DUMMY_LOCATION. */ - /* Stuff a breakpoint instruction onto the stack (or elsewhere if the stack - is not a good place for it). Return the address at which the instruction - got stuffed, or zero if we were unable to stuff it anywhere. */ - -CORE_ADDR -push_breakpoint () -{ - static char breakpoint_insn[] = BREAKPOINT; - extern CORE_ADDR text_end; /* of inferior */ - static char readback_buffer[] = BREAKPOINT; - int i; - - /* With a little bit of luck, we can just stash the breakpoint instruction - in the word just beyond the end of normal text space. For systems on - which the hardware will not allow us to execute out of the stack segment, - we have to hope that we *are* at least allowed to effectively extend the - text segment by one word. If the actual end of user's the text segment - happens to fall right at a page boundary this trick may fail. Note that - we check for this by reading after writing, and comparing in order to - be sure that the write worked. */ - - write_memory (text_end, &breakpoint_insn, 4); - - /* Fill the readback buffer with some garbage which is certain to be - unequal to the breakpoint insn. That way we can tell if the - following read doesn't actually succeed. */ - - for (i = 0; i < sizeof (readback_buffer); i++) - readback_buffer[i] = ~ readback_buffer[i]; /* Invert the bits */ - - /* Now check that the breakpoint insn was successfully installed. */ - - read_memory (text_end, readback_buffer, sizeof (readback_buffer)); - for (i = 0; i < sizeof (readback_buffer); i++) - if (readback_buffer[i] != breakpoint_insn[i]) - return 0; /* Failed to install! */ - - return text_end; -} -#endif diff --git a/gdb/m88k-xdep.c b/gdb/m88k-xdep.c deleted file mode 100644 index 835d8a229f2..00000000000 --- a/gdb/m88k-xdep.c +++ /dev/null @@ -1,330 +0,0 @@ -/* Copyright (C) 1988, 1990 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "defs.h" -#include "param.h" -#include "frame.h" -#include "inferior.h" - -#ifdef USG -#include -#endif - -#include -#include -#include -#include "gdbcore.h" -#include - -#ifndef USER /* added to support BCS ptrace_user */ -#define USER ptrace_user -#endif -#include -#include -#include -#include - -#include "symtab.h" -#include "setjmp.h" -#include "value.h" - -#ifdef DELTA88 -#include - -/* define offsets to the pc instruction offsets in ptrace_user struct */ -#define SXIP_OFFSET (char *)&u.pt_sigframe.sig_sxip - (char *)&u -#define SNIP_OFFSET (char *)&u.pt_sigframe.sig_snip - (char *)&u -#define SFIP_OFFSET (char *)&u.pt_sigframe.sig_sfip - (char *)&u -#else -/* define offsets to the pc instruction offsets in ptrace_user struct */ -#define SXIP_OFFSET (char *)&u.pt_sigframe.dg_sigframe.sc_sxip - (char *)&u -#define SNIP_OFFSET (char *)&u.pt_sigframe.dg_sigframe.sc_snip - (char *)&u -#define SFIP_OFFSET (char *)&u.pt_sigframe.dg_sigframe.sc_sfip - (char *)&u -#endif - -extern int have_symbol_file_p(); - -extern jmp_buf stack_jmp; - -extern int errno; -extern char registers[REGISTER_BYTES]; - -void -fetch_inferior_registers () -{ - register int regno; - register unsigned int regaddr; - char buf[MAX_REGISTER_RAW_SIZE]; - register int i; - - struct USER u; - unsigned int offset; - - offset = (char *) &u.pt_r0 - (char *) &u; - regaddr = offset; /* byte offset to r0;*/ - -/* offset = ptrace (3, inferior_pid, offset, 0) - KERNEL_U_ADDR; */ - for (regno = 0; regno < NUM_REGS; regno++) - { - /*regaddr = register_addr (regno, offset);*/ - /* 88k enhancement */ - - for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int)) - { - *(int *) &buf[i] = ptrace (3, inferior_pid, regaddr, 0); - regaddr += sizeof (int); - } - supply_register (regno, buf); - } - /* now load up registers 36 - 38; special pc registers */ - *(int *) &buf[0] = ptrace (3,inferior_pid,SXIP_OFFSET ,0); - supply_register (SXIP_REGNUM, buf); - *(int *) &buf[0] = ptrace (3, inferior_pid,SNIP_OFFSET,0); - supply_register (SNIP_REGNUM, buf); - *(int *) &buf[0] = ptrace (3, inferior_pid,SFIP_OFFSET,0); - supply_register (SFIP_REGNUM, buf); -} - -/* Store our register values back into the inferior. - If REGNO is -1, do this for all registers. - Otherwise, REGNO specifies which register (so we can save time). */ - -store_inferior_registers (regno) - int regno; -{ - register unsigned int regaddr; - char buf[80]; - - struct USER u; - - - unsigned int offset = (char *) &u.pt_r0 - (char *) &u; - - regaddr = offset; - - if (regno >= 0) - { -/* regaddr = register_addr (regno, offset); */ - if (regno < PC_REGNUM) - { - regaddr = offset + regno * sizeof (int); - errno = 0; - ptrace (6, inferior_pid, regaddr, read_register (regno)); - if (errno != 0) - { - sprintf (buf, "writing register number %d", regno); - perror_with_name (buf); - } - } - else if (regno == SXIP_REGNUM) - ptrace (6, inferior_pid, SXIP_OFFSET, read_register(regno)); - else if (regno == SNIP_REGNUM) - ptrace (6, inferior_pid, SNIP_OFFSET, read_register(regno)); - else if (regno == SFIP_REGNUM) - ptrace (6, inferior_pid, SFIP_OFFSET, read_register(regno)); - else printf ("Bad register number for store_inferior routine\n"); - } - else { - for (regno = 0; regno < NUM_REGS - 3; regno++) - { - /* regaddr = register_addr (regno, offset); */ - errno = 0; - regaddr = offset + regno * sizeof (int); - ptrace (6, inferior_pid, regaddr, read_register (regno)); - if (errno != 0) - { - sprintf (buf, "writing register number %d", regno); - perror_with_name (buf); - } - } - ptrace (6,inferior_pid,SXIP_OFFSET,read_register(SXIP_REGNUM)); - ptrace (6,inferior_pid,SNIP_OFFSET,read_register(SNIP_REGNUM)); - ptrace (6,inferior_pid,SFIP_OFFSET,read_register(SFIP_REGNUM)); - } - - -} - -#if 0 -/* Core files are now a function of BFD. */ - -void -core_file_command (filename, from_tty) - char *filename; - int from_tty; -{ - int val; - extern char registers[]; - - /* Need symbol file and one with tdesc info for corefiles to work */ - if (!have_symbol_file_p()) - error ("Requires symbol-file and exec-file"); - if (!execfile) - error ("Requires exec-file and symbol-file"); - - /* Discard all vestiges of any previous core file - and mark data and stack spaces as empty. */ - - if (corefile) - free (corefile); - corefile = 0; - - if (corechan >= 0) - close (corechan); - corechan = -1; - - data_start = 0; - data_end = 0; - stack_start = STACK_END_ADDR; - stack_end = STACK_END_ADDR; - - /* Now, if a new core file was specified, open it and digest it. */ - - if (filename) - { - filename = tilde_expand (filename); - make_cleanup (free, filename); - - if (have_inferior_p ()) - error ("To look at a core file, you must kill the inferior with \"kill\"."); - corechan = open (filename, O_RDONLY, 0); - if (corechan < 0) - perror_with_name (filename); - /* 4.2-style (and perhaps also sysV-style) core dump file. */ - { - struct USER u; - - int reg_offset; - - val = myread (corechan, &u, sizeof u); - if (val < 0) - perror_with_name (filename); - data_start = u.pt_o_data_start; - - data_end = data_start + u.pt_dsize; - stack_start = stack_end - u.pt_ssize; - data_offset = u.pt_dataptr; - stack_offset = data_offset + u.pt_dsize; - -#if defined(BCS) -#if defined(DGUX) - - reg_offset = 2048; - - -#endif /* defined (DGUX) */ -#else - - /* original code: */ - reg_offset = (int) u.pt_r0 - KERNEL_U_ADDR; - -#endif /* defined(BCS) */ - - /* I don't know where to find this info. - So, for now, mark it as not available. */ -/* N_SET_MAGIC (core_aouthdr, 0); */ - bzero ((char *) &core_aouthdr, sizeof core_aouthdr); - - /* Read the register values out of the core file and store - them where `read_register' will find them. */ - - { - register int regno; - - for (regno = 0; regno < NUM_REGS; regno++) - { - char buf[MAX_REGISTER_RAW_SIZE]; - - val = lseek (corechan, register_addr (regno, reg_offset), 0); - if (val < 0) - perror_with_name (filename); - - val = myread (corechan, buf, sizeof buf); - if (val < 0) - perror_with_name (filename); - supply_register (regno, buf); - } - } - } - if (filename[0] == '/') - corefile = savestring (filename, strlen (filename)); - else - { - corefile = concat (current_directory, "/", filename, NULL); - } - init_tdesc(); - current_context = init_dcontext(); - set_current_frame ( create_new_frame(get_frame_base (read_pc()), - read_pc ())); - select_frame (get_current_frame (), 0); - validate_files (); - } - else if (from_tty) - printf ("No core file now.\n"); -} -#endif - -/* blockend is the address of the end of the user structure */ -m88k_register_u_addr (blockend, regnum) -{ - struct USER u; - int ustart = blockend - sizeof (struct USER); - switch (regnum) - { - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - case 6: - case 7: - case 8: - case 9: - case 10: - case 11: - case 12: - case 13: - case 14: - case 15: - case 16: - case 17: - case 18: - case 19: - case 20: - case 21: - case 22: - case 23: - case 24: - case 25: - case 26: - case 27: - case 28: - case 29: - case 30: - case 31: return (ustart + ((int) &u.pt_r0 - (int) &u) + sizeof(REGISTER_TYPE) * regnum); - case PSR_REGNUM: return (ustart + ((int) &u.pt_psr - (int) &u)); - case FPSR_REGNUM: return (ustart + ((int) &u.pt_fpsr - (int) &u)); - case FPCR_REGNUM: return (ustart + ((int) &u.pt_fpcr - (int) &u)); - case SXIP_REGNUM: return (ustart + SXIP_OFFSET); - case SNIP_REGNUM: return (ustart + SNIP_OFFSET); - case SFIP_REGNUM: return (ustart + SFIP_OFFSET); - default: return (blockend + sizeof (REGISTER_TYPE) * regnum); - } -} diff --git a/gdb/mach386-xdep.c b/gdb/mach386-xdep.c deleted file mode 100644 index 754299a7452..00000000000 --- a/gdb/mach386-xdep.c +++ /dev/null @@ -1,154 +0,0 @@ -/* Machine-dependent code for host Mach 386's for GDB, the GNU debugger. - Copyright (C) 1986, 1987, 1989, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "defs.h" -#include "param.h" -#include "frame.h" -#include "inferior.h" -#include "signame.h" -#include "gdbcore.h" - -#if defined (GDB_TARGET_IS_MACH386) - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include - -void -fetch_inferior_registers () -{ - struct regs inferior_registers; - struct fp_state inferior_fp_registers; - extern char registers[]; - - registers_fetched (); - - ptrace (PTRACE_GETREGS, inferior_pid, &inferior_registers); - ptrace (PTRACE_GETFPREGS, inferior_pid, &inferior_fp_registers); - - bcopy (&inferior_registers, registers, sizeof inferior_registers); - - bcopy (inferior_fp_registers.f_st,®isters[REGISTER_BYTE (FP0_REGNUM)], - sizeof inferior_fp_registers.f_st); - bcopy (&inferior_fp_registers.f_ctrl, - ®isters[REGISTER_BYTE (FPC_REGNUM)], - sizeof inferior_fp_registers - sizeof inferior_fp_registers.f_st); -} - -/* Store our register values back into the inferior. - If REGNO is -1, do this for all registers. - Otherwise, REGNO specifies which register (so we can save time). */ - -store_inferior_registers (regno) - int regno; -{ - struct regs inferior_registers; - struct fp_state inferior_fp_registers; - extern char registers[]; - - bcopy (registers, &inferior_registers, 20 * 4); - - bcopy (®isters[REGISTER_BYTE (FP0_REGNUM)],inferior_fp_registers.f_st, - sizeof inferior_fp_registers.f_st); - bcopy (®isters[REGISTER_BYTE (FPC_REGNUM)], - &inferior_fp_registers.f_ctrl, - sizeof inferior_fp_registers - sizeof inferior_fp_registers.f_st); - -#ifdef PTRACE_FP_BUG - if (regno == FP_REGNUM || regno == -1) - /* Storing the frame pointer requires a gross hack, in which an - instruction that moves eax into ebp gets single-stepped. */ - { - int stack = inferior_registers.r_reg[SP_REGNUM]; - int stuff = ptrace (PTRACE_PEEKDATA, inferior_pid, stack); - int reg = inferior_registers.r_reg[EAX]; - inferior_registers.r_reg[EAX] = - inferior_registers.r_reg[FP_REGNUM]; - ptrace (PTRACE_SETREGS, inferior_pid, &inferior_registers); - ptrace (PTRACE_POKEDATA, inferior_pid, stack, 0xc589); - ptrace (PTRACE_SINGLESTEP, inferior_pid, stack, 0); - wait (0); - ptrace (PTRACE_POKEDATA, inferior_pid, stack, stuff); - inferior_registers.r_reg[EAX] = reg; - } -#endif - ptrace (PTRACE_SETREGS, inferior_pid, &inferior_registers); - ptrace (PTRACE_SETFPREGS, inferior_pid, &inferior_fp_registers); -} - -#else /* Not mach386 target. */ - -/* These functions shouldn't be called when we're cross-debugging. */ - -void -fetch_inferior_registers () -{ -} - -/* ARGSUSED */ -store_inferior_registers (regno) - int regno; -{ -} - -#endif /* Not mach386 target. */ - -/* Work with core files, for GDB. */ - -void -fetch_core_registers (core_reg_sect, core_reg_size, which) - char *core_reg_sect; - unsigned core_reg_size; - int which; -{ - int val; - extern char registers[]; - - switch (which) { - case 0: - case 1: - bcopy (core_reg_sect, registers, core_reg_size); - break; - - case 2: -#ifdef FP0_REGNUM - bcopy (core_reg_sect, - ®isters[REGISTER_BYTE (FP0_REGNUM)], - core_reg_size); /* FIXME, probably bogus */ -#endif -#ifdef FPC_REGNUM - bcopy (&corestr.c_fpu.f_fpstatus.f_ctrl, - ®isters[REGISTER_BYTE (FPC_REGNUM)], - sizeof corestr.c_fpu.f_fpstatus - - sizeof corestr.c_fpu.f_fpstatus.f_st); -#endif - break; - } -} diff --git a/gdb/main.c b/gdb/main.c deleted file mode 100644 index 936879cf001..00000000000 --- a/gdb/main.c +++ /dev/null @@ -1,2196 +0,0 @@ -/* Top level for GDB, the GNU debugger. - Copyright (C) 1986, 1987, 1988, 1989, 1990 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -int fclose (); -#include "defs.h" -#include "gdbcmd.h" -#include "param.h" -#include "symtab.h" -#include "inferior.h" -#include "signals.h" -#include "target.h" -#include "breakpoint.h" -#include "language.h" - -#include "getopt.h" - -/* readline include files */ -#include "readline.h" -#include "history.h" - -/* readline defines this. */ -#undef savestring - -#ifdef USG -#include -#include -#endif - -#include -#include -#include -#include -#include -#include - -#ifdef SET_STACK_LIMIT_HUGE -#include -#include - -int original_stack_limit; -#endif - - -/* If this definition isn't overridden by the header files, assume - that isatty and fileno exist on this system. */ -#ifndef ISATTY -#define ISATTY(FP) (isatty (fileno (FP))) -#endif - -/* Initialization file name for gdb. This is overridden in some configs. */ - -#ifndef GDBINIT_FILENAME -#define GDBINIT_FILENAME ".gdbinit" -#endif -char gdbinit[] = GDBINIT_FILENAME; - -#define ALL_CLEANUPS ((struct cleanup *)0) - -/* Version number of GDB, as a string. */ - -extern char *version; - -/* Message to be printed before the error message, when an error occurs. */ - -extern char *error_pre_print; - -extern char lang_frame_mismatch_warn[]; /* language.c */ - -/* Flag for whether we want all the "from_tty" gubbish printed. */ - -int caution = 1; /* Default is yes, sigh. */ - -/* - * Define all cmd_list_element's - */ - -/* Chain containing all defined commands. */ - -struct cmd_list_element *cmdlist; - -/* Chain containing all defined info subcommands. */ - -struct cmd_list_element *infolist; - -/* Chain containing all defined enable subcommands. */ - -struct cmd_list_element *enablelist; - -/* Chain containing all defined disable subcommands. */ - -struct cmd_list_element *disablelist; - -/* Chain containing all defined delete subcommands. */ - -struct cmd_list_element *deletelist; - -/* Chain containing all defined "enable breakpoint" subcommands. */ - -struct cmd_list_element *enablebreaklist; - -/* Chain containing all defined set subcommands */ - -struct cmd_list_element *setlist; - -/* Chain containing all defined show subcommands. */ -struct cmd_list_element *showlist; - -/* Chain containing all defined \"set history\". */ - -struct cmd_list_element *sethistlist; - -/* Chain containing all defined \"show history\". */ -struct cmd_list_element *showhistlist; - -/* Chain containing all defined \"unset history\". */ - -struct cmd_list_element *unsethistlist; - -/* stdio stream that command input is being read from. */ - -FILE *instream; - -/* Current working directory. */ - -char *current_directory; - -/* The directory name is actually stored here (usually). */ -static char dirbuf[MAXPATHLEN]; - -/* Function to call before reading a command, if nonzero. - The function receives two args: an input stream, - and a prompt string. */ - -void (*window_hook) (); - -extern int frame_file_full_name; -int epoch_interface; -int xgdb_verbose; - -/* The external commands we call... */ -extern void init_source_path (); -extern void directory_command (); -extern void exec_file_command (); -extern void symbol_file_command (); -extern void core_file_command (); -extern void tty_command (); - -extern void help_list (); -extern void initialize_all_files (); -extern void init_malloc (); - -/* Forward declarations for this file */ -void free_command_lines (); -char *gdb_readline (); -char *command_line_input (); -static void initialize_history (); -static void initialize_main (); -static void initialize_cmd_lists (); -static void init_signals (); -static void quit_command (); -void command_loop (); -static void source_command (); -static void print_gdb_version (); -static void print_gnu_advertisement (); -static void float_handler (); -static void cd_command (); -static void read_command_file (); - -char *getenv (); - -/* gdb prints this when reading a command interactively */ -static char *prompt; - -/* Buffer used for reading command lines, and the size - allocated for it so far. */ - -char *line; -int linesize = 100; - -/* Baud rate specified for talking to serial target systems. Default - is left as a zero pointer, so targets can choose their own defaults. */ - -char *baud_rate; - -/* Signal to catch ^Z typed while reading a command: SIGTSTP or SIGCONT. */ - -#ifndef STOP_SIGNAL -#ifdef SIGTSTP -#define STOP_SIGNAL SIGTSTP -#endif -#endif - -/* Some System V have job control but not sigsetmask(). */ -#if !defined (HAVE_SIGSETMASK) -#define HAVE_SIGSETMASK !defined (USG) -#endif - -#if 0 == (HAVE_SIGSETMASK) -#define sigsetmask(n) -#endif - -/* This is how `error' returns to command level. */ - -jmp_buf to_top_level; - -void -return_to_top_level () -{ - quit_flag = 0; - immediate_quit = 0; - bpstat_clear_actions(stop_bpstat); /* Clear queued breakpoint commands */ - clear_momentary_breakpoints (); - disable_current_display (); - do_cleanups (ALL_CLEANUPS); - longjmp (to_top_level, 1); -} - -/* Call FUNC with arg ARGS, catching any errors. - If there is no error, return the value returned by FUNC. - If there is an error, print ERRSTRING, print the specific error message, - then return zero. */ - -int -catch_errors (func, args, errstring) - int (*func) (); - char *args; - char *errstring; -{ - jmp_buf saved; - int val; - struct cleanup *saved_cleanup_chain; - char *saved_error_pre_print; - - saved_cleanup_chain = save_cleanups (); - saved_error_pre_print = error_pre_print; - - bcopy (to_top_level, saved, sizeof (jmp_buf)); - error_pre_print = errstring; - - if (setjmp (to_top_level) == 0) - val = (*func) (args); - else - val = 0; - - restore_cleanups (saved_cleanup_chain); - - error_pre_print = saved_error_pre_print; - bcopy (saved, to_top_level, sizeof (jmp_buf)); - return val; -} - -/* Handler for SIGHUP. */ - -static void -disconnect () -{ - kill_inferior_fast (); - signal (SIGHUP, SIG_DFL); - kill (getpid (), SIGHUP); -} - -/* Clean up on error during a "source" command (or execution of a - user-defined command). */ - -static void -source_cleanup (stream) - FILE *stream; -{ - /* Restore the previous input stream. */ - instream = stream; -} - -/* Read commands from STREAM. */ -static void -read_command_file (stream) - FILE *stream; -{ - struct cleanup *cleanups; - - cleanups = make_cleanup (source_cleanup, instream); - instream = stream; - command_loop (); - do_cleanups (cleanups); -} - -int -main (argc, argv) - int argc; - char **argv; -{ - int count; - static int inhibit_gdbinit = 0; - static int quiet = 0; - static int batch = 0; - - /* Pointers to various arguments from command line. */ - char *symarg = NULL; - char *execarg = NULL; - char *corearg = NULL; - char *cdarg = NULL; - char *ttyarg = NULL; - - /* Pointers to all arguments of +command option. */ - char **cmdarg; - /* Allocated size of cmdarg. */ - int cmdsize; - /* Number of elements of cmdarg used. */ - int ncmd; - - /* Indices of all arguments of +directory option. */ - char **dirarg; - /* Allocated size. */ - int dirsize; - /* Number of elements used. */ - int ndir; - - register int i; - - /* This needs to happen before the first use of malloc. */ - init_malloc (); - -#if defined (ALIGN_STACK_ON_STARTUP) - i = (int) &count & 0x3; - if (i != 0) - alloca (4 - i); -#endif - - /* If error() is called from initialization code, just exit */ - if (setjmp (to_top_level)) { - exit(1); - } - - cmdsize = 1; - cmdarg = (char **) xmalloc (cmdsize * sizeof (*cmdarg)); - ncmd = 0; - dirsize = 1; - dirarg = (char **) xmalloc (dirsize * sizeof (*dirarg)); - ndir = 0; - - quit_flag = 0; - line = (char *) xmalloc (linesize); - line[0] = '\0'; /* Terminate saved (now empty) cmd line */ - instream = stdin; - - getwd (dirbuf); - current_directory = dirbuf; - -#ifdef SET_STACK_LIMIT_HUGE - { - struct rlimit rlim; - - /* Set the stack limit huge so that alloca (particularly stringtab - * in dbxread.c) does not fail. */ - getrlimit (RLIMIT_STACK, &rlim); - original_stack_limit = rlim.rlim_cur; - rlim.rlim_cur = rlim.rlim_max; - setrlimit (RLIMIT_STACK, &rlim); - } -#endif /* SET_STACK_LIMIT_HUGE */ - - /* Parse arguments and options. */ - { - int c; - static int print_help; - /* When var field is 0, use flag field to record the equivalent - short option (or arbitrary numbers starting at 10 for those - with no equivalent). */ - static struct option long_options[] = - { - {"quiet", 0, &quiet, 1}, - {"nx", 0, &inhibit_gdbinit, 1}, - {"batch", 0, &batch, 1}, - {"epoch", 0, &epoch_interface, 1}, - {"fullname", 0, &frame_file_full_name, 1}, - {"help", 0, &print_help, 1}, - {"se", 1, 0, 10}, - {"symbols", 1, 0, 's'}, - {"s", 1, 0, 's'}, - {"exec", 1, 0, 'e'}, - {"core", 1, 0, 'c'}, - {"c", 1, 0, 'c'}, - {"command", 1, 0, 'x'}, - {"x", 1, 0, 'x'}, - {"directory", 1, 0, 'd'}, - {"cd", 1, 0, 11}, - {"tty", 1, 0, 't'}, - {"b", 1, 0, 'b'}, -/* Allow machine descriptions to add more options... */ -#ifdef ADDITIONAL_OPTIONS - ADDITIONAL_OPTIONS -#endif - {0, 0, 0, 0}, - }; - - while (1) - { - c = getopt_long_only (argc, argv, "", - long_options, &option_index); - if (c == EOF) - break; - - /* Long option that takes an argument. */ - if (c == 0 && long_options[option_index].flag == 0) - c = long_options[option_index].val; - - switch (c) - { - case 0: - /* Long option that just sets a flag. */ - break; - case 10: - symarg = optarg; - execarg = optarg; - break; - case 11: - cdarg = optarg; - break; - case 's': - symarg = optarg; - break; - case 'e': - execarg = optarg; - break; - case 'c': - corearg = optarg; - break; - case 'x': - cmdarg[ncmd++] = optarg; - if (ncmd >= cmdsize) - { - cmdsize *= 2; - cmdarg = (char **) xrealloc ((char *)cmdarg, - cmdsize * sizeof (*cmdarg)); - } - break; - case 'd': - dirarg[ndir++] = optarg; - if (ndir >= dirsize) - { - dirsize *= 2; - dirarg = (char **) xrealloc ((char *)dirarg, - dirsize * sizeof (*dirarg)); - } - break; - case 't': - ttyarg = optarg; - break; - case 'q': - quiet = 1; - break; - case 'b': - baud_rate = optarg; - break; -#ifdef ADDITIONAL_OPTION_CASES - ADDITIONAL_OPTION_CASES -#endif - case '?': - fprintf (stderr, - "Use `%s +help' for a complete list of options.\n", - argv[0]); - exit (1); - } - - } - if (print_help) - { - fputs ("\ -This is GDB, the GNU debugger. Use the command\n\ - gdb [options] [executable [core-file]]\n\ -to enter the debugger.\n\ -\n\ -Options available are:\n\ - -help Print this message.\n\ - -quiet Do not print version number on startup.\n\ - -fullname Output information used by emacs-GDB interface.\n\ - -epoch Output information used by epoch emacs-GDB interface.\n\ - -batch Exit after processing options.\n\ - -nx Do not read .gdbinit file.\n\ - -tty=TTY Use TTY for input/output by the program being debugged.\n\ - -cd=DIR Change current directory to DIR.\n\ - -directory=DIR Search for source files in DIR.\n\ - -command=FILE Execute GDB commands from FILE.\n\ - -symbols=SYMFILE Read symbols from SYMFILE.\n\ - -exec=EXECFILE Use EXECFILE as the executable.\n\ - -se=FILE Use FILE as symbol file and executable file.\n\ - -core=COREFILE Analyze the core dump COREFILE.\n\ - -b BAUDRATE Set serial port baud rate used for remote debugging\n\ -", stderr); -#ifdef ADDITIONAL_OPTION_HELP - fputs (ADDITIONAL_OPTION_HELP, stderr); -#endif - fputs ("\n\ -For more information, type \"help\" from within GDB, or consult the\n\ -GDB manual (available as on-line info or a printed manual).\n", stderr); - /* Exiting after printing this message seems like - the most useful thing to do. */ - exit (0); - } - - /* OK, that's all the options. The other arguments are filenames. */ - count = 0; - for (; optind < argc; optind++) - switch (++count) - { - case 1: - symarg = argv[optind]; - execarg = argv[optind]; - break; - case 2: - corearg = argv[optind]; - break; - case 3: - fprintf (stderr, - "Excess command line arguments ignored. (%s%s)\n", - argv[optind], (optind == argc - 1) ? "" : " ..."); - break; - } - if (batch) - quiet = 1; - } - - /* Run the init function of each source file */ - - initialize_cmd_lists (); /* This needs to be done first */ - initialize_all_files (); - initialize_main (); /* But that omits this file! Do it now */ - init_signals (); - - if (!quiet) - { - /* Print all the junk at the top, with trailing "..." if we are about - to read a symbol file (possibly slowly). */ - print_gnu_advertisement (); - print_gdb_version (); - if (symarg) - printf_filtered (".."); - wrap_here(""); - fflush (stdout); /* Force to screen during slow operations */ - } - - error_pre_print = "\n\n"; - - /* Now perform all the actions indicated by the arguments. */ - if (cdarg != NULL) - { - if (!setjmp (to_top_level)) - { - cd_command (cdarg, 0); - init_source_path (); - } - } - do_cleanups (ALL_CLEANUPS); - - for (i = 0; i < ndir; i++) - if (!setjmp (to_top_level)) - directory_command (dirarg[i], 0); - free (dirarg); - do_cleanups (ALL_CLEANUPS); - - if (execarg != NULL - && symarg != NULL - && strcmp (execarg, symarg) == 0) - { - /* The exec file and the symbol-file are the same. If we can't open - it, better only print one error message. */ - if (!setjmp (to_top_level)) - { - exec_file_command (execarg, !batch); - symbol_file_command (symarg, 0); - } - } - else - { - if (execarg != NULL) - if (!setjmp (to_top_level)) - exec_file_command (execarg, !batch); - if (symarg != NULL) - if (!setjmp (to_top_level)) - symbol_file_command (symarg, 0); - } - do_cleanups (ALL_CLEANUPS); - - /* After the symbol file has been read, print a newline to get us - beyond the copyright line... But errors should still set off - the error message with a (single) blank line. */ - if (!quiet) - printf_filtered ("\n"); - error_pre_print = "\n"; - - if (corearg != NULL) - if (!setjmp (to_top_level)) - core_file_command (corearg, !batch); - else if (isdigit (corearg[0]) && !setjmp (to_top_level)) - attach_command (corearg, !batch); - do_cleanups (ALL_CLEANUPS); - - if (ttyarg != NULL) - if (!setjmp (to_top_level)) - tty_command (ttyarg, !batch); - do_cleanups (ALL_CLEANUPS); - -#ifdef ADDITIONAL_OPTION_HANDLER - ADDITIONAL_OPTION_HANDLER; -#endif - - /* Error messages should no longer be distinguished with extra output. */ - error_pre_print = 0; - - { - struct stat homebuf, cwdbuf; - char *homedir, *homeinit; - - /* Read init file, if it exists in home directory */ - homedir = getenv ("HOME"); - if (homedir) - { - homeinit = (char *) alloca (strlen (getenv ("HOME")) + - strlen (gdbinit) + 10); - strcpy (homeinit, getenv ("HOME")); - strcat (homeinit, "/"); - strcat (homeinit, gdbinit); - if (!inhibit_gdbinit && access (homeinit, R_OK) == 0) - if (!setjmp (to_top_level)) - source_command (homeinit, 0); - do_cleanups (ALL_CLEANUPS); - - /* Do stats; no need to do them elsewhere since we'll only - need them if homedir is set. Make sure that they are - zero in case one of them fails (this guarantees that they - won't match if either exists). */ - - bzero (&homebuf, sizeof (struct stat)); - bzero (&cwdbuf, sizeof (struct stat)); - - stat (homeinit, &homebuf); - stat (gdbinit, &cwdbuf); /* We'll only need this if - homedir was set. */ - } - - /* Read the input file in the current directory, *if* it isn't - the same file (it should exist, also). */ - - if (!homedir - || bcmp ((char *) &homebuf, - (char *) &cwdbuf, - sizeof (struct stat))) - if (!inhibit_gdbinit && access (gdbinit, R_OK) == 0) - if (!setjmp (to_top_level)) - source_command (gdbinit, 0); - do_cleanups (ALL_CLEANUPS); - } - - for (i = 0; i < ncmd; i++) - if (!setjmp (to_top_level)) - { - if (cmdarg[i][0] == '-' && cmdarg[i][1] == '\0') - read_command_file (stdin); - else - source_command (cmdarg[i], !batch); - do_cleanups (ALL_CLEANUPS); - } - free (cmdarg); - - /* Read in the old history after all the command files have been read. */ - initialize_history(); - - if (batch) - { - /* We have hit the end of the batch file. */ - exit (0); - } - - /* Do any host- or target-specific hacks. This is used for i960 targets - to force the user to set a nindy target and spec its parameters. */ - -#ifdef BEFORE_MAIN_LOOP_HOOK - BEFORE_MAIN_LOOP_HOOK; -#endif - - /* The command loop. */ - - while (1) - { - if (!setjmp (to_top_level)) - { - do_cleanups (ALL_CLEANUPS); /* Do complete cleanup */ - command_loop (); - quit_command ((char *)0, instream == stdin); - } - } - /* No exit -- exit is through quit_command. */ -} - -/* Execute the line P as a command. - Pass FROM_TTY as second argument to the defining function. */ - -void -execute_command (p, from_tty) - char *p; - int from_tty; -{ - register struct cmd_list_element *c; - register struct command_line *cmdlines; - register enum language flang; - static struct language_defn *saved_language = 0; - static int warned = 0; - - free_all_values (); - - /* This can happen when command_line_input hits end of file. */ - if (p == NULL) - return; - - while (*p == ' ' || *p == '\t') p++; - if (*p) - { - char *arg; - - c = lookup_cmd (&p, cmdlist, "", 0, 1); - /* Pass null arg rather than an empty one. */ - arg = *p ? p : 0; - if (c->class == class_user) - { - struct cleanup *old_chain; - - if (*p) - error ("User-defined commands cannot take arguments."); - cmdlines = c->user_commands; - if (cmdlines == 0) - /* Null command */ - return; - - /* Set the instream to 0, indicating execution of a - user-defined function. */ - old_chain = make_cleanup (source_cleanup, instream); - instream = (FILE *) 0; - while (cmdlines) - { - execute_command (cmdlines->line, 0); - cmdlines = cmdlines->next; - } - do_cleanups (old_chain); - } - else if (c->type == set_cmd || c->type == show_cmd) - do_setshow_command (arg, from_tty & caution, c); - else if (c->function == NO_FUNCTION) - error ("That is not a command, just a help topic."); - else - (*c->function) (arg, from_tty & caution); - } - - /* Tell the user if the language has changed (except first time). */ - if (current_language != saved_language) - { - if (language_mode == language_mode_auto) { - if (saved_language) - language_info (); - } - saved_language = current_language; - warned = 0; - } - - /* Warn the user if the working language does not match the - language of the current frame. Only warn the user if we are - actually running the program, i.e. there is a stack. */ - /* FIXME: This should be cacheing the frame and only running when - the frame changes. */ - if (target_has_stack) - { - flang = get_frame_language (); - if (!warned - && flang != language_unknown - && flang != current_language->la_language) - { - printf_filtered ("%s\n", lang_frame_mismatch_warn); - warned = 1; - } - } -} - -/* ARGSUSED */ -void -command_loop_marker (foo) - int foo; -{ -} - -/* Read commands from `instream' and execute them - until end of file or error reading instream. */ -void -command_loop () -{ - struct cleanup *old_chain; - char *command; - int stdin_is_tty = ISATTY (stdin); - - while (!feof (instream)) - { - if (window_hook && instream == stdin) - (*window_hook) (instream, prompt); - - quit_flag = 0; - if (instream == stdin && stdin_is_tty) - reinitialize_more_filter (); - old_chain = make_cleanup (command_loop_marker, 0); - command = command_line_input (instream == stdin ? prompt : 0, - instream == stdin); - if (command == 0) - return; - execute_command (command, instream == stdin); - /* Do any commands attached to breakpoint we stopped at. */ - bpstat_do_actions (&stop_bpstat); - do_cleanups (old_chain); - } -} - -/* Commands call this if they do not want to be repeated by null lines. */ - -void -dont_repeat () -{ - /* If we aren't reading from standard input, we are saving the last - thing read from stdin in line and don't want to delete it. Null lines - won't repeat here in any case. */ - if (instream == stdin) - *line = 0; -} - -/* Read a line from the stream "instream" without command line editing. - - It prints PRROMPT once at the start. - Action is compatible with "readline", e.g. space for the result is - malloc'd and should be freed by the caller. - - A NULL return means end of file. */ -char * -gdb_readline (prrompt) - char *prrompt; -{ - int c; - char *result; - int input_index = 0; - int result_size = 80; - - if (prrompt) - { - printf (prrompt); - fflush (stdout); - } - - result = (char *) xmalloc (result_size); - - while (1) - { - /* Read from stdin if we are executing a user defined command. - This is the right thing for prompt_for_continue, at least. */ - c = fgetc (instream ? instream : stdin); - - if (c == EOF) - { - free (result); - return NULL; - } - - if (c == '\n') - break; - - result[input_index++] = c; - while (input_index >= result_size) - { - result_size *= 2; - result = (char *) xrealloc (result, result_size); - } - } - - result[input_index++] = '\0'; - return result; -} - -/* Declaration for fancy readline with command line editing. */ -char *readline (); - -/* Variables which control command line editing and history - substitution. These variables are given default values at the end - of this file. */ -static int command_editing_p; -static int history_expansion_p; -static int write_history_p; -static int history_size; -static char *history_filename; - -/* Variables which are necessary for fancy command line editing. */ -char *gdb_completer_word_break_characters = - " \t\n!@#$%^&*()-+=|~`}{[]\"';:?/>.<,"; - -/* Functions that are used as part of the fancy command line editing. */ - -/* This can be used for functions which don't want to complete on symbols - but don't want to complete on anything else either. */ -/* ARGSUSED */ -char ** -noop_completer (text) - char *text; -{ - return NULL; -} - -/* Generate symbol names one by one for the completer. If STATE is - zero, then we need to initialize, otherwise the initialization has - already taken place. TEXT is what we expect the symbol to start - with. RL_LINE_BUFFER is available to be looked at; it contains the - entire text of the line. RL_POINT is the offset in that line of - the cursor. You should pretend that the line ends at RL_POINT. - The result is NULL if there are no more completions, else a char - string which is a possible completion. */ -char * -symbol_completion_function (text, state) - char *text; - int state; -{ - static char **list = (char **)NULL; - static int index; - char *output; - extern char *rl_line_buffer; - extern int rl_point; - char *tmp_command, *p; - struct cmd_list_element *c, *result_list; - - if (!state) - { - /* Free the storage used by LIST, but not by the strings inside. This is - because rl_complete_internal () frees the strings. */ - if (list) - free (list); - list = 0; - index = 0; - - /* Decide whether to complete on a list of gdb commands or on - symbols. */ - tmp_command = (char *) alloca (rl_point + 1); - p = tmp_command; - - strncpy (tmp_command, rl_line_buffer, rl_point); - tmp_command[rl_point] = '\0'; - - if (rl_point == 0) - { - /* An empty line we want to consider ambiguous; that is, - it could be any command. */ - c = (struct cmd_list_element *) -1; - result_list = 0; - } - else - c = lookup_cmd_1 (&p, cmdlist, &result_list, 1); - - /* Move p up to the next interesting thing. */ - while (*p == ' ' || *p == '\t') - p++; - - if (!c) - /* He's typed something unrecognizable. Sigh. */ - list = (char **) 0; - else if (c == (struct cmd_list_element *) -1) - { - /* If we didn't recognize everything up to the thing that - needs completing, and we don't know what command it is - yet, we are in trouble. Part of the trouble might be - that the list of delimiters used by readline includes - '-', which we use in commands. Check for this. */ - if (p + strlen(text) != tmp_command + rl_point) { - if (tmp_command[rl_point - strlen(text) - 1] == '-') - text = p; - else { - /* This really should not produce an error. Better would - be to pretend to hit RETURN here; this would produce a - response like "Ambiguous command: foo, foobar, etc", - and leave the line available for re-entry with ^P. Instead, - this error blows away the user's typed input without - any way to get it back. */ - error (" Unrecognized command."); - } - } - - /* He's typed something ambiguous. This is easier. */ - if (result_list) - list = complete_on_cmdlist (*result_list->prefixlist, text); - else - list = complete_on_cmdlist (cmdlist, text); - } - else - { - /* If we've gotten this far, gdb has recognized a full - command. There are several possibilities: - - 1) We need to complete on the command. - 2) We need to complete on the possibilities coming after - the command. - 2) We need to complete the text of what comes after the - command. */ - - if (!*p && *text) - /* Always (might be longer versions of thie command). */ - list = complete_on_cmdlist (result_list, text); - else if (!*p && !*text) - { - if (c->prefixlist) - list = complete_on_cmdlist (*c->prefixlist, ""); - else - list = (*c->completer) (""); - } - else - { - if (c->prefixlist && !c->allow_unknown) - { -#if 0 - /* Something like "info adsfkdj". But error() is not - the proper response; just return no completions - instead. */ - *p = '\0'; - error ("\"%s\" command requires a subcommand.", - tmp_command); -#else - list = NULL; -#endif - } - else - list = (*c->completer) (text); - } - } - } - - /* If the debugged program wasn't compiled with symbols, or if we're - clearly completing on a command and no command matches, return - NULL. */ - if (!list) - return ((char *)NULL); - - output = list[index]; - if (output) - index++; - - return (output); -} - -#ifdef STOP_SIGNAL -static void -stop_sig () -{ -#if STOP_SIGNAL == SIGTSTP - signal (SIGTSTP, SIG_DFL); - sigsetmask (0); - kill (getpid (), SIGTSTP); - signal (SIGTSTP, stop_sig); -#else - signal (STOP_SIGNAL, stop_sig); -#endif - printf ("%s", prompt); - fflush (stdout); - - /* Forget about any previous command -- null line now will do nothing. */ - dont_repeat (); -} -#endif /* STOP_SIGNAL */ - -/* Initialize signal handlers. */ -static void -do_nothing () -{ -} - -static void -init_signals () -{ - extern void request_quit (); - - signal (SIGINT, request_quit); - - /* If we initialize SIGQUIT to SIG_IGN, then the SIG_IGN will get - passed to the inferior, which we don't want. It would be - possible to do a "signal (SIGQUIT, SIG_DFL)" after we fork, but - on BSD4.3 systems using vfork, that can affect the - GDB process as well as the inferior (the signal handling tables - might be in memory, shared between the two). Since we establish - a handler for SIGQUIT, when we call exec it will set the signal - to SIG_DFL for us. */ - signal (SIGQUIT, do_nothing); - if (signal (SIGHUP, do_nothing) != SIG_IGN) - signal (SIGHUP, disconnect); - signal (SIGFPE, float_handler); -} - -/* Read one line from the command input stream `instream' - into the local static buffer `linebuffer' (whose current length - is `linelength'). - The buffer is made bigger as necessary. - Returns the address of the start of the line. - - NULL is returned for end of file. - - *If* the instream == stdin & stdin is a terminal, the line read - is copied into the file line saver (global var char *line, - length linesize) so that it can be duplicated. - - This routine either uses fancy command line editing or - simple input as the user has requested. */ - -char * -command_line_input (prrompt, repeat) - char *prrompt; - int repeat; -{ - static char *linebuffer = 0; - static int linelength = 0; - register char *p; - char *p1; - char *rl; - char *local_prompt = prrompt; - register int c; - char *nline; - char got_eof = 0; - - if (linebuffer == 0) - { - linelength = 80; - linebuffer = (char *) xmalloc (linelength); - } - - p = linebuffer; - - /* Control-C quits instantly if typed while in this loop - since it should not wait until the user types a newline. */ - immediate_quit++; -#ifdef STOP_SIGNAL - signal (STOP_SIGNAL, stop_sig); -#endif - - while (1) - { - /* Reports are that some Sys V's don't flush stdout/err on reads - from stdin, when stdin/out are sockets rather than ttys. So we - have to do it ourselves, to make emacs-gdb and xxgdb work. - On other machines, doing this once per input should be a cheap nop. */ - fflush (stdout); - fflush (stderr); - - /* Don't use fancy stuff if not talking to stdin. */ - if (command_editing_p && instream == stdin - && ISATTY (instream)) - rl = readline (local_prompt); - else - rl = gdb_readline (local_prompt); - - if (!rl || rl == (char *) EOF) - { - got_eof = 1; - break; - } - if (strlen(rl) + 1 + (p - linebuffer) > linelength) - { - linelength = strlen(rl) + 1 + (p - linebuffer); - nline = (char *) xrealloc (linebuffer, linelength); - p += nline - linebuffer; - linebuffer = nline; - } - p1 = rl; - /* Copy line. Don't copy null at end. (Leaves line alone - if this was just a newline) */ - while (*p1) - *p++ = *p1++; - - free (rl); /* Allocated in readline. */ - - if (p == linebuffer || *(p - 1) != '\\') - break; - - p--; /* Put on top of '\'. */ - local_prompt = (char *) 0; - } - -#ifdef STOP_SIGNAL - signal (SIGTSTP, SIG_DFL); -#endif - immediate_quit--; - - if (got_eof) - return NULL; - - /* Do history expansion if that is wished. */ - if (history_expansion_p && instream == stdin - && ISATTY (instream)) - { - char *history_value; - int expanded; - - *p = '\0'; /* Insert null now. */ - expanded = history_expand (linebuffer, &history_value); - if (expanded) - { - /* Print the changes. */ - printf ("%s\n", history_value); - - /* If there was an error, call this function again. */ - if (expanded < 0) - { - free (history_value); - return command_line_input (prrompt, repeat); - } - if (strlen (history_value) > linelength) - { - linelength = strlen (history_value) + 1; - linebuffer = (char *) xrealloc (linebuffer, linelength); - } - strcpy (linebuffer, history_value); - p = linebuffer + strlen(linebuffer); - free (history_value); - } - } - - /* If we just got an empty line, and that is supposed - to repeat the previous command, return the value in the - global buffer. */ - if (repeat) - { - if (p == linebuffer) - return line; - p1 = linebuffer; - while (*p1 == ' ' || *p1 == '\t') - p1++; - if (!*p1) - return line; - } - - *p = 0; - - /* Add line to history if appropriate. */ - if (instream == stdin - && ISATTY (stdin) && *linebuffer) - add_history (linebuffer); - - /* Note: lines consisting soley of comments are added to the command - history. This is useful when you type a command, and then - realize you don't want to execute it quite yet. You can comment - out the command and then later fetch it from the value history - and remove the '#'. The kill ring is probably better, but some - people are in the habit of commenting things out. */ - p1 = linebuffer; - while ((c = *p1++) != '\0') - { - if (c == '"') - while ((c = *p1++) != '"') - { - /* Make sure an escaped '"' doesn't make us think the string - is ended. */ - if (c == '\\') - parse_escape (&p1); - if (c == '\0') - break; - } - else if (c == '\'') - while ((c = *p1++) != '\'') - { - /* Make sure an escaped '\'' doesn't make us think the string - is ended. */ - if (c == '\\') - parse_escape (&p1); - if (c == '\0') - break; - } - else if (c == '#') - { - /* Found a comment. */ - p1[-1] = '\0'; - break; - } - } - - /* Save into global buffer if appropriate. */ - if (repeat) - { - if (linelength > linesize) - { - line = xrealloc (line, linelength); - linesize = linelength; - } - strcpy (line, linebuffer); - return line; - } - - return linebuffer; -} - -/* Read lines from the input stream - and accumulate them in a chain of struct command_line's - which is then returned. */ - -struct command_line * -read_command_lines () -{ - struct command_line *first = 0; - register struct command_line *next, *tail = 0; - register char *p, *p1; - struct cleanup *old_chain = 0; - - while (1) - { - dont_repeat (); - p = command_line_input (0, instream == stdin); - if (p == NULL) - /* Treat end of file like "end". */ - break; - - /* Remove leading and trailing blanks. */ - while (*p == ' ' || *p == '\t') p++; - p1 = p + strlen (p); - while (p1 != p && (p1[-1] == ' ' || p1[-1] == '\t')) p1--; - - /* Is this "end"? */ - if (p1 - p == 3 && !strncmp (p, "end", 3)) - break; - - /* No => add this line to the chain of command lines. */ - next = (struct command_line *) xmalloc (sizeof (struct command_line)); - next->line = savestring (p, p1 - p); - next->next = 0; - if (tail) - { - tail->next = next; - } - else - { - /* We just read the first line. - From now on, arrange to throw away the lines we have - if we quit or get an error while inside this function. */ - first = next; - old_chain = make_cleanup (free_command_lines, &first); - } - tail = next; - } - - dont_repeat (); - - /* Now we are about to return the chain to our caller, - so freeing it becomes his responsibility. */ - if (first) - discard_cleanups (old_chain); - return first; -} - -/* Free a chain of struct command_line's. */ - -void -free_command_lines (lptr) - struct command_line **lptr; -{ - register struct command_line *l = *lptr; - register struct command_line *next; - - while (l) - { - next = l->next; - free (l->line); - free (l); - l = next; - } -} - -/* Add an element to the list of info subcommands. */ - -void -add_info (name, fun, doc) - char *name; - void (*fun) (); - char *doc; -{ - add_cmd (name, no_class, fun, doc, &infolist); -} - -/* Add an alias to the list of info subcommands. */ - -void -add_info_alias (name, oldname, abbrev_flag) - char *name; - char *oldname; - int abbrev_flag; -{ - add_alias_cmd (name, oldname, 0, abbrev_flag, &infolist); -} - -/* The "info" command is defined as a prefix, with allow_unknown = 0. - Therefore, its own definition is called only for "info" with no args. */ - -/* ARGSUSED */ -static void -info_command (arg, from_tty) - char *arg; - int from_tty; -{ - printf ("\"info\" must be followed by the name of an info command.\n"); - help_list (infolist, "info ", -1, stdout); -} - -/* The "show" command with no arguments shows all the settings. */ - -/* ARGSUSED */ -static void -show_command (arg, from_tty) - char *arg; - int from_tty; -{ - cmd_show_list (showlist, from_tty, ""); -} - -/* Add an element to the list of commands. */ - -void -add_com (name, class, fun, doc) - char *name; - enum command_class class; - void (*fun) (); - char *doc; -{ - add_cmd (name, class, fun, doc, &cmdlist); -} - -/* Add an alias or abbreviation command to the list of commands. */ - -void -add_com_alias (name, oldname, class, abbrev_flag) - char *name; - char *oldname; - enum command_class class; - int abbrev_flag; -{ - add_alias_cmd (name, oldname, class, abbrev_flag, &cmdlist); -} - -void -error_no_arg (why) - char *why; -{ - error ("Argument required (%s).", why); -} - -/* ARGSUSED */ -static void -help_command (command, from_tty) - char *command; - int from_tty; /* Ignored */ -{ - help_cmd (command, stdout); -} - -static void -validate_comname (comname) - char *comname; -{ - register char *p; - - if (comname == 0) - error_no_arg ("name of command to define"); - - p = comname; - while (*p) - { - if (!(*p >= 'A' && *p <= 'Z') - && !(*p >= 'a' && *p <= 'z') - && !(*p >= '0' && *p <= '9') - && *p != '-') - error ("Junk in argument list: \"%s\"", p); - p++; - } -} - -static void -define_command (comname, from_tty) - char *comname; - int from_tty; -{ - register struct command_line *cmds; - register struct cmd_list_element *c, *newc; - char *tem = comname; - extern void not_just_help_class_command (); - - validate_comname (comname); - - /* Look it up, and verify that we got an exact match. */ - c = lookup_cmd (&tem, cmdlist, "", -1, 1); - if (c && 0 != strcmp (comname, c->name)) - c = 0; - - if (c) - { - if (c->class == class_user || c->class == class_alias) - tem = "Redefine command \"%s\"? "; - else - tem = "Really redefine built-in command \"%s\"? "; - if (!query (tem, comname)) - error ("Command \"%s\" not redefined.", comname); - } - - if (from_tty) - { - printf ("Type commands for definition of \"%s\".\n\ -End with a line saying just \"end\".\n", comname); - fflush (stdout); - } - comname = savestring (comname, strlen (comname)); - - cmds = read_command_lines (); - - if (c && c->class == class_user) - free_command_lines (&c->user_commands); - - newc = add_cmd (comname, class_user, not_just_help_class_command, - (c && c->class == class_user) - ? c->doc : savestring ("User-defined.", 13), &cmdlist); - newc->user_commands = cmds; -} - -static void -document_command (comname, from_tty) - char *comname; - int from_tty; -{ - struct command_line *doclines; - register struct cmd_list_element *c; - char *tem = comname; - - validate_comname (comname); - - c = lookup_cmd (&tem, cmdlist, "", 0, 1); - - if (c->class != class_user) - error ("Command \"%s\" is built-in.", comname); - - if (from_tty) - printf ("Type documentation for \"%s\".\n\ -End with a line saying just \"end\".\n", comname); - - doclines = read_command_lines (); - - if (c->doc) free (c->doc); - - { - register struct command_line *cl1; - register int len = 0; - - for (cl1 = doclines; cl1; cl1 = cl1->next) - len += strlen (cl1->line) + 1; - - c->doc = (char *) xmalloc (len + 1); - *c->doc = 0; - - for (cl1 = doclines; cl1; cl1 = cl1->next) - { - strcat (c->doc, cl1->line); - if (cl1->next) - strcat (c->doc, "\n"); - } - } - - free_command_lines (&doclines); -} - -static void -print_gnu_advertisement() -{ - printf ("\ -GDB is free software and you are welcome to distribute copies of it\n\ - under certain conditions; type \"show copying\" to see the conditions.\n\ -There is absolutely no warranty for GDB; type \"show warranty\" for details.\n\ -"); -} - -static void -print_gdb_version () -{ - printf_filtered ("\ -GDB %s, Copyright 1991 Free Software Foundation, Inc.", - version); -} - -/* ARGSUSED */ -static void -show_version (args, from_tty) - char *args; - int from_tty; -{ - immediate_quit++; - print_gnu_advertisement (); - print_gdb_version (); - printf_filtered ("\n"); - immediate_quit--; -} - -/* xgdb calls this to reprint the usual GDB prompt. */ - -void -print_prompt () -{ - printf ("%s", prompt); - fflush (stdout); -} - -static void -quit_command (args, from_tty) - char *args; - int from_tty; -{ - if (inferior_pid != 0 && target_has_execution) - { - if (query ("The program is running. Quit anyway? ")) - { - target_kill (args, from_tty); - } - else - error ("Not confirmed."); - } - /* Save the history information if it is appropriate to do so. */ - if (write_history_p && history_filename) - write_history (history_filename); - exit (0); -} - -int -input_from_terminal_p () -{ - return (instream == stdin) & caution; -} - -/* ARGSUSED */ -static void -pwd_command (args, from_tty) - char *args; - int from_tty; -{ - if (args) error ("The \"pwd\" command does not take an argument: %s", args); - getwd (dirbuf); - - if (strcmp (dirbuf, current_directory)) - printf ("Working directory %s\n (canonically %s).\n", - current_directory, dirbuf); - else - printf ("Working directory %s.\n", current_directory); -} - -static void -cd_command (dir, from_tty) - char *dir; - int from_tty; -{ - int len; - int change; - - /* If the new directory is absolute, repeat is a no-op; if relative, - repeat might be useful but is more likely to be a mistake. */ - dont_repeat (); - - if (dir == 0) - error_no_arg ("new working directory"); - - dir = tilde_expand (dir); - make_cleanup (free, dir); - - len = strlen (dir); - dir = savestring (dir, len - (len > 1 && dir[len-1] == '/')); - if (dir[0] == '/') - current_directory = dir; - else - { - current_directory = concat (current_directory, "/", dir); - free (dir); - } - - /* Now simplify any occurrences of `.' and `..' in the pathname. */ - - change = 1; - while (change) - { - char *p; - change = 0; - - for (p = current_directory; *p;) - { - if (!strncmp (p, "/./", 2) - && (p[2] == 0 || p[2] == '/')) - strcpy (p, p + 2); - else if (!strncmp (p, "/..", 3) - && (p[3] == 0 || p[3] == '/') - && p != current_directory) - { - char *q = p; - while (q != current_directory && q[-1] != '/') q--; - if (q != current_directory) - { - strcpy (q-1, p+3); - p = q-1; - } - } - else p++; - } - } - - if (chdir (dir) < 0) - perror_with_name (dir); - - forget_cached_source_info (); - - if (from_tty) - pwd_command ((char *) 0, 1); -} - -/* ARGSUSED */ -static void -source_command (args, from_tty) - char *args; - int from_tty; -{ - FILE *stream; - struct cleanup *cleanups; - char *file = args; - - if (file == 0) - /* Let source without arguments read .gdbinit. */ - file = gdbinit; - - file = tilde_expand (file); - make_cleanup (free, file); - - stream = fopen (file, "r"); - if (stream == 0) - perror_with_name (file); - - cleanups = make_cleanup (fclose, stream); - - read_command_file (stream); - - do_cleanups (cleanups); -} - -/* ARGSUSED */ -static void -echo_command (text, from_tty) - char *text; - int from_tty; -{ - char *p = text; - register int c; - - if (text) - while (c = *p++) - { - if (c == '\\') - { - /* \ at end of argument is used after spaces - so they won't be lost. */ - if (*p == 0) - return; - - c = parse_escape (&p); - if (c >= 0) - printf_filtered ("%c", c); - } - else - printf_filtered ("%c", c); - } - - /* Force this output to appear now. */ - wrap_here (""); - fflush (stdout); -} - -/* ARGSUSED */ -static void -dump_me_command (args, from_tty) - char *args; - int from_tty; -{ - if (query ("Should GDB dump core? ")) - { - signal (SIGQUIT, SIG_DFL); - kill (getpid (), SIGQUIT); - } -} - -/* Functions to manipulate command line editing control variables. */ - -/* Number of commands to print in each call to show_commands. */ -#define Hist_print 10 -static void -show_commands (args, from_tty) - char *args; - int from_tty; -{ - /* Index for history commands. Relative to history_base. */ - int offset; - - /* Number of the history entry which we are planning to display next. - Relative to history_base. */ - static int num = 0; - - /* The first command in the history which doesn't exist (i.e. one more - than the number of the last command). Relative to history_base. */ - int hist_len; - - struct _hist_entry *history_get(); - extern int history_base; - -#if 0 - /* This is all reported by individual "show" commands. */ - printf_filtered ("Interactive command editing is %s.\n", - command_editing_p ? "on" : "off"); - - printf_filtered ("History expansion of command input is %s.\n", - history_expansion_p ? "on" : "off"); - printf_filtered ("Writing of a history record upon exit is %s.\n", - write_history_p ? "enabled" : "disabled"); - printf_filtered ("The size of the history list (number of stored commands) is %d.\n", - history_size); - printf_filtered ("The name of the history record is \"%s\".\n\n", - history_filename ? history_filename : ""); -#endif /* 0 */ - - /* Print out some of the commands from the command history. */ - /* First determine the length of the history list. */ - hist_len = history_size; - for (offset = 0; offset < history_size; offset++) - { - if (!history_get (history_base + offset)) - { - hist_len = offset; - break; - } - } - - if (args) - { - if (args[0] == '+' && args[1] == '\0') - /* "info editing +" should print from the stored position. */ - ; - else - /* "info editing " should print around command number . */ - num = (parse_and_eval_address (args) - history_base) - Hist_print / 2; - } - /* "info editing" means print the last Hist_print commands. */ - else - { - num = hist_len - Hist_print; - } - - if (num < 0) - num = 0; - - /* If there are at least Hist_print commands, we want to display the last - Hist_print rather than, say, the last 6. */ - if (hist_len - num < Hist_print) - { - num = hist_len - Hist_print; - if (num < 0) - num = 0; - } - -#if 0 - /* No need for a header now that "info editing" only prints one thing. */ - if (num == hist_len - Hist_print) - printf_filtered ("The list of the last %d commands is:\n\n", Hist_print); - else - printf_filtered ("Some of the stored commands are:\n\n"); -#endif /* 0 */ - - for (offset = num; offset < num + Hist_print && offset < hist_len; offset++) - { - printf_filtered ("%5d %s\n", history_base + offset, - (history_get (history_base + offset))->line); - } - - /* The next command we want to display is the next one that we haven't - displayed yet. */ - num += Hist_print; - - /* If the user repeats this command with return, it should do what - "info editing +" does. This is unnecessary if arg is null, - because "info editing +" is not useful after "info editing". */ - if (from_tty && args) - { - args[0] = '+'; - args[1] = '\0'; - } -} - -/* Called by do_setshow_command. */ -/* ARGSUSED */ -static void -set_history_size_command (args, from_tty, c) - char *args; - int from_tty; - struct cmd_list_element *c; -{ - if (history_size == UINT_MAX) - unstifle_history (); - else - stifle_history (history_size); -} - -/* ARGSUSED */ -static void -set_history (args, from_tty) - char *args; - int from_tty; -{ - printf ("\"set history\" must be followed by the name of a history subcommand.\n"); - help_list (sethistlist, "set history ", -1, stdout); -} - -/* ARGSUSED */ -static void -show_history (args, from_tty) - char *args; - int from_tty; -{ - cmd_show_list (showhistlist, from_tty, ""); -} - -int info_verbose = 0; /* Default verbose msgs off */ - -/* Called by do_setshow_command. An elaborate joke. */ -/* ARGSUSED */ -static void -set_verbose (args, from_tty, c) - char *args; - int from_tty; - struct cmd_list_element *c; -{ - char *cmdname = "verbose"; - struct cmd_list_element *showcmd; - - showcmd = lookup_cmd_1 (&cmdname, showlist, NULL, 1); - - if (info_verbose) - { - c->doc = "Set verbose printing of informational messages."; - showcmd->doc = "Show verbose printing of informational messages."; - } - else - { - c->doc = "Set verbosity."; - showcmd->doc = "Show verbosity."; - } -} - -static void -float_handler () -{ - /* This message is based on ANSI C, section 4.7. Note that integer - divide by zero causes this, so "float" is a misnomer. */ - error ("Erroneous arithmetic operation."); -} - -/* Return whether we are running a batch file or from terminal. */ -int -batch_mode () -{ - return !(instream == stdin && ISATTY (stdin)); -} - - -static void -initialize_cmd_lists () -{ - cmdlist = (struct cmd_list_element *) 0; - infolist = (struct cmd_list_element *) 0; - enablelist = (struct cmd_list_element *) 0; - disablelist = (struct cmd_list_element *) 0; - deletelist = (struct cmd_list_element *) 0; - enablebreaklist = (struct cmd_list_element *) 0; - setlist = (struct cmd_list_element *) 0; - showlist = NULL; - sethistlist = (struct cmd_list_element *) 0; - showhistlist = NULL; - unsethistlist = (struct cmd_list_element *) 0; -} - -/* Init the history buffer. Note that we are called after the init file(s) - * have been read so that the user can change the history file via his - * .gdbinit file (for instance). The GDBHISTFILE environment variable - * overrides all of this. - */ - -static void -initialize_history() -{ - char *tmpenv; - - if (tmpenv = getenv ("HISTSIZE")) - history_size = atoi (tmpenv); - else if (!history_size) - history_size = 256; - - stifle_history (history_size); - - if (tmpenv = getenv ("GDBHISTFILE")) - history_filename = savestring (tmpenv, strlen(tmpenv)); - else if (!history_filename) { - /* We include the current directory so that if the user changes - directories the file written will be the same as the one - that was read. */ - history_filename = concat (current_directory, "/.gdb_history", ""); - } - read_history (history_filename); -} - -static void -initialize_main () -{ - struct cmd_list_element *c; - -#ifdef DEFAULT_PROMPT - prompt = savestring (DEFAULT_PROMPT, strlen(DEFAULT_PROMPT)); -#else - prompt = savestring ("(gdb) ", 6); -#endif - - /* Set the important stuff up for command editing. */ - command_editing_p = 1; - history_expansion_p = 0; - write_history_p = 0; - - /* Setup important stuff for command line editing. */ - rl_completion_entry_function = (int (*)()) symbol_completion_function; - rl_completer_word_break_characters = gdb_completer_word_break_characters; - rl_readline_name = "gdb"; - - /* Define the classes of commands. - They will appear in the help list in the reverse of this order. */ - - add_cmd ("obscure", class_obscure, NO_FUNCTION, "Obscure features.", &cmdlist); - add_cmd ("aliases", class_alias, NO_FUNCTION, "Aliases of other commands.", &cmdlist); - add_cmd ("user-defined", class_user, NO_FUNCTION, "User-defined commands.\n\ -The commands in this class are those defined by the user.\n\ -Use the \"define\" command to define a command.", &cmdlist); - add_cmd ("support", class_support, NO_FUNCTION, "Support facilities.", &cmdlist); - add_cmd ("status", class_info, NO_FUNCTION, "Status inquiries.", &cmdlist); - add_cmd ("files", class_files, NO_FUNCTION, "Specifying and examining files.", &cmdlist); - add_cmd ("breakpoints", class_breakpoint, NO_FUNCTION, "Making program stop at certain points.", &cmdlist); - add_cmd ("data", class_vars, NO_FUNCTION, "Examining data.", &cmdlist); - add_cmd ("stack", class_stack, NO_FUNCTION, "Examining the stack.\n\ -The stack is made up of stack frames. Gdb assigns numbers to stack frames\n\ -counting from zero for the innermost (currently executing) frame.\n\n\ -At any time gdb identifies one frame as the \"selected\" frame.\n\ -Variable lookups are done with respect to the selected frame.\n\ -When the program being debugged stops, gdb selects the innermost frame.\n\ -The commands below can be used to select other frames by number or address.", - &cmdlist); - add_cmd ("running", class_run, NO_FUNCTION, "Running the program.", &cmdlist); - - add_com ("pwd", class_files, pwd_command, - "Print working directory. This is used for your program as well."); - add_com ("cd", class_files, cd_command, - "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."); - - add_show_from_set - (add_set_cmd ("prompt", class_support, var_string, (char *)&prompt, - "Set gdb's prompt", - &setlist), - &showlist); - - add_com ("echo", class_support, echo_command, - "Print a constant string. Give string as argument.\n\ -C escape sequences may be used in the argument.\n\ -No newline is added at the end of the argument;\n\ -use \"\\n\" if you want a newline to be printed.\n\ -Since leading and trailing whitespace are ignored in command arguments,\n\ -if you want to print some you must use \"\\\" before leading whitespace\n\ -to be printed or after trailing whitespace."); - add_com ("document", class_support, document_command, - "Document a user-defined command.\n\ -Give command name as argument. Give documentation on following lines.\n\ -End with a line of just \"end\"."); - add_com ("define", class_support, define_command, - "Define a new command name. Command name is argument.\n\ -Definition appears on following lines, one command per line.\n\ -End with a line of just \"end\".\n\ -Use the \"document\" command to give documentation for the new command.\n\ -Commands defined in this way do not take arguments."); - -#ifdef __STDC__ - add_com ("source", class_support, source_command, - "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."); -#else - /* Punt file name, we can't help it easily. */ - add_com ("source", class_support, source_command, - "Read commands from a file named FILE.\n\ -Note that the file \".gdbinit\" is read automatically in this way\n\ -when gdb is started."); -#endif - - add_com ("quit", class_support, quit_command, "Exit gdb."); - add_com ("help", class_support, help_command, "Print list of commands."); - add_com_alias ("q", "quit", class_support, 1); - add_com_alias ("h", "help", class_support, 1); - - - c = add_set_cmd ("verbose", class_support, var_boolean, (char *)&info_verbose, - "Set ", - &setlist), - add_show_from_set (c, &showlist); - c->function = set_verbose; - set_verbose (NULL, 0, c); - - add_com ("dump-me", class_obscure, dump_me_command, - "Get fatal error; make debugger dump its core."); - - add_show_from_set - (add_set_cmd ("editing", class_support, var_boolean, (char *)&command_editing_p, - "Set command line editing.\n\ -Use \"on\" to enable to enable the editing, and \"off\" to disable it.\n\ -Without an argument, command line editing is enabled.", &setlist), - &showlist); - - add_prefix_cmd ("history", class_support, set_history, - "Generic command for setting command history parameters.", - &sethistlist, "set history ", 0, &setlist); - add_prefix_cmd ("history", class_support, show_history, - "Generic command for showing command history parameters.", - &showhistlist, "show history ", 0, &showlist); - - add_show_from_set - (add_set_cmd ("expansion", no_class, var_boolean, (char *)&history_expansion_p, - "Set history expansion on command input.\n\ -Without an argument, history expansion is enabled.", &sethistlist), - &showhistlist); - - add_show_from_set - (add_set_cmd ("save", no_class, var_boolean, (char *)&write_history_p, - "Set saving of the history record on exit.\n\ -Use \"on\" to enable to enable the saving, and \"off\" to disable it.\n\ -Without an argument, saving is enabled.", &sethistlist), - &showhistlist); - - c = add_set_cmd ("size", no_class, var_uinteger, (char *)&history_size, - "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); - c->function = set_history_size_command; - - add_show_from_set - (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), - &showhistlist); - - add_show_from_set - (add_set_cmd ("confirm", class_support, var_boolean, - (char *)&caution, - "Set whether to confirm potentially dangerous operations.", - &setlist), - &showlist); - - add_prefix_cmd ("info", class_info, info_command, - "Generic command for printing status.", - &infolist, "info ", 0, &cmdlist); - add_com_alias ("i", "info", class_info, 1); - - add_prefix_cmd ("show", class_info, show_command, - "Generic command for showing things set with \"set\".", - &showlist, "show ", 0, &cmdlist); - /* Another way to get at the same thing. */ - add_info ("set", show_command, "Show all GDB settings."); - - add_cmd ("commands", no_class, show_commands, "Status of command editor.", - &showlist); - - add_cmd ("version", no_class, show_version, - "Report what version of GDB this is.", &showlist); -} diff --git a/gdb/mcheck.c b/gdb/mcheck.c deleted file mode 100755 index 497bab2c01c..00000000000 --- a/gdb/mcheck.c +++ /dev/null @@ -1,124 +0,0 @@ -/* Standard debugging hooks for `malloc'. - Copyright 1990 Free Software Foundation - Written May 1989 by Mike Haertel. - - The author may be reached (Email) at the address mike@ai.mit.edu, - or (US mail) as Mike Haertel c/o Free Software Foundation. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include "ansidecl.h" -#define size_t unsigned int -#define ptrdiff_t int -#define NULL 0 -#define __ONEFILE -#include "gmalloc.h" - -/* Old hook values. */ -static void EXFUN((*old_free_hook), (PTR ptr)); -static PTR EXFUN((*old_malloc_hook), (size_t size)); -static PTR EXFUN((*old_realloc_hook), (PTR ptr, size_t size)); - - -/* Function to call when something awful happens. */ -extern void abort(); -static void EXFUN((*abortfunc), (void)) = (void (*)()) abort; - -/* Arbitrary magical numbers. */ -#define MAGICWORD 0xfedabeeb -#define MAGICBYTE ((char) 0xd7) - -struct hdr - { - size_t size; /* Exact size requested by user. */ - unsigned int magic; /* Magic number to check header integrity. */ - }; - -static void -DEFUN(checkhdr, (hdr), CONST struct hdr *hdr) -{ - if (hdr->magic != MAGICWORD || ((char *) &hdr[1])[hdr->size] != MAGICBYTE) - (*abortfunc)(); -} - -static void -DEFUN(freehook, (ptr), PTR ptr) -{ - struct hdr *hdr = ((struct hdr *) ptr) - 1; - checkhdr(hdr); - hdr->magic = 0; - __free_hook = old_free_hook; - free(hdr); - __free_hook = freehook; -} - -static PTR -DEFUN(mallochook, (size), size_t size) -{ - struct hdr *hdr; - - __malloc_hook = old_malloc_hook; - hdr = (struct hdr *) malloc(sizeof(struct hdr) + size + 1); - __malloc_hook = mallochook; - if (hdr == NULL) - return NULL; - - hdr->size = size; - hdr->magic = MAGICWORD; - ((char *) &hdr[1])[size] = MAGICBYTE; - return (PTR) (hdr + 1); -} - -static PTR -DEFUN(reallochook, (ptr, size), PTR ptr AND size_t size) -{ - struct hdr *hdr = ((struct hdr *) ptr) - 1; - - checkhdr(hdr); - __free_hook = old_free_hook; - __malloc_hook = old_malloc_hook; - __realloc_hook = old_realloc_hook; - hdr = (struct hdr *) realloc((PTR) hdr, sizeof(struct hdr) + size + 1); - __free_hook = freehook; - __malloc_hook = mallochook; - __realloc_hook = reallochook; - if (hdr == NULL) - return NULL; - - hdr->size = size; - ((char *) &hdr[1])[size] = MAGICBYTE; - return (PTR) (hdr + 1); -} - -void -DEFUN(mcheck, (func), void EXFUN((*func), (void))) -{ - static int mcheck_used = 0; - - if (func) - abortfunc = func; - - /* These hooks may not be safely inserted if malloc is already in use. */ - if (!__malloc_initialized && !mcheck_used) - { - old_free_hook = __free_hook; - __free_hook = freehook; - old_malloc_hook = __malloc_hook; - __malloc_hook = mallochook; - old_realloc_hook = __realloc_hook; - __realloc_hook = reallochook; - mcheck_used = 1; - } -} diff --git a/gdb/mem-break.c b/gdb/mem-break.c deleted file mode 100644 index eebe7e251f1..00000000000 --- a/gdb/mem-break.c +++ /dev/null @@ -1,178 +0,0 @@ -/* Simulate breakpoints by patching locations in the target system. - Copyright (C) 1990 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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 1, or (at your option) -any later version. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include "defs.h" -#include "param.h" - -#ifdef BREAKPOINT -/* This file is only useful if BREAKPOINT is set. If not, we punt. */ - -#include -#include "breakpoint.h" -#include "inferior.h" -#include "target.h" - -/* This is the sequence of bytes we insert for a breakpoint. On some - machines, breakpoints are handled by the target environment and we - don't have to worry about them here. */ - -static char break_insn[] = BREAKPOINT; - -/* This is only to check that BREAKPOINT fits in BREAKPOINT_MAX bytes. */ - -static char check_break_insn_size[BREAKPOINT_MAX] = BREAKPOINT; - -/* Insert a breakpoint on machines that don't have any better breakpoint - support. We read the contents of the target location and stash it, - then overwrite it with a breakpoint instruction. ADDR is the target - location in the target machine. CONTENTS_CACHE is a pointer to - memory allocated for saving the target contents. It is guaranteed - by the caller to be long enough to save sizeof BREAKPOINT bytes. - FIXME: This size is target_arch dependent and should be available in - the target_arch transfer vector, if we ever have one... */ - -int -memory_insert_breakpoint (addr, contents_cache) - CORE_ADDR addr; - char *contents_cache; -{ - int val; - - val = target_read_memory (addr, contents_cache, sizeof break_insn); - - if (val == 0) - val = target_write_memory (addr, break_insn, sizeof break_insn); - - return val; -} - - -int -memory_remove_breakpoint (addr, contents_cache) - CORE_ADDR addr; - char *contents_cache; -{ - return target_write_memory (addr, contents_cache, sizeof break_insn); -} - - -#if 0 -/* This should move back into breakpoint.c, sad to say. Encapsulate - sizeof (BREAKPOINT) by export it as an int from mem-break.c. */ - -/* Like target_read_memory() but if breakpoints are inserted, return - the shadow contents instead of the breakpoints themselves. */ -int -read_memory_nobpt (memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - unsigned len; -{ - int status; - struct breakpoint *b; - ALL_BREAKPOINTS (b) - { - if (b->address == NULL || !b->inserted) - continue; - else if (b->address + sizeof (break_insn) <= memaddr) - /* The breakpoint is entirely before the chunk of memory - we are reading. */ - continue; - else if (b->address >= memaddr + len) - /* The breakpoint is entirely after the chunk of memory we - are reading. */ - continue; - else - { - /* Copy the breakpoint from the shadow contents, and recurse - for the things before and after. */ - - /* Addresses and length of the part of the breakpoint that - we need to copy. */ - CORE_ADDR membpt = b->address; - unsigned int bptlen = sizeof (break_insn); - /* Offset within shadow_contents. */ - int bptoffset = 0; - - if (membpt < memaddr) - { - /* Only copy the second part of the breakpoint. */ - bptlen -= memaddr - membpt; - bptoffset = memaddr - membpt; - membpt = memaddr; - } - - if (membpt + bptlen > memaddr + len) - { - /* Only copy the first part of the breakpoint. */ - bptlen -= (membpt + bptlen) - (memaddr + len); - } - - bcopy (b->shadow_contents + bptoffset, - myaddr + membpt - memaddr, bptlen); - - if (membpt > memaddr) - { - /* Copy the section of memory before the breakpoint. */ - status = read_memory_nobpt (memaddr, myaddr, membpt - memaddr); - if (status != 0) - return status; - } - - if (membpt + bptlen < memaddr + len) - { - /* Copy the section of memory after the breakpoint. */ - status = read_memory_nobpt - (membpt + bptlen, - myaddr + membpt + bptlen - memaddr, - memaddr + len - (membpt + bptlen)); - if (status != 0) - return status; - } - return 0; - } - } - /* Nothing overlaps. Just call read_memory_noerr. */ - return target_read_memory (memaddr, myaddr, len); -} -#endif /* 0 */ - -#else /* BREAKPOINT */ - -char nogo[] = "Breakpoints not implemented for this target."; - -int -memory_insert_breakpoint (addr, contents_cache) - CORE_ADDR addr; - char *contents_cache; -{ - error (nogo); - return 0; /* lint */ -} - -int -memory_remove_breakpoint (addr, contents_cache) - CORE_ADDR addr; - char *contents_cache; -{ - error (nogo); - return 0; /* lint */ -} - -#endif /* BREAKPOINT */ diff --git a/gdb/minimon.h b/gdb/minimon.h deleted file mode 100644 index 7084f4f5eeb..00000000000 --- a/gdb/minimon.h +++ /dev/null @@ -1,562 +0,0 @@ -/* Definitions and macros for support of AMD's remote debugger, MiniMON. - Copyright (C) 1990, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - * Some basic types. FIXME, this should be done by declaring bitfield - * sizes in the structs. We can't portably depend on a "long int" being - * 32 bits, etc. - */ -typedef long int INT32; /* 32 bit integer */ -typedef unsigned long int UINT32; /* 32 bit integer (unsigned) */ -typedef unsigned long int ADDR32; /* 32 bit address */ -typedef unsigned long int INST32; /* 32 bit instruction */ -typedef long int BOOLEAN; /* Boolean value (32 bit) */ -typedef unsigned char BYTE; /* byte (8 bit) */ -typedef short int INT16; /* 16 bit integer */ -typedef unsigned short int UINT16; /* 16 bit integer (unsigned) */ - -/****************************************************************************/ -/************************* Message Information ******************************/ -/****************************************************************************/ - -/* - * Error codes - */ - -/* General errors */ -#define EMUSAGE 1 /* Bad args / flags */ -#define EMFAIL 2 /* Unrecoverable error */ -#define EMBADADDR 3 /* Illegal address */ -#define EMBADREG 4 /* Illegal register */ -#define EMSYNTAX 5 /* Illegal command syntax */ -#define EMACCESS 6 /* Could not access memory */ -#define EMALLOC 7 /* Could not allocate memory */ -#define EMTARGET 8 /* Unknown target type */ -#define EMHINIT 9 /* Could not initialize host */ -#define EMCOMM 10 /* Could not open communication channel */ - -/* Message errors */ -#define EMBADMSG 11 /* Unknown message type */ -#define EMMSG2BIG 12 /* Message to large for buffer */ -#define EMNOSEND 13 /* Could not send message */ -#define EMNORECV 14 /* Could not receive message */ - -#define EMRESET 15 /* Could not RESET target */ -#define EMCONFIG 16 /* Could not get target CONFIG */ -#define EMSTATUS 17 /* Could not get target STATUS */ -#define EMREAD 18 /* Could not READ target memory */ -#define EMWRITE 19 /* Could not WRITE target memory */ -#define EMBKPTSET 20 /* Could not set breakpoint */ -#define EMBKPTRM 21 /* Could not remove breakpoint */ -#define EMBKPTSTAT 22 /* Could not get breakpoint status */ -#define EMBKPTNONE 23 /* All breakpoints in use */ -#define EMBKPTUSED 24 /* Breakpoints already in use */ -#define EMCOPY 25 /* Could not COPY target memory */ -#define EMFILL 26 /* Could not FILL target memory */ -#define EMINIT 27 /* Could not initialize target memory */ -#define EMGO 28 /* Could not start execution */ -#define EMSTEP 29 /* Could not single step */ -#define EMBREAK 30 /* Could not BREAK */ -#define EMHIF 31 /* Could not perform HIF service */ -#define EMCHANNEL0 32 /* Could not read CHANNEL0 */ -#define EMCHANNEL1 33 /* Could not write CHANNEL1 */ - -/* COFF file loader errors */ -#define EMOPEN 34 /* Could not open COFF file */ -#define EMHDR 35 /* Could not read COFF header */ -#define EMMAGIC 36 /* Bad magic number */ -#define EMAOUT 37 /* Could not read COFF a.out header */ -#define EMSCNHDR 38 /* Could not read COFF section header */ -#define EMSCN 39 /* Could not read COFF section */ -#define EMCLOSE 40 /* Could not close COFF file */ - -/* Log file errors */ -#define EMLOGOPEN 41 /* Could not open log file */ -#define EMLOGREAD 42 /* Could not read log file */ -#define EMLOGWRITE 43 /* Could not write to log file */ -#define EMLOGCLOSE 44 /* Could not close log file */ - -/* Command file errors */ -#define EMCMDOPEN 45 /* Could not open command file */ -#define EMCMDREAD 46 /* Could not read command file */ -#define EMCMDWRITE 47 /* Could not write to command file */ -#define EMCMDCLOSE 48 /* Could not close comand file */ - -#define EMTIMEOUT 49 /* Host timed out waiting for a message */ -#define EMCOMMTYPE 50 /* A '-t' flag must be specified */ -#define EMCOMMERR 51 /* Communication error */ -#define EMBAUD 52 /* Invalid baud rate specified */ -/* - * Memory Spaces - */ -#define LOCAL_REG 0 /* Local processor register */ -#define GLOBAL_REG 1 /* Global processor register */ -#define SPECIAL_REG 2 /* Special processor register */ -#define TLB_REG 3 /* Translation Lookaside Buffer */ -#define COPROC_REG 4 /* Coprocessor register */ -#define I_MEM 5 /* Instruction Memory */ -#define D_MEM 6 /* Data Memory */ -#define I_ROM 7 /* Instruction ROM */ -#define D_ROM 8 /* Data ROM */ -#define I_O 9 /* Input/Output */ -#define I_CACHE 10 /* Instruction Cache */ -#define D_CACHE 11 /* Data Cache */ - -/* To supress warnings for zero length array definitions */ -#define DUMMY 1 - -/* -** Host to target definitions -*/ - -#define RESET 0 -#define CONFIG_REQ 1 -#define STATUS_REQ 2 -#define READ_REQ 3 -#define WRITE_REQ 4 -#define BKPT_SET 5 -#define BKPT_RM 6 -#define BKPT_STAT 7 -#define COPY 8 -#define FILL 9 -#define INIT 10 -#define GO 11 -#define STEP 12 -#define BREAK 13 - -#define HIF_CALL_RTN 64 -#define CHANNEL0 65 -#define CHANNEL1_ACK 66 - - -/* -** Target to host definitions -*/ - -#define RESET_ACK 32 -#define CONFIG 33 -#define STATUS 34 -#define READ_ACK 35 -#define WRITE_ACK 36 -#define BKPT_SET_ACK 37 -#define BKPT_RM_ACK 38 -#define BKPT_STAT_ACK 39 -#define COPY_ACK 40 -#define FILL_ACK 41 -#define INIT_ACK 42 -#define HALT 43 - -#define ERROR 63 - -#define HIF_CALL 96 -#define CHANNEL0_ACK 97 -#define CHANNEL1 98 - - -/* A "generic" message */ -struct generic_msg_t { - INT32 code; /* generic */ - INT32 length; - BYTE byte[DUMMY]; -}; - - -/* A "generic" message (with an INT32 array) */ -struct generic_int32_msg_t { - INT32 code; /* generic */ - INT32 length; - INT32 int32[DUMMY]; -}; - - -/* -** Host to target messages -*/ - -struct reset_msg_t { - INT32 code; /* 0 */ - INT32 length; -}; - - -struct config_req_msg_t { - INT32 code; /* 1 */ - INT32 length; -}; - - -struct status_req_msg_t { - INT32 code; /* 2 */ - INT32 length; -}; - - -struct read_req_msg_t { - INT32 code; /* 3 */ - INT32 length; - INT32 memory_space; - ADDR32 address; - INT32 byte_count; -}; - - -struct write_req_msg_t { - INT32 code; /* 4 */ - INT32 length; - INT32 memory_space; - ADDR32 address; - INT32 byte_count; - BYTE data[DUMMY]; -}; - - -struct write_r_msg_t { - INT32 code; /* 4 */ - INT32 length; - INT32 memory_space; - ADDR32 address; - INT32 byte_count; - INT32 data[DUMMY]; -}; - - -struct bkpt_set_msg_t { - INT32 code; /* 5 */ - INT32 length; - INT32 memory_space; - ADDR32 bkpt_addr; - INT32 pass_count; - INT32 bkpt_type; -}; - - -struct bkpt_rm_msg_t { - INT32 code; /* 6 */ - INT32 length; - INT32 memory_space; - ADDR32 bkpt_addr; -}; - - -struct bkpt_stat_msg_t { - INT32 code; /* 7 */ - INT32 length; - INT32 memory_space; - ADDR32 bkpt_addr; -}; - - -struct copy_msg_t { - INT32 code; /* 8 */ - INT32 length; - INT32 source_space; - ADDR32 source_addr; - INT32 dest_space; - ADDR32 dest_addr; - INT32 byte_count; -}; - - -struct fill_msg_t { - INT32 code; /* 9 */ - INT32 length; - INT32 memory_space; - ADDR32 start_addr; - INT32 fill_count; - INT32 byte_count; - BYTE fill_data[DUMMY]; -}; - - -struct init_msg_t { - INT32 code; /* 10 */ - INT32 length; - ADDR32 text_start; - ADDR32 text_end; - ADDR32 data_start; - ADDR32 data_end; - ADDR32 entry_point; - INT32 mem_stack_size; - INT32 reg_stack_size; - ADDR32 arg_start; - INT32 os_control; -}; - - -struct go_msg_t { - INT32 code; /* 11 */ - INT32 length; -}; - - -struct step_msg_t { - INT32 code; /* 12 */ - INT32 length; - INT32 count; -}; - - -struct break_msg_t { - INT32 code; /* 13 */ - INT32 length; -}; - - -struct hif_call_rtn_msg_t { - INT32 code; /* 64 */ - INT32 length; - INT32 service_number; - INT32 gr121; - INT32 gr96; - INT32 gr97; -}; - - -struct channel0_msg_t { - INT32 code; /* 65 */ - INT32 length; - BYTE data; -}; - - -struct channel1_ack_msg_t { - INT32 code; /* 66 */ - INT32 length; -}; - - -/* -** Target to host messages -*/ - - -struct reset_ack_msg_t { - INT32 code; /* 32 */ - INT32 length; -}; - - -struct config_msg_t { - INT32 code; /* 33 */ - INT32 length; - INT32 processor_id; - INT32 version; - ADDR32 I_mem_start; - INT32 I_mem_size; - ADDR32 D_mem_start; - INT32 D_mem_size; - ADDR32 ROM_start; - INT32 ROM_size; - INT32 max_msg_size; - INT32 max_bkpts; - INT32 coprocessor; - INT32 reserved; -}; - - -struct status_msg_t { - INT32 code; /* 34 */ - INT32 length; - INT32 msgs_sent; - INT32 msgs_received; - INT32 errors; - INT32 bkpts_hit; - INT32 bkpts_free; - INT32 traps; - INT32 fills; - INT32 spills; - INT32 cycles; - INT32 reserved; -}; - - -struct read_ack_msg_t { - INT32 code; /* 35 */ - INT32 length; - INT32 memory_space; - ADDR32 address; - INT32 byte_count; - BYTE data[DUMMY]; -}; - -struct read_r_ack_msg_t { - INT32 code; /* 35 */ - INT32 length; - INT32 memory_space; - ADDR32 address; - INT32 byte_count; - INT32 data[DUMMY]; -}; - - -struct write_ack_msg_t { - INT32 code; /* 36 */ - INT32 length; - INT32 memory_space; - ADDR32 address; - INT32 byte_count; -}; - - -struct bkpt_set_ack_msg_t { - INT32 code; /* 37 */ - INT32 length; - INT32 memory_space; - ADDR32 address; - INT32 pass_count; - INT32 bkpt_type; -}; - - -struct bkpt_rm_ack_msg_t { - INT32 code; /* 38 */ - INT32 length; - INT32 memory_space; - ADDR32 address; -}; - - -struct bkpt_stat_ack_msg_t { - INT32 code; /* 39 */ - INT32 length; - INT32 memory_space; - ADDR32 address; - INT32 pass_count; - INT32 bkpt_type; -}; - - -struct copy_ack_msg_t { - INT32 code; /* 40 */ - INT32 length; - INT32 source_space; - ADDR32 source_addr; - INT32 dest_space; - ADDR32 dest_addr; - INT32 byte_count; -}; - - -struct fill_ack_msg_t { - INT32 code; /* 41 */ - INT32 length; - INT32 memory_space; - ADDR32 start_addr; - INT32 fill_count; - INT32 byte_count; -}; - - -struct init_ack_msg_t { - INT32 code; /* 42 */ - INT32 length; -}; - - -struct halt_msg_t { - INT32 code; /* 43 */ - INT32 length; - INT32 memory_space; - ADDR32 pc0; - ADDR32 pc1; - INT32 trap_number; -}; - - -struct error_msg_t { - INT32 code; /* 63 */ - INT32 length; - INT32 error_code; - INT32 memory_space; - ADDR32 address; -}; - - -struct hif_call_msg_t { - INT32 code; /* 96 */ - INT32 length; - INT32 service_number; - INT32 lr2; - INT32 lr3; - INT32 lr4; -}; - - -struct channel0_ack_msg_t { - INT32 code; /* 97 */ - INT32 length; -}; - - -struct channel1_msg_t { - INT32 code; /* 98 */ - INT32 length; - BYTE data[DUMMY]; -}; - - - -/* -** Union all of the message types together -*/ - -union msg_t { - struct generic_msg_t generic_msg; - struct generic_int32_msg_t generic_int32_msg; - - struct reset_msg_t reset_msg; - struct config_req_msg_t config_req_msg; - struct status_req_msg_t status_req_msg; - struct read_req_msg_t read_req_msg; - struct write_req_msg_t write_req_msg; - struct write_r_msg_t write_r_msg; - struct bkpt_set_msg_t bkpt_set_msg; - struct bkpt_rm_msg_t bkpt_rm_msg; - struct bkpt_stat_msg_t bkpt_stat_msg; - struct copy_msg_t copy_msg; - struct fill_msg_t fill_msg; - struct init_msg_t init_msg; - struct go_msg_t go_msg; - struct step_msg_t step_msg; - struct break_msg_t break_msg; - - struct hif_call_rtn_msg_t hif_call_rtn_msg; - struct channel0_msg_t channel0_msg; - struct channel1_ack_msg_t channel1_ack_msg; - - struct reset_ack_msg_t reset_ack_msg; - struct config_msg_t config_msg; - struct status_msg_t status_msg; - struct read_ack_msg_t read_ack_msg; - struct read_r_ack_msg_t read_r_ack_msg; - struct write_ack_msg_t write_ack_msg; - struct bkpt_set_ack_msg_t bkpt_set_ack_msg; - struct bkpt_rm_ack_msg_t bkpt_rm_ack_msg; - struct bkpt_stat_ack_msg_t bkpt_stat_ack_msg; - struct copy_ack_msg_t copy_ack_msg; - struct fill_ack_msg_t fill_ack_msg; - struct init_ack_msg_t init_ack_msg; - struct halt_msg_t halt_msg; - - struct error_msg_t error_msg; - - struct hif_call_msg_t hif_call_msg; - struct channel0_ack_msg_t channel0_ack_msg; - struct channel1_msg_t channel1_msg; -}; diff --git a/gdb/mips-opcode.h b/gdb/mips-opcode.h deleted file mode 100755 index f75d34e4a21..00000000000 --- a/gdb/mips-opcode.h +++ /dev/null @@ -1,363 +0,0 @@ -/* Mips opcde list for GDB, the GNU debugger. - Copyright (C) 1989 Free Software Foundation, Inc. - Contributed by Nobuyuki Hikichi(hikichi@sra.junet) - Made to work for little-endian machines, and debugged - by Per Bothner (bothner@cs.wisc.edu). - Many fixes contributed by Frank Yellin (fy@lucid.com). - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#if BITS_BIG_ENDIAN -#define BIT_FIELDS_2(a,b) a;b; -#define BIT_FIELDS_4(a,b,c,d) a;b;c;d; -#define BIT_FIELDS_6(a,b,c,d,e,f) a;b;c;d;e;f; -#else -#define BIT_FIELDS_2(a,b) b;a; -#define BIT_FIELDS_4(a,b,c,d) d;c;b;a; -#define BIT_FIELDS_6(a,b,c,d,e,f) f;e;d;c;b;a; -#endif - -struct op_i_fmt -{ -BIT_FIELDS_4( - unsigned op : 6, - unsigned rs : 5, - unsigned rt : 5, - unsigned immediate : 16) -}; - -struct op_j_fmt -{ -BIT_FIELDS_2( - unsigned op : 6, - unsigned target : 26) -}; - -struct op_r_fmt -{ -BIT_FIELDS_6( - unsigned op : 6, - unsigned rs : 5, - unsigned rt : 5, - unsigned rd : 5, - unsigned shamt : 5, - unsigned funct : 6) -}; - - -struct fop_i_fmt -{ -BIT_FIELDS_4( - unsigned op : 6, - unsigned rs : 5, - unsigned rt : 5, - unsigned immediate : 16) -}; - -struct op_b_fmt -{ -BIT_FIELDS_4( - unsigned op : 6, - unsigned rs : 5, - unsigned rt : 5, - short delta : 16) -}; - -struct fop_r_fmt -{ -BIT_FIELDS_6( - unsigned op : 6, - unsigned fmt : 5, - unsigned ft : 5, - unsigned fs : 5, - unsigned fd : 5, - unsigned funct : 6) -}; - -struct mips_opcode -{ - char *name; - unsigned long opcode; - unsigned long match; - char *args; - int bdelay; /* Nonzero if delayed branch. */ -}; - -/* args format; - - "s" rs: source register specifier - "t" rt: target register - "i" immediate - "a" target address - "c" branch condition - "d" rd: destination register specifier - "h" shamt: shift amount - "f" funct: function field - - for fpu - "S" fs source 1 register - "T" ft source 2 register - "D" distination register -*/ - -#define one(x) (x << 26) -#define op_func(x, y) ((x << 26) | y) -#define op_cond(x, y) ((x << 26) | (y << 16)) -#define op_rs_func(x, y, z) ((x << 26) | (y << 21) | z) -#define op_rs_b11(x, y, z) ((x << 26) | (y << 21) | z) -#define op_o16(x, y) ((x << 26) | (y << 16)) -#define op_bc(x, y, z) ((x << 26) | (y << 21) | (z << 16)) - -struct mips_opcode mips_opcodes[] = -{ -/* These first opcodes are special cases of the ones in the comments */ - {"nop", 0, 0xffffffff, /*li*/ "", 0}, - {"li", op_bc(9,0,0), op_bc(0x3f,31,0), /*addiu*/ "t,j", 0}, - {"b", one(4), 0xffff0000, /*beq*/ "b", 1}, - {"move", op_func(0, 33), op_cond(0x3f,31)|0x7ff,/*addu*/ "d,s", 0}, - - {"sll", op_func(0, 0), op_func(0x3f, 0x3f), "d,t,h", 0}, - {"srl", op_func(0, 2), op_func(0x3f, 0x3f), "d,t,h", 0}, - {"sra", op_func(0, 3), op_func(0x3f, 0x3f), "d,t,h", 0}, - {"sllv", op_func(0, 4), op_func(0x3f, 0x7ff), "d,t,s", 0}, - {"srlv", op_func(0, 6), op_func(0x3f, 0x7ff), "d,t,s", 0}, - {"srav", op_func(0, 7), op_func(0x3f, 0x7ff), "d,t,s", 0}, - {"jr", op_func(0, 8), op_func(0x3f, 0x1fffff), "s", 1}, - {"jalr", op_func(0, 9), op_func(0x3f, 0x1f07ff), "d,s", 1}, - {"syscall", op_func(0, 12), op_func(0x3f, 0x3f), "", 0}, - {"break", op_func(0, 13), op_func(0x3f, 0x3f), "", 0}, - {"mfhi", op_func(0, 16), op_func(0x3f, 0x03ff07ff), "d", 0}, - {"mthi", op_func(0, 17), op_func(0x3f, 0x1fffff), "s", 0}, - {"mflo", op_func(0, 18), op_func(0x3f, 0x03ff07ff), "d", 0}, - {"mtlo", op_func(0, 19), op_func(0x3f, 0x1fffff), "s", 0}, - {"mult", op_func(0, 24), op_func(0x3f, 0xffff), "s,t", 0}, - {"multu", op_func(0, 25), op_func(0x3f, 0xffff), "s,t", 0}, - {"div", op_func(0, 26), op_func(0x3f, 0xffff), "s,t", 0}, - {"divu", op_func(0, 27), op_func(0x3f, 0xffff), "s,t", 0}, - {"add", op_func(0, 32), op_func(0x3f, 0x7ff), "d,s,t", 0}, - {"addu", op_func(0, 33), op_func(0x3f, 0x7ff), "d,s,t", 0}, - {"sub", op_func(0, 34), op_func(0x3f, 0x7ff), "d,s,t", 0}, - {"subu", op_func(0, 35), op_func(0x3f, 0x7ff), "d,s,t", 0}, - {"and", op_func(0, 36), op_func(0x3f, 0x7ff), "d,s,t", 0}, - {"or", op_func(0, 37), op_func(0x3f, 0x7ff), "d,s,t", 0}, - {"xor", op_func(0, 38), op_func(0x3f, 0x7ff), "d,s,t", 0}, - {"nor", op_func(0, 39), op_func(0x3f, 0x7ff), "d,s,t", 0}, - {"slt", op_func(0, 42), op_func(0x3f, 0x7ff), "d,s,t", 0}, - {"sltu", op_func(0, 43), op_func(0x3f, 0x7ff), "d,s,t", 0}, - - {"bltz", op_cond (1, 0), op_cond(0x3f, 0x1f), "s,b", 1}, - {"bgez", op_cond (1, 1), op_cond(0x3f, 0x1f), "s,b", 1}, - {"bltzal", op_cond (1, 16),op_cond(0x3f, 0x1f), "s,b", 1}, - {"bgezal", op_cond (1, 17),op_cond(0x3f, 0x1f), "s,b", 1}, - - - {"j", one(2), one(0x3f), "a", 1}, - {"jal", one(3), one(0x3f), "a", 1}, - {"beq", one(4), one(0x3f), "s,t,b", 1}, - {"bne", one(5), one(0x3f), "s,t,b", 1}, - {"blez", one(6), one(0x3f) | 0x1f0000, "s,b", 1}, - {"bgtz", one(7), one(0x3f) | 0x1f0000, "s,b", 1}, - {"addi", one(8), one(0x3f), "t,s,j", 0}, - {"addiu", one(9), one(0x3f), "t,s,j", 0}, - {"slti", one(10), one(0x3f), "t,s,j", 0}, - {"sltiu", one(11), one(0x3f), "t,s,j", 0}, - {"andi", one(12), one(0x3f), "t,s,i", 0}, - {"ori", one(13), one(0x3f), "t,s,i", 0}, - {"xori", one(14), one(0x3f), "t,s,i", 0}, - /* rs field is don't care field? */ - {"lui", one(15), one(0x3f), "t,i", 0}, - -/* co processor 0 instruction */ - {"mfc0", op_rs_b11 (16, 0, 0), op_rs_b11(0x3f, 0x1f, 0x1ffff), "t,d", 0}, - {"cfc0", op_rs_b11 (16, 2, 0), op_rs_b11(0x3f, 0x1f, 0x1ffff), "t,d", 0}, - {"mtc0", op_rs_b11 (16, 4, 0), op_rs_b11(0x3f, 0x1f, 0x1ffff), "t,d", 0}, - {"ctc0", op_rs_b11 (16, 6, 0), op_rs_b11(0x3f, 0x1f, 0x1ffff), "t,d", 0}, - - {"bc0f", op_o16(16, 0x100), op_o16(0x3f, 0x3ff), "b", 1}, - {"bc0f", op_o16(16, 0x180), op_o16(0x3f, 0x3ff), "b", 1}, - {"bc0t", op_o16(16, 0x101), op_o16(0x3f, 0x3ff), "b", 1}, - {"bc0t", op_o16(16, 0x181), op_o16(0x3f, 0x3ff), "b", 1}, - - {"tlbr", op_rs_func(16, 0x10, 1), ~0, "", 0}, - {"tlbwi", op_rs_func(16, 0x10, 2), ~0, "", 0}, - {"tlbwr", op_rs_func(16, 0x10, 6), ~0, "", 0}, - {"tlbp", op_rs_func(16, 0x10, 8), ~0, "", 0}, - {"rfe", op_rs_func(16, 0x10, 16), ~0, "", 0}, - - {"mfc1", op_rs_b11 (17, 0, 0), op_rs_b11(0x3f, 0x1f, 0),"t,S", 0}, - {"cfc1", op_rs_b11 (17, 2, 0), op_rs_b11(0x3f, 0x1f, 0),"t,S", 0}, - {"mtc1", op_rs_b11 (17, 4, 0), op_rs_b11(0x3f, 0x1f, 0),"t,S", 0}, - {"ctc1", op_rs_b11 (17, 6, 0), op_rs_b11(0x3f, 0x1f, 0),"t,S", 0}, - - {"bc1f", op_o16(17, 0x100), op_o16(0x3f, 0x3ff), "b", 1}, - {"bc1f", op_o16(17, 0x180), op_o16(0x3f, 0x3ff), "b", 1}, - {"bc1t", op_o16(17, 0x101), op_o16(0x3f, 0x3ff), "b", 1}, - {"bc1t", op_o16(17, 0x181), op_o16(0x3f, 0x3ff), "b", 1}, - -/* fpu instruction */ - {"add.s", op_rs_func(17, 0x10, 0), - op_rs_func(0x3f, 0x1f, 0x3f), "D,S,T", 0}, - {"add.d", op_rs_func(17, 0x11, 0), - op_rs_func(0x3f, 0x1f, 0x3f), "D,S,T", 0}, - {"sub.s", op_rs_func(17, 0x10, 1), - op_rs_func(0x3f, 0x1f, 0x3f), "D,S,T", 0}, - {"sub.d", op_rs_func(17, 0x11, 1), - op_rs_func(0x3f, 0x1f, 0x3f), "D,S,T", 0}, - {"mul.s", op_rs_func(17, 0x10, 2), - op_rs_func(0x3f, 0x1f, 0x3f), "D,S,T", 0}, - {"mul.d", op_rs_func(17, 0x11, 2), - op_rs_func(0x3f, 0x1f, 0x3f), "D,S,T", 0}, - {"div.s", op_rs_func(17, 0x10, 3), - op_rs_func(0x3f, 0x1f, 0x3f), "D,S,T", 0}, - {"div.d", op_rs_func(17, 0x11, 3), - op_rs_func(0x3f, 0x1f, 0x3f), "D,S,T", 0}, - {"abs.s", op_rs_func(17, 0x10, 5), - op_rs_func(0x3f, 0x1f, 0x1f003f), "D,S", 0}, - {"abs.d", op_rs_func(17, 0x11, 5), - op_rs_func(0x3f, 0x1f, 0x1f003f), "D,S", 0}, - {"mov.s", op_rs_func(17, 0x10, 6), - op_rs_func(0x3f, 0x1f, 0x1f003f), "D,S", 0}, - {"mov.d", op_rs_func(17, 0x11, 6), - op_rs_func(0x3f, 0x1f, 0x1f003f), "D,S", 0}, - {"neg.s", op_rs_func(17, 0x10, 7), - op_rs_func(0x3f, 0x1f, 0x1f003f), "D,S", 0}, - {"neg.d", op_rs_func(17, 0x11, 7), - op_rs_func(0x3f, 0x1f, 0x1f003f), "D,S", 0}, - {"cvt.s.s", op_rs_func(17, 0x10, 32), - op_rs_func(0x3f, 0x1f, 0x1f003f), "D,S", 0}, - {"cvt.s.d", op_rs_func(17, 0x11, 32), - op_rs_func(0x3f, 0x1f, 0x1f003f), "D,S", 0}, - {"cvt.s.w", op_rs_func(17, 0x14, 32), - op_rs_func(0x3f, 0x1f, 0x1f003f), "D,S", 0}, - {"cvt.d.s", op_rs_func(17, 0x10, 33), - op_rs_func(0x3f, 0x1f, 0x1f003f), "D,S", 0}, - {"cvt.d.d", op_rs_func(17, 0x11, 33), - op_rs_func(0x3f, 0x1f, 0x1f003f), "D,S", 0}, - {"cvt.d.w", op_rs_func(17, 0x14, 33), - op_rs_func(0x3f, 0x1f, 0x1f003f), "D,S", 0}, - {"cvt.w.s", op_rs_func(17, 0x10, 36), - op_rs_func(0x3f, 0x1f, 0x1f003f), "D,S", 0}, - {"cvt.w.d", op_rs_func(17, 0x11, 36), - op_rs_func(0x3f, 0x1f, 0x1f003f), "D,S", 0}, - {"c.f.s", op_rs_func(17, 0x10, 48), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.f.d", op_rs_func(17, 0x11, 48), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.un.s", op_rs_func(17, 0x10, 49), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.un.d", op_rs_func(17, 0x11, 49), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.eq.s", op_rs_func(17, 0x10, 50), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.eq.d", op_rs_func(17, 0x11, 50), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.ueq.s", op_rs_func(17, 0x10, 51), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.ueq.d", op_rs_func(17, 0x11, 51), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.olt.s", op_rs_func(17, 0x10, 52), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.olt.d", op_rs_func(17, 0x11, 52), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.ult.s", op_rs_func(17, 0x10, 53), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.ult.d", op_rs_func(17, 0x11, 53), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.ole.s", op_rs_func(17, 0x10, 54), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.ole.d", op_rs_func(17, 0x11, 54), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.ule.s", op_rs_func(17, 0x10, 55), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.ule.d", op_rs_func(17, 0x11, 55), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.sf.s", op_rs_func(17, 0x10, 56), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.sf.d", op_rs_func(17, 0x11, 56), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.ngle.s", op_rs_func(17, 0x10, 57), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.ngle.d", op_rs_func(17, 0x11, 57), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.seq.s", op_rs_func(17, 0x10, 58), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.seq.d", op_rs_func(17, 0x11, 58), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.ngl.s", op_rs_func(17, 0x10, 59), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.ngl.d", op_rs_func(17, 0x11, 59), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.lt.s", op_rs_func(17, 0x10, 60), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.lt.d", op_rs_func(17, 0x11, 60), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.nge.s", op_rs_func(17, 0x10, 61), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.nge.d", op_rs_func(17, 0x11, 61), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.le.s", op_rs_func(17, 0x10, 62), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.le.d", op_rs_func(17, 0x11, 62), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.ngt.s", op_rs_func(17, 0x10, 63), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.ngt.d", op_rs_func(17, 0x11, 63), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - -/* co processor 2 instruction */ - {"mfc2", op_rs_b11 (18, 0, 0), op_rs_b11(0x3f, 0x1f, 0x1ffff), "t,d", 0}, - {"cfc2", op_rs_b11 (18, 2, 0), op_rs_b11(0x3f, 0x1f, 0x1ffff), "t,d", 0}, - {"mtc2", op_rs_b11 (18, 4, 0), op_rs_b11(0x3f, 0x1f, 0x1ffff), "t,d", 0}, - {"ctc2", op_rs_b11 (18, 6, 0), op_rs_b11(0x3f, 0x1f, 0x1ffff), "t,d", 0}, - {"bc2f", op_o16(18, 0x100), op_o16(0x3f, 0x3ff), "b", 1}, - {"bc2f", op_o16(18, 0x180), op_o16(0x3f, 0x3ff), "b", 1}, - {"bc2f", op_o16(18, 0x101), op_o16(0x3f, 0x3ff), "b", 1}, - {"bc2t", op_o16(18, 0x181), op_o16(0x3f, 0x3ff), "b", 1}, - -/* co processor 3 instruction */ - {"mtc3", op_rs_b11 (19, 0, 0), op_rs_b11(0x3f, 0x1f, 0x1ffff), "t,d", 0}, - {"cfc3", op_rs_b11 (19, 2, 0), op_rs_b11(0x3f, 0x1f, 0x1ffff), "t,d", 0}, - {"mtc3", op_rs_b11 (19, 4, 0), op_rs_b11(0x3f, 0x1f, 0x1ffff), "t,d", 0}, - {"ctc3", op_rs_b11 (19, 6, 0), op_rs_b11(0x3f, 0x1f, 0x1ffff), "t,d", 0}, - {"bc3f", op_o16(19, 0x100), op_o16(0x3f, 0x3ff), "b", 1}, - {"bc3f", op_o16(19, 0x180), op_o16(0x3f, 0x3ff), "b", 1}, - {"bc3t", op_o16(19, 0x101), op_o16(0x3f, 0x3ff), "b", 1}, - {"bc3t", op_o16(19, 0x181), op_o16(0x3f, 0x3ff), "b", 1}, - - {"lb", one(32), one(0x3f), "t,j(s)", 0}, - {"lh", one(33), one(0x3f), "t,j(s)", 0}, - {"lwl", one(34), one(0x3f), "t,j(s)", 0}, - {"lw", one(35), one(0x3f), "t,j(s)", 0}, - {"lbu", one(36), one(0x3f), "t,j(s)", 0}, - {"lhu", one(37), one(0x3f), "t,j(s)", 0}, - {"lwr", one(38), one(0x3f), "t,j(s)", 0}, - {"sb", one(40), one(0x3f), "t,j(s)", 0}, - {"sh", one(41), one(0x3f), "t,j(s)", 0}, - {"swl", one(42), one(0x3f), "t,j(s)", 0}, - {"swr", one(46), one(0x3f), "t,j(s)", 0}, - {"sw", one(43), one(0x3f), "t,j(s)", 0}, - {"lwc0", one(48), one(0x3f), "t,j(s)", 0}, -/* for fpu */ - {"lwc1", one(49), one(0x3f), "T,j(s)", 0}, - {"lwc2", one(50), one(0x3f), "t,j(s)", 0}, - {"lwc3", one(51), one(0x3f), "t,j(s)", 0}, - {"swc0", one(56), one(0x3f), "t,j(s)", 0}, -/* for fpu */ - {"swc1", one(57), one(0x3f), "T,j(s)", 0}, - {"swc2", one(58), one(0x3f), "t,j(s)", 0}, - {"swc3", one(59), one(0x3f), "t,j(s)", 0}, -}; diff --git a/gdb/mips-pinsn.c b/gdb/mips-pinsn.c deleted file mode 100644 index 6dc3e553755..00000000000 --- a/gdb/mips-pinsn.c +++ /dev/null @@ -1,149 +0,0 @@ -/* Print mips instructions for GDB, the GNU debugger. - Copyright (C) 1989 Free Software Foundation, Inc. - Contributed by Nobuyuki Hikichi(hikichi@sra.co.jp) - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include - -#include "defs.h" -#include "param.h" -#include "symtab.h" -#include "mips-opcode.h" - -/* Mips instructions are never longer than this many bytes. */ -#define MAXLEN 4 - -/* Number of elements in the opcode table. */ -#define NOPCODES (sizeof mips_opcodes / sizeof mips_opcodes[0]) - -#define MKLONG(p) *(unsigned long*)p - -extern char *reg_names[]; - - -/* subroutine */ -static unsigned char * -print_insn_arg (d, l, stream, pc) - char *d; - register unsigned long int *l; - FILE *stream; - CORE_ADDR pc; -{ - switch (*d) - { - case ',': - case '(': - case ')': - fputc (*d, stream); - break; - - case 's': - fprintf (stream, "$%s", reg_names[((struct op_i_fmt *) l)->rs]); - break; - - case 't': - fprintf (stream, "$%s", reg_names[((struct op_i_fmt *) l)->rt]); - break; - - case 'i': - fprintf (stream, "%d", ((struct op_i_fmt *) l)->immediate); - break; - - case 'j': /* same as i, but sign-extended */ - fprintf (stream, "%d", ((struct op_b_fmt *) l)->delta); - break; - - case 'a': - print_address ((pc & 0xF0000000) | (((struct op_j_fmt *)l)->target << 2), - stream); - break; - - case 'b': - print_address ((((struct op_b_fmt *) l)->delta << 2) + pc + 4, stream); - break; - - case 'd': - fprintf (stream, "$%s", reg_names[((struct op_r_fmt *) l)->rd]); - break; - - case 'h': - fprintf (stream, "0x%x", ((struct op_r_fmt *) l)->shamt); - break; - - case 'S': - fprintf (stream, "$f%d", ((struct fop_r_fmt *) l)->fs); - break; - - case 'T': - fprintf (stream, "$f%d", ((struct fop_r_fmt *) l)->ft); - break; - - case 'D': - fprintf (stream, "$f%d", ((struct fop_r_fmt *) l)->fd); - break; - - default: - fprintf (stream, "# internal error, undefined modifier(%c)", *d); - break; - } -} - -/* Print the mips instruction at address MEMADDR in debugged memory, - on STREAM. Returns length of the instruction, in bytes, which - is always 4. */ - -int -print_insn (memaddr, stream) - CORE_ADDR memaddr; - FILE *stream; -{ - unsigned char buffer[MAXLEN]; - register int i; - register char *d; - unsigned long int l; - - read_memory (memaddr, buffer, MAXLEN); - - for (i = 0; i < NOPCODES; i++) - { - register unsigned int opcode = mips_opcodes[i].opcode; - register unsigned int match = mips_opcodes[i].match; - if ((*(unsigned int*)buffer & match) == opcode) - break; - } - - l = MKLONG (buffer); - /* Handle undefined instructions. */ - if (i == NOPCODES) - { - fprintf (stream, "0x%x",l); - return 4; - } - - fprintf (stream, "%s", mips_opcodes[i].name); - - if (!(d = mips_opcodes[i].args)) - return 4; - - fputc (' ', stream); - - while (*d) - print_insn_arg (d++, &l, stream, memaddr); - - return 4; -} diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c deleted file mode 100644 index 849758b6130..00000000000 --- a/gdb/mips-tdep.c +++ /dev/null @@ -1,692 +0,0 @@ -/* Work with core dump and executable files, for GDB on MIPS. - This code would be in core.c if it weren't machine-dependent. */ - -/* Low level interface to ptrace, for GDB when running under Unix. - Copyright (C) 1988, 1989, 1990 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. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* FIXME: Can a MIPS porter/tester determine which of these include - files we still need? -- gnu@cygnus.com */ -#include -#ifdef sgi -#include -#else -#include -#endif -#include "defs.h" -#include "param.h" -#include "frame.h" -#include "inferior.h" -#include "symtab.h" -#include "value.h" -#include "gdbcmd.h" -#include "language.h" - -#ifdef USG -#include -#endif - -#include -#include -#include -#include - -#include "gdbcore.h" - -#ifndef MIPSMAGIC -#ifdef MIPSEL -#define MIPSMAGIC MIPSELMAGIC -#else -#define MIPSMAGIC MIPSEBMAGIC -#endif -#endif - -#define VM_MIN_ADDRESS (unsigned)0x400000 - -#include /* After a.out.h */ -#include -#include - - -#define PROC_LOW_ADDR(proc) ((proc)->adr) /* least address */ -#define PROC_HIGH_ADDR(proc) ((proc)->pad2) /* upper address bound */ -#define PROC_FRAME_OFFSET(proc) ((proc)->framesize) -#define PROC_FRAME_REG(proc) ((proc)->framereg) -#define PROC_REG_MASK(proc) ((proc)->regmask) -#define PROC_FREG_MASK(proc) ((proc)->fregmask) -#define PROC_REG_OFFSET(proc) ((proc)->regoffset) -#define PROC_FREG_OFFSET(proc) ((proc)->fregoffset) -#define PROC_PC_REG(proc) ((proc)->pcreg) -#define PROC_SYMBOL(proc) (*(struct symbol**)&(proc)->isym) -#define _PROC_MAGIC_ 0x0F0F0F0F -#define PROC_DESC_IS_DUMMY(proc) ((proc)->isym == _PROC_MAGIC_) -#define SET_PROC_DESC_IS_DUMMY(proc) ((proc)->isym = _PROC_MAGIC_) - -struct linked_proc_info -{ - struct mips_extra_func_info info; - struct linked_proc_info *next; -} * linked_proc_desc_table = NULL; - - -#define READ_FRAME_REG(fi, regno) read_next_frame_reg((fi)->next, regno) - -int -read_next_frame_reg(fi, regno) - FRAME fi; - int regno; -{ -#define SIGFRAME_BASE sizeof(struct sigcontext) -#define SIGFRAME_PC_OFF (-SIGFRAME_BASE+ 2*sizeof(int)) -#define SIGFRAME_SP_OFF (-SIGFRAME_BASE+32*sizeof(int)) -#define SIGFRAME_RA_OFF (-SIGFRAME_BASE+34*sizeof(int)) - for (; fi; fi = fi->next) - if (in_sigtramp(fi->pc, 0)) { - /* No idea if this code works. --PB. */ - int offset; - if (regno == PC_REGNUM) offset = SIGFRAME_PC_OFF; - else if (regno == RA_REGNUM) offset = SIGFRAME_RA_OFF; - else if (regno == SP_REGNUM) offset = SIGFRAME_SP_OFF; - else return 0; - return read_memory_integer(fi->frame + offset, 4); - } - else if (regno == SP_REGNUM) return fi->frame; - else if (fi->saved_regs->regs[regno]) - return read_memory_integer(fi->saved_regs->regs[regno], 4); - return read_register(regno); -} - -int -mips_frame_saved_pc(frame) - FRAME frame; -{ - mips_extra_func_info_t proc_desc = (mips_extra_func_info_t)frame->proc_desc; - int pcreg = proc_desc ? PROC_PC_REG(proc_desc) : RA_REGNUM; - if (proc_desc && PROC_DESC_IS_DUMMY(proc_desc)) - return read_memory_integer(frame->frame - 4, 4); -#if 0 - /* If in the procedure prologue, RA_REGNUM might not have been saved yet. - * Assume non-leaf functions start with: - * addiu $sp,$sp,-frame_size - * sw $ra,ra_offset($sp) - * This if the pc is pointing at either of these instructions, - * then $ra hasn't been trashed. - * If the pc has advanced beyond these two instructions, - * then $ra has been saved. - * critical, and much more complex. Handling $ra is enough to get - * a stack trace, but some register values with be wrong. - */ - if (frame->proc_desc && frame->pc < PROC_LOW_ADDR(proc_desc) + 8) - return read_register(pcreg); -#endif - return read_next_frame_reg(frame, pcreg); -} - -static struct mips_extra_func_info temp_proc_desc; -static struct frame_saved_regs temp_saved_regs; - -CORE_ADDR heuristic_proc_start(pc) - CORE_ADDR pc; -{ - - CORE_ADDR start_pc = pc; - CORE_ADDR fence = start_pc - 10000; - if (fence < VM_MIN_ADDRESS) fence = VM_MIN_ADDRESS; - /* search back for previous return */ - for (start_pc -= 4; ; start_pc -= 4) - if (start_pc < fence) return 0; - else if (ABOUT_TO_RETURN(start_pc)) - break; - - start_pc += 8; /* skip return, and its delay slot */ -#if 0 - /* skip nops (usually 1) 0 - is this */ - while (start_pc < pc && read_memory_integer (start_pc, 4) == 0) - start_pc += 4; -#endif - return start_pc; -} - -mips_extra_func_info_t -heuristic_proc_desc(start_pc, limit_pc, next_frame) - CORE_ADDR start_pc, limit_pc; - FRAME next_frame; -{ - CORE_ADDR sp = next_frame ? next_frame->frame : read_register (SP_REGNUM); - CORE_ADDR cur_pc; - int frame_size; - int has_frame_reg = 0; - int reg30; /* Value of $r30. Used by gcc for frame-pointer */ - unsigned long reg_mask = 0; - - if (start_pc == 0) return NULL; - bzero(&temp_proc_desc, sizeof(temp_proc_desc)); - bzero(&temp_saved_regs, sizeof(struct frame_saved_regs)); - if (start_pc + 200 < limit_pc) limit_pc = start_pc + 200; - restart: - frame_size = 0; - for (cur_pc = start_pc; cur_pc < limit_pc; cur_pc += 4) { - unsigned long word; - int status; - - status = read_memory_nobpt (cur_pc, &word, 4); - if (status) memory_error (status, cur_pc); - if ((word & 0xFFFF0000) == 0x27bd0000) /* addiu $sp,$sp,-i */ - frame_size += (-word) & 0xFFFF; - else if ((word & 0xFFFF0000) == 0x23bd0000) /* addu $sp,$sp,-i */ - frame_size += (-word) & 0xFFFF; - else if ((word & 0xFFE00000) == 0xafa00000) { /* sw reg,offset($sp) */ - int reg = (word & 0x001F0000) >> 16; - reg_mask |= 1 << reg; - temp_saved_regs.regs[reg] = sp + (short)word; - } - else if ((word & 0xFFFF0000) == 0x27be0000) { /* addiu $30,$sp,size */ - if ((unsigned short)word != frame_size) - reg30 = sp + (unsigned short)word; - else if (!has_frame_reg) { - int alloca_adjust; - has_frame_reg = 1; - reg30 = read_next_frame_reg(next_frame, 30); - alloca_adjust = reg30 - (sp + (unsigned short)word); - if (alloca_adjust > 0) { - /* FP > SP + frame_size. This may be because - /* of an alloca or somethings similar. - * Fix sp to "pre-alloca" value, and try again. - */ - sp += alloca_adjust; - goto restart; - } - } - } - else if ((word & 0xFFE00000) == 0xafc00000) { /* sw reg,offset($30) */ - int reg = (word & 0x001F0000) >> 16; - reg_mask |= 1 << reg; - temp_saved_regs.regs[reg] = reg30 + (short)word; - } - } - if (has_frame_reg) { - PROC_FRAME_REG(&temp_proc_desc) = 30; - PROC_FRAME_OFFSET(&temp_proc_desc) = 0; - } - 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) = RA_REGNUM; - return &temp_proc_desc; -} - -mips_extra_func_info_t -find_proc_desc(pc, next_frame) - CORE_ADDR pc; - FRAME next_frame; -{ - mips_extra_func_info_t proc_desc; - extern struct block *block_for_pc(); - struct block *b = block_for_pc(pc); - - struct symbol *sym = - b ? lookup_symbol(".gdbinfo.", b, LABEL_NAMESPACE, 0, NULL) : NULL; - if (sym != NULL) - { - /* IF this is the topmost frame AND - * (this proc does not have debugging information OR - * the PC is in the procedure prologue) - * THEN create a "hueristic" proc_desc (by analyzing - * the actual code) to replace the "official" proc_desc. - */ - proc_desc = (struct mips_extra_func_info *)sym->value.value; - if (next_frame == NULL) { - struct symtab_and_line val; - struct symbol *proc_symbol = - PROC_DESC_IS_DUMMY(proc_desc) ? 0 : PROC_SYMBOL(proc_desc); - if (proc_symbol) { - val = find_pc_line (BLOCK_START - (SYMBOL_BLOCK_VALUE(proc_symbol)), - 0); - val.pc = val.end ? val.end : pc; - } - if (!proc_symbol || pc < val.pc) { - mips_extra_func_info_t found_heuristic = - heuristic_proc_desc(PROC_LOW_ADDR(proc_desc), - pc, next_frame); - if (found_heuristic) proc_desc = found_heuristic; - } - } - } - else - { - register struct linked_proc_info *link; - for (link = linked_proc_desc_table; link; link = link->next) - if (PROC_LOW_ADDR(&link->info) <= pc - && PROC_HIGH_ADDR(&link->info) > pc) - return &link->info; - proc_desc = - heuristic_proc_desc(heuristic_proc_start(pc), pc, next_frame); - } - return proc_desc; -} - -mips_extra_func_info_t cached_proc_desc; - -FRAME_ADDR mips_frame_chain(frame) - FRAME frame; -{ - extern CORE_ADDR startup_file_start; /* From blockframe.c */ - mips_extra_func_info_t proc_desc; - CORE_ADDR saved_pc = FRAME_SAVED_PC(frame); - if (startup_file_start) - { /* has at least the __start symbol */ - if (saved_pc == 0 || !outside_startup_file (saved_pc)) return 0; - } - else - { /* This hack depends on the internals of __start. */ - /* We also assume the breakpoints are *not* inserted */ - if (saved_pc == 0 - || read_memory_integer (saved_pc + 8, 4) & 0xFC00003F == 0xD) - return 0; /* break */ - } - proc_desc = find_proc_desc(saved_pc, frame); - if (!proc_desc) return 0; - cached_proc_desc = proc_desc; - return read_next_frame_reg(frame, PROC_FRAME_REG(proc_desc)) - + PROC_FRAME_OFFSET(proc_desc); -} - -void -init_extra_frame_info(fci) - struct frame_info *fci; -{ - extern struct obstack frame_cache_obstack; - /* Use proc_desc calculated in frame_chain */ - mips_extra_func_info_t proc_desc = fci->next ? cached_proc_desc : - find_proc_desc(fci->pc, fci->next); - fci->saved_regs = (struct frame_saved_regs*) - obstack_alloc (&frame_cache_obstack, sizeof(struct frame_saved_regs)); - bzero(fci->saved_regs, sizeof(struct frame_saved_regs)); - fci->proc_desc = - proc_desc == &temp_proc_desc ? (char*)NULL : (char*)proc_desc; - if (proc_desc) - { - int ireg; - CORE_ADDR reg_position; - unsigned long mask; - /* r0 bit means kernel trap */ - int kernel_trap = PROC_REG_MASK(proc_desc) & 1; - - /* Fixup frame-pointer - only needed for top frame */ - /* This may not be quite right, if procedure has a real frame register */ - if (fci->pc == PROC_LOW_ADDR(proc_desc)) - fci->frame = read_register (SP_REGNUM); - else - fci->frame = READ_FRAME_REG(fci, PROC_FRAME_REG(proc_desc)) - + PROC_FRAME_OFFSET(proc_desc); - - if (proc_desc == &temp_proc_desc) - *fci->saved_regs = temp_saved_regs; - else - { - /* find which general-purpose registers were saved */ - reg_position = fci->frame + PROC_REG_OFFSET(proc_desc); - mask = kernel_trap ? 0xFFFFFFFF : PROC_REG_MASK(proc_desc); - for (ireg= 31; mask; --ireg, mask <<= 1) - if (mask & 0x80000000) - { - fci->saved_regs->regs[ireg] = reg_position; - reg_position -= 4; - } - /* find which floating-point registers were saved */ - reg_position = fci->frame + PROC_FREG_OFFSET(proc_desc); - /* The freg_offset points to where the first *double* register is saved. - * So skip to the high-order word. */ - reg_position += 4; - mask = kernel_trap ? 0xFFFFFFFF : PROC_FREG_MASK(proc_desc); - for (ireg = 31; mask; --ireg, mask <<= 1) - if (mask & 0x80000000) - { - fci->saved_regs->regs[32+ireg] = reg_position; - reg_position -= 4; - } - } - - /* hack: if argument regs are saved, guess these contain args */ - if ((PROC_REG_MASK(proc_desc) & 0xF0) == 0) fci->num_args = -1; - else if ((PROC_REG_MASK(proc_desc) & 0x80) == 0) fci->num_args = 4; - else if ((PROC_REG_MASK(proc_desc) & 0x40) == 0) fci->num_args = 3; - else if ((PROC_REG_MASK(proc_desc) & 0x20) == 0) fci->num_args = 2; - else if ((PROC_REG_MASK(proc_desc) & 0x10) == 0) fci->num_args = 1; - - fci->saved_regs->regs[PC_REGNUM] = fci->saved_regs->regs[RA_REGNUM]; - } - if (fci->next == 0) - supply_register(FP_REGNUM, &fci->frame); -} - - -CORE_ADDR mips_push_arguments(nargs, args, sp, struct_return, struct_addr) - int nargs; - value *args; - CORE_ADDR sp; - int struct_return; - CORE_ADDR struct_addr; -{ - CORE_ADDR buf; - register i; - int accumulate_size = struct_return ? 4 : 0; - struct mips_arg { char *contents; int len; int offset; }; - struct mips_arg *mips_args = - (struct mips_arg*)alloca(nargs * sizeof(struct mips_arg)); - register struct mips_arg *m_arg; - for (i = 0, m_arg = mips_args; i < nargs; i++, m_arg++) { - extern value value_arg_coerce(); - value arg = value_arg_coerce (args[i]); - m_arg->len = TYPE_LENGTH (VALUE_TYPE (arg)); - /* This entire mips-specific routine is because doubles must be aligned - * on 8-byte boundaries. It still isn't quite right, because MIPS decided - * to align 'struct {int a, b}' on 4-byte boundaries (even though this - * breaks their varargs implementation...). A correct solution - * requires an simulation of gcc's 'alignof' (and use of 'alignof' - * in stdarg.h/varargs.h). - */ - if (m_arg->len > 4) accumulate_size = (accumulate_size + 7) & -8; - m_arg->offset = accumulate_size; - accumulate_size = (accumulate_size + m_arg->len + 3) & -4; - m_arg->contents = VALUE_CONTENTS(arg); - } - accumulate_size = (accumulate_size + 7) & (-8); - if (accumulate_size < 16) accumulate_size = 16; - sp -= accumulate_size; - for (i = nargs; m_arg--, --i >= 0; ) - write_memory(sp + m_arg->offset, m_arg->contents, m_arg->len); - if (struct_return) { - buf = struct_addr; - write_memory(sp, &buf, sizeof(CORE_ADDR)); -} - return sp; -} - -/* MASK(i,j) == (1<info; - CORE_ADDR sp = read_register (SP_REGNUM); - CORE_ADDR save_address; - REGISTER_TYPE buffer; - link->next = linked_proc_desc_table; - linked_proc_desc_table = link; -#define PUSH_FP_REGNUM 16 /* must be a register preserved across calls */ -#define GEN_REG_SAVE_MASK MASK(1,16)|MASK(24,28)|(1<<31) -#define GEN_REG_SAVE_COUNT 22 -#define FLOAT_REG_SAVE_MASK MASK(0,19) -#define FLOAT_REG_SAVE_COUNT 20 -#define SPECIAL_REG_SAVE_COUNT 4 - /* - * The registers we must save are all those not preserved across - * procedure calls. Dest_Reg (see tm-mips.h) must also be saved. - * In addition, we must save the PC, and PUSH_FP_REGNUM. - * (Ideally, we should also save MDLO/-HI and FP Control/Status reg.) - * - * Dummy frame layout: - * (high memory) - * Saved PC - * Saved MMHI, MMLO, FPC_CSR - * Saved R31 - * Saved R28 - * ... - * Saved R1 - * Saved D18 (i.e. F19, F18) - * ... - * Saved D0 (i.e. F1, F0) - * CALL_DUMMY (subroutine stub; see m-mips.h) - * Parameter build area (not yet implemented) - * (low memory) - */ - PROC_REG_MASK(proc_desc) = GEN_REG_SAVE_MASK; - PROC_FREG_MASK(proc_desc) = FLOAT_REG_SAVE_MASK; - PROC_REG_OFFSET(proc_desc) = /* offset of (Saved R31) from FP */ - -sizeof(long) - 4 * SPECIAL_REG_SAVE_COUNT; - PROC_FREG_OFFSET(proc_desc) = /* offset of (Saved D18) from FP */ - -sizeof(double) - 4 * (SPECIAL_REG_SAVE_COUNT + GEN_REG_SAVE_COUNT); - /* save general registers */ - save_address = sp + PROC_REG_OFFSET(proc_desc); - for (ireg = 32; --ireg >= 0; ) - if (PROC_REG_MASK(proc_desc) & (1 << ireg)) - { - buffer = read_register (ireg); - write_memory (save_address, &buffer, sizeof(REGISTER_TYPE)); - save_address -= 4; - } - /* save floating-points registers */ - save_address = sp + PROC_FREG_OFFSET(proc_desc); - for (ireg = 32; --ireg >= 0; ) - if (PROC_FREG_MASK(proc_desc) & (1 << ireg)) - { - buffer = read_register (ireg); - write_memory (save_address, &buffer, 4); - save_address -= 4; - } - write_register (PUSH_FP_REGNUM, sp); - PROC_FRAME_REG(proc_desc) = PUSH_FP_REGNUM; - PROC_FRAME_OFFSET(proc_desc) = 0; - buffer = read_register (PC_REGNUM); - write_memory (sp - 4, &buffer, sizeof(REGISTER_TYPE)); - buffer = read_register (HI_REGNUM); - write_memory (sp - 8, &buffer, sizeof(REGISTER_TYPE)); - buffer = read_register (LO_REGNUM); - write_memory (sp - 12, &buffer, sizeof(REGISTER_TYPE)); - buffer = read_register (FCRCS_REGNUM); - write_memory (sp - 16, &buffer, sizeof(REGISTER_TYPE)); - sp -= 4 * (GEN_REG_SAVE_COUNT+FLOAT_REG_SAVE_COUNT+SPECIAL_REG_SAVE_COUNT); - write_register (SP_REGNUM, sp); - PROC_LOW_ADDR(proc_desc) = sp - CALL_DUMMY_SIZE + CALL_DUMMY_START_OFFSET; - PROC_HIGH_ADDR(proc_desc) = sp; - SET_PROC_DESC_IS_DUMMY(proc_desc); - PROC_PC_REG(proc_desc) = RA_REGNUM; -} - -void -mips_pop_frame() -{ register int regnum; - FRAME frame = get_current_frame (); - CORE_ADDR new_sp = frame->frame; - mips_extra_func_info_t proc_desc = (mips_extra_func_info_t)frame->proc_desc; - if (PROC_DESC_IS_DUMMY(proc_desc)) - { - struct linked_proc_info **ptr = &linked_proc_desc_table;; - for (; &ptr[0]->info != proc_desc; ptr = &ptr[0]->next ) - if (ptr[0] == NULL) abort(); - *ptr = ptr[0]->next; - free (ptr[0]); - write_register (HI_REGNUM, read_memory_integer(new_sp - 8, 4)); - write_register (LO_REGNUM, read_memory_integer(new_sp - 12, 4)); - write_register (FCRCS_REGNUM, read_memory_integer(new_sp - 16, 4)); - } - write_register (PC_REGNUM, FRAME_SAVED_PC(frame)); - if (frame->proc_desc) { - for (regnum = 32; --regnum >= 0; ) - if (PROC_REG_MASK(proc_desc) & (1 << regnum)) - write_register (regnum, - read_memory_integer (frame->saved_regs->regs[regnum], 4)); - for (regnum = 64; --regnum >= 32; ) - if (PROC_FREG_MASK(proc_desc) & (1 << regnum)) - write_register (regnum, - read_memory_integer (frame->saved_regs->regs[regnum], 4)); - } - write_register (SP_REGNUM, new_sp); - flush_cached_frames (); - set_current_frame (create_new_frame (new_sp, read_pc ())); -} - -static -mips_print_register(regnum, all) - int regnum, all; -{ - unsigned char raw_buffer[8]; - REGISTER_TYPE val; - - read_relative_register_raw_bytes (regnum, raw_buffer); - - if (!(regnum & 1) && regnum >= FP0_REGNUM && regnum < FP0_REGNUM+32) { - read_relative_register_raw_bytes (regnum+1, raw_buffer+4); - printf_filtered ("(d%d: ", regnum&31); - val_print (builtin_type_double, raw_buffer, 0, - stdout, 0, 1, 0, Val_pretty_default); - printf_filtered ("); ", regnum&31); - } - fputs_filtered (reg_names[regnum], stdout); -#ifndef NUMERIC_REG_NAMES - if (regnum < 32) - printf_filtered ("(r%d): ", regnum); - else -#endif - printf_filtered (": "); - - /* If virtual format is floating, print it that way. */ - if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (regnum)) == TYPE_CODE_FLT - && ! INVALID_FLOAT (raw_buffer, REGISTER_VIRTUAL_SIZE(regnum))) { - val_print (REGISTER_VIRTUAL_TYPE (regnum), raw_buffer, 0, - stdout, 0, 1, 0, Val_pretty_default); - } - /* Else print as integer in hex. */ - else - { - long val; - - bcopy (raw_buffer, &val, sizeof (long)); - if (val == 0) - printf_filtered ("0"); - else if (all) - printf_filtered (local_hex_format(), val); - else - printf_filtered ("%s=%d", local_hex_string(val), val); - } -} - -/* Replacement for generic do_registers_info. */ -mips_do_registers_info (regnum, fpregs) - int regnum; - int fpregs; -{ - if (regnum != -1) { - mips_print_register (regnum, 0); - printf_filtered ("\n"); - } - else { - for (regnum = 0; regnum < NUM_REGS; ) { - if ((!fpregs) && regnum >= FP0_REGNUM && regnum <= FCRIR_REGNUM) { - regnum++; - continue; - } - mips_print_register (regnum, 1); - regnum++; - if ((regnum & 3) == 0 || regnum == NUM_REGS) - printf_filtered (";\n"); - else - printf_filtered ("; "); - } - } -} -/* Return number of args passed to a frame. described by FIP. - Can return -1, meaning no way to tell. */ - -mips_frame_num_args(fip) - FRAME fip; -{ -#if 0 - struct chain_info_t *p; - - p = mips_find_cached_frame(FRAME_FP(fip)); - if (p->valid) - return p->the_info.numargs; -#endif - return -1; -} - - -/* Bad floats: Returns 0 if P points to a valid IEEE floating point number, - 1 if P points to a denormalized number or a NaN. LEN says whether this is - a single-precision or double-precision float */ -#define SINGLE_EXP_BITS 8 -#define DOUBLE_EXP_BITS 11 -int -isa_NAN(p, len) - int *p, len; -{ - int exponent; - if (len == 4) - { - exponent = *p; - exponent = exponent << 1 >> (32 - SINGLE_EXP_BITS - 1); - return ((exponent == -1) || (! exponent && *p)); - } - else if (len == 8) - { - exponent = *(p+1); - exponent = exponent << 1 >> (32 - DOUBLE_EXP_BITS - 1); - return ((exponent == -1) || (! exponent && *p * *(p+1))); - } - else return 1; -} - -/* To skip prologues, I use this predicate. Returns either PC - itself if the code at PC does not look like a function prologue, - PC+4 if it does (our caller does not need anything more fancy). */ - -CORE_ADDR mips_skip_prologue(pc) - CORE_ADDR pc; -{ - struct symbol *f; - struct block *b; - unsigned long inst; - - /* For -g modules and most functions anyways the - first instruction adjusts the stack. */ - inst = read_memory_integer(pc, 4); - if ((inst & 0xffff0000) == 0x27bd0000) - return pc + 4; - - /* Well, it looks like a frameless. Let's make sure. - Note that we are not called on the current PC, - but on the function`s start PC, and I have definitely - seen optimized code that adjusts the SP quite later */ - b = block_for_pc(pc); - if (!b) return pc; - - f = lookup_symbol(".gdbinfo.", b, LABEL_NAMESPACE, 0, NULL); - if (!f) return pc; - /* Ideally, I would like to use the adjusted info - from mips_frame_info(), but for all practical - purposes it will not matter (and it would require - a different definition of SKIP_PROLOGUE()) - - Actually, it would not hurt to skip the storing - of arguments on the stack as well. */ - if (((struct mips_extra_func_info *)f->value.value)->framesize) - return pc + 4; - - return pc; -} diff --git a/gdb/mips-xdep.c b/gdb/mips-xdep.c deleted file mode 100644 index a5b0b03e655..00000000000 --- a/gdb/mips-xdep.c +++ /dev/null @@ -1,181 +0,0 @@ -/* Low level MIPS interface to ptrace, for GDB when running under Unix. - Copyright (C) 1988, 1989, 1991 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. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#ifdef sgi -#include -#else -#include -#endif -#include "defs.h" -#include "param.h" -#include "frame.h" -#include "inferior.h" -#include "symtab.h" -#include "value.h" - -#ifdef USG -#include -#endif - -#include -#include -#include -#include -/* #include Can we live without this? */ - -#include "gdbcore.h" - -#include /* After a.out.h */ -#include -#include - -/* For now we stub this out; sgi format is super-hairy (and completely - different in the new release) */ - -#ifdef sgi -void -fetch_core_registers () -{ - return; -} - -void -fetch_inferior_registers () -{ - return; -} - -store_inferior_registers (regno) - int regno; -{ - return; -} - - -#else - -/* Map gdb internal register number to ptrace address. */ - -#define REGISTER_PTRACE_ADDR(regno) \ - (regno < 32 ? regno \ - : regno == PC_REGNUM ? 96 \ - : regno == CAUSE_REGNUM ? 97 \ - : regno == HI_REGNUM ? 98 \ - : regno == LO_REGNUM ? 99 \ - : regno == FCRCS_REGNUM ? 100 \ - : regno == FCRIR_REGNUM ? 101 \ - : regno >= FP0_REGNUM ? regno - (FP0_REGNUM-32)\ - : 0) - -/* Get all registers from the inferior */ - -void -fetch_inferior_registers () -{ - register int regno; - register unsigned int regaddr; - char buf[MAX_REGISTER_RAW_SIZE]; - register int i; - - registers_fetched (); - - for (regno = 1; regno < NUM_REGS; regno++) - { - regaddr = REGISTER_PTRACE_ADDR (regno); - for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int)) - { - *(int *) &buf[i] = ptrace (3, inferior_pid, regaddr, 0); - regaddr += sizeof (int); - } - supply_register (regno, buf); - } -} - -/* Store our register values back into the inferior. - If REGNO is -1, do this for all registers. - Otherwise, REGNO specifies which register (so we can save time). */ - -void -store_inferior_registers (regno) - int regno; - { - register unsigned int regaddr; - char buf[80]; - - if (regno == 0) - return; - - if (regno > 0) - { - regaddr = REGISTER_PTRACE_ADDR (regno); - errno = 0; - ptrace (6, inferior_pid, regaddr, read_register (regno)); - if (errno != 0) - { - sprintf (buf, "writing register number %d", regno); - perror_with_name (buf); - } - } - else - { - for (regno = 0; regno < NUM_REGS; regno++) - { - if (regno == ZERO_REGNUM || regno == PS_REGNUM - || regno == BADVADDR_REGNUM || regno == CAUSE_REGNUM - || regno == FCRIR_REGNUM || regno == FP_REGNUM) - continue; - regaddr = register_addr (regno, 1); - errno = 0; - ptrace (6, inferior_pid, regaddr, read_register (regno)); - if (errno != 0) - { - sprintf (buf, "writing all regs, number %d", regno); - perror_with_name (buf); - } - } - } -} - -#endif /* sgi */ - -#if 0 -void -fetch_core_registers () -{ - register int regno; - int val; - - for (regno = 1; regno < NUM_REGS; regno++) { - char buf[MAX_REGISTER_RAW_SIZE]; - - val = bfd_seek (core_bfd, register_addr (regno, 0)); - if (val < 0 || (val = bfd_read (core_bfd, buf, sizeof buf)) < 0) { - char buffer[50]; - strcpy (buffer, "Reading register "); - strcat (buffer, reg_names[regno]); - - perror_with_name (buffer); - } - supply_register (regno, buf); - } -} -#endif /* 0 */ diff --git a/gdb/mipsread.c b/gdb/mipsread.c deleted file mode 100644 index 7d010a4d12a..00000000000 --- a/gdb/mipsread.c +++ /dev/null @@ -1,2809 +0,0 @@ -/* Read a symbol table in MIPS' format (Third-Eye). - Copyright (C) 1986, 1987, 1989-1991 Free Software Foundation, Inc. - Contributed by Alessandro Forin (af@cs.cmu.edu) at CMU - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* This module provides three functions: mipscoff_symfile_init, - which initializes to read a symbol file; mipscoff_new_init, which - discards existing cached information when all symbols are being - discarded; and mipscoff_symfile_read, which reads a symbol table - from a file. - - mipscoff_symfile_read only does the minimum work necessary for letting the - user "name" things symbolically; it does not read the entire symtab. - Instead, it reads the external and static symbols and puts them in partial - symbol tables. When more extensive information is requested of a - file, the corresponding partial symbol table is mutated into a full - fledged symbol table by going back and reading the symbols - for real. mipscoff_psymtab_to_symtab() is called indirectly through - a pointer in the psymtab to do this. */ - -#include -#include "param.h" -#include "obstack.h" -#include -#include -#include -#include "defs.h" -#include "symtab.h" -#include "gdbcore.h" -#include "symfile.h" -#ifdef CMUCS -#include -#else /* not CMUCS */ -#include -#include -#endif /* not CMUCS */ - -#include "coff-mips.h" - -struct coff_exec { - struct external_filehdr f; - struct external_aouthdr a; -}; - -/* Each partial symbol table entry contains a pointer to private data for the - read_symtab() function to use when expanding a partial symbol table entry - to a full symbol table entry. - - For mipsread this structure contains the index of the FDR that this psymtab - represents and a pointer to the symbol table header HDRR from the symbol - file that the psymtab was created from. */ - -#define FDR_IDX(p) (((struct symloc *)((p)->read_symtab_private))->fdr_idx) -#define CUR_HDR(p) (((struct symloc *)((p)->read_symtab_private))->cur_hdr) - -struct symloc { - int fdr_idx; - HDRR *cur_hdr; -}; - -/* Things we import explicitly from other modules */ - -extern int info_verbose; -extern struct block *block_for_pc(); -extern void sort_symtab_syms(); - -/* Various complaints about symbol reading that don't abort the process */ - -struct complaint unknown_ext_complaint = - {"unknown external symbol %s", 0, 0}; - -struct complaint unknown_sym_complaint = - {"unknown local symbol %s", 0, 0}; - -struct complaint unknown_st_complaint = - {"with type %d", 0, 0}; - -struct complaint block_overflow_complaint = - {"block containing %s overfilled", 0, 0}; - -struct complaint basic_type_complaint = - {"cannot map MIPS basic type 0x%x", 0, 0}; - -struct complaint unknown_type_qual_complaint = - {"unknown type qualifier 0x%x", 0, 0}; - -struct complaint array_bitsize_complaint = - {"size of array target type not known, assuming %d bits", 0, 0}; - -struct complaint array_parse_complaint = - {"array type with strange relative symbol", 0, 0}; - -/* Macros and extra defs */ - -/* Already-parsed symbols are marked specially */ - -#define stParsed stType - -/* Puns: hard to find whether -g was used and how */ - -#define MIN_GLEVEL GLEVEL_0 -#define compare_glevel(a,b) \ - (((a) == GLEVEL_3) ? ((b) < GLEVEL_3) : \ - ((b) == GLEVEL_3) ? -1 : (int)((b) - (a))) - -/* When looking at .o files, avoid tripping over bad addresses */ - -#define SAFE_TEXT_ADDR 0x400000 -#define SAFE_DATA_ADDR 0x10000000 - -#define UNSAFE_DATA_ADDR(p) ((unsigned)p < SAFE_DATA_ADDR || (unsigned)p > 2*SAFE_DATA_ADDR) - -/* Things that really are local to this module */ - -/* GDB symtable for the current compilation unit */ - -static struct symtab *cur_stab; - -/* MIPS symtab header for the current file */ - -static HDRR *cur_hdr; - -/* Pointer to current file decriptor record, and its index */ - -static FDR *cur_fdr; -static int cur_fd; - -/* Index of current symbol */ - -static int cur_sdx; - -/* Note how much "debuggable" this image is. We would like - to see at least one FDR with full symbols */ - -static max_gdbinfo; -static max_glevel; - -/* When examining .o files, report on undefined symbols */ - -static int n_undef_symbols, n_undef_labels, n_undef_vars, n_undef_procs; - -/* Extra builtin types */ - -struct type *builtin_type_complex; -struct type *builtin_type_double_complex; -struct type *builtin_type_fixed_dec; -struct type *builtin_type_float_dec; -struct type *builtin_type_string; - -/* Template types */ - -static struct type *builtin_type_ptr; -static struct type *builtin_type_struct; -static struct type *builtin_type_union; -static struct type *builtin_type_enum; -static struct type *builtin_type_range; -static struct type *builtin_type_set; - -/* Forward declarations */ - -static struct symbol *new_symbol(); -static struct type *new_type(); -static struct field *new_field(); -static struct block *new_block(); -static struct symtab *new_symtab(); -static struct linetable *new_linetable(); -static struct blockvector *new_bvect(); - -static struct type *parse_type(); -static struct type *make_type(); -static struct symbol *mylookup_symbol(); -static struct block *shrink_block(); - -static int compare_symtabs(); -static int compare_psymtabs(); -static int compare_blocks(); - -static struct partial_symtab *new_psymtab(); -static struct partial_symtab *parse_fdr(); -static int compare_psymbols(); - -static void psymtab_to_symtab_1(); -static void add_block(); -static void add_symbol(); -static int add_line(); -static void reorder_symtabs(); -static void reorder_psymtabs(); -static void shrink_linetable(); - -/* Things we export to other modules */ - -/* Address bounds for the signal trampoline in inferior, if any */ -/* FIXME: Nothing really seems to use this. Why is it here? */ - -CORE_ADDR sigtramp_address, sigtramp_end; - -/* The entry point (starting address) of the file, if it is an executable. */ - -extern CORE_ADDR startup_file_start; /* From blockframe.c */ -extern CORE_ADDR startup_file_end; /* From blockframe.c */ - -void -mipscoff_new_init() -{ - /* If we have a file symbol header lying around, blow it away. */ - if (cur_hdr) - free ((char *)cur_hdr); - cur_hdr = 0; -} - -void -mipscoff_symfile_init (sf) - struct sym_fns *sf; -{ - sf->sym_private = NULL; -} - -void -mipscoff_symfile_read(sf, addr, mainline) - struct sym_fns *sf; - CORE_ADDR addr; - int mainline; -{ - struct coff_symfile_info *info = (struct coff_symfile_info *)sf->sym_private; - bfd *abfd = sf->objfile->obfd; - char *name = bfd_get_filename (abfd); - int desc; - register int val; - int symtab_offset; - int stringtab_offset; - - /* Initialize a variable that we couldn't do at _initialize_ time. */ - builtin_type_ptr = lookup_pointer_type (builtin_type_void); - -/* WARNING WILL ROBINSON! ACCESSING BFD-PRIVATE DATA HERE! FIXME! */ - desc = fileno ((FILE *)(abfd->iostream)); /* Raw file descriptor */ -/* End of warning */ - - /* Position to read the symbol table. */ - val = lseek (desc, (long)symtab_offset, 0); - if (val < 0) - perror_with_name (name); - - init_misc_bunches (); - make_cleanup (discard_misc_bunches, 0); - - /* Now that the executable file is positioned at symbol table, - process it and define symbols accordingly. */ - - read_mips_symtab(sf->objfile, desc); - - /* Go over the misc symbol bunches and install them in vector. */ - - condense_misc_bunches (!mainline); -} - -/* Exported procedure: Allocate zeroed memory */ - -char * -xzalloc(size) -{ - char *p = xmalloc(size); - - bzero(p, size); - return p; -} - -/* Exported procedure: Builds a symtab from the PST partial one. - Restores the environment in effect when PST was created, delegates - most of the work to an ancillary procedure, and sorts - and reorders the symtab list at the end */ - -static void -mipscoff_psymtab_to_symtab(pst) - struct partial_symtab *pst; -{ - struct symtab *ret; - int i; - - if (!pst) - return; - - if (info_verbose) { - printf_filtered("Reading in symbols for %s...", pst->filename); - fflush(stdout); - } - /* Restore the header and list of pending typedefs */ - cur_hdr = CUR_HDR(pst); - - psymtab_to_symtab_1(pst, pst->filename); - - reorder_symtabs(); - - if (info_verbose) - printf_filtered("done.\n"); -} - -/* Exported procedure: Is PC in the signal trampoline code */ - -int -in_sigtramp(pc, name) - CORE_ADDR pc; - char *name; -{ - if (sigtramp_address == 0) - fixup_sigtramp(); - return (pc >= sigtramp_address && pc < sigtramp_end); -} - -/* File-level interface functions */ - -/* Read the symtab information from file FSYM into memory. Also, - return address just past end of our text segment in *END_OF_TEXT_SEGP. */ - -static -read_the_mips_symtab(abfd, fsym, end_of_text_segp) - bfd *abfd; - int fsym; - CORE_ADDR *end_of_text_segp; -{ - int stsize, st_hdrsize; - unsigned st_filptr; - HDRR st_hdr; - /* Header for executable/object file we read symbols from */ - struct coff_exec filhdr; - - /* We get here with DESC pointing to the symtab header. But we need - * other info from the initial headers */ - lseek(fsym, 0L, 0); - myread(fsym, &filhdr, sizeof filhdr); - - if (end_of_text_segp) - *end_of_text_segp = - bfd_h_get_32 (abfd, filhdr.a.text_start) + - bfd_h_get_32 (abfd, filhdr.a.tsize); - - /* Find and read the symbol table header */ - st_hdrsize = bfd_h_get_32 (abfd, filhdr.f.f_nsyms); - st_filptr = bfd_h_get_32 (abfd, filhdr.f.f_symptr); - if (st_filptr == 0) - return 0; - - lseek(fsym, st_filptr, L_SET); - if (st_hdrsize > sizeof (st_hdr)) /* Profanity check */ - abort(); - if (read(fsym, &st_hdr, st_hdrsize) != st_hdrsize) - goto readerr; - - /* Find out how large the symbol table is */ - stsize = (st_hdr.cbExtOffset - (st_filptr + st_hdrsize)) - + st_hdr.iextMax * cbEXTR; - - /* Allocate space for the symbol table. Read it in. */ - cur_hdr = (HDRR *) xmalloc(stsize + st_hdrsize); - - bcopy(&st_hdr, cur_hdr, st_hdrsize); - if (read(fsym, (char *) cur_hdr + st_hdrsize, stsize) != stsize) - goto readerr; - - /* Fixup file_pointers in it */ - fixup_symtab(cur_hdr, (char *) cur_hdr + st_hdrsize, - st_filptr + st_hdrsize); - - return; -readerr: - error("Short read on %s", bfd_get_filename (abfd)); -} - - -/* Turn all file-relative pointers in the symtab described by HDR - into memory pointers, given that the symtab itself is located - at DATA in memory and F_PTR in the file. */ - -static -fixup_symtab( hdr, data, f_ptr) - HDRR *hdr; - char *data; -{ - int f_idx, s_idx; - FDR *fh; - SYMR *sh; - OPTR *op; - PDR *pr; - EXTR *esh; - - /* - * These fields are useless (and empty) by now: - * hdr->cbDnOffset, hdr->cbOptOffset - * We use them for other internal purposes. - */ - hdr->cbDnOffset = 0; - hdr->cbOptOffset = 0; - -#define FIX(off) \ - if (hdr->off) hdr->off = (unsigned int)data + (hdr->off - f_ptr); - - FIX(cbLineOffset); - FIX(cbPdOffset); - FIX(cbSymOffset); - FIX(cbOptOffset); - FIX(cbAuxOffset); - FIX(cbSsOffset); - FIX(cbSsExtOffset); - FIX(cbFdOffset); - FIX(cbRfdOffset); - FIX(cbExtOffset); -#undef FIX - - - /* - * Fix all string pointers inside the symtab, and - * the FDR records. Also fix other miscellany. - */ - for (f_idx = 0; f_idx < hdr->ifdMax; f_idx++) { - register unsigned code_offset; - - /* Header itself, and strings */ - fh = (FDR *) (hdr->cbFdOffset) + f_idx; - fh->issBase += hdr->cbSsOffset; - if (fh->rss != -1) - fh->rss = (long)fh->rss + fh->issBase; - for (s_idx = 0; s_idx < fh->csym; s_idx++) { - sh = (SYMR*)(hdr->cbSymOffset) + fh->isymBase + s_idx; - sh->iss = (long) sh->iss + fh->issBase; - sh->reserved = 0; - } - - cur_fd = f_idx; - - /* Local symbols */ - fh->isymBase = (int)((SYMR*)(hdr->cbSymOffset)+fh->isymBase); - - /* cannot fix fh->ipdFirst because it is a short */ -#define IPDFIRST(h,fh) \ - ((long)h->cbPdOffset + fh->ipdFirst * sizeof(PDR)) - - /* Optional symbols (actually used for partial_symtabs) */ - fh->ioptBase = 0; - fh->copt = 0; - - /* Aux symbols */ - if (fh->caux) - fh->iauxBase = hdr->cbAuxOffset + fh->iauxBase * sizeof(AUXU); - /* Relative file descriptor table */ - fh->rfdBase = hdr->cbRfdOffset + fh->rfdBase * sizeof(RFDT); - - /* Line numbers */ - if (fh->cbLine) - fh->cbLineOffset += hdr->cbLineOffset; - - /* Procedure symbols. (XXX This should be done later) */ - code_offset = fh->adr; - for (s_idx = 0; s_idx < fh->cpd; s_idx++) { - unsigned name, only_ext; - - pr = (PDR*)(IPDFIRST(hdr,fh)) + s_idx; - - /* Simple rule to find files linked "-x" */ - only_ext = fh->rss == -1; - if (only_ext) { - if (pr->isym == -1) { - /* static function */ - sh = (SYMR*)-1; - } else { - /* external */ - name = hdr->cbExtOffset + pr->isym * sizeof(EXTR); - sh = &((EXTR*)name)->asym; - } - } else { - /* Full symbols */ - sh = (SYMR*)fh->isymBase + pr->isym; - /* Included code ? */ - if (s_idx == 0 && pr->adr != 0) - code_offset -= pr->adr; - } - - /* Turn index into a pointer */ - pr->isym = (long)sh; - - /* Fix line numbers */ - pr->cbLineOffset += fh->cbLineOffset; - - /* Relocate address */ - if (!only_ext) - pr->adr += code_offset; - } - } - - /* External symbols: fix string */ - for (s_idx = 0; s_idx < hdr->iextMax; s_idx++) { - esh = (EXTR*)(hdr->cbExtOffset) + s_idx; - esh->asym.iss = esh->asym.iss + hdr->cbSsExtOffset; - } -} - - -/* Find a file descriptor given its index RF relative to a file CF */ - -static FDR * -get_rfd (cf, rf) - int cf, rf; -{ - register FDR *f; - - f = (FDR *) (cur_hdr->cbFdOffset) + cf; - /* Object files do not have the RFD table, all refs are absolute */ - if (f->rfdBase == 0) - return (FDR *) (cur_hdr->cbFdOffset) + rf; - cf = *((pRFDT) f->rfdBase + rf); - return (FDR *) (cur_hdr->cbFdOffset) + cf; -} - -/* Return a safer print NAME for a file descriptor */ - -static char * -fdr_name(name) - char *name; -{ - if (name == (char *) -1) - return ""; - if (UNSAFE_DATA_ADDR(name)) - return ""; - return name; -} - - -/* Read in and parse the symtab of the file DESC. INCREMENTAL says - whether we are adding to the general symtab or not. - FIXME: INCREMENTAL is currently always zero, though it should not be. */ - -static -read_mips_symtab (objfile, desc) - struct objfile *objfile; - int desc; -{ - CORE_ADDR end_of_text_seg; - - read_the_mips_symtab(objfile->obfd, desc, &end_of_text_seg); - - parse_partial_symbols(end_of_text_seg, objfile); - - /* - * Check to make sure file was compiled with -g. - * If not, warn the user of this limitation. - */ - if (compare_glevel(max_glevel, GLEVEL_2) < 0) { - if (max_gdbinfo == 0) - printf ( -"\n%s not compiled with -g, debugging support is limited.\n", - objfile->name); - printf( -"You should compile with -g2 or -g3 for best debugging support.\n"); - fflush(stdout); - } -} - -/* Local utilities */ - -/* Map of FDR indexes to partial symtabs */ - -static struct pst_map { - struct partial_symtab *pst; /* the psymtab proper */ - int n_globals; /* globals it exports */ - int n_statics; /* statics (locals) it contains */ -} * fdr_to_pst; - - -/* Utility stack, used to nest procedures and blocks properly. - It is a doubly linked list, to avoid too many alloc/free. - Since we might need it quite a few times it is NOT deallocated - after use. */ - -static struct parse_stack { - struct parse_stack *next, *prev; - struct symtab *cur_st; /* Current symtab */ - struct block *cur_block; /* Block in it */ - int blocktype; /* What are we parsing */ - int maxsyms; /* Max symbols in this block */ - struct type *cur_type; /* Type we parse fields for */ - int procadr; /* Start addres of this procedure */ - int numargs; /* Its argument count */ -} *top_stack; /* Top stack ptr */ - - -/* Enter a new lexical context */ - -static push_parse_stack() -{ - struct parse_stack *new; - - /* Reuse frames if possible */ - if (top_stack && top_stack->prev) - new = top_stack->prev; - else - new = (struct parse_stack *) xzalloc(sizeof(struct parse_stack)); - /* Initialize new frame with previous content */ - if (top_stack) { - register struct parse_stack *prev = new->prev; - - *new = *top_stack; - top_stack->prev = new; - new->prev = prev; - new->next = top_stack; - } - top_stack = new; -} - -/* Exit a lexical context */ - -static pop_parse_stack() -{ - if (!top_stack) - return; - if (top_stack->next) - top_stack = top_stack->next; -} - - -/* Cross-references might be to things we haven't looked at - yet, e.g. type references. To avoid too many type - duplications we keep a quick fixup table, an array - of lists of references indexed by file descriptor */ - -static struct pending { - struct pending *next; /* link */ - SYMR *s; /* the symbol */ - struct type *t; /* its partial type descriptor */ -} **pending_list; - - -/* Check whether we already saw symbol SH in file FH as undefined */ - -static -struct pending *is_pending_symbol(fh, sh) - FDR *fh; - SYMR *sh; -{ - int f_idx = fh - (FDR *) cur_hdr->cbFdOffset; - register struct pending *p; - - /* Linear search is ok, list is typically no more than 10 deep */ - for (p = pending_list[f_idx]; p; p = p->next) - if (p->s == sh) - break; - return p; -} - -/* Check whether we already saw type T in file FH as undefined */ - -static -struct pending *is_pending_type(fh, t) - FDR *fh; - struct type *t; -{ - int f_idx = fh - (FDR *) cur_hdr->cbFdOffset; - register struct pending *p; - - for (p = pending_list[f_idx]; p; p = p->next) - if (p->t == t) - break; - return p; -} - -/* Add a new undef symbol SH of type T */ - -static -add_pending(fh, sh, t) - FDR *fh; - SYMR *sh; - struct type *t; -{ - int f_idx = fh - (FDR *) cur_hdr->cbFdOffset; - struct pending *p = is_pending_symbol(fh, sh); - - /* Make sure we do not make duplicates */ - if (!p) { - p = (struct pending *) xmalloc(sizeof(*p)); - p->s = sh; - p->t = t; - p->next = pending_list[f_idx]; - pending_list[f_idx] = p; - } - sh->reserved = 1; /* for quick check */ -} - -/* Throw away undef entries when done with file index F_IDX */ - -static -free_pending(f_idx) -{ - register struct pending *p, *q; - - for (p = pending_list[f_idx]; p; p = q) { - q = p->next; - free(p); - } - pending_list[f_idx] = 0; -} - -/* The number of args to a procedure is not explicit in the symtab, - this is the list of all those we know of. - This makes parsing more reasonable and avoids extra passes */ - -static struct numarg { - struct numarg *next; /* link */ - unsigned adr; /* procedure's start address */ - unsigned num; /* arg count */ -} *numargs_list; - -/* Record that the procedure at ADR takes NUM arguments. */ - -static -got_numargs(adr,num) -{ - struct numarg *n = (struct numarg *) xmalloc(sizeof(struct numarg)); - - n->adr = adr; - n->num = num; - n->next = numargs_list; - numargs_list = n; -} - -/* See if we know how many arguments the procedure at ADR takes */ - -static -lookup_numargs(adr) -{ - struct numarg *n = numargs_list; - - while (n && n->adr != adr) - n = n->next; - return (n) ? n->num : -1; -} - -/* Release storage when done with this file */ - -static void -free_numargs() -{ - struct numarg *n = numargs_list, *m; - - while (n) { - m = n->next; - free(n); - n = m; - } - numargs_list = 0; -} - - -/* Parsing Routines proper. */ - -/* Parse a single symbol. Mostly just make up a GDB symbol for it. - For blocks, procedures and types we open a new lexical context. - This is basically just a big switch on the symbol's type */ - -static void -parse_symbol(sh, ax) - SYMR *sh; - AUXU *ax; -{ - struct symbol *s; - struct block *b; - struct type *t; - struct field *f; - /* When a symbol is cross-referenced from other files/symbols - we mark it explicitly */ - int pend = (sh->reserved == 1); - enum address_class class; - - switch (sh->st) { - - case stNil: - break; - - case stGlobal: /* external symbol, goes into global block */ - class = LOC_STATIC; - b = BLOCKVECTOR_BLOCK(BLOCKVECTOR(top_stack->cur_st), - GLOBAL_BLOCK); - s = new_symbol(sh->iss); - SYMBOL_VALUE_ADDRESS(s) = (CORE_ADDR)sh->value; - goto data; - - case stStatic: /* static data, goes into current block. */ - class = LOC_STATIC; - b = top_stack->cur_block; - s = new_symbol(sh->iss); - SYMBOL_VALUE_ADDRESS(s) = (CORE_ADDR)sh->value; - goto data; - - case stLocal: /* local variable, goes into current block */ - if (sh->sc == scRegister) { - class = LOC_REGISTER; - if (sh->value > 31) - sh->value += 6; - } else - class = LOC_LOCAL; - b = top_stack->cur_block; - s = new_symbol(sh->iss); - SYMBOL_VALUE(s) = sh->value; - -data: /* Common code for symbols describing data */ - SYMBOL_NAMESPACE(s) = VAR_NAMESPACE; - SYMBOL_CLASS(s) = class; - add_symbol(s, b); - - /* Type could be missing in a number of cases */ - if (sh->sc == scUndefined || sh->sc == scNil || - sh->index == 0xfffff) - SYMBOL_TYPE(s) = builtin_type_int; /* undefined? */ - else - SYMBOL_TYPE(s) = parse_type(ax + sh->index, sh, 0); - /* Value of a data symbol is its memory address */ - break; - - case stParam: /* arg to procedure, goes into current block */ - max_gdbinfo++; - top_stack->numargs++; - s = new_symbol(sh->iss); - SYMBOL_NAMESPACE(s) = VAR_NAMESPACE; - if (sh->sc == scRegister) { - SYMBOL_CLASS(s) = LOC_REGPARM; - if (sh->value > 31) - sh->value += 6; - } else - SYMBOL_CLASS(s) = LOC_ARG; - SYMBOL_VALUE(s) = sh->value; - SYMBOL_TYPE(s) = parse_type(ax + sh->index, sh, 0); - add_symbol(s, top_stack->cur_block); -#if 0 - /* FIXME: This has not been tested. See dbxread.c */ - /* Add the type of this parameter to the function/procedure - type of this block. */ - add_param_to_type(&top_stack->cur_block->function->type,s); -#endif - break; - - case stLabel: /* label, goes into current block */ - s = new_symbol(sh->iss); - SYMBOL_NAMESPACE(s) = VAR_NAMESPACE; /* so that it can be used */ - SYMBOL_CLASS(s) = LOC_LABEL; /* but not misused */ - SYMBOL_VALUE_ADDRESS(s) = (CORE_ADDR)sh->value; - SYMBOL_TYPE(s) = builtin_type_int; - add_symbol(s, top_stack->cur_block); - break; - - case stProc: /* Procedure, usually goes into global block */ - case stStaticProc: /* Static procedure, goes into current block */ - s = new_symbol(sh->iss); - SYMBOL_NAMESPACE(s) = VAR_NAMESPACE; - SYMBOL_CLASS(s) = LOC_BLOCK; - /* Type of the return value */ - if (sh->sc == scUndefined || sh->sc == scNil) - t = builtin_type_int; - else - t = parse_type(ax + sh->index, sh, 0); - b = top_stack->cur_block; - if (sh->st == stProc) { - struct blockvector *bv = BLOCKVECTOR(top_stack->cur_st); - /* The next test should normally be true, - but provides a hook for nested functions - (which we don't want to make global). */ - if (b == BLOCKVECTOR_BLOCK(bv, STATIC_BLOCK)) - b = BLOCKVECTOR_BLOCK(bv, GLOBAL_BLOCK); - } - add_symbol(s, b); - - /* Make a type for the procedure itself */ -#if 0 - /* FIXME: This has not been tested yet! See dbxread.c */ - /* Generate a template for the type of this function. The - types of the arguments will be added as we read the symbol - table. */ - bcopy(SYMBOL_TYPE(s),lookup_function_type(t),sizeof(struct type)); -#else - SYMBOL_TYPE(s) = lookup_function_type (t); -#endif - - /* Create and enter a new lexical context */ - b = new_block(top_stack->maxsyms); - SYMBOL_BLOCK_VALUE(s) = b; - BLOCK_FUNCTION(b) = s; - BLOCK_START(b) = BLOCK_END(b) = sh->value; - BLOCK_SUPERBLOCK(b) = top_stack->cur_block; - add_block(b, top_stack->cur_st); - - /* Not if we only have partial info */ - if (sh->sc == scUndefined || sh->sc == scNil) - break; - - push_parse_stack(); - top_stack->cur_block = b; - top_stack->blocktype = sh->st; - top_stack->cur_type = SYMBOL_TYPE(s); - top_stack->procadr = sh->value; - top_stack->numargs = 0; - - sh->value = (long) SYMBOL_TYPE(s); - break; - - case stBlock: /* Either a lexical block, or some type */ - push_parse_stack(); - top_stack->blocktype = stBlock; - if (sh->sc == scInfo) { /* structure/union/enum def */ - s = new_symbol(sh->iss); - SYMBOL_NAMESPACE(s) = STRUCT_NAMESPACE; - SYMBOL_CLASS(s) = LOC_TYPEDEF; - SYMBOL_VALUE(s) = 0; - add_symbol(s, top_stack->cur_block); - /* If this type was expected, use its partial definition */ - if (pend) { - t = is_pending_symbol(cur_fdr, sh)->t; - } else { - /* Uhmm, can`t decide yet. Smash later */ - t = new_type(sh->iss); - TYPE_CODE(t) = TYPE_CODE_UNDEF; - add_pending(cur_fdr, sh, t); - } - SYMBOL_TYPE(s) = t; - /* make this the current type */ - top_stack->cur_type = t; - TYPE_LENGTH(t) = sh->value; - /* Mark that symbol has a type, and say which one */ - sh->value = (long) t; - } else { - /* beginnning of (code) block. Value of symbol - is the displacement from procedure start */ - b = new_block(top_stack->maxsyms); - BLOCK_START(b) = sh->value + top_stack->procadr; - BLOCK_SUPERBLOCK(b) = top_stack->cur_block; - top_stack->cur_block = b; - add_block(b, top_stack->cur_st); - } - break; - - case stEnd: /* end (of anything) */ - if (sh->sc == scInfo) { - /* Finished with type */ - top_stack->cur_type = 0; - } else if (sh->sc == scText && - (top_stack->blocktype == stProc || - top_stack->blocktype == stStaticProc)) { - /* Finished with procedure */ - struct blockvector *bv = BLOCKVECTOR(top_stack->cur_st); - struct block *b; - int i; - - BLOCK_END(top_stack->cur_block) += sh->value; /* size */ - got_numargs(top_stack->procadr, top_stack->numargs); - /* Reallocate symbols, saving memory */ - b = shrink_block(top_stack->cur_block, top_stack->cur_st); - - /* f77 emits proc-level with address bounds==[0,0], - So look for such child blocks, and patch them. */ - for (i = 0; i < BLOCKVECTOR_NBLOCKS(bv); i++) { - struct block *b_bad = BLOCKVECTOR_BLOCK(bv,i); - if (BLOCK_SUPERBLOCK(b_bad) == b - && BLOCK_START(b_bad) == top_stack->procadr - && BLOCK_END(b_bad) == top_stack->procadr) { - BLOCK_START(b_bad) = BLOCK_START(b); - BLOCK_END(b_bad) = BLOCK_END(b); - } - } - if (entry_point < BLOCK_END(b) - && entry_point >= BLOCK_START(b)) { - startup_file_start = BLOCK_START(b); - startup_file_end = BLOCK_END(b); - } - } else if (sh->sc == scText && top_stack->blocktype == stBlock) { - /* End of (code) block. The value of the symbol - is the displacement from the procedure`s start - address of the end of this block. */ - BLOCK_END(top_stack->cur_block) = sh->value + top_stack->procadr; - (void) shrink_block(top_stack->cur_block, top_stack->cur_st); - } - pop_parse_stack(); /* restore previous lexical context */ - break; - - case stMember: /* member of struct/union/enum.. */ - f = new_field(top_stack->cur_type, sh->iss); - f->bitpos = sh->value; - f->type = parse_type(ax + sh->index, sh, &f->bitsize); - break; - - case stTypedef: /* type definition */ - s = new_symbol(sh->iss); - SYMBOL_NAMESPACE(s) = VAR_NAMESPACE; - SYMBOL_CLASS(s) = LOC_TYPEDEF; - SYMBOL_BLOCK_VALUE(s) = top_stack->cur_block; - add_symbol(s, top_stack->cur_block); - SYMBOL_TYPE(s) = parse_type(ax + sh->index, sh, 0); - sh->value = (long) SYMBOL_TYPE(s); - break; - - case stFile: /* file name */ - push_parse_stack(); - top_stack->blocktype = sh->st; - break; - - /* I`ve never seen these for C */ - case stRegReloc: - break; /* register relocation */ - case stForward: - break; /* forwarding address */ - case stConstant: - break; /* constant */ - default: - error("Unknown symbol type %x.", sh->st); - } - sh->st = stParsed; -} - -/* Parse the type information provided in the AX entries for - the symbol SH. Return the bitfield size in BS, in case. */ - -static struct type *parse_type(ax, sh, bs) - AUXU *ax; - SYMR *sh; - int *bs; -{ - /* Null entries in this map are treated specially */ - static struct type **map_bt[] = - { - &builtin_type_void, /* btNil */ - 0, /* btAdr */ - &builtin_type_char, /* btChar */ - &builtin_type_unsigned_char, /* btUChar */ - &builtin_type_short, /* btShort */ - &builtin_type_unsigned_short, /* btUShort */ - &builtin_type_int, /* btInt */ - &builtin_type_unsigned_int, /* btUInt */ - &builtin_type_long, /* btLong */ - &builtin_type_unsigned_long, /* btULong */ - &builtin_type_float, /* btFloat */ - &builtin_type_double, /* btDouble */ - 0, /* btStruct */ - 0, /* btUnion */ - 0, /* btEnum */ - 0, /* btTypedef */ - 0, /* btRange */ - 0, /* btSet */ - &builtin_type_complex, /* btComplex */ - &builtin_type_double_complex, /* btDComplex */ - 0, /* btIndirect */ - &builtin_type_fixed_dec, /* btFixedDec */ - &builtin_type_float_dec, /* btFloatDec */ - &builtin_type_string, /* btString */ - 0, /* btBit */ - 0, /* btPicture */ - &builtin_type_void, /* btVoid */ - }; - - TIR *t; - struct type *tp = 0, *tp1; - char *fmt = "%s"; - - /* Procedures start off by one */ - if (sh->st == stProc || sh->st == stStaticProc) - ax++; - - /* Undefined ? Should not happen */ - if (ax->rndx.rfd == 0xfff) { - return builtin_type_void; - } - - /* Use aux as a type information record, map its basic type */ - t = &ax->ti; - if (t->bt > 26 || t->bt == btPicture) { - complain (&basic_type_complaint, t->bt); - return builtin_type_int; - } - if (map_bt[t->bt]) - tp = *map_bt[t->bt]; - else { - /* Cannot use builtin types, use templates */ - tp = make_type(TYPE_CODE_VOID, 0, 0, 0); - switch (t->bt) { - case btAdr: - *tp = *builtin_type_ptr; - break; - case btStruct: - *tp = *builtin_type_struct; - fmt = "struct %s"; - break; - case btUnion: - *tp = *builtin_type_union; - fmt = "union %s"; - break; - case btEnum: - *tp = *builtin_type_enum; - fmt = "enum %s"; - break; - case btRange: - *tp = *builtin_type_range; - break; - case btSet: - *tp = *builtin_type_set; - fmt = "set %s"; - break; - } - } - - /* Move on to next aux */ - ax++; - if (t->continued) { - /* This is the way it would work if the compiler worked */ - register TIR *t1 = t; - while (t1->continued) - ax++; - } - - /* For bitfields all we need is the width */ - if (t->fBitfield) { - *bs = ax->width; - return tp; - } - - /* All these types really point to some (common) MIPS type - definition, and only the type-qualifiers fully identify - them. We`ll make the same effort at sharing */ - if (t->bt == btIndirect || - t->bt == btStruct || - t->bt == btUnion || - t->bt == btEnum || - t->bt == btTypedef || - t->bt == btRange || - t->bt == btSet) { - char name[256], *pn; - - /* Try to cross reference this type */ - tp1 = tp; - ax += cross_ref(ax, &tp1, &pn); - /* SOMEONE OUGHT TO FIX DBXREAD TO DROP "STRUCT" */ - sprintf(name, fmt, pn); - - /* reading .o file ? */ - if (UNSAFE_DATA_ADDR(tp1)) - tp1 = tp; - if (TYPE_CODE(tp1) == TYPE_CODE_UNDEF) { - /* - * Type was incompletely defined, now we know. - */ - TYPE_CODE(tp1) = TYPE_CODE(tp); - TYPE_NAME(tp1) = obsavestring(name, strlen(name)); - if (TYPE_CODE(tp1) == TYPE_CODE_ENUM) { - int i; - - for (i = 0; i < TYPE_NFIELDS(tp1); i++) - make_enum_constant(&TYPE_FIELD(tp1,i), tp1); - } - } - if (tp1 != tp) { - /* found as cross ref, rid of our template */ - if ((TYPE_FLAGS(tp) & TYPE_FLAG_PERM) == 0) - free(tp); - tp = tp1; - /* stupid idea of prepending "struct" to type names */ - if (t->bt == btStruct && !index(TYPE_NAME(tp), ' ')) { - sprintf(name, fmt, TYPE_NAME(tp)); - TYPE_NAME(tp) = obsavestring(name, strlen(name)); - } - } else - TYPE_NAME(tp) = savestring(name, strlen(name)); - } - - /* Deal with range types */ - if (t->bt == btRange) { - struct field *f; - - f = new_field(tp, "Low"); - f->bitpos = ax->dnLow; - ax++; - f = new_field(tp, "High"); - f->bitpos = ax->dnHigh; - ax++; - } - - /* Parse all the type qualifiers now. If there are more - than 6 the game will continue in the next aux */ - -#define PARSE_TQ(tq) \ - if (t->tq != tqNil) ax += upgrade_type(&tp, t->tq, ax, sh); - -again: PARSE_TQ(tq0); - PARSE_TQ(tq1); - PARSE_TQ(tq2); - PARSE_TQ(tq3); - PARSE_TQ(tq4); - PARSE_TQ(tq5); -#undef PARSE_TQ - - if (t->continued) { - t++; - goto again; - } - return tp; -} - -/* Make up a complex type from a basic one. Type is passed by - reference in TPP and side-effected as necessary. The type - qualifier TQ says how to handle the aux symbols at AX for - the symbol SX we are currently analyzing. - Returns the number of aux symbols we parsed. */ - -static int -upgrade_type(tpp, tq, ax, sh) - struct type **tpp; - AUXU *ax; - SYMR *sh; -{ - int off; - struct type *t; - - /* Used in array processing */ - int rf, id; - FDR *fh; - struct field *f; - SYMR ss; - int lower, upper; - - switch (tq) { - case tqPtr: - t = lookup_pointer_type (*tpp); - *tpp = t; - return 0; - - case tqProc: - t = lookup_function_type (*tpp); - *tpp = t; - return 0; - - case tqArray: - off = 0; - t = make_type(TYPE_CODE_ARRAY, 0, 0, 0); - TYPE_TARGET_TYPE(t) = *tpp; - - /* Determine and record the domain type (type of index) */ - id = ax->rndx.index; - rf = ax->rndx.rfd; - if (rf == 0xfff) { - rf = (++ax)->isym; - off++; - } - fh = get_rfd(cur_fd, rf); - f = new_field(t, (char *)0); - bzero(&ss, sizeof ss); -/* XXX */ f->type = parse_type(fh->iauxBase + id * sizeof(AUXU), - &ss, &f->bitsize); - - if (off == 0) { - /* - * This seems to be a pointer to the end of the Block defining - * the type. Why it is here is magic for me, and I have no - * good use for it anyways. - */ - /* This used to occur because cross_ref returned - the wrong result (ax pointed wrong). FIXME, - delete this code in a while. -- gnu@cygnus jul91 */ - complain (&array_parse_complaint, 0); - off++; - id = (++ax)->rndx.index; - if ((rf = ax->rndx.rfd) == 0xfff) - rf = (++ax)->isym, off++; - } - lower = (++ax)->dnLow; - upper = (++ax)->dnHigh; - rf = (++ax)->width; /* bit size of array element */ - - /* Check whether supplied array element bit size matches - the known size of the element type. If this complaint - ends up not happening, we can remove this code. It's - here because we aren't sure we understand this *&%&$ - symbol format. */ - id = TYPE_LENGTH(TYPE_TARGET_TYPE(t)) << 3; /* bitsize */ - if (id == 0) { - /* Most likely an undefined type */ - id = rf; - TYPE_LENGTH(TYPE_TARGET_TYPE(t)) = id >> 3; - } - if (id != rf) - complain (&array_bitsize_complaint, rf); - - TYPE_LENGTH(t) = (upper < 0) ? 0 : - (upper - lower + 1) * (rf >> 3); - *tpp = t; - return 4 + off; - - case tqVol: - /* Volatile -- currently ignored */ - return 0; - - default: - complain (&unknown_type_qual_complaint, tq); - return 0; - } -} - - -/* Parse a procedure descriptor record PR. Note that the procedure - is parsed _after_ the local symbols, now we just make up the - extra information we need into a special symbol that we insert - in the procedure's main block. Note also that images that - have been partially stripped (ld -x) have been deprived - of local symbols, and we have to cope with them here. - The procedure's code ends at BOUND */ - -static -parse_procedure(pr, bound) - PDR *pr; -{ - struct symbol *s, *i; - SYMR *sh = (SYMR*)pr->isym; - struct block *b; - struct mips_extra_func_info *e; - char name[100]; - char *sh_name; - - /* Reuse the MIPS record */ - e = (struct mips_extra_func_info *) pr; - e->numargs = lookup_numargs(pr->adr); - - /* Make up our special symbol */ - i = new_symbol(".gdbinfo."); - SYMBOL_VALUE(i) = (int)e; - SYMBOL_NAMESPACE(i) = LABEL_NAMESPACE; - SYMBOL_CLASS(i) = LOC_CONST; - SYMBOL_TYPE(i) = builtin_type_void; - - /* Make up a name for static procedures. Sigh. */ - if (sh == (SYMR*)-1) { - sprintf(name,".static_procedure@%x",pr->adr); - sh_name = savestring(name, strlen(name)); - s = NULL; - } - else { - sh_name = (char*)sh->iss; - s = mylookup_symbol(sh_name, top_stack->cur_block, - VAR_NAMESPACE, LOC_BLOCK); - } - if (s != 0) { - b = SYMBOL_BLOCK_VALUE(s); - } else { - s = new_symbol(sh_name); - SYMBOL_NAMESPACE(s) = VAR_NAMESPACE; - SYMBOL_CLASS(s) = LOC_BLOCK; - /* Donno its type, hope int is ok */ - SYMBOL_TYPE(s) = lookup_function_type (builtin_type_int); - add_symbol(s, top_stack->cur_block); - /* Wont have symbols for this one */ - b = new_block(2); - SYMBOL_BLOCK_VALUE(s) = b; - BLOCK_FUNCTION(b) = s; - BLOCK_START(b) = pr->adr; - BLOCK_END(b) = bound; - BLOCK_SUPERBLOCK(b) = top_stack->cur_block; - add_block(b, top_stack->cur_st); - } - e->isym = (long)s; - add_symbol(i,b); -} - -/* Parse the external symbol ES. Just call parse_symbol() after - making sure we know where the aux are for it. For procedures, - parsing of the PDRs has already provided all the needed - information, we only parse them if SKIP_PROCEDURES is false, - and only if this causes no symbol duplication. - - This routine clobbers top_stack->cur_block and ->cur_st. */ - -static -parse_external(es, skip_procedures) - EXTR *es; -{ - AUXU *ax; - - if (es->ifd != ifdNil) { - cur_fd = es->ifd; - cur_fdr = (FDR*)(cur_hdr->cbFdOffset) + cur_fd; - ax = (AUXU*)cur_fdr->iauxBase; - } else { - cur_fdr = (FDR*)(cur_hdr->cbFdOffset); - ax = 0; - } - top_stack->cur_st = cur_stab; - top_stack->cur_block = BLOCKVECTOR_BLOCK(BLOCKVECTOR(top_stack->cur_st), - GLOBAL_BLOCK); - - /* Reading .o files */ - if (es->asym.sc == scUndefined || es->asym.sc == scNil) { - char *what; - switch (es->asym.st) { - case stStaticProc: - case stProc: what = "procedure"; n_undef_procs++; break; - case stGlobal: what = "variable"; n_undef_vars++; break; - case stLabel: what = "label"; n_undef_labels++; break; - default : what = "symbol"; break; - } - n_undef_symbols++; - if (info_verbose) - printf_filtered("Warning: %s `%s' is undefined (in %s)\n", what, - es->asym.iss, fdr_name(cur_fdr->rss)); - return; - } - - switch (es->asym.st) { - case stProc: - /* If we have full symbols we do not need more */ - if (skip_procedures) - return; - if (mylookup_symbol (es->asym.iss, top_stack->cur_block, - VAR_NAMESPACE, LOC_BLOCK)) - break; - /* fall through */ - case stGlobal: - case stLabel: - /* - * Note that the case of a symbol with indexNil - * must be handled anyways by parse_symbol(). - */ - parse_symbol(&es->asym, ax); - break; - default: - break; - } -} - -/* Parse the line number info for file descriptor FH into - GDB's linetable LT. MIPS' encoding requires a little bit - of magic to get things out. Note also that MIPS' line - numbers can go back and forth, apparently we can live - with that and do not need to reorder our linetables */ - -static -parse_lines(fh, lt) - FDR *fh; - struct linetable *lt; -{ - unsigned char *base = (unsigned char*)fh->cbLineOffset; - int i, j, k; - int delta, count, lineno = 0; - PDR *pr; - - if (base == 0) - return; - - /* Scan by procedure descriptors */ - i = 0; j = 0, k = 0; - for (pr = (PDR*)IPDFIRST(cur_hdr,fh); j < fh->cpd; j++, pr++) { - int l, halt; - - /* No code for this one */ - if (pr->iline == ilineNil || - pr->lnLow == -1 || pr->lnHigh == -1) - continue; - /* - * Aurgh! To know where to stop expanding we - * must look-ahead. - */ - for (l = 1; l < (fh->cpd - j); l++) - if (pr[l].iline != -1) - break; - if (l == (fh->cpd - j)) - halt = fh->cline; - else - halt = pr[l].iline; - /* - * When procedures are moved around the linenumbers - * are attributed to the next procedure up - */ - if (pr->iline >= halt) continue; - - base = (unsigned char*)pr->cbLineOffset; - l = pr->adr >> 2; /* in words */ - halt += (pr->adr >> 2) - pr->iline; - for (lineno = pr->lnLow; l < halt;) { - count = *base & 0x0f; - delta = *base++ >> 4; - if (delta >= 8) - delta -= 16; - if (delta == -8) { - delta = (base[0] << 8) | base[1]; - if (delta >= 0x8000) - delta -= 0x10000; - base += 2; - } - lineno += delta;/* first delta is 0 */ - k = add_line(lt, lineno, l, k); - l += count + 1; - } - } -} - - -/* Parse the symbols of the file described by FH, whose index is F_IDX. - BOUND is the highest core address of this file's procedures */ - -static -parse_one_file(fh, f_idx, bound) - FDR *fh; -{ - register int s_idx; - SYMR *sh; - PDR *pr; - - /* Parse local symbols first */ - - for (s_idx = 0; s_idx < fh->csym; s_idx++) { - sh = (SYMR *) (fh->isymBase) + s_idx; - cur_sdx = s_idx; - parse_symbol(sh, fh->iauxBase); - } - - /* Procedures next, note we need to look-ahead to - find out where the procedure's code ends */ - - for (s_idx = 0; s_idx < fh->cpd-1; s_idx++) { - pr = (PDR *) (IPDFIRST(cur_hdr, fh)) + s_idx; - parse_procedure(pr, pr[1].adr); /* next proc up */ - } - if (fh->cpd) { - pr = (PDR *) (IPDFIRST(cur_hdr, fh)) + s_idx; - parse_procedure(pr, bound); /* next file up */ - } - - /* Linenumbers. At the end, check if we can save memory */ - parse_lines(fh, LINETABLE(cur_stab)); - if (LINETABLE(cur_stab)->nitems < fh->cline) - shrink_linetable(cur_stab); -} - -/* Master parsing procedure for first-pass reading of file symbols - into a partial_symtab. - - Parses the symtab described by the global symbolic header CUR_HDR. - END_OF_TEXT_SEG gives the address just after the text segment for - the symtab we are reading. */ - -static -parse_partial_symbols(end_of_text_seg, objfile) - int end_of_text_seg; - struct objfile *objfile; -{ - int f_idx, s_idx, h_max, stat_idx; - HDRR *hdr; - /* Running pointers */ - FDR *fh; - RFDT *rh; - register EXTR *esh; - register SYMR *sh; - struct partial_symtab *pst; - - /* - * Big plan: - * - * Only parse the Local and External symbols, and the Relative FDR. - * Fixup enough of the loader symtab to be able to use it. - * Allocate space only for the file's portions we need to - * look at. (XXX) - */ - - hdr = cur_hdr; - max_gdbinfo = 0; - max_glevel = MIN_GLEVEL; - - /* Allocate the map FDR -> PST. - Minor hack: -O3 images might claim some global data belongs - to FDR -1. We`ll go along with that */ - fdr_to_pst = (struct pst_map *)xzalloc((hdr->ifdMax+1) * sizeof *fdr_to_pst); - fdr_to_pst++; - { - struct partial_symtab * pst = new_psymtab("", objfile); - fdr_to_pst[-1].pst = pst; - FDR_IDX(pst) = -1; - } - - /* Now scan the FDRs, mostly for dependencies */ - for (f_idx = 0; f_idx < hdr->ifdMax; f_idx++) - (void) parse_fdr(f_idx, 1, objfile); - - /* Take a good guess at how many symbols we might ever need */ - h_max = hdr->iextMax; - - /* Parse externals: two passes because they can be ordered - in any way, but gdb likes to have them segregated by their - source file. */ - - /* Pass 1 over external syms: Presize and partition the list */ - for (s_idx = 0; s_idx < hdr->iextMax; s_idx++) { - esh = (EXTR *) (hdr->cbExtOffset) + s_idx; - fdr_to_pst[esh->ifd].n_globals++; - } - - if (global_psymbols.list) { - int origsize = global_psymbols.next - global_psymbols.list; - - global_psymbols.list = (struct partial_symbol *) - xrealloc (global_psymbols.list, - (h_max + origsize) * sizeof(struct partial_symbol)); - global_psymbols.next = global_psymbols.list + origsize; - global_psymbols.size = h_max + origsize; - } else { - global_psymbols.list = (struct partial_symbol *) - xmalloc (h_max * sizeof(struct partial_symbol)); - global_psymbols.next = global_psymbols.list; - global_psymbols.size = h_max; - } - - /* Pass 1.5 over files: partition out global symbol space */ - s_idx = global_psymbols.next - global_psymbols.list; - for (f_idx = -1; f_idx < hdr->ifdMax; f_idx++) { - fdr_to_pst[f_idx].pst->globals_offset = s_idx; - s_idx += fdr_to_pst[f_idx].n_globals; - } - - /* Pass 1.6 over files: partition out static symbol space. - Note that this loop starts at 0, not at -1. */ - stat_idx = static_psymbols.next - static_psymbols.list; - for (f_idx = 0; f_idx < hdr->ifdMax; f_idx++) { - fdr_to_pst[f_idx].pst->statics_offset = stat_idx; - fh = f_idx + (FDR *)(hdr->cbFdOffset); - stat_idx += fh->csym; - } - - /* Now that we know its max size, allocate static symbol list */ - if (static_psymbols.list) { - int origsize = static_psymbols.next - static_psymbols.list; - - static_psymbols.list = (struct partial_symbol *) - xrealloc (static_psymbols.list, - stat_idx * sizeof(struct partial_symbol)); - static_psymbols.next = static_psymbols.list + origsize; - static_psymbols.size = stat_idx; - } else { - static_psymbols.list = (struct partial_symbol *) - xmalloc (stat_idx * sizeof(struct partial_symbol)); - static_psymbols.next = static_psymbols.list; - static_psymbols.size = stat_idx; - } - - /* Pass 2 over external syms: fill in external symbols */ - for (s_idx = 0; s_idx < hdr->iextMax; s_idx++) { - register struct partial_symbol *p; - enum misc_function_type misc_type = mf_text; - esh = (EXTR *) (hdr->cbExtOffset) + s_idx; - - if (esh->asym.sc == scUndefined || esh->asym.sc == scNil) - continue; - - /* Locate the psymtab and the preallocated psymbol. */ - pst = fdr_to_pst[esh->ifd].pst; - p = global_psymbols.list + pst->globals_offset + - pst->n_global_syms++; - SYMBOL_NAME(p) = (char *)(esh->asym.iss); - SYMBOL_NAMESPACE(p) = VAR_NAMESPACE; - - switch (esh->asym.st) { - case stProc: - SYMBOL_CLASS(p) = LOC_BLOCK; - SYMBOL_VALUE(p) = esh->asym.value; - break; - case stGlobal: - SYMBOL_CLASS(p) = LOC_STATIC; - SYMBOL_VALUE_ADDRESS(p) = (CORE_ADDR)esh->asym.value; - misc_type = mf_data; - break; - case stLabel: - SYMBOL_CLASS(p) = LOC_LABEL; - SYMBOL_VALUE_ADDRESS(p) = (CORE_ADDR)esh->asym.value; - break; - default: - misc_type = mf_unknown; - complain (&unknown_ext_complaint, SYMBOL_NAME(p)); - } - prim_record_misc_function (SYMBOL_NAME(p), - SYMBOL_VALUE(p), - misc_type); - } - - /* Pass 3 over files, over local syms: fill in static symbols */ - for (f_idx = 0; f_idx < hdr->ifdMax; f_idx++) { - fh = f_idx + (FDR *)(cur_hdr->cbFdOffset); - pst = fdr_to_pst[f_idx].pst; - pst->texthigh = pst->textlow; - - for (s_idx = 0; s_idx < fh->csym; ) { - register struct partial_symbol *p; - - sh = s_idx + (SYMR *) fh->isymBase; - - if (sh->sc == scUndefined || sh->sc == scNil) { - /* FIXME, premature? */ - s_idx++; - continue; - } - - /* Locate the preallocated psymbol. */ - p = static_psymbols.list + pst->statics_offset + - pst->n_static_syms; - SYMBOL_NAME(p) = (char *)(sh->iss); - SYMBOL_VALUE(p) = sh->value; - SYMBOL_NAMESPACE(p) = VAR_NAMESPACE; - - switch (sh->st) { - case stProc: /* Asm labels apparently */ - case stStaticProc: /* Function */ - SYMBOL_CLASS(p) = LOC_BLOCK; - pst->n_static_syms++; /* Use gdb symbol */ - /* Skip over procedure to next one. */ - s_idx = (sh->index + (AUXU *)fh->iauxBase) - ->isym; - { - long high; - long procaddr = sh->value; - - sh = s_idx + (SYMR *) fh->isymBase - 1; - if (sh->st != stEnd) - continue; - high = procaddr + sh->value; - if (high > pst->texthigh) - pst->texthigh = high; - } - continue; - case stStatic: /* Variable */ - SYMBOL_CLASS(p) = LOC_STATIC; - SYMBOL_VALUE_ADDRESS(p) = (CORE_ADDR)sh->value; - break; - case stTypedef: /* Typedef */ - SYMBOL_CLASS(p) = LOC_TYPEDEF; - break; - case stConstant: /* Constant decl */ - SYMBOL_CLASS(p) = LOC_CONST; - break; - case stBlock: /* { }, str, un, enum*/ - if (sh->sc == scInfo) { - SYMBOL_NAMESPACE(p) = STRUCT_NAMESPACE; - SYMBOL_CLASS(p) = LOC_TYPEDEF; - pst->n_static_syms++; - } - /* Skip over the block */ - s_idx = sh->index; - continue; - case stFile: /* File headers */ - case stLabel: /* Labels */ - case stEnd: /* Ends of files */ - goto skip; - default: - complain (&unknown_sym_complaint, SYMBOL_NAME(p)); - complain (&unknown_st_complaint, sh->st); - s_idx++; - continue; - } - pst->n_static_syms++; /* Use this gdb symbol */ - skip: - s_idx++; /* Go to next file symbol */ -#if 0 -/* We don't usually record static syms, but some we seem to. chk dbxread. */ -/*FIXME*/ prim_record_misc_function (SYMBOL_NAME(p), - SYMBOL_VALUE(p), - misc_type); -#endif - } - } - - /* The array (of lists) of globals must be sorted. */ - reorder_psymtabs(); - - /* Now sort the global psymbols. */ - for (f_idx = 0; f_idx < hdr->ifdMax; f_idx++) { - struct partial_symtab *pst = fdr_to_pst[f_idx].pst; - if (pst->n_global_syms > 1) - qsort (global_psymbols.list + pst->globals_offset, - pst->n_global_syms, sizeof (struct partial_symbol), - compare_psymbols); - } - - /* Mark the last code address, and remember it for later */ - hdr->cbDnOffset = end_of_text_seg; - - free(&fdr_to_pst[-1]); - fdr_to_pst = 0; -} - - -/* Do the initial analisys of the F_IDX-th file descriptor. - Allocates a partial symtab for it, and builds the list - of dependent files by recursion. LEV says at which level - of recursion we are called (to pretty up debug traces) */ - -static struct partial_symtab * -parse_fdr(f_idx, lev, objfile) - int f_idx; - int lev; - struct objfile *objfile; -{ - register FDR *fh; - register struct partial_symtab *pst; - int s_idx, s_id0; - - fh = (FDR *) (cur_hdr->cbFdOffset) + f_idx; - - /* Use this to indicate into which symtab this file was parsed */ - if (fh->ioptBase) - return (struct partial_symtab *) fh->ioptBase; - - /* Debuggability level */ - if (compare_glevel(max_glevel, fh->glevel) < 0) - max_glevel = fh->glevel; - - /* Make a new partial_symtab */ - pst = new_psymtab(fh->rss, objfile); - if (fh->cpd == 0){ - pst->textlow = 0; - pst->texthigh = 0; - } else { - pst->textlow = fh->adr; - pst->texthigh = fh->cpd; /* To be fixed later */ - } - - /* Make everything point to everything. */ - FDR_IDX(pst) = f_idx; - fdr_to_pst[f_idx].pst = pst; - fh->ioptBase = (int)pst; - - /* Analyze its dependencies */ - if (fh->crfd <= 1) - return pst; - - s_id0 = 0; - if (fh->cpd == 0) { /* If there are no functions defined here ... */ - /* ...then presumably a .h file: drop reverse depends .h->.c */ - for (; s_id0 < fh->crfd; s_id0++) { - RFDT *rh = (RFDT *) (fh->rfdBase) + s_id0; - if (*rh == f_idx) { - s_id0++; /* Skip self-dependency */ - break; - } - } - } - pst->number_of_dependencies = fh->crfd - s_id0; - pst->dependencies = (struct partial_symtab **) - obstack_alloc (psymbol_obstack, - pst->number_of_dependencies * - sizeof (struct partial_symtab *)); - for (s_idx = s_id0; s_idx < fh->crfd; s_idx++) { - RFDT *rh = (RFDT *) (fh->rfdBase) + s_idx; - - pst->dependencies[s_idx-s_id0] = parse_fdr(*rh, lev+1, objfile); - } - - return pst; -} - - -/* Ancillary function to psymtab_to_symtab(). Does all the work - for turning the partial symtab PST into a symtab, recurring - first on all dependent psymtabs. The argument FILENAME is - only passed so we can see in debug stack traces what file - is being read. */ - -static void -psymtab_to_symtab_1(pst, filename) - struct partial_symtab *pst; - char *filename; -{ - int i, f_max; - struct symtab *st; - FDR *fh; - - if (pst->readin) - return; - pst->readin = 1; - - pending_list = (struct pending **) cur_hdr->cbOptOffset; - if (pending_list == 0) { - pending_list = (struct pending **) - xzalloc(cur_hdr->ifdMax * sizeof(struct pending *)); - cur_hdr->cbOptOffset = (int)pending_list; - } - - /* How many symbols will we need */ - /* FIXME, this does not count enum values. */ - f_max = pst->n_global_syms + pst->n_static_syms; - if (FDR_IDX(pst) == -1) { - fh = 0; - st = new_symtab ("unknown", f_max, 0, pst->objfile); - } else { - fh = (FDR *) (cur_hdr->cbFdOffset) + FDR_IDX(pst); - f_max += fh->csym + fh->cpd; - st = new_symtab (pst->filename, 2 * f_max, 2 * fh->cline, - pst->objfile); - } - - /* Read in all partial symbtabs on which this one is dependent. - NOTE that we do have circular dependencies, sigh. We solved - that by setting pst->readin before this point. */ - - for (i = 0; i < pst->number_of_dependencies; i++) - if (!pst->dependencies[i]->readin) { - /* Inform about additional files to be read in. */ - if (info_verbose) - { - fputs_filtered (" ", stdout); - wrap_here (""); - fputs_filtered ("and ", stdout); - wrap_here (""); - printf_filtered ("%s...", - pst->dependencies[i]->filename); - wrap_here (""); /* Flush output */ - fflush (stdout); - } - /* We only pass the filename for debug purposes */ - psymtab_to_symtab_1(pst->dependencies[i], - pst->dependencies[i]->filename); - } - - /* Now read the symbols for this symtab */ - - cur_fd = FDR_IDX(pst); - cur_fdr = fh; - cur_stab = st; - - /* Get a new lexical context */ - - push_parse_stack(); - top_stack->cur_st = cur_stab; - top_stack->cur_block = BLOCKVECTOR_BLOCK(BLOCKVECTOR(cur_stab), - STATIC_BLOCK); - BLOCK_START(top_stack->cur_block) = fh ? fh->adr : 0; - BLOCK_END(top_stack->cur_block) = 0; - top_stack->blocktype = stFile; - top_stack->maxsyms = 2*f_max; - top_stack->cur_type = 0; - top_stack->procadr = 0; - top_stack->numargs = 0; - - /* Parse locals and procedures */ - if (fh) - parse_one_file(fh, cur_fd, (cur_fd == (cur_hdr->ifdMax - 1)) ? - cur_hdr->cbDnOffset : fh[1].adr); - - /* .. and our share of externals. - XXX use the global list to speed up things here. how ? - FIXME, Maybe quit once we have found the right number of ext's? */ - /* parse_external clobbers top_stack->cur_block and ->cur_st here. */ - top_stack->blocktype = stFile; - top_stack->maxsyms = cur_hdr->isymMax + cur_hdr->ipdMax + cur_hdr->iextMax; - for (i = 0; i < cur_hdr->iextMax; i++) { - register EXTR *esh = (EXTR *) (cur_hdr->cbExtOffset) + i; - if (esh->ifd == cur_fd) - parse_external(esh, 1); - } - - /* If there are undefined, tell the user */ - if (n_undef_symbols) { - printf_filtered("File %s contains %d unresolved references:", - st->filename, n_undef_symbols); - printf_filtered("\n\t%4d variables\n\t%4d procedures\n\t%4d labels\n", - n_undef_vars, n_undef_procs, n_undef_labels); - n_undef_symbols = n_undef_labels = n_undef_vars = n_undef_procs = 0; - } - - pop_parse_stack(); - - /* - * Sort the symbol table now, we are done adding symbols to it. - */ - sort_symtab_syms(st); - - /* Now link the psymtab and the symtab. */ - pst->symtab = st; -} - -/* Ancillary parsing procedures. */ - -/* Lookup the type at relative index RN. Return it in TPP - if found and in any event come up with its name PNAME. - Return value says how many aux symbols we ate */ - -static -cross_ref(rn, tpp, pname) - RNDXR *rn; - struct type **tpp; - char **pname; -{ - unsigned rf; - - /* Escape index means 'the next one' */ - if (rn->rfd == 0xfff) - rf = *(unsigned *) (rn + 1); - else - rf = rn->rfd; - - if (rf == -1) { - /* Ooops */ - *pname = ""; - } else { - /* - * Find the relative file descriptor and the symbol in it - */ - FDR *fh = get_rfd(cur_fd, rf); - SYMR *sh; - struct type *t; - - /* - * If we have processed this symbol then we left a forwarding - * pointer to the corresponding GDB symbol. If not, we`ll put - * it in a list of pending symbols, to be processed later when - * the file f will be. In any event, we collect the name for - * the type here. Which is why we made a first pass at - * strings. - */ - sh = (SYMR *) (fh->isymBase) + rn->index; - - /* Careful, we might be looking at .o files */ - *pname = (UNSAFE_DATA_ADDR(sh->iss)) ? "" : - (char *) sh->iss; - - /* Have we parsed it ? */ - if ((!UNSAFE_DATA_ADDR(sh->value)) && (sh->st == stParsed)) { - t = (struct type *) sh->value; - *tpp = t; - } else { - struct pending *p; - - /* Avoid duplicates */ - p = is_pending_symbol(fh, sh); - - if (p) - *tpp = p->t; - else - add_pending(fh, sh, *tpp); - } - } - - /* We used one auxent normally, two if we got a "next one" rf. */ - return (rn->rfd == 0xfff? 2: 1); -} - - -/* Quick&dirty lookup procedure, to avoid the MI ones that require - keeping the symtab sorted */ - -static struct symbol * -mylookup_symbol (name, block, namespace, class) - char *name; - register struct block *block; - enum namespace namespace; - enum address_class class; -{ - register int bot, top, inc; - register struct symbol *sym; - - bot = 0; - top = BLOCK_NSYMS(block); - inc = name[0]; - while (bot < top) { - sym = BLOCK_SYM(block, bot); - if (SYMBOL_NAME(sym)[0] == inc - && SYMBOL_NAMESPACE(sym) == namespace - && SYMBOL_CLASS(sym) == class - && !strcmp(SYMBOL_NAME(sym), name)) - return sym; - bot++; - } - if (block = BLOCK_SUPERBLOCK (block)) - return mylookup_symbol (name, block, namespace, class); - return 0; -} - - -/* Add a new symbol S to a block B. - Infrequently, we will need to reallocate the block to make it bigger. - We only detect this case when adding to top_stack->cur_block, since - that's the only time we know how big the block is. FIXME. */ - -static void -add_symbol(s,b) - struct symbol *s; - struct block *b; -{ - int nsyms = BLOCK_NSYMS(b)++; - struct block *origb; - struct parse_stack *stackp; - - if (b == top_stack->cur_block && - nsyms >= top_stack->maxsyms) { - complain (&block_overflow_complaint, s->name); - /* In this case shrink_block is actually grow_block, since - BLOCK_NSYMS(b) is larger than its current size. */ - origb = b; - b = shrink_block (top_stack->cur_block, top_stack->cur_st); - - /* Now run through the stack replacing pointers to the - original block. shrink_block has already done this - for the blockvector and BLOCK_FUNCTION. */ - for (stackp = top_stack; stackp; stackp = stackp->next) { - if (stackp->cur_block == origb) { - stackp->cur_block = b; - stackp->maxsyms = BLOCK_NSYMS (b); - } - } - } - BLOCK_SYM(b,nsyms) = s; -} - -/* Add a new block B to a symtab S */ - -static void -add_block(b,s) - struct block *b; - struct symtab *s; -{ - struct blockvector *bv = BLOCKVECTOR(s); - - bv = (struct blockvector *)xrealloc(bv, sizeof(struct blockvector) + - BLOCKVECTOR_NBLOCKS(bv) * sizeof(bv->block)); - if (bv != BLOCKVECTOR(s)) - BLOCKVECTOR(s) = bv; - - BLOCKVECTOR_BLOCK(bv, BLOCKVECTOR_NBLOCKS(bv)++) = b; -} - -/* Add a new linenumber entry (LINENO,ADR) to a linevector LT. - MIPS' linenumber encoding might need more than one byte - to describe it, LAST is used to detect these continuation lines */ - -static int -add_line(lt, lineno, adr, last) - struct linetable *lt; - int lineno; - CORE_ADDR adr; - int last; -{ - if (last == 0) - last = -2; /* make sure we record first line */ - - if (last == lineno) /* skip continuation lines */ - return lineno; - - lt->item[lt->nitems].line = lineno; - lt->item[lt->nitems++].pc = adr << 2; - return lineno; -} - - - -/* Comparison functions, used when sorting things */ - -/* Symtabs must be ordered viz the code segments they cover */ - -static int -compare_symtabs( s1, s2) - struct symtab **s1, **s2; -{ - /* "most specific" first */ - - register struct block *b1, *b2; - b1 = BLOCKVECTOR_BLOCK(BLOCKVECTOR(*s1),GLOBAL_BLOCK); - b2 = BLOCKVECTOR_BLOCK(BLOCKVECTOR(*s2),GLOBAL_BLOCK); - if (BLOCK_END(b1) == BLOCK_END(b2)) - return BLOCK_START(b1) - BLOCK_START(b2); - return BLOCK_END(b1) - BLOCK_END(b2); -} - - -/* Partial Symtabs, same */ - -static int -compare_psymtabs( s1, s2) - struct partial_symtab **s1, **s2; -{ - /* Perf twist: put the ones with no code at the end */ - - register int a = (*s1)->textlow; - register int b = (*s2)->textlow; - if (a == 0) - return b; - if (b == 0) - return -a; - return a - b; -} - - -/* Partial symbols are compared lexicog by their print names */ - -static int -compare_psymbols (s1, s2) - register struct partial_symbol *s1, *s2; -{ - register char - *st1 = SYMBOL_NAME(s1), - *st2 = SYMBOL_NAME(s2); - - return (st1[0] - st2[0] ? st1[0] - st2[0] : - strcmp(st1 + 1, st2 + 1)); -} - -/* Blocks with a smaller low bound should come first */ - -static int compare_blocks(b1,b2) - struct block **b1, **b2; -{ - register int addr_diff; - - addr_diff = (BLOCK_START((*b1))) - (BLOCK_START((*b2))); - if (addr_diff == 0) - return (BLOCK_END((*b1))) - (BLOCK_END((*b2))); - return addr_diff; -} - - -/* Sorting and reordering procedures */ - -/* Sort the blocks of a symtab S. - Reorder the blocks in the blockvector by code-address, - as required by some MI search routines */ - -static void -sort_blocks(s) - struct symtab *s; -{ - struct blockvector *bv = BLOCKVECTOR(s); - - if (BLOCKVECTOR_NBLOCKS(bv) <= 2) { - /* Cosmetic */ - if (BLOCK_END(BLOCKVECTOR_BLOCK(bv,GLOBAL_BLOCK)) == 0) - BLOCK_START(BLOCKVECTOR_BLOCK(bv,GLOBAL_BLOCK)) = 0; - if (BLOCK_END(BLOCKVECTOR_BLOCK(bv,STATIC_BLOCK)) == 0) - BLOCK_START(BLOCKVECTOR_BLOCK(bv,STATIC_BLOCK)) = 0; - return; - } - /* - * This is very unfortunate: normally all functions are compiled in - * the order they are found, but if the file is compiled -O3 things - * are very different. It would be nice to find a reliable test - * to detect -O3 images in advance. - */ - if (BLOCKVECTOR_NBLOCKS(bv) > 3) - qsort(&BLOCKVECTOR_BLOCK(bv,FIRST_LOCAL_BLOCK), - BLOCKVECTOR_NBLOCKS(bv) - FIRST_LOCAL_BLOCK, - sizeof(struct block *), - compare_blocks); - - { - register CORE_ADDR high = 0; - register int i, j = BLOCKVECTOR_NBLOCKS(bv); - - for (i = FIRST_LOCAL_BLOCK; i < j; i++) - if (high < BLOCK_END(BLOCKVECTOR_BLOCK(bv,i))) - high = BLOCK_END(BLOCKVECTOR_BLOCK(bv,i)); - BLOCK_END(BLOCKVECTOR_BLOCK(bv,GLOBAL_BLOCK)) = high; - } - - BLOCK_START(BLOCKVECTOR_BLOCK(bv,GLOBAL_BLOCK)) = - BLOCK_START(BLOCKVECTOR_BLOCK(bv,FIRST_LOCAL_BLOCK)); - - BLOCK_START(BLOCKVECTOR_BLOCK(bv,STATIC_BLOCK)) = - BLOCK_START(BLOCKVECTOR_BLOCK(bv,GLOBAL_BLOCK)); - BLOCK_END (BLOCKVECTOR_BLOCK(bv,STATIC_BLOCK)) = - BLOCK_END (BLOCKVECTOR_BLOCK(bv,GLOBAL_BLOCK)); -} - -/* Sort the symtab list, as required by some search procedures. - We want files ordered to make them look right to users, and for - searching (see block_for_pc). */ - -static void -reorder_symtabs() -{ - register int i; - struct symtab *stab; - register struct symtab **all_symtabs; - register int symtab_count; - - if (!symtab_list) - return; - - /* Create an array of pointers to all the symtabs. */ - for (symtab_count = 0, stab = symtab_list; - stab; - symtab_count++, stab = stab->next) { - obstack_grow (psymbol_obstack, &stab, sizeof (stab)); - /* FIXME: Only sort blocks for new symtabs ??? */ - sort_blocks(stab); - } - - all_symtabs = (struct symtab **) - obstack_base (psymbol_obstack); - qsort((char *)all_symtabs, symtab_count, - sizeof(struct symtab *), compare_symtabs); - - /* Re-construct the symtab list, but now it is sorted. */ - for (i = 0; i < symtab_count-1; i++) - all_symtabs[i]->next = all_symtabs[i+1]; - all_symtabs[i]->next = 0; - symtab_list = all_symtabs[0]; - - obstack_free (psymbol_obstack, all_symtabs); -} - -/* Sort the partial symtab list, as required by some search procedures. - PC lookups stop at the first psymtab such that textlow <= PC < texthigh */ - -static void -reorder_psymtabs() -{ - register int i; - register int all_psymtabs_count; - struct partial_symtab *pstab; - struct partial_symtab **all_psymtabs; - - if (!partial_symtab_list) - return; - - /* Create an array of pointers to all the partial_symtabs. */ - - for (all_psymtabs_count = 0, pstab = partial_symtab_list; - pstab; - all_psymtabs_count++, pstab = pstab->next) - obstack_grow (psymbol_obstack, &pstab, sizeof (pstab)); - - all_psymtabs = (struct partial_symtab **) - obstack_base (psymbol_obstack); - - qsort((char *)all_psymtabs, all_psymtabs_count, - sizeof(struct partial_symtab *), compare_psymtabs); - - /* Re-construct the partial_symtab_list, but now it is sorted. */ - - for (i = 0; i < all_psymtabs_count-1; i++) - all_psymtabs[i]->next = all_psymtabs[i+1]; - all_psymtabs[i]->next = 0; - partial_symtab_list = all_psymtabs[0]; - - obstack_free (psymbol_obstack, all_psymtabs); -} - -/* Constructor/restructor/destructor procedures */ - -/* Allocate a new symtab for NAME. Needs an estimate of how many symbols - MAXSYMS and linenumbers MAXLINES we'll put in it */ - -static -struct symtab * -new_symtab(name, maxsyms, maxlines, objfile) - char *name; -{ - struct symtab *s = allocate_symtab (name, objfile); - - LINETABLE(s) = new_linetable(maxlines); - - /* All symtabs must have at least two blocks */ - BLOCKVECTOR(s) = new_bvect(2); - BLOCKVECTOR_BLOCK(BLOCKVECTOR(s), GLOBAL_BLOCK) = new_block(maxsyms); - BLOCKVECTOR_BLOCK(BLOCKVECTOR(s), STATIC_BLOCK) = new_block(maxsyms); - BLOCK_SUPERBLOCK( BLOCKVECTOR_BLOCK(BLOCKVECTOR(s),STATIC_BLOCK)) = - BLOCKVECTOR_BLOCK(BLOCKVECTOR(s), GLOBAL_BLOCK); - - s->free_code = free_linetable; - - /* Link the new symtab into the list of such. */ - s->next = symtab_list; - symtab_list = s; - - return s; -} - -/* Allocate a new partial_symtab NAME */ - -static struct partial_symtab * -new_psymtab(name, objfile) - char *name; - struct objfile *objfile; -{ - struct partial_symtab *pst; - - pst = (struct partial_symtab *) - obstack_alloc (psymbol_obstack, sizeof (*pst)); - bzero (pst, sizeof (*pst)); - - if (name == (char*)-1) /* FIXME -- why not null here? */ - pst->filename = ""; - else - pst->filename = name; - - /* Chain it to its object file */ - pst->objfile = objfile; - pst->objfile_chain = sym_objfile->psymtabs; - sym_objfile->psymtabs = pst; - - pst->next = partial_symtab_list; - partial_symtab_list = pst; - - /* Keep a backpointer to the file's symbols */ - pst->read_symtab_private = (char *) obstack_alloc (psymbol_obstack, - sizeof (struct symloc)); - CUR_HDR(pst) = cur_hdr; - - /* The way to turn this into a symtab is to call... */ - pst->read_symtab = mipscoff_psymtab_to_symtab; - - return pst; -} - - -/* Allocate a linetable array of the given SIZE */ - -static -struct linetable *new_linetable(size) -{ - struct linetable *l; - - size = size * sizeof(l->item) + sizeof(struct linetable); - l = (struct linetable *)xmalloc(size); - l->nitems = 0; - return l; -} - -/* Oops, too big. Shrink it. This was important with the 2.4 linetables, - I am not so sure about the 3.4 ones */ - -static void -shrink_linetable(s) - struct symtab *s; -{ - struct linetable *l = new_linetable(LINETABLE(s)->nitems); - - bcopy(LINETABLE(s), l, - LINETABLE(s)->nitems * sizeof(l->item) + sizeof(struct linetable)); - free (LINETABLE(s)); - LINETABLE(s) = l; -} - -/* Allocate and zero a new blockvector of NBLOCKS blocks. */ - -static -struct blockvector * -new_bvect(nblocks) -{ - struct blockvector *bv; - int size; - - size = sizeof(struct blockvector) + nblocks * sizeof(struct block*); - bv = (struct blockvector *) xzalloc(size); - - BLOCKVECTOR_NBLOCKS(bv) = nblocks; - - return bv; -} - -/* Allocate and zero a new block of MAXSYMS symbols */ - -static -struct block * -new_block(maxsyms) -{ - int size = sizeof(struct block) + (maxsyms-1) * sizeof(struct symbol *); - struct block *b = (struct block *)xzalloc(size); - - return b; -} - -/* Ooops, too big. Shrink block B in symtab S to its minimal size. - Shrink_block can also be used by add_symbol to grow a block. */ - -static struct block * -shrink_block(b, s) - struct block *b; - struct symtab *s; -{ - struct block *new; - struct blockvector *bv = BLOCKVECTOR(s); - int i; - - /* Just reallocate it and fix references to the old one */ - - new = (struct block *) xrealloc ((char *)b, sizeof(struct block) + - (BLOCK_NSYMS(b)-1) * sizeof(struct symbol *)); - - /* Should chase pointers to old one. Fortunately, that`s just - the block`s function and inferior blocks */ - if (BLOCK_FUNCTION(new) && SYMBOL_BLOCK_VALUE(BLOCK_FUNCTION(new)) == b) - SYMBOL_BLOCK_VALUE(BLOCK_FUNCTION(new)) = new; - for (i = 0; i < BLOCKVECTOR_NBLOCKS(bv); i++) - if (BLOCKVECTOR_BLOCK(bv,i) == b) - BLOCKVECTOR_BLOCK(bv,i) = new; - else if (BLOCK_SUPERBLOCK(BLOCKVECTOR_BLOCK(bv,i)) == b) - BLOCK_SUPERBLOCK(BLOCKVECTOR_BLOCK(bv,i)) = new; - return new; -} - -/* Create a new symbol with printname NAME */ - -static -struct symbol * -new_symbol(name) - char *name; -{ - struct symbol *s = (struct symbol *) - obstack_alloc (symbol_obstack, sizeof (struct symbol)); - - bzero (s, sizeof (*s)); - SYMBOL_NAME(s) = name; - return s; -} - -/* Create a new type with printname NAME */ - -static -struct type * -new_type(name) - char *name; -{ - struct type *t = (struct type *) - obstack_alloc (symbol_obstack, sizeof (struct type)); - - bzero (t, sizeof (*t)); - TYPE_VPTR_FIELDNO (t) = -1; - TYPE_NAME(t) = name; - return t; -} - -/* Create and initialize a new type with printname NAME. - CODE and LENGTH are the initial info we put in, - UNS says whether the type is unsigned or not. */ - -static -struct type * -make_type(code, length, uns, name) - enum type_code code; - int length, uns; - char *name; -{ - register struct type *type; - - type = (struct type *) xzalloc(sizeof(struct type)); - TYPE_CODE(type) = code; - TYPE_LENGTH(type) = length; - TYPE_FLAGS(type) = uns ? TYPE_FLAG_UNSIGNED : 0; - TYPE_NAME(type) = name; - TYPE_VPTR_FIELDNO (type) = -1; - - return type; -} - -/* Allocate a new field named NAME to the type TYPE */ - -static -struct field * -new_field(type,name) - struct type *type; - char *name; -{ - struct field *f; - - /* Fields are kept in an array */ - if (TYPE_NFIELDS(type)) - TYPE_FIELDS(type) = (struct field*)xrealloc(TYPE_FIELDS(type), - (TYPE_NFIELDS(type)+1) * sizeof(struct field)); - else - TYPE_FIELDS(type) = (struct field*)xzalloc(sizeof(struct field)); - f = &(TYPE_FIELD(type,TYPE_NFIELDS(type))); - TYPE_NFIELDS(type)++; - bzero(f, sizeof(struct field)); - f->name = name; /* Whether or not NAME is zero, this works. */ - return f; -} - -/* Make an enum constant for a member F of an enumerated type T */ - -static -make_enum_constant(f,t) - struct field *f; - struct type *t; -{ - struct symbol *s; - /* - * This is awful, but that`s the way it is supposed to be - * (BTW, no need to free the real 'type', it's a builtin) - */ - f->type = (struct type *) f->bitpos; - - s = new_symbol(f->name); - SYMBOL_NAMESPACE(s) = VAR_NAMESPACE; - SYMBOL_CLASS(s) = LOC_CONST; - SYMBOL_TYPE(s) = t; - SYMBOL_VALUE(s) = f->bitpos; - add_symbol(s, top_stack->cur_block); -} - - - -/* Things used for calling functions in the inferior. - These functions are exported to our companion - mips-dep.c file and are here because they play - with the symbol-table explicitly. */ - -#if 0 -/* Need to make a new symbol on the fly for the dummy - frame we put on the stack. Which goes in the.. */ - -static struct symtab *dummy_symtab; - -/* Make up a dummy symbol for the code we put at END_PC, - of size SIZE, invoking a function with NARGS arguments - and using a frame of FRAMESIZE bytes */ - -mips_create_dummy_symbol(end_pc, size, nargs, framesize) -{ - struct block *bl; - struct symbol *g; - struct mips_extra_func_info *gdbinfo; - - /* Allocate symtab if not done already */ - if (dummy_symtab == 0) - dummy_symtab = new_symtab(".dummy_symtab.", 100, 0); - - /* Make a new block. Only needs one symbol */ - bl = new_block(1); - BLOCK_START(bl) = end_pc - size; - BLOCK_END(bl) = end_pc; - - BLOCK_SUPERBLOCK(bl) = - BLOCKVECTOR_BLOCK(BLOCKVECTOR(dummy_symtab),GLOBAL_BLOCK); - add_block(bl, dummy_symtab); - sort_blocks(dummy_symtab); - - BLOCK_FUNCTION(bl) = new_symbol("??"); - SYMBOL_BLOCK_VALUE(BLOCK_FUNCTION(bl)) = bl; - g = new_symbol(".gdbinfo."); - BLOCK_SYM(bl,BLOCK_NSYMS(bl)++) = g; - - SYMBOL_NAMESPACE(g) = LABEL_NAMESPACE; - SYMBOL_CLASS(g) = LOC_CONST; - SYMBOL_TYPE(g) = builtin_type_void; - gdbinfo = (struct mips_extra_func_info *) - xzalloc(sizeof(struct mips_extra_func_info)); - - SYMBOL_VALUE(g) = (long) gdbinfo; - - gdbinfo->numargs = nargs; - gdbinfo->framesize = framesize; - gdbinfo->framereg = 29; - gdbinfo->pcreg = 31; - gdbinfo->regmask = -2; - gdbinfo->regoffset = -4; - gdbinfo->fregmask = 0; /* XXX */ - gdbinfo->fregoffset = 0; /* XXX */ -} - -/* We just returned from the dummy code at END_PC, drop its symbol */ - -mips_destroy_dummy_symbol(end_pc) -{ - struct block *bl; - struct blockvector *bv = BLOCKVECTOR(dummy_symtab); - int i; - - bl = block_for_pc(end_pc); - free(BLOCK_FUNCTION(bl)); - free(SYMBOL_VALUE(BLOCK_SYM(bl,0))); - free(BLOCK_SYM(bl,0)); - - for (i = FIRST_LOCAL_BLOCK; i < BLOCKVECTOR_NBLOCKS(bv); i++) - if (BLOCKVECTOR_BLOCK(bv,i) == bl) - break; - for (; i < BLOCKVECTOR_NBLOCKS(bv) - 1; i++) - BLOCKVECTOR_BLOCK(bv,i) = BLOCKVECTOR_BLOCK(bv,i+1); - BLOCKVECTOR_NBLOCKS(bv)--; - sort_blocks(dummy_symtab); - free(bl); -} -#endif - -/* Sigtramp: make sure we have all the necessary information - about the signal trampoline code. Since the official code - from MIPS does not do so, we make up that information ourselves. - If they fix the library (unlikely) this code will neutralize itself. */ - -static -fixup_sigtramp() -{ - struct symbol *s; - struct symtab *st; - struct block *b, *b0; - - sigtramp_address = -1; - - /* We know it is sold as sigvec */ - s = lookup_symbol("sigvec", 0, VAR_NAMESPACE, 0, NULL); - - /* Most programs do not play with signals */ - if (s == 0) - return; - - b0 = SYMBOL_BLOCK_VALUE(s); - - /* A label of sigvec, to be more precise */ - s = lookup_symbol("sigtramp", b0, VAR_NAMESPACE, 0, NULL); - - /* But maybe this program uses its own version of sigvec */ - if (s == 0) - return; - - sigtramp_address = SYMBOL_VALUE(s); - sigtramp_end = sigtramp_address + 0x88; /* black magic */ - - /* Did we or MIPSco fix the library ? */ - if (SYMBOL_CLASS(s) == LOC_BLOCK) - return; - - /* But what symtab does it live in ? */ - st = find_pc_symtab(SYMBOL_VALUE(s)); - - /* - * Ok, there goes the fix: turn it into a procedure, with all the - * needed info. Note we make it a nested procedure of sigvec, - * which is the way the (assembly) code is actually written. - */ - SYMBOL_NAMESPACE(s) = VAR_NAMESPACE; - SYMBOL_CLASS(s) = LOC_BLOCK; - SYMBOL_TYPE(s) = make_type(TYPE_CODE_FUNC, 4, 0, 0); - TYPE_TARGET_TYPE(SYMBOL_TYPE(s)) = builtin_type_void; - - /* Need a block to allocate .gdbinfo. in */ - b = new_block(1); - SYMBOL_BLOCK_VALUE(s) = b; - BLOCK_START(b) = sigtramp_address; - BLOCK_END(b) = sigtramp_end; - BLOCK_FUNCTION(b) = s; - BLOCK_SUPERBLOCK(b) = BLOCK_SUPERBLOCK(b0); - add_block(b, st); - sort_blocks(st); - - /* Make a .gdbinfo. for it */ - { - struct mips_extra_func_info *e = - (struct mips_extra_func_info *) - xzalloc(sizeof(struct mips_extra_func_info)); - - e->numargs = 0; /* the kernel thinks otherwise */ - /* align_longword(sigcontext + SIGFRAME) */ - e->framesize = 0x150; - e->framereg = SP_REGNUM; - e->pcreg = 31; - e->regmask = -2; - e->regoffset = -(41 * sizeof(int)); - e->fregmask = -1; - e->fregoffset = -(37 * sizeof(int)); - e->isym = (long)s; - - s = new_symbol(".gdbinfo."); - SYMBOL_VALUE(s) = (int) e; - SYMBOL_NAMESPACE(s) = LABEL_NAMESPACE; - SYMBOL_CLASS(s) = LOC_CONST; - SYMBOL_TYPE(s) = builtin_type_void; - } - - BLOCK_SYM(b,BLOCK_NSYMS(b)++) = s; -} - -/* Initialization */ - -static struct sym_fns ecoff_sym_fns = {"ecoff", 5, - mipscoff_new_init, mipscoff_symfile_init, - mipscoff_symfile_read}; - -_initialize_mipsread () -{ - add_symtab_fns (&ecoff_sym_fns); - - /* Missing basic types */ - builtin_type_string = make_type(TYPE_CODE_PASCAL_ARRAY, - 1, 0, "string"); - builtin_type_complex = make_type(TYPE_CODE_FLT, - 2 * sizeof(float), 0, "complex"); - builtin_type_double_complex = make_type(TYPE_CODE_FLT, - 2 * sizeof(double), 0, "double_complex"); - builtin_type_fixed_dec = make_type(TYPE_CODE_INT, sizeof(int), - 0, "fixed_decimal"); - builtin_type_float_dec = make_type(TYPE_CODE_FLT, sizeof(double), - 0, "floating_decimal"); - - /* Templates types */ - builtin_type_struct = make_type(TYPE_CODE_STRUCT, 0, 0, 0); - builtin_type_union = make_type(TYPE_CODE_UNION, 0, 0, 0); - builtin_type_enum = make_type(TYPE_CODE_ENUM, 0, 0, 0); - builtin_type_range = make_type(TYPE_CODE_RANGE, 0, 0, 0); - builtin_type_set = make_type(TYPE_CODE_SET, 0, 0, 0); - - /* We can't do this now because builtin_type_void may not - be set yet. Do it at symbol reading time. */ - /* builtin_type_ptr = lookup_pointer_type (builtin_type_void); */ -} diff --git a/gdb/mtrace.awk b/gdb/mtrace.awk deleted file mode 100755 index d7689cec3ff..00000000000 --- a/gdb/mtrace.awk +++ /dev/null @@ -1,36 +0,0 @@ -# -# Awk program to analyze mtrace.c output. -# -$1 == "+" { if (allocated[$2] != "") - print "+", $2, "Alloc", NR, "duplicate:", allocated[$2]; - else - allocated[$2] = $3; - } -$1 == "-" { if (allocated[$2] != "") { - allocated[$2] = ""; - if (allocated[$2] != "") - print "DELETE FAILED", $2, allocated[$2]; - } else - print "-", $2, "Free", NR, "was never alloc'd"; - } -$1 == "<" { if (allocated[$2] != "") - allocated[$2] = ""; - else - print "-", $2, "Realloc", NR, "was never alloc'd"; - } -$1 == ">" { if (allocated[$2] != "") - print "+", $2, "Realloc", NR, "duplicate:", allocated[$2]; - else - allocated[$2] = $3; - } - -# Ignore "= Start" -$1 == "=" { } -# Ignore failed realloc attempts for now -$1 == "!" { } - - -END { for (x in allocated) - if (allocated[x] != "") - print "+", x, allocated[x]; - } diff --git a/gdb/mtrace.c b/gdb/mtrace.c deleted file mode 100755 index 82e7f03d41a..00000000000 --- a/gdb/mtrace.c +++ /dev/null @@ -1,146 +0,0 @@ -/* More debugging hooks for `malloc'. - Copyright 1991 Free Software Foundation - Written April 2, 1991 by John Gilmore of Cygnus Support - Based on mcheck.c by Mike Haertel. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "ansidecl.h" - -/* size_t may be defined in the system-supplied stdio.h. */ -/* So just kludge it. */ -#define size_t unsigned int -#define ptrdiff_t int -#define __ONEFILE - -/* We can't declare malloc and realloc here because we don't know - if they are char * or void *, and the compiler will give an error - if we get it wrong and they happen to be defined in some header - file e.g. . We can't include here because - it has some incompatability with our own includes, e.g. size_t or - whatever. So we just punt. This causes malloc and realloc to - default to returning "int", which works for most cases we care - about. FIXME-somehow. */ -/* #include */ -#include "gmalloc.h" - -extern char *getenv(); - -FILE *mallstream; -char mallenv[] = "MALLOC_TRACE"; -static char mallbuf[BUFSIZ]; /* Buffer for the output */ - -/* Address to breakpoint on accesses to... */ -PTR mallwatch; - -/* Old hook values. */ -static void EXFUN((*old_free_hook), (PTR ptr)); -static PTR EXFUN((*old_malloc_hook), (size_t size)); -static PTR EXFUN((*old_realloc_hook), (PTR ptr, size_t size)); - -/* This function is called when the block being alloc'd, realloc'd, or - freed has an address matching the variable "mallwatch". In a debugger, - set "mallwatch" to the address of interest, then put a breakpoint on - tr_break. */ - -void -tr_break() -{ - ; -} - -static void -DEFUN(tr_freehook, (ptr), PTR ptr) -{ - fprintf(mallstream, "- %08x\n", ptr); /* Be sure to print it first */ - if (ptr == mallwatch) - tr_break(); - __free_hook = old_free_hook; - free(ptr); - __free_hook = tr_freehook; -} - -static PTR -DEFUN(tr_mallochook, (size), size_t size) -{ - PTR hdr; - - __malloc_hook = old_malloc_hook; - hdr = (PTR) malloc(size); - __malloc_hook = tr_mallochook; - - /* We could be printing a NULL here; that's OK */ - fprintf (mallstream, "+ %08x %x\n", hdr, size); - - if (hdr == mallwatch) - tr_break(); - - return hdr; -} - -static PTR -DEFUN(tr_reallochook, (ptr, size), PTR ptr AND size_t size) -{ - PTR hdr; - - if (ptr == mallwatch) - tr_break(); - - __free_hook = old_free_hook; - __malloc_hook = old_malloc_hook; - __realloc_hook = old_realloc_hook; - hdr = (PTR) realloc(ptr, size); - __free_hook = tr_freehook; - __malloc_hook = tr_mallochook; - __realloc_hook = tr_reallochook; - if (hdr == NULL) { - fprintf (mallstream, "! %08x %x\n", ptr, size); /* Failed realloc */ - } else { - fprintf (mallstream, "< %08x\n> %08x %x\n", ptr, hdr, size); - } - - if (hdr == mallwatch) - tr_break(); - - return hdr; -} - -/* We enable tracing if either the environment variable MALLOC_TRACE - is set, or if the variable mallwatch has been patched to an address - that the debugging user wants us to stop on. When patching mallwatch, - don't forget to set a breakpoint on tr_break! */ - -void -mtrace() -{ - char *mallfile; - - mallfile = getenv (mallenv); - if (mallfile || mallwatch) { - mallstream = fopen (mallfile? mallfile: "/dev/null", "w"); - if (mallstream) { - /* Be sure it doesn't malloc its buffer! */ - setbuf (mallstream, mallbuf); - fprintf (mallstream, "= Start\n"); - old_free_hook = __free_hook; - __free_hook = tr_freehook; - old_malloc_hook = __malloc_hook; - __malloc_hook = tr_mallochook; - old_realloc_hook = __realloc_hook; - __realloc_hook = tr_reallochook; - } - } -} diff --git a/gdb/munch b/gdb/munch deleted file mode 100755 index 7b1202f32eb..00000000000 --- a/gdb/munch +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh - -# create an initialization procedure from a list of .o files - -echo '/* Do not modify this file. It is created automatically by "munch". */' -echo 'void initialize_all_files () {' - -NMOPT="" -case $1 in -MUNCH_NM=*) - MUNCH_NM=`echo $1 | sed 's/MUNCH_NM=//'`; shift ;; --*) - NMOPT=$1; shift ;; -esac - -# make it easy to use a different nm, e.g. for cross-developing - -MUNCH_NM="${MUNCH_NM-nm} $NMOPT" -if test "`$MUNCH_NM main.o | egrep main | egrep FUNC | egrep GLOB`" != "" ; then - # System V Release 4 style nm - $MUNCH_NM $* | egrep '|__?initialize_' | egrep FUNC | \ - sed -e 's/^.*\(_initialize_[a-zA-Z0-9_]*\).*$/ {extern void \1 (); \1 ();}/' -elif test "`$MUNCH_NM main.o | egrep 'T _?main$'`" = "" ; then - # System V style nm - shift; - $MUNCH_NM $* | egrep '^(.*[^a-zA-Z_]_|_)_?initialize_.*\.text' | \ - sed -e 's/^.*\(_initialize_[a-zA-Z0-9_]*\)[^a-zA-Z0-9_].*$/ {extern void \1 (); \1 ();}/' -else - # BSD style nm - # We now accept either text or data symbols, since the RT/PC uses data. - $MUNCH_NM -p $* | egrep '[TD] *_?_initialize_' | \ - sed -e 's/^.*[TD] *_*\(.*\)/ {extern void _\1 (); _\1 ();}/' -fi - -echo '}' diff --git a/gdb/news-xdep.c b/gdb/news-xdep.c deleted file mode 100644 index 6740b1b2138..00000000000 --- a/gdb/news-xdep.c +++ /dev/null @@ -1,65 +0,0 @@ -/* Low level interface to ptrace, for GDB when running under Unix. - Copyright (C) 1986, 1987, 1989 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifdef __GNUC__ -/* Bad implement execle(3). It's depend for "/bin/cc". - - main() - { - printf("execle:\n"); - execle(FILE, ARGS, envp); - exit(1); - } - - GCC: - link a6,#0 - pea LC5 ; call printf - jbsr _printf - ; ; (not popd stack) - pea _envp ; call execle - clrl sp@- - pea LC4 - pea LC4 - pea LC4 - pea LC3 - pea LC6 - jbsr _execle - addw #32,sp ; delayed pop !! - - /bin/cc: - link.l fp,#L23 - movem.l #L24,(sp) - pea L26 ; call printf - jbsr _printf - addq.l #4,sp ; <--- popd stack !! - pea _envp ; call execle - clr.l -(sp) - pea L32 - - */ - -execle(name, args) - char *name, *args; -{ - register char **env = &args; - while (*env++) - ; - execve(name, (char **)&args, (char **)*env); -} -#endif diff --git a/gdb/nindy-tdep.c b/gdb/nindy-tdep.c deleted file mode 100644 index 8f7083119cf..00000000000 --- a/gdb/nindy-tdep.c +++ /dev/null @@ -1,75 +0,0 @@ -/* Target-machine dependent code for the NINDY monitor running on the Intel 960 - Copyright (C) 1991 Free Software Foundation, Inc. - Contributed by Intel Corporation. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Miscellaneous NINDY-dependent routines. - Some replace macros normally defined in "tm.h". */ - -#include -#include "defs.h" -#include "param.h" -#include "symtab.h" -#include "frame.h" - -/* 'start_frame' is a variable in the NINDY runtime startup routine - that contains the frame pointer of the 'start' routine (the routine - that calls 'main'). By reading its contents out of remote memory, - we can tell where the frame chain ends: backtraces should halt before - they display this frame. */ - -int -nindy_frame_chain_valid (chain, curframe) - unsigned int chain; - FRAME curframe; -{ - struct symbol *sym; - int i; - - /* crtnindy.o is an assembler module that is assumed to be linked - * first in an i80960 executable. It contains the true entry point; - * it performs startup up initialization and then calls 'main'. - * - * 'sf' is the name of a variable in crtnindy.o that is set - * during startup to the address of the first frame. - * - * 'a' is the address of that variable in 80960 memory. - */ - static char sf[] = "start_frame"; - CORE_ADDR a; - - - chain &= ~0x3f; /* Zero low 6 bits because previous frame pointers - contain return status info in them. */ - if ( chain == 0 ){ - return 0; - } - - sym = lookup_symbol(sf, 0, VAR_NAMESPACE, (int *)NULL, - (struct symtab **)NULL); - if ( sym != 0 ){ - a = sym->value.value; - } else { - i = lookup_misc_func (sf); - if (i < 0) - return 0; - a = misc_function_vector[i].address; - } - - return ( chain != read_memory_integer(a,4) ); -} diff --git a/gdb/np1-opcode.h b/gdb/np1-opcode.h deleted file mode 100755 index 7e1001db8f2..00000000000 --- a/gdb/np1-opcode.h +++ /dev/null @@ -1,422 +0,0 @@ -/* Print GOULD NPL instructions for GDB, the GNU debugger. - Copyright (C) 1986, 1987, 1989 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -struct gld_opcode -{ - char *name; - unsigned long opcode; - unsigned long mask; - char *args; - int length; -}; - -/* We store four bytes of opcode for all opcodes because that - is the most any of them need. The actual length of an instruction - is always at least 2 bytes, and at most four. The length of the - instruction is based on the opcode. - - The mask component is a mask saying which bits must match - particular opcode in order for an instruction to be an instance - of that opcode. - - The args component is a string containing characters - that are used to format the arguments to the instruction. */ - -/* Kinds of operands: - r Register in first field - R Register in second field - b Base register in first field - B Base register in second field - v Vector register in first field - V Vector register in first field - A Optional address register (base register) - X Optional index register - I Immediate data (16bits signed) - O Offset field (16bits signed) - h Offset field (15bits signed) - d Offset field (14bits signed) - S Shift count field - - any other characters are printed as is... -*/ - -/* The assembler requires that this array be sorted as follows: - all instances of the same mnemonic must be consecutive. - All instances of the same mnemonic with the same number of operands - must be consecutive. - */ -struct gld_opcode gld_opcodes[] = -{ -{ "lb", 0xb4080000, 0xfc080000, "r,xOA,X", 4 }, -{ "lnb", 0xb8080000, 0xfc080000, "r,xOA,X", 4 }, -{ "lbs", 0xec080000, 0xfc080000, "r,xOA,X", 4 }, -{ "lh", 0xb4000001, 0xfc080001, "r,xOA,X", 4 }, -{ "lnh", 0xb8000001, 0xfc080001, "r,xOA,X", 4 }, -{ "lw", 0xb4000000, 0xfc080000, "r,xOA,X", 4 }, -{ "lnw", 0xb8000000, 0xfc080000, "r,xOA,X", 4 }, -{ "ld", 0xb4000002, 0xfc080002, "r,xOA,X", 4 }, -{ "lnd", 0xb8000002, 0xfc080002, "r,xOA,X", 4 }, -{ "li", 0xf8000000, 0xfc7f0000, "r,I", 4 }, -{ "lpa", 0x50080000, 0xfc080000, "r,xOA,X", 4 }, -{ "la", 0x50000000, 0xfc080000, "r,xOA,X", 4 }, -{ "labr", 0x58080000, 0xfc080000, "b,xOA,X", 4 }, -{ "lbp", 0x90080000, 0xfc080000, "r,xOA,X", 4 }, -{ "lhp", 0x90000001, 0xfc080001, "r,xOA,X", 4 }, -{ "lwp", 0x90000000, 0xfc080000, "r,xOA,X", 4 }, -{ "ldp", 0x90000002, 0xfc080002, "r,xOA,X", 4 }, -{ "suabr", 0x58000000, 0xfc080000, "b,xOA,X", 4 }, -{ "lf", 0xbc000000, 0xfc080000, "r,xOA,X", 4 }, -{ "lfbr", 0xbc080000, 0xfc080000, "b,xOA,X", 4 }, -{ "lwbr", 0x5c000000, 0xfc080000, "b,xOA,X", 4 }, -{ "stb", 0xd4080000, 0xfc080000, "r,xOA,X", 4 }, -{ "sth", 0xd4000001, 0xfc080001, "r,xOA,X", 4 }, -{ "stw", 0xd4000000, 0xfc080000, "r,xOA,X", 4 }, -{ "std", 0xd4000002, 0xfc080002, "r,xOA,X", 4 }, -{ "stf", 0xdc000000, 0xfc080000, "r,xOA,X", 4 }, -{ "stfbr", 0xdc080000, 0xfc080000, "b,xOA,X", 4 }, -{ "stwbr", 0x54000000, 0xfc080000, "b,xOA,X", 4 }, -{ "zmb", 0xd8080000, 0xfc080000, "r,xOA,X", 4 }, -{ "zmh", 0xd8000001, 0xfc080001, "r,xOA,X", 4 }, -{ "zmw", 0xd8000000, 0xfc080000, "r,xOA,X", 4 }, -{ "zmd", 0xd8000002, 0xfc080002, "r,xOA,X", 4 }, -{ "stbp", 0x94080000, 0xfc080000, "r,xOA,X", 4 }, -{ "sthp", 0x94000001, 0xfc080001, "r,xOA,X", 4 }, -{ "stwp", 0x94000000, 0xfc080000, "r,xOA,X", 4 }, -{ "stdp", 0x94000002, 0xfc080002, "r,xOA,X", 4 }, -{ "lil", 0xf80b0000, 0xfc7f0000, "r,D", 4 }, -{ "lwsl1", 0xec000000, 0xfc080000, "r,xOA,X", 4 }, -{ "lwsl2", 0xfc000000, 0xfc080000, "r,xOA,X", 4 }, -{ "lwsl3", 0xfc080000, 0xfc080000, "r,xOA,X", 4 }, - -{ "lvb", 0xb0080000, 0xfc080000, "v,xOA,X", 4 }, -{ "lvh", 0xb0000001, 0xfc080001, "v,xOA,X", 4 }, -{ "lvw", 0xb0000000, 0xfc080000, "v,xOA,X", 4 }, -{ "lvd", 0xb0000002, 0xfc080002, "v,xOA,X", 4 }, -{ "liv", 0x3c040000, 0xfc0f0000, "v,R", 2 }, -{ "livf", 0x3c080000, 0xfc0f0000, "v,R", 2 }, -{ "stvb", 0xd0080000, 0xfc080000, "v,xOA,X", 4 }, -{ "stvh", 0xd0000001, 0xfc080001, "v,xOA,X", 4 }, -{ "stvw", 0xd0000000, 0xfc080000, "v,xOA,X", 4 }, -{ "stvd", 0xd0000002, 0xfc080002, "v,xOA,X", 4 }, - -{ "trr", 0x2c000000, 0xfc0f0000, "r,R", 2 }, -{ "trn", 0x2c040000, 0xfc0f0000, "r,R", 2 }, -{ "trnd", 0x2c0c0000, 0xfc0f0000, "r,R", 2 }, -{ "trabs", 0x2c010000, 0xfc0f0000, "r,R", 2 }, -{ "trabsd", 0x2c090000, 0xfc0f0000, "r,R", 2 }, -{ "trc", 0x2c030000, 0xfc0f0000, "r,R", 2 }, -{ "xcr", 0x28040000, 0xfc0f0000, "r,R", 2 }, -{ "cxcr", 0x2c060000, 0xfc0f0000, "r,R", 2 }, -{ "cxcrd", 0x2c0e0000, 0xfc0f0000, "r,R", 2 }, -{ "tbrr", 0x2c020000, 0xfc0f0000, "r,B", 2 }, -{ "trbr", 0x28030000, 0xfc0f0000, "b,R", 2 }, -{ "xcbr", 0x28020000, 0xfc0f0000, "b,B", 2 }, -{ "tbrbr", 0x28010000, 0xfc0f0000, "b,B", 2 }, - -{ "trvv", 0x28050000, 0xfc0f0000, "v,V", 2 }, -{ "trvvn", 0x2c050000, 0xfc0f0000, "v,V", 2 }, -{ "trvvnd", 0x2c0d0000, 0xfc0f0000, "v,V", 2 }, -{ "trvab", 0x2c070000, 0xfc0f0000, "v,V", 2 }, -{ "trvabd", 0x2c0f0000, 0xfc0f0000, "v,V", 2 }, -{ "cmpv", 0x14060000, 0xfc0f0000, "v,V", 2 }, -{ "expv", 0x14070000, 0xfc0f0000, "v,V", 2 }, -{ "mrvvlt", 0x10030000, 0xfc0f0000, "v,V", 2 }, -{ "mrvvle", 0x10040000, 0xfc0f0000, "v,V", 2 }, -{ "mrvvgt", 0x14030000, 0xfc0f0000, "v,V", 2 }, -{ "mrvvge", 0x14040000, 0xfc0f0000, "v,V", 2 }, -{ "mrvveq", 0x10050000, 0xfc0f0000, "v,V", 2 }, -{ "mrvvne", 0x10050000, 0xfc0f0000, "v,V", 2 }, -{ "mrvrlt", 0x100d0000, 0xfc0f0000, "v,R", 2 }, -{ "mrvrle", 0x100e0000, 0xfc0f0000, "v,R", 2 }, -{ "mrvrgt", 0x140d0000, 0xfc0f0000, "v,R", 2 }, -{ "mrvrge", 0x140e0000, 0xfc0f0000, "v,R", 2 }, -{ "mrvreq", 0x100f0000, 0xfc0f0000, "v,R", 2 }, -{ "mrvrne", 0x140f0000, 0xfc0f0000, "v,R", 2 }, -{ "trvr", 0x140b0000, 0xfc0f0000, "r,V", 2 }, -{ "trrv", 0x140c0000, 0xfc0f0000, "v,R", 2 }, - -{ "bu", 0x40000000, 0xff880000, "xOA,X", 4 }, -{ "bns", 0x70080000, 0xff880000, "xOA,X", 4 }, -{ "bnco", 0x70880000, 0xff880000, "xOA,X", 4 }, -{ "bge", 0x71080000, 0xff880000, "xOA,X", 4 }, -{ "bne", 0x71880000, 0xff880000, "xOA,X", 4 }, -{ "bunge", 0x72080000, 0xff880000, "xOA,X", 4 }, -{ "bunle", 0x72880000, 0xff880000, "xOA,X", 4 }, -{ "bgt", 0x73080000, 0xff880000, "xOA,X", 4 }, -{ "bnany", 0x73880000, 0xff880000, "xOA,X", 4 }, -{ "bs" , 0x70000000, 0xff880000, "xOA,X", 4 }, -{ "bco", 0x70800000, 0xff880000, "xOA,X", 4 }, -{ "blt", 0x71000000, 0xff880000, "xOA,X", 4 }, -{ "beq", 0x71800000, 0xff880000, "xOA,X", 4 }, -{ "buge", 0x72000000, 0xff880000, "xOA,X", 4 }, -{ "bult", 0x72800000, 0xff880000, "xOA,X", 4 }, -{ "ble", 0x73000000, 0xff880000, "xOA,X", 4 }, -{ "bany", 0x73800000, 0xff880000, "xOA,X", 4 }, -{ "brlnk", 0x44000000, 0xfc080000, "r,xOA,X", 4 }, -{ "bib", 0x48000000, 0xfc080000, "r,xOA,X", 4 }, -{ "bih", 0x48080000, 0xfc080000, "r,xOA,X", 4 }, -{ "biw", 0x4c000000, 0xfc080000, "r,xOA,X", 4 }, -{ "bid", 0x4c080000, 0xfc080000, "r,xOA,X", 4 }, -{ "bivb", 0x60000000, 0xfc080000, "r,xOA,X", 4 }, -{ "bivh", 0x60080000, 0xfc080000, "r,xOA,X", 4 }, -{ "bivw", 0x64000000, 0xfc080000, "r,xOA,X", 4 }, -{ "bivd", 0x64080000, 0xfc080000, "r,xOA,X", 4 }, -{ "bvsb", 0x68000000, 0xfc080000, "r,xOA,X", 4 }, -{ "bvsh", 0x68080000, 0xfc080000, "r,xOA,X", 4 }, -{ "bvsw", 0x6c000000, 0xfc080000, "r,xOA,X", 4 }, -{ "bvsd", 0x6c080000, 0xfc080000, "r,xOA,X", 4 }, - -{ "camb", 0x80080000, 0xfc080000, "r,xOA,X", 4 }, -{ "camh", 0x80000001, 0xfc080001, "r,xOA,X", 4 }, -{ "camw", 0x80000000, 0xfc080000, "r,xOA,X", 4 }, -{ "camd", 0x80000002, 0xfc080002, "r,xOA,X", 4 }, -{ "car", 0x10000000, 0xfc0f0000, "r,R", 2 }, -{ "card", 0x14000000, 0xfc0f0000, "r,R", 2 }, -{ "ci", 0xf8050000, 0xfc7f0000, "r,I", 4 }, -{ "chkbnd", 0x5c080000, 0xfc080000, "r,xOA,X", 4 }, - -{ "cavv", 0x10010000, 0xfc0f0000, "v,V", 2 }, -{ "cavr", 0x10020000, 0xfc0f0000, "v,R", 2 }, -{ "cavvd", 0x10090000, 0xfc0f0000, "v,V", 2 }, -{ "cavrd", 0x100b0000, 0xfc0f0000, "v,R", 2 }, - -{ "anmb", 0x84080000, 0xfc080000, "r,xOA,X", 4 }, -{ "anmh", 0x84000001, 0xfc080001, "r,xOA,X", 4 }, -{ "anmw", 0x84000000, 0xfc080000, "r,xOA,X", 4 }, -{ "anmd", 0x84000002, 0xfc080002, "r,xOA,X", 4 }, -{ "anr", 0x04000000, 0xfc0f0000, "r,R", 2 }, -{ "ani", 0xf8080000, 0xfc7f0000, "r,I", 4 }, -{ "ormb", 0xb8080000, 0xfc080000, "r,xOA,X", 4 }, -{ "ormh", 0xb8000001, 0xfc080001, "r,xOA,X", 4 }, -{ "ormw", 0xb8000000, 0xfc080000, "r,xOA,X", 4 }, -{ "ormd", 0xb8000002, 0xfc080002, "r,xOA,X", 4 }, -{ "orr", 0x08000000, 0xfc0f0000, "r,R", 2 }, -{ "oi", 0xf8090000, 0xfc7f0000, "r,I", 4 }, -{ "eomb", 0x8c080000, 0xfc080000, "r,xOA,X", 4 }, -{ "eomh", 0x8c000001, 0xfc080001, "r,xOA,X", 4 }, -{ "eomw", 0x8c000000, 0xfc080000, "r,xOA,X", 4 }, -{ "eomd", 0x8c000002, 0xfc080002, "r,xOA,X", 4 }, -{ "eor", 0x0c000000, 0xfc0f0000, "r,R", 2 }, -{ "eoi", 0xf80a0000, 0xfc7f0000, "r,I", 4 }, - -{ "anvv", 0x04010000, 0xfc0f0000, "v,V", 2 }, -{ "anvr", 0x04020000, 0xfc0f0000, "v,R", 2 }, -{ "orvv", 0x08010000, 0xfc0f0000, "v,V", 2 }, -{ "orvr", 0x08020000, 0xfc0f0000, "v,R", 2 }, -{ "eovv", 0x0c010000, 0xfc0f0000, "v,V", 2 }, -{ "eovr", 0x0c020000, 0xfc0f0000, "v,R", 2 }, - -{ "sacz", 0x100c0000, 0xfc0f0000, "r,R", 2 }, -{ "sla", 0x1c400000, 0xfc600000, "r,S", 2 }, -{ "sll", 0x1c600000, 0xfc600000, "r,S", 2 }, -{ "slc", 0x24400000, 0xfc600000, "r,S", 2 }, -{ "slad", 0x20400000, 0xfc600000, "r,S", 2 }, -{ "slld", 0x20600000, 0xfc600000, "r,S", 2 }, -{ "sra", 0x1c000000, 0xfc600000, "r,S", 2 }, -{ "srl", 0x1c200000, 0xfc600000, "r,S", 2 }, -{ "src", 0x24000000, 0xfc600000, "r,S", 2 }, -{ "srad", 0x20000000, 0xfc600000, "r,S", 2 }, -{ "srld", 0x20200000, 0xfc600000, "r,S", 2 }, -{ "sda", 0x3c030000, 0xfc0f0000, "r,R", 2 }, -{ "sdl", 0x3c020000, 0xfc0f0000, "r,R", 2 }, -{ "sdc", 0x3c010000, 0xfc0f0000, "r,R", 2 }, -{ "sdad", 0x3c0b0000, 0xfc0f0000, "r,R", 2 }, -{ "sdld", 0x3c0a0000, 0xfc0f0000, "r,R", 2 }, - -{ "svda", 0x3c070000, 0xfc0f0000, "v,R", 2 }, -{ "svdl", 0x3c060000, 0xfc0f0000, "v,R", 2 }, -{ "svdc", 0x3c050000, 0xfc0f0000, "v,R", 2 }, -{ "svdad", 0x3c0e0000, 0xfc0f0000, "v,R", 2 }, -{ "svdld", 0x3c0d0000, 0xfc0f0000, "v,R", 2 }, - -{ "sbm", 0xac080000, 0xfc080000, "f,xOA,X", 4 }, -{ "zbm", 0xac000000, 0xfc080000, "f,xOA,X", 4 }, -{ "tbm", 0xa8080000, 0xfc080000, "f,xOA,X", 4 }, -{ "incmb", 0xa0000000, 0xfc080000, "xOA,X", 4 }, -{ "incmh", 0xa0080000, 0xfc080000, "xOA,X", 4 }, -{ "incmw", 0xa4000000, 0xfc080000, "xOA,X", 4 }, -{ "incmd", 0xa4080000, 0xfc080000, "xOA,X", 4 }, -{ "sbmd", 0x7c080000, 0xfc080000, "r,xOA,X", 4 }, -{ "zbmd", 0x7c000000, 0xfc080000, "r,xOA,X", 4 }, -{ "tbmd", 0x78080000, 0xfc080000, "r,xOA,X", 4 }, - -{ "ssm", 0x9c080000, 0xfc080000, "f,xOA,X", 4 }, -{ "zsm", 0x9c000000, 0xfc080000, "f,xOA,X", 4 }, -{ "tsm", 0x98080000, 0xfc080000, "f,xOA,X", 4 }, - -{ "admb", 0xc8080000, 0xfc080000, "r,xOA,X", 4 }, -{ "admh", 0xc8000001, 0xfc080001, "r,xOA,X", 4 }, -{ "admw", 0xc8000000, 0xfc080000, "r,xOA,X", 4 }, -{ "admd", 0xc8000002, 0xfc080002, "r,xOA,X", 4 }, -{ "adr", 0x38000000, 0xfc0f0000, "r,R", 2 }, -{ "armb", 0xe8080000, 0xfc080000, "r,xOA,X", 4 }, -{ "armh", 0xe8000001, 0xfc080001, "r,xOA,X", 4 }, -{ "armw", 0xe8000000, 0xfc080000, "r,xOA,X", 4 }, -{ "armd", 0xe8000002, 0xfc080002, "r,xOA,X", 4 }, -{ "adi", 0xf8010000, 0xfc0f0000, "r,I", 4 }, -{ "sumb", 0xcc080000, 0xfc080000, "r,xOA,X", 4 }, -{ "sumh", 0xcc000001, 0xfc080001, "r,xOA,X", 4 }, -{ "sumw", 0xcc000000, 0xfc080000, "r,xOA,X", 4 }, -{ "sumd", 0xcc000002, 0xfc080002, "r,xOA,X", 4 }, -{ "sur", 0x3c000000, 0xfc0f0000, "r,R", 2 }, -{ "sui", 0xf8020000, 0xfc0f0000, "r,I", 4 }, -{ "mpmb", 0xc0080000, 0xfc080000, "r,xOA,X", 4 }, -{ "mpmh", 0xc0000001, 0xfc080001, "r,xOA,X", 4 }, -{ "mpmw", 0xc0000000, 0xfc080000, "r,xOA,X", 4 }, -{ "mpr", 0x38020000, 0xfc0f0000, "r,R", 2 }, -{ "mprd", 0x3c0f0000, 0xfc0f0000, "r,R", 2 }, -{ "mpi", 0xf8030000, 0xfc0f0000, "r,I", 4 }, -{ "dvmb", 0xc4080000, 0xfc080000, "r,xOA,X", 4 }, -{ "dvmh", 0xc4000001, 0xfc080001, "r,xOA,X", 4 }, -{ "dvmw", 0xc4000000, 0xfc080000, "r,xOA,X", 4 }, -{ "dvr", 0x380a0000, 0xfc0f0000, "r,R", 2 }, -{ "dvi", 0xf8040000, 0xfc0f0000, "r,I", 4 }, -{ "exs", 0x38080000, 0xfc0f0000, "r,R", 2 }, - -{ "advv", 0x30000000, 0xfc0f0000, "v,V", 2 }, -{ "advvd", 0x30080000, 0xfc0f0000, "v,V", 2 }, -{ "adrv", 0x34000000, 0xfc0f0000, "v,R", 2 }, -{ "adrvd", 0x34080000, 0xfc0f0000, "v,R", 2 }, -{ "suvv", 0x30010000, 0xfc0f0000, "v,V", 2 }, -{ "suvvd", 0x30090000, 0xfc0f0000, "v,V", 2 }, -{ "surv", 0x34010000, 0xfc0f0000, "v,R", 2 }, -{ "survd", 0x34090000, 0xfc0f0000, "v,R", 2 }, -{ "mpvv", 0x30020000, 0xfc0f0000, "v,V", 2 }, -{ "mprv", 0x34020000, 0xfc0f0000, "v,R", 2 }, - -{ "adfw", 0xe0080000, 0xfc080000, "r,xOA,X", 4 }, -{ "adfd", 0xe0080002, 0xfc080002, "r,xOA,X", 4 }, -{ "adrfw", 0x38010000, 0xfc0f0000, "r,R", 2 }, -{ "adrfd", 0x38090000, 0xfc0f0000, "r,R", 2 }, -{ "surfw", 0xe0000000, 0xfc080000, "r,xOA,X", 4 }, -{ "surfd", 0xe0000002, 0xfc080002, "r,xOA,X", 4 }, -{ "surfw", 0x38030000, 0xfc0f0000, "r,R", 2 }, -{ "surfd", 0x380b0000, 0xfc0f0000, "r,R", 2 }, -{ "mpfw", 0xe4080000, 0xfc080000, "r,xOA,X", 4 }, -{ "mpfd", 0xe4080002, 0xfc080002, "r,xOA,X", 4 }, -{ "mprfw", 0x38060000, 0xfc0f0000, "r,R", 2 }, -{ "mprfd", 0x380e0000, 0xfc0f0000, "r,R", 2 }, -{ "rfw", 0xe4000000, 0xfc080000, "r,xOA,X", 4 }, -{ "rfd", 0xe4000002, 0xfc080002, "r,xOA,X", 4 }, -{ "rrfw", 0x0c0e0000, 0xfc0f0000, "r", 2 }, -{ "rrfd", 0x0c0f0000, 0xfc0f0000, "r", 2 }, - -{ "advvfw", 0x30040000, 0xfc0f0000, "v,V", 2 }, -{ "advvfd", 0x300c0000, 0xfc0f0000, "v,V", 2 }, -{ "adrvfw", 0x34040000, 0xfc0f0000, "v,R", 2 }, -{ "adrvfd", 0x340c0000, 0xfc0f0000, "v,R", 2 }, -{ "suvvfw", 0x30050000, 0xfc0f0000, "v,V", 2 }, -{ "suvvfd", 0x300d0000, 0xfc0f0000, "v,V", 2 }, -{ "survfw", 0x34050000, 0xfc0f0000, "v,R", 2 }, -{ "survfd", 0x340d0000, 0xfc0f0000, "v,R", 2 }, -{ "mpvvfw", 0x30060000, 0xfc0f0000, "v,V", 2 }, -{ "mpvvfd", 0x300e0000, 0xfc0f0000, "v,V", 2 }, -{ "mprvfw", 0x34060000, 0xfc0f0000, "v,R", 2 }, -{ "mprvfd", 0x340e0000, 0xfc0f0000, "v,R", 2 }, -{ "rvfw", 0x30070000, 0xfc0f0000, "v", 2 }, -{ "rvfd", 0x300f0000, 0xfc0f0000, "v", 2 }, - -{ "fltw", 0x38070000, 0xfc0f0000, "r,R", 2 }, -{ "fltd", 0x380f0000, 0xfc0f0000, "r,R", 2 }, -{ "fixw", 0x38050000, 0xfc0f0000, "r,R", 2 }, -{ "fixd", 0x380d0000, 0xfc0f0000, "r,R", 2 }, -{ "cfpds", 0x3c090000, 0xfc0f0000, "r,R", 2 }, - -{ "fltvw", 0x080d0000, 0xfc0f0000, "v,V", 2 }, -{ "fltvd", 0x080f0000, 0xfc0f0000, "v,V", 2 }, -{ "fixvw", 0x080c0000, 0xfc0f0000, "v,V", 2 }, -{ "fixvd", 0x080e0000, 0xfc0f0000, "v,V", 2 }, -{ "cfpvds", 0x0c0d0000, 0xfc0f0000, "v,V", 2 }, - -{ "orvrn", 0x000a0000, 0xfc0f0000, "r,V", 2 }, -{ "andvrn", 0x00080000, 0xfc0f0000, "r,V", 2 }, -{ "frsteq", 0x04090000, 0xfc0f0000, "r,V", 2 }, -{ "sigma", 0x0c080000, 0xfc0f0000, "r,V", 2 }, -{ "sigmad", 0x0c0a0000, 0xfc0f0000, "r,V", 2 }, -{ "sigmf", 0x08080000, 0xfc0f0000, "r,V", 2 }, -{ "sigmfd", 0x080a0000, 0xfc0f0000, "r,V", 2 }, -{ "prodf", 0x04080000, 0xfc0f0000, "r,V", 2 }, -{ "prodfd", 0x040a0000, 0xfc0f0000, "r,V", 2 }, -{ "maxv", 0x10080000, 0xfc0f0000, "r,V", 2 }, -{ "maxvd", 0x100a0000, 0xfc0f0000, "r,V", 2 }, -{ "minv", 0x14080000, 0xfc0f0000, "r,V", 2 }, -{ "minvd", 0x140a0000, 0xfc0f0000, "r,V", 2 }, - -{ "lpsd", 0xf0000000, 0xfc080000, "xOA,X", 4 }, -{ "ldc", 0xf0080000, 0xfc080000, "xOA,X", 4 }, -{ "spm", 0x040c0000, 0xfc0f0000, "r", 2 }, -{ "rpm", 0x040d0000, 0xfc0f0000, "r", 2 }, -{ "tritr", 0x00070000, 0xfc0f0000, "r", 2 }, -{ "trrit", 0x00060000, 0xfc0f0000, "r", 2 }, -{ "rpswt", 0x04080000, 0xfc0f0000, "r", 2 }, -{ "exr", 0xf8070000, 0xfc0f0000, "", 4 }, -{ "halt", 0x00000000, 0xfc0f0000, "", 2 }, -{ "wait", 0x00010000, 0xfc0f0000, "", 2 }, -{ "nop", 0x00020000, 0xfc0f0000, "", 2 }, -{ "eiae", 0x00030000, 0xfc0f0000, "", 2 }, -{ "efae", 0x000d0000, 0xfc0f0000, "", 2 }, -{ "diae", 0x000e0000, 0xfc0f0000, "", 2 }, -{ "dfae", 0x000f0000, 0xfc0f0000, "", 2 }, -{ "spvc", 0xf8060000, 0xfc0f0000, "r,T,N", 4 }, -{ "rdsts", 0x00090000, 0xfc0f0000, "r", 2 }, -{ "setcpu", 0x000c0000, 0xfc0f0000, "r", 2 }, -{ "cmc", 0x000b0000, 0xfc0f0000, "r", 2 }, -{ "trrcu", 0x00040000, 0xfc0f0000, "r", 2 }, -{ "attnio", 0x00050000, 0xfc0f0000, "", 2 }, -{ "fudit", 0x28080000, 0xfc0f0000, "", 2 }, -{ "break", 0x28090000, 0xfc0f0000, "", 2 }, -{ "frzss", 0x280a0000, 0xfc0f0000, "", 2 }, -{ "ripi", 0x04040000, 0xfc0f0000, "r,R", 2 }, -{ "xcp", 0x04050000, 0xfc0f0000, "r", 2 }, -{ "block", 0x04060000, 0xfc0f0000, "", 2 }, -{ "unblock", 0x04070000, 0xfc0f0000, "", 2 }, -{ "trsc", 0x08060000, 0xfc0f0000, "r,R", 2 }, -{ "tscr", 0x08070000, 0xfc0f0000, "r,R", 2 }, -{ "fq", 0x04080000, 0xfc0f0000, "r", 2 }, -{ "flupte", 0x2c080000, 0xfc0f0000, "r", 2 }, -{ "rviu", 0x040f0000, 0xfc0f0000, "", 2 }, -{ "ldel", 0x280c0000, 0xfc0f0000, "r,R", 2 }, -{ "ldu", 0x280d0000, 0xfc0f0000, "r,R", 2 }, -{ "stdecc", 0x280b0000, 0xfc0f0000, "r,R", 2 }, -{ "trpc", 0x08040000, 0xfc0f0000, "r", 2 }, -{ "tpcr", 0x08050000, 0xfc0f0000, "r", 2 }, -{ "ghalt", 0x0c050000, 0xfc0f0000, "r", 2 }, -{ "grun", 0x0c040000, 0xfc0f0000, "", 2 }, -{ "tmpr", 0x2c0a0000, 0xfc0f0000, "r,R", 2 }, -{ "trmp", 0x2c0b0000, 0xfc0f0000, "r,R", 2 }, - -{ "trrve", 0x28060000, 0xfc0f0000, "r", 2 }, -{ "trver", 0x28070000, 0xfc0f0000, "r", 2 }, -{ "trvlr", 0x280f0000, 0xfc0f0000, "r", 2 }, - -{ "linkfl", 0x18000000, 0xfc0f0000, "r,R", 2 }, -{ "linkbl", 0x18020000, 0xfc0f0000, "r,R", 2 }, -{ "linkfp", 0x18010000, 0xfc0f0000, "r,R", 2 }, -{ "linkbp", 0x18030000, 0xfc0f0000, "r,R", 2 }, -{ "linkpl", 0x18040000, 0xfc0f0000, "r,R", 2 }, -{ "ulinkl", 0x18080000, 0xfc0f0000, "r,R", 2 }, -{ "ulinkp", 0x18090000, 0xfc0f0000, "r,R", 2 }, -{ "ulinktl", 0x180a0000, 0xfc0f0000, "r,R", 2 }, -{ "ulinktp", 0x180b0000, 0xfc0f0000, "r,R", 2 }, -}; - -int numopcodes = sizeof(gld_opcodes) / sizeof(gld_opcodes[0]); - -struct gld_opcode *endop = gld_opcodes + sizeof(gld_opcodes) / - sizeof(gld_opcodes[0]); diff --git a/gdb/ns32k-opcode.h b/gdb/ns32k-opcode.h deleted file mode 100644 index c41ff414b7f..00000000000 --- a/gdb/ns32k-opcode.h +++ /dev/null @@ -1,328 +0,0 @@ -/* ns32k-opcode.h */ - -#ifndef ns32k_opcodeT -#define ns32k_opcodeT int -#endif /* no ns32k_opcodeT */ - -struct not_wot /* ns32k opcode table: wot to do with this */ - /* particular opcode */ -{ - int obits; /* number of opcode bits */ - int ibits; /* number of instruction bits */ - ns32k_opcodeT code; /* op-code (may be > 8 bits!) */ - char *args; /* how to compile said opcode */ -}; - -struct not /* ns32k opcode text */ -{ - char * name; /* opcode name: lowercase string [key] */ - struct not_wot detail; /* rest of opcode table [datum] */ -}; - -/* Instructions look like this: - - basic instruction--1, 2, or 3 bytes - index byte for operand A, if operand A is indexed--1 byte - index byte for operand B, if operand B is indexed--1 byte - addressing extension for operand A - addressing extension for operand B - implied operands - - Operand A is the operand listed first in the following opcode table. - Operand B is the operand listed second in the following opcode table. - All instructions have at most 2 general operands, so this is enough. - The implied operands are associated with operands other than A and B. - - Each operand has a digit and a letter. - - The digit gives the position in the assembly language. The letter, - one of the following, tells us what kind of operand it is. */ - -/* F : 32 bit float - * L : 64 bit float - * B : byte - * W : word - * D : double-word - * Q : quad-word - * d : displacement - * q : quick - * i : immediate (8 bits) - * r : register number (3 bits) - * p : displacement - pc relative addressing -*/ -static struct not -notstrs[] = -{ - { "absf", 14,24, 0x35be, "1F2F" }, - { "absl", 14,24, 0x34be, "1L2L" }, - { "absb", 14,24, 0x304e, "1B2B" }, - { "absw", 14,24, 0x314e, "1W2W" }, - { "absd", 14,24, 0x334e, "1D2D" }, - { "acbb", 7,16, 0x4c, "2B1q3p" }, - { "acbw", 7,16, 0x4d, "2W1q3p" }, - { "acbd", 7,16, 0x4f, "2D1q3p" }, - { "addf", 14,24, 0x01be, "1F2F" }, - { "addl", 14,24, 0x00be, "1L2L" }, - { "addb", 6,16, 0x00, "1B2B" }, - { "addw", 6,16, 0x01, "1W2W" }, - { "addd", 6,16, 0x03, "1D2D" }, - { "addcb", 6,16, 0x10, "1B2B" }, - { "addcw", 6,16, 0x11, "1W2W" }, - { "addcd", 6,16, 0x13, "1D2D" }, - { "addpb", 14,24, 0x3c4e, "1B2B" }, - { "addpw", 14,24, 0x3d4e, "1W2W" }, - { "addpd", 14,24, 0x3f4e, "1D2D" }, - { "addqb", 7,16, 0x0c, "2B1q" }, - { "addqw", 7,16, 0x0d, "2W1q" }, - { "addqd", 7,16, 0x0f, "2D1q" }, - { "addr", 6,16, 0x27, "1D2D" }, - { "adjspb", 11,16, 0x057c, "1B" }, - { "adjspw", 11,16, 0x057d, "1W" }, - { "adjspd", 11,16, 0x057f, "1D" }, - { "andb", 6,16, 0x28, "1B2B" }, - { "andw", 6,16, 0x29, "1W2W" }, - { "andd", 6,16, 0x2b, "1D2D" }, - { "ashb", 14,24, 0x044e, "1B2B" }, - { "ashw", 14,24, 0x054e, "1B2W" }, - { "ashd", 14,24, 0x074e, "1B2D" }, - { "beq", 8,8, 0x0a, "1p" }, - { "bne", 8,8, 0x1a, "1p" }, - { "bcs", 8,8, 0x2a, "1p" }, - { "bcc", 8,8, 0x3a, "1p" }, - { "bhi", 8,8, 0x4a, "1p" }, - { "bls", 8,8, 0x5a, "1p" }, - { "bgt", 8,8, 0x6a, "1p" }, - { "ble", 8,8, 0x7a, "1p" }, - { "bfs", 8,8, 0x8a, "1p" }, - { "bfc", 8,8, 0x9a, "1p" }, - { "blo", 8,8, 0xaa, "1p" }, - { "bhs", 8,8, 0xba, "1p" }, - { "blt", 8,8, 0xca, "1p" }, - { "bge", 8,8, 0xda, "1p" }, - { "bicb", 6,16, 0x08, "1B2B" }, - { "bicw", 6,16, 0x09, "1W2W" }, - { "bicd", 6,16, 0x0b, "1D2D" }, - { "bicpsrb", 11,16, 0x17c, "1B" }, - { "bicpsrw", 11,16, 0x17d, "1W" }, - { "bispsrb", 11,16, 0x37c, "1B" }, - { "bispsrw", 11,16, 0x37d, "1W" }, - { "bpt", 8,8, 0xf2, "" }, - { "br", 8,8, 0xea, "1p" }, - { "bsr", 8,8, 0x02, "1p" }, - { "caseb", 11,16, 0x77c, "1B" }, - { "casew", 11,16, 0x77d, "1W" }, - { "cased", 11,16, 0x77f, "1D" }, - { "cbitb", 14,24, 0x084e, "1B2D" }, - { "cbitw", 14,24, 0x094e, "1W2D" }, - { "cbitd", 14,24, 0x0b4e, "1D2D" }, - { "cbitib", 14,24, 0x0c4e, "1B2D" }, - { "cbitiw", 14,24, 0x0d4e, "1W2D" }, - { "cbitid", 14,24, 0x0f4e, "1D2D" }, - { "checkb", 11,24, 0x0ee, "2A3B1r" }, - { "checkw", 11,24, 0x1ee, "2A3B1r" }, - { "checkd", 11,24, 0x3ee, "2A3D1r" }, - { "cmpf", 14,24, 0x09be, "1F2F" }, - { "cmpl", 14,24, 0x08be, "1L2L" }, - { "cmpb", 6,16, 0x04, "1B2B" }, - { "cmpw", 6,16, 0x05, "1W2W" }, - { "cmpd", 6,16, 0x07, "1D2D" }, - { "cmpmb", 14,24, 0x04ce, "1D2D3d" }, - { "cmpmw", 14,24, 0x05ce, "1D2D3d" }, - { "cmpmd", 14,24, 0x07ce, "1D2D3d" }, - { "cmpqb", 7,16, 0x1c, "2B1q" }, - { "cmpqw", 7,16, 0x1d, "2W1q" }, - { "cmpqd", 7,16, 0x1f, "2D1q" }, - { "cmpsb", 16,16, 0x040e, "1i" }, - { "cmpsw", 16,16, 0x050e, "1i" }, - { "cmpsd", 16,16, 0x070e, "1i" }, - { "cmpst", 16,16, 0x840e, "1i" }, - { "comb", 14,24, 0x344e, "1B2B" }, - { "comw", 14,24, 0x354e, "1W2W" }, - { "comd", 14,24, 0x374e, "1D2D" }, - { "cvtp", 11,24, 0x036e, "2D3D1r" }, - { "cxp", 8,8, 0x22, "1p" }, - { "cxpd", 11,16, 0x07f, "1D" }, - { "deib", 14,24, 0x2cce, "1B2W" }, - { "deiw", 14,24, 0x2dce, "1W2D" }, - { "deid", 14,24, 0x2fce, "1D2Q" }, - { "dia", 8,8, 0xc2, "" }, - { "divf", 14,24, 0x21be, "1F2F" }, - { "divl", 14,24, 0x20be, "1L2L" }, - { "divb", 14,24, 0x3cce, "1B2B" }, - { "divw", 14,24, 0x3dce, "1W2W" }, - { "divd", 14,24, 0x3fce, "1D2D" }, - { "enter", 8,8, 0x82, "1i2d" }, - { "exit", 8,8, 0x92, "1i" }, - { "extb", 11,24, 0x02e, "2D3B1r4d" }, - { "extw", 11,24, 0x12e, "2D3W1r4d" }, - { "extd", 11,24, 0x32e, "2D3D1r4d" }, - { "extsb", 14,24, 0x0cce, "1D2B3i" }, - { "extsw", 14,24, 0x0dce, "1D2W3i" }, - { "extsd", 14,24, 0x0fce, "1D2D3i" }, - { "ffsb", 14,24, 0x046e, "1B2B" }, - { "ffsw", 14,24, 0x056e, "1W2B" }, - { "ffsd", 14,24, 0x076e, "1D2B" }, - { "flag", 8,8, 0xd2, "" }, - { "floorfb", 14,24, 0x3c3e, "1F2B" }, - { "floorfw", 14,24, 0x3d3e, "1F2W" }, - { "floorfd", 14,24, 0x3f3e, "1F2D" }, - { "floorlb", 14,24, 0x383e, "1L2B" }, - { "floorlw", 14,24, 0x393e, "1L2W" }, - { "floorld", 14,24, 0x3b3e, "1L2D" }, - { "ibitb", 14,24, 0x384e, "1B2D" }, - { "ibitw", 14,24, 0x394e, "1W2D" }, - { "ibitd", 14,24, 0x3b4e, "1D2D" }, - { "indexb", 11,24, 0x42e, "2B3B1r" }, - { "indexw", 11,24, 0x52e, "2W3W1r" }, - { "indexd", 11,24, 0x72e, "2D3D1r" }, - { "insb", 11,24, 0x0ae, "2B3B1r4d" }, - { "insw", 11,24, 0x1ae, "2W3W1r4d" }, - { "insd", 11,24, 0x3ae, "2D3D1r4d" }, - { "inssb", 14,24, 0x08ce, "1B2D3i" }, - { "inssw", 14,24, 0x09ce, "1W2D3i" }, - { "inssd", 14,24, 0x0bce, "1D2D3i" }, - { "jsr", 11,16, 0x67f, "1A" }, - { "jump", 11,16, 0x27f, "1A" }, - { "lfsr", 19,24, 0x00f3e,"1D" }, - { "lmr", 15,24, 0x0b1e, "2D1q" }, - { "lprb", 7,16, 0x6c, "2B1q" }, - { "lprw", 7,16, 0x6d, "2W1q" }, - { "lprd", 7,16, 0x6f, "2D1q" }, - { "lshb", 14,24, 0x144e, "1B2B" }, - { "lshw", 14,24, 0x154e, "1B2W" }, - { "lshd", 14,24, 0x174e, "1B2D" }, - { "meib", 14,24, 0x24ce, "1B2W" }, - { "meiw", 14,24, 0x25ce, "1W2D" }, - { "meid", 14,24, 0x27ce, "1D2Q" }, - { "modb", 14,24, 0x38ce, "1B2B" }, - { "modw", 14,24, 0x39ce, "1W2W" }, - { "modd", 14,24, 0x3bce, "1D2D" }, - { "movf", 14,24, 0x05be, "1F2F" }, - { "movl", 14,24, 0x04be, "1L2L" }, - { "movb", 6,16, 0x14, "1B2B" }, - { "movw", 6,16, 0x15, "1W2W" }, - { "movd", 6,16, 0x17, "1D2D" }, - { "movbf", 14,24, 0x043e, "1B2F" }, - { "movwf", 14,24, 0x053e, "1W2F" }, - { "movdf", 14,24, 0x073e, "1D2F" }, - { "movbl", 14,24, 0x003e, "1B2L" }, - { "movwl", 14,24, 0x013e, "1W2L" }, - { "movdl", 14,24, 0x033e, "1D2L" }, - { "movfl", 14,24, 0x1b3e, "1F2L" }, - { "movlf", 14,24, 0x163e, "1L2F" }, - { "movmb", 14,24, 0x00ce, "1D2D3d" }, - { "movmw", 14,24, 0x01ce, "1D2D3d" }, - { "movmd", 14,24, 0x03ce, "1D2D3d" }, - { "movqb", 7,16, 0x5c, "2B1q" }, - { "movqw", 7,16, 0x5d, "2B1q" }, - { "movqd", 7,16, 0x5f, "2B1q" }, - { "movsb", 16,16, 0x000e, "1i" }, - { "movsw", 16,16, 0x010e, "1i" }, - { "movsd", 16,16, 0x030e, "1i" }, - { "movst", 16,16, 0x800e, "1i" }, - { "movsub", 14,24, 0x0cae, "1A1A" }, - { "movsuw", 14,24, 0x0dae, "1A1A" }, - { "movsud", 14,24, 0x0fae, "1A1A" }, - { "movusb", 14,24, 0x1cae, "1A1A" }, - { "movusw", 14,24, 0x1dae, "1A1A" }, - { "movusd", 14,24, 0x1fae, "1A1A" }, - { "movxbd", 14,24, 0x1cce, "1B2D" }, - { "movxwd", 14,24, 0x1dce, "1W2D" }, - { "movxbw", 14,24, 0x10ce, "1B2W" }, - { "movzbd", 14,24, 0x18ce, "1B2D" }, - { "movzwd", 14,24, 0x19ce, "1W2D" }, - { "movzbw", 14,24, 0x14ce, "1B2W" }, - { "mulf", 14,24, 0x31be, "1F2F" }, - { "mull", 14,24, 0x30be, "1L2L" }, - { "mulb", 14,24, 0x20ce, "1B2B" }, - { "mulw", 14,24, 0x21ce, "1W2W" }, - { "muld", 14,24, 0x23ce, "1D2D" }, - { "negf", 14,24, 0x15be, "1F2F" }, - { "negl", 14,24, 0x14be, "1L2L" }, - { "negb", 14,24, 0x204e, "1B2B" }, - { "negw", 14,24, 0x214e, "1W2W" }, - { "negd", 14,24, 0x234e, "1D2D" }, - { "nop", 8,8, 0xa2, "" }, - { "notb", 14,24, 0x244e, "1B2B" }, - { "notw", 14,24, 0x254e, "1W2W" }, - { "notd", 14,24, 0x274e, "1D2D" }, - { "orb", 6,16, 0x18, "1B1B" }, - { "orw", 6,16, 0x19, "1W1W" }, - { "ord", 6,16, 0x1b, "1D2D" }, - { "quob", 14,24, 0x30ce, "1B2B" }, - { "quow", 14,24, 0x31ce, "1W2W" }, - { "quod", 14,24, 0x33ce, "1D2D" }, - { "rdval", 19,24, 0x0031e,"1A" }, - { "remb", 14,24, 0x34ce, "1B2B" }, - { "remw", 14,24, 0x35ce, "1W2W" }, - { "remd", 14,24, 0x37ce, "1D2D" }, - { "restore", 8,8, 0x72, "1i" }, - { "ret", 8,8, 0x12, "1d" }, - { "reti", 8,8, 0x52, "" }, - { "rett", 8,8, 0x42, "" }, - { "rotb", 14,24, 0x004e, "1B2B" }, - { "rotw", 14,24, 0x014e, "1B2W" }, - { "rotd", 14,24, 0x034e, "1B2D" }, - { "roundfb", 14,24, 0x243e, "1F2B" }, - { "roundfw", 14,24, 0x253e, "1F2W" }, - { "roundfd", 14,24, 0x273e, "1F2D" }, - { "roundlb", 14,24, 0x203e, "1L2B" }, - { "roundlw", 14,24, 0x213e, "1L2W" }, - { "roundld", 14,24, 0x233e, "1L2D" }, - { "rxp", 8,8, 0x32, "1d" }, - { "sCONDb", 7,16, 0x3c, "2B1q" }, - { "sCONDw", 7,16, 0x3d, "2D1q" }, - { "sCONDd", 7,16, 0x3f, "2D1q" }, - { "save", 8,8, 0x62, "1i" }, - { "sbitb", 14,24, 0x184e, "1B2A" }, - { "sbitw", 14,24, 0x194e, "1W2A" }, - { "sbitd", 14,24, 0x1b4e, "1D2A" }, - { "sbitib", 14,24, 0x1c4e, "1B2A" }, - { "sbitiw", 14,24, 0x1d4e, "1W2A" }, - { "sbitid", 14,24, 0x1f4e, "1D2A" }, - { "setcfg", 15,24, 0x0b0e, "5D1q" }, - { "sfsr", 14,24, 0x373e, "5D1D" }, - { "skpsb", 16,16, 0x0c0e, "1i" }, - { "skpsw", 16,16, 0x0d0e, "1i" }, - { "skpsd", 16,16, 0x0f0e, "1i" }, - { "skpst", 16,16, 0x8c0e, "1i" }, - { "smr", 15,24, 0x0f1e, "2D1q" }, - { "sprb", 7,16, 0x2c, "2B1q" }, - { "sprw", 7,16, 0x2d, "2W1q" }, - { "sprd", 7,16, 0x2f, "2D1q" }, - { "subf", 14,24, 0x11be, "1F2F" }, - { "subl", 14,24, 0x10be, "1L2L" }, - { "subb", 6,16, 0x20, "1B2B" }, - { "subw", 6,16, 0x21, "1W2W" }, - { "subd", 6,16, 0x23, "1D2D" }, - { "subcb", 6,16, 0x30, "1B2B" }, - { "subcw", 6,16, 0x31, "1W2W" }, - { "subcd", 6,16, 0x33, "1D2D" }, - { "subpb", 14,24, 0x2c4e, "1B2B" }, - { "subpw", 14,24, 0x2d4e, "1W2W" }, - { "subpd", 14,24, 0x2f4e, "1D2D" }, -#ifdef NS32K_SVC_IMMED_OPERANDS - { "svc", 8,8, 0xe2, "2i1i" }, /* not really, but unix uses it */ -#else - { "svc", 8,8, 0xe2, "" }, /* not really, but unix uses it */ -#endif - { "tbitb", 6,16, 0x34, "1B2A" }, - { "tbitw", 6,16, 0x35, "1W2A" }, - { "tbitd", 6,16, 0x37, "1D2A" }, - { "truncfb", 14,24, 0x2c3e, "1F2B" }, - { "truncfw", 14,24, 0x2d3e, "1F2W" }, - { "truncfd", 14,24, 0x2f3e, "1F2D" }, - { "trunclb", 14,24, 0x283e, "1L2B" }, - { "trunclw", 14,24, 0x293e, "1L2W" }, - { "truncld", 14,24, 0x2b3e, "1L2D" }, - { "wait", 8,8, 0xb2, "" }, - { "wrval", 19,24, 0x0071e,"1A" }, - { "xorb", 6,16, 0x38, "1B2B" }, - { "xorw", 6,16, 0x39, "1W2W" }, - { "xord", 6,16, 0x3b, "1D2D" }, -}; /* notstrs */ - -/* end: ns32k.opcode.h */ - -#define MAX_ARGS 4 -#define ARG_LEN 50 diff --git a/gdb/ns32k-pinsn.c b/gdb/ns32k-pinsn.c deleted file mode 100644 index 8cb24823eed..00000000000 --- a/gdb/ns32k-pinsn.c +++ /dev/null @@ -1,522 +0,0 @@ -/* Print 32000 instructions for GDB, the GNU debugger. - Copyright (C) 1986,1988 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include - -#include "defs.h" -#include "param.h" -#include "symtab.h" -#include "ns32k-opcode.h" -#include "gdbcore.h" - -/* 32000 instructions are never longer than this. */ -#define MAXLEN 62 - -/* Number of elements in the opcode table. */ -#define NOPCODES (sizeof notstrs / sizeof notstrs[0]) - -extern char *reg_names[]; - -#define NEXT_IS_ADDR '|' - -/* - * extract "count" bits starting "offset" bits - * into buffer - */ - -int -bit_extract (buffer, offset, count) - char *buffer; - int offset; - int count; -{ - int result; - int mask; - int bit; - - buffer += offset >> 3; - offset &= 7; - bit = 1; - result = 0; - while (count--) - { - if ((*buffer & (1 << offset))) - result |= bit; - if (++offset == 8) - { - offset = 0; - buffer++; - } - bit <<= 1; - } - return result; -} - -float -fbit_extract (buffer, offset, count) -{ - union { - int ival; - float fval; - } foo; - - foo.ival = bit_extract (buffer, offset, 32); - return foo.fval; -} - -double -dbit_extract (buffer, offset, count) -{ - union { - struct {int low, high; } ival; - double dval; - } foo; - - foo.ival.low = bit_extract (buffer, offset, 32); - foo.ival.high = bit_extract (buffer, offset+32, 32); - return foo.dval; -} - -sign_extend (value, bits) -{ - value = value & ((1 << bits) - 1); - return (value & (1 << (bits-1)) - ? value | (~((1 << bits) - 1)) - : value); -} - -flip_bytes (ptr, count) - char *ptr; - int count; -{ - char tmp; - - while (count > 0) - { - tmp = *ptr; - ptr[0] = ptr[count-1]; - ptr[count-1] = tmp; - ptr++; - count -= 2; - } -} - -/* Given a character C, does it represent a general addressing mode? */ -#define Is_gen(c) \ - ((c) == 'F' || (c) == 'L' || (c) == 'B' \ - || (c) == 'W' || (c) == 'D' || (c) == 'A') - -/* Adressing modes. */ -#define Adrmod_index_byte 0x1c -#define Adrmod_index_word 0x1d -#define Adrmod_index_doubleword 0x1e -#define Adrmod_index_quadword 0x1f - -/* Is MODE an indexed addressing mode? */ -#define Adrmod_is_index(mode) \ - (mode == Adrmod_index_byte \ - || mode == Adrmod_index_word \ - || mode == Adrmod_index_doubleword \ - || mode == Adrmod_index_quadword) - - -/* Print the 32000 instruction at address MEMADDR in debugged memory, - on STREAM. Returns length of the instruction, in bytes. */ - -int -print_insn (memaddr, stream) - CORE_ADDR memaddr; - FILE *stream; -{ - unsigned char buffer[MAXLEN]; - register int i; - register unsigned char *p; - register char *d; - unsigned short first_word; - int gen, disp; - int ioffset; /* bits into instruction */ - int aoffset; /* bits into arguments */ - char arg_bufs[MAX_ARGS+1][ARG_LEN]; - int argnum; - int maxarg; - - read_memory (memaddr, buffer, MAXLEN); - - first_word = *(unsigned short *) buffer; - for (i = 0; i < NOPCODES; i++) - if ((first_word & ((1 << notstrs[i].detail.obits) - 1)) - == notstrs[i].detail.code) - break; - - /* Handle undefined instructions. */ - if (i == NOPCODES) - { - fprintf (stream, "0%o", buffer[0]); - return 1; - } - - fprintf (stream, "%s", notstrs[i].name); - - ioffset = notstrs[i].detail.ibits; - aoffset = notstrs[i].detail.ibits; - d = notstrs[i].detail.args; - - if (*d) - { - /* Offset in bits of the first thing beyond each index byte. - Element 0 is for operand A and element 1 is for operand B. - The rest are irrelevant, but we put them here so we don't - index outside the array. */ - int index_offset[MAX_ARGS]; - - /* 0 for operand A, 1 for operand B, greater for other args. */ - int whicharg = 0; - - fputc ('\t', stream); - - maxarg = 0; - - /* First we have to find and keep track of the index bytes, - if we are using scaled indexed addressing mode, since the index - bytes occur right after the basic instruction, not as part - of the addressing extension. */ - if (Is_gen(d[1])) - { - int addr_mode = bit_extract (buffer, ioffset - 5, 5); - - if (Adrmod_is_index (addr_mode)) - { - aoffset += 8; - index_offset[0] = aoffset; - } - } - if (d[2] && Is_gen(d[3])) - { - int addr_mode = bit_extract (buffer, ioffset - 10, 5); - - if (Adrmod_is_index (addr_mode)) - { - aoffset += 8; - index_offset[1] = aoffset; - } - } - - while (*d) - { - argnum = *d - '1'; - d++; - if (argnum > maxarg && argnum < MAX_ARGS) - maxarg = argnum; - ioffset = print_insn_arg (*d, ioffset, &aoffset, buffer, - memaddr, arg_bufs[argnum], - index_offset[whicharg]); - d++; - whicharg++; - } - for (argnum = 0; argnum <= maxarg; argnum++) - { - CORE_ADDR addr; - char *ch, *index (); - for (ch = arg_bufs[argnum]; *ch;) - { - if (*ch == NEXT_IS_ADDR) - { - ++ch; - addr = atoi (ch); - print_address (addr, stream); - while (*ch && *ch != NEXT_IS_ADDR) - ++ch; - if (*ch) - ++ch; - } - else - putc (*ch++, stream); - } - if (argnum < maxarg) - fprintf (stream, ", "); - } - } - return aoffset / 8; -} - -/* Print an instruction operand of category given by d. IOFFSET is - the bit position below which small (<1 byte) parts of the operand can - be found (usually in the basic instruction, but for indexed - addressing it can be in the index byte). AOFFSETP is a pointer to the - bit position of the addressing extension. BUFFER contains the - instruction. ADDR is where BUFFER was read from. Put the disassembled - version of the operand in RESULT. INDEX_OFFSET is the bit position - of the index byte (it contains garbage if this operand is not a - general operand using scaled indexed addressing mode). */ - -print_insn_arg (d, ioffset, aoffsetp, buffer, addr, result, index_offset) - char d; - int ioffset, *aoffsetp; - char *buffer; - CORE_ADDR addr; - char *result; - int index_offset; -{ - int addr_mode; - float Fvalue; - double Lvalue; - int Ivalue; - int disp1, disp2; - int index; - - switch (d) - { - case 'F': - case 'L': - case 'B': - case 'W': - case 'D': - case 'A': - addr_mode = bit_extract (buffer, ioffset-5, 5); - ioffset -= 5; - switch (addr_mode) - { - case 0x0: case 0x1: case 0x2: case 0x3: - case 0x4: case 0x5: case 0x6: case 0x7: - switch (d) - { - case 'F': - case 'L': - sprintf (result, "f%d", addr_mode); - break; - default: - sprintf (result, "r%d", addr_mode); - } - break; - case 0x8: case 0x9: case 0xa: case 0xb: - case 0xc: case 0xd: case 0xe: case 0xf: - disp1 = get_displacement (buffer, aoffsetp); - sprintf (result, "%d(r%d)", disp1, addr_mode & 7); - break; - case 0x10: - case 0x11: - case 0x12: - disp1 = get_displacement (buffer, aoffsetp); - disp2 = get_displacement (buffer, aoffsetp); - sprintf (result, "%d(%d(%s))", disp2, disp1, - addr_mode==0x10?"fp":addr_mode==0x11?"sp":"sb"); - break; - case 0x13: - sprintf (result, "reserved"); - break; - case 0x14: - switch (d) - { - case 'B': - Ivalue = bit_extract (buffer, *aoffsetp, 8); - Ivalue = sign_extend (Ivalue, 8); - *aoffsetp += 8; - sprintf (result, "$%d", Ivalue); - break; - case 'W': - Ivalue = bit_extract (buffer, *aoffsetp, 16); - flip_bytes (&Ivalue, 2); - *aoffsetp += 16; - Ivalue = sign_extend (Ivalue, 16); - sprintf (result, "$%d", Ivalue); - break; - case 'D': - Ivalue = bit_extract (buffer, *aoffsetp, 32); - flip_bytes (&Ivalue, 4); - *aoffsetp += 32; - sprintf (result, "$%d", Ivalue); - break; - case 'A': - Ivalue = bit_extract (buffer, *aoffsetp, 32); - flip_bytes (&Ivalue, 4); - *aoffsetp += 32; - sprintf (result, "$|%d|", Ivalue); - break; - case 'F': - Fvalue = fbit_extract (buffer, *aoffsetp, 32); - flip_bytes (&Fvalue, 4); - *aoffsetp += 32; - sprintf (result, "$%g", Fvalue); - break; - case 'L': - Lvalue = dbit_extract (buffer, *aoffsetp, 64); - flip_bytes (&Lvalue, 8); - *aoffsetp += 64; - sprintf (result, "$%g", Lvalue); - break; - } - break; - case 0x15: - disp1 = get_displacement (buffer, aoffsetp); - sprintf (result, "@|%d|", disp1); - break; - case 0x16: - disp1 = get_displacement (buffer, aoffsetp); - disp2 = get_displacement (buffer, aoffsetp); - sprintf (result, "EXT(%d) + %d", disp1, disp2); - break; - case 0x17: - sprintf (result, "tos"); - break; - case 0x18: - disp1 = get_displacement (buffer, aoffsetp); - sprintf (result, "%d(fp)", disp1); - break; - case 0x19: - disp1 = get_displacement (buffer, aoffsetp); - sprintf (result, "%d(sp)", disp1); - break; - case 0x1a: - disp1 = get_displacement (buffer, aoffsetp); - sprintf (result, "%d(sb)", disp1); - break; - case 0x1b: - disp1 = get_displacement (buffer, aoffsetp); - sprintf (result, "|%d|", addr + disp1); - break; - case 0x1c: - case 0x1d: - case 0x1e: - case 0x1f: - index = bit_extract (buffer, index_offset - 8, 3); - print_insn_arg (d, index_offset, aoffsetp, buffer, addr, - result, 0); - { - static char *ind[] = {"b", "w", "d", "q"}; - char *off; - - off = result + strlen (result); - sprintf (off, "[r%d:%s]", index, - ind[addr_mode & 3]); - } - break; - } - break; - case 'q': - Ivalue = bit_extract (buffer, ioffset-4, 4); - Ivalue = sign_extend (Ivalue, 4); - sprintf (result, "%d", Ivalue); - ioffset -= 4; - break; - case 'r': - Ivalue = bit_extract (buffer, ioffset-3, 3); - sprintf (result, "r%d", Ivalue&7); - ioffset -= 3; - break; - case 'd': - sprintf (result, "%d", get_displacement (buffer, aoffsetp)); - break; - case 'p': - sprintf (result, "%c%d%c", NEXT_IS_ADDR, - addr + get_displacement (buffer, aoffsetp), - NEXT_IS_ADDR); - break; - case 'i': - Ivalue = bit_extract (buffer, *aoffsetp, 8); - *aoffsetp += 8; - sprintf (result, "0x%x", Ivalue); - break; - } - return ioffset; -} - -get_displacement (buffer, aoffsetp) - char *buffer; - int *aoffsetp; -{ - int Ivalue; - - Ivalue = bit_extract (buffer, *aoffsetp, 8); - switch (Ivalue & 0xc0) - { - case 0x00: - case 0x40: - Ivalue = sign_extend (Ivalue, 7); - *aoffsetp += 8; - break; - case 0x80: - Ivalue = bit_extract (buffer, *aoffsetp, 16); - flip_bytes (&Ivalue, 2); - Ivalue = sign_extend (Ivalue, 14); - *aoffsetp += 16; - break; - case 0xc0: - Ivalue = bit_extract (buffer, *aoffsetp, 32); - flip_bytes (&Ivalue, 4); - Ivalue = sign_extend (Ivalue, 30); - *aoffsetp += 32; - break; - } - return Ivalue; -} - -/* Return the number of locals in the current frame given a pc - pointing to the enter instruction. This is used in the macro - FRAME_FIND_SAVED_REGS. */ - -ns32k_localcount (enter_pc) - CORE_ADDR enter_pc; -{ - unsigned char localtype; - int localcount; - - localtype = read_memory_integer (enter_pc+2, 1); - if ((localtype & 0x80) == 0) - localcount = localtype; - else if ((localtype & 0xc0) == 0x80) - localcount = (((localtype & 0x3f) << 8) - | (read_memory_integer (enter_pc+3, 1) & 0xff)); - else - localcount = (((localtype & 0x3f) << 24) - | ((read_memory_integer (enter_pc+3, 1) & 0xff) << 16) - | ((read_memory_integer (enter_pc+4, 1) & 0xff) << 8 ) - | (read_memory_integer (enter_pc+5, 1) & 0xff)); - return localcount; -} - -/* - * Get the address of the enter opcode for the function - * containing PC, if there is an enter for the function, - * and if the pc is between the enter and exit. - * Returns positive address if pc is between enter/exit, - * 1 if pc before enter or after exit, 0 otherwise. - */ - -CORE_ADDR -ns32k_get_enter_addr (pc) - CORE_ADDR pc; -{ - CORE_ADDR enter_addr; - unsigned char op; - - if (ABOUT_TO_RETURN (pc)) - return 1; /* after exit */ - - enter_addr = get_pc_function_start (pc); - - if (pc == enter_addr) - return 1; /* before enter */ - - op = read_memory_integer (enter_addr, 1); - - if (op != 0x82) - return 0; /* function has no enter/exit */ - - return enter_addr; /* pc is between enter and exit */ -} diff --git a/gdb/obstack.c b/gdb/obstack.c deleted file mode 100755 index 590fcaa9dcf..00000000000 --- a/gdb/obstack.c +++ /dev/null @@ -1,333 +0,0 @@ -/* obstack.c - subroutines used implicitly by object stack macros - Copyright (C) 1988 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 1, 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, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include "obstack.h" - -#ifdef __STDC__ -#define POINTER void * -#else -#define POINTER char * -#endif - -/* Determine default alignment. */ -struct fooalign {char x; double d;}; -#define DEFAULT_ALIGNMENT ((char *)&((struct fooalign *) 0)->d - (char *)0) -/* If malloc were really smart, it would round addresses to DEFAULT_ALIGNMENT. - But in fact it might be less smart and round addresses to as much as - DEFAULT_ROUNDING. So we prepare for it to do that. */ -union fooround {long x; double d;}; -#define DEFAULT_ROUNDING (sizeof (union fooround)) - -/* When we copy a long block of data, this is the unit to do it with. - On some machines, copying successive ints does not work; - in such a case, redefine COPYING_UNIT to `long' (if that works) - or `char' as a last resort. */ -#ifndef COPYING_UNIT -#define COPYING_UNIT int -#endif - -/* The non-GNU-C macros copy the obstack into this global variable - to avoid multiple evaluation. */ - -struct obstack *_obstack; - -/* Initialize an obstack H for use. Specify chunk size SIZE (0 means default). - Objects start on multiples of ALIGNMENT (0 means use default). - CHUNKFUN is the function to use to allocate chunks, - and FREEFUN the function to free them. */ - -void -_obstack_begin (h, size, alignment, chunkfun, freefun) - struct obstack *h; - int size; - int alignment; - POINTER (*chunkfun) (); - void (*freefun) (); -{ - register struct _obstack_chunk* chunk; /* points to new chunk */ - - if (alignment == 0) - alignment = DEFAULT_ALIGNMENT; - if (size == 0) - /* Default size is what GNU malloc can fit in a 4096-byte block. */ - { - /* 12 is sizeof (mhead) and 4 is EXTRA from GNU malloc. - Use the values for range checking, because if range checking is off, - the extra bytes won't be missed terribly, but if range checking is on - and we used a larger request, a whole extra 4096 bytes would be - allocated. - - These number are irrelevant to the new GNU malloc. I suspect it is - less sensitive to the size of the request. */ - int extra = ((((12 + DEFAULT_ROUNDING - 1) & ~(DEFAULT_ROUNDING - 1)) - + 4 + DEFAULT_ROUNDING - 1) - & ~(DEFAULT_ROUNDING - 1)); - size = 4096 - extra; - } - - h->chunkfun = chunkfun; - h->freefun = freefun; - h->chunk_size = size; - h->alignment_mask = alignment - 1; - - chunk = h->chunk = (struct _obstack_chunk *)(*h->chunkfun) (h->chunk_size); - h->next_free = h->object_base = chunk->contents; - h->chunk_limit = chunk->limit - = (char *) chunk + h->chunk_size; - chunk->prev = 0; -} - -/* Allocate a new current chunk for the obstack *H - on the assumption that LENGTH bytes need to be added - to the current object, or a new object of length LENGTH allocated. - Copies any partial object from the end of the old chunk - to the beginning of the new one. - - The function must be "int" so it can be used in non-ANSI C - compilers in a : expression. */ - -int -_obstack_newchunk (h, length) - struct obstack *h; - int length; -{ - register struct _obstack_chunk* old_chunk = h->chunk; - register struct _obstack_chunk* new_chunk; - register long new_size; - register int obj_size = h->next_free - h->object_base; - register int i; - int already; - - /* Compute size for new chunk. */ - new_size = (obj_size + length) + (obj_size >> 3) + 100; - if (new_size < h->chunk_size) - new_size = h->chunk_size; - - /* Allocate and initialize the new chunk. */ - new_chunk = h->chunk = (struct _obstack_chunk *)(*h->chunkfun) (new_size); - new_chunk->prev = old_chunk; - new_chunk->limit = h->chunk_limit = (char *) new_chunk + new_size; - - /* Move the existing object to the new chunk. - Word at a time is fast and is safe if the object - is sufficiently aligned. */ - if (h->alignment_mask + 1 >= DEFAULT_ALIGNMENT) - { - for (i = obj_size / sizeof (COPYING_UNIT) - 1; - i >= 0; i--) - ((COPYING_UNIT *)new_chunk->contents)[i] - = ((COPYING_UNIT *)h->object_base)[i]; - /* We used to copy the odd few remaining bytes as one extra COPYING_UNIT, - but that can cross a page boundary on a machine - which does not do strict alignment for COPYING_UNITS. */ - already = obj_size / sizeof (COPYING_UNIT) * sizeof (COPYING_UNIT); - } - else - already = 0; - /* Copy remaining bytes one by one. */ - for (i = already; i < obj_size; i++) - new_chunk->contents[i] = h->object_base[i]; - - h->object_base = new_chunk->contents; - h->next_free = h->object_base + obj_size; -} - -/* Return nonzero if object OBJ has been allocated from obstack H. - This is here for debugging. - If you use it in a program, you are probably losing. */ - -int -_obstack_allocated_p (h, obj) - struct obstack *h; - POINTER obj; -{ - register struct _obstack_chunk* lp; /* below addr of any objects in this chunk */ - register struct _obstack_chunk* plp; /* point to previous chunk if any */ - - lp = (h)->chunk; - while (lp != 0 && ((POINTER)lp > obj || (POINTER)(lp)->limit < obj)) - { - plp = lp -> prev; - lp = plp; - } - return lp != 0; -} - -/* Free objects in obstack H, including OBJ and everything allocate - more recently than OBJ. If OBJ is zero, free everything in H. */ - -#ifdef __STDC__ -#undef obstack_free -void -obstack_free (struct obstack *h, POINTER obj) -#else -int -_obstack_free (h, obj) - struct obstack *h; - POINTER obj; -#endif -{ - register struct _obstack_chunk* lp; /* below addr of any objects in this chunk */ - register struct _obstack_chunk* plp; /* point to previous chunk if any */ - - lp = (h)->chunk; - /* We use >= because there cannot be an object at the beginning of a chunk. - But there can be an empty object at that address - at the end of another chunk. */ - while (lp != 0 && ((POINTER)lp >= obj || (POINTER)(lp)->limit < obj)) - { - plp = lp -> prev; - (*h->freefun) ((POINTER) lp); - lp = plp; - } - if (lp) - { - (h)->object_base = (h)->next_free = (char *)(obj); - (h)->chunk_limit = lp->limit; - (h)->chunk = lp; - } - else if (obj != 0) - /* obj is not in any of the chunks! */ - abort (); -} - -/* Let same .o link with output of gcc and other compilers. */ - -#ifdef __STDC__ -int -_obstack_free (h, obj) - struct obstack *h; - POINTER obj; -{ - obstack_free (h, obj); -} -#endif - -/* #if 0 */ -/* These are now turned off because the applications do not use it - and it uses bcopy via obstack_grow, which causes trouble on sysV. */ - -/* Now define the functional versions of the obstack macros. - Define them to simply use the corresponding macros to do the job. */ - -#ifdef __STDC__ -/* These function definitions do not work with non-ANSI preprocessors; - they won't pass through the macro names in parentheses. */ - -/* The function names appear in parentheses in order to prevent - the macro-definitions of the names from being expanded there. */ - -POINTER (obstack_base) (obstack) - struct obstack *obstack; -{ - return obstack_base (obstack); -} - -POINTER (obstack_next_free) (obstack) - struct obstack *obstack; -{ - return obstack_next_free (obstack); -} - -int (obstack_object_size) (obstack) - struct obstack *obstack; -{ - return obstack_object_size (obstack); -} - -int (obstack_room) (obstack) - struct obstack *obstack; -{ - return obstack_room (obstack); -} - -void (obstack_grow) (obstack, pointer, length) - struct obstack *obstack; - POINTER pointer; - int length; -{ - obstack_grow (obstack, pointer, length); -} - -void (obstack_grow0) (obstack, pointer, length) - struct obstack *obstack; - POINTER pointer; - int length; -{ - obstack_grow0 (obstack, pointer, length); -} - -void (obstack_1grow) (obstack, character) - struct obstack *obstack; - int character; -{ - obstack_1grow (obstack, character); -} - -void (obstack_blank) (obstack, length) - struct obstack *obstack; - int length; -{ - obstack_blank (obstack, length); -} - -void (obstack_1grow_fast) (obstack, character) - struct obstack *obstack; - int character; -{ - obstack_1grow_fast (obstack, character); -} - -void (obstack_blank_fast) (obstack, length) - struct obstack *obstack; - int length; -{ - obstack_blank_fast (obstack, length); -} - -POINTER (obstack_finish) (obstack) - struct obstack *obstack; -{ - return obstack_finish (obstack); -} - -POINTER (obstack_alloc) (obstack, length) - struct obstack *obstack; - int length; -{ - return obstack_alloc (obstack, length); -} - -POINTER (obstack_copy) (obstack, pointer, length) - struct obstack *obstack; - POINTER pointer; - int length; -{ - return obstack_copy (obstack, pointer, length); -} - -POINTER (obstack_copy0) (obstack, pointer, length) - struct obstack *obstack; - POINTER pointer; - int length; -{ - return obstack_copy0 (obstack, pointer, length); -} - -#endif /* __STDC__ */ - -/* #endif 0 */ diff --git a/gdb/obstack.h b/gdb/obstack.h deleted file mode 100755 index 2e80c9c70fa..00000000000 --- a/gdb/obstack.h +++ /dev/null @@ -1,416 +0,0 @@ -/* obstack.h - object stack macros - Copyright (C) 1988 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 1, 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, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Summary: - -All the apparent functions defined here are macros. The idea -is that you would use these pre-tested macros to solve a -very specific set of problems, and they would run fast. -Caution: no side-effects in arguments please!! They may be -evaluated MANY times!! - -These macros operate a stack of objects. Each object starts life -small, and may grow to maturity. (Consider building a word syllable -by syllable.) An object can move while it is growing. Once it has -been "finished" it never changes address again. So the "top of the -stack" is typically an immature growing object, while the rest of the -stack is of mature, fixed size and fixed address objects. - -These routines grab large chunks of memory, using a function you -supply, called `obstack_chunk_alloc'. On occasion, they free chunks, -by calling `obstack_chunk_free'. You must define them and declare -them before using any obstack macros. - -Each independent stack is represented by a `struct obstack'. -Each of the obstack macros expects a pointer to such a structure -as the first argument. - -One motivation for this package is the problem of growing char strings -in symbol tables. Unless you are "fascist pig with a read-only mind" -[Gosper's immortal quote from HAKMEM item 154, out of context] you -would not like to put any arbitrary upper limit on the length of your -symbols. - -In practice this often means you will build many short symbols and a -few long symbols. At the time you are reading a symbol you don't know -how long it is. One traditional method is to read a symbol into a -buffer, realloc()ating the buffer every time you try to read a symbol -that is longer than the buffer. This is beaut, but you still will -want to copy the symbol from the buffer to a more permanent -symbol-table entry say about half the time. - -With obstacks, you can work differently. Use one obstack for all symbol -names. As you read a symbol, grow the name in the obstack gradually. -When the name is complete, finalize it. Then, if the symbol exists already, -free the newly read name. - -The way we do this is to take a large chunk, allocating memory from -low addresses. When you want to build a symbol in the chunk you just -add chars above the current "high water mark" in the chunk. When you -have finished adding chars, because you got to the end of the symbol, -you know how long the chars are, and you can create a new object. -Mostly the chars will not burst over the highest address of the chunk, -because you would typically expect a chunk to be (say) 100 times as -long as an average object. - -In case that isn't clear, when we have enough chars to make up -the object, THEY ARE ALREADY CONTIGUOUS IN THE CHUNK (guaranteed) -so we just point to it where it lies. No moving of chars is -needed and this is the second win: potentially long strings need -never be explicitly shuffled. Once an object is formed, it does not -change its address during its lifetime. - -When the chars burst over a chunk boundary, we allocate a larger -chunk, and then copy the partly formed object from the end of the old -chunk to the beginning of the new larger chunk. We then carry on -accreting characters to the end of the object as we normally would. - -A special macro is provided to add a single char at a time to a -growing object. This allows the use of register variables, which -break the ordinary 'growth' macro. - -Summary: - We allocate large chunks. - We carve out one object at a time from the current chunk. - Once carved, an object never moves. - We are free to append data of any size to the currently - growing object. - Exactly one object is growing in an obstack at any one time. - You can run one obstack per control block. - You may have as many control blocks as you dare. - Because of the way we do it, you can `unwind' a obstack - back to a previous state. (You may remove objects much - as you would with a stack.) -*/ - - -/* Don't do the contents of this file more than once. */ - -#ifndef __OBSTACKS__ -#define __OBSTACKS__ - -/* We use subtraction of (char *)0 instead of casting to int - because on word-addressable machines a simple cast to int - may ignore the byte-within-word field of the pointer. */ - -#ifndef __PTR_TO_INT -#define __PTR_TO_INT(P) ((P) - (char *)0) -#endif - -#ifndef __INT_TO_PTR -#define __INT_TO_PTR(P) ((P) + (char *)0) -#endif - -struct _obstack_chunk /* Lives at front of each chunk. */ -{ - char *limit; /* 1 past end of this chunk */ - struct _obstack_chunk *prev; /* address of prior chunk or NULL */ - char contents[4]; /* objects begin here */ -}; - -struct obstack /* control current object in current chunk */ -{ - long chunk_size; /* preferred size to allocate chunks in */ - struct _obstack_chunk* chunk; /* address of current struct obstack_chunk */ - char *object_base; /* address of object we are building */ - char *next_free; /* where to add next char to current object */ - char *chunk_limit; /* address of char after current chunk */ - int temp; /* Temporary for some macros. */ - int alignment_mask; /* Mask of alignment for each object. */ -#ifdef __STDC__ - void *(*chunkfun) (); /* User's fcn to allocate a chunk. */ -#else - char *(*chunkfun) (); /* User's fcn to allocate a chunk. */ -#endif - void (*freefun) (); /* User's function to free a chunk. */ -}; - -#ifdef __STDC__ - -/* Do the function-declarations after the structs - but before defining the macros. */ - -void obstack_init (struct obstack *obstack); - -void * obstack_alloc (struct obstack *obstack, int size); - -void * obstack_copy (struct obstack *obstack, void *address, int size); -void * obstack_copy0 (struct obstack *obstack, void *address, int size); - -void obstack_free (struct obstack *obstack, void *block); - -void obstack_blank (struct obstack *obstack, int size); - -void obstack_grow (struct obstack *obstack, void *data, int size); -void obstack_grow0 (struct obstack *obstack, void *data, int size); - -void obstack_1grow (struct obstack *obstack, int data_char); -void obstack_ptr_grow (struct obstack *obstack, void *data); -void obstack_int_grow (struct obstack *obstack, int data); - -void * obstack_finish (struct obstack *obstack); - -int obstack_object_size (struct obstack *obstack); - -int obstack_room (struct obstack *obstack); -void obstack_1grow_fast (struct obstack *obstack, int data_char); -void obstack_ptr_grow_fast (struct obstack *obstack, void *data); -void obstack_int_grow_fast (struct obstack *obstack, int data); -void obstack_blank_fast (struct obstack *obstack, int size); - -void * obstack_base (struct obstack *obstack); -void * obstack_next_free (struct obstack *obstack); -int obstack_alignment_mask (struct obstack *obstack); -int obstack_chunk_size (struct obstack *obstack); - -#endif /* __STDC__ */ - -/* Non-ANSI C cannot really support alternative functions for these macros, - so we do not declare them. */ - -/* Pointer to beginning of object being allocated or to be allocated next. - Note that this might not be the final address of the object - because a new chunk might be needed to hold the final size. */ - -#define obstack_base(h) ((h)->object_base) - -/* Size for allocating ordinary chunks. */ - -#define obstack_chunk_size(h) ((h)->chunk_size) - -/* Pointer to next byte not yet allocated in current chunk. */ - -#define obstack_next_free(h) ((h)->next_free) - -/* Mask specifying low bits that should be clear in address of an object. */ - -#define obstack_alignment_mask(h) ((h)->alignment_mask) - -#define obstack_init(h) \ - _obstack_begin ((h), 0, 0, obstack_chunk_alloc, obstack_chunk_free) - -#define obstack_begin(h, size) \ - _obstack_begin ((h), (size), 0, obstack_chunk_alloc, obstack_chunk_free) - -#define obstack_1grow_fast(h,achar) (*((h)->next_free)++ = achar) - -#define obstack_blank_fast(h,n) ((h)->next_free += (n)) - -#if defined (__GNUC__) && defined (__STDC__) - -/* For GNU C, if not -traditional, - we can define these macros to compute all args only once - without using a global variable. - Also, we can avoid using the `temp' slot, to make faster code. */ - -#define obstack_object_size(OBSTACK) \ - ({ struct obstack *__o = (OBSTACK); \ - (unsigned) (__o->next_free - __o->object_base); }) - -#define obstack_room(OBSTACK) \ - ({ struct obstack *__o = (OBSTACK); \ - (unsigned) (__o->chunk_limit - __o->next_free); }) - -#define obstack_grow(OBSTACK,where,length) \ -({ struct obstack *__o = (OBSTACK); \ - int __len = (length); \ - ((__o->next_free + __len > __o->chunk_limit) \ - ? _obstack_newchunk (__o, __len) : 0); \ - bcopy (where, __o->next_free, __len); \ - __o->next_free += __len; \ - (void) 0; }) - -#define obstack_grow0(OBSTACK,where,length) \ -({ struct obstack *__o = (OBSTACK); \ - int __len = (length); \ - ((__o->next_free + __len + 1 > __o->chunk_limit) \ - ? _obstack_newchunk (__o, __len + 1) : 0), \ - bcopy (where, __o->next_free, __len), \ - __o->next_free += __len, \ - *(__o->next_free)++ = 0; \ - (void) 0; }) - -#define obstack_1grow(OBSTACK,datum) \ -({ struct obstack *__o = (OBSTACK); \ - ((__o->next_free + 1 > __o->chunk_limit) \ - ? _obstack_newchunk (__o, 1) : 0), \ - *(__o->next_free)++ = (datum); \ - (void) 0; }) - -/* These assume that the obstack alignment is good enough for pointers or ints, - and that the data added so far to the current object - shares that much alignment. */ - -#define obstack_ptr_grow(OBSTACK,datum) \ -({ struct obstack *__o = (OBSTACK); \ - ((__o->next_free + sizeof (void *) > __o->chunk_limit) \ - ? _obstack_newchunk (__o, sizeof (void *)) : 0), \ - *(*(void ***)&__o->next_free)++ = ((void *)datum); \ - (void) 0; }) - -#define obstack_int_grow(OBSTACK,datum) \ -({ struct obstack *__o = (OBSTACK); \ - ((__o->next_free + sizeof (int) > __o->chunk_limit) \ - ? _obstack_newchunk (__o, sizeof (int)) : 0), \ - *(*(int **)&__o->next_free)++ = ((int)datum); \ - (void) 0; }) - -#define obstack_ptr_grow_fast(h,aptr) (*(*(void ***)&(h)->next_free)++ = (void *)aptr) -#define obstack_int_grow_fast(h,aint) (*(*(int **)&(h)->next_free)++ = (int)aint) - -#define obstack_blank(OBSTACK,length) \ -({ struct obstack *__o = (OBSTACK); \ - int __len = (length); \ - ((__o->chunk_limit - __o->next_free < __len) \ - ? _obstack_newchunk (__o, __len) : 0); \ - __o->next_free += __len; \ - (void) 0; }) - -#define obstack_alloc(OBSTACK,length) \ -({ struct obstack *__h = (OBSTACK); \ - obstack_blank (__h, (length)); \ - obstack_finish (__h); }) - -#define obstack_copy(OBSTACK,where,length) \ -({ struct obstack *__h = (OBSTACK); \ - obstack_grow (__h, (where), (length)); \ - obstack_finish (__h); }) - -#define obstack_copy0(OBSTACK,where,length) \ -({ struct obstack *__h = (OBSTACK); \ - obstack_grow0 (__h, (where), (length)); \ - obstack_finish (__h); }) - -#define obstack_finish(OBSTACK) \ -({ struct obstack *__o = (OBSTACK); \ - void *value = (void *) __o->object_base; \ - __o->next_free \ - = __INT_TO_PTR ((__PTR_TO_INT (__o->next_free)+__o->alignment_mask)\ - & ~ (__o->alignment_mask)); \ - ((__o->next_free - (char *)__o->chunk \ - > __o->chunk_limit - (char *)__o->chunk) \ - ? (__o->next_free = __o->chunk_limit) : 0); \ - __o->object_base = __o->next_free; \ - value; }) - -#define obstack_free(OBSTACK, OBJ) \ -({ struct obstack *__o = (OBSTACK); \ - void *__obj = (OBJ); \ - if (__obj > (void *)__o->chunk && __obj < (void *)__o->chunk_limit) \ - __o->next_free = __o->object_base = __obj; \ - else (obstack_free) (__o, __obj); }) - -#else /* not __GNUC__ or not __STDC__ */ - -#define obstack_object_size(h) \ - (unsigned) ((h)->next_free - (h)->object_base) - -#define obstack_room(h) \ - (unsigned) ((h)->chunk_limit - (h)->next_free) - -#define obstack_grow(h,where,length) \ -( (h)->temp = (length), \ - (((h)->next_free + (h)->temp > (h)->chunk_limit) \ - ? _obstack_newchunk ((h), (h)->temp) : 0), \ - bcopy (where, (h)->next_free, (h)->temp), \ - (h)->next_free += (h)->temp) - -#define obstack_grow0(h,where,length) \ -( (h)->temp = (length), \ - (((h)->next_free + (h)->temp + 1 > (h)->chunk_limit) \ - ? _obstack_newchunk ((h), (h)->temp + 1) : 0), \ - bcopy (where, (h)->next_free, (h)->temp), \ - (h)->next_free += (h)->temp, \ - *((h)->next_free)++ = 0) - -#define obstack_1grow(h,datum) \ -( (((h)->next_free + 1 > (h)->chunk_limit) \ - ? _obstack_newchunk ((h), 1) : 0), \ - *((h)->next_free)++ = (datum)) - -#define obstack_ptr_grow(h,datum) \ -( (((h)->next_free + sizeof (char *) > (h)->chunk_limit) \ - ? _obstack_newchunk ((h), sizeof (char *)) : 0), \ - *(*(char ***)&(h)->next_free)++ = ((char *)datum)) - -#define obstack_int_grow(h,datum) \ -( (((h)->next_free + sizeof (int) > (h)->chunk_limit) \ - ? _obstack_newchunk ((h), sizeof (int)) : 0), \ - *(*(int **)&(h)->next_free)++ = ((int)datum)) - -#define obstack_ptr_grow_fast(h,aptr) (*(*(char ***)&(h)->next_free)++ = (char *)aptr) -#define obstack_int_grow_fast(h,aint) (*(*(int **)&(h)->next_free)++ = (int)aint) - -#define obstack_blank(h,length) \ -( (h)->temp = (length), \ - (((h)->chunk_limit - (h)->next_free < (h)->temp) \ - ? _obstack_newchunk ((h), (h)->temp) : 0), \ - (h)->next_free += (h)->temp) - -#define obstack_alloc(h,length) \ - (obstack_blank ((h), (length)), obstack_finish ((h))) - -#define obstack_copy(h,where,length) \ - (obstack_grow ((h), (where), (length)), obstack_finish ((h))) - -#define obstack_copy0(h,where,length) \ - (obstack_grow0 ((h), (where), (length)), obstack_finish ((h))) - -#define obstack_finish(h) \ -( (h)->temp = __PTR_TO_INT ((h)->object_base), \ - (h)->next_free \ - = __INT_TO_PTR ((__PTR_TO_INT ((h)->next_free)+(h)->alignment_mask) \ - & ~ ((h)->alignment_mask)), \ - (((h)->next_free - (char *)(h)->chunk \ - > (h)->chunk_limit - (char *)(h)->chunk) \ - ? ((h)->next_free = (h)->chunk_limit) : 0), \ - (h)->object_base = (h)->next_free, \ - __INT_TO_PTR ((h)->temp)) - -#ifdef __STDC__ -#define obstack_free(h,obj) \ -( (h)->temp = (char *)(obj) - (char *) (h)->chunk, \ - (((h)->temp >= 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\ - ? (int) ((h)->next_free = (h)->object_base \ - = (h)->temp + (char *) (h)->chunk) \ - : ((obstack_free) ((h), (h)->temp + (char *) (h)->chunk), 0))) -#else -#define obstack_free(h,obj) \ -( (h)->temp = (char *)(obj) - (char *) (h)->chunk, \ - (((h)->temp >= 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\ - ? (int) ((h)->next_free = (h)->object_base \ - = (h)->temp + (char *) (h)->chunk) \ - : (int) _obstack_free ((h), (h)->temp + (char *) (h)->chunk))) -#endif - -#endif /* not __GNUC__ or not __STDC__ */ - -/* Declare the external functions we use; they are in obstack.c. */ - -#ifdef __STDC__ - extern int _obstack_newchunk (struct obstack *h, int length); - extern int _obstack_free (struct obstack *h, void *obj); - extern void _obstack_begin (struct obstack *h, int size, int alignment, - void *(*chunkfun) (), void (*freefun) ()); -#else - extern int _obstack_newchunk (); - extern int _obstack_free (); - extern void _obstack_begin (); -#endif - -#endif /* not __OBSTACKS__ */ - diff --git a/gdb/param-no-tm.h b/gdb/param-no-tm.h deleted file mode 100755 index 96bc85af42d..00000000000 --- a/gdb/param-no-tm.h +++ /dev/null @@ -1,82 +0,0 @@ -/* Copyright (C) 1990 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#if !defined (PARAM_H) -#define PARAM_H 1 - -/* DO NOT #include "tm.h" -- a particular tm file has been inc'd by caller */ - -#include "xm.h" - -/* TARGET_BYTE_ORDER and HOST_BYTE_ORDER should be defined to one of these. */ -#if !defined (BIG_ENDIAN) -#define BIG_ENDIAN 4321 -#endif - -#if !defined (LITTLE_ENDIAN) -#define LITTLE_ENDIAN 1234 -#endif - -/* The bit byte-order has to do just with numbering of bits in - debugging symbols and such. Conceptually, it's quite separate - from byte/word byte order. */ - -#if !defined (BITS_BIG_ENDIAN) -#if TARGET_BYTE_ORDER == BIG_ENDIAN -#define BITS_BIG_ENDIAN 1 -#endif /* Big endian. */ - -#if TARGET_BYTE_ORDER == LITTLE_ENDIAN -#define BITS_BIG_ENDIAN 0 -#endif /* Little endian. */ -#endif /* BITS_BIG_ENDIAN not defined. */ - -/* Swap LEN bytes at BUFFER between target and host byte-order. */ -#if TARGET_BYTE_ORDER == HOST_BYTE_ORDER -#define SWAP_TARGET_AND_HOST(buffer,len) -#else /* Target and host byte order differ. */ -#define SWAP_TARGET_AND_HOST(buffer,len) \ - { \ - char tmp; \ - char *p = (char *)(buffer); \ - char *q = ((char *)(buffer)) + len - 1; \ - for (; p < q; p++, q--) \ - { \ - tmp = *q; \ - *q = *p; \ - *p = tmp; \ - } \ - } -#endif /* Target and host byte order differ. */ - -/* On some machines there are bits in addresses which are not really - part of the address, but are used by the kernel, the hardware, etc. - for special purposes. ADDR_BITS_REMOVE takes out any such bits - so we get a "real" address such as one would find in a symbol - table. ADDR_BITS_SET sets those bits the way the system wants - them. */ -#if !defined (ADDR_BITS_REMOVE) -#define ADDR_BITS_REMOVE(addr) (addr) -#define ADDR_BITS_SET(addr) (addr) -#endif /* No ADDR_BITS_REMOVE. */ - -#if !defined (SYS_SIGLIST_MISSING) -#define SYS_SIGLIST_MISSING defined (USG) -#endif /* No SYS_SIGLIST_MISSING */ - -#endif /* param.h not already included. */ diff --git a/gdb/param.h b/gdb/param.h deleted file mode 100755 index b408a033fc2..00000000000 --- a/gdb/param.h +++ /dev/null @@ -1,32 +0,0 @@ -/* Copyright (C) 1990 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* The standard thing is to include param.h. However, files that are - specific to a particular target can include that tm-xxx.h file and - param-no-tm.h. Any future inclusions of param.h will be protected - against by the #if !defined stuff below. */ - -/* This file requires defs.h. */ - -#if !defined (PARAM_H) -#include "tm.h" -#endif - -#include "param-no-tm.h" - -#define PARAM_H 1 diff --git a/gdb/parse.c b/gdb/parse.c deleted file mode 100644 index 214df03b6b5..00000000000 --- a/gdb/parse.c +++ /dev/null @@ -1,628 +0,0 @@ -/* Parse expressions for GDB. - Copyright (C) 1986, 1989, 1990, 1991 Free Software Foundation, Inc. - Modified from expread.y by the Department of Computer Science at the - State University of New York at Buffalo, 1991. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Parse an expression from text in a string, - and return the result as a struct expression pointer. - That structure contains arithmetic operations in reverse polish, - with constants represented by operations that are followed by special data. - See expression.h for the details of the format. - What is important here is that it can be built up sequentially - during the process of parsing; the lower levels of the tree always - come first in the result. */ - -#include -#include "defs.h" -#include "param.h" -#include "symtab.h" -#include "frame.h" -#include "expression.h" -#include "value.h" -#include "command.h" -#include "language.h" -#include "parser-defs.h" - -/* Assign machine-independent names to certain registers - (unless overridden by the REGISTER_NAMES table) */ - -struct std_regs std_regs[] = { -#ifdef PC_REGNUM - { "pc", PC_REGNUM }, -#endif -#ifdef FP_REGNUM - { "fp", FP_REGNUM }, -#endif -#ifdef SP_REGNUM - { "sp", SP_REGNUM }, -#endif -#ifdef PS_REGNUM - { "ps", PS_REGNUM }, -#endif -}; - -unsigned num_std_regs = (sizeof std_regs / sizeof std_regs[0]); - - -/* Begin counting arguments for a function call, - saving the data about any containing call. */ - -void -start_arglist () -{ - register struct funcall *new = (struct funcall *) xmalloc (sizeof (struct funcall)); - - new->next = funcall_chain; - new->arglist_len = arglist_len; - arglist_len = 0; - funcall_chain = new; -} - -/* Return the number of arguments in a function call just terminated, - and restore the data for the containing function call. */ - -int -end_arglist () -{ - register int val = arglist_len; - register struct funcall *call = funcall_chain; - funcall_chain = call->next; - arglist_len = call->arglist_len; - free (call); - return val; -} - -/* Free everything in the funcall chain. - Used when there is an error inside parsing. */ - -void -free_funcalls () -{ - register struct funcall *call, *next; - - for (call = funcall_chain; call; call = next) - { - next = call->next; - free (call); - } -} - -/* This page contains the functions for adding data to the struct expression - being constructed. */ - -/* Add one element to the end of the expression. */ - -/* To avoid a bug in the Sun 4 compiler, we pass things that can fit into - a register through here */ - -void -write_exp_elt (expelt) - union exp_element expelt; -{ - if (expout_ptr >= expout_size) - { - expout_size *= 2; - expout = (struct expression *) xrealloc (expout, - sizeof (struct expression) - + expout_size * sizeof (union exp_element)); - } - expout->elts[expout_ptr++] = expelt; -} - -void -write_exp_elt_opcode (expelt) - enum exp_opcode expelt; -{ - union exp_element tmp; - - tmp.opcode = expelt; - - write_exp_elt (tmp); -} - -void -write_exp_elt_sym (expelt) - struct symbol *expelt; -{ - union exp_element tmp; - - tmp.symbol = expelt; - - write_exp_elt (tmp); -} - -void -write_exp_elt_longcst (expelt) - LONGEST expelt; -{ - union exp_element tmp; - - tmp.longconst = expelt; - - write_exp_elt (tmp); -} - -void -write_exp_elt_dblcst (expelt) - double expelt; -{ - union exp_element tmp; - - tmp.doubleconst = expelt; - - write_exp_elt (tmp); -} - -void -write_exp_elt_type (expelt) - struct type *expelt; -{ - union exp_element tmp; - - tmp.type = expelt; - - write_exp_elt (tmp); -} - -void -write_exp_elt_intern (expelt) - struct internalvar *expelt; -{ - union exp_element tmp; - - tmp.internalvar = expelt; - - write_exp_elt (tmp); -} - -/* Add a string constant to the end of the expression. - Follow it by its length in bytes, as a separate exp_element. */ - -void -write_exp_string (str) - struct stoken str; -{ - register int len = str.length; - register int lenelt - = (len + sizeof (union exp_element)) / sizeof (union exp_element); - - expout_ptr += lenelt; - - if (expout_ptr >= expout_size) - { - expout_size = max (expout_size * 2, expout_ptr + 10); - expout = (struct expression *) - xrealloc (expout, (sizeof (struct expression) - + (expout_size * sizeof (union exp_element)))); - } - bcopy (str.ptr, (char *) &expout->elts[expout_ptr - lenelt], len); - ((char *) &expout->elts[expout_ptr - lenelt])[len] = 0; - write_exp_elt_longcst ((LONGEST) len); -} - -/* Return a null-terminated temporary copy of the name - of a string token. */ - -char * -copy_name (token) - struct stoken token; -{ - bcopy (token.ptr, namecopy, token.length); - namecopy[token.length] = 0; - return namecopy; -} - -/* Reverse an expression from suffix form (in which it is constructed) - to prefix form (in which we can conveniently print or execute it). */ - -static void prefixify_subexp (); - -void -prefixify_expression (expr) - register struct expression *expr; -{ - register int len = sizeof (struct expression) + - expr->nelts * sizeof (union exp_element); - register struct expression *temp; - register int inpos = expr->nelts, outpos = 0; - - temp = (struct expression *) alloca (len); - - /* Copy the original expression into temp. */ - bcopy (expr, temp, len); - - prefixify_subexp (temp, expr, inpos, outpos); -} - -/* Return the number of exp_elements in the subexpression of EXPR - whose last exp_element is at index ENDPOS - 1 in EXPR. */ - -int -length_of_subexp (expr, endpos) - register struct expression *expr; - register int endpos; -{ - register int oplen = 1; - register int args = 0; - register int i; - - if (endpos < 0) - error ("?error in length_of_subexp"); - - i = (int) expr->elts[endpos - 1].opcode; - - switch (i) - { - /* C++ */ - case OP_SCOPE: - oplen = 4 + ((expr->elts[endpos - 2].longconst - + sizeof (union exp_element)) - / sizeof (union exp_element)); - break; - - case OP_LONG: - case OP_DOUBLE: - oplen = 4; - break; - - case OP_TYPE: - case OP_BOOL: - case OP_VAR_VALUE: - case OP_LAST: - case OP_REGISTER: - case OP_INTERNALVAR: - oplen = 3; - break; - - case OP_FUNCALL: - oplen = 3; - args = 1 + expr->elts[endpos - 2].longconst; - break; - - case UNOP_MAX: - case UNOP_MIN: - oplen = 3; - args = 0; - break; - - case BINOP_VAL: - case UNOP_CAST: - case UNOP_MEMVAL: - oplen = 3; - args = 1; - break; - - case UNOP_ABS: - case UNOP_CAP: - case UNOP_CHR: - case UNOP_FLOAT: - case UNOP_HIGH: - case UNOP_ODD: - case UNOP_ORD: - case UNOP_TRUNC: - oplen = 1; - args = 1; - break; - - case STRUCTOP_STRUCT: - case STRUCTOP_PTR: - args = 1; - case OP_M2_STRING: - case OP_STRING: - oplen = 3 + ((expr->elts[endpos - 2].longconst - + sizeof (union exp_element)) - / sizeof (union exp_element)); - break; - - case TERNOP_COND: - args = 3; - break; - - /* Modula-2 */ - case BINOP_MULTI_SUBSCRIPT: - oplen=3; - args = 1 + expr->elts[endpos- 2].longconst; - break; - - case BINOP_ASSIGN_MODIFY: - oplen = 3; - args = 2; - break; - - /* C++ */ - case OP_THIS: - oplen = 2; - break; - - default: - args = 1 + (i < (int) BINOP_END); - } - - while (args > 0) - { - oplen += length_of_subexp (expr, endpos - oplen); - args--; - } - - return oplen; -} - -/* Copy the subexpression ending just before index INEND in INEXPR - into OUTEXPR, starting at index OUTBEG. - In the process, convert it from suffix to prefix form. */ - -static void -prefixify_subexp (inexpr, outexpr, inend, outbeg) - register struct expression *inexpr; - struct expression *outexpr; - register int inend; - int outbeg; -{ - register int oplen = 1; - register int args = 0; - register int i; - int *arglens; - enum exp_opcode opcode; - - /* Compute how long the last operation is (in OPLEN), - and also how many preceding subexpressions serve as - arguments for it (in ARGS). */ - - opcode = inexpr->elts[inend - 1].opcode; - switch (opcode) - { - /* C++ */ - case OP_SCOPE: - oplen = 4 + ((inexpr->elts[inend - 2].longconst - + sizeof (union exp_element)) - / sizeof (union exp_element)); - break; - - case OP_LONG: - case OP_DOUBLE: - oplen = 4; - break; - - case OP_TYPE: - case OP_BOOL: - case OP_VAR_VALUE: - case OP_LAST: - case OP_REGISTER: - case OP_INTERNALVAR: - oplen = 3; - break; - - case OP_FUNCALL: - oplen = 3; - args = 1 + inexpr->elts[inend - 2].longconst; - break; - - case UNOP_MIN: - case UNOP_MAX: - oplen = 3; - args = 0; - break; - - case UNOP_CAST: - case UNOP_MEMVAL: - oplen = 3; - args = 1; - break; - - case UNOP_ABS: - case UNOP_CAP: - case UNOP_CHR: - case UNOP_FLOAT: - case UNOP_HIGH: - case UNOP_ODD: - case UNOP_ORD: - case UNOP_TRUNC: - oplen=1; - args=1; - break; - - case STRUCTOP_STRUCT: - case STRUCTOP_PTR: - args = 1; - case OP_M2_STRING: - case OP_STRING: - oplen = 3 + ((inexpr->elts[inend - 2].longconst - + sizeof (union exp_element)) - / sizeof (union exp_element)); - - break; - - case TERNOP_COND: - args = 3; - break; - - case BINOP_ASSIGN_MODIFY: - oplen = 3; - args = 2; - break; - - /* Modula-2 */ - case BINOP_MULTI_SUBSCRIPT: - oplen=3; - args = 1 + inexpr->elts[inend - 2].longconst; - break; - - /* C++ */ - case OP_THIS: - oplen = 2; - break; - - default: - args = 1 + ((int) opcode < (int) BINOP_END); - } - - /* Copy the final operator itself, from the end of the input - to the beginning of the output. */ - inend -= oplen; - bcopy (&inexpr->elts[inend], &outexpr->elts[outbeg], - oplen * sizeof (union exp_element)); - outbeg += oplen; - - /* Find the lengths of the arg subexpressions. */ - arglens = (int *) alloca (args * sizeof (int)); - for (i = args - 1; i >= 0; i--) - { - oplen = length_of_subexp (inexpr, inend); - arglens[i] = oplen; - inend -= oplen; - } - - /* Now copy each subexpression, preserving the order of - the subexpressions, but prefixifying each one. - In this loop, inend starts at the beginning of - the expression this level is working on - and marches forward over the arguments. - outbeg does similarly in the output. */ - for (i = 0; i < args; i++) - { - oplen = arglens[i]; - inend += oplen; - prefixify_subexp (inexpr, outexpr, inend, outbeg); - outbeg += oplen; - } -} - -/* This page contains the two entry points to this file. */ - -/* Read an expression from the string *STRINGPTR points to, - parse it, and return a pointer to a struct expression that we malloc. - Use block BLOCK as the lexical context for variable names; - if BLOCK is zero, use the block of the selected stack frame. - Meanwhile, advance *STRINGPTR to point after the expression, - at the first nonwhite character that is not part of the expression - (possibly a null character). - - If COMMA is nonzero, stop if a comma is reached. */ - -struct expression * -parse_exp_1 (stringptr, block, comma) - char **stringptr; - struct block *block; - int comma; -{ - struct cleanup *old_chain; - - lexptr = *stringptr; - - paren_depth = 0; - type_stack_depth = 0; - - comma_terminates = comma; - - if (lexptr == 0 || *lexptr == 0) - error_no_arg ("expression to compute"); - - old_chain = make_cleanup (free_funcalls, 0); - funcall_chain = 0; - - expression_context_block = block ? block : get_selected_block (); - - namecopy = (char *) alloca (strlen (lexptr) + 1); - expout_size = 10; - expout_ptr = 0; - expout = (struct expression *) - xmalloc (sizeof (struct expression) - + expout_size * sizeof (union exp_element)); - expout->language_defn = current_language; - make_cleanup (free_current_contents, &expout); - - if (current_language->la_parser ()) - current_language->la_error (NULL); - - discard_cleanups (old_chain); - expout->nelts = expout_ptr; - expout = (struct expression *) - xrealloc (expout, - sizeof (struct expression) - + expout_ptr * sizeof (union exp_element)); - prefixify_expression (expout); - *stringptr = lexptr; - return expout; -} - -/* Parse STRING as an expression, and complain if this fails - to use up all of the contents of STRING. */ - -struct expression * -parse_expression (string) - char *string; -{ - register struct expression *exp; - exp = parse_exp_1 (&string, 0, 0); - if (*string) - error ("Junk after end of expression."); - return exp; -} - -void -push_type (tp) - enum type_pieces tp; -{ - if (type_stack_depth == type_stack_size) - { - type_stack_size *= 2; - type_stack = (union type_stack_elt *) - xrealloc (type_stack, type_stack_size * sizeof (*type_stack)); - } - type_stack[type_stack_depth++].piece = tp; -} - -void -push_type_int (n) - int n; -{ - if (type_stack_depth == type_stack_size) - { - type_stack_size *= 2; - type_stack = (union type_stack_elt *) - xrealloc (type_stack, type_stack_size * sizeof (*type_stack)); - } - type_stack[type_stack_depth++].int_val = n; -} - -enum type_pieces -pop_type () -{ - if (type_stack_depth) - return type_stack[--type_stack_depth].piece; - return tp_end; -} - -int -pop_type_int () -{ - if (type_stack_depth) - return type_stack[--type_stack_depth].int_val; - /* "Can't happen". */ - return 0; -} - -void -_initialize_parse () -{ - type_stack_size = 80; - type_stack_depth = 0; - type_stack = (union type_stack_elt *) - xmalloc (type_stack_size * sizeof (*type_stack)); -} diff --git a/gdb/parser-defs.h b/gdb/parser-defs.h deleted file mode 100644 index c5c8077d219..00000000000 --- a/gdb/parser-defs.h +++ /dev/null @@ -1,162 +0,0 @@ -/* Parser definitions for GDB. - Copyright (C) 1986, 1989, 1990, 1991 Free Software Foundation, Inc. - Modified from expread.y by the Department of Computer Science at the - State University of New York at Buffalo. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -struct std_regs { - char *name; - int regnum; -}; - -extern struct std_regs std_regs[]; -extern unsigned num_std_regs; - -struct expression *expout; -int expout_size; -int expout_ptr; - -extern struct type *init_type (); - -void write_exp_elt (); -void write_exp_elt_opcode (); -void write_exp_elt_sym (); -void write_exp_elt_longcst (); -void write_exp_elt_dblcst (); -void write_exp_elt_type (); -void write_exp_elt_intern (); -void write_exp_string (); -void start_arglist (); -int end_arglist (); -void free_funcalls (); -char *copy_name (); - -/* If this is nonzero, this block is used as the lexical context - for symbol names. */ - -struct block *expression_context_block; - -/* The innermost context required by the stack and register variables - we've encountered so far. */ -struct block *innermost_block; - -/* The block in which the most recently discovered symbol was found. */ -struct block *block_found; - -/* Number of arguments seen so far in innermost function call. */ -int arglist_len; - -/* Data structure for saving values of arglist_len - for function calls whose arguments contain other function calls. */ - -struct funcall - { - struct funcall *next; - int arglist_len; - }; - -struct funcall *funcall_chain; - -/* This kind of datum is used to represent the name - of a symbol token. */ - -struct stoken - { - char *ptr; - int length; - }; - -struct ttype - { - struct stoken stoken; - struct type *type; - }; - -struct symtoken - { - struct stoken stoken; - struct symbol *sym; - int is_a_field_of_this; - }; - -/* For parsing of complicated types. - An array should be preceded in the list by the size of the array. */ -enum type_pieces - {tp_end = -1, tp_pointer, tp_reference, tp_array, tp_function}; -/* The stack can contain either an enum type_pieces or an int. */ -union type_stack_elt { - enum type_pieces piece; - int int_val; -}; -union type_stack_elt *type_stack; -int type_stack_depth, type_stack_size; - -void push_type (); -void push_type_int (); -enum type_pieces pop_type (); -int pop_type_int (); - -/* During parsing of a C expression, the pointer to the next character - is in this variable. */ - -char *lexptr; - -/* Tokens that refer to names do so with explicit pointer and length, - so they can share the storage that lexptr is parsing. - - When it is necessary to pass a name to a function that expects - a null-terminated string, the substring is copied out - into a block of storage that namecopy points to. - - namecopy is allocated once, guaranteed big enough, for each parsing. */ - -char *namecopy; - -/* Current depth in parentheses within the expression. */ - -int paren_depth; - -/* Nonzero means stop parsing on first comma (if not within parentheses). */ - -int comma_terminates; - -/* These codes indicate operator precedences for expression printing, - least tightly binding first. */ -/* Adding 1 to a precedence value is done for binary operators, - on the operand which is more tightly bound, so that operators - of equal precedence within that operand will get parentheses. */ -/* PREC_HYPER and PREC_ABOVE_COMMA are not the precedence of any operator; - they are used as the "surrounding precedence" to force - various kinds of things to be parenthesized. */ -enum precedence -{ PREC_NULL, PREC_COMMA, PREC_ABOVE_COMMA, PREC_ASSIGN, PREC_OR, PREC_AND, - PREC_LOGIOR, PREC_LOGAND, PREC_LOGXOR, PREC_EQUAL, PREC_ORDER, - PREC_SHIFT, PREC_ADD, PREC_MUL, PREC_REPEAT, - PREC_HYPER, PREC_PREFIX, PREC_SUFFIX }; - -/* Table mapping opcodes into strings for printing operators - and precedences of the operators. */ - -struct op_print -{ - char *string; - enum exp_opcode opcode; - /* Precedence of operator. These values are used only by comparisons. */ - enum precedence precedence; - int right_assoc; -}; diff --git a/gdb/pn-opcode.h b/gdb/pn-opcode.h deleted file mode 100755 index 77a27707640..00000000000 --- a/gdb/pn-opcode.h +++ /dev/null @@ -1,282 +0,0 @@ -/* Print GOULD PN (PowerNode) instructions for GDB, the GNU debugger. - Copyright (C) 1986, 1987, 1989 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -struct gld_opcode -{ - char *name; - unsigned long opcode; - unsigned long mask; - char *args; - int length; -}; - -/* We store four bytes of opcode for all opcodes because that - is the most any of them need. The actual length of an instruction - is always at least 2 bytes, and at most four. The length of the - instruction is based on the opcode. - - The mask component is a mask saying which bits must match - particular opcode in order for an instruction to be an instance - of that opcode. - - The args component is a string containing characters - that are used to format the arguments to the instruction. */ - -/* Kinds of operands: - r Register in first field - R Register in second field - b Base register in first field - B Base register in second field - v Vector register in first field - V Vector register in first field - A Optional address register (base register) - X Optional index register - I Immediate data (16bits signed) - O Offset field (16bits signed) - h Offset field (15bits signed) - d Offset field (14bits signed) - S Shift count field - - any other characters are printed as is... -*/ - -/* The assembler requires that this array be sorted as follows: - all instances of the same mnemonic must be consecutive. - All instances of the same mnemonic with the same number of operands - must be consecutive. - */ -struct gld_opcode gld_opcodes[] = -{ -{ "abm", 0xa0080000, 0xfc080000, "f,xOA,X", 4 }, -{ "abr", 0x18080000, 0xfc0c0000, "r,f", 2 }, -{ "aci", 0xfc770000, 0xfc7f8000, "r,I", 4 }, -{ "adfd", 0xe0080002, 0xfc080002, "r,xOA,X", 4 }, -{ "adfw", 0xe0080000, 0xfc080000, "r,xOA,X", 4 }, -{ "adi", 0xc8010000, 0xfc7f0000, "r,I", 4 }, -{ "admb", 0xb8080000, 0xfc080000, "r,xOA,X", 4 }, -{ "admd", 0xb8000002, 0xfc080002, "r,xOA,X", 4 }, -{ "admh", 0xb8000001, 0xfc080001, "r,xOA,X", 4 }, -{ "admw", 0xb8000000, 0xfc080000, "r,xOA,X", 4 }, -{ "adr", 0x38000000, 0xfc0f0000, "r,R", 2 }, -{ "adrfd", 0x38090000, 0xfc0f0000, "r,R", 2 }, -{ "adrfw", 0x38010000, 0xfc0f0000, "r,R", 2 }, -{ "adrm", 0x38080000, 0xfc0f0000, "r,R", 2 }, -{ "ai", 0xfc030000, 0xfc07ffff, "I", 4 }, -{ "anmb", 0x84080000, 0xfc080000, "r,xOA,X", 4 }, -{ "anmd", 0x84000002, 0xfc080002, "r,xOA,X", 4 }, -{ "anmh", 0x84000001, 0xfc080001, "r,xOA,X", 4 }, -{ "anmw", 0x84000000, 0xfc080000, "r,xOA,X", 4 }, -{ "anr", 0x04000000, 0xfc0f0000, "r,R", 2 }, -{ "armb", 0xe8080000, 0xfc080000, "r,xOA,X", 4 }, -{ "armd", 0xe8000002, 0xfc080002, "r,xOA,X", 4 }, -{ "armh", 0xe8000001, 0xfc080001, "r,xOA,X", 4 }, -{ "armw", 0xe8000000, 0xfc080000, "r,xOA,X", 4 }, -{ "bcf", 0xf0000000, 0xfc080000, "I,xOA,X", 4 }, -{ "bct", 0xec000000, 0xfc080000, "I,xOA,X", 4 }, -{ "bei", 0x00060000, 0xffff0000, "", 2 }, -{ "bft", 0xf0000000, 0xff880000, "xOA,X", 4 }, -{ "bib", 0xf4000000, 0xfc780000, "r,xOA", 4 }, -{ "bid", 0xf4600000, 0xfc780000, "r,xOA", 4 }, -{ "bih", 0xf4200000, 0xfc780000, "r,xOA", 4 }, -{ "biw", 0xf4400000, 0xfc780000, "r,xOA", 4 }, -{ "bl", 0xf8800000, 0xff880000, "xOA,X", 4 }, -{ "bsub", 0x5c080000, 0xff8f0000, "", 2 }, -{ "bsubm", 0x28080000, 0xfc080000, "", 4 }, -{ "bu", 0xec000000, 0xff880000, "xOA,X", 4 }, -{ "call", 0x28080000, 0xfc0f0000, "", 2 }, -{ "callm", 0x5c080000, 0xff880000, "", 4 }, -{ "camb", 0x90080000, 0xfc080000, "r,xOA,X", 4 }, -{ "camd", 0x90000002, 0xfc080002, "r,xOA,X", 4 }, -{ "camh", 0x90000001, 0xfc080001, "r,xOA,X", 4 }, -{ "camw", 0x90000000, 0xfc080000, "r.xOA,X", 4 }, -{ "car", 0x10000000, 0xfc0f0000, "r,R", 2 }, -{ "cd", 0xfc060000, 0xfc070000, "r,f", 4 }, -{ "cea", 0x000f0000, 0xffff0000, "", 2 }, -{ "ci", 0xc8050000, 0xfc7f0000, "r,I", 4 }, -{ "cmc", 0x040a0000, 0xfc7f0000, "r", 2 }, -{ "cmmb", 0x94080000, 0xfc080000, "r,xOA,X", 4 }, -{ "cmmd", 0x94000002, 0xfc080002, "r,xOA,X", 4 }, -{ "cmmh", 0x94000001, 0xfc080001, "r,xOA,X", 4 }, -{ "cmmw", 0x94000000, 0xfc080000, "r,xOA,X", 4 }, -{ "cmr", 0x14000000, 0xfc0f0000, "r,R", 2 }, -{ "daci", 0xfc7f0000, 0xfc7f8000, "r,I", 4 }, -{ "dae", 0x000e0000, 0xffff0000, "", 2 }, -{ "dai", 0xfc040000, 0xfc07ffff, "I", 4 }, -{ "dci", 0xfc6f0000, 0xfc7f8000, "r,I", 4 }, -{ "di", 0xfc010000, 0xfc07ffff, "I", 4 }, -{ "dvfd", 0xe4000002, 0xfc080002, "r,xOA,X", 4 }, -{ "dvfw", 0xe4000000, 0xfc080000, "r,xOA,X", 4 }, -{ "dvi", 0xc8040000, 0xfc7f0000, "r,I", 4 }, -{ "dvmb", 0xc4080000, 0xfc080000, "r,xOA,X", 4 }, -{ "dvmh", 0xc4000001, 0xfc080001, "r,xOA,X", 4 }, -{ "dvmw", 0xc4000000, 0xfc080000, "r,xOA,X", 4 }, -{ "dvr", 0x380a0000, 0xfc0f0000, "r,R", 2 }, -{ "dvrfd", 0x380c0000, 0xfc0f0000, "r,R", 4 }, -{ "dvrfw", 0x38040000, 0xfc0f0000, "r,xOA,X", 4 }, -{ "eae", 0x00080000, 0xffff0000, "", 2 }, -{ "eci", 0xfc670000, 0xfc7f8080, "r,I", 4 }, -{ "ecwcs", 0xfc4f0000, 0xfc7f8000, "", 4 }, -{ "ei", 0xfc000000, 0xfc07ffff, "I", 4 }, -{ "eomb", 0x8c080000, 0xfc080000, "r,xOA,X", 4 }, -{ "eomd", 0x8c000002, 0xfc080002, "r,xOA,X", 4 }, -{ "eomh", 0x8c000001, 0xfc080001, "r,xOA,X", 4 }, -{ "eomw", 0x8c000000, 0xfc080000, "r,xOA,X", 4 }, -{ "eor", 0x0c000000, 0xfc0f0000, "r,R", 2 }, -{ "eorm", 0x0c080000, 0xfc0f0000, "r,R", 2 }, -{ "es", 0x00040000, 0xfc7f0000, "r", 2 }, -{ "exm", 0xa8000000, 0xff880000, "xOA,X", 4 }, -{ "exr", 0xc8070000, 0xfc7f0000, "r", 2 }, -{ "exrr", 0xc8070002, 0xfc7f0002, "r", 2 }, -{ "fixd", 0x380d0000, 0xfc0f0000, "r,R", 2 }, -{ "fixw", 0x38050000, 0xfc0f0000, "r,R", 2 }, -{ "fltd", 0x380f0000, 0xfc0f0000, "r,R", 2 }, -{ "fltw", 0x38070000, 0xfc0f0000, "r,R", 2 }, -{ "grio", 0xfc3f0000, 0xfc7f8000, "r,I", 4 }, -{ "halt", 0x00000000, 0xffff0000, "", 2 }, -{ "hio", 0xfc370000, 0xfc7f8000, "r,I", 4 }, -{ "jwcs", 0xfa080000, 0xff880000, "xOA,X", 4 }, -{ "la", 0x50000000, 0xfc000000, "r,xOA,X", 4 }, -{ "labr", 0x58080000, 0xfc080000, "b,xOA,X", 4 }, -{ "lb", 0xac080000, 0xfc080000, "r,xOA,X", 4 }, -{ "lcs", 0x00030000, 0xfc7f0000, "r", 2 }, -{ "ld", 0xac000002, 0xfc080002, "r,xOA,X", 4 }, -{ "lear", 0x80000000, 0xfc080000, "r,xOA,X", 4 }, -{ "lf", 0xcc000000, 0xfc080000, "r,xOA,X", 4 }, -{ "lfbr", 0xcc080000, 0xfc080000, "b,xOA,X", 4 }, -{ "lh", 0xac000001, 0xfc080001, "r,xOA,X", 4 }, -{ "li", 0xc8000000, 0xfc7f0000, "r,I", 4 }, -{ "lmap", 0x2c070000, 0xfc7f0000, "r", 2 }, -{ "lmb", 0xb0080000, 0xfc080000, "r,xOA,X", 4 }, -{ "lmd", 0xb0000002, 0xfc080002, "r,xOA,X", 4 }, -{ "lmh", 0xb0000001, 0xfc080001, "r,xOA,X", 4 }, -{ "lmw", 0xb0000000, 0xfc080000, "r,xOA,X", 4 }, -{ "lnb", 0xb4080000, 0xfc080000, "r,xOA,X", 4 }, -{ "lnd", 0xb4000002, 0xfc080002, "r,xOA,X", 4 }, -{ "lnh", 0xb4000001, 0xfc080001, "r,xOA,X", 4 }, -{ "lnw", 0xb4000000, 0xfc080000, "r,xOA,X", 4 }, -{ "lpsd", 0xf9800000, 0xff880000, "r,xOA,X", 4 }, -{ "lpsdcm", 0xfa800000, 0xff880000, "r,xOA,X", 4 }, -{ "lw", 0xac000000, 0xfc080000, "r,xOA,X", 4 }, -{ "lwbr", 0x5c000000, 0xfc080000, "b,xOA,X", 4 }, -{ "mpfd", 0xe4080002, 0xfc080002, "r,xOA,X", 4 }, -{ "mpfw", 0xe4080000, 0xfc080000, "r,xOA,X", 4 }, -{ "mpi", 0xc8030000, 0xfc7f0000, "r,I", 4 }, -{ "mpmb", 0xc0080000, 0xfc080000, "r,xOA,X", 4 }, -{ "mpmh", 0xc0000001, 0xfc080001, "r,xOA,X", 4 }, -{ "mpmw", 0xc0000000, 0xfc080000, "r,xOA,X", 4 }, -{ "mpr", 0x38020000, 0xfc0f0000, "r,R", 2 }, -{ "mprfd", 0x380e0000, 0xfc0f0000, "r,R", 2 }, -{ "mprfw", 0x38060000, 0xfc0f0000, "r,R", 2 }, -{ "nop", 0x00020000, 0xffff0000, "", 2 }, -{ "ormb", 0x88080000, 0xfc080000, "r,xOA,X", 4 }, -{ "ormd", 0x88000002, 0xfc080002, "r,xOA,X", 4 }, -{ "ormh", 0x88000001, 0xfc080001, "r,xOA,X", 4 }, -{ "ormw", 0x88000000, 0xfc080000, "r,xOA,X", 4 }, -{ "orr", 0x08000000, 0xfc0f0000, "r,R", 2 }, -{ "orrm", 0x08080000, 0xfc0f0000, "r,R", 2 }, -{ "rdsts", 0x00090000, 0xfc7f0000, "r", 2 }, -{ "return", 0x280e0000, 0xfc7f0000, "", 2 }, -{ "ri", 0xfc020000, 0xfc07ffff, "I", 4 }, -{ "rnd", 0x00050000, 0xfc7f0000, "r", 2 }, -{ "rpswt", 0x040b0000, 0xfc7f0000, "r", 2 }, -{ "rschnl", 0xfc2f0000, 0xfc7f8000, "r,I", 4 }, -{ "rsctl", 0xfc470000, 0xfc7f8000, "r,I", 4 }, -{ "rwcs", 0x000b0000, 0xfc0f0000, "r,R", 2 }, -{ "sacz", 0x10080000, 0xfc0f0000, "r,R", 2 }, -{ "sbm", 0x98080000, 0xfc080000, "f,xOA,X", 4 }, -{ "sbr", 0x18000000, 0xfc0c0000, "r,f", 4 }, -{ "sea", 0x000d0000, 0xffff0000, "", 2 }, -{ "setcpu", 0x2c090000, 0xfc7f0000, "r", 2 }, -{ "sio", 0xfc170000, 0xfc7f8000, "r,I", 4 }, -{ "sipu", 0x000a0000, 0xffff0000, "", 2 }, -{ "sla", 0x1c400000, 0xfc600000, "r,S", 2 }, -{ "slad", 0x20400000, 0xfc600000, "r,S", 2 }, -{ "slc", 0x24400000, 0xfc600000, "r,S", 2 }, -{ "sll", 0x1c600000, 0xfc600000, "r,S", 2 }, -{ "slld", 0x20600000, 0xfc600000, "r,S", 2 }, -{ "smc", 0x04070000, 0xfc070000, "", 2 }, -{ "sra", 0x1c000000, 0xfc600000, "r,S", 2 }, -{ "srad", 0x20000000, 0xfc600000, "r,S", 2 }, -{ "src", 0x24000000, 0xfc600000, "r,S", 2 }, -{ "srl", 0x1c200000, 0xfc600000, "r,S", 2 }, -{ "srld", 0x20200000, 0xfc600000, "r,S", 2 }, -{ "stb", 0xd4080000, 0xfc080000, "r,xOA,X", 4 }, -{ "std", 0xd4000002, 0xfc080002, "r,xOA,X", 4 }, -{ "stf", 0xdc000000, 0xfc080000, "r,xOA,X", 4 }, -{ "stfbr", 0x54000000, 0xfc080000, "b,xOA,X", 4 }, -{ "sth", 0xd4000001, 0xfc080001, "r,xOA,X", 4 }, -{ "stmb", 0xd8080000, 0xfc080000, "r,xOA,X", 4 }, -{ "stmd", 0xd8000002, 0xfc080002, "r,xOA,X", 4 }, -{ "stmh", 0xd8000001, 0xfc080001, "r,xOA,X", 4 }, -{ "stmw", 0xd8000000, 0xfc080000, "r,xOA,X", 4 }, -{ "stpio", 0xfc270000, 0xfc7f8000, "r,I", 4 }, -{ "stw", 0xd4000000, 0xfc080000, "r,xOA,X", 4 }, -{ "stwbr", 0x54000000, 0xfc080000, "b,xOA,X", 4 }, -{ "suabr", 0x58000000, 0xfc080000, "b,xOA,X", 4 }, -{ "sufd", 0xe0000002, 0xfc080002, "r,xOA,X", 4 }, -{ "sufw", 0xe0000000, 0xfc080000, "r,xOA,X", 4 }, -{ "sui", 0xc8020000, 0xfc7f0000, "r,I", 4 }, -{ "sumb", 0xbc080000, 0xfc080000, "r,xOA,X", 4 }, -{ "sumd", 0xbc000002, 0xfc080002, "r,xOA,X", 4 }, -{ "sumh", 0xbc000001, 0xfc080001, "r,xOA,X", 4 }, -{ "sumw", 0xbc000000, 0xfc080000, "r,xOA,X", 4 }, -{ "sur", 0x3c000000, 0xfc0f0000, "r,R", 2 }, -{ "surfd", 0x380b0000, 0xfc0f0000, "r,xOA,X", 4 }, -{ "surfw", 0x38030000, 0xfc0f0000, "r,R", 2 }, -{ "surm", 0x3c080000, 0xfc0f0000, "r,R", 2 }, -{ "svc", 0xc8060000, 0xffff0000, "", 4 }, -{ "tbm", 0xa4080000, 0xfc080000, "f,xOA,X", 4 }, -{ "tbr", 0x180c0000, 0xfc0c0000, "r,f", 2 }, -{ "tbrr", 0x2c020000, 0xfc0f0000, "r,B", 2 }, -{ "tccr", 0x28040000, 0xfc7f0000, "", 2 }, -{ "td", 0xfc050000, 0xfc070000, "r,f", 4 }, -{ "tio", 0xfc1f0000, 0xfc7f8000, "r,I", 4 }, -{ "tmapr", 0x2c0a0000, 0xfc0f0000, "r,R", 2 }, -{ "tpcbr", 0x280c0000, 0xfc7f0000, "r", 2 }, -{ "trbr", 0x2c010000, 0xfc0f0000, "b,R", 2 }, -{ "trc", 0x2c030000, 0xfc0f0000, "r,R", 2 }, -{ "trcc", 0x28050000, 0xfc7f0000, "", 2 }, -{ "trcm", 0x2c0b0000, 0xfc0f0000, "r,R", 2 }, -{ "trn", 0x2c040000, 0xfc0f0000, "r,R", 2 }, -{ "trnm", 0x2c0c0000, 0xfc0f0000, "r,R", 2 }, -{ "trr", 0x2c000000, 0xfc0f0000, "r,R", 2 }, -{ "trrm", 0x2c080000, 0xfc0f0000, "r,R", 2 }, -{ "trsc", 0x2c0e0000, 0xfc0f0000, "r,R", 2 }, -{ "trsw", 0x28000000, 0xfc7f0000, "r", 2 }, -{ "tscr", 0x2c0f0000, 0xfc0f0000, "r,R", 2 }, -{ "uei", 0x00070000, 0xffff0000, "", 2 }, -{ "wait", 0x00010000, 0xffff0000, "", 2 }, -{ "wcwcs", 0xfc5f0000, 0xfc7f8000, "", 4 }, -{ "wwcs", 0x000c0000, 0xfc0f0000, "r,R", 2 }, -{ "xcbr", 0x28020000, 0xfc0f0000, "b,B", 2 }, -{ "xcr", 0x2c050000, 0xfc0f0000, "r,R", 2 }, -{ "xcrm", 0x2c0d0000, 0xfc0f0000, "r,R", 2 }, -{ "zbm", 0x9c080000, 0xfc080000, "f,xOA,X", 4 }, -{ "zbr", 0x18040000, 0xfc0c0000, "r,f", 2 }, -{ "zmb", 0xf8080000, 0xfc080000, "r,xOA,X", 4 }, -{ "zmd", 0xf8000002, 0xfc080002, "r,xOA,X", 4 }, -{ "zmh", 0xf8000001, 0xfc080001, "r,xOA,X", 4 }, -{ "zmw", 0xf8000000, 0xfc080000, "r,xOA,X", 4 }, -{ "zr", 0x0c000000, 0xfc0f0000, "r", 2 }, -}; - -int numopcodes = sizeof(gld_opcodes) / sizeof(gld_opcodes[0]); - -struct gld_opcode *endop = gld_opcodes + sizeof(gld_opcodes) / - sizeof(gld_opcodes[0]); diff --git a/gdb/printcmd.c b/gdb/printcmd.c deleted file mode 100644 index ec96d4919c7..00000000000 --- a/gdb/printcmd.c +++ /dev/null @@ -1,2003 +0,0 @@ -/* Print values for GNU debugger GDB. - Copyright (C) 1986-1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include -#include "defs.h" -#include "param.h" -#include "frame.h" -#include "symtab.h" -#include "value.h" -#include "language.h" -#include "expression.h" -#include "gdbcore.h" -#include "gdbcmd.h" -#include "target.h" - -extern int asm_demangle; /* Whether to demangle syms in asm printouts */ -extern int addressprint; /* Whether to print hex addresses in HLL " */ - -extern struct block *get_current_block (); - -static void print_frame_nameless_args (); - -struct format_data -{ - int count; - char format; - char size; -}; - -/* Last specified output format. */ - -static char last_format = 'x'; - -/* Last specified examination size. 'b', 'h', 'w' or `q'. */ - -static char last_size = 'w'; - -/* Default address to examine next. */ - -static CORE_ADDR next_address; - -/* Last address examined. */ - -static CORE_ADDR last_examine_address; - -/* Contents of last address examined. - This is not valid past the end of the `x' command! */ - -static value last_examine_value; - -/* Number of auto-display expression currently being displayed. - So that we can deleted it if we get an error or a signal within it. - -1 when not doing one. */ - -int current_display_number; - -/* Flag to low-level print routines that this value is being printed - in an epoch window. We'd like to pass this as a parameter, but - every routine would need to take it. Perhaps we can encapsulate - this in the I/O stream once we have GNU stdio. */ - -int inspect_it = 0; - -static void do_one_display (); - -void do_displays (); -void print_scalar_formatted (); - - -/* Decode a format specification. *STRING_PTR should point to it. - OFORMAT and OSIZE are used as defaults for the format and size - if none are given in the format specification. - If OSIZE is zero, then the size field of the returned value - should be set only if a size is explicitly specified by the - user. - The structure returned describes all the data - found in the specification. In addition, *STRING_PTR is advanced - past the specification and past all whitespace following it. */ - -struct format_data -decode_format (string_ptr, oformat, osize) - char **string_ptr; - char oformat; - char osize; -{ - struct format_data val; - register char *p = *string_ptr; - - val.format = '?'; - val.size = '?'; - val.count = 1; - - if (*p >= '0' && *p <= '9') - val.count = atoi (p); - while (*p >= '0' && *p <= '9') p++; - - /* Now process size or format letters that follow. */ - - while (1) - { - if (*p == 'b' || *p == 'h' || *p == 'w' || *p == 'g') - val.size = *p++; -#ifdef LONG_LONG - else if (*p == 'l') - { - val.size = 'g'; - p++; - } -#endif - else if (*p >= 'a' && *p <= 'z') - val.format = *p++; - else - break; - } - -#ifndef LONG_LONG - /* Make sure 'g' size is not used on integer types. - Well, actually, we can handle hex. */ - if (val.size == 'g' && val.format != 'f' && val.format != 'x') - val.size = 'w'; -#endif - - while (*p == ' ' || *p == '\t') p++; - *string_ptr = p; - - /* Set defaults for format and size if not specified. */ - if (val.format == '?') - { - if (val.size == '?') - { - /* Neither has been specified. */ - val.format = oformat; - val.size = osize; - } - else - /* If a size is specified, any format makes a reasonable - default except 'i'. */ - val.format = oformat == 'i' ? 'x' : oformat; - } - else if (val.size == '?') - switch (val.format) - { - case 'a': - case 's': - /* Addresses must be words. */ - val.size = osize ? 'w' : osize; - break; - case 'f': - /* Floating point has to be word or giantword. */ - if (osize == 'w' || osize == 'g') - val.size = osize; - else - /* Default it to giantword if the last used size is not - appropriate. */ - val.size = osize ? 'g' : osize; - break; - case 'c': - /* Characters default to one byte. */ - val.size = osize ? 'b' : osize; - break; - default: - /* The default is the size most recently specified. */ - val.size = osize; - } - - return val; -} - -/* Print value VAL on stdout according to FORMAT, a letter or 0. - Do not end with a newline. - 0 means print VAL according to its own type. - SIZE is the letter for the size of datum being printed. - This is used to pad hex numbers so they line up. */ - -static void -print_formatted (val, format, size) - register value val; - register char format; - char size; -{ - int len = TYPE_LENGTH (VALUE_TYPE (val)); - - if (VALUE_LVAL (val) == lval_memory) - next_address = VALUE_ADDRESS (val) + len; - - switch (format) - { - case 's': - next_address = VALUE_ADDRESS (val) - + value_print (value_addr (val), stdout, format, Val_pretty_default); - break; - - case 'i': - wrap_here (""); /* Force output out, print_insn not using _filtered */ - next_address = VALUE_ADDRESS (val) - + print_insn (VALUE_ADDRESS (val), stdout); - break; - - default: - if (format == 0 - || TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_ARRAY - || TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_STRUCT - || TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_UNION - || VALUE_REPEATED (val)) - value_print (val, stdout, format, Val_pretty_default); - else - print_scalar_formatted (VALUE_CONTENTS (val), VALUE_TYPE (val), - format, size, stdout); - } -} - -/* Print a scalar of data of type TYPE, pointed to in GDB by VALADDR, - according to letters FORMAT and SIZE on STREAM. - FORMAT may not be zero. Formats s and i are not supported at this level. - - This is how the elements of an array or structure are printed - with a format. */ - -void -print_scalar_formatted (valaddr, type, format, size, stream) - char *valaddr; - struct type *type; - char format; - int size; - FILE *stream; -{ - LONGEST val_long; - int len = TYPE_LENGTH (type); - - if (size == 'g' && sizeof (LONGEST) < 8 - && format == 'x') - { - /* ok, we're going to have to get fancy here. Assumption: a - long is four bytes. FIXME. */ - unsigned long v1, v2; - - v1 = unpack_long (builtin_type_long, valaddr); - v2 = unpack_long (builtin_type_long, valaddr + 4); - -#if TARGET_BYTE_ORDER == LITTLE_ENDIAN - /* Swap the two for printing */ - { - unsigned long tmp; - - tmp = v1; - v1 = v2; - v2 = tmp; - } -#endif - - switch (format) - { - case 'x': - fprintf_filtered (stream, local_hex_format_custom("08x%08"), v1, v2); - break; - default: - error ("Output size \"g\" unimplemented for format \"%c\".", - format); - } - return; - } - - val_long = unpack_long (type, valaddr); - - /* If value is unsigned, truncate it in case negative. */ - if (format != 'd') - { - if (len == sizeof (char)) - val_long &= (1 << 8 * sizeof(char)) - 1; - else if (len == sizeof (short)) - val_long &= (1 << 8 * sizeof(short)) - 1; - else if (len == sizeof (long)) - val_long &= (unsigned long) - 1; - } - - switch (format) - { - case 'x': - if (!size) - { - /* no size specified, like in print. Print varying # of digits. */ -#if defined (LONG_LONG) - fprintf_filtered (stream, local_hex_format_custom("ll"), val_long); -#else /* not LONG_LONG. */ - fprintf_filtered (stream, local_hex_format_custom("l"), val_long); -#endif /* not LONG_LONG. */ - } - else -#if defined (LONG_LONG) - switch (size) - { - case 'b': - fprintf_filtered (stream, local_hex_format_custom("02ll"), val_long); - break; - case 'h': - fprintf_filtered (stream, local_hex_format_custom("04ll"), val_long); - break; - case 'w': - fprintf_filtered (stream, local_hex_format_custom("08ll"), val_long); - break; - case 'g': - fprintf_filtered (stream, local_hex_format_custom("016ll"), val_long); - break; - default: - error ("Undefined output size \"%c\".", size); - } -#else /* not LONG_LONG. */ - switch (size) - { - case 'b': - fprintf_filtered (stream, local_hex_format_custom("02"), val_long); - break; - case 'h': - fprintf_filtered (stream, local_hex_format_custom("04"), val_long); - break; - case 'w': - fprintf_filtered (stream, local_hex_format_custom("08"), val_long); - break; - case 'g': - fprintf_filtered (stream, local_hex_format_custom("016"), val_long); - break; - default: - error ("Undefined output size \"%c\".", size); - } -#endif /* not LONG_LONG */ - break; - - case 'd': -#ifdef LONG_LONG - fprintf_filtered (stream, "%lld", val_long); -#else - fprintf_filtered (stream, "%d", val_long); -#endif - break; - - case 'u': -#ifdef LONG_LONG - fprintf_filtered (stream, "%llu", val_long); -#else - fprintf_filtered (stream, "%u", val_long); -#endif - break; - - case 'o': - if (val_long) -#ifdef LONG_LONG - fprintf_filtered (stream, local_octal_format_custom("ll"), val_long); -#else - fprintf_filtered (stream, local_octal_format(), val_long); -#endif - else - fprintf_filtered (stream, "0"); - break; - - case 'a': - print_address (unpack_pointer (type, valaddr), stream); - break; - - case 'c': - value_print (value_from_longest (builtin_type_char, val_long), stream, 0, - Val_pretty_default); - break; - - case 'f': - if (len == sizeof (float)) - type = builtin_type_float; - else if (len == sizeof (double)) - type = builtin_type_double; - print_floating (valaddr, type, stream); - break; - - case 0: - abort (); - - case 't': - /* Binary; 't' stands for "two". */ - { - char bits[8*(sizeof val_long) + 1]; - char *cp = bits; - int width; - - if (!size) - width = 8*(sizeof val_long); - else - switch (size) - { - case 'b': - width = 8; - break; - case 'h': - width = 16; - break; - case 'w': - width = 32; - break; - case 'g': - width = 64; - break; - default: - error ("Undefined output size \"%c\".", size); - } - - bits[width] = '\0'; - while (width-- > 0) - { - bits[width] = (val_long & 1) ? '1' : '0'; - val_long >>= 1; - } - if (!size) - { - while (*cp && *cp == '0') - cp++; - if (*cp == '\0') - cp--; - } - fprintf_filtered (stream, cp); - } - break; - - default: - error ("Undefined output format \"%c\".", format); - } -} - -/* Specify default address for `x' command. - `info lines' uses this. */ - -void -set_next_address (addr) - CORE_ADDR addr; -{ - next_address = addr; - - /* Make address available to the user as $_. */ - set_internalvar (lookup_internalvar ("_"), - value_from_longest (lookup_pointer_type (builtin_type_void), - (LONGEST) addr)); -} - -/* Optionally print address ADDR symbolically as on STREAM, - after LEADIN. Print nothing if no symbolic name is found nearby. - DO_DEMANGLE controls whether to print a symbol in its native "raw" form, - or to interpret it as a possible C++ name and convert it back to source - form. */ - -void -print_address_symbolic (addr, stream, do_demangle, leadin) - CORE_ADDR addr; - FILE *stream; - int do_demangle; - char *leadin; -{ - int name_location; - register int i = find_pc_misc_function (addr); - - /* If nothing comes out, don't print anything symbolic. */ - - if (i < 0) - return; - - fputs_filtered (leadin, stream); - fputs_filtered ("<", stream); - if (do_demangle) - fputs_demangled (misc_function_vector[i].name, stream, 1); - else - fputs_filtered (misc_function_vector[i].name, stream); - name_location = misc_function_vector[i].address; - if (addr - name_location) - fprintf_filtered (stream, "+%d>", addr - name_location); - else - fputs_filtered (">", stream); -} - -/* Print address ADDR symbolically on STREAM. - First print it as a number. Then perhaps print - after the number. */ - -void -print_address (addr, stream) - CORE_ADDR addr; - FILE *stream; -{ - fprintf_filtered (stream, local_hex_format(), addr); - print_address_symbolic (addr, stream, asm_demangle, " "); -} - -/* Print address ADDR symbolically on STREAM. Parameter DEMANGLE - controls whether to print the symbolic name "raw" or demangled. - Global setting "addressprint" controls whether to print hex address - or not. */ - -void -print_address_demangle (addr, stream, do_demangle) - CORE_ADDR addr; - FILE *stream; - int do_demangle; -{ - if (addr == 0) { - fprintf_filtered (stream, "0"); - } else if (addressprint) { - fprintf_filtered (stream, local_hex_format(), addr); - print_address_symbolic (addr, stream, do_demangle, " "); - } else { - print_address_symbolic (addr, stream, do_demangle, ""); - } -} - - -/* Examine data at address ADDR in format FMT. - Fetch it from memory and print on stdout. */ - -static void -do_examine (fmt, addr) - struct format_data fmt; - CORE_ADDR addr; -{ - register char format = 0; - register char size; - register int count = 1; - struct type *val_type; - register int i; - register int maxelts; - - format = fmt.format; - size = fmt.size; - count = fmt.count; - next_address = addr; - - /* String or instruction format implies fetch single bytes - regardless of the specified size. */ - if (format == 's' || format == 'i') - size = 'b'; - - if (size == 'b') - val_type = builtin_type_char; - else if (size == 'h') - val_type = builtin_type_short; - else if (size == 'w') - val_type = builtin_type_long; - else if (size == 'g') -#ifndef LONG_LONG - val_type = builtin_type_double; -#else - val_type = builtin_type_long_long; -#endif - - maxelts = 8; - if (size == 'w') - maxelts = 4; - if (size == 'g') - maxelts = 2; - if (format == 's' || format == 'i') - maxelts = 1; - - /* Print as many objects as specified in COUNT, at most maxelts per line, - with the address of the next one at the start of each line. */ - - while (count > 0) - { - print_address (next_address, stdout); - printf_filtered (":"); - for (i = maxelts; - i > 0 && count > 0; - i--, count--) - { - printf_filtered ("\t"); - /* Note that print_formatted sets next_address for the next - object. */ - last_examine_address = next_address; - last_examine_value = value_at (val_type, next_address); - print_formatted (last_examine_value, format, size); - } - printf_filtered ("\n"); - fflush (stdout); - } -} - -static void -validate_format (fmt, cmdname) - struct format_data fmt; - char *cmdname; -{ - if (fmt.size != 0) - error ("Size letters are meaningless in \"%s\" command.", cmdname); - if (fmt.count != 1) - error ("Item count other than 1 is meaningless in \"%s\" command.", - cmdname); - if (fmt.format == 'i' || fmt.format == 's') - error ("Format letter \"%c\" is meaningless in \"%s\" command.", - fmt.format, cmdname); -} - -static void -print_command_1 (exp, inspect, voidprint) - char *exp; - int inspect; - int voidprint; -{ - struct expression *expr; - register struct cleanup *old_chain = 0; - register char format = 0; - register value val; - struct format_data fmt; - int cleanup = 0; - - /* Pass inspect flag to the rest of the print routines in a global (sigh). */ - inspect_it = inspect; - - if (exp && *exp == '/') - { - exp++; - fmt = decode_format (&exp, last_format, 0); - validate_format (fmt, "print"); - last_format = format = fmt.format; - } - else - { - fmt.count = 1; - fmt.format = 0; - fmt.size = 0; - } - - if (exp && *exp) - { - extern int objectprint; - struct type *type; - expr = parse_expression (exp); - old_chain = make_cleanup (free_current_contents, &expr); - cleanup = 1; - val = evaluate_expression (expr); - - /* C++: figure out what type we actually want to print it as. */ - type = VALUE_TYPE (val); - - if (objectprint - && (TYPE_CODE (type) == TYPE_CODE_PTR - || TYPE_CODE (type) == TYPE_CODE_REF) - && TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_STRUCT) - { - value v; - - v = value_from_vtable_info (val, TYPE_TARGET_TYPE (type)); - if (v != 0) - { - val = v; - type = VALUE_TYPE (val); - } - } - } - else - val = access_value_history (0); - - if (voidprint || (val && VALUE_TYPE (val) && - TYPE_CODE (VALUE_TYPE (val)) != TYPE_CODE_VOID)) - { - int histindex = record_latest_value (val); - - if (inspect) - printf ("\031(gdb-makebuffer \"%s\" %d '(\"", exp, histindex); - else - if (histindex >= 0) printf_filtered ("$%d = ", histindex); - - print_formatted (val, format, fmt.size); - printf_filtered ("\n"); - if (inspect) - printf("\") )\030"); - } - - if (cleanup) - do_cleanups (old_chain); - inspect_it = 0; /* Reset print routines to normal */ -} - -/* ARGSUSED */ -static void -print_command (exp, from_tty) - char *exp; - int from_tty; -{ - print_command_1 (exp, 0, 1); -} - -/* Same as print, except in epoch, it gets its own window */ -/* ARGSUSED */ -static void -inspect_command (exp, from_tty) - char *exp; - int from_tty; -{ - extern int epoch_interface; - - print_command_1 (exp, epoch_interface, 1); -} - -/* Same as print, except it doesn't print void results. */ -/* ARGSUSED */ -static void -call_command (exp, from_tty) - char *exp; - int from_tty; -{ - print_command_1 (exp, 0, 0); -} - -/* ARGSUSED */ -static void -output_command (exp, from_tty) - char *exp; - int from_tty; -{ - struct expression *expr; - register struct cleanup *old_chain; - register char format = 0; - register value val; - struct format_data fmt; - - if (exp && *exp == '/') - { - exp++; - fmt = decode_format (&exp, 0, 0); - validate_format (fmt, "print"); - format = fmt.format; - } - - expr = parse_expression (exp); - old_chain = make_cleanup (free_current_contents, &expr); - - val = evaluate_expression (expr); - - print_formatted (val, format, fmt.size); - - do_cleanups (old_chain); -} - -/* ARGSUSED */ -static void -set_command (exp, from_tty) - char *exp; - int from_tty; -{ - struct expression *expr = parse_expression (exp); - register struct cleanup *old_chain - = make_cleanup (free_current_contents, &expr); - evaluate_expression (expr); - do_cleanups (old_chain); -} - -/* ARGSUSED */ -static void -address_info (exp, from_tty) - char *exp; - int from_tty; -{ - register struct symbol *sym; - register long val; - int is_a_field_of_this; /* C++: lookup_symbol sets this to nonzero - if exp is a field of `this'. */ - - if (exp == 0) - error ("Argument required."); - - sym = lookup_symbol (exp, get_selected_block (), VAR_NAMESPACE, - &is_a_field_of_this, (struct symtab **)NULL); - if (sym == 0) - { - register int i; - - if (is_a_field_of_this) - { - printf ("Symbol \"%s\" is a field of the local class variable `this'\n", exp); - return; - } - - for (i = 0; i < misc_function_count; i++) - if (!strcmp (misc_function_vector[i].name, exp)) - break; - - if (i < misc_function_count) - printf ("Symbol \"%s\" is at %s in a file compiled without debugging.\n", - exp, local_hex_string(misc_function_vector[i].address)); - else - error ("No symbol \"%s\" in current context.", exp); - return; - } - - printf ("Symbol \"%s\" is ", SYMBOL_NAME (sym)); - val = SYMBOL_VALUE (sym); - - switch (SYMBOL_CLASS (sym)) - { - case LOC_CONST: - case LOC_CONST_BYTES: - printf ("constant"); - break; - - case LOC_LABEL: - printf ("a label at address %s", local_hex_string(SYMBOL_VALUE_ADDRESS (sym))); - break; - - case LOC_REGISTER: - printf ("a variable in register %s", reg_names[val]); - break; - - case LOC_STATIC: - printf ("static storage at address %s", local_hex_string(SYMBOL_VALUE_ADDRESS (sym))); - break; - - case LOC_REGPARM: - printf ("an argument in register %s", reg_names[val]); - break; - - case LOC_ARG: - printf ("an argument at offset %ld", val); - break; - - case LOC_LOCAL_ARG: - printf ("an argument at frame offset %ld", val); - break; - - case LOC_LOCAL: - printf ("a local variable at frame offset %ld", val); - break; - - case LOC_REF_ARG: - printf ("a reference argument at offset %ld", val); - break; - - case LOC_TYPEDEF: - printf ("a typedef"); - break; - - case LOC_BLOCK: - printf ("a function at address %s", - local_hex_string(BLOCK_START (SYMBOL_BLOCK_VALUE (sym)))); - break; - - default: - printf ("of unknown (botched) type"); - break; - } - printf (".\n"); -} - -static void -x_command (exp, from_tty) - char *exp; - int from_tty; -{ - struct expression *expr; - struct format_data fmt; - struct cleanup *old_chain; - struct value *val; - - fmt.format = last_format; - fmt.size = last_size; - fmt.count = 1; - - if (exp && *exp == '/') - { - exp++; - fmt = decode_format (&exp, last_format, last_size); - last_size = fmt.size; - last_format = fmt.format; - } - - /* If we have an expression, evaluate it and use it as the address. */ - - if (exp != 0 && *exp != 0) - { - expr = parse_expression (exp); - /* Cause expression not to be there any more - if this command is repeated with Newline. - But don't clobber a user-defined command's definition. */ - if (from_tty) - *exp = 0; - old_chain = make_cleanup (free_current_contents, &expr); - val = evaluate_expression (expr); - if (TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_REF) - val = value_ind (val); - /* In rvalue contexts, such as this, functions are coerced into - pointers to functions. This makes "x/i main" work. */ - if (/* last_format == 'i' - && */ TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_FUNC - && VALUE_LVAL (val) == lval_memory) - next_address = VALUE_ADDRESS (val); - else - next_address = value_as_pointer (val); - do_cleanups (old_chain); - } - - do_examine (fmt, next_address); - - /* Set a couple of internal variables if appropriate. */ - if (last_examine_value) - { - /* Make last address examined available to the user as $_. Use - the correct pointer type. */ - set_internalvar (lookup_internalvar ("_"), - value_from_longest ( - lookup_pointer_type (VALUE_TYPE (last_examine_value)), - (LONGEST) last_examine_address)); - - /* Make contents of last address examined available to the user as $__.*/ - set_internalvar (lookup_internalvar ("__"), last_examine_value); - } -} - -/* Commands for printing types of things. */ - -/* Print type of EXP, or last thing in value history if EXP == NULL. - show is passed to type_print. */ -static void -whatis_exp (exp, show) - char *exp; - int show; -{ - struct expression *expr; - register value val; - register struct cleanup *old_chain; - - if (exp) - { - expr = parse_expression (exp); - old_chain = make_cleanup (free_current_contents, &expr); - val = evaluate_type (expr); - } - else - val = access_value_history (0); - - printf_filtered ("type = "); - type_print (VALUE_TYPE (val), "", stdout, show); - printf_filtered ("\n"); - - if (exp) - do_cleanups (old_chain); -} - -/* ARGSUSED */ -static void -whatis_command (exp, from_tty) - char *exp; - int from_tty; -{ - /* Most of the time users do not want to see all the fields - in a structure. If they do they can use the "ptype" command. - Hence the "-1" below. */ - whatis_exp (exp, -1); -} - -/* Simple subroutine for ptype_command. */ -static -struct type * -ptype_eval(exp) - struct expression *exp; -{ - if(exp->elts[0].opcode==OP_TYPE) - return exp->elts[1].type; - else - return 0; -} - -/* TYPENAME is either the name of a type, or an expression. */ -/* ARGSUSED */ -static void -ptype_command (typename, from_tty) - char *typename; - int from_tty; -{ - register struct type *type; - struct expression *expr; - register struct cleanup *old_chain; - - if (typename) - { - expr = parse_expression (typename); - old_chain = make_cleanup (free_current_contents, &expr); - type = ptype_eval (expr); - - if(type) - { - printf_filtered ("type = "); - type_print (type, "", stdout, 1); - printf_filtered ("\n"); - do_cleanups (old_chain); - } - else - { - do_cleanups (old_chain); - whatis_exp (typename, 1); - } - } - else - whatis_exp (typename, 1); -} - -enum display_status {disabled, enabled}; - -struct display -{ - /* Chain link to next auto-display item. */ - struct display *next; - /* Expression to be evaluated and displayed. */ - struct expression *exp; - /* Item number of this auto-display item. */ - int number; - /* Display format specified. */ - struct format_data format; - /* Innermost block required by this expression when evaluated */ - struct block *block; - /* Status of this display (enabled or disabled) */ - enum display_status status; -}; - -/* Chain of expressions whose values should be displayed - automatically each time the program stops. */ - -static struct display *display_chain; - -static int display_number; - -/* Add an expression to the auto-display chain. - Specify the expression. */ - -static void -display_command (exp, from_tty) - char *exp; - int from_tty; -{ - struct format_data fmt; - register struct expression *expr; - register struct display *new; - - if (exp == 0) - { - do_displays (); - return; - } - - if (*exp == '/') - { - exp++; - fmt = decode_format (&exp, 0, 0); - if (fmt.size && fmt.format == 0) - fmt.format = 'x'; - if (fmt.format == 'i' || fmt.format == 's') - fmt.size = 'b'; - } - else - { - fmt.format = 0; - fmt.size = 0; - fmt.count = 0; - } - - innermost_block = 0; - expr = parse_expression (exp); - - new = (struct display *) xmalloc (sizeof (struct display)); - - new->exp = expr; - new->block = innermost_block; - new->next = display_chain; - new->number = ++display_number; - new->format = fmt; - new->status = enabled; - display_chain = new; - - if (from_tty && target_has_execution) - do_one_display (new); - - dont_repeat (); -} - -static void -free_display (d) - struct display *d; -{ - free (d->exp); - free (d); -} - -/* Clear out the display_chain. - Done when new symtabs are loaded, since this invalidates - the types stored in many expressions. */ - -void -clear_displays () -{ - register struct display *d; - - while (d = display_chain) - { - free (d->exp); - display_chain = d->next; - free (d); - } -} - -/* Delete the auto-display number NUM. */ - -void -delete_display (num) - int num; -{ - register struct display *d1, *d; - - if (!display_chain) - error ("No display number %d.", num); - - if (display_chain->number == num) - { - d1 = display_chain; - display_chain = d1->next; - free_display (d1); - } - else - for (d = display_chain; ; d = d->next) - { - if (d->next == 0) - error ("No display number %d.", num); - if (d->next->number == num) - { - d1 = d->next; - d->next = d1->next; - free_display (d1); - break; - } - } -} - -/* Delete some values from the auto-display chain. - Specify the element numbers. */ - -static void -undisplay_command (args) - char *args; -{ - register char *p = args; - register char *p1; - register int num; - - if (args == 0) - { - if (query ("Delete all auto-display expressions? ")) - clear_displays (); - dont_repeat (); - return; - } - - while (*p) - { - p1 = p; - while (*p1 >= '0' && *p1 <= '9') p1++; - if (*p1 && *p1 != ' ' && *p1 != '\t') - error ("Arguments must be display numbers."); - - num = atoi (p); - - delete_display (num); - - p = p1; - while (*p == ' ' || *p == '\t') p++; - } - dont_repeat (); -} - -/* Display a single auto-display. - Do nothing if the display cannot be printed in the current context, - or if the display is disabled. */ - -static void -do_one_display (d) - struct display *d; -{ - int within_current_scope; - - if (d->status == disabled) - return; - - if (d->block) - within_current_scope = contained_in (get_selected_block (), d->block); - else - within_current_scope = 1; - if (!within_current_scope) - return; - - current_display_number = d->number; - - printf_filtered ("%d: ", d->number); - if (d->format.size) - { - CORE_ADDR addr; - - printf_filtered ("x/"); - if (d->format.count != 1) - printf_filtered ("%d", d->format.count); - printf_filtered ("%c", d->format.format); - if (d->format.format != 'i' && d->format.format != 's') - printf_filtered ("%c", d->format.size); - printf_filtered (" "); - print_expression (d->exp, stdout); - if (d->format.count != 1) - printf_filtered ("\n"); - else - printf_filtered (" "); - - addr = value_as_pointer (evaluate_expression (d->exp)); - if (d->format.format == 'i') - addr = ADDR_BITS_REMOVE (addr); - - do_examine (d->format, addr); - } - else - { - if (d->format.format) - printf_filtered ("/%c ", d->format.format); - print_expression (d->exp, stdout); - printf_filtered (" = "); - print_formatted (evaluate_expression (d->exp), - d->format.format, d->format.size); - printf_filtered ("\n"); - } - - fflush (stdout); - current_display_number = -1; -} - -/* Display all of the values on the auto-display chain which can be - evaluated in the current scope. */ - -void -do_displays () -{ - register struct display *d; - - for (d = display_chain; d; d = d->next) - do_one_display (d); -} - -/* Delete the auto-display which we were in the process of displaying. - This is done when there is an error or a signal. */ - -void -disable_display (num) - int num; -{ - register struct display *d; - - for (d = display_chain; d; d = d->next) - if (d->number == num) - { - d->status = disabled; - return; - } - printf ("No display number %d.\n", num); -} - -void -disable_current_display () -{ - if (current_display_number >= 0) - { - disable_display (current_display_number); - fprintf (stderr, "Disabling display %d to avoid infinite recursion.\n", - current_display_number); - } - current_display_number = -1; -} - -static void -display_info () -{ - register struct display *d; - - if (!display_chain) - printf ("There are no auto-display expressions now.\n"); - else - printf_filtered ("Auto-display expressions now in effect:\n\ -Num Enb Expression\n"); - - for (d = display_chain; d; d = d->next) - { - printf_filtered ("%d: %c ", d->number, "ny"[(int)d->status]); - if (d->format.size) - printf_filtered ("/%d%c%c ", d->format.count, d->format.size, - d->format.format); - else if (d->format.format) - printf_filtered ("/%c ", d->format.format); - print_expression (d->exp, stdout); - if (d->block && !contained_in (get_selected_block (), d->block)) - printf_filtered (" (cannot be evaluated in the current context)"); - printf_filtered ("\n"); - fflush (stdout); - } -} - -void -enable_display (args) - char *args; -{ - register char *p = args; - register char *p1; - register int num; - register struct display *d; - - if (p == 0) - { - for (d = display_chain; d; d = d->next) - d->status = enabled; - } - else - while (*p) - { - p1 = p; - while (*p1 >= '0' && *p1 <= '9') - p1++; - if (*p1 && *p1 != ' ' && *p1 != '\t') - error ("Arguments must be display numbers."); - - num = atoi (p); - - for (d = display_chain; d; d = d->next) - if (d->number == num) - { - d->status = enabled; - goto win; - } - printf ("No display number %d.\n", num); - win: - p = p1; - while (*p == ' ' || *p == '\t') - p++; - } -} - -/* ARGSUSED */ -void -disable_display_command (args, from_tty) - char *args; - int from_tty; -{ - register char *p = args; - register char *p1; - register struct display *d; - - if (p == 0) - { - for (d = display_chain; d; d = d->next) - d->status = disabled; - } - else - while (*p) - { - p1 = p; - while (*p1 >= '0' && *p1 <= '9') - p1++; - if (*p1 && *p1 != ' ' && *p1 != '\t') - error ("Arguments must be display numbers."); - - disable_display (atoi (p)); - - p = p1; - while (*p == ' ' || *p == '\t') - p++; - } -} - - -/* Print the value in stack frame FRAME of a variable - specified by a struct symbol. */ - -void -print_variable_value (var, frame, stream) - struct symbol *var; - FRAME frame; - FILE *stream; -{ - value val = read_var_value (var, frame); - value_print (val, stream, 0, Val_pretty_default); -} - -/* Print the arguments of a stack frame, given the function FUNC - running in that frame (as a symbol), the info on the frame, - and the number of args according to the stack frame (or -1 if unknown). */ - -/* References here and elsewhere to "number of args according to the - stack frame" appear in all cases to refer to "number of ints of args - according to the stack frame". At least for VAX, i386, isi. */ - -void -print_frame_args (func, fi, num, stream) - struct symbol *func; - struct frame_info *fi; - int num; - FILE *stream; -{ - struct block *b; - int nsyms = 0; - int first = 1; - register int i; - register struct symbol *sym; - register value val; - /* Offset of next stack argument beyond the one we have seen that is - at the highest offset. - -1 if we haven't come to a stack argument yet. */ - long highest_offset = -1; - int arg_size; - /* Number of ints of arguments that we have printed so far. */ - int args_printed = 0; - - if (func) - { - b = SYMBOL_BLOCK_VALUE (func); - nsyms = BLOCK_NSYMS (b); - } - - for (i = 0; i < nsyms; i++) - { - QUIT; - sym = BLOCK_SYM (b, i); - - /* Keep track of the highest stack argument offset seen, and - skip over any kinds of symbols we don't care about. */ - - switch (SYMBOL_CLASS (sym)) { - case LOC_ARG: - case LOC_REF_ARG: - { - long current_offset = SYMBOL_VALUE (sym); - - arg_size = TYPE_LENGTH (SYMBOL_TYPE (sym)); - - /* Compute address of next argument by adding the size of - this argument and rounding to an int boundary. */ - current_offset - = ((current_offset + arg_size + sizeof (int) - 1) - & ~(sizeof (int) - 1)); - - /* If this is the highest offset seen yet, set highest_offset. */ - if (highest_offset == -1 - || (current_offset > highest_offset)) - highest_offset = current_offset; - - /* Add the number of ints we're about to print to args_printed. */ - args_printed += (arg_size + sizeof (int) - 1) / sizeof (int); - } - - /* We care about types of symbols, but don't need to keep track of - stack offsets in them. */ - case LOC_REGPARM: - case LOC_LOCAL_ARG: - break; - - /* Other types of symbols we just skip over. */ - default: - continue; - } - - /* We have to re-look-up the symbol because arguments often have - two entries (one a parameter, one a register or local), and the one - we want is the non-parm, which lookup_symbol will find for - us. After this, sym could be any SYMBOL_CLASS... */ - sym = lookup_symbol (SYMBOL_NAME (sym), - b, VAR_NAMESPACE, (int *)NULL, (struct symtab **)NULL); - - /* Print the current arg. */ - if (! first) - fprintf_filtered (stream, ", "); - wrap_here (" "); - fprint_symbol (stream, SYMBOL_NAME (sym)); - fputs_filtered ("=", stream); - - /* Avoid value_print because it will deref ref parameters. We just - want to print their addresses. Print ??? for args whose address - we do not know. We pass 2 as "recurse" to val_print because our - standard indentation here is 4 spaces, and val_print indents - 2 for each recurse. */ - val = read_var_value (sym, FRAME_INFO_ID (fi)); - if (val) - val_print (VALUE_TYPE (val), VALUE_CONTENTS (val), VALUE_ADDRESS (val), - stream, 0, 0, 2, Val_no_prettyprint); - else - fputs_filtered ("???", stream); - first = 0; - } - - /* Don't print nameless args in situations where we don't know - enough about the stack to find them. */ - if (num != -1) - { - long start; - CORE_ADDR addr; - - if (highest_offset == -1) - start = FRAME_ARGS_SKIP; - else - start = highest_offset; - - addr = FRAME_ARGS_ADDRESS (fi); - if (addr) - print_frame_nameless_args (addr, start, num - args_printed, - first, stream); - } -} - -/* Print nameless args on STREAM. - ARGSADDR is the address of the arglist, START is the offset - of the first nameless arg, and NUM is the number of nameless args to - print. FIRST is nonzero if this is the first argument (not just - the first nameless arg). */ -static void -print_frame_nameless_args (argsaddr, start, num, first, stream) - CORE_ADDR argsaddr; - long start; - int num; - int first; - FILE *stream; -{ - int i; - for (i = 0; i < num; i++) - { - QUIT; - if (!first) - fprintf_filtered (stream, ", "); -#ifndef PRINT_TYPELESS_INTEGER - fprintf_filtered (stream, "%d", - read_memory_integer (argsaddr + start, sizeof (int))); -#else - PRINT_TYPELESS_INTEGER (stream, builtin_type_int, - (LONGEST) - read_memory_integer (argsaddr + start, - sizeof (int))); -#endif - first = 0; - start += sizeof (int); - } -} - -/* ARGSUSED */ -static void -printf_command (arg, from_tty) - char *arg; - int from_tty; -{ - register char *f; - register char *s = arg; - char *string; - value *val_args; - int nargs = 0; - int allocated_args = 20; - char *arg_bytes; - - val_args = (value *) xmalloc (allocated_args * sizeof (value)); - - if (s == 0) - error_no_arg ("format-control string and values to print"); - - /* Skip white space before format string */ - while (*s == ' ' || *s == '\t') s++; - - /* A format string should follow, enveloped in double quotes */ - if (*s++ != '"') - error ("Bad format string, missing '\"'."); - - /* Parse the format-control string and copy it into the string STRING, - processing some kinds of escape sequence. */ - - f = string = (char *) alloca (strlen (s) + 1); - while (*s != '"') - { - int c = *s++; - switch (c) - { - case '\0': - error ("Bad format string, non-terminated '\"'."); - /* doesn't return */ - - case '\\': - switch (c = *s++) - { - case '\\': - *f++ = '\\'; - break; - case 'n': - *f++ = '\n'; - break; - case 't': - *f++ = '\t'; - break; - case 'r': - *f++ = '\r'; - break; - case '"': - *f++ = '"'; - break; - default: - /* ??? TODO: handle other escape sequences */ - error ("Unrecognized \\ escape character in format string."); - } - break; - - default: - *f++ = c; - } - } - - /* Skip over " and following space and comma. */ - s++; - *f++ = '\0'; - while (*s == ' ' || *s == '\t') s++; - - if (*s != ',' && *s != 0) - error ("Invalid argument syntax"); - - if (*s == ',') s++; - while (*s == ' ' || *s == '\t') s++; - - { - /* Now scan the string for %-specs and see what kinds of args they want. - argclass[I] classifies the %-specs so we can give vprintf something - of the right size. */ - - enum argclass {int_arg, string_arg, double_arg, long_long_arg}; - enum argclass *argclass; - int nargs_wanted; - int argindex; - int lcount; - int i; - - argclass = (enum argclass *) alloca (strlen (s) * sizeof *argclass); - nargs_wanted = 0; - f = string; - while (*f) - if (*f++ == '%') - { - lcount = 0; - while (strchr ("0123456789.hlL-+ #", *f)) - { - if (*f == 'l' || *f == 'L') - lcount++; - f++; - } - if (*f == 's') - argclass[nargs_wanted++] = string_arg; - else if (*f == 'e' || *f == 'f' || *f == 'g') - argclass[nargs_wanted++] = double_arg; - else if (lcount > 1) - argclass[nargs_wanted++] = long_long_arg; - else if (*f != '%') - argclass[nargs_wanted++] = int_arg; - f++; - } - - /* Now, parse all arguments and evaluate them. - Store the VALUEs in VAL_ARGS. */ - - while (*s != '\0') - { - char *s1; - if (nargs == allocated_args) - val_args = (value *) xrealloc (val_args, - (allocated_args *= 2) - * sizeof (value)); - s1 = s; - val_args[nargs] = parse_to_comma_and_eval (&s1); - - /* If format string wants a float, unchecked-convert the value to - floating point of the same size */ - - if (argclass[nargs] == double_arg) - { - if (TYPE_LENGTH (VALUE_TYPE (val_args[nargs])) == sizeof (float)) - VALUE_TYPE (val_args[nargs]) = builtin_type_float; - if (TYPE_LENGTH (VALUE_TYPE (val_args[nargs])) == sizeof (double)) - VALUE_TYPE (val_args[nargs]) = builtin_type_double; - } - nargs++; - s = s1; - if (*s == ',') - s++; - } - - if (nargs != nargs_wanted) - error ("Wrong number of arguments for specified format-string"); - - /* Now lay out an argument-list containing the arguments - as doubles, integers and C pointers. */ - - arg_bytes = (char *) alloca (sizeof (double) * nargs); - argindex = 0; - for (i = 0; i < nargs; i++) - { - if (argclass[i] == string_arg) - { - char *str; - CORE_ADDR tem; - int j; - tem = value_as_pointer (val_args[i]); - - /* This is a %s argument. Find the length of the string. */ - for (j = 0; ; j++) - { - char c; - QUIT; - read_memory (tem + j, &c, 1); - if (c == 0) - break; - } - - /* Copy the string contents into a string inside GDB. */ - str = (char *) alloca (j + 1); - read_memory (tem, str, j); - str[j] = 0; - - /* Pass address of internal copy as the arg to vprintf. */ - *((int *) &arg_bytes[argindex]) = (int) str; - argindex += sizeof (int); - } - else if (VALUE_TYPE (val_args[i])->code == TYPE_CODE_FLT) - { - *((double *) &arg_bytes[argindex]) = value_as_double (val_args[i]); - argindex += sizeof (double); - } - else -#ifdef LONG_LONG - if (argclass[i] == long_long_arg) - { - *(long long *) &arg_bytes[argindex] = value_as_long (val_args[i]); - argindex += sizeof (long long); - } - else -#endif - { - *((long *) &arg_bytes[argindex]) = value_as_long (val_args[i]); - argindex += sizeof (long); - } - } - } - - /* There is not a standard way to make a va_list, so we need - to do various things for different systems. */ -#if defined (__INT_VARARGS_H) - { - va_list list; - - list.__va_arg = 0; - list.__va_stk = (int *) arg_bytes; - list.__va_reg = (int *) arg_bytes; - vprintf (string, list); - } -#else /* No __INT_VARARGS_H. */ - vprintf (string, arg_bytes); -#endif /* No __INT_VARARGS_H. */ -} - -/* Helper function for asdump_command. Finds the bounds of a function - for a specified section of text. PC is an address within the - function which you want bounds for; *LOW and *HIGH are set to the - beginning (inclusive) and end (exclusive) of the function. This - function returns 1 on success and 0 on failure. */ - -static int -containing_function_bounds (pc, low, high) - CORE_ADDR pc, *low, *high; -{ - int scan; - - if (!find_pc_partial_function (pc, 0, low)) - return 0; - - scan = *low; - do { - scan++; - if (!find_pc_partial_function (scan, 0, high)) - return 0; - } while (*low == *high); - - return 1; -} - -/* Dump a specified section of assembly code. With no command line - arguments, this command will dump the assembly code for the - function surrounding the pc value in the selected frame. With one - argument, it will dump the assembly code surrounding that pc value. - Two arguments are interpeted as bounds within which to dump - assembly. */ - -/* ARGSUSED */ -static void -disassemble_command (arg, from_tty) - char *arg; - int from_tty; -{ - CORE_ADDR low, high; - CORE_ADDR pc; - char *space_index; - - if (!arg) - { - if (!selected_frame) - error ("No frame selected.\n"); - - pc = get_frame_pc (selected_frame); - if (!containing_function_bounds (pc, &low, &high)) - error ("No function contains pc specified by selected frame.\n"); - } - else if (!(space_index = (char *) strchr (arg, ' '))) - { - /* One argument. */ - pc = parse_and_eval_address (arg); - if (!containing_function_bounds (pc, &low, &high)) - error ("No function contains specified pc.\n"); - } - else - { - /* Two arguments. */ - *space_index = '\0'; - low = parse_and_eval_address (arg); - high = parse_and_eval_address (space_index + 1); - } - - printf_filtered ("Dump of assembler code "); - if (!space_index) - { - char *name; - find_pc_partial_function (pc, &name, 0); - printf_filtered ("for function %s:\n", name); - } - else - printf_filtered ("from %s ", local_hex_string(low)); - printf_filtered ("to %s:\n", local_hex_string(high)); - - /* Dump the specified range. */ - for (pc = low; pc < high; ) - { - QUIT; - print_address (pc, stdout); - printf_filtered (":\t"); - pc += print_insn (pc, stdout); - printf_filtered ("\n"); - } - printf_filtered ("End of assembler dump.\n"); - fflush (stdout); -} - - -void -_initialize_printcmd () -{ - current_display_number = -1; - - add_info ("address", address_info, - "Describe where variable VAR is stored."); - - add_com ("x", class_vars, x_command, - "Examine memory: x/FMT ADDRESS.\n\ -ADDRESS is an expression for the memory address to examine.\n\ -FMT is a repeat count followed by a format letter and a size letter.\n\ -Format letters are o(octal), x(hex), d(decimal), u(unsigned decimal),\n\ - f(float), a(address), i(instruction), c(char) and s(string).\n\ -Size letters are b(byte), h(halfword), w(word), g(giant, 8 bytes).\n\ - g is meaningful only with f, for type double.\n\ -The specified number of objects of the specified size are printed\n\ -according to the format.\n\n\ -Defaults for format and size letters are those previously used.\n\ -Default count is 1. Default address is following last thing printed\n\ -with this command or \"print\"."); - - add_com ("disassemble", class_vars, disassemble_command, - "Disassemble a specified section of memory.\n\ -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."); - - add_com ("ptype", class_vars, ptype_command, - "Print definition of type TYPE.\n\ -Argument may be a type name defined by typedef, or \"struct STRUCTNAME\"\n\ -or \"union UNIONNAME\" or \"enum ENUMNAME\".\n\ -The selected stack frame's lexical context is used to look up the name."); - - add_com ("whatis", class_vars, whatis_command, - "Print data type of expression EXP."); - -#if 0 - add_com ("whereis", class_vars, whereis_command, - "Print line number and file of definition of variable."); -#endif - - add_info ("display", display_info, - "Expressions to display when program stops, with code numbers."); - - add_cmd ("undisplay", class_vars, undisplay_command, - "Cancel some expressions to be displayed when program stops.\n\ -Arguments are the code numbers of the expressions to stop displaying.\n\ -No argument means cancel all automatic-display expressions.\n\ -\"delete display\" has the same effect as this command.\n\ -Do \"info display\" to see current list of code numbers.", - &cmdlist); - - add_com ("display", class_vars, display_command, - "Print value of expression EXP each time the program stops.\n\ -/FMT may be used before EXP as in the \"print\" command.\n\ -/FMT \"i\" or \"s\" or including a size-letter is allowed,\n\ -as in the \"x\" command, and then EXP is used to get the address to examine\n\ -and examining is done as in the \"x\" command.\n\n\ -With no argument, display all currently requested auto-display expressions.\n\ -Use \"undisplay\" to cancel display requests previously made."); - - add_cmd ("display", class_vars, enable_display, - "Enable some expressions to be displayed when program stops.\n\ -Arguments are the code numbers of the expressions to resume displaying.\n\ -No argument means enable all automatic-display expressions.\n\ -Do \"info display\" to see current list of code numbers.", &enablelist); - - add_cmd ("display", class_vars, disable_display_command, - "Disable some expressions to be displayed when program stops.\n\ -Arguments are the code numbers of the expressions to stop displaying.\n\ -No argument means disable all automatic-display expressions.\n\ -Do \"info display\" to see current list of code numbers.", &disablelist); - - add_cmd ("display", class_vars, undisplay_command, - "Cancel some expressions to be displayed when program stops.\n\ -Arguments are the code numbers of the expressions to stop displaying.\n\ -No argument means cancel all automatic-display expressions.\n\ -Do \"info display\" to see current list of code numbers.", &deletelist); - - add_com ("printf", class_vars, printf_command, - "printf \"printf format string\", arg1, arg2, arg3, ..., argn\n\ -This is useful for formatted output in user-defined commands."); - add_com ("output", class_vars, output_command, - "Like \"print\" but don't put in value history and don't print newline.\n\ -This is useful in user-defined commands."); - - add_prefix_cmd ("set", class_vars, set_command, -"Perform an assignment VAR = EXP.\n\ -You must type the \"=\". VAR may be a debugger \"convenience\" variable\n\ -(names starting with $), a register (a few standard names starting with $),\n\ -or an actual variable in the program being debugged. EXP is any expression.\n\ -Use \"set variable\" for variables with names identical to set subcommands.\n\ -\nWith a subcommand, this command modifies parts of the gdb environment.\n\ -You can see these environment settings with the \"show\" command.", - &setlist, "set ", 1, &cmdlist); - - /* "call" is the same as "set", but handy for dbx users to call fns. */ - add_com ("call", class_vars, call_command, - "Call a function in the inferior process.\n\ -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."); - - add_cmd ("variable", class_vars, set_command, - "Perform an assignment VAR = EXP.\n\ -You must type the \"=\". VAR may be a debugger \"convenience\" variable\n\ -(names starting with $), a register (a few standard names starting with $),\n\ -or an actual variable in the program being debugged. EXP is any expression.\n\ -This may usually be abbreviated to simply \"set\".", - &setlist); - - add_com ("print", class_vars, print_command, - concat ("Print value of expression EXP.\n\ -Variables accessible are those of the lexical environment of the selected\n\ -stack frame, plus all those whose scope is global or an entire file.\n\ -\n\ -$NUM gets previous value number NUM. $ and $$ are the last two values.\n\ -$$NUM refers to NUM'th value back from the last one.\n\ -Names starting with $ refer to registers (with the values they would have\n\ -if the program were to return to the stack frame now selected, restoring\n\ -all registers saved by frames farther in) or else to debugger\n\ -\"convenience\" variables (any such name not a known register).\n\ -Use assignment expressions to give values to convenience variables.\n", - "\n\ -{TYPE}ADREXP refers to a datum of data type TYPE, located at address ADREXP.\n\ -@ is a binary operator for treating consecutive data objects\n\ -anywhere in memory as an array. FOO@NUM gives an array whose first\n\ -element is FOO, whose second element is stored in the space following\n\ -where FOO is stored, etc. FOO must be an expression whose value\n\ -resides in memory.\n", - "\n\ -EXP may be preceded with /FMT, where FMT is a format letter\n\ -but no count or size letter (see \"x\" command).")); - add_com_alias ("p", "print", class_vars, 1); - - 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."); -} diff --git a/gdb/procfs.c b/gdb/procfs.c deleted file mode 100644 index c745997273d..00000000000 --- a/gdb/procfs.c +++ /dev/null @@ -1,1049 +0,0 @@ -/* Machine independent support for SVR4 /proc (process file system) for GDB. - Copyright (C) 1991 Free Software Foundation, Inc. - Written by Fred Fish at 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - - -/* N O T E S - -For information on the details of using /proc consult section proc(4) -in the UNIX System V Release 4 System Administrator's Reference Manual. - -The general register and floating point register sets are manipulated by -separate ioctl's. This file makes the assumption that if FP0_REGNUM is -defined, then support for the floating point register set is desired, -regardless of whether or not the actual target has floating point hardware. - - */ - - - -#include "param.h" - -#ifdef USE_PROC_FS /* Entire file goes away if not using /proc */ - -#include -#include -#include -#include - -#include "defs.h" -#include "ansidecl.h" -#include "inferior.h" -#include "target.h" - -#ifndef PROC_NAME_FMT -#define PROC_NAME_FMT "/proc/%d" -#endif - -extern void EXFUN(supply_gregset, (gregset_t *gregsetp)); -extern void EXFUN(fill_gregset, (gregset_t *gresetp, int regno)); - -#if defined (FP0_REGNUM) -extern void EXFUN(supply_fpregset, (fpregset_t *fpregsetp)); -extern void EXFUN(fill_fpregset, (fpregset_t *fpresetp, int regno)); -#endif - -#if 1 /* FIXME: Gross and ugly hack to resolve coredep.c global */ -CORE_ADDR kernel_u_addr; -#endif - -/* All access to the inferior, either one started by gdb or one that has - been attached to, is controlled by an instance of a procinfo structure, - defined below. Since gdb currently only handles one inferior at a time, - the procinfo structure is statically allocated and only one exists at - any given time. */ - -struct procinfo { - int valid; /* Nonzero if pid, fd, & pathname are valid */ - int pid; /* Process ID of inferior */ - int fd; /* File descriptor for /proc entry */ - char *pathname; /* Pathname to /proc entry */ - int was_stopped; /* Nonzero if was stopped prior to attach */ - prrun_t prrun; /* Control state when it is run */ - prstatus_t prstatus; /* Current process status info */ - gregset_t gregset; /* General register set */ - fpregset_t fpregset; /* Floating point register set */ - fltset_t fltset; /* Current traced hardware fault set */ - sigset_t trace; /* Current traced signal set */ - sysset_t exitset; /* Current traced system call exit set */ - sysset_t entryset; /* Current traced system call entry set */ -} pi; - -/* Forward declarations of static functions so we don't have to worry - about ordering within this file. The EXFUN macro may be slightly - misleading. Should probably be called DCLFUN instead, or something - more intuitive, since it can be used for both static and external - definitions. */ - -static void EXFUN(proc_init_failed, (char *why)); -static int EXFUN(open_proc_file, (int pid)); -static void EXFUN(close_proc_file, (void)); -static void EXFUN(unconditionally_kill_inferior, (void)); - -/* - -GLOBAL FUNCTION - - ptrace -- override library version to force errors for /proc version - -SYNOPSIS - - int ptrace (int request, int pid, int arg3, int arg4) - -DESCRIPTION - - When gdb is configured to use /proc, it should not be calling - or otherwise attempting to use ptrace. In order to catch errors - where use of /proc is configured, but some routine is still calling - ptrace, we provide a local version of a function with that name - that does nothing but issue an error message. -*/ - -int -DEFUN(ptrace, (request, pid, arg3, arg4), - int request AND - int pid AND - int arg3 AND - int arg4) -{ - error ("internal error - there is a call to ptrace() somewhere"); - /*NOTREACHED*/ -} - -/* - -GLOBAL FUNCTION - - kill_inferior_fast -- kill inferior while gdb is exiting - -SYNOPSIS - - void kill_inferior_fast (void) - -DESCRIPTION - - This is used when GDB is exiting. It gives less chance of error. - -NOTES - - Don't attempt to kill attached inferiors since we may be called - when gdb is in the process of aborting, and killing the attached - inferior may be very anti-social. This is particularly true if we - were attached just so we could use the /proc facilities to get - detailed information about it's status. - -*/ - -void -DEFUN_VOID(kill_inferior_fast) -{ - if (inferior_pid != 0 && !attach_flag) - { - unconditionally_kill_inferior (); - } -} - -/* - -GLOBAL FUNCTION - - kill_inferior - kill any currently inferior - -SYNOPSIS - - void kill_inferior (void) - -DESCRIPTION - - Kill any current inferior. - -NOTES - - Kills even attached inferiors. Presumably the user has already - been prompted that the inferior is an attached one rather than - one started by gdb. (FIXME?) - -*/ - -void -DEFUN_VOID(kill_inferior) -{ - if (inferior_pid != 0) - { - unconditionally_kill_inferior (); - target_mourn_inferior (); - } -} - -/* - -LOCAL FUNCTION - - unconditionally_kill_inferior - terminate the inferior - -SYNOPSIS - - static void unconditionally_kill_inferior (void) - -DESCRIPTION - - Kill the current inferior. Should not be called until it - is at least tested that there is an inferior. - -NOTE - - A possibly useful enhancement would be to first try sending - the inferior a terminate signal, politely asking it to commit - suicide, before we murder it. - -*/ - -static void -DEFUN_VOID(unconditionally_kill_inferior) -{ - int signo; - - signo = SIGKILL; - (void) ioctl (pi.fd, PIOCKILL, &signo); - close_proc_file (); - wait ((int *) 0); -} - -/* - -GLOBAL FUNCTION - - child_xfer_memory -- copy data to or from inferior memory space - -SYNOPSIS - - int child_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, - int dowrite, struct target_ops target) - -DESCRIPTION - - Copy LEN bytes to/from inferior's memory starting at MEMADDR - from/to debugger memory starting at MYADDR. Copy from inferior - if DOWRITE is zero or to inferior if DOWRITE is nonzero. - - 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. - -NOTES - - The /proc interface makes this an almost trivial task. - */ - - -int -DEFUN(child_xfer_memory, (memaddr, myaddr, len, dowrite, target), - CORE_ADDR memaddr AND - char *myaddr AND - int len AND - int dowrite AND - struct target_ops target /* ignored */) -{ - int nbytes = 0; - - if (lseek (pi.fd, (off_t) memaddr, 0) == (off_t) memaddr) - { - if (dowrite) - { - nbytes = write (pi.fd, myaddr, len); - } - else - { - nbytes = read (pi.fd, myaddr, len); - } - if (nbytes < 0) - { - nbytes = 0; - } - } - return (nbytes); -} - -/* - -GLOBAL FUNCTION - - store_inferior_registers -- copy register values back to inferior - -SYNOPSIS - - void store_inferior_registers (int regno) - -DESCRIPTION - - Store our current register values back into the inferior. If - REGNO is -1 then store all the register, otherwise store just - the value specified by REGNO. - -NOTES - - If we are storing only a single register, we first have to get all - the current values from the process, overwrite the desired register - in the gregset with the one we want from gdb's registers, and then - send the whole set back to the process. For writing all the - registers, all we have to do is generate the gregset and send it to - the process. - - Also note that the process has to be stopped on an event of interest - for this to work, which basically means that it has to have been - run under the control of one of the other /proc ioctl calls and not - ptrace. Since we don't use ptrace anyway, we don't worry about this - fine point, but it is worth noting for future reference. - - Gdb is confused about what this function is supposed to return. - Some versions return a value, others return nothing. Some are - declared to return a value and actually return nothing. Gdb ignores - anything returned. (FIXME) - - */ - -void -DEFUN(store_inferior_registers, (regno), - int regno) -{ - if (regno != -1) - { - (void) ioctl (pi.fd, PIOCGREG, &pi.gregset); - } - fill_gregset (&pi.gregset, regno); - (void) ioctl (pi.fd, PIOCSREG, &pi.gregset); - -#if defined (FP0_REGNUM) - - /* Now repeat everything using the floating point register set, if the - target has floating point hardware. Since we ignore the returned value, - we'll never know whether it worked or not anyway. */ - - if (regno != -1) - { - (void) ioctl (pi.fd, PIOCGFPREG, &pi.fpregset); - } - fill_fpregset (&pi.fpregset, regno); - (void) ioctl (pi.fd, PIOCSFPREG, &pi.fpregset); - -#endif /* FP0_REGNUM */ - -} - -/* - -GLOBAL FUNCTION - - inferior_proc_init - initialize access to a /proc entry - -SYNOPSIS - - void inferior_proc_init (int pid) - -DESCRIPTION - - When gdb starts an inferior, this function is called in the parent - process immediately after the fork. It waits for the child to stop - on the return from the exec system call (the child itself takes care - of ensuring that this is set up), then sets up the set of signals - and faults that are to be traced. - -NOTES - - If proc_init_failed ever gets called, control returns to the command - processing loop via the standard error handling code. - */ - -void -DEFUN(inferior_proc_init, (int pid), - int pid) -{ - if (!open_proc_file (pid)) - { - proc_init_failed ("can't open process file"); - } - else - { - (void) memset (&pi.prrun, 0, sizeof (pi.prrun)); - prfillset (&pi.prrun.pr_trace); - prfillset (&pi.prrun.pr_fault); - prdelset (&pi.prrun.pr_fault, FLTPAGE); - if (ioctl (pi.fd, PIOCWSTOP, &pi.prstatus) < 0) - { - proc_init_failed ("PIOCWSTOP failed"); - } - else if (ioctl (pi.fd, PIOCSTRACE, &pi.prrun.pr_trace) < 0) - { - proc_init_failed ("PIOCSTRACE failed"); - } - else if (ioctl (pi.fd, PIOCSFAULT, &pi.prrun.pr_fault) < 0) - { - proc_init_failed ("PIOCSFAULT failed"); - } - } -} - -/* - -GLOBAL FUNCTION - - proc_set_exec_trap -- arrange for exec'd child to halt at startup - -SYNOPSIS - - void proc_set_exec_trap (void) - -DESCRIPTION - - This function is called in the child process when starting up - an inferior, prior to doing the exec of the actual inferior. - It sets the child process's exitset to make exit from the exec - system call an event of interest to stop on, and then simply - returns. The child does the exec, the system call returns, and - the child stops at the first instruction, ready for the gdb - parent process to take control of it. - -NOTE - - We need to use all local variables since the child may be sharing - it's data space with the parent, if vfork was used rather than - fork. - */ - -void -DEFUN_VOID(proc_set_exec_trap) -{ - sysset_t exitset; - auto char procname[32]; - int fd; - - (void) sprintf (procname, PROC_NAME_FMT, getpid ()); - if ((fd = open (procname, O_RDWR)) < 0) - { - perror (procname); - fflush (stderr); - _exit (127); - } - premptyset (&exitset); - praddset (&exitset, SYS_exec); - praddset (&exitset, SYS_execve); - if (ioctl (fd, PIOCSEXIT, &exitset) < 0) - { - perror (procname); - fflush (stderr); - _exit (127); - } -} - - -#ifdef ATTACH_DETACH - -/* - -GLOBAL FUNCTION - - attach -- attach to an already existing process - -SYNOPSIS - - int attach (int pid) - -DESCRIPTION - - Attach to an already existing process with the specified process - id. If the process is not already stopped, query whether to - stop it or not. - -NOTES - - The option of stopping at attach time is specific to the /proc - versions of gdb. Versions using ptrace force the attachee - to stop. - -*/ - -int -DEFUN(attach, (pid), - int pid) -{ - if (!open_proc_file (pid)) - { - perror_with_name (pi.pathname); - /* NOTREACHED */ - } - - /* Get current status of process and if it is not already stopped, - then stop it. Remember whether or not it was stopped when we first - examined it. */ - - if (ioctl (pi.fd, PIOCSTATUS, &pi.prstatus) < 0) - { - print_sys_errmsg (pi.pathname, errno); - close_proc_file (); - error ("PIOCSTATUS failed"); - } - if (pi.prstatus.pr_flags & (PR_STOPPED | PR_ISTOP)) - { - pi.was_stopped = 1; - } - else - { - pi.was_stopped = 0; - if (query ("Process is currently running, stop it? ")) - { - if (ioctl (pi.fd, PIOCSTOP, &pi.prstatus) < 0) - { - print_sys_errmsg (pi.pathname, errno); - close_proc_file (); - error ("PIOCSTOP failed"); - } - } - } - - /* Remember some things about the inferior that we will, or might, change - so that we can restore them when we detach. */ - - (void) ioctl (pi.fd, PIOCGTRACE, &pi.trace); - (void) ioctl (pi.fd, PIOCGFAULT, &pi.fltset); - (void) ioctl (pi.fd, PIOCGENTRY, &pi.entryset); - (void) ioctl (pi.fd, PIOCGEXIT, &pi.exitset); - - /* Set up trace and fault sets, as gdb expects them. */ - - (void) memset (&pi.prrun, 0, sizeof (pi.prrun)); - prfillset (&pi.prrun.pr_trace); - prfillset (&pi.prrun.pr_fault); - prdelset (&pi.prrun.pr_fault, FLTPAGE); - if (ioctl (pi.fd, PIOCSFAULT, &pi.prrun.pr_fault)) - { - print_sys_errmsg ("PIOCSFAULT failed"); - } - if (ioctl (pi.fd, PIOCSTRACE, &pi.prrun.pr_trace)) - { - print_sys_errmsg ("PIOCSTRACE failed"); - } - attach_flag = 1; - return (pid); -} - -/* - -GLOBAL FUNCTION - - detach -- detach from an attached-to process - -SYNOPSIS - - void detach (int signal) - -DESCRIPTION - - Detach from the current attachee. - - If signal is non-zero, the attachee is started running again and sent - the specified signal. - - If signal is zero and the attachee was not already stopped when we - attached to it, then we make it runnable again when we detach. - - Otherwise, we query whether or not to make the attachee runnable - again, since we may simply want to leave it in the state it was in - when we attached. - - We report any problems, but do not consider them errors, since we - MUST detach even if some things don't seem to go right. This may not - be the ideal situation. (FIXME). - */ - -void -DEFUN(detach, (signal), - int signal) -{ - if (signal) - { - struct siginfo siginfo; - siginfo.si_signo = signal; - siginfo.si_code = 0; - siginfo.si_errno = 0; - if (ioctl (pi.fd, PIOCSSIG, &siginfo) < 0) - { - print_sys_errmsg (pi.pathname, errno); - printf ("PIOCSSIG failed.\n"); - } - } - if (ioctl (pi.fd, PIOCSEXIT, &pi.exitset) < 0) - { - print_sys_errmsg (pi.pathname, errno); - printf ("PIOCSEXIT failed.\n"); - } - if (ioctl (pi.fd, PIOCSENTRY, &pi.entryset) < 0) - { - print_sys_errmsg (pi.pathname, errno); - printf ("PIOCSENTRY failed.\n"); - } - if (ioctl (pi.fd, PIOCSTRACE, &pi.trace) < 0) - { - print_sys_errmsg (pi.pathname, errno); - printf ("PIOCSTRACE failed.\n"); - } - if (ioctl (pi.fd, PIOCSFAULT, &pi.fltset) < 0) - { - print_sys_errmsg (pi.pathname, errno); - printf ("PIOCSFAULT failed.\n"); - } - if (ioctl (pi.fd, PIOCSTATUS, &pi.prstatus) < 0) - { - print_sys_errmsg (pi.pathname, errno); - printf ("PIOCSTATUS failed.\n"); - } - else - { - if (signal || (pi.prstatus.pr_flags & (PR_STOPPED | PR_ISTOP))) - { - if (signal || !pi.was_stopped || - query ("Was stopped when attached, make it runnable again? ")) - { - (void) memset (&pi.prrun, 0, sizeof (pi.prrun)); - pi.prrun.pr_flags = PRCFAULT; - if (ioctl (pi.fd, PIOCRUN, &pi.prrun)) - { - print_sys_errmsg (pi.pathname, errno); - printf ("PIOCRUN failed.\n"); - } - } - } - } - close_proc_file (); - attach_flag = 0; -} - -#endif /* ATTACH_DETACH */ - -/* - -GLOBAL FUNCTION - - proc_wait -- emulate wait() as much as possible - -SYNOPSIS - - int proc_wait (int *statloc) - -DESCRIPTION - - Try to emulate wait() as much as possible. Not sure why we can't - just use wait(), but it seems to have problems when applied to a - process being controlled with the /proc interface. - -NOTES - - We have a race problem here with no obvious solution. We need to let - the inferior run until it stops on an event of interest, which means - that we need to use the PIOCWSTOP ioctl. However, we cannot use this - ioctl if the process is already stopped on something that is not an - event of interest, or the call will hang indefinitely. Thus we first - use PIOCSTATUS to see if the process is not stopped. If not, then we - use PIOCWSTOP. But during the window between the two, if the process - stops for any reason that is not an event of interest (such as a job - control signal) then gdb will hang. One possible workaround is to set - an alarm to wake up every minute of so and check to see if the process - is still running, and if so, then reissue the PIOCWSTOP. But this is - a real kludge, so has not been implemented. FIXME: investigate - alternatives. - - FIXME: Investigate why wait() seems to have problems with programs - being control by /proc routines. - - */ - -int -DEFUN(proc_wait, (statloc), - int *statloc) -{ - short what; - short why; - int statval = 0; - int checkerr = 0; - int rtnval = -1; - - if (ioctl (pi.fd, PIOCSTATUS, &pi.prstatus) < 0) - { - checkerr++; - } - else if (!(pi.prstatus.pr_flags & (PR_STOPPED | PR_ISTOP))) - { - if (ioctl (pi.fd, PIOCWSTOP, &pi.prstatus) < 0) - { - checkerr++; - } - } - if (checkerr) - { - if (errno == ENOENT) - { - rtnval = wait (&statval); - if (rtnval != inferior_pid) - { - error ("PIOCWSTOP, wait failed, returned %d", rtnval); - /* NOTREACHED */ - } - } - else - { - print_sys_errmsg (pi.pathname, errno); - error ("PIOCSTATUS or PIOCWSTOP failed."); - /* NOTREACHED */ - } - } - else if (pi.prstatus.pr_flags & (PR_STOPPED | PR_ISTOP)) - { - rtnval = pi.prstatus.pr_pid; - why = pi.prstatus.pr_why; - what = pi.prstatus.pr_what; - if (why == PR_SIGNALLED) - { - statval = (what << 8) | 0177; - } - else if ((why == PR_SYSEXIT) && - (what == SYS_exec || what == SYS_execve)) - { - statval = (SIGTRAP << 8) | 0177; - } - else if (why == PR_REQUESTED) - { - statval = (SIGSTOP << 8) | 0177; - } - else if (why == PR_JOBCONTROL) - { - statval = (what << 8) | 0177; - } - else if (why == PR_FAULTED) - { - switch (what) - { - case FLTPRIV: - case FLTILL: - statval = (SIGILL << 8) | 0177; - break; - case FLTBPT: - case FLTTRACE: - statval = (SIGTRAP << 8) | 0177; - break; - case FLTSTACK: - case FLTACCESS: - case FLTBOUNDS: - statval = (SIGSEGV << 8) | 0177; - break; - case FLTIOVF: - case FLTIZDIV: - case FLTFPE: - statval = (SIGFPE << 8) | 0177; - break; - case FLTPAGE: /* Recoverable page fault */ - default: - rtnval = -1; - error ("PIOCWSTOP, unknown why %d, what %d", why, what); - /* NOTREACHED */ - } - } - else - { - rtnval = -1; - error ("PIOCWSTOP, unknown why %d, what %d", why, what); - /* NOTREACHED */ - } - } - else - { - error ("PIOCWSTOP, stopped for unknown/unhandled reason, flags %#x", - pi.prstatus.pr_flags); - /* NOTREACHED */ - } - if (statloc) - { - *statloc = statval; - } - return (rtnval); -} - -/* - -GLOBAL FUNCTION - - child_resume -- resume execution of the inferior process - -SYNOPSIS - - void child_resume (int step, int signal) - -DESCRIPTION - - Resume execution of the inferior process. If STEP is nozero, then - just single step it. If SIGNAL is nonzero, restart it with that - signal activated. - -NOTE - - It may not be absolutely necessary to specify the PC value for - restarting, but to be safe we use the value that gdb considers - to be current. One case where this might be necessary is if the - user explicitly changes the PC value that gdb considers to be - current. FIXME: Investigate if this is necessary or not. - */ - -void -DEFUN(child_resume, (step, signal), - int step AND - int signal) -{ - errno = 0; - pi.prrun.pr_flags = PRSVADDR | PRSTRACE | PRSFAULT | PRCFAULT; - pi.prrun.pr_vaddr = (caddr_t) *(int *) ®isters[REGISTER_BYTE (PC_REGNUM)]; - if (signal) - { - if (signal != pi.prstatus.pr_cursig) - { - struct siginfo siginfo; - siginfo.si_signo = signal; - siginfo.si_code = 0; - siginfo.si_errno = 0; - (void) ioctl (pi.fd, PIOCSSIG, &siginfo); - } - } - else - { - pi.prrun.pr_flags |= PRCSIG; - } - if (step) - { - pi.prrun.pr_flags |= PRSTEP; - } - if (ioctl (pi.fd, PIOCRUN, &pi.prrun) != 0) - { - perror_with_name (pi.pathname); - /* NOTREACHED */ - } -} - -/* - -GLOBAL FUNCTION - - fetch_inferior_registers -- fetch current registers from inferior - -SYNOPSIS - - void fetch_inferior_registers (void) - -DESCRIPTION - - Read the current values of the inferior's registers, both the - general register set and floating point registers (if supported) - and update gdb's idea of their current values. - -*/ - -void -DEFUN_VOID(fetch_inferior_registers) -{ - if (ioctl (pi.fd, PIOCGREG, &pi.gregset) != -1) - { - supply_gregset (&pi.gregset); - } -#if defined (FP0_REGNUM) - if (ioctl (pi.fd, PIOCGFPREG, &pi.fpregset) != -1) - { - supply_fpregset (&pi.fpregset); - } -#endif -} - -/* - -GLOBAL FUNCTION - - fetch_core_registers -- fetch current registers from core file data - -SYNOPSIS - - void fetch_core_registers (char *core_reg_sect, unsigned core_reg_size, - int which) - -DESCRIPTION - - Read the values of either the general register set (WHICH equals 0) - or the floating point register set (WHICH equals 2) from the core - file data (pointed to by CORE_REG_SECT), and update gdb's idea of - their current values. The CORE_REG_SIZE parameter is ignored. - -NOTES - - Use the indicated sizes to validate the gregset and fpregset - structures. -*/ - -void -fetch_core_registers (core_reg_sect, core_reg_size, which) - char *core_reg_sect; - unsigned core_reg_size; - int which; -{ - - if (which == 0) - { - if (core_reg_size != sizeof (pi.gregset)) - { - warning ("wrong size gregset struct in core file"); - } - else - { - (void) memcpy ((char *) &pi.gregset, core_reg_sect, - sizeof (pi.gregset)); - supply_gregset (&pi.gregset); - } - } - else if (which == 2) - { - if (core_reg_size != sizeof (pi.fpregset)) - { - warning ("wrong size fpregset struct in core file"); - } - else - { - (void) memcpy ((char *) &pi.fpregset, core_reg_sect, - sizeof (pi.fpregset)); -#if defined (FP0_REGNUM) - supply_fpregset (&pi.fpregset); -#endif - } - } -} - -/* - -LOCAL FUNCTION - - proc_init_failed - called whenever /proc access initialization fails - -SYNOPSIS - - static void proc_init_failed (char *why) - -DESCRIPTION - - This function is called whenever initialization of access to a /proc - entry fails. It prints a suitable error message, does some cleanup, - and then invokes the standard error processing routine which dumps - us back into the command loop. - */ - -static void -DEFUN(proc_init_failed, (why), - char *why) -{ - print_sys_errmsg (pi.pathname, errno); - (void) kill (pi.pid, SIGKILL); - close_proc_file (); - error (why); - /* NOTREACHED */ -} - -/* - -LOCAL FUNCTION - - close_proc_file - close any currently open /proc entry - -SYNOPSIS - - static void close_proc_file (void) - -DESCRIPTION - - Close any currently open /proc entry and mark the process information - entry as invalid. In order to ensure that we don't try to reuse any - stale information, the pid, fd, and pathnames are explicitly - invalidated, which may be overkill. - - */ - -static void -DEFUN_VOID(close_proc_file) -{ - pi.pid = 0; - if (pi.valid) - { - (void) close (pi.fd); - } - pi.fd = -1; - if (pi.pathname) - { - free (pi.pathname); - pi.pathname = NULL; - } - pi.valid = 0; -} - -/* - -LOCAL FUNCTION - - open_proc_file - open a /proc entry for a given process id - -SYNOPSIS - - static int open_proc_file (pid) - -DESCRIPTION - - Given a process id, close the existing open /proc entry (if any) - and open one for the new process id. Once it is open, then - mark the local process information structure as valid, which - guarantees that the pid, fd, and pathname fields match an open - /proc entry. Returns zero if the open fails, nonzero otherwise. - - Note that the pathname is left intact, even when the open fails, - so that callers can use it to construct meaningful error messages - rather than just "file open failed". - */ - -static int -DEFUN(open_proc_file, (pid), - int pid) -{ - pi.valid = 0; - if (pi.valid) - { - (void) close (pi.fd); - } - if (pi.pathname == NULL) - { - pi.pathname = xmalloc (32); - } - sprintf (pi.pathname, PROC_NAME_FMT, pid); - if ((pi.fd = open (pi.pathname, O_RDWR)) >= 0) - { - pi.valid = 1; - pi.pid = pid; - } - return (pi.valid); -} - -#endif /* USE_PROC_FS */ diff --git a/gdb/putenv.c b/gdb/putenv.c deleted file mode 100644 index f7318f08084..00000000000 --- a/gdb/putenv.c +++ /dev/null @@ -1,117 +0,0 @@ -/****************************************************************/ -/* */ -/* putenv(3) */ -/* */ -/* Change or add an environment entry */ -/* */ -/****************************************************************/ -/* origination 1987-Oct-7 T. Holm */ -/****************************************************************/ - -/* -From pacbell!ames!ll-xn!mit-eddie!uw-beaver!ssc-vax!uvicctr!tholm Wed May 4 23:40:52 1988 -Path: hoptoad!pacbell!ames!ll-xn!mit-eddie!uw-beaver!ssc-vax!uvicctr!tholm -From: tholm@uvicctr.UUCP (Terrence W. Holm) -Newsgroups: comp.os.minix -Subject: putenv(3) -Message-ID: <395@uvicctr.UUCP> -Date: 5 May 88 06:40:52 GMT -Reply-To: tholm@uvicctr.UUCP (Terrence W. Holm) -Organization: University of Victoria, Victoria B.C. Canada -Lines: 296 - - -EFTH Minix report #2 - May 1988 - putenv(3) - - -This is an implementation of putenv(3) that we -wrote for Minix. Please consider this a public -domain program. -*/ - -#include - - -#define PSIZE sizeof(char *) - - -extern char **environ; - - -char *index(); -char *malloc(); - - -/****************************************************************/ -/* */ -/* putenv( entry ) */ -/* */ -/* The "entry" should follow the form */ -/* "NAME=VALUE". This routine will search the */ -/* user environment for "NAME" and replace its */ -/* value with "VALUE". */ -/* */ -/* Note that "entry" is not copied, it is used */ -/* as the environment entry. This means that it */ -/* must not be unallocated or otherwise modifed */ -/* by the caller, unless it is replaced by a */ -/* subsequent putenv(). */ -/* */ -/* If the name is not found in the environment, */ -/* then a new vector of pointers is allocated, */ -/* "entry" is put at the end and the global */ -/* variable "environ" is updated. */ -/* */ -/* This function normally returns NULL, but -1 */ -/* is returned if it can not allocate enough */ -/* space using malloc(3), or "entry" does not */ -/* contain a '='. */ -/* */ -/****************************************************************/ - - -putenv( entry ) - char *entry; - - { - unsigned length; - unsigned size; - char **p; - char **new_environ; - - /* Find the length of the "NAME=" */ - - if ( (length=(unsigned) index(entry,'=')) == NULL ) - return( -1 ); - - length = length - (unsigned) entry + 1; - - - /* Scan through the environment looking for "NAME=" */ - - for ( p=environ; *p != 0 ; p++ ) - if ( strncmp( entry, *p, length ) == 0 ) - { - *p = entry; - return( NULL ); - } - - - /* The name was not found, build a bigger environment */ - - size = p - environ; - - new_environ = (char **) malloc( (size+2)*PSIZE ); - - if ( new_environ == NULL ) - return( -1 ); - - bcopy( (char *) environ, (char *) new_environ, size*PSIZE ); - - new_environ[size] = entry; - new_environ[size+1] = NULL; - - environ = new_environ; - - return(NULL); - } diff --git a/gdb/pyr-opcode.h b/gdb/pyr-opcode.h deleted file mode 100755 index 06632b8d919..00000000000 --- a/gdb/pyr-opcode.h +++ /dev/null @@ -1,287 +0,0 @@ -/* pyramid.opcode.h -- gdb initial attempt. */ - -/* pyramid opcode table: wot to do with this - particular opcode */ - -struct pyr_datum -{ - char nargs; - char * args; /* how to compile said opcode */ - unsigned long mask; /* Bit vector: which operand modes are valid - for this opcode */ - unsigned char code; /* op-code (always 6(?) bits */ -}; - -typedef struct pyr_insn_format { - unsigned int mode :4; - unsigned int operator :8; - unsigned int index_scale :2; - unsigned int index_reg :6; - unsigned int operand_1 :6; - unsigned int operand_2:6; -} pyr_insn_format; - - -/* We store four bytes of opcode for all opcodes. - Pyramid is sufficiently RISCy that: - - insns are always an integral number of words; - - the length of any insn can be told from the first word of - the insn. (ie, if there are zero, one, or two words of - immediate operand/offset). - - - The args component is a string containing two characters for each - operand of the instruction. The first specifies the kind of operand; - the second, the place it is stored. */ - -/* Kinds of operands: - mask assembler syntax description - 0x0001: movw Rn,Rn register to register - 0x0002: movw K,Rn quick immediate to register - 0x0004: movw I,Rn long immediate to register - 0x0008: movw (Rn),Rn register indirect to register - movw (Rn)[x],Rn register indirect to register - 0x0010: movw I(Rn),Rn offset register indirect to register - movw I(Rn)[x],Rn offset register indirect, indexed, to register - - 0x0020: movw Rn,(Rn) register to register indirect - 0x0040: movw K,(Rn) quick immediate to register indirect - 0x0080: movw I,(Rn) long immediate to register indirect - 0x0100: movw (Rn),(Rn) register indirect to-register indirect - 0x0100: movw (Rn),(Rn) register indirect to-register indirect - 0x0200: movw I(Rn),(Rn) register indirect+offset to register indirect - 0x0200: movw I(Rn),(Rn) register indirect+offset to register indirect - - 0x0400: movw Rn,I(Rn) register to register indirect+offset - 0x0800: movw K,I(Rn) quick immediate to register indirect+offset - 0x1000: movw I,I(Rn) long immediate to register indirect+offset - 0x1000: movw (Rn),I(Rn) register indirect to-register indirect+offset - 0x1000: movw I(Rn),I(Rn) register indirect+offset to register indirect - +offset - 0x0000: (irregular) ??? - - - Each insn has a four-bit field encoding the type(s) of its operands. -*/ - -/* Some common combinations - */ - -/* the first 5,(0x1|0x2|0x4|0x8|0x10) ie (1|2|4|8|16), ie ( 32 -1)*/ -#define GEN_TO_REG (31) - -#define UNKNOWN ((unsigned long)-1) -#define ANY (GEN_TO_REG | (GEN_TO_REG << 5) | (GEN_TO_REG << 15)) - -#define CONVERT (1|8|0x10|0x20|0x200) - -#define K_TO_REG (2) -#define I_TO_REG (4) -#define NOTK_TO_REG (GEN_TO_REG & ~K_TO_REG) -#define NOTI_TO_REG (GEN_TO_REG & ~I_TO_REG) - -/* The assembler requires that this array be sorted as follows: - all instances of the same mnemonic must be consecutive. - All instances of the same mnemonic with the same number of operands - must be consecutive. - */ - -struct pyr_opcode /* pyr opcode text */ -{ - char * name; /* opcode name: lowercase string [key] */ - struct pyr_datum datum; /* rest of opcode table [datum] */ -}; - -#define pyr_how args -#define pyr_nargs nargs -#define pyr_mask mask -#define pyr_name name - -struct pyr_opcode pyr_opcodes[] = -{ - {"movb", { 2, "", UNKNOWN, 0x11}, }, - {"movh", { 2, "", UNKNOWN, 0x12} }, - {"movw", { 2, "", ANY, 0x10} }, - {"movl", { 2, "", ANY, 0x13} }, - {"mnegw", { 2, "", (0x1|0x8|0x10), 0x14} }, - {"mnegf", { 2, "", 0x1, 0x15} }, - {"mnegd", { 2, "", 0x1, 0x16} }, - {"mcomw", { 2, "", (0x1|0x8|0x10), 0x17} }, - {"mabsw", { 2, "", (0x1|0x8|0x10), 0x18} }, - {"mabsf", { 2, "", 0x1, 0x19} }, - {"mabsd", { 2, "", 0x1, 0x1a} }, - {"mtstw", { 2, "", (0x1|0x8|0x10), 0x1c} }, - {"mtstf", { 2, "", 0x1, 0x1d} }, - {"mtstd", { 2, "", 0x1, 0x1e} }, - {"mova", { 2, "", 0x8|0x10, 0x1f} }, - {"movzbw", { 2, "", (0x1|0x8|0x10), 0x20} }, - {"movzhw", { 2, "", (0x1|0x8|0x10), 0x21} }, - /* 2 insns out of order here */ - {"movbl", { 2, "", 1, 0x4f} }, - {"filbl", { 2, "", 1, 0x4e} }, - - {"cvtbw", { 2, "", CONVERT, 0x22} }, - {"cvthw", { 2, "", CONVERT, 0x23} }, - {"cvtwb", { 2, "", CONVERT, 0x24} }, - {"cvtwh", { 2, "", CONVERT, 0x25} }, - {"cvtwf", { 2, "", CONVERT, 0x26} }, - {"cvtwd", { 2, "", CONVERT, 0x27} }, - {"cvtfw", { 2, "", CONVERT, 0x28} }, - {"cvtfd", { 2, "", CONVERT, 0x29} }, - {"cvtdw", { 2, "", CONVERT, 0x2a} }, - {"cvtdf", { 2, "", CONVERT, 0x2b} }, - - {"addw", { 2, "", GEN_TO_REG, 0x40} }, - {"addwc", { 2, "", GEN_TO_REG, 0x41} }, - {"subw", { 2, "", GEN_TO_REG, 0x42} }, - {"subwb", { 2, "", GEN_TO_REG, 0x43} }, - {"rsubw", { 2, "", GEN_TO_REG, 0x44} }, - {"mulw", { 2, "", GEN_TO_REG, 0x45} }, - {"emul", { 2, "", GEN_TO_REG, 0x47} }, - {"umulw", { 2, "", GEN_TO_REG, 0x46} }, - {"divw", { 2, "", GEN_TO_REG, 0x48} }, - {"ediv", { 2, "", GEN_TO_REG, 0x4a} }, - {"rdivw", { 2, "", GEN_TO_REG, 0x4b} }, - {"udivw", { 2, "", GEN_TO_REG, 0x49} }, - {"modw", { 2, "", GEN_TO_REG, 0x4c} }, - {"umodw", { 2, "", GEN_TO_REG, 0x4d} }, - - - {"addf", { 2, "", 1, 0x50} }, - {"addd", { 2, "", 1, 0x51} }, - {"subf", { 2, "", 1, 0x52} }, - {"subd", { 2, "", 1, 0x53} }, - {"mulf", { 2, "", 1, 0x56} }, - {"muld", { 2, "", 1, 0x57} }, - {"divf", { 2, "", 1, 0x58} }, - {"divd", { 2, "", 1, 0x59} }, - - - {"cmpb", { 2, "", UNKNOWN, 0x61} }, - {"cmph", { 2, "", UNKNOWN, 0x62} }, - {"cmpw", { 2, "", UNKNOWN, 0x60} }, - {"ucmpb", { 2, "", UNKNOWN, 0x66} }, - /* WHY no "ucmph"??? */ - {"ucmpw", { 2, "", UNKNOWN, 0x65} }, - {"xchw", { 2, "", UNKNOWN, 0x0f} }, - - - {"andw", { 2, "", GEN_TO_REG, 0x30} }, - {"orw", { 2, "", GEN_TO_REG, 0x31} }, - {"xorw", { 2, "", GEN_TO_REG, 0x32} }, - {"bicw", { 2, "", GEN_TO_REG, 0x33} }, - {"lshlw", { 2, "", GEN_TO_REG, 0x38} }, - {"ashlw", { 2, "", GEN_TO_REG, 0x3a} }, - {"ashll", { 2, "", GEN_TO_REG, 0x3c} }, - {"ashrw", { 2, "", GEN_TO_REG, 0x3b} }, - {"ashrl", { 2, "", GEN_TO_REG, 0x3d} }, - {"rotlw", { 2, "", GEN_TO_REG, 0x3e} }, - {"rotrw", { 2, "", GEN_TO_REG, 0x3f} }, - - /* push and pop insns are "going away next release". */ - {"pushw", { 2, "", GEN_TO_REG, 0x0c} }, - {"popw", { 2, "", (0x1|0x8|0x10), 0x0d} }, - {"pusha", { 2, "", (0x8|0x10), 0x0e} }, - - {"bitsw", { 2, "", UNKNOWN, 0x35} }, - {"bitcw", { 2, "", UNKNOWN, 0x36} }, - /* some kind of ibra/dbra insns??*/ - {"icmpw", { 2, "", UNKNOWN, 0x67} }, - {"dcmpw", { 2, "", (1|4|0x20|0x80|0x400|0x1000), 0x69} },/*FIXME*/ - {"acmpw", { 2, "", 1, 0x6b} }, - - /* Call is written as a 1-op insn, but is always (dis)assembled as a 2-op - insn with a 2nd op of tr14. The assembler will have to grok this. */ - {"call", { 2, "", GEN_TO_REG, 0x04} }, - {"call", { 1, "", GEN_TO_REG, 0x04} }, - - {"callk", { 1, "", UNKNOWN, 0x06} },/* system call?*/ - /* Ret is usually written as a 0-op insn, but gets disassembled as a - 1-op insn. The operand is always tr15. */ - {"ret", { 0, "", UNKNOWN, 0x09} }, - {"ret", { 1, "", UNKNOWN, 0x09} }, - {"adsf", { 2, "", (1|2|4), 0x08} }, - {"retd", { 2, "", UNKNOWN, 0x0a} }, - {"btc", { 2, "", UNKNOWN, 0x01} }, - {"bfc", { 2, "", UNKNOWN, 0x02} }, - /* Careful: halt is 0x00000000. Jump must have some other (mode?)bit set?? */ - {"jump", { 1, "", UNKNOWN, 0x00} }, - {"btp", { 2, "", UNKNOWN, 0xf00} }, - /* read control-stack pointer is another 1-or-2 operand insn. */ - {"rcsp", { 2, "", UNKNOWN, 0x01f} }, - {"rcsp", { 1, "", UNKNOWN, 0x01f} } -}; - -/* end: pyramid.opcode.h */ -/* One day I will have to take the time to find out what operands - are valid for these insns, and guess at what they mean. - - I can't imagine what the "I???" insns (iglob, etc) do. - - the arithmetic-sounding insns ending in "p" sound awfully like BCD - arithmetic insns: - dshlp -> Decimal SHift Left Packed - dshrp -> Decimal SHift Right Packed - and cvtlp would be convert long to packed. - I have no idea how the operands are interpreted; but having them be - a long register with (address, length) of an in-memory packed BCD operand - would not be surprising. - They are unlikely to be a packed bcd string: 64 bits of long give - is only 15 digits+sign, which isn't enough for COBOL. - */ -#if 0 - {"wcsp", { 2, "", UNKNOWN, 0x00} }, /*write csp?*/ - /* The OSx Operating System Porting Guide claims SSL does things - with tr12 (a register reserved to it) to do with static block-structure - references. SSL=Set Static Link? It's "Going away next release". */ - {"ssl", { 2, "", UNKNOWN, 0x00} }, - {"ccmps", { 2, "", UNKNOWN, 0x00} }, - {"lcd", { 2, "", UNKNOWN, 0x00} }, - {"uemul", { 2, "", UNKNOWN, 0x00} }, /*unsigned emul*/ - {"srf", { 2, "", UNKNOWN, 0x00} }, /*Gidget time???*/ - {"mnegp", { 2, "", UNKNOWN, 0x00} }, /move-neg phys?*/ - {"ldp", { 2, "", UNKNOWN, 0x00} }, /*load phys?*/ - {"ldti", { 2, "", UNKNOWN, 0x00} }, - {"ldb", { 2, "", UNKNOWN, 0x00} }, - {"stp", { 2, "", UNKNOWN, 0x00} }, - {"stti", { 2, "", UNKNOWN, 0x00} }, - {"stb", { 2, "", UNKNOWN, 0x00} }, - {"stu", { 2, "", UNKNOWN, 0x00} }, - {"addp", { 2, "", UNKNOWN, 0x00} }, - {"subp", { 2, "", UNKNOWN, 0x00} }, - {"mulp", { 2, "", UNKNOWN, 0x00} }, - {"divp", { 2, "", UNKNOWN, 0x00} }, - {"dshlp", { 2, "", UNKNOWN, 0x00} }, /* dec shl packed? */ - {"dshrp", { 2, "", UNKNOWN, 0x00} }, /* dec shr packed? */ - {"movs", { 2, "", UNKNOWN, 0x00} }, /*move (string?)?*/ - {"cmpp", { 2, "", UNKNOWN, 0x00} }, /* cmp phys?*/ - {"cmps", { 2, "", UNKNOWN, 0x00} }, /* cmp (string?)?*/ - {"cvtlp", { 2, "", UNKNOWN, 0x00} }, /* cvt long to p??*/ - {"cvtpl", { 2, "", UNKNOWN, 0x00} }, /* cvt p to l??*/ - {"dintr", { 2, "", UNKNOWN, 0x00} }, /* ?? intr ?*/ - {"rphysw", { 2, "", UNKNOWN, 0x00} }, /* read phys word?*/ - {"wphysw", { 2, "", UNKNOWN, 0x00} }, /* write phys word?*/ - {"cmovs", { 2, "", UNKNOWN, 0x00} }, - {"rsubw", { 2, "", UNKNOWN, 0x00} }, - {"bicpsw", { 2, "", UNKNOWN, 0x00} }, /* clr bit in psw? */ - {"bispsw", { 2, "", UNKNOWN, 0x00} }, /* set bit in psw? */ - {"eio", { 2, "", UNKNOWN, 0x00} }, /* ?? ?io ? */ - {"callp", { 2, "", UNKNOWN, 0x00} }, /* call phys?*/ - {"callr", { 2, "", UNKNOWN, 0x00} }, - {"lpcxt", { 2, "", UNKNOWN, 0x00} }, /*load proc context*/ - {"rei", { 2, "", UNKNOWN, 0x00} }, /*ret from intrpt*/ - {"rport", { 2, "", UNKNOWN, 0x00} }, /*read-port?*/ - {"rtod", { 2, "", UNKNOWN, 0x00} }, /*read-time-of-day?*/ - {"ssi", { 2, "", UNKNOWN, 0x00} }, - {"vtpa", { 2, "", UNKNOWN, 0x00} }, /*virt-to-phys-addr?*/ - {"wicl", { 2, "", UNKNOWN, 0x00} }, /* write icl ? */ - {"wport", { 2, "", UNKNOWN, 0x00} }, /*write-port?*/ - {"wtod", { 2, "", UNKNOWN, 0x00} }, /*write-time-of-day?*/ - {"flic", { 2, "", UNKNOWN, 0x00} }, - {"iglob", { 2, "", UNKNOWN, 0x00} }, /* I global? */ - {"iphys", { 2, "", UNKNOWN, 0x00} }, /* I physical? */ - {"ipid", { 2, "", UNKNOWN, 0x00} }, /* I pid? */ - {"ivect", { 2, "", UNKNOWN, 0x00} }, /* I vector? */ - {"lamst", { 2, "", UNKNOWN, 0x00} }, - {"tio", { 2, "", UNKNOWN, 0x00} }, -#endif diff --git a/gdb/pyr-pinsn.c b/gdb/pyr-pinsn.c deleted file mode 100644 index 02d626c42d3..00000000000 --- a/gdb/pyr-pinsn.c +++ /dev/null @@ -1,347 +0,0 @@ -/* Disassembler for the Pyramid Technology 90x - Copyright (C) 1988,1989 Free Software Foundation, Inc. - -This file is part of GDB, the GNU disassembler. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include - -#include "defs.h" -#include "param.h" -#include "symtab.h" -#include "pyr-opcode.h" -#include "gdbcore.h" - - -/* A couple of functions used for debugging frame-handling on - Pyramids. (The Pyramid-dependent handling of register values for - windowed registers is known to be buggy.) - - When debugging, these functions supplant the normal definitions of some - of the macros in m-pyramid.h The quantity of information produced - when these functions are used makes the gdb unusable as a - debugger for user programs. */ - -extern unsigned pyr_saved_pc(), pyr_frame_chain(); - -CORE_ADDR pyr_frame_chain(frame) - CORE_ADDR frame; -{ - int foo=frame - CONTROL_STACK_FRAME_SIZE; - /* printf ("...following chain from %x: got %x\n", frame, foo);*/ - return foo; -} - -CORE_ADDR pyr_saved_pc(frame) - CORE_ADDR frame; -{ - int foo=0; - foo = read_memory_integer (((CORE_ADDR)(frame))+60, 4); - printf ("..reading pc from frame 0x%0x+%d regs: got %0x\n", - frame, 60/4, foo); - return foo; -} - - -/* Pyramid instructions are never longer than this many bytes. */ -#define MAXLEN 24 - -/* Number of elements in the opcode table. */ -/*const*/ static int nopcodes = (sizeof (pyr_opcodes) / sizeof( pyr_opcodes[0])); -#define NOPCODES (nopcodes) - -extern char *reg_names[]; - -/* Let's be byte-independent so we can use this as a cross-assembler. - (will this ever be useful? - */ - -#define NEXTLONG(p) \ - (p += 4, (((((p[-4] << 8) + p[-3]) << 8) + p[-2]) << 8) + p[-1]) - - -/* Print one instruction at address MEMADDR in debugged memory, - on STREAM. Returns length of the instruction, in bytes. */ - -int -print_insn (memaddr, stream) - CORE_ADDR memaddr; - FILE *stream; -{ - unsigned char buffer[MAXLEN]; - register int i, nargs, insn_size =4; - register unsigned char *p; - register char *d; - register int insn_opcode, operand_mode; - register int index_multiplier, index_reg_regno, op_1_regno, op_2_regno ; - long insn; /* first word of the insn, not broken down. */ - pyr_insn_format insn_decode; /* the same, broken out into op{code,erands} */ - long extra_1, extra_2; - - read_memory (memaddr, buffer, MAXLEN); - insn_decode = *((pyr_insn_format *) buffer); - insn = * ((int *) buffer); - insn_opcode = insn_decode.operator; - operand_mode = insn_decode.mode; - index_multiplier = insn_decode.index_scale; - index_reg_regno = insn_decode.index_reg; - op_1_regno = insn_decode.operand_1; - op_2_regno = insn_decode.operand_2; - - - if (*((int *)buffer) == 0x0) { - /* "halt" looks just like an invalid "jump" to the insn decoder, - so is dealt with as a special case */ - fprintf (stream, "halt"); - return (4); - } - - for (i = 0; i < NOPCODES; i++) - if (pyr_opcodes[i].datum.code == insn_opcode) - break; - - if (i == NOPCODES) - /* FIXME: Handle unrecognised instructions better. */ - fprintf (stream, "???\t#%08x\t(op=%x mode =%x)", - insn, insn_decode.operator, insn_decode.mode); - else - { - /* Print the mnemonic for the instruction. Pyramid insn operands - are so regular that we can deal with almost all of them - separately. - Unconditional branches are an exception: they are encoded as - conditional branches (branch if false condition, I think) - with no condition specified. The average user will not be - aware of this. To maintain their illusion that an - unconditional branch insn exists, we will have to FIXME to - treat the insn mnemnonic of all branch instructions here as a - special case: check the operands of branch insn and print an - appropriate mnemonic. */ - - fprintf (stream, "%s\t", pyr_opcodes[i].name); - - /* Print the operands of the insn (as specified in - insn.operand_mode). - Branch operands of branches are a special case: they are a word - offset, not a byte offset. */ - - if (insn_decode.operator == 0x01 || insn_decode.operator == 0x02) { - register int bit_codes=(insn >> 16)&0xf; - register int i; - register int displacement = (insn & 0x0000ffff) << 2; - - static char cc_bit_names[] = "cvzn"; /* z,n,c,v: strange order? */ - - /* Is bfc and no bits specified an unconditional branch?*/ - for (i=0;i<4;i++) { - if ((bit_codes) & 0x1) - fputc (cc_bit_names[i], stream); - bit_codes >>= 1; - } - - fprintf (stream, ",%0x", - displacement + memaddr); - return (insn_size); - } - - switch (operand_mode) { - case 0: - fprintf (stream, "%s,%s", - reg_names [op_1_regno], - reg_names [op_2_regno]); - break; - - case 1: - fprintf (stream, " 0x%0x,%s", - op_1_regno, - reg_names [op_2_regno]); - break; - - case 2: - read_memory (memaddr+4, buffer, MAXLEN); - insn_size += 4; - extra_1 = * ((int *) buffer); - fprintf (stream, " $0x%0x,%s", - extra_1, - reg_names [op_2_regno]); - break; - case 3: - fprintf (stream, " (%s),%s", - reg_names [op_1_regno], - reg_names [op_2_regno]); - break; - - case 4: - read_memory (memaddr+4, buffer, MAXLEN); - insn_size += 4; - extra_1 = * ((int *) buffer); - fprintf (stream, " 0x%0x(%s),%s", - extra_1, - reg_names [op_1_regno], - reg_names [op_2_regno]); - break; - - /* S1 destination mode */ - case 5: - fprintf (stream, - ((index_reg_regno) ? "%s,(%s)[%s*%1d]" : "%s,(%s)"), - reg_names [op_1_regno], - reg_names [op_2_regno], - reg_names [index_reg_regno], - index_multiplier); - break; - - case 6: - fprintf (stream, - ((index_reg_regno) ? " $%#0x,(%s)[%s*%1d]" - : " $%#0x,(%s)"), - op_1_regno, - reg_names [op_2_regno], - reg_names [index_reg_regno], - index_multiplier); - break; - - case 7: - read_memory (memaddr+4, buffer, MAXLEN); - insn_size += 4; - extra_1 = * ((int *) buffer); - fprintf (stream, - ((index_reg_regno) ? " $%#0x,(%s)[%s*%1d]" - : " $%#0x,(%s)"), - extra_1, - reg_names [op_2_regno], - reg_names [index_reg_regno], - index_multiplier); - break; - - case 8: - fprintf (stream, - ((index_reg_regno) ? " (%s),(%s)[%s*%1d]" : " (%s),(%s)"), - reg_names [op_1_regno], - reg_names [op_2_regno], - reg_names [index_reg_regno], - index_multiplier); - break; - - case 9: - read_memory (memaddr+4, buffer, MAXLEN); - insn_size += 4; - extra_1 = * ((int *) buffer); - fprintf (stream, - ((index_reg_regno) - ? "%#0x(%s),(%s)[%s*%1d]" - : "%#0x(%s),(%s)"), - extra_1, - reg_names [op_1_regno], - reg_names [op_2_regno], - reg_names [index_reg_regno], - index_multiplier); - break; - - /* S2 destination mode */ - case 10: - read_memory (memaddr+4, buffer, MAXLEN); - insn_size += 4; - extra_1 = * ((int *) buffer); - fprintf (stream, - ((index_reg_regno) ? "%s,%#0x(%s)[%s*%1d]" : "%s,%#0x(%s)"), - reg_names [op_1_regno], - extra_1, - reg_names [op_2_regno], - reg_names [index_reg_regno], - index_multiplier); - break; - case 11: - read_memory (memaddr+4, buffer, MAXLEN); - insn_size += 4; - extra_1 = * ((int *) buffer); - fprintf (stream, - ((index_reg_regno) ? - " $%#0x,%#0x(%s)[%s*%1d]" : " $%#0x,%#0x(%s)"), - op_1_regno, - extra_1, - reg_names [op_2_regno], - reg_names [index_reg_regno], - index_multiplier); - break; - case 12: - read_memory (memaddr+4, buffer, MAXLEN); - insn_size += 4; - extra_1 = * ((int *) buffer); - read_memory (memaddr+8, buffer, MAXLEN); - insn_size += 4; - extra_2 = * ((int *) buffer); - fprintf (stream, - ((index_reg_regno) ? - " $%#0x,%#0x(%s)[%s*%1d]" : " $%#0x,%#0x(%s)"), - extra_1, - extra_2, - reg_names [op_2_regno], - reg_names [index_reg_regno], - index_multiplier); - break; - - case 13: - read_memory (memaddr+4, buffer, MAXLEN); - insn_size += 4; - extra_1 = * ((int *) buffer); - fprintf (stream, - ((index_reg_regno) - ? " (%s),%#0x(%s)[%s*%1d]" - : " (%s),%#0x(%s)"), - reg_names [op_1_regno], - extra_1, - reg_names [op_2_regno], - reg_names [index_reg_regno], - index_multiplier); - break; - case 14: - read_memory (memaddr+4, buffer, MAXLEN); - insn_size += 4; - extra_1 = * ((int *) buffer); - read_memory (memaddr+8, buffer, MAXLEN); - insn_size += 4; - extra_2 = * ((int *) buffer); - fprintf (stream, - ((index_reg_regno) ? "%#0x(%s),%#0x(%s)[%s*%1d]" - : "%#0x(%s),%#0x(%s) "), - extra_1, - reg_names [op_1_regno], - extra_2, - reg_names [op_2_regno], - reg_names [index_reg_regno], - index_multiplier); - break; - - default: - fprintf (stream, - ((index_reg_regno) ? "%s,%s [%s*%1d]" : "%s,%s"), - reg_names [op_1_regno], - reg_names [op_2_regno], - reg_names [index_reg_regno], - index_multiplier); - fprintf (stream, - "\t\t# unknown mode in %08x", - insn); - break; - } /* switch */ - } - - { - return insn_size; - } - abort (); -} diff --git a/gdb/pyr-tdep.c b/gdb/pyr-tdep.c deleted file mode 100644 index f3a3cde97c7..00000000000 --- a/gdb/pyr-tdep.c +++ /dev/null @@ -1,134 +0,0 @@ -/* Pyramid target-dependent code for GDB. - Copyright (C) 1988, 1989, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include "param.h" -#include "defs.h" - -/*** Prettier register printing. ***/ - -/* Print registers in the same format as pyramid's dbx, adb, sdb. */ -pyr_print_registers(reg_buf, regnum) - long *reg_buf[]; -{ - register int regno; - int usp, ksp; - struct user u; - - for (regno = 0; regno < 16; regno++) { - printf/*_filtered*/ ("%6.6s: %8x %6.6s: %8x %6s: %8x %6s: %8x\n", - reg_names[regno], reg_buf[regno], - reg_names[regno+16], reg_buf[regno+16], - reg_names[regno+32], reg_buf[regno+32], - reg_names[regno+48], reg_buf[regno+48]); - } - usp = ptrace (3, inferior_pid, - ((char *)&u.u_pcb.pcb_usp) - - ((char *)&u), 0); - ksp = ptrace (3, inferior_pid, - ((char *)&u.u_pcb.pcb_ksp) - - ((char *)&u), 0); - printf/*_filtered*/ ("\n%6.6s: %8x %6.6s: %8x (%08x) %6.6s %8x\n", - reg_names[CSP_REGNUM],reg_buf[CSP_REGNUM], - reg_names[KSP_REGNUM], reg_buf[KSP_REGNUM], ksp, - "usp", usp); -} - -/* Print the register regnum, or all registers if regnum is -1. - fpregs is currently ignored. */ - -pyr_do_registers_info (regnum, fpregs) - int regnum; - int fpregs; -{ - /* On a pyr, we know a virtual register can always fit in an long. - Here (and elsewhere) we take advantage of that. Yuk. */ - long raw_regs[MAX_REGISTER_RAW_SIZE*NUM_REGS]; - register int i; - - for (i = 0 ; i < 64 ; i++) { - read_relative_register_raw_bytes(i, raw_regs+i); - } - if (regnum == -1) - pyr_print_registers (raw_regs, regnum); - else - for (i = 0; i < NUM_REGS; i++) - if (i == regnum) { - long val = raw_regs[i]; - - fputs_filtered (reg_names[i], stdout); - printf_filtered(":"); - print_spaces_filtered (6 - strlen (reg_names[i]), stdout); - if (val == 0) - printf_filtered ("0"); - else - printf_filtered ("%s %d", local_hex_string_custom(val,"08"), val); - printf_filtered("\n"); - } -} - -/*** Debugging editions of various macros from m-pyr.h ****/ - -CORE_ADDR frame_locals_address (frame) - FRAME frame; -{ - register int addr = find_saved_register (frame,CFP_REGNUM); - register int result = read_memory_integer (addr, 4); -#ifdef PYRAMID_CONTROL_FRAME_DEBUGGING - fprintf (stderr, - "\t[[..frame_locals:%8x, %s= %x @%x fcfp= %x foo= %x\n\t gr13=%x pr13=%x tr13=%x @%x]]\n", - frame->frame, - reg_names[CFP_REGNUM], - result, addr, - frame->frame_cfp, (CFP_REGNUM), - - - read_register(13), read_register(29), read_register(61), - find_saved_register(frame, 61)); -#endif /* PYRAMID_CONTROL_FRAME_DEBUGGING */ - - /* FIXME: I thought read_register (CFP_REGNUM) should be the right answer; - or at least CFP_REGNUM relative to FRAME (ie, result). - There seems to be a bug in the way the innermost frame is set up. */ - - return ((frame->next) ? result: frame->frame_cfp); -} - -CORE_ADDR frame_args_addr (frame) - FRAME frame; -{ - register int addr = find_saved_register (frame,CFP_REGNUM); - register int result = read_memory_integer (addr, 4); - -#ifdef PYRAMID_CONTROL_FRAME_DEBUGGING - fprintf (stderr, - "\t[[..frame_args:%8x, %s= %x @%x fcfp= %x r_r= %x\n\t gr13=%x pr13=%x tr13=%x @%x]]\n", - frame->frame, - reg_names[CFP_REGNUM], - result, addr, - frame->frame_cfp, read_register(CFP_REGNUM), - - read_register(13), read_register(29), read_register(61), - find_saved_register(frame, 61)); -#endif /* PYRAMID_CONTROL_FRAME_DEBUGGING */ - - /* FIXME: I thought read_register (CFP_REGNUM) should be the right answer; - or at least CFP_REGNUM relative to FRAME (ie, result). - There seems to be a bug in the way the innermost frame is set up. */ - return ((frame->next) ? result: frame->frame_cfp); -} diff --git a/gdb/pyr-xdep.c b/gdb/pyr-xdep.c deleted file mode 100644 index 4a89db9498e..00000000000 --- a/gdb/pyr-xdep.c +++ /dev/null @@ -1,366 +0,0 @@ -/* Low level Pyramid interface to ptrace, for GDB when running under Unix. - Copyright (C) 1988, 1989, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "defs.h" -#include "param.h" -#include "frame.h" -#include "inferior.h" - -#include -#include -#include -#include -/* #include Can we live without this? */ - -#include "gdbcore.h" -#include /* After a.out.h */ -#include -#include - -void -fetch_inferior_registers () -{ - register int regno, datum; - register unsigned int regaddr; - int reg_buf[NUM_REGS+1]; - struct user u; - register int skipped_frames = 0; - - registers_fetched (); - - for (regno = 0; regno < 64; regno++) { - reg_buf[regno] = ptrace (3, inferior_pid, regno, 0); - -#if defined(PYRAMID_CONTROL_FRAME_DEBUGGING) - printf ("Fetching %s from inferior, got %0x\n", - reg_names[regno], - reg_buf[regno]); -#endif /* PYRAMID_CONTROL_FRAME_DEBUGGING */ - - if (reg_buf[regno] == -1 && errno == EIO) { - printf("fetch_interior_registers: fetching %s from inferior\n", - reg_names[regno]); - errno = 0; - } - supply_register (regno, reg_buf+regno); - } - /* that leaves regs 64, 65, and 66 */ - datum = ptrace (3, inferior_pid, - ((char *)&u.u_pcb.pcb_csp) - - ((char *)&u), 0); - - - - /* FIXME: Find the Current Frame Pointer (CFP). CFP is a global - register (ie, NOT windowed), that gets saved in a frame iff - the code for that frame has a prologue (ie, "adsf N"). If - there is a prologue, the adsf insn saves the old cfp in - pr13, cfp is set to sp, and N bytes of locals are allocated - (sp is decremented by n). - This makes finding CFP hard. I guess the right way to do it - is: - - If this is the innermost frame, believe ptrace() or - the core area. - - Otherwise: - Find the first insn of the current frame. - - find the saved pc; - - find the call insn that saved it; - - figure out where the call is to; - - if the first insn is an adsf, we got a frame - pointer. */ - - - /* Normal processors have separate stack pointers for user and - kernel mode. Getting the last user mode frame on such - machines is easy: the kernel context of the ptrace()'d - process is on the kernel stack, and the USP points to what - we want. But Pyramids only have a single cfp for both user and - kernel mode. And processes being ptrace()'d have some - kernel-context control frames on their stack. - To avoid tracing back into the kernel context of an inferior, - we skip 0 or more contiguous control frames where the pc is - in the kernel. */ - - while (1) { - register int inferior_saved_pc; - inferior_saved_pc = ptrace (1, inferior_pid, datum+((32+15)*4), 0); - if (inferior_saved_pc > 0) break; -#if defined(PYRAMID_CONTROL_FRAME_DEBUGGING) - printf("skipping kernel frame %08x, pc=%08x\n", datum, - inferior_saved_pc); -#endif /* PYRAMID_CONTROL_FRAME_DEBUGGING */ - skipped_frames++; - datum -= CONTROL_STACK_FRAME_SIZE; - } - - reg_buf[CSP_REGNUM] = datum; - supply_register(CSP_REGNUM, reg_buf+CSP_REGNUM); -#ifdef PYRAMID_CONTROL_FRAME_DEBUGGING - if (skipped_frames) { - fprintf (stderr, - "skipped %d frames from %x to %x; cfp was %x, now %x\n", - skipped_frames, reg_buf[CSP_REGNUM]); - } -#endif /* PYRAMID_CONTROL_FRAME_DEBUGGING */ -} - -/* Store our register values back into the inferior. - If REGNO is -1, do this for all registers. - Otherwise, REGNO specifies which register (so we can save time). */ - -store_inferior_registers (regno) - int regno; -{ - register unsigned int regaddr; - char buf[80]; - - if (regno >= 0) - { - if ((0 <= regno) && (regno < 64)) { - /*regaddr = register_addr (regno, offset);*/ - regaddr = regno; - errno = 0; - ptrace (6, inferior_pid, regaddr, read_register (regno)); - if (errno != 0) - { - sprintf (buf, "writing register number %d", regno); - perror_with_name (buf); - } - } - } - else - { - for (regno = 0; regno < NUM_REGS; regno++) - { - /*regaddr = register_addr (regno, offset);*/ - regaddr = regno; - errno = 0; - ptrace (6, inferior_pid, regaddr, read_register (regno)); - if (errno != 0) - { - sprintf (buf, "writing all regs, number %d", regno); - perror_with_name (buf); - } - } -} - -/*** Extensions to core and dump files, for GDB. */ - -extern unsigned int last_frame_offset; - -#ifdef PYRAMID_CORE - -/* Can't make definitions here static, since core.c needs them - to do bounds checking on the core-file areas. O well. */ - -/* have two stacks: one for data, one for register windows. */ -extern CORE_ADDR reg_stack_start; -extern CORE_ADDR reg_stack_end; - -/* need this so we can find the global registers: they never get saved. */ -CORE_ADDR global_reg_offset; -static CORE_ADDR last_frame_address; -CORE_ADDR last_frame_offset; - - -/* Address in core file of start of register window stack area. - Don't know if is this any of meaningful, useful or necessary. */ -extern int reg_stack_offset; - -#endif /* PYRAMID_CORE */ - - -/* Work with core dump and executable files, for GDB. - This code would be in core.c if it weren't machine-dependent. */ - -void -core_file_command (filename, from_tty) - char *filename; - int from_tty; -{ - int val; - extern char registers[]; - - /* Discard all vestiges of any previous core file - and mark data and stack spaces as empty. */ - - if (corefile) - free (corefile); - corefile = 0; - - if (corechan >= 0) - close (corechan); - corechan = -1; - - data_start = 0; - data_end = 0; - stack_start = STACK_END_ADDR; - stack_end = STACK_END_ADDR; - -#ifdef PYRAMID_CORE - reg_stack_start = CONTROL_STACK_ADDR; - reg_stack_end = CONTROL_STACK_ADDR; /* this isn't strictly true...*/ -#endif /* PYRAMID_CORE */ - - /* Now, if a new core file was specified, open it and digest it. */ - - if (filename) - { - filename = tilde_expand (filename); - make_cleanup (free, filename); - - if (have_inferior_p ()) - error ("To look at a core file, you must kill the inferior with \"kill\"."); - corechan = open (filename, O_RDONLY, 0); - if (corechan < 0) - perror_with_name (filename); - /* 4.2-style (and perhaps also sysV-style) core dump file. */ - { - struct user u; - - unsigned int reg_offset; - - val = myread (corechan, &u, sizeof u); - if (val < 0) - perror_with_name ("Not a core file: reading upage"); - if (val != sizeof u) - error ("Not a core file: could only read %d bytes", val); - data_start = exec_data_start; - - data_end = data_start + NBPG * u.u_dsize; - data_offset = NBPG * UPAGES; - stack_offset = NBPG * (UPAGES + u.u_dsize); - - /* find registers in core file */ -#ifdef PYRAMID_PTRACE - stack_start = stack_end - NBPG * u.u_ussize; - reg_stack_offset = stack_offset + (NBPG *u.u_ussize); - reg_stack_end = reg_stack_start + NBPG * u.u_cssize; - - last_frame_address = ((int) u.u_pcb.pcb_csp); - last_frame_offset = reg_stack_offset + last_frame_address - - CONTROL_STACK_ADDR ; - global_reg_offset = (char *)&u - (char *)&u.u_pcb.pcb_gr0 ; - - /* skip any control-stack frames that were executed in the - kernel. */ - - while (1) { - char buf[4]; - val = lseek (corechan, last_frame_offset+(47*4), 0); - if (val < 0) - perror_with_name (filename); - val = myread (corechan, buf, sizeof buf); - if (val < 0) - perror_with_name (filename); - - if (*(int *)buf >= 0) - break; - printf ("skipping frame %s\n", local_hex_string (last_frame_address)); - last_frame_offset -= CONTROL_STACK_FRAME_SIZE; - last_frame_address -= CONTROL_STACK_FRAME_SIZE; - } - reg_offset = last_frame_offset; - -#if 1 || defined(PYRAMID_CONTROL_FRAME_DEBUGGING) - printf ("Control stack pointer = %s\n", - local_hex_string (u.u_pcb.pcb_csp)); - printf ("offset to control stack %d outermost frame %d (%s)\n", - reg_stack_offset, reg_offset, local_hex_string (last_frame_address)); -#endif /* PYRAMID_CONTROL_FRAME_DEBUGGING */ - -#else /* not PYRAMID_CORE */ - stack_start = stack_end - NBPG * u.u_ssize; - reg_offset = (int) u.u_ar0 - KERNEL_U_ADDR; -#endif /* not PYRAMID_CORE */ - -#ifdef __not_on_pyr_yet - /* Some machines put an absolute address in here and some put - the offset in the upage of the regs. */ - reg_offset = (int) u.u_ar0; - if (reg_offset > NBPG * UPAGES) - reg_offset -= KERNEL_U_ADDR; -#endif - - /* I don't know where to find this info. - So, for now, mark it as not available. */ - N_SET_MAGIC (core_aouthdr, 0); - - /* Read the register values out of the core file and store - them where `read_register' will find them. */ - - { - register int regno; - - for (regno = 0; regno < 64; regno++) - { - char buf[MAX_REGISTER_RAW_SIZE]; - - val = lseek (corechan, register_addr (regno, reg_offset), 0); - if (val < 0 - || (val = myread (corechan, buf, sizeof buf)) < 0) - { - char * buffer = (char *) alloca (strlen (reg_names[regno]) - + 30); - strcpy (buffer, "Reading register "); - strcat (buffer, reg_names[regno]); - - perror_with_name (buffer); - } - - if (val < 0) - perror_with_name (filename); -#ifdef PYRAMID_CONTROL_FRAME_DEBUGGING - printf ("[reg %s(%d), offset in file %s=0x%0x, addr =0x%0x, =%0x]\n", - reg_names[regno], regno, filename, - register_addr(regno, reg_offset), - regno * 4 + last_frame_address, - *((int *)buf)); -#endif /* PYRAMID_CONTROL_FRAME_DEBUGGING */ - supply_register (regno, buf); - } - } - } - if (filename[0] == '/') - corefile = savestring (filename, strlen (filename)); - else - { - corefile = concat (current_directory, "/", filename, NULL); - } - -#if 1 || defined(PYRAMID_CONTROL_FRAME_DEBUGGING) - printf ("Providing CSP (%s) as nominal address of current frame.\n", - local_hex_string(last_frame_address)); -#endif PYRAMID_CONTROL_FRAME_DEBUGGING - /* FIXME: Which of the following is correct? */ -#if 0 - set_current_frame ( create_new_frame (read_register (FP_REGNUM), - read_pc ())); -#else - set_current_frame ( create_new_frame (last_frame_address, - read_pc ())); -#endif - - select_frame (get_current_frame (), 0); - validate_files (); - } - else if (from_tty) - printf ("No core file now.\n"); -} diff --git a/gdb/regex.c b/gdb/regex.c deleted file mode 100644 index a4c9e26b5cb..00000000000 --- a/gdb/regex.c +++ /dev/null @@ -1,1732 +0,0 @@ -/* Extended regular expression matching and search library. - Copyright (C) 1985, 1989 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* To test, compile with -Dtest. - This Dtestable feature turns this into a self-contained program - which reads a pattern, describes how it compiles, - then reads a string and searches for it. */ - -#ifdef emacs - -/* The `emacs' switch turns on certain special matching commands - that make sense only in emacs. */ - -#include "config.h" -#include "lisp.h" -#include "buffer.h" -#include "syntax.h" - -#else /* not emacs */ - -#ifdef USG -#ifndef BSTRING -#define bcopy(s,d,n) memcpy((d),(s),(n)) -#define bcmp(s1,s2,n) memcmp((s1),(s2),(n)) -#define bzero(s,n) memset((s),0,(n)) -#endif -#endif - -/* Make alloca work the best possible way. */ -#ifdef __GNUC__ -#define alloca __builtin_alloca -#else -#ifdef sparc -#include -#endif -#endif - -/* - * Define the syntax stuff, so we can do the \<...\> things. - */ - -#ifndef Sword /* must be non-zero in some of the tests below... */ -#define Sword 1 -#endif - -#define SYNTAX(c) re_syntax_table[c] - -#ifdef SYNTAX_TABLE - -char *re_syntax_table; - -#else - -static char re_syntax_table[256]; - -static void -init_syntax_once () -{ - register int c; - static int done = 0; - - if (done) - return; - - bzero (re_syntax_table, sizeof re_syntax_table); - - for (c = 'a'; c <= 'z'; c++) - re_syntax_table[c] = Sword; - - for (c = 'A'; c <= 'Z'; c++) - re_syntax_table[c] = Sword; - - for (c = '0'; c <= '9'; c++) - re_syntax_table[c] = Sword; - - done = 1; -} - -#endif /* SYNTAX_TABLE */ -#endif /* not emacs */ - -#include "regex.h" - -/* Number of failure points to allocate space for initially, - when matching. If this number is exceeded, more space is allocated, - so it is not a hard limit. */ - -#ifndef NFAILURES -#define NFAILURES 80 -#endif /* NFAILURES */ - -/* width of a byte in bits */ - -#define BYTEWIDTH 8 - -#ifndef SIGN_EXTEND_CHAR -#define SIGN_EXTEND_CHAR(x) (x) -#endif - -static int obscure_syntax = 0; - -/* Specify the precise syntax of regexp for compilation. - This provides for compatibility for various utilities - which historically have different, incompatible syntaxes. - - The argument SYNTAX is a bit-mask containing the two bits - RE_NO_BK_PARENS and RE_NO_BK_VBAR. */ - -int -re_set_syntax (syntax) -{ - int ret; - - ret = obscure_syntax; - obscure_syntax = syntax; - return ret; -} - -/* re_compile_pattern takes a regular-expression string - and converts it into a buffer full of byte commands for matching. - - PATTERN is the address of the pattern string - SIZE is the length of it. - BUFP is a struct re_pattern_buffer * which points to the info - on where to store the byte commands. - This structure contains a char * which points to the - actual space, which should have been obtained with malloc. - re_compile_pattern may use realloc to grow the buffer space. - - The number of bytes of commands can be found out by looking in - the struct re_pattern_buffer that bufp pointed to, - after re_compile_pattern returns. -*/ - -#define PATPUSH(ch) (*b++ = (char) (ch)) - -#define PATFETCH(c) \ - {if (p == pend) goto end_of_pattern; \ - c = * (unsigned char *) p++; \ - if (translate) c = translate[c]; } - -#define PATFETCH_RAW(c) \ - {if (p == pend) goto end_of_pattern; \ - c = * (unsigned char *) p++; } - -#define PATUNFETCH p-- - -#define EXTEND_BUFFER \ - { char *old_buffer = bufp->buffer; \ - if (bufp->allocated == (1<<16)) goto too_big; \ - bufp->allocated *= 2; \ - if (bufp->allocated > (1<<16)) bufp->allocated = (1<<16); \ - if (!(bufp->buffer = (char *) realloc (bufp->buffer, bufp->allocated))) \ - goto memory_exhausted; \ - c = bufp->buffer - old_buffer; \ - b += c; \ - if (fixup_jump) \ - fixup_jump += c; \ - if (laststart) \ - laststart += c; \ - begalt += c; \ - if (pending_exact) \ - pending_exact += c; \ - } - -static int store_jump (), insert_jump (); - -char * -re_compile_pattern (pattern, size, bufp) - char *pattern; - int size; - struct re_pattern_buffer *bufp; -{ - register char *b = bufp->buffer; - register char *p = pattern; - char *pend = pattern + size; - register unsigned c, c1; - char *p1; - unsigned char *translate = (unsigned char *) bufp->translate; - - /* address of the count-byte of the most recently inserted "exactn" command. - This makes it possible to tell whether a new exact-match character - can be added to that command or requires a new "exactn" command. */ - - char *pending_exact = 0; - - /* address of the place where a forward-jump should go - to the end of the containing expression. - Each alternative of an "or", except the last, ends with a forward-jump - of this sort. */ - - char *fixup_jump = 0; - - /* address of start of the most recently finished expression. - This tells postfix * where to find the start of its operand. */ - - char *laststart = 0; - - /* In processing a repeat, 1 means zero matches is allowed */ - - char zero_times_ok; - - /* In processing a repeat, 1 means many matches is allowed */ - - char many_times_ok; - - /* address of beginning of regexp, or inside of last \( */ - - char *begalt = b; - - /* Stack of information saved by \( and restored by \). - Four stack elements are pushed by each \(: - First, the value of b. - Second, the value of fixup_jump. - Third, the value of regnum. - Fourth, the value of begalt. */ - - int stackb[40]; - int *stackp = stackb; - int *stacke = stackb + 40; - int *stackt; - - /* Counts \('s as they are encountered. Remembered for the matching \), - where it becomes the "register number" to put in the stop_memory command */ - - int regnum = 1; - - bufp->fastmap_accurate = 0; - -#ifndef emacs -#ifndef SYNTAX_TABLE - /* - * Initialize the syntax table. - */ - init_syntax_once(); -#endif -#endif - - if (bufp->allocated == 0) - { - bufp->allocated = 28; - if (bufp->buffer) - /* EXTEND_BUFFER loses when bufp->allocated is 0 */ - bufp->buffer = (char *) realloc (bufp->buffer, 28); - else - /* Caller did not allocate a buffer. Do it for him */ - bufp->buffer = (char *) malloc (28); - if (!bufp->buffer) goto memory_exhausted; - begalt = b = bufp->buffer; - } - - while (p != pend) - { - if (b - bufp->buffer > bufp->allocated - 10) - /* Note that EXTEND_BUFFER clobbers c */ - EXTEND_BUFFER; - - PATFETCH (c); - - switch (c) - { - case '$': - if (obscure_syntax & RE_TIGHT_VBAR) - { - if (! (obscure_syntax & RE_CONTEXT_INDEP_OPS) && p != pend) - goto normal_char; - /* Make operand of last vbar end before this `$'. */ - if (fixup_jump) - store_jump (fixup_jump, jump, b); - fixup_jump = 0; - PATPUSH (endline); - break; - } - - /* $ means succeed if at end of line, but only in special contexts. - If randomly in the middle of a pattern, it is a normal character. */ - if (p == pend || *p == '\n' - || (obscure_syntax & RE_CONTEXT_INDEP_OPS) - || (obscure_syntax & RE_NO_BK_PARENS - ? *p == ')' - : *p == '\\' && p[1] == ')') - || (obscure_syntax & RE_NO_BK_VBAR - ? *p == '|' - : *p == '\\' && p[1] == '|')) - { - PATPUSH (endline); - break; - } - goto normal_char; - - case '^': - /* ^ means succeed if at beg of line, but only if no preceding pattern. */ - - if (laststart && p[-2] != '\n' - && ! (obscure_syntax & RE_CONTEXT_INDEP_OPS)) - goto normal_char; - if (obscure_syntax & RE_TIGHT_VBAR) - { - if (p != pattern + 1 - && ! (obscure_syntax & RE_CONTEXT_INDEP_OPS)) - goto normal_char; - PATPUSH (begline); - begalt = b; - } - else - PATPUSH (begline); - break; - - case '+': - case '?': - if (obscure_syntax & RE_BK_PLUS_QM) - goto normal_char; - handle_plus: - case '*': - /* If there is no previous pattern, char not special. */ - if (!laststart && ! (obscure_syntax & RE_CONTEXT_INDEP_OPS)) - goto normal_char; - /* If there is a sequence of repetition chars, - collapse it down to equivalent to just one. */ - zero_times_ok = 0; - many_times_ok = 0; - while (1) - { - zero_times_ok |= c != '+'; - many_times_ok |= c != '?'; - if (p == pend) - break; - PATFETCH (c); - if (c == '*') - ; - else if (!(obscure_syntax & RE_BK_PLUS_QM) - && (c == '+' || c == '?')) - ; - else if ((obscure_syntax & RE_BK_PLUS_QM) - && c == '\\') - { - int c1; - PATFETCH (c1); - if (!(c1 == '+' || c1 == '?')) - { - PATUNFETCH; - PATUNFETCH; - break; - } - c = c1; - } - else - { - PATUNFETCH; - break; - } - } - - /* Star, etc. applied to an empty pattern is equivalent - to an empty pattern. */ - if (!laststart) - break; - - /* Now we know whether 0 matches is allowed, - and whether 2 or more matches is allowed. */ - if (many_times_ok) - { - /* If more than one repetition is allowed, - put in a backward jump at the end. */ - store_jump (b, maybe_finalize_jump, laststart - 3); - b += 3; - } - insert_jump (on_failure_jump, laststart, b + 3, b); - pending_exact = 0; - b += 3; - if (!zero_times_ok) - { - /* At least one repetition required: insert before the loop - a skip over the initial on-failure-jump instruction */ - insert_jump (dummy_failure_jump, laststart, laststart + 6, b); - b += 3; - } - break; - - case '.': - laststart = b; - PATPUSH (anychar); - break; - - case '[': - while (b - bufp->buffer - > bufp->allocated - 3 - (1 << BYTEWIDTH) / BYTEWIDTH) - /* Note that EXTEND_BUFFER clobbers c */ - EXTEND_BUFFER; - - laststart = b; - if (*p == '^') - PATPUSH (charset_not), p++; - else - PATPUSH (charset); - p1 = p; - - PATPUSH ((1 << BYTEWIDTH) / BYTEWIDTH); - /* Clear the whole map */ - bzero (b, (1 << BYTEWIDTH) / BYTEWIDTH); - /* Read in characters and ranges, setting map bits */ - while (1) - { - PATFETCH (c); - if (c == ']' && p != p1 + 1) break; - if (*p == '-' && p[1] != ']') - { - PATFETCH (c1); - PATFETCH (c1); - while (c <= c1) - b[c / BYTEWIDTH] |= 1 << (c % BYTEWIDTH), c++; - } - else - { - b[c / BYTEWIDTH] |= 1 << (c % BYTEWIDTH); - } - } - /* Discard any bitmap bytes that are all 0 at the end of the map. - Decrement the map-length byte too. */ - while ((int) b[-1] > 0 && b[b[-1] - 1] == 0) - b[-1]--; - b += b[-1]; - break; - - case '(': - if (! (obscure_syntax & RE_NO_BK_PARENS)) - goto normal_char; - else - goto handle_open; - - case ')': - if (! (obscure_syntax & RE_NO_BK_PARENS)) - goto normal_char; - else - goto handle_close; - - case '\n': - if (! (obscure_syntax & RE_NEWLINE_OR)) - goto normal_char; - else - goto handle_bar; - - case '|': - if (! (obscure_syntax & RE_NO_BK_VBAR)) - goto normal_char; - else - goto handle_bar; - - case '\\': - if (p == pend) goto invalid_pattern; - PATFETCH_RAW (c); - switch (c) - { - case '(': - if (obscure_syntax & RE_NO_BK_PARENS) - goto normal_backsl; - handle_open: - if (stackp == stacke) goto nesting_too_deep; - if (regnum < RE_NREGS) - { - PATPUSH (start_memory); - PATPUSH (regnum); - } - *stackp++ = b - bufp->buffer; - *stackp++ = fixup_jump ? fixup_jump - bufp->buffer + 1 : 0; - *stackp++ = regnum++; - *stackp++ = begalt - bufp->buffer; - fixup_jump = 0; - laststart = 0; - begalt = b; - break; - - case ')': - if (obscure_syntax & RE_NO_BK_PARENS) - goto normal_backsl; - handle_close: - if (stackp == stackb) goto unmatched_close; - begalt = *--stackp + bufp->buffer; - if (fixup_jump) - store_jump (fixup_jump, jump, b); - if (stackp[-1] < RE_NREGS) - { - PATPUSH (stop_memory); - PATPUSH (stackp[-1]); - } - stackp -= 2; - fixup_jump = 0; - if (*stackp) - fixup_jump = *stackp + bufp->buffer - 1; - laststart = *--stackp + bufp->buffer; - break; - - case '|': - if (obscure_syntax & RE_NO_BK_VBAR) - goto normal_backsl; - handle_bar: - insert_jump (on_failure_jump, begalt, b + 6, b); - pending_exact = 0; - b += 3; - if (fixup_jump) - store_jump (fixup_jump, jump, b); - fixup_jump = b; - b += 3; - laststart = 0; - begalt = b; - break; - -#ifdef emacs - case '=': - PATPUSH (at_dot); - break; - - case 's': - laststart = b; - PATPUSH (syntaxspec); - PATFETCH (c); - PATPUSH (syntax_spec_code[c]); - break; - - case 'S': - laststart = b; - PATPUSH (notsyntaxspec); - PATFETCH (c); - PATPUSH (syntax_spec_code[c]); - break; -#endif /* emacs */ - - case 'w': - laststart = b; - PATPUSH (wordchar); - break; - - case 'W': - laststart = b; - PATPUSH (notwordchar); - break; - - case '<': - PATPUSH (wordbeg); - break; - - case '>': - PATPUSH (wordend); - break; - - case 'b': - PATPUSH (wordbound); - break; - - case 'B': - PATPUSH (notwordbound); - break; - - case '`': - PATPUSH (begbuf); - break; - - case '\'': - PATPUSH (endbuf); - break; - - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - c1 = c - '0'; - if (c1 >= regnum) - goto normal_char; - for (stackt = stackp - 2; stackt > stackb; stackt -= 4) - if (*stackt == c1) - goto normal_char; - laststart = b; - PATPUSH (duplicate); - PATPUSH (c1); - break; - - case '+': - case '?': - if (obscure_syntax & RE_BK_PLUS_QM) - goto handle_plus; - - default: - normal_backsl: - /* You might think it would be useful for \ to mean - not to translate; but if we don't translate it - it will never match anything. */ - if (translate) c = translate[c]; - goto normal_char; - } - break; - - default: - normal_char: - if (!pending_exact || pending_exact + *pending_exact + 1 != b - || *pending_exact == 0177 || *p == '*' || *p == '^' - || ((obscure_syntax & RE_BK_PLUS_QM) - ? *p == '\\' && (p[1] == '+' || p[1] == '?') - : (*p == '+' || *p == '?'))) - { - laststart = b; - PATPUSH (exactn); - pending_exact = b; - PATPUSH (0); - } - PATPUSH (c); - (*pending_exact)++; - } - } - - if (fixup_jump) - store_jump (fixup_jump, jump, b); - - if (stackp != stackb) goto unmatched_open; - - bufp->used = b - bufp->buffer; - return 0; - - invalid_pattern: - return "Invalid regular expression"; - - unmatched_open: - return "Unmatched \\("; - - unmatched_close: - return "Unmatched \\)"; - - end_of_pattern: - return "Premature end of regular expression"; - - nesting_too_deep: - return "Nesting too deep"; - - too_big: - return "Regular expression too big"; - - memory_exhausted: - return "Memory exhausted"; -} - -/* Store where `from' points a jump operation to jump to where `to' points. - `opcode' is the opcode to store. */ - -static int -store_jump (from, opcode, to) - char *from, *to; - char opcode; -{ - from[0] = opcode; - from[1] = (to - (from + 3)) & 0377; - from[2] = (to - (from + 3)) >> 8; -} - -/* Open up space at char FROM, and insert there a jump to TO. - CURRENT_END gives te end of the storage no in use, - so we know how much data to copy up. - OP is the opcode of the jump to insert. - - If you call this function, you must zero out pending_exact. */ - -static int -insert_jump (op, from, to, current_end) - char op; - char *from, *to, *current_end; -{ - register char *pto = current_end + 3; - register char *pfrom = current_end; - while (pfrom != from) - *--pto = *--pfrom; - store_jump (from, op, to); -} - -/* Given a pattern, compute a fastmap from it. - The fastmap records which of the (1 << BYTEWIDTH) possible characters - can start a string that matches the pattern. - This fastmap is used by re_search to skip quickly over totally implausible text. - - The caller must supply the address of a (1 << BYTEWIDTH)-byte data area - as bufp->fastmap. - The other components of bufp describe the pattern to be used. */ - -void -re_compile_fastmap (bufp) - struct re_pattern_buffer *bufp; -{ - unsigned char *pattern = (unsigned char *) bufp->buffer; - int size = bufp->used; - register char *fastmap = bufp->fastmap; - register unsigned char *p = pattern; - register unsigned char *pend = pattern + size; - register int j, k; - unsigned char *translate = (unsigned char *) bufp->translate; - - unsigned char *stackb[NFAILURES]; - unsigned char **stackp = stackb; - - bzero (fastmap, (1 << BYTEWIDTH)); - bufp->fastmap_accurate = 1; - bufp->can_be_null = 0; - - while (p) - { - if (p == pend) - { - bufp->can_be_null = 1; - break; - } -#ifdef SWITCH_ENUM_BUG - switch ((int) ((enum regexpcode) *p++)) -#else - switch ((enum regexpcode) *p++) -#endif - { - case exactn: - if (translate) - fastmap[translate[p[1]]] = 1; - else - fastmap[p[1]] = 1; - break; - - case begline: - case before_dot: - case at_dot: - case after_dot: - case begbuf: - case endbuf: - case wordbound: - case notwordbound: - case wordbeg: - case wordend: - continue; - - case endline: - if (translate) - fastmap[translate['\n']] = 1; - else - fastmap['\n'] = 1; - if (bufp->can_be_null != 1) - bufp->can_be_null = 2; - break; - - case finalize_jump: - case maybe_finalize_jump: - case jump: - case dummy_failure_jump: - bufp->can_be_null = 1; - j = *p++ & 0377; - j += SIGN_EXTEND_CHAR (*(char *)p) << 8; - p += j + 1; /* The 1 compensates for missing ++ above */ - if (j > 0) - continue; - /* Jump backward reached implies we just went through - the body of a loop and matched nothing. - Opcode jumped to should be an on_failure_jump. - Just treat it like an ordinary jump. - For a * loop, it has pushed its failure point already; - if so, discard that as redundant. */ - if ((enum regexpcode) *p != on_failure_jump) - continue; - p++; - j = *p++ & 0377; - j += SIGN_EXTEND_CHAR (*(char *)p) << 8; - p += j + 1; /* The 1 compensates for missing ++ above */ - if (stackp != stackb && *stackp == p) - stackp--; - continue; - - case on_failure_jump: - j = *p++ & 0377; - j += SIGN_EXTEND_CHAR (*(char *)p) << 8; - p++; - *++stackp = p + j; - continue; - - case start_memory: - case stop_memory: - p++; - continue; - - case duplicate: - bufp->can_be_null = 1; - fastmap['\n'] = 1; - case anychar: - for (j = 0; j < (1 << BYTEWIDTH); j++) - if (j != '\n') - fastmap[j] = 1; - if (bufp->can_be_null) - return; - /* Don't return; check the alternative paths - so we can set can_be_null if appropriate. */ - break; - - case wordchar: - for (j = 0; j < (1 << BYTEWIDTH); j++) - if (SYNTAX (j) == Sword) - fastmap[j] = 1; - break; - - case notwordchar: - for (j = 0; j < (1 << BYTEWIDTH); j++) - if (SYNTAX (j) != Sword) - fastmap[j] = 1; - break; - -#ifdef emacs - case syntaxspec: - k = *p++; - for (j = 0; j < (1 << BYTEWIDTH); j++) - if (SYNTAX (j) == (enum syntaxcode) k) - fastmap[j] = 1; - break; - - case notsyntaxspec: - k = *p++; - for (j = 0; j < (1 << BYTEWIDTH); j++) - if (SYNTAX (j) != (enum syntaxcode) k) - fastmap[j] = 1; - break; -#endif /* emacs */ - - case charset: - for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) - if (p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH))) - { - if (translate) - fastmap[translate[j]] = 1; - else - fastmap[j] = 1; - } - break; - - case charset_not: - /* Chars beyond end of map must be allowed */ - for (j = *p * BYTEWIDTH; j < (1 << BYTEWIDTH); j++) - if (translate) - fastmap[translate[j]] = 1; - else - fastmap[j] = 1; - - for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--) - if (!(p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH)))) - { - if (translate) - fastmap[translate[j]] = 1; - else - fastmap[j] = 1; - } - break; - } - - /* Get here means we have successfully found the possible starting characters - of one path of the pattern. We need not follow this path any farther. - Instead, look at the next alternative remembered in the stack. */ - if (stackp != stackb) - p = *stackp--; - else - break; - } -} - -/* Like re_search_2, below, but only one string is specified. */ - -int -re_search (pbufp, string, size, startpos, range, regs) - struct re_pattern_buffer *pbufp; - char *string; - int size, startpos, range; - struct re_registers *regs; -{ - return re_search_2 (pbufp, 0, 0, string, size, startpos, range, regs, size); -} - -/* Like re_match_2 but tries first a match starting at index STARTPOS, - then at STARTPOS + 1, and so on. - RANGE is the number of places to try before giving up. - If RANGE is negative, the starting positions tried are - STARTPOS, STARTPOS - 1, etc. - It is up to the caller to make sure that range is not so large - as to take the starting position outside of the input strings. - -The value returned is the position at which the match was found, - or -1 if no match was found, - or -2 if error (such as failure stack overflow). */ - -int -re_search_2 (pbufp, string1, size1, string2, size2, startpos, range, regs, mstop) - struct re_pattern_buffer *pbufp; - char *string1, *string2; - int size1, size2; - int startpos; - register int range; - struct re_registers *regs; - int mstop; -{ - register char *fastmap = pbufp->fastmap; - register unsigned char *translate = (unsigned char *) pbufp->translate; - int total = size1 + size2; - int val; - - /* Update the fastmap now if not correct already */ - if (fastmap && !pbufp->fastmap_accurate) - re_compile_fastmap (pbufp); - - /* Don't waste time in a long search for a pattern - that says it is anchored. */ - if (pbufp->used > 0 && (enum regexpcode) pbufp->buffer[0] == begbuf - && range > 0) - { - if (startpos > 0) - return -1; - else - range = 1; - } - - while (1) - { - /* If a fastmap is supplied, skip quickly over characters - that cannot possibly be the start of a match. - Note, however, that if the pattern can possibly match - the null string, we must test it at each starting point - so that we take the first null string we get. */ - - if (fastmap && startpos < total && pbufp->can_be_null != 1) - { - if (range > 0) - { - register int lim = 0; - register unsigned char *p; - int irange = range; - if (startpos < size1 && startpos + range >= size1) - lim = range - (size1 - startpos); - - p = ((unsigned char *) - &(startpos >= size1 ? string2 - size1 : string1)[startpos]); - - if (translate) - { - while (range > lim && !fastmap[translate[*p++]]) - range--; - } - else - { - while (range > lim && !fastmap[*p++]) - range--; - } - startpos += irange - range; - } - else - { - register unsigned char c; - if (startpos >= size1) - c = string2[startpos - size1]; - else - c = string1[startpos]; - c &= 0xff; - if (translate ? !fastmap[translate[c]] : !fastmap[c]) - goto advance; - } - } - - if (range >= 0 && startpos == total - && fastmap && pbufp->can_be_null == 0) - return -1; - - val = re_match_2 (pbufp, string1, size1, string2, size2, startpos, regs, mstop); - if (0 <= val) - { - if (val == -2) - return -2; - return startpos; - } - -#ifdef C_ALLOCA - alloca (0); -#endif /* C_ALLOCA */ - - advance: - if (!range) break; - if (range > 0) range--, startpos++; else range++, startpos--; - } - return -1; -} - -#ifndef emacs /* emacs never uses this */ -int -re_match (pbufp, string, size, pos, regs) - struct re_pattern_buffer *pbufp; - char *string; - int size, pos; - struct re_registers *regs; -{ - return re_match_2 (pbufp, 0, 0, string, size, pos, regs, size); -} -#endif /* emacs */ - -/* Maximum size of failure stack. Beyond this, overflow is an error. */ - -int re_max_failures = 2000; - -static int bcmp_translate(); -/* Match the pattern described by PBUFP - against data which is the virtual concatenation of STRING1 and STRING2. - SIZE1 and SIZE2 are the sizes of the two data strings. - Start the match at position POS. - Do not consider matching past the position MSTOP. - - If pbufp->fastmap is nonzero, then it had better be up to date. - - The reason that the data to match are specified as two components - which are to be regarded as concatenated - is so this function can be used directly on the contents of an Emacs buffer. - - -1 is returned if there is no match. -2 is returned if there is - an error (such as match stack overflow). Otherwise the value is the length - of the substring which was matched. */ - -int -re_match_2 (pbufp, string1, size1, string2, size2, pos, regs, mstop) - struct re_pattern_buffer *pbufp; - unsigned char *string1, *string2; - int size1, size2; - int pos; - struct re_registers *regs; - int mstop; -{ - register unsigned char *p = (unsigned char *) pbufp->buffer; - register unsigned char *pend = p + pbufp->used; - /* End of first string */ - unsigned char *end1; - /* End of second string */ - unsigned char *end2; - /* Pointer just past last char to consider matching */ - unsigned char *end_match_1, *end_match_2; - register unsigned char *d, *dend; - register int mcnt; - unsigned char *translate = (unsigned char *) pbufp->translate; - - /* Failure point stack. Each place that can handle a failure further down the line - pushes a failure point on this stack. It consists of two char *'s. - The first one pushed is where to resume scanning the pattern; - the second pushed is where to resume scanning the strings. - If the latter is zero, the failure point is a "dummy". - If a failure happens and the innermost failure point is dormant, - it discards that failure point and tries the next one. */ - - unsigned char *initial_stack[2 * NFAILURES]; - unsigned char **stackb = initial_stack; - unsigned char **stackp = stackb, **stacke = &stackb[2 * NFAILURES]; - - /* Information on the "contents" of registers. - These are pointers into the input strings; they record - just what was matched (on this attempt) by some part of the pattern. - The start_memory command stores the start of a register's contents - and the stop_memory command stores the end. - - At that point, regstart[regnum] points to the first character in the register, - regend[regnum] points to the first character beyond the end of the register, - regstart_seg1[regnum] is true iff regstart[regnum] points into string1, - and regend_seg1[regnum] is true iff regend[regnum] points into string1. */ - - unsigned char *regstart[RE_NREGS]; - unsigned char *regend[RE_NREGS]; - unsigned char regstart_seg1[RE_NREGS], regend_seg1[RE_NREGS]; - - /* Set up pointers to ends of strings. - Don't allow the second string to be empty unless both are empty. */ - if (!size2) - { - string2 = string1; - size2 = size1; - string1 = 0; - size1 = 0; - } - end1 = string1 + size1; - end2 = string2 + size2; - - /* Compute where to stop matching, within the two strings */ - if (mstop <= size1) - { - end_match_1 = string1 + mstop; - end_match_2 = string2; - } - else - { - end_match_1 = end1; - end_match_2 = string2 + mstop - size1; - } - - /* Initialize \) text positions to -1 - to mark ones that no \( or \) has been seen for. */ - - for (mcnt = 0; mcnt < sizeof (regend) / sizeof (*regend); mcnt++) - regend[mcnt] = (unsigned char *) -1; - - /* `p' scans through the pattern as `d' scans through the data. - `dend' is the end of the input string that `d' points within. - `d' is advanced into the following input string whenever necessary, - but this happens before fetching; - therefore, at the beginning of the loop, - `d' can be pointing at the end of a string, - but it cannot equal string2. */ - - if (pos <= size1) - d = string1 + pos, dend = end_match_1; - else - d = string2 + pos - size1, dend = end_match_2; - -/* Write PREFETCH; just before fetching a character with *d. */ -#define PREFETCH \ - while (d == dend) \ - { if (dend == end_match_2) goto fail; /* end of string2 => failure */ \ - d = string2; /* end of string1 => advance to string2. */ \ - dend = end_match_2; } - - /* This loop loops over pattern commands. - It exits by returning from the function if match is complete, - or it drops through if match fails at this starting point in the input data. */ - - while (1) - { - if (p == pend) - /* End of pattern means we have succeeded! */ - { - /* If caller wants register contents data back, convert it to indices */ - if (regs) - { - regs->start[0] = pos; - if (dend == end_match_1) - regs->end[0] = d - string1; - else - regs->end[0] = d - string2 + size1; - for (mcnt = 1; mcnt < RE_NREGS; mcnt++) - { - if (regend[mcnt] == (unsigned char *) -1) - { - regs->start[mcnt] = -1; - regs->end[mcnt] = -1; - continue; - } - if (regstart_seg1[mcnt]) - regs->start[mcnt] = regstart[mcnt] - string1; - else - regs->start[mcnt] = regstart[mcnt] - string2 + size1; - if (regend_seg1[mcnt]) - regs->end[mcnt] = regend[mcnt] - string1; - else - regs->end[mcnt] = regend[mcnt] - string2 + size1; - } - } - if (dend == end_match_1) - return (d - string1 - pos); - else - return d - string2 + size1 - pos; - } - - /* Otherwise match next pattern command */ -#ifdef SWITCH_ENUM_BUG - switch ((int) ((enum regexpcode) *p++)) -#else - switch ((enum regexpcode) *p++) -#endif - { - - /* \( is represented by a start_memory, \) by a stop_memory. - Both of those commands contain a "register number" argument. - The text matched within the \( and \) is recorded under that number. - Then, \ turns into a `duplicate' command which - is followed by the numeric value of as the register number. */ - - case start_memory: - regstart[*p] = d; - regstart_seg1[*p++] = (dend == end_match_1); - break; - - case stop_memory: - regend[*p] = d; - regend_seg1[*p++] = (dend == end_match_1); - break; - - case duplicate: - { - int regno = *p++; /* Get which register to match against */ - register unsigned char *d2, *dend2; - - d2 = regstart[regno]; - dend2 = ((regstart_seg1[regno] == regend_seg1[regno]) - ? regend[regno] : end_match_1); - while (1) - { - /* Advance to next segment in register contents, if necessary */ - while (d2 == dend2) - { - if (dend2 == end_match_2) break; - if (dend2 == regend[regno]) break; - d2 = string2, dend2 = regend[regno]; /* end of string1 => advance to string2. */ - } - /* At end of register contents => success */ - if (d2 == dend2) break; - - /* Advance to next segment in data being matched, if necessary */ - PREFETCH; - - /* mcnt gets # consecutive chars to compare */ - mcnt = dend - d; - if (mcnt > dend2 - d2) - mcnt = dend2 - d2; - /* Compare that many; failure if mismatch, else skip them. */ - if (translate ? bcmp_translate (d, d2, mcnt, translate) : bcmp (d, d2, mcnt)) - goto fail; - d += mcnt, d2 += mcnt; - } - } - break; - - case anychar: - /* fetch a data character */ - PREFETCH; - /* Match anything but a newline. */ - if ((translate ? translate[*d++] : *d++) == '\n') - goto fail; - break; - - case charset: - case charset_not: - { - /* Nonzero for charset_not */ - int not = 0; - register int c; - if (*(p - 1) == (unsigned char) charset_not) - not = 1; - - /* fetch a data character */ - PREFETCH; - - if (translate) - c = translate [*d]; - else - c = *d; - - if (c < *p * BYTEWIDTH - && p[1 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH))) - not = !not; - - p += 1 + *p; - - if (!not) goto fail; - d++; - break; - } - - case begline: - if (d == string1 || d[-1] == '\n') - break; - goto fail; - - case endline: - if (d == end2 - || (d == end1 ? (size2 == 0 || *string2 == '\n') : *d == '\n')) - break; - goto fail; - - /* "or" constructs ("|") are handled by starting each alternative - with an on_failure_jump that points to the start of the next alternative. - Each alternative except the last ends with a jump to the joining point. - (Actually, each jump except for the last one really jumps - to the following jump, because tensioning the jumps is a hassle.) */ - - /* The start of a stupid repeat has an on_failure_jump that points - past the end of the repeat text. - This makes a failure point so that, on failure to match a repetition, - matching restarts past as many repetitions have been found - with no way to fail and look for another one. */ - - /* A smart repeat is similar but loops back to the on_failure_jump - so that each repetition makes another failure point. */ - - case on_failure_jump: - if (stackp == stacke) - { - unsigned char **stackx; - if (stacke - stackb > re_max_failures * 2) - return -2; - stackx = (unsigned char **) alloca (2 * (stacke - stackb) - * sizeof (char *)); - bcopy (stackb, stackx, (stacke - stackb) * sizeof (char *)); - stackp = stackx + (stackp - stackb); - stacke = stackx + 2 * (stacke - stackb); - stackb = stackx; - } - mcnt = *p++ & 0377; - mcnt += SIGN_EXTEND_CHAR (*(char *)p) << 8; - p++; - *stackp++ = mcnt + p; - *stackp++ = d; - break; - - /* The end of a smart repeat has an maybe_finalize_jump back. - Change it either to a finalize_jump or an ordinary jump. */ - - case maybe_finalize_jump: - mcnt = *p++ & 0377; - mcnt += SIGN_EXTEND_CHAR (*(char *)p) << 8; - p++; - { - register unsigned char *p2 = p; - /* Compare what follows with the begining of the repeat. - If we can establish that there is nothing that they would - both match, we can change to finalize_jump */ - while (p2 != pend - && (*p2 == (unsigned char) stop_memory - || *p2 == (unsigned char) start_memory)) - p2++; - if (p2 == pend) - p[-3] = (unsigned char) finalize_jump; - else if (*p2 == (unsigned char) exactn - || *p2 == (unsigned char) endline) - { - register int c = *p2 == (unsigned char) endline ? '\n' : p2[2]; - register unsigned char *p1 = p + mcnt; - /* p1[0] ... p1[2] are an on_failure_jump. - Examine what follows that */ - if (p1[3] == (unsigned char) exactn && p1[5] != c) - p[-3] = (unsigned char) finalize_jump; - else if (p1[3] == (unsigned char) charset - || p1[3] == (unsigned char) charset_not) - { - int not = p1[3] == (unsigned char) charset_not; - if (c < p1[4] * BYTEWIDTH - && p1[5 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH))) - not = !not; - /* not is 1 if c would match */ - /* That means it is not safe to finalize */ - if (!not) - p[-3] = (unsigned char) finalize_jump; - } - } - } - p -= 2; - if (p[-1] != (unsigned char) finalize_jump) - { - p[-1] = (unsigned char) jump; - goto nofinalize; - } - - /* The end of a stupid repeat has a finalize-jump - back to the start, where another failure point will be made - which will point after all the repetitions found so far. */ - - case finalize_jump: - stackp -= 2; - - case jump: - nofinalize: - mcnt = *p++ & 0377; - mcnt += SIGN_EXTEND_CHAR (*(char *)p) << 8; - p += mcnt + 1; /* The 1 compensates for missing ++ above */ - break; - - case dummy_failure_jump: - if (stackp == stacke) - { - unsigned char **stackx - = (unsigned char **) alloca (2 * (stacke - stackb) - * sizeof (char *)); - bcopy (stackb, stackx, (stacke - stackb) * sizeof (char *)); - stackp = stackx + (stackp - stackb); - stacke = stackx + 2 * (stacke - stackb); - stackb = stackx; - } - *stackp++ = 0; - *stackp++ = 0; - goto nofinalize; - - case wordbound: - if (d == string1 /* Points to first char */ - || d == end2 /* Points to end */ - || (d == end1 && size2 == 0)) /* Points to end */ - break; - if ((SYNTAX (d[-1]) == Sword) - != (SYNTAX (d == end1 ? *string2 : *d) == Sword)) - break; - goto fail; - - case notwordbound: - if (d == string1 /* Points to first char */ - || d == end2 /* Points to end */ - || (d == end1 && size2 == 0)) /* Points to end */ - goto fail; - if ((SYNTAX (d[-1]) == Sword) - != (SYNTAX (d == end1 ? *string2 : *d) == Sword)) - goto fail; - break; - - case wordbeg: - if (d == end2 /* Points to end */ - || (d == end1 && size2 == 0) /* Points to end */ - || SYNTAX (* (d == end1 ? string2 : d)) != Sword) /* Next char not a letter */ - goto fail; - if (d == string1 /* Points to first char */ - || SYNTAX (d[-1]) != Sword) /* prev char not letter */ - break; - goto fail; - - case wordend: - if (d == string1 /* Points to first char */ - || SYNTAX (d[-1]) != Sword) /* prev char not letter */ - goto fail; - if (d == end2 /* Points to end */ - || (d == end1 && size2 == 0) /* Points to end */ - || SYNTAX (d == end1 ? *string2 : *d) != Sword) /* Next char not a letter */ - break; - goto fail; - -#ifdef emacs - case before_dot: - if (((d - string2 <= (unsigned) size2) - ? d - bf_p2 : d - bf_p1) - <= point) - goto fail; - break; - - case at_dot: - if (((d - string2 <= (unsigned) size2) - ? d - bf_p2 : d - bf_p1) - == point) - goto fail; - break; - - case after_dot: - if (((d - string2 <= (unsigned) size2) - ? d - bf_p2 : d - bf_p1) - >= point) - goto fail; - break; - - case wordchar: - mcnt = (int) Sword; - goto matchsyntax; - - case syntaxspec: - mcnt = *p++; - matchsyntax: - PREFETCH; - if (SYNTAX (*d++) != (enum syntaxcode) mcnt) goto fail; - break; - - case notwordchar: - mcnt = (int) Sword; - goto matchnotsyntax; - - case notsyntaxspec: - mcnt = *p++; - matchnotsyntax: - PREFETCH; - if (SYNTAX (*d++) == (enum syntaxcode) mcnt) goto fail; - break; -#else - case wordchar: - PREFETCH; - if (SYNTAX (*d++) == 0) goto fail; - break; - - case notwordchar: - PREFETCH; - if (SYNTAX (*d++) != 0) goto fail; - break; -#endif /* not emacs */ - - case begbuf: - if (d == string1) /* Note, d cannot equal string2 */ - break; /* unless string1 == string2. */ - goto fail; - - case endbuf: - if (d == end2 || (d == end1 && size2 == 0)) - break; - goto fail; - - case exactn: - /* Match the next few pattern characters exactly. - mcnt is how many characters to match. */ - mcnt = *p++; - if (translate) - { - do - { - PREFETCH; - if (translate[*d++] != *p++) goto fail; - } - while (--mcnt); - } - else - { - do - { - PREFETCH; - if (*d++ != *p++) goto fail; - } - while (--mcnt); - } - break; - } - continue; /* Successfully matched one pattern command; keep matching */ - - /* Jump here if any matching operation fails. */ - fail: - if (stackp != stackb) - /* A restart point is known. Restart there and pop it. */ - { - if (!stackp[-2]) - { /* If innermost failure point is dormant, flush it and keep looking */ - stackp -= 2; - goto fail; - } - d = *--stackp; - p = *--stackp; - if (d >= string1 && d <= end1) - dend = end_match_1; - } - else break; /* Matching at this starting point really fails! */ - } - return -1; /* Failure to match */ -} - -static int -bcmp_translate (s1, s2, len, translate) - unsigned char *s1, *s2; - register int len; - unsigned char *translate; -{ - register unsigned char *p1 = s1, *p2 = s2; - while (len) - { - if (translate [*p1++] != translate [*p2++]) return 1; - len--; - } - return 0; -} - -/* Entry points compatible with bsd4.2 regex library */ - -#ifndef emacs - -static struct re_pattern_buffer re_comp_buf; - -char * -re_comp (s) - char *s; -{ - if (!s) - { - if (!re_comp_buf.buffer) - return "No previous regular expression"; - return 0; - } - - if (!re_comp_buf.buffer) - { - if (!(re_comp_buf.buffer = (char *) malloc (200))) - return "Memory exhausted"; - re_comp_buf.allocated = 200; - if (!(re_comp_buf.fastmap = (char *) malloc (1 << BYTEWIDTH))) - return "Memory exhausted"; - } - return re_compile_pattern (s, strlen (s), &re_comp_buf); -} - -int -re_exec (s) - char *s; -{ - int len = strlen (s); - return 0 <= re_search (&re_comp_buf, s, len, 0, len, 0); -} - -#endif /* emacs */ - -#ifdef test - -#include - -/* Indexed by a character, gives the upper case equivalent of the character */ - -static char upcase[0400] = - { 000, 001, 002, 003, 004, 005, 006, 007, - 010, 011, 012, 013, 014, 015, 016, 017, - 020, 021, 022, 023, 024, 025, 026, 027, - 030, 031, 032, 033, 034, 035, 036, 037, - 040, 041, 042, 043, 044, 045, 046, 047, - 050, 051, 052, 053, 054, 055, 056, 057, - 060, 061, 062, 063, 064, 065, 066, 067, - 070, 071, 072, 073, 074, 075, 076, 077, - 0100, 0101, 0102, 0103, 0104, 0105, 0106, 0107, - 0110, 0111, 0112, 0113, 0114, 0115, 0116, 0117, - 0120, 0121, 0122, 0123, 0124, 0125, 0126, 0127, - 0130, 0131, 0132, 0133, 0134, 0135, 0136, 0137, - 0140, 0101, 0102, 0103, 0104, 0105, 0106, 0107, - 0110, 0111, 0112, 0113, 0114, 0115, 0116, 0117, - 0120, 0121, 0122, 0123, 0124, 0125, 0126, 0127, - 0130, 0131, 0132, 0173, 0174, 0175, 0176, 0177, - 0200, 0201, 0202, 0203, 0204, 0205, 0206, 0207, - 0210, 0211, 0212, 0213, 0214, 0215, 0216, 0217, - 0220, 0221, 0222, 0223, 0224, 0225, 0226, 0227, - 0230, 0231, 0232, 0233, 0234, 0235, 0236, 0237, - 0240, 0241, 0242, 0243, 0244, 0245, 0246, 0247, - 0250, 0251, 0252, 0253, 0254, 0255, 0256, 0257, - 0260, 0261, 0262, 0263, 0264, 0265, 0266, 0267, - 0270, 0271, 0272, 0273, 0274, 0275, 0276, 0277, - 0300, 0301, 0302, 0303, 0304, 0305, 0306, 0307, - 0310, 0311, 0312, 0313, 0314, 0315, 0316, 0317, - 0320, 0321, 0322, 0323, 0324, 0325, 0326, 0327, - 0330, 0331, 0332, 0333, 0334, 0335, 0336, 0337, - 0340, 0341, 0342, 0343, 0344, 0345, 0346, 0347, - 0350, 0351, 0352, 0353, 0354, 0355, 0356, 0357, - 0360, 0361, 0362, 0363, 0364, 0365, 0366, 0367, - 0370, 0371, 0372, 0373, 0374, 0375, 0376, 0377 - }; - -main (argc, argv) - int argc; - char **argv; -{ - char pat[80]; - struct re_pattern_buffer buf; - int i; - char c; - char fastmap[(1 << BYTEWIDTH)]; - - /* Allow a command argument to specify the style of syntax. */ - if (argc > 1) - obscure_syntax = atoi (argv[1]); - - buf.allocated = 40; - buf.buffer = (char *) malloc (buf.allocated); - buf.fastmap = fastmap; - buf.translate = upcase; - - while (1) - { - gets (pat); - - if (*pat) - { - re_compile_pattern (pat, strlen(pat), &buf); - - for (i = 0; i < buf.used; i++) - printchar (buf.buffer[i]); - - putchar ('\n'); - - printf ("%d allocated, %d used.\n", buf.allocated, buf.used); - - re_compile_fastmap (&buf); - printf ("Allowed by fastmap: "); - for (i = 0; i < (1 << BYTEWIDTH); i++) - if (fastmap[i]) printchar (i); - putchar ('\n'); - } - - gets (pat); /* Now read the string to match against */ - - i = re_match (&buf, pat, strlen (pat), 0, 0); - printf ("Match value %d.\n", i); - } -} - -#ifdef NOTDEF -print_buf (bufp) - struct re_pattern_buffer *bufp; -{ - int i; - - printf ("buf is :\n----------------\n"); - for (i = 0; i < bufp->used; i++) - printchar (bufp->buffer[i]); - - printf ("\n%d allocated, %d used.\n", bufp->allocated, bufp->used); - - printf ("Allowed by fastmap: "); - for (i = 0; i < (1 << BYTEWIDTH); i++) - if (bufp->fastmap[i]) - printchar (i); - printf ("\nAllowed by translate: "); - if (bufp->translate) - for (i = 0; i < (1 << BYTEWIDTH); i++) - if (bufp->translate[i]) - printchar (i); - printf ("\nfastmap is%s accurate\n", bufp->fastmap_accurate ? "" : "n't"); - printf ("can %s be null\n----------", bufp->can_be_null ? "" : "not"); -} -#endif - -printchar (c) - char c; -{ - if (c < 041 || c >= 0177) - { - putchar ('\\'); - putchar (((c >> 6) & 3) + '0'); - putchar (((c >> 3) & 7) + '0'); - putchar ((c & 7) + '0'); - } - else - putchar (c); -} - -error (string) - char *string; -{ - puts (string); - exit (1); -} - -#endif /* test */ diff --git a/gdb/regex.h b/gdb/regex.h deleted file mode 100644 index 6348c3eb6e4..00000000000 --- a/gdb/regex.h +++ /dev/null @@ -1,179 +0,0 @@ -/* Definitions for data structures callers pass the regex library. - Copyright (C) 1985, 1989 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Define number of parens for which we record the beginnings and ends. - This affects how much space the `struct re_registers' type takes up. */ -#ifndef RE_NREGS -#define RE_NREGS 10 -#endif - -/* These bits are used in the obscure_syntax variable to choose among - alternative regexp syntaxes. */ - -/* 1 means plain parentheses serve as grouping, and backslash - parentheses are needed for literal searching. - 0 means backslash-parentheses are grouping, and plain parentheses - are for literal searching. */ -#define RE_NO_BK_PARENS 1 - -/* 1 means plain | serves as the "or"-operator, and \| is a literal. - 0 means \| serves as the "or"-operator, and | is a literal. */ -#define RE_NO_BK_VBAR 2 - -/* 0 means plain + or ? serves as an operator, and \+, \? are literals. - 1 means \+, \? are operators and plain +, ? are literals. */ -#define RE_BK_PLUS_QM 4 - -/* 1 means | binds tighter than ^ or $. - 0 means the contrary. */ -#define RE_TIGHT_VBAR 8 - -/* 1 means treat \n as an _OR operator - 0 means treat it as a normal character */ -#define RE_NEWLINE_OR 16 - -/* 0 means that a special characters (such as *, ^, and $) always have - their special meaning regardless of the surrounding context. - 1 means that special characters may act as normal characters in some - contexts. Specifically, this applies to: - ^ - only special at the beginning, or after ( or | - $ - only special at the end, or before ) or | - *, +, ? - only special when not after the beginning, (, or | */ -#define RE_CONTEXT_INDEP_OPS 32 - -/* Now define combinations of bits for the standard possibilities. */ -#define RE_SYNTAX_AWK (RE_NO_BK_PARENS | RE_NO_BK_VBAR | RE_CONTEXT_INDEP_OPS) -#define RE_SYNTAX_EGREP (RE_SYNTAX_AWK | RE_NEWLINE_OR) -#define RE_SYNTAX_GREP (RE_BK_PLUS_QM | RE_NEWLINE_OR) -#define RE_SYNTAX_EMACS 0 - -/* This data structure is used to represent a compiled pattern. */ - -struct re_pattern_buffer - { - char *buffer; /* Space holding the compiled pattern commands. */ - int allocated; /* Size of space that buffer points to */ - int used; /* Length of portion of buffer actually occupied */ - char *fastmap; /* Pointer to fastmap, if any, or zero if none. */ - /* re_search uses the fastmap, if there is one, - to skip quickly over totally implausible characters */ - char *translate; /* Translate table to apply to all characters before comparing. - Or zero for no translation. - The translation is applied to a pattern when it is compiled - and to data when it is matched. */ - char fastmap_accurate; - /* Set to zero when a new pattern is stored, - set to one when the fastmap is updated from it. */ - char can_be_null; /* Set to one by compiling fastmap - if this pattern might match the null string. - It does not necessarily match the null string - in that case, but if this is zero, it cannot. - 2 as value means can match null string - but at end of range or before a character - listed in the fastmap. */ - }; - -/* Structure to store "register" contents data in. - - Pass the address of such a structure as an argument to re_match, etc., - if you want this information back. - - start[i] and end[i] record the string matched by \( ... \) grouping i, - for i from 1 to RE_NREGS - 1. - start[0] and end[0] record the entire string matched. */ - -struct re_registers - { - int start[RE_NREGS]; - int end[RE_NREGS]; - }; - -/* These are the command codes that appear in compiled regular expressions, one per byte. - Some command codes are followed by argument bytes. - A command code can specify any interpretation whatever for its arguments. - Zero-bytes may appear in the compiled regular expression. */ - -enum regexpcode - { - unused, - exactn, /* followed by one byte giving n, and then by n literal bytes */ - begline, /* fails unless at beginning of line */ - endline, /* fails unless at end of line */ - jump, /* followed by two bytes giving relative address to jump to */ - on_failure_jump, /* followed by two bytes giving relative address of place - to resume at in case of failure. */ - finalize_jump, /* Throw away latest failure point and then jump to address. */ - maybe_finalize_jump, /* Like jump but finalize if safe to do so. - This is used to jump back to the beginning - of a repeat. If the command that follows - this jump is clearly incompatible with the - one at the beginning of the repeat, such that - we can be sure that there is no use backtracking - out of repetitions already completed, - then we finalize. */ - dummy_failure_jump, /* jump, and push a dummy failure point. - This failure point will be thrown away - if an attempt is made to use it for a failure. - A + construct makes this before the first repeat. */ - anychar, /* matches any one character */ - charset, /* matches any one char belonging to specified set. - First following byte is # bitmap bytes. - Then come bytes for a bit-map saying which chars are in. - Bits in each byte are ordered low-bit-first. - A character is in the set if its bit is 1. - A character too large to have a bit in the map - is automatically not in the set */ - charset_not, /* similar but match any character that is NOT one of those specified */ - start_memory, /* starts remembering the text that is matched - and stores it in a memory register. - followed by one byte containing the register number. - Register numbers must be in the range 0 through NREGS. */ - stop_memory, /* stops remembering the text that is matched - and stores it in a memory register. - followed by one byte containing the register number. - Register numbers must be in the range 0 through NREGS. */ - duplicate, /* match a duplicate of something remembered. - Followed by one byte containing the index of the memory register. */ - before_dot, /* Succeeds if before dot */ - at_dot, /* Succeeds if at dot */ - after_dot, /* Succeeds if after dot */ - begbuf, /* Succeeds if at beginning of buffer */ - endbuf, /* Succeeds if at end of buffer */ - wordchar, /* Matches any word-constituent character */ - notwordchar, /* Matches any char that is not a word-constituent */ - wordbeg, /* Succeeds if at word beginning */ - wordend, /* Succeeds if at word end */ - wordbound, /* Succeeds if at a word boundary */ - notwordbound, /* Succeeds if not at a word boundary */ - syntaxspec, /* Matches any character whose syntax is specified. - followed by a byte which contains a syntax code, Sword or such like */ - notsyntaxspec /* Matches any character whose syntax differs from the specified. */ - }; - -extern char *re_compile_pattern (); -/* Is this really advertised? */ -extern void re_compile_fastmap (); -extern int re_search (), re_search_2 (); -extern int re_match (), re_match_2 (); - -/* 4.2 bsd compatibility (yuck) */ -extern char *re_comp (); -extern int re_exec (); - -#ifdef SYNTAX_TABLE -extern char *re_syntax_table; -#endif diff --git a/gdb/rem-m68k.shar b/gdb/rem-m68k.shar deleted file mode 100755 index aeb76e5d851..00000000000 --- a/gdb/rem-m68k.shar +++ /dev/null @@ -1,893 +0,0 @@ -# This is a shell archive. Remove anything before this line, -# then unpack it by saving it in a file and typing "sh file". -# -# Wrapped by Glenn Engel on Mon Jun 12 15:19:20 1989 -# -# This archive contains: -# remcom.c -# - -LANG=""; export LANG -PATH=/bin:/usr/bin:$PATH; export PATH - -echo x - remcom.c -cat >remcom.c <<'@EOF' - -/**************************************************************************** - - THIS SOFTWARE IS NOT COPYRIGHTED - - HP offers the following for use in the public domain. HP makes no - warranty with regard to the software or it's performance and the - user accepts the software "AS IS" with all faults. - - HP 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. - -****************************************************************************/ - -/**************************************************************************** - * $Header$ - * - * $Module name: remcom.c $ - * $Revision$ - * $Date$ - * $Contributor: Lake Stevens Instrument Division$ - * - * $Description: low level support for gdb debugger. $ - * - * $Considerations: only works on target hardware $ - * - * $Written by: Glenn Engel $ - * $ModuleState: Experimental $ - * - * $NOTES: See Below $ - * - * To enable debugger support, two things need to happen. One, a - * call to set_debug_traps() is necessary in order to allow any breakpoints - * or error conditions to be properly intercepted and reported to gdb. - * Two, a breakpoint needs to be generated to begin communication. This - * is most easily accomplished by a call to breakpoint(). Breakpoint() - * simulates a breakpoint by executing a trap #1. - * - * Some explanation is probably necessary to explain how exceptions are - * handled. When an exception is encountered the 68000 pushes the current - * program counter and status register onto the supervisor stack and then - * transfers execution to a location specified in it's vector table. - * The handlers for the exception vectors are hardwired to jmp to an address - * given by the relation: (exception - 256) * 6. These are decending - * addresses starting from -6, -12, -18, ... By allowing 6 bytes for - * each entry, a jsr, jmp, bsr, ... can be used to enter the exception - * handler. Using a jsr to handle an exception has an added benefit of - * allowing a single handler to service several exceptions and use the - * return address as the key differentiation. The vector number can be - * computed from the return address by [ exception = (addr + 1530) / 6 ]. - * The sole purpose of the routine _catchException is to compute the - * exception number and push it on the stack in place of the return address. - * The external function exceptionHandler() is - * used to attach a specific handler to a specific 68k exception. - * For 68020 machines, the ability to have a return address around just - * so the vector can be determined is not necessary because the '020 pushes an - * extra word onto the stack containing the vector offset - * - * Because gdb will sometimes write to the stack area to execute function - * calls, this program cannot rely on using the supervisor stack so it - * uses it's own stack area reserved in the int array remcomStack. - * - ************* - * - * The following gdb commands are supported: - * - * command function Return value - * - * g return the value of the CPU registers hex data or ENN - * G set the value of the CPU registers OK or ENN - * - * mAA..AA,LLLL Read LLLL bytes at address AA..AA hex data or ENN - * MAA..AA,LLLL: Write LLLL bytes at address AA.AA OK or ENN - * - * c Resume at current address SNN ( signal NN) - * cAA..AA Continue at address AA..AA SNN - * - * s Step one instruction SNN - * sAA..AA Step one instruction from AA..AA SNN - * - * k kill - * - * ? What was the last sigval ? SNN (signal NN) - * - * All commands and responses are sent with a packet which includes a - * checksum. A packet consists of - * - * $#. - * - * where - * :: - * :: < two hex digits computed as modulo 256 sum of > - * - * When a packet is received, it is first acknowledged with either '+' or '-'. - * '+' indicates a successful transfer. '-' indicates a failed transfer. - * - * Example: - * - * Host: Reply: - * $m0,10#2a +$00010203040506070809101112131415#42 - * - ****************************************************************************/ - -#include -#include -#include - -/************************************************************************ - * - * external low-level support routines - */ -typedef void (*ExceptionHook)(int); /* pointer to function with int parm */ -typedef void (*Function)(); /* pointer to a function */ - -extern putDebugChar(); /* write a single character */ -extern getDebugChar(); /* read and return a single char */ - -extern Function exceptionHandler(); /* assign an exception handler */ -extern ExceptionHook exceptionHook; /* hook variable for errors/exceptions */ - - -/************************************************************************/ -/* BUFMAX defines the maximum number of characters in inbound/outbound buffers*/ -/* at least NUMREGBYTES*2 are needed for register packets */ -#define BUFMAX 400 - -static char initialized; /* boolean flag. != 0 means we've been initialized */ - -int remote_debug = 0; -/* debug > 0 prints ill-formed commands in valid packets & checksum errors */ - -char hexchars[]="0123456789abcdef"; - -/* there are 180 bytes of registers on a 68020 w/68881 */ -/* many of the fpa registers are 12 byte (96 bit) registers */ -#define NUMREGBYTES 180 -enum regnames {D0,D1,D2,D3,D4,D5,D6,D7, - A0,A1,A2,A3,A4,A5,A6,A7, - PS,PC, - FP0,FP1,FP2,FP3,FP4,FP5,FP6,FP7, - FPCONTROL,FPSTATUS,FPIADDR - }; - -typedef struct FrameStruct -{ - struct FrameStruct *previous; - int exceptionPC; /* pc value when this frame created */ - int exceptionVector; /* cpu vector causing exception */ - short frameSize; /* size of cpu frame in words */ - short sr; /* for 68000, this not always sr */ - int pc; - short format; - int fsaveHeader; - int morejunk[0]; /* exception frame, fp save... */ -} Frame; - -#define FRAMESIZE 500 -static Frame *lastFrame; -static int frameStack[FRAMESIZE]; - -/* - * these should not be static cuz they can be used outside this module - */ -int registers[NUMREGBYTES/4]; -int superStack; - -static int remcomStack[400]; -static int* stackPtr = &remcomStack[399]; - -/* - * In many cases, the system will want to continue exception processing - * when a continue command is given. - * oldExceptionHook is a function to invoke in this case. - */ - -static ExceptionHook oldExceptionHook; - -/* the size of the exception stack on the 68020 varies with the type of - * exception. The following table is the number of WORDS used - * for each exception format. - */ -static short exceptionSize[] = { 4,4,6,4,4,4,4,4,29,10,16,46,4,4,4,4 }; - -/************* jump buffer used for setjmp/longjmp **************************/ -jmp_buf env; - -/*************************** ASSEMBLY CODE MACROS *************************/ -/* */ - -#ifdef __HAVE_68881__ -/* do an fsave, then remember the address to begin a restore from */ -#define SAVE_FP_REGS() asm(" fsave a0@-"); \ - asm(" fmovemx fp0-fp7,_registers+72"); \ - asm(" fmoveml fpcr/fpsr/fpi,_registers+168"); -#define RESTORE_FP_REGS() asm(" fmoveml _registers+168,fpcr/fpsr/fpi"); \ - asm(" fmovemx _registers+72,fp0-fp7"); \ - asm(" frestore a0@+"); -#else -#define SAVE_FP_REGS() -#define RESTORE_FP_REGS() -#endif /* __HAVE_68881__ */ - -asm(" -.text -.globl _return_to_super -_return_to_super: - movel _registers+60,sp /* get new stack pointer */ - movel _lastFrame,a0 /* get last frame info */ - bra return_to_any - -.globl _return_to_user -_return_to_user: - movel _registers+60,a0 /* get usp */ - movel a0,usp /* set usp */ - movel _superStack,sp /* get original stack pointer */ - -return_to_any: - movel _lastFrame,a0 /* get last frame info */ - movel a0@+,_lastFrame /* link in previous frame */ - addql #8,a0 /* skip over pc, vector#*/ - movew a0@+,d0 /* get # of words in cpu frame */ - addw d0,a0 /* point to end of data */ - addw d0,a0 /* point to end of data */ - movel a0,a1 -# -# copy the stack frame - subql #1,d0 -copyUserLoop: - movew a1@-,sp@- - dbf d0,copyUserLoop -"); - RESTORE_FP_REGS() - asm(" moveml _registers,d0-d7/a0-a6"); - asm(" rte"); /* pop and go! */ - -#define DISABLE_INTERRUPTS() asm(" oriw #0x0700,sr"); -#define BREAKPOINT() asm(" trap #1"); - -/* this function is called immediately when a level 7 interrupt occurs */ -/* if the previous interrupt level was 7 then we're already servicing */ -/* this interrupt and an rte is in order to return to the debugger. */ -/* For the 68000, the offset for sr is 6 due to the jsr return address */ -asm(" -.text -.globl __debug_level7 -__debug_level7: - movew d0,sp@-"); -#ifdef mc68020 -asm(" movew sp@(2),d0"); -#else -asm(" movew sp@(6),d0"); -#endif -asm(" andiw #0x700,d0 - cmpiw #0x700,d0 - beq _already7 - movew sp@+,d0 - bra __catchException -_already7: - movew sp@+,d0"); -#ifndef mc68020 -asm(" lea sp@(4),sp"); /* pull off 68000 return address */ -#endif -asm(" rte"); - -extern void _catchException(); - -#ifdef mc68020 -/* This function is called when a 68020 exception occurs. It saves - * all the cpu and fpcp regs in the _registers array, creates a frame on a - * linked list of frames which has the cpu and fpcp stack frames needed - * to properly restore the context of these processors, and invokes - * an exception handler (remcom_handler). - * - * stack on entry: stack on exit: - * N bytes of junk exception # MSWord - * Exception Format Word exception # MSWord - * Program counter LSWord - * Program counter MSWord - * Status Register - * - * - */ -asm(" -.text -.globl __catchException -__catchException:"); -DISABLE_INTERRUPTS(); -asm(" - moveml d0-d7/a0-a6,_registers /* save registers */ - movel _lastFrame,a0 /* last frame pointer */ -"); -SAVE_FP_REGS(); -asm(" - lea _registers,a5 /* get address of registers */ - movew sp@,d1 /* get status register */ - movew d1,a5@(66) /* save sr */ - movel sp@(2),a4 /* save pc in a4 for later use */ - movel a4,a5@(68) /* save pc in _regisers[] */ - -# -# figure out how many bytes in the stack frame - movew sp@(6),d0 /* get '020 exception format */ - movew d0,d2 /* make a copy of format word */ - andiw #0xf000,d0 /* mask off format type */ - rolw #5,d0 /* rotate into the low byte *2 */ - lea _exceptionSize,a1 - addw d0,a1 /* index into the table */ - movew a1@,d0 /* get number of words in frame */ - movew d0,d3 /* save it */ - subw d0,a0 /* adjust save pointer */ - subw d0,a0 /* adjust save pointer(bytes) */ - movel a0,a1 /* copy save pointer */ - subql #1,d0 /* predecrement loop counter */ -# -# copy the frame -saveFrameLoop: - movew sp@+,a1@+ - dbf d0,saveFrameLoop -# -# now that the stack has been clenaed, -# save the a7 in use at time of exception - movel sp,_superStack /* save supervisor sp */ - andiw #0x2000,d1 /* were we in supervisor mode ? */ - beq userMode - movel a7,a5@(60) /* save a7 */ - bra a7saveDone -userMode: - movel usp,a1 - movel a1,a5@(60) /* save user stack pointer */ -a7saveDone: - -# -# save size of frame - movew d3,a0@- - -# -# compute exception number - andl #0xfff,d2 /* mask off vector offset */ - lsrw #2,d2 /* divide by 4 to get vect num */ - movel d2,a0@- /* save it */ -# -# save pc causing exception - movel a4,a0@- -# -# save old frame link and set the new value - movel _lastFrame,a1 /* last frame pointer */ - movel a1,a0@- /* save pointer to prev frame */ - movel a0,_lastFrame - - movel d2,sp@- /* push exception num */ - movel _exceptionHook,a0 /* get address of handler */ - jbsr a0@ /* and call it */ - jmp __returnFromException /* now, return */ -"); -#else /* mc68000 */ -/* This function is called when an exception occurs. It translates the - * return address found on the stack into an exception vector # which - * is then handled by either handle_exception or a system handler. - * _catchException provides a front end for both. - * - * stack on entry: stack on exit: - * Program counter MSWord exception # MSWord - * Program counter LSWord exception # MSWord - * Status Register - * Return Address MSWord - * Return Address LSWord - */ -asm(" -.text -.globl __catchException -__catchException:"); -DISABLE_INTERRUPTS(); -asm(" - moveml d0-d7/a0-a6,_registers /* save registers */ - movel _lastFrame,a0 /* last frame pointer */ -"); -SAVE_FP_REGS(); -asm(" - lea _registers,a5 /* get address of registers */ - movel sp@+,d2 /* pop return address */ - addl #1530,d2 /* convert return addr to */ - divs #6,d2 /* exception number */ - extl d2 - - moveql #3,d3 /* assume a three word frame */ - - cmpiw #3,d2 /* bus error or address error ? */ - bgt normal /* if >3 then normal error */ - movel sp@+,a0@- /* copy error info to frame buff*/ - movel sp@+,a0@- /* these are never used */ - moveql #7,d3 /* this is a 7 word frame */ - -normal: - movew sp@+,d1 /* pop status register */ - movel sp@+,a4 /* pop program counter */ - movew d1,a5@(66) /* save sr */ - movel a4,a5@(68) /* save pc in _regisers[] */ - movel a4,a0@- /* copy pc to frame buffer */ - movew d1,a0@- /* copy sr to frame buffer */ - - movel sp,_superStack /* save supervisor sp */ - - andiw #0x2000,d1 /* were we in supervisor mode ? */ - beq userMode - movel a7,a5@(60) /* save a7 */ - bra saveDone -userMode: - movel usp,a1 /* save user stack pointer */ - movel a1,a5@(60) /* save user stack pointer */ -saveDone: - - movew d3,a0@- /* push frame size in words */ - movel d2,a0@- /* push vector number */ - movel a4,a0@- /* push exception pc */ - -# -# save old frame link and set the new value - movel _lastFrame,a1 /* last frame pointer */ - movel a1,a0@- /* save pointer to prev frame */ - movel a0,_lastFrame - - movel d2,sp@- /* push exception num */ - movel _exceptionHook,a0 /* get address of handler */ - jbsr a0@ /* and call it */ - jmp __returnFromException /* now, return */ -"); -#endif - - -/* - * remcomHandler is a front end for handle_exception. It moves the - * stack pointer into an area reserved for debugger use in case the - * breakpoint happened in supervisor mode. - */ -asm("_remcomHandler:"); -asm(" addl #4,sp"); /* pop off return address */ -asm(" movel sp@+,d0"); /* get the exception number */ -asm(" movel _stackPtr,sp"); /* move to remcom stack area */ -asm(" movel d0,sp@-"); /* push exception onto stack */ -asm(" jbsr _handle_exception"); /* this never returns */ -asm(" rts"); /* return */ - -void _returnFromException( Frame *frame ) -{ - /* if no existing frame, dummy one up */ - if (! frame) - { - frame = lastFrame -1; - frame->frameSize = 4; - frame->format = 0; - frame->fsaveHeader = 0; - frame->previous = lastFrame; - } - -#ifndef mc68020 - /* a 68000 cannot use the internal info pushed onto a bus error - * or address error frame when doing an RTE so don't put this info - * onto the stack or the stack will creep every time this happens. - */ - frame->frameSize=3; -#endif - - /* throw away any frames in the list after this frame */ - lastFrame = frame; - - frame->sr = registers[(int) PS]; - frame->pc = registers[(int) PC]; - - if (registers[(int) PS] & 0x2000) - { - /* return to supervisor mode... */ - return_to_super(); - } - else - { /* return to user mode */ - return_to_user(); - } -} - -int hex(ch) -char ch; -{ - if ((ch >= 'a') && (ch <= 'f')) return (ch-'a'+10); - if ((ch >= '0') && (ch <= '9')) return (ch-'0'); - return (0); -} - - -/* scan for the sequence $# */ -void getpacket(buffer) -char * buffer; -{ - unsigned char checksum; - unsigned char xmitcsum; - int i; - int count; - char ch; - - do { - /* wait around for the start character, ignore all other characters */ - while ((ch = getDebugChar()) != '$'); - checksum = 0; - count = 0; - - /* now, read until a # or end of buffer is found */ - while (count < BUFMAX) { - ch = getDebugChar(); - if (ch == '#') break; - checksum = checksum + ch; - buffer[count] = ch; - count = count + 1; - } - buffer[count] = 0; - - if (ch == '#') { - xmitcsum = hex(getDebugChar()) << 4; - xmitcsum += hex(getDebugChar()); - if ((remote_debug ) && (checksum != xmitcsum)) { - fprintf(stderr,"bad checksum. My count = 0x%x, sent=0x%x. buf=%s\n", - checksum,xmitcsum,buffer); - } - - if (checksum != xmitcsum) putDebugChar('-'); /* failed checksum */ - else { - putDebugChar('+'); /* successful transfer */ - /* if a sequence char is present, reply the sequence ID */ - if (buffer[2] == ':') { - putDebugChar( buffer[0] ); - putDebugChar( buffer[1] ); - /* remove sequence chars from buffer */ - count = strlen(buffer); - for (i=3; i <= count; i++) buffer[i-3] = buffer[i]; - } - } - } - } while (checksum != xmitcsum); - -} - -/* send the packet in buffer. The host get's one chance to read it. - This routine does not wait for a positive acknowledge. */ - - -void putpacket(buffer) -char * buffer; -{ - unsigned char checksum; - int count; - char ch; - - /* $#. */ - do { - putDebugChar('$'); - checksum = 0; - count = 0; - - while (ch=buffer[count]) { - if (! putDebugChar(ch)) return; - checksum += ch; - count += 1; - } - - putDebugChar('#'); - putDebugChar(hexchars[checksum >> 4]); - putDebugChar(hexchars[checksum % 16]); - - } while (1 == 0); /* (getDebugChar() != '+'); */ - -} - -static char inbuffer[BUFMAX]; -static char outbuffer[BUFMAX]; -static short error; - - -void debug_error(format, parm) -char * format; -char * parm; -{ - if (remote_debug) fprintf(stderr,format,parm); -} - -/* convert the memory pointed to by mem into hex, placing result in buf */ -/* return a pointer to the last char put in buf (null) */ -char* mem2hex(mem, buf, count) -char* mem; -char* buf; -int count; -{ - int i; - unsigned char ch; - for (i=0;i> 4]; - *buf++ = hexchars[ch % 16]; - } - *buf = 0; - return(buf); -} - -/* convert the hex array pointed to by buf into binary to be placed in mem */ -/* return a pointer to the character AFTER the last byte written */ -char* hex2mem(buf, mem, count) -char* buf; -char* mem; -int count; -{ - int i; - unsigned char ch; - for (i=0;iexceptionPC, - frame->exceptionVector); - if (frame->exceptionPC == newPC) break; /* bingo! a match */ - /* - * for a breakpoint instruction, the saved pc may - * be off by two due to re-executing the instruction - * replaced by the trap instruction. Check for this. - */ - if ((frame->exceptionVector == 33) && - (frame->exceptionPC == (newPC+2))) break; - frame = frame->previous; - } - - /* - * If we found a match for the PC AND we are not returning - * as a result of a breakpoint (33), - * trace exception (9), nmi (31), jmp to - * the old exception handler as if this code never ran. - */ - if (frame) - { - if ((frame->exceptionVector != 9) && - (frame->exceptionVector != 31) && - (frame->exceptionVector != 33)) - { - /* - * invoke the previous handler. - */ - if (oldExceptionHook) - (*oldExceptionHook) (frame->exceptionVector); - newPC = registers[ PC ]; /* pc may have changed */ - if (newPC != frame->exceptionPC) - { - if (remote_debug) - printf("frame at 0x%x has pc=0x%x, except#=%d\n", - frame,frame->exceptionPC, - frame->exceptionVector); - /* dispose of this frame, we're skipping it (longjump?)*/ - lastFrame = frame->previous; - frame = (Frame *) 0; - } - } - } - - _returnFromException( frame ); - - break; - - /* kill the program */ - case 'k' : /* do nothing */ - break; - } /* switch */ - - /* reply to the request */ - putpacket(outbuffer); - } -} - - -/* this function is used to set up exception handlers for tracing and - breakpoints */ -void set_debug_traps() -{ -extern void _debug_level7(); -extern void remcomHandler(); -int exception; - - for (exception = 2; exception <= 23; exception++) - exceptionHandler(exception,_catchException); - - /* level 7 interrupt */ - exceptionHandler(31,_debug_level7); - - /* breakpoint exception (trap #1) */ - exceptionHandler(33,_catchException); - - /* floating point error (trap #8) */ - exceptionHandler(40,_catchException); - - /* 48 to 54 are floating point coprocessor errors */ - for (exception = 48; exception <= 54; exception++) - exceptionHandler(exception,_catchException); - - if (oldExceptionHook != remcomHandler) - { - oldExceptionHook = exceptionHook; - exceptionHook = remcomHandler; - } - - initialized = 1; - - lastFrame = (Frame *) &frameStack[FRAMESIZE-1]; - lastFrame->previous = (Frame *) 0; -} - -/* This function will generate a breakpoint exception. It is used at the - beginning of a program to sync up with a debugger and can be used - otherwise as a quick means to stop program execution and "break" into - the debugger. */ - -void breakpoint() -{ - if (initialized) BREAKPOINT(); -} - -@EOF - -chmod 444 remcom.c - -exit 0 - diff --git a/gdb/rem-multi.shar b/gdb/rem-multi.shar deleted file mode 100644 index 110e060a879..00000000000 --- a/gdb/rem-multi.shar +++ /dev/null @@ -1,1301 +0,0 @@ -#!/bin/sh -# This is a shell archive. -# Run the file through sh to extract its contents. -# shar: Shell Archiver -# Run the following text with /bin/sh to create: -# Remote_Makefile -# remote_gutils.c -# remote_inflow.c -# remote_server.c -# remote_utils.c -# This archive created: Fri Jun 23 17:06:55 1989 -cat << \SHAR_EOF > Remote_Makefile -# Makefile for the remote server for GDB, the GNU debugger. -# Copyright (C) 1986, 1989 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., 675 Mass Ave, Cambridge, MA 02139, USA. - -CFLAGS = -g -CC = cc - -SERVER = remote_server.o\ - remote_inflow.o\ - remote_utils.o\ - remote_gutils.o - -prog : $(SERVER) - $(CC) -g -o serve $(SERVER) -SHAR_EOF -cat << \SHAR_EOF > remote_gutils.c -/* General utility routines for the remote server for GDB, the GNU debugger. - Copyright (C) 1986, 1989 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include -#include "defs.h" - -void error (); -void fatal (); - -/* Chain of cleanup actions established with make_cleanup, - to be executed if an error happens. */ - -static struct cleanup *cleanup_chain; - -/* Nonzero means a quit has been requested. */ - -int quit_flag; - -/* Nonzero means quit immediately if Control-C is typed now, - rather than waiting until QUIT is executed. */ - -int immediate_quit; - -/* Add a new cleanup to the cleanup_chain, - and return the previous chain pointer - to be passed later to do_cleanups or discard_cleanups. - Args are FUNCTION to clean up with, and ARG to pass to it. */ - -struct cleanup * -make_cleanup (function, arg) - void (*function) (); - int arg; -{ - register struct cleanup *new - = (struct cleanup *) xmalloc (sizeof (struct cleanup)); - register struct cleanup *old_chain = cleanup_chain; - - new->next = cleanup_chain; - new->function = function; - new->arg = arg; - cleanup_chain = new; - - return old_chain; -} - -/* Discard cleanups and do the actions they describe - until we get back to the point OLD_CHAIN in the cleanup_chain. */ - -void -do_cleanups (old_chain) - register struct cleanup *old_chain; -{ - register struct cleanup *ptr; - while ((ptr = cleanup_chain) != old_chain) - { - (*ptr->function) (ptr->arg); - cleanup_chain = ptr->next; - free (ptr); - } -} - -/* Discard cleanups, not doing the actions they describe, - until we get back to the point OLD_CHAIN in the cleanup_chain. */ - -void -discard_cleanups (old_chain) - register struct cleanup *old_chain; -{ - register struct cleanup *ptr; - while ((ptr = cleanup_chain) != old_chain) - { - cleanup_chain = ptr->next; - free (ptr); - } -} - -/* This function is useful for cleanups. - Do - - foo = xmalloc (...); - old_chain = make_cleanup (free_current_contents, &foo); - - to arrange to free the object thus allocated. */ - -void -free_current_contents (location) - char **location; -{ - free (*location); -} - -/* Generally useful subroutines used throughout the program. */ - -/* Like malloc but get error if no storage available. */ - -char * -xmalloc (size) - long size; -{ - register char *val = (char *) malloc (size); - if (!val) - fatal ("virtual memory exhausted.", 0); - return val; -} - -/* Like realloc but get error if no storage available. */ - -char * -xrealloc (ptr, size) - char *ptr; - long size; -{ - register char *val = (char *) realloc (ptr, size); - if (!val) - fatal ("virtual memory exhausted.", 0); - return val; -} - -/* Print the system error message for errno, and also mention STRING - as the file name for which the error was encountered. - Then return to command level. */ - -void -perror_with_name (string) - char *string; -{ - extern int sys_nerr; - extern char *sys_errlist[]; - extern int errno; - char *err; - char *combined; - - if (errno < sys_nerr) - err = sys_errlist[errno]; - else - err = "unknown error"; - - combined = (char *) alloca (strlen (err) + strlen (string) + 3); - strcpy (combined, string); - strcat (combined, ": "); - strcat (combined, err); - - error ("%s.", combined); -} - -/* Print the system error message for ERRCODE, and also mention STRING - as the file name for which the error was encountered. */ - -void -print_sys_errmsg (string, errcode) - char *string; - int errcode; -{ - extern int sys_nerr; - extern char *sys_errlist[]; - char *err; - char *combined; - - if (errcode < sys_nerr) - err = sys_errlist[errcode]; - else - err = "unknown error"; - - combined = (char *) alloca (strlen (err) + strlen (string) + 3); - strcpy (combined, string); - strcat (combined, ": "); - strcat (combined, err); - - printf ("%s.\n", combined); -} - -void -quit () -{ - fflush (stdout); - ioctl (fileno (stdout), TIOCFLUSH, 0); - error ("Quit"); -} - -/* Control C comes here */ - -void -request_quit () -{ - quit_flag = 1; - if (immediate_quit) - quit (); -} - -/* Print an error message and return to command level. - STRING is the error message, used as a fprintf string, - and ARG is passed as an argument to it. */ - -void -error (string, arg1, arg2, arg3) - char *string; - int arg1, arg2, arg3; -{ - fflush (stdout); - fprintf (stderr, string, arg1, arg2, arg3); - fprintf (stderr, "\n"); - /************return_to_top_level ();************/ -} - -/* Print an error message and exit reporting failure. - This is for a error that we cannot continue from. - STRING and ARG are passed to fprintf. */ - -void -fatal (string, arg) - char *string; - int arg; -{ - fprintf (stderr, "gdb: "); - fprintf (stderr, string, arg); - fprintf (stderr, "\n"); - exit (1); -} - -/* Make a copy of the string at PTR with SIZE characters - (and add a null character at the end in the copy). - Uses malloc to get the space. Returns the address of the copy. */ - -char * -savestring (ptr, size) - char *ptr; - int size; -{ - register char *p = (char *) xmalloc (size + 1); - bcopy (ptr, p, size); - p[size] = 0; - return p; -} - -void -print_spaces (n, file) - register int n; - register FILE *file; -{ - while (n-- > 0) - fputc (' ', file); -} - -/* Ask user a y-or-n question and return 1 iff answer is yes. - Takes three args which are given to printf to print the question. - The first, a control string, should end in "? ". - It should not say how to answer, because we do that. */ - -int -query (ctlstr, arg1, arg2) - char *ctlstr; -{ - register int answer; - - /* Automatically answer "yes" if input is not from a terminal. */ - /***********if (!input_from_terminal_p ()) - return 1; *************************/ - - while (1) - { - printf (ctlstr, arg1, arg2); - printf ("(y or n) "); - fflush (stdout); - answer = fgetc (stdin); - clearerr (stdin); /* in case of C-d */ - if (answer != '\n') - while (fgetc (stdin) != '\n') clearerr (stdin); - if (answer >= 'a') - answer -= 040; - if (answer == 'Y') - return 1; - if (answer == 'N') - return 0; - printf ("Please answer y or n.\n"); - } -} - -/* Parse a C escape sequence. STRING_PTR points to a variable - containing a pointer to the string to parse. That pointer - is updated past the characters we use. The value of the - escape sequence is returned. - - A negative value means the sequence \ newline was seen, - which is supposed to be equivalent to nothing at all. - - If \ is followed by a null character, we return a negative - value and leave the string pointer pointing at the null character. - - If \ is followed by 000, we return 0 and leave the string pointer - after the zeros. A value of 0 does not mean end of string. */ - -int -parse_escape (string_ptr) - char **string_ptr; -{ - register int c = *(*string_ptr)++; - switch (c) - { - case 'a': - return '\a'; - case 'b': - return '\b'; - case 'e': - return 033; - case 'f': - return '\f'; - case 'n': - return '\n'; - case 'r': - return '\r'; - case 't': - return '\t'; - case 'v': - return '\v'; - case '\n': - return -2; - case 0: - (*string_ptr)--; - return 0; - case '^': - c = *(*string_ptr)++; - if (c == '\\') - c = parse_escape (string_ptr); - if (c == '?') - return 0177; - return (c & 0200) | (c & 037); - - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - { - register int i = c - '0'; - register int count = 0; - while (++count < 3) - { - if ((c = *(*string_ptr)++) >= '0' && c <= '7') - { - i *= 8; - i += c - '0'; - } - else - { - (*string_ptr)--; - break; - } - } - return i; - } - default: - return c; - } -} - -void -printchar (ch, stream) - unsigned char ch; - FILE *stream; -{ - register int c = ch; - if (c < 040 || c >= 0177) - { - if (c == '\n') - fprintf (stream, "\\n"); - else if (c == '\b') - fprintf (stream, "\\b"); - else if (c == '\t') - fprintf (stream, "\\t"); - else if (c == '\f') - fprintf (stream, "\\f"); - else if (c == '\r') - fprintf (stream, "\\r"); - else if (c == 033) - fprintf (stream, "\\e"); - else if (c == '\a') - fprintf (stream, "\\a"); - else - fprintf (stream, "\\%03o", c); - } - else - { - if (c == '\\' || c == '"' || c == '\'') - fputc ('\\', stream); - fputc (c, stream); - } -} -SHAR_EOF -cat << \SHAR_EOF > remote_inflow.c -/* Low level interface to ptrace, for GDB when running under Unix. - Copyright (C) 1986, 1987 Free Software Foundation, Inc. -*/ - -#include "defs.h" -#include "param.h" -#include "wait.h" -#include "frame.h" -#include "inferior.h" -/*************************** -#include "initialize.h" -****************************/ - -#include -#include -#include -#include -#include -#include -#include -#include - -/***************Begin MY defs*********************/ -int quit_flag = 0; -char registers[REGISTER_BYTES]; - -/* Index within `registers' of the first byte of the space for - register N. */ - - -char buf2[MAX_REGISTER_RAW_SIZE]; -/***************End MY defs*********************/ - -#ifdef NEW_SUN_PTRACE -#include -#include -#endif - -extern char **environ; -extern int errno; -extern int inferior_pid; -void error(), quit(), perror_with_name(); -int query(); -void supply_register(), write_register(); -CORE_ADDR read_register(); - -/* Nonzero if we are debugging an attached outside process - rather than an inferior. */ - - -/* Start an inferior process and returns its pid. - ALLARGS is a vector of program-name and args. - ENV is the environment vector to pass. */ - -int -create_inferior (allargs, env) - char **allargs; - char **env; -{ - int pid; - extern int sys_nerr; - extern char *sys_errlist[]; - extern int errno; - - /* exec is said to fail if the executable is open. */ - /****************close_exec_file ();*****************/ - - pid = vfork (); - if (pid < 0) - perror_with_name ("vfork"); - - if (pid == 0) - { - /* Run inferior in a separate process group. */ - setpgrp (getpid (), getpid ()); - -/* Not needed on Sun, at least, and loses there - because it clobbers the superior. */ -/*??? signal (SIGQUIT, SIG_DFL); - signal (SIGINT, SIG_DFL); */ - - errno = 0; - ptrace (0); - - execle ("/bin/sh", "sh", "-c", allargs, 0, env); - - fprintf (stderr, "Cannot exec /bin/sh: %s.\n", - errno < sys_nerr ? sys_errlist[errno] : "unknown error"); - fflush (stderr); - _exit (0177); - } - return pid; -} - -/* Kill the inferior process. Make us have no inferior. */ - -kill_inferior () -{ - if (inferior_pid == 0) - return; - ptrace (8, inferior_pid, 0, 0); - wait (0); - /*************inferior_died ();****VK**************/ -} - -/* Resume execution of the inferior process. - If STEP is nonzero, single-step it. - If SIGNAL is nonzero, give it that signal. */ - -unsigned char -resume (step, signal,status) - int step; - int signal; - char *status; -{ - int pid ; - WAITTYPE w; - - errno = 0; - ptrace (step ? 9 : 7, inferior_pid, 1, signal); - if (errno) - perror_with_name ("ptrace"); - pid = wait(&w); - if(pid != inferior_pid) - perror_with_name ("wait"); - - if(WIFEXITED(w)) - { - printf("\nchild exited with retcode = %x \n",WRETCODE(w)); - *status = 'E'; - return((unsigned char) WRETCODE(w)); - } - else if(!WIFSTOPPED(w)) - { - printf("\nchild did terminated with signal = %x \n",WTERMSIG(w)); - *status = 'T'; - return((unsigned char) WTERMSIG(w)); - } - else - { - printf("\nchild stopped with signal = %x \n",WSTOPSIG(w)); - *status = 'S'; - return((unsigned char) WSTOPSIG(w)); - } - -} - - -#ifdef NEW_SUN_PTRACE - -void -fetch_inferior_registers () -{ - struct regs inferior_registers; - struct fp_status inferior_fp_registers; - extern char registers[]; - - ptrace (PTRACE_GETREGS, inferior_pid, &inferior_registers); - if (errno) - perror_with_name ("ptrace"); - /**********debugging begin **********/ - print_some_registers(&inferior_registers); - /**********debugging end **********/ - ptrace (PTRACE_GETFPREGS, inferior_pid, &inferior_fp_registers); - if (errno) - perror_with_name ("ptrace"); - - bcopy (&inferior_registers, registers, 16 * 4); - bcopy (&inferior_fp_registers, ®isters[REGISTER_BYTE (FP0_REGNUM)], - sizeof inferior_fp_registers.fps_regs); - *(int *)®isters[REGISTER_BYTE (PS_REGNUM)] = inferior_registers.r_ps; - *(int *)®isters[REGISTER_BYTE (PC_REGNUM)] = inferior_registers.r_pc; - bcopy (&inferior_fp_registers.fps_control, - ®isters[REGISTER_BYTE (FPC_REGNUM)], - sizeof inferior_fp_registers - sizeof inferior_fp_registers.fps_regs); -} - -/* Store our register values back into the inferior. - If REGNO is -1, do this for all registers. - Otherwise, REGNO specifies which register (so we can save time). */ - -store_inferior_registers (regno) - int regno; -{ - struct regs inferior_registers; - struct fp_status inferior_fp_registers; - extern char registers[]; - - bcopy (registers, &inferior_registers, 16 * 4); - bcopy (®isters[REGISTER_BYTE (FP0_REGNUM)], &inferior_fp_registers, - sizeof inferior_fp_registers.fps_regs); - inferior_registers.r_ps = *(int *)®isters[REGISTER_BYTE (PS_REGNUM)]; - inferior_registers.r_pc = *(int *)®isters[REGISTER_BYTE (PC_REGNUM)]; - bcopy (®isters[REGISTER_BYTE (FPC_REGNUM)], - &inferior_fp_registers.fps_control, - sizeof inferior_fp_registers - sizeof inferior_fp_registers.fps_regs); - - ptrace (PTRACE_SETREGS, inferior_pid, &inferior_registers); - if (errno) - perror_with_name ("ptrace"); - ptrace (PTRACE_SETFPREGS, inferior_pid, &inferior_fp_registers); - if (errno) - perror_with_name ("ptrace"); -} - -#endif /* not NEW_SUN_PTRACE */ - - -/* NOTE! I tried using PTRACE_READDATA, etc., to read and write memory - in the NEW_SUN_PTRACE case. - It ought to be straightforward. But it appears that writing did - not write the data that I specified. I cannot understand where - it got the data that it actually did write. */ - -/* Copy LEN bytes from inferior's memory starting at MEMADDR - to debugger memory starting at MYADDR. */ - -read_inferior_memory (memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - register int i; - /* Round starting address down to longword boundary. */ - register CORE_ADDR addr = memaddr & - sizeof (int); - /* Round ending address up; get number of longwords that makes. */ - register int count - = (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (int); - /* Allocate buffer of that many longwords. */ - register int *buffer = (int *) alloca (count * sizeof (int)); - - /* Read all the longwords */ - for (i = 0; i < count; i++, addr += sizeof (int)) - { - buffer[i] = ptrace (1, inferior_pid, addr, 0); - } - - /* Copy appropriate bytes out of the buffer. */ - bcopy ((char *) buffer + (memaddr & (sizeof (int) - 1)), myaddr, len); -} - -/* Copy LEN bytes of data from debugger memory at MYADDR - to inferior's memory at MEMADDR. - On failure (cannot write the inferior) - returns the value of errno. */ - -int -write_inferior_memory (memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - register int i; - /* Round starting address down to longword boundary. */ - register CORE_ADDR addr = memaddr & - sizeof (int); - /* Round ending address up; get number of longwords that makes. */ - register int count - = (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (int); - /* Allocate buffer of that many longwords. */ - register int *buffer = (int *) alloca (count * sizeof (int)); - extern int errno; - - /* Fill start and end extra bytes of buffer with existing memory data. */ - - buffer[0] = ptrace (1, inferior_pid, addr, 0); - - if (count > 1) - { - buffer[count - 1] - = ptrace (1, inferior_pid, - addr + (count - 1) * sizeof (int), 0); - } - - /* Copy data to be written over corresponding part of buffer */ - - bcopy (myaddr, (char *) buffer + (memaddr & (sizeof (int) - 1)), len); - - /* Write the entire buffer. */ - - for (i = 0; i < count; i++, addr += sizeof (int)) - { - errno = 0; - ptrace (4, inferior_pid, addr, buffer[i]); - if (errno) - return errno; - } - - return 0; -} - -void -try_writing_regs_command () -{ - register int i; - register int value; - extern int errno; - - if (inferior_pid == 0) - error ("There is no inferior process now."); - - fetch_inferior_registers(); - for (i = 0;i<18 ; i ++) - { - QUIT; - errno = 0; - value = read_register(i); - write_register ( i, value); - if (errno == 0) - { - printf (" Succeeded with register %d; value 0x%x (%d).\n", - i, value, value); - } - else - printf (" Failed with register %d.\n", i); - } -} - -void -initialize () -{ - - inferior_pid = 0; - - -} - - -/* Return the contents of register REGNO, - regarding it as an integer. */ - -CORE_ADDR -read_register (regno) - int regno; -{ - /* This loses when REGISTER_RAW_SIZE (regno) != sizeof (int) */ - return *(int *) ®isters[REGISTER_BYTE (regno)]; -} - -/* Store VALUE in the register number REGNO, regarded as an integer. */ - -void -write_register (regno, val) - int regno, val; -{ - /* This loses when REGISTER_RAW_SIZE (regno) != sizeof (int) */ - *(int *) ®isters[REGISTER_BYTE (regno)] = val; - - if (have_inferior_p ()) - store_inferior_registers (regno); -} - - -int -have_inferior_p () -{ - return inferior_pid != 0; -} - -print_some_registers(regs) -int regs[]; -{ - register int i; - for (i = 0; i < 18; i++) { - printf("reg[%d] = %x\n", i, regs[i]); - } -} - -SHAR_EOF -cat << \SHAR_EOF > remote_server.c -/* Main code for remote server for GDB, the GNU Debugger. - Copyright (C) 1989 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include "param.h" -#include - -void read_inferior_memory(), fetch_inferior_registers(); -unsigned char resume(); -void kill_inferior(); -void initialize(), try_writing_regs_command(); -int create_inferior(), read_register(); - -extern char registers[]; -int inferior_pid; -extern char **environ; - -/* Descriptor for I/O to remote machine. */ -int remote_desc; -int kiodebug = 0; -int remote_debugging; - -void remote_send (); -void putpkt (); -void getpkt (); -void remote_open(); -void write_ok(); -void write_enn(); -void convert_ascii_to_int(); -void convert_int_to_ascii(); -void prepare_resume_reply(); -void decode_m_packet(); -void decode_M_packet(); - - -main(argc,argv) -int argc; char *argv[]; -{ - char ch,status, own_buf[2000], mem_buf[2000]; - int i=0; - unsigned char signal; - unsigned int mem_addr, len; - - initialize(); - printf("\nwill open serial link\n"); - remote_open("/dev/ttya",0); - - if(argc < 2) - { - printf("Enter name of program to be run with command line args\n"); - gets(own_buf); - inferior_pid = create_inferior(own_buf,environ); - printf("\nProcess %s created; pid = %d\n",own_buf,inferior_pid); - } - else - { - inferior_pid = create_inferior(argv[1],environ); - printf("\nProcess %s created; pid = %d\n",argv[1],inferior_pid); - } - - do { - getpkt(own_buf); - printf("\nPacket received is>:%s\n",own_buf); - i = 0; - ch = own_buf[i++]; - switch (ch) { - case 'h': /**********This is only for tweaking the gdb+ program *******/ - signal = resume(1,0,&status); - prepare_resume_reply(own_buf,status,signal); - break; - /*************end tweak*************************************/ - - case 'g': fetch_inferior_registers(); - convert_int_to_ascii(registers,own_buf,REGISTER_BYTES); - break; - case 'G': convert_ascii_to_int(&own_buf[1],registers,REGISTER_BYTES); - if(store_inferior_registers(-1)==0) - write_ok(own_buf); - else - write_enn(own_buf); - break; - case 'm': decode_m_packet(&own_buf[1],&mem_addr,&len); - read_inferior_memory(mem_addr,mem_buf,len); - convert_int_to_ascii(mem_buf,own_buf,len); - break; - case 'M': decode_M_packet(&own_buf[1],&mem_addr,&len,mem_buf); - if(write_inferior_memory(mem_addr,mem_buf,len)==0) - write_ok(own_buf); - else - write_enn(own_buf); - break; - case 'c': signal = resume(0,0,&status); - printf("\nSignal received is >: %0x \n",signal); - prepare_resume_reply(own_buf,status,signal); - break; - case 's': signal = resume(1,0,&status); - prepare_resume_reply(own_buf,status,signal); - break; - case 'k': kill_inferior(); - sprintf(own_buf,"q"); - putpkt(own_buf); - printf("\nObtained kill request...terminating\n"); - close(remote_desc); - exit(0); - case 't': try_writing_regs_command(); - own_buf[0] = '\0'; - break; - default : printf("\nUnknown option chosen by master\n"); - write_enn(own_buf); - break; - } - - putpkt(own_buf); - } while(1) ; - - close(remote_desc); - /** now get out of here**/ - printf("\nFinished reading data from serial link - Bye!\n"); - exit(0); - -} - -SHAR_EOF -cat << \SHAR_EOF > remote_utils.c -/* Remote utility routines for the remote server for GDB, the GNU debugger. - Copyright (C) 1986, 1989 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include "param.h" -#include -#include -#include -#include -#include -#include -#include - -extern int remote_desc; -extern int remote_debugging; -extern int kiodebug; - -void remote_open(); -void remote_send(); -void putpkt(); -void getpkt(); - -void write_ok(); -void write_enn(); -void convert_ascii_to_int(); -void convert_int_to_ascii(); -void prepare_resume_reply(); - -/* Open a connection to a remote debugger. - NAME is the filename used for communication. */ - -void -remote_open (name, from_tty) - char *name; - int from_tty; -{ - struct sgttyb sg; - - remote_debugging = 0; - - remote_desc = open (name, O_RDWR); - if (remote_desc < 0) - printf("\ncould not open remote device\n"); - - ioctl (remote_desc, TIOCGETP, &sg); - sg.sg_flags = RAW; - ioctl (remote_desc, TIOCSETP, &sg); - - if (from_tty) - printf ("Remote debugging using %s\n", name); - remote_debugging = 1; -} - -/* Convert hex digit A to a number. */ - -static int -fromhex (a) - int a; -{ - if (a >= '0' && a <= '9') - return a - '0'; - else if (a >= 'a' && a <= 'f') - return a - 'a' + 10; - else - perror ("Reply contains invalid hex digit"); -} - -/* Convert number NIB to a hex digit. */ - -static int -tohex (nib) - int nib; -{ - if (nib < 10) - return '0'+nib; - else - return 'a'+nib-10; -} - -/* Send the command in BUF to the remote machine, - and read the reply into BUF. - Report an error if we get an error reply. */ - -void -remote_send (buf) - char *buf; -{ - putpkt (buf); - getpkt (buf); - - if (buf[0] == 'E') - perror ("Remote failure reply: %s", buf); -} - -/* Send a packet to the remote machine, with error checking. - The data of the packet is in BUF. */ - -void -putpkt (buf) - char *buf; -{ - int i; - unsigned char csum = 0; - char buf2[500]; - char buf3[1]; - int cnt = strlen (buf); - char *p; - - if (kiodebug) - fprintf (stderr, "Sending packet: %s\n", buf); - - /* Copy the packet into buffer BUF2, encapsulating it - and giving it a checksum. */ - - p = buf2; - *p++ = '$'; - - for (i = 0; i < cnt; i++) - { - csum += buf[i]; - *p++ = buf[i]; - } - *p++ = '#'; - *p++ = tohex ((csum >> 4) & 0xf); - *p++ = tohex (csum & 0xf); - - /* Send it over and over until we get a positive ack. */ - - do { - write (remote_desc, buf2, p - buf2); - read (remote_desc, buf3, 1); - } while (buf3[0] != '+'); -} - -static int -readchar () -{ - char buf[1]; - while (read (remote_desc, buf, 1) != 1) ; - return buf[0] & 0x7f; -} - -/* Read a packet from the remote machine, with error checking, - and store it in BUF. */ - -void -getpkt (buf) - char *buf; -{ - char *bp; - unsigned char csum, c, c1, c2; - extern kiodebug; - - while (1) - { - csum = 0; - while ((c = readchar()) != '$'); - - bp = buf; - while (1) - { - c = readchar (); - if (c == '#') - break; - *bp++ = c; - csum += c; - } - *bp = 0; - - c1 = fromhex (readchar ()); - c2 = fromhex (readchar ()); - if (csum == (c1 << 4) + c2) - break; - - printf ("Bad checksum, sentsum=0x%x, csum=0x%x, buf=%s\n", - (c1 << 4) + c2, csum, buf); - write (remote_desc, "-", 1); - } - - write (remote_desc, "+", 1); - - if (kiodebug) - fprintf (stderr,"Packet received :%s\n", buf); -} - - -void -write_ok(buf) - char *buf; -{ - buf[0] = 'O'; - buf[1] = 'k'; - buf[2] = '\0'; -} - -void -write_enn(buf) - char *buf; -{ - buf[0] = 'E'; - buf[1] = 'N'; - buf[2] = 'N'; - buf[3] = '\0'; -} - -void -convert_int_to_ascii(from,to,n) -char *from, *to; int n; -{ - int nib ; - char ch; - while( n-- ) - { - ch = *from++; - nib = ((ch & 0xf0) >> 4)& 0x0f; - *to++ = tohex(nib); - nib = ch & 0x0f; - *to++ = tohex(nib); - } - *to++ = 0; -} - - -void -convert_ascii_to_int(from,to,n) -char *from, *to; int n; -{ - int nib1,nib2 ; - while( n-- ) - { - nib1 = fromhex(*from++); - nib2 = fromhex(*from++); - *to++ = (((nib1 & 0x0f)<< 4)& 0xf0) | (nib2 & 0x0f); - } -} - -void -prepare_resume_reply(buf,status,signal) -char *buf ,status; -unsigned char signal; -{ - int nib; - char ch; - - *buf++ = 'S'; - *buf++ = status; - nib = ((signal & 0xf0) >> 4) ; - *buf++ = tohex(nib); - nib = signal & 0x0f; - *buf++ = tohex(nib); - *buf++ = 0; -} - -void -decode_m_packet(from,mem_addr_ptr,len_ptr) -char *from; -unsigned int *mem_addr_ptr, *len_ptr; -{ - int i = 0, j = 0 ; - char ch; - *mem_addr_ptr = *len_ptr = 0; - /************debugging begin************/ - printf("\nIn decode_m_packet"); - /************debugging end************/ - - while((ch = from[i++]) != ',') - { - *mem_addr_ptr = *mem_addr_ptr << 4; - *mem_addr_ptr |= fromhex(ch) & 0x0f; - } - /************debugging begin************/ - printf("\nFinished mem_addr part"); - /************debugging end************/ - - for(j=0; j < 4; j++) - { - if((ch = from[i++]) == 0) - break; - *len_ptr = *len_ptr << 4; - *len_ptr |= fromhex(ch) & 0x0f; - } - /************debugging begin************/ - printf("\nFinished len_ptr part"); - /************debugging end************/ -} - -void -decode_M_packet(from,mem_addr_ptr,len_ptr,to) -char *from, *to; -unsigned int *mem_addr_ptr, *len_ptr; -{ - int i = 0, j = 0 ; - char ch; - *mem_addr_ptr = *len_ptr = 0; - /************debugging begin************/ - printf("\nIn decode_M_packet"); - /************debugging end************/ - - while((ch = from[i++]) != ',') - { - *mem_addr_ptr = *mem_addr_ptr << 4; - *mem_addr_ptr |= fromhex(ch) & 0x0f; - } - /************debugging begin************/ - printf("\nFinished mem_addr part: memaddr = %x",*mem_addr_ptr); - /************debugging end************/ - - while((ch = from[i++]) != ':') - { - *len_ptr = *len_ptr << 4; - *len_ptr |= fromhex(ch) & 0x0f; - } - /************debugging begin************/ - printf("\nFinished len_ptr part: len = %d",*len_ptr); - /************debugging end************/ - - convert_ascii_to_int(&from[i++],to,*len_ptr); - - /************debugging begin************/ - printf("\nmembuf : %x",*(int *)to); - /************debugging end************/ -} - -SHAR_EOF -# End of shell archive -exit 0 diff --git a/gdb/remote-adapt.c b/gdb/remote-adapt.c deleted file mode 100644 index 6c22422285a..00000000000 --- a/gdb/remote-adapt.c +++ /dev/null @@ -1,1448 +0,0 @@ -/* Remote debugging interface for AMD 290*0 Adapt Monitor Version 2.1d18. - Copyright 1990, 1991 Free Software Foundation, Inc. - Contributed by David Wood at New York University (wood@lab.ultra.nyu.edu). - Adapted from work done at Cygnus Support in remote-eb.c. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* This is like remote.c but is for an esoteric situation-- - having a 29k board attached to an Adapt inline monitor. - The monitor is connected via serial line to a unix machine - running gdb. - - 3/91 - developed on Sun3 OS 4.1, by David Wood - o - I can't get binary coff to load. - o - I can't get 19200 baud rate to work. - 7/91 o - Freeze mode tracing can be done on a 29050. */ - -#include -#include -#include "defs.h" -#include "tm.h" -#include "param-no-tm.h" -#include "inferior.h" -#include "wait.h" -#include "value.h" -#include -#include -#include -#include -#include "terminal.h" -#include "target.h" -#include "gdbcore.h" - -/* External data declarations */ -extern int stop_soon_quietly; /* for wait_for_inferior */ - -/* External function declarations */ -extern struct value *call_function_by_hand(); - -/* Forward data declarations */ -extern struct target_ops adapt_ops; /* Forward declaration */ - -/* Forward function declarations */ -static void adapt_fetch_registers (); -static int adapt_store_registers (); -static void adapt_close (); -static int adapt_clear_breakpoints(); - -/* - * Processor types. It is assumed that the adapt has the correct - * ROM for the given processor. - */ -#define TYPE_UNKNOWN 0 -#define TYPE_A29000 1 -#define TYPE_A29030 2 -#define TYPE_A29050 3 -static char *processor_name[] = { "Unknown", "A29000", "A29030", "A29050" }; -static int processor_type=TYPE_UNKNOWN; - -#define FREEZE_MODE (read_register(CPS_REGNUM) && 0x400) -#define USE_SHADOW_PC ((processor_type == TYPE_A29050) && FREEZE_MODE) - - -/* #define DEBUG /* */ -#ifdef DEBUG -# define DENTER(NAME) (printf_filtered("Entering %s\n",NAME), fflush(stdout)) -# define DEXIT(NAME) (printf_filtered("Exiting %s\n",NAME), fflush(stdout)) -#else -# define DENTER(NAME) -# define DEXIT(NAME) -#endif - -/* Can't seem to get binary coff working */ -#define ASCII_COFF /* Adapt will be downloaded with ascii coff */ - -#define LOG_FILE "adapt.log" -#if defined (LOG_FILE) -FILE *log_file=NULL; -#endif - -static int timeout = 5; -static char *dev_name; - -/* Descriptor for I/O to remote machine. Initialize it to -1 so that - adapt_open knows that we don't have a file open when the program - starts. */ -int adapt_desc = -1; - -/* stream which is fdopen'd from adapt_desc. Only valid when - adapt_desc != -1. */ -FILE *adapt_stream; - -#define ON 1 -#define OFF 0 -static void -rawmode(desc, turnon) -int desc; -int turnon; -{ - TERMINAL sg; - - if (desc < 0) - return; - - ioctl (desc, TIOCGETP, &sg); - - if (turnon) { -#ifdef HAVE_TERMIO - sg.c_lflag &= ~(ICANON); -#else - sg.sg_flags |= RAW; -#endif - } else { -#ifdef HAVE_TERMIO - sg.c_lflag |= ICANON; -#else - sg.sg_flags &= ~(RAW); -#endif - } - ioctl (desc, TIOCSETP, &sg); -} - -/* Suck up all the input from the adapt */ -slurp_input() -{ - char buf[8]; - -#ifdef HAVE_TERMIO - /* termio does the timeout for us. */ - while (read (adapt_desc, buf, 8) > 0); -#else - alarm (timeout); - while (read (adapt_desc, buf, 8) > 0); - alarm (0); -#endif -} - -/* Read a character from the remote system, doing all the fancy - timeout stuff. */ -static int -readchar () -{ - char buf; - - buf = '\0'; -#ifdef HAVE_TERMIO - /* termio does the timeout for us. */ - read (adapt_desc, &buf, 1); -#else - alarm (timeout); - if (read (adapt_desc, &buf, 1) < 0) - { - if (errno == EINTR) - error ("Timeout reading from remote system."); - else - perror_with_name ("remote"); - } - alarm (0); -#endif - - if (buf == '\0') - error ("Timeout reading from remote system."); -#if defined (LOG_FILE) - putc (buf & 0x7f, log_file); -#endif - return buf & 0x7f; -} - -/* Keep discarding input from the remote system, until STRING is found. - Let the user break out immediately. */ -static void -expect (string) - char *string; -{ - char *p = string; - - fflush(adapt_stream); - immediate_quit = 1; - while (1) - { - if (readchar() == *p) - { - p++; - if (*p == '\0') - { - immediate_quit = 0; - return; - } - } - else - p = string; - } -} - -/* Keep discarding input until we see the adapt prompt. - - The convention for dealing with the prompt is that you - o give your command - o *then* wait for the prompt. - - Thus the last thing that a procedure does with the serial line - will be an expect_prompt(). Exception: adapt_resume does not - wait for the prompt, because the terminal is being handed over - to the inferior. However, the next thing which happens after that - is a adapt_wait which does wait for the prompt. - Note that this includes abnormal exit, e.g. error(). This is - necessary to prevent getting into states from which we can't - recover. */ -static void -expect_prompt () -{ -#if defined (LOG_FILE) - /* This is a convenient place to do this. The idea is to do it often - enough that we never lose much data if we terminate abnormally. */ - fflush (log_file); -#endif - fflush(adapt_stream); - expect ("\n# "); -} - -/* Get a hex digit from the remote system & return its value. - If ignore_space is nonzero, ignore spaces (not newline, tab, etc). */ -static int -get_hex_digit (ignore_space) - int ignore_space; -{ - int ch; - while (1) - { - ch = readchar (); - if (ch >= '0' && ch <= '9') - return ch - '0'; - else if (ch >= 'A' && ch <= 'F') - return ch - 'A' + 10; - else if (ch >= 'a' && ch <= 'f') - return ch - 'a' + 10; - else if (ch == ' ' && ignore_space) - ; - else - { - expect_prompt (); - error ("Invalid hex digit from remote system."); - } - } -} - -/* Get a byte from adapt_desc and put it in *BYT. Accept any number - leading spaces. */ -static void -get_hex_byte (byt) - char *byt; -{ - int val; - - val = get_hex_digit (1) << 4; - val |= get_hex_digit (0); - *byt = val; -} - -/* Read a 32-bit hex word from the adapt, preceded by a space */ -static long -get_hex_word() -{ - long val; - int j; - - val = 0; - for (j = 0; j < 8; j++) - val = (val << 4) + get_hex_digit (j == 0); - return val; -} -/* Get N 32-bit hex words from remote, each preceded by a space - and put them in registers starting at REGNO. */ -static void -get_hex_regs (n, regno) - int n; - int regno; -{ - long val; - while (n--) { - val = get_hex_word(); - supply_register(regno++,&val); - } -} -/* Called when SIGALRM signal sent due to alarm() timeout. */ -#ifndef HAVE_TERMIO - -#ifndef __STDC__ -# ifndef volatile -# define volatile /**/ -# endif -#endif -volatile int n_alarms; - -void -adapt_timer () -{ -#if 0 - if (kiodebug) - printf ("adapt_timer called\n"); -#endif - n_alarms++; -} -#endif - -/* malloc'd name of the program on the remote system. */ -static char *prog_name = NULL; - -/* Number of SIGTRAPs we need to simulate. That is, the next - NEED_ARTIFICIAL_TRAP calls to adapt_wait should just return - SIGTRAP without actually waiting for anything. */ - -static int need_artificial_trap = 0; - -void -adapt_kill(arg,from_tty) -char *arg; -int from_tty; -{ - DENTER("adapt_kill()"); - fprintf (adapt_stream, "K"); - fprintf (adapt_stream, "\r"); - expect_prompt (); - DEXIT("adapt_kill()"); -} -/* - * Download a file specified in 'args', to the adapt. - * FIXME: Assumes the file to download is a binary coff file. - */ -static void -adapt_load(args,fromtty) -char *args; -int fromtty; -{ - FILE *fp; - int n; - char buffer[1024]; - - DENTER("adapt_load()"); - if (!adapt_stream) { - printf_filtered("Adapt not open. Use 'target' command to open adapt\n"); - return; - } - - /* OK, now read in the file. Y=read, C=COFF, T=dTe port - 0=start address. */ - -#ifdef ASCII_COFF /* Ascii coff */ - fprintf (adapt_stream, "YA T,0\r"); - fflush(adapt_stream); /* Just in case */ - /* FIXME: should check args for only 1 argument */ - sprintf(buffer,"cat %s | btoa > /tmp/#adapt-btoa",args); - system(buffer); - fp = fopen("/tmp/#adapt-btoa","r"); - rawmode(adapt_desc,OFF); - while (n=fread(buffer,1,1024,fp)) { - do { n -= write(adapt_desc,buffer,n); } while (n>0); - if (n<0) { perror("writing ascii coff"); break; } - } - fclose(fp); - rawmode(adapt_desc,ON); - system("rm /tmp/#adapt-btoa"); -#else /* Binary coff - can't get it to work .*/ - fprintf (adapt_stream, "YC T,0\r"); - fflush(adapt_stream); /* Just in case */ - if (!(fp = fopen(args,"r"))) { - printf_filtered("Can't open %s\n",args); - return; - } - while (n=fread(buffer,1,512,fp)) { - do { n -= write(adapt_desc,buffer,n); } while (n>0); - if (n<0) { perror("writing ascii coff"); break; } - } - fclose(fp); -#endif - expect_prompt (); /* Skip garbage that comes out */ - fprintf (adapt_stream, "\r"); - expect_prompt (); - DEXIT("adapt_load()"); -} - -/* This is called not only when we first attach, but also when the - user types "run" after having attached. */ -void -adapt_create_inferior (execfile, args, env) - char *execfile; - char *args; - char **env; -{ - int entry_pt; - - DENTER("adapt_create_inferior()"); - - if (args && *args) - error ("Can't pass arguments to remote adapt process."); - - if (execfile == 0 || exec_bfd == 0) - error ("No exec file specified"); - - entry_pt = (int) bfd_get_start_address (exec_bfd); - - if (adapt_stream) { - adapt_kill(NULL,NULL); - adapt_clear_breakpoints(); - init_wait_for_inferior (); - /* Clear the input because what the adapt sends back is different - * depending on whether it was running or not. - */ - slurp_input(); /* After this there should be a prompt */ - fprintf(adapt_stream,"\r"); - expect_prompt(); - printf_filtered("Do you want to download '%s' (y/n)? [y] : ",prog_name); - { - char buffer[10]; - gets(buffer); - if (*buffer != 'n') { - adapt_load(prog_name,0); - } - } - -#ifdef NOTDEF - /* Set the PC and wait for a go/cont */ - fprintf (adapt_stream, "G %x,N\r",entry_pt); - printf_filtered("Now use the 'continue' command to start.\n"); - expect_prompt (); -#else - insert_breakpoints (); /* Needed to get correct instruction in cache */ - proceed(entry_pt, -1, 0); -#endif - - } else { - printf_filtered("Adapt not open yet.\n"); - } - DEXIT("adapt_create_inferior()"); -} - -/* Translate baud rates from integers to damn B_codes. Unix should - have outgrown this crap years ago, but even POSIX wouldn't buck it. */ - -#ifndef B19200 -#define B19200 EXTA -#endif -#ifndef B38400 -#define B38400 EXTB -#endif - -static struct {int rate, damn_b;} baudtab[] = { - {0, B0}, - {50, B50}, - {75, B75}, - {110, B110}, - {134, B134}, - {150, B150}, - {200, B200}, - {300, B300}, - {600, B600}, - {1200, B1200}, - {1800, B1800}, - {2400, B2400}, - {4800, B4800}, - {9600, B9600}, - {19200, B19200}, - {38400, B38400}, - {-1, -1}, -}; - -static int damn_b (rate) - int rate; -{ - int i; - - for (i = 0; baudtab[i].rate != -1; i++) - if (rate == baudtab[i].rate) return baudtab[i].damn_b; - return B38400; /* Random */ -} - - -/* Open a connection to a remote debugger. - NAME is the filename used for communication, then a space, - then the baud rate. - */ - -static int baudrate = 9600; -static void -adapt_open (name, from_tty) - char *name; - int from_tty; -{ - TERMINAL sg; - unsigned int prl; - char *p; - - DENTER("adapt_open()"); - /* Find the first whitespace character, it separates dev_name from - prog_name. */ - if (name == 0) - goto erroid; - - for (p = name; - *p != '\0' && !isspace (*p); p++) - ; - if (*p == '\0') -erroid: - error ("\ -Please include the name of the device for the serial port,\n\ -the baud rate, and the name of the program to run on the remote system."); - dev_name = (char*)malloc(p - name + 1); - strncpy (dev_name, name, p - name); - dev_name[p - name] = '\0'; - - /* Skip over the whitespace after dev_name */ - for (; isspace (*p); p++) - /*EMPTY*/; - - if (1 != sscanf (p, "%d ", &baudrate)) - goto erroid; - - /* Skip the number and then the spaces */ - for (; isdigit (*p); p++) - /*EMPTY*/; - for (; isspace (*p); p++) - /*EMPTY*/; - - if (prog_name != NULL) - free (prog_name); - prog_name = savestring (p, strlen (p)); - - adapt_close (0); - - adapt_desc = open (dev_name, O_RDWR); - if (adapt_desc < 0) - perror_with_name (dev_name); - ioctl (adapt_desc, TIOCGETP, &sg); -#ifdef HAVE_TERMIO - sg.c_cc[VMIN] = 0; /* read with timeout. */ - sg.c_cc[VTIME] = timeout * 10; - sg.c_lflag &= ~(ICANON | ECHO); - sg.c_cflag = (sg.c_cflag & ~CBAUD) | damn_b (baudrate); -#else - sg.sg_ispeed = damn_b (baudrate); - sg.sg_ospeed = damn_b (baudrate); - sg.sg_flags |= RAW | ANYP; - sg.sg_flags &= ~ECHO; -#endif - - ioctl (adapt_desc, TIOCSETP, &sg); - adapt_stream = fdopen (adapt_desc, "r+"); - - push_target (&adapt_ops); - /* start_remote (); /* Initialize gdb process mechanisms */ - - -#ifndef HAVE_TERMIO -#ifndef NO_SIGINTERRUPT - /* Cause SIGALRM's to make reads fail with EINTR instead of resuming - the read. */ - if (siginterrupt (SIGALRM, 1) != 0) - perror ("adapt_open: error in siginterrupt"); -#endif - - /* Set up read timeout timer. */ - if ((void (*)) signal (SIGALRM, adapt_timer) == (void (*)) -1) - perror ("adapt_open: error in signal"); -#endif - -#if defined (LOG_FILE) - log_file = fopen (LOG_FILE, "w"); - if (log_file == NULL) - perror_with_name (LOG_FILE); -#endif - - /* Put this port into NORMAL mode, send the 'normal' character */ - write(adapt_desc, "", 1); /* Control A */ - write(adapt_desc, "\r", 1); - expect_prompt (); - - /* Hello? Are you there? */ - write (adapt_desc, "\r", 1); - - expect_prompt (); - - /* Clear any break points */ - adapt_clear_breakpoints(); - - /* Determine the processor revision level */ - prl = (unsigned int)read_register(CFG_REGNUM) >> 24; - if (prl == 0x03) { - processor_type = TYPE_A29000; - } else if ((prl&0xf0) == 0x40) { /* 29030 = 0x4* */ - processor_type = TYPE_A29030; - fprintf_filtered(stderr,"WARNING: debugging of A29030 not tested.\n"); - } else if ((prl&0xf0) == 0x20) { /* 29050 = 0x2* */ - processor_type = TYPE_A29050; - fprintf_filtered(stderr,"WARNING: debugging of A29050 not tested.\n"); - } else { - processor_type = TYPE_UNKNOWN; - fprintf_filtered(stderr,"WARNING: processor type unknown.\n"); - } - - /* Print out some stuff, letting the user now what's going on */ - printf_filtered("Remote debugging on an %s connect to an Adapt via %s.\n", - processor_name[processor_type],dev_name); - /* FIXME: can this restriction be removed? */ - printf_filtered("Remote debugging using virtual addresses works only\n"); - printf_filtered("\twhen virtual addresses map 1:1 to physical addresses.\n"); - if (processor_type != TYPE_A29050) { - fprintf_filtered(stderr, - "Freeze-mode debugging not available, and can only be done on an A29050.\n"); - } - DEXIT("adapt_open()"); -} - -/* Close out all files and local state before this target loses control. */ - -static void -adapt_close (quitting) - int quitting; -{ - - DENTER("adapt_close()"); - - /* Clear any break points */ - adapt_clear_breakpoints(); - - /* Put this port back into REMOTE mode */ - if (adapt_stream) { - fflush(adapt_stream); - sleep(1); /* Let any output make it all the way back */ - write(adapt_desc, "R\r", 2); - } - - /* Due to a bug in Unix, fclose closes not only the stdio stream, - but also the file descriptor. So we don't actually close - adapt_desc. */ - if (adapt_stream) - fclose (adapt_stream); /* This also closes adapt_desc */ - if (adapt_desc >= 0) - /* close (adapt_desc); */ - - /* Do not try to close adapt_desc again, later in the program. */ - adapt_stream = NULL; - adapt_desc = -1; - -#if defined (LOG_FILE) - if (log_file) { - if (ferror (log_file)) - printf_filtered ("Error writing log file.\n"); - if (fclose (log_file) != 0) - printf_filtered ("Error closing log file.\n"); - log_file = NULL; - } -#endif - DEXIT("adapt_close()"); -} - -/* Attach to the target that is already loaded and possibly running */ -static void -adapt_attach (args, from_tty) - char *args; - int from_tty; -{ - - DENTER("adapt_attach()"); - if (from_tty) - printf_filtered ("Attaching to remote program %s.\n", prog_name); - - /* push_target(&adapt_ops); /* This done in adapt_open() */ - - mark_breakpoints_out (); - - /* Send the adapt a kill. It is ok if it is not already running */ - fprintf(adapt_stream, "K\r"); fflush(adapt_stream); - expect_prompt(); /* Slurp the echo */ - - /* We will get a task spawn event immediately. */ - init_wait_for_inferior (); - clear_proceed_status (); - stop_soon_quietly = 1; - wait_for_inferior (); - stop_soon_quietly = 0; - normal_stop (); - DEXIT("adapt_attach()"); -} - - -/* Terminate the open connection to the remote debugger. - Use this when you want to detach and do something else - with your gdb. */ -void -adapt_detach (args,from_tty) - char *args; - int from_tty; -{ - DENTER("adapt_detach()"); - if (adapt_stream) { /* Send it on its way (tell it to continue) */ - adapt_clear_breakpoints(); - fprintf(adapt_stream,"G\r"); - } - - pop_target(); /* calls adapt_close to do the real work */ - if (from_tty) - printf_filtered ("Ending remote %s debugging\n", target_shortname); - DEXIT("adapt_detach()"); -} - -/* Tell the remote machine to resume. */ - -void -adapt_resume (step, sig) - int step, sig; -{ - DENTER("adapt_resume()"); - if (step) - { - write (adapt_desc, "t 1,s\r", 6); - /* Wait for the echo. */ - expect ("t 1,s\r\n"); - /* Then comes a line containing the instruction we stepped to. */ - expect ("@"); - /* Then we get the prompt. */ - expect_prompt (); - - /* Force the next adapt_wait to return a trap. Not doing anything - about I/O from the target means that the user has to type - "continue" to see any. FIXME, this should be fixed. */ - need_artificial_trap = 1; - } - else - { - write (adapt_desc, "G\r", 2); - /* Swallow the echo. */ - expect_prompt(); - } - DEXIT("adapt_resume()"); -} - -/* Wait until the remote machine stops, then return, - storing status in STATUS just as `wait' would. */ - -int -adapt_wait (status) - WAITTYPE *status; -{ - /* Strings to look for. '?' means match any single character. - Note that with the algorithm we use, the initial character - of the string cannot recur in the string, or we will not - find some cases of the string in the input. */ - - static char bpt[] = "@"; - /* It would be tempting to look for "\n[__exit + 0x8]\n" - but that requires loading symbols with "yc i" and even if - we did do that we don't know that the file has symbols. */ - static char exitmsg[] = "@????????I JMPTI GR121,LR0"; - char *bp = bpt; - char *ep = exitmsg; - - /* Large enough for either sizeof (bpt) or sizeof (exitmsg) chars. */ - char swallowed[50]; - /* Current position in swallowed. */ - char *swallowed_p = swallowed; - - int ch; - int ch_handled; - int old_timeout = timeout; - int old_immediate_quit = immediate_quit; - - DENTER("adapt_wait()"); - - WSETEXIT ((*status), 0); - - if (need_artificial_trap != 0) - { - WSETSTOP ((*status), SIGTRAP); - need_artificial_trap--; - return 0; - } - - timeout = 0; /* Don't time out -- user program is running. */ - immediate_quit = 1; /* Helps ability to QUIT */ - while (1) { - QUIT; /* Let user quit and leave process running */ - ch_handled = 0; - ch = readchar (); - if (ch == *bp) { - bp++; - if (*bp == '\0') - break; - ch_handled = 1; - - *swallowed_p++ = ch; - } else - bp = bpt; - if (ch == *ep || *ep == '?') { - ep++; - if (*ep == '\0') - break; - - if (!ch_handled) - *swallowed_p++ = ch; - ch_handled = 1; - } else - ep = exitmsg; - if (!ch_handled) { - char *p; - /* Print out any characters which have been swallowed. */ - for (p = swallowed; p < swallowed_p; ++p) - putc (*p, stdout); - swallowed_p = swallowed; - putc (ch, stdout); - } - } - expect_prompt (); - if (*bp== '\0') - WSETSTOP ((*status), SIGTRAP); - else - WSETEXIT ((*status), 0); - timeout = old_timeout; - immediate_quit = old_immediate_quit; - DEXIT("adapt_wait()"); - return 0; -} - -/* Return the name of register number REGNO - in the form input and output by adapt. - - Returns a pointer to a static buffer containing the answer. */ -static char * -get_reg_name (regno) - int regno; -{ - static char buf[80]; - if (regno >= GR96_REGNUM && regno < GR96_REGNUM + 32 ) - sprintf (buf, "GR%03d", regno - GR96_REGNUM + 96); -#if defined(GR64_REGNUM) - else if (regno >= GR64_REGNUM && regno < GR64_REGNUM + 32 ) - sprintf (buf, "GR%03d", regno - GR64_REGNUM + 64); -#endif - else if (regno >= LR0_REGNUM && regno < LR0_REGNUM + 128) - sprintf (buf, "LR%03d", regno - LR0_REGNUM); - else if (regno == Q_REGNUM) - strcpy (buf, "SR131"); - else if (regno >= BP_REGNUM && regno <= CR_REGNUM) - sprintf (buf, "SR%03d", regno - BP_REGNUM + 133); - else if (regno == ALU_REGNUM) - strcpy (buf, "SR132"); - else if (regno >= IPC_REGNUM && regno <= IPB_REGNUM) - sprintf (buf, "SR%03d", regno - IPC_REGNUM + 128); - else if (regno >= VAB_REGNUM && regno <= LRU_REGNUM) { - /* When a 29050 is in freeze-mode, read shadow pcs instead */ - if ((regno >= NPC_REGNUM && regno <= PC2_REGNUM) && USE_SHADOW_PC) - sprintf (buf, "SR%03d", regno - NPC_REGNUM + 20); - else - sprintf (buf, "SR%03d", regno - VAB_REGNUM); - } - else if (regno == GR1_REGNUM) - strcpy (buf, "GR001"); - return buf; -} - -/* Read the remote registers. */ - -static void -adapt_fetch_registers () -{ - int reg_index; - int regnum_index; - char tempbuf[10]; - int sreg_buf[16]; - int i,j; - - DENTER("adapt_fetch_registers()"); - -/* - * Global registers - */ -#if defined(GR64_REGNUM) - write (adapt_desc, "dw gr64,gr95\r", 13); - for (reg_index = 64, regnum_index = GR64_REGNUM; - reg_index < 96; - reg_index += 4, regnum_index += 4) - { - sprintf (tempbuf, "GR%03d ", reg_index); - expect (tempbuf); - get_hex_regs (4, regnum_index); - expect ("\n"); - } -#endif - write (adapt_desc, "dw gr96,gr127\r", 14); - for (reg_index = 96, regnum_index = GR96_REGNUM; - reg_index < 128; - reg_index += 4, regnum_index += 4) - { - sprintf (tempbuf, "GR%03d ", reg_index); - expect (tempbuf); - get_hex_regs (4, regnum_index); - expect ("\n"); - } - -/* - * Local registers - */ - for (i = 0; i < 128; i += 32) - { - /* The PC has a tendency to hang if we get these - all in one fell swoop ("dw lr0,lr127"). */ - sprintf (tempbuf, "dw lr%d\r", i); - write (adapt_desc, tempbuf, strlen (tempbuf)); - for (reg_index = i, regnum_index = LR0_REGNUM + i; - reg_index < i + 32; - reg_index += 4, regnum_index += 4) - { - sprintf (tempbuf, "LR%03d ", reg_index); - expect (tempbuf); - get_hex_regs (4, regnum_index); - expect ("\n"); - } - } - -/* - * Special registers - */ - sprintf (tempbuf, "dw sr0\r"); - write (adapt_desc, tempbuf, strlen (tempbuf)); - for (i=0 ; i<4 ; i++) { /* SR0 - SR14 */ - sprintf (tempbuf, "SR%3d",i*4); - expect(tempbuf); - for (j=0 ; j < (i==3 ? 3 : 4) ; j++) - sreg_buf[i*4 + j] = get_hex_word(); - } - expect_prompt(); - /* - * Read the pcs individually if we are in freeze mode. - * See get_reg_name(), it translates the register names for the pcs to - * the names of the shadow pcs. - */ - if (USE_SHADOW_PC) { - sreg_buf[10] = read_register(NPC_REGNUM); /* pc0 */ - sreg_buf[11] = read_register(PC_REGNUM); /* pc1 */ - sreg_buf[12] = read_register(PC2_REGNUM); /* pc2 */ - } - for (i=0 ; i<14 ; i++) /* Supply vab -> lru */ - supply_register(VAB_REGNUM+i,&sreg_buf[i]); - sprintf (tempbuf, "dw sr128\r"); - write (adapt_desc, tempbuf, strlen (tempbuf)); - for (i=0 ; i<2 ; i++) { /* SR128 - SR135 */ - sprintf (tempbuf, "SR%3d",128 + i*4); - expect(tempbuf); - for (j=0 ; j<4 ; j++) - sreg_buf[i*4 + j] = get_hex_word(); - } - expect_prompt(); - supply_register(IPC_REGNUM,&sreg_buf[0]); - supply_register(IPA_REGNUM,&sreg_buf[1]); - supply_register(IPB_REGNUM,&sreg_buf[2]); - supply_register(Q_REGNUM, &sreg_buf[3]); - /* Skip ALU */ - supply_register(BP_REGNUM, &sreg_buf[5]); - supply_register(FC_REGNUM, &sreg_buf[6]); - supply_register(CR_REGNUM, &sreg_buf[7]); - - /* There doesn't seem to be any way to get these. */ - { - int val = -1; - supply_register (FPE_REGNUM, &val); - supply_register (INT_REGNUM, &val); - supply_register (FPS_REGNUM, &val); - supply_register (EXO_REGNUM, &val); - } - - write (adapt_desc, "dw gr1,gr1\r", 11); - expect ("GR001 "); - get_hex_regs (1, GR1_REGNUM); - expect_prompt (); - - DEXIT("adapt_fetch_registers()"); -} - -/* Fetch register REGNO, or all registers if REGNO is -1. - */ -static void -adapt_fetch_register (regno) - int regno; -{ - DENTER("adapt_fetch_register()"); - if (regno == -1) - adapt_fetch_registers (); - else - { - char *name = get_reg_name (regno); - fprintf (adapt_stream, "dw %s,%s\r", name, name); - expect (name); - expect (" "); - get_hex_regs (1, regno); - expect_prompt (); - } - DEXIT("adapt_fetch_register()"); -} - -/* Store the remote registers from the contents of the block REGS. */ - -static int -adapt_store_registers () -{ - int i, j; - - DENTER("adapt_store_registers()"); - fprintf (adapt_stream, "s gr1,%x\r", read_register (GR1_REGNUM)); - expect_prompt (); - -#if defined(GR64_REGNUM) - for (j = 0; j < 32; j += 16) - { - fprintf (adapt_stream, "s gr%d,", j + 64); - for (i = 0; i < 15; ++i) - fprintf (adapt_stream, "%x,", read_register (GR64_REGNUM + j + i)); - fprintf (adapt_stream, "%x\r", read_register (GR64_REGNUM + j + 15)); - expect_prompt (); - } -#endif - for (j = 0; j < 32; j += 16) - { - fprintf (adapt_stream, "s gr%d,", j + 96); - for (i = 0; i < 15; ++i) - fprintf (adapt_stream, "%x,", read_register (GR96_REGNUM + j + i)); - fprintf (adapt_stream, "%x\r", read_register (GR96_REGNUM + j + 15)); - expect_prompt (); - } - - for (j = 0; j < 128; j += 16) - { - fprintf (adapt_stream, "s lr%d,", j); - for (i = 0; i < 15; ++i) - fprintf (adapt_stream, "%x,", read_register (LR0_REGNUM + j + i)); - fprintf (adapt_stream, "%x\r", read_register (LR0_REGNUM + j + 15)); - expect_prompt (); - } - - fprintf (adapt_stream, "s sr128,%x,%x,%x\r", read_register (IPC_REGNUM), - read_register (IPA_REGNUM), read_register (IPB_REGNUM)); - expect_prompt (); - fprintf (adapt_stream, "s sr133,%x,%x,%x\r", read_register (BP_REGNUM), - read_register (FC_REGNUM), read_register (CR_REGNUM)); - expect_prompt (); - fprintf (adapt_stream, "s sr131,%x\r", read_register (Q_REGNUM)); - expect_prompt (); - fprintf (adapt_stream, "s sr0,"); - for (i=0 ; i<7 ; ++i) - fprintf (adapt_stream, "%x,", read_register (VAB_REGNUM + i)); - expect_prompt (); - fprintf (adapt_stream, "s sr7,"); - for (i=7; i<14 ; ++i) - fprintf (adapt_stream, "%x,", read_register (VAB_REGNUM + i)); - expect_prompt (); -} - -/* Store register REGNO, or all if REGNO == -1. - Return errno value. */ -int -adapt_store_register (regno) - int regno; -{ - /* printf("adapt_store_register() called.\n"); fflush(stdout); /* */ - if (regno == -1) - adapt_store_registers (); - else - { - char *name = get_reg_name (regno); - fprintf (adapt_stream, "s %s,%x\r", name, read_register (regno)); - /* Setting GR1 changes the numbers of all the locals, so - invalidate the register cache. Do this *after* calling - read_register, because we want read_register to return the - value that write_register has just stuffed into the registers - array, not the value of the register fetched from the - inferior. */ - if (regno == GR1_REGNUM) - registers_changed (); - expect_prompt (); - } - DEXIT("adapt_store_registers()"); - return 0; -} - -/* Get ready to modify the registers array. On machines which store - individual registers, this doesn't need to do anything. On machines - which store all the registers in one fell swoop, this makes sure - that registers contains all the registers from the program being - debugged. */ - -void -adapt_prepare_to_store () -{ - /* Do nothing, since we can store individual regs */ -} - -static CORE_ADDR -translate_addr(addr) -CORE_ADDR addr; -{ -#if defined(KERNEL_DEBUGGING) - /* Check for a virtual address in the kernel */ - /* Assume physical address of ublock is in paddr_u register */ - if (addr >= UVADDR) { - /* PADDR_U register holds the physical address of the ublock */ - CORE_ADDR i = (CORE_ADDR)read_register(PADDR_U_REGNUM); - return(i + addr - (CORE_ADDR)UVADDR); - } else { - return(addr); - } -#else - return(addr); -#endif -} - - -/* FIXME! Merge these two. */ -int -adapt_xfer_inferior_memory (memaddr, myaddr, len, write) - CORE_ADDR memaddr; - char *myaddr; - int len; - int write; -{ - - memaddr = translate_addr(memaddr); - - if (write) - return adapt_write_inferior_memory (memaddr, myaddr, len); - else - return adapt_read_inferior_memory (memaddr, myaddr, len); -} - -void -adapt_files_info () -{ - printf_filtered("\tAttached to %s at %d baud and running program %s\n", - dev_name, baudrate, prog_name); - printf_filtered("\ton an %s processor.\n", processor_name[processor_type]); -} - -/* Copy LEN bytes of data from debugger memory at MYADDR - to inferior's memory at MEMADDR. Returns errno value. - * sb/sh instructions don't work on unaligned addresses, when TU=1. - */ -int -adapt_write_inferior_memory (memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - int i; - unsigned int cps; - - /* DENTER("adapt_write_inferior_memory()"); */ - -/* Turn TU bit off so we can do 'sb' commands */ - cps = read_register(CPS_REGNUM); - if (cps & 0x00000800) - write_register(CPS_REGNUM,cps&~(0x00000800)); - - for (i = 0; i < len; i++) - { - if ((i % 16) == 0) - fprintf (adapt_stream, "sb %x,", memaddr + i); - if ((i % 16) == 15 || i == len - 1) - { - fprintf (adapt_stream, "%x\r", ((unsigned char *)myaddr)[i]); - expect_prompt (); - } - else - fprintf (adapt_stream, "%x,", ((unsigned char *)myaddr)[i]); - } - /* Restore the old value of cps if the TU bit was on */ - if (cps & 0x00000800) - write_register(CPS_REGNUM,cps); - /* DEXIT("adapt_write_inferior_memory()"); */ - return len; -} - -/* Read LEN bytes from inferior memory at MEMADDR. Put the result - at debugger address MYADDR. Returns errno value. */ -int -adapt_read_inferior_memory(memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - int i; - - /* Number of bytes read so far. */ - int count; - - /* Starting address of this pass. */ - unsigned long startaddr; - - /* Number of bytes to read in this pass. */ - int len_this_pass; - - /* Note that this code works correctly if startaddr is just less - than UINT_MAX (well, really CORE_ADDR_MAX if there was such a - thing). That is, something like - adapt_read_bytes (CORE_ADDR_MAX - 4, foo, 4) - works--it never adds len to memaddr and gets 0. */ - /* However, something like - adapt_read_bytes (CORE_ADDR_MAX - 3, foo, 4) - doesn't need to work. Detect it and give up if there's an attempt - to do that. */ - /* DENTER("adapt_read_inferior_memory()"); */ - - if (((memaddr - 1) + len) < memaddr) - return EIO; - - startaddr = memaddr; - count = 0; - while (count < len) - { - len_this_pass = 16; - if ((startaddr % 16) != 0) - len_this_pass -= startaddr % 16; - if (len_this_pass > (len - count)) - len_this_pass = (len - count); - - fprintf (adapt_stream, "db %x,%x\r", startaddr, - (startaddr - 1) + len_this_pass); - -#ifdef NOTDEF /* Why do this */ - expect ("\n"); - /* Look for 8 hex digits. */ - i = 0; - while (1) - { - if (isxdigit (readchar ())) - ++i; - else - { - expect_prompt (); - error ("Hex digit expected from remote system."); - } - if (i >= 8) - break; - } -#endif /* NOTDEF */ - - expect (" "); - - for (i = 0; i < len_this_pass; i++) - get_hex_byte (&myaddr[count++]); - - expect_prompt (); - - startaddr += len_this_pass; - } - - /* DEXIT("adapt_read_inferior_memory()"); */ - return count; -} - -#define MAX_BREAKS 8 -static int num_brkpts=0; -static int -adapt_insert_breakpoint(addr, save) -CORE_ADDR addr; -char *save; /* Throw away, let adapt save instructions */ -{ - DENTER("adapt_insert_breakpoint()"); - if (num_brkpts < MAX_BREAKS) { - num_brkpts++; - fprintf (adapt_stream, "B %x", addr); - fprintf (adapt_stream, "\r"); - expect_prompt (); - DEXIT("adapt_insert_breakpoint() success"); - return(0); /* Success */ - } else { - fprintf_filtered(stderr, - "Too many break points, break point not installed\n"); - DEXIT("adapt_insert_breakpoint() failure"); - return(1); /* Failure */ - } - -} -static int -adapt_remove_breakpoint(addr, save) -CORE_ADDR addr; -char *save; /* Throw away, let adapt save instructions */ -{ - DENTER("adapt_remove_breakpoint()"); - if (num_brkpts > 0) { - num_brkpts--; - fprintf (adapt_stream, "BR %x", addr); - fprintf (adapt_stream, "\r"); - fflush (adapt_stream); - expect_prompt (); - } - DEXIT("adapt_remove_breakpoint()"); - return(0); -} - -/* Clear the adapts notion of what the break points are */ -static int -adapt_clear_breakpoints() -{ - DENTER("adapt_clear_breakpoint()"); - if (adapt_stream) { - fprintf (adapt_stream, "BR"); /* Clear all break points */ - fprintf (adapt_stream, "\r"); - fflush(adapt_stream); - expect_prompt (); - } - num_brkpts = 0; - DEXIT("adapt_clear_breakpoint()"); -} -static void -adapt_mourn() -{ - DENTER("adapt_mourn()"); - adapt_clear_breakpoints(); - pop_target (); /* Pop back to no-child state */ - generic_mourn_inferior (); - DEXIT("adapt_mourn()"); -} - -/* Display everthing we read in from the adapt until we match/see the - * specified string - */ -static int -display_until(str) -char *str; -{ - int i=0,j,c; - - while (c=readchar()) { - if (c==str[i]) { - i++; - if (i == strlen(str)) return; - } else { - if (i) { - for (j=0 ; j", class_obscure, adapt_com, - "Send a command to the AMD Adapt remote monitor."); -} diff --git a/gdb/remote-eb.c b/gdb/remote-eb.c deleted file mode 100644 index 0315fe7bd51..00000000000 --- a/gdb/remote-eb.c +++ /dev/null @@ -1,942 +0,0 @@ -/* Remote debugging interface for AMD 29000 EBMON on IBM PC, for GDB. - Copyright 1990-1991 Free Software Foundation, Inc. - Contributed by Cygnus Support. Written by Jim Kingdon for Cygnus. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* This is like remote.c but is for an esoteric situation-- - having a 29k board in a PC hooked up to a unix machine with - a serial line, and running ctty com1 on the PC, through which - the unix machine can run ebmon. Not to mention that the PC - has PC/NFS, so it can access the same executables that gdb can, - over the net in real time. */ - -#include -#include -#include "defs.h" -#include "tm-29k.h" -#include "param-no-tm.h" -#include "inferior.h" -#include "wait.h" -#include "value.h" -#include -#include -#include -#include -#include "terminal.h" -#include "target.h" - -extern struct value *call_function_by_hand(); - -extern struct target_ops eb_ops; /* Forward declaration */ - -static void eb_close(); - -#define LOG_FILE "eb.log" -#if defined (LOG_FILE) -FILE *log_file; -#endif - -static int timeout = 5; - -/* Descriptor for I/O to remote machine. Initialize it to -1 so that - eb_open knows that we don't have a file open when the program - starts. */ -int eb_desc = -1; - -/* stream which is fdopen'd from eb_desc. Only valid when - eb_desc != -1. */ -FILE *eb_stream; - -/* Read a character from the remote system, doing all the fancy - timeout stuff. */ -static int -readchar () -{ - char buf; - - buf = '\0'; -#ifdef HAVE_TERMIO - /* termio does the timeout for us. */ - read (eb_desc, &buf, 1); -#else - alarm (timeout); - if (read (eb_desc, &buf, 1) < 0) - { - if (errno == EINTR) - error ("Timeout reading from remote system."); - else - perror_with_name ("remote"); - } - alarm (0); -#endif - - if (buf == '\0') - error ("Timeout reading from remote system."); -#if defined (LOG_FILE) - putc (buf & 0x7f, log_file); -#endif - return buf & 0x7f; -} - -/* Keep discarding input from the remote system, until STRING is found. - Let the user break out immediately. */ -static void -expect (string) - char *string; -{ - char *p = string; - - immediate_quit = 1; - while (1) - { - if (readchar() == *p) - { - p++; - if (*p == '\0') - { - immediate_quit = 0; - return; - } - } - else - p = string; - } -} - -/* Keep discarding input until we see the ebmon prompt. - - The convention for dealing with the prompt is that you - o give your command - o *then* wait for the prompt. - - Thus the last thing that a procedure does with the serial line - will be an expect_prompt(). Exception: eb_resume does not - wait for the prompt, because the terminal is being handed over - to the inferior. However, the next thing which happens after that - is a eb_wait which does wait for the prompt. - Note that this includes abnormal exit, e.g. error(). This is - necessary to prevent getting into states from which we can't - recover. */ -static void -expect_prompt () -{ -#if defined (LOG_FILE) - /* This is a convenient place to do this. The idea is to do it often - enough that we never lose much data if we terminate abnormally. */ - fflush (log_file); -#endif - expect ("\n# "); -} - -/* Get a hex digit from the remote system & return its value. - If ignore_space is nonzero, ignore spaces (not newline, tab, etc). */ -static int -get_hex_digit (ignore_space) - int ignore_space; -{ - int ch; - while (1) - { - ch = readchar (); - if (ch >= '0' && ch <= '9') - return ch - '0'; - else if (ch >= 'A' && ch <= 'F') - return ch - 'A' + 10; - else if (ch >= 'a' && ch <= 'f') - return ch - 'a' + 10; - else if (ch == ' ' && ignore_space) - ; - else - { - expect_prompt (); - error ("Invalid hex digit from remote system."); - } - } -} - -/* Get a byte from eb_desc and put it in *BYT. Accept any number - leading spaces. */ -static void -get_hex_byte (byt) - char *byt; -{ - int val; - - val = get_hex_digit (1) << 4; - val |= get_hex_digit (0); - *byt = val; -} - -/* Get N 32-bit words from remote, each preceded by a space, - and put them in registers starting at REGNO. */ -static void -get_hex_regs (n, regno) - int n; - int regno; -{ - long val; - int i; - - for (i = 0; i < n; i++) - { - int j; - - val = 0; - for (j = 0; j < 8; j++) - val = (val << 4) + get_hex_digit (j == 0); - supply_register (regno++, &val); - } -} - -/* Called when SIGALRM signal sent due to alarm() timeout. */ -#ifndef HAVE_TERMIO - -#ifndef __STDC__ -#define volatile /**/ -#endif -volatile int n_alarms; - -void -eb_timer () -{ -#if 0 - if (kiodebug) - printf ("eb_timer called\n"); -#endif - n_alarms++; -} -#endif - -/* malloc'd name of the program on the remote system. */ -static char *prog_name = NULL; - -/* Nonzero if we have loaded the file ("yc") and not yet issued a "gi" - command. "gi" is supposed to happen exactly once for each "yc". */ -static int need_gi = 0; - -/* Number of SIGTRAPs we need to simulate. That is, the next - NEED_ARTIFICIAL_TRAP calls to eb_wait should just return - SIGTRAP without actually waiting for anything. */ - -static int need_artificial_trap = 0; - -/* This is called not only when we first attach, but also when the - user types "run" after having attached. */ -void -eb_start (inferior_args) -char *inferior_args; -{ - /* OK, now read in the file. Y=read, C=COFF, D=no symbols - 0=start address, %s=filename. */ - - fprintf (eb_stream, "YC D,0:%s", prog_name); - - if (inferior_args != NULL) - fprintf(eb_stream, " %s", inferior_args); - - fprintf (eb_stream, "\n"); - fflush (eb_stream); - - expect_prompt (); - - need_gi = 1; -} - -/* Translate baud rates from integers to damn B_codes. Unix should - have outgrown this crap years ago, but even POSIX wouldn't buck it. */ - -#ifndef B19200 -#define B19200 EXTA -#endif -#ifndef B38400 -#define B38400 EXTB -#endif - -struct {int rate, damn_b;} baudtab[] = { - {0, B0}, - {50, B50}, - {75, B75}, - {110, B110}, - {134, B134}, - {150, B150}, - {200, B200}, - {300, B300}, - {600, B600}, - {1200, B1200}, - {1800, B1800}, - {2400, B2400}, - {4800, B4800}, - {9600, B9600}, - {19200, B19200}, - {38400, B38400}, - {-1, -1}, -}; - -int damn_b (rate) - int rate; -{ - int i; - - for (i = 0; baudtab[i].rate != -1; i++) - if (rate == baudtab[i].rate) return baudtab[i].damn_b; - return B38400; /* Random */ -} - - -/* Open a connection to a remote debugger. - NAME is the filename used for communication, then a space, - then the name of the program as we should name it to EBMON. */ - -static int baudrate = 9600; -static char *dev_name; -void -eb_open (name, from_tty) - char *name; - int from_tty; -{ - TERMINAL sg; - - char *p; - - target_preopen (from_tty); - - /* Find the first whitespace character, it separates dev_name from - prog_name. */ - if (name == 0) - goto erroid; - - for (p = name; - *p != '\0' && !isspace (*p); p++) - ; - if (*p == '\0') -erroid: - error ("\ -Please include the name of the device for the serial port,\n\ -the baud rate, and the name of the program to run on the remote system."); - dev_name = alloca (p - name + 1); - strncpy (dev_name, name, p - name); - dev_name[p - name] = '\0'; - - /* Skip over the whitespace after dev_name */ - for (; isspace (*p); p++) - /*EMPTY*/; - - if (1 != sscanf (p, "%d ", &baudrate)) - goto erroid; - - /* Skip the number and then the spaces */ - for (; isdigit (*p); p++) - /*EMPTY*/; - for (; isspace (*p); p++) - /*EMPTY*/; - - if (prog_name != NULL) - free (prog_name); - prog_name = savestring (p, strlen (p)); - - eb_close (0); - - eb_desc = open (dev_name, O_RDWR); - if (eb_desc < 0) - perror_with_name (dev_name); - ioctl (eb_desc, TIOCGETP, &sg); -#ifdef HAVE_TERMIO - sg.c_cc[VMIN] = 0; /* read with timeout. */ - sg.c_cc[VTIME] = timeout * 10; - sg.c_lflag &= ~(ICANON | ECHO); - sg.c_cflag = (sg.c_cflag & ~CBAUD) | damn_b (baudrate); -#else - sg.sg_ispeed = damn_b (baudrate); - sg.sg_ospeed = damn_b (baudrate); - sg.sg_flags |= RAW | ANYP; - sg.sg_flags &= ~ECHO; -#endif - - ioctl (eb_desc, TIOCSETP, &sg); - eb_stream = fdopen (eb_desc, "r+"); - - push_target (&eb_ops); - if (from_tty) - printf ("Remote %s debugging %s using %s\n", target_shortname, - prog_name, dev_name); - -#ifndef HAVE_TERMIO -#ifndef NO_SIGINTERRUPT - /* Cause SIGALRM's to make reads fail with EINTR instead of resuming - the read. */ - if (siginterrupt (SIGALRM, 1) != 0) - perror ("eb_open: error in siginterrupt"); -#endif - - /* Set up read timeout timer. */ - if ((void (*)) signal (SIGALRM, eb_timer) == (void (*)) -1) - perror ("eb_open: error in signal"); -#endif - -#if defined (LOG_FILE) - log_file = fopen (LOG_FILE, "w"); - if (log_file == NULL) - perror_with_name (LOG_FILE); -#endif - - /* Hello? Are you there? */ - write (eb_desc, "\n", 1); - - expect_prompt (); -} - -/* Close out all files and local state before this target loses control. */ - -static void -eb_close (quitting) - int quitting; -{ - - /* Due to a bug in Unix, fclose closes not only the stdio stream, - but also the file descriptor. So we don't actually close - eb_desc. */ - if (eb_stream) - fclose (eb_stream); /* This also closes eb_desc */ - if (eb_desc >= 0) - /* close (eb_desc); */ - - /* Do not try to close eb_desc again, later in the program. */ - eb_stream = NULL; - eb_desc = -1; - -#if defined (LOG_FILE) - if (ferror (log_file)) - printf ("Error writing log file.\n"); - if (fclose (log_file) != 0) - printf ("Error closing log file.\n"); -#endif -} - -/* Terminate the open connection to the remote debugger. - Use this when you want to detach and do something else - with your gdb. */ -void -eb_detach (from_tty) - int from_tty; -{ - pop_target(); /* calls eb_close to do the real work */ - if (from_tty) - printf ("Ending remote %s debugging\n", target_shortname); -} - -/* Tell the remote machine to resume. */ - -void -eb_resume (step, sig) - int step, sig; -{ - if (step) - { - write (eb_desc, "t 1,s\n", 6); - /* Wait for the echo. */ - expect ("t 1,s\r"); - /* Then comes a line containing the instruction we stepped to. */ - expect ("\n@"); - /* Then we get the prompt. */ - expect_prompt (); - - /* Force the next eb_wait to return a trap. Not doing anything - about I/O from the target means that the user has to type - "continue" to see any. This should be fixed. */ - need_artificial_trap = 1; - } - else - { - if (need_gi) - { - need_gi = 0; - write (eb_desc, "gi\n", 3); - - /* Swallow the echo of "gi". */ - expect ("gi\r"); - } - else - { - write (eb_desc, "GR\n", 3); - /* Swallow the echo. */ - expect ("GR\r"); - } - } -} - -/* Wait until the remote machine stops, then return, - storing status in STATUS just as `wait' would. */ - -int -eb_wait (status) - WAITTYPE *status; -{ - /* Strings to look for. '?' means match any single character. - Note that with the algorithm we use, the initial character - of the string cannot recur in the string, or we will not - find some cases of the string in the input. */ - - static char bpt[] = "Invalid interrupt taken - #0x50 - "; - /* It would be tempting to look for "\n[__exit + 0x8]\n" - but that requires loading symbols with "yc i" and even if - we did do that we don't know that the file has symbols. */ - static char exitmsg[] = "\n@????????I JMPTI GR121,LR0"; - char *bp = bpt; - char *ep = exitmsg; - - /* Large enough for either sizeof (bpt) or sizeof (exitmsg) chars. */ - char swallowed[50]; - /* Current position in swallowed. */ - char *swallowed_p = swallowed; - - int ch; - int ch_handled; - - int old_timeout = timeout; - - WSETEXIT ((*status), 0); - - if (need_artificial_trap != 0) - { - WSETSTOP ((*status), SIGTRAP); - need_artificial_trap--; - return 0; - } - - timeout = 0; /* Don't time out -- user program is running. */ - while (1) - { - ch_handled = 0; - ch = readchar (); - if (ch == *bp) - { - bp++; - if (*bp == '\0') - break; - ch_handled = 1; - - *swallowed_p++ = ch; - } - else - bp = bpt; - - if (ch == *ep || *ep == '?') - { - ep++; - if (*ep == '\0') - break; - - if (!ch_handled) - *swallowed_p++ = ch; - ch_handled = 1; - } - else - ep = exitmsg; - - if (!ch_handled) - { - char *p; - - /* Print out any characters which have been swallowed. */ - for (p = swallowed; p < swallowed_p; ++p) - putc (*p, stdout); - swallowed_p = swallowed; - - putc (ch, stdout); - } - } - expect_prompt (); - if (*bp== '\0') - WSETSTOP ((*status), SIGTRAP); - else - WSETEXIT ((*status), 0); - timeout = old_timeout; - - return 0; -} - -/* Return the name of register number REGNO - in the form input and output by EBMON. - - Returns a pointer to a static buffer containing the answer. */ -static char * -get_reg_name (regno) - int regno; -{ - static char buf[80]; - if (regno >= GR96_REGNUM && regno < GR96_REGNUM + 32) - sprintf (buf, "GR%03d", regno - GR96_REGNUM + 96); - else if (regno >= LR0_REGNUM && regno < LR0_REGNUM + 128) - sprintf (buf, "LR%03d", regno - LR0_REGNUM); - else if (regno == Q_REGNUM) - strcpy (buf, "SR131"); - else if (regno >= BP_REGNUM && regno <= CR_REGNUM) - sprintf (buf, "SR%03d", regno - BP_REGNUM + 133); - else if (regno == ALU_REGNUM) - strcpy (buf, "SR132"); - else if (regno >= IPC_REGNUM && regno <= IPB_REGNUM) - sprintf (buf, "SR%03d", regno - IPC_REGNUM + 128); - else if (regno >= VAB_REGNUM && regno <= LRU_REGNUM) - sprintf (buf, "SR%03d", regno - VAB_REGNUM); - else if (regno == GR1_REGNUM) - strcpy (buf, "GR001"); - return buf; -} - -/* Read the remote registers into the block REGS. */ - -static void -eb_fetch_registers () -{ - int reg_index; - int regnum_index; - char tempbuf[10]; - int i; - -#if 0 - /* This should not be necessary, because one is supposed to read the - registers only when the inferior is stopped (at least with - ptrace() and why not make it the same for remote?). */ - /* ^A is the "normal character" used to make sure we are talking to EBMON - and not to the program being debugged. */ - write (eb_desc, "\001\n"); - expect_prompt (); -#endif - - write (eb_desc, "dw gr96,gr127\n", 14); - for (reg_index = 96, regnum_index = GR96_REGNUM; - reg_index < 128; - reg_index += 4, regnum_index += 4) - { - sprintf (tempbuf, "GR%03d ", reg_index); - expect (tempbuf); - get_hex_regs (4, regnum_index); - expect ("\n"); - } - - for (i = 0; i < 128; i += 32) - { - /* The PC has a tendency to hang if we get these - all in one fell swoop ("dw lr0,lr127"). */ - sprintf (tempbuf, "dw lr%d\n", i); - write (eb_desc, tempbuf, strlen (tempbuf)); - for (reg_index = i, regnum_index = LR0_REGNUM + i; - reg_index < i + 32; - reg_index += 4, regnum_index += 4) - { - sprintf (tempbuf, "LR%03d ", reg_index); - expect (tempbuf); - get_hex_regs (4, regnum_index); - expect ("\n"); - } - } - - write (eb_desc, "dw sr133,sr133\n", 15); - expect ("SR133 "); - get_hex_regs (1, BP_REGNUM); - expect ("\n"); - - write (eb_desc, "dw sr134,sr134\n", 15); - expect ("SR134 "); - get_hex_regs (1, FC_REGNUM); - expect ("\n"); - - write (eb_desc, "dw sr135,sr135\n", 15); - expect ("SR135 "); - get_hex_regs (1, CR_REGNUM); - expect ("\n"); - - write (eb_desc, "dw sr131,sr131\n", 15); - expect ("SR131 "); - get_hex_regs (1, Q_REGNUM); - expect ("\n"); - - write (eb_desc, "dw sr0,sr14\n", 12); - for (reg_index = 0, regnum_index = VAB_REGNUM; - regnum_index <= LRU_REGNUM; - regnum_index += 4, reg_index += 4) - { - sprintf (tempbuf, "SR%03d ", reg_index); - expect (tempbuf); - get_hex_regs (reg_index == 12 ? 3 : 4, regnum_index); - expect ("\n"); - } - - /* There doesn't seem to be any way to get these. */ - { - int val = -1; - supply_register (FPE_REGNUM, &val); - supply_register (INT_REGNUM, &val); - supply_register (FPS_REGNUM, &val); - supply_register (EXO_REGNUM, &val); - } - - write (eb_desc, "dw gr1,gr1\n", 11); - expect ("GR001 "); - get_hex_regs (1, GR1_REGNUM); - expect_prompt (); -} - -/* Fetch register REGNO, or all registers if REGNO is -1. - Returns errno value. */ -void -eb_fetch_register (regno) - int regno; -{ - if (regno == -1) - eb_fetch_registers (); - else - { - char *name = get_reg_name (regno); - fprintf (eb_stream, "dw %s,%s\n", name, name); - expect (name); - expect (" "); - get_hex_regs (1, regno); - expect_prompt (); - } - return; -} - -/* Store the remote registers from the contents of the block REGS. */ - -static void -eb_store_registers () -{ - int i, j; - fprintf (eb_stream, "s gr1,%x\n", read_register (GR1_REGNUM)); - expect_prompt (); - - for (j = 0; j < 32; j += 16) - { - fprintf (eb_stream, "s gr%d,", j + 96); - for (i = 0; i < 15; ++i) - fprintf (eb_stream, "%x,", read_register (GR96_REGNUM + j + i)); - fprintf (eb_stream, "%x\n", read_register (GR96_REGNUM + j + 15)); - expect_prompt (); - } - - for (j = 0; j < 128; j += 16) - { - fprintf (eb_stream, "s lr%d,", j); - for (i = 0; i < 15; ++i) - fprintf (eb_stream, "%x,", read_register (LR0_REGNUM + j + i)); - fprintf (eb_stream, "%x\n", read_register (LR0_REGNUM + j + 15)); - expect_prompt (); - } - - fprintf (eb_stream, "s sr133,%x,%x,%x\n", read_register (BP_REGNUM), - read_register (FC_REGNUM), read_register (CR_REGNUM)); - expect_prompt (); - fprintf (eb_stream, "s sr131,%x\n", read_register (Q_REGNUM)); - expect_prompt (); - fprintf (eb_stream, "s sr0,"); - for (i = 0; i < 11; ++i) - fprintf (eb_stream, "%x,", read_register (VAB_REGNUM + i)); - fprintf (eb_stream, "%x\n", read_register (VAB_REGNUM + 11)); - expect_prompt (); -} - -/* Store register REGNO, or all if REGNO == 0. - Return errno value. */ -int -eb_store_register (regno) - int regno; -{ - if (regno == -1) - eb_store_registers (); - else - { - char *name = get_reg_name (regno); - fprintf (eb_stream, "s %s,%x\n", name, read_register (regno)); - /* Setting GR1 changes the numbers of all the locals, so - invalidate the register cache. Do this *after* calling - read_register, because we want read_register to return the - value that write_register has just stuffed into the registers - array, not the value of the register fetched from the - inferior. */ - if (regno == GR1_REGNUM) - registers_changed (); - expect_prompt (); - } - return 0; -} - -/* Get ready to modify the registers array. On machines which store - individual registers, this doesn't need to do anything. On machines - which store all the registers in one fell swoop, this makes sure - that registers contains all the registers from the program being - debugged. */ - -void -eb_prepare_to_store () -{ - /* Do nothing, since we can store individual regs */ -} - -/* FIXME! Merge these two. */ -int -eb_xfer_inferior_memory (memaddr, myaddr, len, write, target) - CORE_ADDR memaddr; - char *myaddr; - int len; - int write; - struct target_ops *target; /* ignored */ -{ - if (write) - return eb_write_inferior_memory (memaddr, myaddr, len); - else - return eb_write_inferior_memory (memaddr, myaddr, len); -} - -void -eb_files_info () -{ - printf ("\tAttached to %s at %d baud and running program %s.\n", - dev_name, baudrate, prog_name); -} - -/* Copy LEN bytes of data from debugger memory at MYADDR - to inferior's memory at MEMADDR. Returns errno value. */ -int -eb_write_inferior_memory (memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - int i; - - for (i = 0; i < len; i++) - { - if ((i % 16) == 0) - fprintf (eb_stream, "sb %x,", memaddr + i); - if ((i % 16) == 15 || i == len - 1) - { - fprintf (eb_stream, "%x\n", ((unsigned char *)myaddr)[i]); - expect_prompt (); - } - else - fprintf (eb_stream, "%x,", ((unsigned char *)myaddr)[i]); - } - return 0; -} - -/* Read LEN bytes from inferior memory at MEMADDR. Put the result - at debugger address MYADDR. Returns errno value. */ -int -eb_read_inferior_memory(memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - int i; - - /* Number of bytes read so far. */ - int count; - - /* Starting address of this pass. */ - unsigned long startaddr; - - /* Number of bytes to read in this pass. */ - int len_this_pass; - - /* Note that this code works correctly if startaddr is just less - than UINT_MAX (well, really CORE_ADDR_MAX if there was such a - thing). That is, something like - eb_read_bytes (CORE_ADDR_MAX - 4, foo, 4) - works--it never adds len to memaddr and gets 0. */ - /* However, something like - eb_read_bytes (CORE_ADDR_MAX - 3, foo, 4) - doesn't need to work. Detect it and give up if there's an attempt - to do that. */ - if (((memaddr - 1) + len) < memaddr) - return EIO; - - startaddr = memaddr; - count = 0; - while (count < len) - { - len_this_pass = 16; - if ((startaddr % 16) != 0) - len_this_pass -= startaddr % 16; - if (len_this_pass > (len - count)) - len_this_pass = (len - count); - - fprintf (eb_stream, "db %x,%x\n", startaddr, - (startaddr - 1) + len_this_pass); - expect ("\n"); - - /* Look for 8 hex digits. */ - i = 0; - while (1) - { - if (isxdigit (readchar ())) - ++i; - else - { - expect_prompt (); - error ("Hex digit expected from remote system."); - } - if (i >= 8) - break; - } - - expect (" "); - - for (i = 0; i < len_this_pass; i++) - get_hex_byte (&myaddr[count++]); - - expect_prompt (); - - startaddr += len_this_pass; - } - return 0; -} - -/* Define the target subroutine names */ - -struct target_ops eb_ops = { - "amd-eb", "Remote serial AMD EBMON target", - "Use a remote computer running EBMON connected by a serial line.\n\ -Arguments are the name of the device for the serial line,\n\ -the speed to connect at in bits per second, and the filename of the\n\ -executable as it exists on the remote computer. For example,\n\ - target amd-eb /dev/ttya 9600 demo", - eb_open, eb_close, - 0, eb_detach, eb_resume, eb_wait, - eb_fetch_register, eb_store_register, - eb_prepare_to_store, 0, 0, /* conv_to, conv_from */ - eb_xfer_inferior_memory, eb_files_info, - 0, 0, /* Breakpoints */ - 0, 0, 0, 0, 0, /* Terminal handling */ - 0, /* FIXME, kill */ - 0, /* load */ - call_function_by_hand, - 0, /* lookup_symbol */ - 0, /* create_inferior FIXME, eb_start here or something? */ - 0, /* mourn_inferior FIXME */ - process_stratum, 0, /* next */ - 1, 1, 1, 1, 1, /* all mem, mem, stack, regs, exec */ - 0, 0, /* Section pointers */ - OPS_MAGIC, /* Always the last thing */ -}; - -void -_initialize_remote_eb () -{ - add_target (&eb_ops); -} diff --git a/gdb/remote-mm.c b/gdb/remote-mm.c deleted file mode 100644 index d8984024356..00000000000 --- a/gdb/remote-mm.c +++ /dev/null @@ -1,1706 +0,0 @@ -/* Remote debugging interface for Am290*0 running MiniMON monitor, for GDB. - Copyright (C) 1990, 1991 Free Software Foundation, Inc. - Originally written by Daniel Mann at AMD. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* This is like remote.c but ecpects MiniMON to be running on the Am29000 - target hardware. - - David Wood (wood@lab.ultra.nyu.edu) at New York University adapted this - file to gdb 3.95. I was unable to get this working on sun3os4 - with termio, only with sgtty. Because we are only attempting to - use this module to debug our kernel, which is already loaded when - gdb is started up, I did not code up the file downloading facilities. - As a result this module has only the stubs to download files. - You should get tagged at compile time if you need to make any - changes/additions. */ - -#include -#include "defs.h" -#include "inferior.h" -#include "wait.h" -#include "value.h" -#include -#include -#include -#include -#include -#include "terminal.h" -#include "minimon.h" -#include "target.h" - -/* Offset of member MEMBER in a struct of type TYPE. */ -#define offsetof(TYPE, MEMBER) ((int) &((TYPE *)0)->MEMBER) - -/* #define DEBUG 1 /* */ -#ifdef DEBUG -# define DENTER(NAME) (printf("Entering %s\n",NAME), fflush(stdout)) -# define DEXIT(NAME) (printf("Exiting %s\n",NAME), fflush(stdout)) -#else -# define DENTER(NAME) -# define DEXIT(NAME) -#endif - -#define DRAIN_INPUT() (msg_recv_serial((union msg_t*)0)) - -extern int stop_soon_quietly; /* for wait_for_inferior */ - -extern struct value *call_function_by_hand(); - -static void mm_resume(); -static void mm_fetch_registers (); -static int fetch_register (); -static int mm_store_registers (); -static int store_register (); -static int regnum_to_srnum(); -static void mm_close (); -static char* msg_str(); -static char* error_msg_str(); -static int expect_msg(); -static void init_target_mm(); -static int mm_memory_space(); - -/* - * Processor types. - */ -#define TYPE_UNKNOWN 0 -#define TYPE_A29000 1 -#define TYPE_A29030 2 -#define TYPE_A29050 3 -static char *processor_name[] = { "Unknown", "A29000", "A29030", "A29050" }; -static int processor_type=TYPE_UNKNOWN; -#define FREEZE_MODE (read_register(CPS_REGNUM) && 0x400) -#define USE_SHADOW_PC ((processor_type == TYPE_A29050) && FREEZE_MODE) - -#define LLOG_FILE "minimon.log" -#if defined (LOG_FILE) -FILE *log_file; -#endif - -/* - * Size of message buffers. I couldn't get memory reads to work when - * the byte_count was larger than 512 (it may be a baud rate problem). - */ -#define BUFER_SIZE 512 -/* - * Size of data area in message buffer on the TARGET (remote system). - */ -#define MAXDATA_T (target_config.max_msg_size - \ - offsetof(struct write_r_msg_t,data[0])) -/* - * Size of data area in message buffer on the HOST (gdb). - */ -#define MAXDATA_H (BUFER_SIZE - offsetof(struct write_r_msg_t,data[0])) -/* - * Defined as the minimum size of data areas of the two message buffers - */ -#define MAXDATA (MAXDATA_H < MAXDATA_T ? MAXDATA_H : MAXDATA_T) - -static char out_buf[BUFER_SIZE]; -static char in_buf[BUFER_SIZE]; - -int msg_recv_serial(); -int msg_send_serial(); - -#define MAX_RETRIES 5000 -extern struct target_ops mm_ops; /* Forward declaration */ -struct config_msg_t target_config; /* HIF needs this */ -union msg_t *out_msg_buf = (union msg_t*)out_buf; -union msg_t *in_msg_buf = (union msg_t*)in_buf; - -static int timeout = 5; - -/* Descriptor for I/O to remote machine. Initialize it to -1 so that - mm_open knows that we don't have a file open when the program - starts. */ -int mm_desc = -1; - -/* stream which is fdopen'd from mm_desc. Only valid when - mm_desc != -1. */ -FILE *mm_stream; - -/* Called when SIGALRM signal sent due to alarm() timeout. */ -#ifndef HAVE_TERMIO - -#ifndef __STDC__ -# ifndef volatile -# define volatile /**/ -# endif -#endif -volatile int n_alarms; - -static void -mm_timer () -{ -#if 0 - if (kiodebug) - printf ("mm_timer called\n"); -#endif - n_alarms++; -} -#endif /* HAVE_TERMIO */ - -/* malloc'd name of the program on the remote system. */ -static char *prog_name = NULL; - - -/* Number of SIGTRAPs we need to simulate. That is, the next - NEED_ARTIFICIAL_TRAP calls to mm_wait should just return - SIGTRAP without actually waiting for anything. */ - -/**************************************************** REMOTE_CREATE_INFERIOR */ -/* This is called not only when we first attach, but also when the - user types "run" after having attached. */ -static void -mm_create_inferior (execfile, args, env) - char *execfile; - char *args; - char **env; -{ -#define MAX_TOKENS 25 -#define BUFFER_SIZE 256 - int token_count; - int result; - char *token[MAX_TOKENS]; - char cmd_line[BUFFER_SIZE]; - - DENTER("mm_create_inferior()"); - - if (args && *args) - error ("Can't pass arguments to remote mm process (yet)."); - - if (execfile == 0 /* || exec_bfd == 0 */ ) - error ("No exec file specified"); - - if (!mm_stream) { - printf("Minimon not open yet.\n"); - return; - } - - /* On ultra3 (NYU) we assume the kernel is already running so there is - no file to download. - FIXME: Fixed required here -> load your program, possibly with mm_load(). - */ - printf_filtered ("\n\ -Assuming you are at NYU debuging a kernel, i.e., no need to download.\n\n"); - - /* We will get a task spawn event immediately. */ -#ifdef NOTDEF /* start_remote() now does a wait without a resume - so don't use it*/ - start_remote (); -#else - init_wait_for_inferior (); - clear_proceed_status (); - stop_soon_quietly = 1; - proceed(-1,-1,0); - normal_stop (); -#endif - DEXIT("mm_create_inferior()"); -} -/**************************************************** REMOTE_MOURN_INFERIOR */ -static void -mm_mourn() -{ - DENTER("mm_mourn()"); - pop_target (); /* Pop back to no-child state */ - generic_mourn_inferior (); - DEXIT("mm_mourn()"); -} - -/********************************************************************** damn_b -*/ -/* Translate baud rates from integers to damn B_codes. Unix should - have outgrown this crap years ago, but even POSIX wouldn't buck it. */ - -#ifndef B19200 -#define B19200 EXTA -#endif -#ifndef B38400 -#define B38400 EXTB -#endif - -static struct {int rate, damn_b;} baudtab[] = { - {0, B0}, - {50, B50}, - {75, B75}, - {110, B110}, - {134, B134}, - {150, B150}, - {200, B200}, - {300, B300}, - {600, B600}, - {1200, B1200}, - {1800, B1800}, - {2400, B2400}, - {4800, B4800}, - {9600, B9600}, - {19200, B19200}, - {38400, B38400}, - {-1, -1}, -}; - -static int damn_b (rate) - int rate; -{ - int i; - - for (i = 0; baudtab[i].rate != -1; i++) - if (rate == baudtab[i].rate) return baudtab[i].damn_b; - return B38400; /* Random */ -} - - -/***************************************************************** REMOTE_OPEN -** Open a connection to remote minimon. - NAME is the filename used for communication, then a space, - then the baud rate. - 'target adapt /dev/ttya 9600 [prognam]' for example. - */ - -static char *dev_name; -int baudrate = 9600; -static void -mm_open (name, from_tty) - char *name; - int from_tty; -{ - TERMINAL sg; - unsigned int prl; - char *p; - - DENTER("mm_open()"); - - /* Find the first whitespace character, it separates dev_name from - prog_name. */ - for (p = name; - p && *p && !isspace (*p); p++) - ; - if (p == 0 || *p == '\0') -erroid: - error ("Usage : [progname]"); - dev_name = (char*)malloc (p - name + 1); - strncpy (dev_name, name, p - name); - dev_name[p - name] = '\0'; - - /* Skip over the whitespace after dev_name */ - for (; isspace (*p); p++) - /*EMPTY*/; - - if (1 != sscanf (p, "%d ", &baudrate)) - goto erroid; - - /* Skip the number and then the spaces */ - for (; isdigit (*p); p++) - /*EMPTY*/; - for (; isspace (*p); p++) - /*EMPTY*/; - - if (prog_name != NULL) - free (prog_name); - prog_name = savestring (p, strlen (p)); - - - if (mm_desc >= 0) - close (mm_desc); - - mm_desc = open (dev_name, O_RDWR); - if (mm_desc < 0) - perror_with_name (dev_name); - ioctl (mm_desc, TIOCGETP, &sg); -#ifdef HAVE_TERMIO - sg.c_cc[VMIN] = 0; /* read with timeout. */ - sg.c_cc[VTIME] = timeout * 10; - sg.c_lflag &= ~(ICANON | ECHO); - sg.c_cflag = (sg.c_cflag & ~CBAUD) | damn_b (baudrate); -#else - sg.sg_ispeed = damn_b (baudrate); - sg.sg_ospeed = damn_b (baudrate); - sg.sg_flags |= RAW; - sg.sg_flags |= ANYP; - sg.sg_flags &= ~ECHO; -#endif - - - ioctl (mm_desc, TIOCSETP, &sg); - mm_stream = fdopen (mm_desc, "r+"); - - push_target (&mm_ops); - -#ifndef HAVE_TERMIO -#ifndef NO_SIGINTERRUPT - /* Cause SIGALRM's to make reads fail with EINTR instead of resuming - the read. */ - if (siginterrupt (SIGALRM, 1) != 0) - perror ("mm_open: error in siginterrupt"); -#endif - - /* Set up read timeout timer. */ - if ((void (*)) signal (SIGALRM, mm_timer) == (void (*)) -1) - perror ("mm_open: error in signal"); -#endif - -#if defined (LOG_FILE) - log_file = fopen (LOG_FILE, "w"); - if (log_file == NULL) - perror_with_name (LOG_FILE); -#endif - /* - ** Initialize target configuration structure (global) - */ - DRAIN_INPUT(); - out_msg_buf->config_req_msg.code = CONFIG_REQ; - out_msg_buf->config_req_msg.length = 4*0; - msg_send_serial(out_msg_buf); /* send config request message */ - - expect_msg(CONFIG,in_msg_buf,1); - - /* Determine the processor revision level */ - /* FIXME: this code is the same as in remote-adapt.c */ - prl = (unsigned int)read_register(CFG_REGNUM) >> 24; - if (prl == 0x03) { - processor_type = TYPE_A29000; - } else if ((prl&0xf0) == 0x40) { /* 29030 = 0x4* */ - processor_type = TYPE_A29030; - fprintf_filtered(stderr,"WARNING: debugging of A29030 not tested.\n"); - } else if ((prl&0xf0) == 0x20) { /* 29050 = 0x2* */ - processor_type = TYPE_A29050; - fprintf_filtered(stderr,"WARNING: debugging of A29050 not tested.\n"); - } else { - processor_type = TYPE_UNKNOWN; - fprintf_filtered(stderr,"WARNING: processor type unknown.\n"); - } - - /* Print out some stuff, letting the user now what's going on */ - printf_filtered("Remote debugging on an %s connect to MiniMon via %s.\n", - processor_name[processor_type],dev_name); - /* FIXME: can this restriction be removed? */ - printf_filtered("Remote debugging using virtual addresses works only\n"); - printf_filtered("\twhen virtual addresses map 1:1 to physical addresses.\n") -; - if (processor_type != TYPE_A29050) { - fprintf_filtered(stderr, - "Freeze-mode debugging not available, and can only be done on an A29050.\n"); - } - - target_config.code = CONFIG; - target_config.length = 0; - target_config.processor_id = in_msg_buf->config_msg.processor_id; - target_config.version = in_msg_buf->config_msg.version; - target_config.I_mem_start = in_msg_buf->config_msg.I_mem_start; - target_config.I_mem_size = in_msg_buf->config_msg.I_mem_size; - target_config.D_mem_start = in_msg_buf->config_msg.D_mem_start; - target_config.D_mem_size = in_msg_buf->config_msg.D_mem_size; - target_config.ROM_start = in_msg_buf->config_msg.ROM_start; - target_config.ROM_size = in_msg_buf->config_msg.ROM_size; - target_config.max_msg_size = in_msg_buf->config_msg.max_msg_size; - target_config.max_bkpts = in_msg_buf->config_msg.max_bkpts; - target_config.coprocessor = in_msg_buf->config_msg.coprocessor; - target_config.reserved = in_msg_buf->config_msg.reserved; - if (from_tty) { - printf("Connected to MiniMON :\n"); - printf(" Debugcore version %d.%d\n", - 0x0f & (target_config.version >> 4), - 0x0f & (target_config.version ) ); - printf(" Configuration version %d.%d\n", - 0x0f & (target_config.version >> 12), - 0x0f & (target_config.version >> 8) ); - printf(" Message system version %d.%d\n", - 0x0f & (target_config.version >> 20), - 0x0f & (target_config.version >> 16) ); - printf(" Communication driver version %d.%d\n", - 0x0f & (target_config.version >> 28), - 0x0f & (target_config.version >> 24) ); - } - - /* Leave the target running... - * The above message stopped the target in the dbg core (MiniMon), - * so restart the target out of MiniMon, - */ - out_msg_buf->go_msg.code = GO; - out_msg_buf->go_msg.length = 0; - msg_send_serial(out_msg_buf); - /* No message to expect after a GO */ - - DEXIT("mm_open()"); -} - -/**************************************************************** REMOTE_CLOSE -** Close the open connection to the minimon debugger. - Use this when you want to detach and do something else - with your gdb. */ -static void -mm_close (quitting) /*FIXME: how is quitting used */ - int quitting; -{ - DENTER("mm_close()"); - - if (mm_desc < 0) - error ("Can't close remote connection: not debugging remotely."); - - /* We should never get here if there isn't something valid in - mm_desc and mm_stream. - - Due to a bug in Unix, fclose closes not only the stdio stream, - but also the file descriptor. So we don't actually close - mm_desc. */ - DRAIN_INPUT(); - fclose (mm_stream); - /* close (mm_desc); */ - - /* Do not try to close mm_desc again, later in the program. */ - mm_stream = NULL; - mm_desc = -1; - -#if defined (LOG_FILE) - if (ferror (log_file)) - printf ("Error writing log file.\n"); - if (fclose (log_file) != 0) - printf ("Error closing log file.\n"); -#endif - - printf ("Ending remote debugging\n"); - - DEXIT("mm_close()"); - -} - -/************************************************************* REMOTE_ATACH */ -/* Attach to a program that is already loaded and running - * Upon exiting the process's execution is stopped. - */ -static void -mm_attach (args, from_tty) - char *args; - int from_tty; -{ - - DENTER("mm_attach()"); - - if (!mm_stream) - printf ("MiniMon not opened yet, use the 'target minimon' command.\n"); - - dont_repeat(); - - if (from_tty) - printf ("Attaching to remote program %s...\n", prog_name); - - - /* Make sure the target is currently running, it is supposed to be. */ - /* FIXME: is it ok to send MiniMon a BREAK if it is already stopped in - * the dbg core. If so, we don't need to send this GO. - */ - out_msg_buf->go_msg.code = GO; - out_msg_buf->go_msg.length = 0; - msg_send_serial(out_msg_buf); - sleep(2); /* At the worst it will stop, receive a message, continue */ - - /* Send the mm a break. */ - out_msg_buf->break_msg.code = BREAK; - out_msg_buf->break_msg.length = 0; - msg_send_serial(out_msg_buf); - - mark_breakpoints_out (); - init_wait_for_inferior (); - clear_proceed_status (); - stop_soon_quietly = 1; - wait_for_inferior (); - stop_soon_quietly = 0; - normal_stop (); - - DEXIT("mm_attach()"); -} -/********************************************************** REMOTE_DETACH */ -/* Terminate the open connection to the remote debugger. - Use this when you want to detach and do something else - with your gdb. Leave remote process running (with no breakpoints set). */ -static void -mm_detach (args,from_tty) - char *args; - int from_tty; -{ - DENTER("mm_dettach()"); - remove_breakpoints(); /* Just in case there were any left in */ - out_msg_buf->go_msg.code = GO; - out_msg_buf->go_msg.length = 0; - msg_send_serial(out_msg_buf); - pop_target(); /* calls mm_close to do the real work */ - DEXIT("mm_dettach()"); -} - - -/*************************************************************** REMOTE_RESUME -** Tell the remote machine to resume. */ - -static void -mm_resume (step, sig) - int step, sig; -{ - DENTER("mm_resume()"); - - if (sig) - error ("Can't send signals to a remote MiniMon system."); - - if (step) { - out_msg_buf->step_msg.code= STEP; - out_msg_buf->step_msg.length = 1*4; - out_msg_buf->step_msg.count = 1; /* step 1 instruction */ - msg_send_serial(out_msg_buf); - } else { - out_msg_buf->go_msg.code= GO; - out_msg_buf->go_msg.length = 0; - msg_send_serial(out_msg_buf); - } - - DEXIT("mm_resume()"); -} - -/***************************************************************** REMOTE_WAIT -** Wait until the remote machine stops, then return, - storing status in STATUS just as `wait' would. */ - -static int -mm_wait (status) - WAITTYPE *status; -{ - int i, result; - int old_timeout = timeout; - int old_immediate_quit = immediate_quit; - - DENTER("mm_wait()"); - WSETEXIT ((*status), 0); - - -/* wait for message to arrive. It should be: - - A HIF service request. - - A HIF exit service request. - - A CHANNEL0_ACK. - - A CHANNEL1 request. - - a debugcore HALT message. - HIF services must be responded too, and while-looping continued. - If the target stops executing, mm_wait() should return. -*/ - timeout = 0; /* Wait indefinetly for a message */ - immediate_quit = 1; /* Helps ability to QUIT */ - while(1) - { - while(msg_recv_serial(in_msg_buf)) { - QUIT; /* Let user quit if they want */ - } - switch (in_msg_buf->halt_msg.code) - { - case HIF_CALL: - i = in_msg_buf->hif_call_rtn_msg.service_number; - result=service_HIF(in_msg_buf); - if(i == 1) /* EXIT */ - goto exit; - if(result) - printf("Warning: failure during HIF service %d\n", i); - break; - case CHANNEL0_ACK: - service_HIF(in_msg_buf); - break; - case CHANNEL1: - i=in_msg_buf->channel1_msg.length; - in_msg_buf->channel1_msg.data[i] = '\0'; - printf("%s", in_msg_buf->channel1_msg.data); - fflush(stdout); - /* Send CHANNEL1_ACK message */ - out_msg_buf->channel1_ack_msg.code = CHANNEL1_ACK; - out_msg_buf->channel1_ack_msg.length = 0; - result = msg_send_serial(out_msg_buf); - break; - case HALT: - goto halted; - default: - goto halted; - } - } -halted: - /* FIXME, these printfs should not be here. This is a source level - debugger, guys! */ - if (in_msg_buf->halt_msg.trap_number== 0) - { printf("Am290*0 received vector number %d (break point)\n", - in_msg_buf->halt_msg.trap_number); - WSETSTOP ((*status), SIGTRAP); - } - else if (in_msg_buf->halt_msg.trap_number== 1) - { printf("Am290*0 received vector number %d\n", - in_msg_buf->halt_msg.trap_number); - WSETSTOP ((*status), SIGBUS); - } - else if (in_msg_buf->halt_msg.trap_number== 3 - || in_msg_buf->halt_msg.trap_number== 4) - { printf("Am290*0 received vector number %d\n", - in_msg_buf->halt_msg.trap_number); - WSETSTOP ((*status), SIGFPE); - } - else if (in_msg_buf->halt_msg.trap_number== 5) - { printf("Am290*0 received vector number %d\n", - in_msg_buf->halt_msg.trap_number); - WSETSTOP ((*status), SIGILL); - } - else if (in_msg_buf->halt_msg.trap_number >= 6 - && in_msg_buf->halt_msg.trap_number <= 11) - { printf("Am290*0 received vector number %d\n", - in_msg_buf->halt_msg.trap_number); - WSETSTOP ((*status), SIGSEGV); - } - else if (in_msg_buf->halt_msg.trap_number== 12 - || in_msg_buf->halt_msg.trap_number== 13) - { printf("Am290*0 received vector number %d\n", - in_msg_buf->halt_msg.trap_number); - WSETSTOP ((*status), SIGILL); - } - else if (in_msg_buf->halt_msg.trap_number== 14) - { printf("Am290*0 received vector number %d\n", - in_msg_buf->halt_msg.trap_number); - WSETSTOP ((*status), SIGALRM); - } - else if (in_msg_buf->halt_msg.trap_number== 15) - WSETSTOP ((*status), SIGTRAP); - else if (in_msg_buf->halt_msg.trap_number >= 16 - && in_msg_buf->halt_msg.trap_number <= 21) - { printf("Am290*0 received vector number %d\n", - in_msg_buf->halt_msg.trap_number); - WSETSTOP ((*status), SIGINT); - } - else if (in_msg_buf->halt_msg.trap_number== 22) - { printf("Am290*0 received vector number %d\n", - in_msg_buf->halt_msg.trap_number); - WSETSTOP ((*status), SIGILL); - } /* BREAK message was sent */ - else if (in_msg_buf->halt_msg.trap_number== 75) - WSETSTOP ((*status), SIGTRAP); - else -exit: - WSETEXIT ((*status), 0); - - timeout = old_timeout; /* Restore original timeout value */ - immediate_quit = old_immediate_quit; - DEXIT("mm_wait()"); - return 0; -} - -/******************************************************* REMOTE_FETCH_REGISTERS - * Read a remote register 'regno'. - * If regno==-1 then read all the registers. - */ -static void -mm_fetch_registers (regno) -int regno; -{ - INT32 *data_p; - - if (regno >= 0) { - fetch_register(regno); - return; - } - - DENTER("mm_fetch_registers()"); - -/* Gr1/rsp */ - out_msg_buf->read_req_msg.byte_count = 4*1; - out_msg_buf->read_req_msg.memory_space = GLOBAL_REG; - out_msg_buf->read_req_msg.address = 1; - msg_send_serial(out_msg_buf); - expect_msg(READ_ACK,in_msg_buf,1); - data_p = &(in_msg_buf->read_r_ack_msg.data[0]); - supply_register (GR1_REGNUM , data_p); - -#if defined(GR64_REGNUM) /* Read gr64-127 */ -/* Global Registers gr64-gr95 */ - out_msg_buf->read_req_msg.code= READ_REQ; - out_msg_buf->read_req_msg.length = 4*3; - out_msg_buf->read_req_msg.byte_count = 4*32; - out_msg_buf->read_req_msg.memory_space = GLOBAL_REG; - out_msg_buf->read_req_msg.address = 64; - msg_send_serial(out_msg_buf); - expect_msg(READ_ACK,in_msg_buf,1); - data_p = &(in_msg_buf->read_r_ack_msg.data[0]); - - for (regno=GR64_REGNUM; regnoread_req_msg.code= READ_REQ; - out_msg_buf->read_req_msg.length = 4*3; - out_msg_buf->read_req_msg.byte_count = 4 * 32; - out_msg_buf->read_req_msg.memory_space = GLOBAL_REG; - out_msg_buf->read_req_msg.address = 96; - msg_send_serial(out_msg_buf); - expect_msg(READ_ACK,in_msg_buf,1); - data_p = &(in_msg_buf->read_r_ack_msg.data[0]); - - for (regno=GR96_REGNUM; regnoread_req_msg.byte_count = 4 * (128); - out_msg_buf->read_req_msg.memory_space = LOCAL_REG; - out_msg_buf->read_req_msg.address = 0; - msg_send_serial(out_msg_buf); - expect_msg(READ_ACK,in_msg_buf,1); - data_p = &(in_msg_buf->read_r_ack_msg.data[0]); - - for (regno=LR0_REGNUM; regnoread_req_msg.byte_count = 4*15; - out_msg_buf->read_req_msg.memory_space = SPECIAL_REG; - out_msg_buf->read_req_msg.address = 0; - msg_send_serial( out_msg_buf); - expect_msg(READ_ACK,in_msg_buf,1); - data_p = &(in_msg_buf->read_r_ack_msg.data[0]); - - for (regno=0; regno<=14; regno++) { - supply_register (SR_REGNUM(regno), data_p++); - } - if (USE_SHADOW_PC) { /* Let regno_to_srnum() handle the register number */ - fetch_register(NPC_REGNUM); - fetch_register(PC_REGNUM); - fetch_register(PC2_REGNUM); - } - -/* Unprotected Special Registers */ - out_msg_buf->read_req_msg.byte_count = 4*8; - out_msg_buf->read_req_msg.memory_space = SPECIAL_REG; - out_msg_buf->read_req_msg.address = 128; - msg_send_serial( out_msg_buf); - expect_msg(READ_ACK,in_msg_buf,1); - data_p = &(in_msg_buf->read_r_ack_msg.data[0]); - - for (regno=128; regno<=135; regno++) { - supply_register (SR_REGNUM(regno), data_p++); - } - - /* There doesn't seem to be any way to get these. */ - { - int val = -1; - supply_register (FPE_REGNUM, &val); - supply_register (INT_REGNUM, &val); - supply_register (FPS_REGNUM, &val); - supply_register (EXO_REGNUM, &val); - } - - DEXIT("mm_fetch_registerS()"); -} - - -/****************************************************** REMOTE_STORE_REGISTERS - * Store register regno into the target. - * If regno==-1 then store all the registers. - * Result is 0 for success, -1 for failure. - */ - -static int -mm_store_registers (regno) -int regno; -{ - int result; - - if (regno >= 0) - return(store_register(regno)); - - DENTER("mm_store_registers()"); - result = 0; - - out_msg_buf->write_r_msg.code= WRITE_REQ; - -/* Gr1/rsp */ - out_msg_buf->write_r_msg.byte_count = 4*1; - out_msg_buf->write_r_msg.length = 3*4 + out_msg_buf->write_r_msg.byte_count; - out_msg_buf->write_r_msg.memory_space = GLOBAL_REG; - out_msg_buf->write_r_msg.address = 1; - out_msg_buf->write_r_msg.data[0] = read_register (GR1_REGNUM); - - msg_send_serial( out_msg_buf); - if (!expect_msg(WRITE_ACK,in_msg_buf,1)) { - result = -1; - } - -#if defined(GR64_REGNUM) -/* Global registers gr64-gr95 */ - out_msg_buf->write_r_msg.byte_count = 4* (32); - out_msg_buf->write_r_msg.length = 3*4 + out_msg_buf->write_r_msg.byte_count; - out_msg_buf->write_r_msg.address = 64; - - for (regno=GR64_REGNUM ; regnowrite_r_msg.data[regno-GR64_REGNUM] = read_register (regno); - } - msg_send_serial(out_msg_buf); - if (!expect_msg(WRITE_ACK,in_msg_buf,1)) { - result = -1; - } -#endif /* GR64_REGNUM */ - -/* Global registers gr96-gr127 */ - out_msg_buf->write_r_msg.byte_count = 4* (32); - out_msg_buf->write_r_msg.length = 3*4 + out_msg_buf->write_r_msg.byte_count; - out_msg_buf->write_r_msg.address = 96; - for (regno=GR96_REGNUM ; regnowrite_r_msg.data[regno-GR96_REGNUM] = read_register (regno); - } - msg_send_serial( out_msg_buf); - if (!expect_msg(WRITE_ACK,in_msg_buf,1)) { - result = -1; - } - -/* Local Registers */ - out_msg_buf->write_r_msg.memory_space = LOCAL_REG; - out_msg_buf->write_r_msg.byte_count = 4*128; - out_msg_buf->write_r_msg.length = 3*4 + out_msg_buf->write_r_msg.byte_count; - out_msg_buf->write_r_msg.address = 0; - - for (regno = LR0_REGNUM ; regno < LR0_REGNUM+128 ; regno++) - { - out_msg_buf->write_r_msg.data[regno-LR0_REGNUM] = read_register (regno); - } - msg_send_serial( out_msg_buf); - if (!expect_msg(WRITE_ACK,in_msg_buf,1)) { - result = -1; - } - -/* Protected Special Registers */ - /* VAB through TMR */ - out_msg_buf->write_r_msg.memory_space = SPECIAL_REG; - out_msg_buf->write_r_msg.byte_count = 4* 10; - out_msg_buf->write_r_msg.length = 3*4 + out_msg_buf->write_r_msg.byte_count; - out_msg_buf->write_r_msg.address = 0; - for (regno = 0 ; regno<=9 ; regno++) /* VAB through TMR */ - out_msg_buf->write_r_msg.data[regno] = read_register (SR_REGNUM(regno)); - msg_send_serial( out_msg_buf); - if (!expect_msg(WRITE_ACK,in_msg_buf,1)) { - result = -1; - } - - /* PC0, PC1, PC2 possibly as shadow registers */ - out_msg_buf->write_r_msg.byte_count = 4* 3; - out_msg_buf->write_r_msg.length = 3*4 + out_msg_buf->write_r_msg.byte_count; - for (regno=10 ; regno<=12 ; regno++) /* LRU and MMU */ - out_msg_buf->write_r_msg.data[regno-10] = read_register (SR_REGNUM(regno)); - if (USE_SHADOW_PC) - out_msg_buf->write_r_msg.address = 20; /* SPC0 */ - else - out_msg_buf->write_r_msg.address = 10; /* PC0 */ - msg_send_serial( out_msg_buf); - if (!expect_msg(WRITE_ACK,in_msg_buf,1)) { - result = -1; - } - - /* LRU and MMU */ - out_msg_buf->write_r_msg.byte_count = 4* 2; - out_msg_buf->write_r_msg.length = 3*4 + out_msg_buf->write_r_msg.byte_count; - out_msg_buf->write_r_msg.address = 13; - for (regno=13 ; regno<=14 ; regno++) /* LRU and MMU */ - out_msg_buf->write_r_msg.data[regno-13] = read_register (SR_REGNUM(regno)); - msg_send_serial( out_msg_buf); - if (!expect_msg(WRITE_ACK,in_msg_buf,1)) { - result = -1; - } - -/* Unprotected Special Registers */ - out_msg_buf->write_r_msg.byte_count = 4*8; - out_msg_buf->write_r_msg.length = 3*4 + out_msg_buf->write_r_msg.byte_count; - out_msg_buf->write_r_msg.address = 128; - for (regno = 128 ; regno<=135 ; regno++) - out_msg_buf->write_r_msg.data[regno-128] = read_register(SR_REGNUM(regno)); - msg_send_serial( out_msg_buf); - if (!expect_msg(WRITE_ACK,in_msg_buf,1)) { - result = -1; - } - - registers_changed (); - DEXIT("mm_store_registers()"); - return result; -} - -/*************************************************** REMOTE_PREPARE_TO_STORE */ -/* Get ready to modify the registers array. On machines which store - individual registers, this doesn't need to do anything. On machines - which store all the registers in one fell swoop, this makes sure - that registers contains all the registers from the program being - debugged. */ - -static void -mm_prepare_to_store () -{ - /* Do nothing, since we can store individual regs */ -} - -/******************************************************* REMOTE_XFER_MEMORY */ -static CORE_ADDR -translate_addr(addr) -CORE_ADDR addr; -{ -#if defined(KERNEL_DEBUGGING) - /* Check for a virtual address in the kernel */ - /* Assume physical address of ublock is in paddr_u register */ - /* FIXME: doesn't work for user virtual addresses */ - if (addr >= UVADDR) { - /* PADDR_U register holds the physical address of the ublock */ - CORE_ADDR i = (CORE_ADDR)read_register(PADDR_U_REGNUM); - return(i + addr - (CORE_ADDR)UVADDR); - } else { - return(addr); - } -#else - return(addr); -#endif -} - -/******************************************************* REMOTE_FILES_INFO */ -static void -mm_files_info () -{ - printf ("\tAttached to %s at %d baud and running program %s.\n", - dev_name, baudrate, prog_name); -} - -/************************************************* REMOTE_INSERT_BREAKPOINT */ -static int -mm_insert_breakpoint (addr, contents_cache) - CORE_ADDR addr; - char *contents_cache; -{ - DENTER("mm_insert_breakpoint()"); - out_msg_buf->bkpt_set_msg.code = BKPT_SET; - out_msg_buf->bkpt_set_msg.length = 4*4; - out_msg_buf->bkpt_set_msg.memory_space = I_MEM; - out_msg_buf->bkpt_set_msg.bkpt_addr = (ADDR32) addr; - out_msg_buf->bkpt_set_msg.pass_count = 1; - out_msg_buf->bkpt_set_msg.bkpt_type = -1; /* use illop for 29000 */ - msg_send_serial( out_msg_buf); - if (expect_msg(BKPT_SET_ACK,in_msg_buf,1)) { - DEXIT("mm_insert_breakpoint() success"); - return 0; /* Success */ - } else { - DEXIT("mm_insert_breakpoint() failure"); - return 1; /* Failure */ - } -} - -/************************************************* REMOTE_DELETE_BREAKPOINT */ -static int -mm_remove_breakpoint (addr, contents_cache) - CORE_ADDR addr; - char *contents_cache; -{ - DENTER("mm_remove_breakpoint()"); - out_msg_buf->bkpt_rm_msg.code = BKPT_RM; - out_msg_buf->bkpt_rm_msg.length = 4*3; - out_msg_buf->bkpt_rm_msg.memory_space = I_MEM; - out_msg_buf->bkpt_rm_msg.bkpt_addr = (ADDR32) addr; - msg_send_serial( out_msg_buf); - if (expect_msg(BKPT_RM_ACK,in_msg_buf,1)) { - DEXIT("mm_remove_breakpoint()"); - return 0; /* Success */ - } else { - DEXIT("mm_remove_breakpoint()"); - return 1; /* Failure */ - } -} - - -/******************************************************* REMOTE_KILL */ -static void -mm_kill(arg,from_tty) -char *arg; -int from_tty; -{ - char buf[4]; - - DENTER("mm_kill()"); -#if defined(KERNEL_DEBUGGING) - /* We don't ever kill the kernel */ - if (from_tty) { - printf("Kernel not killed, but left in current state.\n"); - printf("Use detach to leave kernel running.\n"); - } -#else - out_msg_buf->break_msg.code = BREAK; - out_msg_buf->bkpt_set_msg.length = 4*0; - expect_msg(HALT,in_msg_buf,from_tty); - if (from_tty) { - printf("Target has been stopped."); - printf("Would you like to do a hardware reset (y/n) [n] "); - fgets(buf,3,stdin); - if (buf[0] == 'y') { - out_msg_buf->reset_msg.code = RESET; - out_msg_buf->bkpt_set_msg.length = 4*0; - expect_msg(RESET_ACK,in_msg_buf,from_tty); - printf("Target has been reset."); - } - } - pop_target(); -#endif - DEXIT("mm_kill()"); -} - - - -/***************************************************************************/ -/* - * Load a program into the target. - */ -static void -mm_load(arg_string,from_tty) -char *arg_string; -int from_tty; -{ - dont_repeat (); - -#if defined(KERNEL_DEBUGGING) - printf("The kernel had better be loaded already! Loading not done.\n"); -#else - if (arg_string == 0) - error ("The load command takes a file name"); - - arg_string = tilde_expand (arg_string); - make_cleanup (free, arg_string); - QUIT; - immediate_quit++; - error("File loading is not yet supported for MiniMon."); - /* FIXME, code to load your file here... */ - /* You may need to do an init_target_mm() */ - /* init_target_mm(?,?,?,?,?,?,?,?); */ - immediate_quit--; - /* symbol_file_add (arg_string, from_tty, text_addr, 0); */ -#endif - -} - -/************************************************ REMOTE_WRITE_INFERIOR_MEMORY -** Copy LEN bytes of data from debugger memory at MYADDR - to inferior's memory at MEMADDR. Returns number of bytes written. */ -static int -mm_write_inferior_memory (memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - int i,nwritten; - - /* DENTER("mm_write_inferior_memory()"); */ - out_msg_buf->write_req_msg.code= WRITE_REQ; - out_msg_buf->write_req_msg.memory_space = mm_memory_space(memaddr); - - nwritten=0; - while (nwritten < len) { - int num_to_write = len - nwritten; - if (num_to_write > MAXDATA) num_to_write = MAXDATA; - for (i=0 ; i < num_to_write ; i++) - out_msg_buf->write_req_msg.data[i] = myaddr[i+nwritten]; - out_msg_buf->write_req_msg.byte_count = num_to_write; - out_msg_buf->write_req_msg.length = 3*4 + num_to_write; - out_msg_buf->write_req_msg.address = memaddr + nwritten; - msg_send_serial(out_msg_buf); - - if (expect_msg(WRITE_ACK,in_msg_buf,1)) { - nwritten += in_msg_buf->write_ack_msg.byte_count; - } else { - break; - } - } - /* DEXIT("mm_write_inferior_memory()"); */ - return(nwritten); -} - -/************************************************* REMOTE_READ_INFERIOR_MEMORY -** Read LEN bytes from inferior memory at MEMADDR. Put the result - at debugger address MYADDR. Returns number of bytes read. */ -static int -mm_read_inferior_memory(memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - int i,nread; - - /* DENTER("mm_read_inferior_memory()"); */ - out_msg_buf->read_req_msg.code= READ_REQ; - out_msg_buf->read_req_msg.memory_space = mm_memory_space(memaddr); - - nread=0; - while (nread < len) { - int num_to_read = (len - nread); - if (num_to_read > MAXDATA) num_to_read = MAXDATA; - out_msg_buf->read_req_msg.byte_count = num_to_read; - out_msg_buf->read_req_msg.length = 3*4 + num_to_read; - out_msg_buf->read_req_msg.address = memaddr + nread; - msg_send_serial(out_msg_buf); - - if (expect_msg(READ_ACK,in_msg_buf,1)) { - for (i=0 ; iread_ack_msg.byte_count ; i++) - myaddr[i+nread] = in_msg_buf->read_ack_msg.data[i]; - nread += in_msg_buf->read_ack_msg.byte_count; - } else { - break; - } - } - return(nread); -} - -/* FIXME! Merge these two. */ -static int -mm_xfer_inferior_memory (memaddr, myaddr, len, write) - CORE_ADDR memaddr; - char *myaddr; - int len; - int write; -{ - - memaddr = translate_addr(memaddr); - - if (write) - return mm_write_inferior_memory (memaddr, myaddr, len); - else - return mm_read_inferior_memory (memaddr, myaddr, len); -} - - -/********************************************************** MSG_SEND_SERIAL -** This function is used to send a message over the -** serial line. -** -** If the message is successfully sent, a zero is -** returned. If the message was not sendable, a -1 -** is returned. This function blocks. That is, it -** does not return until the message is completely -** sent, or until an error is encountered. -** -*/ - -int -msg_send_serial(msg_ptr) - union msg_t *msg_ptr; -{ - INT32 message_size; - int byte_count; - int result; - char c; - - /* Send message header */ - byte_count = 0; - message_size = msg_ptr->generic_msg.length + (2 * sizeof(INT32)); - do { - c = *((char *)msg_ptr+byte_count); - result = write(mm_desc, &c, 1); - if (result == 1) { - byte_count = byte_count + 1; - } - } while ((byte_count < message_size) ); - - return(0); -} /* end msg_send_serial() */ - -/********************************************************** MSG_RECV_SERIAL -** This function is used to receive a message over a -** serial line. -** -** If the message is waiting in the buffer, a zero is -** returned and the buffer pointed to by msg_ptr is filled -** in. If no message was available, a -1 is returned. -** If timeout==0, wait indefinetly for a character. -** -*/ - -int -msg_recv_serial(msg_ptr) -union msg_t *msg_ptr; -{ - static INT32 length=0; - static INT32 byte_count=0; - int result; - char c; - if(msg_ptr == 0) /* re-sync request */ - { length=0; - byte_count=0; -#ifdef HAVE_TERMIO - /* The timeout here is the prevailing timeout set with VTIME */ - ->"timeout==0 semantics not supported" - read(mm_desc, in_buf, BUFER_SIZE); -#else - alarm (1); - read(mm_desc, in_buf, BUFER_SIZE); - alarm (0); -#endif - return(0); - } - /* Receive message */ -#ifdef HAVE_TERMIO -/* Timeout==0, help support the mm_wait() routine */ - ->"timeout==0 semantics not supported (and its nice if they are)" - result = read(mm_desc, &c, 1); -#else - alarm(timeout); - result = read(mm_desc, &c, 1); - alarm (0); -#endif - if ( result < 0) { - if (errno == EINTR) { - error ("Timeout reading from remote system."); - } else - perror_with_name ("remote"); - } else if (result == 1) { - *((char *)msg_ptr+byte_count) = c; - byte_count = byte_count + 1; - } - - /* Message header received. Save message length. */ - if (byte_count == (2 * sizeof(INT32))) - length = msg_ptr->generic_msg.length; - - if (byte_count >= (length + (2 * sizeof(INT32)))) { - /* Message received */ - byte_count = 0; - return(0); - } else - return (-1); - -} /* end msg_recv_serial() */ - -/********************************************************************* KBD_RAW -** This function is used to put the keyboard in "raw" -** mode for BSD Unix. The original status is saved -** so that it may be restored later. -*/ -TERMINAL kbd_tbuf; - -int -kbd_raw() { - int result; - TERMINAL tbuf; - - /* Get keyboard termio (to save to restore original modes) */ -#ifdef HAVE_TERMIO - result = ioctl(0, TCGETA, &kbd_tbuf); -#else - result = ioctl(0, TIOCGETP, &kbd_tbuf); -#endif - if (result == -1) - return (errno); - - /* Get keyboard TERMINAL (for modification) */ -#ifdef HAVE_TERMIO - result = ioctl(0, TCGETA, &tbuf); -#else - result = ioctl(0, TIOCGETP, &tbuf); -#endif - if (result == -1) - return (errno); - - /* Set up new parameters */ -#ifdef HAVE_TERMIO - tbuf.c_iflag = tbuf.c_iflag & - ~(INLCR | ICRNL | IUCLC | ISTRIP | IXON | BRKINT); - tbuf.c_lflag = tbuf.c_lflag & ~(ICANON | ISIG | ECHO); - tbuf.c_cc[4] = 0; /* MIN */ - tbuf.c_cc[5] = 0; /* TIME */ -#else - /* FIXME: not sure if this is correct (matches HAVE_TERMIO). */ - tbuf.sg_flags |= RAW; - tbuf.sg_flags |= ANYP; - tbuf.sg_flags &= ~ECHO; -#endif - - /* Set keyboard termio to new mode (RAW) */ -#ifdef HAVE_TERMIO - result = ioctl(0, TCSETAF, &tbuf); -#else - result = ioctl(0, TIOCSETP, &tbuf); -#endif - if (result == -1) - return (errno); - - return (0); -} /* end kbd_raw() */ - - - -/***************************************************************** KBD_RESTORE -** This function is used to put the keyboard back in the -** mode it was in before kbk_raw was called. Note that -** kbk_raw() must have been called at least once before -** kbd_restore() is called. -*/ - -int -kbd_restore() { - int result; - - /* Set keyboard termio to original mode */ -#ifdef HAVE_TERMIO - result = ioctl(0, TCSETAF, &kbd_tbuf); -#else - result = ioctl(0, TIOCGETP, &kbd_tbuf); -#endif - - if (result == -1) - return (errno); - - return(0); -} /* end kbd_cooked() */ - - -/*****************************************************************************/ -/* Fetch a single register indicatated by 'regno'. - * Returns 0/-1 on success/failure. - */ -static int -fetch_register (regno) - int regno; -{ - int result; - DENTER("mm_fetch_register()"); - out_msg_buf->read_req_msg.code= READ_REQ; - out_msg_buf->read_req_msg.length = 4*3; - out_msg_buf->read_req_msg.byte_count = 4; - - if (regno == GR1_REGNUM) - { out_msg_buf->read_req_msg.memory_space = GLOBAL_REG; - out_msg_buf->read_req_msg.address = 1; - } - else if (regno >= GR96_REGNUM && regno < GR96_REGNUM + 32) - { out_msg_buf->read_req_msg.memory_space = GLOBAL_REG; - out_msg_buf->read_req_msg.address = (regno - GR96_REGNUM) + 96; - } -#if defined(GR64_REGNUM) - else if (regno >= GR64_REGNUM && regno < GR64_REGNUM + 32 ) - { out_msg_buf->read_req_msg.memory_space = GLOBAL_REG; - out_msg_buf->read_req_msg.address = (regno - GR64_REGNUM) + 64; - } -#endif /* GR64_REGNUM */ - else if (regno >= LR0_REGNUM && regno < LR0_REGNUM + 128) - { out_msg_buf->read_req_msg.memory_space = LOCAL_REG; - out_msg_buf->read_req_msg.address = (regno - LR0_REGNUM); - } - else if (regno>=FPE_REGNUM && regno<=EXO_REGNUM) - { int val = -1; - supply_register(160 + (regno - FPE_REGNUM),&val); - return 0; /* Pretend Success */ - } - else - { out_msg_buf->read_req_msg.memory_space = SPECIAL_REG; - out_msg_buf->read_req_msg.address = regnum_to_srnum(regno); - } - - msg_send_serial(out_msg_buf); - - if (expect_msg(READ_ACK,in_msg_buf,1)) { - supply_register (regno, &(in_msg_buf->read_r_ack_msg.data[0])); - result = 0; - } else { - result = -1; - } - DEXIT("mm_fetch_register()"); - return result; -} -/*****************************************************************************/ -/* Store a single register indicated by 'regno'. - * Returns 0/-1 on success/failure. - */ -static int -store_register (regno) - int regno; -{ - int result; - - DENTER("store_register()"); - out_msg_buf->write_req_msg.code= WRITE_REQ; - out_msg_buf->write_req_msg.length = 4*4; - out_msg_buf->write_req_msg.byte_count = 4; - out_msg_buf->write_r_msg.data[0] = read_register (regno); - - if (regno == GR1_REGNUM) - { out_msg_buf->write_req_msg.memory_space = GLOBAL_REG; - out_msg_buf->write_req_msg.address = 1; - /* Setting GR1 changes the numbers of all the locals, so invalidate the - * register cache. Do this *after* calling read_register, because we want - * read_register to return the value that write_register has just stuffed - * into the registers array, not the value of the register fetched from - * the inferior. - */ - registers_changed (); - } -#if defined(GR64_REGNUM) - else if (regno >= GR64_REGNUM && regno < GR64_REGNUM + 32 ) - { out_msg_buf->write_req_msg.memory_space = GLOBAL_REG; - out_msg_buf->write_req_msg.address = (regno - GR64_REGNUM) + 64; - } -#endif /* GR64_REGNUM */ - else if (regno >= GR96_REGNUM && regno < GR96_REGNUM + 32) - { out_msg_buf->write_req_msg.memory_space = GLOBAL_REG; - out_msg_buf->write_req_msg.address = (regno - GR96_REGNUM) + 96; - } - else if (regno >= LR0_REGNUM && regno < LR0_REGNUM + 128) - { out_msg_buf->write_req_msg.memory_space = LOCAL_REG; - out_msg_buf->write_req_msg.address = (regno - LR0_REGNUM); - } - else if (regno>=FPE_REGNUM && regno<=EXO_REGNUM) - { - return 0; /* Pretend Success */ - } - else /* An unprotected or protected special register */ - { out_msg_buf->write_req_msg.memory_space = SPECIAL_REG; - out_msg_buf->write_req_msg.address = regnum_to_srnum(regno); - } - - msg_send_serial(out_msg_buf); - - if (expect_msg(WRITE_ACK,in_msg_buf,1)) { - result = 0; - } else { - result = -1; - } - DEXIT("store_register()"); - return result; -} -/****************************************************************************/ -/* - * Convert a gdb special register number to a 29000 special register number. - */ -static int -regnum_to_srnum(regno) -int regno; -{ - switch(regno) { - case VAB_REGNUM: return(0); - case OPS_REGNUM: return(1); - case CPS_REGNUM: return(2); - case CFG_REGNUM: return(3); - case CHA_REGNUM: return(4); - case CHD_REGNUM: return(5); - case CHC_REGNUM: return(6); - case RBP_REGNUM: return(7); - case TMC_REGNUM: return(8); - case TMR_REGNUM: return(9); - case NPC_REGNUM: return(USE_SHADOW_PC ? (20) : (10)); - case PC_REGNUM: return(USE_SHADOW_PC ? (21) : (11)); - case PC2_REGNUM: return(USE_SHADOW_PC ? (22) : (12)); - case MMU_REGNUM: return(13); - case LRU_REGNUM: return(14); - case IPC_REGNUM: return(128); - case IPA_REGNUM: return(129); - case IPB_REGNUM: return(130); - case Q_REGNUM: return(131); - case ALU_REGNUM: return(132); - case BP_REGNUM: return(133); - case FC_REGNUM: return(134); - case CR_REGNUM: return(135); - case FPE_REGNUM: return(160); - case INT_REGNUM: return(161); - case FPS_REGNUM: return(162); - case EXO_REGNUM:return(164); - default: - return(255); /* Failure ? */ - } -} -/****************************************************************************/ -/* - * Initialize the target debugger (minimon only). - */ -static void -init_target_mm(tstart,tend,dstart,dend,entry,ms_size,rs_size,arg_start) -ADDR32 tstart,tend,dstart,dend,entry; -INT32 ms_size,rs_size; -ADDR32 arg_start; -{ - out_msg_buf->init_msg.code = INIT; - out_msg_buf->init_msg.length= sizeof(struct init_msg_t)-2*sizeof(INT32); - out_msg_buf->init_msg.text_start = tstart; - out_msg_buf->init_msg.text_end = tend; - out_msg_buf->init_msg.data_start = dstart; - out_msg_buf->init_msg.data_end = dend; - out_msg_buf->init_msg.entry_point = entry; - out_msg_buf->init_msg.mem_stack_size = ms_size; - out_msg_buf->init_msg.reg_stack_size = rs_size; - out_msg_buf->init_msg.arg_start = arg_start; - msg_send_serial(out_msg_buf); - expect_msg(INIT_ACK,in_msg_buf,1); -} -/****************************************************************************/ -/* - * Return a pointer to a string representing the given message code. - * Not all messages are represented here, only the ones that we expect - * to be called with. - */ -static char* -msg_str(code) -INT32 code; -{ - static char cbuf[32]; - - switch (code) { - case BKPT_SET_ACK: sprintf(cbuf,"%s (%d)","BKPT_SET_ACK",code); break; - case BKPT_RM_ACK: sprintf(cbuf,"%s (%d)","BKPT_RM_ACK",code); break; - case INIT_ACK: sprintf(cbuf,"%s (%d)","INIT_ACK",code); break; - case READ_ACK: sprintf(cbuf,"%s (%d)","READ_ACK",code); break; - case WRITE_ACK: sprintf(cbuf,"%s (%d)","WRITE_ACK",code); break; - case ERROR: sprintf(cbuf,"%s (%d)","ERROR",code); break; - case HALT: sprintf(cbuf,"%s (%d)","HALT",code); break; - default: sprintf(cbuf,"UNKNOWN (%d)",code); break; - } - return(cbuf); -} -/****************************************************************************/ -/* - * Selected (not all of them) error codes that we might get. - */ -static char* -error_msg_str(code) -INT32 code; -{ - static char cbuf[50]; - - switch (code) { - case EMFAIL: return("EMFAIL: unrecoverable error"); - case EMBADADDR: return("EMBADADDR: Illegal address"); - case EMBADREG: return("EMBADREG: Illegal register "); - case EMACCESS: return("EMACCESS: Could not access memory"); - case EMBADMSG: return("EMBADMSG: Unknown message type"); - case EMMSG2BIG: return("EMMSG2BIG: Message to large"); - case EMNOSEND: return("EMNOSEND: Could not send message"); - case EMNORECV: return("EMNORECV: Could not recv message"); - case EMRESET: return("EMRESET: Could not RESET target"); - case EMCONFIG: return("EMCONFIG: Could not get target CONFIG"); - case EMSTATUS: return("EMSTATUS: Could not get target STATUS"); - case EMREAD: return("EMREAD: Could not READ target memory"); - case EMWRITE: return("EMWRITE: Could not WRITE target memory"); - case EMBKPTSET: return("EMBKPTSET: Could not set breakpoint"); - case EMBKPTRM: return("EMBKPTRM: Could not remove breakpoint"); - case EMBKPTSTAT:return("EMBKPTSTAT: Could not get breakpoint status"); - case EMBKPTNONE:return("EMBKPTNONE: All breakpoints in use"); - case EMBKPTUSED:return("EMBKPTUSED: Breakpoints already in use"); - case EMINIT: return("EMINIT: Could not init target memory"); - case EMGO: return("EMGO: Could not start execution"); - case EMSTEP: return("EMSTEP: Could not single step"); - case EMBREAK: return("EMBREAK: Could not BREAK"); - case EMCOMMERR: return("EMCOMMERR: Communication error"); - default: sprintf(cbuf,"error number %d",code); break; - } /* end switch */ - - return (cbuf); -} -/****************************************************************************/ -/* - * Receive a message and expect it to be of type msgcode. - * Returns 0/1 on failure/success. - */ -static int -expect_msg(msgcode,msg_buf,from_tty) -INT32 msgcode; /* Msg code we expect */ -union msg_t *msg_buf; /* Where to put the message received */ -int from_tty; /* Print message on error if non-zero */ -{ - /* DENTER("expect_msg()"); */ - int retries=0; - while(msg_recv_serial(msg_buf) && (retries++= MAX_RETRIES) { - printf("Expected msg %s, ",msg_str(msgcode)); - printf("no message received!\n"); - /* DEXIT("expect_msg() failure"); */ - return(0); /* Failure */ - } - - if (msg_buf->generic_msg.code != msgcode) { - if (from_tty) { - printf("Expected msg %s, ",msg_str(msgcode)); - printf("got msg %s\n",msg_str(msg_buf->generic_msg.code)); - if (msg_buf->generic_msg.code == ERROR) - printf("%s\n",error_msg_str(msg_buf->error_msg.error_code)); - } - /* DEXIT("expect_msg() failure"); */ - return(0); /* Failure */ - } - /* DEXIT("expect_msg() success"); */ - return(1); /* Success */ -} -/****************************************************************************/ -/* - * Determine the MiniMon memory space qualifier based on the addr. - * FIXME: Can't distinguis I_ROM/D_ROM. - * FIXME: Doesn't know anything about I_CACHE/D_CACHE. - */ -static int -mm_memory_space(addr) -CORE_ADDR *addr; -{ - ADDR32 tstart = target_config.I_mem_start; - ADDR32 tend = tstart + target_config.I_mem_size; - ADDR32 dstart = target_config.D_mem_start; - ADDR32 dend = tstart + target_config.D_mem_size; - ADDR32 rstart = target_config.ROM_start; - ADDR32 rend = tstart + target_config.ROM_size; - - if (((ADDR32)addr >= tstart) && ((ADDR32)addr < tend)) { - return I_MEM; - } else if (((ADDR32)addr >= dstart) && ((ADDR32)addr < dend)) { - return D_MEM; - } else if (((ADDR32)addr >= rstart) && ((ADDR32)addr < rend)) { - /* FIXME: how do we determine between D_ROM and I_ROM */ - return D_ROM; - } else /* FIXME: what do me do now? */ - return D_MEM; /* Hmmm! */ -} - -/****************************************************************************/ -/* - * Define the target subroutine names - */ -struct target_ops mm_ops = { - "minimon", "Remote AMD/Minimon target", - "Remote debug an AMD 290*0 using the MiniMon dbg core on the target", - mm_open, mm_close, - mm_attach, mm_detach, mm_resume, mm_wait, - mm_fetch_registers, mm_store_registers, - mm_prepare_to_store, 0, 0, /* conv_to, conv_from */ - mm_xfer_inferior_memory, - mm_files_info, - mm_insert_breakpoint, mm_remove_breakpoint, /* Breakpoints */ - 0, 0, 0, 0, 0, /* Terminal handling */ - mm_kill, /* FIXME, kill */ - mm_load, - call_function_by_hand, - 0, /* lookup_symbol */ - mm_create_inferior, /* create_inferior */ - mm_mourn, /* mourn_inferior FIXME */ - process_stratum, 0, /* next */ - 1, 1, 1, 1, 1, /* all mem, mem, stack, regs, exec */ - 0,0, /* sections, sections_end */ - OPS_MAGIC, /* Always the last thing */ -}; - -void -_initialize_remote_mm() -{ - add_target (&mm_ops); -} - -#ifdef NO_HIF_SUPPORT -service_HIF(msg) -union msg_t *msg; -{ - return(0); /* Emulate a failure */ -} -#endif diff --git a/gdb/remote-multi.shar b/gdb/remote-multi.shar deleted file mode 100755 index 86c9cf0217a..00000000000 --- a/gdb/remote-multi.shar +++ /dev/null @@ -1,1313 +0,0 @@ -#!/bin/sh -# This is a shell archive. -# Run the file through sh to extract its contents. -# shar: Shell Archiver -# Run the following text with /bin/sh to create: -# Remote_Makefile -# remote_gutils.c -# remote_inflow.c -# remote_server.c -# remote_utils.c -# This archive created: Fri Jun 23 17:06:55 1989 -cat << \SHAR_EOF > Remote_Makefile -# Makefile for the remote server for GDB, the GNU debugger. -# Copyright (C) 1986, 1989 Free Software Foundation, Inc. -# -# This file is part of GDB. -# -# GDB 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 1, or (at your option) -# any later version. -# -# GDB 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 GDB; see the file COPYING. If not, write to -# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -CFLAGS = -g -CC = cc - -SERVER = remote_server.o\ - remote_inflow.o\ - remote_utils.o\ - remote_gutils.o - -prog : $(SERVER) - $(CC) -g -o serve $(SERVER) -SHAR_EOF -cat << \SHAR_EOF > remote_gutils.c -/* General utility routines for the remote server for GDB, the GNU debugger. - Copyright (C) 1986, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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 1, or (at your option) -any later version. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include -#include "defs.h" - -void error (); -void fatal (); - -/* Chain of cleanup actions established with make_cleanup, - to be executed if an error happens. */ - -static struct cleanup *cleanup_chain; - -/* Nonzero means a quit has been requested. */ - -int quit_flag; - -/* Nonzero means quit immediately if Control-C is typed now, - rather than waiting until QUIT is executed. */ - -int immediate_quit; - -/* Add a new cleanup to the cleanup_chain, - and return the previous chain pointer - to be passed later to do_cleanups or discard_cleanups. - Args are FUNCTION to clean up with, and ARG to pass to it. */ - -struct cleanup * -make_cleanup (function, arg) - void (*function) (); - int arg; -{ - register struct cleanup *new - = (struct cleanup *) xmalloc (sizeof (struct cleanup)); - register struct cleanup *old_chain = cleanup_chain; - - new->next = cleanup_chain; - new->function = function; - new->arg = arg; - cleanup_chain = new; - - return old_chain; -} - -/* Discard cleanups and do the actions they describe - until we get back to the point OLD_CHAIN in the cleanup_chain. */ - -void -do_cleanups (old_chain) - register struct cleanup *old_chain; -{ - register struct cleanup *ptr; - while ((ptr = cleanup_chain) != old_chain) - { - (*ptr->function) (ptr->arg); - cleanup_chain = ptr->next; - free (ptr); - } -} - -/* Discard cleanups, not doing the actions they describe, - until we get back to the point OLD_CHAIN in the cleanup_chain. */ - -void -discard_cleanups (old_chain) - register struct cleanup *old_chain; -{ - register struct cleanup *ptr; - while ((ptr = cleanup_chain) != old_chain) - { - cleanup_chain = ptr->next; - free (ptr); - } -} - -/* This function is useful for cleanups. - Do - - foo = xmalloc (...); - old_chain = make_cleanup (free_current_contents, &foo); - - to arrange to free the object thus allocated. */ - -void -free_current_contents (location) - char **location; -{ - free (*location); -} - -/* Generally useful subroutines used throughout the program. */ - -/* Like malloc but get error if no storage available. */ - -char * -xmalloc (size) - long size; -{ - register char *val = (char *) malloc (size); - if (!val) - fatal ("virtual memory exhausted.", 0); - return val; -} - -/* Like realloc but get error if no storage available. */ - -char * -xrealloc (ptr, size) - char *ptr; - long size; -{ - register char *val = (char *) realloc (ptr, size); - if (!val) - fatal ("virtual memory exhausted.", 0); - return val; -} - -/* Print the system error message for errno, and also mention STRING - as the file name for which the error was encountered. - Then return to command level. */ - -void -perror_with_name (string) - char *string; -{ - extern int sys_nerr; - extern char *sys_errlist[]; - extern int errno; - char *err; - char *combined; - - if (errno < sys_nerr) - err = sys_errlist[errno]; - else - err = "unknown error"; - - combined = (char *) alloca (strlen (err) + strlen (string) + 3); - strcpy (combined, string); - strcat (combined, ": "); - strcat (combined, err); - - error ("%s.", combined); -} - -/* Print the system error message for ERRCODE, and also mention STRING - as the file name for which the error was encountered. */ - -void -print_sys_errmsg (string, errcode) - char *string; - int errcode; -{ - extern int sys_nerr; - extern char *sys_errlist[]; - char *err; - char *combined; - - if (errcode < sys_nerr) - err = sys_errlist[errcode]; - else - err = "unknown error"; - - combined = (char *) alloca (strlen (err) + strlen (string) + 3); - strcpy (combined, string); - strcat (combined, ": "); - strcat (combined, err); - - printf ("%s.\n", combined); -} - -void -quit () -{ - fflush (stdout); - ioctl (fileno (stdout), TIOCFLUSH, 0); - error ("Quit"); -} - -/* Control C comes here */ - -void -request_quit () -{ - quit_flag = 1; - if (immediate_quit) - quit (); -} - -/* Print an error message and return to command level. - STRING is the error message, used as a fprintf string, - and ARG is passed as an argument to it. */ - -void -error (string, arg1, arg2, arg3) - char *string; - int arg1, arg2, arg3; -{ - fflush (stdout); - fprintf (stderr, string, arg1, arg2, arg3); - fprintf (stderr, "\n"); - /************return_to_top_level ();************/ -} - -/* Print an error message and exit reporting failure. - This is for a error that we cannot continue from. - STRING and ARG are passed to fprintf. */ - -void -fatal (string, arg) - char *string; - int arg; -{ - fprintf (stderr, "gdb: "); - fprintf (stderr, string, arg); - fprintf (stderr, "\n"); - exit (1); -} - -/* Make a copy of the string at PTR with SIZE characters - (and add a null character at the end in the copy). - Uses malloc to get the space. Returns the address of the copy. */ - -char * -savestring (ptr, size) - char *ptr; - int size; -{ - register char *p = (char *) xmalloc (size + 1); - bcopy (ptr, p, size); - p[size] = 0; - return p; -} - -char * -concat (s1, s2, s3) - char *s1, *s2, *s3; -{ - register int len = strlen (s1) + strlen (s2) + strlen (s3) + 1; - register char *val = (char *) xmalloc (len); - strcpy (val, s1); - strcat (val, s2); - strcat (val, s3); - return val; -} - -void -print_spaces (n, file) - register int n; - register FILE *file; -{ - while (n-- > 0) - fputc (' ', file); -} - -/* Ask user a y-or-n question and return 1 iff answer is yes. - Takes three args which are given to printf to print the question. - The first, a control string, should end in "? ". - It should not say how to answer, because we do that. */ - -int -query (ctlstr, arg1, arg2) - char *ctlstr; -{ - register int answer; - - /* Automatically answer "yes" if input is not from a terminal. */ - /***********if (!input_from_terminal_p ()) - return 1; *************************/ - - while (1) - { - printf (ctlstr, arg1, arg2); - printf ("(y or n) "); - fflush (stdout); - answer = fgetc (stdin); - clearerr (stdin); /* in case of C-d */ - if (answer != '\n') - while (fgetc (stdin) != '\n') clearerr (stdin); - if (answer >= 'a') - answer -= 040; - if (answer == 'Y') - return 1; - if (answer == 'N') - return 0; - printf ("Please answer y or n.\n"); - } -} - -/* Parse a C escape sequence. STRING_PTR points to a variable - containing a pointer to the string to parse. That pointer - is updated past the characters we use. The value of the - escape sequence is returned. - - A negative value means the sequence \ newline was seen, - which is supposed to be equivalent to nothing at all. - - If \ is followed by a null character, we return a negative - value and leave the string pointer pointing at the null character. - - If \ is followed by 000, we return 0 and leave the string pointer - after the zeros. A value of 0 does not mean end of string. */ - -int -parse_escape (string_ptr) - char **string_ptr; -{ - register int c = *(*string_ptr)++; - switch (c) - { - case 'a': - return '\a'; - case 'b': - return '\b'; - case 'e': - return 033; - case 'f': - return '\f'; - case 'n': - return '\n'; - case 'r': - return '\r'; - case 't': - return '\t'; - case 'v': - return '\v'; - case '\n': - return -2; - case 0: - (*string_ptr)--; - return 0; - case '^': - c = *(*string_ptr)++; - if (c == '\\') - c = parse_escape (string_ptr); - if (c == '?') - return 0177; - return (c & 0200) | (c & 037); - - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - { - register int i = c - '0'; - register int count = 0; - while (++count < 3) - { - if ((c = *(*string_ptr)++) >= '0' && c <= '7') - { - i *= 8; - i += c - '0'; - } - else - { - (*string_ptr)--; - break; - } - } - return i; - } - default: - return c; - } -} - -void -printchar (ch, stream) - unsigned char ch; - FILE *stream; -{ - register int c = ch; - if (c < 040 || c >= 0177) - { - if (c == '\n') - fprintf (stream, "\\n"); - else if (c == '\b') - fprintf (stream, "\\b"); - else if (c == '\t') - fprintf (stream, "\\t"); - else if (c == '\f') - fprintf (stream, "\\f"); - else if (c == '\r') - fprintf (stream, "\\r"); - else if (c == 033) - fprintf (stream, "\\e"); - else if (c == '\a') - fprintf (stream, "\\a"); - else - fprintf (stream, "\\%03o", c); - } - else - { - if (c == '\\' || c == '"' || c == '\'') - fputc ('\\', stream); - fputc (c, stream); - } -} -SHAR_EOF -cat << \SHAR_EOF > remote_inflow.c -/* Low level interface to ptrace, for GDB when running under Unix. - Copyright (C) 1986, 1987 Free Software Foundation, Inc. -*/ - -#include "defs.h" -#include "param.h" -#include "wait.h" -#include "frame.h" -#include "inferior.h" -/*************************** -#include "initialize.h" -****************************/ - -#include -#include -#include -#include -#include -#include -#include -#include - -/***************Begin MY defs*********************/ -int quit_flag = 0; -char registers[REGISTER_BYTES]; - -/* Index within `registers' of the first byte of the space for - register N. */ - - -char buf2[MAX_REGISTER_RAW_SIZE]; -/***************End MY defs*********************/ - -#ifdef NEW_SUN_PTRACE -#include -#include -#endif - -extern char **environ; -extern int errno; -extern int inferior_pid; -void error(), quit(), perror_with_name(); -int query(); -void supply_register(), write_register(); -CORE_ADDR read_register(); - -/* Nonzero if we are debugging an attached outside process - rather than an inferior. */ - - -/* Start an inferior process and returns its pid. - ALLARGS is a vector of program-name and args. - ENV is the environment vector to pass. */ - -int -create_inferior (allargs, env) - char **allargs; - char **env; -{ - int pid; - extern int sys_nerr; - extern char *sys_errlist[]; - extern int errno; - - /* exec is said to fail if the executable is open. */ - /****************close_exec_file ();*****************/ - - pid = vfork (); - if (pid < 0) - perror_with_name ("vfork"); - - if (pid == 0) - { - /* Run inferior in a separate process group. */ - setpgrp (getpid (), getpid ()); - -/* Not needed on Sun, at least, and loses there - because it clobbers the superior. */ -/*??? signal (SIGQUIT, SIG_DFL); - signal (SIGINT, SIG_DFL); */ - - errno = 0; - ptrace (0); - - execle ("/bin/sh", "sh", "-c", allargs, 0, env); - - fprintf (stderr, "Cannot exec /bin/sh: %s.\n", - errno < sys_nerr ? sys_errlist[errno] : "unknown error"); - fflush (stderr); - _exit (0177); - } - return pid; -} - -/* Kill the inferior process. Make us have no inferior. */ - -kill_inferior () -{ - if (inferior_pid == 0) - return; - ptrace (8, inferior_pid, 0, 0); - wait (0); - /*************inferior_died ();****VK**************/ -} - -/* Resume execution of the inferior process. - If STEP is nonzero, single-step it. - If SIGNAL is nonzero, give it that signal. */ - -unsigned char -resume (step, signal,status) - int step; - int signal; - char *status; -{ - int pid ; - WAITTYPE w; - - errno = 0; - ptrace (step ? 9 : 7, inferior_pid, 1, signal); - if (errno) - perror_with_name ("ptrace"); - pid = wait(&w); - if(pid != inferior_pid) - perror_with_name ("wait"); - - if(WIFEXITED(w)) - { - printf("\nchild exited with retcode = %x \n",WRETCODE(w)); - *status = 'E'; - return((unsigned char) WRETCODE(w)); - } - else if(!WIFSTOPPED(w)) - { - printf("\nchild did terminated with signal = %x \n",WTERMSIG(w)); - *status = 'T'; - return((unsigned char) WTERMSIG(w)); - } - else - { - printf("\nchild stopped with signal = %x \n",WSTOPSIG(w)); - *status = 'S'; - return((unsigned char) WSTOPSIG(w)); - } - -} - - -#ifdef NEW_SUN_PTRACE - -void -fetch_inferior_registers () -{ - struct regs inferior_registers; - struct fp_status inferior_fp_registers; - extern char registers[]; - - ptrace (PTRACE_GETREGS, inferior_pid, &inferior_registers); - if (errno) - perror_with_name ("ptrace"); - /**********debugging begin **********/ - print_some_registers(&inferior_registers); - /**********debugging end **********/ - ptrace (PTRACE_GETFPREGS, inferior_pid, &inferior_fp_registers); - if (errno) - perror_with_name ("ptrace"); - - bcopy (&inferior_registers, registers, 16 * 4); - bcopy (&inferior_fp_registers, ®isters[REGISTER_BYTE (FP0_REGNUM)], - sizeof inferior_fp_registers.fps_regs); - *(int *)®isters[REGISTER_BYTE (PS_REGNUM)] = inferior_registers.r_ps; - *(int *)®isters[REGISTER_BYTE (PC_REGNUM)] = inferior_registers.r_pc; - bcopy (&inferior_fp_registers.fps_control, - ®isters[REGISTER_BYTE (FPC_REGNUM)], - sizeof inferior_fp_registers - sizeof inferior_fp_registers.fps_regs); -} - -/* Store our register values back into the inferior. - If REGNO is -1, do this for all registers. - Otherwise, REGNO specifies which register (so we can save time). */ - -store_inferior_registers (regno) - int regno; -{ - struct regs inferior_registers; - struct fp_status inferior_fp_registers; - extern char registers[]; - - bcopy (registers, &inferior_registers, 16 * 4); - bcopy (®isters[REGISTER_BYTE (FP0_REGNUM)], &inferior_fp_registers, - sizeof inferior_fp_registers.fps_regs); - inferior_registers.r_ps = *(int *)®isters[REGISTER_BYTE (PS_REGNUM)]; - inferior_registers.r_pc = *(int *)®isters[REGISTER_BYTE (PC_REGNUM)]; - bcopy (®isters[REGISTER_BYTE (FPC_REGNUM)], - &inferior_fp_registers.fps_control, - sizeof inferior_fp_registers - sizeof inferior_fp_registers.fps_regs); - - ptrace (PTRACE_SETREGS, inferior_pid, &inferior_registers); - if (errno) - perror_with_name ("ptrace"); - ptrace (PTRACE_SETFPREGS, inferior_pid, &inferior_fp_registers); - if (errno) - perror_with_name ("ptrace"); -} - -#endif /* not NEW_SUN_PTRACE */ - - -/* NOTE! I tried using PTRACE_READDATA, etc., to read and write memory - in the NEW_SUN_PTRACE case. - It ought to be straightforward. But it appears that writing did - not write the data that I specified. I cannot understand where - it got the data that it actually did write. */ - -/* Copy LEN bytes from inferior's memory starting at MEMADDR - to debugger memory starting at MYADDR. */ - -read_inferior_memory (memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - register int i; - /* Round starting address down to longword boundary. */ - register CORE_ADDR addr = memaddr & - sizeof (int); - /* Round ending address up; get number of longwords that makes. */ - register int count - = (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (int); - /* Allocate buffer of that many longwords. */ - register int *buffer = (int *) alloca (count * sizeof (int)); - - /* Read all the longwords */ - for (i = 0; i < count; i++, addr += sizeof (int)) - { - buffer[i] = ptrace (1, inferior_pid, addr, 0); - } - - /* Copy appropriate bytes out of the buffer. */ - bcopy ((char *) buffer + (memaddr & (sizeof (int) - 1)), myaddr, len); -} - -/* Copy LEN bytes of data from debugger memory at MYADDR - to inferior's memory at MEMADDR. - On failure (cannot write the inferior) - returns the value of errno. */ - -int -write_inferior_memory (memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - register int i; - /* Round starting address down to longword boundary. */ - register CORE_ADDR addr = memaddr & - sizeof (int); - /* Round ending address up; get number of longwords that makes. */ - register int count - = (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (int); - /* Allocate buffer of that many longwords. */ - register int *buffer = (int *) alloca (count * sizeof (int)); - extern int errno; - - /* Fill start and end extra bytes of buffer with existing memory data. */ - - buffer[0] = ptrace (1, inferior_pid, addr, 0); - - if (count > 1) - { - buffer[count - 1] - = ptrace (1, inferior_pid, - addr + (count - 1) * sizeof (int), 0); - } - - /* Copy data to be written over corresponding part of buffer */ - - bcopy (myaddr, (char *) buffer + (memaddr & (sizeof (int) - 1)), len); - - /* Write the entire buffer. */ - - for (i = 0; i < count; i++, addr += sizeof (int)) - { - errno = 0; - ptrace (4, inferior_pid, addr, buffer[i]); - if (errno) - return errno; - } - - return 0; -} - -void -try_writing_regs_command () -{ - register int i; - register int value; - extern int errno; - - if (inferior_pid == 0) - error ("There is no inferior process now."); - - fetch_inferior_registers(); - for (i = 0;i<18 ; i ++) - { - QUIT; - errno = 0; - value = read_register(i); - write_register ( i, value); - if (errno == 0) - { - printf (" Succeeded with register %d; value 0x%x (%d).\n", - i, value, value); - } - else - printf (" Failed with register %d.\n", i); - } -} - -void -initialize () -{ - - inferior_pid = 0; - - -} - - -/* Return the contents of register REGNO, - regarding it as an integer. */ - -CORE_ADDR -read_register (regno) - int regno; -{ - /* This loses when REGISTER_RAW_SIZE (regno) != sizeof (int) */ - return *(int *) ®isters[REGISTER_BYTE (regno)]; -} - -/* Store VALUE in the register number REGNO, regarded as an integer. */ - -void -write_register (regno, val) - int regno, val; -{ - /* This loses when REGISTER_RAW_SIZE (regno) != sizeof (int) */ - *(int *) ®isters[REGISTER_BYTE (regno)] = val; - - if (have_inferior_p ()) - store_inferior_registers (regno); -} - - -int -have_inferior_p () -{ - return inferior_pid != 0; -} - -print_some_registers(regs) -int regs[]; -{ - register int i; - for (i = 0; i < 18; i++) { - printf("reg[%d] = %x\n", i, regs[i]); - } -} - -SHAR_EOF -cat << \SHAR_EOF > remote_server.c -/* Main code for remote server for GDB, the GNU Debugger. - Copyright (C) 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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 1, or (at your option) -any later version. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include "param.h" -#include - -void read_inferior_memory(), fetch_inferior_registers(); -unsigned char resume(); -void kill_inferior(); -void initialize(), try_writing_regs_command(); -int create_inferior(), read_register(); - -extern char registers[]; -int inferior_pid; -extern char **environ; - -/* Descriptor for I/O to remote machine. */ -int remote_desc; -int kiodebug = 0; -int remote_debugging; - -void remote_send (); -void putpkt (); -void getpkt (); -void remote_open(); -void write_ok(); -void write_enn(); -void convert_ascii_to_int(); -void convert_int_to_ascii(); -void prepare_resume_reply(); -void decode_m_packet(); -void decode_M_packet(); - - -main(argc,argv) -int argc; char *argv[]; -{ - char ch,status, own_buf[2000], mem_buf[2000]; - int i=0; - unsigned char signal; - unsigned int mem_addr, len; - - initialize(); - printf("\nwill open serial link\n"); - remote_open("/dev/ttya",0); - - if(argc < 2) - { - printf("Enter name of program to be run with command line args\n"); - gets(own_buf); - inferior_pid = create_inferior(own_buf,environ); - printf("\nProcess %s created; pid = %d\n",own_buf,inferior_pid); - } - else - { - inferior_pid = create_inferior(argv[1],environ); - printf("\nProcess %s created; pid = %d\n",argv[1],inferior_pid); - } - - do { - getpkt(own_buf); - printf("\nPacket received is>:%s\n",own_buf); - i = 0; - ch = own_buf[i++]; - switch (ch) { - case 'h': /**********This is only for tweaking the gdb+ program *******/ - signal = resume(1,0,&status); - prepare_resume_reply(own_buf,status,signal); - break; - /*************end tweak*************************************/ - - case 'g': fetch_inferior_registers(); - convert_int_to_ascii(registers,own_buf,REGISTER_BYTES); - break; - case 'G': convert_ascii_to_int(&own_buf[1],registers,REGISTER_BYTES); - if(store_inferior_registers(-1)==0) - write_ok(own_buf); - else - write_enn(own_buf); - break; - case 'm': decode_m_packet(&own_buf[1],&mem_addr,&len); - read_inferior_memory(mem_addr,mem_buf,len); - convert_int_to_ascii(mem_buf,own_buf,len); - break; - case 'M': decode_M_packet(&own_buf[1],&mem_addr,&len,mem_buf); - if(write_inferior_memory(mem_addr,mem_buf,len)==0) - write_ok(own_buf); - else - write_enn(own_buf); - break; - case 'c': signal = resume(0,0,&status); - printf("\nSignal received is >: %0x \n",signal); - prepare_resume_reply(own_buf,status,signal); - break; - case 's': signal = resume(1,0,&status); - prepare_resume_reply(own_buf,status,signal); - break; - case 'k': kill_inferior(); - sprintf(own_buf,"q"); - putpkt(own_buf); - printf("\nObtained kill request...terminating\n"); - close(remote_desc); - exit(0); - case 't': try_writing_regs_command(); - own_buf[0] = '\0'; - break; - default : printf("\nUnknown option chosen by master\n"); - write_enn(own_buf); - break; - } - - putpkt(own_buf); - } while(1) ; - - close(remote_desc); - /** now get out of here**/ - printf("\nFinished reading data from serial link - Bye!\n"); - exit(0); - -} - -SHAR_EOF -cat << \SHAR_EOF > remote_utils.c -/* Remote utility routines for the remote server for GDB, the GNU debugger. - Copyright (C) 1986, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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 1, or (at your option) -any later version. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include "param.h" -#include -#include -#include -#include -#include -#include -#include - -extern int remote_desc; -extern int remote_debugging; -extern int kiodebug; - -void remote_open(); -void remote_send(); -void putpkt(); -void getpkt(); - -void write_ok(); -void write_enn(); -void convert_ascii_to_int(); -void convert_int_to_ascii(); -void prepare_resume_reply(); - -/* Open a connection to a remote debugger. - NAME is the filename used for communication. */ - -void -remote_open (name, from_tty) - char *name; - int from_tty; -{ - struct sgttyb sg; - - remote_debugging = 0; - - remote_desc = open (name, O_RDWR); - if (remote_desc < 0) - printf("\ncould not open remote device\n"); - - ioctl (remote_desc, TIOCGETP, &sg); - sg.sg_flags = RAW; - ioctl (remote_desc, TIOCSETP, &sg); - - if (from_tty) - printf ("Remote debugging using %s\n", name); - remote_debugging = 1; -} - -/* Convert hex digit A to a number. */ - -static int -fromhex (a) - int a; -{ - if (a >= '0' && a <= '9') - return a - '0'; - else if (a >= 'a' && a <= 'f') - return a - 'a' + 10; - else - perror ("Reply contains invalid hex digit"); -} - -/* Convert number NIB to a hex digit. */ - -static int -tohex (nib) - int nib; -{ - if (nib < 10) - return '0'+nib; - else - return 'a'+nib-10; -} - -/* Send the command in BUF to the remote machine, - and read the reply into BUF. - Report an error if we get an error reply. */ - -void -remote_send (buf) - char *buf; -{ - putpkt (buf); - getpkt (buf); - - if (buf[0] == 'E') - perror ("Remote failure reply: %s", buf); -} - -/* Send a packet to the remote machine, with error checking. - The data of the packet is in BUF. */ - -void -putpkt (buf) - char *buf; -{ - int i; - unsigned char csum = 0; - char buf2[500]; - char buf3[1]; - int cnt = strlen (buf); - char *p; - - if (kiodebug) - fprintf (stderr, "Sending packet: %s\n", buf); - - /* Copy the packet into buffer BUF2, encapsulating it - and giving it a checksum. */ - - p = buf2; - *p++ = '$'; - - for (i = 0; i < cnt; i++) - { - csum += buf[i]; - *p++ = buf[i]; - } - *p++ = '#'; - *p++ = tohex ((csum >> 4) & 0xf); - *p++ = tohex (csum & 0xf); - - /* Send it over and over until we get a positive ack. */ - - do { - write (remote_desc, buf2, p - buf2); - read (remote_desc, buf3, 1); - } while (buf3[0] != '+'); -} - -static int -readchar () -{ - char buf[1]; - while (read (remote_desc, buf, 1) != 1) ; - return buf[0] & 0x7f; -} - -/* Read a packet from the remote machine, with error checking, - and store it in BUF. */ - -void -getpkt (buf) - char *buf; -{ - char *bp; - unsigned char csum, c, c1, c2; - extern kiodebug; - - while (1) - { - csum = 0; - while ((c = readchar()) != '$'); - - bp = buf; - while (1) - { - c = readchar (); - if (c == '#') - break; - *bp++ = c; - csum += c; - } - *bp = 0; - - c1 = fromhex (readchar ()); - c2 = fromhex (readchar ()); - if (csum == (c1 << 4) + c2) - break; - - printf ("Bad checksum, sentsum=0x%x, csum=0x%x, buf=%s\n", - (c1 << 4) + c2, csum, buf); - write (remote_desc, "-", 1); - } - - write (remote_desc, "+", 1); - - if (kiodebug) - fprintf (stderr,"Packet received :%s\n", buf); -} - - -void -write_ok(buf) - char *buf; -{ - buf[0] = 'O'; - buf[1] = 'k'; - buf[2] = '\0'; -} - -void -write_enn(buf) - char *buf; -{ - buf[0] = 'E'; - buf[1] = 'N'; - buf[2] = 'N'; - buf[3] = '\0'; -} - -void -convert_int_to_ascii(from,to,n) -char *from, *to; int n; -{ - int nib ; - char ch; - while( n-- ) - { - ch = *from++; - nib = ((ch & 0xf0) >> 4)& 0x0f; - *to++ = tohex(nib); - nib = ch & 0x0f; - *to++ = tohex(nib); - } - *to++ = 0; -} - - -void -convert_ascii_to_int(from,to,n) -char *from, *to; int n; -{ - int nib1,nib2 ; - while( n-- ) - { - nib1 = fromhex(*from++); - nib2 = fromhex(*from++); - *to++ = (((nib1 & 0x0f)<< 4)& 0xf0) | (nib2 & 0x0f); - } -} - -void -prepare_resume_reply(buf,status,signal) -char *buf ,status; -unsigned char signal; -{ - int nib; - char ch; - - *buf++ = 'S'; - *buf++ = status; - nib = ((signal & 0xf0) >> 4) ; - *buf++ = tohex(nib); - nib = signal & 0x0f; - *buf++ = tohex(nib); - *buf++ = 0; -} - -void -decode_m_packet(from,mem_addr_ptr,len_ptr) -char *from; -unsigned int *mem_addr_ptr, *len_ptr; -{ - int i = 0, j = 0 ; - char ch; - *mem_addr_ptr = *len_ptr = 0; - /************debugging begin************/ - printf("\nIn decode_m_packet"); - /************debugging end************/ - - while((ch = from[i++]) != ',') - { - *mem_addr_ptr = *mem_addr_ptr << 4; - *mem_addr_ptr |= fromhex(ch) & 0x0f; - } - /************debugging begin************/ - printf("\nFinished mem_addr part"); - /************debugging end************/ - - for(j=0; j < 4; j++) - { - if((ch = from[i++]) == 0) - break; - *len_ptr = *len_ptr << 4; - *len_ptr |= fromhex(ch) & 0x0f; - } - /************debugging begin************/ - printf("\nFinished len_ptr part"); - /************debugging end************/ -} - -void -decode_M_packet(from,mem_addr_ptr,len_ptr,to) -char *from, *to; -unsigned int *mem_addr_ptr, *len_ptr; -{ - int i = 0, j = 0 ; - char ch; - *mem_addr_ptr = *len_ptr = 0; - /************debugging begin************/ - printf("\nIn decode_M_packet"); - /************debugging end************/ - - while((ch = from[i++]) != ',') - { - *mem_addr_ptr = *mem_addr_ptr << 4; - *mem_addr_ptr |= fromhex(ch) & 0x0f; - } - /************debugging begin************/ - printf("\nFinished mem_addr part: memaddr = %x",*mem_addr_ptr); - /************debugging end************/ - - while((ch = from[i++]) != ':') - { - *len_ptr = *len_ptr << 4; - *len_ptr |= fromhex(ch) & 0x0f; - } - /************debugging begin************/ - printf("\nFinished len_ptr part: len = %d",*len_ptr); - /************debugging end************/ - - convert_ascii_to_int(&from[i++],to,*len_ptr); - - /************debugging begin************/ - printf("\nmembuf : %x",*(int *)to); - /************debugging end************/ -} - -SHAR_EOF -# End of shell archive -exit 0 diff --git a/gdb/remote-nindy.c b/gdb/remote-nindy.c deleted file mode 100644 index 34bb3d25941..00000000000 --- a/gdb/remote-nindy.c +++ /dev/null @@ -1,969 +0,0 @@ -/* Memory-access and commands for remote NINDY process, for GDB. - Copyright (C) 1990-1991 Free Software Foundation, Inc. - Contributed by Intel Corporation. Modified from remote.c by Chris Benenati. - -GDB is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY. No author or distributor accepts responsibility to anyone -for the consequences of using it or for whether it serves any -particular purpose or works at all, unless he says so in writing. -Refer to the GDB General Public License for full details. - -Everyone is granted permission to copy, modify and redistribute GDB, -but only under the conditions described in the GDB General Public -License. A copy of this license is supposed to have been given to you -along with GDB so you can know your rights and responsibilities. It -should be in a file named COPYING. Among other things, the copyright -notice and this notice must be preserved on all copies. - -In other words, go ahead and share GDB, but don't try to stop -anyone else from sharing it farther. Help stamp out software hoarding! -*/ - -/* -Except for the data cache routines, this file bears little resemblence -to remote.c. A new (although similar) protocol has been specified, and -portions of the code are entirely dependent on having an i80960 with a -NINDY ROM monitor at the other end of the line. -*/ - -/***************************************************************************** - * - * REMOTE COMMUNICATION PROTOCOL BETWEEN GDB960 AND THE NINDY ROM MONITOR. - * - * - * MODES OF OPERATION - * ----- -- --------- - * - * As far as NINDY is concerned, GDB is always in one of two modes: command - * mode or passthrough mode. - * - * In command mode (the default) pre-defined packets containing requests - * are sent by GDB to NINDY. NINDY never talks except in reponse to a request. - * - * Once the the user program is started, GDB enters passthrough mode, to give - * the user program access to the terminal. GDB remains in this mode until - * NINDY indicates that the program has stopped. - * - * - * PASSTHROUGH MODE - * ----------- ---- - * - * GDB writes all input received from the keyboard directly to NINDY, and writes - * all characters received from NINDY directly to the monitor. - * - * Keyboard input is neither buffered nor echoed to the monitor. - * - * GDB remains in passthrough mode until NINDY sends a single ^P character, - * to indicate that the user process has stopped. - * - * Note: - * GDB assumes NINDY performs a 'flushreg' when the user program stops. - * - * - * COMMAND MODE - * ------- ---- - * - * All info (except for message ack and nak) is transferred between gdb - * and the remote processor in messages of the following format: - * - * # - * - * where - * # is a literal character - * - * ASCII information; all numeric information is in the - * form of hex digits ('0'-'9' and lowercase 'a'-'f'). - * - * - * is a pair of ASCII hex digits representing an 8-bit - * checksum formed by adding together each of the - * characters in . - * - * The receiver of a message always sends a single character to the sender - * to indicate that the checksum was good ('+') or bad ('-'); the sender - * re-transmits the entire message over until a '+' is received. - * - * In response to a command NINDY always sends back either data or - * a result code of the form "Xnn", where "nn" are hex digits and "X00" - * means no errors. (Exceptions: the "s" and "c" commands don't respond.) - * - * SEE THE HEADER OF THE FILE "gdb.c" IN THE NINDY MONITOR SOURCE CODE FOR A - * FULL DESCRIPTION OF LEGAL COMMANDS. - * - * SEE THE FILE "stop.h" IN THE NINDY MONITOR SOURCE CODE FOR A LIST - * OF STOP CODES. - * - ******************************************************************************/ - -#include -#include -#include -#include - -#include "defs.h" -#include "param.h" -#include "frame.h" -#include "inferior.h" -#include "target.h" -#include "gdbcore.h" -#include "command.h" -#include "bfd.h" -#include "ieee-float.h" - -#include "wait.h" -#include -#include -#include -#include "nindy-share/ttycntl.h" -#include "nindy-share/demux.h" -#include "nindy-share/env.h" -#include "nindy-share/stop.h" - -extern int unlink(); -extern char *getenv(); -extern char *mktemp(); - -extern char *coffstrip(); -extern value call_function_by_hand (); -extern void generic_mourn_inferior (); - -extern struct target_ops nindy_ops; -extern jmp_buf to_top_level; -extern FILE *instream; -extern struct ext_format ext_format_i960; /* i960-tdep.c */ - -extern char ninStopWhy (); - -int nindy_initial_brk; /* nonzero if want to send an initial BREAK to nindy */ -int nindy_old_protocol; /* nonzero if want to use old protocol */ -char *nindy_ttyname; /* name of tty to talk to nindy on, or null */ - -#define DLE '\020' /* Character NINDY sends to indicate user program has - * halted. */ -#define TRUE 1 -#define FALSE 0 - -int nindy_fd = 0; /* Descriptor for I/O to NINDY */ -static int have_regs = 0; /* 1 iff regs read since i960 last halted */ -static int regs_changed = 0; /* 1 iff regs were modified since last read */ - -extern char *exists(); -static void dcache_flush (), dcache_poke (), dcache_init(); -static int dcache_fetch (); - -/* FIXME, we can probably use the normal terminal_inferior stuff here. - We have to do terminal_inferior and then set up the passthrough - settings initially. Thereafter, terminal_ours and terminal_inferior - will automatically swap the settings around for us. */ - -/* Restore TTY to normal operation */ - -static TTY_STRUCT orig_tty; /* TTY attributes before entering passthrough */ - -static void -restore_tty() -{ - ioctl( 0, TIOCSETN, &orig_tty ); -} - - -/* Recover from ^Z or ^C while remote process is running */ - -static void (*old_ctrlc)(); /* Signal handlers before entering passthrough */ - -#ifdef SIGTSTP -static void (*old_ctrlz)(); -#endif - -static -#ifdef USG -void -#endif -cleanup() -{ - restore_tty(); - signal(SIGINT, old_ctrlc); -#ifdef SIGTSTP - signal(SIGTSTP, old_ctrlz); -#endif - error("\n\nYou may need to reset the 80960 and/or reload your program.\n"); -} - -/* Clean up anything that needs cleaning when losing control. */ - -static char *savename; - -static void -nindy_close (quitting) - int quitting; -{ - if (nindy_fd) - close (nindy_fd); - nindy_fd = 0; - - if (savename) - free (savename); - savename = 0; -} - -/* Open a connection to a remote debugger. - FIXME, there should be a way to specify the various options that are - now specified with gdb command-line options. (baud_rate, old_protocol, - and initial_brk) */ -void -nindy_open (name, from_tty) - char *name; /* "/dev/ttyXX", "ttyXX", or "XX": tty to be opened */ - int from_tty; -{ - - if (!name) - error_no_arg ("serial port device name"); - - target_preopen (from_tty); - - nindy_close (0); - - have_regs = regs_changed = 0; - dcache_init(); - - /* Allow user to interrupt the following -- we could hang if - * there's no NINDY at the other end of the remote tty. - */ - immediate_quit++; - nindy_fd = ninConnect( name, baud_rate? baud_rate: "9600", - nindy_initial_brk, !from_tty, nindy_old_protocol ); - immediate_quit--; - - if ( nindy_fd < 0 ){ - nindy_fd = 0; - error( "Can't open tty '%s'", name ); - } - - savename = savestring (name, strlen (name)); - push_target (&nindy_ops); - target_fetch_registers(-1); -} - -/* User-initiated quit of nindy operations. */ - -static void -nindy_detach (name, from_tty) - char *name; - int from_tty; -{ - if (name) - error ("Too many arguments"); - pop_target (); -} - -static void -nindy_files_info () -{ - printf("\tAttached to %s at %s bps%s%s.\n", savename, - baud_rate? baud_rate: "9600", - nindy_old_protocol? " in old protocol": "", - nindy_initial_brk? " with initial break": ""); -} - -/****************************************************************************** - * remote_load: - * Download an object file to the remote system by invoking the "comm960" - * utility. We look for "comm960" in $G960BIN, $G960BASE/bin, and - * DEFAULT_BASE/bin/HOST/bin where - * DEFAULT_BASE is defined in env.h, and - * HOST must be defined on the compiler invocation line. - ******************************************************************************/ - -static void -nindy_load( filename, from_tty ) - char *filename; - int from_tty; -{ - char *tmpfile; - struct cleanup *old_chain; - char *scratch_pathname; - int scratch_chan; - - if (!filename) - filename = get_exec_file (1); - - filename = tilde_expand (filename); - make_cleanup (free, filename); - - scratch_chan = openp (getenv ("PATH"), 1, filename, O_RDONLY, 0, - &scratch_pathname); - if (scratch_chan < 0) - perror_with_name (filename); - close (scratch_chan); /* Slightly wasteful FIXME */ - - have_regs = regs_changed = 0; - mark_breakpoints_out(); - inferior_pid = 0; - dcache_flush(); - - tmpfile = coffstrip(scratch_pathname); - if ( tmpfile ){ - old_chain = make_cleanup(unlink,tmpfile); - immediate_quit++; - ninDownload( tmpfile, !from_tty ); -/* FIXME, don't we want this merged in here? */ - immediate_quit--; - do_cleanups (old_chain); - } -} - - - -/* Return the number of characters in the buffer before the first DLE character. - */ - -static -int -non_dle( buf, n ) - char *buf; /* Character buffer; NOT '\0'-terminated */ - int n; /* Number of characters in buffer */ -{ - int i; - - for ( i = 0; i < n; i++ ){ - if ( buf[i] == DLE ){ - break; - } - } - return i; -} - -/* Tell the remote machine to resume. */ - -void -nindy_resume (step, siggnal) - int step, siggnal; -{ - if (siggnal != 0 && siggnal != stop_signal) - error ("Can't send signals to remote NINDY targets."); - - dcache_flush(); - if ( regs_changed ){ - nindy_store_registers (); - regs_changed = 0; - } - have_regs = 0; - ninGo( step ); -} - -/* Wait until the remote machine stops. While waiting, operate in passthrough - * mode; i.e., pass everything NINDY sends to stdout, and everything from - * stdin to NINDY. - * - * Return to caller, storing status in 'status' just as `wait' would. - */ - -void -nindy_wait( status ) - WAITTYPE *status; -{ - DEMUX_DECL; /* OS-dependent data needed by DEMUX... macros */ - char buf[500]; /* FIXME, what is "500" here? */ - int i, n; - unsigned char stop_exit; - unsigned char stop_code; - TTY_STRUCT tty; - long ip_value, fp_value, sp_value; /* Reg values from stop */ - - - WSETEXIT( (*status), 0 ); - - /* OPERATE IN PASSTHROUGH MODE UNTIL NINDY SENDS A DLE CHARACTER */ - - /* Save current tty attributes, set up signals to restore them. - */ - ioctl( 0, TIOCGETP, &orig_tty ); - old_ctrlc = signal( SIGINT, cleanup ); -#ifdef SIGTSTP - old_ctrlz = signal( SIGTSTP, cleanup ); -#endif - - /* Pass input from keyboard to NINDY as it arrives. - * NINDY will interpret and perform echo. - */ - tty = orig_tty; - TTY_NINDYTERM( tty ); - ioctl( 0, TIOCSETN, &tty ); - - while ( 1 ){ - /* Go to sleep until there's something for us on either - * the remote port or stdin. - */ - - DEMUX_WAIT( nindy_fd ); - - /* Pass input through to correct place */ - - n = DEMUX_READ( 0, buf, sizeof(buf) ); - if ( n ){ /* Input on stdin */ - write( nindy_fd, buf, n ); - } - - n = DEMUX_READ( nindy_fd, buf, sizeof(buf) ); - if ( n ){ /* Input on remote */ - /* Write out any characters in buffer preceding DLE */ - i = non_dle( buf, n ); - if ( i > 0 ){ - write( 1, buf, i ); - } - - if ( i != n ){ - /* There *was* a DLE in the buffer */ - stop_exit = ninStopWhy( &stop_code, - &ip_value, &fp_value, &sp_value); - if ( !stop_exit && (stop_code==STOP_SRQ) ){ - immediate_quit++; - ninSrq(); - immediate_quit--; - } else { - /* Get out of loop */ - supply_register (IP_REGNUM, &ip_value); - supply_register (FP_REGNUM, &fp_value); - supply_register (SP_REGNUM, &sp_value); - break; - } - } - } - } - - signal( SIGINT, old_ctrlc ); -#ifdef SIGTSTP - signal( SIGTSTP, old_ctrlz ); -#endif - restore_tty(); - - if ( stop_exit ){ /* User program exited */ - WSETEXIT( (*status), stop_code ); - } else { /* Fault or trace */ - switch (stop_code){ - case STOP_GDB_BPT: - case TRACE_STEP: - /* Make it look like a VAX trace trap */ - stop_code = SIGTRAP; - break; - default: - /* The target is not running Unix, and its - faults/traces do not map nicely into Unix signals. - Make sure they do not get confused with Unix signals - by numbering them with values higher than the highest - legal Unix signal. code in i960_print_fault(), - called via PRINT_RANDOM_SIGNAL, will interpret the - value. */ - stop_code += NSIG; - break; - } - WSETSTOP( (*status), stop_code ); - } -} - -/* Read the remote registers into the block REGS. */ - -/* This is the block that ninRegsGet and ninRegsPut handles. */ -struct nindy_regs { - char local_regs[16 * 4]; - char global_regs[16 * 4]; - char pcw_acw[2 * 4]; - char ip[4]; - char tcw[4]; - char fp_as_double[4 * 8]; -}; - -static int -nindy_fetch_registers(regno) - int regno; -{ - struct nindy_regs nindy_regs; - int regnum, inv; - double dub; - - immediate_quit++; - ninRegsGet( (char *) &nindy_regs ); - immediate_quit--; - - bcopy (nindy_regs.local_regs, ®isters[REGISTER_BYTE (R0_REGNUM)], 16*4); - bcopy (nindy_regs.global_regs, ®isters[REGISTER_BYTE (G0_REGNUM)], 16*4); - bcopy (nindy_regs.pcw_acw, ®isters[REGISTER_BYTE (PCW_REGNUM)], 2*4); - bcopy (nindy_regs.ip, ®isters[REGISTER_BYTE (IP_REGNUM)], 1*4); - bcopy (nindy_regs.tcw, ®isters[REGISTER_BYTE (TCW_REGNUM)], 1*4); - for (regnum = FP0_REGNUM; regnum < FP0_REGNUM + 4; regnum++) { - dub = unpack_double (builtin_type_double, - &nindy_regs.fp_as_double[8 * (regnum - FP0_REGNUM)], - &inv); - /* dub now in host byte order */ - double_to_ieee_extended (&ext_format_i960, &dub, - ®isters[REGISTER_BYTE (regnum)]); - } - - registers_fetched (); - return 0; -} - -static void -nindy_prepare_to_store() -{ - nindy_fetch_registers(-1); -} - -static int -nindy_store_registers(regno) - int regno; -{ - struct nindy_regs nindy_regs; - int regnum, inv; - double dub; - - bcopy (®isters[REGISTER_BYTE (R0_REGNUM)], nindy_regs.local_regs, 16*4); - bcopy (®isters[REGISTER_BYTE (G0_REGNUM)], nindy_regs.global_regs, 16*4); - bcopy (®isters[REGISTER_BYTE (PCW_REGNUM)], nindy_regs.pcw_acw, 2*4); - bcopy (®isters[REGISTER_BYTE (IP_REGNUM)], nindy_regs.ip, 1*4); - bcopy (®isters[REGISTER_BYTE (TCW_REGNUM)], nindy_regs.tcw, 1*4); - /* Float regs. Only works on IEEE_FLOAT hosts. */ - for (regnum = FP0_REGNUM; regnum < FP0_REGNUM + 4; regnum++) { - ieee_extended_to_double (&ext_format_i960, - ®isters[REGISTER_BYTE (regnum)], &dub); - /* dub now in host byte order */ - /* FIXME-someday, the arguments to unpack_double are backward. - It expects a target double and returns a host; we pass the opposite. - This mostly works but not quite. */ - dub = unpack_double (builtin_type_double, &dub, &inv); - /* dub now in target byte order */ - bcopy ((char *)&dub, &nindy_regs.fp_as_double[8 * (regnum - FP0_REGNUM)], - 8); - } - - immediate_quit++; - ninRegsPut( (char *) &nindy_regs ); - immediate_quit--; - return 0; -} - -/* Read a word from remote address ADDR and return it. - * This goes through the data cache. - */ -int -nindy_fetch_word (addr) - CORE_ADDR addr; -{ - return dcache_fetch (addr); -} - -/* Write a word WORD into remote address ADDR. - This goes through the data cache. */ - -void -nindy_store_word (addr, word) - CORE_ADDR addr; - int word; -{ - dcache_poke (addr, word); -} - -/* 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. Returns the length copied. - - This is stolen almost directly from infptrace.c's child_xfer_memory, - which also deals with a word-oriented memory interface. Sometime, - FIXME, rewrite this to not use the word-oriented routines. */ - -int -nindy_xfer_inferior_memory(memaddr, myaddr, len, write, target) - CORE_ADDR memaddr; - char *myaddr; - int len; - int write; - struct target_ops *target; /* ignored */ -{ - register int i; - /* Round starting address down to longword boundary. */ - register CORE_ADDR addr = memaddr & - sizeof (int); - /* Round ending address up; get number of longwords that makes. */ - register int count - = (((memaddr + len) - addr) + sizeof (int) - 1) / sizeof (int); - /* Allocate buffer of that many longwords. */ - register int *buffer = (int *) alloca (count * sizeof (int)); - - if (write) - { - /* Fill start and end extra bytes of buffer with existing memory data. */ - - if (addr != memaddr || len < (int)sizeof (int)) { - /* Need part of initial word -- fetch it. */ - buffer[0] = nindy_fetch_word (addr); - } - - if (count > 1) /* FIXME, avoid if even boundary */ - { - buffer[count - 1] - = nindy_fetch_word (addr + (count - 1) * sizeof (int)); - } - - /* Copy data to be written over corresponding part of buffer */ - - bcopy (myaddr, (char *) buffer + (memaddr & (sizeof (int) - 1)), len); - - /* Write the entire buffer. */ - - for (i = 0; i < count; i++, addr += sizeof (int)) - { - errno = 0; - nindy_store_word (addr, buffer[i]); - if (errno) - return 0; - } - } - else - { - /* Read all the longwords */ - for (i = 0; i < count; i++, addr += sizeof (int)) - { - errno = 0; - buffer[i] = nindy_fetch_word (addr); - if (errno) - return 0; - QUIT; - } - - /* Copy appropriate bytes out of the buffer. */ - bcopy ((char *) buffer + (memaddr & (sizeof (int) - 1)), myaddr, len); - } - return len; -} - -/* The data cache records all the data read from the remote machine - since the last time it stopped. - - Each cache block holds 16 bytes of data - starting at a multiple-of-16 address. */ - -#define DCACHE_SIZE 64 /* Number of cache blocks */ - -struct dcache_block { - struct dcache_block *next, *last; - unsigned int addr; /* Address for which data is recorded. */ - int data[4]; -}; - -struct dcache_block dcache_free, dcache_valid; - -/* Free all the data cache blocks, thus discarding all cached data. */ -static -void -dcache_flush () -{ - register struct dcache_block *db; - - while ((db = dcache_valid.next) != &dcache_valid) - { - remque (db); - insque (db, &dcache_free); - } -} - -/* - * If addr is present in the dcache, return the address of the block - * containing it. - */ -static -struct dcache_block * -dcache_hit (addr) - unsigned int addr; -{ - register struct dcache_block *db; - - if (addr & 3) - abort (); - - /* Search all cache blocks for one that is at this address. */ - db = dcache_valid.next; - while (db != &dcache_valid) - { - if ((addr & 0xfffffff0) == db->addr) - return db; - db = db->next; - } - return NULL; -} - -/* Return the int data at address ADDR in dcache block DC. */ -static -int -dcache_value (db, addr) - struct dcache_block *db; - unsigned int addr; -{ - if (addr & 3) - abort (); - return (db->data[(addr>>2)&3]); -} - -/* Get a free cache block, put or keep it on the valid list, - and return its address. The caller should store into the block - the address and data that it describes, then remque it from the - free list and insert it into the valid list. This procedure - prevents errors from creeping in if a ninMemGet is interrupted - (which used to put garbage blocks in the valid list...). */ -static -struct dcache_block * -dcache_alloc () -{ - register struct dcache_block *db; - - if ((db = dcache_free.next) == &dcache_free) - { - /* If we can't get one from the free list, take last valid and put - it on the free list. */ - db = dcache_valid.last; - remque (db); - insque (db, &dcache_free); - } - - remque (db); - insque (db, &dcache_valid); - return (db); -} - -/* Return the contents of the word at address ADDR in the remote machine, - using the data cache. */ -static -int -dcache_fetch (addr) - CORE_ADDR addr; -{ - register struct dcache_block *db; - - db = dcache_hit (addr); - if (db == 0) - { - db = dcache_alloc (); - immediate_quit++; - ninMemGet(addr & ~0xf, (unsigned char *)db->data, 16); - immediate_quit--; - db->addr = addr & ~0xf; - remque (db); /* Off the free list */ - insque (db, &dcache_valid); /* On the valid list */ - } - return (dcache_value (db, addr)); -} - -/* Write the word at ADDR both in the data cache and in the remote machine. */ -static void -dcache_poke (addr, data) - CORE_ADDR addr; - int data; -{ - register struct dcache_block *db; - - /* First make sure the word is IN the cache. DB is its cache block. */ - db = dcache_hit (addr); - if (db == 0) - { - db = dcache_alloc (); - immediate_quit++; - ninMemGet(addr & ~0xf, (unsigned char *)db->data, 16); - immediate_quit--; - db->addr = addr & ~0xf; - remque (db); /* Off the free list */ - insque (db, &dcache_valid); /* On the valid list */ - } - - /* Modify the word in the cache. */ - db->data[(addr>>2)&3] = data; - - /* Send the changed word. */ - immediate_quit++; - ninMemPut(addr, (unsigned char *)&data, 4); - immediate_quit--; -} - -/* The cache itself. */ -struct dcache_block the_cache[DCACHE_SIZE]; - -/* Initialize the data cache. */ -static void -dcache_init () -{ - register i; - register struct dcache_block *db; - - db = the_cache; - dcache_free.next = dcache_free.last = &dcache_free; - dcache_valid.next = dcache_valid.last = &dcache_valid; - for (i=0;i on Mon Jun 12 15:19:20 1989 -# -# This archive contains: -# remcom.c -# - -LANG=""; export LANG -PATH=/bin:/usr/bin:$PATH; export PATH - -echo x - remcom.c -cat >remcom.c <<'@EOF' - -/**************************************************************************** - - THIS SOFTWARE IS NOT COPYRIGHTED - - HP offers the following for use in the public domain. HP makes no - warranty with regard to the software or it's performance and the - user accepts the software "AS IS" with all faults. - - HP 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. - -****************************************************************************/ - -/**************************************************************************** - * $Header$ - * - * $Module name: remcom.c $ - * $Revision$ - * $Date$ - * $Contributor: Lake Stevens Instrument Division$ - * - * $Description: low level support for gdb debugger. $ - * - * $Considerations: only works on target hardware $ - * - * $Written by: Glenn Engel $ - * $ModuleState: Experimental $ - * - * $NOTES: See Below $ - * - * To enable debugger support, two things need to happen. One, a - * call to set_debug_traps() is necessary in order to allow any breakpoints - * or error conditions to be properly intercepted and reported to gdb. - * Two, a breakpoint needs to be generated to begin communication. This - * is most easily accomplished by a call to breakpoint(). Breakpoint() - * simulates a breakpoint by executing a trap #1. - * - * Some explanation is probably necessary to explain how exceptions are - * handled. When an exception is encountered the 68000 pushes the current - * program counter and status register onto the supervisor stack and then - * transfers execution to a location specified in it's vector table. - * The handlers for the exception vectors are hardwired to jmp to an address - * given by the relation: (exception - 256) * 6. These are decending - * addresses starting from -6, -12, -18, ... By allowing 6 bytes for - * each entry, a jsr, jmp, bsr, ... can be used to enter the exception - * handler. Using a jsr to handle an exception has an added benefit of - * allowing a single handler to service several exceptions and use the - * return address as the key differentiation. The vector number can be - * computed from the return address by [ exception = (addr + 1530) / 6 ]. - * The sole purpose of the routine _catchException is to compute the - * exception number and push it on the stack in place of the return address. - * The external function exceptionHandler() is - * used to attach a specific handler to a specific 68k exception. - * For 68020 machines, the ability to have a return address around just - * so the vector can be determined is not necessary because the '020 pushes an - * extra word onto the stack containing the vector offset - * - * Because gdb will sometimes write to the stack area to execute function - * calls, this program cannot rely on using the supervisor stack so it - * uses it's own stack area reserved in the int array remcomStack. - * - ************* - * - * The following gdb commands are supported: - * - * command function Return value - * - * g return the value of the CPU registers hex data or ENN - * G set the value of the CPU registers OK or ENN - * - * mAA..AA,LLLL Read LLLL bytes at address AA..AA hex data or ENN - * MAA..AA,LLLL: Write LLLL bytes at address AA.AA OK or ENN - * - * c Resume at current address SNN ( signal NN) - * cAA..AA Continue at address AA..AA SNN - * - * s Step one instruction SNN - * sAA..AA Step one instruction from AA..AA SNN - * - * k kill - * - * ? What was the last sigval ? SNN (signal NN) - * - * All commands and responses are sent with a packet which includes a - * checksum. A packet consists of - * - * $#. - * - * where - * :: - * :: < two hex digits computed as modulo 256 sum of > - * - * When a packet is received, it is first acknowledged with either '+' or '-'. - * '+' indicates a successful transfer. '-' indicates a failed transfer. - * - * Example: - * - * Host: Reply: - * $m0,10#2a +$00010203040506070809101112131415#42 - * - ****************************************************************************/ - -#include -#include -#include - -/************************************************************************ - * - * external low-level support routines - */ -typedef void (*ExceptionHook)(int); /* pointer to function with int parm */ -typedef void (*Function)(); /* pointer to a function */ - -extern putDebugChar(); /* write a single character */ -extern getDebugChar(); /* read and return a single char */ - -extern Function exceptionHandler(); /* assign an exception handler */ -extern ExceptionHook exceptionHook; /* hook variable for errors/exceptions */ - - -/************************************************************************/ -/* BUFMAX defines the maximum number of characters in inbound/outbound buffers*/ -/* at least NUMREGBYTES*2 are needed for register packets */ -#define BUFMAX 400 - -static char initialized; /* boolean flag. != 0 means we've been initialized */ - -int remote_debug = 0; -/* debug > 0 prints ill-formed commands in valid packets & checksum errors */ - -char hexchars[]="0123456789abcdef"; - -/* there are 180 bytes of registers on a 68020 w/68881 */ -/* many of the fpa registers are 12 byte (96 bit) registers */ -#define NUMREGBYTES 180 -enum regnames {D0,D1,D2,D3,D4,D5,D6,D7, - A0,A1,A2,A3,A4,A5,A6,A7, - PS,PC, - FP0,FP1,FP2,FP3,FP4,FP5,FP6,FP7, - FPCONTROL,FPSTATUS,FPIADDR - }; - -typedef struct FrameStruct -{ - struct FrameStruct *previous; - int exceptionPC; /* pc value when this frame created */ - int exceptionVector; /* cpu vector causing exception */ - short frameSize; /* size of cpu frame in words */ - short sr; /* for 68000, this not always sr */ - int pc; - short format; - int fsaveHeader; - int morejunk[0]; /* exception frame, fp save... */ -} Frame; - -#define FRAMESIZE 500 -static Frame *lastFrame; -static int frameStack[FRAMESIZE]; - -/* - * these should not be static cuz they can be used outside this module - */ -int registers[NUMREGBYTES/4]; -int superStack; - -static int remcomStack[400]; -static int* stackPtr = &remcomStack[399]; - -/* - * In many cases, the system will want to continue exception processing - * when a continue command is given. - * oldExceptionHook is a function to invoke in this case. - */ - -static ExceptionHook oldExceptionHook; - -/* the size of the exception stack on the 68020 varies with the type of - * exception. The following table is the number of WORDS used - * for each exception format. - */ -static short exceptionSize[] = { 4,4,6,4,4,4,4,4,29,10,16,46,4,4,4,4 }; - -/************* jump buffer used for setjmp/longjmp **************************/ -jmp_buf env; - -/*************************** ASSEMBLY CODE MACROS *************************/ -/* */ - -#ifdef __HAVE_68881__ -/* do an fsave, then remember the address to begin a restore from */ -#define SAVE_FP_REGS() asm(" fsave a0@-"); \ - asm(" fmovemx fp0-fp7,_registers+72"); \ - asm(" fmoveml fpcr/fpsr/fpi,_registers+168"); -#define RESTORE_FP_REGS() asm(" fmoveml _registers+168,fpcr/fpsr/fpi"); \ - asm(" fmovemx _registers+72,fp0-fp7"); \ - asm(" frestore a0@+"); -#else -#define SAVE_FP_REGS() -#define RESTORE_FP_REGS() -#endif /* __HAVE_68881__ */ - -asm(" -.text -.globl _return_to_super -_return_to_super: - movel _registers+60,sp /* get new stack pointer */ - movel _lastFrame,a0 /* get last frame info */ - bra return_to_any - -.globl _return_to_user -_return_to_user: - movel _registers+60,a0 /* get usp */ - movel a0,usp /* set usp */ - movel _superStack,sp /* get original stack pointer */ - -return_to_any: - movel _lastFrame,a0 /* get last frame info */ - movel a0@+,_lastFrame /* link in previous frame */ - addql #8,a0 /* skip over pc, vector#*/ - movew a0@+,d0 /* get # of words in cpu frame */ - addw d0,a0 /* point to end of data */ - addw d0,a0 /* point to end of data */ - movel a0,a1 -# -# copy the stack frame - subql #1,d0 -copyUserLoop: - movew a1@-,sp@- - dbf d0,copyUserLoop -"); - RESTORE_FP_REGS() - asm(" moveml _registers,d0-d7/a0-a6"); - asm(" rte"); /* pop and go! */ - -#define DISABLE_INTERRUPTS() asm(" oriw #0x0700,sr"); -#define BREAKPOINT() asm(" trap #1"); - -/* this function is called immediately when a level 7 interrupt occurs */ -/* if the previous interrupt level was 7 then we're already servicing */ -/* this interrupt and an rte is in order to return to the debugger. */ -/* For the 68000, the offset for sr is 6 due to the jsr return address */ -asm(" -.text -.globl __debug_level7 -__debug_level7: - movew d0,sp@-"); -#ifdef mc68020 -asm(" movew sp@(2),d0"); -#else -asm(" movew sp@(6),d0"); -#endif -asm(" andiw #0x700,d0 - cmpiw #0x700,d0 - beq _already7 - movew sp@+,d0 - bra __catchException -_already7: - movew sp@+,d0"); -#ifndef mc68020 -asm(" lea sp@(4),sp"); /* pull off 68000 return address */ -#endif -asm(" rte"); - -extern void _catchException(); - -#ifdef mc68020 -/* This function is called when a 68020 exception occurs. It saves - * all the cpu and fpcp regs in the _registers array, creates a frame on a - * linked list of frames which has the cpu and fpcp stack frames needed - * to properly restore the context of these processors, and invokes - * an exception handler (remcom_handler). - * - * stack on entry: stack on exit: - * N bytes of junk exception # MSWord - * Exception Format Word exception # MSWord - * Program counter LSWord - * Program counter MSWord - * Status Register - * - * - */ -asm(" -.text -.globl __catchException -__catchException:"); -DISABLE_INTERRUPTS(); -asm(" - moveml d0-d7/a0-a6,_registers /* save registers */ - movel _lastFrame,a0 /* last frame pointer */ -"); -SAVE_FP_REGS(); -asm(" - lea _registers,a5 /* get address of registers */ - movew sp@,d1 /* get status register */ - movew d1,a5@(66) /* save sr */ - movel sp@(2),a4 /* save pc in a4 for later use */ - movel a4,a5@(68) /* save pc in _regisers[] */ - -# -# figure out how many bytes in the stack frame - movew sp@(6),d0 /* get '020 exception format */ - movew d0,d2 /* make a copy of format word */ - andiw #0xf000,d0 /* mask off format type */ - rolw #5,d0 /* rotate into the low byte *2 */ - lea _exceptionSize,a1 - addw d0,a1 /* index into the table */ - movew a1@,d0 /* get number of words in frame */ - movew d0,d3 /* save it */ - subw d0,a0 /* adjust save pointer */ - subw d0,a0 /* adjust save pointer(bytes) */ - movel a0,a1 /* copy save pointer */ - subql #1,d0 /* predecrement loop counter */ -# -# copy the frame -saveFrameLoop: - movew sp@+,a1@+ - dbf d0,saveFrameLoop -# -# now that the stack has been clenaed, -# save the a7 in use at time of exception - movel sp,_superStack /* save supervisor sp */ - andiw #0x2000,d1 /* were we in supervisor mode ? */ - beq userMode - movel a7,a5@(60) /* save a7 */ - bra a7saveDone -userMode: - movel usp,a1 - movel a1,a5@(60) /* save user stack pointer */ -a7saveDone: - -# -# save size of frame - movew d3,a0@- - -# -# compute exception number - andl #0xfff,d2 /* mask off vector offset */ - lsrw #2,d2 /* divide by 4 to get vect num */ - movel d2,a0@- /* save it */ -# -# save pc causing exception - movel a4,a0@- -# -# save old frame link and set the new value - movel _lastFrame,a1 /* last frame pointer */ - movel a1,a0@- /* save pointer to prev frame */ - movel a0,_lastFrame - - movel d2,sp@- /* push exception num */ - movel _exceptionHook,a0 /* get address of handler */ - jbsr a0@ /* and call it */ - jmp __returnFromException /* now, return */ -"); -#else /* mc68000 */ -/* This function is called when an exception occurs. It translates the - * return address found on the stack into an exception vector # which - * is then handled by either handle_exception or a system handler. - * _catchException provides a front end for both. - * - * stack on entry: stack on exit: - * Program counter MSWord exception # MSWord - * Program counter LSWord exception # MSWord - * Status Register - * Return Address MSWord - * Return Address LSWord - */ -asm(" -.text -.globl __catchException -__catchException:"); -DISABLE_INTERRUPTS(); -asm(" - moveml d0-d7/a0-a6,_registers /* save registers */ - movel _lastFrame,a0 /* last frame pointer */ -"); -SAVE_FP_REGS(); -asm(" - lea _registers,a5 /* get address of registers */ - movel sp@+,d2 /* pop return address */ - addl #1530,d2 /* convert return addr to */ - divs #6,d2 /* exception number */ - extl d2 - - moveql #3,d3 /* assume a three word frame */ - - cmpiw #3,d2 /* bus error or address error ? */ - bgt normal /* if >3 then normal error */ - movel sp@+,a0@- /* copy error info to frame buff*/ - movel sp@+,a0@- /* these are never used */ - moveql #7,d3 /* this is a 7 word frame */ - -normal: - movew sp@+,d1 /* pop status register */ - movel sp@+,a4 /* pop program counter */ - movew d1,a5@(66) /* save sr */ - movel a4,a5@(68) /* save pc in _regisers[] */ - movel a4,a0@- /* copy pc to frame buffer */ - movew d1,a0@- /* copy sr to frame buffer */ - - movel sp,_superStack /* save supervisor sp */ - - andiw #0x2000,d1 /* were we in supervisor mode ? */ - beq userMode - movel a7,a5@(60) /* save a7 */ - bra saveDone -userMode: - movel usp,a1 /* save user stack pointer */ - movel a1,a5@(60) /* save user stack pointer */ -saveDone: - - movew d3,a0@- /* push frame size in words */ - movel d2,a0@- /* push vector number */ - movel a4,a0@- /* push exception pc */ - -# -# save old frame link and set the new value - movel _lastFrame,a1 /* last frame pointer */ - movel a1,a0@- /* save pointer to prev frame */ - movel a0,_lastFrame - - movel d2,sp@- /* push exception num */ - movel _exceptionHook,a0 /* get address of handler */ - jbsr a0@ /* and call it */ - jmp __returnFromException /* now, return */ -"); -#endif - - -/* - * remcomHandler is a front end for handle_exception. It moves the - * stack pointer into an area reserved for debugger use in case the - * breakpoint happened in supervisor mode. - */ -asm("_remcomHandler:"); -asm(" addl #4,sp"); /* pop off return address */ -asm(" movel sp@+,d0"); /* get the exception number */ -asm(" movel _stackPtr,sp"); /* move to remcom stack area */ -asm(" movel d0,sp@-"); /* push exception onto stack */ -asm(" jbsr _handle_exception"); /* this never returns */ -asm(" rts"); /* return */ - -void _returnFromException( Frame *frame ) -{ - /* if no existing frame, dummy one up */ - if (! frame) - { - frame = lastFrame -1; - frame->frameSize = 4; - frame->format = 0; - frame->fsaveHeader = 0; - frame->previous = lastFrame; - } - -#ifndef mc68020 - /* a 68000 cannot use the internal info pushed onto a bus error - * or address error frame when doing an RTE so don't put this info - * onto the stack or the stack will creep every time this happens. - */ - frame->frameSize=3; -#endif - - /* throw away any frames in the list after this frame */ - lastFrame = frame; - - frame->sr = registers[(int) PS]; - frame->pc = registers[(int) PC]; - - if (registers[(int) PS] & 0x2000) - { - /* return to supervisor mode... */ - return_to_super(); - } - else - { /* return to user mode */ - return_to_user(); - } -} - -int hex(ch) -char ch; -{ - if ((ch >= 'a') && (ch <= 'f')) return (ch-'a'+10); - if ((ch >= '0') && (ch <= '9')) return (ch-'0'); - return (0); -} - - -/* scan for the sequence $# */ -void getpacket(buffer) -char * buffer; -{ - unsigned char checksum; - unsigned char xmitcsum; - int i; - int count; - char ch; - - do { - /* wait around for the start character, ignore all other characters */ - while ((ch = getDebugChar()) != '$'); - checksum = 0; - count = 0; - - /* now, read until a # or end of buffer is found */ - while (count < BUFMAX) { - ch = getDebugChar(); - if (ch == '#') break; - checksum = checksum + ch; - buffer[count] = ch; - count = count + 1; - } - buffer[count] = 0; - - if (ch == '#') { - xmitcsum = hex(getDebugChar()) << 4; - xmitcsum += hex(getDebugChar()); - if ((remote_debug ) && (checksum != xmitcsum)) { - fprintf(stderr,"bad checksum. My count = 0x%x, sent=0x%x. buf=%s\n", - checksum,xmitcsum,buffer); - } - - if (checksum != xmitcsum) putDebugChar('-'); /* failed checksum */ - else { - putDebugChar('+'); /* successful transfer */ - /* if a sequence char is present, reply the sequence ID */ - if (buffer[2] == ':') { - putDebugChar( buffer[0] ); - putDebugChar( buffer[1] ); - /* remove sequence chars from buffer */ - count = strlen(buffer); - for (i=3; i <= count; i++) buffer[i-3] = buffer[i]; - } - } - } - } while (checksum != xmitcsum); - -} - -/* send the packet in buffer. The host get's one chance to read it. - This routine does not wait for a positive acknowledge. */ - - -void putpacket(buffer) -char * buffer; -{ - unsigned char checksum; - int count; - char ch; - - /* $#. */ - do { - putDebugChar('$'); - checksum = 0; - count = 0; - - while (ch=buffer[count]) { - if (! putDebugChar(ch)) return; - checksum += ch; - count += 1; - } - - putDebugChar('#'); - putDebugChar(hexchars[checksum >> 4]); - putDebugChar(hexchars[checksum % 16]); - - } while (1 == 0); /* (getDebugChar() != '+'); */ - -} - -static char inbuffer[BUFMAX]; -static char outbuffer[BUFMAX]; -static short error; - - -void debug_error(format, parm) -char * format; -char * parm; -{ - if (remote_debug) fprintf(stderr,format,parm); -} - -/* convert the memory pointed to by mem into hex, placing result in buf */ -/* return a pointer to the last char put in buf (null) */ -char* mem2hex(mem, buf, count) -char* mem; -char* buf; -int count; -{ - int i; - unsigned char ch; - for (i=0;i> 4]; - *buf++ = hexchars[ch % 16]; - } - *buf = 0; - return(buf); -} - -/* convert the hex array pointed to by buf into binary to be placed in mem */ -/* return a pointer to the character AFTER the last byte written */ -char* hex2mem(buf, mem, count) -char* buf; -char* mem; -int count; -{ - int i; - unsigned char ch; - for (i=0;iexceptionPC, - frame->exceptionVector); - if (frame->exceptionPC == newPC) break; /* bingo! a match */ - /* - * for a breakpoint instruction, the saved pc may - * be off by two due to re-executing the instruction - * replaced by the trap instruction. Check for this. - */ - if ((frame->exceptionVector == 33) && - (frame->exceptionPC == (newPC+2))) break; - frame = frame->previous; - } - - /* - * If we found a match for the PC AND we are not returning - * as a result of a breakpoint (33), - * trace exception (9), nmi (31), jmp to - * the old exception handler as if this code never ran. - */ - if (frame) - { - if ((frame->exceptionVector != 9) && - (frame->exceptionVector != 31) && - (frame->exceptionVector != 33)) - { - /* - * invoke the previous handler. - */ - if (oldExceptionHook) - (*oldExceptionHook) (frame->exceptionVector); - newPC = registers[ PC ]; /* pc may have changed */ - if (newPC != frame->exceptionPC) - { - if (remote_debug) - printf("frame at 0x%x has pc=0x%x, except#=%d\n", - frame,frame->exceptionPC, - frame->exceptionVector); - /* dispose of this frame, we're skipping it (longjump?)*/ - lastFrame = frame->previous; - frame = (Frame *) 0; - } - } - } - - _returnFromException( frame ); - - break; - - /* kill the program */ - case 'k' : /* do nothing */ - break; - } /* switch */ - - /* reply to the request */ - putpacket(outbuffer); - } -} - - -/* this function is used to set up exception handlers for tracing and - breakpoints */ -void set_debug_traps() -{ -extern void _debug_level7(); -extern void remcomHandler(); -int exception; - - for (exception = 2; exception <= 23; exception++) - exceptionHandler(exception,_catchException); - - /* level 7 interrupt */ - exceptionHandler(31,_debug_level7); - - /* breakpoint exception (trap #1) */ - exceptionHandler(33,_catchException); - - /* floating point error (trap #8) */ - exceptionHandler(40,_catchException); - - /* 48 to 54 are floating point coprocessor errors */ - for (exception = 48; exception <= 54; exception++) - exceptionHandler(exception,_catchException); - - if (oldExceptionHook != remcomHandler) - { - oldExceptionHook = exceptionHook; - exceptionHook = remcomHandler; - } - - initialized = 1; - - lastFrame = (Frame *) &frameStack[FRAMESIZE-1]; - lastFrame->previous = (Frame *) 0; -} - -/* This function will generate a breakpoint exception. It is used at the - beginning of a program to sync up with a debugger and can be used - otherwise as a quick means to stop program execution and "break" into - the debugger. */ - -void breakpoint() -{ - if (initialized) BREAKPOINT(); -} - -@EOF - -chmod 444 remcom.c - -exit 0 - diff --git a/gdb/remote-sa.sparc.c b/gdb/remote-sa.sparc.c deleted file mode 100644 index 686699e2da6..00000000000 --- a/gdb/remote-sa.sparc.c +++ /dev/null @@ -1,1146 +0,0 @@ -/* THIS FILE HAS NOT HAD ITS COPYRIGHT CHECKED...FSF SHOULD NOT - DISTRIBUTE IT UNTIL THIS HAPPENS. */ - -/* Memory-access and commands for inferior process, for GDB. -*/ - -#include -#include -#include -#include "defs.h" -#include "param.h" -#include "frame.h" -#include "value.h" -#include "inferior.h" -#include "symtab.h" - -#undef WSTOPSIG -#undef WTERMSIG -#include "wait.h" - -#ifdef USG -#include -#include -#endif - -#include -#include - -#include -#define TERMINAL struct termios - -#define LONGTIMEOUT 5 -#define SHORTTIMEOUT 1 - -#define KD_MINUTAE 1 -#define KD_LINEDISCIPLINE 2 -#define KD_RETRY 4 -#define KD_BLOCKTRANSFER 8 - -#ifndef STDIN -#define STDIN 0 -#endif - -#define GL_READING 0 /* get line is reading data */ -#define GL_OK 1 /* Getline saw the "ok" string */ -#define GL_SUCCESS 2 /* Get line got data */ -#define GL_TIMEOUT 3 /* Get line timed out */ -#define GL_OVERRUN 4 /* Get line filled up the buffer */ -#define GL_EXCEPTION 5 /* Get line saw "Exception" */ -#define GL_PROMLINE 6 /* Get line saw prom specific info */ -#define GL_BLANKLINE 7 /* Get line saw a blank line */ - -static int kiodebug /* = KD_RETRY | KD_BLOCKTRANSFER */; - -static CORE_ADDR remote_pc = 0; -static CORE_ADDR remote_next_pc = 0; -static CORE_ADDR remove_thisbp_next_pc = 0; -static CORE_ADDR remove_thisbp_target = 0; - -enum showDrainage {DONTSHOW , SHOW} ; - - -/* Descriptor for I/O to remote machine. Initialize it to -1 so that - remote_open knows that we don't have a file open when the program - starts. */ -int remote_desc = -1; - -int dontskipcrs = 0; - -#define PBUFSIZ 400 - -unsigned char ignorebuf[PBUFSIZ]; -#define IGNORE &ignorebuf[0] - -/* 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). */ -#define MAXBUFBYTES ((PBUFSIZ-32)/2) - -static void remote_send (); -static void putpkt (); -static int getpkt (); - - -/* Open a connection to a remote debugger. - NAME is the filename used for communication. */ -CORE_ADDR breakpoint_regs_addr; - - -void -remote_open (name, from_tty) - char *name; - int from_tty; -{ - extern int frame_file_full_name; - unsigned char buf[PBUFSIZ]; - TERMINAL sg; - - remote_debugging = 0; - - if (remote_desc >= 0) - close (remote_desc); - - breakpoint_regs_addr = parse_and_eval_address("&breakpoint_regs"); - - dontskipcrs = !frame_file_full_name; /* if we are running inside of - emacs, this will be true. - then skip carriage returns */ - - remote_desc = open (name, O_RDWR); - if (remote_desc < 0) - perror_with_name (name); - - setup_remote(); - - if (from_tty) - printf ("Remote debugging using %s\n", name); - remote_debugging = 1; - - -} -static char *boot_cmd = 0; - -static print_boot_cmd() -{ - fprintf(stderr, "boot command set to be \"%s\"\n", boot_cmd); -} - -remote_start() -{ - WAITTYPE ignoredWaitType; - - if (boot_cmd) - { - sendbreak(); - remote_wait (&ignoredWaitType); - putpkt ("reset"); - sleep(10); - sendbreak(); - remote_wait (&ignoredWaitType); - sleep(10); - print_boot_cmd(); - putpkt(boot_cmd); - fprintf(stderr, "rgdb and nucleus synchronized, booting....\n"); - } - else - { - error("The boot command is null. Cannot start the remote kernel/nucleus"); - } -} - -/* Close the open connection to the remote debugger. - Use this when you want to detach and do something else - with your gdb. */ -void -remote_close (from_tty) - int from_tty; -{ - if (!remote_debugging) - error ("Can't close remote connection: not debugging remotely."); - - close (remote_desc); /* This should never be called if - there isn't something valid in - remote_desc. */ - - /* Do not try to close remote_desc again, later in the program. */ - remote_desc = -1; - - if (from_tty) - printf ("Ending remote debugging\n"); - - remote_debugging = 0; -} - -/* Convert hex digit A to a number. */ - -static int -fromhex (a) - int a; -{ - if (a >= '0' && a <= '9') - return a - '0'; - else if (a >= 'a' && a <= 'f') - return a - 'a' + 10; - else - error ("Reply contains invalid hex digit"); -} - -/* Convert number NIB to a hex digit. */ - -static int -tohex (nib) - int nib; -{ - if (nib < 10) - return '0'+nib; - else - return 'a'+nib-10; -} - -/* Tell the remote machine to resume. */ - -extern int one_stepped; /* From machine dependent code */ -static int remote_set_one_stepped; - -int -remote_resume (step, signal) - int step, signal; -{ - if (step) - { - remote_single_step(); - } - remote_set_one_stepped = step; - putpkt("go"); -} - -/* Wait until the remote machine stops, then return, - storing status in STATUS just as `wait' would. */ - -int -remote_wait (status) - WAITTYPE *status; -{ - char last, this; - int pend, saveTheOh = 0; - - user_terminal_raw(); - - WSETEXIT ((*status), 0177); - last = this = 0; - - while (1) - { - char buf[PBUFSIZ]; - int readUser, readProm, state; - - doselect(&readUser, &readProm); - if (readProm) - { - switch (state = getline(buf, PBUFSIZ, SHORTTIMEOUT)) - { - case GL_BLANKLINE: - if (remote_set_one_stepped) - break; - - /* fall through */ - - default: - case GL_READING: - case GL_SUCCESS: - case GL_OVERRUN: - case GL_TIMEOUT: - if (kiodebug & KD_LINEDISCIPLINE) - fprintf(stderr, "%d<%s>\n", state, buf); - else - { - fprintf(stderr, "%s", buf); - fflush(stderr); - } - break; - case GL_OK: - remote_cleanup_after_stop(); - WSETSTOP ((*status), SIGTRAP); - return; - case GL_PROMLINE: - break; - } - } - if (readUser) - shuffleFromUserToProm(); - } -} -static TERMINAL userterminal; - -user_terminal_restore() -{ -#if 0 - int in_desc = fileno (stdin); - ioctl (in_desc, TCSETS, &userterminal); -#endif -} -static void set_term_raw(); - -user_terminal_raw() -{ -#if 0 - TERMINAL tempterminal; - int in_desc = fileno (stdin); - ioctl (in_desc, TCGETS, &userterminal); - tempterminal = userterminal; - - tempterminal.c_lflag &= ~(ICANON|ISIG|IEXTEN); - tempterminal.c_cc[VMIN] = 1; - tempterminal.c_cc[VTIME] = 0; - tempterminal.c_iflag &= ~(INPCK|IXON|IXOFF); - tempterminal.c_oflag = 0; - - ioctl (in_desc, TCSETS, &tempterminal); -#endif -} - -doselect(pReadUser, pReadProm) - int *pReadUser, *pReadProm; -{ - extern FILE *instream; - int in_desc = fileno (stdin); - int instreammask = 1 << in_desc; - int remotemask = 1 << remote_desc; - int rfds = instreammask | remotemask; - - select (32, &rfds, 0, 0, (struct timeval *) 0); /* 0 = Block indefinitely */ - *pReadUser = (rfds & instreammask) == instreammask; - *pReadProm = (rfds & remotemask) == remotemask; -} - - - -/* Read the remote registers into the block pRegisters. -implementation copied largely from fetch_inferior_registers () -in sparc-dep.c */ - -void -remote_fetch_registers(ignored) -int *ignored; -{ - struct regs inferior_registers; - extern char registers[]; - CORE_ADDR breakpoint_regs_target; - - if (breakpoint_regs_addr == 0) - { - error("no address for breakpoint_regs\n"); - return; - } - remote_read_inferior_memory(breakpoint_regs_addr, &breakpoint_regs_target, - sizeof(breakpoint_regs_target)); - - bzero(registers, REGISTER_BYTES); - registers[REGISTER_BYTE (0)] = 0; - - if (breakpoint_regs_target) - { - remote_read_inferior_memory(breakpoint_regs_target, &inferior_registers, - sizeof(inferior_registers)); - registers[REGISTER_BYTE (0)] = 0; - bcopy (&inferior_registers.r_g1, ®isters[REGISTER_BYTE (1)], 15 * 4); - *(int *)®isters[REGISTER_BYTE (PS_REGNUM)] = inferior_registers.r_ps; - *(int *)®isters[REGISTER_BYTE (PC_REGNUM)] = inferior_registers.r_pc; - *(int *)®isters[REGISTER_BYTE (NPC_REGNUM)] = inferior_registers.r_npc; - *(int *)®isters[REGISTER_BYTE (Y_REGNUM)] = inferior_registers.r_y; - remote_pc = inferior_registers.r_pc; - remote_next_pc = inferior_registers.r_npc; - remote_read_inferior_memory (inferior_registers.r_sp, - ®isters[REGISTER_BYTE (16)], - 16*4); - } - else - { - error("breakpoint_regs == 0\n"); - } -} - - - - -/* Write memory data directly to the remote machine. - This does not inform the data cache; the data cache uses this. - MEMADDR is the address in the remote memory space. - MYADDR is the address of the buffer in our space. - LEN is the number of bytes. */ - -int -remote_write_bytes (memaddr, myaddr, len) - CORE_ADDR memaddr; - unsigned char *myaddr; - int len; -{ - char buf[PBUFSIZ]; - int i; - - /* Command describes registers byte by byte, - each byte encoded as two hex characters. */ - - for (i = 0; i < len; i++) - { - sprintf(buf, "%x %x c!", myaddr[i], memaddr + i); - remote_send (buf, buf); - if (strstr(buf, "Exception")) - { - return EFAULT; - } - } - return 0; -} - -/* Copy LEN bytes of data from debugger memory at MYADDR - to inferior's memory at MEMADDR. Returns errno value. */ -int -remote_write_inferior_memory (memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - int xfersize; - int retval; - - while (len > 0) - { - if (len > MAXBUFBYTES) - xfersize = MAXBUFBYTES; - else - xfersize = len; - - retval = remote_write_bytes(memaddr, myaddr, xfersize); - if (retval) - return retval; /* error */ - - memaddr += xfersize; - myaddr += xfersize; - len -= xfersize; - } - return 0; /* no error */ -} - - -/* read a single character */ - -static int -readCharFromProm () -{ - char buf; - - buf = '\0'; - /* termio does the timeout for us. */ - read (remote_desc, &buf, 1); - return buf & 0x7f; -} - -/* Send the command in BUF to the remote machine, - and read the reply into BUF. - Report an error if we get an error reply. */ - -static void -remote_send (buf, buf2) - char *buf, *buf2; -{ - putpkt (buf); - getpkt (buf2); -} - -/* Send a single character out over the wire */ - -static void -putcharacter (ch) - char ch; -{ - - while (1) - { - int i; - - write(remote_desc, &ch, 1); - for (i = 0; i < 100; i++) - { - char nch = 0; - - if (read (remote_desc, &nch, 1) == 0) - i++; - if ((ch == nch) - || (ch == '\n' && nch == '\r') - || (ch == '\r' && nch == '\n')) - return; - if (kiodebug & KD_MINUTAE) - fprintf (stderr, "Sent %c(%d) Received %c(%d)\n", ch, ch, nch, nch); - } - } -} - -/* Send a packet to the remote machine, with error checking. - The data of the packet is in BUF. */ - -static void -putpkt (buf) - char *buf; -{ - int i; - int cnt = strlen (buf); - char ch; - - if (kiodebug & KD_LINEDISCIPLINE) - fprintf(stderr, "putpkt(%s)\n", buf); - - for (i = 0; i < cnt; i++) - putcharacter (buf[i]); - putcharacter ('\n'); -} - -jmp_buf getline_jmpbuf; - -/* Read a line from the remote machine, and store it in BUF. */ -getline_timer() -{ - alarm(0); - - if (kiodebug & KD_RETRY) - fprintf(stderr, "getline timed out\n"); - longjmp(getline_jmpbuf, 1); -} - -static int -getline (buf, size, timeout) - char *buf; - int size, timeout; -{ - int cnt = 0; - int state; - int isspace_state = 1; - - if ((void (*)) signal (SIGALRM, getline_timer) == (void (*)) -1) - perror ("remote_open: error in signal"); - - --size; /* back it up one so that we can read */ - - state = GL_READING; - - if (setjmp(getline_jmpbuf)) - state = GL_TIMEOUT; - else - { - alarm (timeout); - do - { - char ch = readCharFromProm(); - isspace_state = isspace_state && isspace(ch); - if (ch && (dontskipcrs || ch != '\r')) - { - buf[cnt++] = ch; - buf[cnt] = '\0'; - } - if (kiodebug & KD_MINUTAE) - fprintf (stderr,"letter received :%c\n", buf[cnt - 1]); - if (cnt >= 2 && buf[cnt - 2] == 'o' && buf[cnt - 1] == 'k') - state = GL_OK; - else if (buf[cnt - 1] == '\n' ) - state = isspace_state ? GL_BLANKLINE : GL_SUCCESS; - else if (cnt == size) - state = GL_OVERRUN; - else if (strstr(buf, "Type 'go' to resume")) - state = GL_PROMLINE; - else if (strstr(buf, "Type help for more information")) - state = GL_PROMLINE; - else if (strstr(buf, "Exception")) - state = GL_EXCEPTION; - } - while (state == GL_READING); - } - alarm (0); - - if (kiodebug & KD_LINEDISCIPLINE) - fprintf (stderr,"Line received :%s\n", buf); - return state; -} - - -/* Read a packet from the remote machine, and store it in BUF. */ - -static int -getpkt (buf) - char *buf; -{ - int cnt = 0; - - do - { - char ch = readCharFromProm(); - if (ch) - buf[cnt++] = ch; - if (kiodebug & KD_MINUTAE) - fprintf (stderr,"letter received :%c\n", buf[cnt - 1]); - } - while (cnt < 2 || - buf[cnt - 2] != 'o' && - buf[cnt - 1] != 'k'); - - buf[cnt] = '\0'; - if (kiodebug& KD_LINEDISCIPLINE) - fprintf (stderr,"Packet received :%s\n", buf); - return cnt; -} - -void remote_fetch_word (addr) - CORE_ADDR addr; -{ - error ("Internal error: remote_fetch_word is obsolete.\n"); -} -void remote_store_word (addr) - CORE_ADDR addr; -{ - error ("Internal error: remote_store_word is obsolete.\n"); -} -#include - -draininput(showit) -enum showDrainage showit; -{ - unsigned char buf[PBUFSIZ]; - int cnt; - - while ((cnt = read(remote_desc, buf, PBUFSIZ)) > 0) - { - buf[cnt] = 0; - if (kiodebug& KD_LINEDISCIPLINE) - fprintf (stderr,"Draining :%s\n", buf); - else - if (showit == SHOW) - fprintf (stderr,"%s", buf); - } - if (kiodebug& KD_LINEDISCIPLINE) - fprintf (stderr,"Drained\n"); -} -sendbreak() -{ - if (kiodebug & KD_RETRY) - fprintf (stderr,"rgdb sending break to target...\n"); - else - { - fprintf (stderr,"="); - fflush(stderr); - } - - ioctl (remote_desc, TCSBRK, 0); - sleep(5); -} - - -/* shuffle a character from the user to remote debugger */ - -int -shuffleFromUserToProm() -{ - char ch; - static int escape = 0; - - extern FILE *instream; - - ch = 0; - if (read(STDIN, &ch , 1) != 1 || ch == 0) - return; - - if (escape) { - if (ch == '#') - sendbreak(); - else if (ch == '.') - { - while (ch != '\n') - read(STDIN, &ch , 1); - return 1; - } - else { - static char tilde = '~'; - - putcharacter(tilde); - putcharacter(ch); - } - escape = 0; - } else /* not escape */ { - if (ch == '~') - escape = 1; - else - putcharacter(ch); - } - return 0; -} - - - -/* Tell the Prom put a breakpoint at memaddr */ -remote_insert_breakpoint(memaddr) - CORE_ADDR memaddr; -{ - char buf[PBUFSIZ]; - - /* Command describes registers byte by byte, - each byte encoded as two hex characters. */ - - sprintf(buf, "%x +bp", memaddr); - remote_send(buf, buf); - if (strstr(buf, "Exception")) - { - return EFAULT; - } - else - { - return 0; - } -} - -/* Tell the Prom remove the the breakpoint at memaddr */ -remote_remove_breakpoint(memaddr) - CORE_ADDR memaddr; -{ - char buf[PBUFSIZ]; - - /* Command describes registers byte by byte, - each byte encoded as two hex characters. */ - - sprintf(buf, "%x -bp", memaddr); - remote_send(buf, buf); - if (strstr(buf, "Exception")) - { - return EFAULT; - } - else - { - return 0; - } -} - - - - - -/* Read memory data directly from the remote machine. - This does not use the data cache; the data cache uses this. - MEMADDR is the address in the remote memory space. - MYADDR is the address of the buffer in our space. - LEN is the number of words. */ - -long -remote_read(memaddr, myaddr, len, increment, promcommand) - CORE_ADDR memaddr; - unsigned char *myaddr; - int len, increment; - char *promcommand; -{ - char buf[PBUFSIZ]; - char buf2[PBUFSIZ]; - int i; - unsigned long num; - - /* Command describes registers byte by byte, - each byte encoded as two hex characters. */ - - for (i = 0; i < len; i += increment) - { - sprintf(buf, promcommand, memaddr + i) ; - remote_send(buf, buf2); - remote_send(".", buf); - if (strstr(buf2, "Exception")) - { - bzero(&myaddr[i], len - i); - return -i; - } - else - { - char *pBuf; - for (pBuf = &buf[0]; *pBuf == '\r' || *pBuf == '\n'; pBuf++) - ; - sscanf(pBuf, "%x\n", &num); - switch (increment) - { - case 1: myaddr[i] = num; - if (num > 255) - fprintf(stderr, "number out of bounds %x truncating to %x\n", - num, myaddr[i]); - break; - case 4: {unsigned long *p; - p = (unsigned long *) &myaddr[i]; - *p = num; - } - break; - default: fprintf(stderr, "unknown increment\n"); break; - } - } - } - return i; -} - - - -/* Read LEN bytes from inferior memory at MEMADDR. Put the result - at debugger address MYADDR. Returns errno value. */ -int -remote_read_inferior_memory(memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - int xfersize; - while (len > 0) - { - int mod; - - if (len > MAXBUFBYTES) - xfersize = MAXBUFBYTES; - else - xfersize = len; - - mod = memaddr % 4; - if (mod == 0 && xfersize >= 4) - if (mod == 0 && xfersize >= 16) - { - xfersize = remote_read_many(memaddr, myaddr, (len & ~3)); - getpkt(IGNORE); - } - else - xfersize = remote_read(memaddr, myaddr, 4, 4, "%x @"); - else - xfersize = remote_read(memaddr, myaddr, max(mod, 1), 1, "%x c@"); - if (xfersize <= 0) - return EFAULT; /* error */ - memaddr += xfersize; - myaddr += xfersize; - len -= xfersize; - } - return 0; /* no error */ -} -static int baud_rate=B38400; - -static void set_term_raw(pTermio) - TERMINAL *pTermio; -{ - pTermio->c_cflag &= (CREAD|HUPCL|CLOCAL); - pTermio->c_cflag |= baud_rate | CS8; - pTermio->c_iflag = ISTRIP /* | IXON | IXOFF */; - pTermio->c_oflag = 0; - pTermio->c_lflag = 0; - pTermio->c_cc[VMIN] = 0; - pTermio->c_cc[VTIME] = 1; -} - -/* setup the remote termio stream */ -setup_remote() -{ - TERMINAL temptempio; - - ioctl(remote_desc, TCGETS, &temptempio); - set_term_raw(&temptempio); - ioctl(remote_desc, TCSETS, &temptempio); -} - -/* step one machine instruction */ -remote_single_step () -{ - CORE_ADDR next_pc, npc4, target, pc; - typedef enum - { - Error, not_branch, bicc, bicca, ba, baa, ticc, ta, - } branch_type; - branch_type br, isannulled(); - - npc4 = remote_next_pc + 4; /* branch not taken */ - - /* Always set breakpoint for NPC. */ - - remote_insert_breakpoint(remote_next_pc); - remove_thisbp_next_pc = remote_next_pc; - - /* printf ("set break at %x\n",remote_next_pc); */ - - br = isannulled (remote_pc, &target); - - if (br == bicca) - { - /* Conditional annulled branch will either end up at - npc (if taken) or at npc+4 (if not taken). - Trap npc+4. */ - remote_insert_breakpoint(npc4); - remove_thisbp_target = npc4; - } - else if (br == baa && target != remote_next_pc) - { - /* Unconditional annulled branch will always end up at - the target. */ - remote_insert_breakpoint(target); - remove_thisbp_target = target; - } -} - - - - -/* read many words of memory */ -long -remote_read_many(memaddr, myaddr, len) - CORE_ADDR memaddr; - unsigned char *myaddr; - int len; -{ -#define BLOCKSIZE 1024 - static int max_number_of_blocks = 24; - - char buf[PBUFSIZ]; - char buf2[PBUFSIZ]; - int i; - unsigned long *p; -/* Command describes registers byte by byte, - each byte encoded as two hex characters. */ - - len = min(len, max_number_of_blocks * BLOCKSIZE); - - sprintf(buf, "%x %x do i @ . cr 4 +loop", memaddr + len, memaddr); - putpkt(buf); - getline(buf2, PBUFSIZ, LONGTIMEOUT); /* I don't care */ - - p = (unsigned long *) myaddr; - for (i = 0; i < len; i += 4, p++) - { - extern int InspectIt; - - if (!InspectIt && ((i % BLOCKSIZE) == 0)) - fprintf(stderr, "+"); /* let 'em know that we are working */ - switch (getline(buf2, PBUFSIZ, LONGTIMEOUT)) - { - default: - case GL_PROMLINE: - case GL_READING: - case GL_OK: - case GL_OVERRUN: - case GL_TIMEOUT: - case GL_BLANKLINE: - /* resync and retry */ - max_number_of_blocks = max(1, i / BLOCKSIZE); - fprintf(stderr, "-"); /* let 'em know that we are working */ - - if (kiodebug & KD_BLOCKTRANSFER) - fprintf(stderr, "failed read_many %d %d/%d (%s)\n", - max_number_of_blocks, i, len, buf2); - sendbreak(); - return remote_read_many(memaddr, myaddr, len); - case GL_EXCEPTION: - return -i; - case GL_SUCCESS: - sscanf(buf2, "%x\n", p); - break; - } - } - if (kiodebug & KD_BLOCKTRANSFER) - fprintf(stderr, "success read_many %d %d/%d (%s)\n", max_number_of_blocks, - i, len, buf2); - return i; -} -/* - * allow the user to type directly to the prom ! - */ -prom_command() -{ - int readUser, readProm; - - user_terminal_raw(); - fprintf(stderr, "entering prom mode...\n"); - while (1) - { - doselect(&readUser, &readProm); - if (readUser) - if (shuffleFromUserToProm()) - { - fprintf(stderr, "exiting prom mode\n"); - user_terminal_restore(); - return; - } - if (readProm) - fprintf(stderr, "%c", readCharFromProm ()); - } -} -static char *boot_set_msg = "boot needs a string in quotes of the form \"boot vmunix\" "; -static char *baud_set_msg = "baud rate should be of the form \"set baud=9600\""; - -static void -set_boot (arg, from_tty) - char *arg; - int from_tty; -{ - int h, i; - - if (!arg) - { - print_boot_cmd(); - error_no_arg (boot_set_msg); - } - - arg = tilde_expand (arg); - make_cleanup (free, arg); - - i = strlen (arg) - 1; - - free (boot_cmd); - - h = 0; - while (*arg && h < i && (arg[h] == ' ' || arg[h] == '\t')) - { - h++; - arg++; - } - while (i > 0 && (arg[i] == ' ' || arg[i] == '\t')) - i--; - - if (h >= i || !*arg || arg[h] != '"' || arg[i] != '"') - error (boot_set_msg); - else - { - boot_cmd = savestring (++arg, i); - boot_cmd[i - 1] = '\0'; - } - if (from_tty) - print_boot_cmd(); -} - -static int bauds[] = { - 0, 50, 75, 110, 134, 150, 200, 300, 600, - 1200, 1800, 2400, 4800, 9600, 19200, 38400, -1 -}; - - -static int convert_to_baud_B(n) - int n; -{ - register int *p; - - for (p = bauds; *p != -1; p++) - if (*p != 0 && *p == n) - return (p - bauds); - return (NULL); -} - -static void print_acceptable_bauds() -{ - register int *p; - - for (p = bauds; *p != -1; p++) - if (*p != 0 ) - fprintf(stderr, "%d\n", *p); -} - -static void print_baud() -{ -fprintf(stderr, "the baud rate is now %d\n", bauds[baud_rate]); -} - -static void -set_baud (arg, from_tty) - char *arg; - int from_tty; -{ - int temp_baud_rate; - - if (!arg) - { - print_baud(); - print_acceptable_bauds(); - error_no_arg (baud_set_msg); - return; - } - - while (*arg && !isdigit(*arg)) - arg++; - - if (*arg && (temp_baud_rate = convert_to_baud_B(atoi(arg))) != NULL) - { - baud_rate = temp_baud_rate; - if (remote_debugging) - setup_remote(); - } - else - { - fprintf(stderr, "bad baud rate %s, acceptable values are\n", arg); - print_acceptable_bauds(); - } - - print_baud(); -} - - - - -void -_initialize_remote() -{ -/* Chain containing all defined set subcommands */ - -extern struct cmd_list_element *setlist; - - - add_com ("prom", class_obscure, prom_command, - "Conduct a dialogue directly with the prom. \ -only useful after an attach\n\ -Terminate by typing ~."); - - add_cmd ("boot_cmd", class_support, set_boot, boot_set_msg, &setlist); - - add_cmd ("baud", class_support, set_baud, baud_set_msg, &setlist); - - set_boot ("\"boot nucleus -d\"", 0); - } - - -/* Store the remote registers from the contents of the block REGS. */ - -void -remote_store_registers (registers) - char *registers; -{ - CORE_ADDR core; - struct regs inferior_registers; - - core = parse_and_eval_address("breakpoint_regs"); - - bcopy (®isters[REGISTER_BYTE (1)], - &inferior_registers.r_g1, 15 * 4); - - inferior_registers.r_ps = - *(int *)®isters[REGISTER_BYTE (PS_REGNUM)]; - inferior_registers.r_pc = - *(int *)®isters[REGISTER_BYTE (PC_REGNUM)]; - inferior_registers.r_npc = - *(int *)®isters[REGISTER_BYTE (NPC_REGNUM)]; - inferior_registers.r_y = - *(int *)®isters[REGISTER_BYTE (Y_REGNUM)]; - - remote_write_inferior_memory (*(int *)®isters[REGISTER_BYTE (SP_REGNUM)], - ®isters[REGISTER_BYTE (16)], - 16*4); - remote_write_inferior_memory (core, - &inferior_registers, - sizeof(inferior_registers)); -} - - - -/* we have stopped. do some cleanup */ -remote_cleanup_after_stop() -{ - if (remove_thisbp_next_pc) - { - remote_remove_breakpoint (remove_thisbp_next_pc); - remove_thisbp_next_pc = 0; - } - if (remove_thisbp_target) - { - remote_remove_breakpoint (remove_thisbp_target); - remove_thisbp_target = 0; - } - user_terminal_restore(); - - one_stepped = remote_set_one_stepped; -} diff --git a/gdb/remote-vx.68.c b/gdb/remote-vx.68.c deleted file mode 100644 index 32e82028d4d..00000000000 --- a/gdb/remote-vx.68.c +++ /dev/null @@ -1,1542 +0,0 @@ -/* Memory-access and commands for remote VxWorks processes, for GDB. - Copyright (C) 1990 Free Software Foundation, Inc. - Contributed by Wind River Systems and 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include "defs.h" -#include "tm-vxworks68.h" -#include "param-no-tm.h" -#include "frame.h" -#include "inferior.h" -#include "wait.h" -#include "target.h" -#include "gdbcore.h" -#include "command.h" -#include "symtab.h" -#include "symfile.h" /* for struct complaint */ - -#include -#include -#include -#include -#include -#include -#include -#include -#define free bogon_free /* Sun claims "int free()" not void */ -#include -#undef free -#include -#include -#include "xdr_ptrace.h" -#include "xdr_ld.h" -#include "xdr_rdb.h" -#include "dbgRpcLib.h" - -/* get rid of value.h if possible */ -#include -#include - -extern value call_function_by_hand (); -extern void symbol_file_command (); -extern int stop_soon_quietly; /* for wait_for_inferior */ - -static int net_ptrace_clnt_call (); /* Forward decl */ -static enum clnt_stat net_clnt_call (); /* Forward decl */ -extern struct target_ops vx_ops, vx_run_ops; /* Forward declaration */ - -/* Saved name of target host and called function for "info files". - Both malloc'd. */ - -static char *vx_host; -static char *vx_running; - -/* Nonzero means target that is being debugged remotely has a floating - point processor. */ - -static int target_has_fp; - -/* Default error message when the network is forking up. */ - -static const char rpcerr[] = "network target debugging: rpc error"; - -CLIENT *pClient; /* client used in net debugging */ -static int ptraceSock = RPC_ANYSOCK; -extern int errno; - -enum clnt_stat net_clnt_call(); -static void parse_args (); - -static struct timeval rpcTimeout = { 10, 0 }; - -static char *skip_white_space (); -static char *find_white_space (); - -/* Tell the VxWorks target system to download a file. - The load addresses of the text, data, and bss segments are - stored in pTextAddr, pDataAddr, and *pBssAddr (respectively). - Returns 0 for success, -1 for failure. */ - -static int -net_load (filename, pTextAddr, pDataAddr, pBssAddr) - char *filename; - CORE_ADDR *pTextAddr; - CORE_ADDR *pDataAddr; - CORE_ADDR *pBssAddr; - { - enum clnt_stat status; - struct ldfile ldstruct; - struct timeval load_timeout; - - bzero ((char *) &ldstruct, sizeof (ldstruct)); - - /* We invoke clnt_call () here directly, instead of through - net_clnt_call (), because we need to set a large timeout value. - The load on the target side can take quite a while, easily - more than 10 seconds. The user can kill this call by typing - CTRL-C if there really is a problem with the load. */ - - load_timeout.tv_sec = 0x7FFF7FFF; /* A large number, effectively inf. */ - load_timeout.tv_usec = 0; - - status = clnt_call (pClient, VX_LOAD, xdr_wrapstring, &filename, xdr_ldfile, - &ldstruct, load_timeout); - - if (status == RPC_SUCCESS) - { - if (*ldstruct.name == NULL) /* load failed on VxWorks side */ - return -1; - *pTextAddr = ldstruct.txt_addr; - *pDataAddr = ldstruct.data_addr; - *pBssAddr = ldstruct.bss_addr; - return 0; - } - else - return -1; - } - -/* returns 0 if successful, errno if RPC failed or VxWorks complains. */ - -static int -net_break (addr, procnum) - int addr; - u_long procnum; - { - enum clnt_stat status; - int break_status; - Rptrace ptrace_in; /* XXX This is stupid. It doesn't need to be a ptrace - structure. How about something smaller? */ - - bzero ((char *) &ptrace_in, sizeof (ptrace_in)); - break_status = 0; - - ptrace_in.addr = addr; - ptrace_in.pid = inferior_pid; - - status = net_clnt_call (procnum, xdr_rptrace, &ptrace_in, xdr_int, - &break_status); - - if (status != RPC_SUCCESS) - return errno; - - if (break_status == -1) - return ENOMEM; - return break_status; /* probably (FIXME) zero */ - } - -/* returns 0 if successful, errno otherwise */ - -int -vx_insert_breakpoint (addr) - int addr; - { - return net_break (addr, VX_BREAK_ADD); - } - -/* returns 0 if successful, errno otherwise */ - -int -vx_remove_breakpoint (addr) - int addr; - { - return net_break (addr, VX_BREAK_DELETE); - } - -/* Call a function on the VxWorks target system. - ARGS is a vector of values of arguments (NARGS of them). - FUNCTION is a value, the function to be called. - Returns a struct value * representing what the function returned. - May fail to return, if a breakpoint or signal is hit - during the execution of the function. */ - -#ifdef FIXME -/* FIXME, function calls are really fried. GO back to manual method. */ -value -vx_call_function (function, nargs, args) - value function; - int nargs; - value *args; -{ - register CORE_ADDR sp; - register int i; - CORE_ADDR start_sp; - static REGISTER_TYPE dummy[] = CALL_DUMMY; - REGISTER_TYPE dummy1[sizeof dummy / sizeof (REGISTER_TYPE)]; - CORE_ADDR old_sp; - struct type *value_type; - unsigned char struct_return; - CORE_ADDR struct_addr; - struct inferior_status inf_status; - struct cleanup *old_chain; - CORE_ADDR funaddr; - int using_gcc; - - save_inferior_status (&inf_status, 1); - old_chain = make_cleanup (restore_inferior_status, &inf_status); - - /* PUSH_DUMMY_FRAME is responsible for saving the inferior registers - (and POP_FRAME for restoring them). (At least on most machines) - they are saved on the stack in the inferior. */ - PUSH_DUMMY_FRAME; - - old_sp = sp = read_register (SP_REGNUM); - -#if 1 INNER_THAN 2 /* Stack grows down */ - sp -= sizeof dummy; - start_sp = sp; -#else /* Stack grows up */ - start_sp = sp; - sp += sizeof dummy; -#endif - - funaddr = find_function_addr (function, &value_type); - - { - struct block *b = block_for_pc (funaddr); - /* If compiled without -g, assume GCC. */ - using_gcc = b == NULL || BLOCK_GCC_COMPILED (b); - } - - /* Are we returning a value using a structure return or a normal - value return? */ - - struct_return = using_struct_return (function, funaddr, value_type, - using_gcc); - - /* Create a call sequence customized for this function - and the number of arguments for it. */ - bcopy (dummy, dummy1, sizeof dummy); - FIX_CALL_DUMMY (dummy1, start_sp, funaddr, nargs, args, - value_type, using_gcc); - -#if CALL_DUMMY_LOCATION == ON_STACK - write_memory (start_sp, dummy1, sizeof dummy); - -#else /* Not on stack. */ -#if CALL_DUMMY_LOCATION == BEFORE_TEXT_END - /* Convex Unix prohibits executing in the stack segment. */ - /* Hope there is empty room at the top of the text segment. */ - { - static checked = 0; - if (!checked) - for (start_sp = text_end - sizeof dummy; start_sp < text_end; ++start_sp) - if (read_memory_integer (start_sp, 1) != 0) - error ("text segment full -- no place to put call"); - checked = 1; - sp = old_sp; - start_sp = text_end - sizeof dummy; - write_memory (start_sp, dummy1, sizeof dummy); - } -#else /* After text_end. */ - { - int errcode; - sp = old_sp; - start_sp = text_end; - errcode = target_write_memory (start_sp, dummy1, sizeof dummy); - if (errcode != 0) - error ("Cannot write text segment -- call_function failed"); - } -#endif /* After text_end. */ -#endif /* Not on stack. */ - -#ifdef STACK_ALIGN - /* If stack grows down, we must leave a hole at the top. */ - { - int len = 0; - - /* Reserve space for the return structure to be written on the - stack, if necessary */ - - if (struct_return) - len += TYPE_LENGTH (value_type); - - for (i = nargs - 1; i >= 0; i--) - len += TYPE_LENGTH (VALUE_TYPE (value_arg_coerce (args[i]))); -#ifdef CALL_DUMMY_STACK_ADJUST - len += CALL_DUMMY_STACK_ADJUST; -#endif -#if 1 INNER_THAN 2 - sp -= STACK_ALIGN (len) - len; -#else - sp += STACK_ALIGN (len) - len; -#endif - } -#endif /* STACK_ALIGN */ - - /* Reserve space for the return structure to be written on the - stack, if necessary */ - - if (struct_return) - { -#if 1 INNER_THAN 2 - sp -= TYPE_LENGTH (value_type); - struct_addr = sp; -#else - struct_addr = sp; - sp += TYPE_LENGTH (value_type); -#endif - } - -#if defined (REG_STRUCT_HAS_ADDR) - { - /* This is a machine like the sparc, where we need to pass a pointer - to the structure, not the structure itself. */ - if (REG_STRUCT_HAS_ADDR (using_gcc)) - for (i = nargs - 1; i >= 0; i--) - if (TYPE_CODE (VALUE_TYPE (args[i])) == TYPE_CODE_STRUCT) - { - CORE_ADDR addr; -#if !(1 INNER_THAN 2) - /* The stack grows up, so the address of the thing we push - is the stack pointer before we push it. */ - addr = sp; -#endif - /* Push the structure. */ - sp = value_push (sp, args[i]); -#if 1 INNER_THAN 2 - /* The stack grows down, so the address of the thing we push - is the stack pointer after we push it. */ - addr = sp; -#endif - /* The value we're going to pass is the address of the thing - we just pushed. */ - args[i] = value_from_long (builtin_type_long, (LONGEST) addr); - } - } -#endif /* REG_STRUCT_HAS_ADDR. */ - -#ifdef PUSH_ARGUMENTS - PUSH_ARGUMENTS(nargs, args, sp, struct_return, struct_addr); -#else /* !PUSH_ARGUMENTS */ - for (i = nargs - 1; i >= 0; i--) - sp = value_arg_push (sp, args[i]); -#endif /* !PUSH_ARGUMENTS */ - -#ifdef CALL_DUMMY_STACK_ADJUST -#if 1 INNER_THAN 2 - sp -= CALL_DUMMY_STACK_ADJUST; -#else - sp += CALL_DUMMY_STACK_ADJUST; -#endif -#endif /* CALL_DUMMY_STACK_ADJUST */ - - /* Store the address at which the structure is supposed to be - written. Note that this (and the code which reserved the space - above) assumes that gcc was used to compile this function. Since - it doesn't cost us anything but space and if the function is pcc - it will ignore this value, we will make that assumption. - - Also note that on some machines (like the sparc) pcc uses a - convention like gcc's. */ - - if (struct_return) - STORE_STRUCT_RETURN (struct_addr, sp); - - /* Write the stack pointer. This is here because the statements above - might fool with it. On SPARC, this write also stores the register - window into the right place in the new stack frame, which otherwise - wouldn't happen. (See write_inferior_registers in sparc-xdep.c.) */ - write_register (SP_REGNUM, sp); - - /* Figure out the value returned by the function. */ - { - char retbuf[REGISTER_BYTES]; - - /* Execute the stack dummy routine, calling FUNCTION. - When it is done, discard the empty frame - after storing the contents of all regs into retbuf. */ - run_stack_dummy (start_sp + CALL_DUMMY_START_OFFSET, retbuf); - - do_cleanups (old_chain); - - return value_being_returned (value_type, retbuf, struct_return); - } -} -/* should return a value of some sort */ - -value -vx_call_function (funcAddr, nargs, args, valueType) - char *funcAddr; - int nargs; - value *args; - struct type * valueType; -{ - int i; - func_call funcInfo; - arg_value *argValue; - enum clnt_stat status; - register int len; - arg_value funcReturn; - value gdbValue; - - argValue = (arg_value *) xmalloc (nargs * sizeof (arg_value)); - - bzero (argValue, nargs * sizeof (arg_value)); - bzero (&funcReturn, sizeof (funcReturn)); - - for (i = nargs - 1; i >= 0; i--) - { - len = TYPE_LENGTH (VALUE_TYPE (args [i])); - - switch (TYPE_CODE (VALUE_TYPE (args[i]))) - { - /* XXX put other types here. Where's CHAR, etc??? */ - - case TYPE_CODE_FLT: - argValue[i].type = T_FLOAT; - break; - case TYPE_CODE_INT: - case TYPE_CODE_PTR: - case TYPE_CODE_ENUM: - case TYPE_CODE_FUNC: - argValue[i].type = T_INT; - break; - - case TYPE_CODE_UNDEF: - case TYPE_CODE_ARRAY: - case TYPE_CODE_STRUCT: - case TYPE_CODE_UNION: - case TYPE_CODE_VOID: - case TYPE_CODE_SET: - case TYPE_CODE_RANGE: - case TYPE_CODE_PASCAL_ARRAY: - case TYPE_CODE_MEMBER: /* C++ */ - case TYPE_CODE_METHOD: /* C++ */ - case TYPE_CODE_REF: /* C++ */ - default: - error ("No corresponding VxWorks type for %d. CHECK IT OUT!!!\n", - TYPE_CODE(VALUE_TYPE(args[i]))); - } /* switch */ - if (TYPE_CODE(VALUE_TYPE(args[i])) == TYPE_CODE_FUNC) - argValue[i].arg_value_u.v_int = VALUE_ADDRESS(args[i]); - else - bcopy (VALUE_CONTENTS (args[i]), (char *) &argValue[i].arg_value_u, - len); - } - - /* XXX what should the type of this function addr be? - * XXX Both in gdb and vxWorks - */ - funcInfo.func_addr = (int) funcAddr; - funcInfo.args.args_len = nargs; - funcInfo.args.args_val = argValue; - - status = net_clnt_call (VX_CALL_FUNC, xdr_func_call, (char *) &funcInfo, - xdr_arg_value, &funcReturn); - - free ((char *) argValue); - - if (status == RPC_SUCCESS) - { - /* XXX this assumes that vxWorks ALWAYS returns an int, and that - * XXX gdb isn't expecting anything more - */ - - /******************* - if (funcReturn.type == T_UNKNOWN) - return YYYXXX...; - *******************/ - gdbValue = allocate_value (valueType); - bcopy (&funcReturn.arg_value_u.v_int, VALUE_CONTENTS (gdbValue), - sizeof (int)); - return gdbValue; - } - else - error (rpcerr); - } -#endif /* FIXME */ - -/* Start an inferior process and sets inferior_pid to its pid. - EXEC_FILE is the file to run. - ALLARGS is a string containing the arguments to the program. - ENV is the environment vector to pass. - Returns process id. Errors reported with error(). - On VxWorks, we ignore exec_file. */ - -void -vx_create_inferior (exec_file, args, env) - char *exec_file; - char *args; - char **env; -{ - enum clnt_stat status; - arg_array passArgs; - TASK_START taskStart; - - bzero ((char *) &passArgs, sizeof (passArgs)); - bzero ((char *) &taskStart, sizeof (taskStart)); - - /* parse arguments, put them in passArgs */ - - parse_args (args, &passArgs); - - if (passArgs.arg_array_len == 0) - error ("You must specify a function name to run, and arguments if any"); - - status = net_clnt_call (PROCESS_START, xdr_arg_array, &passArgs, - xdr_TASK_START, &taskStart); - - if ((status != RPC_SUCCESS) || (taskStart.status == -1)) - error ("Can't create process on remote target machine"); - - /* Save the name of the running function */ - if (vx_running) - free (vx_running); - vx_running = savestring (passArgs.arg_array_val[0], - strlen (passArgs.arg_array_val[0])); - -#ifdef CREATE_INFERIOR_HOOK - CREATE_INFERIOR_HOOK (pid); -#endif - - push_target (&vx_run_ops); - inferior_pid = taskStart.pid; - -#if defined (START_INFERIOR_HOOK) - START_INFERIOR_HOOK (); -#endif - - /* We will get a trace trap after one instruction. - Insert breakpoints and continue. */ - - init_wait_for_inferior (); - - /* Set up the "saved terminal modes" of the inferior - based on what modes we are starting it with. */ - target_terminal_init (); - - /* Install inferior's terminal modes. */ - target_terminal_inferior (); - - /* remote_start(args); */ - /* trap_expected = 0; */ - stop_soon_quietly = 1; - wait_for_inferior (); /* Get the task spawn event */ - stop_soon_quietly = 0; - - /* insert_step_breakpoint (); FIXME, do we need this? */ - proceed(-1, -1, 0); -} - -/* Fill ARGSTRUCT in argc/argv form with the arguments from the - argument string ARGSTRING. */ - -static void -parse_args (arg_string, arg_struct) - register char *arg_string; - arg_array *arg_struct; -{ - register int arg_count = 0; /* number of arguments */ - register int arg_index = 0; - register char *p0; - - bzero ((char *) arg_struct, sizeof (arg_array)); - - /* first count how many arguments there are */ - - p0 = arg_string; - while (*p0 != '\0') - { - if (*(p0 = skip_white_space (p0)) == '\0') - break; - p0 = find_white_space (p0); - arg_count++; - } - - arg_struct->arg_array_len = arg_count; - arg_struct->arg_array_val = (char **) xmalloc ((arg_count + 1) - * sizeof (char *)); - - /* now copy argument strings into arg_struct. */ - - while (*(arg_string = skip_white_space (arg_string))) - { - p0 = find_white_space (arg_string); - arg_struct->arg_array_val[arg_index++] = savestring (arg_string, - p0 - arg_string); - arg_string = p0; - } - - arg_struct->arg_array_val[arg_count] = NULL; -} - -/* Advance a string pointer across whitespace and return a pointer - to the first non-white character. */ - -static char * -skip_white_space (p) - register char *p; -{ - while (*p == ' ' || *p == '\t') - p++; - return p; -} - -/* Search for the first unquoted whitespace character in a string. - Returns a pointer to the character, or to the null terminator - if no whitespace is found. */ - -static char * -find_white_space (p) - register char *p; -{ - register int c; - - while ((c = *p) != ' ' && c != '\t' && c) - { - if (c == '\'' || c == '"') - { - while (*++p != c && *p) - { - if (*p == '\\') - p++; - } - if (!*p) - break; - } - p++; - } - return p; -} - -/* Poll the VxWorks target system for an event related - to the debugged task. - Returns -1 if remote wait failed, task status otherwise. */ - -int -net_wait (pEvent) - RDB_EVENT *pEvent; -{ - int pid; - enum clnt_stat status; - - bzero ((char *) pEvent, sizeof (RDB_EVENT)); - - pid = inferior_pid; - status = net_clnt_call (PROCESS_WAIT, xdr_int, &pid, xdr_RDB_EVENT, pEvent); - - return (status == RPC_SUCCESS)? pEvent->status: -1; -} - -/* Suspend the remote task. - Returns -1 if suspend fails on target system, 0 otherwise. */ - -int -net_quit () -{ - int pid; - int quit_status; - enum clnt_stat status; - - quit_status = 0; - - /* don't let rdbTask suspend itself by passing a pid of 0 */ - - if ((pid = inferior_pid) == 0) - return -1; - - status = net_clnt_call (VX_TASK_SUSPEND, xdr_int, &pid, xdr_int, - &quit_status); - - return (status == RPC_SUCCESS)? quit_status: -1; -} - -/* Read a register or registers from the remote system. */ - -int -vx_read_register (regno) - int regno; -{ - int status; - Rptrace ptrace_in; - Ptrace_return ptrace_out; - struct regs inferior_registers; - struct fp_status inferior_fp_registers; - extern char registers[]; - - bzero ((char *) &ptrace_in, sizeof (ptrace_in)); - bzero ((char *) &ptrace_out, sizeof (ptrace_out)); - - /* FIXME, eventually only get the ones we need. */ - registers_fetched (); - - ptrace_in.pid = inferior_pid; - ptrace_out.info.more_data = (caddr_t) &inferior_registers; - status = net_ptrace_clnt_call (PTRACE_GETREGS, &ptrace_in, &ptrace_out); - if (status) - error (rpcerr); - if (ptrace_out.status == -1) - { - errno = ptrace_out.errno; - return -1; - } - -#ifdef I80960 -#else /* I80960 */ - bcopy (&inferior_registers, registers, 16 * 4); - *(int *)®isters[REGISTER_BYTE (PS_REGNUM)] = inferior_registers.r_ps; - *(int *)®isters[REGISTER_BYTE (PC_REGNUM)] = inferior_registers.r_pc; - - if (target_has_fp) - { - ptrace_in.pid = inferior_pid; - ptrace_out.info.more_data = (caddr_t) &inferior_fp_registers; - status = net_ptrace_clnt_call (PTRACE_GETFPREGS, &ptrace_in, &ptrace_out); - if (status) - error (rpcerr); - if (ptrace_out.status == -1) - { - errno = ptrace_out.errno; - return -1; - } - - bcopy (&inferior_fp_registers, ®isters[REGISTER_BYTE (FP0_REGNUM)], - sizeof inferior_fp_registers.fps_regs); - bcopy (&inferior_fp_registers.fps_control, - ®isters[REGISTER_BYTE (FPC_REGNUM)], - sizeof inferior_fp_registers - sizeof inferior_fp_registers.fps_regs); - } - else - { - bzero (®isters[REGISTER_BYTE (FP0_REGNUM)], - sizeof inferior_fp_registers.fps_regs); - bzero (®isters[REGISTER_BYTE (FPC_REGNUM)], - sizeof inferior_fp_registers - sizeof inferior_fp_registers.fps_regs); - } -#endif - return 0; -} - -/* Prepare to store registers. Since we will store all of them, - read out their current values now. */ - -void -vx_prepare_to_store () -{ - vx_read_register (-1); -} - - -/* Store our register values back into the inferior. - If REGNO is -1, do this for all registers. - Otherwise, REGNO specifies which register (so we can save time). */ - /* FIXME, look at REGNO to save time here */ - -vx_write_register (regno) - int regno; -{ - struct regs inferior_registers; - struct fp_status inferior_fp_registers; - extern char registers[]; - int status; - Rptrace ptrace_in; - Ptrace_return ptrace_out; - - bzero ((char *) &ptrace_in, sizeof (ptrace_in)); - bzero ((char *) &ptrace_out, sizeof (ptrace_out)); - - bcopy (registers, &inferior_registers, 16 * 4); - inferior_registers.r_ps = *(int *)®isters[REGISTER_BYTE (PS_REGNUM)]; - inferior_registers.r_pc = *(int *)®isters[REGISTER_BYTE (PC_REGNUM)]; - ptrace_in.pid = inferior_pid; - ptrace_in.info.ttype = REGS; - ptrace_in.info.more_data = (caddr_t) &inferior_registers; - - /* XXX change second param to be a proc number */ - status = net_ptrace_clnt_call (PTRACE_SETREGS, &ptrace_in, &ptrace_out); - if (status) - error (rpcerr); - if (ptrace_out.status == -1) - { - errno = ptrace_out.errno; - return -1; - } - - if (target_has_fp) - { - bcopy (®isters[REGISTER_BYTE (FP0_REGNUM)], &inferior_fp_registers, - sizeof inferior_fp_registers.fps_regs); - bcopy (®isters[REGISTER_BYTE (FPC_REGNUM)], - &inferior_fp_registers.fps_control, - sizeof inferior_fp_registers - sizeof inferior_fp_registers.fps_regs); - - ptrace_in.pid = inferior_pid; - ptrace_in.info.ttype = FPREGS; - ptrace_in.info.more_data = (caddr_t) &inferior_fp_registers; - - status = net_ptrace_clnt_call (PTRACE_SETFPREGS, &ptrace_in, &ptrace_out); - if (status) - error (rpcerr); - if (ptrace_out.status == -1) - { - errno = ptrace_out.errno; - return -1; - } - } - return 0; -} - -/* Copy LEN bytes to or from remote inferior's memory starting at MEMADDR - to debugger memory starting at MYADDR. WRITE is true if writing to the - inferior. - Result is the number of bytes written or read (zero if error). The - protocol allows us to return a negative count, indicating that we can't - handle the current address but can handle one N bytes further, but - vxworks doesn't give us that information. */ - -int -vx_xfer_memory (memaddr, myaddr, len, write) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - int status; - Rptrace ptrace_in; - Ptrace_return ptrace_out; - C_bytes data; - - bzero ((char *) &ptrace_in, sizeof (ptrace_in)); - bzero ((char *) &ptrace_out, sizeof (ptrace_out)); - - ptrace_in.pid = inferior_pid; /* XXX pid unnecessary for READDATA */ - ptrace_in.addr = (int) memaddr; /* Where from */ - ptrace_in.data = len; /* How many bytes */ - - if (write) - { - ptrace_in.info.ttype = DATA; - ptrace_in.info.more_data = (caddr_t) &data; - - data.bytes = (caddr_t) myaddr; /* Where from */ - data.len = len; /* How many bytes (again, for XDR) */ - - /* XXX change second param to be a proc number */ - status = net_ptrace_clnt_call (PTRACE_WRITEDATA, &ptrace_in, &ptrace_out); - } - else - { - ptrace_out.info.more_data = (caddr_t) &data; - data.bytes = myaddr; /* Where to */ - data.len = len; /* How many (again, for XDR) */ - - /* XXX change second param to be a proc number */ - status = net_ptrace_clnt_call (PTRACE_READDATA, &ptrace_in, &ptrace_out); - } - - if (status) - error (rpcerr); - if (ptrace_out.status == -1) - { - return 0; /* No bytes moved */ - } - return len; /* Moved *all* the bytes */ -} - -void -vx_files_info () -{ - printf ("\tAttached to host `%s'", vx_host); - printf (", which has %sfloating point", target_has_fp? "": "no "); - printf (".\n"); -} - -void -vx_run_files_info () -{ - printf ("\tRunning VxWorks process 0x%x, function `%s'.\n", - inferior_pid, vx_running); -} - -void -vx_resume (step, siggnal) - int step; - int siggnal; -{ - int status; - Rptrace ptrace_in; - Ptrace_return ptrace_out; - - if (siggnal != 0) - error ("Cannot send signals to VxWorks processes"); - - bzero ((char *) &ptrace_in, sizeof (ptrace_in)); - bzero ((char *) &ptrace_out, sizeof (ptrace_out)); - - ptrace_in.pid = inferior_pid; - ptrace_in.addr = 1; /* Target side insists on this, or it panics. */ - - /* XXX change second param to be a proc number */ - status = net_ptrace_clnt_call (step? PTRACE_SINGLESTEP: PTRACE_CONT, - &ptrace_in, &ptrace_out); - if (status) - error (rpcerr); - if (ptrace_out.status == -1) - { - errno = ptrace_out.errno; - perror_with_name ("Resuming remote process"); - } -} - -void -vx_mourn_inferior () -{ - pop_target (); /* Pop back to no-child state */ - generic_mourn_inferior (); -} - - -/* This function allows the addition of incrementally linked object files. */ - -void -vx_add_file_command (arg_string, from_tty) - char* arg_string; - int from_tty; -{ - CORE_ADDR text_addr; - CORE_ADDR data_addr; - CORE_ADDR bss_addr; - - if (arg_string == 0) - error ("add-file takes a file name in VxWorks"); - - arg_string = tilde_expand (arg_string); - make_cleanup (free, arg_string); - - dont_repeat (); - - if (net_load (arg_string, &text_addr, &data_addr, &bss_addr) == -1) - error ("Load failed on target machine"); - - /* FIXME, for now we ignore data_addr and bss_addr. */ - symbol_file_add (arg_string, from_tty, text_addr, 0); -} - -#ifdef FIXME /* Not ready for prime time */ -/* Single step the target program at the source or machine level. - Takes an error exit if rpc fails. - Returns -1 if remote single-step operation fails, else 0. */ - -static int -net_step () -{ - enum clnt_stat status; - int step_status; - SOURCE_STEP source_step; - - source_step.taskId = inferior_pid; - - if (step_range_end) - { - source_step.startAddr = step_range_start; - source_step.endAddr = step_range_end; - } - else - { - source_step.startAddr = 0; - source_step.endAddr = 0; - } - - status = net_clnt_call (VX_SOURCE_STEP, xdr_SOURCE_STEP, &source_step, - xdr_int, &step_status); - - if (status == RPC_SUCCESS) - return step_status; - else - error (rpcerr); -} -#endif - -/* Emulate ptrace using RPC calls to the VxWorks target system. - Returns nonzero (-1) if RPC status to VxWorks is bad, 0 otherwise. */ - -static int -net_ptrace_clnt_call (request, pPtraceIn, pPtraceOut) - enum ptracereq request; - Rptrace *pPtraceIn; - Ptrace_return *pPtraceOut; -{ - enum clnt_stat status; - - status = net_clnt_call (request, xdr_rptrace, pPtraceIn, xdr_ptrace_return, - pPtraceOut); - - if (status != RPC_SUCCESS) - return -1; - - return 0; -} - -/* Query the target for the name of the file from which VxWorks was - booted. pBootFile is the address of a pointer to the buffer to - receive the file name; if the pointer pointed to by pBootFile is - NULL, memory for the buffer will be allocated by XDR. - Returns -1 if rpc failed, 0 otherwise. */ - -int -net_get_boot_file (pBootFile) - char **pBootFile; -{ - enum clnt_stat status; - - status = net_clnt_call (VX_BOOT_FILE_INQ, xdr_void, (char *) 0, - xdr_wrapstring, pBootFile); - return (status == RPC_SUCCESS) ? 0 : -1; -} - -/* Fetch a list of loaded object modules from the VxWorks target. - Returns -1 if rpc failed, 0 otherwise - There's no way to check if the returned loadTable is correct. - VxWorks doesn't check it. */ - -int -net_get_symbols (pLoadTable) - ldtabl *pLoadTable; /* return pointer to ldtabl here */ -{ - enum clnt_stat status; - - bzero ((char *) pLoadTable, sizeof (struct ldtabl)); - - status = net_clnt_call (VX_STATE_INQ, xdr_void, 0, xdr_ldtabl, pLoadTable); - return (status == RPC_SUCCESS) ? 0 : -1; -} - -/* Look up a symbol in the VxWorks target's symbol table. - Returns status of symbol read on target side (0=success, -1=fail) - Returns -1 and complain()s if rpc fails. */ - -struct complaint cant_contact_target = - {"Lost contact with VxWorks target", 0, 0}; - -int -vx_lookup_symbol (name, pAddr) - char *name; /* symbol name */ - CORE_ADDR *pAddr; -{ - enum clnt_stat status; - SYMBOL_ADDR symbolAddr; - - *pAddr = 0; - bzero ((char *) &symbolAddr, sizeof (symbolAddr)); - - status = net_clnt_call (VX_SYMBOL_INQ, xdr_wrapstring, &name, - xdr_SYMBOL_ADDR, &symbolAddr); - if (status != RPC_SUCCESS) { - complain (&cant_contact_target, 0); - return -1; - } - - *pAddr = symbolAddr.addr; - return symbolAddr.status; -} - -/* Check to see if the VxWorks target has a floating point coprocessor. - Returns 1 if target has floating point processor, 0 otherwise. - Calls error() if rpc fails. */ - -int -net_check_for_fp () -{ - enum clnt_stat status; - bool_t fp = 0; /* true if fp processor is present on target board */ - - status = net_clnt_call (VX_FP_INQUIRE, xdr_void, 0, xdr_bool, &fp); - if (status != RPC_SUCCESS) - error (rpcerr); - - return (int) fp; -} - -/* Establish an RPC connection with the VxWorks target system. - Calls error () if unable to establish connection. */ - -void -net_connect (host) - char *host; -{ - struct sockaddr_in destAddr; - struct hostent *destHost; - - /* get the internet address for the given host */ - - if ((destHost = (struct hostent *) gethostbyname (host)) == NULL) - error ("Invalid hostname. Couldn't attach remote target."); - - bzero (&destAddr, sizeof (destAddr)); - - destAddr.sin_addr.s_addr = * (u_long *) destHost->h_addr; - destAddr.sin_family = AF_INET; - destAddr.sin_port = 0; /* set to actual port that remote - ptrace is listening on. */ - - /* Create a tcp client transport on which to issue - calls to the remote ptrace server. */ - - ptraceSock = RPC_ANYSOCK; - pClient = clnttcp_create (&destAddr, RDBPROG, RDBVERS, &ptraceSock, 0, 0); - /* FIXME, here is where we deal with different version numbers of the proto */ - - if (pClient == NULL) - { - clnt_pcreateerror ("\tnet_connect"); - error ("Couldn't connect to remote target."); - } -} - -/* Sleep for the specified number of milliseconds - * (assumed to be less than 1000). - * If select () is interrupted, returns immediately; - * takes an error exit if select () fails for some other reason. - */ - -static void -sleep_ms (ms) - long ms; -{ - struct timeval select_timeout; - int status; - - select_timeout.tv_sec = 0; - select_timeout.tv_usec = ms * 1000; - - status = select (0, (fd_set *) 0, (fd_set *) 0, (fd_set *) 0, &select_timeout); - - if (status < 0 && errno != EINTR) - perror_with_name ("select"); -} - -/* 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 GDB should read more commands. */ - -/* For network debugging with VxWorks. - * VxWorks knows when tasks hit breakpoints, receive signals, exit, etc, - * so vx_wait() receives this information directly from - * VxWorks instead of trying to figure out what happenned via a wait() call. - */ - -static int -vx_wait (status) - int *status; -{ - register int pid; - WAITTYPE w; - RDB_EVENT rdbEvent; - int quit_failed; - - do - { - /* If CTRL-C is hit during this loop, - suspend the inferior process. */ - - quit_failed = 0; - if (quit_flag) - { - quit_failed = (net_quit () == -1); - quit_flag = 0; - } - - /* If a net_quit () or net_wait () call has failed, - allow the user to break the connection with the target. - We can't simply error () out of this loop, since the - data structures representing the state of the inferior - are in an inconsistent state. */ - - if (quit_failed || net_wait (&rdbEvent) == -1) - { - terminal_ours (); - if (query ("Can't %s. Disconnect from target system? ", - (quit_failed) ? "suspend remote task" - : "get status of remote task")) - { - target_mourn_inferior(); - error ("Use the \"target\" command to reconnect."); - } - else - { - terminal_inferior (); - continue; - } - } - - - if (quit_failed || net_wait (&rdbEvent) == -1) - { - error ("Wait on remote target failed"); - } - - pid = rdbEvent.taskId; - if (pid == 0) - { - sleep_ms (200); /* FIXME Don't kill the network too badly */ - } - else if (pid != inferior_pid) - fatal ("Bad pid for debugged task: 0x%x\n", pid); - } while (pid == 0); - - /* FIXME, eventually do more then SIGTRAP on everything... */ - switch (rdbEvent.eventType) - { - case EVENT_EXIT: - WSETEXIT (w, 0); - /* FIXME is it possible to distinguish between a - XXX normal vs abnormal exit in VxWorks? */ - break; - - case EVENT_START: - WSETSTOP (w, SIGTRAP); - break; - - case EVENT_STOP: - WSETSTOP (w, SIGTRAP); - /* XXX was it stopped by a signal? act accordingly */ - break; - - case EVENT_BREAK: - /* Expecting a trace trap. Stop the inferior and - * return silently when it happens. */ - WSETSTOP (w, SIGTRAP); - break; - - case EVENT_SUSPEND: - target_terminal_ours_for_output (); - printf ("\nRemote task suspended\n"); /* FIXME */ - fflush (stdout); - WSETSTOP (w, SIGTRAP); - break; - - case EVENT_SIGNAL: - /* The target is not running Unix, and its - faults/traces do not map nicely into Unix signals. - Make sure they do not get confused with Unix signals - by numbering them with values higher than the highest - legal Unix signal. code in the arch-dependent PRINT_RANDOM_SIGNAL - routine will interpret the value for wait_for_inferior. */ - WSETSTOP (w, rdbEvent.sigType + NSIG); - break; - } /* switch */ - *status = *(int *)&w; /* Grumble union wait crap Grumble */ - return pid; -} - -static int -symbol_stub (arg) - int arg; -{ - char *bootFile = (char *)arg; - symbol_file_command (bootFile, 0); - return 1; -} - -static int -add_symbol_stub (arg) - int arg; -{ - struct ldfile *pLoadFile = (struct ldfile *)arg; - - symbol_file_add (pLoadFile->name, 0, pLoadFile->txt_addr, 0); - return 1; -} -/* Target command for VxWorks target systems. - - Used in vxgdb. Takes the name of a remote target machine - running vxWorks and connects to it to initialize remote network - debugging. */ - -static void -vx_open (args, from_tty) - char *args; - int from_tty; -{ - extern int close (); - char *bootFile; - extern char *source_path; - struct ldtabl loadTable; - struct ldfile *pLoadFile; - int i; - extern CLIENT *pClient; - - if (!args) - error_no_arg ("target machine name"); - - target_preopen (); - - printf ("Attaching remote machine across net...\n"); - fflush (stdout); - - /* Allow the user to kill the connect attempt by typing ^C. - Wait until the call to target_has_fp () completes before - disallowing an immediate quit, since even if net_connect () - is successful, the remote debug server might be hung. */ - - immediate_quit++; - - net_connect (args); - target_has_fp = net_check_for_fp (); - printf_filtered ("Connected to %s\n", args); - - immediate_quit--; - - push_target (&vx_ops); - - /* Save a copy of the target host's name. */ - if (vx_host) - free (vx_host); - vx_host = savestring (args, strlen (args)); - - /* Find out the name of the file from which the target was booted - and load its symbol table. */ - - bootFile = NULL; - if (!net_get_boot_file (&bootFile)) - { - if (*bootFile) { - printf_filtered ("%s: ", bootFile); - if (catch_errors (symbol_stub, (int)bootFile, - "Error reading symbols from boot file")) - puts_filtered ("ok\n"); - } else if (from_tty) - printf ("VxWorks kernel symbols not loaded.\n"); - } - else - error ("Can't retrieve boot file name from target machine."); - - clnt_freeres (pClient, xdr_wrapstring, &bootFile); - - if (net_get_symbols (&loadTable) != 0) - error ("Can't read loaded modules from target machine"); - - i = 0-1; - while (++i < loadTable.tbl_size) - { - QUIT; /* FIXME, avoids clnt_freeres below: mem leak */ - pLoadFile = &loadTable.tbl_ent [i]; -#ifdef WRS_ORIG - { - register int desc; - struct cleanup *old_chain; - char *fullname = NULL; - - desc = openp (source_path, 0, pLoadFile->name, O_RDONLY, 0, &fullname); - if (desc < 0) - perror_with_name (pLoadFile->name); - old_chain = make_cleanup (close, desc); - add_file_at_addr (fullname, desc, pLoadFile->txt_addr, pLoadFile->data_addr, - pLoadFile->bss_addr); - do_cleanups (old_chain); - } -#else - /* Botches, FIXME: - (1) Searches the PATH, not the source path. - (2) data and bss are assumed to be at the usual offsets from text. */ - catch_errors (add_symbol_stub, (int)pLoadFile, - "Error in reading symbols from loaded module."); -#endif - } - - clnt_freeres (pClient, xdr_ldtabl, &loadTable); - - if (from_tty) - { - puts_filtered ("Success!\n"); - } -} - -/* Cross-net conversion of floats to and from extended form. - (This is needed because different target machines have different - extended floating point formats.) */ - -/* Convert from an extended float to a double. - - The extended float is stored as raw data pointed to by FROM. - Return the converted value as raw data in the double pointed to by TO. -*/ - -static void -vx_convert_to_virtual (regno, from, to) - int regno; - char *from; - char *to; -{ - enum clnt_stat status; - ext_fp from_ext_fp; - double to_double; - - if (REGISTER_CONVERTIBLE (regno)) - { - if (!target_has_fp) { - *(double *)to = 0.0; /* Skip the trouble if no float anyway */ - return; - } - bcopy (from, (char *) &from_ext_fp, sizeof (from_ext_fp)); - bzero ((char *) &to_double, sizeof (to_double)); - - status = net_clnt_call (VX_CONV_FROM_68881, xdr_ext_fp, &from_ext_fp, - xdr_double, &to_double); - if (status == RPC_SUCCESS) - bcopy ((char *) &to_double, to, sizeof (to_double)); - else - error (rpcerr); - } - else - bcopy (from, to, REGISTER_VIRTUAL_SIZE (regno)); -} - - -/* The converse: convert from a double to an extended float. - - The double is stored as raw data pointed to by FROM. - Return the converted value as raw data in the extended - float pointed to by TO. -*/ - -static void -vx_convert_from_virtual (regno, from, to) - int regno; - char *from; - char *to; -{ - enum clnt_stat status; - ext_fp to_ext_fp; - double from_double; - - if (REGISTER_CONVERTIBLE (regno)) - { - if (!target_has_fp) { - bzero (to, REGISTER_RAW_SIZE (FP0_REGNUM)); /* Shrug */ - return; - } - bcopy (from, (char *) &from_double, sizeof (from_double)); - bzero ((char *) &to_ext_fp, sizeof (to_ext_fp)); - - status = net_clnt_call (VX_CONV_TO_68881, xdr_double, &from_double, - xdr_ext_fp, &to_ext_fp); - if (status == RPC_SUCCESS) - bcopy ((char *) &to_ext_fp, to, sizeof (to_ext_fp)); - else - error (rpcerr); - } - else - bcopy (from, to, REGISTER_VIRTUAL_SIZE (regno)); -} - -/* Make an RPC call to the VxWorks target. - Returns RPC status. */ - -static enum clnt_stat -net_clnt_call (procNum, inProc, in, outProc, out) - enum ptracereq procNum; - xdrproc_t inProc; - char *in; - xdrproc_t outProc; - char *out; -{ - enum clnt_stat status; - - status = clnt_call (pClient, procNum, inProc, in, outProc, out, rpcTimeout); - - if (status != RPC_SUCCESS) - clnt_perrno (status); - - return status; -} - -/* A vxprocess target should be started via "run" not "target". */ -/*ARGSUSED*/ -static void -vx_proc_open (name, from_tty) - char *name; - int from_tty; -{ - error ("Use the \"run\" command to start a VxWorks process."); -} - - -/* Target ops structure for accessing memory and such over the net */ - -struct target_ops vx_ops = { - "vxworks", "VxWorks target memory via RPC over TCP/IP", - "Use VxWorks target memory. \n\ -Specify the name of the machine to connect to.", - vx_open, 0, /* vx_detach, */ - 0, 0, /* resume, wait */ - 0, 0, /* read_reg, write_reg */ - 0, vx_convert_to_virtual, vx_convert_from_virtual, /* prep_to_store, */ - vx_xfer_memory, vx_files_info, - 0, 0, /* insert_breakpoint, remove_breakpoint */ - 0, 0, 0, 0, 0, /* terminal stuff */ - 0, /* vx_kill, */ - vx_add_file_command, - call_function_by_hand, /* FIXME, calling fns is maybe botched? */ - vx_lookup_symbol, - vx_create_inferior, 0, /* mourn_inferior */ - core_stratum, 0, /* next */ - 1, 1, 0, 0, 0, /* all mem, mem, stack, regs, exec */ - OPS_MAGIC, /* Always the last thing */ -}; - -/* Target ops structure for accessing VxWorks child processes over the net */ - -struct target_ops vx_run_ops = { - "vxprocess", "VxWorks process", - "VxWorks process, started by the \"run\" command.", - vx_proc_open, 0, /* vx_detach, */ - vx_resume, vx_wait, - vx_read_register, vx_write_register, - vx_prepare_to_store, vx_convert_to_virtual, vx_convert_from_virtual, - vx_xfer_memory, vx_run_files_info, - vx_insert_breakpoint, vx_remove_breakpoint, - 0, 0, 0, 0, 0, /* terminal stuff */ - 0, /* vx_kill, */ - vx_add_file_command, - call_function_by_hand, /* FIXME, calling fns is maybe botched? */ - vx_lookup_symbol, - vx_create_inferior, vx_mourn_inferior, - process_stratum, 0, /* next */ - 1, 1, 1, 1, 1, /* all mem, mem, stack, regs, exec */ - OPS_MAGIC, /* Always the last thing */ -}; -/* ==> Remember when reading at end of file, there are two "ops" structs here. */ - -void -_initialize_vx () -{ - add_target (&vx_ops); - add_target (&vx_run_ops); -} diff --git a/gdb/remote-vx.c b/gdb/remote-vx.c deleted file mode 100644 index 42090b75616..00000000000 --- a/gdb/remote-vx.c +++ /dev/null @@ -1,1487 +0,0 @@ -/* Memory-access and commands for remote VxWorks processes, for GDB. - Copyright (C) 1990-1991 Free Software Foundation, Inc. - Contributed by Wind River Systems and 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "defs.h" -#include "param.h" -#include "frame.h" -#include "inferior.h" -#include "wait.h" -#include "target.h" -#include "gdbcore.h" -#include "command.h" -#include "symtab.h" -#include "symfile.h" /* for struct complaint */ - -#include -#include -#include -#include -#include -#include -#include -#define free bogon_free /* Sun claims "int free()" not void */ -#include -#undef free -#include /* UTek's doesn't #incl this */ -#include -#include -#include "xdr_ptrace.h" -#include "xdr_ld.h" -#include "xdr_rdb.h" -#include "dbgRpcLib.h" - -/* get rid of value.h if possible */ -#include -#include - -extern value call_function_by_hand (); -extern void symbol_file_command (); -extern int stop_soon_quietly; /* for wait_for_inferior */ - -static int net_ptrace_clnt_call (); /* Forward decl */ -static enum clnt_stat net_clnt_call (); /* Forward decl */ -extern struct target_ops vx_ops, vx_run_ops; /* Forward declaration */ - -/* Saved name of target host and called function for "info files". - Both malloc'd. */ - -static char *vx_host; -static char *vx_running; /* Called function */ - -/* Nonzero means target that is being debugged remotely has a floating - point processor. */ - -static int target_has_fp; - -/* Default error message when the network is forking up. */ - -static const char rpcerr[] = "network target debugging: rpc error"; - -CLIENT *pClient; /* client used in net debugging */ -static int ptraceSock = RPC_ANYSOCK; - -enum clnt_stat net_clnt_call(); -static void parse_args (); - -static struct timeval rpcTimeout = { 10, 0 }; - -static char *skip_white_space (); -static char *find_white_space (); - -/* Tell the VxWorks target system to download a file. - The load addresses of the text, data, and bss segments are - stored in pTextAddr, pDataAddr, and *pBssAddr (respectively). - Returns 0 for success, -1 for failure. */ - -static int -net_load (filename, pTextAddr, pDataAddr, pBssAddr) - char *filename; - CORE_ADDR *pTextAddr; - CORE_ADDR *pDataAddr; - CORE_ADDR *pBssAddr; - { - enum clnt_stat status; - struct ldfile ldstruct; - struct timeval load_timeout; - - bzero ((char *) &ldstruct, sizeof (ldstruct)); - - /* We invoke clnt_call () here directly, instead of through - net_clnt_call (), because we need to set a large timeout value. - The load on the target side can take quite a while, easily - more than 10 seconds. The user can kill this call by typing - CTRL-C if there really is a problem with the load. - - Do not change the tv_sec value without checking -- select() imposes - a limit of 10**8 on it for no good reason that I can see... */ - - load_timeout.tv_sec = 99999999; /* A large number, effectively inf. */ - load_timeout.tv_usec = 0; - - status = clnt_call (pClient, VX_LOAD, xdr_wrapstring, &filename, xdr_ldfile, - &ldstruct, load_timeout); - - if (status == RPC_SUCCESS) - { - if (*ldstruct.name == NULL) /* load failed on VxWorks side */ - return -1; - *pTextAddr = ldstruct.txt_addr; - *pDataAddr = ldstruct.data_addr; - *pBssAddr = ldstruct.bss_addr; - return 0; - } - else - return -1; - } - -/* returns 0 if successful, errno if RPC failed or VxWorks complains. */ - -static int -net_break (addr, procnum) - int addr; - u_long procnum; - { - enum clnt_stat status; - int break_status; - Rptrace ptrace_in; /* XXX This is stupid. It doesn't need to be a ptrace - structure. How about something smaller? */ - - bzero ((char *) &ptrace_in, sizeof (ptrace_in)); - break_status = 0; - - ptrace_in.addr = addr; - ptrace_in.pid = inferior_pid; - - status = net_clnt_call (procnum, xdr_rptrace, &ptrace_in, xdr_int, - &break_status); - - if (status != RPC_SUCCESS) - return errno; - - if (break_status == -1) - return ENOMEM; - return break_status; /* probably (FIXME) zero */ - } - -/* returns 0 if successful, errno otherwise */ - -int -vx_insert_breakpoint (addr) - int addr; - { - return net_break (addr, VX_BREAK_ADD); - } - -/* returns 0 if successful, errno otherwise */ - -int -vx_remove_breakpoint (addr) - int addr; - { - return net_break (addr, VX_BREAK_DELETE); - } - -/* Start an inferior process and sets inferior_pid to its pid. - EXEC_FILE is the file to run. - ALLARGS is a string containing the arguments to the program. - ENV is the environment vector to pass. - Returns process id. Errors reported with error(). - On VxWorks, we ignore exec_file. */ - -void -vx_create_inferior (exec_file, args, env) - char *exec_file; - char *args; - char **env; -{ - enum clnt_stat status; - arg_array passArgs; - TASK_START taskStart; - - bzero ((char *) &passArgs, sizeof (passArgs)); - bzero ((char *) &taskStart, sizeof (taskStart)); - - /* parse arguments, put them in passArgs */ - - parse_args (args, &passArgs); - - if (passArgs.arg_array_len == 0) - error ("You must specify a function name to run, and arguments if any"); - - status = net_clnt_call (PROCESS_START, xdr_arg_array, &passArgs, - xdr_TASK_START, &taskStart); - - if ((status != RPC_SUCCESS) || (taskStart.status == -1)) - error ("Can't create process on remote target machine"); - - /* Save the name of the running function */ - vx_running = savestring (passArgs.arg_array_val[0], - strlen (passArgs.arg_array_val[0])); - -#ifdef CREATE_INFERIOR_HOOK - CREATE_INFERIOR_HOOK (pid); -#endif - - push_target (&vx_run_ops); - inferior_pid = taskStart.pid; - -#if defined (START_INFERIOR_HOOK) - START_INFERIOR_HOOK (); -#endif - - /* We will get a trace trap after one instruction. - Insert breakpoints and continue. */ - - init_wait_for_inferior (); - - /* Set up the "saved terminal modes" of the inferior - based on what modes we are starting it with. */ - target_terminal_init (); - - /* Install inferior's terminal modes. */ - target_terminal_inferior (); - - /* remote_start(args); */ - /* trap_expected = 0; */ - stop_soon_quietly = 1; - wait_for_inferior (); /* Get the task spawn event */ - stop_soon_quietly = 0; - - /* insert_step_breakpoint (); FIXME, do we need this? */ - proceed(-1, -1, 0); -} - -/* Fill ARGSTRUCT in argc/argv form with the arguments from the - argument string ARGSTRING. */ - -static void -parse_args (arg_string, arg_struct) - register char *arg_string; - arg_array *arg_struct; -{ - register int arg_count = 0; /* number of arguments */ - register int arg_index = 0; - register char *p0; - - bzero ((char *) arg_struct, sizeof (arg_array)); - - /* first count how many arguments there are */ - - p0 = arg_string; - while (*p0 != '\0') - { - if (*(p0 = skip_white_space (p0)) == '\0') - break; - p0 = find_white_space (p0); - arg_count++; - } - - arg_struct->arg_array_len = arg_count; - arg_struct->arg_array_val = (char **) xmalloc ((arg_count + 1) - * sizeof (char *)); - - /* now copy argument strings into arg_struct. */ - - while (*(arg_string = skip_white_space (arg_string))) - { - p0 = find_white_space (arg_string); - arg_struct->arg_array_val[arg_index++] = savestring (arg_string, - p0 - arg_string); - arg_string = p0; - } - - arg_struct->arg_array_val[arg_count] = NULL; -} - -/* Advance a string pointer across whitespace and return a pointer - to the first non-white character. */ - -static char * -skip_white_space (p) - register char *p; -{ - while (*p == ' ' || *p == '\t') - p++; - return p; -} - -/* Search for the first unquoted whitespace character in a string. - Returns a pointer to the character, or to the null terminator - if no whitespace is found. */ - -static char * -find_white_space (p) - register char *p; -{ - register int c; - - while ((c = *p) != ' ' && c != '\t' && c) - { - if (c == '\'' || c == '"') - { - while (*++p != c && *p) - { - if (*p == '\\') - p++; - } - if (!*p) - break; - } - p++; - } - return p; -} - -/* Poll the VxWorks target system for an event related - to the debugged task. - Returns -1 if remote wait failed, task status otherwise. */ - -int -net_wait (pEvent) - RDB_EVENT *pEvent; -{ - int pid; - enum clnt_stat status; - - bzero ((char *) pEvent, sizeof (RDB_EVENT)); - - pid = inferior_pid; - status = net_clnt_call (PROCESS_WAIT, xdr_int, &pid, xdr_RDB_EVENT, pEvent); - - return (status == RPC_SUCCESS)? pEvent->status: -1; -} - -/* Suspend the remote task. - Returns -1 if suspend fails on target system, 0 otherwise. */ - -int -net_quit () -{ - int pid; - int quit_status; - enum clnt_stat status; - - quit_status = 0; - - /* don't let rdbTask suspend itself by passing a pid of 0 */ - - if ((pid = inferior_pid) == 0) - return -1; - - status = net_clnt_call (VX_TASK_SUSPEND, xdr_int, &pid, xdr_int, - &quit_status); - - return (status == RPC_SUCCESS)? quit_status: -1; -} - -/* Read a register or registers from the remote system. */ - -int -vx_read_register (regno) - int regno; -{ - int status; - Rptrace ptrace_in; - Ptrace_return ptrace_out; - struct regs inferior_registers; - struct fp_status inferior_fp_registers; - extern char registers[]; - - bzero ((char *) &ptrace_in, sizeof (ptrace_in)); - bzero ((char *) &ptrace_out, sizeof (ptrace_out)); - - /* FIXME, eventually only get the ones we need. */ - registers_fetched (); - - ptrace_in.pid = inferior_pid; - ptrace_out.info.more_data = (caddr_t) &inferior_registers; - status = net_ptrace_clnt_call (PTRACE_GETREGS, &ptrace_in, &ptrace_out); - if (status) - error (rpcerr); - if (ptrace_out.status == -1) - { - errno = ptrace_out.errno; - return -1; - } - -#ifdef I80960 - - bcopy ((char *) inferior_registers.r_lreg, - ®isters[REGISTER_BYTE (R0_REGNUM)], 16 * sizeof (int)); - bcopy ((char *) inferior_registers.r_greg, - ®isters[REGISTER_BYTE (G0_REGNUM)], 16 * sizeof (int)); - - /* Don't assume that a location in registers[] is properly aligned. */ - - bcopy ((char *) &inferior_registers.r_pcw, - ®isters[REGISTER_BYTE (PCW_REGNUM)], sizeof (int)); - bcopy ((char *) &inferior_registers.r_acw, - ®isters[REGISTER_BYTE (ACW_REGNUM)], sizeof (int)); - bcopy ((char *) &inferior_registers.r_lreg[2], /* r2 (RIP) -> IP */ - ®isters[REGISTER_BYTE (IP_REGNUM)], sizeof (int)); - bcopy ((char *) &inferior_registers.r_tcw, - ®isters[REGISTER_BYTE (TCW_REGNUM)], sizeof (int)); - - /* If the target has floating point registers, fetch them. - Otherwise, zero the floating point register values in - registers[] for good measure, even though we might not - need to. */ - - if (target_has_fp) - { - ptrace_in.pid = inferior_pid; - ptrace_out.info.more_data = (caddr_t) &inferior_fp_registers; - status = net_ptrace_clnt_call (PTRACE_GETFPREGS, &ptrace_in, &ptrace_out); - if (status) - error (rpcerr); - if (ptrace_out.status == -1) - { - errno = ptrace_out.errno; - return -1; - } - - bcopy (&inferior_fp_registers, ®isters[REGISTER_BYTE (FP0_REGNUM)], - REGISTER_RAW_SIZE (FP0_REGNUM) * 4); - } - else - { - bzero ((char *) ®isters[REGISTER_BYTE (FP0_REGNUM)], - REGISTER_RAW_SIZE (FP0_REGNUM) * 4); - } - -#else /* not 960, thus must be 68000: FIXME! */ - - bcopy (&inferior_registers, registers, 16 * 4); - *(int *)®isters[REGISTER_BYTE (PS_REGNUM)] = inferior_registers.r_ps; - *(int *)®isters[REGISTER_BYTE (PC_REGNUM)] = inferior_registers.r_pc; - - if (target_has_fp) - { - ptrace_in.pid = inferior_pid; - ptrace_out.info.more_data = (caddr_t) &inferior_fp_registers; - status = net_ptrace_clnt_call (PTRACE_GETFPREGS, &ptrace_in, &ptrace_out); - if (status) - error (rpcerr); - if (ptrace_out.status == -1) - { - errno = ptrace_out.errno; - return -1; - } - - bcopy (&inferior_fp_registers, ®isters[REGISTER_BYTE (FP0_REGNUM)], - sizeof inferior_fp_registers.fps_regs); - bcopy (&inferior_fp_registers.fps_control, - ®isters[REGISTER_BYTE (FPC_REGNUM)], - sizeof inferior_fp_registers - sizeof inferior_fp_registers.fps_regs); - } - else - { - bzero (®isters[REGISTER_BYTE (FP0_REGNUM)], - sizeof inferior_fp_registers.fps_regs); - bzero (®isters[REGISTER_BYTE (FPC_REGNUM)], - sizeof inferior_fp_registers - sizeof inferior_fp_registers.fps_regs); - } -#endif /* various architectures */ - - return 0; -} - -/* Prepare to store registers. Since we will store all of them, - read out their current values now. */ - -void -vx_prepare_to_store () -{ - vx_read_register (-1); -} - - -/* Store our register values back into the inferior. - If REGNO is -1, do this for all registers. - Otherwise, REGNO specifies which register (so we can save time). */ - /* FIXME, look at REGNO to save time here */ - -vx_write_register (regno) - int regno; -{ - struct regs inferior_registers; - struct fp_status inferior_fp_registers; - extern char registers[]; - int status; - Rptrace ptrace_in; - Ptrace_return ptrace_out; - - bzero ((char *) &ptrace_in, sizeof (ptrace_in)); - bzero ((char *) &ptrace_out, sizeof (ptrace_out)); - -#ifdef I80960 - - bcopy (®isters[REGISTER_BYTE (R0_REGNUM)], - (char *) inferior_registers.r_lreg, 16 * sizeof (int)); - bcopy (®isters[REGISTER_BYTE (G0_REGNUM)], - (char *) inferior_registers.r_greg, 16 * sizeof (int)); - - /* Don't assume that a location in registers[] is properly aligned. */ - - bcopy (®isters[REGISTER_BYTE (PCW_REGNUM)], - (char *) &inferior_registers.r_pcw, sizeof (int)); - bcopy (®isters[REGISTER_BYTE (ACW_REGNUM)], - (char *) &inferior_registers.r_acw, sizeof (int)); - bcopy (®isters[REGISTER_BYTE (TCW_REGNUM)], - (char *) &inferior_registers.r_tcw, sizeof (int)); - -#else /* not 960 -- assume 68k -- FIXME */ - - bcopy (registers, &inferior_registers, 16 * 4); - inferior_registers.r_ps = *(int *)®isters[REGISTER_BYTE (PS_REGNUM)]; - inferior_registers.r_pc = *(int *)®isters[REGISTER_BYTE (PC_REGNUM)]; - -#endif /* Different register sets */ - - ptrace_in.pid = inferior_pid; - ptrace_in.info.ttype = REGS; - ptrace_in.info.more_data = (caddr_t) &inferior_registers; - - /* XXX change second param to be a proc number */ - status = net_ptrace_clnt_call (PTRACE_SETREGS, &ptrace_in, &ptrace_out); - if (status) - error (rpcerr); - if (ptrace_out.status == -1) - { - errno = ptrace_out.errno; - return -1; - } - - /* Store floating point registers if the target has them. */ - - if (target_has_fp) - { -#ifdef I80960 - - bcopy (®isters[REGISTER_BYTE (FP0_REGNUM)], &inferior_fp_registers, - sizeof inferior_fp_registers.fps_regs); - -#else /* not 960 -- assume 68k -- FIXME */ - - bcopy (®isters[REGISTER_BYTE (FP0_REGNUM)], &inferior_fp_registers, - sizeof inferior_fp_registers.fps_regs); - bcopy (®isters[REGISTER_BYTE (FPC_REGNUM)], - &inferior_fp_registers.fps_control, - sizeof inferior_fp_registers - sizeof inferior_fp_registers.fps_regs); - -#endif /* Different register sets */ - - ptrace_in.pid = inferior_pid; - ptrace_in.info.ttype = FPREGS; - ptrace_in.info.more_data = (caddr_t) &inferior_fp_registers; - - status = net_ptrace_clnt_call (PTRACE_SETFPREGS, &ptrace_in, &ptrace_out); - if (status) - error (rpcerr); - if (ptrace_out.status == -1) - { - errno = ptrace_out.errno; - return -1; - } - } - return 0; -} - -/* Copy LEN bytes to or from remote inferior's memory starting at MEMADDR - to debugger memory starting at MYADDR. WRITE is true if writing to the - inferior. - Result is the number of bytes written or read (zero if error). The - protocol allows us to return a negative count, indicating that we can't - handle the current address but can handle one N bytes further, but - vxworks doesn't give us that information. */ - -int -vx_xfer_memory (memaddr, myaddr, len, write, target) - CORE_ADDR memaddr; - char *myaddr; - int len; - int write; - struct target_ops *target; /* ignored */ -{ - int status; - Rptrace ptrace_in; - Ptrace_return ptrace_out; - C_bytes data; - - bzero ((char *) &ptrace_in, sizeof (ptrace_in)); - bzero ((char *) &ptrace_out, sizeof (ptrace_out)); - - ptrace_in.pid = inferior_pid; /* XXX pid unnecessary for READDATA */ - ptrace_in.addr = (int) memaddr; /* Where from */ - ptrace_in.data = len; /* How many bytes */ - - if (write) - { - ptrace_in.info.ttype = DATA; - ptrace_in.info.more_data = (caddr_t) &data; - - data.bytes = (caddr_t) myaddr; /* Where from */ - data.len = len; /* How many bytes (again, for XDR) */ - - /* XXX change second param to be a proc number */ - status = net_ptrace_clnt_call (PTRACE_WRITEDATA, &ptrace_in, &ptrace_out); - } - else - { - ptrace_out.info.more_data = (caddr_t) &data; - data.bytes = myaddr; /* Where to */ - data.len = len; /* How many (again, for XDR) */ - - /* XXX change second param to be a proc number */ - status = net_ptrace_clnt_call (PTRACE_READDATA, &ptrace_in, &ptrace_out); - } - - if (status) - error (rpcerr); - if (ptrace_out.status == -1) - { - return 0; /* No bytes moved */ - } - return len; /* Moved *all* the bytes */ -} - -void -vx_files_info () -{ - printf ("\tAttached to host `%s'", vx_host); - printf (", which has %sfloating point", target_has_fp? "": "no "); - printf (".\n"); -} - -void -vx_run_files_info () -{ - printf ("\tRunning %s VxWorks process %s", - vx_running? "child": "attached", - local_hex_string(inferior_pid)); - if (vx_running) - printf (", function `%s'", vx_running); - printf(".\n"); -} - -void -vx_resume (step, siggnal) - int step; - int siggnal; -{ - int status; - Rptrace ptrace_in; - Ptrace_return ptrace_out; - - if (siggnal != 0 && siggnal != stop_signal) - error ("Cannot send signals to VxWorks processes"); - - bzero ((char *) &ptrace_in, sizeof (ptrace_in)); - bzero ((char *) &ptrace_out, sizeof (ptrace_out)); - - ptrace_in.pid = inferior_pid; - ptrace_in.addr = 1; /* Target side insists on this, or it panics. */ - - /* XXX change second param to be a proc number */ - status = net_ptrace_clnt_call (step? PTRACE_SINGLESTEP: PTRACE_CONT, - &ptrace_in, &ptrace_out); - if (status) - error (rpcerr); - if (ptrace_out.status == -1) - { - errno = ptrace_out.errno; - perror_with_name ("Resuming remote process"); - } -} - -void -vx_mourn_inferior () -{ - pop_target (); /* Pop back to no-child state */ - generic_mourn_inferior (); -} - - -/* This function allows the addition of incrementally linked object files. */ - -void -vx_load_command (arg_string, from_tty) - char* arg_string; - int from_tty; -{ - CORE_ADDR text_addr; - CORE_ADDR data_addr; - CORE_ADDR bss_addr; - - if (arg_string == 0) - error ("The load command takes a file name"); - - arg_string = tilde_expand (arg_string); - make_cleanup (free, arg_string); - - dont_repeat (); - - QUIT; - immediate_quit++; - if (net_load (arg_string, &text_addr, &data_addr, &bss_addr) == -1) - error ("Load failed on target machine"); - immediate_quit--; - - /* FIXME, for now we ignore data_addr and bss_addr. */ - symbol_file_add (arg_string, from_tty, text_addr, 0); -} - -#ifdef FIXME /* Not ready for prime time */ -/* Single step the target program at the source or machine level. - Takes an error exit if rpc fails. - Returns -1 if remote single-step operation fails, else 0. */ - -static int -net_step () -{ - enum clnt_stat status; - int step_status; - SOURCE_STEP source_step; - - source_step.taskId = inferior_pid; - - if (step_range_end) - { - source_step.startAddr = step_range_start; - source_step.endAddr = step_range_end; - } - else - { - source_step.startAddr = 0; - source_step.endAddr = 0; - } - - status = net_clnt_call (VX_SOURCE_STEP, xdr_SOURCE_STEP, &source_step, - xdr_int, &step_status); - - if (status == RPC_SUCCESS) - return step_status; - else - error (rpcerr); -} -#endif - -/* Emulate ptrace using RPC calls to the VxWorks target system. - Returns nonzero (-1) if RPC status to VxWorks is bad, 0 otherwise. */ - -static int -net_ptrace_clnt_call (request, pPtraceIn, pPtraceOut) - enum ptracereq request; - Rptrace *pPtraceIn; - Ptrace_return *pPtraceOut; -{ - enum clnt_stat status; - - status = net_clnt_call (request, xdr_rptrace, pPtraceIn, xdr_ptrace_return, - pPtraceOut); - - if (status != RPC_SUCCESS) - return -1; - - return 0; -} - -/* Query the target for the name of the file from which VxWorks was - booted. pBootFile is the address of a pointer to the buffer to - receive the file name; if the pointer pointed to by pBootFile is - NULL, memory for the buffer will be allocated by XDR. - Returns -1 if rpc failed, 0 otherwise. */ - -int -net_get_boot_file (pBootFile) - char **pBootFile; -{ - enum clnt_stat status; - - status = net_clnt_call (VX_BOOT_FILE_INQ, xdr_void, (char *) 0, - xdr_wrapstring, pBootFile); - return (status == RPC_SUCCESS) ? 0 : -1; -} - -/* Fetch a list of loaded object modules from the VxWorks target. - Returns -1 if rpc failed, 0 otherwise - There's no way to check if the returned loadTable is correct. - VxWorks doesn't check it. */ - -int -net_get_symbols (pLoadTable) - ldtabl *pLoadTable; /* return pointer to ldtabl here */ -{ - enum clnt_stat status; - - bzero ((char *) pLoadTable, sizeof (struct ldtabl)); - - status = net_clnt_call (VX_STATE_INQ, xdr_void, 0, xdr_ldtabl, pLoadTable); - return (status == RPC_SUCCESS) ? 0 : -1; -} - -/* Look up a symbol in the VxWorks target's symbol table. - Returns status of symbol read on target side (0=success, -1=fail) - Returns -1 and complain()s if rpc fails. */ - -struct complaint cant_contact_target = - {"Lost contact with VxWorks target", 0, 0}; - -int -vx_lookup_symbol (name, pAddr) - char *name; /* symbol name */ - CORE_ADDR *pAddr; -{ - enum clnt_stat status; - SYMBOL_ADDR symbolAddr; - - *pAddr = 0; - bzero ((char *) &symbolAddr, sizeof (symbolAddr)); - - status = net_clnt_call (VX_SYMBOL_INQ, xdr_wrapstring, &name, - xdr_SYMBOL_ADDR, &symbolAddr); - if (status != RPC_SUCCESS) { - complain (&cant_contact_target, 0); - return -1; - } - - *pAddr = symbolAddr.addr; - return symbolAddr.status; -} - -/* Check to see if the VxWorks target has a floating point coprocessor. - Returns 1 if target has floating point processor, 0 otherwise. - Calls error() if rpc fails. */ - -int -net_check_for_fp () -{ - enum clnt_stat status; - bool_t fp = 0; /* true if fp processor is present on target board */ - - status = net_clnt_call (VX_FP_INQUIRE, xdr_void, 0, xdr_bool, &fp); - if (status != RPC_SUCCESS) - error (rpcerr); - - return (int) fp; -} - -/* Establish an RPC connection with the VxWorks target system. - Calls error () if unable to establish connection. */ - -void -net_connect (host) - char *host; -{ - struct sockaddr_in destAddr; - struct hostent *destHost; - - /* get the internet address for the given host */ - - if ((destHost = (struct hostent *) gethostbyname (host)) == NULL) - error ("Invalid hostname. Couldn't find remote host address."); - - bzero (&destAddr, sizeof (destAddr)); - - destAddr.sin_addr.s_addr = * (u_long *) destHost->h_addr; - destAddr.sin_family = AF_INET; - destAddr.sin_port = 0; /* set to actual port that remote - ptrace is listening on. */ - - /* Create a tcp client transport on which to issue - calls to the remote ptrace server. */ - - ptraceSock = RPC_ANYSOCK; - pClient = clnttcp_create (&destAddr, RDBPROG, RDBVERS, &ptraceSock, 0, 0); - /* FIXME, here is where we deal with different version numbers of the proto */ - - if (pClient == NULL) - { - clnt_pcreateerror ("\tnet_connect"); - error ("Couldn't connect to remote target."); - } -} - -/* Sleep for the specified number of milliseconds - * (assumed to be less than 1000). - * If select () is interrupted, returns immediately; - * takes an error exit if select () fails for some other reason. - */ - -static void -sleep_ms (ms) - long ms; -{ - struct timeval select_timeout; - int status; - - select_timeout.tv_sec = 0; - select_timeout.tv_usec = ms * 1000; - - status = select (0, (fd_set *) 0, (fd_set *) 0, (fd_set *) 0, &select_timeout); - - if (status < 0 && errno != EINTR) - perror_with_name ("select"); -} - -/* 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 GDB should read more commands. */ - -/* For network debugging with VxWorks. - * VxWorks knows when tasks hit breakpoints, receive signals, exit, etc, - * so vx_wait() receives this information directly from - * VxWorks instead of trying to figure out what happenned via a wait() call. - */ - -static int -vx_wait (status) - int *status; -{ - register int pid; - WAITTYPE w; - RDB_EVENT rdbEvent; - int quit_failed; - - do - { - /* If CTRL-C is hit during this loop, - suspend the inferior process. */ - - quit_failed = 0; - if (quit_flag) - { - quit_failed = (net_quit () == -1); - quit_flag = 0; - } - - /* If a net_quit () or net_wait () call has failed, - allow the user to break the connection with the target. - We can't simply error () out of this loop, since the - data structures representing the state of the inferior - are in an inconsistent state. */ - - if (quit_failed || net_wait (&rdbEvent) == -1) - { - terminal_ours (); - if (query ("Can't %s. Disconnect from target system? ", - (quit_failed) ? "suspend remote task" - : "get status of remote task")) - { - target_mourn_inferior(); - error ("Use the \"target\" command to reconnect."); - } - else - { - terminal_inferior (); - continue; - } - } - - pid = rdbEvent.taskId; - if (pid == 0) - { - sleep_ms (200); /* FIXME Don't kill the network too badly */ - } - else if (pid != inferior_pid) - fatal ("Bad pid for debugged task: %s\n", local_hex_string(pid)); - } while (pid == 0); - - /* FIXME, eventually do more then SIGTRAP on everything... */ - switch (rdbEvent.eventType) - { - case EVENT_EXIT: - WSETEXIT (w, 0); - /* FIXME is it possible to distinguish between a - XXX normal vs abnormal exit in VxWorks? */ - break; - - case EVENT_START: /* Task was just started. */ - WSETSTOP (w, SIGTRAP); - break; - - case EVENT_STOP: - WSETSTOP (w, SIGTRAP); - /* XXX was it stopped by a signal? act accordingly */ - break; - - case EVENT_BREAK: /* Breakpoint was hit. */ - WSETSTOP (w, SIGTRAP); - break; - - case EVENT_SUSPEND: /* Task was suspended, probably by ^C. */ - WSETSTOP (w, SIGINT); - break; - - case EVENT_BUS_ERR: /* Task made evil nasty reference. */ - WSETSTOP (w, SIGBUS); - break; - - case EVENT_ZERO_DIV: /* Division by zero */ - WSETSTOP (w, SIGFPE); /* Like Unix, call it a float exception. */ - - case EVENT_SIGNAL: - /* The target is not running Unix, and its - faults/traces do not map nicely into Unix signals. - Make sure they do not get confused with Unix signals - by numbering them with values higher than the highest - legal Unix signal. code in the arch-dependent PRINT_RANDOM_SIGNAL - routine will interpret the value for wait_for_inferior. */ - WSETSTOP (w, rdbEvent.sigType + NSIG); - break; - } /* switch */ - *status = *(int *)&w; /* Grumble union wait crap Grumble */ - return pid; -} - -static int -symbol_stub (arg) - char *arg; -{ - symbol_file_command (arg, 0); - return 1; -} - -static int -add_symbol_stub (arg) - char *arg; -{ - struct ldfile *pLoadFile = (struct ldfile *)arg; - - printf("\t%s: ", pLoadFile->name); - symbol_file_add (pLoadFile->name, 0, pLoadFile->txt_addr, 0); - printf ("ok\n"); - return 1; -} -/* Target command for VxWorks target systems. - - Used in vxgdb. Takes the name of a remote target machine - running vxWorks and connects to it to initialize remote network - debugging. */ - -static void -vx_open (args, from_tty) - char *args; - int from_tty; -{ - extern int close (); - char *bootFile; - extern char *source_path; - struct ldtabl loadTable; - struct ldfile *pLoadFile; - int i; - extern CLIENT *pClient; - - if (!args) - error_no_arg ("target machine name"); - - target_preopen (from_tty); - - unpush_target (&vx_ops); - printf ("Attaching remote machine across net...\n"); - fflush (stdout); - - /* Allow the user to kill the connect attempt by typing ^C. - Wait until the call to target_has_fp () completes before - disallowing an immediate quit, since even if net_connect () - is successful, the remote debug server might be hung. */ - - immediate_quit++; - - net_connect (args); - target_has_fp = net_check_for_fp (); - printf_filtered ("Connected to %s.\n", args); - - immediate_quit--; - - push_target (&vx_ops); - - /* Save a copy of the target host's name. */ - vx_host = savestring (args, strlen (args)); - - /* Find out the name of the file from which the target was booted - and load its symbol table. */ - - printf_filtered ("Looking in Unix path for all loaded modules:\n"); - bootFile = NULL; - if (!net_get_boot_file (&bootFile)) - { - if (*bootFile) { - printf_filtered ("\t%s: ", bootFile); - if (catch_errors (symbol_stub, bootFile, - "Error while reading symbols from boot file:\n")) - puts_filtered ("ok\n"); - } else if (from_tty) - printf ("VxWorks kernel symbols not loaded.\n"); - } - else - error ("Can't retrieve boot file name from target machine."); - - clnt_freeres (pClient, xdr_wrapstring, &bootFile); - - if (net_get_symbols (&loadTable) != 0) - error ("Can't read loaded modules from target machine"); - - i = 0-1; - while (++i < loadTable.tbl_size) - { - QUIT; /* FIXME, avoids clnt_freeres below: mem leak */ - pLoadFile = &loadTable.tbl_ent [i]; -#ifdef WRS_ORIG - { - register int desc; - struct cleanup *old_chain; - char *fullname = NULL; - - desc = openp (source_path, 0, pLoadFile->name, O_RDONLY, 0, &fullname); - if (desc < 0) - perror_with_name (pLoadFile->name); - old_chain = make_cleanup (close, desc); - add_file_at_addr (fullname, desc, pLoadFile->txt_addr, pLoadFile->data_addr, - pLoadFile->bss_addr); - do_cleanups (old_chain); - } -#else - /* Botches, FIXME: - (1) Searches the PATH, not the source path. - (2) data and bss are assumed to be at the usual offsets from text. */ - catch_errors (add_symbol_stub, (char *)pLoadFile, (char *)0); -#endif - } - printf_filtered ("Done.\n"); - - clnt_freeres (pClient, xdr_ldtabl, &loadTable); -} - -/* attach_command -- - takes a task started up outside of gdb and ``attaches'' to it. - This stops it cold in its tracks and allows us to start tracing it. */ - -static void -vx_attach (args, from_tty) - char *args; - int from_tty; -{ - int pid; - char *cptr = 0; - Rptrace ptrace_in; - Ptrace_return ptrace_out; - int status; - - dont_repeat(); - - if (!args) - error_no_arg ("process-id to attach"); - - pid = strtol (args, &cptr, 0); - if ((cptr == args) || (*cptr != '\0')) - error ("Invalid process-id -- give a single number in decimal or 0xhex"); - - if (from_tty) - printf ("Attaching pid %s.\n", local_hex_string(pid)); - - bzero ((char *)&ptrace_in, sizeof (ptrace_in)); - bzero ((char *)&ptrace_out, sizeof (ptrace_out)); - ptrace_in.pid = pid; - - status = net_ptrace_clnt_call (PTRACE_ATTACH, &ptrace_in, &ptrace_out); - if (status == -1) - error (rpcerr); - if (ptrace_out.status == -1) - { - errno = ptrace_out.errno; - perror_with_name ("Attaching remote process"); - } - - /* It worked... */ - push_target (&vx_run_ops); - inferior_pid = pid; - vx_running = 0; - -#if defined (START_INFERIOR_HOOK) - START_INFERIOR_HOOK (); -#endif - - mark_breakpoints_out (); - - /* Set up the "saved terminal modes" of the inferior - based on what modes we are starting it with. */ - target_terminal_init (); - - /* Install inferior's terminal modes. */ - target_terminal_inferior (); - - /* We will get a task spawn event immediately. */ - init_wait_for_inferior (); - clear_proceed_status (); - stop_soon_quietly = 1; - wait_for_inferior (); - stop_soon_quietly = 0; - normal_stop (); -} - - -/* detach_command -- - takes a program previously attached to and detaches it. - The program resumes execution and will no longer stop - on signals, etc. We better not have left any breakpoints - in the program or it'll die when it hits one. For this - to work, it may be necessary for the process to have been - previously attached. It *might* work if the program was - started via the normal ptrace (PTRACE_TRACEME). */ - -static void -vx_detach (args, from_tty) - char *args; - int from_tty; -{ - Rptrace ptrace_in; - Ptrace_return ptrace_out; - int signal = 0; - int status; - - if (args) - error ("Argument given to VxWorks \"detach\"."); - - if (from_tty) - printf ("Detaching pid %s.\n", local_hex_string(inferior_pid)); - - if (args) /* FIXME, should be possible to leave suspended */ - signal = atoi (args); - - bzero ((char *)&ptrace_in, sizeof (ptrace_in)); - bzero ((char *)&ptrace_out, sizeof (ptrace_out)); - ptrace_in.pid = inferior_pid; - - status = net_ptrace_clnt_call (PTRACE_DETACH, &ptrace_in, &ptrace_out); - if (status == -1) - error (rpcerr); - if (ptrace_out.status == -1) - { - errno = ptrace_out.errno; - perror_with_name ("Detaching VxWorks process"); - } - - inferior_pid = 0; - pop_target (); /* go back to non-executing VxWorks connection */ -} - -/* vx_kill -- takes a running task and wipes it out. */ - -static void -vx_kill (args, from_tty) - char *args; - int from_tty; -{ - Rptrace ptrace_in; - Ptrace_return ptrace_out; - int status; - - if (args) - error ("Argument given to VxWorks \"kill\"."); - - if (from_tty) - printf ("Killing pid %s.\n", local_hex_string(inferior_pid)); - - bzero ((char *)&ptrace_in, sizeof (ptrace_in)); - bzero ((char *)&ptrace_out, sizeof (ptrace_out)); - ptrace_in.pid = inferior_pid; - - status = net_ptrace_clnt_call (PTRACE_KILL, &ptrace_in, &ptrace_out); - if (status == -1) - error (rpcerr); - if (ptrace_out.status == -1) - { - errno = ptrace_out.errno; - perror_with_name ("Killing VxWorks process"); - } - - /* If it gives good status, the process is *gone*, no events remain. */ - inferior_pid = 0; - pop_target (); /* go back to non-executing VxWorks connection */ -} - -/* Clean up from the VxWorks process target as it goes away. */ - -void -vx_proc_close (quitting) - int quitting; -{ - inferior_pid = 0; /* No longer have a process. */ - if (vx_running) - free (vx_running); - vx_running = 0; -} - -/* Cross-net conversion of floats to and from extended form. - (This is needed because different target machines have different - extended floating point formats.) */ - -/* Convert from an extended float to a double. - - The extended float is stored as raw data pointed to by FROM. - Return the converted value as raw data in the double pointed to by TO. -*/ - -static void -vx_convert_to_virtual (regno, from, to) - int regno; - char *from; - char *to; -{ - enum clnt_stat status; - - if (REGISTER_CONVERTIBLE (regno)) - { - if (!target_has_fp) { - *(double *)to = 0.0; /* Skip the trouble if no float anyway */ - return; - } - - status = net_clnt_call (VX_CONV_FROM_68881, xdr_ext_fp, from, - xdr_double, to); - - if (status == RPC_SUCCESS) - return; - else - error (rpcerr); - } - else - bcopy (from, to, REGISTER_VIRTUAL_SIZE (regno)); -} - - -/* The converse: convert from a double to an extended float. - - The double is stored as raw data pointed to by FROM. - Return the converted value as raw data in the extended - float pointed to by TO. -*/ - -static void -vx_convert_from_virtual (regno, from, to) - int regno; - char *from; - char *to; -{ - enum clnt_stat status; - - if (REGISTER_CONVERTIBLE (regno)) - { - if (!target_has_fp) { - bzero (to, REGISTER_RAW_SIZE (FP0_REGNUM)); /* Shrug */ - return; - } - - status = net_clnt_call (VX_CONV_TO_68881, xdr_double, from, - xdr_ext_fp, to); - if (status == RPC_SUCCESS) - return; - else - error (rpcerr); - } - else - bcopy (from, to, REGISTER_VIRTUAL_SIZE (regno)); -} - -/* Make an RPC call to the VxWorks target. - Returns RPC status. */ - -static enum clnt_stat -net_clnt_call (procNum, inProc, in, outProc, out) - enum ptracereq procNum; - xdrproc_t inProc; - char *in; - xdrproc_t outProc; - char *out; -{ - enum clnt_stat status; - - status = clnt_call (pClient, procNum, inProc, in, outProc, out, rpcTimeout); - - if (status != RPC_SUCCESS) - clnt_perrno (status); - - return status; -} - -/* Clean up before losing control. */ - -void -vx_close (quitting) - int quitting; -{ - if (pClient) - clnt_destroy (pClient); /* The net connection */ - pClient = 0; - - if (vx_host) - free (vx_host); /* The hostname */ - vx_host = 0; -} - -/* A vxprocess target should be started via "run" not "target". */ -/*ARGSUSED*/ -static void -vx_proc_open (name, from_tty) - char *name; - int from_tty; -{ - error ("Use the \"run\" command to start a VxWorks process."); -} - -/* Target ops structure for accessing memory and such over the net */ - -struct target_ops vx_ops = { - "vxworks", "VxWorks target memory via RPC over TCP/IP", - "Use VxWorks target memory. \n\ -Specify the name of the machine to connect to.", - vx_open, vx_close, vx_attach, 0, /* vx_detach, */ - 0, 0, /* resume, wait */ - 0, 0, /* read_reg, write_reg */ - 0, vx_convert_to_virtual, vx_convert_from_virtual, /* prep_to_store, */ - vx_xfer_memory, vx_files_info, - 0, 0, /* insert_breakpoint, remove_breakpoint */ - 0, 0, 0, 0, 0, /* terminal stuff */ - 0, /* vx_kill, */ - vx_load_command, - 0, /* call_function */ - vx_lookup_symbol, - vx_create_inferior, 0, /* mourn_inferior */ - core_stratum, 0, /* next */ - 1, 1, 0, 0, 0, /* all mem, mem, stack, regs, exec */ - 0, 0, /* Section pointers */ - OPS_MAGIC, /* Always the last thing */ -}; - -/* Target ops structure for accessing VxWorks child processes over the net */ - -struct target_ops vx_run_ops = { - "vxprocess", "VxWorks process", - "VxWorks process, started by the \"run\" command.", - vx_proc_open, vx_proc_close, 0, vx_detach, /* vx_attach */ - vx_resume, vx_wait, - vx_read_register, vx_write_register, - vx_prepare_to_store, vx_convert_to_virtual, vx_convert_from_virtual, - vx_xfer_memory, vx_run_files_info, - vx_insert_breakpoint, vx_remove_breakpoint, - 0, 0, 0, 0, 0, /* terminal stuff */ - vx_kill, - vx_load_command, - call_function_by_hand, /* FIXME, calling fns is maybe botched? */ - vx_lookup_symbol, - 0, vx_mourn_inferior, - process_stratum, 0, /* next */ - 0, 1, 1, 1, 1, /* all mem, mem, stack, regs, exec */ - /* all_mem is off to avoid spurious msg in "i files" */ - 0, 0, /* Section pointers */ - OPS_MAGIC, /* Always the last thing */ -}; -/* ==> Remember when reading at end of file, there are two "ops" structs here. */ - -void -_initialize_vx () -{ - add_target (&vx_ops); - add_target (&vx_run_ops); -} diff --git a/gdb/remote.c b/gdb/remote.c deleted file mode 100644 index 821524392ad..00000000000 --- a/gdb/remote.c +++ /dev/null @@ -1,854 +0,0 @@ -/* Memory-access and commands for inferior process, for GDB. - Copyright (C) 1988-1991 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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 1, or (at your option) -any later version. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Remote communication protocol. - All values are encoded in ascii hex digits. - - Request Packet - - read registers g - reply XX....X Each byte of register data - is described by two hex digits. - Registers are in the internal order - for GDB, and the bytes in a register - are in the same order the machine uses. - or ENN for an error. - - write regs GXX..XX Each byte of register data - is described by two hex digits. - reply OK for success - ENN for an error - - read mem mAA..AA,LLLL AA..AA is address, LLLL is length. - reply XX..XX XX..XX is mem contents - or ENN NN is errno - - write mem MAA..AA,LLLL:XX..XX - AA..AA is address, - LLLL is number of bytes, - XX..XX is data - reply OK for success - ENN for an error - - cont cAA..AA AA..AA is address to resume - If AA..AA is omitted, - resume at same address. - - step sAA..AA AA..AA is address to resume - If AA..AA is omitted, - resume at same address. - - last signal ? Reply the current reason for stopping. - This is the same reply as is generated - for step or cont : SAA where AA is the - signal number. - - There is no immediate reply to step or cont. - The reply comes when the machine stops. - It is SAA AA is the "signal number" - - kill req k -*/ - -#include -#include -#include -#include "defs.h" -#include "param.h" -#include "frame.h" -#include "inferior.h" -#include "target.h" -#include "wait.h" -#include "terminal.h" - -#ifdef USG -#include -#endif - -#include - -extern void add_syms_addr_command (); -extern struct value *call_function_by_hand(); -extern void start_remote (); - -extern struct target_ops remote_ops; /* Forward decl */ - -static int kiodebug; -static int timeout = 5; - -#if 0 -int icache; -#endif - -/* Descriptor for I/O to remote machine. Initialize it to -1 so that - remote_open knows that we don't have a file open when the program - starts. */ -int remote_desc = -1; - -#define PBUFSIZ 400 - -/* 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). */ -#define MAXBUFBYTES ((PBUFSIZ-32)/2) - -static void remote_send (); -static void putpkt (); -static void getpkt (); -#if 0 -static void dcache_flush (); -#endif - - -/* Called when SIGALRM signal sent due to alarm() timeout. */ -#ifndef HAVE_TERMIO -void -remote_timer () -{ - if (kiodebug) - printf ("remote_timer called\n"); - - alarm (timeout); -} -#endif - -/* Initialize remote connection */ - -void -remote_start() -{ -} - -/* Clean up connection to a remote debugger. */ - -/* ARGSUSED */ -void -remote_close (quitting) - int quitting; -{ - if (remote_desc >= 0) - close (remote_desc); - remote_desc = -1; -} - -/* Open a connection to a remote debugger. - NAME is the filename used for communication. */ - -void -remote_open (name, from_tty) - char *name; - int from_tty; -{ - TERMINAL sg; - - if (name == 0) - error ( -"To open a remote debug connection, you need to specify what serial\n\ -device is attached to the remote system (e.g. /dev/ttya)."); - - target_preopen (from_tty); - - remote_close (0); - -#if 0 - dcache_init (); -#endif - - remote_desc = open (name, O_RDWR); - if (remote_desc < 0) - perror_with_name (name); - - ioctl (remote_desc, TIOCGETP, &sg); -#ifdef HAVE_TERMIO - sg.c_cc[VMIN] = 0; /* read with timeout. */ - sg.c_cc[VTIME] = timeout * 10; - sg.c_lflag &= ~(ICANON | ECHO); -#else - sg.sg_flags = RAW; -#endif - ioctl (remote_desc, TIOCSETP, &sg); - - if (from_tty) - printf ("Remote debugging using %s\n", name); - push_target (&remote_ops); /* Switch to using remote target now */ - -#ifndef HAVE_TERMIO -#ifndef NO_SIGINTERRUPT - /* Cause SIGALRM's to make reads fail. */ - if (siginterrupt (SIGALRM, 1) != 0) - perror ("remote_open: error in siginterrupt"); -#endif - - /* Set up read timeout timer. */ - if ((void (*)()) signal (SIGALRM, remote_timer) == (void (*)()) -1) - perror ("remote_open: error in signal"); -#endif - - /* Ack any packet which the remote side has already sent. */ - write (remote_desc, "+", 1); - putpkt ("?"); /* initiate a query from remote machine */ - - start_remote (); /* Initialize gdb process mechanisms */ -} - -/* remote_detach() - takes a program previously attached to and detaches it. - We better not have left any breakpoints - in the program or it'll die when it hits one. - Close the open connection to the remote debugger. - Use this when you want to detach and do something else - with your gdb. */ - -static void -remote_detach (args, from_tty) - char *args; - int from_tty; -{ - if (args) - error ("Argument given to \"detach\" when remotely debugging."); - - pop_target (); - if (from_tty) - printf ("Ending remote debugging.\n"); -} - -/* Convert hex digit A to a number. */ - -static int -fromhex (a) - int a; -{ - if (a >= '0' && a <= '9') - return a - '0'; - else if (a >= 'a' && a <= 'f') - return a - 'a' + 10; - else - error ("Reply contains invalid hex digit"); - return -1; -} - -/* Convert number NIB to a hex digit. */ - -static int -tohex (nib) - int nib; -{ - if (nib < 10) - return '0'+nib; - else - return 'a'+nib-10; -} - -/* Tell the remote machine to resume. */ - -void -remote_resume (step, siggnal) - int step, siggnal; -{ - char buf[PBUFSIZ]; - - if (siggnal) - error ("Can't send signals to a remote system."); - -#if 0 - dcache_flush (); -#endif - - strcpy (buf, step ? "s": "c"); - - putpkt (buf); -} - -/* Wait until the remote machine stops, then return, - storing status in STATUS just as `wait' would. - Returns "pid" (though it's not clear what, if anything, that - means in the case of this target). */ - -int -remote_wait (status) - WAITTYPE *status; -{ - unsigned char buf[PBUFSIZ]; - - WSETEXIT ((*status), 0); - getpkt (buf); - if (buf[0] == 'E') - error ("Remote failure reply: %s", buf); - if (buf[0] != 'S') - error ("Invalid remote reply: %s", buf); - WSETSTOP ((*status), (((fromhex (buf[1])) << 4) + (fromhex (buf[2])))); - return 0; -} - -/* Read the remote registers into the block REGS. */ - -/* Currently we just read all the registers, so we don't use regno. */ -/* ARGSUSED */ -void -remote_fetch_registers (regno) - int regno; -{ - char buf[PBUFSIZ]; - int i; - char *p; - char regs[REGISTER_BYTES]; - - sprintf (buf, "g"); - remote_send (buf); - - /* Reply describes registers byte by byte, each byte encoded as two - hex characters. Suck them all up, then supply them to the - register cacheing/storage mechanism. */ - - p = buf; - for (i = 0; i < REGISTER_BYTES; i++) - { - if (p[0] == 0 || p[1] == 0) - error ("Remote reply is too short: %s", buf); - regs[i] = fromhex (p[0]) * 16 + fromhex (p[1]); - p += 2; - } - for (i = 0; i < NUM_REGS; i++) - supply_register (i, ®s[REGISTER_BYTE(i)]); -} - -/* Prepare to store registers. Since we send them all, we have to - read out the ones we don't want to change first. */ - -void -remote_prepare_to_store () -{ - remote_fetch_registers (-1); -} - -/* Store the remote registers from the contents of the block REGISTERS. - FIXME, eventually just store one register if that's all that is needed. */ - -/* ARGSUSED */ -int -remote_store_registers (regno) - int regno; -{ - char buf[PBUFSIZ]; - int i; - char *p; - - buf[0] = 'G'; - - /* Command describes registers byte by byte, - each byte encoded as two hex characters. */ - - p = buf + 1; - for (i = 0; i < REGISTER_BYTES; i++) - { - *p++ = tohex ((registers[i] >> 4) & 0xf); - *p++ = tohex (registers[i] & 0xf); - } - *p = '\0'; - - remote_send (buf); - return 0; -} - -#if 0 -/* Read a word from remote address ADDR and return it. - This goes through the data cache. */ - -int -remote_fetch_word (addr) - CORE_ADDR addr; -{ - if (icache) - { - extern CORE_ADDR text_start, text_end; - - if (addr >= text_start && addr < text_end) - { - int buffer; - xfer_core_file (addr, &buffer, sizeof (int)); - return buffer; - } - } - return dcache_fetch (addr); -} - -/* Write a word WORD into remote address ADDR. - This goes through the data cache. */ - -void -remote_store_word (addr, word) - CORE_ADDR addr; - int word; -{ - dcache_poke (addr, word); -} -#endif /* 0 */ - -/* Write memory data directly to the remote machine. - This does not inform the data cache; the data cache uses this. - MEMADDR is the address in the remote memory space. - MYADDR is the address of the buffer in our space. - LEN is the number of bytes. */ - -void -remote_write_bytes (memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - char buf[PBUFSIZ]; - int i; - char *p; - - if (len > PBUFSIZ / 2 - 20) - abort (); - - sprintf (buf, "M%x,%x:", memaddr, len); - - /* Command describes registers byte by byte, - each byte encoded as two hex characters. */ - - p = buf + strlen (buf); - for (i = 0; i < len; i++) - { - *p++ = tohex ((myaddr[i] >> 4) & 0xf); - *p++ = tohex (myaddr[i] & 0xf); - } - *p = '\0'; - - remote_send (buf); -} - -/* Read memory data directly from the remote machine. - This does not use the data cache; the data cache uses this. - MEMADDR is the address in the remote memory space. - MYADDR is the address of the buffer in our space. - LEN is the number of bytes. */ - -void -remote_read_bytes (memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - char buf[PBUFSIZ]; - int i; - char *p; - - if (len > PBUFSIZ / 2 - 1) - abort (); - - sprintf (buf, "m%x,%x", memaddr, len); - remote_send (buf); - - /* Reply describes registers byte by byte, - each byte encoded as two hex characters. */ - - p = buf; - for (i = 0; i < len; i++) - { - if (p[0] == 0 || p[1] == 0) - error ("Remote reply is too short: %s", buf); - myaddr[i] = fromhex (p[0]) * 16 + fromhex (p[1]); - p += 2; - } -} - -/* Read or write LEN bytes from inferior memory at MEMADDR, transferring - to or from debugger address MYADDR. Write to inferior if SHOULD_WRITE is - nonzero. Returns length of data written or read; 0 for error. */ - -int -remote_xfer_inferior_memory(memaddr, myaddr, len, should_write) - CORE_ADDR memaddr; - char *myaddr; - int len; - int should_write; -{ - int origlen = len; - int xfersize; - while (len > 0) - { - if (len > MAXBUFBYTES) - xfersize = MAXBUFBYTES; - else - xfersize = len; - - if (should_write) - remote_write_bytes(memaddr, myaddr, xfersize); - else - remote_read_bytes (memaddr, myaddr, xfersize); - memaddr += xfersize; - myaddr += xfersize; - len -= xfersize; - } - return origlen; /* no error possible */ -} - -void -remote_files_info () -{ - printf ("remote files info missing here. FIXME.\n"); -} - -/* - -A debug packet whose contents are -is encapsulated for transmission in the form: - - $ # CSUM1 CSUM2 - - must be ASCII alphanumeric and cannot include characters - '$' or '#' - - CSUM1 and CSUM2 are ascii hex representation of an 8-bit - checksum of , the most significant nibble is sent first. - the hex digits 0-9,a-f are used. - -Receiver responds with: - - + - if CSUM is correct and ready for next packet - - - if CSUM is incorrect - -*/ - -static int -readchar () -{ - char buf; - - buf = '\0'; -#ifdef HAVE_TERMIO - /* termio does the timeout for us. */ - read (remote_desc, &buf, 1); -#else - alarm (timeout); - read (remote_desc, &buf, 1); - alarm (0); -#endif - - return buf & 0x7f; -} - -/* Send the command in BUF to the remote machine, - and read the reply into BUF. - Report an error if we get an error reply. */ - -static void -remote_send (buf) - char *buf; -{ - - putpkt (buf); - getpkt (buf); - - if (buf[0] == 'E') - error ("Remote failure reply: %s", buf); -} - -/* Send a packet to the remote machine, with error checking. - The data of the packet is in BUF. */ - -static void -putpkt (buf) - char *buf; -{ - int i; - unsigned char csum = 0; - char buf2[500]; - int cnt = strlen (buf); - char ch; - char *p; - - /* Copy the packet into buffer BUF2, encapsulating it - and giving it a checksum. */ - - p = buf2; - *p++ = '$'; - - for (i = 0; i < cnt; i++) - { - csum += buf[i]; - *p++ = buf[i]; - } - *p++ = '#'; - *p++ = tohex ((csum >> 4) & 0xf); - *p++ = tohex (csum & 0xf); - - /* Send it over and over until we get a positive ack. */ - - do { - if (kiodebug) - { - *p = '\0'; - printf ("Sending packet: %s (%s)\n", buf2, buf); - } - write (remote_desc, buf2, p - buf2); - - /* read until either a timeout occurs (\0) or '+' is read */ - do { - ch = readchar (); - } while ((ch != '+') && (ch != '\0')); - } while (ch != '+'); -} - -/* Read a packet from the remote machine, with error checking, - and store it in BUF. */ - -static void -getpkt (buf) - char *buf; -{ - char *bp; - unsigned char csum; - int c; - unsigned char c1, c2; - -#if 0 - /* Sorry, this will cause all hell to break loose, i.e. we'll end - up in the command loop with an inferior, but (at least if this - happens in remote_wait or some such place) without a current_frame, - having set up prev_* in wait_for_inferior, etc. - - If it is necessary to have such an "emergency exit", seems like - the only plausible thing to do is to say the inferior died, and - make the user reattach if they want to. Perhaps with a prompt - asking for confirmation. */ - - /* allow immediate quit while reading from device, it could be hung */ - immediate_quit++; -#endif /* 0 */ - - while (1) - { - /* Force csum to be zero here because of possible error retry. */ - csum = 0; - - while ((c = readchar()) != '$'); - - bp = buf; - while (1) - { - c = readchar (); - if (c == '#') - break; - *bp++ = c; - csum += c; - } - *bp = 0; - - c1 = fromhex (readchar ()); - c2 = fromhex (readchar ()); - if ((csum & 0xff) == (c1 << 4) + c2) - break; - printf ("Bad checksum, sentsum=0x%x, csum=0x%x, buf=%s\n", - (c1 << 4) + c2, csum & 0xff, buf); - write (remote_desc, "-", 1); - } - -#if 0 - immediate_quit--; -#endif - - write (remote_desc, "+", 1); - - if (kiodebug) - fprintf (stderr,"Packet received :%s\n", buf); -} - -/* The data cache leads to incorrect results because it doesn't know about - volatile variables, thus making it impossible to debug functions which - use hardware registers. Therefore it is #if 0'd out. Effect on - performance is some, for backtraces of functions with a few - arguments each. For functions with many arguments, the stack - frames don't fit in the cache blocks, which makes the cache less - helpful. Disabling the cache is a big performance win for fetching - large structures, because the cache code fetched data in 16-byte - chunks. */ -#if 0 -/* The data cache records all the data read from the remote machine - since the last time it stopped. - - Each cache block holds 16 bytes of data - starting at a multiple-of-16 address. */ - -#define DCACHE_SIZE 64 /* Number of cache blocks */ - -struct dcache_block { - struct dcache_block *next, *last; - unsigned int addr; /* Address for which data is recorded. */ - int data[4]; -}; - -struct dcache_block dcache_free, dcache_valid; - -/* Free all the data cache blocks, thus discarding all cached data. */ - -static void -dcache_flush () -{ - register struct dcache_block *db; - - while ((db = dcache_valid.next) != &dcache_valid) - { - remque (db); - insque (db, &dcache_free); - } -} - -/* - * If addr is present in the dcache, return the address of the block - * containing it. - */ - -struct dcache_block * -dcache_hit (addr) -{ - register struct dcache_block *db; - - if (addr & 3) - abort (); - - /* Search all cache blocks for one that is at this address. */ - db = dcache_valid.next; - while (db != &dcache_valid) - { - if ((addr & 0xfffffff0) == db->addr) - return db; - db = db->next; - } - return NULL; -} - -/* Return the int data at address ADDR in dcache block DC. */ - -int -dcache_value (db, addr) - struct dcache_block *db; - unsigned int addr; -{ - if (addr & 3) - abort (); - return (db->data[(addr>>2)&3]); -} - -/* Get a free cache block, put it on the valid list, - and return its address. The caller should store into the block - the address and data that it describes. */ - -struct dcache_block * -dcache_alloc () -{ - register struct dcache_block *db; - - if ((db = dcache_free.next) == &dcache_free) - /* If we can't get one from the free list, take last valid */ - db = dcache_valid.last; - - remque (db); - insque (db, &dcache_valid); - return (db); -} - -/* Return the contents of the word at address ADDR in the remote machine, - using the data cache. */ - -int -dcache_fetch (addr) - CORE_ADDR addr; -{ - register struct dcache_block *db; - - db = dcache_hit (addr); - if (db == 0) - { - db = dcache_alloc (); - remote_read_bytes (addr & ~0xf, db->data, 16); - db->addr = addr & ~0xf; - } - return (dcache_value (db, addr)); -} - -/* Write the word at ADDR both in the data cache and in the remote machine. */ - -dcache_poke (addr, data) - CORE_ADDR addr; - int data; -{ - register struct dcache_block *db; - - /* First make sure the word is IN the cache. DB is its cache block. */ - db = dcache_hit (addr); - if (db == 0) - { - db = dcache_alloc (); - remote_read_bytes (addr & ~0xf, db->data, 16); - db->addr = addr & ~0xf; - } - - /* Modify the word in the cache. */ - db->data[(addr>>2)&3] = data; - - /* Send the changed word. */ - remote_write_bytes (addr, &data, 4); -} - -/* Initialize the data cache. */ - -dcache_init () -{ - register i; - register struct dcache_block *db; - - db = (struct dcache_block *) xmalloc (sizeof (struct dcache_block) * - DCACHE_SIZE); - dcache_free.next = dcache_free.last = &dcache_free; - dcache_valid.next = dcache_valid.last = &dcache_valid; - for (i=0;i -#include "defs.h" -#include "rs6k-opcode.h" - - -/* Print the rs6k instruction at address MEMADDR in debugged memory, - on STREAM. Returns length of the instruction, in bytes. */ - -int -print_insn (memaddr, stream) - CORE_ADDR memaddr; - FILE *stream; -{ - int pop, eop; /* primary and extended opcodes */ - int min, max; - int best = -1; /* found best opcode index */ - int oldbest = -1; - unsigned int the_insn; - - read_memory (memaddr, &the_insn, sizeof (the_insn)); - pop = (unsigned)(the_insn >> 26); - eop = ((the_insn) >> 1) & 0x3ff; - min = 0, max = NOPCODES-1; - - while (min < max) { - best = (min + max) / 2; - - /* see if we are running in loops */ - if (best == oldbest) - goto not_found; - oldbest = best; - - if (pop < rs6k_ops [best].p_opcode) - max = best; - - else if (pop > rs6k_ops [best].p_opcode) - min = best; - - else { - /* opcode matched, check extended opcode. */ - - if (rs6k_ops [best].e_opcode == -1) { - /* there is no valid extended opcode, what we've got is - just fine. */ - goto insn_found; - } - - else if (eop < rs6k_ops [best].e_opcode) { - - while (pop == rs6k_ops [best].p_opcode) { - if (eop == rs6k_ops [best].e_opcode) /* found it! */ - goto insn_found; - --best; - } - goto not_found; - } - - else if (eop > rs6k_ops [best].e_opcode) { - - while (pop == rs6k_ops [best].p_opcode) { - if (eop == rs6k_ops [best].e_opcode) /* found it! */ - goto insn_found; - ++best; - } - goto not_found; - } - - else /* eop == rs6k_ops [best].e_opcode */ - goto insn_found; - } - } - - best = min; - if (pop == rs6k_ops [best].p_opcode && - (rs6k_ops [best].e_opcode == -1 || rs6k_ops [best].e_opcode == eop)) - goto insn_found; - - else - goto not_found; - - -insn_found: - print_operator (stream, memaddr, the_insn, best); - return 4; - -not_found: - fprintf (stream, "0x%08x", the_insn); - return 4; -} - - - -/* condition code names */ -static char *cond_code [] = { - "lt", "gt", "eq", "so", "ge", "le", "ne", "ns", "nl", "ng", "z", "nz" }; - - -print_operator (stream, memaddr, insn_word, insn_no) -FILE *stream; -long memaddr; -long insn_word; -int insn_no; -{ - char buf [BUFSIZ]; - char *qq = buf; - char *pp = rs6k_ops[insn_no].opr_ext; - int tmp; - int nocomma = 0; /* true if no comma needed */ - - *qq = '\0'; - if (pp) { - while (*pp) { - - switch ( *pp ) { - case '.': - if (insn_word & 0x1) - *qq++ = '.'; - break; - - case 'l': - if (insn_word & 0x1) - *qq++ = 'l'; - break; - - case 't': - if ((insn_word & 0x03e00000) == 0x01800000) - *qq++ = 't'; - break; - - case 'f': - if ((insn_word & 0x03e00000) == 0x00800000) - *qq++ = 'f'; - break; - - case 'a': - if (insn_word & 0x2) - *qq++ = 'a'; - break; - - case 'o': - if (insn_word & 0x4000) - *qq++ = 'o'; - break; - - case '1': /* exception #1 for bb/bc ambiguity */ - tmp = (insn_word >> 21) & 0x1f; /* extract BO */ - if (tmp != 0xc && tmp != 0x4) { - /* you can't use `bb' now. switch to `bc' */ - *(qq-1) = 'c'; - ++insn_no; - pp = rs6k_ops[insn_no].opr_ext; - continue; - } - break; - - default: - abort (); - } - ++pp; - } - } - - /* tab between orerator and operand */ - *qq++ = '\t'; - - /* parse the operand now. */ - pp = rs6k_ops[insn_no].oprnd_format; - - while (1) { - switch (*pp) { - case TO : - sprintf (qq, "%d", (insn_word >> 21) & 0x1f); - break; - - case RT : - case RS : - sprintf (qq, "r%d", (insn_word >> 21) & 0x1f); - break; - - case LI : - tmp = (insn_word >> 16) & 0x1f; - if (tmp > 11) { - fprintf (stderr, "Internal error: unknown cond code: 0x%x\n", insn_word); - tmp = 0; - } - sprintf (qq, "%s", cond_code [tmp]); - break; - -#if 0 - case A2 : - tmp = (insn_word >> 2) & 0x3fff; - if (tmp & 0x2000) - tmp -= 0x4000; - sprintf (qq, "0x%x", tmp * 4 + memaddr); - break; -#endif - case A2 : - case TA14 : - tmp = (insn_word & 0xfffc); - if (tmp & 0x8000) /* fix sign extension */ - tmp -= 0x10000; - - if ((insn_word & 0x2) == 0) /* if AA not set */ - tmp += memaddr; - - sprintf (qq, "0x%x", tmp); - break; - - case TA24 : - tmp = insn_word & 0x03fffffc; - if (tmp & 0x2000000) - tmp -= 0x4000000; - - if ((insn_word & 0x2) == 0) /* if no AA bit set */ - tmp += memaddr; - - sprintf (qq, "0x%x", tmp); - break; - - case LEV : /* for svc only */ - if (insn_word & 0x2) { /* SA is set */ - nocomma = 1; - *qq = '\0'; - } - else - sprintf (qq, "%d", (insn_word >> 5) & 0x7f); - break; - - case FL1 : /* for svc only */ - if (insn_word & 0x2) { /* SA is set */ - nocomma = 1; - *qq = '\0'; - } - else - sprintf (qq, "%d", (insn_word >> 12) & 0xf); - break; - - case FL2 : /* for svc only */ - nocomma = 0; - if (insn_word & 0x2) /* SA is set */ - sprintf (qq, "%d", (insn_word >> 2) & 0x3fff); - else - sprintf (qq, "%d", (insn_word >> 2) & 0x7); - break; - - case RA : - if (nocomma) { - sprintf (qq, "r%d)", (insn_word >> 16) & 0x1f); - nocomma = 0; - } - else - sprintf (qq, "r%d", (insn_word >> 16) & 0x1f); - break; - - case RB : - sprintf (qq, "r%d", (insn_word >> 11) & 0x1f); - break; - - case SI : - tmp = insn_word & 0xffff; - if (tmp & 0x8000) - tmp -= 0x10000; - sprintf (qq, "%d", tmp); - break; - - case UI : - sprintf (qq, "%d", insn_word & 0xffff); - break; - - case BF : - sprintf (qq, "%d", (insn_word >> 23) & 0x7); - break; - - case BFA : - sprintf (qq, "%d", (insn_word >> 18) & 0x7); - break; - - case BT : - sprintf (qq, "%d", (insn_word >> 21) & 0x1f); - break; - - case BA : - sprintf (qq, "%d", (insn_word >> 16) & 0x1f); - break; - - case BB : - sprintf (qq, "%d", (insn_word >> 11) & 0x1f); - break; - - case BO : - sprintf (qq, "%d", (insn_word >> 21) & 0x1f); - break; - - case BI : - sprintf (qq, "%d", (insn_word >> 16) & 0x1f); - break; - - case SH : - sprintf (qq, "%d", (insn_word >> 11) & 0x1f); - break; - - case MB : - sprintf (qq, "0x%x", (insn_word >> 6) & 0x1f); - break; - - case ME : - sprintf (qq, "0x%x", (insn_word >> 1) & 0x1f); - break; - - case SPR : - sprintf (qq, "%d", (insn_word >> 16) & 0x1f); - break; - - case DIS : - nocomma = 1; - tmp = insn_word & 0xffff; - if (tmp & 0x8000) - tmp -= 0x10000; - sprintf (qq, "%d(", tmp); - break; - - case FXM : - sprintf (qq, "0x%x", (insn_word >> 12) & 0xff); - break; - - case FRT : - case FRS : - sprintf (qq, "f%d", (insn_word >> 21) & 0x1f); - break; - - case FRA : - sprintf (qq, "f%d", (insn_word >> 16) & 0x1f); - break; - - case FRB : - sprintf (qq, "f%d", (insn_word >> 11) & 0x1f); - break; - - case FRC : - sprintf (qq, "f%d", (insn_word >> 6) & 0x1f); - break; - - case FLM : - sprintf (qq, "0x%x", (insn_word >> 17) & 0xff); - break; - - case NB : - sprintf (qq, "%d", (insn_word >> 11) & 0x1f); - break; - - case I : - sprintf (qq, "%d", (insn_word >> 12) & 0xf); - break; - - default : - sprintf (qq, "Unknown operand format identifier????"); - abort (); - } - while (*qq) ++qq; - ++pp; - - if (*pp == '\0') - break; - else if (!nocomma) - *qq++ = ','; - } - *qq = '\0'; - - fprintf (stream, "0x%08x\t%s%s", - insn_word, rs6k_ops[insn_no].operator, buf); -} - diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c deleted file mode 100644 index 4003de07daa..00000000000 --- a/gdb/rs6000-tdep.c +++ /dev/null @@ -1,975 +0,0 @@ -/* Target-dependent code for GDB, the GNU debugger. - Copyright (C) 1986, 1987, 1989, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include - -#include "defs.h" -#include "param.h" -#include "frame.h" -#include "inferior.h" -#include "symtab.h" -#include "target.h" - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include - -extern int errno; -extern int attach_flag; - -/* Nonzero if we just simulated a single step break. */ -int one_stepped; - -#if 0 - -/* This is Damon's implementation of single step simulation. It suffers the - following program: - - 1 main () { - 2 char buf[10]; - 3 puts ("test"); - 4 strcmp (buf, "test"); puts ("test"); - 5 exit (0); - 6 } - - You cannot `next' on line 4 in the above program. gdb puts a breakpoint - to the return address of `strcmp', and when execution arrives that point, - it is still in the line range and gdb attemps to resume it with single - steps. At that point the breakpoint at step_resume_break_address (return - address of strcmp) and single step's breakpoint mixes up and we end up - with a breakpoint which its shadow and itself are identical. - - Fix that problem and use this version. FIXMEmgo. -*/ - - -static struct sstep_breaks { - int address; - int data; -} tbreak[2]; - - -/* - * branch_dest - calculate all places the current instruction may go - */ -static -branch_dest(tb) - register struct sstep_breaks *tb; -{ - register ulong opcode, iar; - long instr; - int immediate, absolute;; - - iar = read_pc(); /* current IAR */ - target_read_memory(iar, &instr, sizeof (instr)); /* current inst */ - - opcode = instr >> 26; - absolute = instr & 2; - - tb[1].address = -1; - - switch (opcode) { - case 0x10: /* branch conditional */ - immediate = ((instr & ~3) << 16) >> 16; - - /* - * two possible locations for next instruction - */ - tb[0].address = iar + 4; - tb[1].address = immediate + (absolute ? 0 : iar); - - break; - - case 0x12: /* branch unconditional */ - immediate = ((instr & ~3) << 6) >> 6; - - /* - * only one possible location for next instr - */ - tb[0].address = immediate + (absolute ? 0 : iar); - - break; - - case 0x13: /* branch conditional register */ - /* - * WE NEED TO CHECK THE CR HERE, TO SEE IF THIS IS - * REALLY UNCONDITIONAL. - */ - tb++->address = iar + 4; - - switch ((instr >> 1) & 0x3ff) { - case 0x10: /* branch conditional register */ - tb->address = read_register(LR_REGNUM) & ~3; - sigtramp_chk(tb); /* return from sig handler? */ - break; - - case 0x210: /* branch cond to CTR */ - tb->address = read_register(CTR_REGNUM) & ~3; - sigtramp_chk(tb); /* return from sig handler? */ - break; - - default: - /* - * not a branch. - */ - tb->address = iar + 4; - break; - } - break; - - default: - /* - * not a branch, flow proceeds normally - */ - tb->address = iar + 4; - break; - } -} - -/* - * sigtramp_chk - heuristic check to see if we think we are returning - * from a signal handler. - * - * Input: - * tb - ^ to a single step branch location - * - * Note: - * When we are at the "br" instruction returning to a signal handler, - * we return in user mode to an address in the kernel. If the - * segment of the branch target is 0, we may very well be in a - * signal handler. From scrounging through this code, we note that - * register 29 has the signal context pointer, from which we can - * determine where we will end up next. - */ -sigtramp_chk(tb) -register struct sstep_breaks *tb; { - struct sigcontext sc; - - if (tb->address & 0xf0000000) - return; /* can't have been sigtramp */ - - if (target_read_memory(read_register(GPR29), &sc, sizeof (sc))) - return; /* read fails, heuristic fails */ - - if ((sc.sc_jmpbuf.jmp_context.iar & 0xf0000000) == 0x10000000) { - /* - * looks like it might be ok..... - */ - tb->address = sc.sc_jmpbuf.jmp_context.iar; - } -} - - -/* - * single_step - no trace mode harware support, or software support. - * sigh. - */ -single_step(signal) { - register i; - - if (!one_stepped) { - /* - * need to set breakpoints for single step. - * figure out all places the current instruction could go. - */ - branch_dest(&tbreak[0]); - - /* - * always at least one place to go to - */ - target_insert_breakpoint(tbreak[0].address, &tbreak[0].data); - - /* - * if there is another possible location, set a breakpoint there - * as well. - */ - if (tbreak[1].address != -1) - target_insert_breakpoint(tbreak[1].address, &tbreak[1].data); - - one_stepped = 1; - ptrace(PT_CONTINUE, inferior_pid, 1, signal, 0); - } else { - /* - * need to clear the breakpoints. - */ - for (i = 0; i < 2; ++i) - if (tbreak[i].address != -1) - target_remove_breakpoint(tbreak[i].address, &tbreak[i].data); - - one_stepped = 0; - } - - return 1; -} - -#else /* !DAMON'S VERSION */ - -/* Breakpoint shadows for the single step instructions will be kept here. */ - -static struct sstep_breaks { - int address; - int data; -} stepBreaks[2]; - - -/* - * Calculate the destination of a branch/jump. Return -1 if not a branch. - */ -static int -branch_dest (opcode, instr, pc, safety) - int opcode, instr, pc, safety; -{ - register long offset; - unsigned dest; - int immediate; - int absolute; - int ext_op; - - absolute = (int) ((instr >> 1) & 1); - - switch (opcode) { - case 18 : - immediate = ((instr & ~3) << 6) >> 6; /* br unconditionl */ - - case 16 : - if (opcode != 18) /* br conditional */ - immediate = ((instr & ~3) << 16) >> 16; - if (absolute) - dest = immediate; - else - dest = pc + immediate; - break; - - case 19 : - ext_op = (instr>>1) & 0x3ff; - - if (ext_op == 16) /* br conditional register */ - dest = read_register (LR_REGNUM) & ~3; - - else if (ext_op == 528) /* br cond to count reg */ - dest = read_register (CTR_REGNUM) & ~3; - - else return -1; - break; - - default: return -1; - } - return (dest < 0x10000000) ? safety : dest; -} - - - -/* AIX does not support PT_STEP. Simulate it. */ - -int -single_step (signal) -int signal; -{ -#define INSNLEN(OPCODE) 4 - - static char breakp[] = BREAKPOINT; - int ii, insn, ret, loc; - int breaks[2], opcode; - - if (!one_stepped) { - extern CORE_ADDR text_start; - loc = read_pc (); - - ret = read_memory (loc, &insn, sizeof (int)); - if (ret) - printf ("Error in single_step()!!\n"); - - breaks[0] = loc + INSNLEN(insn); - opcode = insn >> 26; - breaks[1] = branch_dest (opcode, insn, loc, breaks[0]); - - stepBreaks[1].address = -1; - - for (ii=0; ii < 2; ++ii) { - - /* ignore invalid breakpoint. */ - if ( breaks[ii] == -1) - continue; - - read_memory (breaks[ii], &(stepBreaks[ii].data), sizeof(int)); - - ret = write_memory (breaks[ii], breakp, sizeof(int)); - stepBreaks[ii].address = breaks[ii]; - } - - one_stepped = 1; - ptrace (PT_CONTINUE, inferior_pid, 1, signal); - } - else { - - /* remove step breakpoints. */ - for (ii=0; ii < 2; ++ii) - if (stepBreaks[ii].address != -1) - write_memory - (stepBreaks[ii].address, &(stepBreaks[ii].data), sizeof(int)); - - one_stepped = 0; - } - return 1; -} -#endif /* !DAMON's version of single step. */ - - - -/* return pc value after skipping a function prologue. */ - -skip_prologue (pc) -int pc; -{ - unsigned int tmp; - unsigned int op; - - if (target_read_memory (pc, (char *)&op, sizeof (op))) - return pc; /* Can't access it -- assume no prologue. */ - SWAP_TARGET_AND_HOST (&op, sizeof (op)); - - /* Assume that subsequent fetches can fail with low probability. */ - - if (op == 0x7c0802a6) { /* mflr r0 */ - pc += 4; - op = read_memory_integer (pc, 4); - } - else /* else, this is a frameless invocation */ - return pc; - - if ((op & 0xfc00003e) == 0x7c000026) { /* mfcr Rx */ - pc += 4; - op = read_memory_integer (pc, 4); - } - - if ((op & 0xfc000000) == 0x48000000) { /* bl foo, to save fprs??? */ - pc += 4; - op = read_memory_integer (pc, 4); - } - - if ((op & 0xfc1f0000) == 0xd8010000) { /* stfd Rx,NUM(r1) */ - pc += 4; /* store floating register double */ - op = read_memory_integer (pc, 4); - } - - if ((op & 0xfc1f0000) == 0xbc010000) { /* stm Rx, NUM(r1) */ - pc += 4; - op = read_memory_integer (pc, 4); - } - - while (((tmp = op >> 16) == 0x9001) || /* st r0, NUM(r1) */ - (tmp == 0x9421) || /* stu r1, NUM(r1) */ - (op == 0x93e1fffc)) /* st r31,-4(r1) */ - { - pc += 4; - op = read_memory_integer (pc, 4); - } - - while ((tmp = (op >> 22)) == 0x20f) { /* l r31, ... or */ - pc += 4; /* l r30, ... */ - op = read_memory_integer (pc, 4); - } - - while ((op & 0xfc1f0000) == 0x90010000) { /* st r?, NUM(r1) */ - pc += 4; - op = read_memory_integer (pc, 4); - } - - if (op == 0x603f0000) { /* oril r31, r1, 0x0 */ - pc += 4; /* this happens if r31 is used as */ - op = read_memory_integer (pc, 4); /* frame ptr. (gcc does that) */ - - if ((op >> 16) == 0x907f) { /* st r3, NUM(r31) */ - pc += 4; - op = read_memory_integer (pc, 4); - } - } - return pc; -} - -/* text start and end addresses in virtual memory. */ - -CORE_ADDR text_start; -CORE_ADDR text_end; - - -/************************************************************************* - Support for creating pushind a dummy frame into the stack, and popping - frames, etc. -*************************************************************************/ - -#define DUMMY_FRAME_ADDR_SIZE 10 - -/* Make sure you initialize these in somewhere, in case gdb gives up what it - was debugging and starts debugging something else. FIXMEmgo */ - -static int dummy_frame_count = 0; -static int dummy_frame_size = 0; -static CORE_ADDR *dummy_frame_addr = 0; - -extern int stop_stack_dummy; - -/* push a dummy frame into stack, save all register. Currently we are saving - only gpr's and fpr's, which is not good enough! FIXMEmgo */ - -push_dummy_frame () -{ - int sp, pc; /* stack pointer and link register */ - int ii; - - if (dummy_frame_count >= dummy_frame_size) { - dummy_frame_size += DUMMY_FRAME_ADDR_SIZE; - if (dummy_frame_addr) - dummy_frame_addr = (CORE_ADDR*) xrealloc - (dummy_frame_addr, sizeof(CORE_ADDR) * (dummy_frame_size)); - else - dummy_frame_addr = (CORE_ADDR*) - xmalloc (sizeof(CORE_ADDR) * (dummy_frame_size)); - } - - sp = read_register(SP_REGNUM); - pc = read_register(PC_REGNUM); - - dummy_frame_addr [dummy_frame_count++] = sp; - - /* Be careful! If the stack pointer is not decremented first, then kernel - thinks he is free to use the sapce underneath it. And kernel actually - uses that area for IPC purposes when executing ptrace(2) calls. So - before writing register values into the new frame, decrement and update - %sp first in order to secure your frame. */ - - write_register (SP_REGNUM, sp-408); - -#if 1 - /* gdb relies on the state of current_frame. We'd better update it, - otherwise things like do_registers_info() wouldn't work properly! */ - - flush_cached_frames (); - set_current_frame (create_new_frame (sp-408, pc)); -#endif /* 0 */ - - /* save program counter in link register's space. */ - write_memory (sp+8, &pc, 4); - - /* save full floating point registers here. They will be from F14..F31 - for know. I am not sure if we need to save everything here! */ - - /* fpr's, f0..f31 */ - for (ii = 0; ii < 32; ++ii) - write_memory (sp-8-(ii*8), ®isters[REGISTER_BYTE (31-ii+FP0_REGNUM)], 8); - - /* gpr's r0..r31 */ - for (ii=1; ii <=32; ++ii) - write_memory (sp-256-(ii*4), ®isters[REGISTER_BYTE (32-ii)], 4); - - /* so far, 32*2 + 32 words = 384 bytes have been written. We need 6 words - (24 bytes) for the rest of the registers. It brings the total to 408 - bytes. - save sp or so call back chain right here. */ - write_memory (sp-408, &sp, 4); - sp -= 408; - - /* And finally, this is the back chain. */ - write_memory (sp+8, &pc, 4); -} - - -/* Pop a dummy frame. - - In rs6000 when we push a dummy frame, we save all of the registers. This - is usually done before user calls a function explicitly. - - After a dummy frame is pushed, some instructions are copied into stack, and - stack pointer is decremented even more. Since we don't have a frame pointer to - get back to the parent frame of the dummy, we start having trouble poping it. - Therefore, we keep a dummy frame stack, keeping addresses of dummy frames as - such. When poping happens and when we detect that was a dummy frame, we pop - it back to its parent by using dummy frame stack (`dummy_frame_addr' array). - */ - -pop_dummy_frame () -{ - CORE_ADDR sp, pc; - int ii; - sp = dummy_frame_addr [--dummy_frame_count]; - - /* restore all fpr's. */ - for (ii = 1; ii <= 32; ++ii) - read_memory (sp-(ii*8), ®isters[REGISTER_BYTE (32-ii+FP0_REGNUM)], 8); - - /* restore all gpr's */ - for (ii=1; ii <= 32; ++ii) { - read_memory (sp-256-(ii*4), ®isters[REGISTER_BYTE (32-ii)], 4); - } - - read_memory (sp-400, ®isters [REGISTER_BYTE(PC_REGNUM)], 4); - - /* when a dummy frame was being pushed, we had to decrement %sp first, in - order to secure astack space. Thus, saved %sp (or %r1) value, is not the - one we should restore. Change it with the one we need. */ - - *(int*)®isters [REGISTER_BYTE(FP_REGNUM)] = sp; - - /* Now we can restore all registers. */ - - store_inferior_registers (-1); - pc = read_pc (); - flush_cached_frames (); - set_current_frame (create_new_frame (sp, pc)); -} - - -/* pop the innermost frame, go back to the caller. */ - -pop_frame () -{ - int pc, lr, sp, prev_sp; /* %pc, %lr, %sp */ - FRAME fr = get_current_frame (); - int offset = 0; - int frameless = 0; /* TRUE if function is frameless */ - int addr, ii; - int saved_gpr, saved_fpr; /* # of saved gpr's and fpr's */ - - pc = read_pc (); - sp = FRAME_FP (fr); - - if (stop_stack_dummy && dummy_frame_count) { - pop_dummy_frame (); - return; - } - - /* figure out previous %pc value. If the function is frameless, it is - still in the link register, otherwise walk the frames and retrieve the - saved %pc value in the previous frame. */ - - addr = get_pc_function_start (fr->pc) + FUNCTION_START_OFFSET; - function_frame_info (addr, &frameless, &offset, &saved_gpr, &saved_fpr); - - read_memory (sp, &prev_sp, 4); - if (frameless) - lr = read_register (LR_REGNUM); - else - read_memory (prev_sp+8, &lr, 4); - - /* reset %pc value. */ - write_register (PC_REGNUM, lr); - - /* reset register values if any was saved earlier. */ - addr = prev_sp - offset; - - if (saved_gpr != -1) - for (ii=saved_gpr; ii <= 31; ++ii) { - read_memory (addr, ®isters [REGISTER_BYTE (ii)], 4); - addr += sizeof (int); - } - - if (saved_fpr != -1) - for (ii=saved_fpr; ii <= 31; ++ii) { - read_memory (addr, ®isters [REGISTER_BYTE (ii+FP0_REGNUM)], 8); - addr += 8; - } - - write_register (SP_REGNUM, prev_sp); - store_inferior_registers (-1); - flush_cached_frames (); - set_current_frame (create_new_frame (prev_sp, lr)); -} - - -/* fixup the call sequence of a dummy function, with the real function address. - its argumets will be passed by gdb. */ - -fix_call_dummy(dummyname, pc, fun, nargs, type) - char *dummyname; - int pc; - int fun; - int nargs; /* not used */ - int type; /* not used */ - -{ -#define TOC_ADDR_OFFSET 20 -#define TARGET_ADDR_OFFSET 28 - - int ii; - unsigned long target_addr; - unsigned long tocvalue; - - target_addr = fun; - tocvalue = find_toc_address (target_addr); - - ii = *(int*)((char*)dummyname + TOC_ADDR_OFFSET); - ii = (ii & 0xffff0000) | (tocvalue >> 16); - *(int*)((char*)dummyname + TOC_ADDR_OFFSET) = ii; - - ii = *(int*)((char*)dummyname + TOC_ADDR_OFFSET+4); - ii = (ii & 0xffff0000) | (tocvalue & 0x0000ffff); - *(int*)((char*)dummyname + TOC_ADDR_OFFSET+4) = ii; - - ii = *(int*)((char*)dummyname + TARGET_ADDR_OFFSET); - ii = (ii & 0xffff0000) | (target_addr >> 16); - *(int*)((char*)dummyname + TARGET_ADDR_OFFSET) = ii; - - ii = *(int*)((char*)dummyname + TARGET_ADDR_OFFSET+4); - ii = (ii & 0xffff0000) | (target_addr & 0x0000ffff); - *(int*)((char*)dummyname + TARGET_ADDR_OFFSET+4) = ii; -} - - - -/* return information about a function frame. - - frameless is TRUE, if function does not save %pc value in its frame. - - offset is the number of bytes used in the frame to save registers. - - saved_gpr is the number of the first saved gpr. - - saved_fpr is the number of the first saved fpr. - */ -function_frame_info (pc, frameless, offset, saved_gpr, saved_fpr) - int pc; - int *frameless, *offset, *saved_gpr, *saved_fpr; -{ - unsigned int tmp; - register unsigned int op; - - *offset = 0; - *saved_gpr = *saved_fpr = -1; - - if (!inferior_pid) - return; - - op = read_memory_integer (pc, 4); - if (op == 0x7c0802a6) { /* mflr r0 */ - pc += 4; - op = read_memory_integer (pc, 4); - *frameless = 0; - } - else /* else, this is a frameless invocation */ - *frameless = 1; - - - if ((op & 0xfc00003e) == 0x7c000026) { /* mfcr Rx */ - pc += 4; - op = read_memory_integer (pc, 4); - } - - if ((op & 0xfc000000) == 0x48000000) { /* bl foo, to save fprs??? */ - pc += 4; - op = read_memory_integer (pc, 4); - } - - if ((op & 0xfc1f0000) == 0xd8010000) { /* stfd Rx,NUM(r1) */ - pc += 4; /* store floating register double */ - op = read_memory_integer (pc, 4); - } - - if ((op & 0xfc1f0000) == 0xbc010000) { /* stm Rx, NUM(r1) */ - int tmp2; - *saved_gpr = (op >> 21) & 0x1f; - tmp2 = op & 0xffff; - if (tmp2 > 0x7fff) - tmp2 = 0xffff0000 | tmp2; - - if (tmp2 < 0) { - tmp2 = tmp2 * -1; - *saved_fpr = (tmp2 - ((32 - *saved_gpr) * 4)) / 8; - if ( *saved_fpr > 0) - *saved_fpr = 32 - *saved_fpr; - else - *saved_fpr = -1; - } - *offset = tmp2; - } -} - - -/* Pass the arguments in either registers, or in the stack. In RS6000, the first - eight words of the argument list (that might be less than eight parameters if - some parameters occupy more than one word) are passed in r3..r11 registers. - float and double parameters are passed in fpr's, in addition to that. Rest of - the parameters if any are passed in user stack. There might be cases in which - half of the parameter is copied into registers, the other half is pushed into - stack. - - If the function is returning a structure, then the return address is passed - in r3, then the first 7 words of the parametes can be passed in registers, - starting from r4. */ - -CORE_ADDR -push_arguments (nargs, args, sp, struct_return, struct_addr) - int nargs; - value *args; - CORE_ADDR sp; - int struct_return; - CORE_ADDR struct_addr; -{ - int ii, len; - int argno; /* current argument number */ - int argbytes; /* current argument byte */ - char tmp_buffer [50]; - value arg; - int f_argno = 0; /* current floating point argno */ - - CORE_ADDR saved_sp, pc; - - if ( dummy_frame_count <= 0) - printf ("FATAL ERROR -push_arguments()! frame not found!!\n"); - - /* The first eight words of ther arguments are passed in registers. Copy - them appropriately. - - If the function is returning a `struct', then the first word (which - will be passed in r3) is used for struct return address. In that - case we should advance one word and start from r4 register to copy - parameters. */ - - ii = struct_return ? 1 : 0; - - for (argno=0, argbytes=0; argno < nargs && ii<8; ++ii) { - - arg = value_arg_coerce (args[argno]); - len = TYPE_LENGTH (VALUE_TYPE (arg)); - - if (TYPE_CODE (VALUE_TYPE (arg)) == TYPE_CODE_FLT) { - - /* floating point arguments are passed in fpr's, as well as gpr's. - There are 13 fpr's reserved for passing parameters. At this point - there is no way we would run out of them. */ - - if (len > 8) - printf ( -"Fatal Error: a floating point parameter #%d with a size > 8 is found!\n", argno); - - bcopy (VALUE_CONTENTS (arg), - ®isters[REGISTER_BYTE(FP0_REGNUM + 1 + f_argno)], len); - ++f_argno; - } - - if (len > 4) { - - /* Argument takes more than one register. */ - while (argbytes < len) { - - *(int*)®isters[REGISTER_BYTE(ii+3)] = 0; - bcopy ( ((char*)VALUE_CONTENTS (arg))+argbytes, - ®isters[REGISTER_BYTE(ii+3)], - (len - argbytes) > 4 ? 4 : len - argbytes); - ++ii, argbytes += 4; - - if (ii >= 8) - goto ran_out_of_registers_for_arguments; - } - argbytes = 0; - --ii; - } - else { /* Argument can fit in one register. No problem. */ - *(int*)®isters[REGISTER_BYTE(ii+3)] = 0; - bcopy (VALUE_CONTENTS (arg), ®isters[REGISTER_BYTE(ii+3)], len); - } - ++argno; - } - -ran_out_of_registers_for_arguments: - - /* location for 8 parameters are always reserved. */ - sp -= 4 * 8; - - /* another six words for back chain, TOC register, link register, etc. */ - sp -= 24; - - /* if there are more arguments, allocate space for them in - the stack, then push them starting from the ninth one. */ - - if ((argno < nargs) || argbytes) { - int space = 0, jj; - value val; - - if (argbytes) { - space += ((len - argbytes + 3) & -4); - jj = argno + 1; - } - else - jj = argno; - - for (; jj < nargs; ++jj) { - val = value_arg_coerce (args[jj]); - space += ((TYPE_LENGTH (VALUE_TYPE (val))) + 3) & -4; - } - - /* add location required for the rest of the parameters */ - space = (space + 7) & -8; - sp -= space; - - /* This is another instance we need to be concerned about securing our - stack space. If we write anything underneath %sp (r1), we might conflict - with the kernel who thinks he is free to use this area. So, update %sp - first before doing anything else. */ - - write_register (SP_REGNUM, sp); - -#if 0 - pc = read_pc (); - flush_cached_frames (); - set_current_frame (create_new_frame (sp, pc)); -#endif - - /* if the last argument copied into the registers didn't fit there - completely, push the rest of it into stack. */ - - if (argbytes) { - write_memory ( - sp+24+(ii*4), ((char*)VALUE_CONTENTS (arg))+argbytes, len - argbytes); - ++argno; - ii += ((len - argbytes + 3) & -4) / 4; - } - - /* push the rest of the arguments into stack. */ - for (; argno < nargs; ++argno) { - - arg = value_arg_coerce (args[argno]); - len = TYPE_LENGTH (VALUE_TYPE (arg)); - - - /* float types should be passed in fpr's, as well as in the stack. */ - if (TYPE_CODE (VALUE_TYPE (arg)) == TYPE_CODE_FLT && f_argno < 13) { - - if (len > 8) - printf ( -"Fatal Error: a floating point parameter #%d with a size > 8 is found!\n", argno); - - bcopy (VALUE_CONTENTS (arg), - ®isters[REGISTER_BYTE(FP0_REGNUM + 1 + f_argno)], len); - ++f_argno; - } - - write_memory (sp+24+(ii*4), VALUE_CONTENTS (arg), len); - ii += ((len + 3) & -4) / 4; - } - } - else { - - /* Secure stack areas first, before doing anything else. */ - write_register (SP_REGNUM, sp); - -#if 0 - pc = read_pc (); - flush_cached_frames (); - set_current_frame (create_new_frame (sp, pc)); -#endif - } - - saved_sp = dummy_frame_addr [dummy_frame_count - 1]; - read_memory (saved_sp, tmp_buffer, 24); - write_memory (sp, tmp_buffer, 24); - - write_memory (sp, &saved_sp, 4); /* set back chain properly */ - - store_inferior_registers (-1); - return sp; -} - -/* a given return value in `regbuf' with a type `valtype', extract and copy its - value into `valbuf' */ - -extract_return_value (valtype, regbuf, valbuf) - struct type *valtype; - char regbuf[REGISTER_BYTES]; - char *valbuf; -{ - - if (TYPE_CODE (valtype) == TYPE_CODE_FLT) { - - double dd; float ff; - /* floats and doubles are returned in fpr1. fpr's have a size of 8 bytes. - We need to truncate the return value into float size (4 byte) if - necessary. */ - - if (TYPE_LENGTH (valtype) > 4) /* this is a double */ - bcopy (®buf[REGISTER_BYTE (FP0_REGNUM + 1)], valbuf, - TYPE_LENGTH (valtype)); - else { /* float */ - bcopy (®buf[REGISTER_BYTE (FP0_REGNUM + 1)], &dd, 8); - ff = (float)dd; - bcopy (&ff, valbuf, sizeof(float)); - } - } - else - /* return value is copied starting from r3. */ - bcopy (®buf[REGISTER_BYTE (3)], valbuf, TYPE_LENGTH (valtype)); -} - - -/* keep keep structure return address in this variable. */ - -CORE_ADDR rs6000_struct_return_address; - - -/* Throw away this debugging code. FIXMEmgo. */ -print_frame(fram) -int fram; -{ - int ii, val; - for (ii=0; ii<40; ++ii) { - if ((ii % 4) == 0) - printf ("\n"); - val = read_memory_integer (fram + ii * 4, 4); - printf ("0x%08x\t", val); - } - printf ("\n"); -} - - - -/* Indirect function calls use a piece of trampoline code do co context switching, - i.e. to set the new TOC table. Skip such code if exists. */ - -skip_trampoline_code (pc) -int pc; -{ - register unsigned int ii, op; - - static unsigned trampoline_code[] = { - 0x800b0000, /* l r0,0x0(r11) */ - 0x90410014, /* st r2,0x14(r1) */ - 0x7c0903a6, /* mtctr r0 */ - 0x804b0004, /* l r2,0x4(r11) */ - 0x816b0008, /* l r11,0x8(r11) */ - 0x4e800420, /* bctr */ - 0x4e800020, /* br */ - 0 - }; - - for (ii=0; trampoline_code[ii]; ++ii) { - op = read_memory_integer (pc + (ii*4), 4); - if (op != trampoline_code [ii]) - return NULL; - } - ii = read_register (11); /* r11 holds destination addr */ - pc = read_memory_integer (ii, 4); /* (r11) value */ - return pc; -} - diff --git a/gdb/rs6000-xdep.c b/gdb/rs6000-xdep.c deleted file mode 100644 index 7d0917b8d34..00000000000 --- a/gdb/rs6000-xdep.c +++ /dev/null @@ -1,364 +0,0 @@ -/* IBM RS/6000 host-dependent code for GDB, the GNU debugger. - Copyright (C) 1986, 1987, 1989, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "defs.h" -#include "param.h" -#include "frame.h" -#include "inferior.h" -#include "symtab.h" -#include "target.h" - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include - -extern int errno; -extern int attach_flag; - -/* Conversion from gdb-to-system special purpose register numbers.. */ - -static int special_regs[] = { - IAR, /* PC_REGNUM */ - MSR, /* PS_REGNUM */ - CR, /* CR_REGNUM */ - LR, /* LR_REGNUM */ - CTR, /* CTR_REGNUM */ - XER, /* XER_REGNUM */ - MQ /* MQ_REGNUM */ -}; - - -/* Nonzero if we just simulated a single step break. */ -extern int one_stepped; - - -fetch_inferior_registers () -{ - int ii; - extern char registers[]; - - /* read 32 general purpose registers. */ - - for (ii=0; ii < 32; ++ii) - *(int*)®isters[REGISTER_BYTE (ii)] = - ptrace (PT_READ_GPR, inferior_pid, ii, 0, 0); - - /* read general purpose floating point registers. */ - - for (ii=0; ii < 32; ++ii) - ptrace (PT_READ_FPR, inferior_pid, - (int*)®isters [REGISTER_BYTE (FP0_REGNUM+ii)], FPR0+ii, 0); - - /* read special registers. */ - for (ii=0; ii <= LAST_SP_REGNUM-FIRST_SP_REGNUM; ++ii) - *(int*)®isters[REGISTER_BYTE (FIRST_SP_REGNUM+ii)] = - ptrace (PT_READ_GPR, inferior_pid, special_regs[ii], 0, 0); -} - -/* Store our register values back into the inferior. - If REGNO is -1, do this for all registers. - Otherwise, REGNO specifies which register (so we can save time). */ - -store_inferior_registers (regno) - int regno; -{ - extern char registers[]; - - errno = 0; - - if (regno == -1) { /* for all registers.. */ - int ii; - - /* execute one dummy instruction (which is a breakpoint) in inferior - process. So give kernel a chance to do internal house keeping. - Otherwise the following ptrace(2) calls will mess up user stack - since kernel will get confused about the bottom of the stack (%sp) */ - - exec_one_dummy_insn (); - - /* write general purpose registers first! */ - for ( ii=GPR0; ii<=GPR31; ++ii) { - ptrace (PT_WRITE_GPR, inferior_pid, ii, - *(int*)®isters[REGISTER_BYTE (ii)], 0); - if ( errno ) { - perror ("ptrace write_gpr"); errno = 0; - } - } - - /* write floating point registers now. */ - for ( ii=0; ii < 32; ++ii) { - ptrace (PT_WRITE_FPR, inferior_pid, - (int*)®isters[REGISTER_BYTE (FP0_REGNUM+ii)], FPR0+ii, 0); - if ( errno ) { - perror ("ptrace write_fpr"); errno = 0; - } - } - - /* write special registers. */ - for (ii=0; ii <= LAST_SP_REGNUM-FIRST_SP_REGNUM; ++ii) { - ptrace (PT_WRITE_GPR, inferior_pid, special_regs[ii], - *(int*)®isters[REGISTER_BYTE (FIRST_SP_REGNUM+ii)], 0); - if ( errno ) { - perror ("ptrace write_gpr"); errno = 0; - } - } - } - - /* else, a specific register number is given... */ - - else if (regno < FP0_REGNUM) { /* a GPR */ - - ptrace (PT_WRITE_GPR, inferior_pid, regno, - *(int*)®isters[REGISTER_BYTE (regno)], 0); - } - - else if (regno <= FPLAST_REGNUM) { /* a FPR */ - ptrace (PT_WRITE_FPR, inferior_pid, - (int*)®isters[REGISTER_BYTE (regno)], regno-FP0_REGNUM+FPR0, 0); - } - - else if (regno <= LAST_SP_REGNUM) { /* a special register */ - - ptrace (PT_WRITE_GPR, inferior_pid, special_regs [regno-FIRST_SP_REGNUM], - *(int*)®isters[REGISTER_BYTE (regno)], 0); - } - - else - fprintf (stderr, "Gdb error: register no %d not implemented.\n", regno); - - if ( errno ) { - perror ("ptrace write"); errno = 0; - return -1; - } - return 0; -} - -void -fetch_core_registers (core_reg_sect, core_reg_size, which) - char *core_reg_sect; - unsigned core_reg_size; - int which; -{ - /* fetch GPRs and special registers from the first register section - in core bfd. */ - if (which == 0) { - - /* copy GPRs first. */ - bcopy (core_reg_sect, registers, 32 * 4); - - /* gdb's internal register template and bfd's register section layout - should share a common include file. FIXMEmgo */ - /* then comes special registes. They are supposed to be in the same - order in gdb template and bfd `.reg' section. */ - core_reg_sect += (32 * 4); - bcopy (core_reg_sect, ®isters [REGISTER_BYTE (FIRST_SP_REGNUM)], - (LAST_SP_REGNUM - FIRST_SP_REGNUM + 1) * 4); - } - - /* fetch floating point registers from register section 2 in core bfd. */ - else if (which == 2) - bcopy (core_reg_sect, ®isters [REGISTER_BYTE (FP0_REGNUM)], 32 * 8); - - else - fprintf (stderr, "Gdb error: unknown parameter to fetch_core_registers().\n"); -} - - -frameless_function_invocation (fi) -struct frame_info *fi; -{ - int ret; - CORE_ADDR func_start, after_prologue; - -#if 0 - func_start = (LOAD_ADDR (get_pc_function_start (fi->pc)) + - FUNCTION_START_OFFSET); -#else - func_start = get_pc_function_start (fi->pc) + FUNCTION_START_OFFSET; -#endif - if (func_start) - { - after_prologue = func_start; - SKIP_PROLOGUE (after_prologue); - ret = (after_prologue == func_start); - } - else - /* If we can't find the start of the function, we don't really */ - /* know whether the function is frameless, but we should be */ - /* able to get a reasonable (i.e. best we can do under the */ - /* circumstances) backtrace by saying that it isn't. */ - ret = 0; - - return ret; - -} - - -/* aixcoff_relocate_symtab - hook for symbol table relocation. - also reads shared libraries.. */ - -aixcoff_relocate_symtab (pid) -unsigned int pid; -{ -#define MAX_LOAD_SEGS 64 /* maximum number of load segments */ - - extern int compare_misc_functions (); - struct ld_info *ldi; - int temp; - - ldi = (void *) alloca(MAX_LOAD_SEGS * sizeof (*ldi)); - - /* According to my humble theory, aixcoff has some timing problems and - when the user stack grows, kernel doesn't update stack info in time - and ptrace calls step on user stack. That is why we sleep here a little, - and give kernel to update its internals. */ - - usleep (36000); - - errno = 0; - ptrace(PT_LDINFO, pid, ldi, MAX_LOAD_SEGS * sizeof(*ldi), ldi); - if (errno) - perror_with_name ("ptrace ldinfo"); - - vmap_ldinfo(ldi); - - do { - add_text_to_loadinfo (ldi->ldinfo_textorg, ldi->ldinfo_dataorg); - } while (ldi->ldinfo_next - && (ldi = (void *) (ldi->ldinfo_next + (char *) ldi))); - - /* Now that we've jumbled things around, re-sort them. */ - sort_misc_function_vector (); - - /* relocate the exec and core sections as well. */ - vmap_exec (); -} - - -/* Keep an array of load segment information and their TOC table addresses. - This info will be useful when calling a shared library function by hand. */ - -typedef struct { - unsigned long textorg, dataorg, toc_offset; -} LoadInfo; - -#define LOADINFOLEN 10 - -static LoadInfo *loadInfo = NULL; -static int loadInfoLen = 0; -static int loadInfoTocIndex = 0; -static int loadInfoTextIndex = 0; - - -xcoff_init_loadinfo () -{ - loadInfoTocIndex = 0; - loadInfoTextIndex = 0; - - if (loadInfoLen == 0) { - loadInfo = (void*) xmalloc (sizeof (LoadInfo) * LOADINFOLEN); - loadInfoLen = LOADINFOLEN; - } -} - - -free_loadinfo () -{ - if (loadInfo) - free (loadInfo); - loadInfo = NULL; - loadInfoLen = 0; - loadInfoTocIndex = 0; - loadInfoTextIndex = 0; -} - - -xcoff_add_toc_to_loadinfo (unsigned long tocaddr) -{ - while (loadInfoTocIndex >= loadInfoLen) { - loadInfoLen += LOADINFOLEN; - loadInfo = (void*) xrealloc (loadInfo, sizeof(LoadInfo) * loadInfoLen); - } - loadInfo [loadInfoTocIndex++].toc_offset = tocaddr; -} - - -add_text_to_loadinfo (unsigned long textaddr, unsigned long dataaddr) -{ - while (loadInfoTextIndex >= loadInfoLen) { - loadInfoLen += LOADINFOLEN; - loadInfo = (void*) xrealloc (loadInfo, sizeof(LoadInfo) * loadInfoLen); - } - loadInfo [loadInfoTextIndex].textorg = textaddr; - loadInfo [loadInfoTextIndex].dataorg = dataaddr; - ++loadInfoTextIndex; -} - - -unsigned long -find_toc_address (unsigned long pc) -{ - int ii, toc_entry; - - for (ii=0; ii < loadInfoTextIndex; ++ii) - if (pc > loadInfo [ii].textorg) - toc_entry = ii; - - return loadInfo [toc_entry].dataorg + loadInfo [toc_entry].toc_offset; -} - - -/* execute one dummy breakpoint instruction. This way we give kernel - a chance to do some housekeeping and update inferior's internal data, - including u_area. */ - -exec_one_dummy_insn () -{ -#define DUMMY_INSN_ADDR 0x10000200 - - unsigned long shadow; - unsigned int status, pid; - - target_insert_breakpoint (DUMMY_INSN_ADDR, &shadow); - - errno = 0; - ptrace (PT_CONTINUE, inferior_pid, DUMMY_INSN_ADDR, 0, 0); - if (errno) - perror ("pt_continue"); - - do { - pid = wait (&status); - } while (pid != inferior_pid); - - target_remove_breakpoint (DUMMY_INSN_ADDR, &shadow); -} - diff --git a/gdb/rs6k-opcode.def b/gdb/rs6k-opcode.def deleted file mode 100755 index 785fd9df2c0..00000000000 --- a/gdb/rs6k-opcode.def +++ /dev/null @@ -1,224 +0,0 @@ - -/* operand format specifiers. */ - -#define TO 1 -#define RA 2 -#define SI 3 -#define RT 4 -#define UI 5 -#define BF 6 -#define BFA 7 -#define BT 8 -#define BA 9 -#define BB 10 -#define BO 11 -#define BI 12 -#define RB 13 -#define RS 14 -#define SH 15 -#define MB 16 -#define ME 17 -#define SPR 18 -#define DIS 19 -#define FXM 21 -#define FRT 22 -#define NB 23 -#define FRS 24 -#define FRA 25 -#define FRB 26 -#define FRC 27 -#define FLM 28 -#define I 29 -#define LI 30 -#define A2 31 -#define TA14 32 /* 14 bit representation of target address */ -#define TA24 33 /* 24 bit representation of target address */ -#define FL1 34 -#define FL2 35 -#define LEV 36 - -#if 0 - - RS6000 INSTRUCTION SET - (sorted on first primary and second extended opcode) - - oprtr primary ext. -operator ext format opcode opcode operand format -------- ------- ------ ------- ------ --------------- -#endif /* 0 */ - -{"ti", 0, "d", 3, -1, {TO,RA,SI,0} }, -{"muli", 0, "d", 7, -1, {RT,RA,SI,0} }, -{"sfi", 0, "d", 8, -1, {RT,RA,SI,0} }, -{"dozi", 0, "d", 9, -1, {RT,RA,SI,0} }, -{"cmpli", 0, "d", 10, -1, {BF,RA,UI,0} }, -{"cmpi", 0, "d", 11, -1, {BF,RA,SI,0} }, -{"ai", 0, "d", 12, -1, {RT,RA,SI,0} }, -{"ai.", 0, "d", 13, -1, {RT,RA,SI,0} }, -{"lil", 0, "d", 14, -1, {RT,SI,0} }, /* same as `cal' */ -{"cal", 0, "d", 14, -1, {RT,DIS,RA,0} }, -{"liu", 0, "d", 15, -1, {RT, UI,0} }, /* same as `cau' */ -{"cau", 0, "d", 15, -1, {RT,RA,UI,0} }, -{"bb", "1tfl", "b", 16, -1, {LI,A2,0} }, -/* ^^^^^ - exception #1. Either fix this, or document what you are doing here. FIXMEmgo. -*/ -{"bc", "la", "b", 16, -1, {BO,BI,TA14,0} }, -{"svc", "la", "sc", 17, -1, {LEV,FL1,FL2,0} }, -{"b", "la", "i", 18, -1, {TA24,0} }, -{"mcrf", 0, "xl", 19, 0, {BF,BFA,0} }, -{"bcr", "l", "xl", 19, 16, {BO,BI,0} }, -{"cror", 0, "xl", 19, 33, {BT,BA,BB,0} }, -{"crandc", 0, "xl", 19, 129, {BT,BA,BB,0} }, -{"bcc", "l", "xl", 19, 193, {BO,BI,0} }, -{"crnor", 0, "xl", 19, 225, {BT,BA,BB,0} }, -{"crand", 0, "xl", 19, 257, {BT,BA,BB,0} }, -{"creqv", 0, "xl", 19, 289, {BT,BA,BB,0} }, -{"crnand", 0, "xl", 19, 289, {BT,BA,BB,0} }, -{"crxor", 0, "xl", 19, 417, {BT,BA,BB,0} }, -{"crorc", 0, "xl", 19, 449, {BT,BA,BB,0} }, -{"bcr", "l", "xl", 19, 528, {BO,BI,0} }, -{"rlimi", ".", "m", 20, -1, {RA,RS,SH,MB,ME,0} /*??*/}, -{"rlinm", ".", "m", 21, -1, {RA,RS,SH,MB,ME,0} /*??*/}, -{"rlmi", ".", "m", 22, -1, {RA,RS,RB,MB,ME,0} /*??*/}, -{"rlnm", ".", "m", 23, -1, {RA,RS,RB,MB,ME,0} /*??*/}, -{"oril", 0, "d", 24, -1, {RA,RS,UI,0} }, -{"oriu", 0, "d", 25, -1, {RA,RS,UI,0} }, -{"xoril", 0, "d", 26, -1, {RA,RS,UI,0} }, -{"xoriu", 0, "d", 27, -1, {RA,RS,UI,0} }, -{"andil.", 0, "d", 28, -1, {RA,RS,UI,0} }, -{"andiu.", 0, "d", 29, -1, {RA,RS,UI,0} }, -{"cmp", 0, "x", 31, 0, {BF,RA,RB,0} }, -{"t", 0, "x", 31, 4, {TO,RA,RB,0} }, -{"sf", "o.", "xo", 31, 8, {RT,RA,RB,0} }, -{"a", "o.", "xo", 31, 10, {RT,RA,RB,0} }, -{"mfcr", 0, "x", 31, 19, {RT,0} }, -{"lx", 0, "x", 31, 23, {RT,RA,RB,0} }, -{"sl", ".", "x", 31, 24, {RA,RS,RB,0} }, -{"cntlz", ".", "xo", 31, 26, {RA,RS,0} }, -{"and", ".", "x", 31, 28, {RA,RS,RB,0} }, -{"maskg", ".", "x", 31, 29, {RA,RS,RB,0} }, -{"cmpl", 0, "x", 31, 32, {BF,RA,RB,0} }, -{"sfe", "o.", "xo", 31, 36, {RT,RA,RB,0} }, -{"lux", 0, "x", 31, 55, {RT,RA,RB,0} }, -{"andc", ".", "x", 31, 60, {RA,RS,RB,0} }, -{"mfmsr", 0, "x", 31, 83, {RT,0} }, -{"lbzx", 0, "x", 31, 87, {RT,RA,RB,0} }, -{"neg", "o.", "xo", 31, 104, {RT,RA,0} }, -{"mul", "o.", "xo", 31, 107, {RT,RA,RB,0} }, -{"lbzux", 0, "x", 31, 119, {RT,RA,RB,0} }, -{"nor", ".", "x", 31, 124, {RA,RS,RB,0} }, -{"ae", "o.", "xo", 31, 138, {RT,RA,RB,0} }, -{"mtcrf", 0, "xfx", 31, 144, {FXM,RS,0} }, -{"stx", 0, "x", 31, 151, {RS,RA,RB,0} }, -{"slq", ".", "x", 31, 152, {RA,RS,RB,0} }, -{"sle", ".", "x", 31, 153, {RA,RS,RB,0} }, -{"stux", 0, "x", 31, 183, {RS,RA,RB,0} }, -{"sliq", ".", "x", 31, 184, {RA,RS,SH,0} }, -{"sfze", "o.", "xo", 31, 200, {RT,RA,0} }, -{"aze", "o.", "xo", 31, 202, {RT,RA,0} }, -{"stbx", 0, "x", 31, 215, {RS,RA,RB,0} }, -{"sllq", ".", "x", 31, 216, {RA,RS,RB,0} }, -{"sleq", ".", "x", 31, 217, {RA,RS,RB,0} }, -{"sfme", "o.", "xo", 31, 232, {RT,RA,0} }, -{"ame", "o.", "xo", 31, 234, {RT,RA,0} }, -{"muls", "o.", "xo", 31, 235, {RT,RA,RB,0} }, -{"stbux", 0, "x", 31, 247, {RS,RA,RB,0} }, -{"slliq", ".", "x", 31, 248, {RA,RS,SH,0} }, -{"doz", "o.", "x", 31, 264, {RT,RA,RB,0} }, -{"cax", "o.", "xo", 31, 266, {RT,RA,RB,0} }, -{"lscbx", ".", "x", 31, 277, {RT,RA,RB,0} }, -{"lhzx", 0, "x", 31, 279, {RT,RA,RB,0} }, -{"eqv", ".", "x", 31, 284, {RA,RS,RB,0} }, -{"lhzux", 0, "x", 31, 311, {RT,RA,RB,0} }, -{"xor", ".", "x", 31, 316, {RA,RS,RB,0} }, -{"div", "o.", "xo", 31, 331, {RT,RA,RB,0} }, -{"mfspr", 0, "x", 31, 339, {RT,SPR,0} }, -{"lhax", 0, "x", 31, 343, {RT,RA,RB,0} }, -{"abs", "o.", "xo", 31, 360, {RT,RA,0} }, -{"divs", "o.", "xo", 31, 363, {RT,RA,RB,0} }, -{"lhaux", 0, "x", 31, 375, {RT,RA,RB,0} }, -{"sthx", 0, "x", 31, 407, {RS,RA,RB,0} }, -{"orc", ".", "x", 31, 412, {RA,RS,RB,0} }, -{"sthux", 0, "x", 31, 439, {RS,RA,RB,0} }, -{"or", ".", "x", 31, 444, {RA,RS,RB,0} }, -{"mtspr", 0, "x", 31, 467, {SPR,RS,0} }, -{"nand", ".", "x", 31, 476, {RA,RS,RB,0} }, -{"nabs", "o.", "xo", 31, 488, {RT,RA,0} }, -{"mcrxr", 0, "x", 31, 512, {BF,0} }, -{"lsx", 0, "x", 31, 533, {RT,RA,RB,0} }, -{"lbrx", 0, "x", 31, 534, {RT,RA,RB,0} }, -{"lfsx", 0, "x", 31, 535, {FRT,RA,RB,0} }, -{"sr", ".", "x", 31, 536, {RA,RS,RB,0} }, -{"rrib", ".", "x", 31, 537, {RA,RS,RB,0} }, -{"maskir", ".", "x", 31, 541, {RA,RS,RB,0} }, -{"lfsux", 0, "x", 31, 567, {FRT,RA,RB,0} }, -{"lsi", 0, "x", 31, 597, {RT,RA,NB,0} }, -{"lfdx", 0, "x", 31, 599, {FRT,RA,RB,0} }, -{"lfdux", 0, "x", 31, 631, {FRT,RA,RB,0} }, -{"stsx", 0, "x", 31, 661, {RS,RA,RB,0} }, -{"stbrx", 0, "x", 31, 662, {RA,RA,RB,0} }, -{"stfsx", 0, "x", 31, 663, {FRS,RA,RB,0} }, -{"srq", ".", "x", 31, 664, {RA,RS,RB,0} }, -{"sre", ".", "x", 31, 665, {RA,RS,RB,0} }, -{"stfsux", 0, "x", 31, 695, {FRS,RA,RB,0} }, -{"sriq", ".", "x", 31, 696, {RA,RS,SH,0} }, -{"stsi", 0, "x", 31, 725, {RS,RA,NB,0} }, -{"stfdx", 0, "x", 31, 727, {FRS,RA,RB,0} }, -{"srlq", ".", "x", 31, 728, {RA,RS,RB,0} }, -{"sreq", ".", "x", 31, 729, {RA,RS,RB,0} }, -{"stfdux", 0, "x", 31, 759, {FRS,RA,RB,0} }, -{"srliq", ".", "x", 31, 760, {RA,RS,SH,0} }, -{"lhbrx", 0, "x", 31, 790, {RT,RA,RB,0} }, -{"sra", ".", "x", 31, 792, {RA,RS,RB,0} }, -{"srai", ".", "x", 31, 824, {RA,RS,SH,0} }, -{"sthbrx", 0, "x", 31, 918, {RS,RA,RB,0} }, -{"sraq", ".", "x", 31, 920, {RA,RS,RB,0} }, -{"srea", ".", "x", 31, 921, {RA,RS,RB,0} }, -{"exts", ".", "x", 31, 922, {RA,RS,0} }, -{"sraiq", ".", "x", 31, 952, {RA,RS,SH,0} }, -{"l", 0, "d", 32, -1, {RT,DIS,RA,0} }, -{"lu", 0, "d", 33, -1, {RT,DIS,RA,0} }, -{"lbz", 0, "d", 34, -1, {RT,DIS,RA,0} }, -{"lbzu", 0, "d", 35, -1, {RT,DIS,RA,0} }, -{"st", 0, "d", 36, -1, {RS,DIS,RA,0} }, -{"stu", 0, "d", 37, -1, {RS,DIS,RA,0} }, -{"stb", 0, "d", 38, -1, {RS,DIS,RA,0} }, -{"stbu", 0, "d", 39, -1, {RS,DIS,RA,0} }, -{"lhz", 0, "d", 40, -1, {RT,DIS,RA,0} }, -{"lhzu", 0, "d", 41, -1, {RT,DIS,RA,0} }, -{"lha", 0, "d", 42, -1, {RT,DIS,RA,0} }, -{"lhau", 0, "d", 43, -1, {RT,DIS,RA,0} }, -{"sth", 0, "d", 44, -1, {RS,DIS,RA,0} }, -{"sthu", 0, "d", 45, -1, {RS,DIS,RA,0} }, -{"lm", 0, "d", 46, -1, {RT,DIS,RA,0} }, -{"stm", 0, "d", 47, -1, {RS,DIS,RA,0} }, -{"lfs", 0, "d", 48, -1, {FRT,DIS,RA,0} }, -{"lfsu", 0, "d", 49, -1, {FRT,DIS,RA,0} }, -{"lfd", 0, "d", 50, -1, {FRT,DIS,RA,0} }, -{"lfdu", 0, "d", 51, -1, {FRT,DIS,RA,0} }, -{"stfs", 0, "d", 52, -1, {FRS,DIS,RA,0} }, -{"stfsu", 0, "d", 53, -1, {FRS,DIS,RA,0} }, -{"stfd", 0, "d", 54, -1, {FRS,DIS,RA,0} }, -{"stfdu", 0, "d", 55, -1, {FRS,DIS,RA,0} }, -{"fcmpu", 0, "x", 63, 0, {BF,FRA,FRB,0} }, -{"fm", ".", "a", 63, 5, {FRT,FRA,FRC,0} }, -{"fd", ".", "a", 63, 8, {FRT,FRA,FRB,0} }, -{"frsp", ".", "x", 63, 12, {FRT,FRB,0} }, -{"fs", ".", "a", 63, 20, {FRT,FRA,FRB,0} }, -{"fa", ".", "a", 63, 21, {FRT,FRA,FRB,0} }, -{"fms", ".", "a", 63, 28, {FRT,FRA,FRC,FRB,0} }, -{"fma", ".", "a", 63, 29, {FRT,FRA,FRC,FRB,0} }, -{"fnms", ".", "a", 63, 30, {FRT,FRA,FRC,FRB,0} }, -{"fnma", ".", "a", 63, 31, {FRT,FRA,FRC,FRB,0} }, -{"fcmpo", 0, "x", 63, 32, {BF,FRA,FRB,0} }, -{"mtfsb1", ".", "x", 63, 38, {BT,0} }, -{"fneg", ".", "x", 63, 40, {FRT,FRB,0} }, -{"mcrfs", 0, "x", 63, 64, {BF,BFA,0} }, -{"mtfsb0", ".", "x", 63, 70, {BT,0} }, -{"fmr", ".", "x", 63, 72, {FRT,FRB,0} }, -{"mtfsfi", ".", "x", 63, 134, {BF,I,0} }, -{"fnabs", ".", "x", 63, 136, {FRT,FRB,0} }, -{"fabs", ".", "x", 63, 264, {FRT,FRB,0} }, -{"mffs", ".", "x", 63, 583, {FRT,0} }, -{"mtfsf", ".", "xfl", 63, 711, {FLM,FRB,0} }, diff --git a/gdb/rs6k-opcode.h b/gdb/rs6k-opcode.h deleted file mode 100755 index db02a9e8ce9..00000000000 --- a/gdb/rs6k-opcode.h +++ /dev/null @@ -1,19 +0,0 @@ - -typedef int (*FUN)(); - -typedef struct { - char *operator; /* opcode name */ - char *opr_ext; /* opcode name ext. */ - char *format; /* opcode format */ - char p_opcode; /* primary opcode */ - int e_opcode; /* extended opcode */ - char oprnd_format [6]; /* operand format */ -} OPCODE; - - -OPCODE rs6k_ops [] = { - -#include "rs6k-opcode.def" -}; - -#define NOPCODES (sizeof (rs6k_ops) / sizeof (OPCODE)) diff --git a/gdb/saber.suppress b/gdb/saber.suppress deleted file mode 100644 index b1e1772a6f4..00000000000 --- a/gdb/saber.suppress +++ /dev/null @@ -1,435 +0,0 @@ - - -/* Options for project */ -unsetopt ansi -setopt auto_compile -unsetopt auto_reload -setopt auto_replace -unsetopt batch_load -unsetopt batch_run -unsetopt cc_prog -setopt ccargs -g -unsetopt create_file -unsetopt debug_child -unsetopt echo -setopt edit_jobs 5 -unsetopt eight_bit -setopt line_edit -setopt line_meta -setopt lint_load 2 -setopt lint_run 2 -setopt list_action -setopt load_flags -I. -g -I.. -I../vx-share -unsetopt long_not_int -unsetopt make_args -setopt make_hfiles -unsetopt make_offset -unsetopt make_prog -setopt make_symbol # -setopt mem_config 16384 -unsetopt mem_trace -setopt num_proc 1 -unsetopt page_cmds -setopt page_list 19 -unsetopt page_load -unsetopt path -setopt proto_path . /s2/saber_dir30/sun4-40/proto /s2/saber_dir30/sun4-40/../common/proto -unsetopt preprocessor -setopt program_name a.out -unsetopt print_custom -setopt print_pointer -setopt print_string 20 -unsetopt save_memory -setopt sbrk_size 1048576 -setopt src_err 3 -setopt src_step 1 -setopt src_stop 3 -setopt sys_load_flags -L/lib -L/usr/lib -L/usr/local/lib -I/usr/include -Dunix -Dsun -Dsparc -unsetopt tab_stop -unsetopt terse_suppress -unsetopt terse_where -setopt unset_value 191 -unsetopt win_fork_nodup -setopt win_no_raise -unsetopt win_message_list -unsetopt win_project_list -/* Suppressions for project */ -suppress 6 in read_huge_number -/* Over/underflow */ -suppress 8 in read_huge_number -/* Over/underflow */ -suppress 22 -/* Pointer subtraction */ -suppress 22 in free_all_psymtabs -/* Pointer subtraction */ -suppress 22 in free_all_symtabs -/* Pointer subtraction */ -suppress 56 in print_string -/* Information lost */ -suppress 65 "../bfd/bfd.c":379 -/* Too many function arguments */ -suppress 65 on printf_filtered -/* Too many function arguments */ -suppress 65 on fprintf_filtered -/* Too many function arguments */ -suppress 65 on vfprintf_filtered -/* Too many function arguments */ -suppress 65 on query -/* Too many function arguments */ -suppress 65 on fatal_dump_core -/* Too many function arguments */ -suppress 65 on fatal -/* Too many function arguments */ -suppress 65 on error -/* Too many function arguments */ -suppress 65 on noprocess -/* Too many function arguments */ -suppress 65 -/* Too many function arguments */ -suppress 66 on say -/* Too few function arguments */ -suppress 66 on printf_filtered -/* Too few function arguments */ -suppress 66 on fprintf_filtered -/* Too few function arguments */ -suppress 66 on vfprintf_filtered -/* Too few function arguments */ -suppress 66 on query -/* Too few function arguments */ -suppress 66 on fatal_dump_core -/* Too few function arguments */ -suppress 66 on fatal -/* Too few function arguments */ -suppress 66 on error -/* Too few function arguments */ -suppress 67 on printf_filtered -/* Signed/unsigned argument mismatch */ -suppress 67 on fprintf_filtered -/* Signed/unsigned argument mismatch */ -suppress 67 on vfprintf_filtered -/* Signed/unsigned argument mismatch */ -suppress 67 on query -/* Signed/unsigned argument mismatch */ -suppress 67 on fatal_dump_core -/* Signed/unsigned argument mismatch */ -suppress 67 on fatal -/* Signed/unsigned argument mismatch */ -suppress 67 on error -/* Signed/unsigned argument mismatch */ -suppress 67 -/* Signed/unsigned argument mismatch */ -suppress 68 on bfd_get_section_contents -/* Benign argument mismatch */ -suppress 68 on _do_getblong -/* Benign argument mismatch */ -suppress 68 on supply_register -/* Benign argument mismatch */ -suppress 68 on target_write_memory -/* Benign argument mismatch */ -suppress 68 on write_register_bytes -/* Benign argument mismatch */ -suppress 68 on read_register_bytes -/* Benign argument mismatch */ -suppress 68 on read_memory -/* Benign argument mismatch */ -suppress 68 on say -/* Benign argument mismatch */ -suppress 68 on printf_filtered -/* Benign argument mismatch */ -suppress 68 on fprintf_filtered -/* Benign argument mismatch */ -suppress 68 on vfprintf_filtered -/* Benign argument mismatch */ -suppress 68 on query -/* Benign argument mismatch */ -suppress 68 on fatal_dump_core -/* Benign argument mismatch */ -suppress 68 on fatal -/* Benign argument mismatch */ -suppress 68 on error -/* Benign argument mismatch */ -suppress 68 in find_solib -/* Benign argument mismatch */ -suppress 68 on child_wait -/* Benign argument mismatch */ -suppress 68 on xrealloc -/* Benign argument mismatch */ -suppress 68 on myread -/* Benign argument mismatch */ -suppress 68 in do_cleanups -/* Benign argument mismatch */ -suppress 68 on make_cleanup -/* Benign argument mismatch */ -suppress 68 on target_read_memory -/* Benign argument mismatch */ -suppress 69 on printf_filtered -/* Serious argument mismatch */ -suppress 69 on fprintf_filtered -/* Serious argument mismatch */ -suppress 69 on vfprintf_filtered -/* Serious argument mismatch */ -suppress 69 on query -/* Serious argument mismatch */ -suppress 69 on fatal_dump_core -/* Serious argument mismatch */ -suppress 69 on fatal -/* Serious argument mismatch */ -suppress 69 on error -/* Serious argument mismatch */ -suppress 70 on printf_filtered -/* Passing illegal enumeration value */ -suppress 70 on fprintf_filtered -/* Passing illegal enumeration value */ -suppress 70 on vfprintf_filtered -/* Passing illegal enumeration value */ -suppress 70 on query -/* Passing illegal enumeration value */ -suppress 70 on fatal_dump_core -/* Passing illegal enumeration value */ -suppress 70 on fatal -/* Passing illegal enumeration value */ -suppress 70 on error -/* Passing illegal enumeration value */ -suppress 110 in printf_filtered -/* Signed/unsigned memory retrieval */ -suppress 110 in fprintf_filtered -/* Signed/unsigned memory retrieval */ -suppress 110 in vfprintf_filtered -/* Signed/unsigned memory retrieval */ -suppress 110 in query -/* Signed/unsigned memory retrieval */ -suppress 110 in fatal_dump_core -/* Signed/unsigned memory retrieval */ -suppress 110 in fatal -/* Signed/unsigned memory retrieval */ -suppress 110 in error -/* Signed/unsigned memory retrieval */ -suppress 112 in printf_filtered -/* Memory retrieval */ -suppress 112 in fprintf_filtered -/* Memory retrieval */ -suppress 112 in vfprintf_filtered -/* Memory retrieval */ -suppress 112 in query -/* Memory retrieval */ -suppress 112 in fatal_dump_core -/* Memory retrieval */ -suppress 112 in fatal -/* Memory retrieval */ -suppress 112 in error -/* Memory retrieval */ -suppress 112 -/* Memory retrieval */ -suppress 112 ../symtab.c -/* Memory retrieval */ -suppress 112 in child_xfer_memory -/* Memory retrieval */ -suppress 165 in frame_saved_pc -/* Dereference */ -suppress 165 in get_prev_frame_info -/* Dereference */ -suppress 167 in get_prev_frame_info -/* Selection */ -suppress 167 in frame_saved_pc -/* Selection */ -suppress 442 in try_baudrate -/* Escape has null value */ -suppress 529 in read_range_type -/* Statement not reached */ -suppress 529 in process_one_symbol -/* Statement not reached */ -suppress 529 in unpack_double -/* Statement not reached */ -suppress 529 in wait_for_inferior -/* Statement not reached */ -suppress 529 in do_registers_info -/* Statement not reached */ -suppress 529 in value_from_register -/* Statement not reached */ -suppress 530 -/* Empty body of statement */ -suppress 546 in net_quit -/* Function exits through bottom */ -suppress 546 in net_wait -/* Function exits through bottom */ -suppress 546 in vx_remove_breakpoint -/* Function exits through bottom */ -suppress 546 in vx_insert_breakpoint -/* Function exits through bottom */ -suppress 546 in value_less -/* Function exits through bottom */ -suppress 546 in value_equal -/* Function exits through bottom */ -suppress 546 in unpack_long -/* Function exits through bottom */ -suppress 558 in read_range_type -/* Constant in conditional */ -suppress 558 in process_one_symbol -/* Constant in conditional */ -suppress 558 in read_dbx_symtab -/* Constant in conditional */ -suppress 558 in vx_write_register -/* Constant in conditional */ -suppress 558 in vx_read_register -/* Constant in conditional */ -suppress 558 in unpack_double -/* Constant in conditional */ -suppress 558 in wait_for_inferior -/* Constant in conditional */ -suppress 558 in do_registers_info -/* Constant in conditional */ -suppress 558 in value_from_register -/* Constant in conditional */ -suppress 560 in solib_address -/* Assignment within conditional */ -suppress 560 in solib_info -/* Assignment within conditional */ -suppress 560 in solib_add -/* Assignment within conditional */ -suppress 560 in read_type -/* Assignment within conditional */ -suppress 560 in type_print_base -/* Assignment within conditional */ -suppress 560 in type_print_derivation_info -/* Assignment within conditional */ -suppress 560 in block_depth -/* Assignment within conditional */ -suppress 560 in select_source_symtab -/* Assignment within conditional */ -suppress 560 in clear_value_history -/* Assignment within conditional */ -suppress 560 in clear_displays -/* Assignment within conditional */ -suppress 560 in initialize_main -/* Assignment within conditional */ -suppress 560 in echo_command -/* Assignment within conditional */ -suppress 560 in unset_in_environ -/* Assignment within conditional */ -suppress 560 in set_in_environ -/* Assignment within conditional */ -suppress 560 in get_in_environ -/* Assignment within conditional */ -suppress 560 in do_setshow_command -/* Assignment within conditional */ -suppress 560 in breakpoint_1 -/* Assignment within conditional */ -suppress 590 on sig -/* Unused formal parameter */ -suppress 590 in nindy_create_inferior -/* Unused formal parameter */ -suppress 590 in add_to_section_table -/* Unused formal parameter */ -suppress 590 in vx_create_inferior -/* Unused formal parameter */ -suppress 590 in host_convert_from_virtual -/* Unused formal parameter */ -suppress 590 in host_convert_to_virtual -/* Unused formal parameter */ -suppress 590 on siggnal -/* Unused formal parameter */ -suppress 590 in init_sig -/* Unused formal parameter */ -suppress 590 in nindy_resume -/* Unused formal parameter */ -suppress 590 in set_history_size_command -/* Unused formal parameter */ -suppress 590 in not_just_help_class_command -/* Unused formal parameter */ -suppress 590 on regno -/* Unused formal parameter */ -suppress 590 on from_tty -/* Unused formal parameter */ -suppress 590 on args -/* Unused formal parameter */ -suppress 590 in process_symbol_pair -/* Unused formal parameter */ -suppress 591 in print_scalar_formatted -/* Unused automatic variable */ -suppress 592 on rcsid -/* Unused static */ -suppress 592 on check_break_insn_size -/* Unused static */ -suppress 594 in call_function_by_hand -/* Set but not used */ -suppress 594 in record_latest_value -/* Set but not used */ -suppress 594 in bpstat_stop_status -/* Set but not used */ -suppress 595 in coffstrip -/* Used before set */ -suppress 652 ../include/bfd.h -/* Declaration has no effect */ -suppress 652 /usr/include/machine/reg.h -/* Declaration has no effect */ -suppress 652 /usr/include/sun4/reg.h -/* Declaration has no effect */ -suppress 68 on complain -/* Benign type mismatch */ -suppress 3 in read_range_type -/* Over/underflow unary minus */ -suppress 442 ../bfd/archive.c -/* \0 in string */ -suppress 558 ../bfd/b.out.c -/* Conditional if always true */ -suppress 558 ../bfd/coffswap.c -/* Conditional if always true -- bfd_h_put_x */ -suppress 529 ../bfd/coffswap.c -/* Stmt unreach -- bfd_h_put_x */ -suppress 590 ../bfd/ecoff.c -/* Formal parameter not used */ -suppress 590 on ignore -/* Formal param not used */ -suppress 590 on ignore_exec_bfd -/* Formal param not used */ -suppress 590 on ignore_core_bfd -/* Formal param not used */ -suppress 590 on ignore_input_section -/* Formal param not used */ -suppress 590 on ignore_newsect -/* Formal param not used */ -suppress 590 on ignore_abfd -/* Formal param not used */ -suppress 590 on ignore_symbol -/* Formal param not used */ -suppress 590 on ignore_symbols -/* Formal param not used */ -suppress 652 in ../bfd/libaout.h -/* The declaration has no effect */ -suppress 442 in ../bfd/archive.c -/* Escape sequence in string literal has null value */ - -/* Signals caught and ignored */ -catch HUP -catch QUIT -catch ILL -catch TRAP -catch IOT -catch EMT -catch FPE -catch KILL -catch BUS -catch SEGV -catch SYS -catch PIPE -catch TERM -catch URG -catch STOP -catch TSTP -catch TTIN -catch TTOU -catch IO -catch XCPU -catch XFSZ -catch VTALRM -catch PROF -catch LOST -catch USR1 -catch USR2 -ignore INT -ignore ALRM -ignore CONT -ignore CHLD -ignore WINCH - -/* Status of project */ diff --git a/gdb/signals.h b/gdb/signals.h deleted file mode 100644 index a89fc0387c7..00000000000 --- a/gdb/signals.h +++ /dev/null @@ -1,34 +0,0 @@ -/* Signal handler definitions for GDB, the GNU Debugger. - Copyright (C) 1986, 1989 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - - -/* This file is almost the same as including except that it - eliminates certain signal names when job control is not supported, - (or, on some systems, when job control is there but doesn't work - the way GDB expects it to work). */ - -#include - -#ifdef NO_JOB_CONTROL -# undef SIGTSTP -# undef SIGSTOP -# undef SIGCONT -# undef SIGTTIN -# undef SIGTTOU -#endif diff --git a/gdb/signame.c b/gdb/signame.c deleted file mode 100755 index 7f07893ccf6..00000000000 --- a/gdb/signame.c +++ /dev/null @@ -1,257 +0,0 @@ -/* Convert between signal names and numbers. - Copyright (C) 1990 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include -#include "signame.h" - -/* GDB-specific, FIXME. (This is for the SYS_SIGLIST_MISSING define). */ -#include "defs.h" -#include "param.h" - -#ifdef __STDC__ -#define CONST const -#else -#define CONST -#endif - -#if SYS_SIGLIST_MISSING -/* There is too much variation in Sys V signal numbers and names, so - we must initialize them at runtime. */ - -static CONST char undoc[] = "unknown signal"; - -/* We'd like to make this const char*[], but whoever's using it might - want to assign from it to a char*. */ -char *sys_siglist[NSIG]; -#endif /* SYS_SIGLIST_MISSING */ - -/* Table of abbreviations for signals. Note: A given number can - appear more than once with different abbreviations. */ -typedef struct - { - int number; - CONST char *abbrev; - } num_abbrev; -static num_abbrev sig_table[NSIG*2]; -/* Number of elements of sig_table used. */ -static int sig_table_nelts = 0; - -/* Enter signal number NUMBER into the tables with ABBREV and NAME. */ -/* ARGSUSED */ -static void -init_sig (number, abbrev, name) - int number; - CONST char *abbrev; - CONST char *name; -{ -#if SYS_SIGLIST_MISSING - sys_siglist[number] = (char *) name; -#endif - sig_table[sig_table_nelts].number = number; - sig_table[sig_table_nelts++].abbrev = abbrev; -} - -static void init_sigs () -{ -#if SYS_SIGLIST_MISSING - int i; - - /* Initialize signal names. */ - for (i = 0; i < NSIG; i++) - sys_siglist[i] = (char *) undoc; -#endif /* SYS_SIGLIST_MISSING */ - - /* Initialize signal names. */ -#if defined (SIGHUP) - init_sig (SIGHUP, "HUP", "Hangup"); -#endif -#if defined (SIGINT) - init_sig (SIGINT, "INT", "Interrupt"); -#endif -#if defined (SIGQUIT) - init_sig (SIGQUIT, "QUIT", "Quit"); -#endif -#if defined (SIGILL) - init_sig (SIGILL, "ILL", "Illegal Instruction"); -#endif -#if defined (SIGTRAP) - init_sig (SIGTRAP, "TRAP", "Trace/breakpoint trap"); -#endif - /* If SIGIOT == SIGABRT, we want to print it as SIGABRT because - SIGABRT is in ANSI and POSIX.1 and SIGIOT isn't. */ -#if defined (SIGABRT) - init_sig (SIGABRT, "ABRT", "Aborted"); -#endif -#if defined (SIGIOT) - init_sig (SIGIOT, "IOT", "IOT trap"); -#endif -#if defined (SIGEMT) - init_sig (SIGEMT, "EMT", "EMT trap"); -#endif -#if defined (SIGFPE) - init_sig (SIGFPE, "FPE", "Floating point exception"); -#endif -#if defined (SIGKILL) - init_sig (SIGKILL, "KILL", "Killed"); -#endif -#if defined (SIGBUS) - init_sig (SIGBUS, "BUS", "Bus error"); -#endif -#if defined (SIGSEGV) - init_sig (SIGSEGV, "SEGV", "Segmentation fault"); -#endif -#if defined (SIGSYS) - init_sig (SIGSYS, "SYS", "Bad system call"); -#endif -#if defined (SIGPIPE) - init_sig (SIGPIPE, "PIPE", "Broken pipe"); -#endif -#if defined (SIGALRM) - init_sig (SIGALRM, "ALRM", "Alarm clock"); -#endif -#if defined (SIGTERM) - init_sig (SIGTERM, "TERM", "Terminated"); -#endif -#if defined (SIGUSR1) - init_sig (SIGUSR1, "USR1", "User defined signal 1"); -#endif -#if defined (SIGUSR2) - init_sig (SIGUSR2, "USR2", "User defined signal 2"); -#endif - /* If SIGCLD == SIGCHLD, we want to print it as SIGCHLD because that - is what is in POSIX.1. */ -#if defined (SIGCHLD) - init_sig (SIGCHLD, "CHLD", "Child exited"); -#endif -#if defined (SIGCLD) - init_sig (SIGCLD, "CLD", "Child exited"); -#endif -#if defined (SIGPWR) - init_sig (SIGPWR, "PWR", "Power failure"); -#endif -#if defined (SIGTSTP) - init_sig (SIGTSTP, "TSTP", "Stopped"); -#endif -#if defined (SIGTTIN) - init_sig (SIGTTIN, "TTIN", "Stopped (tty input)"); -#endif -#if defined (SIGTTOU) - init_sig (SIGTTOU, "TTOU", "Stopped (tty output)"); -#endif -#if defined (SIGSTOP) - init_sig (SIGSTOP, "STOP", "Stopped (signal)"); -#endif -#if defined (SIGXCPU) - init_sig (SIGXCPU, "XCPU", "CPU time limit exceeded"); -#endif -#if defined (SIGXFSZ) - init_sig (SIGXFSZ, "XFSZ", "File size limit exceeded"); -#endif -#if defined (SIGVTALRM) - init_sig (SIGVTALRM, "VTALRM", "Virtual timer expired"); -#endif -#if defined (SIGPROF) - init_sig (SIGPROF, "PROF", "Profiling timer expired"); -#endif -#if defined (SIGWINCH) - /* "Window size changed" might be more accurate, but even if that - is all that it means now, perhaps in the future it will be - extended to cover other kinds of window changes. */ - init_sig (SIGWINCH, "WINCH", "Window changed"); -#endif -#if defined (SIGCONT) - init_sig (SIGCONT, "CONT", "Continued"); -#endif -#if defined (SIGURG) - init_sig (SIGURG, "URG", "Urgent I/O condition"); -#endif -#if defined (SIGIO) - /* "I/O pending" has also been suggested. A disadvantage is - that signal only happens when the process has - asked for it, not everytime I/O is pending. Another disadvantage - is the confusion from giving it a different name than under Unix. */ - init_sig (SIGIO, "IO", "I/O possible"); -#endif -#if defined (SIGWIND) - init_sig (SIGWIND, "WIND", "SIGWIND"); -#endif -#if defined (SIGPHONE) - init_sig (SIGPHONE, "PHONE", "SIGPHONE"); -#endif -#if defined (SIGPOLL) - init_sig (SIGPOLL, "POLL", "I/O possible"); -#endif -#if defined (SIGLOST) - init_sig (SIGLOST, "LOST", "Resource lost"); -#endif -} - -/* Return the abbreviation for signal NUMBER. */ -char * -sig_abbrev (number) - int number; -{ - int i; - - for (i = 0; i < sig_table_nelts; i++) - if (sig_table[i].number == number) - return (char *)sig_table[i].abbrev; - return NULL; -} - -/* Return the signal number for an ABBREV, or -1 if there is no - signal by that name. */ -int -sig_number (abbrev) - CONST char *abbrev; -{ - int i; - - /* Skip over "SIG" if present. */ - if (abbrev[0] == 'S' && abbrev[1] == 'I' && abbrev[2] == 'G') - abbrev += 3; - - for (i = 0; i < sig_table_nelts; i++) - if (abbrev[0] == sig_table[i].abbrev[0] - && strcmp (abbrev, sig_table[i].abbrev) == 0) - return sig_table[i].number; - return -1; -} - -#if SYS_SIGLIST_MISSING -/* Print to standard error the name of SIGNAL, preceded by MESSAGE and - a colon, and followed by a newline. */ -void -psignal (signal, message) - unsigned signal; - CONST char *message; -{ - if (signal <= 0 || signal >= NSIG) - fprintf (stderr, "%s: unknown signal", message); - else - fprintf (stderr, "%s: %s\n", message, sys_siglist[signal]); -} -#endif /* SYS_SIGLIST_MISSING */ - -void -_initialize_signame () -{ - init_sigs (); -} diff --git a/gdb/signame.h b/gdb/signame.h deleted file mode 100755 index 4b9cbf9559e..00000000000 --- a/gdb/signame.h +++ /dev/null @@ -1,41 +0,0 @@ -/* Convert between signal names and numbers. - Copyright (C) 1990 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Names for signals from 0 to NSIG-1. */ -extern char *sys_siglist[]; - -#ifdef __STDC__ -/* Return the abbreviation (e.g. ABRT, FPE, etc.) for signal NUMBER. - Do not return this as a const char *. The caller might want to - assign it to a char *. */ -char *sig_abbrev (int number); - -/* Return the signal number for an ABBREV, or -1 if there is no - signal by that name. */ -int sig_number (const char *abbrev); - -/* Print to standard error the name of SIGNAL, preceded by MESSAGE and - a colon, and followed by a newline. */ -void psignal (unsigned signal, const char *message); - -#else - -char *sig_abbrev (); -int sig_number (); -void psignal (); - -#endif diff --git a/gdb/solib.c b/gdb/solib.c deleted file mode 100644 index 6995e5009e2..00000000000 --- a/gdb/solib.c +++ /dev/null @@ -1,461 +0,0 @@ -/* Copyright (C) 1990 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* -** symbol definitions -*/ -#include -#include -#include -#include -#include -#include -#include "defs.h" -#include "param.h" -#include "symtab.h" -#include "gdbcore.h" -#include "command.h" -#include "target.h" -#include "frame.h" -#include "regex.h" -#include "inferior.h" - -extern char *getenv(); - -/* -** local data declarations -*/ -#define MAX_PATH_SIZE 256 -struct so_list { - struct link_map inferior_lm; /* inferior link map */ - struct link_map *inferior_lm_add; - long ld_text; - char inferior_so_name[MAX_PATH_SIZE]; /* Shared Object Library Name */ - struct so_list *next; /* Next Structure */ - char symbols_loaded; /* Flag: loaded? */ - char from_tty; /* Flag: print msgs? */ - bfd *so_bfd; - struct section_table *sections; - struct section_table *sections_end; -}; - -static struct so_list *so_list_head = 0; - -/* -** Build a section map for a shared library, record its text size in -** the so_list structure and set up the text section of the shared lib. -*/ -static void -solib_map_sections(so) -struct so_list *so; -{ - char *filename; - char *scratch_pathname; - int scratch_chan; - struct section_table *p; - - filename = tilde_expand (so->inferior_so_name); - make_cleanup (free, filename); - - scratch_chan = openp (getenv ("PATH"), 1, filename, O_RDONLY, 0, - &scratch_pathname); - if (scratch_chan < 0) - scratch_chan = openp (getenv ("LD_LIBRARY_PATH"), 1, filename, O_RDONLY, 0, - &scratch_pathname); - if (scratch_chan < 0) - perror_with_name (filename); - - so->so_bfd = bfd_fdopenr (scratch_pathname, NULL, scratch_chan); - if (!so->so_bfd) - error ("Could not open `%s' as an executable file: %s", - scratch_pathname, bfd_errmsg (bfd_error)); - if (!bfd_check_format (so->so_bfd, bfd_object)) - error ("\"%s\": not in executable format: %s.", - scratch_pathname, bfd_errmsg (bfd_error)); - if (build_section_table (so->so_bfd, &so->sections, &so->sections_end)) - error ("Can't find the file sections in `%s': %s", - exec_bfd->filename, bfd_errmsg (bfd_error)); - - for (p = so->sections; p < so->sections_end; p++) - { - if (strcmp (bfd_section_name (so->so_bfd, p->sec_ptr), ".text") == 0) - { - /* Determine length of text section and relocate it. */ - so->ld_text = p->endaddr - p->addr; - p->addr += (CORE_ADDR)so->inferior_lm.lm_addr; - p->endaddr += (CORE_ADDR)so->inferior_lm.lm_addr; - } - else - /* All other sections are ignored for now. */ - p->addr = p->endaddr = 0; - } -} - -/*=======================================================================*/ - -/* find_solib -** -**Description: -** -** This module contains the routine which finds the names of any loaded -** "images" in the current process. The argument in must be NULL on the -** first call, and then the returned value must be passed in on -** subsequent calls. This provides the capability to "step" down the -** list of loaded objects. On the last object, a NULL value is returned. -** The arg and return value are "struct link_map" pointers, as defined -** in . -** -** NOTE: This only works under SunOS4.0. -*/ - -struct so_list *find_solib(so_list_ptr) -struct so_list *so_list_ptr; /* so_list_head position ptr */ -{ -struct so_list *so_list_next = 0; -struct link_map *inferior_lm = 0; -struct link_dynamic inferior_dynamic_cpy; -struct link_dynamic_2 inferior_ld_2_cpy; -struct so_list *new; -int i; - - if (!so_list_ptr) { - if (!(so_list_next = so_list_head)) { - i = lookup_misc_func ("_DYNAMIC"); - if (i >= 0) { - read_memory(misc_function_vector[i].address, - &inferior_dynamic_cpy, - sizeof(struct link_dynamic)); - if (inferior_dynamic_cpy.ld_version == 3) { - read_memory((CORE_ADDR)inferior_dynamic_cpy.ld_un.ld_2, - &inferior_ld_2_cpy, - sizeof(struct link_dynamic_2)); - inferior_lm = inferior_ld_2_cpy.ld_loaded; - } - } - } - } else { - /* - ** Advance to next local abbreviated load_map structure - */ - if (!(inferior_lm = so_list_ptr->inferior_lm.lm_next)) { - /* See if any were added, but be quiet if we can't read - from the target any more. */ - int status; - - status = target_read_memory ( - (CORE_ADDR)so_list_ptr->inferior_lm_add, - (char *)&so_list_ptr->inferior_lm, - sizeof(struct link_map)); - if (status == 0) - inferior_lm = so_list_ptr->inferior_lm.lm_next; - else - inferior_lm = 0; - } - so_list_next = so_list_ptr->next; - } - if ((!so_list_next) && inferior_lm) { - /* - ** Get Next LM Structure from inferior image and build - ** an local abbreviated load_map structure - */ - new = (struct so_list *) xmalloc(sizeof(struct so_list)); - new->inferior_lm_add = inferior_lm; - read_memory((CORE_ADDR)inferior_lm, - &new->inferior_lm, - sizeof(struct link_map)); - - read_memory((CORE_ADDR)new->inferior_lm.lm_name, - new->inferior_so_name, - MAX_PATH_SIZE - 1); - new->inferior_so_name[MAX_PATH_SIZE - 1] = 0; - /* Zero everything after the first terminating null */ - strncpy(new->inferior_so_name, new->inferior_so_name, MAX_PATH_SIZE); - -#if 0 - /* This doesn't work for core files, so instead get ld_text - using solib_map_sections (below). */ - read_memory((CORE_ADDR)new->inferior_lm.lm_ld, - &inferior_dynamic_cpy, - sizeof(struct link_dynamic)); - read_memory((CORE_ADDR)inferior_dynamic_cpy.ld_un.ld_2, - &inferior_ld_2_cpy, - sizeof(struct link_dynamic_2)); - new->ld_text = inferior_ld_2_cpy.ld_text; -#endif - - new->next = 0; - new->symbols_loaded = 0; - new->so_bfd = NULL; - new->sections = NULL; - if (so_list_ptr) - so_list_ptr->next = new; - else - so_list_head = new; - - solib_map_sections (new); - - so_list_next = new; - } - return(so_list_next); -} - -/* A small stub to get us past the arg-passing pinhole of catch_errors. */ - -static int -symbol_add_stub (arg) - char *arg; -{ - register struct so_list *so = (struct so_list *)arg; /* catch_errs bogon */ - - symbol_file_add (so->inferior_so_name, so->from_tty, - (unsigned int)so->inferior_lm.lm_addr, 0); - return 1; -} - -/* The real work of adding a shared library file to the symtab and - the section list. */ - -void -solib_add (arg_string, from_tty, target) - char *arg_string; - int from_tty; - struct target_ops *target; -{ - register struct so_list *so = 0; /* link map state variable */ - char *val; - int count, old; - struct section_table *sec; - - if (arg_string == 0) - re_comp ("."); - else if (val = (char *) re_comp (arg_string)) { - error ("Invalid regexp: %s", val); - } - - /* Getting new symbols may change our opinion about what is - frameless. */ - reinit_frame_cache (); - - if (from_tty) { - printf_filtered ("Shared libraries"); - if (arg_string) - printf_filtered (" matching regular expresion \"%s\"", arg_string); - printf_filtered (":\n"); - } - - dont_repeat(); - - while (so = find_solib(so)) { - if (re_exec(so->inferior_so_name)) { - if (so->symbols_loaded) { - if (from_tty) - printf("Symbols already loaded for %s\n", so->inferior_so_name); - } else { - so->symbols_loaded = 1; - so->from_tty = from_tty; - catch_errors (symbol_add_stub, (char *)so, - "Error while reading shared library symbols:\n"); - } - } - } - - /* Now add the shared library sections to the section table of the - specified target, if any. */ - if (target) { - /* Count how many new section_table entries there are. */ - so = 0; - count = 0; - while (0 != (so = find_solib (so))) { - count += so->sections_end - so->sections; - } - - if (count) { - /* Reallocate the target's section table including the new size. */ - if (target->sections) { - old = target->sections_end - target->sections; - target->sections = (struct section_table *) - realloc ((char *)target->sections, - (sizeof (struct section_table)) * (count + old)); - } else { - old = 0; - target->sections = (struct section_table *) - malloc ((sizeof (struct section_table)) * count); - } - target->sections_end = target->sections + (count + old); - - /* Add these section table entries to the target's table. */ - while (0 != (so = find_solib (so))) { - count = so->sections_end - so->sections; - bcopy (so->sections, (char *)(target->sections + old), - (sizeof (struct section_table)) * count); - old += count; - } - } - } -} - -/*=======================================================================*/ - -static void solib_info() -{ -register struct so_list *so = 0; /* link map state variable */ - - while (so = find_solib(so)) { - if (so == so_list_head) { - printf(" Address Range Syms Read Shared Object Library\n"); - } - printf(" 0x%08x - 0x%08x %s %s\n", - so->inferior_lm.lm_addr, - so->inferior_lm.lm_addr + so->ld_text - 1, - (so->symbols_loaded ? "Yes" : "No "), - so->inferior_so_name); - } - if (!so_list_head) { - printf("No shared libraries loaded at this time.\n"); - } -} - -/* -** Called by Insert Breakpoint to see if Address is Shared Library Address -*/ -int -solib_address(address) - CORE_ADDR address; -{ -register struct so_list *so = 0; /* link map state variable */ - - while (so = find_solib(so)) { - if ((address >= (CORE_ADDR) so->inferior_lm.lm_addr) && - (address < (CORE_ADDR) so->inferior_lm.lm_addr + so->ld_text)) - return 1; - } - return 0; -} - -/* -** Called by free_all_symtabs -*/ -void -clear_solib() -{ -struct so_list *next; - - while (so_list_head) { - if (so_list_head->sections) - free (so_list_head->sections); - if (so_list_head->so_bfd) - bfd_close (so_list_head->so_bfd); - next = so_list_head->next; - free(so_list_head); - so_list_head = next; - } -} - -/* Called by child_create_inferior when the inferior is stopped at its - first instruction. */ - -void -solib_create_inferior_hook() -{ - struct link_dynamic inferior_dynamic_cpy; - CORE_ADDR inferior_debug_addr; - struct ld_debug inferior_debug_cpy; - int in_debugger; - CORE_ADDR in_debugger_addr; - CORE_ADDR breakpoint_addr; - int i, j; - - /* FIXME: We should look around in the executable code to find _DYNAMIC, - if it isn't in the symbol table. It's not that hard to find... - Then we can debug stripped executables using shared library symbols. */ - i = lookup_misc_func ("_DYNAMIC"); - if (i < 0) /* Can't find shared lib ptr. */ - return; - if (misc_function_vector[i].address == 0) /* statically linked program */ - return; - - /* Get link_dynamic structure */ - j = target_read_memory(misc_function_vector[i].address, - &inferior_dynamic_cpy, - sizeof(struct link_dynamic)); - if (j) /* unreadable */ - return; - - /* Calc address of debugger interface structure */ - inferior_debug_addr = (CORE_ADDR)inferior_dynamic_cpy.ldd; - /* Calc address of `in_debugger' member of debugger interface structure */ - in_debugger_addr = inferior_debug_addr + (CORE_ADDR)((char *)&inferior_debug_cpy.ldd_in_debugger - (char *)&inferior_debug_cpy); - /* Write a value of 1 to this member. */ - in_debugger = 1; - write_memory(in_debugger_addr, &in_debugger, sizeof(in_debugger)); - - /* Now run the target. Seeing `in_debugger' set, it will set a - breakpoint at some convenient place, remember the original contents - of that place, and eventually take a SIGTRAP when it runs into the - breakpoint. We handle this by restoring the contents of the - breakpointed location (which is only known after it stops), - chasing around to locate the shared libraries that have been - loaded, then resuming. */ - - clear_proceed_status (); - stop_soon_quietly = 1; - target_resume (0, 0); - wait_for_inferior (); - while (stop_signal != SIGTRAP) - { - /* FIXME, what if child has exit()ed? Must exit loop somehow */ - target_resume (0, stop_signal); - wait_for_inferior (); - } - stop_soon_quietly = 0; - - /* Set `in_debugger' to zero now. WHY, is this needed? */ - in_debugger = 0; - write_memory(in_debugger_addr, &in_debugger, sizeof(in_debugger)); - read_memory(inferior_debug_addr, &inferior_debug_cpy, sizeof(inferior_debug_cpy)); - /* FIXME: maybe we should add the common symbols from the ldd_cp chain - * to the misc_function_vector ? - */ - breakpoint_addr = (CORE_ADDR)inferior_debug_cpy.ldd_bp_addr; - if (stop_pc - DECR_PC_AFTER_BREAK == breakpoint_addr) - { - write_memory(breakpoint_addr, &inferior_debug_cpy.ldd_bp_inst, sizeof(inferior_debug_cpy.ldd_bp_inst)); - if (DECR_PC_AFTER_BREAK) - { - stop_pc -= DECR_PC_AFTER_BREAK; - write_register (PC_REGNUM, stop_pc); - } - } - solib_add ((char *)0, 0, (struct target_ops *)0); -} - -void -sharedlibrary_command (args, from_tty) -{ - solib_add (args, from_tty, (struct target_ops *)0); -} - -void -_initialize_solib() -{ - - add_com("sharedlibrary", class_files, sharedlibrary_command, - "Load shared object library symbols for files matching REGEXP."); - add_info("sharedlibrary", solib_info, - "Status of loaded shared object libraries"); -} diff --git a/gdb/source.c b/gdb/source.c deleted file mode 100644 index 369788fbef0..00000000000 --- a/gdb/source.c +++ /dev/null @@ -1,1212 +0,0 @@ -/* List lines of source files for GDB, the GNU debugger. - Copyright (C) 1986, 1987, 1988, 1989, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "defs.h" -#include "symtab.h" -#include "param.h" -#include "language.h" -#include "command.h" -#include "gdbcmd.h" -#include "frame.h" - -#ifdef USG -#include -#endif - -#include -#include -#include -#include -#include "gdbcore.h" -#include "regex.h" - -/* If we use this declaration, it breaks because of fucking ANSI "const" stuff - on some systems. We just have to not declare it at all, have it default - to int, and possibly botch on a few systems. Thanks, ANSIholes... */ -/* extern char *strstr(); */ - -extern void set_next_address (); - -/* Path of directories to search for source files. - Same format as the PATH environment variable's value. */ - -char *source_path; - -/* Symtab of default file for listing lines of. */ - -struct symtab *current_source_symtab; - -/* Default next line to list. */ - -int current_source_line; - -/* Default number of lines to print with commands like "list". - This is based on guessing how many long (i.e. more than chars_per_line - characters) lines there will be. To be completely correct, "list" - and friends should be rewritten to count characters and see where - things are wrapping, but that would be a fair amount of work. */ - -unsigned lines_to_list = 10; - -/* Line number of last line printed. Default for various commands. - current_source_line is usually, but not always, the same as this. */ - -static int last_line_listed; - -/* First line number listed by last listing command. */ - -static int first_line_listed; - - -/* Set the source file default for the "list" command, specifying a - symtab. Sigh. Behavior specification: If it is called with a - non-zero argument, that is the symtab to select. If it is not, - first lookup "main"; if it exists, use the symtab and line it - defines. If not, take the last symtab in the symtab_list (if it - exists) or the last symtab in the psymtab_list (if *it* exists). If - none of this works, report an error. */ - -void -select_source_symtab (s) - register struct symtab *s; -{ - struct symtabs_and_lines sals; - struct symtab_and_line sal; - struct partial_symtab *ps; - struct partial_symtab *cs_pst = 0; - - if (s) - { - current_source_symtab = s; - current_source_line = 1; - return; - } - - /* Make the default place to list be the function `main' - if one exists. */ - if (lookup_symbol ("main", 0, VAR_NAMESPACE, 0, NULL)) - { - sals = decode_line_spec ("main", 1); - sal = sals.sals[0]; - free (sals.sals); - current_source_symtab = sal.symtab; - current_source_line = max (sal.line - (lines_to_list - 1), 1); - if (current_source_symtab) - return; - } - - /* All right; find the last file in the symtab list (ignoring .h's). */ - - current_source_line = 1; - - for (s = symtab_list; s; s = s->next) - { - char *name = s->filename; - int len = strlen (name); - if (! (len > 2 && !strcmp (&name[len - 2], ".h"))) - current_source_symtab = s; - } - if (current_source_symtab) - return; - - /* Howabout the partial symtab list? */ - - if (partial_symtab_list) - { - ps = partial_symtab_list; - while (ps) - { - char *name = ps->filename; - int len = strlen (name); - if (! (len > 2 && !strcmp (&name[len - 2], ".h"))) - cs_pst = ps; - ps = ps->next; - } - if (cs_pst) - if (cs_pst->readin) - fatal ("Internal: select_source_symtab: readin pst found and no symtabs."); - else - current_source_symtab = PSYMTAB_TO_SYMTAB (cs_pst); - } - if (current_source_symtab) - return; - - error ("Can't find a default source file"); -} - -static void -show_directories () -{ - printf ("Source directories searched: %s\n", source_path); -} - -/* Forget what we learned about line positions in source files, - and which directories contain them; - must check again now since files may be found in - a different directory now. */ - -void -forget_cached_source_info () -{ - register struct symtab *s; - - for (s = symtab_list; s; s = s->next) - { - if (s->line_charpos != 0) - { - free (s->line_charpos); - s->line_charpos = 0; - } - if (s->fullname != 0) - { - free (s->fullname); - s->fullname = 0; - } - } -} - -void -init_source_path () -{ - source_path = savestring ("$cdir:$cwd", /* strlen of it */ 10); - forget_cached_source_info (); -} - -/* Add zero or more directories to the front of the source path. */ - -void -directory_command (dirname, from_tty) - char *dirname; - int from_tty; -{ - dont_repeat (); - /* FIXME, this goes to "delete dir"... */ - if (dirname == 0) - { - if (query ("Reinitialize source path to empty? ", "")) - { - free (source_path); - init_source_path (); - } - } - else - mod_path (dirname, &source_path); - if (from_tty) - show_directories (); - forget_cached_source_info (); -} - -/* Add zero or more directories to the front of an arbitrary path. */ - -void -mod_path (dirname, which_path) - char *dirname; - char **which_path; -{ - char *old = *which_path; - int prefix = 0; - - if (dirname == 0) - return; - - dirname = strsave (dirname); - make_cleanup (free, dirname); - - do - { - extern char *index (); - char *name = dirname; - register char *p; - struct stat st; - - { - char *colon = index (name, ':'); - char *space = index (name, ' '); - char *tab = index (name, '\t'); - if (colon == 0 && space == 0 && tab == 0) - p = dirname = name + strlen (name); - else - { - p = 0; - if (colon != 0 && (p == 0 || colon < p)) - p = colon; - if (space != 0 && (p == 0 || space < p)) - p = space; - if (tab != 0 && (p == 0 || tab < p)) - p = tab; - dirname = p + 1; - while (*dirname == ':' || *dirname == ' ' || *dirname == '\t') - ++dirname; - } - } - - if (p[-1] == '/') - /* Sigh. "foo/" => "foo" */ - --p; - *p = '\0'; - - while (p[-1] == '.') - { - if (p - name == 1) - { - /* "." => getwd (). */ - name = current_directory; - goto append; - } - else if (p[-2] == '/') - { - if (p - name == 2) - { - /* "/." => "/". */ - *--p = '\0'; - goto append; - } - else - { - /* "...foo/." => "...foo". */ - p -= 2; - *p = '\0'; - continue; - } - } - else - break; - } - - if (name[0] == '~') - name = tilde_expand (name); - else if (name[0] != '/' && name[0] != '$') - name = concat (current_directory, "/", name); - else - name = savestring (name, p - name); - make_cleanup (free, name); - - /* Unless it's a variable, check existence. */ - if (name[0] != '$') { - if (stat (name, &st) < 0) - perror_with_name (name); - if ((st.st_mode & S_IFMT) != S_IFDIR) - error ("%s is not a directory.", name); - } - - append: - { - register unsigned int len = strlen (name); - - p = *which_path; - while (1) - { - if (!strncmp (p, name, len) - && (p[len] == '\0' || p[len] == ':')) - { - /* Found it in the search path, remove old copy */ - if (p > *which_path) - p--; /* Back over leading colon */ - if (prefix > p - *which_path) - goto skip_dup; /* Same dir twice in one cmd */ - strcpy (p, &p[len+1]); /* Copy from next \0 or : */ - } - p = index (p, ':'); - if (p != 0) - ++p; - else - break; - } - if (p == 0) - { - /* If we have already tacked on a name(s) in this command, be sure they stay on the front as we tack on some more. */ - if (prefix) - { - char *temp, c; - - c = old[prefix]; - old[prefix] = '\0'; - temp = concat (old, ":", name); - old[prefix] = c; - *which_path = concat (temp, "", &old[prefix]); - prefix = strlen (temp); - free (temp); - } - else - { - *which_path = concat (name, (old[0]? ":" : old), old); - prefix = strlen (name); - } - free (old); - old = *which_path; - } - } - skip_dup: ; - } while (*dirname != '\0'); -} - - -static void -source_info () -{ - register struct symtab *s = current_source_symtab; - - if (!s) - { - printf("No current source file.\n"); - return; - } - printf ("Current source file is %s\n", s->filename); - if (s->dirname) - printf ("Compilation directory is %s\n", s->dirname); - if (s->fullname) - printf ("Located in %s\n", s->fullname); - if (s->nlines) - printf ("Contains %d lines\n", s->nlines); - - printf("Source language %s.\n", language_str (s->language)); -} - - - -/* Open a file named STRING, searching path PATH (dir names sep by colons) - using mode MODE and protection bits PROT in the calls to open. - If TRY_CWD_FIRST, try to open ./STRING before searching PATH. - (ie pretend the first element of PATH is ".") - If FILENAMED_OPENED is non-null, set it to a newly allocated string naming - 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!!! - - If a file is found, return the descriptor. - 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 */ -int -openp (path, try_cwd_first, string, mode, prot, filename_opened) - char *path; - int try_cwd_first; - char *string; - int mode; - int prot; - char **filename_opened; -{ - register int fd; - register char *filename; - register char *p, *p1; - register int len; - int alloclen; - - if (!path) - path = "."; - - /* ./foo => foo */ - while (string[0] == '.' && string[1] == '/') - string += 2; - - if (try_cwd_first || string[0] == '/') - { - filename = string; - fd = open (filename, mode, prot); - if (fd >= 0 || string[0] == '/') - goto done; - } - - alloclen = strlen (path) + strlen (string) + 2; - filename = (char *) alloca (alloclen); - fd = -1; - for (p = path; p; p = p1 ? p1 + 1 : 0) - { - p1 = (char *) index (p, ':'); - if (p1) - len = p1 - p; - else - len = strlen (p); - - if (len == 4 && p[0] == '$' && p[1] == 'c' - && p[2] == 'w' && p[3] == 'd') { - /* Name is $cwd -- insert current directory name instead. */ - int newlen; - - /* First, realloc the filename buffer if too short. */ - len = strlen (current_directory); - newlen = len + strlen (string) + 2; - if (newlen > alloclen) { - alloclen = newlen; - filename = (char *) alloca (alloclen); - } - strcpy (filename, current_directory); - } else { - /* Normal file name in path -- just use it. */ - strncpy (filename, p, len); - filename[len] = 0; - } - - /* Beware the // my son, the Emacs barfs, the botch that catch... */ - while (len > 1 && filename[len-1] == '/') - filename[--len] = 0; - strcat (filename+len, "/"); - strcat (filename, string); - - fd = open (filename, mode, prot); - if (fd >= 0) break; - } - - done: - if (filename_opened) - if (fd < 0) - *filename_opened = (char *) 0; - else if (filename[0] == '/') - *filename_opened = savestring (filename, strlen (filename)); - else - { - /* Beware the // my son, the Emacs barfs, the botch that catch... */ - - *filename_opened = concat (current_directory, - '/' == current_directory[strlen(current_directory)-1]? "": "/", - filename); - } - - return fd; -} - -/* Open a source file given a symtab S. Returns a file descriptor - or negative number for error. */ -int -open_source_file (s) - struct symtab *s; -{ - char *path = source_path; - char *p; - int result; - - /* Quick way out if we already know its full name */ - if (s->fullname) - { - result = open (s->fullname, O_RDONLY); - if (result >= 0) - return result; - /* Didn't work -- free old one, try again. */ - free (s->fullname); - s->fullname = NULL; - } - - if (s->dirname != NULL) - { - /* Replace a path entry of $cdir with the compilation directory name */ -#define cdir_len 5 - /* We cast strstr's result in case an ANSIhole has made it const, - which produces a "required warning" when assigned to a nonconst. */ - p = (char *)strstr (source_path, "$cdir"); - if (p && (p == path || p[-1] == ':') - && (p[cdir_len] == ':' || p[cdir_len] == '\0')) { - int len; - - path = (char *) - alloca (strlen (source_path) + 1 + strlen (s->dirname) + 1); - len = p - source_path; - strncpy (path, source_path, len); /* Before $cdir */ - strcpy (path + len, s->dirname); /* new stuff */ - strcat (path + len, source_path + len + cdir_len); /* After $cdir */ - } - } - - return openp (path, 0, s->filename, O_RDONLY, 0, &s->fullname); -} - - -/* Create and initialize the table S->line_charpos that records - the positions of the lines in the source file, which is assumed - to be open on descriptor DESC. - All set S->nlines to the number of such lines. */ - -static void -find_source_lines (s, desc) - struct symtab *s; - int desc; -{ - struct stat st; - register char *data, *p, *end; - int nlines = 0; - int lines_allocated = 1000; - int *line_charpos = (int *) xmalloc (lines_allocated * sizeof (int)); - - if (fstat (desc, &st) < 0) - perror_with_name (s->filename); - if (exec_bfd && bfd_get_mtime(exec_bfd) < st.st_mtime) - printf ("Source file is more recent than executable.\n"); - -#ifdef BROKEN_LARGE_ALLOCA - data = (char *) xmalloc (st.st_size); - make_cleanup (free, data); -#else - data = (char *) alloca (st.st_size); -#endif - if (myread (desc, data, st.st_size) < 0) - perror_with_name (s->filename); - end = data + st.st_size; - p = data; - line_charpos[0] = 0; - nlines = 1; - while (p != end) - { - if (*p++ == '\n' - /* A newline at the end does not start a new line. */ - && p != end) - { - if (nlines == lines_allocated) - { - lines_allocated *= 2; - line_charpos = (int *) xrealloc (line_charpos, - sizeof (int) * lines_allocated); - } - line_charpos[nlines++] = p - data; - } - } - s->nlines = nlines; - s->line_charpos = (int *) xrealloc (line_charpos, nlines * sizeof (int)); -} - -/* Return the character position of a line LINE in symtab S. - Return 0 if anything is invalid. */ - -int -source_line_charpos (s, line) - struct symtab *s; - int line; -{ - if (!s) return 0; - if (!s->line_charpos || line <= 0) return 0; - if (line > s->nlines) - line = s->nlines; - return s->line_charpos[line - 1]; -} - -/* Return the line number of character position POS in symtab S. */ - -int -source_charpos_line (s, chr) - register struct symtab *s; - register int chr; -{ - register int line = 0; - register int *lnp; - - if (s == 0 || s->line_charpos == 0) return 0; - lnp = s->line_charpos; - /* Files are usually short, so sequential search is Ok */ - while (line < s->nlines && *lnp <= chr) - { - line++; - lnp++; - } - if (line >= s->nlines) - line = s->nlines; - return line; -} - -/* Get full pathname and line number positions for a symtab. - Return nonzero if line numbers may have changed. - Set *FULLNAME to actual name of the file as found by `openp', - or to 0 if the file is not found. */ - -int -get_filename_and_charpos (s, fullname) - struct symtab *s; - char **fullname; -{ - register int desc, linenums_changed = 0; - - desc = open_source_file (s); - if (desc < 0) - { - if (fullname) - *fullname = NULL; - return 0; - } - if (fullname) - *fullname = s->fullname; - if (s->line_charpos == 0) linenums_changed = 1; - if (linenums_changed) find_source_lines (s, desc); - close (desc); - return linenums_changed; -} - -/* Print text describing the full name of the source file S - and the line number LINE and its corresponding character position. - The text starts with two Ctrl-z so that the Emacs-GDB interface - can easily find it. - - MID_STATEMENT is nonzero if the PC is not at the beginning of that line. - - Return 1 if successful, 0 if could not find the file. */ - -int -identify_source_line (s, line, mid_statement) - struct symtab *s; - int line; - int mid_statement; -{ - if (s->line_charpos == 0) - get_filename_and_charpos (s, (char **)NULL); - if (s->fullname == 0) - return 0; - printf ("\032\032%s:%d:%d:%s:0x%x\n", s->fullname, - line, s->line_charpos[line - 1], - mid_statement ? "middle" : "beg", - get_frame_pc (get_current_frame())); - current_source_line = line; - first_line_listed = line; - last_line_listed = line; - current_source_symtab = s; - return 1; -} - -/* Print source lines from the file of symtab S, - starting with line number LINE and stopping before line number STOPLINE. */ - -void -print_source_lines (s, line, stopline, noerror) - struct symtab *s; - int line, stopline; - int noerror; -{ - register int c; - register int desc; - register FILE *stream; - int nlines = stopline - line; - - /* Regardless of whether we can open the file, set current_source_symtab. */ - current_source_symtab = s; - current_source_line = line; - first_line_listed = line; - - desc = open_source_file (s); - if (desc < 0) - { - if (! noerror) { - char *name = alloca (strlen (s->filename) + 100); - sprintf (name, "%s:%d", s->filename, line); - print_sys_errmsg (name, errno); - } - return; - } - - if (s->line_charpos == 0) - find_source_lines (s, desc); - - if (line < 1 || line > s->nlines) - { - close (desc); - error ("Line number %d out of range; %s has %d lines.", - line, s->filename, s->nlines); - } - - if (lseek (desc, s->line_charpos[line - 1], 0) < 0) - { - close (desc); - perror_with_name (s->filename); - } - - stream = fdopen (desc, "r"); - clearerr (stream); - - while (nlines-- > 0) - { - c = fgetc (stream); - if (c == EOF) break; - last_line_listed = current_source_line; - printf_filtered ("%d\t", current_source_line++); - do - { - if (c < 040 && c != '\t' && c != '\n') - printf_filtered ("^%c", c + 0100); - else if (c == 0177) - printf_filtered ("^?"); - else - printf_filtered ("%c", c); - } while (c != '\n' && (c = fgetc (stream)) >= 0); - } - - fclose (stream); -} - - - -/* - C++ - Print a list of files and line numbers which a user may choose from - in order to list a function which was specified ambiguously - (as with `list classname::overloadedfuncname', for example). - The vector in SALS provides the filenames and line numbers. - */ -static void -ambiguous_line_spec (sals) - struct symtabs_and_lines *sals; -{ - int i; - - for (i = 0; i < sals->nelts; ++i) - printf("file: \"%s\", line number: %d\n", - sals->sals[i].symtab->filename, sals->sals[i].line); -} - - -static void -list_command (arg, from_tty) - char *arg; - int from_tty; -{ - struct symtabs_and_lines sals, sals_end; - struct symtab_and_line sal, sal_end; - struct symbol *sym; - char *arg1; - int no_end = 1; - int dummy_end = 0; - int dummy_beg = 0; - int linenum_beg = 0; - char *p; - - if (symtab_list == 0 && partial_symtab_list == 0) - error ("No symbol table is loaded. Use the \"file\" command."); - - /* Pull in a current source symtab if necessary */ - if (current_source_symtab == 0 && - (arg == 0 || arg[0] == '+' || arg[0] == '-')) - select_source_symtab (0); - - /* "l" or "l +" lists next ten lines. */ - - if (arg == 0 || !strcmp (arg, "+")) - { - if (current_source_symtab == 0) - error ("No default source file yet. Do \"help list\"."); - print_source_lines (current_source_symtab, current_source_line, - current_source_line + lines_to_list, 0); - return; - } - - /* "l -" lists previous ten lines, the ones before the ten just listed. */ - if (!strcmp (arg, "-")) - { - if (current_source_symtab == 0) - error ("No default source file yet. Do \"help list\"."); - print_source_lines (current_source_symtab, - max (first_line_listed - lines_to_list, 1), - first_line_listed, 0); - return; - } - - /* Now if there is only one argument, decode it in SAL - and set NO_END. - If there are two arguments, decode them in SAL and SAL_END - and clear NO_END; however, if one of the arguments is blank, - set DUMMY_BEG or DUMMY_END to record that fact. */ - - arg1 = arg; - if (*arg1 == ',') - dummy_beg = 1; - else - { - sals = decode_line_1 (&arg1, 0, 0, 0); - - if (! sals.nelts) return; /* C++ */ - if (sals.nelts > 1) - { - ambiguous_line_spec (&sals); - free (sals.sals); - return; - } - - sal = sals.sals[0]; - free (sals.sals); - } - - /* Record whether the BEG arg is all digits. */ - - for (p = arg; p != arg1 && *p >= '0' && *p <= '9'; p++); - linenum_beg = (p == arg1); - - while (*arg1 == ' ' || *arg1 == '\t') - arg1++; - if (*arg1 == ',') - { - no_end = 0; - arg1++; - while (*arg1 == ' ' || *arg1 == '\t') - arg1++; - if (*arg1 == 0) - dummy_end = 1; - else - { - if (dummy_beg) - sals_end = decode_line_1 (&arg1, 0, 0, 0); - else - sals_end = decode_line_1 (&arg1, 0, sal.symtab, sal.line); - if (sals_end.nelts == 0) - return; - if (sals_end.nelts > 1) - { - ambiguous_line_spec (&sals_end); - free (sals_end.sals); - return; - } - sal_end = sals_end.sals[0]; - free (sals_end.sals); - } - } - - if (*arg1) - error ("Junk at end of line specification."); - - if (!no_end && !dummy_beg && !dummy_end - && sal.symtab != sal_end.symtab) - error ("Specified start and end are in different files."); - if (dummy_beg && dummy_end) - error ("Two empty args do not say what lines to list."); - - /* if line was specified by address, - first print exactly which line, and which file. - In this case, sal.symtab == 0 means address is outside - of all known source files, not that user failed to give a filename. */ - if (*arg == '*') - { - if (sal.symtab == 0) - error ("No source file for address %s.", local_hex_string(sal.pc)); - sym = find_pc_function (sal.pc); - if (sym) - printf ("%s is in %s (%s, line %d).\n", - local_hex_string(sal.pc), - SYMBOL_NAME (sym), sal.symtab->filename, sal.line); - else - printf ("%s is in %s, line %d.\n", - local_hex_string(sal.pc), - sal.symtab->filename, sal.line); - } - - /* If line was not specified by just a line number, - and it does not imply a symtab, it must be an undebuggable symbol - which means no source code. */ - - if (! linenum_beg && sal.symtab == 0) - error ("No line number known for %s.", arg); - - /* If this command is repeated with RET, - turn it into the no-arg variant. */ - - if (from_tty) - *arg = 0; - - if (dummy_beg && sal_end.symtab == 0) - error ("No default source file yet. Do \"help list\"."); - if (dummy_beg) - print_source_lines (sal_end.symtab, - max (sal_end.line - (lines_to_list - 1), 1), - sal_end.line + 1, 0); - else if (sal.symtab == 0) - error ("No default source file yet. Do \"help list\"."); - else if (no_end) - print_source_lines (sal.symtab, - max (sal.line - (lines_to_list / 2), 1), - sal.line + (lines_to_list / 2), 0); - else - print_source_lines (sal.symtab, sal.line, - (dummy_end - ? sal.line + lines_to_list - : sal_end.line + 1), - 0); -} - -/* Print info on range of pc's in a specified line. */ - -static void -line_info (arg, from_tty) - char *arg; - int from_tty; -{ - struct symtabs_and_lines sals; - struct symtab_and_line sal; - CORE_ADDR start_pc, end_pc; - int i; - - if (arg == 0) - { - sal.symtab = current_source_symtab; - sal.line = last_line_listed; - sals.nelts = 1; - sals.sals = (struct symtab_and_line *) - xmalloc (sizeof (struct symtab_and_line)); - sals.sals[0] = sal; - } - else - { - sals = decode_line_spec_1 (arg, 0); - - /* If this command is repeated with RET, - turn it into the no-arg variant. */ - if (from_tty) - *arg = 0; - } - - /* C++ More than one line may have been specified, as when the user - specifies an overloaded function name. Print info on them all. */ - for (i = 0; i < sals.nelts; i++) - { - sal = sals.sals[i]; - - if (sal.symtab == 0) - error ("No source file specified."); - - if (sal.line > 0 - && find_line_pc_range (sal.symtab, sal.line, &start_pc, &end_pc)) - { - if (start_pc == end_pc) - printf ("Line %d of \"%s\" is at pc %s but contains no code.\n", - sal.line, sal.symtab->filename, local_hex_string(start_pc)); - else - printf ("Line %d of \"%s\" starts at pc %s", - sal.line, sal.symtab->filename, - local_hex_string(start_pc)); - printf (" and ends at %s.\n", - local_hex_string(end_pc)); - /* x/i should display this line's code. */ - set_next_address (start_pc); - /* Repeating "info line" should do the following line. */ - last_line_listed = sal.line + 1; - } - else - printf ("Line number %d is out of range for \"%s\".\n", - sal.line, sal.symtab->filename); - } -} - -/* Commands to search the source file for a regexp. */ - -/* ARGSUSED */ -static void -forward_search_command (regex, from_tty) - char *regex; - int from_tty; -{ - register int c; - register int desc; - register FILE *stream; - int line = last_line_listed + 1; - char *msg; - - msg = (char *) re_comp (regex); - if (msg) - error (msg); - - if (current_source_symtab == 0) - select_source_symtab (0); - - /* Search from last_line_listed+1 in current_source_symtab */ - - desc = open_source_file (current_source_symtab); - if (desc < 0) - perror_with_name (current_source_symtab->filename); - - if (current_source_symtab->line_charpos == 0) - find_source_lines (current_source_symtab, desc); - - if (line < 1 || line > current_source_symtab->nlines) - { - close (desc); - error ("Expression not found"); - } - - if (lseek (desc, current_source_symtab->line_charpos[line - 1], 0) < 0) - { - close (desc); - perror_with_name (current_source_symtab->filename); - } - - stream = fdopen (desc, "r"); - clearerr (stream); - while (1) { -/* FIXME!!! We walk right off the end of buf if we get a long line!!! */ - char buf[4096]; /* Should be reasonable??? */ - register char *p = buf; - - c = getc (stream); - if (c == EOF) - break; - do { - *p++ = c; - } while (c != '\n' && (c = getc (stream)) >= 0); - - /* we now have a source line in buf, null terminate and match */ - *p = 0; - if (re_exec (buf) > 0) - { - /* Match! */ - fclose (stream); - print_source_lines (current_source_symtab, - line, line+1, 0); - current_source_line = max (line - lines_to_list / 2, 1); - return; - } - line++; - } - - printf ("Expression not found\n"); - fclose (stream); -} - -/* ARGSUSED */ -static void -reverse_search_command (regex, from_tty) - char *regex; - int from_tty; -{ - register int c; - register int desc; - register FILE *stream; - int line = last_line_listed - 1; - char *msg; - - msg = (char *) re_comp (regex); - if (msg) - error (msg); - - if (current_source_symtab == 0) - select_source_symtab (0); - - /* Search from last_line_listed-1 in current_source_symtab */ - - desc = open_source_file (current_source_symtab); - if (desc < 0) - perror_with_name (current_source_symtab->filename); - - if (current_source_symtab->line_charpos == 0) - find_source_lines (current_source_symtab, desc); - - if (line < 1 || line > current_source_symtab->nlines) - { - close (desc); - error ("Expression not found"); - } - - if (lseek (desc, current_source_symtab->line_charpos[line - 1], 0) < 0) - { - close (desc); - perror_with_name (current_source_symtab->filename); - } - - stream = fdopen (desc, "r"); - clearerr (stream); - while (line > 1) - { -/* FIXME!!! We walk right off the end of buf if we get a long line!!! */ - char buf[4096]; /* Should be reasonable??? */ - register char *p = buf; - - c = getc (stream); - if (c == EOF) - break; - do { - *p++ = c; - } while (c != '\n' && (c = getc (stream)) >= 0); - - /* We now have a source line in buf; null terminate and match. */ - *p = 0; - if (re_exec (buf) > 0) - { - /* Match! */ - fclose (stream); - print_source_lines (current_source_symtab, - line, line+1, 0); - current_source_line = max (line - lines_to_list / 2, 1); - return; - } - line--; - if (fseek (stream, current_source_symtab->line_charpos[line - 1], 0) < 0) - { - fclose (stream); - perror_with_name (current_source_symtab->filename); - } - } - - printf ("Expression not found\n"); - fclose (stream); - return; -} - -void -_initialize_source () -{ - current_source_symtab = 0; - init_source_path (); - - add_com ("directory", class_files, directory_command, - "Add directory DIR to beginning of search path for source files.\n\ -Forget cached info on source file locations and line positions.\n\ -DIR can also be $cwd for the current working directory, or $cdir for the\n\ -directory in which the source file was compiled into object code.\n\ -With no argument, reset the search path to $cdir:$cwd, the default."); - - add_cmd ("directories", no_class, show_directories, - "Current search path for finding source files.\n\ -$cwd in the path means the current working directory.\n\ -$cdir in the path means the compilation directory of the source file.", - &showlist); - - add_info ("source", source_info, - "Information about the current source file."); - - add_info ("line", line_info, - "Core addresses of the code for a source line.\n\ -Line can be specified as\n\ - LINENUM, to list around that line in current file,\n\ - FILE:LINENUM, to list around that line in that file,\n\ - FUNCTION, to list around beginning of that function,\n\ - FILE:FUNCTION, to distinguish among like-named static functions.\n\ -Default is to describe the last source line that was listed.\n\n\ -This sets the default address for \"x\" to the line's first instruction\n\ -so that \"x/i\" suffices to start examining the machine code.\n\ -The address is also stored as the value of \"$_\"."); - - add_com ("forward-search", class_files, forward_search_command, - "Search for regular expression (see regex(3)) from last line listed."); - add_com_alias ("search", "forward-search", class_files, 0); - - add_com ("reverse-search", class_files, reverse_search_command, - "Search backward for regular expression (see regex(3)) from last line listed."); - - add_com ("list", class_files, list_command, - "List specified function or line.\n\ -With no argument, lists ten more lines after or around previous listing.\n\ -\"list -\" lists the ten lines before a previous ten-line listing.\n\ -One argument specifies a line, and ten lines are listed around that line.\n\ -Two arguments with comma between specify starting and ending lines to list.\n\ -Lines can be specified in these ways:\n\ - LINENUM, to list around that line in current file,\n\ - FILE:LINENUM, to list around that line in that file,\n\ - FUNCTION, to list around beginning of that function,\n\ - FILE:FUNCTION, to distinguish among like-named static functions.\n\ - *ADDRESS, to list around the line containing that address.\n\ -With two args if one is empty it stands for ten lines away from the other arg."); - add_com_alias ("l", "list", class_files, 0); - - add_show_from_set - (add_set_cmd ("listsize", class_support, var_uinteger, - (char *)&lines_to_list, - "Set number of source lines gdb will list by default.", - &setlist), - &showlist); -} diff --git a/gdb/sparc-opcode.h b/gdb/sparc-opcode.h deleted file mode 100755 index d97c7a32849..00000000000 --- a/gdb/sparc-opcode.h +++ /dev/null @@ -1,643 +0,0 @@ -/* Table of opcodes for the sparc. - Copyright (C) 1989 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler, and GDB, the GNU disassembler. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#if !defined(__STDC__) && !defined(const) -#define const -#endif - -/* - * Structure of an opcode table entry. - */ -struct sparc_opcode -{ - const char *name; - unsigned long int match; /* Bits that must be set. */ - unsigned long int lose; /* Bits that must not be set. */ - const char *args; - char flags; -}; - -#define F_DELAYED 1 /* Delayed branch */ -#define F_ALIAS 2 /* Alias for a "real" instruction */ - -/* - All sparc opcodes are 32 bits, except for the `set' instruction (really - a macro), which is 64 bits. It is handled as a special case. - - The match component is a mask saying which bits must match a - particular opcode in order for an instruction to be an instance - of that opcode. - - The args component is a string containing one character - for each operand of the instruction. - -Kinds of operands: - # Number used by optimizer. It is ignored. - 1 rs1 register. - 2 rs2 register. - d rd register. - e frs1 floating point register. - f frs2 floating point register. - g frsd floating point register. - b crs1 coprocessor register - c crs2 coprocessor register - D crsd coprocessor register - h 22 high bits. - i 13 bit Immediate. - l 22 bit PC relative immediate. - L 30 bit PC relative immediate. - a Annul. The annul bit is set. - A Alternate address space. Stored as 8 bits. - C Coprocessor state register. - F floating point state register. - p Processor state register. - q Floating point queue. - r Single register that is both rs1 and rsd. - Q Coprocessor queue. - S Special case. - t Trap base register. - w Window invalid mask register. - y Y register. - -*/ - -/* The order of the opcodes in this table is significant: - - * The assembler requires that all instances of the same mnemonic must be - consecutive. If they aren't, the assembler will bomb at runtime. - - * The disassembler should not care about the order of the opcodes. */ - -static struct sparc_opcode sparc_opcodes[] = -{ - -{ "ldd", 0xc1980000, 0x0060201f, "[1],D", 0 }, /* ldd [rs1+%g0],d */ -{ "ldd", 0xc1982000, 0x00601fff, "[1],D", 0 }, /* ldd [rs1+0],d */ -{ "ldd", 0xc1982000, 0x00600000, "[1+i],D", 0 }, -{ "ldd", 0xc1982000, 0x00600000, "[i+1],D", 0 }, -{ "ldd", 0xc1980000, 0x00602000, "[1+2],D", 0 }, -{ "ldd", 0xc1180000, 0x00e0201f, "[1],g", 0 }, /* ldd [rs1+%g0],d */ -{ "ldd", 0xc1182000, 0x00e01fff, "[1],g", 0 }, /* ldd [rs1+0],d */ -{ "ldd", 0xc1182000, 0x00e00000, "[1+i],g", 0 }, -{ "ldd", 0xc1182000, 0x00e00000, "[i+1],g", 0 }, -{ "ldd", 0xc1180000, 0x00e02000, "[1+2],g", 0 }, -{ "ldd", 0xc0180000, 0x01e0201f, "[1],d", 0 }, /* ldd [rs1+%g0],d */ -{ "ldd", 0xc0182000, 0x01e01fff, "[1],d", 0 }, /* ldd [rs1+0],d */ -{ "ldd", 0xc0182000, 0x01e00000, "[1+i],d", 0 }, -{ "ldd", 0xc0182000, 0x01e00000, "[i+1],d", 0 }, -{ "ldd", 0xc0180000, 0x01e02000, "[1+2],d", 0 }, -{ "ld", 0xc1880000, 0x0070201f, "[1],C", 0 }, /* ld [rs1+%g0],d */ -{ "ld", 0xc1882000, 0x00701fff, "[1],C", 0 }, /* ld [rs1+0],d */ -{ "ld", 0xc1882000, 0x00700000, "[1+i],C", 0 }, -{ "ld", 0xc1882000, 0x00700000, "[i+1],C", 0 }, -{ "ld", 0xc1880000, 0x00702000, "[1+2],C", 0 }, -{ "ld", 0xc1800000, 0x0078201f, "[1],D", 0 }, /* ld [rs1+%g0],d */ -{ "ld", 0xc1802000, 0x00781fff, "[1],D", 0 }, /* ld [rs1+0],d */ -{ "ld", 0xc1802000, 0x00780000, "[1+i],D", 0 }, -{ "ld", 0xc1802000, 0x00780000, "[i+1],D", 0 }, -{ "ld", 0xc1800000, 0x00782000, "[1+2],D", 0 }, -{ "ld", 0xc1080000, 0x00f0201f, "[1],F", 0 }, /* ld [rs1+%g0],d */ -{ "ld", 0xc1082000, 0x00f01fff, "[1],F", 0 }, /* ld [rs1+0],d */ -{ "ld", 0xc1082000, 0x00f00000, "[1+i],F", 0 }, -{ "ld", 0xc1082000, 0x00f00000, "[i+1],F", 0 }, -{ "ld", 0xc1080000, 0x00f02000, "[1+2],F", 0 }, -{ "ld", 0xc1000000, 0x00f8201f, "[1],g", 0 }, /* ld [rs1+%g0],d */ -{ "ld", 0xc1002000, 0x00f81fff, "[1],g", 0 }, /* ld [rs1+0],d */ -{ "ld", 0xc1002000, 0x00f80000, "[1+i],g", 0 }, -{ "ld", 0xc1002000, 0x00f80000, "[i+1],g", 0 }, -{ "ld", 0xc1000000, 0x00f82000, "[1+2],g", 0 }, -{ "ld", 0xc0000000, 0x01f8201f, "[1],d", 0 }, /* ld [rs1+%g0],d */ -{ "ld", 0xc0002000, 0x01f81fff, "[1],d", 0 }, /* ld [rs1+0],d */ -{ "ld", 0xc0002000, 0x01f80000, "[1+i],d", 0 }, -{ "ld", 0xc0002000, 0x01f80000, "[i+1],d", 0 }, -{ "ld", 0xc0000000, 0x01f82000, "[1+2],d", 0 }, -{ "ldstuba", 0xc0d80000, 0x0100201f, "[1]A,d", 0 }, /* ldstuba [rs1+%g0],d */ -{ "ldstuba", 0xc0d80000, 0x01002000, "[1+2]A,d", 0 }, -{ "ldsha", 0xc0d00000, 0x0128201f, "[1]A,d", 0 }, /* ldsha [rs1+%g0],d */ -{ "ldsha", 0xc0d00000, 0x01282000, "[1+2]A,d", 0 }, -{ "ldsba", 0xc0c80000, 0x0130201f, "[1]A,d", 0 }, /* ldsba [rs1+%g0],d */ -{ "ldsba", 0xc0c80000, 0x01302000, "[1+2]A,d", 0 }, -{ "ldda", 0xc0980000, 0x0160201f, "[1]A,d", 0 }, /* ldda [rs1+%g0],d */ -{ "ldda", 0xc0980000, 0x01602000, "[1+2]A,d", 0 }, -{ "lduha", 0xc0900000, 0x0168201f, "[1]A,d", 0 }, /* lduha [rs1+%g0],d */ -{ "lduha", 0xc0900000, 0x01682000, "[1+2]A,d", 0 }, -{ "ldstub", 0xc0680000, 0x0190201f, "[1],d", 0 }, /* ldstub [rs1+%g0],d */ -{ "ldstub", 0xc0682000, 0x01900000, "[1+i],d", 0 }, -{ "ldstub", 0xc0682000, 0x01900000, "[i+1],d", 0 }, -{ "ldstub", 0xc0680000, 0x01902000, "[1+2],d", 0 }, -{ "lda", 0xc0800000, 0x0178201f, "[1]A,d", 0 }, /* lda [rs1+%g0],d */ -{ "lda", 0xc0800000, 0x01782000, "[1+2]A,d", 0 }, -{ "ldsh", 0xc0500000, 0x0000000d, "[1],d", 0 }, /* ldsh [rs1+%g0],d */ -{ "ldsh", 0xc0502000, 0x01a81fff, "[1],d", 0 }, /* ldsh [rs1+0],d */ -{ "ldsh", 0xc0502000, 0x01a80000, "[1+i],d", 0 }, -{ "ldsh", 0xc0502000, 0x01a80000, "[i+1],d", 0 }, -{ "ldsh", 0xc0500000, 0x01a82000, "[1+2],d", 0 }, -{ "ldsb", 0xc0480000, 0x01b0201f, "[1],d", 0 }, /* ldsb [rs1+%g0],d */ -{ "ldsb", 0xc0482000, 0x01b01fff, "[1],d", 0 }, /* ldsb [rs1+0],d */ -{ "ldsb", 0xc0482000, 0x01b00000, "[1+i],d", 0 }, -{ "ldsb", 0xc0482000, 0x01b00000, "[i+1],d", 0 }, -{ "ldsb", 0xc0480000, 0x01b02000, "[1+2],d", 0 }, -{ "ldub", 0xc0080000, 0x01f0201f, "[1],d", 0 }, /* ldub [rs1+%g0],d */ -{ "ldub", 0xc0082000, 0x01f01fff, "[1],d", 0 }, /* ldub [rs1+0],d */ -{ "ldub", 0xc0082000, 0x01f00000, "[1+i],d", 0 }, -{ "ldub", 0xc0082000, 0x01f00000, "[i+1],d", 0 }, -{ "ldub", 0xc0080000, 0x01f02000, "[1+2],d", 0 }, -{ "lduba", 0xc0880000, 0x0170201f, "[1]A,d", 0 }, /* lduba [rs1+%g0],d */ -{ "lduba", 0xc0880000, 0x01702000, "[1+2]A,d", 0 }, -{ "lduh", 0xc0102000, 0x01e80000, "[1+i],d", 0 }, -{ "lduh", 0xc0102000, 0x01e80000, "[i+1],d", 0 }, -{ "lduh", 0xc0100000, 0x01e8201f, "[1],d", 0 }, /* lduh [rs1+%g0],d */ -{ "lduh", 0xc0102000, 0x01e81fff, "[1],d", 0 }, /* lduh [rs1+0],d */ -{ "lduh", 0xc0100000, 0x01e82000, "[1+2],d", 0 }, - -{ "st", 0xc0200000, 0x01d8201f, "d,[1]", 0 }, /* st d,[rs1+%g0] */ -{ "st", 0xc0202000, 0x01d81fff, "d,[1]", 0 }, /* st d,[rs1+0] */ -{ "st", 0xc0202000, 0x01d80000, "d,[1+i]", 0 }, -{ "st", 0xc0202000, 0x01d80000, "d,[i+1]", 0 }, -{ "st", 0xc0200000, 0x01d82000, "d,[1+2]", 0 }, -{ "st", 0xc1200000, 0x00d8201f, "g,[1]", 0 }, /* st d[rs1+%g0] */ -{ "st", 0xc1202000, 0x00d81fff, "g,[1]", 0 }, /* st d,[rs1+0] */ -{ "st", 0xc1202000, 0x00d80000, "g,[1+i]", 0 }, -{ "st", 0xc1202000, 0x00d80000, "g,[i+1]", 0 }, -{ "st", 0xc1200000, 0x00d82000, "g,[1+2]", 0 }, -{ "st", 0xc1280000, 0x00d0201f, "F,[1]", 0 }, /* st %fsr,[rs1+%g0] */ -{ "st", 0xc1282000, 0x00d01fff, "F,[1]", 0 }, /* st %fsr,[rs1+0] */ -{ "st", 0xc1282000, 0x00d00000, "F,[1+i]", 0 }, -{ "st", 0xc1282000, 0x00d00000, "F,[i+1]", 0 }, -{ "st", 0xc1280000, 0x00d02000, "F,[1+2]", 0 }, -{ "st", 0xc1a00000, 0x0058201f, "D,[1]", 0 }, /* st d,[rs1+%g0] */ -{ "st", 0xc1a02000, 0x00581fff, "D,[1]", 0 }, /* st d,[rs1+0] */ -{ "st", 0xc1a02000, 0x00580000, "D,[1+i]", 0 }, -{ "st", 0xc1a02000, 0x00580000, "D,[i+1]", 0 }, -{ "st", 0xc1a00000, 0x00582000, "D,[1+2]", 0 }, -{ "st", 0xc1a80000, 0x0050201f, "C,[1]", 0 }, /* st d,[rs1+%g0] */ -{ "st", 0xc1a82000, 0x00501fff, "C,[1]", 0 }, /* st d,[rs1+0] */ -{ "st", 0xc1a82000, 0x00500000, "C,[1+i]", 0 }, -{ "st", 0xc1a82000, 0x00500000, "C,[i+1]", 0 }, -{ "st", 0xc1a80000, 0x00502000, "C,[1+2]", 0 }, -{ "sta", 0xc0a00000, 0x0108201f, "d,[1]A", 0 }, /* sta d,[rs1+%g0] */ -{ "sta", 0xc0a00000, 0x01082000, "d,[1+2]A", 0 }, - -{ "stb", 0xc0280000, 0x01d0201f, "d,[1]", 0 }, /* stb d,[rs1+%g0] */ -{ "stb", 0xc0282000, 0x01d01fff, "d,[1]", 0 }, /* stb d,[rs1+0] */ -{ "stb", 0xc0282000, 0x01d00000, "d,[1+i]", 0 }, -{ "stb", 0xc0282000, 0x01d00000, "d,[i+1]", 0 }, -{ "stb", 0xc0280000, 0x01d02000, "d,[1+2]", 0 }, -{ "stba", 0xc0a80000, 0x01002000, "d,[1+2]A", 0 }, -{ "stba", 0xc0a80000, 0x0100201f, "d,[1]A", 0 }, /* stba d,[rs1+%g0] */ - -{ "std", 0xc0380000, 0x01c0201f, "d,[1]", 0 }, /* std d,[rs1+%g0] */ -{ "std", 0xc0382000, 0x01c01fff, "d,[1]", 0 }, /* std d,[rs1+0] */ -{ "std", 0xc0382000, 0x01c00000, "d,[1+i]", 0 }, -{ "std", 0xc0382000, 0x01c00000, "d,[i+1]", 0 }, -{ "std", 0xc0380000, 0x01c02000, "d,[1+2]", 0 }, -{ "std", 0xc1380000, 0x00c0201f, "g,[1]", 0 }, /* std d,[rs1+%g0] */ -{ "std", 0xc1382000, 0x00c01fff, "g,[1]", 0 }, /* std d,[rs1+0] */ -{ "std", 0xc1382000, 0x00c00000, "g,[1+i]", 0 }, -{ "std", 0xc1382000, 0x00c00000, "g,[i+1]", 0 }, -{ "std", 0xc1380000, 0x00c02000, "g,[1+2]", 0 }, -{ "std", 0xc1300000, 0x00c8201f, "q,[1]", 0 }, /* std d,[rs1+%g0] */ -{ "std", 0xc1302000, 0x00c81fff, "q,[1]", 0 }, /* std d,[rs1+0] */ -{ "std", 0xc1302000, 0x00c80000, "q,[1+i]", 0 }, -{ "std", 0xc1302000, 0x00c80000, "q,[i+1]", 0 }, -{ "std", 0xc1300000, 0x00c82000, "q,[1+2]", 0 }, -{ "std", 0xc1b80000, 0x0040201f, "D,[1]", 0 }, /* std d,[rs1+%g0] */ -{ "std", 0xc1b82000, 0x00401fff, "D,[1]", 0 }, /* std d,[rs1+0] */ -{ "std", 0xc1b82000, 0x00400000, "D,[1+i]", 0 }, -{ "std", 0xc1b82000, 0x00400000, "D,[i+1]", 0 }, -{ "std", 0xc1b80000, 0x00402000, "D,[1+2]", 0 }, -{ "std", 0xc1b00000, 0x0048201f, "Q,[1]", 0 }, /* std d,[rs1+%g0] */ -{ "std", 0xc1b02000, 0x00481fff, "Q,[1]", 0 }, /* std d,[rs1+0] */ -{ "std", 0xc1b02000, 0x00480000, "Q,[1+i]", 0 }, -{ "std", 0xc1b02000, 0x00480000, "Q,[i+1]", 0 }, -{ "std", 0xc1b00000, 0x00482000, "Q,[1+2]", 0 }, -{ "stda", 0xc0b80000, 0x01402000, "d,[1+2]A", 0 }, -{ "stda", 0xc0b80000, 0x0140201f, "d,[1]A", 0 }, /* stda d,[rs1+%g0] */ - -{ "sth", 0xc0300000, 0x01c8201f, "d,[1]", 0 }, /* sth d,[rs1+%g0] */ -{ "sth", 0xc0302000, 0x01c81fff, "d,[1]", 0 }, /* sth d,[rs1+0] */ -{ "sth", 0xc0300000, 0x01c82000, "d,[1+2]", 0 }, -{ "sth", 0xc0302000, 0x01c80000, "d,[1+i]", 0 }, -{ "sth", 0xc0302000, 0x01c80000, "d,[i+1]", 0 }, -{ "stha", 0xc0b00000, 0x0148201f, "d,[1]A", 0 }, /* stha d,[rs1+%g0] */ -{ "stha", 0xc0b00000, 0x01482000, "d,[1+2]A", 0 }, - -{ "swap", 0xc0780000, 0x0180201f, "[1],d", 0 }, /* swap [rs1+%g0],d */ -{ "swap", 0xc0782000, 0x01801fff, "[1],d", 0 }, /* swap [rs1+0],d */ -{ "swap", 0xc0782000, 0x01800000, "[1+i],d", 0 }, -{ "swap", 0xc0782000, 0x01800000, "[i+1],d", 0 }, -{ "swap", 0xc0780000, 0x01802000, "[1+2],d", 0 }, -{ "swapa", 0xc0f80000, 0x01002000, "[1+2]A,d", 0 }, -{ "swapa", 0xc0f80000, 0x0100201f, "[1]A,d", 0 }, /* swapa [rs1+%g0],d */ - -{ "restore", 0x81e80000, 0x7e17e01f, "", 0 }, /* restore %g0,%g0,%g0 */ -{ "restore", 0x81e82000, 0x7e14dfff, "", 0 }, /* restore %g0,0,%g0 */ -{ "restore", 0x81e82000, 0x00000000, "1,i,d", 0 }, -{ "restore", 0x81e80000, 0x00000000, "1,2,d", 0 }, -{ "rett", 0x81c82000, 0x40300000, "1+i", F_DELAYED }, -{ "rett", 0x81c82000, 0x40300000, "i+1", F_DELAYED }, -{ "rett", 0x81c80000, 0x40302000, "1+2", F_DELAYED }, -{ "rett", 0x81c82000, 0x40301fff, "1", F_DELAYED}, /* rett X,0 */ -{ "rett", 0x81c80000, 0x4030201f, "1", F_DELAYED}, /* rett X,%g0 */ -{ "save", 0x81e02000, 0x40180000, "1,i,d", 0 }, -{ "save", 0x81e00000, 0x40180000, "1,2,d", 0 }, - -{ "ret", 0x81c7e008, 0x00001ff7, "", F_DELAYED }, /* jmpl %i7+8,%g0 */ -{ "retl", 0x81c3e008, 0x00001ff7, "", F_DELAYED }, /* jmpl %o7+8,%g0 */ - -{ "jmpl", 0x81c00000, 0x4038201f, "1,d", F_DELAYED }, /* jmpl rs1+%g0,d */ -{ "jmpl", 0x81c02000, 0x4037c000, "i,d", F_DELAYED }, /* jmpl %g0+i,d */ -{ "jmpl", 0x81c02000, 0x40380000, "1+i,d", F_DELAYED }, -{ "jmpl", 0x81c02000, 0x40380000, "i+1,d", F_DELAYED }, -{ "jmpl", 0x81c00000, 0x40382000, "1+2,d", F_DELAYED }, -{ "wr", 0x81982000, 0x40600000, "1,i,t", 0 }, -{ "wr", 0x81980000, 0x40600000, "1,2,t", 0 }, -{ "wr", 0x81902000, 0x40680000, "1,i,w", 0 }, -{ "wr", 0x81900000, 0x40680000, "1,2,w", 0 }, -{ "wr", 0x81882000, 0x40700000, "1,i,p", 0 }, -{ "wr", 0x81880000, 0x40700000, "1,2,p", 0 }, -{ "wr", 0x81802000, 0x40780000, "1,i,y", 0 }, -{ "wr", 0x81800000, 0x40780000, "1,2,y", 0 }, - -{ "rd", 0x81580000, 0x40a00000, "t,d", 0 }, -{ "rd", 0x81500000, 0x40a80000, "w,d", 0 }, -{ "rd", 0x81480000, 0x40b00000, "p,d", 0 }, -{ "rd", 0x81400000, 0x40b80000, "y,d", 0 }, - -{ "sra", 0x81382000, 0x00000000, "1,i,d", 0 }, -{ "sra", 0x81380000, 0x00000000, "1,2,d", 0 }, -{ "srl", 0x81302000, 0x40c80000, "1,i,d", 0 }, -{ "srl", 0x81300000, 0x40c80000, "1,2,d", 0 }, -{ "sll", 0x81282000, 0x40d00000, "1,i,d", 0 }, -{ "sll", 0x81280000, 0x40d00000, "1,2,d", 0 }, - -{ "mulscc", 0x81202000, 0x40d80000, "1,i,d", 0 }, -{ "mulscc", 0x81200000, 0x40d80000, "1,2,d", 0 }, - -{ "clr", 0x80100000, 0x4e87e01f, "d", F_ALIAS }, /* or %g0,%g0,d */ -{ "clr", 0x80102000, 0x41efdfff, "d", F_ALIAS }, /* or %g0,0,d */ -{ "clr", 0xc0200000, 0x3fd8001f, "[1]", F_ALIAS }, /* st %g0,[rs1+%g0] */ -{ "clr", 0xc0202000, 0x3fd81fff, "[1]", F_ALIAS }, /* st %g0,[rs1+0] */ -{ "clr", 0xc0202000, 0x3fd80000, "[1+i]", F_ALIAS }, -{ "clr", 0xc0202000, 0x3fd80000, "[i+1]", F_ALIAS }, -{ "clr", 0xc0200000, 0x3fd80000, "[1+2]", F_ALIAS }, - -{ "clrb", 0xc0280000, 0x3fd0001f, "[1]", F_ALIAS },/* stb %g0,[rs1+%g0] */ -{ "clrb", 0xc0282000, 0x3fd00000, "[1+i]", F_ALIAS }, -{ "clrb", 0xc0282000, 0x3fd00000, "[i+1]", F_ALIAS }, -{ "clrb", 0xc0280000, 0x3fd00000, "[1+2]", F_ALIAS }, - -{ "clrh", 0xc0300000, 0x3fc8001f, "[1]", F_ALIAS },/* sth %g0,[rs1+%g0] */ -{ "clrh", 0xc0300000, 0x3fc80000, "[1+2]", F_ALIAS }, -{ "clrh", 0xc0302000, 0x3fc80000, "[1+i]", F_ALIAS }, -{ "clrh", 0xc0302000, 0x3fc80000, "[i+1]", F_ALIAS }, - -{ "orncc", 0x80b02000, 0x04048000, "1,i,d", 0 }, -{ "orncc", 0x80b00000, 0x04048000, "1,2,d", 0 }, - -{ "tst", 0x80900000, 0x7f6fe000, "2", 0 }, /* orcc %g0, rs2, %g0 */ -{ "tst", 0x80900000, 0x7f68201f, "1", 0 }, /* orcc rs1, %g0, %g0 */ -{ "tst", 0x80902000, 0x7f681fff, "1", 0 }, /* orcc rs1, 0, %g0 */ - -{ "orcc", 0x80902000, 0x41680000, "1,i,d", 0 }, -{ "orcc", 0x80902000, 0x41680000, "i,1,d", 0 }, -{ "orcc", 0x80900000, 0x41680000, "1,2,d", 0 }, -{ "orn", 0x80302000, 0x41c80000, "1,i,d", 0 }, -{ "orn", 0x80300000, 0x41c80000, "1,2,d", 0 }, - -{ "mov", 0x81800000, 0x4078201f, "1,y", F_ALIAS }, /* wr rs1,%g0,%y */ -{ "mov", 0x81802000, 0x40781fff, "1,y", F_ALIAS }, /* wr rs1,0,%y */ -{ "mov", 0x81802000, 0x40780000, "i,y", F_ALIAS }, -{ "mov", 0x81400000, 0x40b80000, "y,d", F_ALIAS }, /* rd %y,d */ -{ "mov", 0x81980000, 0x4060201f, "1,t", F_ALIAS }, /* wr rs1,%g0,%tbr */ -{ "mov", 0x81982000, 0x40601fff, "1,t", F_ALIAS }, /* wr rs1,0,%tbr */ -{ "mov", 0x81982000, 0x40600000, "i,t", F_ALIAS }, -{ "mov", 0x81580000, 0x40a00000, "t,d", F_ALIAS }, /* rd %tbr,d */ -{ "mov", 0x81900000, 0x4068201f, "1,w", F_ALIAS }, /* wr rs1,%g0,%wim */ -{ "mov", 0x81902000, 0x40681fff, "1,w", F_ALIAS }, /* wr rs1,0,%wim */ -{ "mov", 0x81902000, 0x40680000, "i,w", F_ALIAS }, -{ "mov", 0x81500000, 0x40a80000, "w,d", F_ALIAS }, /* rd %wim,d */ -{ "mov", 0x81880000, 0x4070201f, "1,p", F_ALIAS }, /* wr rs1,%g0,%psr */ -{ "mov", 0x81882000, 0x40701fff, "1,p", F_ALIAS }, /* wr rs1,0,%psr */ -{ "mov", 0x81882000, 0x40700000, "i,p", F_ALIAS }, -{ "mov", 0x81480000, 0x40b00000, "p,d", F_ALIAS }, /* rd %psr,d */ - -{ "mov", 0x80102000, 0x41efc000, "i,d", 0 }, /* or %g0,i,d */ -{ "mov", 0x80100000, 0x41efe000, "2,d", 0 }, /* or %g0,rs2,d */ -{ "mov", 0x80102000, 0x41e81fff, "1,d", 0 }, /* or rs1,0,d */ -{ "mov", 0x80100000, 0x41e8201f, "1,d", 0 }, /* or rs1,%g0,d */ - -{ "or", 0x80102000, 0x40800000, "1,i,d", 0 }, -{ "or", 0x80102000, 0x40800000, "i,1,d", 0 }, -{ "or", 0x80100000, 0x40800000, "1,2,d", 0 }, - -{ "bset", 0x80102000, 0x40800000, "i,r", F_ALIAS },/* or rd,i,rd */ -{ "bset", 0x80100000, 0x40800000, "2,r", F_ALIAS },/* or rd,rs2,rd */ - -{ "andncc", 0x80a82000, 0x41500000, "1,i,d", 0 }, -{ "andncc", 0x80a80000, 0x41500000, "1,2,d", 0 }, -{ "andn", 0x80282000, 0x41d00000, "1,i,d", 0 }, -{ "andn", 0x80280000, 0x41d00000, "1,2,d", 0 }, - -{ "bclr", 0x80282000, 0x41d00000, "i,r", F_ALIAS },/* andn rd,i,rd */ -{ "bclr", 0x80280000, 0x41d00000, "2,r", F_ALIAS },/* andn rd,rs2,rd */ - -{ "cmp", 0x80a02000, 0x7d580000, "1,i", 0 }, /* subcc rs1,i,%g0 */ -{ "cmp", 0x80a00000, 0x7d580000, "1,2", 0 }, /* subcc rs1,rs2,%g0 */ - -{ "subcc", 0x80a02000, 0x41580000, "1,i,d", 0 }, -{ "subcc", 0x80a00000, 0x41580000, "1,2,d", 0 }, -{ "sub", 0x80202000, 0x41d80000, "1,i,d", 0 }, -{ "sub", 0x80200000, 0x41d80000, "1,2,d", 0 }, -{ "subx", 0x80602000, 0x41980000, "1,i,d", 0 }, -{ "subx", 0x80600000, 0x41980000, "1,2,d", 0 }, -{ "subxcc", 0x80e02000, 0x41180000, "1,i,d", 0 }, -{ "subxcc", 0x80e00000, 0x41180000, "1,2,d", 0 }, - -{ "andcc", 0x80882000, 0x41700000, "1,i,d", 0 }, -{ "andcc", 0x80882000, 0x41700000, "i,1,d", 0 }, -{ "andcc", 0x80880000, 0x41700000, "1,2,d", 0 }, -{ "and", 0x80082000, 0x41f00000, "1,i,d", 0 }, -{ "and", 0x80082000, 0x41f00000, "i,1,d", 0 }, -{ "and", 0x80080000, 0x41f00000, "1,2,d", 0 }, - -{ "inc", 0x80002001, 0x41f81ffe, "r", F_ALIAS }, /* add rs1,1,rsd */ -{ "inccc", 0x80802001, 0x41781ffe, "r", F_ALIAS }, /* addcc rd,1,rd */ -{ "dec", 0x80202001, 0x41d81ffe, "r", F_ALIAS }, /* sub rd,1,rd */ -{ "deccc", 0x80a02001, 0x41581ffe, "r", F_ALIAS }, /* subcc rd,1,rd */ - -{ "btst", 0x80882000, 0x41700000, "i,1", F_ALIAS },/* andcc rs1,i,%g0 */ -{ "btst", 0x80880000, 0x41700000, "1,2", F_ALIAS },/* andcc rs1,rs2,%0 */ - -{ "neg", 0x80200000, 0x41d80000, "r", F_ALIAS }, /* sub %0,rd,rd */ -{ "neg", 0x80200000, 0x41d80000, "2,d", F_ALIAS }, /* sub %0,rs2,rd */ - -{ "addxcc", 0x80c02000, 0x41380000, "1,i,d", 0 }, -{ "addxcc", 0x80c02000, 0x41380000, "i,1,d", 0 }, -{ "addxcc", 0x80c00000, 0x41380000, "1,2,d", 0 }, -{ "addcc", 0x80802000, 0x41780000, "1,i,d", 0 }, -{ "addcc", 0x80802000, 0x41780000, "i,1,d", 0 }, -{ "addcc", 0x80800000, 0x41780000, "1,2,d", 0 }, -{ "addx", 0x80402000, 0x41b80000, "1,i,d", 0 }, -{ "addx", 0x80402000, 0x41b80000, "i,1,d", 0 }, -{ "addx", 0x80400000, 0x41b80000, "1,2,d", 0 }, -{ "add", 0x80002000, 0x41f80000, "1,i,d", 0 }, -{ "add", 0x80002000, 0x41f80000, "i,1,d", 0 }, -{ "add", 0x80000000, 0x41f80000, "1,2,d", 0 }, - -{ "call", 0x9fc00000, 0x4038201f, "1", F_DELAYED }, /* jmpl rs1+%g0, %o7 */ -{ "call", 0x9fc00000, 0x4038201f, "1,#", F_DELAYED }, -{ "call", 0x40000000, 0x80000000, "L", F_DELAYED }, -{ "call", 0x40000000, 0x80000000, "L,#", F_DELAYED }, - -{ "jmp", 0x81c00000, 0x7e38201f, "1", F_DELAYED }, /* jmpl rs1+%g0,%g0 */ -{ "jmp", 0x81c02000, 0x7e3fc000, "i", F_DELAYED }, /* jmpl %g0+i,%g0 */ -{ "jmp", 0x81c00000, 0x7e382000, "1+2", F_DELAYED }, /* jmpl rs1+rs2,%g0 */ -{ "jmp", 0x81c02000, 0x7e380000, "1+i", F_DELAYED }, /* jmpl rs1+i,%g0 */ -{ "jmp", 0x81c02000, 0x7e380000, "i+1", F_DELAYED }, /* jmpl i+rs1,%g0 */ - -{ "nop", 0x01000000, 0xfeffffff, "", 0 }, /* sethi 0, %g0 */ - -{ "set", 0x01000000, 0xc0c00000, "Sh,d", F_ALIAS }, - -{ "sethi", 0x01000000, 0xc0c00000, "h,d", 0 }, - -{ "taddcctv", 0x81102000, 0x40e00000, "1,i,d", 0 }, -{ "taddcctv", 0x81100000, 0x40e00000, "1,2,d", 0 }, -{ "taddcc", 0x81002000, 0x40f80000, "1,i,d", 0 }, -{ "taddcc", 0x81000000, 0x40f80000, "1,2,d", 0 }, - -/* Conditional instructions. - - Because this part of the table was such a mess earlier, I have - macrofied it so that all the branches and traps are generated from - a single-line description of each condition value. */ - -#define ANNUL 0x20000000 -#define IMMED 0x00002000 -#define RS1_G0 0x0007C000 -#define RS2_G0 0x0000001F - -/* Define two branches -- one annulled, one without */ -#define br(opcode, mask, lose, flags) \ - { opcode, mask+ANNUL, lose, ",al", flags }, \ - { opcode, mask , lose, "l", flags } - -/* Define four traps: reg+reg, reg + immediate, immediate alone, reg alone. */ -#define tr(opcode, mask, lose, flags) \ - {opcode, mask+IMMED, lose+RS1_G0 , "i", flags }, /* %g0 + imm */ \ - {opcode, mask+IMMED, lose , "1+i", flags }, /* rs1 + imm */ \ - {opcode, mask , lose+IMMED , "1+2", flags }, /* rs1 + rs2 */ \ - {opcode, mask , lose+IMMED+RS2_G0, "1", flags } /* rs1 + %g0 */ - -/* Define both branches and traps based on condition mask */ -#ifdef __STDC__ -#define cond(bop, top, mask, flags) \ - br(#bop, 0x00800000+(mask << 25), 0xC1400000, F_DELAYED|flags), \ - tr(#top, 0x81d00000+(mask << 25), 0x40280000, flags) -#else -#define cond(bop, top, mask, flags) \ - br("bop", 0x00800000+(mask << 25), 0xC1400000, F_DELAYED|flags), \ - tr("top", 0x81d00000+(mask << 25), 0x40280000, flags) -#endif - -/* Define all the conditions, all the branches, all the traps. */ -/* Use no extra spaces or tabs around the first two args, since cpp - will include them in the printed strings. */ -cond (bvc,tvc, 0xF, 0), -cond (bvs,tvs, 0x7, 0), -cond (bpos,tpos, 0xE, 0), -cond (bneg,tneg, 0x6, 0), -cond (bcc,tcc, 0xD, 0), -cond (bcs,tcs, 0x5, 0), -cond (blu,tlu, 0x5, F_ALIAS), /* for cs */ -cond (bgeu,tgeu, 0xD, F_ALIAS), /* for cc */ -cond (bgu,tgu, 0xC, 0), -cond (bleu,tleu, 0x4, 0), -cond (bge,tge, 0xB, 0), -cond (bl,tl, 0x3, 0), -cond (bg,tg, 0xA, 0), -cond (ble,tle, 0x2, 0), -cond (be,te, 0x1, 0), -cond (bz,tz, 0x1, F_ALIAS), /* for e */ -cond (bne,tne, 0x9, 0), -cond (bnz,tnz, 0x9, F_ALIAS), /* for ne */ -cond (b,t, 0x8, 0), -cond (ba,ta, 0x8, F_ALIAS), /* for nothing */ -cond (bn,tn, 0x0, 0), - -#undef cond -#undef br -#undef tr - -{ "tsubcc", 0x81080000, 0x40f00000, "1,2,d", 0 }, -{ "tsubcc", 0x81082000, 0x40f00000, "1,i,d", 0 }, -{ "tsubcctv", 0x80580000, 0x40a00000, "1,2,d", 0 }, -{ "tsubcctv", 0x80582000, 0x40a00000, "1,i,d", 0 }, - -{ "unimp", 0x00000000, 0xFFFFFFFF, "l", 0 }, - -{ "iflush", 0x81d80000, 0x40202000, "1+2", 0 }, -{ "iflush", 0x81d82000, 0x40200000, "1+i", 0 }, - -{ "xnorcc", 0x80b80000, 0x41400000, "1,2,d", 0 }, -{ "xnorcc", 0x80b82000, 0x41400000, "1,i,d", 0 }, -{ "xnorcc", 0x80b82000, 0x41400000, "i,1,d", 0 }, -{ "xorcc", 0x80980000, 0x41600000, "1,2,d", 0 }, -{ "xorcc", 0x80982000, 0x41600000, "1,i,d", 0 }, -{ "xorcc", 0x80982000, 0x41600000, "i,1,d", 0 }, -{ "xnor", 0x80380000, 0x41c00000, "1,2,d", 0 }, -{ "xnor", 0x80382000, 0x41c00000, "1,i,d", 0 }, -{ "xnor", 0x80382000, 0x41c00000, "i,1,d", 0 }, -{ "xor", 0x80180000, 0x41e00000, "1,2,d", 0 }, -{ "xor", 0x80182000, 0x41e00000, "1,i,d", 0 }, -{ "xor", 0x80182000, 0x41e00000, "i,1,d", 0 }, - -{ "not", 0x80380000, 0x41c00000, "r", F_ALIAS }, /* xnor rd,%0,rd */ -{ "not", 0x80380000, 0x41c00000, "1,d", F_ALIAS }, /* xnor rs1,%0,rd */ - -{ "btog", 0x80180000, 0x41e02000, "2,r", F_ALIAS }, /* xor rd,rs2,rd */ -{ "btog", 0x80182000, 0x41e00000, "i,r", F_ALIAS }, /* xor rd,i,rd */ - -{ "fpop1", 0x81a00000, 0x40580000, "[1+2],d", 0 }, -{ "fpop2", 0x81a80000, 0x40500000, "[1+2],d", 0 }, - -/* Someday somebody should give these the same treatment as the branches - above. FIXME someday. */ - -{ "fb", 0x31800000, 0xc0400000, ",al", F_DELAYED }, -{ "fb", 0x11800000, 0xc0400000, "l", F_DELAYED }, -{ "fba", 0x31800000, 0xc0400000, ",al", F_DELAYED|F_ALIAS }, -{ "fba", 0x11800000, 0xc0400000, "l", F_DELAYED|F_ALIAS }, -{ "fbn", 0x21800000, 0xc0400000, ",al", F_DELAYED }, -{ "fbn", 0x01800000, 0xc0400000, "l", F_DELAYED }, -{ "fbu", 0x2f800000, 0xc0400000, ",al", F_DELAYED }, -{ "fbu", 0x0f800000, 0xc0400000, "l", F_DELAYED }, -{ "fbg", 0x2d800000, 0xc0400000, ",al", F_DELAYED }, -{ "fbg", 0x0d800000, 0xc0400000, "l", F_DELAYED }, -{ "fbug", 0x2b800000, 0xc0400000, ",al", F_DELAYED }, -{ "fbug", 0x0b800000, 0xc0400000, "l", F_DELAYED }, -{ "fbl", 0x29800000, 0xc0400000, ",al", F_DELAYED }, -{ "fbl", 0x09800000, 0xc0400000, "l", F_DELAYED }, -{ "fbul", 0x27800000, 0xc0400000, ",al", F_DELAYED }, -{ "fbul", 0x07800000, 0xc0400000, "l", F_DELAYED }, -{ "fblg", 0x25800000, 0xc0400000, ",al", F_DELAYED }, -{ "fblg", 0x05800000, 0xc0400000, "l", F_DELAYED }, -{ "fbne", 0x23800000, 0xc0400000, ",al", F_DELAYED }, -{ "fbne", 0x03800000, 0xc0400000, "l", F_DELAYED }, -{ "fbe", 0x33800000, 0xc0400000, ",al", F_DELAYED }, -{ "fbe", 0x13800000, 0xc0400000, "l", F_DELAYED }, -{ "fbue", 0x35800000, 0xc0400000, ",al", F_DELAYED }, -{ "fbue", 0x15800000, 0xc0400000, "l", F_DELAYED }, -{ "fbge", 0x37800000, 0xc0400000, ",al", F_DELAYED }, -{ "fbge", 0x17800000, 0xc0400000, "l", F_DELAYED }, -{ "fbuge", 0x39800000, 0xc0400000, ",al", F_DELAYED }, -{ "fbuge", 0x19800000, 0xc0400000, "l", F_DELAYED }, -{ "fble", 0x3b800000, 0xc0400000, ",al", F_DELAYED }, -{ "fble", 0x1b800000, 0xc0400000, "l", F_DELAYED }, -{ "fbule", 0x3d800000, 0xc0400000, ",al", F_DELAYED }, -{ "fbule", 0x1d800000, 0xc0400000, "l", F_DELAYED }, -{ "fbo", 0x3f800000, 0xc0400000, ",al", F_DELAYED }, -{ "fbo", 0x1f800000, 0xc0400000, "l", F_DELAYED }, - -{ "cba", 0x31c00000, 0xce000000, ",al", F_DELAYED }, -{ "cba", 0x11c00000, 0xce000000, "l", F_DELAYED }, -{ "cbn", 0x21c00000, 0xde000000, ",al", F_DELAYED }, -{ "cbn", 0x01c00000, 0xde000000, "l", F_DELAYED }, -{ "cb3", 0x2fc00000, 0xc0000000, ",al", F_DELAYED }, -{ "cb3", 0x0fc00000, 0xc0000000, "l", F_DELAYED }, -{ "cb2", 0x2dc00000, 0xc0000000, ",al", F_DELAYED }, -{ "cb2", 0x0dc00000, 0xc0000000, "l", F_DELAYED }, -{ "cb23", 0x2bc00000, 0xc0000000, ",al", F_DELAYED }, -{ "cb23", 0x0bc00000, 0xc0000000, "l", F_DELAYED }, -{ "cb1", 0x29c00000, 0xc0000000, ",al", F_DELAYED }, -{ "cb1", 0x09c00000, 0xc0000000, "l", F_DELAYED }, -{ "cb13", 0x27c00000, 0xc0000000, ",al", F_DELAYED }, -{ "cb13", 0x07c00000, 0xc0000000, "l", F_DELAYED }, -{ "cb12", 0x25c00000, 0xc0000000, ",al", F_DELAYED }, -{ "cb12", 0x05c00000, 0xc0000000, "l", F_DELAYED }, -{ "cb123", 0x23c00000, 0xc0000000, ",al", F_DELAYED }, -{ "cb123", 0x03c00000, 0xc0000000, "l", F_DELAYED }, -{ "cb0", 0x33c00000, 0xc0000000, ",al", F_DELAYED }, -{ "cb0", 0x13c00000, 0xc0000000, "l", F_DELAYED }, -{ "cb03", 0x35c00000, 0xc0000000, ",al", F_DELAYED }, -{ "cb03", 0x15c00000, 0xc0000000, "l", F_DELAYED }, -{ "cb02", 0x37c00000, 0xc0000000, ",al", F_DELAYED }, -{ "cb02", 0x17c00000, 0xc0000000, "l", F_DELAYED }, -{ "cb023", 0x39c00000, 0xc0000000, ",al", F_DELAYED }, -{ "cb023", 0x19c00000, 0xc0000000, "l", F_DELAYED }, -{ "cb01", 0x3bc00000, 0xc0000000, ",al", F_DELAYED }, -{ "cb01", 0x1bc00000, 0xc0000000, "l", F_DELAYED }, -{ "cb013", 0x3dc00000, 0xc0000000, ",al", F_DELAYED }, -{ "cb013", 0x1dc00000, 0xc0000000, "l", F_DELAYED }, -{ "cb012", 0x3fc00000, 0xc0000000, ",al", F_DELAYED }, -{ "cb012", 0x1fc00000, 0xc0000000, "l", F_DELAYED }, - -{ "fstoi", 0x81a01a20, 0x400025c0, "f,g", 0 }, -{ "fdtoi", 0x81a01a40, 0x400025a0, "f,g", 0 }, -{ "fxtoi", 0x81a01a60, 0x40002580, "f,g", 0 }, - -{ "fitox", 0x81a01980, 0x40002660, "f,g", 0 }, -{ "fitod", 0x81a01900, 0x400026e0, "f,g", 0 }, -{ "fitos", 0x81a01880, 0x40002660, "f,g", 0 }, - -{ "fstod", 0x81a01920, 0x400026c0, "f,g", 0 }, -{ "fstox", 0x81a019a0, 0x40002640, "f,g", 0 }, -{ "fdtos", 0x81a018c0, 0x40002720, "f,g", 0 }, -{ "fdtox", 0x81a019c0, 0x40002620, "f,g", 0 }, -{ "fxtos", 0x81a018e0, 0x40002700, "f,g", 0 }, -{ "fxtod", 0x81a01960, 0x40002680, "f,g", 0 }, - -{ "fdivx", 0x81a009e0, 0x40083600, "e,f,g", 0 }, -{ "fdivd", 0x81a009c0, 0x40003620, "e,f,g", 0 }, -{ "fdivs", 0x81a009a0, 0x40003640, "e,f,g", 0 }, - -{ "fmuls", 0x81a00920, 0x400036c0, "e,f,g", 0 }, -{ "fmuld", 0x81a00940, 0x400036a0, "e,f,g", 0 }, -{ "fmulx", 0x81a00960, 0x40003680, "e,f,g", 0 }, - -{ "fsqrts", 0x81a00520, 0x40003ac0, "f,g", 0 }, -{ "fsqrtd", 0x81a00540, 0x40003aa8, "f,g", 0 }, -{ "fsqrtx", 0x81a00560, 0x40003a80, "f,g", 0 }, - -{ "fabss", 0x81a00120, 0x40003ec0, "f,g", 0 }, -{ "fnegs", 0x81a000a0, 0x40003f40, "f,g", 0 }, -{ "fmovs", 0x81a00020, 0x40003fc0, "f,g", 0 }, - -{ "fsubx", 0x81a008e0, 0x40003700, "e,f,g", 0 }, -{ "fsubd", 0x81a008c0, 0x40003720, "e,f,g", 0 }, -{ "fsubs", 0x81a008a0, 0x40003740, "e,f,g", 0 }, - -{ "faddx", 0x81a00860, 0x40003780, "e,f,g", 0 }, -{ "faddd", 0x81a00840, 0x400037a0, "e,f,g", 0 }, -{ "fadds", 0x81a00820, 0x400037c0, "e,f,g", 0 }, - -{ "fcmpex", 0x81a80ae0, 0x40003500, "e,f", 0 }, -{ "fcmped", 0x81a80ac0, 0x40003520, "e,f", 0 }, -{ "fcmpes", 0x81a80aa0, 0x40003540, "e,f", 0 }, -{ "fcmpx", 0x81a80a60, 0x40003580, "e,f", 0 }, -{ "fcmpd", 0x81a80a40, 0x400035a0, "e,f", 0 }, -{ "fcmps", 0x81a80a20, 0x400035c0, "e,f", 0 }, - -{ "cpop1", 0x81b00000, 0x40480000, "[1+2],d", 0 }, -{ "cpop2", 0x81b80000, 0x40400000, "[1+2],d", 0 }, -}; - -#define NUMOPCODES ((sizeof sparc_opcodes)/(sizeof sparc_opcodes[0])) - diff --git a/gdb/sparc-pinsn.c b/gdb/sparc-pinsn.c deleted file mode 100644 index 2a63772ad7c..00000000000 --- a/gdb/sparc-pinsn.c +++ /dev/null @@ -1,465 +0,0 @@ -/* Disassembler for the sparc. - Copyright (C) 1989 Free Software Foundation, Inc. - -This file is part of GDB, the GNU disassembler. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include - -#include "defs.h" -#include "param.h" -#include "symtab.h" -#include "sparc-opcode.h" -#include "gdbcore.h" -#include "string.h" -#include "target.h" - -extern void qsort (); - - -extern char *reg_names[]; -#define freg_names (®_names[4 * 8]) - -union sparc_insn - { - unsigned long int code; - struct - { - unsigned int OP:2; -#define op ldst.OP - unsigned int RD:5; -#define rd ldst.RD - unsigned int op3:6; - unsigned int RS1:5; -#define rs1 ldst.RS1 - unsigned int i:1; - unsigned int ASI:8; -#define asi ldst.ASI - unsigned int RS2:5; -#define rs2 ldst.RS2 -#define shcnt rs2 - } ldst; - struct - { - unsigned int OP:2, RD:5, op3:6, RS1:5, i:1; - unsigned int IMM13:13; -#define imm13 IMM13.IMM13 - } IMM13; - struct - { - unsigned int OP:2; - unsigned int a:1; - unsigned int cond:4; - unsigned int op2:3; - unsigned int DISP22:22; -#define disp22 branch.DISP22 - } branch; -#define imm22 disp22 - struct - { - unsigned int OP:2; - unsigned int DISP30:30; -#define disp30 call.DISP30 - } call; - }; - -/* Nonzero if INSN is the opcode for a delayed branch. */ -static int -is_delayed_branch (insn) - union sparc_insn insn; -{ - unsigned int i; - - for (i = 0; i < NUMOPCODES; ++i) - { - const struct sparc_opcode *opcode = &sparc_opcodes[i]; - if ((opcode->match & insn.code) == opcode->match - && (opcode->lose & insn.code) == 0) - return (opcode->flags & F_DELAYED); - } - return 0; -} - -static int opcodes_sorted = 0; - -/* Print one instruction from MEMADDR on STREAM. */ -int -print_insn (memaddr, stream) - CORE_ADDR memaddr; - FILE *stream; -{ - union sparc_insn insn; - - register unsigned int i; - - if (!opcodes_sorted) - { - static int compare_opcodes (); - qsort ((char *) sparc_opcodes, NUMOPCODES, - sizeof (sparc_opcodes[0]), compare_opcodes); - opcodes_sorted = 1; - } - - read_memory (memaddr, &insn, sizeof (insn)); - - for (i = 0; i < NUMOPCODES; ++i) - { - const struct sparc_opcode *opcode = &sparc_opcodes[i]; - if ((opcode->match & insn.code) == opcode->match - && (opcode->lose & insn.code) == 0) - { - /* Nonzero means that we have found an instruction which has - the effect of adding or or'ing the imm13 field to rs1. */ - int imm_added_to_rs1 = 0; - - /* Nonzero means that we have found a plus sign in the args - field of the opcode table. */ - int found_plus = 0; - - /* Do we have an 'or' instruction where rs1 is the same - as rsd, and which has the i bit set? */ - if (opcode->match == 0x80102000 - && insn.rs1 == insn.rd) - imm_added_to_rs1 = 1; - - if (insn.rs1 != insn.rd - && strchr (opcode->args, 'r') != 0) - /* Can't do simple format if source and dest are different. */ - continue; - - fputs_filtered (opcode->name, stream); - - { - register const char *s; - - if (opcode->args[0] != ',') - fputs_filtered (" ", stream); - for (s = opcode->args; *s != '\0'; ++s) - { - if (*s == ',') - { - fputs_filtered (",", stream); - ++s; - if (*s == 'a') - { - fputs_filtered ("a", stream); - ++s; - } - fputs_filtered (" ", stream); - } - - switch (*s) - { - case '+': - found_plus = 1; - - /* note fall-through */ - default: - fprintf_filtered (stream, "%c", *s); - break; - - case '#': - fputs_filtered ("0", stream); - break; - -#define reg(n) fprintf_filtered (stream, "%%%s", reg_names[n]) - case '1': - case 'r': - reg (insn.rs1); - break; - - case '2': - reg (insn.rs2); - break; - - case 'd': - reg (insn.rd); - break; -#undef reg - -#define freg(n) fprintf_filtered (stream, "%%%s", freg_names[n]) - case 'e': - freg (insn.rs1); - break; - - case 'f': - freg (insn.rs2); - break; - - case 'g': - freg (insn.rd); - break; -#undef freg - -#define creg(n) fprintf_filtered (stream, "%%c%u", (unsigned int) (n)) - case 'b': - creg (insn.rs1); - break; - - case 'c': - creg (insn.rs2); - break; - - case 'D': - creg (insn.rd); - break; -#undef creg - - case 'h': - fprintf_filtered (stream, "%%hi(%#x)", - (int) insn.imm22 << 10); - break; - - case 'i': - { - /* We cannot trust the compiler to sign-extend - when extracting the bitfield, hence the shifts. */ - int imm = ((int) insn.imm13 << 19) >> 19; - - /* Check to see whether we have a 1+i, and take - note of that fact. - - Note: because of the way we sort the table, - we will be matching 1+i rather than i+1, - so it is OK to assume that i is after +, - not before it. */ - if (found_plus) - imm_added_to_rs1 = 1; - - if (imm <= 9) - fprintf_filtered (stream, "%d", imm); - else - fprintf_filtered (stream, "%#x", imm); - } - break; - - case 'L': - print_address ((CORE_ADDR) memaddr + insn.disp30 * 4, - stream); - break; - - case 'l': - if ((insn.code >> 22) == 0) - /* Special case for `unimp'. Don't try to turn - it's operand into a function offset. */ - fprintf_filtered (stream, "%#x", - (int) (((int) insn.disp22 << 10) >> 10)); - else - /* We cannot trust the compiler to sign-extend - when extracting the bitfield, hence the shifts. */ - print_address ((CORE_ADDR) - (memaddr - + (((int) insn.disp22 << 10) >> 10) * 4), - stream); - break; - - case 'A': - fprintf_filtered (stream, "(%d)", (int) insn.asi); - break; - - case 'C': - fputs_filtered ("%csr", stream); - break; - - case 'F': - fputs_filtered ("%fsr", stream); - break; - - case 'p': - fputs_filtered ("%psr", stream); - break; - - case 'q': - fputs_filtered ("%fq", stream); - break; - - case 'Q': - fputs_filtered ("%cq", stream); - break; - - case 't': - fputs_filtered ("%tbr", stream); - break; - - case 'w': - fputs_filtered ("%wim", stream); - break; - - case 'y': - fputs_filtered ("%y", stream); - break; - } - } - } - - /* If we are adding or or'ing something to rs1, then - check to see whether the previous instruction was - a sethi to the same register as in the sethi. - If so, attempt to print the result of the add or - or (in this context add and or do the same thing) - and its symbolic value. */ - if (imm_added_to_rs1) - { - union sparc_insn prev_insn; - int errcode; - - errcode = target_read_memory (memaddr - 4, - (char *)&prev_insn, sizeof (prev_insn)); - - if (errcode == 0) - { - /* If it is a delayed branch, we need to look at the - instruction before the delayed branch. This handles - sequences such as - - sethi %o1, %hi(_foo), %o1 - call _printf - or %o1, %lo(_foo), %o1 - */ - - if (is_delayed_branch (prev_insn)) - errcode = target_read_memory - (memaddr - 8, (char *)&prev_insn, sizeof (prev_insn)); - } - - /* If there was a problem reading memory, then assume - the previous instruction was not sethi. */ - if (errcode == 0) - { - /* Is it sethi to the same register? */ - if ((prev_insn.code & 0xc1c00000) == 0x01000000 - && prev_insn.rd == insn.rs1) - { - fprintf_filtered (stream, "\t! "); - /* We cannot trust the compiler to sign-extend - when extracting the bitfield, hence the shifts. */ - print_address (((int) prev_insn.imm22 << 10) - | (insn.imm13 << 19) >> 19, stream); - } - } - } - - return sizeof (insn); - } - } - - printf_filtered ("%#8x", insn.code); - return sizeof (insn); -} - - -/* Compare opcodes A and B. */ - -static int -compare_opcodes (a, b) - char *a, *b; -{ - struct sparc_opcode *op0 = (struct sparc_opcode *) a; - struct sparc_opcode *op1 = (struct sparc_opcode *) b; - unsigned long int match0 = op0->match, match1 = op1->match; - unsigned long int lose0 = op0->lose, lose1 = op1->lose; - register unsigned int i; - - /* If a bit is set in both match and lose, there is something - wrong with the opcode table. */ - if (match0 & lose0) - { - fprintf (stderr, "Internal error: bad sparc-opcode.h: \"%s\", %#.8lx, %#.8lx\n", - op0->name, match0, lose0); - op0->lose &= ~op0->match; - lose0 = op0->lose; - } - - if (match1 & lose1) - { - fprintf (stderr, "Internal error: bad sparc-opcode.h: \"%s\", %#.8lx, %#.8lx\n", - op1->name, match1, lose1); - op1->lose &= ~op1->match; - lose1 = op1->lose; - } - - /* Because the bits that are variable in one opcode are constant in - another, it is important to order the opcodes in the right order. */ - for (i = 0; i < 32; ++i) - { - unsigned long int x = 1 << i; - int x0 = (match0 & x) != 0; - int x1 = (match1 & x) != 0; - - if (x0 != x1) - return x1 - x0; - } - - for (i = 0; i < 32; ++i) - { - unsigned long int x = 1 << i; - int x0 = (lose0 & x) != 0; - int x1 = (lose1 & x) != 0; - - if (x0 != x1) - return x1 - x0; - } - - /* They are functionally equal. So as long as the opcode table is - valid, we can put whichever one first we want, on aesthetic grounds. */ - - /* Our first aesthetic ground is that aliases defer to real insns. */ - { - int alias_diff = (op0->flags & F_ALIAS) - (op1->flags & F_ALIAS); - if (alias_diff != 0) - /* Put the one that isn't an alias first. */ - return alias_diff; - } - - /* Except for the above aliases, two "identical" instructions had - better have the same opcode. This is a sanity check on the table. */ - if (0 != strcmp (op0->name, op1->name)) - fprintf (stderr, "Internal error: bad sparc-opcode.h: \"%s\" == \"%s\"\n", - op0->name, op1->name); - - /* Fewer arguments are preferred. */ - { - int length_diff = strlen (op0->args) - strlen (op1->args); - if (length_diff != 0) - /* Put the one with fewer arguments first. */ - return length_diff; - } - - /* Put 1+i before i+1. */ - { - char *p0 = (char *) strchr(op0->args, '+'); - char *p1 = (char *) strchr(op1->args, '+'); - - if (p0 && p1) - { - /* There is a plus in both operands. Note that a plus - sign cannot be the first character in args, - so the following [-1]'s are valid. */ - if (p0[-1] == 'i' && p1[1] == 'i') - /* op0 is i+1 and op1 is 1+i, so op1 goes first. */ - return 1; - if (p0[1] == 'i' && p1[-1] == 'i') - /* op0 is 1+i and op1 is i+1, so op0 goes first. */ - return -1; - } - } - - /* They are, as far as we can tell, identical. - Since qsort may have rearranged the table partially, there is - no way to tell which one was first in the opcode table as - written, so just say there are equal. */ - return 0; -} diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c deleted file mode 100644 index 12ad9c564a2..00000000000 --- a/gdb/sparc-tdep.c +++ /dev/null @@ -1,644 +0,0 @@ -/* Machine-dependent code which would otherwise be in inflow.c and core.c, - for GDB, the GNU debugger. - Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc. - This code is for the sparc cpu. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "defs.h" -#include "param.h" -#include "frame.h" -#include "inferior.h" -#include "obstack.h" -#include "signame.h" -#include "target.h" -#include "ieee-float.h" - -#include - -#include "gdbcore.h" - -/* From infrun.c */ -extern int stop_after_trap; - -typedef enum -{ - Error, not_branch, bicc, bicca, ba, baa, ticc, ta, -} branch_type; - -/* Simulate single-step ptrace call for sun4. Code written by Gary - Beihl (beihl@mcc.com). */ - -/* npc4 and next_pc describe the situation at the time that the - step-breakpoint was set, not necessary the current value of NPC_REGNUM. */ -static CORE_ADDR next_pc, npc4, target; -static int brknpc4, brktrg; -typedef char binsn_quantum[BREAKPOINT_MAX]; -static binsn_quantum break_mem[3]; - -/* Non-zero if we just simulated a single-step ptrace call. This is - needed because we cannot remove the breakpoints in the inferior - process until after the `wait' in `wait_for_inferior'. Used for - sun4. */ - -int one_stepped; - -/* single_step() is called just before we want to resume the inferior, - if we want to single-step it but there is no hardware or kernel single-step - support (as on all SPARCs). We find all the possible targets of the - coming instruction and breakpoint them. - - single_step is also called just after the inferior stops. If we had - set up a simulated single-step, we undo our damage. */ - -void -single_step () -{ - branch_type br, isannulled(); - CORE_ADDR pc; - long pc_instruction; - - if (!one_stepped) - { - /* Always set breakpoint for NPC. */ - next_pc = read_register (NPC_REGNUM); - npc4 = next_pc + 4; /* branch not taken */ - - target_insert_breakpoint (next_pc, break_mem[0]); - /* printf ("set break at %x\n",next_pc); */ - - pc = read_register (PC_REGNUM); - pc_instruction = read_memory_integer (pc, sizeof(pc_instruction)); - br = isannulled (pc_instruction, pc, &target); - brknpc4 = brktrg = 0; - - if (br == bicca) - { - /* Conditional annulled branch will either end up at - npc (if taken) or at npc+4 (if not taken). - Trap npc+4. */ - brknpc4 = 1; - target_insert_breakpoint (npc4, break_mem[1]); - } - else if (br == baa && target != next_pc) - { - /* Unconditional annulled branch will always end up at - the target. */ - brktrg = 1; - target_insert_breakpoint (target, break_mem[2]); - } - - /* We are ready to let it go */ - one_stepped = 1; - return; - } - else - { - /* Remove breakpoints */ - target_remove_breakpoint (next_pc, break_mem[0]); - - if (brknpc4) - target_remove_breakpoint (npc4, break_mem[1]); - - if (brktrg) - target_remove_breakpoint (target, break_mem[2]); - - one_stepped = 0; - } -} - -CORE_ADDR -sparc_frame_chain (thisframe) - FRAME thisframe; -{ - CORE_ADDR retval; - int err; - err = target_read_memory - ((CORE_ADDR)&(((struct rwindow *)(thisframe->frame))->rw_in[6]), - &retval, - sizeof (CORE_ADDR)); - if (err) - return 0; - return retval; -} - -CORE_ADDR -sparc_extract_struct_value_address (regbuf) - char regbuf[REGISTER_BYTES]; -{ - CORE_ADDR retval; - read_memory (((int *)(regbuf))[SP_REGNUM]+(16*4), - &retval, - sizeof (CORE_ADDR)); - return retval; -} - -/* - * Find the pc saved in frame FRAME. - */ -CORE_ADDR -frame_saved_pc (frame) - FRAME frame; -{ - CORE_ADDR prev_pc; - - /* If it's at the bottom, the return value's stored in i7/rp */ - if (get_current_frame () == frame) - read_memory ((CORE_ADDR)&((struct rwindow *) - (read_register (SP_REGNUM)))->rw_in[7], - &prev_pc, sizeof (CORE_ADDR)); - else - /* Wouldn't this always work? */ - read_memory ((CORE_ADDR)&((struct rwindow *)(frame->bottom))->rw_in[7], - &prev_pc, - sizeof (CORE_ADDR)); - - return PC_ADJUST (prev_pc); -} - -/* - * Since an individual frame in the frame cache is defined by two - * arguments (a frame pointer and a stack pointer), we need two - * arguments to get info for an arbitrary stack frame. This routine - * takes two arguments and makes the cached frames look as if these - * two arguments defined a frame on the cache. This allows the rest - * of info frame to extract the important arguments without - * difficulty. - */ -FRAME -setup_arbitrary_frame (frame, stack) - FRAME_ADDR frame, stack; -{ - FRAME fid = create_new_frame (frame, 0); - - if (!fid) - fatal ("internal: create_new_frame returned invalid frame id"); - - fid->bottom = stack; - fid->pc = FRAME_SAVED_PC (fid); - return fid; -} - -/* This code was written by Gary Beihl (beihl@mcc.com). - It was modified by Michael Tiemann (tiemann@corto.inria.fr). */ - -/* - * This routine appears to be passed a size by which to increase the - * stack. It then executes a save instruction in the inferior to - * increase the stack by this amount. Only the register window system - * should be affected by this; the program counter & etc. will not be. - * - * This instructions used for this purpose are: - * - * sethi %hi(0x0),g1 * - * add g1,0x1ee0,g1 * - * save sp,g1,sp - * sethi %hi(0x0),g1 * - * add g1,0x1ee0,g1 * - * t g0,0x1,o0 - * sethi %hi(0x0),g0 (nop) - * - * I presume that these set g1 to be the negative of the size, do a - * save (putting the stack pointer at sp - size) and restore the - * original contents of g1. A * indicates that the actual value of - * the instruction is modified below. - */ -static int save_insn_opcodes[] = { - 0x03000000, 0x82007ee0, 0x9de38001, 0x03000000, - 0x82007ee0, 0x91d02001, 0x01000000 }; - -/* Neither do_save_insn or do_restore_insn save stack configuration - (current_frame, etc), - since the stack is in an indeterminate state through the call to - each of them. That responsibility of the routine which calls them. */ - -static void -do_save_insn (size) - int size; -{ - int g1 = read_register (G1_REGNUM); - CORE_ADDR sp = read_register (SP_REGNUM); - CORE_ADDR pc = read_register (PC_REGNUM); - CORE_ADDR npc = read_register (NPC_REGNUM); - CORE_ADDR fake_pc = sp - sizeof (save_insn_opcodes); - struct inferior_status inf_status; - - save_inferior_status (&inf_status, 0); /* Don't restore stack info */ - /* - * See above. - */ - save_insn_opcodes[0] = 0x03000000 | ((-size >> 10) & 0x3fffff); - save_insn_opcodes[1] = 0x82006000 | (-size & 0x3ff); - save_insn_opcodes[3] = 0x03000000 | ((g1 >> 10) & 0x3fffff); - save_insn_opcodes[4] = 0x82006000 | (g1 & 0x3ff); - write_memory (fake_pc, (char *)save_insn_opcodes, sizeof (save_insn_opcodes)); - - clear_proceed_status (); - stop_after_trap = 1; - proceed (fake_pc, 0, 0); - - write_register (PC_REGNUM, pc); - write_register (NPC_REGNUM, npc); - restore_inferior_status (&inf_status); -} - -/* - * This routine takes a program counter value. It restores the - * register window system to the frame above the current one. - * THIS ROUTINE CLOBBERS PC AND NPC IN THE TARGET! - */ - -/* The following insns translate to: - - restore %g0,%g0,%g0 - t %g0,1 - sethi %hi(0),%g0 */ - -static int restore_insn_opcodes[] = { 0x81e80000, 0x91d02001, 0x01000000 }; - -static void -do_restore_insn () -{ - CORE_ADDR sp = read_register (SP_REGNUM); - CORE_ADDR fake_pc = sp - sizeof (restore_insn_opcodes); - struct inferior_status inf_status; - - save_inferior_status (&inf_status, 0); /* Don't restore stack info */ - - write_memory (fake_pc, (char *)restore_insn_opcodes, - sizeof (restore_insn_opcodes)); - - clear_proceed_status (); - stop_after_trap = 1; - proceed (fake_pc, 0, 0); - - restore_inferior_status (&inf_status); -} - -/* Given a pc value, skip it forward past the function prologue by - disassembling instructions that appear to be a prologue. - - If FRAMELESS_P is set, we are only testing to see if the function - is frameless. This allows a quicker answer. - - This routine should be more specific in its actions; making sure - that it uses the same register in the initial prologue section. */ -CORE_ADDR -skip_prologue (start_pc, frameless_p) - CORE_ADDR start_pc; - int frameless_p; -{ - union - { - unsigned long int code; - struct - { - unsigned int op:2; - unsigned int rd:5; - unsigned int op2:3; - unsigned int imm22:22; - } sethi; - struct - { - unsigned int op:2; - unsigned int rd:5; - unsigned int op3:6; - unsigned int rs1:5; - unsigned int i:1; - unsigned int simm13:13; - } add; - int i; - } x; - int dest = -1; - CORE_ADDR pc = start_pc; - - x.i = read_memory_integer (pc, 4); - - /* Recognize the `sethi' insn and record its destination. */ - if (x.sethi.op == 0 && x.sethi.op2 == 4) - { - dest = x.sethi.rd; - pc += 4; - x.i = read_memory_integer (pc, 4); - } - - /* Recognize an add immediate value to register to either %g1 or - the destination register recorded above. Actually, this might - well recognize several different arithmetic operations. - It doesn't check that rs1 == rd because in theory "sub %g0, 5, %g1" - followed by "save %sp, %g1, %sp" is a valid prologue (Not that - I imagine any compiler really does that, however). */ - if (x.add.op == 2 && x.add.i && (x.add.rd == 1 || x.add.rd == dest)) - { - pc += 4; - x.i = read_memory_integer (pc, 4); - } - - /* This recognizes any SAVE insn. But why do the XOR and then - the compare? That's identical to comparing against 60 (as long - as there isn't any sign extension). */ - if (x.add.op == 2 && (x.add.op3 ^ 32) == 28) - { - pc += 4; - if (frameless_p) /* If the save is all we care about, */ - return pc; /* return before doing more work */ - x.i = read_memory_integer (pc, 4); - } - else - { - /* Without a save instruction, it's not a prologue. */ - return start_pc; - } - - /* Now we need to recognize stores into the frame from the input - registers. This recognizes all non alternate stores of input - register, into a location offset from the frame pointer. */ - while (x.add.op == 3 - && (x.add.op3 & 0x3c) == 4 /* Store, non-alternate. */ - && (x.add.rd & 0x18) == 0x18 /* Input register. */ - && x.add.i /* Immediate mode. */ - && x.add.rs1 == 30 /* Off of frame pointer. */ - /* Into reserved stack space. */ - && x.add.simm13 >= 0x44 - && x.add.simm13 < 0x5b) - { - pc += 4; - x.i = read_memory_integer (pc, 4); - } - return pc; -} - -/* Check instruction at ADDR to see if it is an annulled branch. - All other instructions will go to NPC or will trap. - Set *TARGET if we find a canidate branch; set to zero if not. */ - -branch_type -isannulled (instruction, addr, target) - long instruction; - CORE_ADDR addr, *target; -{ - branch_type val = not_branch; - long int offset; /* Must be signed for sign-extend. */ - union - { - unsigned long int code; - struct - { - unsigned int op:2; - unsigned int a:1; - unsigned int cond:4; - unsigned int op2:3; - unsigned int disp22:22; - } b; - } insn; - - *target = 0; - insn.code = instruction; - - if (insn.b.op == 0 - && (insn.b.op2 == 2 || insn.b.op2 == 6 || insn.b.op2 == 7)) - { - if (insn.b.cond == 8) - val = insn.b.a ? baa : ba; - else - val = insn.b.a ? bicca : bicc; - offset = 4 * ((int) (insn.b.disp22 << 10) >> 10); - *target = addr + offset; - } - - return val; -} - -/* sparc_frame_find_saved_regs () - - Stores, 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. - - Note that on register window machines, we are currently making the - assumption that window registers are being saved somewhere in the - frame in which they are being used. If they are stored in an - inferior frame, find_saved_register will break. - - On the Sun 4, the only time all registers are saved is when - a dummy frame is involved. Otherwise, the only saved registers - are the LOCAL and IN registers which are saved as a result - of the "save/restore" opcodes. This condition is determined - by address rather than by value. - - The "pc" is not stored in a frame on the SPARC. (What is stored - is a return address minus 8.) sparc_pop_frame knows how to - deal with that. Other routines might or might not. - - See tm-sparc.h (PUSH_FRAME and friends) for CRITICAL information - about how this works. */ - -void -sparc_frame_find_saved_regs (fi, saved_regs_addr) - struct frame_info *fi; - struct frame_saved_regs *saved_regs_addr; -{ - register int regnum; - FRAME_ADDR frame = read_register (FP_REGNUM); - FRAME fid = FRAME_INFO_ID (fi); - - if (!fid) - fatal ("Bad frame info struct in FRAME_FIND_SAVED_REGS"); - - bzero (saved_regs_addr, sizeof (*saved_regs_addr)); - - /* Old test. - if (fi->pc >= frame - CALL_DUMMY_LENGTH - 0x140 - && fi->pc <= frame) */ - - if (fi->pc >= (fi->bottom ? fi->bottom : - read_register (SP_REGNUM)) - && fi->pc <= FRAME_FP(fi)) - { - /* Dummy frame. All but the window regs are in there somewhere. */ - for (regnum = G1_REGNUM; regnum < G1_REGNUM+7; regnum++) - saved_regs_addr->regs[regnum] = - frame + (regnum - G0_REGNUM) * 4 - 0xa0; - for (regnum = I0_REGNUM; regnum < I0_REGNUM+8; regnum++) - saved_regs_addr->regs[regnum] = - frame + (regnum - I0_REGNUM) * 4 - 0xc0; - for (regnum = FP0_REGNUM; regnum < FP0_REGNUM + 32; regnum++) - saved_regs_addr->regs[regnum] = - frame + (regnum - FP0_REGNUM) * 4 - 0x80; - for (regnum = Y_REGNUM; regnum < NUM_REGS; regnum++) - saved_regs_addr->regs[regnum] = - frame + (regnum - Y_REGNUM) * 4 - 0xe0; - frame = fi->bottom ? - fi->bottom : read_register (SP_REGNUM); - } - else - { - /* Normal frame. Just Local and In registers */ - frame = fi->bottom ? - fi->bottom : read_register (SP_REGNUM); - for (regnum = L0_REGNUM; regnum < L0_REGNUM+16; regnum++) - saved_regs_addr->regs[regnum] = frame + (regnum-L0_REGNUM) * 4; - } - if (fi->next) - { - /* Pull off either the next frame pointer or the stack pointer */ - FRAME_ADDR next_next_frame = - (fi->next->bottom ? - fi->next->bottom : - read_register (SP_REGNUM)); - for (regnum = O0_REGNUM; regnum < O0_REGNUM+8; regnum++) - saved_regs_addr->regs[regnum] = next_next_frame + regnum * 4; - } - /* Otherwise, whatever we would get from ptrace(GETREGS) is accurate */ - saved_regs_addr->regs[SP_REGNUM] = FRAME_FP (fi); -} - -/* Push an empty stack frame, and record in it the current PC, regs, etc. - - Note that the write's are of registers in the context of the newly - pushed frame. Thus the the fp*'s, the g*'s, the i*'s, and - the randoms, of the new frame, are being saved. The locals and outs - are new; they don't need to be saved. The i's and l's of - the last frame were saved by the do_save_insn in the register - file (now on the stack, since a context switch happended imm after). - - The return pointer register %i7 does not have - the pc saved into it (return from this frame will be accomplished - by a POP_FRAME). In fact, we must leave it unclobbered, since we - must preserve it in the calling routine except across call instructions. */ - -/* Definitely see tm-sparc.h for more doc of the frame format here. */ - -void -sparc_push_dummy_frame () -{ - CORE_ADDR fp; - char register_temp[REGISTER_BYTES]; - - do_save_insn (0x140); /* FIXME where does this value come from? */ - fp = read_register (FP_REGNUM); - - read_register_bytes (REGISTER_BYTE (FP0_REGNUM), register_temp, 32 * 4); - write_memory (fp - 0x80, register_temp, 32 * 4); - - read_register_bytes (REGISTER_BYTE (G0_REGNUM), register_temp, 8 * 4); - write_memory (fp - 0xa0, register_temp, 8 * 4); - - read_register_bytes (REGISTER_BYTE (I0_REGNUM), register_temp, 8 * 4); - write_memory (fp - 0xc0, register_temp, 8 * 4); - - /* Y, PS, WIM, TBR, PC, NPC, FPS, CPS regs */ - read_register_bytes (REGISTER_BYTE (Y_REGNUM), register_temp, 8 * 4); - write_memory (fp - 0xe0, register_temp, 8 * 4); -} - -/* Discard from the stack the innermost frame, restoring all saved registers. - - Note that the values stored in fsr by get_frame_saved_regs are *in - the context of the called frame*. What this means is that the i - regs of fsr must be restored into the o regs of the (calling) frame that - we pop into. We don't care about the output regs of the calling frame, - since unless it's a dummy frame, it won't have any output regs in it. - - We never have to bother with %l (local) regs, since the called routine's - locals get tossed, and the calling routine's locals are already saved - on its stack. */ - -/* Definitely see tm-sparc.h for more doc of the frame format here. */ - -void -sparc_pop_frame () -{ - register FRAME frame = get_current_frame (); - register CORE_ADDR pc; - struct frame_saved_regs fsr; - struct frame_info *fi; - char raw_buffer[REGISTER_BYTES]; - - fi = get_frame_info (frame); - get_frame_saved_regs (fi, &fsr); - do_restore_insn (); - if (fsr.regs[FP0_REGNUM]) - { - read_memory (fsr.regs[FP0_REGNUM], raw_buffer, 32 * 4); - write_register_bytes (REGISTER_BYTE (FP0_REGNUM), raw_buffer, 32 * 4); - } - if (fsr.regs[G1_REGNUM]) - { - read_memory (fsr.regs[G1_REGNUM], raw_buffer, 7 * 4); - write_register_bytes (REGISTER_BYTE (G1_REGNUM), raw_buffer, 7 * 4); - } - if (fsr.regs[I0_REGNUM]) - { - read_memory (fsr.regs[I0_REGNUM], raw_buffer, 8 * 4); - write_register_bytes (REGISTER_BYTE (O0_REGNUM), raw_buffer, 8 * 4); - } - if (fsr.regs[PS_REGNUM]) - write_register (PS_REGNUM, read_memory_integer (fsr.regs[PS_REGNUM], 4)); - if (fsr.regs[Y_REGNUM]) - write_register (Y_REGNUM, read_memory_integer (fsr.regs[Y_REGNUM], 4)); - if (fsr.regs[PC_REGNUM]) - { - /* Explicitly specified PC (and maybe NPC) -- just restore them. */ - write_register (PC_REGNUM, read_memory_integer (fsr.regs[PC_REGNUM], 4)); - if (fsr.regs[NPC_REGNUM]) - write_register (NPC_REGNUM, - read_memory_integer (fsr.regs[NPC_REGNUM], 4)); - } - else if (fsr.regs[I7_REGNUM]) - { - /* Return address in %i7 -- adjust it, then restore PC and NPC from it */ - pc = PC_ADJUST (read_memory_integer (fsr.regs[I7_REGNUM], 4)); - write_register (PC_REGNUM, pc); - write_register (NPC_REGNUM, pc + 4); - } - flush_cached_frames (); - set_current_frame ( create_new_frame (read_register (FP_REGNUM), - read_pc ())); -} - -/* On the Sun 4 under SunOS, the compile will leave a fake insn which - encodes the structure size being returned. If we detect such - a fake insn, step past it. */ - -CORE_ADDR -sparc_pc_adjust(pc) - CORE_ADDR pc; -{ - long insn; - int err; - - err = target_read_memory (pc + 8, (char *)&insn, sizeof(long)); - SWAP_TARGET_AND_HOST (&insn, sizeof(long)); - if ((err == 0) && (insn & 0xfffffe00) == 0) - return pc+12; - else - return pc+8; -} - - -/* Structure of SPARC extended floating point numbers. - This information is not currently used by GDB, since no current SPARC - implementations support extended float. */ - -const struct ext_format ext_format_sparc[] = { -/* tot sbyte smask expbyte manbyte */ - { 16, 0, 0x80, 0,1, 4,8 }, /* sparc */ -}; diff --git a/gdb/sparc-xdep.c b/gdb/sparc-xdep.c deleted file mode 100644 index b09dbe888ae..00000000000 --- a/gdb/sparc-xdep.c +++ /dev/null @@ -1,305 +0,0 @@ -/* Machine-dependent code which would otherwise be in inflow.c and core.c, - for GDB, the GNU debugger, for SPARC host systems. - - Copyright (C) 1986, 1987, 1989, 1990 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "defs.h" -#include "tm-sparc.h" -#include "param-no-tm.h" -#include "inferior.h" -#include "target.h" - -#include -#include /* For L_SET */ - -#include -#include - -#include "gdbcore.h" -#include - -extern char register_valid[]; - -/* We don't store all registers immediately when requested, since they - get sent over in large chunks anyway. Instead, we accumulate most - of the changes and send them over once. "deferred_stores" keeps - track of which sets of registers we have locally-changed copies of, - so we only need send the groups that have changed. */ - -#define INT_REGS 1 -#define STACK_REGS 2 -#define FP_REGS 4 - -int deferred_stores = 0; /* Cumulates stores we want to do eventually. */ - -/* Fetch one or more registers from the inferior. REGNO == -1 to get - them all. We actually fetch more than requested, when convenient, - marking them as valid so we won't fetch them again. */ -void -fetch_inferior_registers (regno) - int regno; -{ - struct regs inferior_registers; - struct fp_status inferior_fp_registers; - int i; - - /* We should never be called with deferred stores, because a prerequisite - for writing regs is to have fetched them all (PREPARE_TO_STORE), sigh. */ - if (deferred_stores) abort(); - - DO_DEFERRED_STORES; - - /* Global and Out regs are fetched directly, as well as the control - registers. If we're getting one of the in or local regs, - and the stack pointer has not yet been fetched, - we have to do that first, since they're found in memory relative - to the stack pointer. */ - if (regno < O7_REGNUM /* including -1 */ - || regno >= Y_REGNUM - || (!register_valid[SP_REGNUM] && regno < I7_REGNUM)) - { - if (0 != ptrace (PTRACE_GETREGS, inferior_pid, &inferior_registers)) - perror("ptrace_getregs"); - - registers[REGISTER_BYTE (0)] = 0; - bcopy (&inferior_registers.r_g1, ®isters[REGISTER_BYTE (1)], 15 * REGISTER_RAW_SIZE (G0_REGNUM)); - *(int *)®isters[REGISTER_BYTE (PS_REGNUM)] = inferior_registers.r_ps; - *(int *)®isters[REGISTER_BYTE (PC_REGNUM)] = inferior_registers.r_pc; - *(int *)®isters[REGISTER_BYTE (NPC_REGNUM)] = inferior_registers.r_npc; - *(int *)®isters[REGISTER_BYTE (Y_REGNUM)] = inferior_registers.r_y; - - for (i = G0_REGNUM; i <= O7_REGNUM; i++) - register_valid[i] = 1; - register_valid[Y_REGNUM] = 1; - register_valid[PS_REGNUM] = 1; - register_valid[PC_REGNUM] = 1; - register_valid[NPC_REGNUM] = 1; - /* If we don't set these valid, read_register_bytes() rereads - all the regs every time it is called! FIXME. */ - register_valid[WIM_REGNUM] = 1; /* Not true yet, FIXME */ - register_valid[TBR_REGNUM] = 1; /* Not true yet, FIXME */ - register_valid[FPS_REGNUM] = 1; /* Not true yet, FIXME */ - register_valid[CPS_REGNUM] = 1; /* Not true yet, FIXME */ - } - - /* Floating point registers */ - if (regno == -1 || (regno >= FP0_REGNUM && regno <= FP0_REGNUM + 31)) - { - if (0 != ptrace (PTRACE_GETFPREGS, inferior_pid, &inferior_fp_registers)) - perror("ptrace_getfpregs"); - bcopy (&inferior_fp_registers, ®isters[REGISTER_BYTE (FP0_REGNUM)], - sizeof inferior_fp_registers.fpu_fr); - /* bcopy (&inferior_fp_registers.Fpu_fsr, - ®isters[REGISTER_BYTE (FPS_REGNUM)], - sizeof (FPU_FSR_TYPE)); FIXME??? -- gnu@cyg */ - for (i = FP0_REGNUM; i <= FP0_REGNUM+31; i++) - register_valid[i] = 1; - register_valid[FPS_REGNUM] = 1; - } - - /* These regs are saved on the stack by the kernel. Only read them - all (16 ptrace calls!) if we really need them. */ - if (regno == -1) - { - target_xfer_memory (*(CORE_ADDR*)®isters[REGISTER_BYTE (SP_REGNUM)], - ®isters[REGISTER_BYTE (L0_REGNUM)], - 16*REGISTER_RAW_SIZE (L0_REGNUM), 0); - for (i = L0_REGNUM; i <= I7_REGNUM; i++) - register_valid[i] = 1; - } - else if (regno >= L0_REGNUM && regno <= I7_REGNUM) - { - CORE_ADDR sp = *(CORE_ADDR*)®isters[REGISTER_BYTE (SP_REGNUM)]; - i = REGISTER_BYTE (regno); - if (register_valid[regno]) - printf("register %d valid and read\n", regno); - target_xfer_memory (sp + i - REGISTER_BYTE (L0_REGNUM), - ®isters[i], REGISTER_RAW_SIZE (regno), 0); - register_valid[regno] = 1; - } -} - -/* Store our register values back into the inferior. - If REGNO is -1, do this for all registers. - Otherwise, REGNO specifies which register (so we can save time). */ - -int -store_inferior_registers (regno) - int regno; -{ - struct regs inferior_registers; - struct fp_status inferior_fp_registers; - int wanna_store = INT_REGS + STACK_REGS + FP_REGS; - - /* 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 - wanna_store = STACK_REGS; - } - - /* See if we're forcing the stores to happen now, or deferring. */ - if (regno == -2) - { - wanna_store = deferred_stores; - deferred_stores = 0; - } - else - { - if (wanna_store == STACK_REGS) - { - /* Fall through and just store one stack reg. If we deferred - it, we'd have to store them all, or remember more info. */ - } - else - { - deferred_stores |= wanna_store; - return 0; - } - } - - if (wanna_store & STACK_REGS) - { - CORE_ADDR sp = *(CORE_ADDR *)®isters[REGISTER_BYTE (SP_REGNUM)]; - - if (regno < 0 || regno == SP_REGNUM) - { - if (!register_valid[L0_REGNUM+5]) abort(); - target_xfer_memory (sp, - ®isters[REGISTER_BYTE (L0_REGNUM)], - 16*REGISTER_RAW_SIZE (L0_REGNUM), 1); - } - else - { - if (!register_valid[regno]) abort(); - target_xfer_memory (sp + REGISTER_BYTE (regno) - REGISTER_BYTE (L0_REGNUM), - ®isters[REGISTER_BYTE (regno)], - REGISTER_RAW_SIZE (regno), 1); - } - - } - - if (wanna_store & INT_REGS) - { - if (!register_valid[G1_REGNUM]) abort(); - - bcopy (®isters[REGISTER_BYTE (G1_REGNUM)], - &inferior_registers.r_g1, 15 * REGISTER_RAW_SIZE (G1_REGNUM)); - - inferior_registers.r_ps = - *(int *)®isters[REGISTER_BYTE (PS_REGNUM)]; - inferior_registers.r_pc = - *(int *)®isters[REGISTER_BYTE (PC_REGNUM)]; - inferior_registers.r_npc = - *(int *)®isters[REGISTER_BYTE (NPC_REGNUM)]; - inferior_registers.r_y = - *(int *)®isters[REGISTER_BYTE (Y_REGNUM)]; - - if (0 != ptrace (PTRACE_SETREGS, inferior_pid, &inferior_registers)) - perror("ptrace_setregs"); - } - - if (wanna_store & FP_REGS) - { - if (!register_valid[FP0_REGNUM+9]) abort(); - bcopy (®isters[REGISTER_BYTE (FP0_REGNUM)], - &inferior_fp_registers, - sizeof inferior_fp_registers.fpu_fr); - -/* bcopy (®isters[REGISTER_BYTE (FPS_REGNUM)], - &inferior_fp_registers.Fpu_fsr, - sizeof (FPU_FSR_TYPE)); -****/ - if (0 != - ptrace (PTRACE_SETFPREGS, inferior_pid, &inferior_fp_registers)) - perror("ptrace_setfpregs"); - } - return 0; -} - -void -fetch_core_registers (core_reg_sect, core_reg_size, which) - char *core_reg_sect; - unsigned core_reg_size; - int which; -{ - - if (which == 0) { - - /* Integer registers */ - -#define gregs ((struct regs *)core_reg_sect) - /* G0 *always* holds 0. */ - *(int *)®isters[REGISTER_BYTE (0)] = 0; - - /* The globals and output registers. */ - bcopy (&gregs->r_g1, - ®isters[REGISTER_BYTE (G1_REGNUM)], - 15 * REGISTER_RAW_SIZE (G1_REGNUM)); - *(int *)®isters[REGISTER_BYTE (PS_REGNUM)] = gregs->r_ps; - *(int *)®isters[REGISTER_BYTE (PC_REGNUM)] = gregs->r_pc; - *(int *)®isters[REGISTER_BYTE (NPC_REGNUM)] = gregs->r_npc; - *(int *)®isters[REGISTER_BYTE (Y_REGNUM)] = gregs->r_y; - - /* My best guess at where to get the locals and input - registers is exactly where they usually are, right above - the stack pointer. If the core dump was caused by a bus error - from blowing away the stack pointer (as is possible) then this - won't work, but it's worth the try. */ - { - int sp; - - sp = *(int *)®isters[REGISTER_BYTE (SP_REGNUM)]; - if (0 != target_read_memory (sp, ®isters[REGISTER_BYTE (L0_REGNUM)], - 16 * REGISTER_RAW_SIZE (L0_REGNUM))) - { - /* fprintf so user can still use gdb */ - fprintf (stderr, - "Couldn't read input and local registers from core file\n"); - } - } - } else if (which == 2) { - - /* Floating point registers */ - -#define fpuregs ((struct fpu *) core_reg_sect) - if (core_reg_size >= sizeof (struct fpu)) - { - bcopy (fpuregs->fpu_regs, - ®isters[REGISTER_BYTE (FP0_REGNUM)], - sizeof (fpuregs->fpu_regs)); - bcopy (&fpuregs->fpu_fsr, - ®isters[REGISTER_BYTE (FPS_REGNUM)], - sizeof (FPU_FSR_TYPE)); - } - else - fprintf (stderr, "Couldn't read float regs from core file\n"); - } -} diff --git a/gdb/stab.def b/gdb/stab.def deleted file mode 100755 index 58364e14229..00000000000 --- a/gdb/stab.def +++ /dev/null @@ -1,182 +0,0 @@ -/* Table of DBX symbol codes for the GNU system. - Copyright (C) 1988 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Global variable. Only the name is significant. - To find the address, look in the corresponding external symbol. */ -__define_stab (N_GSYM, 0x20, "GSYM") - -/* Function name for BSD Fortran. Only the name is significant. - To find the address, look in the corresponding external symbol. */ -__define_stab (N_FNAME, 0x22, "FNAME") - -/* Function name or text-segment variable for C. Value is its address. - Desc is supposedly starting line number, but GCC doesn't set it - and DBX seems not to miss it. */ -__define_stab (N_FUN, 0x24, "FUN") - -/* Data-segment variable with internal linkage. Value is its address. */ -__define_stab (N_STSYM, 0x26, "STSYM") - -/* BSS-segment variable with internal linkage. Value is its address. */ -__define_stab (N_LCSYM, 0x28, "LCSYM") - -/* Name of main routine. Only the name is significant. - This is not used in C. */ -__define_stab (N_MAIN, 0x2a, "MAIN") - -/* Register variable. Value is number of register. */ -__define_stab (N_RSYM, 0x40, "RSYM") - -/* Structure or union element. Value is offset in the structure. */ -__define_stab (N_SSYM, 0x60, "SSYM") - -/* Parameter variable. Value is offset from argument pointer. - (On most machines the argument pointer is the same as the frame pointer. */ -__define_stab (N_PSYM, 0xa0, "PSYM") - -/* Automatic variable in the stack. Value is offset from frame pointer. - Also used for type descriptions. */ -__define_stab (N_LSYM, 0x80, "LSYM") - -/* Alternate entry point. Value is its address. */ -__define_stab (N_ENTRY, 0xa4, "ENTRY") - -/* Name of main source file. - Value is starting text address of the compilation. */ -__define_stab (N_SO, 0x64, "SO") - -/* Name of sub-source file. - Value is starting text address of the compilation. */ -__define_stab (N_SOL, 0x84, "SOL") - -/* Line number in text segment. Desc is the line number; - value is corresponding address. */ -__define_stab (N_SLINE, 0x44, "SLINE") -/* Similar, for data segment. */ -__define_stab (N_DSLINE, 0x66, "DSLINE") -/* Similar, for bss segment. */ -__define_stab (N_BSLINE, 0x68, "BSLINE") - -/* Beginning of an include file. Only Sun uses this. - In an object file, only the name is significant. - The Sun linker puts data into some of the other fields. */ -__define_stab (N_BINCL, 0x82, "BINCL") -/* End of an include file. No name. - These two act as brackets around the file's output. - In an object file, there is no significant data in this entry. - The Sun linker puts data into some of the fields. */ -__define_stab (N_EINCL, 0xa2, "EINCL") -/* Place holder for deleted include file. - This appears only in output from the Sun linker. */ -__define_stab (N_EXCL, 0xc2, "EXCL") - -/* Beginning of lexical block. - The desc is the nesting level in lexical blocks. - The value is the address of the start of the text for the block. - The variables declared inside the block *precede* the N_LBRAC symbol. */ -__define_stab (N_LBRAC, 0xc0, "LBRAC") -/* End of a lexical block. Desc matches the N_LBRAC's desc. - The value is the address of the end of the text for the block. */ -__define_stab (N_RBRAC, 0xe0, "RBRAC") - -/* Begin named common block. Only the name is significant. */ -__define_stab (N_BCOMM, 0xe2, "BCOMM") -/* Begin named common block. Only the name is significant - (and it should match the N_BCOMM). */ -__define_stab (N_ECOMM, 0xe4, "ECOMM") -/* End common (local name): value is address. - I'm not sure how this is used. */ -__define_stab (N_ECOML, 0xe8, "ECOML") -/* Second symbol entry containing a length-value for the preceding entry. - The value is the length. */ -__define_stab (N_LENG, 0xfe, "LENG") - -/* Global symbol in Pascal. - Supposedly the value is its line number; I'm skeptical. */ -__define_stab (N_PC, 0x30, "PC") - -/* Modula-2 compilation unit. Can someone say what info it contains? */ -__define_stab (N_M2C, 0x42, "M2C") -/* Modula-2 scope information. Can someone say what info it contains? */ -__define_stab (N_SCOPE, 0xc4, "SCOPE") - -/* Sun's source-code browser stabs. ?? Don't know what the fields are. - Supposedly the field is "path to associated .cb file". */ -__define_stab (N_BROWS, 0x48, "BROWS") - -/* GNU C++ exception stabs. */ - -/* GNU C++ exception variable. Name is variable name. */ -__define_stab (N_EHDECL, 0x50, "EHDECL") - -/* GNU C++ `catch' clause. Value is its address. Desc is nonzero if - this entry is immediately followed by a CAUGHT stab saying what exception - was caught. Multiple CAUGHT stabs means that multiple exceptions - can be caught here. If Desc is 0, it means all exceptions are caught - here. */ -__define_stab (N_CATCH, 0x54, "CATCH") - -/* These STAB's are used on Gould systems for Non-Base register symbols - or something like that. FIXME. I have assigned the values at random - since I don't have a Gould here. Fixups from Gould folk welcome... */ -__define_stab (N_NBTEXT, 0xF0, "NBTEXT") -__define_stab (N_NBDATA, 0xF2, "NBDATA") -__define_stab (N_NBBSS, 0xF4, "NBBSS") -__define_stab (N_NBSTS, 0xF6, "NBSTS") -__define_stab (N_NBLCS, 0xF8, "NBLCS") -__define_stab (N_NSYMS, 0xFA, "NSYMS") - -/* The above information, in matrix format. - - STAB MATRIX - _________________________________________________ - | 00 - 1F are not dbx stab symbols | - | Entries with bits 01 set are external symbols | - | N_UNDEF | N_ABS | N_TEXT | N_DATA | - | N_BSS | N_COMM | | N_FN | - |_______________________________________________| - | 20 GSYM | 22 FNAME | 24 FUN | 26 STSYM | - | 28 LCSYM | 2A MAIN | 2C | 2E | - | 30 PC | 32 | 34 | 36 | - | 38 | 3A | 3C | 3E | - | 40 RSYM | 42 M2C | 44 SLINE | 46 | - | 48 BROWS | 4A | 4C | 4E | - | 50 EHDECL | 52 | 54 CATCH | 56 | - | 58 | 5A | 5C | 5E | - | 60 SSYM | 62 | 64 SO | 66 DSLINE | - | 68 BSLINE | 6A | 6C | 6E | - | 70 | 72 | 74 | 76 | - | 78 | 7A | 7C | 7E | - | 80 LSYM | 82 BINCL | 84 SOL | 86 | - | 88 | 8A | 8C | 8E | - | 90 | 92 | 94 | 96 | - | 98 | 9A | 9C | 9E | - | A0 PSYM | A2 EINCL | A4 ENTRY | A6 | - | A8 | AA | AC | AE | - | B0 | B2 | B4 | B6 | - | B8 | BA | BC | BE | - | C0 LBRAC | C2 EXCL | C4 SCOPE | C6 | - | C8 | CA | CC | CE | - | D0 | D2 | D4 | D6 | - | D8 | DA | DC | DE | - | E0 RBRAC | E2 BCOMM | E4 ECOMM | E6 | - | E8 ECOML | EA | EC | EE | - | F0 | F2 | F4 | F6 | - | F8 | FA | FC | FE LENG | - +-----------------------------------------------+ - -*/ diff --git a/gdb/stack.c b/gdb/stack.c deleted file mode 100644 index 6153650327a..00000000000 --- a/gdb/stack.c +++ /dev/null @@ -1,1178 +0,0 @@ -/* Print and select stack frames for GDB, the GNU debugger. - Copyright (C) 1986, 1987, 1989, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include - -#include "defs.h" -#include "param.h" -#include "language.h" -#include "symtab.h" -#include "frame.h" -#include "gdbcmd.h" -#include "value.h" -#include "gdbcore.h" -#include "target.h" -#include "breakpoint.h" - -extern int addressprint; /* Print addresses, or stay symbolic only? */ -extern int info_verbose; /* Verbosity of symbol reading msgs */ -extern int lines_to_list; /* # of lines "list" command shows by default */ -extern char *reg_names[]; /* Names of registers */ - -/* Thie "selected" stack frame is used by default for local and arg access. - May be zero, for no selected frame. */ - -FRAME selected_frame; - -/* Level of the selected frame: - 0 for innermost, 1 for its caller, ... - or -1 for frame specified by address with no defined level. */ - -int selected_frame_level; - -/* Nonzero means print the full filename and linenumber - when a frame is printed, and do so in a format programs can parse. */ - -int frame_file_full_name = 0; - -void print_frame_info (); - -/* Print a stack frame briefly. FRAME should be the frame id - and LEVEL should be its level in the stack (or -1 for level not defined). - This prints the level, the function executing, the arguments, - and the file name and line number. - If the pc is not at the beginning of the source line, - the actual pc is printed at the beginning. - - If SOURCE is 1, print the source line as well. - If SOURCE is -1, print ONLY the source line. */ - -void -print_stack_frame (frame, level, source) - FRAME frame; - int level; - int source; -{ - struct frame_info *fi; - - fi = get_frame_info (frame); - - print_frame_info (fi, level, source, 1); -} - -void -print_frame_info (fi, level, source, args) - struct frame_info *fi; - register int level; - int source; - int args; -{ - struct symtab_and_line sal; - struct symbol *func; - register char *funname = 0; - int numargs; - -#if 0 /* Symbol reading is fast enough now */ - struct partial_symtab *pst; - - /* Don't give very much information if we haven't readin the - symbol table yet. */ - pst = find_pc_psymtab (fi->pc); - if (pst && !pst->readin) - { - /* Abbreviated information. */ - char *fname; - - if (!find_pc_partial_function (fi->pc, &fname, 0)) - fname = "??"; - - printf_filtered ("#%-2d ", level); - if (addressprint) - printf_filtered ("%s in ", local_hex_string(fi->pc)); - - fputs_demangled (fname, stdout, -1); - fputs_filtered (" (...)\n", stdout); - - return; - } -#endif - - sal = find_pc_line (fi->pc, fi->next_frame); - func = find_pc_function (fi->pc); - if (func) - { - /* In certain pathological cases, the symtabs give the wrong - function (when we are in the first function in a file which - is compiled without debugging symbols, the previous function - is compiled with debugging symbols, and the "foo.o" symbol - that is supposed to tell us where the file with debugging symbols - ends has been truncated by ar because it is longer than 15 - characters). - - So look in the misc_function_vector as well, and if it comes - up with a larger address for the function use that instead. - I don't think this can ever cause any problems; - there shouldn't be any - misc_function_vector symbols in the middle of a function. */ - int misc_index = find_pc_misc_function (fi->pc); - if (misc_index >= 0 - && (misc_function_vector[misc_index].address - > BLOCK_START (SYMBOL_BLOCK_VALUE (func)))) - { - /* In this case we have no way of knowing the source file - and line number, so don't print them. */ - sal.symtab = 0; - /* We also don't know anything about the function besides - its address and name. */ - func = 0; - funname = misc_function_vector[misc_index].name; - } - else - funname = SYMBOL_NAME (func); - } - else - { - register int misc_index = find_pc_misc_function (fi->pc); - if (misc_index >= 0) - funname = misc_function_vector[misc_index].name; - } - - if (source >= 0 || !sal.symtab) - { - if (level >= 0) - printf_filtered ("#%-2d ", level); - if (addressprint) - if (fi->pc != sal.pc || !sal.symtab) - printf_filtered ("%s in ", local_hex_string(fi->pc)); - fputs_demangled (funname ? funname : "??", stdout, -1); - wrap_here (" "); - fputs_filtered (" (", stdout); - if (args) - { - FRAME_NUM_ARGS (numargs, fi); - print_frame_args (func, fi, numargs, stdout); - } - printf_filtered (")"); - if (sal.symtab && sal.symtab->filename) - { - wrap_here (" "); - printf_filtered (" at %s:%d", sal.symtab->filename, sal.line); - } - printf_filtered ("\n"); - } - - if ((source != 0) && sal.symtab) - { - int done = 0; - int mid_statement = source < 0 && fi->pc != sal.pc; - if (frame_file_full_name) - done = identify_source_line (sal.symtab, sal.line, mid_statement); - if (!done) - { - if (addressprint && mid_statement) - printf_filtered ("%s\t", local_hex_string(fi->pc)); - print_source_lines (sal.symtab, sal.line, sal.line + 1, 0); - } - current_source_line = max (sal.line - lines_to_list/2, 1); - } - if (source != 0) - set_default_breakpoint (1, fi->pc, sal.symtab, sal.line); - - fflush (stdout); -} - -void flush_cached_frames (); - -#ifdef FRAME_SPECIFICATION_DYADIC -extern FRAME setup_arbitrary_frame (); -#endif - -/* - * Read a frame specification in whatever the appropriate format is. - * Call error() if the specification is in any way invalid (i.e. - * this function never returns NULL). - */ -static FRAME -parse_frame_specification (frame_exp) - char *frame_exp; -{ - int numargs = 0; - int arg1, arg2; - - if (frame_exp) - { - char *addr_string, *p; - struct cleanup *tmp_cleanup; - - while (*frame_exp == ' ') frame_exp++; - for (p = frame_exp; *p && *p != ' '; p++) - ; - - if (*frame_exp) - { - numargs = 1; - addr_string = savestring(frame_exp, p - frame_exp); - - { - tmp_cleanup = make_cleanup (free, addr_string); - arg1 = parse_and_eval_address (addr_string); - do_cleanups (tmp_cleanup); - } - - while (*p == ' ') p++; - - if (*p) - { - numargs = 2; - arg2 = parse_and_eval_address (p); - } - } - } - - switch (numargs) - { - case 0: - if (selected_frame == NULL) - error ("No selected frame."); - return selected_frame; - /* NOTREACHED */ - case 1: - { - int level = arg1; - FRAME fid = find_relative_frame (get_current_frame (), &level); - FRAME tfid; - - if (level == 0) - /* find_relative_frame was successful */ - return fid; - - /* If (s)he specifies the frame with an address, he deserves what - (s)he gets. Still, give the highest one that matches. */ - - for (fid = get_current_frame (); - fid && FRAME_FP (fid) != arg1; - fid = get_prev_frame (fid)) - ; - - if (fid) - while ((tfid = get_prev_frame (fid)) && - (FRAME_FP (tfid) == arg1)) - fid = tfid; - -#ifdef FRAME_SPECIFICATION_DYADIC - if (!fid) - error ("Incorrect number of args in frame specification"); - - return fid; -#else - return create_new_frame (arg1, 0); -#endif - } - /* NOTREACHED */ - case 2: - /* Must be addresses */ -#ifndef FRAME_SPECIFICATION_DYADIC - error ("Incorrect number of args in frame specification"); -#else - return setup_arbitrary_frame (arg1, arg2); -#endif - /* NOTREACHED */ - } - fatal ("Internal: Error in parsing in parse_frame_specification"); - /* NOTREACHED */ -} - -/* FRAME_ARGS_ADDRESS_CORRECT is just like FRAME_ARGS_ADDRESS except - that if it is unsure about the answer, it returns 0 - instead of guessing (this happens on the VAX and i960, for example). - - On most machines, we never have to guess about the args address, - so FRAME_ARGS_ADDRESS{,_CORRECT} are the same. */ -#if !defined (FRAME_ARGS_ADDRESS_CORRECT) -#define FRAME_ARGS_ADDRESS_CORRECT FRAME_ARGS_ADDRESS -#endif - -/* Print verbosely the selected frame or the frame at address ADDR. - This means absolutely all information in the frame is printed. */ - -static void -frame_info (addr_exp) - char *addr_exp; -{ - FRAME frame; - struct frame_info *fi; - struct frame_saved_regs fsr; - struct symtab_and_line sal; - struct symbol *func; - struct symtab *s; - FRAME calling_frame; - int i, count; - char *funname = 0; - - if (!target_has_stack) - error ("No inferior or core file."); - - frame = parse_frame_specification (addr_exp); - if (!frame) - error ("Invalid frame specified."); - - fi = get_frame_info (frame); - sal = find_pc_line (fi->pc, fi->next_frame); - func = get_frame_function (frame); - s = find_pc_symtab(fi->pc); - if (func) - funname = SYMBOL_NAME (func); - else - { - register int misc_index = find_pc_misc_function (fi->pc); - if (misc_index >= 0) - funname = misc_function_vector[misc_index].name; - } - calling_frame = get_prev_frame (frame); - - if (!addr_exp && selected_frame_level >= 0) { - printf_filtered ("Stack level %d, frame at %s:\n", - selected_frame_level, - local_hex_string(FRAME_FP(frame))); - } else { - printf_filtered ("Stack frame at %s:\n", - local_hex_string(FRAME_FP(frame))); - } - printf_filtered (" %s = %s", - reg_names[PC_REGNUM], - local_hex_string(fi->pc)); - - wrap_here (" "); - if (funname) - { - printf_filtered (" in "); - fputs_demangled (funname, stdout, 1); - } - wrap_here (" "); - if (sal.symtab) - printf_filtered (" (%s:%d)", sal.symtab->filename, sal.line); - puts_filtered ("; "); - wrap_here (" "); - printf_filtered ("saved %s %s\n", reg_names[PC_REGNUM], - local_hex_string(FRAME_SAVED_PC (frame))); - if (calling_frame) - printf_filtered (" called by frame at %s", - local_hex_string(FRAME_FP (calling_frame))); - if (fi->next_frame && calling_frame) - puts_filtered (","); - wrap_here (" "); - if (fi->next_frame) - printf_filtered (" caller of frame at %s", local_hex_string(fi->next_frame)); - if (fi->next_frame || calling_frame) - puts_filtered ("\n"); - if (s) - printf_filtered(" source language %s.\n", language_str(s->language)); - - { - /* Address of the argument list for this frame, or 0. */ - CORE_ADDR arg_list = FRAME_ARGS_ADDRESS_CORRECT (fi); - /* Number of args for this frame, or -1 if unknown. */ - int numargs; - - if (arg_list == 0) - printf_filtered (" Arglist at unknown address.\n"); - else - { - printf_filtered (" Arglist at %s,", local_hex_string(arg_list)); - - FRAME_NUM_ARGS (numargs, fi); - if (numargs < 0) - puts_filtered (" args: "); - else if (numargs == 0) - puts_filtered (" no args."); - else if (numargs == 1) - puts_filtered (" 1 arg: "); - else - printf_filtered (" %d args: ", numargs); - print_frame_args (func, fi, numargs, stdout); - puts_filtered ("\n"); - } - } - -#if defined (FRAME_FIND_SAVED_REGS) - get_frame_saved_regs (fi, &fsr); - /* The sp is special; what's returned isn't the save address, but - actually the value of the previous frame's sp. */ - printf_filtered (" Previous frame's sp is %s\n", - local_hex_string(fsr.regs[SP_REGNUM])); - count = 0; - for (i = 0; i < NUM_REGS; i++) - if (fsr.regs[i] && i != SP_REGNUM) - { - if (count == 0) - puts_filtered (" Saved registers:\n "); - else - puts_filtered (","); - wrap_here (" "); - printf_filtered (" %s at %s", reg_names[i], - local_hex_string(fsr.regs[i])); - count++; - } - if (count) - puts_filtered ("\n"); -#endif /* Have FRAME_FIND_SAVED_REGS. */ -} - -#if 0 -/* Set a limit on the number of frames printed by default in a - backtrace. */ - -static int backtrace_limit; - -static void -set_backtrace_limit_command (count_exp, from_tty) - char *count_exp; - int from_tty; -{ - int count = parse_and_eval_address (count_exp); - - if (count < 0) - error ("Negative argument not meaningful as backtrace limit."); - - backtrace_limit = count; -} - -static void -backtrace_limit_info (arg, from_tty) - char *arg; - int from_tty; -{ - if (arg) - error ("\"Info backtrace-limit\" takes no arguments."); - - printf ("Backtrace limit: %d.\n", backtrace_limit); -} -#endif - -/* Print briefly all stack frames or just the innermost COUNT frames. */ - -static void -backtrace_command (count_exp, from_tty) - char *count_exp; - int from_tty; -{ - struct frame_info *fi; - register int count; - register FRAME frame; - register int i; - register FRAME trailing; - register int trailing_level; - - if (!target_has_stack) - error ("No stack."); - - /* The following code must do two things. First, it must - set the variable TRAILING to the frame from which we should start - printing. Second, it must set the variable count to the number - of frames which we should print, or -1 if all of them. */ - trailing = get_current_frame (); - trailing_level = 0; - if (count_exp) - { - count = parse_and_eval_address (count_exp); - if (count < 0) - { - FRAME current; - - count = -count; - - current = trailing; - while (current && count--) - { - QUIT; - current = get_prev_frame (current); - } - - /* Will stop when CURRENT reaches the top of the stack. TRAILING - will be COUNT below it. */ - while (current) - { - QUIT; - trailing = get_prev_frame (trailing); - current = get_prev_frame (current); - trailing_level++; - } - - count = -1; - } - } - else - count = -1; - - if (info_verbose) - { - struct partial_symtab *ps; - - /* Read in symbols for all of the frames. Need to do this in - a separate pass so that "Reading in symbols for xxx" messages - don't screw up the appearance of the backtrace. Also - if people have strong opinions against reading symbols for - backtrace this may have to be an option. */ - i = count; - for (frame = trailing; - frame != NULL && i--; - frame = get_prev_frame (frame)) - { - QUIT; - fi = get_frame_info (frame); - ps = find_pc_psymtab (fi->pc); - if (ps) - (void) PSYMTAB_TO_SYMTAB (ps); /* Force syms to come in */ - } - } - - for (i = 0, frame = trailing; - frame && count--; - i++, frame = get_prev_frame (frame)) - { - QUIT; - fi = get_frame_info (frame); - print_frame_info (fi, trailing_level + i, 0, 1); - } - - /* If we've stopped before the end, mention that. */ - if (frame && from_tty) - printf_filtered ("(More stack frames follow...)\n"); -} - -/* Print the local variables of a block B active in FRAME. - Return 1 if any variables were printed; 0 otherwise. */ - -static int -print_block_frame_locals (b, frame, stream) - struct block *b; - register FRAME frame; - register FILE *stream; -{ - int nsyms; - register int i; - register struct symbol *sym; - register int values_printed = 0; - - nsyms = BLOCK_NSYMS (b); - - for (i = 0; i < nsyms; i++) - { - sym = BLOCK_SYM (b, i); - if (SYMBOL_CLASS (sym) == LOC_LOCAL - || SYMBOL_CLASS (sym) == LOC_REGISTER - || SYMBOL_CLASS (sym) == LOC_STATIC) - { - values_printed = 1; - fprint_symbol (stream, SYMBOL_NAME (sym)); - fputs_filtered (" = ", stream); - print_variable_value (sym, frame, stream); - fprintf_filtered (stream, "\n"); - } - } - return values_printed; -} - -/* Same, but print labels. */ - -static int -print_block_frame_labels (b, have_default, stream) - struct block *b; - int *have_default; - register FILE *stream; -{ - int nsyms; - register int i; - register struct symbol *sym; - register int values_printed = 0; - - nsyms = BLOCK_NSYMS (b); - - for (i = 0; i < nsyms; i++) - { - sym = BLOCK_SYM (b, i); - if (! strcmp (SYMBOL_NAME (sym), "default")) - { - if (*have_default) - continue; - *have_default = 1; - } - if (SYMBOL_CLASS (sym) == LOC_LABEL) - { - struct symtab_and_line sal; - sal = find_pc_line (SYMBOL_VALUE_ADDRESS (sym), 0); - values_printed = 1; - fputs_demangled (SYMBOL_NAME (sym), stream, 1); - if (addressprint) - fprintf_filtered (stream, " %s", - local_hex_string(SYMBOL_VALUE_ADDRESS (sym))); - fprintf_filtered (stream, " in file %s, line %d\n", - sal.symtab->filename, sal.line); - } - } - return values_printed; -} - -/* Print on STREAM all the local variables in frame FRAME, - including all the blocks active in that frame - at its current pc. - - Returns 1 if the job was done, - or 0 if nothing was printed because we have no info - on the function running in FRAME. */ - -static void -print_frame_local_vars (frame, stream) - register FRAME frame; - register FILE *stream; -{ - register struct block *block = get_frame_block (frame); - register int values_printed = 0; - - if (block == 0) - { - fprintf_filtered (stream, "No symbol table info available.\n"); - return; - } - - while (block != 0) - { - if (print_block_frame_locals (block, frame, stream)) - values_printed = 1; - /* After handling the function's top-level block, stop. - Don't continue to its superblock, the block of - per-file symbols. */ - if (BLOCK_FUNCTION (block)) - break; - block = BLOCK_SUPERBLOCK (block); - } - - if (!values_printed) - { - fprintf_filtered (stream, "No locals.\n"); - } -} - -/* Same, but print labels. */ - -static void -print_frame_label_vars (frame, this_level_only, stream) - register FRAME frame; - int this_level_only; - register FILE *stream; -{ - extern struct blockvector *blockvector_for_pc (); - register struct blockvector *bl; - register struct block *block = get_frame_block (frame); - register int values_printed = 0; - int index, have_default = 0; - char *blocks_printed; - struct frame_info *fi = get_frame_info (frame); - CORE_ADDR pc = fi->pc; - - if (block == 0) - { - fprintf_filtered (stream, "No symbol table info available.\n"); - return; - } - - bl = blockvector_for_pc (BLOCK_END (block) - 4, &index); - blocks_printed = (char *) alloca (BLOCKVECTOR_NBLOCKS (bl) * sizeof (char)); - bzero (blocks_printed, BLOCKVECTOR_NBLOCKS (bl) * sizeof (char)); - - while (block != 0) - { - CORE_ADDR end = BLOCK_END (block) - 4; - int last_index; - - if (bl != blockvector_for_pc (end, &index)) - error ("blockvector blotch"); - if (BLOCKVECTOR_BLOCK (bl, index) != block) - error ("blockvector botch"); - last_index = BLOCKVECTOR_NBLOCKS (bl); - index += 1; - - /* Don't print out blocks that have gone by. */ - while (index < last_index - && BLOCK_END (BLOCKVECTOR_BLOCK (bl, index)) < pc) - index++; - - while (index < last_index - && BLOCK_END (BLOCKVECTOR_BLOCK (bl, index)) < end) - { - if (blocks_printed[index] == 0) - { - if (print_block_frame_labels (BLOCKVECTOR_BLOCK (bl, index), &have_default, stream)) - values_printed = 1; - blocks_printed[index] = 1; - } - index++; - } - if (have_default) - return; - if (values_printed && this_level_only) - return; - - /* After handling the function's top-level block, stop. - Don't continue to its superblock, the block of - per-file symbols. */ - if (BLOCK_FUNCTION (block)) - break; - block = BLOCK_SUPERBLOCK (block); - } - - if (!values_printed && !this_level_only) - { - fprintf_filtered (stream, "No catches.\n"); - } -} - -/* ARGSUSED */ -static void -locals_info (args, from_tty) - char *args; - int from_tty; -{ - if (!selected_frame) - error ("No frame selected."); - print_frame_local_vars (selected_frame, stdout); -} - -static void -catch_info () -{ - if (!selected_frame) - error ("No frame selected."); - print_frame_label_vars (selected_frame, 0, stdout); -} - -static void -print_frame_arg_vars (frame, stream) - register FRAME frame; - register FILE *stream; -{ - struct symbol *func = get_frame_function (frame); - register struct block *b; - int nsyms; - register int i; - register struct symbol *sym, *sym2; - register int values_printed = 0; - - if (func == 0) - { - fprintf_filtered (stream, "No symbol table info available.\n"); - return; - } - - b = SYMBOL_BLOCK_VALUE (func); - nsyms = BLOCK_NSYMS (b); - - for (i = 0; i < nsyms; i++) - { - sym = BLOCK_SYM (b, i); - if (SYMBOL_CLASS (sym) == LOC_ARG - || SYMBOL_CLASS (sym) == LOC_LOCAL_ARG - || SYMBOL_CLASS (sym) == LOC_REF_ARG - || SYMBOL_CLASS (sym) == LOC_REGPARM) - { - values_printed = 1; - fprint_symbol (stream, SYMBOL_NAME (sym)); - fputs_filtered (" = ", stream); - /* We have to look up the symbol because arguments often have - two entries (one a parameter, one a register) and the one - we want is the register, which lookup_symbol will find for - us. */ - sym2 = lookup_symbol (SYMBOL_NAME (sym), - b, VAR_NAMESPACE, (int *)NULL, (struct symtab **)NULL); - print_variable_value (sym2, frame, stream); - fprintf_filtered (stream, "\n"); - } - } - - if (!values_printed) - { - fprintf_filtered (stream, "No arguments.\n"); - } -} - -static void -args_info () -{ - if (!selected_frame) - error ("No frame selected."); - print_frame_arg_vars (selected_frame, stdout); -} - -/* Select frame FRAME, and note that its stack level is LEVEL. - LEVEL may be -1 if an actual level number is not known. */ - -void -select_frame (frame, level) - FRAME frame; - int level; -{ - register struct symtab *s; - - selected_frame = frame; - selected_frame_level = level; - - /* Ensure that symbols for this frame are read in. Also, determine the - source language of this frame, and switch to it if desired. */ - if (frame) - { - s = find_pc_symtab (get_frame_info (frame)->pc); - if (s - && s->language != current_language->la_language - && s->language != language_unknown - && language_mode == language_mode_auto) { - set_language(s->language); - } - } -} - -/* Store the selected frame and its level into *FRAMEP and *LEVELP. - If there is no selected frame, *FRAMEP is set to NULL. */ - -void -record_selected_frame (frameaddrp, levelp) - FRAME_ADDR *frameaddrp; - int *levelp; -{ - *frameaddrp = selected_frame ? FRAME_FP (selected_frame) : NULL; - *levelp = selected_frame_level; -} - -/* Return the symbol-block in which the selected frame is executing. - Can return zero under various legitimate circumstances. */ - -struct block * -get_selected_block () -{ - if (!target_has_stack) - return 0; - - if (!selected_frame) - return get_current_block (); - return get_frame_block (selected_frame); -} - -/* Find a frame a certain number of levels away from FRAME. - LEVEL_OFFSET_PTR points to an int containing the number of levels. - Positive means go to earlier frames (up); negative, the reverse. - The int that contains the number of levels is counted toward - zero as the frames for those levels are found. - If the top or bottom frame is reached, that frame is returned, - but the final value of *LEVEL_OFFSET_PTR is nonzero and indicates - how much farther the original request asked to go. */ - -FRAME -find_relative_frame (frame, level_offset_ptr) - register FRAME frame; - register int* level_offset_ptr; -{ - register FRAME prev; - register FRAME frame1; - - /* Going up is simple: just do get_prev_frame enough times - or until initial frame is reached. */ - while (*level_offset_ptr > 0) - { - prev = get_prev_frame (frame); - if (prev == 0) - break; - (*level_offset_ptr)--; - frame = prev; - } - /* Going down is just as simple. */ - if (*level_offset_ptr < 0) - { - while (*level_offset_ptr < 0) { - frame1 = get_next_frame (frame); - if (!frame1) - break; - frame = frame1; - (*level_offset_ptr)++; - } - } - return frame; -} - -/* The "select_frame" command. With no arg, NOP. - With arg LEVEL_EXP, select the frame at level LEVEL if it is a - valid level. Otherwise, treat level_exp as an address expression - and select it. See parse_frame_specification for more info on proper - frame expressions. */ - -/* ARGSUSED */ -static void -select_frame_command (level_exp, from_tty) - char *level_exp; - int from_tty; -{ - register FRAME frame, frame1; - unsigned int level = 0; - - if (!target_has_stack) - error ("No stack."); - - 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); -} - -/* The "frame" command. With no arg, print selected frame briefly. - With arg, behaves like select_frame and then prints the selected - frame. */ - -static void -frame_command (level_exp, from_tty) - char *level_exp; - int from_tty; -{ - select_frame_command (level_exp, from_tty); - print_stack_frame (selected_frame, selected_frame_level, 1); -} - -/* Select the frame up one or COUNT stack levels - from the previously selected frame, and print it briefly. */ - -/* ARGSUSED */ -static void -up_silently_command (count_exp, from_tty) - char *count_exp; - int from_tty; -{ - register FRAME frame; - int count = 1, count1; - if (count_exp) - count = parse_and_eval_address (count_exp); - count1 = count; - - if (!target_has_stack) - error ("No stack."); - - frame = find_relative_frame (selected_frame, &count1); - if (count1 != 0 && count_exp == 0) - error ("Initial frame selected; you cannot go up."); - select_frame (frame, selected_frame_level + count - count1); -} - -static void -up_command (count_exp, from_tty) - char *count_exp; - int from_tty; -{ - up_silently_command (count_exp, from_tty); - print_stack_frame (selected_frame, selected_frame_level, 1); -} - -/* Select the frame down one or COUNT stack levels - from the previously selected frame, and print it briefly. */ - -/* ARGSUSED */ -static void -down_silently_command (count_exp, from_tty) - char *count_exp; - int from_tty; -{ - register FRAME frame; - int count = -1, count1; - if (count_exp) - count = - parse_and_eval_address (count_exp); - count1 = count; - - if (!target_has_stack) - error ("No stack."); - - frame = find_relative_frame (selected_frame, &count1); - if (count1 != 0 && count_exp == 0) - error ("Bottom (i.e., innermost) frame selected; you cannot go down."); - select_frame (frame, selected_frame_level + count - count1); -} - - -static void -down_command (count_exp, from_tty) - char *count_exp; - int from_tty; -{ - down_silently_command (count_exp, from_tty); - print_stack_frame (selected_frame, selected_frame_level, 1); -} - -static void -return_command (retval_exp, from_tty) - char *retval_exp; - int from_tty; -{ - struct symbol *thisfun; - FRAME_ADDR selected_frame_addr; - CORE_ADDR selected_frame_pc; - FRAME frame; - - if (selected_frame == NULL) - error ("No selected frame."); - thisfun = get_frame_function (selected_frame); - selected_frame_addr = FRAME_FP (selected_frame); - selected_frame_pc = (get_frame_info (selected_frame))->pc; - - /* If interactive, require confirmation. */ - - if (from_tty) - { - if (thisfun != 0) - { - if (!query ("Make %s return now? ", SYMBOL_NAME (thisfun))) - error ("Not confirmed."); - } - else - if (!query ("Make selected stack frame return now? ")) - error ("Not confirmed."); - } - - /* Do the real work. Pop until the specified frame is current. We - use this method because the selected_frame is not valid after - a POP_FRAME. The pc comparison makes this work even if the - selected frame shares its fp with another frame. */ - - while ( selected_frame_addr != FRAME_FP (frame = get_current_frame()) - || selected_frame_pc != (get_frame_info (frame))->pc ) - POP_FRAME; - - /* Then pop that frame. */ - - POP_FRAME; - - /* Compute the return value (if any) and store in the place - for return values. */ - - if (retval_exp) - set_return_value (parse_and_eval (retval_exp)); - - /* If interactive, print the frame that is now current. */ - - if (from_tty) - frame_command ("0", 1); -} - -/* Gets the language of the current frame. */ -enum language -get_frame_language() -{ - register struct symtab *s; - FRAME fr; - enum language flang; /* The language of the current frame */ - - fr = get_frame_info(selected_frame); - if(fr) - { - s = find_pc_symtab(fr->pc); - if(s) - flang = s->language; - else - flang = language_unknown; - } - else - flang = language_unknown; - - return flang; -} - -void -_initialize_stack () -{ -#if 0 - backtrace_limit = 30; -#endif - - add_com ("return", class_stack, return_command, - "Make selected stack frame return to its caller.\n\ -Control remains in the debugger, but when you continue\n\ -execution will resume in the frame above the one now selected.\n\ -If an argument is given, it is an expression for the value to return."); - - add_com ("up", class_stack, up_command, - "Select and print stack frame that called this one.\n\ -An argument says how many frames up to go."); - add_com ("up-silently", class_support, up_silently_command, - "Same as the `up' command, but does not print anything.\n\ -This is useful in command scripts."); - - add_com ("down", class_stack, down_command, - "Select and print stack frame called by this one.\n\ -An argument says how many frames down to go."); - add_com_alias ("do", "down", class_stack, 1); - add_com ("down-silently", class_support, down_silently_command, - "Same as the `down' command, but does not print anything.\n\ -This is useful in command scripts."); - - add_com ("frame", class_stack, frame_command, - "Select and print a stack frame.\n\ -With no argument, print the selected stack frame. (See also \"info frame\").\n\ -An argument specifies the frame to select.\n\ -It can be a stack frame number or the address of the frame.\n\ -With argument, nothing is printed if input is coming from\n\ -a command file or a user-defined command."); - - add_com_alias ("f", "frame", class_stack, 1); - - add_com ("select-frame", class_stack, select_frame_command, - "Select a stack frame without printing anything.\n\ -An argument specifies the frame to select.\n\ -It can be a stack frame number or the address of the frame.\n"); - - add_com ("backtrace", class_stack, backtrace_command, - "Print backtrace of all stack frames, or innermost COUNT frames.\n\ -With a negative argument, print outermost -COUNT frames."); - add_com_alias ("bt", "backtrace", class_stack, 0); - add_com_alias ("where", "backtrace", class_alias, 0); - add_info ("stack", backtrace_command, - "Backtrace of the stack, or innermost COUNT frames."); - add_info_alias ("s", "stack", 1); - add_info ("frame", frame_info, - "All about selected stack frame, or frame at ADDR."); - add_info_alias ("f", "frame", 1); - add_info ("locals", locals_info, - "Local variables of current stack frame."); - add_info ("args", args_info, - "Argument variables of current stack frame."); - add_info ("catch", catch_info, - "Exceptions that can be caught in the current stack frame."); - -#if 0 - add_cmd ("backtrace-limit", class_stack, set_backtrace_limit_command, - "Specify maximum number of frames for \"backtrace\" to print by default.", - &setlist); - add_info ("backtrace-limit", backtrace_limit_info, - "The maximum number of frames for \"backtrace\" to print by default."); -#endif -} diff --git a/gdb/standalone.c b/gdb/standalone.c deleted file mode 100644 index 88c70536be3..00000000000 --- a/gdb/standalone.c +++ /dev/null @@ -1,594 +0,0 @@ -/* Interface to bare machine for GDB running as kernel debugger. - Copyright (C) 1986, 1989, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include -#include -#include -#include - -#if defined (SIGTSTP) && defined (SIGIO) -#include -#include -#endif /* SIGTSTP and SIGIO defined (must be 4.2) */ - -#include "defs.h" -#include "param.h" -#include "signals.h" -#include "symtab.h" -#include "frame.h" -#include "inferior.h" -#include "wait.h" - - -/* Random system calls, mostly no-ops to prevent link problems */ - -ioctl (desc, code, arg) -{} - -int (* signal ()) () -{} - -kill () -{} - -getpid () -{ - return 0; -} - -sigsetmask () -{} - -chdir () -{} - -char * -getwd (buf) - char *buf; -{ - buf[0] = '/'; - buf[1] = 0; - return buf; -} - -/* Used to check for existence of .gdbinit. Say no. */ - -access () -{ - return -1; -} - -exit () -{ - error ("Fatal error; restarting."); -} - -/* Reading "files". The contents of some files are written into kdb's - data area before it is run. These files are used to contain the - symbol table for kdb to load, and the source files (in case the - kdb user wants to print them). The symbols are stored in a file - named "kdb-symbols" in a.out format (except that all the text and - data have been stripped to save room). - - The files are stored in the following format: - int number of bytes of data for this file, including these four. - char[] name of the file, ending with a null. - padding to multiple of 4 boundary. - char[] file contents. The length can be deduced from what was - specified before. There is no terminating null here. - - If the int at the front is zero, it means there are no more files. - - Opening a file in kdb returns a nonzero value to indicate success, - but the value does not matter. Only one file can be open, and only - for reading. All the primitives for input from the file know - which file is open and ignore what is specified for the descriptor - or for the stdio stream. - - Input with fgetc can be done either on the file that is open - or on stdin (which reads from the terminal through tty_input () */ - -/* Address of data for the files stored in format described above. */ -char *files_start; - -/* The file stream currently open: */ - -char *sourcebeg; /* beginning of contents */ -int sourcesize; /* size of contents */ -char *sourceptr; /* current read pointer */ -int sourceleft; /* number of bytes to eof */ - -/* "descriptor" for the file now open. - Incremented at each close. - If specified descriptor does not match this, - it means the program is trying to use a closed descriptor. - We report an error for that. */ - -int sourcedesc; - -open (filename, modes) - char *filename; - int modes; -{ - register char *next; - - if (modes) - { - errno = EROFS; - return -1; - } - - if (sourceptr) - { - errno = EMFILE; - return -1; - } - - for (next - files_start; * (int *) next; - next += * (int *) next) - { - if (!strcmp (next + 4, filename)) - { - sourcebeg = next + 4 + strlen (next + 4) + 1; - sourcebeg = (char *) (((int) sourcebeg + 3) & (-4)); - sourceptr = sourcebeg; - sourcesize = next + * (int *) next - sourceptr; - sourceleft = sourcesize; - return sourcedesc; - } - } - return 0; -} - -close (desc) - int desc; -{ - sourceptr = 0; - sourcedesc++; - /* Don't let sourcedesc get big enough to be confused with stdin. */ - if (sourcedesc == 100) - sourcedesc = 5; -} - -FILE * -fopen (filename, modes) - char *filename; - char *modes; -{ - return (FILE *) open (filename, *modes == 'w'); -} - -FILE * -fdopen (desc) - int desc; -{ - return (FILE *) desc; -} - -fclose (desc) - int desc; -{ - close (desc); -} - -fstat (desc, statbuf) - struct stat *statbuf; -{ - if (desc != sourcedesc) - { - errno = EBADF; - return -1; - } - statbuf->st_size = sourcesize; -} - -myread (desc, destptr, size, filename) - int desc; - char *destptr; - int size; - char *filename; -{ - int len = min (sourceleft, size); - - if (desc != sourcedesc) - { - errno = EBADF; - return -1; - } - - bcopy (sourceptr, destptr, len); - sourceleft -= len; - return len; -} - -int -fread (bufp, numelts, eltsize, stream) -{ - register int elts = min (numelts, sourceleft / eltsize); - register int len = elts * eltsize; - - if (stream != sourcedesc) - { - errno = EBADF; - return -1; - } - - bcopy (sourceptr, bufp, len); - sourceleft -= len; - return elts; -} - -int -fgetc (desc) - int desc; -{ - - if (desc == (int) stdin) - return tty_input (); - - if (desc != sourcedesc) - { - errno = EBADF; - return -1; - } - - if (sourceleft-- <= 0) - return EOF; - return *sourceptr++; -} - -lseek (desc, pos) - int desc; - int pos; -{ - - if (desc != sourcedesc) - { - errno = EBADF; - return -1; - } - - if (pos < 0 || pos > sourcesize) - { - errno = EINVAL; - return -1; - } - - sourceptr = sourcebeg + pos; - sourceleft = sourcesize - pos; -} - -/* Output in kdb can go only to the terminal, so the stream - specified may be ignored. */ - -printf (a1, a2, a3, a4, a5, a6, a7, a8, a9) -{ - char buffer[1024]; - sprintf (buffer, a1, a2, a3, a4, a5, a6, a7, a8, a9); - display_string (buffer); -} - -fprintf (ign, a1, a2, a3, a4, a5, a6, a7, a8, a9) -{ - char buffer[1024]; - sprintf (buffer, a1, a2, a3, a4, a5, a6, a7, a8, a9); - display_string (buffer); -} - -fwrite (buf, numelts, size, stream) - register char *buf; - int numelts, size; -{ - register int i = numelts * size; - while (i-- > 0) - fputc (*buf++, stream); -} - -fputc (c, ign) -{ - char buf[2]; - buf[0] = c; - buf[1] = 0; - display_string (buf); -} - -/* sprintf refers to this, but loading this from the - library would cause fflush to be loaded from it too. - In fact there should be no need to call this (I hope). */ - -_flsbuf () -{ - error ("_flsbuf was actually called."); -} - -fflush (ign) -{ -} - -/* Entries into core and inflow, needed only to make things link ok. */ - -exec_file_command () -{} - -core_file_command () -{} - -char * -get_exec_file (err) - int err; -{ - /* Makes one printout look reasonable; value does not matter otherwise. */ - return "run"; -} - -have_core_file_p () -{ - return 0; -} - -kill_command () -{ - inferior_pid = 0; -} - -terminal_inferior () -{} - -terminal_ours () -{} - -terminal_init_inferior () -{} - -write_inferior_register () -{} - -read_inferior_register () -{} - -read_memory (memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - bcopy (memaddr, myaddr, len); -} - -/* Always return 0 indicating success. */ - -write_memory (memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - bcopy (myaddr, memaddr, len); - return 0; -} - -static REGISTER_TYPE saved_regs[NUM_REGS]; - -REGISTER_TYPE -read_register (regno) - int regno; -{ - if (regno < 0 || regno >= NUM_REGS) - error ("Register number %d out of range.", regno); - return saved_regs[regno]; -} - -void -write_register (regno, value) - int regno; - REGISTER_TYPE value; -{ - if (regno < 0 || regno >= NUM_REGS) - error ("Register number %d out of range.", regno); - saved_regs[regno] = value; -} - -/* System calls needed in relation to running the "inferior". */ - -vfork () -{ - /* Just appear to "succeed". Say the inferior's pid is 1. */ - return 1; -} - -/* These are called by code that normally runs in the inferior - that has just been forked. That code never runs, when standalone, - and these definitions are so it will link without errors. */ - -ptrace () -{} - -setpgrp () -{} - -execle () -{} - -_exit () -{} - -/* Malloc calls these. */ - -malloc_warning (str) - char *str; -{ - printf ("\n%s.\n\n", str); -} - -char *next_free; -char *memory_limit; - -char * -sbrk (amount) - int amount; -{ - if (next_free + amount > memory_limit) - return (char *) -1; - next_free += amount; - return next_free - amount; -} - -/* Various ways malloc might ask where end of memory is. */ - -char * -ulimit () -{ - return memory_limit; -} - -int -vlimit () -{ - return memory_limit - next_free; -} - -getrlimit (addr) - struct rlimit *addr; -{ - addr->rlim_cur = memory_limit - next_free; -} - -/* Context switching to and from program being debugged. */ - -/* GDB calls here to run the user program. - The frame pointer for this function is saved in - gdb_stack by save_frame_pointer; then we restore - all of the user program's registers, including PC and PS. */ - -static int fault_code; -static REGISTER_TYPE gdb_stack; - -resume () -{ - REGISTER_TYPE restore[NUM_REGS]; - - PUSH_FRAME_PTR; - save_frame_pointer (); - - bcopy (saved_regs, restore, sizeof restore); - POP_REGISTERS; - /* Control does not drop through here! */ -} - -save_frame_pointer (val) - CORE_ADDR val; -{ - gdb_stack = val; -} - -/* Fault handlers call here, running in the user program stack. - They must first push a fault code, - old PC, old PS, and any other info about the fault. - The exact format is machine-dependent and is known only - in the definition of PUSH_REGISTERS. */ - -fault () -{ - /* Transfer all registers and fault code to the stack - in canonical order: registers in order of GDB register number, - followed by fault code. */ - PUSH_REGISTERS; - - /* Transfer them to saved_regs and fault_code. */ - save_registers (); - - restore_gdb (); - /* Control does not reach here */ -} - -restore_gdb () -{ - CORE_ADDR new_fp = gdb_stack; - /* Switch to GDB's stack */ - POP_FRAME_PTR; - /* Return from the function `resume'. */ -} - -/* Assuming register contents and fault code have been pushed on the stack as - arguments to this function, copy them into the standard place - for the program's registers while GDB is running. */ - -save_registers (firstreg) - int firstreg; -{ - bcopy (&firstreg, saved_regs, sizeof saved_regs); - fault_code = (&firstreg)[NUM_REGS]; -} - -/* Store into the structure such as `wait' would return - the information on why the program faulted, - converted into a machine-independent signal number. */ - -static int fault_table[] = FAULT_TABLE; - -int -wait (w) - WAITTYPE *w; -{ - WSETSTOP (*w, fault_table[fault_code / FAULT_CODE_UNITS]); - return inferior_pid; -} - -/* Allocate a big space in which files for kdb to read will be stored. - Whatever is left is where malloc can allocate storage. - - Initialize it, so that there will be space in the executable file - for it. Then the files can be put into kdb by writing them into - kdb's executable file. */ - -/* The default size is as much space as we expect to be available - for kdb to use! */ - -#ifndef HEAP_SIZE -#define HEAP_SIZE 400000 -#endif - -char heap[HEAP_SIZE] = {0}; - -#ifndef STACK_SIZE -#define STACK_SIZE 100000 -#endif - -int kdb_stack_beg[STACK_SIZE / sizeof (int)]; -int kdb_stack_end; - -_initialize_standalone () -{ - register char *next; - - /* Find start of data on files. */ - - files_start = heap; - - /* Find the end of the data on files. */ - - for (next - files_start; * (int *) next; - next += * (int *) next) - {} - - /* That is where free storage starts for sbrk to give out. */ - next_free = next; - - memory_limit = heap + sizeof heap; -} - diff --git a/gdb/stddef.h b/gdb/stddef.h deleted file mode 100755 index c2c396e139a..00000000000 --- a/gdb/stddef.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef _STDDEF_H -#define _STDDEF_H - -/* Signed type of difference of two pointers. */ - -typedef long ptrdiff_t; - -/* Unsigned type of `sizeof' something. */ - -/* in case has defined it. */ -/* DECstation uses _SIZE_T_. */ -#if !defined (_SIZE_T) && !defined (_SIZE_T_) -#define _SIZE_T -typedef unsigned long size_t; -#endif /* _SIZE_T */ - -/* A null pointer constant. */ - -#undef NULL /* in case has defined it. */ -#define NULL 0 - -/* Offset of member MEMBER in a struct of type TYPE. */ - -#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) - -#endif /* _STDDEF_H */ diff --git a/gdb/stdlib.h b/gdb/stdlib.h deleted file mode 100755 index 40ce1676a13..00000000000 --- a/gdb/stdlib.h +++ /dev/null @@ -1,10 +0,0 @@ -/* Fake stdlib.h supplying the stuff needed by malloc. */ - -#ifndef __ONEFILE -#include -#endif - -extern void EXFUN(abort, (void)); -extern void EXFUN(free, (PTR)); -extern PTR EXFUN(malloc, (size_t)); -extern PTR EXFUN(realloc, (PTR, size_t)); diff --git a/gdb/stuff.c b/gdb/stuff.c deleted file mode 100644 index a28511d6e7e..00000000000 --- a/gdb/stuff.c +++ /dev/null @@ -1,174 +0,0 @@ -/* Program to stuff files into a specially prepared space in kdb. - Copyright (C) 1986, 1989, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Written 13-Mar-86 by David Bridgham. */ - -#include -#include -#include -#include -#include -#include - -extern char *sys_errlist[]; - -main (argc, argv) - int argc; - char *argv[]; -{ - register char *cp; - char *outfile; - register int i; - int offset; - int out_fd, in_fd; - struct stat stat_buf; - int size, pad; - char buf[1024]; - static char zeros[4] = {0}; - - if (argc < 4) - err("Not enough arguments\nUsage: %s -o kdb file1 file2 ...\n", - argv[0]); - - outfile = 0; - for (i = 1; i < argc; i++) - { - if (strcmp (argv[i], "-o") == 0) - outfile = argv[++i]; - } - if (outfile == 0) - err("Output file not specified\n"); - - offset = get_offset (outfile, "_heap"); - - out_fd = open (outfile, O_WRONLY); - if (out_fd < 0) - err ("Error opening %s for write: %s\n", outfile, sys_errlist[errno]); - if (lseek (out_fd, offset, 0) < 0) - err ("Error seeking to heap in %s: %s\n", outfile, sys_errlist[errno]); - - /* For each file listed on the command line, write it into the - * 'heap' of the output file. Make sure to skip the arguments - * that name the output file. */ - for (i = 1; i < argc; i++) - { - if (strcmp (argv[i], "-o") == 0) - continue; - if ((in_fd = open (argv[i], O_RDONLY)) < 0) - err ("Error opening %s for read: %s\n", argv[i], sys_errlist[errno]); - if (fstat (in_fd, &stat_buf) < 0) - err ("Error stat'ing %s: %s\n", argv[i], sys_errlist[errno]); - size = strlen (argv[i]); - pad = 4 - (size & 3); - size += pad + stat_buf.st_size + sizeof (int); - write (out_fd, &size, sizeof (int)); - write (out_fd, argv[i], strlen (argv[i])); - write (out_fd, zeros, pad); - while ((size = read (in_fd, buf, sizeof (buf))) > 0) - write (out_fd, buf, size); - close (in_fd); - } - size = 0; - write (out_fd, &size, sizeof (int)); - close (out_fd); - return (0); -} - -/* Read symbol table from file and returns the offset into the file - * where symbol sym_name is located. If error, print message and - * exit. */ -get_offset (file, sym_name) - char *file; - char *sym_name; -{ - int f; - struct exec file_hdr; - struct nlist *symbol_table; - int size; - char *strings; - - f = open (file, O_RDONLY); - if (f < 0) - err ("Error opening %s: %s\n", file, sys_errlist[errno]); - if (read (f, &file_hdr, sizeof (file_hdr)) < 0) - err ("Error reading exec structure: %s\n", sys_errlist[errno]); - if (N_BADMAG (file_hdr)) - err ("File %s not an a.out file\n", file); - - /* read in symbol table */ - if ((symbol_table = (struct nlist *)malloc (file_hdr.a_syms)) == 0) - err ("Couldn't allocate space for symbol table\n"); - if (lseek (f, N_SYMOFF (file_hdr), 0) == -1) - err ("lseek error: %s\n", sys_errlist[errno]); - if (read (f, symbol_table, file_hdr.a_syms) == -1) - err ("Error reading symbol table from %s: %s\n", file, sys_errlist[errno]); - - /* read in string table */ - if (read (f, &size, 4) == -1) - err ("reading string table size: %s\n", sys_errlist[errno]); - if ((strings = (char *)malloc (size)) == 0) - err ("Couldn't allocate memory for string table\n"); - if (read (f, strings, size - 4) == -1) - err ("reading string table: %s\n", sys_errlist[errno]); - - /* Find the core address at which the first byte of kdb text segment - should be loaded into core when kdb is run. */ - origin = find_symbol ("_etext", symbol_table, file_hdr.a_syms, strings) - - file_hdr.a_text; - /* Find the core address at which the heap will appear. */ - coreaddr = find_symbol (sym_name, symbol_table, file_hdr.a_syms, strings); - /* Return address in file of the heap data space. */ - return (N_TXTOFF (file_hdr) + core_addr - origin); -} - -find_symbol (sym_name, symbol_table, length, strings) - char *sym_name; - struct nlist *symbol_table; - int length; - char *strings; -{ - register struct nlist *sym; - - /* Find symbol in question */ - for (sym = symbol_table; - sym != (struct nlist *)((char *)symbol_table + length); - sym++) - { - if ((sym->n_type & N_TYPE) != N_DATA) continue; - if (sym->n_un.n_strx == 0) continue; - if (strcmp (sym_name, strings + sym->n_un.n_strx - 4) == 0) - return sym->n_value; - } - err ("Data symbol %s not found in %s\n", sym_name, file); -} - -/* VARARGS */ -void -err (va_alist) - va_dcl -{ - va_list args; - char *string; - - va_start (args); - string = va_arg (args, char *); - vfprintf (stderr, string, args); - va_end (args); - exit (-1); -} diff --git a/gdb/sun3-xdep.c b/gdb/sun3-xdep.c deleted file mode 100644 index f6394bce02a..00000000000 --- a/gdb/sun3-xdep.c +++ /dev/null @@ -1,160 +0,0 @@ -/* Sun-3 Machine-dependent code which would otherwise be in inflow.c and core.c, - for GDB, the GNU debugger. - Copyright (C) 1986, 1987, 1989 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "defs.h" -#include "param.h" -#include "inferior.h" - -#include -#define KERNEL /* To get floating point reg definitions */ -#include - -#include "gdbcore.h" - -extern int errno; - -#if defined (GDB_TARGET_IS_SUN3) -/* All of this stuff is only relevant if both host and target are sun3. */ -void -fetch_inferior_registers () -{ - struct regs inferior_registers; -#ifdef FP0_REGNUM - struct fp_status inferior_fp_registers; -#endif - extern char registers[]; - - registers_fetched (); - - ptrace (PTRACE_GETREGS, inferior_pid, &inferior_registers); -#ifdef FP0_REGNUM - ptrace (PTRACE_GETFPREGS, inferior_pid, &inferior_fp_registers); -#endif - - bcopy (&inferior_registers, registers, 16 * 4); -#ifdef FP0_REGNUM - bcopy (&inferior_fp_registers, ®isters[REGISTER_BYTE (FP0_REGNUM)], - sizeof inferior_fp_registers.fps_regs); -#endif - *(int *)®isters[REGISTER_BYTE (PS_REGNUM)] = inferior_registers.r_ps; - *(int *)®isters[REGISTER_BYTE (PC_REGNUM)] = inferior_registers.r_pc; -#ifdef FP0_REGNUM - bcopy (&inferior_fp_registers.fps_control, - ®isters[REGISTER_BYTE (FPC_REGNUM)], - sizeof inferior_fp_registers - sizeof inferior_fp_registers.fps_regs); -#endif -} - -/* Store our register values back into the inferior. - If REGNO is -1, do this for all registers. - Otherwise, REGNO specifies which register (so we can save time). */ - -store_inferior_registers (regno) - int regno; -{ - struct regs inferior_registers; -#ifdef FP0_REGNUM - struct fp_status inferior_fp_registers; -#endif - extern char registers[]; - - bcopy (registers, &inferior_registers, 16 * 4); -#ifdef FP0_REGNUM - bcopy (®isters[REGISTER_BYTE (FP0_REGNUM)], &inferior_fp_registers, - sizeof inferior_fp_registers.fps_regs); -#endif - inferior_registers.r_ps = *(int *)®isters[REGISTER_BYTE (PS_REGNUM)]; - inferior_registers.r_pc = *(int *)®isters[REGISTER_BYTE (PC_REGNUM)]; - -#ifdef FP0_REGNUM - bcopy (®isters[REGISTER_BYTE (FPC_REGNUM)], - &inferior_fp_registers.fps_control, - sizeof inferior_fp_registers - sizeof inferior_fp_registers.fps_regs); -#endif - - ptrace (PTRACE_SETREGS, inferior_pid, &inferior_registers); -#if FP0_REGNUM - ptrace (PTRACE_SETFPREGS, inferior_pid, &inferior_fp_registers); -#endif -} - -/* Machine-dependent code for pulling registers out of a Sun-3 core file. */ - -void -fetch_core_registers (core_reg_sect, core_reg_size, which) - char *core_reg_sect; - unsigned core_reg_size; - int which; -{ - extern char registers[]; - struct regs *regs = (struct regs *) core_reg_sect; - - if (which == 0) { - if (core_reg_size < sizeof (struct regs)) - error ("Can't find registers in core file"); - - bcopy ((char *)regs, registers, 16 * 4); - supply_register (PS_REGNUM, ®s->r_ps); - supply_register (PC_REGNUM, ®s->r_pc); - - } else if (which == 2) { - -#define fpustruct ((struct fpu *) core_reg_sect) - - if (core_reg_size >= sizeof (struct fpu)) - { -#ifdef FP0_REGNUM - bcopy (fpustruct->f_fpstatus.fps_regs, - ®isters[REGISTER_BYTE (FP0_REGNUM)], - sizeof fpustruct->f_fpstatus.fps_regs); - bcopy (&fpustruct->f_fpstatus.fps_control, - ®isters[REGISTER_BYTE (FPC_REGNUM)], - sizeof fpustruct->f_fpstatus - - sizeof fpustruct->f_fpstatus.fps_regs); -#endif - } - else - fprintf (stderr, "Couldn't read float regs from core file\n"); - } -} -#else /* Not sun3 target. */ -/* These functions shouldn't be called when we're cross-debugging. */ - -void -fetch_inferior_registers () -{ -} - -/* ARGSUSED */ -store_inferior_registers (regno) - int regno; -{ -} - -/* ARGSUSED */ -void -fetch_core_registers (core_reg_sect, core_reg_size, which) - char *core_reg_sect; - unsigned core_reg_size; - int which; -{ -} -#endif /* Not sun3 target. */ diff --git a/gdb/sun386-xdep.c b/gdb/sun386-xdep.c deleted file mode 100644 index 4ecb54223c6..00000000000 --- a/gdb/sun386-xdep.c +++ /dev/null @@ -1,279 +0,0 @@ -/* Machine-dependent code for host Sun 386i's for GDB, the GNU debugger. - Copyright (C) 1986, 1987, 1989, 1991 Free Software Foundation, Inc. - Changes for sun386i by Jean Daniel Fekete (jdf@litp.univ-p6-7.fr), - C2V Paris, April 89. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#if defined (GDB_TARGET_IS_SUN386) - -#include -#include "defs.h" -#include "param.h" -#include "frame.h" -#include "inferior.h" -#include "signame.h" -#include "gdbcore.h" - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include - -void -fetch_inferior_registers () -{ - struct regs inferior_registers; - struct fp_state inferior_fp_registers; - extern char registers[]; - - registers_fetched (); - - ptrace (PTRACE_GETREGS, inferior_pid, &inferior_registers); - ptrace (PTRACE_GETFPREGS, inferior_pid, &inferior_fp_registers); - - bcopy (&inferior_registers, registers, sizeof inferior_registers); - - bcopy (inferior_fp_registers.f_st,®isters[REGISTER_BYTE (FP0_REGNUM)], - sizeof inferior_fp_registers.f_st); - bcopy (&inferior_fp_registers.f_ctrl, - ®isters[REGISTER_BYTE (FPC_REGNUM)], - sizeof inferior_fp_registers - sizeof inferior_fp_registers.f_st); -} - -/* Store our register values back into the inferior. - If REGNO is -1, do this for all registers. - Otherwise, REGNO specifies which register (so we can save time). */ - -store_inferior_registers (regno) - int regno; -{ - struct regs inferior_registers; - struct fp_state inferior_fp_registers; - extern char registers[]; - - bcopy (registers, &inferior_registers, 20 * 4); - - bcopy (®isters[REGISTER_BYTE (FP0_REGNUM)],inferior_fp_registers.f_st, - sizeof inferior_fp_registers.f_st); - bcopy (®isters[REGISTER_BYTE (FPC_REGNUM)], - &inferior_fp_registers.f_ctrl, - sizeof inferior_fp_registers - sizeof inferior_fp_registers.f_st); - -#ifdef PTRACE_FP_BUG - if (regno == FP_REGNUM || regno == -1) - /* Storing the frame pointer requires a gross hack, in which an - instruction that moves eax into ebp gets single-stepped. */ - { - int stack = inferior_registers.r_reg[SP_REGNUM]; - int stuff = ptrace (PTRACE_PEEKDATA, inferior_pid, stack); - int reg = inferior_registers.r_reg[EAX]; - inferior_registers.r_reg[EAX] = - inferior_registers.r_reg[FP_REGNUM]; - ptrace (PTRACE_SETREGS, inferior_pid, &inferior_registers); - ptrace (PTRACE_POKEDATA, inferior_pid, stack, 0xc589); - ptrace (PTRACE_SINGLESTEP, inferior_pid, stack, 0); - wait (0); - ptrace (PTRACE_POKEDATA, inferior_pid, stack, stuff); - inferior_registers.r_reg[EAX] = reg; - } -#endif - ptrace (PTRACE_SETREGS, inferior_pid, &inferior_registers); - ptrace (PTRACE_SETFPREGS, inferior_pid, &inferior_fp_registers); -} - -/* Machine-dependent code which would otherwise be in core.c */ -/* Work with core files, for GDB. */ - - -void -core_file_command (filename, from_tty) - char *filename; - int from_tty; -{ - int val; - extern char registers[]; - - /* Discard all vestiges of any previous core file - and mark data and stack spaces as empty. */ - - if (corefile) - free (corefile); - corefile = 0; - - if (corechan >= 0) - close (corechan); - corechan = -1; - - data_start = 0; - data_end = 0; - stack_start = STACK_END_ADDR; - stack_end = STACK_END_ADDR; - - /* Now, if a new core file was specified, open it and digest it. */ - - if (filename) - { - filename = tilde_expand (filename); - make_cleanup (free, filename); - - if (have_inferior_p ()) - error ("To look at a core file, you must kill the inferior with \"kill\"."); - corechan = open (filename, O_RDONLY, 0); - if (corechan < 0) - perror_with_name (filename); - - { - struct core corestr; - - val = myread (corechan, &corestr, sizeof corestr); - if (val < 0) - perror_with_name (filename); - if (corestr.c_magic != CORE_MAGIC) - error ("\"%s\" does not appear to be a core dump file (magic 0x%x, expected 0x%x)", - filename, corestr.c_magic, (int) CORE_MAGIC); - else if (sizeof (struct core) != corestr.c_len) - error ("\"%s\" has an invalid struct core length (%d, expected %d)", - filename, corestr.c_len, (int) sizeof (struct core)); - - data_start = exec_data_start; - data_end = data_start + corestr.c_dsize; - stack_start = stack_end - corestr.c_ssize; - data_offset = sizeof corestr; - stack_offset = sizeof corestr + corestr.c_dsize; - - bcopy (&corestr.c_regs, registers, sizeof corestr.c_regs); - - bcopy (corestr.c_fpu.f_fpstatus.f_st, - ®isters[REGISTER_BYTE (FP0_REGNUM)], - sizeof corestr.c_fpu.f_fpstatus.f_st); - bcopy (&corestr.c_fpu.f_fpstatus.f_ctrl, - ®isters[REGISTER_BYTE (FPC_REGNUM)], - sizeof corestr.c_fpu.f_fpstatus - - sizeof corestr.c_fpu.f_fpstatus.f_st); - - /* the struct aouthdr of sun coff is not the struct exec stored - in the core file. */ - bcopy (&corestr.c_aouthdr, &core_aouthdr, sizeof (struct exec)); -#ifndef COFF_ENCAPSULATE - core_aouthdr.magic = corestr.c_aouthdr.a_info; - core_aouthdr.vstamp = /*SUNVERSION*/ 31252; -#endif - printf ("Core file is from \"%s\".\n", corestr.c_cmdname); - if (corestr.c_signo > 0) - printf ("Program terminated with signal %d, %s.\n", - corestr.c_signo, - corestr.c_signo < NSIG - ? sys_siglist[corestr.c_signo] - : "(undocumented)"); - } - if (filename[0] == '/') - corefile = savestring (filename, strlen (filename)); - else - { - corefile = concat (current_directory, "/", filename, NULL); - } - - set_current_frame ( create_new_frame (read_register (FP_REGNUM), - read_pc ())); - select_frame (get_current_frame (), 0); - - validate_files (); - } - else if (from_tty) - printf ("No core file now.\n"); -} - -i387_to_double (from, to) - char *from; - char *to; -{ - long *lp; - /* push extended mode on 387 stack, then pop in double mode - * - * first, set exception masks so no error is generated - - * number will be rounded to inf or 0, if necessary - */ - asm ("pushl %eax"); /* grab a stack slot */ - asm ("fstcw (%esp)"); /* get 387 control word */ - asm ("movl (%esp),%eax"); /* save old value */ - asm ("orl $0x3f,%eax"); /* mask all exceptions */ - asm ("pushl %eax"); - asm ("fldcw (%esp)"); /* load new value into 387 */ - - asm ("movl 8(%ebp),%eax"); - asm ("fldt (%eax)"); /* push extended number on 387 stack */ - asm ("fwait"); - asm ("movl 12(%ebp),%eax"); - asm ("fstpl (%eax)"); /* pop double */ - asm ("fwait"); - - asm ("popl %eax"); /* flush modified control word */ - asm ("fnclex"); /* clear exceptions */ - asm ("fldcw (%esp)"); /* restore original control word */ - asm ("popl %eax"); /* flush saved copy */ -} - -double_to_i387 (from, to) - char *from; - char *to; -{ - /* push double mode on 387 stack, then pop in extended mode - * no errors are possible because every 64-bit pattern - * can be converted to an extended - */ - asm ("movl 8(%ebp),%eax"); - asm ("fldl (%eax)"); - asm ("fwait"); - asm ("movl 12(%ebp),%eax"); - asm ("fstpt (%eax)"); - asm ("fwait"); -} -#else /* Not sun386 target. */ - -/* These functions shouldn't be called when we're cross-debugging. */ - -void -fetch_inferior_registers () -{ -} - -/* ARGSUSED */ -store_inferior_registers (regno) - int regno; -{ -} - -/* ARGSUSED */ -void -fetch_core_registers (core_reg_sect, core_reg_size, which) - char *core_reg_sect; - unsigned core_reg_size; - int which; -{ -} - -#endif /* Not sun386 target. */ diff --git a/gdb/symfile.c b/gdb/symfile.c deleted file mode 100644 index cf75a17e643..00000000000 --- a/gdb/symfile.c +++ /dev/null @@ -1,1077 +0,0 @@ -/* Generic symbol file reading for the GNU debugger, GDB. - Copyright 1990, 1991 Free Software Foundation, Inc. - Contributed by Cygnus Support, using pieces from other GDB modules. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "defs.h" -#include "symtab.h" -#include "param.h" -#include "gdbcore.h" -#include "frame.h" -#include "target.h" -#include "value.h" -#include "symfile.h" -#include "gdbcmd.h" -#include "breakpoint.h" - -#include -#include - -#include -#include -#include -#include - -CORE_ADDR entry_point; /* Where execution starts in symfile */ - -extern int info_verbose; - -extern void qsort (); -extern char *getenv (); -extern char *rindex (); - -extern CORE_ADDR startup_file_start; /* From blockframe.c */ -extern CORE_ADDR startup_file_end; /* From blockframe.c */ - -/* Functions this file defines */ -static bfd *symfile_open(); -static struct sym_fns *symfile_init(); -static void clear_symtab_users_once(); - -/* List of all available sym_fns. */ - -struct sym_fns *symtab_fns = NULL; - -/* Saves the sym_fns of the current symbol table, so we can call - the right XXX_new_init function when we free it. FIXME. This - should be extended to calling the new_init function for each - existing symtab or psymtab, since the main symbol file and - subsequent added symbol files can have different types. */ - -static struct sym_fns *symfile_fns; - -/* Allocate an obstack to hold objects that should be freed - when we load a new symbol table. - This includes the symbols made by dbxread - and the types that are not permanent. */ - -struct obstack obstack1; - -struct obstack *symbol_obstack = &obstack1; - -/* This obstack will be used for partial_symbol objects. It can - probably actually be the same as the symbol_obstack above, but I'd - like to keep them seperate for now. If I want to later, I'll - replace one with the other. */ - -struct obstack obstack2; - -struct obstack *psymbol_obstack = &obstack2; - -/* File name symbols were loaded from. */ - -char *symfile = 0; - -/* The modification date of the file when they were loaded. */ - -long /* really time_t */ symfile_mtime = 0; - -/* Structures with which to manage partial symbol allocation. */ - -#include "param.h" -struct psymbol_allocation_list global_psymbols = {0}, static_psymbols = {0}; - -/* Flag for whether user will be reloading symbols multiple times. - Defaults to ON for VxWorks, otherwise OFF. */ - -#ifdef SYMBOL_RELOADING_DEFAULT -int symbol_reloading = SYMBOL_RELOADING_DEFAULT; -#else -int symbol_reloading = 0; -#endif - -/* Structure to manage complaints about symbol file contents. */ - -struct complaint complaint_root[1] = { - {(char *)0, 0, complaint_root}, -}; - -/* Some actual complaints. */ - -struct complaint oldsyms_complaint = { - "Replacing old symbols for `%s'", 0, 0 }; - -struct complaint empty_symtab_complaint = { - "Empty symbol table found for `%s'", 0, 0 }; - - -/* In the following sort, we always make sure that - register debug symbol declarations always come before regular - debug symbol declarations (as might happen when parameters are - then put into registers by the compiler). */ - -static int -compare_symbols (s1, s2) - struct symbol **s1, **s2; -{ - register int namediff; - - /* Compare the initial characters. */ - namediff = SYMBOL_NAME (*s1)[0] - SYMBOL_NAME (*s2)[0]; - if (namediff != 0) return namediff; - - /* If they match, compare the rest of the names. */ - namediff = strcmp (SYMBOL_NAME (*s1), SYMBOL_NAME (*s2)); - if (namediff != 0) return namediff; - - /* For symbols of the same name, registers should come first. */ - return ((SYMBOL_CLASS (*s2) == LOC_REGISTER) - - (SYMBOL_CLASS (*s1) == LOC_REGISTER)); -} - -/* Call sort_block_syms to sort alphabetically the symbols of one block. */ - -void -sort_block_syms (b) - register struct block *b; -{ - qsort (&BLOCK_SYM (b, 0), BLOCK_NSYMS (b), - sizeof (struct symbol *), compare_symbols); -} - -/* Call sort_symtab_syms to sort alphabetically - the symbols of each block of one symtab. */ - -void -sort_symtab_syms (s) - register struct symtab *s; -{ - register struct blockvector *bv; - int nbl; - int i; - register struct block *b; - - if (s == 0) - return; - bv = BLOCKVECTOR (s); - nbl = BLOCKVECTOR_NBLOCKS (bv); - for (i = 0; i < nbl; i++) - { - b = BLOCKVECTOR_BLOCK (bv, i); - if (BLOCK_SHOULD_SORT (b)) - sort_block_syms (b); - } -} - -void -sort_all_symtab_syms () -{ - register struct symtab *s; - - for (s = symtab_list; s; s = s->next) - { - sort_symtab_syms (s); - } -} - -/* Make a copy of the string at PTR with SIZE characters in the symbol obstack - (and add a null character at the end in the copy). - Returns the address of the copy. */ - -char * -obsavestring (ptr, size) - char *ptr; - int size; -{ - register char *p = (char *) obstack_alloc (symbol_obstack, size + 1); - /* Open-coded bcopy--saves function call time. - These strings are usually short. */ - { - register char *p1 = ptr; - register char *p2 = p; - char *end = ptr + size; - while (p1 != end) - *p2++ = *p1++; - } - p[size] = 0; - return p; -} - -/* Concatenate strings S1, S2 and S3; return the new string. - Space is found in the symbol_obstack. */ - -char * -obconcat (s1, s2, s3) - char *s1, *s2, *s3; -{ - register int len = strlen (s1) + strlen (s2) + strlen (s3) + 1; - register char *val = (char *) obstack_alloc (symbol_obstack, len); - strcpy (val, s1); - strcat (val, s2); - strcat (val, s3); - return val; -} - -/* Accumulate the misc functions in bunches of 127. - At the end, copy them all into one newly allocated structure. */ - -#define MISC_BUNCH_SIZE 127 - -struct misc_bunch -{ - struct misc_bunch *next; - struct misc_function contents[MISC_BUNCH_SIZE]; -}; - -/* Bunch currently being filled up. - The next field points to chain of filled bunches. */ - -static struct misc_bunch *misc_bunch; - -/* Number of slots filled in current bunch. */ - -static int misc_bunch_index; - -/* Total number of misc functions recorded so far. */ - -static int misc_count; - -void -init_misc_bunches () -{ - misc_count = 0; - misc_bunch = 0; - misc_bunch_index = MISC_BUNCH_SIZE; -} - -void -prim_record_misc_function (name, address, misc_type) - char *name; - CORE_ADDR address; - enum misc_function_type misc_type; -{ - register struct misc_bunch *new; - - if (misc_bunch_index == MISC_BUNCH_SIZE) - { - new = (struct misc_bunch *) xmalloc (sizeof (struct misc_bunch)); - misc_bunch_index = 0; - new->next = misc_bunch; - misc_bunch = new; - } - misc_bunch->contents[misc_bunch_index].name = name; - misc_bunch->contents[misc_bunch_index].address = address; - misc_bunch->contents[misc_bunch_index].type = misc_type; - misc_bunch->contents[misc_bunch_index].misc_info = 0; - misc_bunch_index++; - misc_count++; -} - -static int -compare_misc_functions (fn1, fn2) - struct misc_function *fn1, *fn2; -{ - /* Return a signed result based on unsigned comparisons - so that we sort into unsigned numeric order. */ - if (fn1->address < fn2->address) - return -1; - if (fn1->address > fn2->address) - return 1; - return 0; -} - -/* ARGSUSED */ -void -discard_misc_bunches (foo) - int foo; -{ - register struct misc_bunch *next; - - while (misc_bunch) - { - next = misc_bunch->next; - free (misc_bunch); - misc_bunch = next; - } -} - -/* INCLINK nonzero means bunches are from an incrementally-linked file. - Add them to the existing bunches. - Otherwise INCLINK is zero, and we start from scratch. */ -void -condense_misc_bunches (inclink) - int inclink; -{ - register int i, j; - register struct misc_bunch *bunch; - - if (inclink) - { - misc_function_vector - = (struct misc_function *) - xrealloc (misc_function_vector, (misc_count + misc_function_count) - * sizeof (struct misc_function)); - j = misc_function_count; - } - else - { - misc_function_vector - = (struct misc_function *) - xmalloc (misc_count * sizeof (struct misc_function)); - j = 0; - } - - bunch = misc_bunch; - while (bunch) - { - for (i = 0; i < misc_bunch_index; i++, j++) - { - misc_function_vector[j] = bunch->contents[i]; -#ifdef NAMES_HAVE_UNDERSCORE - if (misc_function_vector[j].name[0] == '_') - misc_function_vector[j].name++; -#endif -#ifdef SOME_NAMES_HAVE_DOT - if (misc_function_vector[j].name[0] == '.') - misc_function_vector[j].name++; -#endif - - } - bunch = bunch->next; - misc_bunch_index = MISC_BUNCH_SIZE; - } - - if (misc_function_count + misc_count != j) /* DEBUG */ - printf_filtered ("Function counts are off! %d + %d != %d\n", - misc_function_count, misc_count, j); - - misc_function_count = j; - - /* Sort the misc functions by address. */ - - qsort (misc_function_vector, misc_function_count, - sizeof (struct misc_function), - compare_misc_functions); -} - - -/* Get the symbol table that corresponds to a partial_symtab. - This is fast after the first time you do it. In fact, there - is an even faster macro PSYMTAB_TO_SYMTAB that does the fast - case inline. */ - -struct symtab * -psymtab_to_symtab (pst) - register struct partial_symtab *pst; -{ - /* If it's been looked up before, return it. */ - if (pst->symtab) - return pst->symtab; - - /* If it has not yet been read in, read it. */ - if (!pst->readin) - { - (*pst->read_symtab) (pst); - } - - return pst->symtab; -} - -/* Process a symbol file, as either the main file or as a dynamically - loaded file. - - NAME is the file name (which will be tilde-expanded and made - absolute herein) (but we don't free or modify NAME itself). - FROM_TTY says how verbose to be. MAINLINE specifies whether this - is the main symbol file, or whether it's an extra symbol file such - as dynamically loaded code. If !mainline, ADDR is the address - where the text segment was loaded. */ - -void -syms_from_bfd (sym_bfd, addr, mainline) - bfd *sym_bfd; - CORE_ADDR addr; - int mainline; -{ - asection *text_sect; - struct sym_fns *sf; - char *realname; - - /* There is a distinction between having no symbol table - (we refuse to read the file, leaving the old set of symbols around) - and having no debugging symbols in your symbol table (we read - the file and end up with a mostly empty symbol table). */ - - if (!(bfd_get_file_flags (sym_bfd) & HAS_SYMS)) - return; - - /* Save startup file's range of PC addresses to help blockframe.c - decide where the bottom of the stack is. */ - if (bfd_get_file_flags (sym_bfd) & EXEC_P) - { - /* Executable file -- record its entry point so we'll recognize - the startup file because it contains the entry point. */ - entry_point = bfd_get_start_address (sym_bfd); - } - else - { - /* Examination of non-executable.o files. Short-circuit this stuff. */ - /* ~0 will not be in any file, we hope. */ - entry_point = ~0; - /* set the startup file to be an empty range. */ - startup_file_start = 0; - startup_file_end = 0; - } - - sf = symfile_init (sym_bfd); - realname = bfd_get_filename (sym_bfd); - realname = savestring (realname, strlen (realname)); - /* FIXME, this probably creates a storage leak... */ - - if (mainline) - { - /* Since no error yet, throw away the old symbol table. */ - - if (symfile) - free (symfile); - symfile = 0; - free_all_symtabs (); - free_all_psymtabs (); - - (*sf->sym_new_init) (); - - /* For mainline, caller didn't know the specified address of the - text section. We fix that here. */ - text_sect = bfd_get_section_by_name (sym_bfd, ".text"); - addr = bfd_section_vma (sym_bfd, text_sect); - } - - clear_complaints(); /* Allow complaints to appear for this new file. */ - - (*sf->sym_read) (sf, addr, mainline); - - /* Don't allow char * to have a typename (else would get caddr_t.) */ - /* Ditto void *. FIXME should do this for all the builtin types. */ - - TYPE_NAME (lookup_pointer_type (builtin_type_char)) = 0; - TYPE_NAME (lookup_pointer_type (builtin_type_void)) = 0; - - if (mainline) - { - /* OK, make it the "real" symbol file. */ - symfile = realname; - symfile_fns = sf; - } - - /* If we have wiped out any old symbol tables, clean up. */ - clear_symtab_users_once (); -} - - -/* Process a symbol file, as either the main file or as a dynamically - loaded file. - - NAME is the file name (which will be tilde-expanded and made - absolute herein) (but we don't free or modify NAME itself). - FROM_TTY says how verbose to be. MAINLINE specifies whether this - is the main symbol file, or whether it's an extra symbol file such - as dynamically loaded code. If !mainline, ADDR is the address - where the text segment was loaded. */ - -void -symbol_file_add (name, from_tty, addr, mainline) - char *name; - int from_tty; - CORE_ADDR addr; - int mainline; -{ - bfd *sym_bfd; - - sym_bfd = symfile_open (name); - - if (mainline) - symfile_mtime = bfd_get_mtime (sym_bfd); - - /* There is a distinction between having no symbol table - (we refuse to read the file, leaving the old set of symbols around) - and having no debugging symbols in your symbol table (we read - the file and end up with a mostly empty symbol table). */ - - if (!(bfd_get_file_flags (sym_bfd) & HAS_SYMS)) - { - error ("%s has no symbol-table", name); - } - - if ((symtab_list || partial_symtab_list) - && mainline - && from_tty - && !query ("Load new symbol table from \"%s\"? ", name)) - error ("Not confirmed."); - - if (from_tty) - { - printf_filtered ("Reading symbols from %s...", name); - wrap_here (""); - fflush (stdout); - } - - syms_from_bfd (sym_bfd, addr, mainline); - - if (from_tty) - { - printf_filtered ("done.\n"); - fflush (stdout); - } -} - -/* This is the symbol-file command. Read the file, analyze its symbols, - and add a struct symtab to symtab_list. */ - -void -symbol_file_command (name, from_tty) - char *name; - int from_tty; -{ - - dont_repeat (); - - if (name == 0) - { - if ((symtab_list || partial_symtab_list) - && from_tty - && !query ("Discard symbol table from `%s'? ", symfile)) - error ("Not confirmed."); - if (symfile) - free (symfile); - symfile = 0; - free_all_symtabs (); - free_all_psymtabs (); - /* FIXME, this does not account for the main file and subsequent - files (shared libs, dynloads, etc) having different formats. - It only calls the cleanup routine for the main file's format. */ - if (symfile_fns) { - (*symfile_fns->sym_new_init) (); - free (symfile_fns); - symfile_fns = 0; - } - return; - } - - /* Getting new symbols may change our opinion about what is - frameless. */ - reinit_frame_cache (); - - symbol_file_add (name, from_tty, (CORE_ADDR)0, 1); -} - -/* Open NAME and hand it off to BFD for preliminary analysis. Result - is a BFD *, which includes a new copy of NAME dynamically allocated - (which will be freed by the cleanup chain). In case of trouble, - error() is called. */ - -static bfd * -symfile_open (name) - char *name; -{ - bfd *sym_bfd; - int desc; - char *absolute_name; - - name = tilde_expand (name); - make_cleanup (free, name); - - desc = openp (getenv ("PATH"), 1, name, O_RDONLY, 0, &absolute_name); - if (desc < 0) - perror_with_name (name); - else - { - make_cleanup (free, absolute_name); - name = absolute_name; - } - - sym_bfd = bfd_fdopenr (name, NULL, desc); - if (!sym_bfd) - { - close (desc); - error ("Could not open `%s' to read symbols: %s", - name, bfd_errmsg (bfd_error)); - } - make_cleanup (bfd_close, sym_bfd); - - if (!bfd_check_format (sym_bfd, bfd_object)) - error ("\"%s\": can't read symbols: %s.", - name, bfd_errmsg (bfd_error)); - - return sym_bfd; -} - -/* Link a new symtab_fns into the global symtab_fns list. - Called by various _initialize routines. */ - -void -add_symtab_fns (sf) - struct sym_fns *sf; -{ - sf->next = symtab_fns; - symtab_fns = sf; -} - - -/* Initialize to read symbols from the symbol file sym_bfd. It either - returns or calls error(). The result is a malloc'd struct sym_fns - that contains cached information about the symbol file. */ - -static struct sym_fns * -symfile_init (sym_bfd) - bfd *sym_bfd; -{ - struct sym_fns *sf, *sf2; - - for (sf = symtab_fns; sf != NULL; sf = sf->next) - { - if (!strncmp (bfd_get_target (sym_bfd), sf->sym_name, sf->sym_namelen)) - { - sf2 = (struct sym_fns *)xmalloc (sizeof (*sf2)); - /* FIXME, who frees this? */ - *sf2 = *sf; - sf2->sym_bfd = sym_bfd; - sf2->sym_private = 0; /* Not alloc'd yet */ - (*sf2->sym_init) (sf2); - return sf2; - } - } - error ("I'm sorry, Dave, I can't do that. Symbol format `%s' unknown.", - bfd_get_target (sym_bfd)); - return 0; /* Appease lint. */ -} - -/* This function runs the load command of our current target. */ - -void -load_command (arg, from_tty) - char *arg; - int from_tty; -{ - target_load (arg, from_tty); -} - -/* This function allows the addition of incrementally linked object files. - It does not modify any state in the target, only in the debugger. */ - -/* ARGSUSED */ -void -add_symbol_file_command (arg_string, from_tty) - char *arg_string; - int from_tty; -{ - char *name; - CORE_ADDR text_addr; - - /* Getting new symbols may change our opinion about what is - frameless. */ - reinit_frame_cache (); - - if (arg_string == 0) - error ("add-symbol-file takes a file name and an address"); - - arg_string = tilde_expand (arg_string); - make_cleanup (free, arg_string); - - for( ; *arg_string == ' '; arg_string++ ); - name = arg_string; - for( ; *arg_string && *arg_string != ' ' ; arg_string++ ); - *arg_string++ = (char) 0; - - if (name[0] == 0) - error ("add-symbol-file takes a file name and an address"); - - text_addr = parse_and_eval_address (arg_string); - - dont_repeat (); - - if (!query ("add symbol table from file \"%s\" at text_addr = %s?\n", - name, local_hex_string (text_addr))) - error ("Not confirmed."); - - symbol_file_add (name, 0, text_addr, 0); -} - -/* Re-read symbols if the symbol-file has changed. */ -void -reread_symbols () -{ - struct stat symstat; - - /* With the addition of shared libraries, this should be modified, - the load time should be saved in the partial symbol tables, since - different tables may come from different source files. FIXME. - This routine should then walk down each partial symbol table - and see if the symbol table that it originates from has been changed - */ - - if (stat (symfile, &symstat) < 0) - /* Can't read symbol-file. Assume it is up to date. */ - return; - - if (symstat.st_mtime > symfile_mtime) - { - printf_filtered ("Symbol file has changed; re-reading symbols.\n"); - symbol_file_command (symfile, 0); - breakpoint_re_set (); - } -} - -/* This function is really horrible, but to avoid it, there would need - to be more filling in of forward references. */ -void -fill_in_vptr_fieldno (type) - struct type *type; -{ - if (TYPE_VPTR_FIELDNO (type) < 0) - { - int i; - for (i = 1; i < TYPE_N_BASECLASSES (type); i++) - { - fill_in_vptr_fieldno (TYPE_BASECLASS (type, i)); - if (TYPE_VPTR_FIELDNO (TYPE_BASECLASS (type, i)) >= 0) - { - TYPE_VPTR_FIELDNO (type) - = TYPE_VPTR_FIELDNO (TYPE_BASECLASS (type, i)); - TYPE_VPTR_BASETYPE (type) - = TYPE_VPTR_BASETYPE (TYPE_BASECLASS (type, i)); - break; - } - } - } -} - -/* Functions to handle complaints during symbol reading. */ - -/* How many complaints about a particular thing should be printed before - we stop whining about it? Default is no whining at all, since so many - systems have ill-constructed symbol files. */ - -static unsigned stop_whining = 0; - -/* Print a complaint about the input symbols, and link the complaint block - into a chain for later handling. Result is 1 if the complaint was - printed, 0 if it was suppressed. */ - -int -complain (complaint, val) - struct complaint *complaint; - char *val; -{ - complaint->counter++; - if (complaint->next == 0) { - complaint->next = complaint_root->next; - complaint_root->next = complaint; - } - if (complaint->counter > stop_whining) - return 0; - wrap_here (""); - if (!info_verbose) { - puts_filtered ("During symbol reading..."); - } - printf_filtered (complaint->message, val); - puts_filtered ("..."); - wrap_here(""); - if (!info_verbose) - puts_filtered ("\n"); - return 1; -} - -/* Clear out all complaint counters that have ever been incremented. */ - -void -clear_complaints () -{ - struct complaint *p; - - for (p = complaint_root->next; p != complaint_root; p = p->next) - p->counter = 0; -} - -/* allocate_symtab: - - Allocate and partly initialize a new symbol table. Return a pointer - to it. error() if no space. - - Caller must set these fields: - LINETABLE(symtab) - symtab->blockvector - symtab->dirname - symtab->free_code - symtab->free_ptr - initialize any EXTRA_SYMTAB_INFO - possibly free_named_symtabs (symtab->filename); - symtab->next = symtab_list; - symtab_list = symtab; - */ - -struct symtab * -allocate_symtab(name) - char *name; -{ - register struct symtab *symtab; - char *c; - - symtab = (struct symtab *) xmalloc (sizeof (struct symtab)); - bzero (symtab, sizeof (*symtab)); - symtab->filename = name; - symtab->fullname = NULL; - symtab->nlines = 0; - symtab->line_charpos = 0; - symtab->version = 0; - symtab->language = language_unknown; /* default */ - - c = rindex (name, '.'); - - if (!c) { - ; /* Don't know language of file. */ - } else if(!strcmp(c,".mod")) { - symtab->language = language_m2; - } else if(!strcmp(c,".c") || !strcmp(c,".cc")) { - symtab->language = language_c; - } - - return symtab; -} - -/* clear_symtab_users_once: - - This function is run after symbol reading, or from a cleanup. - If an old symbol table was obsoleted, the old symbol table - has been blown away, but the other GDB data structures that may - reference it have not yet been cleared or re-directed. (The old - symtab was zapped, and the cleanup queued, in free_named_symtab() - below.) - - This function can be queued N times as a cleanup, or called - directly; it will do all the work the first time, and then will be a - no-op until the next time it is queued. This works by bumping a - counter at queueing time. Much later when the cleanup is run, or at - the end of symbol processing (in case the cleanup is discarded), if - the queued count is greater than the "done-count", we do the work - and set the done-count to the queued count. If the queued count is - less than or equal to the done-count, we just ignore the call. This - is needed because reading a single .o file will often replace many - symtabs (one per .h file, for example), and we don't want to reset - the breakpoints N times in the user's face. - - The reason we both queue a cleanup, and call it directly after symbol - reading, is because the cleanup protects us in case of errors, but is - discarded if symbol reading is successful. */ - -static int clear_symtab_users_queued; -static int clear_symtab_users_done; - -static void -clear_symtab_users_once () -{ - /* Enforce once-per-`do_cleanups'-semantics */ - if (clear_symtab_users_queued <= clear_symtab_users_done) - return; - clear_symtab_users_done = clear_symtab_users_queued; - - printf ("Resetting debugger state after updating old symbol tables\n"); - - /* Someday, we should do better than this, by only blowing away - the things that really need to be blown. */ - clear_value_history (); - clear_displays (); - clear_internalvars (); - breakpoint_re_set (); - set_default_breakpoint (0, 0, 0, 0); - current_source_symtab = 0; -} - -/* Delete the specified psymtab, and any others that reference it. */ - -static void -cashier_psymtab (pst) - struct partial_symtab *pst; -{ - struct partial_symtab *ps, *pprev; - int i; - - /* Find its previous psymtab in the chain */ - for (ps = partial_symtab_list; ps; ps = ps->next) { - if (ps == pst) - break; - pprev = ps; - } - - if (ps) { - /* Unhook it from the chain. */ - if (ps == partial_symtab_list) - partial_symtab_list = ps->next; - else - pprev->next = ps->next; - - /* FIXME, we can't conveniently deallocate the entries in the - partial_symbol lists (global_psymbols/static_psymbols) that - this psymtab points to. These just take up space until all - the psymtabs are reclaimed. Ditto the dependencies list and - filename, which are all in the psymbol_obstack. */ - - /* We need to cashier any psymtab that has this one as a dependency... */ -again: - for (ps = partial_symtab_list; ps; ps = ps->next) { - for (i = 0; i < ps->number_of_dependencies; i++) { - if (ps->dependencies[i] == pst) { - cashier_psymtab (ps); - goto again; /* Must restart, chain has been munged. */ - } - } - } - } -} - -/* If a symtab or psymtab for filename NAME is found, free it along - with any dependent breakpoints, displays, etc. - Used when loading new versions of object modules with the "add-file" - command. This is only called on the top-level symtab or psymtab's name; - it is not called for subsidiary files such as .h files. - - Return value is 1 if we blew away the environment, 0 if not. - - FIXME. I think this is not the best way to do this. We should - work on being gentler to the environment while still cleaning up - all stray pointers into the freed symtab. */ - -int -free_named_symtabs (name) - char *name; -{ - register struct symtab *s; - register struct symtab *prev; - register struct partial_symtab *ps; - struct blockvector *bv; - int blewit = 0; - - /* We only wack things if the symbol-reload switch is set. */ - if (!symbol_reloading) - return 0; - - /* Some symbol formats have trouble providing file names... */ - if (name == 0 || *name == '\0') - return 0; - - /* Look for a psymtab with the specified name. */ - -again2: - for (ps = partial_symtab_list; ps; ps = ps->next) { - if (!strcmp (name, ps->filename)) { - cashier_psymtab (ps); /* Blow it away...and its little dog, too. */ - goto again2; /* Must restart, chain has been munged */ - } - } - - /* Look for a symtab with the specified name. */ - - for (s = symtab_list; s; s = s->next) - { - if (!strcmp (name, s->filename)) - break; - prev = s; - } - - if (s) - { - if (s == symtab_list) - symtab_list = s->next; - else - prev->next = s->next; - - /* For now, queue a delete for all breakpoints, displays, etc., whether - or not they depend on the symtab being freed. This should be - changed so that only those data structures affected are deleted. */ - - /* But don't delete anything if the symtab is empty. - This test is necessary due to a bug in "dbxread.c" that - causes empty symtabs to be created for N_SO symbols that - contain the pathname of the object file. (This problem - has been fixed in GDB 3.9x). */ - - bv = BLOCKVECTOR (s); - if (BLOCKVECTOR_NBLOCKS (bv) > 2 - || BLOCK_NSYMS (BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK)) - || BLOCK_NSYMS (BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK))) - { - complain (&oldsyms_complaint, name); - - clear_symtab_users_queued++; - make_cleanup (clear_symtab_users_once, 0); - blewit = 1; - } else { - complain (&empty_symtab_complaint, name); - } - - free_symtab (s); - } - else - { - /* It is still possible that some breakpoints will be affected - even though no symtab was found, since the file might have - been compiled without debugging, and hence not be associated - with a symtab. In order to handle this correctly, we would need - to keep a list of text address ranges for undebuggable files. - For now, we do nothing, since this is a fairly obscure case. */ - ; - } - - /* FIXME, what about the misc function vector? */ - return blewit; -} - -void -_initialize_symfile () -{ - - add_com ("symbol-file", class_files, symbol_file_command, - "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."); - - add_com ("add-symbol-file", class_files, add_symbol_file_command, - "Load the symbols from FILE, assuming FILE has been dynamically loaded.\n\ -The second argument provides the starting address of the file's text."); - - add_com ("load", class_files, load_command, - "Dynamically load FILE into the running program, and record its symbols\n\ -for access from GDB."); - - add_show_from_set - (add_set_cmd ("complaints", class_support, var_uinteger, - (char *)&stop_whining, - "Set max number of complaints about incorrect symbols.", - &setlist), - &showlist); - - add_show_from_set - (add_set_cmd ("symbol-reloading", class_support, var_boolean, - (char *)&symbol_reloading, - "Set dynamic symbol table reloading multiple times in one run.", - &setlist), - &showlist); - - obstack_init (symbol_obstack); - obstack_init (psymbol_obstack); -} diff --git a/gdb/symfile.h b/gdb/symfile.h deleted file mode 100644 index 5d1c1c666ec..00000000000 --- a/gdb/symfile.h +++ /dev/null @@ -1,160 +0,0 @@ -/* Definitions for reading symbol files into GDB. - Copyright (C) 1990 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* This file requires that you first include "bfd.h". */ - -/* Data structures and function definitions for dealing with - symbol table reading from files. */ - -/* Structure to keep track of symbol reading functions for various - object file types. */ - -struct sym_fns { - - /* sym_name - is the name, or name prefix, of the BFD "target type" that this - set of functions handles. E.g. "a.out" or "sunOs" or "coff" or "elf". */ - - char *sym_name; - - /* sym_namelen - counts how many bytes of sym_name should be checked against the - BFD target type of the file being read. If an exact match is - desired, specify the number of characters in sym_name plus 1 for the - NUL. If a prefix match is desired, specify the number of characters in - sym_name. */ - - int sym_namelen; - - /* sym_new_init - initializes anything that is global to the entire - symbol table. It is called during symbol_file_add, when - we begin debugging an entirely new program. */ - - void (*sym_new_init) (); - - /* sym_init (sf) - reads any initial information from a symbol file, and - initializes the struct sym_fns SF in preparation for sym_read(). - It is called every time we read a symbol file for any reason. */ - - void (*sym_init) (); - - /* sym_read (sf, addr, mainline) - reads a symbol file into a psymtab (or possibly a symtab). - SF is the struct sym_fns that sym_init initialized. ADDR - is the offset between the file's specified start address and - its true address in memory. MAINLINE is 1 if this is the - main symbol table being read, and 0 if a secondary - symbol file (e.g. shared library or dynamically loaded file) - is being read. */ - - void (*sym_read) (); - - /* sym_bfd - is the accessor for the symbol file being read. */ - - bfd *sym_bfd; - - /* sym_private - is where information can be shared among sym_init and sym_read. - It is typically a pointer to malloc'd memory. */ - - char *sym_private; /* Should be void * */ - - /* next - finds the next struct sym_fns. They are allocated and initialized - in whatever module implements the functions pointed to; an - initializer calls add_symtab_fns to add them to the global chain. */ - struct sym_fns *next; -}; - - /* Functions */ - -extern struct symtab *allocate_symtab (); -extern int free_named_symtabs (); -extern void fill_in_vptr_fieldno (); -extern void add_symtab_fns (); - -/* Functions for dealing with the misc "function" vector, really a misc - address<->symbol mapping vector for things we don't have debug symbols - for. */ - -extern void init_misc_bunches (); -extern void prim_record_misc_function (); -extern void discard_misc_bunches (); -extern void condense_misc_bunches (); - -/* Sorting your symbols for fast lookup or alphabetical printing. */ - -extern void sort_block_syms (); -extern void sort_symtab_syms (); -extern void sort_all_symtab_syms (); -extern void sort_block_syms (); - -/* Make a copy of the string at PTR with SIZE characters in the symbol obstack - (and add a null character at the end in the copy). - Returns the address of the copy. */ - -extern char *obsavestring (); - -/* Concatenate strings S1, S2 and S3; return the new string. - Space is found in the symbol_obstack. */ - -extern char *obconcat (); - - /* Variables */ - -/* File name symbols were loaded from. */ - -extern char *symfile; - -/* The modification date of the file when they were loaded. */ - -extern long /* really time_t */ symfile_mtime; - -/* Vectors of all partial symbols read in from file. */ - -extern struct psymbol_allocation_list { - struct partial_symbol *list, *next; - int size; -} global_psymbols, static_psymbols; - -/* Support for complaining about things in the symbol file that aren't - catastrophic. - - Each such thing gets a counter. The first time we have the problem, - during a symbol read, we report it. At the end of symbol reading, - if verbose, we report how many of each problem we had. */ - -struct complaint { - char *message; - unsigned counter; - struct complaint *next; -}; - -/* Root of the chain of complaints that have at some point been issued. - This is used to reset the counters, and/or report the total counts. */ - -extern struct complaint complaint_root[1]; - -/* Functions that handle complaints. (in symfile.c) */ - -int complain(); -void clear_complaints(); diff --git a/gdb/symm-tdep.c b/gdb/symm-tdep.c deleted file mode 100644 index d7d5def3e1f..00000000000 --- a/gdb/symm-tdep.c +++ /dev/null @@ -1,494 +0,0 @@ -/* Sequent Symmetry target interface, for GDB when running under Unix. - Copyright (C) 1986, 1987, 1989, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* many 387-specific items of use taken from i386-dep.c */ - -#include -#include "defs.h" -#include "param.h" -#include "frame.h" -#include "inferior.h" -#include "symtab.h" - -#include -#include -#include -#include -#include -#include -#include "gdbcore.h" -#include - -static long i386_get_frame_setup (); -static i386_follow_jump (); - -#include -#define TERMINAL struct sgttyb - -exec_file_command (filename, from_tty) - char *filename; - int from_tty; -{ - int val; - - /* Eliminate all traces of old exec file. - Mark text segment as empty. */ - - if (execfile) - free (execfile); - execfile = 0; - data_start = 0; - data_end -= exec_data_start; - text_start = 0; - text_end = 0; - exec_data_start = 0; - exec_data_end = 0; - if (execchan >= 0) - close (execchan); - execchan = -1; - - /* Now open and digest the file the user requested, if any. */ - - if (filename) - { - filename = tilde_expand (filename); - make_cleanup (free, filename); - - execchan = openp (getenv ("PATH"), 1, filename, O_RDONLY, 0, - &execfile); - if (execchan < 0) - perror_with_name (filename); - -#ifdef COFF_FORMAT - { - int aout_hdrsize; - int num_sections; - - if (read_file_hdr (execchan, &file_hdr) < 0) - error ("\"%s\": not in executable format.", execfile); - - aout_hdrsize = file_hdr.f_opthdr; - num_sections = file_hdr.f_nscns; - - if (read_aout_hdr (execchan, &exec_aouthdr, aout_hdrsize) < 0) - error ("\"%s\": can't read optional aouthdr", execfile); - - if (read_section_hdr (execchan, _TEXT, &text_hdr, num_sections, - aout_hdrsize) < 0) - error ("\"%s\": can't read text section header", execfile); - - if (read_section_hdr (execchan, _DATA, &data_hdr, num_sections, - aout_hdrsize) < 0) - error ("\"%s\": can't read data section header", execfile); - - text_start = exec_aouthdr.text_start; - text_end = text_start + exec_aouthdr.tsize; - text_offset = text_hdr.s_scnptr; - exec_data_start = exec_aouthdr.data_start; - exec_data_end = exec_data_start + exec_aouthdr.dsize; - exec_data_offset = data_hdr.s_scnptr; - data_start = exec_data_start; - data_end += exec_data_start; - exec_mtime = file_hdr.f_timdat; - } -#else /* not COFF_FORMAT */ - { - struct stat st_exec; - - val = myread (execchan, &exec_aouthdr, sizeof (AOUTHDR)); - - if (val < 0) - perror_with_name (filename); - - text_start = N_ADDRADJ(exec_aouthdr); - exec_data_start = round(exec_aouthdr.a_text, NBPG*CLSIZE); - text_offset = N_TXTOFF (exec_aouthdr); - exec_data_offset = N_TXTOFF (exec_aouthdr) + exec_aouthdr.a_text; - text_end = exec_aouthdr.a_text; - exec_data_end = exec_data_start + exec_aouthdr.a_data; - data_start = exec_data_start; - data_end = data_start + exec_aouthdr.a_data; - exec_data_offset = N_TXTOFF(exec_aouthdr); - fstat (execchan, &st_exec); - exec_mtime = st_exec.st_mtime; - } -#endif /* not COFF_FORMAT */ - - validate_files (); - } - else if (from_tty) - printf ("No exec file now.\n"); - - /* Tell display code (if any) about the changed file name. */ - if (exec_file_display_hook) - (*exec_file_display_hook) (filename); -} - -/* rounds 'one' up to divide evenly by 'two' */ - -int -round(one,two) -register int one, two; - -{ - register int temp; - temp = (one/two)*two; - if (one != temp) { - temp += two; - } - return temp; -} - - -static CORE_ADDR codestream_next_addr; -static CORE_ADDR codestream_addr; -static unsigned char codestream_buf[sizeof (int)]; -static int codestream_off; -static int codestream_cnt; - -#define codestream_tell() (codestream_addr + codestream_off) -#define codestream_peek() (codestream_cnt == 0 ? \ - codestream_fill(1): codestream_buf[codestream_off]) -#define codestream_get() (codestream_cnt-- == 0 ? \ - codestream_fill(0) : codestream_buf[codestream_off++]) - - -static unsigned char -codestream_fill (peek_flag) -{ - codestream_addr = codestream_next_addr; - codestream_next_addr += sizeof (int); - codestream_off = 0; - codestream_cnt = sizeof (int); - read_memory (codestream_addr, - (unsigned char *)codestream_buf, - sizeof (int)); - - if (peek_flag) - return (codestream_peek()); - else - return (codestream_get()); -} - -static void -codestream_seek (place) -{ - codestream_next_addr = place & -sizeof (int); - codestream_cnt = 0; - codestream_fill (1); - while (codestream_tell() != place) - codestream_get (); -} - -static void -codestream_read (buf, count) - unsigned char *buf; -{ - unsigned char *p; - int i; - p = buf; - for (i = 0; i < count; i++) - *p++ = codestream_get (); -} - -/* - * Following macro translates i386 opcode register numbers to Symmetry - * register numbers. This is used by FRAME_FIND_SAVED_REGS. - * - * %eax %ecx %edx %ebx %esp %ebp %esi %edi - * i386 0 1 2 3 4 5 6 7 - * Symmetry 0 2 1 5 14 15 6 7 - * - */ -#define I386_REGNO_TO_SYMMETRY(n) \ -((n)==0?0 :(n)==1?2 :(n)==2?1 :(n)==3?5 :(n)==4?14 :(n)==5?15 :(n)) - -/* from i386-dep.c */ -i386_frame_find_saved_regs (fip, fsrp) - struct frame_info *fip; - struct frame_saved_regs *fsrp; -{ - unsigned long locals; - unsigned char *p; - unsigned char op; - CORE_ADDR dummy_bottom; - CORE_ADDR adr; - int i; - - bzero (fsrp, sizeof *fsrp); - - /* if frame is the end of a dummy, compute where the - * beginning would be - */ - dummy_bottom = fip->frame - 4 - NUM_REGS*4 - CALL_DUMMY_LENGTH; - - /* check if the PC is in the stack, in a dummy frame */ - if (dummy_bottom <= fip->pc && fip->pc <= fip->frame) - { - /* all regs were saved by push_call_dummy () */ - adr = fip->frame - 4; - for (i = 0; i < NUM_REGS; i++) - { - fsrp->regs[i] = adr; - adr -= 4; - } - return; - } - - locals = i386_get_frame_setup (get_pc_function_start (fip->pc)); - - if (locals >= 0) - { - adr = fip->frame - 4 - locals; - for (i = 0; i < 8; i++) - { - op = codestream_get (); - if (op < 0x50 || op > 0x57) - break; - fsrp->regs[I386_REGNO_TO_SYMMETRY(op - 0x50)] = adr; - adr -= 4; - } - } - - fsrp->regs[PC_REGNUM] = fip->frame + 4; - fsrp->regs[FP_REGNUM] = fip->frame; -} - -static long -i386_get_frame_setup (pc) -{ - unsigned char op; - - codestream_seek (pc); - - i386_follow_jump (); - - op = codestream_get (); - - if (op == 0x58) /* popl %eax */ - { - /* - * this function must start with - * - * popl %eax 0x58 - * xchgl %eax, (%esp) 0x87 0x04 0x24 - * or xchgl %eax, 0(%esp) 0x87 0x44 0x24 0x00 - * - * (the system 5 compiler puts out the second xchg - * inst, and the assembler doesn't try to optimize it, - * so the 'sib' form gets generated) - * - * this sequence is used to get the address of the return - * buffer for a function that returns a structure - */ - int pos; - unsigned char buf[4]; - static unsigned char proto1[3] = { 0x87,0x04,0x24 }; - static unsigned char proto2[4] = { 0x87,0x44,0x24,0x00 }; - pos = codestream_tell (); - codestream_read (buf, 4); - if (bcmp (buf, proto1, 3) == 0) - pos += 3; - else if (bcmp (buf, proto2, 4) == 0) - pos += 4; - - codestream_seek (pos); - op = codestream_get (); /* update next opcode */ - } - - if (op == 0x55) /* pushl %esp */ - { - if (codestream_get () != 0x8b) /* movl %esp, %ebp (2bytes) */ - return (-1); - if (codestream_get () != 0xec) - return (-1); - /* - * check for stack adjustment - * - * subl $XXX, %esp - * - * note: you can't subtract a 16 bit immediate - * from a 32 bit reg, so we don't have to worry - * about a data16 prefix - */ - op = codestream_peek (); - if (op == 0x83) /* subl with 8 bit immed */ - { - codestream_get (); - if (codestream_get () != 0xec) - return (-1); - /* subl with signed byte immediate - * (though it wouldn't make sense to be negative) - */ - return (codestream_get()); - } - else if (op == 0x81) /* subl with 32 bit immed */ - { - int locals; - if (codestream_get () != 0xec) - return (-1); - /* subl with 32 bit immediate */ - codestream_read ((unsigned char *)&locals, 4); - return (locals); - } - else - { - return (0); - } - } - else if (op == 0xc8) - { - /* enter instruction: arg is 16 unsigned immed */ - unsigned short slocals; - codestream_read ((unsigned char *)&slocals, 2); - codestream_get (); /* flush final byte of enter instruction */ - return (slocals); - } - return (-1); -} - -/* next instruction is a jump, move to target */ -static -i386_follow_jump () -{ - int long_delta; - short short_delta; - char byte_delta; - int data16; - int pos; - - pos = codestream_tell (); - - data16 = 0; - if (codestream_peek () == 0x66) - { - codestream_get (); - data16 = 1; - } - - switch (codestream_get ()) - { - case 0xe9: - /* relative jump: if data16 == 0, disp32, else disp16 */ - if (data16) - { - codestream_read ((unsigned char *)&short_delta, 2); - pos += short_delta + 3; /* include size of jmp inst */ - } - else - { - codestream_read ((unsigned char *)&long_delta, 4); - pos += long_delta + 5; - } - break; - case 0xeb: - /* relative jump, disp8 (ignore data16) */ - codestream_read ((unsigned char *)&byte_delta, 1); - pos += byte_delta + 2; - break; - } - codestream_seek (pos + data16); -} - -/* return pc of first real instruction */ -/* from i386-dep.c */ - -i386_skip_prologue (pc) -{ - unsigned char op; - int i; - - if (i386_get_frame_setup (pc) < 0) - return (pc); - - /* found valid frame setup - codestream now points to - * start of push instructions for saving registers - */ - - /* skip over register saves */ - for (i = 0; i < 8; i++) - { - op = codestream_peek (); - /* break if not pushl inst */ - if (op < 0x50 || op > 0x57) - break; - codestream_get (); - } - - i386_follow_jump (); - - return (codestream_tell ()); -} - -symmetry_extract_return_value(type, regbuf, valbuf) - struct type *type; - char *regbuf; - char *valbuf; -{ - union { - double d; - int l[2]; - } xd; - int i; - float f; - - if (TYPE_CODE_FLT == TYPE_CODE(type)) { - for (i = 0; i < misc_function_count; i++) { - if (!strcmp(misc_function_vector[i].name, "1167_flt")) - break; - } - if (i < misc_function_count) { - /* found "1167_flt" means 1167, %fp2-%fp3 */ - /* float & double; 19= %fp2, 20= %fp3 */ - /* no single precision on 1167 */ - xd.l[1] = *((int *)®buf[REGISTER_BYTE(19)]); - xd.l[0] = *((int *)®buf[REGISTER_BYTE(20)]); - switch (TYPE_LENGTH(type)) { - case 4: - f = (float) xd.d; - bcopy(&f, valbuf, TYPE_LENGTH(type)); - break; - case 8: - bcopy(&xd.d, valbuf, TYPE_LENGTH(type)); - break; - default: - error("Unknown floating point size"); - break; - } - } else { - /* 387 %st(0), gcc uses this */ - i387_to_double(((int *)®buf[REGISTER_BYTE(3)]), - &xd.d); - switch (TYPE_LENGTH(type)) { - case 4: /* float */ - f = (float) xd.d; - bcopy(&f, valbuf, 4); - break; - case 8: /* double */ - bcopy(&xd.d, valbuf, 8); - break; - default: - error("Unknown floating point size"); - break; - } - } - } else { - bcopy (regbuf, valbuf, TYPE_LENGTH (type)); - } -} diff --git a/gdb/symm-xdep.c b/gdb/symm-xdep.c deleted file mode 100644 index 28713079aee..00000000000 --- a/gdb/symm-xdep.c +++ /dev/null @@ -1,448 +0,0 @@ -/* Sequent Symmetry host interface, for GDB when running under Unix. - Copyright (C) 1986, 1987, 1989, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* FIXME, some 387-specific items of use taken from i387-tdep.c -- ought to be - merged back in. */ - -#include -#include "defs.h" -#include "param.h" -#include "frame.h" -#include "inferior.h" -#include "symtab.h" - -#include -#include -#include -#include -#include -#include -#include "gdbcore.h" -#include -#include -#define TERMINAL struct sgttyb - -extern void print_387_control_word (); -extern void print_387_status_word (); -extern void i387_to_double (from, to); - -store_inferior_registers(regno) -int regno; -{ - struct pt_regset regs; - int reg_tmp, i; - extern char registers[]; - -#if 0 - /* PREPARE_TO_STORE deals with this. */ - if (-1 == regno) - { -#endif - regs.pr_eax = *(int *)®isters[REGISTER_BYTE(0)]; - regs.pr_ebx = *(int *)®isters[REGISTER_BYTE(5)]; - regs.pr_ecx = *(int *)®isters[REGISTER_BYTE(2)]; - regs.pr_edx = *(int *)®isters[REGISTER_BYTE(1)]; - regs.pr_esi = *(int *)®isters[REGISTER_BYTE(6)]; - regs.pr_edi = *(int *)®isters[REGISTER_BYTE(7)]; - regs.pr_esp = *(int *)®isters[REGISTER_BYTE(14)]; - regs.pr_ebp = *(int *)®isters[REGISTER_BYTE(15)]; - regs.pr_eip = *(int *)®isters[REGISTER_BYTE(16)]; - regs.pr_flags = *(int *)®isters[REGISTER_BYTE(17)]; - for (i = 0; i < 31; i++) { - regs.pr_fpa.fpa_regs[i] = - *(int *)®isters[REGISTER_BYTE(FP1_REGNUM+i)]; - } -#if 0 - } - else - { - reg_tmp = *(int *)®isters[REGISTER_BYTE(regno)]; - ptrace(XPT_RREGS, inferior_pid, ®s, 0); - switch (regno) - { - case 0: - regs.pr_eax = *(int *)®isters[REGISTER_BYTE(0)]; - break; - case 5: - regs.pr_ebx = *(int *)®isters[REGISTER_BYTE(5)]; - break; - case 2: - regs.pr_ecx = *(int *)®isters[REGISTER_BYTE(2)]; - break; - case 1: - regs.pr_edx = *(int *)®isters[REGISTER_BYTE(1)]; - break; - case 6: - regs.pr_esi = *(int *)®isters[REGISTER_BYTE(6)]; - break; - case 7: - regs.pr_edi = *(int *)®isters[REGISTER_BYTE(7)]; - break; - case 15: - regs.pr_ebp = *(int *)®isters[REGISTER_BYTE(15)]; - break; - case 14: - regs.pr_esp = *(int *)®isters[REGISTER_BYTE(14)]; - break; - case 16: - regs.pr_eip = *(int *)®isters[REGISTER_BYTE(16)]; - break; - case 17: - regs.pr_flags = *(int *)®isters[REGISTER_BYTE(17)]; - break; - } - } -#endif /* 0 */ - ptrace(XPT_WREGS, inferior_pid, ®s, 0); -} - -void -fetch_inferior_registers() -{ - int i; - struct pt_regset regs; - extern char registers[]; - - registers_fetched (); - - ptrace(XPT_RREGS, inferior_pid, ®s, 0); - *(int *)®isters[REGISTER_BYTE(0)] = regs.pr_eax; - *(int *)®isters[REGISTER_BYTE(5)] = regs.pr_ebx; - *(int *)®isters[REGISTER_BYTE(2)] = regs.pr_ecx; - *(int *)®isters[REGISTER_BYTE(1)] = regs.pr_edx; - *(int *)®isters[REGISTER_BYTE(6)] = regs.pr_esi; - *(int *)®isters[REGISTER_BYTE(7)] = regs.pr_edi; - *(int *)®isters[REGISTER_BYTE(15)] = regs.pr_ebp; - *(int *)®isters[REGISTER_BYTE(14)] = regs.pr_esp; - *(int *)®isters[REGISTER_BYTE(16)] = regs.pr_eip; - *(int *)®isters[REGISTER_BYTE(17)] = regs.pr_flags; - for (i = 0; i < FPA_NREGS; i++) { - *(int *)®isters[REGISTER_BYTE(FP1_REGNUM+i)] = regs.pr_fpa.fpa_regs[i]; - } - bcopy(regs.pr_fpu.fpu_stack[0], ®isters[REGISTER_BYTE(3)], 10); - bcopy(regs.pr_fpu.fpu_stack[1], ®isters[REGISTER_BYTE(4)], 10); - bcopy(regs.pr_fpu.fpu_stack[2], ®isters[REGISTER_BYTE(8)], 10); - bcopy(regs.pr_fpu.fpu_stack[3], ®isters[REGISTER_BYTE(9)], 10); - bcopy(regs.pr_fpu.fpu_stack[4], ®isters[REGISTER_BYTE(10)], 10); - bcopy(regs.pr_fpu.fpu_stack[5], ®isters[REGISTER_BYTE(11)], 10); - bcopy(regs.pr_fpu.fpu_stack[6], ®isters[REGISTER_BYTE(12)], 10); - bcopy(regs.pr_fpu.fpu_stack[7], ®isters[REGISTER_BYTE(13)], 10); -} - - -/* Work with core dump and executable files, for GDB. - This code would be in core.c if it weren't machine-dependent. */ - -#include "gdbcore.h" - -void -core_file_command (filename, from_tty) - char *filename; - int from_tty; -{ - int val; - extern char registers[]; - - /* Discard all vestiges of any previous core file - and mark data and stack spaces as empty. */ - - if (corefile) - free (corefile); - corefile = 0; - - if (corechan >= 0) - close (corechan); - corechan = -1; - - data_start = 0; - data_end = 0; - stack_start = STACK_END_ADDR; - stack_end = STACK_END_ADDR; - - /* Now, if a new core file was specified, open it and digest it. */ - - if (filename) - { - filename = tilde_expand (filename); - make_cleanup (free, filename); - - if (have_inferior_p ()) - error ("To look at a core file, you must kill the inferior with \"kill\"."); - corechan = open (filename, O_RDONLY, 0); - if (corechan < 0) - perror_with_name (filename); - /* 4.2-style (and perhaps also sysV-style) core dump file. */ - { - struct user u; - int reg_offset; - - val = myread (corechan, &u, sizeof u); - if (val < 0) - perror_with_name (filename); - data_start = exec_data_start; - - data_end = data_start + NBPG * (u.u_dsize - u.u_tsize); - stack_start = stack_end - NBPG * u.u_ssize; - data_offset = NBPG * UPAGES; - stack_offset = ctob(UPAGES + u.u_dsize - u.u_tsize); - reg_offset = (int) u.u_ar0 - KERNEL_U_ADDR; -printf("u.u_tsize= %#x, u.u_dsize= %#x, u.u_ssize= %#x, stack_off= %#x\n", - u.u_tsize, u.u_dsize, u.u_ssize, stack_offset); - - core_aouthdr.a_magic = 0; - - /* Read the register values out of the core file and store - them where `read_register' will find them. */ - - { - register int regno; - - for (regno = 0; regno < NUM_REGS; regno++) - { - char buf[MAX_REGISTER_RAW_SIZE]; - - val = lseek (corechan, register_addr (regno, reg_offset), 0); - if (val < 0) - perror_with_name (filename); - - val = myread (corechan, buf, sizeof buf); - if (val < 0) - perror_with_name (filename); - supply_register (regno, buf); - } - } - } - if (filename[0] == '/') - corefile = savestring (filename, strlen (filename)); - else - { - corefile = concat (current_directory, "/", filename, NULL); - } - - set_current_frame(create_new_frame(read_register(FP_REGNUM), - read_pc())); -/* set_current_frame (read_register (FP_REGNUM));*/ - select_frame (get_current_frame (), 0); - validate_files (); - } - else if (from_tty) - printf ("No core file now.\n"); -} - -/* FIXME: This should be merged with i387-tdep.c as well. */ -static -print_fpu_status(ep) -struct pt_regset ep; -{ - int i; - int bothstatus; - int top; - int fpreg; - unsigned char *p; - - printf("80387:"); - if (ep.pr_fpu.fpu_ip == 0) { - printf(" not in use.\n"); - return; - } else { - printf("\n"); - } - if (ep.pr_fpu.fpu_status != 0) { - print_387_status_word (ep.pr_fpu.fpu_status); - } - print_387_control_word (ep.pr_fpu.fpu_control); - printf ("last exception: "); - printf ("opcode 0x%x; ", ep.pr_fpu.fpu_rsvd4); - printf ("pc 0x%x:0x%x; ", ep.pr_fpu.fpu_cs, ep.pr_fpu.fpu_ip); - printf ("operand 0x%x:0x%x\n", ep.pr_fpu.fpu_data_offset, ep.pr_fpu.fpu_op_sel); - - top = (ep.pr_fpu.fpu_status >> 11) & 7; - - printf ("regno tag msb lsb value\n"); - for (fpreg = 7; fpreg >= 0; fpreg--) - { - double val; - - printf ("%s %d: ", fpreg == top ? "=>" : " ", fpreg); - - switch ((ep.pr_fpu.fpu_tag >> (fpreg * 2)) & 3) - { - case 0: printf ("valid "); break; - case 1: printf ("zero "); break; - case 2: printf ("trap "); break; - case 3: printf ("empty "); break; - } - for (i = 9; i >= 0; i--) - printf ("%02x", ep.pr_fpu.fpu_stack[fpreg][i]); - - i387_to_double (ep.pr_fpu.fpu_stack[fpreg], (char *)&val); - printf (" %g\n", val); - } - if (ep.pr_fpu.fpu_rsvd1) - printf ("warning: rsvd1 is 0x%x\n", ep.pr_fpu.fpu_rsvd1); - if (ep.pr_fpu.fpu_rsvd2) - printf ("warning: rsvd2 is 0x%x\n", ep.pr_fpu.fpu_rsvd2); - if (ep.pr_fpu.fpu_rsvd3) - printf ("warning: rsvd3 is 0x%x\n", ep.pr_fpu.fpu_rsvd3); - if (ep.pr_fpu.fpu_rsvd5) - printf ("warning: rsvd5 is 0x%x\n", ep.pr_fpu.fpu_rsvd5); -} - - -print_1167_control_word(pcr) -unsigned int pcr; - -{ - int pcr_tmp; - - pcr_tmp = pcr & FPA_PCR_MODE; - printf("\tMODE= %#x; RND= %#x ", pcr_tmp, pcr_tmp & 12); - switch (pcr_tmp & 12) { - case 0: - printf("RN (Nearest Value)"); - break; - case 1: - printf("RZ (Zero)"); - break; - case 2: - printf("RP (Positive Infinity)"); - break; - case 3: - printf("RM (Negative Infinity)"); - break; - } - printf("; IRND= %d ", pcr_tmp & 2); - if (0 == pcr_tmp & 2) { - printf("(same as RND)\n"); - } else { - printf("(toward zero)\n"); - } - pcr_tmp = pcr & FPA_PCR_EM; - printf("\tEM= %#x", pcr_tmp); - if (pcr_tmp & FPA_PCR_EM_DM) printf(" DM"); - if (pcr_tmp & FPA_PCR_EM_UOM) printf(" UOM"); - if (pcr_tmp & FPA_PCR_EM_PM) printf(" PM"); - if (pcr_tmp & FPA_PCR_EM_UM) printf(" UM"); - if (pcr_tmp & FPA_PCR_EM_OM) printf(" OM"); - if (pcr_tmp & FPA_PCR_EM_ZM) printf(" ZM"); - if (pcr_tmp & FPA_PCR_EM_IM) printf(" IM"); - printf("\n"); - pcr_tmp = FPA_PCR_CC; - printf("\tCC= %#x", pcr_tmp); - if (pcr_tmp & FPA_PCR_20MHZ) printf(" 20MHZ"); - if (pcr_tmp & FPA_PCR_CC_Z) printf(" Z"); - if (pcr_tmp & FPA_PCR_CC_C2) printf(" C2"); - if (pcr_tmp & FPA_PCR_CC_C1) printf(" C1"); - switch (pcr_tmp) { - case FPA_PCR_CC_Z: - printf(" (Equal)"); - break; - case FPA_PCR_CC_C1: - printf(" (Less than)"); - break; - case 0: - printf(" (Greater than)"); - break; - case FPA_PCR_CC_Z | FPA_PCR_CC_C1 | FPA_PCR_CC_C2: - printf(" (Unordered)"); - break; - default: - printf(" (Undefined)"); - break; - } - printf("\n"); - pcr_tmp = pcr & FPA_PCR_AE; - printf("\tAE= %#x", pcr_tmp); - if (pcr_tmp & FPA_PCR_AE_DE) printf(" DE"); - if (pcr_tmp & FPA_PCR_AE_UOE) printf(" UOE"); - if (pcr_tmp & FPA_PCR_AE_PE) printf(" PE"); - if (pcr_tmp & FPA_PCR_AE_UE) printf(" UE"); - if (pcr_tmp & FPA_PCR_AE_OE) printf(" OE"); - if (pcr_tmp & FPA_PCR_AE_ZE) printf(" ZE"); - if (pcr_tmp & FPA_PCR_AE_EE) printf(" EE"); - if (pcr_tmp & FPA_PCR_AE_IE) printf(" IE"); - printf("\n"); -} - -print_1167_regs(regs) -long regs[FPA_NREGS]; - -{ - int i; - - union { - double d; - long l[2]; - } xd; - union { - float f; - long l; - } xf; - - - for (i = 0; i < FPA_NREGS; i++) { - xf.l = regs[i]; - printf("%%fp%d: raw= %#x, single= %f", i+1, regs[i], xf.f); - if (!(i & 1)) { - printf("\n"); - } else { - xd.l[1] = regs[i]; - xd.l[0] = regs[i+1]; - printf(", double= %f\n", xd.d); - } - } -} - -print_fpa_status(ep) -struct pt_regset ep; - -{ - - printf("WTL 1167:"); - if (ep.pr_fpa.fpa_pcr !=0) { - printf("\n"); - print_1167_control_word(ep.pr_fpa.fpa_pcr); - print_1167_regs(ep.pr_fpa.fpa_regs); - } else { - printf(" not in use.\n"); - } -} - -i386_float_info () -{ - char ubuf[UPAGES*NBPG]; - struct pt_regset regset; - extern int corechan; - - if (have_inferior_p()) { - call_ptrace(XPT_RREGS, inferior_pid, ®set, 0); - } else { - if (lseek (corechan, 0, 0) < 0) { - perror ("seek on core file"); - } - if (myread (corechan, ubuf, UPAGES*NBPG) < 0) { - perror ("read on core file"); - } - /* only interested in the floating point registers */ - regset.pr_fpu = ((struct user *) ubuf)->u_fpusave; - regset.pr_fpa = ((struct user *) ubuf)->u_fpasave; - } - print_fpu_status(regset); - print_fpa_status(regset); -} diff --git a/gdb/symmetry-tdep.c b/gdb/symmetry-tdep.c deleted file mode 100755 index aba21c3c432..00000000000 --- a/gdb/symmetry-tdep.c +++ /dev/null @@ -1,494 +0,0 @@ -/* Sequent Symmetry target interface, for GDB when running under Unix. - Copyright (C) 1986, 1987, 1989, 1991 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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 1, or (at your option) -any later version. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* many 387-specific items of use taken from i386-dep.c */ - -#include -#include "defs.h" -#include "param.h" -#include "frame.h" -#include "inferior.h" -#include "symtab.h" - -#include -#include -#include -#include -#include -#include -#include "gdbcore.h" -#include - -static long i386_get_frame_setup (); -static i386_follow_jump (); - -#include -#define TERMINAL struct sgttyb - -exec_file_command (filename, from_tty) - char *filename; - int from_tty; -{ - int val; - - /* Eliminate all traces of old exec file. - Mark text segment as empty. */ - - if (execfile) - free (execfile); - execfile = 0; - data_start = 0; - data_end -= exec_data_start; - text_start = 0; - text_end = 0; - exec_data_start = 0; - exec_data_end = 0; - if (execchan >= 0) - close (execchan); - execchan = -1; - - /* Now open and digest the file the user requested, if any. */ - - if (filename) - { - filename = tilde_expand (filename); - make_cleanup (free, filename); - - execchan = openp (getenv ("PATH"), 1, filename, O_RDONLY, 0, - &execfile); - if (execchan < 0) - perror_with_name (filename); - -#ifdef COFF_FORMAT - { - int aout_hdrsize; - int num_sections; - - if (read_file_hdr (execchan, &file_hdr) < 0) - error ("\"%s\": not in executable format.", execfile); - - aout_hdrsize = file_hdr.f_opthdr; - num_sections = file_hdr.f_nscns; - - if (read_aout_hdr (execchan, &exec_aouthdr, aout_hdrsize) < 0) - error ("\"%s\": can't read optional aouthdr", execfile); - - if (read_section_hdr (execchan, _TEXT, &text_hdr, num_sections, - aout_hdrsize) < 0) - error ("\"%s\": can't read text section header", execfile); - - if (read_section_hdr (execchan, _DATA, &data_hdr, num_sections, - aout_hdrsize) < 0) - error ("\"%s\": can't read data section header", execfile); - - text_start = exec_aouthdr.text_start; - text_end = text_start + exec_aouthdr.tsize; - text_offset = text_hdr.s_scnptr; - exec_data_start = exec_aouthdr.data_start; - exec_data_end = exec_data_start + exec_aouthdr.dsize; - exec_data_offset = data_hdr.s_scnptr; - data_start = exec_data_start; - data_end += exec_data_start; - exec_mtime = file_hdr.f_timdat; - } -#else /* not COFF_FORMAT */ - { - struct stat st_exec; - - val = myread (execchan, &exec_aouthdr, sizeof (AOUTHDR)); - - if (val < 0) - perror_with_name (filename); - - text_start = N_ADDRADJ(exec_aouthdr); - exec_data_start = round(exec_aouthdr.a_text, NBPG*CLSIZE); - text_offset = N_TXTOFF (exec_aouthdr); - exec_data_offset = N_TXTOFF (exec_aouthdr) + exec_aouthdr.a_text; - text_end = exec_aouthdr.a_text; - exec_data_end = exec_data_start + exec_aouthdr.a_data; - data_start = exec_data_start; - data_end = data_start + exec_aouthdr.a_data; - exec_data_offset = N_TXTOFF(exec_aouthdr); - fstat (execchan, &st_exec); - exec_mtime = st_exec.st_mtime; - } -#endif /* not COFF_FORMAT */ - - validate_files (); - } - else if (from_tty) - printf ("No exec file now.\n"); - - /* Tell display code (if any) about the changed file name. */ - if (exec_file_display_hook) - (*exec_file_display_hook) (filename); -} - -/* rounds 'one' up to divide evenly by 'two' */ - -int -round(one,two) -register int one, two; - -{ - register int temp; - temp = (one/two)*two; - if (one != temp) { - temp += two; - } - return temp; -} - - -static CORE_ADDR codestream_next_addr; -static CORE_ADDR codestream_addr; -static unsigned char codestream_buf[sizeof (int)]; -static int codestream_off; -static int codestream_cnt; - -#define codestream_tell() (codestream_addr + codestream_off) -#define codestream_peek() (codestream_cnt == 0 ? \ - codestream_fill(1): codestream_buf[codestream_off]) -#define codestream_get() (codestream_cnt-- == 0 ? \ - codestream_fill(0) : codestream_buf[codestream_off++]) - - -static unsigned char -codestream_fill (peek_flag) -{ - codestream_addr = codestream_next_addr; - codestream_next_addr += sizeof (int); - codestream_off = 0; - codestream_cnt = sizeof (int); - read_memory (codestream_addr, - (unsigned char *)codestream_buf, - sizeof (int)); - - if (peek_flag) - return (codestream_peek()); - else - return (codestream_get()); -} - -static void -codestream_seek (place) -{ - codestream_next_addr = place & -sizeof (int); - codestream_cnt = 0; - codestream_fill (1); - while (codestream_tell() != place) - codestream_get (); -} - -static void -codestream_read (buf, count) - unsigned char *buf; -{ - unsigned char *p; - int i; - p = buf; - for (i = 0; i < count; i++) - *p++ = codestream_get (); -} - -/* - * Following macro translates i386 opcode register numbers to Symmetry - * register numbers. This is used by FRAME_FIND_SAVED_REGS. - * - * %eax %ecx %edx %ebx %esp %ebp %esi %edi - * i386 0 1 2 3 4 5 6 7 - * Symmetry 0 2 1 5 14 15 6 7 - * - */ -#define I386_REGNO_TO_SYMMETRY(n) \ -((n)==0?0 :(n)==1?2 :(n)==2?1 :(n)==3?5 :(n)==4?14 :(n)==5?15 :(n)) - -/* from i386-dep.c */ -i386_frame_find_saved_regs (fip, fsrp) - struct frame_info *fip; - struct frame_saved_regs *fsrp; -{ - unsigned long locals; - unsigned char *p; - unsigned char op; - CORE_ADDR dummy_bottom; - CORE_ADDR adr; - int i; - - bzero (fsrp, sizeof *fsrp); - - /* if frame is the end of a dummy, compute where the - * beginning would be - */ - dummy_bottom = fip->frame - 4 - NUM_REGS*4 - CALL_DUMMY_LENGTH; - - /* check if the PC is in the stack, in a dummy frame */ - if (dummy_bottom <= fip->pc && fip->pc <= fip->frame) - { - /* all regs were saved by push_call_dummy () */ - adr = fip->frame - 4; - for (i = 0; i < NUM_REGS; i++) - { - fsrp->regs[i] = adr; - adr -= 4; - } - return; - } - - locals = i386_get_frame_setup (get_pc_function_start (fip->pc)); - - if (locals >= 0) - { - adr = fip->frame - 4 - locals; - for (i = 0; i < 8; i++) - { - op = codestream_get (); - if (op < 0x50 || op > 0x57) - break; - fsrp->regs[I386_REGNO_TO_SYMMETRY(op - 0x50)] = adr; - adr -= 4; - } - } - - fsrp->regs[PC_REGNUM] = fip->frame + 4; - fsrp->regs[FP_REGNUM] = fip->frame; -} - -static long -i386_get_frame_setup (pc) -{ - unsigned char op; - - codestream_seek (pc); - - i386_follow_jump (); - - op = codestream_get (); - - if (op == 0x58) /* popl %eax */ - { - /* - * this function must start with - * - * popl %eax 0x58 - * xchgl %eax, (%esp) 0x87 0x04 0x24 - * or xchgl %eax, 0(%esp) 0x87 0x44 0x24 0x00 - * - * (the system 5 compiler puts out the second xchg - * inst, and the assembler doesn't try to optimize it, - * so the 'sib' form gets generated) - * - * this sequence is used to get the address of the return - * buffer for a function that returns a structure - */ - int pos; - unsigned char buf[4]; - static unsigned char proto1[3] = { 0x87,0x04,0x24 }; - static unsigned char proto2[4] = { 0x87,0x44,0x24,0x00 }; - pos = codestream_tell (); - codestream_read (buf, 4); - if (bcmp (buf, proto1, 3) == 0) - pos += 3; - else if (bcmp (buf, proto2, 4) == 0) - pos += 4; - - codestream_seek (pos); - op = codestream_get (); /* update next opcode */ - } - - if (op == 0x55) /* pushl %esp */ - { - if (codestream_get () != 0x8b) /* movl %esp, %ebp (2bytes) */ - return (-1); - if (codestream_get () != 0xec) - return (-1); - /* - * check for stack adjustment - * - * subl $XXX, %esp - * - * note: you can't subtract a 16 bit immediate - * from a 32 bit reg, so we don't have to worry - * about a data16 prefix - */ - op = codestream_peek (); - if (op == 0x83) /* subl with 8 bit immed */ - { - codestream_get (); - if (codestream_get () != 0xec) - return (-1); - /* subl with signed byte immediate - * (though it wouldn't make sense to be negative) - */ - return (codestream_get()); - } - else if (op == 0x81) /* subl with 32 bit immed */ - { - int locals; - if (codestream_get () != 0xec) - return (-1); - /* subl with 32 bit immediate */ - codestream_read ((unsigned char *)&locals, 4); - return (locals); - } - else - { - return (0); - } - } - else if (op == 0xc8) - { - /* enter instruction: arg is 16 unsigned immed */ - unsigned short slocals; - codestream_read ((unsigned char *)&slocals, 2); - codestream_get (); /* flush final byte of enter instruction */ - return (slocals); - } - return (-1); -} - -/* next instruction is a jump, move to target */ -static -i386_follow_jump () -{ - int long_delta; - short short_delta; - char byte_delta; - int data16; - int pos; - - pos = codestream_tell (); - - data16 = 0; - if (codestream_peek () == 0x66) - { - codestream_get (); - data16 = 1; - } - - switch (codestream_get ()) - { - case 0xe9: - /* relative jump: if data16 == 0, disp32, else disp16 */ - if (data16) - { - codestream_read ((unsigned char *)&short_delta, 2); - pos += short_delta + 3; /* include size of jmp inst */ - } - else - { - codestream_read ((unsigned char *)&long_delta, 4); - pos += long_delta + 5; - } - break; - case 0xeb: - /* relative jump, disp8 (ignore data16) */ - codestream_read ((unsigned char *)&byte_delta, 1); - pos += byte_delta + 2; - break; - } - codestream_seek (pos + data16); -} - -/* return pc of first real instruction */ -/* from i386-dep.c */ - -i386_skip_prologue (pc) -{ - unsigned char op; - int i; - - if (i386_get_frame_setup (pc) < 0) - return (pc); - - /* found valid frame setup - codestream now points to - * start of push instructions for saving registers - */ - - /* skip over register saves */ - for (i = 0; i < 8; i++) - { - op = codestream_peek (); - /* break if not pushl inst */ - if (op < 0x50 || op > 0x57) - break; - codestream_get (); - } - - i386_follow_jump (); - - return (codestream_tell ()); -} - -symmetry_extract_return_value(type, regbuf, valbuf) - struct type *type; - char *regbuf; - char *valbuf; -{ - union { - double d; - int l[2]; - } xd; - int i; - float f; - - if (TYPE_CODE_FLT == TYPE_CODE(type)) { - for (i = 0; i < misc_function_count; i++) { - if (!strcmp(misc_function_vector[i].name, "1167_flt")) - break; - } - if (i < misc_function_count) { - /* found "1167_flt" means 1167, %fp2-%fp3 */ - /* float & double; 19= %fp2, 20= %fp3 */ - /* no single precision on 1167 */ - xd.l[1] = *((int *)®buf[REGISTER_BYTE(19)]); - xd.l[0] = *((int *)®buf[REGISTER_BYTE(20)]); - switch (TYPE_LENGTH(type)) { - case 4: - f = (float) xd.d; - bcopy(&f, valbuf, TYPE_LENGTH(type)); - break; - case 8: - bcopy(&xd.d, valbuf, TYPE_LENGTH(type)); - break; - default: - error("Unknown floating point size"); - break; - } - } else { - /* 387 %st(0), gcc uses this */ - i387_to_double(((int *)®buf[REGISTER_BYTE(3)]), - &xd.d); - switch (TYPE_LENGTH(type)) { - case 4: /* float */ - f = (float) xd.d; - bcopy(&f, valbuf, 4); - break; - case 8: /* double */ - bcopy(&xd.d, valbuf, 8); - break; - default: - error("Unknown floating point size"); - break; - } - } - } else { - bcopy (regbuf, valbuf, TYPE_LENGTH (type)); - } -} diff --git a/gdb/symmetry-xdep.c b/gdb/symmetry-xdep.c deleted file mode 100755 index 34496789aca..00000000000 --- a/gdb/symmetry-xdep.c +++ /dev/null @@ -1,557 +0,0 @@ -/* Sequent Symmetry host interface, for GDB when running under Unix. - Copyright (C) 1986, 1987, 1989, 1991 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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 1, or (at your option) -any later version. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* many 387-specific items of use taken from i386-dep.c */ - -#include -#include "defs.h" -#include "param.h" -#include "frame.h" -#include "inferior.h" -#include "symtab.h" - -#include -#include -#include -#include -#include -#include -#include "gdbcore.h" -#include - -static long i386_get_frame_setup (); -static i386_follow_jump (); - -#include -#define TERMINAL struct sgttyb - -store_inferior_registers(regno) -int regno; -{ - struct pt_regset regs; - int reg_tmp, i; - extern char registers[]; - -#if 0 - /* PREPARE_TO_STORE deals with this. */ - if (-1 == regno) - { -#endif - regs.pr_eax = *(int *)®isters[REGISTER_BYTE(0)]; - regs.pr_ebx = *(int *)®isters[REGISTER_BYTE(5)]; - regs.pr_ecx = *(int *)®isters[REGISTER_BYTE(2)]; - regs.pr_edx = *(int *)®isters[REGISTER_BYTE(1)]; - regs.pr_esi = *(int *)®isters[REGISTER_BYTE(6)]; - regs.pr_edi = *(int *)®isters[REGISTER_BYTE(7)]; - regs.pr_esp = *(int *)®isters[REGISTER_BYTE(14)]; - regs.pr_ebp = *(int *)®isters[REGISTER_BYTE(15)]; - regs.pr_eip = *(int *)®isters[REGISTER_BYTE(16)]; - regs.pr_flags = *(int *)®isters[REGISTER_BYTE(17)]; - for (i = 0; i < 31; i++) { - regs.pr_fpa.fpa_regs[i] = - *(int *)®isters[REGISTER_BYTE(FP1_REGNUM+i)]; - } -#if 0 - } - else - { - reg_tmp = *(int *)®isters[REGISTER_BYTE(regno)]; - ptrace(XPT_RREGS, inferior_pid, ®s, 0); - switch (regno) - { - case 0: - regs.pr_eax = *(int *)®isters[REGISTER_BYTE(0)]; - break; - case 5: - regs.pr_ebx = *(int *)®isters[REGISTER_BYTE(5)]; - break; - case 2: - regs.pr_ecx = *(int *)®isters[REGISTER_BYTE(2)]; - break; - case 1: - regs.pr_edx = *(int *)®isters[REGISTER_BYTE(1)]; - break; - case 6: - regs.pr_esi = *(int *)®isters[REGISTER_BYTE(6)]; - break; - case 7: - regs.pr_edi = *(int *)®isters[REGISTER_BYTE(7)]; - break; - case 15: - regs.pr_ebp = *(int *)®isters[REGISTER_BYTE(15)]; - break; - case 14: - regs.pr_esp = *(int *)®isters[REGISTER_BYTE(14)]; - break; - case 16: - regs.pr_eip = *(int *)®isters[REGISTER_BYTE(16)]; - break; - case 17: - regs.pr_flags = *(int *)®isters[REGISTER_BYTE(17)]; - break; - } - } -#endif /* 0 */ - ptrace(XPT_WREGS, inferior_pid, ®s, 0); -} - -void -fetch_inferior_registers() -{ - int i; - struct pt_regset regs; - extern char registers[]; - - registers_fetched (); - - ptrace(XPT_RREGS, inferior_pid, ®s, 0); - *(int *)®isters[REGISTER_BYTE(0)] = regs.pr_eax; - *(int *)®isters[REGISTER_BYTE(5)] = regs.pr_ebx; - *(int *)®isters[REGISTER_BYTE(2)] = regs.pr_ecx; - *(int *)®isters[REGISTER_BYTE(1)] = regs.pr_edx; - *(int *)®isters[REGISTER_BYTE(6)] = regs.pr_esi; - *(int *)®isters[REGISTER_BYTE(7)] = regs.pr_edi; - *(int *)®isters[REGISTER_BYTE(15)] = regs.pr_ebp; - *(int *)®isters[REGISTER_BYTE(14)] = regs.pr_esp; - *(int *)®isters[REGISTER_BYTE(16)] = regs.pr_eip; - *(int *)®isters[REGISTER_BYTE(17)] = regs.pr_flags; - for (i = 0; i < FPA_NREGS; i++) { - *(int *)®isters[REGISTER_BYTE(FP1_REGNUM+i)] = regs.pr_fpa.fpa_regs[i]; - } - bcopy(regs.pr_fpu.fpu_stack[0], ®isters[REGISTER_BYTE(3)], 10); - bcopy(regs.pr_fpu.fpu_stack[1], ®isters[REGISTER_BYTE(4)], 10); - bcopy(regs.pr_fpu.fpu_stack[2], ®isters[REGISTER_BYTE(8)], 10); - bcopy(regs.pr_fpu.fpu_stack[3], ®isters[REGISTER_BYTE(9)], 10); - bcopy(regs.pr_fpu.fpu_stack[4], ®isters[REGISTER_BYTE(10)], 10); - bcopy(regs.pr_fpu.fpu_stack[5], ®isters[REGISTER_BYTE(11)], 10); - bcopy(regs.pr_fpu.fpu_stack[6], ®isters[REGISTER_BYTE(12)], 10); - bcopy(regs.pr_fpu.fpu_stack[7], ®isters[REGISTER_BYTE(13)], 10); -} - - -/* Work with core dump and executable files, for GDB. - This code would be in core.c if it weren't machine-dependent. */ - -#include "gdbcore.h" - -void -core_file_command (filename, from_tty) - char *filename; - int from_tty; -{ - int val; - extern char registers[]; - - /* Discard all vestiges of any previous core file - and mark data and stack spaces as empty. */ - - if (corefile) - free (corefile); - corefile = 0; - - if (corechan >= 0) - close (corechan); - corechan = -1; - - data_start = 0; - data_end = 0; - stack_start = STACK_END_ADDR; - stack_end = STACK_END_ADDR; - - /* Now, if a new core file was specified, open it and digest it. */ - - if (filename) - { - filename = tilde_expand (filename); - make_cleanup (free, filename); - - if (have_inferior_p ()) - error ("To look at a core file, you must kill the inferior with \"kill\"."); - corechan = open (filename, O_RDONLY, 0); - if (corechan < 0) - perror_with_name (filename); - /* 4.2-style (and perhaps also sysV-style) core dump file. */ - { - struct user u; - int reg_offset; - - val = myread (corechan, &u, sizeof u); - if (val < 0) - perror_with_name (filename); - data_start = exec_data_start; - - data_end = data_start + NBPG * (u.u_dsize - u.u_tsize); - stack_start = stack_end - NBPG * u.u_ssize; - data_offset = NBPG * UPAGES; - stack_offset = ctob(UPAGES + u.u_dsize - u.u_tsize); - reg_offset = (int) u.u_ar0 - KERNEL_U_ADDR; -printf("u.u_tsize= %#x, u.u_dsize= %#x, u.u_ssize= %#x, stack_off= %#x\n", - u.u_tsize, u.u_dsize, u.u_ssize, stack_offset); - - core_aouthdr.a_magic = 0; - - /* Read the register values out of the core file and store - them where `read_register' will find them. */ - - { - register int regno; - - for (regno = 0; regno < NUM_REGS; regno++) - { - char buf[MAX_REGISTER_RAW_SIZE]; - - val = lseek (corechan, register_addr (regno, reg_offset), 0); - if (val < 0) - perror_with_name (filename); - - val = myread (corechan, buf, sizeof buf); - if (val < 0) - perror_with_name (filename); - supply_register (regno, buf); - } - } - } - if (filename[0] == '/') - corefile = savestring (filename, strlen (filename)); - else - { - corefile = concat (current_directory, "/", filename); - } - - set_current_frame(create_new_frame(read_register(FP_REGNUM), - read_pc())); -/* set_current_frame (read_register (FP_REGNUM));*/ - select_frame (get_current_frame (), 0); - validate_files (); - } - else if (from_tty) - printf ("No core file now.\n"); -} - -/* from i386-dep.c */ -static -print_387_control_word (control) -unsigned short control; -{ - printf ("control 0x%04x: ", control); - printf ("compute to "); - switch ((control >> 8) & 3) - { - case 0: printf ("24 bits; "); break; - case 1: printf ("(bad); "); break; - case 2: printf ("53 bits; "); break; - case 3: printf ("64 bits; "); break; - } - printf ("round "); - switch ((control >> 10) & 3) - { - case 0: printf ("NEAREST; "); break; - case 1: printf ("DOWN; "); break; - case 2: printf ("UP; "); break; - case 3: printf ("CHOP; "); break; - } - if (control & 0x3f) - { - printf ("mask:"); - if (control & 0x0001) printf (" INVALID"); - if (control & 0x0002) printf (" DENORM"); - if (control & 0x0004) printf (" DIVZ"); - if (control & 0x0008) printf (" OVERF"); - if (control & 0x0010) printf (" UNDERF"); - if (control & 0x0020) printf (" LOS"); - printf (";"); - } - printf ("\n"); - if (control & 0xe080) printf ("warning: reserved bits on 0x%x\n", - control & 0xe080); -} - -static -print_387_status_word (status) - unsigned short status; -{ - printf ("status %#04x: ", status); - if (status & 0xff) { - printf ("exceptions:"); /* exception names match */ - if (status & 0x0001) printf (" FLTINV"); - if (status & 0x0002) printf (" FLTDEN"); - if (status & 0x0004) printf (" FLTDIV"); - if (status & 0x0008) printf (" FLTOVF"); - if (status & 0x0010) printf (" FLTUND"); - if (status & 0x0020) printf (" FLTPRE"); - if (status & 0x0040) printf (" FLTSTK"); - printf ("; "); - } - printf ("flags: %d%d%d%d; ", - (status & 0x4000) != 0, - (status & 0x0400) != 0, - (status & 0x0200) != 0, - (status & 0x0100) != 0); - - printf ("top %d\n", (status >> 11) & 7); -} - -static -print_fpu_status(ep) -struct pt_regset ep; - -{ - int i; - int bothstatus; - int top; - int fpreg; - unsigned char *p; - - printf("80387:"); - if (ep.pr_fpu.fpu_ip == 0) { - printf(" not in use.\n"); - return; - } else { - printf("\n"); - } - if (ep.pr_fpu.fpu_status != 0) { - print_387_status_word (ep.pr_fpu.fpu_status); - } - print_387_control_word (ep.pr_fpu.fpu_control); - printf ("last exception: "); - printf ("opcode 0x%x; ", ep.pr_fpu.fpu_rsvd4); - printf ("pc 0x%x:0x%x; ", ep.pr_fpu.fpu_cs, ep.pr_fpu.fpu_ip); - printf ("operand 0x%x:0x%x\n", ep.pr_fpu.fpu_data_offset, ep.pr_fpu.fpu_op_sel); - - top = (ep.pr_fpu.fpu_status >> 11) & 7; - - printf ("regno tag msb lsb value\n"); - for (fpreg = 7; fpreg >= 0; fpreg--) - { - double val; - - printf ("%s %d: ", fpreg == top ? "=>" : " ", fpreg); - - switch ((ep.pr_fpu.fpu_tag >> (fpreg * 2)) & 3) - { - case 0: printf ("valid "); break; - case 1: printf ("zero "); break; - case 2: printf ("trap "); break; - case 3: printf ("empty "); break; - } - for (i = 9; i >= 0; i--) - printf ("%02x", ep.pr_fpu.fpu_stack[fpreg][i]); - - i387_to_double (ep.pr_fpu.fpu_stack[fpreg], (char *)&val); - printf (" %g\n", val); - } - if (ep.pr_fpu.fpu_rsvd1) - printf ("warning: rsvd1 is 0x%x\n", ep.pr_fpu.fpu_rsvd1); - if (ep.pr_fpu.fpu_rsvd2) - printf ("warning: rsvd2 is 0x%x\n", ep.pr_fpu.fpu_rsvd2); - if (ep.pr_fpu.fpu_rsvd3) - printf ("warning: rsvd3 is 0x%x\n", ep.pr_fpu.fpu_rsvd3); - if (ep.pr_fpu.fpu_rsvd5) - printf ("warning: rsvd5 is 0x%x\n", ep.pr_fpu.fpu_rsvd5); -} - - -print_1167_control_word(pcr) -unsigned int pcr; - -{ - int pcr_tmp; - - pcr_tmp = pcr & FPA_PCR_MODE; - printf("\tMODE= %#x; RND= %#x ", pcr_tmp, pcr_tmp & 12); - switch (pcr_tmp & 12) { - case 0: - printf("RN (Nearest Value)"); - break; - case 1: - printf("RZ (Zero)"); - break; - case 2: - printf("RP (Positive Infinity)"); - break; - case 3: - printf("RM (Negative Infinity)"); - break; - } - printf("; IRND= %d ", pcr_tmp & 2); - if (0 == pcr_tmp & 2) { - printf("(same as RND)\n"); - } else { - printf("(toward zero)\n"); - } - pcr_tmp = pcr & FPA_PCR_EM; - printf("\tEM= %#x", pcr_tmp); - if (pcr_tmp & FPA_PCR_EM_DM) printf(" DM"); - if (pcr_tmp & FPA_PCR_EM_UOM) printf(" UOM"); - if (pcr_tmp & FPA_PCR_EM_PM) printf(" PM"); - if (pcr_tmp & FPA_PCR_EM_UM) printf(" UM"); - if (pcr_tmp & FPA_PCR_EM_OM) printf(" OM"); - if (pcr_tmp & FPA_PCR_EM_ZM) printf(" ZM"); - if (pcr_tmp & FPA_PCR_EM_IM) printf(" IM"); - printf("\n"); - pcr_tmp = FPA_PCR_CC; - printf("\tCC= %#x", pcr_tmp); - if (pcr_tmp & FPA_PCR_20MHZ) printf(" 20MHZ"); - if (pcr_tmp & FPA_PCR_CC_Z) printf(" Z"); - if (pcr_tmp & FPA_PCR_CC_C2) printf(" C2"); - if (pcr_tmp & FPA_PCR_CC_C1) printf(" C1"); - switch (pcr_tmp) { - case FPA_PCR_CC_Z: - printf(" (Equal)"); - break; - case FPA_PCR_CC_C1: - printf(" (Less than)"); - break; - case 0: - printf(" (Greater than)"); - break; - case FPA_PCR_CC_Z | FPA_PCR_CC_C1 | FPA_PCR_CC_C2: - printf(" (Unordered)"); - break; - default: - printf(" (Undefined)"); - break; - } - printf("\n"); - pcr_tmp = pcr & FPA_PCR_AE; - printf("\tAE= %#x", pcr_tmp); - if (pcr_tmp & FPA_PCR_AE_DE) printf(" DE"); - if (pcr_tmp & FPA_PCR_AE_UOE) printf(" UOE"); - if (pcr_tmp & FPA_PCR_AE_PE) printf(" PE"); - if (pcr_tmp & FPA_PCR_AE_UE) printf(" UE"); - if (pcr_tmp & FPA_PCR_AE_OE) printf(" OE"); - if (pcr_tmp & FPA_PCR_AE_ZE) printf(" ZE"); - if (pcr_tmp & FPA_PCR_AE_EE) printf(" EE"); - if (pcr_tmp & FPA_PCR_AE_IE) printf(" IE"); - printf("\n"); -} - -print_1167_regs(regs) -long regs[FPA_NREGS]; - -{ - int i; - - union { - double d; - long l[2]; - } xd; - union { - float f; - long l; - } xf; - - - for (i = 0; i < FPA_NREGS; i++) { - xf.l = regs[i]; - printf("%%fp%d: raw= %#x, single= %f", i+1, regs[i], xf.f); - if (!(i & 1)) { - printf("\n"); - } else { - xd.l[1] = regs[i]; - xd.l[0] = regs[i+1]; - printf(", double= %f\n", xd.d); - } - } -} - -print_fpa_status(ep) -struct pt_regset ep; - -{ - - printf("WTL 1167:"); - if (ep.pr_fpa.fpa_pcr !=0) { - printf("\n"); - print_1167_control_word(ep.pr_fpa.fpa_pcr); - print_1167_regs(ep.pr_fpa.fpa_regs); - } else { - printf(" not in use.\n"); - } -} - -i386_float_info () - -{ - char ubuf[UPAGES*NBPG]; - struct pt_regset regset; - extern int corechan; - - if (have_inferior_p()) { - call_ptrace(XPT_RREGS, inferior_pid, ®set, 0); - } else { - if (lseek (corechan, 0, 0) < 0) { - perror ("seek on core file"); - } - if (myread (corechan, ubuf, UPAGES*NBPG) < 0) { - perror ("read on core file"); - } - /* only interested in the floating point registers */ - regset.pr_fpu = ((struct user *) ubuf)->u_fpusave; - regset.pr_fpa = ((struct user *) ubuf)->u_fpasave; - } - print_fpu_status(regset); - print_fpa_status(regset); -} - -i387_to_double (from, to) - char *from; - char *to; -{ - long *lp; - /* push extended mode on 387 stack, then pop in double mode - * - * first, set exception masks so no error is generated - - * number will be rounded to inf or 0, if necessary - */ - asm ("pushl %eax"); /* grab a stack slot */ - asm ("fstcw (%esp)"); /* get 387 control word */ - asm ("movl (%esp),%eax"); /* save old value */ - asm ("orl $0x3f,%eax"); /* mask all exceptions */ - asm ("pushl %eax"); - asm ("fldcw (%esp)"); /* load new value into 387 */ - - asm ("movl 8(%ebp),%eax"); - asm ("fldt (%eax)"); /* push extended number on 387 stack */ - asm ("fwait"); - asm ("movl 12(%ebp),%eax"); - asm ("fstpl (%eax)"); /* pop double */ - asm ("fwait"); - - asm ("popl %eax"); /* flush modified control word */ - asm ("fnclex"); /* clear exceptions */ - asm ("fldcw (%esp)"); /* restore original control word */ - asm ("popl %eax"); /* flush saved copy */ -} - -double_to_i387 (from, to) - char *from; - char *to; -{ - /* push double mode on 387 stack, then pop in extended mode - * no errors are possible because every 64-bit pattern - * can be converted to an extended - */ - asm ("movl 8(%ebp),%eax"); - asm ("fldl (%eax)"); - asm ("fwait"); - asm ("movl 12(%ebp),%eax"); - asm ("fstpt (%eax)"); - asm ("fwait"); -} diff --git a/gdb/symmisc.c b/gdb/symmisc.c deleted file mode 100644 index 04d375957b0..00000000000 --- a/gdb/symmisc.c +++ /dev/null @@ -1,493 +0,0 @@ -/* Do various things to symbol tables (other than lookup)), for GDB. - Copyright (C) 1986, 1987, 1989 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - - -#include -#include "defs.h" -#include "param.h" -#include "symtab.h" -#include "bfd.h" -#include "symfile.h" -#include "breakpoint.h" -#include "command.h" - -#include - -/* Free all the symtabs that are currently installed, - and all storage associated with them. - Leaves us in a consistent state with no symtabs installed. */ - -void -free_all_symtabs () -{ - register struct symtab *s, *snext; - - /* All values will be invalid because their types will be! */ - - clear_value_history (); - clear_displays (); - clear_internalvars (); -#if defined (CLEAR_SOLIB) - CLEAR_SOLIB (); -#endif - set_default_breakpoint (0, 0, 0, 0); - - current_source_symtab = 0; - - for (s = symtab_list; s; s = snext) - { - snext = s->next; - free_symtab (s); - } - symtab_list = 0; - obstack_free (symbol_obstack, 0); - obstack_init (symbol_obstack); - - if (misc_function_vector) - free (misc_function_vector); - misc_function_count = 0; - misc_function_vector = 0; - clear_pc_function_cache(); -} - -/* Free a struct block <- B and all the symbols defined in that block. */ - -static void -free_symtab_block (b) - struct block *b; -{ - register int i, n; - n = BLOCK_NSYMS (b); - for (i = 0; i < n; i++) - { - free (SYMBOL_NAME (BLOCK_SYM (b, i))); - free (BLOCK_SYM (b, i)); - } - free (b); -} - -/* Free all the storage associated with the struct symtab <- S. - Note that some symtabs have contents malloc'ed structure by structure, - while some have contents that all live inside one big block of memory, - and some share the contents of another symbol table and so you should - not free the contents on their behalf (except sometimes the linetable, - which maybe per symtab even when the rest is not). - It is s->free_code that says which alternative to use. */ - -void -free_symtab (s) - register struct symtab *s; -{ - register int i, n; - register struct blockvector *bv; - - switch (s->free_code) - { - case free_nothing: - /* All the contents are part of a big block of memory (an obstack), - and some other symtab is in charge of freeing that block. - Therefore, do nothing. */ - break; - - case free_contents: - /* Here all the contents were malloc'ed structure by structure - and must be freed that way. */ - /* First free the blocks (and their symbols. */ - bv = BLOCKVECTOR (s); - n = BLOCKVECTOR_NBLOCKS (bv); - for (i = 0; i < n; i++) - free_symtab_block (BLOCKVECTOR_BLOCK (bv, i)); - /* Free the blockvector itself. */ - free (bv); - /* Also free the linetable. */ - - case free_linetable: - /* Everything will be freed either by our `free_ptr' - or by some other symbatb, except for our linetable. - Free that now. */ - free (LINETABLE (s)); - break; - } - - /* If there is a single block of memory to free, free it. */ - if (s->free_ptr) - free (s->free_ptr); - - /* Free source-related stuff */ - if (s->line_charpos) - free (s->line_charpos); - if (s->fullname) - free (s->fullname); - free (s); -} - -static int block_depth (); -static void print_symbol (); -static void print_partial_symbol (); - -void -print_symtabs (filename) - char *filename; -{ - FILE *outfile; - register struct symtab *s; - register int i, j; - int len, blen; - register struct linetable *l; - struct blockvector *bv; - register struct block *b; - int depth; - struct cleanup *cleanups; - extern int fclose(); - - if (filename == 0) - error_no_arg ("file to write symbol data in"); - - filename = tilde_expand (filename); - make_cleanup (free, filename); - - outfile = fopen (filename, "w"); - if (outfile == 0) - perror_with_name (filename); - - cleanups = make_cleanup (fclose, outfile); - immediate_quit++; - - for (s = symtab_list; s; s = s->next) - { - /* First print the line table. */ - fprintf (outfile, "Symtab for file %s\n", s->filename); - l = LINETABLE (s); - if (l) { - fprintf (outfile, "\nLine table:\n\n"); - len = l->nitems; - for (i = 0; i < len; i++) - fprintf (outfile, " line %d at %x\n", l->item[i].line, - l->item[i].pc); - } - /* Now print the block info. */ - fprintf (outfile, "\nBlockvector:\n\n"); - bv = BLOCKVECTOR (s); - len = BLOCKVECTOR_NBLOCKS (bv); - for (i = 0; i < len; i++) - { - b = BLOCKVECTOR_BLOCK (bv, i); - depth = block_depth (b) * 2; - print_spaces (depth, outfile); - fprintf (outfile, "block #%03d (object 0x%x) ", i, b); - fprintf (outfile, "[0x%x..0x%x]", BLOCK_START (b), BLOCK_END (b)); - if (BLOCK_SUPERBLOCK (b)) - fprintf (outfile, " (under 0x%x)", BLOCK_SUPERBLOCK (b)); - if (BLOCK_FUNCTION (b)) - fprintf (outfile, " %s", SYMBOL_NAME (BLOCK_FUNCTION (b))); - fputc ('\n', outfile); - blen = BLOCK_NSYMS (b); - for (j = 0; j < blen; j++) - { - print_symbol (BLOCK_SYM (b, j), depth + 1, outfile); - } - } - - fprintf (outfile, "\n\n"); - } - - immediate_quit--; - do_cleanups (cleanups); -} - -static void -print_symbol (symbol, depth, outfile) - struct symbol *symbol; - int depth; - FILE *outfile; -{ - print_spaces (depth, outfile); - if (SYMBOL_NAMESPACE (symbol) == LABEL_NAMESPACE) - { - fprintf (outfile, "label %s at 0x%x\n", SYMBOL_NAME (symbol), - SYMBOL_VALUE_ADDRESS (symbol)); - return; - } - if (SYMBOL_NAMESPACE (symbol) == STRUCT_NAMESPACE) - { - if (TYPE_NAME (SYMBOL_TYPE (symbol))) - { - type_print_1 (SYMBOL_TYPE (symbol), "", outfile, 1, depth); - } - else - { - fprintf (outfile, "%s %s = ", - (TYPE_CODE (SYMBOL_TYPE (symbol)) == TYPE_CODE_ENUM - ? "enum" - : (TYPE_CODE (SYMBOL_TYPE (symbol)) == TYPE_CODE_STRUCT - ? "struct" : "union")), - SYMBOL_NAME (symbol)); - type_print_1 (SYMBOL_TYPE (symbol), "", outfile, 1, depth); - } - fprintf (outfile, ";\n"); - } - else - { - if (SYMBOL_CLASS (symbol) == LOC_TYPEDEF) - fprintf (outfile, "typedef "); - if (SYMBOL_TYPE (symbol)) - { - type_print_1 (SYMBOL_TYPE (symbol), SYMBOL_NAME (symbol), - outfile, 1, depth); - fprintf (outfile, "; "); - } - else - fprintf (outfile, "%s ", SYMBOL_NAME (symbol)); - - switch (SYMBOL_CLASS (symbol)) - { - case LOC_CONST: - fprintf (outfile, "const %ld (0x%lx),", - SYMBOL_VALUE (symbol), SYMBOL_VALUE (symbol)); - break; - - case LOC_CONST_BYTES: - fprintf (outfile, "const %u hex bytes:", - TYPE_LENGTH (SYMBOL_TYPE (symbol))); - { - unsigned i; - for (i = 0; i < TYPE_LENGTH (SYMBOL_TYPE (symbol)); i++) - fprintf (outfile, " %2x", - (unsigned)SYMBOL_VALUE_BYTES (symbol) [i]); - fprintf (outfile, ","); - } - break; - - case LOC_STATIC: - fprintf (outfile, "static at 0x%x,", SYMBOL_VALUE_ADDRESS (symbol)); - break; - - case LOC_REGISTER: - fprintf (outfile, "register %ld,", SYMBOL_VALUE (symbol)); - break; - - case LOC_ARG: - fprintf (outfile, "arg at 0x%lx,", SYMBOL_VALUE (symbol)); - break; - - case LOC_LOCAL_ARG: - fprintf (outfile, "arg at offset 0x%x from fp,", - SYMBOL_VALUE (symbol)); - - case LOC_REF_ARG: - fprintf (outfile, "reference arg at 0x%lx,", SYMBOL_VALUE (symbol)); - break; - - case LOC_REGPARM: - fprintf (outfile, "parameter register %ld,", SYMBOL_VALUE (symbol)); - break; - - case LOC_LOCAL: - fprintf (outfile, "local at 0x%lx,", SYMBOL_VALUE (symbol)); - break; - - case LOC_TYPEDEF: - break; - - case LOC_LABEL: - fprintf (outfile, "label at 0x%lx", SYMBOL_VALUE_ADDRESS (symbol)); - break; - - case LOC_BLOCK: - fprintf (outfile, "block (object 0x%x) starting at 0x%x,", - SYMBOL_BLOCK_VALUE (symbol), - BLOCK_START (SYMBOL_BLOCK_VALUE (symbol))); - break; - - default: - fprintf (outfile, "botched symbol class %x", SYMBOL_CLASS (symbol)); - break; - } - } - fprintf (outfile, "\n"); -} - -void -print_partial_symtabs (filename) - char *filename; -{ - FILE *outfile; - struct partial_symtab *p; - struct cleanup *cleanups; - extern int fclose(); - - if (filename == 0) - error_no_arg ("file to write partial symbol data in"); - - filename = tilde_expand (filename); - make_cleanup (free, filename); - - outfile = fopen (filename, "w"); - if (outfile == 0) - perror_with_name (filename); - - cleanups = make_cleanup (fclose, outfile); - immediate_quit++; - - for (p = partial_symtab_list; p; p = p->next) - { - fprintf_filtered (outfile, "Partial symtab for source file %s ", - p->filename); - fprintf_filtered (outfile, "(object 0x%x)\n\n", p); - fprintf_filtered (outfile, " Full symbol table %s been read from %s\n", - p->readin ? "has" : "has not yet", - p->symfile_name); - if (p->readin) - fprintf_filtered (outfile, " Was read into symtab at 0x%x by function at 0x%x\n", - p->symtab, p->read_symtab); - fprintf_filtered (outfile, " Relocate symbols by 0x%x\n", p->addr); - fprintf_filtered (outfile, " Symbols cover text addresses 0x%x-0x%x\n", - p->textlow, p->texthigh); - fprintf_filtered (outfile, " Depends on %d other partial symtabs.\n", - p->number_of_dependencies); - if (p->n_global_syms > 0) - print_partial_symbol (global_psymbols.list + p->globals_offset, - p->n_global_syms, "Global", outfile); - if (p->n_static_syms > 0) - print_partial_symbol (static_psymbols.list + p->statics_offset, - p->n_static_syms, "Static", outfile); - fprintf_filtered (outfile, "\n\n"); - } - - immediate_quit--; - do_cleanups (cleanups); -} - -static void -print_partial_symbol (p, count, what, outfile) -struct partial_symbol *p; -int count; -char *what; -FILE *outfile; -{ - char *space; - char *class; - - fprintf_filtered (outfile, " %s partial symbols:\n", what); - while (count-- > 0) - { - fprintf_filtered (outfile, " `%s', ", SYMBOL_NAME(p)); - switch (SYMBOL_NAMESPACE (p)) - { - case UNDEF_NAMESPACE: - fputs_filtered ("undefined namespace, ", outfile); - break; - case VAR_NAMESPACE: - /* This is the usual thing -- don't print it */ - break; - case STRUCT_NAMESPACE: - fputs_filtered ("struct namespace, ", outfile); - break; - case LABEL_NAMESPACE: - fputs_filtered ("label namespace, ", outfile); - break; - default: - fputs_filtered (", ", outfile); - break; - } - switch (SYMBOL_CLASS (p)) - { - case LOC_UNDEF: - fputs_filtered ("undefined", outfile); - break; - case LOC_CONST: - fputs_filtered ("constant int", outfile); - break; - case LOC_STATIC: - fputs_filtered ("static", outfile); - break; - case LOC_REGISTER: - fputs_filtered ("register", outfile); - break; - case LOC_ARG: - fputs_filtered ("pass by value", outfile); - break; - case LOC_REF_ARG: - fputs_filtered ("pass by reference", outfile); - break; - case LOC_REGPARM: - fputs_filtered ("register parameter", outfile); - break; - case LOC_LOCAL: - fputs_filtered ("stack parameter", outfile); - break; - case LOC_TYPEDEF: - fputs_filtered ("type", outfile); - break; - case LOC_LABEL: - fputs_filtered ("label", outfile); - break; - case LOC_BLOCK: - fputs_filtered ("function", outfile); - break; - case LOC_CONST_BYTES: - fputs_filtered ("constant bytes", outfile); - break; - case LOC_LOCAL_ARG: - fputs_filtered ("shuffled arg", outfile); - break; - default: - fputs_filtered ("", outfile); - break; - } - fputs_filtered (", ", outfile); - fprintf_filtered (outfile, "0x%x\n", SYMBOL_VALUE (p)); - p++; - } -} - -/* Return the nexting depth of a block within other blocks in its symtab. */ - -static int -block_depth (block) - struct block *block; -{ - register int i = 0; - while (block = BLOCK_SUPERBLOCK (block)) i++; - return i; -} - -/* - * Free all partial_symtab storage. - */ -void -free_all_psymtabs() -{ - obstack_free (psymbol_obstack, 0); - obstack_init (psymbol_obstack); - partial_symtab_list = (struct partial_symtab *) 0; -} - -void -_initialize_symmisc () -{ - symtab_list = (struct symtab *) 0; - partial_symtab_list = (struct partial_symtab *) 0; - - add_com ("printsyms", class_obscure, print_symtabs, - "Print dump of current symbol definitions to file OUTFILE."); - add_com ("printpsyms", class_obscure, print_partial_symtabs, - "Print dump of current partial symbol definitions to file OUTFILE."); -} - diff --git a/gdb/symtab.c b/gdb/symtab.c deleted file mode 100644 index 27d4952dfe7..00000000000 --- a/gdb/symtab.c +++ /dev/null @@ -1,3020 +0,0 @@ -/* Symbol table lookup for the GNU debugger, GDB. - Copyright 1986, 1987, 1988, 1989, 1990, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "defs.h" -#include "symtab.h" -#include "param.h" -#include "gdbcore.h" -#include "frame.h" -#include "target.h" -#include "value.h" -#include "symfile.h" -#include "gdbcmd.h" -#include "regex.h" -#include "language.h" - -#include -#include - -#include -#include -#include -#include - -extern char *getenv (); - -extern char *cplus_demangle (); -extern char *cplus_mangle_opname (); -extern struct value *value_of_this (); -extern void break_command (); -extern void select_source_symtab (); - -/* Functions this file defines */ -static int find_line_common (); -struct partial_symtab *lookup_partial_symtab (); -static struct partial_symbol *lookup_partial_symbol (); -static struct partial_symbol *lookup_demangled_partial_symbol (); -static struct symbol *lookup_demangled_block_symbol (); - -/* The single non-language-specific builtin type */ -struct type *builtin_type_error; - -/* Block in which the most recently searched-for symbol was found. - Might be better to make this a parameter to lookup_symbol and - value_of_this. */ -struct block *block_found; - -char no_symtab_msg[] = "No symbol table is loaded. Use the \"file\" command."; - -/* Check for a symtab of a specific name; first in symtabs, then in - psymtabs. *If* there is no '/' in the name, a match after a '/' - in the symtab filename will also work. */ - -static struct symtab * -lookup_symtab_1 (name) - char *name; -{ - register struct symtab *s; - register struct partial_symtab *ps; - register char *slash = strchr (name, '/'); - register int len = strlen (name); - - for (s = symtab_list; s; s = s->next) - if (!strcmp (name, s->filename)) - return s; - - for (ps = partial_symtab_list; ps; ps = ps->next) - if (!strcmp (name, ps->filename)) - { - if (ps->readin) - error ("Internal: readin pst for `%s' found when no symtab found.", name); - return PSYMTAB_TO_SYMTAB (ps); - } - - if (!slash) - { - for (s = symtab_list; s; s = s->next) - { - int l = strlen (s->filename); - - if (s->filename[l - len -1] == '/' - && !strcmp (s->filename + l - len, name)) - return s; - } - - for (ps = partial_symtab_list; ps; ps = ps->next) - { - int l = strlen (ps->filename); - - if (ps->filename[l - len - 1] == '/' - && !strcmp (ps->filename + l - len, name)) - { - if (ps->readin) - error ("Internal: readin pst for `%s' found when no symtab found.", name); - return PSYMTAB_TO_SYMTAB (ps); - } - } - } - return 0; -} - -/* Lookup the symbol table of a source file named NAME. Try a couple - of variations if the first lookup doesn't work. */ - -struct symtab * -lookup_symtab (name) - char *name; -{ - register struct symtab *s; - register char *copy; - - s = lookup_symtab_1 (name); - if (s) return s; - - /* If name not found as specified, see if adding ".c" helps. */ - - copy = (char *) alloca (strlen (name) + 3); - strcpy (copy, name); - strcat (copy, ".c"); - s = lookup_symtab_1 (copy); - if (s) return s; - - /* We didn't find anything; die. */ - return 0; -} - -/* Lookup the partial symbol table of a source file named NAME. This - only returns true on an exact match (ie. this semantics are - different from lookup_symtab. */ - -struct partial_symtab * -lookup_partial_symtab (name) -char *name; -{ - register struct partial_symtab *s; - - for (s = partial_symtab_list; s; s = s->next) - if (!strcmp (name, s->filename)) - return s; - - return 0; -} - -/* Return a typename for a struct/union/enum type - without the tag qualifier. If the type has a NULL name, - NULL is returned. */ -char * -type_name_no_tag (type) - register struct type *type; -{ - register char *name = TYPE_NAME (type); - - if (name == 0) - return 0; - - switch (TYPE_CODE (type)) - { - case TYPE_CODE_STRUCT: - if(!strncmp(name,"struct ",7)) - return name + 7; - else return name; - case TYPE_CODE_UNION: - if(!strncmp(name,"union ",6)) - return name + 6; - else return name; - case TYPE_CODE_ENUM: - if(!strncmp(name,"enum ",5)) - return name + 5; - else return name; - } - - return TYPE_NAME (type); -} - -/* Added by Bryan Boreham, Kewill, Sun Sep 17 18:07:17 1989. - - If this is a stubbed struct (i.e. declared as struct foo *), see if - we can find a full definition in some other file. If so, copy this - definition, so we can use it in future. If not, set a flag so we - don't waste too much time in future. (FIXME, this doesn't seem - to be happening...) - - This used to be coded as a macro, but I don't think it is called - often enough to merit such treatment. -*/ - -struct complaint stub_noname_complaint = - {"stub type has NULL name", 0, 0}; - -void -check_stub_type(type) - struct type *type; -{ - if (TYPE_FLAGS(type) & TYPE_FLAG_STUB) - { - char* name= type_name_no_tag (type); - struct symbol *sym; - if (name == 0) - { - complain (&stub_noname_complaint, 0); - return; - } - sym = lookup_symbol (name, 0, STRUCT_NAMESPACE, 0, - (struct symtab **)NULL); - if (sym) - bcopy (SYMBOL_TYPE(sym), type, sizeof (struct type)); - } -} - -/* Demangle a GDB method stub type. */ -char * -gdb_mangle_name (type, i, j) - struct type *type; - int i, j; -{ - int mangled_name_len; - char *mangled_name; - struct fn_field *f = TYPE_FN_FIELDLIST1 (type, i); - struct fn_field *method = &f[j]; - char *field_name = TYPE_FN_FIELDLIST_NAME (type, i); - - /* Need a new type prefix. */ - char *strchr (); - char *const_prefix = method->is_const ? "C" : ""; - char *volatile_prefix = method->is_volatile ? "V" : ""; - char *newname = type_name_no_tag (type); - char buf[20]; - int len = strlen (newname); - - sprintf (buf, "__%s%s%d", const_prefix, volatile_prefix, len); - mangled_name_len = (strlen (field_name) - + strlen (buf) + len - + strlen (TYPE_FN_FIELD_PHYSNAME (f, j)) - + 1); - - if (OPNAME_PREFIX_P (field_name)) - { - char *opname = cplus_mangle_opname (field_name + 3); - if (opname == NULL) - error ("No mangling for \"%s\"", field_name); - mangled_name_len += strlen (opname); - mangled_name = (char *)xmalloc (mangled_name_len); - - strncpy (mangled_name, field_name, 3); - mangled_name[3] = '\0'; - strcat (mangled_name, opname); - } - else - { - mangled_name = (char *)xmalloc (mangled_name_len); - strcpy (mangled_name, TYPE_FN_FIELDLIST_NAME (type, i)); - } - strcat (mangled_name, buf); - strcat (mangled_name, newname); - strcat (mangled_name, TYPE_FN_FIELD_PHYSNAME (f, j)); - - return mangled_name; -} - -/* Lookup a primitive type named NAME. - Return zero if NAME is not a primitive type.*/ - -struct type * -lookup_primitive_typename (name) - char *name; -{ - struct type ** const *p; - - for (p = current_language->la_builtin_type_vector; *p; p++) - if(!strcmp((**p)->name, name)) - return **p; - return 0; -} - -/* Lookup a typedef or primitive type named NAME, - visible in lexical block BLOCK. - If NOERR is nonzero, return zero if NAME is not suitably defined. */ - -struct type * -lookup_typename (name, block, noerr) - char *name; - struct block *block; - int noerr; -{ - register struct symbol *sym = - lookup_symbol (name, block, VAR_NAMESPACE, 0, (struct symtab **)NULL); - if (sym == 0 || SYMBOL_CLASS (sym) != LOC_TYPEDEF) - { - struct type *tmp; - tmp = lookup_primitive_typename (name); - if(tmp) - return tmp; - else if (!tmp && noerr) - return 0; - else - error ("No type named %s.", name); - } - return SYMBOL_TYPE (sym); -} - -struct type * -lookup_unsigned_typename (name) - char *name; -{ - char *uns = alloca (strlen(name) + 10); - - strcpy (uns, "unsigned "); - strcpy (uns+9, name); - return lookup_typename (uns, (struct block *)0, 0); -} - -/* Lookup a structure type named "struct NAME", - visible in lexical block BLOCK. */ - -struct type * -lookup_struct (name, block) - char *name; - struct block *block; -{ - register struct symbol *sym - = lookup_symbol (name, block, STRUCT_NAMESPACE, 0, (struct symtab **)NULL); - - if (sym == 0) - error ("No struct type named %s.", name); - if (TYPE_CODE (SYMBOL_TYPE (sym)) != TYPE_CODE_STRUCT) - error ("This context has class, union or enum %s, not a struct.", name); - return SYMBOL_TYPE (sym); -} - -/* Lookup a union type named "union NAME", - visible in lexical block BLOCK. */ - -struct type * -lookup_union (name, block) - char *name; - struct block *block; -{ - register struct symbol *sym - = lookup_symbol (name, block, STRUCT_NAMESPACE, 0, (struct symtab **)NULL); - - if (sym == 0) - error ("No union type named %s.", name); - if (TYPE_CODE (SYMBOL_TYPE (sym)) != TYPE_CODE_UNION) - error ("This context has class, struct or enum %s, not a union.", name); - return SYMBOL_TYPE (sym); -} - -/* Lookup an enum type named "enum NAME", - visible in lexical block BLOCK. */ - -struct type * -lookup_enum (name, block) - char *name; - struct block *block; -{ - register struct symbol *sym - = lookup_symbol (name, block, STRUCT_NAMESPACE, 0, (struct symtab **)NULL); - if (sym == 0) - error ("No enum type named %s.", name); - if (TYPE_CODE (SYMBOL_TYPE (sym)) != TYPE_CODE_ENUM) - error ("This context has class, struct or union %s, not an enum.", name); - return SYMBOL_TYPE (sym); -} - -/* Lookup a template type named "template NAME", - visible in lexical block BLOCK. */ - -struct type * -lookup_template_type (name, type, block) - char *name; - struct type *type; - struct block *block; -{ - struct symbol *sym ; - char *nam = (char*) alloca(strlen(name) + strlen(type->name) + 4); - strcpy(nam, name); - strcat(nam, "<"); - strcat(nam, type->name); - strcat(nam, " >"); /* extra space still introduced in gcc? */ - - sym = lookup_symbol (nam, block, VAR_NAMESPACE, 0, (struct symtab **)NULL); - - if (sym == 0) - error ("No template type named %s.", name); - if (TYPE_CODE (SYMBOL_TYPE (sym)) != TYPE_CODE_STRUCT) - error ("This context has class, union or enum %s, not a struct.", name); - return SYMBOL_TYPE (sym); -} - -/* Given a type TYPE, lookup the type of the component of type named - NAME. - If NOERR is nonzero, return zero if NAME is not suitably defined. */ - -struct type * -lookup_struct_elt_type (type, name, noerr) - struct type *type; - char *name; - int noerr; -{ - int i; - - if (TYPE_CODE (type) != TYPE_CODE_STRUCT - && TYPE_CODE (type) != TYPE_CODE_UNION) - { - target_terminal_ours (); - fflush (stdout); - fprintf (stderr, "Type "); - type_print (type, "", stderr, -1); - error (" is not a structure or union type."); - } - - check_stub_type (type); - - for (i = TYPE_NFIELDS (type) - 1; i >= TYPE_N_BASECLASSES (type); i--) - { - char *t_field_name = TYPE_FIELD_NAME (type, i); - - if (t_field_name && !strcmp (t_field_name, name)) - return TYPE_FIELD_TYPE (type, i); - } - /* OK, it's not in this class. Recursively check the baseclasses. */ - for (i = TYPE_N_BASECLASSES (type) - 1; i >= 0; i--) - { - struct type *t = lookup_struct_elt_type (TYPE_BASECLASS (type, i), - name, 0); - if (t != NULL) - return t; - } - - if (noerr) - return NULL; - - target_terminal_ours (); - fflush (stdout); - fprintf (stderr, "Type "); - type_print (type, "", stderr, -1); - fprintf (stderr, " has no component named "); - fputs_filtered (name, stderr); - error ("."); - return (struct type *)-1; /* For lint */ -} - -/* Given a type TYPE, return a type of pointers to that type. - May need to construct such a type if this is the first use. - - C++: use TYPE_MAIN_VARIANT and TYPE_CHAIN to keep pointer - to member types under control. */ - -struct type * -lookup_pointer_type (type) - struct type *type; -{ - register struct type *ptype = TYPE_POINTER_TYPE (type); - if (ptype) return TYPE_MAIN_VARIANT (ptype); - - /* This is the first time anyone wanted a pointer to a TYPE. */ - if (TYPE_FLAGS (type) & TYPE_FLAG_PERM) - ptype = (struct type *) xmalloc (sizeof (struct type)); - else - ptype = (struct type *) obstack_alloc (symbol_obstack, - sizeof (struct type)); - - bzero (ptype, sizeof (struct type)); - TYPE_MAIN_VARIANT (ptype) = ptype; - TYPE_TARGET_TYPE (ptype) = type; - TYPE_POINTER_TYPE (type) = ptype; - /* New type is permanent if type pointed to is permanent. */ - if (TYPE_FLAGS (type) & TYPE_FLAG_PERM) - TYPE_FLAGS (ptype) |= TYPE_FLAG_PERM; - /* We assume the machine has only one representation for pointers! */ - /* FIXME: This confuses host<->target data representations, and is a - poor assumption besides. */ - TYPE_LENGTH (ptype) = sizeof (char *); - TYPE_CODE (ptype) = TYPE_CODE_PTR; - return ptype; -} - -struct type * -lookup_reference_type (type) - struct type *type; -{ - register struct type *rtype = TYPE_REFERENCE_TYPE (type); - if (rtype) return TYPE_MAIN_VARIANT (rtype); - - /* This is the first time anyone wanted a pointer to a TYPE. */ - if (TYPE_FLAGS (type) & TYPE_FLAG_PERM) - rtype = (struct type *) xmalloc (sizeof (struct type)); - else - rtype = (struct type *) obstack_alloc (symbol_obstack, - sizeof (struct type)); - - bzero (rtype, sizeof (struct type)); - TYPE_MAIN_VARIANT (rtype) = rtype; - TYPE_TARGET_TYPE (rtype) = type; - TYPE_REFERENCE_TYPE (type) = rtype; - /* New type is permanent if type pointed to is permanent. */ - if (TYPE_FLAGS (type) & TYPE_FLAG_PERM) - TYPE_FLAGS (rtype) |= TYPE_FLAG_PERM; - /* We assume the machine has only one representation for pointers! */ - TYPE_LENGTH (rtype) = sizeof (char *); - TYPE_CODE (rtype) = TYPE_CODE_REF; - return rtype; -} - - -/* Implement direct support for MEMBER_TYPE in GNU C++. - May need to construct such a type if this is the first use. - The TYPE is the type of the member. The DOMAIN is the type - of the aggregate that the member belongs to. */ - -struct type * -lookup_member_type (type, domain) - struct type *type, *domain; -{ - register struct type *mtype = TYPE_MAIN_VARIANT (type); - struct type *main_type; - - main_type = mtype; - while (mtype) - { - if (TYPE_DOMAIN_TYPE (mtype) == domain) - return mtype; - mtype = TYPE_NEXT_VARIANT (mtype); - } - - /* This is the first time anyone wanted this member type. */ - if (TYPE_FLAGS (type) & TYPE_FLAG_PERM) - mtype = (struct type *) xmalloc (sizeof (struct type)); - else - mtype = (struct type *) obstack_alloc (symbol_obstack, - sizeof (struct type)); - - bzero (mtype, sizeof (struct type)); - if (main_type == 0) - main_type = mtype; - else - { - TYPE_NEXT_VARIANT (mtype) = TYPE_NEXT_VARIANT (main_type); - TYPE_NEXT_VARIANT (main_type) = mtype; - } - TYPE_MAIN_VARIANT (mtype) = main_type; - TYPE_TARGET_TYPE (mtype) = type; - TYPE_DOMAIN_TYPE (mtype) = domain; - /* New type is permanent if type pointed to is permanent. */ - if (TYPE_FLAGS (type) & TYPE_FLAG_PERM) - TYPE_FLAGS (mtype) |= TYPE_FLAG_PERM; - - /* In practice, this is never used. */ - TYPE_LENGTH (mtype) = 1; - TYPE_CODE (mtype) = TYPE_CODE_MEMBER; - -#if 0 - /* Now splice in the new member pointer type. */ - if (main_type) - { - /* This type was not "smashed". */ - TYPE_CHAIN (mtype) = TYPE_CHAIN (main_type); - TYPE_CHAIN (main_type) = mtype; - } -#endif - - return mtype; -} - -/* Allocate a stub method whose return type is - TYPE. We will fill in arguments later. This always - returns a fresh type. If we unify this type with - an existing type later, the storage allocated - here can be freed. */ -struct type * -allocate_stub_method (type) - struct type *type; -{ - struct type *mtype = (struct type *)xmalloc (sizeof (struct type)); - bzero (mtype, sizeof (struct type)); - TYPE_MAIN_VARIANT (mtype) = mtype; - TYPE_TARGET_TYPE (mtype) = type; - TYPE_FLAGS (mtype) = TYPE_FLAG_STUB; - TYPE_CODE (mtype) = TYPE_CODE_METHOD; - TYPE_LENGTH (mtype) = 1; - return mtype; -} - -/* Lookup a method type belonging to class DOMAIN, returning type TYPE, - and taking a list of arguments ARGS. - If one is not found, allocate a new one. */ - -struct type * -lookup_method_type (domain, type, args) - struct type *domain, *type, **args; -{ - register struct type *mtype = TYPE_MAIN_VARIANT (type); - struct type *main_type; - - main_type = mtype; - while (mtype) - { - if (TYPE_DOMAIN_TYPE (mtype) == domain) - { - struct type **t1 = args; - struct type **t2 = TYPE_ARG_TYPES (mtype); - if (t2) - { - int i; - for (i = 0; t1[i] != 0 && t1[i]->code != TYPE_CODE_VOID; i++) - if (t1[i] != t2[i]) - break; - if (t1[i] == t2[i]) - return mtype; - } - } - mtype = TYPE_NEXT_VARIANT (mtype); - } - - /* This is the first time anyone wanted this member type. */ - if (TYPE_FLAGS (type) & TYPE_FLAG_PERM) - mtype = (struct type *) xmalloc (sizeof (struct type)); - else - mtype = (struct type *) obstack_alloc (symbol_obstack, - sizeof (struct type)); - - bzero (mtype, sizeof (struct type)); - if (main_type == 0) - main_type = mtype; - else - { - TYPE_NEXT_VARIANT (mtype) = TYPE_NEXT_VARIANT (main_type); - TYPE_NEXT_VARIANT (main_type) = mtype; - } - TYPE_MAIN_VARIANT (mtype) = main_type; - TYPE_TARGET_TYPE (mtype) = type; - TYPE_DOMAIN_TYPE (mtype) = domain; - TYPE_ARG_TYPES (mtype) = args; - /* New type is permanent if type pointed to is permanent. */ - if (TYPE_FLAGS (type) & TYPE_FLAG_PERM) - TYPE_FLAGS (mtype) |= TYPE_FLAG_PERM; - - /* In practice, this is never used. */ - TYPE_LENGTH (mtype) = 1; - TYPE_CODE (mtype) = TYPE_CODE_METHOD; - -#if 0 - /* Now splice in the new member pointer type. */ - if (main_type) - { - /* This type was not "smashed". */ - TYPE_CHAIN (mtype) = TYPE_CHAIN (main_type); - TYPE_CHAIN (main_type) = mtype; - } -#endif - - return mtype; -} - -#if 0 -/* Given a type TYPE, return a type which has offset OFFSET, - via_virtual VIA_VIRTUAL, and via_public VIA_PUBLIC. - May need to construct such a type if none exists. */ -struct type * -lookup_basetype_type (type, offset, via_virtual, via_public) - struct type *type; - int offset; - int via_virtual, via_public; -{ - register struct type *btype = TYPE_MAIN_VARIANT (type); - struct type *main_type; - - if (offset != 0) - { - printf ("Internal error: type offset non-zero in lookup_basetype_type"); - offset = 0; - } - - main_type = btype; - while (btype) - { - if (/* TYPE_OFFSET (btype) == offset - && */ TYPE_VIA_PUBLIC (btype) == via_public - && TYPE_VIA_VIRTUAL (btype) == via_virtual) - return btype; - btype = TYPE_NEXT_VARIANT (btype); - } - - /* This is the first time anyone wanted this member type. */ - if (TYPE_FLAGS (type) & TYPE_FLAG_PERM) - btype = (struct type *) xmalloc (sizeof (struct type)); - else - btype = (struct type *) obstack_alloc (symbol_obstack, - sizeof (struct type)); - - if (main_type == 0) - { - main_type = btype; - bzero (btype, sizeof (struct type)); - TYPE_MAIN_VARIANT (btype) = main_type; - } - else - { - bcopy (main_type, btype, sizeof (struct type)); - TYPE_NEXT_VARIANT (main_type) = btype; - } -/* TYPE_OFFSET (btype) = offset; */ - if (via_public) - TYPE_FLAGS (btype) |= TYPE_FLAG_VIA_PUBLIC; - if (via_virtual) - TYPE_FLAGS (btype) |= TYPE_FLAG_VIA_VIRTUAL; - /* New type is permanent if type pointed to is permanent. */ - if (TYPE_FLAGS (type) & TYPE_FLAG_PERM) - TYPE_FLAGS (btype) |= TYPE_FLAG_PERM; - - /* In practice, this is never used. */ - TYPE_LENGTH (btype) = 1; - TYPE_CODE (btype) = TYPE_CODE_STRUCT; - - return btype; -} -#endif - -/* Given a type TYPE, return a type of functions that return that type. - May need to construct such a type if this is the first use. */ - -struct type * -lookup_function_type (type) - struct type *type; -{ - register struct type *ptype = TYPE_FUNCTION_TYPE (type); - if (ptype) return ptype; - - /* This is the first time anyone wanted a function returning a TYPE. */ - if (TYPE_FLAGS (type) & TYPE_FLAG_PERM) - ptype = (struct type *) xmalloc (sizeof (struct type)); - else - ptype = (struct type *) obstack_alloc (symbol_obstack, - sizeof (struct type)); - - bzero (ptype, sizeof (struct type)); - TYPE_TARGET_TYPE (ptype) = type; - TYPE_FUNCTION_TYPE (type) = ptype; - /* New type is permanent if type returned is permanent. */ - if (TYPE_FLAGS (type) & TYPE_FLAG_PERM) - TYPE_FLAGS (ptype) |= TYPE_FLAG_PERM; - TYPE_LENGTH (ptype) = 1; - TYPE_CODE (ptype) = TYPE_CODE_FUNC; - TYPE_NFIELDS (ptype) = 0; - return ptype; -} - -/* Create an array type. Elements will be of type TYPE, and there will - be NUM of them. - - Eventually this should be extended to take two more arguments which - specify the bounds of the array and the type of the index. - It should also be changed to be a "lookup" function, with the - appropriate data structures added to the type field. - Then read array type should call here. */ - -struct type * -create_array_type (element_type, number) - struct type *element_type; - int number; -{ - struct type *result_type = (struct type *) - obstack_alloc (symbol_obstack, sizeof (struct type)); - struct type *range_type; - - bzero (result_type, sizeof (struct type)); - - TYPE_CODE (result_type) = TYPE_CODE_ARRAY; - TYPE_TARGET_TYPE (result_type) = element_type; - TYPE_LENGTH (result_type) = number * TYPE_LENGTH (element_type); - TYPE_NFIELDS (result_type) = 1; - TYPE_FIELDS (result_type) = - (struct field *) obstack_alloc (symbol_obstack, sizeof (struct field)); - - { - /* Create range type. */ - range_type = (struct type *) obstack_alloc (symbol_obstack, - sizeof (struct type)); - TYPE_CODE (range_type) = TYPE_CODE_RANGE; - TYPE_TARGET_TYPE (range_type) = builtin_type_int; /* FIXME */ - - /* This should never be needed. */ - TYPE_LENGTH (range_type) = sizeof (int); - - TYPE_NFIELDS (range_type) = 2; - TYPE_FIELDS (range_type) = - (struct field *) obstack_alloc (symbol_obstack, - 2 * sizeof (struct field)); - TYPE_FIELD_BITPOS (range_type, 0) = 0; /* FIXME */ - TYPE_FIELD_BITPOS (range_type, 1) = number-1; /* FIXME */ - TYPE_FIELD_TYPE (range_type, 0) = builtin_type_int; /* FIXME */ - TYPE_FIELD_TYPE (range_type, 1) = builtin_type_int; /* FIXME */ - } - TYPE_FIELD_TYPE(result_type,0)=range_type; - TYPE_VPTR_FIELDNO (result_type) = -1; - - return result_type; -} - - -/* Smash TYPE to be a type of members of DOMAIN with type TO_TYPE. */ - -void -smash_to_member_type (type, domain, to_type) - struct type *type, *domain, *to_type; -{ - bzero (type, sizeof (struct type)); - TYPE_TARGET_TYPE (type) = to_type; - TYPE_DOMAIN_TYPE (type) = domain; - - /* In practice, this is never needed. */ - TYPE_LENGTH (type) = 1; - TYPE_CODE (type) = TYPE_CODE_MEMBER; - - TYPE_MAIN_VARIANT (type) = lookup_member_type (domain, to_type); -} - -/* Smash TYPE to be a type of method of DOMAIN with type TO_TYPE. */ - -void -smash_to_method_type (type, domain, to_type, args) - struct type *type, *domain, *to_type, **args; -{ - bzero (type, sizeof (struct type)); - TYPE_TARGET_TYPE (type) = to_type; - TYPE_DOMAIN_TYPE (type) = domain; - TYPE_ARG_TYPES (type) = args; - - /* In practice, this is never needed. */ - TYPE_LENGTH (type) = 1; - TYPE_CODE (type) = TYPE_CODE_METHOD; - - TYPE_MAIN_VARIANT (type) = lookup_method_type (domain, to_type, args); -} - -/* Find which partial symtab on the partial_symtab_list contains - PC. Return 0 if none. */ - -struct partial_symtab * -find_pc_psymtab (pc) - register CORE_ADDR pc; -{ - register struct partial_symtab *ps; - - for (ps = partial_symtab_list; ps; ps = ps->next) - if (pc >= ps->textlow && pc < ps->texthigh) - return ps; - - return 0; -} - -/* Find which partial symbol within a psymtab contains PC. Return 0 - if none. Check all psymtabs if PSYMTAB is 0. */ -struct partial_symbol * -find_pc_psymbol (psymtab, pc) - struct partial_symtab *psymtab; - CORE_ADDR pc; -{ - struct partial_symbol *best, *p; - CORE_ADDR best_pc; - - if (!psymtab) - psymtab = find_pc_psymtab (pc); - if (!psymtab) - return 0; - - best_pc = psymtab->textlow - 1; - - for (p = static_psymbols.list + psymtab->statics_offset; - (p - (static_psymbols.list + psymtab->statics_offset) - < psymtab->n_static_syms); - p++) - if (SYMBOL_NAMESPACE (p) == VAR_NAMESPACE - && SYMBOL_CLASS (p) == LOC_BLOCK - && pc >= SYMBOL_VALUE_ADDRESS (p) - && SYMBOL_VALUE_ADDRESS (p) > best_pc) - { - best_pc = SYMBOL_VALUE_ADDRESS (p); - best = p; - } - if (best_pc == psymtab->textlow - 1) - return 0; - return best; -} - - -/* Find the definition for a specified symbol name NAME - in namespace NAMESPACE, visible from lexical block BLOCK. - Returns the struct symbol pointer, or zero if no symbol is found. - If SYMTAB is non-NULL, store the symbol table in which the - symbol was found there, or NULL if not found. - C++: if IS_A_FIELD_OF_THIS is nonzero on entry, check to see if - NAME is a field of the current implied argument `this'. If so set - *IS_A_FIELD_OF_THIS to 1, otherwise set it to zero. - BLOCK_FOUND is set to the block in which NAME is found (in the case of - a field of `this', value_of_this sets BLOCK_FOUND to the proper value.) */ - -struct symbol * -lookup_symbol (name, block, namespace, is_a_field_of_this, symtab) - char *name; - register struct block *block; - enum namespace namespace; - int *is_a_field_of_this; - struct symtab **symtab; -{ - register struct symbol *sym; - register struct symtab *s; - register struct partial_symtab *ps; - struct blockvector *bv; - - /* Search specified block and its superiors. */ - - while (block != 0) - { - sym = lookup_block_symbol (block, name, namespace); - if (sym) - { - block_found = block; - if (symtab != NULL) - { - /* Search the list of symtabs for one which contains the - address of the start of this block. */ - struct block *b; - for (s = symtab_list; s; s = s->next) - { - bv = BLOCKVECTOR (s); - b = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK); - if (BLOCK_START (b) <= BLOCK_START (block) - && BLOCK_END (b) > BLOCK_START (block)) - break; - } - *symtab = s; - } - - return sym; - } - block = BLOCK_SUPERBLOCK (block); - } - - /* But that doesn't do any demangling for the STATIC_BLOCK. - I'm not sure whether demangling is needed in the case of - nested function in inner blocks; if so this needs to be changed. - - Don't need to mess with the psymtabs; if we have a block, - that file is read in. If we don't, then we deal later with - all the psymtab stuff that needs checking. */ - if (namespace == VAR_NAMESPACE && block != NULL) - { - struct block *b; - /* Find the right symtab. */ - for (s = symtab_list; s; s = s->next) - { - bv = BLOCKVECTOR (s); - b = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK); - if (BLOCK_START (b) <= BLOCK_START (block) - && BLOCK_END (b) > BLOCK_START (block)) - { - sym = lookup_demangled_block_symbol (b, name); - if (sym) - { - block_found = b; - if (symtab != NULL) - *symtab = s; - return sym; - } - } - } - } - - - /* C++: If requested to do so by the caller, - check to see if NAME is a field of `this'. */ - if (is_a_field_of_this) - { - struct value *v = value_of_this (0); - - *is_a_field_of_this = 0; - if (v && check_field (v, name)) - { - *is_a_field_of_this = 1; - if (symtab != NULL) - *symtab = NULL; - return 0; - } - } - - /* Now search all global blocks. Do the symtab's first, then - check the psymtab's */ - - for (s = symtab_list; s; s = s->next) - { - bv = BLOCKVECTOR (s); - block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK); - sym = lookup_block_symbol (block, name, namespace); - if (sym) - { - block_found = block; - if (symtab != NULL) - *symtab = s; - return sym; - } - } - - /* Check for the possibility of the symbol being a global function - that is stored on the misc function vector. Eventually, all - global symbols might be resolved in this way. */ - - if (namespace == VAR_NAMESPACE) - { - int ind = lookup_misc_func (name); - - /* Look for a mangled C++ name for NAME. */ - if (ind == -1) - { - int name_len = strlen (name); - - for (ind = misc_function_count; --ind >= 0; ) - /* Assume orginal name is prefix of mangled name. */ - if (!strncmp (misc_function_vector[ind].name, name, name_len)) - { - char *demangled = - cplus_demangle(misc_function_vector[ind].name, -1); - if (demangled != NULL) - { - int cond = strcmp (demangled, name); - free (demangled); - if (!cond) - break; - } - } - /* Loop terminates on no match with ind == -1. */ - } - - if (ind != -1) - { - s = find_pc_symtab (misc_function_vector[ind].address); - /* If S is zero, there are no debug symbols for this file. - Skip this stuff and check for matching static symbols below. */ - if (s) - { - bv = BLOCKVECTOR (s); - block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK); - sym = lookup_block_symbol (block, misc_function_vector[ind].name, - namespace); - /* sym == 0 if symbol was found in the misc_function_vector - but not in the symtab. - Return 0 to use the misc_function definition of "foo_". - - This happens for Fortran "foo_" symbols, - which are "foo" in the symtab. - - This can also happen if "asm" is used to make a - regular symbol but not a debugging symbol, e.g. - asm(".globl _main"); - asm("_main:"); - */ - - if (symtab != NULL) - *symtab = s; - return sym; - } - } - } - - for (ps = partial_symtab_list; ps; ps = ps->next) - if (!ps->readin && lookup_partial_symbol (ps, name, 1, namespace)) - { - s = PSYMTAB_TO_SYMTAB(ps); - bv = BLOCKVECTOR (s); - block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK); - sym = lookup_block_symbol (block, name, namespace); - if (!sym) - error ("Internal: global symbol `%s' found in psymtab but not in symtab", name); - if (symtab != NULL) - *symtab = s; - return sym; - } - - /* Now search all per-file blocks. - Not strictly correct, but more useful than an error. - Do the symtabs first, then check the psymtabs */ - - for (s = symtab_list; s; s = s->next) - { - bv = BLOCKVECTOR (s); - block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK); - sym = lookup_block_symbol (block, name, namespace); - if (sym) - { - block_found = block; - if (symtab != NULL) - *symtab = s; - return sym; - } - } - - for (ps = partial_symtab_list; ps; ps = ps->next) - if (!ps->readin && lookup_partial_symbol (ps, name, 0, namespace)) - { - s = PSYMTAB_TO_SYMTAB(ps); - bv = BLOCKVECTOR (s); - block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK); - sym = lookup_block_symbol (block, name, namespace); - if (!sym) - error ("Internal: static symbol `%s' found in psymtab but not in symtab", name); - if (symtab != NULL) - *symtab = s; - return sym; - } - - /* Now search all per-file blocks for static mangled symbols. - Do the symtabs first, then check the psymtabs. */ - - if (namespace == VAR_NAMESPACE) - { - for (s = symtab_list; s; s = s->next) - { - bv = BLOCKVECTOR (s); - block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK); - sym = lookup_demangled_block_symbol (block, name); - if (sym) - { - block_found = block; - if (symtab != NULL) - *symtab = s; - return sym; - } - } - - for (ps = partial_symtab_list; ps; ps = ps->next) - if (!ps->readin && lookup_demangled_partial_symbol (ps, name)) - { - s = PSYMTAB_TO_SYMTAB(ps); - bv = BLOCKVECTOR (s); - block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK); - sym = lookup_demangled_block_symbol (block, name); - if (!sym) - error ("Internal: mangled static symbol `%s' found in psymtab but not in symtab", name); - if (symtab != NULL) - *symtab = s; - return sym; - } - } - - if (symtab != NULL) - *symtab = NULL; - return 0; -} - -/* Look for a static demangled symbol in block BLOCK. */ - -static struct symbol * -lookup_demangled_block_symbol (block, name) - register struct block *block; - char *name; -{ - register int bot, top, inc; - register struct symbol *sym; - - bot = 0; - top = BLOCK_NSYMS (block); - inc = name[0]; - - while (bot < top) - { - sym = BLOCK_SYM (block, bot); - if (SYMBOL_NAME (sym)[0] == inc - && SYMBOL_NAMESPACE (sym) == VAR_NAMESPACE) - { - char *demangled = cplus_demangle(SYMBOL_NAME (sym), -1); - if (demangled != NULL) - { - int cond = strcmp (demangled, name); - free (demangled); - if (!cond) - return sym; - } - } - bot++; - } - - return 0; -} - -/* Look, in partial_symtab PST, for static mangled symbol NAME. */ - -static struct partial_symbol * -lookup_demangled_partial_symbol (pst, name) - struct partial_symtab *pst; - char *name; -{ - struct partial_symbol *start, *psym; - int length = pst->n_static_syms; - register int inc = name[0]; - - if (!length) - return (struct partial_symbol *) 0; - - start = static_psymbols.list + pst->statics_offset; - for (psym = start; psym < start + length; psym++) - { - if (SYMBOL_NAME (psym)[0] == inc - && SYMBOL_NAMESPACE (psym) == VAR_NAMESPACE) - { - char *demangled = cplus_demangle(SYMBOL_NAME (psym), -1); - if (demangled != NULL) - { - int cond = strcmp (demangled, name); - free (demangled); - if (!cond) - return psym; - } - } - } - - return (struct partial_symbol *) 0; -} - -/* Look, in partial_symtab PST, for symbol NAME. Check the global - symbols if GLOBAL, the static symbols if not */ - -static struct partial_symbol * -lookup_partial_symbol (pst, name, global, namespace) - struct partial_symtab *pst; - char *name; - int global; - enum namespace namespace; -{ - struct partial_symbol *start, *psym; - int length = (global ? pst->n_global_syms : pst->n_static_syms); - - if (!length) - return (struct partial_symbol *) 0; - - start = (global ? - global_psymbols.list + pst->globals_offset : - static_psymbols.list + pst->statics_offset ); - - if (global) /* This means we can use a binary */ - /* search. */ - { - struct partial_symbol *top, *bottom, *center; - - /* Binary search. This search is guaranteed to end with center - pointing at the earliest partial symbol with the correct - name. At that point *all* partial symbols with that name - will be checked against the correct namespace. */ - bottom = start; - top = start + length - 1; - while (top > bottom) - { - center = bottom + (top - bottom) / 2; - - assert (center < top); - - if (strcmp (SYMBOL_NAME (center), name) >= 0) - top = center; - else - bottom = center + 1; - } - assert (top == bottom); - - while (!strcmp (SYMBOL_NAME (top), name)) - { - if (SYMBOL_NAMESPACE (top) == namespace) - return top; - top ++; - } - } - else - { - /* Can't use a binary search */ - for (psym = start; psym < start + length; psym++) - if (namespace == SYMBOL_NAMESPACE (psym) - && !strcmp (name, SYMBOL_NAME (psym))) - return psym; - } - - return (struct partial_symbol *) 0; -} - -/* Find the psymtab containing main(). */ - -struct partial_symtab * -find_main_psymtab () -{ - register struct partial_symtab *pst; - for (pst = partial_symtab_list; pst; pst = pst->next) - if (lookup_partial_symbol (pst, "main", 1, VAR_NAMESPACE)) - return pst; - return NULL; -} - -/* Look for a symbol in block BLOCK. */ - -struct symbol * -lookup_block_symbol (block, name, namespace) - register struct block *block; - char *name; - enum namespace namespace; -{ - register int bot, top, inc; - register struct symbol *sym, *parameter_sym; - - top = BLOCK_NSYMS (block); - bot = 0; - - /* If the blocks's symbols were sorted, start with a binary search. */ - - if (BLOCK_SHOULD_SORT (block)) - { - /* First, advance BOT to not far before - the first symbol whose name is NAME. */ - - while (1) - { - inc = (top - bot + 1); - /* No need to keep binary searching for the last few bits worth. */ - if (inc < 4) - break; - inc = (inc >> 1) + bot; - sym = BLOCK_SYM (block, inc); - if (SYMBOL_NAME (sym)[0] < name[0]) - bot = inc; - else if (SYMBOL_NAME (sym)[0] > name[0]) - top = inc; - else if (strcmp (SYMBOL_NAME (sym), name) < 0) - bot = inc; - else - top = inc; - } - - /* Now scan forward until we run out of symbols, - find one whose name is greater than NAME, - or find one we want. - If there is more than one symbol with the right name and namespace, - we return the first one. dbxread.c is careful to make sure - that if one is a register then it comes first. */ - - top = BLOCK_NSYMS (block); - while (bot < top) - { - sym = BLOCK_SYM (block, bot); - inc = SYMBOL_NAME (sym)[0] - name[0]; - if (inc == 0) - inc = strcmp (SYMBOL_NAME (sym), name); - if (inc == 0 && SYMBOL_NAMESPACE (sym) == namespace) - return sym; - if (inc > 0) - return 0; - bot++; - } - return 0; - } - - /* Here if block isn't sorted. - This loop is equivalent to the loop above, - but hacked greatly for speed. - - Note that parameter symbols do not always show up last in the - list; this loop makes sure to take anything else other than - parameter symbols first; it only uses parameter symbols as a - last resort. Note that this only takes up extra computation - time on a match. */ - - parameter_sym = (struct symbol *) 0; - top = BLOCK_NSYMS (block); - inc = name[0]; - while (bot < top) - { - sym = BLOCK_SYM (block, bot); - if (SYMBOL_NAME (sym)[0] == inc - && !strcmp (SYMBOL_NAME (sym), name) - && SYMBOL_NAMESPACE (sym) == namespace) - { - if (SYMBOL_CLASS (sym) == LOC_ARG - || SYMBOL_CLASS (sym) == LOC_LOCAL_ARG - || SYMBOL_CLASS (sym) == LOC_REF_ARG - || SYMBOL_CLASS (sym) == LOC_REGPARM) - parameter_sym = sym; - else - return sym; - } - bot++; - } - return parameter_sym; /* Will be 0 if not found. */ -} - -/* Return the symbol for the function which contains a specified - lexical block, described by a struct block BL. */ - -struct symbol * -block_function (bl) - struct block *bl; -{ - while (BLOCK_FUNCTION (bl) == 0 && BLOCK_SUPERBLOCK (bl) != 0) - bl = BLOCK_SUPERBLOCK (bl); - - return BLOCK_FUNCTION (bl); -} - -/* Subroutine of find_pc_line */ - -struct symtab * -find_pc_symtab (pc) - register CORE_ADDR pc; -{ - register struct block *b; - struct blockvector *bv; - register struct symtab *s; - register struct partial_symtab *ps; - - /* Search all symtabs for one whose file contains our pc */ - - for (s = symtab_list; s; s = s->next) - { - bv = BLOCKVECTOR (s); - b = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK); - if (BLOCK_START (b) <= pc - && BLOCK_END (b) > pc) - break; - } - - if (!s) - { - ps = find_pc_psymtab (pc); - if (ps && ps->readin) - printf_filtered ( - "(Internal error: pc 0x%x in read in psymtab, but not in symtab.)\n", pc); - - if (ps) - s = PSYMTAB_TO_SYMTAB (ps); - } - - return s; -} - -/* Find the source file and line number for a given PC value. - Return a structure containing a symtab pointer, a line number, - and a pc range for the entire source line. - The value's .pc field is NOT the specified pc. - NOTCURRENT nonzero means, if specified pc is on a line boundary, - use the line that ends there. Otherwise, in that case, the line - that begins there is used. */ - -struct symtab_and_line -find_pc_line (pc, notcurrent) - CORE_ADDR pc; - int notcurrent; -{ - struct symtab *s; - register struct linetable *l; - register int len; - register int i; - register struct linetable_entry *item; - struct symtab_and_line val; - struct blockvector *bv; - - /* Info on best line seen so far, and where it starts, and its file. */ - - int best_line = 0; - CORE_ADDR best_pc = 0; - CORE_ADDR best_end = 0; - struct symtab *best_symtab = 0; - - /* Store here the first line number - of a file which contains the line at the smallest pc after PC. - If we don't find a line whose range contains PC, - we will use a line one less than this, - with a range from the start of that file to the first line's pc. */ - int alt_line = 0; - CORE_ADDR alt_pc = 0; - struct symtab *alt_symtab = 0; - - /* Info on best line seen in this file. */ - - int prev_line; - CORE_ADDR prev_pc; - - /* Info on first line of this file. */ - - int first_line; - CORE_ADDR first_pc; - - /* If this pc is not from the current frame, - it is the address of the end of a call instruction. - Quite likely that is the start of the following statement. - But what we want is the statement containing the instruction. - Fudge the pc to make sure we get that. */ - - if (notcurrent) pc -= 1; - - s = find_pc_symtab (pc); - if (s == 0) - { - val.symtab = 0; - val.line = 0; - val.pc = pc; - val.end = 0; - return val; - } - - bv = BLOCKVECTOR (s); - - /* Look at all the symtabs that share this blockvector. - They all have the same apriori range, that we found was right; - but they have different line tables. */ - - for (; s && BLOCKVECTOR (s) == bv; s = s->next) - { - /* Find the best line in this symtab. */ - l = LINETABLE (s); - if (!l) - continue; - len = l->nitems; - prev_line = -1; - first_line = -1; - for (i = 0; i < len; i++) - { - item = &(l->item[i]); - - if (first_line < 0) - { - first_line = item->line; - first_pc = item->pc; - } - /* Return the last line that did not start after PC. */ - if (pc >= item->pc) - { - prev_line = item->line; - prev_pc = item->pc; - } - else - break; - } - - /* Is this file's best line closer than the best in the other files? - If so, record this file, and its best line, as best so far. */ - if (prev_line >= 0 && prev_pc > best_pc) - { - best_pc = prev_pc; - best_line = prev_line; - best_symtab = s; - if (i < len) - best_end = item->pc; - else - best_end = 0; - } - /* Is this file's first line closer than the first lines of other files? - If so, record this file, and its first line, as best alternate. */ - if (first_line >= 0 && first_pc > pc - && (alt_pc == 0 || first_pc < alt_pc)) - { - alt_pc = first_pc; - alt_line = first_line; - alt_symtab = s; - } - } - if (best_symtab == 0) - { - val.symtab = alt_symtab; - val.line = alt_line - 1; - val.pc = BLOCK_END (BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK)); - val.end = alt_pc; - } - else - { - val.symtab = best_symtab; - val.line = best_line; - val.pc = best_pc; - val.end = (best_end ? best_end - : (alt_pc ? alt_pc - : BLOCK_END (BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK)))); - } - return val; -} - -/* Find the PC value for a given source file and line number. - Returns zero for invalid line number. - The source file is specified with a struct symtab. */ - -CORE_ADDR -find_line_pc (symtab, line) - struct symtab *symtab; - int line; -{ - register struct linetable *l; - register int ind; - int dummy; - - if (symtab == 0) - return 0; - l = LINETABLE (symtab); - ind = find_line_common(l, line, &dummy); - return (ind >= 0) ? l->item[ind].pc : 0; -} - -/* Find the range of pc values in a line. - Store the starting pc of the line into *STARTPTR - and the ending pc (start of next line) into *ENDPTR. - Returns 1 to indicate success. - Returns 0 if could not find the specified line. */ - -int -find_line_pc_range (symtab, thisline, startptr, endptr) - struct symtab *symtab; - int thisline; - CORE_ADDR *startptr, *endptr; -{ - register struct linetable *l; - register int ind; - int exact_match; /* did we get an exact linenumber match */ - - if (symtab == 0) - return 0; - - l = LINETABLE (symtab); - ind = find_line_common (l, thisline, &exact_match); - if (ind >= 0) - { - *startptr = l->item[ind].pc; - /* If we have not seen an entry for the specified line, - assume that means the specified line has zero bytes. */ - if (!exact_match || ind == l->nitems-1) - *endptr = *startptr; - else - /* Perhaps the following entry is for the following line. - It's worth a try. */ - if (ind+1 < l->nitems - && l->item[ind+1].line == thisline + 1) - *endptr = l->item[ind+1].pc; - else - *endptr = find_line_pc (symtab, thisline+1); - return 1; - } - - return 0; -} - -/* Given a line table and a line number, return the index into the line - table for the pc of the nearest line whose number is >= the specified one. - Return -1 if none is found. The value is >= 0 if it is an index. - - Set *EXACT_MATCH nonzero if the value returned is an exact match. */ - -static int -find_line_common (l, lineno, exact_match) - register struct linetable *l; - register int lineno; - int *exact_match; -{ - register int i; - register int len; - - /* BEST is the smallest linenumber > LINENO so far seen, - or 0 if none has been seen so far. - BEST_INDEX identifies the item for it. */ - - int best_index = -1; - int best = 0; - - if (lineno <= 0) - return -1; - if (l == 0) - return -1; - - len = l->nitems; - for (i = 0; i < len; i++) - { - register struct linetable_entry *item = &(l->item[i]); - - if (item->line == lineno) - { - *exact_match = 1; - return i; - } - - if (item->line > lineno && (best == 0 || item->line < best)) - { - best = item->line; - best_index = i; - } - } - - /* If we got here, we didn't get an exact match. */ - - *exact_match = 0; - return best_index; -} - -int -find_pc_line_pc_range (pc, startptr, endptr) - CORE_ADDR pc; - CORE_ADDR *startptr, *endptr; -{ - struct symtab_and_line sal; - sal = find_pc_line (pc, 0); - *startptr = sal.pc; - *endptr = sal.end; - return sal.symtab != 0; -} - -/* If P is of the form "operator[ \t]+..." where `...' is - some legitimate operator text, return a pointer to the - beginning of the substring of the operator text. - Otherwise, return "". */ -static char * -operator_chars (p, end) - char *p; - char **end; -{ - *end = ""; - if (strncmp (p, "operator", 8)) - return *end; - p += 8; - - /* Don't get faked out by `operator' being part of a longer - identifier. */ - if ((*p >= 'A' && *p <= 'Z') || (*p >= 'a' && *p <= 'z') - || *p == '_' || *p == '$' || *p == '\0') - return *end; - - /* Allow some whitespace between `operator' and the operator symbol. */ - while (*p == ' ' || *p == '\t') - p++; - - switch (*p) - { - case '!': - case '=': - case '*': - case '/': - case '%': - case '^': - if (p[1] == '=') - *end = p+2; - else - *end = p+1; - return p; - case '<': - case '>': - case '+': - case '-': - case '&': - case '|': - if (p[1] == '=' || p[1] == p[0]) - *end = p+2; - else - *end = p+1; - return p; - case '~': - case ',': - *end = p+1; - return p; - case '(': - if (p[1] != ')') - error ("`operator ()' must be specified without whitespace in `()'"); - *end = p+2; - return p; - case '?': - if (p[1] != ':') - error ("`operator ?:' must be specified without whitespace in `?:'"); - *end = p+2; - return p; - case '[': - if (p[1] != ']') - error ("`operator []' must be specified without whitespace in `[]'"); - *end = p+2; - return p; - default: - error ("`operator %s' not supported", p); - break; - } - *end = ""; - return *end; -} - -/* Recursive helper function for decode_line_1. - * Look for methods named NAME in type T. - * Return number of matches. - * Put matches in PHYSNAMES and SYM_ARR (which better be big enough!). - * These allocations seem to define "big enough": - * sym_arr = (struct symbol **) alloca(TYPE_NFN_FIELDS_TOTAL (t) * sizeof(struct symbol*)); - * physnames = (char **) alloca (TYPE_NFN_FIELDS_TOTAL (t) * sizeof(char*)); - */ - -int -find_methods(t, name, physnames, sym_arr) - struct type *t; - char *name; - char **physnames; - struct symbol **sym_arr; -{ - int i1 = 0; - int ibase; - struct symbol *sym_class; - char *class_name = type_name_no_tag (t); - /* Ignore this class if it doesn't have a name. - This prevents core dumps, but is just a workaround - because we might not find the function in - certain cases, such as - struct D {virtual int f();} - struct C : D {virtual int g();} - (in this case g++ 1.35.1- does not put out a name - for D as such, it defines type 19 (for example) in - the same stab as C, and then does a - .stabs "D:T19" and a .stabs "D:t19". - Thus - "break C::f" should not be looking for field f in - the class named D, - but just for the field f in the baseclasses of C - (no matter what their names). - - However, I don't know how to replace the code below - that depends on knowing the name of D. */ - if (class_name - && (sym_class = lookup_symbol (class_name, - (struct block *)NULL, - STRUCT_NAMESPACE, - (int *)NULL, - (struct symtab **)NULL))) - { - int method_counter; - t = SYMBOL_TYPE (sym_class); - for (method_counter = TYPE_NFN_FIELDS (t) - 1; - method_counter >= 0; - --method_counter) - { - int field_counter; - struct fn_field *f = TYPE_FN_FIELDLIST1 (t, method_counter); - - char *method_name = TYPE_FN_FIELDLIST_NAME (t, method_counter); - if (!strcmp (name, method_name)) - /* Find all the fields with that name. */ - for (field_counter = TYPE_FN_FIELDLIST_LENGTH (t, method_counter) - 1; - field_counter >= 0; - --field_counter) - { - char *phys_name; - if (TYPE_FLAGS (TYPE_FN_FIELD_TYPE (f, field_counter)) & TYPE_FLAG_STUB) - check_stub_method (t, method_counter, field_counter); - phys_name = TYPE_FN_FIELD_PHYSNAME (f, field_counter); - physnames[i1] = (char*) alloca (strlen (phys_name) + 1); - strcpy (physnames[i1], phys_name); - sym_arr[i1] = lookup_symbol (phys_name, - SYMBOL_BLOCK_VALUE (sym_class), - VAR_NAMESPACE, - (int *) NULL, - (struct symtab **) NULL); - if (sym_arr[i1]) i1++; - } - } - } - /* Only search baseclasses if there is no match yet, - * since names in derived classes override those in baseclasses. - */ - if (i1) - return i1; - for (ibase = 0; ibase < TYPE_N_BASECLASSES (t); ibase++) - i1 += find_methods(TYPE_BASECLASS(t, ibase), name, - physnames + i1, sym_arr + i1); - return i1; -} - -/* Parse a string that specifies a line number. - Pass the address of a char * variable; that variable will be - advanced over the characters actually parsed. - - The string can be: - - LINENUM -- that line number in current file. PC returned is 0. - FILE:LINENUM -- that line in that file. PC returned is 0. - FUNCTION -- line number of openbrace of that function. - PC returned is the start of the function. - VARIABLE -- line number of definition of that variable. - PC returned is 0. - FILE:FUNCTION -- likewise, but prefer functions in that file. - *EXPR -- line in which address EXPR appears. - - FUNCTION may be an undebuggable function found in misc_function_vector. - - If the argument FUNFIRSTLINE is nonzero, we want the first line - of real code inside a function when a function is specified. - - DEFAULT_SYMTAB specifies the file to use if none is specified. - It defaults to current_source_symtab. - DEFAULT_LINE specifies the line number to use for relative - line numbers (that start with signs). Defaults to current_source_line. - - Note that it is possible to return zero for the symtab - if no file is validly specified. Callers must check that. - Also, the line number returned may be invalid. */ - -struct symtabs_and_lines -decode_line_1 (argptr, funfirstline, default_symtab, default_line) - char **argptr; - int funfirstline; - struct symtab *default_symtab; - int default_line; -{ - struct symtabs_and_lines decode_line_2 (); - struct symtabs_and_lines values; - struct symtab_and_line val; - register char *p, *p1; - char *q, *q1; - register struct symtab *s; - - register struct symbol *sym; - /* The symtab that SYM was found in. */ - struct symtab *sym_symtab; - - register CORE_ADDR pc; - register int i; - char *copy; - struct symbol *sym_class; - int i1; - struct symbol **sym_arr; - struct type *t; - char **physnames; - - /* Defaults have defaults. */ - - if (default_symtab == 0) - { - default_symtab = current_source_symtab; - default_line = current_source_line; - } - - /* See if arg is *PC */ - - if (**argptr == '*') - { - (*argptr)++; - pc = parse_and_eval_address_1 (argptr); - values.sals = (struct symtab_and_line *) - xmalloc (sizeof (struct symtab_and_line)); - values.nelts = 1; - values.sals[0] = find_pc_line (pc, 0); - values.sals[0].pc = pc; - return values; - } - - /* Maybe arg is FILE : LINENUM or FILE : FUNCTION */ - - s = 0; - - for (p = *argptr; *p; p++) - { - if (p[0] == ':' || p[0] == ' ' || p[0] == '\t') - break; - } - while (p[0] == ' ' || p[0] == '\t') p++; - - if (p[0] == ':') - { - - /* C++ */ - if (p[1] ==':') - { - /* Extract the class name. */ - p1 = p; - while (p != *argptr && p[-1] == ' ') --p; - copy = (char *) alloca (p - *argptr + 1); - bcopy (*argptr, copy, p - *argptr); - copy[p - *argptr] = 0; - - /* Discard the class name from the arg. */ - p = p1 + 2; - while (*p == ' ' || *p == '\t') p++; - *argptr = p; - - sym_class = lookup_symbol (copy, 0, STRUCT_NAMESPACE, 0, - (struct symtab **)NULL); - - if (sym_class && - (TYPE_CODE (SYMBOL_TYPE (sym_class)) == TYPE_CODE_STRUCT - || TYPE_CODE (SYMBOL_TYPE (sym_class)) == TYPE_CODE_UNION)) - { - /* Arg token is not digits => try it as a function name - Find the next token (everything up to end or next whitespace). */ - p = *argptr; - while (*p && *p != ' ' && *p != '\t' && *p != ',' && *p !=':') p++; - q = operator_chars (*argptr, &q1); - - copy = (char *) alloca (p - *argptr + 1 + (q1 - q)); - if (q1 - q) - { - copy[0] = 'o'; - copy[1] = 'p'; - copy[2] = CPLUS_MARKER; - bcopy (q, copy + 3, q1 - q); - copy[3 + (q1 - q)] = '\0'; - p = q1; - } - else - { - bcopy (*argptr, copy, p - *argptr); - copy[p - *argptr] = '\0'; - } - - /* no line number may be specified */ - while (*p == ' ' || *p == '\t') p++; - *argptr = p; - - sym = 0; - i1 = 0; /* counter for the symbol array */ - t = SYMBOL_TYPE (sym_class); - sym_arr = (struct symbol **) alloca(TYPE_NFN_FIELDS_TOTAL (t) * sizeof(struct symbol*)); - physnames = (char **) alloca (TYPE_NFN_FIELDS_TOTAL (t) * sizeof(char*)); - - if (destructor_name_p (copy, t)) - { - /* destructors are a special case. */ - struct fn_field *f = TYPE_FN_FIELDLIST1 (t, 0); - int len = TYPE_FN_FIELDLIST_LENGTH (t, 0) - 1; - char *phys_name = TYPE_FN_FIELD_PHYSNAME (f, len); - physnames[i1] = (char *)alloca (strlen (phys_name) + 1); - strcpy (physnames[i1], phys_name); - sym_arr[i1] = - lookup_symbol (phys_name, SYMBOL_BLOCK_VALUE (sym_class), - VAR_NAMESPACE, 0, (struct symtab **)NULL); - if (sym_arr[i1]) i1++; - } - else - i1 = find_methods (t, copy, physnames, sym_arr); - if (i1 == 1) - { - /* There is exactly one field with that name. */ - sym = sym_arr[0]; - - if (sym && SYMBOL_CLASS (sym) == LOC_BLOCK) - { - /* Arg is the name of a function */ - pc = BLOCK_START (SYMBOL_BLOCK_VALUE (sym)) + FUNCTION_START_OFFSET; - if (funfirstline) - SKIP_PROLOGUE (pc); - values.sals = (struct symtab_and_line *)xmalloc (sizeof (struct symtab_and_line)); - values.nelts = 1; - values.sals[0] = find_pc_line (pc, 0); - values.sals[0].pc = (values.sals[0].end && values.sals[0].pc != pc) ? values.sals[0].end : pc; - } - else - { - values.nelts = 0; - } - return values; - } - if (i1 > 0) - { - /* There is more than one field with that name - (overloaded). Ask the user which one to use. */ - return decode_line_2 (sym_arr, i1, funfirstline); - } - else - { - char *tmp; - - if (OPNAME_PREFIX_P (copy)) - { - tmp = (char *)alloca (strlen (copy+3) + 9); - strcpy (tmp, "operator "); - strcat (tmp, copy+3); - } - else - tmp = copy; - if (tmp[0] == '~') - error ("The class `%s' does not have destructor defined", - sym_class->name); - else - error ("The class %s does not have any method named %s", - sym_class->name, tmp); - } - } - else - /* The quotes are important if copy is empty. */ - error("No class, struct, or union named \"%s\"", copy ); - } - /* end of C++ */ - - - /* Extract the file name. */ - p1 = p; - while (p != *argptr && p[-1] == ' ') --p; - copy = (char *) alloca (p - *argptr + 1); - bcopy (*argptr, copy, p - *argptr); - copy[p - *argptr] = 0; - - /* Find that file's data. */ - s = lookup_symtab (copy); - if (s == 0) - { - if (symtab_list == 0 && partial_symtab_list == 0) - error (no_symtab_msg); - error ("No source file named %s.", copy); - } - - /* Discard the file name from the arg. */ - p = p1 + 1; - while (*p == ' ' || *p == '\t') p++; - *argptr = p; - } - - /* S is specified file's symtab, or 0 if no file specified. - arg no longer contains the file name. */ - - /* Check whether arg is all digits (and sign) */ - - p = *argptr; - if (*p == '-' || *p == '+') p++; - while (*p >= '0' && *p <= '9') - p++; - - if (p != *argptr && (*p == 0 || *p == ' ' || *p == '\t' || *p == ',')) - { - /* We found a token consisting of all digits -- at least one digit. */ - enum sign {none, plus, minus} sign = none; - - /* This is where we need to make sure that we have good defaults. - We must guarantee that this section of code is never executed - when we are called with just a function name, since - select_source_symtab calls us with such an argument */ - - if (s == 0 && default_symtab == 0) - { - select_source_symtab (0); - default_symtab = current_source_symtab; - default_line = current_source_line; - } - - if (**argptr == '+') - sign = plus, (*argptr)++; - else if (**argptr == '-') - sign = minus, (*argptr)++; - val.line = atoi (*argptr); - switch (sign) - { - case plus: - if (p == *argptr) - val.line = 5; - if (s == 0) - val.line = default_line + val.line; - break; - case minus: - if (p == *argptr) - val.line = 15; - if (s == 0) - val.line = default_line - val.line; - else - val.line = 1; - break; - case none: - break; /* No need to adjust val.line. */ - } - - while (*p == ' ' || *p == '\t') p++; - *argptr = p; - if (s == 0) - s = default_symtab; - val.symtab = s; - val.pc = 0; - values.sals = (struct symtab_and_line *)xmalloc (sizeof (struct symtab_and_line)); - values.sals[0] = val; - values.nelts = 1; - return values; - } - - /* Arg token is not digits => try it as a variable name - Find the next token (everything up to end or next whitespace). */ - p = *argptr; - while (*p && *p != ' ' && *p != '\t' && *p != ',') p++; - copy = (char *) alloca (p - *argptr + 1); - bcopy (*argptr, copy, p - *argptr); - copy[p - *argptr] = 0; - while (*p == ' ' || *p == '\t') p++; - *argptr = p; - - /* Look up that token as a variable. - If file specified, use that file's per-file block to start with. */ - - sym = lookup_symbol (copy, - (s ? BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK) - : get_selected_block ()), - VAR_NAMESPACE, 0, &sym_symtab); - - if (sym != NULL) - { - if (SYMBOL_CLASS (sym) == LOC_BLOCK) - { - /* Arg is the name of a function */ - pc = BLOCK_START (SYMBOL_BLOCK_VALUE (sym)) + FUNCTION_START_OFFSET; - if (funfirstline) - SKIP_PROLOGUE (pc); - val = find_pc_line (pc, 0); -#ifdef PROLOGUE_FIRSTLINE_OVERLAP - /* Convex: no need to suppress code on first line, if any */ - val.pc = pc; -#else - val.pc = (val.end && val.pc != pc) ? val.end : pc; -#endif - values.sals = (struct symtab_and_line *)xmalloc (sizeof (struct symtab_and_line)); - values.sals[0] = val; - values.nelts = 1; - - /* I think this is always the same as the line that - we calculate above, but the general principle is - "trust the symbols more than stuff like - SKIP_PROLOGUE". */ - if (SYMBOL_LINE (sym) != 0) - values.sals[0].line = SYMBOL_LINE (sym); - - return values; - } - else if (SYMBOL_LINE (sym) != 0) - { - /* We know its line number. */ - values.sals = (struct symtab_and_line *) - xmalloc (sizeof (struct symtab_and_line)); - values.nelts = 1; - bzero (&values.sals[0], sizeof (values.sals[0])); - values.sals[0].symtab = sym_symtab; - values.sals[0].line = SYMBOL_LINE (sym); - return values; - } - else - /* This can happen if it is compiled with a compiler which doesn't - put out line numbers for variables. */ - error ("Line number not known for symbol \"%s\"", copy); - } - - if ((i = lookup_misc_func (copy)) >= 0) - { - val.symtab = 0; - val.line = 0; - val.pc = misc_function_vector[i].address + FUNCTION_START_OFFSET; - if (funfirstline) - SKIP_PROLOGUE (val.pc); - values.sals = (struct symtab_and_line *)xmalloc (sizeof (struct symtab_and_line)); - values.sals[0] = val; - values.nelts = 1; - return values; - } - - if (symtab_list == 0 && partial_symtab_list == 0 && misc_function_count == 0) - error (no_symtab_msg); - - error ("Function %s not defined.", copy); - return values; /* for lint */ -} - -struct symtabs_and_lines -decode_line_spec (string, funfirstline) - char *string; - int funfirstline; -{ - struct symtabs_and_lines sals; - if (string == 0) - error ("Empty line specification."); - sals = decode_line_1 (&string, funfirstline, - current_source_symtab, current_source_line); - if (*string) - error ("Junk at end of line specification: %s", string); - return sals; -} - -/* Given a list of NELTS symbols in sym_arr (with corresponding - mangled names in physnames), return a list of lines to operate on - (ask user if necessary). */ -struct symtabs_and_lines -decode_line_2 (sym_arr, nelts, funfirstline) - struct symbol *sym_arr[]; - int nelts; - int funfirstline; -{ - struct symtabs_and_lines values, return_values; - register CORE_ADDR pc; - char *args, *arg1, *command_line_input (); - int i; - char *prompt; - - values.sals = (struct symtab_and_line *) alloca (nelts * sizeof(struct symtab_and_line)); - return_values.sals = (struct symtab_and_line *) xmalloc (nelts * sizeof(struct symtab_and_line)); - - i = 0; - printf("[0] cancel\n[1] all\n"); - while (i < nelts) - { - if (sym_arr[i] && SYMBOL_CLASS (sym_arr[i]) == LOC_BLOCK) - { - /* Arg is the name of a function */ - pc = BLOCK_START (SYMBOL_BLOCK_VALUE (sym_arr[i])) - + FUNCTION_START_OFFSET; - if (funfirstline) - SKIP_PROLOGUE (pc); - values.sals[i] = find_pc_line (pc, 0); - values.sals[i].pc = (values.sals[i].end && values.sals[i].pc != pc) ? - values.sals[i].end : pc; - printf("[%d] file:%s; line number:%d\n", - (i+2), values.sals[i].symtab->filename, values.sals[i].line); - } - else printf ("?HERE\n"); - i++; - } - - if ((prompt = getenv ("PS2")) == NULL) - { - prompt = ">"; - } - printf("%s ",prompt); - fflush(stdout); - - args = command_line_input (0, 0); - - if (args == 0) - error_no_arg ("one or more choice numbers"); - - i = 0; - while (*args) - { - int num; - - arg1 = args; - while (*arg1 >= '0' && *arg1 <= '9') arg1++; - if (*arg1 && *arg1 != ' ' && *arg1 != '\t') - error ("Arguments must be choice numbers."); - - num = atoi (args); - - if (num == 0) - error ("cancelled"); - else if (num == 1) - { - bcopy (values.sals, return_values.sals, (nelts * sizeof(struct symtab_and_line))); - return_values.nelts = nelts; - return return_values; - } - - if (num > nelts + 2) - { - printf ("No choice number %d.\n", num); - } - else - { - num -= 2; - if (values.sals[num].pc) - { - return_values.sals[i++] = values.sals[num]; - values.sals[num].pc = 0; - } - else - { - printf ("duplicate request for %d ignored.\n", num); - } - } - - args = arg1; - while (*args == ' ' || *args == '\t') args++; - } - return_values.nelts = i; - return return_values; -} - -/* Return the index of misc function named NAME. */ - -int -lookup_misc_func (name) - register char *name; -{ - register int i; - - for (i = 0; i < misc_function_count; i++) - if (!strcmp (misc_function_vector[i].name, name)) - return i; - return -1; /* not found */ -} - -/* Slave routine for sources_info. Force line breaks at ,'s. - NAME is the name to print and *FIRST is nonzero if this is the first - name printed. Set *FIRST to zero. */ -static void -output_source_filename (name, first) - char *name; - int *first; -{ - static int column; - /* Table of files printed so far. Since a single source file can - result in several partial symbol tables, we need to avoid printing - it more than once. Note: if some of the psymtabs are read in and - some are not, it gets printed both under "Source files for which - symbols have been read" and "Source files for which symbols will - be read in on demand". I consider this a reasonable way to deal - with the situation. I'm not sure whether this can also happen for - symtabs; it doesn't hurt to check. */ - static char **tab = NULL; - /* Allocated size of tab in elements. - Start with one 256-byte block (when using GNU malloc.c). - 24 is the malloc overhead when range checking is in effect. */ - static int tab_alloc_size = (256 - 24) / sizeof (char *); - /* Current size of tab in elements. */ - static int tab_cur_size; - - char **p; - - if (*first) - { - if (tab == NULL) - tab = (char **) xmalloc (tab_alloc_size * sizeof (*tab)); - tab_cur_size = 0; - } - - /* Is NAME in tab? */ - for (p = tab; p < tab + tab_cur_size; p++) - if (strcmp (*p, name) == 0) - /* Yes; don't print it again. */ - return; - /* No; add it to tab. */ - if (tab_cur_size == tab_alloc_size) - { - tab_alloc_size *= 2; - tab = (char **) xrealloc (tab, tab_alloc_size * sizeof (*tab)); - } - tab[tab_cur_size++] = name; - - if (*first) - { - column = 0; - *first = 0; - } - else - { - printf_filtered (","); - column++; - } - - if (column != 0 && column + strlen (name) >= 70) - { - printf_filtered ("\n"); - column = 0; - } - else if (column != 0) - { - printf_filtered (" "); - column++; - } - fputs_filtered (name, stdout); - column += strlen (name); -} - -static void -sources_info () -{ - register struct symtab *s; - register struct partial_symtab *ps; - int first; - - if (symtab_list == 0 && partial_symtab_list == 0) - { - printf (no_symtab_msg); - return; - } - - printf_filtered ("Source files for which symbols have been read in:\n\n"); - - first = 1; - for (s = symtab_list; s; s = s->next) - output_source_filename (s->filename, &first); - printf_filtered ("\n\n"); - - printf_filtered ("Source files for which symbols will be read in on demand:\n\n"); - - first = 1; - for (ps = partial_symtab_list; ps; ps = ps->next) - if (!ps->readin) - output_source_filename (ps->filename, &first); - printf_filtered ("\n"); -} - -/* List all symbols (if REGEXP is 0) or all symbols matching REGEXP. - If CLASS is zero, list all symbols except functions and type names. - If CLASS is 1, list only functions. - If CLASS is 2, list only type names. - If CLASS is 3, list only method names. - - BPT is non-zero if we should set a breakpoint at the functions - we find. */ - -static void -list_symbols (regexp, class, bpt) - char *regexp; - int class; - int bpt; -{ - register struct symtab *s; - register struct partial_symtab *ps; - register struct blockvector *bv; - struct blockvector *prev_bv = 0; - register struct block *b; - register int i, j; - register struct symbol *sym; - struct partial_symbol *psym; - char *val; - static char *classnames[] - = {"variable", "function", "type", "method"}; - int found_in_file = 0; - int found_misc = 0; - static enum misc_function_type types[] - = {mf_data, mf_text, mf_abs, mf_unknown}; - static enum misc_function_type types2[] - = {mf_bss, mf_text, mf_abs, mf_unknown}; - enum misc_function_type ourtype = types[class]; - enum misc_function_type ourtype2 = types2[class]; - - if (regexp) - if (0 != (val = re_comp (regexp))) - error ("Invalid regexp (%s): %s", val, regexp); - - /* Search through the partial_symtab_list *first* for all symbols - matching the regexp. That way we don't have to reproduce all of - the machinery below. */ - for (ps = partial_symtab_list; ps; ps = ps->next) - { - struct partial_symbol *bound, *gbound, *sbound; - int keep_going = 1; - - if (ps->readin) continue; - - gbound = global_psymbols.list + ps->globals_offset + ps->n_global_syms; - sbound = static_psymbols.list + ps->statics_offset + ps->n_static_syms; - bound = gbound; - - /* Go through all of the symbols stored in a partial - symtab in one loop. */ - psym = global_psymbols.list + ps->globals_offset; - while (keep_going) - { - if (psym >= bound) - { - if (bound == gbound && ps->n_static_syms != 0) - { - psym = static_psymbols.list + ps->statics_offset; - bound = sbound; - } - else - keep_going = 0; - continue; - } - else - { - QUIT; - - /* If it would match (logic taken from loop below) - load the file and go on to the next one */ - if ((regexp == 0 || re_exec (SYMBOL_NAME (psym))) - && ((class == 0 && SYMBOL_CLASS (psym) != LOC_TYPEDEF - && SYMBOL_CLASS (psym) != LOC_BLOCK) - || (class == 1 && SYMBOL_CLASS (psym) == LOC_BLOCK) - || (class == 2 && SYMBOL_CLASS (psym) == LOC_TYPEDEF) - || (class == 3 && SYMBOL_CLASS (psym) == LOC_BLOCK))) - { - (void) PSYMTAB_TO_SYMTAB(ps); - keep_going = 0; - } - } - psym++; - } - } - - /* Here, we search through the misc function vector for functions that - match, and call find_pc_symtab on them to force their symbols to - be read. The symbol will then be found during the scan of symtabs - below. If find_pc_symtab fails, set found_misc so that we will - rescan to print any matching symbols without debug info. */ - - if (class == 1) { - for (i = 0; i < misc_function_count; i++) { - if (misc_function_vector[i].type != ourtype - && misc_function_vector[i].type != ourtype2) - continue; - if (regexp == 0 || re_exec (misc_function_vector[i].name)) { - if (0 == find_pc_symtab (misc_function_vector[i].address)) - found_misc = 1; - } - } - } - - /* Printout here so as to get after the "Reading in symbols" - messages which will be generated above. */ - if (!bpt) - printf_filtered (regexp - ? "All %ss matching regular expression \"%s\":\n" - : "All defined %ss:\n", - classnames[class], - regexp); - - for (s = symtab_list; s; s = s->next) - { - found_in_file = 0; - bv = BLOCKVECTOR (s); - /* Often many files share a blockvector. - Scan each blockvector only once so that - we don't get every symbol many times. - It happens that the first symtab in the list - for any given blockvector is the main file. */ - if (bv != prev_bv) - for (i = GLOBAL_BLOCK; i <= STATIC_BLOCK; i++) - { - b = BLOCKVECTOR_BLOCK (bv, i); - /* Skip the sort if this block is always sorted. */ - if (!BLOCK_SHOULD_SORT (b)) - sort_block_syms (b); - for (j = 0; j < BLOCK_NSYMS (b); j++) - { - QUIT; - sym = BLOCK_SYM (b, j); - if ((regexp == 0 || re_exec (SYMBOL_NAME (sym))) - && ((class == 0 && SYMBOL_CLASS (sym) != LOC_TYPEDEF - && SYMBOL_CLASS (sym) != LOC_BLOCK) - || (class == 1 && SYMBOL_CLASS (sym) == LOC_BLOCK) - || (class == 2 && SYMBOL_CLASS (sym) == LOC_TYPEDEF) - || (class == 3 && SYMBOL_CLASS (sym) == LOC_BLOCK))) - { - if (bpt) - { - /* Set a breakpoint here, if it's a function */ - if (class == 1) - break_command (SYMBOL_NAME(sym), 0); - } - else if (!found_in_file) - { - fputs_filtered ("\nFile ", stdout); - fputs_filtered (s->filename, stdout); - fputs_filtered (":\n", stdout); - } - found_in_file = 1; - - if (class != 2 && i == STATIC_BLOCK) - printf_filtered ("static "); - - /* Typedef that is not a C++ class */ - if (class == 2 - && SYMBOL_NAMESPACE (sym) != STRUCT_NAMESPACE) - typedef_print (SYMBOL_TYPE(sym), sym, stdout); - /* variable, func, or typedef-that-is-c++-class */ - else if (class < 2 || - (class == 2 && - SYMBOL_NAMESPACE(sym) == STRUCT_NAMESPACE)) - { - type_print (SYMBOL_TYPE (sym), - (SYMBOL_CLASS (sym) == LOC_TYPEDEF - ? "" : SYMBOL_NAME (sym)), - stdout, 0); - - printf_filtered (";\n"); - } - else - { -# if 0 - char buf[1024]; - type_print_base (TYPE_FN_FIELD_TYPE(t, i), stdout, 0, 0); - type_print_varspec_prefix (TYPE_FN_FIELD_TYPE(t, i), stdout, 0); - sprintf (buf, " %s::", type_name_no_tag (t)); - type_print_method_args (TYPE_FN_FIELD_ARGS (t, i), buf, name, stdout); -# endif - } - } - } - } - prev_bv = bv; - } - - - /* If there are no eyes, avoid all contact. I mean, if there are - no debug symbols, then print directly from the misc_function_vector. */ - - if (found_misc || class != 1) { - found_in_file = 0; - for (i = 0; i < misc_function_count; i++) { - if (misc_function_vector[i].type != ourtype - && misc_function_vector[i].type != ourtype2) - continue; - if (regexp == 0 || re_exec (misc_function_vector[i].name)) { - /* Functions: Look up by address. */ - if (class == 1) - if (0 != find_pc_symtab (misc_function_vector[i].address)) - continue; - /* Variables/Absolutes: Look up by name */ - if (0 != lookup_symbol (misc_function_vector[i].name, - (struct block *)0, VAR_NAMESPACE, 0, (struct symtab **)0)) - continue; - if (!found_in_file) { - printf_filtered ("\nNon-debugging symbols:\n"); - found_in_file = 1; - } - printf_filtered (" %08x %s\n", - misc_function_vector[i].address, - misc_function_vector[i].name); - } - } - } -} - -static void -variables_info (regexp) - char *regexp; -{ - list_symbols (regexp, 0, 0); -} - -static void -functions_info (regexp) - char *regexp; -{ - list_symbols (regexp, 1, 0); -} - -static void -types_info (regexp) - char *regexp; -{ - list_symbols (regexp, 2, 0); -} - -#if 0 -/* Tiemann says: "info methods was never implemented." */ -static void -methods_info (regexp) - char *regexp; -{ - list_symbols (regexp, 3, 0); -} -#endif /* 0 */ - -/* Breakpoint all functions matching regular expression. */ -static void -rbreak_command (regexp) - char *regexp; -{ - list_symbols (regexp, 1, 1); -} - -/* Helper function to initialize the standard scalar types. */ - -struct type * -init_type (code, length, uns, name) - enum type_code code; - int length, uns; - char *name; -{ - register struct type *type; - - type = (struct type *) xmalloc (sizeof (struct type)); - bzero (type, sizeof *type); - TYPE_MAIN_VARIANT (type) = type; - TYPE_CODE (type) = code; - TYPE_LENGTH (type) = length; - TYPE_FLAGS (type) = uns ? TYPE_FLAG_UNSIGNED : 0; - TYPE_FLAGS (type) |= TYPE_FLAG_PERM; - TYPE_NFIELDS (type) = 0; - TYPE_NAME (type) = name; - - /* C++ fancies. */ - TYPE_NFN_FIELDS (type) = 0; - TYPE_N_BASECLASSES (type) = 0; - return type; -} - -/* Return Nonzero if block a is lexically nested within block b, - or if a and b have the same pc range. - Return zero otherwise. */ -int -contained_in (a, b) - struct block *a, *b; -{ - if (!a || !b) - return 0; - return BLOCK_START (a) >= BLOCK_START (b) - && BLOCK_END (a) <= BLOCK_END (b); -} - - -/* Helper routine for make_symbol_completion_list. */ - -int return_val_size, return_val_index; -char **return_val; - -void -completion_list_add_symbol (symname) - char *symname; -{ - if (return_val_index + 3 > return_val_size) - return_val = - (char **)xrealloc (return_val, - (return_val_size *= 2) * sizeof (char *)); - - return_val[return_val_index] = - (char *)xmalloc (1 + strlen (symname)); - - strcpy (return_val[return_val_index], symname); - - return_val[++return_val_index] = (char *)NULL; -} - -/* Return a NULL terminated array of all symbols (regardless of class) which - begin by matching TEXT. If the answer is no symbols, then the return value - is an array which contains only a NULL pointer. - - Problem: All of the symbols have to be copied because readline - frees them. I'm not going to worry about this; hopefully there - won't be that many. */ - -char ** -make_symbol_completion_list (text) - char *text; -{ - register struct symtab *s; - register struct partial_symtab *ps; - register struct block *b, *surrounding_static_block = 0; - extern struct block *get_selected_block (); - register int i, j; - struct partial_symbol *psym; - - int text_len = strlen (text); - return_val_size = 100; - return_val_index = 0; - return_val = - (char **)xmalloc ((1 + return_val_size) *sizeof (char *)); - return_val[0] = (char *)NULL; - - /* Look through the partial symtabs for all symbols which begin - by matching TEXT. Add each one that you find to the list. */ - - for (ps = partial_symtab_list; ps; ps = ps->next) - { - /* If the psymtab's been read in we'll get it when we search - through the blockvector. */ - if (ps->readin) continue; - - for (psym = global_psymbols.list + ps->globals_offset; - psym < (global_psymbols.list + ps->globals_offset - + ps->n_global_syms); - psym++) - { - QUIT; /* If interrupted, then quit. */ - if ((strncmp (SYMBOL_NAME (psym), text, text_len) == 0)) - completion_list_add_symbol (SYMBOL_NAME (psym)); - } - - for (psym = static_psymbols.list + ps->statics_offset; - psym < (static_psymbols.list + ps->statics_offset - + ps->n_static_syms); - psym++) - { - QUIT; - if ((strncmp (SYMBOL_NAME (psym), text, text_len) == 0)) - completion_list_add_symbol (SYMBOL_NAME (psym)); - } - } - - /* At this point scan through the misc function vector and add each - symbol you find to the list. Eventually we want to ignore - anything that isn't a text symbol (everything else will be - handled by the psymtab code above). */ - - for (i = 0; i < misc_function_count; i++) - if (!strncmp (text, misc_function_vector[i].name, text_len)) - completion_list_add_symbol (misc_function_vector[i].name); - - /* Search upwards from currently selected frame (so that we can - complete on local vars. */ - for (b = get_selected_block (); b; b = BLOCK_SUPERBLOCK (b)) - { - if (!BLOCK_SUPERBLOCK (b)) - surrounding_static_block = b; /* For elmin of dups */ - - /* Also catch fields of types defined in this places which - match our text string. Only complete on types visible - from current context. */ - for (i = 0; i < BLOCK_NSYMS (b); i++) - { - register struct symbol *sym = BLOCK_SYM (b, i); - - if (!strncmp (SYMBOL_NAME (sym), text, text_len)) - completion_list_add_symbol (SYMBOL_NAME (sym)); - - if (SYMBOL_CLASS (sym) == LOC_TYPEDEF) - { - struct type *t = SYMBOL_TYPE (sym); - enum type_code c = TYPE_CODE (t); - - if (c == TYPE_CODE_UNION || c == TYPE_CODE_STRUCT) - for (j = TYPE_N_BASECLASSES (t); j < TYPE_NFIELDS (t); j++) - if (TYPE_FIELD_NAME (t, j) && - !strncmp (TYPE_FIELD_NAME (t, j), text, text_len)) - completion_list_add_symbol (TYPE_FIELD_NAME (t, j)); - } - } - } - - /* Go through the symtabs and check the externs and statics for - symbols which match. */ - - for (s = symtab_list; s; s = s->next) - { - b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK); - - for (i = 0; i < BLOCK_NSYMS (b); i++) - if (!strncmp (SYMBOL_NAME (BLOCK_SYM (b, i)), text, text_len)) - completion_list_add_symbol (SYMBOL_NAME (BLOCK_SYM (b, i))); - } - - for (s = symtab_list; s; s = s->next) - { - b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK); - - /* Don't do this block twice. */ - if (b == surrounding_static_block) continue; - - for (i = 0; i < BLOCK_NSYMS (b); i++) - if (!strncmp (SYMBOL_NAME (BLOCK_SYM (b, i)), text, text_len)) - completion_list_add_symbol (SYMBOL_NAME (BLOCK_SYM (b, i))); - } - - return (return_val); -} - -#if 0 -/* Add the type of the symbol sym to the type of the current - function whose block we are in (assumed). The type of - this current function is contained in *TYPE. - - This basically works as follows: When we find a function - symbol (N_FUNC with a 'f' or 'F' in the symbol name), we record - a pointer to its type in the global in_function_type. Every - time we come across a parameter symbol ('p' in its name), then - this procedure adds the name and type of that parameter - to the function type pointed to by *TYPE. (Which should correspond - to in_function_type if it was called correctly). - - Note that since we are modifying a type, the result of - lookup_function_type() should be bcopy()ed before calling - this. When not in strict typing mode, the expression - evaluator can choose to ignore this. - - Assumption: All of a function's parameter symbols will - appear before another function symbol is found. The parameters - appear in the same order in the argument list as they do in the - symbol table. */ - -void -add_param_to_type (type,sym) - struct type **type; - struct symbol *sym; -{ - int num = ++(TYPE_NFIELDS(*type)); - - if(TYPE_NFIELDS(*type)-1) - TYPE_FIELDS(*type) = - (struct field *)xrealloc((char *)(TYPE_FIELDS(*type)), - num*sizeof(struct field)); - else - TYPE_FIELDS(*type) = - (struct field *)xmalloc(num*sizeof(struct field)); - - TYPE_FIELD_BITPOS(*type,num-1) = num-1; - TYPE_FIELD_BITSIZE(*type,num-1) = 0; - TYPE_FIELD_TYPE(*type,num-1) = SYMBOL_TYPE(sym); - TYPE_FIELD_NAME(*type,num-1) = SYMBOL_NAME(sym); -} -#endif - -void -_initialize_symtab () -{ - add_info ("variables", variables_info, - "All global and static variable names, or those matching REGEXP."); - add_info ("functions", functions_info, - "All function names, or those matching REGEXP."); - - /* FIXME: This command has at least the following problems: - 1. It prints builtin types (in a very strange and confusing fashion). - 2. It doesn't print right, e.g. with - typedef struct foo *FOO - type_print prints "FOO" when we want to make it (in this situation) - print "struct foo *". - I also think "ptype" or "whatis" is more likely to be useful (but if - there is much disagreement "info types" can be fixed). */ - add_info ("types", types_info, - "All types names, or those matching REGEXP."); - -#if 0 - add_info ("methods", methods_info, - "All method names, or those matching REGEXP::REGEXP.\n\ -If the class qualifier is ommited, it is assumed to be the current scope.\n\ -If the first REGEXP is ommited, then all methods matching the second REGEXP\n\ -are listed."); -#endif - add_info ("sources", sources_info, - "Source files in the program."); - - add_com ("rbreak", no_class, rbreak_command, - "Set a breakpoint for all functions matching REGEXP."); - - /* Initialize the one built-in type that isn't language dependent... */ - builtin_type_error = init_type (TYPE_CODE_ERROR, 0, 0, ""); -} diff --git a/gdb/symtab.h b/gdb/symtab.h deleted file mode 100644 index c97c22aa911..00000000000 --- a/gdb/symtab.h +++ /dev/null @@ -1,922 +0,0 @@ -/* Symbol table definitions for GDB. - Copyright (C) 1986, 1989, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#if !defined (SYMTAB_H) -#define SYMTAB_H 1 -#include - -/* An obstack to hold objects that should be freed - when we load a new symbol table. - This includes the symbols made by dbxread - and the types that are not permanent. */ - -extern struct obstack *symbol_obstack; -extern struct obstack *psymbol_obstack; - -/* Some definitions and declarations to go with use of obstacks. */ -#define obstack_chunk_alloc xmalloc -#define obstack_chunk_free free -#ifdef __STDC__ -extern void *xmalloc (); -#else -extern char *xmalloc (); -#endif -extern void free (); - -/* Some macros for char-based bitfields. */ -#define B_SET(a,x) (a[x>>3] |= (1 << (x&7))) -#define B_CLR(a,x) (a[x>>3] &= ~(1 << (x&7))) -#define B_TST(a,x) (a[x>>3] & (1 << (x&7))) -#define B_TYPE unsigned char -#define B_BYTES(x) ( 1 + ((x)>>3) ) -#define B_CLRALL(a,x) bzero (a, B_BYTES(x)) - -/* gdb can know one or several symbol tables at the same time; - the ultimate intent is to have one for each separately-compiled module. - Each such symbol table is recorded by a struct symtab, and they - are all chained together. */ - -/* In addition, gdb can record any number of miscellaneous undebuggable - functions' addresses. In a system that appends _ to function names, - the _'s are removed from the names stored in this table. */ - -/* Actually, the misc function list is used to store *all* of the - global symbols (text, data, bss, and abs). It is sometimes used - to figure out what symtabs to read in. The "type" field is used - occasionally. Calling it the misc "function" vector is now a misnomer. - - The misc_info field is available for machine-specific information - that can be cached along with a misc function vector entry. The - AMD 29000 tdep.c uses it to remember things it has decoded from the - instructions in the function header, so it doesn't have to rederive - the info constantly (over a serial line). It is initialized to zero - and stays that way until target-dependent code sets it. */ - -enum misc_function_type {mf_unknown = 0, mf_text, mf_data, mf_bss, mf_abs}; - -struct misc_function -{ - char *name; - CORE_ADDR address; - char *misc_info; /* Random pointer to misc info. void * but for old C */ - enum misc_function_type type; -}; - -/* Address and length of the vector recording all misc function names/addresses. */ - -struct misc_function *misc_function_vector; -int misc_function_count; - -/* Different kinds of data types are distinguished by the `code' field. */ - -enum type_code -{ - TYPE_CODE_UNDEF, /* Not used; catches errors */ - TYPE_CODE_PTR, /* Pointer type */ - TYPE_CODE_ARRAY, /* Array type, lower bound zero */ - TYPE_CODE_STRUCT, /* C struct or Pascal record */ - TYPE_CODE_UNION, /* C union or Pascal variant part */ - TYPE_CODE_ENUM, /* Enumeration type */ - TYPE_CODE_FUNC, /* Function type */ - TYPE_CODE_INT, /* Integer type */ - TYPE_CODE_FLT, /* Floating type */ - TYPE_CODE_VOID, /* Void type (values zero length) */ - TYPE_CODE_SET, /* Pascal sets */ - TYPE_CODE_RANGE, /* Range (integers within spec'd bounds) */ - TYPE_CODE_PASCAL_ARRAY, /* Array with explicit type of index */ - TYPE_CODE_ERROR, /* Unknown type */ - - /* C++ */ - TYPE_CODE_MEMBER, /* Member type */ - TYPE_CODE_METHOD, /* Method type */ - TYPE_CODE_REF, /* C++ Reference types */ - - /* Modula-2 */ - TYPE_CODE_CHAR, /* *real* character type */ - TYPE_CODE_BOOL, /* Builtin Modula-2 BOOLEAN */ -}; - -/* This appears in a type's flags word for an unsigned integer type. */ -#define TYPE_FLAG_UNSIGNED 1 -/* This appears in a type's flags word - if it is a (pointer to a|function returning a)* built in scalar type. - These types are never freed. */ -#define TYPE_FLAG_PERM 4 -/* This appears in a type's flags word if it is a stub type (eg. if - someone referenced a type that wasn't definined in a source file - via (struct sir_not_appearing_in_this_film *)). */ -#define TYPE_FLAG_STUB 8 -/* Set when a class has a constructor defined */ -#define TYPE_FLAG_HAS_CONSTRUCTOR 256 -/* Set when a class has a destructor defined */ -#define TYPE_FLAG_HAS_DESTRUCTOR 512 - -struct type -{ - /* Code for kind of type */ - enum type_code code; - /* Name of this type, or zero if none. - This is used for printing only, except by poorly designed C++ code. - Type names specified as input are defined by symbols. */ - char *name; - /* Length in bytes of storage for a value of this type */ - unsigned length; - /* For a pointer type, describes the type of object pointed to. - For an array type, describes the type of the elements. - For a function or method type, describes the type of the value. - For a range type, describes the type of the full range. - Unused otherwise. */ - struct type *target_type; - /* Type that is a pointer to this type. - Zero if no such pointer-to type is known yet. - The debugger may add the address of such a type - if it has to construct one later. */ - struct type *pointer_type; - /* C++: also need a reference type. */ - struct type *reference_type; - struct type **arg_types; - - /* Type that is a function returning this type. - Zero if no such function type is known here. - The debugger may add the address of such a type - if it has to construct one later. */ - struct type *function_type; - -/* Handling of pointers to members: - TYPE_MAIN_VARIANT is used for pointer and pointer - to member types. Normally it the value of the address of its - containing type. However, for pointers to members, we must be - able to allocate pointer to member types and look them up - from some place of reference. - NEXT_VARIANT is the next element in the chain. - - A long time ago (Jul 88; GDB 2.5) Tiemann said that main_variant - may no longer be necessary and that he might eliminate it. I don't - know whether this is still true (or ever was). */ - struct type *main_variant, *next_variant; - - /* Flags about this type. */ - short flags; - /* Number of fields described for this type */ - short nfields; - /* For structure and union types, a description of each field. - For set and pascal array types, there is one "field", - whose type is the domain type of the set or array. - For range types, there are two "fields", - the minimum and maximum values (both inclusive). - For enum types, each possible value is described by one "field". - - Using a pointer to a separate array of fields - allows all types to have the same size, which is useful - because we can allocate the space for a type before - we know what to put in it. */ - struct field - { - /* Position of this field, counting in bits from start of - containing structure. For a function type, this is the - position in the argument list of this argument. - For a range bound or enum value, this is the value itself. */ - int bitpos; - /* Size of this field, in bits, or zero if not packed. - For an unpacked field, the field's type's length - says how many bytes the field occupies. */ - int bitsize; - /* In a struct or enum type, type of this field. - In a function type, type of this argument. - In an array type, the domain-type of the array. */ - struct type *type; - /* Name of field, value or argument. - Zero for range bounds and array domains. */ - char *name; - } *fields; - - /* C++ */ - B_TYPE *virtual_field_bits; /* if base class is virtual */ - B_TYPE *private_field_bits; - B_TYPE *protected_field_bits; - - /* Number of methods described for this type */ - short nfn_fields; - /* Number of base classes this type derives from. */ - short n_baseclasses; - - /* Number of methods described for this type plus all the - methods that it derives from. */ - int nfn_fields_total; - - /* For classes, structures, and unions, a description of each field, - which consists of an overloaded name, followed by the types of - arguments that the method expects, and then the name after it - has been renamed to make it distinct. */ - struct fn_fieldlist - { - /* The overloaded name. */ - char *name; - /* The number of methods with this name. */ - int length; - /* The list of methods. */ - struct fn_field - { - /* The return value of the method */ - struct type *type; - /* The argument list */ - struct type **args; - /* The name after it has been processed */ - char *physname; - - /* For virtual functions. */ - /* First baseclass that defines this virtual function. */ - struct type *fcontext; - unsigned int is_const : 1; - unsigned int is_volatile : 1; - /* Index into that baseclass's virtual function table, - minus 2; else if static: VOFFSET_STATIC; else: 0. */ - unsigned voffset : 30; -# define VOFFSET_STATIC 1 - } *fn_fields; - - B_TYPE *private_fn_field_bits; - B_TYPE *protected_fn_field_bits; - - } *fn_fieldlists; - - unsigned char via_protected; - unsigned char via_public; - - /* For types with virtual functions, VPTR_BASETYPE is the base class which - defined the virtual function table pointer. VPTR_FIELDNO is - the field number of that pointer in the structure. - - For types that are pointer to member types, VPTR_BASETYPE - ifs the type that this pointer is a member of. - - Unused otherwise. */ - struct type *vptr_basetype; - - int vptr_fieldno; -}; - -/* All of the name-scope contours of the program - are represented by `struct block' objects. - All of these objects are pointed to by the blockvector. - - Each block represents one name scope. - Each lexical context has its own block. - - The first two blocks in the blockvector are special. - The first one contains all the symbols defined in this compilation - whose scope is the entire program linked together. - The second one contains all the symbols whose scope is the - entire compilation excluding other separate compilations. - In C, these correspond to global symbols and static symbols. - - Each block records a range of core addresses for the code that - is in the scope of the block. The first two special blocks - give, for the range of code, the entire range of code produced - by the compilation that the symbol segment belongs to. - - The blocks appear in the blockvector - in order of increasing starting-address, - and, within that, in order of decreasing ending-address. - - This implies that within the body of one function - the blocks appear in the order of a depth-first tree walk. */ - -struct blockvector -{ - /* Number of blocks in the list. */ - int nblocks; - /* The blocks themselves. */ - struct block *block[1]; -}; - -/* Special block numbers */ -#define GLOBAL_BLOCK 0 -#define STATIC_BLOCK 1 -#define FIRST_LOCAL_BLOCK 2 - -struct block -{ - /* Addresses in the executable code that are in this block. - Note: in an unrelocated symbol segment in a file, - these are always zero. They can be filled in from the - N_LBRAC and N_RBRAC symbols in the loader symbol table. */ - CORE_ADDR startaddr, endaddr; - /* The symbol that names this block, - if the block is the body of a function; - otherwise, zero. - Note: In an unrelocated symbol segment in an object file, - this field may be zero even when the block has a name. - That is because the block is output before the name - (since the name resides in a higher block). - Since the symbol does point to the block (as its value), - it is possible to find the block and set its name properly. */ - struct symbol *function; - /* The `struct block' for the containing block, or 0 if none. */ - /* Note that in an unrelocated symbol segment in an object file - this pointer may be zero when the correct value should be - the second special block (for symbols whose scope is one compilation). - This is because the compiler ouptuts the special blocks at the - very end, after the other blocks. */ - struct block *superblock; - /* A flag indicating whether or not the fucntion corresponding - to this block was compiled with gcc or not. If there is no - function corresponding to this block, this meaning of this flag - is undefined. (In practice it will be 1 if the block was created - while processing a file compiled with gcc and 0 when not). */ - unsigned char gcc_compile_flag; - /* Number of local symbols. */ - int nsyms; - /* The symbols. */ - struct symbol *sym[1]; -}; - -/* Represent one symbol name; a variable, constant, function or typedef. */ - -/* Different name spaces for symbols. Looking up a symbol specifies - a namespace and ignores symbol definitions in other name spaces. - - VAR_NAMESPACE is the usual namespace. - In C, this contains variables, function names, typedef names - and enum type values. - - STRUCT_NAMESPACE is used in C to hold struct, union and enum type names. - Thus, if `struct foo' is used in a C program, - it produces a symbol named `foo' in the STRUCT_NAMESPACE. - - LABEL_NAMESPACE may be used for names of labels (for gotos); - currently it is not used and labels are not recorded at all. */ - -/* For a non-global symbol allocated statically, - the correct core address cannot be determined by the compiler. - The compiler puts an index number into the symbol's value field. - This index number can be matched with the "desc" field of - an entry in the loader symbol table. */ - -enum namespace -{ - UNDEF_NAMESPACE, VAR_NAMESPACE, STRUCT_NAMESPACE, LABEL_NAMESPACE, -}; - -/* An address-class says where to find the value of a symbol. */ - -enum address_class -{ - LOC_UNDEF, /* Not used; catches errors */ - LOC_CONST, /* Value is constant int SYMBOL_VALUE, host byteorder */ - LOC_STATIC, /* Value is at fixed address SYMBOL_VALUE_ADDRESS */ - LOC_REGISTER, /* Value is in register */ - LOC_ARG, /* Value is at spec'd offset in arglist */ - LOC_REF_ARG, /* Value address is at spec'd offset in arglist. */ - LOC_REGPARM, /* Value is at spec'd offset in register window */ - LOC_LOCAL, /* Value is at spec'd offset in stack frame */ - LOC_TYPEDEF, /* Value not used; definition in SYMBOL_TYPE - Symbols in the namespace STRUCT_NAMESPACE - all have this class. */ - LOC_LABEL, /* Value is address SYMBOL_VALUE_ADDRESS in the code */ - LOC_BLOCK, /* Value is address SYMBOL_VALUE_BLOCK of a - `struct block'. Function names have this class. */ - LOC_CONST_BYTES, /* Value is a constant byte-sequence pointed to by - SYMBOL_VALUE_ADDRESS, in target byte order. */ - LOC_LOCAL_ARG, /* Value is arg at spec'd offset in stack frame. - Differs from LOC_LOCAL in that symbol is an - argument; differs from LOC_ARG in that we find it - in the frame (FRAME_LOCALS_ADDRESS), not in the - arglist (FRAME_ARGS_ADDRESS). Added for i960, - which passes args in regs then copies to frame. */ -}; - -struct symbol -{ - /* Symbol name */ - char *name; - /* Name space code. */ - enum namespace namespace; - /* Address class */ - enum address_class class; - /* Data type of value */ - struct type *type; - - /* Line number of definition. */ - unsigned short line; - - /* constant value, or address if static, or register number, - or offset in arguments, or offset in stack frame. All of - these are in host byte order (though what they point to might - be in target byte order, e.g. LOC_CONST_BYTES). */ - union - { - long value; /* for LOC_CONST, LOC_REGISTER, LOC_ARG, - LOC_REF_ARG, LOC_REGPARM, LOC_LOCAL */ - struct block *block; /* for LOC_BLOCK */ - char *bytes; /* for LOC_CONST_BYTES */ - CORE_ADDR address; /* for LOC_STATIC, LOC_LABEL */ - struct symbol *chain; /* for opaque typedef struct chain */ - } - value; -}; - - -/* A partial_symbol records the name, namespace, and address class of - symbols whose types we have not parsed yet. For functions, it also - contains their memory address, so we can find them from a PC value. - Each partial_symbol sits in a partial_symtab, all of which are chained - on the partial_symtab_list and which points to the corresponding - normal symtab once the partial_symtab has been referenced. */ - -struct partial_symbol -{ - /* Symbol name */ - char *name; - /* Name space code. */ - enum namespace namespace; - /* Address class (for info_symbols) */ - enum address_class class; - /* Value (only used for static functions currently). Done this - way so that we can use the struct symbol macros. - Note that the address of a function is SYMBOL_VALUE_ADDRESS (pst) - in a partial symbol table, but BLOCK_START (SYMBOL_BLOCK_VALUE (st)) - in a symbol table. */ - union - { - long value; - CORE_ADDR address; - } - value; -}; - -/* Source-file information. - This describes the relation between source files and line numbers - and addresses in the program text. */ - -struct sourcevector -{ - int length; /* Number of source files described */ - struct source *source[1]; /* Descriptions of the files */ -}; - -/* Each item represents a line-->pc (or the reverse) mapping. This is - somewhat more wasteful of space than one might wish, but since only - the files which are actually debugged are read in to core, we don't - waste much space. - - Each item used to be an int; either minus a line number, or a - program counter. If it represents a line number, that is the line - described by the next program counter value. If it is positive, it - is the program counter at which the code for the next line starts. */ - -struct linetable_entry -{ - int line; - CORE_ADDR pc; -}; - -struct linetable -{ - int nitems; - struct linetable_entry item[1]; -}; - -/* All the information on one source file. */ - -struct source -{ - char *name; /* Name of file */ - struct linetable contents; -}; - -/* Each source file is represented by a struct symtab. - These objects are chained through the `next' field. */ - -struct symtab - { - /* Chain of all existing symtabs. */ - struct symtab *next; - /* List of all symbol scope blocks for this symtab. */ - struct blockvector *blockvector; - /* Table mapping core addresses to line numbers for this file. - Can be NULL if none. */ - struct linetable *linetable; - /* Name of this source file. */ - char *filename; - /* Directory in which it was compiled, or NULL if we don't know. */ - char *dirname; - /* This component says how to free the data we point to: - free_contents => do a tree walk and free each object. - free_nothing => do nothing; some other symtab will free - the data this one uses. - free_linetable => free just the linetable. */ - enum free_code {free_nothing, free_contents, free_linetable} - free_code; - /* Pointer to one block of storage to be freed, if nonzero. */ - /* This is IN ADDITION to the action indicated by free_code. */ - char *free_ptr; - /* Total number of lines found in source file. */ - int nlines; - /* Array mapping line number to character position. */ - int *line_charpos; - /* Language of this source file. */ - enum language language; - /* String of version information. May be zero. */ - char *version; - /* Full name of file as found by searching the source path. - 0 if not yet known. */ - char *fullname; - - /* Object file from which this symbol information was read. */ - struct objfile *objfile; - /* Chain of all symtabs owned by that objfile. */ - struct symtab *objfile_chain; - - /* Anything extra for this symtab. This is for target machines - with special debugging info of some sort (which cannot just - be represented in a normal symtab). */ -#if defined (EXTRA_SYMTAB_INFO) - EXTRA_SYMTAB_INFO -#endif - }; - -/* Each source file that has not been fully read in is represented by - a partial_symtab. This contains the information on where in the - executable the debugging symbols for a specific file are, and a - list of names of global symbols which are located in this file. - They are all chained on partial_symtab_list. - - Even after the source file has been read into a symtab, the - partial_symtab remains around. They are allocated on an obstack, - psymbol_obstack. FIXME, this is bad for dynamic linking or VxWorks- - style execution of a bunch of .o's. */ -struct partial_symtab -{ - /* Chain of all existing partial symtabs. */ - struct partial_symtab *next; - /* Name of the source file which this partial_symtab defines */ - char *filename; - - /* Information about the object file from which symbols should be read. */ - struct objfile *objfile; - /* Chain of psymtabs owned by this objfile */ - struct partial_symtab *objfile_chain; - - /* Address relative to which the symbols in this file are. Need to - relocate by this amount when reading in symbols from the symbol - file. */ - CORE_ADDR addr; - /* Range of text addresses covered by this file; texthigh is the - beginning of the next section. */ - CORE_ADDR textlow, texthigh; - /* Array of pointers to all of the partial_symtab's which this one - depends on. Since this array can only be set to previous or - the current (?) psymtab, this dependency tree is guaranteed not - to have any loops. */ - struct partial_symtab **dependencies; - int number_of_dependencies; - /* Global symbol list. This list will be sorted after readin to - improve access. Binary search will be the usual method of - finding a symbol within it. globals_offset is an integer offset - within global_psymbols[]. */ - int globals_offset, n_global_syms; - /* Static symbol list. This list will *not* be sorted after readin; - to find a symbol in it, exhaustive search must be used. This is - reasonable because searches through this list will eventually - lead to either the read in of a files symbols for real (assumed - to take a *lot* of time; check) or an error (and we don't care - how long errors take). This is an offset and size within - static_psymbols[]. */ - int statics_offset, n_static_syms; - /* Pointer to symtab eventually allocated for this source file, 0 if - !readin or if we haven't looked for the symtab after it was readin. */ - struct symtab *symtab; - /* Pointer to function which will read in the symtab corresponding to - this psymtab. */ - void (*read_symtab) (); - /* Information that lets read_symtab() locate the part of the symbol table - that this psymtab corresponds to. This information is private to the - format-dependent symbol reading routines. For further detail examine - the various symbol reading modules. Should really be (void *) but is - (char *) as with other such gdb variables. (FIXME) */ - char *read_symtab_private; - /* Non-zero if the symtab corresponding to this psymtab has been - readin */ - unsigned char readin; -}; - -/* A fast way to get from a psymtab to its symtab (after the first time). */ -#define PSYMTAB_TO_SYMTAB(pst) ((pst)->symtab? \ - (pst)->symtab: \ - psymtab_to_symtab (pst) ) - -/* This is the list of struct symtab's that gdb considers current. */ - -struct symtab *symtab_list; - -/* This is the list of struct partial_symtab's that gdb may need to access */ - -struct partial_symtab *partial_symtab_list; - -/* This symtab variable specifies the current file for printing source lines */ - -struct symtab *current_source_symtab; - -/* This is the next line to print for listing source lines. */ - -int current_source_line; - -#define BLOCKVECTOR(symtab) (symtab)->blockvector - -#define LINETABLE(symtab) (symtab)->linetable - -/* Macros normally used to access components of symbol table structures. */ - -#define BLOCKVECTOR_NBLOCKS(blocklist) (blocklist)->nblocks -#define BLOCKVECTOR_BLOCK(blocklist,n) (blocklist)->block[n] - -#define BLOCK_START(bl) (bl)->startaddr -#define BLOCK_END(bl) (bl)->endaddr -#define BLOCK_NSYMS(bl) (bl)->nsyms -#define BLOCK_SYM(bl, n) (bl)->sym[n] -#define BLOCK_FUNCTION(bl) (bl)->function -#define BLOCK_SUPERBLOCK(bl) (bl)->superblock -#define BLOCK_GCC_COMPILED(bl) (bl)->gcc_compile_flag - -/* Nonzero if symbols of block BL should be sorted alphabetically. */ -#define BLOCK_SHOULD_SORT(bl) ((bl)->nsyms >= 40) - -#define SYMBOL_NAME(symbol) (symbol)->name -#define SYMBOL_NAMESPACE(symbol) (symbol)->namespace -#define SYMBOL_CLASS(symbol) (symbol)->class -#define SYMBOL_VALUE(symbol) (symbol)->value.value -#define SYMBOL_VALUE_ADDRESS(symbol) (symbol)->value.address -#define SYMBOL_VALUE_BYTES(symbol) (symbol)->value.bytes -#define SYMBOL_BLOCK_VALUE(symbol) (symbol)->value.block -#define SYMBOL_VALUE_CHAIN(symbol) (symbol)->value.chain -#define SYMBOL_TYPE(symbol) (symbol)->type -#define SYMBOL_LINE(symbol) (symbol)->line - -#define TYPE_NAME(thistype) (thistype)->name -#define TYPE_TARGET_TYPE(thistype) (thistype)->target_type -#define TYPE_POINTER_TYPE(thistype) (thistype)->pointer_type -#define TYPE_REFERENCE_TYPE(thistype) (thistype)->reference_type -#define TYPE_FUNCTION_TYPE(thistype) (thistype)->function_type -#define TYPE_MAIN_VARIANT(thistype) (thistype)->main_variant -#define TYPE_NEXT_VARIANT(thistype) (thistype)->next_variant -#define TYPE_LENGTH(thistype) (thistype)->length -#define TYPE_FLAGS(thistype) (thistype)->flags -#define TYPE_UNSIGNED(thistype) ((thistype)->flags & TYPE_FLAG_UNSIGNED) -#define TYPE_CODE(thistype) (thistype)->code -#define TYPE_NFIELDS(thistype) (thistype)->nfields -#define TYPE_FIELDS(thistype) (thistype)->fields -/* C++ */ -#define TYPE_VPTR_BASETYPE(thistype) (thistype)->vptr_basetype -#define TYPE_DOMAIN_TYPE(thistype) (thistype)->vptr_basetype -#define TYPE_VPTR_FIELDNO(thistype) (thistype)->vptr_fieldno -#define TYPE_FN_FIELDS(thistype) (thistype)->fn_fields -#define TYPE_NFN_FIELDS(thistype) (thistype)->nfn_fields -#define TYPE_NFN_FIELDS_TOTAL(thistype) (thistype)->nfn_fields_total -#define TYPE_ARG_TYPES(thistype) (thistype)->arg_types -#define TYPE_BASECLASS(thistype,index) (thistype)->fields[index].type -#define TYPE_N_BASECLASSES(thistype) (thistype)->n_baseclasses -#define TYPE_BASECLASS_NAME(thistype,index) (thistype)->fields[index].name -#define TYPE_BASECLASS_BITPOS(thistype,index) (thistype)->fields[index].bitpos -#define BASETYPE_VIA_PUBLIC(thistype, index) (!TYPE_FIELD_PRIVATE(thistype, index)) -#define BASETYPE_VIA_VIRTUAL(thistype, index) B_TST((thistype)->virtual_field_bits, (index)) - -#define TYPE_FIELD(thistype, n) (thistype)->fields[n] -#define TYPE_FIELD_TYPE(thistype, n) (thistype)->fields[n].type -#define TYPE_FIELD_NAME(thistype, n) (thistype)->fields[n].name -#define TYPE_FIELD_VALUE(thistype, n) (* (int*) &(thistype)->fields[n].type) -#define TYPE_FIELD_BITPOS(thistype, n) (thistype)->fields[n].bitpos -#define TYPE_FIELD_BITSIZE(thistype, n) (thistype)->fields[n].bitsize -#define TYPE_FIELD_PACKED(thistype, n) (thistype)->fields[n].bitsize - -#define TYPE_FIELD_PRIVATE_BITS(thistype) (thistype)->private_field_bits -#define TYPE_FIELD_PROTECTED_BITS(thistype) (thistype)->protected_field_bits -#define TYPE_FIELD_VIRTUAL_BITS(thistype) (thistype)->virtual_field_bits -#define SET_TYPE_FIELD_PRIVATE(thistype, n) B_SET ((thistype)->private_field_bits, (n)) -#define SET_TYPE_FIELD_PROTECTED(thistype, n) B_SET ((thistype)->protected_field_bits, (n)) -#define SET_TYPE_FIELD_VIRTUAL(thistype, n) B_SET ((thistype)->virtual_field_bits, (n)) -#define TYPE_FIELD_PRIVATE(thistype, n) B_TST((thistype)->private_field_bits, (n)) -#define TYPE_FIELD_PROTECTED(thistype, n) B_TST((thistype)->protected_field_bits, (n)) -#define TYPE_FIELD_VIRTUAL(thistype, n) B_TST((thistype)->virtual_field_bits, (n)) - -#define TYPE_HAS_DESTRUCTOR(thistype) ((thistype)->flags & TYPE_FLAG_HAS_DESTRUCTOR) -#define TYPE_HAS_CONSTRUCTOR(thistype) ((thistype)->flags & TYPE_FLAG_HAS_CONSTRUCTOR) - -#define TYPE_FIELD_STATIC(thistype, n) ((thistype)->fields[n].bitpos == -1) -#define TYPE_FIELD_STATIC_PHYSNAME(thistype, n) ((char *)(thistype)->fields[n].bitsize) - -#define TYPE_FN_FIELDLISTS(thistype) (thistype)->fn_fieldlists -#define TYPE_FN_FIELDLIST(thistype, n) (thistype)->fn_fieldlists[n] -#define TYPE_FN_FIELDLIST1(thistype, n) (thistype)->fn_fieldlists[n].fn_fields -#define TYPE_FN_FIELDLIST_NAME(thistype, n) (thistype)->fn_fieldlists[n].name -#define TYPE_FN_FIELDLIST_LENGTH(thistype, n) (thistype)->fn_fieldlists[n].length - -#define TYPE_FN_FIELD(thistype, n) (thistype)[n] -#define TYPE_FN_FIELD_NAME(thistype, n) (thistype)[n].name -#define TYPE_FN_FIELD_TYPE(thistype, n) (thistype)[n].type -#define TYPE_FN_FIELD_ARGS(thistype, n) TYPE_ARG_TYPES ((thistype)[n].type) -#define TYPE_FN_FIELD_PHYSNAME(thistype, n) (thistype)[n].physname -#define TYPE_FN_FIELD_VIRTUAL_P(thistype, n) ((thistype)[n].voffset > 1) -#define TYPE_FN_FIELD_STATIC_P(thistype, n) ((thistype)[n].voffset == VOFFSET_STATIC) -#define TYPE_FN_FIELD_VOFFSET(thistype, n) ((thistype)[n].voffset-2) -#define TYPE_FN_FIELD_FCONTEXT(thistype, n) ((thistype)[n].fcontext) - -#define TYPE_FN_PRIVATE_BITS(thistype) (thistype).private_fn_field_bits -#define TYPE_FN_PROTECTED_BITS(thistype) (thistype).protected_fn_field_bits -#define SET_TYPE_FN_PRIVATE(thistype, n) B_SET ((thistype).private_fn_field_bits, n) -#define SET_TYPE_FN_PROTECTED(thistype, n) B_SET ((thistype).protected_fn_field_bits, n) -#define TYPE_FN_PRIVATE(thistype, n) B_TST ((thistype).private_fn_field_bits, n) -#define TYPE_FN_PROTECTED(thistype, n) B_TST ((thistype).protected_fn_field_bits, n) - -/* The virtual function table is now an array of structures - which have the form { int16 offset, delta; void *pfn; }. - - In normal virtual function tables, OFFSET is unused. - DELTA is the amount which is added to the apparent object's base - address in order to point to the actual object to which the - virtual function should be applied. - PFN is a pointer to the virtual function. */ - -#define VTBL_FNADDR_OFFSET 2 - -/* Macro that yields non-zero value iff NAME is the prefix - for C++ operator names. If you leave out the parenthesis - here you will lose! - - Currently 'o' 'p' CPLUS_MARKER is used for both the symbol in the - symbol-file and the names in gdb's symbol table. */ -#define OPNAME_PREFIX_P(NAME) ((NAME)[0] == 'o' && (NAME)[1] == 'p' \ - && (NAME)[2] == CPLUS_MARKER) - -#define VTBL_PREFIX_P(NAME) ((NAME)[3] == CPLUS_MARKER \ - && !strncmp ((NAME), "_vt", 3)) - -/* Functions that work on the objects described above */ - -extern struct symtab *lookup_symtab (); -extern struct symbol *lookup_symbol (); -extern struct symbol *lookup_block_symbol (); -extern int lookup_misc_func (); -extern void check_stub_type (); -extern void check_stub_method (); -extern struct type *lookup_primitive_typename (); -extern struct type *lookup_typename (); -extern struct type *lookup_unsigned_typename (); -extern struct type *lookup_struct (); -extern struct type *lookup_union (); -extern struct type *lookup_enum (); -extern struct type *lookup_struct_elt_type (); -extern struct type *lookup_pointer_type (); -extern struct type *lookup_function_type (); -extern struct type *create_array_type (); -extern struct symbol *block_function (); -extern struct symbol *find_pc_function (); -extern int find_pc_partial_function (); -extern void clear_pc_function_cache (); -extern struct partial_symtab *lookup_partial_symtab (); -extern struct partial_symtab *find_pc_psymtab (); -extern struct symtab *find_pc_symtab (); -extern struct partial_symbol *find_pc_psymbol (); -extern int find_pc_misc_function (); -extern int find_pc_line_pc_range (); -extern char *type_name_no_tag (); -extern int contained_in(); - -/* C++ stuff. */ -extern struct type *lookup_reference_type (); -extern struct type *lookup_member_type (); -extern struct type *lookup_method_type (); -extern void smash_to_method_type (); -void smash_to_member_type ( -#ifdef __STDC__ - struct type *, struct type *, struct type * -#endif - ); -extern struct type *allocate_stub_method (); -/* end of C++ stuff. */ - -extern void reread_symbols (); - -extern struct type *builtin_type_void; -extern struct type *builtin_type_char; -extern struct type *builtin_type_short; -extern struct type *builtin_type_int; -extern struct type *builtin_type_long; -extern struct type *builtin_type_unsigned_char; -extern struct type *builtin_type_unsigned_short; -extern struct type *builtin_type_unsigned_int; -extern struct type *builtin_type_unsigned_long; -extern struct type *builtin_type_float; -extern struct type *builtin_type_double; -extern struct type *builtin_type_long_double; -extern struct type *builtin_type_complex; -extern struct type *builtin_type_double_complex; -/* This type represents a type that was unrecognized in symbol - read-in. */ -extern struct type *builtin_type_error; - -extern struct type *builtin_type_long_long; -extern struct type *builtin_type_unsigned_long_long; - -/* Modula-2 types */ -extern struct type *builtin_type_m2_char; -extern struct type *builtin_type_m2_int; -extern struct type *builtin_type_m2_card; -extern struct type *builtin_type_m2_real; -extern struct type *builtin_type_m2_bool; - -/* LONG_LONG is defined if the host has "long long". */ -#ifdef LONG_LONG -#define BUILTIN_TYPE_LONGEST builtin_type_long_long -#define BUILTIN_TYPE_UNSIGNED_LONGEST builtin_type_unsigned_long_long -/* This should not be a typedef, because "unsigned LONGEST" needs - to work. */ -#define LONGEST long long - -#else /* not LONG_LONG. */ - -#define BUILTIN_TYPE_LONGEST builtin_type_long -#define BUILTIN_TYPE_UNSIGNED_LONGEST builtin_type_unsigned_long -#define LONGEST long - -#endif /* not LONG_LONG. */ - -struct symtab_and_line -{ - struct symtab *symtab; - int line; - CORE_ADDR pc; - CORE_ADDR end; -}; - -struct symtabs_and_lines -{ - struct symtab_and_line *sals; - int nelts; -}; - -/* Given a pc value, return line number it is in. - Second arg nonzero means if pc is on the boundary - use the previous statement's line number. */ - -struct symtab_and_line find_pc_line (); - -/* Given a symtab and line number, return the pc there. */ -extern CORE_ADDR find_line_pc (); -extern int find_line_pc_range (); - -/* Given a string, return the line specified by it. - For commands like "list" and "breakpoint". */ - -struct symtabs_and_lines decode_line_spec (); -struct symtabs_and_lines decode_line_spec_1 (); -struct symtabs_and_lines decode_line_1 (); - -/* Symmisc.c */ -void free_symtab (); - -/* Symbol-reading stuff in symfile.c and solib.c. */ -struct symtab *psymtab_to_symtab (); -void clear_solib (); -void symbol_file_add (); - -/* source.c */ -int identify_source_line (); -void print_source_lines (); -void forget_cached_source_info ( -#ifdef __STDC__ - void -#endif - ); -void select_source_symtab ( -#ifdef __STDC__ - struct symtab * -#endif - ); - -char **make_symbol_completion_list (); - -/* Maximum and minimum values of built-in types */ -#define MAX_OF_TYPE(t) \ - TYPE_UNSIGNED(t) ? UMAX_OF_SIZE(TYPE_LENGTH(t)) : MAX_OF_SIZE(TYPE_LENGTH(t)) - -#define MIN_OF_TYPE(t) \ - TYPE_UNSIGNED(t) ? UMIN_OF_SIZE(TYPE_LENGTH(t)) : MIN_OF_SIZE(TYPE_LENGTH(t)) - -#endif /* symtab.h not already included. */ diff --git a/gdb/tahoe-opcode.h b/gdb/tahoe-opcode.h deleted file mode 100755 index b5cee249ee4..00000000000 --- a/gdb/tahoe-opcode.h +++ /dev/null @@ -1,213 +0,0 @@ -/* - * Ported by the State University of New York at Buffalo by the Distributed - * Computer Systems Lab, Department of Computer Science, 1991. - */ - -#ifndef tahoe_opcodeT -#define tahoe_opcodeT int -#endif /* no tahoe_opcodeT */ - -struct vot_wot /* tahoe opcode table: wot to do with this */ - /* particular opcode */ -{ - char * args; /* how to compile said opcode */ - tahoe_opcodeT code; /* op-code (may be > 8 bits!) */ -}; - -struct vot /* tahoe opcode text */ -{ - char * name; /* opcode name: lowercase string [key] */ - struct vot_wot detail; /* rest of opcode table [datum] */ -}; - -#define vot_how args -#define vot_code code -#define vot_detail detail -#define vot_name name - -static struct vot -votstrs[] = -{ -{ "halt", {"", 0x00 } }, -{ "sinf", {"", 0x05 } }, -{ "ldf", {"rl", 0x06 } }, -{ "ldd", {"rq", 0x07 } }, -{ "addb2", {"rbmb", 0x08 } }, -{ "movb", {"rbwb", 0x09 } }, -{ "addw2", {"rwmw", 0x0a } }, -{ "movw", {"rwww", 0x0b } }, -{ "addl2", {"rlml", 0x0c } }, -{ "movl", {"rlwl", 0x0d } }, -{ "bbs", {"rlvlbw", 0x0e } }, -{ "nop", {"", 0x10 } }, -{ "brb", {"bb", 0x11 } }, -{ "brw", {"bw", 0x13 } }, -{ "cosf", {"", 0x15 } }, -{ "lnf", {"rl", 0x16 } }, -{ "lnd", {"rq", 0x17 } }, -{ "addb3", {"rbrbwb", 0x18 } }, -{ "cmpb", {"rbwb", 0x19 } }, -{ "addw3", {"rwrwww", 0x1a } }, -{ "cmpw", {"rwww", 0x1b } }, -{ "addl3", {"rlrlwl", 0x1c } }, -{ "cmpl", {"rlwl", 0x1d } }, -{ "bbc", {"rlvlbw", 0x1e } }, -{ "rei", {"", 0x20 } }, -{ "bneq", {"bb", 0x21 } }, -{ "bnequ", {"bb", 0x21 } }, -{ "cvtwl", {"rwwl", 0x23 } }, -{ "stf", {"wl", 0x26 } }, -{ "std", {"wq", 0x27 } }, -{ "subb2", {"rbmb", 0x28 } }, -{ "mcomb", {"rbwb", 0x29 } }, -{ "subw2", {"rwmw", 0x2a } }, -{ "mcomw", {"rwww", 0x2b } }, -{ "subl2", {"rlml", 0x2c } }, -{ "mcoml", {"rlwl", 0x2d } }, -{ "emul", {"rlrlrlwq", 0x2e } }, -{ "aoblss", {"rlmlbw", 0x2f } }, -{ "bpt", {"", 0x30 } }, -{ "beql", {"bb", 0x31 } }, -{ "beqlu", {"bb", 0x31 } }, -{ "cvtwb", {"rwwb", 0x33 } }, -{ "logf", {"", 0x35 } }, -{ "cmpf", {"rl", 0x36 } }, -{ "cmpd", {"rq", 0x37 } }, -{ "subb3", {"rbrbwb", 0x38 } }, -{ "bitb", {"rbrb", 0x39 } }, -{ "subw3", {"rwrwww", 0x3a } }, -{ "bitw", {"rwrw", 0x3b } }, -{ "subl3", {"rlrlwl", 0x3c } }, -{ "bitl", {"rlrl", 0x3d } }, -{ "ediv", {"rlrqwlwl", 0x3e } }, -{ "aobleq", {"rlmlbw", 0x3f } }, -{ "ret", {"", 0x40 } }, -{ "bgtr", {"bb", 0x41 } }, -{ "sqrtf", {"", 0x45 } }, -{ "cmpf2", {"rl", 0x46 } }, -{ "cmpd2", {"rqrq", 0x47 } }, -{ "shll", {"rbrlwl", 0x48 } }, -{ "clrb", {"wb", 0x49 } }, -{ "shlq", {"rbrqwq", 0x4a } }, -{ "clrw", {"ww", 0x4b } }, -{ "mull2", {"rlml", 0x4c } }, -{ "clrl", {"wl", 0x4d } }, -{ "shal", {"rbrlwl", 0x4e } }, -{ "bleq", {"bb", 0x51 } }, -{ "expf", {"", 0x55 } }, -{ "tstf", {"", 0x56 } }, -{ "tstd", {"", 0x57 } }, -{ "shrl", {"rbrlwl", 0x58 } }, -{ "tstb", {"rb", 0x59 } }, -{ "shrq", {"rbrqwq", 0x5a } }, -{ "tstw", {"rw", 0x5b } }, -{ "mull3", {"rlrlwl", 0x5c } }, -{ "tstl", {"rl", 0x5d } }, -{ "shar", {"rbrlwl", 0x5e } }, -{ "bbssi", {"rlmlbw", 0x5f } }, -{ "ldpctx", {"", 0x60 } }, -{ "pushd", {"", 0x67 } }, -{ "incb", {"mb", 0x69 } }, -{ "incw", {"mw", 0x6b } }, -{ "divl2", {"rlml", 0x6c } }, -{ "incl", {"ml", 0x6d } }, -{ "cvtlb", {"rlwb", 0x6f } }, -{ "svpctx", {"", 0x70 } }, -{ "jmp", {"ab", 0x71 } }, -{ "cvlf", {"rl", 0x76 } }, -{ "cvld", {"rl", 0x77 } }, -{ "decb", {"mb", 0x79 } }, -{ "decw", {"mw", 0x7b } }, -{ "divl3", {"rlrlwl", 0x7c } }, -{ "decl", {"ml", 0x7d } }, -{ "cvtlw", {"rlww", 0x7f } }, -{ "bgeq", {"bb", 0x81 } }, -{ "movs2", {"abab", 0x82 } }, -{ "cvfl", {"wl", 0x86 } }, -{ "cvdl", {"wl", 0x87 } }, -{ "orb2", {"rbmb", 0x88 } }, -{ "cvtbl", {"rbwl", 0x89 } }, -{ "orw2", {"rwmw", 0x8a } }, -{ "bispsw", {"rw", 0x8b } }, -{ "orl2", {"rlml", 0x8c } }, -{ "adwc", {"rlml", 0x8d } }, -{ "adda", {"rlml", 0x8e } }, -{ "blss", {"bb", 0x91 } }, -{ "cmps2", {"abab", 0x92 } }, -{ "ldfd", {"rl", 0x97 } }, -{ "orb3", {"rbrbwb", 0x98 } }, -{ "cvtbw", {"rbww", 0x99 } }, -{ "orw3", {"rwrwww", 0x9a } }, -{ "bicpsw", {"rw", 0x9b } }, -{ "orl3", {"rlrlwl", 0x9c } }, -{ "sbwc", {"rlml", 0x9d } }, -{ "suba", {"rlml", 0x9e } }, -{ "bgtru", {"bb", 0xa1 } }, -{ "cvdf", {"", 0xa6 } }, -{ "andb2", {"rbmb", 0xa8 } }, -{ "movzbl", {"rbwl", 0xa9 } }, -{ "andw2", {"rwmw", 0xaa } }, -{ "loadr", {"rwal", 0xab } }, -{ "andl2", {"rlml", 0xac } }, -{ "mtpr", {"rlrl", 0xad } }, -{ "ffs", {"rlwl", 0xae } }, -{ "blequ", {"bb", 0xb1 } }, -{ "negf", {"", 0xb6 } }, -{ "negd", {"", 0xb7 } }, -{ "andb3", {"rbrbwb", 0xb8 } }, -{ "movzbw", {"rbww", 0xb9 } }, -{ "andw3", {"rwrwww", 0xba } }, -{ "storer", {"rwal", 0xbb } }, -{ "andl3", {"rlrlwl", 0xbc } }, -{ "mfpr", {"rlwl", 0xbd } }, -{ "ffc", {"rlwl", 0xbe } }, -{ "calls", {"rbab", 0xbf } }, -{ "prober", {"rbabrl", 0xc0 } }, -{ "bvc", {"bb", 0xc1 } }, -{ "movs3", {"ababrw", 0xc2 } }, -{ "movzwl", {"rwwl", 0xc3 } }, -{ "addf", {"rl", 0xc6 } }, -{ "addd", {"rq", 0xc7 } }, -{ "xorb2", {"rbmb", 0xc8 } }, -{ "movob", {"rbwb", 0xc9 } }, -{ "xorw2", {"rwmw", 0xca } }, -{ "movow", {"rwww", 0xcb } }, -{ "xorl2", {"rlml", 0xcc } }, -{ "movpsl", {"wl", 0xcd } }, -{ "kcall", {"rw", 0xcf } }, -{ "probew", {"rbabrl", 0xd0 } }, -{ "bvs", {"bb", 0xd1 } }, -{ "cmps3", {"ababrw", 0xd2 } }, -{ "subf", {"rq", 0xd6 } }, -{ "subd", {"rq", 0xd7 } }, -{ "xorb3", {"rbrbwb", 0xd8 } }, -{ "pushb", {"rb", 0xd9 } }, -{ "xorw3", {"rwrwww", 0xda } }, -{ "pushw", {"rw", 0xdb } }, -{ "xorl3", {"rlrlwl", 0xdc } }, -{ "pushl", {"rl", 0xdd } }, -{ "insque", {"abab", 0xe0 } }, -{ "bcs", {"bb", 0xe1 } }, -{ "bgequ", {"bb", 0xe1 } }, -{ "mulf", {"rq", 0xe6 } }, -{ "muld", {"rq", 0xe7 } }, -{ "mnegb", {"rbwb", 0xe8 } }, -{ "movab", {"abwl", 0xe9 } }, -{ "mnegw", {"rwww", 0xea } }, -{ "movaw", {"awwl", 0xeb } }, -{ "mnegl", {"rlwl", 0xec } }, -{ "moval", {"alwl", 0xed } }, -{ "remque", {"ab", 0xf0 } }, -{ "bcc", {"bb", 0xf1 } }, -{ "blssu", {"bb", 0xf1 } }, -{ "divf", {"rq", 0xf6 } }, -{ "divd", {"rq", 0xf7 } }, -{ "movblk", {"alalrw", 0xf8 } }, -{ "pushab", {"ab", 0xf9 } }, -{ "pushaw", {"aw", 0xfb } }, -{ "casel", {"rlrlrl", 0xfc } }, -{ "pushal", {"al", 0xfd } }, -{ "callf", {"rbab", 0xfe } }, -{ "" , "" } /* empty is end sentinel */ - -}; diff --git a/gdb/tahoe-pinsn.c b/gdb/tahoe-pinsn.c deleted file mode 100644 index c3c675c501a..00000000000 --- a/gdb/tahoe-pinsn.c +++ /dev/null @@ -1,223 +0,0 @@ -/* - * Ported by the State University of New York at Buffalo by the Distributed - * Computer Systems Lab, Department of Computer Science, 1991. - */ - -#include - -#include "defs.h" -#include "param.h" -#include "symtab.h" -#include "tahoe-opcode.h" - -/* Tahoe instructions are never longer than this. */ -#define MAXLEN 62 - -/* Number of elements in the opcode table. */ -#define NOPCODES (sizeof votstrs / sizeof votstrs[0]) - -extern char *reg_names[]; - -static unsigned char *print_insn_arg (); - -/* Print the Tahoe instruction at address MEMADDR in debugged memory, - on STREAM. Returns length of the instruction, in bytes. */ - -int -print_insn (memaddr, stream) - CORE_ADDR memaddr; - FILE *stream; -{ - unsigned char buffer[MAXLEN]; - register int i; - register unsigned char *p; - register char *d; - - read_memory (memaddr, buffer, MAXLEN); - - for (i = 0; i < NOPCODES; i++) - if (votstrs[i].detail.code == buffer[0] - || votstrs[i].detail.code == *(unsigned short *)buffer) - break; - - /* Handle undefined instructions. */ - if (i == NOPCODES) - { - fprintf (stream, "0%o", buffer[0]); - return 1; - } - - fprintf (stream, "%s", votstrs[i].name); - - /* Point at first byte of argument data, - and at descriptor for first argument. */ - p = buffer + 1 + (votstrs[i].detail.code >= 0x100); - d = votstrs[i].detail.args; - - if (*d) - fputc ('\t', stream); - - while (*d) - { - p = print_insn_arg (d, p, memaddr + (p - buffer), stream); - d += 2; - if (*d) - fprintf (stream, ","); - } - return p - buffer; -} -/*******************************************************************/ -static unsigned char * -print_insn_arg (d, p, addr, stream) - char *d; - register char *p; - CORE_ADDR addr; - FILE *stream; -{ - int temp1 = 0; - register int regnum = *p & 0xf; - float floatlitbuf; - - if (*d == 'b') - { - if (d[1] == 'b') - fprintf (stream, "0x%x", addr + *p++ + 1); - else - { - - temp1 = *p; - temp1 <<= 8; - temp1 |= *(p + 1); - fprintf (stream, "0x%x", addr + temp1 + 2); - p += 2; - } - } - else - switch ((*p++ >> 4) & 0xf) - { - case 0: - case 1: - case 2: - case 3: /* Liter>al(short immediate byte) mode */ - if (d[1] == 'd' || d[1] == 'f' || d[1] == 'g' || d[1] == 'h') - { - *(int *)&floatlitbuf = 0x4000 + ((p[-1] & 0x3f) << 4); - fprintf (stream, "$%f", floatlitbuf); - } - else - fprintf (stream, "$%d", p[-1] & 0x3f); - break; - - case 4: /* Indexed */ - p = (char *) print_insn_arg (d, p, addr + 1, stream); - fprintf (stream, "[%s]", reg_names[regnum]); - break; - - case 5: /* Register */ - fprintf (stream, reg_names[regnum]); - break; - - case 7: /* Autodecrement */ - fputc ('-', stream); - case 6: /* Register deferred */ - fprintf (stream, "(%s)", reg_names[regnum]); - break; - - case 9: /* Absolute Address & Autoincrement deferred */ - fputc ('*', stream); - if (regnum == PC_REGNUM) - { - temp1 = *p; - temp1 <<= 8; - temp1 |= *(p +1); - - fputc ('$', stream); - print_address (temp1, stream); - p += 4; - break; - } - case 8: /*Immediate & Autoincrement SP */ - if (regnum == 8) /*88 is Immediate Byte Mode*/ - fprintf (stream, "$%d", *p++); - - else if (regnum == 9) /*89 is Immediate Word Mode*/ - { - temp1 = *p; - temp1 <<= 8; - temp1 |= *(p +1); - fprintf (stream, "$%d", temp1); - p += 2; - } - - else if (regnum == PC_REGNUM) /*8F is Immediate Long Mode*/ - { - temp1 = *p; - temp1 <<=8; - temp1 |= *(p +1); - temp1 <<=8; - temp1 |= *(p +2); - temp1 <<= 8; - temp1 |= *(p +3); - fprintf (stream, "$%d", temp1); - p += 4; - } - - else /*8E is Autoincrement SP Mode*/ - fprintf (stream, "(%s)+", reg_names[regnum]); - break; - - case 11: /* Register + Byte Displacement Deferred Mode*/ - fputc ('*', stream); - case 10: /* Register + Byte Displacement Mode*/ - if (regnum == PC_REGNUM) - print_address (addr + *p + 2, stream); - else - fprintf (stream, "%d(%s)", *p, reg_names[regnum]); - p += 1; - break; - - case 13: /* Register + Word Displacement Deferred Mode*/ - fputc ('*', stream); - case 12: /* Register + Word Displacement Mode*/ - temp1 = *p; - temp1 <<= 8; - temp1 |= *(p +1); - if (regnum == PC_REGNUM) - print_address (addr + temp1 + 3, stream); - else - fprintf (stream, "%d(%s)", temp1, reg_names[regnum]); - p += 2; - break; - - case 15: /* Register + Long Displacement Deferred Mode*/ - fputc ('*', stream); - case 14: /* Register + Long Displacement Mode*/ - temp1 = *p; - temp1 <<= 8; - temp1 |= *(p +1); - temp1 <<= 8; - temp1 |= *(p +2); - temp1 <<= 8; - temp1 |= *(p +3); - if (regnum == PC_REGNUM) - print_address (addr + temp1 + 5, stream); - else - fprintf (stream, "%d(%s)", temp1, reg_names[regnum]); - p += 4; - } - - return (unsigned char *) p; -} - - - - - - - - - - - - - diff --git a/gdb/target.c b/gdb/target.c deleted file mode 100644 index a23c910944c..00000000000 --- a/gdb/target.c +++ /dev/null @@ -1,532 +0,0 @@ -/* Select target systems and architectures at runtime for GDB. - Copyright (C) 1990 Free Software Foundation, Inc. - Contributed by Cygnus Support. - -This file is part of GDB. - -GDB 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 1, or (at your option) -any later version. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include -#include -#include "defs.h" -#include "target.h" -#include "gdbcmd.h" -#include "symtab.h" -#include "inferior.h" -#include "bfd.h" -#include "symfile.h" - -extern int memory_insert_breakpoint(), memory_remove_breakpoint(); -extern void host_convert_to_virtual(), host_convert_from_virtual(); -extern void add_syms_addr_command(); - -static void cleanup_target (); - -/* Pointer to array of target architecture structures; the size of the - array; the current index into the array; the allocated size of the - array. */ -struct target_ops **target_structs; -unsigned target_struct_size; -unsigned target_struct_index; -unsigned target_struct_allocsize; -#define DEFAULT_ALLOCSIZE 10 - -/* The initial current target, so that there is always a semi-valid - current target. */ - -struct target_ops dummy_target = {"None", "None", "", - 0, 0, 0, 0, /* open, close, attach, detach */ - 0, 0, /* resume, wait */ - 0, 0, 0, 0, 0, /* registers */ - 0, 0, /* memory */ - 0, 0, /* bkpts */ - 0, 0, 0, 0, 0, /* terminal */ - 0, 0, /* kill, load */ - add_syms_addr_command, /* add_syms */ - 0, 0, /* call_function, lookup_symbol */ - 0, 0, /* create_inferior, mourn_inferior */ - dummy_stratum, 0, /* stratum, next */ - 0, 0, 0, 0, 0, /* all mem, mem, stack, regs, exec */ - OPS_MAGIC, -}; - -/* The target structure we are currently using to talk to a process - or file or whatever "inferior" we have. */ - -struct target_ops *current_target; - -/* The stack of target structures that have been pushed. */ - -struct target_ops **current_target_stack; - -/* Command list for target. */ - -static struct cmd_list_element *targetlist = NULL; - -/* The user just typed 'target' without the name of a target. */ - -/* ARGSUSED */ -static void -target_command (arg, from_tty) - char *arg; - int from_tty; -{ - fputs_filtered ("Argument required (target name).\n", stdout); -} - -/* Add a possible target architecture to the list. */ - -void -add_target (t) - struct target_ops *t; -{ - if (t->to_magic != OPS_MAGIC) - { - fprintf(stderr, "Magic number of %s target struct wrong\n", - t->to_shortname); - abort(); - } - - if (!target_structs) - { - target_struct_allocsize = DEFAULT_ALLOCSIZE; - target_structs = (struct target_ops **) xmalloc - (target_struct_allocsize * sizeof (*target_structs)); - } - if (target_struct_size >= target_struct_allocsize) - { - target_struct_allocsize *= 2; - target_structs = (struct target_ops **) xrealloc (target_structs, - target_struct_allocsize * sizeof (*target_structs)); - } - target_structs[target_struct_size++] = t; - cleanup_target (t); - - if (targetlist == NULL) - add_prefix_cmd ("target", class_run, target_command, - "Connect to a target machine or process.\n\ -The first argument is the type or protocol of the target machine.\n\ -Remaining arguments are interpreted by the target protocol. For more\n\ -information on the arguments for a particular protocol, type\n\ -`help target ' followed by the protocol name.", - &targetlist, "target ", 0, &cmdlist); - add_cmd (t->to_shortname, no_class, t->to_open, t->to_doc, &targetlist); -} - -/* Stub functions */ - -static void -ignore () -{ -} - -/* ARGSUSED */ -static int -nomemory (memaddr, myaddr, len, write) - CORE_ADDR memaddr; - char *myaddr; - int len; - int write; -{ - return 0; /* No bytes handled */ -} - -static void -tcomplain () -{ - error ("You can't do that when your target is `%s'", - current_target->to_shortname); -} - -static int -noprocess () -{ - error ("You can't do that without a process to debug"); -} - -/* ARGSUSED */ -static int -nosymbol (name, addrp) - char *name; - CORE_ADDR *addrp; -{ - return 1; /* Symbol does not exist in target env */ -} - -/* ARGSUSED */ -static void -default_terminal_info (args, from_tty) - char *args; - int from_tty; -{ - printf("No saved terminal information.\n"); -} - -#if 0 -/* With strata, this function is no longer needed. FIXME. */ -/* This is the default target_create_inferior function. It looks up - the stack for some target that cares to create inferiors, then - calls it -- or complains if not found. */ - -static void -upstack_create_inferior (exec, args, env) - char *exec; - char *args; - char **env; -{ - struct target_ops *t; - - for (t = current_target; - t; - t = t->to_next) - { - if (t->to_create_inferior != upstack_create_inferior) - { - t->to_create_inferior (exec, args, env); - return; - } - - } - tcomplain(); -} -#endif - -/* This is the default target_create_inferior and target_attach function. - If the current target is executing, it asks whether to kill it off. - If this function returns without calling error(), it has killed off - the target, and the operation should be attempted. */ - -static void -kill_or_be_killed (from_tty) - int from_tty; -{ - /* FIXME: What is savecur for? Why isn't it used? */ - struct target_ops *savecur; - - if (target_has_execution) - { - printf ("You are already running a program:\n"); - target_files_info (); - if (query ("Kill it? ")) { - savecur = current_target; - target_kill (0, from_tty); - if (target_has_execution) - error ("Killing the program did not help."); - return; - } else { - error ("Program not killed."); - } - } - tcomplain(); -} - -static void -maybe_kill_then_attach (args, from_tty) - char *args; - int from_tty; -{ - kill_or_be_killed (from_tty); - target_attach (args, from_tty); -} - -static void -maybe_kill_then_create_inferior (exec, args, env) - char *exec; - char *args; - char **env; -{ - kill_or_be_killed (0); - target_create_inferior (exec, args, env); -} - -/* Clean up a target struct so it no longer has any zero pointers in it. - We default entries, at least to stubs that print error messages. */ - -static void -cleanup_target (t) - struct target_ops *t; -{ - - /* Check magic number. If wrong, it probably means someone changed - the struct definition, but not all the places that initialize one. */ - if (t->to_magic != OPS_MAGIC) - { - fprintf(stderr, "Magic number of %s target struct wrong\n", - t->to_shortname); - abort(); - } - -#define de_fault(field, value) \ - if (!t->field) t->field = value - - /* FIELD DEFAULT VALUE */ - - de_fault (to_open, tcomplain); - de_fault (to_close, (void (*)())ignore); - de_fault (to_attach, maybe_kill_then_attach); - de_fault (to_detach, (void (*)())ignore); - de_fault (to_resume, (void (*)())noprocess); - de_fault (to_wait, noprocess); - de_fault (to_fetch_registers, noprocess); - de_fault (to_store_registers, noprocess); - de_fault (to_prepare_to_store, (void (*)())noprocess); - de_fault (to_convert_to_virtual, host_convert_to_virtual); - de_fault (to_convert_from_virtual, host_convert_from_virtual); - de_fault (to_xfer_memory, nomemory); - de_fault (to_files_info, ignore); - de_fault (to_insert_breakpoint, memory_insert_breakpoint); - de_fault (to_remove_breakpoint, memory_remove_breakpoint); - de_fault (to_terminal_init, ignore); - de_fault (to_terminal_inferior, ignore); - de_fault (to_terminal_ours_for_output,ignore); - de_fault (to_terminal_ours, ignore); - de_fault (to_terminal_info, default_terminal_info); - de_fault (to_kill, (void (*)())noprocess); - de_fault (to_load, tcomplain); - de_fault (to_add_syms, tcomplain); - de_fault (to_call_function, (struct value *(*)())noprocess); - de_fault (to_lookup_symbol, nosymbol); - de_fault (to_create_inferior, maybe_kill_then_create_inferior); - de_fault (to_mourn_inferior, (void (*)())noprocess); - de_fault (to_next, 0); - de_fault (to_has_all_memory, 0); - de_fault (to_has_memory, 0); - de_fault (to_has_stack, 0); - de_fault (to_has_registers, 0); - de_fault (to_has_execution, 0); - -#undef de_fault -} - -/* Push a new target type into the stack of the existing target accessors, - possibly superseding some of the existing accessors. - - Result is zero if the pushed target ended up on top of the stack, - nonzero if at least one target is on top of it. - - Rather than allow an empty stack, we always have the dummy target at - the bottom stratum, so we can call the function vectors without - checking them. */ - -int -push_target (t) - struct target_ops *t; -{ - struct target_ops *st, *prev; - - for (prev = 0, st = current_target; - st; - prev = st, st = st->to_next) { - if ((int)(t->to_stratum) >= (int)(st->to_stratum)) - break; - } - - while (t->to_stratum == st->to_stratum) { - /* There's already something on this stratum. Close it off. */ - (st->to_close) (0); - if (prev) - prev->to_next = st->to_next; /* Unchain old target_ops */ - else - current_target = st->to_next; /* Unchain first on list */ - st = st->to_next; - } - - /* We have removed all targets in our stratum, now add ourself. */ - t->to_next = st; - if (prev) - prev->to_next = t; - else - current_target = t; - - cleanup_target (current_target); - return prev != 0; -} - -/* Remove a target_ops vector from the stack, wherever it may be. - Return how many times it was removed (0 or 1 unless bug). */ - -int -unpush_target (t) - struct target_ops *t; -{ - struct target_ops *u, *v; - int result = 0; - - for (u = current_target, v = 0; - u; - v = u, u = u->to_next) - if (u == t) - { - if (v == 0) - pop_target(); /* unchain top copy */ - else { - (t->to_close)(0); /* Let it clean up */ - v->to_next = t->to_next; /* unchain middle copy */ - } - result++; - } - return result; -} - -void -pop_target () -{ - (current_target->to_close)(0); /* Let it clean up */ - current_target = current_target->to_next; - if (!current_target) /* At bottom, push dummy. */ - push_target (&dummy_target); -} - -/* Move memory to or from the targets. Iterate until all of it has - been moved, if necessary. The top target gets priority; anything - it doesn't want, is offered to the next one down, etc. Note the - business with curlen: if an early target says "no, but I have a - boundary overlapping this xfer" then we shorten what we offer to - the subsequent targets so the early guy will get a chance at the - tail before the subsequent ones do. - - Result is 0 or errno value. */ - -int -target_read_memory (memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - return target_xfer_memory (memaddr, myaddr, len, 0); -} - -int -target_write_memory (memaddr, myaddr, len) - CORE_ADDR memaddr; - char *myaddr; - int len; -{ - return target_xfer_memory (memaddr, myaddr, len, 1); -} - -int -target_xfer_memory (memaddr, myaddr, len, write) - CORE_ADDR memaddr; - char *myaddr; - int len; - int write; -{ - int curlen; - int res; - struct target_ops *t; - - /* The quick case is that the top target does it all. */ - res = current_target->to_xfer_memory(memaddr, myaddr, len, write); - if (res == len) - return 0; - - if (res > 0) - goto bump; - /* If res <= 0 then we call it again in the loop. Ah well. */ - - for (; len > 0;) - { - curlen = len; /* Want to do it all */ - for (t = current_target; - t; - t = t->to_has_all_memory? 0: t->to_next) - { - res = t->to_xfer_memory(memaddr, myaddr, curlen, write); - if (res > 0) break; /* Handled all or part of xfer */ - if (res == 0) continue; /* Handled none */ - curlen = -res; /* Could handle once we get past res bytes */ - } - if (res <= 0) - { - /* If this address is for nonexistent memory, - read zeros if reading, or do nothing if writing. Return error. */ - if (!write) - bzero (myaddr, len); - return EIO; - } -bump: - memaddr += res; - myaddr += res; - len -= res; - } - return 0; /* We managed to cover it all somehow. */ -} - - -/* ARGSUSED */ -static void -target_info (args, from_tty) - char *args; - int from_tty; -{ - struct target_ops *t; - int has_all_mem = 0; - - if (symfile != 0) - printf ("Symbols from \"%s\".\n", symfile); - -#ifdef FILES_INFO_HOOK - if (FILES_INFO_HOOK ()) - return; -#endif - - for (t = current_target; - t; - t = t->to_next) - { - if ((int)(t->to_stratum) <= (int)dummy_stratum) - continue; - if (has_all_mem) - printf("\tWhile running this, gdb does not access memory from...\n"); - printf("%s:\n", t->to_longname); - (t->to_files_info)(); - has_all_mem = t->to_has_all_memory; - } -} - -/* This is to be called by the open routine before it does - anything. */ - -void -target_preopen (from_tty) - int from_tty; -{ - dont_repeat(); - - if (target_has_execution) - { - if (query ("A program is being debugged already. Kill it? ")) - target_kill ((char *)0, from_tty); - else - error ("Program not killed."); - } -} - -static char targ_desc[] = - "Names of targets and files being debugged.\n\ -Shows the entire stack of targets currently in use (including the exec-file,\n\ -core-file, and process, if any), as well as the symbol file name."; - -void -_initialize_targets () -{ - current_target = &dummy_target; - cleanup_target (current_target); - - add_info ("target", target_info, targ_desc); - add_info ("files", target_info, targ_desc); -} diff --git a/gdb/target.h b/gdb/target.h deleted file mode 100644 index 7bc64f006b6..00000000000 --- a/gdb/target.h +++ /dev/null @@ -1,415 +0,0 @@ -/* Interface between GDB and target environments, including files and processes - Copyright 1990, 1991 Free Software Foundation, Inc. - Contributed by Cygnus Support. Written by John Gilmore. - -This file is part of GDB. - -GDB 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 1, or (at your option) -any later version. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* This include file defines the interface between the main part - of the debugger, and the part which is target-specific, or - specific to the communications interface between us and the - target. - - A TARGET is an interface between the debugger and a particular - kind of file or process. Targets can be STACKED in STRATA, - so that more than one target can potentially respond to a request. - In particular, memory accesses will walk down the stack of targets - until they find a target that is interested in handling that particular - address. STRATA are artificial boundaries on the stack, within - which particular kinds of targets live. Strata exist so that - people don't get confused by pushing e.g. a process target and then - a file target, and wondering why they can't see the current values - of variables any more (the file target is handling them and they - never get to the process target). So when you push a file target, - it goes into the file stratum, which is always below the process - stratum. */ - -enum strata { - dummy_stratum, /* The lowest of the low */ - file_stratum, /* Executable files, etc */ - core_stratum, /* Core dump files */ - process_stratum, /* Executing processes */ -}; - -struct target_ops { - char *to_shortname; /* Name this target type */ - char *to_longname; /* Name for printing */ - /* Documentation. Does not include trailing newline, and - starts with a one-line description (probably similar to - to_longname). */ - char *to_doc; -#ifdef __STDC__ - void (*to_open) (char *name, int from_tty); - void (*to_close) (int quitting); - void (*to_attach) (char *name, int from_tty); - void (*to_detach) (char *args, int from_tty); - void (*to_resume) (int step, int siggnal); - int (*to_wait) (int *status); - int (*to_fetch_registers) (int regno); - int (*to_store_registers) (int regno); - void (*to_prepare_to_store) (); - void (*to_convert_to_virtual) (int regnum, char *from, char *to); - void (*to_convert_from_virtual) (int regnum, char *from, char *to); - int (*to_xfer_memory) (CORE_ADDR memaddr, char *myaddr, int len, int w); - void (*to_files_info) (); - int (*to_insert_breakpoint) (CORE_ADDR addr, char *save); - int (*to_remove_breakpoint) (CORE_ADDR addr, char *save); - void (*to_terminal_init) (); - void (*to_terminal_inferior) (); - void (*to_terminal_ours_for_output) (); - void (*to_terminal_ours) (); - void (*to_terminal_info) (char *arg, int from_tty); - void (*to_kill) (char *arg, int from_tty); - void (*to_load) (char *arg, int from_tty); - void (*to_add_syms) (char *arg, int from_tty); -struct value *(*to_call_function) (struct value *function, - int nargs, struct value **args); - int (*to_lookup_symbol) (char *name, CORE_ADDR *addrp); - void (*to_create_inferior) (char *exec, char *args, char **env); - void (*to_mourn_inferior) (); - enum strata to_stratum; -struct target_ops *to_next; - int to_has_all_memory; - int to_has_memory; - int to_has_stack; - int to_has_registers; - int to_has_execution; - int to_magic; -/* Need sub-structure for target machine related rather than comm related? */ -#else /* STDC */ - void (*to_open) (); - void (*to_close) (); - void (*to_attach) (); - void (*to_detach) (); - void (*to_resume) (); - int (*to_wait) (); - int (*to_fetch_registers) (); - int (*to_store_registers) (); - void (*to_prepare_to_store) (); - void (*to_convert_to_virtual) (); - void (*to_convert_from_virtual) (); - int (*to_xfer_memory) (); - void (*to_files_info) (); - int (*to_insert_breakpoint) (); - int (*to_remove_breakpoint) (); - void (*to_terminal_init) (); - void (*to_terminal_inferior) (); - void (*to_terminal_ours_for_output) (); - void (*to_terminal_ours) (); - void (*to_terminal_info) (); - void (*to_kill) (); - void (*to_load) (); - void (*to_add_syms) (); -struct value *(*to_call_function) (); - int (*to_lookup_symbol) (); - void (*to_create_inferior) (); - void (*to_mourn_inferior) (); - enum strata to_stratum; -struct target_ops *to_next; - int to_has_all_memory; - int to_has_memory; - int to_has_stack; - int to_has_registers; - int to_has_execution; - int to_magic; -/* Need sub-structure for target machine related rather than comm related? */ -#endif -}; - -/* Magic number for checking ops size. If a struct doesn't end with this - number, somebody changed the declaration but didn't change all the - places that initialize one. */ - -#define OPS_MAGIC 3840 - -/* The ops structure for our "current" target process. */ - -extern struct target_ops *current_target; - -/* Define easy words for doing these operations on our current target. */ - -#define target_shortname (current_target->to_shortname) -#define target_longname (current_target->to_longname) - -/* The open routine takes the rest of the parameters from the command, - and (if successful) pushes a new target onto the stack. - Targets should supply this routine, if only to provide an error message. */ -#define target_open(name, from_tty) \ - (*current_target->to_open) (name, from_tty) - -/* Does whatever cleanup is required for a target that we are no longer - going to be calling. Argument says whether we are quitting gdb and - should not get hung in case of errors, or whether we want a clean - termination even if it takes a while. This routine is automatically - always called just before a routine is popped off the target stack. - Closing file descriptors and freeing memory are typical things it should - do. */ - -#define target_close(quitting) \ - (*current_target->to_close) (quitting) - -/* Attaches to a process on the target side. */ - -#define target_attach(args, from_tty) \ - (*current_target->to_attach) (args, from_tty) - -/* Takes a program previously attached to and detaches it. - The program may resume execution (some targets do, some don't) and will - no longer stop on signals, etc. We better not have left any breakpoints - in the program or it'll die when it hits one. ARGS is arguments - typed by the user (e.g. a signal to send the process). FROM_TTY - says whether to be verbose or not. */ - -#define target_detach(args, from_tty) \ - (*current_target->to_detach) (args, from_tty) - -/* Resume execution of the target process. STEP says whether to single-step - or to run free; SIGGNAL is the signal value (e.g. SIGINT) to be given - to the target, or zero for no signal. */ - -#define target_resume(step, siggnal) \ - (*current_target->to_resume) (step, siggnal) - -/* Wait for inferior process to do something. Return pid of child, - or -1 in case of error; store status through argument pointer STATUS. */ - -#define target_wait(status) \ - (*current_target->to_wait) (status) - -/* Fetch register REGNO, or all regs if regno == -1. Result is 0 - for success, -1 for problems. */ - -#define target_fetch_registers(regno) \ - (*current_target->to_fetch_registers) (regno) - -/* Store at least register REGNO, or all regs if REGNO == -1. - It can store as many registers as it wants to, so the entire registers - array must be valid. Result is 0 for success, -1 for problems. */ - -#define target_store_registers(regs) \ - (*current_target->to_store_registers) (regs) - -/* Get ready to modify the registers array. On machines which store - individual registers, this doesn't need to do anything. On machines - which store all the registers in one fell swoop, this makes sure - that REGISTERS contains all the registers from the program being - debugged. */ - -#define target_prepare_to_store() \ - (*current_target->to_prepare_to_store) () - -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ - -#define target_convert_to_virtual(regnum, from, to) \ - (*current_target->to_convert_to_virtual) (regnum, from, to) - -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ - -#define target_convert_from_virtual(regnum, from, to) \ - (*current_target->to_convert_from_virtual) (regnum, from, to) - -/* Reading and writing memory actually happens through a glue - function which iterates across the various targets. Result is - 0 for success, or an errno value. */ - -#ifdef __STDC__ -/* Needs defs.h for CORE_ADDR */ -extern int target_read_memory(CORE_ADDR memaddr, char *myaddr, int len); -extern int target_write_memory(CORE_ADDR memaddr, char *myaddr, int len); -extern int target_xfer_memory(CORE_ADDR memaddr, char *myaddr, int len, - int write); -#else -extern int target_read_memory(); -extern int target_write_memory(); -extern int target_xfer_memory(); -#endif - -/* Print a line about the current target. */ - -#define target_files_info() \ - (*current_target->to_files_info) () - -/* Insert a breakpoint at address ADDR in the target machine. - SAVE is a pointer to memory allocated for saving the - target contents. It is guaranteed by the caller to be long enough - to save "sizeof BREAKPOINT" bytes. Result is 0 for success, or - an errno value. */ - -#define target_insert_breakpoint(addr, save) \ - (*current_target->to_insert_breakpoint) (addr, save) - -/* Remove a breakpoint at address ADDR in the target machine. - SAVE is a pointer to the same save area - that was previously passed to target_insert_breakpoint. - Result is 0 for success, or an errno value. */ - -#define target_remove_breakpoint(addr, save) \ - (*current_target->to_remove_breakpoint) (addr, save) - -/* Initialize the terminal settings we record for the inferior, - before we actually run the inferior. */ - -#define target_terminal_init() \ - (*current_target->to_terminal_init) () - -/* Put the inferior's terminal settings into effect. - This is preparation for starting or resuming the inferior. */ - -#define target_terminal_inferior() \ - (*current_target->to_terminal_inferior) () - -/* Put some of our terminal settings into effect, - enough to get proper results from our output, - but do not change into or out of RAW mode - so that no input is discarded. - - After doing this, either terminal_ours or terminal_inferior - should be called to get back to a normal state of affairs. */ - -#define target_terminal_ours_for_output() \ - (*current_target->to_terminal_ours_for_output) () - -/* Put our terminal settings into effect. - First record the inferior's terminal settings - so they can be restored properly later. */ - -#define target_terminal_ours() \ - (*current_target->to_terminal_ours) () - -/* Print useful information about our terminal status, if such a thing - exists. */ - -#define target_terminal_info(arg, from_tty) \ - (*current_target->to_terminal_info) (arg, from_tty) - -/* Kill the inferior process. Make it go away. */ - -#define target_kill(arg, from_tty) \ - (*current_target->to_kill) (arg, from_tty) - -/* Load an executable file into the target process. This is expected to - not only bring new code into the target process, but also to update - GDB's symbol tables to match. */ - -#define target_load(arg, from_tty) \ - (*current_target->to_load) (arg, from_tty) - -/* Add the symbols from an executable file into GDB's symbol table, as if - the file had been loaded at a particular address (or set of addresses). - This does not change any state in the target system, only in GDB. */ - -#define target_add_syms(arg, from_tty) \ - (*current_target->to_add_syms) (arg, from_tty) - -/* Perform a function call in the inferior. - ARGS is a vector of values of arguments (NARGS of them). - FUNCTION is a value, the function to be called. - Returns a value representing what the function returned. - May fail to return, if a breakpoint or signal is hit - during the execution of the function. */ - -#define target_call_function(function, nargs, args) \ - (*current_target->to_call_function) (function, nargs, args) - -/* Look up a symbol in the target's symbol table. NAME is the symbol - name. ADDRP is a CORE_ADDR * pointing to where the value of the symbol - should be returned. The result is 0 if successful, nonzero if the - symbol does not exist in the target environment. This function should - not call error() if communication with the target is interrupted, since - it is called from symbol reading, but should return nonzero, possibly - doing a complain(). */ - -#define target_lookup_symbol(name, addrp) \ - (*current_target->to_lookup_symbol) (name, addrp) - -/* Start an inferior process and set inferior_pid to its pid. - EXEC_FILE is the file to run. - ALLARGS is a string containing the arguments to the program. - ENV is the environment vector to pass. Errors reported with error(). - On VxWorks and various standalone systems, we ignore exec_file. */ - -#define target_create_inferior(exec_file, args, env) \ - (*current_target->to_create_inferior) (exec_file, args, env) - -/* The inferior process has died. Do what is right. */ - -#define target_mourn_inferior() \ - (*current_target->to_mourn_inferior) () - -/* Pointer to next target in the chain, e.g. a core file and an exec file. */ - -#define target_next \ - (current_target->to_next) - -/* Does the target include all of memory, or only part of it? This - determines whether we look up the target chain for other parts of - memory if this target can't satisfy a request. */ - -#define target_has_all_memory \ - (current_target->to_has_all_memory) - -/* Does the target include memory? (Dummy targets don't.) */ - -#define target_has_memory \ - (current_target->to_has_memory) - -/* Does the target have a stack? (Exec files don't, VxWorks doesn't, until - we start a process.) */ - -#define target_has_stack \ - (current_target->to_has_stack) - -/* Does the target have registers? (Exec files don't.) */ - -#define target_has_registers \ - (current_target->to_has_registers) - -/* Does the target have execution? Can we make it jump (through hoops), - or pop its stack a few times, or set breakpoints? */ - -#define target_has_execution \ - (current_target->to_has_execution) - -/* Routines for maintenance of the target structures... - - add_target: Add a target to the list of all possible targets. - - push_target: Make this target the top of the stack of currently used - targets, within its particular stratum of the stack. Result - is 0 if now atop the stack, nonzero if not on top (maybe - should warn user). - - unpush_target: Remove this from the stack of currently used targets, - no matter where it is on the list. Returns 0 if no - change, 1 if removed from stack. - - pop_target: Remove the top thing on the stack of current targets. */ - -#ifdef __STDC__ -void add_target (struct target_ops *); -int push_target (struct target_ops *); -int unpush_target (struct target_ops *); -void target_preopen (int); -void pop_target (void); -#else -void add_target (); -int push_target (); -int unpush_target (); -void target_preopen (); -void pop_target (); -#endif diff --git a/gdb/tdesc.c b/gdb/tdesc.c deleted file mode 100755 index 4a38649aa36..00000000000 --- a/gdb/tdesc.c +++ /dev/null @@ -1,1650 +0,0 @@ -/* This file has been modified by Data General Corporation, November 1989. */ - -/* -This file provides an abstract interface to "tdesc" information. - It is designed to be used in a uniform manner by several kinds - of debuggers: - (1) code in live debugged process (e.g., a traceback routine) - (2) a separate-process debugger debugging a live process - (3) a separate-process debugger debugging a memory dump - - Dcontext model notes - * captures machine context - * partial: excludes memory - * frames - * kinds - * make one for starters, chain in reverse order to previous ones - * representation: pointer to opaque - * alloc/free protocol - - Overall model - * access functions - * handle - * error handling -*/ - - - -typedef int dc_boolean_t; /* range 0 .. 1 */ -#define DC_FALSE 0 -#define DC_TRUE 1 - - -typedef int dc_tristate_t; /* range 0 .. 2 */ -#define DC_NO 0 -#define DC_YES 1 -#define DC_MAYBE 2 - - -/* - A word is 32 bits of information. In memory, a word is word-aligned. - - A common and important use of dc_word_t is to represent values in the - target process, including (byte) addresses in the target process. - In this case, C arithmetic can be used to simulate machine address - arithmetic on the target. (Unsigned arithmetic is actually modulus - arithmetic.) -*/ -typedef unsigned int dc_word_t; - - -/* These bit operations number bits from 0 at the least significant end. */ -#define bit_test(word,bit) ((word) & (1 << (bit))) /* returns 0 or other */ -#define bit_value(word,bit) (((word) >> (bit)) & 1) /* returns 0 or 1 */ -#define bit_set(word,bit) ((word) |= (1 << (bit))) -#define bit_clear(word,bit) ((word) &= ~(1 << (bit))) -#define bit_assign(word, bit, bool) \ - if (bool) bit_set(word, bit); else bit_clear(word, bit) - - -/*----------------*/ - - -/* The exactness of locations may not be certainly known. */ -typedef dc_tristate_t dc_exactness_t; - - -/* - The model includes five kinds of contexts. Because each context - has an associated region and frame, these describe region kinds - and frame kinds as well. - [more description needed] - Currently, only call contexts exist. -*/ - -typedef int dc_kind_t; /* range 0 .. 4 */ -#define DC_CALL_KIND 0 -#define DC_SAVE_KIND 1 -#define DC_EXCEPTION_KIND 2 -#define DC_PROTECTION_KIND 3 -#define DC_SPECIAL_KIND 4 -#define DC_NUM_KINDS 5 - -#define DC_MIO_ENTRY_POINT (1<< 0) -#define DC_MIO_PROLOGUE_END (1<< 1) -#define DC_MIO_EPILOGUE_START (1<< 2) -#define DC_MIO_IMPLICIT_PROLOGUE_END (1<<16) -#define DC_MIO_LITERAL_ENTRY_POINT (1<<17) -#define DC_MIO_LITERAL_EPILOGUE_START (1<<18) - -#define DC_MII_PRECEDING_TDESC_END (1<<0) -#define DC_MII_FOLLOWING_TDESC_START (1<<1) - -typedef struct dc_debug_info { - unsigned int protocol; /* 1 for this structure */ - dc_word_t tdesc_ptr; - unsigned int text_words_count; - dc_word_t text_words_ptr; - unsigned int data_words_count; - dc_word_t data_words_ptr; -} dc_debug_info_t; - - -typedef struct tdesc_hdr { - unsigned int map_protocol; /* 1 for this structure */ - unsigned int end; /* address beyond end */ -} tdesc_hdr_t; - - -typedef struct tdesc_chunk_hdr { - int zeroes : 8; - int info_length : 22; - int info_alignment : 2; - unsigned int info_protocol; - dc_word_t start_address; - dc_word_t end_address; -} tdesc_chunk_hdr_t; - - -typedef struct tdesc_chunk_info1 { - int variant : 8; /* 1 for this structure */ - int register_save_mask : 17; - int pad1 : 1; - int return_address_info_discriminant : 1; - int frame_address_register : 5; - unsigned int frame_address_offset; - unsigned int return_address_info; - unsigned int register_save_offset; -} tdesc_chunk_info1_t; - - -typedef struct tdesc_chunk1 { - tdesc_chunk_hdr_t hdr; - tdesc_chunk_info1_t info; -} tdesc_chunk1_t; - - -typedef struct dc_mstate { - dc_word_t reg[32]; /* general registers */ - dc_word_t xip; - dc_word_t nip; - dc_word_t fip; - dc_word_t fpsr; - dc_word_t fpcr; - dc_word_t psr; -} dc_mstate_t; - - -typedef struct dc_map_info_in { - dc_word_t flags; - dc_word_t preceding_tdesc_end; - dc_word_t following_tdesc_start; -} dc_map_info_in_t; - - -typedef struct dc_map_info_out { - dc_word_t flags; - dc_word_t entry_point; - dc_word_t prologue_end; - dc_word_t epilogue_start; -} dc_map_info_out_t; - - -#if 0 - - void error_fcn (env, continuable, message) - dc_word_t env; /* environment (arbitrary datum) */ - dc_boolean_t continuable; /* whether error function may return */ - char *message; /* string (no trailing newline) */ - - /* In the future, we probably want the error_fcn to be: */ - void error_fcn (env, continuable, code, ...) - dc_word_t env; /* environment (arbitrary datum) */ - dc_boolean_t continuable; /* whether error function may return */ - int code; /* error code */ - ... /* parameters to message associated - with the code */ - - void read_fcn (env, memory, length, buffer) - dc_word_t env; /* environment (arbitrary datum) */ - dc_word_t memory; /* start address in image */ - int length; /* in bytes */ - char *buffer; /* start address of buffer */ - /* There are no alignment assumptions for the read function. */ - - void write_fcn (env, memory, length, buffer) - dc_word_t env; /* environment (arbitrary datum) */ - dc_word_t memory; /* start address in image */ - int length; /* in bytes */ - char *buffer; /* start address of buffer */ - /* There are no alignment assumptions for the write function. */ - /* The write function is optional. It must be provided if changes - to writable registers are to be made. */ - - void exec_fcn (env, mstate) - dc_word_t env; /* environment (arbitrary datum) */ - dc_mstate_t *mstate; /* machine state (read-write) */ - /* The execute function is optional. It would be used (in the future) - by the implementation of a procedurally specified tdesc mechanism. */ - -#endif - -/*----------------*/ - - -#ifndef NULL -#define NULL ((void *) 0) -#endif - -extern char *malloc(); -extern char *calloc(); -extern void qsort(); - - -/* - At initialization, create a tdesc table from the tdesc info. - A tdesc table is simply a sorted array of tdesc elements. - A tdesc element is the last 6 words of the tdesc chunk. - We require that all tdesc chunks have info protocol 1. -*/ - -typedef struct tdesc_elem { - dc_word_t start_address; - dc_word_t end_address; - tdesc_chunk_info1_t info; -} tdesc_elem_t; - -typedef tdesc_elem_t *tdesc_table_t; - -void dc_correct_cr_data(); - -int dc_compare_tdesc_elems (elem1, elem2) - char *elem1, *elem2; -{ - dc_word_t s1, s2, e1, e2; - s1 = ((tdesc_elem_t *) elem1)->start_address; - s2 = ((tdesc_elem_t *) elem2)->start_address; - if (s1 < s2) return -1; - if (s1 > s2) return 1; - e1 = ((tdesc_elem_t *) elem1)->end_address; - e2 = ((tdesc_elem_t *) elem2)->end_address; - if (e1 < e2) return -1; - if (e1 > e2) return 1; - return 0; -} - - -typedef struct handle_info { - dc_word_t debug_info_ptr; - void (*error_fcn)(); - dc_word_t error_env; - void (*read_fcn)(); - dc_word_t read_env; - void (*write_fcn)(); /* NULL => absent */ - dc_word_t write_env; - void (*exec_fcn)(); /* NULL => absent */ - dc_word_t exec_env; - void (*map_fcn)(); /* NULL => absent */ - dc_word_t map_env; - tdesc_table_t tdesc_table; - int tdesc_table_size; -} handle_info_t; - -typedef handle_info_t *dc_handle_t; - - -/* - Errors detected in this module are funnelled through dc_error or dc_warn, - as appropriate. Both routines call dc_exception, which invokes the error - handler supplied by the user. - - Currently, dc_exception substitutes parameters into the message given - it and passes the resulting string to the user error handler. - In the future, dc_exception should simply pass an error code and - the parameters on to the user error handler. -*/ - -#include -extern int vsprintf(); - -/* Exit status for exception-processing machinery failure */ -#define DC_EXCEPTION_FAILURE 250 - -void dc_exception(continuable, args) - dc_boolean_t continuable; - va_list args; -{ - dc_handle_t handle; - char *format; - char buffer[1024]; - - handle = va_arg(args, dc_handle_t); - format = va_arg(args, char *); - (void) vsprintf(buffer, format, args); - (*(handle->error_fcn)) (handle->error_env, continuable, buffer); - if (!continuable) - exit(DC_EXCEPTION_FAILURE); /* User error handler should never return in this case. */ -} - - -void dc_error(va_alist) /* (handle, format, args... ) */ - va_dcl -{ - va_list args; - - va_start(args); - dc_exception(DC_FALSE, args); - va_end(args); -} - - -void dc_warn(va_alist) /* (handle, format, args... ) */ - va_dcl -{ - va_list args; - - va_start(args); - dc_exception(DC_TRUE, args); - va_end(args); -} - - - -#define MALLOC_FAILURE_MESSAGE "Heap space exhausted (malloc failed)." -#define CALLOC_FAILURE_MESSAGE "Heap space exhausted (Calloc failed)." - - -/* Commonize memory allocation call so failure diagnosis is easier */ - -char* dc_malloc( handle, size ) - dc_handle_t handle; - int size; -{ - char* space = malloc( size ); - if (space == (char *)NULL) - dc_error( handle, MALLOC_FAILURE_MESSAGE ); - - return space; -} - - -/* Commonize memory allocation call so failure diagnosis is easier */ - -char* dc_calloc( handle,nelem, size ) - dc_handle_t handle; - int nelem; - int size; -{ - char* space = calloc( nelem, size ); - if (space == (char *)NULL) - dc_error( handle, CALLOC_FAILURE_MESSAGE ); - - return space; -} - - -dc_word_t dc_read_word (handle, address) - dc_handle_t handle; - dc_word_t address; -{ - dc_word_t word; - (*(handle->read_fcn)) (handle->read_env, address, - sizeof(dc_word_t), (char *)(&(word))); - return word; -} - - -void dc_write_word (handle, address, value) - dc_handle_t handle; - dc_word_t address; - dc_word_t value; -{ - dc_word_t word; - word = value; - if (handle->write_fcn) { - (*(handle->write_fcn)) (handle->write_env, address, - sizeof(dc_word_t), (char *)(&(word))); - } else { - dc_error (handle, "Writing is disabled."); - } -} - - -void dc_write_masked_word (handle, address, mask, value) - dc_handle_t handle; - dc_word_t address; - dc_word_t mask; - dc_word_t value; -{ - dc_write_word (handle, address, - (value & mask) | (dc_read_word(handle, address) & ~mask)); -} - - -dc_handle_t dc_initiate (debug_info_ptr, - error_fcn, error_env, - read_fcn, read_env, - write_fcn, write_env, - exec_fcn, exec_env, - map_fcn, map_env) - dc_word_t debug_info_ptr; - void (*error_fcn)(); - dc_word_t error_env; - void (*read_fcn)(); - dc_word_t read_env; - void (*write_fcn)(); /* NULL => absent */ - dc_word_t write_env; - void (*exec_fcn)(); /* NULL => absent */ - dc_word_t exec_env; - void (*map_fcn)(); /* NULL => absent */ - dc_word_t map_env; - /* write_fcn may be given as NULL if no writing is required. */ - /* exec_fcn may be given as NULL if no execution is required. - Currently, no execution is required. It would be if the - implementation needed to invoke procedures in the debugged process. */ -{ - dc_handle_t handle; - unsigned int debug_info_protocol; - dc_debug_info_t debug_info; - unsigned int tdesc_map_protocol; - tdesc_hdr_t tdesc_hdr; - dc_word_t tdesc_info_start; - dc_word_t tdesc_info_end; - dc_word_t tdesc_info_length; - - /* Set up handle enough for dc_error. */ - handle = (dc_handle_t) malloc(sizeof(handle_info_t)); - /* Cant use dc_malloc() as handle is being created ... */ - /* if (handle == NULL) (*error_fcn)( error_env, MALLOC_FAILURE_MESSAGE ) */ - handle->error_fcn = error_fcn; - handle->error_env = error_env; - handle->read_fcn = read_fcn; - handle->read_env = read_env; - handle->write_fcn = write_fcn; - handle->write_env = write_env; - handle->exec_fcn = exec_fcn; - handle->exec_env = exec_env; -/****************************************************************/ -/* BUG 9/19/89 Found by hls. Map functions not initialized. */ -/****************************************************************/ - handle->map_fcn = map_fcn; - handle->map_env = map_env; - handle->debug_info_ptr = debug_info_ptr; - handle->tdesc_table = (tdesc_table_t)NULL; - - /* Find tdesc info. */ - if (debug_info_ptr) { - (*read_fcn) (read_env, debug_info_ptr, sizeof(unsigned int), - (char *)(&debug_info_protocol)); - if (debug_info_protocol != 1) - dc_error (handle, "Unrecognized debug info protocol: %d", - debug_info_protocol); - (*read_fcn) (read_env, debug_info_ptr, sizeof(dc_debug_info_t), - (char *)(&debug_info)); - (*read_fcn) (read_env, debug_info.tdesc_ptr, sizeof(unsigned int), - (char *)(&tdesc_map_protocol)); - if (tdesc_map_protocol != 1) - dc_error (handle, "Unrecognized tdesc map protocol: %d", - tdesc_map_protocol); - (*read_fcn) (read_env, debug_info.tdesc_ptr, sizeof(tdesc_hdr_t), - (char *)(&tdesc_hdr)); - tdesc_info_start = debug_info.tdesc_ptr + sizeof(tdesc_hdr_t); - tdesc_info_end = tdesc_hdr.end; - tdesc_info_length = tdesc_info_end - tdesc_info_start; - - /* Create tdesc table from tdesc info. */ - { - /* Over-allocate in order to avoid second pass over tdesc info. */ - tdesc_table_t tt = (tdesc_table_t) dc_malloc(handle, tdesc_info_length); - dc_word_t p = tdesc_info_start; - dc_word_t q = tdesc_info_end - sizeof(tdesc_chunk1_t); - int n = 0; - tdesc_chunk1_t chunk; - dc_word_t start_address, end_address; - int i; - - for (; p <= q; ) { - (*read_fcn) (read_env, p, sizeof(tdesc_chunk1_t), (char *)(&chunk)); - if (chunk.hdr.zeroes != 0) { - /* Skip padding. */ - p += sizeof(dc_word_t); - continue; - } - if (chunk.hdr.info_protocol != 1) { - dc_warn (handle, "Unrecognized tdesc info protocol: %d", - chunk.hdr.info_protocol); - goto next_chunk; - } - if (chunk.hdr.info_length != 16) { - dc_warn (handle, "Incorrect tdesc info length: %d", - chunk.hdr.info_length); - goto next_chunk; - } - if (chunk.hdr.info_alignment > 2) { - dc_warn (handle, "Incorrect tdesc info alignment: %d", - chunk.hdr.info_alignment); - goto next_chunk; - } - start_address = chunk.hdr.start_address; - end_address = chunk.hdr.end_address; - if ((start_address&3)!=0) { - dc_warn (handle, - "Tdesc start address is not word-aligned: %#.8X", - start_address); - goto next_chunk; - } - if ((end_address&3)!=0) { - dc_warn (handle, - "Tdesc end address is not word-aligned: %#.8X", - end_address); - goto next_chunk; - } - if (start_address > end_address) { - /* Note that the range may be null. */ - dc_warn (handle, - "Tdesc start address (%#.8X) follows end address (%#.8X).", - start_address, end_address); - goto next_chunk; - } - if (chunk.info.variant != 1) { - dc_warn (handle, "Invalid tdesc chunk variant: %d", - chunk.info.variant); - goto next_chunk; - } - if (chunk.info.pad1 != 0) { - dc_warn (handle, "Tdesc chunk padding is not zero."); - goto next_chunk; - } - if (chunk.info.return_address_info_discriminant != 0) { - if ((chunk.info.return_address_info & 3) != 0) { - dc_warn (handle, - "Tdesc return address offset is not word-aligned: %#.8X", - chunk.info.return_address_info); - goto next_chunk; - } - } else { - if ((chunk.info.return_address_info & ~31) != 0) { - dc_warn (handle, - "Invalid tdesc return address register: %d", - chunk.info.return_address_info); - goto next_chunk; - } - } - if ((chunk.info.register_save_offset & 3) != 0) { - dc_warn (handle, - "Tdesc register save offset is not word-aligned: %#.8X", - chunk.info.register_save_offset); - goto next_chunk; - } - - tt[n].start_address = start_address; - tt[n].end_address = end_address; - tt[n].info = chunk.info; - n++; - - next_chunk: - p += sizeof(tdesc_chunk1_t); - } - /* Leftover (less than a tdesc_chunk1_t in size) is padding or - in error. Ignore it in either case. */ - - if (n != 0) { - - /* Sort table by start address. */ - qsort ((char *)tt, n, sizeof(tdesc_elem_t), dc_compare_tdesc_elems); - - /* Check for overlap among tdesc chunks. */ - for (i=0; i<(n-1); i++) { - if (tt[i].end_address > tt[i+1].start_address) - dc_error (handle, "Text chunks overlap."); - } - } - - /* Finish setting up handle. */ - handle->tdesc_table = tt; - handle->tdesc_table_size = n; - } - } else { - handle->tdesc_table_size = 0; - } - - return (dc_handle_t) handle; -} - - -void dc_terminate (handle) - dc_handle_t handle; -{ - if (((dc_handle_t)handle)->tdesc_table) { - free((char *)(((dc_handle_t)handle)->tdesc_table)); - } - free((char *)handle); -} - - - -/* - - Dcontext Model - - For each interesting register (word-sized piece of machine state), - a word of value information is kept. This word may - be either the value of the register, or the address in - subject memory where the value can be found (and changed). In - addition, the register may be invalid (in which case the value - information is undefined). These three cases are encoded for - a given register in the same-numbered bit of two words of flags: - - flags[0] bit flags[1] bit meaning - ------------ ------------ ------- - 0 0 register is invalid; info is undefined - 0 1 register is readable; info is value - 1 0 register is writable; info is address - 1 1 (reserved) - - The general registers (r0-r31) are handled by reg_info and - reg_flags. The bit number for a register is that register's number. - The other registers are grouped together for convenience and are - handled by aux_info and aux_flags. The bit numbers for these - registers are: - - bit number register - ---------- -------- - 0 location - 1 SXIP - 2 SNIP - 3 SFIP - 4 FPSR - 5 FPCR - - The SXIP, SNIP, and SFIP are the exception-time values of the - XIP, NIP, and FIP registers. They are valid only in the topmost frame. - (That is, in any context obtained from dc_previous_context, they - are invalid.) - - "location" is a pseudo-register of this model and represents the - location of the context. It is always valid. It also has an - exactness associated with it. The location and its exactness of a - context obtained from dc_previous_context are taken from the - return address and its exactness of the context given as an argument - to dc_previous_context. - - The following model is recommended for dealing with the partial - redundancy between location and the SXIP, SNIP, and SFIP values - in the topmost frame. The location should be set to either the - SNIP or SXIP value, and its exactness should be set to DC_NO. A - change to the register whose value the location is set to should - be accompanied by an identical change to the location. - - The PSR is handled separately, because it is a diverse collection - of flags. The PSR, as a whole, is always valid. A separate - psr_ind flag tells whether the psr_info data is a value or - an address. Each bit of the PSR has its own pair of flag bits to - mark validity and writability. - -*/ - - -/* The following value means "other", because state is stored in 2 bits. */ -#define DC_RESERVED 3 - - -#define RSTATE(flags, bit) \ - ((bit_value((flags)[0], bit) << 1) + bit_value((flags)[1], bit)) - -#define REG_STATE(dcontext, reg) RSTATE(dcontext->reg_flags, reg) -#define AUX_STATE(dcontext, reg) RSTATE(dcontext->aux_flags, reg) -#define PSR_STATE(dcontext, reg) RSTATE(dcontext->psr_flags, reg) - - -#define SET_INVALID(flags, bit) \ - { bit_clear ((flags)[0], bit); bit_clear ((flags)[1], bit); } - -#define SET_READABLE(flags, bit) \ - { bit_clear ((flags)[0], bit); bit_set ((flags)[1], bit); } - -#define SET_WRITABLE(flags, bit) \ - { bit_set ((flags)[0], bit); bit_clear ((flags)[1], bit); } - -#define ASSIGN_RSTATE(to_flags, to_bit, from_flags, from_bit) \ - { bit_assign ((to_flags)[0], to_bit, bit_value((from_flags)[0], from_bit));\ - bit_assign ((to_flags)[1], to_bit, bit_value((from_flags)[1], from_bit));} - - -#define CHECK_REG_READ(dcontext, reg) \ - if (REG_STATE(dcontext, reg) == DC_INVALID) \ - dc_error (dcontext->handle, \ - "General register %d is not readable.", reg) - -#define CHECK_REG_WRITE(dcontext, reg) \ - if (REG_STATE(dcontext, reg) != DC_WRITABLE) \ - dc_error (dcontext->handle, \ - "General register %d is not writable.", reg) - -#define CHECK_AUX_READ(dcontext, reg) \ - if (AUX_STATE(dcontext, reg) == DC_INVALID) \ - dc_error (dcontext->handle, \ - "Auxiliary register %d is not readable.", reg) - -#define CHECK_AUX_WRITE(dcontext, reg) \ - if (AUX_STATE(dcontext, reg) != DC_WRITABLE) \ - dc_error (dcontext->handle, \ - "Auxiliary register %d is not writable.", reg) - - - -#define DC_REG_RA 1 -#define DC_REG_FP 30 -#define DC_REG_SP 31 -#define DC_NUM_REG 32 - -#define DC_AUX_LOC 0 - /* DC_AUX_LOC must be first, with value 0 */ -#define DC_AUX_SXIP 1 -#define DC_AUX_SNIP 2 -#define DC_AUX_SFIP 3 -#define DC_AUX_FPSR 4 -#define DC_AUX_FPCR 5 -#define DC_NUM_AUX 6 - - - -#define CHECK_REG(dcontext, reg) \ - if ((reg < 0) || (reg >= DC_NUM_REG)) \ - dc_error (dcontext->handle, \ - "Bad general register number: %d", reg) - -#define CHECK_AUX(dcontext, reg) \ - if ((reg < 1) || (reg >= DC_NUM_AUX)) \ - dc_error (dcontext->handle, \ - "Bad auxiliary register number: %d", reg) - /* CHECK_AUX is not used for location pseudo-register. */ - -#define CHECK_BIT(dcontext, bit) \ - if ((bit < 0) || (bit >= 32)) \ - dc_error (dcontext->handle, \ - "Bad bit number: %d", bit) - - - -typedef struct cr_value { - int reg; - unsigned int off; - } dc_cr_value_t; - -#define DC_UNDEF 32 - -/* - A "dc_cr_value" represents an execution-time value symbolically, in - terms of the initial value of a register (the value on entry to - the procedure being analyzed) and a known offset. A value with - a 'reg' field value of 0 through 31 represents the value obtained - by summing (using 32-bit modulus arithmetic) the initial value of - register 'reg' and the value 'off'. Note that the value (0,k) - represents the constant value k, that (31,0) represents the CFA, and - that (1,0) represents the return address. A value with a 'reg' field - of DC_UNDEF represents an indeterminable value; in this case the - 'off' field is undefined. Other values of 'reg' are erroneous. -*/ - -typedef struct cr_data { - dc_cr_value_t reg_val[DC_NUM_REG]; - dc_word_t saved; - dc_word_t how; - unsigned int where[DC_NUM_REG]; -} dc_cr_data_t; - -/* - 'cr_data' collects all the information needed to represent the - symbolic machine state during code reading. - - The 'reg_val' array gives the current dc_cr_value for each register. - - The 'saved', 'how', and 'where' fields combine to describe what - registers have been saved, and where. The 'saved' and 'how' fields - are implicitly bit arrays over 0..31, where the numbering is from - 0 on the right. (Hence, 1<handle, dcontext->reg_info, dcontext->reg_flags, reg) - -#define SET_REG_VALUE(dcontext, reg, value) \ - dc_set_value(dcontext->handle, dcontext->reg_info, dcontext->reg_flags, reg, \ - value) - -#define GET_AUX_VALUE(dcontext, reg) \ - dc_get_value(dcontext->handle, dcontext->aux_info, dcontext->aux_flags, reg) - -#define SET_AUX_VALUE(dcontext, reg, value) \ - dc_set_value(dcontext->handle, dcontext->aux_info, dcontext->aux_flags, reg, \ - value) - - - -void dc_check_dcontext (dc) - dc_dcontext_t dc; - /* Check consistency of information supplied to make a dcontext. */ -{ - int i; - - if ((REG_STATE(dc, 0) != DC_READABLE) || (dc->reg_info[0] != 0)) - dc_error (dc->handle, "Register 0 is misspecified"); - for (i = 1; i < DC_NUM_REG; i++) - if (REG_STATE(dc, i) == DC_RESERVED) - dc_error (dc->handle, - "State for general register %d is incorrect", i); - for (i = 0; i < DC_NUM_AUX; i++) - if (AUX_STATE(dc, i) == DC_RESERVED) - dc_error (dc->handle, - "State for auxiliary register %d is incorrect", i); - if (AUX_STATE(dc, DC_AUX_LOC) == DC_INVALID) - dc_error (dc->handle, "Location is specified as invalid"); - if (GET_AUX_VALUE(dc, DC_AUX_LOC) == 0) - dc_error (dc->handle, "Location is zero."); - if (dc->loc_exact >= 3) - dc_error (dc->handle, "Location exactness is incorrectly specified: %d", - dc->loc_exact); - if (dc->psr_ind >= 2) - dc_error (dc->handle, - "PSR indirection flag is incorrectly specified: %d", - dc->psr_ind); - for (i = 0; i < 32; i++) - if (PSR_STATE(dc, i) == DC_RESERVED) - dc_error (dc->handle, "State for PSR bit %d is incorrect", i); -} - - - -tdesc_elem_t * dc_tdesc_lookup (loc, tt, tt_size, map_info_in_ptr) - dc_word_t loc; - tdesc_table_t tt; - int tt_size; - dc_map_info_in_t *map_info_in_ptr; - /* Return address of tdesc_elem_t for given location, or NULL if - there is no tdesc chunk for the location. - */ -{ - int l = 0; - int h = tt_size; - int m; - - if (tt_size == 0) { - map_info_in_ptr->flags = 0; - return (tdesc_elem_t *)NULL; - } - for (;;) { - m = (l + h) / 2; - if (m == l) break; - if (loc >= tt[m].start_address) - l = m; - else - h = m; - } - if (loc >= tt[m].end_address) { - map_info_in_ptr->preceding_tdesc_end = tt[m].end_address; - if (m+1 < tt_size) { - map_info_in_ptr->following_tdesc_start = tt[m+1].start_address; - map_info_in_ptr->flags = DC_MII_PRECEDING_TDESC_END | - DC_MII_FOLLOWING_TDESC_START; - } else { - map_info_in_ptr->flags = DC_MII_PRECEDING_TDESC_END; - } - return (tdesc_elem_t *)NULL; - } else if (loc < tt[m].start_address) { - map_info_in_ptr->following_tdesc_start = tt[m].start_address; - map_info_in_ptr->flags = DC_MII_FOLLOWING_TDESC_START; - return (tdesc_elem_t *)NULL; - } else { - return (&tt[m]); - } -} - - - -dc_dcontext_t dc_make_dcontext (handle, - reg_info, reg_flags, - aux_info, aux_flags, loc_exact, - psr_info, psr_ind, psr_flags) - dc_handle_t handle; - dc_word_t reg_info[DC_NUM_REG]; - dc_word_t reg_flags[2]; - dc_word_t aux_info[DC_NUM_AUX]; - dc_word_t aux_flags[2]; - dc_exactness_t loc_exact; - dc_word_t psr_info; - dc_boolean_t psr_ind; - dc_word_t psr_flags[2]; -{ - dc_dcontext_t dc = (dc_dcontext_t) dc_malloc (handle, sizeof(dcontext_info_t)); - int i; - dc_map_info_in_t map_info_in; - - /* Fill in supplied content. */ - dc->handle = ((dc_handle_t)handle); - for (i = 0; i < DC_NUM_REG; i++) dc->reg_info[i] = reg_info[i]; - for (i = 0; i < 2; i++) dc->reg_flags[i] = reg_flags[i]; - for (i = 0; i < DC_NUM_AUX; i++) dc->aux_info[i] = aux_info[i]; - for (i = 0; i < 2; i++) dc->aux_flags[i] = aux_flags[i]; - dc->loc_exact = loc_exact; - dc->psr_info = psr_info; - dc->psr_ind = psr_ind; - for (i = 0; i < 2; i++) dc->psr_flags[i] = psr_flags[i]; - - dc_check_dcontext(dc); - - /* Find tdesc information for the text chunk. */ - { -/***************************************************************/ -/* BUG 8/16/89 Found by hls. Not zeroing EV bits of location. */ -/* SHOULD USE dc_location()! */ -/* dc_word_t loc = GET_AUX_VALUE(dc, DC_AUX_LOC); */ -/***************************************************************/ - dc_word_t loc = GET_AUX_VALUE(dc, DC_AUX_LOC) & ~3; - tdesc_elem_t *tep = - dc_tdesc_lookup(loc, ((dc_handle_t)handle)->tdesc_table, - ((dc_handle_t)handle)->tdesc_table_size,&map_info_in); - if (tep) { - dc->code_reading = 0; - dc->info_ptr.tdesc_elem_ptr = tep; - } else { - dc->code_reading = 1; - if (!dc->handle->map_fcn) { - dc_error (dc->handle, "No tdesc information for %#.8X and no map function supplied.",loc); - } -/****************************************************************/ -/* BUG 9/18/89 Found by hls. Not using dc_malloc() */ -/* dc->info_ptr.cr_data_ptr= (dc_cr_data_t *)malloc(sizeof(dc_cr_data_t )); */ -/****************************************************************/ - dc->info_ptr.cr_data_ptr= (dc_cr_data_t *)dc_calloc(dc->handle,1,sizeof(dc_cr_data_t )); - dc_read_code(loc,dc,map_info_in,dc->info_ptr.cr_data_ptr); - } - } - - return (dc_dcontext_t) dc; -} - - - -void dc_free_dcontext (dcontext) - dc_dcontext_t dcontext; -{ -/****************************************************************/ -/* BUG 9/19/89 Found by hls. Freeing non-pointer value. */ -/* free((char *)dcontext->code_reading); */ -/****************************************************************/ - if (dcontext->code_reading) - free((char *)dcontext->info_ptr.cr_data_ptr); - free((char *)dcontext); -} - - - -dc_register_state_t dc_location_state (dcontext) - dc_dcontext_t dcontext; -{ - return AUX_STATE(((dc_dcontext_t)dcontext), DC_AUX_LOC); -} - - -dc_exactness_t dc_location_exactness (dcontext) - dc_dcontext_t dcontext; -{ - return ((dc_dcontext_t)dcontext)->loc_exact; -} - - -dc_word_t dc_location (dcontext) - dc_dcontext_t dcontext; - /* Return high 30 bits only. */ -{ - /* Don't need: CHECK_AUX_READ (((dc_dcontext_t)dcontext), DC_AUX_LOC); */ - return GET_AUX_VALUE (((dc_dcontext_t)dcontext), DC_AUX_LOC) & ~3; -} - - -dc_boolean_t dc_location_in_text_chunk( dcontext, value ) - dc_dcontext_t dcontext; - dc_word_t value; -{ - /* Check that new location is still within same text chunk. */ - tdesc_elem_t *tep = ((dc_dcontext_t)dcontext)->info_ptr.tdesc_elem_ptr; -/********************************************************************/ -/* Bug in predicate -- LS adjusted according to OCS documentation.. */ -/* if ((value < tep->start_address) || (value >= tep->end_address))*/ -/********************************************************************/ - if ((value >= tep->start_address) && (value < tep->end_address)) - return DC_TRUE; - else - return DC_FALSE; - -} - - -void dc_set_location (dcontext, value) - dc_dcontext_t dcontext; - dc_word_t value; - /* Set high 30 bits only. */ -{ - if (dc_location_in_text_chunk( dcontext, value ) != DC_TRUE) - dc_warn (((dc_dcontext_t)dcontext)->handle, - "New location is not in same text chunk."); - - CHECK_AUX_WRITE (((dc_dcontext_t)dcontext), DC_AUX_LOC); - dc_write_masked_word (((dc_dcontext_t)dcontext)->handle, - ((dc_dcontext_t)dcontext)->aux_info[DC_AUX_LOC], ~3, value); -} - - - -dc_register_state_t dc_general_register_state (dcontext, reg) - dc_dcontext_t dcontext; - int reg; -{ - CHECK_REG (((dc_dcontext_t)dcontext), reg); - return REG_STATE(((dc_dcontext_t)dcontext), reg); -} - - -dc_word_t dc_general_register (dcontext, reg) - dc_dcontext_t dcontext; - int reg; -{ - CHECK_REG (((dc_dcontext_t)dcontext), reg); - CHECK_REG_READ (((dc_dcontext_t)dcontext), reg); - return GET_REG_VALUE(((dc_dcontext_t)dcontext), reg); -} - - -void dc_set_general_register (dcontext, reg, value) - dc_dcontext_t dcontext; - int reg; - dc_word_t value; -{ - CHECK_REG (((dc_dcontext_t)dcontext), reg); - CHECK_REG_WRITE (((dc_dcontext_t)dcontext), reg); - SET_REG_VALUE (((dc_dcontext_t)dcontext), reg, value); -} - - - -dc_register_state_t dc_auxiliary_register_state (dcontext, reg) - dc_dcontext_t dcontext; - int reg; -{ - CHECK_AUX (((dc_dcontext_t)dcontext), reg); - return AUX_STATE(((dc_dcontext_t)dcontext), reg); -} - - -dc_word_t dc_auxiliary_register (dcontext, reg) - dc_dcontext_t dcontext; - int reg; -{ - CHECK_AUX (((dc_dcontext_t)dcontext), reg); - CHECK_AUX_READ (((dc_dcontext_t)dcontext), reg); - return GET_AUX_VALUE(((dc_dcontext_t)dcontext), reg); -} - - -void dc_set_auxiliary_register (dcontext, reg, value) - dc_dcontext_t dcontext; - int reg; - dc_word_t value; -{ - CHECK_AUX (((dc_dcontext_t)dcontext), reg); - CHECK_AUX_WRITE (((dc_dcontext_t)dcontext), reg); - SET_AUX_VALUE (((dc_dcontext_t)dcontext), reg, value); -} - - - -dc_register_state_t dc_psr_register_bit_state (dcontext, bit) - dc_dcontext_t dcontext; - int bit; -{ - CHECK_BIT (((dc_dcontext_t)dcontext), bit); - return PSR_STATE(((dc_dcontext_t)dcontext), bit); -} - - -dc_word_t dc_psr_register (dcontext) - dc_dcontext_t dcontext; -{ - if (((dc_dcontext_t)dcontext)->psr_ind) { - return dc_read_word(((dc_dcontext_t)dcontext)->handle, - ((dc_dcontext_t)dcontext)->psr_info); - } else { - return ((dc_dcontext_t)dcontext)->psr_info; - } -} - - -void dc_set_psr_register (dcontext, mask, value) - dc_dcontext_t dcontext; - dc_word_t mask; - dc_word_t value; - /* Set bits of PSR corresponding to 1 bits in mask. */ -{ - if (((dc_dcontext_t)dcontext)->psr_ind) { - if (((((dc_dcontext_t)dcontext)->psr_flags[0] & mask) != mask) || - ((((dc_dcontext_t)dcontext)->psr_flags[1] & mask) != 0)) - dc_error (((dc_dcontext_t)dcontext)->handle, - "Some PSR bits specified are not writable."); - dc_write_masked_word (((dc_dcontext_t)dcontext)->handle, - ((dc_dcontext_t)dcontext)->psr_info, mask, value); - } else { - dc_error (((dc_dcontext_t)dcontext)->handle, "PSR is not writable."); - } -} - - - -dc_word_t dc_frame_address (dcontext) - dc_dcontext_t dcontext; -{ - if (!dcontext->code_reading) { - tdesc_elem_t *tep = ((dc_dcontext_t)dcontext)->info_ptr.tdesc_elem_ptr; - return dc_general_register(dcontext, - tep->info.frame_address_register) + tep->info.frame_address_offset; - } else { - if (dcontext->info_ptr.cr_data_ptr->reg_val[DC_REG_FP].reg == DC_REG_SP) { - return (dc_general_register(dcontext,DC_REG_FP) - - dcontext->info_ptr.cr_data_ptr->reg_val[DC_REG_FP].off); - } - if (dcontext->info_ptr.cr_data_ptr->reg_val[DC_REG_SP].reg == DC_REG_SP) { - return (dc_general_register(dcontext,DC_REG_SP) - - dcontext->info_ptr.cr_data_ptr->reg_val[DC_REG_SP].off); - } - dc_error (((dc_dcontext_t)dcontext)->handle, "Cannot locate frame pointer."); - } -} - - - -dc_kind_t dc_context_kind (dcontext) - dc_dcontext_t dcontext; -{ - return DC_CALL_KIND; -} - - - - -/* operations valid for call contexts only */ - - -dc_register_state_t dc_return_address_state (dcontext) - dc_dcontext_t dcontext; -{ - tdesc_elem_t *tep = ((dc_dcontext_t)dcontext)->info_ptr.tdesc_elem_ptr; - int reg; - - if (!dcontext->code_reading) { - if (tep->info.return_address_info_discriminant) { - return DC_WRITABLE; - } else { - return REG_STATE(((dc_dcontext_t)dcontext), tep->info.return_address_info); - } - } else { - reg= DC_REG_RA; - if (bit_test(dcontext->info_ptr.cr_data_ptr->saved,DC_REG_RA)) { - if (bit_test(dcontext->info_ptr.cr_data_ptr->how,DC_REG_RA)) { - return DC_WRITABLE; - } else { - reg= dcontext->info_ptr.cr_data_ptr->where[DC_REG_RA]; - } - } - return REG_STATE(((dc_dcontext_t)dcontext),reg); - - - } -} - - -dc_exactness_t dc_return_address_exactness (dcontext) - dc_dcontext_t dcontext; -{ - return DC_MAYBE; -} - - -dc_word_t dc_return_address (dcontext) - dc_dcontext_t dcontext; - /* Return high 30 bits only. */ -{ - tdesc_elem_t *tep = ((dc_dcontext_t)dcontext)->info_ptr.tdesc_elem_ptr; - dc_word_t rai = tep->info.return_address_info; - dc_word_t val; - int reg; - - if (!dcontext->code_reading) { - if (tep->info.return_address_info_discriminant) { - val = dc_read_word (((dc_dcontext_t)dcontext)->handle, - dc_frame_address(dcontext) + rai); - } else { - val = dc_general_register (dcontext, rai); - } - } else { - reg=DC_REG_RA; - if (bit_test(dcontext->info_ptr.cr_data_ptr->saved,reg)) { - if (bit_test(dcontext->info_ptr.cr_data_ptr->how,reg)) { - val = dc_read_word (((dc_dcontext_t)dcontext)->handle, - dc_frame_address(dcontext) + - (dcontext->info_ptr.cr_data_ptr->where[reg])); - } else { - reg= dcontext->info_ptr.cr_data_ptr->where[DC_REG_RA]; - val = dc_general_register (dcontext, reg); - } - } else { - val = dc_general_register (dcontext, reg); - } - } - return val & ~3; -} - - -void dc_set_return_address (dcontext, value) - dc_dcontext_t dcontext; - dc_word_t value; - /* Set high 30 bits only. */ -{ - if (!dcontext->code_reading) { - tdesc_elem_t *tep = ((dc_dcontext_t)dcontext)->info_ptr.tdesc_elem_ptr; - dc_word_t rai = tep->info.return_address_info; - - if (tep->info.return_address_info_discriminant) { - dc_write_masked_word (((dc_dcontext_t)dcontext)->handle, - dc_frame_address(dcontext) + rai, ~3, value); - } else { - dc_set_general_register (dcontext, rai, - (value & ~3) | (dc_general_register(dcontext, rai) & 3)); - } - } else { - if (bit_test(dcontext->info_ptr.cr_data_ptr->saved,DC_REG_RA)) { - if (bit_test(dcontext->info_ptr.cr_data_ptr->how,DC_REG_RA)) { - dc_write_masked_word (((dc_dcontext_t)dcontext)->handle, - dc_frame_address(dcontext) - + dcontext->info_ptr.cr_data_ptr->where[DC_REG_RA], ~3, value); - } else { - dc_set_general_register( dcontext, - dcontext->info_ptr.cr_data_ptr->where[DC_REG_RA]); - } - } else { - dc_set_general_register( dcontext, - dcontext->info_ptr.cr_data_ptr->where[DC_REG_RA]); - } - } -} - - - -/* operations valid for save contexts only */ - -/* (none) */ - - - -/* operations valid for exception contexts only */ - - -void dc_get_exception_info (dcontext, handler, datum) - dc_dcontext_t dcontext; - dc_word_t *handler; - dc_word_t *datum; -{ - dc_error (((dc_dcontext_t)dcontext)->handle, - "dc_get_exception_info is not yet implemented."); -} - - - -/* operations valid for protection contexts only */ - - -void dc_get_protection_info (dcontext, handler, datum) - dc_dcontext_t dcontext; - dc_word_t *handler; - dc_word_t *datum; -{ - dc_error (((dc_dcontext_t)dcontext)->handle, - "dc_get_protection_info is not yet implemented."); -} - - - -/* operations valid for special contexts only */ - - -void dc_get_special_info (dcontext, kind, datum) - dc_dcontext_t dcontext; - dc_word_t *kind; - dc_word_t *datum; -{ - dc_error (((dc_dcontext_t)dcontext)->handle, - "dc_get_special_info is not yet implemented."); -} - - - -/* operations valid for all contexts (again) */ - - -dc_dcontext_t dc_previous_dcontext (dcontext) - dc_dcontext_t dcontext; - /* Return NULL if there is no previous context. */ -{ - dc_dcontext_t old = (dc_dcontext_t) dcontext; - dcontext_info_t new; /* to serve as temporary storage only */ - tdesc_elem_t *tep; - dc_cr_data_t *cdp; - dc_word_t cfa; - int rsm; - dc_word_t offset; - dc_word_t rai; - int r; - - if (dc_return_address_state((dc_dcontext_t)old) == DC_INVALID) - dc_error (old->handle, "Return address is invalid."); - - if (dc_return_address((dc_dcontext_t)old) == 0) - return (dc_dcontext_t)NULL; /* end of the chain */ - - /* Copy over old contents. */ - new = *old; - - cfa = dc_frame_address(old); - /* Restore stack pointer. */ - new.reg_info[DC_REG_SP] = cfa; - SET_READABLE (new.reg_flags, DC_REG_SP); - - /* Invalidate temporary registers. */ - for (r = 1; r <= 13; r++) SET_INVALID (new.reg_flags, r); - - if (!old->code_reading) { - tep = old->info_ptr.tdesc_elem_ptr; - /* Restore preserved registers. */ - rsm = tep->info.register_save_mask; - offset = cfa + tep->info.register_save_offset; - for (r = 14; r <= 30; r++) { - if (bit_test(rsm, 30-r)) { - new.reg_info[r] = offset; - SET_WRITABLE (new.reg_flags, r); - offset += sizeof(dc_word_t); - } - } - - /* Set location from old return address. */ - rai = tep->info.return_address_info; - if (tep->info.return_address_info_discriminant) { - new.aux_info[DC_AUX_LOC] = cfa + rai; - SET_WRITABLE (new.aux_flags, DC_AUX_LOC); - } else { - new.aux_info[DC_AUX_LOC] = old->reg_info[rai]; - ASSIGN_RSTATE (new.aux_flags, DC_AUX_LOC, old->reg_flags, rai); - } - } else { - cdp = old->info_ptr.cr_data_ptr; - - /* Restore preserved registers. */ - for (r = 14; r <= 30; r++) { - if (bit_test(cdp->saved,r)) { - if (bit_test(cdp->how,r)){ /* saved in the frame */ - new.reg_info[r] = cfa+cdp->where[r]; - SET_WRITABLE (new.reg_flags, r); - } else { /* saved in the in a register */ - new.reg_info[r] = dc_general_register(old,cdp->where[r]); - ASSIGN_RSTATE (new.aux_flags, r, old->reg_flags, cdp->where[r]); - } - } /* not saved, therefore, already valid , no else*/ - } - - /* Set location from old return address. */ - if (bit_test(cdp->saved,DC_REG_RA)) { - if (bit_test(cdp->how,DC_REG_RA)){ /* saved in the frame */ - new.aux_info[DC_AUX_LOC] = - new.reg_info[DC_REG_RA] = cfa+cdp->where[DC_REG_RA]; - SET_WRITABLE (new.reg_flags, DC_REG_RA); - SET_WRITABLE (new.aux_flags, DC_AUX_LOC); - } else { /* saved in the in a register */ - new.reg_info[DC_REG_RA] = - new.aux_info[DC_AUX_LOC] = - dc_general_register(old,cdp->where[DC_REG_RA]); - ASSIGN_RSTATE (new.aux_flags, DC_AUX_LOC, - old->reg_flags, cdp->where[DC_REG_RA]); - } - } else { /* not saved, therefore, already valid , set DC_AUX_LOC only*/ - new.aux_info[DC_AUX_LOC] = - dc_general_register(old,DC_REG_RA); - ASSIGN_RSTATE (new.aux_flags, DC_AUX_LOC, - old->reg_flags, DC_REG_RA); - } - } - - /* Invalidate instruction pointers. */ - SET_INVALID (new.aux_flags, DC_AUX_SXIP); - SET_INVALID (new.aux_flags, DC_AUX_SNIP); - SET_INVALID (new.aux_flags, DC_AUX_SFIP); - - /* No change to FCR registers. */ - - /* No change to PSR register. */ - - return dc_make_dcontext ((dc_handle_t)new.handle, - new.reg_info, new.reg_flags, - new.aux_info, new.aux_flags, new.loc_exact, - new.psr_info, new.psr_ind, new.psr_flags); -} - - - -/* extensions for nonlocal goto */ - -#if 0 - -typedef - struct label { - ??? - } label_t; - - -label_t dc_make_label (dcontext, location) - dc_dcontext_t dcontext; - dc_word_t location; -{ -} - -#endif - -/* procedure for reading code */ - -dc_read_code(loc,dc,map_info_in,cdp) -dc_word_t loc; -dc_dcontext_t dc; -dc_cr_data_t *cdp; -dc_map_info_in_t map_info_in; -{ -dc_map_info_out_t map_info_out; -dc_word_t pc; -dc_boolean_t found_branch=DC_FALSE; -dc_word_t instr; - - (*dc->handle->map_fcn)(dc->handle->map_env,loc,map_info_in,&map_info_out); - if (map_info_out.flags & DC_MIO_ENTRY_POINT - && (!(map_info_in.flags & DC_MII_PRECEDING_TDESC_END) - || map_info_out.entry_point >= map_info_in.preceding_tdesc_end - || map_info_out.flags & DC_MIO_LITERAL_ENTRY_POINT)) { - dc_init_cr_data(cdp,(tdesc_elem_t *)NULL); - pc= map_info_out.entry_point; - } else if (map_info_in.flags & DC_MII_PRECEDING_TDESC_END) { - /**/ - /* tdesc_lookup gets the tep for the preceeding tdesc information - /* so we call it with one less than the preceding tdesc end since - /* tdesc information is exclusive of the ending address - /**/ - dc_init_cr_data(cdp, - dc_tdesc_lookup(map_info_in.preceding_tdesc_end-1, - ((dc_handle_t)dc->handle)->tdesc_table, - ((dc_handle_t)dc->handle)->tdesc_table_size, - &map_info_in)); - pc= map_info_in.preceding_tdesc_end; - } else { - dc_error (dc->handle, "Insufficient information for code reading."); - } - for (;;pc+=4) { - if (pc==loc) { - return (DC_TRUE); - } - instr= dc_read_word(dc->handle,pc); - found_branch= dc_decode_finds_branch(dc,instr); - if ((map_info_out.flags & DC_MIO_PROLOGUE_END) - && (pc==map_info_out.prologue_end)) { - break; - } - if (found_branch) { - if (DC_MIO_IMPLICIT_PROLOGUE_END & map_info_out.flags) { - break; - } else { - dc_error (dc->handle, "Found branch before end of prologue."); - } - } - } - if (!(map_info_out.flags & DC_MIO_LITERAL_EPILOGUE_START) - && (map_info_out.epilogue_start >= loc - || !(map_info_out.flags & DC_MIO_EPILOGUE_START))) { - return (DC_TRUE); - } - dc_correct_cr_data(cdp,dc->handle); - for (pc=map_info_out.epilogue_start;pchandle,pc); - if (dc_decode_finds_branch(dc,instr)) { - return (DC_FALSE); - } - } - return (DC_TRUE); - -} - - - -dc_init_cr_data(cdp,tep) -dc_cr_data_t *cdp; -tdesc_elem_t *tep; -{ -int reg; -dc_word_t rai; -dc_word_t raid; -dc_word_t rsm; -dc_word_t frpos; - - if (tep){ - - /* Start off with all registers undefined and none saved. */ - for (reg = 0; reg < DC_NUM_REG; reg++) { - cdp->reg_val[reg].reg = DC_UNDEF; - } - cdp->saved = 0; - - /* Overwrite with what tdesc element says. */ - - cdp->reg_val[tep->info.frame_address_register].reg = DC_REG_SP; - cdp->reg_val[tep->info.frame_address_register].off = - - tep->info.frame_address_offset; - - rai = tep->info.return_address_info; - raid = tep->info.return_address_info_discriminant; - if (raid || rai != DC_REG_RA) { - bit_set(cdp->saved,DC_REG_RA); - bit_assign(cdp->how,DC_REG_RA,raid); - cdp->where[DC_REG_RA] = rai; - } - - rsm = tep->info.register_save_mask; - frpos = tep->info.register_save_offset; - for (reg = 14; reg <= 30; reg++) { - if (bit_test(rsm, 30-reg)) { - bit_set(cdp->saved,reg); - bit_set(cdp->how,reg); - cdp->where[reg] = frpos; - frpos += sizeof(dc_word_t); - } else { - cdp->reg_val[reg].reg = reg; - cdp->reg_val[reg].off = 0; - } - } - - cdp->reg_val[0].reg = 0; /* guarantee what hardware does */ - cdp->reg_val[0].off = 0; - - } else { - /* Each register has its own initial value. */ - for (reg = 0; reg < DC_NUM_REG; reg++) { - cdp->reg_val[reg].reg = reg; - cdp->reg_val[reg].off = 0; - } - /* No register is yet saved. */ - cdp->saved = 0; - cdp->how = 0; - } -} -void dc_correct_cr_data(cdp,handle) -dc_cr_data_t *cdp; -dc_handle_t handle; -{ -long sr,r; -dc_word_t save_regs = 0; /* registers used to save others */ - for (r = 1; r < DC_REG_SP; r++) { - if (bit_test(cdp->saved,r) && !bit_test(cdp->how,r)) { - sr = cdp->where[r]; - if (bit_test(save_regs,sr)) { - dc_error(handle, "Same register used to save two others."); - } - bit_set(save_regs,sr); - } - } - for (r = 1; r < DC_REG_FP; r++) { - if ((r < 14 || bit_test(cdp->saved,r)) && !bit_test(save_regs,r)) { - cdp->reg_val[r].reg = DC_UNDEF; - } - } - if (bit_test(cdp->saved,DC_REG_FP) && - cdp->reg_val[DC_REG_FP].reg == DC_REG_SP) { /* is r30 the far? */ - cdp->reg_val[DC_REG_SP].reg = DC_UNDEF; /* trash sp */ - } else if (cdp->reg_val[DC_REG_SP].reg == DC_REG_SP) { /* is r31 the far? */ - if (bit_test(cdp->saved,DC_REG_FP) && !bit_test(save_regs,DC_REG_FP)) { - cdp->reg_val[DC_REG_FP].reg = DC_UNDEF; /* trash r30 */ - } - } -} diff --git a/gdb/tdesc.h b/gdb/tdesc.h deleted file mode 100755 index 39363305280..00000000000 --- a/gdb/tdesc.h +++ /dev/null @@ -1,329 +0,0 @@ -/* This file has been modified by Data General Corporation, November 1989. */ - -#ifndef _tdesc_h -#define _tdesc_h -#ifdef __STDC__ -#define _ARGS(x) x -#else -#define _ARGS(x) () -#endif - -/* - This file provides an abstract interface to "tdesc" information. - It is designed to be used in a uniform manner by several kinds - of debuggers: - (1) code in live debugged process (e.g., a traceback routine) - (2) a separate-process debugger debugging a live process - (3) a separate-process debugger debugging a memory dump - - Dcontext model notes - * captures machine context - * partial: excludes memory - * frames - * kinds - * make one for starters, chain in reverse order to previous ones - * representation: pointer to opaque - * alloc/free protocol - - Overall model - * access functions - * handle - * error handling -*/ - - - -typedef int dc_boolean_t; /* range 0 .. 1 */ -#define DC_FALSE 0 -#define DC_TRUE 1 - - -typedef int dc_tristate_t; /* range 0 .. 2 */ -#define DC_NO 0 -#define DC_YES 1 -#define DC_MAYBE 2 - - -#define DC_MII_PRECEDING_TDESC_END (1<<0) -#define DC_MII_FOLLOWING_TDESC_START (1<<1) - -#define DC_MIO_ENTRY_POINT (1<< 0) -#define DC_MIO_PROLOGUE_END (1<< 1) -#define DC_MIO_EPILOGUE_START (1<< 2) -#define DC_MIO_IMPLICIT_PROLOGUE_END (1<<16) -#define DC_MIO_LITERAL_ENTRY_POINT (1<<17) -#define DC_MIO_LITERAL_EPILOGUE_START (1<<18) - - -/* - A word is 32 bits of information. In memory, a word is word-aligned. - - A common and important use of word_t is to represent values in the - target process, including (byte) addresses in the target process. - In this case, C arithmetic can be used to simulate machine address - arithmetic on the target. (Unsigned arithmetic is actually modulus - arithmetic.) -*/ -typedef unsigned int dc_word_t; - - -/*----------------*/ - - -/* The exactness of locations may not be certainly known. */ -typedef dc_tristate_t dc_exactness_t; - - -/* - The model includes five kinds of contexts. Because each context - has an associated region and frame, these describe region kinds - and frame kinds as well. - [more description needed] - Currently, only call contexts exist. -*/ - -typedef int dc_kind_t; /* range 0 .. 4 */ -#define DC_CALL_KIND 0 -#define DC_SAVE_KIND 1 -#define DC_EXCEPTION_KIND 2 -#define DC_PROTECTION_KIND 3 -#define DC_SPECIAL_KIND 4 -#define DC_NUM_KINDS 5 - - -typedef struct dc_debug_info { - unsigned int protocol; /* 1 for this structure */ - dc_word_t tdesc_ptr; - unsigned int text_words_count; - dc_word_t text_words_ptr; - unsigned int data_words_count; - dc_word_t data_words_ptr; -} dc_debug_info_t; - - -typedef struct dc_mstate { - dc_word_t reg[32]; /* general registers */ - dc_word_t xip; - dc_word_t nip; - dc_word_t fip; - dc_word_t fpsr; - dc_word_t fpcr; - dc_word_t psr; -} dc_mstate_t; - - - -#if 0 - - void error_fcn (env, continuable, message) - dc_word_t env; /* environment (arbitrary datum) */ - boolean_t continuable; /* whether error function may return */ - char *message; /* string (no trailing newline) */ - - /* In the future, we probably want the error_fcn to be: */ - void error_fcn (env, continuable, code, ...) - dc_word_t env; /* environment (arbitrary datum) */ - boolean_t continuable; /* whether error function may return */ - int code; /* error code */ - ... /* parameters to message associated - with the code */ - - void read_fcn (env, memory, length, buffer) - dc_word_t env; /* environment (arbitrary datum) */ - dc_word_t memory; /* start address in image */ - int length; /* in bytes */ - char *buffer; /* start address of buffer */ - /* There are no alignment assumptions for the read function. */ - - void write_fcn (env, memory, length, buffer) - dc_word_t env; /* environment (arbitrary datum) */ - dc_word_t memory; /* start address in image */ - int length; /* in bytes */ - char *buffer; /* start address of buffer */ - /* There are no alignment assumptions for the write function. */ - /* The write function is optional. It must be provided if changes - to writable registers are to be made. */ - - void exec_fcn (env, mstate) - dc_word_t env; /* environment (arbitrary datum) */ - dc_mstate_t *mstate; /* machine state (read-write) */ - /* The execute function is optional. It would be used (in the future) - by the implementation of a procedurally specified tdesc mechanism. */ - -#endif - -/*----------------*/ - - -typedef struct dc_map_info_in { - dc_word_t flags; - dc_word_t preceding_tdesc_end; - dc_word_t following_tdesc_start; -} dc_map_info_in_t; - - -typedef struct dc_map_info_out { - dc_word_t flags; - dc_word_t entry_point; - dc_word_t prologue_end; - dc_word_t epilogue_start; -} dc_map_info_out_t; - - -typedef void *dc_handle_t; - -typedef void (*tdesc_error_fcn_type) _ARGS(( - dc_word_t env, /* environment (arbitrary datum) */ - dc_boolean_t continuable, /* whether error function may return */ - const char *message /* string (no trailing newline) */ -)); -typedef void (*tdesc_io_fcn_type) _ARGS(( - dc_word_t env, /* environment (arbitrary datum) */ - dc_word_t memory, /* start address in image */ - int length, /* in bytes */ - void *buffer /* start address of buffer */ -)); -typedef void (*tdesc_exec_fcn_type) _ARGS(( - dc_word_t env, /* environment (arbitrary datum) */ - dc_mstate_t *mstate /* machine state (read-write) */ -)); -typedef void (*tdesc_map_fcn_type) _ARGS(( - dc_word_t map_env, - dc_word_t loc, - dc_map_info_in_t map_info_in, - dc_map_info_out_t *map_info_out -)); - - -extern dc_handle_t dc_initiate _ARGS(( - dc_word_t debug_info_ptr, - tdesc_error_fcn_type error_fcn, - dc_word_t error_env, - tdesc_io_fcn_type read_fcn, - dc_word_t read_env, - tdesc_io_fcn_type write_fcn, /* NULL => absent */ - dc_word_t write_env, - tdesc_exec_fcn_type exec_fcn, /* NULL => absent */ - dc_word_t exec_env, - tdesc_map_fcn_type map_fcn, /* NULL => absent */ - dc_word_t map_env -)); -extern void dc_terminate _ARGS(( - dc_handle_t handle -)); - -typedef int dc_register_state_t; /* range 0 to 2 */ - -#define DC_INVALID 0 -#define DC_READABLE 1 -#define DC_WRITABLE 2 - -#define DC_NUM_REG 32 - -#define DC_AUX_LOC 0 -#define DC_AUX_SXIP 1 -#define DC_AUX_SNIP 2 -#define DC_AUX_SFIP 3 -#define DC_AUX_FPSR 4 -#define DC_AUX_FPCR 5 -#define DC_NUM_AUX 6 - - -typedef void *dc_dcontext_t; - -extern dc_dcontext_t dc_make_dcontext _ARGS(( - dc_handle_t handle, - dc_word_t reg_info[DC_NUM_REG], - dc_word_t reg_flags[2], - dc_word_t aux_info[DC_NUM_AUX], - dc_word_t aux_flags[2], - dc_exactness_t loc_exact, - dc_word_t psr_info, - dc_boolean_t psr_ind, - dc_word_t psr_flags[2] -)); -extern void dc_free_dcontext _ARGS(( - dc_dcontext_t dcontext -)); -extern dc_register_state_t dc_location_state _ARGS(( - dc_dcontext_t dcontext -)); -extern dc_exactness_t dc_location_exactness _ARGS(( - dc_dcontext_t dcontext -)); -extern dc_word_t dc_location _ARGS(( - dc_dcontext_t dcontext -)); -extern void dc_set_location _ARGS(( - dc_dcontext_t dcontext, - dc_word_t value -)); -extern dc_register_state_t dc_general_register_state _ARGS(( - dc_dcontext_t dcontext, - int reg -)); -extern dc_word_t dc_general_register _ARGS(( - dc_dcontext_t dcontext, - int reg -)); -extern void dc_set_general_register _ARGS(( - dc_dcontext_t dcontext, - int reg, - dc_word_t value -)); -extern dc_register_state_t dc_auxiliary_register_state _ARGS(( - dc_dcontext_t dcontext, - int reg -)); -extern dc_word_t dc_auxiliary_register _ARGS(( - dc_dcontext_t dcontext, - int reg -)); -extern void dc_set_auxiliary_register _ARGS(( - dc_dcontext_t dcontext, - int reg, - dc_word_t value -)); -extern dc_register_state_t dc_psr_register_bit_state _ARGS(( - dc_dcontext_t dcontext, - int bit -)); -extern dc_word_t dc_psr_register _ARGS(( - dc_dcontext_t dcontext -)); -extern void dc_set_psr_register _ARGS(( - dc_dcontext_t dcontext, - dc_word_t mask, - dc_word_t value -)); -extern dc_word_t dc_frame_address _ARGS(( - dc_dcontext_t dcontext -)); -extern dc_kind_t dc_context_kind _ARGS(( - dc_dcontext_t dcontext -)); -extern dc_register_state_t dc_return_address_state _ARGS(( - dc_dcontext_t dcontext -)); -extern dc_exactness_t dc_return_address_exactness _ARGS(( - dc_dcontext_t dcontext -)); -extern dc_word_t dc_return_address _ARGS(( - dc_dcontext_t dcontext -)); -extern void dc_set_return_address _ARGS(( - dc_dcontext_t dcontext, - dc_word_t value -)); -extern void dc_get_exception_info(); -extern void dc_get_protection_info(); -extern void dc_get_special_info(); -extern dc_dcontext_t dc_previous_dcontext _ARGS(( - dc_dcontext_t dcontext -)); -extern dc_boolean_t dc_location_in_text_chunk _ARGS(( - dc_dcontext_t dcontext, - dc_word_t value -)); - -#endif diff --git a/gdb/terminal.h b/gdb/terminal.h deleted file mode 100644 index 4658c7ab4a3..00000000000 --- a/gdb/terminal.h +++ /dev/null @@ -1,50 +0,0 @@ -/* Terminal interface definitions for GDB, the GNU Debugger. - Copyright (C) 1986, 1989, 1991 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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 1, or (at your option) -any later version. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - - -/* Define a common set of macros -- BSD based -- and redefine whatever - the system offers to make it look like that. */ - -#ifdef HAVE_TERMIO - -#include - -#undef TIOCGETP -#define TIOCGETP TCGETA -#undef TIOCSETN -#define TIOCSETN TCSETA -#undef TIOCSETP -#define TIOCSETP TCSETAF -#define TERMINAL struct termio - -#ifdef NO_JOB_CONTROL -# undef TIOCGPGRP -# undef TIOCGPGRP -#endif - -#else /* no termio */ - -#include -#include -#include -#define TERMINAL struct sgttyb - -#endif /* no termio */ - -extern void new_tty (); diff --git a/gdb/tm-29k.h b/gdb/tm-29k.h deleted file mode 100644 index 8e970d0fffa..00000000000 --- a/gdb/tm-29k.h +++ /dev/null @@ -1,666 +0,0 @@ -/* Parameters for target machine of AMD 29000, for GDB, the GNU debugger. - Copyright 1990, 1991 Free Software Foundation, Inc. - Contributed by Cygnus Support. Written by Jim Kingdon. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Parameters for an EB29K (a board which plugs into a PC and is - accessed through EBMON software running on the PC, which we - use as we'd use a remote stub (see remote-eb.c). - - If gdb is ported to other 29k machines/systems, the - machine/system-specific parts should be removed from this file (a - la tm-68k.h). */ - -/* Byte order is configurable, but this machine runs big-endian. */ -#define TARGET_BYTE_ORDER BIG_ENDIAN - -/* Floating point uses IEEE representations. */ -#define IEEE_FLOAT - -/* Recognize our magic number. */ -#define BADMAG(x) ((x).f_magic != 0572) - -/* Define this if the C compiler puts an underscore at the front - of external names before giving them to the linker. */ - -#define NAMES_HAVE_UNDERSCORE - -/* 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) \ - { pc = skip_prologue (pc); } -CORE_ADDR skip_prologue (); - -/* 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 - some instructions. */ - -#define SAVED_PC_AFTER_CALL(frame) (read_register (LR0_REGNUM)) - -/* I'm not sure about the exact value of this, but based on looking - at the stack pointer when we get to main this seems to be right. - - This is the register stack; We call it "CONTROL" in GDB for consistency - with Pyramid. */ -#define CONTROL_END_ADDR 0x80200000 - -/* Memory stack. This is for the default register stack size, which is - only 0x800 bytes. Perhaps we should let the user specify stack sizes - (and tell EBMON with the "ZS" command). */ -#define STACK_END_ADDR 0x801ff800 - -/* Stack grows downward. */ - -#define INNER_THAN < - -/* Stack must be aligned on 32-bit word boundaries. */ -#define STACK_ALIGN(ADDR) (((ADDR) + 3) & ~3) - -/* Sequence of bytes for breakpoint instruction. */ -/* ASNEQ 0x50, gr1, gr1 - The trap number 0x50 is chosen arbitrarily. */ -#if TARGET_BYTE_ORDER == BIG_ENDIAN -#define BREAKPOINT {0x72, 0x50, 0x01, 0x01} -#else /* Target is little-endian. */ -#define BREAKPOINT {0x01, 0x01, 0x50, 0x72} -#endif /* Target is little-endian. */ - -/* 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 4 - -/* Nonzero if instruction at PC is a return instruction. - On the 29k, this is a "jmpi l0" instruction. */ - -#define ABOUT_TO_RETURN(pc) \ - ((read_memory_integer (pc, 4) & 0xff0000ff) == 0xc0000080) - -/* Return 1 if P points to an invalid floating point value. */ - -#define INVALID_FLOAT(p, len) 0 /* Just a first guess; not checked */ - -/* Say how long (ordinary) registers are. */ - -#define REGISTER_TYPE long - -/* Allow the register declarations here to be overridden for remote - kernel debugging. */ -#if !defined (REGISTER_NAMES) - -/* Number of machine registers */ - -#define NUM_REGS 205 - -/* Initializer for an array of names of registers. - There should be NUM_REGS strings in this initializer. - - FIXME, add floating point registers and support here. - - Also note that this list does not attempt to deal with kernel - debugging (in which the first 32 registers are gr64-gr95). */ - -#define REGISTER_NAMES \ -{"gr96", "gr97", "gr98", "gr99", "gr100", "gr101", "gr102", "gr103", "gr104", \ - "gr105", "gr106", "gr107", "gr108", "gr109", "gr110", "gr111", "gr112", \ - "gr113", "gr114", "gr115", "gr116", "gr117", "gr118", "gr119", "gr120", \ - "gr121", "gr122", "gr123", "gr124", "gr125", "gr126", "gr127", \ - "lr0", "lr1", "lr2", "lr3", "lr4", "lr5", "lr6", "lr7", "lr8", "lr9", \ - "lr10", "lr11", "lr12", "lr13", "lr14", "lr15", "lr16", "lr17", "lr18", \ - "lr19", "lr20", "lr21", "lr22", "lr23", "lr24", "lr25", "lr26", "lr27", \ - "lr28", "lr29", "lr30", "lr31", "lr32", "lr33", "lr34", "lr35", "lr36", \ - "lr37", "lr38", "lr39", "lr40", "lr41", "lr42", "lr43", "lr44", "lr45", \ - "lr46", "lr47", "lr48", "lr49", "lr50", "lr51", "lr52", "lr53", "lr54", \ - "lr55", "lr56", "lr57", "lr58", "lr59", "lr60", "lr61", "lr62", "lr63", \ - "lr64", "lr65", "lr66", "lr67", "lr68", "lr69", "lr70", "lr71", "lr72", \ - "lr73", "lr74", "lr75", "lr76", "lr77", "lr78", "lr79", "lr80", "lr81", \ - "lr82", "lr83", "lr84", "lr85", "lr86", "lr87", "lr88", "lr89", "lr90", \ - "lr91", "lr92", "lr93", "lr94", "lr95", "lr96", "lr97", "lr98", "lr99", \ - "lr100", "lr101", "lr102", "lr103", "lr104", "lr105", "lr106", "lr107", \ - "lr108", "lr109", "lr110", "lr111", "lr112", "lr113", "lr114", "lr115", \ - "lr116", "lr117", "lr118", "lr119", "lr120", "lr121", "lr122", "lr123", \ - "lr124", "lr125", "lr126", "lr127", \ - "AI0", "AI1", "AI2", "AI3", "AI4", "AI5", "AI6", "AI7", "AI8", "AI9", \ - "AI10", "AI11", "AI12", "AI13", "AI14", "AI15", "FP", \ - "bp", "fc", "cr", "q", \ - "vab", "ops", "cps", "cfg", "cha", "chd", "chc", "rbp", "tmc", "tmr", \ - "pc0", "pc1", "pc2", "mmu", "lru", "fpe", "int", "fps", "exo", "gr1", \ - "alu", "ipc", "ipa", "ipb" } - -/* Convert Processor Special register #x to REGISTER_NAMES register # */ -#define SR_REGNUM(x) \ - ((x) < 15 ? VAB_REGNUM + (x) \ - : (x) >= 128 && (x) < 131 ? IPC_REGNUM + (x) - 128 \ - : (x) == 131 ? Q_REGNUM \ - : (x) == 132 ? ALU_REGNUM \ - : (x) >= 133 && (x) < 136 ? BP_REGNUM + (x) - 133 \ - : (x) >= 160 && (x) < 163 ? FPE_REGNUM + (x) - 160 \ - : (x) == 164 ? EXO_REGNUM \ - : (error ("Internal error in SR_REGNUM"), 0)) -#define GR96_REGNUM 0 -/* Define the return register separately, so it can be overridden for - kernel procedure calling conventions. */ -#define RETURN_REGNUM GR96_REGNUM -#define GR1_REGNUM 200 -/* This needs to be the memory stack pointer, not the register stack pointer, - to make call_function work right. */ -#define SP_REGNUM MSP_REGNUM -#define FP_REGNUM 33 /* lr1 */ -/* Large Return Pointer (gr123). */ -#define LRP_REGNUM (123 - 96 + GR96_REGNUM) -/* Static link pointer (gr124). */ -#define SLP_REGNUM (124 - 96 + GR96_REGNUM) -/* Memory Stack Pointer (gr125). */ -#define MSP_REGNUM (125 - 96 + GR96_REGNUM) -/* Register allocate bound (gr126). */ -#define RAB_REGNUM (126 - 96 + GR96_REGNUM) -/* Register Free Bound (gr127). */ -#define RFB_REGNUM (127 - 96 + GR96_REGNUM) -/* Register Stack Pointer. */ -#define RSP_REGNUM GR1_REGNUM -#define LR0_REGNUM 32 -#define BP_REGNUM 177 -#define FC_REGNUM 178 -#define CR_REGNUM 179 -#define Q_REGNUM 180 -#define VAB_REGNUM 181 -#define OPS_REGNUM (VAB_REGNUM + 1) -#define CPS_REGNUM (VAB_REGNUM + 2) -#define CFG_REGNUM (VAB_REGNUM + 3) -#define CHA_REGNUM (VAB_REGNUM + 4) -#define CHD_REGNUM (VAB_REGNUM + 5) -#define CHC_REGNUM (VAB_REGNUM + 6) -#define RBP_REGNUM (VAB_REGNUM + 7) -#define TMC_REGNUM (VAB_REGNUM + 8) -#define TMR_REGNUM (VAB_REGNUM + 9) -#define NPC_REGNUM (VAB_REGNUM + 10) /* pc0 */ -#define PC_REGNUM (VAB_REGNUM + 11) /* pc1 */ -#define PC2_REGNUM (VAB_REGNUM + 12) -#define MMU_REGNUM (VAB_REGNUM + 13) -#define LRU_REGNUM (VAB_REGNUM + 14) -#define FPE_REGNUM (VAB_REGNUM + 15) -#define INT_REGNUM (VAB_REGNUM + 16) -#define FPS_REGNUM (VAB_REGNUM + 17) -#define EXO_REGNUM (VAB_REGNUM + 18) -/* gr1 is defined above as 200 = VAB_REGNUM + 19 */ -#define ALU_REGNUM (VAB_REGNUM + 20) -#define PS_REGNUM ALU_REGNUM -#define IPC_REGNUM (VAB_REGNUM + 21) -#define IPA_REGNUM (VAB_REGNUM + 22) -#define IPB_REGNUM (VAB_REGNUM + 23) - -#endif /* !defined(REGISTER_NAMES) */ - -/* Total amount of space needed to store our copies of the machine's - register state, the array `registers'. */ -#define REGISTER_BYTES (NUM_REGS * 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. */ - -/* All regs are 4 bytes. */ - -#define REGISTER_RAW_SIZE(N) (4) - -/* Number of bytes of storage in the program's representation - for register N. */ - -/* 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) - -/* Nonzero if register N requires conversion - from raw format to virtual format. */ - -#define REGISTER_CONVERTIBLE(N) (0) - -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ -{ bcopy ((FROM), (TO), 4); } - -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ -{ bcopy ((FROM), (TO), 4); } - -/* Return the GDB type object for the "standard" data type - of data in register N. */ - -#define REGISTER_VIRTUAL_TYPE(N) \ - (((N) == PC_REGNUM || (N) == LRP_REGNUM || (N) == SLP_REGNUM \ - || (N) == MSP_REGNUM || (N) == RAB_REGNUM || (N) == RFB_REGNUM \ - || (N) == GR1_REGNUM || (N) == FP_REGNUM || (N) == LR0_REGNUM \ - || (N) == NPC_REGNUM || (N) == PC2_REGNUM) \ - ? lookup_pointer_type (builtin_type_void) : 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. */ -/* On the 29k the LRP points to the part of the structure beyond the first - 16 words. */ -#define STORE_STRUCT_RETURN(ADDR, SP) \ - write_register (LRP_REGNUM, (ADDR) + 16 * 4); - -/* Should call_function allocate stack space for a struct return? */ -/* On the 29k objects over 16 words require the caller to allocate space. */ -#define USE_STRUCT_CONVENTION(gcc_p, type) (TYPE_LENGTH (type) > 16 * 4) - -/* 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) \ - { \ - int reg_length = TYPE_LENGTH (TYPE); \ - if (reg_length > 16 * 4) \ - { \ - reg_length = 16 * 4; \ - read_memory (*((int *)(REGBUF) + LRP_REGNUM), (VALBUF) + 16 * 4, \ - TYPE_LENGTH (TYPE) - 16 * 4); \ - } \ - bcopy (((int *)(REGBUF))+RETURN_REGNUM, (VALBUF), reg_length); \ - } - -/* Write into appropriate registers a function return value - of type TYPE, given in virtual format. */ - -#define STORE_RETURN_VALUE(TYPE,VALBUF) \ - { \ - int reg_length = TYPE_LENGTH (TYPE); \ - if (reg_length > 16 * 4) \ - { \ - reg_length = 16 * 4; \ - write_memory (read_register (LRP_REGNUM), \ - (char *)(VALBUF) + 16 * 4, \ - TYPE_LENGTH (TYPE) - 16 * 4); \ - } \ - write_register_bytes (REGISTER_BYTE (RETURN_REGNUM), (char *)(VALBUF), \ - TYPE_LENGTH (TYPE)); \ - } - -/* The am29k user's guide documents well what the stacks look like. - But what isn't so clear there is how this interracts with the - symbols, or with GDB. - In the following saved_msp, saved memory stack pointer (which functions - as a memory frame pointer), means either - a register containing the memory frame pointer or, in the case of - functions with fixed size memory frames (i.e. those who don't use - alloca()), the result of the calculation msp + msize. - - LOC_ARG, LOC_LOCAL - For GCC, these are relative to saved_msp. - For high C, these are relative to msp (making alloca impossible). - LOC_REGISTER, LOC_REGPARM - The register number is the number at the - time the function is running (after the prologue), or in the case - of LOC_REGPARM, may be a register number in the range 160-175. - - The compilers do things like store an argument into memory, and then put out - a LOC_ARG for it, or put it into global registers and put out a - LOC_REGPARM. Thus is it important to execute the first line of - code (i.e. the line of the open brace, i.e. the prologue) of a function - before trying to print arguments or anything. - - The following diagram attempts to depict what is going on in memory - (see also the _am29k user's guide_) and also how that interacts with - GDB frames. We arbitrarily pick fci->frame to point the same place - as the register stack pointer; since we set it ourself in - INIT_EXTRA_FRAME_INFO, and access it only through the FRAME_* - macros, it doesn't really matter exactly how we - do it. However, note that FRAME_FP is used in two ways in GDB: - (1) as a "magic cookie" which uniquely identifies frames (even over - calls to the inferior), (2) (in PC_IN_CALL_DUMMY [ON_STACK]) - as the value of SP_REGNUM before the dummy frame was pushed. These - two meanings would be incompatible for the 29k if we defined - CALL_DUMMY_LOCATION == ON_STACK (but we don't, so don't worry about it). - Also note that "lr1" below, while called a frame pointer - in the user's guide, has only one function: To determine whether - registers need to be filled in the function epilogue. - - Consider the code: - < call bar> - loc1: . . . - bar: sub gr1,gr1,rsize_b - . . . - add mfp,msp,0 - sub msp,msp,msize_b - . . . - < call foo > - loc2: . . . - foo: sub gr1,gr1,rsize_f - . . . - add mfp,msp,0 - sub msp,msp,msize_f - . . . - loc3: < suppose the inferior stops here > - - memory stack register stack - | | |____________| - | | |____loc1____| - +------->|___________| | | ^ - | | ^ | | locals_b | | - | | | | |____________| | - | | | | | | | rsize_b - | | | msize_b | | args_to_f | | - | | | | |____________| | - | | | | |____lr1_____| V - | | V | |____loc2____|<----------------+ - | +--->|___________|<---------mfp | ^ | - | | | ^ | | locals_f | | | - | | | | msize_f | |____________| | | - | | | | | | | | rsize_f | - | | | V | | args | | | - | | |___________|pc and ->frame, but all the extra stuff, when called from - get_prev_frame_info, that is. */ -#define INIT_EXTRA_FRAME_INFO(fromleaf, fci) \ - init_extra_frame_info(fci); -void init_extra_frame_info (); -#define INIT_FRAME_PC(fromleaf, fci) \ - init_frame_pc(fromleaf, fci); -void init_frame_pc (); - -/* FRAME_CHAIN takes a FRAME - and produces the frame's chain-pointer. - - However, if FRAME_CHAIN_VALID returns zero, - it means the given frame is the outermost one and has no caller. */ - -/* On the 29k, the nominal address of a frame is the address on the - register stack of the return address (the one next to the incoming - arguments, not down at the bottom so nominal address == stack pointer). - - GDB expects "nominal address" to equal contents of FP_REGNUM, - at least when it comes time to create the innermost frame. - However, that doesn't work for us, so when creating the innermost - frame we set ->frame ourselves in INIT_EXTRA_FRAME_INFO. */ - -/* These are mostly dummies for the 29k because INIT_FRAME_PC - sets prev->frame instead. */ -#define FRAME_CHAIN(thisframe) (0) - -/* Not sure how to figure out where the bottom frame is. There is - no frame for start. In my tests so far the - pc has been outside the text segment, though, so check for that. - FIXME!!! - However, allow a pc in a call dummy. */ -#define FRAME_CHAIN_VALID(chain, thisframe) \ - (outside_startup_file (FRAME_SAVED_PC (thisframe))) - -/* 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. */ -#define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \ - (FRAMELESS) = frameless_look_for_prologue(FI) - -/* Saved pc (i.e. return address). */ -#define FRAME_SAVED_PC(fraim) \ - (read_register_stack_integer ((fraim)->frame + (fraim)->rsize, 4)) - -/* Local variables (i.e. LOC_LOCAL) are on the memory stack, with their - offsets being relative to the memory stack pointer (high C) or - saved_msp (gcc). */ - -#define FRAME_LOCALS_ADDRESS(fi) frame_locals_address (fi) -extern CORE_ADDR frame_locals_address (); - -/* Return number of args passed to a frame. - Can return -1, meaning no way to tell. */ -/* While we could go the effort of finding the tags word and getting - the argcount field from it, - (1) It only counts arguments in registers, i.e. the first 16 words - of arguments - (2) It gives the number of arguments the function was declared with - not how many it was called with (or some variation, like all 16 - words for varadic functions). This makes argcount pretty much - redundant with -g info, even for varadic functions. - So don't bother. */ -#define FRAME_NUM_ARGS(numargs, fi) ((numargs) = -1) - -#define FRAME_ARGS_ADDRESS(fi) FRAME_LOCALS_ADDRESS (fi) - -/* Return number of bytes at start of arglist that are not really args. */ - -#define FRAME_ARGS_SKIP 0 - -/* Provide our own get_saved_register. HAVE_REGISTER_WINDOWS is insufficient - because registers get renumbered on the 29k without getting saved. */ - -#define GET_SAVED_REGISTER - -/* Call function stuff. */ - -/* The dummy frame looks like this (see also the general frame picture - above): - - register stack - - | | frame for function - | locals_sproc | executing at time - |________________| of call_function. - | | We must not disturb - | args_out_sproc | it. - memory stack |________________| - |____lr1_sproc___| - | | |__retaddr_sproc_| <- gr1 (at start) - |____________|<-msp 0 <-----------mfp_dummy_____| - | | (at start) | | - | arg_slop | | saved regs | - | (16 words) | | gr96-gr124 | - |____________|<-msp 1--after | sr128-sr135 | - | | PUSH_DUMMY_FRAME| | - | struct ret | |________________| - | 17+ | | | - |____________|<- lrp | args_out_dummy | - | struct ret | | (16 words) | - | 16 | |________________| - | (16 words) | |____lr1_dummy___| - |____________|<- msp 2--after |_retaddr_dummy__|<- gr1 after - | | struct ret | | PUSH_DUMMY_FRAME - | margs17+ | area allocated | locals_inf | - | | |________________| called - |____________|<- msp 4--when | | function's - | | inf called | args_out_inf | frame (set up - | margs16 | |________________| by called - | (16 words) | |_____lr1_inf____| function). - |____________|<- msp 3--after | . | - | | args pushed | . | - | | | . | - | | - - arg_slop: This area is so that when the call dummy adds 16 words to - the msp, it won't end up larger than mfp_dummy (it is needed in the - case where margs and struct_ret do not add up to at least 16 words). - struct ret: This area is allocated by GDB if the return value is more - than 16 words. struct ret_16 is not used on the 29k. - margs: Pushed by GDB. The call dummy copies the first 16 words to - args_out_dummy. - retaddr_sproc: Contains the PC at the time we call the function. - set by PUSH_DUMMY_FRAME and read by POP_FRAME. - retaddr_dummy: This points to a breakpoint instruction in the dummy. */ - -/* Rsize for dummy frame, in bytes. */ - -/* Bytes for outgoing args, lr1, and retaddr. */ -#define DUMMY_ARG (2 * 4 + 16 * 4) - -/* Number of special registers (sr128-) to save. */ -#define DUMMY_SAVE_SR128 8 -/* Number of general (gr96- or gr64-) registers to save. */ -#define DUMMY_SAVE_GREGS 29 - -#define DUMMY_FRAME_RSIZE \ -(4 /* mfp_dummy */ \ - + DUMMY_SAVE_GREGS * 4 \ - + DUMMY_SAVE_SR128 * 4 \ - + DUMMY_ARG \ - ) - -/* Push an empty stack frame, to record the current PC, etc. */ - -#define PUSH_DUMMY_FRAME push_dummy_frame(); -extern void push_dummy_frame (); - -/* Discard from the stack the innermost frame, - restoring all saved registers. */ - -#define POP_FRAME pop_frame (); -extern void pop_frame (); - -/* This sequence of words is the instructions - mtsrim cr, 15 - loadm 0, 0, lr2, msp ; load first 16 words of arguments into registers - add msp, msp, 16 * 4 ; point to the remaining arguments - CONST_INSN: - const gr96,inf - consth gr96,inf - calli lr0, gr96 - aseq 0x40,gr1,gr1 ; nop - asneq 0x50,gr1,gr1 ; breakpoint - */ - -/* Position of the "const" instruction within CALL_DUMMY in bytes. */ -#define CONST_INSN (3 * 4) -#if TARGET_BYTE_ORDER == HOST_BYTE_ORDER -#define CALL_DUMMY {0x0400870f, 0x3600827d, 0x157d7d40, 0x03ff60ff, \ - 0x02ff60ff, 0xc8008060, 0x70400101, 0x72500101} -#else /* Byte order differs. */ - you lose -#endif /* Byte order differs. */ -#define CALL_DUMMY_LENGTH (8 * 4) - -#define CALL_DUMMY_START_OFFSET 0 /* Start execution at beginning of dummy */ - -/* Helper macro for FIX_CALL_DUMMY. WORDP is a long * which points to a - word in target byte order; bits 0-7 and 16-23 of *WORDP are replaced with - bits 0-7 and 8-15 of DATA (which is in host byte order). */ - -#if TARGET_BYTE_ORDER == BIG_ENDIAN -#define STUFF_I16(WORDP, DATA) \ - { \ - *((char *)(WORDP) + 3) = ((DATA) & 0xff);\ - *((char *)(WORDP) + 1) = (((DATA) >> 8) & 0xff);\ - } -#else /* Target is little endian. */ -#define STUFF_I16(WORDP, DATA) \ - { - *(char *)(WORDP) = ((DATA) & 0xff); - *((char *)(WORDP) + 2) = (((DATA) >> 8) & 0xff); - } -#endif /* Target is little endian. */ - -/* Insert the specified number of args and function address - into a call sequence of the above form stored at DUMMYNAME. */ - -/* Currently this stuffs in the address of the function that we are calling. - If different 29k systems use different breakpoint instructions, it - could also stuff BREAKPOINT in the right place (to avoid having to - duplicate CALL_DUMMY in each tm-*.h file). */ - -#define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p) \ - {\ - STUFF_I16((char *)dummyname + CONST_INSN, fun);\ - STUFF_I16((char *)dummyname + CONST_INSN + 4, fun >> 16);\ - } - -/* 29k architecture has separate data & instruction memories -- wired to - different pins on the chip -- and can't execute the data memory. - Also, there should be space after text_end; - we won't get a SIGSEGV or scribble on data space. */ - -#define CALL_DUMMY_LOCATION AFTER_TEXT_END - -/* Because of this, we need (as a kludge) to know the addresses of the - text section. */ - -#define NEED_TEXT_START_END - -/* How to translate register numbers in the .stab's into gdb's internal register - numbers. We don't translate them, but we warn if an invalid register - number is seen. Note that FIXME, we use the value "sym" as an implicit - argument in printing the error message. It happens to be available where - this macro is used. (This macro definition appeared in a late revision - of gdb-3.91.6 and is not well tested. Also, it should be a "complaint".) */ - -#define STAB_REG_TO_REGNUM(num) \ - (((num) > LR0_REGNUM + 127) \ - ? fprintf(stderr, \ - "Invalid register number %d in symbol table entry for %s\n", \ - (num), SYMBOL_NAME (sym)), (num) \ - : (num)) diff --git a/gdb/tm-3b1.h b/gdb/tm-3b1.h deleted file mode 100644 index 4bcf01fcb0f..00000000000 --- a/gdb/tm-3b1.h +++ /dev/null @@ -1,38 +0,0 @@ -/* Parameters for targeting to a 3b1. - Copyright (C) 1986, 1987, 1989, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Define BPT_VECTOR if it is different than the default. - This is the vector number used by traps to indicate a breakpoint. */ - -#define BPT_VECTOR 0x1 - -/* Define this if the C compiler puts an underscore at the front - of external names before giving them to the linker. */ - -#define NAMES_HAVE_UNDERSCORE - -/* Debugger information will be in COFF format, without long filenames. */ - -#define COFF_NO_LONG_FILE_NAMES - -/* Address of end of stack space. */ - -#define STACK_END_ADDR 0x300000 - -#include "tm-68k.h" diff --git a/gdb/tm-68k.h b/gdb/tm-68k.h deleted file mode 100644 index 8464263f004..00000000000 --- a/gdb/tm-68k.h +++ /dev/null @@ -1,538 +0,0 @@ -/* Parameters for execution on a 68000 series machine. - Copyright (C) 1986, 1987, 1989, 1990 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Generic 68000 stuff, to be included by other tm-*.h files. - Define HAVE_68881 if that is the case. */ - -#if defined (HAVE_68881) -#define IEEE_FLOAT 1 -#endif - -/* Define the bit, byte, and word ordering of the machine. */ -#define TARGET_BYTE_ORDER BIG_ENDIAN - -/* 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. */ - -#if !defined(SKIP_PROLOGUE) -#define SKIP_PROLOGUE(ip) {(ip) = m68k_skip_prologue(ip);} -extern CORE_ADDR m68k_skip_prologue (); -#endif - -/* 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) \ -read_memory_integer (read_register (SP_REGNUM), 4) - -/* Stack grows downward. */ - -#define INNER_THAN < - -/* Sequence of bytes for breakpoint instruction. - This is a TRAP instruction. The last 4 bits (0xf below) is the - vector. Systems which don't use 0xf should define BPT_VECTOR - themselves before including this file. */ - -#if !defined (BPT_VECTOR) -#define BPT_VECTOR 0xf -#endif - -#if !defined (BREAKPOINT) -#define BREAKPOINT {0x4e, (0x40 | BPT_VECTOR)} -#endif - -/* If your kernel resets the pc after the trap happens you may need to - define this before including this file. */ - -#if !defined (DECR_PC_AFTER_BREAK) -#define DECR_PC_AFTER_BREAK 2 -#endif - -/* Nonzero if instruction at PC is a return instruction. */ -/* Allow any of the return instructions, including a trapv and a return - from interupt. */ - -#define ABOUT_TO_RETURN(pc) ((read_memory_integer (pc, 2) & ~0x3) == 0x4e74) - -/* Return 1 if P points to an invalid floating point value. */ - -#define INVALID_FLOAT(p, len) 0 /* Just a first guess; not checked */ - -/* Say how long registers are. */ - -#define REGISTER_TYPE long - -#if defined (HAVE_68881) -# if defined (GDB_TARGET_IS_SUN3) - /* Sun3 status includes fpflags, which shows whether the FPU has been used - by the process, and whether the FPU was done with an instruction or - was interrupted in the middle of a long instruction. See - . */ - /* a&d, pc,sr, fp, fpstat, fpflags */ -# define NUM_REGS 31 -# define REGISTER_BYTES (16*4 + 8 + 8*12 + 3*4 + 4) -# else /* Not sun3. */ -# define NUM_REGS 29 -# define REGISTER_BYTES (16*4 + 8 + 8*12 + 3*4) -# endif /* Not sun3. */ -#else /* No 68881. */ -# define NUM_REGS 18 -# define REGISTER_BYTES (16*4 + 8) -#endif /* No 68881. */ - -/* Index within `registers' of the first byte of the space for - register N. */ - -#if defined (HAVE_68881) -#define REGISTER_BYTE(N) \ - ((N) >= FPC_REGNUM ? (((N) - FPC_REGNUM) * 4) + 168 \ - : (N) >= FP0_REGNUM ? (((N) - FP0_REGNUM) * 12) + 72 \ - : (N) * 4) - -/* Number of bytes of storage in the actual machine representation - for register N. On the 68000, all regs are 4 bytes - except the floating point regs which are 12 bytes. */ -/* Note that the unsigned cast here forces the result of the - subtraction to very high positive values if N < FP0_REGNUM */ - -#define REGISTER_RAW_SIZE(N) (((unsigned)(N) - FP0_REGNUM) < 8 ? 12 : 4) - -/* Number of bytes of storage in the program's representation - for register N. On the 68000, all regs are 4 bytes - except the floating point regs which are 8-byte doubles. */ - -#define REGISTER_VIRTUAL_SIZE(N) (((unsigned)(N) - FP0_REGNUM) < 8 ? 8 : 4) - -/* Largest value REGISTER_RAW_SIZE can have. */ - -#define MAX_REGISTER_RAW_SIZE 12 - -/* 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. */ - -#define REGISTER_CONVERTIBLE(N) (((unsigned)(N) - FP0_REGNUM) < 8) - -/* Put the declaration out here because if it's in the macros, PCC - will complain. */ -extern struct ext_format ext_format_68881; - -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ -{ \ - if ((REGNUM) >= FP0_REGNUM && (REGNUM) < FPC_REGNUM) \ - ieee_extended_to_double (&ext_format_68881, (FROM), (double *)(TO)); \ - else \ - bcopy ((FROM), (TO), 4); \ -} - -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ -{ \ - if ((REGNUM) >= FP0_REGNUM && (REGNUM) < FPC_REGNUM) \ - double_to_ieee_extended (&ext_format_68881, (double *)(FROM), (TO)); \ - else \ - bcopy ((FROM), (TO), 4); \ -} - -/* Return the GDB type object for the "standard" data type - of data in register N. */ -/* Note, for registers which contain addresses return - pointer to void, not pointer to char, because we don't - want to attempt to print the string after printing the address. */ -#define REGISTER_VIRTUAL_TYPE(N) \ - (((unsigned)(N) - FP0_REGNUM) < 8 ? builtin_type_double : \ - (N) == PC_REGNUM || (N) == FP_REGNUM || (N) == SP_REGNUM ? \ - lookup_pointer_type (builtin_type_void) : builtin_type_int) - -#else /* no 68881. */ -/* 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 68000, 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 68000, 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 - -/* Nonzero if register N requires conversion - from raw format to virtual format. */ - -#define REGISTER_CONVERTIBLE(N) 0 - -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) bcopy ((FROM), (TO), 4); - -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) bcopy ((FROM), (TO), 4); - -/* Return the GDB type object for the "standard" data type - of data in register N. */ - -#define REGISTER_VIRTUAL_TYPE(N) builtin_type_int - -#endif /* No 68881. */ - -/* Initializer for an array of names of registers. - Entries beyond the first NUM_REGS are ignored. */ - -#define REGISTER_NAMES \ - {"d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", \ - "a0", "a1", "a2", "a3", "a4", "a5", "fp", "sp", \ - "ps", "pc", \ - "fp0", "fp1", "fp2", "fp3", "fp4", "fp5", "fp6", "fp7", \ - "fpcontrol", "fpstatus", "fpiaddr", "fpcode", "fpflags" } - -/* 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 A1_REGNUM 9 -#define FP_REGNUM 14 /* Contains address of executing stack frame */ -#define SP_REGNUM 15 /* Contains address of top of stack */ -#define PS_REGNUM 16 /* Contains processor status */ -#define PC_REGNUM 17 /* Contains program counter */ -#if defined (HAVE_68881) -#define FP0_REGNUM 18 /* Floating point register 0 */ -#define FPC_REGNUM 26 /* 68881 control register */ -#define FPS_REGNUM 27 /* 68881 status register */ -#define FPI_REGNUM 28 /* 68881 iaddr register */ -#endif /* 68881. */ - -/* 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 (A1_REGNUM, (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. This is assuming that floating point values are returned - as doubles in d0/d1. */ - -#if !defined (EXTRACT_RETURN_VALUE) -#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \ - bcopy ((char *)(REGBUF) + \ - (TYPE_LENGTH(TYPE) >= 4 ? 0 : 4 - TYPE_LENGTH(TYPE)), \ - VALBUF, TYPE_LENGTH(TYPE)) -#endif - -/* Write into appropriate registers a function return value - of type TYPE, given in virtual format. Assumes floats are passed - in d0/d1. */ - -#if !defined (STORE_RETURN_VALUE) -#define STORE_RETURN_VALUE(TYPE,VALBUF) \ - write_register_bytes (0, VALBUF, TYPE_LENGTH (TYPE)) -#endif - -/* 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) (*(CORE_ADDR *)(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. - - However, if FRAME_CHAIN_VALID returns zero, - it means the given frame is the outermost one and has no caller. */ - -/* In the case of the 68000, the frame's nominal address - is the address of a 4-byte word containing the calling frame's address. */ - -#define FRAME_CHAIN(thisframe) \ - (outside_startup_file ((thisframe)->pc) ? \ - read_memory_integer ((thisframe)->frame, 4) :\ - 0) - -#if defined (FRAME_CHAIN_VALID_ALTERNATE) - -/* Use the alternate method of avoiding running up off the end of - the frame chain or following frames back into the startup code. - See the comments in blockframe.c */ - -#define FRAME_CHAIN_VALID(chain, thisframe) \ - (chain != 0 \ - && !(inside_main_scope ((thisframe)->pc)) \ - && !(inside_entry_scope ((thisframe)->pc))) - -#else - -#define FRAME_CHAIN_VALID(chain, thisframe) \ - (chain != 0 && outside_startup_file (FRAME_SAVED_PC (thisframe))) - -#endif /* FRAME_CHAIN_VALID_ALTERNATE */ - -/* 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. */ -#define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \ - (FRAMELESS) = frameless_look_for_prologue(FI) - -#define FRAME_SAVED_PC(FRAME) (read_memory_integer ((FRAME)->frame + 4, 4)) - -#define FRAME_ARGS_ADDRESS(fi) ((fi)->frame) - -#define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame) - -/* Set VAL to the number of args passed to frame described by FI. - Can set VAL to -1, meaning no way to tell. */ - -/* We can't tell how many args there are - now that the C compiler delays popping them. */ -#if !defined (FRAME_NUM_ARGS) -#define FRAME_NUM_ARGS(val,fi) (val = -1) -#endif - -/* Return number of bytes at start of arglist that are not really args. */ - -#define FRAME_ARGS_SKIP 8 - -/* 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. */ - -#if !defined (FRAME_FIND_SAVED_REGS) -#if defined (HAVE_68881) -#define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \ -{ register int regnum; \ - register int regmask; \ - register CORE_ADDR next_addr; \ - register CORE_ADDR pc; \ - int nextinsn; \ - bzero (&frame_saved_regs, sizeof frame_saved_regs); \ - if ((frame_info)->pc >= (frame_info)->frame - CALL_DUMMY_LENGTH - FP_REGNUM*4 - 8*12 - 4 \ - && (frame_info)->pc <= (frame_info)->frame) \ - { next_addr = (frame_info)->frame; \ - pc = (frame_info)->frame - CALL_DUMMY_LENGTH - FP_REGNUM * 4 - 8*12 - 4; }\ - else \ - { pc = get_pc_function_start ((frame_info)->pc); \ - /* Verify we have a link a6 instruction next; \ - if not we lose. If we win, find the address above the saved \ - regs using the amount of storage from the link instruction. */\ - if (044016 == read_memory_integer (pc, 2)) \ - next_addr = (frame_info)->frame + read_memory_integer (pc += 2, 4), pc+=4; \ - else if (047126 == read_memory_integer (pc, 2)) \ - next_addr = (frame_info)->frame + read_memory_integer (pc += 2, 2), pc+=2; \ - else goto lose; \ - /* If have an addal #-n, sp next, adjust next_addr. */ \ - if ((0177777 & read_memory_integer (pc, 2)) == 0157774) \ - next_addr += read_memory_integer (pc += 2, 4), pc += 4; \ - } \ - /* next should be a moveml to (sp) or -(sp) or a movl r,-(sp) */ \ - regmask = read_memory_integer (pc + 2, 2); \ - /* But before that can come an fmovem. Check for it. */ \ - nextinsn = 0xffff & read_memory_integer (pc, 2); \ - if (0xf227 == nextinsn \ - && (regmask & 0xff00) == 0xe000) \ - { pc += 4; /* Regmask's low bit is for register fp7, the first pushed */ \ - for (regnum = FP0_REGNUM + 7; regnum >= FP0_REGNUM; regnum--, regmask >>= 1) \ - if (regmask & 1) \ - (frame_saved_regs).regs[regnum] = (next_addr -= 12); \ - regmask = read_memory_integer (pc + 2, 2); } \ - if (0044327 == read_memory_integer (pc, 2)) \ - { pc += 4; /* Regmask's low bit is for register 0, the first written */ \ - for (regnum = 0; regnum < 16; regnum++, regmask >>= 1) \ - if (regmask & 1) \ - (frame_saved_regs).regs[regnum] = (next_addr += 4) - 4; } \ - else if (0044347 == read_memory_integer (pc, 2)) \ - { pc += 4; /* Regmask's low bit is for register 15, the first pushed */ \ - for (regnum = 15; regnum >= 0; regnum--, regmask >>= 1) \ - if (regmask & 1) \ - (frame_saved_regs).regs[regnum] = (next_addr -= 4); } \ - else if (0x2f00 == (0xfff0 & read_memory_integer (pc, 2))) \ - { regnum = 0xf & read_memory_integer (pc, 2); pc += 2; \ - (frame_saved_regs).regs[regnum] = (next_addr -= 4); } \ - /* fmovemx to index of sp may follow. */ \ - regmask = read_memory_integer (pc + 2, 2); \ - nextinsn = 0xffff & read_memory_integer (pc, 2); \ - if (0xf236 == nextinsn \ - && (regmask & 0xff00) == 0xf000) \ - { pc += 10; /* Regmask's low bit is for register fp0, the first written */ \ - for (regnum = FP0_REGNUM + 7; regnum >= FP0_REGNUM; regnum--, regmask >>= 1) \ - if (regmask & 1) \ - (frame_saved_regs).regs[regnum] = (next_addr += 12) - 12; \ - regmask = read_memory_integer (pc + 2, 2); } \ - /* clrw -(sp); movw ccr,-(sp) may follow. */ \ - if (0x426742e7 == read_memory_integer (pc, 4)) \ - (frame_saved_regs).regs[PS_REGNUM] = (next_addr -= 4); \ - lose: ; \ - (frame_saved_regs).regs[SP_REGNUM] = (frame_info)->frame + 8; \ - (frame_saved_regs).regs[FP_REGNUM] = (frame_info)->frame; \ - (frame_saved_regs).regs[PC_REGNUM] = (frame_info)->frame + 4; \ -} -#else /* no 68881. */ -#define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \ -{ register int regnum; \ - register int regmask; \ - register CORE_ADDR next_addr; \ - register CORE_ADDR pc; \ - bzero (&frame_saved_regs, sizeof frame_saved_regs); \ - if ((frame_info)->pc >= (frame_info)->frame - CALL_DUMMY_LENGTH - FP_REGNUM*4 - 4 \ - && (frame_info)->pc <= (frame_info)->frame) \ - { next_addr = (frame_info)->frame; \ - pc = (frame_info)->frame - CALL_DUMMY_LENGTH - FP_REGNUM * 4 - 4; }\ - else \ - { pc = get_pc_function_start ((frame_info)->pc); \ - /* Verify we have a link a6 instruction next; \ - if not we lose. If we win, find the address above the saved \ - regs using the amount of storage from the link instruction. */\ - if (044016 == read_memory_integer (pc, 2)) \ - next_addr = (frame_info)->frame + read_memory_integer (pc += 2, 4), pc+=4; \ - else if (047126 == read_memory_integer (pc, 2)) \ - next_addr = (frame_info)->frame + read_memory_integer (pc += 2, 2), pc+=2; \ - else goto lose; \ - /* If have an addal #-n, sp next, adjust next_addr. */ \ - if ((0177777 & read_memory_integer (pc, 2)) == 0157774) \ - next_addr += read_memory_integer (pc += 2, 4), pc += 4; \ - } \ - /* next should be a moveml to (sp) or -(sp) or a movl r,-(sp) */ \ - regmask = read_memory_integer (pc + 2, 2); \ - if (0044327 == read_memory_integer (pc, 2)) \ - { pc += 4; /* Regmask's low bit is for register 0, the first written */ \ - for (regnum = 0; regnum < 16; regnum++, regmask >>= 1) \ - if (regmask & 1) \ - (frame_saved_regs).regs[regnum] = (next_addr += 4) - 4; } \ - else if (0044347 == read_memory_integer (pc, 2)) \ - { pc += 4; /* Regmask's low bit is for register 15, the first pushed */ \ - for (regnum = 15; regnum >= 0; regnum--, regmask >>= 1) \ - if (regmask & 1) \ - (frame_saved_regs).regs[regnum] = (next_addr -= 4); } \ - else if (0x2f00 == 0xfff0 & read_memory_integer (pc, 2)) \ - { regnum = 0xf & read_memory_integer (pc, 2); pc += 2; \ - (frame_saved_regs).regs[regnum] = (next_addr -= 4); } \ - /* clrw -(sp); movw ccr,-(sp) may follow. */ \ - if (0x426742e7 == read_memory_integer (pc, 4)) \ - (frame_saved_regs).regs[PS_REGNUM] = (next_addr -= 4); \ - lose: ; \ - (frame_saved_regs).regs[SP_REGNUM] = (frame_info)->frame + 8; \ - (frame_saved_regs).regs[FP_REGNUM] = (frame_info)->frame; \ - (frame_saved_regs).regs[PC_REGNUM] = (frame_info)->frame + 4; \ -} -#endif /* no 68881. */ -#endif /* no FIND_FRAME_SAVED_REGS. */ - - -/* Things needed for making the inferior call functions. - It seems like every m68k based machine has almost identical definitions - in the individual machine's configuration files. Most other cpu types - (mips, i386, etc) have routines in their *-tdep.c files to handle this - for most configurations. The m68k family should be able to do this as - well. These macros can still be overridden when necessary. */ - -/* The CALL_DUMMY macro is the sequence of instructions, as disassembled - by gdb itself: - - fmovemx fp0-fp7,sp@- 0xf227 0xe0ff - moveml d0-a5,sp@- 0x48e7 0xfffc - clrw sp@- 0x4267 - movew ccr,sp@- 0x42e7 - - /..* The arguments are pushed at this point by GDB; - no code is needed in the dummy for this. - The CALL_DUMMY_START_OFFSET gives the position of - the following jsr instruction. *../ - - jsr @#0x32323232 0x4eb9 0x3232 0x3232 - addal #0x69696969,sp 0xdffc 0x6969 0x6969 - trap # 0x4e4? - nop 0x4e71 - - Note this is CALL_DUMMY_LENGTH bytes (28 for the above example). - We actually start executing at the jsr, since the pushing of the - registers is done by PUSH_DUMMY_FRAME. If this were real code, - the arguments for the function called by the jsr would be pushed - between the moveml and the jsr, and we could allow it to execute through. - But the arguments have to be pushed by GDB after the PUSH_DUMMY_FRAME is - done, and we cannot allow the moveml to push the registers again lest - they be taken for the arguments. */ - -#if defined (HAVE_68881) - -#define CALL_DUMMY {0xf227e0ff, 0x48e7fffc, 0x426742e7, 0x4eb93232, 0x3232dffc, 0x69696969, (0x4e404e71 | (BPT_VECTOR << 16))} -#define CALL_DUMMY_LENGTH 28 /* Size of CALL_DUMMY */ -#define CALL_DUMMY_START_OFFSET 12 /* Offset to jsr instruction*/ - -#else - -#define CALL_DUMMY {0x48e7fffc, 0x426742e7, 0x4eb93232, 0x3232dffc, 0x69696969, (0x4e404e71 | (BPT_VECTOR << 16))} -#define CALL_DUMMY_LENGTH 24 /* Size of CALL_DUMMY */ -#define CALL_DUMMY_START_OFFSET 8 /* Offset to jsr instruction*/ - -#endif /* HAVE_68881 */ - -/* 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) \ -{ *(int *)((char *) dummyname + CALL_DUMMY_START_OFFSET + 2) = fun; \ - *(int *)((char *) dummyname + CALL_DUMMY_START_OFFSET + 8) = nargs * 4; } - -/* Push an empty stack frame, to record the current PC, etc. */ - -#define PUSH_DUMMY_FRAME { m68k_push_dummy_frame (); } - -/* Discard from the stack the innermost frame, restoring all registers. */ - -#define POP_FRAME { m68k_pop_frame (); } - diff --git a/gdb/tm-altos.h b/gdb/tm-altos.h deleted file mode 100644 index f3cc306b1b2..00000000000 --- a/gdb/tm-altos.h +++ /dev/null @@ -1,63 +0,0 @@ -/* Definitions to make GDB run on an Altos 3068 (m68k running SVR2) - Copyright (C) 1987, 1989, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Define BPT_VECTOR if it is different than the default. - This is the vector number used by traps to indicate a breakpoint. */ - -#define BPT_VECTOR 0xe - -/* Define this if the C compiler puts an underscore at the front - of external names before giving them to the linker. */ - -#undef NAMES_HAVE_UNDERSCORE - -/* COFF files don't have long filenames. */ - -#define COFF_NO_LONG_FILE_NAMES - -/* Address of end of stack space. */ - -/*#define STACK_END_ADDR (0xffffff)*/ -#define STACK_END_ADDR (0x1000000) - -/* Amount PC must be decremented by after a breakpoint. - On the Altos, the kernel resets the pc to the trap instr */ - -#define DECR_PC_AFTER_BREAK 0 - -/* The only reason this is here is the tm-altos.h reference below. It - was moved back here from tm-68k.h. FIXME? */ - -#define SKIP_PROLOGUE(pc) \ -{ register int op = read_memory_integer (pc, 2); \ - if (op == 0047126) \ - pc += 4; /* Skip link #word */ \ - else if (op == 0044016) \ - pc += 6; /* Skip link #long */ \ - /* Not sure why branches are here. */ \ - /* From tm-isi.h, tm-altos.h */ \ - else if (op == 0060000) \ - pc += 4; /* Skip bra #word */ \ - else if (op == 00600377) \ - pc += 6; /* skip bra #long */ \ - else if ((op & 0177400) == 0060000) \ - pc += 2; /* skip bra #char */ \ -} - -#include "tm-68k.h" diff --git a/gdb/tm-altosgas.h b/gdb/tm-altosgas.h deleted file mode 100644 index c20030c4253..00000000000 --- a/gdb/tm-altosgas.h +++ /dev/null @@ -1,24 +0,0 @@ -/* Definitions to make GDB run on an Altos 3068 using COFF encapsulation. - Copyright (C) 1989, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#define COFF_ENCAPSULATE - -#include "m-altos.h" - -#define NAMES_HAVE_UNDERSCORE diff --git a/gdb/tm-amix.h b/gdb/tm-amix.h deleted file mode 100644 index 635d3b38efb..00000000000 --- a/gdb/tm-amix.h +++ /dev/null @@ -1,47 +0,0 @@ -/* Macro definitions for GDB on a Commodore Amiga running SVR4 (amix). - Copyright (C) 1991, Free Software Foundation, Inc. - Written by Fred Fish at Cygnus Support (fnf@cygint) - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* All Amiga's (so far) running UNIX have come standard with the floating - point coprocessor. */ - -#define HAVE_68881 - -/* Define BPT_VECTOR if it is different than the default. - This is the vector number used by traps to indicate a breakpoint. */ - -#define BPT_VECTOR 0x1 - -/* How much to decrement the PC after a trap. Depends on kernel. */ - -#define DECR_PC_AFTER_BREAK 0 /* No decrement required */ - -/* Address of end of stack space. Actually one byte past it. - This value is typically very OS dependent. - FIXME: Check to see if SVR4 offers some machine independent way - of discovering this value and use it if so, and if we need it. */ - -/* #define STACK_END_ADDR 0xc0800000 */ - -/* Use the alternate method of determining valid frame chains. */ - -#define FRAME_CHAIN_VALID_ALTERNATE - -#include "tm-svr4.h" -#include "tm-68k.h" diff --git a/gdb/tm-arm.h b/gdb/tm-arm.h deleted file mode 100644 index 87151950799..00000000000 --- a/gdb/tm-arm.h +++ /dev/null @@ -1,405 +0,0 @@ -/* Definitions to make GDB target for an ARM under RISCiX (4.3bsd). - Copyright (C) 1986, 1987, 1989, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#define TARGET_BYTE_ORDER LITTLE_ENDIAN - -/* IEEE format floating point */ - -#define IEEE_FLOAT - -/* I provide my own xfer_core_file to cope with shared libraries */ - -#define XFER_CORE_FILE - -/* Define this if the C compiler puts an underscore at the front - of external names before giving them to the linker. */ - -#define NAMES_HAVE_UNDERSCORE - -/* 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) pc = 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) (read_register (LR_REGNUM) & 0x03fffffc) - -/* I don't know the real values for these. */ -#define TARGET_UPAGES UPAGES -#define TARGET_NBPG NBPG - -/* Address of end of stack space. */ - -#define STACK_END_ADDR (0x01000000 - (TARGET_UPAGES * TARGET_NBPG)) - -/* Stack grows downward. */ - -#define INNER_THAN < - -/* Sequence of bytes for breakpoint instruction. */ - -#define BREAKPOINT {0x00,0x00,0x18,0xef} /* BKPT_SWI from */ - -/* 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 - -/* Nonzero if instruction at PC is a return instruction. */ - -#define ABOUT_TO_RETURN(pc) \ - ((read_memory_integer(pc, 4) & 0x0fffffff == 0x01b0f00e) || \ - (read_memory_integer(pc, 4) & 0x0ffff800 == 0x09eba800)) - -/* Return 1 if P points to an invalid floating point value. - LEN is the length in bytes. */ - -#define INVALID_FLOAT(p, len) 0 - -/* code to execute to print interesting information about the - * floating point processor (if any) - * No need to define if there is nothing to do. - */ -#define FLOAT_INFO { arm_float_info (); } - -/* Say how long (ordinary) registers are. */ - -#define REGISTER_TYPE long - -/* Number of machine registers */ - -/* Note: I make a fake copy of the pc in register 25 (calling it ps) so - that I can clear the status bits from pc (register 15) */ - -#define NUM_REGS 26 - -/* Initializer for an array of names of registers. - There should be NUM_REGS strings in this initializer. */ - -#define REGISTER_NAMES \ - { "a1", "a2", "a3", "a4", \ - "v1", "v2", "v3", "v4", "v5", "v6", \ - "sl", "fp", "ip", "sp", "lr", "pc", \ - "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "fps", "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 11 -#define FP_REGNUM 11 /* Contains address of executing stack frame */ -#define SP_REGNUM 13 /* Contains address of top of stack */ -#define LR_REGNUM 14 /* address to return to from a function call */ -#define PC_REGNUM 15 /* Contains program counter */ -#define F0_REGNUM 16 /* first floating point register */ -#define FPS_REGNUM 24 /* floating point status register */ -#define PS_REGNUM 25 /* Contains processor status */ - - -/* Total amount of space needed to store our copies of the machine's - register state, the array `registers'. */ -#define REGISTER_BYTES (16*4 + 12*8 + 4 + 4) - -/* Index within `registers' of the first byte of the space for - register N. */ - -#define REGISTER_BYTE(N) (((N) < F0_REGNUM) ? (N)*4 : \ - (((N) < PS_REGNUM) ? 16*4 + ((N) - 16)*12 : \ - 16*4 + 8*12 + ((N) - FPS_REGNUM) * 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) (((N) < F0_REGNUM || (N) >= FPS_REGNUM) ? 4 : 12) - -/* 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) (((N) < F0_REGNUM || (N) >= FPS_REGNUM) ? 4 : 8) - -/* Largest value REGISTER_RAW_SIZE can have. */ - -#define MAX_REGISTER_RAW_SIZE 12 - -/* 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. */ - -#define REGISTER_CONVERTIBLE(N) ((unsigned)(N) - F0_REGNUM < 8) - -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ - if (REGISTER_CONVERTIBLE(REGNUM)) \ - convert_from_extended((FROM), (TO)); \ - else \ - bcopy ((FROM), (TO), 4); - -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ - if (REGISTER_CONVERTIBLE(REGNUM)) \ - convert_to_extended((FROM), (TO)); \ - else \ - bcopy ((FROM), (TO), 4); - -/* Return the GDB type object for the "standard" data type - of data in register N. */ - -#define REGISTER_VIRTUAL_TYPE(N) \ - (((unsigned)(N) - F0_REGNUM) < 8 ? builtin_type_double : builtin_type_int) - -/* The system C compiler uses a similar structure return convention to gcc */ - -#define USE_STRUCT_CONVENTION(gcc_p, type) (TYPE_LENGTH (type) > 4) - -/* 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 (0, (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) \ - if (TYPE_CODE (TYPE) == TYPE_CODE_FLT) \ - convert_from_extended(REGBUF + REGISTER_BYTE (F0_REGNUM), VALBUF); \ - else \ - bcopy (REGBUF, VALBUF, TYPE_LENGTH (TYPE)) - -/* Write into appropriate registers a function return value - of type TYPE, given in virtual format. */ - -#define STORE_RETURN_VALUE(TYPE,VALBUF) \ - if (TYPE_CODE (TYPE) == TYPE_CODE_FLT) { \ - char _buf[MAX_REGISTER_RAW_SIZE]; \ - convert_to_extended(VALBUF, _buf); \ - write_register_bytes (REGISTER_BYTE (F0_REGNUM), _buf, MAX_REGISTER_RAW_SIZE); \ - } else \ - 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)) - -/* Specify that for the native compiler variables for a particular - lexical context are listed after the beginning LBRAC instead of - before in the executables list of symbols. */ -#define VARIABLES_INSIDE_BLOCK(desc, gcc_p) (!(gcc_p)) - - -/* 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. - - However, if FRAME_CHAIN_VALID returns zero, - it means the given frame is the outermost one and has no caller. */ - -/* In the case of the ARM, the frame's nominal address is the FP value, - and 12 bytes before comes the saved previous FP value as a 4-byte word. */ - -#define FRAME_CHAIN(thisframe) \ - ((thisframe)->pc >= first_object_file_end ? \ - read_memory_integer ((thisframe)->frame - 12, 4) :\ - 0) - -#define FRAME_CHAIN_VALID(chain, thisframe) \ - (chain != 0 && (FRAME_SAVED_PC (thisframe) >= first_object_file_end)) - -/* 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. */ -#define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \ -{ \ - CORE_ADDR func_start, after_prologue; \ - func_start = (get_pc_function_start ((FI)->pc) + \ - FUNCTION_START_OFFSET); \ - after_prologue = func_start; \ - SKIP_PROLOGUE (after_prologue); \ - (FRAMELESS) = (after_prologue == func_start); \ -} - -/* Saved Pc. */ - -#define FRAME_SAVED_PC(FRAME) \ - (read_memory_integer ((FRAME)->frame - 4, 4) & 0x03fffffc) - -#define FRAME_ARGS_ADDRESS(fi) (fi->frame) - -#define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame) - -/* Return number of args passed to a frame. - Can return -1, meaning no way to tell. */ - -#define FRAME_NUM_ARGS(numargs, fi) (numargs = -1) - -/* 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_FIND_SAVED_REGS(frame_info, frame_saved_regs) \ -{ \ - register int regnum; \ - register int frame; \ - register int next_addr; \ - register int return_data_save; \ - register int saved_register_mask; \ - bzero (&frame_saved_regs, sizeof frame_saved_regs); \ - frame = (frame_info)->frame; \ - return_data_save = read_memory_integer(frame, 4) & 0x03fffffc - 12; \ - saved_register_mask = \ - read_memory_integer(return_data_save, 4); \ - next_addr = frame - 12; \ - for (regnum = 4; regnum < 10; regnum++) \ - if (saved_register_mask & (1<= 4; regnum --) \ - sp = push_word(sp, read_register (regnum)); \ - write_register (FP_REGNUM, read_register (SP_REGNUM) - 8); \ - write_register (SP_REGNUM, sp); } - -/* Discard from the stack the innermost frame, restoring all registers. */ - -#define POP_FRAME \ -{ \ - register CORE_ADDR fp = read_register (FP_REGNUM); \ - register unsigned long return_data_save = \ - read_memory_integer ( (read_memory_integer (fp, 4) & \ - 0x03fffffc) - 12, 4); \ - register int regnum; \ - write_register (PS_REGNUM, read_memory_integer (fp - 4, 4)); \ - write_register (PC_REGNUM, read_register (PS_REGNUM) & 0x03fffffc); \ - write_register (SP_REGNUM, read_memory_integer (fp - 8, 4)); \ - write_register (FP_REGNUM, read_memory_integer (fp - 12, 4)); \ - fp -= 12; \ - for (regnum = 9; regnum >= 4; regnum--) \ - if (return_data_save & (1< 4) { \ - nargs_in_registers = min(nargs + 1, 4); \ - struct_return = 1; \ - } else \ - nargs_in_registers = min(nargs, 4); \ - *(char *) dummyname = (1 << nargs_in_registers) - 1 - struct_return; \ - *(int *)((char *) dummyname + 8) = \ - (((fun - (pc + 16)) / 4) & 0x00ffffff) | 0xeb000000; } diff --git a/gdb/tm-bigmips.h b/gdb/tm-bigmips.h deleted file mode 100644 index da134042cf1..00000000000 --- a/gdb/tm-bigmips.h +++ /dev/null @@ -1,21 +0,0 @@ -/* Copyright (C) 1990 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#define TARGET_BYTE_ORDER BIG_ENDIAN - -#include "tm-mips.h" diff --git a/gdb/tm-convex.h b/gdb/tm-convex.h deleted file mode 100644 index 1ada10b667d..00000000000 --- a/gdb/tm-convex.h +++ /dev/null @@ -1,557 +0,0 @@ -/* Definitions to make GDB run on Convex Unix (4bsd) - Copyright (C) 1989, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#define TARGET_BYTE_ORDER BIG_ENDIAN - -/* I don't know if this will work for cross-debugging, even if you do get - the right files. */ -/* Include certain files for dbxread.c */ -#include -#include -#include -#include - -/* Define this if the C compiler puts an underscore at the front - of external names before giving them to the linker. */ - -#define NAMES_HAVE_UNDERSCORE - -/* There is come problem with the debugging symbols generated by the - compiler such that the debugging symbol for the first line of a - function overlap with the function prologue. */ -#define PROLOGUE_FIRSTLINE_OVERLAP - -/* When convex pcc says CHAR or SHORT, it provides the correct address. */ - -#define BELIEVE_PCC_PROMOTION 1 - -/* Symbol types to ignore. */ -/* 0xc4 is N_MONPT. Use the numeric value for the benefit of people - with (rather) old OS's. */ -#define IGNORE_SYMBOL(TYPE) \ - (((TYPE) & ~N_EXT) == N_TBSS \ - || ((TYPE) & ~N_EXT) == N_TDATA \ - || ((TYPE) & ~N_EXT) == 0xc4) - -/* 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. - Convex prolog is: - [sub.w #-,sp] in one of 3 possible sizes - [mov psw,- fc/vc main program prolog - and #-,- (skip it because the "mov psw" saves the - mov -,psw] T bit, so continue gets a surprise trap) - [and #-,sp] fc/vc O2 main program prolog - [ld.- -(ap),-] pcc/gcc register arg loads -*/ - -#define SKIP_PROLOGUE(pc) \ -{ int op, ix; \ - op = read_memory_integer (pc, 2); \ - if ((op & 0xffc7) == 0x5ac0) pc += 2; \ - else if (op == 0x1580) pc += 4; \ - else if (op == 0x15c0) pc += 6; \ - if ((read_memory_integer (pc, 2) & 0xfff8) == 0x7c40 \ - && (read_memory_integer (pc + 2, 2) & 0xfff8) == 0x1240 \ - && (read_memory_integer (pc + 8, 2) & 0xfff8) == 0x7c48) \ - pc += 10; \ - if (read_memory_integer (pc, 2) == 0x1240) pc += 6; \ - for (;;) { \ - op = read_memory_integer (pc, 2); \ - ix = (op >> 3) & 7; \ - if (ix != 6) break; \ - if ((op & 0xfcc0) == 0x3000) pc += 4; \ - else if ((op & 0xfcc0) == 0x3040) pc += 6; \ - else if ((op & 0xfcc0) == 0x2800) pc += 4; \ - else if ((op & 0xfcc0) == 0x2840) pc += 6; \ - else break;}} - -/* Immediately after a function call, return the saved pc. - (ignore frame and return *$sp so we can handle both calls and callq) */ - -#define SAVED_PC_AFTER_CALL(frame) \ - read_memory_integer (read_register (SP_REGNUM), 4) - -/* Address of end of stack space. - This is ((USRSTACK + 0xfff) & -0x1000)) from but - that expression depends on the kernel version; instead, fetch a - page-zero pointer and get it from that. This will be invalid if - they ever change the way bkpt signals are delivered. */ - -#define STACK_END_ADDR (0xfffff000 & *(unsigned *) 0x80000050) - -/* User-mode traps push an extended rtn block, - then fault with one of the following PCs */ - -#define is_trace_pc(pc) ((unsigned) ((pc) - (*(int *) 0x80000040)) <= 4) -#define is_arith_pc(pc) ((unsigned) ((pc) - (*(int *) 0x80000044)) <= 4) -#define is_break_pc(pc) ((unsigned) ((pc) - (*(int *) 0x80000050)) <= 4) - -/* We need to manipulate trap bits in the psw */ - -#define PSW_TRAP_FLAGS 0x69670000 -#define PSW_T_BIT 0x08000000 -#define PSW_S_BIT 0x01000000 - -/* Stack grows downward. */ - -#define INNER_THAN < - -/* Sequence of bytes for breakpoint instruction. (bkpt) */ - -#define BREAKPOINT {0x7d,0x50} - -/* Amount PC must be decremented by after a breakpoint. - This is often the number of bytes in BREAKPOINT but not always. - (The break PC needs to be decremented by 2, but we do it when the - break frame is recognized and popped. That way gdb can tell breaks - from trace traps with certainty.) */ - -#define DECR_PC_AFTER_BREAK 0 - -/* Nonzero if instruction at PC is a return instruction. (rtn or rtnq) */ - -#define ABOUT_TO_RETURN(pc) \ - ((read_memory_integer (pc, 2) & 0xffe0) == 0x7c80) - -/* Return 1 if P points to an invalid floating point value. */ - -#define INVALID_FLOAT(p,len) 0 - -/* Say how long (ordinary) registers are. */ - -#define REGISTER_TYPE long long - -/* Number of machine registers */ - -#define NUM_REGS 26 - -/* Initializer for an array of names of registers. - There should be NUM_REGS strings in this initializer. */ - -#define REGISTER_NAMES {"pc","psw","fp","ap","a5","a4","a3","a2","a1","sp",\ - "s7","s6","s5","s4","s3","s2","s1","s0",\ - "S7","S6","S5","S4","S3","S2","S1","S0"} - -/* 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 S0_REGNUM 25 /* the real S regs */ -#define S7_REGNUM 18 -#define s0_REGNUM 17 /* low-order halves of S regs */ -#define s7_REGNUM 10 -#define SP_REGNUM 9 /* A regs */ -#define A1_REGNUM 8 -#define A5_REGNUM 4 -#define AP_REGNUM 3 -#define FP_REGNUM 2 /* Contains address of executing stack frame */ -#define PS_REGNUM 1 /* Contains processor status */ -#define PC_REGNUM 0 /* Contains program counter */ - -/* convert dbx stab register number (from `r' declaration) to a gdb REGNUM */ - -#define STAB_REG_TO_REGNUM(value) \ - ((value) < 8 ? S0_REGNUM - (value) : SP_REGNUM - ((value) - 8)) - -/* Vector register numbers, not handled as ordinary regs. - They are treated as convenience variables whose values are read - from the inferior when needed. */ - -#define V0_REGNUM 0 -#define V7_REGNUM 7 -#define VM_REGNUM 8 -#define VS_REGNUM 9 -#define VL_REGNUM 10 - -/* Total amount of space needed to store our copies of the machine's - register state, the array `registers'. */ -#define REGISTER_BYTES (4*10 + 8*8) - -/* Index within `registers' of the first byte of the space for - register N. - NB: must match structure of struct syscall_context for correct operation */ - -#define REGISTER_BYTE(N) ((N) < s7_REGNUM ? 4*(N) : \ - (N) < S7_REGNUM ? 44 + 8 * ((N)-s7_REGNUM) : \ - 40 + 8 * ((N)-S7_REGNUM)) - -/* Number of bytes of storage in the actual machine representation - for register N. */ - -#define REGISTER_RAW_SIZE(N) ((N) < S7_REGNUM ? 4 : 8) - -/* Number of bytes of storage in the program's representation - for register N. */ - -#define REGISTER_VIRTUAL_SIZE(N) REGISTER_RAW_SIZE(N) - -/* 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. */ - -#define REGISTER_CONVERTIBLE(N) 0 - -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ - bcopy ((FROM), (TO), REGISTER_RAW_SIZE (REGNUM)); - -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ - bcopy ((FROM), (TO), REGISTER_RAW_SIZE (REGNUM)); - -/* Return the GDB type object for the "standard" data type - of data in register N. */ - -#define REGISTER_VIRTUAL_TYPE(N) \ - ((N) < S7_REGNUM ? builtin_type_int : builtin_type_long_long) - -/* 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 (A1_REGNUM, (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) \ - bcopy (&((char *) REGBUF) [REGISTER_BYTE (S0_REGNUM) + \ - 8 - TYPE_LENGTH (TYPE)],\ - VALBUF, 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 (REGISTER_BYTE (S0_REGNUM), VALBUF, 8) - -/* 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 *) & ((char *) REGBUF) [REGISTER_BYTE (s0_REGNUM)]) - -/* Define trapped internal variable hooks to read and write - vector and communication registers. */ - -#define IS_TRAPPED_INTERNALVAR is_trapped_internalvar -#define VALUE_OF_TRAPPED_INTERNALVAR value_of_trapped_internalvar -#define SET_TRAPPED_INTERNALVAR set_trapped_internalvar - -extern struct value *value_of_trapped_internalvar (); - -/* Hooks to read data from soff exec and core files, - and to describe the files. */ - -#define XFER_CORE_FILE -#define FILES_INFO_HOOK print_maps - -/* Hook to call to print a typeless integer value, normally printed in decimal. - For convex, use hex instead if the number looks like an address. */ - -#define PRINT_TYPELESS_INTEGER decout - -/* For the native compiler, variables for a particular lexical context - are listed after the beginning LBRAC instead of before in the - executables list of symbols. Using "gcc_compiled." to distinguish - between GCC and native compiler doesn't work on Convex because the - linker sorts the symbols to put "gcc_compiled." in the wrong place. - desc is nonzero for native, zero for gcc. */ -#define VARIABLES_INSIDE_BLOCK(desc, gcc_p) (desc != 0) - -/* Pcc occaisionally puts an SO where there should be an SOL. */ -#define PCC_SOL_BROKEN - -/* Describe the pointer in each stack frame to the previous stack frame - (its caller). */ - -/* FRAME_CHAIN takes a frame_info with a frame's nominal address in fi->frame, - and produces the frame's chain-pointer. - - However, if FRAME_CHAIN_VALID returns zero, - it means the given frame is the outermost one and has no caller. */ - -/* (caller fp is saved at 8(fp)) */ - -#define FRAME_CHAIN(fi) (read_memory_integer ((fi)->frame + 8, 4)) - -#define FRAME_CHAIN_VALID(chain, thisframe) \ - (chain != 0 && (outside_startup_file (FRAME_SAVED_PC (thisframe)))) - -/* Define other aspects of the stack frame. */ - -/* We need the boundaries of the text in the exec file, as a kludge, - for FRAMELESS_FUNCTION_INVOCATION and CALL_DUMMY_LOCATION. */ - -#define NEED_TEXT_START_END - -/* 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 convex, check at the return address for `callq' -- if so, frameless, - otherwise, not. */ - -#define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \ -{ \ - extern CORE_ADDR text_start, text_end; \ - CORE_ADDR call_addr = SAVED_PC_AFTER_CALL (FI); \ - (FRAMELESS) = (call_addr >= text_start && call_addr < text_end \ - && read_memory_integer (call_addr - 6, 1) == 0x22); \ -} - -#define FRAME_SAVED_PC(fi) (read_memory_integer ((fi)->frame, 4)) - -#define FRAME_ARGS_ADDRESS(fi) (read_memory_integer ((fi)->frame + 12, 4)) - -#define FRAME_LOCALS_ADDRESS(fi) (fi)->frame - -/* Return number of args passed to a frame. - Can return -1, meaning no way to tell. */ - -#define FRAME_NUM_ARGS(numargs, fi) \ -{ numargs = read_memory_integer (FRAME_ARGS_ADDRESS (fi) - 4, 4); \ - if (numargs < 0 || numargs >= 256) numargs = -1;} - -/* 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. */ - -/* Normal (short) frames save only PC, FP, (callee's) AP. To reasonably - handle gcc and pcc register variables, scan the code following the - call for the instructions the compiler inserts to reload register - variables from stack slots and record the stack slots as the saved - locations of those registers. This will occasionally identify some - random load as a saved register; this is harmless. vc does not - declare its register allocation actions in the stabs. */ - -#define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \ -{ register int regnum; \ - register int frame_length = /* 3 short, 2 long, 1 extended, 0 context */\ - (read_memory_integer ((frame_info)->frame + 4, 4) >> 25) & 3; \ - register CORE_ADDR frame_fp = \ - read_memory_integer ((frame_info)->frame + 8, 4); \ - register CORE_ADDR next_addr; \ - bzero (&frame_saved_regs, sizeof frame_saved_regs); \ - (frame_saved_regs).regs[PC_REGNUM] = (frame_info)->frame + 0; \ - (frame_saved_regs).regs[PS_REGNUM] = (frame_info)->frame + 4; \ - (frame_saved_regs).regs[FP_REGNUM] = (frame_info)->frame + 8; \ - (frame_saved_regs).regs[AP_REGNUM] = frame_fp + 12; \ - next_addr = (frame_info)->frame + 12; \ - if (frame_length < 3) \ - for (regnum = A5_REGNUM; regnum < SP_REGNUM; ++regnum) \ - (frame_saved_regs).regs[regnum] = (next_addr += 4); \ - if (frame_length < 2) \ - (frame_saved_regs).regs[SP_REGNUM] = (next_addr += 4); \ - next_addr -= 4; \ - if (frame_length < 3) \ - for (regnum = S7_REGNUM; regnum < S0_REGNUM; ++regnum) \ - (frame_saved_regs).regs[regnum] = (next_addr += 8); \ - if (frame_length < 2) \ - (frame_saved_regs).regs[S0_REGNUM] = (next_addr += 8); \ - else \ - (frame_saved_regs).regs[SP_REGNUM] = next_addr + 8; \ - if (frame_length == 3) { \ - CORE_ADDR pc = read_memory_integer ((frame_info)->frame, 4); \ - int op, ix, disp; \ - op = read_memory_integer (pc, 2); \ - if ((op & 0xffc7) == 0x1480) pc += 4; /* add.w #-,sp */ \ - else if ((op & 0xffc7) == 0x58c0) pc += 2; /* add.w #-,sp */ \ - op = read_memory_integer (pc, 2); \ - if ((op & 0xffc7) == 0x2a06) pc += 4; /* ld.w -,ap */ \ - for (;;) { \ - op = read_memory_integer (pc, 2); \ - ix = (op >> 3) & 7; \ - if ((op & 0xfcc0) == 0x2800) { /* ld.- -,ak */ \ - regnum = SP_REGNUM - (op & 7); \ - disp = read_memory_integer (pc + 2, 2); \ - pc += 4;} \ - else if ((op & 0xfcc0) == 0x2840) { /* ld.- -,ak */ \ - regnum = SP_REGNUM - (op & 7); \ - disp = read_memory_integer (pc + 2, 4); \ - pc += 6;} \ - if ((op & 0xfcc0) == 0x3000) { /* ld.- -,sk */ \ - regnum = S0_REGNUM - (op & 7); \ - disp = read_memory_integer (pc + 2, 2); \ - pc += 4;} \ - else if ((op & 0xfcc0) == 0x3040) { /* ld.- -,sk */ \ - regnum = S0_REGNUM - (op & 7); \ - disp = read_memory_integer (pc + 2, 4); \ - pc += 6;} \ - else if ((op & 0xff00) == 0x7100) { /* br crossjump */ \ - pc += 2 * (char) op; \ - continue;} \ - else if (op == 0x0140) { /* jmp crossjump */ \ - pc = read_memory_integer (pc + 2, 4); \ - continue;} \ - else break; \ - if ((frame_saved_regs).regs[regnum]) \ - break; \ - if (ix == 7) disp += frame_fp; \ - else if (ix == 6) disp += read_memory_integer (frame_fp + 12, 4); \ - else if (ix != 0) break; \ - (frame_saved_regs).regs[regnum] = \ - disp - 8 + (1 << ((op >> 8) & 3)); \ - if (regnum >= S7_REGNUM) \ - (frame_saved_regs).regs[regnum - S0_REGNUM + s0_REGNUM] = \ - disp - 4 + (1 << ((op >> 8) & 3)); \ - } \ - } \ -} - -/* Things needed for making the inferior call functions. */ - -#define CALL_DUMMY_LOCATION BEFORE_TEXT_END - -/* 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; \ - char buf[8]; \ - long word; \ - for (regnum = S0_REGNUM; regnum >= S7_REGNUM; --regnum) { \ - read_register_bytes (REGISTER_BYTE (regnum), buf, 8); \ - sp = push_bytes (sp, buf, 8);} \ - for (regnum = SP_REGNUM; regnum >= FP_REGNUM; --regnum) { \ - word = read_register (regnum); \ - sp = push_bytes (sp, &word, 4);} \ - word = (read_register (PS_REGNUM) &~ (3<<25)) | (1<<25); \ - sp = push_bytes (sp, &word, 4); \ - word = read_register (PC_REGNUM); \ - sp = push_bytes (sp, &word, 4); \ - write_register (SP_REGNUM, sp); \ - write_register (FP_REGNUM, sp); \ - write_register (AP_REGNUM, sp);} - -/* Discard from the stack the innermost frame, restoring all registers. */ - -#define POP_FRAME do {\ - register CORE_ADDR fp = read_register (FP_REGNUM); \ - register int regnum; \ - register int frame_length = /* 3 short, 2 long, 1 extended, 0 context */ \ - (read_memory_integer (fp + 4, 4) >> 25) & 3; \ - char buf[8]; \ - write_register (PC_REGNUM, read_memory_integer (fp, 4)); \ - write_register (PS_REGNUM, read_memory_integer (fp += 4, 4)); \ - write_register (FP_REGNUM, read_memory_integer (fp += 4, 4)); \ - write_register (AP_REGNUM, read_memory_integer (fp += 4, 4)); \ - if (frame_length < 3) \ - for (regnum = A5_REGNUM; regnum < SP_REGNUM; ++regnum) \ - write_register (regnum, read_memory_integer (fp += 4, 4)); \ - if (frame_length < 2) \ - write_register (SP_REGNUM, read_memory_integer (fp += 4, 4)); \ - fp -= 4; \ - if (frame_length < 3) \ - for (regnum = S7_REGNUM; regnum < S0_REGNUM; ++regnum) { \ - read_memory (fp += 8, buf, 8); \ - write_register_bytes (REGISTER_BYTE (regnum), buf, 8);} \ - if (frame_length < 2) { \ - read_memory (fp += 8, buf, 8); \ - write_register_bytes (REGISTER_BYTE (regnum), buf, 8);} \ - else write_register (SP_REGNUM, fp + 8); \ - flush_cached_frames (); \ - set_current_frame (create_new_frame (read_register (FP_REGNUM), \ - read_pc ())); \ -} while (0) - -/* This sequence of words is the instructions - mov sp,ap - pshea 69696969 - calls 32323232 - bkpt - Note this is 16 bytes. */ - -#define CALL_DUMMY {0x50860d4069696969LL,0x2140323232327d50LL} - -#define CALL_DUMMY_LENGTH 16 - -#define CALL_DUMMY_START_OFFSET 0 - -/* 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) \ -{ *(int *)((char *) dummyname + 4) = nargs; \ - *(int *)((char *) dummyname + 10) = fun; } - -/* Defs to read soff symbol tables, see dbxread.c */ - -#define NUMBER_OF_SYMBOLS ((long) opthdr.o_nsyms) -#define STRING_TABLE_OFFSET ((long) filehdr.h_strptr) -#define SYMBOL_TABLE_OFFSET ((long) opthdr.o_symptr) -#define STRING_TABLE_SIZE ((long) filehdr.h_strsiz) -#define SIZE_OF_TEXT_SEGMENT ((long) txthdr.s_size) -#define ENTRY_POINT ((long) opthdr.o_entry) - -#define READ_STRING_TABLE_SIZE(BUFFER) \ - (BUFFER = STRING_TABLE_SIZE) - -#define DECLARE_FILE_HEADERS \ - FILEHDR filehdr; \ - OPTHDR opthdr; \ - SCNHDR txthdr - -#define READ_FILE_HEADERS(DESC,NAME) \ -{ \ - int n; \ - val = myread (DESC, &filehdr, sizeof filehdr); \ - if (val < 0) \ - perror_with_name (NAME); \ - if (! IS_SOFF_MAGIC (filehdr.h_magic)) \ - error ("%s: not an executable file.", NAME); \ - lseek (DESC, 0L, 0); \ - if (myread (DESC, &filehdr, sizeof filehdr) < 0) \ - perror_with_name (NAME); \ - if (myread (DESC, &opthdr, filehdr.h_opthdr) <= 0) \ - perror_with_name (NAME); \ - for (n = 0; n < filehdr.h_nscns; n++) \ - { \ - if (myread (DESC, &txthdr, sizeof txthdr) < 0) \ - perror_with_name (NAME); \ - if ((txthdr.s_flags & S_TYPMASK) == S_TEXT) \ - break; \ - } \ -} diff --git a/gdb/tm-delta88.h b/gdb/tm-delta88.h deleted file mode 100644 index 7474b3e3708..00000000000 --- a/gdb/tm-delta88.h +++ /dev/null @@ -1,27 +0,0 @@ -/* Target machine description for Motorola Delta 88 box, for GDB. - Copyright 1986, 1987, 1988, 1989, 1990, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include "tm-m88k.h" - -/* BCS is a standard for binary compatibility. This machine uses it. */ -#if !defined (BCS) -#define BCS 1 -#endif - -#define DELTA88 diff --git a/gdb/tm-hp300bsd.h b/gdb/tm-hp300bsd.h deleted file mode 100644 index 4edcbd3a80a..00000000000 --- a/gdb/tm-hp300bsd.h +++ /dev/null @@ -1,55 +0,0 @@ -/* Parameters for target machine Hewlett-Packard 9000/300, running bsd. - Copyright (C) 1986, 1987, 1989, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - * Configuration file for HP9000/300 series machine running - * University of Utah's 4.3bsd port. This is NOT for HP-UX. - * Problems to hpbsd-bugs@cs.utah.edu - */ - -#define HAVE_68881 - -/* Define BPT_VECTOR if it is different than the default. - This is the vector number used by traps to indicate a breakpoint. */ - -#define BPT_VECTOR 0x2 - -/* Define this if the C compiler puts an underscore at the front - of external names before giving them to the linker. */ - -#define NAMES_HAVE_UNDERSCORE - -#define TARGET_NBPG 4096 -#define TARGET_UPAGES 3 - -/* On the HP300, sigtramp is in the u area. Gak! User struct is not - mapped to the same virtual address in user/kernel address space - (hence STACK_END_ADDR as opposed to KERNEL_U_ADDR). This tests - for the whole u area, since we don't necessarily have hp300bsd - include files around. */ -#define IN_SIGTRAMP(pc, name) \ - ((pc) >= STACK_END_ADDR \ - && (pc) < STACK_END_ADDR + TARGET_UPAGES * TARGET_NBPG \ - ) - -/* Address of end of stack space. */ - -#define STACK_END_ADDR 0xfff00000 - -#include "tm-68k.h" diff --git a/gdb/tm-hp300hpux.h b/gdb/tm-hp300hpux.h deleted file mode 100644 index f1926a148d2..00000000000 --- a/gdb/tm-hp300hpux.h +++ /dev/null @@ -1,36 +0,0 @@ -/* Parameters for execution on an HP 9000 model 320, for GDB, the GNU debugger. - Copyright (C) 1986, 1987, 1989, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include HAVE_68881 - -/* Define BPT_VECTOR if it is different than the default. - This is the vector number used by traps to indicate a breakpoint. */ - -#define BPT_VECTOR 0x1 - -/* Define this if the C compiler puts an underscore at the front - of external names before giving them to the linker. */ - -#define NAMES_HAVE_UNDERSCORE - -/* Address of end of stack space. */ - -#define STACK_END_ADDR 0xFFF00000 - -#include "tm-68k.h" diff --git a/gdb/tm-i386v-g.h b/gdb/tm-i386v-g.h deleted file mode 100644 index 669284a32b7..00000000000 --- a/gdb/tm-i386v-g.h +++ /dev/null @@ -1,32 +0,0 @@ -/* Macro definitions for i386 using the GNU object file format. - Copyright (C) 1986, 1987, 1989, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - * Changes for 80386 by Pace Willisson (pace@prep.ai.mit.edu) - * July 1988 - * - * i386gnu: COFF_ENCAPSULATE - */ - - -#define COFF_ENCAPSULATE - -#include "tm-i386v.h" - -#define NAMES_HAVE_UNDERSCORE diff --git a/gdb/tm-i386v.h b/gdb/tm-i386v.h deleted file mode 100644 index 409cc535ffc..00000000000 --- a/gdb/tm-i386v.h +++ /dev/null @@ -1,299 +0,0 @@ -/* Macro defintions for i386. - Copyright (C) 1986, 1987, 1989, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - * Changes for 80386 by Pace Willisson (pace@prep.ai.mit.edu) - * July 1988 - */ - -#define TARGET_BYTE_ORDER LITTLE_ENDIAN - -/* define this if you don't have the extension to coff that allows - * file names to appear in the string table - * (aux.x_file.x_foff) - */ -#define COFF_NO_LONG_FILE_NAMES - -/* turn this on when rest of gdb is ready */ -#define IEEE_FLOAT - -/* Define this if the C compiler puts an underscore at the front - of external names before giving them to the linker. */ - -/* #define NAMES_HAVE_UNDERSCORE */ - -/* 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 4 - -/* 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(frompc) {(frompc) = i386_skip_prologue((frompc));} - -/* 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) \ - (read_memory_integer (read_register (SP_REGNUM), 4)) - -/* Address of end of stack space. */ - -#define STACK_END_ADDR 0x80000000 - -/* Stack grows downward. */ - -#define INNER_THAN < - -/* Sequence of bytes for breakpoint instruction. */ - -#define BREAKPOINT {0xcc} - -/* 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 1 - -/* Nonzero if instruction at PC is a return instruction. */ - -#define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 1) == 0xc3) - -/* Return 1 if P points to an invalid floating point value. - LEN is the length in bytes -- not relevant on the 386. */ - -#define INVALID_FLOAT(p, len) (0) - -#if 0 -/* code to execute to print interesting information about the - floating point processor (if any) - No need to define if there is nothing to do. - On the 386, unfortunately this code is host-dependent (and lives - in the i386-xdep.c file), so we can't - do this unless we *know* we aren't cross-debugging. FIXME. - */ -#define FLOAT_INFO { i386_float_info (); } -#endif /*0*/ - -/* Say how long (ordinary) registers are. */ - -#define REGISTER_TYPE long - -/* Number of machine registers */ - -#define NUM_REGS 16 - -/* Initializer for an array of names of registers. - There should be NUM_REGS strings in this initializer. */ - -/* the order of the first 8 registers must match the compiler's - * numbering scheme (which is the same as the 386 scheme) - * also, this table must match regmap in i386-pinsn.c. - */ -#define REGISTER_NAMES { "eax", "ecx", "edx", "ebx", \ - "esp", "ebp", "esi", "edi", \ - "eip", "ps", "cs", "ss", \ - "ds", "es", "fs", "gs", \ - } - -/* 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 FP_REGNUM 5 /* Contains address of executing stack frame */ -#define SP_REGNUM 4 /* Contains address of top of stack */ - -#define PC_REGNUM 8 -#define PS_REGNUM 9 - -/* Total amount of space needed to store our copies of the machine's - register state, the array `registers'. */ -#define REGISTER_BYTES (NUM_REGS * 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. */ - -#define REGISTER_RAW_SIZE(N) (4) - -/* Number of bytes of storage in the program's representation - for register N. */ - -#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 - -/* Nonzero if register N requires conversion - from raw format to virtual format. */ - -#define REGISTER_CONVERTIBLE(N) (0) - -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) {bcopy ((FROM), (TO), 4);} - -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) {bcopy ((FROM), (TO), 4);} - -/* Return the GDB type object for the "standard" data type - of data in register N. */ -/* Perhaps si and di should go here, but potentially they could be - used for things other than address. */ -#define REGISTER_VIRTUAL_TYPE(N) \ - ((N) == PC_REGNUM || (N) == FP_REGNUM || (N) == SP_REGNUM ? \ - lookup_pointer_type (builtin_type_void) : 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) \ - { (SP) -= sizeof (ADDR); \ - write_memory ((SP), &(ADDR), sizeof (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) \ - bcopy (REGBUF, VALBUF, 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. - - However, if FRAME_CHAIN_VALID returns zero, - it means the given frame is the outermost one and has no caller. */ - -#define FRAME_CHAIN(thisframe) \ - (outside_startup_file ((thisframe)->pc) ? \ - read_memory_integer ((thisframe)->frame, 4) :\ - 0) - -#define FRAME_CHAIN_VALID(chain, thisframe) \ - (chain != 0 && (outside_startup_file (FRAME_SAVED_PC (thisframe)))) - -/* 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. */ -#define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \ - (FRAMELESS) = frameless_look_for_prologue(FI) - -#define FRAME_SAVED_PC(FRAME) (read_memory_integer ((FRAME)->frame + 4, 4)) - -#define FRAME_ARGS_ADDRESS(fi) ((fi)->frame) - -#define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame) - -/* Return number of args passed to a frame. - Can return -1, meaning no way to tell. */ - -#define FRAME_NUM_ARGS(numargs, fi) (numargs) = i386_frame_num_args(fi) - -/* Return number of bytes at start of arglist that are not really args. */ - -#define FRAME_ARGS_SKIP 8 - -/* 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) \ -{ i386_frame_find_saved_regs ((frame_info), &(frame_saved_regs)); } - - -/* Things needed for making the inferior call functions. */ - -/* Push an empty stack frame, to record the current PC, etc. */ - -#define PUSH_DUMMY_FRAME { i386_push_dummy_frame (); } - -/* Discard from the stack the innermost frame, restoring all registers. */ - -#define POP_FRAME { i386_pop_frame (); } - -/* this is - * call 11223344 (32 bit relative) - * int3 - */ - -#define CALL_DUMMY { 0x223344e8, 0xcc11 } - -#define CALL_DUMMY_LENGTH 8 - -#define CALL_DUMMY_START_OFFSET 0 /* Start execution at beginning of dummy */ - -/* 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) \ -{ \ - int from, to, delta, loc; \ - loc = (int)(read_register (SP_REGNUM) - CALL_DUMMY_LENGTH); \ - from = loc + 5; \ - to = (int)(fun); \ - delta = to - from; \ - *((char *)(dummyname) + 1) = (delta & 0xff); \ - *((char *)(dummyname) + 2) = ((delta >> 8) & 0xff); \ - *((char *)(dummyname) + 3) = ((delta >> 16) & 0xff); \ - *((char *)(dummyname) + 4) = ((delta >> 24) & 0xff); \ -} diff --git a/gdb/tm-i960.h b/gdb/tm-i960.h deleted file mode 100644 index 7dba1dec15d..00000000000 --- a/gdb/tm-i960.h +++ /dev/null @@ -1,394 +0,0 @@ -/* Parameters for target machine Intel 960, for GDB, the GNU debugger. - Copyright (C) 1990-1991 Free Software Foundation, Inc. - Contributed by Intel Corporation. -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Definitions to target GDB to any i960. */ - -#ifndef I80960 -#define I80960 -#endif - -/* Hook for the SYMBOL_CLASS of a parameter when decoding DBX symbol - information. In the i960, parameters can be stored as locals or as - args, depending on the type of the debug record. - - From empirical observation, gcc960 uses N_LSYM to indicate - arguments passed in registers and then copied immediately - to the frame, and N_PSYM to indicate arguments passed in a - g14-relative argument block. */ - -#define DBX_PARM_SYMBOL_CLASS(type) ((type == N_LSYM)? LOC_LOCAL_ARG: LOC_ARG) - -/* Byte order is configurable, but this machine runs little-endian. */ -#define TARGET_BYTE_ORDER LITTLE_ENDIAN - -/* We have IEEE floating point, if we have any float at all. */ - -#define IEEE_FLOAT - -/* Define this if the C compiler puts an underscore at the front - of external names before giving them to the linker. */ - -#define NAMES_HAVE_UNDERSCORE - - -/* Offset from address of function to start of its code. - Zero on most machines. */ - -#define FUNCTION_START_OFFSET 0 - -/* Advance ip across any function entry prologue instructions - to reach some "real" code. */ - -#define SKIP_PROLOGUE(ip) { ip = skip_prologue (ip); } -extern CORE_ADDR skip_prologue (); - -/* Immediately after a function call, return the saved ip. - 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) (saved_pc_after_call (frame)) -extern CORE_ADDR saved_pc_after_call (); - -/* Stack grows upward */ - -#define INNER_THAN > - -/* Nonzero if instruction at ip is a return instruction. */ - -#define ABOUT_TO_RETURN(ip) (read_memory_integer(ip,4) == 0x0a000000) - -/* Return 1 if P points to an invalid floating point value. - LEN is the length in bytes. */ - -#define INVALID_FLOAT(p, len) (0) - -/* How long (ordinary) registers are */ - -#define REGISTER_TYPE long - -/* Number of machine registers */ -#define NUM_REGS 40 - -/* Initializer for an array of names of registers. - There should be NUM_REGS strings in this initializer. */ - -#define REGISTER_NAMES { \ - /* 0 */ "pfp", "sp", "rip", "r3", "r4", "r5", "r6", "r7", \ - /* 8 */ "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",\ - /* 16 */ "g0", "g1", "g2", "g3", "g4", "g5", "g6", "g7", \ - /* 24 */ "g8", "g9", "g10", "g11", "g12", "g13", "g14", "fp", \ - /* 32 */ "pc", "ac", "ip", "tc", "fp0", "fp1", "fp2", "fp3", \ -} - -/* Register numbers of various important registers (used to index - into arrays of register names and register values). */ - -#define R0_REGNUM 0 /* First local register */ -#define SP_REGNUM 1 /* Contains address of top of stack */ -#define RIP_REGNUM 2 /* Return instruction pointer (local r2) */ -#define R15_REGNUM 15 /* Last local register */ -#define G0_REGNUM 16 /* First global register */ -#define G13_REGNUM 29 /* g13 - holds struct return address */ -#define G14_REGNUM 30 /* g14 - ptr to arg block / leafproc return address */ -#define FP_REGNUM 31 /* Contains address of executing stack frame */ -#define PCW_REGNUM 32 /* process control word */ -#define ACW_REGNUM 33 /* arithmetic control word */ -#define IP_REGNUM 34 /* instruction pointer */ -#define TCW_REGNUM 35 /* trace control word */ -#define FP0_REGNUM 36 /* First floating point register */ - -/* Some registers have more than one name */ - -#define PC_REGNUM IP_REGNUM /* GDB refers to ip as the Program Counter */ -#define PFP_REGNUM R0_REGNUM /* Previous frame pointer */ - -/* Total amount of space needed to store our copies of the machine's - register state, the array `registers'. */ -#define REGISTER_BYTES ((36*4) + (4*10)) - -/* Index within `registers' of the first byte of the space for register N. */ - -#define REGISTER_BYTE(N) ( (N) < FP0_REGNUM ? \ - (4*(N)) : ((10*(N)) - (6*FP0_REGNUM)) ) - -/* The i960 has register windows, sort of. */ - -#define HAVE_REGISTER_WINDOWS - -/* 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). */ - -#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 - point, which are 10. NINDY only sends us 8 byte values for these, - which is a pain, but VxWorks handles this correctly, so we must. */ - -#define REGISTER_RAW_SIZE(N) ( (N) < FP0_REGNUM ? 4 : 10 ) - -/* Number of bytes of storage in the program's representation for register N. */ - -#define REGISTER_VIRTUAL_SIZE(N) ( (N) < FP0_REGNUM ? 4 : 8 ) - -/* Largest value REGISTER_RAW_SIZE can have. */ - -#define MAX_REGISTER_RAW_SIZE 10 - -/* 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. */ - -#define REGISTER_CONVERTIBLE(N) ((N) >= FP0_REGNUM) - -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ -{ \ - extern struct ext_format ext_format_i960; \ - \ - if ((REGNUM) >= FP0_REGNUM) \ - ieee_extended_to_double (&ext_format_i960, (FROM), (double *)(TO)); \ - else \ - bcopy ((FROM), (TO), 4); \ -} - -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ -{ \ - extern struct ext_format ext_format_i960; \ - \ - if ((REGNUM) >= FP0_REGNUM) \ - double_to_ieee_extended (&ext_format_i960, (double *)(FROM), (TO)); \ - else \ - bcopy ((FROM), (TO), 4); \ -} - - -/* Return the GDB type object for the "standard" data type - of data in register N. */ - -#define REGISTER_VIRTUAL_TYPE(N) ((N) < FP0_REGNUM ? \ - builtin_type_int : builtin_type_double) - -/* Macros for understanding function return values... */ - -/* Does the specified function use the "struct returning" convention - or the "value returning" convention? The "value returning" convention - almost invariably returns the entire value in registers. The - "struct returning" convention often returns the entire value in - memory, and passes a pointer (out of or into the function) saying - where the value (is or should go). - - Since this sometimes depends on whether it was compiled with GCC, - this is also an argument. This is used in call_function to build a - stack, and in value_being_returned to print return values. - - On i960, a structure is returned in registers g0-g3, if it will fit. - If it's more than 16 bytes long, g13 pointed to it on entry. */ - -#define USE_STRUCT_CONVENTION(gcc_p, type) (TYPE_LENGTH (type) > 16) - -/* 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. This is only called if USE_STRUCT_CONVENTION for this - type is 0. - - On the i960 we just take as many bytes as we need from G0 through G3. */ - -#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \ - bcopy(REGBUF+REGISTER_BYTE(G0_REGNUM), VALBUF, TYPE_LENGTH (TYPE)) - -/* If USE_STRUCT_CONVENTION produces a 1, - 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). - - Address of where to put structure was passed in in global - register g13 on entry. God knows what's in g13 now. The - (..., 0) below is to make it appear to return a value, though - actually all it does is call error(). */ - -#define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) \ - (error("Don't know where large structure is returned on i960"), 0) - -/* Write into appropriate registers a function return value - of type TYPE, given in virtual format, for "value returning" functions. - - For 'return' command: not (yet) implemented for i960. */ - -#define STORE_RETURN_VALUE(TYPE,VALBUF) \ - error ("Returning values from functions is not implemented in i960 gdb") - -/* 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) \ - error ("Returning values from functions is not implemented in i960 gdb") - -/* 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. - - However, if FRAME_CHAIN_VALID returns zero, - it means the given frame is the outermost one and has no caller. */ - -/* We cache information about saved registers in the frame structure, - to save us from having to re-scan function prologues every time - a register in a non-current frame is accessed. */ - -#define EXTRA_FRAME_INFO \ - struct frame_saved_regs *fsr; \ - CORE_ADDR arg_pointer; - -/* Zero the frame_saved_regs pointer when the frame is initialized, - so that FRAME_FIND_SAVED_REGS () will know to allocate and - initialize a frame_saved_regs struct the first time it is called. - Set the arg_pointer to -1, which is not valid; 0 and other values - indicate real, cached values. */ - -#define INIT_EXTRA_FRAME_INFO(fromleaf, fi) \ - ((fi)->fsr = 0, (fi)->arg_pointer = -1) - -/* On the i960, we get the chain pointer by reading the PFP saved - on the stack and clearing the status bits. */ - -#define FRAME_CHAIN(thisframe) \ - (read_memory_integer (FRAME_FP(thisframe), 4) & ~0xf) - -/* FRAME_CHAIN_VALID returns zero if the given frame is the outermost one - and has no caller. - - On the i960, each various target system type must define FRAME_CHAIN_VALID, - since it differs between NINDY and VxWorks, the two currently supported - targets types. We leave it undefined here. */ - - -/* 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. */ - -#define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \ - { (FRAMELESS) = (leafproc_return ((FI)->pc) != 0); } - -/* Note that in the i960 architecture the return pointer is saved in the - *caller's* stack frame. - - Make sure to zero low-order bits because of bug in 960CA A-step part - (instruction addresses should always be word-aligned anyway). */ - -#define FRAME_SAVED_PC(frame) \ - ((read_memory_integer(FRAME_CHAIN(frame)+8,4)) & ~3) - -/* On the i960, FRAME_ARGS_ADDRESS should return the value of - g14 as passed into the frame, if known. We need a function for this. - We cache this value in the frame info if we've already looked it up. */ - -#define FRAME_ARGS_ADDRESS(fi) \ - (((fi)->arg_pointer != -1)? (fi)->arg_pointer: frame_args_address (fi, 0)) -extern CORE_ADDR frame_args_address (); /* i960-tdep.c */ - -/* This is the same except it should return 0 when - it does not really know where the args are, rather than guessing. - This value is not cached since it is only used infrequently. */ - -#define FRAME_ARGS_ADDRESS_CORRECT(fi) (frame_args_address (fi, 1)) - -#define FRAME_LOCALS_ADDRESS(fi) (fi)->frame - -/* Set NUMARGS to the number of args passed to a frame. - Can return -1, meaning no way to tell. */ - -#define FRAME_NUM_ARGS(numargs, fi) (numargs = -1) - -/* Return number of bytes at start of arglist that are not really args. */ - -#define FRAME_ARGS_SKIP 0 - -/* Produce the positions of the saved registers in a stack frame. */ - -#define FRAME_FIND_SAVED_REGS(frame_info_addr, sr) \ - frame_find_saved_regs (frame_info_addr, &sr) -extern void frame_find_saved_regs(); /* See i960-tdep.c */ - - -/* Print status when we get a random unexpected signal. We have more - kinds of signals than Unix does... */ - -#define PRINT_RANDOM_SIGNAL(stop_signal) print_fault (stop_signal) - -/* Things needed for making calls to functions in the inferior process */ - -/* Push an empty stack frame, to record the current ip, etc. - - Not (yet?) implemented for i960. */ - -#define PUSH_DUMMY_FRAME \ -error("Function calls into the inferior process are not supported on the i960") - -/* Discard from the stack the innermost frame, restoring all registers. */ - -#define POP_FRAME \ - pop_frame () - - -/* This sequence of words is the instructions - - callx 0x00000000 - fmark - */ - -/* #define CALL_DUMMY { 0x86003000, 0x00000000, 0x66003e00 } */ - -/* #define CALL_DUMMY_START_OFFSET 0 *//* Start execution at beginning of dummy */ - -/* Indicate that we don't support calling inferior child functions. */ - -#undef CALL_DUMMY - -/* Insert the specified number of args and function address - into a call sequence of the above form stored at 'dummyname'. - - Ignore arg count on i960. */ - -/* #define FIX_CALL_DUMMY(dummyname, fun, nargs) *(((int *)dummyname)+1) = fun */ - -#undef FIX_CALL_DUMMY - - -/* Interface definitions for kernel debugger KDB */ -/* (Not relevant to i960.) */ diff --git a/gdb/tm-irix3.h b/gdb/tm-irix3.h deleted file mode 100644 index f62a39e4419..00000000000 --- a/gdb/tm-irix3.h +++ /dev/null @@ -1,325 +0,0 @@ -/* Target machine description for SGI Iris under Irix, for GDB. - Copyright 1990, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#define TARGET_BYTE_ORDER BIG_ENDIAN - -/* Floating point is IEEE compliant */ -#define IEEE_FLOAT - -/* Define this if the C compiler puts an underscore at the front - of external names before giving them to the linker. */ - -/*#define NAMES_HAVE_UNDERSCORE*/ - -/* 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) pc = mips_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) read_register(RA_REGNUM) - -/* Are we currently handling a signal */ - -#define IN_SIGTRAMP(pc, name) in_sigtramp(pc, name) - -/* Address of end of stack space. */ - -#define STACK_END_ADDR (0x7ffff000) - -/* Stack grows downward. */ - -#define INNER_THAN < - -#define BREAKPOINT {0, 0x5, 0, 0xd} - -/* 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 - -/* Nonzero if instruction at PC is a return instruction. "j ra" on mips. */ - -#define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 4) == 0x3e00008) - -/* Return 1 if P points to an invalid floating point value. */ - -#define INVALID_FLOAT(p,l) isa_NAN(p,l) - -/* Say how long (all) registers are. */ - -#define REGISTER_TYPE long - -/* Number of machine registers */ - -#define NUM_REGS 71 - -/* Initializer for an array of names of registers. - There should be NUM_REGS strings in this initializer. */ - -#define REGISTER_NAMES \ - { "zero", "at", "v0", "v1", "a0", "a1", "a2", "a3", \ - "t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7", \ - "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", \ - "t8", "t9", "k0", "k1", "gp", "sp", "fp", "ra", \ - "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \ - "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", \ - "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23",\ - "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31",\ - "pc", "cause", "bad", "hi", "lo", "fsr", "fir" \ - } - -/* 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 SP_REGNUM 29 /* Contains address of top of stack */ -#define FP_REGNUM 30 /* Pseudo register that contains true address of executing stack frame */ -#define RA_REGNUM 31 /* Contains return address value */ -#define FP0_REGNUM 32 /* Floating point register 0 (single float) */ -#define PC_REGNUM 64 /* Contains program counter */ -#define PS_REGNUM 65 /* Contains processor status */ -#define HI_REGNUM 67 /* Multiple/divide temp */ -#define LO_REGNUM 68 /* ... */ -#define FCRCS_REGNUM 69 /* FP control/status */ -#define FCRIR_REGNUM 70 /* FP implementation/revision */ - -/* Define DO_REGISTERS_INFO() to do machine-specific formatting - of register dumps. */ - -#define DO_REGISTERS_INFO(_regnum, fp) mips_do_registers_info(_regnum, fp) - -/* Total amount of space needed to store our copies of the machine's - register state, the array `registers'. */ -#define REGISTER_BYTES (NUM_REGS*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 mips, 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 mips, 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 - -/* Nonzero if register N requires conversion - from raw format to virtual format. */ - -#define REGISTER_CONVERTIBLE(N) 0 - -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ - bcopy ((FROM), (TO), 4); - -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ - bcopy ((FROM), (TO), 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) \ - { sp = push_word(sp, 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. XXX floats */ - -#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \ - bcopy (REGBUF+REGISTER_BYTE (TYPE_CODE (TYPE) == TYPE_CODE_FLT ? FP0_REGNUM : 2), VALBUF, 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 (REGISTER_BYTE (TYPE_CODE (TYPE) == TYPE_CODE_FLT ? FP0_REGNUM : 2), 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+16)) - -/* Structures are returned by ref in extra arg0 */ -#define USE_STRUCT_CONVENTION(gcc_p, type) 1 - - -/* 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. - - However, if FRAME_CHAIN_VALID returns zero, - it means the given frame is the outermost one and has no caller. */ - -#define FRAME_CHAIN(thisframe) (FRAME_ADDR)mips_frame_chain(thisframe) - -#define FRAME_CHAIN_VALID(chain, thisframe) \ - (chain != 0 && (outside_startup_file (FRAME_SAVED_PC (thisframe)))) - -/* 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. */ -/* We handle this differently for mips, and maybe we should not */ - -#define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) {(FRAMELESS) = 0;} - -/* Saved Pc. */ - -#define FRAME_SAVED_PC(FRAME) (mips_frame_saved_pc(FRAME)) - -#define FRAME_ARGS_ADDRESS(fi) (fi)->frame - -#define FRAME_LOCALS_ADDRESS(fi) (fi)->frame - -/* Return number of args passed to a frame. - Can return -1, meaning no way to tell. */ - -#define FRAME_NUM_ARGS(num, fi) (num = mips_frame_num_args(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_FIND_SAVED_REGS(frame_info, frame_saved_regs) ( \ - (frame_saved_regs) = *(frame_info)->saved_regs, \ - (frame_saved_regs).regs[SP_REGNUM] = (frame_info)->frame) - - -/* Things needed for making the inferior call functions. */ - -/* Stack has strict alignment. However, use PUSH_ARGUMENTS - to take care of it. */ -/*#define STACK_ALIGN(addr) (((addr)+3)&~3)*/ - -#define PUSH_ARGUMENTS(nargs, args, sp, struct_return, struct_addr) \ - sp = mips_push_arguments(nargs, args, sp, struct_return, struct_addr) - -/* Push an empty stack frame, to record the current PC, etc. */ - -#define PUSH_DUMMY_FRAME mips_push_dummy_frame() - -/* Discard from the stack the innermost frame, restoring all registers. */ - -#define POP_FRAME mips_pop_frame() - -#define MK_OP(op,rs,rt,offset) (((op)<<26)|((rs)<<21)|((rt)<<16)|(offset)) -#define CALL_DUMMY_SIZE (16*4) -#define Dest_Reg 2 -#define CALL_DUMMY {\ - MK_OP(0,RA_REGNUM,0,8), /* jr $ra # Fake ABOUT_TO_RETURN ...*/\ - 0, /* nop # ... to stop raw backtrace*/\ - 0x27bd0000, /* addu sp,?0 # Pseudo prologue */\ -/* Start here: */\ - MK_OP(061,SP_REGNUM,12,0), /* lwc1 $f12,0(sp) # Reload first 4 args*/\ - MK_OP(061,SP_REGNUM,13,4), /* lwc1 $f13,4(sp) */\ - MK_OP(061,SP_REGNUM,14,8), /* lwc1 $f14,8(sp) */\ - MK_OP(061,SP_REGNUM,15,12), /* lwc1 $f15,12(sp) */\ - MK_OP(043,SP_REGNUM,4,0), /* lw $r4,0(sp) # Re-load FP regs*/\ - MK_OP(043,SP_REGNUM,5,4), /* lw $r5,4(sp) */\ - MK_OP(043,SP_REGNUM,6,8), /* lw $r6,8(sp) */\ - MK_OP(043,SP_REGNUM,7,12), /* lw $r7,12(sp) */\ - (017<<26)| (Dest_Reg << 16), /* lui $r31,*/\ - MK_OP(13,Dest_Reg,Dest_Reg,0), /* ori $r31,$r31,*/ \ - (Dest_Reg<<21) | (31<<11) | 9, /* jalr $r31 */\ - MK_OP(043,SP_REGNUM,7,12), /* lw $r7,12(sp) */\ - 0x5000d, /* bpt */\ -} - -#define CALL_DUMMY_START_OFFSET 12 - -/* 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, start_sp, fun, nargs, args, rettype, gcc_p)\ - (((int*)dummyname)[11] |= (((unsigned long)(fun)) >> 16), \ - ((int*)dummyname)[12] |= (unsigned short)(fun)) - -/* Specific information about a procedure. - This overlays the MIPS's PDR records, - mipsread.c (ab)uses this to save memory */ - -typedef struct mips_extra_func_info { - unsigned long adr; /* memory address of start of procedure */ - long isym; /* pointer to procedure symbol */ - long pad2; /* iline: start of line number entries*/ - long regmask; /* save register mask */ - long regoffset; /* save register offset */ - long numargs; /* number of args to procedure (was iopt) */ - long fregmask; /* save floating point register mask */ - long fregoffset; /* save floating point register offset */ - long framesize; /* frameoffset: frame size */ - short framereg; /* frame pointer register */ - short pcreg; /* offset or reg of return pc */ - long lnLow; /* lowest line in the procedure */ - long lnHigh; /* highest line in the procedure */ - long pad3; /* cbLineOffset: byte offset for this procedure from the fd base */ -} *mips_extra_func_info_t; - -#define EXTRA_FRAME_INFO \ - char *proc_desc; /* actually, a mips_extra_func_info_t */\ - int num_args;\ - struct frame_saved_regs *saved_regs; - -#define INIT_EXTRA_FRAME_INFO(fromleaf, fci) init_extra_frame_info(fci) diff --git a/gdb/tm-isi.h b/gdb/tm-isi.h deleted file mode 100644 index e4e64923a69..00000000000 --- a/gdb/tm-isi.h +++ /dev/null @@ -1,161 +0,0 @@ -/* Definitions to target GDB on an ISI Optimum V (3.05) under 4.3bsd. - Copyright (C) 1987, 1989, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* This has not been tested on ISI's running BSD 4.2, but it will probably - work. */ - -#define HAVE_68881 - -/* Define this if the C compiler puts an underscore at the front - of external names before giving them to the linker. */ - -#define NAMES_HAVE_UNDERSCORE - -/* Address of end of stack space. */ - -#define STACK_END_ADDR 0xfffe000 - -/* Data segment starts at etext rounded up to DATAROUND in {N,Z}MAGIC files */ - -#define DATAROUND 0x20000 -#define N_DATADDR(hdr) (hdr.a_magic != OMAGIC ? \ - (hdr.a_text + DATAROUND) & ~(DATAROUND-1) : hdr.a_text) - -/* Text segment starts at sizeof (struct exec) in {N,Z}MAGIC files */ - -#define N_TXTADDR(hdr) (hdr.a_magic != OMAGIC ? sizeof (struct exec) : 0) - -/* Amount PC must be decremented by after a breakpoint. - This is often the number of bytes in BREAKPOINT - but not always. - On the ISI, the kernel resets the pc to the trap instr */ - -#define DECR_PC_AFTER_BREAK 0 - - -/* Return number of args passed to a frame. - Can return -1, meaning no way to tell. */ - -#define FRAME_NUM_ARGS(val, fi) \ -{ register CORE_ADDR pc = FRAME_SAVED_PC (fi); \ - register int insn = 0177777 & read_memory_integer (pc, 2); \ - val = 0; \ - if (insn == 0047757 || insn == 0157374) /* lea W(sp),sp or addaw #W,sp */ \ - val = read_memory_integer (pc + 2, 2); \ - else if ((insn & 0170777) == 0050217 /* addql #N, sp */ \ - || (insn & 0170777) == 0050117) /* addqw */ \ - { val = (insn >> 9) & 7; if (val == 0) val = 8; } \ - else if (insn == 0157774) /* addal #WW, sp */ \ - val = read_memory_integer (pc + 2, 4); \ - val >>= 2; } - -/* 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; \ - register CORE_ADDR next_addr; \ - register CORE_ADDR pc; \ - register int insn; \ - register int offset; \ - bzero (&frame_saved_regs, sizeof frame_saved_regs); \ - if ((frame_info)->pc >= (frame_info)->frame - CALL_DUMMY_LENGTH - FP_REGNUM*4 - 8*12 - 4 \ - && (frame_info)->pc <= (frame_info)->frame) \ - { next_addr = (frame_info)->frame; \ - pc = (frame_info)->frame - CALL_DUMMY_LENGTH - FP_REGNUM * 4 - 8*12 - 4; }\ - else \ - { pc = get_pc_function_start ((frame_info)->pc); \ - /* Verify we have a link a6 instruction next, \ - or a branch followed by a link a6 instruction; \ - if not we lose. If we win, find the address above the saved \ - regs using the amount of storage from the link instruction. */\ -retry: \ - insn = read_memory_integer (pc, 2); \ - if (insn == 044016) \ - next_addr = (frame_info)->frame - read_memory_integer (pc += 2, 4), pc+=4; \ - else if (insn == 047126) \ - next_addr = (frame_info)->frame - read_memory_integer (pc += 2, 2), pc+=2; \ - else if ((insn & 0177400) == 060000) /* bra insn */ \ - { offset = insn & 0377; \ - pc += 2; /* advance past bra */ \ - if (offset == 0) /* bra #word */ \ - offset = read_memory_integer (pc, 2), pc += 2; \ - else if (offset == 0377) /* bra #long */ \ - offset = read_memory_integer (pc, 4), pc += 4; \ - pc += offset; \ - goto retry; \ - } else goto lose; \ - /* If have an addal #-n, sp next, adjust next_addr. */ \ - if ((0177777 & read_memory_integer (pc, 2)) == 0157774) \ - next_addr += read_memory_integer (pc += 2, 4), pc += 4; \ - } \ - /* next should be a moveml to (sp) or -(sp) or a movl r,-(sp) */ \ - insn = read_memory_integer (pc, 2), pc += 2; \ - regmask = read_memory_integer (pc, 2); \ - if ((insn & 0177760) == 022700) /* movl rn, (sp) */ \ - (frame_saved_regs).regs[(insn&7) + ((insn&010)?8:0)] = next_addr; \ - else if ((insn & 0177760) == 024700) /* movl rn, -(sp) */ \ - (frame_saved_regs).regs[(insn&7) + ((insn&010)?8:0)] = next_addr-=4; \ - else if (insn == 0044327) /* moveml mask, (sp) */ \ - { pc += 2; \ - /* Regmask's low bit is for register 0, the first written */ \ - next_addr -= 4; \ - for (regnum = 0; regnum < 16; regnum++, regmask >>= 1) \ - if (regmask & 1) \ - (frame_saved_regs).regs[regnum] = (next_addr += 4); \ - } else if (insn == 0044347) /* moveml mask, -(sp) */ \ - { pc += 2; \ - /* Regmask's low bit is for register 15, the first pushed */ \ - for (regnum = 15; regnum >= 0; regnum--, regmask >>= 1) \ - if (regmask & 1) \ - (frame_saved_regs).regs[regnum] = (next_addr -= 4); } \ - /* clrw -(sp); movw ccr,-(sp) may follow. */ \ - if (read_memory_integer (pc, 2) == 041147 \ - && read_memory_integer (pc+2, 2) == 042347) \ - (frame_saved_regs).regs[PS_REGNUM] = (next_addr -= 4); \ - lose: ; \ - (frame_saved_regs).regs[SP_REGNUM] = (frame_info)->frame + 8; \ - (frame_saved_regs).regs[FP_REGNUM] = (frame_info)->frame; \ - (frame_saved_regs).regs[PC_REGNUM] = (frame_info)->frame + 4; \ -} - -/* The only reason this is here is the tm-isi.h reference below. It - was moved back here from tm-68k.h. FIXME? */ - -#define SKIP_PROLOGUE(pc) \ -{ register int op = read_memory_integer (pc, 2); \ - if (op == 0047126) \ - pc += 4; /* Skip link #word */ \ - else if (op == 0044016) \ - pc += 6; /* Skip link #long */ \ - /* Not sure why branches are here. */ \ - /* From tm-isi.h, tm-altos.h */ \ - else if (op == 0060000) \ - pc += 4; /* Skip bra #word */ \ - else if (op == 00600377) \ - pc += 6; /* skip bra #long */ \ - else if ((op & 0177400) == 0060000) \ - pc += 2; /* skip bra #char */ \ -} - -#include "tm-68k.h" diff --git a/gdb/tm-m88k.h b/gdb/tm-m88k.h deleted file mode 100644 index f562f86f385..00000000000 --- a/gdb/tm-m88k.h +++ /dev/null @@ -1,400 +0,0 @@ -/* Target machine description for generic Motorola 88000, for GDB. - Copyright 1986, 1987, 1988, 1989, 1990, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* g++ support is not yet included. */ - -#define TARGET_BYTE_ORDER BIG_ENDIAN - -/* We cache information about saved registers in the frame structure, - to save us from having to re-scan function prologues every time - a register in a non-current frame is accessed. */ - -#define EXTRA_FRAME_INFO \ - struct frame_saved_regs *fsr; \ - CORE_ADDR locals_pointer; \ - CORE_ADDR args_pointer; - -/* Zero the frame_saved_regs pointer when the frame is initialized, - so that FRAME_FIND_SAVED_REGS () will know to allocate and - initialize a frame_saved_regs struct the first time it is called. - Set the arg_pointer to -1, which is not valid; 0 and other values - indicate real, cached values. */ - -#define INIT_EXTRA_FRAME_INFO(fromleaf, fi) \ - init_extra_frame_info (fromleaf, fi) -extern void init_extra_frame_info (); - -#define IEEE_FLOAT - -/* Define this if the C compiler puts an underscore at the front - of external names before giving them to the linker. */ - -#define NAMES_HAVE_UNDERSCORE - -/* 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(frompc) \ - skip_prologue (frompc) -extern CORE_ADDR skip_prologue (); - -/* The m88k kernel aligns all instructions on 4-byte boundaries. The - kernel also uses the least significant two bits for its own hocus - pocus. When gdb receives an address from the kernel, it needs to - preserve those right-most two bits, but gdb also needs to be careful - to realize that those two bits are not really a part of the address - of an instruction. Shrug. */ - -#define ADDR_BITS_REMOVE(addr) ((addr) & ~3) -#define ADDR_BITS_SET(addr) (((addr) | 0x00000002) - 4) - -/* 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) \ - (ADDR_BITS_REMOVE (read_register (SRP_REGNUM))) - -/* Stack grows downward. */ - -#define INNER_THAN < - -/* Sequence of bytes for breakpoint instruction. */ - -/* instruction 0xF000D1FF is 'tb0 0,r0,511' - If Bit bit 0 of r0 is clear (always true), - initiate exception processing (trap). - */ -#define BREAKPOINT {0xF0, 0x00, 0xD1, 0xFF} - -/* 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 - -/* Nonzero if instruction at PC is a return instruction. */ -/* 'jmp r1' or 'jmp.n r1' is used to return from a subroutine. */ - -#define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 2) == 0xF800) - -/* Return 1 if P points to an invalid floating point value. - LEN is the length in bytes. */ - -#define INVALID_FLOAT(p, len) IEEE_isNAN(p,len) - -/* Say how long (ordinary) registers are. */ - -#define REGISTER_TYPE long - -/* Number of machine registers */ - -#define NUM_REGS 38 - -/* 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",\ - "r12",\ - "r13",\ - "r14",\ - "r15",\ - "r16",\ - "r17",\ - "r18",\ - "r19",\ - "r20",\ - "r21",\ - "r22",\ - "r23",\ - "r24",\ - "r25",\ - "r26",\ - "r27",\ - "r28",\ - "r29",\ - "r30",\ - "r31",\ - "psr",\ - "fpsr",\ - "fpcr",\ - "sxip",\ - "snip",\ - "sfip",\ - "vbr",\ - "dmt0",\ - "dmd0",\ - "dma0",\ - "dmt1",\ - "dmd1",\ - "dma1",\ - "dmt2",\ - "dmd2",\ - "dma2",\ - "sr0",\ - "sr1",\ - "sr2",\ - "sr3",\ - "fpecr",\ - "fphs1",\ - "fpls1",\ - "fphs2",\ - "fpls2",\ - "fppt",\ - "fprh",\ - "fprl",\ - "fpit",\ - "fpsr",\ - "fpcr",\ - }; - - -/* 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 SRP_REGNUM 1 /* Contains subroutine return pointer */ -#define RV_REGNUM 2 /* Contains simple return values */ -#define SRA_REGNUM 12 /* Contains address of struct return values */ -#define FP_REGNUM 31 /* Reg fetched to locate frame when pgm stops */ -#define SP_REGNUM 31 /* Contains address of top of stack */ -#define SXIP_REGNUM 35 /* Contains Shadow Execute Instruction Pointer */ -#define SNIP_REGNUM 36 /* Contains Shadow Next Instruction Pointer */ -#define PC_REGNUM SXIP_REGNUM /* Program Counter */ -#define NPC_REGNUM SNIP_REGNUM /* Next Program Counter */ -#define PSR_REGNUM 32 /* Processor Status Register */ -#define FPSR_REGNUM 33 /* Floating Point Status Register */ -#define FPCR_REGNUM 34 /* Floating Point Control Register */ -#define SFIP_REGNUM 37 /* Contains Shadow Fetched Intruction pointer */ -#define NNPC_REGNUM SFIP_REGNUM /* Next Next Program Counter */ - -/* PSR status bit definitions. */ - -#define PSR_MODE 0x80000000 -#define PSR_BYTE_ORDER 0x40000000 -#define PSR_SERIAL_MODE 0x20000000 -#define PSR_CARRY 0x10000000 -#define PSR_SFU_DISABLE 0x000003f0 -#define PSR_SFU1_DISABLE 0x00000008 -#define PSR_MXM 0x00000004 -#define PSR_IND 0x00000002 -#define PSR_SFRZ 0x00000001 - -/* BCS requires that the SXIP_REGNUM (or PC_REGNUM) contain the address - of the next instr to be executed when a breakpoint occurs. Because - the kernel gets the next instr (SNIP_REGNUM), the instr in SNIP needs - to be put back into SFIP, and the instr in SXIP should be shifted - to SNIP */ - -/* Are you sitting down? It turns out that the 88K BCS (binary compatibility - standard) folks originally felt that the debugger should be responsible - for backing up the IPs, not the kernel (as is usually done). Well, they - have reversed their decision, and in future releases our kernel will be - handling the backing up of the IPs. So, eventually, we won't need to - do the SHIFT_INST_REGS stuff. But, for now, since there are 88K systems out - there that do need the debugger to do the IP shifting, and since there - will be systems where the kernel does the shifting, the code is a little - more complex than perhaps it needs to be (we still go inside SHIFT_INST_REGS, - and if the shifting hasn't occurred then gdb goes ahead and shifts). */ - -#define SHIFT_INST_REGS - -/* Total amount of space needed to store our copies of the machine's - register state, the array `registers'. */ - -#define REGISTER_BYTES (NUM_REGS * sizeof(REGISTER_TYPE)) - -/* Index within `registers' of the first byte of the space for - register N. */ - -#define REGISTER_BYTE(N) ((N)*sizeof(REGISTER_TYPE)) - -/* Number of bytes of storage in the actual machine representation - for register N. */ - -#define REGISTER_RAW_SIZE(N) (sizeof(REGISTER_TYPE)) - -/* Number of bytes of storage in the program's representation - for register N. */ - -#define REGISTER_VIRTUAL_SIZE(N) (sizeof(REGISTER_TYPE)) - -/* Largest value REGISTER_RAW_SIZE can have. */ - -#define MAX_REGISTER_RAW_SIZE (sizeof(REGISTER_TYPE)) - -/* Largest value REGISTER_VIRTUAL_SIZE can have. -/* Are FPS1, FPS2, FPR "virtual" regisers? */ - -#define MAX_REGISTER_VIRTUAL_SIZE (sizeof(REGISTER_TYPE)) - -/* Nonzero if register N requires conversion - from raw format to virtual format. */ - -#define REGISTER_CONVERTIBLE(N) (0) - -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) {bcopy ((FROM), (TO), (sizeof(REGISTER_TYPE)));} - -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) {bcopy ((FROM), (TO), (sizeof(REGISTER_TYPE)));} - -/* Return the GDB type object for the "standard" data type - of data in register N. */ - -#define REGISTER_VIRTUAL_TYPE(N) (builtin_type_int) - -/* The 88k call/return conventions call for "small" values to be returned - into consecutive registers starting from r2. */ - -#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \ - bcopy (&(((char *)REGBUF)[REGISTER_BYTE(RV_REGNUM)]), (VALBUF), TYPE_LENGTH (TYPE)) - -#define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF)) - -/* Write into appropriate registers a function return value - of type TYPE, given in virtual format. */ - -#define STORE_RETURN_VALUE(TYPE,VALBUF) \ - write_register_bytes (2*sizeof(void*), (VALBUF), TYPE_LENGTH (TYPE)) - -/* In COFF, if PCC says a parameter is a short or a char, do not - change it to int (it seems the convention is to change it). */ - -#define BELIEVE_PCC_PROMOTION 1 - -/* 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. - - However, if FRAME_CHAIN_VALID returns zero, - it means the given frame is the outermost one and has no caller. */ - -extern CORE_ADDR frame_chain (); -extern int frame_chain_valid (); -extern int frameless_function_invocation (); - -#define FRAME_CHAIN(thisframe) \ - frame_chain (thisframe) - -#define FRAME_CHAIN_VALID(chain, thisframe) \ - frame_chain_valid (chain, thisframe) - -#define FRAMELESS_FUNCTION_INVOCATION(frame, fromleaf) \ - fromleaf = frameless_function_invocation (frame) - -/* Define other aspects of the stack frame. */ - -#define FRAME_SAVED_PC(FRAME) \ - frame_saved_pc (FRAME) -extern CORE_ADDR frame_saved_pc (); - -#define FRAME_ARGS_ADDRESS(fi) \ - frame_args_address (fi) -extern CORE_ADDR frame_args_address (); - -#define FRAME_LOCALS_ADDRESS(fi) \ - frame_locals_address (fi) -extern CORE_ADDR frame_locals_address (); - -/* Return number of args passed to a frame. - Can return -1, meaning no way to tell. */ - -#define FRAME_NUM_ARGS(numargs, fi) ((numargs) = -1) - -/* 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. */ - -/* On the 88k, parameter registers get stored into the so called "homing" - area. This *always* happens when you compiled with GCC and use -g. - Also, (with GCC and -g) the saving of the parameter register values - always happens right within the function prologue code, so these register - values can generally be relied upon to be already copied into their - respective homing slots by the time you will normally try to look at - them (we hope). - - Note that homing area stack slots are always at *positive* offsets from - the frame pointer. Thus, the homing area stack slots for the parameter - registers (passed values) for a given function are actually part of the - frame area of the caller. This is unusual, but it should not present - any special problems for GDB. - - Note also that on the 88k, we are only interested in finding the - registers that might have been saved in memory. This is a subset of - the whole set of registers because the standard calling sequence allows - the called routine to clobber many registers. - - We could manage to locate values for all of the so called "preserved" - registers (some of which may get saved within any particular frame) but - that would require decoding all of the tdesc information. Tht would be - nice information for GDB to have, but it is not strictly manditory if we - can live without the ability to look at values within (or backup to) - previous frames. -*/ - -#define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \ - frame_find_saved_regs (frame_info, &frame_saved_regs) - - -/* There is not currently a functioning way to call functions in the - inferior. */ - -/* But if there was this is where we'd put the call dummy. */ -/* #define CALL_DUMMY_LOCATION AFTER_TEXT_END */ - -/* When popping a frame on the 88k (say when doing a return command), the - calling function only expects to have the "preserved" registers restored. - Thus, those are the only ones that we even try to restore here. */ - -#define POP_FRAME pop_frame () -extern void pop_frame (); diff --git a/gdb/tm-merlin.h b/gdb/tm-merlin.h deleted file mode 100644 index f782dd0ed64..00000000000 --- a/gdb/tm-merlin.h +++ /dev/null @@ -1,354 +0,0 @@ -/* Definitions to target GDB to a merlin under utek 2.1 - Copyright (C) 1986, 1987, 1989, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#define TARGET_BYTE_ORDER LITTLE_ENDIAN - -/* I don't know if this will work for cross-debugging, even if you do get - a copy of the right include file. */ -#include - -/* Define this if the C compiler puts an underscore at the front - of external names before giving them to the linker. */ - -#define NAMES_HAVE_UNDERSCORE - -/* 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) \ -{ register int op = read_memory_integer (pc, 1); \ - if (op == 0x82) \ - { op = read_memory_integer (pc+2,1); \ - if ((op & 0x80) == 0) pc += 3; \ - else if ((op & 0xc0) == 0x80) pc += 4; \ - else pc += 6; \ - }} - -/* 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) \ - read_memory_integer (read_register (SP_REGNUM), 4) - -/* Address of end of stack space. */ - -#define STACK_END_ADDR (0x800000) - -/* Stack grows downward. */ - -#define INNER_THAN < - -/* Sequence of bytes for breakpoint instruction. */ - -#define BREAKPOINT {0xf2} - -/* 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 - -/* Nonzero if instruction at PC is a return instruction. */ - -#define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 1) == 0x12) - -/* Return 1 if P points to an invalid floating point value. */ - -#define INVALID_FLOAT(p, len) 0 - -/* Define this to say that the "svc" insn is followed by - codes in memory saying which kind of system call it is. */ - -#define NS32K_SVC_IMMED_OPERANDS - -/* Say how long (ordinary) registers are. */ - -#define REGISTER_TYPE long - -/* Number of machine registers */ - -#define NUM_REGS 25 - -#define NUM_GENERAL_REGS 8 - -/* 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", \ - "pc", "sp", "fp", "ps", \ - "fsr", \ - "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \ - "l0", "l1", "l2", "l3", "l4", \ - } - -/* 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 FP_REGNUM -#define FP_REGNUM 10 /* Contains address of executing stack frame */ -#define SP_REGNUM 9 /* Contains address of top of stack */ -#define PC_REGNUM 8 /* Contains program counter */ -#define PS_REGNUM 11 /* Contains processor status */ -#define FPS_REGNUM 12 /* Floating point status register */ -#define FP0_REGNUM 13 /* Floating point register 0 */ -#define LP0_REGNUM 21 /* Double register 0 (same as FP0) */ - -/* Total amount of space needed to store our copies of the machine's - register state, the array `registers'. */ -#define REGISTER_BYTES ((NUM_REGS - 4) * sizeof (int) + 4 * sizeof (double)) - -/* Index within `registers' of the first byte of the space for - register N. */ - -#define REGISTER_BYTE(N) ((N) >= LP0_REGNUM ? \ - LP0_REGNUM * 4 + ((N) - LP0_REGNUM) * 8 : (N) * 4) - -/* Number of bytes of storage in the actual machine representation - for register N. On the 32000, all regs are 4 bytes - except for the doubled floating registers. */ - -#define REGISTER_RAW_SIZE(N) ((N) >= LP0_REGNUM ? 8 : 4) - -/* Number of bytes of storage in the program's representation - for register N. On the 32000, all regs are 4 bytes - except for the doubled floating registers. */ - -#define REGISTER_VIRTUAL_SIZE(N) ((N) >= LP0_REGNUM ? 8 : 4) - -/* 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. */ - -#define REGISTER_CONVERTIBLE(N) 0 - -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ - bcopy ((FROM), (TO), REGISTER_VIRTUAL_SIZE(REGNUM)); - -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ - bcopy ((FROM), (TO), REGISTER_VIRTUAL_SIZE(REGNUM)); - -/* Return the GDB type object for the "standard" data type - of data in register N. */ - -#define REGISTER_VIRTUAL_TYPE(N) \ - ((N) >= FP0_REGNUM ? \ - ((N) >= LP0_REGNUM ? \ - builtin_type_double \ - : builtin_type_float) \ - : 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. - - On this machine this is a no-op, as gcc doesn't run on it yet. - This calling convention is not used. */ - -#define STORE_STRUCT_RETURN(ADDR, SP) - -/* 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) \ - bcopy (REGBUF, VALBUF, 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. - - However, if FRAME_CHAIN_VALID returns zero, - it means the given frame is the outermost one and has no caller. */ - -/* In the case of the Merlin, the frame's nominal address is the FP value, - and at that address is saved previous FP value as a 4-byte word. */ - -#define FRAME_CHAIN(thisframe) \ - (outside_startup_file ((thisframe)->pc) ? \ - read_memory_integer ((thisframe)->frame, 4) :\ - 0) - -#define FRAME_CHAIN_VALID(chain, thisframe) \ - (chain != 0 && (outside_startup_file (FRAME_SAVED_PC (thisframe)))) - -/* Define other aspects of the stack frame. */ - -#define FRAME_SAVED_PC(FRAME) (read_memory_integer ((FRAME)->frame + 4, 4)) - -/* compute base of arguments */ -#define FRAME_ARGS_ADDRESS(fi) ((fi)->frame) - -#define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame) - -/* Return number of args passed to a frame. - Can return -1, meaning no way to tell. */ - -#define FRAME_NUM_ARGS(numargs, fi) \ -{ CORE_ADDR pc; \ - int insn; \ - int addr_mode; \ - int width; \ - \ - pc = FRAME_SAVED_PC (fi); \ - insn = read_memory_integer (pc,2); \ - addr_mode = (insn >> 11) & 0x1f; \ - insn = insn & 0x7ff; \ - if ((insn & 0x7fc) == 0x57c \ - && addr_mode == 0x14) /* immediate */ \ - { if (insn == 0x57c) /* adjspb */ \ - width = 1; \ - else if (insn == 0x57d) /* adjspw */ \ - width = 2; \ - else if (insn == 0x57f) /* adjspd */ \ - width = 4; \ - numargs = read_memory_integer (pc+2,width); \ - if (width > 1) \ - flip_bytes (&numargs, width); \ - numargs = - sign_extend (numargs, width*8) / 4; } \ - else numargs = -1; \ -} - -/* Return number of bytes at start of arglist that are not really args. */ - -#define FRAME_ARGS_SKIP 8 - -/* 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) \ -{ int regmask,regnum; \ - int localcount; \ - CORE_ADDR enter_addr; \ - CORE_ADDR next_addr; \ - \ - enter_addr = get_pc_function_start ((frame_info)->pc); \ - regmask = read_memory_integer (enter_addr+1, 1); \ - localcount = ns32k_localcount (enter_addr); \ - next_addr = (frame_info)->frame + localcount; \ - for (regnum = 0; regnum < 8; regnum++, regmask >>= 1) \ - (frame_saved_regs).regs[regnum] \ - = (regmask & 1) ? (next_addr -= 4) : 0; \ - (frame_saved_regs).regs[SP_REGNUM] = (frame_info)->frame + 4; \ - (frame_saved_regs).regs[PC_REGNUM] = (frame_info)->frame + 4; \ - (frame_saved_regs).regs[FP_REGNUM] \ - = read_memory_integer ((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, read_register (PC_REGNUM)); \ - sp = push_word (sp, read_register (FP_REGNUM)); \ - write_register (FP_REGNUM, sp); \ - for (regnum = 0; regnum < 8; regnum++) \ - sp = push_word (sp, read_register (regnum)); \ - write_register (SP_REGNUM, sp); \ -} - -/* Discard from the stack the innermost frame, restoring all registers. */ - -#define POP_FRAME \ -{ register FRAME frame = get_current_frame (); \ - register CORE_ADDR fp; \ - register int regnum; \ - struct frame_saved_regs fsr; \ - struct frame_info *fi; \ - fi = get_frame_info (frame); \ - fp = fi->frame; \ - get_frame_saved_regs (fi, &fsr); \ - for (regnum = 0; regnum < 8; regnum++) \ - if (fsr.regs[regnum]) \ - write_register (regnum, read_memory_integer (fsr.regs[regnum], 4)); \ - write_register (FP_REGNUM, read_memory_integer (fp, 4)); \ - write_register (PC_REGNUM, read_memory_integer (fp + 4, 4)); \ - write_register (SP_REGNUM, fp + 8); \ - flush_cached_frames (); \ - set_current_frame (create_new_frame (read_register (FP_REGNUM),\ - read_pc ())); \ -} - -/* This sequence of words is the instructions - enter 0xff,0 82 ff 00 - jsr @0x00010203 7f ae c0 01 02 03 - adjspd 0x69696969 7f a5 01 02 03 04 - bpt f2 - Note this is 16 bytes. */ - -#define CALL_DUMMY { 0x7f00ff82, 0x0201c0ae, 0x01a57f03, 0xf2040302 } - -#define CALL_DUMMY_START_OFFSET 3 -#define CALL_DUMMY_LENGTH 16 -#define CALL_DUMMY_ADDR 5 -#define CALL_DUMMY_NARGS 11 - -/* 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) \ -{ int flipped = fun | 0xc0000000; \ - flip_bytes (&flipped, 4); \ - *((int *) (((char *) dummyname)+CALL_DUMMY_ADDR)) = flipped; \ - flipped = - nargs * 4; \ - flip_bytes (&flipped, 4); \ - *((int *) (((char *) dummyname)+CALL_DUMMY_NARGS)) = flipped; \ -} diff --git a/gdb/tm-mips.h b/gdb/tm-mips.h deleted file mode 100644 index dc5af0dc4f6..00000000000 --- a/gdb/tm-mips.h +++ /dev/null @@ -1,346 +0,0 @@ -/* Definitions to make GDB run on a mips box under 4.3bsd. - Copyright (C) 1986, 1987, 1989, 1991 Free Software Foundation, Inc. - Contributed by Per Bothner (bothner@cs.wisc.edu) at U.Wisconsin - and by Alessandro Forin (af@cs.cmu.edu) at CMU. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#if !defined (TARGET_BYTE_ORDER) -#define TARGET_BYTE_ORDER LITTLE_ENDIAN -#endif - -/* Floating point is IEEE compliant */ -#define IEEE_FLOAT - -/* Define this if the C compiler puts an underscore at the front - of external names before giving them to the linker. */ - -/*#define NAMES_HAVE_UNDERSCORE*/ - -/* Debugger information will be in mips' format */ - -#define READ_MIPS_FORMAT - -/* File format is coff, but with additions */ - -#define COFF_FORMAT - -/* 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) pc = mips_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) read_register(RA_REGNUM) - -/* Are we currently handling a signal */ - -#define IN_SIGTRAMP(pc, name) in_sigtramp(pc, name) - -/* Address of end of stack space. */ - -#define STACK_END_ADDR (0x7ffff000) - -/* Stack grows downward. */ - -#define INNER_THAN < - -#define BIG_ENDIAN 4321 -#if TARGET_BYTE_ORDER == BIG_ENDIAN -#define BREAKPOINT {0, 0x5, 0, 0xd} -#else -#define BREAKPOINT {0xd, 0, 0x5, 0} -#endif - -/* 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 - -/* Nonzero if instruction at PC is a return instruction. "j ra" on mips. */ - -#define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 4) == 0x3e00008) - -/* Return 1 if P points to an invalid floating point value. */ - -#define INVALID_FLOAT(p,l) isa_NAN(p,l) - -/* Say how long (all) registers are. */ - -#define REGISTER_TYPE long - -/* Number of machine registers */ - -#define NUM_REGS 73 - -/* Initializer for an array of names of registers. - There should be NUM_REGS strings in this initializer. */ - -#define REGISTER_NAMES \ - { "zero", "at", "v0", "v1", "a0", "a1", "a2", "a3", \ - "t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7", \ - "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", \ - "t8", "t9", "k0", "k1", "gp", "sp", "s8", "ra", \ - "sr", "lo", "hi", "bad", "cause","pc", \ - "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \ - "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", \ - "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23",\ - "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31",\ - "fsr", "fir", "fp" \ - } - -/* 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 ZERO_REGNUM 0 /* read-only register, always 0 */ -#define SP_REGNUM 29 /* Contains address of top of stack */ -#define RA_REGNUM 31 /* Contains return address value */ -#define PS_REGNUM 32 /* Contains processor status */ -#define HI_REGNUM 34 /* Multiple/divide temp */ -#define LO_REGNUM 33 /* ... */ -#define BADVADDR_REGNUM 35 /* bad vaddr for addressing exception */ -#define CAUSE_REGNUM 36 /* describes last exception */ -#define PC_REGNUM 37 /* Contains program counter */ -#define FP0_REGNUM 38 /* Floating point register 0 (single float) */ -#define FCRCS_REGNUM 70 /* FP control/status */ -#define FCRIR_REGNUM 71 /* FP implementation/revision */ -#define FP_REGNUM 72 /* Pseudo register that contains true address of executing stack frame */ - -/* Define DO_REGISTERS_INFO() to do machine-specific formatting - of register dumps. */ - -#define DO_REGISTERS_INFO(_regnum, fp) mips_do_registers_info(_regnum, fp) - -/* Total amount of space needed to store our copies of the machine's - register state, the array `registers'. */ -#define REGISTER_BYTES (NUM_REGS*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 mips, 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 mips, 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 - -/* Nonzero if register N requires conversion - from raw format to virtual format. */ - -#define REGISTER_CONVERTIBLE(N) 0 - -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ - bcopy ((FROM), (TO), 4); - -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ - bcopy ((FROM), (TO), 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) \ - { sp = push_word(sp, 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. XXX floats */ - -#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \ - bcopy (REGBUF+REGISTER_BYTE (TYPE_CODE (TYPE) == TYPE_CODE_FLT ? FP0_REGNUM : 2), VALBUF, 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 (REGISTER_BYTE (TYPE_CODE (TYPE) == TYPE_CODE_FLT ? FP0_REGNUM : 2), 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+16)) - -/* Structures are returned by ref in extra arg0 */ -#define USE_STRUCT_CONVENTION(gcc_p, type) 1 - - -/* 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. - - However, if FRAME_CHAIN_VALID returns zero, - it means the given frame is the outermost one and has no caller. */ - -#define FRAME_CHAIN(thisframe) (FRAME_ADDR)mips_frame_chain(thisframe) - -#define FRAME_CHAIN_VALID(chain, thisframe) \ - (chain != 0 && (outside_startup_file (FRAME_SAVED_PC (thisframe)))) - -/* 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. */ -/* We handle this differently for mips, and maybe we should not */ - -#define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) {(FRAMELESS) = 0;} - -/* Saved Pc. */ - -#define FRAME_SAVED_PC(FRAME) (mips_frame_saved_pc(FRAME)) - -#define FRAME_ARGS_ADDRESS(fi) (fi)->frame - -#define FRAME_LOCALS_ADDRESS(fi) (fi)->frame - -/* Return number of args passed to a frame. - Can return -1, meaning no way to tell. */ - -#define FRAME_NUM_ARGS(num, fi) (num = mips_frame_num_args(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_FIND_SAVED_REGS(frame_info, frame_saved_regs) ( \ - (frame_saved_regs) = *(frame_info)->saved_regs, \ - (frame_saved_regs).regs[SP_REGNUM] = (frame_info)->frame) - - -/* Things needed for making the inferior call functions. */ - -/* Stack has strict alignment. However, use PUSH_ARGUMENTS - to take care of it. */ -/*#define STACK_ALIGN(addr) (((addr)+3)&~3)*/ - -#define PUSH_ARGUMENTS(nargs, args, sp, struct_return, struct_addr) \ - sp = mips_push_arguments(nargs, args, sp, struct_return, struct_addr) - -/* Push an empty stack frame, to record the current PC, etc. */ - -#define PUSH_DUMMY_FRAME mips_push_dummy_frame() - -/* Discard from the stack the innermost frame, restoring all registers. */ - -#define POP_FRAME mips_pop_frame() - -#define MK_OP(op,rs,rt,offset) (((op)<<26)|((rs)<<21)|((rt)<<16)|(offset)) -#define CALL_DUMMY_SIZE (16*4) -#define Dest_Reg 2 -#define CALL_DUMMY {\ - MK_OP(0,RA_REGNUM,0,8), /* jr $ra # Fake ABOUT_TO_RETURN ...*/\ - 0, /* nop # ... to stop raw backtrace*/\ - 0x27bd0000, /* addu sp,?0 # Pseudo prologue */\ -/* Start here: */\ - MK_OP(061,SP_REGNUM,12,0), /* lwc1 $f12,0(sp) # Reload first 4 args*/\ - MK_OP(061,SP_REGNUM,13,4), /* lwc1 $f13,4(sp) */\ - MK_OP(061,SP_REGNUM,14,8), /* lwc1 $f14,8(sp) */\ - MK_OP(061,SP_REGNUM,15,12), /* lwc1 $f15,12(sp) */\ - MK_OP(043,SP_REGNUM,4,0), /* lw $r4,0(sp) # Re-load FP regs*/\ - MK_OP(043,SP_REGNUM,5,4), /* lw $r5,4(sp) */\ - MK_OP(043,SP_REGNUM,6,8), /* lw $r6,8(sp) */\ - MK_OP(043,SP_REGNUM,7,12), /* lw $r7,12(sp) */\ - (017<<26)| (Dest_Reg << 16), /* lui $r31,*/\ - MK_OP(13,Dest_Reg,Dest_Reg,0), /* ori $r31,$r31,*/ \ - (Dest_Reg<<21) | (31<<11) | 9, /* jalr $r31 */\ - MK_OP(043,SP_REGNUM,7,12), /* lw $r7,12(sp) */\ - 0x5000d, /* bpt */\ -} - -#define CALL_DUMMY_START_OFFSET 12 - -/* 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, start_sp, fun, nargs, args, rettype, gcc_p)\ - (((int*)dummyname)[11] |= (((unsigned long)(fun)) >> 16), \ - ((int*)dummyname)[12] |= (unsigned short)(fun)) - -/* Specific information about a procedure. - This overlays the MIPS's PDR records, - mipsread.c (ab)uses this to save memory */ - -typedef struct mips_extra_func_info { - unsigned long adr; /* memory address of start of procedure */ - long isym; /* pointer to procedure symbol */ - long pad2; /* iline: start of line number entries*/ - long regmask; /* save register mask */ - long regoffset; /* save register offset */ - long numargs; /* number of args to procedure (was iopt) */ - long fregmask; /* save floating point register mask */ - long fregoffset; /* save floating point register offset */ - long framesize; /* frameoffset: frame size */ - short framereg; /* frame pointer register */ - short pcreg; /* offset or reg of return pc */ - long lnLow; /* lowest line in the procedure */ - long lnHigh; /* highest line in the procedure */ - long pad3; /* cbLineOffset: byte offset for this procedure from the fd base */ -} *mips_extra_func_info_t; - -#define EXTRA_FRAME_INFO \ - char *proc_desc; /* actually, a mips_extra_func_info_t */\ - int num_args;\ - struct frame_saved_regs *saved_regs; - -#define INIT_EXTRA_FRAME_INFO(fromleaf, fci) init_extra_frame_info(fci) diff --git a/gdb/tm-news.h b/gdb/tm-news.h deleted file mode 100644 index 6ec1fab0c15..00000000000 --- a/gdb/tm-news.h +++ /dev/null @@ -1,90 +0,0 @@ -/* Parameters for execution on a Sony/NEWS, for GDB, the GNU debugger. - Copyright (C) 1987, 1989, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* See following cpu type determination macro to get the machine type. - -Here is an m-news.h file for gdb. It supports the 68881 registers. - by hikichi@srava.sra.junet - -* Support Sun assembly format instead of Motorola one. -* Ptrace for handling floating register has a bug(before NEWS OS version 2.2), -* After NEWS OS version 3.2, some of ptrace's bug is fixed. - But we cannot change the floating register(see adb(1) in OS 3.2) yet. */ - -#define HAVE_68881 - -/* Define this if the C compiler puts an underscore at the front - of external names before giving them to the linker. */ - -#define NAMES_HAVE_UNDERSCORE - -/* Use to compute STACK_END_ADDR. */ -#define TARGET_UPAGES 2 -#define TARGET_NBPG 4096 - -/* Address of end of stack space. */ - -#define STACK_END_ADDR (0x80000000 - TARGET_UPAGES * TARGET_NBPG) - -/* 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. */ - -/* when it return the floating value, use the FP0 in NEWS. */ -#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \ - { if (TYPE_CODE (TYPE) == TYPE_CODE_FLT) \ - { \ - REGISTER_CONVERT_TO_VIRTUAL (FP0_REGNUM, \ - ®BUF[REGISTER_BYTE (FP0_REGNUM)], VALBUF); \ - } \ - else \ - bcopy (REGBUF, VALBUF, TYPE_LENGTH (TYPE)); } - -/* Write into appropriate registers a function return value - of type TYPE, given in virtual format. */ - -/* when it return the floating value, use the FP0 in NEWS. */ -#define STORE_RETURN_VALUE(TYPE,VALBUF) \ - { if (TYPE_CODE (TYPE) == TYPE_CODE_FLT) \ - { \ - char raw_buf[REGISTER_RAW_SIZE (FP0_REGNUM)]; \ - REGISTER_CONVERT_TO_RAW (FP0_REGNUM, VALBUF, raw_buf); \ - write_register_bytes (FP0_REGNUM, \ - raw_buf, REGISTER_RAW_SIZE (FP0_REGNUM)); \ - } \ - else \ - write_register_bytes (0, VALBUF, TYPE_LENGTH (TYPE)); } - -/* Return number of args passed to a frame. - Can return -1, meaning no way to tell. */ - -#define FRAME_NUM_ARGS(val, fi) \ -{ register CORE_ADDR pc = FRAME_SAVED_PC (fi); \ - register int insn = 0177777 & read_memory_integer (pc, 2); \ - val = 0; \ - if (insn == 0047757 || insn == 0157374) /* lea W(sp),sp or addaw #W,sp */ \ - val = read_memory_integer (pc + 2, 2); \ - else if ((insn & 0170777) == 0050217 /* addql #N, sp */ \ - || (insn & 0170777) == 0050117) /* addqw */ \ - { val = (insn >> 9) & 7; if (val == 0) val = 8; } \ - else if (insn == 0157774) /* addal #WW, sp */ \ - val = read_memory_integer (pc + 2, 4); \ - val >>= 2; } - -#include "tm-68k.h" diff --git a/gdb/tm-nindy960.h b/gdb/tm-nindy960.h deleted file mode 100644 index 520eb6b8cca..00000000000 --- a/gdb/tm-nindy960.h +++ /dev/null @@ -1,100 +0,0 @@ -/* Parameters for Intel 960 running NINDY monitor, for GDB, the GNU debugger. - Copyright (C) 1990-1991 Free Software Foundation, Inc. - Contributed by Intel Corporation and 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/***************************************************************************** - * Definitions to target GDB to an i960 debugged over a serial line. - ******************************************************************************/ - -#include "tm-i960.h" - -/* Override the standard gdb prompt when compiled for this target. */ - -#define DEFAULT_PROMPT "(gdb960) " - -/* Additional command line options accepted by nindy gdb's, for handling - the remote-nindy.c interface. These should really be target-specific - rather than architecture-specific. */ - -extern int nindy_old_protocol; /* nonzero if old NINDY serial protocol */ -extern int nindy_initial_brk; /* Send a BREAK to reset board first */ -extern char *nindy_ttyname; /* Name of serial port to talk to nindy */ - -#define ADDITIONAL_OPTIONS \ - {"O", 0, &nindy_old_protocol, 1}, \ - {"brk", 0, &nindy_initial_brk, 1}, \ - {"r", 1, 0, 1004}, /* 1004 is magic cookie for ADDL_CASES */ - -#define ADDITIONAL_OPTION_CASES \ - case 1004: /* -r option: remote nindy auto-start */ \ - nindy_ttyname = optarg; \ - break; - -#define ADDITIONAL_OPTION_HELP \ - "\ - -O Use old protocol to talk to a Nindy target\n\ - -brk Send a break to a Nindy target to reset it.\n\ - -r SERIAL Open remote Nindy session to SERIAL port.\n\ -" - -/* If specified on the command line, open tty for talking to nindy, - and download the executable file if one was specified. */ - -#define ADDITIONAL_OPTION_HANDLER \ - if (!setjmp (to_top_level) && nindy_ttyname) { \ - nindy_open (nindy_ttyname, !batch); \ - if ( !setjmp(to_top_level) && execarg ) { \ - target_load (execarg, !batch); \ - } \ - } - -/* If configured for i960 target, we take control before main loop - and demand that we configure for a nindy target. */ - -#define BEFORE_MAIN_LOOP_HOOK \ - nindy_before_main_loop(); - -/* Address of end of stack space. - * This probably doesn't matter for nindy, because it's only used - * in manipulation of core files, which we don't support. - */ - -#define STACK_END_ADDR (0xfe000000) - -/* FRAME_CHAIN_VALID returns zero if the given frame is the outermost one - and has no caller. - - On the i960, each various target system type defines FRAME_CHAIN_VALID, - since it differs between NINDY and VxWorks, the two currently supported - targets types. */ - -#define FRAME_CHAIN_VALID(chain, thisframe) \ - nindy_frame_chain_valid (chain, thisframe) - -extern int nindy_frame_chain_valid(); /* See nindy-tdep.c */ - -/* Sequence of bytes for breakpoint instruction */ - -#define BREAKPOINT {0x00, 0x3e, 0x00, 0x66} - -/* Amount ip 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 diff --git a/gdb/tm-np1.h b/gdb/tm-np1.h deleted file mode 100644 index 75a36aff0f5..00000000000 --- a/gdb/tm-np1.h +++ /dev/null @@ -1,506 +0,0 @@ -/* Parameters for targeting on a Gould NP1, for GDB, the GNU debugger. - Copyright (C) 1986, 1987, 1989, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#define GOULD_NPL - -#define TARGET_BYTE_ORDER BIG_ENDIAN - -/* N_ENTRY appears in libraries on Gould machines. - Don't know what 0xa4 is; it's mentioned in stab.h - but only in the sdb symbol list. */ -#define IGNORE_SYMBOL(type) (type == N_ENTRY || type == 0xa4) - -/* We don't want the extra gnu symbols on the machine; - they will interfere with the shared segment symbols. */ -#define NO_GNU_STABS - -/* Macro for text-offset and data info (in NPL a.out format). */ -#define TEXTINFO \ - text_offset = N_TXTOFF (exec_coffhdr, exec_aouthdr); \ - exec_data_offset = N_TXTOFF (exec_coffhdr, exec_aouthdr)\ - + exec_aouthdr.a_text - -/* Macro for number of symbol table entries */ -#define NUMBER_OF_SYMBOLS \ - (coffhdr.f_nsyms) - -/* Macro for file-offset of symbol table (in NPL a.out format). */ -#define SYMBOL_TABLE_OFFSET \ - N_SYMOFF (coffhdr) - -/* Macro for file-offset of string table (in NPL a.out format). */ -#define STRING_TABLE_OFFSET \ - (N_STROFF (coffhdr)) - -/* Macro to store the length of the string table data in INTO. */ -#define READ_STRING_TABLE_SIZE(INTO) \ - { INTO = hdr.a_stsize; } - -/* Macro to declare variables to hold the file's header data. */ -#define DECLARE_FILE_HEADERS struct exec hdr; \ - FILHDR coffhdr - -/* Macro to read the header data from descriptor DESC and validate it. - NAME is the file name, for error messages. */ -#define READ_FILE_HEADERS(DESC, NAME) \ -{ val = myread (DESC, &coffhdr, sizeof coffhdr); \ - if (val < 0) \ - perror_with_name (NAME); \ - val = myread (DESC, &hdr, sizeof hdr); \ - if (val < 0) \ - perror_with_name (NAME); \ - if (coffhdr.f_magic != GNP1MAGIC) \ - error ("File \"%s\" not in coff executable format.", NAME); \ - if (N_BADMAG (hdr)) \ - error ("File \"%s\" not in executable format.", NAME); } - -/* Define COFF and other symbolic names needed on NP1 */ -#define NS32GMAGIC GNP1MAGIC -#define NS32SMAGIC GPNMAGIC - -/* Define this if the C compiler puts an underscore at the front - of external names before giving them to the linker. */ -#define NAMES_HAVE_UNDERSCORE - -/* Address of blocks in N_LBRAC and N_RBRAC symbols are absolute addresses, - not relative to start of source address. */ -#define BLOCK_ADDRESS_ABSOLUTE - -/* Offset from address of function to start of its code. - Zero on most machines. */ -#define FUNCTION_START_OFFSET 8 - -/* Advance PC across any function entry prologue instructions - to reach some "real" code. One NPL we can have one two startup - sequences depending on the size of the local stack: - - Either: - "suabr b2, #" - of - "lil r4, #", "suabr b2, #(r4)" - - "lwbr b6, #", "stw r1, 8(b2)" - Optional "stwbr b3, c(b2)" - Optional "trr r2,r7" (Gould first argument register passing) - or - Optional "stw r2,8(b3)" (Gould first argument register passing) - */ -#define SKIP_PROLOGUE(pc) { \ - register int op = read_memory_integer ((pc), 4); \ - if ((op & 0xffff0000) == 0xFA0B0000) { \ - pc += 4; \ - op = read_memory_integer ((pc), 4); \ - if ((op & 0xffff0000) == 0x59400000) { \ - pc += 4; \ - op = read_memory_integer ((pc), 4); \ - if ((op & 0xffff0000) == 0x5F000000) { \ - pc += 4; \ - op = read_memory_integer ((pc), 4); \ - if (op == 0xD4820008) { \ - pc += 4; \ - op = read_memory_integer ((pc), 4); \ - if (op == 0x5582000C) { \ - pc += 4; \ - op = read_memory_integer ((pc), 2); \ - if (op == 0x2fa0) { \ - pc += 2; \ - } else { \ - op = read_memory_integer ((pc), 4); \ - if (op == 0xd5030008) { \ - pc += 4; \ - } \ - } \ - } else { \ - op = read_memory_integer ((pc), 2); \ - if (op == 0x2fa0) { \ - pc += 2; \ - } \ - } \ - } \ - } \ - } \ - } \ - if ((op & 0xffff0000) == 0x59000000) { \ - pc += 4; \ - op = read_memory_integer ((pc), 4); \ - if ((op & 0xffff0000) == 0x5F000000) { \ - pc += 4; \ - op = read_memory_integer ((pc), 4); \ - if (op == 0xD4820008) { \ - pc += 4; \ - op = read_memory_integer ((pc), 4); \ - if (op == 0x5582000C) { \ - pc += 4; \ - op = read_memory_integer ((pc), 2); \ - if (op == 0x2fa0) { \ - pc += 2; \ - } else { \ - op = read_memory_integer ((pc), 4); \ - if (op == 0xd5030008) { \ - pc += 4; \ - } \ - } \ - } else { \ - op = read_memory_integer ((pc), 2); \ - if (op == 0x2fa0) { \ - pc += 2; \ - } \ - } \ - } \ - } \ - } \ -} - -/* 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 - some instructions. True on NPL! Return address is in R1. - The true return address is REALLY 4 past that location! */ -#define SAVED_PC_AFTER_CALL(frame) \ - (read_register(R1_REGNUM) + 4) - -/* Address of end of stack space. */ -#define STACK_END_ADDR 0x7fffc000 - -/* Stack grows downward. */ -#define INNER_THAN < - -/* Sequence of bytes for breakpoint instruction. - This is padded out to the size of a machine word. When it was just - {0x28, 0x09} it gave problems if hit breakpoint on returning from a - function call. */ -#define BREAKPOINT {0x28, 0x09, 0x0, 0x0} - -/* 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 2 - -/* Nonzero if instruction at PC is a return instruction. "bu 4(r1)" */ -#define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 4) == 0x40100004) - -/* Return 1 if P points to an invalid floating point value. */ -#define INVALID_FLOAT(p, len) ((*(short *)p & 0xff80) == 0x8000) - -/* Say how long (ordinary) registers are. */ -#define REGISTER_TYPE long - -/* Size of bytes of vector register (NP1 only), 32 elements * sizeof(int) */ -#define VR_SIZE 128 - -/* Number of machine registers */ -#define NUM_REGS 27 -#define NUM_GEN_REGS 16 -#define NUM_CPU_REGS 4 -#define NUM_VECTOR_REGS 7 - -/* 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", \ - "b0", "b1", "b2", "b3", "b4", "b5", "b6", "b7", \ - "sp", "ps", "pc", "ve", \ - "v1", "v2", "v3", "v4", "v5", "v6", "v7", \ -} - -/* 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 R1_REGNUM 1 /* Gr1 => return address of caller */ -#define R2_REGNUM 2 /* Gr2 => return value from function */ -#define R4_REGNUM 4 /* Gr4 => register save area */ -#define R5_REGNUM 5 /* Gr5 => register save area */ -#define R6_REGNUM 6 /* Gr6 => register save area */ -#define R7_REGNUM 7 /* Gr7 => register save area */ -#define B1_REGNUM 9 /* Br1 => start of this code routine */ -#define SP_REGNUM 10 /* Br2 == (sp) */ -#define AP_REGNUM 11 /* Br3 == (ap) */ -#define FP_REGNUM 16 /* A copy of Br2 saved in trap */ -#define PS_REGNUM 17 /* Contains processor status */ -#define PC_REGNUM 18 /* Contains program counter */ -#define VE_REGNUM 19 /* Vector end (user setup) register */ -#define V1_REGNUM 20 /* First vector register */ -#define V7_REGNUM 26 /* First vector register */ - -/* Total amount of space needed to store our copies of the machine's - register state, the array `registers'. */ -#define REGISTER_BYTES \ - (NUM_GEN_REGS*4 + NUM_VECTOR_REGS*VR_SIZE + NUM_CPU_REGS*4) - -/* Index within `registers' of the first byte of the space for - register N. */ -#define REGISTER_BYTE(N) \ - (((N) < V1_REGNUM) ? ((N) * 4) : (((N) - V1_REGNUM) * VR_SIZE) + 80) - -/* Number of bytes of storage in the actual machine representation - for register N. On the NP1, all normal regs are 4 bytes, but - the vector registers are VR_SIZE*4 bytes long. */ -#define REGISTER_RAW_SIZE(N) \ - (((N) < V1_REGNUM) ? 4 : VR_SIZE) - -/* Number of bytes of storage in the program's representation - for register N. On the NP1, all regs are 4 bytes. */ -#define REGISTER_VIRTUAL_SIZE(N) \ - (((N) < V1_REGNUM) ? 4 : VR_SIZE) - -/* Largest value REGISTER_RAW_SIZE can have. */ -#define MAX_REGISTER_RAW_SIZE VR_SIZE - -/* Largest value REGISTER_VIRTUAL_SIZE can have. */ -#define MAX_REGISTER_VIRTUAL_SIZE VR_SIZE - -/* Nonzero if register N requires conversion - from raw format to virtual format. */ -#define REGISTER_CONVERTIBLE(N) (0) - -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ - bcopy ((FROM), (TO), REGISTER_RAW_SIZE(REGNUM)); - -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ - bcopy ((FROM), (TO), REGISTER_VIRTUAL_SIZE(REGNUM)); - -/* Return the GDB type object for the "standard" data type - of data in register N. */ -#define REGISTER_VIRTUAL_TYPE(N) \ - ((N) > VE_REGNUM ? builtin_type_np1_vector : builtin_type_int) -extern struct type *builtin_type_np1_vector; - -/* Store the address of the place in which to copy the structure the - subroutine will return. This is called from call_function. - - On this machine this is a no-op, because gcc isn't used on it - yet. So this calling convention is not used. */ - -#define STORE_STRUCT_RETURN(ADDR, SP) push_word(SP + 8, ADDR) - -/* Extract from an arrary 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) \ - bcopy (((int *)(REGBUF)) + 2, VALBUF, 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 (REGISTER_BYTE (R2_REGNUM), 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) + 2)) - -/* Both gcc and cc return small structs in registers (i.e. in GDB - terminology, small structs don't use the struct return convention). */ -#define USE_STRUCT_CONVENTION(gcc_p, type) (TYPE_LENGTH(type) > 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. - - However, if FRAME_CHAIN_VALID returns zero, - it means the given frame is the outermost one and has no caller. */ - -/* In the case of the NPL, the frame's norminal address is Br2 and the - previous routines frame is up the stack X bytes, where X is the - value stored in the code function header xA(Br1). */ -#define FRAME_CHAIN(thisframe) (findframe(thisframe)) - -#define FRAME_CHAIN_VALID(chain, thisframe) \ - (chain != 0 && chain != (thisframe)->frame) - -/* Define other aspects of the stack frame on NPL. */ -#define FRAME_SAVED_PC(FRAME) \ - (read_memory_integer ((FRAME)->frame + 8, 4)) - -#define FRAME_ARGS_ADDRESS(fi) \ - ((fi)->next_frame ? \ - read_memory_integer ((fi)->frame + 12, 4) : \ - read_register (AP_REGNUM)) - -#define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame) - -/* Set VAL to the number of args passed to frame described by FI. - Can set VAL to -1, meaning no way to tell. */ - -/* We can check the stab info to see how - many arg we have. No info in stack will tell us */ -#define FRAME_NUM_ARGS(val,fi) (val = findarg(fi)) - -/* Return number of bytes at start of arglist that are not really args. */ -#define FRAME_ARGS_SKIP 8 - -/* 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) \ -{ \ - bzero (&frame_saved_regs, sizeof frame_saved_regs); \ - (frame_saved_regs).regs[SP_REGNUM] = framechain (frame_info); \ - (frame_saved_regs).regs[PC_REGNUM] = (frame_info)->frame + 8; \ - (frame_saved_regs).regs[R4_REGNUM] = (frame_info)->frame + 0x30; \ - (frame_saved_regs).regs[R5_REGNUM] = (frame_info)->frame + 0x34; \ - (frame_saved_regs).regs[R6_REGNUM] = (frame_info)->frame + 0x38; \ - (frame_saved_regs).regs[R7_REGNUM] = (frame_info)->frame + 0x3C; \ -} - -/* Things needed for making the inferior call functions. */ - -#define CALL_DUMMY_LOCATION BEFORE_TEXT_END -#define NEED_TEXT_START_END - -/* 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; \ - for (regnum = 0; regnum < FP_REGNUM; regnum++) \ - sp = push_word (sp, read_register (regnum)); \ - sp = push_word (sp, read_register (PS_REGNUM)); \ - sp = push_word (sp, read_register (PC_REGNUM)); \ - write_register (SP_REGNUM, sp);} - -/* Discard from the stack the innermost frame, - restoring all saved registers. */ - -#define POP_FRAME \ -{ CORE_ADDR sp = read_register(SP_REGNUM); \ - REGISTER_TYPE reg; \ - int regnum; \ - for(regnum = 0;regnum < FP_REGNUM;regnum++){ \ - sp-=sizeof(REGISTER_TYPE); \ - read_memory(sp,®,sizeof(REGISTER_TYPE)); \ - write_register(regnum,reg);} \ - sp-=sizeof(REGISTER_TYPE); \ - read_memory(sp,®,sizeof(REGISTER_TYPE)); \ - write_register(PS_REGNUM,reg); \ - sp-=sizeof(REGISTER_TYPE); \ - read_memory(sp,®,sizeof(REGISTER_TYPE)); \ - write_register(PC_REGNUM,reg);} - -/* MJD - Size of dummy frame pushed onto stack by PUSH_DUMMY_FRAME */ - -#define DUMMY_FRAME_SIZE (0x48) - -/* MJD - The sequence of words in the instructions is - halt - halt - halt - halt - subr b2,stack size,0 grab stack space for dummy call - labr b3,x0(b2),0 set AP_REGNUM to point at arguments - lw r2,x8(b3),0 load r2 with first argument - lwbr b1,arguments size(b2),0 load address of function to be called - brlnk r1,x8(b1),0 call function - halt - halt - labr b2,stack size(b2),0 give back stack - break break - */ - -#define CALL_DUMMY {0x00000000, \ - 0x00000000, \ - 0x59000000, \ - 0x598a0000, \ - 0xb5030008, \ - 0x5c820000, \ - 0x44810008, \ - 0x00000000, \ - 0x590a0000, \ - 0x28090000 } - -#define CALL_DUMMY_LENGTH 40 - -#define CALL_DUMMY_START_OFFSET 8 - -#define CALL_DUMMY_STACK_ADJUST 8 - -/* MJD - Fixup CALL_DUMMY for the specific function call. - OK heres the problems - 1) On a trap there are two copies of the stack pointer, one in SP_REGNUM - which is read/write and one in FP_REGNUM which is only read. It seems - that when restarting the GOULD NP1 uses FP_REGNUM's value. - 2) Loading function address into b1 looks a bit difficult if bigger than - 0x0000fffc, infact from what I can tell the compiler sets up table of - function address in base3 through which function calls are referenced. - - OK my solutions - Calculate the size of the dummy stack frame and do adjustments of - SP_REGNUM in the dummy call. - Push function address onto the stack and load it in the dummy call - */ - -#define FIX_CALL_DUMMY(dummyname, sp, fun, nargs, args, type, gcc_p) \ - { int i;\ - int arg_len = 0, total_len;\ - old_sp = push_word(old_sp,fun);\ - for(i = nargs - 1;i >= 0;i--)\ - arg_len += TYPE_LENGTH (VALUE_TYPE (value_arg_coerce (args[i])));\ - if(struct_return)\ - arg_len += TYPE_LENGTH(value_type);\ - total_len = DUMMY_FRAME_SIZE+CALL_DUMMY_STACK_ADJUST+4+arg_len;\ - dummyname[0] += total_len;\ - dummyname[2] += total_len;\ - dummyname[5] += arg_len+CALL_DUMMY_STACK_ADJUST;\ - dummyname[8] += total_len;} - -/* MJD - So the stack should end up looking like this - - | Normal stack frame | - | from normal program | - | flow | - +---------------------+ <- Final sp - 0x08 - argument size - | | - 0x4 - dummy_frame_size - | Pushed dummy frame | - | b0-b7, r0-r7 | - | pc and ps | - | | - +---------------------+ - | Function address | - +---------------------+ <- Final sp - 0x8 - arguments size - | | - | | - | | - | Arguments to | - | Function | - | | - | | - | | - +---------------------+ <- Final sp - 0x8 - | Dummy_stack_adjust | - +---------------------+ <- Final sp - | | - | where call will | - | build frame | -*/ diff --git a/gdb/tm-pn.h b/gdb/tm-pn.h deleted file mode 100644 index 3300c8c6daf..00000000000 --- a/gdb/tm-pn.h +++ /dev/null @@ -1,426 +0,0 @@ -/* Parameters for targe of a Gould Powernode, for GDB, the GNU debugger. - Copyright (C) 1986, 1987, 1989, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#define GOULD_PN - -#define TARGET_BYTE_ORDER BIG_ENDIAN - -/* This code appears in libraries on Gould machines. Ignore it. */ -#define IGNORE_SYMBOL(type) (type == N_ENTRY) - -/* We don't want the extra gnu symbols on the machine; - they will interfere with the shared segment symbols. */ -#define NO_GNU_STABS - -/* Macro for text-offset and data info (in PN a.out format). */ -#define TEXTINFO \ - text_offset = N_TXTOFF (exec_coffhdr); \ - exec_data_offset = N_TXTOFF (exec_coffhdr) \ - + exec_aouthdr.a_text - -/* Macro for number of symbol table entries */ -#define END_OF_TEXT_DEFAULT \ - (0xffffff) - -/* Macro for number of symbol table entries */ -#define NUMBER_OF_SYMBOLS \ - (coffhdr.f_nsyms) - -/* Macro for file-offset of symbol table (in usual a.out format). */ -#define SYMBOL_TABLE_OFFSET \ - N_SYMOFF (coffhdr) - -/* Macro for file-offset of string table (in usual a.out format). */ -#define STRING_TABLE_OFFSET \ - (N_STROFF (coffhdr) + sizeof(int)) - -/* Macro to store the length of the string table data in INTO. */ -#define READ_STRING_TABLE_SIZE(INTO) \ - { INTO = hdr.a_stsize; } - -/* Macro to declare variables to hold the file's header data. */ -#define DECLARE_FILE_HEADERS struct old_exec hdr; \ - FILHDR coffhdr - -/* Macro to read the header data from descriptor DESC and validate it. - NAME is the file name, for error messages. */ -#define READ_FILE_HEADERS(DESC, NAME) \ -{ val = myread (DESC, &coffhdr, sizeof coffhdr); \ - if (val < 0) \ - perror_with_name (NAME); \ - val = myread (DESC, &hdr, sizeof hdr); \ - if (val < 0) \ - perror_with_name (NAME); \ - if (coffhdr.f_magic != GNP1MAGIC) \ - error ("File \"%s\" not in coff executable format.", NAME); \ - if (N_BADMAG (hdr)) \ - error ("File \"%s\" not in executable format.", NAME); } - -/* Define COFF and other symbolic names needed on NP1 */ -#define NS32GMAGIC GDPMAGIC -#define NS32SMAGIC PN_MAGIC -/* Define this if the C compiler puts an underscore at the front - of external names before giving them to the linker. */ -#define NAMES_HAVE_UNDERSCORE - -/* Offset from address of function to start of its code. - Zero on most machines. */ -#define FUNCTION_START_OFFSET 4 - -/* Advance PC across any function entry prologue instructions - to reach some "real" code. One PN we can have one or two startup - sequences depending on the size of the local stack: - - Either: - "suabr b2, #" - of - "lil r4, #", "suabr b2, #(r4)" - - "lwbr b6, #", "stw r1, 8(b2)" - Optional "stwbr b3, c(b2)" - Optional "trr r2,r7" (Gould first argument register passing) - or - Optional "stw r2,8(b3)" (Gould first argument register passing) - */ -#define SKIP_PROLOGUE(pc) { \ - register int op = read_memory_integer ((pc), 4); \ - if ((op & 0xffff0000) == 0x580B0000) { \ - pc += 4; \ - op = read_memory_integer ((pc), 4); \ - if ((op & 0xffff0000) == 0x59400000) { \ - pc += 4; \ - op = read_memory_integer ((pc), 4); \ - if ((op & 0xffff0000) == 0x5F000000) { \ - pc += 4; \ - op = read_memory_integer ((pc), 4); \ - if (op == 0xD4820008) { \ - pc += 4; \ - op = read_memory_integer ((pc), 4); \ - if (op == 0x5582000C) { \ - pc += 4; \ - op = read_memory_integer ((pc), 2); \ - if (op == 0x2fa0) { \ - pc += 2; \ - } else { \ - op = read_memory_integer ((pc), 4); \ - if (op == 0xd5030008) { \ - pc += 4; \ - } \ - } \ - } else { \ - op = read_memory_integer ((pc), 2); \ - if (op == 0x2fa0) { \ - pc += 2; \ - } \ - } \ - } \ - } \ - } \ - } \ - if ((op & 0xffff0000) == 0x59000000) { \ - pc += 4; \ - op = read_memory_integer ((pc), 4); \ - if ((op & 0xffff0000) == 0x5F000000) { \ - pc += 4; \ - op = read_memory_integer ((pc), 4); \ - if (op == 0xD4820008) { \ - pc += 4; \ - op = read_memory_integer ((pc), 4); \ - if (op == 0x5582000C) { \ - pc += 4; \ - op = read_memory_integer ((pc), 2); \ - if (op == 0x2fa0) { \ - pc += 2; \ - } else { \ - op = read_memory_integer ((pc), 4); \ - if (op == 0xd5030008) { \ - pc += 4; \ - } \ - } \ - } else { \ - op = read_memory_integer ((pc), 2); \ - if (op == 0x2fa0) { \ - pc += 2; \ - } \ - } \ - } \ - } \ - } \ -} - -/* 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 - some instructions. True on PN! Return address is in R1. - Note: true return location is 4 bytes past R1! */ -#define SAVED_PC_AFTER_CALL(frame) \ - (read_register(R1_REGNUM) + 4) - -/* Address of end of stack space. */ -#define STACK_END_ADDR 0x480000 - -/* Stack grows downward. */ -#define INNER_THAN < - -/* Sequence of bytes for breakpoint instruction. */ -#define BREAKPOINT {0x28, 0x09} - -/* 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 2 - -/* Nonzero if instruction at PC is a return instruction. "bu 4(r1)" */ -#define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 4) == 0xEC100004) - -/* Return 1 if P points to an invalid floating point value. */ -#define INVALID_FLOAT(p, len) ((*(short *)p & 0xff80) == 0x8000) - -/* Say how long (ordinary) registers are. */ -#define REGISTER_TYPE long - -/* Number of machine registers */ -#define NUM_REGS 19 -#define NUM_GEN_REGS 16 -#define NUM_CPU_REGS 3 - -/* 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", \ - "b0", "b1", "b2", "b3", "b4", "b5", "b6", "b7", \ - "sp", "ps", "pc", \ -} - -/* 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 R1_REGNUM 1 /* Gr1 => return address of caller */ -#define R4_REGNUM 4 /* Gr4 => register save area */ -#define R5_REGNUM 5 /* Gr5 => register save area */ -#define R6_REGNUM 6 /* Gr6 => register save area */ -#define R7_REGNUM 7 /* Gr7 => register save area */ -#define B1_REGNUM 9 /* Br1 => start of this code routine */ -#define FP_REGNUM 10 /* Br2 == (sp) */ -#define AP_REGNUM 11 /* Br3 == (ap) */ -#define SP_REGNUM 16 /* A copy of Br2 saved in trap */ -#define PS_REGNUM 17 /* Contains processor status */ -#define PC_REGNUM 18 /* Contains program counter */ - -/* Total amount of space needed to store our copies of the machine's - register state, the array `registers'. */ -#define REGISTER_BYTES (NUM_GEN_REGS*4 + NUM_CPU_REGS*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 PN, all normal 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 PN, 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) - -/* Nonzero if register N requires conversion - from raw format to virtual format. */ -#define REGISTER_CONVERTIBLE(N) (0) - -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ - bcopy ((FROM), (TO), REGISTER_RAW_SIZE(REGNUM)); - -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ - bcopy ((FROM), (TO), REGISTER_VIRTUAL_SIZE(REGNUM)); - -/* 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. - - On this machine this is a no-op, because gcc isn't used on it - yet. So this calling convention is not used. */ - -#define STORE_STRUCT_RETURN(ADDR, SP) - -/* Extract from an arrary 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) \ - bcopy (REGBUF, VALBUF, 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. - - However, if FRAME_CHAIN_VALID returns zero, - it means the given frame is the outermost one and has no caller. */ - -/* In the case of the NPL, the frame's norminal address is Br2 and the - previous routines frame is up the stack X bytes, where X is the - value stored in the code function header xA(Br1). */ -#define FRAME_CHAIN(thisframe) (findframe(thisframe)) - -#define FRAME_CHAIN_VALID(chain, thisframe) \ - (chain != 0 && chain != (thisframe)->frame) - -/* Define other aspects of the stack frame on NPL. */ -#define FRAME_SAVED_PC(frame) \ - (read_memory_integer ((frame)->frame + 8, 4)) - -#define FRAME_ARGS_ADDRESS(fi) \ - ((fi)->next_frame ? \ - read_memory_integer ((fi)->frame + 12, 4) : \ - read_register (AP_REGNUM)) - -#define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame + 80) - -/* Set VAL to the number of args passed to frame described by FI. - Can set VAL to -1, meaning no way to tell. */ - -/* We can check the stab info to see how - many arg we have. No info in stack will tell us */ -#define FRAME_NUM_ARGS(val,fi) (val = findarg(fi)) - -/* Return number of bytes at start of arglist that are not really args. */ -#define FRAME_ARGS_SKIP 8 - -/* 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) \ -{ \ - bzero (&frame_saved_regs, sizeof frame_saved_regs); \ - (frame_saved_regs).regs[PC_REGNUM] = (frame_info)->frame + 8; \ - (frame_saved_regs).regs[R4_REGNUM] = (frame_info)->frame + 0x30; \ - (frame_saved_regs).regs[R5_REGNUM] = (frame_info)->frame + 0x34; \ - (frame_saved_regs).regs[R6_REGNUM] = (frame_info)->frame + 0x38; \ - (frame_saved_regs).regs[R7_REGNUM] = (frame_info)->frame + 0x3C; \ -} - -/* 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, read_register (PC_REGNUM)); \ - sp = push_word (sp, read_register (FP_REGNUM)); \ - write_register (FP_REGNUM, sp); \ - for (regnum = FP_REGNUM - 1; regnum >= 0; regnum--) \ - sp = push_word (sp, read_register (regnum)); \ - sp = push_word (sp, read_register (PS_REGNUM)); \ - write_register (SP_REGNUM, sp); } - -/* Discard from the stack the innermost frame, - restoring all saved registers. */ - -#define POP_FRAME \ -{ register FRAME frame = get_current_frame (); \ - register CORE_ADDR fp; \ - register int regnum; \ - struct frame_saved_regs fsr; \ - struct frame_info *fi; \ - fi = get_frame_info (frame); \ - fp = fi->frame; \ - get_frame_saved_regs (fi, &fsr); \ - for (regnum = FP_REGNUM - 1; regnum >= 0; regnum--) \ - if (fsr.regs[regnum]) \ - write_register (regnum, read_memory_integer (fsr.regs[regnum], 4)); \ - if (fsr.regs[PS_REGNUM]) \ - write_register (PS_REGNUM, read_memory_integer (fsr.regs[PS_REGNUM], 4)); \ - write_register (FP_REGNUM, read_memory_integer (fp, 4)); \ - write_register (PC_REGNUM, read_memory_integer (fp + 4, 4)); \ - write_register (SP_REGNUM, fp + 8); \ - flush_cached_frames (); \ - set_current_frame ( create_new_frame (read_register (FP_REGNUM),\ - read_pc ())); } - -/* This sequence of words is the instructions: - halt - halt - halt - halt - suabr b2, # - lwbr b6, #con - stw r1, 8(b2) - save caller address, do we care? - lw r2, 60(b2) - arg1 - labr b3, 50(b2) - std r4, 30(b2) - save r4-r7 - std r6, 38(b2) - lwbr b1, # - load function call address - brlnk r1, 8(b1) - call function - halt - halt - ld r4, 30(b2) - restore r4-r7 - ld r6, 38(b2) - - Setup our stack frame, load argumemts, call and then restore registers. -*/ - -/* FIXME: The below defines an m68k CALL_DUMMY, which looks nothing like what - is documented above. */ - -#define CALL_DUMMY {0xf227e0ff, 0x48e7fffc, 0x426742e7, 0x4eb93232, 0x3232dffc, 0x69696969, 0x4e4f4e71} - -#define CALL_DUMMY_LENGTH 28 - -#define CALL_DUMMY_START_OFFSET 12 - -/* 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) \ -{ *(int *)((char *) dummyname + 20) = nargs * 4; \ - *(int *)((char *) dummyname + 14) = fun; } diff --git a/gdb/tm-pyr.h b/gdb/tm-pyr.h deleted file mode 100644 index a977a5257ec..00000000000 --- a/gdb/tm-pyr.h +++ /dev/null @@ -1,520 +0,0 @@ -/* Definitions to make GDB run on a Pyramid under OSx 4.0 (4.2bsd). - Copyright (C) 1988, 1989, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#define TARGET_BYTE_ORDER BIG_ENDIAN - -/* Traditional Unix virtual address spaces have thre regions: text, - data and stack. The text, initialised data, and uninitialised data - are represented in separate segments of the a.out file. - When a process dumps core, the data and stack regions are written - to a core file. This gives a debugger enough information to - reconstruct (and debug) the virtual address space at the time of - the coredump. - Pyramids have an distinct fourth region of the virtual address - space, in which the contents of the windowed registers are stacked - in fixed-size frames. Pyramid refer to this region as the control - stack. Each call (or trap) automatically allocates a new register - frame; each return deallocates the current frame and restores the - windowed registers to their values before the call. - - When dumping core, the control stack is written to a core files as - a third segment. The core-handling functions need to know to deal - with it. */ -/* Tell core.c there is an extra segment. */ -#define REG_STACK_SEGMENT - -/* Floating point is IEEE compatible on most Pyramid hardware - (Older processors do not have IEEE NaNs). */ -#define IEEE_FLOAT - -/* Define this if the C compiler puts an underscore at the front - of external names before giving them to the linker. */ - -#define NAMES_HAVE_UNDERSCORE - -/* 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. */ - -/* FIXME -- do we want to skip insns to allocate the local frame? - If so, what do they look like? - This is becoming harder, since tege@sics.SE wants to change - gcc to not output a prologue when no frame is needed. */ -#define SKIP_PROLOGUE(pc) do {} while (0) - - -/* 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) - -/* Address of end of stack space. */ -/* This seems to be right for the 90x comp.vuw.ac.nz. - The correct value at any site may be a function of the configured - maximum control stack depth. If so, I don't know where the - control-stack depth is configured, so I can't #include it here. */ -#define STACK_END_ADDR (0xc00cc000) - -/* Register window stack (Control stack) stack definitions - - Address of beginning of control stack. - - size of control stack frame - (Note that since crts0 is usually the first function called, - main()'s control stack is one frame (0x80 bytes) beyond this value. */ - -#define CONTROL_STACK_ADDR (0xc00cd000) - -/* Bytes in a register window -- 16 parameter regs, 16 local regs - for each call, is 32 regs * 4 bytes */ - -#define CONTROL_STACK_FRAME_SIZE (32*4) - -/* FIXME. On a pyr, Data Stack grows downward; control stack goes upwards. - Which direction should we use for INNER_THAN, PC_INNER_THAN ?? */ - -#define INNER_THAN < -#define PC_INNER_THAN > - -/* Stack has strict alignment. */ - -#define STACK_ALIGN(ADDR) (((ADDR)+3)&-4) - -/* Sequence of bytes for breakpoint instruction. */ - -#define BREAKPOINT {0xf0, 00, 00, 00} - -/* 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 - -/* Nonzero if instruction at PC is a return instruction. - On a pyr, this is either "ret" or "retd". - It would be friendly to check that any "retd" always had an - argument of 0, since anything else is invalid. */ - -#define ABOUT_TO_RETURN(pc) \ -(((read_memory_integer (pc, 2) & 0x3ff0) == 0x3090) || \ - ((read_memory_integer (pc, 2) & 0x0ff0) == 0x00a0)) - -/* Return 1 if P points to an invalid floating point value. - LEN is the length in bytes -- not relevant on the Vax. */ -/* FIXME -- this is ok for a vax, bad for big-endian ieee format. - I would use the definition for a Sun; but it is no better! */ - -#define INVALID_FLOAT(p, len) ((*(short *) p & 0xff80) == 0x8000) - -/* Say how long (ordinary) registers are. */ - -#define REGISTER_TYPE long - -/* Number of machine registers */ -/* pyramids have 64, plus one for the PSW; plus perhaps one more for the - kernel stack pointer (ksp) and control-stack pointer (CSP) */ - -#define NUM_REGS 67 - -/* Initializer for an array of names of registers. - There should be NUM_REGS strings in this initializer. */ - -#define REGISTER_NAMES \ -{"gr0", "gr1", "gr2", "gr3", "gr4", "gr5", "gr6", "gr7", \ - "gr8", "gr9", "gr10", "gr11", "logpsw", "cfp", "sp", "pc", \ - "pr0", "pr1", "pr2", "pr3", "pr4", "pr5", "pr6", "pr7", \ - "pr8", "pr9", "pr10", "pr11", "pr12", "pr13", "pr14", "pr15", \ - "lr0", "lr1", "lr2", "lr3", "lr4", "lr5", "lr6", "lr7", \ - "lr8", "lr9", "lr10", "lr11", "lr12", "lr13", "lr14", "lr15", \ - "tr0", "tr1", "tr2", "tr3", "tr4", "tr5", "tr6", "tr7", \ - "tr8", "tr9", "tr10", "tr11", "tr12", "tr13", "tr14", "tr15", \ - "psw", "ksp", "csp"} - -/* 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. */ - -/* pseudo-registers: */ -#define PS_REGNUM 64 /* Contains processor status */ -#define PSW_REGNUM 64 /* Contains current psw, whatever it is.*/ -#define CSP_REGNUM 65 /* address of this control stack frame*/ -#define KSP_REGNUM 66 /* Contains process's Kernel Stack Pointer */ - -#define CFP_REGNUM 13 /* Current data-stack frame ptr */ -#define TR0_REGNUM 48 /* After function call, contains - function result */ - -/* Registers interesting to the machine-independent part of gdb*/ - -#define FP_REGNUM CSP_REGNUM /* Contains address of executing (control) - stack frame */ -#define SP_REGNUM 14 /* Contains address of top of stack -??*/ -#define PC_REGNUM 15 /* Contains program counter */ - -/* Define DO_REGISTERS_INFO() to do machine-specific formatting - of register dumps. */ - -#define DO_REGISTERS_INFO(_regnum, fp) pyr_do_registers_info(_regnum, fp) - -/* need this so we can find the global registers: they never get saved. */ -extern unsigned int global_reg_offset; -extern unsigned int last_frame_offset; - -/* Total amount of space needed to store our copies of the machine's - register state, the array `registers'. */ -#define REGISTER_BYTES (NUM_REGS*4) - -/* the Pyramid has register windows. */ - -#define HAVE_REGISTER_WINDOWS - -/* 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" (out - registers shifting into ins counts) upon subroutine calls and thus - there is no need to search more than one stack frame for it. */ - -#define REGISTER_IN_WINDOW_P(regnum) \ - ((regnum) >= 16 && (regnum) < 64) - -/* 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 Pyramid, 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 Pyramid, 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 - -/* Nonzero if register N requires conversion - from raw format to virtual format. */ - -#define REGISTER_CONVERTIBLE(N) 0 - -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ - bcopy ((FROM), (TO), 4); - -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ - bcopy ((FROM), (TO), 4); - -/* Return the GDB type object for the "standard" data type - of data in register N. */ - -#define REGISTER_VIRTUAL_TYPE(N) builtin_type_int - -/* FIXME: It seems impossible for both EXTRACT_RETURN_VALUE and - STORE_RETURN_VALUE to be correct. */ - -/* Store the address of the place in which to copy the structure the - subroutine will return. This is called from call_function. */ - -/****FIXME****/ -#define STORE_STRUCT_RETURN(ADDR, SP) \ - { write_register (TR0_REGNUM, (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. */ - -/* Note that on a register-windowing machine (eg, Pyr, SPARC), this is - where the value is found after the function call -- ie, it should - correspond to GNU CC's FUNCTION_VALUE rather than FUNCTION_OUTGOING_VALUE.*/ - -#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \ - bcopy (((int *)(REGBUF))+TR0_REGNUM, VALBUF, TYPE_LENGTH (TYPE)) - -/* Write into appropriate registers a function return value - of type TYPE, given in virtual format. */ -/* on pyrs, values are returned in */ - -#define STORE_RETURN_VALUE(TYPE,VALBUF) \ - write_register_bytes (REGISTER_BYTE(TR0_REGNUM), 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). */ -/* FIXME */ -#define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) \ - ( ((int *)(REGBUF)) [TR0_REGNUM]) - - -/* Describe the pointer in each stack frame to the previous stack frame - (its caller). */ - -#define EXTRA_FRAME_INFO \ - FRAME_ADDR bottom; \ - CORE_ADDR frame_cfp; \ - CORE_ADDR frame_window_addr; - -#define INIT_EXTRA_FRAME_INFO(fromleaf, fci) \ -do { \ - (fci)->frame_window_addr = (fci)->frame; \ - (fci)->bottom = \ - ((fci)->next ? \ - ((fci)->frame == (fci)->next_frame ? \ - (fci)->next->bottom : (fci)->next->frame) : \ - read_register (SP_REGNUM)); \ - (fci)->frame_cfp = \ - read_register (CFP_REGNUM); \ - /***fprintf (stderr, \ - "[[creating new frame for %0x,pc=%0x,csp=%0x]]\n", \ - (fci)->frame, (fci)->pc,(fci)->frame_cfp);*/ \ -} while (0); - -/* FRAME_CHAIN takes a frame's nominal address - and produces the frame's chain-pointer. - - However, if FRAME_CHAIN_VALID returns zero, - it means the given frame is the outermost one and has no caller. */ - -/* In the case of the pyr, the frame's nominal address is the address - of parameter register 0. The previous frame is found 32 words up. */ - -#define FRAME_CHAIN(thisframe) \ - ( (thisframe) -> frame - CONTROL_STACK_FRAME_SIZE) - -#define FRAME_CHAIN_VALID(chain, thisframe) \ - (chain != 0 && (outside_startup_file (FRAME_SAVED_PC (thisframe)))) - - /*((thisframe) >= CONTROL_STACK_ADDR))*/ - -/* 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. - - I do not understand what this means on a Pyramid, where functions - *always* have a control-stack frame, but may or may not have a - frame on the data stack. Since GBD uses the value of the - control stack pointer as its "address" of a frame, FRAMELESS - is always 1, so does not need to be defined. */ - - -/* Where is the PC for a specific frame */ - -#define FRAME_SAVED_PC(fi) \ - ((CORE_ADDR) (read_memory_integer ( (fi) -> frame + 60, 4))) - -/* There may be bugs in FRAME_ARGS_ADDRESS and FRAME_LOCALS_ADDRESS; - or there may be bugs in accessing the registers that break - their definitions. - Having the macros expand into functions makes them easier to debug. - When the bug is finally located, the inline macro defintions can - be un-#if 0ed, and frame_args_addr and frame_locals_address can - be deleted from pyr-dep.c */ - -/* If the argument is on the stack, it will be here. */ -#define FRAME_ARGS_ADDRESS(fi) \ - frame_args_addr(fi) - -#define FRAME_LOCALS_ADDRESS(fi) \ - frame_locals_address(fi) - -/* The following definitions doesn't seem to work. - I don't understand why. */ -#if 0 -#define FRAME_ARGS_ADDRESS(fi) \ - /*(FRAME_FP(fi) + (13*4))*/ (read_register (CFP_REGNUM)) - -#define FRAME_LOCALS_ADDRESS(fi) \ - ((fi)->frame +(16*4)) - -#endif /* 0 */ - -/* Return number of args passed to a frame. - Can return -1, meaning no way to tell. */ - -#define FRAME_NUM_ARGS(val, fi) (val = -1) - -/* 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. - - Note that on register window machines, we are currently making the - assumption that window registers are being saved somewhere in the - frame in which they are being used. If they are stored in an - inferior frame, find_saved_register will break. - - On pyrs, frames of window registers are stored contiguously on a - separate stack. All window registers are always stored. - The pc and psw (gr15 and gr14) are also always saved: the call - insn saves them in pr15 and pr14 of the new frame (tr15,tr14 of the - old frame). - The data-stack frame pointer (CFP) is only saved in functions which - allocate a (data)stack frame (with "adsf"). We detect them by - looking at the first insn of the procedure. - - Other non-window registers (gr0-gr11) are never saved. Pyramid's C - compiler and gcc currently ignore them, so it's not an issue. */ - -#define FRAME_FIND_SAVED_REGS(fi_p, frame_saved_regs) \ -{ register int regnum; \ - register CORE_ADDR pc; \ - register CORE_ADDR fn_start_pc; \ - register int first_insn; \ - register CORE_ADDR prev_cf_addr; \ - register int window_ptr; \ - FRAME fid = FRAME_INFO_ID (fi_p); \ - if (!fid) fatal ("Bad frame info struct in FRAME_FIND_SAVED_REGS"); \ - bzero (&(frame_saved_regs), sizeof (frame_saved_regs)); \ - \ - window_ptr = prev_cf_addr = FRAME_FP(fi_p); \ - \ - for (regnum = 16 ; regnum < 64; regnum++,window_ptr+=4) \ - { \ - (frame_saved_regs).regs[regnum] = window_ptr; \ - } \ - \ - /* In each window, psw, and pc are "saved" in tr14,tr15. */ \ - /*** psw is sometimes saved in gr12 (so sez ) */ \ - (frame_saved_regs).regs[PS_REGNUM] = FRAME_FP(fi_p) + (14*4); \ - \ -/*(frame_saved_regs).regs[PC_REGNUM] = (frame_saved_regs).regs[31];*/ \ - (frame_saved_regs).regs[PC_REGNUM] = FRAME_FP(fi_p) + ((15+32)*4); \ - \ - /* Functions that allocate a frame save sp *where*? */ \ -/*first_insn = read_memory_integer (get_pc_function_start ((fi_p)->pc),4); */ \ - \ - fn_start_pc = (get_pc_function_start ((fi_p)->pc)); \ - first_insn = read_memory_integer(fn_start_pc, 4); \ - \ - if (0x08 == ((first_insn >> 20) &0x0ff)) { \ - /* NB: because WINDOW_REGISTER_P(cfp) is false, a saved cfp \ - in this frame is only visible in this frame's callers. \ - That means the cfp we mark saved is my caller's cfp, ie pr13. \ - I don't understand why we don't have to do that for pc, too. */ \ - \ - (frame_saved_regs).regs[CFP_REGNUM] = FRAME_FP(fi_p)+(13*4); \ - \ - (frame_saved_regs).regs[SP_REGNUM] = \ - read_memory_integer (FRAME_FP(fi_p)+((13+32)*4),4); \ - } \ - \ -/* \ - *(frame_saved_regs).regs[CFP_REGNUM] = (frame_saved_regs).regs[61]; \ - * (frame_saved_regs).regs[SP_REGNUM] = \ - * read_memory_integer (FRAME_FP(fi_p)+((13+32)*4),4); \ - */ \ - \ - (frame_saved_regs).regs[CSP_REGNUM] = prev_cf_addr; \ -} - -/* Things needed for making the inferior call functions. */ -#if 0 -/* These are all lies. These macro definitions are appropriate for a - SPARC. On a pyramid, pushing a dummy frame will - surely involve writing the control stack pointer, - then saving the pc. This requires a privileged instruction. - Maybe one day Pyramid can be persuaded to add a syscall to do this. - Until then, we are out of luck. */ - -/* 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); \ - set_current_frame (read_register (FP_REGNUM)); } - -/* 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 */ - -/* 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; } -#endif /* 0 */ - -#define POP_FRAME \ - { error ("The return command is not supported on this machine."); } diff --git a/gdb/tm-rs6000.h b/gdb/tm-rs6000.h deleted file mode 100644 index 3b90fe3ce5b..00000000000 --- a/gdb/tm-rs6000.h +++ /dev/null @@ -1,455 +0,0 @@ -/* Parameters for target execution on an RS6000, for GDB, the GNU debugger. - Copyright (C) 1986, 1987, 1989, 1991 Free Software Foundation, Inc. - Contributed by IBM Corporation. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -extern int symtab_relocated; - -/* text addresses in a core file does not necessarily match to symbol table, - if symbol table relocation wasn't done yet. */ - -#define CORE_NEEDS_RELOCATION(PC) \ - if (!symtab_relocated && !inferior_pid && (PC) > 0x10000000) \ - (PC) -= (0x10000000 + text_adjustment (exec_bfd)); - -/* Conversion between a register number in stab string to actual register num. */ - -#define STAB_REG_TO_REGNUM(value) (value) - -/* return true if a given `pc' value is in `call dummy' function. */ - -#define PC_IN_CALL_DUMMY(STOP_PC, STOP_SP, STOP_FRAME_ADDR) \ - (STOP_SP < STOP_PC && STOP_PC < STACK_END_ADDR) - -/* For each symtab, we keep track of which BFD it came from. */ -#define EXTRA_SYMTAB_INFO \ - unsigned nonreloc:1; /* TRUE if non relocatable */ - -#define INIT_EXTRA_SYMTAB_INFO(symtab) \ - symtab->nonreloc = 0; \ - -extern unsigned int text_start, data_start; -extern int inferior_pid; -extern char *corefile; - -/* setpgrp() messes up controling terminal. The other version of it - requires libbsd.a. */ -#define setpgrp(XX,YY) setpgid (XX, YY) - -/* We are missing register descriptions in the system header files. Sigh! */ - -struct regs { - int gregs [32]; /* general purpose registers */ - int pc; /* program conter */ - int ps; /* processor status, or machine state */ -}; - -struct fp_status { - double fpregs [32]; /* floating GP registers */ -}; - -/* Define the byte order of the machine. */ - -#define TARGET_BYTE_ORDER BIG_ENDIAN - -/* Define this if the C compiler puts an underscore at the front - of external names before giving them to the linker. */ - -#undef NAMES_HAVE_UNDERSCORE - -/* 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) pc = skip_prologue (pc) - -/* If PC is in some function-call trampoline code, return the PC - where the function itself actually starts. If not, return NULL. */ - -#define SKIP_TRAMPOLINE_CODE(pc) skip_trampoline_code (pc) - -/* When a child process is just starting, we sneak in and relocate - the symbol table (and other stuff) after the dynamic linker has - figured out where they go. */ - -#define SOLIB_CREATE_INFERIOR_HOOK(PID) aixcoff_relocate_symtab (PID) - -/* When a target process or core-file has been attached, we sneak in - and figure out where the shared libraries have got to. */ - -#define SOLIB_ADD(a, b, c) aixcoff_relocate_symtab (inferior_pid) - -/* 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 - some instructions. */ - -extern char registers[]; - -#define SAVED_PC_AFTER_CALL(frame) \ - (*(int*)®isters[REGISTER_BYTE (LR_REGNUM)]) - -/*#define SAVED_PC_AFTER_CALL(frame) saved_pc_after_call(frame) */ - - -/* Address of end of stack space. */ - -#define STACK_END_ADDR 0x2ff80000 - -/* Stack grows downward. */ - -#define INNER_THAN < - -#if 0 -/* No, we shouldn't use this. push_arguments() should leave stack in a - proper alignment! */ -/* Stack has strict alignment. */ - -#define STACK_ALIGN(ADDR) (((ADDR)+7)&-8) -#endif - -/* This is how argumets pushed onto stack or passed in registers. */ - -#define PUSH_ARGUMENTS(nargs, args, sp, struct_return, struct_addr) \ - sp = push_arguments(nargs, args, sp, struct_return, struct_addr) - -/* Sequence of bytes for breakpoint instruction. */ - -#define BREAKPOINT {0x7d, 0x82, 0x10, 0x08} - -/* 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 - -/* Nonzero if instruction at PC is a return instruction. */ -/* Allow any of the return instructions, including a trapv and a return - from interrupt. */ - -#define ABOUT_TO_RETURN(pc) \ - ((read_memory_integer (pc, 4) & 0xfe8007ff) == 0x4e800020) - -/* Return 1 if P points to an invalid floating point value. */ - -#define INVALID_FLOAT(p, len) 0 /* Just a first guess; not checked */ - -/* Largest integer type */ - -#define LONGEST long - -/* Name of the builtin type for the LONGEST type above. */ - -#define BUILTIN_TYPE_LONGEST builtin_type_long - -/* Say how long (ordinary) registers are. */ - -#define REGISTER_TYPE long - -/* Number of machine registers */ - -#define NUM_REGS 71 - -/* Initializer for an array of names of registers. - There should be NUM_REGS strings in this initializer. */ - -#define REGISTER_NAMES \ - {"r0", "sp", "toc", "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", \ - "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \ - "f8", "f9", "f10","f11","f12","f13","f14","f15", \ - "f16","f17","f18","f19","f20","f21","f22","f23", \ - "f24","f25","f26","f27","f28","f29","f30","f31", \ - "pc", "ps", "cnd", "lr", "cnt", "xer", "mq" } - -/* 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 FP_REGNUM 1 /* Contains address of executing stack frame */ -#define SP_REGNUM 1 /* Contains address of top of stack */ -#define TOC_REGNUM 2 /* TOC register */ -#define FP0_REGNUM 32 /* Floating point register 0 */ -#define FPLAST_REGNUM 63 /* Last floating point register */ - -/* Special purpose registers... */ -/* P.S. keep these in the same order as in /usr/mstsave.h `mstsave' structure, for - easier processing */ - -#define PC_REGNUM 64 /* Program counter (instruction address %iar) */ -#define PS_REGNUM 65 /* Processor (or machine) status (%msr) */ -#define CR_REGNUM 66 /* Condition register */ -#define LR_REGNUM 67 /* Link register */ -#define CTR_REGNUM 68 /* Count register */ -#define XER_REGNUM 69 /* Fixed point exception registers */ -#define MQ_REGNUM 70 /* Multiply/quotient register */ - -#define FIRST_SP_REGNUM 64 /* first special register number */ -#define LAST_SP_REGNUM 70 /* last special register number */ - -/* Total amount of space needed to store our copies of the machine's - register state, the array `registers'. - - 32 4-byte gpr's - 32 8-byte fpr's - 7 4-byte special purpose registers, - - total 416 bytes. Keep some extra space for now, in case to add more. */ - -#define REGISTER_BYTES 420 - - -/* Index within `registers' of the first byte of the space for - register N. */ - -#define REGISTER_BYTE(N) \ - ( \ - ((N) > FPLAST_REGNUM) ? ((((N) - FPLAST_REGNUM -1) * 4) + 384)\ - :((N) >= FP0_REGNUM) ? ((((N) - FP0_REGNUM) * 8) + 128) \ - :((N) * 4) ) - -/* Number of bytes of storage in the actual machine representation - for register N. */ -/* Note that the unsigned cast here forces the result of the - subtractiion to very high positive values if N < FP0_REGNUM */ - -#define REGISTER_RAW_SIZE(N) (((unsigned)(N) - FP0_REGNUM) < 32 ? 8 : 4) - -/* Number of bytes of storage in the program's representation - for register N. On the RS6000, all regs are 4 bytes - except the floating point regs which are 8-byte doubles. */ - -#define REGISTER_VIRTUAL_SIZE(N) (((unsigned)(N) - FP0_REGNUM) < 32 ? 8 : 4) - -/* 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 - -/* convert a dbx stab register number (from `r' declaration) to a gdb REGNUM */ - -#define STAB_REG_TO_REGNUM(value) (value) - -/* Nonzero if register N requires conversion - from raw format to virtual format. */ - -#define REGISTER_CONVERTIBLE(N) ((N) >= FP0_REGNUM && (N) <= FPLAST_REGNUM) - -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ - bcopy ((FROM), (TO), REGISTER_RAW_SIZE (REGNUM)) - -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ - bcopy ((FROM), (TO), REGISTER_RAW_SIZE (REGNUM)) - -/* Return the GDB type object for the "standard" data type - of data in register N. */ - -#define REGISTER_VIRTUAL_TYPE(N) \ - (((unsigned)(N) - FP0_REGNUM) < 32 ? builtin_type_double : 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. */ -/* in RS6000, struct return addresses are passed as an extra parameter in r3. - In function return, callee is not responsible of returning this address back. - Since gdb needs to find it, we will store in a designated variable - `rs6000_struct_return_address'. */ - -extern unsigned int rs6000_struct_return_address; - -#define STORE_STRUCT_RETURN(ADDR, SP) \ - { write_register (3, (ADDR)); \ - rs6000_struct_return_address = (unsigned int)(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) \ - bcopy (REGBUF, VALBUF, TYPE_LENGTH (TYPE)) */ - -#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \ - extract_return_value(TYPE,REGBUF,VALBUF) - -/* Write into appropriate registers a function return value - of type TYPE, given in virtual format. */ - -#define STORE_RETURN_VALUE(TYPE,VALBUF) \ - printf ("FIXMEmgo! STORE_RETURN_VALUE not implemented yet!\n") - -/* 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) rs6000_struct_return_address - - -/* Do implement the attach and detach commands. */ - -#define ATTACH_DETACH /* FIXMEmgo! Not implemented yet! */ - - -/* 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. - - However, if FRAME_CHAIN_VALID returns zero, - it means the given frame is the outermost one and has no caller. */ - -/* In the case of the RS6000, the frame's nominal address - is the address of a 4-byte word containing the calling frame's address. */ - -#define FRAME_CHAIN(thisframe) \ - (outside_startup_file ((thisframe)->pc) ? \ - read_memory_integer ((thisframe)->frame, 4) :\ - 0) - -#define FRAME_CHAIN_VALID(chain, thisframe) \ - (chain != 0 && (outside_startup_file (FRAME_SAVED_PC (thisframe)))) - -/* 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. */ - -#define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \ - FRAMELESS = frameless_function_invocation (FI) - -/* Frameless function invocation in IBM RS/6000 is half-done. It perfectly - sets up a new frame, e.g. a new frame (in fact stack) pointer, etc, but it - doesn't save the %pc. In the following, even though it is considered a - frameless invocation, we still need to walk one frame up. */ - -#define INIT_EXTRA_FRAME_INFO(fromleaf, fi) \ - if (fromleaf) { \ - int tmp = 0; \ - read_memory ((fi)->frame, &tmp, sizeof (int)); \ - (fi)->frame = tmp; \ - } - -#define FRAME_SAVED_PC(FRAME) \ - read_memory_integer (read_memory_integer ((FRAME)->frame, 4)+8, 4) - -#define FRAME_ARGS_ADDRESS(fi) ((fi)->frame) - -#define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame) - -/* Set VAL to the number of args passed to frame described by FI. - Can set VAL to -1, meaning no way to tell. */ - -/* We can't tell how many args there are - now that the C compiler delays popping them. */ - -#define FRAME_NUM_ARGS(val,fi) (val = -1) - -/* Return number of bytes at start of arglist that are not really args. */ - -#define FRAME_ARGS_SKIP 8 /* Not sure on this. FIXMEmgo */ - -/* 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) \ - printf ("FIXMEmgo! FRAME_FIND_SAVED_REGS() not implemented!\n") - -/* Things needed for making the inferior call functions. */ - -/* Push an empty stack frame, to record the current PC, etc. */ -/* Change these names into rs6k_{push, pop}_frame(). FIXMEmgo. */ - -#define PUSH_DUMMY_FRAME push_dummy_frame () - -/* Discard from the stack the innermost frame, - restoring all saved registers. */ - -#define POP_FRAME pop_frame () - -/* This sequence of words is the instructions: - - mflr r0 // 0x7c0802a6 - // save fpr's - stfd r?, num(r1) // 0xd8010000 there should be 32 of this?? - // save gpr's - stm r0, num(r1) // 0xbc010000 - stu r1, num(r1) // 0x94210000 - - // the function we want to branch might be in a different load - // segment. reset the toc register. Note that the actual toc address - // will be fix by fix_call_dummy () along with function address. - - st r2, 0x14(r1) // 0x90410014 save toc register - liu r2, 0x1234 // 0x3c401234 reset a new toc value 0x12345678 - oril r2, r2,0x5678 // 0x60425678 - - // load absolute address 0x12345678 to r0 - liu r0, 0x1234 // 0x3c001234 - oril r0, r0,0x5678 // 0x60005678 - mtctr r0 // 0x7c0903a6 ctr <- r0 - bctrl // 0x4e800421 jump subroutine 0x12345678 (%ctr) - cror 0xf, 0xf, 0xf // 0x4def7b82 - brpt // 0x7d821008, breakpoint - cror 0xf, 0xf, 0xf // 0x4def7b82 (for 8 byte alignment) - - - We actually start executing by saving the toc register first, since the pushing - of the registers is done by PUSH_DUMMY_FRAME. If this were real code, - the arguments for the function called by the `bctrl' would be pushed - between the `stu' and the `bctrl', and we could allow it to execute through. - But the arguments have to be pushed by GDB after the PUSH_DUMMY_FRAME is done, - and we cannot allow to push the registers again. -*/ - -#define CALL_DUMMY {0x7c0802a6, 0xd8010000, 0xbc010000, 0x94210000, \ - 0x90410014, 0x3c401234, 0x60425678, \ - 0x3c001234, 0x60005678, 0x7c0903a6, 0x4e800421, \ - 0x4def7b82, 0x7d821008, 0x4def7b82 } - - -/* keep this as multiple of 8 (%sp requires 8 byte alignment) */ -#define CALL_DUMMY_LENGTH 56 - -#define CALL_DUMMY_START_OFFSET 16 - -/* 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, using_gcc) \ - fix_call_dummy(dummyname, pc, fun, nargs, type) diff --git a/gdb/tm-sparc.h b/gdb/tm-sparc.h deleted file mode 100644 index 15d214b48a7..00000000000 --- a/gdb/tm-sparc.h +++ /dev/null @@ -1,588 +0,0 @@ -/* Parameters for target machine of Sun 4, for GDB, the GNU debugger. - Copyright (C) 1986, 1987, 1989, 1991 Free Software Foundation, Inc. - Contributed by Michael Tiemann (tiemann@mcc.com) - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#define TARGET_BYTE_ORDER BIG_ENDIAN - -/* Floating point is IEEE compatible. */ -#define IEEE_FLOAT - -/* Define this if the C compiler puts an underscore at the front - of external names before giving them to the linker. */ - -#define NAMES_HAVE_UNDERSCORE - -/* When passing a structure to a function, Sun cc passes the address - in a register, not the structure itself. It (under SunOS4) creates - two symbols, so we get a LOC_ARG saying the address is on the stack - (a lie, and a serious one since we don't know which register to - use), and a LOC_REGISTER saying that the struct is in a register - (sort of a lie, but fixable with REG_STRUCT_HAS_ADDR). Gcc version - two (as of 1.92) behaves like sun cc, but I don't know how we can - distinguish between gcc version 1 and gcc version 2. - - This still doesn't work if the argument is not one passed in a - register (i.e. it's the 7th or later argument). */ -#define REG_STRUCT_HAS_ADDR(gcc_p) (!(gcc_p)) -#define STRUCT_ARG_SYM_GARBAGE(gcc_p) (!(gcc_p)) - -/* If Pcc says that a parameter is a short, it's a short. This is - because the parameter does get passed in in a register as an int, - but pcc puts it onto the stack frame as a short (not nailing - whatever else might be there. I'm not sure that I consider this - swift. Sigh.) - - No, don't do this. The problem here is that pcc says that the - argument is in the upper half of the word reserved on the stack, - but puts it in the lower half. */ -/* #define BELIEVE_PCC_PROMOTION 1 */ -/* OK, I've added code to dbxread.c to deal with this case. */ -#define BELIEVE_PCC_PROMOTION_TYPE - -/* 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. 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(pc) \ - { pc = skip_prologue (pc, 0); } -#define SKIP_PROLOGUE_FRAMELESS_P(pc) \ - { pc = skip_prologue (pc, 1); } -extern CORE_ADDR skip_prologue (); - -/* 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 - some instructions. */ - -/* On the Sun 4 under SunOS, the compile will leave a fake insn which - encodes the structure size being returned. If we detect such - a fake insn, step past it. */ - -#define PC_ADJUST(pc) sparc_pc_adjust(pc) -extern CORE_ADDR sparc_pc_adjust(); - -#define SAVED_PC_AFTER_CALL(frame) PC_ADJUST (read_register (RP_REGNUM)) - -/* Address of the end of stack space. We get this from the system - include files. */ -#include -#include -#define STACK_END_ADDR USRSTACK - -#define INNER_THAN < - -/* Stack has strict alignment. */ - -#define STACK_ALIGN(ADDR) (((ADDR)+7)&-8) - -/* Sequence of bytes for breakpoint instruction. */ - -#define BREAKPOINT {0x91, 0xd0, 0x20, 0x01} - -/* 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 - -/* Nonzero if instruction at PC is a return instruction. */ -/* For SPARC, this is either a "jmpl %o7+8,%g0" or "jmpl %i7+8,%g0". - - Note: this does not work for functions returning structures under SunOS. */ -#define ABOUT_TO_RETURN(pc) \ - ((read_memory_integer (pc, 4)|0x00040000) == 0x81c7e008) - -/* Return 1 if P points to an invalid floating point value. */ - -#define INVALID_FLOAT(p, len) 0 /* Just a first guess; not checked */ - -/* Say how long (ordinary) registers are. */ - -#define REGISTER_TYPE long - -/* Number of machine registers */ - -#define NUM_REGS 72 - -/* Initializer for an array of names of registers. - There should be NUM_REGS strings in this initializer. */ - -#define REGISTER_NAMES \ -{ "g0", "g1", "g2", "g3", "g4", "g5", "g6", "g7", \ - "o0", "o1", "o2", "o3", "o4", "o5", "sp", "o7", \ - "l0", "l1", "l2", "l3", "l4", "l5", "l6", "l7", \ - "i0", "i1", "i2", "i3", "i4", "i5", "fp", "i7", \ - \ - "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \ - "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", \ - "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23", \ - "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31", \ - \ - "y", "psr", "wim", "tbr", "pc", "npc", "fpsr", "cpsr" }; - -/* 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 G0_REGNUM 0 /* %g0 */ -#define G1_REGNUM 1 /* %g1 */ -#define O0_REGNUM 8 /* %o0 */ -#define SP_REGNUM 14 /* Contains address of top of stack, \ - which is also the bottom of the frame. */ -#define RP_REGNUM 15 /* Contains return address value, *before* \ - any windows get switched. */ -#define O7_REGNUM 15 /* Last local reg not saved on stack frame */ -#define L0_REGNUM 16 /* First local reg that's saved on stack frame - rather than in machine registers */ -#define I0_REGNUM 24 /* %i0 */ -#define FP_REGNUM 30 /* Contains address of executing stack frame */ -#define I7_REGNUM 31 /* Last local reg saved on stack frame */ -#define FP0_REGNUM 32 /* Floating point register 0 */ -#define Y_REGNUM 64 /* Temp register for multiplication, etc. */ -#define PS_REGNUM 65 /* Contains processor status */ -#define WIM_REGNUM 66 /* Window Invalid Mask (not really supported) */ -#define TBR_REGNUM 67 /* Trap Base Register (not really supported) */ -#define PC_REGNUM 68 /* Contains program counter */ -#define NPC_REGNUM 69 /* Contains next PC */ -#define FPS_REGNUM 70 /* Floating point status register */ -#define CPS_REGNUM 71 /* Coprocessor status register */ - -/* Total amount of space needed to store our copies of the machine's - register state, the array `registers'. */ -#define REGISTER_BYTES (32*4+32*4+8*4) - -/* Index within `registers' of the first byte of the space for - register N. */ -/* ?? */ -#define REGISTER_BYTE(N) ((N)*4) - -/* The SPARC processor has register windows. */ - -#define HAVE_REGISTER_WINDOWS - -/* 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" (out - registers shifting into ins counts) upon subroutine calls and thus - there is no need to search more than one stack frame for it. */ - -#define REGISTER_IN_WINDOW_P(regnum) \ - ((regnum) >= 8 && (regnum) < 32) - -/* Number of bytes of storage in the actual machine representation - for register N. */ - -/* On the SPARC, 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 SPARC, all regs are 4 bytes. */ - -#define REGISTER_VIRTUAL_SIZE(N) (4) - -/* 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. */ - -#define REGISTER_CONVERTIBLE(N) (0) - -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ -{ bcopy ((FROM), (TO), 4); } - -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ -{ bcopy ((FROM), (TO), 4); } - -/* Return the GDB type object for the "standard" data type - of data in register N. */ - -#define REGISTER_VIRTUAL_TYPE(N) \ - ((N) < 32 ? builtin_type_int : (N) < 64 ? builtin_type_float : \ - builtin_type_int) - -/* Writing to %g0 is a noop (not an error or exception or anything like - that, however). */ - -#define CANNOT_STORE_REGISTER(regno) ((regno) == G0_REGNUM) - -/* 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) \ - { target_write_memory ((SP)+(16*4), (char *)&(ADDR), 4); } - -/* 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) \ - { \ - if (TYPE_CODE (TYPE) == TYPE_CODE_FLT) \ - { \ - bcopy (((int *)(REGBUF))+FP0_REGNUM, \ - (VALBUF), TYPE_LENGTH(TYPE)); \ - } \ - else \ - bcopy ((char *)(REGBUF) + 4 * 8 + \ - (TYPE_LENGTH(TYPE) >= 4 ? 0 : 4 - TYPE_LENGTH(TYPE)), \ - (VALBUF), TYPE_LENGTH(TYPE)); \ - } - -/* Write into appropriate registers a function return value - of type TYPE, given in virtual format. */ -/* On sparc, values are returned in register %o0. */ -#define STORE_RETURN_VALUE(TYPE,VALBUF) \ - { \ - if (TYPE_CODE (TYPE) == TYPE_CODE_FLT) \ - /* Floating-point values are returned in the register pair */ \ - /* formed by %f0 and %f1 (doubles are, anyway). */ \ - write_register_bytes (REGISTER_BYTE (FP0_REGNUM), (VALBUF), \ - TYPE_LENGTH (TYPE)); \ - else \ - /* Other values are returned in register %o0. */ \ - write_register_bytes (REGISTER_BYTE (O0_REGNUM), (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) \ - (sparc_extract_struct_value_address (REGBUF)) -CORE_ADDR sparc_extract_struct_value_address ( -#ifdef __STDC__ - char [REGISTER_BYTES] -#endif - ); - - -/* Describe the pointer in each stack frame to the previous stack frame - (its caller). */ - -/* If you're not compiling this on a sun, you'll have to get a copy - of (also known as ). */ -#include - -/* FRAME_CHAIN takes a frame's nominal address - and produces the frame's chain-pointer. - - However, if FRAME_CHAIN_VALID returns zero, - it means the given frame is the outermost one and has no caller. */ - -/* In the case of the Sun 4, the frame-chain's nominal address - is held in the frame pointer register. - - On the Sun4, the frame (in %fp) is %sp for the previous frame. - From the previous frame's %sp, we can find the previous frame's - %fp: it is in the save area just above the previous frame's %sp. - - If we are setting up an arbitrary frame, we'll need to know where - it ends. Hence the following. This part of the frame cache - structure should be checked before it is assumed that this frame's - bottom is in the stack pointer. - - If there isn't a frame below this one, the bottom of this frame is - in the stack pointer. - - If there is a frame below this one, and the frame pointers are - identical, it's a leaf frame and the bottoms are the same also. - - Otherwise the bottom of this frame is the top of the next frame. */ - -#define EXTRA_FRAME_INFO FRAME_ADDR bottom; -#define INIT_EXTRA_FRAME_INFO(fromleaf, fci) \ - (fci)->bottom = \ - ((fci)->next ? \ - ((fci)->frame == (fci)->next_frame ? \ - (fci)->next->bottom : (fci)->next->frame) : \ - read_register (SP_REGNUM)); - -#define FRAME_CHAIN(thisframe) (sparc_frame_chain (thisframe)) -CORE_ADDR sparc_frame_chain (); - -#define FRAME_CHAIN_VALID(chain, thisframe) \ - (chain != 0 && (outside_startup_file (FRAME_SAVED_PC (thisframe)))) - -/* 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. */ -#define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \ - (FRAMELESS) = frameless_look_for_prologue(FI) - -/* Where is the PC for a specific frame */ - -#define FRAME_SAVED_PC(FRAME) frame_saved_pc (FRAME) -CORE_ADDR frame_saved_pc (); - -/* If the argument is on the stack, it will be here. */ -#define FRAME_ARGS_ADDRESS(fi) ((fi)->frame) - -#define FRAME_STRUCT_ARGS_ADDRESS(fi) ((fi)->frame) - -#define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame) - -/* Set VAL to the number of args passed to frame described by FI. - Can set VAL to -1, meaning no way to tell. */ - -/* We can't tell how many args there are - now that the C compiler delays popping them. */ -#define FRAME_NUM_ARGS(val,fi) (val = -1) - -/* Return number of bytes at start of arglist that are not really args. */ - -#define FRAME_ARGS_SKIP 68 - -/* Put here the code to store, into a struct frame_saved_regs, - the addresses of the saved registers of frame described by FRAME_INFO. - The actual code is in sparc-tdep.c so we can debug it sanely. */ - -#define FRAME_FIND_SAVED_REGS(fi, frame_saved_regs) \ - sparc_frame_find_saved_regs ((fi), &(frame_saved_regs)) -extern void sparc_frame_find_saved_regs (); - -/* Things needed for making the inferior call functions. */ -/* - * First of all, let me give my opinion of what the DUMMY_FRAME - * actually looks like. - * - * | | - * | | - * + - - - - - - - - - - - - - - - - +<-- fp (level 0) - * | | - * | | - * | | - * | | - * | Frame of innermost program | - * | function | - * | | - * | | - * | | - * | | - * | | - * |---------------------------------|<-- sp (level 0), fp (c) - * | | - * DUMMY | fp0-31 | - * | | - * | ------ |<-- fp - 0x80 - * FRAME | g0-7 |<-- fp - 0xa0 - * | i0-7 |<-- fp - 0xc0 - * | other |<-- fp - 0xe0 - * | ? | - * | ? | - * |---------------------------------|<-- sp' = fp - 0x140 - * | | - * xcution start | | - * sp' + 0x94 -->| CALL_DUMMY (x code) | - * | | - * | | - * |---------------------------------|<-- sp'' = fp - 0x200 - * | align sp to 8 byte boundary | - * | ==> args to fn <== | - * Room for | | - * i & l's + agg | CALL_DUMMY_STACK_ADJUST = 0x0x44| - * |---------------------------------|<-- final sp (variable) - * | | - * | Where function called will | - * | build frame. | - * | | - * | | - * - * I understand everything in this picture except what the space - * between fp - 0xe0 and fp - 0x140 is used for. Oh, and I don't - * understand why there's a large chunk of CALL_DUMMY that never gets - * executed (its function is superceeded by PUSH_DUMMY_FRAME; they - * are designed to do the same thing). - * - * PUSH_DUMMY_FRAME saves the registers above sp' and pushes the - * register file stack down one. - * - * call_function then writes CALL_DUMMY, pushes the args onto the - * stack, and adjusts the stack pointer. - * - * run_stack_dummy then starts execution (in the middle of - * CALL_DUMMY, as directed by call_function). - */ - -/* Push an empty stack frame, to record the current PC, etc. */ - -#define PUSH_DUMMY_FRAME sparc_push_dummy_frame () -#define POP_FRAME sparc_pop_frame () - -void sparc_push_dummy_frame (), sparc_pop_frame (); -/* This sequence of words is the instructions - - save %sp,-0x140,%sp - std %f30,[%fp-0x08] - std %f28,[%fp-0x10] - std %f26,[%fp-0x18] - std %f24,[%fp-0x20] - std %f22,[%fp-0x28] - std %f20,[%fp-0x30] - std %f18,[%fp-0x38] - std %f16,[%fp-0x40] - std %f14,[%fp-0x48] - std %f12,[%fp-0x50] - std %f10,[%fp-0x58] - std %f8,[%fp-0x60] - std %f6,[%fp-0x68] - std %f4,[%fp-0x70] - std %f2,[%fp-0x78] - std %f0,[%fp-0x80] - std %g6,[%fp-0x88] - std %g4,[%fp-0x90] - std %g2,[%fp-0x98] - std %g0,[%fp-0xa0] - std %i6,[%fp-0xa8] - std %i4,[%fp-0xb0] - std %i2,[%fp-0xb8] - std %i0,[%fp-0xc0] - nop ! stcsr [%fp-0xc4] - nop ! stfsr [%fp-0xc8] - nop ! wr %npc,[%fp-0xcc] - nop ! wr %pc,[%fp-0xd0] - rd %tbr,%o0 - st %o0,[%fp-0xd4] - rd %wim,%o1 - st %o0,[%fp-0xd8] - rd %psr,%o0 - st %o0,[%fp-0xdc] - rd %y,%o0 - st %o0,[%fp-0xe0] - - /..* The arguments are pushed at this point by GDB; - no code is needed in the dummy for this. - The CALL_DUMMY_START_OFFSET gives the position of - the following ld instruction. *../ - - ld [%sp+0x58],%o5 - ld [%sp+0x54],%o4 - ld [%sp+0x50],%o3 - ld [%sp+0x4c],%o2 - ld [%sp+0x48],%o1 - call 0x00000000 - ld [%sp+0x44],%o0 - nop - ta 1 - nop - - note that this is 192 bytes, which is a multiple of 8 (not only 4) bytes. - note that the `call' insn is a relative, not an absolute call. - note that the `nop' at the end is needed to keep the trap from - clobbering things (if NPC pointed to garbage instead). - -We actually start executing at the `sethi', since the pushing of the -registers (as arguments) is done by PUSH_DUMMY_FRAME. If this were -real code, the arguments for the function called by the CALL would be -pushed between the list of ST insns and the CALL, and we could allow -it to execute through. But the arguments have to be pushed by GDB -after the PUSH_DUMMY_FRAME is done, and we cannot allow these ST -insns to be performed again, lest the registers saved be taken for -arguments. */ - -#define CALL_DUMMY { 0x9de3bee0, 0xfd3fbff8, 0xf93fbff0, 0xf53fbfe8, \ - 0xf13fbfe0, 0xed3fbfd8, 0xe93fbfd0, 0xe53fbfc8, \ - 0xe13fbfc0, 0xdd3fbfb8, 0xd93fbfb0, 0xd53fbfa8, \ - 0xd13fbfa0, 0xcd3fbf98, 0xc93fbf90, 0xc53fbf88, \ - 0xc13fbf80, 0xcc3fbf78, 0xc83fbf70, 0xc43fbf68, \ - 0xc03fbf60, 0xfc3fbf58, 0xf83fbf50, 0xf43fbf48, \ - 0xf03fbf40, 0x01000000, 0x01000000, 0x01000000, \ - 0x01000000, 0x91580000, 0xd027bf50, 0x93500000, \ - 0xd027bf4c, 0x91480000, 0xd027bf48, 0x91400000, \ - 0xd027bf44, 0xda03a058, 0xd803a054, 0xd603a050, \ - 0xd403a04c, 0xd203a048, 0x40000000, 0xd003a044, \ - 0x01000000, 0x91d02001, 0x01000000, 0x01000000} - -#define CALL_DUMMY_LENGTH 192 - -#define CALL_DUMMY_START_OFFSET 148 - -#define CALL_DUMMY_STACK_ADJUST 68 - -/* Insert the specified number of args and function address - into a call sequence of the above form stored at DUMMYNAME. - - For structs and unions, if the function was compiled with Sun cc, - it expects 'unimp' after the call. But gcc doesn't use that - (twisted) convention. So leave a nop there for gcc (FIX_CALL_DUMMY - can assume it is operating on a pristine CALL_DUMMY, not one that - has already been customized for a different function). */ - -#define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p) \ -{ \ - *(int *)((char *) dummyname+168) = (0x40000000|((fun-(pc+168))>>2)); \ - if (!gcc_p \ - && (TYPE_CODE (type) == TYPE_CODE_STRUCT \ - || TYPE_CODE (type) == TYPE_CODE_UNION)) \ - *(int *)((char *) dummyname+176) = (TYPE_LENGTH (type) & 0x1fff); \ -} - - -/* Sparc has no reliable single step ptrace call */ - -#define NO_SINGLE_STEP 1 -extern void single_step (); - -/* We need two arguments (in general) to the "info frame" command. - Note that the definition of this macro implies that there exists a - function "setup_arbitrary_frame" in sparc-tdep.c */ - -#define FRAME_SPECIFICATION_DYADIC - -/* To print every pair of float registers as a double, we use this hook. */ - -#define PRINT_REGISTER_HOOK(regno) \ - if (((regno) >= FP0_REGNUM) \ - && ((regno) < FP0_REGNUM + 32) \ - && (0 == (regno & 1))) { \ - char doublereg[8]; /* two float regs */ \ - if (!read_relative_register_raw_bytes (i , doublereg ) \ - && !read_relative_register_raw_bytes (i+1, doublereg+4)) { \ - printf("\t"); \ - print_floating (doublereg, builtin_type_double, stdout); \ - } \ - } - diff --git a/gdb/tm-sun2.h b/gdb/tm-sun2.h deleted file mode 100644 index 38ce53ac3b3..00000000000 --- a/gdb/tm-sun2.h +++ /dev/null @@ -1,32 +0,0 @@ -/* Parameters for execution on a Sun, for GDB, the GNU debugger. - Copyright (C) 1986, 1987, 1989, 199 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Define this if the C compiler puts an underscore at the front - of external names before giving them to the linker. */ - -#define NAMES_HAVE_UNDERSCORE - -/* Address of the end of stack space. We get this from the system - include files. */ - -#include -#include -#define STACK_END_ADDR USRSTACK - -#include "tm-68k.h" diff --git a/gdb/tm-sun2os4.h b/gdb/tm-sun2os4.h deleted file mode 100644 index 236ee5cc6ef..00000000000 --- a/gdb/tm-sun2os4.h +++ /dev/null @@ -1,20 +0,0 @@ -/* Copyright (C) 1990, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include "tm-sun2.h" -#include "tm-sunos.h" diff --git a/gdb/tm-sun3.h b/gdb/tm-sun3.h deleted file mode 100644 index d7e403fccbf..00000000000 --- a/gdb/tm-sun3.h +++ /dev/null @@ -1,39 +0,0 @@ -/* Parameters for execution on a Sun, for GDB, the GNU debugger. - Copyright (C) 1986, 1987, 1989 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#define HAVE_68881 - -/* Let native-versus-cross support code know we are targeting sun3, - and modify registers to include sun3 fpustate register. */ - -#define GDB_TARGET_IS_SUN3 1 - -/* Define this if the C compiler puts an underscore at the front - of external names before giving them to the linker. */ - -#define NAMES_HAVE_UNDERSCORE - -/* Address of the end of stack space. We get this from the system - include files. */ - -#include -#include -#define STACK_END_ADDR USRSTACK - -#include "tm-68k.h" diff --git a/gdb/tm-sun386.h b/gdb/tm-sun386.h deleted file mode 100644 index 0af69c0b1a2..00000000000 --- a/gdb/tm-sun386.h +++ /dev/null @@ -1,294 +0,0 @@ -/* Parameters for execution on a Sun 386i, for GDB, the GNU debugger. - Copyright (C) 1986, 1987, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#define TARGET_BYTE_ORDER LITTLE_ENDIAN - -#ifndef sun386 -#define sun386 -#endif -#define GDB_TARGET_IS_SUN386 1 -#define SUNOS4 -#define USE_MACHINE_REG_H - -/* Perhaps some day this will work even without the following #define */ -#define COFF_ENCAPSULATE - -#ifdef COFF_ENCAPSULATE -#define NAMES_HAVE_UNDERSCORE -/* Avoid conflicts between "a.out.gnu.h" and */ -#define _EXEC_ -#endif - -/* sun386 ptrace seems unable to change the frame pointer */ -#define PTRACE_FP_BUG - -/* 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(frompc) {(frompc) = i386_skip_prologue((frompc));} - -/* 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) \ - (read_memory_integer (read_register (SP_REGNUM), 4)) - -/* Address of end of stack space. */ - -#define STACK_END_ADDR 0xfc000000 - -/* Stack grows downward. */ - -#define INNER_THAN < - -/* Sequence of bytes for breakpoint instruction. */ - -#define BREAKPOINT {0xcc} - -/* 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 1 - -/* Nonzero if instruction at PC is a return instruction. */ - -#define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 1) == 0xc3) - -/* Return 1 if P points to an invalid floating point value. - LEN is the length in bytes -- not relevant on the 386. */ - -#define INVALID_FLOAT(p, len) (0) - -/* Largest integer type */ -#define LONGEST long - -/* Name of the builtin type for the LONGEST type above. */ -#define BUILTIN_TYPE_LONGEST builtin_type_long - -/* Say how long (ordinary) registers are. */ - -#define REGISTER_TYPE long - -/* Number of machine registers */ - -#define NUM_REGS 35 - -/* Initializer for an array of names of registers. - There should be NUM_REGS strings in this initializer. */ - -/* the order of the first 8 registers must match the compiler's - * numbering scheme (which is the same as the 386 scheme) - * also, this table must match regmap in i386-pinsn.c. - */ -#define REGISTER_NAMES { "gs", "fs", "es", "ds", \ - "edi", "esi", "ebp", "esp", \ - "ebx", "edx", "ecx", "eax", \ - "retaddr", "trapnum", "errcode", "ip", \ - "cs", "ps", "sp", "ss", \ - "fst0", "fst1", "fst2", "fst3", \ - "fst4", "fst5", "fst6", "fst7", \ - "fctrl", "fstat", "ftag", "fip", \ - "fcs", "fopoff", "fopsel" \ - } - -/* 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 FP_REGNUM 6 /* Contains address of executing stack frame */ -#define SP_REGNUM 18 /* Contains address of top of stack */ -#define PS_REGNUM 17 /* Contains processor status */ -#define PC_REGNUM 15 /* Contains program counter */ -#define FP0_REGNUM 20 /* Floating point register 0 */ -#define FPC_REGNUM 28 /* 80387 control register */ - -/* Total amount of space needed to store our copies of the machine's - register state, the array `registers'. */ -#define REGISTER_BYTES (20*4+8*10+7*4) - -/* Index within `registers' of the first byte of the space for - register N. */ - -#define REGISTER_BYTE(N) \ - ((N) >= FPC_REGNUM ? (((N) - FPC_REGNUM) * 4) + 160 \ - : (N) >= FP0_REGNUM ? (((N) - FP0_REGNUM) * 10) + 80 \ - : (N) * 4) - -/* Number of bytes of storage in the actual machine representation - for register N. */ - -#define REGISTER_RAW_SIZE(N) (((unsigned)((N) - FP0_REGNUM)) < 8 ? 10 : 4) - -/* Number of bytes of storage in the program's representation - for register N. */ - -#define REGISTER_VIRTUAL_SIZE(N) (((unsigned)((N) - FP0_REGNUM)) < 8 ? 8 : 4) - -/* Largest value REGISTER_RAW_SIZE can have. */ - -#define MAX_REGISTER_RAW_SIZE 10 - -/* 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. */ - -#define REGISTER_CONVERTIBLE(N) (((unsigned)((N) - FP0_REGNUM)) < 8) - -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ -{ if ((REGNUM) >= FP0_REGNUM && (REGNUM) < FPC_REGNUM) \ - i387_to_double ((FROM), (TO)); \ - else \ - bcopy ((FROM), (TO), 4); } - -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ -{ if ((REGNUM) >= FP0_REGNUM && (REGNUM) < FPC_REGNUM) \ - double_to_i387 ((FROM), (TO)); \ - else \ - bcopy ((FROM), (TO), 4); } - -/* Return the GDB type object for the "standard" data type - of data in register N. */ - -#define REGISTER_VIRTUAL_TYPE(N) \ - (((unsigned)((N) - FP0_REGNUM)) < 8 ? builtin_type_double : 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) \ - { (SP) -= sizeof (ADDR); \ - write_memory ((SP), &(ADDR), sizeof (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) \ - bcopy (REGBUF + REGISTER_BYTE (TYPE_CODE (TYPE) == TYPE_CODE_FLT ? FP0_REGNUM : 11), VALBUF, 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 (REGISTER_BYTE (TYPE_CODE (TYPE) == TYPE_CODE_FLT ? FP0_REGNUM : 11), 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. - - However, if FRAME_CHAIN_VALID returns zero, - it means the given frame is the outermost one and has no caller. */ - -#define FRAME_CHAIN(thisframe) \ - (outside_startup_file ((thisframe)->pc) ? \ - read_memory_integer ((thisframe)->frame, 4) :\ - 0) - -#define FRAME_CHAIN_VALID(chain, thisframe) \ - (chain != 0 && (outside_startup_file (FRAME_SAVED_PC (thisframe)))) - -/* 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. */ -#define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \ -{ (FRAMELESS) = frameless_look_for_prologue (FI); } - -#define FRAME_SAVED_PC(FRAME) (read_memory_integer ((FRAME)->frame + 4, 4)) - -#define FRAME_ARGS_ADDRESS(fi) ((fi)->frame) - -#define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame) - -/* Return number of args passed to a frame. - Can return -1, meaning no way to tell. */ - -#define FRAME_NUM_ARGS(numargs, fi) (numargs) = i386_frame_num_args(fi) - -/* Return number of bytes at start of arglist that are not really args. */ - -#define FRAME_ARGS_SKIP 8 - -/* 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) \ -{ i386_frame_find_saved_regs ((frame_info), &(frame_saved_regs)); } - - -/* Things needed for making the inferior call functions. */ - -/* Push an empty stack frame, to record the current PC, etc. */ - -#define PUSH_DUMMY_FRAME { i386_push_dummy_frame (); } - -/* Discard from the stack the innermost frame, restoring all registers. */ - -#define POP_FRAME { i386_pop_frame (); } - -/* this is - * call 11223344 (32 bit relative) - * int3 - */ - -#define CALL_DUMMY { 0x223344e8, 0xcc11 } - -#define CALL_DUMMY_LENGTH 8 - -#define CALL_DUMMY_START_OFFSET 0 /* Start execution at beginning of dummy */ - -/* 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) \ -{ \ - *(int *)((char *)(dummyname) + 1) = (int)(fun) - (pc) - 5; \ -} diff --git a/gdb/tm-sun3os4.h b/gdb/tm-sun3os4.h deleted file mode 100644 index ab1f4fedc5a..00000000000 --- a/gdb/tm-sun3os4.h +++ /dev/null @@ -1,20 +0,0 @@ -/* Copyright (C) 1990, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include "tm-sun3.h" -#include "tm-sunos.h" diff --git a/gdb/tm-sun4os4.h b/gdb/tm-sun4os4.h deleted file mode 100644 index 6a5ad193283..00000000000 --- a/gdb/tm-sun4os4.h +++ /dev/null @@ -1,24 +0,0 @@ -/* Macro definitions for GDB for a Sun 4 running sunos 4. - Copyright (C) 1989, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include "tm-sparc.h" -#include "tm-sunos.h" - -#undef STACK_END_ADDRESS -#define STACK_END_ADDRESS 0xf8000000 diff --git a/gdb/tm-sunos.h b/gdb/tm-sunos.h deleted file mode 100644 index 3abfe9bfa20..00000000000 --- a/gdb/tm-sunos.h +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright (C) 1990, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* This is for SunOS version 4, not for earlier versions. */ - -#define CLEAR_SOLIB clear_solib -extern void clear_solib (); - -#define SOLIB_ADD(filename, from_tty, targ) solib_add (filename, from_tty, targ) -extern void solib_add (); - -#define SOLIB_CREATE_INFERIOR_HOOK solib_create_inferior_hook -extern void solib_create_inferior_hook(); - -/* If we can't set a breakpoint, and it's in a shared library, just - disable it. */ -#define DISABLE_UNSETTABLE_BREAK(addr) solib_address(addr) -extern int solib_address (); /* solib.c */ diff --git a/gdb/tm-svr4.h b/gdb/tm-svr4.h deleted file mode 100755 index ed142142b8d..00000000000 --- a/gdb/tm-svr4.h +++ /dev/null @@ -1,21 +0,0 @@ -/* Macro definitions for GDB on all SVR4 target systems. - Copyright (C) 1991, Free Software Foundation, Inc. - Written by Fred Fish at Cygnus Support (fnf@cygint) - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Currently empty */ diff --git a/gdb/tm-symmetry.h b/gdb/tm-symmetry.h deleted file mode 100644 index cf5af29fe27..00000000000 --- a/gdb/tm-symmetry.h +++ /dev/null @@ -1,379 +0,0 @@ -/* Definitions to make GDB run on a Sequent Symmetry under dynix 3.0, - with Weitek 1167 and i387 support. - Copyright (C) 1986, 1987, 1989, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Symmetry version by Jay Vosburgh (uunet!sequent!fubar) */ - -/* I don't know if this will work for cross-debugging, even if you do get - a copy of the right include file. */ -#include - -#define TARGET_BYTE_ORDER LITTLE_ENDIAN - -/* Define this if the C compiler puts an underscore at the front - of external names before giving them to the linker. */ - -#define NAMES_HAVE_UNDERSCORE - -/* 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. From m-i386.h */ - -#define SKIP_PROLOGUE(frompc) {(frompc) = i386_skip_prologue((frompc));} - -/* 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) \ - read_memory_integer(read_register(SP_REGNUM), 4) - -/* I don't know the real values for these. */ -#define TARGET_UPAGES UPAGES -#define TARGET_NBPG NBPG - -/* Address of end of stack space. */ - -#define STACK_END_ADDR (0x40000000 - (TARGET_UPAGES * TARGET_NBPG)) - -/* Stack grows downward. */ - -#define INNER_THAN < - -/* Sequence of bytes for breakpoint instruction. */ - -#define BREAKPOINT {0xcc} - -/* 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 - -/* Nonzero if instruction at PC is a return instruction. */ -/* For Symmetry, this is really the 'leave' instruction, which */ -/* is right before the ret */ - -#define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 1) == 0xc9) - -/* Return 1 if P points to an invalid floating point value. -*/ - -#define INVALID_FLOAT(p, len) (0) - -/* code for 80387 fpu. Functions are from i386-dep.c, copied into - * symm-dep.c. - */ -#define FLOAT_INFO { i386_float_info(); } - -/* Say how long (ordinary) registers are. */ - -#define REGISTER_TYPE long - -/* Number of machine registers */ -#define NUM_REGS 49 - -/* Initializer for an array of names of registers. - There should be NUM_REGS strings in this initializer. */ - -/* Symmetry registers are in this weird order to match the register - numbers in the symbol table entries. If you change the order, - things will probably break mysteriously for no apparent reason. - Also note that the st(0)...st(7) 387 registers are represented as - st0...st7. */ - -#define REGISTER_NAMES { "eax", "edx", "ecx", "st0", "st1", \ - "ebx", "esi", "edi", "st2", "st3", \ - "st4", "st5", "st6", "st7", "esp", \ - "ebp", "eip", "eflags", "fp1", "fp2", \ - "fp3", "fp4", "fp5", "fp6", "fp7", \ - "fp8", "fp9", "fp10", "fp11", "fp12", \ - "fp13", "fp14", "fp15", "fp16", "fp17", \ - "fp18", "fp19", "fp20", "fp21", "fp22", \ - "fp23", "fp24", "fp25", "fp26", "fp27", \ - "fp28", "fp29", "fp30", "fp31" } - -/* 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 FP1_REGNUM 18 /* first 1167 register */ -#define SP_REGNUM 14 /* Contains address of top of stack */ -#define FP_REGNUM 15 /* Contains address of executing stack frame */ -#define PC_REGNUM 16 /* Contains program counter */ -#define PS_REGNUM 17 /* Contains processor status */ - -/* Total amount of space needed to store our copies of the machine's - register state, the array `registers'. */ -/* 10 i386 registers, 8 i387 registers, and 31 Weitek 1167 registers */ -#define REGISTER_BYTES ((10 * 4) + (8 * 10) + (31 * 4)) - -/* Index within `registers' of the first byte of the space for - register N. */ - -#define REGISTER_BYTE(N) \ -((N < 3) ? (N * 4) : \ -(N < 5) ? (((N - 2) * 10) + 2) : \ -(N < 8) ? (((N - 5) * 4) + 32) : \ -(N < 14) ? (((N - 8) * 10) + 44) : \ - (((N - 14) * 4) + 104)) - -/* Number of bytes of storage in the actual machine representation - * for register N. All registers are 4 bytes, except 387 st(0) - st(7), - * which are 80 bits each. - */ - -#define REGISTER_RAW_SIZE(N) \ -((N < 3) ? 4 : \ -(N < 5) ? 10 : \ -(N < 8) ? 4 : \ -(N < 14) ? 10 : \ - 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 10 - -/* Largest value REGISTER_VIRTUAL_SIZE can have. */ - -#define MAX_REGISTER_VIRTUAL_SIZE 4 - -/* Nonzero if register N requires conversion - from raw format to virtual format. */ - -#define REGISTER_CONVERTIBLE(N) \ -((N < 3) ? 0 : \ -(N < 5) ? 1 : \ -(N < 8) ? 0 : \ -(N < 14) ? 1 : \ - 0) - -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ -((REGNUM < 3) ? bcopy ((FROM), (TO), 4) : \ -(REGNUM < 5) ? i387_to_double((FROM), (TO)) : \ -(REGNUM < 8) ? bcopy ((FROM), (TO), 4) : \ -(REGNUM < 14) ? i387_to_double((FROM), (TO)) : \ - bcopy ((FROM), (TO), 4)) - -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ -((REGNUM < 3) ? bcopy ((FROM), (TO), 4) : \ -(REGNUM < 5) ? double_to_i387((FROM), (TO)) : \ -(REGNUM < 8) ? bcopy ((FROM), (TO), 4) : \ -(REGNUM < 14) ? double_to_i387((FROM), (TO)) : \ - bcopy ((FROM), (TO), 4)) - -/* Return the GDB type object for the "standard" data type - of data in register N. */ - -#define REGISTER_VIRTUAL_TYPE(N) \ -((N < 3) ? builtin_type_int : \ -(N < 5) ? builtin_type_double : \ -(N < 8) ? builtin_type_int : \ -(N < 14) ? builtin_type_double : \ - builtin_type_int) - -/* from m-i386.h */ -/* 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) \ - { (SP) -= sizeof (ADDR); \ - write_memory ((SP), &(ADDR), sizeof (ADDR)); \ - write_register(0, (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) \ - symmetry_extract_return_value(TYPE, REGBUF, VALBUF) - -/* 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. - - However, if FRAME_CHAIN_VALID returns zero, - it means the given frame is the outermost one and has no caller. */ - -/* On Symmetry, %ebp points to caller's %ebp, and the return address - is right on top of that. */ - -#define FRAME_CHAIN(thisframe) \ - (outside_startup_file ((thisframe)->pc) ? \ - read_memory_integer((thisframe)->frame, 4) :\ - 0) - -#define FRAME_CHAIN_VALID(chain, thisframe) \ - (chain != 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. */ -#define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \ - (FRAMELESS) = frameless_look_for_prologue(FI) - -#define FRAME_SAVED_PC(fi) (read_memory_integer((fi)->frame + 4, 4)) - -#define FRAME_ARGS_ADDRESS(fi) ((fi)->frame) - -#define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame) - -/* Return number of args passed to a frame. - Can return -1, meaning no way to tell. - - The weirdness in the "addl $imm8" case is due to gcc sometimes - issuing "addl $-int" after function call returns; this would - produce ridiculously huge arg counts. */ - -#define FRAME_NUM_ARGS(numargs, fi) \ -{ \ - int op = read_memory_integer(FRAME_SAVED_PC((fi)), 4); \ - int narg; \ - if ((op & 0xff) == 0x59) /* 0x59 'popl %ecx' */ \ - { \ - numargs = 1; \ - } \ - else if ((op & 0xffff) == 0xc483) /* 0xc483 'addl $imm8' */ \ - { \ - narg = ((op >> 16) & 0xff); \ - numargs = (narg >= 128) ? -1 : narg / 4; \ - } \ - else if ((op & 0xffff) == 0xc481) /* 0xc481 'addl $imm32' */ \ - { \ - narg = read_memory_integer(FRAME_SAVED_PC((fi))+2,4); \ - numargs = (narg < 0) ? -1 : narg / 4; \ - } \ - else \ - { \ - numargs = -1; \ - } \ -} - -/* Return number of bytes at start of arglist that are not really args. */ - -#define FRAME_ARGS_SKIP 8 - -/* 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) \ -{ i386_frame_find_saved_regs ((frame_info), &(frame_saved_regs)); } - - -/* Things needed for making the inferior call functions. */ - -#define PUSH_DUMMY_FRAME \ -{ CORE_ADDR sp = read_register (SP_REGNUM); \ - int regnum; \ - sp = push_word (sp, read_register (PC_REGNUM)); \ - sp = push_word (sp, read_register (FP_REGNUM)); \ - write_register (FP_REGNUM, sp); \ - for (regnum = 0; regnum < NUM_REGS; regnum++) \ - sp = push_word (sp, read_register (regnum)); \ - write_register (SP_REGNUM, sp); \ -} - -#define POP_FRAME \ -{ \ - FRAME frame = get_current_frame (); \ - CORE_ADDR fp; \ - int regnum; \ - struct frame_saved_regs fsr; \ - struct frame_info *fi; \ - fi = get_frame_info (frame); \ - fp = fi->frame; \ - get_frame_saved_regs (fi, &fsr); \ - for (regnum = 0; regnum < NUM_REGS; regnum++) { \ - CORE_ADDR adr; \ - adr = fsr.regs[regnum]; \ - if (adr) \ - write_register (regnum, read_memory_integer (adr, 4)); \ - } \ - write_register (FP_REGNUM, read_memory_integer (fp, 4)); \ - write_register (PC_REGNUM, read_memory_integer (fp + 4, 4)); \ - write_register (SP_REGNUM, fp + 8); \ - flush_cached_frames (); \ - set_current_frame ( create_new_frame (read_register (FP_REGNUM), \ - read_pc ())); \ -} - -/* from i386-dep.c, worked better than my original... */ -/* This sequence of words is the instructions - * call (32-bit offset) - * int 3 - * This is 6 bytes. - */ - -#define CALL_DUMMY { 0x223344e8, 0xcc11 } - -#define CALL_DUMMY_LENGTH 8 - -#define CALL_DUMMY_START_OFFSET 0 /* Start execution at beginning of dummy */ - -/* 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) \ -{ \ - int from, to, delta, loc; \ - loc = (int)(read_register (SP_REGNUM) - CALL_DUMMY_LENGTH); \ - from = loc + 5; \ - to = (int)(fun); \ - delta = to - from; \ - *(int *)((char *)(dummyname) + 1) = delta; \ -} diff --git a/gdb/tm-tahoe.h b/gdb/tm-tahoe.h deleted file mode 100644 index 9456808e7fe..00000000000 --- a/gdb/tm-tahoe.h +++ /dev/null @@ -1,325 +0,0 @@ -/* Definitions to make GDB target for a tahoe running 4.3-Reno. - Copyright (C) 1986, 1987, 1989, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - * Ported by the State University of New York at Buffalo by the Distributed - * Computer Systems Lab, Department of Computer Science, 1991. - */ - -#define TARGET_BYTE_ORDER BIG_ENDIAN -#define BITS_BIG_ENDIAN 0 - -/* Define this if the C compiler puts an underscore at the front - of external names before giving them to the linker. */ - -#define NAMES_HAVE_UNDERSCORE - -/* 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. */ - -#define SKIP_PROLOGUE(pc) \ -{ register int op = (unsigned char) read_memory_integer (pc, 1); \ - if (op == 0x11) pc += 2; /* skip brb */ \ - if (op == 0x13) pc += 3; /* skip brw */ \ - if (op == 0x2c && \ - ((unsigned char) read_memory_integer (pc+2, 1)) == 0x5e) \ - pc += 3; /* skip subl2 */ \ - if (op == 0xe9 && \ - ((unsigned char) read_memory_integer (pc+1, 1)) == 0xae && \ - ((unsigned char) read_memory_integer(pc+3, 1)) == 0x5e) \ - pc += 4; /* skip movab */ \ - if (op == 0xe9 && \ - ((unsigned char) read_memory_integer (pc+1, 1)) == 0xce && \ - ((unsigned char) read_memory_integer(pc+4, 1)) == 0x5e) \ - pc += 5; /* skip movab */ \ - if (op == 0xe9 && \ - ((unsigned char) read_memory_integer (pc+1, 1)) == 0xee && \ - ((unsigned char) read_memory_integer(pc+6, 1)) == 0x5e) \ - pc += 7; /* skip movab */ \ -} - -/* 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) - -/* Wrong for cross-debugging. I don't know the real values. */ -#include -#define TARGET_UPAGES UPAGES -#define TARGET_NBPG NBPG - -/* This is the amount to subtract from u.u_ar0 - to get the offset in the core file of the register values. */ - -#define KERNEL_U_ADDR (0xc0000000 - (TARGET_UPAGES * TARGET_NBPG)) - -/* Address of end of stack space. */ - -#define STACK_END_ADDR (0xc0000000 - (TARGET_UPAGES * TARGET_NBPG)) - -/* On BSD, sigtramp is in the u area. Can't check the exact - addresses because for cross-debugging we don't have target include - files around. This should be close enough. */ -#define IN_SIGTRAMP(pc, name) ((pc) >= STACK_END_ADDR && (pc < 0xc0000000)) - -/* Stack grows downward. */ - -#define INNER_THAN < - -/* Sequence of bytes for breakpoint instruction. */ - -#define BREAKPOINT {0x30} - -/* 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 - -/* Nonzero if instruction at PC is a return instruction. */ - -#define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 1) == 0x40) - -/* Return 1 if P points to an invalid floating point value. - LEN is the length in bytes -- not relevant on the Tahoe. */ - -#define INVALID_FLOAT(p, len) ((*(short *) p & 0xff80) == 0x8000) - -/* Say how long (ordinary) registers are. */ - -#define REGISTER_TYPE long - -/* Number of machine registers */ - -#define NUM_REGS 19 - -/* 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", "r12", "fp", "sp", "pc", "ps", "al", "ah"} - -#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 */ - -#define AL_REGNUM 17 /* Contains accumulator */ -#define AH_REGNUM 18 - -/* Total amount of space needed to store our copies of the machine's - register state, the array `registers'. */ - -#define REGISTER_BYTES (19*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 tahoe, 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 tahoe, 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 - -/* Nonzero if register N requires conversion - from raw format to virtual format. */ - -#define REGISTER_CONVERTIBLE(N) 0 - -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ - bcopy ((FROM), (TO), 4); - -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ - bcopy ((FROM), (TO), 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) \ - bcopy (REGBUF, VALBUF, 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. - - However, if FRAME_CHAIN_VALID returns zero, - it means the given frame is the outermost one and has no caller. */ - -/* In the case of the Tahoe, the frame's nominal address is the FP value, - and it points to the old FP */ - -#define FRAME_CHAIN(thisframe) \ - (outside_startup_file ((thisframe)->pc) ? \ - read_memory_integer ((thisframe)->frame, 4) :\ - 0) - -#define FRAME_CHAIN_VALID(chain, thisframe) \ - (chain != 0 && (outside_startup_file (FRAME_SAVED_PC (thisframe)))) - -/* Define other aspects of the stack frame. */ - -/* Saved PC */ - -#define FRAME_SAVED_PC(FRAME) (read_memory_integer ((FRAME)->frame - 8, 4)) - -/* In most of GDB, getting the args address is too important to - just say "I don't know". */ - -#define FRAME_ARGS_ADDRESS(fi) ((fi)->frame+4) - -/* Address to use as an anchor for finding local variables */ - -#define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame) - -/* Return number of args passed to a frame. - Can return -1, meaning no way to tell. */ - -#define FRAME_NUM_ARGS(numargs, fi) \ -{ numargs = ((0xffff & read_memory_integer(((fi)->frame-4),4)) - 4) >> 2; } - -/* 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_FIND_SAVED_REGS(frame_info, frame_saved_regs) \ -{ register int regnum; \ - register int rmask = read_memory_integer ((frame_info)->frame-4, 4) >> 16;\ - register CORE_ADDR next_addr; \ - bzero (&frame_saved_regs, sizeof frame_saved_regs); \ - next_addr = (frame_info)->frame - 8; \ - for (regnum = 12; regnum >= 0; regnum--, rmask <<= 1) \ - (frame_saved_regs).regs[regnum] = (rmask & 0x1000) ? (next_addr -= 4) : 0;\ - (frame_saved_regs).regs[SP_REGNUM] = (frame_info)->frame + 4; \ - (frame_saved_regs).regs[PC_REGNUM] = (frame_info)->frame - 8; \ - (frame_saved_regs).regs[FP_REGNUM] = (frame_info)->frame; \ -} - -/* 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; \ -printf("PUSH_DUMMY_FRAME\n"); \ - sp = push_word (sp, read_register (FP_REGNUM)); \ - write_register (FP_REGNUM, sp); \ - sp = push_word (sp, 0x1fff0004); /*SAVE MASK*/ \ - sp = push_word (sp, read_register (PC_REGNUM)); \ - for (regnum = 12; regnum >= 0; regnum--) \ - sp = push_word (sp, read_register (regnum)); \ - write_register (SP_REGNUM, sp); \ -} - -/* 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); \ -printf("POP_FRAME\n"); \ - regmask >>= 16; \ - write_register (SP_REGNUM, fp+4); \ - write_register (PC_REGNUM, read_memory_integer(fp-8, 4)); \ - write_register (FP_REGNUM, read_memory_integer(fp, 4)); \ - fp -= 8; \ - for (regnum = 12; regnum >= 0; regnum--, regmask <<= 1) \ - if (regmask & 0x1000) \ - write_register (regnum, read_memory_integer (fp-=4, 4)); \ - flush_cached_frames (); \ - set_current_frame (create_new_frame (read_register (FP_REGNUM), \ - read_pc ())); } - -/* This sequence of words is the instructions - calls #69, @#32323232 - bpt - Note this is 8 bytes. */ - -#define CALL_DUMMY {0xbf699f32, 0x32323230} - -/* Start execution at beginning of dummy */ - -#define CALL_DUMMY_START_OFFSET 0 - -/* 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, valtype, using_gcc) \ -{ int temp = (int) fun; \ - *((char *) dummyname + 1) = nargs; \ - bcopy(&temp,(char *)dummyname+3,4); } - diff --git a/gdb/tm-ultra3.h b/gdb/tm-ultra3.h deleted file mode 100644 index 59dcaa3c413..00000000000 --- a/gdb/tm-ultra3.h +++ /dev/null @@ -1,226 +0,0 @@ -/* Parameters for NYU Ultracomputer 29000 target, for GDB, the GNU debugger. - Copyright 1990, 1991 Free Software Foundation, Inc. - Contributed by David Wood @ New York University (wood@nyu.edu). - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* This file includes tm-29k.h, but predefines REGISTER_NAMES and - related macros. The file supports a 29k running our flavor of - Unix on our Ultra3 PE Boards. */ - -/* Byte order is configurable, but this machine runs big-endian. */ -#define TARGET_BYTE_ORDER BIG_ENDIAN - -/* Initializer for an array of names of registers. - There should be NUM_REGS strings in this initializer. - */ -#define NUM_REGS (EXO_REGNUM + 1) - -#define REGISTER_NAMES { \ - "gr1", \ - "gr64", "gr65", "gr66", "gr67", "gr68", "gr69", "gr70", "gr71", "gr72", \ - "gr73", "gr74", "gr75", "gr76", "gr77", "gr78", "gr79", "gr80", "gr81", \ - "gr82", "gr83", "gr84", "gr85", "gr86", "gr87", "gr88", "gr89", "gr90", \ - "gr91", "gr92", "gr93", "gr94", "gr95", \ - "gr96", "gr97", "gr98", "gr99", "gr100", "gr101", "gr102", "gr103", "gr104", \ - "gr105", "gr106", "gr107", "gr108", "gr109", "gr110", "gr111", "gr112", \ - "gr113", "gr114", "gr115", "gr116", "gr117", "gr118", "gr119", "gr120", \ - "gr121", "gr122", "gr123", "gr124", "gr125", "gr126", "gr127", \ - "lr0", "lr1", "lr2", "lr3", "lr4", "lr5", "lr6", "lr7", "lr8", "lr9", \ - "lr10", "lr11", "lr12", "lr13", "lr14", "lr15", "lr16", "lr17", "lr18", \ - "lr19", "lr20", "lr21", "lr22", "lr23", "lr24", "lr25", "lr26", "lr27", \ - "lr28", "lr29", "lr30", "lr31", "lr32", "lr33", "lr34", "lr35", "lr36", \ - "lr37", "lr38", "lr39", "lr40", "lr41", "lr42", "lr43", "lr44", "lr45", \ - "lr46", "lr47", "lr48", "lr49", "lr50", "lr51", "lr52", "lr53", "lr54", \ - "lr55", "lr56", "lr57", "lr58", "lr59", "lr60", "lr61", "lr62", "lr63", \ - "lr64", "lr65", "lr66", "lr67", "lr68", "lr69", "lr70", "lr71", "lr72", \ - "lr73", "lr74", "lr75", "lr76", "lr77", "lr78", "lr79", "lr80", "lr81", \ - "lr82", "lr83", "lr84", "lr85", "lr86", "lr87", "lr88", "lr89", "lr90", \ - "lr91", "lr92", "lr93", "lr94", "lr95", "lr96", "lr97", "lr98", "lr99", \ - "lr100", "lr101", "lr102", "lr103", "lr104", "lr105", "lr106", "lr107", \ - "lr108", "lr109", "lr110", "lr111", "lr112", "lr113", "lr114", "lr115", \ - "lr116", "lr117", "lr118", "lr119", "lr120", "lr121", "lr122", "lr123", \ - "lr124", "lr125", "lr126", "lr127", \ - "vab", "ops", "cps", "cfg", "cha", "chd", "chc", "rbp", "tmc", "tmr", \ - "pc0", "pc1", "pc2", "mmu", "lru", \ - "ipc", "ipa", "ipb", "q", "alu", "bp", "fc", "cr", \ - "fpe", "int", "fps", "exo" } - - -#ifdef KERNEL_DEBUGGING -# define PADDR_U_REGNUM 22 /* gr86 */ -# define RETURN_REGNUM GR64_REGNUM -#else -# define RETURN_REGNUM GR96_REGNUM -#endif /* KERNEL_DEBUGGING */ - - -/* Should rename all GR96_REGNUM to RETURN_REGNUM */ -#define GR1_REGNUM (0) -#define GR64_REGNUM 1 -#define GR96_REGNUM (GR64_REGNUM + 32) -/* This needs to be the memory stack pointer, not the register stack pointer, - to make call_function work right. */ -#define SP_REGNUM MSP_REGNUM - -#define FP_REGNUM (LR0_REGNUM + 1) /* lr1 */ -/* Large Return Pointer */ -#define LRP_REGNUM (123 - 96 + RETURN_REGNUM) -/* Static link pointer */ -#define SLP_REGNUM (124 - 96 + RETURN_REGNUM) -/* Memory Stack Pointer. */ -#define MSP_REGNUM (125 - 96 + RETURN_REGNUM) -/* Register allocate bound. */ -#define RAB_REGNUM (126 - 96 + RETURN_REGNUM) -/* Register Free Bound. */ -#define RFB_REGNUM (127 - 96 + RETURN_REGNUM) -/* Register Stack Pointer. */ -#define RSP_REGNUM GR1_REGNUM -#define LR0_REGNUM ( 32 + GR96_REGNUM) - -/* Protected Special registers */ -#define VAB_REGNUM (LR0_REGNUM + 128) -#define OPS_REGNUM (VAB_REGNUM + 1) -#define CPS_REGNUM (VAB_REGNUM + 2) -#define CFG_REGNUM (VAB_REGNUM + 3) -#define CHA_REGNUM (VAB_REGNUM + 4) -#define CHD_REGNUM (VAB_REGNUM + 5) -#define CHC_REGNUM (VAB_REGNUM + 6) -#define RBP_REGNUM (VAB_REGNUM + 7) -#define TMC_REGNUM (VAB_REGNUM + 8) -#define TMR_REGNUM (VAB_REGNUM + 9) -#define NPC_REGNUM (VAB_REGNUM + 10) /* pc0 */ -#define PC_REGNUM (VAB_REGNUM + 11) /* pc1 */ -#define PC2_REGNUM (VAB_REGNUM + 12) /* pc2 */ -#define MMU_REGNUM (VAB_REGNUM + 13) -#define LRU_REGNUM (VAB_REGNUM + 14) - /* Register sequence gap */ -/* Unprotected Special registers */ -#define IPC_REGNUM (LRU_REGNUM + 1) -#define IPA_REGNUM (IPC_REGNUM + 1) -#define IPB_REGNUM (IPC_REGNUM + 2) -#define Q_REGNUM (IPC_REGNUM + 3) -#define ALU_REGNUM (IPC_REGNUM + 4) -#define PS_REGNUM ALU_REGNUM -#define BP_REGNUM (IPC_REGNUM + 5) -#define FC_REGNUM (IPC_REGNUM + 6) -#define CR_REGNUM (IPC_REGNUM + 7) - /* Register sequence gap */ -#define FPE_REGNUM (CR_REGNUM + 1) -#define INT_REGNUM (FPE_REGNUM + 1) -#define FPS_REGNUM (FPE_REGNUM + 2) - /* Register sequence gap */ -#define EXO_REGNUM (FPS_REGNUM + 1) - -/* Special register #x. */ -#define SR_REGNUM(x) \ - ((x) < 15 ? VAB_REGNUM + (x) \ - : (x) >= 128 && (x) < 136 ? IPC_REGNUM + (x-128) \ - : (x) >= 160 && (x) < 163 ? FPE_REGNUM + (x-160) \ - : (x) == 164 ? EXO_REGNUM \ - : (error ("Internal error in SR_REGNUM"), 0)) - -#ifndef KERNEL_DEBUGGING -/* - * This macro defines the register numbers (from REGISTER_NAMES) that - * are effectively unavailable to the user through ptrace(). It allows - * us to include the whole register set in REGISTER_NAMES (inorder to - * better support remote debugging). If it is used in - * fetch/store_inferior_registers() gdb will not complain about I/O errors - * on fetching these registers. If all registers in REGISTER_NAMES - * are available, then return false (0). - */ -#define CANNOT_STORE_REGISTER(regno) \ - (((regno)>=GR64_REGNUM && (regno)=CFG_REGNUM && (regno)<=TMR_REGNUM) || \ - ((regno)==MMU_REGNUM) || \ - ((regno)==LRU_REGNUM) || \ - ((regno)>=ALU_REGNUM) || \ - ((regno)==CR_REGNUM) || \ - ((regno)==EXO_REGNUM)) -#define CANNOT_FETCH_REGISTER(regno) CANNOT_STORE_REGISTER(regno) -#endif /* KERNEL_DEBUGGING */ - -/* - * Converts an sdb register number to an internal gdb register number. - * Currently under gcc, gr96->0...gr128->31...lr0->32...lr127->159, or... - * gr64->0...gr95->31, lr0->32...lr127->159. - */ -#define SDB_REG_TO_REGNUM(value) (((value)<32) ? ((value)+RETURN_REGNUM) : \ - ((value)-32+LR0_REGNUM)) - -#ifdef KERNEL_DEBUGGING - /* ublock virtual address as defined in our sys/param.h */ - /* FIXME: Should get this from sys/param.h */ -# define UVADDR ((32*0x100000)-8192) -#endif - -/* - * Are we in sigtramp(), needed in infrun.c. Specific to ultra3, because - * we take off the leading '_'. - */ -#if !defined(KERNEL_DEBUGGING) -#ifdef SYM1 -# define IN_SIGTRAMP(pc, name) (name && !strcmp ("sigtramp", name)) -#else - Need to define IN_SIGTRAMP() for sym2. -#endif -#endif /* !KERNEL_DEBUGGING */ - -#include "tm-29k.h" - -/**** The following are definitions that override those in tm-29k.h ****/ - -/* This sequence of words is the instructions - mtsrim cr, 15 - loadm 0, 0, lr2, msp ; load first 16 words of arguments into registers - add msp, msp, 16 * 4 ; point to the remaining arguments - CONST_INSN: - const gr96,inf - consth gr96,inf - calli lr0, gr96 - aseq 0x40,gr1,gr1 ; nop - asneq 0x50,gr1,gr1 ; breakpoint - When KERNEL_DEBUGGIN is defined, msp -> gr93, gr96 -> gr64, - 7d -> 5d, 60 -> 40 - */ - -/* Position of the "const" instruction within CALL_DUMMY in bytes. */ -#undef CALL_DUMMY -#if TARGET_BYTE_ORDER == HOST_BYTE_ORDER -#ifdef KERNEL_DEBUGGING /* gr96 -> gr64 */ -# define CALL_DUMMY {0x0400870f, 0x3600825d, 0x155d5d40, 0x03ff40ff, \ - 0x02ff40ff, 0xc8008040, 0x70400101, 0x72500101} -#else -# define CALL_DUMMY {0x0400870f, 0x3600827d, 0x157d7d40, 0x03ff60ff, \ - 0x02ff60ff, 0xc8008060, 0x70400101, 0x72500101} -#endif /* KERNEL_DEBUGGING */ -#else /* Byte order differs. */ - you lose -#endif /* Byte order differs. */ - -#if !defined(KERNEL_DEBUGGING) -# ifdef SYM1 -# undef DECR_PC_AFTER_BREAK -# define DECR_PC_AFTER_BREAK 0 /* Sym1 kernel does the decrement */ -# else - ->"ULTRA3 running other than sym1 OS"!; -# endif -#endif /* !KERNEL_DEBUGGING */ - diff --git a/gdb/tm-umax.h b/gdb/tm-umax.h deleted file mode 100644 index 727ffcf1190..00000000000 --- a/gdb/tm-umax.h +++ /dev/null @@ -1,395 +0,0 @@ -/* Definitions to make GDB run on an encore under umax 4.2 - Copyright (C) 1987, 1989, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#define TARGET_BYTE_ORDER LITTLE_ENDIAN - -/* Define this if the C compiler puts an underscore at the front - of external names before giving them to the linker. */ - -#define NAMES_HAVE_UNDERSCORE - -/* Need to get function ends by adding this to epilogue address from .bf - record, not using x_fsize field. */ -#define FUNCTION_EPILOGUE_SIZE 4 - -/* 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) \ -{ register unsigned char op = read_memory_integer (pc, 1); \ - if (op == 0x82) { op = read_memory_integer (pc+2,1); \ - if ((op & 0x80) == 0) pc += 3; \ - else if ((op & 0xc0) == 0x80) pc += 4; \ - else pc += 6; \ - } \ -} - -/* 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) \ - read_memory_integer (read_register (SP_REGNUM), 4) - -/* Address of end of stack space. */ - -#define STACK_END_ADDR (0xfffff000) - -/* Stack grows downward. */ - -#define INNER_THAN < - -/* Sequence of bytes for breakpoint instruction. */ - -#define BREAKPOINT {0xf2} - -/* 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 - -/* Nonzero if instruction at PC is a return instruction. */ - -#define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 1) == 0x12) - -#ifndef NaN -#include -#endif NaN - -/* Return 1 if P points to an invalid floating point value. */ -/* Surely wrong for cross-debugging. */ -#define INVALID_FLOAT(p, s) \ - ((s == sizeof (float))? \ - NaF (*(float *) p) : \ - NaD (*(double *) p)) - -/* Say how long (ordinary) registers are. */ - -#define REGISTER_TYPE long - -/* Number of machine registers */ - -#define NUM_REGS 25 - -#define NUM_GENERAL_REGS 8 - -/* 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", \ - "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \ - "sp", "fp", "pc", "ps", \ - "fsr", \ - "l0", "l1", "l2", "l3", "xx", \ - } - -/* 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 FP0_REGNUM 8 /* Floating point register 0 */ -#define SP_REGNUM 16 /* Contains address of top of stack */ -#define AP_REGNUM FP_REGNUM -#define FP_REGNUM 17 /* Contains address of executing stack frame */ -#define PC_REGNUM 18 /* Contains program counter */ -#define PS_REGNUM 19 /* Contains processor status */ -#define FPS_REGNUM 20 /* Floating point status register */ -#define LP0_REGNUM 21 /* Double register 0 (same as FP0) */ - -/* Total amount of space needed to store our copies of the machine's - register state, the array `registers'. */ -#define REGISTER_BYTES ((NUM_REGS - 4) * sizeof (int) + 4 * sizeof (double)) - -/* Index within `registers' of the first byte of the space for - register N. */ - -#define REGISTER_BYTE(N) ((N) >= LP0_REGNUM ? \ - LP0_REGNUM * 4 + ((N) - LP0_REGNUM) * 8 : (N) * 4) - -/* Number of bytes of storage in the actual machine representation - for register N. On the 32000, all regs are 4 bytes - except for the doubled floating registers. */ - -#define REGISTER_RAW_SIZE(N) ((N) >= LP0_REGNUM ? 8 : 4) - -/* Number of bytes of storage in the program's representation - for register N. On the 32000, all regs are 4 bytes - except for the doubled floating registers. */ - -#define REGISTER_VIRTUAL_SIZE(N) ((N) >= LP0_REGNUM ? 8 : 4) - -/* 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. */ - -#define REGISTER_CONVERTIBLE(N) 0 - -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ - bcopy ((FROM), (TO), REGISTER_VIRTUAL_SIZE(REGNUM)); - -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ - bcopy ((FROM), (TO), REGISTER_VIRTUAL_SIZE(REGNUM)); - -/* Return the GDB type object for the "standard" data type - of data in register N. */ - -#define REGISTER_VIRTUAL_TYPE(N) \ - (((N) < FP0_REGNUM) ? \ - builtin_type_int : \ - ((N) < FP0_REGNUM + 8) ? \ - builtin_type_float : \ - ((N) < LP0_REGNUM) ? \ - builtin_type_int : \ - builtin_type_double) - -/* Store the address of the place in which to copy the structure the - subroutine will return. This is called from call_function. - - On this machine this is a no-op, because gcc isn't used on it - yet. So this calling convention is not used. */ - -#define STORE_STRUCT_RETURN(ADDR, SP) - -/* 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) \ - bcopy (REGBUF+REGISTER_BYTE (TYPE_CODE (TYPE) == TYPE_CODE_FLT ? FP0_REGNUM : 0), VALBUF, 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 (REGISTER_BYTE (TYPE_CODE (TYPE) == TYPE_CODE_FLT ? FP0_REGNUM : 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. - - However, if FRAME_CHAIN_VALID returns zero, - it means the given frame is the outermost one and has no caller. */ - -/* In the case of the ns32000 series, the frame's nominal address is the FP - value, and at that address is saved previous FP value as a 4-byte word. */ - -#define FRAME_CHAIN(thisframe) \ - (outside_startup_file ((thisframe)->pc) ? \ - read_memory_integer ((thisframe)->frame, 4) :\ - 0) - -#define FRAME_CHAIN_VALID(chain, thisframe) \ - (chain != 0 && (outside_startup_file (FRAME_SAVED_PC (thisframe)))) - -/* Define other aspects of the stack frame. */ - -#define FRAME_SAVED_PC(FRAME) (read_memory_integer ((FRAME)->frame + 4, 4)) - -/* Compute base of arguments. */ - -#define FRAME_ARGS_ADDRESS(fi) \ - ((ns32k_get_enter_addr ((fi)->pc) > 1) ? \ - ((fi)->frame) : (read_register (SP_REGNUM) - 4)) - -#define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame) - -/* Get the address of the enter opcode for this function, if it is active. - Returns positive address > 1 if pc is between enter/exit, - 1 if pc before enter or after exit, 0 otherwise. */ - -#ifndef CORE_ADDR -#include "defs.h" /* Make sure CORE_ADDR is defined. */ -#endif - -extern CORE_ADDR ns32k_get_enter_addr (); - -/* Return number of args passed to a frame. - Can return -1, meaning no way to tell. - Encore's C compiler often reuses same area on stack for args, - so this will often not work properly. If the arg names - are known, it's likely most of them will be printed. */ - -#define FRAME_NUM_ARGS(numargs, fi) \ -{ CORE_ADDR pc; \ - CORE_ADDR enter_addr; \ - unsigned int insn; \ - unsigned int addr_mode; \ - int width; \ - \ - numargs = -1; \ - enter_addr = ns32k_get_enter_addr ((fi)->pc); \ - if (enter_addr > 0) \ - { \ - pc = (enter_addr == 1) ? \ - SAVED_PC_AFTER_CALL (fi) : \ - FRAME_SAVED_PC (fi); \ - insn = read_memory_integer (pc,2); \ - addr_mode = (insn >> 11) & 0x1f; \ - insn = insn & 0x7ff; \ - if ((insn & 0x7fc) == 0x57c && \ - addr_mode == 0x14) /* immediate */ \ - { \ - if (insn == 0x57c) /* adjspb */ \ - width = 1; \ - else if (insn == 0x57d) /* adjspw */ \ - width = 2; \ - else if (insn == 0x57f) /* adjspd */ \ - width = 4; \ - numargs = read_memory_integer (pc+2,width); \ - if (width > 1) \ - flip_bytes (&numargs, width); \ - numargs = - sign_extend (numargs, width*8) / 4;\ - } \ - } \ -} - -/* Return number of bytes at start of arglist that are not really args. */ - -#define FRAME_ARGS_SKIP 8 - -/* 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 regmask, regnum; \ - int localcount; \ - register CORE_ADDR enter_addr; \ - register CORE_ADDR next_addr; \ - \ - bzero (&(frame_saved_regs), sizeof (frame_saved_regs)); \ - enter_addr = ns32k_get_enter_addr ((frame_info)->pc); \ - if (enter_addr > 1) \ - { \ - regmask = read_memory_integer (enter_addr+1, 1) & 0xff; \ - localcount = ns32k_localcount (enter_addr); \ - next_addr = (frame_info)->frame + localcount; \ - for (regnum = 0; regnum < 8; regnum++, regmask >>= 1) \ - (frame_saved_regs).regs[regnum] = (regmask & 1) ? \ - (next_addr -= 4) : 0; \ - (frame_saved_regs).regs[SP_REGNUM] = (frame_info)->frame + 4;\ - (frame_saved_regs).regs[PC_REGNUM] = (frame_info)->frame + 4;\ - (frame_saved_regs).regs[FP_REGNUM] = \ - (read_memory_integer ((frame_info)->frame, 4));\ - } \ - else if (enter_addr == 1) \ - { \ - CORE_ADDR sp = read_register (SP_REGNUM); \ - (frame_saved_regs).regs[PC_REGNUM] = sp; \ - (frame_saved_regs).regs[SP_REGNUM] = sp + 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, read_register (PC_REGNUM)); \ - sp = push_word (sp, read_register (FP_REGNUM)); \ - write_register (FP_REGNUM, sp); \ - for (regnum = 0; regnum < 8; regnum++) \ - sp = push_word (sp, read_register (regnum)); \ - write_register (SP_REGNUM, sp); \ -} - -/* Discard from the stack the innermost frame, restoring all registers. */ - -#define POP_FRAME \ -{ register FRAME frame = get_current_frame (); \ - register CORE_ADDR fp; \ - register int regnum; \ - struct frame_saved_regs fsr; \ - struct frame_info *fi; \ - fi = get_frame_info (frame); \ - fp = fi->frame; \ - get_frame_saved_regs (fi, &fsr); \ - for (regnum = 0; regnum < 8; regnum++) \ - if (fsr.regs[regnum]) \ - write_register (regnum, read_memory_integer (fsr.regs[regnum], 4)); \ - write_register (FP_REGNUM, read_memory_integer (fp, 4)); \ - write_register (PC_REGNUM, read_memory_integer (fp + 4, 4)); \ - write_register (SP_REGNUM, fp + 8); \ - flush_cached_frames (); \ - set_current_frame (create_new_frame (read_register (FP_REGNUM),\ - read_pc ())); } - -/* This sequence of words is the instructions - enter 0xff,0 82 ff 00 - jsr @0x00010203 7f ae c0 01 02 03 - adjspd 0x69696969 7f a5 01 02 03 04 - bpt f2 - Note this is 16 bytes. */ - -#define CALL_DUMMY { 0x7f00ff82, 0x0201c0ae, 0x01a57f03, 0xf2040302 } - -#define CALL_DUMMY_START_OFFSET 3 -#define CALL_DUMMY_LENGTH 16 -#define CALL_DUMMY_ADDR 5 -#define CALL_DUMMY_NARGS 11 - -/* 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) \ -{ \ - int flipped; \ - flipped = fun | 0xc0000000; \ - flip_bytes (&flipped, 4); \ - *((int *) (((char *) dummyname)+CALL_DUMMY_ADDR)) = flipped; \ - flipped = - nargs * 4; \ - flip_bytes (&flipped, 4); \ - *((int *) (((char *) dummyname)+CALL_DUMMY_NARGS)) = flipped; \ -} diff --git a/gdb/tm-vax.h b/gdb/tm-vax.h deleted file mode 100644 index a91a3c722ee..00000000000 --- a/gdb/tm-vax.h +++ /dev/null @@ -1,367 +0,0 @@ -/* Definitions to make GDB run on a vax under 4.2bsd. - Copyright (C) 1986, 1987, 1989, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* There is one known bug with VAX support that I don't know how to - fix: if you do a backtrace from a signal handler, you get something - like: -#0 0xbc in kill (592, 3) -#1 0x7f in hand (...) (...) -#2 0x7fffec7e in ?? (2, 0, 2147478112, 94) - ^^ GDB doesn't know about sigtramp -#3 0x7fffec70 in ?? (592, 2) - ^^^^^^^^^^ wrong address -#4 0xae in main (...) (...) - -when the correct backtrace (as given by adb) is: -_kill(250,3) from _hand+21 -_hand(2,0,7fffea60,5e) from 7fffec7e -sigtramp(2,0,7fffea60,5e) from _kill+4 -_kill(250,2) from _main+2e -_main(1,7fffeac4,7fffeacc) from start+3d - -If anyone knows enough about VAX BSD to fix this, please send the -fix to bug-gdb@prep.ai.mit.edu. */ - -#define TARGET_BYTE_ORDER LITTLE_ENDIAN - -/* Define this if the C compiler puts an underscore at the front - of external names before giving them to the linker. */ - -#define NAMES_HAVE_UNDERSCORE - -/* 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. */ - -#define SKIP_PROLOGUE(pc) \ -{ register int op = (unsigned char) read_memory_integer (pc, 1); \ - if (op == 0x11) pc += 2; /* skip brb */ \ - if (op == 0x31) pc += 3; /* skip brw */ \ - if (op == 0xC2 && \ - ((unsigned char) read_memory_integer (pc+2, 1)) == 0x5E) \ - pc += 3; /* skip subl2 */ \ - if (op == 0x9E && \ - ((unsigned char) read_memory_integer (pc+1, 1)) == 0xAE && \ - ((unsigned char) read_memory_integer(pc+3, 1)) == 0x5E) \ - pc += 4; /* skip movab */ \ - if (op == 0x9E && \ - ((unsigned char) read_memory_integer (pc+1, 1)) == 0xCE && \ - ((unsigned char) read_memory_integer(pc+4, 1)) == 0x5E) \ - pc += 5; /* skip movab */ \ - if (op == 0x9E && \ - ((unsigned char) read_memory_integer (pc+1, 1)) == 0xEE && \ - ((unsigned char) read_memory_integer(pc+6, 1)) == 0x5E) \ - pc += 7; /* skip movab */ \ -} - -/* 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 TARGET_UPAGES 10 -#define TARGET_NBPG 512 -#define STACK_END_ADDR (0x80000000 - (TARGET_UPAGES * TARGET_NBPG)) - -/* On the VAX, sigtramp is in the u area. Can't check the exact - addresses because for cross-debugging we don't have VAX include - files around. This should be close enough. */ -#define IN_SIGTRAMP(pc, name) ((pc) >= STACK_END_ADDR && (pc < 0x80000000)) - -/* Stack grows downward. */ - -#define INNER_THAN < - -/* 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 - -/* Nonzero if instruction at PC is a return instruction. */ - -#define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 1) == 04) - -/* Return 1 if P points to an invalid floating point value. - LEN is the length in bytes -- not relevant on the Vax. */ - -#define INVALID_FLOAT(p, len) ((*(short *) p & 0xff80) == 0x8000) - -/* Say how long (ordinary) registers are. */ - -#define REGISTER_TYPE long - -/* 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 - -/* Nonzero if register N requires conversion - from raw format to virtual format. */ - -#define REGISTER_CONVERTIBLE(N) 0 - -/* Convert data from raw format for register REGNUM - to virtual format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ - bcopy ((FROM), (TO), 4); - -/* Convert data from virtual format for register REGNUM - to raw format for register REGNUM. */ - -#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ - bcopy ((FROM), (TO), 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) \ - bcopy (REGBUF, VALBUF, 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. - - However, if FRAME_CHAIN_VALID returns zero, - it means the given frame is the outermost one and has no caller. */ - -/* 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) \ - (outside_startup_file ((thisframe)->pc) ? \ - read_memory_integer ((thisframe)->frame + 12, 4) :\ - 0) - -#define FRAME_CHAIN_VALID(chain, thisframe) \ - (chain != 0 && (outside_startup_file (FRAME_SAVED_PC (thisframe)))) - -/* 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, FRAMELESS) {(FRAMELESS) = 0;} - -/* Saved Pc. */ - -#define FRAME_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_frame \ - ? 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_frame \ - ? 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. */ - -#define FRAME_NUM_ARGS(numargs, fi) \ -{ numargs = (0xff & read_memory_integer (FRAME_ARGS_ADDRESS (fi), 1)); } - -/* 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; \ - bzero (&frame_saved_regs, 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 (); \ - set_current_frame (create_new_frame (read_register (FP_REGNUM),\ - read_pc ())); } - -/* 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 */ - -/* 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; } diff --git a/gdb/tm-vx68.h b/gdb/tm-vx68.h deleted file mode 100644 index 106080e6141..00000000000 --- a/gdb/tm-vx68.h +++ /dev/null @@ -1,48 +0,0 @@ -/* Parameters for execution on VxWorks 68k's, for GDB, the GNU debugger. - Copyright (C) 1986, 1987, 1989, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#define GDBINIT_FILENAME ".vxgdbinit" - -#define DEFAULT_PROMPT "(vxgdb) " - -/* Kludge... */ -#include "tm-sun3.h" - -/* We have more complex, useful breakpoints on the target. */ -#undef DECR_PC_AFTER_BREAK -#define DECR_PC_AFTER_BREAK 0 - -/* We are guaranteed to have a zero frame pointer at bottom of stack, too. */ -#undef FRAME_CHAIN -#undef FRAME_CHAIN_VALID - -/* Takes the current frame-struct pointer and returns the chain-pointer - to get to the calling frame. - - If our current frame pointer is zero, we're at the top; else read out - the saved FP from memory pointed to by the current FP. */ - -#define FRAME_CHAIN(thisframe) ((thisframe)->frame? read_memory_integer ((thisframe)->frame, 4): 0) - -/* If the chain pointer is zero (either because the saved value fetched - by FRAME_CHAIN was zero, or because the current FP was zero so FRAME_CHAIN - never fetched anything), we are at the top of the stack. */ - -#define FRAME_CHAIN_VALID(chain, thisframe) (chain != 0) diff --git a/gdb/tm-vx960.h b/gdb/tm-vx960.h deleted file mode 100644 index f6a5e1f7853..00000000000 --- a/gdb/tm-vx960.h +++ /dev/null @@ -1,37 +0,0 @@ -/* Parameters for VxWorks Intel 960's, for GDB, the GNU debugger. - Copyright (C) 1986-1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include "tm-i960.h" - -#define GDBINIT_FILENAME ".vxgdbinit" - -#define DEFAULT_PROMPT "(vxgdb) " - -/* We have more complex, useful breakpoints on the target. - Amount ip must be decremented by after a breakpoint. */ - -#define DECR_PC_AFTER_BREAK 0 - -/* We are guaranteed to have a zero frame pointer at bottom of stack, too. */ - -#define FRAME_CHAIN_VALID(chain, thisframe) (chain != 0) - -/* Breakpoint patching is handled at the target end in VxWorks. */ -/* #define BREAKPOINT {0x00, 0x3e, 0x00, 0x66} */ diff --git a/gdb/tm-vxworks68.h b/gdb/tm-vxworks68.h deleted file mode 100755 index a3cd7c22f62..00000000000 --- a/gdb/tm-vxworks68.h +++ /dev/null @@ -1,48 +0,0 @@ -/* Parameters for execution on VxWorks 68k's, for GDB, the GNU debugger. - Copyright (C) 1986, 1987, 1989, 1991 Free Software Foundation, Inc. - Contributed by Cygnus Support. - -This file is part of GDB. - -GDB 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 1, or (at your option) -any later version. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#define GDBINIT_FILENAME ".vxgdbinit" - -#define DEFAULT_PROMPT "(vxgdb) " - -/* Kludge... */ -#include "tm-sun3.h" - -/* We have more complex, useful breakpoints on the target. */ -#undef DECR_PC_AFTER_BREAK -#define DECR_PC_AFTER_BREAK 0 - -/* We are guaranteed to have a zero frame pointer at bottom of stack, too. */ -#undef FRAME_CHAIN -#undef FRAME_CHAIN_VALID - -/* Takes the current frame-struct pointer and returns the chain-pointer - to get to the calling frame. - - If our current frame pointer is zero, we're at the top; else read out - the saved FP from memory pointed to by the current FP. */ - -#define FRAME_CHAIN(thisframe) ((thisframe)->frame? read_memory_integer ((thisframe)->frame, 4): 0) - -/* If the chain pointer is zero (either because the saved value fetched - by FRAME_CHAIN was zero, or because the current FP was zero so FRAME_CHAIN - never fetched anything), we are at the top of the stack. */ - -#define FRAME_CHAIN_VALID(chain, thisframe) (chain != 0) diff --git a/gdb/tm-vxworks960.h b/gdb/tm-vxworks960.h deleted file mode 100755 index fc5c21454f3..00000000000 --- a/gdb/tm-vxworks960.h +++ /dev/null @@ -1,48 +0,0 @@ -/* Parameters for VxWorks Intel 960's, for GDB, the GNU debugger. - Copyright (C) 1986-1991 Free Software Foundation, Inc. - Contributed by Cygnus Support. - -This file is part of GDB. - -GDB 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 1, or (at your option) -any later version. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include "tm-i960.h" - -#define GDBINIT_FILENAME ".vxgdbinit" - -#define DEFAULT_PROMPT "(vxgdb) " - -/* We have more complex, useful breakpoints on the target. - Amount ip must be decremented by after a breakpoint. */ - -#define DECR_PC_AFTER_BREAK 0 - -/* We are guaranteed to have a zero frame pointer at bottom of stack, too. */ - -#define FRAME_CHAIN_VALID(chain, thisframe) (chain != 0) - -/* Breakpoint patching is handled at the target end in VxWorks. */ -/* #define BREAKPOINT {0x00, 0x3e, 0x00, 0x66} */ - -/* Not needed, because we don't support core files: - #define KERNEL_U_ADDR - #define REGISTER_U_ADDR(addr, blockend, regno) - */ - -/* Address of end of stack space. - This doesn't matter for VxWorks, because it's only used - in manipulation of core files, which we don't support. */ - -/* #define STACK_END_ADDR (0xfe000000) */ diff --git a/gdb/ultra3-xdep.c b/gdb/ultra3-xdep.c deleted file mode 100644 index c910e3d4779..00000000000 --- a/gdb/ultra3-xdep.c +++ /dev/null @@ -1,393 +0,0 @@ -/* Host-dependent code for GDB, for NYU Ultra3 running Sym1 OS. - Copyright (C) 1988, 1989, 1991 Free Software Foundation, Inc. - Contributed by David Wood (wood@nyu.edu) at New York University. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#define DEBUG -#include -#include "defs.h" -#include "param.h" -#include "frame.h" -#include "inferior.h" -#include "symtab.h" -#include "value.h" - -#include -#include -#include -#include -#include - -#include "gdbcore.h" - -#include -#include -#include - -/* Assumes support for AMD's Binary Compatibility Standard - for ptrace(). If you define ULTRA3, the ultra3 extensions to - ptrace() are used allowing the reading of more than one register - at a time. - - This file assumes KERNEL_DEBUGGING is turned off. This means - that if the user/gdb tries to read gr64-gr95 or any of the - protected special registers we silently return -1 (see the - CANNOT_STORE/FETCH_REGISTER macros). */ -#define ULTRA3 - -#if !defined (offsetof) -# define offsetof(TYPE, MEMBER) ((unsigned long) &((TYPE *)0)->MEMBER) -#endif - -extern int errno; -struct ptrace_user pt_struct; - -/* - * Fetch an individual register (and supply it). - * return 0 on success, -1 on failure. - * NOTE: Assumes AMD's Binary Compatibility Standard for ptrace(). - */ -static void -fetch_register (regno) - int regno; -{ - char buf[128]; - int val; - - if (CANNOT_FETCH_REGISTER(regno)) { - val = -1; - supply_register (regno, &val); - } else { - errno = 0; - val = ptrace (PT_READ_U, inferior_pid, (int*)register_addr(regno,0), 0); - if (errno != 0) { - sprintf(buf,"reading register %s (#%d)",reg_names[regno],regno); - perror_with_name (buf); - } else { - supply_register (regno, &val); - } - } -} - -/* Get all available registers from the inferior. Registers that are - * defined in REGISTER_NAMES, but not available to the user/gdb are - * supplied as -1. This may include gr64-gr95 and the protected special - * purpose registers. - */ - -void -fetch_inferior_registers (regno) - int regno; -{ - register int i,j,ret_val=0; - char buf[128]; - - if (regno != -1) { - fetch_register (regno); - return; - } - -/* Global Registers */ -#ifdef ULTRA3 - errno = 0; - ptrace (PT_READ_STRUCT, inferior_pid, (int*)register_addr(GR96_REGNUM,0), - (int)&pt_struct.pt_gr[0], 32*4); - if (errno != 0) { - perror_with_name ("reading global registers"); - ret_val = -1; - } else for (regno=GR96_REGNUM, j=0 ; j<32 ; regno++, j++) { - supply_register (regno, &pt_struct.pt_gr[j]); - } -#else - for (regno=GR96_REGNUM ; !ret_val && regno < GR96_REGNUM+32 ; regno++) - fetch_register(regno); -#endif - -/* Local Registers */ -#ifdef ULTRA3 - errno = 0; - ptrace (PT_READ_STRUCT, inferior_pid, (int*)register_addr(LR0_REGNUM,0), - (int)&pt_struct.pt_lr[0], 128*4); - if (errno != 0) { - perror_with_name ("reading local registers"); - ret_val = -1; - } else for (regno=LR0_REGNUM, j=0 ; j<128 ; regno++, j++) { - supply_register (regno, &pt_struct.pt_lr[j]); - } -#else - for (regno=LR0_REGNUM ; !ret_val && regno < LR0_REGNUM+128 ; regno++) - fetch_register(regno); -#endif - -/* Special Registers */ - fetch_register(GR1_REGNUM); - fetch_register(CPS_REGNUM); - fetch_register(PC_REGNUM); - fetch_register(NPC_REGNUM); - fetch_register(PC2_REGNUM); - fetch_register(IPC_REGNUM); - fetch_register(IPA_REGNUM); - fetch_register(IPB_REGNUM); - fetch_register(Q_REGNUM); - fetch_register(BP_REGNUM); - fetch_register(FC_REGNUM); - -/* Fake any registers that are in REGISTER_NAMES, but not available to gdb */ - registers_fetched(); -} - -/* Store our register values back into the inferior. - * If REGNO is -1, do this for all registers. - * Otherwise, REGNO specifies which register (so we can save time). - * NOTE: Assumes AMD's binary compatibility standard. - */ - -int -store_inferior_registers (regno) - int regno; -{ - register unsigned int regaddr; - char buf[80]; - - if (regno >= 0) - { - if (CANNOT_STORE_REGISTER(regno)) - return 0; /* Pretend success */ - regaddr = register_addr (regno, 0); - errno = 0; - ptrace (PT_WRITE_U, inferior_pid,(int*)regaddr,read_register(regno)); - if (errno != 0) - { - sprintf (buf, "writing register %s (#%d)", reg_names[regno],regno); - perror_with_name (buf); - } - } - else - { -#ifdef ULTRA3 - pt_struct.pt_gr1 = read_register(GR1_REGNUM); - for (regno = GR96_REGNUM; regno < GR96_REGNUM+32; regno++) - pt_struct.pt_gr[regno] = read_register(regno); - for (regno = LR0_REGNUM; regno < LR0_REGNUM+128; regno++) - pt_struct.pt_gr[regno] = read_register(regno); - errno = 0; - ptrace (PT_WRITE_STRUCT, inferior_pid, (int*)register_addr(GR1_REGNUM,0), - (int)&pt_struct.pt_gr1,(1*32*128)*4); - if (errno != 0) - { - sprintf (buf, "writing all local/global registers"); - perror_with_name (buf); - } - pt_struct.pt_psr = read_register(CPS_REGNUM); - pt_struct.pt_pc0 = read_register(NPC_REGNUM); - pt_struct.pt_pc1 = read_register(PC_REGNUM); - pt_struct.pt_pc2 = read_register(PC2_REGNUM); - pt_struct.pt_ipc = read_register(IPC_REGNUM); - pt_struct.pt_ipa = read_register(IPA_REGNUM); - pt_struct.pt_ipb = read_register(IPB_REGNUM); - pt_struct.pt_q = read_register(Q_REGNUM); - pt_struct.pt_bp = read_register(BP_REGNUM); - pt_struct.pt_fc = read_register(FC_REGNUM); - errno = 0; - ptrace (PT_WRITE_STRUCT, inferior_pid, (int*)register_addr(CPS_REGNUM,0), - (int)&pt_struct.pt_psr,(10)*4); - if (errno != 0) - { - sprintf (buf, "writing all special registers"); - perror_with_name (buf); - return -1; - } -#else - store_inferior_registers(GR1_REGNUM); - for (regno=GR96_REGNUM ; regno= LR0_REGNUM) && (regno < LR0_REGNUM + 128)) { - return(offsetof(struct ptrace_user,pt_lr[regno-LR0_REGNUM])); - } else if ((regno >= GR96_REGNUM) && (regno < GR96_REGNUM + 32)) { - return(offsetof(struct ptrace_user,pt_gr[regno-GR96_REGNUM])); - } else { - switch (regno) { - case GR1_REGNUM: return(offsetof(struct ptrace_user,pt_gr1)); - case CPS_REGNUM: return(offsetof(struct ptrace_user,pt_psr)); - case NPC_REGNUM: return(offsetof(struct ptrace_user,pt_pc0)); - case PC_REGNUM: return(offsetof(struct ptrace_user,pt_pc1)); - case PC2_REGNUM: return(offsetof(struct ptrace_user,pt_pc2)); - case IPC_REGNUM: return(offsetof(struct ptrace_user,pt_ipc)); - case IPA_REGNUM: return(offsetof(struct ptrace_user,pt_ipa)); - case IPB_REGNUM: return(offsetof(struct ptrace_user,pt_ipb)); - case Q_REGNUM: return(offsetof(struct ptrace_user,pt_q)); - case BP_REGNUM: return(offsetof(struct ptrace_user,pt_bp)); - case FC_REGNUM: return(offsetof(struct ptrace_user,pt_fc)); - default: - fprintf_filtered(stderr,"register_addr():Bad register %s (%d)\n", - reg_names[regno],regno); - return(0xffffffff); /* Should make ptrace() fail */ - } - } -} - - -/* Assorted operating system circumventions */ - -#ifdef SYM1 - -/* FIXME: Kludge this for now. It really should be system call. */ -int -getpagesize() -{ return(8192); } - -/* FIXME: Fake out the fcntl() call, which we don't have. */ -fcntl(fd, cmd, arg) -int fd, cmd, arg; -{ - - switch (cmd) { - case F_GETFL: return(O_RDONLY); break; - default: - printf("Ultra3's fcntl() failing, cmd = %d.\n",cmd); - return(-1); - } -} - - -/* - * 4.2 Signal support, requires linking with libjobs. - */ -static int _SigMask; -#define sigbit(s) (1L << ((s)-1)) - -init_SigMask() -{ - /* Taken from the sym1 kernel in machdep.c:startup() */ - _SigMask = sigbit (SIGTSTP) | sigbit (SIGTTOU) | sigbit (SIGTTIN) | - sigbit (SIGCHLD) | sigbit (SIGTINT); -} - -sigmask(signo) - int signo; -{ - return (1 << (signo-1)); -} - -sigsetmask(sigmask) -unsigned int sigmask; -{ - int i, mask = 1; - int lastmask = _SigMask; - - for (i=0 ; i -#include "defs.h" -#include "param.h" -#include "frame.h" -#include "inferior.h" - -#include -#include -#include -#include -#include - -#include "gdbcore.h" -#include -#define PTRACE_ATTACH PT_ATTACH -#define PTRACE_DETACH PT_FREEPROC - -#include -#include - -/* Work with core dump and executable files, for GDB. - This code would be in core.c if it weren't machine-dependent. */ - -void -core_file_command (filename, from_tty) - char *filename; - int from_tty; -{ - int val; - extern char registers[]; - - /* Discard all vestiges of any previous core file - and mark data and stack spaces as empty. */ - - if (corefile) - free (corefile); - corefile = 0; - - if (corechan >= 0) - close (corechan); - corechan = -1; - - data_start = 0; - data_end = 0; - stack_start = STACK_END_ADDR; - stack_end = STACK_END_ADDR; - - /* Now, if a new core file was specified, open it and digest it. */ - - if (filename) - { - filename = tilde_expand (filename); - make_cleanup (free, filename); - - if (have_inferior_p ()) - error ("To look at a core file, you must kill the inferior with \"kill\"."); - corechan = open (filename, O_RDONLY, 0); - if (corechan < 0) - perror_with_name (filename); - /* 4.2-style (and perhaps also sysV-style) core dump file. */ - { - struct ptrace_user u; - int reg_offset; - - val = myread (corechan, &u, sizeof u); - if (val < 0) - perror_with_name (filename); - data_start = exec_data_start; - - data_end = data_start + u.pt_dsize; - stack_start = stack_end - u.pt_ssize; - data_offset = sizeof u; - stack_offset = data_offset + u.pt_dsize; - reg_offset = 0; - - bcopy (&u.pt_aouthdr, &core_aouthdr, sizeof (AOUTHDR)); - printf ("Core file is from \"%s\".\n", u.pt_comm); - if (u.pt_signal > 0) - printf ("Program terminated with signal %d, %s.\n", - u.pt_signal, - u.pt_signal < NSIG - ? sys_siglist[u.pt_signal] - : "(undocumented)"); - - /* Read the register values out of the core file and store - them where `read_register' will find them. */ - - { - register int regno; - - for (regno = 0; regno < NUM_REGS; regno++) - { - char buf[MAX_REGISTER_RAW_SIZE]; - - val = lseek (corechan, register_addr (regno, reg_offset), 0); - if (val < 0) - perror_with_name (filename); - - val = myread (corechan, buf, sizeof buf); - if (val < 0) - perror_with_name (filename); - supply_register (regno, buf); - } - } - } - if (filename[0] == '/') - corefile = savestring (filename, strlen (filename)); - else - { - corefile = concat (current_directory, "/", filename, NULL); - } - - set_current_frame ( create_new_frame (read_register (FP_REGNUM), - read_pc ())); - select_frame (get_current_frame (), 0); - validate_files (); - } - else if (from_tty) - printf ("No core file now.\n"); -} diff --git a/gdb/utils.c b/gdb/utils.c deleted file mode 100644 index 36645ebd1eb..00000000000 --- a/gdb/utils.c +++ /dev/null @@ -1,1269 +0,0 @@ -/* General utility routines for GDB, the GNU debugger. - Copyright (C) 1986, 1989, 1990, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include -#include -#include -#include -#include -#include - -#include "defs.h" -#include "param.h" -#include "signals.h" -#include "gdbcmd.h" -#include "terminal.h" -#include "bfd.h" -#include "target.h" - -extern volatile void return_to_top_level (); -extern volatile void exit (); -extern char *gdb_readline (); -extern char *getenv(); -extern char *malloc(); -extern char *realloc(); - -/* If this definition isn't overridden by the header files, assume - that isatty and fileno exist on this system. */ -#ifndef ISATTY -#define ISATTY(FP) (isatty (fileno (FP))) -#endif - -#ifdef MISSING_VPRINTF -#ifdef __GNU_LIBRARY -#undef MISSING_VPRINTF -#else /* !__GNU_LIBRARY */ - -#ifndef vfprintf -/* Can't #define it since language.c needs it (though FIXME it shouldn't) */ -void -vfprintf (file, format, ap) - FILE *file; - char *format; - va_list ap; -{ - _doprnt (format, ap, file); -} -#endif /* vfprintf */ - -#ifndef vprintf -/* Can't #define it since printcmd.c needs it */ -void -vprintf (format, ap) - char *format; - va_list ap; -{ - vfprintf (stdout, format, ap); -} -#endif /* vprintf */ - -#endif /* GNU_LIBRARY */ -#endif /* MISSING_VPRINTF */ - -void error (); -void fatal (); - -/* Chain of cleanup actions established with make_cleanup, - to be executed if an error happens. */ - -static struct cleanup *cleanup_chain; - -/* Nonzero means a quit has been requested. */ - -int quit_flag; - -/* Nonzero means quit immediately if Control-C is typed now, - rather than waiting until QUIT is executed. */ - -int immediate_quit; - -/* Nonzero means that encoded C++ names should be printed out in their - C++ form rather than raw. */ - -int demangle = 1; - -/* Nonzero means that encoded C++ names should be printed out in their - C++ form even in assembler language displays. If this is set, but - DEMANGLE is zero, names are printed raw, i.e. DEMANGLE controls. */ - -int asm_demangle = 0; - -/* Nonzero means that strings with character values >0x7F should be printed - as octal escapes. Zero means just print the value (e.g. it's an - international character, and the terminal or window can cope.) */ - -int sevenbit_strings = 0; - -/* String to be printed before error messages, if any. */ - -char *error_pre_print; -char *warning_pre_print; - -/* Add a new cleanup to the cleanup_chain, - and return the previous chain pointer - to be passed later to do_cleanups or discard_cleanups. - Args are FUNCTION to clean up with, and ARG to pass to it. */ - -struct cleanup * -make_cleanup (function, arg) - void (*function) (); - int arg; -{ - register struct cleanup *new - = (struct cleanup *) xmalloc (sizeof (struct cleanup)); - register struct cleanup *old_chain = cleanup_chain; - - new->next = cleanup_chain; - new->function = function; - new->arg = arg; - cleanup_chain = new; - - return old_chain; -} - -/* Discard cleanups and do the actions they describe - until we get back to the point OLD_CHAIN in the cleanup_chain. */ - -void -do_cleanups (old_chain) - register struct cleanup *old_chain; -{ - register struct cleanup *ptr; - while ((ptr = cleanup_chain) != old_chain) - { - cleanup_chain = ptr->next; /* Do this first incase recursion */ - (*ptr->function) (ptr->arg); - free (ptr); - } -} - -/* Discard cleanups, not doing the actions they describe, - until we get back to the point OLD_CHAIN in the cleanup_chain. */ - -void -discard_cleanups (old_chain) - register struct cleanup *old_chain; -{ - register struct cleanup *ptr; - while ((ptr = cleanup_chain) != old_chain) - { - cleanup_chain = ptr->next; - free (ptr); - } -} - -/* Set the cleanup_chain to 0, and return the old cleanup chain. */ -struct cleanup * -save_cleanups () -{ - struct cleanup *old_chain = cleanup_chain; - - cleanup_chain = 0; - return old_chain; -} - -/* Restore the cleanup chain from a previously saved chain. */ -void -restore_cleanups (chain) - struct cleanup *chain; -{ - cleanup_chain = chain; -} - -/* This function is useful for cleanups. - Do - - foo = xmalloc (...); - old_chain = make_cleanup (free_current_contents, &foo); - - to arrange to free the object thus allocated. */ - -void -free_current_contents (location) - char **location; -{ - free (*location); -} - -/* Provide a hook for modules wishing to print their own warning messages - to set up the terminal state in a compatible way, without them having - to import all the target_<...> macros. */ - -void -warning_setup () -{ - target_terminal_ours (); - wrap_here(""); /* Force out any buffered output */ - fflush (stdout); -} - -/* Print a warning message. - The first argument STRING is the warning message, used as a fprintf string, - and the remaining args are passed as arguments to it. - The primary difference between warnings and errors is that a warning - does not force the return to command level. */ - -/* VARARGS */ -void -warning (va_alist) - va_dcl -{ - va_list args; - char *string; - - va_start (args); - target_terminal_ours (); - wrap_here(""); /* Force out any buffered output */ - fflush (stdout); - if (warning_pre_print) - fprintf (stderr, warning_pre_print); - string = va_arg (args, char *); - vfprintf (stderr, string, args); - fprintf (stderr, "\n"); - va_end (args); -} - -/* Print an error message and return to command level. - The first argument STRING is the error message, used as a fprintf string, - and the remaining args are passed as arguments to it. */ - -/* VARARGS */ -void -error (va_alist) - va_dcl -{ - va_list args; - char *string; - - va_start (args); - target_terminal_ours (); - wrap_here(""); /* Force out any buffered output */ - fflush (stdout); - if (error_pre_print) - fprintf (stderr, error_pre_print); - string = va_arg (args, char *); - vfprintf (stderr, string, args); - fprintf (stderr, "\n"); - va_end (args); - return_to_top_level (); -} - -/* Print an error message and exit reporting failure. - This is for a error that we cannot continue from. - The arguments are printed a la printf. */ - -/* VARARGS */ -void -fatal (va_alist) - va_dcl -{ - va_list args; - char *string; - - va_start (args); - string = va_arg (args, char *); - fprintf (stderr, "gdb: "); - vfprintf (stderr, string, args); - fprintf (stderr, "\n"); - va_end (args); - exit (1); -} - -/* Print an error message and exit, dumping core. - The arguments are printed a la printf (). */ -/* VARARGS */ -void -fatal_dump_core (va_alist) - va_dcl -{ - va_list args; - char *string; - - va_start (args); - string = va_arg (args, char *); - /* "internal error" is always correct, since GDB should never dump - core, no matter what the input. */ - fprintf (stderr, "gdb internal error: "); - vfprintf (stderr, string, args); - fprintf (stderr, "\n"); - va_end (args); - - signal (SIGQUIT, SIG_DFL); - kill (getpid (), SIGQUIT); - /* We should never get here, but just in case... */ - exit (1); -} - -/* Memory management stuff (malloc friends). */ - -#if defined (NO_MALLOC_CHECK) -void -init_malloc () -{} -#else /* Have mcheck(). */ -static void -malloc_botch () -{ - fatal_dump_core ("Memory corruption"); -} - -void -init_malloc () -{ - mcheck (malloc_botch); - mtrace (); -} -#endif /* Have mcheck(). */ - -/* Like malloc but get error if no storage available. */ - -#ifdef __STDC__ -void * -#else -char * -#endif -xmalloc (size) - long size; -{ - register char *val; - - /* At least one place (dbxread.c:condense_misc_bunches where misc_count == 0) - GDB wants to allocate zero bytes. */ - if (size == 0) - return NULL; - - val = (char *) malloc (size); - if (!val) - fatal ("virtual memory exhausted.", 0); - return val; -} - -/* Like realloc but get error if no storage available. */ - -#ifdef __STDC__ -void * -#else -char * -#endif -xrealloc (ptr, size) - char *ptr; - long size; -{ - register char *val = (char *) realloc (ptr, size); - if (!val) - fatal ("virtual memory exhausted.", 0); - return val; -} - -/* Print the system error message for errno, and also mention STRING - as the file name for which the error was encountered. - Then return to command level. */ - -void -perror_with_name (string) - char *string; -{ - extern int sys_nerr; - extern char *sys_errlist[]; - char *err; - char *combined; - - if (errno < sys_nerr) - err = sys_errlist[errno]; - else - err = "unknown error"; - - combined = (char *) alloca (strlen (err) + strlen (string) + 3); - strcpy (combined, string); - strcat (combined, ": "); - strcat (combined, err); - - /* I understand setting these is a matter of taste. Still, some people - may clear errno but not know about bfd_error. Doing this here is not - unreasonable. */ - bfd_error = no_error; - errno = 0; - - error ("%s.", combined); -} - -/* Print the system error message for ERRCODE, and also mention STRING - as the file name for which the error was encountered. */ - -void -print_sys_errmsg (string, errcode) - char *string; - int errcode; -{ - extern int sys_nerr; - extern char *sys_errlist[]; - char *err; - char *combined; - - if (errcode < sys_nerr) - err = sys_errlist[errcode]; - else - err = "unknown error"; - - combined = (char *) alloca (strlen (err) + strlen (string) + 3); - strcpy (combined, string); - strcat (combined, ": "); - strcat (combined, err); - - printf ("%s.\n", combined); -} - -/* Control C eventually causes this to be called, at a convenient time. */ - -void -quit () -{ - target_terminal_ours (); - wrap_here ((char *)0); /* Force out any pending output */ -#ifdef HAVE_TERMIO - ioctl (fileno (stdout), TCFLSH, 1); -#else /* not HAVE_TERMIO */ - ioctl (fileno (stdout), TIOCFLUSH, 0); -#endif /* not HAVE_TERMIO */ -#ifdef TIOCGPGRP - error ("Quit"); -#else - error ("Quit (expect signal %d when inferior is resumed)", SIGINT); -#endif /* TIOCGPGRP */ -} - -/* Control C comes here */ - -void -request_quit () -{ - quit_flag = 1; - -#ifdef USG - /* Restore the signal handler. */ - signal (SIGINT, request_quit); -#endif - - if (immediate_quit) - quit (); -} - -/* My replacement for the read system call. - Used like `read' but keeps going if `read' returns too soon. */ - -int -myread (desc, addr, len) - int desc; - char *addr; - int len; -{ - register int val; - int orglen = len; - - while (len > 0) - { - val = read (desc, addr, len); - if (val < 0) - return val; - if (val == 0) - return orglen - len; - len -= val; - addr += val; - } - return orglen; -} - -/* Make a copy of the string at PTR with SIZE characters - (and add a null character at the end in the copy). - Uses malloc to get the space. Returns the address of the copy. */ - -char * -savestring (ptr, size) - char *ptr; - int size; -{ - register char *p = (char *) xmalloc (size + 1); - bcopy (ptr, p, size); - p[size] = 0; - return p; -} - -/* The "const" is so it compiles under DGUX (which prototypes strsave - in . FIXME: This should be named "xstrsave", shouldn't it? - Doesn't real strsave return NULL if out of memory? */ -char * -strsave (ptr) - const char *ptr; -{ - return savestring (ptr, strlen (ptr)); -} - -char * -concat (s1, s2, s3) - char *s1, *s2, *s3; -{ - register int len = strlen (s1) + strlen (s2) + strlen (s3) + 1; - register char *val = (char *) xmalloc (len); - strcpy (val, s1); - strcat (val, s2); - strcat (val, s3); - return val; -} - -void -print_spaces (n, file) - register int n; - register FILE *file; -{ - while (n-- > 0) - fputc (' ', file); -} - -/* Ask user a y-or-n question and return 1 iff answer is yes. - Takes three args which are given to printf to print the question. - The first, a control string, should end in "? ". - It should not say how to answer, because we do that. */ - -/* VARARGS */ -int -query (va_alist) - va_dcl -{ - va_list args; - char *ctlstr; - register int answer; - register int ans2; - - /* Automatically answer "yes" if input is not from a terminal. */ - if (!input_from_terminal_p ()) - return 1; - - while (1) - { - va_start (args); - ctlstr = va_arg (args, char *); - vfprintf (stdout, ctlstr, args); - va_end (args); - printf ("(y or n) "); - fflush (stdout); - answer = fgetc (stdin); - clearerr (stdin); /* in case of C-d */ - if (answer == EOF) /* C-d */ - return 1; - if (answer != '\n') /* Eat rest of input line, to EOF or newline */ - do - { - ans2 = fgetc (stdin); - clearerr (stdin); - } - while (ans2 != EOF && ans2 != '\n'); - if (answer >= 'a') - answer -= 040; - if (answer == 'Y') - return 1; - if (answer == 'N') - return 0; - printf ("Please answer y or n.\n"); - } -} - -/* Parse a C escape sequence. STRING_PTR points to a variable - containing a pointer to the string to parse. That pointer - should point to the character after the \. That pointer - is updated past the characters we use. The value of the - escape sequence is returned. - - A negative value means the sequence \ newline was seen, - which is supposed to be equivalent to nothing at all. - - If \ is followed by a null character, we return a negative - value and leave the string pointer pointing at the null character. - - If \ is followed by 000, we return 0 and leave the string pointer - after the zeros. A value of 0 does not mean end of string. */ - -int -parse_escape (string_ptr) - char **string_ptr; -{ - register int c = *(*string_ptr)++; - switch (c) - { - case 'a': - return 007; /* Bell (alert) char */ - case 'b': - return '\b'; - case 'e': /* Escape character */ - return 033; - case 'f': - return '\f'; - case 'n': - return '\n'; - case 'r': - return '\r'; - case 't': - return '\t'; - case 'v': - return '\v'; - case '\n': - return -2; - case 0: - (*string_ptr)--; - return 0; - case '^': - c = *(*string_ptr)++; - if (c == '\\') - c = parse_escape (string_ptr); - if (c == '?') - return 0177; - return (c & 0200) | (c & 037); - - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - { - register int i = c - '0'; - register int count = 0; - while (++count < 3) - { - if ((c = *(*string_ptr)++) >= '0' && c <= '7') - { - i *= 8; - i += c - '0'; - } - else - { - (*string_ptr)--; - break; - } - } - return i; - } - default: - return c; - } -} - -/* Print the character CH on STREAM as part of the contents - of a literal string whose delimiter is QUOTER. */ - -void -printchar (ch, stream, quoter) - unsigned char ch; - FILE *stream; - int quoter; -{ - register int c = ch; - - if (c < 040 || (sevenbit_strings && c >= 0177)) { - switch (c) - { - case '\n': - fputs_filtered ("\\n", stream); - break; - case '\b': - fputs_filtered ("\\b", stream); - break; - case '\t': - fputs_filtered ("\\t", stream); - break; - case '\f': - fputs_filtered ("\\f", stream); - break; - case '\r': - fputs_filtered ("\\r", stream); - break; - case '\033': - fputs_filtered ("\\e", stream); - break; - case '\007': - fputs_filtered ("\\a", stream); - break; - default: - fprintf_filtered (stream, "\\%.3o", (unsigned int) c); - break; - } - } else { - if (c == '\\' || c == quoter) - fputs_filtered ("\\", stream); - fprintf_filtered (stream, "%c", c); - } -} - -/* Number of lines per page or UINT_MAX if paging is disabled. */ -static unsigned int lines_per_page; -/* Number of chars per line or UNIT_MAX is line folding is disabled. */ -static unsigned int chars_per_line; -/* Current count of lines printed on this page, chars on this line. */ -static unsigned int lines_printed, chars_printed; - -/* Buffer and start column of buffered text, for doing smarter word- - wrapping. When someone calls wrap_here(), we start buffering output - that comes through fputs_filtered(). If we see a newline, we just - spit it out and forget about the wrap_here(). If we see another - wrap_here(), we spit it out and remember the newer one. If we see - the end of the line, we spit out a newline, the indent, and then - the buffered output. - - wrap_column is the column number on the screen where wrap_buffer begins. - When wrap_column is zero, wrapping is not in effect. - wrap_buffer is malloc'd with chars_per_line+2 bytes. - When wrap_buffer[0] is null, the buffer is empty. - wrap_pointer points into it at the next character to fill. - wrap_indent is the string that should be used as indentation if the - wrap occurs. */ - -static char *wrap_buffer, *wrap_pointer, *wrap_indent; -static int wrap_column; - -/* ARGSUSED */ -static void -set_width_command (args, from_tty, c) - char *args; - int from_tty; - struct cmd_list_element *c; -{ - if (!wrap_buffer) - { - wrap_buffer = (char *) xmalloc (chars_per_line + 2); - wrap_buffer[0] = '\0'; - } - else - wrap_buffer = (char *) xrealloc (wrap_buffer, chars_per_line + 2); - wrap_pointer = wrap_buffer; /* Start it at the beginning */ -} - -static void -prompt_for_continue () -{ - char *ignore; - - immediate_quit++; - ignore = gdb_readline ("---Type to continue---"); - if (ignore) - free (ignore); - chars_printed = lines_printed = 0; - immediate_quit--; - dont_repeat (); /* Forget prev cmd -- CR won't repeat it. */ -} - -/* Reinitialize filter; ie. tell it to reset to original values. */ - -void -reinitialize_more_filter () -{ - lines_printed = 0; - chars_printed = 0; -} - -/* Indicate that if the next sequence of characters overflows the line, - a newline should be inserted here rather than when it hits the end. - If INDENT is nonzero, it is a string to be printed to indent the - wrapped part on the next line. INDENT must remain accessible until - the next call to wrap_here() or until a newline is printed through - fputs_filtered(). - - If the line is already overfull, we immediately print a newline and - the indentation, and disable further wrapping. - - If we don't know the width of lines, but we know the page height, - we must not wrap words, but should still keep track of newlines - that were explicitly printed. - - INDENT should not contain tabs, as that - will mess up the char count on the next line. FIXME. */ - -void -wrap_here(indent) - char *indent; -{ - if (wrap_buffer[0]) - { - *wrap_pointer = '\0'; - fputs (wrap_buffer, stdout); - } - wrap_pointer = wrap_buffer; - wrap_buffer[0] = '\0'; - if (chars_per_line == UINT_MAX) /* No line overflow checking */ - { - wrap_column = 0; - } - else if (chars_printed >= chars_per_line) - { - puts_filtered ("\n"); - puts_filtered (indent); - wrap_column = 0; - } - else - { - wrap_column = chars_printed; - wrap_indent = indent; - } -} - -/* Like fputs but pause after every screenful, and can wrap at points - other than the final character of a line. - Unlike fputs, fputs_filtered does not return a value. - It is OK for LINEBUFFER to be NULL, in which case just don't print - anything. - - Note that a longjmp to top level may occur in this routine - (since prompt_for_continue may do so) so this routine should not be - called when cleanups are not in place. */ - -void -fputs_filtered (linebuffer, stream) - char *linebuffer; - FILE *stream; -{ - char *lineptr; - - if (linebuffer == 0) - return; - - /* Don't do any filtering if it is disabled. */ - if (stream != stdout - || (lines_per_page == UINT_MAX && chars_per_line == UINT_MAX)) - { - fputs (linebuffer, stream); - return; - } - - /* Go through and output each character. Show line extension - when this is necessary; prompt user for new page when this is - necessary. */ - - lineptr = linebuffer; - while (*lineptr) - { - /* Possible new page. */ - if (lines_printed >= lines_per_page - 1) - prompt_for_continue (); - - while (*lineptr && *lineptr != '\n') - { - /* Print a single line. */ - if (*lineptr == '\t') - { - if (wrap_column) - *wrap_pointer++ = '\t'; - else - putc ('\t', stream); - /* Shifting right by 3 produces the number of tab stops - we have already passed, and then adding one and - shifting left 3 advances to the next tab stop. */ - chars_printed = ((chars_printed >> 3) + 1) << 3; - lineptr++; - } - else - { - if (wrap_column) - *wrap_pointer++ = *lineptr; - else - putc (*lineptr, stream); - chars_printed++; - lineptr++; - } - - if (chars_printed >= chars_per_line) - { - unsigned int save_chars = chars_printed; - - chars_printed = 0; - lines_printed++; - /* If we aren't actually wrapping, don't output newline -- - if chars_per_line is right, we probably just overflowed - anyway; if it's wrong, let us keep going. */ - if (wrap_column) - putc ('\n', stream); - - /* Possible new page. */ - if (lines_printed >= lines_per_page - 1) - prompt_for_continue (); - - /* Now output indentation and wrapped string */ - if (wrap_column) - { - if (wrap_indent) - fputs (wrap_indent, stream); - *wrap_pointer = '\0'; /* Null-terminate saved stuff */ - fputs (wrap_buffer, stream); /* and eject it */ - /* FIXME, this strlen is what prevents wrap_indent from - containing tabs. However, if we recurse to print it - and count its chars, we risk trouble if wrap_indent is - longer than (the user settable) chars_per_line. - Note also that this can set chars_printed > chars_per_line - if we are printing a long string. */ - chars_printed = strlen (wrap_indent) - + (save_chars - wrap_column); - wrap_pointer = wrap_buffer; /* Reset buffer */ - wrap_buffer[0] = '\0'; - wrap_column = 0; /* And disable fancy wrap */ - } - } - } - - if (*lineptr == '\n') - { - chars_printed = 0; - wrap_here ((char *)0); /* Spit out chars, cancel further wraps */ - lines_printed++; - putc ('\n', stream); - lineptr++; - } - } -} - - -/* fputs_demangled is a variant of fputs_filtered that - demangles g++ names.*/ - -void -fputs_demangled (linebuffer, stream, arg_mode) - char *linebuffer; - FILE *stream; - int arg_mode; -{ -#ifdef __STDC__ - extern char *cplus_demangle (const char *, int); -#else - extern char *cplus_demangle (); -#endif -#define SYMBOL_MAX 1024 - -#define SYMBOL_CHAR(c) (isascii(c) \ - && (isalnum(c) || (c) == '_' || (c) == CPLUS_MARKER)) - - char buf[SYMBOL_MAX+1]; -# define SLOP 5 /* How much room to leave in buf */ - char *p; - - if (linebuffer == NULL) - return; - - /* If user wants to see raw output, no problem. */ - if (!demangle) { - fputs_filtered (linebuffer, stream); - return; - } - - p = linebuffer; - - while ( *p != (char) 0 ) { - int i = 0; - - /* collect non-interesting characters into buf */ - while ( *p != (char) 0 && !SYMBOL_CHAR(*p) && i < (int)sizeof(buf)-SLOP ) { - buf[i++] = *p; - p++; - } - if (i > 0) { - /* output the non-interesting characters without demangling */ - buf[i] = (char) 0; - fputs_filtered(buf, stream); - i = 0; /* reset buf */ - } - - /* and now the interesting characters */ - while (i < SYMBOL_MAX - && *p != (char) 0 - && SYMBOL_CHAR(*p) - && i < (int)sizeof(buf) - SLOP) { - buf[i++] = *p; - p++; - } - buf[i] = (char) 0; - if (i > 0) { - char * result; - - if ( (result = cplus_demangle(buf, arg_mode)) != NULL ) { - fputs_filtered(result, stream); - free(result); - } - else { - fputs_filtered(buf, stream); - } - } - } -} - -/* Print a variable number of ARGS using format FORMAT. If this - information is going to put the amount written (since the last call - to INITIALIZE_MORE_FILTER or the last page break) over the page size, - print out a pause message and do a gdb_readline to get the users - permision to continue. - - Unlike fprintf, this function does not return a value. - - We implement three variants, vfprintf (takes a vararg list and stream), - fprintf (takes a stream to write on), and printf (the usual). - - Note that this routine has a restriction that the length of the - final output line must be less than 255 characters *or* it must be - less than twice the size of the format string. This is a very - arbitrary restriction, but it is an internal restriction, so I'll - put it in. This means that the %s format specifier is almost - useless; unless the caller can GUARANTEE that the string is short - enough, fputs_filtered should be used instead. - - Note also that a longjmp to top level may occur in this routine - (since prompt_for_continue may do so) so this routine should not be - called when cleanups are not in place. */ - -#if !defined(MISSING_VPRINTF) || defined (vsprintf) -/* VARARGS */ -void -vfprintf_filtered (stream, format, args) - va_list args; -#else -void fprintf_filtered (stream, format, arg1, arg2, arg3, arg4, arg5, arg6) -#endif - FILE *stream; - char *format; -{ - static char *linebuffer = (char *) 0; - static int line_size; - int format_length; - - format_length = strlen (format); - - /* Allocated linebuffer for the first time. */ - if (!linebuffer) - { - linebuffer = (char *) xmalloc (255); - line_size = 255; - } - - /* Reallocate buffer to a larger size if this is necessary. */ - if (format_length * 2 > line_size) - { - line_size = format_length * 2; - - /* You don't have to copy. */ - free (linebuffer); - linebuffer = (char *) xmalloc (line_size); - } - - - /* This won't blow up if the restrictions described above are - followed. */ -#if !defined(MISSING_VPRINTF) || defined (vsprintf) - (void) vsprintf (linebuffer, format, args); -#else - (void) sprintf (linebuffer, format, arg1, arg2, arg3, arg4, arg5, arg6); -#endif - - fputs_filtered (linebuffer, stream); -} - -#if !defined(MISSING_VPRINTF) || defined (vsprintf) -/* VARARGS */ -void -fprintf_filtered (va_alist) - va_dcl -{ - va_list args; - FILE *stream; - char *format; - - va_start (args); - stream = va_arg (args, FILE *); - format = va_arg (args, char *); - - /* This won't blow up if the restrictions described above are - followed. */ - (void) vfprintf_filtered (stream, format, args); - va_end (args); -} - -/* VARARGS */ -void -printf_filtered (va_alist) - va_dcl -{ - va_list args; - char *format; - - va_start (args); - format = va_arg (args, char *); - - (void) vfprintf_filtered (stdout, format, args); - va_end (args); -} -#else -void -printf_filtered (format, arg1, arg2, arg3, arg4, arg5, arg6) - char *format; - int arg1, arg2, arg3, arg4, arg5, arg6; -{ - fprintf_filtered (stdout, format, arg1, arg2, arg3, arg4, arg5, arg6); -} -#endif - -/* Easy */ - -void -puts_filtered (string) - char *string; -{ - fputs_filtered (string, stdout); -} - -/* Return a pointer to N spaces and a null. The pointer is good - until the next call to here. */ -char * -n_spaces (n) - int n; -{ - register char *t; - static char *spaces; - static int max_spaces; - - if (n > max_spaces) - { - if (spaces) - free (spaces); - spaces = malloc (n+1); - for (t = spaces+n; t != spaces;) - *--t = ' '; - spaces[n] = '\0'; - max_spaces = n; - } - - return spaces + max_spaces - n; -} - -/* Print N spaces. */ -void -print_spaces_filtered (n, stream) - int n; - FILE *stream; -{ - fputs_filtered (n_spaces (n), stream); -} - -/* C++ demangler stuff. */ -char *cplus_demangle (); - -/* Print NAME on STREAM, demangling if necessary. */ -void -fprint_symbol (stream, name) - FILE *stream; - char *name; -{ - char *demangled; - if ((!demangle) || NULL == (demangled = cplus_demangle (name, 1))) - fputs_filtered (name, stream); - else - { - fputs_filtered (demangled, stream); - free (demangled); - } -} - -void -_initialize_utils () -{ - struct cmd_list_element *c; - - c = add_set_cmd ("width", class_support, var_uinteger, - (char *)&chars_per_line, - "Set number of characters gdb thinks are in a line.", - &setlist); - add_show_from_set (c, &showlist); - c->function = set_width_command; - - add_show_from_set - (add_set_cmd ("height", class_support, - var_uinteger, (char *)&lines_per_page, - "Set number of lines gdb thinks are in a page.", &setlist), - &showlist); - - /* These defaults will be used if we are unable to get the correct - values from termcap. */ - lines_per_page = 24; - chars_per_line = 80; - /* Initialize the screen height and width from termcap. */ - { - char *termtype = getenv ("TERM"); - - /* Positive means success, nonpositive means failure. */ - int status; - - /* 2048 is large enough for all known terminals, according to the - GNU termcap manual. */ - char term_buffer[2048]; - - if (termtype) - { - status = tgetent (term_buffer, termtype); - if (status > 0) - { - int val; - - val = tgetnum ("li"); - if (val >= 0) - lines_per_page = val; - else - /* The number of lines per page is not mentioned - in the terminal description. This probably means - that paging is not useful (e.g. emacs shell window), - so disable paging. */ - lines_per_page = UINT_MAX; - - val = tgetnum ("co"); - if (val >= 0) - chars_per_line = val; - } - } - } - - /* If the output is not a terminal, don't paginate it. */ - if (!ISATTY (stdout)) - lines_per_page = UINT_MAX; - - set_width_command ((char *)NULL, 0, c); - - add_show_from_set - (add_set_cmd ("demangle", class_support, var_boolean, - (char *)&demangle, - "Set demangling of encoded C++ names when displaying symbols.", - &setprintlist), - &showprintlist); - - add_show_from_set - (add_set_cmd ("sevenbit-strings", class_support, var_boolean, - (char *)&sevenbit_strings, - "Set printing of 8-bit characters in strings as \\nnn.", - &setprintlist), - &showprintlist); - - add_show_from_set - (add_set_cmd ("asm-demangle", class_support, var_boolean, - (char *)&asm_demangle, - "Set demangling of C++ names in disassembly listings.", - &setprintlist), - &showprintlist); -} diff --git a/gdb/valarith.c b/gdb/valarith.c deleted file mode 100644 index 6269defec53..00000000000 --- a/gdb/valarith.c +++ /dev/null @@ -1,694 +0,0 @@ -/* Perform arithmetic and other operations on values, for GDB. - Copyright (C) 1986, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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 1, or (at your option) -any later version. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include "defs.h" -#include "param.h" -#include "value.h" -#include "expression.h" -#include "target.h" -#include - - -value value_x_binop (); -value value_subscripted_rvalue (); - -value -value_add (arg1, arg2) - value arg1, arg2; -{ - register value val, valint, valptr; - register int len; - - COERCE_ARRAY (arg1); - COERCE_ARRAY (arg2); - - if ((TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_PTR - || TYPE_CODE (VALUE_TYPE (arg2)) == TYPE_CODE_PTR) - && - (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_INT - || TYPE_CODE (VALUE_TYPE (arg2)) == TYPE_CODE_INT)) - /* Exactly one argument is a pointer, and one is an integer. */ - { - if (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_PTR) - { - valptr = arg1; - valint = arg2; - } - else - { - valptr = arg2; - valint = arg1; - } - len = TYPE_LENGTH (TYPE_TARGET_TYPE (VALUE_TYPE (valptr))); - if (len == 0) len = 1; /* For (void *) */ - val = value_from_long (builtin_type_long, - value_as_long (valptr) - + (len * value_as_long (valint))); - VALUE_TYPE (val) = VALUE_TYPE (valptr); - return val; - } - - return value_binop (arg1, arg2, BINOP_ADD); -} - -value -value_sub (arg1, arg2) - value arg1, arg2; -{ - register value val; - - COERCE_ARRAY (arg1); - COERCE_ARRAY (arg2); - - if (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_PTR) - { - if (TYPE_CODE (VALUE_TYPE (arg2)) == TYPE_CODE_INT) - { - /* pointer - integer. */ - val = value_from_long - (builtin_type_long, - value_as_long (arg1) - - (TYPE_LENGTH (TYPE_TARGET_TYPE (VALUE_TYPE (arg1))) - * value_as_long (arg2))); - VALUE_TYPE (val) = VALUE_TYPE (arg1); - return val; - } - else if (VALUE_TYPE (arg1) == VALUE_TYPE (arg2)) - { - /* pointer to - pointer to . */ - val = value_from_long - (builtin_type_long, - (value_as_long (arg1) - value_as_long (arg2)) - / TYPE_LENGTH (TYPE_TARGET_TYPE (VALUE_TYPE (arg1)))); - return val; - } - else - { - error ("\ -First argument of `-' is a pointer and second argument is neither\n\ -an integer nor a pointer of the same type."); - } - } - - return value_binop (arg1, arg2, BINOP_SUB); -} - -/* Return the value of ARRAY[IDX]. */ - -value -value_subscript (array, idx) - value array, idx; -{ - if (TYPE_CODE (VALUE_TYPE (array)) == TYPE_CODE_ARRAY - && VALUE_LVAL (array) != lval_memory) - return value_subscripted_rvalue (array, idx); - else - return value_ind (value_add (array, idx)); -} - -/* Return the value of EXPR[IDX], expr an aggregate rvalue - (eg, a vector register). This routine used to promote floats - to doubles, but no longer does. */ - -value -value_subscripted_rvalue (array, idx) - value array, idx; -{ - struct type *elt_type = TYPE_TARGET_TYPE (VALUE_TYPE (array)); - int elt_size = TYPE_LENGTH (elt_type); - int elt_offs = elt_size * value_as_long (idx); - value v; - - if (elt_offs >= TYPE_LENGTH (VALUE_TYPE (array))) - error ("no such vector element"); - - v = allocate_value (elt_type); - bcopy (VALUE_CONTENTS (array) + elt_offs, VALUE_CONTENTS (v), elt_size); - - if (VALUE_LVAL (array) == lval_internalvar) - VALUE_LVAL (v) = lval_internalvar_component; - else - VALUE_LVAL (v) = not_lval; - VALUE_ADDRESS (v) = VALUE_ADDRESS (array); - VALUE_OFFSET (v) = VALUE_OFFSET (array) + elt_offs; - VALUE_BITSIZE (v) = elt_size * 8; - return v; -} - -/* Check to see if either argument is a structure. This is called so - we know whether to go ahead with the normal binop or look for a - user defined function instead. - - For now, we do not overload the `=' operator. */ - -int -binop_user_defined_p (op, arg1, arg2) - enum exp_opcode op; - value arg1, arg2; -{ - if (op == BINOP_ASSIGN) - return 0; - return (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_STRUCT - || TYPE_CODE (VALUE_TYPE (arg2)) == TYPE_CODE_STRUCT - || (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_REF - && TYPE_CODE (TYPE_TARGET_TYPE (VALUE_TYPE (arg1))) == TYPE_CODE_STRUCT) - || (TYPE_CODE (VALUE_TYPE (arg2)) == TYPE_CODE_REF - && TYPE_CODE (TYPE_TARGET_TYPE (VALUE_TYPE (arg2))) == TYPE_CODE_STRUCT)); -} - -/* Check to see if argument is a structure. This is called so - we know whether to go ahead with the normal unop or look for a - user defined function instead. - - For now, we do not overload the `&' operator. */ - -int unop_user_defined_p (op, arg1) - enum exp_opcode op; - value arg1; -{ - if (op == UNOP_ADDR) - return 0; - return (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_STRUCT - || (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_REF - && TYPE_CODE (TYPE_TARGET_TYPE (VALUE_TYPE (arg1))) == TYPE_CODE_STRUCT)); -} - -/* We know either arg1 or arg2 is a structure, so try to find the right - user defined function. Create an argument vector that calls - arg1.operator @ (arg1,arg2) and return that value (where '@' is any - binary operator which is legal for GNU C++). */ - -value -value_x_binop (arg1, arg2, op, otherop) - value arg1, arg2; - enum exp_opcode op, otherop; -{ - value * argvec; - char *ptr; - char tstr[13]; - int static_memfuncp; - - COERCE_ENUM (arg1); - COERCE_ENUM (arg2); - - /* now we know that what we have to do is construct our - arg vector and find the right function to call it with. */ - - if (TYPE_CODE (VALUE_TYPE (arg1)) != TYPE_CODE_STRUCT) - error ("Can't do that binary op on that type"); /* FIXME be explicit */ - - argvec = (value *) alloca (sizeof (value) * 4); - argvec[1] = value_addr (arg1); - argvec[2] = arg2; - argvec[3] = 0; - - /* make the right function name up */ - strcpy(tstr, "operator__"); - ptr = tstr+8; - switch (op) - { - case BINOP_ADD: strcpy(ptr,"+"); break; - case BINOP_SUB: strcpy(ptr,"-"); break; - case BINOP_MUL: strcpy(ptr,"*"); break; - case BINOP_DIV: strcpy(ptr,"/"); break; - case BINOP_REM: strcpy(ptr,"%"); break; - case BINOP_LSH: strcpy(ptr,"<<"); break; - case BINOP_RSH: strcpy(ptr,">>"); break; - case BINOP_LOGAND: strcpy(ptr,"&"); break; - case BINOP_LOGIOR: strcpy(ptr,"|"); break; - case BINOP_LOGXOR: strcpy(ptr,"^"); break; - case BINOP_AND: strcpy(ptr,"&&"); break; - case BINOP_OR: strcpy(ptr,"||"); break; - case BINOP_MIN: strcpy(ptr,"?"); break; - case BINOP_ASSIGN: strcpy(ptr,"="); break; - case BINOP_ASSIGN_MODIFY: - switch (otherop) - { - case BINOP_ADD: strcpy(ptr,"+="); break; - case BINOP_SUB: strcpy(ptr,"-="); break; - case BINOP_MUL: strcpy(ptr,"*="); break; - case BINOP_DIV: strcpy(ptr,"/="); break; - case BINOP_REM: strcpy(ptr,"%="); break; - case BINOP_LOGAND: strcpy(ptr,"&="); break; - case BINOP_LOGIOR: strcpy(ptr,"|="); break; - case BINOP_LOGXOR: strcpy(ptr,"^="); break; - default: - error ("Invalid binary operation specified."); - } - break; - case BINOP_SUBSCRIPT: strcpy(ptr,"[]"); break; - case BINOP_EQUAL: strcpy(ptr,"=="); break; - case BINOP_NOTEQUAL: strcpy(ptr,"!="); break; - case BINOP_LESS: strcpy(ptr,"<"); break; - case BINOP_GTR: strcpy(ptr,">"); break; - case BINOP_GEQ: strcpy(ptr,">="); break; - case BINOP_LEQ: strcpy(ptr,"<="); break; - default: - error ("Invalid binary operation specified."); - } - argvec[0] = value_struct_elt (&arg1, argvec+1, tstr, &static_memfuncp, "structure"); - if (argvec[0]) - { - if (static_memfuncp) - { - argvec[1] = argvec[0]; - argvec++; - } - return target_call_function (argvec[0], 2 - static_memfuncp, argvec + 1); - } - error ("member function %s not found", tstr); -#ifdef lint - return target_call_function (argvec[0], 2 - static_memfuncp, argvec + 1); -#endif -} - -/* We know that arg1 is a structure, so try to find a unary user - defined operator that matches the operator in question. - Create an argument vector that calls arg1.operator @ (arg1) - and return that value (where '@' is (almost) any unary operator which - is legal for GNU C++). */ - -value -value_x_unop (arg1, op) - value arg1; - enum exp_opcode op; -{ - value * argvec; - char *ptr; - char tstr[13]; - int static_memfuncp; - - COERCE_ENUM (arg1); - - /* now we know that what we have to do is construct our - arg vector and find the right function to call it with. */ - - if (TYPE_CODE (VALUE_TYPE (arg1)) != TYPE_CODE_STRUCT) - error ("Can't do that unary op on that type"); /* FIXME be explicit */ - - argvec = (value *) alloca (sizeof (value) * 3); - argvec[1] = value_addr (arg1); - argvec[2] = 0; - - /* make the right function name up */ - strcpy(tstr,"operator__"); - ptr = tstr+8; - switch (op) - { - case UNOP_PREINCREMENT: strcpy(ptr,"++"); break; - case UNOP_PREDECREMENT: strcpy(ptr,"++"); break; - case UNOP_POSTINCREMENT: strcpy(ptr,"++"); break; - case UNOP_POSTDECREMENT: strcpy(ptr,"++"); break; - case UNOP_ZEROP: strcpy(ptr,"!"); break; - case UNOP_LOGNOT: strcpy(ptr,"~"); break; - case UNOP_NEG: strcpy(ptr,"-"); break; - default: - error ("Invalid binary operation specified."); - } - argvec[0] = value_struct_elt (&arg1, argvec+1, tstr, &static_memfuncp, "structure"); - if (argvec[0]) - { - if (static_memfuncp) - { - argvec[1] = argvec[0]; - argvec++; - } - return target_call_function (argvec[0], 1 - static_memfuncp, argvec + 1); - } - error ("member function %s not found", tstr); - return 0; /* For lint -- never reached */ -} - -/* Perform a binary operation on two integers or two floats. - Does not support addition and subtraction on pointers; - use value_add or value_sub if you want to handle those possibilities. */ - -value -value_binop (arg1, arg2, op) - value arg1, arg2; - int op; -{ - register value val; - - COERCE_ENUM (arg1); - COERCE_ENUM (arg2); - - if ((TYPE_CODE (VALUE_TYPE (arg1)) != TYPE_CODE_FLT - && - TYPE_CODE (VALUE_TYPE (arg1)) != TYPE_CODE_INT) - || - (TYPE_CODE (VALUE_TYPE (arg2)) != TYPE_CODE_FLT - && - TYPE_CODE (VALUE_TYPE (arg2)) != TYPE_CODE_INT)) - error ("Argument to arithmetic operation not a number."); - - if (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_FLT - || - TYPE_CODE (VALUE_TYPE (arg2)) == TYPE_CODE_FLT) - { - double v1, v2, v; - v1 = value_as_double (arg1); - v2 = value_as_double (arg2); - switch (op) - { - case BINOP_ADD: - v = v1 + v2; - break; - - case BINOP_SUB: - v = v1 - v2; - break; - - case BINOP_MUL: - v = v1 * v2; - break; - - case BINOP_DIV: - v = v1 / v2; - break; - - default: - error ("Integer-only operation on floating point number."); - } - - val = allocate_value (builtin_type_double); - SWAP_TARGET_AND_HOST (&v, sizeof (v)); - *(double *) VALUE_CONTENTS_RAW (val) = v; - } - else - /* Integral operations here. */ - { - /* Should we promote to unsigned longest? */ - if ((TYPE_UNSIGNED (VALUE_TYPE (arg1)) - || TYPE_UNSIGNED (VALUE_TYPE (arg2))) - && (TYPE_LENGTH (VALUE_TYPE (arg1)) >= sizeof (unsigned LONGEST) - || TYPE_LENGTH (VALUE_TYPE (arg1)) >= sizeof (unsigned LONGEST))) - { - unsigned LONGEST v1, v2, v; - v1 = (unsigned LONGEST) value_as_long (arg1); - v2 = (unsigned LONGEST) value_as_long (arg2); - - switch (op) - { - case BINOP_ADD: - v = v1 + v2; - break; - - case BINOP_SUB: - v = v1 - v2; - break; - - case BINOP_MUL: - v = v1 * v2; - break; - - case BINOP_DIV: - v = v1 / v2; - break; - - case BINOP_REM: - v = v1 % v2; - break; - - case BINOP_LSH: - v = v1 << v2; - break; - - case BINOP_RSH: - v = v1 >> v2; - break; - - case BINOP_LOGAND: - v = v1 & v2; - break; - - case BINOP_LOGIOR: - v = v1 | v2; - break; - - case BINOP_LOGXOR: - v = v1 ^ v2; - break; - - case BINOP_AND: - v = v1 && v2; - break; - - case BINOP_OR: - v = v1 || v2; - break; - - case BINOP_MIN: - v = v1 < v2 ? v1 : v2; - break; - - case BINOP_MAX: - v = v1 > v2 ? v1 : v2; - break; - - default: - error ("Invalid binary operation on numbers."); - } - - val = allocate_value (BUILTIN_TYPE_UNSIGNED_LONGEST); - SWAP_TARGET_AND_HOST (&v, sizeof (v)); - *(unsigned LONGEST *) VALUE_CONTENTS_RAW (val) = v; - } - else - { - LONGEST v1, v2, v; - v1 = value_as_long (arg1); - v2 = value_as_long (arg2); - - switch (op) - { - case BINOP_ADD: - v = v1 + v2; - break; - - case BINOP_SUB: - v = v1 - v2; - break; - - case BINOP_MUL: - v = v1 * v2; - break; - - case BINOP_DIV: - v = v1 / v2; - break; - - case BINOP_REM: - v = v1 % v2; - break; - - case BINOP_LSH: - v = v1 << v2; - break; - - case BINOP_RSH: - v = v1 >> v2; - break; - - case BINOP_LOGAND: - v = v1 & v2; - break; - - case BINOP_LOGIOR: - v = v1 | v2; - break; - - case BINOP_LOGXOR: - v = v1 ^ v2; - break; - - case BINOP_AND: - v = v1 && v2; - break; - - case BINOP_OR: - v = v1 || v2; - break; - - case BINOP_MIN: - v = v1 < v2 ? v1 : v2; - break; - - case BINOP_MAX: - v = v1 > v2 ? v1 : v2; - break; - - default: - error ("Invalid binary operation on numbers."); - } - - val = allocate_value (BUILTIN_TYPE_LONGEST); - SWAP_TARGET_AND_HOST (&v, sizeof (v)); - *(LONGEST *) VALUE_CONTENTS_RAW (val) = v; - } - } - - return val; -} - -/* Simulate the C operator ! -- return 1 if ARG1 contains zeros. */ - -int -value_zerop (arg1) - value arg1; -{ - register int len; - register char *p; - - COERCE_ARRAY (arg1); - - len = TYPE_LENGTH (VALUE_TYPE (arg1)); - p = VALUE_CONTENTS (arg1); - - while (--len >= 0) - { - if (*p++) - break; - } - - return len < 0; -} - -/* Simulate the C operator == by returning a 1 - iff ARG1 and ARG2 have equal contents. */ - -int -value_equal (arg1, arg2) - register value arg1, arg2; - -{ - register int len; - register char *p1, *p2; - enum type_code code1; - enum type_code code2; - - COERCE_ARRAY (arg1); - COERCE_ARRAY (arg2); - - code1 = TYPE_CODE (VALUE_TYPE (arg1)); - code2 = TYPE_CODE (VALUE_TYPE (arg2)); - - if (code1 == TYPE_CODE_INT && code2 == TYPE_CODE_INT) - return value_as_long (arg1) == value_as_long (arg2); - else if ((code1 == TYPE_CODE_FLT || code1 == TYPE_CODE_INT) - && (code2 == TYPE_CODE_FLT || code2 == TYPE_CODE_INT)) - return value_as_double (arg1) == value_as_double (arg2); - else if ((code1 == TYPE_CODE_PTR && code2 == TYPE_CODE_INT) - || (code2 == TYPE_CODE_PTR && code1 == TYPE_CODE_INT)) - return (char *) value_as_long (arg1) == (char *) value_as_long (arg2); - else if (code1 == code2 - && ((len = TYPE_LENGTH (VALUE_TYPE (arg1))) - == TYPE_LENGTH (VALUE_TYPE (arg2)))) - { - p1 = VALUE_CONTENTS (arg1); - p2 = VALUE_CONTENTS (arg2); - while (--len >= 0) - { - if (*p1++ != *p2++) - break; - } - return len < 0; - } - else - { - error ("Invalid type combination in equality test."); - return 0; /* For lint -- never reached */ - } -} - -/* Simulate the C operator < by returning 1 - iff ARG1's contents are less than ARG2's. */ - -int -value_less (arg1, arg2) - register value arg1, arg2; -{ - register enum type_code code1; - register enum type_code code2; - - COERCE_ARRAY (arg1); - COERCE_ARRAY (arg2); - - code1 = TYPE_CODE (VALUE_TYPE (arg1)); - code2 = TYPE_CODE (VALUE_TYPE (arg2)); - - if (code1 == TYPE_CODE_INT && code2 == TYPE_CODE_INT) - { - if (TYPE_UNSIGNED (VALUE_TYPE (arg1)) - || TYPE_UNSIGNED (VALUE_TYPE (arg2))) - return (unsigned)value_as_long (arg1) < (unsigned)value_as_long (arg2); - else - return value_as_long (arg1) < value_as_long (arg2); - } - else if ((code1 == TYPE_CODE_FLT || code1 == TYPE_CODE_INT) - && (code2 == TYPE_CODE_FLT || code2 == TYPE_CODE_INT)) - return value_as_double (arg1) < value_as_double (arg2); - else if ((code1 == TYPE_CODE_PTR || code1 == TYPE_CODE_INT) - && (code2 == TYPE_CODE_PTR || code2 == TYPE_CODE_INT)) - { - /* FIXME, this assumes that host and target char *'s are the same! */ - return (char *) value_as_long (arg1) < (char *) value_as_long (arg2); - } - else - { - error ("Invalid type combination in ordering comparison."); - return 0; - } -} - -/* The unary operators - and ~. Both free the argument ARG1. */ - -value -value_neg (arg1) - register value arg1; -{ - register struct type *type; - - COERCE_ENUM (arg1); - - type = VALUE_TYPE (arg1); - - if (TYPE_CODE (type) == TYPE_CODE_FLT) - return value_from_double (type, - value_as_double (arg1)); - else if (TYPE_CODE (type) == TYPE_CODE_INT) - return value_from_long (type, - value_as_long (arg1)); - else { - error ("Argument to negate operation not a number."); - return 0; /* For lint -- never reached */ - } -} - -value -value_lognot (arg1) - register value arg1; -{ - COERCE_ENUM (arg1); - - if (TYPE_CODE (VALUE_TYPE (arg1)) != TYPE_CODE_INT) - error ("Argument to complement operation not an integer."); - - return value_from_long (VALUE_TYPE (arg1), ~ value_as_long (arg1)); -} - diff --git a/gdb/valops.c b/gdb/valops.c deleted file mode 100644 index 07c96af55b9..00000000000 --- a/gdb/valops.c +++ /dev/null @@ -1,1498 +0,0 @@ -/* Perform non-arithmetic operations on values, for GDB. - Copyright (C) 1986, 1987, 1989 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "defs.h" -#include "param.h" -#include "symtab.h" -#include "value.h" -#include "frame.h" -#include "inferior.h" -#include "gdbcore.h" -#include "target.h" - -#include - -/* Local functions. */ -static value search_struct_field (); - -/* Cast value ARG2 to type TYPE and return as a value. - More general than a C cast: accepts any two types of the same length, - and if ARG2 is an lvalue it can be cast into anything at all. */ -/* In C++, casts may change pointer representations. */ - -value -value_cast (type, arg2) - struct type *type; - register value arg2; -{ - register enum type_code code1; - register enum type_code code2; - register int scalar; - - /* Coerce arrays but not enums. Enums will work as-is - and coercing them would cause an infinite recursion. */ - if (TYPE_CODE (VALUE_TYPE (arg2)) != TYPE_CODE_ENUM) - COERCE_ARRAY (arg2); - - code1 = TYPE_CODE (type); - code2 = TYPE_CODE (VALUE_TYPE (arg2)); - scalar = (code2 == TYPE_CODE_INT || code2 == TYPE_CODE_FLT - || code2 == TYPE_CODE_ENUM); - - if (code1 == TYPE_CODE_FLT && scalar) - return value_from_double (type, value_as_double (arg2)); - else if ((code1 == TYPE_CODE_INT || code1 == TYPE_CODE_ENUM) - && (scalar || code2 == TYPE_CODE_PTR)) - return value_from_longest (type, value_as_long (arg2)); - else if (TYPE_LENGTH (type) == TYPE_LENGTH (VALUE_TYPE (arg2))) - { - if (code1 == TYPE_CODE_PTR && code2 == TYPE_CODE_PTR) - { - /* Look in the type of the source to see if it contains the - type of the target as a superclass. If so, we'll need to - offset the pointer rather than just change its type. */ - struct type *t1 = TYPE_TARGET_TYPE (type); - struct type *t2 = TYPE_TARGET_TYPE (VALUE_TYPE (arg2)); - if (TYPE_CODE (t1) == TYPE_CODE_STRUCT - && TYPE_CODE (t2) == TYPE_CODE_STRUCT - && TYPE_NAME (t1) != 0) /* if name unknown, can't have supercl */ - { - value v = search_struct_field (type_name_no_tag (t1), - value_ind (arg2), 0, t2, 1); - if (v) - { - v = value_addr (v); - VALUE_TYPE (v) = type; - return v; - } - } - /* No superclass found, just fall through to change ptr type. */ - } - VALUE_TYPE (arg2) = type; - return arg2; - } - else if (VALUE_LVAL (arg2) == lval_memory) - { - return value_at_lazy (type, VALUE_ADDRESS (arg2) + VALUE_OFFSET (arg2)); - } - else if (code1 == TYPE_CODE_VOID) - { - return value_zero (builtin_type_void, not_lval); - } - else - { - error ("Invalid cast."); - return 0; - } -} - -/* Create a value of type TYPE that is zero, and return it. */ - -value -value_zero (type, lv) - struct type *type; - enum lval_type lv; -{ - register value val = allocate_value (type); - - bzero (VALUE_CONTENTS (val), TYPE_LENGTH (type)); - VALUE_LVAL (val) = lv; - - return val; -} - -/* Return a value with type TYPE located at ADDR. - - Call value_at only if the data needs to be fetched immediately; - if we can be 'lazy' and defer the fetch, perhaps indefinately, call - value_at_lazy instead. value_at_lazy simply records the address of - the data and sets the lazy-evaluation-required flag. The lazy flag - is tested in the VALUE_CONTENTS macro, which is used if and when - the contents are actually required. */ - -value -value_at (type, addr) - struct type *type; - CORE_ADDR addr; -{ - register value val = allocate_value (type); - - read_memory (addr, VALUE_CONTENTS_RAW (val), TYPE_LENGTH (type)); - - VALUE_LVAL (val) = lval_memory; - VALUE_ADDRESS (val) = addr; - - return val; -} - -/* Return a lazy value with type TYPE located at ADDR (cf. value_at). */ - -value -value_at_lazy (type, addr) - struct type *type; - CORE_ADDR addr; -{ - register value val = allocate_value (type); - - VALUE_LVAL (val) = lval_memory; - VALUE_ADDRESS (val) = addr; - VALUE_LAZY (val) = 1; - - return val; -} - -/* Called only from the VALUE_CONTENTS macro, if the current data for - a variable needs to be loaded into VALUE_CONTENTS(VAL). Fetches the - data from the user's process, and clears the lazy flag to indicate - that the data in the buffer is valid. - - If the value is zero-length, we avoid calling read_memory, which would - abort. We mark the value as fetched anyway -- all 0 bytes of it. - - This function returns a value because it is used in the VALUE_CONTENTS - macro as part of an expression, where a void would not work. The - value is ignored. */ - -int -value_fetch_lazy (val) - register value val; -{ - CORE_ADDR addr = VALUE_ADDRESS (val) + VALUE_OFFSET (val); - - if (TYPE_LENGTH (VALUE_TYPE (val))) - read_memory (addr, VALUE_CONTENTS_RAW (val), - TYPE_LENGTH (VALUE_TYPE (val))); - VALUE_LAZY (val) = 0; - return 0; -} - - -/* Store the contents of FROMVAL into the location of TOVAL. - Return a new value with the location of TOVAL and contents of FROMVAL. */ - -value -value_assign (toval, fromval) - register value toval, fromval; -{ - register struct type *type = VALUE_TYPE (toval); - register value val; - char raw_buffer[MAX_REGISTER_RAW_SIZE]; - char virtual_buffer[MAX_REGISTER_VIRTUAL_SIZE]; - int use_buffer = 0; - - COERCE_ARRAY (fromval); - - if (VALUE_LVAL (toval) != lval_internalvar) - fromval = value_cast (type, fromval); - - /* If TOVAL is a special machine register requiring conversion - of program values to a special raw format, - convert FROMVAL's contents now, with result in `raw_buffer', - and set USE_BUFFER to the number of bytes to write. */ - - if (VALUE_REGNO (toval) >= 0 - && REGISTER_CONVERTIBLE (VALUE_REGNO (toval))) - { - int regno = VALUE_REGNO (toval); - if (VALUE_TYPE (fromval) != REGISTER_VIRTUAL_TYPE (regno)) - fromval = value_cast (REGISTER_VIRTUAL_TYPE (regno), fromval); - bcopy (VALUE_CONTENTS (fromval), virtual_buffer, - REGISTER_VIRTUAL_SIZE (regno)); - target_convert_from_virtual (regno, virtual_buffer, raw_buffer); - use_buffer = REGISTER_RAW_SIZE (regno); - } - - switch (VALUE_LVAL (toval)) - { - case lval_internalvar: - set_internalvar (VALUE_INTERNALVAR (toval), fromval); - break; - - case lval_internalvar_component: - set_internalvar_component (VALUE_INTERNALVAR (toval), - VALUE_OFFSET (toval), - VALUE_BITPOS (toval), - VALUE_BITSIZE (toval), - fromval); - break; - - case lval_memory: - if (VALUE_BITSIZE (toval)) - { - int v; /* FIXME, this won't work for large bitfields */ - read_memory (VALUE_ADDRESS (toval) + VALUE_OFFSET (toval), - &v, sizeof v); - modify_field (&v, (int) value_as_long (fromval), - VALUE_BITPOS (toval), VALUE_BITSIZE (toval)); - write_memory (VALUE_ADDRESS (toval) + VALUE_OFFSET (toval), - (char *)&v, sizeof v); - } - else if (use_buffer) - write_memory (VALUE_ADDRESS (toval) + VALUE_OFFSET (toval), - raw_buffer, use_buffer); - else - write_memory (VALUE_ADDRESS (toval) + VALUE_OFFSET (toval), - VALUE_CONTENTS (fromval), TYPE_LENGTH (type)); - break; - - case lval_register: - if (VALUE_BITSIZE (toval)) - { - int v; - - read_register_bytes (VALUE_ADDRESS (toval) + VALUE_OFFSET (toval), - &v, sizeof v); - modify_field (&v, (int) value_as_long (fromval), - VALUE_BITPOS (toval), VALUE_BITSIZE (toval)); - write_register_bytes (VALUE_ADDRESS (toval) + VALUE_OFFSET (toval), - &v, sizeof v); - } - else if (use_buffer) - write_register_bytes (VALUE_ADDRESS (toval) + VALUE_OFFSET (toval), - raw_buffer, use_buffer); - else - write_register_bytes (VALUE_ADDRESS (toval) + VALUE_OFFSET (toval), - VALUE_CONTENTS (fromval), TYPE_LENGTH (type)); - break; - - case lval_reg_frame_relative: - { - /* value is stored in a series of registers in the frame - specified by the structure. Copy that value out, modify - it, and copy it back in. */ - int amount_to_copy = (VALUE_BITSIZE (toval) ? 1 : TYPE_LENGTH (type)); - int reg_size = REGISTER_RAW_SIZE (VALUE_FRAME_REGNUM (toval)); - int byte_offset = VALUE_OFFSET (toval) % reg_size; - int reg_offset = VALUE_OFFSET (toval) / reg_size; - int amount_copied; - char *buffer = (char *) alloca (amount_to_copy); - int regno; - FRAME frame; - - /* Figure out which frame this is in currently. */ - for (frame = get_current_frame (); - frame && FRAME_FP (frame) != VALUE_FRAME (toval); - frame = get_prev_frame (frame)) - ; - - if (!frame) - error ("Value being assigned to is no longer active."); - - amount_to_copy += (reg_size - amount_to_copy % reg_size); - - /* Copy it out. */ - for ((regno = VALUE_FRAME_REGNUM (toval) + reg_offset, - amount_copied = 0); - amount_copied < amount_to_copy; - amount_copied += reg_size, regno++) - { - get_saved_register (buffer + amount_copied, - (int *)NULL, (CORE_ADDR)NULL, - frame, regno, (enum lval_type *)NULL); - } - - /* Modify what needs to be modified. */ - if (VALUE_BITSIZE (toval)) - modify_field (buffer + byte_offset, - (int) value_as_long (fromval), - VALUE_BITPOS (toval), VALUE_BITSIZE (toval)); - else if (use_buffer) - bcopy (raw_buffer, buffer + byte_offset, use_buffer); - else - bcopy (VALUE_CONTENTS (fromval), buffer + byte_offset, - TYPE_LENGTH (type)); - - /* Copy it back. */ - for ((regno = VALUE_FRAME_REGNUM (toval) + reg_offset, - amount_copied = 0); - amount_copied < amount_to_copy; - amount_copied += reg_size, regno++) - { - enum lval_type lval; - CORE_ADDR addr; - int optim; - - /* Just find out where to put it. */ - get_saved_register ((char *)NULL, - &optim, &addr, frame, regno, &lval); - - if (optim) - error ("Attempt to assign to a value that was optimized out."); - if (lval == lval_memory) - write_memory (addr, buffer + amount_copied, reg_size); - else if (lval == lval_register) - write_register_bytes (addr, buffer + amount_copied, reg_size); - else - error ("Attempt to assign to an unmodifiable value."); - } - } - break; - - - default: - error ("Left side of = operation is not an lvalue."); - } - - /* Return a value just like TOVAL except with the contents of FROMVAL - (except in the case of the type if TOVAL is an internalvar). */ - - if (VALUE_LVAL (toval) == lval_internalvar - || VALUE_LVAL (toval) == lval_internalvar_component) - { - type = VALUE_TYPE (fromval); - } - - val = allocate_value (type); - bcopy (toval, val, VALUE_CONTENTS_RAW (val) - (char *) val); - bcopy (VALUE_CONTENTS (fromval), VALUE_CONTENTS_RAW (val), TYPE_LENGTH (type)); - VALUE_TYPE (val) = type; - - return val; -} - -/* Extend a value VAL to COUNT repetitions of its type. */ - -value -value_repeat (arg1, count) - value arg1; - int count; -{ - register value val; - - if (VALUE_LVAL (arg1) != lval_memory) - error ("Only values in memory can be extended with '@'."); - if (count < 1) - error ("Invalid number %d of repetitions.", count); - - val = allocate_repeat_value (VALUE_TYPE (arg1), count); - - read_memory (VALUE_ADDRESS (arg1) + VALUE_OFFSET (arg1), - VALUE_CONTENTS_RAW (val), - TYPE_LENGTH (VALUE_TYPE (val)) * count); - VALUE_LVAL (val) = lval_memory; - VALUE_ADDRESS (val) = VALUE_ADDRESS (arg1) + VALUE_OFFSET (arg1); - - return val; -} - -value -value_of_variable (var) - struct symbol *var; -{ - value val; - - val = read_var_value (var, (FRAME) 0); - if (val == 0) - error ("Address of symbol \"%s\" is unknown.", SYMBOL_NAME (var)); - return val; -} - -/* Given a value which is an array, return a value which is - a pointer to its first (actually, zeroth) element. - FIXME, this should be subtracting the array's lower bound. */ - -value -value_coerce_array (arg1) - value arg1; -{ - register struct type *type; - - if (VALUE_LVAL (arg1) != lval_memory) - error ("Attempt to take address of value not located in memory."); - - /* Get type of elements. */ - if (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_ARRAY) - type = TYPE_TARGET_TYPE (VALUE_TYPE (arg1)); - else - /* A phony array made by value_repeat. - Its type is the type of the elements, not an array type. */ - type = VALUE_TYPE (arg1); - - return value_from_longest (lookup_pointer_type (type), - (LONGEST) (VALUE_ADDRESS (arg1) + VALUE_OFFSET (arg1))); -} - -/* Given a value which is a function, return a value which is a pointer - to it. */ - -value -value_coerce_function (arg1) - value arg1; -{ - - if (VALUE_LVAL (arg1) != lval_memory) - error ("Attempt to take address of value not located in memory."); - - return value_from_longest (lookup_pointer_type (VALUE_TYPE (arg1)), - (LONGEST) (VALUE_ADDRESS (arg1) + VALUE_OFFSET (arg1))); -} - -/* Return a pointer value for the object for which ARG1 is the contents. */ - -value -value_addr (arg1) - value arg1; -{ - - COERCE_REF(arg1); - if (VALUE_REPEATED (arg1) - || TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_ARRAY) - return value_coerce_array (arg1); - if (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_FUNC) - return value_coerce_function (arg1); - - if (VALUE_LVAL (arg1) != lval_memory) - error ("Attempt to take address of value not located in memory."); - - return value_from_longest (lookup_pointer_type (VALUE_TYPE (arg1)), - (LONGEST) (VALUE_ADDRESS (arg1) + VALUE_OFFSET (arg1))); -} - -/* Given a value of a pointer type, apply the C unary * operator to it. */ - -value -value_ind (arg1) - value arg1; -{ - COERCE_ARRAY (arg1); - - if (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_MEMBER) - error ("not implemented: member types in value_ind"); - - /* Allow * on an integer so we can cast it to whatever we want. - This returns an int, which seems like the most C-like thing - to do. "long long" variables are rare enough that - BUILTIN_TYPE_LONGEST would seem to be a mistake. */ - if (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_INT) - return value_at (builtin_type_int, - (CORE_ADDR) value_as_long (arg1)); - else if (TYPE_CODE (VALUE_TYPE (arg1)) == TYPE_CODE_PTR) - return value_at_lazy (TYPE_TARGET_TYPE (VALUE_TYPE (arg1)), - value_as_pointer (arg1)); - error ("Attempt to take contents of a non-pointer value."); - return 0; /* For lint -- never reached */ -} - -/* Pushing small parts of stack frames. */ - -/* Push one word (the size of object that a register holds). */ - -CORE_ADDR -push_word (sp, buffer) - CORE_ADDR sp; - REGISTER_TYPE buffer; -{ - register int len = sizeof (REGISTER_TYPE); - - SWAP_TARGET_AND_HOST (&buffer, len); -#if 1 INNER_THAN 2 - sp -= len; - write_memory (sp, (char *)&buffer, len); -#else /* stack grows upward */ - write_memory (sp, (char *)&buffer, len); - sp += len; -#endif /* stack grows upward */ - - return sp; -} - -/* Push LEN bytes with data at BUFFER. */ - -CORE_ADDR -push_bytes (sp, buffer, len) - CORE_ADDR sp; - char *buffer; - int len; -{ -#if 1 INNER_THAN 2 - sp -= len; - write_memory (sp, buffer, len); -#else /* stack grows upward */ - write_memory (sp, buffer, len); - sp += len; -#endif /* stack grows upward */ - - return sp; -} - -/* Push onto the stack the specified value VALUE. */ - -CORE_ADDR -value_push (sp, arg) - register CORE_ADDR sp; - value arg; -{ - register int len = TYPE_LENGTH (VALUE_TYPE (arg)); - -#if 1 INNER_THAN 2 - sp -= len; - write_memory (sp, VALUE_CONTENTS (arg), len); -#else /* stack grows upward */ - write_memory (sp, VALUE_CONTENTS (arg), len); - sp += len; -#endif /* stack grows upward */ - - return sp; -} - -/* Perform the standard coercions that are specified - for arguments to be passed to C functions. */ - -value -value_arg_coerce (arg) - value arg; -{ - register struct type *type; - - COERCE_ENUM (arg); - - type = VALUE_TYPE (arg); - - if (TYPE_CODE (type) == TYPE_CODE_INT - && TYPE_LENGTH (type) < sizeof (int)) - return value_cast (builtin_type_int, arg); - - if (type == builtin_type_float) - return value_cast (builtin_type_double, arg); - - return arg; -} - -/* Push the value ARG, first coercing it as an argument - to a C function. */ - -CORE_ADDR -value_arg_push (sp, arg) - register CORE_ADDR sp; - value arg; -{ - return value_push (sp, value_arg_coerce (arg)); -} - -/* Determine a function's address and its return type from its value. - Calls error() if the function is not valid for calling. */ - -CORE_ADDR -find_function_addr (function, retval_type) - value function; - struct type **retval_type; -{ - register struct type *ftype = VALUE_TYPE (function); - register enum type_code code = TYPE_CODE (ftype); - struct type *value_type; - CORE_ADDR funaddr; - - /* If it's a member function, just look at the function - part of it. */ - - /* Determine address to call. */ - if (code == TYPE_CODE_FUNC || code == TYPE_CODE_METHOD) - { - funaddr = VALUE_ADDRESS (function); - value_type = TYPE_TARGET_TYPE (ftype); - } - else if (code == TYPE_CODE_PTR) - { - funaddr = value_as_pointer (function); - if (TYPE_CODE (TYPE_TARGET_TYPE (ftype)) == TYPE_CODE_FUNC - || TYPE_CODE (TYPE_TARGET_TYPE (ftype)) == TYPE_CODE_METHOD) - value_type = TYPE_TARGET_TYPE (TYPE_TARGET_TYPE (ftype)); - else - value_type = builtin_type_int; - } - else if (code == TYPE_CODE_INT) - { - /* Handle the case of functions lacking debugging info. - Their values are characters since their addresses are char */ - if (TYPE_LENGTH (ftype) == 1) - funaddr = value_as_pointer (value_addr (function)); - else - /* Handle integer used as address of a function. */ - funaddr = (CORE_ADDR) value_as_long (function); - - value_type = builtin_type_int; - } - else - error ("Invalid data type for function to be called."); - - *retval_type = value_type; - return funaddr; -} - -#if defined (CALL_DUMMY) -/* All this stuff with a dummy frame may seem unnecessarily complicated - (why not just save registers in GDB?). The purpose of pushing a dummy - frame which looks just like a real frame is so that if you call a - function and then hit a breakpoint (get a signal, etc), "backtrace" - will look right. Whether the backtrace needs to actually show the - stack at the time the inferior function was called is debatable, but - it certainly needs to not display garbage. So if you are contemplating - making dummy frames be different from normal frames, consider that. */ - -/* Perform a function call in the inferior. - ARGS is a vector of values of arguments (NARGS of them). - FUNCTION is a value, the function to be called. - Returns a value representing what the function returned. - May fail to return, if a breakpoint or signal is hit - during the execution of the function. */ - -value -call_function_by_hand (function, nargs, args) - value function; - int nargs; - value *args; -{ - register CORE_ADDR sp; - register int i; - CORE_ADDR start_sp; - /* CALL_DUMMY is an array of words (REGISTER_TYPE), but each word - is in host byte order. It is switched to target byte order before calling - FIX_CALL_DUMMY. */ - static REGISTER_TYPE dummy[] = CALL_DUMMY; - REGISTER_TYPE dummy1[sizeof dummy / sizeof (REGISTER_TYPE)]; - CORE_ADDR old_sp; - struct type *value_type; - unsigned char struct_return; - CORE_ADDR struct_addr; - struct inferior_status inf_status; - struct cleanup *old_chain; - CORE_ADDR funaddr; - int using_gcc; - - save_inferior_status (&inf_status, 1); - old_chain = make_cleanup (restore_inferior_status, &inf_status); - - /* PUSH_DUMMY_FRAME is responsible for saving the inferior registers - (and POP_FRAME for restoring them). (At least on most machines) - they are saved on the stack in the inferior. */ - PUSH_DUMMY_FRAME; - - old_sp = sp = read_register (SP_REGNUM); - -#if 1 INNER_THAN 2 /* Stack grows down */ - sp -= sizeof dummy; - start_sp = sp; -#else /* Stack grows up */ - start_sp = sp; - sp += sizeof dummy; -#endif - - funaddr = find_function_addr (function, &value_type); - - { - struct block *b = block_for_pc (funaddr); - /* If compiled without -g, assume GCC. */ - using_gcc = b == NULL || BLOCK_GCC_COMPILED (b); - } - - /* Are we returning a value using a structure return or a normal - value return? */ - - struct_return = using_struct_return (function, funaddr, value_type, - using_gcc); - - /* Create a call sequence customized for this function - and the number of arguments for it. */ - bcopy (dummy, dummy1, sizeof dummy); - for (i = 0; i < sizeof dummy / sizeof (REGISTER_TYPE); i++) - SWAP_TARGET_AND_HOST (&dummy1[i], sizeof (REGISTER_TYPE)); - FIX_CALL_DUMMY (dummy1, start_sp, funaddr, nargs, args, - value_type, using_gcc); - -#if CALL_DUMMY_LOCATION == ON_STACK - write_memory (start_sp, (char *)dummy1, sizeof dummy); - -#else /* Not on stack. */ -#if CALL_DUMMY_LOCATION == BEFORE_TEXT_END - /* Convex Unix prohibits executing in the stack segment. */ - /* Hope there is empty room at the top of the text segment. */ - { - extern CORE_ADDR text_end; - static checked = 0; - if (!checked) - for (start_sp = text_end - sizeof dummy; start_sp < text_end; ++start_sp) - if (read_memory_integer (start_sp, 1) != 0) - error ("text segment full -- no place to put call"); - checked = 1; - sp = old_sp; - start_sp = text_end - sizeof dummy; - write_memory (start_sp, (char *)dummy1, sizeof dummy); - } -#else /* After text_end. */ - { - extern CORE_ADDR text_end; - int errcode; - sp = old_sp; - start_sp = text_end; - errcode = target_write_memory (start_sp, (char *)dummy1, sizeof dummy); - if (errcode != 0) - error ("Cannot write text segment -- call_function failed"); - } -#endif /* After text_end. */ -#endif /* Not on stack. */ - -#ifdef lint - sp = old_sp; /* It really is used, for some ifdef's... */ -#endif - -#ifdef STACK_ALIGN - /* If stack grows down, we must leave a hole at the top. */ - { - int len = 0; - - /* Reserve space for the return structure to be written on the - stack, if necessary */ - - if (struct_return) - len += TYPE_LENGTH (value_type); - - for (i = nargs - 1; i >= 0; i--) - len += TYPE_LENGTH (VALUE_TYPE (value_arg_coerce (args[i]))); -#ifdef CALL_DUMMY_STACK_ADJUST - len += CALL_DUMMY_STACK_ADJUST; -#endif -#if 1 INNER_THAN 2 - sp -= STACK_ALIGN (len) - len; -#else - sp += STACK_ALIGN (len) - len; -#endif - } -#endif /* STACK_ALIGN */ - - /* Reserve space for the return structure to be written on the - stack, if necessary */ - - if (struct_return) - { -#if 1 INNER_THAN 2 - sp -= TYPE_LENGTH (value_type); - struct_addr = sp; -#else - struct_addr = sp; - sp += TYPE_LENGTH (value_type); -#endif - } - -#if defined (REG_STRUCT_HAS_ADDR) - { - /* This is a machine like the sparc, where we need to pass a pointer - to the structure, not the structure itself. */ - if (REG_STRUCT_HAS_ADDR (using_gcc)) - for (i = nargs - 1; i >= 0; i--) - if (TYPE_CODE (VALUE_TYPE (args[i])) == TYPE_CODE_STRUCT) - { - CORE_ADDR addr; -#if !(1 INNER_THAN 2) - /* The stack grows up, so the address of the thing we push - is the stack pointer before we push it. */ - addr = sp; -#endif - /* Push the structure. */ - sp = value_push (sp, args[i]); -#if 1 INNER_THAN 2 - /* The stack grows down, so the address of the thing we push - is the stack pointer after we push it. */ - addr = sp; -#endif - /* The value we're going to pass is the address of the thing - we just pushed. */ - args[i] = value_from_longest (lookup_pointer_type (value_type), - (LONGEST) addr); - } - } -#endif /* REG_STRUCT_HAS_ADDR. */ - -#ifdef PUSH_ARGUMENTS - PUSH_ARGUMENTS(nargs, args, sp, struct_return, struct_addr); -#else /* !PUSH_ARGUMENTS */ - for (i = nargs - 1; i >= 0; i--) - sp = value_arg_push (sp, args[i]); -#endif /* !PUSH_ARGUMENTS */ - -#ifdef CALL_DUMMY_STACK_ADJUST -#if 1 INNER_THAN 2 - sp -= CALL_DUMMY_STACK_ADJUST; -#else - sp += CALL_DUMMY_STACK_ADJUST; -#endif -#endif /* CALL_DUMMY_STACK_ADJUST */ - - /* Store the address at which the structure is supposed to be - written. Note that this (and the code which reserved the space - above) assumes that gcc was used to compile this function. Since - it doesn't cost us anything but space and if the function is pcc - it will ignore this value, we will make that assumption. - - Also note that on some machines (like the sparc) pcc uses a - convention like gcc's. */ - - if (struct_return) - STORE_STRUCT_RETURN (struct_addr, sp); - - /* Write the stack pointer. This is here because the statements above - might fool with it. On SPARC, this write also stores the register - window into the right place in the new stack frame, which otherwise - wouldn't happen. (See write_inferior_registers in sparc-xdep.c.) */ - write_register (SP_REGNUM, sp); - - /* Figure out the value returned by the function. */ - { - char retbuf[REGISTER_BYTES]; - - /* Execute the stack dummy routine, calling FUNCTION. - When it is done, discard the empty frame - after storing the contents of all regs into retbuf. */ - run_stack_dummy (start_sp + CALL_DUMMY_START_OFFSET, retbuf); - - do_cleanups (old_chain); - - return value_being_returned (value_type, retbuf, struct_return); - } -} -#else /* no CALL_DUMMY. */ -value -call_function_by_hand (function, nargs, args) - value function; - int nargs; - value *args; -{ - error ("Cannot invoke functions on this machine."); -} -#endif /* no CALL_DUMMY. */ - -/* Create a value for a string constant: - Call the function malloc in the inferior to get space for it, - then copy the data into that space - and then return the address with type char *. - PTR points to the string constant data; LEN is number of characters. */ - -value -value_string (ptr, len) - char *ptr; - int len; -{ - register value val; - register struct symbol *sym; - value blocklen; - register char *copy = (char *) alloca (len + 1); - char *i = ptr; - register char *o = copy, *ibeg = ptr; - register int c; - - /* Copy the string into COPY, processing escapes. - We could not conveniently process them in the parser - because the string there wants to be a substring of the input. */ - - while (i - ibeg < len) - { - c = *i++; - if (c == '\\') - { - c = parse_escape (&i); - if (c == -1) - continue; - } - *o++ = c; - } - *o = 0; - - /* Get the length of the string after escapes are processed. */ - - len = o - copy; - - /* Find the address of malloc in the inferior. */ - - sym = lookup_symbol ("malloc", 0, VAR_NAMESPACE, 0, NULL); - if (sym != 0) - { - if (SYMBOL_CLASS (sym) != LOC_BLOCK) - error ("\"malloc\" exists in this program but is not a function."); - val = value_of_variable (sym); - } - else - { - register int j; - j = lookup_misc_func ("malloc"); - if (j >= 0) - val = value_from_longest ( - lookup_pointer_type (lookup_function_type ( - lookup_pointer_type (builtin_type_char))), - (LONGEST) misc_function_vector[j].address); - else - error ("String constants require the program to have a function \"malloc\"."); - } - - blocklen = value_from_longest (builtin_type_int, (LONGEST) (len + 1)); - val = target_call_function (val, 1, &blocklen); - if (value_zerop (val)) - error ("No memory available for string constant."); - write_memory (value_as_pointer (val), copy, len + 1); - VALUE_TYPE (val) = lookup_pointer_type (builtin_type_char); - return val; -} - -/* Helper function used by value_struct_elt to recurse through baseclasses. - Look for a field NAME in ARG1. Adjust the address of ARG1 by OFFSET bytes, - and treat the result as having type TYPE. - If found, return value, else return NULL. - - If LOOKING_FOR_BASECLASS, then instead of looking for struct fields, - look for a baseclass named NAME. */ - -static value -search_struct_field (name, arg1, offset, type, looking_for_baseclass) - char *name; - register value arg1; - int offset; - register struct type *type; - int looking_for_baseclass; -{ - int i; - - check_stub_type (type); - - if (! looking_for_baseclass) - for (i = TYPE_NFIELDS (type) - 1; i >= TYPE_N_BASECLASSES (type); i--) - { - char *t_field_name = TYPE_FIELD_NAME (type, i); - - if (t_field_name && !strcmp (t_field_name, name)) - { - value v = (TYPE_FIELD_STATIC (type, i) - ? value_static_field (type, name, i) - : value_primitive_field (arg1, offset, i, type)); - if (v == 0) - error("there is no field named %s", name); - return v; - } - } - - for (i = TYPE_N_BASECLASSES (type) - 1; i >= 0; i--) - { - value v; - /* If we are looking for baseclasses, this is what we get when we - hit them. */ - int found_baseclass = (looking_for_baseclass - && !strcmp (name, TYPE_BASECLASS_NAME (type, i))); - - if (BASETYPE_VIA_VIRTUAL (type, i)) - { - value v2; - baseclass_addr (type, i, VALUE_CONTENTS (arg1) + offset, - &v2, (int *)NULL); - if (v2 == 0) - error ("virtual baseclass botch"); - if (found_baseclass) - return v2; - v = search_struct_field (name, v2, 0, TYPE_BASECLASS (type, i), - looking_for_baseclass); - if (v) return v; - else continue; - } - if (found_baseclass) - v = value_primitive_field (arg1, offset, i, type); - else - v = search_struct_field (name, arg1, - offset + TYPE_BASECLASS_BITPOS (type, i) / 8, - TYPE_BASECLASS (type, i), - looking_for_baseclass); - if (v) return v; - } - return NULL; -} - -/* Helper function used by value_struct_elt to recurse through baseclasses. - Look for a field NAME in ARG1. Adjust the address of ARG1 by OFFSET bytes, - and treat the result as having type TYPE. - If found, return value, else return NULL. */ - -static value -search_struct_method (name, arg1, args, offset, static_memfuncp, type) - char *name; - register value arg1, *args; - int offset, *static_memfuncp; - register struct type *type; -{ - int i; - - check_stub_type (type); - for (i = TYPE_NFN_FIELDS (type) - 1; i >= 0; i--) - { - char *t_field_name = TYPE_FN_FIELDLIST_NAME (type, i); - if (t_field_name && !strcmp (t_field_name, name)) - { - int j = TYPE_FN_FIELDLIST_LENGTH (type, i) - 1; - struct fn_field *f = TYPE_FN_FIELDLIST1 (type, i); - - if (j > 0 && args == 0) - error ("cannot resolve overloaded method `%s'", name); - while (j >= 0) - { - if (TYPE_FLAGS (TYPE_FN_FIELD_TYPE (f, j)) & TYPE_FLAG_STUB) - check_stub_method (type, i, j); - if (!typecmp (TYPE_FN_FIELD_STATIC_P (f, j), - TYPE_FN_FIELD_ARGS (f, j), args)) - { - if (TYPE_FN_FIELD_VIRTUAL_P (f, j)) - return (value)value_virtual_fn_field (arg1, f, j, type); - if (TYPE_FN_FIELD_STATIC_P (f, j) && static_memfuncp) - *static_memfuncp = 1; - return (value)value_fn_field (arg1, i, j); - } - j--; - } - } - } - - for (i = TYPE_N_BASECLASSES (type) - 1; i >= 0; i--) - { - value v; - - if (BASETYPE_VIA_VIRTUAL (type, i)) - { - value v2; - baseclass_addr (type, i, VALUE_CONTENTS (arg1) + offset, - &v2, (int *)NULL); - if (v2 == 0) - error ("virtual baseclass botch"); - v = search_struct_method (name, v2, args, 0, - static_memfuncp, TYPE_BASECLASS (type, i)); - if (v) return v; - else continue; - } - - v = search_struct_method (name, arg1, args, - TYPE_BASECLASS_BITPOS (type, i) / 8, - static_memfuncp, TYPE_BASECLASS (type, i)); - if (v) return v; - } - return NULL; -} - -/* Given *ARGP, a value of type (pointer to a)* structure/union, - extract the component named NAME from the ultimate target structure/union - and return it as a value with its appropriate type. - ERR is used in the error message if *ARGP's type is wrong. - - C++: ARGS is a list of argument types to aid in the selection of - an appropriate method. Also, handle derived types. - - STATIC_MEMFUNCP, if non-NULL, points to a caller-supplied location - where the truthvalue of whether the function that was resolved was - a static member function or not is stored. - - ERR is an error message to be printed in case the field is not found. */ - -value -value_struct_elt (argp, args, name, static_memfuncp, err) - register value *argp, *args; - char *name; - int *static_memfuncp; - char *err; -{ - register struct type *t; - value v; - - COERCE_ARRAY (*argp); - - t = VALUE_TYPE (*argp); - - /* Follow pointers until we get to a non-pointer. */ - - while (TYPE_CODE (t) == TYPE_CODE_PTR || TYPE_CODE (t) == TYPE_CODE_REF) - { - *argp = value_ind (*argp); - /* Don't coerce fn pointer to fn and then back again! */ - if (TYPE_CODE (VALUE_TYPE (*argp)) != TYPE_CODE_FUNC) - COERCE_ARRAY (*argp); - t = VALUE_TYPE (*argp); - } - - if (TYPE_CODE (t) == TYPE_CODE_MEMBER) - error ("not implemented: member type in value_struct_elt"); - - if (TYPE_CODE (t) != TYPE_CODE_STRUCT - && TYPE_CODE (t) != TYPE_CODE_UNION) - error ("Attempt to extract a component of a value that is not a %s.", err); - - /* Assume it's not, unless we see that it is. */ - if (static_memfuncp) - *static_memfuncp =0; - - if (!args) - { - /* if there are no arguments ...do this... */ - - /* Try as a field first, because if we succeed, there - is less work to be done. */ - v = search_struct_field (name, *argp, 0, t, 0); - if (v) - return v; - - /* C++: If it was not found as a data field, then try to - return it as a pointer to a method. */ - - if (destructor_name_p (name, t)) - error ("Cannot get value of destructor"); - - v = search_struct_method (name, *argp, args, 0, static_memfuncp, t); - - if (v == 0) - { - if (TYPE_NFN_FIELDS (t)) - error ("There is no member or method named %s.", name); - else - error ("There is no member named %s.", name); - } - return v; - } - - if (destructor_name_p (name, t)) - { - if (!args[1]) - { - /* destructors are a special case. */ - return (value)value_fn_field (*argp, 0, - TYPE_FN_FIELDLIST_LENGTH (t, 0)); - } - else - { - error ("destructor should not have any argument"); - } - } - else - v = search_struct_method (name, *argp, args, 0, static_memfuncp, t); - - if (v == 0) - { - /* See if user tried to invoke data as function. If so, - hand it back. If it's not callable (i.e., a pointer to function), - gdb should give an error. */ - v = search_struct_field (name, *argp, 0, t, 0); - } - - if (!v) - error ("Structure has no component named %s.", name); - return v; -} - -/* C++: return 1 is NAME is a legitimate name for the destructor - of type TYPE. If TYPE does not have a destructor, or - if NAME is inappropriate for TYPE, an error is signaled. */ -int -destructor_name_p (name, type) - char *name; - struct type *type; -{ - /* destructors are a special case. */ - - if (name[0] == '~') - { - char *dname = type_name_no_tag (type); - - if (! TYPE_HAS_DESTRUCTOR (type)) - error ("type `%s' does not have destructor defined", dname); - if (strcmp (dname, name+1)) - error ("name of destructor must equal name of class"); - else - return 1; - } - return 0; -} - -/* Helper function for check_field: Given TYPE, a structure/union, - return 1 if the component named NAME from the ultimate - target structure/union is defined, otherwise, return 0. */ - -static int -check_field_in (type, name) - register struct type *type; - char *name; -{ - register int i; - - for (i = TYPE_NFIELDS (type) - 1; i >= TYPE_N_BASECLASSES (type); i--) - { - char *t_field_name = TYPE_FIELD_NAME (type, i); - if (t_field_name && !strcmp (t_field_name, name)) - return 1; - } - - /* C++: If it was not found as a data field, then try to - return it as a pointer to a method. */ - - /* Destructors are a special case. */ - if (destructor_name_p (name, type)) - return 1; - - for (i = TYPE_NFN_FIELDS (type) - 1; i >= 0; --i) - { - if (!strcmp (TYPE_FN_FIELDLIST_NAME (type, i), name)) - return 1; - } - - for (i = TYPE_N_BASECLASSES (type) - 1; i >= 0; i--) - if (check_field_in (TYPE_BASECLASS (type, i), name)) - return 1; - - return 0; -} - - -/* C++: Given ARG1, a value of type (pointer to a)* structure/union, - return 1 if the component named NAME from the ultimate - target structure/union is defined, otherwise, return 0. */ - -int -check_field (arg1, name) - register value arg1; - char *name; -{ - register struct type *t; - - COERCE_ARRAY (arg1); - - t = VALUE_TYPE (arg1); - - /* Follow pointers until we get to a non-pointer. */ - - while (TYPE_CODE (t) == TYPE_CODE_PTR || TYPE_CODE (t) == TYPE_CODE_REF) - t = TYPE_TARGET_TYPE (t); - - if (TYPE_CODE (t) == TYPE_CODE_MEMBER) - error ("not implemented: member type in check_field"); - - if (TYPE_CODE (t) != TYPE_CODE_STRUCT - && TYPE_CODE (t) != TYPE_CODE_UNION) - error ("Internal error: `this' is not an aggregate"); - - return check_field_in (t, name); -} - -/* C++: Given an aggregate type DOMAIN, and a member name NAME, - return the address of this member as a pointer to member - type. If INTYPE is non-null, then it will be the type - of the member we are looking for. This will help us resolve - pointers to member functions. */ - -value -value_struct_elt_for_address (domain, intype, name) - struct type *domain, *intype; - char *name; -{ - register struct type *t = domain; - register int i; - value v; - - struct type *baseclass; - - if (TYPE_CODE (t) != TYPE_CODE_STRUCT - && TYPE_CODE (t) != TYPE_CODE_UNION) - error ("Internal error: non-aggregate type to value_struct_elt_for_address"); - - baseclass = t; - - while (t) - { - for (i = TYPE_NFIELDS (t) - 1; i >= TYPE_N_BASECLASSES (t); i--) - { - char *t_field_name = TYPE_FIELD_NAME (t, i); - if (t_field_name && !strcmp (t_field_name, name)) - { - if (TYPE_FIELD_STATIC (t, i)) - { - char *phys_name = TYPE_FIELD_STATIC_PHYSNAME (t, i); - struct symbol *sym = - lookup_symbol (phys_name, 0, VAR_NAMESPACE, 0, NULL); - if (! sym) error ("Internal error: could not find physical static variable named %s", phys_name); - return value_from_longest ( - lookup_pointer_type (TYPE_FIELD_TYPE (t, i)), - (LONGEST)SYMBOL_BLOCK_VALUE (sym)); - } - if (TYPE_FIELD_PACKED (t, i)) - error ("pointers to bitfield members not allowed"); - - return value_from_longest ( - lookup_pointer_type ( - lookup_member_type (TYPE_FIELD_TYPE (t, i), baseclass)), - (LONGEST) (TYPE_FIELD_BITPOS (t, i) >> 3)); - } - } - - if (TYPE_N_BASECLASSES (t) == 0) - break; - - t = TYPE_BASECLASS (t, 0); - } - - /* C++: If it was not found as a data field, then try to - return it as a pointer to a method. */ - t = baseclass; - - /* Destructors are a special case. */ - if (destructor_name_p (name, t)) - { - error ("pointers to destructors not implemented yet"); - } - - /* Perform all necessary dereferencing. */ - while (intype && TYPE_CODE (intype) == TYPE_CODE_PTR) - intype = TYPE_TARGET_TYPE (intype); - - while (t) - { - for (i = TYPE_NFN_FIELDS (t) - 1; i >= 0; --i) - { - if (!strcmp (TYPE_FN_FIELDLIST_NAME (t, i), name)) - { - int j = TYPE_FN_FIELDLIST_LENGTH (t, i); - struct fn_field *f = TYPE_FN_FIELDLIST1 (t, i); - - if (intype == 0 && j > 1) - error ("non-unique member `%s' requires type instantiation", name); - if (intype) - { - while (j--) - if (TYPE_FN_FIELD_TYPE (f, j) == intype) - break; - if (j < 0) - error ("no member function matches that type instantiation"); - } - else - j = 0; - - check_stub_method (t, i, j); - if (TYPE_FN_FIELD_VIRTUAL_P (f, j)) - { - return value_from_longest ( - lookup_pointer_type ( - lookup_member_type (TYPE_FN_FIELD_TYPE (f, j), - baseclass)), - (LONGEST) TYPE_FN_FIELD_VOFFSET (f, j)); - } - else - { - struct symbol *s = lookup_symbol (TYPE_FN_FIELD_PHYSNAME (f, j), - 0, VAR_NAMESPACE, 0, NULL); - v = locate_var_value (s, 0); - VALUE_TYPE (v) = lookup_pointer_type (lookup_member_type (TYPE_FN_FIELD_TYPE (f, j), baseclass)); - return v; - } - } - } - - if (TYPE_N_BASECLASSES (t) == 0) - break; - - t = TYPE_BASECLASS (t, 0); - } - return 0; -} - -/* Compare two argument lists and return the position in which they differ, - or zero if equal. - - STATICP is nonzero if the T1 argument list came from a - static member function. - - For non-static member functions, we ignore the first argument, - which is the type of the instance variable. This is because we want - to handle calls with objects from derived classes. This is not - entirely correct: we should actually check to make sure that a - requested operation is type secure, shouldn't we? FIXME. */ - -int -typecmp (staticp, t1, t2) - int staticp; - struct type *t1[]; - value t2[]; -{ - int i; - - if (t2 == 0) - return 1; - if (staticp && t1 == 0) - return t2[1] != 0; - if (t1 == 0) - return 1; - if (t1[0]->code == TYPE_CODE_VOID) return 0; - if (t1[!staticp] == 0) return 0; - for (i = !staticp; t1[i] && t1[i]->code != TYPE_CODE_VOID; i++) - { - if (! t2[i] - || t1[i]->code != t2[i]->type->code -/* Too pessimistic: || t1[i]->target_type != t2[i]->type->target_type */ - ) - return i+1; - } - if (!t1[i]) return 0; - return t2[i] ? i+1 : 0; -} - -/* C++: return the value of the class instance variable, if one exists. - Flag COMPLAIN signals an error if the request is made in an - inappropriate context. */ -value -value_of_this (complain) - int complain; -{ - extern FRAME selected_frame; - struct symbol *func, *sym; - struct block *b; - int i; - static const char funny_this[] = "this"; - value this; - - if (selected_frame == 0) - if (complain) - error ("no frame selected"); - else return 0; - - func = get_frame_function (selected_frame); - if (!func) - { - if (complain) - error ("no `this' in nameless context"); - else return 0; - } - - b = SYMBOL_BLOCK_VALUE (func); - i = BLOCK_NSYMS (b); - if (i <= 0) - if (complain) - error ("no args, no `this'"); - else return 0; - - /* 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); - if (sym == NULL) - { - if (complain) - error ("current stack frame not in method"); - else - return NULL; - } - - this = read_var_value (sym, selected_frame); - if (this == 0 && complain) - error ("`this' argument at unknown address"); - return this; -} diff --git a/gdb/valprint.c b/gdb/valprint.c deleted file mode 100644 index 1baf6984e6b..00000000000 --- a/gdb/valprint.c +++ /dev/null @@ -1,2053 +0,0 @@ -/* Print values for GNU debugger gdb. - Copyright (C) 1986, 1988, 1989 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include -#include "defs.h" -#include "param.h" -#include "symtab.h" -#include "value.h" -#include "gdbcore.h" -#include "gdbcmd.h" -#include "target.h" -#include "obstack.h" -#include "language.h" - -#include -extern int sys_nerr; -extern char *sys_errlist[]; - -extern void print_scalar_formatted(); /* printcmd.c */ -extern void print_address_demangle(); /* printcmd.c */ -extern int demangle; /* whether to print C++ syms raw or source-form */ - -/* Maximum number of chars to print for a string pointer value - or vector contents, or UINT_MAX for no limit. */ - -static unsigned int print_max; - -static void type_print_varspec_suffix (); -static void type_print_varspec_prefix (); -static void type_print_base (); -static void type_print_method_args (); - -/* Default input and output radixes, and output format letter. */ - -unsigned input_radix = 10; -unsigned output_radix = 10; -int output_format = 0; - - -char **unsigned_type_table; -char **signed_type_table; -char **float_type_table; - - -/* Print repeat counts if there are more than this - many repetitions of an element in an array. */ -#define REPEAT_COUNT_THRESHOLD 10 - -/* Define a mess of print controls. */ - -int prettyprint; /* Controls pretty printing of structures */ -int vtblprint; /* Controls printing of vtbl's */ -int unionprint; /* Controls printing of nested unions. */ -int arrayprint; /* Controls pretty printing of arrays. */ -int addressprint; /* Controls pretty printing of addresses. */ -int objectprint; /* Controls looking up an object's derived type - using what we find in its vtables. */ - -struct obstack dont_print_obstack; - -static void cplus_val_print (); - -/* Print the character string STRING, printing at most LENGTH characters. - Printing stops early if the number hits print_max; repeat counts - are printed as appropriate. Print ellipses at the end if we - had to stop before printing LENGTH characters, or if FORCE_ELLIPSES. */ - -void -print_string (stream, string, length, force_ellipses) - FILE *stream; - char *string; - unsigned int length; - int force_ellipses; -{ - register unsigned int i; - unsigned int things_printed = 0; - int in_quotes = 0; - int need_comma = 0; - extern int inspect_it; - - if (length == 0) - { - fputs_filtered ("\"\"", stdout); - return; - } - - for (i = 0; i < length && things_printed < print_max; ++i) - { - /* Position of the character we are examining - to see whether it is repeated. */ - unsigned int rep1; - /* Number of repetitions we have detected so far. */ - unsigned int reps; - - QUIT; - - if (need_comma) - { - fputs_filtered (", ", stream); - need_comma = 0; - } - - rep1 = i + 1; - reps = 1; - while (rep1 < length && string[rep1] == string[i]) - { - ++rep1; - ++reps; - } - - if (reps > REPEAT_COUNT_THRESHOLD) - { - if (in_quotes) - { - if (inspect_it) - fputs_filtered ("\\\", ", stream); - else - fputs_filtered ("\", ", stream); - in_quotes = 0; - } - fputs_filtered ("'", stream); - printchar (string[i], stream, '\''); - fprintf_filtered (stream, "' ", reps); - i = rep1 - 1; - things_printed += REPEAT_COUNT_THRESHOLD; - need_comma = 1; - } - else - { - if (!in_quotes) - { - if (inspect_it) - fputs_filtered ("\\\"", stream); - else - fputs_filtered ("\"", stream); - in_quotes = 1; - } - printchar (string[i], stream, '"'); - ++things_printed; - } - } - - /* Terminate the quotes if necessary. */ - if (in_quotes) - { - if (inspect_it) - fputs_filtered ("\\\"", stream); - else - fputs_filtered ("\"", stream); - } - - if (force_ellipses || i < length) - fputs_filtered ("...", stream); -} - -/* Print a floating point value of type TYPE, pointed to in GDB by VALADDR, - on STREAM. */ - -void -print_floating (valaddr, type, stream) - char *valaddr; - struct type *type; - FILE *stream; -{ - double doub; - int inv; - unsigned len = TYPE_LENGTH (type); - -#if defined (IEEE_FLOAT) - - /* Check for NaN's. Note that this code does not depend on us being - on an IEEE conforming system. It only depends on the target - machine using IEEE representation. This means (a) - cross-debugging works right, and (2) IEEE_FLOAT can (and should) - be defined for systems like the 68881, which uses IEEE - representation, but is not IEEE conforming. */ - - { - long low, high; - /* Is the sign bit 0? */ - int nonnegative; - /* Is it is a NaN (i.e. the exponent is all ones and - the fraction is nonzero)? */ - int is_nan; - - if (len == sizeof (float)) - { - /* It's single precision. */ - bcopy (valaddr, &low, sizeof (low)); - /* target -> host. */ - SWAP_TARGET_AND_HOST (&low, sizeof (float)); - nonnegative = low >= 0; - is_nan = ((((low >> 23) & 0xFF) == 0xFF) - && 0 != (low & 0x7FFFFF)); - low &= 0x7fffff; - high = 0; - } - else - { - /* It's double precision. Get the high and low words. */ - -#if TARGET_BYTE_ORDER == BIG_ENDIAN - bcopy (valaddr+4, &low, sizeof (low)); - bcopy (valaddr+0, &high, sizeof (high)); -#else - bcopy (valaddr+0, &low, sizeof (low)); - bcopy (valaddr+4, &high, sizeof (high)); -#endif - SWAP_TARGET_AND_HOST (&low, sizeof (low)); - SWAP_TARGET_AND_HOST (&high, sizeof (high)); - nonnegative = high >= 0; - is_nan = (((high >> 20) & 0x7ff) == 0x7ff - && ! ((((high & 0xfffff) == 0)) && (low == 0))); - high &= 0xfffff; - } - - if (is_nan) - { - /* The meaning of the sign and fraction is not defined by IEEE. - But the user might know what they mean. For example, they - (in an implementation-defined manner) distinguish between - signaling and quiet NaN's. */ - if (high) - fprintf_filtered (stream, "-NaN(0x%lx%.8lx)" + nonnegative, - high, low); - else - fprintf_filtered (stream, "-NaN(0x%lx)" + nonnegative, low); - return; - } - } -#endif /* IEEE_FLOAT. */ - - doub = unpack_double (type, valaddr, &inv); - if (inv) - fprintf_filtered (stream, ""); - else - fprintf_filtered (stream, len <= sizeof(float) ? "%.9g" : "%.17g", doub); -} - -/* VALADDR points to an integer of LEN bytes. Print it in hex on stream. */ -static void -print_hex_chars (stream, valaddr, len) - FILE *stream; - unsigned char *valaddr; - unsigned len; -{ - unsigned char *p; - - fprintf_filtered (stream, "0x"); -#if TARGET_BYTE_ORDER == BIG_ENDIAN - for (p = valaddr; - p < valaddr + len; - p++) -#else /* Little endian. */ - for (p = valaddr + len - 1; - p >= valaddr; - p--) -#endif - { - fprintf_filtered (stream, "%02x", *p); - } -} - -/* Print the value VAL in C-ish syntax on stream STREAM. - FORMAT is a format-letter, or 0 for print in natural format of data type. - If the object printed is a string pointer, returns - the number of string bytes printed. */ - -int -value_print (val, stream, format, pretty) - value val; - FILE *stream; - char format; - enum val_prettyprint pretty; -{ - register unsigned int i, n, typelen; - - if (val == 0) - { - printf_filtered ("
"); - return 0; - } - if (VALUE_OPTIMIZED_OUT (val)) - { - printf_filtered (""); - return 0; - } - - /* A "repeated" value really contains several values in a row. - They are made by the @ operator. - Print such values as if they were arrays. */ - - else if (VALUE_REPEATED (val)) - { - n = VALUE_REPETITIONS (val); - typelen = TYPE_LENGTH (VALUE_TYPE (val)); - fprintf_filtered (stream, "{"); - /* Print arrays of characters using string syntax. */ - if (typelen == 1 && TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_INT - && format == 0) - print_string (stream, VALUE_CONTENTS (val), n, 0); - else - { - unsigned int things_printed = 0; - - for (i = 0; i < n && things_printed < print_max; i++) - { - /* Position of the array element we are examining to see - whether it is repeated. */ - unsigned int rep1; - /* Number of repetitions we have detected so far. */ - unsigned int reps; - - if (i != 0) - fprintf_filtered (stream, ", "); - wrap_here (""); - - rep1 = i + 1; - reps = 1; - while (rep1 < n - && !bcmp (VALUE_CONTENTS (val) + typelen * i, - VALUE_CONTENTS (val) + typelen * rep1, typelen)) - { - ++reps; - ++rep1; - } - - if (reps > REPEAT_COUNT_THRESHOLD) - { - val_print (VALUE_TYPE (val), - VALUE_CONTENTS (val) + typelen * i, - VALUE_ADDRESS (val) + typelen * i, - stream, format, 1, 0, pretty); - fprintf (stream, " ", reps); - i = rep1 - 1; - things_printed += REPEAT_COUNT_THRESHOLD; - } - else - { - val_print (VALUE_TYPE (val), - VALUE_CONTENTS (val) + typelen * i, - VALUE_ADDRESS (val) + typelen * i, - stream, format, 1, 0, pretty); - things_printed++; - } - } - if (i < n) - fprintf_filtered (stream, "..."); - } - fprintf_filtered (stream, "}"); - return n * typelen; - } - else - { - struct type *type = VALUE_TYPE (val); - - /* If it is a pointer, indicate what it points to. - - Print type also if it is a reference. - - C++: if it is a member pointer, we will take care - of that when we print it. */ - if (TYPE_CODE (type) == TYPE_CODE_PTR - || TYPE_CODE (type) == TYPE_CODE_REF) - { - /* Hack: remove (char *) for char strings. Their - type is indicated by the quoted string anyway. */ - if (TYPE_CODE (type) == TYPE_CODE_PTR - && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) == sizeof(char) - && TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_INT - && !TYPE_UNSIGNED (TYPE_TARGET_TYPE (type))) - { - /* Print nothing */ - } - else - { - fprintf_filtered (stream, "("); - type_print (type, "", stream, -1); - fprintf_filtered (stream, ") "); - } - } - return val_print (type, VALUE_CONTENTS (val), - VALUE_ADDRESS (val), stream, format, 1, 0, pretty); - } -} - -/* Return truth value for assertion that TYPE is of the type - "pointer to virtual function". */ -static int -is_vtbl_ptr_type(type) - struct type *type; -{ - char *typename = type_name_no_tag (type); - static const char vtbl_ptr_name[] = - { CPLUS_MARKER,'v','t','b','l','_','p','t','r','_','t','y','p','e', 0 }; - - return (typename != NULL && !strcmp(typename, vtbl_ptr_name)); -} - -/* Return truth value for the assertion that TYPE is of the type - "pointer to virtual function table". */ -static int -is_vtbl_member(type) - struct type *type; -{ - if (TYPE_CODE (type) == TYPE_CODE_PTR) - type = TYPE_TARGET_TYPE (type); - else - return 0; - - if (TYPE_CODE (type) == TYPE_CODE_ARRAY - && TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_STRUCT) - /* Virtual functions tables are full of pointers to virtual functions. */ - return is_vtbl_ptr_type (TYPE_TARGET_TYPE (type)); - return 0; -} - -/* Mutually recursive subroutines of cplus_val_print and val_print to print out - a structure's fields: val_print_fields and cplus_val_print. - - TYPE, VALADDR, STREAM, RECURSE, and PRETTY have the - same meanings as in cplus_val_print and val_print. - - DONT_PRINT is an array of baseclass types that we - should not print, or zero if called from top level. */ -static void -val_print_fields (type, valaddr, stream, format, recurse, pretty, dont_print) - struct type *type; - char *valaddr; - FILE *stream; - char format; - int recurse; - enum val_prettyprint pretty; - struct type **dont_print; -{ - int i, len, n_baseclasses; - - check_stub_type (type); - - fprintf_filtered (stream, "{"); - len = TYPE_NFIELDS (type); - n_baseclasses = TYPE_N_BASECLASSES (type); - - /* Print out baseclasses such that we don't print - duplicates of virtual baseclasses. */ - if (n_baseclasses > 0) - cplus_val_print (type, valaddr, stream, format, recurse+1, pretty, dont_print); - - if (!len && n_baseclasses == 1) - fprintf_filtered (stream, ""); - else - { - extern int inspect_it; - int fields_seen = 0; - - for (i = n_baseclasses; i < len; i++) - { - /* Check if static field */ - if (TYPE_FIELD_STATIC (type, i)) - continue; - if (fields_seen) - fprintf_filtered (stream, ", "); - else if (n_baseclasses > 0) - { - fprintf_filtered (stream, "\n"); - print_spaces_filtered (2 + 2 * recurse, stream); - fputs_filtered ("members of ", stream); - fputs_filtered (type_name_no_tag (type), stream); - fputs_filtered (": ", stream); - } - fields_seen = 1; - - if (pretty) - { - fprintf_filtered (stream, "\n"); - print_spaces_filtered (2 + 2 * recurse, stream); - } - else - { - wrap_here (n_spaces (2 + 2 * recurse)); - } - if (inspect_it) - { - if (TYPE_CODE (TYPE_FIELD_TYPE (type, i)) == TYPE_CODE_PTR) - fputs_filtered ("\"( ptr \"", stream); - else - fputs_filtered ("\"( nodef \"", stream); - fputs_filtered (TYPE_FIELD_NAME (type, i), stream); - fputs_filtered ("\" \"", stream); - fputs_filtered (TYPE_FIELD_NAME (type, i), stream); - fputs_filtered ("\") \"", stream); - } - else - { - fputs_filtered (TYPE_FIELD_NAME (type, i), stream); - fputs_filtered (" = ", stream); - } - if (TYPE_FIELD_PACKED (type, i)) - { - value v; - - /* Bitfields require special handling, especially due to byte - order problems. */ - v = value_from_longest (TYPE_FIELD_TYPE (type, i), - unpack_field_as_long (type, valaddr, i)); - - val_print (TYPE_FIELD_TYPE (type, i), VALUE_CONTENTS (v), 0, - stream, format, 0, recurse + 1, pretty); - } - else - { - val_print (TYPE_FIELD_TYPE (type, i), - valaddr + TYPE_FIELD_BITPOS (type, i) / 8, - 0, stream, format, 0, recurse + 1, pretty); - } - } - if (pretty) - { - fprintf_filtered (stream, "\n"); - print_spaces_filtered (2 * recurse, stream); - } - } - fprintf_filtered (stream, "}"); -} - -/* Special val_print routine to avoid printing multiple copies of virtual - baseclasses. */ - -static void -cplus_val_print (type, valaddr, stream, format, recurse, pretty, dont_print) - struct type *type; - char *valaddr; - FILE *stream; - char format; - int recurse; - enum val_prettyprint pretty; - struct type **dont_print; -{ - struct obstack tmp_obstack; - struct type **last_dont_print - = (struct type **)obstack_next_free (&dont_print_obstack); - int i, n_baseclasses = TYPE_N_BASECLASSES (type); - - if (dont_print == 0) - { - /* If we're at top level, carve out a completely fresh - chunk of the obstack and use that until this particular - invocation returns. */ - tmp_obstack = dont_print_obstack; - /* Bump up the high-water mark. Now alpha is omega. */ - obstack_finish (&dont_print_obstack); - } - - for (i = 0; i < n_baseclasses; i++) - { - char *baddr; - int err; - - if (BASETYPE_VIA_VIRTUAL (type, i)) - { - struct type **first_dont_print - = (struct type **)obstack_base (&dont_print_obstack); - - int j = (struct type **)obstack_next_free (&dont_print_obstack) - - first_dont_print; - - while (--j >= 0) - if (TYPE_BASECLASS (type, i) == first_dont_print[j]) - goto flush_it; - - obstack_ptr_grow (&dont_print_obstack, TYPE_BASECLASS (type, i)); - } - - baddr = baseclass_addr (type, i, valaddr, 0, &err); - if (err == 0 && baddr == 0) - error ("could not find virtual baseclass `%s'\n", - type_name_no_tag (TYPE_BASECLASS (type, i))); - - fprintf_filtered (stream, "\n"); - if (pretty) - print_spaces_filtered (2 + 2 * recurse, stream); - fputs_filtered ("<", stream); - fputs_filtered (type_name_no_tag (TYPE_BASECLASS (type, i)), stream); - fputs_filtered ("> = ", stream); - if (err != 0) - fprintf_filtered (stream, "", baddr); - else - val_print_fields (TYPE_BASECLASS (type, i), baddr, stream, format, - recurse, pretty, - (struct type **)obstack_base (&dont_print_obstack)); - flush_it: - ; - } - - if (dont_print == 0) - { - /* Free the space used to deal with the printing - of this type from top level. */ - obstack_free (&dont_print_obstack, last_dont_print); - /* Reset watermark so that we can continue protecting - ourselves from whatever we were protecting ourselves. */ - dont_print_obstack = tmp_obstack; - } -} - -/* Print data of type TYPE located at VALADDR (within GDB), - which came from the inferior at address ADDRESS, - onto stdio stream STREAM according to FORMAT - (a letter or 0 for natural format). The data at VALADDR - is in target byte order. - - If the data are a string pointer, returns the number of - sting characters printed. - - if DEREF_REF is nonzero, then dereference references, - otherwise just print them like pointers. - - The PRETTY parameter controls prettyprinting. */ - -int -val_print (type, valaddr, address, stream, format, - deref_ref, recurse, pretty) - struct type *type; - char *valaddr; - CORE_ADDR address; - FILE *stream; - char format; - int deref_ref; - int recurse; - enum val_prettyprint pretty; -{ - register unsigned int i; - unsigned len; - struct type *elttype; - unsigned eltlen; - LONGEST val; - unsigned char c; - - if (pretty == Val_pretty_default) - { - pretty = prettyprint ? Val_prettyprint : Val_no_prettyprint; - } - - QUIT; - - check_stub_type (type); - - if (TYPE_FLAGS (type) & TYPE_FLAG_STUB) - { - fprintf_filtered (stream, ""); - fflush (stream); - return 0; - } - - switch (TYPE_CODE (type)) - { - case TYPE_CODE_ARRAY: - /* FIXME: TYPE_LENGTH (type) is unsigned and therefore always - >= 0. Is "> 0" meant? I'm not sure what an "array of - unspecified length" (mentioned in the comment for the else-part - of this if) is. */ - if (TYPE_LENGTH (type) >= 0 - && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0) - { - elttype = TYPE_TARGET_TYPE (type); - eltlen = TYPE_LENGTH (elttype); - len = TYPE_LENGTH (type) / eltlen; - if (arrayprint) - print_spaces_filtered (2 + 2 * recurse, stream); - fprintf_filtered (stream, "{"); - /* For an array of chars, print with string syntax. */ - if (eltlen == 1 && TYPE_CODE (elttype) == TYPE_CODE_INT - && (format == 0 || format == 's') ) - print_string (stream, valaddr, len, 0); - else - { - unsigned int things_printed = 0; - - /* If this is a virtual function table, print the 0th - entry specially, and the rest of the members normally. */ - if (is_vtbl_ptr_type (elttype)) - { - fprintf_filtered (stream, "%d vtable entries", len-1); - i = 1; - } - else - i = 0; - - for (; i < len && things_printed < print_max; i++) - { - /* Position of the array element we are examining to see - whether it is repeated. */ - unsigned int rep1; - /* Number of repetitions we have detected so far. */ - unsigned int reps; - - if (i != 0) - if (arrayprint) - { - fprintf_filtered (stream, ",\n"); - print_spaces_filtered (2 + 2 * recurse, stream); - } - else - fprintf_filtered (stream, ", "); - wrap_here (n_spaces (2 + 2 * recurse)); - - rep1 = i + 1; - reps = 1; - while (rep1 < len - && !bcmp (valaddr + i * eltlen, - valaddr + rep1 * eltlen, eltlen)) - { - ++reps; - ++rep1; - } - - if (reps > REPEAT_COUNT_THRESHOLD) - { - val_print (elttype, valaddr + i * eltlen, - 0, stream, format, deref_ref, - recurse + 1, pretty); - fprintf_filtered (stream, " ", reps); - i = rep1 - 1; - things_printed += REPEAT_COUNT_THRESHOLD; - } - else - { - val_print (elttype, valaddr + i * eltlen, - 0, stream, format, deref_ref, - recurse + 1, pretty); - things_printed++; - } - } - if (i < len) - fprintf_filtered (stream, "..."); - } - fprintf_filtered (stream, "}"); - break; - } - /* Array of unspecified length: treat like pointer to first elt. */ - valaddr = (char *) &address; - - case TYPE_CODE_PTR: - if (format && format != 's') - { - print_scalar_formatted (valaddr, type, format, 0, stream); - break; - } - if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_METHOD) - { - struct type *domain = TYPE_DOMAIN_TYPE (TYPE_TARGET_TYPE (type)); - struct fn_field *f; - int j, len2; - char *kind = ""; - CORE_ADDR addr; - - addr = unpack_pointer (lookup_pointer_type (builtin_type_void), - valaddr); - if (addr < 128) - { - len = TYPE_NFN_FIELDS (domain); - for (i = 0; i < len; i++) - { - f = TYPE_FN_FIELDLIST1 (domain, i); - len2 = TYPE_FN_FIELDLIST_LENGTH (domain, i); - - for (j = 0; j < len2; j++) - { - QUIT; - if (TYPE_FN_FIELD_VOFFSET (f, j) == addr) - { - kind = "virtual"; - goto common; - } - } - } - } - else - { - struct symbol *sym = find_pc_function (addr); - if (sym == 0) - error ("invalid pointer to member function"); - len = TYPE_NFN_FIELDS (domain); - for (i = 0; i < len; i++) - { - f = TYPE_FN_FIELDLIST1 (domain, i); - len2 = TYPE_FN_FIELDLIST_LENGTH (domain, i); - - for (j = 0; j < len2; j++) - { - QUIT; - if (!strcmp (SYMBOL_NAME (sym), TYPE_FN_FIELD_PHYSNAME (f, j))) - goto common; - } - } - } - common: - if (i < len) - { - fprintf_filtered (stream, "&"); - type_print_varspec_prefix (TYPE_FN_FIELD_TYPE (f, j), stream, 0, 0); - fprintf (stream, kind); - if (TYPE_FN_FIELD_PHYSNAME (f, j)[0] == '_' - && TYPE_FN_FIELD_PHYSNAME (f, j)[1] == CPLUS_MARKER) - type_print_method_args - (TYPE_FN_FIELD_ARGS (f, j) + 1, "~", - TYPE_FN_FIELDLIST_NAME (domain, i), 0, stream); - else - type_print_method_args - (TYPE_FN_FIELD_ARGS (f, j), "", - TYPE_FN_FIELDLIST_NAME (domain, i), 0, stream); - break; - } - fprintf_filtered (stream, "("); - type_print (type, "", stream, -1); - fprintf_filtered (stream, ") %d", (int) addr >> 3); - } - else if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_MEMBER) - { - struct type *domain = TYPE_DOMAIN_TYPE (TYPE_TARGET_TYPE (type)); - - /* VAL is a byte offset into the structure type DOMAIN. - Find the name of the field for that offset and - print it. */ - int extra = 0; - int bits = 0; - len = TYPE_NFIELDS (domain); - /* @@ Make VAL into bit offset */ - val = unpack_long (builtin_type_int, valaddr) << 3; - for (i = TYPE_N_BASECLASSES (domain); i < len; i++) - { - int bitpos = TYPE_FIELD_BITPOS (domain, i); - QUIT; - if (val == bitpos) - break; - if (val < bitpos && i != 0) - { - /* Somehow pointing into a field. */ - i -= 1; - extra = (val - TYPE_FIELD_BITPOS (domain, i)); - if (extra & 0x3) - bits = 1; - else - extra >>= 3; - break; - } - } - if (i < len) - { - fprintf_filtered (stream, "&"); - type_print_base (domain, stream, 0, 0); - fprintf_filtered (stream, "::"); - fputs_filtered (TYPE_FIELD_NAME (domain, i), stream); - if (extra) - fprintf_filtered (stream, " + %d bytes", extra); - if (bits) - fprintf_filtered (stream, " (offset in bits)"); - break; - } - fprintf_filtered (stream, "%d", val >> 3); - } - else - { - CORE_ADDR addr = unpack_pointer (type, valaddr); - elttype = TYPE_TARGET_TYPE (type); - - if (TYPE_CODE (elttype) == TYPE_CODE_FUNC) - { - /* Try to print what function it points to. */ - print_address_demangle (addr, stream, demangle); - /* Return value is irrelevant except for string pointers. */ - return 0; - } - - if (addressprint && format != 's') - fprintf_filtered (stream, "0x%x", addr); - - /* For a pointer to char or unsigned char, - also print the string pointed to, unless pointer is null. */ - i = 0; /* Number of characters printed. */ - if (TYPE_LENGTH (elttype) == 1 - && TYPE_CODE (elttype) == TYPE_CODE_INT - && (format == 0 || format == 's') - && addr != 0 - /* If print_max is UINT_MAX, the alloca below will fail. - In that case don't try to print the string. */ - && print_max < UINT_MAX) - { - int first_addr_err = 0; - int errcode = 0; - - /* Get first character. */ - errcode = target_read_memory (addr, (char *)&c, 1); - if (errcode != 0) - { - /* First address out of bounds. */ - first_addr_err = 1; - } - else - { - /* A real string. */ - char *string = (char *) alloca (print_max); - - /* If the loop ends by us hitting print_max characters, - we need to have elipses at the end. */ - int force_ellipses = 1; - - /* This loop always fetches print_max characters, even - though print_string might want to print more or fewer - (with repeated characters). This is so that - we don't spend forever fetching if we print - a long string consisting of the same character - repeated. Also so we can do it all in one memory - operation, which is faster. However, this will be - slower if print_max is set high, e.g. if you set - print_max to 1000, not only will it take a long - time to fetch short strings, but if you are near - the end of the address space, it might not work. - FIXME. */ - QUIT; - errcode = target_read_memory (addr, string, print_max); - if (errcode != 0) - force_ellipses = 0; - else - for (i = 0; i < print_max; i++) - if (string[i] == '\0') - { - force_ellipses = 0; - break; - } - QUIT; - - if (addressprint) - fputs_filtered (" ", stream); - print_string (stream, string, i, force_ellipses); - } - - if (errcode != 0) - { - if (errcode == EIO) - { - fprintf_filtered (stream, - ("
" - + first_addr_err), - addr + i); - } - else - { - if (errcode >= sys_nerr || errcode < 0) - error ("Error reading memory address 0x%x: unknown error (%d).", - addr + i, errcode); - else - error ("Error reading memory address 0x%x: %s.", - addr + i, sys_errlist[errcode]); - } - } - - fflush (stream); - } - else /* print vtbl's nicely */ - if (is_vtbl_member(type)) - { - CORE_ADDR vt_address = unpack_pointer (type, valaddr); - - int vt_index = find_pc_misc_function (vt_address); - if (vt_index >= 0 - && vt_address == misc_function_vector[vt_index].address) - { - fputs_filtered (" <", stream); - fputs_demangled (misc_function_vector[vt_index].name, - stream, 1); - fputs_filtered (">", stream); - } - if (vtblprint) - { - value vt_val; - - vt_val = value_at (TYPE_TARGET_TYPE (type), vt_address); - val_print (VALUE_TYPE (vt_val), VALUE_CONTENTS (vt_val), - VALUE_ADDRESS (vt_val), stream, format, - deref_ref, recurse + 1, pretty); - if (pretty) - { - fprintf_filtered (stream, "\n"); - print_spaces_filtered (2 + 2 * recurse, stream); - } - } - } - - /* Return number of characters printed, plus one for the - terminating null if we have "reached the end". */ - return i + (print_max && i != print_max); - } - break; - - case TYPE_CODE_MEMBER: - error ("not implemented: member type in val_print"); - break; - - case TYPE_CODE_REF: - if (addressprint) - { - fprintf_filtered (stream, "@0x%lx", - unpack_long (builtin_type_int, valaddr)); - if (deref_ref) - fputs_filtered (": ", stream); - } - /* De-reference the reference. */ - if (deref_ref) - { - if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_UNDEF) - { - value deref_val = - value_at - (TYPE_TARGET_TYPE (type), - unpack_pointer (lookup_pointer_type (builtin_type_void), - valaddr)); - val_print (VALUE_TYPE (deref_val), VALUE_CONTENTS (deref_val), - VALUE_ADDRESS (deref_val), stream, format, - deref_ref, recurse + 1, pretty); - } - else - fputs_filtered ("???", stream); - } - break; - - case TYPE_CODE_UNION: - if (recurse && !unionprint) - { - fprintf_filtered (stream, "{...}"); - break; - } - /* Fall through. */ - case TYPE_CODE_STRUCT: - if (vtblprint && is_vtbl_ptr_type(type)) - { - /* Print the unmangled name if desired. */ - print_address_demangle(*((int *) (valaddr + /* FIXME bytesex */ - TYPE_FIELD_BITPOS (type, VTBL_FNADDR_OFFSET) / 8)), - stream, demangle); - break; - } - val_print_fields (type, valaddr, stream, format, recurse, pretty, 0); - break; - - case TYPE_CODE_ENUM: - if (format) - { - print_scalar_formatted (valaddr, type, format, 0, stream); - break; - } - len = TYPE_NFIELDS (type); - val = unpack_long (builtin_type_int, valaddr); - for (i = 0; i < len; i++) - { - QUIT; - if (val == TYPE_FIELD_BITPOS (type, i)) - break; - } - if (i < len) - fputs_filtered (TYPE_FIELD_NAME (type, i), stream); - else -#ifdef LONG_LONG - fprintf_filtered (stream, "%lld", val); -#else - fprintf_filtered (stream, "%ld", val); -#endif - break; - - case TYPE_CODE_FUNC: - if (format) - { - print_scalar_formatted (valaddr, type, format, 0, stream); - break; - } - /* FIXME, we should consider, at least for ANSI C language, eliminating - the distinction made between FUNCs and POINTERs to FUNCs. */ - fprintf_filtered (stream, "{"); - type_print (type, "", stream, -1); - fprintf_filtered (stream, "} "); - /* Try to print what function it points to, and its address. */ - print_address_demangle (address, stream, demangle); - break; - - case TYPE_CODE_INT: - if (format || output_format) - { - print_scalar_formatted (valaddr, type, - format? format: output_format, - 0, stream); - break; - } - if (TYPE_LENGTH (type) > sizeof (LONGEST)) - { - if (TYPE_UNSIGNED (type)) - { - /* First figure out whether the number in fact has zeros - in all its bytes more significant than least significant - sizeof (LONGEST) ones. */ - char *p; - /* Pointer to first (i.e. lowest address) nonzero character. */ - char *first_addr; - len = TYPE_LENGTH (type); - -#if TARGET_BYTE_ORDER == BIG_ENDIAN - for (p = valaddr; - len > sizeof (LONGEST) - && p < valaddr + TYPE_LENGTH (type); - p++) -#else /* Little endian. */ - first_addr = valaddr; - for (p = valaddr + TYPE_LENGTH (type); - len > sizeof (LONGEST) && p >= valaddr; - p--) -#endif /* Little endian. */ - { - if (*p == 0) - len--; - else - break; - } -#if TARGET_BYTE_ORDER == BIG_ENDIAN - first_addr = p; -#endif - - if (len <= sizeof (LONGEST)) - { - /* We can print it in decimal. */ - fprintf_filtered - (stream, -#if defined (LONG_LONG) - "%llu", -#else - "%lu", -#endif - unpack_long (BUILTIN_TYPE_LONGEST, first_addr)); - } - else - { - /* It is big, so print it in hex. */ - print_hex_chars (stream, (unsigned char *)first_addr, len); - } - } - else - { - /* Signed. One could assume two's complement (a reasonable - assumption, I think) and do better than this. */ - print_hex_chars (stream, (unsigned char *)valaddr, - TYPE_LENGTH (type)); - } - break; - } -#ifdef PRINT_TYPELESS_INTEGER - PRINT_TYPELESS_INTEGER (stream, type, unpack_long (type, valaddr)); -#else -#ifndef LONG_LONG - fprintf_filtered (stream, - TYPE_UNSIGNED (type) ? "%u" : "%d", - unpack_long (type, valaddr)); -#else - fprintf_filtered (stream, - TYPE_UNSIGNED (type) ? "%llu" : "%lld", - unpack_long (type, valaddr)); -#endif -#endif - - if (TYPE_LENGTH (type) == 1) - { - fprintf_filtered (stream, " '"); - printchar ((unsigned char) unpack_long (type, valaddr), - stream, '\''); - fprintf_filtered (stream, "'"); - } - break; - - case TYPE_CODE_FLT: - if (format) - print_scalar_formatted (valaddr, type, format, 0, stream); - else - print_floating (valaddr, type, stream); - break; - - case TYPE_CODE_VOID: - fprintf_filtered (stream, "void"); - break; - - case TYPE_CODE_UNDEF: - /* This happens (without TYPE_FLAG_STUB set) on systems which don't use - dbx xrefs (NO_DBX_XREFS in gcc) if a file has a "struct foo *bar" - and no complete type for struct foo in that file. */ - fprintf_filtered (stream, ""); - break; - - case TYPE_CODE_ERROR: - fprintf_filtered (stream, "?"); - break; - - case TYPE_CODE_RANGE: - /* FIXME, we should not ever have to print one of these yet. */ - fprintf_filtered (stream, ""); - break; - - default: - error ("Invalid type code in symbol table."); - } - fflush (stream); - return 0; -} - -/* Print a description of a type in the format of a - typedef for the current language. - NEW is the new name for a type TYPE. */ -void -typedef_print (type, new, stream) - struct type *type; - struct symbol *new; - FILE *stream; -{ - switch (current_language->la_language) - { -#ifdef _LANG_c - case language_c: - fprintf_filtered(stream, "typedef "); - type_print(type,"",stream,0); - if(TYPE_NAME ((SYMBOL_TYPE (new))) == 0 - || 0 != strcmp (TYPE_NAME ((SYMBOL_TYPE (new))), - SYMBOL_NAME (new))) - fprintf_filtered(stream, " %s", SYMBOL_NAME(new)); - break; -#endif -#ifdef _LANG_m2 - case language_m2: - fprintf_filtered(stream, "TYPE "); - if(!TYPE_NAME(SYMBOL_TYPE(new)) || - strcmp (TYPE_NAME(SYMBOL_TYPE(new)), - SYMBOL_NAME(new))) - fprintf_filtered(stream, "%s = ", SYMBOL_NAME(new)); - else - fprintf_filtered(stream, " = "); - type_print(type,"",stream,0); - break; -#endif - default: - error("Language not supported."); - } - fprintf_filtered(stream, ";\n"); -} - - -/* Print a description of a type TYPE - in the form of a declaration of a variable named VARSTRING. - (VARSTRING is demangled if necessary.) - Output goes to STREAM (via stdio). - If SHOW is positive, we show the contents of the outermost level - of structure even if there is a type name that could be used instead. - If SHOW is negative, we never show the details of elements' types. */ - -void -type_print (type, varstring, stream, show) - struct type *type; - char *varstring; - FILE *stream; - int show; -{ - type_print_1 (type, varstring, stream, show, 0); -} - -/* LEVEL is the depth to indent lines by. */ - -void -type_print_1 (type, varstring, stream, show, level) - struct type *type; - char *varstring; - FILE *stream; - int show; - int level; -{ - register enum type_code code; - type_print_base (type, stream, show, level); - code = TYPE_CODE (type); - if ((varstring && *varstring) - || - /* Need a space if going to print stars or brackets; - but not if we will print just a type name. */ - ((show > 0 || TYPE_NAME (type) == 0) - && - (code == TYPE_CODE_PTR || code == TYPE_CODE_FUNC - || code == TYPE_CODE_METHOD - || code == TYPE_CODE_ARRAY - || code == TYPE_CODE_MEMBER - || code == TYPE_CODE_REF))) - fprintf_filtered (stream, " "); - type_print_varspec_prefix (type, stream, show, 0); - fputs_demangled (varstring, stream, -1); /* Print demangled name - without arguments */ - type_print_varspec_suffix (type, stream, show, 0); -} - -/* Print the method arguments ARGS to the file STREAM. */ -static void -type_print_method_args (args, prefix, varstring, staticp, stream) - struct type **args; - char *prefix, *varstring; - int staticp; - FILE *stream; -{ - int i; - - fputs_filtered (" ", stream); - fputs_demangled (prefix, stream, 1); - fputs_demangled (varstring, stream, 1); - fputs_filtered (" (", stream); - if (args && args[!staticp] && args[!staticp]->code != TYPE_CODE_VOID) - { - i = !staticp; /* skip the class variable */ - while (1) - { - type_print (args[i++], "", stream, 0); - if (!args[i]) - { - fprintf_filtered (stream, " ..."); - break; - } - else if (args[i]->code != TYPE_CODE_VOID) - { - fprintf_filtered (stream, ", "); - } - else break; - } - } - fprintf_filtered (stream, ")"); -} - -/* If TYPE is a derived type, then print out derivation - information. Print out all layers of the type heirarchy - until we encounter one with multiple inheritance. - At that point, print out that ply, and return. */ -static void -type_print_derivation_info (stream, type) - FILE *stream; - struct type *type; -{ - char *name; - int i, n_baseclasses = TYPE_N_BASECLASSES (type); - struct type *basetype = 0; - - while (type && n_baseclasses > 0) - { - /* Not actually sure about this one -- Bryan. */ - check_stub_type (type); - - fprintf_filtered (stream, ": "); - for (i = 0; ;) - { - basetype = TYPE_BASECLASS (type, i); - if (name = type_name_no_tag (basetype)) - { - fprintf_filtered (stream, "%s%s ", - BASETYPE_VIA_PUBLIC(type, i) ? "public" : "private", - BASETYPE_VIA_VIRTUAL(type, i) ? " virtual" : ""); - fputs_filtered (name, stream); - } - i++; - if (i >= n_baseclasses) - break; - fprintf_filtered (stream, ", "); - } - - fprintf_filtered (stream, " "); - if (n_baseclasses != 1) - break; - n_baseclasses = TYPE_N_BASECLASSES (basetype); - type = basetype; - } -} - -/* Print any asterisks or open-parentheses needed before the - variable name (to describe its type). - - On outermost call, pass 0 for PASSED_A_PTR. - On outermost call, SHOW > 0 means should ignore - any typename for TYPE and show its details. - SHOW is always zero on recursive calls. */ - -static void -type_print_varspec_prefix (type, stream, show, passed_a_ptr) - struct type *type; - FILE *stream; - int show; - int passed_a_ptr; -{ - if (type == 0) - return; - - if (TYPE_NAME (type) && show <= 0) - return; - - QUIT; - - switch (TYPE_CODE (type)) - { - case TYPE_CODE_PTR: - type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 1); - fprintf_filtered (stream, "*"); - break; - - case TYPE_CODE_MEMBER: - if (passed_a_ptr) - fprintf_filtered (stream, "("); - type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, - 0); - fprintf_filtered (stream, " "); - type_print_base (TYPE_DOMAIN_TYPE (type), stream, 0, - passed_a_ptr); - fprintf_filtered (stream, "::"); - break; - - case TYPE_CODE_METHOD: - if (passed_a_ptr) - fprintf (stream, "("); - type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, - 0); - if (passed_a_ptr) - { - fprintf_filtered (stream, " "); - type_print_base (TYPE_DOMAIN_TYPE (type), stream, 0, - passed_a_ptr); - fprintf_filtered (stream, "::"); - } - break; - - case TYPE_CODE_REF: - type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 1); - fprintf_filtered (stream, "&"); - break; - - case TYPE_CODE_FUNC: - type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, - 0); - if (passed_a_ptr) - fprintf_filtered (stream, "("); - break; - - case TYPE_CODE_ARRAY: - type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, - 0); - if (passed_a_ptr) - fprintf_filtered (stream, "("); - - case TYPE_CODE_UNDEF: - case TYPE_CODE_STRUCT: - case TYPE_CODE_UNION: - case TYPE_CODE_ENUM: - case TYPE_CODE_INT: - case TYPE_CODE_FLT: - case TYPE_CODE_VOID: - case TYPE_CODE_ERROR: - /* These types need no prefix. They are listed here so that - gcc -Wall will reveal any types that haven't been handled. */ - break; - } -} - -/* Print any array sizes, function arguments or close parentheses - needed after the variable name (to describe its type). - Args work like type_print_varspec_prefix. */ - -static void -type_print_varspec_suffix (type, stream, show, passed_a_ptr) - struct type *type; - FILE *stream; - int show; - int passed_a_ptr; -{ - if (type == 0) - return; - - if (TYPE_NAME (type) && show <= 0) - return; - - QUIT; - - switch (TYPE_CODE (type)) - { - case TYPE_CODE_ARRAY: - if (passed_a_ptr) - fprintf_filtered (stream, ")"); - - fprintf_filtered (stream, "["); - if (TYPE_LENGTH (type) > 0 - && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0) - fprintf_filtered (stream, "%d", - (TYPE_LENGTH (type) - / TYPE_LENGTH (TYPE_TARGET_TYPE (type)))); - fprintf_filtered (stream, "]"); - - type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, - 0); - break; - - case TYPE_CODE_MEMBER: - if (passed_a_ptr) - fprintf_filtered (stream, ")"); - type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 0); - break; - - case TYPE_CODE_METHOD: - if (passed_a_ptr) - fprintf_filtered (stream, ")"); - type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 0); - if (passed_a_ptr) - { - int i; - struct type **args = TYPE_ARG_TYPES (type); - - fprintf_filtered (stream, "("); - if (args[1] == 0) - fprintf_filtered (stream, "..."); - else for (i = 1; args[i] != 0 && args[i]->code != TYPE_CODE_VOID; i++) - { - type_print_1 (args[i], "", stream, -1, 0); - if (args[i+1] == 0) - fprintf_filtered (stream, "..."); - else if (args[i+1]->code != TYPE_CODE_VOID) { - fprintf_filtered (stream, ","); - wrap_here (" "); - } - } - fprintf_filtered (stream, ")"); - } - break; - - case TYPE_CODE_PTR: - case TYPE_CODE_REF: - type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 1); - break; - - case TYPE_CODE_FUNC: - type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, - passed_a_ptr); - if (passed_a_ptr) - fprintf_filtered (stream, ")"); - fprintf_filtered (stream, "()"); - break; - - case TYPE_CODE_UNDEF: - case TYPE_CODE_STRUCT: - case TYPE_CODE_UNION: - case TYPE_CODE_ENUM: - case TYPE_CODE_INT: - case TYPE_CODE_FLT: - case TYPE_CODE_VOID: - case TYPE_CODE_ERROR: - /* These types do not need a suffix. They are listed so that - gcc -Wall will report types that may not have been considered. */ - break; - } -} - -/* Print the name of the type (or the ultimate pointer target, - function value or array element), or the description of a - structure or union. - - SHOW nonzero means don't print this type as just its name; - show its real definition even if it has a name. - SHOW zero means print just typename or struct tag if there is one - SHOW negative means abbreviate structure elements. - SHOW is decremented for printing of structure elements. - - LEVEL is the depth to indent by. - We increase it for some recursive calls. */ - -static void -type_print_base (type, stream, show, level) - struct type *type; - FILE *stream; - int show; - int level; -{ - char *name; - register int i; - register int len; - register int lastval; - - QUIT; - - wrap_here (" "); - if (type == 0) - { - fprintf_filtered (stream, ""); - return; - } - - if (TYPE_NAME (type) && show <= 0) - { - fputs_filtered (TYPE_NAME (type), stream); - return; - } - - switch (TYPE_CODE (type)) - { - case TYPE_CODE_ARRAY: - case TYPE_CODE_PTR: - case TYPE_CODE_MEMBER: - case TYPE_CODE_REF: - case TYPE_CODE_FUNC: - case TYPE_CODE_METHOD: - type_print_base (TYPE_TARGET_TYPE (type), stream, show, level); - break; - - case TYPE_CODE_STRUCT: - fprintf_filtered (stream, "struct "); - goto struct_union; - - case TYPE_CODE_UNION: - fprintf_filtered (stream, "union "); - struct_union: - if (name = type_name_no_tag (type)) - { - fputs_filtered (name, stream); - fputs_filtered (" ", stream); - wrap_here (" "); - } - if (show < 0) - fprintf_filtered (stream, "{...}"); - else - { - check_stub_type (type); - - type_print_derivation_info (stream, type); - - fprintf_filtered (stream, "{"); - len = TYPE_NFIELDS (type); - if (len) - fprintf_filtered (stream, "\n"); - else - { - if (TYPE_FLAGS (type) & TYPE_FLAG_STUB) - fprintf_filtered (stream, "\n"); - else - fprintf_filtered (stream, "\n"); - } - - /* If there is a base class for this type, - do not print the field that it occupies. */ - for (i = TYPE_N_BASECLASSES (type); i < len; i++) - { - QUIT; - /* Don't print out virtual function table. */ - if ((TYPE_FIELD_NAME (type, i))[5] == CPLUS_MARKER && - !strncmp (TYPE_FIELD_NAME (type, i), "_vptr", 5)) - continue; - - print_spaces_filtered (level + 4, stream); - if (TYPE_FIELD_STATIC (type, i)) - { - fprintf_filtered (stream, "static "); - } - type_print_1 (TYPE_FIELD_TYPE (type, i), - TYPE_FIELD_NAME (type, i), - stream, show - 1, level + 4); - if (!TYPE_FIELD_STATIC (type, i) - && TYPE_FIELD_PACKED (type, i)) - { - /* It is a bitfield. This code does not attempt - to look at the bitpos and reconstruct filler, - unnamed fields. This would lead to misleading - results if the compiler does not put out fields - for such things (I don't know what it does). */ - fprintf_filtered (stream, " : %d", - TYPE_FIELD_BITSIZE (type, i)); - } - fprintf_filtered (stream, ";\n"); - } - - /* C++: print out the methods */ - len = TYPE_NFN_FIELDS (type); - if (len) fprintf_filtered (stream, "\n"); - for (i = 0; i < len; i++) - { - struct fn_field *f = TYPE_FN_FIELDLIST1 (type, i); - int j, len2 = TYPE_FN_FIELDLIST_LENGTH (type, i); - - for (j = 0; j < len2; j++) - { - QUIT; - print_spaces_filtered (level + 4, stream); - if (TYPE_FN_FIELD_VIRTUAL_P (f, j)) - fprintf_filtered (stream, "virtual "); - else if (TYPE_FN_FIELD_STATIC_P (f, j)) - fprintf_filtered (stream, "static "); - if (TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j)) == 0) - { - /* Keep GDB from crashing here. */ - fprintf (stream, " %s;\n", - TYPE_FN_FIELD_PHYSNAME (f, j)); - break; - } - else - type_print (TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j)), "", stream, 0); - if (TYPE_FLAGS (TYPE_FN_FIELD_TYPE (f, j)) & TYPE_FLAG_STUB) - { - /* Build something we can demangle. */ - char *strchr (), *gdb_mangle_name (), *cplus_demangle (); - char *mangled_name = gdb_mangle_name (type, i, j); - char *demangled_name = cplus_demangle (mangled_name, 1); - if (demangled_name == 0) - fprintf_filtered (stream, " ", - mangled_name); - else - { - fprintf_filtered (stream, " %s", - strchr (demangled_name, ':') + 2); - free (demangled_name); - } - free (mangled_name); - } - else if (TYPE_FN_FIELD_PHYSNAME (f, j)[0] == '_' - && TYPE_FN_FIELD_PHYSNAME (f, j)[1] == CPLUS_MARKER) - type_print_method_args - (TYPE_FN_FIELD_ARGS (f, j) + 1, "~", - TYPE_FN_FIELDLIST_NAME (type, i), 0, stream); - else - type_print_method_args - (TYPE_FN_FIELD_ARGS (f, j), "", - TYPE_FN_FIELDLIST_NAME (type, i), - TYPE_FN_FIELD_STATIC_P (f, j), stream); - - fprintf_filtered (stream, ";\n"); - } - } - - print_spaces_filtered (level, stream); - fprintf_filtered (stream, "}"); - } - break; - - case TYPE_CODE_ENUM: - fprintf_filtered (stream, "enum "); - if (name = type_name_no_tag (type)) - { - fputs_filtered (name, stream); - fputs_filtered (" ", stream); - } - wrap_here (" "); - if (show < 0) - fprintf_filtered (stream, "{...}"); - else - { - fprintf_filtered (stream, "{"); - len = TYPE_NFIELDS (type); - lastval = 0; - for (i = 0; i < len; i++) - { - QUIT; - if (i) fprintf_filtered (stream, ", "); - wrap_here (" "); - fputs_filtered (TYPE_FIELD_NAME (type, i), stream); - if (lastval != TYPE_FIELD_BITPOS (type, i)) - { - fprintf_filtered (stream, " = %d", TYPE_FIELD_BITPOS (type, i)); - lastval = TYPE_FIELD_BITPOS (type, i); - } - lastval++; - } - fprintf_filtered (stream, "}"); - } - break; - - case TYPE_CODE_INT: - name = 0; - if (TYPE_LENGTH (type) <= sizeof (LONGEST)) - { - if (TYPE_UNSIGNED (type)) - name = unsigned_type_table[TYPE_LENGTH (type)]; - else - name = signed_type_table[TYPE_LENGTH (type)]; - } - if (name) - fputs_filtered (name, stream); - else - fprintf_filtered (stream, "<%d bit integer>", - TYPE_LENGTH (type) * TARGET_CHAR_BIT); - break; - - case TYPE_CODE_FLT: - name = float_type_table[TYPE_LENGTH (type)]; - fputs_filtered (name, stream); - break; - - case TYPE_CODE_VOID: - fprintf_filtered (stream, "void"); - break; - - case TYPE_CODE_UNDEF: - fprintf_filtered (stream, "struct "); - break; - - case TYPE_CODE_ERROR: - fprintf_filtered (stream, ""); - break; - - case TYPE_CODE_RANGE: - /* This should not occur */ - fprintf_filtered (stream, ""); - break; - - default: - error ("Invalid type code in symbol table."); - } -} - -#if 0 -/* Validate an input or output radix setting, and make sure the user - knows what they really did here. Radix setting is confusing, e.g. - setting the input radix to "10" never changes it! */ - -/* ARGSUSED */ -static void -set_input_radix (args, from_tty, c) - char *args; - int from_tty; - struct cmd_list_element *c; -{ - unsigned radix = *(unsigned *)c->var; - - if (from_tty) - printf_filtered ("Input radix set to decimal %d, hex %x, octal %o\n", - radix, radix, radix); -} -#endif - -/* ARGSUSED */ -static void -set_output_radix (args, from_tty, c) - char *args; - int from_tty; - struct cmd_list_element *c; -{ - unsigned radix = *(unsigned *)c->var; - - if (from_tty) - printf_filtered ("Output radix set to decimal %d, hex %x, octal %o\n", - radix, radix, radix); - - /* FIXME, we really should be able to validate the setting BEFORE - it takes effect. */ - switch (radix) - { - case 16: - output_format = 'x'; - break; - case 10: - output_format = 0; - break; - case 8: - output_format = 'o'; /* octal */ - break; - default: - output_format = 0; - error ("Unsupported radix ``decimal %d''; using decimal output", - radix); - } -} - -/* Both at once */ -static void -set_radix (arg, from_tty, c) - char *arg; - int from_tty; - struct cmd_list_element *c; -{ - unsigned radix = *(unsigned *)c->var; - - if (from_tty) - printf_filtered ("Radix set to decimal %d, hex %x, octal %o\n", - radix, radix, radix); - - input_radix = radix; - output_radix = radix; - - set_output_radix (arg, 0, c); -} - -struct cmd_list_element *setprintlist = NULL; -struct cmd_list_element *showprintlist = NULL; - -/*ARGSUSED*/ -static void -set_print (arg, from_tty) - char *arg; - int from_tty; -{ - printf ( -"\"set print\" must be followed by the name of a print subcommand.\n"); - help_list (setprintlist, "set print ", -1, stdout); -} - -/*ARGSUSED*/ -static void -show_print (args, from_tty) - char *args; - int from_tty; -{ - cmd_show_list (showprintlist, from_tty, ""); -} - -void -_initialize_valprint () -{ - struct cmd_list_element *c; - - add_prefix_cmd ("print", no_class, set_print, - "Generic command for setting how things print.", - &setprintlist, "set print ", 0, &setlist); - add_alias_cmd ("p", "print", no_class, 1, &setlist); - add_alias_cmd ("pr", "print", no_class, 1, &setlist); /* prefer set print - to set prompt */ - add_prefix_cmd ("print", no_class, show_print, - "Generic command for showing print settings.", - &showprintlist, "show print ", 0, &showlist); - add_alias_cmd ("p", "print", no_class, 1, &showlist); - add_alias_cmd ("pr", "print", no_class, 1, &showlist); - - add_show_from_set - (add_set_cmd ("elements", no_class, var_uinteger, (char *)&print_max, - "Set limit on string chars or array elements to print.\n\ -\"set print elements 0\" causes there to be no limit.", - &setprintlist), - &showprintlist); - - add_show_from_set - (add_set_cmd ("pretty", class_support, var_boolean, (char *)&prettyprint, - "Set prettyprinting of structures.", - &setprintlist), - &showprintlist); - - add_show_from_set - (add_set_cmd ("union", class_support, var_boolean, (char *)&unionprint, - "Set printing of unions interior to structures.", - &setprintlist), - &showprintlist); - - add_show_from_set - (add_set_cmd ("vtbl", class_support, var_boolean, (char *)&vtblprint, - "Set printing of C++ virtual function tables.", - &setprintlist), - &showprintlist); - - add_show_from_set - (add_set_cmd ("array", class_support, var_boolean, (char *)&arrayprint, - "Set prettyprinting of arrays.", - &setprintlist), - &showprintlist); - - add_show_from_set - (add_set_cmd ("object", class_support, var_boolean, (char *)&objectprint, - "Set printing of object's derived type based on vtable info.", - &setprintlist), - &showprintlist); - - add_show_from_set - (add_set_cmd ("address", class_support, var_boolean, (char *)&addressprint, - "Set printing of addresses.", - &setprintlist), - &showprintlist); - -#if 0 - /* The "show radix" cmd isn't good enough to show two separate values. - The rest of the code works, but the show part is confusing, so don't - let them be set separately 'til we work out "show". */ - c = add_set_cmd ("input-radix", class_support, var_uinteger, - (char *)&input_radix, - "Set default input radix for entering numbers.", - &setlist); - add_show_from_set (c, &showlist); - c->function = set_input_radix; - - c = add_set_cmd ("output-radix", class_support, var_uinteger, - (char *)&output_radix, - "Set default output radix for printing of values.", - &setlist); - add_show_from_set (c, &showlist); - c->function = set_output_radix; -#endif - - c = add_set_cmd ("radix", class_support, var_uinteger, - (char *)&output_radix, - "Set default input and output number radix.", - &setlist); - add_show_from_set (c, &showlist); - c->function = set_radix; - - /* Give people the defaults which they are used to. */ - prettyprint = 0; - unionprint = 1; - vtblprint = 0; - arrayprint = 0; - addressprint = 1; - objectprint = 0; - - print_max = 200; - - /* Initialize the names of the various types based on their lengths on - the target, in bits. Note that ordering is important, so that for example, - if ints and longs are the same size, that size will default to "int". */ - - unsigned_type_table = (char **) - xmalloc ((1 + (TARGET_LONG_LONG_BIT/TARGET_CHAR_BIT)) * sizeof (char *)); - bzero (unsigned_type_table, (1 + (TARGET_LONG_LONG_BIT/TARGET_CHAR_BIT))); - unsigned_type_table[TARGET_CHAR_BIT/TARGET_CHAR_BIT] = "unsigned char"; - unsigned_type_table[TARGET_SHORT_BIT/TARGET_CHAR_BIT] = "unsigned short"; - unsigned_type_table[TARGET_LONG_LONG_BIT/TARGET_CHAR_BIT] = "unsigned long long"; - unsigned_type_table[TARGET_LONG_BIT/TARGET_CHAR_BIT] = "unsigned long"; - unsigned_type_table[TARGET_INT_BIT/TARGET_CHAR_BIT] = "unsigned int"; - - signed_type_table = (char **) - xmalloc ((1 + (TARGET_LONG_LONG_BIT/TARGET_CHAR_BIT)) * sizeof (char *)); - bzero (signed_type_table, (1 + (TARGET_LONG_LONG_BIT/TARGET_CHAR_BIT))); - signed_type_table[TARGET_CHAR_BIT/TARGET_CHAR_BIT] = "char"; - signed_type_table[TARGET_SHORT_BIT/TARGET_CHAR_BIT] = "short"; - signed_type_table[TARGET_LONG_LONG_BIT/TARGET_CHAR_BIT] = "long long"; - signed_type_table[TARGET_LONG_BIT/TARGET_CHAR_BIT] = "long"; - signed_type_table[TARGET_INT_BIT/TARGET_CHAR_BIT] = "int"; - - float_type_table = (char **) - xmalloc ((1 + (TARGET_LONG_DOUBLE_BIT/TARGET_CHAR_BIT)) * sizeof (char *)); - bzero (float_type_table, (1 + (TARGET_LONG_DOUBLE_BIT/TARGET_CHAR_BIT))); - float_type_table[TARGET_FLOAT_BIT/TARGET_CHAR_BIT] = "float"; - float_type_table[TARGET_DOUBLE_COMPLEX_BIT/TARGET_CHAR_BIT] = "double complex"; - float_type_table[TARGET_COMPLEX_BIT/TARGET_CHAR_BIT] = "complex"; - float_type_table[TARGET_LONG_DOUBLE_BIT/TARGET_CHAR_BIT] = "long double"; - float_type_table[TARGET_DOUBLE_BIT/TARGET_CHAR_BIT] = "double"; - - obstack_begin (&dont_print_obstack, 32 * sizeof (struct type *)); -} diff --git a/gdb/value.h b/gdb/value.h deleted file mode 100644 index e0cc0d452e0..00000000000 --- a/gdb/value.h +++ /dev/null @@ -1,291 +0,0 @@ -/* Definitions for values of C expressions, for GDB. - Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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 1, or (at your option) -any later version. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#if !defined (VALUE_H) -#define VALUE_H 1 -/* - * The structure which defines the type of a value. It should never - * be possible for a program lval value to survive over a call to the inferior - * (ie to be put into the history list or an internal variable). - */ -enum lval_type { - /* Not an lval. */ - not_lval, - /* In memory. Could be a saved register. */ - lval_memory, - /* In a register. */ - lval_register, - /* In a gdb internal variable. */ - lval_internalvar, - /* Part of a gdb internal variable (structure field). */ - lval_internalvar_component, - /* In a register series in a frame not the current one, which may have been - partially saved or saved in different places (otherwise would be - lval_register or lval_memory). */ - lval_reg_frame_relative, -}; - -struct value - { - /* Type of value; either not an lval, or one of the various - different possible kinds of lval. */ - enum lval_type lval; - /* Location of value (if lval). */ - union - { - /* Address in inferior or byte of registers structure. */ - CORE_ADDR address; - /* Pointer to interrnal variable. */ - struct internalvar *internalvar; - /* Number of register. Only used with - lval_reg_frame_relative. */ - int regnum; - } location; - /* Describes offset of a value within lval a structure in bytes. */ - int offset; - /* Only used for bitfields; number of bits contained in them. */ - int bitsize; - /* Only used for bitfields; position of start of field. */ - int bitpos; - /* Frame value is relative to. In practice, this address is only - used if the value is stored in several registers in other than - the current frame, and these registers have not all been saved - at the same place in memory. This will be described in the - lval enum above as "lval_reg_frame_relative". */ - CORE_ADDR frame_addr; - /* Type of the value. */ - struct type *type; - /* Values are stored in a chain, so that they can be deleted - easily over calls to the inferior. Values assigned to internal - variables or put into the value history are taken off this - list. */ - struct value *next; - /* If an lval is forced to repeat, a new value is created with - these fields set. The new value is not an lval. */ - short repeated; - short repetitions; - /* 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? */ - short regno; - /* If zero, contents of this value are in the contents field. - If nonzero, contents are in inferior memory at address - in the location.address field plus the offset field - (and the lval field should be lval_memory). */ - char lazy; - /* If nonzero, this is the value of a variable which does not - actually exist in the program. */ - char optimized_out; - /* Actual contents of the value. For use of this value; setting - it uses the stuff above. Not valid if lazy is nonzero. - Target byte-order. We force it to be aligned properly for any - possible value. */ - union { - long contents[1]; - double force_double_align; -#ifdef LONG_LONG - long long force_longlong_align; -#endif - } aligner; - - }; - -typedef struct value *value; - -#define VALUE_TYPE(val) (val)->type -#define VALUE_LAZY(val) (val)->lazy -/* VALUE_CONTENTS and VALUE_CONTENTS_RAW both return the address of - the gdb buffer used to hold a copy of the contents of the lval. - VALUE_CONTENTS is used when the contents of the buffer are needed -- - it uses value_fetch_lazy() to load the buffer from the process being - debugged if it hasn't already been loaded. VALUE_CONTENTS_RAW is - used when data is being stored into the buffer, or when it is - certain that the contents of the buffer are valid. */ -#define VALUE_CONTENTS_RAW(val) ((char *) (val)->aligner.contents) -#define VALUE_CONTENTS(val) ((void)(VALUE_LAZY(val) && value_fetch_lazy(val)),\ - VALUE_CONTENTS_RAW(val)) -extern int value_fetch_lazy (); -#define VALUE_LVAL(val) (val)->lval -#define VALUE_ADDRESS(val) (val)->location.address -#define VALUE_INTERNALVAR(val) (val)->location.internalvar -#define VALUE_FRAME_REGNUM(val) ((val)->location.regnum) -#define VALUE_FRAME(val) ((val)->frame_addr) -#define VALUE_OFFSET(val) (val)->offset -#define VALUE_BITSIZE(val) (val)->bitsize -#define VALUE_BITPOS(val) (val)->bitpos -#define VALUE_NEXT(val) (val)->next -#define VALUE_REPEATED(val) (val)->repeated -#define VALUE_REPETITIONS(val) (val)->repetitions -#define VALUE_REGNO(val) (val)->regno -#define VALUE_OPTIMIZED_OUT(val) ((val)->optimized_out) - -/* Convert a REF to the object referenced. */ - -#define COERCE_REF(arg) \ -{ if (TYPE_CODE ( VALUE_TYPE (arg)) == TYPE_CODE_REF) \ - arg = value_at_lazy (TYPE_TARGET_TYPE (VALUE_TYPE (arg)), \ - unpack_long (VALUE_TYPE (arg), \ - VALUE_CONTENTS (arg)));} - -/* If ARG is an array, convert it to a pointer. - If ARG is an enum, convert it to an integer. - If ARG is a function, convert it to a function pointer. - - References are dereferenced. */ - -#define COERCE_ARRAY(arg) \ -{ COERCE_REF(arg); \ - if (VALUE_REPEATED (arg) \ - || TYPE_CODE (VALUE_TYPE (arg)) == TYPE_CODE_ARRAY) \ - arg = value_coerce_array (arg); \ - if (TYPE_CODE (VALUE_TYPE (arg)) == TYPE_CODE_FUNC) \ - arg = value_coerce_function (arg); \ - if (TYPE_CODE (VALUE_TYPE (arg)) == TYPE_CODE_ENUM) \ - arg = value_cast (builtin_type_unsigned_int, arg); \ -} - -/* If ARG is an enum, convert it to an integer. */ - -#define COERCE_ENUM(arg) \ -{ if (TYPE_CODE ( VALUE_TYPE (arg)) == TYPE_CODE_REF) \ - arg = value_ind (arg); \ - if (TYPE_CODE (VALUE_TYPE (arg)) == TYPE_CODE_ENUM) \ - arg = value_cast (builtin_type_unsigned_int, arg); \ -} - -/* Internal variables (variables for convenience of use of debugger) - are recorded as a chain of these structures. */ - -struct internalvar -{ - struct internalvar *next; - char *name; - value value; -}; - -#include "symtab.h" -LONGEST value_as_long (); -double value_as_double (); -LONGEST unpack_long (); -double unpack_double (); -long unpack_field_as_long (); -value value_from_long (); -value value_from_double (); -value value_at (); -value value_at_lazy (); -value value_from_register (); -value value_of_variable (); -value value_of_register (); -value read_var_value (); -value locate_var_value (); -value allocate_value (); -value allocate_repeat_value (); -value value_mark (); -void value_free_to_mark (); -value value_string (); - -value value_binop (); -value value_add (); -value value_sub (); -value value_coerce_array (); -value value_coerce_function (); -value value_ind (); -value value_addr (); -value value_assign (); -value value_neg (); -value value_lognot (); -value value_struct_elt (), value_struct_elt_for_address (); -value value_field (), value_primitive_field (); -value value_cast (); -value value_zero (); -value value_repeat (); -value value_subscript (); -value value_from_vtable_info (); - -value value_being_returned (); -int using_struct_return (); -void set_return_value (); - -value evaluate_expression (); -value evaluate_type (); -value parse_and_eval (); -value parse_to_comma_and_eval (); -extern CORE_ADDR parse_and_eval_address (); -extern CORE_ADDR parse_and_eval_address_1 (); - -value access_value_history (); -value value_of_internalvar (); -void set_internalvar (); -void set_internalvar_component (); -struct internalvar *lookup_internalvar (); - -int value_equal (); -int value_less (); -int value_zerop (); - -/* C++ */ -value value_of_this (); -value value_static_field (); -value value_x_binop (); -value value_x_unop (); -value value_fn_field (); -value value_virtual_fn_field (); -int binop_user_defined_p (); -int unop_user_defined_p (); -int typecmp (); -void fill_in_vptr_fieldno (); -int destructor_name_p (); - -#define value_free(val) free (val) -void free_all_values (); -void release_value (); -int record_latest_value (); - -void registers_changed (); -void read_register_bytes (); -void write_register_bytes (); -void read_register_gen (); -CORE_ADDR read_register (); -void write_register (); -void supply_register (); -void get_saved_register (); - -void modify_field (); -void type_print (); -void type_print_1 (); - -/* Possibilities for prettyprint parameters to routines which print - things. */ -enum val_prettyprint { - Val_no_prettyprint = 0, - Val_prettyprint, - /* Use the default setting which the user has specified. */ - Val_pretty_default - }; - -char *baseclass_addr (); -void print_floating (); -int value_print (); -int val_print (); -void print_variable_value (); -char *internalvar_name (); -void clear_value_history (); -void clear_internalvars (); - -#endif /* value.h not already included. */ diff --git a/gdb/values.c b/gdb/values.c deleted file mode 100644 index 810e00b41a8..00000000000 --- a/gdb/values.c +++ /dev/null @@ -1,1586 +0,0 @@ -/* Low level packing and unpacking of values for GDB. - Copyright (C) 1986, 1987, 1989 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include -#include "defs.h" -#include "param.h" -#include "symtab.h" -#include "value.h" -#include "gdbcore.h" -#include "frame.h" -#include "command.h" -#include "gdbcmd.h" - -extern char *cplus_demangle (); - -/* The value-history records all the values printed - by print commands during this session. Each chunk - records 60 consecutive values. The first chunk on - the chain records the most recent values. - The total number of values is in value_history_count. */ - -#define VALUE_HISTORY_CHUNK 60 - -struct value_history_chunk -{ - struct value_history_chunk *next; - value values[VALUE_HISTORY_CHUNK]; -}; - -/* Chain of chunks now in use. */ - -static struct value_history_chunk *value_history_chain; - -static int value_history_count; /* Abs number of last entry stored */ - -/* List of all value objects currently allocated - (except for those released by calls to release_value) - This is so they can be freed after each command. */ - -static value all_values; - -/* Allocate a value that has the correct length for type TYPE. */ - -value -allocate_value (type) - struct type *type; -{ - register value val; - - check_stub_type (type); - - val = (value) xmalloc (sizeof (struct value) + TYPE_LENGTH (type)); - VALUE_NEXT (val) = all_values; - all_values = val; - VALUE_TYPE (val) = type; - VALUE_LVAL (val) = not_lval; - VALUE_ADDRESS (val) = 0; - VALUE_FRAME (val) = 0; - VALUE_OFFSET (val) = 0; - VALUE_BITPOS (val) = 0; - VALUE_BITSIZE (val) = 0; - VALUE_REPEATED (val) = 0; - VALUE_REPETITIONS (val) = 0; - VALUE_REGNO (val) = -1; - VALUE_LAZY (val) = 0; - VALUE_OPTIMIZED_OUT (val) = 0; - return val; -} - -/* Allocate a value that has the correct length - for COUNT repetitions type TYPE. */ - -value -allocate_repeat_value (type, count) - struct type *type; - int count; -{ - register value val; - - val = (value) xmalloc (sizeof (struct value) + TYPE_LENGTH (type) * count); - VALUE_NEXT (val) = all_values; - all_values = val; - VALUE_TYPE (val) = type; - VALUE_LVAL (val) = not_lval; - VALUE_ADDRESS (val) = 0; - VALUE_FRAME (val) = 0; - VALUE_OFFSET (val) = 0; - VALUE_BITPOS (val) = 0; - VALUE_BITSIZE (val) = 0; - VALUE_REPEATED (val) = 1; - VALUE_REPETITIONS (val) = count; - VALUE_REGNO (val) = -1; - VALUE_LAZY (val) = 0; - VALUE_OPTIMIZED_OUT (val) = 0; - return val; -} - -/* Return a mark in the value chain. All values allocated after the - mark is obtained (except for those released) are subject to being freed - if a subsequent value_free_to_mark is passed the mark. */ -value -value_mark () -{ - return all_values; -} - -/* Free all values allocated since MARK was obtained by value_mark - (except for those released). */ -void -value_free_to_mark (mark) - value mark; -{ - value val, next; - - for (val = all_values; val && val != mark; val = next) - { - next = VALUE_NEXT (val); - value_free (val); - } - all_values = val; -} - -/* Free all the values that have been allocated (except for those released). - Called after each command, successful or not. */ - -void -free_all_values () -{ - register value val, next; - - for (val = all_values; val; val = next) - { - next = VALUE_NEXT (val); - value_free (val); - } - - all_values = 0; -} - -/* Remove VAL from the chain all_values - so it will not be freed automatically. */ - -void -release_value (val) - register value val; -{ - register value v; - - if (all_values == val) - { - all_values = val->next; - return; - } - - for (v = all_values; v; v = v->next) - { - if (v->next == val) - { - v->next = val->next; - break; - } - } -} - -/* Return a copy of the value ARG. - It contains the same contents, for same memory address, - but it's a different block of storage. */ - -static value -value_copy (arg) - value arg; -{ - register value val; - register struct type *type = VALUE_TYPE (arg); - if (VALUE_REPEATED (arg)) - val = allocate_repeat_value (type, VALUE_REPETITIONS (arg)); - else - val = allocate_value (type); - VALUE_LVAL (val) = VALUE_LVAL (arg); - VALUE_ADDRESS (val) = VALUE_ADDRESS (arg); - VALUE_OFFSET (val) = VALUE_OFFSET (arg); - VALUE_BITPOS (val) = VALUE_BITPOS (arg); - VALUE_BITSIZE (val) = VALUE_BITSIZE (arg); - VALUE_REGNO (val) = VALUE_REGNO (arg); - VALUE_LAZY (val) = VALUE_LAZY (arg); - if (!VALUE_LAZY (val)) - { - bcopy (VALUE_CONTENTS_RAW (arg), VALUE_CONTENTS_RAW (val), - TYPE_LENGTH (VALUE_TYPE (arg)) - * (VALUE_REPEATED (arg) ? VALUE_REPETITIONS (arg) : 1)); - } - return val; -} - -/* Access to the value history. */ - -/* Record a new value in the value history. - Returns the absolute history index of the entry. - Result of -1 indicates the value was not saved; otherwise it is the - value history index of this new item. */ - -int -record_latest_value (val) - value val; -{ - int i; - - /* Check error now if about to store an invalid float. We return -1 - to the caller, but allow them to continue, e.g. to print it as "Nan". */ - if (TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_FLT) { - (void) unpack_double (VALUE_TYPE (val), VALUE_CONTENTS (val), &i); - if (i) return -1; /* Indicate value not saved in history */ - } - - /* Here we treat value_history_count as origin-zero - and applying to the value being stored now. */ - - i = value_history_count % VALUE_HISTORY_CHUNK; - if (i == 0) - { - register struct value_history_chunk *new - = (struct value_history_chunk *) - xmalloc (sizeof (struct value_history_chunk)); - bzero (new->values, sizeof new->values); - new->next = value_history_chain; - value_history_chain = new; - } - - value_history_chain->values[i] = val; - release_value (val); - - /* Now we regard value_history_count as origin-one - and applying to the value just stored. */ - - return ++value_history_count; -} - -/* Return a copy of the value in the history with sequence number NUM. */ - -value -access_value_history (num) - int num; -{ - register struct value_history_chunk *chunk; - register int i; - register int absnum = num; - - if (absnum <= 0) - absnum += value_history_count; - - if (absnum <= 0) - { - if (num == 0) - error ("The history is empty."); - else if (num == 1) - error ("There is only one value in the history."); - else - error ("History does not go back to $$%d.", -num); - } - if (absnum > value_history_count) - error ("History has not yet reached $%d.", absnum); - - absnum--; - - /* Now absnum is always absolute and origin zero. */ - - chunk = value_history_chain; - for (i = (value_history_count - 1) / VALUE_HISTORY_CHUNK - absnum / VALUE_HISTORY_CHUNK; - i > 0; i--) - chunk = chunk->next; - - return value_copy (chunk->values[absnum % VALUE_HISTORY_CHUNK]); -} - -/* Clear the value history entirely. - Must be done when new symbol tables are loaded, - because the type pointers become invalid. */ - -void -clear_value_history () -{ - register struct value_history_chunk *next; - register int i; - register value val; - - while (value_history_chain) - { - for (i = 0; i < VALUE_HISTORY_CHUNK; i++) - if (val = value_history_chain->values[i]) - free (val); - next = value_history_chain->next; - free (value_history_chain); - value_history_chain = next; - } - value_history_count = 0; -} - -static void -show_values (num_exp, from_tty) - char *num_exp; - int from_tty; -{ - register int i; - register value val; - static int num = 1; - - if (num_exp) - { - if (num_exp[0] == '+' && num_exp[1] == '\0') - /* "info history +" should print from the stored position. */ - ; - else - /* "info history " should print around value number . */ - num = parse_and_eval_address (num_exp) - 5; - } - else - { - /* "info history" means print the last 10 values. */ - num = value_history_count - 9; - } - - if (num <= 0) - num = 1; - - for (i = num; i < num + 10 && i <= value_history_count; i++) - { - val = access_value_history (i); - printf_filtered ("$%d = ", i); - value_print (val, stdout, 0, Val_pretty_default); - printf_filtered ("\n"); - } - - /* The next "info history +" should start after what we just printed. */ - num += 10; - - /* Hitting just return after this command should do the same thing as - "info history +". If num_exp is null, this is unnecessary, since - "info history +" is not useful after "info history". */ - if (from_tty && num_exp) - { - num_exp[0] = '+'; - num_exp[1] = '\0'; - } -} - -/* Internal variables. These are variables within the debugger - that hold values assigned by debugger commands. - The user refers to them with a '$' prefix - that does not appear in the variable names stored internally. */ - -static struct internalvar *internalvars; - -/* Look up an internal variable with name NAME. NAME should not - normally include a dollar sign. - - If the specified internal variable does not exist, - one is created, with a void value. */ - -struct internalvar * -lookup_internalvar (name) - char *name; -{ - register struct internalvar *var; - - for (var = internalvars; var; var = var->next) - if (!strcmp (var->name, name)) - return var; - - var = (struct internalvar *) xmalloc (sizeof (struct internalvar)); - var->name = concat (name, NULL); - var->value = allocate_value (builtin_type_void); - release_value (var->value); - var->next = internalvars; - internalvars = var; - return var; -} - -value -value_of_internalvar (var) - struct internalvar *var; -{ - register value val; - -#ifdef IS_TRAPPED_INTERNALVAR - if (IS_TRAPPED_INTERNALVAR (var->name)) - return VALUE_OF_TRAPPED_INTERNALVAR (var); -#endif - - val = value_copy (var->value); - if (VALUE_LAZY (val)) - value_fetch_lazy (val); - VALUE_LVAL (val) = lval_internalvar; - VALUE_INTERNALVAR (val) = var; - return val; -} - -void -set_internalvar_component (var, offset, bitpos, bitsize, newval) - struct internalvar *var; - int offset, bitpos, bitsize; - value newval; -{ - register char *addr = VALUE_CONTENTS (var->value) + offset; - -#ifdef IS_TRAPPED_INTERNALVAR - if (IS_TRAPPED_INTERNALVAR (var->name)) - SET_TRAPPED_INTERNALVAR (var, newval, bitpos, bitsize, offset); -#endif - - if (bitsize) - modify_field (addr, (int) value_as_long (newval), - bitpos, bitsize); - else - bcopy (VALUE_CONTENTS (newval), addr, - TYPE_LENGTH (VALUE_TYPE (newval))); -} - -void -set_internalvar (var, val) - struct internalvar *var; - value val; -{ -#ifdef IS_TRAPPED_INTERNALVAR - if (IS_TRAPPED_INTERNALVAR (var->name)) - SET_TRAPPED_INTERNALVAR (var, val, 0, 0, 0); -#endif - - free (var->value); - var->value = value_copy (val); - release_value (var->value); -} - -char * -internalvar_name (var) - struct internalvar *var; -{ - return var->name; -} - -/* Free all internalvars. Done when new symtabs are loaded, - because that makes the values invalid. */ - -void -clear_internalvars () -{ - register struct internalvar *var; - - while (internalvars) - { - var = internalvars; - internalvars = var->next; - free (var->name); - free (var->value); - free (var); - } -} - -static void -show_convenience () -{ - register struct internalvar *var; - int varseen = 0; - - for (var = internalvars; var; var = var->next) - { -#ifdef IS_TRAPPED_INTERNALVAR - if (IS_TRAPPED_INTERNALVAR (var->name)) - continue; -#endif - if (!varseen) - { -#if 0 - /* Useless noise. */ - printf ("Debugger convenience variables:\n\n"); -#endif - varseen = 1; - } - printf_filtered ("$%s = ", var->name); - value_print (var->value, stdout, 0, Val_pretty_default); - printf_filtered ("\n"); - } - if (!varseen) - printf ("No debugger convenience variables now defined.\n\ -Convenience variables have names starting with \"$\";\n\ -use \"set\" as in \"set $foo = 5\" to define them.\n"); -} - -/* Extract a value as a C number (either long or double). - Knows how to convert fixed values to double, or - floating values to long. - Does not deallocate the value. */ - -LONGEST -value_as_long (val) - register value val; -{ - /* This coerces arrays and functions, which is necessary (e.g. - in disassemble_command). It also dereferences references, which - I suspect is the most logical thing to do. */ - if (TYPE_CODE (VALUE_TYPE (val)) != TYPE_CODE_ENUM) - COERCE_ARRAY (val); - return unpack_long (VALUE_TYPE (val), VALUE_CONTENTS (val)); -} - -double -value_as_double (val) - register value val; -{ - double foo; - int inv; - - foo = unpack_double (VALUE_TYPE (val), VALUE_CONTENTS (val), &inv); - if (inv) - error ("Invalid floating value found in program."); - return foo; -} -/* Extract a value as a C pointer. - Does not deallocate the value. */ -CORE_ADDR -value_as_pointer (val) - value val; -{ - /* Assume a CORE_ADDR can fit in a LONGEST (for now). Not sure - whether we want this to be true eventually. */ - return value_as_long (val); -} - -/* Unpack raw data (copied from debugee, target byte order) at VALADDR - as a long, or as a double, assuming the raw data is described - by type TYPE. Knows how to convert different sizes of values - and can convert between fixed and floating point. We don't assume - any alignment for the raw data. Return value is in host byte order. - - If you want functions and arrays to be coerced to pointers, and - references to be dereferenced, call value_as_long() instead. - - C++: It is assumed that the front-end has taken care of - all matters concerning pointers to members. A pointer - to member which reaches here is considered to be equivalent - to an INT (or some size). After all, it is only an offset. */ - -/* FIXME: This should be rewritten as a switch statement for speed and - ease of comprehension. */ - -LONGEST -unpack_long (type, valaddr) - struct type *type; - char *valaddr; -{ - register enum type_code code = TYPE_CODE (type); - register int len = TYPE_LENGTH (type); - register int nosign = TYPE_UNSIGNED (type); - - if (code == TYPE_CODE_ENUM || code == TYPE_CODE_BOOL) - code = TYPE_CODE_INT; - if (code == TYPE_CODE_FLT) - { - if (len == sizeof (float)) - { - float retval; - bcopy (valaddr, &retval, sizeof (retval)); - SWAP_TARGET_AND_HOST (&retval, sizeof (retval)); - return retval; - } - - if (len == sizeof (double)) - { - double retval; - bcopy (valaddr, &retval, sizeof (retval)); - SWAP_TARGET_AND_HOST (&retval, sizeof (retval)); - return retval; - } - else - { - error ("Unexpected type of floating point number."); - } - } - else if (code == TYPE_CODE_INT && nosign) - { - if (len == sizeof (char)) - { - unsigned char retval = * (unsigned char *) valaddr; - /* SWAP_TARGET_AND_HOST (&retval, sizeof (unsigned char)); */ - return retval; - } - - if (len == sizeof (short)) - { - unsigned short retval; - bcopy (valaddr, &retval, sizeof (retval)); - SWAP_TARGET_AND_HOST (&retval, sizeof (retval)); - return retval; - } - - if (len == sizeof (int)) - { - unsigned int retval; - bcopy (valaddr, &retval, sizeof (retval)); - SWAP_TARGET_AND_HOST (&retval, sizeof (retval)); - return retval; - } - - if (len == sizeof (long)) - { - unsigned long retval; - bcopy (valaddr, &retval, sizeof (retval)); - SWAP_TARGET_AND_HOST (&retval, sizeof (retval)); - return retval; - } -#ifdef LONG_LONG - if (len == sizeof (long long)) - { - unsigned long long retval; - bcopy (valaddr, &retval, sizeof (retval)); - SWAP_TARGET_AND_HOST (&retval, sizeof (retval)); - return retval; - } -#endif - else - { - error ("That operation is not possible on an integer of that size."); - } - } - else if (code == TYPE_CODE_INT) - { - if (len == sizeof (char)) - { - char retval; - bcopy (valaddr, &retval, sizeof (retval)); - SWAP_TARGET_AND_HOST (&retval, sizeof (retval)); - return retval; - } - - if (len == sizeof (short)) - { - short retval; - bcopy (valaddr, &retval, sizeof (retval)); - SWAP_TARGET_AND_HOST (&retval, sizeof (retval)); - return retval; - } - - if (len == sizeof (int)) - { - int retval; - bcopy (valaddr, &retval, sizeof (retval)); - SWAP_TARGET_AND_HOST (&retval, sizeof (retval)); - return retval; - } - - if (len == sizeof (long)) - { - long retval; - bcopy (valaddr, &retval, sizeof (retval)); - SWAP_TARGET_AND_HOST (&retval, sizeof (retval)); - return retval; - } - -#ifdef LONG_LONG - if (len == sizeof (long long)) - { - long long retval; - bcopy (valaddr, &retval, sizeof (retval)); - SWAP_TARGET_AND_HOST (&retval, sizeof (retval)); - return retval; - } -#endif - else - { - error ("That operation is not possible on an integer of that size."); - } - } - /* Assume a CORE_ADDR can fit in a LONGEST (for now). Not sure - whether we want this to be true eventually. */ - else if (code == TYPE_CODE_PTR - || code == TYPE_CODE_REF) - { - if (len == sizeof (CORE_ADDR)) - { - CORE_ADDR retval; - bcopy (valaddr, &retval, sizeof (retval)); - SWAP_TARGET_AND_HOST (&retval, sizeof (retval)); - return retval; - } - } - else if (code == TYPE_CODE_MEMBER) - error ("not implemented: member types in unpack_long"); - else if (code == TYPE_CODE_CHAR) - return *(unsigned char *)valaddr; - - error ("Value not integer or pointer."); - return 0; /* For lint -- never reached */ -} - -/* Return a double value from the specified type and address. - INVP points to an int which is set to 0 for valid value, - 1 for invalid value (bad float format). In either case, - the returned double is OK to use. Argument is in target - format, result is in host format. */ - -double -unpack_double (type, valaddr, invp) - struct type *type; - char *valaddr; - int *invp; -{ - register enum type_code code = TYPE_CODE (type); - register int len = TYPE_LENGTH (type); - register int nosign = TYPE_UNSIGNED (type); - - *invp = 0; /* Assume valid. */ - if (code == TYPE_CODE_FLT) - { - if (INVALID_FLOAT (valaddr, len)) - { - *invp = 1; - return 1.234567891011121314; - } - - if (len == sizeof (float)) - { - float retval; - bcopy (valaddr, &retval, sizeof (retval)); - SWAP_TARGET_AND_HOST (&retval, sizeof (retval)); - return retval; - } - - if (len == sizeof (double)) - { - double retval; - bcopy (valaddr, &retval, sizeof (retval)); - SWAP_TARGET_AND_HOST (&retval, sizeof (retval)); - return retval; - } - else - { - error ("Unexpected type of floating point number."); - return 0; /* Placate lint. */ - } - } - else if (nosign) { - /* Unsigned -- be sure we compensate for signed LONGEST. */ -#ifdef LONG_LONG - return (unsigned long long) unpack_long (type, valaddr); -#else - return (unsigned long ) unpack_long (type, valaddr); -#endif - } else { - /* Signed -- we are OK with unpack_long. */ - return unpack_long (type, valaddr); - } -} - -/* Unpack raw data (copied from debugee, target byte order) at VALADDR - as a CORE_ADDR, assuming the raw data is described by type TYPE. - We don't assume any alignment for the raw data. Return value is in - host byte order. - - If you want functions and arrays to be coerced to pointers, and - references to be dereferenced, call value_as_pointer() instead. - - C++: It is assumed that the front-end has taken care of - all matters concerning pointers to members. A pointer - to member which reaches here is considered to be equivalent - to an INT (or some size). After all, it is only an offset. */ - -CORE_ADDR -unpack_pointer (type, valaddr) - struct type *type; - char *valaddr; -{ -#if 0 - /* The user should be able to use an int (e.g. 0x7892) in contexts - where a pointer is expected. So this doesn't do enough. */ - register enum type_code code = TYPE_CODE (type); - register int len = TYPE_LENGTH (type); - - if (code == TYPE_CODE_PTR - || code == TYPE_CODE_REF) - { - if (len == sizeof (CORE_ADDR)) - { - CORE_ADDR retval; - bcopy (valaddr, &retval, sizeof (retval)); - SWAP_TARGET_AND_HOST (&retval, sizeof (retval)); - return retval; - } - error ("Unrecognized pointer size."); - } - else if (code == TYPE_CODE_MEMBER) - error ("not implemented: member types in unpack_pointer"); - - error ("Value is not a pointer."); - return 0; /* For lint -- never reached */ -#else - /* Assume a CORE_ADDR can fit in a LONGEST (for now). Not sure - whether we want this to be true eventually. */ - return unpack_long (type, valaddr); -#endif -} - -/* Given a value ARG1 (offset by OFFSET bytes) - of a struct or union type ARG_TYPE, - extract and return the value of one of its fields. - FIELDNO says which field. - - For C++, must also be able to return values from static fields */ - -value -value_primitive_field (arg1, offset, fieldno, arg_type) - register value arg1; - int offset; - register int fieldno; - register struct type *arg_type; -{ - register value v; - register struct type *type; - - check_stub_type (arg_type); - type = TYPE_FIELD_TYPE (arg_type, fieldno); - - /* Handle packed fields */ - - offset += TYPE_FIELD_BITPOS (arg_type, fieldno) / 8; - if (TYPE_FIELD_BITSIZE (arg_type, fieldno)) - { - v = value_from_longest (type, - unpack_field_as_long (arg_type, - VALUE_CONTENTS (arg1), - fieldno)); - VALUE_BITPOS (v) = TYPE_FIELD_BITPOS (arg_type, fieldno) % 8; - VALUE_BITSIZE (v) = TYPE_FIELD_BITSIZE (arg_type, fieldno); - } - else - { - v = allocate_value (type); - if (VALUE_LAZY (arg1)) - VALUE_LAZY (v) = 1; - else - bcopy (VALUE_CONTENTS_RAW (arg1) + offset, - VALUE_CONTENTS_RAW (v), - TYPE_LENGTH (type)); - } - VALUE_LVAL (v) = VALUE_LVAL (arg1); - if (VALUE_LVAL (arg1) == lval_internalvar) - VALUE_LVAL (v) = lval_internalvar_component; - VALUE_ADDRESS (v) = VALUE_ADDRESS (arg1); - VALUE_OFFSET (v) = offset + VALUE_OFFSET (arg1); - return v; -} - -/* Given a value ARG1 of a struct or union type, - extract and return the value of one of its fields. - FIELDNO says which field. - - For C++, must also be able to return values from static fields */ - -value -value_field (arg1, fieldno) - register value arg1; - register int fieldno; -{ - return value_primitive_field (arg1, 0, fieldno, VALUE_TYPE (arg1)); -} - -/* Return a non-virtual function as a value. - F is the list of member functions which contains the desired method. - J is an index into F which provides the desired method. */ - -value -value_fn_field (f, j) - struct fn_field *f; - int j; -{ - register value v; - register struct type *type = TYPE_FN_FIELD_TYPE (f, j); - struct symbol *sym; - - sym = lookup_symbol (TYPE_FN_FIELD_PHYSNAME (f, j), - 0, VAR_NAMESPACE, 0, NULL); - if (! sym) error ("Internal error: could not find physical method named %s", - TYPE_FN_FIELD_PHYSNAME (f, j)); - - v = allocate_value (type); - VALUE_ADDRESS (v) = BLOCK_START (SYMBOL_BLOCK_VALUE (sym)); - VALUE_TYPE (v) = type; - return v; -} - -/* Return a virtual function as a value. - ARG1 is the object which provides the virtual function - table pointer. ARG1 is side-effected in calling this function. - F is the list of member functions which contains the desired virtual - function. - J is an index into F which provides the desired virtual function. - - TYPE is the type in which F is located. */ -value -value_virtual_fn_field (arg1, f, j, type) - value arg1; - struct fn_field *f; - int j; - struct type *type; -{ - /* First, get the virtual function table pointer. That comes - with a strange type, so cast it to type `pointer to long' (which - should serve just fine as a function type). Then, index into - the table, and convert final value to appropriate function type. */ - value entry, vfn, vtbl; - value vi = value_from_longest (builtin_type_int, - (LONGEST) TYPE_FN_FIELD_VOFFSET (f, j)); - struct type *fcontext = TYPE_FN_FIELD_FCONTEXT (f, j); - struct type *context; - if (fcontext == NULL) - /* We don't have an fcontext (e.g. the program was compiled with - g++ version 1). Try to get the vtbl from the TYPE_VPTR_BASETYPE. - This won't work right for multiple inheritance, but at least we - should do as well as GDB 3.x did. */ - fcontext = TYPE_VPTR_BASETYPE (type); - context = lookup_pointer_type (fcontext); - /* Now context is a pointer to the basetype containing the vtbl. */ - if (TYPE_TARGET_TYPE (context) != VALUE_TYPE (arg1)) - arg1 = value_ind (value_cast (context, value_addr (arg1))); - - context = VALUE_TYPE (arg1); - /* Now context is the basetype containing the vtbl. */ - - /* This type may have been defined before its virtual function table - was. If so, fill in the virtual function table entry for the - type now. */ - if (TYPE_VPTR_FIELDNO (context) < 0) - fill_in_vptr_fieldno (context); - - /* The virtual function table is now an array of structures - which have the form { int16 offset, delta; void *pfn; }. */ - vtbl = value_ind (value_field (arg1, TYPE_VPTR_FIELDNO (context))); - - /* Index into the virtual function table. This is hard-coded because - looking up a field is not cheap, and it may be important to save - time, e.g. if the user has set a conditional breakpoint calling - a virtual function. */ - entry = value_subscript (vtbl, vi); - - /* Move the `this' pointer according to the virtual function table. */ - VALUE_OFFSET (arg1) += value_as_long (value_field (entry, 0)); - if (! VALUE_LAZY (arg1)) - { - VALUE_LAZY (arg1) = 1; - value_fetch_lazy (arg1); - } - - vfn = value_field (entry, 2); - /* Reinstantiate the function pointer with the correct type. */ - VALUE_TYPE (vfn) = lookup_pointer_type (TYPE_FN_FIELD_TYPE (f, j)); - - return vfn; -} - -/* ARG is a pointer to an object we know to be at least - a DTYPE. BTYPE is the most derived basetype that has - already been searched (and need not be searched again). - After looking at the vtables between BTYPE and DTYPE, - return the most derived type we find. The caller must - be satisfied when the return value == DTYPE. - - FIXME-tiemann: should work with dossier entries as well. */ - -static value -value_headof (arg, btype, dtype) - value arg; - struct type *btype, *dtype; -{ - /* First collect the vtables we must look at for this object. */ - /* FIXME-tiemann: right now, just look at top-most vtable. */ - value vtbl, entry, best_entry = 0; - /* FIXME: entry_type is never used. */ - struct type *entry_type; - int i, nelems; - int offset, best_offset = 0; - struct symbol *sym; - CORE_ADDR pc_for_sym; - char *demangled_name; - btype = TYPE_VPTR_BASETYPE (dtype); - check_stub_type (btype); - if (btype != dtype) - vtbl = value_cast (lookup_pointer_type (btype), arg); - else - vtbl = arg; - vtbl = value_ind (value_field (value_ind (vtbl), TYPE_VPTR_FIELDNO (btype))); - - /* Check that VTBL looks like it points to a virtual function table. */ - i = find_pc_misc_function (VALUE_ADDRESS (vtbl)); - if (i < 0 || ! VTBL_PREFIX_P (demangled_name = misc_function_vector[i].name)) - { - /* If we expected to find a vtable, but did not, let the user - know that we aren't happy, but don't throw an error. - FIXME: there has to be a better way to do this. */ - struct type *error_type = (struct type *)xmalloc (sizeof (struct type)); - bcopy (VALUE_TYPE (arg), error_type, sizeof (struct type)); - TYPE_NAME (error_type) = savestring ("suspicious *", sizeof ("suspicious *")); - VALUE_TYPE (arg) = error_type; - return arg; - } - - /* Now search through the virtual function table. */ - entry = value_ind (vtbl); - nelems = longest_to_int (value_as_long (value_field (entry, 2))); - for (i = 1; i <= nelems; i++) - { - entry = value_subscript (vtbl, value_from_longest (builtin_type_int, - (LONGEST) i)); - offset = longest_to_int (value_as_long (value_field (entry, 0))); - /* If we use '<=' we can handle single inheritance - * where all offsets are zero - just use the first entry found. */ - if (offset <= best_offset) - { - best_offset = offset; - best_entry = entry; - } - } - /* Move the pointer according to BEST_ENTRY's offset, and figure - out what type we should return as the new pointer. */ - if (best_entry == 0) - { - /* An alternative method (which should no longer be necessary). - * But we leave it in for future use, when we will hopefully - * have optimizes the vtable to use thunks instead of offsets. */ - /* Use the name of vtable itself to extract a base type. */ - demangled_name += 4; /* Skip _vt$ prefix. */ - } - else - { - pc_for_sym = value_as_pointer (value_field (best_entry, 2)); - sym = find_pc_function (pc_for_sym); - demangled_name = cplus_demangle (SYMBOL_NAME (sym), -1); - *(strchr (demangled_name, ':')) = '\0'; - } - sym = lookup_symbol (demangled_name, 0, VAR_NAMESPACE, 0, 0); - if (sym == 0) - error ("could not find type declaration for `%s'", SYMBOL_NAME (sym)); - if (best_entry) - { - free (demangled_name); - arg = value_add (value_cast (builtin_type_int, arg), - value_field (best_entry, 0)); - } - VALUE_TYPE (arg) = lookup_pointer_type (SYMBOL_TYPE (sym)); - return arg; -} - -/* ARG is a pointer object of type TYPE. If TYPE has virtual - function tables, probe ARG's tables (including the vtables - of its baseclasses) to figure out the most derived type that ARG - could actually be a pointer to. */ - -value -value_from_vtable_info (arg, type) - value arg; - struct type *type; -{ - /* Take care of preliminaries. */ - if (TYPE_VPTR_FIELDNO (type) < 0) - fill_in_vptr_fieldno (type); - if (TYPE_VPTR_FIELDNO (type) < 0 || VALUE_REPEATED (arg)) - return 0; - - return value_headof (arg, 0, type); -} - -/* The value of a static class member does not depend - on its instance, only on its type. If FIELDNO >= 0, - then fieldno is a valid field number and is used directly. - Otherwise, FIELDNAME is the name of the field we are - searching for. If it is not a static field name, an - error is signaled. TYPE is the type in which we look for the - static field member. - - Return zero if we couldn't find anything; the caller may signal - an error in that case. */ - -value -value_static_field (type, fieldname, fieldno) - register struct type *type; - char *fieldname; - register int fieldno; -{ - register value v; - struct symbol *sym; - char *phys_name; - - if (fieldno < 0) - { - /* Look for static field. */ - int i; - for (i = TYPE_NFIELDS (type) - 1; i >= TYPE_N_BASECLASSES (type); i--) - if (! strcmp (TYPE_FIELD_NAME (type, i), fieldname)) - { - if (TYPE_FIELD_STATIC (type, i)) - { - fieldno = i; - goto found; - } - else - error ("field `%s' is not static", fieldname); - } - for (; i > 0; i--) - { - v = value_static_field (TYPE_BASECLASS (type, i), fieldname, -1); - if (v != 0) - return v; - } - - if (destructor_name_p (fieldname, type)) - error ("Cannot get value of destructor"); - - for (i = TYPE_NFN_FIELDS (type) - 1; i >= 0; i--) - { - if (! strcmp (TYPE_FN_FIELDLIST_NAME (type, i), fieldname)) - error ("Cannot get value of method \"%s\"", fieldname); - } - error("there is no field named %s", fieldname); - } - - found: - phys_name = TYPE_FIELD_STATIC_PHYSNAME (type, fieldno); - sym = lookup_symbol (phys_name, 0, VAR_NAMESPACE, 0, NULL); - if (! sym) error ("Internal error: could not find physical static variable named %s", phys_name); - - type = TYPE_FIELD_TYPE (type, fieldno); - v = value_at (type, (CORE_ADDR)SYMBOL_BLOCK_VALUE (sym)); - return v; -} - -/* Compute the address of the baseclass which is - the INDEXth baseclass of TYPE. The TYPE base - of the object is at VALADDR. - - If ERRP is non-NULL, set *ERRP to be the errno code of any error, - or 0 if no error. In that case the return value is not the address - of the baseclasss, but the address which could not be read - successfully. */ - -char * -baseclass_addr (type, index, valaddr, valuep, errp) - struct type *type; - int index; - char *valaddr; - value *valuep; - int *errp; -{ - struct type *basetype = TYPE_BASECLASS (type, index); - - if (errp) - *errp = 0; - - if (BASETYPE_VIA_VIRTUAL (type, index)) - { - /* Must hunt for the pointer to this virtual baseclass. */ - register int i, len = TYPE_NFIELDS (type); - register int n_baseclasses = TYPE_N_BASECLASSES (type); - char *vbase_name, *type_name = type_name_no_tag (basetype); - - if (TYPE_MAIN_VARIANT (basetype)) - basetype = TYPE_MAIN_VARIANT (basetype); - - vbase_name = (char *)alloca (strlen (type_name) + 8); - sprintf (vbase_name, "_vb$%s", type_name); - /* First look for the virtual baseclass pointer - in the fields. */ - for (i = n_baseclasses; i < len; i++) - { - if (! strcmp (vbase_name, TYPE_FIELD_NAME (type, i))) - { - value val = allocate_value (basetype); - CORE_ADDR addr; - int status; - - addr - = unpack_pointer (TYPE_FIELD_TYPE (type, i), - valaddr + (TYPE_FIELD_BITPOS (type, i) / 8)); - - status = target_read_memory (addr, - VALUE_CONTENTS_RAW (val), - TYPE_LENGTH (basetype)); - VALUE_LVAL (val) = lval_memory; - VALUE_ADDRESS (val) = addr; - - if (status != 0) - { - if (valuep) - *valuep = NULL; - release_value (val); - value_free (val); - if (errp) - *errp = status; - return (char *)addr; - } - else - { - if (valuep) - *valuep = val; - return (char *) VALUE_CONTENTS (val); - } - } - } - /* Not in the fields, so try looking through the baseclasses. */ - for (i = index+1; i < n_baseclasses; i++) - { - char *baddr; - - baddr = baseclass_addr (type, i, valaddr, valuep, errp); - if (baddr) - return baddr; - } - /* Not found. */ - if (valuep) - *valuep = 0; - return 0; - } - - /* Baseclass is easily computed. */ - if (valuep) - *valuep = 0; - return valaddr + TYPE_BASECLASS_BITPOS (type, index) / 8; -} - -/* Ugly hack to convert method stubs into method types. - - He ain't kiddin'. This demangles the name of the method into a string - including argument types, parses out each argument type, generates - a string casting a zero to that type, evaluates the string, and stuffs - the resulting type into an argtype vector!!! Then it knows the type - of the whole function (including argument types for overloading), - which info used to be in the stab's but was removed to hack back - the space required for them. */ -void -check_stub_method (type, i, j) - struct type *type; - int i, j; -{ - extern char *gdb_mangle_name (), *strchr (); - struct fn_field *f = TYPE_FN_FIELDLIST1 (type, i); - char *mangled_name = gdb_mangle_name (type, i, j); - char *demangled_name = cplus_demangle (mangled_name, 0); - char *argtypetext, *p; - int depth = 0, argcount = 1; - struct type **argtypes; - - /* Now, read in the parameters that define this type. */ - argtypetext = strchr (demangled_name, '(') + 1; - p = argtypetext; - while (*p) - { - if (*p == '(') - depth += 1; - else if (*p == ')') - depth -= 1; - else if (*p == ',' && depth == 0) - argcount += 1; - - p += 1; - } - /* We need one more slot for the void [...] or NULL [end of arglist] */ - argtypes = (struct type **)xmalloc ((argcount+1) * sizeof (struct type *)); - p = argtypetext; - argtypes[0] = lookup_pointer_type (type); - argcount = 1; - - if (*p != ')') /* () means no args, skip while */ - { - depth = 0; - while (*p) - { - if (depth <= 0 && (*p == ',' || *p == ')')) - { - argtypes[argcount] = - parse_and_eval_type (argtypetext, p - argtypetext); - argcount += 1; - argtypetext = p + 1; - } - - if (*p == '(') - depth += 1; - else if (*p == ')') - depth -= 1; - - p += 1; - } - } - - if (p[-2] != '.') /* ... */ - argtypes[argcount] = builtin_type_void; /* Ellist terminator */ - else - argtypes[argcount] = NULL; /* List terminator */ - - free (demangled_name); - - type = lookup_method_type (type, TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j)), argtypes); - /* Free the stub type...it's no longer needed. */ - free (TYPE_FN_FIELD_TYPE (f, j)); - TYPE_FN_FIELD_PHYSNAME (f, j) = mangled_name; - TYPE_FN_FIELD_TYPE (f, j) = type; -} - -long -unpack_field_as_long (type, valaddr, fieldno) - struct type *type; - char *valaddr; - int fieldno; -{ - long val; - int bitpos = TYPE_FIELD_BITPOS (type, fieldno); - int bitsize = TYPE_FIELD_BITSIZE (type, fieldno); - - bcopy (valaddr + bitpos / 8, &val, sizeof val); - SWAP_TARGET_AND_HOST (&val, sizeof val); - - /* Extracting bits depends on endianness of the machine. */ -#if BITS_BIG_ENDIAN - val = val >> (sizeof val * 8 - bitpos % 8 - bitsize); -#else - val = val >> (bitpos % 8); -#endif - - if (bitsize < 8 * sizeof (val)) - val &= (((unsigned long)1) << bitsize) - 1; - return val; -} - -/* Modify the value of a bitfield. ADDR points to a block of memory in - target byte order; the bitfield starts in the byte pointed to. FIELDVAL - is the desired value of the field, in host byte order. BITPOS and BITSIZE - indicate which bits (in target bit order) comprise the bitfield. */ - -void -modify_field (addr, fieldval, bitpos, bitsize) - char *addr; - int fieldval; - int bitpos, bitsize; -{ - long oword; - - /* Reject values too big to fit in the field in question, - otherwise adjoining fields may be corrupted. */ - if (bitsize < (8 * sizeof (fieldval)) - && 0 != (fieldval & ~((1<= longword size */ - if (bitsize < 8 * sizeof (oword)) - oword &= ~(((((unsigned long)1) << bitsize) - 1) << bitpos); - else - oword &= ~((-1) << bitpos); - oword |= fieldval << bitpos; - - SWAP_TARGET_AND_HOST (&oword, sizeof oword); /* To target format */ - bcopy (&oword, addr, sizeof oword); -} - -/* Convert C numbers into newly allocated values */ - -value -value_from_longest (type, num) - struct type *type; - register LONGEST num; -{ - register value val = allocate_value (type); - register enum type_code code = TYPE_CODE (type); - register int len = TYPE_LENGTH (type); - - /* FIXME, we assume that pointers have the same form and byte order as - integers, and that all pointers have the same form. */ - if (code == TYPE_CODE_INT || code == TYPE_CODE_ENUM || - code == TYPE_CODE_CHAR || code == TYPE_CODE_PTR) - { - if (len == sizeof (char)) - * (char *) VALUE_CONTENTS_RAW (val) = num; - else if (len == sizeof (short)) - * (short *) VALUE_CONTENTS_RAW (val) = num; - else if (len == sizeof (int)) - * (int *) VALUE_CONTENTS_RAW (val) = num; - else if (len == sizeof (long)) - * (long *) VALUE_CONTENTS_RAW (val) = num; -#ifdef LONG_LONG - else if (len == sizeof (long long)) - * (long long *) VALUE_CONTENTS_RAW (val) = num; -#endif - else - error ("Integer type encountered with unexpected data length."); - } - else - error ("Unexpected type encountered for integer constant."); - - /* num was in host byte order. So now put the value's contents - into target byte order. */ - SWAP_TARGET_AND_HOST (VALUE_CONTENTS_RAW (val), len); - - return val; -} - -value -value_from_double (type, num) - struct type *type; - double num; -{ - register value val = allocate_value (type); - register enum type_code code = TYPE_CODE (type); - register int len = TYPE_LENGTH (type); - - if (code == TYPE_CODE_FLT) - { - if (len == sizeof (float)) - * (float *) VALUE_CONTENTS_RAW (val) = num; - else if (len == sizeof (double)) - * (double *) VALUE_CONTENTS_RAW (val) = num; - else - error ("Floating type encountered with unexpected data length."); - } - else - error ("Unexpected type encountered for floating constant."); - - /* num was in host byte order. So now put the value's contents - into target byte order. */ - SWAP_TARGET_AND_HOST (VALUE_CONTENTS_RAW (val), len); - - return val; -} - -/* Deal with the value that is "about to be returned". */ - -/* Return the value that a function returning now - would be returning to its caller, assuming its type is VALTYPE. - RETBUF is where we look for what ought to be the contents - of the registers (in raw form). This is because it is often - desirable to restore old values to those registers - after saving the contents of interest, and then call - this function using the saved values. - struct_return is non-zero when the function in question is - using the structure return conventions on the machine in question; - 0 when it is using the value returning conventions (this often - means returning pointer to where structure is vs. returning value). */ - -value -value_being_returned (valtype, retbuf, struct_return) - register struct type *valtype; - char retbuf[REGISTER_BYTES]; - int struct_return; - /*ARGSUSED*/ -{ - register value val; - CORE_ADDR addr; - -#if defined (EXTRACT_STRUCT_VALUE_ADDRESS) - /* If this is not defined, just use EXTRACT_RETURN_VALUE instead. */ - if (struct_return) { - addr = EXTRACT_STRUCT_VALUE_ADDRESS (retbuf); - if (!addr) - error ("Function return value unknown"); - return value_at (valtype, addr); - } -#endif - - val = allocate_value (valtype); - EXTRACT_RETURN_VALUE (valtype, retbuf, VALUE_CONTENTS_RAW (val)); - - return val; -} - -/* Should we use EXTRACT_STRUCT_VALUE_ADDRESS instead of - EXTRACT_RETURN_VALUE? GCC_P is true if compiled with gcc - and TYPE is the type (which is known to be struct, union or array). - - On most machines, the struct convention is used unless we are - using gcc and the type is of a special size. */ -#if !defined (USE_STRUCT_CONVENTION) -#define USE_STRUCT_CONVENTION(gcc_p, type)\ - (!((gcc_p) && (TYPE_LENGTH (value_type) == 1 \ - || TYPE_LENGTH (value_type) == 2 \ - || TYPE_LENGTH (value_type) == 4 \ - || TYPE_LENGTH (value_type) == 8 \ - ) \ - )) -#endif - -/* Return true if the function specified is using the structure returning - convention on this machine to return arguments, or 0 if it is using - the value returning convention. FUNCTION is the value representing - the function, FUNCADDR is the address of the function, and VALUE_TYPE - is the type returned by the function. GCC_P is nonzero if compiled - with GCC. */ - -int -using_struct_return (function, funcaddr, value_type, gcc_p) - value function; - CORE_ADDR funcaddr; - struct type *value_type; - int gcc_p; - /*ARGSUSED*/ -{ - register enum type_code code = TYPE_CODE (value_type); - - if (code == TYPE_CODE_ERROR) - error ("Function return type unknown."); - - if (code == TYPE_CODE_STRUCT || - code == TYPE_CODE_UNION || - code == TYPE_CODE_ARRAY) - return USE_STRUCT_CONVENTION (gcc_p, value_type); - - return 0; -} - -/* Store VAL so it will be returned if a function returns now. - Does not verify that VAL's type matches what the current - function wants to return. */ - -void -set_return_value (val) - value val; -{ - register enum type_code code = TYPE_CODE (VALUE_TYPE (val)); - double dbuf; - LONGEST lbuf; - - if (code == TYPE_CODE_ERROR) - error ("Function return type unknown."); - - if (code == TYPE_CODE_STRUCT - || code == TYPE_CODE_UNION) - error ("Specifying a struct or union return value is not supported."); - - /* FIXME, this is bogus. We don't know what the return conventions - are, or how values should be promoted.... */ - if (code == TYPE_CODE_FLT) - { - dbuf = value_as_double (val); - - STORE_RETURN_VALUE (VALUE_TYPE (val), (char *)&dbuf); - } - else - { - lbuf = value_as_long (val); - STORE_RETURN_VALUE (VALUE_TYPE (val), (char *)&lbuf); - } -} - -void -_initialize_values () -{ - add_cmd ("convenience", no_class, show_convenience, - "Debugger convenience (\"$foo\") variables.\n\ -These variables are created when you assign them values;\n\ -thus, \"print $foo=1\" gives \"$foo\" the value 1. Values may be any type.\n\n\ -A few convenience variables are given values automatically:\n\ -\"$_\"holds the last address examined with \"x\" or \"info lines\",\n\ -\"$__\" holds the contents of the last address examined with \"x\".", - &showlist); - - add_cmd ("values", no_class, show_values, - "Elements of value history around item number IDX (or last ten).", - &showlist); -} diff --git a/gdb/vax-opcode.h b/gdb/vax-opcode.h deleted file mode 100755 index 594e6352b95..00000000000 --- a/gdb/vax-opcode.h +++ /dev/null @@ -1,382 +0,0 @@ -/* Vax opcde list. - Copyright (C) 1989, Free Software Foundation, Inc. - -This file is part of GDB and GAS. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifndef vax_opcodeT -#define vax_opcodeT int -#endif /* no vax_opcodeT */ - -struct vot_wot /* vax opcode table: wot to do with this */ - /* particular opcode */ -{ - char * args; /* how to compile said opcode */ - vax_opcodeT code; /* op-code (may be > 8 bits!) */ -}; - -struct vot /* vax opcode text */ -{ - char * name; /* opcode name: lowercase string [key] */ - struct vot_wot detail; /* rest of opcode table [datum] */ -}; - -#define vot_how args -#define vot_code code -#define vot_detail detail -#define vot_name name - -const static struct vot -votstrs[] = -{ -{ "halt", {"", 0x00 } }, -{ "nop", {"", 0x01 } }, -{ "rei", {"", 0x02 } }, -{ "bpt", {"", 0x03 } }, -{ "ret", {"", 0x04 } }, -{ "rsb", {"", 0x05 } }, -{ "ldpctx", {"", 0x06 } }, -{ "svpctx", {"", 0x07 } }, -{ "cvtps", {"rwabrwab", 0x08 } }, -{ "cvtsp", {"rwabrwab", 0x09 } }, -{ "index", {"rlrlrlrlrlwl", 0x0a } }, -{ "crc", {"abrlrwab", 0x0b } }, -{ "prober", {"rbrwab", 0x0c } }, -{ "probew", {"rbrwab", 0x0d } }, -{ "insque", {"abab", 0x0e } }, -{ "remque", {"abwl", 0x0f } }, -{ "bsbb", {"bb", 0x10 } }, -{ "brb", {"bb", 0x11 } }, -{ "bneq", {"bb", 0x12 } }, -{ "bnequ", {"bb", 0x12 } }, -{ "beql", {"bb", 0x13 } }, -{ "beqlu", {"bb", 0x13 } }, -{ "bgtr", {"bb", 0x14 } }, -{ "bleq", {"bb", 0x15 } }, -{ "jsb", {"ab", 0x16 } }, -{ "jmp", {"ab", 0x17 } }, -{ "bgeq", {"bb", 0x18 } }, -{ "blss", {"bb", 0x19 } }, -{ "bgtru", {"bb", 0x1a } }, -{ "blequ", {"bb", 0x1b } }, -{ "bvc", {"bb", 0x1c } }, -{ "bvs", {"bb", 0x1d } }, -{ "bcc", {"bb", 0x1e } }, -{ "bgequ", {"bb", 0x1e } }, -{ "blssu", {"bb", 0x1f } }, -{ "bcs", {"bb", 0x1f } }, -{ "addp4", {"rwabrwab", 0x20 } }, -{ "addp6", {"rwabrwabrwab", 0x21 } }, -{ "subp4", {"rwabrwab", 0x22 } }, -{ "subp6", {"rwabrwabrwab", 0x23 } }, -{ "cvtpt", {"rwababrwab", 0x24 } }, -{ "mulp", {"rwabrwabrwab", 0x25 } }, -{ "cvttp", {"rwababrwab", 0x26 } }, -{ "divp", {"rwabrwabrwab", 0x27 } }, -{ "movc3", {"rwabab", 0x28 } }, -{ "cmpc3", {"rwabab", 0x29 } }, -{ "scanc", {"rwababrb", 0x2a } }, -{ "spanc", {"rwababrb", 0x2b } }, -{ "movc5", {"rwabrbrwab", 0x2c } }, -{ "cmpc5", {"rwabrbrwab", 0x2d } }, -{ "movtc", {"rwabrbabrwab", 0x2e } }, -{ "movtuc", {"rwabrbabrwab", 0x2f } }, -{ "bsbw", {"bw", 0x30 } }, -{ "brw", {"bw", 0x31 } }, -{ "cvtwl", {"rwwl", 0x32 } }, -{ "cvtwb", {"rwwb", 0x33 } }, -{ "movp", {"rwabab", 0x34 } }, -{ "cmpp3", {"rwabab", 0x35 } }, -{ "cvtpl", {"rwabwl", 0x36 } }, -{ "cmpp4", {"rwabrwab", 0x37 } }, -{ "editpc", {"rwababab", 0x38 } }, -{ "matchc", {"rwabrwab", 0x39 } }, -{ "locc", {"rbrwab", 0x3a } }, -{ "skpc", {"rbrwab", 0x3b } }, -{ "movzwl", {"rwwl", 0x3c } }, -{ "acbw", {"rwrwmwbw", 0x3d } }, -{ "movaw", {"awwl", 0x3e } }, -{ "pushaw", {"aw", 0x3f } }, -{ "addf2", {"rfmf", 0x40 } }, -{ "addf3", {"rfrfwf", 0x41 } }, -{ "subf2", {"rfmf", 0x42 } }, -{ "subf3", {"rfrfwf", 0x43 } }, -{ "mulf2", {"rfmf", 0x44 } }, -{ "mulf3", {"rfrfwf", 0x45 } }, -{ "divf2", {"rfmf", 0x46 } }, -{ "divf3", {"rfrfwf", 0x47 } }, -{ "cvtfb", {"rfwb", 0x48 } }, -{ "cvtfw", {"rfww", 0x49 } }, -{ "cvtfl", {"rfwl", 0x4a } }, -{ "cvtrfl", {"rfwl", 0x4b } }, -{ "cvtbf", {"rbwf", 0x4c } }, -{ "cvtwf", {"rwwf", 0x4d } }, -{ "cvtlf", {"rlwf", 0x4e } }, -{ "acbf", {"rfrfmfbw", 0x4f } }, -{ "movf", {"rfwf", 0x50 } }, -{ "cmpf", {"rfrf", 0x51 } }, -{ "mnegf", {"rfwf", 0x52 } }, -{ "tstf", {"rf", 0x53 } }, -{ "emodf", {"rfrbrfwlwf", 0x54 } }, -{ "polyf", {"rfrwab", 0x55 } }, -{ "cvtfd", {"rfwd", 0x56 } }, - /* opcode 57 is not defined yet */ -{ "adawi", {"rwmw", 0x58 } }, - /* opcode 59 is not defined yet */ - /* opcode 5a is not defined yet */ - /* opcode 5b is not defined yet */ -{ "insqhi", {"abaq", 0x5c } }, -{ "insqti", {"abaq", 0x5d } }, -{ "remqhi", {"aqwl", 0x5e } }, -{ "remqti", {"aqwl", 0x5f } }, -{ "addd2", {"rdmd", 0x60 } }, -{ "addd3", {"rdrdwd", 0x61 } }, -{ "subd2", {"rdmd", 0x62 } }, -{ "subd3", {"rdrdwd", 0x63 } }, -{ "muld2", {"rdmd", 0x64 } }, -{ "muld3", {"rdrdwd", 0x65 } }, -{ "divd2", {"rdmd", 0x66 } }, -{ "divd3", {"rdrdwd", 0x67 } }, -{ "cvtdb", {"rdwb", 0x68 } }, -{ "cvtdw", {"rdww", 0x69 } }, -{ "cvtdl", {"rdwl", 0x6a } }, -{ "cvtrdl", {"rdwl", 0x6b } }, -{ "cvtbd", {"rbwd", 0x6c } }, -{ "cvtwd", {"rwwd", 0x6d } }, -{ "cvtld", {"rlwd", 0x6e } }, -{ "acbd", {"rdrdmdbw", 0x6f } }, -{ "movd", {"rdwd", 0x70 } }, -{ "cmpd", {"rdrd", 0x71 } }, -{ "mnegd", {"rdwd", 0x72 } }, -{ "tstd", {"rd", 0x73 } }, -{ "emodd", {"rdrbrdwlwd", 0x74 } }, -{ "polyd", {"rdrwab", 0x75 } }, -{ "cvtdf", {"rdwf", 0x76 } }, - /* opcode 77 is not defined yet */ -{ "ashl", {"rbrlwl", 0x78 } }, -{ "ashq", {"rbrqwq", 0x79 } }, -{ "emul", {"rlrlrlwq", 0x7a } }, -{ "ediv", {"rlrqwlwl", 0x7b } }, -{ "clrd", {"wd", 0x7c } }, -{ "clrg", {"wg", 0x7c } }, -{ "clrq", {"wd", 0x7c } }, -{ "movq", {"rqwq", 0x7d } }, -{ "movaq", {"aqwl", 0x7e } }, -{ "movad", {"adwl", 0x7e } }, -{ "pushaq", {"aq", 0x7f } }, -{ "pushad", {"ad", 0x7f } }, -{ "addb2", {"rbmb", 0x80 } }, -{ "addb3", {"rbrbwb", 0x81 } }, -{ "subb2", {"rbmb", 0x82 } }, -{ "subb3", {"rbrbwb", 0x83 } }, -{ "mulb2", {"rbmb", 0x84 } }, -{ "mulb3", {"rbrbwb", 0x85 } }, -{ "divb2", {"rbmb", 0x86 } }, -{ "divb3", {"rbrbwb", 0x87 } }, -{ "bisb2", {"rbmb", 0x88 } }, -{ "bisb3", {"rbrbwb", 0x89 } }, -{ "bicb2", {"rbmb", 0x8a } }, -{ "bicb3", {"rbrbwb", 0x8b } }, -{ "xorb2", {"rbmb", 0x8c } }, -{ "xorb3", {"rbrbwb", 0x8d } }, -{ "mnegb", {"rbwb", 0x8e } }, -{ "caseb", {"rbrbrb", 0x8f } }, -{ "movb", {"rbwb", 0x90 } }, -{ "cmpb", {"rbrb", 0x91 } }, -{ "mcomb", {"rbwb", 0x92 } }, -{ "bitb", {"rbrb", 0x93 } }, -{ "clrb", {"wb", 0x94 } }, -{ "tstb", {"rb", 0x95 } }, -{ "incb", {"mb", 0x96 } }, -{ "decb", {"mb", 0x97 } }, -{ "cvtbl", {"rbwl", 0x98 } }, -{ "cvtbw", {"rbww", 0x99 } }, -{ "movzbl", {"rbwl", 0x9a } }, -{ "movzbw", {"rbww", 0x9b } }, -{ "rotl", {"rbrlwl", 0x9c } }, -{ "acbb", {"rbrbmbbw", 0x9d } }, -{ "movab", {"abwl", 0x9e } }, -{ "pushab", {"ab", 0x9f } }, -{ "addw2", {"rwmw", 0xa0 } }, -{ "addw3", {"rwrwww", 0xa1 } }, -{ "subw2", {"rwmw", 0xa2 } }, -{ "subw3", {"rwrwww", 0xa3 } }, -{ "mulw2", {"rwmw", 0xa4 } }, -{ "mulw3", {"rwrwww", 0xa5 } }, -{ "divw2", {"rwmw", 0xa6 } }, -{ "divw3", {"rwrwww", 0xa7 } }, -{ "bisw2", {"rwmw", 0xa8 } }, -{ "bisw3", {"rwrwww", 0xa9 } }, -{ "bicw2", {"rwmw", 0xaa } }, -{ "bicw3", {"rwrwww", 0xab } }, -{ "xorw2", {"rwmw", 0xac } }, -{ "xorw3", {"rwrwww", 0xad } }, -{ "mnegw", {"rwww", 0xae } }, -{ "casew", {"rwrwrw", 0xaf } }, -{ "movw", {"rwww", 0xb0 } }, -{ "cmpw", {"rwrw", 0xb1 } }, -{ "mcomw", {"rwww", 0xb2 } }, -{ "bitw", {"rwrw", 0xb3 } }, -{ "clrw", {"ww", 0xb4 } }, -{ "tstw", {"rw", 0xb5 } }, -{ "incw", {"mw", 0xb6 } }, -{ "decw", {"mw", 0xb7 } }, -{ "bispsw", {"rw", 0xb8 } }, -{ "bicpsw", {"rw", 0xb9 } }, -{ "popr", {"rw", 0xba } }, -{ "pushr", {"rw", 0xbb } }, -{ "chmk", {"rw", 0xbc } }, -{ "chme", {"rw", 0xbd } }, -{ "chms", {"rw", 0xbe } }, -{ "chmu", {"rw", 0xbf } }, -{ "addl2", {"rlml", 0xc0 } }, -{ "addl3", {"rlrlwl", 0xc1 } }, -{ "subl2", {"rlml", 0xc2 } }, -{ "subl3", {"rlrlwl", 0xc3 } }, -{ "mull2", {"rlml", 0xc4 } }, -{ "mull3", {"rlrlwl", 0xc5 } }, -{ "divl2", {"rlml", 0xc6 } }, -{ "divl3", {"rlrlwl", 0xc7 } }, -{ "bisl2", {"rlml", 0xc8 } }, -{ "bisl3", {"rlrlwl", 0xc9 } }, -{ "bicl2", {"rlml", 0xca } }, -{ "bicl3", {"rlrlwl", 0xcb } }, -{ "xorl2", {"rlml", 0xcc } }, -{ "xorl3", {"rlrlwl", 0xcd } }, -{ "mnegl", {"rlwl", 0xce } }, -{ "casel", {"rlrlrl", 0xcf } }, -{ "movl", {"rlwl", 0xd0 } }, -{ "cmpl", {"rlrl", 0xd1 } }, -{ "mcoml", {"rlwl", 0xd2 } }, -{ "bitl", {"rlrl", 0xd3 } }, -{ "clrf", {"wf", 0xd4 } }, -{ "clrl", {"wl", 0xd4 } }, -{ "tstl", {"rl", 0xd5 } }, -{ "incl", {"ml", 0xd6 } }, -{ "decl", {"ml", 0xd7 } }, -{ "adwc", {"rlml", 0xd8 } }, -{ "sbwc", {"rlml", 0xd9 } }, -{ "mtpr", {"rlrl", 0xda } }, -{ "mfpr", {"rlwl", 0xdb } }, -{ "movpsl", {"wl", 0xdc } }, -{ "pushl", {"rl", 0xdd } }, -{ "moval", {"alwl", 0xde } }, -{ "movaf", {"afwl", 0xde } }, -{ "pushal", {"al", 0xdf } }, -{ "pushaf", {"af", 0xdf } }, -{ "bbs", {"rlabbb", 0xe0 } }, -{ "bbc", {"rlabbb", 0xe1 } }, -{ "bbss", {"rlabbb", 0xe2 } }, -{ "bbcs", {"rlabbb", 0xe3 } }, -{ "bbsc", {"rlabbb", 0xe4 } }, -{ "bbcc", {"rlabbb", 0xe5 } }, -{ "bbssi", {"rlabbb", 0xe6 } }, -{ "bbcci", {"rlabbb", 0xe7 } }, -{ "blbs", {"rlbb", 0xe8 } }, -{ "blbc", {"rlbb", 0xe9 } }, -{ "ffs", {"rlrbvbwl", 0xea } }, -{ "ffc", {"rlrbvbwl", 0xeb } }, -{ "cmpv", {"rlrbvbrl", 0xec } }, -{ "cmpzv", {"rlrbvbrl", 0xed } }, -{ "extv", {"rlrbvbwl", 0xee } }, -{ "extzv", {"rlrbvbwl", 0xef } }, -{ "insv", {"rlrlrbvb", 0xf0 } }, -{ "acbl", {"rlrlmlbw", 0xf1 } }, -{ "aoblss", {"rlmlbb", 0xf2 } }, -{ "aobleq", {"rlmlbb", 0xf3 } }, -{ "sobgeq", {"mlbb", 0xf4 } }, -{ "sobgtr", {"mlbb", 0xf5 } }, -{ "cvtlb", {"rlwb", 0xf6 } }, -{ "cvtlw", {"rlww", 0xf7 } }, -{ "ashp", {"rbrwabrbrwab", 0xf8 } }, -{ "cvtlp", {"rlrwab", 0xf9 } }, -{ "callg", {"abab", 0xfa } }, -{ "calls", {"rlab", 0xfb } }, -{ "xfc", {"", 0xfc } }, - /* undefined opcodes here */ -{ "cvtdh", {"rdwh", 0x32fd } }, -{ "cvtgf", {"rgwh", 0x33fd } }, -{ "addg2", {"rgmg", 0x40fd } }, -{ "addg3", {"rgrgwg", 0x41fd } }, -{ "subg2", {"rgmg", 0x42fd } }, -{ "subg3", {"rgrgwg", 0x43fd } }, -{ "mulg2", {"rgmg", 0x44fd } }, -{ "mulg3", {"rgrgwg", 0x45fd } }, -{ "divg2", {"rgmg", 0x46fd } }, -{ "divg3", {"rgrgwg", 0x47fd } }, -{ "cvtgb", {"rgwb", 0x48fd } }, -{ "cvtgw", {"rgww", 0x49fd } }, -{ "cvtgl", {"rgwl", 0x4afd } }, -{ "cvtrgl", {"rgwl", 0x4bfd } }, -{ "cvtbg", {"rbwg", 0x4cfd } }, -{ "cvtwg", {"rwwg", 0x4dfd } }, -{ "cvtlg", {"rlwg", 0x4efd } }, -{ "acbg", {"rgrgmgbw", 0x4ffd } }, -{ "movg", {"rgwg", 0x50fd } }, -{ "cmpg", {"rgrg", 0x51fd } }, -{ "mnegg", {"rgwg", 0x52fd } }, -{ "tstg", {"rg", 0x53fd } }, -{ "emodg", {"rgrwrgwlwg", 0x54fd } }, -{ "polyg", {"rgrwab", 0x55fd } }, -{ "cvtgh", {"rgwh", 0x56fd } }, - /* undefined opcodes here */ -{ "addh2", {"rhmh", 0x60fd } }, -{ "addh3", {"rhrhwh", 0x61fd } }, -{ "subh2", {"rhmh", 0x62fd } }, -{ "subh3", {"rhrhwh", 0x63fd } }, -{ "mulh2", {"rhmh", 0x64fd } }, -{ "mulh3", {"rhrhwh", 0x65fd } }, -{ "divh2", {"rhmh", 0x66fd } }, -{ "divh3", {"rhrhwh", 0x67fd } }, -{ "cvthb", {"rhwb", 0x68fd } }, -{ "cvthw", {"rhww", 0x69fd } }, -{ "cvthl", {"rhwl", 0x6afd } }, -{ "cvtrhl", {"rhwl", 0x6bfd } }, -{ "cvtbh", {"rbwh", 0x6cfd } }, -{ "cvtwh", {"rwwh", 0x6dfd } }, -{ "cvtlh", {"rlwh", 0x6efd } }, -{ "acbh", {"rhrhmhbw", 0x6ffd } }, -{ "movh", {"rhwh", 0x70fd } }, -{ "cmph", {"rhrh", 0x71fd } }, -{ "mnegh", {"rhwh", 0x72fd } }, -{ "tsth", {"rh", 0x73fd } }, -{ "emodh", {"rhrwrhwlwh", 0x74fd } }, -{ "polyh", {"rhrwab", 0x75fd } }, -{ "cvthg", {"rhwg", 0x76fd } }, - /* undefined opcodes here */ -{ "clrh", {"wh", 0x7cfd } }, -{ "clro", {"wo", 0x7cfd } }, -{ "movo", {"rowo", 0x7dfd } }, -{ "movah", {"ahwl", 0x7efd } }, -{ "movao", {"aowl", 0x7efd } }, -{ "pushah", {"ah", 0x7ffd } }, -{ "pushao", {"ao", 0x7ffd } }, - /* undefined opcodes here */ -{ "cvtfh", {"rfwh", 0x98fd } }, -{ "cvtfg", {"rfwg", 0x99fd } }, - /* undefined opcodes here */ -{ "cvthf", {"rhwf", 0xf6fd } }, -{ "cvthd", {"rhwd", 0xf7fd } }, - /* undefined opcodes here */ -{ "bugl", {"rl", 0xfdff } }, -{ "bugw", {"rw", 0xfeff } }, - /* undefined opcodes here */ - -{ "" , "" } /* empty is end sentinel */ - -}; /* votstrs */ - -/* end: vax.opcode.h */ diff --git a/gdb/vax-pinsn.c b/gdb/vax-pinsn.c deleted file mode 100644 index 011cd952dc2..00000000000 --- a/gdb/vax-pinsn.c +++ /dev/null @@ -1,240 +0,0 @@ -/* Print vax instructions for GDB, the GNU debugger. - Copyright (C) 1986, 1989 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include - -#include "defs.h" -#include "param.h" -#include "symtab.h" -#include "vax-opcode.h" - -/* Vax instructions are never longer than this. */ -#define MAXLEN 62 - -/* Number of elements in the opcode table. */ -#define NOPCODES (sizeof votstrs / sizeof votstrs[0]) - -extern char *reg_names[]; - -static unsigned char *print_insn_arg (); - -/* Print the vax instruction at address MEMADDR in debugged memory, - on STREAM. Returns length of the instruction, in bytes. */ - -int -print_insn (memaddr, stream) - CORE_ADDR memaddr; - FILE *stream; -{ - unsigned char buffer[MAXLEN]; - register int i; - register unsigned char *p; - register char *d; - - read_memory (memaddr, buffer, MAXLEN); - - for (i = 0; i < NOPCODES; i++) - if (votstrs[i].detail.code == buffer[0] - || votstrs[i].detail.code == *(unsigned short *)buffer) - break; - - /* Handle undefined instructions. */ - if (i == NOPCODES) - { - fprintf (stream, "0%o", buffer[0]); - return 1; - } - - fprintf (stream, "%s", votstrs[i].name); - - /* Point at first byte of argument data, - and at descriptor for first argument. */ - p = buffer + 1 + (votstrs[i].detail.code >= 0x100); - d = votstrs[i].detail.args; - - if (*d) - fputc (' ', stream); - - while (*d) - { - p = print_insn_arg (d, p, memaddr + (p - buffer), stream); - d += 2; - if (*d) - fprintf (stream, ","); - } - return p - buffer; -} - -static unsigned char * -print_insn_arg (d, p, addr, stream) - char *d; - register char *p; - CORE_ADDR addr; - FILE *stream; -{ - register int regnum = *p & 0xf; - float floatlitbuf; - - if (*d == 'b') - { - if (d[1] == 'b') - fprintf (stream, "0x%x", addr + *p++ + 1); - else - { - fprintf (stream, "0x%x", addr + *(short *)p + 2); - p += 2; - } - } - else - switch ((*p++ >> 4) & 0xf) - { - case 0: - case 1: - case 2: - case 3: /* Literal mode */ - if (d[1] == 'd' || d[1] == 'f' || d[1] == 'g' || d[1] == 'h') - { - *(int *)&floatlitbuf = 0x4000 + ((p[-1] & 0x3f) << 4); - fprintf (stream, "$%f", floatlitbuf); - } - else - fprintf (stream, "$%d", p[-1] & 0x3f); - break; - - case 4: /* Indexed */ - p = (char *) print_insn_arg (d, p, addr + 1, stream); - fprintf (stream, "[%s]", reg_names[regnum]); - break; - - case 5: /* Register */ - fprintf (stream, reg_names[regnum]); - break; - - case 7: /* Autodecrement */ - fputc ('-', stream); - case 6: /* Register deferred */ - fprintf (stream, "(%s)", reg_names[regnum]); - break; - - case 9: /* Autoincrement deferred */ - fputc ('@', stream); - if (regnum == PC_REGNUM) - { - fputc ('#', stream); - print_address (*(long *)p, stream); - p += 4; - break; - } - case 8: /* Autoincrement */ - if (regnum == PC_REGNUM) - { - fputc ('#', stream); - switch (d[1]) - { - case 'b': - fprintf (stream, "%d", *p++); - break; - - case 'w': - fprintf (stream, "%d", *(short *)p); - p += 2; - break; - - case 'l': - fprintf (stream, "%d", *(long *)p); - p += 4; - break; - - case 'q': - fprintf (stream, "0x%x%08x", ((long *)p)[1], ((long *)p)[0]); - p += 8; - break; - - case 'o': - fprintf (stream, "0x%x%08x%08x%08x", - ((long *)p)[3], ((long *)p)[2], - ((long *)p)[1], ((long *)p)[0]); - p += 16; - break; - - case 'f': - if (INVALID_FLOAT (p, 4)) - fprintf (stream, "<>", *(int *) p); - else - fprintf (stream, "%f", *(float *) p); - p += 4; - break; - - case 'd': - if (INVALID_FLOAT (p, 8)) - fprintf (stream, "<>", - ((long *)p)[1], ((long *)p)[0]); - else - fprintf (stream, "%f", *(double *) p); - p += 8; - break; - - case 'g': - fprintf (stream, "g-float"); - p += 8; - break; - - case 'h': - fprintf (stream, "h-float"); - p += 16; - break; - - } - } - else - fprintf (stream, "(%s)+", reg_names[regnum]); - break; - - case 11: /* Byte displacement deferred */ - fputc ('@', stream); - case 10: /* Byte displacement */ - if (regnum == PC_REGNUM) - print_address (addr + *p + 2, stream); - else - fprintf (stream, "%d(%s)", *p, reg_names[regnum]); - p += 1; - break; - - case 13: /* Word displacement deferred */ - fputc ('@', stream); - case 12: /* Word displacement */ - if (regnum == PC_REGNUM) - print_address (addr + *(short *)p + 3, stream); - else - fprintf (stream, "%d(%s)", *(short *)p, reg_names[regnum]); - p += 2; - break; - - case 15: /* Long displacement deferred */ - fputc ('@', stream); - case 14: /* Long displacement */ - if (regnum == PC_REGNUM) - print_address (addr + *(long *)p + 5, stream); - else - fprintf (stream, "%d(%s)", *(long *)p, reg_names[regnum]); - p += 4; - } - - return (unsigned char *) p; -} diff --git a/gdb/vx-share/.Sanitize b/gdb/vx-share/.Sanitize deleted file mode 100644 index 39d666466e5..00000000000 --- a/gdb/vx-share/.Sanitize +++ /dev/null @@ -1,58 +0,0 @@ -# Sanitize.in for devo. -# $Id$ -# - -# Each directory to survive it's way into a release will need a file -# like this one called "./.Sanitize". All keyword lines must exist, -# and must exist in the order specified by this file. Each directory -# in the tree will be processed, top down, in the following order. - -# Hash started lines like this one are comments and will be deleted -# before anything else is done. Blank lines will also be squashed -# out. - -# The lines between the "Do-first:" line and the "Things-to-keep:" -# line are executed as a /bin/sh shell script before anything else is -# done in this - -Do-first: - -echo Sanitizing `pwd`... - -# All files listed between the "Things-to-keep:" line and the -# "Files-to-sed:" line will be kept. All other files will be removed. -# Directories listed in this section will have their own Sanitize -# called. Directories not listed will be removed in their entirety -# with rm -rf. - -Things-to-keep: - -dbgRpcLib.h -ptrace.h -reg.h -vxTypes.h -vxWorks.h -wait.h -xdr_ld.c -xdr_ld.h -xdr_ptrace.c -xdr_ptrace.h -xdr_rdb.c -xdr_rdb.h -xdr_regs.c -xdr_regs.h - -Do-last: - -echo Done in `pwd`. - -# -# -# $Log$ -# Revision 1.1 1991/05/23 22:05:02 rich -# Initial revision -# -# -# - -# End of file. diff --git a/gdb/vx-share/dbgRpcLib.h b/gdb/vx-share/dbgRpcLib.h deleted file mode 100644 index c420075c281..00000000000 --- a/gdb/vx-share/dbgRpcLib.h +++ /dev/null @@ -1,28 +0,0 @@ -/* dbgRpcLib.h - header file for remote debugging via rpc */ - -/* -modification history --------------------- -01b,04oct90,maf added VX_BOOT_FILE_INQ. -01a,05jun90,llk extracted from xdr_dbx.h. -*/ - -#ifndef INCdbxRpcLibh -#define INCdbxRpcLibh 1 - -#define PROCESS_START 50 -#define PROCESS_WAIT 51 -#define VX_STATE_INQ 60 -#define VX_LOAD 61 -#define VX_SYMBOL_INQ 62 -#define VX_BREAK_ADD 63 -#define VX_BREAK_DELETE 64 -#define VX_FP_INQUIRE 65 -#define VX_TASK_SUSPEND 66 -#define VX_CALL_FUNC 67 -#define VX_CONV_FROM_68881 68 -#define VX_CONV_TO_68881 69 -#define VX_BOOT_FILE_INQ 70 -#define VX_SOURCE_STEP 71 - -#endif INCdbxRpcLibh diff --git a/gdb/vx-share/ptrace.h b/gdb/vx-share/ptrace.h deleted file mode 100644 index 34801c71e06..00000000000 --- a/gdb/vx-share/ptrace.h +++ /dev/null @@ -1,44 +0,0 @@ -/* @(#)ptrace.h 1.1 86/07/07 SMI */ - -/* - * Copyright (c) 1985 by Sun Microsystems, Inc. - */ - -/* -modification history --------------------- -01a,05jun90,llk borrowed. -*/ - -#ifndef _PTRACE_ -#define _PTRACE_ - -/* - * Request values for the ptrace system call - */ -enum ptracereq { - PTRACE_TRACEME = 0, /* 0, by tracee to begin tracing */ - PTRACE_CHILDDONE = 0, /* 0, tracee is done with his half */ - PTRACE_PEEKTEXT, /* 1, read word from text segment */ - PTRACE_PEEKDATA, /* 2, read word from data segment */ - PTRACE_PEEKUSER, /* 3, read word from user struct */ - PTRACE_POKETEXT, /* 4, write word into text segment */ - PTRACE_POKEDATA, /* 5, write word into data segment */ - PTRACE_POKEUSER, /* 6, write word into user struct */ - PTRACE_CONT, /* 7, continue process */ - PTRACE_KILL, /* 8, terminate process */ - PTRACE_SINGLESTEP, /* 9, single step process */ - PTRACE_ATTACH, /* 10, attach to an existing process */ - PTRACE_DETACH, /* 11, detach from a process */ - PTRACE_GETREGS, /* 12, get all registers */ - PTRACE_SETREGS, /* 13, set all registers */ - PTRACE_GETFPREGS, /* 14, get all floating point regs */ - PTRACE_SETFPREGS, /* 15, set all floating point regs */ - PTRACE_READDATA, /* 16, read data segment */ - PTRACE_WRITEDATA, /* 17, write data segment */ - PTRACE_READTEXT, /* 18, read text segment */ - PTRACE_WRITETEXT, /* 19, write text segment */ - PTRACE_GETFPAREGS, /* 20, get all fpa regs */ - PTRACE_SETFPAREGS, /* 21, set all fpa regs */ -}; -#endif !_PTRACE diff --git a/gdb/vx-share/reg.h b/gdb/vx-share/reg.h deleted file mode 100644 index 84658b7760e..00000000000 --- a/gdb/vx-share/reg.h +++ /dev/null @@ -1,209 +0,0 @@ -/* @(#)reg.h 1.1 86/07/07 SMI */ - -/* - * Copyright (c) 1986 by Sun Microsystems, Inc. - */ - -/* -modification history --------------------- -01a,05jun90,llk borrowed. -*/ - -#ifndef _REG_ -#define _REG_ - -#ifdef I80960 - -/* Intel 960 register values passed over the wire by RPC: */ - -struct regs -{ - int r_lreg[16]; /* local registers */ - int r_greg[16]; /* global registers */ - int r_pcw; /* process control word */ - int r_acw; /* arithmetic control word */ - int r_tcw; /* trace control word */ -}; - -#define FP_REG_SIZE 12 - -struct fp_status { - char fps_regs[4][FP_REG_SIZE]; /* floating point regs */ -}; - -#else /* For now, just 68000 */ - -/* - * Location of the users' stored - * registers relative to R0. - * Usage is u.u_ar0[XX]. - */ -#define R0 (0) -#define R1 (1) -#define R2 (2) -#define R3 (3) -#define R4 (4) -#define R5 (5) -#define R6 (6) -#define R7 (7) -#define AR0 (8) -#define AR1 (9) -#define AR2 (10) -#define AR3 (11) -#define AR4 (12) -#define AR5 (13) -#define AR6 (14) -#define AR7 (15) -#define SP (15) -#define PS (16) -#define PC (17) - -/* - * And now for something completely the same... - */ -#ifndef LOCORE -struct regs { - int r_dreg[8]; /* data registers */ -#define r_r0 r_dreg[0] /* r0 for portability */ - int r_areg[8]; /* address registers */ -#define r_sp r_areg[7] /* user stack pointer */ - int r_sr; /* status register (actually a short) */ -#define r_ps r_sr - int r_pc; /* program counter */ -}; - -struct stkfmt { - int f_stkfmt : 4; /* stack format */ - int : 2; - int f_vector : 10; /* vector offset */ - short f_beibase; /* start of bus error info (if any) */ -}; - - -/* - * Struct for floating point registers and general state - * for the MC68881 (the sky fpp has no user visible state). - * If fps_flags == FPS_UNUSED, the other 68881 fields have no meaning. - * fps_code and fps_flags are software implemented fields. - * fps_flags is not used when set by user level programs, - * but changing fps_code has the side effect of changing u.u_code. - */ - -typedef struct ext_fp { - int fp[3]; -} ext_fp; /* extended 96-bit 68881 fp registers */ - -struct fp_status { - ext_fp fps_regs[8]; /* 68881 floating point regs */ - int fps_control; /* 68881 control reg */ - int fps_status; /* 68881 status reg */ - int fps_iaddr; /* 68881 instruction address reg */ - int fps_code; /* additional word for signals */ - int fps_flags; /* r/o - unused, idle or busy */ -}; -#endif !LOCORE - -/* - * Values defined for `fps_flags'. - */ -#define FPS_UNUSED 0 /* 68881 never used yet */ -#define FPS_IDLE 1 /* 68881 instruction completed */ -#define FPS_BUSY 2 /* 68881 instruction interrupted */ - -/* - * The EXT_FPS_FLAGS() macro is used to convert a pointer to an - * fp_istate into a value to be used for the user visible state - * found in fps_flags. As a speed optimization, this convertion - * is only done is required (e.g. the PTRACE_GETFPREGS ptrace - * call or when dumping core) instead of on each context switch. - * The tests that we base the state on are that a fpis_vers of - * FPIS_VERSNULL means NULL state, else a fpis_bufsiz of FPIS_IDLESZ - * means IDLE state, else we assume BUSY state. - */ -#define FPIS_VERSNULL 0x0 -#define FPIS_IDLESIZE 0x18 - -#define EXT_FPS_FLAGS(istatep) \ - ((istatep)->fpis_vers == FPIS_VERSNULL ? FPS_UNUSED : \ - (istatep)->fpis_bufsiz == FPIS_IDLESIZE ? FPS_IDLE : FPS_BUSY) - -#ifndef LOCORE -/* - * Struct for the internal state of the MC68881 - * Although the MC68881 can have a smaller maximum for - * internal state, we allow for more to allow for expansion. - */ -#define FPIS_BUFSIZ 0xc0 - -struct fp_istate { - unsigned char fpis_vers; /* version number */ - unsigned char fpis_bufsiz; /* size of info in fpis_buf */ - unsigned short fpis_reserved; /* reserved word */ - unsigned char fpis_buf[FPIS_BUFSIZ]; /* fpp internal state buffer */ -}; - -/* - * Structures for the status and data registers are defined here. - * Struct fpa_status are included in the u area. - * Struct fpa_regs is included in struct core. - */ - -/* struct fpa_status is saved/restored during context switch */ -struct fpa_status { - unsigned int fpas_state; /* STATE, supervisor privileged reg */ - unsigned int fpas_imask; /* IMASK */ - unsigned int fpas_load_ptr; /* LOAD_PTR */ - unsigned int fpas_ierr; /* IERR */ - unsigned int fpas_act_instr; /* pipe active instruction halves */ - unsigned int fpas_nxt_instr; /* pipe next instruction halves */ - unsigned int fpas_act_d1half;/* pipe active data first half */ - unsigned int fpas_act_d2half;/* pipe active data second half */ - unsigned int fpas_nxt_d1half;/* pipe next data first half */ - unsigned int fpas_nxt_d2half;/* pipe next data second half */ - unsigned int fpas_mode3_0; /* FPA MODE3_0 register */ - unsigned int fpas_wstatus; /* FPA WSTATUS register */ -}; - -/* - * Since there are 32 contexts supported by the FPA hardware, - * when we do context switch on the FPA, we don't save/restore - * the data registers between the FPA and the u area. - * If there are already 32 processes using the fpa concurrently, - * we give an error message to the 33rd process trying to use the fpa. - * (Hopefully there will not be this many processes using FPA concurrently.) - */ - -#define FPA_NCONTEXTS 32 -#define FPA_NDATA_REGS 32 - -typedef struct fpa_long { - int fpl_data[2]; -} fpa_long; /* 64 bit double precision registers */ - -/* Struct fpa_regs is included in struct core. */ -struct fpa_regs { - unsigned int fpar_flags; /* if zero, other fields are meaningless */ - struct fpa_status fpar_status; - fpa_long fpar_data[FPA_NDATA_REGS]; -}; - -/* - * The size of struct fpa_regs is changed from 141 ints in 3.0 to - * 77 ints in 3.x. A pad of this size difference is added to struct core. - */ -#define CORE_PADLEN 64 - -/* - * If there is going to be external FPU state then we must define the FPU - * variable - */ -struct fpu { - struct fp_status f_fpstatus; /* External FPP state, if any */ - struct fpa_regs f_fparegs; /* FPA registers, if any */ - int f_pad[CORE_PADLEN]; /* see comment above */ -}; - -#endif !LOCORE -#endif /* !I80960 */ -#endif !_REG_ diff --git a/gdb/vx-share/vxTypes.h b/gdb/vx-share/vxTypes.h deleted file mode 100644 index 3ebd7c6d4b3..00000000000 --- a/gdb/vx-share/vxTypes.h +++ /dev/null @@ -1,70 +0,0 @@ -/* vxTypes.h - VxWorks type definition header */ - -/* Copyright 1984-1990 Wind River Systems, Inc. */ - -/* -modification history --------------------- -01c,05oct90,shl added copyright notice. - made #endif ANSI style. -01b,10aug90,dnw added VOIDFUNCPTR -01a,29may90,del written. -*/ - -#ifndef INCvxTypesh -#define INCvxTypesh - -/* The following stuff must NOT be included if this include file is used - * from assembly language. Just #define ASMLANGUAGE before the include, - * to get rid of it. - */ - -#ifndef ASMLANGUAGE - -/* vxWorks types */ - -typedef char INT8; -typedef short INT16; -typedef int INT32; - -typedef unsigned char UINT8; -typedef unsigned short UINT16; -typedef unsigned int UINT32; - -typedef unsigned char UCHAR; -typedef unsigned short USHORT; -typedef unsigned int UINT; -typedef unsigned long ULONG; - -typedef int BOOL; -typedef int VOID; -typedef int STATUS; -typedef int ARGINT; - -typedef int (*FUNCPTR) (); /* ptr to function returning int */ -typedef VOID (*VOIDFUNCPTR) (); /* ptr to function returning VOID */ - - -/* historical definitions - now obsolete */ - -typedef char TINY; /* obsolete */ -typedef char TBOOL; /* obsolete */ -typedef unsigned char UTINY; /* obsolete */ - - -/* architecture dependent typedefs */ - -#ifdef CPU_FAMILY - -#if CPU_FAMILY==MC680X0 -typedef unsigned short INSTR; /* word-aligned instructions */ -#endif /* CPU_FAMILY==MC680X0 */ - -#if CPU_FAMILY==SPARC -typedef unsigned long INSTR; /* 32 bit word-aligned instructions */ -#endif /* CPU_FAMILY==SPARC */ - -#endif - -#endif /* ASMLANGUAGE */ -#endif /* INCvxTypesh */ diff --git a/gdb/vx-share/vxWorks.h b/gdb/vx-share/vxWorks.h deleted file mode 100644 index 483313e1f95..00000000000 --- a/gdb/vx-share/vxWorks.h +++ /dev/null @@ -1,177 +0,0 @@ -/* vxWorks.h - VxWorks standard definitions header */ - -/* Copyright 1984-1990 Wind River Systems, Inc. */ - -/* -modification history --------------------- -01z,05oct90,shl added copyright notice. - made #endif ANSI style. -01y,28sep90,del added I960 defines. -01x,29may90,del moved types to vxTypes.h -01w,09apr90,jcf added timeout definitions. -01v,24jan90,gae moved network configuration flags here from makefile's. -01u,01sep88,mcl definition of INSTR dependent on processor family; added SPARC. - +gae added MC680X0 and defined CPU_FAMILY. -01t,08apr89,dnw added ifdef to prevent inclusion of vxWorks.h more than once. -01s,22jun88,dnw moved READ, WRITE, and UPDATE back here from ioLib.h. -01r,22apr88,gae oops! forgot some #endif's in 01q. -01q,12apr88,gae removed QUICK & WAIT; added STD_{IN,OUT,ERR}. - fixed #define's of FALSE, TRUE, etc. - moved READ, WRITE, and UPDATE to ioLib.h. -01p,04dec87,dnw added undefine of MC68000 to get around Green Hills bug that - pre-defines MC68000. -01o,12nov87,ecs added type ULONG. -01n,08feb86,dnw added types INSTR, UINT, USHORT. -01m,14oct85,rdc added BUS types. -01l,16jul85,jlf added conditional for NULL and EOF. -01k,24jun85,rdc installed condtional compile so we can include in - assembly language files. See instructions below. - Added System type macro and CPU type macro. -01j,13jun85,dnw cleaned-up, removed more obsolete stuff to wrs.h -01i,11sep84,jlf changed name from wrs.h to vxWorks.h. removed GLOBAL. -01h,03jun84,dnw removed IGNORE declaration. -01g,09apr84,jlf added MEMBER_SIZE macro. -01f,14dec83,dnw added MSB, LSB macros -01e,17nov83,jlf added STATUS type, for routines which return a status. -01d,13jul83,dnw added NELEMENTS macro -01c,14May83,dnw added OFFSET macro -01b,17Feb83,dnw added stuff from Whitesmiths std.h -01a,15Feb83,dnw written -*/ - -#ifndef INCvxWorksh -#define INCvxWorksh - -#if !defined(NULL) || (NULL!=0) -#define NULL 0 -#endif - -#if !defined(EOF) || (EOF!=(-1)) -#define EOF (-1) -#endif - -#if !defined(FALSE) || (FALSE!=0) -#define FALSE 0 -#endif - -#if !defined(TRUE) || (TRUE!=1) -#define TRUE 1 -#endif - - -#define NONE (-1) /* for times when NULL won't do */ -#define EOS '\0' /* C string terminator */ - - -/* return status values */ - -#define OK 0 -#define ERROR (-1) - -/* timeout defines */ - -#define NO_WAIT 0 -#define WAIT_FOREVER (-1) - -/* low-level I/O input, output, error fd's */ - -#define STD_IN 0 -#define STD_OUT 1 -#define STD_ERR 2 - -/* modes - must match O_RDONLY/O_WRONLY/O_RDWR in ioLib.h! */ - -#define READ 0 -#define WRITE 1 -#define UPDATE 2 - -/* SYSTEM types */ - -#define V7 1 /* ATT version 7 */ -#define SYS_V 2 /* ATT System 5 */ -#define BSD_4_2 3 /* Berkeley BSD 4.2 */ - -/* CPU types */ - -/* The Green Hills compiler pre-defines "MC68000"!! */ -#ifdef MC68000 -#undef MC68000 -#endif - -#define MC68000 1 -#define MC68010 2 -#define MC68020 3 -#define MC68030 4 -#define MC68040 5 -#define MC680X0 9 - -#define SPARC 10 - -#ifndef I960 -#define I960 20 -#endif - -#define I960KB 21 -#define I960CA 22 - -#if CPU==MC68000 || CPU==MC68010 || CPU==MC68020 || CPU==MC68030 -#define CPU_FAMILY MC680X0 -#endif /* CPU==MC68000 || CPU==MC68010 || CPU==MC68020 || CPU==MC68030 */ - -#if CPU==SPARC -#define CPU_FAMILY SPARC -#endif /* CPU==SPARC */ - -#if CPU==I960KB -#define CPU_FAMILY I960 -#endif /* CPU==I960KB */ - -#if CPU==I960CA -#define CPU_FAMILY I960 -#endif /* CPU==I960CA */ - -/* BUS types */ - -#define VME_BUS 1 -#define MULTI_BUS 2 - -/* network configuration parameters */ - -#define INET /* include internet protocols */ -#define BSD 43 /* BSD 4.3 -like OS */ -#define BSDDEBUG /* turn on debug */ -#define GATEWAY /* tables to be initialized for gateway routing */ - -/* common macros */ - -#define MSB(x) (((x) >> 8) & 0xff) /* most signif byte of 2-byte integer */ -#define LSB(x) ((x) & 0xff) /* least signif byte of 2-byte integer*/ - -#define OFFSET(structure, member) /* byte offset of member in structure*/\ - ((int) &(((structure *) 0) -> member)) - -#define MEMBER_SIZE(structure, member) /* size of a member of a structure */\ - (sizeof (((structure *) 0) -> member)) - -#define NELEMENTS(array) /* number of elements in an array */ \ - (sizeof (array) / sizeof ((array) [0])) - -#define FOREVER for (;;) - -#define max(x, y) (((x) < (y)) ? (y) : (x)) -#define min(x, y) (((x) < (y)) ? (x) : (y)) - - -/* storage class specifier definitions */ - -#define FAST register -#define IMPORT extern -#define LOCAL static - - -/* include typedefs - must come after CPU_FAMILY definitions above */ - -#include "vxTypes.h" - -#endif /* INCvxWorksh */ diff --git a/gdb/vx-share/wait.h b/gdb/vx-share/wait.h deleted file mode 100644 index bb81f5b7fac..00000000000 --- a/gdb/vx-share/wait.h +++ /dev/null @@ -1,42 +0,0 @@ -/* wait.h - header file for remote wait call */ - -/* -modification history --------------------- -01a,05jun90,llk borrowed. -*/ - -/* Define how to access the structure that the wait system call stores. - On many systems, there is a structure defined for this. - But on vanilla-ish USG systems there is not. */ - -#ifndef HAVE_WAIT_STRUCT -#define WAITTYPE int -#define WIFSTOPPED(w) (((w)&0377) == 0177) -#define WIFSIGNALED(w) (((w)&0377) != 0177 && ((w)&~0377) == 0) -#define WIFEXITED(w) (((w)&0377) == 0) -#define WRETCODE(w) ((w) >> 8) -#define WSTOPSIG(w) ((w) >> 8) -#define WCOREDUMP(w) (((w)&0200) != 0) -#define WTERMSIG(w) ((w) & 0177) -#define WSETEXIT(w, status) ((w) = (status)) -#define WSETSTOP(w,sig) ((w) = (0177 | ((sig) << 8))) -#else -#if FALSE -#ifndef ORIG - -/* don't include sys/wait.h */ - -#else ORIG -#include -#endif ORIG -#endif FALSE -#define WAITTYPE union wait -#define WRETCODE(w) (w).w_retcode -#define WSTOPSIG(w) (w).w_stopsig -#define WCOREDUMP(w) (w).w_coredump -#define WTERMSIG(w) (w).w_termsig -#define WSETEXIT(w, status) ((w).w_status = (status)) -#define WSETSTOP(w,sig) \ - ((w).w_stopsig = (sig), (w).w_coredump = 0, (w).w_termsig = 0177) -#endif diff --git a/gdb/vx-share/xdr_ld.c b/gdb/vx-share/xdr_ld.c deleted file mode 100644 index 4935c3402bc..00000000000 --- a/gdb/vx-share/xdr_ld.c +++ /dev/null @@ -1,82 +0,0 @@ -/* xdr_ld.c - xdr routines for remote dbx interface to VxWorks */ - -/* Copyright 1984,1985,1986,1987,1988,1989 Wind River Systems, Inc. */ -/*extern char copyright_wind_river[]; static char *copyright=copyright_wind_river;*/ - -/* -modification history --------------------- -01a,05jun90,llk extracted from xdr_dbx.c. -*/ - -/* -DESCRIPTION -This module contains the eXternal Data Representation (XDR) routines -for object files that are downloaded to VxWorks. They are used by -remote debuggers that use RPC (such as dbxWorks and vxGdb). -*/ - -#include "vxWorks.h" -#include "rpc/rpc.h" -#include "xdr_ld.h" - -/* forward declarations */ - -bool_t xdr_String(); /* xdr routine for argument list */ - - -/******************************************************************************* -* -* xdr_String - xdr routine for strings. -* -* Used by xdr_arg_info to handle the actual argument -* strings. normally calls xdr_string - but does something -* reasonable encode of null pointer. -*/ - -bool_t xdr_String (xdrs, strp) - XDR *xdrs; - char **strp; - - { - if ((*strp == NULL) & (xdrs->x_op == XDR_ENCODE)) - return(FALSE); - else - return(xdr_string(xdrs, strp, MAXSTRLEN)); - } -/******************************************************************************* -* -* xdr_ldfile - xdr routine for a single element in the load table -*/ - -bool_t xdr_ldfile (xdrs, objp) - XDR *xdrs; - ldfile *objp; - - { - if (! xdr_String(xdrs, &objp->name)) - return(FALSE); - if (! xdr_int(xdrs, &objp->txt_addr)) - return(FALSE); - if (! xdr_int(xdrs, &objp->data_addr)) - return(FALSE); - if (! xdr_int(xdrs, &objp->bss_addr)) - return(FALSE); - - return(TRUE); - } -/******************************************************************************* -* -* xdr_ldtabl - -* -* xdr routine for a list of files and load addresses loaded into VxWorks. -*/ - -bool_t xdr_ldtabl (xdrs,objp) - XDR *xdrs; - ldtabl *objp; - - { - return (xdr_array (xdrs, (char *) &objp->tbl_ent, (UINT *) &objp->tbl_size, - MAXTBLSZ, sizeof(ldfile), xdr_ldfile)); - } diff --git a/gdb/vx-share/xdr_ld.h b/gdb/vx-share/xdr_ld.h deleted file mode 100644 index 8021ccf8520..00000000000 --- a/gdb/vx-share/xdr_ld.h +++ /dev/null @@ -1,41 +0,0 @@ -/* xdr_ld.h - xdr for additional dbxWorks structures */ - -/* -modification history --------------------- -01a,05jun90,llk extracted from xdr_dbx.h. -*/ - -#ifndef INCxdrldh -#define INCxdrldh - -#define MAXSTRLEN 256 -#define MAXTBLSZ 100 - -/* - * structure used to pass back the information for a single file - * loaded in VxWorks - */ -struct ldfile { - char *name; - int txt_addr; - int data_addr; - int bss_addr; -}; -typedef struct ldfile ldfile; - -/* - * structure used to return a list of all files loaded over to - * VxWorks. (VX_STATE_INQ return) - */ -struct ldtabl { - u_int tbl_size; - ldfile *tbl_ent; -}; -typedef struct ldtabl ldtabl; - - -bool_t xdr_ldfile(); -bool_t xdr_ldtabl(); - -#endif INCxdrldh diff --git a/gdb/vx-share/xdr_ptrace.c b/gdb/vx-share/xdr_ptrace.c deleted file mode 100644 index 08813fcc355..00000000000 --- a/gdb/vx-share/xdr_ptrace.c +++ /dev/null @@ -1,171 +0,0 @@ -/* xdr_ptrace.c - xdr routines for remote ptrace calls */ - -/* Copyright 1984,1985,1986,1987,1988,1989 Wind River Systems, Inc. */ -/* extern char copyright_wind_river[]; static char *copyright=copyright_wind_river;*/ - -/* -modification history --------------------- -01a,05jun90,llk extracted from xdr_ptrace.h, version 01c. -*/ - -#include -#include -#include - -#define MAX_LEN 32000 - -/******************************************************************** -* -* xdr_regs_ptr - -* -* xdr routine to get regs* branch of discriminated union ptrace_info -* -*/ - -LOCAL bool_t xdr_regs_ptr(xdrs,objp) - XDR *xdrs; - struct regs **objp; - { - return (xdr_pointer(xdrs, (char **) objp, sizeof(struct regs), xdr_regs)); - } /* xdr_regs_ptr */ - -/******************************************************************** -* -* xdr_fp_status_ptr - -* -* xdr routine for fp_status * branch of discrimanated union -* -*/ - -LOCAL bool_t xdr_fp_status_ptr(xdrs,objp) - XDR *xdrs; - struct fp_status **objp; - { - return(xdr_pointer(xdrs, (char **) objp, sizeof(struct fp_status), - xdr_fp_status)); - } /* xdr_fp_status_ptr */ - -#ifndef I80960 -/******************************************************************** -* -* xdr_fpa_regs_ptr - -* -* xdr routine for fpa_regs* branch of ptrace_info -* -*/ - -LOCAL bool_t xdr_fpa_regs_ptr(xdrs,objp) - XDR *xdrs; - struct fpa_regs **objp; - { - if (! xdr_pointer(xdrs, (char **) objp, sizeof(struct fpa_regs), - xdr_fpa_regs)) - return(FALSE); - else - return(TRUE); - } /* xdr_fpa_regs_ptr */ -#endif - -/******************************************************************** -* -* xdr_c_bytes_ptr - -* -* xdr routine for counted bytes branch of ptrace_info -* -*/ - -LOCAL bool_t xdr_c_bytes_ptr(xdrs,objp) - XDR *xdrs; - C_bytes **objp; - { - return(xdr_pointer(xdrs, (char **) objp, sizeof(C_bytes), xdr_c_bytes)); - } /* xdr_c_bytes_ptr */ - -/******************************************************************** -* -* xdr_ptrace_info - -* -* xdr routine for discriminated union ptrace_info -* -*/ - -bool_t xdr_ptrace_info(xdrs,objp) - XDR *xdrs; - Ptrace_info *objp; - { - static struct xdr_discrim choices[] = - { - { (int) REGS, xdr_regs_ptr }, - { (int) FPREGS, xdr_fp_status_ptr }, -#ifndef I80960 - { (int) FPAREGS, xdr_fpa_regs_ptr }, -#endif - { (int) DATA, xdr_c_bytes_ptr }, - { __dontcare__, NULL } - }; - - return(xdr_union(xdrs, (enum_t *) &objp->ttype, - (char *) &objp->more_data, choices, xdr_void)); - } /* xdr_ptrace_info */ - -/******************************************************************** -* -* xdr_rptrace - -* -* xdr routine for remote ptrace data into server -* -*/ - -bool_t xdr_rptrace(xdrs,objp) - XDR *xdrs; - Rptrace *objp; - { - if (! xdr_int(xdrs, &objp->pid)) - return(FALSE); - if (! xdr_int(xdrs, &objp->data)) - return(FALSE); - if (! xdr_int(xdrs, &objp->addr)) - return(FALSE); - if (! xdr_ptrace_info(xdrs, &objp->info)) - return(FALSE); - - return(TRUE); - } /* xdr_rptrace */ - -/******************************************************************** -* -* xdr_ptrace_return - -* -* xdr routine for remote ptrace data returned by server -* -*/ - -bool_t xdr_ptrace_return(xdrs, objp) - XDR *xdrs; - Ptrace_return *objp; - { - if (! xdr_int(xdrs, &objp->status)) - return(FALSE); - if (! xdr_int(xdrs, &objp->errno)) - return(FALSE); - if (! xdr_ptrace_info(xdrs, &objp->info)) - return(FALSE); - - return(TRUE); - } /* xdr_ptrace_return */ - -/******************************************************************** -* -* xdr_c_bytes - -* -* xdr routine for counted bytes -* -*/ -bool_t xdr_c_bytes(xdrs,objp) - XDR *xdrs; - C_bytes *objp; - { - return(xdr_bytes(xdrs, &objp->bytes, (u_int *) &objp->len, MAX_LEN)); - } /* xdr_c_bytes */ - diff --git a/gdb/vx-share/xdr_ptrace.h b/gdb/vx-share/xdr_ptrace.h deleted file mode 100644 index 1fe7ab43d19..00000000000 --- a/gdb/vx-share/xdr_ptrace.h +++ /dev/null @@ -1,68 +0,0 @@ -/* xdr_ptrace.h - xdr header for remote ptrace structures */ - -/* -modification history --------------------- -01a,05jun90,llk extracted from xdr_ptrace.h. -*/ - - -#include "xdr_regs.h" -#include "reg.h" - -/* - * Counted byte structure used by READ/WRITE TEXT/DATA - */ -struct c_bytes { - u_int len; - caddr_t bytes; -}; -typedef struct c_bytes C_bytes; - -/* - * enum for discriminated union ptrace_info - */ -enum ptype { - NOINFO = 0, /* no additional infomation */ - REGS = 1, /* regs (SETREGS) */ - FPREGS = 2, /* fp_status (SETFPREGS) */ - FPAREGS = 3, /* fpa_regs (SETFPAREGS) */ - DATA = 4, /* c_bytes (WRITETEXT/DATA)*/ -}; -typedef enum ptype ptype; - -/* - * discrimnated union for passing additional data to be - * written to the debugged process. With the exception of - * c_bytes, the structures are defined in - */ -struct ptrace_info { - ptype ttype; - caddr_t more_data; -}; -typedef struct ptrace_info Ptrace_info; - -/* - * structure passed to server on all remote ptrace calls - */ -struct rptrace { - int pid; - int data; - int addr; /* FIX! this really should be caddr_t or something */ - Ptrace_info info; -}; -typedef struct rptrace Rptrace; -/* - * structure returned by server on all remote ptrace calls - */ -struct ptrace_return { - int status; - int errno; - Ptrace_info info; -}; -typedef struct ptrace_return Ptrace_return; - -bool_t xdr_c_bytes(); -bool_t xdr_ptrace_info(); -bool_t xdr_rptrace(); -bool_t xdr_ptrace_return(); diff --git a/gdb/vx-share/xdr_rdb.c b/gdb/vx-share/xdr_rdb.c deleted file mode 100644 index 3c70fbf7692..00000000000 --- a/gdb/vx-share/xdr_rdb.c +++ /dev/null @@ -1,207 +0,0 @@ -/* xdr_rdb.c - xdr routines for Remote Debug interface to VxWorks */ - -/* -modification history --------------------- -01a,21mar90,llk created using modification 01d of xdr_dbx.c. -*/ - -/* -DESCRIPTION -This module contains the eXternal Data Representation (XDR) routines -for the RDB interface for VxWorks. -*/ - -#include "vxWorks.h" -#include -#include "xdr_rdb.h" - -/* forward declarations */ - -bool_t -xdr_arg_type(xdrs, objp) - XDR *xdrs; - arg_type *objp; -{ - if (!xdr_enum(xdrs, (enum_t *)objp)) { - return (FALSE); - } - return (TRUE); -} - -bool_t -xdr_arg_value(xdrs, objp) - XDR *xdrs; - arg_value *objp; -{ - if (!xdr_arg_type(xdrs, &objp->type)) { - return (FALSE); - } - switch (objp->type) { - case T_BYTE: - if (!xdr_char(xdrs, &objp->arg_value_u.v_byte)) { - return (FALSE); - } - break; - case T_WORD: - if (!xdr_short(xdrs, &objp->arg_value_u.v_word)) { - return (FALSE); - } - break; - case T_INT: - if (!xdr_int(xdrs, &objp->arg_value_u.v_int)) { - return (FALSE); - } - break; - case T_FLOAT: - if (!xdr_float(xdrs, &objp->arg_value_u.v_fp)) { - return (FALSE); - } - break; - case T_DOUBLE: - if (!xdr_double(xdrs, &objp->arg_value_u.v_dp)) { - return (FALSE); - } - break; - case T_UNKNOWN: - break; - } - return (TRUE); -} - -bool_t -xdr_func_call(xdrs, objp) - XDR *xdrs; - func_call *objp; -{ - if (!xdr_int(xdrs, &objp->func_addr)) { - return (FALSE); - } - if (!xdr_array(xdrs, (char **)&objp->args.args_val, (u_int *)&objp->args.args_len, MAX_FUNC_ARGS, sizeof(arg_value), xdr_arg_value)) { - return (FALSE); - } - return (TRUE); -} - -bool_t -xdr_arg_one(xdrs, objp) - XDR *xdrs; - arg_one *objp; -{ - if (!xdr_string(xdrs, objp, MAX_ARG_LEN)) { - return (FALSE); - } - return (TRUE); -} - - - - -bool_t -xdr_arg_array(xdrs, objp) - XDR *xdrs; - arg_array *objp; -{ - if (!xdr_array(xdrs, (char **)&objp->arg_array_val, (u_int *)&objp->arg_array_len, MAX_ARG_CNT, sizeof(arg_one), xdr_arg_one)) { - return (FALSE); - } - return (TRUE); -} - -/********************************************************************* -* -* xdr_EVENT_TYPE - -* -*/ - -bool_t xdr_EVENT_TYPE(xdrs, objp) - XDR *xdrs; - EVENT_TYPE *objp; - - { - if (!xdr_enum (xdrs, (enum_t *) objp)) - return (FALSE); - return (TRUE); - } - -/********************************************************************* -* -* xdr_RDB_EVENT - -* -*/ - -bool_t xdr_RDB_EVENT (xdrs, objp) - XDR *xdrs; - RDB_EVENT *objp; - - { - if (!xdr_int (xdrs, &objp->status)) - return (FALSE); - if (!xdr_int (xdrs, &objp->taskId)) - return (FALSE); - if (!xdr_EVENT_TYPE (xdrs, &objp->eventType)) - return (FALSE); - if (!xdr_int (xdrs, &objp->sigType)) - return (FALSE); - return (TRUE); - } - -/********************************************************************* -* -* xdr_TASK_START - -* -*/ - -bool_t -xdr_TASK_START (xdrs, objp) - XDR *xdrs; - TASK_START *objp; - - { - if (!xdr_int (xdrs, &objp->status)) - return (FALSE); - if (!xdr_int (xdrs, &objp->pid)) - return (FALSE); - return (TRUE); - } - - -/********************************************************************* -* -* xdr_SYMBOL_ADDR - -* -*/ - -bool_t -xdr_SYMBOL_ADDR (xdrs, objp) - XDR *xdrs; - SYMBOL_ADDR *objp; - - { - if (!xdr_int (xdrs, &objp->status)) - return (FALSE); - if (!xdr_u_int (xdrs, &objp->addr)) - return (FALSE); - return (TRUE); - } - -/********************************************************************* -* -* xdr_SOURCE_STEP - -* -*/ - -bool_t -xdr_SOURCE_STEP (xdrs, objp) - XDR *xdrs; - SOURCE_STEP *objp; - - { - if (!xdr_int (xdrs, &objp->taskId)) - return (FALSE); - if (!xdr_u_int (xdrs, &objp->startAddr)) - return (FALSE); - if (!xdr_u_int (xdrs, &objp->endAddr)) - return (FALSE); - return (TRUE); - } diff --git a/gdb/vx-share/xdr_rdb.h b/gdb/vx-share/xdr_rdb.h deleted file mode 100644 index eebec43dc8c..00000000000 --- a/gdb/vx-share/xdr_rdb.h +++ /dev/null @@ -1,132 +0,0 @@ -/* xdr_rdb.h - xdr for additional rdb structures */ - -/* -modification history --------------------- -01a,23may90,llk created using xdr_dbx.h. - added arg_array to replace arg_info. arg_info had - MAXNCMDARGS (= 100) as the max limit of char strings, - but it should be MAX_TASK_ARGS (= 10). -*/ - -#ifndef INCxdrrdbh -#define INCxdrrdbh - -enum arg_type { - T_UNKNOWN = 0, - T_BYTE = 1, - T_WORD = 2, - T_INT = 3, - T_FLOAT = 4, - T_DOUBLE = 5, -}; -typedef enum arg_type arg_type; -bool_t xdr_arg_type(); - - -struct arg_value { - arg_type type; - union { - char v_byte; - short v_word; - int v_int; - float v_fp; - double v_dp; - } arg_value_u; -}; -typedef struct arg_value arg_value; -bool_t xdr_arg_value(); - -struct func_call { - int func_addr; - struct { - u_int args_len; - arg_value *args_val; - } args; -}; -typedef struct func_call func_call; -bool_t xdr_func_call(); - - -typedef char *arg_one; -bool_t xdr_arg_one(); - - -typedef struct { - u_int arg_array_len; - arg_one *arg_array_val; -} arg_array; -bool_t xdr_arg_array(); - - -/* - * Structures used to pass structures required for - * process control but not part of the standard ptrace interface - */ - -/* - * arg_info is used to pass arguments into process start - */ -struct arg_info { - int rargc; - char **rargv; -}; -typedef struct arg_info Arg_info; - - -enum EVENT_TYPE { - EVENT_BREAK = 0, - EVENT_STOP = 1, - EVENT_EXIT = 2, - EVENT_BUS_ERR = 3, - EVENT_SUSPEND = 4, - EVENT_ZERO_DIV = 5, - EVENT_SIGNAL = 6, - EVENT_START = 7, -}; -typedef enum EVENT_TYPE EVENT_TYPE; - - -struct RDB_EVENT { - int status; - int taskId; - EVENT_TYPE eventType; - int sigType; -}; -typedef struct RDB_EVENT RDB_EVENT; - - -struct TASK_START { - int status; - int pid; -}; -typedef struct TASK_START TASK_START; - - -struct SYMBOL_ADDR { - int status; - u_int addr; -}; -typedef struct SYMBOL_ADDR SYMBOL_ADDR; - -struct SOURCE_STEP { - int taskId; - u_int startAddr; - u_int endAddr; -}; -typedef struct SOURCE_STEP SOURCE_STEP; - -#define MAX_ARG_CNT 10 -#define MAX_FUNC_ARGS 100 -#define MAX_ARG_LEN 100 - -bool_t xdr_arg_info(); -bool_t xdr_EVENT_TYPE(); -bool_t xdr_RDB_EVENT(); -bool_t xdr_TASK_START(); -bool_t xdr_SYMBOL_ADDR(); -bool_t xdr_SOURCE_STEP(); - -#define RDBPROG (u_long) 0x44444444 -#define RDBVERS (u_long) 1 -#endif INCxdrrdbh diff --git a/gdb/vx-share/xdr_regs.c b/gdb/vx-share/xdr_regs.c deleted file mode 100644 index 9152423142b..00000000000 --- a/gdb/vx-share/xdr_regs.c +++ /dev/null @@ -1,216 +0,0 @@ -/* xdr_regs.c - xdr routines for 68k registers */ - -/* Copyright 1984,1985,1986,1987,1988,1989 Wind River Systems, Inc. */ - -/* -DESCRIPTION -This module contains the eXternal Data Representation (XDR) routines -for the GDB interface for VxWorks. -*/ - -#include -#include -#include -#include - - -#ifdef I80960 -/******************************************************************************* -* -* xdr_regs - xdr routine for i960 registers -*/ - -bool_t xdr_regs (xdrs, objp) - XDR *xdrs; - struct regs *objp; - - { - if (! xdr_opaque(xdrs, (char *) objp->r_lreg, 16 * sizeof(int))) - return(FALSE); - if (! xdr_opaque(xdrs, (char *) objp->r_greg, 16 * sizeof(int))) - return(FALSE); - if (! xdr_opaque(xdrs, (char *) &objp->r_pcw, sizeof(int))) - return(FALSE); - if (! xdr_opaque(xdrs, (char *) &objp->r_acw, sizeof(int))) - return(FALSE); - if (! xdr_opaque(xdrs, (char *) &objp->r_tcw, sizeof(int))) - return(FALSE); - - return(TRUE); - } - -/******************************************************************************* -* -* xdr_fp_status - xdr routine for i960 floating point registers -*/ - -bool_t xdr_fp_status (xdrs, objp) - XDR *xdrs; - struct fp_status *objp; - - { - unsigned int size = 4 * FP_REG_SIZE; - - /* We use xdr_bytes to indicate how many bytes of FP regs there are! */ - if (! xdr_bytes (xdrs, (char *) objp->fps_regs, &size, 4 * FP_REG_SIZE)) - return (FALSE); - return (TRUE); - } - -/******************************************************************************* -* -* xdr_ext_fp - xdr for a single fp register -*/ - -bool_t xdr_ext_fp (xdrs, objp) - XDR *xdrs; - char *objp; - - { - unsigned int size = FP_REG_SIZE; - - if (! xdr_bytes (xdrs, objp, &size, FP_REG_SIZE)) - return(FALSE); - - return(TRUE); - } -#else /* Must be 68K if it isn't i960 -- for now. FIXME! */ - -/******************************************************************************* -* -* xdr_regs - xdr routine for 68k registers -*/ - -bool_t xdr_regs (xdrs, objp) - XDR *xdrs; - struct regs *objp; - - { - if (! xdr_opaque(xdrs, (char *) objp->r_dreg, 8 * sizeof(int))) - return(FALSE); - if (! xdr_opaque(xdrs, (char *) objp->r_areg, 8 * sizeof(int))) - return(FALSE); - if (! xdr_opaque(xdrs, (char *) &objp->r_sr, sizeof(int))) - return(FALSE); - if (! xdr_opaque(xdrs, (char *) &objp->r_pc, sizeof(int))) - return(FALSE); - - return(TRUE); - } - -/******************************************************************************* -* -* xdr_ext_fp - xdr for a single fp register -*/ - -bool_t xdr_ext_fp (xdrs, objp) - XDR *xdrs; - ext_fp *objp; - - { - if (! xdr_vector(xdrs, (char *) objp->fp, 3, sizeof(int), xdr_int)) - return(FALSE); - - return(TRUE); - } -/******************************************************************************* -* -* xdr_fp_status - xdr routine for floating point registers -*/ - -bool_t xdr_fp_status (xdrs, objp) - XDR *xdrs; - struct fp_status *objp; - - { - if (! xdr_vector (xdrs, (char *) objp->fps_regs, 8, - sizeof(ext_fp), xdr_ext_fp)) - return (FALSE); - if (! xdr_int (xdrs, &objp->fps_control)) - return (FALSE); - if (! xdr_int (xdrs, &objp->fps_status)) - return (FALSE); - if (! xdr_int (xdrs, &objp->fps_iaddr)) - return (FALSE); - if (! xdr_int (xdrs, &objp->fps_code)) - return (FALSE); - if (! xdr_int (xdrs, &objp->fps_flags)) - return (FALSE); - - return (TRUE); - } -/******************************************************************************* -* -* xdr_fpa_status - xdr for fpa status -*/ - -bool_t xdr_fpa_status (xdrs, objp) - XDR *xdrs; - struct fpa_status *objp; - - { - if (! xdr_u_int (xdrs, &objp->fpas_state)) - return (FALSE); - if (! xdr_u_int (xdrs, &objp->fpas_imask)) - return (FALSE); - if (! xdr_u_int (xdrs, &objp->fpas_load_ptr)) - return (FALSE); - if (! xdr_u_int (xdrs, &objp->fpas_ierr)) - return (FALSE); - if (! xdr_u_int (xdrs, &objp->fpas_act_instr)) - return (FALSE); - if (! xdr_u_int (xdrs, &objp->fpas_nxt_instr)) - return (FALSE); - if (! xdr_u_int (xdrs, &objp->fpas_act_d1half)) - return (FALSE); - if (! xdr_u_int (xdrs, &objp->fpas_act_d2half)) - return (FALSE); - if (! xdr_u_int (xdrs, &objp->fpas_nxt_d1half)) - return (FALSE); - if (! xdr_u_int (xdrs, &objp->fpas_nxt_d2half)) - return (FALSE); - if (! xdr_u_int (xdrs, &objp->fpas_mode3_0)) - return (FALSE); - if (! xdr_u_int (xdrs, &objp->fpas_wstatus)) - return (FALSE); - - return (TRUE); - } -/******************************************************************************* -* -* xdr_fpa_long - xdr for fpa data register -*/ - -bool_t xdr_fpa_long (xdrs,objp) - XDR *xdrs; - fpa_long *objp; - - { - if (! xdr_vector (xdrs, (char *) objp->fpl_data, 2, sizeof(int), xdr_int)) - return (FALSE); - - return (TRUE); - } -/******************************************************************************* -* -* xdr_fpa_regs - xdr for fpa_regs -*/ - -bool_t xdr_fpa_regs (xdrs, objp) - XDR *xdrs; - struct fpa_regs *objp; - - { - if (! xdr_u_int (xdrs, &objp->fpar_flags)) - return (FALSE); - if (! xdr_fpa_status (xdrs, &objp->fpar_status)) - return (FALSE); - if (! xdr_vector (xdrs, (char *) objp->fpar_data, - FPA_NDATA_REGS, sizeof(fpa_long), xdr_fpa_long)) - return (FALSE); - - return (TRUE); - } - -#endif /* I80960 */ - diff --git a/gdb/vx-share/xdr_regs.h b/gdb/vx-share/xdr_regs.h deleted file mode 100644 index c829d643493..00000000000 --- a/gdb/vx-share/xdr_regs.h +++ /dev/null @@ -1,16 +0,0 @@ -/* xdr_regs.h - xdr header for 68k registers */ - -/* -modification history --------------------- -01a,05jun90,llk extracted from xdr_regs.h. -*/ - -/* xdr structures are defined in reg.h (a bad place for them, i might add) */ - -bool_t xdr_regs(); -bool_t xdr_ext_fp(); -bool_t xdr_fp_status(); -bool_t xdr_fpa_status(); -bool_t xdr_fpa_long(); -bool_t xdr_fpa_regs(); diff --git a/gdb/xcoffexec.c b/gdb/xcoffexec.c deleted file mode 100644 index f1bd3d8ddc3..00000000000 --- a/gdb/xcoffexec.c +++ /dev/null @@ -1,932 +0,0 @@ -/* Execute AIXcoff files, for GDB. - Copyright (C) 1988, 1989, 1991 Free Software Foundation, Inc. - Derived from exec.c. Modified by IBM Corporation. - Donated by IBM Corporation and 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* xcoff-exec - deal with executing XCOFF files. */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "defs.h" -#include "param.h" -#include "frame.h" -#include "inferior.h" -#include "target.h" -#include "gdbcmd.h" -#include "gdbcore.h" -#include "symfile.h" - -#include "libbfd.h" /* BFD internals (sigh!) FIXME */ - -struct section_table *exec_sections, *exec_sections_end; - -#define eq(s0, s1) !strcmp(s0, s1) - -/* Whether to open exec and core files read-only or read-write. */ - -int write_files = 0; - -bfd *exec_bfd; /* needed by core.c */ - -extern char *getenv(); -extern void child_create_inferior (), child_attach (); -extern void add_syms_addr_command (); -extern void symbol_file_command (); -static void exec_files_info(); - -/* - * the vmap struct is used to describe the virtual address space of - * the target we are manipulating. The first entry is always the "exec" - * file. Subsequent entries correspond to other objects that are - * mapped into the address space of a process created from the "exec" file. - * These are either in response to exec()ing the file, in which case all - * shared libraries are loaded, or a "load" system call, followed by the - * user's issuance of a "load" command. - */ -struct vmap { - struct vmap *nxt; /* ^ to next in chain */ - bfd *bfd; /* BFD for mappable object library */ - char *name; /* ^ to object file name */ - char *member; /* ^ to member name */ - CORE_ADDR tstart; /* virtual addr where member is mapped */ - CORE_ADDR tend; /* virtual upper bound of member */ - CORE_ADDR tadj; /* heuristically derived adjustment */ - CORE_ADDR dstart; /* virtual address of data start */ - CORE_ADDR dend; /* vitrual address of data end */ -}; - - -struct vmap_and_bfd { - bfd *pbfd; - struct vmap *pvmap; -}; - -static struct vmap *vmap; /* current vmap */ - -extern struct target_ops exec_ops; - - -/* exec_close - done with exec file, clean up all resources. */ - -void -exec_close(quitting) { - register struct vmap *vp, *nxt; - - for (nxt = vmap; vp = nxt; ) { - nxt = vp->nxt; - bfd_close(vp->bfd); - free_named_symtabs(vp->name, vp->member); /* XXX */ - free(vp); - } - - vmap = 0; - exec_bfd = 0; -} - -/* - * exec_file_command - handle the "exec" command, &c. - */ -void -exec_file_command(filename, from_tty) -char *filename; -{ - bfd *bfd; - - target_preopen(from_tty); - unpush_target(&exec_ops); - - /* Now open and digest the file the user requested, if any. */ - - if (filename) { - char *scratch_pathname; - int scratch_chan; - - filename = tilde_expand(filename); - make_cleanup(free, filename); - - scratch_chan = openp(getenv("PATH"), 1, filename, O_RDONLY, 0 - , &scratch_pathname); - if (scratch_chan < 0) - perror_with_name(filename); - - bfd = bfd_fdopenr(scratch_pathname, NULL, scratch_chan); - if (!bfd) - error("Could not open `%s' as an executable file: %s" - , scratch_pathname, bfd_errmsg(bfd_error)); - - /* make sure we have an object file */ - - if (!bfd_check_format(bfd, bfd_object)) - error("\"%s\": not in executable format: %s." - , scratch_pathname, bfd_errmsg(bfd_error)); - - - /* setup initial vmap */ - - map_vmap (bfd, 0); - if (!vmap) - error("Can't find the file sections in `%s': %s" - , bfd->filename, bfd_errmsg(bfd_error)); - - exec_bfd = bfd; - - if (build_section_table (exec_bfd, &exec_sections, &exec_sections_end)) - error ("Can't find the file sections in `%s': %s", - exec_bfd->filename, bfd_errmsg (bfd_error)); - - /* make sure core, if present, matches */ - validate_files(); - - push_target(&exec_ops); - - /* Tell display code(if any) about the changed file name. */ - - if (exec_file_display_hook) - (*exec_file_display_hook)(filename); - } - else { - exec_close(0); /* just in case */ - if (from_tty) - printf("No exec file now.\n"); - } -} - -/* Set both the exec file and the symbol file, in one command. What a - * novelty. Why did GDB go through four major releases before this - * command was added? - */ -void -file_command(arg, from_tty) -char *arg; { - - exec_file_command(arg, from_tty); - symbol_file_command(arg, from_tty); -} - -/* Locate all mappable sections of a BFD file. - table_pp_char is a char * to get it through bfd_map_over_sections; - we cast it back to its proper type. */ - -void -add_to_section_table (abfd, asect, table_pp_char) - bfd *abfd; - sec_ptr asect; - char *table_pp_char; -{ - struct section_table **table_pp = (struct section_table **)table_pp_char; - flagword aflag; - - aflag = bfd_get_section_flags (abfd, asect); - /* FIXME, we need to handle BSS segment here...it alloc's but doesn't load */ - if (!(aflag & SEC_LOAD)) - return; - (*table_pp)->sec_ptr = asect; - (*table_pp)->addr = bfd_section_vma (abfd, asect); - (*table_pp)->endaddr = (*table_pp)->addr + bfd_section_size (abfd, asect); - (*table_pp)++; -} - -int -build_section_table (some_bfd, start, end) - bfd *some_bfd; - struct section_table **start, **end; -{ - unsigned count; - - count = bfd_count_sections (some_bfd); - if (count == 0) - abort(); /* return 1? */ - if (*start) - free (*start); - *start = (struct section_table *) xmalloc (count * sizeof (**start)); - *end = *start; - bfd_map_over_sections (some_bfd, add_to_section_table, (char *)end); - if (*end > *start + count) - abort(); - /* We could realloc the table, but it probably loses for most files. */ - return 0; -} - -/* - * lookup_symtab_bfd - find if we currently have any symbol tables from bfd - */ -struct objfile * -lookup_objfile_bfd(bfd *bfd) { - register struct objfile *s; - - for (s = object_files; s; s = s->next) - if (s->obfd == bfd) - return s; - return 0; -} - - -void -sex_to_vmap(bfd *bf, sec_ptr sex, struct vmap_and_bfd *vmap_bfd) -{ - register struct vmap *vp, **vpp; - register struct symtab *syms; - bfd *arch = vmap_bfd->pbfd; - vp = vmap_bfd->pvmap; - - if ((bfd_get_section_flags(bf, sex) & SEC_LOAD) == 0) - return; - - if (!strcmp(bfd_section_name(bf, sex), ".text")) { - vp->tstart = 0; - vp->tend = vp->tstart + bfd_section_size(bf, sex); - - /* This is quite a tacky way to recognize the `exec' load segment (rather - than shared libraries. You should use `arch' instead. FIXMEmgo */ - if (!vmap) - vp->tadj = sex->filepos - bfd_section_vma(bf, sex); - else - vp->tadj = 0; - } - - else if (!strcmp(bfd_section_name(bf, sex), ".data")) { - vp->dstart = 0; - vp->dend = vp->dstart + bfd_section_size(bf, sex); - } - - else if (!strcmp(bfd_section_name(bf, sex), ".bss")) /* FIXMEmgo */ - printf ("bss section in exec! Don't know what the heck to do!\n"); -} - -/* Make a vmap for the BFD "bf", which might be a member of the archive - BFD "arch". If we have not yet read in symbols for this file, do so. */ - -map_vmap (bfd *bf, bfd *arch) -{ - struct vmap_and_bfd vmap_bfd; - struct vmap *vp, **vpp; - struct objfile *obj; - char *name; - - vp = (void*) xmalloc (sizeof (*vp)); - vp->nxt = 0; - vp->bfd = bf; - vp->name = bfd_get_filename(arch ? arch : bf); - vp->member = arch ? bfd_get_filename(bf) : ""; - - vmap_bfd.pbfd = arch; - vmap_bfd.pvmap = vp; - bfd_map_over_sections (bf, sex_to_vmap, &vmap_bfd); - - obj = lookup_objfile_bfd (bf); - if (exec_bfd && !obj) { - name = savestring (bfd_get_filename (bf), strlen (bfd_get_filename (bf))); - obj = allocate_objfile (bf, name); - syms_from_objfile (obj, 0, 0); - } - - /* find the end of the list, and append. */ - for (vpp = &vmap; *vpp; vpp = &(*vpp)->nxt) - ; - *vpp = vp; -} - - -/* true, if symbol table and misc_function_vector is relocated. */ - -int symtab_relocated = 0; - - -/* vmap_symtab - handle symbol translation on vmapping */ - -vmap_symtab(vp, old_start, vip) -register struct vmap *vp; -CORE_ADDR old_start; -struct stat *vip; -{ - register struct symtab *s; - - /* - * for each symbol table generated from the vp->bfd - */ - for (s = symtab_list; s; s = s->next) { - - /* skip over if this is not relocatable and doesn't have a line table */ - if (s->nonreloc && !LINETABLE (s)) - continue; - - /* matching the symbol table's BFD and the *vp's BFD is hairy. - exec_file creates a seperate BFD for possibly the - same file as symbol_file.FIXME ALL THIS MUST BE RECTIFIED. */ - - if (s->objfile->obfd == vp->bfd) { - /* if they match, we luck out. */ - ; - } else if (vp->member[0]) { - /* no match, and member present, not this one. */ - continue; - } else { - struct stat si; - FILE *io; - - /* - * no match, and no member. need to be sure. - */ - io = bfd_cache_lookup(s->objfile->obfd); - if (!io) - fatal("cannot find BFD's iostream for sym"); - /* - * see if we are referring to the same file - */ - if (fstat(fileno(io), &si) < 0) - fatal("cannot fstat BFD for sym"); - - if (si.st_dev != vip->st_dev - || si.st_ino != vip->st_ino) - continue; - } - - if (vp->tstart != old_start) - vmap_symtab_1(s, vp, old_start); - } - - if (vp->tstart != old_start) - fixup_misc_vector (vp->tstart - old_start); - - symtab_relocated = 1; -} - - -fixup_misc_vector (int disp) -{ - int ii; - for (ii=0; ii < misc_function_count; ++ii) - if (misc_function_vector[ii].address < 0x10000000) - misc_function_vector[ii].address += disp; -} - - -vmap_symtab_1(s, vp, old_start) -register struct symtab *s; -register struct vmap *vp; -CORE_ADDR old_start; -{ - register int i, j; - int len, blen; - register struct linetable *l; - struct blockvector *bv; - register struct block *b; - int depth; - register ulong reloc, dreloc; - - if ((reloc = vp->tstart - old_start) == 0) - return; - - dreloc = vp->dstart; /* data relocation */ - - /* - * The line table must be relocated. This is only present for - * b.text sections, so only vp->text type maps need be considered. - */ - l = LINETABLE (s); - len = l->nitems; - for (i = 0; i < len; i++) - l->item[i].pc += reloc; - - /* if this symbol table is not relocatable, only line table should - be relocated and the rest ignored. */ - if (s->nonreloc) - return; - - bv = BLOCKVECTOR(s); - len = BLOCKVECTOR_NBLOCKS(bv); - - for (i = 0; i < len; i++) { - b = BLOCKVECTOR_BLOCK(bv, i); - - BLOCK_START(b) += reloc; - BLOCK_END(b) += reloc; - - blen = BLOCK_NSYMS(b); - for (j = 0; j < blen; j++) { - register struct symbol *sym; - - sym = BLOCK_SYM(b, j); - switch (SYMBOL_NAMESPACE(sym)) { - case STRUCT_NAMESPACE: - case UNDEF_NAMESPACE: - continue; - - case LABEL_NAMESPACE: - case VAR_NAMESPACE: - break; - } - - switch (SYMBOL_CLASS(sym)) { - case LOC_CONST: - case LOC_CONST_BYTES: - case LOC_LOCAL: - case LOC_REGISTER: - case LOC_ARG: - case LOC_LOCAL_ARG: - case LOC_REF_ARG: - case LOC_REGPARM: - case LOC_TYPEDEF: - continue; - -#ifdef FIXME - case LOC_EXTERNAL: -#endif - case LOC_LABEL: - SYMBOL_VALUE_ADDRESS(sym) += reloc; - break; - - case LOC_STATIC: - SYMBOL_VALUE_ADDRESS(sym) += dreloc; - break; - - case LOC_BLOCK: - break; - - default: - fatal("botched symbol class %x" - , SYMBOL_CLASS(sym)); - break; - } - } - } -} - -/* - * add_vmap - add a new vmap entry based on ldinfo() information - */ -add_vmap(ldi) -register struct ld_info *ldi; { - bfd *bfd, *last; - register char *mem; - - mem = ldi->ldinfo_filename + strlen(ldi->ldinfo_filename) + 1; - bfd = bfd_fdopenr(ldi->ldinfo_filename, NULL, ldi->ldinfo_fd); - if (!bfd) - error("Could not open `%s' as an executable file: %s" - , ldi->ldinfo_filename, bfd_errmsg(bfd_error)); - - - /* make sure we have an object file */ - - if (bfd_check_format(bfd, bfd_object)) - map_vmap (bfd, 0); - - else if (bfd_check_format(bfd, bfd_archive)) { - last = 0; - /* - * FIXME??? am I tossing BFDs? bfd? - */ - while (last = bfd_openr_next_archived_file(bfd, last)) - if (eq(mem, last->filename)) - break; - - if (!last) { - bfd_close(bfd); -/* FIXME -- should be error */ - warning("\"%s\": member \"%s\" missing.", - bfd->filename, mem); - return; - } - - if (!bfd_check_format(last, bfd_object)) { - bfd_close(last); /* XXX??? */ - goto obj_err; - } - - map_vmap (last, bfd); - } - else { - obj_err: - bfd_close(bfd); -/* FIXME -- should be error */ - warning("\"%s\": not in executable format: %s." - , ldi->ldinfo_filename, bfd_errmsg(bfd_error)); - return; - } -} - - -/* As well as symbol tables, exec_sections need relocation. Otherwise after - the inferior process terminates, symbol table is relocated but there is - no inferior process. Thus, we have to use `exec' bfd, rather than the inferior - process's memory space, when lookipng at symbols. - `exec_sections' need to be relocated only once though, as long as the exec - file was not changed. -*/ -vmap_exec () -{ - static bfd *execbfd; - if (execbfd == exec_bfd) - return; - - execbfd = exec_bfd; - - if (!vmap || !exec_sections) { - printf ("WARNING: vmap not found in vmap_exec()!\n"); - return; - } - /* First exec section is `.text', second is `.data'. If this is changed, - then this routine will choke. Better you should check section names, - FIXMEmgo. */ - exec_sections [0].addr += vmap->tstart; - exec_sections [0].endaddr += vmap->tstart; - exec_sections [1].addr += vmap->dstart; - exec_sections [1].endaddr += vmap->dstart; -} - - -int -text_adjustment (abfd) -bfd *abfd; -{ - static bfd *execbfd; - static int adjustment; - sec_ptr sect; - - if (exec_bfd == execbfd) - return adjustment; - - sect = bfd_get_section_by_name (abfd, ".text"); - if (sect) - adjustment = sect->filepos - sect->vma; - else - adjustment = 0x200; /* just a wild assumption */ - - return adjustment; -} - - -/* - * vmap_ldinfo - update VMAP info with ldinfo() information - * - * Input: - * ldi - ^ to ldinfo() results. - */ -vmap_ldinfo(ldi) -register struct ld_info *ldi; -{ - struct stat ii, vi; - register struct vmap *vp; - register got_one, retried; - CORE_ADDR ostart; - - /* - * for each *ldi, see if we have a corresponding *vp - * if so, update the mapping, and symbol table. - * if not, add an entry and symbol table. - */ - do { - char *name = ldi->ldinfo_filename; - char *memb = name + strlen(name) + 1; - - retried = 0; - - if (fstat(ldi->ldinfo_fd, &ii) < 0) - fatal("cannot fstat(%d) on %s" - , ldi->ldinfo_fd - , name); -retry: - for (got_one = 0, vp = vmap; vp; vp = vp->nxt) { - FILE *io; - - /* The filenames are not always sufficient to match on. */ - if ((name[0] == "/" - && !eq(name, vp->name)) - || (memb[0] && !eq(memb, vp->member))) - continue; - - /* totally opaque! */ - io = bfd_cache_lookup(vp->bfd); - if (!io) - fatal("cannot find BFD's iostream for %s" - , vp->name); - - /* see if we are referring to the same file */ - if (fstat(fileno(io), &vi) < 0) - fatal("cannot fstat BFD for %s", vp->name); - - if (ii.st_dev != vi.st_dev || ii.st_ino != vi.st_ino) - continue; - - if (!retried) - close(ldi->ldinfo_fd); - - ++got_one; - - /* found a corresponding VMAP. remap! */ - ostart = vp->tstart; - - vp->tstart = ldi->ldinfo_textorg; - vp->tend = vp->tstart + ldi->ldinfo_textsize; - vp->dstart = ldi->ldinfo_dataorg; - vp->dend = vp->dstart + ldi->ldinfo_datasize; - - if (vp->tadj) { - vp->tstart += vp->tadj; - vp->tend += vp->tadj; - } - - /* relocate symbol table(s). */ - vmap_symtab(vp, ostart, &vi); - - /* there may be more, so we don't break out of the loop. */ - } - - /* - * if there was no matching *vp, we must perforce create - * the sucker(s) - */ - if (!got_one && !retried) { - add_vmap(ldi); - ++retried; - goto retry; - } - } while (ldi->ldinfo_next - && (ldi = (void *) (ldi->ldinfo_next + (char *) ldi))); - - breakpoint_re_set(); -} - -/* - * vmap_inferior - print VMAP info for inferior - */ -vmap_inferior() { - - if (inferior_pid == 0) - return 0; /* normal processing */ - - exec_files_info(); - - return 1; -} - -/* Read or write the exec file. - - Args are address within exec file, address within gdb address-space, - length, and a flag indicating whether to read or write. - - Result is a length: - - 0: We cannot handle this address and length. - > 0: We have handled N bytes starting at this address. - (If N == length, we did it all.) We might be able - to handle more bytes beyond this length, but no - promises. - < 0: We cannot handle this address, but if somebody - else handles (-N) bytes, we can start from there. - - The same routine is used to handle both core and exec files; - we just tail-call it with more arguments to select between them. */ - -int -xfer_memory (memaddr, myaddr, len, write, abfd, sections, sections_end) - CORE_ADDR memaddr; - char *myaddr; - int len; - int write; - bfd *abfd; - struct section_table *sections, *sections_end; -{ - boolean res; - struct section_table *p; - CORE_ADDR nextsectaddr, memend; - boolean (*xfer_fn) (); - - if (len <= 0) - abort(); - - memend = memaddr + len; - xfer_fn = write? bfd_set_section_contents: bfd_get_section_contents; - nextsectaddr = memend; - - for (p = sections; p < sections_end; p++) - { - if (p->addr <= memaddr) - if (p->endaddr >= memend) - { - /* Entire transfer is within this section. */ - res = xfer_fn (abfd, p->sec_ptr, myaddr, memaddr - p->addr, len); - return (res != false)? len: 0; - } - else if (p->endaddr <= memaddr) - { - /* This section ends before the transfer starts. */ - continue; - } - else - { - /* This section overlaps the transfer. Just do half. */ - len = p->endaddr - memaddr; - res = xfer_fn (abfd, p->sec_ptr, myaddr, memaddr - p->addr, len); - return (res != false)? len: 0; - } - else if (p->addr < nextsectaddr) - nextsectaddr = p->addr; - } - - if (nextsectaddr >= memend) - return 0; /* We can't help */ - else - return - (nextsectaddr - memaddr); /* Next boundary where we can help */ -} - -/* The function called by target_xfer_memory via our target_ops */ - -int -exec_xfer_memory (memaddr, myaddr, len, write) - CORE_ADDR memaddr; - char *myaddr; - int len; - int write; -{ - return xfer_memory (memaddr, myaddr, len, write, - exec_bfd, exec_sections, exec_sections_end); -} - -/* - * exec_files_info - "info files" command processor - */ -static void -exec_files_info() { - register struct vmap *vp = vmap; - - if (!vp) - return; - - printf("\tMapping info for file `%s'.\n", vp->name); - printf("\t %8.8s %8.8s %8.8s %s\n" - , "start", "end", "section", "file(member)"); - - for (; vp; vp = vp->nxt) - printf("\t0x%8.8x 0x%8.8x %s%s%s%s\n" - , vp->tstart - , vp->tend - , vp->name - , *vp->member ? "(" : "" - , vp->member - , *vp->member ? ")" : ""); -} - -#ifdef DAMON - Damon's implementation of set_section_command! It is based on the sex member - (which is a section pointer from vmap) of vmap. - We will not have multiple vmap entries (one for each section), rather transmit - text and data base offsets and fix them at the same time. Elimination of sex - entry in vmap make this function obsolute, use the one from exec.c. - Need further testing!! FIXMEmgo. - -static void -set_section_command(args, from_tty) -char *args; -{ - register struct vmap *vp = vmap; - char *secname; - unsigned seclen; - unsigned long secaddr; - char secprint[100]; - long offset; - - if (args == 0) - error("Must specify section name and its virtual address"); - - /* Parse out section name */ - for (secname = args; !isspace(*args); args++) - ; - seclen = args - secname; - - /* Parse out new virtual address */ - secaddr = parse_and_eval_address(args); - - for (vp = vmap; vp; vp = vp->nxt) { - if (!strncmp(secname - , bfd_section_name(vp->bfd, vp->sex), seclen) - && bfd_section_name(vp->bfd, vp->sex)[seclen] == '\0') { - offset = secaddr - vp->tstart; - vp->tstart += offset; - vp->tend += offset; - exec_files_info(); - return; - } - } - - if (seclen >= sizeof(secprint)) - seclen = sizeof(secprint) - 1; - strncpy(secprint, secname, seclen); - secprint[seclen] = '\0'; - error("Section %s not found", secprint); -} -#else -static void -set_section_command (args, from_tty) - char *args; - int from_tty; -{ - struct section_table *p; - char *secname; - unsigned seclen; - unsigned long secaddr; - char secprint[100]; - long offset; - - if (args == 0) - error ("Must specify section name and its virtual address"); - - /* Parse out section name */ - for (secname = args; !isspace(*args); args++) ; - seclen = args - secname; - - /* Parse out new virtual address */ - secaddr = parse_and_eval_address (args); - - for (p = exec_sections; p < exec_sections_end; p++) { - if (!strncmp (secname, bfd_section_name (exec_bfd, p->sec_ptr), seclen) - && bfd_section_name (exec_bfd, p->sec_ptr)[seclen] == '\0') { - offset = secaddr - p->addr; - p->addr += offset; - p->endaddr += offset; - exec_files_info(); - return; - } - } - if (seclen >= sizeof (secprint)) - seclen = sizeof (secprint) - 1; - strncpy (secprint, secname, seclen); - secprint[seclen] = '\0'; - error ("Section %s not found", secprint); -} - -#endif /* !DAMON */ - -struct target_ops exec_ops = { - "exec", "Local exec file", - "Use an executable file as a target.\n\ -Specify the filename of the executable file.", - exec_file_command, exec_close, /* open, close */ - child_attach, 0, 0, 0, /* attach, detach, resume, wait, */ - 0, 0, /* fetch_registers, store_registers, */ - 0, 0, 0, /* prepare_to_store, conv_to, conv_from, */ - exec_xfer_memory, exec_files_info, - 0, 0, /* insert_breakpoint, remove_breakpoint, */ - 0, 0, 0, 0, 0, /* terminal stuff */ - 0, 0, /* kill, load */ - 0, 0, /* call fn, lookup sym */ - child_create_inferior, - 0, /* mourn_inferior */ - file_stratum, 0, /* next */ - 0, 1, 0, 0, 0, /* all mem, mem, stack, regs, exec */ - 0, 0, /* section pointers */ - OPS_MAGIC, /* Always the last thing */ -}; - - -void -_initialize_exec() -{ - - add_com("file", class_files, file_command, - "Use FILE as program to be debugged.\n\ -It is read for its symbols, for getting the contents of pure memory,\n\ -and it is the program executed when you use the `run' command.\n\ -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."); - - add_com("exec-file", class_files, exec_file_command, - "Use FILE as program for getting contents of pure memory.\n\ -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."); - - add_com("section", class_files, set_section_command, - "Change the base address of section SECTION of the exec file to ADDR.\n\ -This can be used if the exec file does not contain section addresses,\n\ -(such as in the a.out format), or when the addresses specified in the\n\ -file itself are wrong. Each section must be changed separately. The\n\ -``info files'' command lists all the sections and their addresses."); - - add_target(&exec_ops); -} diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c deleted file mode 100644 index 912c9d11ae9..00000000000 --- a/gdb/xcoffread.c +++ /dev/null @@ -1,1506 +0,0 @@ -/* Read AIXcoff symbol tables and convert to internal format, for GDB. - Copyright (C) 1986-1991 Free Software Foundation, Inc. - Derived from coffread.c, dbxread.c, and a lot of hacking. - Contributed by IBM Corporation. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include "defs.h" -#include "bfd.h" -#include "param.h" - -#include - -/* AIX COFF names have a preceeding dot `.' */ -#define NAMES_HAVE_DOT 1 - -#include -#include -#include - -#include "obstack.h" -#include -#include -#include - -#include "symtab.h" -#include "symfile.h" -#include "buildsym.h" - -#include "internalcoff.h" /* FIXME, internal data from BFD */ -#include "libcoff.h" /* FIXME, internal data from BFD */ -#include "coff-rs6000.h" /* FIXME, raw file-format guts of xcoff */ - -extern char *index(); - -static void enter_line_range (); -static struct symbol *process_xcoff_symbol (); -static int read_symbol_nvalue (); -static int read_symbol_lineno (); - - -/* Simplified internal version of coff symbol table information */ - -struct coff_symbol { - char *c_name; - int c_symnum; /* symbol number of this entry */ - int c_nsyms; /* 0 if syment only, 1 if syment + auxent */ - long c_value; - int c_sclass; - int c_secnum; - unsigned int c_type; -}; - -/* The COFF line table, in raw form. */ -static char *linetab = NULL; /* Its actual contents */ -static long linetab_offset; /* Its offset in the file */ -static unsigned long linetab_size; /* Its size */ - -/* last function's saved coff symbol `cs' */ - -static struct coff_symbol fcn_cs_saved; - -static bfd *symfile_bfd; - -/* Core address of start and end of text of current source file. - This is calculated from the first function seen after a C_FILE - symbol. */ - -static CORE_ADDR cur_src_start_addr; -static CORE_ADDR cur_src_end_addr; - -/* Core address of the end of the first object file. */ - -static CORE_ADDR first_object_file_end; - -/* pointer to the string table */ -static char *strtbl; - -/* length of the string table */ -static int strtbl_len; - -/* pointer to debug section */ -static char *debugsec; - -/* pointer to the a.out symbol table */ -static char *symtbl; - -/* initial symbol-table-debug-string vector length */ - -#define INITIAL_STABVECTOR_LENGTH 40 - -struct pending_stabs *global_stabs; -struct pending_stabs *file_stabs; - -/* Nonzero if within a function (so symbols should be local, - if nothing says specifically). */ - -int within_function; - -/* Local variables that hold the shift and mask values for the - COFF file that we are currently reading. These come back to us - from BFD, and are referenced by their macro names, as well as - internally to the BTYPE, ISPTR, ISFCN, ISARY, ISTAG, and DECREF - macros from ../internalcoff.h . */ - -static unsigned local_n_btshft; -static unsigned local_n_tmask; - -#undef N_BTSHFT -#define N_BTSHFT local_n_btshft -#undef N_TMASK -#define N_TMASK local_n_tmask - -/* Local variables that hold the sizes in the file of various COFF structures. - (We only need to know this to read them from the file -- BFD will then - translate the data in them, into `internal_xxx' structs in the right - byte order, alignment, etc.) */ - -static unsigned local_symesz; - -/* coff_symfile_init() - is the coff-specific initialization routine for reading symbols. - It is passed a struct sym_fns which contains, among other things, - the BFD for the file whose symbols are being read, and a slot for - a pointer to "private data" which we fill with cookies and other - treats for coff_symfile_read(). - - We will only be called if this is a COFF or COFF-like file. - BFD handles figuring out the format of the file, and code in symtab.c - uses BFD's determination to vector to us. - - The ultimate result is a new symtab (or, FIXME, eventually a psymtab). */ - -struct coff_symfile_info { - file_ptr min_lineno_offset; /* Where in file lowest line#s are */ - file_ptr max_lineno_offset; /* 1+last byte of line#s in file */ -}; - - -/* Call sort_syms to sort alphabetically - the symbols of each block of each symtab. */ - -static int -compare_symbols (s1, s2) -struct symbol **s1, **s2; -{ - /* Names that are less should come first. */ - register int namediff = strcmp (SYMBOL_NAME (*s1), SYMBOL_NAME (*s2)); - if (namediff != 0) - return namediff; - - /* For symbols of the same name, registers should come first. */ - return ((SYMBOL_CLASS (*s2) == LOC_REGISTER) - - (SYMBOL_CLASS (*s1) == LOC_REGISTER)); -} - - -/* Sort a vector of symbols by their value. */ - -static void -sort_syms () -{ - register struct symtab *s; - register int i, nbl; - register struct blockvector *bv; - register struct block *b; - - for (s = symtab_list; s; s = s->next) - { - bv = BLOCKVECTOR (s); - nbl = BLOCKVECTOR_NBLOCKS (bv); - for (i = 0; i < nbl; i++) - { - b = BLOCKVECTOR_BLOCK (bv, i); - if (BLOCK_SHOULD_SORT (b)) - qsort (&BLOCK_SYM (b, 0), BLOCK_NSYMS (b), - sizeof (struct symbol *), compare_symbols); - } - } -} - - -/* add a given stab string into given stab vector. */ - -static void -add_stab_to_list (stabname, stabvector) -char *stabname; -struct pending_stabs **stabvector; -{ - if ( *stabvector == NULL) { - *stabvector = (struct pending_stabs *) - xmalloc (sizeof (struct pending_stabs) + - INITIAL_STABVECTOR_LENGTH * sizeof (char*)); - (*stabvector)->count = 0; - (*stabvector)->length = INITIAL_STABVECTOR_LENGTH; - } - else if ((*stabvector)->count >= (*stabvector)->length) { - (*stabvector)->length += INITIAL_STABVECTOR_LENGTH; - *stabvector = (struct pending_stabs *) - xrealloc (*stabvector, sizeof (struct pending_stabs) + - (*stabvector)->length * sizeof (char*)); - } - (*stabvector)->stab [(*stabvector)->count++] = stabname; -} - - -/* for all the stabs in a given stab vector, build appropriate types - and fix their symbols in given symbol vector. */ - -void -patch_block_stabs (symbols, stabs) -struct pending *symbols; -struct pending_stabs *stabs; -{ - int ii; - - if (!stabs) - return; - - /* for all the stab entries, find their corresponding symbols and - patch their types! */ - - for (ii=0; ii < stabs->count; ++ii) { - char *name = stabs->stab[ii]; - char *pp = (char*) index (name, ':'); - struct symbol *sym = find_symbol_in_list (symbols, name, pp-name); - if (!sym) { - printf ("ERROR! stab symbol not found!\n"); /* FIXME */ - } - else { - pp += 2; - - if (*(pp-1) == 'F' || *(pp-1) == 'f') - SYMBOL_TYPE (sym) = lookup_function_type (read_type (&pp)); - else - SYMBOL_TYPE (sym) = read_type (&pp); - } - } -} - -/* Enter a given range of lines into the line vector. - can be called in the following two ways: - enter_line_range (subfile, beginoffset, endoffset, 0, firstLine) or - enter_line_range (subfile, beginoffset, 0, endaddr, firstLine) */ - -static void -enter_line_range (subfile, beginoffset, endoffset, endaddr, firstLine) - struct subfile *subfile; /* which sub-file to put line#s in */ - unsigned beginoffset, endoffset; /* offsets to line table */ - CORE_ADDR endaddr; - unsigned *firstLine; -{ - char *pp, *limit; - CORE_ADDR addr; - struct internal_lineno lptr; - unsigned local_linesz = coff_data (symfile_bfd)->local_linesz; - - pp = &linetab [beginoffset - linetab_offset]; - limit = endoffset ? &linetab [endoffset - linetab_offset] - : &linetab [linetab_size -1]; - - while (pp <= limit) { - - /* Swap and align this lineno entry into lptr. */ - bfd_coff_swap_lineno_in (symfile_bfd, pp, &lptr); - - /* find the address this line represents */ - addr = lptr.l_lnno ? - lptr.l_addr.l_paddr : read_symbol_nvalue (symtbl, lptr.l_addr.l_symndx); - - if (endaddr && addr >= endaddr) - return; - - if (lptr.l_lnno == 0) { - *firstLine = read_symbol_lineno (symtbl, lptr.l_addr.l_symndx); - --(*firstLine); - } - else - record_line (subfile, *firstLine + lptr.l_lnno, addr); - - pp += local_linesz; - } -} - - -/* Save the vital information for use when closing off the current file. - NAME is the file name the symbols came from, START_ADDR is the first - text address for the file, and SIZE is the number of bytes of text. */ - -#define complete_symtab(name, start_addr) { \ - last_source_file = savestring (name, strlen (name)); \ - cur_src_start_addr = start_addr; \ -} - - -/* Refill the symbol table input buffer - and set the variables that control fetching entries from it. - Reports an error if no data available. - This function can read past the end of the symbol table - (into the string table) but this does no harm. */ - -/* Reading symbol table has to be fast! Keep the followings as macros, rather - than functions. */ - -#define RECORD_MISC_FUNCTION(NAME, ADDR, TYPE, ALLOCED) \ -{ \ - char *namestr; \ - if (ALLOCED) \ - namestr = (NAME) + 1; \ - else { \ - namestr = obstack_copy0 (symbol_obstack, (NAME) + 1, strlen ((NAME)+1)); \ - (ALLOCED) = 1; \ - } \ - prim_record_misc_function (namestr, (ADDR), (TYPE)); \ - last_recorded_fun = (ADDR); \ -} - - - -/* aixcoff has static blocks marked in `.bs', `.es' pairs. They cannot be - nested. At any given time, a symbol can only be in one static block. - This is the base address of current static block, zero if non exists. */ - -static int static_block_base = 0; - -/* true if space for symbol name has been allocated. */ - -static int symname_alloced = 0; - -/* read the whole symbol table of a given bfd. */ - -void -read_xcoff_symtab (objfile, nsyms) - struct objfile *objfile; /* Object file we're reading from */ - int nsyms; /* # of symbols */ -{ - bfd *abfd = objfile->obfd; - /* char *symtbl; */ /* Raw symbol table base */ - char *raw_symbol; /* Pointer into raw seething symbol table */ - char *raw_auxptr; /* Pointer to first raw aux entry for sym */ - struct internal_syment symbol[1]; - union internal_auxent main_aux[1]; - struct coff_symbol cs[1]; - CORE_ADDR file_start_addr = 0; - CORE_ADDR file_end_addr = 0; - - int next_file_symnum = -1; - int just_started = 1; - int depth = 0; - int val; - int fcn_first_line; - int fcn_last_line; - int fcn_start_addr; - long fcn_line_offset; - size_t size; - - /* fcn_cs_saved is global because process_xcoff_symbol needs it. */ - union internal_auxent fcn_aux_saved; - struct context_stack *new; - - char *filestring = " _start_ "; /* Name of the current file. */ - char *last_seen_csect; - int last_recorded_fun = 0; /* last recorded fun. value */ - - /* Get the appropriate COFF "constants" related to the file we're handling. */ - N_TMASK = coff_data (abfd)->local_n_tmask; - N_BTSHFT = coff_data (abfd)->local_n_btshft; - local_symesz = coff_data (abfd)->local_symesz; - - last_source_file = 0; - last_seen_csect = 0; - last_recorded_fun = 0; - - start_symtab (filestring, (char *)NULL, file_start_addr); - symnum = 0; - first_object_file_end = 0; - - /* Allocate space for the entire symbol table at once, and read it - all in. The bfd is already positioned at the beginning of - the symbol table. */ - - size = coff_data (abfd)->local_symesz * nsyms; - symtbl = xmalloc (size); - - val = bfd_read (symtbl, size, 1, abfd); - if (val != size) - perror_with_name ("reading symbol table"); - - raw_symbol = symtbl; - - while (symnum < nsyms) { - - QUIT; /* make this command interruptable. */ - - /* READ_ONE_SYMBOL (symbol, cs, symname_alloced); */ - /* read one symbol into `cs' structure. After processing the whole symbol - table, only string table will be kept in memory, symbol table and debug - section of aixcoff will be freed. Thus we can mark symbols with names - in string table as `alloced'. */ - { - int ii; - - /* Swap and align the symbol into a reasonable C structure. */ - bfd_coff_swap_sym_in (abfd, raw_symbol, symbol); - - cs->c_symnum = symnum; - cs->c_nsyms = symbol->n_numaux; - if (symbol->n_zeroes) { - symname_alloced = 0; - /* We must use the original, unswapped, name here so the name field - pointed to by cs->c_name will persist throughout xcoffread. If - we use the new field, it gets overwritten for each symbol. */ - cs->c_name = ((struct external_syment *)raw_symbol)->e.e_name; - } else if (symbol->n_sclass & 0x80) { - cs->c_name = debugsec + symbol->n_offset; - symname_alloced = 0; - } else { /* in string table */ - cs->c_name = strtbl + (int)symbol->n_offset; - symname_alloced = 1; - } - cs->c_value = symbol->n_value; - cs->c_sclass = symbol->n_sclass & 0xff; - cs->c_secnum = symbol->n_scnum; - cs->c_type = (unsigned)symbol->n_type; - - raw_symbol += coff_data (abfd)->local_symesz; - ++symnum; - - raw_auxptr = raw_symbol; /* Save addr of first aux entry */ - - /* Skip all the auxents associated with this symbol. */ - for (ii = symbol->n_numaux; ii; --ii ) { - raw_symbol += coff_data (abfd)->local_auxesz; - ++symnum; - } - } - - /* if symbol name starts with ".$" or "$", ignore it. */ - if (cs->c_name[0] == '$' || (cs->c_name[1] == '$' && cs->c_name[0] == '.')) - continue; - - if (cs->c_symnum == next_file_symnum && cs->c_sclass != C_FILE) { - if (last_source_file) - end_symtab (cur_src_end_addr, 1, 1, objfile); - - start_symtab ("_globals_", (char *)NULL, (CORE_ADDR)0); - cur_src_end_addr = first_object_file_end; - /* done with all files, everything from here on is globals */ - } - - /* if explicitly specified as a function, treat is as one. */ - if (ISFCN(cs->c_type) && cs->c_sclass != C_TPDEF) { - bfd_coff_swap_aux_in (abfd, raw_auxptr, cs->c_type, cs->c_sclass, - main_aux); - goto function_entry_point; - } - - if ((cs->c_sclass == C_EXT || cs->c_sclass == C_HIDEXT) && cs->c_nsyms == 1) - { - /* dealing with a symbol with a csect entry. */ - -# define CSECT(PP) ((PP)->x_csect) -# define CSECT_LEN(PP) (CSECT(PP).x_scnlen) -# define CSECT_ALIGN(PP) (SMTYP_ALIGN(CSECT(PP).x_smtyp)) -# define CSECT_SMTYP(PP) (SMTYP_SMTYP(CSECT(PP).x_smtyp)) -# define CSECT_SCLAS(PP) (CSECT(PP).x_smclas) - - /* Convert the auxent to something we can access. */ - bfd_coff_swap_aux_in (abfd, raw_auxptr, cs->c_type, cs->c_sclass, - main_aux); - - switch (CSECT_SMTYP (main_aux)) { - - case XTY_ER : - continue; /* ignore all external references. */ - - case XTY_SD : /* a section description. */ - { - switch (CSECT_SCLAS (main_aux)) { - - case XMC_PR : /* a `.text' csect. */ - { - - /* A program csect is seen. - - We have to allocate one symbol table for each program csect. Normally - gdb prefers one symtab for each compilation unit (CU). In case of AIX, one - CU might include more than one prog csect, and they don't have to be - adjacent in terms of the space they occupy in memory. Thus, one single - CU might get fragmented in the memory and gdb's file start and end address - approach does not work! */ - - if (last_seen_csect) { - complete_symtab (filestring, file_start_addr); - cur_src_end_addr = file_end_addr; - end_symtab (file_end_addr, 1, 1, objfile); - start_symtab ((char *)NULL, (char *)NULL, (CORE_ADDR)0); - } - - /* If this is the very first csect seen, basically `__start'. */ - if (just_started) { - first_object_file_end = cs->c_value + CSECT_LEN (main_aux); - just_started = 0; - } - - file_start_addr = cs->c_value; - file_end_addr = cs->c_value + CSECT_LEN (main_aux); - - if (cs->c_name && cs->c_name[0] == '.') { - last_seen_csect = cs->c_name; - RECORD_MISC_FUNCTION (cs->c_name, cs->c_value, mf_text, symname_alloced); - } - } - continue; - - case XMC_RW : - break; - - /* If the section is not a data description, ignore it. Note that - uninitialized data will show up as XTY_CM/XMC_RW pair. */ - - case XMC_TC0: -#ifdef XCOFF_ADD_TOC_TO_LOADINFO - XCOFF_ADD_TOC_TO_LOADINFO (cs->c_value); -#endif - /* fall down to default case. */ - - case XMC_TC : /* ignore toc entries */ - default : /* any other XMC_XXX */ - continue; - } - } - break; /* switch CSECT_SCLAS() */ - - case XTY_LD : - - /* a function entry point. */ - if (CSECT_SCLAS (main_aux) == XMC_PR) { - -function_entry_point: - if (cs->c_value != last_recorded_fun) - RECORD_MISC_FUNCTION (cs->c_name, cs->c_value, mf_text, - symname_alloced); - - fcn_line_offset = main_aux->x_sym.x_fcnary.x_fcn.x_lnnoptr; - fcn_start_addr = cs->c_value; - - /* save the function header info, which will be used - when `.bf' is seen. */ - fcn_cs_saved = *cs; - fcn_aux_saved = *main_aux; - continue; - } - - /* shared library function entry point. */ - else if (CSECT_SCLAS (main_aux) == XMC_GL) { - if (last_recorded_fun != cs->c_value) - RECORD_MISC_FUNCTION (cs->c_name, cs->c_value, mf_text, - symname_alloced); - continue; - } - break; - - default : /* all other XTY_XXXs */ - break; - } /* switch CSECT_SMTYP() */ - } - - switch (cs->c_sclass) { - - case C_FILE: - - /* c_value field contains symnum of next .file entry in table - or symnum of first global after last .file. */ - - next_file_symnum = cs->c_value; - - /* complete symbol table for last object file containing - debugging information. */ - - /* Whether or not there was a csect in the previous file, we have - to call `end_symtab' and `start_symtab' to reset type_vector, - line_vector, etc. structures. */ - complete_symtab (filestring, file_start_addr); - cur_src_end_addr = file_end_addr; - end_symtab (file_end_addr, 1, 1, objfile); - start_symtab (cs->c_name, (char *)NULL, (CORE_ADDR)0); - last_seen_csect = 0; - - /* reset file start and end addresses. A compilation unit with no text - (only data) should have zero file boundaries. */ - file_start_addr = file_end_addr = 0; - - filestring = cs->c_name; - break; - - - case C_FCN: - if (strcmp (cs->c_name, ".bf") == 0) { - - bfd_coff_swap_aux_in (abfd, raw_auxptr, cs->c_type, cs->c_sclass, - main_aux); - - within_function = 1; - - /* value contains address of first non-init type code */ - /* main_aux.x_sym.x_misc.x_lnsz.x_lnno - contains line number of '{' } */ - fcn_first_line = main_aux->x_sym.x_misc.x_lnsz.x_lnno; - - /* Linenos are now processed on a file-by-file, not fn-by-fn, basis. - Metin did it, I'm not sure why. FIXME. -- gnu@cygnus.com */ - /* mark_first_line (fcn_line_offset, cs->c_symnum); */ - - new = push_context (0, fcn_start_addr); - new->name = process_xcoff_symbol (&fcn_cs_saved); - } - else if (strcmp (cs->c_name, ".ef") == 0) { - - bfd_coff_swap_aux_in (abfd, raw_auxptr, cs->c_type, cs->c_sclass, - main_aux); - - /* the value of .ef is the address of epilogue code; - not useful for gdb */ - /* { main_aux.x_sym.x_misc.x_lnsz.x_lnno - contains number of lines to '}' */ - - fcn_last_line = main_aux->x_sym.x_misc.x_lnsz.x_lnno; -#if 0 - enter_linenos (fcn_line_offset, fcn_first_line, - fcn_first_line + fcn_last_line); -#endif - - new = pop_context (); - if (context_stack_depth != 0) - error ("invalid symbol data; .bf/.ef/.bb/.eb symbol mismatch, at symbol %d.", - symnum); - - finish_block (new->name, &local_symbols, new->old_blocks, - new->start_addr, - fcn_cs_saved.c_value + - fcn_aux_saved.x_sym.x_misc.x_fsize); - within_function = 0; - } - break; - - case C_BSTAT : /* begin static block */ - static_block_base = read_symbol_nvalue (symtbl, cs->c_value); - break; - - case C_ESTAT : /* end of static block */ - static_block_base = 0; - break; - - case C_ARG : /* These are not implemented. */ - case C_REGPARM : - case C_TPDEF : - case C_STRTAG : - case C_UNTAG : - case C_ENTAG : - printf ("ERROR: Unimplemented storage class: %d.\n", cs->c_sclass); - break; - - case C_HIDEXT : /* ignore these.. */ - case C_LABEL : - case C_NULL : - break; - - case C_BINCL : /* beginning of include file */ - push_subfile (); - start_subfile (cs->c_name, (char *)0); - fcn_first_line = cs->c_value; /* Offset to first lineno of file */ - break; - - case C_EINCL : /* end of include file */ - fcn_last_line = cs->c_value; /* Offset to last line number */ - { long dummy = 0; - enter_line_range (current_subfile, fcn_first_line, cs->c_value, 0, - &dummy); - } - start_subfile (pop_subfile (), (char *)0); - break; - - case C_BLOCK : - if (strcmp (cs->c_name, ".bb") == 0) { - depth++; - new = push_context (depth, cs->c_value); - } - else if (strcmp (cs->c_name, ".eb") == 0) { - new = pop_context (); - if (depth != new->depth) - error ("Invalid symbol data: .bb/.eb symbol mismatch at symbol %d.", - symnum); - - depth--; - if (local_symbols && context_stack_depth > 0) { - /* Make a block for the local symbols within. */ - finish_block (new->name, &local_symbols, new->old_blocks, - new->start_addr, cs->c_value); - } - local_symbols = new->locals; - } - break; - - default : - (void) process_xcoff_symbol (cs); - break; - } - - } /* while */ - - if (last_source_file) - end_symtab (cur_src_end_addr, 1, 1, objfile); - - free (symtbl); -} - -#define SYMBOL_DUP(SYMBOL1, SYMBOL2) \ - (SYMBOL2) = (struct symbol *) \ - obstack_alloc (symbol_obstack, sizeof (struct symbol)); \ - *(SYMBOL2) = *(SYMBOL1); - - -#define SYMNAME_ALLOC(NAME, ALLOCED) \ - (ALLOCED) ? (NAME) : obstack_copy0 (symbol_obstack, (NAME), strlen (NAME)); - - - -/* process one xcoff symbol. */ - -static struct symbol * -process_xcoff_symbol (cs) - register struct coff_symbol *cs; -{ - struct symbol onesymbol; - register struct symbol *sym = &onesymbol; - struct symbol *sym2 = NULL; - struct type *ttype; - char *name, *pp, *qq; - - name = cs->c_name; - if (name[0] == '.') - ++name; - - bzero (sym, sizeof (struct symbol)); - - /* default assumptions */ - SYMBOL_VALUE (sym) = cs->c_value; - SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; - - if (ISFCN (cs->c_type)) { - - /* At this point, we don't know the type of the function and assume it - is int. This will be patched with the type from its stab entry later - on in patch_block_stabs () */ - - SYMBOL_NAME (sym) = SYMNAME_ALLOC (name, symname_alloced); - SYMBOL_TYPE (sym) = lookup_function_type (builtin_type_int); - - SYMBOL_CLASS (sym) = LOC_BLOCK; - SYMBOL_DUP (sym, sym2); - - if (cs->c_sclass == C_EXT) - add_symbol_to_list (sym2, &global_symbols); - else if (cs->c_sclass == C_HIDEXT || cs->c_sclass == C_STAT) - add_symbol_to_list (sym2, &file_symbols); - } - - else { - - /* in case we can't figure out the type, default is `int'. */ - SYMBOL_TYPE (sym) = builtin_type_int; - - switch (cs->c_sclass) - { - case C_FUN: - if (fcn_cs_saved.c_sclass == C_EXT) - add_stab_to_list (name, &global_stabs); - else - add_stab_to_list (name, &file_stabs); - break; - - case C_DECL: /* a type decleration?? */ - qq = (char*) index (name, ':'); - if (!qq) /* skip if there is no ':' */ - return NULL; - - pp = qq + 2; - ttype = SYMBOL_TYPE (sym) = read_type (&pp); - - /* read_type() will return null if type (or tag) definition was - unnnecessarily duplicated. Also, if the symbol doesn't have a name, - there is no need to keep it in symbol table. */ - - if (!ttype || name == qq) - return NULL; - - if (qq[1] == 'T') - SYMBOL_NAMESPACE (sym) = STRUCT_NAMESPACE; - else if (qq[1] == 't') - SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; - else { - printf ("ERROR: Unrecognized stab string.\n"); - return NULL; - } - - SYMBOL_CLASS (sym) = LOC_TYPEDEF; - SYMBOL_NAME (sym) = obsavestring (name, qq-name); - - if (SYMBOL_NAMESPACE (sym) == STRUCT_NAMESPACE) - TYPE_NAME (ttype) = concat ( - TYPE_CODE (ttype) == TYPE_CODE_UNION ? "union " : - TYPE_CODE (ttype) == TYPE_CODE_STRUCT? "struct " : "enum ", - SYMBOL_NAME (sym), NULL); - - else if (!TYPE_NAME (ttype)) /* else, regular typedef. */ - TYPE_NAME (ttype) = SYMBOL_NAME (sym); - - SYMBOL_DUP (sym, sym2); - add_symbol_to_list - (sym2, within_function ? &local_symbols : &file_symbols); - break; - - case C_GSYM: - add_stab_to_list (name, &global_stabs); - break; - - case C_PSYM: - if (*name == ':' || (pp = (char *) index (name, ':')) == NULL) - return NULL; - SYMBOL_NAME (sym) = obsavestring (name, pp-name); - SYMBOL_CLASS (sym) = LOC_ARG; - pp += 2; - SYMBOL_TYPE (sym) = read_type (&pp); - SYMBOL_DUP (sym, sym2); - add_symbol_to_list (sym2, &local_symbols); - break; - - case C_STSYM: - if (*name == ':' || (pp = (char *) index (name, ':')) == NULL) - return NULL; - SYMBOL_NAME (sym) = obsavestring (name, pp-name); - SYMBOL_CLASS (sym) = LOC_STATIC; - SYMBOL_VALUE (sym) += static_block_base; - pp += 2; - SYMBOL_TYPE (sym) = read_type (&pp); - SYMBOL_DUP (sym, sym2); - add_symbol_to_list - (sym2, within_function ? &local_symbols : &file_symbols); - break; - - case C_LSYM: - if (*name == ':' || (pp = (char *) index (name, ':')) == NULL) - return NULL; - SYMBOL_NAME (sym) = obsavestring (name, pp-name); - SYMBOL_CLASS (sym) = LOC_LOCAL; - pp += 1; - SYMBOL_TYPE (sym) = read_type (&pp); - SYMBOL_DUP (sym, sym2); - add_symbol_to_list (sym2, &local_symbols); - break; - - case C_AUTO: - SYMBOL_CLASS (sym) = LOC_LOCAL; - SYMBOL_NAME (sym) = SYMNAME_ALLOC (name, symname_alloced); - SYMBOL_DUP (sym, sym2); - add_symbol_to_list (sym2, &local_symbols); - break; - - case C_EXT: - SYMBOL_CLASS (sym) = LOC_STATIC; - SYMBOL_NAME (sym) = SYMNAME_ALLOC (name, symname_alloced); - SYMBOL_DUP (sym, sym2); - add_symbol_to_list (sym2, &global_symbols); - break; - - case C_STAT: - SYMBOL_CLASS (sym) = LOC_STATIC; - SYMBOL_NAME (sym) = SYMNAME_ALLOC (name, symname_alloced); - SYMBOL_DUP (sym, sym2); - add_symbol_to_list - (sym2, within_function ? &local_symbols : &file_symbols); - break; - - case C_REG: - printf ("ERROR! C_REG is not fully implemented!\n"); - SYMBOL_CLASS (sym) = LOC_REGISTER; - SYMBOL_NAME (sym) = SYMNAME_ALLOC (name, symname_alloced); - SYMBOL_DUP (sym, sym2); - add_symbol_to_list (sym2, &local_symbols); - break; - - case C_RSYM: - pp = (char*) index (name, ':'); - SYMBOL_CLASS (sym) = LOC_REGISTER; - SYMBOL_VALUE (sym) = STAB_REG_TO_REGNUM (cs->c_value); - if (pp) { - SYMBOL_NAME (sym) = obsavestring (name, pp-name); - pp += 2; - if (*pp) - SYMBOL_TYPE (sym) = read_type (&pp); - } - else - /* else this is not a stab entry, suppose the type is either - `int' or `float', depending on the register class. */ - - SYMBOL_TYPE (sym) = (SYMBOL_VALUE (sym) < 32) ? - builtin_type_int : builtin_type_float; - - SYMBOL_DUP (sym, sym2); - add_symbol_to_list (sym2, &local_symbols); - break; - - default : - printf ("ERROR: Unexpected storage class: %d.\n", cs->c_sclass); - return NULL; - } - } - return sym2; -} - - -static int -read_symbol_nvalue (symtable, symno) - char *symtable; - int symno; -{ - struct internal_syment symbol[1]; - - bfd_coff_swap_sym_in (symfile_bfd, symtable + (symno*local_symesz), symbol); - return symbol->n_value; -} - - -static int -read_symbol_lineno (symtable, symno) - char *symtable; - int symno; -{ - struct internal_syment symbol[1]; - union internal_auxent main_aux[1]; - - int ii; - - for (ii = 0; ii < 50; ii++) { - bfd_coff_swap_sym_in (symfile_bfd, - symtable + (symno*local_symesz), symbol); - if (symbol->n_sclass == C_FCN && 0 == strcmp (symbol->n_name, ".bf")) - goto gotit; - symno += 1 + symbol->n_numaux+1; - } - - printf ("GDB Error: `.bf' not found.\n"); - return 0; - -gotit: - /* take aux entry and return its lineno */ - symno++; - bfd_coff_swap_aux_in (symfile_bfd, symtable+(symno*local_symesz), - symbol->n_type, symbol->n_sclass, main_aux); - - return main_aux->x_sym.x_misc.x_lnsz.x_lnno; -} - -/* Support for line number handling */ - -/* This function is called for every section; it finds the outer limits - * of the line table (minimum and maximum file offset) so that the - * mainline code can read the whole thing for efficiency. - */ -static void -find_linenos(abfd, asect, vpinfo) -bfd *abfd; -sec_ptr asect; -void *vpinfo; -{ - struct coff_symfile_info *info; - int size, count; - file_ptr offset, maxoff; - - count = asect->lineno_count; - - if (count == 0) - return; - - size = count * coff_data (symfile_bfd)->local_linesz; - info = (struct coff_symfile_info *)vpinfo; - offset = asect->line_filepos; - maxoff = offset + size; - - if (offset < info->min_lineno_offset || info->min_lineno_offset == 0) - info->min_lineno_offset = offset; - - if (maxoff > info->max_lineno_offset) - info->max_lineno_offset = maxoff; -} - - -/* Read in all the line numbers for fast lookups later. Leave them in - external (unswapped) format in memory; we'll swap them as we enter - them into GDB's data structures. */ - -static int -init_lineno (abfd, offset, size) - bfd *abfd; - long offset; - int size; -{ - int val; - - if (bfd_seek(abfd, offset, 0) < 0) - return -1; - - linetab = (char *) xmalloc(size); - - val = bfd_read(linetab, 1, size, abfd); - if (val != size) - return -1; - - linetab_offset = offset; - linetab_size = size; - make_cleanup(free, linetab); /* Be sure it gets de-allocated. */ - return 0; -} - - -void -dump_strtbl () -{ - int ii; - printf ("===STRING TABLE DUMP...\n\n"); - for ( ii=0; ii < strtbl_len; ++ii ) - printf ("%c", isprint (*(strtbl+ii)) ? *(strtbl+ii) : ' '); - printf ("\n"); -} - -void -dump_linetable (ltb) - struct linetable *ltb; -{ - int ii; - for (ii=0; ii < ltb->nitems; ++ii) - printf ("line: %d, addr: 0x%x\n", ltb->item[ii].line, ltb->item[ii].pc); -} - -void -dump_type (typeP) - struct type *typeP; -{ - printf ("0x%x: name: %s\n", typeP, typeP->name ? typeP->name : "(nil)"); -} - -char *dump_namespace (); -char *dump_addrclass (); - -void -dump_symbol (pp) - struct symbol *pp; -{ - printf (" sym: %s\t%s,\t%s\ttype: 0x%x, val: 0x%x end: 0x%x\n", - pp->name, dump_namespace (pp->namespace), - dump_addrclass (pp->class), pp->type, - SYMBOL_CLASS(pp) == LOC_BLOCK ? BLOCK_START(SYMBOL_BLOCK_VALUE(pp)) - : pp->value.value, - SYMBOL_CLASS(pp) == LOC_BLOCK ? BLOCK_END(SYMBOL_BLOCK_VALUE(pp)) : 0); -} - - -char * -dump_namespace (ns) -int ns; -{ - static char *ns_name [] = { - "UNDEF_NS", "VAR_NS", "STRUCT_NS", "LABEL_NS"}; - - switch (ns) { - case UNDEF_NAMESPACE: - case VAR_NAMESPACE: - case STRUCT_NAMESPACE: - case LABEL_NAMESPACE: - return ns_name[ns]; - } - - return "***ERROR***"; -} - - -char * -dump_addrclass (ac) -int ac; /* address class */ -{ - static char *ac_name [] = { - "LOC_UNDEF", - "LOC_CONST", - "LOC_STATIC", - "LOC_REGISTER", - "LOC_ARG", - "LOC_REF_ARG", - "LOC_REGPARM", - "LOC_LOCAL", - "LOC_TYPEDEF", - "LOC_LABEL", - "LOC_BLOCK", - "LOC_CONST_BYTES", - "LOC_LOCAL_ARG", - }; - switch (ac) { - case LOC_UNDEF: - case LOC_CONST: - case LOC_STATIC: - case LOC_REGISTER: - case LOC_ARG: - case LOC_REF_ARG: - case LOC_REGPARM: - case LOC_LOCAL: - case LOC_TYPEDEF: - case LOC_LABEL: - case LOC_BLOCK: - case LOC_CONST_BYTES: - case LOC_LOCAL_ARG: - return ac_name [ac]; - } - return "***ERROR***"; -} - -void -dump_block (pp) - struct block *pp; -{ - int ii; - printf ("BLOCK..: start: 0x%x, end: 0x%x\n", pp->startaddr, pp->endaddr); - for (ii=0; ii < pp->nsyms; ++ii) - dump_symbol (pp->sym[ii]); -} - -void -dump_blockvector (pp) - struct blockvector *pp; -{ - int ii; - for (ii=0; ii < pp->nblocks; ++ii) - dump_block (pp->block [ii]); -} - - -void -dump_last_symtab (pp) - struct symtab *pp; -{ - for ( ; pp; pp = pp->next) { - if ( pp->next == 0 ) { - printf ("SYMTAB NAME: %s\n", pp->filename); - dump_blockvector (pp->blockvector); - } - } -} - -void -dump_symtabs (pp) - struct symtab *pp; -{ - for ( ; pp; pp = pp->next) { - printf ("SYMTAB NAME: %s\n", pp->filename ? pp->filename : "(nil)"); -/* if (pp->linetable) - dump_linetable (pp->linetable); */ - dump_blockvector (pp->blockvector); - } -} - -void -dump_symtab_lines (pp) - struct symtab *pp; -{ - for ( ; pp; pp = pp->next) { - printf ("SYMTAB NAME: %s\n", pp->filename ? pp->filename : "(nil)"); - if (pp->linetable) - dump_linetable (pp->linetable); - /* dump_blockvector (pp->blockvector); */ - } -} - -void -dump_misc_funcs () -{ - int ii; - for (ii=0; ii < misc_function_count; ++ii) - printf ("name: %s, addr: 0x%x\n", - misc_function_vector[ii].name, - misc_function_vector[ii].address); -} - - -/* dbx allows the text of a symbol name to be continued into the - next symbol name! When such a continuation is encountered - (a \ at the end of the text of a name) - call this function to get the continuation. */ -/* So far, I haven't seen this happenning xlc output. I doubt we'll need this - for aixcoff. */ - -#define next_symbol_text() \ - printf ("Gdb Error: symbol names on multiple lines not implemented.\n") - - -/* xlc/dbx combination uses a set of builtin types, starting from -1. return - the proper type node fora given builtin type #. */ - -struct type * -builtin_type (pp) -char **pp; -{ - int typenums[2]; - - if (**pp != '-') { - printf ("ERROR!, unknown built-in type!\n"); - return NULL; - } - *pp += 1; - read_type_number (pp, typenums); - - /* default types are defined in dbxstclass.h. */ - switch ( typenums[1] ) { - case 1: - return builtin_type_int; - case 2: - return builtin_type_char; - case 3: - return builtin_type_short; - case 4: - return builtin_type_long; - case 5: - return builtin_type_unsigned_char; - case 6: - return builtin_type_char; /* requires a builtin `signed char' */ - case 7: - return builtin_type_unsigned_short; - case 8: - return builtin_type_unsigned_int; - case 9: - return builtin_type_unsigned_int; - case 10: - return builtin_type_unsigned_long; - case 11: - return builtin_type_void; - case 12: - return builtin_type_float; - case 13: - return builtin_type_double; - case 14: - return builtin_type_double; /* requires a builtin `long double' */ - case 15: - return builtin_type_int; /* requires a builtin `integer' */ - case 16: - return builtin_type_int; /* requires builtin `boolean' */ - case 17: - return builtin_type_float; /* requires builtin `short real' */ - case 18: - return builtin_type_float; /* requires builtin `real' */ - default : - printf ("ERROR! Unknown builtin type -%d\n", typenums[1]); - return NULL; - } -} - -/* if we now nothing about a function but its address, make a function symbol - out of it with the limited knowladge you have. This will be used when - somebody refers to a function, which doesn't exist in the symbol table, - but in misc_function_vector. */ - -struct symbol * -build_function_symbol (ind) - int ind; -{ - struct symbol *sym = - (struct symbol *) obstack_alloc (symbol_obstack, sizeof (struct symbol)); - SYMBOL_NAME (sym) = misc_function_vector[ind].name; - /* SYMBOL_VALUE (sym) = misc_function_vector[ind].address; */ - SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; - SYMBOL_CLASS (sym) = LOC_BLOCK; - SYMBOL_TYPE (sym) = lookup_function_type (builtin_type_int); - SYMBOL_BLOCK_VALUE (sym) = (struct block *) - obstack_alloc (symbol_obstack, sizeof (struct block)); - BLOCK_START (SYMBOL_BLOCK_VALUE (sym)) = misc_function_vector[ind].address; - return sym; -} - - -void -aixcoff_new_init () -{ - /* Nothin' to do. */ -} - -void -aixcoff_symfile_init (sf) -struct sym_fns *sf; -{ - bfd *abfd = sf->sym_bfd; - - /* Allocate struct to keep track of the symfile */ - /* FIXME memory leak */ - sf->sym_private = xmalloc(sizeof (struct coff_symfile_info)); - - /* - * Save startup file's range of PC addresses to help - * blockframe.c decide where the bottom of the stack is. - */ - if (bfd_get_file_flags(abfd) & EXEC_P) { - entry_point = bfd_get_start_address(abfd); - } else { - entry_point = ~0; - /* set the startup file to be an empty range. */ - startup_file_start = 0; - startup_file_end = 0; - } -} - - -static int -init_stringtab(abfd, offset) - bfd *abfd; - long offset; -{ - long length; - int val; - unsigned char lengthbuf[4]; - - if (bfd_seek(abfd, offset, 0) < 0) - return -1; - - val = bfd_read((char *)lengthbuf, 1, sizeof lengthbuf, abfd); - length = bfd_h_get_32(abfd, lengthbuf); - - /* If no string table is needed, then the file may end immediately - after the symbols. Just return with `strtbl' set to null. */ - - if (val != sizeof length || length < sizeof length) - return 0; - - /* Allocate string table from symbol_obstack. We will need this table - as long as we have its symbol table around. */ - - strtbl = (char*) obstack_alloc (symbol_obstack, length); - if (strtbl == NULL) - return -1; - - bcopy(&length, strtbl, sizeof length); - if (length == sizeof length) - return 0; - - val = bfd_read(strtbl + sizeof length, 1, length - sizeof length, abfd); - - if (val != length - sizeof length || strtbl[length - 1] != '\0') - return -1; - - return 0; -} - -static int -init_debugsection(abfd) - bfd *abfd; -{ - register sec_ptr secp; - bfd_size_type length; - - if (debugsec) { - free(debugsec); - debugsec = NULL; - } - - secp = bfd_get_section_by_name(abfd, ".debug"); - if (!secp) - return 0; - - if (!(length = bfd_section_size(abfd, secp))) - return 0; - - debugsec = (void *) xmalloc ((unsigned)length); - if (debugsec == NULL) - return -1; - - if (!bfd_get_section_contents(abfd, secp, debugsec, (file_ptr) 0, length)) { - printf ("Can't read .debug section from symbol file\n"); - return -1; - } - return 0; -} - -static void -free_debugsection() -{ - if (debugsec) - free(debugsec); - debugsec = NULL; -} - - -/* aixcoff version of symbol file read. */ - -void -aixcoff_symfile_read (sf, addr, mainline) - struct sym_fns *sf; - CORE_ADDR addr; - int mainline; -{ - int num_symbols; /* # of symbols */ - int symtab_offset; /* symbol table and */ - int stringtab_offset; /* string table file offsets */ - int val; - bfd *abfd; - struct coff_symfile_info *info = (void*) sf->sym_private; - char *name; - - symfile_bfd = abfd = sf->objfile->obfd; - name = sf->objfile->name; - - num_symbols = bfd_get_symcount (abfd); /* # of symbols */ - symtab_offset = obj_sym_filepos (abfd); /* symbol table file offset */ - stringtab_offset = symtab_offset + - num_symbols * coff_data(abfd)->local_symesz; - - info->min_lineno_offset = 0; - info->max_lineno_offset = 0; - bfd_map_over_sections (abfd, find_linenos, info); - - /* FIXME! This stuff should move into symfile_init */ - if (info->min_lineno_offset != 0 - && info->max_lineno_offset > info->min_lineno_offset) { - - /* only read in the line # table if one exists */ - val = init_lineno(abfd, info->min_lineno_offset, - info->max_lineno_offset - info->min_lineno_offset); - - if (val < 0) - error("\"%s\": error reading line numbers\n", name); - } - - val = init_stringtab(abfd, stringtab_offset); - if (val < 0) { - error ("\"%s\": can't get string table", name); - } - - if (init_debugsection(abfd) < 0) { - error ("Error reading .debug section of `%s'\n", name); - } - - /* Position to read the symbol table. Do not read it all at once. */ - val = bfd_seek(abfd, (long)symtab_offset, 0); - if (val < 0) - perror_with_name(name); - - if (bfd_tell(abfd) != symtab_offset) - fatal("bfd? BFD!"); - - init_misc_bunches (); - make_cleanup(discard_misc_bunches, 0); - -#ifdef XCOFF_INIT_LOADINFO - if (mainline) - XCOFF_INIT_LOADINFO (); -#endif - - /* Now that the executable file is positioned at symbol table, - process it and define symbols accordingly. */ - - read_xcoff_symtab(sf->objfile, num_symbols); - - make_cleanup(free_debugsection, 0); - - /* Sort symbols alphabetically within each block. */ - sort_syms (); - - /* Go over the misc functions and install them in vector. */ - condense_misc_bunches (!mainline); - - /* Make a default for file to list. */ - select_source_symtab (0); -} - -/* Register our ability to parse symbols for aixcoff BFD files. */ - -static struct sym_fns aixcoff_sym_fns = -{ - "aixcoff-rs6000", 15, - aixcoff_new_init, aixcoff_symfile_init, - aixcoff_symfile_read, -}; - -void -_initialize_xcoffread () -{ - add_symtab_fns(&aixcoff_sym_fns); -} diff --git a/gdb/xm-3b1.h b/gdb/xm-3b1.h deleted file mode 100644 index e31e86fc241..00000000000 --- a/gdb/xm-3b1.h +++ /dev/null @@ -1,87 +0,0 @@ -/* Parameters for execution on a 3b1. - Copyright (C) 1986, 1987, 1989 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#define HOST_BYTE_ORDER BIG_ENDIAN - -#define HAVE_TERMIO -#define USG - -#define MAXPATHLEN 200 - -/* This is the amount to subtract from u.u_ar0 - to get the offset in the core file of the register values. */ - -#define KERNEL_U_ADDR 0x70000 - -#define REGISTER_U_ADDR(addr, blockend, regno) \ -{ addr = blockend + regno * 4; } - -/* Interface definitions for kernel debugger KDB. */ - -/* Map machine fault codes into signal numbers. - First subtract 0, divide by 4, then index in a table. - Faults for which the entry in this table is 0 - are not handled by KDB; the program's own trap handler - gets to handle then. */ - -#define FAULT_CODE_ORIGIN 0 -#define FAULT_CODE_UNITS 4 -#define FAULT_TABLE \ -{ 0, 0, 0, 0, SIGTRAP, 0, 0, 0, \ - 0, SIGTRAP, 0, 0, 0, 0, 0, SIGKILL, \ - 0, 0, 0, 0, 0, 0, 0, 0, \ - SIGILL } - -/* Start running with a stack stretching from BEG to END. - BEG and END should be symbols meaningful to the assembler. - This is used only for kdb. */ - -#define INIT_STACK(beg, end) \ -{ asm (".globl end"); \ - asm ("movel $ end, sp"); \ - asm ("clrl fp"); } - -/* Push the frame pointer register on the stack. */ -#define PUSH_FRAME_PTR \ - asm ("movel fp, -(sp)"); - -/* Copy the top-of-stack to the frame pointer register. */ -#define POP_FRAME_PTR \ - asm ("movl (sp), fp"); - -/* After KDB is entered by a fault, push all registers - that GDB thinks about (all NUM_REGS of them), - so that they appear in order of ascending GDB register number. - The fault code will be on the stack beyond the last register. */ - -#define PUSH_REGISTERS \ -{ asm ("clrw -(sp)"); \ - asm ("pea 10(sp)"); \ - asm ("movem $ 0xfffe,-(sp)"); } - -/* Assuming the registers (including processor status) have been - pushed on the stack in order of ascending GDB register number, - restore them and return to the address in the saved PC register. */ - -#define POP_REGISTERS \ -{ asm ("subil $8,28(sp)"); \ - asm ("movem (sp),$ 0xffff"); \ - asm ("rte"); } - -#endif diff --git a/gdb/xm-altos.h b/gdb/xm-altos.h deleted file mode 100644 index cc501c0f943..00000000000 --- a/gdb/xm-altos.h +++ /dev/null @@ -1,208 +0,0 @@ -/* Definitions to make GDB run on an Altos 3068 (m68k running SVR2) - Copyright (C) 1987,1989 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#define HOST_BYTE_ORDER BIG_ENDIAN - -/* The altos support would make a good base for a port to other USGR2 systems - (like the 3b1 and the Convergent miniframe). */ - -/* This is only needed in one file, but it's cleaner to put it here than - putting in more #ifdef's. */ -#include -#include - -#define USG - -#define HAVE_TERMIO - -#define CBREAK XTABS /* It takes all kinds... */ - -#ifndef R_OK -#define R_OK 4 -#define W_OK 2 -#define X_OK 1 -#define F_OK 0 -#endif - -#ifndef MAXPATHLEN -#define MAXPATHLEN (1024) -#endif - -/* Get sys/wait.h ie. from a Sun and edit it a little (mc68000 to m68k) */ -/* Why bother? */ -#if 0 -#define HAVE_WAIT_STRUCT -#endif - -#define vfork fork - -/* This is the amount to subtract from u.u_ar0 - to get the offset in the core file of the register values. */ - -#define KERNEL_U_ADDR 0x1fbf000 - -#define REGISTER_U_ADDR(addr, blockend, regno) \ -{ if (regno <= SP_REGNUM) \ - addr = blockend + regno * 4; \ - else if (regno == PS_REGNUM) \ - addr = blockend + regno * 4 + 4; \ - else if (regno == PC_REGNUM) \ - addr = blockend + regno * 4 + 2; \ -} - -#define REGISTER_ADDR(u_ar0, regno) \ - (((regno) < PS_REGNUM) \ - ? (&((struct exception_stack *) (u_ar0))->e_regs[(regno + R0)]) \ - : (((regno) == PS_REGNUM) \ - ? ((int *) (&((struct exception_stack *) (u_ar0))->e_PS)) \ - : (&((struct exception_stack *) (u_ar0))->e_PC))) - -#define FP_REGISTER_ADDR(u, regno) \ - (((char *) \ - (((regno) < FPC_REGNUM) \ - ? (&u.u_pcb.pcb_mc68881[FMC68881_R0 + (((regno) - FP0_REGNUM) * 3)]) \ - : (&u.u_pcb.pcb_mc68881[FMC68881_C + ((regno) - FPC_REGNUM)]))) \ - - ((char *) (& u))) - - -#ifndef __GNUC__ -#undef USE_GAS -#define ALTOS_AS -#else -#define USE_GAS -#endif - -/* Motorola assembly format */ -#if !defined(USE_GAS) && !defined(ALTOS) -#define MOTOROLA -#endif - -/* Interface definitions for kernel debugger KDB. */ - -/* Map machine fault codes into signal numbers. - First subtract 0, divide by 4, then index in a table. - Faults for which the entry in this table is 0 - are not handled by KDB; the program's own trap handler - gets to handle then. */ - -#define FAULT_CODE_ORIGIN 0 -#define FAULT_CODE_UNITS 4 -#define FAULT_TABLE \ -{ 0, 0, 0, 0, SIGTRAP, 0, 0, 0, \ - 0, SIGTRAP, 0, 0, 0, 0, 0, SIGKILL, \ - 0, 0, 0, 0, 0, 0, 0, 0, \ - SIGILL } - -/* Start running with a stack stretching from BEG to END. - BEG and END should be symbols meaningful to the assembler. - This is used only for kdb. */ - -#ifdef MOTOROLA -#define INIT_STACK(beg, end) \ -{ asm (".globl end"); \ - asm ("move.l $ end, sp"); \ - asm ("clr.l fp"); } -#else -#ifdef ALTOS_AS -#define INIT_STACK(beg, end) \ -{ asm ("global end"); \ - asm ("mov.l &end,%sp"); \ - asm ("clr.l %fp"); } -#else -#define INIT_STACK(beg, end) \ -{ asm (".globl end"); \ - asm ("movel $ end, sp"); \ - asm ("clrl fp"); } -#endif -#endif - -/* Push the frame pointer register on the stack. */ -#ifdef MOTOROLA -#define PUSH_FRAME_PTR \ - asm ("move.l fp, -(sp)"); -#else -#ifdef ALTOS_AS -#define PUSH_FRAME_PTR \ - asm ("mov.l %fp, -(%sp)"); -#else -#define PUSH_FRAME_PTR \ - asm ("movel fp, -(sp)"); -#endif -#endif - -/* Copy the top-of-stack to the frame pointer register. */ -#ifdef MOTOROLA -#define POP_FRAME_PTR \ - asm ("move.l (sp), fp"); -#else -#ifdef ALTOS_AS -#define POP_FRAME_PTR \ - asm ("mov.l (%sp), %fp"); -#else -#define POP_FRAME_PTR \ - asm ("movl (sp), fp"); -#endif -#endif - -/* After KDB is entered by a fault, push all registers - that GDB thinks about (all NUM_REGS of them), - so that they appear in order of ascending GDB register number. - The fault code will be on the stack beyond the last register. */ - -#ifdef MOTOROLA -#define PUSH_REGISTERS \ -{ asm ("clr.w -(sp)"); \ - asm ("pea (10,sp)"); \ - asm ("movem $ 0xfffe,-(sp)"); } -#else -#ifdef ALTOS_AS -#define PUSH_REGISTERS \ -{ asm ("clr.w -(%sp)"); \ - asm ("pea (10,%sp)"); \ - asm ("movm.l &0xfffe,-(%sp)"); } -#else -#define PUSH_REGISTERS \ -{ asm ("clrw -(sp)"); \ - asm ("pea 10(sp)"); \ - asm ("movem $ 0xfffe,-(sp)"); } -#endif -#endif - -/* Assuming the registers (including processor status) have been - pushed on the stack in order of ascending GDB register number, - restore them and return to the address in the saved PC register. */ - -#ifdef MOTOROLA -#define POP_REGISTERS \ -{ asm ("subi.l $8,28(sp)"); \ - asm ("movem (sp),$ 0xffff"); \ - asm ("rte"); } -#else -#ifdef ALTOS_AS -#define POP_REGISTERS \ -{ asm ("sub.l &8,28(%sp)"); \ - asm ("movem (%sp),&0xffff"); \ - asm ("rte"); } -#else -#define POP_REGISTERS \ -{ asm ("subil $8,28(sp)"); \ - asm ("movem (sp),$ 0xffff"); \ - asm ("rte"); } -#endif -#endif diff --git a/gdb/xm-amix.h b/gdb/xm-amix.h deleted file mode 100644 index cf55ce10e0d..00000000000 --- a/gdb/xm-amix.h +++ /dev/null @@ -1,28 +0,0 @@ -/* Macro definitions for GDB on a Commodore Amiga running SVR4 (amix) - Copyright (C) 1991, Free Software Foundation, Inc. - Written by Fred Fish at Cygnus Support (fnf@cygint) - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Pick up most of what we need from the generic m68k host include file. */ - -#include "xm-m68k.h" - -/* Pick up more stuff from the generic SVR4 host include file. */ - -#include "xm-svr4.h" - diff --git a/gdb/xm-arm.h b/gdb/xm-arm.h deleted file mode 100644 index 70953c8de83..00000000000 --- a/gdb/xm-arm.h +++ /dev/null @@ -1,88 +0,0 @@ -/* Definitions to make GDB run on an ARM under RISCiX (4.3bsd). - Copyright (C) 1986, 1987, 1989 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#define HOST_BYTE_ORDER LITTLE_ENDIAN - -/* Get rid of any system-imposed stack limit if possible. */ - -#define SET_STACK_LIMIT_HUGE - -/* This is the amount to subtract from u.u_ar0 - to get the offset in the core file of the register values. */ - -#define KERNEL_U_ADDR (0x01000000 - (UPAGES * NBPG)) - -/* Override copies of {fetch,store}_inferior_registers in infptrace.c. */ -#define FETCH_INFERIOR_REGISTERS - - -#if 0 -/* Interface definitions for kernel debugger KDB. */ - -/* Map machine fault codes into signal numbers. - First subtract 0, divide by 4, then index in a table. - Faults for which the entry in this table is 0 - are not handled by KDB; the program's own trap handler - gets to handle then. */ - -#define FAULT_CODE_ORIGIN 0 -#define FAULT_CODE_UNITS 4 -#define FAULT_TABLE \ -{ 0, SIGKILL, SIGSEGV, 0, 0, 0, 0, 0, \ - 0, 0, SIGTRAP, SIGTRAP, 0, 0, 0, 0, \ - 0, 0, 0, 0, 0, 0, 0, 0} - -/* Start running with a stack stretching from BEG to END. - BEG and END should be symbols meaningful to the assembler. - This is used only for kdb. */ - -#define INIT_STACK(beg, end) \ -{ asm (".globl end"); \ - asm ("movl $ end, sp"); \ - asm ("clrl fp"); } - -/* Push the frame pointer register on the stack. */ -#define PUSH_FRAME_PTR \ - asm ("pushl fp"); - -/* Copy the top-of-stack to the frame pointer register. */ -#define POP_FRAME_PTR \ - asm ("movl (sp), fp"); - -/* After KDB is entered by a fault, push all registers - that GDB thinks about (all NUM_REGS of them), - so that they appear in order of ascending GDB register number. - The fault code will be on the stack beyond the last register. */ - -#define PUSH_REGISTERS \ -{ asm ("pushl 8(sp)"); \ - asm ("pushl 8(sp)"); \ - asm ("pushal 0x14(sp)"); \ - asm ("pushr $037777"); } - -/* Assuming the registers (including processor status) have been - pushed on the stack in order of ascending GDB register number, - restore them and return to the address in the saved PC register. */ - -#define POP_REGISTERS \ -{ asm ("popr $037777"); \ - asm ("subl2 $8,(sp)"); \ - asm ("movl (sp),sp"); \ - asm ("rei"); } -#endif /* 0 */ diff --git a/gdb/xm-bigmips.h b/gdb/xm-bigmips.h deleted file mode 100644 index 85f314f2ba4..00000000000 --- a/gdb/xm-bigmips.h +++ /dev/null @@ -1,21 +0,0 @@ -/* Copyright (C) 1990 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#define HOST_BYTE_ORDER BIG_ENDIAN - -#include "xm-mips.h" diff --git a/gdb/xm-convex.h b/gdb/xm-convex.h deleted file mode 100644 index 156214c2f5f..00000000000 --- a/gdb/xm-convex.h +++ /dev/null @@ -1,51 +0,0 @@ -/* Definitions to make GDB run on Convex Unix (4bsd) - Copyright (C) 1989 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#define HOST_BYTE_ORDER BIG_ENDIAN - -#define LONG_LONG -#define ATTACH_DETACH -#define HAVE_WAIT_STRUCT -#define NO_SIGINTERRUPT - -/* Get rid of any system-imposed stack limit if possible. */ - -#define SET_STACK_LIMIT_HUGE - -/* Use SIGCONT rather than SIGTSTP because convex Unix occasionally - turkeys SIGTSTP. I think. */ - -#define STOP_SIGNAL SIGCONT - -/* Use csh to do argument expansion so we get ~ and such. */ - -/* Doesn't work. */ -/* #define SHELL_FILE "/bin/csh" */ - -/* Compensate for lack of `vprintf' function. */ -#define MISSING_VPRINTF - -/* Hook to call after creating inferior process. */ - -#define CREATE_INFERIOR_HOOK create_inferior_hook - - -/* Interface definitions for kernel debugger KDB. */ - -/* (no kdb) */ diff --git a/gdb/xm-delta88.h b/gdb/xm-delta88.h deleted file mode 100644 index f408c8bb48c..00000000000 --- a/gdb/xm-delta88.h +++ /dev/null @@ -1,57 +0,0 @@ -/* Host machine description for Motorola Delta 88 system, for GDB. - Copyright 1986, 1987, 1988, 1989, 1990, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#define HOST_BYTE_ORDER BIG_ENDIAN - -#if !defined (USG) -#define USG 1 -#endif - -#define MAXPATHLEN 1024 - -#include -#include - -#define HAVE_TERMIO - -/*#define USIZE 2048*/ -#define NBPG NBPC -#define UPAGES USIZE - -/* Get rid of any system-imposed stack limit if possible. */ - -/*#define SET_STACK_LIMIT_HUGE*/ - -/* This is the amount to subtract from u.u_ar0 - to get the offset in the core file of the register values. */ - -/* Since registers r0 through r31 are stored directly in the struct ptrace_user, - (for m88k BCS) - the ptrace_user offsets are sufficient and KERNEL_U_ADDRESS can be 0 */ - -#define KERNEL_U_ADDR 0 - -#define REGISTER_U_ADDR(addr, blockend, regno) \ - (addr) = m88k_register_u_addr ((blockend),(regno)); - -#define FETCH_INFERIOR_REGISTERS - -/* Address of end of stack space (in core files). */ - -#define STACK_END_ADDR 0xF0000000 diff --git a/gdb/xm-hp300bsd.h b/gdb/xm-hp300bsd.h deleted file mode 100644 index db06dbc7ce8..00000000000 --- a/gdb/xm-hp300bsd.h +++ /dev/null @@ -1,120 +0,0 @@ -/* Parameters for hosting on a Hewlett-Packard 9000/300, running bsd. - Copyright (C) 1986, 1987, 1989, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - * Configuration file for HP9000/300 series machine running - * University of Utah's 4.3bsd port. This is NOT for HP-UX. - * Problems to hpbsd-bugs@cs.utah.edu - */ - -#define HOST_BYTE_ORDER BIG_ENDIAN - -/* Avoid "INT_MIN redefined" warnings -- by defining it here, exactly - the same as in the system file. */ -#undef INT_MIN -#define INT_MIN 0x80000000 - -/* Get rid of any system-imposed stack limit if possible. */ - -#define SET_STACK_LIMIT_HUGE - -/* Get kernel u area address at run-time using BSD style nlist (). */ -#define KERNEL_U_ADDR_BSD - -/* This is a piece of magic that is given a register number REGNO - and as BLOCKEND the address in the system of the end of the user structure - and stores in ADDR the address in the kernel or core dump - of that register. */ - -#define REGISTER_U_ADDR(addr, blockend, regno) \ -{ \ - if (regno < PS_REGNUM) \ - addr = (int) &((struct frame *)(blockend))->f_regs[regno]; \ - else if (regno == PS_REGNUM) \ - addr = (int) &((struct frame *)(blockend))->f_stackadj; \ - else if (regno == PC_REGNUM) \ - addr = (int) &((struct frame *)(blockend))->f_pc; \ - else if (regno < FPC_REGNUM) \ - addr = (int) \ - &((struct user *)0)->u_pcb.pcb_fpregs.fpf_regs[((regno)-FP0_REGNUM)*3];\ - else if (regno == FPC_REGNUM) \ - addr = (int) &((struct user *)0)->u_pcb.pcb_fpregs.fpf_fpcr; \ - else if (regno == FPS_REGNUM) \ - addr = (int) &((struct user *)0)->u_pcb.pcb_fpregs.fpf_fpsr; \ - else \ - addr = (int) &((struct user *)0)->u_pcb.pcb_fpregs.fpf_fpiar; \ -} - -/* Compensate for lack of `vprintf' function. */ -#define MISSING_VPRINTF - -/* Kernel is a bit tenacious about sharing text segments, disallowing bpts. */ -#define ONE_PROCESS_WRITETEXT - -/* Interface definitions for kernel debugger KDB. */ - -/* Map machine fault codes into signal numbers. - First subtract 0, divide by 4, then index in a table. - Faults for which the entry in this table is 0 - are not handled by KDB; the program's own trap handler - gets to handle then. */ - -#define FAULT_CODE_ORIGIN 0 -#define FAULT_CODE_UNITS 4 -#define FAULT_TABLE \ -{ 0, 0, 0, 0, SIGTRAP, 0, 0, 0, \ - 0, SIGTRAP, 0, 0, 0, 0, 0, SIGKILL, \ - 0, 0, 0, 0, 0, 0, 0, 0, \ - SIGILL } - -/* Start running with a stack stretching from BEG to END. - BEG and END should be symbols meaningful to the assembler. - This is used only for kdb. */ - -#define INIT_STACK(beg, end) \ -{ asm (".globl end"); \ - asm ("movel #end, sp"); \ - asm ("movel #0,a6"); } - -/* Push the frame pointer register on the stack. */ -#define PUSH_FRAME_PTR \ - asm ("movel a6,sp@-"); - -/* Copy the top-of-stack to the frame pointer register. */ -#define POP_FRAME_PTR \ - asm ("movl sp@,a6"); - -/* After KDB is entered by a fault, push all registers - that GDB thinks about (all NUM_REGS of them), - so that they appear in order of ascending GDB register number. - The fault code will be on the stack beyond the last register. */ - -#define PUSH_REGISTERS \ -{ asm ("clrw -(sp)"); \ - asm ("pea sp@(10)"); \ - asm ("movem #0xfffe,sp@-"); } - -/* Assuming the registers (including processor status) have been - pushed on the stack in order of ascending GDB register number, - restore them and return to the address in the saved PC register. */ - -#define POP_REGISTERS \ -{ asm ("subil #8,sp@(28)"); \ - asm ("movem sp@,#0xffff"); \ - asm ("rte"); } diff --git a/gdb/xm-hp300hpux.h b/gdb/xm-hp300hpux.h deleted file mode 100644 index 79bc6daf7b0..00000000000 --- a/gdb/xm-hp300hpux.h +++ /dev/null @@ -1,173 +0,0 @@ -/* Parameters for execution on an HP 9000 model 320, for GDB, the GNU debugger. - Copyright (C) 1986, 1987, 1989 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#define HOST_BYTE_ORDER BIG_ENDIAN - -/* Define this to indicate problems with traps after continuing. */ -#define HP_OS_BUG - -/* fetch_inferior_registers is in hp300hpux-dep.c. */ -#define FETCH_INFERIOR_REGISTERS - -/* Set flag to indicate whether HP's assembler is in use. */ -#ifdef __GNUC__ -#ifdef __HPUX_ASM__ -#define HPUX_ASM -#endif -#else /* not GNU C. */ -#define HPUX_ASM -#endif /* not GNU C. */ - -/* Define this for versions of hp-ux older than 6.0 */ -/* #define HPUX_VERSION_5 */ - -/* define USG if you are using sys5 /usr/include's */ -#undef USG /* In case it was defined in the Makefile for cplus-dem.c */ -#define USG - -#define HAVE_TERMIO - -/* Get rid of any system-imposed stack limit if possible. */ -/* The hp9k320.h doesn't seem to have this feature. */ -/* #define SET_STACK_LIMIT_HUGE */ -/* So we'll just have to avoid big alloca's. */ -#define BROKEN_LARGE_ALLOCA - -/* This is the amount to subtract from u.u_ar0 - to get the offset in the core file of the register values. */ - -#ifdef HPUX_VERSION_5 -#define KERNEL_U_ADDR 0x00979000 -#else /* Not HPUX version 5. */ -/* Use HPUX-style nlist() to get kernel_u_addr. */ -#define KERNEL_U_ADDR_HPUX -#endif /* Not HPUX version 5. */ - -#define REGISTER_ADDR(u_ar0, regno) \ - (unsigned int) \ - (((regno) < PS_REGNUM) \ - ? (&((struct exception_stack *) (u_ar0))->e_regs[(regno + R0)]) \ - : (((regno) == PS_REGNUM) \ - ? ((int *) (&((struct exception_stack *) (u_ar0))->e_PS)) \ - : (&((struct exception_stack *) (u_ar0))->e_PC))) - -#define FP_REGISTER_ADDR(u, regno) \ - (((char *) \ - (((regno) < FPC_REGNUM) \ - ? (&u.u_pcb.pcb_mc68881[FMC68881_R0 + (((regno) - FP0_REGNUM) * 3)]) \ - : (&u.u_pcb.pcb_mc68881[FMC68881_C + ((regno) - FPC_REGNUM)]))) \ - - ((char *) (& u))) - -/* Do implement the attach and detach commands. */ - -#define ATTACH_DETACH - -/* Interface definitions for kernel debugger KDB. */ - -/* Map machine fault codes into signal numbers. - First subtract 0, divide by 4, then index in a table. - Faults for which the entry in this table is 0 - are not handled by KDB; the program's own trap handler - gets to handle then. */ - -#define FAULT_CODE_ORIGIN 0 -#define FAULT_CODE_UNITS 4 -#define FAULT_TABLE \ -{ 0, 0, 0, 0, SIGTRAP, 0, 0, 0, \ - 0, SIGTRAP, 0, 0, 0, 0, 0, SIGKILL, \ - 0, 0, 0, 0, 0, 0, 0, 0, \ - SIGILL } - -#ifndef HPUX_ASM - -/* Start running with a stack stretching from BEG to END. - BEG and END should be symbols meaningful to the assembler. - This is used only for kdb. */ - -#define INIT_STACK(beg, end) \ -{ asm (".globl end"); \ - asm ("movel $ end, sp"); \ - asm ("clrl fp"); } - -/* Push the frame pointer register on the stack. */ -#define PUSH_FRAME_PTR \ - asm ("movel fp, -(sp)"); - -/* Copy the top-of-stack to the frame pointer register. */ -#define POP_FRAME_PTR \ - asm ("movl (sp), fp"); - -/* After KDB is entered by a fault, push all registers - that GDB thinks about (all NUM_REGS of them), - so that they appear in order of ascending GDB register number. - The fault code will be on the stack beyond the last register. */ - -#define PUSH_REGISTERS \ -{ asm ("clrw -(sp)"); \ - asm ("pea 10(sp)"); \ - asm ("movem $ 0xfffe,-(sp)"); } - -/* Assuming the registers (including processor status) have been - pushed on the stack in order of ascending GDB register number, - restore them and return to the address in the saved PC register. */ - -#define POP_REGISTERS \ -{ asm ("subil $8,28(sp)"); \ - asm ("movem (sp),$ 0xffff"); \ - asm ("rte"); } - -#else /* HPUX_ASM */ - -/* Start running with a stack stretching from BEG to END. - BEG and END should be symbols meaningful to the assembler. - This is used only for kdb. */ - -#define INIT_STACK(beg, end) \ -{ asm ("global end"); \ - asm ("mov.l &end,%sp"); \ - asm ("clr.l %a6"); } - -/* Push the frame pointer register on the stack. */ -#define PUSH_FRAME_PTR \ - asm ("mov.l %fp,-(%sp)"); - -/* Copy the top-of-stack to the frame pointer register. */ -#define POP_FRAME_PTR \ - asm ("mov.l (%sp),%fp"); - -/* After KDB is entered by a fault, push all registers - that GDB thinks about (all NUM_REGS of them), - so that they appear in order of ascending GDB register number. - The fault code will be on the stack beyond the last register. */ - -#define PUSH_REGISTERS \ -{ asm ("clr.w -(%sp)"); \ - asm ("pea 10(%sp)"); \ - asm ("movm.l &0xfffe,-(%sp)"); } - -/* Assuming the registers (including processor status) have been - pushed on the stack in order of ascending GDB register number, - restore them and return to the address in the saved PC register. */ - -#define POP_REGISTERS \ -{ asm ("subi.l &8,28(%sp)"); \ - asm ("mov.m (%sp),&0xffff"); \ - asm ("rte"); } - -#endif /* HPUX_ASM */ diff --git a/gdb/xm-i386mach.h b/gdb/xm-i386mach.h deleted file mode 100644 index 244361bd00d..00000000000 --- a/gdb/xm-i386mach.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Definitions to make GDB run on Mach on an Intel 386 - Copyright (C) 1986, 1987, 1989, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#define HOST_BYTE_ORDER LITTLE_ENDIAN - -/* Avoid "INT_MIN redefined" warnings -- by defining it here, exactly - the same as in the system file. */ -#undef INT_MIN -#define INT_MIN 0x80000000 - -/* Get rid of any system-imposed stack limit if possible. */ - -#define SET_STACK_LIMIT_HUGE - -/* This is the amount to subtract from u.u_ar0 - to get the offset in the core file of the register values. */ - -#define KERNEL_U_ADDR (0x80000000 - (UPAGES * NBPG)) - -#define BROKEN_LARGE_ALLOCA - -/* Do implement the attach and detach commands. */ -/* #define ATTACH_DETACH 1 */ - -/* Override copies of {fetch,store}_inferior_registers in infptrace.c. */ -#define FETCH_INFERIOR_REGISTERS - -#define PREPARE_TO_STORE() read_register_bytes (0, NULL, REGISTER_BYTES) diff --git a/gdb/xm-i386sco.h b/gdb/xm-i386sco.h deleted file mode 100644 index d9d2b9e5a74..00000000000 --- a/gdb/xm-i386sco.h +++ /dev/null @@ -1,39 +0,0 @@ -/* Macro defintions for i386, running SCO Unix System V/386 3.2. - Copyright (C) 1989 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include "xm-i386v.h" - -/* Apparently there is inconsistency among various System V's about what - the name of this field is. */ -#define U_FPSTATE(u) u.u_fps.u_fpstate - -/* TIOCGETC is defined in System V 3.2 termio.h, but struct tchars - is not. This makes problems for inflow.c. */ -#define TIOCGETC_BROKEN - -/* All the job control definitions exist in SCO Unix, but the standard - shells don't use them. So we must disable job control. */ -/* This is no longer true with 3.2v2 and later */ -/* #define NO_JOB_CONTROL */ - -/* SCO's assembler doesn't grok dollar signs in identifiers. - So we use dots instead. This item must be coordinated with G++. */ -#undef CPLUS_MARKER -#define CPLUS_MARKER '.' -#define HAVE_STRSTR diff --git a/gdb/xm-i386v.h b/gdb/xm-i386v.h deleted file mode 100644 index 589d7097310..00000000000 --- a/gdb/xm-i386v.h +++ /dev/null @@ -1,101 +0,0 @@ -/* Macro defintions for i386. - Copyright (C) 1986, 1987, 1989 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - * Changes for 80386 by Pace Willisson (pace@prep.ai.mit.edu) - * July 1988 - */ - -#define HOST_BYTE_ORDER LITTLE_ENDIAN - -/* I'm running gdb 3.4 under 386/ix 2.0.2, which is a derivative of AT&T's -Sys V/386 3.2. - -On some machines, gdb crashes when it's starting up while calling the -vendor's termio tgetent() routine. It always works when run under -itself (actually, under 3.2, it's not an infinitely recursive bug.) -After some poking around, it appears that depending on the environment -size, or whether you're running YP, or the phase of the moon or something, -the stack is not always long-aligned when main() is called, and tgetent() -takes strong offense at that. On some machines this bug never appears, but -on those where it does, it occurs quite reliably. */ -#define ALIGN_STACK_ON_STARTUP - -/* define USG if you are using sys5 /usr/include's */ -#define USG - -/* USG systems need these */ -#define vfork() fork() -#define MAXPATHLEN 500 - -#define HAVE_TERMIO - -/* Get rid of any system-imposed stack limit if possible. */ - -/* #define SET_STACK_LIMIT_HUGE not in sys5 */ - -/* This is the amount to subtract from u.u_ar0 - to get the offset in the core file of the register values. */ - -#define KERNEL_U_ADDR 0xe0000000 - -#define REGISTER_U_ADDR(addr, blockend, regno) \ - (addr) = i386_register_u_addr ((blockend),(regno)); - -#if 0 -/* Interface definitions for kernel debugger KDB. */ - -/* Map machine fault codes into signal numbers. - First subtract 0, divide by 4, then index in a table. - Faults for which the entry in this table is 0 - are not handled by KDB; the program's own trap handler - gets to handle then. */ - -#define FAULT_CODE_ORIGIN 0 -#define FAULT_CODE_UNITS 4 -#define FAULT_TABLE \ -{ 0, 0, 0, 0, 0, 0, 0, 0, \ - 0, 0, 0, 0, 0, 0, 0, 0, \ - 0, 0, 0, 0, 0, 0, 0, 0} - -/* Start running with a stack stretching from BEG to END. - BEG and END should be symbols meaningful to the assembler. - This is used only for kdb. */ - -#define INIT_STACK(beg, end) {} - -/* Push the frame pointer register on the stack. */ -#define PUSH_FRAME_PTR {} - -/* Copy the top-of-stack to the frame pointer register. */ -#define POP_FRAME_PTR {} - -/* After KDB is entered by a fault, push all registers - that GDB thinks about (all NUM_REGS of them), - so that they appear in order of ascending GDB register number. - The fault code will be on the stack beyond the last register. */ - -#define PUSH_REGISTERS {} - -/* Assuming the registers (including processor status) have been - pushed on the stack in order of ascending GDB register number, - restore them and return to the address in the saved PC register. */ - -#define POP_REGISTERS {} -#endif /* 0 */ diff --git a/gdb/xm-i386v32.h b/gdb/xm-i386v32.h deleted file mode 100644 index 4a6932ad8b3..00000000000 --- a/gdb/xm-i386v32.h +++ /dev/null @@ -1,28 +0,0 @@ -/* Macro defintions for i386, running System V 3.2. - Copyright (C) 1989 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include "xm-i386v.h" - -/* Apparently there is inconsistency among various System V's about what - the name of this field is. */ -#define U_FPSTATE(u) u.u_fps.u_fpstate - -/* TIOCGETC is defined in System V 3.2 termio.h, but struct tchars - is not. This makes problems for inflow.c. */ -#define TIOCGETC_BROKEN diff --git a/gdb/xm-irix3.h b/gdb/xm-irix3.h deleted file mode 100644 index e155a419f0b..00000000000 --- a/gdb/xm-irix3.h +++ /dev/null @@ -1,36 +0,0 @@ -/* Copyright (C) 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* This is for the iris. */ - -#define HAVE_TERMIO - -#define U_REGS_OFFSET 0 - -#include "xm-bigmips.h" - -/* Override register locations in upage for SGI machines */ -#undef REGISTER_U_ADDR -#define REGISTER_U_ADDR(addr, blockend, regno) \ - if (regno < PC_REGNUM) \ - addr = regno; \ - else \ - addr = regno + NSIG_HNDLRS; /* Skip over signal handlers */ - -/* Don't need special routines for the SGI -- we can use infptrace.c */ -#undef FETCH_INFERIOR_REGISTERS diff --git a/gdb/xm-isi.h b/gdb/xm-isi.h deleted file mode 100644 index e26cb9548fc..00000000000 --- a/gdb/xm-isi.h +++ /dev/null @@ -1,95 +0,0 @@ -/* Definitions to make GDB run on an ISI Optimum V (3.05) under 4.3bsd. - Copyright (C) 1987, 1989 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#define HOST_BYTE_ORDER BIG_ENDIAN - -/* This has not been tested on ISI's running BSD 4.2, but it will probably - work. */ - -/* This is the amount to subtract from u.u_ar0 - to get the offset in the core file of the register values. */ - -/*#define KERNEL_U_ADDR 0x10800000*/ -#define KERNEL_U_ADDR 0 - -/* expects blockend to be u.u_ar0 */ -extern int rloc[]; /* Defined in isi-dep.c */ -#define REGISTER_U_ADDR(addr, blockend, regno) \ -{ blockend &= UPAGES*NBPG - 1; \ - if (regno < 18) addr = (int)blockend + rloc[regno]*4; \ - else if (regno < 26) addr = (int) &((struct user *)0)->u_68881_regs \ - + (regno - 18) * 12; \ - else if (regno < 29) addr = (int) &((struct user *)0)->u_68881_regs \ - + 8 * 12 + (regno - 26) * 4; \ -} - -/* Compensate for lack of `vprintf' function. */ -#define MISSING_VPRINTF - -/* Interface definitions for kernel debugger KDB. */ - -/* Map machine fault codes into signal numbers. - First subtract 0, divide by 4, then index in a table. - Faults for which the entry in this table is 0 - are not handled by KDB; the program's own trap handler - gets to handle then. */ - -#define FAULT_CODE_ORIGIN 0 -#define FAULT_CODE_UNITS 4 -#define FAULT_TABLE \ -{ 0, 0, 0, 0, SIGTRAP, 0, 0, 0, \ - 0, SIGTRAP, 0, 0, 0, 0, 0, SIGKILL, \ - 0, 0, 0, 0, 0, 0, 0, 0, \ - SIGILL } - -/* Start running with a stack stretching from BEG to END. - BEG and END should be symbols meaningful to the assembler. - This is used only for kdb. */ - -#define INIT_STACK(beg, end) \ -{ asm (".globl end"); \ - asm ("movl $ end, sp"); \ - asm ("clrl fp"); } - -/* Push the frame pointer register on the stack. */ -#define PUSH_FRAME_PTR \ - asm ("movel fp, -(sp)"); - -/* Copy the top-of-stack to the frame pointer register. */ -#define POP_FRAME_PTR \ - asm ("movl (sp), fp"); - -/* After KDB is entered by a fault, push all registers - that GDB thinks about (all NUM_REGS of them), - so that they appear in order of ascending GDB register number. - The fault code will be on the stack beyond the last register. */ - -#define PUSH_REGISTERS \ -{ asm ("clrw -(sp)"); \ - asm ("pea 10(sp)"); \ - asm ("movem $ 0xfffe,-(sp)"); } - -/* Assuming the registers (including processor status) have been - pushed on the stack in order of ascending GDB register number, - restore them and return to the address in the saved PC register. */ - -#define POP_REGISTERS \ -{ asm ("subil $8,28(sp)"); \ - asm ("movem (sp),$ 0xffff"); \ - asm ("rte"); } diff --git a/gdb/xm-m68k.h b/gdb/xm-m68k.h deleted file mode 100644 index f417e97b569..00000000000 --- a/gdb/xm-m68k.h +++ /dev/null @@ -1,22 +0,0 @@ -/* Macro definitions for running gdb on host machines with m68k cpu's. - Copyright (C) 1991, Free Software Foundation, Inc. - Written by Fred Fish at Cygnus Support (fnf@cygint) - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#define HOST_BYTE_ORDER BIG_ENDIAN - diff --git a/gdb/xm-m88k.h b/gdb/xm-m88k.h deleted file mode 100644 index bad91f8ddaa..00000000000 --- a/gdb/xm-m88k.h +++ /dev/null @@ -1,66 +0,0 @@ -/* Host-machine dependent parameters for Motorola 88000, for GDB. - Copyright 1986, 1987, 1988, 1989, 1990, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#define HOST_BYTE_ORDER BIG_ENDIAN - -#if !defined (USG) -#define USG 1 -#endif - -#include - -#ifdef __GNUC__ -#define memcpy __builtin_memcpy -/* gcc doesn't have this, at least not gcc 1.92. */ -/* #define memset __builtin_memset */ -#define strcmp __builtin_strcmp -#endif - -#ifdef DGUX -#define x_foff _x_x._x_offset -#define x_fname _x_name -#define USER ptrace_user -#define _BSD_WAIT_FLAVOR -#endif - -#define HAVE_TERMIO - -#ifndef USIZE -#define USIZE 2048 -#endif -#define NBPG NBPC -#define UPAGES USIZE - -/* Get rid of any system-imposed stack limit if possible. */ - -#define SET_STACK_LIMIT_HUGE - -/* This is the amount to subtract from u.u_ar0 - to get the offset in the core file of the register values. */ - -/* Since registers r0 through r31 are stored directly in the struct ptrace_user, - (for m88k BCS) - the ptrace_user offsets are sufficient and KERNEL_U_ADDRESS can be 0 */ - -#define KERNEL_U_ADDR 0 - -#define REGISTER_U_ADDR(addr, blockend, regno) \ - (addr) = m88k_register_u_addr ((blockend),(regno)); - -#define FETCH_INFERIOR_REGISTERS diff --git a/gdb/xm-merlin.h b/gdb/xm-merlin.h deleted file mode 100644 index 0564f0d7ed5..00000000000 --- a/gdb/xm-merlin.h +++ /dev/null @@ -1,120 +0,0 @@ -/* Definitions to make GDB run on a merlin under utek 2.1 - Copyright (C) 1986, 1987, 1989 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* This machine doesn't have the siginterrupt call. */ -#define NO_SIGINTERRUPT - -/* Under Utek, a ptrace'd process can be the only active process for - an executable. Therefore instead of /bin/sh use gdb-sh (which should - just be a copy of /bin/sh which is world readable and writeable). */ -#define SHELL_FILE "/usr/gnu/lib/gdb-sh" - -#define HOST_BYTE_ORDER LITTLE_ENDIAN - -/* This is the amount to subtract from u.u_ar0 - to get the offset in the core file of the register values. */ - -#define KERNEL_U_ADDR (0xfef000) - -#define REGISTER_U_ADDR(addr, blockend, regno) \ -{ \ - switch (regno) { \ - case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: \ - addr = blockend + (R0 - regno) * sizeof (int); break; \ - case PC_REGNUM: \ - addr = blockend + PC * sizeof (int); break; \ - case SP_REGNUM: \ - addr = blockend + SP * sizeof (int); break; \ - case FP_REGNUM: \ - addr = blockend + FP * sizeof (int); break; \ - case PS_REGNUM: \ - addr = blockend + 12 * sizeof (int); break; \ - case FPS_REGNUM: \ - addr = 108; break; \ - case FP0_REGNUM + 0: case FP0_REGNUM + 1: \ - case FP0_REGNUM + 2: case FP0_REGNUM + 3: \ - case FP0_REGNUM + 4: case FP0_REGNUM + 5: \ - case FP0_REGNUM + 6: case FP0_REGNUM + 7: \ - addr = 76 + (regno - FP0_REGNUM) * sizeof (float); break; \ - case LP0_REGNUM + 0: case LP0_REGNUM + 1: \ - case LP0_REGNUM + 2: case LP0_REGNUM + 3: \ - addr = 76 + (regno - LP0_REGNUM) * sizeof (double); break; \ - default: \ - printf ("bad argument to REGISTER_U_ADDR %d\n", regno); \ - abort (); \ - } \ -} - -/* Compensate for lack of `vprintf' function. */ -#define MISSING_VPRINTF - -#if 0 -/* Interface definitions for kernel debugger KDB. */ - -/* Map machine fault codes into signal numbers. - First subtract 0, divide by 4, then index in a table. - Faults for which the entry in this table is 0 - are not handled by KDB; the program's own trap handler - gets to handle then. */ - -#define FAULT_CODE_ORIGIN 0 -#define FAULT_CODE_UNITS 4 -#define FAULT_TABLE \ -{ 0, SIGKILL, SIGSEGV, 0, 0, 0, 0, 0, \ - 0, 0, SIGTRAP, SIGTRAP, 0, 0, 0, 0, \ - 0, 0, 0, 0, 0, 0, 0, 0} - -/* Start running with a stack stretching from BEG to END. - BEG and END should be symbols meaningful to the assembler. - This is used only for kdb. */ - -#define INIT_STACK(beg, end) \ -{ asm (".globl end"); \ - asm ("movl $ end, sp"); \ - asm ("clrl fp"); } - -/* Push the frame pointer register on the stack. */ -#define PUSH_FRAME_PTR \ - asm ("pushl fp"); - -/* Copy the top-of-stack to the frame pointer register. */ -#define POP_FRAME_PTR \ - asm ("movl (sp), fp"); - -/* After KDB is entered by a fault, push all registers - that GDB thinks about (all NUM_REGS of them), - so that they appear in order of ascending GDB register number. - The fault code will be on the stack beyond the last register. */ - -#define PUSH_REGISTERS \ -{ asm ("pushl 8(sp)"); \ - asm ("pushl 8(sp)"); \ - asm ("pushal 0x14(sp)"); \ - asm ("pushr $037777"); } - -/* Assuming the registers (including processor status) have been - pushed on the stack in order of ascending GDB register number, - restore them and return to the address in the saved PC register. */ - -#define POP_REGISTERS \ -{ asm ("popr $037777"); \ - asm ("subl2 $8,(sp)"); \ - asm ("movl (sp),sp"); \ - asm ("rei"); } -#endif /* 0 */ diff --git a/gdb/xm-mips.h b/gdb/xm-mips.h deleted file mode 100644 index ff2bebf51b5..00000000000 --- a/gdb/xm-mips.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Definitions to make GDB run on a mips box under 4.3bsd. - Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc. - Contributed by Per Bothner(bothner@cs.wisc.edu) at U.Wisconsin - and by Alessandro Forin(af@cs.cmu.edu) at CMU - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#if !defined (HOST_BYTE_ORDER) -#define HOST_BYTE_ORDER LITTLE_ENDIAN -#endif - -/* Get rid of any system-imposed stack limit if possible */ - -#define SET_STACK_LIMIT_HUGE - -#define KERNEL_U_ADDR 0 /* Not needed. */ - -/* Only used for core files on DECstations. */ - -#define REGISTER_U_ADDR(addr, blockend, regno) \ - if (regno < 38) addr = (NBPG*UPAGES) + (regno - 38)*sizeof(int);\ - else addr = 0; /* ..somewhere in the pcb */ - -/* Override copies of {fetch,store}_inferior_registers in infptrace.c. */ -#define FETCH_INFERIOR_REGISTERS - -/* Kernel is a bit tenacious about sharing text segments, disallowing bpts. */ -#define ONE_PROCESS_WRITETEXT diff --git a/gdb/xm-news.h b/gdb/xm-news.h deleted file mode 100644 index eae0248885a..00000000000 --- a/gdb/xm-news.h +++ /dev/null @@ -1,143 +0,0 @@ -/* Parameters for execution on a Sony/NEWS, for GDB, the GNU debugger. - Copyright (C) 1987, 1989 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#define HOST_BYTE_ORDER BIG_ENDIAN - -#define HAVE_WAIT_STRUCT - -/* Get rid of any system-imposed stack limit if possible. */ - -#define SET_STACK_LIMIT_HUGE - -/* We can't use "isatty" or "fileno" on this machine. This isn't good, - but it will have to do. */ -#define ISATTY(FP) ((FP) == stdin || (FP) == stdout) - -/* THis is the amount to subtract from u.u_ar0 - to get the offset in the core file of the register values. */ - -#define KERNEL_U_ADDR UADDR - -/* The offsets in this macro are from /usr/include/machine/reg.h */ - -#define REGISTER_U_ADDR(addr, blockend, regno) \ -{ static char offsets[] = { \ - /*d0-d7:*/1,2,3,4,5,6,7,8, \ - /*a0-a6:*/9,10,11,12,13,14,15, /*sp:*/-4, /*ps:*/0, /*pc:*/-1, \ - /*fp0-fp7:*/19,22,25,28,31,34,37,40, /*fpc:*/16,17,18 }; \ - addr = blockend + 4 * offsets[regno]; \ -} - -/* Compensate for lack of `vprintf' function. */ -#define MISSING_VPRINTF - -/* NewsOS 3 apparently dies on large alloca's -- roland@ai.mit.edu. */ -#define BROKEN_LARGE_ALLOCA - - -/* Interface definitions for kernel debugger KDB. */ - -/* Use GNU assembler instead of standard assembler */ -#define USE_GAS - -/* Motorola assembly format */ -#ifndef USE_GAS -#define MOTOROLA -#endif - -/* Map machine fault codes into signal numbers. - First subtract 0, divide by 4, then index in a table. - Faults for which the entry in this table is 0 - are not handled by KDB; the program's own trap handler - gets to handle then. */ - -#define FAULT_CODE_ORIGIN 0 -#define FAULT_CODE_UNITS 4 -#define FAULT_TABLE \ -{ 0, 0, 0, 0, SIGTRAP, 0, 0, 0, \ - 0, SIGTRAP, 0, 0, 0, 0, 0, SIGKILL, \ - 0, 0, 0, 0, 0, 0, 0, 0, \ - SIGILL } - -/* Start running with a stack stretching from BEG to END. - BEG and END should be symbols meaningful to the assembler. - This is used only for kdb. */ - -#ifdef MOTOROLA -#define INIT_STACK(beg, end) \ -{ asm (".globl end"); \ - asm ("move.l $ end, sp"); \ - asm ("clr.l fp"); } -#else -#define INIT_STACK(beg, end) \ -{ asm (".globl end"); \ - asm ("movel $ end, sp"); \ - asm ("clrl fp"); } -#endif - -/* Push the frame pointer register on the stack. */ -#ifdef MOTOROLA -#define PUSH_FRAME_PTR \ - asm ("move.l fp, -(sp)"); -#else -#define PUSH_FRAME_PTR \ - asm ("movel fp, -(sp)"); -#endif - -/* Copy the top-of-stack to the frame pointer register. */ -#ifdef MOTOROLA -#define POP_FRAME_PTR \ - asm ("move.l (sp), fp"); -#else -#define POP_FRAME_PTR \ - asm ("movl (sp), fp"); -#endif - -/* After KDB is entered by a fault, push all registers - that GDB thinks about (all NUM_REGS of them), - so that they appear in order of ascending GDB register number. - The fault code will be on the stack beyond the last register. */ - -#ifdef MOTOROLA -#define PUSH_REGISTERS \ -{ asm ("clr.w -(sp)"); \ - asm ("pea (10,sp)"); \ - asm ("movem $ 0xfffe,-(sp)"); } -#else -#define PUSH_REGISTERS \ -{ asm ("clrw -(sp)"); \ - asm ("pea 10(sp)"); \ - asm ("movem $ 0xfffe,-(sp)"); } -#endif - -/* Assuming the registers (including processor status) have been - pushed on the stack in order of ascending GDB register number, - restore them and return to the address in the saved PC register. */ - -#ifdef MOTOROLA -#define POP_REGISTERS \ -{ asm ("subi.l $8,28(sp)"); \ - asm ("movem (sp),$ 0xffff"); \ - asm ("rte"); } -#else -#define POP_REGISTERS \ -{ asm ("subil $8,28(sp)"); \ - asm ("movem (sp),$ 0xffff"); \ - asm ("rte"); } -#endif diff --git a/gdb/xm-news1000.h b/gdb/xm-news1000.h deleted file mode 100644 index 58671c5ecd0..00000000000 --- a/gdb/xm-news1000.h +++ /dev/null @@ -1,26 +0,0 @@ -/* Parameters for a Sony/NEWS series 1000 with News-OS version 3, - for GDB, the GNU debugger. - Copyright (C) 1990 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* This is required by Sony include files like so we - get the right offset into the u area. Relying on the compiler - to define this only works for cc, not gcc. */ -#undef mc68030 -#define mc68030 -#include "xm-news.h" diff --git a/gdb/xm-np1.h b/gdb/xm-np1.h deleted file mode 100644 index 8d3bf40e647..00000000000 --- a/gdb/xm-np1.h +++ /dev/null @@ -1,99 +0,0 @@ -/* Parameters for execution on a Gould NP1, for GDB, the GNU debugger. - Copyright (C) 1986, 1987, 1989 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#define HOST_BYTE_ORDER BIG_ENDIAN - -/* Get rid of any system-imposed stack limit if possible. */ -#define SET_STACK_LIMIT_HUGE - -/* Address of U in kernel space */ -#define KERNEL_U_ADDR 0x7fffc000 - -/* This is a piece of magic that is given a register number REGNO - and as BLOCKEND the address in the system of the end of the user structure - and stores in ADDR the address in the kernel or core dump - of that register. */ -#define REGISTER_U_ADDR(addr, blockend, regno) { \ - addr = blockend + regno * 4; \ - if (regno == VE_REGNUM) addr = blockend - 9 * 4; \ - if (regno == PC_REGNUM) addr = blockend - 8 * 4; \ - if (regno == PS_REGNUM) addr = blockend - 7 * 4; \ - if (regno == FP_REGNUM) addr = blockend - 6 * 4; \ - if (regno >= V1_REGNUM) \ - addr = blockend + 16 * 4 + (regno - V1_REGNUM) * VR_SIZE; \ -} - -/* Don't try to write the frame pointer. */ -#define CANNOT_STORE_REGISTER(regno) ((regno) == FP_REGNUM) - -#define MISSING_VPRINTF - -/* - * No KDB support, Yet! */ -/* Interface definitions for kernel debugger KDB. */ - -/* Map machine fault codes into signal numbers. - First subtract 0, divide by 4, then index in a table. - Faults for which the entry in this table is 0 - are not handled by KDB; the program's own trap handler - gets to handle then. */ - -#define FAULT_CODE_ORIGIN 0 -#define FAULT_CODE_UNITS 4 -#define FAULT_TABLE \ -{ 0, 0, 0, 0, SIGTRAP, 0, 0, 0, \ - 0, SIGTRAP, 0, 0, 0, 0, 0, SIGKILL, \ - 0, 0, 0, 0, 0, 0, 0, 0, \ - SIGILL } - -/* Start running with a stack stretching from BEG to END. - BEG and END should be symbols meaningful to the assembler. - This is used only for kdb. */ - -#define INIT_STACK(beg, end) \ -{ asm (".globl end"); \ - asm ("movel $ end, sp"); \ - asm ("clrl fp"); } - -/* Push the frame pointer register on the stack. */ -#define PUSH_FRAME_PTR \ - asm ("movel fp, -(sp)"); - -/* Copy the top-of-stack to the frame pointer register. */ -#define POP_FRAME_PTR \ - asm ("movl (sp), fp"); - -/* After KDB is entered by a fault, push all registers - that GDB thinks about (all NUM_REGS of them), - so that they appear in order of ascending GDB register number. - The fault code will be on the stack beyond the last register. */ - -#define PUSH_REGISTERS \ -{ asm ("clrw -(sp)"); \ - asm ("pea 10(sp)"); \ - asm ("movem $ 0xfffe,-(sp)"); } - -/* Assuming the registers (including processor status) have been - pushed on the stack in order of ascending GDB register number, - restore them and return to the address in the saved PC register. */ - -#define POP_REGISTERS \ -{ asm ("subil $8,28(sp)"); \ - asm ("movem (sp),$ 0xffff"); \ - asm ("rte"); } diff --git a/gdb/xm-pn.h b/gdb/xm-pn.h deleted file mode 100644 index d180b6e6c65..00000000000 --- a/gdb/xm-pn.h +++ /dev/null @@ -1,92 +0,0 @@ -/* Parameters for execution on a Gould PN, for GDB, the GNU debugger. - Copyright (C) 1986, 1987, 1989 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#define HOST_BYTE_ORDER BIG_ENDIAN - -/* Get rid of any system-imposed stack limit if possible. */ -#define SET_STACK_LIMIT_HUGE - -#define MISSING_VPRINTF - -/* Address of U in kernel space */ -#define KERNEL_U_ADDR 0x3fc000 - -/* This is a piece of magic that is given a register number REGNO - and as BLOCKEND the address in the system of the end of the user structure - and stores in ADDR the address in the kernel or core dump - of that register. */ -#define REGISTER_U_ADDR(addr, blockend, regno) { \ - addr = blockend + regno * 4; \ - if (regno == PC_REGNUM) addr = blockend - 8 * 4; \ - if (regno == PS_REGNUM) addr = blockend - 7 * 4; \ - if (regno == SP_REGNUM) addr = blockend - 6 * 4; \ -} - -/* No KDB support, Yet! */ -/* Interface definitions for kernel debugger KDB. */ - -/* Map machine fault codes into signal numbers. - First subtract 0, divide by 4, then index in a table. - Faults for which the entry in this table is 0 - are not handled by KDB; the program's own trap handler - gets to handle then. */ - -#define FAULT_CODE_ORIGIN 0 -#define FAULT_CODE_UNITS 4 -#define FAULT_TABLE \ -{ 0, 0, 0, 0, SIGTRAP, 0, 0, 0, \ - 0, SIGTRAP, 0, 0, 0, 0, 0, SIGKILL, \ - 0, 0, 0, 0, 0, 0, 0, 0, \ - SIGILL } - -/* Start running with a stack stretching from BEG to END. - BEG and END should be symbols meaningful to the assembler. - This is used only for kdb. */ - -#define INIT_STACK(beg, end) \ -{ asm (".globl end"); \ - asm ("movel $ end, sp"); \ - asm ("clrl fp"); } - -/* Push the frame pointer register on the stack. */ -#define PUSH_FRAME_PTR \ - asm ("movel fp, -(sp)"); - -/* Copy the top-of-stack to the frame pointer register. */ -#define POP_FRAME_PTR \ - asm ("movl (sp), fp"); - -/* After KDB is entered by a fault, push all registers - that GDB thinks about (all NUM_REGS of them), - so that they appear in order of ascending GDB register number. - The fault code will be on the stack beyond the last register. */ - -#define PUSH_REGISTERS \ -{ asm ("clrw -(sp)"); \ - asm ("pea 10(sp)"); \ - asm ("movem $ 0xfffe,-(sp)"); } - -/* Assuming the registers (including processor status) have been - pushed on the stack in order of ascending GDB register number, - restore them and return to the address in the saved PC register. */ - -#define POP_REGISTERS \ -{ asm ("subil $8,28(sp)"); \ - asm ("movem (sp),$ 0xffff"); \ - asm ("rte"); } diff --git a/gdb/xm-pyr.h b/gdb/xm-pyr.h deleted file mode 100644 index 21924dfd014..00000000000 --- a/gdb/xm-pyr.h +++ /dev/null @@ -1,105 +0,0 @@ -/* Definitions to make GDB run on a Pyramidax under OSx 4.0 (4.2bsd). - Copyright (C) 1988, 1989 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#define HOST_BYTE_ORDER BIG_ENDIAN - -/* Define PYRAMID_CONTROL_FRAME_DEBUGGING to get copious messages - about reading the control stack on standard output. This - makes gdb unusable as a debugger. */ - -/* #define PYRAMID_CONTROL_FRAME_DEBUGGING */ - -/* Define PYRAMID_FRAME_DEBUGGING for ? */ - -/* use Pyramid's slightly strange ptrace */ -#define PYRAMID_PTRACE - -/* Traditional Unix virtual address spaces have thre regions: text, - data and stack. The text, initialised data, and uninitialised data - are represented in separate segments of the a.out file. - When a process dumps core, the data and stack regions are written - to a core file. This gives a debugger enough information to - reconstruct (and debug) the virtual address space at the time of - the coredump. - Pyramids have an distinct fourth region of the virtual address - space, in which the contents of the windowed registers are stacked - in fixed-size frames. Pyramid refer to this region as the control - stack. Each call (or trap) automatically allocates a new register - frame; each return deallocates the current frame and restores the - windowed registers to their values before the call. - - When dumping core, the control stack is written to a core files as - a third segment. The core-handling functions need to know to deal - with it. */ - -/* Tell dep.c what the extra segment is. */ -#define PYRAMID_CORE - -#define NO_SIGINTERRUPT - -#define HAVE_WAIT_STRUCT - -/* Get rid of any system-imposed stack limit if possible. */ - -#define SET_STACK_LIMIT_HUGE - -/* This is the amount to subtract from u.u_ar0 - to get the offset in the core file of the register values. */ - -#define KERNEL_U_ADDR (0x80000000 - (UPAGES * NBPG)) - -/* Define offsets of registers in the core file (or maybe u area) */ -#define REGISTER_U_ADDR(addr, blockend, regno) \ -{ struct user __u; \ - addr = blockend + (regno - 16 ) * 4; \ - if (regno == 67) { \ - printf("\\geting reg 67\\"); \ - addr = (int)(&__u.u_pcb.pcb_csp) - (int) &__u; \ - } else if (regno == KSP_REGNUM) { \ - printf("\\geting KSP (reg %d)\\", KSP_REGNUM); \ - addr = (int)(&__u.u_pcb.pcb_ksp) - (int) &__u; \ - } else if (regno == CSP_REGNUM) { \ - printf("\\geting CSP (reg %d\\",CSP_REGNUM); \ - addr = (int)(&__u.u_pcb.pcb_csp) - (int) &__u; \ - } else if (regno == 64) { \ - printf("\\geting reg 64\\"); \ - addr = (int)(&__u.u_pcb.pcb_csp) - (int) &__u; \ - } else if (regno == PS_REGNUM) \ - addr = blockend - 4; \ - else if (1 && ((16 > regno) && (regno > 11))) \ - addr = last_frame_offset + (4 *(regno+32)); \ - else if (0 && (12 > regno)) \ - addr = global_reg_offset + (4 *regno); \ - else if (16 > regno) \ - addr = global_reg_offset + (4 *regno); \ - else \ - addr = blockend + (regno - 16 ) * 4; \ -} - -/* Override copies of {fetch,store}_inferior_registers in infptrace.c. */ -#define FETCH_INFERIOR_REGISTERS - -/* Compensate for lack of `vprintf' function. */ -#define MISSING_VPRINTF - - -/* Interface definitions for kernel debugger KDB. */ - -/* I have *no idea* how to debug OSx kernels, so this - is flushed, possible forever. */ diff --git a/gdb/xm-rs6000.h b/gdb/xm-rs6000.h deleted file mode 100644 index 2c0c1019489..00000000000 --- a/gdb/xm-rs6000.h +++ /dev/null @@ -1,67 +0,0 @@ -/* Parameters for hosting on an RS6000, for GDB, the GNU debugger. - Copyright (C) 1986, 1987, 1989, 1991 Free Software Foundation, Inc. - Contributed by IBM Corporation. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Big end is at the low address */ - -#define HOST_BYTE_ORDER BIG_ENDIAN - -#define HAVE_TERMIO 1 -#define USG 1 -#define HAVE_SIGSETMASK 1 - -/* This system requires that we open a terminal with O_NOCTTY for it to - not become our controlling terminal. */ - -#define USE_O_NOCTTY - -/* Get rid of any system-imposed stack limit if possible. */ - -#define SET_STACK_LIMIT_HUGE - -/* Brain death inherited from PC's pervades. */ -#undef NULL -#define NULL 0 - -/* The IBM compiler requires this in order to properly compile alloca(). */ -#pragma alloca - -#define vfork fork - -/* Do implement the attach and detach commands. */ - -#define ATTACH_DETACH - -/* Override copies of {fetch,store}_inferior_registers in infptrace.c. */ - -#define FETCH_INFERIOR_REGISTERS - -/* Setpgrp() takes arguments, unlike ordinary Sys V's. */ - -#define SETPGRP_ARGS - -/* RS6000/AIXCOFF does not support PT_STEP. Has to be simulated. */ - -#define NO_SINGLE_STEP - -/* Interface between xcoff symbol reading code and AIX shared library - handling code. FIXME, this probably needs generalizing. */ - -#define XCOFF_INIT_LOADINFO() xcoff_init_loadinfo() -#define XCOFF_ADD_TOC_TO_LOADINFO(x) xcoff_add_toc_to_loadinfo (x) diff --git a/gdb/xm-rtbsd.h b/gdb/xm-rtbsd.h deleted file mode 100644 index 109d0ad0454..00000000000 --- a/gdb/xm-rtbsd.h +++ /dev/null @@ -1,46 +0,0 @@ -/* Definitions to host GDB on an IBM RT/PC running BSD Unix. - Copyright (C) 1986, 1987, 1989, 1991 Free Software Foundation, Inc. - Contributed by David Wood @ New York University (wood@lab.ultra.nyu.edu). - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Get rid of any system-imposed stack limit if possible. */ -#define SET_STACK_LIMIT_HUGE - -/* This machine is most significant byte first */ -#define HOST_BYTE_ORDER BIG_ENDIAN - -/* This OS has the wait structure */ -#define HAVE_WAIT_STRUCT - -/* This unix does not have a libc with vprintf */ -#define MISSING_VPRINTF - -#ifdef HOSTING_ONLY -/* - * This next two defines are to get GDB up and running as a host to - * do remote debugging. I know there is a gdb for the RT, but there wasn't - * an xconfig/rt* file. - */ -#define KERNEL_U_ADDR_BSD /* This may be correct, but hasn't been tested */ -#define REGISTER_U_ADDR(a,b,c) \ - (printf("GDB can not debug IBM RT/PC BSD executables (yet)\n"),\ - quit(),0) -#else -# include "GDB for the RT is not included in the distribution" -#endif - diff --git a/gdb/xm-sparc.h b/gdb/xm-sparc.h deleted file mode 100644 index cbdac01a572..00000000000 --- a/gdb/xm-sparc.h +++ /dev/null @@ -1,60 +0,0 @@ -/* Parameters for execution on a Sun 4, for GDB, the GNU debugger. - Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc. - Contributed by Michael Tiemann (tiemann@mcc.com) -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#define HOST_BYTE_ORDER BIG_ENDIAN - -/* Get rid of any system-imposed stack limit if possible. */ - -#define SET_STACK_LIMIT_HUGE - -/* Enable use of alternate code for Sun's format of core dump file. */ - -#define NEW_SUN_CORE - -/* Do implement the attach and detach commands. */ - -#define ATTACH_DETACH - -/* Override copies of {fetch,store}_inferior_registers in infptrace.c. */ - -#define FETCH_INFERIOR_REGISTERS - -/* Before storing, we need to read all the registers. */ - -#define CHILD_PREPARE_TO_STORE() read_register_bytes (0, NULL, REGISTER_BYTES) - -/* It does have a wait structure, and it might help things out . . . */ - -#define HAVE_WAIT_STRUCT - -/* Optimization for storing registers to the inferior. The hook - DO_DEFERRED_STORES - actually executes any deferred stores. It is called any time - we are going to proceed the child, or read its registers. - The hook CLEAR_DEFERRED_STORES is called when we want to throw - away the inferior process, e.g. when it dies or we kill it. - FIXME, this does not handle remote debugging cleanly. */ - -extern int deferred_stores; -extern int store_inferior_registers (); -#define DO_DEFERRED_STORES \ - if (deferred_stores) \ - store_inferior_registers (-2); -#define CLEAR_DEFERRED_STORES \ - deferred_stores = 0; diff --git a/gdb/xm-sun2.h b/gdb/xm-sun2.h deleted file mode 100644 index aac1cb873d0..00000000000 --- a/gdb/xm-sun2.h +++ /dev/null @@ -1,96 +0,0 @@ -/* Parameters for execution on a Sun, for GDB, the GNU debugger. - Copyright (C) 1986, 1987, 1989 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#define HOST_BYTE_ORDER BIG_ENDIAN - -/* This is the amount to subtract from u.u_ar0 - to get the offset in the core file of the register values. */ - -#define KERNEL_U_ADDR 0x2800 - -/* Enable use of alternate code for Sun's format of core dump file. */ - -#define NEW_SUN_CORE - -/* Do implement the attach and detach commands. */ - -#define ATTACH_DETACH - -/* Override copies of {fetch,store}_inferior_registers in infptrace.c. */ -#define FETCH_INFERIOR_REGISTERS - -/* This is a piece of magic that is given a register number REGNO - and as BLOCKEND the address in the system of the end of the user structure - and stores in ADDR the address in the kernel or core dump - of that register. */ - -#define REGISTER_U_ADDR(addr, blockend, regno) \ -{ addr = blockend + regno * 4; } - -/* Interface definitions for kernel debugger KDB. */ - -/* Map machine fault codes into signal numbers. - First subtract 0, divide by 4, then index in a table. - Faults for which the entry in this table is 0 - are not handled by KDB; the program's own trap handler - gets to handle then. */ - -#define FAULT_CODE_ORIGIN 0 -#define FAULT_CODE_UNITS 4 -#define FAULT_TABLE \ -{ 0, 0, 0, 0, SIGTRAP, 0, 0, 0, \ - 0, SIGTRAP, 0, 0, 0, 0, 0, SIGKILL, \ - 0, 0, 0, 0, 0, 0, 0, 0, \ - SIGILL } - -/* Start running with a stack stretching from BEG to END. - BEG and END should be symbols meaningful to the assembler. - This is used only for kdb. */ - -#define INIT_STACK(beg, end) \ -{ asm (".globl end"); \ - asm ("movel $ end, sp"); \ - asm ("clrl fp"); } - -/* Push the frame pointer register on the stack. */ -#define PUSH_FRAME_PTR \ - asm ("movel fp, -(sp)"); - -/* Copy the top-of-stack to the frame pointer register. */ -#define POP_FRAME_PTR \ - asm ("movl (sp), fp"); - -/* After KDB is entered by a fault, push all registers - that GDB thinks about (all NUM_REGS of them), - so that they appear in order of ascending GDB register number. - The fault code will be on the stack beyond the last register. */ - -#define PUSH_REGISTERS \ -{ asm ("clrw -(sp)"); \ - asm ("pea 10(sp)"); \ - asm ("movem $ 0xfffe,-(sp)"); } - -/* Assuming the registers (including processor status) have been - pushed on the stack in order of ascending GDB register number, - restore them and return to the address in the saved PC register. */ - -#define POP_REGISTERS \ -{ asm ("subil $8,28(sp)"); \ - asm ("movem (sp),$ 0xffff"); \ - asm ("rte"); } diff --git a/gdb/xm-sun3.h b/gdb/xm-sun3.h deleted file mode 100644 index bd5eeaa222c..00000000000 --- a/gdb/xm-sun3.h +++ /dev/null @@ -1,93 +0,0 @@ -/* Parameters for execution on a Sun, for GDB, the GNU debugger. - Copyright (C) 1986, 1987, 1989 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#define HOST_BYTE_ORDER BIG_ENDIAN - -/* Get rid of any system-imposed stack limit if possible. */ - -#define SET_STACK_LIMIT_HUGE - -/* Enable use of alternate code for Sun's format of core dump file. */ - -#define NEW_SUN_CORE - -/* Do implement the attach and detach commands. */ - -#define ATTACH_DETACH - -/* Override copies of {fetch,store}_inferior_registers in infptrace.c. */ - -#define FETCH_INFERIOR_REGISTERS - -/* We have to grab the regs since we store all regs at once. */ - -#define CHILD_PREPARE_TO_STORE() \ - read_register_bytes (0, (char *)NULL, REGISTER_BYTES) - -/* Interface definitions for kernel debugger KDB. */ - -/* Map machine fault codes into signal numbers. - First subtract 0, divide by 4, then index in a table. - Faults for which the entry in this table is 0 - are not handled by KDB; the program's own trap handler - gets to handle then. */ - -#define FAULT_CODE_ORIGIN 0 -#define FAULT_CODE_UNITS 4 -#define FAULT_TABLE \ -{ 0, 0, 0, 0, SIGTRAP, 0, 0, 0, \ - 0, SIGTRAP, 0, 0, 0, 0, 0, SIGKILL, \ - 0, 0, 0, 0, 0, 0, 0, 0, \ - SIGILL } - -/* Start running with a stack stretching from BEG to END. - BEG and END should be symbols meaningful to the assembler. - This is used only for kdb. */ - -#define INIT_STACK(beg, end) \ -{ asm (".globl end"); \ - asm ("movel #end, sp"); \ - asm ("movel #0,a6"); } - -/* Push the frame pointer register on the stack. */ -#define PUSH_FRAME_PTR \ - asm ("movel a6,sp@-"); - -/* Copy the top-of-stack to the frame pointer register. */ -#define POP_FRAME_PTR \ - asm ("movl sp@,a6"); - -/* After KDB is entered by a fault, push all registers - that GDB thinks about (all NUM_REGS of them), - so that they appear in order of ascending GDB register number. - The fault code will be on the stack beyond the last register. */ - -#define PUSH_REGISTERS \ -{ asm ("clrw -(sp)"); \ - asm ("pea sp@(10)"); \ - asm ("movem #0xfffe,sp@-"); } - -/* Assuming the registers (including processor status) have been - pushed on the stack in order of ascending GDB register number, - restore them and return to the address in the saved PC register. */ - -#define POP_REGISTERS \ -{ asm ("subil #8,sp@(28)"); \ - asm ("movem sp@,#0xffff"); \ - asm ("rte"); } diff --git a/gdb/xm-sun386.h b/gdb/xm-sun386.h deleted file mode 100644 index aea57635f0f..00000000000 --- a/gdb/xm-sun386.h +++ /dev/null @@ -1,41 +0,0 @@ -/* Parameters for execution on a Sun 386i, for GDB, the GNU debugger. - Copyright (C) 1986, 1987, 1989 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#define HOST_BYTE_ORDER LITTLE_ENDIAN - -/* Get rid of any system-imposed stack limit if possible. */ - -/* If I do this on SunOS 4.0.1, I get SIGSEGV's on (some) instructions which - try to access the stack. */ -/* #define SET_STACK_LIMIT_HUGE */ - -#define BROKEN_LARGE_ALLOCA - -/* Enable use of alternate code for Sun's format of core dump file. */ - -#define NEW_SUN_CORE - -/* Do implement the attach and detach commands. */ - -#define ATTACH_DETACH - -/* Override copies of {fetch,store}_inferior_registers in infptrace.c. */ -#define FETCH_INFERIOR_REGISTERS - -#define PREPARE_TO_STORE() read_register_bytes (0, NULL, REGISTER_BYTES) diff --git a/gdb/xm-sun3os4.h b/gdb/xm-sun3os4.h deleted file mode 100644 index d7d1c958d04..00000000000 --- a/gdb/xm-sun3os4.h +++ /dev/null @@ -1,28 +0,0 @@ -/* Macro definitions for a sun 3 running os 4. - Copyright (C) 1989, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include "xm-sun3.h" -#define FPU - -/* Large alloca's fail because the attempt to increase the stack limit in - main() fails because shared libraries are allocated just below the initial - stack limit. The SunOS kernel will not allow the stack to grow into - the area occupied by the shared libraries. Sun knows about this bug - but has no obvious fix for it. */ -#define BROKEN_LARGE_ALLOCA diff --git a/gdb/xm-sun4os4.h b/gdb/xm-sun4os4.h deleted file mode 100644 index 75f10375079..00000000000 --- a/gdb/xm-sun4os4.h +++ /dev/null @@ -1,28 +0,0 @@ -/* Macro definitions for running gdb on a Sun 4 running sunos 4. - Copyright (C) 1989, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include "xm-sparc.h" -#define FPU - -/* Large alloca's fail because the attempt to increase the stack limit in - main() fails because shared libraries are allocated just below the initial - stack limit. The SunOS kernel will not allow the stack to grow into - the area occupied by the shared libraries. Sun knows about this bug - but has no obvious fix for it. */ -#define BROKEN_LARGE_ALLOCA diff --git a/gdb/xm-svr4.h b/gdb/xm-svr4.h deleted file mode 100755 index f4c4a53690f..00000000000 --- a/gdb/xm-svr4.h +++ /dev/null @@ -1,56 +0,0 @@ -/* Definitions for running gdb on a host machine running any flavor of SVR4. - Copyright (C) 1991, Free Software Foundation, Inc. - Written by Fred Fish at Cygnus Support (fnf@cygint) - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* SVR4 has /proc support, so use it instead of ptrace. */ - -#define USE_PROC_FS - -/* SVR4 has termio facilities. */ - -#define HAVE_TERMIO - -/* TIOCGETC and TIOCGLTC are picked up somewhere, but struct tchars - and struct ltchars are not. This makes problems for inflow.c. - It is unknown at this time if this is a generic SVR4 problem or - one just limited to the initial SVR4 port host machine. */ - -#define TIOCGETC_BROKEN -#define TIOCGLTC_BROKEN - -/* SVR4 is a derivative of System V Release 3 (USG) */ - -#define USG - -/* Get rid of any system-imposed stack limit if possible. */ - -/* #define SET_STACK_LIMIT_HUGE */ - -/* SVR4 machines can easily do attach and detach via /proc (procfs.c) - support */ - -#define ATTACH_DETACH - -/* If we are using SVR4 /proc instead of ptrace, use CREATE_INFERIOR_HOOK - to do internal /proc initialization. */ - -#ifdef USE_PROC_FS -#define CREATE_INFERIOR_HOOK(pid) inferior_proc_init(pid) -#endif - diff --git a/gdb/xm-symmetry.h b/gdb/xm-symmetry.h deleted file mode 100644 index 4e1aeac6598..00000000000 --- a/gdb/xm-symmetry.h +++ /dev/null @@ -1,249 +0,0 @@ -/* Definitions to make GDB run on a Sequent Symmetry under dynix 3.0, - with Weitek 1167 and i387 support. - Copyright (C) 1986, 1987, 1989 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Symmetry version by Jay Vosburgh (uunet!sequent!fubar) */ - -/* This machine doesn't have the siginterrupt call. */ -#define NO_SIGINTERRUPT - -#define HAVE_WAIT_STRUCT - -/* XPT_DEBUG doesn't work yet under Dynix 3.0.12, but UNDEBUG does... */ -/* #define PTRACE_ATTACH XPT_DEBUG -#define PTRACE_DETACH XPT_UNDEBUG -#define ATTACH_DETACH */ - -#define HOST_BYTE_ORDER LITTLE_ENDIAN - -/* Get rid of any system-imposed stack limit if possible. */ - -#define SET_STACK_LIMIT_HUGE - -/* This is the amount to subtract from u.u_ar0 - to get the offset in the core file of the register values. */ - -#define KERNEL_U_ADDR (0x80000000 - (UPAGES * NBPG)) - -/* The magic numbers below are offsets into u_ar0 in the user struct. - They live in . Gdb calls this macro with blockend - holding u.u_ar0 - KERNEL_U_ADDR. Only the registers listed are - saved in the u area (along with a few others that aren't useful - here. See ). */ - -#define REGISTER_U_ADDR(addr, blockend, regno) \ -{ struct user foo; /* needed for finding fpu regs */ \ -switch (regno) { \ - case 0: \ - addr = blockend + EAX * sizeof(int); break; \ - case 1: \ - addr = blockend + EDX * sizeof(int); break; \ - case 2: \ - addr = blockend + ECX * sizeof(int); break; \ - case 3: /* st(0) */ \ - addr = blockend - \ - ((int)&foo.u_fpusave.fpu_stack[0][0] - (int)&foo); \ - break; \ - case 4: /* st(1) */ \ - addr = blockend - \ - ((int) &foo.u_fpusave.fpu_stack[1][0] - (int)&foo); \ - break; \ - case 5: \ - addr = blockend + EBX * sizeof(int); break; \ - case 6: \ - addr = blockend + ESI * sizeof(int); break; \ - case 7: \ - addr = blockend + EDI * sizeof(int); break; \ - case 8: /* st(2) */ \ - addr = blockend - \ - ((int) &foo.u_fpusave.fpu_stack[2][0] - (int)&foo); \ - break; \ - case 9: /* st(3) */ \ - addr = blockend - \ - ((int) &foo.u_fpusave.fpu_stack[3][0] - (int)&foo); \ - break; \ - case 10: /* st(4) */ \ - addr = blockend - \ - ((int) &foo.u_fpusave.fpu_stack[4][0] - (int)&foo); \ - break; \ - case 11: /* st(5) */ \ - addr = blockend - \ - ((int) &foo.u_fpusave.fpu_stack[5][0] - (int)&foo); \ - break; \ - case 12: /* st(6) */ \ - addr = blockend - \ - ((int) &foo.u_fpusave.fpu_stack[6][0] - (int)&foo); \ - break; \ - case 13: /* st(7) */ \ - addr = blockend - \ - ((int) &foo.u_fpusave.fpu_stack[7][0] - (int)&foo); \ - break; \ - case 14: \ - addr = blockend + ESP * sizeof(int); break; \ - case 15: \ - addr = blockend + EBP * sizeof(int); break; \ - case 16: \ - addr = blockend + EIP * sizeof(int); break; \ - case 17: \ - addr = blockend + FLAGS * sizeof(int); break; \ - case 18: /* fp1 */ \ - case 19: /* fp2 */ \ - case 20: /* fp3 */ \ - case 21: /* fp4 */ \ - case 22: /* fp5 */ \ - case 23: /* fp6 */ \ - case 24: /* fp7 */ \ - case 25: /* fp8 */ \ - case 26: /* fp9 */ \ - case 27: /* fp10 */ \ - case 28: /* fp11 */ \ - case 29: /* fp12 */ \ - case 30: /* fp13 */ \ - case 31: /* fp14 */ \ - case 32: /* fp15 */ \ - case 33: /* fp16 */ \ - case 34: /* fp17 */ \ - case 35: /* fp18 */ \ - case 36: /* fp19 */ \ - case 37: /* fp20 */ \ - case 38: /* fp21 */ \ - case 39: /* fp22 */ \ - case 40: /* fp23 */ \ - case 41: /* fp24 */ \ - case 42: /* fp25 */ \ - case 43: /* fp26 */ \ - case 44: /* fp27 */ \ - case 45: /* fp28 */ \ - case 46: /* fp29 */ \ - case 47: /* fp30 */ \ - case 48: /* fp31 */ \ - addr = blockend - \ - ((int) &foo.u_fpasave.fpa_regs[(regno)-18] - (int)&foo); \ - } \ -} - -/* Compensate for lack of `vprintf' function. */ - -#define MISSING_VPRINTF - -/* Override copies of {fetch,store}_inferior_registers in infptrace.c. */ - -#define FETCH_INFERIOR_REGISTERS - -/* We must fetch all the regs before storing, since we store all at once. */ - -#define CHILD_PREPARE_TO_STORE() read_register_bytes (0, NULL, REGISTER_BYTES) - -/* Interface definitions for kernel debugger KDB. */ -/* This doesn't work... */ -/* Map machine fault codes into signal numbers. - First subtract 0, divide by 4, then index in a table. - Faults for which the entry in this table is 0 - are not handled by KDB; the program's own trap handler - gets to handle then. */ - -#define FAULT_CODE_ORIGIN 0 -#define FAULT_CODE_UNITS 4 -#define FAULT_TABLE \ -{ 0, SIGKILL, SIGSEGV, 0, 0, 0, 0, 0, \ - 0, 0, SIGTRAP, SIGTRAP, 0, 0, 0, 0, \ - 0, 0, 0, 0, 0, 0, 0, 0} - -/* Start running with a stack stretching from BEG to END. - BEG and END should be symbols meaningful to the assembler. - This is used only for kdb. */ - -#define INIT_STACK(beg, end) \ -{ asm (".globl end"); \ - asm ("movl $ end, %esp"); \ - asm ("movl %ebp, $0"); } - -/* Push the frame pointer register on the stack. */ -#define PUSH_FRAME_PTR \ - asm ("pushl %ebp"); - -/* Copy the top-of-stack to the frame pointer register. */ -#define POP_FRAME_PTR \ - asm ("movl (%esp), %ebp"); - -/* After KDB is entered by a fault, push all registers - that GDB thinks about (all NUM_REGS of them), - so that they appear in order of ascending GDB register number. - The fault code will be on the stack beyond the last register. */ - -#define PUSH_REGISTERS \ -{ asm("pushad"); } -/* -{ asm("pushl %eax"); \ - asm("pushl %edx"); \ - asm("pushl %ecx"); \ - asm("pushl %st(0)"); \ - asm("pushl %st(1)"); \ - asm("pushl %ebx"); \ - asm("pushl %esi"); \ - asm("pushl %edi"); \ - asm("pushl %st(2)"); \ - asm("pushl %st(3)"); \ - asm("pushl %st(4)"); \ - asm("pushl %st(5)"); \ - asm("pushl %st(6)"); \ - asm("pushl %st(7)"); \ - asm("pushl %esp"); \ - asm("pushl %ebp"); \ - asm("pushl %eip"); \ - asm("pushl %eflags"); \ - asm("pushl %fp1"); \ - asm("pushl %fp2"); \ - asm("pushl %fp3"); \ - asm("pushl %fp4"); \ - asm("pushl %fp5"); \ - asm("pushl %fp6"); \ - asm("pushl %fp7"); \ - asm("pushl %fp8"); \ - asm("pushl %fp9"); \ - asm("pushl %fp10"); \ - asm("pushl %fp11"); \ - asm("pushl %fp12"); \ - asm("pushl %fp13"); \ - asm("pushl %fp14"); \ - asm("pushl %fp15"); \ - asm("pushl %fp16"); \ - asm("pushl %fp17"); \ - asm("pushl %fp18"); \ - asm("pushl %fp19"); \ - asm("pushl %fp20"); \ - asm("pushl %fp21"); \ - asm("pushl %fp22"); \ - asm("pushl %fp23"); \ - asm("pushl %fp24"); \ - asm("pushl %fp25"); \ - asm("pushl %fp26"); \ - asm("pushl %fp27"); \ - asm("pushl %fp28"); \ - asm("pushl %fp29"); \ - asm("pushl %fp30"); \ - asm("pushl %fp31"); \ -} -*/ -/* Assuming the registers (including processor status) have been - pushed on the stack in order of ascending GDB register number, - restore them and return to the address in the saved PC register. */ - -#define POP_REGISTERS \ -{ asm ("popad"); } diff --git a/gdb/xm-tahoe.h b/gdb/xm-tahoe.h deleted file mode 100644 index d18d6835595..00000000000 --- a/gdb/xm-tahoe.h +++ /dev/null @@ -1,129 +0,0 @@ -/* Definitions to make GDB hosted on a tahoe running 4.3-Reno - Copyright (C) 1986, 1987, 1989, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - * Ported by the State University of New York at Buffalo by the Distributed - * Computer Systems Lab, Department of Computer Science, 1991. - */ - -/* Get rid of any system-imposed stack limit if possible. */ - -#define SET_STACK_LIMIT_HUGE - -#define REGISTER_U_ADDR(addr, blockend, regno) \ -{ addr = blockend - 100 + regno * 4; \ - if (regno == PC_REGNUM) addr = blockend - 8; \ - if (regno == PS_REGNUM) addr = blockend - 4; \ - if (regno == FP_REGNUM) addr = blockend - 40; \ - if (regno == SP_REGNUM) addr = blockend - 36; \ - if (regno == AL_REGNUM) addr = blockend - 20; \ - if (regno == AH_REGNUM) addr = blockend - 24;} - -/* Interface definitions for kernel debugger KDB. */ - -/* Map machine fault codes into signal numbers. - First subtract 0, divide by 4, then index in a table. - Faults for which the entry in this table is 0 - are not handled by KDB; the program's own trap handler - gets to handle then. */ - -#define FAULT_CODE_ORIGIN 0 -#define FAULT_CODE_UNITS 4 -#define FAULT_TABLE \ -{ 0, SIGKILL, SIGSEGV, 0, 0, 0, 0, 0, \ - 0, 0, SIGTRAP, SIGTRAP, 0, 0, 0, 0, \ - 0, 0, 0, 0, 0, 0, 0, 0} - -/* Start running with a stack stretching from BEG to END. - BEG and END should be symbols meaningful to the assembler. - This is used only for kdb. */ - -#define INIT_STACK(beg, end) \ -{ asm (".globl end"); \ - asm ("movl $ end, sp"); \ - asm ("clrl fp"); } - -/* Push the frame pointer register on the stack. */ - -#define PUSH_FRAME_PTR \ - asm ("pushl fp"); - -/* Copy the top-of-stack to the frame pointer register. */ - -#define POP_FRAME_PTR \ - asm ("movl (sp), fp"); - -/* After KDB is entered by a fault, push all registers - that GDB thinks about (all NUM_REGS of them), - so that they appear in order of ascending GDB register number. - The fault code will be on the stack beyond the last register. */ - -#define PUSH_REGISTERS \ -{ asm ("pushl 8(sp)"); \ - asm ("pushl 8(sp)"); \ - asm ("pushal 0x41(sp)"); \ - asm ("pushl r0" ); \ - asm ("pushl r1" ); \ - asm ("pushl r2" ); \ - asm ("pushl r3" ); \ - asm ("pushl r4" ); \ - asm ("pushl r5" ); \ - asm ("pushl r6" ); \ - asm ("pushl r7" ); \ - asm ("pushl r8" ); \ - asm ("pushl r9" ); \ - asm ("pushl r10" ); \ - asm ("pushl r11" ); \ - asm ("pushl r12" ); \ - asm ("pushl fp" ); \ - asm ("pushl sp" ); \ - asm ("pushl pc" ); \ - asm ("pushl ps" ); \ - asm ("pushl aclo" ); \ - asm ("pushl achi" ); \ -} - -/* Assuming the registers (including processor status) have been - pushed on the stack in order of ascending GDB register number, - restore them and return to the address in the saved PC register. */ - -#define POP_REGISTERS \ -{ \ - asm ("movl (sp)+, achi"); \ - asm ("movl (sp)+, aclo"); \ - asm ("movl (sp)+, ps"); \ - asm ("movl (sp)+, pc"); \ - asm ("movl (sp)+, sp"); \ - asm ("movl (sp)+, fp"); \ - asm ("movl (sp)+, r12"); \ - asm ("movl (sp)+, r11"); \ - asm ("movl (sp)+, r10"); \ - asm ("movl (sp)+, r9"); \ - asm ("movl (sp)+, r8"); \ - asm ("movl (sp)+, r7"); \ - asm ("movl (sp)+, r6"); \ - asm ("movl (sp)+, r5"); \ - asm ("movl (sp)+, r4"); \ - asm ("movl (sp)+, r3"); \ - asm ("movl (sp)+, r2"); \ - asm ("movl (sp)+, r1"); \ - asm ("movl (sp)+, r0"); \ - asm ("subl2 $8,(sp)"); \ - asm ("movl (sp),sp"); \ - asm ("rei"); } diff --git a/gdb/xm-ultra3.h b/gdb/xm-ultra3.h deleted file mode 100644 index 34bd2d20148..00000000000 --- a/gdb/xm-ultra3.h +++ /dev/null @@ -1,74 +0,0 @@ -/* Host definitions for GDB running on a 29k NYU Ultracomputer - Copyright (C) 1986, 1987, 1989, 1991 Free Software Foundation, Inc. - Contributed by David Wood (wood@lab.ultra.nyu.edu). - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Here at NYU we have what we call an ULTRA3 PE board. So - ifdefs for ULTRA3 are my doing. At this point in time, - I don't know of any other Unixi running on the 29k. */ - -#define HOST_BYTE_ORDER BIG_ENDIAN - -#define HAVE_WAIT_STRUCT - -#ifndef L_SET -# define L_SET 0 /* set the seek pointer */ -# define L_INCR 1 /* increment the seek pointer */ -# define L_XTND 2 /* extend the file size */ -#endif - -#ifndef O_RDONLY -# define O_RDONLY 0 -# define O_WRONLY 1 -# define O_RDWR 2 -#endif - -#ifndef F_OK -# define R_OK 4 -# define W_OK 2 -# define X_OK 1 -# define F_OK 0 -#endif - -/* For dirbuf[] in main.c */ -#ifndef MAXPATHLEN -#define MAXPATHLEN (1024) -#endif - -/* Get rid of any system-imposed stack limit if possible */ - -#define SET_STACK_LIMIT_HUGE - -/* Override copies of {fetch,store}_inferior_registers in infptrace.c. */ -#define FETCH_INFERIOR_REGISTERS - -/* If we ever *do* end up using the standard fetch_inferior_registers, - this is the right value for U_REGS_OFFSET. */ -#define U_REGS_OFFSET 0 - -/* System doesn't provide a list of signal names. */ -#define SYS_SIGLIST_MISSING 1 - -/* System doesn't provide siginterrupt(). */ -#define NO_SIGINTERRUPT - -/* System uses a `short' to hold a process group ID. */ -#define SHORT_PGRP - -/* No vfork in this system. */ -#define vfork() fork() diff --git a/gdb/xm-umax.h b/gdb/xm-umax.h deleted file mode 100644 index 263ac79d9b8..00000000000 --- a/gdb/xm-umax.h +++ /dev/null @@ -1,64 +0,0 @@ -/* Definitions to make GDB run on an encore under umax 4.2 - Copyright (C) 1987, 1989 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#define HOST_BYTE_ORDER LITTLE_ENDIAN - -#define HAVE_WAIT_STRUCT - -/* Offset of registers within u area. */ -#define U_REGS_OFFSET 0 - -/* Do implement the attach and detach commands... */ -#define ATTACH_DETACH - -/* Doesn't have siginterupt. */ -#define NO_SIGINTERRUPT - -/* called from register_addr() -- blockend not used for now */ -#define REGISTER_U_ADDR(addr, blockend, regno) \ -{ \ - switch (regno) { \ - case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: \ - addr = PU_R0 - (regno * sizeof (int)); break; \ - case SP_REGNUM: \ - addr = PU_SP; break; \ - case PC_REGNUM: \ - addr = PU_PC; break; \ - case FP_REGNUM: \ - addr = PU_FP; break; \ - case PS_REGNUM: \ - addr = PU_PSL; break; \ - case FPS_REGNUM: \ - addr = PU_FSR; break; \ - case FP0_REGNUM + 0: case FP0_REGNUM + 1: \ - case FP0_REGNUM + 2: case FP0_REGNUM + 3: \ - case FP0_REGNUM + 4: case FP0_REGNUM + 5: \ - case FP0_REGNUM + 6: case FP0_REGNUM + 7: \ - addr = PU_F0 + (regno - FP0_REGNUM) * sizeof (float); break; \ - case LP0_REGNUM + 0: case LP0_REGNUM + 1: \ - case LP0_REGNUM + 2: case LP0_REGNUM + 3: \ - addr = PU_F0 + (regno - LP0_REGNUM) * sizeof (double); break; \ - default: \ - printf ("bad argument to REGISTER_U_ADDR %d\n", regno); \ - abort (); \ - } \ -} - -/* Compensate for lack of `vprintf' function. */ -#define MISSING_VPRINTF diff --git a/gdb/xm-vax.h b/gdb/xm-vax.h deleted file mode 100644 index 9da7306216b..00000000000 --- a/gdb/xm-vax.h +++ /dev/null @@ -1,93 +0,0 @@ -/* Definitions to make GDB run on a vax under 4.2bsd. - Copyright (C) 1986, 1987, 1989 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#define HOST_BYTE_ORDER LITTLE_ENDIAN - -/* Get rid of any system-imposed stack limit if possible. */ - -#define SET_STACK_LIMIT_HUGE - -/* This is the amount to subtract from u.u_ar0 - to get the offset in the core file of the register values. */ - -#define KERNEL_U_ADDR (0x80000000 - (UPAGES * NBPG)) - -#define REGISTER_U_ADDR(addr, blockend, regno) \ -{ addr = blockend - 0110 + regno * 4; \ - if (regno == PC_REGNUM) addr = blockend - 8; \ - if (regno == PS_REGNUM) addr = blockend - 4; \ - if (regno == FP_REGNUM) addr = blockend - 0120; \ - if (regno == AP_REGNUM) addr = blockend - 0124; \ - if (regno == SP_REGNUM) addr = blockend - 20; } - -/* Kernel is a bit tenacious about sharing text segments, disallowing bpts. */ -#define ONE_PROCESS_WRITETEXT - -/* Interface definitions for kernel debugger KDB. */ - -/* Map machine fault codes into signal numbers. - First subtract 0, divide by 4, then index in a table. - Faults for which the entry in this table is 0 - are not handled by KDB; the program's own trap handler - gets to handle then. */ - -#define FAULT_CODE_ORIGIN 0 -#define FAULT_CODE_UNITS 4 -#define FAULT_TABLE \ -{ 0, SIGKILL, SIGSEGV, 0, 0, 0, 0, 0, \ - 0, 0, SIGTRAP, SIGTRAP, 0, 0, 0, 0, \ - 0, 0, 0, 0, 0, 0, 0, 0} - -/* Start running with a stack stretching from BEG to END. - BEG and END should be symbols meaningful to the assembler. - This is used only for kdb. */ - -#define INIT_STACK(beg, end) \ -{ asm (".globl end"); \ - asm ("movl $ end, sp"); \ - asm ("clrl fp"); } - -/* Push the frame pointer register on the stack. */ -#define PUSH_FRAME_PTR \ - asm ("pushl fp"); - -/* Copy the top-of-stack to the frame pointer register. */ -#define POP_FRAME_PTR \ - asm ("movl (sp), fp"); - -/* After KDB is entered by a fault, push all registers - that GDB thinks about (all NUM_REGS of them), - so that they appear in order of ascending GDB register number. - The fault code will be on the stack beyond the last register. */ - -#define PUSH_REGISTERS \ -{ asm ("pushl 8(sp)"); \ - asm ("pushl 8(sp)"); \ - asm ("pushal 0x14(sp)"); \ - asm ("pushr $037777"); } - -/* Assuming the registers (including processor status) have been - pushed on the stack in order of ascending GDB register number, - restore them and return to the address in the saved PC register. */ - -#define POP_REGISTERS \ -{ asm ("popr $037777"); \ - asm ("subl2 $8,(sp)"); \ - asm ("movl (sp),sp"); \ - asm ("rei"); } diff --git a/gprof/Makefile b/gprof/Makefile deleted file mode 100755 index b233afb4119..00000000000 --- a/gprof/Makefile +++ /dev/null @@ -1,25 +0,0 @@ -# @(#)Makefile 5.17 (Berkeley) 5/11/90 - -CC= gcc -MACHINE= sparc -PROG= gprof -SRCS= gprof.c arcs.c dfn.c lookup.c ${MACHINE}.c hertz.c \ - printgprof.c printlist.c -LIBS = ../bfd/libbfd.a ../libiberty/libiberty.a - -#CFLAGS+=-I${.CURDIR}/../../lib/csu.${MACHINE} -CFLAGS= -I. -I../include -O -g -DMACHINE_H=\"${MACHINE}.h\" - -OBJS= gprof.o arcs.o dfn.o lookup.o ${MACHINE}.o hertz.o \ - printgprof.o printlist.o - -all: ${PROG} - -beforeinstall: - install -c -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ - ${.CURDIR}/gprof.flat ${.CURDIR}/gprof.callg \ - ${DESTDIR}/usr/share/misc - -#.include -$(PROG): $(OBJS) - $(CC) $(CFLAGS) $(OBJS) -o $(PROG) $(LIBS) diff --git a/gprof/Makefile.in b/gprof/Makefile.in deleted file mode 100644 index 1dcfd4d7b8d..00000000000 --- a/gprof/Makefile.in +++ /dev/null @@ -1,25 +0,0 @@ - # @(#)Makefile 5.17 (Berkeley) 5/11/90 - -CC= gcc -MACHINE= sparc -PROG= gprof -SRCS= gprof.c arcs.c dfn.c lookup.c ${MACHINE}.c hertz.c \ - printgprof.c printlist.c -LIBS = ../bfd/libbfd.a ../libiberty/libiberty.a - -#CFLAGS+=-I${.CURDIR}/../../lib/csu.${MACHINE} -CFLAGS= -I. -I../include -O -g -DMACHINE_H=\"${MACHINE}.h\" - -OBJS= gprof.o arcs.o dfn.o lookup.o ${MACHINE}.o hertz.o \ - printgprof.o printlist.o - -all: ${PROG} - -beforeinstall: - install -c -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ - ${.CURDIR}/gprof.flat ${.CURDIR}/gprof.callg \ - ${DESTDIR}/usr/share/misc - -#.include -$(PROG): $(OBJS) - $(CC) $(CFLAGS) $(OBJS) -o $(PROG) $(LIBS) diff --git a/gprof/arcs.c b/gprof/arcs.c deleted file mode 100644 index 8cb6dad518b..00000000000 --- a/gprof/arcs.c +++ /dev/null @@ -1,567 +0,0 @@ -/* - * Copyright (c) 1983 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that: (1) source distributions retain this entire copyright - * notice and comment, and (2) distributions including binaries display - * the following acknowledgement: ``This product includes software - * developed by the University of California, Berkeley and its contributors'' - * in the documentation or other materials provided with the distribution - * and in all advertising materials mentioning features or use of this - * software. Neither the name of the University nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ - -#ifndef lint -static char sccsid[] = "@(#)arcs.c 5.6 (Berkeley) 6/1/90"; -#endif /* not lint */ - -#include "gprof.h" - - /* - * add (or just increment) an arc - */ -addarc( parentp , childp , count ) - nltype *parentp; - nltype *childp; - long count; -{ - arctype *calloc(); - arctype *arcp; - -# ifdef DEBUG - if ( debug & TALLYDEBUG ) { - printf( "[addarc] %d arcs from %s to %s\n" , - count , parentp -> name , childp -> name ); - } -# endif DEBUG - arcp = arclookup( parentp , childp ); - if ( arcp != 0 ) { - /* - * a hit: just increment the count. - */ -# ifdef DEBUG - if ( debug & TALLYDEBUG ) { - printf( "[tally] hit %d += %d\n" , - arcp -> arc_count , count ); - } -# endif DEBUG - arcp -> arc_count += count; - return; - } - arcp = calloc( 1 , sizeof *arcp ); - arcp -> arc_parentp = parentp; - arcp -> arc_childp = childp; - arcp -> arc_count = count; - /* - * prepend this child to the children of this parent - */ - arcp -> arc_childlist = parentp -> children; - parentp -> children = arcp; - /* - * prepend this parent to the parents of this child - */ - arcp -> arc_parentlist = childp -> parents; - childp -> parents = arcp; -} - - /* - * the code below topologically sorts the graph (collapsing cycles), - * and propagates time bottom up and flags top down. - */ - - /* - * the topologically sorted name list pointers - */ -nltype **topsortnlp; - -topcmp( npp1 , npp2 ) - nltype **npp1; - nltype **npp2; -{ - return (*npp1) -> toporder - (*npp2) -> toporder; -} - -nltype ** -doarcs() -{ - nltype *parentp, **timesortnlp; - arctype *arcp; - long index; - - /* - * initialize various things: - * zero out child times. - * count self-recursive calls. - * indicate that nothing is on cycles. - */ - for ( parentp = nl ; parentp < npe ; parentp++ ) { - parentp -> childtime = 0.0; - arcp = arclookup( parentp , parentp ); - if ( arcp != 0 ) { - parentp -> ncall -= arcp -> arc_count; - parentp -> selfcalls = arcp -> arc_count; - } else { - parentp -> selfcalls = 0; - } - parentp -> propfraction = 0.0; - parentp -> propself = 0.0; - parentp -> propchild = 0.0; - parentp -> printflag = FALSE; - parentp -> toporder = DFN_NAN; - parentp -> cycleno = 0; - parentp -> cyclehead = parentp; - parentp -> cnext = 0; - if ( cflag ) { - findcall( parentp , parentp -> value , (parentp+1) -> value ); - } - } - /* - * topologically order things - * if any node is unnumbered, - * number it and any of its descendents. - */ - for ( parentp = nl ; parentp < npe ; parentp++ ) { - if ( parentp -> toporder == DFN_NAN ) { - dfn( parentp ); - } - } - /* - * link together nodes on the same cycle - */ - cyclelink(); - /* - * Sort the symbol table in reverse topological order - */ - topsortnlp = (nltype **) calloc( nname , sizeof(nltype *) ); - if ( topsortnlp == (nltype **) 0 ) { - fprintf( stderr , "[doarcs] ran out of memory for topo sorting\n" ); - } - for ( index = 0 ; index < nname ; index += 1 ) { - topsortnlp[ index ] = &nl[ index ]; - } - qsort( topsortnlp , nname , sizeof(nltype *) , topcmp ); -# ifdef DEBUG - if ( debug & DFNDEBUG ) { - printf( "[doarcs] topological sort listing\n" ); - for ( index = 0 ; index < nname ; index += 1 ) { - printf( "[doarcs] " ); - printf( "%d:" , topsortnlp[ index ] -> toporder ); - printname( topsortnlp[ index ] ); - printf( "\n" ); - } - } -# endif DEBUG - /* - * starting from the topological top, - * propagate print flags to children. - * also, calculate propagation fractions. - * this happens before time propagation - * since time propagation uses the fractions. - */ - doflags(); - /* - * starting from the topological bottom, - * propogate children times up to parents. - */ - dotime(); - /* - * Now, sort by propself + propchild. - * sorting both the regular function names - * and cycle headers. - */ - timesortnlp = (nltype **) calloc( nname + ncycle , sizeof(nltype *) ); - if ( timesortnlp == (nltype **) 0 ) { - fprintf( stderr , "%s: ran out of memory for sorting\n" , whoami ); - } - for ( index = 0 ; index < nname ; index++ ) { - timesortnlp[index] = &nl[index]; - } - for ( index = 1 ; index <= ncycle ; index++ ) { - timesortnlp[nname+index-1] = &cyclenl[index]; - } - qsort( timesortnlp , nname + ncycle , sizeof(nltype *) , totalcmp ); - for ( index = 0 ; index < nname + ncycle ; index++ ) { - timesortnlp[ index ] -> index = index + 1; - } - return( timesortnlp ); -} - -dotime() -{ - int index; - - cycletime(); - for ( index = 0 ; index < nname ; index += 1 ) { - timepropagate( topsortnlp[ index ] ); - } -} - -timepropagate( parentp ) - nltype *parentp; -{ - arctype *arcp; - nltype *childp; - double share; - double propshare; - - if ( parentp -> propfraction == 0.0 ) { - return; - } - /* - * gather time from children of this parent. - */ - for ( arcp = parentp -> children ; arcp ; arcp = arcp -> arc_childlist ) { - childp = arcp -> arc_childp; - if ( arcp -> arc_count == 0 ) { - continue; - } - if ( childp == parentp ) { - continue; - } - if ( childp -> propfraction == 0.0 ) { - continue; - } - if ( childp -> cyclehead != childp ) { - if ( parentp -> cycleno == childp -> cycleno ) { - continue; - } - if ( parentp -> toporder <= childp -> toporder ) { - fprintf( stderr , "[propagate] toporder botches\n" ); - } - childp = childp -> cyclehead; - } else { - if ( parentp -> toporder <= childp -> toporder ) { - fprintf( stderr , "[propagate] toporder botches\n" ); - continue; - } - } - if ( childp -> ncall == 0 ) { - continue; - } - /* - * distribute time for this arc - */ - arcp -> arc_time = childp -> time - * ( ( (double) arcp -> arc_count ) / - ( (double) childp -> ncall ) ); - arcp -> arc_childtime = childp -> childtime - * ( ( (double) arcp -> arc_count ) / - ( (double) childp -> ncall ) ); - share = arcp -> arc_time + arcp -> arc_childtime; - parentp -> childtime += share; - /* - * ( 1 - propfraction ) gets lost along the way - */ - propshare = parentp -> propfraction * share; - /* - * fix things for printing - */ - parentp -> propchild += propshare; - arcp -> arc_time *= parentp -> propfraction; - arcp -> arc_childtime *= parentp -> propfraction; - /* - * add this share to the parent's cycle header, if any. - */ - if ( parentp -> cyclehead != parentp ) { - parentp -> cyclehead -> childtime += share; - parentp -> cyclehead -> propchild += propshare; - } -# ifdef DEBUG - if ( debug & PROPDEBUG ) { - printf( "[dotime] child \t" ); - printname( childp ); - printf( " with %f %f %d/%d\n" , - childp -> time , childp -> childtime , - arcp -> arc_count , childp -> ncall ); - printf( "[dotime] parent\t" ); - printname( parentp ); - printf( "\n[dotime] share %f\n" , share ); - } -# endif DEBUG - } -} - -cyclelink() -{ - register nltype *nlp; - register nltype *cyclenlp; - int cycle; - nltype *memberp; - arctype *arcp; - - /* - * Count the number of cycles, and initialze the cycle lists - */ - ncycle = 0; - for ( nlp = nl ; nlp < npe ; nlp++ ) { - /* - * this is how you find unattached cycles - */ - if ( nlp -> cyclehead == nlp && nlp -> cnext != 0 ) { - ncycle += 1; - } - } - /* - * cyclenl is indexed by cycle number: - * i.e. it is origin 1, not origin 0. - */ - cyclenl = (nltype *) calloc( ncycle + 1 , sizeof( nltype ) ); - if ( cyclenl == 0 ) { - fprintf( stderr , "%s: No room for %d bytes of cycle headers\n" , - whoami , ( ncycle + 1 ) * sizeof( nltype ) ); - done(); - } - /* - * now link cycles to true cycleheads, - * number them, accumulate the data for the cycle - */ - cycle = 0; - for ( nlp = nl ; nlp < npe ; nlp++ ) { - if ( !( nlp -> cyclehead == nlp && nlp -> cnext != 0 ) ) { - continue; - } - cycle += 1; - cyclenlp = &cyclenl[cycle]; - cyclenlp -> name = 0; /* the name */ - cyclenlp -> value = 0; /* the pc entry point */ - cyclenlp -> time = 0.0; /* ticks in this routine */ - cyclenlp -> childtime = 0.0; /* cumulative ticks in children */ - cyclenlp -> ncall = 0; /* how many times called */ - cyclenlp -> selfcalls = 0; /* how many calls to self */ - cyclenlp -> propfraction = 0.0; /* what % of time propagates */ - cyclenlp -> propself = 0.0; /* how much self time propagates */ - cyclenlp -> propchild = 0.0; /* how much child time propagates */ - cyclenlp -> printflag = TRUE; /* should this be printed? */ - cyclenlp -> index = 0; /* index in the graph list */ - cyclenlp -> toporder = DFN_NAN; /* graph call chain top-sort order */ - cyclenlp -> cycleno = cycle; /* internal number of cycle on */ - cyclenlp -> cyclehead = cyclenlp; /* pointer to head of cycle */ - cyclenlp -> cnext = nlp; /* pointer to next member of cycle */ - cyclenlp -> parents = 0; /* list of caller arcs */ - cyclenlp -> children = 0; /* list of callee arcs */ -# ifdef DEBUG - if ( debug & CYCLEDEBUG ) { - printf( "[cyclelink] " ); - printname( nlp ); - printf( " is the head of cycle %d\n" , cycle ); - } -# endif DEBUG - /* - * link members to cycle header - */ - for ( memberp = nlp ; memberp ; memberp = memberp -> cnext ) { - memberp -> cycleno = cycle; - memberp -> cyclehead = cyclenlp; - } - /* - * count calls from outside the cycle - * and those among cycle members - */ - for ( memberp = nlp ; memberp ; memberp = memberp -> cnext ) { - for ( arcp=memberp->parents ; arcp ; arcp=arcp->arc_parentlist ) { - if ( arcp -> arc_parentp == memberp ) { - continue; - } - if ( arcp -> arc_parentp -> cycleno == cycle ) { - cyclenlp -> selfcalls += arcp -> arc_count; - } else { - cyclenlp -> ncall += arcp -> arc_count; - } - } - } - } -} - -cycletime() -{ - int cycle; - nltype *cyclenlp; - nltype *childp; - - for ( cycle = 1 ; cycle <= ncycle ; cycle += 1 ) { - cyclenlp = &cyclenl[ cycle ]; - for ( childp = cyclenlp -> cnext ; childp ; childp = childp -> cnext ) { - if ( childp -> propfraction == 0.0 ) { - /* - * all members have the same propfraction except those - * that were excluded with -E - */ - continue; - } - cyclenlp -> time += childp -> time; - } - cyclenlp -> propself = cyclenlp -> propfraction * cyclenlp -> time; - } -} - - /* - * in one top to bottom pass over the topologically sorted namelist - * propagate: - * printflag as the union of parents' printflags - * propfraction as the sum of fractional parents' propfractions - * and while we're here, sum time for functions. - */ -doflags() -{ - int index; - nltype *childp; - nltype *oldhead; - - oldhead = 0; - for ( index = nname-1 ; index >= 0 ; index -= 1 ) { - childp = topsortnlp[ index ]; - /* - * if we haven't done this function or cycle, - * inherit things from parent. - * this way, we are linear in the number of arcs - * since we do all members of a cycle (and the cycle itself) - * as we hit the first member of the cycle. - */ - if ( childp -> cyclehead != oldhead ) { - oldhead = childp -> cyclehead; - inheritflags( childp ); - } -# ifdef DEBUG - if ( debug & PROPDEBUG ) { - printf( "[doflags] " ); - printname( childp ); - printf( " inherits printflag %d and propfraction %f\n" , - childp -> printflag , childp -> propfraction ); - } -# endif DEBUG - if ( ! childp -> printflag ) { - /* - * printflag is off - * it gets turned on by - * being on -f list, - * or there not being any -f list and not being on -e list. - */ - if ( onlist( flist , childp -> name ) - || ( !fflag && !onlist( elist , childp -> name ) ) ) { - childp -> printflag = TRUE; - } - } else { - /* - * this function has printing parents: - * maybe someone wants to shut it up - * by putting it on -e list. (but favor -f over -e) - */ - if ( ( !onlist( flist , childp -> name ) ) - && onlist( elist , childp -> name ) ) { - childp -> printflag = FALSE; - } - } - if ( childp -> propfraction == 0.0 ) { - /* - * no parents to pass time to. - * collect time from children if - * its on -F list, - * or there isn't any -F list and its not on -E list. - */ - if ( onlist( Flist , childp -> name ) - || ( !Fflag && !onlist( Elist , childp -> name ) ) ) { - childp -> propfraction = 1.0; - } - } else { - /* - * it has parents to pass time to, - * but maybe someone wants to shut it up - * by puttting it on -E list. (but favor -F over -E) - */ - if ( !onlist( Flist , childp -> name ) - && onlist( Elist , childp -> name ) ) { - childp -> propfraction = 0.0; - } - } - childp -> propself = childp -> time * childp -> propfraction; - printtime += childp -> propself; -# ifdef DEBUG - if ( debug & PROPDEBUG ) { - printf( "[doflags] " ); - printname( childp ); - printf( " ends up with printflag %d and propfraction %f\n" , - childp -> printflag , childp -> propfraction ); - printf( "time %f propself %f printtime %f\n" , - childp -> time , childp -> propself , printtime ); - } -# endif DEBUG - } -} - - /* - * check if any parent of this child - * (or outside parents of this cycle) - * have their print flags on and set the - * print flag of the child (cycle) appropriately. - * similarly, deal with propagation fractions from parents. - */ -inheritflags( childp ) - nltype *childp; -{ - nltype *headp; - arctype *arcp; - nltype *parentp; - nltype *memp; - - headp = childp -> cyclehead; - if ( childp == headp ) { - /* - * just a regular child, check its parents - */ - childp -> printflag = FALSE; - childp -> propfraction = 0.0; - for (arcp = childp -> parents ; arcp ; arcp = arcp -> arc_parentlist) { - parentp = arcp -> arc_parentp; - if ( childp == parentp ) { - continue; - } - childp -> printflag |= parentp -> printflag; - /* - * if the child was never actually called - * (e.g. this arc is static (and all others are, too)) - * no time propagates along this arc. - */ - if ( childp -> ncall ) { - childp -> propfraction += parentp -> propfraction - * ( ( (double) arcp -> arc_count ) - / ( (double) childp -> ncall ) ); - } - } - } else { - /* - * its a member of a cycle, look at all parents from - * outside the cycle - */ - headp -> printflag = FALSE; - headp -> propfraction = 0.0; - for ( memp = headp -> cnext ; memp ; memp = memp -> cnext ) { - for (arcp = memp->parents ; arcp ; arcp = arcp->arc_parentlist) { - if ( arcp -> arc_parentp -> cyclehead == headp ) { - continue; - } - parentp = arcp -> arc_parentp; - headp -> printflag |= parentp -> printflag; - /* - * if the cycle was never actually called - * (e.g. this arc is static (and all others are, too)) - * no time propagates along this arc. - */ - if ( headp -> ncall ) { - headp -> propfraction += parentp -> propfraction - * ( ( (double) arcp -> arc_count ) - / ( (double) headp -> ncall ) ); - } - } - } - for ( memp = headp ; memp ; memp = memp -> cnext ) { - memp -> printflag = headp -> printflag; - memp -> propfraction = headp -> propfraction; - } - } -} diff --git a/gprof/config/mt-i386 b/gprof/config/mt-i386 deleted file mode 100644 index 5b457984f7f..00000000000 --- a/gprof/config/mt-i386 +++ /dev/null @@ -1 +0,0 @@ -MACHINE=i386 diff --git a/gprof/config/mt-sparc b/gprof/config/mt-sparc deleted file mode 100644 index b88bc27e5a9..00000000000 --- a/gprof/config/mt-sparc +++ /dev/null @@ -1 +0,0 @@ -MACHINE=sparc diff --git a/gprof/config/tmake-i386 b/gprof/config/tmake-i386 deleted file mode 100755 index 5b457984f7f..00000000000 --- a/gprof/config/tmake-i386 +++ /dev/null @@ -1 +0,0 @@ -MACHINE=i386 diff --git a/gprof/config/tmake-sparc b/gprof/config/tmake-sparc deleted file mode 100755 index b88bc27e5a9..00000000000 --- a/gprof/config/tmake-sparc +++ /dev/null @@ -1 +0,0 @@ -MACHINE=sparc diff --git a/gprof/configure b/gprof/configure deleted file mode 100755 index a42008f88ba..00000000000 --- a/gprof/configure +++ /dev/null @@ -1,678 +0,0 @@ -#!/bin/sh -# Please do not edit this file. It is generated automatically from -# configure.in and a configure template. -configdirs= - -# the debugger. -#set -x - -#!/bin/sh - -# Configuration script template -# Copyright (C) 1988, 1990, 1991 Free Software Foundation, Inc. - -#This file is part of GNU. - -#GNU CC 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 1, or (at your option) -#any later version. - -#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 -#GNU General Public License for more details. - -#You should have received a copy of the GNU General Public License -#along with GNU CC; see the file COPYING. If not, write to -#the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - -# $Id$ - -# -# Shell script to create proper links to machine-dependent files in -# preparation for compilation. -# -# If configure succeeds, it leaves its status in config.status. -# If configure fails after disturbing the status quo, -# config.status is removed. -# - -remove=rm -hard_link=ln -symbolic_link='ln -s' - -#for Test -#remove="echo rm" -#hard_link="echo ln" -#symbolic_link="echo ln -s" - -progname=$0 - -# clear some things potentially inherited from environment. - -ansi= -clib= -defaulttargets= -destdir= -fatal= -hostsubdir= -norecurse= -removing= -srcdir= -srctrigger= -target= -targets= -targetsubdir= -template= -verbose= - -for arg in $*; -do - case ${arg} in - -ansi | +ansi) - ansi=true - ;; - -clib | +c*) - clib=clib - ;; - -destdir=* | +destdir=* | +destdi=* | +destd=* | +dest=* | +des=* | +de=* | +d=*) - destdir=`echo ${arg} | sed 's/[+-]d[a-z]*=//'` - ;; - -forcesubdirs | +forcesubdirs | +forcesubdir | +forcesubdi | +forcesubd \ - | +forcesub | +forcesu | +forces | +force | +forc | +for | +fo | +f) - forcesubdirs=${arg} - ;; - -languages=* | +languages=* | +language=* | +languag=* \ - | +langua=* | +langu=* | +lang=* | +lan=* | +la=* \ - | +l=*) - languages="${languages} `echo ${arg} | sed 's/[+-]l[a-z]*=//'`" - ;; - -gas | +gas | +ga | +g) - gas=yes - ;; - -help | +h | +help) - fatal=true - ;; - -nfp | +nfp | +nf | +n) - nfp=yes - ;; - -norecurse | +norecurse) - norecurse=true - ;; - -rm | +rm) - removing=${arg} - ;; -# -srcdir=* | +srcdir=* | +srcdi=* | +srcd=* | +src=* | +sr=* | +s=*) -# srcdir=`echo ${arg} | sed 's/[+-]s[a-z]*=//'` -# ;; - -target=* | +target=* | +targe=* | +targ=* | +tar=* | +ta=* | +t=*) - if [ -n "${targets}" ] ; then - forcesubdirs="+forcesubdirs" - fi - - newtargets="${targets} `echo ${arg} | sed 's/[+-]t[a-z]*=//'`" - targets="${newtargets}" - ;; - -template=* | +template=*) - template=`echo ${arg} | sed 's/[+-]template=//'` - ;; - +verbose | +verbos | +verbo | +verb | +ver | +ve | +v) - verbose=${arg} - ;; - -* | +*) - (echo ; - echo "Unrecognized option: \"${arg}\"". ; - echo) 1>&2 - fatal=true - ;; - *) - if [ -n "${hosts}" ] ; then - forcesubdirs="+forcesubdirs" - fi - - newhosts="${hosts} ${arg}" - hosts=${newhosts} - ;; - esac -done - -if [ -n "${verbose}" ] ; then - echo `pwd`/configure $* - echo targets=\"${targets}\" -fi - -# process host and target only if not rebuilding configure itself or removing. -if [ -z "${template}" -a -z "${removing}" -a -z "${fatal}" ] ; then - # Complain if an arg is missing - if [ -z "${hosts}" ] ; then - (echo ; - echo "configure: No HOST specified." ; - echo) 2>&1 - fatal=true - fi -fi - -if [ -n "${fatal}" -o "${hosts}" = "help" ] ; then - (echo "Usage: configure HOST" ; - echo ; - echo "Options: [defaults in brackets]" ; - echo " +ansi configure w/ANSI library. [no ansi lib]" ; - echo " +destdir=MYDIR configure for installation into MYDIR. [/usr/local]" ; - echo " +forcesubdirs configure in subdirectories. [in source directories]" ; - echo " +lang=LANG configure to build LANG. [gcc]" ; - echo " +help print this message. [normal config]" ; - echo " +gas configure the compilers for use with gas. [native as]" ; - echo " +nfp configure the compilers default to soft floating point. [hard float]" ; - echo " +norecurse configure this directory only. [recurse]" ; - echo " +rm remove this configuration. [build a configuration]" ; - echo " +target=TARGET configure for TARGET. [TARGET = HOST]" ; - echo " +template=TEM rebuild configure using TEM. [normal config]" ; - echo ; - echo "Where HOST and TARGET are something like \"vax\", \"sun3\", \"encore\", etc." ; - echo "Asking for more than one \"+target\" implies \"+forcesubdirs\". Any other" ; - echo "options given will apply to all targets.") 1>&2 - - if [ -r config.status ] ; then - cat config.status - fi - - exit 1 -fi - -#### configure.in common parts come in here. -# This file is a shell script that supplies the information necessary -# to tailor a template configure script into the configure script -# appropriate for this directory. For more information, check any -# existing configure script. - -srctrigger=gprof.c -srcname="gprof" - -## end of common part. - -# are we rebuilding config itself? -if [ -n "${template}" ] ; then - if [ ! -r ${template} ] ; then - echo "Can't find template ${template}." - exit 1 - fi - -# prep the template - sed -e '/^#### configure.in common parts come in here.$/,/^## end of common part.$/c\ -#### configure.in common parts come in here.\ -## end of common part.' \ - -e '/^#### configure.in per-host parts come in here.$/,/^## end of per-host part.$/c\ -#### configure.in per-host parts come in here.\ -## end of per-host part.' \ - -e '/^#### configure.in per-target parts come in here.$/,/^## end of per-target part.$/c\ -#### configure.in per-target parts come in here.\ -## end of per-target part.' \ - < ${template} > template.new - - if [ -r configure.in ] ; then - if [ -z "`grep '^# per\-host:' configure.in`" ] ; then - echo `pwd`/configure.in has no "per-host:" line. - exit 1 - fi - - if [ -z "`grep '^# per\-target:' configure.in`" ] ; then - echo `pwd`/configure.in has no "per-target:" line. - exit 1 - fi - - # split configure.in into common, per-host, and per-target parts - sed -e '/^# per\-host:/,$d' configure.in > configure.com - sed -e '1,/^# per\-host:/d' -e '/^# per\-target:/,$d' configure.in > configure.hst - sed -e '1,/^# per\-target:/d' configure.in > configure.tgt - - # and insert them - sed -e '/^#### configure.in common parts come in here.$/ r configure.com' \ - -e '/^#### configure.in per\-host parts come in here.$/ r configure.hst' \ - -e '/^#### configure.in per\-target parts come in here.$/ r configure.tgt' \ - template.new > configure.new - - rm -f configure.com configure.tgt configure.hst - else - echo Warning: no configure.in in `pwd` - cat ${template} >> configure - fi - - chmod a+x configure.new - rm template.new -# mv configure configure.old - mv configure.new configure - echo Rebuilt configure in `pwd` - - if [ -z "${norecurse}" ] ; then - while [ -n "${configdirs}" ] ; do - # set configdir to car of configdirs, configdirs to cdr of configdirs - set ${configdirs}; configdir=$1; shift; configdirs=$* - - if [ "`echo ${configdir}.*`" != "${configdir}.*" ] ; then - targetspecificdirs=${configdir}.* - else - targetspecificdirs= - fi - - for i in ${configdir} ${targetspecificdirs} ; do - if [ -d $i ] ; then - if [ -r $i/configure ] ; then - (cd $i ; - ./configure +template=${template} ${verbose}) - else - echo No configure script in `pwd`/$i - fi - else - echo Warning: directory $i is missing. - fi - done - done - fi - - exit 0 -fi - -# some sanity checks on configure.in -if [ -z "${srctrigger}" ] ; then - echo srctrigger not set in configure.in. `pwd` not configured. - exit 1 -fi - -for host in ${hosts} ; do - # Default other arg - if [ -z "${targets}" -o -n "${defaulttargets}" ] ; then - targets=${host} - defaulttargets=true - fi - - host_makefile_frag=config/hmake-${host} - -#### configure.in per-host parts come in here. - -## end of per-host part. - - - for target in ${targets} ; do - - if [ -n "${verbose}" ] ; then - echo host \= \"${host}\", target \= \"${target}\". - fi - - target_makefile_frag=config/tmake-${target} - -#### configure.in per-target parts come in here. - -files= -links= -## end of per-target part. - - # Temporarily, we support only direct subdir builds. - hostsubdir=Host-${host} - targetsubdir=Target-${target} - - if [ -n "${removing}" ] ; then - if [ -n "${forcesubdirs}" ] ; then - if [ -d "${hostsubdir}" ] ; then - rm -rf ${hostsubdir}/${targetsubdir} - - if [ -z "`(ls ${hostsubdir}) 2>&1 | grep Target-`" ] ; then - rm -rf ${hostsubdir} - fi - else - echo Warning: no `pwd`/${hostsubdir} to remove. - fi - else - rm -f Makefile config.status ${links} - fi - else - if [ -n "${forcesubdirs}" ] ; then - # check for existing status before allowing forced subdirs. - if [ -f Makefile ] ; then - echo "Makefile already exists in source directory. `pwd` not configured." - exit 1 - fi - - if [ ! -d ${hostsubdir} ] ; then mkdir ${hostsubdir} ; fi - cd ${hostsubdir} - - if [ ! -d ${targetsubdir} ] ; then mkdir ${targetsubdir} ; fi - cd ${targetsubdir} - - srcdir=../.. - else - # if not subdir builds, then make sure none exist. - if [ -n "`(ls .) 2>&1 | grep Host-`" ] ; then - echo "Configured subdirs exist. `pwd` not configured." - exit 1 - fi - fi - - # Find the source files, if location was not specified. - if [ -z "${srcdir}" ] ; then - srcdirdefaulted=1 - srcdir=. - if [ -n "${srctrigger}" -a ! -r ${srctrigger} ] ; then - srcdir=.. - fi - fi - - if [ -n "${srctrigger}" -a ! -r ${srcdir}/${srctrigger} ] ; then - if [ -z "${srcdirdefaulted}" ] ; then - echo "${progname}: Can't find ${srcname} sources in `pwd`/${srcdir}" 1>&2 - else - echo "${progname}: Can't find ${srcname} sources in `pwd`/. or `pwd`/.." 1>&2 - fi - - echo \(At least ${srctrigger} is missing.\) 1>&2 - exit 1 - fi - - # Set up the list of links to be made. - # ${links} is the list of link names, and ${files} is the list of names to link to. - - # Make the links. - while [ -n "${files}" ] ; do - # set file to car of files, files to cdr of files - set ${files}; file=$1; shift; files=$* - set ${links}; link=$1; shift; links=$* - - if [ ! -r ${srcdir}/${file} ] ; then - echo "${progname}: cannot create a link \"${link}\"," 1>&2 - echo "since the file \"${file}\" does not exist." 1>&2 - exit 1 - fi - - ${remove} -f ${link} - rm -f config.status - # Make a symlink if possible, otherwise try a hard link - ${symbolic_link} ${srcdir}/${file} ${link} 2>/dev/null || ${hard_link} ${srcdir}/${file} ${link} - - if [ ! -r ${link} ] ; then - echo "${progname}: unable to link \"${link}\" to \"${srcdir}/${file}\"." 1>&2 - exit 1 - fi - echo "Linked \"${link}\" to \"${srcdir}/${file}\"." - done - - # Create a .gdbinit file which runs the one in srcdir - # and tells GDB to look there for source files. - - case ${srcdir} in - .) - ;; - *) - echo "dir ." > .gdbinit - echo "dir ${srcdir}" >> .gdbinit - echo "source ${srcdir}/.gdbinit" >> .gdbinit - ;; - esac - - # Install a makefile, and make it set VPATH - # if necessary so that the sources are found. - # Also change its value of srcdir. - - # FIXME-someday: This business of always writing to .tem and mv back - # is so that I don't screw things up while developing. Once this - # template is stable, these should be optimized. xoxorich. - - # Define macro CROSS_COMPILE in compilation if this is a cross-compiler. - if [ "${host}" != "${target}" ] ; then - echo "CROSS=-DCROSS_COMPILE" > Makefile - echo "ALL=start.encap" >> Makefile - else - echo "ALL=all.internal" > Makefile - fi - - # set target, host, VPATH - echo "host = ${host}" >> Makefile - echo "target = ${target}" >> Makefile - - if [ -n "${forcesubdirs}" ] ; then - echo "subdir = /${hostsubdir}/${targetsubdir}" >> Makefile - else - echo "subdir =" >> Makefile - fi - - # echo "workdir = `pwd`" >> Makefile - echo "VPATH = ${srcdir}" >> Makefile - - # add Makefile.in - cat ${srcdir}/Makefile.in >> Makefile - - # and shake thoroughly. - # Conditionalize the makefile for this host. - if [ -f ${srcdir}/${host_makefile_frag} ] ; then - sed -e "/^####/ r ${srcdir}/${host_makefile_frag}" Makefile > Makefile.tem - mv Makefile.tem Makefile - fi - - # Conditionalize the makefile for this target. - if [ -f ${srcdir}/${target_makefile_frag} ] ; then - sed -e "/^####/ r ${srcdir}/${target_makefile_frag}" Makefile > Makefile.tem - mv Makefile.tem Makefile - fi - - # set srcdir - sed "s@^srcdir = \.@srcdir = ${srcdir}@" Makefile > Makefile.tem - mv Makefile.tem Makefile - - # set destdir - if [ -n "${destdir}" ] ; then - sed "s:^destdir =.*$:destdir = ${destdir}:" Makefile > Makefile.tem - mv Makefile.tem Makefile - fi - - # Remove all formfeeds, since some Makes get confused by them. - sed "s/ //" Makefile >> Makefile.tem - mv Makefile.tem Makefile - - # reset SUBDIRS - sed "s:^SUBDIRS =.*$:SUBDIRS = ${configdirs}:" Makefile > Makefile.tem - mv Makefile.tem Makefile - - # reset NONSUBDIRS - sed "s:^NONSUBDIRS =.*$:NONSUBDIRS = ${noconfigdirs}:" Makefile > Makefile.tem - mv Makefile.tem Makefile - - using= - if [ -f ${srcdir}/${host_makefile_frag} ] ; then - using=" using \"${host_makefile_frag}\"" - fi - - if [ -f ${srcdir}/${target_makefile_frag} ] ; then - if [ -z "${using}" ] ; then - andusing=" using \"${target_makefile_frag}\"" - else - andusing="${using} and \"${target_makefile_frag}\"" - fi - else - andusing=${using} - fi - - echo "Created \"Makefile\"" in `pwd`${andusing}. - - if [ "${host}" = "${target}" ] ; then - echo "Links are now set up for use with a ${target}." \ - > config.status - # | tee ${srcdir}/config.status - else - echo "Links are now set up for host ${host} and target ${target}." \ - > config.status - # | tee ${srcdir}/config.status - fi - - originaldir=`pwd` - cd ${srcdir} - fi - done # for each target - -# # Now build a Makefile for this host. -# if [ -n "${forcesubdirs}" ] ; then -# cd ${hostsubdir} -# cat > GNUmakefile << E!O!F -## Makefile generated by configure for host ${host}. -# -#%: -# for i in ${targets} ; do \ -# $(MAKE) -C Target-\$i \$@ -# -#all clean stage1 stage2 stage3 stage4etags tags TAGS -#E!O!F -# fi -done # for each host - -# If there are subdirectories, then recurse. - -if [ -n "${norecurse}" -o -z "${configdirs}" ] ; then exit 0 ; fi - -# configdirs is not null -for configdir in ${configdirs} ; do - echo Configuring ${configdir}... - specifics= - commons= - - if [ -n "${defaulttargets}" ] ; then - for host in ${hosts} ; do - if [ -d ${configdir}.${host} ] ; then - newspecifics="${specifics} ${host}" - specifics=${newspecifics} - else - newcommons="${commons} ${host}" - commons=${newcommons} - fi # if target specific - done # for each host - - if [ -n "${commons}" ] ; then - if [ -d ${configdir} ] ; then - (cd ${configdir} ; - ./configure ${commons} ${verbose} ${forcesubdirs} ${removing} "+destdir=${destdir}") \ - | sed 's/^/ /' - else - echo Warning: directory \"${configdir}\" is missing. - fi - fi # if any common hosts - - if [ -n "${specifics}" ] ; then - for host in ${specifics} ; do - echo Configuring target specific directory ${configdir}.${host}... - (cd ${configdir}.${host} ; - ./configure ${host} ${verbose} ${forcesubdirs} ${removing} "+destdir=${destdir}") \ - | sed 's/^/ /' - done # for host in specifics - fi # if there are any specifics - else - - for target in ${targets} ; do - if [ -d ${configdir}.${target} ] ; then - newspecifics="${specifics} ${target}" - specifics=${newspecifics} - else - newcommons="${commons} +target=${target}" - commons=${newcommons} - fi - - done # check for target specific dir override - - if [ -n "${verbose}" ] ; then - echo " "commons=\"${commons}\" - echo " "specifics=\"${specifics}\" - fi # if verbose - - if [ -n "${commons}" ] ; then - if [ -d ${configdir} ] ; then - (cd ${configdir} ; - ./configure ${hosts} ${verbose} ${forcesubdirs} ${removing} ${commons} "+destdir=${destdir}") \ - | sed 's/^/ /' - else - echo Warning: directory \"${configdir}\" is missing. - fi - fi # if any commons - - if [ -n "${specifics}" ] ; then - for target in ${specifics} ; do - echo Configuring target specific directory ${configdir}.${target}... - (cd ${configdir}.${target} ; - ./configure ${hosts} ${verbose} ${forcesubdirs} ${removing} "+target=${target}" "+destdir=${destdir}") \ - | sed 's/^/ /' - done - fi # if any specifics - fi # not default targets -done - -exit 0 - -# -# $Log$ -# Revision 1.1 1991/07/23 19:09:21 sef -# Initial revision -# -# Revision 1.20 1991/06/18 15:30:33 rich -# Added prms. -# -# Revision 1.19 1991/06/13 04:21:14 rich -# Re-arrange so that gcc, which creates directories, gets installed -# first. -# -# Revision 1.18 1991/06/12 21:23:05 rich -# correctly propogate destdir -# -# Revision 1.17 1991/06/09 20:39:58 rich -# Added +clib option. -# -# Revision 1.16 1991/05/27 21:04:21 rich -# Removed clib for now. -# -# Revision 1.15 1991/05/27 20:54:24 rich -# fixed a bug in multiple targets -# -# Revision 1.14 1991/05/22 01:44:04 rich -# remove gdb until config issues resolve. -# -# Revision 1.13 1991/05/19 08:00:09 rich -# Added gdb. -# -# Revision 1.12 1991/05/19 00:32:13 rich -# Changes to deal with missing subdirs gracefully, and changes dictated -# from dropping configure over gdb. -# -# Revision 1.4 1991/05/19 00:16:45 rich -# Configure for gdb. -# -# Revision 1.10 1991/05/04 00:58:38 rich -# Fix program name bug. -# -# Revision 1.9 1991/05/03 19:14:18 rich -# Changed getopt to libiberty, commented out an aborted attempt at host -# level Makefiles because it caused errors on +rm, add a warning for -# directories expected to be removed on +rm but that don't exist. -# -# Revision 1.8 1991/04/24 16:50:59 rich -# Three staging checkpoint. -# -# Revision 1.7 1991/04/17 01:34:47 rich -# Added getopt for binutils, fixed problem with host dependancies in -# configure.template. -# -# Revision 1.6 1991/04/16 00:18:44 rich -# Now handles multiple hosts and targets. -# -# Revision 1.5 1991/04/15 23:43:44 rich -# Now handles multiple hosts and targets. -# -# Revision 1.4 1991/04/13 02:11:03 rich -# Config cut 3. We now almost install a29k. -# -# Revision 1.3 1991/04/11 02:41:54 rich -# Cut 2 config. Subdirs. -# -# -# - -# -# Local Variables: -# fill-column: 131 -# End: -# - -# end of configure.template diff --git a/gprof/configure.in b/gprof/configure.in deleted file mode 100644 index 107cd6a409e..00000000000 --- a/gprof/configure.in +++ /dev/null @@ -1,14 +0,0 @@ -# This file is a shell script that supplies the information necessary -# to tailor a template configure script into the configure script -# appropriate for this directory. For more information, check any -# existing configure script. - -srctrigger=gprof.c -srcname="gprof" - -# per-host: - -# per-target: - -files= -links= diff --git a/gprof/dfn.c b/gprof/dfn.c deleted file mode 100644 index 1d464beb276..00000000000 --- a/gprof/dfn.c +++ /dev/null @@ -1,302 +0,0 @@ -/* - * Copyright (c) 1983 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that: (1) source distributions retain this entire copyright - * notice and comment, and (2) distributions including binaries display - * the following acknowledgement: ``This product includes software - * developed by the University of California, Berkeley and its contributors'' - * in the documentation or other materials provided with the distribution - * and in all advertising materials mentioning features or use of this - * software. Neither the name of the University nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ - -#ifndef lint -static char sccsid[] = "@(#)dfn.c 5.4 (Berkeley) 6/1/90"; -#endif /* not lint */ - -#include -#include "gprof.h" - -#define DFN_DEPTH 100 -struct dfnstruct { - nltype *nlentryp; - int cycletop; -}; -typedef struct dfnstruct dfntype; - -dfntype dfn_stack[ DFN_DEPTH ]; -int dfn_depth = 0; - -int dfn_counter = DFN_NAN; - - /* - * given this parent, depth first number its children. - */ -dfn( parentp ) - nltype *parentp; -{ - arctype *arcp; - -# ifdef DEBUG - if ( debug & DFNDEBUG ) { - printf( "[dfn] dfn(" ); - printname( parentp ); - printf( ")\n" ); - } -# endif DEBUG - /* - * if we're already numbered, no need to look any furthur. - */ - if ( dfn_numbered( parentp ) ) { - return; - } - /* - * if we're already busy, must be a cycle - */ - if ( dfn_busy( parentp ) ) { - dfn_findcycle( parentp ); - return; - } - /* - * visit yourself before your children - */ - dfn_pre_visit( parentp ); - /* - * visit children - */ - for ( arcp = parentp -> children ; arcp ; arcp = arcp -> arc_childlist ) { - dfn( arcp -> arc_childp ); - } - /* - * visit yourself after your children - */ - dfn_post_visit( parentp ); -} - - /* - * push a parent onto the stack and mark it busy - */ -dfn_pre_visit( parentp ) - nltype *parentp; -{ - - dfn_depth += 1; - if ( dfn_depth >= DFN_DEPTH ) { - fprintf( stderr , "[dfn] out of my depth (dfn_stack overflow)\n" ); - exit( 1 ); - } - dfn_stack[ dfn_depth ].nlentryp = parentp; - dfn_stack[ dfn_depth ].cycletop = dfn_depth; - parentp -> toporder = DFN_BUSY; -# ifdef DEBUG - if ( debug & DFNDEBUG ) { - printf( "[dfn_pre_visit]\t\t%d:" , dfn_depth ); - printname( parentp ); - printf( "\n" ); - } -# endif DEBUG -} - - /* - * are we already numbered? - */ -bool -dfn_numbered( childp ) - nltype *childp; -{ - - return ( childp -> toporder != DFN_NAN && childp -> toporder != DFN_BUSY ); -} - - /* - * are we already busy? - */ -bool -dfn_busy( childp ) - nltype *childp; -{ - - if ( childp -> toporder == DFN_NAN ) { - return FALSE; - } - return TRUE; -} - - /* - * MISSING: an explanation - */ -dfn_findcycle( childp ) - nltype *childp; -{ - int cycletop; - nltype *cycleheadp; - nltype *tailp; - int index; - - for ( cycletop = dfn_depth ; cycletop > 0 ; cycletop -= 1 ) { - cycleheadp = dfn_stack[ cycletop ].nlentryp; - if ( childp == cycleheadp ) { - break; - } - if ( childp -> cyclehead != childp && - childp -> cyclehead == cycleheadp ) { - break; - } - } - if ( cycletop <= 0 ) { - fprintf( stderr , "[dfn_findcycle] couldn't find head of cycle\n" ); - exit( 1 ); - } -# ifdef DEBUG - if ( debug & DFNDEBUG ) { - printf( "[dfn_findcycle] dfn_depth %d cycletop %d " , - dfn_depth , cycletop ); - printname( cycleheadp ); - printf( "\n" ); - } -# endif DEBUG - if ( cycletop == dfn_depth ) { - /* - * this is previous function, e.g. this calls itself - * sort of boring - */ - dfn_self_cycle( childp ); - } else { - /* - * glom intervening functions that aren't already - * glommed into this cycle. - * things have been glommed when their cyclehead field - * points to the head of the cycle they are glommed into. - */ - for ( tailp = cycleheadp ; tailp -> cnext ; tailp = tailp -> cnext ) { - /* void: chase down to tail of things already glommed */ -# ifdef DEBUG - if ( debug & DFNDEBUG ) { - printf( "[dfn_findcycle] tail " ); - printname( tailp ); - printf( "\n" ); - } -# endif DEBUG - } - /* - * if what we think is the top of the cycle - * has a cyclehead field, then it's not really the - * head of the cycle, which is really what we want - */ - if ( cycleheadp -> cyclehead != cycleheadp ) { - cycleheadp = cycleheadp -> cyclehead; -# ifdef DEBUG - if ( debug & DFNDEBUG ) { - printf( "[dfn_findcycle] new cyclehead " ); - printname( cycleheadp ); - printf( "\n" ); - } -# endif DEBUG - } - for ( index = cycletop + 1 ; index <= dfn_depth ; index += 1 ) { - childp = dfn_stack[ index ].nlentryp; - if ( childp -> cyclehead == childp ) { - /* - * not yet glommed anywhere, glom it - * and fix any children it has glommed - */ - tailp -> cnext = childp; - childp -> cyclehead = cycleheadp; -# ifdef DEBUG - if ( debug & DFNDEBUG ) { - printf( "[dfn_findcycle] glomming " ); - printname( childp ); - printf( " onto " ); - printname( cycleheadp ); - printf( "\n" ); - } -# endif DEBUG - for ( tailp = childp ; tailp->cnext ; tailp = tailp->cnext ) { - tailp -> cnext -> cyclehead = cycleheadp; -# ifdef DEBUG - if ( debug & DFNDEBUG ) { - printf( "[dfn_findcycle] and its tail " ); - printname( tailp -> cnext ); - printf( " onto " ); - printname( cycleheadp ); - printf( "\n" ); - } -# endif DEBUG - } - } else if ( childp -> cyclehead != cycleheadp /* firewall */ ) { - fprintf( stderr , - "[dfn_busy] glommed, but not to cyclehead\n" ); - } - } - } -} - - /* - * deal with self-cycles - * for lint: ARGSUSED - */ -dfn_self_cycle( parentp ) - nltype *parentp; -{ - /* - * since we are taking out self-cycles elsewhere - * no need for the special case, here. - */ -# ifdef DEBUG - if ( debug & DFNDEBUG ) { - printf( "[dfn_self_cycle] " ); - printname( parentp ); - printf( "\n" ); - } -# endif DEBUG -} - - /* - * visit a node after all its children - * [MISSING: an explanation] - * and pop it off the stack - */ -dfn_post_visit( parentp ) - nltype *parentp; -{ - nltype *memberp; - -# ifdef DEBUG - if ( debug & DFNDEBUG ) { - printf( "[dfn_post_visit]\t%d: " , dfn_depth ); - printname( parentp ); - printf( "\n" ); - } -# endif DEBUG - /* - * number functions and things in their cycles - * unless the function is itself part of a cycle - */ - if ( parentp -> cyclehead == parentp ) { - dfn_counter += 1; - for ( memberp = parentp ; memberp ; memberp = memberp -> cnext ) { - memberp -> toporder = dfn_counter; -# ifdef DEBUG - if ( debug & DFNDEBUG ) { - printf( "[dfn_post_visit]\t\tmember " ); - printname( memberp ); - printf( " -> toporder = %d\n" , dfn_counter ); - } -# endif DEBUG - } - } else { -# ifdef DEBUG - if ( debug & DFNDEBUG ) { - printf( "[dfn_post_visit]\t\tis part of a cycle\n" ); - } -# endif DEBUG - } - dfn_depth -= 1; -} diff --git a/gprof/gmon.h b/gprof/gmon.h deleted file mode 100644 index c89a721972b..00000000000 --- a/gprof/gmon.h +++ /dev/null @@ -1,105 +0,0 @@ -/*- - * Copyright (c) 1991 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)gmon.h 5.2 (Berkeley) 5/6/91 - */ - -struct phdr { - char *lpc; - char *hpc; - int ncnt; -}; - - /* - * histogram counters are unsigned shorts (according to the kernel). - */ -#define HISTCOUNTER unsigned short - - /* - * fraction of text space to allocate for histogram counters - * here, 1/2 - */ -#define HISTFRACTION 2 - - /* - * Fraction of text space to allocate for from hash buckets. - * The value of HASHFRACTION is based on the minimum number of bytes - * of separation between two subroutine call points in the object code. - * Given MIN_SUBR_SEPARATION bytes of separation the value of - * HASHFRACTION is calculated as: - * - * HASHFRACTION = MIN_SUBR_SEPARATION / (2 * sizeof(short) - 1); - * - * For the VAX, the shortest two call sequence is: - * - * calls $0,(r0) - * calls $0,(r0) - * - * which is separated by only three bytes, thus HASHFRACTION is - * calculated as: - * - * HASHFRACTION = 3 / (2 * 2 - 1) = 1 - * - * Note that the division above rounds down, thus if MIN_SUBR_FRACTION - * is less than three, this algorithm will not work! - */ -#define HASHFRACTION 1 - - /* - * percent of text space to allocate for tostructs - * with a minimum. - */ -#define ARCDENSITY 2 -#define MINARCS 50 - -struct tostruct { - char *selfpc; - long count; - unsigned short link; -}; - - /* - * a raw arc, - * with pointers to the calling site and the called site - * and a count. - */ -struct rawarc { - unsigned long raw_frompc; - unsigned long raw_selfpc; - long raw_count; -}; - - /* - * general rounding functions. - */ -#define ROUNDDOWN(x,y) (((x)/(y))*(y)) -#define ROUNDUP(x,y) ((((x)+(y)-1)/(y))*(y)) diff --git a/gprof/gprof.1 b/gprof/gprof.1 deleted file mode 100644 index 286a312008a..00000000000 --- a/gprof/gprof.1 +++ /dev/null @@ -1,264 +0,0 @@ -.\" Copyright (c) 1983, 1990 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms are permitted provided -.\" that: (1) source distributions retain this entire copyright notice and -.\" comment, and (2) distributions including binaries display the following -.\" acknowledgement: ``This product includes software developed by the -.\" University of California, Berkeley and its contributors'' in the -.\" documentation or other materials provided with the distribution and in -.\" all advertising materials mentioning features or use of this software. -.\" Neither the name of the University nor the names of its contributors may -.\" be used to endorse or promote products derived from this software without -.\" specific prior written permission. -.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED -.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF -.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -.\" -.\" @(#)gprof.1 6.6 (Berkeley) 7/24/90 -.\" -.Dd July 24, 1990 -.Dt GPROF 1 -.Os BSD 4.2 -.Sh NAME -.Nm gprof -.Nd display call graph profile data -.Sh SYNOPSIS -.Nm gprof -.Op options -.Op Ar a.out Op Ar gmon.out ... -.Sh DESCRIPTION -.Nm gprof -produces an execution profile of C, Pascal, or Fortran77 programs. -The effect of called routines is incorporated in the profile of each caller. -The profile data is taken from the call graph profile file -.Pf \&( Pa gmon.out -default) which is created by programs -that are compiled with the -.Fl pg -option of -.Xr cc 1 , -.Xr pc 1 , -and -.Xr f77 1 . -The -.Fl pg -option also links in versions of the library routines -that are compiled for profiling. -.Nm Gprof -reads the given object file (the default is -.Pa a.out) -and establishes the relation between it's symbol table -and the call graph profile from -.Pa gmon.out . -If more than one profile file is specified, -the -.Nm gprof -output shows the sum of the profile information in the given profile files. -.Pp -.Nm Gprof -calculates the amount of time spent in each routine. -Next, these times are propagated along the edges of the call graph. -Cycles are discovered, and calls into a cycle are made to share the time -of the cycle. -The first listing shows the functions -sorted according to the time they represent -including the time of their call graph descendents. -Below each function entry is shown its (direct) call graph children, -and how their times are propagated to this function. -A similar display above the function shows how this function's time and the -time of its descendents is propagated to its (direct) call graph parents. -.Pp -Cycles are also shown, with an entry for the cycle as a whole and -a listing of the members of the cycle and their contributions to the -time and call counts of the cycle. -.Pp -Second, a flat profile is given, -similar to that provided by -.Xr prof 1 . -This listing gives the total execution times, the call counts, -the time in milleseconds the call spent in the routine itself, and -the time in milleseconds the call spent in the routine itself including -its descendents. -.Pp -Finally, an index of the function names is provided. -.Pp -The following options are available: -.Tw Fl -.Tp Fl a -suppresses the printing of statically declared functions. -If this option is given, all relevant information about the static function -(e.g., time samples, calls to other functions, calls from other functions) -belongs to the function loaded just before the static function in the -.Pa a.out -file. -.Tp Fl b -suppresses the printing of a description of each field in the profile. -.Tp Fl c -the static call graph of the program is discovered by a heuristic -that examines the text space of the object file. -Static-only parents or children are shown -with call counts of 0. -.Tc Fl e -.Ws -.Ar name -.Cx -suppresses the printing of the graph profile entry for routine -.Ar name -and all its descendants -(unless they have other ancestors that aren't suppressed). -More than one -.Fl e -option may be given. -Only one -.Ar name -may be given with each -.Fl e -option. -.Tc Fl E -.Ws -.Ar name -.Cx -suppresses the printing of the graph profile entry for routine -.Ar name -(and its descendants) as -.Fl e , -above, and also excludes the time spent in -.Ar name -(and its descendants) from the total and percentage time computations. -(For example, -.Fl E -.Ar mcount -.Fl E -.Ar mcleanup -is the default.) -.Tc Fl f -.Ws -.Ar name -.Cx -prints the graph profile entry of only the specified routine -.Ar name -and its descendants. -More than one -.Fl f -option may be given. -Only one -.Ar name -may be given with each -.Fl f -option. -.Tc Fl F -.Ws -.Ar name -.Cx -prints the graph profile entry of only the routine -.Ar name -and its descendants (as -.Fl f , -above) and also uses only the times of the printed routines -in total time and percentage computations. -More than one -.Fl F -option may be given. -Only one -.Ar name -may be given with each -.Fl F -option. -The -.Fl F -option -overrides -the -.Fl E -option. -.Tc Fl k -.Ws -.Ar fromname -.Ws -.Ar toname -.Cx -will delete any arcs from routine -.Ar fromname -to routine -.Ar toname . -This can be used to break undesired cycles. -More than one -.Fl k -option may be given. -Only one pair of routine names may be given with each -.Fl k -option. -.Tp Fl s -a profile file -.Pa gmon.sum -is produced that represents -the sum of the profile information in all the specified profile files. -This summary profile file may be given to later -executions of gprof (probably also with a -.Fl s ) -to accumulate profile data across several runs of an -.Pa a.out -file. -.Tp Fl z -displays routines that have zero usage (as shown by call counts -and accumulated time). -This is useful with the -.Fl c -option for discovering which routines were never called. -.Tp -.Sh FILES -.Dw gmon.sum -.Di L -.Dp Pa a.out -the namelist and text space. -.Dp Pa gmon.out -dynamic call graph and profile. -.Dp Pa gmon.sum -summarized dynamic call graph and profile. -.Dp -.Sh SEE ALSO -.Xr monitor 3 , -.Xr profil 2 , -.Xr cc 1 , -.Xr prof 1 -.br -.Em An Execution Profiler for Modular Programs , -by -S. Graham, P. Kessler, M. McKusick; -Software - Practice and Experience, -Vol. 13, pp. 671-685, 1983. -.br -.Em gprof: A Call Graph Execution Profiler , -by S. Graham, P. Kessler, M. McKusick; -Proceedings of the SIGPLAN '82 Symposium on Compiler Construction, -SIGPLAN Notices, Vol. 17, No 6, pp. 120-126, June 1982. -.Sh HISTORY -.Nm Gprof -appeared in 4.2 BSD. -.Sh BUGS -The granularity of the sampling is shown, but remains -statistical at best. -We assume that the time for each execution of a function -can be expressed by the total time for the function divided -by the number of times the function is called. -Thus the time propagated along the call graph arcs to the function's -parents is directly proportional to the number of times that -arc is traversed. -.Pp -Parents that are not themselves profiled will have the time of -their profiled children propagated to them, but they will appear -to be spontaneously invoked in the call graph listing, and will -not have their time propagated further. -Similarly, signal catchers, even though profiled, will appear -to be spontaneous (although for more obscure reasons). -Any profiled children of signal catchers should have their times -propagated properly, unless the signal catcher was invoked during -the execution of the profiling routine, in which case all is lost. -.Pp -The profiled program must call -.Xr exit 2 -or return normally for the profiling information to be saved -in the -.Pa gmon.out -file. diff --git a/gprof/gprof.c b/gprof/gprof.c deleted file mode 100644 index 94f7f98ba2e..00000000000 --- a/gprof/gprof.c +++ /dev/null @@ -1,706 +0,0 @@ -/* - * Copyright (c) 1983 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that: (1) source distributions retain this entire copyright - * notice and comment, and (2) distributions including binaries display - * the following acknowledgement: ``This product includes software - * developed by the University of California, Berkeley and its contributors'' - * in the documentation or other materials provided with the distribution - * and in all advertising materials mentioning features or use of this - * software. Neither the name of the University nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ - -#ifndef lint -char copyright[] = -"@(#) Copyright (c) 1983 Regents of the University of California.\n\ - All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)gprof.c 5.6 (Berkeley) 6/1/90"; -#endif /* not lint */ - -#include "gprof.h" - -char *whoami = "gprof"; - - /* - * things which get -E excluded by default. - */ -char *defaultEs[] = { "mcount" , "__mcleanup" , 0 }; - -main(argc, argv) - int argc; - char **argv; -{ - char **sp; - nltype **timesortnlp; - - --argc; - argv++; - debug = 0; - bflag = TRUE; - while ( *argv != 0 && **argv == '-' ) { - (*argv)++; - switch ( **argv ) { - case 'a': - aflag = TRUE; - break; - case 'b': - bflag = FALSE; - break; - case 'c': - cflag = TRUE; - break; - case 'd': - dflag = TRUE; - (*argv)++; - debug |= atoi( *argv ); - debug |= ANYDEBUG; -# ifdef DEBUG - printf("[main] debug = %d\n", debug); -# else not DEBUG - printf("%s: -d ignored\n", whoami); -# endif DEBUG - break; - case 'E': - ++argv; - addlist( Elist , *argv ); - Eflag = TRUE; - addlist( elist , *argv ); - eflag = TRUE; - break; - case 'e': - addlist( elist , *++argv ); - eflag = TRUE; - break; - case 'F': - ++argv; - addlist( Flist , *argv ); - Fflag = TRUE; - addlist( flist , *argv ); - fflag = TRUE; - break; - case 'f': - addlist( flist , *++argv ); - fflag = TRUE; - break; - case 'k': - addlist( kfromlist , *++argv ); - addlist( ktolist , *++argv ); - kflag = TRUE; - break; - case 's': - sflag = TRUE; - break; - case 'z': - zflag = TRUE; - break; - } - argv++; - } - if ( *argv != 0 ) { - a_outname = *argv; - argv++; - } else { - a_outname = A_OUTNAME; - } - if ( *argv != 0 ) { - gmonname = *argv; - argv++; - } else { - gmonname = GMONNAME; - } - /* - * turn off default functions - */ - for ( sp = &defaultEs[0] ; *sp ; sp++ ) { - Eflag = TRUE; - addlist( Elist , *sp ); - eflag = TRUE; - addlist( elist , *sp ); - } - /* - * how many ticks per second? - * if we can't tell, report time in ticks. - */ - hz = hertz(); - if (hz == 0) { - hz = 1; - fprintf(stderr, "time is in ticks, not seconds\n"); - } - /* - * get information about a.out file. - */ - getnfile(); - /* - * get information about mon.out file(s). - */ - do { - getpfile( gmonname ); - if ( *argv != 0 ) { - gmonname = *argv; - } - } while ( *argv++ != 0 ); - /* - * dump out a gmon.sum file if requested - */ - if ( sflag ) { - dumpsum( GMONSUM ); - } - /* - * assign samples to procedures - */ - asgnsamples(); - /* - * assemble the dynamic profile - */ - timesortnlp = doarcs(); - /* - * print the dynamic profile - */ - printgprof( timesortnlp ); - /* - * print the flat profile - */ - printprof(); - /* - * print the index - */ - printindex(); - done(); -} - - /* - * Set up string and symbol tables from a.out. - * and optionally the text space. - * On return symbol table is sorted by value. - */ -getnfile() -{ - bfd *abfd; - int valcmp(); - - abfd = bfd_openr (a_outname, NULL); - - if (abfd == NULL) { - perror (a_outname); - done(); - } - - if (!bfd_check_format (abfd, bfd_object)) { - fprintf (stderr, "%s: %s: bad format\n", whoami, a_outname); - done(); - } - -/* getstrtab(nfile); */ - getsymtab(abfd); - gettextspace( abfd ); - qsort(nl, nname, sizeof(nltype), valcmp); - -# ifdef DEBUG - if ( debug & AOUTDEBUG ) { - register int j; - - for (j = 0; j < nname; j++){ - printf("[getnfile] 0X%08x\t%s\n", nl[j].value, nl[j].name); - } - } -# endif DEBUG -} - -#if 0 -getstrtab(nfile) - FILE *nfile; -{ - - fseek(nfile, (long)(N_SYMOFF(xbuf) + xbuf.a_syms), 0); - if (fread(&ssiz, sizeof (ssiz), 1, nfile) == 0) { - fprintf(stderr, "%s: %s: no string table (old format?)\n" , - whoami , a_outname ); - done(); - } - strtab = (char *)calloc(ssiz, 1); - if (strtab == NULL) { - fprintf(stderr, "%s: %s: no room for %d bytes of string table", - whoami , a_outname , ssiz); - done(); - } - if (fread(strtab+sizeof(ssiz), ssiz-sizeof(ssiz), 1, nfile) != 1) { - fprintf(stderr, "%s: %s: error reading string table\n", - whoami , a_outname ); - done(); - } -} -#endif /* 0 */ - /* - * Read in symbol table - */ -getsymtab(abfd) -bfd *abfd; -{ - register long i; - int askfor; - int nosyms; - asymbol **syms; - i = get_symtab_upper_bound (abfd); /* This will probably give us more - * than we need, but that's ok. - */ - syms = malloc (i); - nosyms = bfd_canonicalize_symtab (abfd, syms); - - nname = 0; - for (i = 0; i < nosyms; i++) { - if (!funcsymbol (syms[i])) - continue; - nname++; - } - - if (nname == 0) { - fprintf(stderr, "%s: %s: no symbols\n", whoami , a_outname ); - done(); - } - askfor = nname + 1; - nl = (nltype *) calloc( askfor , sizeof(nltype) ); - if (nl == 0) { - fprintf(stderr, "%s: No room for %d bytes of symbol table\n", - whoami, askfor * sizeof(nltype) ); - done(); - } - - /* pass2 - read symbols */ - npe = nl; - nname = 0; - for (i = 0; i < nosyms; i++) { - if (!funcsymbol (syms[i])) { -# ifdef DEBUG - if ( debug & AOUTDEBUG ) { - printf( "[getsymtab] rejecting: 0x%x %s\n" , - syms[i]->value, syms[i]->name); - } -# endif DEBUG - continue; - } - npe->value = syms[i]->value + syms[i]->section->vma; - npe->name = syms[i]->name; -# ifdef DEBUG - if ( debug & AOUTDEBUG ) { - printf( "[getsymtab] %d %s 0x%08x\n" , - nname , npe -> name , npe -> value ); - } -# endif DEBUG - npe++; - nname++; - } - npe->value = -1; -} - -/* - * read in the text space of an a.out file - */ -gettextspace( abfd ) - bfd *abfd; -{ - asection *texsec; - - if ( cflag == 0 ) { - return; - } - - texsec = bfd_get_section_by_name (abfd, ".text"); - if (texsec == NULL) { - return; - } - - textspace = (u_char *) malloc( texsec->size ); - - if ( textspace == 0 ) { - fprintf( stderr , "%s: ran out room for %d bytes of text space: " , - whoami , texsec->size); - fprintf( stderr , "can't do -c\n" ); - return; - } - bfd_get_section_contents (abfd, texsec, textspace, texsec->filepos, - texsec->size); -} -/* - * information from a gmon.out file is in two parts: - * an array of sampling hits within pc ranges, - * and the arcs. - */ -getpfile(filename) - char *filename; -{ - FILE *pfile; - FILE *openpfile(); - struct rawarc arc; - - pfile = openpfile(filename); - readsamples(pfile); - /* - * the rest of the file consists of - * a bunch of tuples. - */ - while ( fread( &arc , sizeof arc , 1 , pfile ) == 1 ) { -# ifdef DEBUG - if ( debug & SAMPLEDEBUG ) { - printf( "[getpfile] frompc 0x%x selfpc 0x%x count %d\n" , - arc.raw_frompc , arc.raw_selfpc , arc.raw_count ); - } -# endif DEBUG - /* - * add this arc - */ - tally( &arc ); - } - fclose(pfile); -} - -FILE * -openpfile(filename) - char *filename; -{ - struct hdr tmp; - FILE *pfile; - - if((pfile = fopen(filename, "r")) == NULL) { - perror(filename); - done(); - } - fread(&tmp, sizeof(struct hdr), 1, pfile); - if ( s_highpc != 0 && ( tmp.lowpc != h.lowpc || - tmp.highpc != h.highpc || tmp.ncnt != h.ncnt ) ) { - fprintf(stderr, "%s: incompatible with first gmon file\n", filename); - done(); - } - h = tmp; - s_lowpc = (unsigned long) h.lowpc; - s_highpc = (unsigned long) h.highpc; - lowpc = (unsigned long)h.lowpc / sizeof(UNIT); - highpc = (unsigned long)h.highpc / sizeof(UNIT); - sampbytes = h.ncnt - sizeof(struct hdr); - nsamples = sampbytes / sizeof (UNIT); -# ifdef DEBUG - if ( debug & SAMPLEDEBUG ) { - printf( "[openpfile] hdr.lowpc 0x%x hdr.highpc 0x%x hdr.ncnt %d\n", - h.lowpc , h.highpc , h.ncnt ); - printf( "[openpfile] s_lowpc 0x%x s_highpc 0x%x\n" , - s_lowpc , s_highpc ); - printf( "[openpfile] lowpc 0x%x highpc 0x%x\n" , - lowpc , highpc ); - printf( "[openpfile] sampbytes %d nsamples %d\n" , - sampbytes , nsamples ); - } -# endif DEBUG - return(pfile); -} - -tally( rawp ) - struct rawarc *rawp; -{ - nltype *parentp; - nltype *childp; - - parentp = nllookup( rawp -> raw_frompc ); - childp = nllookup( rawp -> raw_selfpc ); - if ( kflag - && onlist( kfromlist , parentp -> name ) - && onlist( ktolist , childp -> name ) ) { - return; - } - childp -> ncall += rawp -> raw_count; -# ifdef DEBUG - if ( debug & TALLYDEBUG ) { - printf( "[tally] arc from %s to %s traversed %d times\n" , - parentp -> name , childp -> name , rawp -> raw_count ); - } -# endif DEBUG - addarc( parentp , childp , rawp -> raw_count ); -} - -/* - * dump out the gmon.sum file - */ -dumpsum( sumfile ) - char *sumfile; -{ - register nltype *nlp; - register arctype *arcp; - struct rawarc arc; - FILE *sfile; - - if ( ( sfile = fopen ( sumfile , "w" ) ) == NULL ) { - perror( sumfile ); - done(); - } - /* - * dump the header; use the last header read in - */ - if ( fwrite( &h , sizeof h , 1 , sfile ) != 1 ) { - perror( sumfile ); - done(); - } - /* - * dump the samples - */ - if (fwrite(samples, sizeof (UNIT), nsamples, sfile) != nsamples) { - perror( sumfile ); - done(); - } - /* - * dump the normalized raw arc information - */ - for ( nlp = nl ; nlp < npe ; nlp++ ) { - for ( arcp = nlp -> children ; arcp ; arcp = arcp -> arc_childlist ) { - arc.raw_frompc = arcp -> arc_parentp -> value; - arc.raw_selfpc = arcp -> arc_childp -> value; - arc.raw_count = arcp -> arc_count; - if ( fwrite ( &arc , sizeof arc , 1 , sfile ) != 1 ) { - perror( sumfile ); - done(); - } -# ifdef DEBUG - if ( debug & SAMPLEDEBUG ) { - printf( "[dumpsum] frompc 0x%x selfpc 0x%x count %d\n" , - arc.raw_frompc , arc.raw_selfpc , arc.raw_count ); - } -# endif DEBUG - } - } - fclose( sfile ); -} - -valcmp(p1, p2) - nltype *p1, *p2; -{ - if ( p1 -> value < p2 -> value ) { - return LESSTHAN; - } - if ( p1 -> value > p2 -> value ) { - return GREATERTHAN; - } - return EQUALTO; -} - -readsamples(pfile) - FILE *pfile; -{ - register i; - UNIT sample; - - if (samples == 0) { - samples = (UNIT *) calloc(sampbytes, sizeof (UNIT)); - if (samples == 0) { - fprintf( stderr , "%s: No room for %d sample pc's\n", - whoami , sampbytes / sizeof (UNIT)); - done(); - } - } - for (i = 0; i < nsamples; i++) { - fread(&sample, sizeof (UNIT), 1, pfile); - if (feof(pfile)) - break; - samples[i] += sample; - } - if (i != nsamples) { - fprintf(stderr, - "%s: unexpected EOF after reading %d/%d samples\n", - whoami , --i , nsamples ); - done(); - } -} - -/* - * Assign samples to the procedures to which they belong. - * - * There are three cases as to where pcl and pch can be - * with respect to the routine entry addresses svalue0 and svalue1 - * as shown in the following diagram. overlap computes the - * distance between the arrows, the fraction of the sample - * that is to be credited to the routine which starts at svalue0. - * - * svalue0 svalue1 - * | | - * v v - * - * +-----------------------------------------------+ - * | | - * | ->| |<- ->| |<- ->| |<- | - * | | | | | | - * +---------+ +---------+ +---------+ - * - * ^ ^ ^ ^ ^ ^ - * | | | | | | - * pcl pch pcl pch pcl pch - * - * For the vax we assert that samples will never fall in the first - * two bytes of any routine, since that is the entry mask, - * thus we give call alignentries() to adjust the entry points if - * the entry mask falls in one bucket but the code for the routine - * doesn't start until the next bucket. In conjunction with the - * alignment of routine addresses, this should allow us to have - * only one sample for every four bytes of text space and never - * have any overlap (the two end cases, above). - */ -asgnsamples() -{ - register int j; - UNIT ccnt; - double time; - unsigned long pcl, pch; - register int i; - unsigned long overlap; - unsigned long svalue0, svalue1; - - /* read samples and assign to namelist symbols */ - scale = highpc - lowpc; - scale /= nsamples; - alignentries(); - for (i = 0, j = 1; i < nsamples; i++) { - ccnt = samples[i]; - if (ccnt == 0) - continue; - pcl = lowpc + scale * i; - pch = lowpc + scale * (i + 1); - time = ccnt; -# ifdef DEBUG - if ( debug & SAMPLEDEBUG ) { - printf( "[asgnsamples] pcl 0x%x pch 0x%x ccnt %d\n" , - pcl , pch , ccnt ); - } -# endif DEBUG - totime += time; - for (j = j - 1; j < nname; j++) { - svalue0 = nl[j].svalue; - svalue1 = nl[j+1].svalue; - /* - * if high end of tick is below entry address, - * go for next tick. - */ - if (pch < svalue0) - break; - /* - * if low end of tick into next routine, - * go for next routine. - */ - if (pcl >= svalue1) - continue; - overlap = min(pch, svalue1) - max(pcl, svalue0); - if (overlap > 0) { -# ifdef DEBUG - if (debug & SAMPLEDEBUG) { - printf("[asgnsamples] (0x%x->0x%x-0x%x) %s gets %f ticks %d overlap\n", - nl[j].value/sizeof(UNIT), svalue0, svalue1, - nl[j].name, - overlap * time / scale, overlap); - } -# endif DEBUG - nl[j].time += overlap * time / scale; - } - } - } -# ifdef DEBUG - if (debug & SAMPLEDEBUG) { - printf("[asgnsamples] totime %f\n", totime); - } -# endif DEBUG -} - - -unsigned long -min(a, b) - unsigned long a,b; -{ - if (ab) - return(a); - return(b); -} - - /* - * calculate scaled entry point addresses (to save time in asgnsamples), - * and possibly push the scaled entry points over the entry mask, - * if it turns out that the entry point is in one bucket and the code - * for a routine is in the next bucket. - */ -alignentries() -{ - register struct nl *nlp; - unsigned long bucket_of_entry; - unsigned long bucket_of_code; - - for (nlp = nl; nlp < npe; nlp++) { - nlp -> svalue = nlp -> value / sizeof(UNIT); - bucket_of_entry = (nlp->svalue - lowpc) / scale; - bucket_of_code = (nlp->svalue + UNITS_TO_CODE - lowpc) / scale; - if (bucket_of_entry < bucket_of_code) { -# ifdef DEBUG - if (debug & SAMPLEDEBUG) { - printf("[alignentries] pushing svalue 0x%x to 0x%x\n", - nlp->svalue, nlp->svalue + UNITS_TO_CODE); - } -# endif DEBUG - nlp->svalue += UNITS_TO_CODE; - } - } -} - -bool -funcsymbol( symp ) - asymbol *symp; -{ - extern char *strtab; /* string table from a.out */ - extern int aflag; /* if static functions aren't desired */ - char *name; - - /* - * must be a text symbol, - * and static text symbols don't qualify if aflag set. - */ - - if (!symp->section) - return FALSE; - - if (!aflag && (symp->flags&BSF_LOCAL)) { -#ifdef DEBUG - fprintf (stderr, "%s(%d): %s: not a function\n", __FILE__, __LINE__, symp->name); -#endif - return FALSE; - } - - /* - * can't have any `funny' characters in name, - * where `funny' includes `.', .o file names - * and `$', pascal labels. - */ - if (!symp->name) - return FALSE; - - for (name = symp->name; *name; name++) { - if ( *name == '.' || *name == '$' ) { - return FALSE; - } - } - return TRUE; -} - -done() -{ - - exit(0); -} diff --git a/gprof/gprof.callg b/gprof/gprof.callg deleted file mode 100644 index 533c96ca439..00000000000 --- a/gprof/gprof.callg +++ /dev/null @@ -1,108 +0,0 @@ - - - -call graph profile: - The sum of self and descendents is the major sort - for this listing. - - function entries: - -index the index of the function in the call graph - listing, as an aid to locating it (see below). - -%time the percentage of the total time of the program - accounted for by this function and its - descendents. - -self the number of seconds spent in this function - itself. - -descendents - the number of seconds spent in the descendents of - this function on behalf of this function. - -called the number of times this function is called (other - than recursive calls). - -self the number of times this function calls itself - recursively. - -name the name of the function, with an indication of - its membership in a cycle, if any. - -index the index of the function in the call graph - listing, as an aid to locating it. - - - - parent listings: - -self* the number of seconds of this function's self time - which is due to calls from this parent. - -descendents* - the number of seconds of this function's - descendent time which is due to calls from this - parent. - -called** the number of times this function is called by - this parent. This is the numerator of the - fraction which divides up the function's time to - its parents. - -total* the number of times this function was called by - all of its parents. This is the denominator of - the propagation fraction. - -parents the name of this parent, with an indication of the - parent's membership in a cycle, if any. - -index the index of this parent in the call graph - listing, as an aid in locating it. - - - - children listings: - -self* the number of seconds of this child's self time - which is due to being called by this function. - -descendent* - the number of seconds of this child's descendent's - time which is due to being called by this - function. - -called** the number of times this child is called by this - function. This is the numerator of the - propagation fraction for this child. - -total* the number of times this child is called by all - functions. This is the denominator of the - propagation fraction. - -children the name of this child, and an indication of its - membership in a cycle, if any. - -index the index of this child in the call graph listing, - as an aid to locating it. - - - - * these fields are omitted for parents (or - children) in the same cycle as the function. If - the function (or child) is a member of a cycle, - the propagated times and propagation denominator - represent the self time and descendent time of the - cycle as a whole. - - ** static-only parents and children are indicated - by a call count of 0. - - - - cycle listings: - the cycle as a whole is listed with the same - fields as a function entry. Below it are listed - the members of the cycle, and their contributions - to the time and call counts of the cycle. - diff --git a/gprof/gprof.flat b/gprof/gprof.flat deleted file mode 100644 index 60999a35f2f..00000000000 --- a/gprof/gprof.flat +++ /dev/null @@ -1,32 +0,0 @@ - - - -flat profile: - - % the percentage of the total running time of the -time program used by this function. - -cumulative a running sum of the number of seconds accounted - seconds for by this function and those listed above it. - - self the number of seconds accounted for by this -seconds function alone. This is the major sort for this - listing. - -calls the number of times this function was invoked, if - this function is profiled, else blank. - - self the average number of milliseconds spent in this -ms/call function per call, if this function is profiled, - else blank. - - total the average number of milliseconds spent in this -ms/call function and its descendents per call, if this - function is profiled, else blank. - -name the name of the function. This is the minor sort - for this listing. The index shows the location of - the function in the gprof listing. If the index is - in parenthesis it shows where it would appear in - the gprof listing if it were to be printed. - diff --git a/gprof/gprof.h b/gprof/gprof.h deleted file mode 100644 index 35ad5af3ee6..00000000000 --- a/gprof/gprof.h +++ /dev/null @@ -1,284 +0,0 @@ -/* - * Copyright (c) 1983 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that: (1) source distributions retain this entire copyright - * notice and comment, and (2) distributions including binaries display - * the following acknowledgement: ``This product includes software - * developed by the University of California, Berkeley and its contributors'' - * in the documentation or other materials provided with the distribution - * and in all advertising materials mentioning features or use of this - * software. Neither the name of the University nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * @(#)gprof.h 5.9 (Berkeley) 6/1/90 - */ - -#include -#include -#include -#include -#include "bfd.h" -#include "gmon.h" - -#ifdef MACHINE_H -# include MACHINE_H -#else -# if vax -# include "vax.h" -# endif -# if sun -# include "sun.h" -# endif -# if tahoe -# include "tahoe.h" -# endif -#endif - - - /* - * who am i, for error messages. - */ -char *whoami; - - /* - * booleans - */ -typedef int bool; -#define FALSE 0 -#define TRUE 1 - - /* - * ticks per second - */ -long hz; - -typedef u_short UNIT; /* unit of profiling */ -char *a_outname; -#define A_OUTNAME "a.out" - -char *gmonname; -#define GMONNAME "gmon.out" -#define GMONSUM "gmon.sum" - - /* - * a constructed arc, - * with pointers to the namelist entry of the parent and the child, - * a count of how many times this arc was traversed, - * and pointers to the next parent of this child and - * the next child of this parent. - */ -struct arcstruct { - struct nl *arc_parentp; /* pointer to parent's nl entry */ - struct nl *arc_childp; /* pointer to child's nl entry */ - long arc_count; /* how calls from parent to child */ - double arc_time; /* time inherited along arc */ - double arc_childtime; /* childtime inherited along arc */ - struct arcstruct *arc_parentlist; /* parents-of-this-child list */ - struct arcstruct *arc_childlist; /* children-of-this-parent list */ -}; -typedef struct arcstruct arctype; - - /* - * The symbol table; - * for each external in the specified file we gather - * its address, the number of calls and compute its share of cpu time. - */ -struct nl { - char *name; /* the name */ - unsigned long value; /* the pc entry point */ - unsigned long svalue; /* entry point aligned to histograms */ - double time; /* ticks in this routine */ - double childtime; /* cumulative ticks in children */ - long ncall; /* how many times called */ - long selfcalls; /* how many calls to self */ - double propfraction; /* what % of time propagates */ - double propself; /* how much self time propagates */ - double propchild; /* how much child time propagates */ - bool printflag; /* should this be printed? */ - int index; /* index in the graph list */ - int toporder; /* graph call chain top-sort order */ - int cycleno; /* internal number of cycle on */ - struct nl *cyclehead; /* pointer to head of cycle */ - struct nl *cnext; /* pointer to next member of cycle */ - arctype *parents; /* list of caller arcs */ - arctype *children; /* list of callee arcs */ -}; -typedef struct nl nltype; - -nltype *nl; /* the whole namelist */ -nltype *npe; /* the virtual end of the namelist */ -int nname; /* the number of function names */ - - /* - * flag which marks a nl entry as topologically ``busy'' - * flag which marks a nl entry as topologically ``not_numbered'' - */ -#define DFN_BUSY -1 -#define DFN_NAN 0 - - /* - * namelist entries for cycle headers. - * the number of discovered cycles. - */ -nltype *cyclenl; /* cycle header namelist */ -int ncycle; /* number of cycles discovered */ - - /* - * The header on the gmon.out file. - * gmon.out consists of one of these headers, - * and then an array of ncnt samples - * representing the discretized program counter values. - * this should be a struct phdr, but since everything is done - * as UNITs, this is in UNITs too. - */ -struct hdr { - UNIT *lowpc; - UNIT *highpc; - int ncnt; -}; - -struct hdr h; - -int debug; - - /* - * Each discretized pc sample has - * a count of the number of samples in its range - */ -UNIT *samples; - -unsigned long s_lowpc; /* lowpc from the profile file */ -unsigned long s_highpc; /* highpc from the profile file */ -unsigned lowpc, highpc; /* range profiled, in UNIT's */ -unsigned sampbytes; /* number of bytes of samples */ -int nsamples; /* number of samples */ -double actime; /* accumulated time thus far for putprofline */ -double totime; /* total time for all routines */ -double printtime; /* total of time being printed */ -double scale; /* scale factor converting samples to pc - values: each sample covers scale bytes */ -char *strtab; /* string table in core */ -off_t ssiz; /* size of the string table */ -unsigned char *textspace; /* text space of a.out in core */ - - /* - * option flags, from a to z. - */ -bool aflag; /* suppress static functions */ -bool bflag; /* blurbs, too */ -bool cflag; /* discovered call graph, too */ -bool dflag; /* debugging options */ -bool eflag; /* specific functions excluded */ -bool Eflag; /* functions excluded with time */ -bool fflag; /* specific functions requested */ -bool Fflag; /* functions requested with time */ -bool kflag; /* arcs to be deleted */ -bool sflag; /* sum multiple gmon.out files */ -bool zflag; /* zero time/called functions, too */ - - /* - * structure for various string lists - */ -struct stringlist { - struct stringlist *next; - char *string; -}; -struct stringlist *elist; -struct stringlist *Elist; -struct stringlist *flist; -struct stringlist *Flist; -struct stringlist *kfromlist; -struct stringlist *ktolist; - - /* - * function declarations - */ -/* - addarc(); -*/ -int arccmp(); -arctype *arclookup(); -/* - asgnsamples(); - printblurb(); - cyclelink(); - dfn(); -*/ -bool dfn_busy(); -/* - dfn_findcycle(); -*/ -bool dfn_numbered(); -/* - dfn_post_visit(); - dfn_pre_visit(); - dfn_self_cycle(); -*/ -nltype **doarcs(); -/* - done(); - findcalls(); - flatprofheader(); - flatprofline(); -*/ -bool funcsymbol(); -/* - getnfile(); - getpfile(); - getstrtab(); - getsymtab(); - gettextspace(); - gprofheader(); - gprofline(); - main(); -*/ -unsigned long max(); -int membercmp(); -unsigned long min(); -nltype *nllookup(); -FILE *openpfile(); -/* - printchildren(); - printcycle(); - printgprof(); - printmembers(); - printname(); - printparents(); - printprof(); - readsamples(); -*/ -unsigned long reladdr(); -/* - sortchildren(); - sortmembers(); - sortparents(); - tally(); - timecmp(); - topcmp(); -*/ -int totalcmp(); -/* - valcmp(); -*/ - -#define LESSTHAN -1 -#define EQUALTO 0 -#define GREATERTHAN 1 - -#define DFNDEBUG 1 -#define CYCLEDEBUG 2 -#define ARCDEBUG 4 -#define TALLYDEBUG 8 -#define TIMEDEBUG 16 -#define SAMPLEDEBUG 32 -#define AOUTDEBUG 64 -#define CALLDEBUG 128 -#define LOOKUPDEBUG 256 -#define PROPDEBUG 512 -#define ANYDEBUG 1024 diff --git a/gprof/hertz.c b/gprof/hertz.c deleted file mode 100644 index 1c2927f673e..00000000000 --- a/gprof/hertz.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 1983 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that: (1) source distributions retain this entire copyright - * notice and comment, and (2) distributions including binaries display - * the following acknowledgement: ``This product includes software - * developed by the University of California, Berkeley and its contributors'' - * in the documentation or other materials provided with the distribution - * and in all advertising materials mentioning features or use of this - * software. Neither the name of the University nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ - -#ifndef lint -static char sccsid[] = "@(#)hertz.c 5.4 (Berkeley) 6/1/90"; -#endif /* not lint */ - -#include - - /* - * discover the tick frequency of the machine - * if something goes wrong, we return 0, an impossible hertz. - */ -#define HZ_WRONG 0 - -hertz() -{ - struct itimerval tim; - - tim.it_interval.tv_sec = 0; - tim.it_interval.tv_usec = 1; - tim.it_value.tv_sec = 0; - tim.it_value.tv_usec = 0; - setitimer(ITIMER_REAL, &tim, 0); - setitimer(ITIMER_REAL, 0, &tim); - if (tim.it_interval.tv_usec < 2) - return(HZ_WRONG); - return (1000000 / tim.it_interval.tv_usec); -} diff --git a/gprof/i386.c b/gprof/i386.c deleted file mode 100644 index cdced1c9b8b..00000000000 --- a/gprof/i386.c +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (c) 1983 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that: (1) source distributions retain this entire copyright - * notice and comment, and (2) distributions including binaries display - * the following acknowledgement: ``This product includes software - * developed by the University of California, Berkeley and its contributors'' - * in the documentation or other materials provided with the distribution - * and in all advertising materials mentioning features or use of this - * software. Neither the name of the University nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ - -#ifndef lint -static char sccsid[] = "@(#)tahoe.c 1.5 (Berkeley) 6/1/90"; -#endif /* not lint */ - -#include "gprof.h" - - /* - * a namelist entry to be the child of indirect callf - */ -nltype indirectchild = { - "(*)" , /* the name */ - (unsigned long) 0 , /* the pc entry point */ - (unsigned long) 0 , /* entry point aligned to histogram */ - (double) 0.0 , /* ticks in this routine */ - (double) 0.0 , /* cumulative ticks in children */ - (long) 0 , /* how many times called */ - (long) 0 , /* how many calls to self */ - (double) 1.0 , /* propagation fraction */ - (double) 0.0 , /* self propagation time */ - (double) 0.0 , /* child propagation time */ - (bool) 0 , /* print flag */ - (int) 0 , /* index in the graph list */ - (int) 0 , /* graph call chain top-sort order */ - (int) 0 , /* internal number of cycle on */ - (struct nl *) &indirectchild , /* pointer to head of cycle */ - (struct nl *) 0 , /* pointer to next member of cycle */ - (arctype *) 0 , /* list of caller arcs */ - (arctype *) 0 /* list of callee arcs */ - }; - -int -iscall (unsigned char *ip) { - if (*ip == 0xeb || *ip = 0x9a) - return 1; - return 0; -} - -findcall( parentp , p_lowpc , p_highpc ) - nltype *parentp; - unsigned long p_lowpc; - unsigned long p_highpc; -{ - unsigned char *instructp; - long length; - nltype *childp; - unsigned long destpc; - - if ( textspace == 0 ) { - return; - } - if ( p_lowpc < s_lowpc ) { - p_lowpc = s_lowpc; - } - if ( p_highpc > s_highpc ) { - p_highpc = s_highpc; - } -# ifdef DEBUG - if ( debug & CALLDEBUG ) { - printf( "[findcall] %s: 0x%x to 0x%x\n" , - parentp -> name , p_lowpc , p_highpc ); - } -# endif DEBUG - for ( instructp = textspace + p_lowpc ; - instructp < textspace + p_highpc ; - instructp += length ) { - length = 1; - if ( iscall (instructp) ) { -# ifdef DEBUG - if ( debug & CALLDEBUG ) { - printf( "[findcall]\t0x%x:callf" , instructp - textspace ); - } -# endif DEBUG - length = 4; - /* - * regular pc relative addressing - * check that this is the address of - * a function. - */ - destpc = ( (unsigned long)instructp + 5 - - (unsigned long) textspace; - if ( destpc >= s_lowpc && destpc <= s_highpc ) { - childp = nllookup( destpc ); -# ifdef DEBUG - if ( debug & CALLDEBUG ) { - printf( "[findcall]\tdestpc 0x%x" , destpc ); - printf( " childp->name %s" , childp -> name ); - printf( " childp->value 0x%x\n" , - childp -> value ); - } -# endif DEBUG - if ( childp -> value == destpc ) { - /* - * a hit - */ - addarc( parentp , childp , (long) 0 ); - length += 4; /* constant lengths */ - continue; - } - goto botched; - } - /* - * else: - * it looked like a callf, - * but it wasn't to anywhere. - */ - botched: - /* - * something funny going on. - */ -# ifdef DEBUG - if ( debug & CALLDEBUG ) { - printf( "[findcall]\tbut it's a botch\n" ); - } -# endif DEBUG - length = 1; - continue; - } - } - } diff --git a/gprof/i386.h b/gprof/i386.h deleted file mode 100644 index f248f6b5cf3..00000000000 --- a/gprof/i386.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 1983 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that: (1) source distributions retain this entire copyright - * notice and comment, and (2) distributions including binaries display - * the following acknowledgement: ``This product includes software - * developed by the University of California, Berkeley and its contributors'' - * in the documentation or other materials provided with the distribution - * and in all advertising materials mentioning features or use of this - * software. Neither the name of the University nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * @(#)tahoe.h 1.4 (Berkeley) 6/1/90 - */ - -/* - * Right now, this does very little - */ - - /* - * opcode of the `callf' instruction - */ - /* - * offset (in bytes) of the code from the entry address of a routine. - * (see asgnsamples for use and explanation.) - */ -#define OFFSET_OF_CODE 0 -#define UNITS_TO_CODE (OFFSET_OF_CODE / sizeof(UNIT)) - diff --git a/gprof/lookup.c b/gprof/lookup.c deleted file mode 100644 index 405f3205027..00000000000 --- a/gprof/lookup.c +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 1983 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that: (1) source distributions retain this entire copyright - * notice and comment, and (2) distributions including binaries display - * the following acknowledgement: ``This product includes software - * developed by the University of California, Berkeley and its contributors'' - * in the documentation or other materials provided with the distribution - * and in all advertising materials mentioning features or use of this - * software. Neither the name of the University nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ - -#ifndef lint -static char sccsid[] = "@(#)lookup.c 5.4 (Berkeley) 6/1/90"; -#endif /* not lint */ - -#include "gprof.h" - - /* - * look up an address in a sorted-by-address namelist - * this deals with misses by mapping them to the next lower - * entry point. - */ -nltype * -nllookup( address ) - unsigned long address; -{ - register long low; - register long middle; - register long high; -# ifdef DEBUG - register int probes; - - probes = 0; -# endif DEBUG - for ( low = 0 , high = nname - 1 ; low != high ; ) { -# ifdef DEBUG - probes += 1; -# endif DEBUG - middle = ( high + low ) >> 1; - if ( nl[ middle ].value <= address && nl[ middle+1 ].value > address ) { -# ifdef DEBUG - if ( debug & LOOKUPDEBUG ) { - printf( "[nllookup] %d (%d) probes\n" , probes , nname-1 ); - } -# endif DEBUG - return &nl[ middle ]; - } - if ( nl[ middle ].value > address ) { - high = middle; - } else { - low = middle + 1; - } - } - fprintf( stderr , "[nllookup] binary search fails???\n" ); - return 0; -} - -arctype * -arclookup( parentp , childp ) - nltype *parentp; - nltype *childp; -{ - arctype *arcp; - - if ( parentp == 0 || childp == 0 ) { - fprintf( "[arclookup] parentp == 0 || childp == 0\n" ); - return 0; - } -# ifdef DEBUG - if ( debug & LOOKUPDEBUG ) { - printf( "[arclookup] parent %s child %s\n" , - parentp -> name , childp -> name ); - } -# endif DEBUG - for ( arcp = parentp -> children ; arcp ; arcp = arcp -> arc_childlist ) { -# ifdef DEBUG - if ( debug & LOOKUPDEBUG ) { - printf( "[arclookup]\t arc_parent %s arc_child %s\n" , - arcp -> arc_parentp -> name , - arcp -> arc_childp -> name ); - } -# endif DEBUG - if ( arcp -> arc_childp == childp ) { - return arcp; - } - } - return 0; -} diff --git a/gprof/pathnames.h b/gprof/pathnames.h deleted file mode 100755 index 729325cbe82..00000000000 --- a/gprof/pathnames.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 1989 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that: (1) source distributions retain this entire copyright - * notice and comment, and (2) distributions including binaries display - * the following acknowledgement: ``This product includes software - * developed by the University of California, Berkeley and its contributors'' - * in the documentation or other materials provided with the distribution - * and in all advertising materials mentioning features or use of this - * software. Neither the name of the University nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * @(#)pathnames.h 5.2 (Berkeley) 6/1/90 - */ - -#define _PATH_FLAT_BLURB "/usr/share/misc/gprof.flat" -#define _PATH_CALLG_BLURB "/usr/share/misc/gprof.callg" - diff --git a/gprof/printgprof.c b/gprof/printgprof.c deleted file mode 100644 index ce788522bd9..00000000000 --- a/gprof/printgprof.c +++ /dev/null @@ -1,704 +0,0 @@ -/* - * Copyright (c) 1983 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that: (1) source distributions retain this entire copyright - * notice and comment, and (2) distributions including binaries display - * the following acknowledgement: ``This product includes software - * developed by the University of California, Berkeley and its contributors'' - * in the documentation or other materials provided with the distribution - * and in all advertising materials mentioning features or use of this - * software. Neither the name of the University nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ - -#ifndef lint -static char sccsid[] = "@(#)printgprof.c 5.7 (Berkeley) 6/1/90"; -#endif /* not lint */ - -#include "gprof.h" -#include "pathnames.h" - -printprof() -{ - register nltype *np; - nltype **sortednlp; - int index, timecmp(); - - actime = 0.0; - printf( "\f\n" ); - flatprofheader(); - /* - * Sort the symbol table in by time - */ - sortednlp = (nltype **) calloc( nname , sizeof(nltype *) ); - if ( sortednlp == (nltype **) 0 ) { - fprintf( stderr , "[printprof] ran out of memory for time sorting\n" ); - } - for ( index = 0 ; index < nname ; index += 1 ) { - sortednlp[ index ] = &nl[ index ]; - } - qsort( sortednlp , nname , sizeof(nltype *) , timecmp ); - for ( index = 0 ; index < nname ; index += 1 ) { - np = sortednlp[ index ]; - flatprofline( np ); - } - actime = 0.0; - cfree( sortednlp ); -} - -timecmp( npp1 , npp2 ) - nltype **npp1, **npp2; -{ - double timediff; - long calldiff; - - timediff = (*npp2) -> time - (*npp1) -> time; - if ( timediff > 0.0 ) - return 1 ; - if ( timediff < 0.0 ) - return -1; - calldiff = (*npp2) -> ncall - (*npp1) -> ncall; - if ( calldiff > 0 ) - return 1; - if ( calldiff < 0 ) - return -1; - return( strcmp( (*npp1) -> name , (*npp2) -> name ) ); -} - - /* - * header for flatprofline - */ -flatprofheader() -{ - - if ( bflag ) { - printblurb( _PATH_FLAT_BLURB ); - } - printf( "\ngranularity: each sample hit covers %d byte(s)" , - (long) scale * sizeof(UNIT) ); - if ( totime > 0.0 ) { - printf( " for %.2f%% of %.2f seconds\n\n" , - 100.0/totime , totime / hz ); - } else { - printf( " no time accumulated\n\n" ); - /* - * this doesn't hurt sinc eall the numerators will be zero. - */ - totime = 1.0; - } - printf( "%5.5s %10.10s %8.8s %8.8s %8.8s %8.8s %-8.8s\n" , - "% " , "cumulative" , "self " , "" , "self " , "total " , "" ); - printf( "%5.5s %10.10s %8.8s %8.8s %8.8s %8.8s %-8.8s\n" , - "time" , "seconds " , "seconds" , "calls" , - "ms/call" , "ms/call" , "name" ); -} - -flatprofline( np ) - register nltype *np; -{ - - if ( zflag == 0 && np -> ncall == 0 && np -> time == 0 ) { - return; - } - actime += np -> time; - printf( "%5.1f %10.2f %8.2f" , - 100 * np -> time / totime , actime / hz , np -> time / hz ); - if ( np -> ncall != 0 ) { - printf( " %8d %8.2f %8.2f " , np -> ncall , - 1000 * np -> time / hz / np -> ncall , - 1000 * ( np -> time + np -> childtime ) / hz / np -> ncall ); - } else { - printf( " %8.8s %8.8s %8.8s " , "" , "" , "" ); - } - printname( np ); - printf( "\n" ); -} - -gprofheader() -{ - - if ( bflag ) { - printblurb( _PATH_CALLG_BLURB ); - } - printf( "\ngranularity: each sample hit covers %d byte(s)" , - (long) scale * sizeof(UNIT) ); - if ( printtime > 0.0 ) { - printf( " for %.2f%% of %.2f seconds\n\n" , - 100.0/printtime , printtime / hz ); - } else { - printf( " no time propagated\n\n" ); - /* - * this doesn't hurt, since all the numerators will be 0.0 - */ - printtime = 1.0; - } - printf( "%6.6s %5.5s %7.7s %11.11s %7.7s/%-7.7s %-8.8s\n" , - "" , "" , "" , "" , "called" , "total" , "parents"); - printf( "%-6.6s %5.5s %7.7s %11.11s %7.7s+%-7.7s %-8.8s\t%5.5s\n" , - "index" , "%time" , "self" , "descendents" , - "called" , "self" , "name" , "index" ); - printf( "%6.6s %5.5s %7.7s %11.11s %7.7s/%-7.7s %-8.8s\n" , - "" , "" , "" , "" , "called" , "total" , "children"); - printf( "\n" ); -} - -gprofline( np ) - register nltype *np; -{ - char kirkbuffer[ BUFSIZ ]; - - sprintf( kirkbuffer , "[%d]" , np -> index ); - printf( "%-6.6s %5.1f %7.2f %11.2f" , - kirkbuffer , - 100 * ( np -> propself + np -> propchild ) / printtime , - np -> propself / hz , - np -> propchild / hz ); - if ( ( np -> ncall + np -> selfcalls ) != 0 ) { - printf( " %7d" , np -> ncall ); - if ( np -> selfcalls != 0 ) { - printf( "+%-7d " , np -> selfcalls ); - } else { - printf( " %7.7s " , "" ); - } - } else { - printf( " %7.7s %7.7s " , "" , "" ); - } - printname( np ); - printf( "\n" ); -} - -printgprof(timesortnlp) - nltype **timesortnlp; -{ - int index; - nltype *parentp; - - /* - * Print out the structured profiling list - */ - gprofheader(); - for ( index = 0 ; index < nname + ncycle ; index ++ ) { - parentp = timesortnlp[ index ]; - if ( zflag == 0 && - parentp -> ncall == 0 && - parentp -> selfcalls == 0 && - parentp -> propself == 0 && - parentp -> propchild == 0 ) { - continue; - } - if ( ! parentp -> printflag ) { - continue; - } - if ( parentp -> name == 0 && parentp -> cycleno != 0 ) { - /* - * cycle header - */ - printcycle( parentp ); - printmembers( parentp ); - } else { - printparents( parentp ); - gprofline( parentp ); - printchildren( parentp ); - } - printf( "\n" ); - printf( "-----------------------------------------------\n" ); - printf( "\n" ); - } - cfree( timesortnlp ); -} - - /* - * sort by decreasing propagated time - * if times are equal, but one is a cycle header, - * say that's first (e.g. less, i.e. -1). - * if one's name doesn't have an underscore and the other does, - * say the one is first. - * all else being equal, sort by names. - */ -int -totalcmp( npp1 , npp2 ) - nltype **npp1; - nltype **npp2; -{ - register nltype *np1 = *npp1; - register nltype *np2 = *npp2; - double diff; - - diff = ( np1 -> propself + np1 -> propchild ) - - ( np2 -> propself + np2 -> propchild ); - if ( diff < 0.0 ) - return 1; - if ( diff > 0.0 ) - return -1; - if ( np1 -> name == 0 && np1 -> cycleno != 0 ) - return -1; - if ( np2 -> name == 0 && np2 -> cycleno != 0 ) - return 1; - if ( np1 -> name == 0 ) - return -1; - if ( np2 -> name == 0 ) - return 1; - if ( *(np1 -> name) != '_' && *(np2 -> name) == '_' ) - return -1; - if ( *(np1 -> name) == '_' && *(np2 -> name) != '_' ) - return 1; - if ( np1 -> ncall > np2 -> ncall ) - return -1; - if ( np1 -> ncall < np2 -> ncall ) - return 1; - return strcmp( np1 -> name , np2 -> name ); -} - -printparents( childp ) - nltype *childp; -{ - nltype *parentp; - arctype *arcp; - nltype *cycleheadp; - - if ( childp -> cyclehead != 0 ) { - cycleheadp = childp -> cyclehead; - } else { - cycleheadp = childp; - } - if ( childp -> parents == 0 ) { - printf( "%6.6s %5.5s %7.7s %11.11s %7.7s %7.7s \n" , - "" , "" , "" , "" , "" , "" ); - return; - } - sortparents( childp ); - for ( arcp = childp -> parents ; arcp ; arcp = arcp -> arc_parentlist ) { - parentp = arcp -> arc_parentp; - if ( childp == parentp || - ( childp->cycleno != 0 && parentp->cycleno == childp->cycleno ) ) { - /* - * selfcall or call among siblings - */ - printf( "%6.6s %5.5s %7.7s %11.11s %7d %7.7s " , - "" , "" , "" , "" , - arcp -> arc_count , "" ); - printname( parentp ); - printf( "\n" ); - } else { - /* - * regular parent of child - */ - printf( "%6.6s %5.5s %7.2f %11.2f %7d/%-7d " , - "" , "" , - arcp -> arc_time / hz , arcp -> arc_childtime / hz , - arcp -> arc_count , cycleheadp -> ncall ); - printname( parentp ); - printf( "\n" ); - } - } -} - -printchildren( parentp ) - nltype *parentp; -{ - nltype *childp; - arctype *arcp; - - sortchildren( parentp ); - arcp = parentp -> children; - for ( arcp = parentp -> children ; arcp ; arcp = arcp -> arc_childlist ) { - childp = arcp -> arc_childp; - if ( childp == parentp || - ( childp->cycleno != 0 && childp->cycleno == parentp->cycleno ) ) { - /* - * self call or call to sibling - */ - printf( "%6.6s %5.5s %7.7s %11.11s %7d %7.7s " , - "" , "" , "" , "" , arcp -> arc_count , "" ); - printname( childp ); - printf( "\n" ); - } else { - /* - * regular child of parent - */ - printf( "%6.6s %5.5s %7.2f %11.2f %7d/%-7d " , - "" , "" , - arcp -> arc_time / hz , arcp -> arc_childtime / hz , - arcp -> arc_count , childp -> cyclehead -> ncall ); - printname( childp ); - printf( "\n" ); - } - } -} - -printname( selfp ) - nltype *selfp; -{ - - if ( selfp -> name != 0 ) { - printf( "%s" , selfp -> name ); -# ifdef DEBUG - if ( debug & DFNDEBUG ) { - printf( "{%d} " , selfp -> toporder ); - } - if ( debug & PROPDEBUG ) { - printf( "%5.2f%% " , selfp -> propfraction ); - } -# endif DEBUG - } - if ( selfp -> cycleno != 0 ) { - printf( " " , selfp -> cycleno ); - } - if ( selfp -> index != 0 ) { - if ( selfp -> printflag ) { - printf( " [%d]" , selfp -> index ); - } else { - printf( " (%d)" , selfp -> index ); - } - } -} - -sortchildren( parentp ) - nltype *parentp; -{ - arctype *arcp; - arctype *detachedp; - arctype sorted; - arctype *prevp; - - /* - * unlink children from parent, - * then insertion sort back on to sorted's children. - * *arcp the arc you have detached and are inserting. - * *detachedp the rest of the arcs to be sorted. - * sorted arc list onto which you insertion sort. - * *prevp arc before the arc you are comparing. - */ - sorted.arc_childlist = 0; - for ( (arcp = parentp -> children)&&(detachedp = arcp -> arc_childlist); - arcp ; - (arcp = detachedp)&&(detachedp = detachedp -> arc_childlist)) { - /* - * consider *arcp as disconnected - * insert it into sorted - */ - for ( prevp = &sorted ; - prevp -> arc_childlist ; - prevp = prevp -> arc_childlist ) { - if ( arccmp( arcp , prevp -> arc_childlist ) != LESSTHAN ) { - break; - } - } - arcp -> arc_childlist = prevp -> arc_childlist; - prevp -> arc_childlist = arcp; - } - /* - * reattach sorted children to parent - */ - parentp -> children = sorted.arc_childlist; -} - -sortparents( childp ) - nltype *childp; -{ - arctype *arcp; - arctype *detachedp; - arctype sorted; - arctype *prevp; - - /* - * unlink parents from child, - * then insertion sort back on to sorted's parents. - * *arcp the arc you have detached and are inserting. - * *detachedp the rest of the arcs to be sorted. - * sorted arc list onto which you insertion sort. - * *prevp arc before the arc you are comparing. - */ - sorted.arc_parentlist = 0; - for ( (arcp = childp -> parents)&&(detachedp = arcp -> arc_parentlist); - arcp ; - (arcp = detachedp)&&(detachedp = detachedp -> arc_parentlist)) { - /* - * consider *arcp as disconnected - * insert it into sorted - */ - for ( prevp = &sorted ; - prevp -> arc_parentlist ; - prevp = prevp -> arc_parentlist ) { - if ( arccmp( arcp , prevp -> arc_parentlist ) != GREATERTHAN ) { - break; - } - } - arcp -> arc_parentlist = prevp -> arc_parentlist; - prevp -> arc_parentlist = arcp; - } - /* - * reattach sorted arcs to child - */ - childp -> parents = sorted.arc_parentlist; -} - - /* - * print a cycle header - */ -printcycle( cyclep ) - nltype *cyclep; -{ - char kirkbuffer[ BUFSIZ ]; - - sprintf( kirkbuffer , "[%d]" , cyclep -> index ); - printf( "%-6.6s %5.1f %7.2f %11.2f %7d" , - kirkbuffer , - 100 * ( cyclep -> propself + cyclep -> propchild ) / printtime , - cyclep -> propself / hz , - cyclep -> propchild / hz , - cyclep -> ncall ); - if ( cyclep -> selfcalls != 0 ) { - printf( "+%-7d" , cyclep -> selfcalls ); - } else { - printf( " %7.7s" , "" ); - } - printf( " \t[%d]\n" , - cyclep -> cycleno , cyclep -> index ); -} - - /* - * print the members of a cycle - */ -printmembers( cyclep ) - nltype *cyclep; -{ - nltype *memberp; - - sortmembers( cyclep ); - for ( memberp = cyclep -> cnext ; memberp ; memberp = memberp -> cnext ) { - printf( "%6.6s %5.5s %7.2f %11.2f %7d" , - "" , "" , memberp -> propself / hz , memberp -> propchild / hz , - memberp -> ncall ); - if ( memberp -> selfcalls != 0 ) { - printf( "+%-7d" , memberp -> selfcalls ); - } else { - printf( " %7.7s" , "" ); - } - printf( " " ); - printname( memberp ); - printf( "\n" ); - } -} - - /* - * sort members of a cycle - */ -sortmembers( cyclep ) - nltype *cyclep; -{ - nltype *todo; - nltype *doing; - nltype *prev; - - /* - * detach cycle members from cyclehead, - * and insertion sort them back on. - */ - todo = cyclep -> cnext; - cyclep -> cnext = 0; - for ( (doing = todo)&&(todo = doing -> cnext); - doing ; - (doing = todo )&&(todo = doing -> cnext )){ - for ( prev = cyclep ; prev -> cnext ; prev = prev -> cnext ) { - if ( membercmp( doing , prev -> cnext ) == GREATERTHAN ) { - break; - } - } - doing -> cnext = prev -> cnext; - prev -> cnext = doing; - } -} - - /* - * major sort is on propself + propchild, - * next is sort on ncalls + selfcalls. - */ -int -membercmp( this , that ) - nltype *this; - nltype *that; -{ - double thistime = this -> propself + this -> propchild; - double thattime = that -> propself + that -> propchild; - long thiscalls = this -> ncall + this -> selfcalls; - long thatcalls = that -> ncall + that -> selfcalls; - - if ( thistime > thattime ) { - return GREATERTHAN; - } - if ( thistime < thattime ) { - return LESSTHAN; - } - if ( thiscalls > thatcalls ) { - return GREATERTHAN; - } - if ( thiscalls < thatcalls ) { - return LESSTHAN; - } - return EQUALTO; -} - /* - * compare two arcs to/from the same child/parent. - * - if one arc is a self arc, it's least. - * - if one arc is within a cycle, it's less than. - * - if both arcs are within a cycle, compare arc counts. - * - if neither arc is within a cycle, compare with - * arc_time + arc_childtime as major key - * arc count as minor key - */ -int -arccmp( thisp , thatp ) - arctype *thisp; - arctype *thatp; -{ - nltype *thisparentp = thisp -> arc_parentp; - nltype *thischildp = thisp -> arc_childp; - nltype *thatparentp = thatp -> arc_parentp; - nltype *thatchildp = thatp -> arc_childp; - double thistime; - double thattime; - -# ifdef DEBUG - if ( debug & TIMEDEBUG ) { - printf( "[arccmp] " ); - printname( thisparentp ); - printf( " calls " ); - printname ( thischildp ); - printf( " %f + %f %d/%d\n" , - thisp -> arc_time , thisp -> arc_childtime , - thisp -> arc_count , thischildp -> ncall ); - printf( "[arccmp] " ); - printname( thatparentp ); - printf( " calls " ); - printname( thatchildp ); - printf( " %f + %f %d/%d\n" , - thatp -> arc_time , thatp -> arc_childtime , - thatp -> arc_count , thatchildp -> ncall ); - printf( "\n" ); - } -# endif DEBUG - if ( thisparentp == thischildp ) { - /* this is a self call */ - return LESSTHAN; - } - if ( thatparentp == thatchildp ) { - /* that is a self call */ - return GREATERTHAN; - } - if ( thisparentp -> cycleno != 0 && thischildp -> cycleno != 0 && - thisparentp -> cycleno == thischildp -> cycleno ) { - /* this is a call within a cycle */ - if ( thatparentp -> cycleno != 0 && thatchildp -> cycleno != 0 && - thatparentp -> cycleno == thatchildp -> cycleno ) { - /* that is a call within the cycle, too */ - if ( thisp -> arc_count < thatp -> arc_count ) { - return LESSTHAN; - } - if ( thisp -> arc_count > thatp -> arc_count ) { - return GREATERTHAN; - } - return EQUALTO; - } else { - /* that isn't a call within the cycle */ - return LESSTHAN; - } - } else { - /* this isn't a call within a cycle */ - if ( thatparentp -> cycleno != 0 && thatchildp -> cycleno != 0 && - thatparentp -> cycleno == thatchildp -> cycleno ) { - /* that is a call within a cycle */ - return GREATERTHAN; - } else { - /* neither is a call within a cycle */ - thistime = thisp -> arc_time + thisp -> arc_childtime; - thattime = thatp -> arc_time + thatp -> arc_childtime; - if ( thistime < thattime ) - return LESSTHAN; - if ( thistime > thattime ) - return GREATERTHAN; - if ( thisp -> arc_count < thatp -> arc_count ) - return LESSTHAN; - if ( thisp -> arc_count > thatp -> arc_count ) - return GREATERTHAN; - return EQUALTO; - } - } -} - -printblurb( blurbname ) - char *blurbname; -{ - FILE *blurbfile; - int input; - - blurbfile = fopen( blurbname , "r" ); - if ( blurbfile == NULL ) { - perror( blurbname ); - return; - } - while ( ( input = getc( blurbfile ) ) != EOF ) { - putchar( input ); - } - fclose( blurbfile ); -} - -int -namecmp( npp1 , npp2 ) - nltype **npp1, **npp2; -{ - return( strcmp( (*npp1) -> name , (*npp2) -> name ) ); -} - -printindex() -{ - nltype **namesortnlp; - register nltype *nlp; - int index, nnames, todo, i, j; - char peterbuffer[ BUFSIZ ]; - - /* - * Now, sort regular function name alphbetically - * to create an index. - */ - namesortnlp = (nltype **) calloc( nname + ncycle , sizeof(nltype *) ); - if ( namesortnlp == (nltype **) 0 ) { - fprintf( stderr , "%s: ran out of memory for sorting\n" , whoami ); - } - for ( index = 0 , nnames = 0 ; index < nname ; index++ ) { - if ( zflag == 0 && nl[index].ncall == 0 && nl[index].time == 0 ) - continue; - namesortnlp[nnames++] = &nl[index]; - } - qsort( namesortnlp , nnames , sizeof(nltype *) , namecmp ); - for ( index = 1 , todo = nnames ; index <= ncycle ; index++ ) { - namesortnlp[todo++] = &cyclenl[index]; - } - printf( "\f\nIndex by function name\n\n" ); - index = ( todo + 2 ) / 3; - for ( i = 0; i < index ; i++ ) { - for ( j = i; j < todo ; j += index ) { - nlp = namesortnlp[ j ]; - if ( nlp -> printflag ) { - sprintf( peterbuffer , "[%d]" , nlp -> index ); - } else { - sprintf( peterbuffer , "(%d)" , nlp -> index ); - } - if ( j < nnames ) { - printf( "%6.6s %-19.19s" , peterbuffer , nlp -> name ); - } else { - printf( "%6.6s " , peterbuffer ); - sprintf( peterbuffer , "" , nlp -> cycleno ); - printf( "%-19.19s" , peterbuffer ); - } - } - printf( "\n" ); - } - cfree( namesortnlp ); -} diff --git a/gprof/printlist.c b/gprof/printlist.c deleted file mode 100644 index 8e952f05d2b..00000000000 --- a/gprof/printlist.c +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 1983 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that: (1) source distributions retain this entire copyright - * notice and comment, and (2) distributions including binaries display - * the following acknowledgement: ``This product includes software - * developed by the University of California, Berkeley and its contributors'' - * in the documentation or other materials provided with the distribution - * and in all advertising materials mentioning features or use of this - * software. Neither the name of the University nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ - -#ifndef lint -static char sccsid[] = "@(#)printlist.c 5.5 (Berkeley) 6/1/90"; -#endif /* not lint */ - -#include "gprof.h" - - /* - * these are the lists of names: - * there is the list head and then the listname - * is a pointer to the list head - * (for ease of passing to stringlist functions). - */ -struct stringlist kfromhead = { 0 , 0 }; -struct stringlist *kfromlist = &kfromhead; -struct stringlist ktohead = { 0 , 0 }; -struct stringlist *ktolist = &ktohead; -struct stringlist fhead = { 0 , 0 }; -struct stringlist *flist = &fhead; -struct stringlist Fhead = { 0 , 0 }; -struct stringlist *Flist = &Fhead; -struct stringlist ehead = { 0 , 0 }; -struct stringlist *elist = &ehead; -struct stringlist Ehead = { 0 , 0 }; -struct stringlist *Elist = &Ehead; - -addlist( listp , funcname ) - struct stringlist *listp; - char *funcname; -{ - struct stringlist *slp; - - slp = (struct stringlist *) malloc( sizeof(struct stringlist)); - if ( slp == (struct stringlist *) 0 ) { - fprintf( stderr, "gprof: ran out room for printlist\n" ); - done(); - } - slp -> next = listp -> next; - slp -> string = funcname; - listp -> next = slp; -} - -bool -onlist( listp , funcname ) - struct stringlist *listp; - char *funcname; -{ - struct stringlist *slp; - - for ( slp = listp -> next ; slp ; slp = slp -> next ) { - if ( ! strcmp( slp -> string , funcname ) ) { - return TRUE; - } - if ( funcname[0] == '_' && ! strcmp( slp -> string , &funcname[1] ) ) { - return TRUE; - } - } - return FALSE; -} diff --git a/gprof/sparc.c b/gprof/sparc.c deleted file mode 100644 index 2fd7c65c4ae..00000000000 --- a/gprof/sparc.c +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright (c) 1983 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that: (1) source distributions retain this entire copyright - * notice and comment, and (2) distributions including binaries display - * the following acknowledgement: ``This product includes software - * developed by the University of California, Berkeley and its contributors'' - * in the documentation or other materials provided with the distribution - * and in all advertising materials mentioning features or use of this - * software. Neither the name of the University nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ - -#ifndef lint -static char sccsid[] = "@(#)tahoe.c 1.5 (Berkeley) 6/1/90"; -#endif /* not lint */ - -#include "gprof.h" - - /* - * a namelist entry to be the child of indirect callf - */ -nltype indirectchild = { - "(*)" , /* the name */ - (unsigned long) 0 , /* the pc entry point */ - (unsigned long) 0 , /* entry point aligned to histogram */ - (double) 0.0 , /* ticks in this routine */ - (double) 0.0 , /* cumulative ticks in children */ - (long) 0 , /* how many times called */ - (long) 0 , /* how many calls to self */ - (double) 1.0 , /* propagation fraction */ - (double) 0.0 , /* self propagation time */ - (double) 0.0 , /* child propagation time */ - (bool) 0 , /* print flag */ - (int) 0 , /* index in the graph list */ - (int) 0 , /* graph call chain top-sort order */ - (int) 0 , /* internal number of cycle on */ - (struct nl *) &indirectchild , /* pointer to head of cycle */ - (struct nl *) 0 , /* pointer to next member of cycle */ - (arctype *) 0 , /* list of caller arcs */ - (arctype *) 0 /* list of callee arcs */ - }; - -findcall( parentp , p_lowpc , p_highpc ) - nltype *parentp; - unsigned long p_lowpc; - unsigned long p_highpc; -{ - unsigned char *instructp; - long length; - nltype *childp; - unsigned long destpc; - - if ( textspace == 0 ) { - return; - } - if ( p_lowpc < s_lowpc ) { - p_lowpc = s_lowpc; - } - if ( p_highpc > s_highpc ) { - p_highpc = s_highpc; - } -# ifdef DEBUG - if ( debug & CALLDEBUG ) { - printf( "[findcall] %s: 0x%x to 0x%x\n" , - parentp -> name , p_lowpc , p_highpc ); - } -# endif DEBUG - for ( instructp = textspace + p_lowpc ; - instructp < textspace + p_highpc ; - instructp += length ) { - length = 1; - if ( (*instructp & CALL) ) { -# ifdef DEBUG - if ( debug & CALLDEBUG ) { - printf( "[findcall]\t0x%x:callf" , instructp - textspace ); - } -# endif DEBUG - length = 4; /* constant length in a SPARC */ - /* - * regular pc relative addressing - * check that this is the address of - * a function. - */ - destpc = ( (unsigned long)instructp + (*(long *)instructp & ~CALL) ) - - (unsigned long) textspace; - if ( destpc >= s_lowpc && destpc <= s_highpc ) { - childp = nllookup( destpc ); -# ifdef DEBUG - if ( debug & CALLDEBUG ) { - printf( "[findcall]\tdestpc 0x%x" , destpc ); - printf( " childp->name %s" , childp -> name ); - printf( " childp->value 0x%x\n" , - childp -> value ); - } -# endif DEBUG - if ( childp -> value == destpc ) { - /* - * a hit - */ - addarc( parentp , childp , (long) 0 ); - length += 4; /* constant lengths */ - continue; - } - goto botched; - } - /* - * else: - * it looked like a callf, - * but it wasn't to anywhere. - */ - botched: - /* - * something funny going on. - */ -# ifdef DEBUG - if ( debug & CALLDEBUG ) { - printf( "[findcall]\tbut it's a botch\n" ); - } -# endif DEBUG - length = 1; - continue; - } - } - } diff --git a/gprof/sparc.h b/gprof/sparc.h deleted file mode 100644 index 0287b88fc69..00000000000 --- a/gprof/sparc.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 1983 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that: (1) source distributions retain this entire copyright - * notice and comment, and (2) distributions including binaries display - * the following acknowledgement: ``This product includes software - * developed by the University of California, Berkeley and its contributors'' - * in the documentation or other materials provided with the distribution - * and in all advertising materials mentioning features or use of this - * software. Neither the name of the University nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * @(#)tahoe.h 1.4 (Berkeley) 6/1/90 - */ - - /* - * opcode of the `callf' instruction - */ -#define CALL (0xc0000000) - /* - * offset (in bytes) of the code from the entry address of a routine. - * (see asgnsamples for use and explanation.) - */ -#define OFFSET_OF_CODE 0 -#define UNITS_TO_CODE (OFFSET_OF_CODE / sizeof(UNIT)) - diff --git a/gprof/t.c b/gprof/t.c deleted file mode 100755 index 62272b4b1fc..00000000000 --- a/gprof/t.c +++ /dev/null @@ -1,12 +0,0 @@ -void -foo(int x) { - if (x&3) - foo (x-1); -} - -main() { - int i; - - for (i=0; i< 1024; i++) - foo(i); -} diff --git a/gprof/tahoe.c b/gprof/tahoe.c deleted file mode 100644 index 924d95d06e1..00000000000 --- a/gprof/tahoe.c +++ /dev/null @@ -1,335 +0,0 @@ -/* - * Copyright (c) 1983 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that: (1) source distributions retain this entire copyright - * notice and comment, and (2) distributions including binaries display - * the following acknowledgement: ``This product includes software - * developed by the University of California, Berkeley and its contributors'' - * in the documentation or other materials provided with the distribution - * and in all advertising materials mentioning features or use of this - * software. Neither the name of the University nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ - -#ifndef lint -static char sccsid[] = "@(#)tahoe.c 1.5 (Berkeley) 6/1/90"; -#endif /* not lint */ - -#include "gprof.h" - - /* - * a namelist entry to be the child of indirect callf - */ -nltype indirectchild = { - "(*)" , /* the name */ - (unsigned long) 0 , /* the pc entry point */ - (unsigned long) 0 , /* entry point aligned to histogram */ - (double) 0.0 , /* ticks in this routine */ - (double) 0.0 , /* cumulative ticks in children */ - (long) 0 , /* how many times called */ - (long) 0 , /* how many calls to self */ - (double) 1.0 , /* propagation fraction */ - (double) 0.0 , /* self propagation time */ - (double) 0.0 , /* child propagation time */ - (bool) 0 , /* print flag */ - (int) 0 , /* index in the graph list */ - (int) 0 , /* graph call chain top-sort order */ - (int) 0 , /* internal number of cycle on */ - (struct nl *) &indirectchild , /* pointer to head of cycle */ - (struct nl *) 0 , /* pointer to next member of cycle */ - (arctype *) 0 , /* list of caller arcs */ - (arctype *) 0 /* list of callee arcs */ - }; - -operandenum -operandmode( modep ) - unsigned char *modep; -{ - long usesreg = ((long)*modep) & 0xf; - - switch ( ((long)*modep) >> 4 ) { - case 0: - case 1: - case 2: - case 3: - return literal; - case 4: - return indexed; - case 5: - return reg; - case 6: - return regdef; - case 7: - return autodec; - case 8: - return ( usesreg != 0xe ? autoinc : immediate ); - case 9: - return ( usesreg != PC ? autoincdef : absolute ); - case 10: - return ( usesreg != PC ? bytedisp : byterel ); - case 11: - return ( usesreg != PC ? bytedispdef : bytereldef ); - case 12: - return ( usesreg != PC ? worddisp : wordrel ); - case 13: - return ( usesreg != PC ? worddispdef : wordreldef ); - case 14: - return ( usesreg != PC ? longdisp : longrel ); - case 15: - return ( usesreg != PC ? longdispdef : longreldef ); - } - /* NOTREACHED */ -} - -char * -operandname( mode ) - operandenum mode; -{ - - switch ( mode ) { - case literal: - return "literal"; - case indexed: - return "indexed"; - case reg: - return "register"; - case regdef: - return "register deferred"; - case autodec: - return "autodecrement"; - case autoinc: - return "autoincrement"; - case autoincdef: - return "autoincrement deferred"; - case bytedisp: - return "byte displacement"; - case bytedispdef: - return "byte displacement deferred"; - case byterel: - return "byte relative"; - case bytereldef: - return "byte relative deferred"; - case worddisp: - return "word displacement"; - case worddispdef: - return "word displacement deferred"; - case wordrel: - return "word relative"; - case wordreldef: - return "word relative deferred"; - case immediate: - return "immediate"; - case absolute: - return "absolute"; - case longdisp: - return "long displacement"; - case longdispdef: - return "long displacement deferred"; - case longrel: - return "long relative"; - case longreldef: - return "long relative deferred"; - } - /* NOTREACHED */ -} - -long -operandlength( modep ) - unsigned char *modep; -{ - - switch ( operandmode( modep ) ) { - case literal: - case reg: - case regdef: - case autodec: - case autoinc: - case autoincdef: - return 1; - case bytedisp: - case bytedispdef: - case byterel: - case bytereldef: - return 2; - case worddisp: - case worddispdef: - case wordrel: - case wordreldef: - return 3; - case immediate: - case absolute: - case longdisp: - case longdispdef: - case longrel: - case longreldef: - return 5; - case indexed: - return 1+operandlength( modep + 1 ); - } - /* NOTREACHED */ -} - -unsigned long -reladdr( modep ) - char *modep; -{ - operandenum mode = operandmode( modep ); - char *cp; - short *sp; - long *lp; - int i; - long value = 0; - - cp = modep; - cp += 1; /* skip over the mode */ - switch ( mode ) { - default: - fprintf( stderr , "[reladdr] not relative address\n" ); - return (unsigned long) modep; - case byterel: - return (unsigned long) ( cp + sizeof *cp + *cp ); - case wordrel: - for (i = 0; i < sizeof *sp; i++) - value = (value << 8) + (cp[i] & 0xff); - return (unsigned long) ( cp + sizeof *sp + value ); - case longrel: - for (i = 0; i < sizeof *lp; i++) - value = (value << 8) + (cp[i] & 0xff); - return (unsigned long) ( cp + sizeof *lp + value ); - } -} - -findcall( parentp , p_lowpc , p_highpc ) - nltype *parentp; - unsigned long p_lowpc; - unsigned long p_highpc; -{ - unsigned char *instructp; - long length; - nltype *childp; - operandenum mode; - operandenum firstmode; - unsigned long destpc; - - if ( textspace == 0 ) { - return; - } - if ( p_lowpc < s_lowpc ) { - p_lowpc = s_lowpc; - } - if ( p_highpc > s_highpc ) { - p_highpc = s_highpc; - } -# ifdef DEBUG - if ( debug & CALLDEBUG ) { - printf( "[findcall] %s: 0x%x to 0x%x\n" , - parentp -> name , p_lowpc , p_highpc ); - } -# endif DEBUG - for ( instructp = textspace + p_lowpc ; - instructp < textspace + p_highpc ; - instructp += length ) { - length = 1; - if ( *instructp == CALLF ) { - /* - * maybe a callf, better check it out. - * skip the count of the number of arguments. - */ -# ifdef DEBUG - if ( debug & CALLDEBUG ) { - printf( "[findcall]\t0x%x:callf" , instructp - textspace ); - } -# endif DEBUG - firstmode = operandmode( instructp+length ); - switch ( firstmode ) { - case literal: - case immediate: - break; - default: - goto botched; - } - length += operandlength( instructp+length ); - mode = operandmode( instructp + length ); -# ifdef DEBUG - if ( debug & CALLDEBUG ) { - printf( "\tfirst operand is %s", operandname( firstmode ) ); - printf( "\tsecond operand is %s\n" , operandname( mode ) ); - } -# endif DEBUG - switch ( mode ) { - case regdef: - case bytedispdef: - case worddispdef: - case longdispdef: - case bytereldef: - case wordreldef: - case longreldef: - /* - * indirect call: call through pointer - * either *d(r) as a parameter or local - * (r) as a return value - * *f as a global pointer - * [are there others that we miss?, - * e.g. arrays of pointers to functions???] - */ - addarc( parentp , &indirectchild , (long) 0 ); - length += operandlength( instructp + length ); - continue; - case byterel: - case wordrel: - case longrel: - /* - * regular pc relative addressing - * check that this is the address of - * a function. - */ - destpc = reladdr( instructp+length ) - - (unsigned long) textspace; - if ( destpc >= s_lowpc && destpc <= s_highpc ) { - childp = nllookup( destpc ); -# ifdef DEBUG - if ( debug & CALLDEBUG ) { - printf( "[findcall]\tdestpc 0x%x" , destpc ); - printf( " childp->name %s" , childp -> name ); - printf( " childp->value 0x%x\n" , - childp -> value ); - } -# endif DEBUG - if ( childp -> value == destpc ) { - /* - * a hit - */ - addarc( parentp , childp , (long) 0 ); - length += operandlength( instructp + length ); - continue; - } - goto botched; - } - /* - * else: - * it looked like a callf, - * but it wasn't to anywhere. - */ - goto botched; - default: - botched: - /* - * something funny going on. - */ -# ifdef DEBUG - if ( debug & CALLDEBUG ) { - printf( "[findcall]\tbut it's a botch\n" ); - } -# endif DEBUG - length = 1; - continue; - } - } - } -} diff --git a/gprof/tahoe.h b/gprof/tahoe.h deleted file mode 100644 index 55c1d32e47e..00000000000 --- a/gprof/tahoe.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 1983 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that: (1) source distributions retain this entire copyright - * notice and comment, and (2) distributions including binaries display - * the following acknowledgement: ``This product includes software - * developed by the University of California, Berkeley and its contributors'' - * in the documentation or other materials provided with the distribution - * and in all advertising materials mentioning features or use of this - * software. Neither the name of the University nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * @(#)tahoe.h 1.4 (Berkeley) 6/1/90 - */ - - /* - * opcode of the `callf' instruction - */ -#define CALLF 0xfe - - /* - * offset (in bytes) of the code from the entry address of a routine. - * (see asgnsamples for use and explanation.) - */ -#define OFFSET_OF_CODE 2 -#define UNITS_TO_CODE (OFFSET_OF_CODE / sizeof(UNIT)) - - /* - * register for pc relative addressing - */ -#define PC 0xf - -enum opermodes { - literal, indexed, reg, regdef, autodec, autoinc, autoincdef, - bytedisp, bytedispdef, worddisp, worddispdef, longdisp, longdispdef, - immediate, absolute, byterel, bytereldef, wordrel, wordreldef, - longrel, longreldef -}; -typedef enum opermodes operandenum; diff --git a/gprof/vax.c b/gprof/vax.c deleted file mode 100644 index 220b7582ad1..00000000000 --- a/gprof/vax.c +++ /dev/null @@ -1,333 +0,0 @@ -/* - * Copyright (c) 1983 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that: (1) source distributions retain this entire copyright - * notice and comment, and (2) distributions including binaries display - * the following acknowledgement: ``This product includes software - * developed by the University of California, Berkeley and its contributors'' - * in the documentation or other materials provided with the distribution - * and in all advertising materials mentioning features or use of this - * software. Neither the name of the University nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ - -#ifndef lint -static char sccsid[] = "@(#)vax.c 5.6 (Berkeley) 6/1/90"; -#endif /* not lint */ - -#include "gprof.h" - - /* - * a namelist entry to be the child of indirect calls - */ -nltype indirectchild = { - "(*)" , /* the name */ - (unsigned long) 0 , /* the pc entry point */ - (unsigned long) 0 , /* entry point aligned to histogram */ - (double) 0.0 , /* ticks in this routine */ - (double) 0.0 , /* cumulative ticks in children */ - (long) 0 , /* how many times called */ - (long) 0 , /* how many calls to self */ - (double) 1.0 , /* propagation fraction */ - (double) 0.0 , /* self propagation time */ - (double) 0.0 , /* child propagation time */ - (bool) 0 , /* print flag */ - (int) 0 , /* index in the graph list */ - (int) 0 , /* graph call chain top-sort order */ - (int) 0 , /* internal number of cycle on */ - (struct nl *) &indirectchild , /* pointer to head of cycle */ - (struct nl *) 0 , /* pointer to next member of cycle */ - (arctype *) 0 , /* list of caller arcs */ - (arctype *) 0 /* list of callee arcs */ - }; - -operandenum -operandmode( modep ) - struct modebyte *modep; -{ - long usesreg = modep -> regfield; - - switch ( modep -> modefield ) { - case 0: - case 1: - case 2: - case 3: - return literal; - case 4: - return indexed; - case 5: - return reg; - case 6: - return regdef; - case 7: - return autodec; - case 8: - return ( usesreg != PC ? autoinc : immediate ); - case 9: - return ( usesreg != PC ? autoincdef : absolute ); - case 10: - return ( usesreg != PC ? bytedisp : byterel ); - case 11: - return ( usesreg != PC ? bytedispdef : bytereldef ); - case 12: - return ( usesreg != PC ? worddisp : wordrel ); - case 13: - return ( usesreg != PC ? worddispdef : wordreldef ); - case 14: - return ( usesreg != PC ? longdisp : longrel ); - case 15: - return ( usesreg != PC ? longdispdef : longreldef ); - } - /* NOTREACHED */ -} - -char * -operandname( mode ) - operandenum mode; -{ - - switch ( mode ) { - case literal: - return "literal"; - case indexed: - return "indexed"; - case reg: - return "register"; - case regdef: - return "register deferred"; - case autodec: - return "autodecrement"; - case autoinc: - return "autoincrement"; - case autoincdef: - return "autoincrement deferred"; - case bytedisp: - return "byte displacement"; - case bytedispdef: - return "byte displacement deferred"; - case byterel: - return "byte relative"; - case bytereldef: - return "byte relative deferred"; - case worddisp: - return "word displacement"; - case worddispdef: - return "word displacement deferred"; - case wordrel: - return "word relative"; - case wordreldef: - return "word relative deferred"; - case immediate: - return "immediate"; - case absolute: - return "absolute"; - case longdisp: - return "long displacement"; - case longdispdef: - return "long displacement deferred"; - case longrel: - return "long relative"; - case longreldef: - return "long relative deferred"; - } - /* NOTREACHED */ -} - -long -operandlength( modep ) - struct modebyte *modep; -{ - - switch ( operandmode( modep ) ) { - case literal: - case reg: - case regdef: - case autodec: - case autoinc: - case autoincdef: - return 1; - case bytedisp: - case bytedispdef: - case byterel: - case bytereldef: - return 2; - case worddisp: - case worddispdef: - case wordrel: - case wordreldef: - return 3; - case immediate: - case absolute: - case longdisp: - case longdispdef: - case longrel: - case longreldef: - return 5; - case indexed: - return 1+operandlength( (struct modebyte *) ((char *) modep) + 1 ); - } - /* NOTREACHED */ -} - -unsigned long -reladdr( modep ) - struct modebyte *modep; -{ - operandenum mode = operandmode( modep ); - char *cp; - short *sp; - long *lp; - - cp = (char *) modep; - cp += 1; /* skip over the mode */ - switch ( mode ) { - default: - fprintf( stderr , "[reladdr] not relative address\n" ); - return (unsigned long) modep; - case byterel: - return (unsigned long) ( cp + sizeof *cp + *cp ); - case wordrel: - sp = (short *) cp; - return (unsigned long) ( cp + sizeof *sp + *sp ); - case longrel: - lp = (long *) cp; - return (unsigned long) ( cp + sizeof *lp + *lp ); - } -} - -findcall( parentp , p_lowpc , p_highpc ) - nltype *parentp; - unsigned long p_lowpc; - unsigned long p_highpc; -{ - unsigned char *instructp; - long length; - nltype *childp; - operandenum mode; - operandenum firstmode; - unsigned long destpc; - - if ( textspace == 0 ) { - return; - } - if ( p_lowpc < s_lowpc ) { - p_lowpc = s_lowpc; - } - if ( p_highpc > s_highpc ) { - p_highpc = s_highpc; - } -# ifdef DEBUG - if ( debug & CALLDEBUG ) { - printf( "[findcall] %s: 0x%x to 0x%x\n" , - parentp -> name , p_lowpc , p_highpc ); - } -# endif DEBUG - for ( instructp = textspace + p_lowpc ; - instructp < textspace + p_highpc ; - instructp += length ) { - length = 1; - if ( *instructp == CALLS ) { - /* - * maybe a calls, better check it out. - * skip the count of the number of arguments. - */ -# ifdef DEBUG - if ( debug & CALLDEBUG ) { - printf( "[findcall]\t0x%x:calls" , instructp - textspace ); - } -# endif DEBUG - firstmode = operandmode( (struct modebyte *) (instructp+length) ); - switch ( firstmode ) { - case literal: - case immediate: - break; - default: - goto botched; - } - length += operandlength( (struct modebyte *) (instructp+length) ); - mode = operandmode( (struct modebyte *) ( instructp + length ) ); -# ifdef DEBUG - if ( debug & CALLDEBUG ) { - printf( "\tfirst operand is %s", operandname( firstmode ) ); - printf( "\tsecond operand is %s\n" , operandname( mode ) ); - } -# endif DEBUG - switch ( mode ) { - case regdef: - case bytedispdef: - case worddispdef: - case longdispdef: - case bytereldef: - case wordreldef: - case longreldef: - /* - * indirect call: call through pointer - * either *d(r) as a parameter or local - * (r) as a return value - * *f as a global pointer - * [are there others that we miss?, - * e.g. arrays of pointers to functions???] - */ - addarc( parentp , &indirectchild , (long) 0 ); - length += operandlength( - (struct modebyte *) ( instructp + length ) ); - continue; - case byterel: - case wordrel: - case longrel: - /* - * regular pc relative addressing - * check that this is the address of - * a function. - */ - destpc = reladdr( (struct modebyte *) (instructp+length) ) - - (unsigned long) textspace; - if ( destpc >= s_lowpc && destpc <= s_highpc ) { - childp = nllookup( destpc ); -# ifdef DEBUG - if ( debug & CALLDEBUG ) { - printf( "[findcall]\tdestpc 0x%x" , destpc ); - printf( " childp->name %s" , childp -> name ); - printf( " childp->value 0x%x\n" , - childp -> value ); - } -# endif DEBUG - if ( childp -> value == destpc ) { - /* - * a hit - */ - addarc( parentp , childp , (long) 0 ); - length += operandlength( (struct modebyte *) - ( instructp + length ) ); - continue; - } - goto botched; - } - /* - * else: - * it looked like a calls, - * but it wasn't to anywhere. - */ - goto botched; - default: - botched: - /* - * something funny going on. - */ -# ifdef DEBUG - if ( debug & CALLDEBUG ) { - printf( "[findcall]\tbut it's a botch\n" ); - } -# endif DEBUG - length = 1; - continue; - } - } - } -} diff --git a/gprof/vax.h b/gprof/vax.h deleted file mode 100644 index 3e45167520e..00000000000 --- a/gprof/vax.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 1983 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms are permitted - * provided that: (1) source distributions retain this entire copyright - * notice and comment, and (2) distributions including binaries display - * the following acknowledgement: ``This product includes software - * developed by the University of California, Berkeley and its contributors'' - * in the documentation or other materials provided with the distribution - * and in all advertising materials mentioning features or use of this - * software. Neither the name of the University nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * @(#)vax.h 5.4 (Berkeley) 6/1/90 - */ - - /* - * opcode of the `calls' instruction - */ -#define CALLS 0xfb - - /* - * offset (in bytes) of the code from the entry address of a routine. - * (see asgnsamples for use and explanation.) - */ -#define OFFSET_OF_CODE 2 -#define UNITS_TO_CODE (OFFSET_OF_CODE / sizeof(UNIT)) - - /* - * register for pc relative addressing - */ -#define PC 0xf - -enum opermodes { - literal, indexed, reg, regdef, autodec, autoinc, autoincdef, - bytedisp, bytedispdef, worddisp, worddispdef, longdisp, longdispdef, - immediate, absolute, byterel, bytereldef, wordrel, wordreldef, - longrel, longreldef -}; -typedef enum opermodes operandenum; - -struct modebyte { - unsigned int regfield:4; - unsigned int modefield:4; -}; - diff --git a/include/.Sanitize b/include/.Sanitize deleted file mode 100644 index e039c3d0453..00000000000 --- a/include/.Sanitize +++ /dev/null @@ -1,173 +0,0 @@ -# Sanitize.in for devo. -# $Id$ -# - -# Each directory to survive it's way into a release will need a file -# like this one called "./.Sanitize". All keyword lines must exist, -# and must exist in the order specified by this file. Each directory -# in the tree will be processed, top down, in the following order. - -# Hash started lines like this one are comments and will be deleted -# before anything else is done. Blank lines will also be squashed -# out. - -# The lines between the "Do-first:" line and the "Things-to-keep:" -# line are executed as a /bin/sh shell script before anything else is -# done in this - -Do-first: - -echo Sanitizing `pwd`... - -# All files listed between the "Things-to-keep:" line and the -# "Files-to-sed:" line will be kept. All other files will be removed. -# Directories listed in this section will have their own Sanitize -# called. Directories not listed will be removed in their entirety -# with rm -rf. - -Things-to-keep: - -COPYING -ChangeLog -a.out.encap.h -a.out.gnu.h -a.out.host.h -a.out.sun4.h -a29k-opcode.h -h8300-opcode.h -ansidecl.h -aout64.h -ar.h -arm-opcode.h -bcs88kcoff.h -bfd.h -bout.h -coff-a29k.h -coff-i386.h -coff-i960.h -coff-mips.h -coff-m68k.h -coff-m88k.h -coff-rs6000.h -convx-opcode.h -dwarf.h -elf-common.h -elf-external.h -elf-internal.h -gdbm.h -getopt.h -i386-opcode.h -i860-opcode.h -i960-opcode.h -ieee.h -m68k-opcode.h -internalcoff.h -m88k-opcode.h -mips-opcode.h -np1-opcode.h -ns32k-opcode.h -oasys.h -obstack.h -pn-opcode.h -pyr-opcode.h -ranlib.h -reloc.h -sparc-opcode.h -stab.def -stab.gnu.h -tahoe-opcode.h -vax-opcode.h -wait.h - -Do-last: - -v9dirty="sparc-opcode.h aout64.h" - -if ( echo $* | grep keep\-v9 > /dev/null ) ; then - echo Keeping v9 in ${v9dirty} -else - for i in ${v9dirty} ; do - echo Sanitizing v9 in $i - rm -f new - grep -v v9 $i > new - if [ -n "${safe}" ] ; then - mv $i .Recover - else - rm $i - fi - mv new $i - done -fi - -echo Done in `pwd`. - -# -# -# $Log$ -# Revision 1.20 1991/10/25 10:21:10 gnu -# Rename coff-related files. -# -# Revision 1.19 1991/10/25 07:59:50 gnu -# rs6000 -# -# Revision 1.18 1991/10/24 18:12:14 fnf -# Add "dwarf.h". -# -# Revision 1.17 1991/10/16 01:08:08 gnu -# Remove include files to bfd/hosts. -# -# Revision 1.16 1991/10/05 06:18:24 gnu -# a.out.vax.h gone. -# -# Revision 1.15 1991/10/03 22:24:27 gnu -# Add elf-*.h files. -# -# Revision 1.14 1991/09/26 22:46:53 steve -# Newly created -# -# Revision 1.13 1991/09/13 05:17:53 gnu -# Removes sparc-opcode.h rather than the file it is sanitizing, if not testing! -# (fixed...) -# -# Revision 1.12 1991/09/04 02:51:18 rich -# Adding "recover"'ability. -# -# Revision 1.11 1991/09/02 21:21:47 rich -# Recover the editted files. -# -# Revision 1.10 1991/08/29 00:34:45 gnu -# Paperwork handled for AMD Coff. -# -# Revision 1.9 1991/08/22 08:00:35 gnu -# Add ChangeLog for Include. -# -# Revision 1.8 1991/07/31 17:36:04 gnu -# Remove amdcoff.h by default because its copyright is not assigned to FSF. -# "Sanitize -keep-29k" will keep it. -# -# Revision 1.7 1991/07/31 03:11:46 gnu -# Remove symseg.h, the ancient GDB symbol-segments (gdb-specific debug -# information) definition. -# -# Revision 1.6 1991/07/24 01:07:25 gnu -# Add COPYING file. -# -# Revision 1.5 1991/07/24 00:47:13 gnu -# Blow away v9 stuff in aout64.h too. -# -# Revision 1.4 1991/07/15 23:34:14 steve -# *** empty log message *** -# -# Revision 1.3 1991/06/14 22:14:07 steve -# *** empty log message *** -# -# Revision 1.2 1991/05/31 11:26:52 gnu -# Add i386coff.h. Print msg when sanitizing sparc-opcode.h. -# -# Revision 1.1 1991/05/23 17:00:59 rich -# Initial revision -# -# -# - -# End of file. diff --git a/include/COPYING b/include/COPYING deleted file mode 100644 index a43ea2126fb..00000000000 --- a/include/COPYING +++ /dev/null @@ -1,339 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 675 Mass Ave, Cambridge, MA 02139, USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - Appendix: How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) 19yy - - 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., 675 Mass Ave, Cambridge, MA 02139, USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) 19yy name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/include/ChangeLog b/include/ChangeLog deleted file mode 100644 index 0ef71972ad0..00000000000 --- a/include/ChangeLog +++ /dev/null @@ -1,174 +0,0 @@ -Thu Nov 14 19:17:03 1991 Fred Fish (fnf at cygnus.com) - - * elf-common.h: Add defines to support ELF symbol table code. - -Mon Nov 11 19:01:06 1991 Fred Fish (fnf at cygnus.com) - - * elf-internal.h, elf-external.h, elf-common.h: Add support for - note sections, which are used in ELF core files to hold copies - of various /proc structures. - -Thu Nov 7 08:58:26 1991 Steve Chamberlain (sac at cygnus.com) - - * internalcoff.h: took out the M88 dependency in the lineno - struct. - * coff-m88k.h: defines GET_LINENO_LNNO and PUT_LINENO_LNNO to use - 32bit linno entries. - * a29k-opcode.h: fixed encoding of mtacc - -Sun Nov 3 11:54:22 1991 Per Bothner (bothner at cygnus.com) - - * bfd.h: Updated from ../bfd/bfd-in.h (q.v). - -Fri Nov 1 11:13:53 1991 John Gilmore (gnu at cygnus.com) - - * internalcoff.h: Add x_csect defines. - -Fri Oct 25 03:18:20 1991 John Gilmore (gnu at cygnus.com) - - * Rename COFF-related files in `coff-ARCH.h' form. - coff-a29k.h, coff-i386.h, coff-i960.h, coff-m68k.h, coff-m88k.h, - coff-mips.h, coff-rs6000.h to be exact. - -Thu Oct 24 22:11:11 1991 John Gilmore (gnu at cygnus.com) - - RS/6000 support, by Metin G. Ozisik, Mimi Phûông-Thåo Võ, and - John Gilmore. - - * a.out.gnu.h: Update slightly. - * bfd.h: Add new error code, fix doc, add bfd_arch_rs6000. - * internalcoff.h: Add more F_ codes for filehdr. Add - rs/6000-dependent fields to aouthdr. Add storage classes - to syments. Add 6000-specific auxent. Add r_size in reloc. - * rs6000coff.c: New file. - -Thu Oct 24 04:13:20 1991 Fred Fish (fnf at cygnus.com) - - * dwarf.h: New file for dwarf support. Copied from gcc2 - distribution. - -Wed Oct 16 13:31:45 1991 John Gilmore (gnu at cygnus.com) - - * aout64.h: Remove PAGE_SIZE defines; they are target-dependent. - Add N_FN_SEQ for N_FN symbol type used on Sequent machines. - * stab.def: Include N_FN_SEQ in table. - * bout.h: External formats of structures use unsigned chars. - -Fri Oct 11 12:40:43 1991 Steve Chamberlain (steve at cygnus.com) - - * bfd.h:upgrade from bfd.c - * internalcoff.h: add n_name, n_zeroes and n_offset macros - * amdcoff.h: Define OMAGIC and AOUTHDRSZ. - -Fri Oct 11 10:58:06 1991 Per Bothner (bothner at cygnus.com) - - * a.out.host.h: Change SEGMENT_SIZE to 0x1000 for Sony. - * bfd.h (align_power): Add (actually move) comment. - -Tue Oct 8 15:29:32 1991 Per Bothner (bothner at cygnus.com) - - * sys/h-rtbsd.h: Define MISSING_VFPRINT (for binutils/bucomm.c). - -Sun Oct 6 19:24:39 1991 John Gilmore (gnu at cygnus.com) - - * aout64.h: Move struct internal_exec to ../bfd/libaout.h so - it can be shared by all `a.out-family' code. Rename - EXTERNAL_LIST_SIZE to EXTERNAL_NLIST_SIZE. Use basic types - for nlist members, and make strx integral rather than pointer. - More commentary on n_type values. - * bout.h: Provide a struct external_exec rather than an - internal_exec. - * m68kcoff.h: Remove `tagentries' which snuck in from the i960 - COFF port. - -Fri Oct 4 01:25:59 1991 John Gilmore (gnu at cygnus.com) - - * h8300-opcode.h: Remove `_enum' from the typedef for an enum. - * bfd.h: Update to match bfd changes. - - * sys/h-i386mach.h, sysdep.h: Add 386 Mach host support. - -Tue Oct 1 04:58:42 1991 John Gilmore (gnu at cygnus.com) - - * bfd.h, elf-common.h, elf-external.h, elf-internal.h: - Add preliminary ELF support, sufficient for GDB, from Fred Fish. - * sysdep.h, sys/h-amix.h: Support Amiga SVR4. - - * sys/h-vaxult.h: Make it work. (David Taylor ) - * a.out.vax.h: Remove unused and confusing file. - -Mon Sep 30 12:52:35 1991 Per Bothner (bothner at cygnus.com) - - * sysdep.h: Define NEWSOS3_SYS, and use it. - -Fri Sep 20 13:38:21 1991 John Gilmore (gnu at cygnus.com) - - * a.out.gnu.h (N_FN): Its value *really is* 0x1F. - Fix it, and add comments warning about or-ing N_EXT with it - and/or N_WARNING. - * aout64.h (N_FN): Fix value, add comments about N_EXT. - * stab.def (table at end): Update to show all the type - values <0x20, including low order bits. Move N_FN to - its rightful place. - -Tue Sep 17 17:41:37 1991 Stu Grossman (grossman at cygnus.com) - - * sys/h-irix3.h: sgi/irix support. - -Tue Sep 17 07:52:59 1991 John Gilmore (gnu at cygint.cygnus.com) - - * stab.def (N_DEFD): Add GNU Modula-2 debug stab, from Andrew - Beers. - -Thu Sep 12 14:12:59 1991 John Gilmore (gnu at cygint.cygnus.com) - - * internalcoff.h (SYMNMLEN, FILNMLEN, DIMNUM): Define these - for internalcoff, separately from the various external coff's. - * amdcoff.h, bcs88kcoff.h, i386coff.h, intel-coff.h, m68kcoff.h, - m88k-bcs.h: Prefix SYMNMLEN, FILNMLEN, and DIMNUM with E_'s for - the external struct definitions. - * ecoff.h: Remove these #define's, kludge no longer needed. - - * sys/h-ultra3.h: Add new Ultracomputer host. - * sysdep.h: Add ULTRA3_SYM1_SYS and use it. - -Tue Sep 10 10:11:46 1991 John Gilmore (gnu at cygint.cygnus.com) - - * i386coff.h (LINESZ): Always 6, not based on sizeof(). - (Fix from Peter Schauer .) - -Wed Sep 4 08:58:37 1991 John Gilmore (gnu at cygint.cygnus.com) - - * a.out.gnu.h, aout64.h: Add N_WARNING. Change N_FN to 0x0E, - to match SunOS and BSD. Add N_COMM as 0x12 for SunOS shared lib - support. - * stab.def: Add N_COMM to table, fix overlap comment. - -Tue Sep 3 06:29:20 1991 John Gilmore (gnu at cygint.cygnus.com) - - Merge with latest FSF versions of these files. - - * stab.gnu.h: Add LAST_UNUSED_STAB_CODE. - * stab.def: Update to GPL2. Move N_WARNING out, since not a - debug symbol. Change comments, and reorder table to numeric - order. Update final table comment. - (N_DSLINE, N_BSLINE): Renumber from 0x66 and 0x68, to 0x46 and 0x48. - - * obstack.h: GPL2. Merge. - -Fri Aug 23 01:54:23 1991 John Gilmore (gnu at cygint.cygnus.com) - - * a.out.gnu.h, a.out.sun4.h: Make SEGMENT_SIZE able to depend - on the particular a.out being examined. - * a.out.sun4.h: Define segment sizes for Sun-3's and Sun-4's. - * FIXME: a.out.gnu.h is almost obsolete. - * FIXME: a.out.sun4.h should be renamed a.out.sun.h now. - -Wed Aug 21 20:32:13 1991 John Gilmore (gnu at cygint.cygnus.com) - - * Start a ChangeLog for the includes directory. - - * a.out.gnu.h (N_FN): Fix value -- was 15, should be 0x1E. - * stab.def: Update allocation table in comments at end, - to reflect reality as I know it. - diff --git a/include/a.out.encap.h b/include/a.out.encap.h deleted file mode 100755 index cebedf38336..00000000000 --- a/include/a.out.encap.h +++ /dev/null @@ -1,135 +0,0 @@ -/* Yet Another Try at encapsulating bsd object files in coff. - Copyright (C) 1988, 1989, 1991 Free Software Foundation, Inc. - Written by Pace Willisson 12/9/88 - - This file is obsolete. It needs to be converted to just define a bunch - of stuff that BFD can use to do coff-encapsulated files. --gnu@cygnus.com - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - * We only use the coff headers to tell the kernel - * how to exec the file. Therefore, the only fields that need to - * be filled in are the scnptr and vaddr for the text and data - * sections, and the vaddr for the bss. As far as coff is concerned, - * there is no symbol table, relocation, or line numbers. - * - * A normal bsd header (struct exec) is placed after the coff headers, - * and before the real text. I defined a the new fields 'a_machtype' - * and a_flags. If a_machtype is M_386, and a_flags & A_ENCAP is - * true, then the bsd header is preceeded by a coff header. Macros - * like N_TXTOFF and N_TXTADDR use this field to find the bsd header. - * - * The only problem is to track down the bsd exec header. The - * macros HEADER_OFFSET, etc do this. - */ - -#define N_FLAGS_COFF_ENCAPSULATE 0x20 /* coff header precedes bsd header */ - -/* Describe the COFF header used for encapsulation. */ - -struct coffheader -{ - /* filehdr */ - unsigned short f_magic; - unsigned short f_nscns; - long f_timdat; - long f_symptr; - long f_nsyms; - unsigned short f_opthdr; - unsigned short f_flags; - /* aouthdr */ - short magic; - short vstamp; - long tsize; - long dsize; - long bsize; - long entry; - long text_start; - long data_start; - struct coffscn - { - char s_name[8]; - long s_paddr; - long s_vaddr; - long s_size; - long s_scnptr; - long s_relptr; - long s_lnnoptr; - unsigned short s_nreloc; - unsigned short s_nlnno; - long s_flags; - } scns[3]; -}; - -/* Describe some of the parameters of the encapsulation, - including how to find the encapsulated BSD header. */ - -/* FIXME, this is dumb. The same tools can't handle a.outs for different - architectures, just because COFF_MAGIC is different; so you need a - separate GNU nm for every architecture!!? Unfortunately, it needs to - be this way, since the COFF_MAGIC value is determined by the kernel - we're trying to fool here. */ - -#define COFF_MAGIC_I386 0514 /* I386MAGIC */ -#define COFF_MAGIC_M68K 0520 /* MC68MAGIC */ -#define COFF_MAGIC_A29K 0x17A /* Used by asm29k cross-tools */ - -#ifdef COFF_MAGIC -short __header_offset_temp; -#define HEADER_OFFSET(f) \ - (__header_offset_temp = 0, \ - fread ((char *)&__header_offset_temp, sizeof (short), 1, (f)), \ - fseek ((f), -sizeof (short), 1), \ - __header_offset_temp==COFF_MAGIC ? sizeof(struct coffheader) : 0) -#else -#define HEADER_OFFSET(f) 0 -#endif - -#define HEADER_SEEK(f) (fseek ((f), HEADER_OFFSET((f)), 1)) - -/* Describe the characteristics of the BSD header - that appears inside the encapsulation. */ - -/* Encapsulated coff files that are linked ZMAGIC have a text segment - offset just past the header (and a matching TXTADDR), excluding - the headers from the text segment proper but keeping the physical - layout and the virtual memory layout page-aligned. - - Non-encapsulated a.out files that are linked ZMAGIC have a text - segment that starts at 0 and an N_TXTADR similarly offset to 0. - They too are page-aligned with each other, but they include the - a.out header as part of the text. - - The _N_HDROFF gets sizeof struct exec added to it, so we have - to compensate here. See . */ - -#undef _N_HDROFF -#undef N_TXTADDR -#undef N_DATADDR - -#define _N_HDROFF(x) ((N_FLAGS(x) & N_FLAGS_COFF_ENCAPSULATE) ? \ - sizeof (struct coffheader) : 0) - -/* Address of text segment in memory after it is loaded. */ -#define N_TXTADDR(x) \ - ((N_FLAGS(x) & N_FLAGS_COFF_ENCAPSULATE) ? \ - sizeof (struct coffheader) + sizeof (struct exec) : 0) -#define SEGMENT_SIZE 0x400000 - -#define N_DATADDR(x) \ - ((N_FLAGS(x) & N_FLAGS_COFF_ENCAPSULATE) ? \ - (SEGMENT_SIZE + ((N_TXTADDR(x)+(x).a_text-1) & ~(SEGMENT_SIZE-1))) : \ - (N_TXTADDR(x)+(x).a_text)) diff --git a/include/a.out.host.h b/include/a.out.host.h deleted file mode 100755 index 5d3488a62ec..00000000000 --- a/include/a.out.host.h +++ /dev/null @@ -1,22 +0,0 @@ -/* Parameters about the a.out format, based on the host system on which - the program is compiled. */ - -/* Address of data segment in memory after it is loaded. - It is up to you to define SEGMENT_SIZE - on machines not listed here. */ -#ifndef SEGMENT_SIZE -#if defined(hp300) || defined(pyr) -#define SEGMENT_SIZE page_size -#endif -#ifdef sony -#define SEGMENT_SIZE 0x1000 -#endif /* Sony. */ -#ifdef is68k -#define SEGMENT_SIZE 0x20000 -#endif -#if defined(m68k) && defined(PORTAR) -#define PAGE_SIZE 0x400 -#define SEGMENT_SIZE PAGE_SIZE -#endif -#endif /*!defined(SEGMENT_SIZE)*/ - diff --git a/include/a.out.hp.h b/include/a.out.hp.h deleted file mode 100755 index 4fdd0494c5d..00000000000 --- a/include/a.out.hp.h +++ /dev/null @@ -1,79 +0,0 @@ -/* Special version of for use under hp-ux. - Copyright (C) 1988 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* The `exec' structure and overall layout must be close to HP's when - we are running on an HP system, otherwise we will not be able to - execute the resulting file. */ - -/* Allow this file to be included twice. */ -#ifndef __GNU_EXEC_MACROS__ - -struct exec -{ - unsigned short a_machtype; /* machine type */ - unsigned short a_magic; /* magic number */ - unsigned long a_spare1; - unsigned long a_spare2; - unsigned long a_text; /* length of text, in bytes */ - unsigned long a_data; /* length of data, in bytes */ - unsigned long a_bss; /* length of uninitialized data area for file, in bytes */ - unsigned long a_trsize; /* length of relocation info for text, in bytes */ - unsigned long a_drsize; /* length of relocation info for data, in bytes */ - unsigned long a_spare3; /* HP = pascal interface size */ - unsigned long a_spare4; /* HP = symbol table size */ - unsigned long a_spare5; /* HP = debug name table size */ - unsigned long a_entry; /* start address */ - unsigned long a_spare6; /* HP = source line table size */ - unsigned long a_spare7; /* HP = value table size */ - unsigned long a_syms; /* length of symbol table data in file, in bytes */ - unsigned long a_spare8; -}; - -/* Tell a.out.gnu.h not to define `struct exec'. */ -#define __STRUCT_EXEC_OVERRIDE__ - -#include "../a.out.gnu.h" - -#undef N_MAGIC -#undef N_MACHTYPE -#undef N_FLAGS -#undef N_SET_INFO -#undef N_SET_MAGIC -#undef N_SET_MACHTYPE -#undef N_SET_FLAGS - -#define N_MAGIC(exec) ((exec) . a_magic) -#define N_MACHTYPE(exec) ((exec) . a_machtype) -#define N_SET_MAGIC(exec, magic) (((exec) . a_magic) = (magic)) -#define N_SET_MACHTYPE(exec, machtype) (((exec) . a_machtype) = (machtype)) - -#undef N_BADMAG -#define N_BADMAG(x) ((_N_BADMAG (x)) || (_N_BADMACH (x))) - -#define _N_BADMACH(x) \ -(((N_MACHTYPE (x)) != HP9000S200_ID) && \ - ((N_MACHTYPE (x)) != HP98x6_ID)) - -#define HP98x6_ID 0x20A -#define HP9000S200_ID 0x20C - -#undef _N_HDROFF -#define _N_HDROFF(x) (SEGMENT_SIZE - (sizeof (struct exec))) - -#define SEGMENT_SIZE 0x1000 - -#endif /* __GNU_EXEC_MACROS__ */ diff --git a/include/a.out.sun4.h b/include/a.out.sun4.h deleted file mode 100755 index 8d938b031d3..00000000000 --- a/include/a.out.sun4.h +++ /dev/null @@ -1,34 +0,0 @@ -/* SPARC-specific values for a.out files */ - -#define PAGE_SIZE 0x2000 /* 8K. aka NBPG in */ -/* Note that some SPARCs have 4K pages, some 8K, some others. */ - -#define SEG_SIZE_SPARC PAGE_SIZE -#define SEG_SIZE_SUN3 0x20000 /* Resolution of r/w protection hw */ - -#define TEXT_START_ADDR PAGE_SIZE /* Location 0 is not accessible */ - -/* Non-default definitions of the accessor macros... */ - -/* Segment size varies on Sun-3 versus Sun-4. */ - -#define N_SEGSIZE(x) (N_MACHTYPE(x) == M_SPARC? SEG_SIZE_SPARC: \ - N_MACHTYPE(x) == M_68020? SEG_SIZE_SUN3: \ - /* Guess? */ PAGE_SIZE) - -/* Offset in a.out file of the text section. For ZMAGIC, the text section - actually includes the a.out header. */ - -#define N_TXTOFF(x) ( (N_MAGIC((x)) == ZMAGIC) ? 0 : EXEC_BYTES_SIZE) - -/* Virtual Address of text segment from the a.out file. For OMAGIC, - (almost always "unlinked .o's" these days), should be zero. - Sun added a kludge so that shared libraries linked ZMAGIC get - an address of zero if a_entry (!!!) is lower than the otherwise - expected text address. These kludges have gotta go! - For linked files, should reflect reality if we know it. */ - -#define N_TXTADDR(x) \ - (N_MAGIC(x)==OMAGIC? 0 \ - : (N_MAGIC(x) == ZMAGIC && (x).a_entry < TEXT_START_ADDR)? 0 \ - : TEXT_START_ADDR) diff --git a/include/a.out.vax.h b/include/a.out.vax.h deleted file mode 100755 index 73118ff1626..00000000000 --- a/include/a.out.vax.h +++ /dev/null @@ -1,20 +0,0 @@ -/* VAX-specific definitions for a.out file header fields. */ - -#define PAGE_SIZE 512 /* aka NBPG in */ -#define SEGMENT_SIZE PAGE_SIZE /* rounding between text/data ? */ -#define TEXT_START_ADDR 0 /* Text start address: see - USRTEXT. */ -#define STACK_END_ADDR 0x80000000-(14+14)*PAGE_SIZE /* see - USRSTACK. */ - -#define N_BADMAG(x) \ - (N_MAGIC(x) != OMAGIC && N_MAGIC(x) != NMAGIC \ - && N_MAGIC(x) != ZMAGIC) - - -#define N_TXTOFF(x) ( (N_MAGIC((x)) == ZMAGIC) ? 1024 : EXEC_BYTES_SIZE ) -#define N_DATOFF(x) ( N_TXTOFF(x) + (x).a_text ) -#define N_TRELOFF(x) ( N_DATOFF(x) + (x).a_data ) -#define N_DRELOFF(x) ( N_TRELOFF(x) + (x).a_trsize ) -#define N_SYMOFF(x) ( N_DRELOFF(x) + (x).a_drsize ) -#define N_STROFF(x) ( N_SYMOFF(x) + (x).a_syms ) diff --git a/include/a29k-opcode.h b/include/a29k-opcode.h deleted file mode 100755 index ac37b494bea..00000000000 --- a/include/a29k-opcode.h +++ /dev/null @@ -1,317 +0,0 @@ -/* Table of opcodes for the AMD 29000 - Copyright (C) 1990, 1991 Free Software Foundation, Inc. - -This file is part of GDB and GAS. - -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 1, 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; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* $Id$ */ - -struct a29k_opcode { - /* Name of the instruction. */ - char *name; - - /* Opcode word */ - unsigned long opcode; - - /* A string of characters which describe the operands. - Valid characters are: - , Itself. The character appears in the assembly code. - a RA. The register number is in bits 8-15 of the instruction. - b RB. The register number is in bits 0-7 of the instruction. - c RC. The register number is in bits 16-23 of the instruction. - i An immediate operand is in bits 0-7 of the instruction. - x Bits 0-7 and 16-23 of the instruction are bits 0-7 and 8-15 - (respectively) of the immediate operand. - h Same as x but the instruction contains bits 16-31 of the - immediate operand. - X Same as x but bits 16-31 of the signed immediate operand - are set to 1 (thus the operand is always negative). - P,A Bits 0-7 and 16-23 of the instruction are bits 2-9 and 10-17 - (respectively) of the immediate operand. - P=PC-relative, sign-extended to 32 bits. - A=Absolute, zero-extended to 32 bits. - e CE bit (bit 23) for a load/store instruction. - n Control field (bits 16-22) for a load/store instruction. - v Immediate operand in bits 16-23 of the instruction. - (used for trap numbers). - s SA. Special-purpose register number in bits 8-15 - of the instruction. - u UI--bit 7 of the instruction. - r RND--bits 4-6 of the instruction. - d FD--bits 2-3 of the instruction. - f FS--bits 0-1 of the instruction. - - Extensions for 29050: - - d FMT--bits 2-3 of the instruction (not really new). - f ACN--bits 0-1 of the instruction (not really new). - F FUNC--Special function in bits 18-21 of the instruction. - C ACN--bits 16-17 specifying the accumlator register. */ - char *args; -}; - -#ifndef CONST -#define CONST -#endif /* CONST */ - -static CONST struct a29k_opcode a29k_opcodes[] = -{ - -{ "add", 0x14000000, "c,a,b" }, -{ "add", 0x15000000, "c,a,i" }, -{ "addc", 0x1c000000, "c,a,b" }, -{ "addc", 0x1d000000, "c,a,i" }, -{ "addcs", 0x18000000, "c,a,b" }, -{ "addcs", 0x19000000, "c,a,i" }, -{ "addcu", 0x1a000000, "c,a,b" }, -{ "addcu", 0x1b000000, "c,a,i" }, -{ "adds", 0x10000000, "c,a,b" }, -{ "adds", 0x11000000, "c,a,i" }, -{ "addu", 0x12000000, "c,a,b" }, -{ "addu", 0x13000000, "c,a,i" }, -{ "and", 0x90000000, "c,a,b" }, -{ "and", 0x91000000, "c,a,i" }, -{ "andn", 0x9c000000, "c,a,b" }, -{ "andn", 0x9d000000, "c,a,i" }, -{ "aseq", 0x70000000, "v,a,b" }, -{ "aseq", 0x71000000, "v,a,i" }, -{ "asge", 0x5c000000, "v,a,b" }, -{ "asge", 0x5d000000, "v,a,i" }, -{ "asgeu", 0x5e000000, "v,a,b" }, -{ "asgeu", 0x5f000000, "v,a,i" }, -{ "asgt", 0x58000000, "v,a,b" }, -{ "asgt", 0x59000000, "v,a,i" }, -{ "asgtu", 0x5a000000, "v,a,b" }, -{ "asgtu", 0x5b000000, "v,a,i" }, -{ "asle", 0x54000000, "v,a,b" }, -{ "asle", 0x55000000, "v,a,i" }, -{ "asleu", 0x56000000, "v,a,b" }, -{ "asleu", 0x57000000, "v,a,i" }, -{ "aslt", 0x50000000, "v,a,b" }, -{ "aslt", 0x51000000, "v,a,i" }, -{ "asltu", 0x52000000, "v,a,b" }, -{ "asltu", 0x53000000, "v,a,i" }, -{ "asneq", 0x72000000, "v,a,b" }, -{ "asneq", 0x73000000, "v,a,i" }, -{ "call", 0xa8000000, "a,P" }, -{ "call", 0xa9000000, "a,A" }, -{ "calli", 0xc8000000, "a,b" }, -{ "class", 0xe6000000, "c,a,f" }, -{ "clz", 0x08000000, "c,b" }, -{ "clz", 0x09000000, "c,i" }, -{ "const", 0x03000000, "a,x" }, -{ "consth", 0x02000000, "a,h" }, -{ "consthz", 0x05000000, "a,h" }, -{ "constn", 0x01000000, "a,X" }, -{ "convert", 0xe4000000, "c,a,u,r,d,f" }, -{ "cpbyte", 0x2e000000, "c,a,b" }, -{ "cpbyte", 0x2f000000, "c,a,i" }, -{ "cpeq", 0x60000000, "c,a,b" }, -{ "cpeq", 0x61000000, "c,a,i" }, -{ "cpge", 0x4c000000, "c,a,b" }, -{ "cpge", 0x4d000000, "c,a,i" }, -{ "cpgeu", 0x4e000000, "c,a,b" }, -{ "cpgeu", 0x4f000000, "c,a,i" }, -{ "cpgt", 0x48000000, "c,a,b" }, -{ "cpgt", 0x49000000, "c,a,i" }, -{ "cpgtu", 0x4a000000, "c,a,b" }, -{ "cpgtu", 0x4b000000, "c,a,i" }, -{ "cple", 0x44000000, "c,a,b" }, -{ "cple", 0x45000000, "c,a,i" }, -{ "cpleu", 0x46000000, "c,a,b" }, -{ "cpleu", 0x47000000, "c,a,i" }, -{ "cplt", 0x40000000, "c,a,b" }, -{ "cplt", 0x41000000, "c,a,i" }, -{ "cpltu", 0x42000000, "c,a,b" }, -{ "cpltu", 0x43000000, "c,a,i" }, -{ "cpneq", 0x62000000, "c,a,b" }, -{ "cpneq", 0x63000000, "c,a,i" }, -{ "dadd", 0xf1000000, "c,a,b" }, -{ "ddiv", 0xf7000000, "c,a,b" }, -{ "deq", 0xeb000000, "c,a,b" }, -{ "dge", 0xef000000, "c,a,b" }, -{ "dgt", 0xed000000, "c,a,b" }, -{ "div", 0x6a000000, "c,a,b" }, -{ "div", 0x6b000000, "c,a,i" }, -{ "div0", 0x68000000, "c,b" }, -{ "div0", 0x69000000, "c,i" }, -{ "divide", 0xe1000000, "c,a,b" }, -{ "dividu", 0xe3000000, "c,a,b" }, -{ "divl", 0x6c000000, "c,a,b" }, -{ "divl", 0x6d000000, "c,a,i" }, -{ "divrem", 0x6e000000, "c,a,b" }, -{ "divrem", 0x6f000000, "c,a,i" }, -{ "dmac", 0xd9000000, "F,C,a,b" }, -{ "dmsm", 0xdb000000, "c,a,b" }, -{ "dmul", 0xf5000000, "c,a,b" }, -{ "dsub", 0xf3000000, "c,a,b" }, -{ "emulate", 0xd7000000, "v,a,b" }, -{ "exbyte", 0x0a000000, "c,a,b" }, -{ "exbyte", 0x0b000000, "c,a,i" }, -{ "exhw", 0x7c000000, "c,a,b" }, -{ "exhw", 0x7d000000, "c,a,i" }, -{ "exhws", 0x7e000000, "c,a" }, -{ "extract", 0x7a000000, "c,a,b" }, -{ "extract", 0x7b000000, "c,a,i" }, -{ "fadd", 0xf0000000, "c,a,b" }, -{ "fdiv", 0xf6000000, "c,a,b" }, -{ "fdmul", 0xf9000000, "c,a,b" }, -{ "feq", 0xea000000, "c,a,b" }, -{ "fge", 0xee000000, "c,a,b" }, -{ "fgt", 0xec000000, "c,a,b" }, -{ "fmac", 0xd8000000, "F,C,a,b" }, -{ "fmsm", 0xda000000, "c,a,b" }, -{ "fmul", 0xf4000000, "c,a,b" }, -{ "fsub", 0xf2000000, "c,a,b" }, -{ "halt", 0x89000000, "" }, -{ "inbyte", 0x0c000000, "c,a,b" }, -{ "inbyte", 0x0d000000, "c,a,i" }, -{ "inhw", 0x78000000, "c,a,b" }, -{ "inhw", 0x79000000, "c,a,i" }, -{ "inv", 0x9f000000, "" }, -{ "iret", 0x88000000, "" }, -{ "iretinv", 0x8c000000, "" }, -{ "jmp", 0xa0000000, "P" }, -{ "jmp", 0xa1000000, "A" }, -{ "jmpf", 0xa4000000, "a,P" }, -{ "jmpf", 0xa5000000, "a,A" }, -{ "jmpfdec", 0xb4000000, "a,P" }, -{ "jmpfdec", 0xb5000000, "a,A" }, -{ "jmpfi", 0xc4000000, "a,b" }, -{ "jmpi", 0xc0000000, "b" }, -{ "jmpt", 0xac000000, "a,P" }, -{ "jmpt", 0xad000000, "a,A" }, -{ "jmpti", 0xcc000000, "a,b" }, -{ "load", 0x16000000, "e,n,a,b" }, -{ "load", 0x17000000, "e,n,a,i" }, -{ "loadl", 0x06000000, "e,n,a,b" }, -{ "loadl", 0x07000000, "e,n,a,i" }, -{ "loadm", 0x36000000, "e,n,a,b" }, -{ "loadm", 0x37000000, "e,n,a,i" }, -{ "loadset", 0x26000000, "e,n,a,b" }, -{ "loadset", 0x27000000, "e,n,a,i" }, -{ "mfacc", 0xe9000100, "c,d,f" }, -{ "mfsr", 0xc6000000, "c,s" }, -{ "mftlb", 0xb6000000, "c,a" }, -{ "mtacc", 0xe8010000, "a,d,f" }, -{ "mtsr", 0xce000000, "s,b" }, -{ "mtsrim", 0x04000000, "s,x" }, -{ "mttlb", 0xbe000000, "a,b" }, -{ "mul", 0x64000000, "c,a,b" }, -{ "mul", 0x65000000, "c,a,i" }, -{ "mull", 0x66000000, "c,a,b" }, -{ "mull", 0x67000000, "c,a,i" }, -{ "multiplu", 0xe2000000, "c,a,b" }, -{ "multiply", 0xe0000000, "c,a,b" }, -{ "multm", 0xde000000, "c,a,b" }, -{ "multmu", 0xdf000000, "c,a,b" }, -{ "mulu", 0x74000000, "c,a,b" }, -{ "mulu", 0x75000000, "c,a,i" }, -{ "nand", 0x9a000000, "c,a,b" }, -{ "nand", 0x9b000000, "c,a,i" }, -{ "nop", 0x70400101, "" }, -{ "nor", 0x98000000, "c,a,b" }, -{ "nor", 0x99000000, "c,a,i" }, -{ "or", 0x92000000, "c,a,b" }, -{ "or", 0x93000000, "c,a,i" }, -{ "orn", 0xaa000000, "c,a,b" }, -{ "orn", 0xab000000, "c,a,i" }, - -/* The description of "setip" in Chapter 8 ("instruction set") of the user's - manual claims that these are absolute register numbers. But section - 7.2.1 explains that they are not. The latter is correct, so print - these normally ("lr0", "lr5", etc.). */ -{ "setip", 0x9e000000, "c,a,b" }, - -{ "sll", 0x80000000, "c,a,b" }, -{ "sll", 0x81000000, "c,a,i" }, -{ "sqrt", 0xe5000000, "c,a,f" }, -{ "sra", 0x86000000, "c,a,b" }, -{ "sra", 0x87000000, "c,a,i" }, -{ "srl", 0x82000000, "c,a,b" }, -{ "srl", 0x83000000, "c,a,i" }, -{ "store", 0x1e000000, "e,n,a,b" }, -{ "store", 0x1f000000, "e,n,a,i" }, -{ "storel", 0x0e000000, "e,n,a,b" }, -{ "storel", 0x0f000000, "e,n,a,i" }, -{ "storem", 0x3e000000, "e,n,a,b" }, -{ "storem", 0x3f000000, "e,n,a,i" }, -{ "sub", 0x24000000, "c,a,b" }, -{ "sub", 0x25000000, "c,a,i" }, -{ "subc", 0x2c000000, "c,a,b" }, -{ "subc", 0x2d000000, "c,a,i" }, -{ "subcs", 0x28000000, "c,a,b" }, -{ "subcs", 0x29000000, "c,a,i" }, -{ "subcu", 0x2a000000, "c,a,b" }, -{ "subcu", 0x2b000000, "c,a,i" }, -{ "subr", 0x34000000, "c,a,b" }, -{ "subr", 0x35000000, "c,a,i" }, -{ "subrc", 0x3c000000, "c,a,b" }, -{ "subrc", 0x3d000000, "c,a,i" }, -{ "subrcs", 0x38000000, "c,a,b" }, -{ "subrcs", 0x39000000, "c,a,i" }, -{ "subrcu", 0x3a000000, "c,a,b" }, -{ "subrcu", 0x3b000000, "c,a,i" }, -{ "subrs", 0x30000000, "c,a,b" }, -{ "subrs", 0x31000000, "c,a,i" }, -{ "subru", 0x32000000, "c,a,b" }, -{ "subru", 0x33000000, "c,a,i" }, -{ "subs", 0x20000000, "c,a,b" }, -{ "subs", 0x21000000, "c,a,i" }, -{ "subu", 0x22000000, "c,a,b" }, -{ "subu", 0x23000000, "c,a,i" }, -{ "xnor", 0x96000000, "c,a,b" }, -{ "xnor", 0x97000000, "c,a,i" }, -{ "xor", 0x94000000, "c,a,b" }, -{ "xor", 0x95000000, "c,a,i" }, - -{ "", 0x0, "" } /* Dummy entry, not included in NUM_OPCODES. This - lets code examine entry i+1 without checking - if we've run off the end of the table. */ -}; - -CONST unsigned int num_opcodes = (((sizeof a29k_opcodes) / (sizeof a29k_opcodes[0])) - 1); - -/* - * $Log$ - * Revision 1.5 1991/11/07 16:59:19 sac - * Fixed encoding of mtacc instruction. - * - * Revision 1.4 1991/08/06 07:20:27 rich - * Fixing CONST declarations. - * - * Revision 1.3 1991/08/05 22:31:05 rich - * *** empty log message *** - * - * Revision 1.2 1991/07/15 23:34:04 steve - * *** empty log message *** - * - * Revision 1.1 1991/05/19 00:19:33 rich - * Initial revision - * - * Revision 1.1.1.1 1991/04/04 18:15:23 rich - * new gas main line - * - * Revision 1.1 1991/04/04 18:15:23 rich - * Initial revision - * - * Revision 1.2 1991/03/30 17:13:19 rich - * num_opcodes now unsigned. Also, added rcsid and log. - * - * - */ - -/* end of a29k-opcode.h */ diff --git a/include/aout64.h b/include/aout64.h deleted file mode 100755 index 97866e4a2c4..00000000000 --- a/include/aout64.h +++ /dev/null @@ -1,310 +0,0 @@ -/* `a.out' object-file definitions, including extensions to 64-bit fields */ - -#ifndef __A_OUT_64_H__ -#define __A_OUT_64_H__ - -/* This is the layout on disk of the 32-bit or 64-bit exec header. */ - -struct external_exec -{ - bfd_byte e_info[4]; /* magic number and stuff */ - bfd_byte e_text[BYTES_IN_WORD]; /* length of text section in bytes */ - bfd_byte e_data[BYTES_IN_WORD]; /* length of data section in bytes */ - bfd_byte e_bss[BYTES_IN_WORD]; /* length of bss area in bytes */ - bfd_byte e_syms[BYTES_IN_WORD]; /* length of symbol table in bytes */ - bfd_byte e_entry[BYTES_IN_WORD]; /* start address */ - bfd_byte e_trsize[BYTES_IN_WORD]; /* length of text relocation info */ - bfd_byte e_drsize[BYTES_IN_WORD]; /* length of data relocation info */ -}; - -#define EXEC_BYTES_SIZE (4 + BYTES_IN_WORD * 7) - -/* By default, segment size is constant. But on some machines, it can - be a function of the a.out header (e.g. machine type). */ -#ifndef N_SEGSIZE -#define N_SEGSIZE(x) SEGMENT_SIZE -#endif - -#define _N_HDROFF(x) (N_SEGSIZE(x) - EXEC_BYTES_SIZE) -/* address in an a.out of the text section. When demand paged, it's - set up a bit to make nothing at 0, when an object file it's 0. - There's a special hack case when the entry point is < TEXT_START_ADDR - for executables, then the real start is 0 -*/ - -#define N_TXTADDR(x) \ - (N_MAGIC(x)==OMAGIC? 0 \ - : (N_MAGIC(x) == ZMAGIC && (x).a_entry < TEXT_START_ADDR)? 0 \ - : TEXT_START_ADDR) - -/* offset in an a.out of the start of the text section. When demand - paged, this is the start of the file -*/ - -#define N_TXTOFF(x) ( (N_MAGIC((x)) == ZMAGIC) ? 0 : EXEC_BYTES_SIZE) -#if ARCH_SIZE==64 -#define OMAGIC 0x1001 /* Code indicating object file */ -#define ZMAGIC 0x1002 /* Code indicating demand-paged executable. */ -#define NMAGIC 0x1003 /* Code indicating pure executable. */ -#else -#define OMAGIC 0407 /* Code indicating object file or impure executable. */ -#define NMAGIC 0410 /* Code indicating pure executable. */ -#define ZMAGIC 0413 /* Code indicating demand-paged executable. */ -#endif - -#define N_BADMAG(x) (N_MAGIC(x) != OMAGIC \ - && N_MAGIC(x) != NMAGIC \ - && N_MAGIC(x) != ZMAGIC) - - - -#define N_DATADDR(x) \ - (N_MAGIC(x)==OMAGIC? (N_TXTADDR(x)+(x).a_text) \ - : (N_SEGSIZE(x) + ((N_TXTADDR(x)+(x).a_text-1) & ~(N_SEGSIZE(x)-1)))) - -#define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data) - - -#define N_DATOFF(x) ( N_TXTOFF(x) + (x).a_text ) -#define N_TRELOFF(x) ( N_DATOFF(x) + (x).a_data ) -#define N_DRELOFF(x) ( N_TRELOFF(x) + (x).a_trsize ) -#define N_SYMOFF(x) ( N_DRELOFF(x) + (x).a_drsize ) -#define N_STROFF(x) ( N_SYMOFF(x) + (x).a_syms ) - - -/* Symbols */ -struct external_nlist { - bfd_byte e_strx[BYTES_IN_WORD]; /* index into string table of name */ - bfd_byte e_type[1]; /* type of symbol */ - bfd_byte e_other[1]; /* misc info (usually empty) */ - bfd_byte e_desc[2]; /* description field */ - bfd_byte e_value[BYTES_IN_WORD]; /* value of symbol */ -}; - -#define EXTERNAL_NLIST_SIZE (BYTES_IN_WORD+4+BYTES_IN_WORD) - -struct internal_nlist { - unsigned long n_strx; /* index into string table of name */ - unsigned char n_type; /* type of symbol */ - unsigned char n_other; /* misc info (usually empty) */ - unsigned short n_desc; /* description field */ - bfd_vma n_value; /* value of symbol */ -}; - -/* The n_type field is the symbol type, containing: */ - -#define N_UNDF 0 /* Undefined symbol */ -#define N_ABS 2 /* Absolute symbol -- defined at particular addr */ -#define N_TEXT 4 /* Text sym -- defined at offset in text seg */ -#define N_DATA 6 /* Data sym -- defined at offset in data seg */ -#define N_BSS 8 /* BSS sym -- defined at offset in zero'd seg */ -#define N_COMM 0x12 /* Common symbol (visible after shared lib dynlink) */ -#define N_FN 0x1f /* File name of .o file */ -#define N_FN_SEQ 0x0C /* N_FN from Sequent compilers (sigh) */ -/* Note: N_EXT can only be usefully OR-ed with N_UNDF, N_ABS, N_TEXT, - N_DATA, or N_BSS. When the low-order bit of other types is set, - (e.g. N_WARNING versus N_FN), they are two different types. */ -#define N_EXT 1 /* External symbol (as opposed to local-to-this-file) */ -#define N_TYPE 0x1e -#define N_STAB 0xe0 /* If any of these bits are on, it's a debug symbol */ - -#define N_INDR 0x0a - -/* The following symbols refer to set elements. - All the N_SET[ATDB] symbols with the same name form one set. - Space is allocated for the set in the text section, and each set - elements value is stored into one word of the space. - The first word of the space is the length of the set (number of elements). - - The address of the set is made into an N_SETV symbol - whose name is the same as the name of the set. - This symbol acts like a N_DATA global symbol - in that it can satisfy undefined external references. */ - -/* These appear as input to LD, in a .o file. */ -#define N_SETA 0x14 /* Absolute set element symbol */ -#define N_SETT 0x16 /* Text set element symbol */ -#define N_SETD 0x18 /* Data set element symbol */ -#define N_SETB 0x1A /* Bss set element symbol */ - -/* This is output from LD. */ -#define N_SETV 0x1C /* Pointer to set vector in data area. */ - -/* Warning symbol. The text gives a warning message, the next symbol - in the table will be undefined. When the symbol is referenced, the - message is printed. */ - -#define N_WARNING 0x1e - -/* Relocations - - There are two types of relocation flavours for a.out systems, - standard and extended. The standard form is used on systems where the - instruction has room for all the bits of an offset to the operand, whilst - the extended form is used when an address operand has to be split over n - instructions. Eg, on the 68k, each move instruction can reference - the target with a displacement of 16 or 32 bits. On the sparc, move - instructions use an offset of 14 bits, so the offset is stored in - the reloc field, and the data in the section is ignored. -*/ - -/* This structure describes a single relocation to be performed. - The text-relocation section of the file is a vector of these structures, - all of which apply to the text section. - Likewise, the data-relocation section applies to the data section. */ - -struct reloc_std_external { - bfd_byte r_address[BYTES_IN_WORD]; /* offset of of data to relocate */ - bfd_byte r_index[3]; /* symbol table index of symbol */ - bfd_byte r_type[1]; /* relocation type */ -}; - -#define RELOC_STD_BITS_PCREL_BIG 0x80 -#define RELOC_STD_BITS_PCREL_LITTLE 0x01 - -#define RELOC_STD_BITS_LENGTH_BIG 0x60 -#define RELOC_STD_BITS_LENGTH_SH_BIG 5 /* To shift to units place */ -#define RELOC_STD_BITS_LENGTH_LITTLE 0x06 -#define RELOC_STD_BITS_LENGTH_SH_LITTLE 1 - -#define RELOC_STD_BITS_EXTERN_BIG 0x10 -#define RELOC_STD_BITS_EXTERN_LITTLE 0x08 - -#define RELOC_STD_BITS_BASEREL_BIG 0x08 -#define RELOC_STD_BITS_BASEREL_LITTLE 0x08 - -#define RELOC_STD_BITS_JMPTABLE_BIG 0x04 -#define RELOC_STD_BITS_JMPTABLE_LITTLE 0x04 - -#define RELOC_STD_BITS_RELATIVE_BIG 0x02 -#define RELOC_STD_BITS_RELATIVE_LITTLE 0x02 - -#define RELOC_STD_SIZE (BYTES_IN_WORD + 3 + 1) /* Bytes per relocation entry */ - -struct reloc_std_internal -{ - bfd_vma r_address; /* Address (within segment) to be relocated. */ - /* The meaning of r_symbolnum depends on r_extern. */ - unsigned int r_symbolnum:24; - /* Nonzero means value is a pc-relative offset - and it should be relocated for changes in its own address - as well as for changes in the symbol or section specified. */ - unsigned int r_pcrel:1; - /* Length (as exponent of 2) of the field to be relocated. - Thus, a value of 2 indicates 1<<2 bytes. */ - unsigned int r_length:2; - /* 1 => relocate with value of symbol. - r_symbolnum is the index of the symbol - in files the symbol table. - 0 => relocate with the address of a segment. - r_symbolnum is N_TEXT, N_DATA, N_BSS or N_ABS - (the N_EXT bit may be set also, but signifies nothing). */ - unsigned int r_extern:1; - /* The next three bits are for SunOS shared libraries, and seem to - be undocumented. */ - unsigned int r_baserel:1; /* Linkage table relative */ - unsigned int r_jmptable:1; /* pc-relative to jump table */ - unsigned int r_relative:1; /* "relative relocation" */ - /* unused */ - unsigned int r_pad:1; /* Padding -- set to zero */ -}; - - -/* EXTENDED RELOCS */ - -struct reloc_ext_external { - bfd_byte r_address[BYTES_IN_WORD]; /* offset of of data to relocate */ - bfd_byte r_index[3]; /* symbol table index of symbol */ - bfd_byte r_type[1]; /* relocation type */ - bfd_byte r_addend[BYTES_IN_WORD]; /* datum addend */ -}; - -#define RELOC_EXT_BITS_EXTERN_BIG 0x80 -#define RELOC_EXT_BITS_EXTERN_LITTLE 0x01 - -#define RELOC_EXT_BITS_TYPE_BIG 0x1F -#define RELOC_EXT_BITS_TYPE_SH_BIG 0 -#define RELOC_EXT_BITS_TYPE_LITTLE 0xF8 -#define RELOC_EXT_BITS_TYPE_SH_LITTLE 3 - -/* Bytes per relocation entry */ -#define RELOC_EXT_SIZE (BYTES_IN_WORD + 3 + 1 + BYTES_IN_WORD) - -enum reloc_type -{ - /* simple relocations */ - RELOC_8, /* data[0:7] = addend + sv */ - RELOC_16, /* data[0:15] = addend + sv */ - RELOC_32, /* data[0:31] = addend + sv */ - /* pc-rel displacement */ - RELOC_DISP8, /* data[0:7] = addend - pc + sv */ - RELOC_DISP16, /* data[0:15] = addend - pc + sv */ - RELOC_DISP32, /* data[0:31] = addend - pc + sv */ - /* Special */ - RELOC_WDISP30, /* data[0:29] = (addend + sv - pc)>>2 */ - RELOC_WDISP22, /* data[0:21] = (addend + sv - pc)>>2 */ - RELOC_HI22, /* data[0:21] = (addend + sv)>>10 */ - RELOC_22, /* data[0:21] = (addend + sv) */ - RELOC_13, /* data[0:12] = (addend + sv) */ - RELOC_LO10, /* data[0:9] = (addend + sv) */ - RELOC_SFA_BASE, - RELOC_SFA_OFF13, - /* P.I.C. (base-relative) */ - RELOC_BASE10, /* Not sure - maybe we can do this the */ - RELOC_BASE13, /* right way now */ - RELOC_BASE22, - /* for some sort of pc-rel P.I.C. (?) */ - RELOC_PC10, - RELOC_PC22, - /* P.I.C. jump table */ - RELOC_JMP_TBL, - /* reputedly for shared libraries somehow */ - RELOC_SEGOFF16, - RELOC_GLOB_DAT, - RELOC_JMP_SLOT, - RELOC_RELATIVE, - - RELOC_11, - RELOC_WDISP2_14, - RELOC_WDISP19, - RELOC_HHI22, /* data[0:21] = (addend + sv) >> 42 */ - RELOC_HLO10, /* data[0:9] = (addend + sv) >> 32 */ - - /* 29K relocation types */ - RELOC_JUMPTARG, - RELOC_CONST, - RELOC_CONSTH, - - /* All the new ones I can think of *//*v9*/ - - RELOC_64, /* data[0:63] = addend + sv *//*v9*/ - RELOC_DISP64, /* data[0:63] = addend - pc + sv *//*v9*/ - RELOC_WDISP21, /* data[0:20] = (addend + sv - pc)>>2 *//*v9*/ - RELOC_DISP21, /* data[0:20] = addend - pc + sv *//*v9*/ - RELOC_DISP14, /* data[0:13] = addend - pc + sv *//*v9*/ - /* Q . - What are the other ones, - Since this is a clean slate, can we throw away the ones we dont - understand ? Should we sort the values ? What about using a - microcode format like the 68k ? - */ - NO_RELOC - }; - - -struct reloc_internal { - bfd_vma r_address; /* offset of of data to relocate */ - long r_index; /* symbol table index of symbol */ - enum reloc_type r_type; /* relocation type */ - bfd_vma r_addend; /* datum addend */ -}; - -/* Q. - Should the length of the string table be 4 bytes or 8 bytes ? - - Q. - What about archive indexes ? - - */ - -#endif /* __A_OUT_64_H__ */ diff --git a/include/ar.h b/include/ar.h deleted file mode 100755 index 2bca46d1f32..00000000000 --- a/include/ar.h +++ /dev/null @@ -1,24 +0,0 @@ -/* archive file definition for GNU software */ - -/* So far this is correct for BSDish archives. Don't forget that - files must begin on an even byte boundary. */ - -#ifndef __GNU_AR_H__ -#define __GNU_AR_H__ - -#define ARMAG "!\n" /* For COFF and a.out archives */ -#define ARMAGB "!\n" /* For b.out archives */ -#define SARMAG 8 -#define ARFMAG "`\n" - -struct ar_hdr { - char ar_name[16]; /* name of this member */ - char ar_date[12]; /* file mtime */ - char ar_uid[6]; /* owner uid; printed as decimal */ - char ar_gid[6]; /* owner gid; printed as decimal */ - char ar_mode[8]; /* file mode, printed as octal */ - char ar_size[10]; /* file size, printed as decimal */ - char ar_fmag[2]; /* should contain ARFMAG */ -}; - -#endif /* __GNU_AR_H__ */ diff --git a/include/arm-opcode.h b/include/arm-opcode.h deleted file mode 100755 index d968e6ef8fd..00000000000 --- a/include/arm-opcode.h +++ /dev/null @@ -1,294 +0,0 @@ -/* ARM opcode list. - Copyright (C) 1989, Free Software Foundation, Inc. - -This file is part of GDB and GAS. - -GDB and GAS are 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 1, or (at your option) -any later version. - -GDB and GAS are 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 GDB or GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* types of instruction (encoded in bits 26 and 27 of the instruction) */ - -#define TYPE_ARITHMETIC 0 -#define TYPE_LDR_STR 1 -#define TYPE_BLOCK_BRANCH 2 -#define TYPE_SWI 3 - -/* bit 25 decides whether an instruction is a block move or a branch */ -#define SUBTYPE_BLOCK 0 -#define SUBTYPE_BRANCH 1 - -/* codes to distinguish the arithmetic instructions */ - -#define OPCODE_AND 0 -#define OPCODE_EOR 1 -#define OPCODE_SUB 2 -#define OPCODE_RSB 3 -#define OPCODE_ADD 4 -#define OPCODE_ADC 5 -#define OPCODE_SBC 6 -#define OPCODE_RSC 7 -#define OPCODE_TST 8 -#define OPCODE_TEQ 9 -#define OPCODE_CMP 10 -#define OPCODE_CMN 11 -#define OPCODE_ORR 12 -#define OPCODE_MOV 13 -#define OPCODE_BIC 14 -#define OPCODE_MVN 15 - -/* condition codes */ - -#define COND_EQ 0 -#define COND_NE 1 -#define COND_CS 2 -#define COND_CC 3 -#define COND_MI 4 -#define COND_PL 5 -#define COND_VS 6 -#define COND_VC 7 -#define COND_HI 8 -#define COND_LS 9 -#define COND_GE 10 -#define COND_LT 11 -#define COND_GT 12 -#define COND_LE 13 -#define COND_AL 14 -#define COND_NV 15 - -/* Describes the format of an ARM machine instruction */ - -struct generic_fmt { - unsigned rest :25; /* the rest of the instruction */ - unsigned subtype :1; /* used to decide between block and branch */ - unsigned type :2; /* one of TYPE_* */ - unsigned cond :4; /* one of COND_* defined above */ -}; - -struct arith_fmt { - unsigned operand2 :12; /* #nn or rn or rn shift #m or rn shift rm */ - unsigned dest :4; /* place where the answer goes */ - unsigned operand1 :4; /* first operand to instruction */ - unsigned set :1; /* == 1 means set processor flags */ - unsigned opcode :4; /* one of OPCODE_* defined above */ - unsigned immed :1; /* operand2 is an immediate value */ - unsigned type :2; /* == TYPE_ARITHMETIC */ - unsigned cond :4; /* one of COND_* defined above */ -}; - -struct ldr_str_fmt { - unsigned offset :12; /* #nn or rn or rn shift #m */ - unsigned reg :4; /* destination for LDR, source for STR */ - unsigned base :4; /* base register */ - unsigned is_load :1; /* == 1 for LDR */ - unsigned writeback :1; /* == 1 means write back (base+offset) into base */ - unsigned byte :1; /* == 1 means byte access else word */ - unsigned up :1; /* == 1 means add offset else subtract it */ - unsigned pre_index :1; /* == 1 means [a,b] form else [a],b form */ - unsigned immed :1; /* == 0 means immediate offset */ - unsigned type :2; /* == TYPE_LDR_STR */ - unsigned cond :4; /* one of COND_* defined above */ -}; - -struct block_fmt { - unsigned mask :16; /* register mask */ - unsigned base :4; /* register used as base of move */ - unsigned is_load :1; /* == 1 for LDM */ - unsigned writeback :1; /* == 1 means update base after move */ - unsigned set :1; /* == 1 means set flags in pc if included in mask */ - unsigned increment :1; /* == 1 means increment base register */ - unsigned before :1; /* == 1 means inc/dec before each move */ - unsigned is_block :1; /* == SUBTYPE_BLOCK */ - unsigned type :2; /* == TYPE_BLOCK_BRANCH */ - unsigned cond :4; /* one of COND_* defined above */ -}; - -struct branch_fmt { - unsigned dest :24; /* destination of the branch */ - unsigned link :1; /* branch with link (function call) */ - unsigned is_branch :1; /* == SUBTYPE_BRANCH */ - unsigned type :2; /* == TYPE_BLOCK_BRANCH */ - unsigned cond :4; /* one of COND_* defined above */ -}; - -#define ROUND_N 0 -#define ROUND_P 1 -#define ROUND_M 2 -#define ROUND_Z 3 - -#define FLOAT2_MVF 0 -#define FLOAT2_MNF 1 -#define FLOAT2_ABS 2 -#define FLOAT2_RND 3 -#define FLOAT2_SQT 4 -#define FLOAT2_LOG 5 -#define FLOAT2_LGN 6 -#define FLOAT2_EXP 7 -#define FLOAT2_SIN 8 -#define FLOAT2_COS 9 -#define FLOAT2_TAN 10 -#define FLOAT2_ASN 11 -#define FLOAT2_ACS 12 -#define FLOAT2_ATN 13 - -#define FLOAT3_ADF 0 -#define FLOAT3_MUF 1 -#define FLOAT3_SUF 2 -#define FLOAT3_RSF 3 -#define FLOAT3_DVF 4 -#define FLOAT3_RDF 5 -#define FLOAT3_POW 6 -#define FLOAT3_RPW 7 -#define FLOAT3_RMF 8 -#define FLOAT3_FML 9 -#define FLOAT3_FDV 10 -#define FLOAT3_FRD 11 -#define FLOAT3_POL 12 - -struct float2_fmt { - unsigned operand2 :3; /* second operand */ - unsigned immed :1; /* == 1 if second operand is a constant */ - unsigned pad1 :1; /* == 0 */ - unsigned rounding :2; /* ROUND_* */ - unsigned is_double :1; /* == 1 if precision is double (only if not extended) */ - unsigned pad2 :4; /* == 1 */ - unsigned dest :3; /* destination */ - unsigned is_2_op :1; /* == 1 if 2 operand ins */ - unsigned operand1 :3; /* first operand (only of is_2_op == 0) */ - unsigned is_extended :1; /* == 1 if precision is extended */ - unsigned opcode :4; /* FLOAT2_* or FLOAT3_* depending on is_2_op */ - unsigned must_be_2 :2; /* == 2 */ - unsigned type :2; /* == TYPE_SWI */ - unsigned cond :4; /* COND_* */ -}; - -struct swi_fmt { - unsigned argument :24; /* argument to SWI (syscall number) */ - unsigned must_be_3 :2; /* == 3 */ - unsigned type :2; /* == TYPE_SWI */ - unsigned cond :4; /* one of COND_* defined above */ -}; - -union insn_fmt { - struct generic_fmt generic; - struct arith_fmt arith; - struct ldr_str_fmt ldr_str; - struct block_fmt block; - struct branch_fmt branch; - struct swi_fmt swi; - unsigned long ins; -}; - -struct opcode { - unsigned long value, mask; /* recognise instruction if (op&mask)==value */ - char *assembler; /* how to disassemble this instruction */ -}; - -/* format of the assembler string : - - %% % - %d print the bitfield in decimal - %x print the bitfield in hex - %r print as an ARM register - %f print a floating point constant if >7 else an fp register - %c print condition code (always bits 28-31) - %P print floating point precision in arithmetic insn - %Q print floating point precision in ldf/stf insn - %R print floating point rounding mode - %'c print specified char iff bit is one - %`c print specified char iff bit is zero - %?ab print a if bit is one else print b - %p print 'p' iff bits 12-15 are 15 - %o print operand2 (immediate or register + shift) - %a print address for ldr/str instruction - %b print branch destination - %A print address for ldc/stc/ldf/stf instruction - %m print register mask for ldm/stm instruction -*/ - -static struct opcode opcodes[] = { - /* ARM instructions */ - 0x00000090, 0x0fe000f0, "mul%20's %12-15r, %16-19r, %0-3r", - 0x00200090, 0x0fe000f0, "mla%20's %12-15r, %16-19r, %0-3r, %8-11r", - 0x00000000, 0x0de00000, "and%c%20's %12-15r, %16-19r, %o", - 0x00200000, 0x0de00000, "eor%c%20's %12-15r, %16-19r, %o", - 0x00400000, 0x0de00000, "sub%c%20's %12-15r, %16-19r, %o", - 0x00600000, 0x0de00000, "rsb%c%20's %12-15r, %16-19r, %o", - 0x00800000, 0x0de00000, "add%c%20's %12-15r, %16-19r, %o", - 0x00a00000, 0x0de00000, "adc%c%20's %12-15r, %16-19r, %o", - 0x00c00000, 0x0de00000, "sbc%c%20's %12-15r, %16-19r, %o", - 0x00e00000, 0x0de00000, "rsc%c%20's %12-15r, %16-19r, %o", - 0x01000000, 0x0de00000, "tst%c%p %16-19r, %o", - 0x01200000, 0x0de00000, "teq%c%p %16-19r, %o", - 0x01400000, 0x0de00000, "cmp%c%p %16-19r, %o", - 0x01600000, 0x0de00000, "cmn%c%p %16-19r, %o", - 0x01800000, 0x0de00000, "orr%c%20's %12-15r, %16-19r, %o", - 0x01a00000, 0x0de00000, "mov%c%20's %12-15r, %o", - 0x01c00000, 0x0de00000, "bic%c%20's %12-15r, %16-19r, %o", - 0x01e00000, 0x0de00000, "mvn%c%20's %12-15r, %o", - 0x04000000, 0x0c100000, "str%c%22'b %12-15r, %a", - 0x04100000, 0x0c100000, "ldr%c%22'b %12-15r, %a", - 0x08000000, 0x0e100000, "stm%c%23?id%24?ba %16-19r%22`!, %m", - 0x08100000, 0x0e100000, "ldm%c%23?id%24?ba %16-19r%22`!, %m%22'^", - 0x0a000000, 0x0e000000, "b%c%24'l %b", - 0x0f000000, 0x0f000000, "swi%c %0-23x", - /* Floating point coprocessor instructions */ - 0x0e000100, 0x0ff08f10, "adf%c%P%R %12-14f, %16-18f, %0-3f", - 0x0e100100, 0x0ff08f10, "muf%c%P%R %12-14f, %16-18f, %0-3f", - 0x0e200100, 0x0ff08f10, "suf%c%P%R %12-14f, %16-18f, %0-3f", - 0x0e300100, 0x0ff08f10, "rsf%c%P%R %12-14f, %16-18f, %0-3f", - 0x0e400100, 0x0ff08f10, "dvf%c%P%R %12-14f, %16-18f, %0-3f", - 0x0e500100, 0x0ff08f10, "rdf%c%P%R %12-14f, %16-18f, %0-3f", - 0x0e600100, 0x0ff08f10, "pow%c%P%R %12-14f, %16-18f, %0-3f", - 0x0e700100, 0x0ff08f10, "rpw%c%P%R %12-14f, %16-18f, %0-3f", - 0x0e800100, 0x0ff08f10, "rmf%c%P%R %12-14f, %16-18f, %0-3f", - 0x0e900100, 0x0ff08f10, "fml%c%P%R %12-14f, %16-18f, %0-3f", - 0x0ea00100, 0x0ff08f10, "fdv%c%P%R %12-14f, %16-18f, %0-3f", - 0x0eb00100, 0x0ff08f10, "frd%c%P%R %12-14f, %16-18f, %0-3f", - 0x0ec00100, 0x0ff08f10, "pol%c%P%R %12-14f, %16-18f, %0-3f", - 0x0e008100, 0x0ff08f10, "mvf%c%P%R %12-14f, %0-3f", - 0x0e108100, 0x0ff08f10, "mnf%c%P%R %12-14f, %0-3f", - 0x0e208100, 0x0ff08f10, "abs%c%P%R %12-14f, %0-3f", - 0x0e308100, 0x0ff08f10, "rnd%c%P%R %12-14f, %0-3f", - 0x0e408100, 0x0ff08f10, "sqt%c%P%R %12-14f, %0-3f", - 0x0e508100, 0x0ff08f10, "log%c%P%R %12-14f, %0-3f", - 0x0e608100, 0x0ff08f10, "lgn%c%P%R %12-14f, %0-3f", - 0x0e708100, 0x0ff08f10, "exp%c%P%R %12-14f, %0-3f", - 0x0e808100, 0x0ff08f10, "sin%c%P%R %12-14f, %0-3f", - 0x0e908100, 0x0ff08f10, "cos%c%P%R %12-14f, %0-3f", - 0x0ea08100, 0x0ff08f10, "tan%c%P%R %12-14f, %0-3f", - 0x0eb08100, 0x0ff08f10, "asn%c%P%R %12-14f, %0-3f", - 0x0ec08100, 0x0ff08f10, "acs%c%P%R %12-14f, %0-3f", - 0x0ed08100, 0x0ff08f10, "atn%c%P%R %12-14f, %0-3f", - 0x0e000110, 0x0ff00f1f, "flt%c%P%R %16-18f, %12-15r", - 0x0e100110, 0x0fff0f98, "fix%c%R %12-15r, %0-2f", - 0x0e200110, 0x0fff0fff, "wfs%c %12-15r", - 0x0e300110, 0x0fff0fff, "rfs%c %12-15r", - 0x0e400110, 0x0fff0fff, "wfc%c %12-15r", - 0x0e500110, 0x0fff0fff, "rfc%c %12-15r", - 0x0e90f110, 0x0ff8fff0, "cmf%c %16-18f, %0-3f", - 0x0eb0f110, 0x0ff8fff0, "cnf%c %16-18f, %0-3f", - 0x0ed0f110, 0x0ff8fff0, "cmfe%c %16-18f, %0-3f", - 0x0ef0f110, 0x0ff8fff0, "cnfe%c %16-18f, %0-3f", - 0x0c000100, 0x0e100f00, "stf%c%Q %12-14f, %A", - 0x0c100100, 0x0e100f00, "ldf%c%Q %12-14f, %A", - /* Generic coprocessor instructions */ - 0x0e000000, 0x0f000010, "cdp%c %8-11d, %20-23d, cr%12-15d, cr%16-19d, cr%0-3d, {%5-7d}", - 0x0e000010, 0x0f100010, "mrc%c %8-11d, %21-23d, %12-15r, cr%16-19d, cr%0-3d, {%5-7d}", - 0x0e100010, 0x0f100010, "mcr%c %8-11d, %21-23d, %12-15r, cr%16-19d, cr%0-3d, {%5-7d}", - 0x0c000000, 0x0e100000, "stc%c%22`l %8-11d, cr%12-15d, %A", - 0x0c100000, 0x0e100000, "ldc%c%22`l %8-11d, cr%12-15d, %A", - /* the rest */ - 0x00000000, 0x00000000, "undefined instruction %0-31x", -}; -#define N_OPCODES (sizeof opcodes / sizeof opcodes[0]) diff --git a/include/bcs88kcoff.h b/include/bcs88kcoff.h deleted file mode 100755 index bc8df2d8dbe..00000000000 --- a/include/bcs88kcoff.h +++ /dev/null @@ -1,300 +0,0 @@ -/*** coff information for 88k bcs */ - -#ifndef M88 -#define M88 -#endif - -/********************** FILE HEADER **********************/ - -struct filehdr { - unsigned short f_magic; /* magic number */ - unsigned short f_nscns; /* number of sections */ - long f_timdat; /* time & date stamp */ - long f_symptr; /* file pointer to symtab */ - long f_nsyms; /* number of symtab entries */ - unsigned short f_opthdr; /* sizeof(optional hdr) */ - unsigned short f_flags; /* flags */ -}; - -/* Bits for f_flags: - * F_RELFLG relocation info stripped from file - * F_EXEC file is executable (no unresolved externel references) - * F_LNNO line nunbers stripped from file - * F_LSYMS local symbols stripped from file - * F_AR32WR file has byte ordering of an AR32WR machine (e.g. vax) - */ -#define F_RELFLG 0000001 -#define F_EXEC 0000002 -#define F_LNNO 0000004 -#define F_LSYMS 0000010 -#define F_AR32WR 0000400 - - -#define MC88MAGIC 0555 /* 88k BCS executable */ -#define MC88DMAGIC 0541 /* DG/UX executable */ - - -#define MC88BADMAG(x) (((x).f_magic!=MC88MAGIC) && ((x).f_magic!=MC88DMAGIC)) - -#define FILHDR struct filehdr -#define FILHSZ sizeof(FILHDR) - - -/********************** AOUT "OPTIONAL HEADER" **********************/ - - -#define PAGEMAGIC3 0414 /* Split i&d, zero mapped */ -typedef struct aouthdr { - short magic; /* type of file */ - short vstamp; /* version stamp */ - unsigned long tsize; /* text size in bytes, padded to FW bdry*/ - unsigned long dsize; /* initialized data " " */ - unsigned long bsize; /* uninitialized data " " */ - - unsigned long entry; /* entry pt. */ - unsigned long text_start; /* base of text used for this file */ - unsigned long data_start; /* base of data used for this file */ - -} AOUTHDR; - - -/* compute size of a header */ - -#define AOUTSZ (sizeof(AOUTHDR)) - -/********************** STORAGE CLASSES **********************/ - -#define C_EFCN -1 /* physical end of function */ -#define C_NULL 0 -#define C_AUTO 1 /* automatic variable */ -#define C_EXT 2 /* external symbol */ -#define C_STAT 3 /* static */ -#define C_REG 4 /* register variable */ -#define C_EXTDEF 5 /* external definition */ -#define C_LABEL 6 /* label */ -#define C_ULABEL 7 /* undefined label */ -#define C_MOS 8 /* member of structure */ -#define C_ARG 9 /* function argument */ -#define C_STRTAG 10 /* structure tag */ -#define C_MOU 11 /* member of union */ -#define C_UNTAG 12 /* union tag */ -#define C_TPDEF 13 /* type definition */ -#define C_USTATIC 14 /* undefined static */ -#define C_ENTAG 15 /* enumeration tag */ -#define C_MOE 16 /* member of enumeration */ -#define C_REGPARM 17 /* register parameter */ -#define C_FIELD 18 /* bit field */ -#define C_BLOCK 100 /* ".bb" or ".eb" */ -#define C_FCN 101 /* ".bf" or ".ef" */ -#define C_EOS 102 /* end of structure */ -#define C_FILE 103 /* file name */ -#define C_LINE 104 /* line # reformatted as symbol table entry */ -#define C_ALIAS 105 /* duplicate tag */ -#define C_HIDDEN 106 /* ext symbol in dmert public lib */ -#define C_SHADOW 107 /* shadow symbol */ -#define C_VERSION 108 /* coff version symbol */ - - -/********************** SECTION HEADER **********************/ - -struct scnhdr { - char s_name[8]; /* section name */ - long s_paddr; /* physical address, aliased s_nlib */ - long s_vaddr; /* virtual address */ - long s_size; /* section size */ - long s_scnptr; /* file ptr to raw data for section */ - long s_relptr; /* file ptr to relocation */ - long s_lnnoptr; /* file ptr to line numbers */ - long s_nreloc; /* number of relocation entries */ - long s_nlnno; /* number of line number entries*/ - long s_flags; /* flags */ -}; - -/* - * names of "special" sections - */ -#define _TEXT ".text" -#define _DATA ".data" -#define _BSS ".bss" - -/* - * s_flags "type" - */ -#define STYP_TEXT 0x20 /* section contains text only */ -#define STYP_DATA 0x40 /* section contains data only */ -#define STYP_BSS 0x80 /* section contains bss only */ - -#define SCNHDR struct scnhdr -#define SCNHSZ sizeof(SCNHDR) - - -/********************** 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 lineno{ - union { - long l_symndx; /* function name symbol index, iff l_lnno == 0*/ - long l_paddr; /* (physical) address of line number */ - } l_addr; - - long l_lnno; - -}; - -#define LINENO struct lineno -#define LINESZ sizeof(LINENO) - - -/********************** SYMBOLS **********************/ - -#define E_SYMNMLEN 8 /* # characters in a symbol name */ -#define E_FILNMLEN 14 /* # characters in a file name */ -#define E_DIMNUM 4 /* # array dimensions in auxiliary entry */ - - -struct syment { - union { - char _n_name[E_SYMNMLEN]; /* old COFF version */ - struct { - long _n_zeroes; /* new == 0 */ - long _n_offset; /* offset into string table */ - } _n_n; - char *_n_nptr[2]; /* allows for overlaying */ - } _n; - long n_value; /* value of symbol */ - short n_scnum; /* section number */ - unsigned short n_type; /* type and derived type */ - char n_sclass; /* storage class */ - char n_numaux; /* number of aux. entries */ - char pad2[2]; /* force alignment */ -}; - -#define n_name _n._n_name -#define n_zeroes _n._n_n._n_zeroes -#define n_offset _n._n_n._n_offset - -/* - * Relocatable symbols have number of the section in which they are defined, - * or one of the following: - */ -#define N_UNDEF 0 /* undefined symbol */ -#define N_ABS -1 /* value of symbol is absolute */ -#define N_DEBUG -2 /* debugging symbol -- symbol value is meaningless */ - -/* - * Type of a symbol, in low 4 bits of the word - */ -#define T_NULL 0 -#define T_VOID 1 /* function argument (only used by compiler) */ -#define T_CHAR 2 /* character */ -#define T_SHORT 3 /* short integer */ -#define T_INT 4 /* integer */ -#define T_LONG 5 /* long integer */ -#define T_FLOAT 6 /* floating point */ -#define T_DOUBLE 7 /* double word */ -#define T_STRUCT 8 /* structure */ -#define T_UNION 9 /* union */ -#define T_ENUM 10 /* enumeration */ -#define T_MOE 11 /* member of enumeration*/ -#define T_UCHAR 12 /* unsigned character */ -#define T_USHORT 13 /* unsigned short */ -#define T_UINT 14 /* unsigned integer */ -#define T_ULONG 15 /* unsigned long */ - - - -/* - * derived types - */ -#define DT_NON 0 -#define DT_PTR 1 /* pointer */ -#define DT_FCN 2 /* function */ -#define DT_ARY 3 /* array */ - -#define N_BTMASK 017 -#define N_TMASK 060 -#define N_BTSHFT 4 -#define N_TSHIFT 2 - -#define BTYPE(x) ((x) & N_BTMASK) - - -#define ISPTR(x) (((x) & N_TMASK) == (DT_PTR << N_BTSHFT)) -#define ISFCN(x) (((x) & N_TMASK) == (DT_FCN << N_BTSHFT)) -#define ISARY(x) (((x) & N_TMASK) == (DT_ARY << N_BTSHFT)) - -#define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK)) - -union auxent { - struct { - long x_tagndx; /* str, un, or enum tag indx */ - union { - struct { - unsigned long x_lnno; /* declaration line number */ - unsigned long x_size; /* str/union/array size */ - } x_lnsz; - long x_fsize; /* size of function */ - } x_misc; - union { - struct { /* if ISFCN, tag, or .bb */ - long x_lnnoptr; /* ptr to fcn line # */ - long x_endndx; /* entry ndx past block end */ - } x_fcn; - struct { /* if ISARY, up to 4 dimen. */ - unsigned short x_dimen[E_DIMNUM]; - } x_ary; - } x_fcnary; - unsigned short x_tvndx; /* tv index */ - } x_sym; - - union { - char x_fname[E_FILNMLEN]; - struct { - long x_zeroes; - long x_offset; - } x_n; - } x_file; - - struct { - long x_scnlen; /* section length */ - unsigned long x_nreloc; /* # relocation entries */ - unsigned long x_nlinno; /* # line numbers */ - } x_scn; - - -}; - -#define SYMENT struct syment -#define SYMESZ sizeof(SYMENT) -#define AUXENT union auxent -#define AUXESZ sizeof(AUXENT) - - -/********************** RELOCATION DIRECTIVES **********************/ - -struct reloc { - long r_vaddr; /* Virtual address of reference */ - long r_symndx; /* Index into symbol table */ - unsigned short r_type; /* Relocation type */ - unsigned short r_offset;/* Hi 16 bits of constant */ -}; - -/* Only values of r_type GNU/88k cares about */ -#define R_PCR16L 128 -#define R_PCR26L 129 -#define R_VRT16 130 -#define R_HVRT16 131 -#define R_LVRT16 132 -#define R_VRT32 133 - - - - -#define RELOC struct reloc -#define RELSZ sizeof(RELOC) - -#define DEFAULT_SECTION_ALIGNMENT 8 /* double word */ diff --git a/include/bfd.h b/include/bfd.h deleted file mode 100644 index 345e8e03619..00000000000 --- a/include/bfd.h +++ /dev/null @@ -1,2372 +0,0 @@ -/* A -*- C -*- header file for the bfd library - Copyright 1990, 1991 Free Software Foundation, Inc. - Contributed by Cygnus Support. - -This file is part of BFD, the Binary File Descriptor library. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* bfd.h -- The only header file required by users of the bfd library - -This file is generated from various .c files, if you change it, your -bits may be lost. - -All the prototypes and definitions following the comment "THE FOLLOWING -IS EXTRACTED FROM THE SOURCE" are extracted from the source files for -BFD. If you change it, someone oneday will extract it from the source -again, and your changes will be lost. To save yourself from this bind, -change the definitions in the source in the bfd directory. Type "make -docs" and then "make headers" in that directory, and magically this file -will change to reflect your changes. - -If you don't have the tools to perform the extraction, then you are -safe from someone on your system trampling over your header files. -You should still maintain the equivalence between the source and this -file though; every change you make to the .c file should be reflected -here. */ - -#ifndef __BFD_H_SEEN__ -#define __BFD_H_SEEN__ - -#include "ansidecl.h" -#include "obstack.h" - -/* Make it easier to declare prototypes (puts conditional here) */ -#ifndef PROTO -# if __STDC__ -# define PROTO(type, name, arglist) type name arglist -# else -# define PROTO(type, name, arglist) type name () -# endif -#endif - -#define BFD_VERSION "0.18" - -/* forward declaration */ -typedef struct _bfd bfd; - -/* General rules: functions which are boolean return true on success - and false on failure (unless they're a predicate). -- bfd.doc */ -/* I'm sure this is going to break something and someone is going to - force me to change it. */ -/* typedef enum boolean {false, true} boolean; */ -/* Yup, SVR4 has a "typedef enum boolean" in -fnf */ -typedef enum bfd_boolean {false, true} boolean; - -/* Try to avoid breaking stuff */ -typedef long int file_ptr; - -/* Support for different sizes of target format ints and addresses */ - -#ifdef HOST_64_BIT -typedef HOST_64_BIT rawdata_offset; -typedef HOST_64_BIT bfd_vma; -typedef HOST_64_BIT bfd_word; -typedef HOST_64_BIT bfd_offset; -typedef HOST_64_BIT bfd_size_type; -typedef HOST_64_BIT symvalue; -typedef HOST_64_BIT bfd_64_type; -#define fprintf_vma(s,x) \ - fprintf(s,"%08x%08x", uint64_typeHIGH(x), uint64_typeLOW(x)) -#else -typedef struct {int a,b;} bfd_64_type; -typedef unsigned long rawdata_offset; -typedef unsigned long bfd_vma; -typedef unsigned long bfd_offset; -typedef unsigned long bfd_word; -typedef unsigned long bfd_size; -typedef unsigned long symvalue; -typedef unsigned long bfd_size_type; -#define fprintf_vma(s,x) fprintf(s, "%08lx", x) -#endif -#define printf_vma(x) fprintf_vma(stdout,x) - -typedef unsigned int flagword; /* 32 bits of flags */ - -/** File formats */ - -typedef enum bfd_format { - bfd_unknown = 0, /* file format is unknown */ - bfd_object, /* linker/assember/compiler output */ - bfd_archive, /* object archive file */ - bfd_core, /* core dump */ - bfd_type_end} /* marks the end; don't use it! */ - bfd_format; - -/* Object file flag values */ -#define NO_FLAGS 0 -#define HAS_RELOC 001 -#define EXEC_P 002 -#define HAS_LINENO 004 -#define HAS_DEBUG 010 -#define HAS_SYMS 020 -#define HAS_LOCALS 040 -#define DYNAMIC 0100 -#define WP_TEXT 0200 -#define D_PAGED 0400 - - -/* symbols and relocation */ - -typedef unsigned long symindex; - -#define BFD_NO_MORE_SYMBOLS ((symindex) ~0) - -typedef enum bfd_symclass { - bfd_symclass_unknown = 0, - bfd_symclass_fcommon, /* fortran common symbols */ - bfd_symclass_global, /* global symbol, what a surprise */ - bfd_symclass_debugger, /* some debugger symbol */ - bfd_symclass_undefined /* none known */ - } symclass; - - -typedef int symtype; /* Who knows, yet? */ - - -/* general purpose part of a symbol; - target specific parts will be found in libcoff.h, liba.out.h etc */ - - -#define bfd_get_section(x) ((x)->section) -#define bfd_get_output_section(x) ((x)->section->output_section) -#define bfd_set_section(x,y) ((x)->section) = (y) -#define bfd_asymbol_base(x) ((x)->section?((x)->section->vma):0) -#define bfd_asymbol_value(x) (bfd_asymbol_base(x) + x->value) -#define bfd_asymbol_name(x) ((x)->name) - -/* This is a type pun with struct ranlib on purpose! */ -typedef struct carsym { - char *name; - file_ptr file_offset; /* look here to find the file */ -} carsym; /* to make these you call a carsymogen */ - - -/* Used in generating armaps. Perhaps just a forward definition would do? */ -struct orl { /* output ranlib */ - char **name; /* symbol name */ - file_ptr pos; /* bfd* or file position */ - int namidx; /* index into string table */ -}; - - - -/* Linenumber stuff */ -typedef struct lineno_cache_entry { - unsigned int line_number; /* Linenumber from start of function*/ - union { - struct symbol_cache_entry *sym; /* Function name */ - unsigned long offset; /* Offset into section */ - } u; -} alent; - -/* object and core file sections */ - - -#define align_power(addr, align) \ - ( ((addr) + ((1<<(align))-1)) & (-1 << (align))) - -typedef struct sec *sec_ptr; - -#define bfd_section_name(bfd, ptr) ((ptr)->name) -#define bfd_section_size(bfd, ptr) ((ptr)->size) -#define bfd_section_vma(bfd, ptr) ((ptr)->vma) -#define bfd_section_alignment(bfd, ptr) ((ptr)->alignment_power) -#define bfd_get_section_flags(bfd, ptr) ((ptr)->flags) -#define bfd_get_section_userdata(bfd, ptr) ((ptr)->userdata) - -#define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (val)), 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) - -typedef struct stat stat_type; - -/** Error handling */ - -typedef enum bfd_error { - no_error = 0, system_call_error, invalid_target, - wrong_format, invalid_operation, no_memory, - no_symbols, no_relocation_info, - no_more_archived_files, malformed_archive, - symbol_not_found, file_not_recognized, - file_ambiguously_recognized, no_contents, - bfd_error_nonrepresentable_section, - no_debug_section, - invalid_error_code} bfd_ec; - -extern bfd_ec bfd_error; - -typedef struct bfd_error_vector { - PROTO(void,(* nonrepresentable_section ),(CONST bfd *CONST abfd, - CONST char *CONST name)); -} bfd_error_vector_type; - -PROTO (char *, bfd_errmsg, ()); -PROTO (void, bfd_perror, (CONST char *message)); - - -typedef enum bfd_print_symbol -{ - bfd_print_symbol_name, - bfd_print_symbol_more, - bfd_print_symbol_all, - bfd_print_symbol_nm, /* Pretty format suitable for nm program. */ -} bfd_print_symbol_type; - - - -/* The code that implements targets can initialize a jump table with this - macro. It must name all its routines the same way (a prefix plus - the standard routine suffix), or it must #define the routines that - are not so named, before calling JUMP_TABLE in the initializer. */ - -/* Semi-portable string concatenation in cpp */ -#ifndef CAT -#ifdef __STDC__ -#define CAT(a,b) a##b -#else -#define CAT(a,b) a/**/b -#endif -#endif - -#define JUMP_TABLE(NAME)\ -CAT(NAME,_core_file_failing_command),\ -CAT(NAME,_core_file_failing_signal),\ -CAT(NAME,_core_file_matches_executable_p),\ -CAT(NAME,_slurp_armap),\ -CAT(NAME,_slurp_extended_name_table),\ -CAT(NAME,_truncate_arname),\ -CAT(NAME,_write_armap),\ -CAT(NAME,_close_and_cleanup), \ -CAT(NAME,_set_section_contents),\ -CAT(NAME,_get_section_contents),\ -CAT(NAME,_new_section_hook),\ -CAT(NAME,_get_symtab_upper_bound),\ -CAT(NAME,_get_symtab),\ -CAT(NAME,_get_reloc_upper_bound),\ -CAT(NAME,_canonicalize_reloc),\ -CAT(NAME,_make_empty_symbol),\ -CAT(NAME,_print_symbol),\ -CAT(NAME,_get_lineno),\ -CAT(NAME,_set_arch_mach),\ -CAT(NAME,_openr_next_archived_file),\ -CAT(NAME,_find_nearest_line),\ -CAT(NAME,_generic_stat_arch_elt),\ -CAT(NAME,_sizeof_headers),\ -CAT(NAME,_bfd_debug_info_start),\ -CAT(NAME,_bfd_debug_info_end),\ -CAT(NAME,_bfd_debug_info_accumulate) - -#define COFF_SWAP_TABLE \ - coff_swap_aux_in, coff_swap_sym_in, coff_swap_lineno_in, \ - coff_swap_aux_out, coff_swap_sym_out, \ - coff_swap_lineno_out, coff_swap_reloc_out, \ - coff_swap_filehdr_out, coff_swap_aouthdr_out, \ - coff_swap_scnhdr_out - - - -/* User program access to BFD facilities */ - -extern CONST short _bfd_host_big_endian; -#define HOST_BYTE_ORDER_BIG_P (*(char *)&_bfd_host_big_endian) - -/* The bfd itself */ - -/* Cast from const char * to char * so that caller can assign to - a char * without a warning. */ -#define bfd_get_filename(abfd) ((char *) (abfd)->filename) -#define bfd_get_format(abfd) ((abfd)->format) -#define bfd_get_target(abfd) ((abfd)->xvec->name) -#define bfd_get_file_flags(abfd) ((abfd)->flags) -#define bfd_applicable_file_flags(abfd) ((abfd)->xvec->object_flags) -#define bfd_applicable_section_flags(abfd) ((abfd)->xvec->section_flags) -#define bfd_my_archive(abfd) ((abfd)->my_archive); -#define bfd_has_map(abfd) ((abfd)->has_armap) -#define bfd_header_twiddle_required(abfd) \ - ((((abfd)->xvec->header_byteorder_big_p) \ - != (boolean)HOST_BYTE_ORDER_BIG_P) ? true:false) - -#define bfd_valid_reloc_types(abfd) ((abfd)->xvec->valid_reloc_types) -#define bfd_usrdata(abfd) ((abfd)->usrdata) - -#define bfd_get_start_address(abfd) ((abfd)->start_address) -#define bfd_get_symcount(abfd) ((abfd)->symcount) -#define bfd_get_outsymbols(abfd) ((abfd)->outsymbols) -#define bfd_count_sections(abfd) ((abfd)->section_count) -#define bfd_get_architecture(abfd) ((abfd)->obj_arch) -#define bfd_get_machine(abfd) ((abfd)->obj_machine) - - - -#define BYTE_SIZE 1 -#define SHORT_SIZE 2 -#define LONG_SIZE 4 - - - -/*THE FOLLOWING IS EXTRACTED FROM THE SOURCE */ - - -/*:init.c*/ -/* bfd_init - -This routine must be called before any other bfd function to initialize -magical internal data structures. -*/ - - void EXFUN(bfd_init,(void)); - -/* -*/ - -/*:opncls.c*/ -/* *i bfd_openr -Opens the file supplied (using @code{fopen}) with the target supplied, it -returns a pointer to the created BFD. - -If NULL is returned then an error has occured. -Possible errors are no_memory, invalid_target or system_call error. -*/ - PROTO(bfd*, bfd_openr, (CONST char *filename,CONST char*target)); - -/* - -*i bfd_fdopenr -bfd_fdopenr is to bfd_fopenr much like fdopen is to fopen. It opens a BFD on -a file already described by the @var{fd} supplied. - -Possible errors are no_memory, invalid_target and system_call error. -*/ - PROTO(bfd *, bfd_fdopenr, - (CONST char *filename, CONST char *target, int fd)); - -/* - - bfd_openw -Creates a BFD, associated with file @var{filename}, using the file -format @var{target}, and returns a pointer to it. - -Possible errors are system_call_error, no_memory, invalid_target. -*/ - PROTO(bfd *, bfd_openw, (CONST char *filename, CONST char *target)); - -/* - - bfd_close -This function closes a BFD. If the BFD was open for writing, then -pending operations are completed and the file written out and closed. -If the created file is executable, then @code{chmod} is called to mark -it as such. - -All memory attached to the BFD's obstacks is released. - -@code{true} is returned if all is ok, otherwise @code{false}. -*/ - PROTO(boolean, bfd_close,(bfd *)); - -/* - - bfd_close_all_done -This function closes a BFD. It differs from @code{bfd_close} since it -does not complete any pending operations. This routine would be used -if the application had just used BFD for swapping and didn't want to -use any of the writing code. - -If the created file is executable, then @code{chmod} is called to mark -it as such. - -All memory attached to the BFD's obstacks is released. - -@code{true} is returned if all is ok, otherwise @code{false}. -*/ - PROTO(boolean, bfd_close_all_done,(bfd *)); - -/* - - bfd_create -This routine creates a new BFD in the manner of @code{bfd_openw}, but without -opening a file. The new BFD takes the target from the target used by -@var{template}. The format is always set to @code{bfd_object}. -*/ - - PROTO(bfd *, bfd_create, (CONST char *filename, bfd *template)); - -/* - - bfd_alloc_size -Return the number of bytes in the obstacks connected to the supplied -BFD. -*/ - PROTO(bfd_size_type,bfd_alloc_size,(bfd *abfd)); - -/* -*/ - - -/*:libbfd.c*/ -/* *i bfd_put_size -*i bfd_get_size -These macros as used for reading and writing raw data in sections; -each access (except for bytes) is vectored through the target format -of the BFD and mangled accordingly. The mangling performs any -necessary endian translations and removes alignment restrictions. -*/ -#define bfd_put_8(abfd, val, ptr) \ - (*((char *)ptr) = (char)val) -#define bfd_get_8(abfd, ptr) \ - (*((char *)ptr)) -#define bfd_put_16(abfd, val, ptr) \ - BFD_SEND(abfd, bfd_putx16, (val,ptr)) -#define bfd_get_16(abfd, ptr) \ - BFD_SEND(abfd, bfd_getx16, (ptr)) -#define bfd_put_32(abfd, val, ptr) \ - BFD_SEND(abfd, bfd_putx32, (val,ptr)) -#define bfd_get_32(abfd, ptr) \ - BFD_SEND(abfd, bfd_getx32, (ptr)) -#define bfd_put_64(abfd, val, ptr) \ - BFD_SEND(abfd, bfd_putx64, (val, ptr)) -#define bfd_get_64(abfd, ptr) \ - BFD_SEND(abfd, bfd_getx64, (ptr)) -/* *i bfd_h_put_size -*i bfd_h_get_size -These macros have the same function as their @code{bfd_get_x} -bretherin, except that they are used for removing information for the -header records of object files. Believe it or not, some object files -keep their header records in big endian order, and their data in little -endan order. -*/ -#define bfd_h_put_8(abfd, val, ptr) \ - (*((char *)ptr) = (char)val) -#define bfd_h_get_8(abfd, ptr) \ - (*((char *)ptr)) -#define bfd_h_put_16(abfd, val, ptr) \ - BFD_SEND(abfd, bfd_h_putx16,(val,ptr)) -#define bfd_h_get_16(abfd, ptr) \ - BFD_SEND(abfd, bfd_h_getx16,(ptr)) -#define bfd_h_put_32(abfd, val, ptr) \ - BFD_SEND(abfd, bfd_h_putx32,(val,ptr)) -#define bfd_h_get_32(abfd, ptr) \ - BFD_SEND(abfd, bfd_h_getx32,(ptr)) -#define bfd_h_put_64(abfd, val, ptr) \ - BFD_SEND(abfd, bfd_h_putx64,(val, ptr)) -#define bfd_h_get_64(abfd, ptr) \ - BFD_SEND(abfd, bfd_h_getx64,(ptr)) - -/*:section.c*/ -/* The shape of a section struct: -*/ - -typedef struct sec { - -/* -The name of the section, the name isn't a copy, the pointer is -the same as that passed to bfd_make_section. -*/ - - CONST char *name; - -/* -The next section in the list belonging to the BFD, or NULL. -*/ - - struct sec *next; - -/* -The field flags contains attributes of the section. Some of these -flags are read in from the object file, and some are synthesized from -other information. -*/ - -flagword flags; - -/* -*/ - -#define SEC_NO_FLAGS 0x000 - -/* -Tells the OS to allocate space for this section when loaded. -This would clear for a section containing debug information only. -*/ - -#define SEC_ALLOC 0x001 - -/* -Tells the OS to load the section from the file when loading. -This would be clear for a .bss section -*/ - -#define SEC_LOAD 0x002 - -/* -The section contains data still to be relocated, so there will be some -relocation information too. -*/ - -#define SEC_RELOC 0x004 - -/* -Obsolete ? -*/ - -#define SEC_BALIGN 0x008 - -/* -A signal to the OS that the section contains read only data. -*/ - -#define SEC_READONLY 0x010 - -/* -The section contains code only. -*/ - -#define SEC_CODE 0x020 - -/* -The section contains data only. -*/ - -#define SEC_DATA 0x040 - -/* -The section will reside in ROM. -*/ - -#define SEC_ROM 0x080 - -/* -The section contains constructor information. This section type is -used by the linker to create lists of constructors and destructors -used by @code{g++}. When a back end sees a symbol which should be used -in a constructor list, it creates a new section for the type of name -(eg @code{__CTOR_LIST__}), attaches the symbol to it and builds a -relocation. To build the lists of constructors, all the linker has to -to is catenate all the sections called @code{__CTOR_LIST__} and -relocte the data contained within - exactly the operations it would -peform on standard data. -*/ - -#define SEC_CONSTRUCTOR 0x100 - -/* -The section is a constuctor, and should be placed at the end of the .. -*/ - -#define SEC_CONSTRUCTOR_TEXT 0x1100 - -/* -*/ -#define SEC_CONSTRUCTOR_DATA 0x2100 - -/* -*/ -#define SEC_CONSTRUCTOR_BSS 0x3100 - -/* - -The section has contents - a bss section could be -@code{SEC_ALLOC} | @code{SEC_HAS_CONTENTS}, a debug section could be -@code{SEC_HAS_CONTENTS} -*/ - -#define SEC_HAS_CONTENTS 0x200 - -/* -An instruction to the linker not to output sections containing -this flag even if they have information which would normally be written. -*/ - -#define SEC_NEVER_LOAD 0x400 - -/* - -The base address of the section in the address space of the target. -*/ - - bfd_vma vma; - -/* -The size of the section in bytes of the loaded section. This contains -a value even if the section has no contents (eg, the size of @code{.bss}). -*/ - - bfd_size_type size; - -/* -If this section is going to be output, then this value is the -offset into the output section of the first byte in the input -section. Eg, if this was going to start at the 100th byte in the -output section, this value would be 100. -*/ - - bfd_vma output_offset; - -/* -The output section through which to map on output. -*/ - - struct sec *output_section; - -/* -The alignment requirement of the section, as an exponent - eg 3 -aligns to 2^3 (or 8) -*/ - - unsigned int alignment_power; - -/* -If an input section, a pointer to a vector of relocation records for -the data in this section. -*/ - - struct reloc_cache_entry *relocation; - -/* -If an output section, a pointer to a vector of pointers to -relocation records for the data in this section. -*/ - - struct reloc_cache_entry **orelocation; - -/* -The number of relocation records in one of the above -*/ - - unsigned reloc_count; - -/* -Which section is it 0..nth -*/ - - int index; - -/* -Information below is back end specific - and not always used or -updated - -File position of section data -*/ - - file_ptr filepos; -/* File position of relocation info -*/ - - file_ptr rel_filepos; - -/* -File position of line data -*/ - - file_ptr line_filepos; - -/* -Pointer to data for applications -*/ - - PTR userdata; - -/* -*/ - struct lang_output_section *otheruserdata; - -/* -Attached line number information -*/ - - alent *lineno; -/* Number of line number records -*/ - - unsigned int lineno_count; - -/* -When a section is being output, this value changes as more -linenumbers are written out -*/ - - file_ptr moving_line_filepos; - -/* -what the section number is in the target world -*/ - - unsigned int target_index; - -/* -*/ - PTR used_by_bfd; - -/* -If this is a constructor section then here is a list of the -relocations created to relocate items within it. -*/ - - struct relent_chain *constructor_chain; - -/* -The BFD which owns the section. -*/ - - bfd *owner; - -/* -*/ -} asection ; - -/* - - bfd_get_section_by_name -Runs through the provided @var{abfd} and returns the @code{asection} -who's name matches that provided, otherwise NULL. @xref{Sections}, for more information. -*/ - - PROTO(asection *, bfd_get_section_by_name, - (bfd *abfd, CONST char *name)); - -/* - - bfd_make_section_old_way -This function creates a new empty section called @var{name} and attaches it -to the end of the chain of sections for the BFD supplied. An attempt to -create a section with a name which is already in use, returns its pointer without -changing the section chain. - -It has the funny name since this is the way it used to be before gilmore broke it. - -Possible errors are: -@table @code -@item invalid_operation -If output has already started for this BFD. -@item no_memory -If obstack alloc fails. -@end table -*/ - - PROTO(asection *, bfd_make_section_old_way, (bfd *, CONST char *name)); - -/* - - bfd_make_section -This function creates a new empty section called @var{name} and attaches it -to the end of the chain of sections for the BFD supplied. An attempt to -create a section with a name which is already in use, returns NULL without -changing the section chain. - -Possible errors are: -@table @code -@item invalid_operation -If output has already started for this BFD. -@item no_memory -If obstack alloc fails. -@end table -*/ - - PROTO(asection *, bfd_make_section, (bfd *, CONST char *name)); - -/* - - bfd_set_section_flags -Attempts to set the attributes of the section named in the BFD -supplied to the value. Returns true on success, false on error. -Possible error returns are: -@table @code -@item invalid operation -The section cannot have one or more of the attributes requested. For -example, a .bss section in @code{a.out} may not have the -@code{SEC_HAS_CONTENTS} field set. -@end table -*/ - - PROTO(boolean, bfd_set_section_flags, - (bfd *, asection *, flagword)); - -/* - - bfd_map_over_sections -Calls the provided function @var{func} for each section attached to -the BFD @var{abfd}, passing @var{obj} as an argument. The function -will be called as if by - -@example - func(abfd, the_section, obj); -@end example -*/ - - PROTO(void, bfd_map_over_sections, - (bfd *abfd, void (*func)(), PTR obj)); - -/* - -This is the prefered method for iterating over sections, an -alternative would be to use a loop: - -@example - section *p; - for (p = abfd->sections; p != NULL; p = p->next) - func(abfd, p, ...) -@end example - - bfd_set_section_size -Sets @var{section} to the size @var{val}. If the operation is ok, then -@code{true} is returned, else @code{false}. - -Possible error returns: -@table @code -@item invalid_operation -Writing has started to the BFD, so setting the size is invalid -@end table -*/ - - PROTO(boolean, bfd_set_section_size, - (bfd *, asection *, bfd_size_type val)); - -/* - - bfd_set_section_contents -Sets the contents of the section @var{section} in BFD @var{abfd} to -the data starting in memory at @var{data}. The data is written to the -output section starting at offset @var{offset} for @var{count} bytes. - -Normally @code{true} is returned, else @code{false}. Possible error -returns are: -@table @code -@item no_contents -The output section does not have the @code{SEC_HAS_CONTENTS} -attribute, so nothing can be written to it. -@item and some more too -@end table -This routine is front end to the back end function @code{_bfd_set_section_contents}. -*/ - - PROTO(boolean, bfd_set_section_contents, - (bfd *abfd, - asection *section, - PTR data, - file_ptr offset, - bfd_size_type count)); - -/* - - bfd_get_section_contents -This function reads data from @var{section} in BFD @var{abfd} into -memory starting at @var{location}. The data is read at an offset of -@var{offset} from the start of the input section, and is read for -@var{count} bytes. - -If the contents of a constuctor with the @code{SEC_CONSTUCTOR} flag -set are requested, then the @var{location} is filled with zeroes. - -If no errors occur, @code{true} is returned, else @code{false}. -Possible errors are: - -@table @code -@item unknown yet -@end table -*/ - - PROTO(boolean, bfd_get_section_contents, - (bfd *abfd, asection *section, PTR location, - file_ptr offset, bfd_size_type count)); - -/* -*/ - - - -/*:archures.c*/ -/* bfd_architecture -This enum gives the object file's CPU -architecture, in a global sense. E.g. what processor family does it -belong to? There is another field, which indicates what processor -within the family is in use. The machine gives a number which -distingushes different versions of the architecture, containing for -example 2 and 3 for Intel i960 KA and i960 KB, and 68020 and 68030 for -Motorola 68020 and 68030. -*/ - -enum bfd_architecture -{ - bfd_arch_unknown, /* File arch not known */ - bfd_arch_obscure, /* Arch known, not one of these */ - bfd_arch_m68k, /* Motorola 68xxx */ - bfd_arch_vax, /* DEC Vax */ - bfd_arch_i960, /* Intel 960 */ - /* The order of the following is important. - lower number indicates a machine type that - only accepts a subset of the instructions - available to machines with higher numbers. - The exception is the "ca", which is - incompatible with all other machines except - "core". */ - -#define bfd_mach_i960_core 1 -#define bfd_mach_i960_ka_sa 2 -#define bfd_mach_i960_kb_sb 3 -#define bfd_mach_i960_mc 4 -#define bfd_mach_i960_xa 5 -#define bfd_mach_i960_ca 6 - - bfd_arch_a29k, /* AMD 29000 */ - bfd_arch_sparc, /* SPARC */ - bfd_arch_mips, /* MIPS Rxxxx */ - bfd_arch_i386, /* Intel 386 */ - bfd_arch_ns32k, /* National Semiconductor 32xxx */ - bfd_arch_tahoe, /* CCI/Harris Tahoe */ - bfd_arch_i860, /* Intel 860 */ - bfd_arch_romp, /* IBM ROMP PC/RT */ - bfd_arch_alliant, /* Alliant */ - bfd_arch_convex, /* Convex */ - bfd_arch_m88k, /* Motorola 88xxx */ - bfd_arch_pyramid, /* Pyramid Technology */ - bfd_arch_h8300, /* Hitachi H8/300 */ - bfd_arch_rs6000, /* IBM RS/6000 */ - bfd_arch_last - }; - -/* -stuff - - bfd_arch_info -This structure contains information on architectures. -*/ -typedef int bfd_reloc_code_type; - -typedef struct bfd_arch_info -{ - int bits_per_word; - int bits_per_address; - int bits_per_byte; - enum bfd_architecture arch; - long mach; - char *arch_name; - CONST char *printable_name; -/* true if this is the default machine for the architecture */ - boolean the_default; - CONST struct bfd_arch_info * EXFUN((*compatible),(CONST struct bfd_arch_info *a, - CONST struct bfd_arch_info *b)); - - boolean EXFUN((*scan),(CONST struct bfd_arch_info *,CONST char *)); - unsigned int EXFUN((*disassemble),(bfd_vma addr, CONST char *data, - PTR stream)); - CONST struct reloc_howto_struct *EXFUN((*reloc_type_lookup), (CONST struct - bfd_arch_info *, - bfd_reloc_code_type code)); - - struct bfd_arch_info *next; - -} bfd_arch_info_type; - -/* - bfd_printable_name - -Return a printable string representing the architecture and machine -from the pointer to the arch info structure -*/ - - CONST char *EXFUN(bfd_printable_name,(bfd *abfd)); - -/* - -*i bfd_scan_arch -This routine is provided with a string and tries to work out if bfd -supports any cpu which could be described with the name provided. The -routine returns a pointer to an arch_info structure if a machine is -found, otherwise NULL. -*/ - - bfd_arch_info_type *EXFUN(bfd_scan_arch,(CONST char *)); - -/* - - bfd_arch_get_compatible -This routine is used to determine whether two BFDs' architectures and -machine types are compatible. It calculates the lowest common -denominator between the two architectures and machine types implied by -the BFDs and returns a pointer to an arch_info structure describing -the compatible machine. -*/ - - CONST bfd_arch_info_type *EXFUN(bfd_arch_get_compatible, - (CONST bfd *abfd, - CONST bfd *bbfd)); - -/* - - bfd_set_arch_info -*/ - - void EXFUN(bfd_set_arch_info,(bfd *, bfd_arch_info_type *)); - -/* - - bfd_get_arch - -Returns the enumerated type which describes the supplied bfd's -architecture -*/ - - enum bfd_architecture EXFUN(bfd_get_arch, (bfd *abfd)); - -/* - - bfd_get_mach - -Returns the long type which describes the supplied bfd's -machine -*/ - - unsigned long EXFUN(bfd_get_mach, (bfd *abfd)); - -/* - - bfd_arch_bits_per_byte - -Returns the number of bits in one of the architectures bytes -*/ - - unsigned int EXFUN(bfd_arch_bits_per_byte, (bfd *abfd)); - -/* - - bfd_arch_bits_per_address - -Returns the number of bits in one of the architectures addresses -*/ - - unsigned int EXFUN(bfd_arch_bits_per_address, (bfd *abfd)); - -/* - - bfd_get_arch_info -*/ - - bfd_arch_info_type * EXFUN(bfd_get_arch_info,(bfd *)); - -/* - - bfd_lookup_arch - -*/ - bfd_arch_info_type * EXFUN(bfd_lookup_arch,(enum - bfd_architecture arch,long machine)); - -/* - -Look for the architecure info struct which matches the arguments -given. A machine of 0 will match the machine/architecture structure which -marks itself as the default. - - bfd_printable_arch_mach -Return a printable string representing the architecture and machine -type. - -NB. The use of this routine is depreciated. -*/ - - PROTO(CONST char *,bfd_printable_arch_mach, - (enum bfd_architecture arch, unsigned long machine)); - -/* -*/ - -/*:reloc.c*/ -/* bfd_perform_relocation -The relocation routine returns as a status an enumerated type: -*/ - -typedef enum bfd_reloc_status { -/* No errors detected -*/ - - bfd_reloc_ok, - -/* -The relocation was performed, but there was an overflow. -*/ - - bfd_reloc_overflow, - -/* -The address to relocate was not within the section supplied -*/ - - bfd_reloc_outofrange, - -/* -Used by special functions -*/ - - bfd_reloc_continue, - -/* -Unused -*/ - - bfd_reloc_notsupported, - -/* -Unsupported relocation size requested. -*/ - - bfd_reloc_other, - -/* -The symbol to relocate against was undefined. -*/ - - bfd_reloc_undefined, - -/* -The relocation was performed, but may not be ok - presently generated -only when linking i960 coff files with i960 b.out symbols. -*/ - - bfd_reloc_dangerous - } - bfd_reloc_status_type; - -/* -*/ - -typedef struct reloc_cache_entry -{ - -/* -A pointer into the canonical table of pointers -*/ - - struct symbol_cache_entry **sym_ptr_ptr; - -/* -offset in section -*/ - - rawdata_offset address; - -/* -addend for relocation value -*/ - - bfd_vma addend; - -/* -if sym is null this is the section -*/ - - struct sec *section; - -/* -Pointer to how to perform the required relocation -*/ - - CONST struct reloc_howto_struct *howto; -} arelent; - -/* - - reloc_howto_type -The @code{reloc_howto_type} is a structure which contains all the -information that BFD needs to know to tie up a back end's data. -*/ - -typedef CONST struct reloc_howto_struct -{ -/* The type field has mainly a documetary use - the back end can to what -it wants with it, though the normally the back end's external idea of -what a reloc number would be would be stored in this field. For -example, the a PC relative word relocation in a coff environment would -have the type 023 - because that's what the outside world calls a -R_PCRWORD reloc. -*/ - - unsigned int type; - -/* -The value the final relocation is shifted right by. This drops -unwanted data from the relocation. -*/ - - unsigned int rightshift; - -/* -The size of the item to be relocated - 0, is one byte, 1 is 2 bytes, 3 -is four bytes. -*/ - - unsigned int size; - -/* -Now obsolete -*/ - - unsigned int bitsize; - -/* -Notes that the relocation is relative to the location in the data -section of the addend. The relocation function will subtract from the -relocation value the address of the location being relocated. -*/ - - boolean pc_relative; - -/* -Now obsolete -*/ - - unsigned int bitpos; - -/* -Now obsolete -*/ - - boolean absolute; - -/* -Causes the relocation routine to return an error if overflow is -detected when relocating. -*/ - - boolean complain_on_overflow; - -/* -If this field is non null, then the supplied function is called rather -than the normal function. This allows really strange relocation -methods to be accomodated (eg, i960 callj instructions). -*/ - - bfd_reloc_status_type (*special_function)(); - -/* -The textual name of the relocation type. -*/ - - char *name; - -/* -When performing a partial link, some formats must modify the -relocations rather than the data - this flag signals this. -*/ - - boolean partial_inplace; - -/* -The src_mask is used to select what parts of the read in data are to -be used in the relocation sum. Eg, if this was an 8 bit bit of data -which we read and relocated, this would be 0x000000ff. When we have -relocs which have an addend, such as sun4 extended relocs, the value -in the offset part of a relocating field is garbage so we never use -it. In this case the mask would be 0x00000000. -*/ - - bfd_word src_mask; -/* The dst_mask is what parts of the instruction are replaced into the -instruction. In most cases src_mask == dst_mask, except in the above -special case, where dst_mask would be 0x000000ff, and src_mask would -be 0x00000000. -*/ - - bfd_word dst_mask; - -/* -When some formats create PC relative instructions, they leave the -value of the pc of the place being relocated in the offset slot of the -instruction, so that a PC relative relocation can be made just by -adding in an ordinary offset (eg sun3 a.out). Some formats leave the -displacement part of an instruction empty (eg m88k bcs), this flag -signals the fact. -*/ - - boolean pcrel_offset; -} reloc_howto_type; - -/* - - HOWTO -The HOWTO define is horrible and will go away. -*/ -#define HOWTO(C, R,S,B, P, BI, ABS, O, SF, NAME, INPLACE, MASKSRC, MASKDST, PC) \ - {(unsigned)C,R,S,B, P, BI, ABS,O,SF,NAME,INPLACE,MASKSRC,MASKDST,PC} - -/* -And will be replaced with the totally magic way. But for the moment, -we are compatible, so do it this way.. -*/ - -#define NEWHOWTO( FUNCTION, NAME,SIZE,REL,IN) HOWTO(0,0,SIZE,0,REL,0,false,false,FUNCTION, NAME,false,0,0,IN) - -/* -Helper routine to turn a symbol into a relocation value. -*/ - - -#define HOWTO_PREPARE(relocation, symbol) \ - { \ - if (symbol != (asymbol *)NULL) { \ - if (symbol->flags & BSF_FORT_COMM) { \ - relocation = 0; \ - } \ - else { \ - relocation = symbol->value; \ - } \ - } \ - if (symbol->section != (asection *)NULL) { \ - relocation += symbol->section->output_section->vma + \ - symbol->section->output_offset; \ - } \ -} - -/* - reloc_chain -*/ -typedef unsigned char bfd_byte; - -typedef struct relent_chain { - arelent relent; - struct relent_chain *next; -} arelent_chain; - -/* - -If an output_bfd is supplied to this function the generated image -will be relocatable, the relocations are copied to the output file -after they have been changed to reflect the new state of the world. -There are two ways of reflecting the results of partial linkage in an -output file; by modifying the output data in place, and by modifying -the relocation record. Some native formats (eg basic a.out and basic -coff) have no way of specifying an addend in the relocation type, so -the addend has to go in the output data. This is no big deal since in -these formats the output data slot will always be big enough for the -addend. Complex reloc types with addends were invented to solve just -this problem. -*/ - PROTO(bfd_reloc_status_type, - bfd_perform_relocation, - (bfd * abfd, - arelent *reloc_entry, - PTR data, - asection *input_section, - bfd *output_bfd)); - -/* - - bfd_reloc_code_type -*/ - -typedef enum bfd_reloc_code_real { - -/* -16 bits wide, simple reloc -*/ - - BFD_RELOC_16, - -/* -8 bits wide, but used to form an address like 0xffnn -*/ - - BFD_RELOC_8_FFnn, - -/* -8 bits wide, simple -*/ - - BFD_RELOC_8, - -/* -8 bits wide, pc relative -*/ - - BFD_RELOC_8_PCREL, - -/* -The type of reloc used to build a contructor table - at the moment probably a 32 bit -wide abs address, but the cpu can choose. -*/ - - BFD_RELOC_CTOR - -/* -*/ - } bfd_reloc_code_real_type; - -/* - - bfd_reloc_type_lookup -This routine returns a pointer to a howto struct which when invoked, -will perform the supplied relocation on data from the architecture -noted. -*/ - - PROTO(CONST struct reloc_howto_struct *, - bfd_reloc_type_lookup, - (CONST bfd_arch_info_type *arch, bfd_reloc_code_type code)); - -/* -*/ - -/*:syms.c*/ -/* @subsection typedef asymbol -An @code{asymbol} has the form: -*/ - -typedef struct symbol_cache_entry -{ -/* A pointer to the BFD which owns the symbol. This information is -necessary so that a back end can work out what additional (invisible to -the application writer) information is carried with the symbol. -*/ - - struct _bfd *the_bfd; - -/* -The text of the symbol. The name is left alone, and not copied - the -application may not alter it. -*/ - - CONST char *name; - -/* -The value of the symbol. -*/ - - symvalue value; - -/* -Attributes of a symbol: -*/ - -#define BSF_NO_FLAGS 0x00 - -/* -The symbol has local scope; @code{static} in @code{C}. The value is -the offset into the section of the data. -*/ - -#define BSF_LOCAL 0x01 - -/* -The symbol has global scope; initialized data in @code{C}. The value -is the offset into the section of the data. -*/ - -#define BSF_GLOBAL 0x02 - -/* -Obsolete -*/ - -#define BSF_IMPORT 0x04 - -/* -The symbol has global scope, and is exported. The value is the offset -into the section of the data. -*/ - -#define BSF_EXPORT 0x08 - -/* -The symbol is undefined. @code{extern} in @code{C}. The value has no meaning. -*/ - -#define BSF_UNDEFINED 0x10 - -/* -The symbol is common, initialized to zero; default in @code{C}. The -value is the size of the object in bytes. -*/ - -#define BSF_FORT_COMM 0x20 - -/* -A normal @code{C} symbol would be one of: -@code{BSF_LOCAL}, @code{BSF_FORT_COMM}, @code{BSF_UNDEFINED} or @code{BSF_EXPORT|BSD_GLOBAL} - -The symbol is a debugging record. The value has an arbitary meaning. -*/ - -#define BSF_DEBUGGING 0x40 - -/* -The symbol has no section attached, any value is the actual value and -is not a relative offset to a section. -*/ - -#define BSF_ABSOLUTE 0x80 - -/* -Used by the linker -*/ - -#define BSF_KEEP 0x10000 -#define BSF_KEEP_G 0x80000 - -/* -Unused -*/ - -#define BSF_WEAK 0x100000 -#define BSF_CTOR 0x200000 -#define BSF_FAKE 0x400000 - -/* -The symbol used to be a common symbol, but now it is allocated. -*/ - -#define BSF_OLD_COMMON 0x800000 - -/* -The default value for common data. -*/ - -#define BFD_FORT_COMM_DEFAULT_VALUE 0 - -/* -In some files the type of a symbol sometimes alters its location -in an output file - ie in coff a @code{ISFCN} symbol which is also @code{C_EXT} -symbol appears where it was declared and not at the end of a section. -This bit is set by the target BFD part to convey this information. -*/ - -#define BSF_NOT_AT_END 0x40000 - -/* -Signal that the symbol is the label of constructor section. -*/ - -#define BSF_CONSTRUCTOR 0x1000000 - -/* -Signal that the symbol is a warning symbol. If the symbol is a warning -symbol, then the value field (I know this is tacky) will point to the -asymbol which when referenced will cause the warning. -*/ - -#define BSF_WARNING 0x2000000 - -/* -Signal that the symbol is indirect. The value of the symbol is a -pointer to an undefined asymbol which contains the name to use -instead. -*/ - -#define BSF_INDIRECT 0x4000000 - -/* -*/ - flagword flags; - -/* -A pointer to the section to which this symbol is relative, or 0 if the -symbol is absolute or undefined. Note that it is not sufficient to set -this location to 0 to mark a symbol as absolute - the flag -@code{BSF_ABSOLUTE} must be set also. -*/ - - struct sec *section; - -/* -Back end special data. This is being phased out in favour of making -this a union. -*/ - - PTR udata; -} asymbol; - -/* - - get_symtab_upper_bound -Returns the number of bytes required in a vector of pointers to -@code{asymbols} for all the symbols in the supplied BFD, including a -terminal NULL pointer. If there are no symbols in the BFD, then 0 is -returned. -*/ -#define get_symtab_upper_bound(abfd) \ - BFD_SEND (abfd, _get_symtab_upper_bound, (abfd)) - -/* - - bfd_canonicalize_symtab -Supplied a BFD and a pointer to an uninitialized vector of pointers. -This reads in the symbols from the BFD, and fills in the table with -pointers to the symbols, and a trailing NULL. The routine returns the -actual number of symbol pointers not including the NULL. -*/ - -#define bfd_canonicalize_symtab(abfd, location) \ - BFD_SEND (abfd, _bfd_canonicalize_symtab,\ - (abfd, location)) - -/* - bfd_set_symtab -Provided a table of pointers to symbols and a count, writes to the -output BFD the symbols when closed. -*/ - - PROTO(boolean, bfd_set_symtab, (bfd *, asymbol **, unsigned int )); - -/* - - bfd_print_symbol_vandf -Prints the value and flags of the symbol supplied to the stream file. -*/ - - PROTO(void, bfd_print_symbol_vandf, (PTR file, asymbol *symbol)); - -/* - - bfd_make_empty_symbol -This function creates a new @code{asymbol} structure for the BFD, and -returns a pointer to it. - -This routine is necessary, since each back end has private information -surrounding the @code{asymbol}. Building your own @code{asymbol} and -pointing to it will not create the private information, and will cause -problems later on. -*/ -#define bfd_make_empty_symbol(abfd) \ - BFD_SEND (abfd, _bfd_make_empty_symbol, (abfd)) - -/* - bfd_decode_symclass -Return a lower-case character corresponding to the symbol class of symbol. -*/ - - PROTO(int, bfd_decode_symclass, (asymbol *symbol)); - -/* - - bfd_stab_name -Returns a string for the stab with the given code, or NULL if not found. -*/ - - PROTO(char *, bfd_stab_name, (int code)); - -/* -*/ - -/*:bfd.c*/ -/* @section @code{typedef bfd} - -A BFD is has type @code{bfd}; objects of this type are the cornerstone -of any application using @code{libbfd}. References though the BFD and -to data in the BFD give the entire BFD functionality. - -Here is the struct used to define the type @code{bfd}. This contains -the major data about the file, and contains pointers to the rest of -the data. -*/ - -struct _bfd -{ -/* The filename the application opened the BFD with. -*/ - - CONST char *filename; - -/* -A pointer to the target jump table. -*/ - - struct bfd_target *xvec; - -/* - -To avoid dragging too many header files into every file that -includes @file{bfd.h}, IOSTREAM has been declared as a "char *", and MTIME -as a "long". Their correct types, to which they are cast when used, -are "FILE *" and "time_t". - -The iostream is the result of an fopen on the filename. -*/ - - char *iostream; - -/* -Is the file being cached @xref{File Caching}. -*/ - - boolean cacheable; - -/* -Marks whether there was a default target specified when the BFD was -opened. This is used to select what matching algorithm to use to chose -the back end. -*/ - - boolean target_defaulted; - -/* -The caching routines use these to maintain a least-recently-used list of -BFDs (@pxref{File Caching}). -*/ - - struct _bfd *lru_prev, *lru_next; - -/* -When a file is closed by the caching routines, BFD retains state -information on the file here: -*/ - - file_ptr where; - -/* -and here: -*/ - - boolean opened_once; - -/* -*/ - boolean mtime_set; -/* File modified time -*/ - - long mtime; - -/* -Reserved for an unimplemented file locking extension. -*/ - -int ifd; - -/* -The format which belongs to the BFD. -*/ - - bfd_format format; - -/* -The direction the BFD was opened with -*/ - - enum bfd_direction {no_direction = 0, - read_direction = 1, - write_direction = 2, - both_direction = 3} direction; - -/* -Format_specific flags -*/ - - flagword flags; - -/* -Currently my_archive is tested before adding origin to anything. I -believe that this can become always an add of origin, with origin set -to 0 for non archive files. -*/ - - file_ptr origin; - -/* -Remember when output has begun, to stop strange things happening. -*/ - - boolean output_has_begun; - -/* -Pointer to linked list of sections -*/ - - struct sec *sections; - -/* -The number of sections -*/ - - unsigned int section_count; - -/* -Stuff only useful for object files: -The start address. -*/ - - bfd_vma start_address; -/* Used for input and output -*/ - - unsigned int symcount; -/* Symbol table for output BFD -*/ - - struct symbol_cache_entry **outsymbols; - -/* -Pointer to structure which contains architecture information -*/ - - struct bfd_arch_info *arch_info; - -/* -Stuff only useful for archives: -*/ - - PTR arelt_data; - struct _bfd *my_archive; - struct _bfd *next; - struct _bfd *archive_head; - boolean has_armap; - -/* -Used by the back end to hold private data. -*/ - - PTR tdata; - -/* -Used by the application to hold private data -*/ - - PTR usrdata; - -/* -Where all the allocated stuff under this BFD goes (@pxref{Memory Usage}). -*/ - - struct obstack memory; -}; - -/* - - bfd_set_start_address - -Marks the entry point of an output BFD. Returns @code{true} on -success, @code{false} otherwise. -*/ - - PROTO(boolean, bfd_set_start_address,(bfd *, bfd_vma)); - -/* - - bfd_get_mtime - -Return cached file modification time (e.g. as read from archive header -for archive members, or from file system if we have been called -before); else determine modify time, cache it, and return it. -*/ - - PROTO(long, bfd_get_mtime, (bfd *)); - -/* - - stuff -*/ - - -#define bfd_sizeof_headers(abfd, reloc) \ - BFD_SEND (abfd, _bfd_sizeof_headers, (abfd, reloc)) - -#define bfd_find_nearest_line(abfd, section, symbols, offset, filename_ptr, func, line_ptr) \ - BFD_SEND (abfd, _bfd_find_nearest_line, (abfd, section, symbols, offset, filename_ptr, func, line_ptr)) - -#define bfd_debug_info_start(abfd) \ - BFD_SEND (abfd, _bfd_debug_info_start, (abfd)) - -#define bfd_debug_info_end(abfd) \ - BFD_SEND (abfd, _bfd_debug_info_end, (abfd)) - -#define bfd_debug_info_accumulate(abfd, section) \ - BFD_SEND (abfd, _bfd_debug_info_accumulate, (abfd, section)) - -#define bfd_stat_arch_elt(abfd, stat) \ - BFD_SEND (abfd, _bfd_stat_arch_elt,(abfd, stat)) - -#define bfd_coff_swap_aux_in(a,e,t,c,i) \ - BFD_SEND (a, _bfd_coff_swap_aux_in, (a,e,t,c,i)) - -#define bfd_coff_swap_sym_in(a,e,i) \ - BFD_SEND (a, _bfd_coff_swap_sym_in, (a,e,i)) - -#define bfd_coff_swap_lineno_in(a,e,i) \ - BFD_SEND ( a, _bfd_coff_swap_lineno_in, (a,e,i)) - -#define bfd_set_arch_mach(abfd, arch, mach)\ - BFD_SEND ( abfd, _bfd_set_arch_mach, (abfd, arch, mach)) - -#define bfd_coff_swap_reloc_out(abfd, i, o) \ - BFD_SEND (abfd, _bfd_coff_swap_reloc_out, (abfd, i, o)) - -#define bfd_coff_swap_lineno_out(abfd, i, o) \ - BFD_SEND (abfd, _bfd_coff_swap_lineno_out, (abfd, i, o)) - -#define bfd_coff_swap_aux_out(abfd, i, t,c,o) \ - BFD_SEND (abfd, _bfd_coff_swap_aux_out, (abfd, i,t,c, o)) - -#define bfd_coff_swap_sym_out(abfd, i,o) \ - BFD_SEND (abfd, _bfd_coff_swap_sym_out, (abfd, i, o)) - -#define bfd_coff_swap_scnhdr_out(abfd, i,o) \ - BFD_SEND (abfd, _bfd_coff_swap_scnhdr_out, (abfd, i, o)) - -#define bfd_coff_swap_filehdr_out(abfd, i,o) \ - BFD_SEND (abfd, _bfd_coff_swap_filehdr_out, (abfd, i, o)) - -#define bfd_coff_swap_aouthdr_out(abfd, i,o) \ - BFD_SEND (abfd, _bfd_coff_swap_aouthdr_out, (abfd, i, o)) - -/* -*/ - -/*:archive.c*/ -/* bfd_get_next_mapent -What this does -*/ - PROTO(symindex, bfd_get_next_mapent, (bfd *, symindex, carsym **)); - -/* - - bfd_set_archive_head - -Used whilst processing archives. Sets the head of the chain of BFDs -contained in an archive to @var{new_head}. (see chapter on archives) -*/ - - PROTO(boolean, bfd_set_archive_head, (bfd *output, bfd *new_head)); - -/* - - bfd_get_elt_at_index -Return the sub bfd contained within the archive at archive index n. -*/ - - PROTO(bfd *, bfd_get_elt_at_index, (bfd *, int)); - -/* - - bfd_openr_next_archived_file -Initially provided a BFD containing an archive and NULL, opens a BFD -on the first contained element and returns that. Subsequent calls to -bfd_openr_next_archived_file should pass the archive and the previous -return value to return a created BFD to the next contained element. -NULL is returned when there are no more. -*/ - - PROTO(bfd*, bfd_openr_next_archived_file, - (bfd *archive, bfd *previous)); - -/* -*/ - - -/*:core.c*/ -/* bfd_core_file_failing_command -Returns a read-only string explaining what program was running when -it failed and produced the core file being read -*/ - - PROTO(CONST char *, bfd_core_file_failing_command, (bfd *)); - -/* - - bfd_core_file_failing_signal -Returns the signal number which caused the core dump which generated -the file the BFD is attached to. -*/ - - PROTO(int, bfd_core_file_failing_signal, (bfd *)); - -/* - - core_file_matches_executable_p -Returns @code{true} if the core file attached to @var{core_bfd} was -generated by a run of the executable file attached to @var{exec_bfd}, -or else @code{false}. -*/ - PROTO(boolean, core_file_matches_executable_p, - (bfd *core_bfd, bfd *exec_bfd)); - -/* -*/ - -/*:targets.c*/ -/* bfd_target -@node bfd_target, , Targets, Targets -@subsection bfd_target -This structure contains everything that BFD knows about a target. -It includes things like its byte order, name, what routines to call -to do various operations, etc. - -Every BFD points to a target structure with its "xvec" member. - -Shortcut for declaring fields which are prototyped function pointers, -while avoiding anguish on compilers that don't support protos. -*/ - -#define SDEF(ret, name, arglist) \ - PROTO(ret,(*name),arglist) -#define SDEF_FMT(ret, name, arglist) \ - PROTO(ret,(*name[bfd_type_end]),arglist) - -/* -These macros are used to dispatch to functions through the bfd_target -vector. They are used in a number of macros further down in @file{bfd.h}, and -are also used when calling various routines by hand inside the BFD -implementation. The "arglist" argument must be parenthesized; it -contains all the arguments to the called function. -*/ - -#define BFD_SEND(bfd, message, arglist) \ - ((*((bfd)->xvec->message)) arglist) - -/* -For operations which index on the BFD format -*/ - -#define BFD_SEND_FMT(bfd, message, arglist) \ - (((bfd)->xvec->message[(int)((bfd)->format)]) arglist) - -/* -This is the struct which defines the type of BFD this is. The -"xvec" member of the struct @code{bfd} itself points here. Each module -that implements access to a different target under BFD, defines -one of these. - -FIXME, these names should be rationalised with the names of the -entry points which call them. Too bad we can't have one macro to -define them both! -*/ - -typedef struct bfd_target -{ - -/* -identifies the kind of target, eg SunOS4, Ultrix, etc -*/ - - char *name; - -/* -The "flavour" of a back end is a general indication about the contents -of a file. -*/ - - enum target_flavour { - bfd_target_unknown_flavour, - bfd_target_aout_flavour, - bfd_target_coff_flavour, - bfd_target_elf_flavour, - bfd_target_ieee_flavour, - bfd_target_oasys_flavour, - bfd_target_srec_flavour} flavour; - -/* -The order of bytes within the data area of a file. -*/ - - boolean byteorder_big_p; - -/* -The order of bytes within the header parts of a file. -*/ - - boolean header_byteorder_big_p; - -/* -This is a mask of all the flags which an executable may have set - -from the set @code{NO_FLAGS}, @code{HAS_RELOC}, ...@code{D_PAGED}. -*/ - - flagword object_flags; - -/* -This is a mask of all the flags which a section may have set - from -the set @code{SEC_NO_FLAGS}, @code{SEC_ALLOC}, ...@code{SET_NEVER_LOAD}. -*/ - - flagword section_flags; - -/* -The pad character for filenames within an archive header. -*/ - - char ar_pad_char; - -/* -The maximum number of characters in an archive header. -*/ - - unsigned short ar_max_namelen; - -/* -The minimum alignment restriction for any section. -*/ - - unsigned int align_power_min; - -/* -Entries for byte swapping for data. These are different to the other -entry points, since they don't take BFD as first arg. Certain other handlers -could do the same. -*/ - - SDEF (bfd_vma, bfd_getx64, (bfd_byte *)); - SDEF (void, bfd_putx64, (bfd_vma, bfd_byte *)); - SDEF (bfd_vma, bfd_getx32, (bfd_byte *)); - SDEF (void, bfd_putx32, (bfd_vma, bfd_byte *)); - SDEF (bfd_vma, bfd_getx16, (bfd_byte *)); - SDEF (void, bfd_putx16, (bfd_vma, bfd_byte *)); - -/* -Byte swapping for the headers -*/ - - SDEF (bfd_vma, bfd_h_getx64, (bfd_byte *)); - SDEF (void, bfd_h_putx64, (bfd_vma, bfd_byte *)); - SDEF (bfd_vma, bfd_h_getx32, (bfd_byte *)); - SDEF (void, bfd_h_putx32, (bfd_vma, bfd_byte *)); - SDEF (bfd_vma, bfd_h_getx16, (bfd_byte *)); - SDEF (void, bfd_h_putx16, (bfd_vma, bfd_byte *)); - -/* -Format dependent routines, these turn into vectors of entry points -within the target vector structure; one for each format to check. - -Check the format of a file being read. Return bfd_target * or zero. -*/ - - SDEF_FMT (struct bfd_target *, _bfd_check_format, (bfd *)); - -/* -Set the format of a file being written. -*/ - - SDEF_FMT (boolean, _bfd_set_format, (bfd *)); - -/* -Write cached information into a file being written, at bfd_close. -*/ - - SDEF_FMT (boolean, _bfd_write_contents, (bfd *)); - -/* -The following functions are defined in @code{JUMP_TABLE}. The idea is -that the back end writer of @code{foo} names all the routines -@code{foo_}@var{entry_point}, @code{JUMP_TABLE} will built the entries -in this structure in the right order. - -Core file entry points -*/ - - SDEF (char *, _core_file_failing_command, (bfd *)); - SDEF (int, _core_file_failing_signal, (bfd *)); - SDEF (boolean, _core_file_matches_executable_p, (bfd *, bfd *)); - -/* -Archive entry points -*/ - - SDEF (boolean, _bfd_slurp_armap, (bfd *)); - SDEF (boolean, _bfd_slurp_extended_name_table, (bfd *)); - SDEF (void, _bfd_truncate_arname, (bfd *, CONST char *, char *)); - SDEF (boolean, write_armap, (bfd *arch, - unsigned int elength, - struct orl *map, - unsigned int orl_count, - int stridx)); - -/* -Standard stuff. -*/ - - SDEF (boolean, _close_and_cleanup, (bfd *)); - SDEF (boolean, _bfd_set_section_contents, (bfd *, sec_ptr, PTR, - file_ptr, bfd_size_type)); - SDEF (boolean, _bfd_get_section_contents, (bfd *, sec_ptr, PTR, - file_ptr, bfd_size_type)); - SDEF (boolean, _new_section_hook, (bfd *, sec_ptr)); - -/* -Symbols and reloctions -*/ - - SDEF (unsigned int, _get_symtab_upper_bound, (bfd *)); - SDEF (unsigned int, _bfd_canonicalize_symtab, - (bfd *, struct symbol_cache_entry **)); - SDEF (unsigned int, _get_reloc_upper_bound, (bfd *, sec_ptr)); - SDEF (unsigned int, _bfd_canonicalize_reloc, (bfd *, sec_ptr, arelent **, - struct symbol_cache_entry**)); - SDEF (struct symbol_cache_entry *, _bfd_make_empty_symbol, (bfd *)); - SDEF (void, _bfd_print_symbol, (bfd *, PTR, struct symbol_cache_entry *, - bfd_print_symbol_type)); -#define bfd_print_symbol(b,p,s,e) BFD_SEND(b, _bfd_print_symbol, (b,p,s,e)) - SDEF (alent *, _get_lineno, (bfd *, struct symbol_cache_entry *)); - - SDEF (boolean, _bfd_set_arch_mach, (bfd *, enum bfd_architecture, - unsigned long)); - - SDEF (bfd *, openr_next_archived_file, (bfd *arch, bfd *prev)); - SDEF (boolean, _bfd_find_nearest_line, - (bfd *abfd, struct sec *section, - struct symbol_cache_entry **symbols,bfd_vma offset, - CONST char **file, CONST char **func, unsigned int *line)); - SDEF (int, _bfd_stat_arch_elt, (bfd *, struct stat *)); - - SDEF (int, _bfd_sizeof_headers, (bfd *, boolean)); - - SDEF (void, _bfd_debug_info_start, (bfd *)); - SDEF (void, _bfd_debug_info_end, (bfd *)); - SDEF (void, _bfd_debug_info_accumulate, (bfd *, struct sec *)); - -/* -Special entry points for gdb to swap in coff symbol table parts -*/ - - SDEF(void, _bfd_coff_swap_aux_in,( - bfd *abfd , - PTR ext, - int type, - int class , - PTR in)); - - SDEF(void, _bfd_coff_swap_sym_in,( - bfd *abfd , - PTR ext, - PTR in)); - - SDEF(void, _bfd_coff_swap_lineno_in, ( - bfd *abfd, - PTR ext, - PTR in)); - -/* -Special entry points for gas to swap coff parts -*/ - - SDEF(unsigned int, _bfd_coff_swap_aux_out,( - bfd *abfd, - PTR in, - int type, - int class, - PTR ext)); - - SDEF(unsigned int, _bfd_coff_swap_sym_out,( - bfd *abfd, - PTR in, - PTR ext)); - - SDEF(unsigned int, _bfd_coff_swap_lineno_out,( - bfd *abfd, - PTR in, - PTR ext)); - - SDEF(unsigned int, _bfd_coff_swap_reloc_out,( - bfd *abfd, - PTR src, - PTR dst)); - - SDEF(unsigned int, _bfd_coff_swap_filehdr_out,( - bfd *abfd, - PTR in, - PTR out)); - - SDEF(unsigned int, _bfd_coff_swap_aouthdr_out,( - bfd *abfd, - PTR in, - PTR out)); - - SDEF(unsigned int, _bfd_coff_swap_scnhdr_out,( - bfd *abfd, - PTR in, - PTR out)); - -} bfd_target; - -/* - -*i bfd_find_target -Returns a pointer to the transfer vector for the object target -named target_name. If target_name is NULL, chooses the one in the -environment variable GNUTARGET; if that is null or not defined then -the first entry in the target list is chosen. Passing in the -string "default" or setting the environment variable to "default" -will cause the first entry in the target list to be returned, -and "target_defaulted" will be set in the BFD. This causes -@code{bfd_check_format} to loop over all the targets to find the one -that matches the file being read. -*/ - PROTO(bfd_target *, bfd_find_target,(CONST char *, bfd *)); - -/* - -*i bfd_target_list -This function returns a freshly malloced NULL-terminated vector of the -names of all the valid BFD targets. Do not modify the names -*/ - PROTO(CONST char **,bfd_target_list,()); - -/* -*/ - - -/*:format.c*/ -/* *i bfd_check_format -This routine is supplied a BFD and a format. It attempts to verify if -the file attached to the BFD is indeed compatible with the format -specified (ie, one of @code{bfd_object}, @code{bfd_archive} or -@code{bfd_core}). - -If the BFD has been set to a specific @var{target} before the call, -only the named target and format combination will be checked. If the -target has not been set, or has been set to @code{default} then all -the known target backends will be interrogated to determine a match. - -The function returns @code{true} on success, otherwise @code{false} -with one of the following error codes: -@table @code -@item -invalid_operation -if @code{format} is not one of @code{bfd_object}, @code{bfd_archive} -or @code{bfd_core}. -@item system_call_error -if an error occured during a read - even some file mismatches can -cause system_call_errros -@item file_not_recognised -none of the backends recognised the file format -@item file_ambiguously_recognized -more than one backend recognised the file format. -@end table -*/ - PROTO(boolean, bfd_check_format, (bfd *abfd, bfd_format format)); - -/* - -*i bfd_set_format -This function sets the file format of the supplied BFD to the format -requested. If the target set in the BFD does not support the format -requested, the format is illegal or the BFD is not open for writing -than an error occurs. -*/ - PROTO(boolean,bfd_set_format,(bfd *, bfd_format)); - -/* - -*i bfd_format_string -This function takes one argument, and enumerated type (bfd_format) and -returns a pointer to a const string "invalid", "object", "archive", -"core" or "unknown" depending upon the value of the enumeration. -*/ - PROTO(CONST char *, bfd_format_string, (bfd_format)); - -/* -*/ - -#endif - - - - - diff --git a/include/bout.h b/include/bout.h deleted file mode 100644 index f875670d8d6..00000000000 --- a/include/bout.h +++ /dev/null @@ -1,167 +0,0 @@ -/* - * This file is a modified version of 'a.out.h'. It is to be used in all - * GNU tools modified to support the i80960 (or tools that operate on - * object files created by such tools). - * - * All i80960 development is done in a CROSS-DEVELOPMENT environment. I.e., - * object code is generated on, and executed under the direction of a symbolic - * debugger running on, a host system. We do not want to be subject to the - * vagaries of which host it is or whether it supports COFF or a.out format, - * or anything else. We DO want to: - * - * o always generate the same format object files, regardless of host. - * - * o have an 'a.out' header that we can modify for our own purposes - * (the 80960 is typically an embedded processor and may require - * enhanced linker support that the normal a.out.h header can't - * accommodate). - * - * As for byte-ordering, the following rules apply: - * - * o Text and data that is actually downloaded to the target is always - * in i80960 (little-endian) order. - * - * o All other numbers (in the header, symbols, relocation directives) - * are in host byte-order: object files CANNOT be lifted from a - * little-end host and used on a big-endian (or vice versa) without - * modification. - * ==> THIS IS NO LONGER TRUE USING BFD. WE CAN GENERATE ANY BYTE ORDER - * FOR THE HEADER, AND READ ANY BYTE ORDER. PREFERENCE WOULD BE TO - * USE LITTLE-ENDIAN BYTE ORDER THROUGHOUT, REGARDLESS OF HOST. <== - * - * o The downloader ('comm960') takes care to generate a pseudo-header - * with correct (i80960) byte-ordering before shipping text and data - * off to the NINDY monitor in the target systems. Symbols and - * relocation info are never sent to the target. - */ - - -#define BMAGIC 0415 -/* We don't accept the following (see N_BADMAG macro). - * They're just here so GNU code will compile. - */ -#define OMAGIC 0407 /* old impure format */ -#define NMAGIC 0410 /* read-only text */ -#define ZMAGIC 0413 /* demand load format */ - -/* FILE HEADER - * All 'lengths' are given as a number of bytes. - * All 'alignments' are for relinkable files only; an alignment of - * 'n' indicates the corresponding segment must begin at an - * address that is a multiple of (2**n). - */ -struct exec { - /* Standard stuff */ - unsigned long a_magic; /* Identifies this as a b.out file */ - unsigned long a_text; /* Length of text */ - unsigned long a_data; /* Length of data */ - unsigned long a_bss; /* Length of runtime uninitialized data area */ - unsigned long a_syms; /* Length of symbol table */ - unsigned long a_entry; /* Runtime start address */ - unsigned long a_trsize; /* Length of text relocation info */ - unsigned long a_drsize; /* Length of data relocation info */ - - /* Added for i960 */ - unsigned long a_tload; /* Text runtime load address */ - unsigned long a_dload; /* Data runtime load address */ - unsigned char a_talign; /* Alignment of text segment */ - unsigned char a_dalign; /* Alignment of data segment */ - unsigned char a_balign; /* Alignment of bss segment */ - unsigned char unused; /* (Just to make struct size a multiple of 4) */ -}; - -#define N_BADMAG(x) (((x).a_magic)!=BMAGIC) -#define N_TXTOFF(x) ( sizeof(struct exec) ) -#define N_DATOFF(x) ( N_TXTOFF(x) + (x).a_text ) -#define N_TROFF(x) ( N_DATOFF(x) + (x).a_data ) -#define N_DROFF(x) ( N_TROFF(x) + (x).a_trsize ) -#define N_SYMOFF(x) ( N_DROFF(x) + (x).a_drsize ) -#define N_STROFF(x) ( N_SYMOFF(x) + (x).a_syms ) - -/* A single entry in the symbol table - */ -struct nlist { - union { - char *n_name; - struct nlist *n_next; - long n_strx; /* Index into string table */ - } n_un; - unsigned char n_type; /* See below */ - char n_other; /* Used in i80960 support -- see below */ - short n_desc; - unsigned long n_value; -}; - - -/* Legal values of n_type - */ -#define N_UNDF 0 /* Undefined symbol */ -#define N_ABS 2 /* Absolute symbol */ -#define N_TEXT 4 /* Text symbol */ -#define N_DATA 6 /* Data symbol */ -#define N_BSS 8 /* BSS symbol */ -#define N_FN 31 /* Filename symbol */ - -#define N_EXT 1 /* External symbol (OR'd in with one of above) */ -#define N_TYPE 036 /* Mask for all the type bits */ -#define N_STAB 0340 /* Mask for all bits used for SDB entries */ - -/* MEANING OF 'n_other' - * - * If non-zero, the 'n_other' fields indicates either a leaf procedure or - * a system procedure, as follows: - * - * 1 <= n_other <= 32 : - * The symbol is the entry point to a system procedure. - * 'n_value' is the address of the entry, as for any other - * procedure. The system procedure number (which can be used in - * a 'calls' instruction) is (n_other-1). These entries come from - * '.sysproc' directives. - * - * n_other == N_CALLNAME - * the symbol is the 'call' entry point to a leaf procedure. - * The *next* symbol in the symbol table must be the corresponding - * 'bal' entry point to the procedure (see following). These - * entries come from '.leafproc' directives in which two different - * symbols are specified (the first one is represented here). - * - * - * n_other == N_BALNAME - * the symbol is the 'bal' entry point to a leaf procedure. - * These entries result from '.leafproc' directives in which only - * one symbol is specified, or in which the same symbol is - * specified twice. - * - * Note that an N_CALLNAME entry *must* have a corresponding N_BALNAME entry, - * but not every N_BALNAME entry must have an N_CALLNAME entry. - */ -#define N_CALLNAME (-1) -#define N_BALNAME (-2) -#define IS_CALLNAME(x) (N_CALLNAME == (int)(x)) -#define IS_BALNAME(x) (N_BALNAME == (int)(x)) -#define IS_OTHER(x) ((x)>0 && (x) <=32) - -struct relocation_info { - int r_address; /* File address of item to be relocated */ - unsigned - r_symbolnum:24,/* Index of symbol on which relocation is based, - * if r_extern is set. Otherwise set to - * either N_TEXT, N_DATA, or N_BSS to - * indicate section on which relocation is - * based. - */ - r_pcrel:1, /* 1 => relocate PC-relative; else absolute - * On i960, pc-relative implies 24-bit - * address, absolute implies 32-bit. - */ - r_length:2, /* Number of bytes to relocate: - * 0 => 1 byte - * 1 => 2 bytes - * 2 => 4 bytes -- only value used for i960 - */ - r_extern:1, - r_bsr:1, /* Something for the GNU NS32K assembler */ - r_disp:1, /* Something for the GNU NS32K assembler */ - r_callj:1, /* 1 if relocation target is an i960 'callj' */ - nuthin:1; /* Unused */ -}; diff --git a/include/coff-a29k.h b/include/coff-a29k.h deleted file mode 100755 index 8042d51fb3a..00000000000 --- a/include/coff-a29k.h +++ /dev/null @@ -1,305 +0,0 @@ -/* COFF spec for AMD 290*0 - Contributed by David Wood @ New York University. - */ - -#ifndef AMD -# define AMD -#endif - -/****************************************************************/ - -/* -** File Header and related definitions -*/ - -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[4]; /* file pointer to symtab */ - char f_nsyms[4]; /* number of symtab entries */ - char f_opthdr[2]; /* sizeof(optional hdr) */ - char f_flags[2]; /* flags */ -}; - -#define FILHDR struct external_filehdr -#define FILHSZ sizeof (FILHDR) - -/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/ - -/* -** Magic numbers for Am29000 -** (AT&T will assign the "real" magic number) -*/ - -#define SIPFBOMAGIC 0572 /* Am29000 (Byte 0 is MSB) */ -#define SIPRBOMAGIC 0573 /* Am29000 (Byte 0 is LSB) */ - - -#define A29K_MAGIC_BIG SIPFBOMAGIC -#define A29K_MAGIC_LITTLE SIPRBOMAGIC -#define A29KBADMAG(x) (((x).f_magic!=A29K_MAGIC_BIG) && \ - ((x).f_magic!=A29K_MAGIC_LITTLE)) - -#define OMAGIC A29K_MAGIC_BIG -/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/ - -/* -** File header flags currently known to us. -** -** Am29000 will use the F_AR32WR and F_AR32W flags to indicate -** the byte ordering in the file. -*/ - -/*--------------------------------------------------------------*/ - -/* -** Optional (a.out) header -*/ - -typedef struct external_aouthdr -{ - char magic[2]; /* type of file */ - char vstamp[2]; /* version stamp */ - char tsize[4]; /* text size in bytes, padded to FW bdry*/ - char dsize[4]; /* initialized data " " */ - char bsize[4]; /* uninitialized data " " */ - char entry[4]; /* entry pt. */ - char text_start[4]; /* base of text used for this file */ - char data_start[4]; /* base of data used for this file */ -} AOUTHDR; - -#define AOUTSZ (sizeof(AOUTHDR)) -#define AOUTHDRSZ (sizeof(AOUTHDR)) - -/* aouthdr magic numbers */ -#define NMAGIC 0410 /* separate i/d executable */ -#define SHMAGIC 0406 /* NYU/Ultra3 shared data executable - (writable text) */ - -#define _ETEXT "_etext" - -/*--------------------------------------------------------------*/ - -/* -** Section header and related definitions -*/ - -struct external_scnhdr -{ - char s_name[8]; /* section name */ - char s_paddr[4]; /* physical address, aliased s_nlib */ - char s_vaddr[4]; /* virtual address */ - char s_size[4]; /* section size */ - char s_scnptr[4]; /* file ptr to raw data for section */ - char s_relptr[4]; /* file ptr to relocation */ - char s_lnnoptr[4]; /* file ptr to line numbers */ - char s_nreloc[2]; /* number of relocation entries */ - char s_nlnno[2]; /* number of line number entries*/ - char s_flags[4]; /* flags */ -}; - -#define SCNHDR struct external_scnhdr -#define SCNHSZ sizeof (SCNHDR) - -/* - * names of "special" sections - */ -#define _TEXT ".text" -#define _DATA ".data" -#define _BSS ".bss" - -/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/ - -/* -** Section types - with additional section type for global -** registers which will be relocatable for the Am29000. -** -** In instances where it is necessary for a linker to produce an -** output file which contains text or data not based at virtual -** address 0, e.g. for a ROM, then the linker should accept -** address base information as command input and use PAD sections -** to skip over unused addresses. -*/ - -#define STYP_BSSREG 0x1200 /* Global register area (like STYP_INFO) */ -#define STYP_ENVIR 0x2200 /* Environment (like STYP_INFO) */ -#define STYP_ABS 0x4000 /* Absolute (allocated, not reloc, loaded) */ -#define STYP_LIT 0x8020 /* Literal data (like STYP_TEXT) */ - -/*--------------------------------------------------------------*/ - -/* -** Relocation information declaration and related definitions -*/ - -struct external_reloc { - char r_vaddr[4]; /* (virtual) address of reference */ - char r_symndx[4]; /* index into symbol table */ - char r_type[2]; /* relocation type */ -}; - -#define RELOC struct external_reloc -#define RELSZ 10 /* sizeof (RELOC) */ - -/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/ - -/* -** Relocation types for the Am29000 -*/ - -#define R_ABS 0 /* reference is absolute */ - -#define R_IREL 030 /* instruction relative (jmp/call) */ -#define R_IABS 031 /* instruction absolute (jmp/call) */ -#define R_ILOHALF 032 /* instruction low half (const) */ -#define R_IHIHALF 033 /* instruction high half (consth) part 1 */ -#define R_IHCONST 034 /* instruction high half (consth) part 2 */ - /* constant offset of R_IHIHALF relocation */ -#define R_BYTE 035 /* relocatable byte value */ -#define R_HWORD 036 /* relocatable halfword value */ -#define R_WORD 037 /* relocatable word value */ - -#define R_IGLBLRC 040 /* instruction global register RC */ -#define R_IGLBLRA 041 /* instruction global register RA */ -#define R_IGLBLRB 042 /* instruction global register RB */ - -/* -NOTE: -All the "I" forms refer to 29000 instruction formats. The linker is -expected to know how the numeric information is split and/or aligned -within the instruction word(s). R_BYTE works for instructions, too. - -If the parameter to a CONSTH instruction is a relocatable type, two -relocation records are written. The first has an r_type of R_IHIHALF -(33 octal) and a normal r_vaddr and r_symndx. The second relocation -record has an r_type of R_IHCONST (34 octal), a normal r_vaddr (which -is redundant), and an r_symndx containing the 32-bit constant offset -to the relocation instead of the actual symbol table index. This -second record is always written, even if the constant offset is zero. -The constant fields of the instruction are set to zero. -*/ - -/*--------------------------------------------------------------*/ - -/* -** Line number entry declaration and related definitions -*/ - -struct external_lineno -{ - union { - char l_symndx[4]; /* function name symbol index, iff l_lnno == 0*/ - char l_paddr[4]; /* (physical) address of line number */ - } l_addr; - char l_lnno[2]; /* line number */ -}; - -#define LINENO struct external_lineno -#define LINESZ 6 /* sizeof (LINENO) */ - -/*--------------------------------------------------------------*/ - -/* -** Symbol entry declaration and related definitions -*/ - -#define E_SYMNMLEN 8 /* Number of characters in a symbol name */ - -struct external_syment -{ - union { - char e_name[E_SYMNMLEN]; - struct { - char e_zeroes[4]; - char e_offset[4]; - } e; - } e; - char e_value[4]; - char e_scnum[2]; - char e_type[2]; - char e_sclass[1]; - char e_numaux[1]; -}; - -#define SYMENT struct external_syment -#define SYMESZ sizeof(SYMENT) - -/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/ - -/* -** Storage class definitions - new classes for global registers. -*/ - -#define C_GLBLREG 19 /* global register */ -#define C_EXTREG 20 /* external global register */ -#define C_DEFREG 21 /* ext. def. of global register */ - - -/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/ - -/* -** Derived symbol mask/shifts. -*/ - -#define N_BTMASK (0xf) -#define N_BTSHFT (4) -#define N_TMASK (0x30) -#define N_TSHIFT (2) - -/*--------------------------------------------------------------*/ - -/* -** Auxiliary symbol table entry declaration and related -** definitions. -*/ - -#define E_FILNMLEN 14 /* # characters in a file name */ -#define E_DIMNUM 4 /* # array dimensions in auxiliary entry */ - -union external_auxent { - struct { - char x_tagndx[4]; /* str, un, or enum tag indx */ - union { - struct { - char x_lnno[2]; /* declaration line number */ - char x_size[2]; /* str/union/array size */ - } x_lnsz; - char x_fsize[4]; /* size of function */ - } x_misc; - union { - struct { /* if ISFCN, tag, or .bb */ - char x_lnnoptr[4]; /* ptr to fcn line # */ - char x_endndx[4]; /* entry ndx past block end */ - } x_fcn; - struct { /* if ISARY, up to 4 dimen. */ - char x_dimen[E_DIMNUM][2]; - } x_ary; - } x_fcnary; - char x_tvndx[2]; /* tv index */ - } x_sym; - - union { - char x_fname[E_FILNMLEN]; - struct { - char x_zeroes[4]; - char x_offset[4]; - } x_n; - } x_file; - - struct { - char x_scnlen[4]; /* section length */ - char x_nreloc[2]; /* # relocation entries */ - char x_nlinno[2]; /* # line numbers */ - } x_scn; - - struct { - char x_tvfill[4]; /* tv fill value */ - char x_tvlen[2]; /* length of .tv */ - char x_tvran[2][2]; /* tv range */ - } x_tv; /* info about .tv section (in auxent of symbol .tv)) */ -}; - -#define AUXENT union external_auxent -#define AUXESZ 18 diff --git a/include/coff-i386.h b/include/coff-i386.h deleted file mode 100755 index 0683692ff77..00000000000 --- a/include/coff-i386.h +++ /dev/null @@ -1,316 +0,0 @@ -/*** coff information for M68K */ - - -/********************** 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[4]; /* file pointer to symtab */ - char f_nsyms[4]; /* number of symtab entries */ - char f_opthdr[2]; /* sizeof(optional hdr) */ - char f_flags[2]; /* flags */ -}; - - -/* Bits for f_flags: - * F_RELFLG relocation info stripped from file - * F_EXEC file is executable (no unresolved external references) - * F_LNNO line numbers stripped from file - * F_LSYMS local symbols stripped from file - * F_AR32WR file has byte ordering of an AR32WR machine (e.g. vax) - */ - -#define F_RELFLG (0x0001) -#define F_EXEC (0x0002) -#define F_LNNO (0x0004) -#define F_LSYMS (0x0008) - - - -#define I386MAGIC 0x14c -#define I386BADMAG(x) (((x).f_magic!=I386MAGIC)) - - -#define FILHDR struct external_filehdr -#define FILHSZ sizeof(FILHDR) - - -/********************** AOUT "OPTIONAL HEADER" **********************/ - - -typedef struct -{ - char magic[2]; /* type of file */ - char vstamp[2]; /* version stamp */ - char tsize[4]; /* text size in bytes, padded to FW bdry*/ - char dsize[4]; /* initialized data " " */ - char bsize[4]; /* uninitialized data " " */ - char entry[4]; /* entry pt. */ - char text_start[4]; /* base of text used for this file */ - char data_start[4]; /* base of data used for this file */ -} -AOUTHDR; - -#define AOUTSZ (sizeof(AOUTHDR)) - - -/********************** STORAGE CLASSES **********************/ - -#define C_EFCN -1 /* physical end of function */ -#define C_NULL 0 -#define C_AUTO 1 /* automatic variable */ -#define C_EXT 2 /* external symbol */ -#define C_STAT 3 /* static */ -#define C_REG 4 /* register variable */ -#define C_EXTDEF 5 /* external definition */ -#define C_LABEL 6 /* label */ -#define C_ULABEL 7 /* undefined label */ -#define C_MOS 8 /* member of structure */ -#define C_ARG 9 /* function argument */ -#define C_STRTAG 10 /* structure tag */ -#define C_MOU 11 /* member of union */ -#define C_UNTAG 12 /* union tag */ -#define C_TPDEF 13 /* type definition */ -#define C_USTATIC 14 /* undefined static */ -#define C_ENTAG 15 /* enumeration tag */ -#define C_MOE 16 /* member of enumeration */ -#define C_REGPARM 17 /* register parameter */ -#define C_FIELD 18 /* bit field */ -#define C_AUTOARG 19 /* auto argument */ -#define C_LASTENT 20 /* dummy entry (end of block) */ -#define C_BLOCK 100 /* ".bb" or ".eb" */ -#define C_FCN 101 /* ".bf" or ".ef" */ -#define C_EOS 102 /* end of structure */ -#define C_FILE 103 /* file name */ -#define C_LINE 104 /* line # reformatted as symbol table entry */ -#define C_ALIAS 105 /* duplicate tag */ -#define C_HIDDEN 106 /* ext symbol in dmert public lib */ - -/********************** SECTION HEADER **********************/ - - -struct external_scnhdr { - char s_name[8]; /* section name */ - char s_paddr[4]; /* physical address, aliased s_nlib */ - char s_vaddr[4]; /* virtual address */ - char s_size[4]; /* section size */ - char s_scnptr[4]; /* file ptr to raw data for section */ - char s_relptr[4]; /* file ptr to relocation */ - char s_lnnoptr[4]; /* file ptr to line numbers */ - char s_nreloc[2]; /* number of relocation entries */ - char s_nlnno[2]; /* number of line number entries*/ - char s_flags[4]; /* flags */ -}; - -/* - * names of "special" sections - */ -#define _TEXT ".text" -#define _DATA ".data" -#define _BSS ".bss" -#define _COMMENT ".comment" - -/* - * s_flags "type" - */ -#define STYP_REG (0x0000) /* "regular": allocated, relocated, loaded */ -#define STYP_DSECT (0x0001) /* "dummy": relocated only*/ -#define STYP_NOLOAD (0x0002) /* "noload": allocated, relocated, not loaded */ -#define STYP_GROUP (0x0004) /* "grouped": formed of input sections */ -#define STYP_PAD (0x0008) /* "padding": not allocated, not relocated, loaded */ -#define STYP_COPY (0x0010) /* "copy": for decision function used by field update; not allocated, not relocated, - loaded; reloc & lineno entries processed normally */ -#define STYP_TEXT (0x0020) /* section contains text only */ -#define S_SHRSEG (0x0020) /* In 3b Update files (output of ogen), sections which appear in SHARED segments of the Pfile - will have the S_SHRSEG flag set by ogen, to inform dufr that updating 1 copy of the proc. will - update all process invocations. */ -#define STYP_DATA (0x0040) /* section contains data only */ -#define STYP_BSS (0x0080) /* section contains bss only */ -#define S_NEWFCN (0x0100) /* In a minimal file or an update file, a new function (as compared with a replaced function) */ -#define STYP_INFO (0x0200) /* comment: not allocated not relocated, not loaded */ -#define STYP_OVER (0x0400) /* overlay: relocated not allocated or loaded */ -#define STYP_LIB (0x0800) /* for .lib: same as INFO */ -#define STYP_MERGE (0x2000) /* merge section -- combines with text, data or bss sections only */ -#define STYP_REVERSE_PAD (0x4000) /* section will be padded with no-op instructions wherever padding is necessary and there is a - word of contiguous bytes beginning on a word boundary. */ - -#define SCNHDR struct external_scnhdr -#define SCNHSZ sizeof(SCNHDR) - - -/********************** 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[4]; /* (physical) address of line number */ - } l_addr; - char l_lnno[2]; /* line number */ -}; - - -#define LINENO struct external_lineno -#define LINESZ 6 - - -/********************** SYMBOLS **********************/ - -#define E_SYMNMLEN 8 /* # characters in a symbol name */ -#define E_FILNMLEN 14 /* # characters in a file name */ -#define E_DIMNUM 4 /* # array dimensions in auxiliary entry */ - -struct external_syment -{ - union { - char e_name[E_SYMNMLEN]; - struct { - char e_zeroes[4]; - char e_offset[4]; - } e; - } e; - char e_value[4]; - char e_scnum[2]; - char e_type[2]; - char e_sclass[1]; - char e_numaux[1]; -}; - - -/*#define n_name _n._n_name -#define n_ptr _n._n_nptr[1] -#define n_zeroes _n._n_n._n_zeroes -#define n_offset _n._n_n._n_offset -*/ - -/* - * Relocatable symbols have number of the section in which they are defined, - * or one of the following: - */ -#define N_UNDEF ((short)0) /* undefined symbol */ -#define N_ABS ((short)-1) /* value of symbol is absolute */ -#define N_DEBUG ((short)-2) /* debugging symbol -- value is meaningless */ -#define N_TV ((short)-3) /* indicates symbol needs preload transfer vector */ -#define P_TV ((short)-4) /* indicates symbol needs postload transfer vector*/ - -/* - * Type of a symbol, in low 4 bits of the word - */ -#define T_NULL 0 -#define T_VOID 1 /* function argument (only used by compiler) */ -#define T_CHAR 2 /* character */ -#define T_SHORT 3 /* short integer */ -#define T_INT 4 /* integer */ -#define T_LONG 5 /* long integer */ -#define T_FLOAT 6 /* floating point */ -#define T_DOUBLE 7 /* double word */ -#define T_STRUCT 8 /* structure */ -#define T_UNION 9 /* union */ -#define T_ENUM 10 /* enumeration */ -#define T_MOE 11 /* member of enumeration*/ -#define T_UCHAR 12 /* unsigned character */ -#define T_USHORT 13 /* unsigned short */ -#define T_UINT 14 /* unsigned integer */ -#define T_ULONG 15 /* unsigned long */ -#define T_LNGDBL 16 /* long double */ - -/* - * derived types, in n_type -*/ -#define DT_NON (0) /* no derived type */ -#define DT_PTR (1) /* pointer */ -#define DT_FCN (2) /* function */ -#define DT_ARY (3) /* array */ - -#define N_BTMASK (0xf) -#define N_TMASK (0x30) -#define N_BTSHFT (4) -#define N_TSHIFT (2) - -#define BTYPE(x) ((x) & N_BTMASK) - -#define ISPTR(x) (((x) & N_TMASK) == (DT_PTR << N_BTSHFT)) -#define ISFCN(x) (((x) & N_TMASK) == (DT_FCN << N_BTSHFT)) -#define ISARY(x) (((x) & N_TMASK) == (DT_ARY << N_BTSHFT)) - -#define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK)) - -union external_auxent { - struct { - char x_tagndx[4]; /* str, un, or enum tag indx */ - union { - struct { - char x_lnno[2]; /* declaration line number */ - char x_size[2]; /* str/union/array size */ - } x_lnsz; - char x_fsize[4]; /* size of function */ - } x_misc; - union { - struct { /* if ISFCN, tag, or .bb */ - char x_lnnoptr[4]; /* ptr to fcn line # */ - char x_endndx[4]; /* entry ndx past block end */ - } x_fcn; - struct { /* if ISARY, up to 4 dimen. */ - char x_dimen[E_DIMNUM][2]; - } x_ary; - } x_fcnary; - char x_tvndx[2]; /* tv index */ - } x_sym; - - union { - char x_fname[E_FILNMLEN]; - struct { - char x_zeroes[4]; - char x_offset[4]; - } x_n; - } x_file; - - struct { - char x_scnlen[4]; /* section length */ - char x_nreloc[2]; /* # relocation entries */ - char x_nlinno[2]; /* # line numbers */ - } x_scn; - - struct { - char x_tvfill[4]; /* tv fill value */ - char x_tvlen[2]; /* length of .tv */ - char x_tvran[2][2]; /* tv range */ - } x_tv; /* info about .tv section (in auxent of symbol .tv)) */ - - -}; - -#define SYMENT struct external_syment -#define SYMESZ 18 -#define AUXENT union external_auxent -#define AUXESZ 18 - - -# define _ETEXT "etext" - - -/********************** RELOCATION DIRECTIVES **********************/ - - - -struct external_reloc { - char r_vaddr[4]; - char r_symndx[4]; - char r_type[2]; -}; - - -#define RELOC struct external_reloc -#define RELSZ 10 - -#define DEFAULT_DATA_SECTION_ALIGNMENT 4 -#define DEFAULT_BSS_SECTION_ALIGNMENT 4 -#define DEFAULT_TEXT_SECTION_ALIGNMENT 4 -/* For new sections we havn't heard of before */ -#define DEFAULT_SECTION_ALIGNMENT 4 diff --git a/include/coff-i960.h b/include/coff-i960.h deleted file mode 100755 index 871aa87c750..00000000000 --- a/include/coff-i960.h +++ /dev/null @@ -1,254 +0,0 @@ -/*** coff information for 80960. Origins: Intel corp, natch. */ - -/* NOTE: Tagentries (cf TAGBITS) are no longer used by the 960 */ - -/********************** 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[4]; /* file pointer to symtab */ - char f_nsyms[4]; /* number of symtab entries */ - char f_opthdr[2]; /* sizeof(optional hdr) */ - char f_flags[2]; /* flags */ -}; - -#define OMAGIC (0407) /* old impure format. data immediately - follows text. both sections are rw. */ -#define NMAGIC (0410) /* split i&d, read-only text */ - -/* -* Intel 80960 (I960) processor flags. -* F_I960TYPE == mask for processor type field. -*/ - -#define F_I960TYPE (0xf000) -#define F_I960CORE (0x1000) -#define F_I960KB (0x2000) -#define F_I960SB (0x2000) -#define F_I960MC (0x3000) -#define F_I960XA (0x4000) -#define F_I960CA (0x5000) -#define F_I960KA (0x6000) -#define F_I960SA (0x6000) - - -/** i80960 Magic Numbers -*/ - -#define I960ROMAGIC (0x160) /* read-only text segments */ -#define I960RWMAGIC (0x161) /* read-write text segments */ - -#define I960BADMAG(x) (((x).f_magic!=I960ROMAGIC) && ((x).f_magic!=I960RWMAGIC)) - -#define FILHDR struct external_filehdr -#define FILHSZ 20 - -/********************** AOUT "OPTIONAL HEADER" **********************/ - -typedef struct { - unsigned long phys_addr; - unsigned long bitarray; -} TAGBITS; - - - -typedef struct -{ - char magic[2]; /* type of file */ - char vstamp[2]; /* version stamp */ - char tsize[4]; /* text size in bytes, padded to FW bdry*/ - char dsize[4]; /* initialized data " " */ - char bsize[4]; /* uninitialized data " " */ - char entry[4]; /* entry pt. */ - char text_start[4]; /* base of text used for this file */ - char data_start[4]; /* base of data used for this file */ - char tagentries[4]; /* number of tag entries to follow */ -} -AOUTHDR; - -/* return a pointer to the tag bits array */ - -#define TAGPTR(aout) ((TAGBITS *) (&(aout.tagentries)+1)) - -/* compute size of a header */ - -/*#define AOUTSZ(aout) (sizeof(AOUTHDR)+(aout.tagentries*sizeof(TAGBITS)))*/ -#define AOUTSZ (sizeof(AOUTHDR)) - - - -/********************** SECTION HEADER **********************/ - - -struct external_scnhdr { - char s_name[8]; /* section name */ - char s_paddr[4]; /* physical address, aliased s_nlib */ - char s_vaddr[4]; /* virtual address */ - char s_size[4]; /* section size */ - char s_scnptr[4]; /* file ptr to raw data for section */ - char s_relptr[4]; /* file ptr to relocation */ - char s_lnnoptr[4]; /* file ptr to line numbers */ - char s_nreloc[2]; /* number of relocation entries */ - char s_nlnno[2]; /* number of line number entries*/ - char s_flags[4]; /* flags */ - char s_align[4]; /* section alignment */ -}; - - -#define SCNHDR struct external_scnhdr -#define SCNHSZ sizeof(SCNHDR) - -/* - * names of "special" sections - */ -#define _TEXT ".text" -#define _DATA ".data" -#define _BSS ".bss" - -/********************** 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[4]; /* (physical) address of line number */ - } l_addr; - char l_lnno[2]; /* line number */ - char padding[2]; /* force alignment */ -}; - - -#define LINENO struct external_lineno -#define LINESZ 8 - - -/********************** SYMBOLS **********************/ - -#define E_SYMNMLEN 8 /* # characters in a symbol name */ -#define E_FILNMLEN 14 /* # characters in a file name */ -#define E_DIMNUM 4 /* # array dimensions in auxiliary entry */ - -struct external_syment -{ - union { - char e_name[E_SYMNMLEN]; - struct { - char e_zeroes[4]; - char e_offset[4]; - } e; - } e; - char e_value[4]; - char e_scnum[2]; - char e_flags[2]; - char e_type[4]; - char e_sclass[1]; - char e_numaux[1]; - char pad2[2]; -}; - - - - -#define N_BTMASK (0x1f) -#define N_TMASK (0x60) -#define N_BTSHFT (5) -#define N_TSHIFT (2) - -union external_auxent { - struct { - char x_tagndx[4]; /* str, un, or enum tag indx */ - union { - struct { - char x_lnno[2]; /* declaration line number */ - char x_size[2]; /* str/union/array size */ - } x_lnsz; - char x_fsize[4]; /* size of function */ - } x_misc; - union { - struct { /* if ISFCN, tag, or .bb */ - char x_lnnoptr[4]; /* ptr to fcn line # */ - char x_endndx[4]; /* entry ndx past block end */ - } x_fcn; - struct { /* if ISARY, up to 4 dimen. */ - char x_dimen[E_DIMNUM][2]; - } x_ary; - } x_fcnary; - char x_tvndx[2]; /* tv index */ - } x_sym; - - union { - char x_fname[E_FILNMLEN]; - struct { - char x_zeroes[4]; - char x_offset[4]; - } x_n; - } x_file; - - struct { - char x_scnlen[4]; /* section length */ - char x_nreloc[2]; /* # relocation entries */ - char x_nlinno[2]; /* # line numbers */ - } x_scn; - - struct { - char x_tvfill[4]; /* tv fill value */ - char x_tvlen[2]; /* length of .tv */ - char x_tvran[2][2]; /* tv range */ - } x_tv; /* info about .tv section (in auxent of symbol .tv)) */ - - /****************************************** - * I960-specific *2nd* aux. entry formats - ******************************************/ - struct { - /* This is a very old typo that keeps getting propagated. */ -#define x_stdindx x_stindx - char x_stindx[4]; /* sys. table entry */ - } x_sc; /* system call entry */ - - struct { - char x_balntry[4]; /* BAL entry point */ - } x_bal; /* BAL-callable function */ - - struct { - char x_timestamp[4]; /* time stamp */ - char x_idstring[20]; /* producer identity string */ - } x_ident; /* Producer ident info */ - -}; - - - -#define SYMENT struct external_syment -#define SYMESZ sizeof(SYMENT) /* FIXME - calc by hand */ -#define AUXENT union external_auxent -#define AUXESZ sizeof(AUXENT) /* FIXME - calc by hand */ - -# define _ETEXT "_etext" - -/********************** RELOCATION DIRECTIVES **********************/ - -struct external_reloc { - char r_vaddr[4]; - char r_symndx[4]; - char r_type[2]; - char pad[2]; -}; - - -/* Relevent values for r_type and i960. Would someone please document them */ - - -#define RELOC struct external_reloc -#define RELSZ 12 - -#define DEFAULT_DATA_SECTION_ALIGNMENT 4 -#define DEFAULT_BSS_SECTION_ALIGNMENT 4 -#define DEFAULT_TEXT_SECTION_ALIGNMENT 16 -/* For new sections we havn't heard of before */ -#define DEFAULT_SECTION_ALIGNMENT 4 diff --git a/include/coff-m68k.h b/include/coff-m68k.h deleted file mode 100755 index 815dcb27ab7..00000000000 --- a/include/coff-m68k.h +++ /dev/null @@ -1,201 +0,0 @@ -/*** coff information for M68K */ - -/********************** 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[4]; /* file pointer to symtab */ - char f_nsyms[4]; /* number of symtab entries */ - char f_opthdr[2]; /* sizeof(optional hdr) */ - char f_flags[2]; /* flags */ -}; - - -/* Motorola 68000/68008/68010/68020 */ -#define MC68MAGIC 0520 -#define MC68KWRMAGIC 0520 /* writeable text segments */ -#define MC68TVMAGIC 0521 -#define MC68KROMAGIC 0521 /* readonly shareable text segments */ -#define MC68KPGMAGIC 0522 /* demand paged text segments */ -#define M68MAGIC 0210 -#define M68TVMAGIC 0211 - -#define M68KBADMAG(x) (((x).f_magic!=MC68MAGIC) && ((x).f_magic!=MC68KWRMAGIC) && ((x).f_magic!=MC68TVMAGIC) && \ - ((x).f_magic!=MC68KROMAGIC) && ((x).f_magic!=MC68KPGMAGIC) && ((x).f_magic!=M68MAGIC) && ((x).f_magic!=M68TVMAGIC) ) - - - -#define FILHDR struct external_filehdr -#define FILHSZ sizeof(FILHDR) - - -/********************** AOUT "OPTIONAL HEADER" **********************/ - - -typedef struct -{ - char magic[2]; /* type of file */ - char vstamp[2]; /* version stamp */ - char tsize[4]; /* text size in bytes, padded to FW bdry*/ - char dsize[4]; /* initialized data " " */ - char bsize[4]; /* uninitialized data " " */ - char entry[4]; /* entry pt. */ - char text_start[4]; /* base of text used for this file */ - char data_start[4]; /* base of data used for this file */ -} -AOUTHDR; - -#define AOUTSZ (sizeof(AOUTHDR)) - - - -/********************** SECTION HEADER **********************/ - - -struct external_scnhdr { - char s_name[8]; /* section name */ - char s_paddr[4]; /* physical address, aliased s_nlib */ - char s_vaddr[4]; /* virtual address */ - char s_size[4]; /* section size */ - char s_scnptr[4]; /* file ptr to raw data for section */ - char s_relptr[4]; /* file ptr to relocation */ - char s_lnnoptr[4]; /* file ptr to line numbers */ - char s_nreloc[2]; /* number of relocation entries */ - char s_nlnno[2]; /* number of line number entries*/ - char s_flags[4]; /* flags */ -}; - -/* - * names of "special" sections - */ -#define _TEXT ".text" -#define _DATA ".data" -#define _BSS ".bss" - - -#define SCNHDR struct external_scnhdr -#define SCNHSZ sizeof(SCNHDR) - - -/********************** 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[4]; /* (physical) address of line number */ - } l_addr; - char l_lnno[2]; /* line number */ -}; - - -#define LINENO struct external_lineno -#define LINESZ sizeof(LINENO) - - -/********************** SYMBOLS **********************/ - -#define E_SYMNMLEN 8 /* # characters in a symbol name */ -#define E_FILNMLEN 14 /* # characters in a file name */ -#define E_DIMNUM 4 /* # array dimensions in auxiliary entry */ - -struct external_syment -{ - union { - char e_name[E_SYMNMLEN]; - struct { - char e_zeroes[4]; - char e_offset[4]; - } e; - } e; - char e_value[4]; - char e_scnum[2]; - char e_type[2]; - char e_sclass[1]; - char e_numaux[1]; -}; - - - -#define N_BTMASK (017) -#define N_TMASK (060) -#define N_BTSHFT (4) -#define N_TSHIFT (2) - - -union external_auxent { - struct { - char x_tagndx[4]; /* str, un, or enum tag indx */ - union { - struct { - char x_lnno[2]; /* declaration line number */ - char x_size[2]; /* str/union/array size */ - } x_lnsz; - char x_fsize[4]; /* size of function */ - } x_misc; - union { - struct { /* if ISFCN, tag, or .bb */ - char x_lnnoptr[4]; /* ptr to fcn line # */ - char x_endndx[4]; /* entry ndx past block end */ - } x_fcn; - struct { /* if ISARY, up to 4 dimen. */ - char x_dimen[E_DIMNUM][2]; - } x_ary; - } x_fcnary; - char x_tvndx[2]; /* tv index */ - } x_sym; - - union { - char x_fname[E_FILNMLEN]; - struct { - char x_zeroes[4]; - char x_offset[4]; - } x_n; - } x_file; - - struct { - char x_scnlen[4]; /* section length */ - char x_nreloc[2]; /* # relocation entries */ - char x_nlinno[2]; /* # line numbers */ - } x_scn; - - struct { - char x_tvfill[4]; /* tv fill value */ - char x_tvlen[2]; /* length of .tv */ - char x_tvran[2][2]; /* tv range */ - } x_tv; /* info about .tv section (in auxent of symbol .tv)) */ - - -}; - -#define SYMENT struct external_syment -#define SYMESZ 18 -#define AUXENT union external_auxent -#define AUXESZ 18 - - - -/********************** RELOCATION DIRECTIVES **********************/ - - -struct external_reloc { - char r_vaddr[4]; - char r_symndx[4]; - char r_type[2]; -}; - - -#define RELOC struct external_reloc -#define RELSZ 10 - -#define DEFAULT_DATA_SECTION_ALIGNMENT 4 -#define DEFAULT_BSS_SECTION_ALIGNMENT 4 -#define DEFAULT_TEXT_SECTION_ALIGNMENT 4 -/* For new sections we havn't heard of before */ -#define DEFAULT_SECTION_ALIGNMENT 4 diff --git a/include/coff-m88k.h b/include/coff-m88k.h deleted file mode 100755 index 9ed4deb6649..00000000000 --- a/include/coff-m88k.h +++ /dev/null @@ -1,251 +0,0 @@ -/*** coff information for 88k bcs */ - -/********************** 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[4]; /* file pointer to symtab */ - char f_nsyms[4]; /* number of symtab entries */ - char f_opthdr[2]; /* sizeof(optional hdr) */ - char f_flags[2]; /* flags */ -}; - -#define MC88MAGIC 0540 /* 88k BCS executable */ -#define MC88DMAGIC 0541 /* DG/UX executable */ -#define MC88OMAGIC 0555 /* Object file */ - -#define MC88BADMAG(x) (((x).f_magic!=MC88MAGIC) &&((x).f_magic!=MC88DMAGIC) && ((x).f_magic != MC88OMAGIC)) - -#define FILHDR struct external_filehdr -#define FILHSZ sizeof(FILHDR) - - -/********************** AOUT "OPTIONAL HEADER" **********************/ - - -#define PAGEMAGIC3 0414 /* Split i&d, zero mapped */ -#define PAGEMAGICBCS 0413 - - -typedef struct -{ - char magic[2]; /* type of file */ - char vstamp[2]; /* version stamp */ - char tsize[4]; /* text size in bytes, padded to FW bdry*/ - char dsize[4]; /* initialized data " " */ - char bsize[4]; /* uninitialized data " " */ - char entry[4]; /* entry pt. */ - char text_start[4]; /* base of text used for this file */ - char data_start[4]; /* base of data used for this file */ -} -AOUTHDR; - - -/* compute size of a header */ - -#define AOUTSZ (sizeof(AOUTHDR)) - -/********************** STORAGE CLASSES **********************/ - -#define C_EFCN -1 /* physical end of function */ -#define C_NULL 0 -#define C_AUTO 1 /* automatic variable */ -#define C_EXT 2 /* external symbol */ -#define C_STAT 3 /* static */ -#define C_REG 4 /* register variable */ -#define C_EXTDEF 5 /* external definition */ -#define C_LABEL 6 /* label */ -#define C_ULABEL 7 /* undefined label */ -#define C_MOS 8 /* member of structure */ -#define C_ARG 9 /* function argument */ -#define C_STRTAG 10 /* structure tag */ -#define C_MOU 11 /* member of union */ -#define C_UNTAG 12 /* union tag */ -#define C_TPDEF 13 /* type definition */ -#define C_USTATIC 14 /* undefined static */ -#define C_ENTAG 15 /* enumeration tag */ -#define C_MOE 16 /* member of enumeration */ -#define C_REGPARM 17 /* register parameter */ -#define C_FIELD 18 /* bit field */ -#define C_BLOCK 100 /* ".bb" or ".eb" */ -#define C_FCN 101 /* ".bf" or ".ef" */ -#define C_EOS 102 /* end of structure */ -#define C_FILE 103 /* file name */ -#define C_LINE 104 /* line # reformatted as symbol table entry */ -#define C_ALIAS 105 /* duplicate tag */ -#define C_HIDDEN 106 /* ext symbol in dmert public lib */ -#define C_SHADOW 107 /* shadow symbol */ -#define C_VERSION 108 /* coff version symbol */ - - -/********************** SECTION HEADER **********************/ - - -struct external_scnhdr -{ - char s_name[8]; /* section name */ - char s_paddr[4]; /* physical address, aliased s_nlib */ - char s_vaddr[4]; /* virtual address */ - char s_size[4]; /* section size */ - char s_scnptr[4]; /* file ptr to raw data for section */ - char s_relptr[4]; /* file ptr to relocation */ - char s_lnnoptr[4]; /* 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 */ -}; - - -#define SCNHDR struct external_scnhdr -#define SCNHSZ sizeof(SCNHDR) - -/* - * names of "special" sections - */ -#define _TEXT ".text" -#define _DATA ".data" -#define _BSS ".bss" - -/********************** 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[4]; /* (physical) address of line number */ - } l_addr; - - char l_lnno[4]; - -}; - -#define LINENO struct external_lineno -#define LINESZ 8 - - -/********************** SYMBOLS **********************/ - -#define E_SYMNMLEN 8 /* # characters in a symbol name */ -#define E_FILNMLEN 14 /* # characters in a file name */ -#define E_DIMNUM 4 /* # array dimensions in auxiliary entry */ - -struct external_syment -{ - union { - char e_name[E_SYMNMLEN]; - struct { - char e_zeroes[4]; - char e_offset[4]; - } e; - } e; - char e_value[4]; - char e_scnum[2]; - char e_type[2]; - char e_sclass[1]; - char e_numaux[1]; - char pad2[2]; -}; - - - - -#define N_BTMASK 017 -#define N_TMASK 060 -#define N_BTSHFT 4 -#define N_TSHIFT 2 - - -/* Note that this isn't the same shape as other coffs */ -union external_auxent { - struct { - char x_tagndx[4]; /* str, un, or enum tag indx */ - /* 4 */ - union { - char x_fsize[4]; /* size of function */ - struct { - char x_lnno[4]; /* declaration line number */ - char x_size[4]; /* str/union/array size */ - } x_lnsz; - } x_misc; - struct { /* if ISFCN, tag, or .bb */ - char x_lnnoptr[4]; /* ptr to fcn line # */ - char x_endndx[4]; /* entry ndx past block end */ - } x_fcn; - - /* 12 */ - union { - struct { /* if ISARY, up to 4 dimen. */ - char x_dimen[E_DIMNUM][2]; - } x_ary; - } x_fcnary; - /* 20 */ - - } x_sym; - - union { - char x_fname[E_FILNMLEN]; - struct { - char x_zeroes[4]; - char x_offset[4]; - } x_n; - } x_file; - - struct { - char x_scnlen[4]; /* section length */ - char x_nreloc[4]; /* # relocation entries */ - char x_nlinno[4]; /* # line numbers */ - } x_scn; - - struct { - char x_tvfill[4]; /* tv fill value */ - char x_tvlen[2]; /* length of .tv */ - char x_tvran[2][2]; /* tv range */ - } x_tv; /* info about .tv section (in auxent of symbol .tv)) */ - -}; - -#define GET_FCN_LNNOPTR(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *)ext->x_sym.x_fcn.x_lnnoptr) -#define GET_FCN_ENDNDX(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_fcn.x_endndx) -#define PUT_FCN_LNNOPTR(abfd, in, ext) bfd_h_put_32(abfd, in, (bfd_byte *) ext->x_sym.x_fcn.x_lnnoptr) -#define PUT_FCN_ENDNDX(abfd, in, ext) bfd_h_put_32(abfd, in, (bfd_byte *) ext->x_sym.x_fcn.x_endndx) -#define GET_LNSZ_SIZE(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_misc.x_lnsz.x_size) -#define GET_LNSZ_LNNO(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_misc.x_lnsz.x_lnno) -#define PUT_LNSZ_LNNO(abfd, in, ext) bfd_h_put_32(abfd, in, (bfd_byte *) ext->x_sym.x_misc.x_lnsz.x_lnno) -#define PUT_LNSZ_SIZE(abfd, in, ext) bfd_h_put_32(abfd, in, (bfd_byte *) ext->x_sym.x_misc.x_lnsz.x_size) -#define GET_SCN_SCNLEN(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *) ext->x_scn.x_scnlen) -#define GET_SCN_NRELOC(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *) ext->x_scn.x_nreloc) -#define GET_SCN_NLINNO(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *) ext->x_scn.x_nlinno) -#define PUT_SCN_SCNLEN(abfd,in, ext) bfd_h_put_32(abfd, in, (bfd_byte *) ext->x_scn.x_scnlen) -#define PUT_SCN_NRELOC(abfd,in, ext) bfd_h_put_32(abfd, in, (bfd_byte *)ext->x_scn.x_nreloc) -#define PUT_SCN_NLINNO(abfd,in, ext) bfd_h_put_32(abfd,in, (bfd_byte *) ext->x_scn.x_nlinno) -#define GET_LINENO_LNNO(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *) (ext->l_lnno)) -#define PUT_LINENO_LNNO(abfd,val, ext) bfd_h_put_32(abfd,val, (bfd_byte *) (ext->l_lnno)); - - - -#define SYMENT struct external_syment -#define SYMESZ 20 -#define AUXENT union external_auxent -#define AUXESZ 20 - - -/********************** RELOCATION DIRECTIVES **********************/ - -struct external_reloc { - char r_vaddr[4]; - char r_symndx[4]; - char r_type[2]; - char r_offset[2]; -}; - -#define RELOC struct external_reloc -#define RELSZ 12 - -#define DEFAULT_SECTION_ALIGNMENT 8 /* double word */ - -#define NO_TVNDX diff --git a/include/coff-mips.h b/include/coff-mips.h deleted file mode 100755 index 2faad589eb1..00000000000 --- a/include/coff-mips.h +++ /dev/null @@ -1,95 +0,0 @@ -/* Rudimentary ECOFF support on MIPS machines. - This lacks symbol information, normally provided on MIPS Unix systems - in the files and . */ - -/********************** 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[4]; /* file pointer to symtab */ - char f_nsyms[4]; /* number of symtab entries */ - char f_opthdr[2]; /* sizeof(optional hdr) */ - char f_flags[2]; /* flags */ -}; - - -/* Mips magics */ -#define MIPS_MAGIC_1 0x0180 -#define MIPS_MAGIC_2 0x0162 -#define MIPS_MAGIC_3 0x0160 - -#define ECOFFBADMAG(x) (((x).f_magic!=MIPS_MAGIC_1) && \ - ((x).f_magic!=MIPS_MAGIC_2) &&\ - ((x).f_magic!=MIPS_MAGIC_3)) - - -#define FILHDR struct external_filehdr -#define FILHSZ 20 - -/********************** AOUT "OPTIONAL HEADER" **********************/ - - -typedef struct external_aouthdr -{ - char magic[2]; /* type of file */ - char vstamp[2]; /* version stamp */ - char tsize[4]; /* text size in bytes, padded to FW bdry*/ - char dsize[4]; /* initialized data " " */ - char bsize[4]; /* uninitialized data " " */ - char entry[4]; /* entry pt. */ - char text_start[4]; /* base of text used for this file */ - char data_start[4]; /* base of data used for this file */ -} AOUTHDR; - -/* compute size of a header */ - -#define AOUTSZ (sizeof(AOUTHDR)) - - -/********************** SECTION HEADER **********************/ - -struct external_scnhdr { - char s_name[8]; /* section name */ - char s_paddr[4]; /* physical address, aliased s_nlib */ - char s_vaddr[4]; /* virtual address */ - char s_size[4]; /* section size */ - char s_scnptr[4]; /* file ptr to raw data for section */ - char s_relptr[4]; /* file ptr to relocation */ - char s_lnnoptr[4]; /* file ptr to line numbers */ - char s_nreloc[2]; /* number of relocation entries */ - char s_nlnno[2]; /* number of line number entries*/ - char s_flags[4]; /* flags */ - }; - -#define SCNHDR struct external_scnhdr -#define SCNHSZ sizeof(SCNHDR) - -/* - * names of "special" sections - */ -#define _TEXT ".text" -#define _DATA ".data" -#define _BSS ".bss" - -#define DEFAULT_DATA_SECTION_ALIGNMENT 4 -#define DEFAULT_BSS_SECTION_ALIGNMENT 4 -#define DEFAULT_TEXT_SECTION_ALIGNMENT 16 -/* For new sections we havn't heard of before */ -#define DEFAULT_SECTION_ALIGNMENT 4 - -/********************** RELOCATION DIRECTIVES **********************/ - -struct external_reloc { - char r_vaddr[4]; - char r_symndx[4]; - char r_type[2]; - char pad[2]; -}; - - -/* Relevent values for r_type and ecoff. Would someone please document them */ - -#define RELOC struct external_reloc -#define RELSZ 12 diff --git a/include/coff-rs6000.h b/include/coff-rs6000.h deleted file mode 100755 index c88654a0113..00000000000 --- a/include/coff-rs6000.h +++ /dev/null @@ -1,226 +0,0 @@ -/* IBM RS/6000 "XCOFF" file definitions for BFD. - Copyright (C) 1990, 1991 Free Software Foundation, Inc. - Written by Mimi Phûông-Thåo Võ and John Gilmore. - Contributed by IBM Corporation and Cygnus Support. - -/********************** 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[4]; /* file pointer to symtab */ - char f_nsyms[4]; /* number of symtab entries */ - char f_opthdr[2]; /* sizeof(optional hdr) */ - char f_flags[2]; /* flags */ -}; - - /* IBM RS/6000 */ -#define U802WRMAGIC 0730 /* writeable text segments **chh** */ -#define U802ROMAGIC 0735 /* readonly sharable text segments */ -#define U802TOCMAGIC 0737 /* readonly text segments and TOC */ - -#define BADMAG(x) \ - ((x).f_magic != U802ROMAGIC && (x).f_magic != U802WRMAGIC && \ - (x).f_magic != U802TOCMAGIC) - -#define FILHDR struct external_filehdr -#define FILHSZ sizeof(FILHDR) - - -/********************** AOUT "OPTIONAL HEADER" **********************/ - - -typedef struct -{ - char magic[2]; /* type of file */ - char vstamp[2]; /* version stamp */ - char tsize[4]; /* text size in bytes, padded to FW bdry*/ - char dsize[4]; /* initialized data " " */ - char bsize[4]; /* uninitialized data " " */ - char entry[4]; /* entry pt. */ - char text_start[4]; /* base of text used for this file */ - char data_start[4]; /* base of data used for this file */ - char o_toc[4]; - char o_snentry[2]; - char o_sntext[2]; - char o_sndata[2]; - char o_sntoc[2]; - char o_snloader[2]; - char o_snbss[2]; - char o_algntext[2]; - char o_algndata[2]; - char o_modtype[2]; - char o_resv1[2]; - char o_maxstack[4]; - char o_resv2[16]; -} -AOUTHDR; - -#define AOUTSZ (sizeof(AOUTHDR)) - -#define RS6K_AOUTHDR_OMAGIC 0x0107 /* old: text & data writeable */ -#define RS6K_AOUTHDR_NMAGIC 0x0108 /* new: text r/o, data r/w */ -#define RS6K_AOUTHDR_ZMAGIC 0x010B /* paged: text r/o, both page-aligned */ - - -/********************** SECTION HEADER **********************/ - - -struct external_scnhdr { - char s_name[8]; /* section name */ - char s_paddr[4]; /* physical address, aliased s_nlib */ - char s_vaddr[4]; /* virtual address */ - char s_size[4]; /* section size */ - char s_scnptr[4]; /* file ptr to raw data for section */ - char s_relptr[4]; /* file ptr to relocation */ - char s_lnnoptr[4]; /* file ptr to line numbers */ - char s_nreloc[2]; /* number of relocation entries */ - char s_nlnno[2]; /* number of line number entries*/ - char s_flags[4]; /* flags */ -}; - -/* - * names of "special" sections - */ -#define _TEXT ".text" -#define _DATA ".data" -#define _BSS ".bss" - - -#define SCNHDR struct external_scnhdr -#define SCNHSZ sizeof(SCNHDR) - - -/********************** 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[4]; /* (physical) address of line number */ - } l_addr; - char l_lnno[2]; /* line number */ -}; - - -#define LINENO struct external_lineno -#define LINESZ sizeof(LINENO) - - -/********************** SYMBOLS **********************/ - -#define E_SYMNMLEN 8 /* # characters in a symbol name */ -#define E_FILNMLEN 14 /* # characters in a file name */ -#define E_DIMNUM 4 /* # array dimensions in auxiliary entry */ - -struct external_syment -{ - union { - char e_name[E_SYMNMLEN]; - struct { - char e_zeroes[4]; - char e_offset[4]; - } e; - } e; - char e_value[4]; - char e_scnum[2]; - char e_type[2]; - char e_sclass[1]; - char e_numaux[1]; -}; - - - -#define N_BTMASK (017) -#define N_TMASK (060) -#define N_BTSHFT (4) -#define N_TSHIFT (2) - - -union external_auxent { - struct { - char x_tagndx[4]; /* str, un, or enum tag indx */ - union { - struct { - char x_lnno[2]; /* declaration line number */ - char x_size[2]; /* str/union/array size */ - } x_lnsz; - char x_fsize[4]; /* size of function */ - } x_misc; - union { - struct { /* if ISFCN, tag, or .bb */ - char x_lnnoptr[4]; /* ptr to fcn line # */ - char x_endndx[4]; /* entry ndx past block end */ - } x_fcn; - struct { /* if ISARY, up to 4 dimen. */ - char x_dimen[E_DIMNUM][2]; - } x_ary; - } x_fcnary; - char x_tvndx[2]; /* tv index */ - } x_sym; - - union { - char x_fname[E_FILNMLEN]; - struct { - char x_zeroes[4]; - char x_offset[4]; - } x_n; - } x_file; - - struct { - char x_scnlen[4]; /* section length */ - char x_nreloc[2]; /* # relocation entries */ - char x_nlinno[2]; /* # line numbers */ - } x_scn; - - struct { - char x_tvfill[4]; /* tv fill value */ - char x_tvlen[2]; /* length of .tv */ - char x_tvran[2][2]; /* tv range */ - } x_tv; /* info about .tv section (in auxent of symbol .tv)) */ - - struct { - char x_scnlen[4], - x_parmhash[4], - x_snhash[2], - x_smtyp[1], - x_smclas[1], - x_stab[4], - x_snstab[2]; - } x_csect; - -}; - -#define SYMENT struct external_syment -#define SYMESZ 18 -#define AUXENT union external_auxent -#define AUXESZ 18 -#define DBXMASK 0x80 /* for dbx storage mask */ -#define SYMNAME_IN_DEBUG(symptr) ((symptr)->n_sclass & DBXMASK) - - - -/********************** RELOCATION DIRECTIVES **********************/ - - -struct external_reloc { - char r_vaddr[4]; - char r_symndx[4]; - char r_size[1]; - char r_type[1]; -}; - - -#define RELOC struct external_reloc -#define RELSZ 10 - -#define DEFAULT_DATA_SECTION_ALIGNMENT 4 -#define DEFAULT_BSS_SECTION_ALIGNMENT 4 -#define DEFAULT_TEXT_SECTION_ALIGNMENT 4 -/* For new sections we havn't heard of before */ -#define DEFAULT_SECTION_ALIGNMENT 4 diff --git a/include/convx-opcode.h b/include/convx-opcode.h deleted file mode 100755 index 523c8744c28..00000000000 --- a/include/convx-opcode.h +++ /dev/null @@ -1,1677 +0,0 @@ -/* Include information for instruction dissasembly on the Convex. - Copyright (C) 1989, Free Software Foundation. - -This file is part of GDB. - -GDB 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 1, or (at your option) -any later version. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#define xxx 0 -#define rrr 1 -#define rr 2 -#define rxr 3 -#define r 4 -#define nops 5 -#define nr 6 -#define pcrel 7 -#define lr 8 -#define rxl 9 -#define rlr 10 -#define rrl 11 -#define iml 12 -#define imr 13 -#define a1r 14 -#define a1l 15 -#define a2r 16 -#define a2l 17 -#define a3 18 -#define a4 19 -#define a5 20 -#define V 1 -#define S 2 -#define VM 3 -#define A 4 -#define VL 5 -#define VS 6 -#define VLS 7 -#define PSW 8 -/* Prevent an error during "make depend". */ -#if !defined (PC) -#define PC 9 -#endif -#define ITR 10 -#define VV 11 -#define ITSR 12 -#define TOC 13 -#define CIR 14 -#define TTR 15 -#define VMU 16 -#define VML 17 -#define ICR 18 -#define TCPU 19 -#define CPUID 20 -#define TID 21 -char *op[] = { - "", - "v0\0v1\0v2\0v3\0v4\0v5\0v6\0v7", - "s0\0s1\0s2\0s3\0s4\0s5\0s6\0s7", - "vm", - "sp\0a1\0a2\0a3\0a4\0a5\0ap\0fp", - "vl", - "vs", - "vls", - "psw", - "pc", - "itr", - "vv", - "itsr", - "toc", - "cir", - "ttr", - "vmu", - "vml", - "icr", - "tcpu", - "cpuid", - "tid", -}; -struct formstr format0[] = { - {0,0,rrr,V,S,S}, /* mov */ - {0,0,rrr,S,S,V}, /* mov */ - {1,1,rrr,V,V,V}, /* merg.t */ - {2,1,rrr,V,V,V}, /* mask.t */ - {1,2,rrr,V,S,V}, /* merg.f */ - {2,2,rrr,V,S,V}, /* mask.f */ - {1,1,rrr,V,S,V}, /* merg.t */ - {2,1,rrr,V,S,V}, /* mask.t */ - {3,3,rrr,V,V,V}, /* mul.s */ - {3,4,rrr,V,V,V}, /* mul.d */ - {4,3,rrr,V,V,V}, /* div.s */ - {4,4,rrr,V,V,V}, /* div.d */ - {3,3,rrr,V,S,V}, /* mul.s */ - {3,4,rrr,V,S,V}, /* mul.d */ - {4,3,rrr,V,S,V}, /* div.s */ - {4,4,rrr,V,S,V}, /* div.d */ - {5,0,rrr,V,V,V}, /* and */ - {6,0,rrr,V,V,V}, /* or */ - {7,0,rrr,V,V,V}, /* xor */ - {8,0,rrr,V,V,V}, /* shf */ - {5,0,rrr,V,S,V}, /* and */ - {6,0,rrr,V,S,V}, /* or */ - {7,0,rrr,V,S,V}, /* xor */ - {8,0,rrr,V,S,V}, /* shf */ - {9,3,rrr,V,V,V}, /* add.s */ - {9,4,rrr,V,V,V}, /* add.d */ - {10,3,rrr,V,V,V}, /* sub.s */ - {10,4,rrr,V,V,V}, /* sub.d */ - {9,3,rrr,V,S,V}, /* add.s */ - {9,4,rrr,V,S,V}, /* add.d */ - {10,3,rrr,V,S,V}, /* sub.s */ - {10,4,rrr,V,S,V}, /* sub.d */ - {9,5,rrr,V,V,V}, /* add.b */ - {9,6,rrr,V,V,V}, /* add.h */ - {9,7,rrr,V,V,V}, /* add.w */ - {9,8,rrr,V,V,V}, /* add.l */ - {9,5,rrr,V,S,V}, /* add.b */ - {9,6,rrr,V,S,V}, /* add.h */ - {9,7,rrr,V,S,V}, /* add.w */ - {9,8,rrr,V,S,V}, /* add.l */ - {10,5,rrr,V,V,V}, /* sub.b */ - {10,6,rrr,V,V,V}, /* sub.h */ - {10,7,rrr,V,V,V}, /* sub.w */ - {10,8,rrr,V,V,V}, /* sub.l */ - {10,5,rrr,V,S,V}, /* sub.b */ - {10,6,rrr,V,S,V}, /* sub.h */ - {10,7,rrr,V,S,V}, /* sub.w */ - {10,8,rrr,V,S,V}, /* sub.l */ - {3,5,rrr,V,V,V}, /* mul.b */ - {3,6,rrr,V,V,V}, /* mul.h */ - {3,7,rrr,V,V,V}, /* mul.w */ - {3,8,rrr,V,V,V}, /* mul.l */ - {3,5,rrr,V,S,V}, /* mul.b */ - {3,6,rrr,V,S,V}, /* mul.h */ - {3,7,rrr,V,S,V}, /* mul.w */ - {3,8,rrr,V,S,V}, /* mul.l */ - {4,5,rrr,V,V,V}, /* div.b */ - {4,6,rrr,V,V,V}, /* div.h */ - {4,7,rrr,V,V,V}, /* div.w */ - {4,8,rrr,V,V,V}, /* div.l */ - {4,5,rrr,V,S,V}, /* div.b */ - {4,6,rrr,V,S,V}, /* div.h */ - {4,7,rrr,V,S,V}, /* div.w */ - {4,8,rrr,V,S,V}, /* div.l */ -}; -struct formstr format1[] = { - {11,0,xxx,0,0,0}, /* exit */ - {12,0,a3,0,0,0}, /* jmp */ - {13,2,a3,0,0,0}, /* jmpi.f */ - {13,1,a3,0,0,0}, /* jmpi.t */ - {14,2,a3,0,0,0}, /* jmpa.f */ - {14,1,a3,0,0,0}, /* jmpa.t */ - {15,2,a3,0,0,0}, /* jmps.f */ - {15,1,a3,0,0,0}, /* jmps.t */ - {16,0,a3,0,0,0}, /* tac */ - {17,0,a1r,A,0,0}, /* ldea */ - {18,8,a1l,VLS,0,0}, /* ld.l */ - {18,9,a1l,VM,0,0}, /* ld.x */ - {19,0,a3,0,0,0}, /* tas */ - {20,0,a3,0,0,0}, /* pshea */ - {21,8,a2l,VLS,0,0}, /* st.l */ - {21,9,a2l,VM,0,0}, /* st.x */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {22,0,a3,0,0,0}, /* call */ - {23,0,a3,0,0,0}, /* calls */ - {24,0,a3,0,0,0}, /* callq */ - {25,0,a1r,A,0,0}, /* pfork */ - {26,5,a2r,S,0,0}, /* ste.b */ - {26,6,a2r,S,0,0}, /* ste.h */ - {26,7,a2r,S,0,0}, /* ste.w */ - {26,8,a2r,S,0,0}, /* ste.l */ - {18,5,a1r,A,0,0}, /* ld.b */ - {18,6,a1r,A,0,0}, /* ld.h */ - {18,7,a1r,A,0,0}, /* ld.w */ - {27,7,a1r,A,0,0}, /* incr.w */ - {21,5,a2r,A,0,0}, /* st.b */ - {21,6,a2r,A,0,0}, /* st.h */ - {21,7,a2r,A,0,0}, /* st.w */ - {27,8,a1r,S,0,0}, /* incr.l */ - {18,5,a1r,S,0,0}, /* ld.b */ - {18,6,a1r,S,0,0}, /* ld.h */ - {18,7,a1r,S,0,0}, /* ld.w */ - {18,8,a1r,S,0,0}, /* ld.l */ - {21,5,a2r,S,0,0}, /* st.b */ - {21,6,a2r,S,0,0}, /* st.h */ - {21,7,a2r,S,0,0}, /* st.w */ - {21,8,a2r,S,0,0}, /* st.l */ - {18,5,a1r,V,0,0}, /* ld.b */ - {18,6,a1r,V,0,0}, /* ld.h */ - {18,7,a1r,V,0,0}, /* ld.w */ - {18,8,a1r,V,0,0}, /* ld.l */ - {21,5,a2r,V,0,0}, /* st.b */ - {21,6,a2r,V,0,0}, /* st.h */ - {21,7,a2r,V,0,0}, /* st.w */ - {21,8,a2r,V,0,0}, /* st.l */ -}; -struct formstr format2[] = { - {28,5,rr,A,A,0}, /* cvtw.b */ - {28,6,rr,A,A,0}, /* cvtw.h */ - {29,7,rr,A,A,0}, /* cvtb.w */ - {30,7,rr,A,A,0}, /* cvth.w */ - {28,5,rr,S,S,0}, /* cvtw.b */ - {28,6,rr,S,S,0}, /* cvtw.h */ - {29,7,rr,S,S,0}, /* cvtb.w */ - {30,7,rr,S,S,0}, /* cvth.w */ - {28,3,rr,S,S,0}, /* cvtw.s */ - {31,7,rr,S,S,0}, /* cvts.w */ - {32,3,rr,S,S,0}, /* cvtd.s */ - {31,4,rr,S,S,0}, /* cvts.d */ - {31,8,rr,S,S,0}, /* cvts.l */ - {32,8,rr,S,S,0}, /* cvtd.l */ - {33,3,rr,S,S,0}, /* cvtl.s */ - {33,4,rr,S,S,0}, /* cvtl.d */ - {34,0,rr,A,A,0}, /* ldpa */ - {8,0,nr,A,0,0}, /* shf */ - {18,6,nr,A,0,0}, /* ld.h */ - {18,7,nr,A,0,0}, /* ld.w */ - {33,7,rr,S,S,0}, /* cvtl.w */ - {28,8,rr,S,S,0}, /* cvtw.l */ - {35,1,rr,S,S,0}, /* plc.t */ - {36,0,rr,S,S,0}, /* tzc */ - {37,6,rr,A,A,0}, /* eq.h */ - {37,7,rr,A,A,0}, /* eq.w */ - {37,6,nr,A,0,0}, /* eq.h */ - {37,7,nr,A,0,0}, /* eq.w */ - {37,5,rr,S,S,0}, /* eq.b */ - {37,6,rr,S,S,0}, /* eq.h */ - {37,7,rr,S,S,0}, /* eq.w */ - {37,8,rr,S,S,0}, /* eq.l */ - {38,6,rr,A,A,0}, /* leu.h */ - {38,7,rr,A,A,0}, /* leu.w */ - {38,6,nr,A,0,0}, /* leu.h */ - {38,7,nr,A,0,0}, /* leu.w */ - {38,5,rr,S,S,0}, /* leu.b */ - {38,6,rr,S,S,0}, /* leu.h */ - {38,7,rr,S,S,0}, /* leu.w */ - {38,8,rr,S,S,0}, /* leu.l */ - {39,6,rr,A,A,0}, /* ltu.h */ - {39,7,rr,A,A,0}, /* ltu.w */ - {39,6,nr,A,0,0}, /* ltu.h */ - {39,7,nr,A,0,0}, /* ltu.w */ - {39,5,rr,S,S,0}, /* ltu.b */ - {39,6,rr,S,S,0}, /* ltu.h */ - {39,7,rr,S,S,0}, /* ltu.w */ - {39,8,rr,S,S,0}, /* ltu.l */ - {40,6,rr,A,A,0}, /* le.h */ - {40,7,rr,A,A,0}, /* le.w */ - {40,6,nr,A,0,0}, /* le.h */ - {40,7,nr,A,0,0}, /* le.w */ - {40,5,rr,S,S,0}, /* le.b */ - {40,6,rr,S,S,0}, /* le.h */ - {40,7,rr,S,S,0}, /* le.w */ - {40,8,rr,S,S,0}, /* le.l */ - {41,6,rr,A,A,0}, /* lt.h */ - {41,7,rr,A,A,0}, /* lt.w */ - {41,6,nr,A,0,0}, /* lt.h */ - {41,7,nr,A,0,0}, /* lt.w */ - {41,5,rr,S,S,0}, /* lt.b */ - {41,6,rr,S,S,0}, /* lt.h */ - {41,7,rr,S,S,0}, /* lt.w */ - {41,8,rr,S,S,0}, /* lt.l */ - {9,7,rr,S,A,0}, /* add.w */ - {8,0,rr,A,A,0}, /* shf */ - {0,0,rr,A,A,0}, /* mov */ - {0,0,rr,S,A,0}, /* mov */ - {0,7,rr,S,S,0}, /* mov.w */ - {8,0,rr,S,S,0}, /* shf */ - {0,0,rr,S,S,0}, /* mov */ - {0,0,rr,A,S,0}, /* mov */ - {5,0,rr,A,A,0}, /* and */ - {6,0,rr,A,A,0}, /* or */ - {7,0,rr,A,A,0}, /* xor */ - {42,0,rr,A,A,0}, /* not */ - {5,0,rr,S,S,0}, /* and */ - {6,0,rr,S,S,0}, /* or */ - {7,0,rr,S,S,0}, /* xor */ - {42,0,rr,S,S,0}, /* not */ - {40,3,rr,S,S,0}, /* le.s */ - {40,4,rr,S,S,0}, /* le.d */ - {41,3,rr,S,S,0}, /* lt.s */ - {41,4,rr,S,S,0}, /* lt.d */ - {9,3,rr,S,S,0}, /* add.s */ - {9,4,rr,S,S,0}, /* add.d */ - {10,3,rr,S,S,0}, /* sub.s */ - {10,4,rr,S,S,0}, /* sub.d */ - {37,3,rr,S,S,0}, /* eq.s */ - {37,4,rr,S,S,0}, /* eq.d */ - {43,6,rr,A,A,0}, /* neg.h */ - {43,7,rr,A,A,0}, /* neg.w */ - {3,3,rr,S,S,0}, /* mul.s */ - {3,4,rr,S,S,0}, /* mul.d */ - {4,3,rr,S,S,0}, /* div.s */ - {4,4,rr,S,S,0}, /* div.d */ - {9,6,rr,A,A,0}, /* add.h */ - {9,7,rr,A,A,0}, /* add.w */ - {9,6,nr,A,0,0}, /* add.h */ - {9,7,nr,A,0,0}, /* add.w */ - {9,5,rr,S,S,0}, /* add.b */ - {9,6,rr,S,S,0}, /* add.h */ - {9,7,rr,S,S,0}, /* add.w */ - {9,8,rr,S,S,0}, /* add.l */ - {10,6,rr,A,A,0}, /* sub.h */ - {10,7,rr,A,A,0}, /* sub.w */ - {10,6,nr,A,0,0}, /* sub.h */ - {10,7,nr,A,0,0}, /* sub.w */ - {10,5,rr,S,S,0}, /* sub.b */ - {10,6,rr,S,S,0}, /* sub.h */ - {10,7,rr,S,S,0}, /* sub.w */ - {10,8,rr,S,S,0}, /* sub.l */ - {3,6,rr,A,A,0}, /* mul.h */ - {3,7,rr,A,A,0}, /* mul.w */ - {3,6,nr,A,0,0}, /* mul.h */ - {3,7,nr,A,0,0}, /* mul.w */ - {3,5,rr,S,S,0}, /* mul.b */ - {3,6,rr,S,S,0}, /* mul.h */ - {3,7,rr,S,S,0}, /* mul.w */ - {3,8,rr,S,S,0}, /* mul.l */ - {4,6,rr,A,A,0}, /* div.h */ - {4,7,rr,A,A,0}, /* div.w */ - {4,6,nr,A,0,0}, /* div.h */ - {4,7,nr,A,0,0}, /* div.w */ - {4,5,rr,S,S,0}, /* div.b */ - {4,6,rr,S,S,0}, /* div.h */ - {4,7,rr,S,S,0}, /* div.w */ - {4,8,rr,S,S,0}, /* div.l */ -}; -struct formstr format3[] = { - {32,3,rr,V,V,0}, /* cvtd.s */ - {31,4,rr,V,V,0}, /* cvts.d */ - {33,4,rr,V,V,0}, /* cvtl.d */ - {32,8,rr,V,V,0}, /* cvtd.l */ - {0,0,rrl,S,S,VM}, /* mov */ - {0,0,rlr,S,VM,S}, /* mov */ - {0,0,0,0,0,0}, - {44,0,rr,S,S,0}, /* lop */ - {36,0,rr,V,V,0}, /* tzc */ - {44,0,rr,V,V,0}, /* lop */ - {0,0,0,0,0,0}, - {42,0,rr,V,V,0}, /* not */ - {8,0,rr,S,V,0}, /* shf */ - {35,1,rr,V,V,0}, /* plc.t */ - {45,2,rr,V,V,0}, /* cprs.f */ - {45,1,rr,V,V,0}, /* cprs.t */ - {37,3,rr,V,V,0}, /* eq.s */ - {37,4,rr,V,V,0}, /* eq.d */ - {43,3,rr,V,V,0}, /* neg.s */ - {43,4,rr,V,V,0}, /* neg.d */ - {37,3,rr,S,V,0}, /* eq.s */ - {37,4,rr,S,V,0}, /* eq.d */ - {43,3,rr,S,S,0}, /* neg.s */ - {43,4,rr,S,S,0}, /* neg.d */ - {40,3,rr,V,V,0}, /* le.s */ - {40,4,rr,V,V,0}, /* le.d */ - {41,3,rr,V,V,0}, /* lt.s */ - {41,4,rr,V,V,0}, /* lt.d */ - {40,3,rr,S,V,0}, /* le.s */ - {40,4,rr,S,V,0}, /* le.d */ - {41,3,rr,S,V,0}, /* lt.s */ - {41,4,rr,S,V,0}, /* lt.d */ - {37,5,rr,V,V,0}, /* eq.b */ - {37,6,rr,V,V,0}, /* eq.h */ - {37,7,rr,V,V,0}, /* eq.w */ - {37,8,rr,V,V,0}, /* eq.l */ - {37,5,rr,S,V,0}, /* eq.b */ - {37,6,rr,S,V,0}, /* eq.h */ - {37,7,rr,S,V,0}, /* eq.w */ - {37,8,rr,S,V,0}, /* eq.l */ - {40,5,rr,V,V,0}, /* le.b */ - {40,6,rr,V,V,0}, /* le.h */ - {40,7,rr,V,V,0}, /* le.w */ - {40,8,rr,V,V,0}, /* le.l */ - {40,5,rr,S,V,0}, /* le.b */ - {40,6,rr,S,V,0}, /* le.h */ - {40,7,rr,S,V,0}, /* le.w */ - {40,8,rr,S,V,0}, /* le.l */ - {41,5,rr,V,V,0}, /* lt.b */ - {41,6,rr,V,V,0}, /* lt.h */ - {41,7,rr,V,V,0}, /* lt.w */ - {41,8,rr,V,V,0}, /* lt.l */ - {41,5,rr,S,V,0}, /* lt.b */ - {41,6,rr,S,V,0}, /* lt.h */ - {41,7,rr,S,V,0}, /* lt.w */ - {41,8,rr,S,V,0}, /* lt.l */ - {43,5,rr,V,V,0}, /* neg.b */ - {43,6,rr,V,V,0}, /* neg.h */ - {43,7,rr,V,V,0}, /* neg.w */ - {43,8,rr,V,V,0}, /* neg.l */ - {43,5,rr,S,S,0}, /* neg.b */ - {43,6,rr,S,S,0}, /* neg.h */ - {43,7,rr,S,S,0}, /* neg.w */ - {43,8,rr,S,S,0}, /* neg.l */ -}; -struct formstr format4[] = { - {46,0,nops,0,0,0}, /* nop */ - {47,0,pcrel,0,0,0}, /* br */ - {48,2,pcrel,0,0,0}, /* bri.f */ - {48,1,pcrel,0,0,0}, /* bri.t */ - {49,2,pcrel,0,0,0}, /* bra.f */ - {49,1,pcrel,0,0,0}, /* bra.t */ - {50,2,pcrel,0,0,0}, /* brs.f */ - {50,1,pcrel,0,0,0}, /* brs.t */ -}; -struct formstr format5[] = { - {51,5,rr,V,V,0}, /* ldvi.b */ - {51,6,rr,V,V,0}, /* ldvi.h */ - {51,7,rr,V,V,0}, /* ldvi.w */ - {51,8,rr,V,V,0}, /* ldvi.l */ - {28,3,rr,V,V,0}, /* cvtw.s */ - {31,7,rr,V,V,0}, /* cvts.w */ - {28,8,rr,V,V,0}, /* cvtw.l */ - {33,7,rr,V,V,0}, /* cvtl.w */ - {52,5,rxr,V,V,0}, /* stvi.b */ - {52,6,rxr,V,V,0}, /* stvi.h */ - {52,7,rxr,V,V,0}, /* stvi.w */ - {52,8,rxr,V,V,0}, /* stvi.l */ - {52,5,rxr,S,V,0}, /* stvi.b */ - {52,6,rxr,S,V,0}, /* stvi.h */ - {52,7,rxr,S,V,0}, /* stvi.w */ - {52,8,rxr,S,V,0}, /* stvi.l */ -}; -struct formstr format6[] = { - {53,0,r,A,0,0}, /* ldsdr */ - {54,0,r,A,0,0}, /* ldkdr */ - {55,3,r,S,0,0}, /* ln.s */ - {55,4,r,S,0,0}, /* ln.d */ - {56,0,nops,0,0,0}, /* patu */ - {57,0,r,A,0,0}, /* pate */ - {58,0,nops,0,0,0}, /* pich */ - {59,0,nops,0,0,0}, /* plch */ - {0,0,lr,PSW,A,0}, /* mov */ - {0,0,rxl,A,PSW,0}, /* mov */ - {0,0,lr,PC,A,0}, /* mov */ - {60,0,r,S,0,0}, /* idle */ - {0,0,lr,ITR,S,0}, /* mov */ - {0,0,rxl,S,ITR,0}, /* mov */ - {0,0,0,0,0,0}, - {0,0,rxl,S,ITSR,0}, /* mov */ - {61,0,nops,0,0,0}, /* rtnq */ - {62,0,nops,0,0,0}, /* cfork */ - {63,0,nops,0,0,0}, /* rtn */ - {64,0,nops,0,0,0}, /* wfork */ - {65,0,nops,0,0,0}, /* join */ - {66,0,nops,0,0,0}, /* rtnc */ - {67,3,r,S,0,0}, /* exp.s */ - {67,4,r,S,0,0}, /* exp.d */ - {68,3,r,S,0,0}, /* sin.s */ - {68,4,r,S,0,0}, /* sin.d */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {69,3,r,S,0,0}, /* cos.s */ - {69,4,r,S,0,0}, /* cos.d */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {70,7,r,A,0,0}, /* psh.w */ - {0,0,0,0,0,0}, - {71,7,r,A,0,0}, /* pop.w */ - {0,0,0,0,0,0}, - {70,7,r,S,0,0}, /* psh.w */ - {70,8,r,S,0,0}, /* psh.l */ - {71,7,r,S,0,0}, /* pop.w */ - {71,8,r,S,0,0}, /* pop.l */ - {72,0,nops,0,0,0}, /* eni */ - {73,0,nops,0,0,0}, /* dsi */ - {74,0,nops,0,0,0}, /* bkpt */ - {75,0,nops,0,0,0}, /* msync */ - {76,0,r,S,0,0}, /* mski */ - {77,0,r,S,0,0}, /* xmti */ - {0,0,rxl,S,VV,0}, /* mov */ - {78,0,nops,0,0,0}, /* tstvv */ - {0,0,lr,VS,A,0}, /* mov */ - {0,0,rxl,A,VS,0}, /* mov */ - {0,0,lr,VL,A,0}, /* mov */ - {0,0,rxl,A,VL,0}, /* mov */ - {0,7,lr,VS,S,0}, /* mov.w */ - {0,7,rxl,S,VS,0}, /* mov.w */ - {0,7,lr,VL,S,0}, /* mov.w */ - {0,7,rxl,S,VL,0}, /* mov.w */ - {79,0,r,A,0,0}, /* diag */ - {80,0,nops,0,0,0}, /* pbkpt */ - {81,3,r,S,0,0}, /* sqrt.s */ - {81,4,r,S,0,0}, /* sqrt.d */ - {82,0,nops,0,0,0}, /* casr */ - {0,0,0,0,0,0}, - {83,3,r,S,0,0}, /* atan.s */ - {83,4,r,S,0,0}, /* atan.d */ -}; -struct formstr format7[] = { - {84,5,r,V,0,0}, /* sum.b */ - {84,6,r,V,0,0}, /* sum.h */ - {84,7,r,V,0,0}, /* sum.w */ - {84,8,r,V,0,0}, /* sum.l */ - {85,0,r,V,0,0}, /* all */ - {86,0,r,V,0,0}, /* any */ - {87,0,r,V,0,0}, /* parity */ - {0,0,0,0,0,0}, - {88,5,r,V,0,0}, /* max.b */ - {88,6,r,V,0,0}, /* max.h */ - {88,7,r,V,0,0}, /* max.w */ - {88,8,r,V,0,0}, /* max.l */ - {89,5,r,V,0,0}, /* min.b */ - {89,6,r,V,0,0}, /* min.h */ - {89,7,r,V,0,0}, /* min.w */ - {89,8,r,V,0,0}, /* min.l */ - {84,3,r,V,0,0}, /* sum.s */ - {84,4,r,V,0,0}, /* sum.d */ - {90,3,r,V,0,0}, /* prod.s */ - {90,4,r,V,0,0}, /* prod.d */ - {88,3,r,V,0,0}, /* max.s */ - {88,4,r,V,0,0}, /* max.d */ - {89,3,r,V,0,0}, /* min.s */ - {89,4,r,V,0,0}, /* min.d */ - {90,5,r,V,0,0}, /* prod.b */ - {90,6,r,V,0,0}, /* prod.h */ - {90,7,r,V,0,0}, /* prod.w */ - {90,8,r,V,0,0}, /* prod.l */ - {35,2,lr,VM,S,0}, /* plc.f */ - {35,1,lr,VM,S,0}, /* plc.t */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, -}; -struct formstr formatx[] = { - {0,0,0,0,0,0}, -}; -struct formstr format1a[] = { - {91,0,imr,A,0,0}, /* halt */ - {92,0,a4,0,0,0}, /* sysc */ - {18,6,imr,A,0,0}, /* ld.h */ - {18,7,imr,A,0,0}, /* ld.w */ - {5,0,imr,A,0,0}, /* and */ - {6,0,imr,A,0,0}, /* or */ - {7,0,imr,A,0,0}, /* xor */ - {8,0,imr,A,0,0}, /* shf */ - {9,6,imr,A,0,0}, /* add.h */ - {9,7,imr,A,0,0}, /* add.w */ - {10,6,imr,A,0,0}, /* sub.h */ - {10,7,imr,A,0,0}, /* sub.w */ - {3,6,imr,A,0,0}, /* mul.h */ - {3,7,imr,A,0,0}, /* mul.w */ - {4,6,imr,A,0,0}, /* div.h */ - {4,7,imr,A,0,0}, /* div.w */ - {18,7,iml,VL,0,0}, /* ld.w */ - {18,7,iml,VS,0,0}, /* ld.w */ - {0,0,0,0,0,0}, - {8,7,imr,S,0,0}, /* shf.w */ - {93,0,a5,0,0,0}, /* trap */ - {0,0,0,0,0,0}, - {37,6,imr,A,0,0}, /* eq.h */ - {37,7,imr,A,0,0}, /* eq.w */ - {38,6,imr,A,0,0}, /* leu.h */ - {38,7,imr,A,0,0}, /* leu.w */ - {39,6,imr,A,0,0}, /* ltu.h */ - {39,7,imr,A,0,0}, /* ltu.w */ - {40,6,imr,A,0,0}, /* le.h */ - {40,7,imr,A,0,0}, /* le.w */ - {41,6,imr,A,0,0}, /* lt.h */ - {41,7,imr,A,0,0}, /* lt.w */ -}; -struct formstr format1b[] = { - {18,4,imr,S,0,0}, /* ld.d */ - {18,10,imr,S,0,0}, /* ld.u */ - {18,8,imr,S,0,0}, /* ld.l */ - {18,7,imr,S,0,0}, /* ld.w */ - {5,0,imr,S,0,0}, /* and */ - {6,0,imr,S,0,0}, /* or */ - {7,0,imr,S,0,0}, /* xor */ - {8,0,imr,S,0,0}, /* shf */ - {9,6,imr,S,0,0}, /* add.h */ - {9,7,imr,S,0,0}, /* add.w */ - {10,6,imr,S,0,0}, /* sub.h */ - {10,7,imr,S,0,0}, /* sub.w */ - {3,6,imr,S,0,0}, /* mul.h */ - {3,7,imr,S,0,0}, /* mul.w */ - {4,6,imr,S,0,0}, /* div.h */ - {4,7,imr,S,0,0}, /* div.w */ - {9,3,imr,S,0,0}, /* add.s */ - {10,3,imr,S,0,0}, /* sub.s */ - {3,3,imr,S,0,0}, /* mul.s */ - {4,3,imr,S,0,0}, /* div.s */ - {40,3,imr,S,0,0}, /* le.s */ - {41,3,imr,S,0,0}, /* lt.s */ - {37,6,imr,S,0,0}, /* eq.h */ - {37,7,imr,S,0,0}, /* eq.w */ - {38,6,imr,S,0,0}, /* leu.h */ - {38,7,imr,S,0,0}, /* leu.w */ - {39,6,imr,S,0,0}, /* ltu.h */ - {39,7,imr,S,0,0}, /* ltu.w */ - {40,6,imr,S,0,0}, /* le.h */ - {40,7,imr,S,0,0}, /* le.w */ - {41,6,imr,S,0,0}, /* lt.h */ - {41,7,imr,S,0,0}, /* lt.w */ -}; -struct formstr e0_format0[] = { - {10,3,rrr,S,V,V}, /* sub.s */ - {10,4,rrr,S,V,V}, /* sub.d */ - {4,3,rrr,S,V,V}, /* div.s */ - {4,4,rrr,S,V,V}, /* div.d */ - {10,11,rrr,S,V,V}, /* sub.s.f */ - {10,12,rrr,S,V,V}, /* sub.d.f */ - {4,11,rrr,S,V,V}, /* div.s.f */ - {4,12,rrr,S,V,V}, /* div.d.f */ - {3,11,rrr,V,V,V}, /* mul.s.f */ - {3,12,rrr,V,V,V}, /* mul.d.f */ - {4,11,rrr,V,V,V}, /* div.s.f */ - {4,12,rrr,V,V,V}, /* div.d.f */ - {3,11,rrr,V,S,V}, /* mul.s.f */ - {3,12,rrr,V,S,V}, /* mul.d.f */ - {4,11,rrr,V,S,V}, /* div.s.f */ - {4,12,rrr,V,S,V}, /* div.d.f */ - {5,2,rrr,V,V,V}, /* and.f */ - {6,2,rrr,V,V,V}, /* or.f */ - {7,2,rrr,V,V,V}, /* xor.f */ - {8,2,rrr,V,V,V}, /* shf.f */ - {5,2,rrr,V,S,V}, /* and.f */ - {6,2,rrr,V,S,V}, /* or.f */ - {7,2,rrr,V,S,V}, /* xor.f */ - {8,2,rrr,V,S,V}, /* shf.f */ - {9,11,rrr,V,V,V}, /* add.s.f */ - {9,12,rrr,V,V,V}, /* add.d.f */ - {10,11,rrr,V,V,V}, /* sub.s.f */ - {10,12,rrr,V,V,V}, /* sub.d.f */ - {9,11,rrr,V,S,V}, /* add.s.f */ - {9,12,rrr,V,S,V}, /* add.d.f */ - {10,11,rrr,V,S,V}, /* sub.s.f */ - {10,12,rrr,V,S,V}, /* sub.d.f */ - {9,13,rrr,V,V,V}, /* add.b.f */ - {9,14,rrr,V,V,V}, /* add.h.f */ - {9,15,rrr,V,V,V}, /* add.w.f */ - {9,16,rrr,V,V,V}, /* add.l.f */ - {9,13,rrr,V,S,V}, /* add.b.f */ - {9,14,rrr,V,S,V}, /* add.h.f */ - {9,15,rrr,V,S,V}, /* add.w.f */ - {9,16,rrr,V,S,V}, /* add.l.f */ - {10,13,rrr,V,V,V}, /* sub.b.f */ - {10,14,rrr,V,V,V}, /* sub.h.f */ - {10,15,rrr,V,V,V}, /* sub.w.f */ - {10,16,rrr,V,V,V}, /* sub.l.f */ - {10,13,rrr,V,S,V}, /* sub.b.f */ - {10,14,rrr,V,S,V}, /* sub.h.f */ - {10,15,rrr,V,S,V}, /* sub.w.f */ - {10,16,rrr,V,S,V}, /* sub.l.f */ - {3,13,rrr,V,V,V}, /* mul.b.f */ - {3,14,rrr,V,V,V}, /* mul.h.f */ - {3,15,rrr,V,V,V}, /* mul.w.f */ - {3,16,rrr,V,V,V}, /* mul.l.f */ - {3,13,rrr,V,S,V}, /* mul.b.f */ - {3,14,rrr,V,S,V}, /* mul.h.f */ - {3,15,rrr,V,S,V}, /* mul.w.f */ - {3,16,rrr,V,S,V}, /* mul.l.f */ - {4,13,rrr,V,V,V}, /* div.b.f */ - {4,14,rrr,V,V,V}, /* div.h.f */ - {4,15,rrr,V,V,V}, /* div.w.f */ - {4,16,rrr,V,V,V}, /* div.l.f */ - {4,13,rrr,V,S,V}, /* div.b.f */ - {4,14,rrr,V,S,V}, /* div.h.f */ - {4,15,rrr,V,S,V}, /* div.w.f */ - {4,16,rrr,V,S,V}, /* div.l.f */ -}; -struct formstr e0_format1[] = { - {0,0,0,0,0,0}, - {94,0,a3,0,0,0}, /* tst */ - {95,0,a3,0,0,0}, /* lck */ - {96,0,a3,0,0,0}, /* ulk */ - {17,0,a1r,S,0,0}, /* ldea */ - {97,0,a1r,A,0,0}, /* spawn */ - {98,0,a1r,A,0,0}, /* ldcmr */ - {99,0,a2r,A,0,0}, /* stcmr */ - {100,0,a1r,A,0,0}, /* popr */ - {101,0,a2r,A,0,0}, /* pshr */ - {102,7,a1r,A,0,0}, /* rcvr.w */ - {103,7,a2r,A,0,0}, /* matm.w */ - {104,7,a2r,A,0,0}, /* sndr.w */ - {104,8,a2r,S,0,0}, /* sndr.l */ - {102,8,a1r,S,0,0}, /* rcvr.l */ - {103,8,a2r,S,0,0}, /* matm.l */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {105,7,a2r,A,0,0}, /* putr.w */ - {105,8,a2r,S,0,0}, /* putr.l */ - {106,7,a1r,A,0,0}, /* getr.w */ - {106,8,a1r,S,0,0}, /* getr.l */ - {26,13,a2r,S,0,0}, /* ste.b.f */ - {26,14,a2r,S,0,0}, /* ste.h.f */ - {26,15,a2r,S,0,0}, /* ste.w.f */ - {26,16,a2r,S,0,0}, /* ste.l.f */ - {107,7,a2r,A,0,0}, /* matr.w */ - {108,7,a2r,A,0,0}, /* mat.w */ - {109,7,a1r,A,0,0}, /* get.w */ - {110,7,a1r,A,0,0}, /* rcv.w */ - {0,0,0,0,0,0}, - {111,7,a1r,A,0,0}, /* inc.w */ - {112,7,a2r,A,0,0}, /* put.w */ - {113,7,a2r,A,0,0}, /* snd.w */ - {107,8,a2r,S,0,0}, /* matr.l */ - {108,8,a2r,S,0,0}, /* mat.l */ - {109,8,a1r,S,0,0}, /* get.l */ - {110,8,a1r,S,0,0}, /* rcv.l */ - {0,0,0,0,0,0}, - {111,8,a1r,S,0,0}, /* inc.l */ - {112,8,a2r,S,0,0}, /* put.l */ - {113,8,a2r,S,0,0}, /* snd.l */ - {18,13,a1r,V,0,0}, /* ld.b.f */ - {18,14,a1r,V,0,0}, /* ld.h.f */ - {18,15,a1r,V,0,0}, /* ld.w.f */ - {18,16,a1r,V,0,0}, /* ld.l.f */ - {21,13,a2r,V,0,0}, /* st.b.f */ - {21,14,a2r,V,0,0}, /* st.h.f */ - {21,15,a2r,V,0,0}, /* st.w.f */ - {21,16,a2r,V,0,0}, /* st.l.f */ -}; -struct formstr e0_format2[] = { - {28,5,rr,V,V,0}, /* cvtw.b */ - {28,6,rr,V,V,0}, /* cvtw.h */ - {29,7,rr,V,V,0}, /* cvtb.w */ - {30,7,rr,V,V,0}, /* cvth.w */ - {28,13,rr,V,V,0}, /* cvtw.b.f */ - {28,14,rr,V,V,0}, /* cvtw.h.f */ - {29,15,rr,V,V,0}, /* cvtb.w.f */ - {30,15,rr,V,V,0}, /* cvth.w.f */ - {31,8,rr,V,V,0}, /* cvts.l */ - {32,7,rr,V,V,0}, /* cvtd.w */ - {33,3,rr,V,V,0}, /* cvtl.s */ - {28,4,rr,V,V,0}, /* cvtw.d */ - {31,16,rr,V,V,0}, /* cvts.l.f */ - {32,15,rr,V,V,0}, /* cvtd.w.f */ - {33,11,rr,V,V,0}, /* cvtl.s.f */ - {28,12,rr,V,V,0}, /* cvtw.d.f */ - {114,0,rr,S,S,0}, /* enal */ - {8,7,rr,S,S,0}, /* shf.w */ - {115,0,rr,S,S,0}, /* enag */ - {0,0,0,0,0,0}, - {28,4,rr,S,S,0}, /* cvtw.d */ - {32,7,rr,S,S,0}, /* cvtd.w */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {116,3,rr,S,S,0}, /* frint.s */ - {116,4,rr,S,S,0}, /* frint.d */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {116,3,rr,V,V,0}, /* frint.s */ - {116,4,rr,V,V,0}, /* frint.d */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {116,11,rr,V,V,0}, /* frint.s.f */ - {116,12,rr,V,V,0}, /* frint.d.f */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {81,3,rr,V,V,0}, /* sqrt.s */ - {81,4,rr,V,V,0}, /* sqrt.d */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {81,11,rr,V,V,0}, /* sqrt.s.f */ - {81,12,rr,V,V,0}, /* sqrt.d.f */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, -}; -struct formstr e0_format3[] = { - {32,11,rr,V,V,0}, /* cvtd.s.f */ - {31,12,rr,V,V,0}, /* cvts.d.f */ - {33,12,rr,V,V,0}, /* cvtl.d.f */ - {32,16,rr,V,V,0}, /* cvtd.l.f */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {36,2,rr,V,V,0}, /* tzc.f */ - {44,2,rr,V,V,0}, /* lop.f */ - {117,2,rr,V,V,0}, /* xpnd.f */ - {42,2,rr,V,V,0}, /* not.f */ - {8,2,rr,S,V,0}, /* shf.f */ - {35,17,rr,V,V,0}, /* plc.t.f */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {37,11,rr,V,V,0}, /* eq.s.f */ - {37,12,rr,V,V,0}, /* eq.d.f */ - {43,11,rr,V,V,0}, /* neg.s.f */ - {43,12,rr,V,V,0}, /* neg.d.f */ - {37,11,rr,S,V,0}, /* eq.s.f */ - {37,12,rr,S,V,0}, /* eq.d.f */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {40,11,rr,V,V,0}, /* le.s.f */ - {40,12,rr,V,V,0}, /* le.d.f */ - {41,11,rr,V,V,0}, /* lt.s.f */ - {41,12,rr,V,V,0}, /* lt.d.f */ - {40,11,rr,S,V,0}, /* le.s.f */ - {40,12,rr,S,V,0}, /* le.d.f */ - {41,11,rr,S,V,0}, /* lt.s.f */ - {41,12,rr,S,V,0}, /* lt.d.f */ - {37,13,rr,V,V,0}, /* eq.b.f */ - {37,14,rr,V,V,0}, /* eq.h.f */ - {37,15,rr,V,V,0}, /* eq.w.f */ - {37,16,rr,V,V,0}, /* eq.l.f */ - {37,13,rr,S,V,0}, /* eq.b.f */ - {37,14,rr,S,V,0}, /* eq.h.f */ - {37,15,rr,S,V,0}, /* eq.w.f */ - {37,16,rr,S,V,0}, /* eq.l.f */ - {40,13,rr,V,V,0}, /* le.b.f */ - {40,14,rr,V,V,0}, /* le.h.f */ - {40,15,rr,V,V,0}, /* le.w.f */ - {40,16,rr,V,V,0}, /* le.l.f */ - {40,13,rr,S,V,0}, /* le.b.f */ - {40,14,rr,S,V,0}, /* le.h.f */ - {40,15,rr,S,V,0}, /* le.w.f */ - {40,16,rr,S,V,0}, /* le.l.f */ - {41,13,rr,V,V,0}, /* lt.b.f */ - {41,14,rr,V,V,0}, /* lt.h.f */ - {41,15,rr,V,V,0}, /* lt.w.f */ - {41,16,rr,V,V,0}, /* lt.l.f */ - {41,13,rr,S,V,0}, /* lt.b.f */ - {41,14,rr,S,V,0}, /* lt.h.f */ - {41,15,rr,S,V,0}, /* lt.w.f */ - {41,16,rr,S,V,0}, /* lt.l.f */ - {43,13,rr,V,V,0}, /* neg.b.f */ - {43,14,rr,V,V,0}, /* neg.h.f */ - {43,15,rr,V,V,0}, /* neg.w.f */ - {43,16,rr,V,V,0}, /* neg.l.f */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, -}; -struct formstr e0_format4[] = { - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, -}; -struct formstr e0_format5[] = { - {51,13,rr,V,V,0}, /* ldvi.b.f */ - {51,14,rr,V,V,0}, /* ldvi.h.f */ - {51,15,rr,V,V,0}, /* ldvi.w.f */ - {51,16,rr,V,V,0}, /* ldvi.l.f */ - {28,11,rr,V,V,0}, /* cvtw.s.f */ - {31,15,rr,V,V,0}, /* cvts.w.f */ - {28,16,rr,V,V,0}, /* cvtw.l.f */ - {33,15,rr,V,V,0}, /* cvtl.w.f */ - {52,13,rxr,V,V,0}, /* stvi.b.f */ - {52,14,rxr,V,V,0}, /* stvi.h.f */ - {52,15,rxr,V,V,0}, /* stvi.w.f */ - {52,16,rxr,V,V,0}, /* stvi.l.f */ - {52,13,rxr,S,V,0}, /* stvi.b.f */ - {52,14,rxr,S,V,0}, /* stvi.h.f */ - {52,15,rxr,S,V,0}, /* stvi.w.f */ - {52,16,rxr,S,V,0}, /* stvi.l.f */ -}; -struct formstr e0_format6[] = { - {0,0,rxl,S,CIR,0}, /* mov */ - {0,0,lr,CIR,S,0}, /* mov */ - {0,0,lr,TOC,S,0}, /* mov */ - {0,0,lr,CPUID,S,0}, /* mov */ - {0,0,rxl,S,TTR,0}, /* mov */ - {0,0,lr,TTR,S,0}, /* mov */ - {118,0,nops,0,0,0}, /* ctrsl */ - {119,0,nops,0,0,0}, /* ctrsg */ - {0,0,rxl,S,VMU,0}, /* mov */ - {0,0,lr,VMU,S,0}, /* mov */ - {0,0,rxl,S,VML,0}, /* mov */ - {0,0,lr,VML,S,0}, /* mov */ - {0,0,rxl,S,ICR,0}, /* mov */ - {0,0,lr,ICR,S,0}, /* mov */ - {0,0,rxl,S,TCPU,0}, /* mov */ - {0,0,lr,TCPU,S,0}, /* mov */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {120,0,nops,0,0,0}, /* stop */ - {0,0,0,0,0,0}, - {0,0,rxl,S,TID,0}, /* mov */ - {0,0,lr,TID,S,0}, /* mov */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, -}; -struct formstr e0_format7[] = { - {84,13,r,V,0,0}, /* sum.b.f */ - {84,14,r,V,0,0}, /* sum.h.f */ - {84,15,r,V,0,0}, /* sum.w.f */ - {84,16,r,V,0,0}, /* sum.l.f */ - {85,2,r,V,0,0}, /* all.f */ - {86,2,r,V,0,0}, /* any.f */ - {87,2,r,V,0,0}, /* parity.f */ - {0,0,0,0,0,0}, - {88,13,r,V,0,0}, /* max.b.f */ - {88,14,r,V,0,0}, /* max.h.f */ - {88,15,r,V,0,0}, /* max.w.f */ - {88,16,r,V,0,0}, /* max.l.f */ - {89,13,r,V,0,0}, /* min.b.f */ - {89,14,r,V,0,0}, /* min.h.f */ - {89,15,r,V,0,0}, /* min.w.f */ - {89,16,r,V,0,0}, /* min.l.f */ - {84,11,r,V,0,0}, /* sum.s.f */ - {84,12,r,V,0,0}, /* sum.d.f */ - {90,11,r,V,0,0}, /* prod.s.f */ - {90,12,r,V,0,0}, /* prod.d.f */ - {88,11,r,V,0,0}, /* max.s.f */ - {88,12,r,V,0,0}, /* max.d.f */ - {89,11,r,V,0,0}, /* min.s.f */ - {89,12,r,V,0,0}, /* min.d.f */ - {90,13,r,V,0,0}, /* prod.b.f */ - {90,14,r,V,0,0}, /* prod.h.f */ - {90,15,r,V,0,0}, /* prod.w.f */ - {90,16,r,V,0,0}, /* prod.l.f */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, -}; -struct formstr e1_format0[] = { - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {10,18,rrr,S,V,V}, /* sub.s.t */ - {10,19,rrr,S,V,V}, /* sub.d.t */ - {4,18,rrr,S,V,V}, /* div.s.t */ - {4,19,rrr,S,V,V}, /* div.d.t */ - {3,18,rrr,V,V,V}, /* mul.s.t */ - {3,19,rrr,V,V,V}, /* mul.d.t */ - {4,18,rrr,V,V,V}, /* div.s.t */ - {4,19,rrr,V,V,V}, /* div.d.t */ - {3,18,rrr,V,S,V}, /* mul.s.t */ - {3,19,rrr,V,S,V}, /* mul.d.t */ - {4,18,rrr,V,S,V}, /* div.s.t */ - {4,19,rrr,V,S,V}, /* div.d.t */ - {5,1,rrr,V,V,V}, /* and.t */ - {6,1,rrr,V,V,V}, /* or.t */ - {7,1,rrr,V,V,V}, /* xor.t */ - {8,1,rrr,V,V,V}, /* shf.t */ - {5,1,rrr,V,S,V}, /* and.t */ - {6,1,rrr,V,S,V}, /* or.t */ - {7,1,rrr,V,S,V}, /* xor.t */ - {8,1,rrr,V,S,V}, /* shf.t */ - {9,18,rrr,V,V,V}, /* add.s.t */ - {9,19,rrr,V,V,V}, /* add.d.t */ - {10,18,rrr,V,V,V}, /* sub.s.t */ - {10,19,rrr,V,V,V}, /* sub.d.t */ - {9,18,rrr,V,S,V}, /* add.s.t */ - {9,19,rrr,V,S,V}, /* add.d.t */ - {10,18,rrr,V,S,V}, /* sub.s.t */ - {10,19,rrr,V,S,V}, /* sub.d.t */ - {9,20,rrr,V,V,V}, /* add.b.t */ - {9,21,rrr,V,V,V}, /* add.h.t */ - {9,22,rrr,V,V,V}, /* add.w.t */ - {9,23,rrr,V,V,V}, /* add.l.t */ - {9,20,rrr,V,S,V}, /* add.b.t */ - {9,21,rrr,V,S,V}, /* add.h.t */ - {9,22,rrr,V,S,V}, /* add.w.t */ - {9,23,rrr,V,S,V}, /* add.l.t */ - {10,20,rrr,V,V,V}, /* sub.b.t */ - {10,21,rrr,V,V,V}, /* sub.h.t */ - {10,22,rrr,V,V,V}, /* sub.w.t */ - {10,23,rrr,V,V,V}, /* sub.l.t */ - {10,20,rrr,V,S,V}, /* sub.b.t */ - {10,21,rrr,V,S,V}, /* sub.h.t */ - {10,22,rrr,V,S,V}, /* sub.w.t */ - {10,23,rrr,V,S,V}, /* sub.l.t */ - {3,20,rrr,V,V,V}, /* mul.b.t */ - {3,21,rrr,V,V,V}, /* mul.h.t */ - {3,22,rrr,V,V,V}, /* mul.w.t */ - {3,23,rrr,V,V,V}, /* mul.l.t */ - {3,20,rrr,V,S,V}, /* mul.b.t */ - {3,21,rrr,V,S,V}, /* mul.h.t */ - {3,22,rrr,V,S,V}, /* mul.w.t */ - {3,23,rrr,V,S,V}, /* mul.l.t */ - {4,20,rrr,V,V,V}, /* div.b.t */ - {4,21,rrr,V,V,V}, /* div.h.t */ - {4,22,rrr,V,V,V}, /* div.w.t */ - {4,23,rrr,V,V,V}, /* div.l.t */ - {4,20,rrr,V,S,V}, /* div.b.t */ - {4,21,rrr,V,S,V}, /* div.h.t */ - {4,22,rrr,V,S,V}, /* div.w.t */ - {4,23,rrr,V,S,V}, /* div.l.t */ -}; -struct formstr e1_format1[] = { - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {26,20,a2r,S,0,0}, /* ste.b.t */ - {26,21,a2r,S,0,0}, /* ste.h.t */ - {26,22,a2r,S,0,0}, /* ste.w.t */ - {26,23,a2r,S,0,0}, /* ste.l.t */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {18,20,a1r,V,0,0}, /* ld.b.t */ - {18,21,a1r,V,0,0}, /* ld.h.t */ - {18,22,a1r,V,0,0}, /* ld.w.t */ - {18,23,a1r,V,0,0}, /* ld.l.t */ - {21,20,a2r,V,0,0}, /* st.b.t */ - {21,21,a2r,V,0,0}, /* st.h.t */ - {21,22,a2r,V,0,0}, /* st.w.t */ - {21,23,a2r,V,0,0}, /* st.l.t */ -}; -struct formstr e1_format2[] = { - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {28,20,rr,V,V,0}, /* cvtw.b.t */ - {28,21,rr,V,V,0}, /* cvtw.h.t */ - {29,22,rr,V,V,0}, /* cvtb.w.t */ - {30,22,rr,V,V,0}, /* cvth.w.t */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {31,23,rr,V,V,0}, /* cvts.l.t */ - {32,22,rr,V,V,0}, /* cvtd.w.t */ - {33,18,rr,V,V,0}, /* cvtl.s.t */ - {28,19,rr,V,V,0}, /* cvtw.d.t */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {116,18,rr,V,V,0}, /* frint.s.t */ - {116,19,rr,V,V,0}, /* frint.d.t */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {81,18,rr,V,V,0}, /* sqrt.s.t */ - {81,19,rr,V,V,0}, /* sqrt.d.t */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, -}; -struct formstr e1_format3[] = { - {32,18,rr,V,V,0}, /* cvtd.s.t */ - {31,19,rr,V,V,0}, /* cvts.d.t */ - {33,19,rr,V,V,0}, /* cvtl.d.t */ - {32,23,rr,V,V,0}, /* cvtd.l.t */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {36,1,rr,V,V,0}, /* tzc.t */ - {44,1,rr,V,V,0}, /* lop.t */ - {117,1,rr,V,V,0}, /* xpnd.t */ - {42,1,rr,V,V,0}, /* not.t */ - {8,1,rr,S,V,0}, /* shf.t */ - {35,24,rr,V,V,0}, /* plc.t.t */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {37,18,rr,V,V,0}, /* eq.s.t */ - {37,19,rr,V,V,0}, /* eq.d.t */ - {43,18,rr,V,V,0}, /* neg.s.t */ - {43,19,rr,V,V,0}, /* neg.d.t */ - {37,18,rr,S,V,0}, /* eq.s.t */ - {37,19,rr,S,V,0}, /* eq.d.t */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {40,18,rr,V,V,0}, /* le.s.t */ - {40,19,rr,V,V,0}, /* le.d.t */ - {41,18,rr,V,V,0}, /* lt.s.t */ - {41,19,rr,V,V,0}, /* lt.d.t */ - {40,18,rr,S,V,0}, /* le.s.t */ - {40,19,rr,S,V,0}, /* le.d.t */ - {41,18,rr,S,V,0}, /* lt.s.t */ - {41,19,rr,S,V,0}, /* lt.d.t */ - {37,20,rr,V,V,0}, /* eq.b.t */ - {37,21,rr,V,V,0}, /* eq.h.t */ - {37,22,rr,V,V,0}, /* eq.w.t */ - {37,23,rr,V,V,0}, /* eq.l.t */ - {37,20,rr,S,V,0}, /* eq.b.t */ - {37,21,rr,S,V,0}, /* eq.h.t */ - {37,22,rr,S,V,0}, /* eq.w.t */ - {37,23,rr,S,V,0}, /* eq.l.t */ - {40,20,rr,V,V,0}, /* le.b.t */ - {40,21,rr,V,V,0}, /* le.h.t */ - {40,22,rr,V,V,0}, /* le.w.t */ - {40,23,rr,V,V,0}, /* le.l.t */ - {40,20,rr,S,V,0}, /* le.b.t */ - {40,21,rr,S,V,0}, /* le.h.t */ - {40,22,rr,S,V,0}, /* le.w.t */ - {40,23,rr,S,V,0}, /* le.l.t */ - {41,20,rr,V,V,0}, /* lt.b.t */ - {41,21,rr,V,V,0}, /* lt.h.t */ - {41,22,rr,V,V,0}, /* lt.w.t */ - {41,23,rr,V,V,0}, /* lt.l.t */ - {41,20,rr,S,V,0}, /* lt.b.t */ - {41,21,rr,S,V,0}, /* lt.h.t */ - {41,22,rr,S,V,0}, /* lt.w.t */ - {41,23,rr,S,V,0}, /* lt.l.t */ - {43,20,rr,V,V,0}, /* neg.b.t */ - {43,21,rr,V,V,0}, /* neg.h.t */ - {43,22,rr,V,V,0}, /* neg.w.t */ - {43,23,rr,V,V,0}, /* neg.l.t */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, -}; -struct formstr e1_format4[] = { - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, -}; -struct formstr e1_format5[] = { - {51,20,rr,V,V,0}, /* ldvi.b.t */ - {51,21,rr,V,V,0}, /* ldvi.h.t */ - {51,22,rr,V,V,0}, /* ldvi.w.t */ - {51,23,rr,V,V,0}, /* ldvi.l.t */ - {28,18,rr,V,V,0}, /* cvtw.s.t */ - {31,22,rr,V,V,0}, /* cvts.w.t */ - {28,23,rr,V,V,0}, /* cvtw.l.t */ - {33,22,rr,V,V,0}, /* cvtl.w.t */ - {52,20,rxr,V,V,0}, /* stvi.b.t */ - {52,21,rxr,V,V,0}, /* stvi.h.t */ - {52,22,rxr,V,V,0}, /* stvi.w.t */ - {52,23,rxr,V,V,0}, /* stvi.l.t */ - {52,20,rxr,S,V,0}, /* stvi.b.t */ - {52,21,rxr,S,V,0}, /* stvi.h.t */ - {52,22,rxr,S,V,0}, /* stvi.w.t */ - {52,23,rxr,S,V,0}, /* stvi.l.t */ -}; -struct formstr e1_format6[] = { - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, -}; -struct formstr e1_format7[] = { - {84,20,r,V,0,0}, /* sum.b.t */ - {84,21,r,V,0,0}, /* sum.h.t */ - {84,22,r,V,0,0}, /* sum.w.t */ - {84,23,r,V,0,0}, /* sum.l.t */ - {85,1,r,V,0,0}, /* all.t */ - {86,1,r,V,0,0}, /* any.t */ - {87,1,r,V,0,0}, /* parity.t */ - {0,0,0,0,0,0}, - {88,20,r,V,0,0}, /* max.b.t */ - {88,21,r,V,0,0}, /* max.h.t */ - {88,22,r,V,0,0}, /* max.w.t */ - {88,23,r,V,0,0}, /* max.l.t */ - {89,20,r,V,0,0}, /* min.b.t */ - {89,21,r,V,0,0}, /* min.h.t */ - {89,22,r,V,0,0}, /* min.w.t */ - {89,23,r,V,0,0}, /* min.l.t */ - {84,18,r,V,0,0}, /* sum.s.t */ - {84,19,r,V,0,0}, /* sum.d.t */ - {90,18,r,V,0,0}, /* prod.s.t */ - {90,19,r,V,0,0}, /* prod.d.t */ - {88,18,r,V,0,0}, /* max.s.t */ - {88,19,r,V,0,0}, /* max.d.t */ - {89,18,r,V,0,0}, /* min.s.t */ - {89,19,r,V,0,0}, /* min.d.t */ - {90,20,r,V,0,0}, /* prod.b.t */ - {90,21,r,V,0,0}, /* prod.h.t */ - {90,22,r,V,0,0}, /* prod.w.t */ - {90,23,r,V,0,0}, /* prod.l.t */ - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, - {0,0,0,0,0,0}, -}; -char *lop[] = { - "mov", /* 0 */ - "merg", /* 1 */ - "mask", /* 2 */ - "mul", /* 3 */ - "div", /* 4 */ - "and", /* 5 */ - "or", /* 6 */ - "xor", /* 7 */ - "shf", /* 8 */ - "add", /* 9 */ - "sub", /* 10 */ - "exit", /* 11 */ - "jmp", /* 12 */ - "jmpi", /* 13 */ - "jmpa", /* 14 */ - "jmps", /* 15 */ - "tac", /* 16 */ - "ldea", /* 17 */ - "ld", /* 18 */ - "tas", /* 19 */ - "pshea", /* 20 */ - "st", /* 21 */ - "call", /* 22 */ - "calls", /* 23 */ - "callq", /* 24 */ - "pfork", /* 25 */ - "ste", /* 26 */ - "incr", /* 27 */ - "cvtw", /* 28 */ - "cvtb", /* 29 */ - "cvth", /* 30 */ - "cvts", /* 31 */ - "cvtd", /* 32 */ - "cvtl", /* 33 */ - "ldpa", /* 34 */ - "plc", /* 35 */ - "tzc", /* 36 */ - "eq", /* 37 */ - "leu", /* 38 */ - "ltu", /* 39 */ - "le", /* 40 */ - "lt", /* 41 */ - "not", /* 42 */ - "neg", /* 43 */ - "lop", /* 44 */ - "cprs", /* 45 */ - "nop", /* 46 */ - "br", /* 47 */ - "bri", /* 48 */ - "bra", /* 49 */ - "brs", /* 50 */ - "ldvi", /* 51 */ - "stvi", /* 52 */ - "ldsdr", /* 53 */ - "ldkdr", /* 54 */ - "ln", /* 55 */ - "patu", /* 56 */ - "pate", /* 57 */ - "pich", /* 58 */ - "plch", /* 59 */ - "idle", /* 60 */ - "rtnq", /* 61 */ - "cfork", /* 62 */ - "rtn", /* 63 */ - "wfork", /* 64 */ - "join", /* 65 */ - "rtnc", /* 66 */ - "exp", /* 67 */ - "sin", /* 68 */ - "cos", /* 69 */ - "psh", /* 70 */ - "pop", /* 71 */ - "eni", /* 72 */ - "dsi", /* 73 */ - "bkpt", /* 74 */ - "msync", /* 75 */ - "mski", /* 76 */ - "xmti", /* 77 */ - "tstvv", /* 78 */ - "diag", /* 79 */ - "pbkpt", /* 80 */ - "sqrt", /* 81 */ - "casr", /* 82 */ - "atan", /* 83 */ - "sum", /* 84 */ - "all", /* 85 */ - "any", /* 86 */ - "parity", /* 87 */ - "max", /* 88 */ - "min", /* 89 */ - "prod", /* 90 */ - "halt", /* 91 */ - "sysc", /* 92 */ - "trap", /* 93 */ - "tst", /* 94 */ - "lck", /* 95 */ - "ulk", /* 96 */ - "spawn", /* 97 */ - "ldcmr", /* 98 */ - "stcmr", /* 99 */ - "popr", /* 100 */ - "pshr", /* 101 */ - "rcvr", /* 102 */ - "matm", /* 103 */ - "sndr", /* 104 */ - "putr", /* 105 */ - "getr", /* 106 */ - "matr", /* 107 */ - "mat", /* 108 */ - "get", /* 109 */ - "rcv", /* 110 */ - "inc", /* 111 */ - "put", /* 112 */ - "snd", /* 113 */ - "enal", /* 114 */ - "enag", /* 115 */ - "frint", /* 116 */ - "xpnd", /* 117 */ - "ctrsl", /* 118 */ - "ctrsg", /* 119 */ - "stop", /* 120 */ -}; -char *rop[] = { - "", /* 0 */ - ".t", /* 1 */ - ".f", /* 2 */ - ".s", /* 3 */ - ".d", /* 4 */ - ".b", /* 5 */ - ".h", /* 6 */ - ".w", /* 7 */ - ".l", /* 8 */ - ".x", /* 9 */ - ".u", /* 10 */ - ".s.f", /* 11 */ - ".d.f", /* 12 */ - ".b.f", /* 13 */ - ".h.f", /* 14 */ - ".w.f", /* 15 */ - ".l.f", /* 16 */ - ".t.f", /* 17 */ - ".s.t", /* 18 */ - ".d.t", /* 19 */ - ".b.t", /* 20 */ - ".h.t", /* 21 */ - ".w.t", /* 22 */ - ".l.t", /* 23 */ - ".t.t", /* 24 */ -}; diff --git a/include/dwarf.h b/include/dwarf.h deleted file mode 100755 index fb40c452427..00000000000 --- a/include/dwarf.h +++ /dev/null @@ -1,257 +0,0 @@ -/* Dwarf definitions. - - This file is derived from the DWARF specification, Draft #5 by the UNIX - International Programming Languages Special Interest Group dated 10/21/91. - - (Extracted from GCC 2.0, snapshot 312 and placed in Cygnus include - tree on 11/16/91 by Fred Fish, as part of gdb SVR4 DWARF support.) -*/ - -/* Tag names and codes: Figure 9. */ - -#define TAG_padding 0x0000 -#define TAG_array_type 0x0001 -#define TAG_class_type 0x0002 -#define TAG_entry_point 0x0003 -#define TAG_enumeration_type 0x0004 -#define TAG_formal_parameter 0x0005 -#define TAG_global_subroutine 0x0006 -#define TAG_global_variable 0x0007 -#define TAG_imported_declaration 0x0008 - -#define TAG_label 0x000a -#define TAG_lexical_block 0x000b -#define TAG_local_variable 0x000c -#define TAG_member 0x000d - -#define TAG_pointer_type 0x000f -#define TAG_reference_type 0x0010 -#define TAG_compile_unit 0x0011 -#define TAG_source_file 0x0011 -#define TAG_string_type 0x0012 -#define TAG_structure_type 0x0013 -#define TAG_subroutine 0x0014 -#define TAG_subroutine_type 0x0015 -#define TAG_typedef 0x0016 -#define TAG_union_type 0x0017 -#define TAG_unspecified_parameters 0x0018 -#define TAG_variant 0x0019 -#define TAG_common_block 0x001a -#define TAG_common_inclusion 0x001b -#define TAG_format 0x001c -#define TAG_inheritance 0x001d -#define TAG_inlined_subroutine 0x001e -#define TAG_module 0x001f -#define TAG_ptr_to_member_type 0x0020 -#define TAG_set_type 0x0021 -#define TAG_subrange_type 0x0022 -#define TAG_with_stmt 0x0023 - -#define TAG_lo_user 0x8000 -#define TAG_hi_user 0xffff - -/* Form names and codes: Figure 10. */ - -#define FORM_ADDR 0x1 -#define FORM_REF 0x2 -#define FORM_BLOCK2 0x3 -#define FORM_BLOCK4 0x4 -#define FORM_DATA2 0x5 -#define FORM_DATA4 0x6 -#define FORM_DATA8 0x7 -#define FORM_STRING 0x8 - -/* Attribute names and codes: Figure 11. */ - -#define AT_sibling /* reference */ (0x0010|FORM_REF) -#define AT_location /* block2 */ (0x0020|FORM_BLOCK2) -#define AT_name /* string */ (0x0030|FORM_STRING) -#define AT_fund_type /* halfword */ (0x0050|FORM_DATA2) -#define AT_mod_fund_type /* block2 */ (0x0060|FORM_BLOCK2) -#define AT_user_def_type /* reference */ (0x0070|FORM_REF) -#define AT_mod_u_d_type /* block2 */ (0x0080|FORM_BLOCK2) -#define AT_ordering /* halfword */ (0x0090|FORM_DATA2) -#define AT_subscr_data /* block2 */ (0x00a0|FORM_BLOCK2) -#define AT_byte_size /* word */ (0x00b0|FORM_DATA4) -#define AT_bit_offset /* halfword */ (0x00c0|FORM_DATA2) -#define AT_bit_size /* word */ (0x00d0|FORM_DATA4) - -#define AT_element_list /* block4 */ (0x00f0|FORM_BLOCK4) -#define AT_stmt_list /* word */ (0x0100|FORM_DATA4) -#define AT_low_pc /* address */ (0x0110|FORM_ADDR) -#define AT_high_pc /* address */ (0x0120|FORM_ADDR) -#define AT_language /* word */ (0x0130|FORM_DATA4) -#define AT_member /* reference */ (0x0140|FORM_REF) -#define AT_discr /* reference */ (0x0150|FORM_REF) -#define AT_discr_value /* block2 */ (0x0160|FORM_BLOCK2) -#define AT_visibility /* halfword */ (0x0170|FORM_DATA2) -#define AT_import /* reference */ (0x0180|FORM_REF) -#define AT_string_length /* block2 */ (0x0190|FORM_BLOCK2) -#define AT_common_reference /* reference */ (0x01a0|FORM_REF) -#define AT_comp_dir /* string */ (0x01b0|FORM_STRING) - -#define AT_const_value_string /* string */ (0x01c0|FORM_STRING) -#define AT_const_value_data2 /* halfword */ (0x01c0|FORM_DATA2) -#define AT_const_value_data4 /* word */ (0x01c0|FORM_DATA4) -#define AT_const_value_data8 /* doubleword */(0x01c0|FORM_DATA8) -#define AT_const_value_block2 /* block2 */ (0x01c0|FORM_BLOCK2) -#define AT_const_value_block4 /* block4 */ (0x01c0|FORM_BLOCK4) - -#define AT_containing_type /* reference */ (0x01d0|FORM_REF) - -#define AT_default_value_addr /* address */ (0x01e0|FORM_ADDR) -#define AT_default_value_data2 /* halfword */ (0x01e0|FORM_DATA2) -#define AT_default_value_data4 /* word */ (0x01e0|FORM_DATA4) -#define AT_default_value_data8 /* doubleword */(0x01e0|FORM_DATA8) -#define AT_default_value_string /* string */ (0x01e0|FORM_STRING) - -#define AT_friends /* block2 */ (0x01f0|FORM_BLOCK2) -#define AT_inline /* string */ (0x0200|FORM_STRING) -#define AT_is_optional /* string */ (0x0210|FORM_STRING) - -#define AT_lower_bound_ref /* reference */ (0x0220|FORM_REF) -#define AT_lower_bound_data2 /* halfword */ (0x0220|FORM_DATA2) -#define AT_lower_bound_data4 /* word */ (0x0220|FORM_DATA4) -#define AT_lower_bound_data8 /* doubleword */(0x0220|FORM_DATA8) - -#define AT_main_program /* string */ (0x0230|FORM_STRING) -#define AT_private /* string */ (0x0240|FORM_STRING) -#define AT_producer /* string */ (0x0250|FORM_STRING) -#define AT_protected /* string */ (0x0260|FORM_STRING) -#define AT_prototyped /* string */ (0x0270|FORM_STRING) -#define AT_public /* string */ (0x0280|FORM_STRING) -#define AT_pure_virtual /* string */ (0x0290|FORM_STRING) -#define AT_return_addr_loc /* block2 */ (0x02a0|FORM_BLOCK2) -#define AT_specification /* reference */ (0x02b0|FORM_REF) -#define AT_start_scope /* word */ (0x02c0|FORM_DATA4) -#define AT_static_link_loc /* block2 */ (0x02d0|FORM_BLOCK2) -#define AT_stride_size /* word */ (0x02e0|FORM_DATA4) - -#define AT_upper_bound_ref /* reference */ (0x02f0|FORM_REF) -#define AT_upper_bound_data2 /* halfword */ (0x02f0|FORM_DATA2) -#define AT_upper_bound_data4 /* word */ (0x02f0|FORM_DATA4) -#define AT_upper_bound_data8 /* doubleword */(0x02f0|FORM_DATA8) - -#define AT_virtual /* string */ (0x0300|FORM_STRING) -#define AT_frame_base /* block2 */ (0x0310|FORM_BLOCK2) - -/* GNU attribute extensions. */ - -#define AT_sf_names /* word */ (0x8000|FORM_DATA4) -#define AT_src_info /* word */ (0x8010|FORM_DATA4) -#define AT_mac_info /* word */ (0x8020|FORM_DATA4) - -#define AT_lo_user /* - */ 0x8000 -#define AT_hi_user /* - */ 0xffff - -/* Location atom names and codes: Figure 13. */ - -#define OP_REG 0x01 -#define OP_BASEREG 0x02 -#define OP_ADDR 0x03 -#define OP_CONST 0x04 -#define OP_DEREF2 0x05 -#define OP_DEREF4 0x06 -#define OP_ADD 0x07 - -#define OP_LO_USER 0x80 -#define OP_HI_USER 0xff - -/* Fundamental type names and codes: figure 14. */ - -#define FT_char 0x0001 -#define FT_signed_char 0x0002 -#define FT_unsigned_char 0x0003 -#define FT_short 0x0004 -#define FT_signed_short 0x0005 -#define FT_unsigned_short 0x0006 -#define FT_integer 0x0007 -#define FT_signed_integer 0x0008 -#define FT_unsigned_integer 0x0009 -#define FT_long 0x000a -#define FT_signed_long 0x000b -#define FT_unsigned_long 0x000c -#define FT_pointer 0x000d -#define FT_float 0x000e -#define FT_dbl_prec_float 0x000f -#define FT_ext_prec_float 0x0010 /* not accepted by "classic" svr4 SDB */ -#define FT_complex 0x0011 /* not accepted by "classic" svr4 SDB */ -#define FT_dbl_prec_complex 0x0012 /* not accepted by "classic" svr4 SDB */ - -#define FT_void 0x0014 -#define FT_boolean 0x0015 /* not accepted by "classic" svr4 SDB */ -#define FT_ext_prec_complex 0x0016 /* not accepted by "classic" svr4 SDB */ - -/* GNU-specific fundamental type codes - not accepted by "classic" svr4 SDB */ - -#define FT_long_long 0x8000 -#define FT_signed_long_long 0x8001 -#define FT_unsigned_long_long 0x8002 - -#define FT_lo_user 0x8000 -#define FT_hi_user 0xffff - -/* Type modifier names and codes: Figure 15. */ - -#define MOD_pointer_to 0x01 -#define MOD_reference_to 0x02 -#define MOD_const 0x03 -#define MOD_volatile 0x04 - -#define MOD_lo_user 0x80 -#define MOD_hi_user 0xff - -/* Visibility names and codes: Figure 16. */ - -#define VIS_local 0x00 -#define VIS_exported 0x01 - -#define VIS_lo_user 0x80 -#define VIS_hi_user 0xff - -/* Array ordering names and codes: Figure 18. */ - -#define ORD_row_major 0 -#define ORD_col_major 1 - -/* Array subscript format names and codes: Figure 19. */ - -#define FMT_FT_C_C 0x0 -#define FMT_FT_C_X 0x1 -#define FMT_FT_X_C 0x2 -#define FMT_FT_X_X 0x3 -#define FMT_UT_C_C 0x4 -#define FMT_UT_C_X 0x5 -#define FMT_UT_X_C 0x6 -#define FMT_UT_X_X 0x7 -#define FMT_ET 0x8 - -/* Derived from above for ease of use. */ - -#define FMT_CODE(_FUNDAMENTAL_TYPE_P, _UB_CONST_P, _LB_CONST_P) \ - (((_FUNDAMENTAL_TYPE_P) ? 0 : 4) \ - | ((_UB_CONST_P) ? 0 : 2) \ - | ((_LB_CONST_P) ? 0 : 1)) - -/* Source language names and codes: Figure 17. */ - -#define LANG_C89 0x0001 -#define LANG_C 0x0002 -#define LANG_ADA83 0x0003 -#define LANG_C_PLUS_PLUS 0x0004 -#define LANG_COBOL74 0x0005 -#define LANG_COBOL85 0x0006 -#define LANG_FORTRAN77 0x0007 -#define LANG_FORTRAN90 0x0008 -#define LANG_PASCAL83 0x0009 -#define LANG_MODULA2 0x000a - -#define LANG_LO_USER 0x8000 -#define LANG_HI_USER 0xffff - -/* Names and codes for GNU "macinfo" extension. */ - -#define MACINFO_start 's' -#define MACINFO_resume 'r' -#define MACINFO_define 'd' -#define MACINFO_undef 'u' diff --git a/include/elf-common.h b/include/elf-common.h deleted file mode 100755 index cd15b9b2f11..00000000000 --- a/include/elf-common.h +++ /dev/null @@ -1,167 +0,0 @@ -/* ELF support for BFD. - Copyright (C) 1991 Free Software Foundation, Inc. - - Written by Fred Fish @ Cygnus Support, from information published - in "UNIX System V Release 4, Programmers Guide: ANSI C and - Programming Support Tools". - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - - -/* This file is part of ELF support for BFD, and contains the portions - that are common to both the internal and external representations. - For example, ELFMAG0 is the byte 0x7F in both the internal (in-memory) - and external (in-file) representations. */ - - -/* Fields in e_ident[] */ - -#define EI_MAG0 0 /* File identification byte 0 index */ -#define ELFMAG0 0x7F /* Magic number byte 0 */ - -#define EI_MAG1 1 /* File identification byte 1 index */ -#define ELFMAG1 'E' /* Magic number byte 1 */ - -#define EI_MAG2 2 /* File identification byte 2 index */ -#define ELFMAG2 'L' /* Magic number byte 2 */ - -#define EI_MAG3 3 /* File identification byte 3 index */ -#define ELFMAG3 'F' /* Magic number byte 3 */ - -#define EI_CLASS 4 /* File class */ -#define ELFCLASSNONE 0 /* Invalid class */ -#define ELFCLASS32 1 /* 32-bit objects */ -#define ELFCLASS64 2 /* 64-bit objects */ - -#define EI_DATA 5 /* Data encoding */ -#define ELFDATANONE 0 /* Invalid data encoding */ -#define ELFDATA2LSB 1 /* 2's complement, little endian */ -#define ELFDATA2MSB 2 /* 2's complement, big endian */ - -#define EI_VERSION 6 /* File version */ - -#define EI_PAD 7 /* Start of padding bytes */ - - -/* Values for e_type, which identifies the object file type */ - -#define ET_NONE 0 /* No file type */ -#define ET_REL 1 /* Relocatable file */ -#define ET_EXEC 2 /* Executable file */ -#define ET_DYN 3 /* Shared object file */ -#define ET_CORE 4 /* Core file */ -#define ET_LOPROC 0xFF00 /* Processor-specific */ -#define ET_HIPROC 0xFFFF /* Processor-specific */ - -/* Values for e_machine, which identifies the architecture */ - -#define EM_NONE 0 /* No machine */ -#define EM_M32 1 /* AT&T WE 32100 */ -#define EM_SPARC 2 /* SUN SPARC */ -#define EM_386 3 /* Intel 80386 */ -#define EM_68K 4 /* Motorola m68k family */ -#define EM_88K 5 /* Motorola m88k family */ -#define EM_860 6 /* Intel 80860 */ - -/* Values for e_version */ - -#define EV_NONE 0 /* Invalid ELF version */ -#define EV_CURRENT 1 /* Current version */ - -/* Values for program header, p_type field */ - -#define PT_NULL 0 /* Program header table entry unused */ -#define PT_LOAD 1 /* Loadable program segment */ -#define PT_DYNAMIC 2 /* Dynamic linking information */ -#define PT_INTERP 3 /* Program interpreter */ -#define PT_NOTE 4 /* Auxiliary information */ -#define PT_SHLIB 5 /* Reserved, unspecified semantics */ -#define PT_PHDR 6 /* Entry for header table itself */ -#define PT_LOPROC 0x70000000 /* Processor-specific */ -#define PT_HIPROC 0x7FFFFFFF /* Processor-specific */ - -/* Program segment permissions, in program header p_flags field */ - -#define PF_X (1 << 0) /* Segment is executable */ -#define PF_W (1 << 1) /* Segment is writable */ -#define PF_R (1 << 2) /* Segment is readable */ -#define PF_MASKPROC 0xF0000000 /* Processor-specific reserved bits */ - -/* Values for section header, sh_type field */ - -#define SHT_NULL 0 /* Section header table entry unused */ -#define SHT_PROGBITS 1 /* Program specific (private) data */ -#define SHT_SYMTAB 2 /* Link editing symbol table */ -#define SHT_STRTAB 3 /* A string table */ -#define SHT_RELA 4 /* Relocation entries with addends */ -#define SHT_HASH 5 /* A symbol hash table */ -#define SHT_DYNAMIC 6 /* Information for dynamic linking */ -#define SHT_NOTE 7 /* Information that marks file */ -#define SHT_NOBITS 8 /* Section occupies no space in file */ -#define SHT_REL 9 /* Relocation entries, no addends */ -#define SHT_SHLIB 10 /* Reserved, unspecified semantics */ -#define SHT_DYNSYM 11 /* Dynamic linking symbol table */ -#define SHT_LOPROC 0x70000000 /* Processor-specific semantics, lo */ -#define SHT_HIPROC 0x7FFFFFFF /* Processor-specific semantics, hi */ -#define SHT_LOUSER 0x80000000 /* Application-specific semantics */ -#define SHT_HIUSER 0x8FFFFFFF /* Application-specific semantics */ - -/* Values for section header, sh_flags field */ - -#define SHF_WRITE (1 << 0) /* Writable data during execution */ -#define SHF_ALLOC (1 << 1) /* Occupies memory during execution */ -#define SHF_EXECINSTR (1 << 2) /* Executable machine instructions */ -#define SHF_MASKPROC 0xF0000000 /* Processor-specific semantics */ - -/* Values of note segment descriptor types for core files. */ - -#define NT_PRSTATUS 1 /* Contains copy of prstatus struct */ -#define NT_FPREGSET 2 /* Contains copy of fpregset struct */ -#define NT_PRPSINFO 3 /* Contains copy of prpsinfo struct */ - -/* These three macros disassemble and assemble a symbol table st_info field, - which contains the symbol binding and symbol type. The STB_ and STT_ - defines identify the binding and type. */ - -#define ELF_ST_BIND(val) (((unsigned int)(val)) >> 4) -#define ELF_ST_TYPE(val) ((val) & 0xF) -#define ELF_ST_INFO(bind,type) (((bind) << 4) & ((type) & 0xF)) - -#define STB_LOCAL 0 /* Symbol not visible outside obj */ -#define STB_GLOBAL 1 /* Symbol visible outside obj */ -#define STB_WEAK 2 /* Like globals, lower precedence */ -#define STB_LOPROC 13 /* Application-specific semantics */ -#define STB_HIPROC 15 /* Application-specific semantics */ - -#define STT_NOTYPE 0 /* Symbol type is unspecified */ -#define STT_OBJECT 1 /* Symbol is a data object */ -#define STT_FUNC 2 /* Symbol is a code object */ -#define STT_SECTION 3 /* Symbol associated with a section */ -#define STT_FILE 4 /* Symbol gives a file name */ -#define STT_LOPROC 13 /* Application-specific semantics */ -#define STT_HIPROC 15 /* Application-specific semantics */ - -/* Special section indices, which may show up in st_shndx fields, among - other places. */ - -#define SHN_UNDEF 0 /* Undefined section reference */ -#define SHN_LORESERV 0xFF00 /* Begin range of reserved indices */ -#define SHN_LOPROC 0xFF00 /* Begin range of appl-specific */ -#define SHN_HIPROC 0xFF1F /* End range of appl-specific */ -#define SHN_ABS 0xFFF1 /* Associated symbol is absolute */ -#define SHN_COMMON 0xFFF2 /* Associated symbol is in common */ -#define SHN_HIRESERVE 0xFFFF /* End range of reserved indices */ diff --git a/include/elf-external.h b/include/elf-external.h deleted file mode 100755 index 0cc8eebe142..00000000000 --- a/include/elf-external.h +++ /dev/null @@ -1,96 +0,0 @@ -/* ELF support for BFD. - Copyright (C) 1991 Free Software Foundation, Inc. - - Written by Fred Fish @ Cygnus Support, from information published - in "UNIX System V Release 4, Programmers Guide: ANSI C and - Programming Support Tools". - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - - -/* This file is part of ELF support for BFD, and contains the portions - that describe how ELF is represented externally by the BFD library. - I.E. it describes the in-file representation of ELF. It requires - the elf-common.h file which contains the portions that are common to - both the internal and external representations. */ - -/* ELF Header (32-bit implementations) */ - -typedef struct { - unsigned char e_ident[16]; /* ELF "magic number" */ - unsigned char e_type[2]; /* Identifies object file type */ - unsigned char e_machine[2]; /* Specifies required architecture */ - unsigned char e_version[4]; /* Identifies object file version */ - unsigned char e_entry[4]; /* Entry point virtual address */ - unsigned char e_phoff[4]; /* Program header table file offset */ - unsigned char e_shoff[4]; /* Section header table file offset */ - unsigned char e_flags[4]; /* Processor-specific flags */ - unsigned char e_ehsize[2]; /* ELF header size in bytes */ - unsigned char e_phentsize[2]; /* Program header table entry size */ - unsigned char e_phnum[2]; /* Program header table entry count */ - unsigned char e_shentsize[2]; /* Section header table entry size */ - unsigned char e_shnum[2]; /* Section header table entry count */ - unsigned char e_shstrndx[2]; /* Section header string table index */ -} Elf_External_Ehdr; - -/* Program header */ - -typedef struct { - unsigned char p_type[4]; /* Identifies program segment type */ - unsigned char p_offset[4]; /* Segment file offset */ - unsigned char p_vaddr[4]; /* Segment virtual address */ - unsigned char p_paddr[4]; /* Segment physical address */ - unsigned char p_filesz[4]; /* Segment size in file */ - unsigned char p_memsz[4]; /* Segment size in memory */ - unsigned char p_flags[4]; /* Segment flags */ - unsigned char p_align[4]; /* Segment alignment, file & memory */ -} Elf_External_Phdr; - -/* Section header */ - -typedef struct { - unsigned char sh_name[4]; /* Section name, index in string tbl */ - unsigned char sh_type[4]; /* Type of section */ - unsigned char sh_flags[4]; /* Miscellaneous section attributes */ - unsigned char sh_addr[4]; /* Section virtual addr at execution */ - unsigned char sh_offset[4]; /* Section file offset */ - unsigned char sh_size[4]; /* Size of section in bytes */ - unsigned char sh_link[4]; /* Index of another section */ - unsigned char sh_info[4]; /* Additional section information */ - unsigned char sh_addralign[4]; /* Section alignment */ - unsigned char sh_entsize[4]; /* Entry size if section holds table */ -} Elf_External_Shdr; - -/* Symbol table entry */ - -typedef struct { - unsigned char st_name[4]; /* Symbol name, index in string tbl */ - unsigned char st_value[4]; /* Value of the symbol */ - unsigned char st_size[4]; /* Associated symbol size */ - unsigned char st_info[1]; /* Type and binding attributes */ - unsigned char st_other[1]; /* No defined meaning, 0 */ - unsigned char st_shndx[2]; /* Associated section index */ -} Elf_External_Sym; - -/* Note segments */ - -typedef struct { - unsigned char namesz[4]; /* Size of entry's owner string */ - unsigned char descsz[4]; /* Size of the note descriptor */ - unsigned char type[4]; /* Interpretation of the descriptor */ - char name[1]; /* Start of the name+desc data */ -} Elf_External_Note; diff --git a/include/elf-internal.h b/include/elf-internal.h deleted file mode 100755 index 40193737ea0..00000000000 --- a/include/elf-internal.h +++ /dev/null @@ -1,107 +0,0 @@ -/* ELF support for BFD. - Copyright (C) 1991 Free Software Foundation, Inc. - - Written by Fred Fish @ Cygnus Support, from information published - in "UNIX System V Release 4, Programmers Guide: ANSI C and - Programming Support Tools". - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - - -/* This file is part of ELF support for BFD, and contains the portions - that describe how ELF is represented internally in the BFD library. - I.E. it describes the in-memory representation of ELF. It requires - the elf-common.h file which contains the portions that are common to - both the internal and external representations. */ - -/* Types used by various structures, functions, etc. */ - -typedef unsigned long Elf_Addr; /* Unsigned program address */ -typedef unsigned long Elf_Off; /* Unsigned file offset */ -typedef long Elf_Sword; /* Signed large integer */ -typedef unsigned long Elf_Word; /* Unsigned large integer */ -typedef unsigned short Elf_Half; /* Unsigned medium integer */ -typedef unsigned char Elf_Char; /* Unsigned tiny integer */ - -/* ELF Header */ - -#define EI_NIDENT 16 /* Size of e_ident[] */ - -typedef struct { - unsigned char e_ident[EI_NIDENT]; /* ELF "magic number" */ - Elf_Half e_type; /* Identifies object file type */ - Elf_Half e_machine; /* Specifies required architecture */ - Elf_Word e_version; /* Identifies object file version */ - Elf_Addr e_entry; /* Entry point virtual address */ - Elf_Off e_phoff; /* Program header table file offset */ - Elf_Off e_shoff; /* Section header table file offset */ - Elf_Word e_flags; /* Processor-specific flags */ - Elf_Half e_ehsize; /* ELF header size in bytes */ - Elf_Half e_phentsize; /* Program header table entry size */ - Elf_Half e_phnum; /* Program header table entry count */ - Elf_Half e_shentsize; /* Section header table entry size */ - Elf_Half e_shnum; /* Section header table entry count */ - Elf_Half e_shstrndx; /* Section header string table index */ -} Elf_Internal_Ehdr; - -/* Program header */ - -typedef struct { - Elf_Word p_type; /* Identifies program segment type */ - Elf_Off p_offset; /* Segment file offset */ - Elf_Addr p_vaddr; /* Segment virtual address */ - Elf_Addr p_paddr; /* Segment physical address */ - Elf_Word p_filesz; /* Segment size in file */ - Elf_Word p_memsz; /* Segment size in memory */ - Elf_Word p_flags; /* Segment flags */ - Elf_Word p_align; /* Segment alignment, file & memory */ -} Elf_Internal_Phdr; - -/* Section header */ - -typedef struct { - Elf_Word sh_name; /* Section name, index in string tbl */ - Elf_Word sh_type; /* Type of section */ - Elf_Word sh_flags; /* Miscellaneous section attributes */ - Elf_Addr sh_addr; /* Section virtual addr at execution */ - Elf_Off sh_offset; /* Section file offset */ - Elf_Word sh_size; /* Size of section in bytes */ - Elf_Word sh_link; /* Index of another section */ - Elf_Word sh_info; /* Additional section information */ - Elf_Word sh_addralign; /* Section alignment */ - Elf_Word sh_entsize; /* Entry size if section holds table */ -} Elf_Internal_Shdr; - -/* Symbol table entry */ - -typedef struct { - Elf_Word st_name; /* Symbol name, index in string tbl */ - Elf_Addr st_value; /* Value of the symbol */ - Elf_Word st_size; /* Associated symbol size */ - Elf_Char st_info; /* Type and binding attributes */ - Elf_Char st_other; /* No defined meaning, 0 */ - Elf_Half st_shndx; /* Associated section index */ -} Elf_Internal_Sym; - -/* Note segments */ - -typedef struct { - Elf_Word namesz; /* Size of entry's owner string */ - Elf_Word descsz; /* Size of the note descriptor */ - Elf_Word type; /* Interpretation of the descriptor */ - char name[1]; /* Start of the name+desc data */ -} Elf_Internal_Note; diff --git a/include/gdbm.h b/include/gdbm.h deleted file mode 100644 index b27f8e79b3c..00000000000 --- a/include/gdbm.h +++ /dev/null @@ -1,91 +0,0 @@ -/* gdbm.h - The include file for dbm users. */ - -/* GNU DBM - DataBase Manager (database subroutines) by Philip A. Nelson - Copyright (C) 1989 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. - - 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., 675 Mass Ave, Cambridge, MA 02139, USA. - - You may contact the author by: - e-mail: phil@wwu.edu - us-mail: Philip A. Nelson - Computer Science Department - Western Washington University - Bellingham, WA 98226 - phone: (206) 676-3035 - -*************************************************************************/ - -/* Parameters to gdbm_open for READERS, WRITERS, and WRITERS who - can create the database. */ -#define GDBM_READER 0 -#define GDBM_WRITER 1 -#define GDBM_WRCREAT 2 -#define GDBM_NEWDB 3 - -/* Parameters to gdbm_store for simple insertion or replacement. */ -#define GDBM_INSERT 0 -#define GDBM_REPLACE 1 - - -/* The data and key structure. This structure is defined for compatibility. */ -typedef struct { - char *dptr; - int dsize; - } datum; - - -/* The file information header. This is good enough for most applications. */ -typedef struct {int dummy[10];} *GDBM_FILE; - - -/* These are the routines! */ - -extern GDBM_FILE gdbm_open (); - -extern void gdbm_close (); - -extern datum gdbm_fetch (); - -extern int gdbm_store (); - -extern int gdbm_delete (); - -extern datum gdbm_firstkey (); - -extern datum gdbm_nextkey (); - -extern int gdbm_reorganize (); - - -/* gdbm sends back the following error codes in the variable gdbm_errno. */ -typedef enum { NO_ERROR, - MALLOC_ERROR, - BLOCK_SIZE_ERROR, - FILE_OPEN_ERROR, - FILE_WRITE_ERROR, - FILE_SEEK_ERROR, - FILE_READ_ERROR, - BAD_MAGIC_NUMBER, - EMPTY_DATABASE, - CANT_BE_READER, - CANT_BE_WRITER, - READER_CANT_RECOVER, - READER_CANT_DELETE, - READER_CANT_STORE, - READER_CANT_REORGANIZE, - UNKNOWN_UPDATE, - ITEM_NOT_FOUND, - REORGANIZE_FAILED, - CANNOT_REPLACE} - gdbm_error; diff --git a/include/getopt.h b/include/getopt.h deleted file mode 100644 index 1e5db6c9714..00000000000 --- a/include/getopt.h +++ /dev/null @@ -1,76 +0,0 @@ -/* declarations for getopt - Copyright (C) 1989 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* For communication from `getopt' to the caller. - When `getopt' finds an option that takes an argument, - the argument value is returned here. - Also, when `ordering' is RETURN_IN_ORDER, - each non-option ARGV-element is returned here. */ - -extern char *optarg; - -/* Index in ARGV of the next element to be scanned. - This is used for communication to and from the caller - and for communication between successive calls to `getopt'. - - On entry to `getopt', zero means this is the first call; initialize. - - When `getopt' returns EOF, this is the index of the first of the - non-option elements that the caller should itself scan. - - Otherwise, `optind' communicates from one call to the next - how much of ARGV has been scanned so far. */ - -extern int optind; - -/* Callers store zero here to inhibit the error message `getopt' prints - for unrecognized options. */ - -extern int opterr; - -/* Describe the long-named options requested by the application. - _GETOPT_LONG_OPTIONS is a vector of `struct option' terminated by an - element containing a name which is zero. - The field `has_arg' is: - 0 if the option does not take an argument, - 1 if the option requires an argument, - 2 if the option takes an optional argument. - If the field `flag' is nonzero, it points to a variable that is set to - the value given in the field `val' when the option is found, but - left unchanged if the option is not found. */ - -struct option -{ - char *name; - int has_arg; - int *flag; - int val; -}; - -extern struct option *_getopt_long_options; - -/* Name of long-named option actually found. - Only changed when a long-named option is found. */ - -extern char *_getopt_option_name; - -/* The index in GETOPT_LONG_OPTIONS of the long-named option found. - Only valid when a long-named option has been found by the most - recent call to `getopt'. */ - -extern int option_index; - diff --git a/include/h8300-opcode.h b/include/h8300-opcode.h deleted file mode 100755 index 92da20630d5..00000000000 --- a/include/h8300-opcode.h +++ /dev/null @@ -1,233 +0,0 @@ -/* Opcode table for the H8-300 - Copyright (C) 1989, 1991 Free Software Foundation. - Written by Steve Chamberlain, steve@cygnus.com. - -This file is part of GDB, the GNU Debugger and GAS, the GNU Assembler. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -typedef enum op_type - { -Hex0=0, -Hex1,Hex2,Hex3,Hex4,Hex5,Hex6,Hex7,Hex8,Hex9,HexA,HexB,HexC,HexD,HexE,HexF, - START = 0x20, - KBIT, /* K is #1, or #2, yielding 0x0 or 0x8 */ - IMM3, /* bit number */ - RD8, /* 8 bit reg as 2nd op */ - RD16, /* 16 bit reg as 2nd op */ - RS8, /* 8 bit reg as 1st op */ - RS16, /* 16 bit reg 1st op */ - IMM8, /* constant which fits into 8 bits */ - IMM16, /* constant which fits into 16 bits */ - CCR, /* CCR reg */ - ABS8SRC, /* abs 8 address mode */ - ABS8DST, /* abs 8 address mode */ - DISP8, /* pc rel displacement */ - ABS16SRC, /* abs 16 address mode */ - ABS16DST, /* abs 16 address mode */ - DISPSRC, /* @(r:16) address mode src */ - DISPDST, /* @(r:16) address mode dst*/ - DISPREG, /* register from DISP address mode */ - RDDEC, /* @-rn mode */ - RSINC, /* @rn+ mode */ - RDIND, /* @R mode dst */ - RSIND, /* @R mode src */ - MEMIND, /* @@r8 mode */ - IGNORE, - B30 = 0x40, /* bit 3 must be low */ - B31 = 0x80, /* bit 3 must be high */ - - E /* End of list */ - } op_type; - - -struct code { - - op_type nib[9]; -} ; - -struct h8_opcode { - int length; - int noperands; /* Number of operands this opcode takes */ - int nopcodes; /* Number of opcodes with same mnemonic */ - char *name; - struct code args; - struct code data; -int value; -}; - - - -struct h8_opcode h8_opcodes[] -#ifdef DEFINE_TABLE - -#define BITOP(n,imm, name, op00, op01,op10,op11, op20,op21)\ -{ 2, 2,n, name, {imm,RD8,E}, {op00, op01, imm, RD8,E}},\ -{ 4, 2,n, name, {imm,RDIND,E}, {op10, op11, RDIND, 0, op00,op01, imm, 0,E}},\ -{ 4, 2,n, name, {imm,ABS8DST,E}, {op20, op21, ABS8DST, IGNORE, op00,op01, imm, 0,E}} - -#define EBITOP(n,imm, name, op00, op01,op10,op11, op20,op21)\ - BITOP(n,imm, name, op00+1, op01, op10,op11, op20,op21),\ - BITOP(n, RS8, name, op00, op01, op10,op11, op20,op21) - -#define BRANCH(name, op) \ -{ 2, 1, 1,name,{DISP8,E}, { Hex4, op, DISP8,IGNORE,E }} - -#define TWOOP(name, op1, op2,op3) \ -{ 2, 2, 2, name, {IMM8, RD8,E}, { op1, RD8, IMM8,IGNORE,E}},\ -{ 2, 2, 2, name, {RS8, RD8, E}, { op2, op3, RS8, RD8 ,E}} - -#define UNOP(name, op1, op2) \ -{ 2, 1, 1, name, {RS8, E}, { op1, op2, 0, RS8, E}} - -#define UNOP3(name, op1, op2, op3) \ -{2, 1, 1, name , {RS8, E}, {op1, op2, op3, RS8, E}} - -#define WTWOP(name, op1, op2) \ -{2, 2, 1, name, {RS16, RD16, E}, { op1, op2, RS16, RD16, E}} - -= -{ - TWOOP("add.b", Hex8, Hex0,Hex8), - WTWOP("add.w", Hex0, Hex9), - { 2, 2, 1, "adds", {KBIT,RD16|B30, E},{Hex0, HexB, KBIT, RD16|B30, E}}, - TWOOP("addx", Hex9,Hex0,HexE), - TWOOP("and", HexE,Hex1,Hex6), - { 2, 2, 1, "andc", {IMM8, CCR, E}, { Hex0, Hex6, IMM8,IGNORE, E}}, - BITOP(3,IMM3|B30, "band", Hex7, Hex6, Hex7, HexC, Hex7, HexE), - BRANCH("bra", Hex0), - BRANCH("bt", Hex0), - BRANCH("brn", Hex1), - BRANCH("bf", Hex1), - BRANCH("bhi", Hex2), - BRANCH("bls", Hex3), - BRANCH("bcc", Hex4), - BRANCH("bhs", Hex4), - BRANCH("bcs", Hex5), - BRANCH("blo", Hex5), - BRANCH("bne", Hex6), - BRANCH("beq", Hex7), - BRANCH("bvc", Hex8), - BRANCH("bvs", Hex9), - BRANCH("bpl", HexA), - BRANCH("bmi", HexB), - BRANCH("bge", HexC), - BRANCH("blt", HexD), - BRANCH("bgt", HexE), - BRANCH("ble", HexF), - EBITOP(6,IMM3|B30,"bclr", Hex6, Hex2, Hex7, HexD, Hex7, HexF), - BITOP(3,IMM3|B31,"biand", Hex7, Hex6, Hex7, HexC, Hex7, HexE), - BITOP(3,IMM3|B31, "bild", Hex7, Hex7,Hex7, HexC, Hex7, HexE), - BITOP(3,IMM3|B31, "bior", Hex7, Hex4,Hex7, HexC, Hex7, HexE), - BITOP(3,IMM3|B31, "bist", Hex6, Hex7,Hex7, HexD, Hex7, HexE), - BITOP(3,IMM3|B31, "bixor", Hex7, Hex5,Hex7, HexC, Hex7, HexE), - BITOP(3,IMM3|B30, "bld", Hex7, Hex7,Hex7, HexC, Hex7, HexE), - EBITOP(6,IMM3|B30,"bnot", Hex6, Hex1, Hex7, HexD, Hex7, HexF), - BITOP(3,IMM3|B30,"bor", Hex7, Hex4,Hex7, HexC, Hex7, HexE), - EBITOP(6,IMM3|B30,"bset", Hex6, Hex0,Hex7, HexD, Hex7, HexF), - { 2, 1, 1, "bsr",{DISP8, E},{ Hex5, Hex5, DISP8,IGNORE, E}}, - BITOP(3,IMM3|B30, "bst", Hex6, Hex7,Hex7, HexD, Hex7, HexF), - EBITOP(6,IMM3|B30, "btst", Hex6, Hex3,Hex7, HexC, Hex7, HexE), - BITOP(3,IMM3|B30, "bxor", Hex7,Hex5,Hex7, HexC, Hex7, HexE), - TWOOP( "cmp.b",HexA, Hex1, HexC), - WTWOP( "cmp.w",Hex1,HexD), - UNOP( "daa",Hex0, HexF), - UNOP( "das",Hex1, HexF), - UNOP( "dec",Hex1, HexA), - { 2, 2, 1, "divxu",{RS8, RD16|B30, E}, { Hex5, Hex1, RS8, RD16|B30, E}}, - { 4, 0, 1, "eepmov",{ E}, {Hex7, HexB, Hex5, HexC, Hex5, Hex9, Hex8, HexF,E}}, - UNOP( "inc", Hex0, HexA), - { 2, 1, 3, "jmp",{RSIND|B30, E}, {Hex5, Hex9, RSIND|B30, Hex0, E}}, - { 4, 1, 3, "jmp",{ABS16SRC, E}, {Hex5, HexA, Hex0, Hex0, ABS16SRC, IGNORE,IGNORE,IGNORE,E}}, - { 2, 1, 3, "jmp",{MEMIND, E}, {Hex5, HexB, MEMIND,IGNORE, E}}, - { 2, 1, 3, "jsr",{RSIND|B30, E}, {Hex5, HexD, RSIND|B30, Hex0, E}}, - { 4, 1, 3, "jsr",{ABS16SRC, E}, {Hex5, HexE, Hex0, Hex0, ABS16SRC,IGNORE,IGNORE,IGNORE, E}}, - { 2, 1, 3, "jsr",{MEMIND, E}, {Hex5, HexF, MEMIND, IGNORE,E}}, - { 2, 2, 2, "ldc", {IMM8, CCR, E}, { Hex0, Hex7, IMM8,IGNORE, E}}, - { 2, 2, 2, "ldc", {RS8, CCR, E}, { Hex0, Hex3, Hex0, RS8, E}}, - - { 2, 2,13, "mov.b", {RS8, RD8, E}, { Hex0, HexC, RS8, RD8, E}}, - { 2, 2,13, "mov.b", {IMM8, RD8, E}, { HexF, RD8, IMM8,IGNORE, E}}, - { 2, 2,13, "mov.b", {RSIND|B30,RD8, E}, { Hex6, Hex8, RSIND|B30, RD8, E}}, - { 4, 2,13, "mov.b", {DISPSRC,RD8, E}, { Hex6, HexE, DISPREG|B30, RD8, DISPSRC, IGNORE, IGNORE, IGNORE, E}} , - { 2, 2,13, "mov.b", {RSINC|B30, RD8, E}, { Hex6, HexC, RSINC|B30, RD8, E}}, - - { 4, 2,13, "mov.b", {ABS16SRC, RD8, E}, { Hex6, HexA, Hex0, RD8,ABS16SRC, IGNORE,IGNORE,IGNORE,E}}, - { 2, 2,13, "mov.b", {ABS8SRC, RD8, E}, { Hex2, RD8, ABS8SRC,IGNORE, E}}, - { 2, 2,13, "mov.b", {RS8, RDIND|B30, E}, { Hex6, Hex8, RDIND|B31, RS8, E}}, - { 4, 2,13, "mov.b", {RS8, DISPDST, E}, { Hex6, HexE, DISPREG|B31, RS8,DISPDST, IGNORE, IGNORE, IGNORE, E}}, - { 2, 2,13, "mov.b", {RS8, RDDEC|B31, E}, { Hex6, HexC, RDDEC|B31, RS8, E}}, -/* Put the 16 bit one in first so it matches first */ - { 4, 2,13, "mov.b", {RS8, ABS16DST, E}, { Hex6, HexA, Hex8, RS8, ABS16DST,IGNORE,IGNORE,IGNORE, E}}, - { 2, 2,13, "mov.b", {RS8, ABS8DST, E}, { Hex3, RS8, ABS8DST,IGNORE, E}}, - { 2, 2,11, "mov.w", {RS16|B30, RD16|B30, E},{ Hex0, HexD, RS16|B30, RD16|B30, E}}, - { 4, 2,11, "mov.w", {IMM16, RD16|B30, E}, { Hex7, Hex9, Hex0, RD16|B30, IMM16,IGNORE,IGNORE,IGNORE, E}}, - { 2, 2,11, "mov.w", {RSIND|B30,RD16|B30, E},{ Hex6, Hex9, RSIND|B30, RD16|B30, E}}, - { 4, 2,11, "mov.w", {DISPSRC,RD16|B30, E}, { Hex6, HexF, DISPREG|B30, RD16|B30, DISPSRC, IGNORE, IGNORE, IGNORE,E}} , - { 2, 2,11, "mov.w", {RSINC|B30, RD16|B30, E}, { Hex6, HexD, RSINC|B30, RD16|B30, E}}, - { 4, 2,11, "mov.w", {ABS16SRC, RD16|B30, E}, { Hex6, HexB, Hex0, RD16|B30,ABS16SRC,IGNORE,IGNORE,IGNORE, E}}, - { 2, 2,11, "mov.w", {RS16|B30, RDIND|B30, E},{ Hex6, Hex9, RDIND|B31, RS16|B30, E}}, - { 4, 2,11, "mov.w", {RS16|B30, DISPDST, E}, { Hex6, HexF, DISPREG|B31, RS16|B30,DISPDST, IGNORE,IGNORE,IGNORE,E}}, - { 2, 2,11, "mov.w", {RS16|B30, RDDEC|B30, E},{ Hex6, HexD, RDDEC|B31, RS16|B30, E}}, - { 4, 2,11, "mov.w", {RS16|B30, ABS16DST, E}, { Hex6, HexB, Hex8, RS16|B30, ABS16DST, IGNORE, IGNORE, IGNORE, E}}, - - - { 4, 2,1, "movfpe", {ABS16SRC, RD8, E}, { Hex6, HexA, Hex4, RD8, ABS16SRC,IGNORE,IGNORE,IGNORE, E}}, - { 4, 2,1, "movtpe", {RS8, ABS16DST, E}, { Hex6, HexA, HexC, RS8, ABS16DST,IGNORE,IGNORE,IGNORE, E}}, - { 2, 2,1, "mulxu", {RS8, RD16|B30, E}, { Hex5, Hex0, RS8, RD16|B30, E}}, - { 2, 1,1, "neg", {RS8, E}, { Hex1, Hex7, Hex8, RS8, E}}, - { 2, 0,1, "nop", {E}, { Hex0, Hex0, Hex0, Hex0,E}}, - { 2, 1,1, "not", {RS8,E}, { Hex1, Hex7, Hex0, RS8,E}}, - TWOOP("or", HexC, Hex1, Hex4), - { 2, 2,1, "orc", {IMM8, CCR,E}, { Hex0, Hex4, IMM8,IGNORE,E}}, - { 2, 1,1, "pop", {RS16|B30,E}, { Hex6, HexD, Hex7, RS16|B30,E}}, - { 2, 1,1, "push", {RS16|B30,E}, { Hex6, HexD, HexF, RS16|B30,E}}, - UNOP3( "rotl",Hex1, Hex2,Hex8), - UNOP3( "rotr",Hex1, Hex3, Hex8), - UNOP3( "rotxl",Hex1, Hex2, Hex0), - UNOP3( "rotxr",Hex1, Hex3, Hex0), - { 2, 0, 1, "rte", {E}, { Hex5, Hex6, Hex7, Hex0,E}}, - { 2, 0, 1, "rts", {E}, { Hex5, Hex4, Hex7, Hex0,E}}, - UNOP3( "shal", Hex1, Hex0, Hex8), - UNOP3( "shar", Hex1, Hex1, Hex8), - UNOP3( "shll", Hex1, Hex0, Hex0), - UNOP3( "shlr", Hex1, Hex1, Hex0), - { 2, 0, 1, "sleep", {E}, { Hex0, Hex1, Hex8, Hex0,E}}, - { 2, 2, 1, "stc", {CCR, RD8,E}, { Hex0, Hex2, Hex0, RD8,E}}, - { 2, 2, 1, "sub.b", {RS8,RD8,E}, { Hex1, Hex8, RS8, RD8,E}}, - { 2, 2, 1, "sub.w", {RS16|B30, RD16|B30,E}, {Hex1, Hex9, RS16|B30, RD16|B30,E}}, - { 2, 2, 1, "subs", {KBIT,RD16|B30,E}, { Hex1, HexB, KBIT, RD16|B30,E}}, - TWOOP("subx",HexB, Hex1, HexE), - TWOOP("xor", HexD, Hex1, Hex5), - { 2, 2, 1,"xorc", {IMM8, CCR,E}, { Hex0, Hex5, IMM8,IGNORE,E}}, - { 2, 0,1, "bad 52", {E, IMM8}, { Hex5, Hex2, IMM8, IGNORE,E}}, - { 2, 0,1, "bad 53", {E, IMM8}, { Hex5, Hex3, IMM8, IGNORE,E}}, - { 2, 0,1, "bad 57", {E, IMM8}, { Hex5, Hex7, IMM8, IGNORE,E}}, - { 2, 0,1, "bad 58", {E, IMM8}, { Hex5, Hex8, IMM8, IGNORE,E}}, - { 2, 0,1, "bad 64", {E, IMM8}, { Hex6, Hex4, IMM8, IGNORE,E}}, - { 2, 0,1, "bad 65", {E, IMM8}, { Hex6, Hex5, IMM8, IGNORE,E}}, - { 2, 0,1, "bad 66", {E, IMM8}, { Hex6, Hex6, IMM8, IGNORE,E}}, - { 2, 0,1, "bad 78", {E, IMM8}, { Hex7, Hex8, IMM8, IGNORE,E}}, - { 2, 0,1, "bad 7a", {E, IMM8}, { Hex7, HexA, IMM8, IGNORE,E}}, - { 2, 0,1, "bad 5c", {E, IMM8}, { Hex5, HexC, IMM8, IGNORE,E}}, - - 0 - } - - - -#endif - -; diff --git a/include/i386-opcode.h b/include/i386-opcode.h deleted file mode 100755 index 4c87ba5cd07..00000000000 --- a/include/i386-opcode.h +++ /dev/null @@ -1,800 +0,0 @@ -/* i386-opcode.h -- Intel 80386 opcode table - Copyright (C) 1989, 1991, Free Software Foundation. - -This file is part of GAS, the GNU Assembler. - -GAS 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 1, or (at your option) -any later version. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* $Id$ */ - -static const template i386_optab[] = { - -#define _ None -/* move instructions */ -{ "mov", 2, 0xa0, _, DW|NoModrm, Disp32, Acc, 0 }, -{ "mov", 2, 0x88, _, DW|Modrm, Reg, Reg|Mem, 0 }, -{ "mov", 2, 0xb0, _, ShortFormW, Imm, Reg, 0 }, -{ "mov", 2, 0xc6, _, W|Modrm, Imm, Reg|Mem, 0 }, -{ "mov", 2, 0x8c, _, D|Modrm, SReg3|SReg2, Reg16|Mem16, 0 }, -/* move to/from control debug registers */ -{ "mov", 2, 0x0f20, _, D|Modrm, Control, Reg32, 0}, -{ "mov", 2, 0x0f21, _, D|Modrm, Debug, Reg32, 0}, -{ "mov", 2, 0x0f24, _, D|Modrm, Test, Reg32, 0}, - -/* move with sign extend */ -/* "movsbl" & "movsbw" must not be unified into "movsb" to avoid - conflict with the "movs" string move instruction. Thus, - {"movsb", 2, 0x0fbe, _, ReverseRegRegmem|Modrm, Reg8|Mem, Reg16|Reg32, 0}, - is not kosher; we must seperate the two instructions. */ -{"movsbl", 2, 0x0fbe, _, ReverseRegRegmem|Modrm, Reg8|Mem, Reg32, 0}, -{"movsbw", 2, 0x660fbe, _, ReverseRegRegmem|Modrm, Reg8|Mem, Reg16, 0}, -{"movswl", 2, 0x0fbf, _, ReverseRegRegmem|Modrm, Reg16|Mem, Reg32, 0}, - -/* move with zero extend */ -{"movzb", 2, 0x0fb6, _, ReverseRegRegmem|Modrm, Reg8|Mem, Reg16|Reg32, 0}, -{"movzwl", 2, 0x0fb7, _, ReverseRegRegmem|Modrm, Reg16|Mem, Reg32, 0}, - -/* push instructions */ -{"push", 1, 0x50, _, ShortForm, WordReg,0,0 }, -{"push", 1, 0xff, 0x6, Modrm, WordReg|WordMem, 0, 0 }, -{"push", 1, 0x6a, _, NoModrm, Imm8S, 0, 0}, -{"push", 1, 0x68, _, NoModrm, Imm32, 0, 0}, -{"push", 1, 0x06, _, Seg2ShortForm, SReg2,0,0 }, -{"push", 1, 0x0fa0, _, Seg3ShortForm, SReg3,0,0 }, -/* push all */ -{"pusha", 0, 0x60, _, NoModrm, 0, 0, 0 }, - -/* pop instructions */ -{"pop", 1, 0x58, _, ShortForm, WordReg,0,0 }, -{"pop", 1, 0x8f, 0x0, Modrm, WordReg|WordMem, 0, 0 }, -#define POP_SEG_SHORT 0x7 -{"pop", 1, 0x07, _, Seg2ShortForm, SReg2,0,0 }, -{"pop", 1, 0x0fa1, _, Seg3ShortForm, SReg3,0,0 }, -/* pop all */ -{"popa", 0, 0x61, _, NoModrm, 0, 0, 0 }, - -/* xchg exchange instructions - xchg commutes: we allow both operand orders */ -{"xchg", 2, 0x90, _, ShortForm, WordReg, Acc, 0 }, -{"xchg", 2, 0x90, _, ShortForm, Acc, WordReg, 0 }, -{"xchg", 2, 0x86, _, W|Modrm, Reg, Reg|Mem, 0 }, -{"xchg", 2, 0x86, _, W|Modrm, Reg|Mem, Reg, 0 }, - -/* in/out from ports */ -{"in", 2, 0xe4, _, W|NoModrm, Imm8, Acc, 0 }, -{"in", 2, 0xec, _, W|NoModrm, InOutPortReg, Acc, 0 }, -{"out", 2, 0xe6, _, W|NoModrm, Acc, Imm8, 0 }, -{"out", 2, 0xee, _, W|NoModrm, Acc, InOutPortReg, 0 }, - -/* load effective address */ -{"lea", 2, 0x8d, _, Modrm, WordMem, WordReg, 0 }, - -/* load segment registers from memory */ -{"lds", 2, 0xc5, _, Modrm, Mem, Reg32, 0}, -{"les", 2, 0xc4, _, Modrm, Mem, Reg32, 0}, -{"lfs", 2, 0x0fb4, _, Modrm, Mem, Reg32, 0}, -{"lgs", 2, 0x0fb5, _, Modrm, Mem, Reg32, 0}, -{"lss", 2, 0x0fb2, _, Modrm, Mem, Reg32, 0}, - -/* flags register instructions */ -{"clc", 0, 0xf8, _, NoModrm, 0, 0, 0}, -{"cld", 0, 0xfc, _, NoModrm, 0, 0, 0}, -{"cli", 0, 0xfa, _, NoModrm, 0, 0, 0}, -{"clts", 0, 0x0f06, _, NoModrm, 0, 0, 0}, -{"cmc", 0, 0xf5, _, NoModrm, 0, 0, 0}, -{"lahf", 0, 0x9f, _, NoModrm, 0, 0, 0}, -{"sahf", 0, 0x9e, _, NoModrm, 0, 0, 0}, -{"pushf", 0, 0x9c, _, NoModrm, 0, 0, 0}, -{"popf", 0, 0x9d, _, NoModrm, 0, 0, 0}, -{"stc", 0, 0xf9, _, NoModrm, 0, 0, 0}, -{"std", 0, 0xfd, _, NoModrm, 0, 0, 0}, -{"sti", 0, 0xfb, _, NoModrm, 0, 0, 0}, - -{"add", 2, 0x0, _, DW|Modrm, Reg, Reg|Mem, 0}, -{"add", 2, 0x83, 0, Modrm, Imm8S, WordReg|WordMem, 0}, -{"add", 2, 0x4, _, W|NoModrm, Imm, Acc, 0}, -{"add", 2, 0x80, 0, W|Modrm, Imm, Reg|Mem, 0}, - -{"inc", 1, 0x40, _, ShortForm, WordReg, 0, 0}, -{"inc", 1, 0xfe, 0, W|Modrm, Reg|Mem, 0, 0}, - -{"sub", 2, 0x28, _, DW|Modrm, Reg, Reg|Mem, 0}, -{"sub", 2, 0x83, 5, Modrm, Imm8S, WordReg|WordMem, 0}, -{"sub", 2, 0x2c, _, W|NoModrm, Imm, Acc, 0}, -{"sub", 2, 0x80, 5, W|Modrm, Imm, Reg|Mem, 0}, - -{"dec", 1, 0x48, _, ShortForm, WordReg, 0, 0}, -{"dec", 1, 0xfe, 1, W|Modrm, Reg|Mem, 0, 0}, - -{"sbb", 2, 0x18, _, DW|Modrm, Reg, Reg|Mem, 0}, -{"sbb", 2, 0x83, 3, Modrm, Imm8S, WordReg|WordMem, 0}, -{"sbb", 2, 0x1c, _, W|NoModrm, Imm, Acc, 0}, -{"sbb", 2, 0x80, 3, W|Modrm, Imm, Reg|Mem, 0}, - -{"cmp", 2, 0x38, _, DW|Modrm, Reg, Reg|Mem, 0}, -{"cmp", 2, 0x83, 7, Modrm, Imm8S, WordReg|WordMem, 0}, -{"cmp", 2, 0x3c, _, W|NoModrm, Imm, Acc, 0}, -{"cmp", 2, 0x80, 7, W|Modrm, Imm, Reg|Mem, 0}, - -{"test", 2, 0x84, _, W|Modrm, Reg|Mem, Reg, 0}, -{"test", 2, 0x84, _, W|Modrm, Reg, Reg|Mem, 0}, -{"test", 2, 0xa8, _, W|NoModrm, Imm, Acc, 0}, -{"test", 2, 0xf6, 0, W|Modrm, Imm, Reg|Mem, 0}, - -{"and", 2, 0x20, _, DW|Modrm, Reg, Reg|Mem, 0}, -{"and", 2, 0x83, 4, Modrm, Imm8S, WordReg|WordMem, 0}, -{"and", 2, 0x24, _, W|NoModrm, Imm, Acc, 0}, -{"and", 2, 0x80, 4, W|Modrm, Imm, Reg|Mem, 0}, - -{"or", 2, 0x08, _, DW|Modrm, Reg, Reg|Mem, 0}, -{"or", 2, 0x83, 1, Modrm, Imm8S, WordReg|WordMem, 0}, -{"or", 2, 0x0c, _, W|NoModrm, Imm, Acc, 0}, -{"or", 2, 0x80, 1, W|Modrm, Imm, Reg|Mem, 0}, - -{"xor", 2, 0x30, _, DW|Modrm, Reg, Reg|Mem, 0}, -{"xor", 2, 0x83, 6, Modrm, Imm8S, WordReg|WordMem, 0}, -{"xor", 2, 0x34, _, W|NoModrm, Imm, Acc, 0}, -{"xor", 2, 0x80, 6, W|Modrm, Imm, Reg|Mem, 0}, - -{"adc", 2, 0x10, _, DW|Modrm, Reg, Reg|Mem, 0}, -{"adc", 2, 0x83, 2, Modrm, Imm8S, WordReg|WordMem, 0}, -{"adc", 2, 0x14, _, W|NoModrm, Imm, Acc, 0}, -{"adc", 2, 0x80, 2, W|Modrm, Imm, Reg|Mem, 0}, - -{"neg", 1, 0xf6, 3, W|Modrm, Reg|Mem, 0, 0}, -{"not", 1, 0xf6, 2, W|Modrm, Reg|Mem, 0, 0}, - -{"aaa", 0, 0x37, _, NoModrm, 0, 0, 0}, -{"aas", 0, 0x3f, _, NoModrm, 0, 0, 0}, -{"daa", 0, 0x27, _, NoModrm, 0, 0, 0}, -{"das", 0, 0x2f, _, NoModrm, 0, 0, 0}, -{"aad", 0, 0xd50a, _, NoModrm, 0, 0, 0}, -{"aam", 0, 0xd40a, _, NoModrm, 0, 0, 0}, - -/* conversion insns */ -/* conversion: intel naming */ -{"cbw", 0, 0x6698, _, NoModrm, 0, 0, 0}, -{"cwd", 0, 0x6699, _, NoModrm, 0, 0, 0}, -{"cwde", 0, 0x98, _, NoModrm, 0, 0, 0}, -{"cdq", 0, 0x99, _, NoModrm, 0, 0, 0}, -/* att naming */ -{"cbtw", 0, 0x6698, _, NoModrm, 0, 0, 0}, -{"cwtl", 0, 0x98, _, NoModrm, 0, 0, 0}, -{"cwtd", 0, 0x6699, _, NoModrm, 0, 0, 0}, -{"cltd", 0, 0x99, _, NoModrm, 0, 0, 0}, - -/* Warning! the mul/imul (opcode 0xf6) must only have 1 operand! They are - expanding 64-bit multiplies, and *cannot* be selected to accomplish - 'imul %ebx, %eax' (opcode 0x0faf must be used in this case) - These multiplies can only be selected with single opearnd forms. */ -{"mul", 1, 0xf6, 4, W|Modrm, Reg|Mem, 0, 0}, -{"imul", 1, 0xf6, 5, W|Modrm, Reg|Mem, 0, 0}, - - - - -/* imulKludge here is needed to reverse the i.rm.reg & i.rm.regmem fields. - These instructions are exceptions: 'imul $2, %eax, %ecx' would put - '%eax' in the reg field and '%ecx' in the regmem field if we did not - switch them. */ -{"imul", 2, 0x0faf, _, Modrm|ReverseRegRegmem, WordReg|Mem, WordReg, 0}, -{"imul", 3, 0x6b, _, Modrm|ReverseRegRegmem, Imm8S, WordReg|Mem, WordReg}, -{"imul", 3, 0x69, _, Modrm|ReverseRegRegmem, Imm16|Imm32, WordReg|Mem, WordReg}, -/* - imul with 2 operands mimicks imul with 3 by puting register both - in i.rm.reg & i.rm.regmem fields -*/ -{"imul", 2, 0x6b, _, Modrm|imulKludge, Imm8S, WordReg, 0}, -{"imul", 2, 0x69, _, Modrm|imulKludge, Imm16|Imm32, WordReg, 0}, -{"div", 1, 0xf6, 6, W|Modrm, Reg|Mem, 0, 0}, -{"div", 2, 0xf6, 6, W|Modrm, Reg|Mem, Acc, 0}, -{"idiv", 1, 0xf6, 7, W|Modrm, Reg|Mem, 0, 0}, -{"idiv", 2, 0xf6, 7, W|Modrm, Reg|Mem, Acc, 0}, - -{"rol", 2, 0xd0, 0, W|Modrm, Imm1, Reg|Mem, 0}, -{"rol", 2, 0xc0, 0, W|Modrm, Imm8, Reg|Mem, 0}, -{"rol", 2, 0xd2, 0, W|Modrm, ShiftCount, Reg|Mem, 0}, -{"rol", 1, 0xd0, 0, W|Modrm, Reg|Mem, 0, 0}, - -{"ror", 2, 0xd0, 1, W|Modrm, Imm1, Reg|Mem, 0}, -{"ror", 2, 0xc0, 1, W|Modrm, Imm8, Reg|Mem, 0}, -{"ror", 2, 0xd2, 1, W|Modrm, ShiftCount, Reg|Mem, 0}, -{"ror", 1, 0xd0, 1, W|Modrm, Reg|Mem, 0, 0}, - -{"rcl", 2, 0xd0, 2, W|Modrm, Imm1, Reg|Mem, 0}, -{"rcl", 2, 0xc0, 2, W|Modrm, Imm8, Reg|Mem, 0}, -{"rcl", 2, 0xd2, 2, W|Modrm, ShiftCount, Reg|Mem, 0}, -{"rcl", 1, 0xd0, 2, W|Modrm, Reg|Mem, 0, 0}, - -{"rcr", 2, 0xd0, 3, W|Modrm, Imm1, Reg|Mem, 0}, -{"rcr", 2, 0xc0, 3, W|Modrm, Imm8, Reg|Mem, 0}, -{"rcr", 2, 0xd2, 3, W|Modrm, ShiftCount, Reg|Mem, 0}, -{"rcr", 1, 0xd0, 3, W|Modrm, Reg|Mem, 0, 0}, - -{"sal", 2, 0xd0, 4, W|Modrm, Imm1, Reg|Mem, 0}, -{"sal", 2, 0xc0, 4, W|Modrm, Imm8, Reg|Mem, 0}, -{"sal", 2, 0xd2, 4, W|Modrm, ShiftCount, Reg|Mem, 0}, -{"sal", 1, 0xd0, 4, W|Modrm, Reg|Mem, 0, 0}, -{"shl", 2, 0xd0, 4, W|Modrm, Imm1, Reg|Mem, 0}, -{"shl", 2, 0xc0, 4, W|Modrm, Imm8, Reg|Mem, 0}, -{"shl", 2, 0xd2, 4, W|Modrm, ShiftCount, Reg|Mem, 0}, -{"shl", 1, 0xd0, 4, W|Modrm, Reg|Mem, 0, 0}, - -{"shld", 3, 0x0fa4, _, Modrm, Imm8, WordReg, WordReg|Mem}, -{"shld", 3, 0x0fa5, _, Modrm, ShiftCount, WordReg, WordReg|Mem}, - -{"shr", 2, 0xd0, 5, W|Modrm, Imm1, Reg|Mem, 0}, -{"shr", 2, 0xc0, 5, W|Modrm, Imm8, Reg|Mem, 0}, -{"shr", 2, 0xd2, 5, W|Modrm, ShiftCount, Reg|Mem, 0}, -{"shr", 1, 0xd0, 5, W|Modrm, Reg|Mem, 0, 0}, - -{"shrd", 3, 0x0fac, _, Modrm, Imm8, WordReg, WordReg|Mem}, -{"shrd", 3, 0x0fad, _, Modrm, ShiftCount, WordReg, WordReg|Mem}, - -{"sar", 2, 0xd0, 7, W|Modrm, Imm1, Reg|Mem, 0}, -{"sar", 2, 0xc0, 7, W|Modrm, Imm8, Reg|Mem, 0}, -{"sar", 2, 0xd2, 7, W|Modrm, ShiftCount, Reg|Mem, 0}, -{"sar", 1, 0xd0, 7, W|Modrm, Reg|Mem, 0, 0}, - -/* control transfer instructions */ -#define CALL_PC_RELATIVE 0xe8 -{"call", 1, 0xe8, _, JumpDword, Disp32, 0, 0}, -{"call", 1, 0xff, 2, Modrm, Reg|Mem|JumpAbsolute, 0, 0}, -#define CALL_FAR_IMMEDIATE 0x9a -{"lcall", 2, 0x9a, _, JumpInterSegment, Imm16, Abs32, 0}, -{"lcall", 1, 0xff, 3, Modrm, Mem, 0, 0}, - -#define JUMP_PC_RELATIVE 0xeb -{"jmp", 1, 0xeb, _, Jump, Disp, 0, 0}, -{"jmp", 1, 0xff, 4, Modrm, Reg32|Mem|JumpAbsolute, 0, 0}, -#define JUMP_FAR_IMMEDIATE 0xea -{"ljmp", 2, 0xea, _, JumpInterSegment, Imm16, Imm32, 0}, -{"ljmp", 1, 0xff, 5, Modrm, Mem, 0, 0}, - -{"ret", 0, 0xc3, _, NoModrm, 0, 0, 0}, -{"ret", 1, 0xc2, _, NoModrm, Imm16, 0, 0}, -{"lret", 0, 0xcb, _, NoModrm, 0, 0, 0}, -{"lret", 1, 0xca, _, NoModrm, Imm16, 0, 0}, -{"enter", 2, 0xc8, _, NoModrm, Imm16, Imm8, 0}, -{"leave", 0, 0xc9, _, NoModrm, 0, 0, 0}, - -/* conditional jumps */ -{"jo", 1, 0x70, _, Jump, Disp, 0, 0}, - -{"jno", 1, 0x71, _, Jump, Disp, 0, 0}, - -{"jb", 1, 0x72, _, Jump, Disp, 0, 0}, -{"jc", 1, 0x72, _, Jump, Disp, 0, 0}, -{"jnae", 1, 0x72, _, Jump, Disp, 0, 0}, - -{"jnb", 1, 0x73, _, Jump, Disp, 0, 0}, -{"jnc", 1, 0x73, _, Jump, Disp, 0, 0}, -{"jae", 1, 0x73, _, Jump, Disp, 0, 0}, - -{"je", 1, 0x74, _, Jump, Disp, 0, 0}, -{"jz", 1, 0x74, _, Jump, Disp, 0, 0}, - -{"jne", 1, 0x75, _, Jump, Disp, 0, 0}, -{"jnz", 1, 0x75, _, Jump, Disp, 0, 0}, - -{"jbe", 1, 0x76, _, Jump, Disp, 0, 0}, -{"jna", 1, 0x76, _, Jump, Disp, 0, 0}, - -{"jnbe", 1, 0x77, _, Jump, Disp, 0, 0}, -{"ja", 1, 0x77, _, Jump, Disp, 0, 0}, - -{"js", 1, 0x78, _, Jump, Disp, 0, 0}, - -{"jns", 1, 0x79, _, Jump, Disp, 0, 0}, - -{"jp", 1, 0x7a, _, Jump, Disp, 0, 0}, -{"jpe", 1, 0x7a, _, Jump, Disp, 0, 0}, - -{"jnp", 1, 0x7b, _, Jump, Disp, 0, 0}, -{"jpo", 1, 0x7b, _, Jump, Disp, 0, 0}, - -{"jl", 1, 0x7c, _, Jump, Disp, 0, 0}, -{"jnge", 1, 0x7c, _, Jump, Disp, 0, 0}, - -{"jnl", 1, 0x7d, _, Jump, Disp, 0, 0}, -{"jge", 1, 0x7d, _, Jump, Disp, 0, 0}, - -{"jle", 1, 0x7e, _, Jump, Disp, 0, 0}, -{"jng", 1, 0x7e, _, Jump, Disp, 0, 0}, - -{"jnle", 1, 0x7f, _, Jump, Disp, 0, 0}, -{"jg", 1, 0x7f, _, Jump, Disp, 0, 0}, - -/* these turn into pseudo operations when disp is larger than 8 bits */ -#define IS_JUMP_ON_CX_ZERO(o) \ - (o == 0x67e3) -#define IS_JUMP_ON_ECX_ZERO(o) \ - (o == 0xe3) - -{"jcxz", 1, 0x67e3, _, JumpByte, Disp, 0, 0}, -{"jecxz", 1, 0xe3, _, JumpByte, Disp, 0, 0}, - -#define IS_LOOP_ECX_TIMES(o) \ - (o == 0xe2 || o == 0xe1 || o == 0xe0) - -{"loop", 1, 0xe2, _, JumpByte, Disp, 0, 0}, - -{"loopz", 1, 0xe1, _, JumpByte, Disp, 0, 0}, -{"loope", 1, 0xe1, _, JumpByte, Disp, 0, 0}, - -{"loopnz", 1, 0xe0, _, JumpByte, Disp, 0, 0}, -{"loopne", 1, 0xe0, _, JumpByte, Disp, 0, 0}, - -/* set byte on flag instructions */ -{"seto", 1, 0x0f90, 0, Modrm, Reg8|Mem, 0, 0}, - -{"setno", 1, 0x0f91, 0, Modrm, Reg8|Mem, 0, 0}, - -{"setb", 1, 0x0f92, 0, Modrm, Reg8|Mem, 0, 0}, -{"setnae", 1, 0x0f92, 0, Modrm, Reg8|Mem, 0, 0}, - -{"setnb", 1, 0x0f93, 0, Modrm, Reg8|Mem, 0, 0}, -{"setae", 1, 0x0f93, 0, Modrm, Reg8|Mem, 0, 0}, - -{"sete", 1, 0x0f94, 0, Modrm, Reg8|Mem, 0, 0}, -{"setz", 1, 0x0f94, 0, Modrm, Reg8|Mem, 0, 0}, - -{"setne", 1, 0x0f95, 0, Modrm, Reg8|Mem, 0, 0}, -{"setnz", 1, 0x0f95, 0, Modrm, Reg8|Mem, 0, 0}, - -{"setbe", 1, 0x0f96, 0, Modrm, Reg8|Mem, 0, 0}, -{"setna", 1, 0x0f96, 0, Modrm, Reg8|Mem, 0, 0}, - -{"setnbe", 1, 0x0f97, 0, Modrm, Reg8|Mem, 0, 0}, -{"seta", 1, 0x0f97, 0, Modrm, Reg8|Mem, 0, 0}, - -{"sets", 1, 0x0f98, 0, Modrm, Reg8|Mem, 0, 0}, - -{"setns", 1, 0x0f99, 0, Modrm, Reg8|Mem, 0, 0}, - -{"setp", 1, 0x0f9a, 0, Modrm, Reg8|Mem, 0, 0}, -{"setpe", 1, 0x0f9a, 0, Modrm, Reg8|Mem, 0, 0}, - -{"setnp", 1, 0x0f9b, 0, Modrm, Reg8|Mem, 0, 0}, -{"setpo", 1, 0x0f9b, 0, Modrm, Reg8|Mem, 0, 0}, - -{"setl", 1, 0x0f9c, 0, Modrm, Reg8|Mem, 0, 0}, -{"setnge", 1, 0x0f9c, 0, Modrm, Reg8|Mem, 0, 0}, - -{"setnl", 1, 0x0f9d, 0, Modrm, Reg8|Mem, 0, 0}, -{"setge", 1, 0x0f9d, 0, Modrm, Reg8|Mem, 0, 0}, - -{"setle", 1, 0x0f9e, 0, Modrm, Reg8|Mem, 0, 0}, -{"setng", 1, 0x0f9e, 0, Modrm, Reg8|Mem, 0, 0}, - -{"setnle", 1, 0x0f9f, 0, Modrm, Reg8|Mem, 0, 0}, -{"setg", 1, 0x0f9f, 0, Modrm, Reg8|Mem, 0, 0}, - -#define IS_STRING_INSTRUCTION(o) \ - ((o) == 0xa6 || (o) == 0x6c || (o) == 0x6e || (o) == 0x6e || \ - (o) == 0xac || (o) == 0xa4 || (o) == 0xae || (o) == 0xaa || \ - (o) == 0xd7) - -/* string manipulation */ -{"cmps", 0, 0xa6, _, W|NoModrm, 0, 0, 0}, -{"ins", 0, 0x6c, _, W|NoModrm, 0, 0, 0}, -{"outs", 0, 0x6e, _, W|NoModrm, 0, 0, 0}, -{"lods", 0, 0xac, _, W|NoModrm, 0, 0, 0}, -{"movs", 0, 0xa4, _, W|NoModrm, 0, 0, 0}, -{"scas", 0, 0xae, _, W|NoModrm, 0, 0, 0}, -{"stos", 0, 0xaa, _, W|NoModrm, 0, 0, 0}, -{"xlat", 0, 0xd7, _, NoModrm, 0, 0, 0}, - -/* bit manipulation */ -{"bsf", 2, 0x0fbc, _, Modrm|ReverseRegRegmem, Reg|Mem, Reg, 0}, -{"bsr", 2, 0x0fbd, _, Modrm|ReverseRegRegmem, Reg|Mem, Reg, 0}, -{"bt", 2, 0x0fa3, _, Modrm, Reg, Reg|Mem, 0}, -{"bt", 2, 0x0fba, 4, Modrm, Imm8, Reg|Mem, 0}, -{"btc", 2, 0x0fbb, _, Modrm, Reg, Reg|Mem, 0}, -{"btc", 2, 0x0fba, 7, Modrm, Imm8, Reg|Mem, 0}, -{"btr", 2, 0x0fb3, _, Modrm, Reg, Reg|Mem, 0}, -{"btr", 2, 0x0fba, 6, Modrm, Imm8, Reg|Mem, 0}, -{"bts", 2, 0x0fab, _, Modrm, Reg, Reg|Mem, 0}, -{"bts", 2, 0x0fba, 5, Modrm, Imm8, Reg|Mem, 0}, - -/* interrupts & op. sys insns */ -/* See i386.c for conversion of 'int $3' into the special int 3 insn. */ -#define INT_OPCODE 0xcd -#define INT3_OPCODE 0xcc -{"int", 1, 0xcd, _, NoModrm, Imm8, 0, 0}, -{"int3", 0, 0xcc, _, NoModrm, 0, 0, 0}, -{"into", 0, 0xce, _, NoModrm, 0, 0, 0}, -{"iret", 0, 0xcf, _, NoModrm, 0, 0, 0}, - -{"boundl", 2, 0x62, _, Modrm, Reg32, Mem, 0}, -{"boundw", 2, 0x6662, _, Modrm, Reg16, Mem, 0}, - -{"hlt", 0, 0xf4, _, NoModrm, 0, 0, 0}, -{"wait", 0, 0x9b, _, NoModrm, 0, 0, 0}, -/* nop is actually 'xchgl %eax, %eax' */ -{"nop", 0, 0x90, _, NoModrm, 0, 0, 0}, - -/* protection control */ -{"arpl", 2, 0x63, _, Modrm, Reg16, Reg16|Mem, 0}, -{"lar", 2, 0x0f02, _, Modrm|ReverseRegRegmem, WordReg|Mem, WordReg, 0}, -{"lgdt", 1, 0x0f01, 2, Modrm, Mem, 0, 0}, -{"lidt", 1, 0x0f01, 3, Modrm, Mem, 0, 0}, -{"lldt", 1, 0x0f00, 2, Modrm, WordReg|Mem, 0, 0}, -{"lmsw", 1, 0x0f01, 6, Modrm, WordReg|Mem, 0, 0}, -{"lsl", 2, 0x0f03, _, Modrm|ReverseRegRegmem, WordReg|Mem, WordReg, 0}, -{"ltr", 1, 0x0f00, 3, Modrm, WordReg|Mem, 0, 0}, - -{"sgdt", 1, 0x0f01, 0, Modrm, Mem, 0, 0}, -{"sidt", 1, 0x0f01, 1, Modrm, Mem, 0, 0}, -{"sldt", 1, 0x0f00, 0, Modrm, WordReg|Mem, 0, 0}, -{"smsw", 1, 0x0f01, 4, Modrm, WordReg|Mem, 0, 0}, -{"str", 1, 0x0f00, 1, Modrm, Reg16|Mem, 0, 0}, - -{"verr", 1, 0x0f00, 4, Modrm, WordReg|Mem, 0, 0}, -{"verw", 1, 0x0f00, 5, Modrm, WordReg|Mem, 0, 0}, - -/* floating point instructions */ - -/* load */ -{"fld", 1, 0xd9c0, _, ShortForm, FloatReg, 0, 0}, /* register */ -{"flds", 1, 0xd9, 0, Modrm, Mem, 0, 0}, /* %st0 <-- mem float */ -{"fildl", 1, 0xdb, 0, Modrm, Mem, 0, 0}, /* %st0 <-- mem word */ -{"fldl", 1, 0xdd, 0, Modrm, Mem, 0, 0}, /* %st0 <-- mem double */ -{"fldl", 1, 0xd9c0, _, ShortForm, FloatReg, 0, 0}, /* register */ -{"filds", 1, 0xdf, 0, Modrm, Mem, 0, 0}, /* %st0 <-- mem dword */ -{"fildq", 1, 0xdf, 5, Modrm, Mem, 0, 0}, /* %st0 <-- mem qword */ -{"fldt", 1, 0xdb, 5, Modrm, Mem, 0, 0}, /* %st0 <-- mem efloat */ -{"fbld", 1, 0xdf, 4, Modrm, Mem, 0, 0}, /* %st0 <-- mem bcd */ - -/* store (no pop) */ -{"fst", 1, 0xddd0, _, ShortForm, FloatReg, 0, 0}, /* register */ -{"fsts", 1, 0xd9, 2, Modrm, Mem, 0, 0}, /* %st0 --> mem float */ -{"fistl", 1, 0xdb, 2, Modrm, Mem, 0, 0}, /* %st0 --> mem dword */ -{"fstl", 1, 0xdd, 2, Modrm, Mem, 0, 0}, /* %st0 --> mem double */ -{"fstl", 1, 0xddd0, _, ShortForm, FloatReg, 0, 0}, /* register */ -{"fists", 1, 0xdf, 2, Modrm, Mem, 0, 0}, /* %st0 --> mem word */ - -/* store (with pop) */ -{"fstp", 1, 0xddd8, _, ShortForm, FloatReg, 0, 0}, /* register */ -{"fstps", 1, 0xd9, 3, Modrm, Mem, 0, 0}, /* %st0 --> mem float */ -{"fistpl", 1, 0xdb, 3, Modrm, Mem, 0, 0}, /* %st0 --> mem word */ -{"fstpl", 1, 0xdd, 3, Modrm, Mem, 0, 0}, /* %st0 --> mem double */ -{"fstpl", 1, 0xddd8, _, ShortForm, FloatReg, 0, 0}, /* register */ -{"fistps", 1, 0xdf, 3, Modrm, Mem, 0, 0}, /* %st0 --> mem dword */ -{"fistpq", 1, 0xdf, 7, Modrm, Mem, 0, 0}, /* %st0 --> mem qword */ -{"fstpt", 1, 0xdb, 7, Modrm, Mem, 0, 0}, /* %st0 --> mem efloat */ -{"fbstp", 1, 0xdf, 6, Modrm, Mem, 0, 0}, /* %st0 --> mem bcd */ - -/* exchange %st with %st0 */ -{"fxch", 1, 0xd9c8, _, ShortForm, FloatReg, 0, 0}, - -/* comparison (without pop) */ -{"fcom", 1, 0xd8d0, _, ShortForm, FloatReg, 0, 0}, -{"fcoms", 1, 0xd8, 2, Modrm, Mem, 0, 0}, /* compare %st0, mem float */ -{"ficoml", 1, 0xda, 2, Modrm, Mem, 0, 0}, /* compare %st0, mem word */ -{"fcoml", 1, 0xdc, 2, Modrm, Mem, 0, 0}, /* compare %st0, mem double */ -{"fcoml", 1, 0xd8d0, _, ShortForm, FloatReg, 0, 0}, -{"ficoms", 1, 0xde, 2, Modrm, Mem, 0, 0}, /* compare %st0, mem dword */ - -/* comparison (with pop) */ -{"fcomp", 1, 0xd8d8, _, ShortForm, FloatReg, 0, 0}, -{"fcomps", 1, 0xd8, 3, Modrm, Mem, 0, 0}, /* compare %st0, mem float */ -{"ficompl", 1, 0xda, 3, Modrm, Mem, 0, 0}, /* compare %st0, mem word */ -{"fcompl", 1, 0xdc, 3, Modrm, Mem, 0, 0}, /* compare %st0, mem double */ -{"fcompl", 1, 0xd8d8, _, ShortForm, FloatReg, 0, 0}, -{"ficomps", 1, 0xde, 3, Modrm, Mem, 0, 0}, /* compare %st0, mem dword */ -{"fcompp", 0, 0xded9, _, NoModrm, 0, 0, 0}, /* compare %st0, %st1 & pop twice */ - -/* unordered comparison (with pop) */ -{"fucom", 1, 0xdde0, _, ShortForm, FloatReg, 0, 0}, -{"fucomp", 1, 0xdde8, _, ShortForm, FloatReg, 0, 0}, -{"fucompp", 0, 0xdae9, _, NoModrm, 0, 0, 0}, /* ucompare %st0, %st1 & pop twice */ - -{"ftst", 0, 0xd9e4, _, NoModrm, 0, 0, 0}, /* test %st0 */ -{"fxam", 0, 0xd9e5, _, NoModrm, 0, 0, 0}, /* examine %st0 */ - -/* load constants into %st0 */ -{"fld1", 0, 0xd9e8, _, NoModrm, 0, 0, 0}, /* %st0 <-- 1.0 */ -{"fldl2t", 0, 0xd9e9, _, NoModrm, 0, 0, 0}, /* %st0 <-- log2(10) */ -{"fldl2e", 0, 0xd9ea, _, NoModrm, 0, 0, 0}, /* %st0 <-- log2(e) */ -{"fldpi", 0, 0xd9eb, _, NoModrm, 0, 0, 0}, /* %st0 <-- pi */ -{"fldlg2", 0, 0xd9ec, _, NoModrm, 0, 0, 0}, /* %st0 <-- log10(2) */ -{"fldln2", 0, 0xd9ed, _, NoModrm, 0, 0, 0}, /* %st0 <-- ln(2) */ -{"fldz", 0, 0xd9ee, _, NoModrm, 0, 0, 0}, /* %st0 <-- 0.0 */ - -/* arithmetic */ - -/* add */ -{"fadd", 1, 0xd8c0, _, ShortForm, FloatReg, 0, 0}, -{"fadd", 2, 0xd8c0, _, ShortForm|FloatD, FloatReg, FloatAcc, 0}, -{"fadd", 0, 0xdcc1, _, NoModrm, 0, 0, 0}, /* alias for fadd %st, %st(1) */ -{"faddp", 1, 0xdac0, _, ShortForm, FloatReg, 0, 0}, -{"faddp", 2, 0xdac0, _, ShortForm|FloatD, FloatReg, FloatAcc, 0}, -{"faddp", 0, 0xdec1, _, NoModrm, 0, 0, 0}, /* alias for faddp %st, %st(1) */ -{"fadds", 1, 0xd8, 0, Modrm, Mem, 0, 0}, -{"fiaddl", 1, 0xda, 0, Modrm, Mem, 0, 0}, -{"faddl", 1, 0xdc, 0, Modrm, Mem, 0, 0}, -{"fiadds", 1, 0xde, 0, Modrm, Mem, 0, 0}, - -/* sub */ -/* Note: intel has decided that certain of these operations are reversed - in assembler syntax. */ -{"fsub", 1, 0xd8e0, _, ShortForm, FloatReg, 0, 0}, -{"fsub", 2, 0xd8e0, _, ShortForm, FloatReg, FloatAcc, 0}, -#ifdef NON_BROKEN_OPCODES -{"fsub", 2, 0xdce8, _, ShortForm, FloatAcc, FloatReg, 0}, -#else -{"fsub", 2, 0xdce0, _, ShortForm, FloatAcc, FloatReg, 0}, -#endif -{"fsub", 0, 0xdce1, _, NoModrm, 0, 0, 0}, -{"fsubp", 1, 0xdae0, _, ShortForm, FloatReg, 0, 0}, -{"fsubp", 2, 0xdae0, _, ShortForm, FloatReg, FloatAcc, 0}, -#ifdef NON_BROKEN_OPCODES -{"fsubp", 2, 0xdee8, _, ShortForm, FloatAcc, FloatReg, 0}, -#else -{"fsubp", 2, 0xdee0, _, ShortForm, FloatAcc, FloatReg, 0}, -#endif -{"fsubp", 0, 0xdee1, _, NoModrm, 0, 0, 0}, -{"fsubs", 1, 0xd8, 4, Modrm, Mem, 0, 0}, -{"fisubl", 1, 0xda, 4, Modrm, Mem, 0, 0}, -{"fsubl", 1, 0xdc, 4, Modrm, Mem, 0, 0}, -{"fisubs", 1, 0xde, 4, Modrm, Mem, 0, 0}, - -/* sub reverse */ -{"fsubr", 1, 0xd8e8, _, ShortForm, FloatReg, 0, 0}, -{"fsubr", 2, 0xd8e8, _, ShortForm, FloatReg, FloatAcc, 0}, -#ifdef NON_BROKEN_OPCODES -{"fsubr", 2, 0xdce0, _, ShortForm, FloatAcc, FloatReg, 0}, -#else -{"fsubr", 2, 0xdce8, _, ShortForm, FloatAcc, FloatReg, 0}, -#endif -{"fsubr", 0, 0xdce9, _, NoModrm, 0, 0, 0}, -{"fsubrp", 1, 0xdae8, _, ShortForm, FloatReg, 0, 0}, -{"fsubrp", 2, 0xdae8, _, ShortForm, FloatReg, FloatAcc, 0}, -#ifdef NON_BROKEN_OPCODES -{"fsubrp", 2, 0xdee0, _, ShortForm, FloatAcc, FloatReg, 0}, -#else -{"fsubrp", 2, 0xdee8, _, ShortForm, FloatAcc, FloatReg, 0}, -#endif -{"fsubrp", 0, 0xdee9, _, NoModrm, 0, 0, 0}, -{"fsubrs", 1, 0xd8, 5, Modrm, Mem, 0, 0}, -{"fisubrl", 1, 0xda, 5, Modrm, Mem, 0, 0}, -{"fsubrl", 1, 0xdc, 5, Modrm, Mem, 0, 0}, -{"fisubrs", 1, 0xde, 5, Modrm, Mem, 0, 0}, - -/* mul */ -{"fmul", 1, 0xd8c8, _, ShortForm, FloatReg, 0, 0}, -{"fmul", 2, 0xd8c8, _, ShortForm|FloatD, FloatReg, FloatAcc, 0}, -{"fmul", 0, 0xdcc9, _, NoModrm, 0, 0, 0}, -{"fmulp", 1, 0xdac8, _, ShortForm, FloatReg, 0, 0}, -{"fmulp", 2, 0xdac8, _, ShortForm|FloatD, FloatReg, FloatAcc, 0}, -{"fmulp", 0, 0xdec9, _, NoModrm, 0, 0, 0}, -{"fmuls", 1, 0xd8, 1, Modrm, Mem, 0, 0}, -{"fimull", 1, 0xda, 1, Modrm, Mem, 0, 0}, -{"fmull", 1, 0xdc, 1, Modrm, Mem, 0, 0}, -{"fimuls", 1, 0xde, 1, Modrm, Mem, 0, 0}, - -/* div */ -/* Note: intel has decided that certain of these operations are reversed - in assembler syntax. */ -{"fdiv", 1, 0xd8f0, _, ShortForm, FloatReg, 0, 0}, -{"fdiv", 2, 0xd8f0, _, ShortForm, FloatReg, FloatAcc, 0}, -#ifdef NON_BROKEN_OPCODES -{"fdiv", 2, 0xdcf8, _, ShortForm, FloatAcc, FloatReg, 0}, -#else -{"fdiv", 2, 0xdcf0, _, ShortForm, FloatAcc, FloatReg, 0}, -#endif -{"fdiv", 0, 0xdcf1, _, NoModrm, 0, 0, 0}, -{"fdivp", 1, 0xdaf0, _, ShortForm, FloatReg, 0, 0}, -{"fdivp", 2, 0xdaf0, _, ShortForm, FloatReg, FloatAcc, 0}, -#ifdef NON_BROKEN_OPCODES -{"fdivp", 2, 0xdef8, _, ShortForm, FloatAcc, FloatReg, 0}, -#else -{"fdivp", 2, 0xdef0, _, ShortForm, FloatAcc, FloatReg, 0}, -#endif -{"fdivp", 0, 0xdef1, _, NoModrm, 0, 0, 0}, -{"fdivs", 1, 0xd8, 6, Modrm, Mem, 0, 0}, -{"fidivl", 1, 0xda, 6, Modrm, Mem, 0, 0}, -{"fdivl", 1, 0xdc, 6, Modrm, Mem, 0, 0}, -{"fidivs", 1, 0xde, 6, Modrm, Mem, 0, 0}, - -/* div reverse */ -{"fdivr", 1, 0xd8f8, _, ShortForm, FloatReg, 0, 0}, -{"fdivr", 2, 0xd8f8, _, ShortForm, FloatReg, FloatAcc, 0}, -#ifdef NON_BROKEN_OPCODES -{"fdivr", 2, 0xdcf0, _, ShortForm, FloatAcc, FloatReg, 0}, -#else -{"fdivr", 2, 0xdcf8, _, ShortForm, FloatAcc, FloatReg, 0}, -#endif -{"fdivr", 0, 0xdcf9, _, NoModrm, 0, 0, 0}, -{"fdivrp", 1, 0xdaf8, _, ShortForm, FloatReg, 0, 0}, -{"fdivrp", 2, 0xdaf8, _, ShortForm, FloatReg, FloatAcc, 0}, -#ifdef NON_BROKEN_OPCODES -{"fdivrp", 2, 0xdef0, _, ShortForm, FloatAcc, FloatReg, 0}, -#else -{"fdivrp", 2, 0xdef8, _, ShortForm, FloatAcc, FloatReg, 0}, -#endif -{"fdivrp", 0, 0xdef9, _, NoModrm, 0, 0, 0}, -{"fdivrs", 1, 0xd8, 7, Modrm, Mem, 0, 0}, -{"fidivrl", 1, 0xda, 7, Modrm, Mem, 0, 0}, -{"fdivrl", 1, 0xdc, 7, Modrm, Mem, 0, 0}, -{"fidivrs", 1, 0xde, 7, Modrm, Mem, 0, 0}, - -{"f2xm1", 0, 0xd9f0, _, NoModrm, 0, 0, 0}, -{"fyl2x", 0, 0xd9f1, _, NoModrm, 0, 0, 0}, -{"fptan", 0, 0xd9f2, _, NoModrm, 0, 0, 0}, -{"fpatan", 0, 0xd9f3, _, NoModrm, 0, 0, 0}, -{"fxtract", 0, 0xd9f4, _, NoModrm, 0, 0, 0}, -{"fprem1", 0, 0xd9f5, _, NoModrm, 0, 0, 0}, -{"fdecstp", 0, 0xd9f6, _, NoModrm, 0, 0, 0}, -{"fincstp", 0, 0xd9f7, _, NoModrm, 0, 0, 0}, -{"fprem", 0, 0xd9f8, _, NoModrm, 0, 0, 0}, -{"fyl2xp1", 0, 0xd9f9, _, NoModrm, 0, 0, 0}, -{"fsqrt", 0, 0xd9fa, _, NoModrm, 0, 0, 0}, -{"fsincos", 0, 0xd9fb, _, NoModrm, 0, 0, 0}, -{"frndint", 0, 0xd9fc, _, NoModrm, 0, 0, 0}, -{"fscale", 0, 0xd9fd, _, NoModrm, 0, 0, 0}, -{"fsin", 0, 0xd9fe, _, NoModrm, 0, 0, 0}, -{"fcos", 0, 0xd9ff, _, NoModrm, 0, 0, 0}, - -{"fchs", 0, 0xd9e0, _, NoModrm, 0, 0, 0}, -{"fabs", 0, 0xd9e1, _, NoModrm, 0, 0, 0}, - -/* processor control */ -{"fninit", 0, 0xdbe3, _, NoModrm, 0, 0, 0}, -{"finit", 0, 0xdbe3, _, NoModrm, 0, 0, 0}, -{"fldcw", 1, 0xd9, 5, Modrm, Mem, 0, 0}, -{"fnstcw", 1, 0xd9, 7, Modrm, Mem, 0, 0}, -{"fstcw", 1, 0xd9, 7, Modrm, Mem, 0, 0}, -{"fnstsw", 1, 0xdfe0, _, NoModrm, Acc, 0, 0}, -{"fnstsw", 1, 0xdd, 7, Modrm, Mem, 0, 0}, -{"fnstsw", 0, 0xdfe0, _, NoModrm, 0, 0, 0}, -{"fstsw", 1, 0xdfe0, _, NoModrm, Acc, 0, 0}, -{"fstsw", 1, 0xdd, 7, Modrm, Mem, 0, 0}, -{"fstsw", 0, 0xdfe0, _, NoModrm, 0, 0, 0}, -{"fnclex", 0, 0xdbe2, _, NoModrm, 0, 0, 0}, -{"fclex", 0, 0xdbe2, _, NoModrm, 0, 0, 0}, -/* - We ignore the short format (287) versions of fstenv/fldenv & fsave/frstor - instructions; i'm not sure how to add them or how they are different. - My 386/387 book offers no details about this. -*/ -{"fnstenv", 1, 0xd9, 6, Modrm, Mem, 0, 0}, -{"fstenv", 1, 0xd9, 6, Modrm, Mem, 0, 0}, -{"fldenv", 1, 0xd9, 4, Modrm, Mem, 0, 0}, -{"fnsave", 1, 0xdd, 6, Modrm, Mem, 0, 0}, -{"fsave", 1, 0xdd, 6, Modrm, Mem, 0, 0}, -{"frstor", 1, 0xdd, 4, Modrm, Mem, 0, 0}, - -{"ffree", 1, 0xddc0, _, ShortForm, FloatReg, 0, 0}, -{"fnop", 0, 0xd9d0, _, NoModrm, 0, 0, 0}, -{"fwait", 0, 0x9b, _, NoModrm, 0, 0, 0}, - -/* - opcode prefixes; we allow them as seperate insns too - (see prefix table below) -*/ -{"aword", 0, 0x67, _, NoModrm, 0, 0, 0}, -{"word", 0, 0x66, _, NoModrm, 0, 0, 0}, -{"lock", 0, 0xf0, _, NoModrm, 0, 0, 0}, -{"cs", 0, 0x2e, _, NoModrm, 0, 0, 0}, -{"ds", 0, 0x3e, _, NoModrm, 0, 0, 0}, -{"es", 0, 0x26, _, NoModrm, 0, 0, 0}, -{"fs", 0, 0x64, _, NoModrm, 0, 0, 0}, -{"gs", 0, 0x65, _, NoModrm, 0, 0, 0}, -{"ss", 0, 0x36, _, NoModrm, 0, 0, 0}, -{"rep", 0, 0xf3, _, NoModrm, 0, 0, 0}, -{"repe", 0, 0xf3, _, NoModrm, 0, 0, 0}, -{ "repne", 0, 0xf2, _, NoModrm, 0, 0, 0}, - -{"", 0, 0, 0, 0, 0, 0, 0} /* sentinal */ -}; -#undef _ - -static const template *i386_optab_end - = i386_optab + sizeof (i386_optab)/sizeof(i386_optab[0]); - -/* 386 register table */ - -static const reg_entry i386_regtab[] = { - /* 8 bit regs */ - {"al", Reg8|Acc, 0}, {"cl", Reg8|ShiftCount, 1}, {"dl", Reg8, 2}, - {"bl", Reg8, 3}, - {"ah", Reg8, 4}, {"ch", Reg8, 5}, {"dh", Reg8, 6}, {"bh", Reg8, 7}, - /* 16 bit regs */ - {"ax", Reg16|Acc, 0}, {"cx", Reg16, 1}, {"dx", Reg16|InOutPortReg, 2}, {"bx", Reg16, 3}, - {"sp", Reg16, 4}, {"bp", Reg16, 5}, {"si", Reg16, 6}, {"di", Reg16, 7}, - /* 32 bit regs */ - {"eax", Reg32|Acc, 0}, {"ecx", Reg32, 1}, {"edx", Reg32, 2}, {"ebx", Reg32, 3}, - {"esp", Reg32, 4}, {"ebp", Reg32, 5}, {"esi", Reg32, 6}, {"edi", Reg32, 7}, - /* segment registers */ - {"es", SReg2, 0}, {"cs", SReg2, 1}, {"ss", SReg2, 2}, - {"ds", SReg2, 3}, {"fs", SReg3, 4}, {"gs", SReg3, 5}, - /* control registers */ - {"cr0", Control, 0}, {"cr2", Control, 2}, {"cr3", Control, 3}, - /* debug registers */ - {"db0", Debug, 0}, {"db1", Debug, 1}, {"db2", Debug, 2}, - {"db3", Debug, 3}, {"db6", Debug, 6}, {"db7", Debug, 7}, - /* test registers */ - {"tr6", Test, 6}, {"tr7", Test, 7}, - /* float registers */ - {"st(0)", FloatReg|FloatAcc, 0}, - {"st", FloatReg|FloatAcc, 0}, - {"st(1)", FloatReg, 1}, {"st(2)", FloatReg, 2}, - {"st(3)", FloatReg, 3}, {"st(4)", FloatReg, 4}, {"st(5)", FloatReg, 5}, - {"st(6)", FloatReg, 6}, {"st(7)", FloatReg, 7} -}; - -#define MAX_REG_NAME_SIZE 8 /* for parsing register names from input */ - -static const reg_entry *i386_regtab_end - = i386_regtab + sizeof(i386_regtab)/sizeof(i386_regtab[0]); - -/* segment stuff */ -static const seg_entry cs = { "cs", 0x2e }; -static const seg_entry ds = { "ds", 0x3e }; -static const seg_entry ss = { "ss", 0x36 }; -static const seg_entry es = { "es", 0x26 }; -static const seg_entry fs = { "fs", 0x64 }; -static const seg_entry gs = { "gs", 0x65 }; -static const seg_entry null = { "", 0x0 }; - -/* - This table is used to store the default segment register implied by all - possible memory addressing modes. - It is indexed by the mode & modrm entries of the modrm byte as follows: - index = (mode<<3) | modrm; -*/ -static const seg_entry *one_byte_segment_defaults[] = { - /* mode 0 */ - &ds, &ds, &ds, &ds, &null, &ds, &ds, &ds, - /* mode 1 */ - &ds, &ds, &ds, &ds, &null, &ss, &ds, &ds, - /* mode 2 */ - &ds, &ds, &ds, &ds, &null, &ss, &ds, &ds, - /* mode 3 --- not a memory reference; never referenced */ -}; - -static const seg_entry *two_byte_segment_defaults[] = { - /* mode 0 */ - &ds, &ds, &ds, &ds, &ss, &ds, &ds, &ds, - /* mode 1 */ - &ds, &ds, &ds, &ds, &ss, &ds, &ds, &ds, - /* mode 2 */ - &ds, &ds, &ds, &ds, &ss, &ds, &ds, &ds, - /* mode 3 --- not a memory reference; never referenced */ -}; - -static const prefix_entry i386_prefixtab[] = { - { "addr16", 0x67 }, /* address size prefix ==> 16bit addressing - * (How is this useful?) */ -#define WORD_PREFIX_OPCODE 0x66 - { "data16", 0x66 }, /* operand size prefix */ - { "lock", 0xf0 }, /* bus lock prefix */ - { "wait", 0x9b }, /* wait for coprocessor */ - { "cs", 0x2e }, { "ds", 0x3e }, /* segment overrides ... */ - { "es", 0x26 }, { "fs", 0x64 }, - { "gs", 0x65 }, { "ss", 0x36 }, -/* REPE & REPNE used to detect rep/repne with a non-string instruction */ -#define REPNE 0xf2 -#define REPE 0xf3 - { "rep", 0xf3 }, { "repe", 0xf3 }, /* repeat string instructions */ - { "repne", 0xf2 } -}; - -static const prefix_entry *i386_prefixtab_end - = i386_prefixtab + sizeof(i386_prefixtab)/sizeof(i386_prefixtab[0]); - -/* end of i386-opcode.h */ diff --git a/include/i860-opcode.h b/include/i860-opcode.h deleted file mode 100755 index c17e1f7f869..00000000000 --- a/include/i860-opcode.h +++ /dev/null @@ -1,491 +0,0 @@ -/* Table of opcodes for the i860. - Copyright (C) 1989 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler, and GDB, the GNU disassembler. - -GAS/GDB 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 1, or (at your option) -any later version. - -GAS/GDB 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 GAS or GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#if !defined(__STDC__) && !defined(const) -#define const -#endif - -/* - * Structure of an opcode table entry. - */ -struct i860_opcode -{ - const char *name; - unsigned long match; /* Bits that must be set. */ - unsigned long lose; /* Bits that must not be set. */ - const char *args; - /* Nonzero if this is a possible expand-instruction. */ - char expand; -}; - -enum expand_type -{ - E_MOV = 1, E_ADDR, E_U32, E_AND, E_S32, E_DELAY -}; - -/* - All i860 opcodes are 32 bits, except for the pseudoinstructions - and the operations utilizing a 32-bit address expression, an - unsigned 32-bit constant, or a signed 32-bit constant. - These opcodes are expanded into a two-instruction sequence for - any situation where the immediate operand does not fit in 32 bits. - In the case of the add and subtract operations the expansion is - to a three-instruction sequence (ex: orh, or, adds). In cases - where the address is to be relocated, the instruction is - expanded to handle the worse case, this could be optimized at - the final link if the actual address were known. - - The pseudoinstructions are: mov, fmov, pmov, nop, and fnop. - These instructions are implemented as a one or two instruction - sequence of other operations. - - The match component is a mask saying which bits must match a - particular opcode in order for an instruction to be an instance - of that opcode. - - The args component is a string containing one character - for each operand of the instruction. - -Kinds of operands: - # Number used by optimizer. It is ignored. - 1 src1 integer register. - 2 src2 integer register. - d dest register. - c ctrlreg control register. - i 16 bit immediate. - I 16 bit immediate, aligned. - 5 5 bit immediate. - l lbroff 26 bit PC relative immediate. - r sbroff 16 bit PC relative immediate. - s split 16 bit immediate. - S split 16 bit immediate, aligned. - e src1 floating point register. - f src2 floating point register. - g dest floating point register. - -*/ - -/* The order of the opcodes in this table is significant: - - * The assembler requires that all instances of the same mnemonic must be - consecutive. If they aren't, the assembler will bomb at runtime. - - * The disassembler should not care about the order of the opcodes. */ - -static struct i860_opcode i860_opcodes[] = -{ - -/* REG-Format Instructions */ -{ "ld.c", 0x30000000, 0xcc000000, "c,d", 0 }, /* ld.c csrc2,idest */ -{ "ld.b", 0x00000000, 0xfc000000, "1(2),d", 0 }, /* ld.b isrc1(isrc2),idest */ -{ "ld.b", 0x04000000, 0xf8000000, "I(2),d", E_ADDR }, /* ld.b #const(isrc2),idest */ -{ "ld.s", 0x10000000, 0xec000001, "1(2),d", 0 }, /* ld.s isrc1(isrc2),idest */ -{ "ld.s", 0x14000001, 0xe8000000, "I(2),d", E_ADDR }, /* ld.s #const(isrc2),idest */ -{ "ld.l", 0x10000001, 0xec000000, "1(2),d", 0 }, /* ld.l isrc1(isrc2),idest */ -{ "ld.l", 0x14000001, 0xe8000000, "I(2),d", E_ADDR }, /* ld.l #const(isrc2),idest */ - -{ "st.c", 0x38000000, 0xc4000000, "1,c", 0 }, /* st.c isrc1ni,csrc2 */ -{ "st.b", 0x0c000000, 0xf0000000, "1,S(2)", E_ADDR }, /* st.b isrc1ni,#const(isrc2) */ -{ "st.s", 0x1c000000, 0xe0000000, "1,S(2)", E_ADDR }, /* st.s isrc1ni,#const(isrc2) */ -{ "st.l", 0x1c000001, 0xe0000000, "1,S(2)", E_ADDR }, /* st.l isrc1ni,#const(isrc2) */ - -{ "ixfr", 0x08000000, 0xf4000000, "1,g", 0 }, /* ixfr isrc1ni,fdest */ - -{ "fld.l", 0x20000002, 0xdc000001, "1(2),g", 0 }, /* fld.l isrc1(isrc2),fdest */ -{ "fld.l", 0x24000002, 0xd8000001, "i(2),g", E_ADDR }, /* fld.l #const(isrc2),fdest */ -{ "fld.l", 0x20000003, 0xdc000000, "1(2)++,g", 0 }, /* fld.l isrc1(isrc2)++,fdest */ -{ "fld.l", 0x24000003, 0xd8000000, "i(2)++,g", E_ADDR }, /* fld.l #const(isrc2)++,fdest */ -{ "fld.d", 0x20000000, 0xdc000007, "1(2),g", 0 }, /* fld.d isrc1(isrc2),fdest */ -{ "fld.d", 0x24000000, 0xd8000007, "i(2),g", E_ADDR }, /* fld.d #const(isrc2),fdest */ -{ "fld.d", 0x20000001, 0xdc000006, "1(2)++,g", 0 }, /* fld.d isrc1(isrc2)++,fdest */ -{ "fld.d", 0x24000001, 0xd8000006, "i(2)++,g", E_ADDR }, /* fld.d #const(isrc2)++,fdest */ -{ "fld.q", 0x20000004, 0xdc000003, "1(2),g", 0 }, /* fld.q isrc1(isrc2),fdest */ -{ "fld.q", 0x24000004, 0xd8000003, "i(2),g", E_ADDR }, /* fld.q #const(isrc2),fdest */ -{ "fld.q", 0x20000005, 0xdc000002, "1(2)++,g", 0 }, /* fld.q isrc1(isrc2)++,fdest */ -{ "fld.q", 0x24000005, 0xd8000002, "i(2)++,g", E_ADDR }, /* fld.q #const(isrc2)++,fdest */ - -{ "pfld.l", 0x60000000, 0x9c000003, "1(2),g", 0 }, /* pfld.l isrc1(isrc2),fdest */ -{ "pfld.l", 0x64000000, 0x98000003, "i(2),g", E_ADDR }, /* pfld.l #const(isrc2),fdest */ -{ "pfld.l", 0x60000001, 0x9c000002, "1(2)++,g", 0 }, /* pfld.l isrc1(isrc2)++,fdest */ -{ "pfld.l", 0x64000001, 0x98000002, "i(2)++,g", E_ADDR }, /* pfld.l #const(isrc2)++,fdest */ -{ "pfld.d", 0x60000000, 0x9c000007, "1(2),g", 0 }, /* pfld.d isrc1(isrc2),fdest */ -{ "pfld.d", 0x64000000, 0x98000007, "i(2),g", E_ADDR }, /* pfld.d #const(isrc2),fdest */ -{ "pfld.d", 0x60000001, 0x9c000006, "1(2)++,g", 0 }, /* pfld.d isrc1(isrc2)++,fdest */ -{ "pfld.d", 0x64000001, 0x98000006, "i(2)++,g", E_ADDR }, /* pfld.d #const(isrc2)++,fdest */ - -{ "fst.l", 0x28000002, 0xd4000001, "g,1(2)", 0 }, /* fst.l fdest,isrc1(isrc2) */ -{ "fst.l", 0x2c000002, 0xd0000001, "g,i(2)", E_ADDR }, /* fst.l fdest,#const(isrc2) */ -{ "fst.l", 0x28000003, 0xd4000000, "g,1(2)++", 0 }, /* fst.l fdest,isrc1(isrc2)++ */ -{ "fst.l", 0x2c000003, 0xd0000000, "g,i(2)++", E_ADDR }, /* fst.l fdest,#const(isrc2)++ */ -{ "fst.d", 0x28000000, 0xd4000007, "g,1(2)", 0 }, /* fst.d fdest,isrc1(isrc2) */ -{ "fst.d", 0x2c000000, 0xd0000007, "g,i(2)", E_ADDR }, /* fst.d fdest,#const(isrc2) */ -{ "fst.d", 0x28000001, 0xd4000006, "g,1(2)++", 0 }, /* fst.d fdest,isrc1(isrc2)++ */ -{ "fst.d", 0x2c000001, 0xd0000006, "g,i(2)++", E_ADDR }, /* fst.d fdest,#const(isrc2)++ */ - -{ "pst.d", 0x3c000000, 0xc0000007, "g,i(2)", E_ADDR }, /* pst.d fdest,#const(isrc2) */ -{ "pst.d", 0x3c000001, 0xc0000006, "g,i(2)++", E_ADDR }, /* pst.d fdest,#const(isrc2)++ */ - -{ "addu", 0x80000000, 0x7c000000, "1,2,d", 0 }, /* addu isrc1,isrc2,idest */ -{ "addu", 0x84000000, 0x78000000, "i,2,d", E_S32 }, /* addu #const,isrc2,idest */ -{ "adds", 0x90000000, 0x6c000000, "1,2,d", 0 }, /* adds isrc1,isrc2,idest */ -{ "adds", 0x94000000, 0x68000000, "i,2,d", E_S32 }, /* adds #const,isrc2,idest */ -{ "subu", 0x88000000, 0x74000000, "1,2,d", 0 }, /* subu isrc1,isrc2,idest */ -{ "subu", 0x8c000000, 0x70000000, "i,2,d", E_S32 }, /* subu #const,isrc2,idest */ -{ "subs", 0x98000000, 0x64000000, "1,2,d", 0 }, /* subs isrc1,isrc2,idest */ -{ "subs", 0x9c000000, 0x60000000, "i,2,d", E_S32 }, /* subs #const,isrc2,idest */ - -{ "shl", 0xa0000000, 0x5c000000, "1,2,d", 0 }, /* shl isrc1,isrc2,idest */ -{ "shl", 0xa4000000, 0x58000000, "i,2,d", 0 }, /* shl #const,isrc2,idest */ -{ "shr", 0xa8000000, 0x54000000, "1,2,d", 0 }, /* shr isrc1,isrc2,idest */ -{ "shr", 0xac000000, 0x50000000, "i,2,d", 0 }, /* shr #const,isrc2,idest */ -{ "shrd", 0xb0000000, 0x4c000000, "1,2,d", 0 }, /* shrd isrc1,isrc2,idest */ -{ "shra", 0xb8000000, 0x44000000, "1,2,d", 0 }, /* shra isrc1,isrc2,idest */ -{ "shra", 0xbc000000, 0x40000000, "i,2,d", 0 }, /* shra #const,isrc2,idest */ - -{ "mov", 0xa0000000, 0x5c00f800, "2,d", 0 }, /* shl r0,isrc2,idest */ -{ "mov", 0x94000000, 0x69e00000, "i,d", E_MOV }, /* adds #const,r0,idest */ -{ "nop", 0xa0000000, 0x5ffff800, "", 0 }, /* shl r0,r0,r0 */ -{ "fnop", 0xb0000000, 0x4ffff800, "", 0 }, /* shrd r0,r0,r0 */ - -{ "trap", 0x44000000, 0xb8000000, "1,2,d", 0 }, /* trap isrc1ni,isrc2,idest */ - -{ "flush", 0x34000000, 0xc81f0001, "i(2)", E_ADDR }, /* flush #const(isrc2) */ -{ "flush", 0x34000001, 0xc81f0000, "i(2)++", E_ADDR }, /* flush #const(isrc2)++ */ - -{ "and", 0xc0000000, 0x3c000000, "1,2,d", 0 }, /* and isrc1,isrc2,idest */ -{ "and", 0xc4000000, 0x38000000, "i,2,d", E_AND }, /* and #const,isrc2,idest */ -{ "andh", 0xc8000000, 0x34000000, "1,2,d", 0 }, /* andh isrc1,isrc2,idest */ -{ "andh", 0xcc000000, 0x30000000, "i,2,d", 0 }, /* andh #const,isrc2,idest */ -{ "andnot", 0xd0000000, 0x2c000000, "1,2,d", 0 }, /* andnot isrc1,isrc2,idest */ -{ "andnot", 0xd4000000, 0x28000000, "i,2,d", E_U32 }, /* andnot #const,isrc2,idest */ -{ "andnoth", 0xd8000000, 0x24000000, "1,2,d", 0 }, /* andnoth isrc1,isrc2,idest */ -{ "andnoth", 0xdc000000, 0x20000000, "i,2,d", 0 }, /* andnoth #const,isrc2,idest */ -{ "or", 0xe0000000, 0x1c000000, "1,2,d", 0 }, /* or isrc1,isrc2,idest */ -{ "or", 0xe4000000, 0x18000000, "i,2,d", E_U32 }, /* or #const,isrc2,idest */ -{ "orh", 0xe8000000, 0x14000000, "1,2,d", 0 }, /* orh isrc1,isrc2,idest */ -{ "orh", 0xec000000, 0x10000000, "i,2,d", 0 }, /* orh #const,isrc2,idest */ -{ "xor", 0xf0000000, 0x0c000000, "1,2,d", 0 }, /* xor isrc1,isrc2,idest */ -{ "xor", 0xf4000000, 0x08000000, "i,2,d", E_U32 }, /* xor #const,isrc2,idest */ -{ "xorh", 0xf8000000, 0x04000000, "1,2,d", 0 }, /* xorh isrc1,isrc2,idest */ -{ "xorh", 0xfc000000, 0x00000000, "i,2,d", 0 }, /* xorh #const,isrc2,idest */ - -{ "bte", 0x58000000, 0xa4000000, "1,2,s", 0 }, /* bte isrc1s,isrc2,sbroff */ -{ "bte", 0x5c000000, 0xa0000000, "5,2,s", 0 }, /* bte #const5,isrc2,sbroff */ -{ "btne", 0x50000000, 0xac000000, "1,2,s", 0 }, /* btne isrc1s,isrc2,sbroff */ -{ "btne", 0x54000000, 0xa8000000, "5,2,s", 0 }, /* btne #const5,isrc2,sbroff */ -{ "bla", 0xb4000000, 0x48000000, "1,2,s", E_DELAY }, /* bla isrc1s,isrc2,sbroff */ -{ "bri", 0x40000000, 0xbc000000, "1", E_DELAY }, /* bri isrc1ni */ - -/* Core Escape Instruction Format */ -{ "lock", 0x4c000001, 0xb000001e, "", 0 }, /* lock set BL in dirbase */ -{ "calli", 0x4c000002, 0xb000001d, "1", E_DELAY }, /* calli isrc1ni */ -{ "intovr", 0x4c000004, 0xb000001b, "", 0 }, /* intovr trap on integer overflow */ -{ "unlock", 0x4c000007, 0xb0000018, "", 0 }, /* unlock clear BL in dirbase */ - -/* CTRL-Format Instructions */ -{ "br", 0x68000000, 0x94000000, "l", E_DELAY }, /* br lbroff */ -{ "call", 0x6c000000, 0x90000000, "l", E_DELAY }, /* call lbroff */ -{ "bc", 0x70000000, 0x8c000000, "l", 0 }, /* bc lbroff */ -{ "bc.t", 0x74000000, 0x88000000, "l", E_DELAY }, /* bc.t lbroff */ -{ "bnc", 0x78000000, 0x84000000, "l", 0 }, /* bnc lbroff */ -{ "bnc.t", 0x7c000000, 0x80000000, "l", E_DELAY }, /* bnc.t lbroff */ - -/* Floating Point Escape Instruction Format - pfam.p fsrc1,fsrc2,fdest */ -{ "r2p1.ss", 0x48000400, 0xb40003ff, "e,f,g", 0 }, -{ "r2p1.sd", 0x48000480, 0xb400037f, "e,f,g", 0 }, -{ "r2p1.dd", 0x48000580, 0xb400027f, "e,f,g", 0 }, -{ "r2pt.ss", 0x48000401, 0xb40003fe, "e,f,g", 0 }, -{ "r2pt.sd", 0x48000481, 0xb400037e, "e,f,g", 0 }, -{ "r2pt.dd", 0x48000581, 0xb400027e, "e,f,g", 0 }, -{ "r2ap1.ss", 0x48000402, 0xb40003fd, "e,f,g", 0 }, -{ "r2ap1.sd", 0x48000482, 0xb400037d, "e,f,g", 0 }, -{ "r2ap1.dd", 0x48000582, 0xb400027d, "e,f,g", 0 }, -{ "r2apt.ss", 0x48000403, 0xb40003fc, "e,f,g", 0 }, -{ "r2apt.sd", 0x48000483, 0xb400037c, "e,f,g", 0 }, -{ "r2apt.dd", 0x48000583, 0xb400027c, "e,f,g", 0 }, -{ "i2p1.ss", 0x48000404, 0xb40003fb, "e,f,g", 0 }, -{ "i2p1.sd", 0x48000484, 0xb400037b, "e,f,g", 0 }, -{ "i2p1.dd", 0x48000584, 0xb400027b, "e,f,g", 0 }, -{ "i2pt.ss", 0x48000405, 0xb40003fa, "e,f,g", 0 }, -{ "i2pt.sd", 0x48000485, 0xb400037a, "e,f,g", 0 }, -{ "i2pt.dd", 0x48000585, 0xb400027a, "e,f,g", 0 }, -{ "i2ap1.ss", 0x48000406, 0xb40003f9, "e,f,g", 0 }, -{ "i2ap1.sd", 0x48000486, 0xb4000379, "e,f,g", 0 }, -{ "i2ap1.dd", 0x48000586, 0xb4000279, "e,f,g", 0 }, -{ "i2apt.ss", 0x48000407, 0xb40003f8, "e,f,g", 0 }, -{ "i2apt.sd", 0x48000487, 0xb4000378, "e,f,g", 0 }, -{ "i2apt.dd", 0x48000587, 0xb4000278, "e,f,g", 0 }, -{ "rat1p2.ss", 0x48000408, 0xb40003f7, "e,f,g", 0 }, -{ "rat1p2.sd", 0x48000488, 0xb4000377, "e,f,g", 0 }, -{ "rat1p2.dd", 0x48000588, 0xb4000277, "e,f,g", 0 }, -{ "m12apm.ss", 0x48000409, 0xb40003f6, "e,f,g", 0 }, -{ "m12apm.sd", 0x48000489, 0xb4000376, "e,f,g", 0 }, -{ "m12apm.dd", 0x48000589, 0xb4000276, "e,f,g", 0 }, -{ "ra1p2.ss", 0x4800040a, 0xb40003f5, "e,f,g", 0 }, -{ "ra1p2.sd", 0x4800048a, 0xb4000375, "e,f,g", 0 }, -{ "ra1p2.dd", 0x4800058a, 0xb4000275, "e,f,g", 0 }, -{ "m12ttpa.ss", 0x4800040b, 0xb40003f4, "e,f,g", 0 }, -{ "m12ttpa.sd", 0x4800048b, 0xb4000374, "e,f,g", 0 }, -{ "m12ttpa.dd", 0x4800058b, 0xb4000274, "e,f,g", 0 }, -{ "iat1p2.ss", 0x4800040c, 0xb40003f3, "e,f,g", 0 }, -{ "iat1p2.sd", 0x4800048c, 0xb4000373, "e,f,g", 0 }, -{ "iat1p2.dd", 0x4800058c, 0xb4000273, "e,f,g", 0 }, -{ "m12tpm.ss", 0x4800040d, 0xb40003f2, "e,f,g", 0 }, -{ "m12tpm.sd", 0x4800048d, 0xb4000372, "e,f,g", 0 }, -{ "m12tpm.dd", 0x4800058d, 0xb4000272, "e,f,g", 0 }, -{ "ia1p2.ss", 0x4800040e, 0xb40003f1, "e,f,g", 0 }, -{ "ia1p2.sd", 0x4800048e, 0xb4000371, "e,f,g", 0 }, -{ "ia1p2.dd", 0x4800058e, 0xb4000271, "e,f,g", 0 }, -{ "m12tpa.ss", 0x4800040f, 0xb40003f0, "e,f,g", 0 }, -{ "m12tpa.sd", 0x4800048f, 0xb4000370, "e,f,g", 0 }, -{ "m12tpa.dd", 0x4800058f, 0xb4000270, "e,f,g", 0 }, - -/* Floating Point Escape Instruction Format - pfsm.p fsrc1,fsrc2,fdest */ -{ "r2s1.ss", 0x48000410, 0xb40003ef, "e,f,g", 0 }, -{ "r2s1.sd", 0x48000490, 0xb400036f, "e,f,g", 0 }, -{ "r2s1.dd", 0x48000590, 0xb400026f, "e,f,g", 0 }, -{ "r2st.ss", 0x48000411, 0xb40003ee, "e,f,g", 0 }, -{ "r2st.sd", 0x48000491, 0xb400036e, "e,f,g", 0 }, -{ "r2st.dd", 0x48000591, 0xb400026e, "e,f,g", 0 }, -{ "r2as1.ss", 0x48000412, 0xb40003ed, "e,f,g", 0 }, -{ "r2as1.sd", 0x48000492, 0xb400036d, "e,f,g", 0 }, -{ "r2as1.dd", 0x48000592, 0xb400026d, "e,f,g", 0 }, -{ "r2ast.ss", 0x48000413, 0xb40003ec, "e,f,g", 0 }, -{ "r2ast.sd", 0x48000493, 0xb400036c, "e,f,g", 0 }, -{ "r2ast.dd", 0x48000593, 0xb400026c, "e,f,g", 0 }, -{ "i2s1.ss", 0x48000414, 0xb40003eb, "e,f,g", 0 }, -{ "i2s1.sd", 0x48000494, 0xb400036b, "e,f,g", 0 }, -{ "i2s1.dd", 0x48000594, 0xb400026b, "e,f,g", 0 }, -{ "i2st.ss", 0x48000415, 0xb40003ea, "e,f,g", 0 }, -{ "i2st.sd", 0x48000495, 0xb400036a, "e,f,g", 0 }, -{ "i2st.dd", 0x48000595, 0xb400026a, "e,f,g", 0 }, -{ "i2as1.ss", 0x48000416, 0xb40003e9, "e,f,g", 0 }, -{ "i2as1.sd", 0x48000496, 0xb4000369, "e,f,g", 0 }, -{ "i2as1.dd", 0x48000596, 0xb4000269, "e,f,g", 0 }, -{ "i2ast.ss", 0x48000417, 0xb40003e8, "e,f,g", 0 }, -{ "i2ast.sd", 0x48000497, 0xb4000368, "e,f,g", 0 }, -{ "i2ast.dd", 0x48000597, 0xb4000268, "e,f,g", 0 }, -{ "rat1s2.ss", 0x48000418, 0xb40003e7, "e,f,g", 0 }, -{ "rat1s2.sd", 0x48000498, 0xb4000367, "e,f,g", 0 }, -{ "rat1s2.dd", 0x48000598, 0xb4000267, "e,f,g", 0 }, -{ "m12asm.ss", 0x48000419, 0xb40003e6, "e,f,g", 0 }, -{ "m12asm.sd", 0x48000499, 0xb4000366, "e,f,g", 0 }, -{ "m12asm.dd", 0x48000599, 0xb4000266, "e,f,g", 0 }, -{ "ra1s2.ss", 0x4800041a, 0xb40003e5, "e,f,g", 0 }, -{ "ra1s2.sd", 0x4800049a, 0xb4000365, "e,f,g", 0 }, -{ "ra1s2.dd", 0x4800059a, 0xb4000265, "e,f,g", 0 }, -{ "m12ttsa.ss", 0x4800041b, 0xb40003e4, "e,f,g", 0 }, -{ "m12ttsa.sd", 0x4800049b, 0xb4000364, "e,f,g", 0 }, -{ "m12ttsa.dd", 0x4800059b, 0xb4000264, "e,f,g", 0 }, -{ "iat1s2.ss", 0x4800041c, 0xb40003e3, "e,f,g", 0 }, -{ "iat1s2.sd", 0x4800049c, 0xb4000363, "e,f,g", 0 }, -{ "iat1s2.dd", 0x4800059c, 0xb4000263, "e,f,g", 0 }, -{ "m12tsm.ss", 0x4800041d, 0xb40003e2, "e,f,g", 0 }, -{ "m12tsm.sd", 0x4800049d, 0xb4000362, "e,f,g", 0 }, -{ "m12tsm.dd", 0x4800059d, 0xb4000262, "e,f,g", 0 }, -{ "ia1s2.ss", 0x4800041e, 0xb40003e1, "e,f,g", 0 }, -{ "ia1s2.sd", 0x4800049e, 0xb4000361, "e,f,g", 0 }, -{ "ia1s2.dd", 0x4800059e, 0xb4000261, "e,f,g", 0 }, -{ "m12tsa.ss", 0x4800041f, 0xb40003e0, "e,f,g", 0 }, -{ "m12tsa.sd", 0x4800049f, 0xb4000360, "e,f,g", 0 }, -{ "m12tsa.dd", 0x4800059f, 0xb4000260, "e,f,g", 0 }, - -/* Floating Point Escape Instruction Format - pfmam.p fsrc1,fsrc2,fdest */ -{ "mr2p1.ss", 0x48000000, 0xb40007ff, "e,f,g", 0 }, -{ "mr2p1.sd", 0x48000080, 0xb400077f, "e,f,g", 0 }, -{ "mr2p1.dd", 0x48000180, 0xb400067f, "e,f,g", 0 }, -{ "mr2pt.ss", 0x48000001, 0xb40007fe, "e,f,g", 0 }, -{ "mr2pt.sd", 0x48000081, 0xb400077e, "e,f,g", 0 }, -{ "mr2pt.dd", 0x48000181, 0xb400067e, "e,f,g", 0 }, -{ "mr2mp1.ss", 0x48000002, 0xb40007fd, "e,f,g", 0 }, -{ "mr2mp1.sd", 0x48000082, 0xb400077d, "e,f,g", 0 }, -{ "mr2mp1.dd", 0x48000182, 0xb400067d, "e,f,g", 0 }, -{ "mr2mpt.ss", 0x48000003, 0xb40007fc, "e,f,g", 0 }, -{ "mr2mpt.sd", 0x48000083, 0xb400077c, "e,f,g", 0 }, -{ "mr2mpt.dd", 0x48000183, 0xb400067c, "e,f,g", 0 }, -{ "mi2p1.ss", 0x48000004, 0xb40007fb, "e,f,g", 0 }, -{ "mi2p1.sd", 0x48000084, 0xb400077b, "e,f,g", 0 }, -{ "mi2p1.dd", 0x48000184, 0xb400067b, "e,f,g", 0 }, -{ "mi2pt.ss", 0x48000005, 0xb40007fa, "e,f,g", 0 }, -{ "mi2pt.sd", 0x48000085, 0xb400077a, "e,f,g", 0 }, -{ "mi2pt.dd", 0x48000185, 0xb400067a, "e,f,g", 0 }, -{ "mi2mp1.ss", 0x48000006, 0xb40007f9, "e,f,g", 0 }, -{ "mi2mp1.sd", 0x48000086, 0xb4000779, "e,f,g", 0 }, -{ "mi2mp1.dd", 0x48000186, 0xb4000679, "e,f,g", 0 }, -{ "mi2mpt.ss", 0x48000007, 0xb40007f8, "e,f,g", 0 }, -{ "mi2mpt.sd", 0x48000087, 0xb4000778, "e,f,g", 0 }, -{ "mi2mpt.dd", 0x48000187, 0xb4000678, "e,f,g", 0 }, -{ "mrmt1p2.ss", 0x48000008, 0xb40007f7, "e,f,g", 0 }, -{ "mrmt1p2.sd", 0x48000088, 0xb4000777, "e,f,g", 0 }, -{ "mrmt1p2.dd", 0x48000188, 0xb4000677, "e,f,g", 0 }, -{ "mm12mpm.ss", 0x48000009, 0xb40007f6, "e,f,g", 0 }, -{ "mm12mpm.sd", 0x48000089, 0xb4000776, "e,f,g", 0 }, -{ "mm12mpm.dd", 0x48000189, 0xb4000676, "e,f,g", 0 }, -{ "mrm1p2.ss", 0x4800000a, 0xb40007f5, "e,f,g", 0 }, -{ "mrm1p2.sd", 0x4800008a, 0xb4000775, "e,f,g", 0 }, -{ "mrm1p2.dd", 0x4800018a, 0xb4000675, "e,f,g", 0 }, -{ "mm12ttpm.ss",0x4800000b, 0xb40007f4, "e,f,g", 0 }, -{ "mm12ttpm.sd",0x4800008b, 0xb4000774, "e,f,g", 0 }, -{ "mm12ttpm.dd",0x4800018b, 0xb4000674, "e,f,g", 0 }, -{ "mimt1p2.ss", 0x4800000c, 0xb40007f3, "e,f,g", 0 }, -{ "mimt1p2.sd", 0x4800008c, 0xb4000773, "e,f,g", 0 }, -{ "mimt1p2.dd", 0x4800018c, 0xb4000673, "e,f,g", 0 }, -{ "mm12tpm.ss", 0x4800000d, 0xb40007f2, "e,f,g", 0 }, -{ "mm12tpm.sd", 0x4800008d, 0xb4000772, "e,f,g", 0 }, -{ "mm12tpm.dd", 0x4800018d, 0xb4000672, "e,f,g", 0 }, -{ "mim1p2.ss", 0x4800000e, 0xb40007f1, "e,f,g", 0 }, -{ "mim1p2.sd", 0x4800008e, 0xb4000771, "e,f,g", 0 }, -{ "mim1p2.dd", 0x4800018e, 0xb4000671, "e,f,g", 0 }, - -/* Floating Point Escape Instruction Format - pfmsm.p fsrc1,fsrc2,fdest */ -{ "mr2s1.ss", 0x48000010, 0xb40007ef, "e,f,g", 0 }, -{ "mr2s1.sd", 0x48000090, 0xb400076f, "e,f,g", 0 }, -{ "mr2s1.dd", 0x48000190, 0xb400066f, "e,f,g", 0 }, -{ "mr2st.ss", 0x48000011, 0xb40007ee, "e,f,g", 0 }, -{ "mr2st.sd", 0x48000091, 0xb400076e, "e,f,g", 0 }, -{ "mr2st.dd", 0x48000191, 0xb400066e, "e,f,g", 0 }, -{ "mr2ms1.ss", 0x48000012, 0xb40007ed, "e,f,g", 0 }, -{ "mr2ms1.sd", 0x48000092, 0xb400076d, "e,f,g", 0 }, -{ "mr2ms1.dd", 0x48000192, 0xb400066d, "e,f,g", 0 }, -{ "mr2mst.ss", 0x48000013, 0xb40007ec, "e,f,g", 0 }, -{ "mr2mst.sd", 0x48000093, 0xb400076c, "e,f,g", 0 }, -{ "mr2mst.dd", 0x48000193, 0xb400066c, "e,f,g", 0 }, -{ "mi2s1.ss", 0x48000014, 0xb40007eb, "e,f,g", 0 }, -{ "mi2s1.sd", 0x48000094, 0xb400076b, "e,f,g", 0 }, -{ "mi2s1.dd", 0x48000194, 0xb400066b, "e,f,g", 0 }, -{ "mi2st.ss", 0x48000015, 0xb40007ea, "e,f,g", 0 }, -{ "mi2st.sd", 0x48000095, 0xb400076a, "e,f,g", 0 }, -{ "mi2st.dd", 0x48000195, 0xb400066a, "e,f,g", 0 }, -{ "mi2ms1.ss", 0x48000016, 0xb40007e9, "e,f,g", 0 }, -{ "mi2ms1.sd", 0x48000096, 0xb4000769, "e,f,g", 0 }, -{ "mi2ms1.dd", 0x48000196, 0xb4000669, "e,f,g", 0 }, -{ "mi2mst.ss", 0x48000017, 0xb40007e8, "e,f,g", 0 }, -{ "mi2mst.sd", 0x48000097, 0xb4000768, "e,f,g", 0 }, -{ "mi2mst.dd", 0x48000197, 0xb4000668, "e,f,g", 0 }, -{ "mrmt1s2.ss", 0x48000018, 0xb40007e7, "e,f,g", 0 }, -{ "mrmt1s2.sd", 0x48000098, 0xb4000767, "e,f,g", 0 }, -{ "mrmt1s2.dd", 0x48000198, 0xb4000667, "e,f,g", 0 }, -{ "mm12msm.ss", 0x48000019, 0xb40007e6, "e,f,g", 0 }, -{ "mm12msm.sd", 0x48000099, 0xb4000766, "e,f,g", 0 }, -{ "mm12msm.dd", 0x48000199, 0xb4000666, "e,f,g", 0 }, -{ "mrm1s2.ss", 0x4800001a, 0xb40007e5, "e,f,g", 0 }, -{ "mrm1s2.sd", 0x4800009a, 0xb4000765, "e,f,g", 0 }, -{ "mrm1s2.dd", 0x4800019a, 0xb4000665, "e,f,g", 0 }, -{ "mm12ttsm.ss",0x4800001b, 0xb40007e4, "e,f,g", 0 }, -{ "mm12ttsm.sd",0x4800009b, 0xb4000764, "e,f,g", 0 }, -{ "mm12ttsm.dd",0x4800019b, 0xb4000664, "e,f,g", 0 }, -{ "mimt1s2.ss", 0x4800001c, 0xb40007e3, "e,f,g", 0 }, -{ "mimt1s2.sd", 0x4800009c, 0xb4000763, "e,f,g", 0 }, -{ "mimt1s2.dd", 0x4800019c, 0xb4000663, "e,f,g", 0 }, -{ "mm12tsm.ss", 0x4800001d, 0xb40007e2, "e,f,g", 0 }, -{ "mm12tsm.sd", 0x4800009d, 0xb4000762, "e,f,g", 0 }, -{ "mm12tsm.dd", 0x4800019d, 0xb4000662, "e,f,g", 0 }, -{ "mim1s2.ss", 0x4800001e, 0xb40007e1, "e,f,g", 0 }, -{ "mim1s2.sd", 0x4800009e, 0xb4000761, "e,f,g", 0 }, -{ "mim1s2.dd", 0x4800019e, 0xb4000661, "e,f,g", 0 }, - - -{ "fmul.ss", 0x48000020, 0xb40007df, "e,f,g", 0 }, /* fmul.p fsrc1,fsrc2,fdest */ -{ "fmul.sd", 0x480000a0, 0xb400075f, "e,f,g", 0 }, /* fmul.p fsrc1,fsrc2,fdest */ -{ "fmul.dd", 0x480001a0, 0xb400065f, "e,f,g", 0 }, /* fmul.p fsrc1,fsrc2,fdest */ -{ "pfmul.ss", 0x48000420, 0xb40003df, "e,f,g", 0 }, /* pfmul.p fsrc1,fsrc2,fdest */ -{ "pfmul.sd", 0x480004a0, 0xb400035f, "e,f,g", 0 }, /* pfmul.p fsrc1,fsrc2,fdest */ -{ "pfmul.dd", 0x480005a0, 0xb400025f, "e,f,g", 0 }, /* pfmul.p fsrc1,fsrc2,fdest */ -{ "pfmul3.dd", 0x480005a4, 0xb400025b, "e,f,g", 0 }, /* pfmul3.p fsrc1,fsrc2,fdest */ -{ "fmlow.dd", 0x480001a1, 0xb400065e, "e,f,g", 0 }, /* fmlow.dd fsrc1,fsrc2,fdest */ -{ "frcp.ss", 0x48000022, 0xb40007dd, "f,g", 0 }, /* frcp.p fsrc2,fdest */ -{ "frcp.sd", 0x480000a2, 0xb400075d, "f,g", 0 }, /* frcp.p fsrc2,fdest */ -{ "frcp.dd", 0x480001a2, 0xb400065d, "f,g", 0 }, /* frcp.p fsrc2,fdest */ -{ "frsqr.ss", 0x48000023, 0xb40007dc, "f,g", 0 }, /* frsqr.p fsrc2,fdest */ -{ "frsqr.sd", 0x480000a3, 0xb400075c, "f,g", 0 }, /* frsqr.p fsrc2,fdest */ -{ "frsqr.dd", 0x480001a3, 0xb400065c, "f,g", 0 }, /* frsqr.p fsrc2,fdest */ -{ "fadd.ss", 0x48000030, 0xb40007cf, "e,f,g", 0 }, /* fadd.p fsrc1,fsrc2,fdest */ -{ "fadd.sd", 0x480000b0, 0xb400074f, "e,f,g", 0 }, /* fadd.p fsrc1,fsrc2,fdest */ -{ "fadd.dd", 0x480001b0, 0xb400064f, "e,f,g", 0 }, /* fadd.p fsrc1,fsrc2,fdest */ -{ "pfadd.ss", 0x48000430, 0xb40003cf, "e,f,g", 0 }, /* pfadd.p fsrc1,fsrc2,fdest */ -{ "pfadd.sd", 0x480004b0, 0xb400034f, "e,f,g", 0 }, /* pfadd.p fsrc1,fsrc2,fdest */ -{ "pfadd.dd", 0x480005b0, 0xb400024f, "e,f,g", 0 }, /* pfadd.p fsrc1,fsrc2,fdest */ -{ "fsub.ss", 0x48000031, 0xb40007ce, "e,f,g", 0 }, /* fsub.p fsrc1,fsrc2,fdest */ -{ "fsub.sd", 0x480000b1, 0xb400074e, "e,f,g", 0 }, /* fsub.p fsrc1,fsrc2,fdest */ -{ "fsub.dd", 0x480001b1, 0xb400064e, "e,f,g", 0 }, /* fsub.p fsrc1,fsrc2,fdest */ -{ "pfsub.ss", 0x48000431, 0xb40003ce, "e,f,g", 0 }, /* pfsub.p fsrc1,fsrc2,fdest */ -{ "pfsub.sd", 0x480004b1, 0xb400034e, "e,f,g", 0 }, /* pfsub.p fsrc1,fsrc2,fdest */ -{ "pfsub.dd", 0x480005b1, 0xb400024e, "e,f,g", 0 }, /* pfsub.p fsrc1,fsrc2,fdest */ -{ "fix.ss", 0x48000032, 0xb40007cd, "e,g", 0 }, /* fix.p fsrc1,fdest */ -{ "fix.sd", 0x480000b2, 0xb400074d, "e,g", 0 }, /* fix.p fsrc1,fdest */ -{ "fix.dd", 0x480001b2, 0xb400064d, "e,g", 0 }, /* fix.p fsrc1,fdest */ -{ "pfix.ss", 0x48000432, 0xb40003cd, "e,g", 0 }, /* pfix.p fsrc1,fdest */ -{ "pfix.sd", 0x480004b2, 0xb400034d, "e,g", 0 }, /* pfix.p fsrc1,fdest */ -{ "pfix.dd", 0x480005b2, 0xb400024d, "e,g", 0 }, /* pfix.p fsrc1,fdest */ -{ "famov.ss", 0x48000033, 0xb40007cc, "e,g", 0 }, /* famov.p fsrc1,fdest */ -{ "famov.ds", 0x48000133, 0xb40006cc, "e,g", 0 }, /* famov.p fsrc1,fdest */ -{ "famov.sd", 0x480000b3, 0xb400074c, "e,g", 0 }, /* famov.p fsrc1,fdest */ -{ "famov.dd", 0x480001b3, 0xb400064c, "e,g", 0 }, /* famov.p fsrc1,fdest */ -{ "pfamov.ss", 0x48000433, 0xb40003cc, "e,g", 0 }, /* pfamov.p fsrc1,fdest */ -{ "pfamov.ds", 0x48000533, 0xb40002cc, "e,g", 0 }, /* pfamov.p fsrc1,fdest */ -{ "pfamov.sd", 0x480004b3, 0xb400034c, "e,g", 0 }, /* pfamov.p fsrc1,fdest */ -{ "pfamov.dd", 0x480005b3, 0xb400024c, "e,g", 0 }, /* pfamov.p fsrc1,fdest */ -/* pfgt has R bit cleared; pfle has R bit set */ -{ "pfgt.ss", 0x48000434, 0xb40003cb, "e,f,g", 0 }, /* pfgt.p fsrc1,fsrc2,fdest */ -{ "pfgt.sd", 0x48000434, 0xb40003cb, "e,f,g", 0 }, /* pfgt.p fsrc1,fsrc2,fdest */ -{ "pfgt.dd", 0x48000534, 0xb40002cb, "e,f,g", 0 }, /* pfgt.p fsrc1,fsrc2,fdest */ -/* pfgt has R bit cleared; pfle has R bit set */ -{ "pfle.ss", 0x480004b4, 0xb400034b, "e,f,g", 0 }, /* pfle.p fsrc1,fsrc2,fdest */ -{ "pfle.sd", 0x480004b4, 0xb400034b, "e,f,g", 0 }, /* pfle.p fsrc1,fsrc2,fdest */ -{ "pfle.dd", 0x480005b4, 0xb400024b, "e,f,g", 0 }, /* pfle.p fsrc1,fsrc2,fdest */ -{ "ftrunc.ss", 0x4800003a, 0xb40007c5, "e,g", 0 }, /* ftrunc.p fsrc1,fdest */ -{ "ftrunc.sd", 0x480000ba, 0xb4000745, "e,g", 0 }, /* ftrunc.p fsrc1,fdest */ -{ "ftrunc.dd", 0x480001ba, 0xb4000645, "e,g", 0 }, /* ftrunc.p fsrc1,fdest */ -{ "pftrunc.ss", 0x4800043a, 0xb40003c5, "e,g", 0 }, /* pftrunc.p fsrc1,fdest */ -{ "pftrunc.sd", 0x480004ba, 0xb4000345, "e,g", 0 }, /* pftrunc.p fsrc1,fdest */ -{ "pftrunc.dd", 0x480005ba, 0xb4000245, "e,g", 0 }, /* pftrunc.p fsrc1,fdest */ -{ "fxfr", 0x48000040, 0xb40007bf, "e,d", 0 }, /* fxfr fsrc1,idest */ -{ "fiadd.ss", 0x48000049, 0xb40007b6, "e,f,g", 0 }, /* fiadd.w fsrc1,fsrc2,fdest */ -{ "fiadd.dd", 0x480001c9, 0xb4000636, "e,f,g", 0 }, /* fiadd.w fsrc1,fsrc2,fdest */ -{ "pfiadd.ss", 0x48000449, 0xb40003b6, "e,f,g", 0 }, /* pfiadd.w fsrc1,fsrc2,fdest */ -{ "pfiadd.dd", 0x480005c9, 0xb4000236, "e,f,g", 0 }, /* pfiadd.w fsrc1,fsrc2,fdest */ -{ "fisub.ss", 0x4800004d, 0xb40007b2, "e,f,g", 0 }, /* fisub.w fsrc1,fsrc2,fdest */ -{ "fisub.dd", 0x480001cd, 0xb4000632, "e,f,g", 0 }, /* fisub.w fsrc1,fsrc2,fdest */ -{ "pfisub.ss", 0x4800044d, 0xb40003b2, "e,f,g", 0 }, /* pfisub.w fsrc1,fsrc2,fdest */ -{ "pfisub.dd", 0x480005cd, 0xb4000232, "e,f,g", 0 }, /* pfisub.w fsrc1,fsrc2,fdest */ -{ "fzchkl", 0x48000057, 0xb40007a8, "e,f,g", 0 }, /* fzchkl fsrc1,fsrc2,fdest */ -{ "pfzchkl", 0x48000457, 0xb40003a8, "e,f,g", 0 }, /* pfzchkl fsrc1,fsrc2,fdest */ -{ "fzchks", 0x4800005f, 0xb40007a0, "e,f,g", 0 }, /* fzchks fsrc1,fsrc2,fdest */ -{ "pfzchks", 0x4800045f, 0xb40003a0, "e,f,g", 0 }, /* pfzchks fsrc1,fsrc2,fdest */ -{ "faddp", 0x48000050, 0xb40007af, "e,f,g", 0 }, /* faddp fsrc1,fsrc2,fdest */ -{ "pfaddp", 0x48000450, 0xb40003af, "e,f,g", 0 }, /* pfaddp fsrc1,fsrc2,fdest */ -{ "faddz", 0x48000051, 0xb40007ae, "e,f,g", 0 }, /* faddz fsrc1,fsrc2,fdest */ -{ "pfaddz", 0x48000451, 0xb40003ae, "e,f,g", 0 }, /* pfaddz fsrc1,fsrc2,fdest */ -{ "form", 0x4800005a, 0xb40007a5, "e,g", 0 }, /* form fsrc1,fdest */ -{ "pform", 0x4800045a, 0xb40003a5, "e,g", 0 }, /* pform fsrc1,fdest */ - -/* Floating point pseudo-instructions */ -{ "fmov.ss", 0x48000049, 0xb7e007b6, "e,g", 0 }, /* fiadd.ss fsrc1,f0,fdest */ -{ "fmov.dd", 0x480001c9, 0xb7e00636, "e,g", 0 }, /* fiadd.dd fsrc1,f0,fdest */ -{ "fmov.sd", 0x480000b0, 0xb7e0074f, "e,g", 0 }, /* fadd.sd fsrc1,f0,fdest */ -{ "fmov.ds", 0x48000130, 0xb7e006cf, "e,g", 0 }, /* fadd.ds fsrc1,f0,fdest */ -{ "pfmov.ds", 0x48000530, 0xb73002cf, "e,g", 0 }, /* pfadd.ds fsrc1,f0,fdest */ -{ "pfmov.dd", 0x480005c9, 0xb7e00236, "e,g", 0 }, /* pfiadd.dd fsrc1,f0,fdest */ - - -}; - -#define NUMOPCODES ((sizeof i860_opcodes)/(sizeof i860_opcodes[0])) - - diff --git a/include/i960-opcode.h b/include/i960-opcode.h deleted file mode 100755 index 6572f4e3988..00000000000 --- a/include/i960-opcode.h +++ /dev/null @@ -1,434 +0,0 @@ -/* Basic 80960 instruction formats. - * - * The 'COJ' instructions are actually COBR instructions with the 'b' in - * the mnemonic replaced by a 'j'; they are ALWAYS "de-optimized" if necessary: - * if the displacement will not fit in 13 bits, the assembler will replace them - * with the corresponding compare and branch instructions. - * - * All of the 'MEMn' instructions are the same format; the 'n' in the name - * indicates the default index scale factor (the size of the datum operated on). - * - * The FBRA formats are not actually an instruction format. They are the - * "convenience directives" for branching on floating-point comparisons, - * each of which generates 2 instructions (a 'bno' and one other branch). - * - * The CALLJ format is not actually an instruction format. It indicates that - * the instruction generated (a CTRL-format 'call') should have its relocation - * specially flagged for link-time replacement with a 'bal' or 'calls' if - * appropriate. - */ - -/* $Id$ */ - -#define CTRL 0 -#define COBR 1 -#define COJ 2 -#define REG 3 -#define MEM1 4 -#define MEM2 5 -#define MEM4 6 -#define MEM8 7 -#define MEM12 8 -#define MEM16 9 -#define FBRA 10 -#define CALLJ 11 - -/* Masks for the mode bits in REG format instructions */ -#define M1 0x0800 -#define M2 0x1000 -#define M3 0x2000 - -/* Generate the 12-bit opcode for a REG format instruction by placing the - * high 8 bits in instruction bits 24-31, the low 4 bits in instruction bits - * 7-10. - */ - -#define REG_OPC(opc) ((opc & 0xff0) << 20) | ((opc & 0xf) << 7) - -/* Generate a template for a REG format instruction: place the opcode bits - * in the appropriate fields and OR in mode bits for the operands that will not - * be used. I.e., - * set m1=1, if src1 will not be used - * set m2=1, if src2 will not be used - * set m3=1, if dst will not be used - * - * Setting the "unused" mode bits to 1 speeds up instruction execution(!). - * The information is also useful to us because some 1-operand REG instructions - * use the src1 field, others the dst field; and some 2-operand REG instructions - * use src1/src2, others src1/dst. The set mode bits enable us to distinguish. - */ -#define R_0(opc) ( REG_OPC(opc) | M1 | M2 | M3 ) /* No operands */ -#define R_1(opc) ( REG_OPC(opc) | M2 | M3 ) /* 1 operand: src1 */ -#define R_1D(opc) ( REG_OPC(opc) | M1 | M2 ) /* 1 operand: dst */ -#define R_2(opc) ( REG_OPC(opc) | M3 ) /* 2 ops: src1/src2 */ -#define R_2D(opc) ( REG_OPC(opc) | M2 ) /* 2 ops: src1/dst */ -#define R_3(opc) ( REG_OPC(opc) ) /* 3 operands */ - -/* DESCRIPTOR BYTES FOR REGISTER OPERANDS - * - * Interpret names as follows: - * R: global or local register only - * RS: global, local, or (if target allows) special-function register only - * RL: global or local register, or integer literal - * RSL: global, local, or (if target allows) special-function register; - * or integer literal - * F: global, local, or floating-point register - * FL: global, local, or floating-point register; or literal (including - * floating point) - * - * A number appended to a name indicates that registers must be aligned, - * as follows: - * 2: register number must be multiple of 2 - * 4: register number must be multiple of 4 - */ - -#define SFR 0x10 /* Mask for the "sfr-OK" bit */ -#define LIT 0x08 /* Mask for the "literal-OK" bit */ -#define FP 0x04 /* Mask for "floating-point-OK" bit */ - -/* This macro ors the bits together. Note that 'align' is a mask - * for the low 0, 1, or 2 bits of the register number, as appropriate. - */ -#define OP(align,lit,fp,sfr) ( align | lit | fp | sfr ) - -#define R OP( 0, 0, 0, 0 ) -#define RS OP( 0, 0, 0, SFR ) -#define RL OP( 0, LIT, 0, 0 ) -#define RSL OP( 0, LIT, 0, SFR ) -#define F OP( 0, 0, FP, 0 ) -#define FL OP( 0, LIT, FP, 0 ) -#define R2 OP( 1, 0, 0, 0 ) -#define RL2 OP( 1, LIT, 0, 0 ) -#define F2 OP( 1, 0, FP, 0 ) -#define FL2 OP( 1, LIT, FP, 0 ) -#define R4 OP( 3, 0, 0, 0 ) -#define RL4 OP( 3, LIT, 0, 0 ) -#define F4 OP( 3, 0, FP, 0 ) -#define FL4 OP( 3, LIT, FP, 0 ) - -#define M 0x7f /* Memory operand (MEMA & MEMB format instructions) */ - -/* Macros to extract info from the register operand descriptor byte 'od'. - */ -#define SFR_OK(od) (od & SFR) /* TRUE if sfr operand allowed */ -#define LIT_OK(od) (od & LIT) /* TRUE if literal operand allowed */ -#define FP_OK(od) (od & FP) /* TRUE if floating-point op allowed */ -#define REG_ALIGN(od,n) ((od & 0x3 & n) == 0) - /* TRUE if reg #n is properly aligned */ -#define MEMOP(od) (od == M) /* TRUE if operand is a memory operand*/ - -/* Description of a single i80960 instruction */ -struct i960_opcode { - long opcode; /* 32 bits, constant fields filled in, rest zeroed */ - char *name; /* Assembler mnemonic */ - short iclass; /* Class: see #defines below */ - char format; /* REG, COBR, CTRL, MEMn, COJ, FBRA, or CALLJ */ - char num_ops; /* Number of operands */ - char operand[3];/* Operand descriptors; same order as assembler instr */ -}; - -/* Classes of 960 intructions: - * - each instruction falls into one class. - * - each target architecture supports one or more classes. - * - * EACH CONSTANT MUST CONTAIN 1 AND ONLY 1 SET BIT!: see targ_has_iclass(). - */ -#define I_BASE 0x01 /* 80960 base instruction set */ -#define I_CX 0x02 /* 80960Cx instruction */ -#define I_DEC 0x04 /* Decimal instruction */ -#define I_FP 0x08 /* Floating point instruction */ -#define I_KX 0x10 /* 80960Kx instruction */ -#define I_MIL 0x20 /* Military instruction */ -#define I_CASIM 0x40 /* CA simulator instruction */ - -/****************************************************************************** - * - * TABLE OF i960 INSTRUCTION DESCRIPTIONS - * - ******************************************************************************/ - -const struct i960_opcode i960_opcodes[] = { - - /* if a CTRL instruction has an operand, it's always a displacement */ - - { 0x09000000, "callj", I_BASE, CALLJ, 1 },/*default=='call'*/ - { 0x08000000, "b", I_BASE, CTRL, 1 }, - { 0x09000000, "call", I_BASE, CTRL, 1 }, - { 0x0a000000, "ret", I_BASE, CTRL, 0 }, - { 0x0b000000, "bal", I_BASE, CTRL, 1 }, - { 0x10000000, "bno", I_BASE, CTRL, 1 }, - { 0x10000000, "bf", I_BASE, CTRL, 1 }, /* same as bno */ - { 0x10000000, "bru", I_BASE, CTRL, 1 }, /* same as bno */ - { 0x11000000, "bg", I_BASE, CTRL, 1 }, - { 0x11000000, "brg", I_BASE, CTRL, 1 }, /* same as bg */ - { 0x12000000, "be", I_BASE, CTRL, 1 }, - { 0x12000000, "bre", I_BASE, CTRL, 1 }, /* same as be */ - { 0x13000000, "bge", I_BASE, CTRL, 1 }, - { 0x13000000, "brge", I_BASE, CTRL, 1 }, /* same as bge */ - { 0x14000000, "bl", I_BASE, CTRL, 1 }, - { 0x14000000, "brl", I_BASE, CTRL, 1 }, /* same as bl */ - { 0x15000000, "bne", I_BASE, CTRL, 1 }, - { 0x15000000, "brlg", I_BASE, CTRL, 1 }, /* same as bne */ - { 0x16000000, "ble", I_BASE, CTRL, 1 }, - { 0x16000000, "brle", I_BASE, CTRL, 1 }, /* same as ble */ - { 0x17000000, "bo", I_BASE, CTRL, 1 }, - { 0x17000000, "bt", I_BASE, CTRL, 1 }, /* same as bo */ - { 0x17000000, "bro", I_BASE, CTRL, 1 }, /* same as bo */ - { 0x18000000, "faultno", I_BASE, CTRL, 0 }, - { 0x18000000, "faultf", I_BASE, CTRL, 0 }, /*same as faultno*/ - { 0x19000000, "faultg", I_BASE, CTRL, 0 }, - { 0x1a000000, "faulte", I_BASE, CTRL, 0 }, - { 0x1b000000, "faultge", I_BASE, CTRL, 0 }, - { 0x1c000000, "faultl", I_BASE, CTRL, 0 }, - { 0x1d000000, "faultne", I_BASE, CTRL, 0 }, - { 0x1e000000, "faultle", I_BASE, CTRL, 0 }, - { 0x1f000000, "faulto", I_BASE, CTRL, 0 }, - { 0x1f000000, "faultt", I_BASE, CTRL, 0 }, /* syn for faulto */ - - { 0x01000000, "syscall", I_CASIM,CTRL, 0 }, - - /* If a COBR (or COJ) has 3 operands, the last one is always a - * displacement and does not appear explicitly in the table. - */ - - { 0x20000000, "testno", I_BASE, COBR, 1, R }, - { 0x21000000, "testg", I_BASE, COBR, 1, R }, - { 0x22000000, "teste", I_BASE, COBR, 1, R }, - { 0x23000000, "testge", I_BASE, COBR, 1, R }, - { 0x24000000, "testl", I_BASE, COBR, 1, R }, - { 0x25000000, "testne", I_BASE, COBR, 1, R }, - { 0x26000000, "testle", I_BASE, COBR, 1, R }, - { 0x27000000, "testo", I_BASE, COBR, 1, R }, - { 0x30000000, "bbc", I_BASE, COBR, 3, RL, RS }, - { 0x31000000, "cmpobg", I_BASE, COBR, 3, RL, RS }, - { 0x32000000, "cmpobe", I_BASE, COBR, 3, RL, RS }, - { 0x33000000, "cmpobge", I_BASE, COBR, 3, RL, RS }, - { 0x34000000, "cmpobl", I_BASE, COBR, 3, RL, RS }, - { 0x35000000, "cmpobne", I_BASE, COBR, 3, RL, RS }, - { 0x36000000, "cmpoble", I_BASE, COBR, 3, RL, RS }, - { 0x37000000, "bbs", I_BASE, COBR, 3, RL, RS }, - { 0x38000000, "cmpibno", I_BASE, COBR, 3, RL, RS }, - { 0x39000000, "cmpibg", I_BASE, COBR, 3, RL, RS }, - { 0x3a000000, "cmpibe", I_BASE, COBR, 3, RL, RS }, - { 0x3b000000, "cmpibge", I_BASE, COBR, 3, RL, RS }, - { 0x3c000000, "cmpibl", I_BASE, COBR, 3, RL, RS }, - { 0x3d000000, "cmpibne", I_BASE, COBR, 3, RL, RS }, - { 0x3e000000, "cmpible", I_BASE, COBR, 3, RL, RS }, - { 0x3f000000, "cmpibo", I_BASE, COBR, 3, RL, RS }, - { 0x31000000, "cmpojg", I_BASE, COJ, 3, RL, RS }, - { 0x32000000, "cmpoje", I_BASE, COJ, 3, RL, RS }, - { 0x33000000, "cmpojge", I_BASE, COJ, 3, RL, RS }, - { 0x34000000, "cmpojl", I_BASE, COJ, 3, RL, RS }, - { 0x35000000, "cmpojne", I_BASE, COJ, 3, RL, RS }, - { 0x36000000, "cmpojle", I_BASE, COJ, 3, RL, RS }, - { 0x38000000, "cmpijno", I_BASE, COJ, 3, RL, RS }, - { 0x39000000, "cmpijg", I_BASE, COJ, 3, RL, RS }, - { 0x3a000000, "cmpije", I_BASE, COJ, 3, RL, RS }, - { 0x3b000000, "cmpijge", I_BASE, COJ, 3, RL, RS }, - { 0x3c000000, "cmpijl", I_BASE, COJ, 3, RL, RS }, - { 0x3d000000, "cmpijne", I_BASE, COJ, 3, RL, RS }, - { 0x3e000000, "cmpijle", I_BASE, COJ, 3, RL, RS }, - { 0x3f000000, "cmpijo", I_BASE, COJ, 3, RL, RS }, - - { 0x80000000, "ldob", I_BASE, MEM1, 2, M, R }, - { 0x82000000, "stob", I_BASE, MEM1, 2, R , M }, - { 0x84000000, "bx", I_BASE, MEM1, 1, M }, - { 0x85000000, "balx", I_BASE, MEM1, 2, M, R }, - { 0x86000000, "callx", I_BASE, MEM1, 1, M }, - { 0x88000000, "ldos", I_BASE, MEM2, 2, M, R }, - { 0x8a000000, "stos", I_BASE, MEM2, 2, R , M }, - { 0x8c000000, "lda", I_BASE, MEM1, 2, M, R }, - { 0x90000000, "ld", I_BASE, MEM4, 2, M, R }, - { 0x92000000, "st", I_BASE, MEM4, 2, R , M }, - { 0x98000000, "ldl", I_BASE, MEM8, 2, M, R2 }, - { 0x9a000000, "stl", I_BASE, MEM8, 2, R2 ,M }, - { 0xa0000000, "ldt", I_BASE, MEM12, 2, M, R4 }, - { 0xa2000000, "stt", I_BASE, MEM12, 2, R4 ,M }, - { 0xb0000000, "ldq", I_BASE, MEM16, 2, M, R4 }, - { 0xb2000000, "stq", I_BASE, MEM16, 2, R4 ,M }, - { 0xc0000000, "ldib", I_BASE, MEM1, 2, M, R }, - { 0xc2000000, "stib", I_BASE, MEM1, 2, R , M }, - { 0xc8000000, "ldis", I_BASE, MEM2, 2, M, R }, - { 0xca000000, "stis", I_BASE, MEM2, 2, R , M }, - - { R_3(0x580), "notbit", I_BASE, REG, 3, RSL,RSL,RS }, - { R_3(0x581), "and", I_BASE, REG, 3, RSL,RSL,RS }, - { R_3(0x582), "andnot", I_BASE, REG, 3, RSL,RSL,RS }, - { R_3(0x583), "setbit", I_BASE, REG, 3, RSL,RSL,RS }, - { R_3(0x584), "notand", I_BASE, REG, 3, RSL,RSL,RS }, - { R_3(0x586), "xor", I_BASE, REG, 3, RSL,RSL,RS }, - { R_3(0x587), "or", I_BASE, REG, 3, RSL,RSL,RS }, - { R_3(0x588), "nor", I_BASE, REG, 3, RSL,RSL,RS }, - { R_3(0x589), "xnor", I_BASE, REG, 3, RSL,RSL,RS }, - { R_2D(0x58a), "not", I_BASE, REG, 2, RSL,RS }, - { R_3(0x58b), "ornot", I_BASE, REG, 3, RSL,RSL,RS }, - { R_3(0x58c), "clrbit", I_BASE, REG, 3, RSL,RSL,RS }, - { R_3(0x58d), "notor", I_BASE, REG, 3, RSL,RSL,RS }, - { R_3(0x58e), "nand", I_BASE, REG, 3, RSL,RSL,RS }, - { R_3(0x58f), "alterbit", I_BASE, REG, 3, RSL,RSL,RS }, - { R_3(0x590), "addo", I_BASE, REG, 3, RSL,RSL,RS }, - { R_3(0x591), "addi", I_BASE, REG, 3, RSL,RSL,RS }, - { R_3(0x592), "subo", I_BASE, REG, 3, RSL,RSL,RS }, - { R_3(0x593), "subi", I_BASE, REG, 3, RSL,RSL,RS }, - { R_3(0x598), "shro", I_BASE, REG, 3, RSL,RSL,RS }, - { R_3(0x59a), "shrdi", I_BASE, REG, 3, RSL,RSL,RS }, - { R_3(0x59b), "shri", I_BASE, REG, 3, RSL,RSL,RS }, - { R_3(0x59c), "shlo", I_BASE, REG, 3, RSL,RSL,RS }, - { R_3(0x59d), "rotate", I_BASE, REG, 3, RSL,RSL,RS }, - { R_3(0x59e), "shli", I_BASE, REG, 3, RSL,RSL,RS }, - { R_2(0x5a0), "cmpo", I_BASE, REG, 2, RSL,RSL }, - { R_2(0x5a1), "cmpi", I_BASE, REG, 2, RSL,RSL }, - { R_2(0x5a2), "concmpo", I_BASE, REG, 2, RSL,RSL }, - { R_2(0x5a3), "concmpi", I_BASE, REG, 2, RSL,RSL }, - { R_3(0x5a4), "cmpinco", I_BASE, REG, 3, RSL,RSL,RS }, - { R_3(0x5a5), "cmpinci", I_BASE, REG, 3, RSL,RSL,RS }, - { R_3(0x5a6), "cmpdeco", I_BASE, REG, 3, RSL,RSL,RS }, - { R_3(0x5a7), "cmpdeci", I_BASE, REG, 3, RSL,RSL,RS }, - { R_2(0x5ac), "scanbyte", I_BASE, REG, 2, RSL,RSL }, - { R_2(0x5ae), "chkbit", I_BASE, REG, 2, RSL,RSL }, - { R_3(0x5b0), "addc", I_BASE, REG, 3, RSL,RSL,RS }, - { R_3(0x5b2), "subc", I_BASE, REG, 3, RSL,RSL,RS }, - { R_2D(0x5cc), "mov", I_BASE, REG, 2, RSL,RS }, - { R_2D(0x5dc), "movl", I_BASE, REG, 2, RL2,R2 }, - { R_2D(0x5ec), "movt", I_BASE, REG, 2, RL4,R4 }, - { R_2D(0x5fc), "movq", I_BASE, REG, 2, RL4,R4 }, - { R_3(0x610), "atmod", I_BASE, REG, 3, RS, RSL,R }, - { R_3(0x612), "atadd", I_BASE, REG, 3, RS, RSL,RS }, - { R_2D(0x640), "spanbit", I_BASE, REG, 2, RSL,RS }, - { R_2D(0x641), "scanbit", I_BASE, REG, 2, RSL,RS }, - { R_3(0x645), "modac", I_BASE, REG, 3, RSL,RSL,RS }, - { R_3(0x650), "modify", I_BASE, REG, 3, RSL,RSL,R }, - { R_3(0x651), "extract", I_BASE, REG, 3, RSL,RSL,R }, - { R_3(0x654), "modtc", I_BASE, REG, 3, RSL,RSL,RS }, - { R_3(0x655), "modpc", I_BASE, REG, 3, RSL,RSL,R }, - { R_1(0x660), "calls", I_BASE, REG, 1, RSL }, - { R_0(0x66b), "mark", I_BASE, REG, 0, }, - { R_0(0x66c), "fmark", I_BASE, REG, 0, }, - { R_0(0x66d), "flushreg", I_BASE, REG, 0, }, - { R_0(0x66f), "syncf", I_BASE, REG, 0, }, - { R_3(0x670), "emul", I_BASE, REG, 3, RSL,RSL,R2 }, - { R_3(0x671), "ediv", I_BASE, REG, 3, RSL,RL2,RS }, - { R_2D(0x672), "cvtadr", I_CASIM,REG, 2, RL, R2 }, - { R_3(0x701), "mulo", I_BASE, REG, 3, RSL,RSL,RS }, - { R_3(0x708), "remo", I_BASE, REG, 3, RSL,RSL,RS }, - { R_3(0x70b), "divo", I_BASE, REG, 3, RSL,RSL,RS }, - { R_3(0x741), "muli", I_BASE, REG, 3, RSL,RSL,RS }, - { R_3(0x748), "remi", I_BASE, REG, 3, RSL,RSL,RS }, - { R_3(0x749), "modi", I_BASE, REG, 3, RSL,RSL,RS }, - { R_3(0x74b), "divi", I_BASE, REG, 3, RSL,RSL,RS }, - - /* Floating-point instructions */ - - { R_2D(0x674), "cvtir", I_FP, REG, 2, RL, F }, - { R_2D(0x675), "cvtilr", I_FP, REG, 2, RL, F }, - { R_3(0x676), "scalerl", I_FP, REG, 3, RL, FL2,F2 }, - { R_3(0x677), "scaler", I_FP, REG, 3, RL, FL, F }, - { R_3(0x680), "atanr", I_FP, REG, 3, FL, FL, F }, - { R_3(0x681), "logepr", I_FP, REG, 3, FL, FL, F }, - { R_3(0x682), "logr", I_FP, REG, 3, FL, FL, F }, - { R_3(0x683), "remr", I_FP, REG, 3, FL, FL, F }, - { R_2(0x684), "cmpor", I_FP, REG, 2, FL, FL }, - { R_2(0x685), "cmpr", I_FP, REG, 2, FL, FL }, - { R_2D(0x688), "sqrtr", I_FP, REG, 2, FL, F }, - { R_2D(0x689), "expr", I_FP, REG, 2, FL, F }, - { R_2D(0x68a), "logbnr", I_FP, REG, 2, FL, F }, - { R_2D(0x68b), "roundr", I_FP, REG, 2, FL, F }, - { R_2D(0x68c), "sinr", I_FP, REG, 2, FL, F }, - { R_2D(0x68d), "cosr", I_FP, REG, 2, FL, F }, - { R_2D(0x68e), "tanr", I_FP, REG, 2, FL, F }, - { R_1(0x68f), "classr", I_FP, REG, 1, FL }, - { R_3(0x690), "atanrl", I_FP, REG, 3, FL2,FL2,F2 }, - { R_3(0x691), "logeprl", I_FP, REG, 3, FL2,FL2,F2 }, - { R_3(0x692), "logrl", I_FP, REG, 3, FL2,FL2,F2 }, - { R_3(0x693), "remrl", I_FP, REG, 3, FL2,FL2,F2 }, - { R_2(0x694), "cmporl", I_FP, REG, 2, FL2,FL2 }, - { R_2(0x695), "cmprl", I_FP, REG, 2, FL2,FL2 }, - { R_2D(0x698), "sqrtrl", I_FP, REG, 2, FL2,F2 }, - { R_2D(0x699), "exprl", I_FP, REG, 2, FL2,F2 }, - { R_2D(0x69a), "logbnrl", I_FP, REG, 2, FL2,F2 }, - { R_2D(0x69b), "roundrl", I_FP, REG, 2, FL2,F2 }, - { R_2D(0x69c), "sinrl", I_FP, REG, 2, FL2,F2 }, - { R_2D(0x69d), "cosrl", I_FP, REG, 2, FL2,F2 }, - { R_2D(0x69e), "tanrl", I_FP, REG, 2, FL2,F2 }, - { R_1(0x69f), "classrl", I_FP, REG, 1, FL2 }, - { R_2D(0x6c0), "cvtri", I_FP, REG, 2, FL, R }, - { R_2D(0x6c1), "cvtril", I_FP, REG, 2, FL, R2 }, - { R_2D(0x6c2), "cvtzri", I_FP, REG, 2, FL, R }, - { R_2D(0x6c3), "cvtzril", I_FP, REG, 2, FL, R2 }, - { R_2D(0x6c9), "movr", I_FP, REG, 2, FL, F }, - { R_2D(0x6d9), "movrl", I_FP, REG, 2, FL2,F2 }, - { R_2D(0x6e1), "movre", I_FP, REG, 2, FL4,F4 }, - { R_3(0x6e2), "cpysre", I_FP, REG, 3, FL4,FL4,F4 }, - { R_3(0x6e3), "cpyrsre", I_FP, REG, 3, FL4,FL4,F4 }, - { R_3(0x78b), "divr", I_FP, REG, 3, FL, FL, F }, - { R_3(0x78c), "mulr", I_FP, REG, 3, FL, FL, F }, - { R_3(0x78d), "subr", I_FP, REG, 3, FL, FL, F }, - { R_3(0x78f), "addr", I_FP, REG, 3, FL, FL, F }, - { R_3(0x79b), "divrl", I_FP, REG, 3, FL2,FL2,F2 }, - { R_3(0x79c), "mulrl", I_FP, REG, 3, FL2,FL2,F2 }, - { R_3(0x79d), "subrl", I_FP, REG, 3, FL2,FL2,F2 }, - { R_3(0x79f), "addrl", I_FP, REG, 3, FL2,FL2,F2 }, - - /* These are the floating point branch instructions. Each actually - * generates 2 branch instructions: the first a CTRL instruction with - * the indicated opcode, and the second a 'bno'. - */ - - { 0x12000000, "brue", I_FP, FBRA, 1 }, - { 0x11000000, "brug", I_FP, FBRA, 1 }, - { 0x13000000, "bruge", I_FP, FBRA, 1 }, - { 0x14000000, "brul", I_FP, FBRA, 1 }, - { 0x16000000, "brule", I_FP, FBRA, 1 }, - { 0x15000000, "brulg", I_FP, FBRA, 1 }, - - - /* Decimal instructions */ - - { R_3(0x642), "daddc", I_DEC, REG, 3, RSL,RSL,RS }, - { R_3(0x643), "dsubc", I_DEC, REG, 3, RSL,RSL,RS }, - { R_2D(0x644), "dmovt", I_DEC, REG, 2, RSL,RS }, - - - /* KX extensions */ - - { R_2(0x600), "synmov", I_KX, REG, 2, R, R }, - { R_2(0x601), "synmovl", I_KX, REG, 2, R, R }, - { R_2(0x602), "synmovq", I_KX, REG, 2, R, R }, - { R_2D(0x615), "synld", I_KX, REG, 2, R, R }, - - - /* MC extensions */ - - { R_3(0x603), "cmpstr", I_MIL, REG, 3, R, R, RL }, - { R_3(0x604), "movqstr", I_MIL, REG, 3, R, R, RL }, - { R_3(0x605), "movstr", I_MIL, REG, 3, R, R, RL }, - { R_2D(0x613), "inspacc", I_MIL, REG, 2, R, R }, - { R_2D(0x614), "ldphy", I_MIL, REG, 2, R, R }, - { R_3(0x617), "fill", I_MIL, REG, 3, R, RL, RL }, - { R_2D(0x646), "condrec", I_MIL, REG, 2, R, R }, - { R_2D(0x656), "receive", I_MIL, REG, 2, R, R }, - { R_3(0x662), "send", I_MIL, REG, 3, R, RL, R }, - { R_1(0x663), "sendserv", I_MIL, REG, 1, R }, - { R_1(0x664), "resumprcs", I_MIL, REG, 1, R }, - { R_1(0x665), "schedprcs", I_MIL, REG, 1, R }, - { R_0(0x666), "saveprcs", I_MIL, REG, 0, }, - { R_1(0x668), "condwait", I_MIL, REG, 1, R }, - { R_1(0x669), "wait", I_MIL, REG, 1, R }, - { R_1(0x66a), "signal", I_MIL, REG, 1, R }, - { R_1D(0x673), "ldtime", I_MIL, REG, 1, R2 }, - - - /* CX extensions */ - - { R_3(0x5d8), "eshro", I_CX, REG, 3, RSL,RSL,RS }, - { R_3(0x630), "sdma", I_CX, REG, 3, RSL,RSL,RL }, - { R_3(0x631), "udma", I_CX, REG, 0 }, - { R_3(0x659), "sysctl", I_CX, REG, 3, RSL,RSL,RL }, - - - /* END OF TABLE */ - - { 0, NULL, 0, 0 } -}; - - /* end of i960-opcode.h */ diff --git a/include/ieee.h b/include/ieee.h deleted file mode 100644 index 08ebd011667..00000000000 --- a/include/ieee.h +++ /dev/null @@ -1,128 +0,0 @@ -#define N_W_VARIABLES 8 -#define Module_Beginning 0xe0 - -typedef struct { - char *processor; - char *module_name; -} ieee_module_begin_type; - -#define Address_Descriptor 0xec -typedef struct { -bfd_vma number_of_bits_mau; - bfd_vma number_of_maus_in_address; - - unsigned char byte_order; -#define IEEE_LITTLE 0xcc -#define IEEE_BIG 0xcd -} ieee_address_descriptor_type; - -typedef union { - file_ptr offset[N_W_VARIABLES]; - struct { - file_ptr extension_record; - file_ptr environmental_record; - file_ptr section_part; - file_ptr external_part; - file_ptr debug_information_part; - file_ptr data_part; - file_ptr trailer_part; - file_ptr me_record; - } r; -} ieee_w_variable_type; - - - - - -typedef enum -{ - ieee_number_start_enum = 0x00, - ieee_number_end_enum=0x7f, - ieee_number_repeat_start_enum = 0x80, - ieee_number_repeat_end_enum = 0x88, - ieee_number_repeat_4_enum = 0x84, - ieee_number_repeat_3_enum = 0x83, - ieee_number_repeat_2_enum = 0x82, - ieee_number_repeat_1_enum = 0x81, - ieee_module_beginning_enum = 0xe0, - ieee_module_end_enum = 0xe1, - ieee_extension_length_1_enum = 0xde, - ieee_extension_length_2_enum = 0xdf, - ieee_section_type_enum = 0xe6, - ieee_section_alignment_enum = 0xe7, - ieee_external_symbol_enum = 0xe8, - ieee_attribute_record_enum = 0xf1c9, - ieee_comma = 0x90, - ieee_external_reference_enum = 0xe9, - ieee_set_current_section_enum = 0xe5, - ieee_address_descriptor_enum = 0xec, - ieee_load_constant_bytes_enum = 0xed, - ieee_load_with_relocation_enum = 0xe4, - - ieee_variable_A_enum = 0xc1, - ieee_variable_B_enum = 0xc2, - ieee_variable_C_enum = 0xc3, - ieee_variable_D_enum = 0xc4, - ieee_variable_E_enum = 0xc5, - ieee_variable_F_enum = 0xc6, - ieee_variable_G_enum = 0xc7, - ieee_variable_H_enum = 0xc8, - ieee_variable_I_enum = 0xc9, - ieee_variable_J_enum = 0xca, - ieee_variable_K_enum = 0xcb, - ieee_variable_L_enum = 0xcc, - ieee_variable_M_enum = 0xcd, - ieee_variable_N_enum = 0xce, - ieee_variable_O_enum = 0xcf, - ieee_variable_P_enum = 0xd0, - ieee_variable_Q_enum = 0xd1, - ieee_variable_R_enum = 0xd2, - ieee_variable_S_enum = 0xd3, - ieee_variable_T_enum = 0xd4, - ieee_variable_U_enum = 0xd5, - ieee_variable_V_enum = 0xd6, - ieee_variable_W_enum = 0xd7, - ieee_variable_X_enum = 0xd8, - ieee_variable_Y_enum = 0xd9, - ieee_variable_Z_enum = 0xda, - ieee_function_plus_enum = 0xa5, - ieee_function_minus_enum = 0xa6, - ieee_function_signed_open_b_enum = 0xba, - ieee_function_signed_close_b_enum = 0xbb, - - ieee_function_unsigned_open_b_enum = 0xbc, - ieee_function_unsigned_close_b_enum = 0xbd, - - ieee_function_either_open_b_enum = 0xbe, - ieee_function_either_close_b_enum = 0xbf, - ieee_record_seperator_enum = 0xdb, - - ieee_e2_first_byte_enum = 0xe2, - ieee_section_size_enum = 0xe2d3, - ieee_physical_region_size_enum = 0xe2c1, - ieee_region_base_address_enum = 0xe2c2, - ieee_mau_size_enum = 0xe2c6, - ieee_m_value_enum = 0xe2cd, - ieee_section_base_address_enum = 0xe2cc, - ieee_section_offset_enum = 0xe2d2, - ieee_value_starting_address_enum = 0xe2c7, - ieee_assign_value_to_variable_enum = 0xe2d7, - ieee_set_current_pc_enum = 0xe2d0, - ieee_value_record_enum = 0xe2c9, - ieee_weak_external_reference_enum= 0xf4, - -} ieee_record_enum_type; - - -typedef struct { - unsigned int section_index; - unsigned int section_type; - char *section_name; - unsigned int parent_section_index; - unsigned int sibling_section_index; - unsigned int context_index; -} ieee_section_type; -#define IEEE_REFERENCE_BASE 11 -#define IEEE_PUBLIC_BASE 32 -#define IEEE_SECTION_NUMBER_BASE 1 - diff --git a/include/internalcoff.h b/include/internalcoff.h deleted file mode 100755 index 879f20c5229..00000000000 --- a/include/internalcoff.h +++ /dev/null @@ -1,437 +0,0 @@ -/********************** FILE HEADER **********************/ -struct internal_filehdr -{ - unsigned short f_magic; /* magic number */ - unsigned short f_nscns; /* number of sections */ - long f_timdat; /* time & date stamp */ - long f_symptr; /* file pointer to symtab */ - long f_nsyms; /* number of symtab entries */ - unsigned short f_opthdr; /* sizeof(optional hdr) */ - unsigned short f_flags; /* flags */ -}; - -/* Bits for f_flags: - * F_RELFLG relocation info stripped from file - * F_EXEC file is executable (no unresolved external references) - * F_LNNO line numbers stripped from file - * F_LSYMS local symbols stripped from file - * F_AR16WR file is 16-bit little-endian - * F_AR32WR file is 32-bit little-endian - * F_AR32W file is 32-bit big-endian - * F_DYNLOAD rs/6000 aix: dynamically loadable w/imports & exports - * F_SHROBJ rs/6000 aix: file is a shared object - */ - -#define F_RELFLG (0x0001) -#define F_EXEC (0x0002) -#define F_LNNO (0x0004) -#define F_LSYMS (0x0008) -#define F_AR16WR (0x0080) -#define F_AR32WR (0x0100) -#define F_AR32W (0x0200) -#define F_DYNLOAD (0x1000) -#define F_SHROBJ (0x2000) - -/********************** AOUT "OPTIONAL HEADER" **********************/ -struct internal_aouthdr { - short magic; /* type of file */ - short vstamp; /* version stamp */ - unsigned long tsize; /* text size in bytes, padded to FW bdry*/ - unsigned long dsize; /* initialized data " " */ - unsigned long bsize; /* uninitialized data " " */ - unsigned long entry; /* entry pt. */ - unsigned long text_start; /* base of text used for this file */ - unsigned long data_start; /* base of data used for this file */ - - /* i960 stuff */ - unsigned long tagentries; /* number of tag entries to follow */ - - /* RS/6000 stuff */ - unsigned long o_toc; /* address of TOC */ - short o_snentry; /* section number for entry point */ - short o_sntext; /* section number for text */ - short o_sndata; /* section number for data */ - short o_sntoc; /* section number for toc */ - short o_snloader; /* section number for loader section */ - short o_snbss; /* section number for bss */ - short o_algntext; /* max alignment for text */ - short o_algndata; /* max alignment for data */ - short o_modtype; /* Module type field, 1R,RE,RO */ - unsigned long o_maxstack; /* max stack size allowed. */ -}; - -/********************** STORAGE CLASSES **********************/ - -#define C_EFCN -1 /* physical end of function */ -#define C_NULL 0 -#define C_AUTO 1 /* automatic variable */ -#define C_EXT 2 /* external symbol */ -#define C_STAT 3 /* static */ -#define C_REG 4 /* register variable */ -#define C_EXTDEF 5 /* external definition */ -#define C_LABEL 6 /* label */ -#define C_ULABEL 7 /* undefined label */ -#define C_MOS 8 /* member of structure */ -#define C_ARG 9 /* function argument */ -#define C_STRTAG 10 /* structure tag */ -#define C_MOU 11 /* member of union */ -#define C_UNTAG 12 /* union tag */ -#define C_TPDEF 13 /* type definition */ -#define C_USTATIC 14 /* undefined static */ -#define C_ENTAG 15 /* enumeration tag */ -#define C_MOE 16 /* member of enumeration */ -#define C_REGPARM 17 /* register parameter */ -#define C_FIELD 18 /* bit field */ -#define C_AUTOARG 19 /* auto argument */ -#define C_LASTENT 20 /* dummy entry (end of block) */ -#define C_BLOCK 100 /* ".bb" or ".eb" */ -#define C_FCN 101 /* ".bf" or ".ef" */ -#define C_EOS 102 /* end of structure */ -#define C_FILE 103 /* file name */ -#define C_LINE 104 /* line # reformatted as symbol table entry */ -#define C_ALIAS 105 /* duplicate tag */ -#define C_HIDDEN 106 /* ext symbol in dmert public lib */ - - /* New storage classes for 80960 */ - -/* C_LEAFPROC is obsolete. Use C_LEAFEXT or C_LEAFSTAT */ -#define C_LEAFPROC 108 /* Leaf procedure, "call" via BAL */ - -#define C_SCALL 107 /* Procedure reachable via system call */ -#define C_LEAFEXT 108 /* External leaf */ -#define C_LEAFSTAT 113 /* Static leaf */ -#define C_OPTVAR 109 /* Optimized variable */ -#define C_DEFINE 110 /* Preprocessor #define */ -#define C_PRAGMA 111 /* Advice to compiler or linker */ -#define C_SEGMENT 112 /* 80960 segment name */ - - /* New storage classes for RS/6000 */ -#define C_HIDEXT 107 /* Un-named external symbol */ -#define C_BINCL 108 /* Marks beginning of include file */ -#define C_EINCL 109 /* Marks ending of include file */ - - /* storage classes for stab symbols for RS/6000 */ -#define C_GSYM 0x80 -#define C_LSYM 0x81 -#define C_PSYM 0x82 -#define C_RSYM 0x83 -#define C_RPSYM 0x84 -#define C_STSYM 0x85 -#define C_TCSYM 0x86 -#define C_BCOMM 0x87 -#define C_ECOML 0x88 -#define C_ECOMM 0x89 -#define C_DECL 0x8c -#define C_ENTRY 0x8d -#define C_FUN 0x8e -#define C_BSTAT 0x8f -#define C_ESTAT 0x90 - -/********************** SECTION HEADER **********************/ -struct internal_scnhdr { - char s_name[8]; /* section name */ - long s_paddr; /* physical address, aliased s_nlib */ - long s_vaddr; /* virtual address */ - long s_size; /* section size */ - long s_scnptr; /* file ptr to raw data for section */ - long s_relptr; /* file ptr to relocation */ - long s_lnnoptr; /* file ptr to line numbers */ -#ifdef M88 - unsigned long s_nreloc; - unsigned long s_nlnno; -#else - unsigned short s_nreloc; /* number of relocation entries */ - unsigned short s_nlnno; /* number of line number entries*/ -#endif - long s_flags; /* flags */ -#ifdef I960 - long s_align; -#endif -}; - - -/* - * s_flags "type" - */ -#define STYP_REG (0x0000) /* "regular": allocated, relocated, loaded */ -#define STYP_DSECT (0x0001) /* "dummy": relocated only*/ -#define STYP_NOLOAD (0x0002) /* "noload": allocated, relocated, not loaded */ -#define STYP_GROUP (0x0004) /* "grouped": formed of input sections */ -#define STYP_PAD (0x0008) /* "padding": not allocated, not relocated, loaded */ -#define STYP_COPY (0x0010) /* "copy": for decision function used by field update; not allocated, not relocated, - loaded; reloc & lineno entries processed normally */ -#define STYP_TEXT (0x0020) /* section contains text only */ -#define S_SHRSEG (0x0020) /* In 3b Update files (output of ogen), sections which appear in SHARED segments of the Pfile - will have the S_SHRSEG flag set by ogen, to inform dufr that updating 1 copy of the proc. will - update all process invocations. */ -#define STYP_DATA (0x0040) /* section contains data only */ -#define STYP_BSS (0x0080) /* section contains bss only */ -#define S_NEWFCN (0x0100) /* In a minimal file or an update file, a new function (as compared with a replaced function) */ -#define STYP_INFO (0x0200) /* comment: not allocated not relocated, not loaded */ -#define STYP_OVER (0x0400) /* overlay: relocated not allocated or loaded */ -#define STYP_LIB (0x0800) /* for .lib: same as INFO */ -#define STYP_MERGE (0x2000) /* merge section -- combines with text, data or bss sections only */ -#define STYP_REVERSE_PAD (0x4000) /* section will be padded with no-op instructions wherever padding is necessary and there is a - word of contiguous bytes beginning on a word boundary. */ -/********************** 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 internal_lineno { - union { - long l_symndx; /* function name symbol index, iff l_lnno == 0*/ - long l_paddr; /* (physical) address of line number */ - } l_addr; - unsigned long l_lnno; /* line number */ -}; - - -/********************** SYMBOLS **********************/ - -#define SYMNMLEN 8 /* # characters in a symbol name */ -#define FILNMLEN 14 /* # characters in a file name */ -#define DIMNUM 4 /* # array dimensions in auxiliary entry */ - -struct internal_syment { - union { - char _n_name[SYMNMLEN]; /* old COFF version */ - struct { - long _n_zeroes; /* new == 0 */ - long _n_offset; /* offset into string table */ - } _n_n; - char *_n_nptr[2]; /* allows for overlaying */ - } _n; - long n_value; /* value of symbol */ - short n_scnum; /* section number */ - unsigned short n_flags; /* copy of flags from filhdr */ - unsigned short n_type; /* type and derived type */ -#if __STDC__ - signed -#endif - char n_sclass; /* storage class */ - char n_numaux; /* number of aux. entries */ -}; -#define n_name _n._n_name -#define n_zeroes _n._n_n._n_zeroes -#define n_offset _n._n_n._n_offset - - -/* Relocatable symbols have number of the section in which they are defined, - or one of the following: */ - -#define N_UNDEF ((short)0) /* undefined symbol */ -#define N_ABS ((short)-1) /* value of symbol is absolute */ -#define N_DEBUG ((short)-2) /* debugging symbol -- value is meaningless */ -#define N_TV ((short)-3) /* indicates symbol needs preload transfer vector */ -#define P_TV ((short)-4) /* indicates symbol needs postload transfer vector*/ - -/* - * Type of a symbol, in low N bits of the word - */ -#define T_NULL 0 -#define T_VOID 1 /* function argument (only used by compiler) */ -#define T_CHAR 2 /* character */ -#define T_SHORT 3 /* short integer */ -#define T_INT 4 /* integer */ -#define T_LONG 5 /* long integer */ -#define T_FLOAT 6 /* floating point */ -#define T_DOUBLE 7 /* double word */ -#define T_STRUCT 8 /* structure */ -#define T_UNION 9 /* union */ -#define T_ENUM 10 /* enumeration */ -#define T_MOE 11 /* member of enumeration*/ -#define T_UCHAR 12 /* unsigned character */ -#define T_USHORT 13 /* unsigned short */ -#define T_UINT 14 /* unsigned integer */ -#define T_ULONG 15 /* unsigned long */ -#define T_LNGDBL 16 /* long double */ - -/* - * derived types, in n_type -*/ -#define DT_NON (0) /* no derived type */ -#define DT_PTR (1) /* pointer */ -#define DT_FCN (2) /* function */ -#define DT_ARY (3) /* array */ - -#define BTYPE(x) ((x) & N_BTMASK) - -#define ISPTR(x) (((x) & N_TMASK) == (DT_PTR << N_BTSHFT)) -#define ISFCN(x) (((x) & N_TMASK) == (DT_FCN << N_BTSHFT)) -#define ISARY(x) (((x) & N_TMASK) == (DT_ARY << N_BTSHFT)) -#define ISTAG(x) ((x)==C_STRTAG||(x)==C_UNTAG||(x)==C_ENTAG) -#define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK)) - - -union internal_auxent -{ - struct { - - union { - long l; /* str, un, or enum tag indx */ - struct coff_ptr_struct *p; - } x_tagndx; - - union { - struct { - unsigned short x_lnno; /* declaration line number */ - unsigned short x_size; /* str/union/array size */ - } x_lnsz; - long x_fsize; /* size of function */ - } x_misc; - - union { - struct { /* if ISFCN, tag, or .bb */ - long x_lnnoptr; /* ptr to fcn line # */ - union { /* entry ndx past block end */ - long l; - struct coff_ptr_struct *p; - } x_endndx; - } x_fcn; - - struct { /* if ISARY, up to 4 dimen. */ - unsigned short x_dimen[DIMNUM]; - } x_ary; - } x_fcnary; - - unsigned short x_tvndx; /* tv index */ - } x_sym; - - union { - char x_fname[FILNMLEN]; - struct { - long x_zeroes; - long x_offset; - } x_n; - } x_file; - - struct { - long x_scnlen; /* section length */ - unsigned short x_nreloc; /* # relocation entries */ - unsigned short x_nlinno; /* # line numbers */ - } x_scn; - - struct { - long x_tvfill; /* tv fill value */ - unsigned short x_tvlen; /* length of .tv */ - unsigned short x_tvran[2]; /* tv range */ - } x_tv; /* info about .tv section (in auxent of symbol .tv)) */ - - /****************************************** - * RS/6000-specific auxent - last auxent for every external symbol - ******************************************/ - struct { - long x_scnlen; /* csect length */ - long x_parmhash; /* parm type hash index */ - unsigned short x_snhash; /* sect num with parm hash */ - unsigned char x_smtyp; /* symbol align and type */ - /* 0-4 - Log 2 of alignment */ - /* 5-7 - symbol type */ - unsigned char x_smclas; /* storage mapping class */ - long x_stab; /* dbx stab info index */ - unsigned short x_snstab; /* sect num with dbx stab */ - } x_csect; /* csect definition information */ - -/* x_smtyp values: */ - -#define SMTYP_ALIGN(x) ((x) >> 3) /* log2 of alignment */ -#define SMTYP_SMTYP(x) ((x) & 0x7) /* symbol type */ -/* Symbol type values: */ -#define XTY_ER 0 /* External reference */ -#define XTY_SD 1 /* Csect definition */ -#define XTY_LD 2 /* Label definition */ -#define XTY_CM 3 /* .BSS */ -#define XTY_EM 4 /* Error message */ -#define XTY_US 5 /* "Reserved for internal use" */ - -/* x_smclas values: */ - -#define XMC_PR 0 /* Read-only program code */ -#define XMC_RO 1 /* Read-only constant */ -#define XMC_DB 2 /* Read-only debug dictionary table */ -#define XMC_TC 3 /* Read-write general TOC entry */ -#define XMC_UA 4 /* Read-write unclassified */ -#define XMC_RW 5 /* Read-write data */ -#define XMC_GL 6 /* Read-only global linkage */ -#define XMC_XO 7 /* Read-only extended operation (simulated insn) */ -#define XMC_SV 8 /* Read-only supervisor call */ -#define XMC_BS 9 /* Read-write BSS */ -#define XMC_DS 10 /* Read-write descriptor csect */ -#define XMC_UC 11 /* Read-write unnamed Fortran common */ -#define XMC_TI 12 /* Read-only traceback index csect */ -#define XMC_TB 13 /* Read-only traceback table csect */ -/* 14 ??? */ -#define XMC_TC0 15 /* Read-write TOC anchor for TOC addressability */ - - - /****************************************** - * I960-specific *2nd* aux. entry formats - ******************************************/ - struct { - /* This is a very old typo that keeps getting propagated. */ -#define x_stdindx x_stindx - long x_stindx; /* sys. table entry */ - } x_sc; /* system call entry */ - - struct { - unsigned long x_balntry; /* BAL entry point */ - } x_bal; /* BAL-callable function */ - - struct { - unsigned long x_timestamp; /* time stamp */ - char x_idstring[20]; /* producer identity string */ - } x_ident; /* Producer ident info */ - -}; - -/********************** RELOCATION DIRECTIVES **********************/ - -struct internal_reloc { - long r_vaddr; /* Virtual address of reference */ - long r_symndx; /* Index into symbol table */ - unsigned short r_type; /* Relocation type */ - -#if RS6000COFF_C - unsigned char r_size; -#endif - -#if M88 - unsigned short r_offset; -#endif -}; - -#define R_RELBYTE 017 -#define R_RELWORD 020 -#define R_PCRBYTE 022 -#define R_PCRWORD 023 -#define R_PCRLONG 024 - -#define R_DIR32 06 -#define R_PCLONG 020 -#define R_RELBYTE 017 -#define R_RELWORD 020 - -#define R_PCRBYTE 022 -#define R_PCRWORD 023 -#define R_PCRLONG 024 - -#define R_PCR16L 128 -#define R_PCR26L 129 -#define R_VRT16 130 -#define R_HVRT16 131 -#define R_LVRT16 132 -#define R_VRT32 133 -#define R_RELLONG (0x11) /* Direct 32-bit relocation */ -#define R_IPRSHORT (0x18) -#define R_IPRMED (0x19) /* 24-bit ip-relative relocation */ -#define R_IPRLONG (0x1a) -#define R_OPTCALL (0x1b) /* 32-bit optimizable call (leafproc/sysproc) */ -#define R_OPTCALLX (0x1c) /* 64-bit optimizable call (leafproc/sysproc) */ -#define R_GETSEG (0x1d) -#define R_GETPA (0x1e) -#define R_TAGWORD (0x1f) -#define R_JUMPTARG 0x20 /* strange 29k 00xx00xx reloc */ diff --git a/include/m68k-opcode.h b/include/m68k-opcode.h deleted file mode 100755 index c61bea76b8f..00000000000 --- a/include/m68k-opcode.h +++ /dev/null @@ -1,1996 +0,0 @@ -/* Opcode table for m680[01234]0/m6888[12]/m68851. - Copyright (C) 1989, 1991 Free Software Foundation. - -This file is part of GDB, the GNU Debugger and GAS, the GNU Assembler. - -Both GDB and GAS are free software; you can redistribute and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 1, or (at your option) -any later version. - -GDB and GAS are 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 GDB or GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* These are used as bit flags for arch below. */ - -enum m68k_architecture { - m68000 = 0x01, - m68008 = m68000, /* synonym for -m68000. otherwise unused. */ - m68010 = 0x02, - m68020 = 0x04, - m68030 = 0x08, - m68040 = 0x10, - m68881 = 0x20, - m68882 = m68881, /* synonym for -m68881. otherwise unused. */ - m68851 = 0x40, - - /* handy aliases */ - m68040up = m68040, - m68030up = (m68030 | m68040up), - m68020up = (m68020 | m68030up), - m68010up = (m68010 | m68020up), - m68000up = (m68000 | m68010up), - - mfloat = (m68881 | m68882 | m68040), - mmmu = (m68851 | m68030 | m68040), -}; /* enum m68k_architecture */ - - /* note that differences in addressing modes that aren't distinguished - in the following table are handled explicitly by gas. */ - -struct m68k_opcode { - char *name; - unsigned long opcode; - unsigned long match; - char *args; - enum m68k_architecture arch; -}; - -/* We store four bytes of opcode for all opcodes because that - is the most any of them need. The actual length of an instruction - is always at least 2 bytes, and is as much longer as necessary to - hold the operands it has. - - The match component is a mask saying which bits must match - particular opcode in order for an instruction to be an instance - of that opcode. - - The args component is a string containing two characters - for each operand of the instruction. The first specifies - the kind of operand; the second, the place it is stored. */ - -/* Kinds of operands: - D data register only. Stored as 3 bits. - A address register only. Stored as 3 bits. - a address register indirect only. Stored as 3 bits. - R either kind of register. Stored as 4 bits. - F floating point coprocessor register only. Stored as 3 bits. - O an offset (or width): immediate data 0-31 or data register. - Stored as 6 bits in special format for BF... insns. - + autoincrement only. Stored as 3 bits (number of the address register). - - autodecrement only. Stored as 3 bits (number of the address register). - Q quick immediate data. Stored as 3 bits. - This matches an immediate operand only when value is in range 1 .. 8. - M moveq immediate data. Stored as 8 bits. - This matches an immediate operand only when value is in range -128..127 - T trap vector immediate data. Stored as 4 bits. - - k K-factor for fmove.p instruction. Stored as a 7-bit constant or - a three bit register offset, depending on the field type. - - # immediate data. Stored in special places (b, w or l) - which say how many bits to store. - ^ immediate data for floating point instructions. Special places - are offset by 2 bytes from '#'... - B pc-relative address, converted to an offset - that is treated as immediate data. - d displacement and register. Stores the register as 3 bits - and stores the displacement in the entire second word. - - C the CCR. No need to store it; this is just for filtering validity. - S the SR. No need to store, just as with CCR. - U the USP. No need to store, just as with CCR. - - I Coprocessor ID. Not printed if 1. The Coprocessor ID is always - extracted from the 'd' field of word one, which means that an extended - coprocessor opcode can be skipped using the 'i' place, if needed. - - s System Control register for the floating point coprocessor. - S List of system control registers for floating point coprocessor. - - J Misc register for movec instruction, stored in 'j' format. - Possible values: - 0x000 SFC Source Function Code reg [40, 30, 20, 10] - 0x001 DFC Data Function Code reg [40, 30, 20, 10] - 0x002 CACR Cache Control Register [40, 30, 20] - 0x800 USP User Stack Pointer [40, 30, 20, 10] - 0x801 VBR Vector Base reg [40, 30, 20, 10] - 0x802 CAAR Cache Address Register [ 30, 20] - 0x803 MSP Master Stack Pointer [40, 30, 20] - 0x804 ISP Interrupt Stack Pointer [40, 30, 20] - 0x003 TC MMU Translation Control [40] - 0x004 ITT0 Instruction Transparent - Translation reg 0 [40] - 0x005 ITT1 Instruction Transparent - Translation reg 1 [40] - 0x006 DTT0 Data Transparent - Translation reg 0 [40] - 0x007 DTT1 Data Transparent - Translation reg 1 [40] - 0x805 MMUSR MMU Status reg [40] - 0x806 URP User Root Pointer [40] - 0x807 SRP Supervisor Root Pointer [40] - - L Register list of the type d0-d7/a0-a7 etc. - (New! Improved! Can also hold fp0-fp7, as well!) - The assembler tries to see if the registers match the insn by - looking at where the insn wants them stored. - - l Register list like L, but with all the bits reversed. - Used for going the other way. . . - - c cache identifier which may be "nc" for no cache, "ic" - for instruction cache, "dc" for data cache, or "bc" - for both caches. Used in cinv and cpush. Always - stored in position "d". - - They are all stored as 6 bits using an address mode and a register number; - they differ in which addressing modes they match. - - * all (modes 0-6,7.*) - ~ alterable memory (modes 2-6,7.0,7.1)(not 0,1,7.~) - % alterable (modes 0-6,7.0,7.1)(not 7.~) - ; data (modes 0,2-6,7.*)(not 1) - @ data, but not immediate (modes 0,2-6,7.? ? ?)(not 1,7.?) This may really be ;, the 68020 book says it is - ! control (modes 2,5,6,7.*-)(not 0,1,3,4,7.4) - & alterable control (modes 2,5,6,7.0,7.1)(not 0,1,7.? ? ?) - $ alterable data (modes 0,2-6,7.0,7.1)(not 1,7.~) - ? alterable control, or data register (modes 0,2,5,6,7.0,7.1)(not 1,3,4,7.~) - / control, or data register (modes 0,2,5,6,7.0,7.1,7.2,7.3)(not 1,3,4,7.4) -*/ - -/* JF: for the 68851 */ -/* - I didn't use much imagination in choosing the - following codes, so many of them aren't very - mnemonic. -rab - - P pmmu register - Possible values: - 000 TC Translation Control reg - 100 CAL Current Access Level - 101 VAL Validate Access Level - 110 SCC Stack Change Control - 111 AC Access Control - - W wide pmmu registers - Possible values: - 001 DRP Dma Root Pointer - 010 SRP Supervisor Root Pointer - 011 CRP Cpu Root Pointer - - f function code register - 0 SFC - 1 DFC - - V VAL register only - - X BADx, BACx - 100 BAD Breakpoint Acknowledge Data - 101 BAC Breakpoint Acknowledge Control - - Y PSR - Z PCSR - - | memory (modes 2-6, 7.*) - -*/ - -/* Places to put an operand, for non-general operands: - s source, low bits of first word. - d dest, shifted 9 in first word - 1 second word, shifted 12 - 2 second word, shifted 6 - 3 second word, shifted 0 - 4 third word, shifted 12 - 5 third word, shifted 6 - 6 third word, shifted 0 - 7 second word, shifted 7 - 8 second word, shifted 10 - D store in both place 1 and place 3; for divul and divsl. - B first word, low byte, for branch displacements - W second word (entire), for branch displacements - L second and third words (entire), for branch displacements (also overloaded for move16) - b second word, low byte - w second word (entire) [variable word/long branch offset for dbra] - l second and third word (entire) - g variable branch offset for bra and similar instructions. - The place to store depends on the magnitude of offset. - t store in both place 7 and place 8; for floating point operations - c branch offset for cpBcc operations. - The place to store is word two if bit six of word one is zero, - and words two and three if bit six of word one is one. - i Increment by two, to skip over coprocessor extended operands. Only - works with the 'I' format. - k Dynamic K-factor field. Bits 6-4 of word 2, used as a register number. - Also used for dynamic fmovem instruction. - C floating point coprocessor constant - 7 bits. Also used for static - K-factors... - j Movec register #, stored in 12 low bits of second word. - - Places to put operand, for general operands: - d destination, shifted 6 bits in first word - b source, at low bit of first word, and immediate uses one byte - w source, at low bit of first word, and immediate uses two bytes - l source, at low bit of first word, and immediate uses four bytes - s source, at low bit of first word. - Used sometimes in contexts where immediate is not allowed anyway. - f single precision float, low bit of 1st word, immediate uses 4 bytes - F double precision float, low bit of 1st word, immediate uses 8 bytes - x extended precision float, low bit of 1st word, immediate uses 12 bytes - p packed float, low bit of 1st word, immediate uses 12 bytes -*/ - -#define one(x) ((x) << 16) -#define two(x, y) (((x) << 16) + y) - -/* - *** DANGER WILL ROBINSON *** - - The assembler requires that all instances of the same mnemonic must be - consecutive. If they aren't, the assembler will bomb at runtime - */ -struct m68k_opcode m68k_opcodes[] = -{ -{"abcd", one(0140400), one(0170770), "DsDd", m68000up }, -{"abcd", one(0140410), one(0170770), "-s-d", m68000up }, - - /* Add instructions */ -{"addal", one(0150700), one(0170700), "*lAd", m68000up }, -{"addaw", one(0150300), one(0170700), "*wAd", m68000up }, -{"addib", one(0003000), one(0177700), "#b$b", m68000up }, -{"addil", one(0003200), one(0177700), "#l$l", m68000up }, -{"addiw", one(0003100), one(0177700), "#w$w", m68000up }, -{"addqb", one(0050000), one(0170700), "Qd$b", m68000up }, -{"addql", one(0050200), one(0170700), "Qd%l", m68000up }, -{"addqw", one(0050100), one(0170700), "Qd%w", m68000up }, - -{"addb", one(0050000), one(0170700), "Qd$b", m68000up }, /* addq written as add */ -{"addb", one(0003000), one(0177700), "#b$b", m68000up }, /* addi written as add */ -{"addb", one(0150000), one(0170700), ";bDd", m68000up }, /* addb , Dd */ -{"addb", one(0150400), one(0170700), "Dd~b", m68000up }, /* addb Dd, */ - -{"addw", one(0050100), one(0170700), "Qd%w", m68000up }, /* addq written as add */ -{"addw", one(0003100), one(0177700), "#w$w", m68000up }, /* addi written as add */ -{"addw", one(0150300), one(0170700), "*wAd", m68000up }, /* adda written as add */ -{"addw", one(0150100), one(0170700), "*wDd", m68000up }, /* addw , Dd */ -{"addw", one(0150500), one(0170700), "Dd~w", m68000up }, /* addw Dd, */ - -{"addl", one(0050200), one(0170700), "Qd%l", m68000up }, /* addq written as add */ -{"addl", one(0003200), one(0177700), "#l$l", m68000up }, /* addi written as add */ -{"addl", one(0150700), one(0170700), "*lAd", m68000up }, /* adda written as add */ -{"addl", one(0150200), one(0170700), "*lDd", m68000up }, /* addl , Dd */ -{"addl", one(0150600), one(0170700), "Dd~l", m68000up }, /* addl Dd, */ - -{"addxb", one(0150400), one(0170770), "DsDd", m68000up }, -{"addxb", one(0150410), one(0170770), "-s-d", m68000up }, -{"addxl", one(0150600), one(0170770), "DsDd", m68000up }, -{"addxl", one(0150610), one(0170770), "-s-d", m68000up }, -{"addxw", one(0150500), one(0170770), "DsDd", m68000up }, -{"addxw", one(0150510), one(0170770), "-s-d", m68000up }, - -{"andib", one(0001000), one(0177700), "#b$b", m68000up }, -{"andib", one(0001074), one(0177777), "#bCb", m68000up }, /* andi to ccr */ -{"andiw", one(0001100), one(0177700), "#w$w", m68000up }, -{"andiw", one(0001174), one(0177777), "#wSw", m68000up }, /* andi to sr */ -{"andil", one(0001200), one(0177700), "#l$l", m68000up }, - -{"andb", one(0001000), one(0177700), "#b$b", m68000up }, /* andi written as or */ -{"andb", one(0001074), one(0177777), "#bCb", m68000up }, /* andi to ccr */ -{"andb", one(0140000), one(0170700), ";bDd", m68000up }, /* memory to register */ -{"andb", one(0140400), one(0170700), "Dd~b", m68000up }, /* register to memory */ -{"andw", one(0001100), one(0177700), "#w$w", m68000up }, /* andi written as or */ -{"andw", one(0001174), one(0177777), "#wSw", m68000up }, /* andi to sr */ -{"andw", one(0140100), one(0170700), ";wDd", m68000up }, /* memory to register */ -{"andw", one(0140500), one(0170700), "Dd~w", m68000up }, /* register to memory */ -{"andl", one(0001200), one(0177700), "#l$l", m68000up }, /* andi written as or */ -{"andl", one(0140200), one(0170700), ";lDd", m68000up }, /* memory to register */ -{"andl", one(0140600), one(0170700), "Dd~l", m68000up }, /* register to memory */ - -{"aslb", one(0160400), one(0170770), "QdDs", m68000up }, -{"aslb", one(0160440), one(0170770), "DdDs", m68000up }, -{"asll", one(0160600), one(0170770), "QdDs", m68000up }, -{"asll", one(0160640), one(0170770), "DdDs", m68000up }, -{"aslw", one(0160500), one(0170770), "QdDs", m68000up }, -{"aslw", one(0160540), one(0170770), "DdDs", m68000up }, -{"aslw", one(0160700), one(0177700), "~s", m68000up }, /* Shift memory */ -{"asrb", one(0160000), one(0170770), "QdDs", m68000up }, -{"asrb", one(0160040), one(0170770), "DdDs", m68000up }, -{"asrl", one(0160200), one(0170770), "QdDs", m68000up }, -{"asrl", one(0160240), one(0170770), "DdDs", m68000up }, -{"asrw", one(0160100), one(0170770), "QdDs", m68000up }, -{"asrw", one(0160140), one(0170770), "DdDs", m68000up }, -{"asrw", one(0160300), one(0177700), "~s", m68000up }, /* Shift memory */ - -/* Fixed-size branches with 16-bit offsets */ - -{"bhi", one(0061000), one(0177777), "BW", m68000up }, -{"bls", one(0061400), one(0177777), "BW", m68000up }, -{"bcc", one(0062000), one(0177777), "BW", m68000up }, -{"jfnlt", one(0062000), one(0177777), "BW", m68000up }, /* apparently a sun alias */ -{"bcs", one(0062400), one(0177777), "BW", m68000up }, -{"bne", one(0063000), one(0177777), "BW", m68000up }, -{"beq", one(0063400), one(0177777), "BW", m68000up }, -{"bvc", one(0064000), one(0177777), "BW", m68000up }, -{"bvs", one(0064400), one(0177777), "BW", m68000up }, -{"bpl", one(0065000), one(0177777), "BW", m68000up }, -{"bmi", one(0065400), one(0177777), "BW", m68000up }, -{"bge", one(0066000), one(0177777), "BW", m68000up }, -{"blt", one(0066400), one(0177777), "BW", m68000up }, -{"bgt", one(0067000), one(0177777), "BW", m68000up }, -{"ble", one(0067400), one(0177777), "BW", m68000up }, -{"jfngt", one(0067400), one(0177777), "BW", m68000up }, /* apparently a sun alias */ -{"bra", one(0060000), one(0177777), "BW", m68000up }, -{"bsr", one(0060400), one(0177777), "BW", m68000up }, - -/* Fixed-size branches with short (byte) offsets */ - -{"bhis", one(0061000), one(0177400), "BB", m68000up }, -{"blss", one(0061400), one(0177400), "BB", m68000up }, -{"bccs", one(0062000), one(0177400), "BB", m68000up }, -{"bcss", one(0062400), one(0177400), "BB", m68000up }, -{"bnes", one(0063000), one(0177400), "BB", m68000up }, -{"beqs", one(0063400), one(0177400), "BB", m68000up }, -{"jfeq", one(0063400), one(0177400), "BB", m68000up }, /* apparently a sun alias */ -{"bvcs", one(0064000), one(0177400), "BB", m68000up }, -{"bvss", one(0064400), one(0177400), "BB", m68000up }, -{"bpls", one(0065000), one(0177400), "BB", m68000up }, -{"bmis", one(0065400), one(0177400), "BB", m68000up }, -{"bges", one(0066000), one(0177400), "BB", m68000up }, -{"blts", one(0066400), one(0177400), "BB", m68000up }, -{"bgts", one(0067000), one(0177400), "BB", m68000up }, -{"bles", one(0067400), one(0177400), "BB", m68000up }, -{"bras", one(0060000), one(0177400), "BB", m68000up }, -{"bsrs", one(0060400), one(0177400), "BB", m68000up }, - -/* Fixed-size branches with long (32-bit) offsets */ - -{"bhil", one(0061377), one(0177777), "BL", m68020up }, -{"blsl", one(0061777), one(0177777), "BL", m68020up }, -{"bccl", one(0062377), one(0177777), "BL", m68020up }, -{"bcsl", one(0062777), one(0177777), "BL", m68020up }, -{"bnel", one(0063377), one(0177777), "BL", m68020up }, -{"beql", one(0063777), one(0177777), "BL", m68020up }, -{"bvcl", one(0064377), one(0177777), "BL", m68020up }, -{"bvsl", one(0064777), one(0177777), "BL", m68020up }, -{"bpll", one(0065377), one(0177777), "BL", m68020up }, -{"bmil", one(0065777), one(0177777), "BL", m68020up }, -{"bgel", one(0066377), one(0177777), "BL", m68020up }, -{"bltl", one(0066777), one(0177777), "BL", m68020up }, -{"bgtl", one(0067377), one(0177777), "BL", m68020up }, -{"blel", one(0067777), one(0177777), "BL", m68020up }, -{"bral", one(0060377), one(0177777), "BL", m68020up }, -{"bsrl", one(0060777), one(0177777), "BL", m68020up }, - -/* We now return you to our regularly scheduled instruction set */ - -{"bchg", one(0000500), one(0170700), "Dd$s", m68000up }, -{"bchg", one(0004100), one(0177700), "#b$s", m68000up }, -{"bclr", one(0000600), one(0170700), "Dd$s", m68000up }, -{"bclr", one(0004200), one(0177700), "#b$s", m68000up }, - -{"bfchg", two(0165300, 0), two(0177700, 0170000), "?sO2O3", m68020up }, -{"bfclr", two(0166300, 0), two(0177700, 0170000), "?sO2O3", m68020up }, -{"bfexts", two(0165700, 0), two(0177700, 0100000), "/sO2O3D1", m68020up }, -{"bfextu", two(0164700, 0), two(0177700, 0100000), "/sO2O3D1", m68020up }, -{"bfffo", two(0166700, 0), two(0177700, 0100000), "/sO2O3D1", m68020up }, -{"bfins", two(0167700, 0), two(0177700, 0100000), "D1?sO2O3", m68020up }, -{"bfset", two(0167300, 0), two(0177700, 0170000), "?sO2O3", m68020up }, -{"bftst", two(0164300, 0), two(0177700, 0170000), "/sO2O3", m68020up }, -{"bkpt", one(0044110), one(0177770), "Qs", m68020up }, - -{"bset", one(0000700), one(0170700), "Dd$s", m68000up }, -{"bset", one(0004300), one(0177700), "#b$s", m68000up }, -{"btst", one(0000400), one(0170700), "Dd@s", m68000up }, -{"btst", one(0004000), one(0177700), "#b@s", m68000up }, - - -{"callm", one(0003300), one(0177700), "#b!s", m68020 }, - -{"cas2l", two(0007374, 0), two(0177777, 0107070), "D3D6D2D5R1R4", m68020up }, /* JF FOO really a 3 word ins */ -{"cas2w", two(0006374, 0), two(0177777, 0107070), "D3D6D2D5R1R4", m68020up }, /* JF ditto */ -{"casb", two(0005300, 0), two(0177700, 0177070), "D3D2~s", m68020up }, -{"casl", two(0007300, 0), two(0177700, 0177070), "D3D2~s", m68020up }, -{"casw", two(0006300, 0), two(0177700, 0177070), "D3D2~s", m68020up }, - -/* {"chk", one(0040600), one(0170700), ";wDd"}, JF FOO this looks wrong */ -{"chk2b", two(0000300, 0004000), two(0177700, 07777), "!sR1", m68020up }, -{"chk2l", two(0002300, 0004000), two(0177700, 07777), "!sR1", m68020up }, -{"chk2w", two(0001300, 0004000), two(0177700, 07777), "!sR1", m68020up }, -{"chkl", one(0040400), one(0170700), ";lDd", m68000up }, -{"chkw", one(0040600), one(0170700), ";wDd", m68000up }, - -#define SCOPE_LINE (0x1 << 3) -#define SCOPE_PAGE (0x2 << 3) -#define SCOPE_ALL (0x3 << 3) - -{"cinva", one(0xf400|SCOPE_ALL), one(0xff20), "ce", m68040 }, -{"cinvl", one(0xf400|SCOPE_LINE), one(0xff20), "ceas", m68040 }, -{"cinvp", one(0xf400|SCOPE_PAGE), one(0xff20), "ceas", m68040 }, - -{"cpusha", one(0xf420|SCOPE_ALL), one(0xff20), "ce", m68040 }, -{"cpushl", one(0xf420|SCOPE_LINE), one(0xff20), "ceas", m68040 }, -{"cpushp", one(0xf420|SCOPE_PAGE), one(0xff20), "ceas", m68040 }, - -#undef SCOPE_LINE -#undef SCOPE_PAGE -#undef SCOPE_ALL - -{"clrb", one(0041000), one(0177700), "$s", m68000up }, -{"clrl", one(0041200), one(0177700), "$s", m68000up }, -{"clrw", one(0041100), one(0177700), "$s", m68000up }, - -{"cmp2b", two(0000300, 0), two(0177700, 07777), "!sR1", m68020up }, -{"cmp2l", two(0002300, 0), two(0177700, 07777), "!sR1", m68020up }, -{"cmp2w", two(0001300, 0), two(0177700, 07777), "!sR1", m68020up }, -{"cmpal", one(0130700), one(0170700), "*lAd", m68000up }, -{"cmpaw", one(0130300), one(0170700), "*wAd", m68000up }, -{"cmpib", one(0006000), one(0177700), "#b;b", m68000up }, -{"cmpil", one(0006200), one(0177700), "#l;l", m68000up }, -{"cmpiw", one(0006100), one(0177700), "#w;w", m68000up }, -{"cmpb", one(0006000), one(0177700), "#b;b", m68000up }, /* cmpi written as cmp */ -{"cmpb", one(0130000), one(0170700), ";bDd", m68000up }, -{"cmpw", one(0006100), one(0177700), "#w;w", m68000up }, -{"cmpw", one(0130100), one(0170700), "*wDd", m68000up }, -{"cmpw", one(0130300), one(0170700), "*wAd", m68000up }, /* cmpa written as cmp */ -{"cmpl", one(0006200), one(0177700), "#l;l", m68000up }, -{"cmpl", one(0130200), one(0170700), "*lDd", m68000up }, -{"cmpl", one(0130700), one(0170700), "*lAd", m68000up }, -{"cmpmb", one(0130410), one(0170770), "+s+d", m68000up }, -{"cmpml", one(0130610), one(0170770), "+s+d", m68000up }, -{"cmpmw", one(0130510), one(0170770), "+s+d", m68000up }, - -{"dbcc", one(0052310), one(0177770), "DsBw", m68000up }, -{"dbcs", one(0052710), one(0177770), "DsBw", m68000up }, -{"dbeq", one(0053710), one(0177770), "DsBw", m68000up }, -{"dbf", one(0050710), one(0177770), "DsBw", m68000up }, -{"dbge", one(0056310), one(0177770), "DsBw", m68000up }, -{"dbgt", one(0057310), one(0177770), "DsBw", m68000up }, -{"dbhi", one(0051310), one(0177770), "DsBw", m68000up }, -{"dble", one(0057710), one(0177770), "DsBw", m68000up }, -{"dbls", one(0051710), one(0177770), "DsBw", m68000up }, -{"dblt", one(0056710), one(0177770), "DsBw", m68000up }, -{"dbmi", one(0055710), one(0177770), "DsBw", m68000up }, -{"dbne", one(0053310), one(0177770), "DsBw", m68000up }, -{"dbpl", one(0055310), one(0177770), "DsBw", m68000up }, -{"dbra", one(0050710), one(0177770), "DsBw", m68000up }, -{"dbt", one(0050310), one(0177770), "DsBw", m68000up }, -{"dbvc", one(0054310), one(0177770), "DsBw", m68000up }, -{"dbvs", one(0054710), one(0177770), "DsBw", m68000up }, - -{"divsl", two(0046100, 0006000), two(0177700, 0107770), ";lD3D1", m68020up }, -{"divsl", two(0046100, 0004000), two(0177700, 0107770), ";lDD", m68020up }, -{"divsll", two(0046100, 0004000), two(0177700, 0107770), ";lD3D1", m68020up }, -{"divsw", one(0100700), one(0170700), ";wDd", m68000up }, -{"divs", one(0100700), one(0170700), ";wDd", m68000up }, -{"divul", two(0046100, 0002000), two(0177700, 0107770), ";lD3D1", m68020up }, -{"divul", two(0046100, 0000000), two(0177700, 0107770), ";lDD", m68020up }, -{"divull", two(0046100, 0000000), two(0177700, 0107770), ";lD3D1", m68020up }, -{"divuw", one(0100300), one(0170700), ";wDd", m68000up }, -{"divu", one(0100300), one(0170700), ";wDd", m68000up }, -{"eorb", one(0005000), one(0177700), "#b$s", m68000up }, /* eori written as or */ -{"eorb", one(0005074), one(0177777), "#bCs", m68000up }, /* eori to ccr */ -{"eorb", one(0130400), one(0170700), "Dd$s", m68000up }, /* register to memory */ -{"eorib", one(0005000), one(0177700), "#b$s", m68000up }, -{"eorib", one(0005074), one(0177777), "#bCs", m68000up }, /* eori to ccr */ -{"eoril", one(0005200), one(0177700), "#l$s", m68000up }, -{"eoriw", one(0005100), one(0177700), "#w$s", m68000up }, -{"eoriw", one(0005174), one(0177777), "#wSs", m68000up }, /* eori to sr */ -{"eorl", one(0005200), one(0177700), "#l$s", m68000up }, -{"eorl", one(0130600), one(0170700), "Dd$s", m68000up }, -{"eorw", one(0005100), one(0177700), "#w$s", m68000up }, -{"eorw", one(0005174), one(0177777), "#wSs", m68000up }, /* eori to sr */ -{"eorw", one(0130500), one(0170700), "Dd$s", m68000up }, - -{"exg", one(0140500), one(0170770), "DdDs", m68000up }, -{"exg", one(0140510), one(0170770), "AdAs", m68000up }, -{"exg", one(0140610), one(0170770), "DdAs", m68000up }, -{"exg", one(0140610), one(0170770), "AsDd", m68000up }, - -{"extw", one(0044200), one(0177770), "Ds", m68000up }, -{"extl", one(0044300), one(0177770), "Ds", m68000up }, -{"extbl", one(0044700), one(0177770), "Ds", m68020up }, -{"extb.l", one(0044700), one(0177770), "Ds", m68020up }, /* Not sure we should support this one */ - -/* float stuff starts here */ -{"fabsb", two(0xF000, 0x5818), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat }, -{"fabsd", two(0xF000, 0x5418), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat }, -{"fabsl", two(0xF000, 0x4018), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat }, -{"fabsp", two(0xF000, 0x4C18), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat }, -{"fabss", two(0xF000, 0x4418), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat }, -{"fabsw", two(0xF000, 0x5018), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat }, -{"fabsx", two(0xF000, 0x0018), two(0xF1C0, 0xE07F), "IiF8F7", mfloat }, -{"fabsx", two(0xF000, 0x4818), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat }, -{"fabsx", two(0xF000, 0x0018), two(0xF1C0, 0xE07F), "IiFt", mfloat }, - -/* FIXME-NOW: The '040 book that I have claims that these should be - coded exactly like fadd. In fact, the table of opmodes calls them - fadd, fsadd, fdadd. That can't be right. If someone can give me the - right encoding, I'll fix it. By induction, I *think* the right - encoding is 38 & 3c, but I'm not sure. - - in the mean time, if you know the encoding for the opmode field, you - can replace all of the "38),"'s and "3c),"'s below with the corrected - values and these guys should then just work. xoxorich. 31Aug91 */ - -#ifdef comment -{"fsabsb", two(0xF000, 0x5838), two(0xF1C0, 0xFC7F), "Ii;bF7", m68040 }, -{"fsabsd", two(0xF000, 0x5438), two(0xF1C0, 0xFC7F), "Ii;FF7", m68040 }, -{"fsabsl", two(0xF000, 0x4038), two(0xF1C0, 0xFC7F), "Ii;lF7", m68040 }, -{"fsabsp", two(0xF000, 0x4C38), two(0xF1C0, 0xFC7F), "Ii;pF7", m68040 }, -{"fsabss", two(0xF000, 0x4438), two(0xF1C0, 0xFC7F), "Ii;fF7", m68040 }, -{"fsabsw", two(0xF000, 0x5038), two(0xF1C0, 0xFC7F), "Ii;wF7", m68040 }, -{"fsabsx", two(0xF000, 0x0038), two(0xF1C0, 0xE07F), "IiF8F7", m68040 }, -{"fsabsx", two(0xF000, 0x4838), two(0xF1C0, 0xFC7F), "Ii;xF7", m68040 }, -{"fsabsx", two(0xF000, 0x0038), two(0xF1C0, 0xE07F), "IiFt", m68040 }, - -{"fdabsb", two(0xF000, 0x583c), two(0xF1C0, 0xFC7F), "Ii;bF7", m68040}, -{"fdabsd", two(0xF000, 0x543c), two(0xF1C0, 0xFC7F), "Ii;FF7", m68040}, -{"fdabsl", two(0xF000, 0x403c), two(0xF1C0, 0xFC7F), "Ii;lF7", m68040}, -{"fdabsp", two(0xF000, 0x4C3c), two(0xF1C0, 0xFC7F), "Ii;pF7", m68040}, -{"fdabss", two(0xF000, 0x443c), two(0xF1C0, 0xFC7F), "Ii;fF7", m68040}, -{"fdabsw", two(0xF000, 0x503c), two(0xF1C0, 0xFC7F), "Ii;wF7", m68040}, -{"fdabsx", two(0xF000, 0x003c), two(0xF1C0, 0xE07F), "IiF8F7", m68040}, -{"fdabsx", two(0xF000, 0x483c), two(0xF1C0, 0xFC7F), "Ii;xF7", m68040}, -{"fdabsx", two(0xF000, 0x003c), two(0xF1C0, 0xE07F), "IiFt", m68040}, -#endif /* comment */ - -{"facosb", two(0xF000, 0x581C), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat }, -{"facosd", two(0xF000, 0x541C), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat }, -{"facosl", two(0xF000, 0x401C), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat }, -{"facosp", two(0xF000, 0x4C1C), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat }, -{"facoss", two(0xF000, 0x441C), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat }, -{"facosw", two(0xF000, 0x501C), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat }, -{"facosx", two(0xF000, 0x001C), two(0xF1C0, 0xE07F), "IiF8F7", mfloat }, -{"facosx", two(0xF000, 0x481C), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat }, -{"facosx", two(0xF000, 0x001C), two(0xF1C0, 0xE07F), "IiFt", mfloat }, - -{"faddb", two(0xF000, 0x5822), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat }, -{"faddd", two(0xF000, 0x5422), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat }, -{"faddl", two(0xF000, 0x4022), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat }, -{"faddp", two(0xF000, 0x4C22), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat }, -{"fadds", two(0xF000, 0x4422), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat }, -{"faddw", two(0xF000, 0x5022), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat }, -{"faddx", two(0xF000, 0x0022), two(0xF1C0, 0xE07F), "IiF8F7", mfloat }, -{"faddx", two(0xF000, 0x4822), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat }, -/* {"faddx", two(0xF000, 0x0022), two(0xF1C0, 0xE07F), "IiFt", mfloat }, JF removed */ - -{"fsaddb", two(0xF000, 0x5832), two(0xF1C0, 0xFC7F), "Ii;bF7", m68040 }, -{"fsaddd", two(0xF000, 0x5432), two(0xF1C0, 0xFC7F), "Ii;FF7", m68040 }, -{"fsaddl", two(0xF000, 0x4032), two(0xF1C0, 0xFC7F), "Ii;lF7", m68040 }, -{"fsaddp", two(0xF000, 0x4C32), two(0xF1C0, 0xFC7F), "Ii;pF7", m68040 }, -{"fsadds", two(0xF000, 0x4432), two(0xF1C0, 0xFC7F), "Ii;fF7", m68040 }, -{"fsaddw", two(0xF000, 0x5032), two(0xF1C0, 0xFC7F), "Ii;wF7", m68040 }, -{"fsaddx", two(0xF000, 0x0032), two(0xF1C0, 0xE07F), "IiF8F7", m68040 }, -{"fsaddx", two(0xF000, 0x4832), two(0xF1C0, 0xFC7F), "Ii;xF7", m68040 }, -/* {"fsaddx", two(0xF000, 0x0032), two(0xF1C0, 0xE07F), "IiFt", m68040 }, JF removed */ - -{"fdaddb", two(0xF000, 0x5836), two(0xF1C0, 0xFC7F), "Ii;bF7", m68040 }, -{"fdaddd", two(0xF000, 0x5436), two(0xF1C0, 0xFC7F), "Ii;FF7", m68040 }, -{"fdaddl", two(0xF000, 0x4036), two(0xF1C0, 0xFC7F), "Ii;lF7", m68040 }, -{"fdaddp", two(0xF000, 0x4C36), two(0xF1C0, 0xFC7F), "Ii;pF7", m68040 }, -{"fdadds", two(0xF000, 0x4436), two(0xF1C0, 0xFC7F), "Ii;fF7", m68040 }, -{"fdaddw", two(0xF000, 0x5036), two(0xF1C0, 0xFC7F), "Ii;wF7", m68040 }, -{"fdaddx", two(0xF000, 0x0036), two(0xF1C0, 0xE07F), "IiF8F7", m68040 }, -{"fdaddx", two(0xF000, 0x4836), two(0xF1C0, 0xFC7F), "Ii;xF7", m68040 }, -/* {"faddx", two(0xF000, 0x0036), two(0xF1C0, 0xE07F), "IiFt", m68040 }, JF removed */ - -{"fasinb", two(0xF000, 0x580C), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat }, -{"fasind", two(0xF000, 0x540C), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat }, -{"fasinl", two(0xF000, 0x400C), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat }, -{"fasinp", two(0xF000, 0x4C0C), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat }, -{"fasins", two(0xF000, 0x440C), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat }, -{"fasinw", two(0xF000, 0x500C), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat }, -{"fasinx", two(0xF000, 0x000C), two(0xF1C0, 0xE07F), "IiF8F7", mfloat }, -{"fasinx", two(0xF000, 0x480C), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat }, -{"fasinx", two(0xF000, 0x000C), two(0xF1C0, 0xE07F), "IiFt", mfloat }, - -{"fatanb", two(0xF000, 0x580A), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat }, -{"fatand", two(0xF000, 0x540A), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat }, -{"fatanl", two(0xF000, 0x400A), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat }, -{"fatanp", two(0xF000, 0x4C0A), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat }, -{"fatans", two(0xF000, 0x440A), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat }, -{"fatanw", two(0xF000, 0x500A), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat }, -{"fatanx", two(0xF000, 0x000A), two(0xF1C0, 0xE07F), "IiF8F7", mfloat }, -{"fatanx", two(0xF000, 0x480A), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat }, -{"fatanx", two(0xF000, 0x000A), two(0xF1C0, 0xE07F), "IiFt", mfloat }, - -{"fatanhb", two(0xF000, 0x580D), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat }, -{"fatanhd", two(0xF000, 0x540D), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat }, -{"fatanhl", two(0xF000, 0x400D), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat }, -{"fatanhp", two(0xF000, 0x4C0D), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat }, -{"fatanhs", two(0xF000, 0x440D), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat }, -{"fatanhw", two(0xF000, 0x500D), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat }, -{"fatanhx", two(0xF000, 0x000D), two(0xF1C0, 0xE07F), "IiF8F7", mfloat }, -{"fatanhx", two(0xF000, 0x480D), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat }, -{"fatanhx", two(0xF000, 0x000D), two(0xF1C0, 0xE07F), "IiFt", mfloat }, - -/* Fixed-size Float branches */ - -{"fbeq", one(0xF081), one(0xF1BF), "IdBW", mfloat }, -{"fbf", one(0xF080), one(0xF1BF), "IdBW", mfloat }, -{"fbge", one(0xF093), one(0xF1BF), "IdBW", mfloat }, -{"fbgl", one(0xF096), one(0xF1BF), "IdBW", mfloat }, -{"fbgle", one(0xF097), one(0xF1BF), "IdBW", mfloat }, -{"fbgt", one(0xF092), one(0xF1BF), "IdBW", mfloat }, -{"fble", one(0xF095), one(0xF1BF), "IdBW", mfloat }, -{"fblt", one(0xF094), one(0xF1BF), "IdBW", mfloat }, -{"fbne", one(0xF08E), one(0xF1BF), "IdBW", mfloat }, -{"fbnge", one(0xF09C), one(0xF1BF), "IdBW", mfloat }, -{"fbngl", one(0xF099), one(0xF1BF), "IdBW", mfloat }, -{"fbngle", one(0xF098), one(0xF1BF), "IdBW", mfloat }, -{"fbngt", one(0xF09D), one(0xF1BF), "IdBW", mfloat }, -{"fbnle", one(0xF09A), one(0xF1BF), "IdBW", mfloat }, -{"fbnlt", one(0xF09B), one(0xF1BF), "IdBW", mfloat }, -{"fboge", one(0xF083), one(0xF1BF), "IdBW", mfloat }, -{"fbogl", one(0xF086), one(0xF1BF), "IdBW", mfloat }, -{"fbogt", one(0xF082), one(0xF1BF), "IdBW", mfloat }, -{"fbole", one(0xF085), one(0xF1BF), "IdBW", mfloat }, -{"fbolt", one(0xF084), one(0xF1BF), "IdBW", mfloat }, -{"fbor", one(0xF087), one(0xF1BF), "IdBW", mfloat }, -{"fbseq", one(0xF091), one(0xF1BF), "IdBW", mfloat }, -{"fbsf", one(0xF090), one(0xF1BF), "IdBW", mfloat }, -{"fbsne", one(0xF09E), one(0xF1BF), "IdBW", mfloat }, -{"fbst", one(0xF09F), one(0xF1BF), "IdBW", mfloat }, -{"fbt", one(0xF08F), one(0xF1BF), "IdBW", mfloat }, -{"fbueq", one(0xF089), one(0xF1BF), "IdBW", mfloat }, -{"fbuge", one(0xF08B), one(0xF1BF), "IdBW", mfloat }, -{"fbugt", one(0xF08A), one(0xF1BF), "IdBW", mfloat }, -{"fbule", one(0xF08D), one(0xF1BF), "IdBW", mfloat }, -{"fbult", one(0xF08C), one(0xF1BF), "IdBW", mfloat }, -{"fbun", one(0xF088), one(0xF1BF), "IdBW", mfloat }, - -/* Float branches -- long (32-bit) displacements */ - -{"fbeql", one(0xF081), one(0xF1BF), "IdBC", mfloat }, -{"fbfl", one(0xF080), one(0xF1BF), "IdBC", mfloat }, -{"fbgel", one(0xF093), one(0xF1BF), "IdBC", mfloat }, -{"fbgll", one(0xF096), one(0xF1BF), "IdBC", mfloat }, -{"fbglel", one(0xF097), one(0xF1BF), "IdBC", mfloat }, -{"fbgtl", one(0xF092), one(0xF1BF), "IdBC", mfloat }, -{"fblel", one(0xF095), one(0xF1BF), "IdBC", mfloat }, -{"fbltl", one(0xF094), one(0xF1BF), "IdBC", mfloat }, -{"fbnel", one(0xF08E), one(0xF1BF), "IdBC", mfloat }, -{"fbngel", one(0xF09C), one(0xF1BF), "IdBC", mfloat }, -{"fbngll", one(0xF099), one(0xF1BF), "IdBC", mfloat }, -{"fbnglel", one(0xF098), one(0xF1BF), "IdBC", mfloat }, -{"fbngtl", one(0xF09D), one(0xF1BF), "IdBC", mfloat }, -{"fbnlel", one(0xF09A), one(0xF1BF), "IdBC", mfloat }, -{"fbnltl", one(0xF09B), one(0xF1BF), "IdBC", mfloat }, -{"fbogel", one(0xF083), one(0xF1BF), "IdBC", mfloat }, -{"fbogll", one(0xF086), one(0xF1BF), "IdBC", mfloat }, -{"fbogtl", one(0xF082), one(0xF1BF), "IdBC", mfloat }, -{"fbolel", one(0xF085), one(0xF1BF), "IdBC", mfloat }, -{"fboltl", one(0xF084), one(0xF1BF), "IdBC", mfloat }, -{"fborl", one(0xF087), one(0xF1BF), "IdBC", mfloat }, -{"fbseql", one(0xF091), one(0xF1BF), "IdBC", mfloat }, -{"fbsfl", one(0xF090), one(0xF1BF), "IdBC", mfloat }, -{"fbsnel", one(0xF09E), one(0xF1BF), "IdBC", mfloat }, -{"fbstl", one(0xF09F), one(0xF1BF), "IdBC", mfloat }, -{"fbtl", one(0xF08F), one(0xF1BF), "IdBC", mfloat }, -{"fbueql", one(0xF089), one(0xF1BF), "IdBC", mfloat }, -{"fbugel", one(0xF08B), one(0xF1BF), "IdBC", mfloat }, -{"fbugtl", one(0xF08A), one(0xF1BF), "IdBC", mfloat }, -{"fbulel", one(0xF08D), one(0xF1BF), "IdBC", mfloat }, -{"fbultl", one(0xF08C), one(0xF1BF), "IdBC", mfloat }, -{"fbunl", one(0xF088), one(0xF1BF), "IdBC", mfloat }, - -{"fcmpb", two(0xF000, 0x5838), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat }, -{"fcmpd", two(0xF000, 0x5438), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat }, -{"fcmpl", two(0xF000, 0x4038), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat }, -{"fcmpp", two(0xF000, 0x4C38), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat }, -{"fcmps", two(0xF000, 0x4438), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat }, -{"fcmpw", two(0xF000, 0x5038), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat }, -{"fcmpx", two(0xF000, 0x0038), two(0xF1C0, 0xE07F), "IiF8F7", mfloat }, -{"fcmpx", two(0xF000, 0x4838), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat }, -/* {"fcmpx", two(0xF000, 0x0038), two(0xF1C0, 0xE07F), "IiFt", mfloat }, JF removed */ - -{"fcosb", two(0xF000, 0x581D), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat }, -{"fcosd", two(0xF000, 0x541D), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat }, -{"fcosl", two(0xF000, 0x401D), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat }, -{"fcosp", two(0xF000, 0x4C1D), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat }, -{"fcoss", two(0xF000, 0x441D), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat }, -{"fcosw", two(0xF000, 0x501D), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat }, -{"fcosx", two(0xF000, 0x001D), two(0xF1C0, 0xE07F), "IiF8F7", mfloat }, -{"fcosx", two(0xF000, 0x481D), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat }, -{"fcosx", two(0xF000, 0x001D), two(0xF1C0, 0xE07F), "IiFt", mfloat }, - -{"fcoshb", two(0xF000, 0x5819), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat }, -{"fcoshd", two(0xF000, 0x5419), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat }, -{"fcoshl", two(0xF000, 0x4019), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat }, -{"fcoshp", two(0xF000, 0x4C19), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat }, -{"fcoshs", two(0xF000, 0x4419), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat }, -{"fcoshw", two(0xF000, 0x5019), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat }, -{"fcoshx", two(0xF000, 0x0019), two(0xF1C0, 0xE07F), "IiF8F7", mfloat }, -{"fcoshx", two(0xF000, 0x4819), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat }, -{"fcoshx", two(0xF000, 0x0019), two(0xF1C0, 0xE07F), "IiFt", mfloat }, - -{"fdbeq", two(0xF048, 0x0001), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat }, -{"fdbf", two(0xF048, 0x0000), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat }, -{"fdbge", two(0xF048, 0x0013), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat }, -{"fdbgl", two(0xF048, 0x0016), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat }, -{"fdbgle", two(0xF048, 0x0017), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat }, -{"fdbgt", two(0xF048, 0x0012), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat }, -{"fdble", two(0xF048, 0x0015), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat }, -{"fdblt", two(0xF048, 0x0014), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat }, -{"fdbne", two(0xF048, 0x000E), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat }, -{"fdbnge", two(0xF048, 0x001C), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat }, -{"fdbngl", two(0xF048, 0x0019), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat }, -{"fdbngle", two(0xF048, 0x0018), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat }, -{"fdbngt", two(0xF048, 0x001D), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat }, -{"fdbnle", two(0xF048, 0x001A), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat }, -{"fdbnlt", two(0xF048, 0x001B), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat }, -{"fdboge", two(0xF048, 0x0003), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat }, -{"fdbogl", two(0xF048, 0x0006), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat }, -{"fdbogt", two(0xF048, 0x0002), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat }, -{"fdbole", two(0xF048, 0x0005), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat }, -{"fdbolt", two(0xF048, 0x0004), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat }, -{"fdbor", two(0xF048, 0x0007), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat }, -{"fdbseq", two(0xF048, 0x0011), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat }, -{"fdbsf", two(0xF048, 0x0010), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat }, -{"fdbsne", two(0xF048, 0x001E), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat }, -{"fdbst", two(0xF048, 0x001F), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat }, -{"fdbt", two(0xF048, 0x000F), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat }, -{"fdbueq", two(0xF048, 0x0009), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat }, -{"fdbuge", two(0xF048, 0x000B), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat }, -{"fdbugt", two(0xF048, 0x000A), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat }, -{"fdbule", two(0xF048, 0x000D), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat }, -{"fdbult", two(0xF048, 0x000C), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat }, -{"fdbun", two(0xF048, 0x0008), two(0xF1F8, 0xFFFF), "IiDsBw", mfloat }, - -{"fdivb", two(0xF000, 0x5820), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat }, -{"fdivd", two(0xF000, 0x5420), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat }, -{"fdivl", two(0xF000, 0x4020), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat }, -{"fdivp", two(0xF000, 0x4C20), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat }, -{"fdivs", two(0xF000, 0x4420), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat }, -{"fdivw", two(0xF000, 0x5020), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat }, -{"fdivx", two(0xF000, 0x0020), two(0xF1C0, 0xE07F), "IiF8F7", mfloat }, -{"fdivx", two(0xF000, 0x4820), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat }, -/* {"fdivx", two(0xF000, 0x0020), two(0xF1C0, 0xE07F), "IiFt", mfloat }, JF */ - -{"fsdivb", two(0xF000, 0x5830), two(0xF1C0, 0xFC7F), "Ii;bF7", m68040 }, -{"fsdivd", two(0xF000, 0x5430), two(0xF1C0, 0xFC7F), "Ii;FF7", m68040 }, -{"fsdivl", two(0xF000, 0x4030), two(0xF1C0, 0xFC7F), "Ii;lF7", m68040 }, -{"fsdivp", two(0xF000, 0x4C30), two(0xF1C0, 0xFC7F), "Ii;pF7", m68040 }, -{"fsdivs", two(0xF000, 0x4430), two(0xF1C0, 0xFC7F), "Ii;fF7", m68040 }, -{"fsdivw", two(0xF000, 0x5030), two(0xF1C0, 0xFC7F), "Ii;wF7", m68040 }, -{"fsdivx", two(0xF000, 0x0030), two(0xF1C0, 0xE07F), "IiF8F7", m68040 }, -{"fsdivx", two(0xF000, 0x4830), two(0xF1C0, 0xFC7F), "Ii;xF7", m68040 }, -/* {"fsdivx", two(0xF000, 0x0030), two(0xF1C0, 0xE07F), "IiFt", m68040 }, JF */ - -{"fddivb", two(0xF000, 0x5834), two(0xF1C0, 0xFC7F), "Ii;bF7", m68040 }, -{"fddivd", two(0xF000, 0x5434), two(0xF1C0, 0xFC7F), "Ii;FF7", m68040 }, -{"fddivl", two(0xF000, 0x4034), two(0xF1C0, 0xFC7F), "Ii;lF7", m68040 }, -{"fddivp", two(0xF000, 0x4C34), two(0xF1C0, 0xFC7F), "Ii;pF7", m68040 }, -{"fddivs", two(0xF000, 0x4434), two(0xF1C0, 0xFC7F), "Ii;fF7", m68040 }, -{"fddivw", two(0xF000, 0x5034), two(0xF1C0, 0xFC7F), "Ii;wF7", m68040 }, -{"fddivx", two(0xF000, 0x0034), two(0xF1C0, 0xE07F), "IiF8F7", m68040 }, -{"fddivx", two(0xF000, 0x4834), two(0xF1C0, 0xFC7F), "Ii;xF7", m68040 }, -/* {"fddivx", two(0xF000, 0x0034), two(0xF1C0, 0xE07F), "IiFt", m68040 }, JF */ - -{"fetoxb", two(0xF000, 0x5810), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat }, -{"fetoxd", two(0xF000, 0x5410), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat }, -{"fetoxl", two(0xF000, 0x4010), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat }, -{"fetoxp", two(0xF000, 0x4C10), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat }, -{"fetoxs", two(0xF000, 0x4410), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat }, -{"fetoxw", two(0xF000, 0x5010), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat }, -{"fetoxx", two(0xF000, 0x0010), two(0xF1C0, 0xE07F), "IiF8F7", mfloat }, -{"fetoxx", two(0xF000, 0x4810), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat }, -{"fetoxx", two(0xF000, 0x0010), two(0xF1C0, 0xE07F), "IiFt", mfloat }, - -{"fetoxm1b", two(0xF000, 0x5808), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat }, -{"fetoxm1d", two(0xF000, 0x5408), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat }, -{"fetoxm1l", two(0xF000, 0x4008), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat }, -{"fetoxm1p", two(0xF000, 0x4C08), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat }, -{"fetoxm1s", two(0xF000, 0x4408), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat }, -{"fetoxm1w", two(0xF000, 0x5008), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat }, -{"fetoxm1x", two(0xF000, 0x0008), two(0xF1C0, 0xE07F), "IiF8F7", mfloat }, -{"fetoxm1x", two(0xF000, 0x4808), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat }, -{"fetoxm1x", two(0xF000, 0x0008), two(0xF1C0, 0xE07F), "IiFt", mfloat }, - -{"fgetexpb", two(0xF000, 0x581E), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat }, -{"fgetexpd", two(0xF000, 0x541E), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat }, -{"fgetexpl", two(0xF000, 0x401E), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat }, -{"fgetexpp", two(0xF000, 0x4C1E), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat }, -{"fgetexps", two(0xF000, 0x441E), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat }, -{"fgetexpw", two(0xF000, 0x501E), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat }, -{"fgetexpx", two(0xF000, 0x001E), two(0xF1C0, 0xE07F), "IiF8F7", mfloat }, -{"fgetexpx", two(0xF000, 0x481E), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat }, -{"fgetexpx", two(0xF000, 0x001E), two(0xF1C0, 0xE07F), "IiFt", mfloat }, - -{"fgetmanb", two(0xF000, 0x581F), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat }, -{"fgetmand", two(0xF000, 0x541F), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat }, -{"fgetmanl", two(0xF000, 0x401F), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat }, -{"fgetmanp", two(0xF000, 0x4C1F), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat }, -{"fgetmans", two(0xF000, 0x441F), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat }, -{"fgetmanw", two(0xF000, 0x501F), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat }, -{"fgetmanx", two(0xF000, 0x001F), two(0xF1C0, 0xE07F), "IiF8F7", mfloat }, -{"fgetmanx", two(0xF000, 0x481F), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat }, -{"fgetmanx", two(0xF000, 0x001F), two(0xF1C0, 0xE07F), "IiFt", mfloat }, - -{"fintb", two(0xF000, 0x5801), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat }, -{"fintd", two(0xF000, 0x5401), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat }, -{"fintl", two(0xF000, 0x4001), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat }, -{"fintp", two(0xF000, 0x4C01), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat }, -{"fints", two(0xF000, 0x4401), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat }, -{"fintw", two(0xF000, 0x5001), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat }, -{"fintx", two(0xF000, 0x0001), two(0xF1C0, 0xE07F), "IiF8F7", mfloat }, -{"fintx", two(0xF000, 0x4801), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat }, -{"fintx", two(0xF000, 0x0001), two(0xF1C0, 0xE07F), "IiFt", mfloat }, - -{"fintrzb", two(0xF000, 0x5803), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat }, -{"fintrzd", two(0xF000, 0x5403), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat }, -{"fintrzl", two(0xF000, 0x4003), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat }, -{"fintrzp", two(0xF000, 0x4C03), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat }, -{"fintrzs", two(0xF000, 0x4403), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat }, -{"fintrzw", two(0xF000, 0x5003), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat }, -{"fintrzx", two(0xF000, 0x0003), two(0xF1C0, 0xE07F), "IiF8F7", mfloat }, -{"fintrzx", two(0xF000, 0x4803), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat }, -{"fintrzx", two(0xF000, 0x0003), two(0xF1C0, 0xE07F), "IiFt", mfloat }, - -{"flog10b", two(0xF000, 0x5815), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat }, -{"flog10d", two(0xF000, 0x5415), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat }, -{"flog10l", two(0xF000, 0x4015), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat }, -{"flog10p", two(0xF000, 0x4C15), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat }, -{"flog10s", two(0xF000, 0x4415), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat }, -{"flog10w", two(0xF000, 0x5015), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat }, -{"flog10x", two(0xF000, 0x0015), two(0xF1C0, 0xE07F), "IiF8F7", mfloat }, -{"flog10x", two(0xF000, 0x4815), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat }, -{"flog10x", two(0xF000, 0x0015), two(0xF1C0, 0xE07F), "IiFt", mfloat }, - -{"flog2b", two(0xF000, 0x5816), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat }, -{"flog2d", two(0xF000, 0x5416), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat }, -{"flog2l", two(0xF000, 0x4016), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat }, -{"flog2p", two(0xF000, 0x4C16), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat }, -{"flog2s", two(0xF000, 0x4416), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat }, -{"flog2w", two(0xF000, 0x5016), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat }, -{"flog2x", two(0xF000, 0x0016), two(0xF1C0, 0xE07F), "IiF8F7", mfloat }, -{"flog2x", two(0xF000, 0x4816), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat }, -{"flog2x", two(0xF000, 0x0016), two(0xF1C0, 0xE07F), "IiFt", mfloat }, - -{"flognb", two(0xF000, 0x5814), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat }, -{"flognd", two(0xF000, 0x5414), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat }, -{"flognl", two(0xF000, 0x4014), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat }, -{"flognp", two(0xF000, 0x4C14), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat }, -{"flogns", two(0xF000, 0x4414), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat }, -{"flognw", two(0xF000, 0x5014), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat }, -{"flognx", two(0xF000, 0x0014), two(0xF1C0, 0xE07F), "IiF8F7", mfloat }, -{"flognx", two(0xF000, 0x4814), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat }, -{"flognx", two(0xF000, 0x0014), two(0xF1C0, 0xE07F), "IiFt", mfloat }, - -{"flognp1b", two(0xF000, 0x5806), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat }, -{"flognp1d", two(0xF000, 0x5406), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat }, -{"flognp1l", two(0xF000, 0x4006), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat }, -{"flognp1p", two(0xF000, 0x4C06), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat }, -{"flognp1s", two(0xF000, 0x4406), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat }, -{"flognp1w", two(0xF000, 0x5006), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat }, -{"flognp1x", two(0xF000, 0x0006), two(0xF1C0, 0xE07F), "IiF8F7", mfloat }, -{"flognp1x", two(0xF000, 0x4806), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat }, -{"flognp1x", two(0xF000, 0x0006), two(0xF1C0, 0xE07F), "IiFt", mfloat }, - -{"fmodb", two(0xF000, 0x5821), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat }, -{"fmodd", two(0xF000, 0x5421), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat }, -{"fmodl", two(0xF000, 0x4021), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat }, -{"fmodp", two(0xF000, 0x4C21), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat }, -{"fmods", two(0xF000, 0x4421), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat }, -{"fmodw", two(0xF000, 0x5021), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat }, -{"fmodx", two(0xF000, 0x0021), two(0xF1C0, 0xE07F), "IiF8F7", mfloat }, -{"fmodx", two(0xF000, 0x4821), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat }, -/* {"fmodx", two(0xF000, 0x0021), two(0xF1C0, 0xE07F), "IiFt", mfloat }, JF */ - -{"fmoveb", two(0xF000, 0x5800), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat }, /* fmove from to fp */ -{"fmoveb", two(0xF000, 0x7800), two(0xF1C0, 0xFC7F), "IiF7@b", mfloat }, /* fmove from fp to */ -{"fmoved", two(0xF000, 0x5400), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat }, /* fmove from to fp */ -{"fmoved", two(0xF000, 0x7400), two(0xF1C0, 0xFC7F), "IiF7@F", mfloat }, /* fmove from fp to */ -{"fmovel", two(0xF000, 0x4000), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat }, /* fmove from to fp */ -{"fmovel", two(0xF000, 0x6000), two(0xF1C0, 0xFC7F), "IiF7@l", mfloat }, /* fmove from fp to */ -/* Warning: The addressing modes on these are probably not right: - esp, Areg direct is only allowed for FPI */ - /* fmove.l from/to system control registers: */ -{"fmovel", two(0xF000, 0xA000), two(0xF1C0, 0xE3FF), "Iis8@s", mfloat }, -{"fmovel", two(0xF000, 0x8000), two(0xF1C0, 0xE3FF), "Ii*ls8", mfloat }, - -/* {"fmovel", two(0xF000, 0xA000), two(0xF1C0, 0xE3FF), "Iis8@s", mfloat }, -{"fmovel", two(0xF000, 0x8000), two(0xF2C0, 0xE3FF), "Ii*ss8", mfloat }, */ - -{"fmovep", two(0xF000, 0x4C00), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat }, /* fmove from to fp */ -{"fmovep", two(0xF000, 0x6C00), two(0xF1C0, 0xFC00), "IiF7@pkC", mfloat }, /* fmove.p with k-factors: */ -{"fmovep", two(0xF000, 0x7C00), two(0xF1C0, 0xFC0F), "IiF7@pDk", mfloat }, /* fmove.p with k-factors: */ - -{"fmoves", two(0xF000, 0x4400), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat }, /* fmove from to fp */ -{"fmoves", two(0xF000, 0x6400), two(0xF1C0, 0xFC7F), "IiF7@f", mfloat }, /* fmove from fp to */ -{"fmovew", two(0xF000, 0x5000), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat }, /* fmove from to fp */ -{"fmovew", two(0xF000, 0x7000), two(0xF1C0, 0xFC7F), "IiF7@w", mfloat }, /* fmove from fp to */ -{"fmovex", two(0xF000, 0x0000), two(0xF1C0, 0xE07F), "IiF8F7", mfloat }, /* fmove from to fp */ -{"fmovex", two(0xF000, 0x4800), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat }, /* fmove from to fp */ -{"fmovex", two(0xF000, 0x6800), two(0xF1C0, 0xFC7F), "IiF7@x", mfloat }, /* fmove from fp to */ -/* JF removed {"fmovex", two(0xF000, 0x0000), two(0xF1C0, 0xE07F), "IiFt", mfloat }, / * fmove from to fp */ - -{"fsmoveb", two(0xF000, 0x5800), two(0xF1C0, 0xFC7F), "Ii;bF7", m68040 }, /* fmove from to fp */ -{"fsmoved", two(0xF000, 0x5400), two(0xF1C0, 0xFC7F), "Ii;FF7", m68040 }, /* fmove from to fp */ -{"fsmovel", two(0xF000, 0x4000), two(0xF1C0, 0xFC7F), "Ii;lF7", m68040 }, /* fmove from to fp */ -{"fsmoves", two(0xF000, 0x4400), two(0xF1C0, 0xFC7F), "Ii;fF7", m68040 }, /* fmove from to fp */ -{"fsmovew", two(0xF000, 0x5000), two(0xF1C0, 0xFC7F), "Ii;wF7", m68040 }, /* fmove from to fp */ -{"fsmovex", two(0xF000, 0x0000), two(0xF1C0, 0xE07F), "IiF8F7", m68040 }, /* fmove from to fp */ -{"fsmovex", two(0xF000, 0x4800), two(0xF1C0, 0xFC7F), "Ii;xF7", m68040 }, /* fmove from to fp */ -/* JF removed {"fsmovex", two(0xF000, 0x0000), two(0xF1C0, 0xE07F), "IiFt", m68040 }, / * fmove from to fp */ - -{"fdmoveb", two(0xF000, 0x5800), two(0xF1C0, 0xFC7F), "Ii;bF7", m68040 }, /* fmove from to fp */ -{"fdmoved", two(0xF000, 0x5400), two(0xF1C0, 0xFC7F), "Ii;FF7", m68040 }, /* fmove from to fp */ -{"fdmovel", two(0xF000, 0x4000), two(0xF1C0, 0xFC7F), "Ii;lF7", m68040 }, /* fmove from to fp */ -{"fdmoves", two(0xF000, 0x4400), two(0xF1C0, 0xFC7F), "Ii;fF7", m68040 }, /* fmove from to fp */ -{"fdmovew", two(0xF000, 0x5000), two(0xF1C0, 0xFC7F), "Ii;wF7", m68040 }, /* fmove from to fp */ -{"fdmovex", two(0xF000, 0x0000), two(0xF1C0, 0xE07F), "IiF8F7", m68040 }, /* fmove from to fp */ -{"fdmovex", two(0xF000, 0x4800), two(0xF1C0, 0xFC7F), "Ii;xF7", m68040 }, /* fmove from to fp */ -/* JF removed {"fdmovex", two(0xF000, 0x0000), two(0xF1C0, 0xE07F), "IiFt", m68040 }, / * fmove from to fp */ - -{"fmovecrx", two(0xF000, 0x5C00), two(0xF1FF, 0xFC00), "Ii#CF7", mfloat }, /* fmovecr.x #ccc, FPn */ -{"fmovecr", two(0xF000, 0x5C00), two(0xF1FF, 0xFC00), "Ii#CF7", mfloat }, - -/* Other fmovemx. */ -{"fmovemx", two(0xF000, 0xF800), two(0xF1C0, 0xFF8F), "IiDk&s", mfloat }, /* reg to control, static and dynamic: */ -{"fmovemx", two(0xF000, 0xD800), two(0xF1C0, 0xFF8F), "Ii&sDk", mfloat }, /* from control to reg, static and dynamic: */ - -{"fmovemx", two(0xF000, 0xF000), two(0xF1C0, 0xFF00), "Idl3&s", mfloat }, /* to control, static and dynamic: */ -{"fmovemx", two(0xF000, 0xF000), two(0xF1C0, 0xFF00), "Id#3&s", mfloat }, /* to control, static and dynamic: */ - -{"fmovemx", two(0xF000, 0xD000), two(0xF1C0, 0xFF00), "Id&sl3", mfloat }, /* from control, static and dynamic: */ -{"fmovemx", two(0xF000, 0xD000), two(0xF1C0, 0xFF00), "Id&s#3", mfloat }, /* from control, static and dynamic: */ - -{"fmovemx", two(0xF020, 0xE800), two(0xF1F8, 0xFF8F), "IiDk-s", mfloat }, /* reg to autodecrement, static and dynamic */ -{"fmovemx", two(0xF020, 0xE000), two(0xF1F8, 0xFF00), "IdL3-s", mfloat }, /* to autodecrement, static and dynamic */ -{"fmovemx", two(0xF020, 0xE000), two(0xF1F8, 0xFF00), "Id#3-s", mfloat }, /* to autodecrement, static and dynamic */ - -{"fmovemx", two(0xF018, 0xD800), two(0xF1F8, 0xFF8F), "Ii+sDk", mfloat }, /* from autoinc to reg, static and dynamic: */ -{"fmovemx", two(0xF018, 0xD000), two(0xF1F8, 0xFF00), "Id+sl3", mfloat }, /* from autoincrement, static and dynamic: */ -{"fmovemx", two(0xF018, 0xD000), two(0xF1F8, 0xFF00), "Id+s#3", mfloat }, /* from autoincrement, static and dynamic: */ - -{"fmoveml", two(0xF000, 0xA000), two(0xF1C0, 0xE3FF), "IiL8@s", mfloat }, -{"fmoveml", two(0xF000, 0xA000), two(0xF1C0, 0xE3FF), "Ii#8@s", mfloat }, -{"fmoveml", two(0xF000, 0xA000), two(0xF1C0, 0xE3FF), "Iis8@s", mfloat }, - -{"fmoveml", two(0xF000, 0x8000), two(0xF2C0, 0xE3FF), "Ii*sL8", mfloat }, -{"fmoveml", two(0xF000, 0x8000), two(0xF1C0, 0xE3FF), "Ii*s#8", mfloat }, -{"fmoveml", two(0xF000, 0x8000), two(0xF1C0, 0xE3FF), "Ii*ss8", mfloat }, - -/* fmovemx with register lists */ -{"fmovem", two(0xF020, 0xE000), two(0xF1F8, 0xFF00), "IdL3-s", mfloat }, /* to autodec, static & dynamic */ -{"fmovem", two(0xF000, 0xF000), two(0xF1C0, 0xFF00), "Idl3&s", mfloat }, /* to control, static and dynamic */ -{"fmovem", two(0xF018, 0xD000), two(0xF1F8, 0xFF00), "Id+sl3", mfloat }, /* from autoinc, static & dynamic */ -{"fmovem", two(0xF000, 0xD000), two(0xF1C0, 0xFF00), "Id&sl3", mfloat }, /* from control, static and dynamic */ - - /* Alternate mnemonics for GNU as and GNU CC */ -{"fmovem", two(0xF020, 0xE000), two(0xF1F8, 0xFF00), "Id#3-s", mfloat }, /* to autodecrement, static and dynamic */ -{"fmovem", two(0xF020, 0xE800), two(0xF1F8, 0xFF8F), "IiDk-s", mfloat }, /* to autodecrement, static and dynamic */ - -{"fmovem", two(0xF000, 0xF000), two(0xF1C0, 0xFF00), "Id#3&s", mfloat }, /* to control, static and dynamic: */ -{"fmovem", two(0xF000, 0xF800), two(0xF1C0, 0xFF8F), "IiDk&s", mfloat }, /* to control, static and dynamic: */ - -{"fmovem", two(0xF018, 0xD000), two(0xF1F8, 0xFF00), "Id+s#3", mfloat }, /* from autoincrement, static and dynamic: */ -{"fmovem", two(0xF018, 0xD800), two(0xF1F8, 0xFF8F), "Ii+sDk", mfloat }, /* from autoincrement, static and dynamic: */ - -{"fmovem", two(0xF000, 0xD000), two(0xF1C0, 0xFF00), "Id&s#3", mfloat }, /* from control, static and dynamic: */ -{"fmovem", two(0xF000, 0xD800), two(0xF1C0, 0xFF8F), "Ii&sDk", mfloat }, /* from control, static and dynamic: */ - -/* fmoveml a FP-control register */ -{"fmovem", two(0xF000, 0xA000), two(0xF1C0, 0xE3FF), "Iis8@s", mfloat }, -{"fmovem", two(0xF000, 0x8000), two(0xF1C0, 0xE3FF), "Ii*ss8", mfloat }, - -/* fmoveml a FP-control reglist */ -{"fmovem", two(0xF000, 0xA000), two(0xF1C0, 0xE3FF), "IiL8@s", mfloat }, -{"fmovem", two(0xF000, 0x8000), two(0xF2C0, 0xE3FF), "Ii*sL8", mfloat }, - -{"fmulb", two(0xF000, 0x5823), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat }, -{"fmuld", two(0xF000, 0x5423), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat }, -{"fmull", two(0xF000, 0x4023), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat }, -{"fmulp", two(0xF000, 0x4C23), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat }, -{"fmuls", two(0xF000, 0x4423), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat }, -{"fmulw", two(0xF000, 0x5023), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat }, -{"fmulx", two(0xF000, 0x0023), two(0xF1C0, 0xE07F), "IiF8F7", mfloat }, -{"fmulx", two(0xF000, 0x4823), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat }, -/* {"fmulx", two(0xF000, 0x0023), two(0xF1C0, 0xE07F), "IiFt", mfloat }, JF */ - -{"fsmulb", two(0xF000, 0x5833), two(0xF1C0, 0xFC7F), "Ii;bF7", m68040 }, -{"fsmuld", two(0xF000, 0x5433), two(0xF1C0, 0xFC7F), "Ii;FF7", m68040 }, -{"fsmull", two(0xF000, 0x4033), two(0xF1C0, 0xFC7F), "Ii;lF7", m68040 }, -{"fsmulp", two(0xF000, 0x4C33), two(0xF1C0, 0xFC7F), "Ii;pF7", m68040 }, -{"fsmuls", two(0xF000, 0x4433), two(0xF1C0, 0xFC7F), "Ii;fF7", m68040 }, -{"fsmulw", two(0xF000, 0x5033), two(0xF1C0, 0xFC7F), "Ii;wF7", m68040 }, -{"fsmulx", two(0xF000, 0x0033), two(0xF1C0, 0xE07F), "IiF8F7", m68040 }, -{"fsmulx", two(0xF000, 0x4833), two(0xF1C0, 0xFC7F), "Ii;xF7", m68040 }, -/* {"fsmulx", two(0xF000, 0x0033), two(0xF1C0, 0xE07F), "IiFt", m68040 }, JF */ - -{"fdmulb", two(0xF000, 0x5837), two(0xF1C0, 0xFC7F), "Ii;bF7", m68040 }, -{"fdmuld", two(0xF000, 0x5437), two(0xF1C0, 0xFC7F), "Ii;FF7", m68040 }, -{"fdmull", two(0xF000, 0x4037), two(0xF1C0, 0xFC7F), "Ii;lF7", m68040 }, -{"fdmulp", two(0xF000, 0x4C37), two(0xF1C0, 0xFC7F), "Ii;pF7", m68040 }, -{"fdmuls", two(0xF000, 0x4437), two(0xF1C0, 0xFC7F), "Ii;fF7", m68040 }, -{"fdmulw", two(0xF000, 0x5037), two(0xF1C0, 0xFC7F), "Ii;wF7", m68040 }, -{"fdmulx", two(0xF000, 0x0037), two(0xF1C0, 0xE07F), "IiF8F7", m68040 }, -{"fdmulx", two(0xF000, 0x4837), two(0xF1C0, 0xFC7F), "Ii;xF7", m68040 }, -/* {"dfmulx", two(0xF000, 0x0037), two(0xF1C0, 0xE07F), "IiFt", m68040 }, JF */ - -{"fnegb", two(0xF000, 0x581A), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat }, -{"fnegd", two(0xF000, 0x541A), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat }, -{"fnegl", two(0xF000, 0x401A), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat }, -{"fnegp", two(0xF000, 0x4C1A), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat }, -{"fnegs", two(0xF000, 0x441A), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat }, -{"fnegw", two(0xF000, 0x501A), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat }, -{"fnegx", two(0xF000, 0x001A), two(0xF1C0, 0xE07F), "IiF8F7", mfloat }, -{"fnegx", two(0xF000, 0x481A), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat }, -{"fnegx", two(0xF000, 0x001A), two(0xF1C0, 0xE07F), "IiFt", mfloat }, - -{"fsnegb", two(0xF000, 0x585A), two(0xF1C0, 0xFC7F), "Ii;bF7", m68040 }, -{"fsnegd", two(0xF000, 0x545A), two(0xF1C0, 0xFC7F), "Ii;FF7", m68040 }, -{"fsnegl", two(0xF000, 0x405A), two(0xF1C0, 0xFC7F), "Ii;lF7", m68040 }, -{"fsnegp", two(0xF000, 0x4C5A), two(0xF1C0, 0xFC7F), "Ii;pF7", m68040 }, -{"fsnegs", two(0xF000, 0x445A), two(0xF1C0, 0xFC7F), "Ii;fF7", m68040 }, -{"fsnegw", two(0xF000, 0x505A), two(0xF1C0, 0xFC7F), "Ii;wF7", m68040 }, -{"fsnegx", two(0xF000, 0x005A), two(0xF1C0, 0xE07F), "IiF8F7", m68040 }, -{"fsnegx", two(0xF000, 0x485A), two(0xF1C0, 0xFC7F), "Ii;xF7", m68040 }, -{"fsnegx", two(0xF000, 0x005A), two(0xF1C0, 0xE07F), "IiFt", m68040 }, - -{"fdnegb", two(0xF000, 0x585E), two(0xF1C0, 0xFC7F), "Ii;bF7", m68040 }, -{"fdnegd", two(0xF000, 0x545E), two(0xF1C0, 0xFC7F), "Ii;FF7", m68040 }, -{"fdnegl", two(0xF000, 0x405E), two(0xF1C0, 0xFC7F), "Ii;lF7", m68040 }, -{"fdnegp", two(0xF000, 0x4C5E), two(0xF1C0, 0xFC7F), "Ii;pF7", m68040 }, -{"fdnegs", two(0xF000, 0x445E), two(0xF1C0, 0xFC7F), "Ii;fF7", m68040 }, -{"fdnegw", two(0xF000, 0x505E), two(0xF1C0, 0xFC7F), "Ii;wF7", m68040 }, -{"fdnegx", two(0xF000, 0x005E), two(0xF1C0, 0xE07F), "IiF8F7", m68040 }, -{"fdnegx", two(0xF000, 0x485E), two(0xF1C0, 0xFC7F), "Ii;xF7", m68040 }, -{"fdnegx", two(0xF000, 0x005E), two(0xF1C0, 0xE07F), "IiFt", m68040 }, - -{"fnop", two(0xF280, 0x0000), two(0xFFFF, 0xFFFF), "Ii", mfloat }, - -{"fremb", two(0xF000, 0x5825), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat }, -{"fremd", two(0xF000, 0x5425), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat }, -{"freml", two(0xF000, 0x4025), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat }, -{"fremp", two(0xF000, 0x4C25), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat }, -{"frems", two(0xF000, 0x4425), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat }, -{"fremw", two(0xF000, 0x5025), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat }, -{"fremx", two(0xF000, 0x0025), two(0xF1C0, 0xE07F), "IiF8F7", mfloat }, -{"fremx", two(0xF000, 0x4825), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat }, -/* {"fremx", two(0xF000, 0x0025), two(0xF1C0, 0xE07F), "IiFt", mfloat }, JF */ - -{"frestore", one(0xF140), one(0xF1C0), "Id&s", mfloat }, -{"frestore", one(0xF158), one(0xF1F8), "Id+s", mfloat }, -{"fsave", one(0xF100), one(0xF1C0), "Id&s", mfloat }, -{"fsave", one(0xF120), one(0xF1F8), "Id-s", mfloat }, - -{"fscaleb", two(0xF000, 0x5826), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat }, -{"fscaled", two(0xF000, 0x5426), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat }, -{"fscalel", two(0xF000, 0x4026), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat }, -{"fscalep", two(0xF000, 0x4C26), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat }, -{"fscales", two(0xF000, 0x4426), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat }, -{"fscalew", two(0xF000, 0x5026), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat }, -{"fscalex", two(0xF000, 0x0026), two(0xF1C0, 0xE07F), "IiF8F7", mfloat }, -{"fscalex", two(0xF000, 0x4826), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat }, -/* {"fscalex", two(0xF000, 0x0026), two(0xF1C0, 0xE07F), "IiFt", mfloat }, JF */ - -/* $ is necessary to prevent the assembler from using PC-relative. - If @ were used, "label: fseq label" could produce "ftrapeq", - because "label" became "pc@label". */ -{"fseq", two(0xF040, 0x0001), two(0xF1C0, 0xFFFF), "Ii$s", mfloat }, -{"fsf", two(0xF040, 0x0000), two(0xF1C0, 0xFFFF), "Ii$s", mfloat }, -{"fsge", two(0xF040, 0x0013), two(0xF1C0, 0xFFFF), "Ii$s", mfloat }, -{"fsgl", two(0xF040, 0x0016), two(0xF1C0, 0xFFFF), "Ii$s", mfloat }, -{"fsgle", two(0xF040, 0x0017), two(0xF1C0, 0xFFFF), "Ii$s", mfloat }, -{"fsgt", two(0xF040, 0x0012), two(0xF1C0, 0xFFFF), "Ii$s", mfloat }, -{"fsle", two(0xF040, 0x0015), two(0xF1C0, 0xFFFF), "Ii$s", mfloat }, -{"fslt", two(0xF040, 0x0014), two(0xF1C0, 0xFFFF), "Ii$s", mfloat }, -{"fsne", two(0xF040, 0x000E), two(0xF1C0, 0xFFFF), "Ii$s", mfloat }, -{"fsnge", two(0xF040, 0x001C), two(0xF1C0, 0xFFFF), "Ii$s", mfloat }, -{"fsngl", two(0xF040, 0x0019), two(0xF1C0, 0xFFFF), "Ii$s", mfloat }, -{"fsngle", two(0xF040, 0x0018), two(0xF1C0, 0xFFFF), "Ii$s", mfloat }, -{"fsngt", two(0xF040, 0x001D), two(0xF1C0, 0xFFFF), "Ii$s", mfloat }, -{"fsnle", two(0xF040, 0x001A), two(0xF1C0, 0xFFFF), "Ii$s", mfloat }, -{"fsnlt", two(0xF040, 0x001B), two(0xF1C0, 0xFFFF), "Ii$s", mfloat }, -{"fsoge", two(0xF040, 0x0003), two(0xF1C0, 0xFFFF), "Ii$s", mfloat }, -{"fsogl", two(0xF040, 0x0006), two(0xF1C0, 0xFFFF), "Ii$s", mfloat }, -{"fsogt", two(0xF040, 0x0002), two(0xF1C0, 0xFFFF), "Ii$s", mfloat }, -{"fsole", two(0xF040, 0x0005), two(0xF1C0, 0xFFFF), "Ii$s", mfloat }, -{"fsolt", two(0xF040, 0x0004), two(0xF1C0, 0xFFFF), "Ii$s", mfloat }, -{"fsor", two(0xF040, 0x0007), two(0xF1C0, 0xFFFF), "Ii$s", mfloat }, -{"fsseq", two(0xF040, 0x0011), two(0xF1C0, 0xFFFF), "Ii$s", mfloat }, -{"fssf", two(0xF040, 0x0010), two(0xF1C0, 0xFFFF), "Ii$s", mfloat }, -{"fssne", two(0xF040, 0x001E), two(0xF1C0, 0xFFFF), "Ii$s", mfloat }, -{"fsst", two(0xF040, 0x001F), two(0xF1C0, 0xFFFF), "Ii$s", mfloat }, -{"fst", two(0xF040, 0x000F), two(0xF1C0, 0xFFFF), "Ii$s", mfloat }, -{"fsueq", two(0xF040, 0x0009), two(0xF1C0, 0xFFFF), "Ii$s", mfloat }, -{"fsuge", two(0xF040, 0x000B), two(0xF1C0, 0xFFFF), "Ii$s", mfloat }, -{"fsugt", two(0xF040, 0x000A), two(0xF1C0, 0xFFFF), "Ii$s", mfloat }, -{"fsule", two(0xF040, 0x000D), two(0xF1C0, 0xFFFF), "Ii$s", mfloat }, -{"fsult", two(0xF040, 0x000C), two(0xF1C0, 0xFFFF), "Ii$s", mfloat }, -{"fsun", two(0xF040, 0x0008), two(0xF1C0, 0xFFFF), "Ii$s", mfloat }, - -{"fsgldivb", two(0xF000, 0x5824), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat }, -{"fsgldivd", two(0xF000, 0x5424), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat }, -{"fsgldivl", two(0xF000, 0x4024), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat }, -{"fsgldivp", two(0xF000, 0x4C24), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat }, -{"fsgldivs", two(0xF000, 0x4424), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat }, -{"fsgldivw", two(0xF000, 0x5024), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat }, -{"fsgldivx", two(0xF000, 0x0024), two(0xF1C0, 0xE07F), "IiF8F7", mfloat }, -{"fsgldivx", two(0xF000, 0x4824), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat }, -{"fsgldivx", two(0xF000, 0x0024), two(0xF1C0, 0xE07F), "IiFt", mfloat }, - -{"fsglmulb", two(0xF000, 0x5827), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat }, -{"fsglmuld", two(0xF000, 0x5427), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat }, -{"fsglmull", two(0xF000, 0x4027), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat }, -{"fsglmulp", two(0xF000, 0x4C27), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat }, -{"fsglmuls", two(0xF000, 0x4427), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat }, -{"fsglmulw", two(0xF000, 0x5027), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat }, -{"fsglmulx", two(0xF000, 0x0027), two(0xF1C0, 0xE07F), "IiF8F7", mfloat }, -{"fsglmulx", two(0xF000, 0x4827), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat }, -{"fsglmulx", two(0xF000, 0x0027), two(0xF1C0, 0xE07F), "IiFt", mfloat }, - -{"fsinb", two(0xF000, 0x580E), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat }, -{"fsind", two(0xF000, 0x540E), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat }, -{"fsinl", two(0xF000, 0x400E), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat }, -{"fsinp", two(0xF000, 0x4C0E), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat }, -{"fsins", two(0xF000, 0x440E), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat }, -{"fsinw", two(0xF000, 0x500E), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat }, -{"fsinx", two(0xF000, 0x000E), two(0xF1C0, 0xE07F), "IiF8F7", mfloat }, -{"fsinx", two(0xF000, 0x480E), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat }, -{"fsinx", two(0xF000, 0x000E), two(0xF1C0, 0xE07F), "IiFt", mfloat }, - -{"fsinhb", two(0xF000, 0x5802), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat }, -{"fsinhd", two(0xF000, 0x5402), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat }, -{"fsinhl", two(0xF000, 0x4002), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat }, -{"fsinhp", two(0xF000, 0x4C02), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat }, -{"fsinhs", two(0xF000, 0x4402), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat }, -{"fsinhw", two(0xF000, 0x5002), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat }, -{"fsinhx", two(0xF000, 0x0002), two(0xF1C0, 0xE07F), "IiF8F7", mfloat }, -{"fsinhx", two(0xF000, 0x4802), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat }, -{"fsinhx", two(0xF000, 0x0002), two(0xF1C0, 0xE07F), "IiFt", mfloat }, - -{"fsincosb", two(0xF000, 0x5830), two(0xF1C0, 0xFC78), "Ii;bF3F7", mfloat }, -{"fsincosd", two(0xF000, 0x5430), two(0xF1C0, 0xFC78), "Ii;FF3F7", mfloat }, -{"fsincosl", two(0xF000, 0x4030), two(0xF1C0, 0xFC78), "Ii;lF3F7", mfloat }, -{"fsincosp", two(0xF000, 0x4C30), two(0xF1C0, 0xFC78), "Ii;pF3F7", mfloat }, -{"fsincoss", two(0xF000, 0x4430), two(0xF1C0, 0xFC78), "Ii;fF3F7", mfloat }, -{"fsincosw", two(0xF000, 0x5030), two(0xF1C0, 0xFC78), "Ii;wF3F7", mfloat }, -{"fsincosx", two(0xF000, 0x0030), two(0xF1C0, 0xE078), "IiF8F3F7", mfloat }, -{"fsincosx", two(0xF000, 0x4830), two(0xF1C0, 0xFC78), "Ii;xF3F7", mfloat }, - -{"fsqrtb", two(0xF000, 0x5804), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat }, -{"fsqrtd", two(0xF000, 0x5404), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat }, -{"fsqrtl", two(0xF000, 0x4004), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat }, -{"fsqrtp", two(0xF000, 0x4C04), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat }, -{"fsqrts", two(0xF000, 0x4404), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat }, -{"fsqrtw", two(0xF000, 0x5004), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat }, -{"fsqrtx", two(0xF000, 0x0004), two(0xF1C0, 0xE07F), "IiF8F7", mfloat }, -{"fsqrtx", two(0xF000, 0x4804), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat }, -{"fsqrtx", two(0xF000, 0x0004), two(0xF1C0, 0xE07F), "IiFt", mfloat }, - -{"fssqrtb", two(0xF000, 0x5841), two(0xF1C0, 0xFC7F), "Ii;bF7", m68040 }, -{"fssqrtd", two(0xF000, 0x5441), two(0xF1C0, 0xFC7F), "Ii;FF7", m68040 }, -{"fssqrtl", two(0xF000, 0x4041), two(0xF1C0, 0xFC7F), "Ii;lF7", m68040 }, -{"fssqrtp", two(0xF000, 0x4C41), two(0xF1C0, 0xFC7F), "Ii;pF7", m68040 }, -{"fssqrts", two(0xF000, 0x4441), two(0xF1C0, 0xFC7F), "Ii;fF7", m68040 }, -{"fssqrtw", two(0xF000, 0x5041), two(0xF1C0, 0xFC7F), "Ii;wF7", m68040 }, -{"fssqrtx", two(0xF000, 0x0041), two(0xF1C0, 0xE07F), "IiF8F7", m68040 }, -{"fssqrtx", two(0xF000, 0x4841), two(0xF1C0, 0xFC7F), "Ii;xF7", m68040 }, -{"fssqrtx", two(0xF000, 0x0041), two(0xF1C0, 0xE07F), "IiFt", m68040 }, - -{"fdsqrtb", two(0xF000, 0x5845), two(0xF1C0, 0xFC7F), "Ii;bF7", m68040 }, -{"fdsqrtd", two(0xF000, 0x5445), two(0xF1C0, 0xFC7F), "Ii;FF7", m68040 }, -{"fdsqrtl", two(0xF000, 0x4045), two(0xF1C0, 0xFC7F), "Ii;lF7", m68040 }, -{"fdsqrtp", two(0xF000, 0x4C45), two(0xF1C0, 0xFC7F), "Ii;pF7", m68040 }, -{"fdsqrts", two(0xF000, 0x4445), two(0xF1C0, 0xFC7F), "Ii;fF7", m68040 }, -{"fdsqrtw", two(0xF000, 0x5045), two(0xF1C0, 0xFC7F), "Ii;wF7", m68040 }, -{"fdsqrtx", two(0xF000, 0x0045), two(0xF1C0, 0xE07F), "IiF8F7", m68040 }, -{"fdsqrtx", two(0xF000, 0x4845), two(0xF1C0, 0xFC7F), "Ii;xF7", m68040 }, -{"fdsqrtx", two(0xF000, 0x0045), two(0xF1C0, 0xE07F), "IiFt", m68040 }, - -{"fsubb", two(0xF000, 0x5828), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat }, -{"fsubd", two(0xF000, 0x5428), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat }, -{"fsubl", two(0xF000, 0x4028), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat }, -{"fsubp", two(0xF000, 0x4C28), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat }, -{"fsubs", two(0xF000, 0x4428), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat }, -{"fsubw", two(0xF000, 0x5028), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat }, -{"fsubx", two(0xF000, 0x0028), two(0xF1C0, 0xE07F), "IiF8F7", mfloat }, -{"fsubx", two(0xF000, 0x4828), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat }, -{"fsubx", two(0xF000, 0x0028), two(0xF1C0, 0xE07F), "IiFt", mfloat }, - -{"fssubb", two(0xF000, 0x5838), two(0xF1C0, 0xFC7F), "Ii;bF7", m68040 }, -{"fssubd", two(0xF000, 0x5438), two(0xF1C0, 0xFC7F), "Ii;FF7", m68040 }, -{"fssubl", two(0xF000, 0x4038), two(0xF1C0, 0xFC7F), "Ii;lF7", m68040 }, -{"fssubp", two(0xF000, 0x4C38), two(0xF1C0, 0xFC7F), "Ii;pF7", m68040 }, -{"fssubs", two(0xF000, 0x4438), two(0xF1C0, 0xFC7F), "Ii;fF7", m68040 }, -{"fssubw", two(0xF000, 0x5038), two(0xF1C0, 0xFC7F), "Ii;wF7", m68040 }, -{"fssubx", two(0xF000, 0x0038), two(0xF1C0, 0xE07F), "IiF8F7", m68040 }, -{"fssubx", two(0xF000, 0x4838), two(0xF1C0, 0xFC7F), "Ii;xF7", m68040 }, -{"fssubx", two(0xF000, 0x0038), two(0xF1C0, 0xE07F), "IiFt", m68040 }, - -{"fdsubb", two(0xF000, 0x583c), two(0xF1C0, 0xFC7F), "Ii;bF7", m68040 }, -{"fdsubd", two(0xF000, 0x543c), two(0xF1C0, 0xFC7F), "Ii;FF7", m68040 }, -{"fdsubl", two(0xF000, 0x403c), two(0xF1C0, 0xFC7F), "Ii;lF7", m68040 }, -{"fdsubp", two(0xF000, 0x4C3c), two(0xF1C0, 0xFC7F), "Ii;pF7", m68040 }, -{"fdsubs", two(0xF000, 0x443c), two(0xF1C0, 0xFC7F), "Ii;fF7", m68040 }, -{"fdsubw", two(0xF000, 0x503c), two(0xF1C0, 0xFC7F), "Ii;wF7", m68040 }, -{"fdsubx", two(0xF000, 0x003c), two(0xF1C0, 0xE07F), "IiF8F7", m68040 }, -{"fdsubx", two(0xF000, 0x483c), two(0xF1C0, 0xFC7F), "Ii;xF7", m68040 }, -{"fdsubx", two(0xF000, 0x003c), two(0xF1C0, 0xE07F), "IiFt", m68040 }, - -{"ftanb", two(0xF000, 0x580F), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat }, -{"ftand", two(0xF000, 0x540F), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat }, -{"ftanl", two(0xF000, 0x400F), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat }, -{"ftanp", two(0xF000, 0x4C0F), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat }, -{"ftans", two(0xF000, 0x440F), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat }, -{"ftanw", two(0xF000, 0x500F), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat }, -{"ftanx", two(0xF000, 0x000F), two(0xF1C0, 0xE07F), "IiF8F7", mfloat }, -{"ftanx", two(0xF000, 0x480F), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat }, -{"ftanx", two(0xF000, 0x000F), two(0xF1C0, 0xE07F), "IiFt", mfloat }, - -{"ftanhb", two(0xF000, 0x5809), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat }, -{"ftanhd", two(0xF000, 0x5409), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat }, -{"ftanhl", two(0xF000, 0x4009), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat }, -{"ftanhp", two(0xF000, 0x4C09), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat }, -{"ftanhs", two(0xF000, 0x4409), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat }, -{"ftanhw", two(0xF000, 0x5009), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat }, -{"ftanhx", two(0xF000, 0x0009), two(0xF1C0, 0xE07F), "IiF8F7", mfloat }, -{"ftanhx", two(0xF000, 0x4809), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat }, -{"ftanhx", two(0xF000, 0x0009), two(0xF1C0, 0xE07F), "IiFt", mfloat }, - -{"ftentoxb", two(0xF000, 0x5812), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat }, -{"ftentoxd", two(0xF000, 0x5412), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat }, -{"ftentoxl", two(0xF000, 0x4012), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat }, -{"ftentoxp", two(0xF000, 0x4C12), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat }, -{"ftentoxs", two(0xF000, 0x4412), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat }, -{"ftentoxw", two(0xF000, 0x5012), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat }, -{"ftentoxx", two(0xF000, 0x0012), two(0xF1C0, 0xE07F), "IiF8F7", mfloat }, -{"ftentoxx", two(0xF000, 0x4812), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat }, -{"ftentoxx", two(0xF000, 0x0012), two(0xF1C0, 0xE07F), "IiFt", mfloat }, - -{"ftrapeq", two(0xF07C, 0x0001), two(0xF1FF, 0xFFFF), "Ii", mfloat }, -{"ftrapf", two(0xF07C, 0x0000), two(0xF1FF, 0xFFFF), "Ii", mfloat }, -{"ftrapge", two(0xF07C, 0x0013), two(0xF1FF, 0xFFFF), "Ii", mfloat }, -{"ftrapgl", two(0xF07C, 0x0016), two(0xF1FF, 0xFFFF), "Ii", mfloat }, -{"ftrapgle", two(0xF07C, 0x0017), two(0xF1FF, 0xFFFF), "Ii", mfloat }, -{"ftrapgt", two(0xF07C, 0x0012), two(0xF1FF, 0xFFFF), "Ii", mfloat }, -{"ftraple", two(0xF07C, 0x0015), two(0xF1FF, 0xFFFF), "Ii", mfloat }, -{"ftraplt", two(0xF07C, 0x0014), two(0xF1FF, 0xFFFF), "Ii", mfloat }, -{"ftrapne", two(0xF07C, 0x000E), two(0xF1FF, 0xFFFF), "Ii", mfloat }, -{"ftrapnge", two(0xF07C, 0x001C), two(0xF1FF, 0xFFFF), "Ii", mfloat }, -{"ftrapngl", two(0xF07C, 0x0019), two(0xF1FF, 0xFFFF), "Ii", mfloat }, -{"ftrapngle", two(0xF07C, 0x0018), two(0xF1FF, 0xFFFF), "Ii", mfloat }, -{"ftrapngt", two(0xF07C, 0x001D), two(0xF1FF, 0xFFFF), "Ii", mfloat }, -{"ftrapnle", two(0xF07C, 0x001A), two(0xF1FF, 0xFFFF), "Ii", mfloat }, -{"ftrapnlt", two(0xF07C, 0x001B), two(0xF1FF, 0xFFFF), "Ii", mfloat }, -{"ftrapoge", two(0xF07C, 0x0003), two(0xF1FF, 0xFFFF), "Ii", mfloat }, -{"ftrapogl", two(0xF07C, 0x0006), two(0xF1FF, 0xFFFF), "Ii", mfloat }, -{"ftrapogt", two(0xF07C, 0x0002), two(0xF1FF, 0xFFFF), "Ii", mfloat }, -{"ftrapole", two(0xF07C, 0x0005), two(0xF1FF, 0xFFFF), "Ii", mfloat }, -{"ftrapolt", two(0xF07C, 0x0004), two(0xF1FF, 0xFFFF), "Ii", mfloat }, -{"ftrapor", two(0xF07C, 0x0007), two(0xF1FF, 0xFFFF), "Ii", mfloat }, -{"ftrapseq", two(0xF07C, 0x0011), two(0xF1FF, 0xFFFF), "Ii", mfloat }, -{"ftrapsf", two(0xF07C, 0x0010), two(0xF1FF, 0xFFFF), "Ii", mfloat }, -{"ftrapsne", two(0xF07C, 0x001E), two(0xF1FF, 0xFFFF), "Ii", mfloat }, -{"ftrapst", two(0xF07C, 0x001F), two(0xF1FF, 0xFFFF), "Ii", mfloat }, -{"ftrapt", two(0xF07C, 0x000F), two(0xF1FF, 0xFFFF), "Ii", mfloat }, -{"ftrapueq", two(0xF07C, 0x0009), two(0xF1FF, 0xFFFF), "Ii", mfloat }, -{"ftrapuge", two(0xF07C, 0x000B), two(0xF1FF, 0xFFFF), "Ii", mfloat }, -{"ftrapugt", two(0xF07C, 0x000A), two(0xF1FF, 0xFFFF), "Ii", mfloat }, -{"ftrapule", two(0xF07C, 0x000D), two(0xF1FF, 0xFFFF), "Ii", mfloat }, -{"ftrapult", two(0xF07C, 0x000C), two(0xF1FF, 0xFFFF), "Ii", mfloat }, -{"ftrapun", two(0xF07C, 0x0008), two(0xF1FF, 0xFFFF), "Ii", mfloat }, - -{"ftrapeqw", two(0xF07A, 0x0001), two(0xF1FF, 0xFFFF), "Ii^w", mfloat }, -{"ftrapfw", two(0xF07A, 0x0000), two(0xF1FF, 0xFFFF), "Ii^w", mfloat }, -{"ftrapgew", two(0xF07A, 0x0013), two(0xF1FF, 0xFFFF), "Ii^w", mfloat }, -{"ftrapglw", two(0xF07A, 0x0016), two(0xF1FF, 0xFFFF), "Ii^w", mfloat }, -{"ftrapglew", two(0xF07A, 0x0017), two(0xF1FF, 0xFFFF), "Ii^w", mfloat }, -{"ftrapgtw", two(0xF07A, 0x0012), two(0xF1FF, 0xFFFF), "Ii^w", mfloat }, -{"ftraplew", two(0xF07A, 0x0015), two(0xF1FF, 0xFFFF), "Ii^w", mfloat }, -{"ftrapltw", two(0xF07A, 0x0014), two(0xF1FF, 0xFFFF), "Ii^w", mfloat }, -{"ftrapnew", two(0xF07A, 0x000E), two(0xF1FF, 0xFFFF), "Ii^w", mfloat }, -{"ftrapngew", two(0xF07A, 0x001C), two(0xF1FF, 0xFFFF), "Ii^w", mfloat }, -{"ftrapnglw", two(0xF07A, 0x0019), two(0xF1FF, 0xFFFF), "Ii^w", mfloat }, -{"ftrapnglew", two(0xF07A, 0x0018), two(0xF1FF, 0xFFFF), "Ii^w", mfloat }, -{"ftrapngtw", two(0xF07A, 0x001D), two(0xF1FF, 0xFFFF), "Ii^w", mfloat }, -{"ftrapnlew", two(0xF07A, 0x001A), two(0xF1FF, 0xFFFF), "Ii^w", mfloat }, -{"ftrapnltw", two(0xF07A, 0x001B), two(0xF1FF, 0xFFFF), "Ii^w", mfloat }, -{"ftrapogew", two(0xF07A, 0x0003), two(0xF1FF, 0xFFFF), "Ii^w", mfloat }, -{"ftrapoglw", two(0xF07A, 0x0006), two(0xF1FF, 0xFFFF), "Ii^w", mfloat }, -{"ftrapogtw", two(0xF07A, 0x0002), two(0xF1FF, 0xFFFF), "Ii^w", mfloat }, -{"ftrapolew", two(0xF07A, 0x0005), two(0xF1FF, 0xFFFF), "Ii^w", mfloat }, -{"ftrapoltw", two(0xF07A, 0x0004), two(0xF1FF, 0xFFFF), "Ii^w", mfloat }, -{"ftraporw", two(0xF07A, 0x0007), two(0xF1FF, 0xFFFF), "Ii^w", mfloat }, -{"ftrapseqw", two(0xF07A, 0x0011), two(0xF1FF, 0xFFFF), "Ii^w", mfloat }, -{"ftrapsfw", two(0xF07A, 0x0010), two(0xF1FF, 0xFFFF), "Ii^w", mfloat }, -{"ftrapsnew", two(0xF07A, 0x001E), two(0xF1FF, 0xFFFF), "Ii^w", mfloat }, -{"ftrapstw", two(0xF07A, 0x001F), two(0xF1FF, 0xFFFF), "Ii^w", mfloat }, -{"ftraptw", two(0xF07A, 0x000F), two(0xF1FF, 0xFFFF), "Ii^w", mfloat }, -{"ftrapueqw", two(0xF07A, 0x0009), two(0xF1FF, 0xFFFF), "Ii^w", mfloat }, -{"ftrapugew", two(0xF07A, 0x000B), two(0xF1FF, 0xFFFF), "Ii^w", mfloat }, -{"ftrapugtw", two(0xF07A, 0x000A), two(0xF1FF, 0xFFFF), "Ii^w", mfloat }, -{"ftrapulew", two(0xF07A, 0x000D), two(0xF1FF, 0xFFFF), "Ii^w", mfloat }, -{"ftrapultw", two(0xF07A, 0x000C), two(0xF1FF, 0xFFFF), "Ii^w", mfloat }, -{"ftrapunw", two(0xF07A, 0x0008), two(0xF1FF, 0xFFFF), "Ii^w", mfloat }, - -{"ftrapeql", two(0xF07B, 0x0001), two(0xF1FF, 0xFFFF), "Ii^l", mfloat }, -{"ftrapfl", two(0xF07B, 0x0000), two(0xF1FF, 0xFFFF), "Ii^l", mfloat }, -{"ftrapgel", two(0xF07B, 0x0013), two(0xF1FF, 0xFFFF), "Ii^l", mfloat }, -{"ftrapgll", two(0xF07B, 0x0016), two(0xF1FF, 0xFFFF), "Ii^l", mfloat }, -{"ftrapglel", two(0xF07B, 0x0017), two(0xF1FF, 0xFFFF), "Ii^l", mfloat }, -{"ftrapgtl", two(0xF07B, 0x0012), two(0xF1FF, 0xFFFF), "Ii^l", mfloat }, -{"ftraplel", two(0xF07B, 0x0015), two(0xF1FF, 0xFFFF), "Ii^l", mfloat }, -{"ftrapltl", two(0xF07B, 0x0014), two(0xF1FF, 0xFFFF), "Ii^l", mfloat }, -{"ftrapnel", two(0xF07B, 0x000E), two(0xF1FF, 0xFFFF), "Ii^l", mfloat }, -{"ftrapngel", two(0xF07B, 0x001C), two(0xF1FF, 0xFFFF), "Ii^l", mfloat }, -{"ftrapngll", two(0xF07B, 0x0019), two(0xF1FF, 0xFFFF), "Ii^l", mfloat }, -{"ftrapnglel", two(0xF07B, 0x0018), two(0xF1FF, 0xFFFF), "Ii^l", mfloat }, -{"ftrapngtl", two(0xF07B, 0x001D), two(0xF1FF, 0xFFFF), "Ii^l", mfloat }, -{"ftrapnlel", two(0xF07B, 0x001A), two(0xF1FF, 0xFFFF), "Ii^l", mfloat }, -{"ftrapnltl", two(0xF07B, 0x001B), two(0xF1FF, 0xFFFF), "Ii^l", mfloat }, -{"ftrapogel", two(0xF07B, 0x0003), two(0xF1FF, 0xFFFF), "Ii^l", mfloat }, -{"ftrapogll", two(0xF07B, 0x0006), two(0xF1FF, 0xFFFF), "Ii^l", mfloat }, -{"ftrapogtl", two(0xF07B, 0x0002), two(0xF1FF, 0xFFFF), "Ii^l", mfloat }, -{"ftrapolel", two(0xF07B, 0x0005), two(0xF1FF, 0xFFFF), "Ii^l", mfloat }, -{"ftrapoltl", two(0xF07B, 0x0004), two(0xF1FF, 0xFFFF), "Ii^l", mfloat }, -{"ftraporl", two(0xF07B, 0x0007), two(0xF1FF, 0xFFFF), "Ii^l", mfloat }, -{"ftrapseql", two(0xF07B, 0x0011), two(0xF1FF, 0xFFFF), "Ii^l", mfloat }, -{"ftrapsfl", two(0xF07B, 0x0010), two(0xF1FF, 0xFFFF), "Ii^l", mfloat }, -{"ftrapsnel", two(0xF07B, 0x001E), two(0xF1FF, 0xFFFF), "Ii^l", mfloat }, -{"ftrapstl", two(0xF07B, 0x001F), two(0xF1FF, 0xFFFF), "Ii^l", mfloat }, -{"ftraptl", two(0xF07B, 0x000F), two(0xF1FF, 0xFFFF), "Ii^l", mfloat }, -{"ftrapueql", two(0xF07B, 0x0009), two(0xF1FF, 0xFFFF), "Ii^l", mfloat }, -{"ftrapugel", two(0xF07B, 0x000B), two(0xF1FF, 0xFFFF), "Ii^l", mfloat }, -{"ftrapugtl", two(0xF07B, 0x000A), two(0xF1FF, 0xFFFF), "Ii^l", mfloat }, -{"ftrapulel", two(0xF07B, 0x000D), two(0xF1FF, 0xFFFF), "Ii^l", mfloat }, -{"ftrapultl", two(0xF07B, 0x000C), two(0xF1FF, 0xFFFF), "Ii^l", mfloat }, -{"ftrapunl", two(0xF07B, 0x0008), two(0xF1FF, 0xFFFF), "Ii^l", mfloat }, - -{"ftstb", two(0xF000, 0x583A), two(0xF1C0, 0xFC7F), "Ii;b", mfloat }, -{"ftstd", two(0xF000, 0x543A), two(0xF1C0, 0xFC7F), "Ii;F", mfloat }, -{"ftstl", two(0xF000, 0x403A), two(0xF1C0, 0xFC7F), "Ii;l", mfloat }, -{"ftstp", two(0xF000, 0x4C3A), two(0xF1C0, 0xFC7F), "Ii;p", mfloat }, -{"ftsts", two(0xF000, 0x443A), two(0xF1C0, 0xFC7F), "Ii;f", mfloat }, -{"ftstw", two(0xF000, 0x503A), two(0xF1C0, 0xFC7F), "Ii;w", mfloat }, -{"ftstx", two(0xF000, 0x003A), two(0xF1C0, 0xE07F), "IiF8", mfloat }, -{"ftstx", two(0xF000, 0x483A), two(0xF1C0, 0xFC7F), "Ii;x", mfloat }, - -{"ftwotoxb", two(0xF000, 0x5811), two(0xF1C0, 0xFC7F), "Ii;bF7", mfloat }, -{"ftwotoxd", two(0xF000, 0x5411), two(0xF1C0, 0xFC7F), "Ii;FF7", mfloat }, -{"ftwotoxl", two(0xF000, 0x4011), two(0xF1C0, 0xFC7F), "Ii;lF7", mfloat }, -{"ftwotoxp", two(0xF000, 0x4C11), two(0xF1C0, 0xFC7F), "Ii;pF7", mfloat }, -{"ftwotoxs", two(0xF000, 0x4411), two(0xF1C0, 0xFC7F), "Ii;fF7", mfloat }, -{"ftwotoxw", two(0xF000, 0x5011), two(0xF1C0, 0xFC7F), "Ii;wF7", mfloat }, -{"ftwotoxx", two(0xF000, 0x0011), two(0xF1C0, 0xE07F), "IiF8F7", mfloat }, -{"ftwotoxx", two(0xF000, 0x4811), two(0xF1C0, 0xFC7F), "Ii;xF7", mfloat }, -{"ftwotoxx", two(0xF000, 0x0011), two(0xF1C0, 0xE07F), "IiFt", mfloat }, - -/* Variable-sized float branches */ - -{"fjeq", one(0xF081), one(0xF1FF), "IdBc", mfloat }, -{"fjf", one(0xF080), one(0xF1FF), "IdBc", mfloat }, -{"fjge", one(0xF093), one(0xF1FF), "IdBc", mfloat }, -{"fjgl", one(0xF096), one(0xF1FF), "IdBc", mfloat }, -{"fjgle", one(0xF097), one(0xF1FF), "IdBc", mfloat }, -{"fjgt", one(0xF092), one(0xF1FF), "IdBc", mfloat }, -{"fjle", one(0xF095), one(0xF1FF), "IdBc", mfloat }, -{"fjlt", one(0xF094), one(0xF1FF), "IdBc", mfloat }, -{"fjne", one(0xF08E), one(0xF1FF), "IdBc", mfloat }, -{"fjnge", one(0xF09C), one(0xF1FF), "IdBc", mfloat }, -{"fjngl", one(0xF099), one(0xF1FF), "IdBc", mfloat }, -{"fjngle", one(0xF098), one(0xF1FF), "IdBc", mfloat }, -{"fjngt", one(0xF09D), one(0xF1FF), "IdBc", mfloat }, -{"fjnle", one(0xF09A), one(0xF1FF), "IdBc", mfloat }, -{"fjnlt", one(0xF09B), one(0xF1FF), "IdBc", mfloat }, -{"fjoge", one(0xF083), one(0xF1FF), "IdBc", mfloat }, -{"fjogl", one(0xF086), one(0xF1FF), "IdBc", mfloat }, -{"fjogt", one(0xF082), one(0xF1FF), "IdBc", mfloat }, -{"fjole", one(0xF085), one(0xF1FF), "IdBc", mfloat }, -{"fjolt", one(0xF084), one(0xF1FF), "IdBc", mfloat }, -{"fjor", one(0xF087), one(0xF1FF), "IdBc", mfloat }, -{"fjseq", one(0xF091), one(0xF1FF), "IdBc", mfloat }, -{"fjsf", one(0xF090), one(0xF1FF), "IdBc", mfloat }, -{"fjsne", one(0xF09E), one(0xF1FF), "IdBc", mfloat }, -{"fjst", one(0xF09F), one(0xF1FF), "IdBc", mfloat }, -{"fjt", one(0xF08F), one(0xF1FF), "IdBc", mfloat }, -{"fjueq", one(0xF089), one(0xF1FF), "IdBc", mfloat }, -{"fjuge", one(0xF08B), one(0xF1FF), "IdBc", mfloat }, -{"fjugt", one(0xF08A), one(0xF1FF), "IdBc", mfloat }, -{"fjule", one(0xF08D), one(0xF1FF), "IdBc", mfloat }, -{"fjult", one(0xF08C), one(0xF1FF), "IdBc", mfloat }, -{"fjun", one(0xF088), one(0xF1FF), "IdBc", mfloat }, -/* float stuff ends here */ - -{"illegal", one(0045374), one(0177777), "", m68000up }, -{"jmp", one(0047300), one(0177700), "!s", m68000up }, -{"jsr", one(0047200), one(0177700), "!s", m68000up }, -{"lea", one(0040700), one(0170700), "!sAd", m68000up }, -{"linkw", one(0047120), one(0177770), "As#w", m68000up }, -{"linkl", one(0044010), one(0177770), "As#l", m68020up }, -{"link", one(0047120), one(0177770), "As#w", m68000up }, -{"link", one(0044010), one(0177770), "As#l", m68020up }, - -{"lslb", one(0160410), one(0170770), "QdDs", m68000up }, /* lsrb #Q, Ds */ -{"lslb", one(0160450), one(0170770), "DdDs", m68000up }, /* lsrb Dd, Ds */ -{"lslw", one(0160510), one(0170770), "QdDs", m68000up }, /* lsrb #Q, Ds */ -{"lslw", one(0160550), one(0170770), "DdDs", m68000up }, /* lsrb Dd, Ds */ -{"lslw", one(0161700), one(0177700), "~s", m68000up }, /* Shift memory */ -{"lsll", one(0160610), one(0170770), "QdDs", m68000up }, /* lsrb #Q, Ds */ -{"lsll", one(0160650), one(0170770), "DdDs", m68000up }, /* lsrb Dd, Ds */ - -{"lsrb", one(0160010), one(0170770), "QdDs", m68000up }, /* lsrb #Q, Ds */ -{"lsrb", one(0160050), one(0170770), "DdDs", m68000up }, /* lsrb Dd, Ds */ -{"lsrl", one(0160210), one(0170770), "QdDs", m68000up }, /* lsrb #Q, Ds */ -{"lsrl", one(0160250), one(0170770), "DdDs", m68000up }, /* lsrb #Q, Ds */ -{"lsrw", one(0160110), one(0170770), "QdDs", m68000up }, /* lsrb #Q, Ds */ -{"lsrw", one(0160150), one(0170770), "DdDs", m68000up }, /* lsrb #Q, Ds */ -{"lsrw", one(0161300), one(0177700), "~s", m68000up }, /* Shift memory */ - -{"moveal", one(0020100), one(0170700), "*lAd", m68000up }, -{"moveaw", one(0030100), one(0170700), "*wAd", m68000up }, -{"moveb", one(0010000), one(0170000), ";b$d", m68000up }, /* move */ -{"movel", one(0070000), one(0170400), "MsDd", m68000up }, /* moveq written as move */ -{"movel", one(0020000), one(0170000), "*l$d", m68000up }, -{"movel", one(0020100), one(0170700), "*lAd", m68000up }, -{"movel", one(0047140), one(0177770), "AsUd", m68000up }, /* move to USP */ -{"movel", one(0047150), one(0177770), "UdAs", m68000up }, /* move from USP */ - -{"movec", one(0047173), one(0177777), "R1Jj", m68010up }, -{"movec", one(0047173), one(0177777), "R1#j", m68010up }, -{"movec", one(0047172), one(0177777), "JjR1", m68010up }, -{"movec", one(0047172), one(0177777), "#jR1", m68010up }, - -/* JF added these next four for the assembler */ -{"moveml", one(0044300), one(0177700), "Lw&s", m68000up }, /* movem reg to mem. */ -{"moveml", one(0044340), one(0177770), "lw-s", m68000up }, /* movem reg to autodecrement. */ -{"moveml", one(0046300), one(0177700), "!sLw", m68000up }, /* movem mem to reg. */ -{"moveml", one(0046330), one(0177770), "+sLw", m68000up }, /* movem autoinc to reg. */ - -{"moveml", one(0044300), one(0177700), "#w&s", m68000up }, /* movem reg to mem. */ -{"moveml", one(0044340), one(0177770), "#w-s", m68000up }, /* movem reg to autodecrement. */ -{"moveml", one(0046300), one(0177700), "!s#w", m68000up }, /* movem mem to reg. */ -{"moveml", one(0046330), one(0177770), "+s#w", m68000up }, /* movem autoinc to reg. */ - -/* JF added these next four for the assembler */ -{"movemw", one(0044200), one(0177700), "Lw&s", m68000up }, /* movem reg to mem. */ -{"movemw", one(0044240), one(0177770), "lw-s", m68000up }, /* movem reg to autodecrement. */ -{"movemw", one(0046200), one(0177700), "!sLw", m68000up }, /* movem mem to reg. */ -{"movemw", one(0046230), one(0177770), "+sLw", m68000up }, /* movem autoinc to reg. */ - -{"movemw", one(0044200), one(0177700), "#w&s", m68000up }, /* movem reg to mem. */ -{"movemw", one(0044240), one(0177770), "#w-s", m68000up }, /* movem reg to autodecrement. */ -{"movemw", one(0046200), one(0177700), "!s#w", m68000up }, /* movem mem to reg. */ -{"movemw", one(0046230), one(0177770), "+s#w", m68000up }, /* movem autoinc to reg. */ - -{"movepl", one(0000510), one(0170770), "dsDd", m68000up }, /* memory to register */ -{"movepl", one(0000710), one(0170770), "Ddds", m68000up }, /* register to memory */ -{"movepw", one(0000410), one(0170770), "dsDd", m68000up }, /* memory to register */ -{"movepw", one(0000610), one(0170770), "Ddds", m68000up }, /* register to memory */ -{"moveq", one(0070000), one(0170400), "MsDd", m68000up }, -{"movew", one(0030000), one(0170000), "*w$d", m68000up }, -{"movew", one(0030100), one(0170700), "*wAd", m68000up }, /* movea, written as move */ -{"movew", one(0040300), one(0177700), "Ss$s", m68000up }, /* Move from sr */ -{"movew", one(0041300), one(0177700), "Cs$s", m68010up }, /* Move from ccr */ -{"movew", one(0042300), one(0177700), ";wCd", m68000up }, /* move to ccr */ -{"movew", one(0043300), one(0177700), ";wSd", m68000up }, /* move to sr */ - -{"movesb", two(0007000, 0), two(0177700, 07777), "~sR1", m68010up }, /* moves from memory */ -{"movesb", two(0007000, 04000), two(0177700, 07777), "R1~s", m68010up }, /* moves to memory */ -{"movesl", two(0007200, 0), two(0177700, 07777), "~sR1", m68010up }, /* moves from memory */ -{"movesl", two(0007200, 04000), two(0177700, 07777), "R1~s", m68010up }, /* moves to memory */ -{"movesw", two(0007100, 0), two(0177700, 07777), "~sR1", m68010up }, /* moves from memory */ -{"movesw", two(0007100, 04000), two(0177700, 07777), "R1~s", m68010up }, /* moves to memory */ - -{"move16", two(0xf620, 0x8000), two(0xfff8, 0x8fff), "+s+1", m68040 }, -{"move16", one(0xf600), one(0xfff8), "+s_L", m68040 }, -{"move16", one(0xf608), one(0xfff8), "_L+s", m68040 }, -{"move16", one(0xf610), one(0xfff8), "as_L", m68040 }, -{"move16", one(0xf618), one(0xfff8), "_Las", m68040 }, - -{"mulsl", two(0046000, 004000), two(0177700, 0107770), ";lD1", m68020up }, -{"mulsl", two(0046000, 006000), two(0177700, 0107770), ";lD3D1", m68020up }, -{"mulsw", one(0140700), one(0170700), ";wDd", m68000up }, -{"muls", one(0140700), one(0170700), ";wDd", m68000up }, -{"mulul", two(0046000, 000000), two(0177700, 0107770), ";lD1", m68020up }, -{"mulul", two(0046000, 002000), two(0177700, 0107770), ";lD3D1", m68020up }, -{"muluw", one(0140300), one(0170700), ";wDd", m68000up }, -{"mulu", one(0140300), one(0170700), ";wDd", m68000up }, -{"nbcd", one(0044000), one(0177700), "$s", m68000up }, -{"negb", one(0042000), one(0177700), "$s", m68000up }, -{"negl", one(0042200), one(0177700), "$s", m68000up }, -{"negw", one(0042100), one(0177700), "$s", m68000up }, -{"negxb", one(0040000), one(0177700), "$s", m68000up }, -{"negxl", one(0040200), one(0177700), "$s", m68000up }, -{"negxw", one(0040100), one(0177700), "$s", m68000up }, -{"nop", one(0047161), one(0177777), "", m68000up }, -{"notb", one(0043000), one(0177700), "$s", m68000up }, -{"notl", one(0043200), one(0177700), "$s", m68000up }, -{"notw", one(0043100), one(0177700), "$s", m68000up }, - -{"orb", one(0000000), one(0177700), "#b$s", m68000up }, /* ori written as or */ -{"orb", one(0000074), one(0177777), "#bCs", m68000up }, /* ori to ccr */ -{"orb", one(0100000), one(0170700), ";bDd", m68000up }, /* memory to register */ -{"orb", one(0100400), one(0170700), "Dd~s", m68000up }, /* register to memory */ -{"orib", one(0000000), one(0177700), "#b$s", m68000up }, -{"orib", one(0000074), one(0177777), "#bCs", m68000up }, /* ori to ccr */ -{"oril", one(0000200), one(0177700), "#l$s", m68000up }, -{"oriw", one(0000100), one(0177700), "#w$s", m68000up }, -{"oriw", one(0000174), one(0177777), "#wSs", m68000up }, /* ori to sr */ -{"orl", one(0000200), one(0177700), "#l$s", m68000up }, -{"orl", one(0100200), one(0170700), ";lDd", m68000up }, /* memory to register */ -{"orl", one(0100600), one(0170700), "Dd~s", m68000up }, /* register to memory */ -{"orw", one(0000100), one(0177700), "#w$s", m68000up }, -{"orw", one(0000174), one(0177777), "#wSs", m68000up }, /* ori to sr */ -{"orw", one(0100100), one(0170700), ";wDd", m68000up }, /* memory to register */ -{"orw", one(0100500), one(0170700), "Dd~s", m68000up }, /* register to memory */ - -{"pack", one(0100500), one(0170770), "DsDd#w", m68020up }, /* pack Ds, Dd, #w */ -{"pack", one(0100510), one(0170770), "-s-d#w", m68020up }, /* pack -(As), -(Ad), #w */ - -#ifndef NO_68851 -{"pbac", one(0xf0c7), one(0xffbf), "Bc", m68851 }, -{"pbacw", one(0xf087), one(0xffbf), "Bc", m68851 }, -{"pbas", one(0xf0c6), one(0xffbf), "Bc", m68851 }, -{"pbasw", one(0xf086), one(0xffbf), "Bc", m68851 }, -{"pbbc", one(0xf0c1), one(0xffbf), "Bc", m68851 }, -{"pbbcw", one(0xf081), one(0xffbf), "Bc", m68851 }, -{"pbbs", one(0xf0c0), one(0xffbf), "Bc", m68851 }, -{"pbbsw", one(0xf080), one(0xffbf), "Bc", m68851 }, -{"pbcc", one(0xf0cf), one(0xffbf), "Bc", m68851 }, -{"pbccw", one(0xf08f), one(0xffbf), "Bc", m68851 }, -{"pbcs", one(0xf0ce), one(0xffbf), "Bc", m68851 }, -{"pbcsw", one(0xf08e), one(0xffbf), "Bc", m68851 }, -{"pbgc", one(0xf0cd), one(0xffbf), "Bc", m68851 }, -{"pbgcw", one(0xf08d), one(0xffbf), "Bc", m68851 }, -{"pbgs", one(0xf0cc), one(0xffbf), "Bc", m68851 }, -{"pbgsw", one(0xf08c), one(0xffbf), "Bc", m68851 }, -{"pbic", one(0xf0cb), one(0xffbf), "Bc", m68851 }, -{"pbicw", one(0xf08b), one(0xffbf), "Bc", m68851 }, -{"pbis", one(0xf0ca), one(0xffbf), "Bc", m68851 }, -{"pbisw", one(0xf08a), one(0xffbf), "Bc", m68851 }, -{"pblc", one(0xf0c3), one(0xffbf), "Bc", m68851 }, -{"pblcw", one(0xf083), one(0xffbf), "Bc", m68851 }, -{"pbls", one(0xf0c2), one(0xffbf), "Bc", m68851 }, -{"pblsw", one(0xf082), one(0xffbf), "Bc", m68851 }, -{"pbsc", one(0xf0c5), one(0xffbf), "Bc", m68851 }, -{"pbscw", one(0xf085), one(0xffbf), "Bc", m68851 }, -{"pbss", one(0xf0c4), one(0xffbf), "Bc", m68851 }, -{"pbssw", one(0xf084), one(0xffbf), "Bc", m68851 }, -{"pbwc", one(0xf0c9), one(0xffbf), "Bc", m68851 }, -{"pbwcw", one(0xf089), one(0xffbf), "Bc", m68851 }, -{"pbws", one(0xf0c8), one(0xffbf), "Bc", m68851 }, -{"pbwsw", one(0xf088), one(0xffbf), "Bc", m68851 }, - -{"pdbac", two(0xf048, 0x0007), two(0xfff8, 0xffff), "DsBw", m68851 }, -{"pdbas", two(0xf048, 0x0006), two(0xfff8, 0xffff), "DsBw", m68851 }, -{"pdbbc", two(0xf048, 0x0001), two(0xfff8, 0xffff), "DsBw", m68851 }, -{"pdbbs", two(0xf048, 0x0000), two(0xfff8, 0xffff), "DsBw", m68851 }, -{"pdbcc", two(0xf048, 0x000f), two(0xfff8, 0xffff), "DsBw", m68851 }, -{"pdbcs", two(0xf048, 0x000e), two(0xfff8, 0xffff), "DsBw", m68851 }, -{"pdbgc", two(0xf048, 0x000d), two(0xfff8, 0xffff), "DsBw", m68851 }, -{"pdbgs", two(0xf048, 0x000c), two(0xfff8, 0xffff), "DsBw", m68851 }, -{"pdbic", two(0xf048, 0x000b), two(0xfff8, 0xffff), "DsBw", m68851 }, -{"pdbis", two(0xf048, 0x000a), two(0xfff8, 0xffff), "DsBw", m68851 }, -{"pdblc", two(0xf048, 0x0003), two(0xfff8, 0xffff), "DsBw", m68851 }, -{"pdbls", two(0xf048, 0x0002), two(0xfff8, 0xffff), "DsBw", m68851 }, -{"pdbsc", two(0xf048, 0x0005), two(0xfff8, 0xffff), "DsBw", m68851 }, -{"pdbss", two(0xf048, 0x0004), two(0xfff8, 0xffff), "DsBw", m68851 }, -{"pdbwc", two(0xf048, 0x0009), two(0xfff8, 0xffff), "DsBw", m68851 }, -{"pdbws", two(0xf048, 0x0008), two(0xfff8, 0xffff), "DsBw", m68851 }, -#endif /* NO_68851 */ - -{"pea", one(0044100), one(0177700), "!s", m68000up }, - -#ifndef NO_68851 -{"pflusha", two(0xf000, 0x2400), two(0xffff, 0xffff), "", m68030 | m68851 }, -{"pflusha", one(0xf510), one(0xfff8), "", m68040 }, - -{"pflush", two(0xf000, 0x3010), two(0xffc0, 0xfe10), "T3T9", m68030 | m68851 }, -{"pflush", two(0xf000, 0x3810), two(0xffc0, 0xfe10), "T3T9&s", m68030 | m68851 }, -{"pflush", two(0xf000, 0x3008), two(0xffc0, 0xfe18), "D3T9", m68030 | m68851 }, -{"pflush", two(0xf000, 0x3808), two(0xffc0, 0xfe18), "D3T9&s", m68030 | m68851 }, -{"pflush", two(0xf000, 0x3000), two(0xffc0, 0xfe1e), "f3T9", m68030 | m68851 }, -{"pflush", two(0xf000, 0x3800), two(0xffc0, 0xfe1e), "f3T9&s", m68030 | m68851 }, -{"pflush", one(0xf500), one(0xfff8), "As", m68040 }, - -{"pflushan", one(0xf518), one(0xfff8), "", m68040 }, -{"pflushn", one(0xf508), one(0xfff8), "As", m68040 }, - -{"pflushr", two(0xf000, 0xa000), two(0xffc0, 0xffff), "|s", m68851 }, - -{"pflushs", two(0xf000, 0x3410), two(0xfff8, 0xfe10), "T3T9", m68851 }, -{"pflushs", two(0xf000, 0x3c10), two(0xfff8, 0xfe00), "T3T9&s", m68851 }, -{"pflushs", two(0xf000, 0x3408), two(0xfff8, 0xfe18), "D3T9", m68851 }, -{"pflushs", two(0xf000, 0x3c08), two(0xfff8, 0xfe18), "D3T9&s", m68851 }, -{"pflushs", two(0xf000, 0x3400), two(0xfff8, 0xfe1e), "f3T9", m68851 }, -{"pflushs", two(0xf000, 0x3c00), two(0xfff8, 0xfe1e), "f3T9&s", m68851 }, - -{"ploadr", two(0xf000, 0x2210), two(0xffc0, 0xfff0), "T3&s", m68030 | m68851 }, -{"ploadr", two(0xf000, 0x2208), two(0xffc0, 0xfff8), "D3&s", m68030 | m68851 }, -{"ploadr", two(0xf000, 0x2200), two(0xffc0, 0xfffe), "f3&s", m68030 | m68851 }, -{"ploadw", two(0xf000, 0x2010), two(0xffc0, 0xfff0), "T3&s", m68030 | m68851 }, -{"ploadw", two(0xf000, 0x2008), two(0xffc0, 0xfff8), "D3&s", m68030 | m68851 }, -{"ploadw", two(0xf000, 0x2000), two(0xffc0, 0xfffe), "f3&s", m68030 | m68851 }, - -/* TC, CRP, DRP, SRP, CAL, VAL, SCC, AC */ -{"pmove", two(0xf000, 0x4000), two(0xffc0, 0xe3ff), "*sP8", m68030 | m68851 }, -{"pmove", two(0xf000, 0x4200), two(0xffc0, 0xe3ff), "P8%s", m68030 | m68851 }, -{"pmove", two(0xf000, 0x4000), two(0xffc0, 0xe3ff), "|sW8", m68030 | m68851 }, -{"pmove", two(0xf000, 0x4200), two(0xffc0, 0xe3ff), "W8~s", m68030 | m68851 }, - -/* BADx, BACx */ -{"pmove", two(0xf000, 0x6200), two(0xffc0, 0xe3e3), "*sX3", m68030 | m68851 }, -{"pmove", two(0xf000, 0x6000), two(0xffc0, 0xe3e3), "X3%s", m68030 | m68851 }, - -/* PSR, PCSR */ -/* {"pmove", two(0xf000, 0x6100), two(oxffc0, oxffff), "*sZ8", m68030 | m68851 }, */ -{"pmove", two(0xf000, 0x6000), two(0xffc0, 0xffff), "*sY8", m68030 | m68851 }, -{"pmove", two(0xf000, 0x6200), two(0xffc0, 0xffff), "Y8%s", m68030 | m68851 }, -{"pmove", two(0xf000, 0x6600), two(0xffc0, 0xffff), "Z8%s", m68030 | m68851 }, - -{"prestore", one(0xf140), one(0xffc0), "&s", m68851 }, -{"prestore", one(0xf158), one(0xfff8), "+s", m68851 }, -{"psave", one(0xf100), one(0xffc0), "&s", m68851 }, -{"psave", one(0xf100), one(0xffc0), "+s", m68851 }, - -{"psac", two(0xf040, 0x0007), two(0xffc0, 0xffff), "@s", m68851 }, -{"psas", two(0xf040, 0x0006), two(0xffc0, 0xffff), "@s", m68851 }, -{"psbc", two(0xf040, 0x0001), two(0xffc0, 0xffff), "@s", m68851 }, -{"psbs", two(0xf040, 0x0000), two(0xffc0, 0xffff), "@s", m68851 }, -{"pscc", two(0xf040, 0x000f), two(0xffc0, 0xffff), "@s", m68851 }, -{"pscs", two(0xf040, 0x000e), two(0xffc0, 0xffff), "@s", m68851 }, -{"psgc", two(0xf040, 0x000d), two(0xffc0, 0xffff), "@s", m68851 }, -{"psgs", two(0xf040, 0x000c), two(0xffc0, 0xffff), "@s", m68851 }, -{"psic", two(0xf040, 0x000b), two(0xffc0, 0xffff), "@s", m68851 }, -{"psis", two(0xf040, 0x000a), two(0xffc0, 0xffff), "@s", m68851 }, -{"pslc", two(0xf040, 0x0003), two(0xffc0, 0xffff), "@s", m68851 }, -{"psls", two(0xf040, 0x0002), two(0xffc0, 0xffff), "@s", m68851 }, -{"pssc", two(0xf040, 0x0005), two(0xffc0, 0xffff), "@s", m68851 }, -{"psss", two(0xf040, 0x0004), two(0xffc0, 0xffff), "@s", m68851 }, -{"pswc", two(0xf040, 0x0009), two(0xffc0, 0xffff), "@s", m68851 }, -{"psws", two(0xf040, 0x0008), two(0xffc0, 0xffff), "@s", m68851 }, - -{"ptestr", two(0xf000, 0x8210), two(0xffc0, 0xe3f0), "T3&sQ8", m68030 | m68851 }, -{"ptestr", two(0xf000, 0x8310), two(0xffc0, 0xe310), "T3&sQ8A9", m68030 | m68851 }, -{"ptestr", two(0xf000, 0x8208), two(0xffc0, 0xe3f8), "D3&sQ8", m68030 | m68851 }, -{"ptestr", two(0xf000, 0x8308), two(0xffc0, 0xe318), "D3&sQ8A9", m68030 | m68851 }, -{"ptestr", two(0xf000, 0x8200), two(0xffc0, 0xe3fe), "f3&sQ8", m68030 | m68851 }, -{"ptestr", two(0xf000, 0x8300), two(0xffc0, 0xe31e), "f3&sQ8A9", m68030 | m68851 }, - -{"ptestr", one(0xf568), one(0xfff8), "As", m68040 }, - -{"ptestw", two(0xf000, 0x8010), two(0xffc0, 0xe3f0), "T3&sQ8", m68030 | m68851 }, -{"ptestw", two(0xf000, 0x8110), two(0xffc0, 0xe310), "T3&sQ8A9", m68030 | m68851 }, -{"ptestw", two(0xf000, 0x8008), two(0xffc0, 0xe3f8), "D3&sQ8", m68030 | m68851 }, -{"ptestw", two(0xf000, 0x8108), two(0xffc0, 0xe318), "D3&sQ8A9", m68030 | m68851 }, -{"ptestw", two(0xf000, 0x8000), two(0xffc0, 0xe3fe), "f3&sQ8", m68030 | m68851 }, -{"ptestw", two(0xf000, 0x8100), two(0xffc0, 0xe31e), "f3&sQ8A9", m68030 | m68851 }, - -{"ptestw", one(0xf548), one(0xfff8), "As", m68040 }, - -{"ptrapacw", two(0xf07a, 0x0007), two(0xffff, 0xffff), "#w", m68851 }, -{"ptrapacl", two(0xf07b, 0x0007), two(0xffff, 0xffff), "#l", m68851 }, -{"ptrapac", two(0xf07c, 0x0007), two(0xffff, 0xffff), "", m68851 }, - -{"ptrapasw", two(0xf07a, 0x0006), two(0xffff, 0xffff), "#w", m68851 }, -{"ptrapasl", two(0xf07b, 0x0006), two(0xffff, 0xffff), "#l", m68851 }, -{"ptrapas", two(0xf07c, 0x0006), two(0xffff, 0xffff), "", m68851 }, - -{"ptrapbcw", two(0xf07a, 0x0001), two(0xffff, 0xffff), "#w", m68851 }, -{"ptrapbcl", two(0xf07b, 0x0001), two(0xffff, 0xffff), "#l", m68851 }, -{"ptrapbc", two(0xf07c, 0x0001), two(0xffff, 0xffff), "", m68851 }, - -{"ptrapbsw", two(0xf07a, 0x0000), two(0xffff, 0xffff), "#w", m68851 }, -{"ptrapbsl", two(0xf07b, 0x0000), two(0xffff, 0xffff), "#l", m68851 }, -{"ptrapbs", two(0xf07c, 0x0000), two(0xffff, 0xffff), "", m68851 }, - -{"ptrapccw", two(0xf07a, 0x000f), two(0xffff, 0xffff), "#w", m68851 }, -{"ptrapccl", two(0xf07b, 0x000f), two(0xffff, 0xffff), "#l", m68851 }, -{"ptrapcc", two(0xf07c, 0x000f), two(0xffff, 0xffff), "", m68851 }, - -{"ptrapcsw", two(0xf07a, 0x000e), two(0xffff, 0xffff), "#w", m68851 }, -{"ptrapcsl", two(0xf07b, 0x000e), two(0xffff, 0xffff), "#l", m68851 }, -{"ptrapcs", two(0xf07c, 0x000e), two(0xffff, 0xffff), "", m68851 }, - -{"ptrapgcw", two(0xf07a, 0x000d), two(0xffff, 0xffff), "#w", m68851 }, -{"ptrapgcl", two(0xf07b, 0x000d), two(0xffff, 0xffff), "#l", m68851 }, -{"ptrapgc", two(0xf07c, 0x000d), two(0xffff, 0xffff), "", m68851 }, - -{"ptrapgsw", two(0xf07a, 0x000c), two(0xffff, 0xffff), "#w", m68851 }, -{"ptrapgsl", two(0xf07b, 0x000c), two(0xffff, 0xffff), "#l", m68851 }, -{"ptrapgs", two(0xf07c, 0x000c), two(0xffff, 0xffff), "", m68851 }, - -{"ptrapicw", two(0xf07a, 0x000b), two(0xffff, 0xffff), "#w", m68851 }, -{"ptrapicl", two(0xf07b, 0x000b), two(0xffff, 0xffff), "#l", m68851 }, -{"ptrapic", two(0xf07c, 0x000b), two(0xffff, 0xffff), "", m68851 }, - -{"ptrapisw", two(0xf07a, 0x000a), two(0xffff, 0xffff), "#w", m68851 }, -{"ptrapisl", two(0xf07b, 0x000a), two(0xffff, 0xffff), "#l", m68851 }, -{"ptrapis", two(0xf07c, 0x000a), two(0xffff, 0xffff), "", m68851 }, - -{"ptraplcw", two(0xf07a, 0x0003), two(0xffff, 0xffff), "#w", m68851 }, -{"ptraplcl", two(0xf07b, 0x0003), two(0xffff, 0xffff), "#l", m68851 }, -{"ptraplc", two(0xf07c, 0x0003), two(0xffff, 0xffff), "", m68851 }, - -{"ptraplsw", two(0xf07a, 0x0002), two(0xffff, 0xffff), "#w", m68851 }, -{"ptraplsl", two(0xf07b, 0x0002), two(0xffff, 0xffff), "#l", m68851 }, -{"ptrapls", two(0xf07c, 0x0002), two(0xffff, 0xffff), "", m68851 }, - -{"ptrapscw", two(0xf07a, 0x0005), two(0xffff, 0xffff), "#w", m68851 }, -{"ptrapscl", two(0xf07b, 0x0005), two(0xffff, 0xffff), "#l", m68851 }, -{"ptrapsc", two(0xf07c, 0x0005), two(0xffff, 0xffff), "", m68851 }, - -{"ptrapssw", two(0xf07a, 0x0004), two(0xffff, 0xffff), "#w", m68851 }, -{"ptrapssl", two(0xf07b, 0x0004), two(0xffff, 0xffff), "#l", m68851 }, -{"ptrapss", two(0xf07c, 0x0004), two(0xffff, 0xffff), "", m68851 }, - -{"ptrapwcw", two(0xf07a, 0x0009), two(0xffff, 0xffff), "#w", m68851 }, -{"ptrapwcl", two(0xf07b, 0x0009), two(0xffff, 0xffff), "#l", m68851 }, -{"ptrapwc", two(0xf07c, 0x0009), two(0xffff, 0xffff), "", m68851 }, - -{"ptrapwsw", two(0xf07a, 0x0008), two(0xffff, 0xffff), "#w", m68851 }, -{"ptrapwsl", two(0xf07b, 0x0008), two(0xffff, 0xffff), "#l", m68851 }, -{"ptrapws", two(0xf07c, 0x0008), two(0xffff, 0xffff), "", m68851 }, - -{"pvalid", two(0xf000, 0x2800), two(0xffc0, 0xffff), "Vs&s", m68851 }, -{"pvalid", two(0xf000, 0x2c00), two(0xffc0, 0xfff8), "A3&s", m68851 }, - -#endif /* NO_68851 */ - -{"reset", one(0047160), one(0177777), "", m68000up }, - -{"rolb", one(0160430), one(0170770), "QdDs", m68000up }, /* rorb #Q, Ds */ -{"rolb", one(0160470), one(0170770), "DdDs", m68000up }, /* rorb Dd, Ds */ -{"roll", one(0160630), one(0170770), "QdDs", m68000up }, /* rorb #Q, Ds */ -{"roll", one(0160670), one(0170770), "DdDs", m68000up }, /* rorb Dd, Ds */ -{"rolw", one(0160530), one(0170770), "QdDs", m68000up }, /* rorb #Q, Ds */ -{"rolw", one(0160570), one(0170770), "DdDs", m68000up }, /* rorb Dd, Ds */ -{"rolw", one(0163700), one(0177700), "~s", m68000up }, /* Rotate memory */ -{"rorb", one(0160030), one(0170770), "QdDs", m68000up }, /* rorb #Q, Ds */ -{"rorb", one(0160070), one(0170770), "DdDs", m68000up }, /* rorb Dd, Ds */ -{"rorl", one(0160230), one(0170770), "QdDs", m68000up }, /* rorb #Q, Ds */ -{"rorl", one(0160270), one(0170770), "DdDs", m68000up }, /* rorb Dd, Ds */ -{"rorw", one(0160130), one(0170770), "QdDs", m68000up }, /* rorb #Q, Ds */ -{"rorw", one(0160170), one(0170770), "DdDs", m68000up }, /* rorb Dd, Ds */ -{"rorw", one(0163300), one(0177700), "~s", m68000up }, /* Rotate memory */ - -{"roxlb", one(0160420), one(0170770), "QdDs", m68000up }, /* roxrb #Q, Ds */ -{"roxlb", one(0160460), one(0170770), "DdDs", m68000up }, /* roxrb Dd, Ds */ -{"roxll", one(0160620), one(0170770), "QdDs", m68000up }, /* roxrb #Q, Ds */ -{"roxll", one(0160660), one(0170770), "DdDs", m68000up }, /* roxrb Dd, Ds */ -{"roxlw", one(0160520), one(0170770), "QdDs", m68000up }, /* roxrb #Q, Ds */ -{"roxlw", one(0160560), one(0170770), "DdDs", m68000up }, /* roxrb Dd, Ds */ -{"roxlw", one(0162700), one(0177700), "~s", m68000up }, /* Rotate memory */ -{"roxrb", one(0160020), one(0170770), "QdDs", m68000up }, /* roxrb #Q, Ds */ -{"roxrb", one(0160060), one(0170770), "DdDs", m68000up }, /* roxrb Dd, Ds */ -{"roxrl", one(0160220), one(0170770), "QdDs", m68000up }, /* roxrb #Q, Ds */ -{"roxrl", one(0160260), one(0170770), "DdDs", m68000up }, /* roxrb Dd, Ds */ -{"roxrw", one(0160120), one(0170770), "QdDs", m68000up }, /* roxrb #Q, Ds */ -{"roxrw", one(0160160), one(0170770), "DdDs", m68000up }, /* roxrb Dd, Ds */ -{"roxrw", one(0162300), one(0177700), "~s", m68000up }, /* Rotate memory */ - -{"rtd", one(0047164), one(0177777), "#w", m68010up }, -{"rte", one(0047163), one(0177777), "", m68000up }, -{"rtm", one(0003300), one(0177760), "Rs", m68020 }, -{"rtr", one(0047167), one(0177777), "", m68000up }, -{"rts", one(0047165), one(0177777), "", m68000up }, - -{"sbcd", one(0100400), one(0170770), "DsDd", m68000up }, -{"sbcd", one(0100410), one(0170770), "-s-d", m68000up }, - -{"scc", one(0052300), one(0177700), "$s", m68000up }, -{"scs", one(0052700), one(0177700), "$s", m68000up }, -{"seq", one(0053700), one(0177700), "$s", m68000up }, -{"sf", one(0050700), one(0177700), "$s", m68000up }, -{"sge", one(0056300), one(0177700), "$s", m68000up }, -{"sfge", one(0056300), one(0177700), "$s", m68000up }, -{"sgt", one(0057300), one(0177700), "$s", m68000up }, -{"sfgt", one(0057300), one(0177700), "$s", m68000up }, -{"shi", one(0051300), one(0177700), "$s", m68000up }, -{"sle", one(0057700), one(0177700), "$s", m68000up }, -{"sfle", one(0057700), one(0177700), "$s", m68000up }, -{"sls", one(0051700), one(0177700), "$s", m68000up }, -{"slt", one(0056700), one(0177700), "$s", m68000up }, -{"sflt", one(0056700), one(0177700), "$s", m68000up }, -{"smi", one(0055700), one(0177700), "$s", m68000up }, -{"sne", one(0053300), one(0177700), "$s", m68000up }, -{"sfneq", one(0053300), one(0177700), "$s", m68000up }, -{"spl", one(0055300), one(0177700), "$s", m68000up }, -{"st", one(0050300), one(0177700), "$s", m68000up }, -{"svc", one(0054300), one(0177700), "$s", m68000up }, -{"svs", one(0054700), one(0177700), "$s", m68000up }, - -{"stop", one(0047162), one(0177777), "#w", m68000up }, - -{"subal", one(0110700), one(0170700), "*lAd", m68000up }, -{"subaw", one(0110300), one(0170700), "*wAd", m68000up }, -{"subb", one(0050400), one(0170700), "Qd%s", m68000up }, /* subq written as sub */ -{"subb", one(0002000), one(0177700), "#b$s", m68000up }, /* subi written as sub */ -{"subb", one(0110000), one(0170700), ";bDd", m68000up }, /* subb ? ?, Dd */ -{"subb", one(0110400), one(0170700), "Dd~s", m68000up }, /* subb Dd, ? ? */ -{"subib", one(0002000), one(0177700), "#b$s", m68000up }, -{"subil", one(0002200), one(0177700), "#l$s", m68000up }, -{"subiw", one(0002100), one(0177700), "#w$s", m68000up }, -{"subl", one(0050600), one(0170700), "Qd%s", m68000up }, -{"subl", one(0002200), one(0177700), "#l$s", m68000up }, -{"subl", one(0110700), one(0170700), "*lAd", m68000up }, -{"subl", one(0110200), one(0170700), "*lDd", m68000up }, -{"subl", one(0110600), one(0170700), "Dd~s", m68000up }, -{"subqb", one(0050400), one(0170700), "Qd%s", m68000up }, -{"subql", one(0050600), one(0170700), "Qd%s", m68000up }, -{"subqw", one(0050500), one(0170700), "Qd%s", m68000up }, -{"subw", one(0050500), one(0170700), "Qd%s", m68000up }, -{"subw", one(0002100), one(0177700), "#w$s", m68000up }, -{"subw", one(0110100), one(0170700), "*wDd", m68000up }, -{"subw", one(0110300), one(0170700), "*wAd", m68000up }, /* suba written as sub */ -{"subw", one(0110500), one(0170700), "Dd~s", m68000up }, -{"subxb", one(0110400), one(0170770), "DsDd", m68000up }, /* subxb Ds, Dd */ -{"subxb", one(0110410), one(0170770), "-s-d", m68000up }, /* subxb -(As), -(Ad) */ -{"subxl", one(0110600), one(0170770), "DsDd", m68000up }, -{"subxl", one(0110610), one(0170770), "-s-d", m68000up }, -{"subxw", one(0110500), one(0170770), "DsDd", m68000up }, -{"subxw", one(0110510), one(0170770), "-s-d", m68000up }, - -{"swap", one(0044100), one(0177770), "Ds", m68000up }, - -{"tas", one(0045300), one(0177700), "$s", m68000up }, -{"trap", one(0047100), one(0177760), "Ts", m68000up }, - -{"trapcc", one(0052374), one(0177777), "", m68020up }, -{"trapcs", one(0052774), one(0177777), "", m68020up }, -{"trapeq", one(0053774), one(0177777), "", m68020up }, -{"trapf", one(0050774), one(0177777), "", m68020up }, -{"trapge", one(0056374), one(0177777), "", m68020up }, -{"trapgt", one(0057374), one(0177777), "", m68020up }, -{"traphi", one(0051374), one(0177777), "", m68020up }, -{"traple", one(0057774), one(0177777), "", m68020up }, -{"trapls", one(0051774), one(0177777), "", m68020up }, -{"traplt", one(0056774), one(0177777), "", m68020up }, -{"trapmi", one(0055774), one(0177777), "", m68020up }, -{"trapne", one(0053374), one(0177777), "", m68020up }, -{"trappl", one(0055374), one(0177777), "", m68020up }, -{"trapt", one(0050374), one(0177777), "", m68020up }, -{"trapvc", one(0054374), one(0177777), "", m68020up }, -{"trapvs", one(0054774), one(0177777), "", m68020up }, - -{"trapcc.w", one(0052372), one(0177777), "", m68020up }, -{"trapcs.w", one(0052772), one(0177777), "", m68020up }, -{"trapeq.w", one(0053772), one(0177777), "", m68020up }, -{"trapf.w", one(0050772), one(0177777), "", m68020up }, -{"trapge.w", one(0056372), one(0177777), "", m68020up }, -{"trapgt.w", one(0057372), one(0177777), "", m68020up }, -{"traphi.w", one(0051372), one(0177777), "", m68020up }, -{"traple.w", one(0057772), one(0177777), "", m68020up }, -{"trapls.w", one(0051772), one(0177777), "", m68020up }, -{"traplt.w", one(0056772), one(0177777), "", m68020up }, -{"trapmi.w", one(0055772), one(0177777), "", m68020up }, -{"trapne.w", one(0053372), one(0177777), "", m68020up }, -{"trappl.w", one(0055372), one(0177777), "", m68020up }, -{"trapt.w", one(0050372), one(0177777), "", m68020up }, -{"trapvc.w", one(0054372), one(0177777), "", m68020up }, -{"trapvs.w", one(0054772), one(0177777), "", m68020up }, - -{"trapcc.l", one(0052373), one(0177777), "", m68020up }, -{"trapcs.l", one(0052773), one(0177777), "", m68020up }, -{"trapeq.l", one(0053773), one(0177777), "", m68020up }, -{"trapf.l", one(0050773), one(0177777), "", m68020up }, -{"trapge.l", one(0056373), one(0177777), "", m68020up }, -{"trapgt.l", one(0057373), one(0177777), "", m68020up }, -{"traphi.l", one(0051373), one(0177777), "", m68020up }, -{"traple.l", one(0057773), one(0177777), "", m68020up }, -{"trapls.l", one(0051773), one(0177777), "", m68020up }, -{"traplt.l", one(0056773), one(0177777), "", m68020up }, -{"trapmi.l", one(0055773), one(0177777), "", m68020up }, -{"trapne.l", one(0053373), one(0177777), "", m68020up }, -{"trappl.l", one(0055373), one(0177777), "", m68020up }, -{"trapt.l", one(0050373), one(0177777), "", m68020up }, -{"trapvc.l", one(0054373), one(0177777), "", m68020up }, -{"trapvs.l", one(0054773), one(0177777), "", m68020up }, - -{"trapv", one(0047166), one(0177777), "", m68000up }, - -{"tstb", one(0045000), one(0177700), ";b", m68000up }, -{"tstw", one(0045100), one(0177700), "*w", m68000up }, -{"tstl", one(0045200), one(0177700), "*l", m68000up }, - -{"unlk", one(0047130), one(0177770), "As", m68000up }, -{"unpk", one(0100600), one(0170770), "DsDd#w", m68020up }, -{"unpk", one(0100610), one(0170770), "-s-d#w", m68020up }, - -/* Variable-sized branches */ - -{"jbsr", one(0060400), one(0177400), "Bg", m68000up }, -{"jbsr", one(0047200), one(0177700), "!s", m68000up }, -{"jra", one(0060000), one(0177400), "Bg", m68000up }, -{"jra", one(0047300), one(0177700), "!s", m68000up }, - -{"jhi", one(0061000), one(0177400), "Bg", m68000up }, -{"jls", one(0061400), one(0177400), "Bg", m68000up }, -{"jcc", one(0062000), one(0177400), "Bg", m68000up }, -{"jcs", one(0062400), one(0177400), "Bg", m68000up }, -{"jne", one(0063000), one(0177400), "Bg", m68000up }, -{"jeq", one(0063400), one(0177400), "Bg", m68000up }, -{"jvc", one(0064000), one(0177400), "Bg", m68000up }, -{"jvs", one(0064400), one(0177400), "Bg", m68000up }, -{"jpl", one(0065000), one(0177400), "Bg", m68000up }, -{"jmi", one(0065400), one(0177400), "Bg", m68000up }, -{"jge", one(0066000), one(0177400), "Bg", m68000up }, -{"jlt", one(0066400), one(0177400), "Bg", m68000up }, -{"jgt", one(0067000), one(0177400), "Bg", m68000up }, -{"jle", one(0067400), one(0177400), "Bg", m68000up }, - -/* aliases */ - -{"movql", one(0070000), one(0170400), "MsDd", m68000up }, -{"moveql", one(0070000), one(0170400), "MsDd", m68000up }, -{"moval", one(0020100), one(0170700), "*lAd", m68000up }, -{"movaw", one(0030100), one(0170700), "*wAd", m68000up }, -{"movb", one(0010000), one(0170000), ";b$d", m68000up }, /* mov */ -{"movl", one(0070000), one(0170400), "MsDd", m68000up }, /* movq written as mov */ -{"movl", one(0020000), one(0170000), "*l$d", m68000up }, -{"movl", one(0020100), one(0170700), "*lAd", m68000up }, -{"movl", one(0047140), one(0177770), "AsUd", m68000up }, /* mov to USP */ -{"movl", one(0047150), one(0177770), "UdAs", m68000up }, /* mov from USP */ -{"movc", one(0047173), one(0177777), "R1Jj", m68010up }, -{"movc", one(0047173), one(0177777), "R1#j", m68010up }, -{"movc", one(0047172), one(0177777), "JjR1", m68010up }, -{"movc", one(0047172), one(0177777), "#jR1", m68010up }, -{"movml", one(0044300), one(0177700), "#w&s", m68000up }, /* movm reg to mem. */ -{"movml", one(0044340), one(0177770), "#w-s", m68000up }, /* movm reg to autodecrement. */ -{"movml", one(0046300), one(0177700), "!s#w", m68000up }, /* movm mem to reg. */ -{"movml", one(0046330), one(0177770), "+s#w", m68000up }, /* movm autoinc to reg. */ -{"movml", one(0044300), one(0177700), "Lw&s", m68000up }, /* movm reg to mem. */ -{"movml", one(0044340), one(0177770), "lw-s", m68000up }, /* movm reg to autodecrement. */ -{"movml", one(0046300), one(0177700), "!sLw", m68000up }, /* movm mem to reg. */ -{"movml", one(0046330), one(0177770), "+sLw", m68000up }, /* movm autoinc to reg. */ -{"movmw", one(0044200), one(0177700), "#w&s", m68000up }, /* movm reg to mem. */ -{"movmw", one(0044240), one(0177770), "#w-s", m68000up }, /* movm reg to autodecrement. */ -{"movmw", one(0046200), one(0177700), "!s#w", m68000up }, /* movm mem to reg. */ -{"movmw", one(0046230), one(0177770), "+s#w", m68000up }, /* movm autoinc to reg. */ -{"movmw", one(0044200), one(0177700), "Lw&s", m68000up }, /* movm reg to mem. */ -{"movmw", one(0044240), one(0177770), "lw-s", m68000up }, /* movm reg to autodecrement. */ -{"movmw", one(0046200), one(0177700), "!sLw", m68000up }, /* movm mem to reg. */ -{"movmw", one(0046230), one(0177770), "+sLw", m68000up }, /* movm autoinc to reg. */ -{"movpl", one(0000510), one(0170770), "dsDd", m68000up }, /* memory to register */ -{"movpl", one(0000710), one(0170770), "Ddds", m68000up }, /* register to memory */ -{"movpw", one(0000410), one(0170770), "dsDd", m68000up }, /* memory to register */ -{"movpw", one(0000610), one(0170770), "Ddds", m68000up }, /* register to memory */ -{"movq", one(0070000), one(0170400), "MsDd", m68000up }, -{"movw", one(0030000), one(0170000), "*w$d", m68000up }, -{"movw", one(0030100), one(0170700), "*wAd", m68000up }, /* mova, written as mov */ -{"movw", one(0040300), one(0177700), "Ss$s", m68000up }, /* Move from sr */ -{"movw", one(0041300), one(0177700), "Cs$s", m68010up }, /* Move from ccr */ -{"movw", one(0042300), one(0177700), ";wCd", m68000up }, /* mov to ccr */ -{"movw", one(0043300), one(0177700), ";wSd", m68000up }, /* mov to sr */ - -{"movsb", two(0007000, 0), two(0177700, 07777), "~sR1", m68010up }, -{"movsb", two(0007000, 04000), two(0177700, 07777), "R1~s", m68010up }, -{"movsl", two(0007200, 0), two(0177700, 07777), "~sR1", m68010up }, -{"movsl", two(0007200, 04000), two(0177700, 07777), "R1~s", m68010up }, -{"movsw", two(0007100, 0), two(0177700, 07777), "~sR1", m68010up }, -{"movsw", two(0007100, 04000), two(0177700, 07777), "R1~s", m68010up }, - -}; - -int numopcodes=sizeof(m68k_opcodes)/sizeof(m68k_opcodes[0]); - -struct m68k_opcode *endop = m68k_opcodes+sizeof(m68k_opcodes)/sizeof(m68k_opcodes[0]); - -/* - * Local Variables: - * fill-column: 131 - * End: - */ - -/* end of m68k-opcode.h */ diff --git a/include/m88k-opcode.h b/include/m88k-opcode.h deleted file mode 100755 index c5e643a1ff9..00000000000 --- a/include/m88k-opcode.h +++ /dev/null @@ -1,585 +0,0 @@ -/* This file has been modified by Data General Corporation, November 1989. */ - - -/* -* Disassembler Instruction Table -* -* The first field of the table is the opcode field. If an opcode -* is specified which has any non-opcode bits on, a system error -* will occur when the system attempts the install it into the -* instruction table. The second parameter is a pointer to the -* instruction mnemonic. Each operand is specified by offset, width, -* and type. The offset is the bit number of the least significant -* bit of the operand with bit 0 being the least significant bit of -* the instruction. The width is the number of bits used to specify -* the operand. The type specifies the output format to be used for -* the operand. The valid formats are: register, register indirect, -* hex constant, and bit field specification. The last field is a -* pointer to the next instruction in the linked list. These pointers -* are initialized by init_disasm(). -* -* Structure Format -* -* struct INSTAB { -* UPINT opcode; -* char *mnemonic; -* struct OPSPEC op1,op2,op3; -* struct SIM_FLAGS flgs; -* struct INSTAB *next; -* } -* -* struct OPSPEC { -* UPINT offset:5; -* UPINT width:6; -* UPINT type:5; -* } -* -* Revision History -* -* Revision 1.0 11/08/85 Creation date -* 1.1 02/05/86 Updated instruction mnemonic table MD -* 1.2 06/16/86 Updated SIM_FLAGS for floating point -* 1.3 09/20/86 Updated for new encoding -* 05/11/89 R. Trawick adapted from Motorola disassembler -*/ - -#include - - -/* - * This file contains the structures and constants needed to build the M88000 - * simulator. It is the main include file, containing all the - * structures, macros and definitions except for the floating point - * instruction set. - */ - -/* - * The following flag informs the Simulator as to what type of byte ordering - * will be used. For instance, a BOFLAG = 1 indicates a DEC VAX and IBM type - * of ordering shall be used. -*/ - -/* # define BOFLAG 1 /* BYTE ORDERING FLAG */ - -/* define the number of bits in the primary opcode field of the instruction, - * the destination field, the source 1 and source 2 fields. - */ -# define OP 8 /* size of opcode field */ -# define DEST 6 /* size of destination */ -# define SOURCE1 6 /* size of source1 */ -# define SOURCE2 6 /* size of source2 */ - -# define REGs 32 /* number of registers */ - -# define WORD long -# define FLAG unsigned -# define STATE short - -# define TRUE 1 -# define FALSE 0 - -# define READ 0 -# define WRITE 1 - -/* The next four equates define the priorities that the various classes - * of instructions have regarding writing results back into registers and - * signalling exceptions. - */ - -# define PINT 0 /* Integer Priority */ -# define PFLT 1 /* Floating Point Priority */ -# define PMEM 2 /* Memory Priority */ -# define NA 3 /* Not Applicable, instruction doesnt write to regs */ -# define HIPRI 3 /* highest of these priorities */ - -/* The instruction registers are an artificial mechanism to speed up - * simulator execution. In the real processor, an instruction register - * is 32 bits wide. In the simulator, the 32 bit instruction is kept in - * a structure field called rawop, and the instruction is partially decoded, - * and split into various fields and flags which make up the other fields - * of the structure. - * The partial decode is done when the instructions are initially loaded - * into simulator memory. The simulator code memory is not an array of - * 32 bit words, but is an array of instruction register structures. - * Yes this wastes memory, but it executes much quicker. - */ - -struct IR_FIELDS { - unsigned long op:OP, - dest: DEST, - src1: SOURCE1, - src2: SOURCE2; - int ltncy, - extime, - wb_pri; /* writeback priority */ - unsigned short imm_flags:2,/* immediate size */ - rs1_used:1, /* register source 1 used */ - rs2_used:1, /* register source 2 used */ - rsd_used:1, /* register source/dest. used */ - c_flag:1, /* complement */ - u_flag:1, /* upper half word */ - n_flag:1, /* execute next */ - wb_flag:1, /* uses writeback slot */ - dest_64:1, /* dest size */ - s1_64:1, /* source 1 size */ - s2_64:1, /* source 2 size */ - scale_flag:1, /* scaled register */ - brk_flg:1; - }; - -struct mem_segs { - struct mem_wrd *seg; /* pointer (returned by calloc) to segment */ - unsigned long baseaddr; /* base load address from file headers */ - unsigned long endaddr; /* Ending address of segment */ - int flags; /* segment control flags (none defined 12/5/86) */ -}; - -#define MAXSEGS (10) /* max number of segment allowed */ -#define MEMSEGSIZE (sizeof(struct mem_segs))/* size of mem_segs structure */ - - -#define BRK_RD (0x01) /* break on memory read */ -#define BRK_WR (0x02) /* break on memory write */ -#define BRK_EXEC (0x04) /* break on execution */ -#define BRK_CNT (0x08) /* break on terminal count */ - - -struct mem_wrd { - struct IR_FIELDS opcode; /* simulator instruction break down */ - union { - unsigned long l; /* memory element break down */ - unsigned short s[2]; - unsigned char c[4]; - } mem; -}; - -#define MEMWRDSIZE (sizeof(struct mem_wrd)) /* size of each 32 bit memory model */ - -/* External declarations */ - -extern struct mem_segs memory[]; -extern struct PROCESSOR m78000; - -struct PROCESSOR { - unsigned WORD - ip, /* execute instruction pointer */ - vbr, /* vector base register */ - psr; /* processor status register */ - - WORD S1bus, /* source 1 */ - S2bus, /* source 2 */ - Dbus, /* destination */ - DAbus, /* data address bus */ - ALU, - Regs[REGs], /* data registers */ - time_left[REGs], /* max clocks before reg is available */ - wb_pri[REGs], /* writeback priority of reg */ - SFU0_regs[REGs], /* integer unit control regs */ - SFU1_regs[REGs], /* floating point control regs */ - Scoreboard[REGs], - Vbr; - unsigned WORD scoreboard, - Psw, - Tpsw; - FLAG jump_pending:1; /* waiting for a jump instr. */ - }; - -# define i26bit 1 /* size of immediate field */ -# define i16bit 2 -# define i10bit 3 - -/* Definitions for fields in psr */ - -# define mode 31 -# define rbo 30 -# define ser 29 -# define carry 28 -# define sf7m 11 -# define sf6m 10 -# define sf5m 9 -# define sf4m 8 -# define sf3m 7 -# define sf2m 6 -# define sf1m 5 -# define mam 4 -# define inm 3 -# define exm 2 -# define trm 1 -# define ovfm 0 - -#define MODEMASK (1<<(mode-1)) -# define SILENT 0 /* simulate without output to crt */ -# define VERBOSE 1 /* simulate in verbose mode */ -# define PR_INSTR 2 /* only print instructions */ - -# define RESET 16 /* reset phase */ - -# define PHASE1 0 /* data path phases */ -# define PHASE2 1 - -/* the 1 clock operations */ - -# define ADDU 1 -# define ADDC 2 -# define ADDUC 3 -# define ADD 4 - -# define SUBU ADD+1 -# define SUBB ADD+2 -# define SUBUB ADD+3 -# define SUB ADD+4 - -# define AND ADD+5 -# define OR ADD+6 -# define XOR ADD+7 -# define CMP ADD+8 - -/* the LOADS */ - -# define LDAB CMP+1 -# define LDAH CMP+2 -# define LDA CMP+3 -# define LDAD CMP+4 - -# define LDB LDAD+1 -# define LDH LDAD+2 -# define LD LDAD+3 -# define LDD LDAD+4 -# define LDBU LDAD+5 -# define LDHU LDAD+6 - -/* the STORES */ - -# define STB LDHU+1 -# define STH LDHU+2 -# define ST LDHU+3 -# define STD LDHU+4 - -/* the exchange */ - -# define XMEMBU LDHU+5 -# define XMEM LDHU+6 - -/* the branches */ -# define JSR STD+1 -# define BSR STD+2 -# define BR STD+3 -# define JMP STD+4 -# define BB1 STD+5 -# define BB0 STD+6 -# define RTN STD+7 -# define BCND STD+8 - -/* the TRAPS */ -# define TB1 BCND+1 -# define TB0 BCND+2 -# define TCND BCND+3 -# define RTE BCND+4 -# define TBND BCND+5 - -/* the MISC instructions */ -# define MUL TBND + 1 -# define DIV MUL +2 -# define DIVU MUL +3 -# define MASK MUL +4 -# define FF0 MUL +5 -# define FF1 MUL +6 -# define CLR MUL +7 -# define SET MUL +8 -# define EXT MUL +9 -# define EXTU MUL +10 -# define MAK MUL +11 -# define ROT MUL +12 - -/* control register manipulations */ - -# define LDCR ROT +1 -# define STCR ROT +2 -# define XCR ROT +3 - -# define FLDCR ROT +4 -# define FSTCR ROT +5 -# define FXCR ROT +6 - - -# define NOP XCR +1 - -/* floating point instructions */ - -# define FADD NOP +1 -# define FSUB NOP +2 -# define FMUL NOP +3 -# define FDIV NOP +4 -# define FSQRT NOP +5 -# define FCMP NOP +6 -# define FIP NOP +7 -# define FLT NOP +8 -# define INT NOP +9 -# define NINT NOP +10 -# define TRNC NOP +11 -# define FLDC NOP +12 -# define FSTC NOP +13 -# define FXC NOP +14 - -# define UEXT(src,off,wid) ((((unsigned int)(src))>>(off)) & ((1<<(wid)) - 1)) -# define SEXT(src,off,wid) (((((int)(src))<<(32-((off)+(wid)))) >>(32-(wid))) ) -# define MAKE(src,off,wid) \ - ((((unsigned int)(src)) & ((1<<(wid)) - 1)) << (off)) - -# define opword(n) (unsigned long) (memaddr->mem.l) - -/* Constants and Masks */ - -#define SFU0 0x80000000 -#define SFU1 0x84000000 -#define SFU7 0x9c000000 -#define RRI10 0xf0000000 -#define RRR 0xf4000000 -#define SFUMASK 0xfc00ffe0 -#define RRRMASK 0xfc00ffe0 -#define RRI10MASK 0xfc00fc00 -#define DEFMASK 0xfc000000 -#define CTRL 0x0000f000 -#define CTRLMASK 0xfc00f800 - -/* Operands types */ - -#define HEX 1 -#define REG 2 -#define IND 3 -#define CONT 3 -#define IND 3 -#define BF 4 -#define REGSC 5 /* scaled register */ -#define CRREG 6 /* control register */ -#define FCRREG 7 /* floating point control register */ -#define PCREL 8 -#define CONDMASK 9 - -/* Hashing Specification */ - -#define HASHVAL 79 - -/* Type definitions */ - -typedef unsigned int UINT; - -/* Structure templates */ - -typedef struct { - unsigned int offset:5; - unsigned int width:6; - unsigned int type:5; -} OPSPEC; - - struct SIM_FLAGS { - int ltncy, /* latency (max number of clocks needed to execute) */ - extime, /* execution time (min number of clocks needed to execute) */ - wb_pri; /* writeback slot priority */ - unsigned long op:OP, /* simulator version of opcode */ - imm_flags:2, /* 10,16 or 26 bit immediate flags */ - rs1_used:1, /* register source 1 used */ - rs2_used:1, /* register source 2 used */ - rsd_used:1, /* register source/dest used */ - c_flag:1, /* complement */ - u_flag:1, /* upper half word */ - n_flag:1, /* execute next */ - wb_flag:1, /* uses writeback slot */ - dest_64:1, /* double precision dest */ - s1_64:1, /* double precision source 1 */ - s2_64:1, /* double precision source 2 */ - scale_flag:1; /* register is scaled */ -}; - -typedef struct INSTRUCTAB { - unsigned int opcode; - char *mnemonic; - OPSPEC op1,op2,op3; - struct SIM_FLAGS flgs; - struct INSTRUCTAB *next; -} INSTAB; - - -/* Opcode Mnemonic Op 1 Spec Op 2 Spec Op 3 Spec Simflags Next */ - -static INSTAB instructions[] = -{0xf400c800,"jsr ",{0,5,REG} ,{0,0,0} ,{0,0,0} , {2,2,NA,JSR , 0,0,1,0,0,0,0,1,0,0,0,0}, NULL, - 0xf400cc00,"jsr.n ",{0,5,REG} ,{0,0,0} ,{0,0,0} , {1,1,NA,JSR , 0,0,1,0,0,0,1,1,0,0,0,0}, NULL, - 0xf400c000,"jmp ",{0,5,REG} ,{0,0,0} ,{0,0,0} , {2,2,NA,JMP , 0,0,1,0,0,0,0,1,0,0,0,0}, NULL, - 0xf400c400,"jmp.n ",{0,5,REG} ,{0,0,0} ,{0,0,0} , {1,1,NA,JMP , 0,0,1,0,0,0,1,1,0,0,0,0}, NULL, - 0xc8000000,"bsr ",{0,26,PCREL},{0,0,0} ,{0,0,0} , {2,2,NA,BSR , i26bit,0,0,0,0,0,0,1,0,0,0,0}, NULL, - 0xcc000000,"bsr.n ",{0,26,PCREL},{0,0,0} ,{0,0,0} , {1,1,NA,BSR , i26bit,0,0,0,0,0,1,1,0,0,0,0}, NULL, - 0xc0000000,"br ",{0,26,PCREL},{0,0,0} ,{0,0,0} , {2,2,NA,BR , i26bit,0,0,0,0,0,0,1,0,0,0,0}, NULL, - 0xc4000000,"br.n ",{0,26,PCREL},{0,0,0} ,{0,0,0} , {1,1,NA,BR , i26bit,0,0,0,0,0,1,1,0,0,0,0}, NULL, - 0xd0000000,"bb0 ",{21,5,HEX} ,{16,5,REG} ,{0,16,PCREL},{2,2,NA,BB0, i16bit,0,1,0,0,0,0,1,0,0,0,0}, NULL, - 0xd4000000,"bb0.n ",{21,5,HEX} ,{16,5,REG} ,{0,16,PCREL},{1,1,NA,BB0, i16bit,0,1,0,0,0,1,1,0,0,0,0}, NULL, - 0xd8000000,"bb1 ",{21,5,HEX},{16,5,REG} ,{0,16,PCREL},{2,2,NA,BB1, i16bit,0,1,0,0,0,0,1,0,0,0,0}, NULL, - 0xdc000000,"bb1.n ",{21,5,HEX},{16,5,REG} ,{0,16,PCREL},{1,1,NA,BB1, i16bit,0,1,0,0,0,1,1,0,0,0,0}, NULL, - 0xf000d000,"tb0 ",{21,5,HEX} ,{16,5,REG} ,{0,10,HEX}, {2,2,NA,TB0 , i10bit,0,1,0,0,0,0,1,0,0,0,0}, NULL, - 0xf000d800,"tb1 ",{21,5,HEX} ,{16,5,REG} ,{0,10,HEX}, {2,2,NA,TB1 , i10bit,0,1,0,0,0,0,1,0,0,0,0}, NULL, - 0xe8000000,"bcnd ",{21,5,CONDMASK},{16,5,REG},{0,16,PCREL},{2,2,NA,BCND, i16bit,0,1,0,0,0,0,1,0,0,0,0}, NULL, - 0xec000000,"bcnd.n ",{21,5,CONDMASK},{16,5,REG},{0,16,PCREL},{1,1,NA,BCND, i16bit,0,1,0,0,0,1,1,0,0,0,0}, NULL, - 0xf000e800,"tcnd ",{21,5,CONDMASK},{16,5,REG},{0,10,HEX}, {2,2,NA,TCND, i10bit,0,1,0,0,0,0,1,0,0,0,0}, NULL, - 0xf8000000,"tbnd ",{16,5,REG} ,{0,16,HEX} ,{0,0,0} , {2,2,NA,TBND, i10bit,1,0,0,0,0,0,1,0,0,0,0}, NULL, - 0xf400f800,"tbnd ",{16,5,REG} ,{0,5,REG} ,{0,0,0} , {2,2,NA,TBND, 0,1,1,0,0,0,0,1,0,0,0,0}, NULL, - 0xf400fc00,"rte ",{0,0,0} ,{0,0,0} ,{0,0,0} , {2,2,NA,RTE , 0,0,0,0,0,0,0,1,0,0,0,0}, NULL, - 0x1c000000,"ld.b ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {3,1,PMEM,LDB ,i16bit,1,0,1,0,0,0,1,0,0,0,0}, NULL, - 0xf4001c00,"ld.b ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {3,1,PMEM,LDB , 0,1,1,1,0,0,0,1,0,0,0,0}, NULL, - 0x0c000000,"ld.bu ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {3,1,PMEM,LDBU, i16bit,1,0,1,0,0,0,1,0,0,0,0}, NULL, - 0xf4000c00,"ld.bu ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {3,1,PMEM,LDBU ,0,1,1,1,0,0,0,1,0,0,0,0}, NULL, - 0x18000000,"ld.h ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {3,1,PMEM,LDH ,i16bit,1,0,1,0,0,0,1,0,0,0,0}, NULL, - 0xf4001800,"ld.h ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {3,1,PMEM,LDH ,0,1,1,1,0,0,0,1,0,0,0,0}, NULL, - 0xf4001a00,"ld.h ",{21,5,REG} ,{16,5,REG} ,{0,5,REGSC},{3,1,PMEM,LDH ,0,1,1,1,0,0,0,1,0,0,0,1}, NULL, - 0x08000000,"ld.hu ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {3,1,PMEM,LDHU, i16bit,1,0,1,0,0,0,1,0,0,0,0}, NULL, - 0xf4000800,"ld.hu ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {3,1,PMEM,LDHU ,0,1,1,1,0,0,0,1,0,0,0,0}, NULL, - 0xf4000a00,"ld.hu ",{21,5,REG} ,{16,5,REG} ,{0,5,REGSC},{3,1,PMEM,LDHU ,0,1,1,1,0,0,0,1,0,0,0,1}, NULL, - 0x14000000,"ld ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {3,1,PMEM,LD ,i16bit,1,0,1,0,0,0,1,0,0,0,0}, NULL, - 0xf4001400,"ld ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {3,1,PMEM,LD ,0,1,1,1,0,0,0,1,0,0,0,0}, NULL, - 0xf4001600,"ld ",{21,5,REG} ,{16,5,REG} ,{0,5,REGSC},{3,1,PMEM,LD ,0,1,1,1,0,0,0,1,0,0,0,1}, NULL, - 0x10000000,"ld.d ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {3,1,PMEM,LDD ,i16bit,1,0,1,0,0,0,1,0,0,0,0}, NULL, - 0xf4001000,"ld.d ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {3,1,PMEM,LDD ,0,1,1,1,0,0,0,1,0,0,0,0}, NULL, - 0xf4001200,"ld.d ",{21,5,REG} ,{16,5,REG} ,{0,5,REGSC},{3,1,PMEM,LDD ,0,1,1,1,0,0,0,1,0,0,0,1}, NULL, - 0xf4001500,"ld.usr ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {3,1,PMEM,LD ,0,1,1,1,0,0,0,1,0,0,0,0}, NULL, - 0xf4001700,"ld.usr ",{21,5,REG} ,{16,5,REG} ,{0,5,REGSC},{3,1,PMEM,LD ,0,1,1,1,0,0,0,1,0,0,0,1}, NULL, - 0x2c000000,"st.b ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {1,1,NA,STB ,i16bit,1,0,1,0,0,0,1,0,0,0,0}, NULL, - 0xf4002c00,"st.b ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,NA,STB ,0,1,1,1,0,0,0,1,0,0,0,0}, NULL, - 0x28000000,"st.h ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {1,1,NA,STH ,i16bit,1,0,1,0,0,0,1,0,0,0,0}, NULL, - 0xf4002800,"st.h ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,NA,STH ,0,1,1,1,0,0,0,1,0,0,0,0}, NULL, - 0xf4002a00,"st.h ",{21,5,REG} ,{16,5,REG} ,{0,5,REGSC},{1,1,NA,STH ,0,1,1,1,0,0,0,1,0,0,0,1}, NULL, - 0x24000000,"st ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {1,1,NA,ST ,i16bit,1,0,1,0,0,0,1,0,0,0,0}, NULL, - 0xf4002400,"st ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,NA,ST ,0,1,1,1,0,0,0,1,0,0,0,0} ,NULL, - 0xf4002600,"st ",{21,5,REG} ,{16,5,REG} ,{0,5,REGSC},{1,1,NA,ST ,0,1,1,1,0,0,0,1,0,0,0,1} ,NULL, - 0x20000000,"st.d ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {1,1,NA,STD ,i16bit,0,1,0,0,0,0,1,0,0,0,0} ,NULL, - 0xf4002000,"st.d ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,NA,STD ,0,1,1,1,0,0,0,1,0,0,0,0} ,NULL, - 0xf4002200,"st.d ",{21,5,REG} ,{16,5,REG} ,{0,5,REGSC},{1,1,NA,STD ,0,1,1,1,0,0,0,1,0,0,0,1} ,NULL, - 0xf4002500,"st.usr ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,NA,ST ,0,1,1,1,0,0,0,1,0,0,0,0} ,NULL, - 0xf4002700,"st.usr ",{21,5,REG} ,{16,5,REG} ,{0,5,REGSC},{1,1,NA,ST ,0,1,1,1,0,0,0,1,0,0,0,1} ,NULL, - 0x00000000,"xmem.bu ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {3,1,PMEM,XMEMBU ,i16bit,1,1,1,0,0,0,1,0,0,0,0} ,NULL, - 0xf4000000,"xmem.bu ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {3,1,PMEM,XMEM ,0,1,1,1,0,0,0,1,0,0,0,0} ,NULL, - 0x04000000,"xmem ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {3,1,PMEM,XMEM ,i16bit,1,1,1,0,0,0,1,0,0,0,0} ,NULL, - 0xf4000400,"xmem ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {3,1,PMEM,XMEM ,0,1,1,1,0,0,0,1,0,0,0,0} ,NULL, - 0xf4000600,"xmem ",{21,5,REG} ,{16,5,REG} ,{0,5,REGSC},{3,1,PMEM,XMEM ,0,1,1,1,0,0,0,1,0,0,0,1} ,NULL, - 0xf4000500,"xmem.usr ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {3,1,PMEM,XMEM ,0,1,1,1,0,0,0,1,0,0,0,0} ,NULL, - 0xf4000700,"xmem.usr ",{21,5,REG} ,{16,5,REG} ,{0,5,REGSC},{3,1,PMEM,XMEM ,0,1,1,1,0,0,0,1,0,0,0,1} ,NULL, - 0xf4003e00,"lda.b ",{21,5,REG} ,{16,5,REG} ,{0,5,REGSC},{1,1,PINT,LDAH, 0,1,1,1,0,0,0,0,0,0,0,1} ,NULL, - 0xf4003a00,"lda.h ",{21,5,REG} ,{16,5,REG} ,{0,5,REGSC},{1,1,PINT,LDAH, 0,1,1,1,0,0,0,0,0,0,0,1} ,NULL, - 0xf4003600,"lda ",{21,5,REG} ,{16,5,REG} ,{0,5,REGSC},{1,1,PINT,LDA , 0,1,1,1,0,0,0,0,0,0,0,1} ,NULL, - 0xf4003200,"lda.d ",{21,5,REG} ,{16,5,REG} ,{0,5,REGSC},{1,1,PINT,LDAD, 0,1,1,1,0,0,0,0,0,0,0,1} ,NULL, - - 0x80004000,"ldcr ",{21,5,REG} ,{5,6,CRREG} ,{0,0,0} ,{1,1,PINT,LDCR, 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0x80008000,"stcr ",{16,5,REG} ,{5,6,CRREG} ,{0,0,0} ,{1,1,PINT,STCR, 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0x8000c000,"xcr ",{21,5,REG} ,{16,5,REG} ,{5,6,CRREG},{1,1,PINT,XCR, 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - - 0xf4006000,"addu ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,ADDU, 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf4006200,"addu.ci ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,ADDU, 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf4006100,"addu.co ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,ADDU, 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf4006300,"addu.cio ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,ADDU, 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf4006400,"subu ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,SUBU, 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf4006600,"subu.ci ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,SUBU, 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf4006500,"subu.co ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,SUBU, 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf4006700,"subu.cio ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,SUBU, 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf4006900,"divu ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {32,32,PINT,DIVU, 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf4006d00,"mul ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,4,PINT,MUL, 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf4007000,"add ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,ADD , 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf4007200,"add.ci ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,ADD , 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf4007100,"add.co ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,ADD , 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf4007300,"add.cio ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,ADD , 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf4007400,"sub ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,SUB , 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf4007600,"sub.ci ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,SUB , 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf4007500,"sub.co ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,SUB , 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf4007700,"sub.cio ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,SUB , 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf4007900,"div ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {32,32,PINT,DIV , 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf4007d00,"cmp ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,CMP, 0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - - 0x60000000,"addu ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {1,1,PINT,ADDU, i16bit,1,0,1,0,0,0,0,0,0,0,0} ,NULL, - 0x64000000,"subu ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {1,1,PINT,SUBU, i16bit,1,0,1,0,0,0,0,0,0,0,0} ,NULL, - - 0x68000000,"divu ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {32,32,PINT,DIVU, i16bit,1,0,1,0,0,0,0,0,0,0,0} ,NULL, - 0x6c000000,"mul ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {4,1,PINT,MUL, i16bit,1,0,1,0,0,0,0,0,0,0,0} ,NULL, - 0x70000000,"add ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {1,1,PINT,ADD, i16bit,1,0,1,0,0,0,0,0,0,0,0} ,NULL, - 0x74000000,"sub ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {1,1,PINT,SUB, i16bit,1,0,1,0,0,0,0,0,0,0,0} ,NULL, - 0x78000000,"div ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {32,32,PINT,DIV, i16bit,1,0,1,0,0,0,0,0,0,0,0} ,NULL, - 0x7c000000,"cmp ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {1,1,PINT,CMP, i16bit,1,0,1,0,0,0,0,0,0,0,0} ,NULL, - - 0xf4004000,"and ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,AND ,0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf4004400,"and.c ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,AND ,0,1,1,1,1,0,0,0,0,0,0,0} ,NULL, - 0xf4005800,"or ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,OR ,0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf4005c00,"or.c ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,OR ,0,1,1,1,1,0,0,0,0,0,0,0} ,NULL, - 0xf4005000,"xor ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,XOR ,0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf4005400,"xor.c ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,XOR ,0,1,1,1,1,0,0,0,0,0,0,0} ,NULL, - 0x40000000,"and ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {1,1,PINT,AND ,i16bit,1,0,1,0,0,0,0,0,0,0,0} ,NULL, - 0x44000000,"and.u ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {1,1,PINT,AND ,i16bit,1,0,1,0,1,0,0,0,0,0,0} ,NULL, - 0x58000000,"or ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {1,1,PINT,OR ,i16bit,1,0,1,0,0,0,0,0,0,0,0} ,NULL, - 0x5c000000,"or.u ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {1,1,PINT,OR ,i16bit,1,0,1,0,1,0,0,0,0,0,0} ,NULL, - 0x50000000,"xor ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {1,1,PINT,XOR ,i16bit,1,0,1,0,0,0,0,0,0,0,0} ,NULL, - 0x54000000,"xor.u ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {1,1,PINT,XOR ,i16bit,1,0,1,0,1,0,0,0,0,0,0} ,NULL, - 0x48000000,"mask ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {1,1,PINT,MASK ,i16bit,1,0,1,0,0,0,0,0,0,0,0} ,NULL, - 0x4c000000,"mask.u ",{21,5,REG} ,{16,5,REG} ,{0,16,HEX}, {1,1,PINT,MASK ,i16bit,1,0,1,0,1,0,0,0,0,0,0} ,NULL, - 0xf400ec00,"ff0 ",{21,5,REG} ,{0,5,REG} ,{0,0,0} , {1,1,PINT,FF0 ,0,0,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf400e800,"ff1 ",{21,5,REG} ,{0,5,REG} ,{0,0,0} , {1,1,PINT,FF1 ,0,0,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf0008000,"clr ",{21,5,REG} ,{16,5,REG} ,{0,10,BF} , {1,1,PINT,CLR ,i10bit,1,0,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf0008800,"set ",{21,5,REG} ,{16,5,REG} ,{0,10,BF} , {1,1,PINT,SET ,i10bit,1,0,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf0009000,"ext ",{21,5,REG} ,{16,5,REG} ,{0,10,BF} , {1,1,PINT,EXT ,i10bit,1,0,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf0009800,"extu ",{21,5,REG} ,{16,5,REG} ,{0,10,BF} , {1,1,PINT,EXTU ,i10bit,1,0,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf000a000,"mak ",{21,5,REG} ,{16,5,REG} ,{0,10,BF} , {1,1,PINT,MAK ,i10bit,1,0,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf000a800,"rot ",{21,5,REG} ,{16,5,REG} ,{0,10,BF} , {1,1,PINT,ROT ,i10bit,1,0,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf4008000,"clr ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,CLR ,0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf4008800,"set ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,SET ,0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf4009000,"ext ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,EXT ,0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf4009800,"extu ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,EXTU ,0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf400a000,"mak ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,MAK ,0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - 0xf400a800,"rot ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {1,1,PINT,ROT ,0,1,1,1,0,0,0,0,0,0,0,0} ,NULL, - - 0x84002800,"fadd.sss ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {5,1,PFLT,FADD ,0,1,1,1,0,0,0,1,0,0,0,0} ,NULL, - 0x84002880,"fadd.ssd ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {6,2,PFLT,FADD ,0,1,1,1,0,0,0,1,0,0,1,0} ,NULL, - 0x84002a00,"fadd.sds ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {6,2,PFLT,FADD ,0,1,1,1,0,0,0,1,0,1,0,0} ,NULL, - 0x84002a80,"fadd.sdd ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {6,2,PFLT,FADD ,0,1,1,1,0,0,0,1,0,1,1,0} ,NULL, - 0x84002820,"fadd.dss ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {6,2,PFLT,FADD ,0,1,1,1,0,0,0,1,1,0,0,0} ,NULL, - 0x840028a0,"fadd.dsd ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {6,2,PFLT,FADD ,0,1,1,1,0,0,0,1,1,0,1,0} ,NULL, - 0x84002a20,"fadd.dds ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {6,2,PFLT,FADD ,0,1,1,1,0,0,0,1,1,1,0,0} ,NULL, - 0x84002aa0,"fadd.ddd ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {6,2,PFLT,FADD ,0,1,1,1,0,0,0,1,1,1,1,0} ,NULL, - 0x84003000,"fsub.sss ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {5,1,PFLT,FSUB ,0,1,1,1,0,0,0,1,0,0,0,0} ,NULL, - 0x84003080,"fsub.ssd ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {6,2,PFLT,FSUB ,0,1,1,1,0,0,0,1,0,0,1,0} ,NULL, - 0x84003200,"fsub.sds ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {6,2,PFLT,FSUB ,0,1,1,1,0,0,0,1,0,1,0,0} ,NULL, - 0x84003280,"fsub.sdd ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {6,2,PFLT,FSUB ,0,1,1,1,0,0,0,1,0,1,1,0} ,NULL, - 0x84003020,"fsub.dss ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {6,2,PFLT,FSUB ,0,1,1,1,0,0,0,1,1,0,0,0} ,NULL, - 0x840030a0,"fsub.dsd ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {6,2,PFLT,FSUB ,0,1,1,1,0,0,0,1,1,0,1,0} ,NULL, - 0x84003220,"fsub.dds ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {6,2,PFLT,FSUB ,0,1,1,1,0,0,0,1,1,1,0,0} ,NULL, - 0x840032a0,"fsub.ddd ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {6,2,PFLT,FSUB ,0,1,1,1,0,0,0,1,1,1,1,0} ,NULL, - 0x84000000,"fmul.sss ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {6,1,PFLT,FMUL ,0,1,1,1,0,0,0,1,0,0,0,0} ,NULL, - 0x84000080,"fmul.ssd ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {9,2,PFLT,FMUL ,0,1,1,1,0,0,0,1,0,0,1,0} ,NULL, - 0x84000200,"fmul.sds ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {9,2,PFLT,FMUL ,0,1,1,1,0,0,0,1,0,1,0,0} ,NULL, - 0x84000280,"fmul.sdd ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {9,2,PFLT,FMUL ,0,1,1,1,0,0,0,1,0,1,1,0} ,NULL, - 0x84000020,"fmul.dss ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {9,2,PFLT,FMUL ,0,1,1,1,0,0,0,1,1,0,0,0} ,NULL, - 0x840000a0,"fmul.dsd ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {9,2,PFLT,FMUL ,0,1,1,1,0,0,0,1,1,0,1,0} ,NULL, - 0x84000220,"fmul.dds ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {9,2,PFLT,FMUL ,0,1,1,1,0,0,0,1,1,1,0,0} ,NULL, - 0x840002a0,"fmul.ddd ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {9,2,PFLT,FMUL ,0,1,1,1,0,0,0,1,1,1,1,0} ,NULL, - 0x84007000,"fdiv.sss ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {30,30,PFLT,FDIV ,0,1,1,1,0,0,0,1,0,0,0,0} ,NULL, - 0x84007080,"fdiv.ssd ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {60,60,PFLT,FDIV ,0,1,1,1,0,0,0,1,0,0,1,0} ,NULL, - 0x84007200,"fdiv.sds ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {60,60,PFLT,FDIV ,0,1,1,1,0,0,0,1,0,1,0,0} ,NULL, - 0x84007280,"fdiv.sdd ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {60,60,PFLT,FDIV ,0,1,1,1,0,0,0,1,0,1,1,0} ,NULL, - 0x84007020,"fdiv.dss ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {60,60,PFLT,FDIV ,0,1,1,1,0,0,0,1,1,0,0,0} ,NULL, - 0x840070a0,"fdiv.dsd ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {60,60,PFLT,FDIV ,0,1,1,1,0,0,0,1,1,0,1,0} ,NULL, - 0x84007220,"fdiv.dds ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {60,60,PFLT,FDIV ,0,1,1,1,0,0,0,1,1,1,0,0} ,NULL, - 0x840072a0,"fdiv.ddd ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {60,60,PFLT,FDIV ,0,1,1,1,0,0,0,1,1,1,1,0} ,NULL, - 0x84007800,"fsqrt.ss ",{21,5,REG} ,{0,5,REG} ,{0,0,0} , {5,1,PFLT,FLT ,0,0,1,1,0,0,0,1,0,0,0,0} ,NULL, - 0x84007880,"fsqrt.sd ",{21,5,REG} ,{0,5,REG} ,{0,0,0} , {5,1,PFLT,FLT ,0,0,1,1,0,0,0,1,0,0,0,0} ,NULL, - 0x84007820,"fsqrt.ds ",{21,5,REG} ,{0,5,REG} ,{0,0,0} , {5,1,PFLT,FLT ,0,0,1,1,0,0,0,1,0,0,0,0} ,NULL, - 0x840078a0,"fsqrt.dd ",{21,5,REG} ,{0,5,REG} ,{0,0,0} , {6,1,PFLT,FLT ,0,0,1,1,0,0,0,1,1,0,0,0} ,NULL, - 0x84003800,"fcmp.ss ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {5,1,PFLT,FCMP ,0,1,1,1,0,0,0,1,0,0,0,0} ,NULL, - 0x84003880,"fcmp.sd ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {6,1,PFLT,FCMP ,0,1,1,1,0,0,0,1,0,1,0,0} ,NULL, - 0x84003a00,"fcmp.ds ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {6,1,PFLT,FCMP ,0,1,1,1,0,0,0,1,1,0,0,0} ,NULL, - 0x84003a80,"fcmp.dd ",{21,5,REG} ,{16,5,REG} ,{0,5,REG} , {6,1,PFLT,FCMP ,0,1,1,1,0,0,0,1,1,1,0,0} ,NULL, - 0x84002000,"flt.s ",{21,5,REG} ,{0,5,REG} ,{0,0,0} , {5,1,PFLT,FLT ,0,0,1,1,0,0,0,1,0,0,0,0} ,NULL, - 0x84002020,"flt.d ",{21,5,REG} ,{0,5,REG} ,{0,0,0} , {6,1,PFLT,FLT ,0,0,1,1,0,0,0,1,1,0,0,0} ,NULL, - 0x84004800,"int.s ",{21,5,REG} ,{0,5,REG} ,{0,0,0} , {5,1,PFLT,INT ,0,0,1,1,0,0,0,1,0,0,0,0} ,NULL, - 0x84004880,"int.d ",{21,5,REG} ,{0,5,REG} ,{0,0,0} , {6,1,PFLT,INT ,0,0,1,1,0,0,0,1,1,0,0,0} ,NULL, - 0x84005000,"nint.s ",{21,5,REG} ,{0,5,REG} ,{0,0,0} , {5,1,PFLT,INT ,0,0,1,1,0,0,0,1,0,0,0,0} ,NULL, - 0x84005080,"nint.d ",{21,5,REG} ,{0,5,REG} ,{0,0,0} , {6,1,PFLT,INT ,0,0,1,1,0,0,0,1,1,0,0,0} ,NULL, - 0x84005800,"trnc.s ",{21,5,REG} ,{0,5,REG} ,{0,0,0} , {5,1,PFLT,TRNC ,0,0,1,1,0,0,0,1,0,0,0,0} ,NULL, - 0x84005880,"trnc.d ",{21,5,REG} ,{0,5,REG} ,{0,0,0} , {6,1,PFLT,TRNC ,0,0,1,1,0,0,0,1,1,0,0,0} ,NULL, - - 0x80004800,"fldcr ",{21,5,REG} ,{5,6,FCRREG} ,{0,0,0} , {1,1,PFLT,FLDC ,0,0,1,1,0,0,0,1,0,0,0,0} ,NULL, - 0x80008800,"fstcr ",{16,5,REG} ,{5,6,FCRREG} ,{0,0,0} , {1,1,PFLT,FSTC ,0,0,1,1,0,0,0,1,0,0,0,0} ,NULL, - 0x8000c800,"fxcr ",{21,5,REG} ,{16,5,REG} ,{5,6,FCRREG} , {1,1,PFLT,FXC ,0,0,1,1,0,0,0,1,0,0,0,0} ,NULL}; - diff --git a/include/mips-opcode.h b/include/mips-opcode.h deleted file mode 100755 index a65678a941d..00000000000 --- a/include/mips-opcode.h +++ /dev/null @@ -1,363 +0,0 @@ -/* Mips opcde list for GDB, the GNU debugger. - Copyright (C) 1989 Free Software Foundation, Inc. - Contributed by Nobuyuki Hikichi(hikichi@sra.junet) - Made to work for little-endian machines, and debugged - by Per Bothner (bothner@cs.wisc.edu). - Many fixes contributed by Frank Yellin (fy@lucid.com). - -This file is part of GDB. - -GDB 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 1, or (at your option) -any later version. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#if BITS_BIG_ENDIAN -#define BIT_FIELDS_2(a,b) a;b; -#define BIT_FIELDS_4(a,b,c,d) a;b;c;d; -#define BIT_FIELDS_6(a,b,c,d,e,f) a;b;c;d;e;f; -#else -#define BIT_FIELDS_2(a,b) b;a; -#define BIT_FIELDS_4(a,b,c,d) d;c;b;a; -#define BIT_FIELDS_6(a,b,c,d,e,f) f;e;d;c;b;a; -#endif - -struct op_i_fmt -{ -BIT_FIELDS_4( - unsigned op : 6, - unsigned rs : 5, - unsigned rt : 5, - unsigned immediate : 16) -}; - -struct op_j_fmt -{ -BIT_FIELDS_2( - unsigned op : 6, - unsigned target : 26) -}; - -struct op_r_fmt -{ -BIT_FIELDS_6( - unsigned op : 6, - unsigned rs : 5, - unsigned rt : 5, - unsigned rd : 5, - unsigned shamt : 5, - unsigned funct : 6) -}; - - -struct fop_i_fmt -{ -BIT_FIELDS_4( - unsigned op : 6, - unsigned rs : 5, - unsigned rt : 5, - unsigned immediate : 16) -}; - -struct op_b_fmt -{ -BIT_FIELDS_4( - unsigned op : 6, - unsigned rs : 5, - unsigned rt : 5, - short delta : 16) -}; - -struct fop_r_fmt -{ -BIT_FIELDS_6( - unsigned op : 6, - unsigned fmt : 5, - unsigned ft : 5, - unsigned fs : 5, - unsigned fd : 5, - unsigned funct : 6) -}; - -struct mips_opcode -{ - char *name; - unsigned long opcode; - unsigned long match; - char *args; - int bdelay; /* Nonzero if delayed branch. */ -}; - -/* args format; - - "s" rs: source register specifier - "t" rt: target register - "i" immediate - "a" target address - "c" branch condition - "d" rd: destination register specifier - "h" shamt: shift amount - "f" funct: function field - - for fpu - "S" fs source 1 register - "T" ft source 2 register - "D" distination register -*/ - -#define one(x) (x << 26) -#define op_func(x, y) ((x << 26) | y) -#define op_cond(x, y) ((x << 26) | (y << 16)) -#define op_rs_func(x, y, z) ((x << 26) | (y << 21) | z) -#define op_rs_b11(x, y, z) ((x << 26) | (y << 21) | z) -#define op_o16(x, y) ((x << 26) | (y << 16)) -#define op_bc(x, y, z) ((x << 26) | (y << 21) | (z << 16)) - -struct mips_opcode mips_opcodes[] = -{ -/* These first opcodes are special cases of the ones in the comments */ - {"nop", 0, 0xffffffff, /*li*/ "", 0}, - {"li", op_bc(9,0,0), op_bc(0x3f,31,0), /*addiu*/ "t,j", 0}, - {"b", one(4), 0xffff0000, /*beq*/ "b", 1}, - {"move", op_func(0, 33), op_cond(0x3f,31)|0x7ff,/*addu*/ "d,s", 0}, - - {"sll", op_func(0, 0), op_func(0x3f, 0x3f), "d,t,h", 0}, - {"srl", op_func(0, 2), op_func(0x3f, 0x3f), "d,t,h", 0}, - {"sra", op_func(0, 3), op_func(0x3f, 0x3f), "d,t,h", 0}, - {"sllv", op_func(0, 4), op_func(0x3f, 0x7ff), "d,t,s", 0}, - {"srlv", op_func(0, 6), op_func(0x3f, 0x7ff), "d,t,s", 0}, - {"srav", op_func(0, 7), op_func(0x3f, 0x7ff), "d,t,s", 0}, - {"jr", op_func(0, 8), op_func(0x3f, 0x1fffff), "s", 1}, - {"jalr", op_func(0, 9), op_func(0x3f, 0x1f07ff), "d,s", 1}, - {"syscall", op_func(0, 12), op_func(0x3f, 0x3f), "", 0}, - {"break", op_func(0, 13), op_func(0x3f, 0x3f), "", 0}, - {"mfhi", op_func(0, 16), op_func(0x3f, 0x03ff07ff), "d", 0}, - {"mthi", op_func(0, 17), op_func(0x3f, 0x1fffff), "s", 0}, - {"mflo", op_func(0, 18), op_func(0x3f, 0x03ff07ff), "d", 0}, - {"mtlo", op_func(0, 19), op_func(0x3f, 0x1fffff), "s", 0}, - {"mult", op_func(0, 24), op_func(0x3f, 0xffff), "s,t", 0}, - {"multu", op_func(0, 25), op_func(0x3f, 0xffff), "s,t", 0}, - {"div", op_func(0, 26), op_func(0x3f, 0xffff), "s,t", 0}, - {"divu", op_func(0, 27), op_func(0x3f, 0xffff), "s,t", 0}, - {"add", op_func(0, 32), op_func(0x3f, 0x7ff), "d,s,t", 0}, - {"addu", op_func(0, 33), op_func(0x3f, 0x7ff), "d,s,t", 0}, - {"sub", op_func(0, 34), op_func(0x3f, 0x7ff), "d,s,t", 0}, - {"subu", op_func(0, 35), op_func(0x3f, 0x7ff), "d,s,t", 0}, - {"and", op_func(0, 36), op_func(0x3f, 0x7ff), "d,s,t", 0}, - {"or", op_func(0, 37), op_func(0x3f, 0x7ff), "d,s,t", 0}, - {"xor", op_func(0, 38), op_func(0x3f, 0x7ff), "d,s,t", 0}, - {"nor", op_func(0, 39), op_func(0x3f, 0x7ff), "d,s,t", 0}, - {"slt", op_func(0, 42), op_func(0x3f, 0x7ff), "d,s,t", 0}, - {"sltu", op_func(0, 43), op_func(0x3f, 0x7ff), "d,s,t", 0}, - - {"bltz", op_cond (1, 0), op_cond(0x3f, 0x1f), "s,b", 1}, - {"bgez", op_cond (1, 1), op_cond(0x3f, 0x1f), "s,b", 1}, - {"bltzal", op_cond (1, 16),op_cond(0x3f, 0x1f), "s,b", 1}, - {"bgezal", op_cond (1, 17),op_cond(0x3f, 0x1f), "s,b", 1}, - - - {"j", one(2), one(0x3f), "a", 1}, - {"jal", one(3), one(0x3f), "a", 1}, - {"beq", one(4), one(0x3f), "s,t,b", 1}, - {"bne", one(5), one(0x3f), "s,t,b", 1}, - {"blez", one(6), one(0x3f) | 0x1f0000, "s,b", 1}, - {"bgtz", one(7), one(0x3f) | 0x1f0000, "s,b", 1}, - {"addi", one(8), one(0x3f), "t,s,j", 0}, - {"addiu", one(9), one(0x3f), "t,s,j", 0}, - {"slti", one(10), one(0x3f), "t,s,j", 0}, - {"sltiu", one(11), one(0x3f), "t,s,j", 0}, - {"andi", one(12), one(0x3f), "t,s,i", 0}, - {"ori", one(13), one(0x3f), "t,s,i", 0}, - {"xori", one(14), one(0x3f), "t,s,i", 0}, - /* rs field is don't care field? */ - {"lui", one(15), one(0x3f), "t,i", 0}, - -/* co processor 0 instruction */ - {"mfc0", op_rs_b11 (16, 0, 0), op_rs_b11(0x3f, 0x1f, 0x1ffff), "t,d", 0}, - {"cfc0", op_rs_b11 (16, 2, 0), op_rs_b11(0x3f, 0x1f, 0x1ffff), "t,d", 0}, - {"mtc0", op_rs_b11 (16, 4, 0), op_rs_b11(0x3f, 0x1f, 0x1ffff), "t,d", 0}, - {"ctc0", op_rs_b11 (16, 6, 0), op_rs_b11(0x3f, 0x1f, 0x1ffff), "t,d", 0}, - - {"bc0f", op_o16(16, 0x100), op_o16(0x3f, 0x3ff), "b", 1}, - {"bc0f", op_o16(16, 0x180), op_o16(0x3f, 0x3ff), "b", 1}, - {"bc0t", op_o16(16, 0x101), op_o16(0x3f, 0x3ff), "b", 1}, - {"bc0t", op_o16(16, 0x181), op_o16(0x3f, 0x3ff), "b", 1}, - - {"tlbr", op_rs_func(16, 0x10, 1), ~0, "", 0}, - {"tlbwi", op_rs_func(16, 0x10, 2), ~0, "", 0}, - {"tlbwr", op_rs_func(16, 0x10, 6), ~0, "", 0}, - {"tlbp", op_rs_func(16, 0x10, 8), ~0, "", 0}, - {"rfe", op_rs_func(16, 0x10, 16), ~0, "", 0}, - - {"mfc1", op_rs_b11 (17, 0, 0), op_rs_b11(0x3f, 0x1f, 0),"t,S", 0}, - {"cfc1", op_rs_b11 (17, 2, 0), op_rs_b11(0x3f, 0x1f, 0),"t,S", 0}, - {"mtc1", op_rs_b11 (17, 4, 0), op_rs_b11(0x3f, 0x1f, 0),"t,S", 0}, - {"ctc1", op_rs_b11 (17, 6, 0), op_rs_b11(0x3f, 0x1f, 0),"t,S", 0}, - - {"bc1f", op_o16(17, 0x100), op_o16(0x3f, 0x3ff), "b", 1}, - {"bc1f", op_o16(17, 0x180), op_o16(0x3f, 0x3ff), "b", 1}, - {"bc1t", op_o16(17, 0x101), op_o16(0x3f, 0x3ff), "b", 1}, - {"bc1t", op_o16(17, 0x181), op_o16(0x3f, 0x3ff), "b", 1}, - -/* fpu instruction */ - {"add.s", op_rs_func(17, 0x10, 0), - op_rs_func(0x3f, 0x1f, 0x3f), "D,S,T", 0}, - {"add.d", op_rs_func(17, 0x11, 0), - op_rs_func(0x3f, 0x1f, 0x3f), "D,S,T", 0}, - {"sub.s", op_rs_func(17, 0x10, 1), - op_rs_func(0x3f, 0x1f, 0x3f), "D,S,T", 0}, - {"sub.d", op_rs_func(17, 0x11, 1), - op_rs_func(0x3f, 0x1f, 0x3f), "D,S,T", 0}, - {"mul.s", op_rs_func(17, 0x10, 2), - op_rs_func(0x3f, 0x1f, 0x3f), "D,S,T", 0}, - {"mul.d", op_rs_func(17, 0x11, 2), - op_rs_func(0x3f, 0x1f, 0x3f), "D,S,T", 0}, - {"div.s", op_rs_func(17, 0x10, 3), - op_rs_func(0x3f, 0x1f, 0x3f), "D,S,T", 0}, - {"div.d", op_rs_func(17, 0x11, 3), - op_rs_func(0x3f, 0x1f, 0x3f), "D,S,T", 0}, - {"abs.s", op_rs_func(17, 0x10, 5), - op_rs_func(0x3f, 0x1f, 0x1f003f), "D,S", 0}, - {"abs.d", op_rs_func(17, 0x11, 5), - op_rs_func(0x3f, 0x1f, 0x1f003f), "D,S", 0}, - {"mov.s", op_rs_func(17, 0x10, 6), - op_rs_func(0x3f, 0x1f, 0x1f003f), "D,S", 0}, - {"mov.d", op_rs_func(17, 0x11, 6), - op_rs_func(0x3f, 0x1f, 0x1f003f), "D,S", 0}, - {"neg.s", op_rs_func(17, 0x10, 7), - op_rs_func(0x3f, 0x1f, 0x1f003f), "D,S", 0}, - {"neg.d", op_rs_func(17, 0x11, 7), - op_rs_func(0x3f, 0x1f, 0x1f003f), "D,S", 0}, - {"cvt.s.s", op_rs_func(17, 0x10, 32), - op_rs_func(0x3f, 0x1f, 0x1f003f), "D,S", 0}, - {"cvt.s.d", op_rs_func(17, 0x11, 32), - op_rs_func(0x3f, 0x1f, 0x1f003f), "D,S", 0}, - {"cvt.s.w", op_rs_func(17, 0x14, 32), - op_rs_func(0x3f, 0x1f, 0x1f003f), "D,S", 0}, - {"cvt.d.s", op_rs_func(17, 0x10, 33), - op_rs_func(0x3f, 0x1f, 0x1f003f), "D,S", 0}, - {"cvt.d.d", op_rs_func(17, 0x11, 33), - op_rs_func(0x3f, 0x1f, 0x1f003f), "D,S", 0}, - {"cvt.d.w", op_rs_func(17, 0x14, 33), - op_rs_func(0x3f, 0x1f, 0x1f003f), "D,S", 0}, - {"cvt.w.s", op_rs_func(17, 0x10, 36), - op_rs_func(0x3f, 0x1f, 0x1f003f), "D,S", 0}, - {"cvt.w.d", op_rs_func(17, 0x11, 36), - op_rs_func(0x3f, 0x1f, 0x1f003f), "D,S", 0}, - {"c.f.s", op_rs_func(17, 0x10, 48), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.f.d", op_rs_func(17, 0x11, 48), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.un.s", op_rs_func(17, 0x10, 49), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.un.d", op_rs_func(17, 0x11, 49), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.eq.s", op_rs_func(17, 0x10, 50), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.eq.d", op_rs_func(17, 0x11, 50), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.ueq.s", op_rs_func(17, 0x10, 51), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.ueq.d", op_rs_func(17, 0x11, 51), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.olt.s", op_rs_func(17, 0x10, 52), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.olt.d", op_rs_func(17, 0x11, 52), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.ult.s", op_rs_func(17, 0x10, 53), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.ult.d", op_rs_func(17, 0x11, 53), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.ole.s", op_rs_func(17, 0x10, 54), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.ole.d", op_rs_func(17, 0x11, 54), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.ule.s", op_rs_func(17, 0x10, 55), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.ule.d", op_rs_func(17, 0x11, 55), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.sf.s", op_rs_func(17, 0x10, 56), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.sf.d", op_rs_func(17, 0x11, 56), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.ngle.s", op_rs_func(17, 0x10, 57), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.ngle.d", op_rs_func(17, 0x11, 57), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.seq.s", op_rs_func(17, 0x10, 58), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.seq.d", op_rs_func(17, 0x11, 58), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.ngl.s", op_rs_func(17, 0x10, 59), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.ngl.d", op_rs_func(17, 0x11, 59), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.lt.s", op_rs_func(17, 0x10, 60), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.lt.d", op_rs_func(17, 0x11, 60), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.nge.s", op_rs_func(17, 0x10, 61), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.nge.d", op_rs_func(17, 0x11, 61), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.le.s", op_rs_func(17, 0x10, 62), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.le.d", op_rs_func(17, 0x11, 62), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.ngt.s", op_rs_func(17, 0x10, 63), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - {"c.ngt.d", op_rs_func(17, 0x11, 63), - op_rs_func(0x3f, 0x1f, 0x7ff), "S,T", 0}, - -/* co processor 2 instruction */ - {"mfc2", op_rs_b11 (18, 0, 0), op_rs_b11(0x3f, 0x1f, 0x1ffff), "t,d", 0}, - {"cfc2", op_rs_b11 (18, 2, 0), op_rs_b11(0x3f, 0x1f, 0x1ffff), "t,d", 0}, - {"mtc2", op_rs_b11 (18, 4, 0), op_rs_b11(0x3f, 0x1f, 0x1ffff), "t,d", 0}, - {"ctc2", op_rs_b11 (18, 6, 0), op_rs_b11(0x3f, 0x1f, 0x1ffff), "t,d", 0}, - {"bc2f", op_o16(18, 0x100), op_o16(0x3f, 0x3ff), "b", 1}, - {"bc2f", op_o16(18, 0x180), op_o16(0x3f, 0x3ff), "b", 1}, - {"bc2f", op_o16(18, 0x101), op_o16(0x3f, 0x3ff), "b", 1}, - {"bc2t", op_o16(18, 0x181), op_o16(0x3f, 0x3ff), "b", 1}, - -/* co processor 3 instruction */ - {"mtc3", op_rs_b11 (19, 0, 0), op_rs_b11(0x3f, 0x1f, 0x1ffff), "t,d", 0}, - {"cfc3", op_rs_b11 (19, 2, 0), op_rs_b11(0x3f, 0x1f, 0x1ffff), "t,d", 0}, - {"mtc3", op_rs_b11 (19, 4, 0), op_rs_b11(0x3f, 0x1f, 0x1ffff), "t,d", 0}, - {"ctc3", op_rs_b11 (19, 6, 0), op_rs_b11(0x3f, 0x1f, 0x1ffff), "t,d", 0}, - {"bc3f", op_o16(19, 0x100), op_o16(0x3f, 0x3ff), "b", 1}, - {"bc3f", op_o16(19, 0x180), op_o16(0x3f, 0x3ff), "b", 1}, - {"bc3t", op_o16(19, 0x101), op_o16(0x3f, 0x3ff), "b", 1}, - {"bc3t", op_o16(19, 0x181), op_o16(0x3f, 0x3ff), "b", 1}, - - {"lb", one(32), one(0x3f), "t,j(s)", 0}, - {"lh", one(33), one(0x3f), "t,j(s)", 0}, - {"lwl", one(34), one(0x3f), "t,j(s)", 0}, - {"lw", one(35), one(0x3f), "t,j(s)", 0}, - {"lbu", one(36), one(0x3f), "t,j(s)", 0}, - {"lhu", one(37), one(0x3f), "t,j(s)", 0}, - {"lwr", one(38), one(0x3f), "t,j(s)", 0}, - {"sb", one(40), one(0x3f), "t,j(s)", 0}, - {"sh", one(41), one(0x3f), "t,j(s)", 0}, - {"swl", one(42), one(0x3f), "t,j(s)", 0}, - {"swr", one(46), one(0x3f), "t,j(s)", 0}, - {"sw", one(43), one(0x3f), "t,j(s)", 0}, - {"lwc0", one(48), one(0x3f), "t,j(s)", 0}, -/* for fpu */ - {"lwc1", one(49), one(0x3f), "T,j(s)", 0}, - {"lwc2", one(50), one(0x3f), "t,j(s)", 0}, - {"lwc3", one(51), one(0x3f), "t,j(s)", 0}, - {"swc0", one(56), one(0x3f), "t,j(s)", 0}, -/* for fpu */ - {"swc1", one(57), one(0x3f), "T,j(s)", 0}, - {"swc2", one(58), one(0x3f), "t,j(s)", 0}, - {"swc3", one(59), one(0x3f), "t,j(s)", 0}, -}; diff --git a/include/np1-opcode.h b/include/np1-opcode.h deleted file mode 100755 index 654682570fa..00000000000 --- a/include/np1-opcode.h +++ /dev/null @@ -1,422 +0,0 @@ -/* Print GOULD NPL instructions for GDB, the GNU debugger. - Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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 1, or (at your option) -any later version. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -struct gld_opcode -{ - char *name; - unsigned long opcode; - unsigned long mask; - char *args; - int length; -}; - -/* We store four bytes of opcode for all opcodes because that - is the most any of them need. The actual length of an instruction - is always at least 2 bytes, and at most four. The length of the - instruction is based on the opcode. - - The mask component is a mask saying which bits must match - particular opcode in order for an instruction to be an instance - of that opcode. - - The args component is a string containing characters - that are used to format the arguments to the instruction. */ - -/* Kinds of operands: - r Register in first field - R Register in second field - b Base register in first field - B Base register in second field - v Vector register in first field - V Vector register in first field - A Optional address register (base register) - X Optional index register - I Immediate data (16bits signed) - O Offset field (16bits signed) - h Offset field (15bits signed) - d Offset field (14bits signed) - S Shift count field - - any other characters are printed as is... -*/ - -/* The assembler requires that this array be sorted as follows: - all instances of the same mnemonic must be consecutive. - All instances of the same mnemonic with the same number of operands - must be consecutive. - */ -struct gld_opcode gld_opcodes[] = -{ -{ "lb", 0xb4080000, 0xfc080000, "r,xOA,X", 4 }, -{ "lnb", 0xb8080000, 0xfc080000, "r,xOA,X", 4 }, -{ "lbs", 0xec080000, 0xfc080000, "r,xOA,X", 4 }, -{ "lh", 0xb4000001, 0xfc080001, "r,xOA,X", 4 }, -{ "lnh", 0xb8000001, 0xfc080001, "r,xOA,X", 4 }, -{ "lw", 0xb4000000, 0xfc080000, "r,xOA,X", 4 }, -{ "lnw", 0xb8000000, 0xfc080000, "r,xOA,X", 4 }, -{ "ld", 0xb4000002, 0xfc080002, "r,xOA,X", 4 }, -{ "lnd", 0xb8000002, 0xfc080002, "r,xOA,X", 4 }, -{ "li", 0xf8000000, 0xfc7f0000, "r,I", 4 }, -{ "lpa", 0x50080000, 0xfc080000, "r,xOA,X", 4 }, -{ "la", 0x50000000, 0xfc080000, "r,xOA,X", 4 }, -{ "labr", 0x58080000, 0xfc080000, "b,xOA,X", 4 }, -{ "lbp", 0x90080000, 0xfc080000, "r,xOA,X", 4 }, -{ "lhp", 0x90000001, 0xfc080001, "r,xOA,X", 4 }, -{ "lwp", 0x90000000, 0xfc080000, "r,xOA,X", 4 }, -{ "ldp", 0x90000002, 0xfc080002, "r,xOA,X", 4 }, -{ "suabr", 0x58000000, 0xfc080000, "b,xOA,X", 4 }, -{ "lf", 0xbc000000, 0xfc080000, "r,xOA,X", 4 }, -{ "lfbr", 0xbc080000, 0xfc080000, "b,xOA,X", 4 }, -{ "lwbr", 0x5c000000, 0xfc080000, "b,xOA,X", 4 }, -{ "stb", 0xd4080000, 0xfc080000, "r,xOA,X", 4 }, -{ "sth", 0xd4000001, 0xfc080001, "r,xOA,X", 4 }, -{ "stw", 0xd4000000, 0xfc080000, "r,xOA,X", 4 }, -{ "std", 0xd4000002, 0xfc080002, "r,xOA,X", 4 }, -{ "stf", 0xdc000000, 0xfc080000, "r,xOA,X", 4 }, -{ "stfbr", 0xdc080000, 0xfc080000, "b,xOA,X", 4 }, -{ "stwbr", 0x54000000, 0xfc080000, "b,xOA,X", 4 }, -{ "zmb", 0xd8080000, 0xfc080000, "r,xOA,X", 4 }, -{ "zmh", 0xd8000001, 0xfc080001, "r,xOA,X", 4 }, -{ "zmw", 0xd8000000, 0xfc080000, "r,xOA,X", 4 }, -{ "zmd", 0xd8000002, 0xfc080002, "r,xOA,X", 4 }, -{ "stbp", 0x94080000, 0xfc080000, "r,xOA,X", 4 }, -{ "sthp", 0x94000001, 0xfc080001, "r,xOA,X", 4 }, -{ "stwp", 0x94000000, 0xfc080000, "r,xOA,X", 4 }, -{ "stdp", 0x94000002, 0xfc080002, "r,xOA,X", 4 }, -{ "lil", 0xf80b0000, 0xfc7f0000, "r,D", 4 }, -{ "lwsl1", 0xec000000, 0xfc080000, "r,xOA,X", 4 }, -{ "lwsl2", 0xfc000000, 0xfc080000, "r,xOA,X", 4 }, -{ "lwsl3", 0xfc080000, 0xfc080000, "r,xOA,X", 4 }, - -{ "lvb", 0xb0080000, 0xfc080000, "v,xOA,X", 4 }, -{ "lvh", 0xb0000001, 0xfc080001, "v,xOA,X", 4 }, -{ "lvw", 0xb0000000, 0xfc080000, "v,xOA,X", 4 }, -{ "lvd", 0xb0000002, 0xfc080002, "v,xOA,X", 4 }, -{ "liv", 0x3c040000, 0xfc0f0000, "v,R", 2 }, -{ "livf", 0x3c080000, 0xfc0f0000, "v,R", 2 }, -{ "stvb", 0xd0080000, 0xfc080000, "v,xOA,X", 4 }, -{ "stvh", 0xd0000001, 0xfc080001, "v,xOA,X", 4 }, -{ "stvw", 0xd0000000, 0xfc080000, "v,xOA,X", 4 }, -{ "stvd", 0xd0000002, 0xfc080002, "v,xOA,X", 4 }, - -{ "trr", 0x2c000000, 0xfc0f0000, "r,R", 2 }, -{ "trn", 0x2c040000, 0xfc0f0000, "r,R", 2 }, -{ "trnd", 0x2c0c0000, 0xfc0f0000, "r,R", 2 }, -{ "trabs", 0x2c010000, 0xfc0f0000, "r,R", 2 }, -{ "trabsd", 0x2c090000, 0xfc0f0000, "r,R", 2 }, -{ "trc", 0x2c030000, 0xfc0f0000, "r,R", 2 }, -{ "xcr", 0x28040000, 0xfc0f0000, "r,R", 2 }, -{ "cxcr", 0x2c060000, 0xfc0f0000, "r,R", 2 }, -{ "cxcrd", 0x2c0e0000, 0xfc0f0000, "r,R", 2 }, -{ "tbrr", 0x2c020000, 0xfc0f0000, "r,B", 2 }, -{ "trbr", 0x28030000, 0xfc0f0000, "b,R", 2 }, -{ "xcbr", 0x28020000, 0xfc0f0000, "b,B", 2 }, -{ "tbrbr", 0x28010000, 0xfc0f0000, "b,B", 2 }, - -{ "trvv", 0x28050000, 0xfc0f0000, "v,V", 2 }, -{ "trvvn", 0x2c050000, 0xfc0f0000, "v,V", 2 }, -{ "trvvnd", 0x2c0d0000, 0xfc0f0000, "v,V", 2 }, -{ "trvab", 0x2c070000, 0xfc0f0000, "v,V", 2 }, -{ "trvabd", 0x2c0f0000, 0xfc0f0000, "v,V", 2 }, -{ "cmpv", 0x14060000, 0xfc0f0000, "v,V", 2 }, -{ "expv", 0x14070000, 0xfc0f0000, "v,V", 2 }, -{ "mrvvlt", 0x10030000, 0xfc0f0000, "v,V", 2 }, -{ "mrvvle", 0x10040000, 0xfc0f0000, "v,V", 2 }, -{ "mrvvgt", 0x14030000, 0xfc0f0000, "v,V", 2 }, -{ "mrvvge", 0x14040000, 0xfc0f0000, "v,V", 2 }, -{ "mrvveq", 0x10050000, 0xfc0f0000, "v,V", 2 }, -{ "mrvvne", 0x10050000, 0xfc0f0000, "v,V", 2 }, -{ "mrvrlt", 0x100d0000, 0xfc0f0000, "v,R", 2 }, -{ "mrvrle", 0x100e0000, 0xfc0f0000, "v,R", 2 }, -{ "mrvrgt", 0x140d0000, 0xfc0f0000, "v,R", 2 }, -{ "mrvrge", 0x140e0000, 0xfc0f0000, "v,R", 2 }, -{ "mrvreq", 0x100f0000, 0xfc0f0000, "v,R", 2 }, -{ "mrvrne", 0x140f0000, 0xfc0f0000, "v,R", 2 }, -{ "trvr", 0x140b0000, 0xfc0f0000, "r,V", 2 }, -{ "trrv", 0x140c0000, 0xfc0f0000, "v,R", 2 }, - -{ "bu", 0x40000000, 0xff880000, "xOA,X", 4 }, -{ "bns", 0x70080000, 0xff880000, "xOA,X", 4 }, -{ "bnco", 0x70880000, 0xff880000, "xOA,X", 4 }, -{ "bge", 0x71080000, 0xff880000, "xOA,X", 4 }, -{ "bne", 0x71880000, 0xff880000, "xOA,X", 4 }, -{ "bunge", 0x72080000, 0xff880000, "xOA,X", 4 }, -{ "bunle", 0x72880000, 0xff880000, "xOA,X", 4 }, -{ "bgt", 0x73080000, 0xff880000, "xOA,X", 4 }, -{ "bnany", 0x73880000, 0xff880000, "xOA,X", 4 }, -{ "bs" , 0x70000000, 0xff880000, "xOA,X", 4 }, -{ "bco", 0x70800000, 0xff880000, "xOA,X", 4 }, -{ "blt", 0x71000000, 0xff880000, "xOA,X", 4 }, -{ "beq", 0x71800000, 0xff880000, "xOA,X", 4 }, -{ "buge", 0x72000000, 0xff880000, "xOA,X", 4 }, -{ "bult", 0x72800000, 0xff880000, "xOA,X", 4 }, -{ "ble", 0x73000000, 0xff880000, "xOA,X", 4 }, -{ "bany", 0x73800000, 0xff880000, "xOA,X", 4 }, -{ "brlnk", 0x44000000, 0xfc080000, "r,xOA,X", 4 }, -{ "bib", 0x48000000, 0xfc080000, "r,xOA,X", 4 }, -{ "bih", 0x48080000, 0xfc080000, "r,xOA,X", 4 }, -{ "biw", 0x4c000000, 0xfc080000, "r,xOA,X", 4 }, -{ "bid", 0x4c080000, 0xfc080000, "r,xOA,X", 4 }, -{ "bivb", 0x60000000, 0xfc080000, "r,xOA,X", 4 }, -{ "bivh", 0x60080000, 0xfc080000, "r,xOA,X", 4 }, -{ "bivw", 0x64000000, 0xfc080000, "r,xOA,X", 4 }, -{ "bivd", 0x64080000, 0xfc080000, "r,xOA,X", 4 }, -{ "bvsb", 0x68000000, 0xfc080000, "r,xOA,X", 4 }, -{ "bvsh", 0x68080000, 0xfc080000, "r,xOA,X", 4 }, -{ "bvsw", 0x6c000000, 0xfc080000, "r,xOA,X", 4 }, -{ "bvsd", 0x6c080000, 0xfc080000, "r,xOA,X", 4 }, - -{ "camb", 0x80080000, 0xfc080000, "r,xOA,X", 4 }, -{ "camh", 0x80000001, 0xfc080001, "r,xOA,X", 4 }, -{ "camw", 0x80000000, 0xfc080000, "r,xOA,X", 4 }, -{ "camd", 0x80000002, 0xfc080002, "r,xOA,X", 4 }, -{ "car", 0x10000000, 0xfc0f0000, "r,R", 2 }, -{ "card", 0x14000000, 0xfc0f0000, "r,R", 2 }, -{ "ci", 0xf8050000, 0xfc7f0000, "r,I", 4 }, -{ "chkbnd", 0x5c080000, 0xfc080000, "r,xOA,X", 4 }, - -{ "cavv", 0x10010000, 0xfc0f0000, "v,V", 2 }, -{ "cavr", 0x10020000, 0xfc0f0000, "v,R", 2 }, -{ "cavvd", 0x10090000, 0xfc0f0000, "v,V", 2 }, -{ "cavrd", 0x100b0000, 0xfc0f0000, "v,R", 2 }, - -{ "anmb", 0x84080000, 0xfc080000, "r,xOA,X", 4 }, -{ "anmh", 0x84000001, 0xfc080001, "r,xOA,X", 4 }, -{ "anmw", 0x84000000, 0xfc080000, "r,xOA,X", 4 }, -{ "anmd", 0x84000002, 0xfc080002, "r,xOA,X", 4 }, -{ "anr", 0x04000000, 0xfc0f0000, "r,R", 2 }, -{ "ani", 0xf8080000, 0xfc7f0000, "r,I", 4 }, -{ "ormb", 0xb8080000, 0xfc080000, "r,xOA,X", 4 }, -{ "ormh", 0xb8000001, 0xfc080001, "r,xOA,X", 4 }, -{ "ormw", 0xb8000000, 0xfc080000, "r,xOA,X", 4 }, -{ "ormd", 0xb8000002, 0xfc080002, "r,xOA,X", 4 }, -{ "orr", 0x08000000, 0xfc0f0000, "r,R", 2 }, -{ "oi", 0xf8090000, 0xfc7f0000, "r,I", 4 }, -{ "eomb", 0x8c080000, 0xfc080000, "r,xOA,X", 4 }, -{ "eomh", 0x8c000001, 0xfc080001, "r,xOA,X", 4 }, -{ "eomw", 0x8c000000, 0xfc080000, "r,xOA,X", 4 }, -{ "eomd", 0x8c000002, 0xfc080002, "r,xOA,X", 4 }, -{ "eor", 0x0c000000, 0xfc0f0000, "r,R", 2 }, -{ "eoi", 0xf80a0000, 0xfc7f0000, "r,I", 4 }, - -{ "anvv", 0x04010000, 0xfc0f0000, "v,V", 2 }, -{ "anvr", 0x04020000, 0xfc0f0000, "v,R", 2 }, -{ "orvv", 0x08010000, 0xfc0f0000, "v,V", 2 }, -{ "orvr", 0x08020000, 0xfc0f0000, "v,R", 2 }, -{ "eovv", 0x0c010000, 0xfc0f0000, "v,V", 2 }, -{ "eovr", 0x0c020000, 0xfc0f0000, "v,R", 2 }, - -{ "sacz", 0x100c0000, 0xfc0f0000, "r,R", 2 }, -{ "sla", 0x1c400000, 0xfc600000, "r,S", 2 }, -{ "sll", 0x1c600000, 0xfc600000, "r,S", 2 }, -{ "slc", 0x24400000, 0xfc600000, "r,S", 2 }, -{ "slad", 0x20400000, 0xfc600000, "r,S", 2 }, -{ "slld", 0x20600000, 0xfc600000, "r,S", 2 }, -{ "sra", 0x1c000000, 0xfc600000, "r,S", 2 }, -{ "srl", 0x1c200000, 0xfc600000, "r,S", 2 }, -{ "src", 0x24000000, 0xfc600000, "r,S", 2 }, -{ "srad", 0x20000000, 0xfc600000, "r,S", 2 }, -{ "srld", 0x20200000, 0xfc600000, "r,S", 2 }, -{ "sda", 0x3c030000, 0xfc0f0000, "r,R", 2 }, -{ "sdl", 0x3c020000, 0xfc0f0000, "r,R", 2 }, -{ "sdc", 0x3c010000, 0xfc0f0000, "r,R", 2 }, -{ "sdad", 0x3c0b0000, 0xfc0f0000, "r,R", 2 }, -{ "sdld", 0x3c0a0000, 0xfc0f0000, "r,R", 2 }, - -{ "svda", 0x3c070000, 0xfc0f0000, "v,R", 2 }, -{ "svdl", 0x3c060000, 0xfc0f0000, "v,R", 2 }, -{ "svdc", 0x3c050000, 0xfc0f0000, "v,R", 2 }, -{ "svdad", 0x3c0e0000, 0xfc0f0000, "v,R", 2 }, -{ "svdld", 0x3c0d0000, 0xfc0f0000, "v,R", 2 }, - -{ "sbm", 0xac080000, 0xfc080000, "f,xOA,X", 4 }, -{ "zbm", 0xac000000, 0xfc080000, "f,xOA,X", 4 }, -{ "tbm", 0xa8080000, 0xfc080000, "f,xOA,X", 4 }, -{ "incmb", 0xa0000000, 0xfc080000, "xOA,X", 4 }, -{ "incmh", 0xa0080000, 0xfc080000, "xOA,X", 4 }, -{ "incmw", 0xa4000000, 0xfc080000, "xOA,X", 4 }, -{ "incmd", 0xa4080000, 0xfc080000, "xOA,X", 4 }, -{ "sbmd", 0x7c080000, 0xfc080000, "r,xOA,X", 4 }, -{ "zbmd", 0x7c000000, 0xfc080000, "r,xOA,X", 4 }, -{ "tbmd", 0x78080000, 0xfc080000, "r,xOA,X", 4 }, - -{ "ssm", 0x9c080000, 0xfc080000, "f,xOA,X", 4 }, -{ "zsm", 0x9c000000, 0xfc080000, "f,xOA,X", 4 }, -{ "tsm", 0x98080000, 0xfc080000, "f,xOA,X", 4 }, - -{ "admb", 0xc8080000, 0xfc080000, "r,xOA,X", 4 }, -{ "admh", 0xc8000001, 0xfc080001, "r,xOA,X", 4 }, -{ "admw", 0xc8000000, 0xfc080000, "r,xOA,X", 4 }, -{ "admd", 0xc8000002, 0xfc080002, "r,xOA,X", 4 }, -{ "adr", 0x38000000, 0xfc0f0000, "r,R", 2 }, -{ "armb", 0xe8080000, 0xfc080000, "r,xOA,X", 4 }, -{ "armh", 0xe8000001, 0xfc080001, "r,xOA,X", 4 }, -{ "armw", 0xe8000000, 0xfc080000, "r,xOA,X", 4 }, -{ "armd", 0xe8000002, 0xfc080002, "r,xOA,X", 4 }, -{ "adi", 0xf8010000, 0xfc0f0000, "r,I", 4 }, -{ "sumb", 0xcc080000, 0xfc080000, "r,xOA,X", 4 }, -{ "sumh", 0xcc000001, 0xfc080001, "r,xOA,X", 4 }, -{ "sumw", 0xcc000000, 0xfc080000, "r,xOA,X", 4 }, -{ "sumd", 0xcc000002, 0xfc080002, "r,xOA,X", 4 }, -{ "sur", 0x3c000000, 0xfc0f0000, "r,R", 2 }, -{ "sui", 0xf8020000, 0xfc0f0000, "r,I", 4 }, -{ "mpmb", 0xc0080000, 0xfc080000, "r,xOA,X", 4 }, -{ "mpmh", 0xc0000001, 0xfc080001, "r,xOA,X", 4 }, -{ "mpmw", 0xc0000000, 0xfc080000, "r,xOA,X", 4 }, -{ "mpr", 0x38020000, 0xfc0f0000, "r,R", 2 }, -{ "mprd", 0x3c0f0000, 0xfc0f0000, "r,R", 2 }, -{ "mpi", 0xf8030000, 0xfc0f0000, "r,I", 4 }, -{ "dvmb", 0xc4080000, 0xfc080000, "r,xOA,X", 4 }, -{ "dvmh", 0xc4000001, 0xfc080001, "r,xOA,X", 4 }, -{ "dvmw", 0xc4000000, 0xfc080000, "r,xOA,X", 4 }, -{ "dvr", 0x380a0000, 0xfc0f0000, "r,R", 2 }, -{ "dvi", 0xf8040000, 0xfc0f0000, "r,I", 4 }, -{ "exs", 0x38080000, 0xfc0f0000, "r,R", 2 }, - -{ "advv", 0x30000000, 0xfc0f0000, "v,V", 2 }, -{ "advvd", 0x30080000, 0xfc0f0000, "v,V", 2 }, -{ "adrv", 0x34000000, 0xfc0f0000, "v,R", 2 }, -{ "adrvd", 0x34080000, 0xfc0f0000, "v,R", 2 }, -{ "suvv", 0x30010000, 0xfc0f0000, "v,V", 2 }, -{ "suvvd", 0x30090000, 0xfc0f0000, "v,V", 2 }, -{ "surv", 0x34010000, 0xfc0f0000, "v,R", 2 }, -{ "survd", 0x34090000, 0xfc0f0000, "v,R", 2 }, -{ "mpvv", 0x30020000, 0xfc0f0000, "v,V", 2 }, -{ "mprv", 0x34020000, 0xfc0f0000, "v,R", 2 }, - -{ "adfw", 0xe0080000, 0xfc080000, "r,xOA,X", 4 }, -{ "adfd", 0xe0080002, 0xfc080002, "r,xOA,X", 4 }, -{ "adrfw", 0x38010000, 0xfc0f0000, "r,R", 2 }, -{ "adrfd", 0x38090000, 0xfc0f0000, "r,R", 2 }, -{ "surfw", 0xe0000000, 0xfc080000, "r,xOA,X", 4 }, -{ "surfd", 0xe0000002, 0xfc080002, "r,xOA,X", 4 }, -{ "surfw", 0x38030000, 0xfc0f0000, "r,R", 2 }, -{ "surfd", 0x380b0000, 0xfc0f0000, "r,R", 2 }, -{ "mpfw", 0xe4080000, 0xfc080000, "r,xOA,X", 4 }, -{ "mpfd", 0xe4080002, 0xfc080002, "r,xOA,X", 4 }, -{ "mprfw", 0x38060000, 0xfc0f0000, "r,R", 2 }, -{ "mprfd", 0x380e0000, 0xfc0f0000, "r,R", 2 }, -{ "rfw", 0xe4000000, 0xfc080000, "r,xOA,X", 4 }, -{ "rfd", 0xe4000002, 0xfc080002, "r,xOA,X", 4 }, -{ "rrfw", 0x0c0e0000, 0xfc0f0000, "r", 2 }, -{ "rrfd", 0x0c0f0000, 0xfc0f0000, "r", 2 }, - -{ "advvfw", 0x30040000, 0xfc0f0000, "v,V", 2 }, -{ "advvfd", 0x300c0000, 0xfc0f0000, "v,V", 2 }, -{ "adrvfw", 0x34040000, 0xfc0f0000, "v,R", 2 }, -{ "adrvfd", 0x340c0000, 0xfc0f0000, "v,R", 2 }, -{ "suvvfw", 0x30050000, 0xfc0f0000, "v,V", 2 }, -{ "suvvfd", 0x300d0000, 0xfc0f0000, "v,V", 2 }, -{ "survfw", 0x34050000, 0xfc0f0000, "v,R", 2 }, -{ "survfd", 0x340d0000, 0xfc0f0000, "v,R", 2 }, -{ "mpvvfw", 0x30060000, 0xfc0f0000, "v,V", 2 }, -{ "mpvvfd", 0x300e0000, 0xfc0f0000, "v,V", 2 }, -{ "mprvfw", 0x34060000, 0xfc0f0000, "v,R", 2 }, -{ "mprvfd", 0x340e0000, 0xfc0f0000, "v,R", 2 }, -{ "rvfw", 0x30070000, 0xfc0f0000, "v", 2 }, -{ "rvfd", 0x300f0000, 0xfc0f0000, "v", 2 }, - -{ "fltw", 0x38070000, 0xfc0f0000, "r,R", 2 }, -{ "fltd", 0x380f0000, 0xfc0f0000, "r,R", 2 }, -{ "fixw", 0x38050000, 0xfc0f0000, "r,R", 2 }, -{ "fixd", 0x380d0000, 0xfc0f0000, "r,R", 2 }, -{ "cfpds", 0x3c090000, 0xfc0f0000, "r,R", 2 }, - -{ "fltvw", 0x080d0000, 0xfc0f0000, "v,V", 2 }, -{ "fltvd", 0x080f0000, 0xfc0f0000, "v,V", 2 }, -{ "fixvw", 0x080c0000, 0xfc0f0000, "v,V", 2 }, -{ "fixvd", 0x080e0000, 0xfc0f0000, "v,V", 2 }, -{ "cfpvds", 0x0c0d0000, 0xfc0f0000, "v,V", 2 }, - -{ "orvrn", 0x000a0000, 0xfc0f0000, "r,V", 2 }, -{ "andvrn", 0x00080000, 0xfc0f0000, "r,V", 2 }, -{ "frsteq", 0x04090000, 0xfc0f0000, "r,V", 2 }, -{ "sigma", 0x0c080000, 0xfc0f0000, "r,V", 2 }, -{ "sigmad", 0x0c0a0000, 0xfc0f0000, "r,V", 2 }, -{ "sigmf", 0x08080000, 0xfc0f0000, "r,V", 2 }, -{ "sigmfd", 0x080a0000, 0xfc0f0000, "r,V", 2 }, -{ "prodf", 0x04080000, 0xfc0f0000, "r,V", 2 }, -{ "prodfd", 0x040a0000, 0xfc0f0000, "r,V", 2 }, -{ "maxv", 0x10080000, 0xfc0f0000, "r,V", 2 }, -{ "maxvd", 0x100a0000, 0xfc0f0000, "r,V", 2 }, -{ "minv", 0x14080000, 0xfc0f0000, "r,V", 2 }, -{ "minvd", 0x140a0000, 0xfc0f0000, "r,V", 2 }, - -{ "lpsd", 0xf0000000, 0xfc080000, "xOA,X", 4 }, -{ "ldc", 0xf0080000, 0xfc080000, "xOA,X", 4 }, -{ "spm", 0x040c0000, 0xfc0f0000, "r", 2 }, -{ "rpm", 0x040d0000, 0xfc0f0000, "r", 2 }, -{ "tritr", 0x00070000, 0xfc0f0000, "r", 2 }, -{ "trrit", 0x00060000, 0xfc0f0000, "r", 2 }, -{ "rpswt", 0x04080000, 0xfc0f0000, "r", 2 }, -{ "exr", 0xf8070000, 0xfc0f0000, "", 4 }, -{ "halt", 0x00000000, 0xfc0f0000, "", 2 }, -{ "wait", 0x00010000, 0xfc0f0000, "", 2 }, -{ "nop", 0x00020000, 0xfc0f0000, "", 2 }, -{ "eiae", 0x00030000, 0xfc0f0000, "", 2 }, -{ "efae", 0x000d0000, 0xfc0f0000, "", 2 }, -{ "diae", 0x000e0000, 0xfc0f0000, "", 2 }, -{ "dfae", 0x000f0000, 0xfc0f0000, "", 2 }, -{ "spvc", 0xf8060000, 0xfc0f0000, "r,T,N", 4 }, -{ "rdsts", 0x00090000, 0xfc0f0000, "r", 2 }, -{ "setcpu", 0x000c0000, 0xfc0f0000, "r", 2 }, -{ "cmc", 0x000b0000, 0xfc0f0000, "r", 2 }, -{ "trrcu", 0x00040000, 0xfc0f0000, "r", 2 }, -{ "attnio", 0x00050000, 0xfc0f0000, "", 2 }, -{ "fudit", 0x28080000, 0xfc0f0000, "", 2 }, -{ "break", 0x28090000, 0xfc0f0000, "", 2 }, -{ "frzss", 0x280a0000, 0xfc0f0000, "", 2 }, -{ "ripi", 0x04040000, 0xfc0f0000, "r,R", 2 }, -{ "xcp", 0x04050000, 0xfc0f0000, "r", 2 }, -{ "block", 0x04060000, 0xfc0f0000, "", 2 }, -{ "unblock", 0x04070000, 0xfc0f0000, "", 2 }, -{ "trsc", 0x08060000, 0xfc0f0000, "r,R", 2 }, -{ "tscr", 0x08070000, 0xfc0f0000, "r,R", 2 }, -{ "fq", 0x04080000, 0xfc0f0000, "r", 2 }, -{ "flupte", 0x2c080000, 0xfc0f0000, "r", 2 }, -{ "rviu", 0x040f0000, 0xfc0f0000, "", 2 }, -{ "ldel", 0x280c0000, 0xfc0f0000, "r,R", 2 }, -{ "ldu", 0x280d0000, 0xfc0f0000, "r,R", 2 }, -{ "stdecc", 0x280b0000, 0xfc0f0000, "r,R", 2 }, -{ "trpc", 0x08040000, 0xfc0f0000, "r", 2 }, -{ "tpcr", 0x08050000, 0xfc0f0000, "r", 2 }, -{ "ghalt", 0x0c050000, 0xfc0f0000, "r", 2 }, -{ "grun", 0x0c040000, 0xfc0f0000, "", 2 }, -{ "tmpr", 0x2c0a0000, 0xfc0f0000, "r,R", 2 }, -{ "trmp", 0x2c0b0000, 0xfc0f0000, "r,R", 2 }, - -{ "trrve", 0x28060000, 0xfc0f0000, "r", 2 }, -{ "trver", 0x28070000, 0xfc0f0000, "r", 2 }, -{ "trvlr", 0x280f0000, 0xfc0f0000, "r", 2 }, - -{ "linkfl", 0x18000000, 0xfc0f0000, "r,R", 2 }, -{ "linkbl", 0x18020000, 0xfc0f0000, "r,R", 2 }, -{ "linkfp", 0x18010000, 0xfc0f0000, "r,R", 2 }, -{ "linkbp", 0x18030000, 0xfc0f0000, "r,R", 2 }, -{ "linkpl", 0x18040000, 0xfc0f0000, "r,R", 2 }, -{ "ulinkl", 0x18080000, 0xfc0f0000, "r,R", 2 }, -{ "ulinkp", 0x18090000, 0xfc0f0000, "r,R", 2 }, -{ "ulinktl", 0x180a0000, 0xfc0f0000, "r,R", 2 }, -{ "ulinktp", 0x180b0000, 0xfc0f0000, "r,R", 2 }, -}; - -int numopcodes = sizeof(gld_opcodes) / sizeof(gld_opcodes[0]); - -struct gld_opcode *endop = gld_opcodes + sizeof(gld_opcodes) / - sizeof(gld_opcodes[0]); diff --git a/include/ns32k-opcode.h b/include/ns32k-opcode.h deleted file mode 100755 index cc4ba6b04e2..00000000000 --- a/include/ns32k-opcode.h +++ /dev/null @@ -1,491 +0,0 @@ -/* ns32k-opcode.h -- Opcode table for National Semi 32k processor - Copyright (C) 1987 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler. - -GAS 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 1, or (at your option) -any later version. - -GAS 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 GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - - -#ifdef SEQUENT_COMPATABILITY -#define DEF_MODEC 20 -#define DEF_MODEL 21 -#endif - -#ifndef DEF_MODEC -#define DEF_MODEC 20 -#endif - -#ifndef DEF_MODEL -#define DEF_MODEL 20 -#endif -/* - After deciding the instruction entry (via hash.c) the instruction parser - will try to match the operands after the instruction to the required set - given in the entry operandfield. Every operand will result in a change in - the opcode or the addition of data to the opcode. - The operands in the source instruction are checked for inconsistent - semantics. - - F : 32 bit float general form - L : 64 bit float " - B : byte " - W : word " - D : double-word " - Q : quad-word " - A : double-word gen-address-form ie no regs allowed - d : displacement - b : displacement - pc relative addressing acb - p : displacement - pc relative addressing br bcond bsr cxp - q : quick - i : immediate (8 bits) - This is not a standard ns32k operandtype, it is used to build - instructions like svc arg1,arg2 - Svc is the instruction SuperVisorCall and is sometimes used to - call OS-routines from usermode. Some args might be handy! - r : register number (3 bits) - O : setcfg instruction optionslist - C : cinv instruction optionslist - S : stringinstruction optionslist - U : registerlist save,enter - u : registerlist restore,exit - M : mmu register - P : cpu register - g : 3:rd operand of inss or exts instruction - G : 4:th operand of inss or exts instruction - Those operands are encoded in the same byte. - This byte is placed last in the instruction. - f : operand of sfsr - H : sequent-hack for bsr (Warning) - -column 1 instructions - 2 number of bits in opcode. - 3 number of bits in opcode explicitly - determined by the instruction type. - 4 opcodeseed, the number we build our opcode - from. - 5 operandtypes, used by operandparser. - 6 size in bytes of immediate -*/ -struct ns32k_opcode { - char *name; - unsigned char opcode_id_size; /* not used by the assembler */ - unsigned char opcode_size; - unsigned long opcode_seed; - char *operands; - unsigned char im_size; /* not used by dissassembler */ - char *default_args; /* default to those args when none given */ - char default_modec; /* default to this addr-mode when ambigous - ie when the argument of a general addr-mode - is a plain constant */ - char default_model; /* is a plain label */ -}; - -#ifdef comment -/* This section was from the gdb version of this file. */ - -#ifndef ns32k_opcodeT -#define ns32k_opcodeT int -#endif /* no ns32k_opcodeT */ - -struct not_wot /* ns32k opcode table: wot to do with this */ - /* particular opcode */ -{ - int obits; /* number of opcode bits */ - int ibits; /* number of instruction bits */ - ns32k_opcodeT code; /* op-code (may be > 8 bits!) */ - char *args; /* how to compile said opcode */ -}; - -struct not /* ns32k opcode text */ -{ - char * name; /* opcode name: lowercase string [key] */ - struct not_wot detail; /* rest of opcode table [datum] */ -}; - -/* Instructions look like this: - - basic instruction--1, 2, or 3 bytes - index byte for operand A, if operand A is indexed--1 byte - index byte for operand B, if operand B is indexed--1 byte - addressing extension for operand A - addressing extension for operand B - implied operands - - Operand A is the operand listed first in the following opcode table. - Operand B is the operand listed second in the following opcode table. - All instructions have at most 2 general operands, so this is enough. - The implied operands are associated with operands other than A and B. - - Each operand has a digit and a letter. - - The digit gives the position in the assembly language. The letter, - one of the following, tells us what kind of operand it is. */ - -/* F : 32 bit float - * L : 64 bit float - * B : byte - * W : word - * D : double-word - * Q : quad-word - * d : displacement - * q : quick - * i : immediate (8 bits) - * r : register number (3 bits) - * p : displacement - pc relative addressing -*/ - - -#endif /* comment */ - -static const struct ns32k_opcode ns32k_opcodes[]= -{ - { "absf", 14,24, 0x35be, "1F2F", 4, "", DEF_MODEC,DEF_MODEL }, - { "absl", 14,24, 0x34be, "1L2L", 8, "", DEF_MODEC,DEF_MODEL }, - { "absb", 14,24, 0x304e, "1B2B", 1, "", DEF_MODEC,DEF_MODEL }, - { "absw", 14,24, 0x314e, "1W2W", 2, "", DEF_MODEC,DEF_MODEL }, - { "absd", 14,24, 0x334e, "1D2D", 4, "", DEF_MODEC,DEF_MODEL }, - { "acbb", 7,16, 0x4c, "2B1q3p", 1, "", DEF_MODEC,DEF_MODEL }, - { "acbw", 7,16, 0x4d, "2W1q3p", 2, "", DEF_MODEC,DEF_MODEL }, - { "acbd", 7,16, 0x4f, "2D1q3p", 4, "", DEF_MODEC,DEF_MODEL }, - { "addf", 14,24, 0x01be, "1F2F", 4, "", DEF_MODEC,DEF_MODEL }, - { "addl", 14,24, 0x00be, "1L2L", 8, "", DEF_MODEC,DEF_MODEL }, - { "addb", 6,16, 0x00, "1B2B", 1, "", DEF_MODEC,DEF_MODEL }, - { "addw", 6,16, 0x01, "1W2W", 2, "", DEF_MODEC,DEF_MODEL }, - { "addd", 6,16, 0x03, "1D2D", 4, "", DEF_MODEC,DEF_MODEL }, - { "addcb", 6,16, 0x10, "1B2B", 1, "", DEF_MODEC,DEF_MODEL }, - { "addcw", 6,16, 0x11, "1W2W", 2, "", DEF_MODEC,DEF_MODEL }, - { "addcd", 6,16, 0x13, "1D2D", 4, "", DEF_MODEC,DEF_MODEL }, - { "addpb", 14,24, 0x3c4e, "1B2B", 1, "", DEF_MODEC,DEF_MODEL }, - { "addpw", 14,24, 0x3d4e, "1W2W", 2, "", DEF_MODEC,DEF_MODEL }, - { "addpd", 14,24, 0x3f4e, "1D2D", 4, "", DEF_MODEC,DEF_MODEL }, - { "addqb", 7,16, 0x0c, "2B1q", 1, "", DEF_MODEC,DEF_MODEL }, - { "addqw", 7,16, 0x0d, "2W1q", 2, "", DEF_MODEC,DEF_MODEL }, - { "addqd", 7,16, 0x0f, "2D1q", 4, "", DEF_MODEC,DEF_MODEL }, - { "addr", 6,16, 0x27, "1A2D", 4, "", 21,21 }, - { "adjspb", 11,16, 0x057c, "1B", 1, "", DEF_MODEC,DEF_MODEL }, - { "adjspw", 11,16, 0x057d, "1W", 2, "", DEF_MODEC,DEF_MODEL }, - { "adjspd", 11,16, 0x057f, "1D", 4, "", DEF_MODEC,DEF_MODEL }, - { "andb", 6,16, 0x28, "1B2B", 1, "", DEF_MODEC,DEF_MODEL }, - { "andw", 6,16, 0x29, "1W2W", 2, "", DEF_MODEC,DEF_MODEL }, - { "andd", 6,16, 0x2b, "1D2D", 4, "", DEF_MODEC,DEF_MODEL }, - { "ashb", 14,24, 0x044e, "1B2B", 1, "", DEF_MODEC,DEF_MODEL }, - { "ashw", 14,24, 0x054e, "1B2W", 1, "", DEF_MODEC,DEF_MODEL }, - { "ashd", 14,24, 0x074e, "1B2D", 1, "", DEF_MODEC,DEF_MODEL }, - { "beq", 8,8, 0x0a, "1p", 0, "", 21,21 }, - { "bne", 8,8, 0x1a, "1p", 0, "", 21,21 }, - { "bcs", 8,8, 0x2a, "1p", 0, "", 21,21 }, - { "bcc", 8,8, 0x3a, "1p", 0, "", 21,21 }, - { "bhi", 8,8, 0x4a, "1p", 0, "", 21,21 }, - { "bls", 8,8, 0x5a, "1p", 0, "", 21,21 }, - { "bgt", 8,8, 0x6a, "1p", 0, "", 21,21 }, - { "ble", 8,8, 0x7a, "1p", 0, "", 21,21 }, - { "bfs", 8,8, 0x8a, "1p", 0, "", 21,21 }, - { "bfc", 8,8, 0x9a, "1p", 0, "", 21,21 }, - { "blo", 8,8, 0xaa, "1p", 0, "", 21,21 }, - { "bhs", 8,8, 0xba, "1p", 0, "", 21,21 }, - { "blt", 8,8, 0xca, "1p", 0, "", 21,21 }, - { "bge", 8,8, 0xda, "1p", 0, "", 21,21 }, - { "but", 8,8, 0xea, "1p", 0, "", 21,21 }, - { "buf", 8,8, 0xfa, "1p", 0, "", 21,21 }, - { "bicb", 6,16, 0x08, "1B2B", 1, "", DEF_MODEC,DEF_MODEL }, - { "bicw", 6,16, 0x09, "1W2W", 2, "", DEF_MODEC,DEF_MODEL }, - { "bicd", 6,16, 0x0b, "1D2D", 4, "", DEF_MODEC,DEF_MODEL }, - { "bicpsrb", 11,16, 0x17c, "1B", 1, "", DEF_MODEC,DEF_MODEL }, - { "bicpsrw", 11,16, 0x17d, "1W", 2, "", DEF_MODEC,DEF_MODEL }, - { "bispsrb", 11,16, 0x37c, "1B", 1, "", DEF_MODEC,DEF_MODEL }, - { "bispsrw", 11,16, 0x37d, "1W", 2, "", DEF_MODEC,DEF_MODEL }, - { "bpt", 8,8, 0xf2, "", 0, "", DEF_MODEC,DEF_MODEL }, - { "br", 8,8, 0xea, "1p", 0, "", 21,21 }, -#ifdef SEQUENT_COMPATABILITY - { "bsr", 8,8, 0x02, "1H", 0, "", 21,21 }, -#else - { "bsr", 8,8, 0x02, "1p", 0, "", 21,21 }, -#endif - { "caseb", 11,16, 0x77c, "1B", 1, "", DEF_MODEC,DEF_MODEL }, - { "casew", 11,16, 0x77d, "1W", 2, "", DEF_MODEC,DEF_MODEL }, - { "cased", 11,16, 0x77f, "1D", 4, "", DEF_MODEC,DEF_MODEL }, - { "cbitb", 14,24, 0x084e, "1B2D", 1, "", DEF_MODEC,DEF_MODEL }, - { "cbitw", 14,24, 0x094e, "1W2D", 2, "", DEF_MODEC,DEF_MODEL }, - { "cbitd", 14,24, 0x0b4e, "1D2D", 4, "", DEF_MODEC,DEF_MODEL }, - { "cbitib", 14,24, 0x0c4e, "1B2D", 1, "", DEF_MODEC,DEF_MODEL }, - { "cbitiw", 14,24, 0x0d4e, "1W2D", 2, "", DEF_MODEC,DEF_MODEL }, - { "cbitid", 14,24, 0x0f4e, "1D2D", 4, "", DEF_MODEC,DEF_MODEL }, - { "checkb", 11,24, 0x0ee, "2A3B1r", 1, "", DEF_MODEC,DEF_MODEL }, - { "checkw", 11,24, 0x1ee, "2A3W1r", 2, "", DEF_MODEC,DEF_MODEL }, - { "checkd", 11,24, 0x3ee, "2A3D1r", 4, "", DEF_MODEC,DEF_MODEL }, - { "cinv", 14,24, 0x271e, "2D1C", 4, "", DEF_MODEC,DEF_MODEL }, - { "cmpf", 14,24, 0x09be, "1F2F", 4, "", DEF_MODEC,DEF_MODEL }, - { "cmpl", 14,24, 0x08be, "1L2L", 8, "", DEF_MODEC,DEF_MODEL }, - { "cmpb", 6,16, 0x04, "1B2B", 1, "", DEF_MODEC,DEF_MODEL }, - { "cmpw", 6,16, 0x05, "1W2W", 2, "", DEF_MODEC,DEF_MODEL }, - { "cmpd", 6,16, 0x07, "1D2D", 4, "", DEF_MODEC,DEF_MODEL }, - { "cmpmb", 14,24, 0x04ce, "1A2A3b", 1, "", DEF_MODEC,DEF_MODEL }, - { "cmpmw", 14,24, 0x05ce, "1A2A3b", 2, "", DEF_MODEC,DEF_MODEL }, - { "cmpmd", 14,24, 0x07ce, "1A2A3b", 4, "", DEF_MODEC,DEF_MODEL }, - { "cmpqb", 7,16, 0x1c, "2B1q", 1, "", DEF_MODEC,DEF_MODEL }, - { "cmpqw", 7,16, 0x1d, "2W1q", 2, "", DEF_MODEC,DEF_MODEL }, - { "cmpqd", 7,16, 0x1f, "2D1q", 4, "", DEF_MODEC,DEF_MODEL }, - { "cmpsb", 16,24, 0x040e, "1S", 0, "[]", DEF_MODEC,DEF_MODEL }, - { "cmpsw", 16,24, 0x050e, "1S", 0, "[]", DEF_MODEC,DEF_MODEL }, - { "cmpsd", 16,24, 0x070e, "1S", 0, "[]", DEF_MODEC,DEF_MODEL }, - { "cmpst", 16,24, 0x840e, "1S", 0, "[]", DEF_MODEC,DEF_MODEL }, - { "comb", 14,24, 0x344e, "1B2B", 1, "", DEF_MODEC,DEF_MODEL }, - { "comw", 14,24, 0x354e, "1W2W", 2, "", DEF_MODEC,DEF_MODEL }, - { "comd", 14,24, 0x374e, "1D2D", 4, "", DEF_MODEC,DEF_MODEL }, - { "cvtp", 11,24, 0x036e, "2A3D1r", 4, "", DEF_MODEC,DEF_MODEL }, - { "cxp", 8,8, 0x22, "1p", 0, "", 21,21 }, - { "cxpd", 11,16, 0x07f, "1A", 4, "", DEF_MODEC,DEF_MODEL }, - { "deib", 14,24, 0x2cce, "1B2W", 1, "", DEF_MODEC,DEF_MODEL }, - { "deiw", 14,24, 0x2dce, "1W2D", 2, "", DEF_MODEC,DEF_MODEL }, - { "deid", 14,24, 0x2fce, "1D2Q", 4, "", DEF_MODEC,DEF_MODEL }, - { "dia", 8,8, 0xc2, "", 1, "", DEF_MODEC,DEF_MODEL }, - { "divf", 14,24, 0x21be, "1F2F", 4, "", DEF_MODEC,DEF_MODEL }, - { "divl", 14,24, 0x20be, "1L2L", 8, "", DEF_MODEC,DEF_MODEL }, - { "divb", 14,24, 0x3cce, "1B2B", 1, "", DEF_MODEC,DEF_MODEL }, - { "divw", 14,24, 0x3dce, "1W2W", 2, "", DEF_MODEC,DEF_MODEL }, - { "divd", 14,24, 0x3fce, "1D2D", 4, "", DEF_MODEC,DEF_MODEL }, - { "enter", 8,8, 0x82, "1U2d", 0, "", DEF_MODEC,DEF_MODEL }, - { "exit", 8,8, 0x92, "1u", 0, "", DEF_MODEC,DEF_MODEL }, - { "extb", 11,24, 0x02e, "2D3B1r4d", 1, "", DEF_MODEC,DEF_MODEL }, - { "extw", 11,24, 0x12e, "2D3W1r4d", 2, "", DEF_MODEC,DEF_MODEL }, - { "extd", 11,24, 0x32e, "2D3D1r4d", 4, "", DEF_MODEC,DEF_MODEL }, - { "extsb", 14,24, 0x0cce, "1D2B3g4G", 1, "", DEF_MODEC,DEF_MODEL }, - { "extsw", 14,24, 0x0dce, "1D2W3g4G", 2, "", DEF_MODEC,DEF_MODEL }, - { "extsd", 14,24, 0x0fce, "1D2D3g4G", 4, "", DEF_MODEC,DEF_MODEL }, - { "ffsb", 14,24, 0x046e, "1B2B", 1, "", DEF_MODEC,DEF_MODEL }, - { "ffsw", 14,24, 0x056e, "1W2B", 2, "", DEF_MODEC,DEF_MODEL }, - { "ffsd", 14,24, 0x076e, "1D2B", 4, "", DEF_MODEC,DEF_MODEL }, - { "flag", 8,8, 0xd2, "", 0, "", DEF_MODEC,DEF_MODEL }, - { "floorfb", 14,24, 0x3c3e, "1F2B", 4, "", DEF_MODEC,DEF_MODEL }, - { "floorfw", 14,24, 0x3d3e, "1F2W", 4, "", DEF_MODEC,DEF_MODEL }, - { "floorfd", 14,24, 0x3f3e, "1F2D", 4, "", DEF_MODEC,DEF_MODEL }, - { "floorlb", 14,24, 0x383e, "1L2B", 8, "", DEF_MODEC,DEF_MODEL }, - { "floorlw", 14,24, 0x393e, "1L2W", 8, "", DEF_MODEC,DEF_MODEL }, - { "floorld", 14,24, 0x3b3e, "1L2D", 8, "", DEF_MODEC,DEF_MODEL }, - { "ibitb", 14,24, 0x384e, "1B2D", 1, "", DEF_MODEC,DEF_MODEL }, - { "ibitw", 14,24, 0x394e, "1W2D", 2, "", DEF_MODEC,DEF_MODEL }, - { "ibitd", 14,24, 0x3b4e, "1D2D", 4, "", DEF_MODEC,DEF_MODEL }, - { "indexb", 11,24, 0x42e, "2B3B1r", 1, "", DEF_MODEC,DEF_MODEL }, - { "indexw", 11,24, 0x52e, "2W3W1r", 2, "", DEF_MODEC,DEF_MODEL }, - { "indexd", 11,24, 0x72e, "2D3D1r", 4, "", DEF_MODEC,DEF_MODEL }, - { "insb", 11,24, 0x0ae, "2B3B1r4d", 1, "", DEF_MODEC,DEF_MODEL }, - { "insw", 11,24, 0x1ae, "2W3W1r4d", 2, "", DEF_MODEC,DEF_MODEL }, - { "insd", 11,24, 0x3ae, "2D3D1r4d", 4, "", DEF_MODEC,DEF_MODEL }, - { "inssb", 14,24, 0x08ce, "1B2D3g4G", 1, "", DEF_MODEC,DEF_MODEL }, - { "inssw", 14,24, 0x09ce, "1W2D3g4G", 2, "", DEF_MODEC,DEF_MODEL }, - { "inssd", 14,24, 0x0bce, "1D2D3g4G", 4, "", DEF_MODEC,DEF_MODEL }, - { "jsr", 11,16, 0x67f, "1A", 4, "", 21,21 }, - { "jump", 11,16, 0x27f, "1A", 4, "", 21,21 }, - { "lfsr", 19,24, 0x00f3e,"1D", 4, "", DEF_MODEC,DEF_MODEL }, - { "lmr", 15,24, 0x0b1e, "2D1M", 4, "", DEF_MODEC,DEF_MODEL }, - { "lprb", 7,16, 0x6c, "2B1P", 1, "", DEF_MODEC,DEF_MODEL }, - { "lprw", 7,16, 0x6d, "2W1P", 2, "", DEF_MODEC,DEF_MODEL }, - { "lprd", 7,16, 0x6f, "2D1P", 4, "", DEF_MODEC,DEF_MODEL }, - { "lshb", 14,24, 0x144e, "1B2B", 1, "", DEF_MODEC,DEF_MODEL }, - { "lshw", 14,24, 0x154e, "1B2W", 1, "", DEF_MODEC,DEF_MODEL }, - { "lshd", 14,24, 0x174e, "1B2D", 1, "", DEF_MODEC,DEF_MODEL }, - { "meib", 14,24, 0x24ce, "1B2W", 1, "", DEF_MODEC,DEF_MODEL }, - { "meiw", 14,24, 0x25ce, "1W2D", 2, "", DEF_MODEC,DEF_MODEL }, - { "meid", 14,24, 0x27ce, "1D2Q", 4, "", DEF_MODEC,DEF_MODEL }, - { "modb", 14,24, 0x38ce, "1B2B", 1, "", DEF_MODEC,DEF_MODEL }, - { "modw", 14,24, 0x39ce, "1W2W", 2, "", DEF_MODEC,DEF_MODEL }, - { "modd", 14,24, 0x3bce, "1D2D", 4, "", DEF_MODEC,DEF_MODEL }, - { "movf", 14,24, 0x05be, "1F2F", 4, "", DEF_MODEC,DEF_MODEL }, - { "movl", 14,24, 0x04be, "1L2L", 8, "", DEF_MODEC,DEF_MODEL }, - { "movb", 6,16, 0x14, "1B2B", 1, "", DEF_MODEC,DEF_MODEL }, - { "movw", 6,16, 0x15, "1W2W", 2, "", DEF_MODEC,DEF_MODEL }, - { "movd", 6,16, 0x17, "1D2D", 4, "", DEF_MODEC,DEF_MODEL }, - { "movbf", 14,24, 0x043e, "1B2F", 1, "", DEF_MODEC,DEF_MODEL }, - { "movwf", 14,24, 0x053e, "1W2F", 2, "", DEF_MODEC,DEF_MODEL }, - { "movdf", 14,24, 0x073e, "1D2F", 4, "", DEF_MODEC,DEF_MODEL }, - { "movbl", 14,24, 0x003e, "1B2L", 1, "", DEF_MODEC,DEF_MODEL }, - { "movwl", 14,24, 0x013e, "1W2L", 2, "", DEF_MODEC,DEF_MODEL }, - { "movdl", 14,24, 0x033e, "1D2L", 4, "", DEF_MODEC,DEF_MODEL }, - { "movfl", 14,24, 0x1b3e, "1F2L", 4, "", DEF_MODEC,DEF_MODEL }, - { "movlf", 14,24, 0x163e, "1L2F", 8, "", DEF_MODEC,DEF_MODEL }, - { "movmb", 14,24, 0x00ce, "1A2A3b", 1, "", DEF_MODEC,DEF_MODEL }, - { "movmw", 14,24, 0x01ce, "1A2A3b", 2, "", DEF_MODEC,DEF_MODEL }, - { "movmd", 14,24, 0x03ce, "1A2A3b", 4, "", DEF_MODEC,DEF_MODEL }, - { "movqb", 7,16, 0x5c, "2B1q", 1, "", DEF_MODEC,DEF_MODEL }, - { "movqw", 7,16, 0x5d, "2B1q", 2, "", DEF_MODEC,DEF_MODEL }, - { "movqd", 7,16, 0x5f, "2B1q", 4, "", DEF_MODEC,DEF_MODEL }, - { "movsb", 16,24, 0x000e, "1S", 0, "[]", DEF_MODEC,DEF_MODEL }, - { "movsw", 16,24, 0x010e, "1S", 0, "[]", DEF_MODEC,DEF_MODEL }, - { "movsd", 16,24, 0x030e, "1S", 0, "[]", DEF_MODEC,DEF_MODEL }, - { "movst", 16,24, 0x800e, "1S", 0, "[]", DEF_MODEC,DEF_MODEL }, - { "movsub", 14,24, 0x0cae, "1A2A", 1, "", DEF_MODEC,DEF_MODEL }, - { "movsuw", 14,24, 0x0dae, "1A2A", 2, "", DEF_MODEC,DEF_MODEL }, - { "movsud", 14,24, 0x0fae, "1A2A", 4, "", DEF_MODEC,DEF_MODEL }, - { "movusb", 14,24, 0x1cae, "1A2A", 1, "", DEF_MODEC,DEF_MODEL }, - { "movusw", 14,24, 0x1dae, "1A2A", 2, "", DEF_MODEC,DEF_MODEL }, - { "movusd", 14,24, 0x1fae, "1A2A", 4, "", DEF_MODEC,DEF_MODEL }, - { "movxbd", 14,24, 0x1cce, "1B2D", 1, "", DEF_MODEC,DEF_MODEL }, - { "movxwd", 14,24, 0x1dce, "1W2D", 2, "", DEF_MODEC,DEF_MODEL }, - { "movxbw", 14,24, 0x10ce, "1B2W", 1, "", DEF_MODEC,DEF_MODEL }, - { "movzbd", 14,24, 0x18ce, "1B2D", 1, "", DEF_MODEC,DEF_MODEL }, - { "movzwd", 14,24, 0x19ce, "1W2D", 2, "", DEF_MODEC,DEF_MODEL }, - { "movzbw", 14,24, 0x14ce, "1B2W", 1, "", DEF_MODEC,DEF_MODEL }, - { "mulf", 14,24, 0x31be, "1F2F", 4, "", DEF_MODEC,DEF_MODEL }, - { "mull", 14,24, 0x30be, "1L2L", 8, "", DEF_MODEC,DEF_MODEL }, - { "mulb", 14,24, 0x20ce, "1B2B", 1, "", DEF_MODEC,DEF_MODEL }, - { "mulw", 14,24, 0x21ce, "1W2W", 2, "", DEF_MODEC,DEF_MODEL }, - { "muld", 14,24, 0x23ce, "1D2D", 4, "", DEF_MODEC,DEF_MODEL }, - { "negf", 14,24, 0x15be, "1F2F", 4, "", DEF_MODEC,DEF_MODEL }, - { "negl", 14,24, 0x14be, "1L2L", 8, "", DEF_MODEC,DEF_MODEL }, - { "negb", 14,24, 0x204e, "1B2B", 1, "", DEF_MODEC,DEF_MODEL }, - { "negw", 14,24, 0x214e, "1W2W", 2, "", DEF_MODEC,DEF_MODEL }, - { "negd", 14,24, 0x234e, "1D2D", 4, "", DEF_MODEC,DEF_MODEL }, - { "nop", 8,8, 0xa2, "", 0, "", DEF_MODEC,DEF_MODEL }, - { "notb", 14,24, 0x244e, "1B2B", 1, "", DEF_MODEC,DEF_MODEL }, - { "notw", 14,24, 0x254e, "1W2W", 2, "", DEF_MODEC,DEF_MODEL }, - { "notd", 14,24, 0x274e, "1D2D", 4, "", DEF_MODEC,DEF_MODEL }, - { "orb", 6,16, 0x18, "1B2B", 1, "", DEF_MODEC,DEF_MODEL }, - { "orw", 6,16, 0x19, "1W2W", 2, "", DEF_MODEC,DEF_MODEL }, - { "ord", 6,16, 0x1b, "1D2D", 4, "", DEF_MODEC,DEF_MODEL }, - { "quob", 14,24, 0x30ce, "1B2B", 1, "", DEF_MODEC,DEF_MODEL }, - { "quow", 14,24, 0x31ce, "1W2W", 2, "", DEF_MODEC,DEF_MODEL }, - { "quod", 14,24, 0x33ce, "1D2D", 4, "", DEF_MODEC,DEF_MODEL }, - { "rdval", 19,24, 0x0031e,"1A", 4, "", DEF_MODEC,DEF_MODEL }, - { "remb", 14,24, 0x34ce, "1B2B", 1, "", DEF_MODEC,DEF_MODEL }, - { "remw", 14,24, 0x35ce, "1W2W", 2, "", DEF_MODEC,DEF_MODEL }, - { "remd", 14,24, 0x37ce, "1D2D", 4, "", DEF_MODEC,DEF_MODEL }, - { "restore", 8,8, 0x72, "1u", 0, "", DEF_MODEC,DEF_MODEL }, - { "ret", 8,8, 0x12, "1d", 0, "", DEF_MODEC,DEF_MODEL }, - { "reti", 8,8, 0x52, "", 0, "", DEF_MODEC,DEF_MODEL }, - { "rett", 8,8, 0x42, "1d", 0, "", DEF_MODEC,DEF_MODEL }, - { "rotb", 14,24, 0x004e, "1B2B", 1, "", DEF_MODEC,DEF_MODEL }, - { "rotw", 14,24, 0x014e, "1B2W", 1, "", DEF_MODEC,DEF_MODEL }, - { "rotd", 14,24, 0x034e, "1B2D", 1, "", DEF_MODEC,DEF_MODEL }, - { "roundfb", 14,24, 0x243e, "1F2B", 4, "", DEF_MODEC,DEF_MODEL }, - { "roundfw", 14,24, 0x253e, "1F2W", 4, "", DEF_MODEC,DEF_MODEL }, - { "roundfd", 14,24, 0x273e, "1F2D", 4, "", DEF_MODEC,DEF_MODEL }, - { "roundlb", 14,24, 0x203e, "1L2B", 8, "", DEF_MODEC,DEF_MODEL }, - { "roundlw", 14,24, 0x213e, "1L2W", 8, "", DEF_MODEC,DEF_MODEL }, - { "roundld", 14,24, 0x233e, "1L2D", 8, "", DEF_MODEC,DEF_MODEL }, - { "rxp", 8,8, 0x32, "1d", 0, "", DEF_MODEC,DEF_MODEL }, - { "seqb", 11,16, 0x3c, "1B", 0, "", DEF_MODEC,DEF_MODEL }, - { "seqw", 11,16, 0x3d, "1W", 0, "", DEF_MODEC,DEF_MODEL }, - { "seqd", 11,16, 0x3f, "1D", 0, "", DEF_MODEC,DEF_MODEL }, - { "sneb", 11,16, 0xbc, "1B", 0, "", DEF_MODEC,DEF_MODEL }, - { "snew", 11,16, 0xbd, "1W", 0, "", DEF_MODEC,DEF_MODEL }, - { "sned", 11,16, 0xbf, "1D", 0, "", DEF_MODEC,DEF_MODEL }, - { "scsb", 11,16, 0x13c, "1B", 0, "", DEF_MODEC,DEF_MODEL }, - { "scsw", 11,16, 0x13d, "1W", 0, "", DEF_MODEC,DEF_MODEL }, - { "scsd", 11,16, 0x13f, "1D", 0, "", DEF_MODEC,DEF_MODEL }, - { "sccb", 11,16, 0x1bc, "1B", 0, "", DEF_MODEC,DEF_MODEL }, - { "sccw", 11,16, 0x1bd, "1W", 0, "", DEF_MODEC,DEF_MODEL }, - { "sccd", 11,16, 0x1bf, "1D", 0, "", DEF_MODEC,DEF_MODEL }, - { "shib", 11,16, 0x23c, "1B", 0, "", DEF_MODEC,DEF_MODEL }, - { "shiw", 11,16, 0x23d, "1W", 0, "", DEF_MODEC,DEF_MODEL }, - { "shid", 11,16, 0x23f, "1D", 0, "", DEF_MODEC,DEF_MODEL }, - { "slsb", 11,16, 0x2bc, "1B", 0, "", DEF_MODEC,DEF_MODEL }, - { "slsw", 11,16, 0x2bd, "1W", 0, "", DEF_MODEC,DEF_MODEL }, - { "slsd", 11,16, 0x2bf, "1D", 0, "", DEF_MODEC,DEF_MODEL }, - { "sgtb", 11,16, 0x33c, "1B", 0, "", DEF_MODEC,DEF_MODEL }, - { "sgtw", 11,16, 0x33d, "1W", 0, "", DEF_MODEC,DEF_MODEL }, - { "sgtd", 11,16, 0x33f, "1D", 0, "", DEF_MODEC,DEF_MODEL }, - { "sleb", 11,16, 0x3bc, "1B", 0, "", DEF_MODEC,DEF_MODEL }, - { "slew", 11,16, 0x3bd, "1W", 0, "", DEF_MODEC,DEF_MODEL }, - { "sled", 11,16, 0x3bf, "1D", 0, "", DEF_MODEC,DEF_MODEL }, - { "sfsb", 11,16, 0x43c, "1B", 0, "", DEF_MODEC,DEF_MODEL }, - { "sfsw", 11,16, 0x43d, "1W", 0, "", DEF_MODEC,DEF_MODEL }, - { "sfsd", 11,16, 0x43f, "1D", 0, "", DEF_MODEC,DEF_MODEL }, - { "sfcb", 11,16, 0x4bc, "1B", 0, "", DEF_MODEC,DEF_MODEL }, - { "sfcw", 11,16, 0x4bd, "1W", 0, "", DEF_MODEC,DEF_MODEL }, - { "sfcd", 11,16, 0x4bf, "1D", 0, "", DEF_MODEC,DEF_MODEL }, - { "slob", 11,16, 0x53c, "1B", 0, "", DEF_MODEC,DEF_MODEL }, - { "slow", 11,16, 0x53d, "1W", 0, "", DEF_MODEC,DEF_MODEL }, - { "slod", 11,16, 0x53f, "1D", 0, "", DEF_MODEC,DEF_MODEL }, - { "shsb", 11,16, 0x5bc, "1B", 0, "", DEF_MODEC,DEF_MODEL }, - { "shsw", 11,16, 0x5bd, "1W", 0, "", DEF_MODEC,DEF_MODEL }, - { "shsd", 11,16, 0x5bf, "1D", 0, "", DEF_MODEC,DEF_MODEL }, - { "sltb", 11,16, 0x63c, "1B", 0, "", DEF_MODEC,DEF_MODEL }, - { "sltw", 11,16, 0x63d, "1W", 0, "", DEF_MODEC,DEF_MODEL }, - { "sltd", 11,16, 0x63f, "1D", 0, "", DEF_MODEC,DEF_MODEL }, - { "sgeb", 11,16, 0x6bc, "1B", 0, "", DEF_MODEC,DEF_MODEL }, - { "sgew", 11,16, 0x6bd, "1W", 0, "", DEF_MODEC,DEF_MODEL }, - { "sged", 11,16, 0x6bf, "1D", 0, "", DEF_MODEC,DEF_MODEL }, - { "sutb", 11,16, 0x73c, "1B", 0, "", DEF_MODEC,DEF_MODEL }, - { "sutw", 11,16, 0x73d, "1W", 0, "", DEF_MODEC,DEF_MODEL }, - { "sutd", 11,16, 0x73f, "1D", 0, "", DEF_MODEC,DEF_MODEL }, - { "sufb", 11,16, 0x7bc, "1B", 0, "", DEF_MODEC,DEF_MODEL }, - { "sufw", 11,16, 0x7bd, "1W", 0, "", DEF_MODEC,DEF_MODEL }, - { "sufd", 11,16, 0x7bf, "1D", 0, "", DEF_MODEC,DEF_MODEL }, - { "save", 8,8, 0x62, "1U", 0, "", DEF_MODEC,DEF_MODEL }, - { "sbitb", 14,24, 0x184e, "1B2A", 1, "", DEF_MODEC,DEF_MODEL }, - { "sbitw", 14,24, 0x194e, "1W2A", 2, "", DEF_MODEC,DEF_MODEL }, - { "sbitd", 14,24, 0x1b4e, "1D2A", 4, "", DEF_MODEC,DEF_MODEL }, - { "sbitib", 14,24, 0x1c4e, "1B2A", 1, "", DEF_MODEC,DEF_MODEL }, - { "sbitiw", 14,24, 0x1d4e, "1W2A", 2, "", DEF_MODEC,DEF_MODEL }, - { "sbitid", 14,24, 0x1f4e, "1D2A", 4, "", DEF_MODEC,DEF_MODEL }, - { "setcfg", 15,24, 0x0b0e, "1O", 0, "", DEF_MODEC,DEF_MODEL }, - { "sfsr", 14,24, 0x373e, "1f", 0, "", DEF_MODEC,DEF_MODEL }, - { "skpsb", 16,24, 0x0c0e, "1S", 0, "[]", DEF_MODEC,DEF_MODEL }, - { "skpsw", 16,24, 0x0d0e, "1S", 0, "[]", DEF_MODEC,DEF_MODEL }, - { "skpsd", 16,24, 0x0f0e, "1S", 0, "[]", DEF_MODEC,DEF_MODEL }, - { "skpst", 16,24, 0x8c0e, "1S", 0, "[]", DEF_MODEC,DEF_MODEL }, - { "smr", 15,24, 0x0f1e, "2D1M", 4, "", DEF_MODEC,DEF_MODEL }, - { "sprb", 7,16, 0x2c, "2B1P", 1, "", DEF_MODEC,DEF_MODEL }, - { "sprw", 7,16, 0x2d, "2W1P", 2, "", DEF_MODEC,DEF_MODEL }, - { "sprd", 7,16, 0x2f, "2D1P", 4, "", DEF_MODEC,DEF_MODEL }, - { "subf", 14,24, 0x11be, "1F2F", 4, "", DEF_MODEC,DEF_MODEL }, - { "subl", 14,24, 0x10be, "1L2L", 8, "", DEF_MODEC,DEF_MODEL }, - { "subb", 6,16, 0x20, "1B2B", 1, "", DEF_MODEC,DEF_MODEL }, - { "subw", 6,16, 0x21, "1W2W", 2, "", DEF_MODEC,DEF_MODEL }, - { "subd", 6,16, 0x23, "1D2D", 4, "", DEF_MODEC,DEF_MODEL }, - { "subcb", 6,16, 0x30, "1B2B", 1, "", DEF_MODEC,DEF_MODEL }, - { "subcw", 6,16, 0x31, "1W2W", 2, "", DEF_MODEC,DEF_MODEL }, - { "subcd", 6,16, 0x33, "1D2D", 4, "", DEF_MODEC,DEF_MODEL }, - { "subpb", 14,24, 0x2c4e, "1B2B", 1, "", DEF_MODEC,DEF_MODEL }, - { "subpw", 14,24, 0x2d4e, "1W2W", 2, "", DEF_MODEC,DEF_MODEL }, - { "subpd", 14,24, 0x2f4e, "1D2D", 4, "", DEF_MODEC,DEF_MODEL }, -#ifdef NS32K_SVC_IMMED_OPERANDS - { "svc", 8,8, 0xe2, "2i1i", 1, "", DEF_MODEC,DEF_MODEL }, /* not really, but unix uses it */ -#else - { "svc", 8,8, 0xe2, "", 0, "", DEF_MODEC,DEF_MODEL }, -#endif - { "tbitb", 6,16, 0x34, "1B2A", 1, "", DEF_MODEC,DEF_MODEL }, - { "tbitw", 6,16, 0x35, "1W2A", 2, "", DEF_MODEC,DEF_MODEL }, - { "tbitd", 6,16, 0x37, "1D2A", 4, "", DEF_MODEC,DEF_MODEL }, - { "truncfb", 14,24, 0x2c3e, "1F2B", 4, "", DEF_MODEC,DEF_MODEL }, - { "truncfw", 14,24, 0x2d3e, "1F2W", 4, "", DEF_MODEC,DEF_MODEL }, - { "truncfd", 14,24, 0x2f3e, "1F2D", 4, "", DEF_MODEC,DEF_MODEL }, - { "trunclb", 14,24, 0x283e, "1L2B", 8, "", DEF_MODEC,DEF_MODEL }, - { "trunclw", 14,24, 0x293e, "1L2W", 8, "", DEF_MODEC,DEF_MODEL }, - { "truncld", 14,24, 0x2b3e, "1L2D", 8, "", DEF_MODEC,DEF_MODEL }, - { "wait", 8,8, 0xb2, "", 0, "", DEF_MODEC,DEF_MODEL }, - { "wrval", 19,24, 0x0071e,"1A", 0, "", DEF_MODEC,DEF_MODEL }, - { "xorb", 6,16, 0x38, "1B2B", 1, "", DEF_MODEC,DEF_MODEL }, - { "xorw", 6,16, 0x39, "1W2W", 2, "", DEF_MODEC,DEF_MODEL }, - { "xord", 6,16, 0x3b, "1D2D", 4, "", DEF_MODEC,DEF_MODEL }, -#if defined(NS32381) /* I'm not too sure of these */ - { "dotf", 14,24, 0x0dfe, "1F2F", 4, "", DEF_MODEC,DEF_MODEL }, - { "dotl", 14,24, 0x0cfe, "1L2L", 8, "", DEF_MODEC,DEF_MODEL }, - { "logbf", 14,24, 0x15fe, "1F2F", 4, "", DEF_MODEC,DEF_MODEL }, - { "logbl", 14,24, 0x14fe, "1L2L", 8, "", DEF_MODEC,DEF_MODEL }, - { "polyf", 14,24, 0x09fe, "1F2F", 4, "", DEF_MODEC,DEF_MODEL }, - { "polyl", 14,24, 0x08fe, "1L2L", 8, "", DEF_MODEC,DEF_MODEL }, - { "scalbf", 14,24, 0x11fe, "1F2F", 4, "", DEF_MODEC,DEF_MODEL }, - { "scalbl", 14,24, 0x10fe, "1L2L", 8, "", DEF_MODEC,DEF_MODEL }, -#endif -}; - -static const int numopcodes=sizeof(ns32k_opcodes)/sizeof(ns32k_opcodes[0]); - -static const struct ns32k_opcode *endop = ns32k_opcodes+sizeof(ns32k_opcodes)/sizeof(ns32k_opcodes[0]); - -#define MAX_ARGS 4 -#define ARG_LEN 50 - diff --git a/include/oasys.h b/include/oasys.h deleted file mode 100644 index 214095f4b53..00000000000 --- a/include/oasys.h +++ /dev/null @@ -1,144 +0,0 @@ -#define OASYS_MAX_SEC_COUNT 16 -/* **** */ - - -typedef struct { - uint32_type version; - char create_date[12]; - char revision_date[12]; - uint32_type mod_count; - uint32_type mod_tbl_offset; - uint32_type sym_tbl_size; - uint32_type sym_count; - uint32_type sym_tbl_offset; - uint32_type xref_count; - uint32_type xref_lst_offset; -} oasys_archive_header_type; - -typedef struct { - char version[4]; - char create_date[12]; - char revision_date[12]; - char mod_count[4]; - char mod_tbl_offset[4]; - char sym_tbl_size[4]; - char sym_count[4]; - char sym_tbl_offset[4]; - char xref_count[4]; - char xref_lst_offset[4]; -} oasys_external_archive_header_type; - -typedef struct { - int32_type mod_number; - char mod_date[12]; - int32_type mod_size; - int32_type dep_count; - int32_type depee_count; - int32_type file_offset; - int32_type sect_count; - char *module_name; - -} oasys_module_table_type; - - -typedef struct { - char mod_number[4]; - char mod_date[12]; - char mod_size[4]; - char dep_count[4]; - char depee_count[4]; - char sect_count[4]; - char file_offset[4]; - char mod_name[32]; -} oasys_external_module_table_type; - - - -typedef enum { - oasys_record_is_end_enum = 0, - oasys_record_is_data_enum = 1, - oasys_record_is_symbol_enum = 2, - oasys_record_is_header_enum = 3, - oasys_record_is_named_section_enum = 4, - oasys_record_is_com_enum = 5, - oasys_record_is_debug_enum = 6, - oasys_record_is_section_enum = 7, - oasys_record_is_debug_file_enum = 8, - oasys_record_is_module_enum = 9, - oasys_record_is_local_enum = 10 -} oasys_record_enum_type; - - - -typedef struct { - uint8_type length; - int8_type check_sum; - int8_type type; - int8_type fill; -} oasys_record_header_type; - -typedef struct { - oasys_record_header_type header; - uint8e_type relb; - uint8e_type addr[4]; - uint8e_type data[256]; -} oasys_data_record_type; - -typedef struct { - oasys_record_header_type header; - int8_type version_number; - int8_type rev_number; - char module_name[26-6]; - char description[64-26]; -} oasys_header_record_type; - -#define OASYS_VERSION_NUMBER 0 -#define OASYS_REV_NUMBER 0 -typedef struct { - oasys_record_header_type header; - int8e_type relb; - int8e_type value[4]; - int8e_type refno[2]; - char name[64]; -} oasys_symbol_record_type; - -typedef int8e_type relocation_byte; - -#define RELOCATION_PCREL_BIT 0x80 -#define RELOCATION_32BIT_BIT 0x40 -#define RELOCATION_TYPE_BITS 0x30 -#define RELOCATION_TYPE_ABS 0x00 -#define RELOCATION_TYPE_REL 0x10 -#define RELOCATION_TYPE_UND 0x20 -#define RELOCATION_TYPE_COM 0x30 -#define RELOCATION_SECT_BITS 0x0f - -typedef struct -{ - oasys_record_header_type header; - uint8e_type relb; - int8_type value[4]; - int8_type vma[4]; - int8_type fill[3]; -} oasys_section_record_type; - -typedef struct { - oasys_record_header_type header; - uint8e_type relb; - int8e_type entry[4]; - int8e_type fill[2]; - int8e_type zero; -} oasys_end_record_type; - - - -typedef union -{ - oasys_record_header_type header; - oasys_data_record_type data; - oasys_section_record_type section; - oasys_symbol_record_type symbol; - oasys_header_record_type first; - oasys_end_record_type end; - uint8e_type pad[256]; -} oasys_record_union_type; diff --git a/include/obstack.h b/include/obstack.h deleted file mode 100644 index 2e80c9c70fa..00000000000 --- a/include/obstack.h +++ /dev/null @@ -1,416 +0,0 @@ -/* obstack.h - object stack macros - Copyright (C) 1988 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 1, 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, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Summary: - -All the apparent functions defined here are macros. The idea -is that you would use these pre-tested macros to solve a -very specific set of problems, and they would run fast. -Caution: no side-effects in arguments please!! They may be -evaluated MANY times!! - -These macros operate a stack of objects. Each object starts life -small, and may grow to maturity. (Consider building a word syllable -by syllable.) An object can move while it is growing. Once it has -been "finished" it never changes address again. So the "top of the -stack" is typically an immature growing object, while the rest of the -stack is of mature, fixed size and fixed address objects. - -These routines grab large chunks of memory, using a function you -supply, called `obstack_chunk_alloc'. On occasion, they free chunks, -by calling `obstack_chunk_free'. You must define them and declare -them before using any obstack macros. - -Each independent stack is represented by a `struct obstack'. -Each of the obstack macros expects a pointer to such a structure -as the first argument. - -One motivation for this package is the problem of growing char strings -in symbol tables. Unless you are "fascist pig with a read-only mind" -[Gosper's immortal quote from HAKMEM item 154, out of context] you -would not like to put any arbitrary upper limit on the length of your -symbols. - -In practice this often means you will build many short symbols and a -few long symbols. At the time you are reading a symbol you don't know -how long it is. One traditional method is to read a symbol into a -buffer, realloc()ating the buffer every time you try to read a symbol -that is longer than the buffer. This is beaut, but you still will -want to copy the symbol from the buffer to a more permanent -symbol-table entry say about half the time. - -With obstacks, you can work differently. Use one obstack for all symbol -names. As you read a symbol, grow the name in the obstack gradually. -When the name is complete, finalize it. Then, if the symbol exists already, -free the newly read name. - -The way we do this is to take a large chunk, allocating memory from -low addresses. When you want to build a symbol in the chunk you just -add chars above the current "high water mark" in the chunk. When you -have finished adding chars, because you got to the end of the symbol, -you know how long the chars are, and you can create a new object. -Mostly the chars will not burst over the highest address of the chunk, -because you would typically expect a chunk to be (say) 100 times as -long as an average object. - -In case that isn't clear, when we have enough chars to make up -the object, THEY ARE ALREADY CONTIGUOUS IN THE CHUNK (guaranteed) -so we just point to it where it lies. No moving of chars is -needed and this is the second win: potentially long strings need -never be explicitly shuffled. Once an object is formed, it does not -change its address during its lifetime. - -When the chars burst over a chunk boundary, we allocate a larger -chunk, and then copy the partly formed object from the end of the old -chunk to the beginning of the new larger chunk. We then carry on -accreting characters to the end of the object as we normally would. - -A special macro is provided to add a single char at a time to a -growing object. This allows the use of register variables, which -break the ordinary 'growth' macro. - -Summary: - We allocate large chunks. - We carve out one object at a time from the current chunk. - Once carved, an object never moves. - We are free to append data of any size to the currently - growing object. - Exactly one object is growing in an obstack at any one time. - You can run one obstack per control block. - You may have as many control blocks as you dare. - Because of the way we do it, you can `unwind' a obstack - back to a previous state. (You may remove objects much - as you would with a stack.) -*/ - - -/* Don't do the contents of this file more than once. */ - -#ifndef __OBSTACKS__ -#define __OBSTACKS__ - -/* We use subtraction of (char *)0 instead of casting to int - because on word-addressable machines a simple cast to int - may ignore the byte-within-word field of the pointer. */ - -#ifndef __PTR_TO_INT -#define __PTR_TO_INT(P) ((P) - (char *)0) -#endif - -#ifndef __INT_TO_PTR -#define __INT_TO_PTR(P) ((P) + (char *)0) -#endif - -struct _obstack_chunk /* Lives at front of each chunk. */ -{ - char *limit; /* 1 past end of this chunk */ - struct _obstack_chunk *prev; /* address of prior chunk or NULL */ - char contents[4]; /* objects begin here */ -}; - -struct obstack /* control current object in current chunk */ -{ - long chunk_size; /* preferred size to allocate chunks in */ - struct _obstack_chunk* chunk; /* address of current struct obstack_chunk */ - char *object_base; /* address of object we are building */ - char *next_free; /* where to add next char to current object */ - char *chunk_limit; /* address of char after current chunk */ - int temp; /* Temporary for some macros. */ - int alignment_mask; /* Mask of alignment for each object. */ -#ifdef __STDC__ - void *(*chunkfun) (); /* User's fcn to allocate a chunk. */ -#else - char *(*chunkfun) (); /* User's fcn to allocate a chunk. */ -#endif - void (*freefun) (); /* User's function to free a chunk. */ -}; - -#ifdef __STDC__ - -/* Do the function-declarations after the structs - but before defining the macros. */ - -void obstack_init (struct obstack *obstack); - -void * obstack_alloc (struct obstack *obstack, int size); - -void * obstack_copy (struct obstack *obstack, void *address, int size); -void * obstack_copy0 (struct obstack *obstack, void *address, int size); - -void obstack_free (struct obstack *obstack, void *block); - -void obstack_blank (struct obstack *obstack, int size); - -void obstack_grow (struct obstack *obstack, void *data, int size); -void obstack_grow0 (struct obstack *obstack, void *data, int size); - -void obstack_1grow (struct obstack *obstack, int data_char); -void obstack_ptr_grow (struct obstack *obstack, void *data); -void obstack_int_grow (struct obstack *obstack, int data); - -void * obstack_finish (struct obstack *obstack); - -int obstack_object_size (struct obstack *obstack); - -int obstack_room (struct obstack *obstack); -void obstack_1grow_fast (struct obstack *obstack, int data_char); -void obstack_ptr_grow_fast (struct obstack *obstack, void *data); -void obstack_int_grow_fast (struct obstack *obstack, int data); -void obstack_blank_fast (struct obstack *obstack, int size); - -void * obstack_base (struct obstack *obstack); -void * obstack_next_free (struct obstack *obstack); -int obstack_alignment_mask (struct obstack *obstack); -int obstack_chunk_size (struct obstack *obstack); - -#endif /* __STDC__ */ - -/* Non-ANSI C cannot really support alternative functions for these macros, - so we do not declare them. */ - -/* Pointer to beginning of object being allocated or to be allocated next. - Note that this might not be the final address of the object - because a new chunk might be needed to hold the final size. */ - -#define obstack_base(h) ((h)->object_base) - -/* Size for allocating ordinary chunks. */ - -#define obstack_chunk_size(h) ((h)->chunk_size) - -/* Pointer to next byte not yet allocated in current chunk. */ - -#define obstack_next_free(h) ((h)->next_free) - -/* Mask specifying low bits that should be clear in address of an object. */ - -#define obstack_alignment_mask(h) ((h)->alignment_mask) - -#define obstack_init(h) \ - _obstack_begin ((h), 0, 0, obstack_chunk_alloc, obstack_chunk_free) - -#define obstack_begin(h, size) \ - _obstack_begin ((h), (size), 0, obstack_chunk_alloc, obstack_chunk_free) - -#define obstack_1grow_fast(h,achar) (*((h)->next_free)++ = achar) - -#define obstack_blank_fast(h,n) ((h)->next_free += (n)) - -#if defined (__GNUC__) && defined (__STDC__) - -/* For GNU C, if not -traditional, - we can define these macros to compute all args only once - without using a global variable. - Also, we can avoid using the `temp' slot, to make faster code. */ - -#define obstack_object_size(OBSTACK) \ - ({ struct obstack *__o = (OBSTACK); \ - (unsigned) (__o->next_free - __o->object_base); }) - -#define obstack_room(OBSTACK) \ - ({ struct obstack *__o = (OBSTACK); \ - (unsigned) (__o->chunk_limit - __o->next_free); }) - -#define obstack_grow(OBSTACK,where,length) \ -({ struct obstack *__o = (OBSTACK); \ - int __len = (length); \ - ((__o->next_free + __len > __o->chunk_limit) \ - ? _obstack_newchunk (__o, __len) : 0); \ - bcopy (where, __o->next_free, __len); \ - __o->next_free += __len; \ - (void) 0; }) - -#define obstack_grow0(OBSTACK,where,length) \ -({ struct obstack *__o = (OBSTACK); \ - int __len = (length); \ - ((__o->next_free + __len + 1 > __o->chunk_limit) \ - ? _obstack_newchunk (__o, __len + 1) : 0), \ - bcopy (where, __o->next_free, __len), \ - __o->next_free += __len, \ - *(__o->next_free)++ = 0; \ - (void) 0; }) - -#define obstack_1grow(OBSTACK,datum) \ -({ struct obstack *__o = (OBSTACK); \ - ((__o->next_free + 1 > __o->chunk_limit) \ - ? _obstack_newchunk (__o, 1) : 0), \ - *(__o->next_free)++ = (datum); \ - (void) 0; }) - -/* These assume that the obstack alignment is good enough for pointers or ints, - and that the data added so far to the current object - shares that much alignment. */ - -#define obstack_ptr_grow(OBSTACK,datum) \ -({ struct obstack *__o = (OBSTACK); \ - ((__o->next_free + sizeof (void *) > __o->chunk_limit) \ - ? _obstack_newchunk (__o, sizeof (void *)) : 0), \ - *(*(void ***)&__o->next_free)++ = ((void *)datum); \ - (void) 0; }) - -#define obstack_int_grow(OBSTACK,datum) \ -({ struct obstack *__o = (OBSTACK); \ - ((__o->next_free + sizeof (int) > __o->chunk_limit) \ - ? _obstack_newchunk (__o, sizeof (int)) : 0), \ - *(*(int **)&__o->next_free)++ = ((int)datum); \ - (void) 0; }) - -#define obstack_ptr_grow_fast(h,aptr) (*(*(void ***)&(h)->next_free)++ = (void *)aptr) -#define obstack_int_grow_fast(h,aint) (*(*(int **)&(h)->next_free)++ = (int)aint) - -#define obstack_blank(OBSTACK,length) \ -({ struct obstack *__o = (OBSTACK); \ - int __len = (length); \ - ((__o->chunk_limit - __o->next_free < __len) \ - ? _obstack_newchunk (__o, __len) : 0); \ - __o->next_free += __len; \ - (void) 0; }) - -#define obstack_alloc(OBSTACK,length) \ -({ struct obstack *__h = (OBSTACK); \ - obstack_blank (__h, (length)); \ - obstack_finish (__h); }) - -#define obstack_copy(OBSTACK,where,length) \ -({ struct obstack *__h = (OBSTACK); \ - obstack_grow (__h, (where), (length)); \ - obstack_finish (__h); }) - -#define obstack_copy0(OBSTACK,where,length) \ -({ struct obstack *__h = (OBSTACK); \ - obstack_grow0 (__h, (where), (length)); \ - obstack_finish (__h); }) - -#define obstack_finish(OBSTACK) \ -({ struct obstack *__o = (OBSTACK); \ - void *value = (void *) __o->object_base; \ - __o->next_free \ - = __INT_TO_PTR ((__PTR_TO_INT (__o->next_free)+__o->alignment_mask)\ - & ~ (__o->alignment_mask)); \ - ((__o->next_free - (char *)__o->chunk \ - > __o->chunk_limit - (char *)__o->chunk) \ - ? (__o->next_free = __o->chunk_limit) : 0); \ - __o->object_base = __o->next_free; \ - value; }) - -#define obstack_free(OBSTACK, OBJ) \ -({ struct obstack *__o = (OBSTACK); \ - void *__obj = (OBJ); \ - if (__obj > (void *)__o->chunk && __obj < (void *)__o->chunk_limit) \ - __o->next_free = __o->object_base = __obj; \ - else (obstack_free) (__o, __obj); }) - -#else /* not __GNUC__ or not __STDC__ */ - -#define obstack_object_size(h) \ - (unsigned) ((h)->next_free - (h)->object_base) - -#define obstack_room(h) \ - (unsigned) ((h)->chunk_limit - (h)->next_free) - -#define obstack_grow(h,where,length) \ -( (h)->temp = (length), \ - (((h)->next_free + (h)->temp > (h)->chunk_limit) \ - ? _obstack_newchunk ((h), (h)->temp) : 0), \ - bcopy (where, (h)->next_free, (h)->temp), \ - (h)->next_free += (h)->temp) - -#define obstack_grow0(h,where,length) \ -( (h)->temp = (length), \ - (((h)->next_free + (h)->temp + 1 > (h)->chunk_limit) \ - ? _obstack_newchunk ((h), (h)->temp + 1) : 0), \ - bcopy (where, (h)->next_free, (h)->temp), \ - (h)->next_free += (h)->temp, \ - *((h)->next_free)++ = 0) - -#define obstack_1grow(h,datum) \ -( (((h)->next_free + 1 > (h)->chunk_limit) \ - ? _obstack_newchunk ((h), 1) : 0), \ - *((h)->next_free)++ = (datum)) - -#define obstack_ptr_grow(h,datum) \ -( (((h)->next_free + sizeof (char *) > (h)->chunk_limit) \ - ? _obstack_newchunk ((h), sizeof (char *)) : 0), \ - *(*(char ***)&(h)->next_free)++ = ((char *)datum)) - -#define obstack_int_grow(h,datum) \ -( (((h)->next_free + sizeof (int) > (h)->chunk_limit) \ - ? _obstack_newchunk ((h), sizeof (int)) : 0), \ - *(*(int **)&(h)->next_free)++ = ((int)datum)) - -#define obstack_ptr_grow_fast(h,aptr) (*(*(char ***)&(h)->next_free)++ = (char *)aptr) -#define obstack_int_grow_fast(h,aint) (*(*(int **)&(h)->next_free)++ = (int)aint) - -#define obstack_blank(h,length) \ -( (h)->temp = (length), \ - (((h)->chunk_limit - (h)->next_free < (h)->temp) \ - ? _obstack_newchunk ((h), (h)->temp) : 0), \ - (h)->next_free += (h)->temp) - -#define obstack_alloc(h,length) \ - (obstack_blank ((h), (length)), obstack_finish ((h))) - -#define obstack_copy(h,where,length) \ - (obstack_grow ((h), (where), (length)), obstack_finish ((h))) - -#define obstack_copy0(h,where,length) \ - (obstack_grow0 ((h), (where), (length)), obstack_finish ((h))) - -#define obstack_finish(h) \ -( (h)->temp = __PTR_TO_INT ((h)->object_base), \ - (h)->next_free \ - = __INT_TO_PTR ((__PTR_TO_INT ((h)->next_free)+(h)->alignment_mask) \ - & ~ ((h)->alignment_mask)), \ - (((h)->next_free - (char *)(h)->chunk \ - > (h)->chunk_limit - (char *)(h)->chunk) \ - ? ((h)->next_free = (h)->chunk_limit) : 0), \ - (h)->object_base = (h)->next_free, \ - __INT_TO_PTR ((h)->temp)) - -#ifdef __STDC__ -#define obstack_free(h,obj) \ -( (h)->temp = (char *)(obj) - (char *) (h)->chunk, \ - (((h)->temp >= 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\ - ? (int) ((h)->next_free = (h)->object_base \ - = (h)->temp + (char *) (h)->chunk) \ - : ((obstack_free) ((h), (h)->temp + (char *) (h)->chunk), 0))) -#else -#define obstack_free(h,obj) \ -( (h)->temp = (char *)(obj) - (char *) (h)->chunk, \ - (((h)->temp >= 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\ - ? (int) ((h)->next_free = (h)->object_base \ - = (h)->temp + (char *) (h)->chunk) \ - : (int) _obstack_free ((h), (h)->temp + (char *) (h)->chunk))) -#endif - -#endif /* not __GNUC__ or not __STDC__ */ - -/* Declare the external functions we use; they are in obstack.c. */ - -#ifdef __STDC__ - extern int _obstack_newchunk (struct obstack *h, int length); - extern int _obstack_free (struct obstack *h, void *obj); - extern void _obstack_begin (struct obstack *h, int size, int alignment, - void *(*chunkfun) (), void (*freefun) ()); -#else - extern int _obstack_newchunk (); - extern int _obstack_free (); - extern void _obstack_begin (); -#endif - -#endif /* not __OBSTACKS__ */ - diff --git a/include/pn-opcode.h b/include/pn-opcode.h deleted file mode 100755 index fde4764c02c..00000000000 --- a/include/pn-opcode.h +++ /dev/null @@ -1,282 +0,0 @@ -/* Print GOULD PN (PowerNode) instructions for GDB, the GNU debugger. - Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc. - -This file is part of GDB. - -GDB 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 1, or (at your option) -any later version. - -GDB 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 GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -struct gld_opcode -{ - char *name; - unsigned long opcode; - unsigned long mask; - char *args; - int length; -}; - -/* We store four bytes of opcode for all opcodes because that - is the most any of them need. The actual length of an instruction - is always at least 2 bytes, and at most four. The length of the - instruction is based on the opcode. - - The mask component is a mask saying which bits must match - particular opcode in order for an instruction to be an instance - of that opcode. - - The args component is a string containing characters - that are used to format the arguments to the instruction. */ - -/* Kinds of operands: - r Register in first field - R Register in second field - b Base register in first field - B Base register in second field - v Vector register in first field - V Vector register in first field - A Optional address register (base register) - X Optional index register - I Immediate data (16bits signed) - O Offset field (16bits signed) - h Offset field (15bits signed) - d Offset field (14bits signed) - S Shift count field - - any other characters are printed as is... -*/ - -/* The assembler requires that this array be sorted as follows: - all instances of the same mnemonic must be consecutive. - All instances of the same mnemonic with the same number of operands - must be consecutive. - */ -struct gld_opcode gld_opcodes[] = -{ -{ "abm", 0xa0080000, 0xfc080000, "f,xOA,X", 4 }, -{ "abr", 0x18080000, 0xfc0c0000, "r,f", 2 }, -{ "aci", 0xfc770000, 0xfc7f8000, "r,I", 4 }, -{ "adfd", 0xe0080002, 0xfc080002, "r,xOA,X", 4 }, -{ "adfw", 0xe0080000, 0xfc080000, "r,xOA,X", 4 }, -{ "adi", 0xc8010000, 0xfc7f0000, "r,I", 4 }, -{ "admb", 0xb8080000, 0xfc080000, "r,xOA,X", 4 }, -{ "admd", 0xb8000002, 0xfc080002, "r,xOA,X", 4 }, -{ "admh", 0xb8000001, 0xfc080001, "r,xOA,X", 4 }, -{ "admw", 0xb8000000, 0xfc080000, "r,xOA,X", 4 }, -{ "adr", 0x38000000, 0xfc0f0000, "r,R", 2 }, -{ "adrfd", 0x38090000, 0xfc0f0000, "r,R", 2 }, -{ "adrfw", 0x38010000, 0xfc0f0000, "r,R", 2 }, -{ "adrm", 0x38080000, 0xfc0f0000, "r,R", 2 }, -{ "ai", 0xfc030000, 0xfc07ffff, "I", 4 }, -{ "anmb", 0x84080000, 0xfc080000, "r,xOA,X", 4 }, -{ "anmd", 0x84000002, 0xfc080002, "r,xOA,X", 4 }, -{ "anmh", 0x84000001, 0xfc080001, "r,xOA,X", 4 }, -{ "anmw", 0x84000000, 0xfc080000, "r,xOA,X", 4 }, -{ "anr", 0x04000000, 0xfc0f0000, "r,R", 2 }, -{ "armb", 0xe8080000, 0xfc080000, "r,xOA,X", 4 }, -{ "armd", 0xe8000002, 0xfc080002, "r,xOA,X", 4 }, -{ "armh", 0xe8000001, 0xfc080001, "r,xOA,X", 4 }, -{ "armw", 0xe8000000, 0xfc080000, "r,xOA,X", 4 }, -{ "bcf", 0xf0000000, 0xfc080000, "I,xOA,X", 4 }, -{ "bct", 0xec000000, 0xfc080000, "I,xOA,X", 4 }, -{ "bei", 0x00060000, 0xffff0000, "", 2 }, -{ "bft", 0xf0000000, 0xff880000, "xOA,X", 4 }, -{ "bib", 0xf4000000, 0xfc780000, "r,xOA", 4 }, -{ "bid", 0xf4600000, 0xfc780000, "r,xOA", 4 }, -{ "bih", 0xf4200000, 0xfc780000, "r,xOA", 4 }, -{ "biw", 0xf4400000, 0xfc780000, "r,xOA", 4 }, -{ "bl", 0xf8800000, 0xff880000, "xOA,X", 4 }, -{ "bsub", 0x5c080000, 0xff8f0000, "", 2 }, -{ "bsubm", 0x28080000, 0xfc080000, "", 4 }, -{ "bu", 0xec000000, 0xff880000, "xOA,X", 4 }, -{ "call", 0x28080000, 0xfc0f0000, "", 2 }, -{ "callm", 0x5c080000, 0xff880000, "", 4 }, -{ "camb", 0x90080000, 0xfc080000, "r,xOA,X", 4 }, -{ "camd", 0x90000002, 0xfc080002, "r,xOA,X", 4 }, -{ "camh", 0x90000001, 0xfc080001, "r,xOA,X", 4 }, -{ "camw", 0x90000000, 0xfc080000, "r.xOA,X", 4 }, -{ "car", 0x10000000, 0xfc0f0000, "r,R", 2 }, -{ "cd", 0xfc060000, 0xfc070000, "r,f", 4 }, -{ "cea", 0x000f0000, 0xffff0000, "", 2 }, -{ "ci", 0xc8050000, 0xfc7f0000, "r,I", 4 }, -{ "cmc", 0x040a0000, 0xfc7f0000, "r", 2 }, -{ "cmmb", 0x94080000, 0xfc080000, "r,xOA,X", 4 }, -{ "cmmd", 0x94000002, 0xfc080002, "r,xOA,X", 4 }, -{ "cmmh", 0x94000001, 0xfc080001, "r,xOA,X", 4 }, -{ "cmmw", 0x94000000, 0xfc080000, "r,xOA,X", 4 }, -{ "cmr", 0x14000000, 0xfc0f0000, "r,R", 2 }, -{ "daci", 0xfc7f0000, 0xfc7f8000, "r,I", 4 }, -{ "dae", 0x000e0000, 0xffff0000, "", 2 }, -{ "dai", 0xfc040000, 0xfc07ffff, "I", 4 }, -{ "dci", 0xfc6f0000, 0xfc7f8000, "r,I", 4 }, -{ "di", 0xfc010000, 0xfc07ffff, "I", 4 }, -{ "dvfd", 0xe4000002, 0xfc080002, "r,xOA,X", 4 }, -{ "dvfw", 0xe4000000, 0xfc080000, "r,xOA,X", 4 }, -{ "dvi", 0xc8040000, 0xfc7f0000, "r,I", 4 }, -{ "dvmb", 0xc4080000, 0xfc080000, "r,xOA,X", 4 }, -{ "dvmh", 0xc4000001, 0xfc080001, "r,xOA,X", 4 }, -{ "dvmw", 0xc4000000, 0xfc080000, "r,xOA,X", 4 }, -{ "dvr", 0x380a0000, 0xfc0f0000, "r,R", 2 }, -{ "dvrfd", 0x380c0000, 0xfc0f0000, "r,R", 4 }, -{ "dvrfw", 0x38040000, 0xfc0f0000, "r,xOA,X", 4 }, -{ "eae", 0x00080000, 0xffff0000, "", 2 }, -{ "eci", 0xfc670000, 0xfc7f8080, "r,I", 4 }, -{ "ecwcs", 0xfc4f0000, 0xfc7f8000, "", 4 }, -{ "ei", 0xfc000000, 0xfc07ffff, "I", 4 }, -{ "eomb", 0x8c080000, 0xfc080000, "r,xOA,X", 4 }, -{ "eomd", 0x8c000002, 0xfc080002, "r,xOA,X", 4 }, -{ "eomh", 0x8c000001, 0xfc080001, "r,xOA,X", 4 }, -{ "eomw", 0x8c000000, 0xfc080000, "r,xOA,X", 4 }, -{ "eor", 0x0c000000, 0xfc0f0000, "r,R", 2 }, -{ "eorm", 0x0c080000, 0xfc0f0000, "r,R", 2 }, -{ "es", 0x00040000, 0xfc7f0000, "r", 2 }, -{ "exm", 0xa8000000, 0xff880000, "xOA,X", 4 }, -{ "exr", 0xc8070000, 0xfc7f0000, "r", 2 }, -{ "exrr", 0xc8070002, 0xfc7f0002, "r", 2 }, -{ "fixd", 0x380d0000, 0xfc0f0000, "r,R", 2 }, -{ "fixw", 0x38050000, 0xfc0f0000, "r,R", 2 }, -{ "fltd", 0x380f0000, 0xfc0f0000, "r,R", 2 }, -{ "fltw", 0x38070000, 0xfc0f0000, "r,R", 2 }, -{ "grio", 0xfc3f0000, 0xfc7f8000, "r,I", 4 }, -{ "halt", 0x00000000, 0xffff0000, "", 2 }, -{ "hio", 0xfc370000, 0xfc7f8000, "r,I", 4 }, -{ "jwcs", 0xfa080000, 0xff880000, "xOA,X", 4 }, -{ "la", 0x50000000, 0xfc000000, "r,xOA,X", 4 }, -{ "labr", 0x58080000, 0xfc080000, "b,xOA,X", 4 }, -{ "lb", 0xac080000, 0xfc080000, "r,xOA,X", 4 }, -{ "lcs", 0x00030000, 0xfc7f0000, "r", 2 }, -{ "ld", 0xac000002, 0xfc080002, "r,xOA,X", 4 }, -{ "lear", 0x80000000, 0xfc080000, "r,xOA,X", 4 }, -{ "lf", 0xcc000000, 0xfc080000, "r,xOA,X", 4 }, -{ "lfbr", 0xcc080000, 0xfc080000, "b,xOA,X", 4 }, -{ "lh", 0xac000001, 0xfc080001, "r,xOA,X", 4 }, -{ "li", 0xc8000000, 0xfc7f0000, "r,I", 4 }, -{ "lmap", 0x2c070000, 0xfc7f0000, "r", 2 }, -{ "lmb", 0xb0080000, 0xfc080000, "r,xOA,X", 4 }, -{ "lmd", 0xb0000002, 0xfc080002, "r,xOA,X", 4 }, -{ "lmh", 0xb0000001, 0xfc080001, "r,xOA,X", 4 }, -{ "lmw", 0xb0000000, 0xfc080000, "r,xOA,X", 4 }, -{ "lnb", 0xb4080000, 0xfc080000, "r,xOA,X", 4 }, -{ "lnd", 0xb4000002, 0xfc080002, "r,xOA,X", 4 }, -{ "lnh", 0xb4000001, 0xfc080001, "r,xOA,X", 4 }, -{ "lnw", 0xb4000000, 0xfc080000, "r,xOA,X", 4 }, -{ "lpsd", 0xf9800000, 0xff880000, "r,xOA,X", 4 }, -{ "lpsdcm", 0xfa800000, 0xff880000, "r,xOA,X", 4 }, -{ "lw", 0xac000000, 0xfc080000, "r,xOA,X", 4 }, -{ "lwbr", 0x5c000000, 0xfc080000, "b,xOA,X", 4 }, -{ "mpfd", 0xe4080002, 0xfc080002, "r,xOA,X", 4 }, -{ "mpfw", 0xe4080000, 0xfc080000, "r,xOA,X", 4 }, -{ "mpi", 0xc8030000, 0xfc7f0000, "r,I", 4 }, -{ "mpmb", 0xc0080000, 0xfc080000, "r,xOA,X", 4 }, -{ "mpmh", 0xc0000001, 0xfc080001, "r,xOA,X", 4 }, -{ "mpmw", 0xc0000000, 0xfc080000, "r,xOA,X", 4 }, -{ "mpr", 0x38020000, 0xfc0f0000, "r,R", 2 }, -{ "mprfd", 0x380e0000, 0xfc0f0000, "r,R", 2 }, -{ "mprfw", 0x38060000, 0xfc0f0000, "r,R", 2 }, -{ "nop", 0x00020000, 0xffff0000, "", 2 }, -{ "ormb", 0x88080000, 0xfc080000, "r,xOA,X", 4 }, -{ "ormd", 0x88000002, 0xfc080002, "r,xOA,X", 4 }, -{ "ormh", 0x88000001, 0xfc080001, "r,xOA,X", 4 }, -{ "ormw", 0x88000000, 0xfc080000, "r,xOA,X", 4 }, -{ "orr", 0x08000000, 0xfc0f0000, "r,R", 2 }, -{ "orrm", 0x08080000, 0xfc0f0000, "r,R", 2 }, -{ "rdsts", 0x00090000, 0xfc7f0000, "r", 2 }, -{ "return", 0x280e0000, 0xfc7f0000, "", 2 }, -{ "ri", 0xfc020000, 0xfc07ffff, "I", 4 }, -{ "rnd", 0x00050000, 0xfc7f0000, "r", 2 }, -{ "rpswt", 0x040b0000, 0xfc7f0000, "r", 2 }, -{ "rschnl", 0xfc2f0000, 0xfc7f8000, "r,I", 4 }, -{ "rsctl", 0xfc470000, 0xfc7f8000, "r,I", 4 }, -{ "rwcs", 0x000b0000, 0xfc0f0000, "r,R", 2 }, -{ "sacz", 0x10080000, 0xfc0f0000, "r,R", 2 }, -{ "sbm", 0x98080000, 0xfc080000, "f,xOA,X", 4 }, -{ "sbr", 0x18000000, 0xfc0c0000, "r,f", 4 }, -{ "sea", 0x000d0000, 0xffff0000, "", 2 }, -{ "setcpu", 0x2c090000, 0xfc7f0000, "r", 2 }, -{ "sio", 0xfc170000, 0xfc7f8000, "r,I", 4 }, -{ "sipu", 0x000a0000, 0xffff0000, "", 2 }, -{ "sla", 0x1c400000, 0xfc600000, "r,S", 2 }, -{ "slad", 0x20400000, 0xfc600000, "r,S", 2 }, -{ "slc", 0x24400000, 0xfc600000, "r,S", 2 }, -{ "sll", 0x1c600000, 0xfc600000, "r,S", 2 }, -{ "slld", 0x20600000, 0xfc600000, "r,S", 2 }, -{ "smc", 0x04070000, 0xfc070000, "", 2 }, -{ "sra", 0x1c000000, 0xfc600000, "r,S", 2 }, -{ "srad", 0x20000000, 0xfc600000, "r,S", 2 }, -{ "src", 0x24000000, 0xfc600000, "r,S", 2 }, -{ "srl", 0x1c200000, 0xfc600000, "r,S", 2 }, -{ "srld", 0x20200000, 0xfc600000, "r,S", 2 }, -{ "stb", 0xd4080000, 0xfc080000, "r,xOA,X", 4 }, -{ "std", 0xd4000002, 0xfc080002, "r,xOA,X", 4 }, -{ "stf", 0xdc000000, 0xfc080000, "r,xOA,X", 4 }, -{ "stfbr", 0x54000000, 0xfc080000, "b,xOA,X", 4 }, -{ "sth", 0xd4000001, 0xfc080001, "r,xOA,X", 4 }, -{ "stmb", 0xd8080000, 0xfc080000, "r,xOA,X", 4 }, -{ "stmd", 0xd8000002, 0xfc080002, "r,xOA,X", 4 }, -{ "stmh", 0xd8000001, 0xfc080001, "r,xOA,X", 4 }, -{ "stmw", 0xd8000000, 0xfc080000, "r,xOA,X", 4 }, -{ "stpio", 0xfc270000, 0xfc7f8000, "r,I", 4 }, -{ "stw", 0xd4000000, 0xfc080000, "r,xOA,X", 4 }, -{ "stwbr", 0x54000000, 0xfc080000, "b,xOA,X", 4 }, -{ "suabr", 0x58000000, 0xfc080000, "b,xOA,X", 4 }, -{ "sufd", 0xe0000002, 0xfc080002, "r,xOA,X", 4 }, -{ "sufw", 0xe0000000, 0xfc080000, "r,xOA,X", 4 }, -{ "sui", 0xc8020000, 0xfc7f0000, "r,I", 4 }, -{ "sumb", 0xbc080000, 0xfc080000, "r,xOA,X", 4 }, -{ "sumd", 0xbc000002, 0xfc080002, "r,xOA,X", 4 }, -{ "sumh", 0xbc000001, 0xfc080001, "r,xOA,X", 4 }, -{ "sumw", 0xbc000000, 0xfc080000, "r,xOA,X", 4 }, -{ "sur", 0x3c000000, 0xfc0f0000, "r,R", 2 }, -{ "surfd", 0x380b0000, 0xfc0f0000, "r,xOA,X", 4 }, -{ "surfw", 0x38030000, 0xfc0f0000, "r,R", 2 }, -{ "surm", 0x3c080000, 0xfc0f0000, "r,R", 2 }, -{ "svc", 0xc8060000, 0xffff0000, "", 4 }, -{ "tbm", 0xa4080000, 0xfc080000, "f,xOA,X", 4 }, -{ "tbr", 0x180c0000, 0xfc0c0000, "r,f", 2 }, -{ "tbrr", 0x2c020000, 0xfc0f0000, "r,B", 2 }, -{ "tccr", 0x28040000, 0xfc7f0000, "", 2 }, -{ "td", 0xfc050000, 0xfc070000, "r,f", 4 }, -{ "tio", 0xfc1f0000, 0xfc7f8000, "r,I", 4 }, -{ "tmapr", 0x2c0a0000, 0xfc0f0000, "r,R", 2 }, -{ "tpcbr", 0x280c0000, 0xfc7f0000, "r", 2 }, -{ "trbr", 0x2c010000, 0xfc0f0000, "b,R", 2 }, -{ "trc", 0x2c030000, 0xfc0f0000, "r,R", 2 }, -{ "trcc", 0x28050000, 0xfc7f0000, "", 2 }, -{ "trcm", 0x2c0b0000, 0xfc0f0000, "r,R", 2 }, -{ "trn", 0x2c040000, 0xfc0f0000, "r,R", 2 }, -{ "trnm", 0x2c0c0000, 0xfc0f0000, "r,R", 2 }, -{ "trr", 0x2c000000, 0xfc0f0000, "r,R", 2 }, -{ "trrm", 0x2c080000, 0xfc0f0000, "r,R", 2 }, -{ "trsc", 0x2c0e0000, 0xfc0f0000, "r,R", 2 }, -{ "trsw", 0x28000000, 0xfc7f0000, "r", 2 }, -{ "tscr", 0x2c0f0000, 0xfc0f0000, "r,R", 2 }, -{ "uei", 0x00070000, 0xffff0000, "", 2 }, -{ "wait", 0x00010000, 0xffff0000, "", 2 }, -{ "wcwcs", 0xfc5f0000, 0xfc7f8000, "", 4 }, -{ "wwcs", 0x000c0000, 0xfc0f0000, "r,R", 2 }, -{ "xcbr", 0x28020000, 0xfc0f0000, "b,B", 2 }, -{ "xcr", 0x2c050000, 0xfc0f0000, "r,R", 2 }, -{ "xcrm", 0x2c0d0000, 0xfc0f0000, "r,R", 2 }, -{ "zbm", 0x9c080000, 0xfc080000, "f,xOA,X", 4 }, -{ "zbr", 0x18040000, 0xfc0c0000, "r,f", 2 }, -{ "zmb", 0xf8080000, 0xfc080000, "r,xOA,X", 4 }, -{ "zmd", 0xf8000002, 0xfc080002, "r,xOA,X", 4 }, -{ "zmh", 0xf8000001, 0xfc080001, "r,xOA,X", 4 }, -{ "zmw", 0xf8000000, 0xfc080000, "r,xOA,X", 4 }, -{ "zr", 0x0c000000, 0xfc0f0000, "r", 2 }, -}; - -int numopcodes = sizeof(gld_opcodes) / sizeof(gld_opcodes[0]); - -struct gld_opcode *endop = gld_opcodes + sizeof(gld_opcodes) / - sizeof(gld_opcodes[0]); diff --git a/include/pyr-opcode.h b/include/pyr-opcode.h deleted file mode 100755 index 06632b8d919..00000000000 --- a/include/pyr-opcode.h +++ /dev/null @@ -1,287 +0,0 @@ -/* pyramid.opcode.h -- gdb initial attempt. */ - -/* pyramid opcode table: wot to do with this - particular opcode */ - -struct pyr_datum -{ - char nargs; - char * args; /* how to compile said opcode */ - unsigned long mask; /* Bit vector: which operand modes are valid - for this opcode */ - unsigned char code; /* op-code (always 6(?) bits */ -}; - -typedef struct pyr_insn_format { - unsigned int mode :4; - unsigned int operator :8; - unsigned int index_scale :2; - unsigned int index_reg :6; - unsigned int operand_1 :6; - unsigned int operand_2:6; -} pyr_insn_format; - - -/* We store four bytes of opcode for all opcodes. - Pyramid is sufficiently RISCy that: - - insns are always an integral number of words; - - the length of any insn can be told from the first word of - the insn. (ie, if there are zero, one, or two words of - immediate operand/offset). - - - The args component is a string containing two characters for each - operand of the instruction. The first specifies the kind of operand; - the second, the place it is stored. */ - -/* Kinds of operands: - mask assembler syntax description - 0x0001: movw Rn,Rn register to register - 0x0002: movw K,Rn quick immediate to register - 0x0004: movw I,Rn long immediate to register - 0x0008: movw (Rn),Rn register indirect to register - movw (Rn)[x],Rn register indirect to register - 0x0010: movw I(Rn),Rn offset register indirect to register - movw I(Rn)[x],Rn offset register indirect, indexed, to register - - 0x0020: movw Rn,(Rn) register to register indirect - 0x0040: movw K,(Rn) quick immediate to register indirect - 0x0080: movw I,(Rn) long immediate to register indirect - 0x0100: movw (Rn),(Rn) register indirect to-register indirect - 0x0100: movw (Rn),(Rn) register indirect to-register indirect - 0x0200: movw I(Rn),(Rn) register indirect+offset to register indirect - 0x0200: movw I(Rn),(Rn) register indirect+offset to register indirect - - 0x0400: movw Rn,I(Rn) register to register indirect+offset - 0x0800: movw K,I(Rn) quick immediate to register indirect+offset - 0x1000: movw I,I(Rn) long immediate to register indirect+offset - 0x1000: movw (Rn),I(Rn) register indirect to-register indirect+offset - 0x1000: movw I(Rn),I(Rn) register indirect+offset to register indirect - +offset - 0x0000: (irregular) ??? - - - Each insn has a four-bit field encoding the type(s) of its operands. -*/ - -/* Some common combinations - */ - -/* the first 5,(0x1|0x2|0x4|0x8|0x10) ie (1|2|4|8|16), ie ( 32 -1)*/ -#define GEN_TO_REG (31) - -#define UNKNOWN ((unsigned long)-1) -#define ANY (GEN_TO_REG | (GEN_TO_REG << 5) | (GEN_TO_REG << 15)) - -#define CONVERT (1|8|0x10|0x20|0x200) - -#define K_TO_REG (2) -#define I_TO_REG (4) -#define NOTK_TO_REG (GEN_TO_REG & ~K_TO_REG) -#define NOTI_TO_REG (GEN_TO_REG & ~I_TO_REG) - -/* The assembler requires that this array be sorted as follows: - all instances of the same mnemonic must be consecutive. - All instances of the same mnemonic with the same number of operands - must be consecutive. - */ - -struct pyr_opcode /* pyr opcode text */ -{ - char * name; /* opcode name: lowercase string [key] */ - struct pyr_datum datum; /* rest of opcode table [datum] */ -}; - -#define pyr_how args -#define pyr_nargs nargs -#define pyr_mask mask -#define pyr_name name - -struct pyr_opcode pyr_opcodes[] = -{ - {"movb", { 2, "", UNKNOWN, 0x11}, }, - {"movh", { 2, "", UNKNOWN, 0x12} }, - {"movw", { 2, "", ANY, 0x10} }, - {"movl", { 2, "", ANY, 0x13} }, - {"mnegw", { 2, "", (0x1|0x8|0x10), 0x14} }, - {"mnegf", { 2, "", 0x1, 0x15} }, - {"mnegd", { 2, "", 0x1, 0x16} }, - {"mcomw", { 2, "", (0x1|0x8|0x10), 0x17} }, - {"mabsw", { 2, "", (0x1|0x8|0x10), 0x18} }, - {"mabsf", { 2, "", 0x1, 0x19} }, - {"mabsd", { 2, "", 0x1, 0x1a} }, - {"mtstw", { 2, "", (0x1|0x8|0x10), 0x1c} }, - {"mtstf", { 2, "", 0x1, 0x1d} }, - {"mtstd", { 2, "", 0x1, 0x1e} }, - {"mova", { 2, "", 0x8|0x10, 0x1f} }, - {"movzbw", { 2, "", (0x1|0x8|0x10), 0x20} }, - {"movzhw", { 2, "", (0x1|0x8|0x10), 0x21} }, - /* 2 insns out of order here */ - {"movbl", { 2, "", 1, 0x4f} }, - {"filbl", { 2, "", 1, 0x4e} }, - - {"cvtbw", { 2, "", CONVERT, 0x22} }, - {"cvthw", { 2, "", CONVERT, 0x23} }, - {"cvtwb", { 2, "", CONVERT, 0x24} }, - {"cvtwh", { 2, "", CONVERT, 0x25} }, - {"cvtwf", { 2, "", CONVERT, 0x26} }, - {"cvtwd", { 2, "", CONVERT, 0x27} }, - {"cvtfw", { 2, "", CONVERT, 0x28} }, - {"cvtfd", { 2, "", CONVERT, 0x29} }, - {"cvtdw", { 2, "", CONVERT, 0x2a} }, - {"cvtdf", { 2, "", CONVERT, 0x2b} }, - - {"addw", { 2, "", GEN_TO_REG, 0x40} }, - {"addwc", { 2, "", GEN_TO_REG, 0x41} }, - {"subw", { 2, "", GEN_TO_REG, 0x42} }, - {"subwb", { 2, "", GEN_TO_REG, 0x43} }, - {"rsubw", { 2, "", GEN_TO_REG, 0x44} }, - {"mulw", { 2, "", GEN_TO_REG, 0x45} }, - {"emul", { 2, "", GEN_TO_REG, 0x47} }, - {"umulw", { 2, "", GEN_TO_REG, 0x46} }, - {"divw", { 2, "", GEN_TO_REG, 0x48} }, - {"ediv", { 2, "", GEN_TO_REG, 0x4a} }, - {"rdivw", { 2, "", GEN_TO_REG, 0x4b} }, - {"udivw", { 2, "", GEN_TO_REG, 0x49} }, - {"modw", { 2, "", GEN_TO_REG, 0x4c} }, - {"umodw", { 2, "", GEN_TO_REG, 0x4d} }, - - - {"addf", { 2, "", 1, 0x50} }, - {"addd", { 2, "", 1, 0x51} }, - {"subf", { 2, "", 1, 0x52} }, - {"subd", { 2, "", 1, 0x53} }, - {"mulf", { 2, "", 1, 0x56} }, - {"muld", { 2, "", 1, 0x57} }, - {"divf", { 2, "", 1, 0x58} }, - {"divd", { 2, "", 1, 0x59} }, - - - {"cmpb", { 2, "", UNKNOWN, 0x61} }, - {"cmph", { 2, "", UNKNOWN, 0x62} }, - {"cmpw", { 2, "", UNKNOWN, 0x60} }, - {"ucmpb", { 2, "", UNKNOWN, 0x66} }, - /* WHY no "ucmph"??? */ - {"ucmpw", { 2, "", UNKNOWN, 0x65} }, - {"xchw", { 2, "", UNKNOWN, 0x0f} }, - - - {"andw", { 2, "", GEN_TO_REG, 0x30} }, - {"orw", { 2, "", GEN_TO_REG, 0x31} }, - {"xorw", { 2, "", GEN_TO_REG, 0x32} }, - {"bicw", { 2, "", GEN_TO_REG, 0x33} }, - {"lshlw", { 2, "", GEN_TO_REG, 0x38} }, - {"ashlw", { 2, "", GEN_TO_REG, 0x3a} }, - {"ashll", { 2, "", GEN_TO_REG, 0x3c} }, - {"ashrw", { 2, "", GEN_TO_REG, 0x3b} }, - {"ashrl", { 2, "", GEN_TO_REG, 0x3d} }, - {"rotlw", { 2, "", GEN_TO_REG, 0x3e} }, - {"rotrw", { 2, "", GEN_TO_REG, 0x3f} }, - - /* push and pop insns are "going away next release". */ - {"pushw", { 2, "", GEN_TO_REG, 0x0c} }, - {"popw", { 2, "", (0x1|0x8|0x10), 0x0d} }, - {"pusha", { 2, "", (0x8|0x10), 0x0e} }, - - {"bitsw", { 2, "", UNKNOWN, 0x35} }, - {"bitcw", { 2, "", UNKNOWN, 0x36} }, - /* some kind of ibra/dbra insns??*/ - {"icmpw", { 2, "", UNKNOWN, 0x67} }, - {"dcmpw", { 2, "", (1|4|0x20|0x80|0x400|0x1000), 0x69} },/*FIXME*/ - {"acmpw", { 2, "", 1, 0x6b} }, - - /* Call is written as a 1-op insn, but is always (dis)assembled as a 2-op - insn with a 2nd op of tr14. The assembler will have to grok this. */ - {"call", { 2, "", GEN_TO_REG, 0x04} }, - {"call", { 1, "", GEN_TO_REG, 0x04} }, - - {"callk", { 1, "", UNKNOWN, 0x06} },/* system call?*/ - /* Ret is usually written as a 0-op insn, but gets disassembled as a - 1-op insn. The operand is always tr15. */ - {"ret", { 0, "", UNKNOWN, 0x09} }, - {"ret", { 1, "", UNKNOWN, 0x09} }, - {"adsf", { 2, "", (1|2|4), 0x08} }, - {"retd", { 2, "", UNKNOWN, 0x0a} }, - {"btc", { 2, "", UNKNOWN, 0x01} }, - {"bfc", { 2, "", UNKNOWN, 0x02} }, - /* Careful: halt is 0x00000000. Jump must have some other (mode?)bit set?? */ - {"jump", { 1, "", UNKNOWN, 0x00} }, - {"btp", { 2, "", UNKNOWN, 0xf00} }, - /* read control-stack pointer is another 1-or-2 operand insn. */ - {"rcsp", { 2, "", UNKNOWN, 0x01f} }, - {"rcsp", { 1, "", UNKNOWN, 0x01f} } -}; - -/* end: pyramid.opcode.h */ -/* One day I will have to take the time to find out what operands - are valid for these insns, and guess at what they mean. - - I can't imagine what the "I???" insns (iglob, etc) do. - - the arithmetic-sounding insns ending in "p" sound awfully like BCD - arithmetic insns: - dshlp -> Decimal SHift Left Packed - dshrp -> Decimal SHift Right Packed - and cvtlp would be convert long to packed. - I have no idea how the operands are interpreted; but having them be - a long register with (address, length) of an in-memory packed BCD operand - would not be surprising. - They are unlikely to be a packed bcd string: 64 bits of long give - is only 15 digits+sign, which isn't enough for COBOL. - */ -#if 0 - {"wcsp", { 2, "", UNKNOWN, 0x00} }, /*write csp?*/ - /* The OSx Operating System Porting Guide claims SSL does things - with tr12 (a register reserved to it) to do with static block-structure - references. SSL=Set Static Link? It's "Going away next release". */ - {"ssl", { 2, "", UNKNOWN, 0x00} }, - {"ccmps", { 2, "", UNKNOWN, 0x00} }, - {"lcd", { 2, "", UNKNOWN, 0x00} }, - {"uemul", { 2, "", UNKNOWN, 0x00} }, /*unsigned emul*/ - {"srf", { 2, "", UNKNOWN, 0x00} }, /*Gidget time???*/ - {"mnegp", { 2, "", UNKNOWN, 0x00} }, /move-neg phys?*/ - {"ldp", { 2, "", UNKNOWN, 0x00} }, /*load phys?*/ - {"ldti", { 2, "", UNKNOWN, 0x00} }, - {"ldb", { 2, "", UNKNOWN, 0x00} }, - {"stp", { 2, "", UNKNOWN, 0x00} }, - {"stti", { 2, "", UNKNOWN, 0x00} }, - {"stb", { 2, "", UNKNOWN, 0x00} }, - {"stu", { 2, "", UNKNOWN, 0x00} }, - {"addp", { 2, "", UNKNOWN, 0x00} }, - {"subp", { 2, "", UNKNOWN, 0x00} }, - {"mulp", { 2, "", UNKNOWN, 0x00} }, - {"divp", { 2, "", UNKNOWN, 0x00} }, - {"dshlp", { 2, "", UNKNOWN, 0x00} }, /* dec shl packed? */ - {"dshrp", { 2, "", UNKNOWN, 0x00} }, /* dec shr packed? */ - {"movs", { 2, "", UNKNOWN, 0x00} }, /*move (string?)?*/ - {"cmpp", { 2, "", UNKNOWN, 0x00} }, /* cmp phys?*/ - {"cmps", { 2, "", UNKNOWN, 0x00} }, /* cmp (string?)?*/ - {"cvtlp", { 2, "", UNKNOWN, 0x00} }, /* cvt long to p??*/ - {"cvtpl", { 2, "", UNKNOWN, 0x00} }, /* cvt p to l??*/ - {"dintr", { 2, "", UNKNOWN, 0x00} }, /* ?? intr ?*/ - {"rphysw", { 2, "", UNKNOWN, 0x00} }, /* read phys word?*/ - {"wphysw", { 2, "", UNKNOWN, 0x00} }, /* write phys word?*/ - {"cmovs", { 2, "", UNKNOWN, 0x00} }, - {"rsubw", { 2, "", UNKNOWN, 0x00} }, - {"bicpsw", { 2, "", UNKNOWN, 0x00} }, /* clr bit in psw? */ - {"bispsw", { 2, "", UNKNOWN, 0x00} }, /* set bit in psw? */ - {"eio", { 2, "", UNKNOWN, 0x00} }, /* ?? ?io ? */ - {"callp", { 2, "", UNKNOWN, 0x00} }, /* call phys?*/ - {"callr", { 2, "", UNKNOWN, 0x00} }, - {"lpcxt", { 2, "", UNKNOWN, 0x00} }, /*load proc context*/ - {"rei", { 2, "", UNKNOWN, 0x00} }, /*ret from intrpt*/ - {"rport", { 2, "", UNKNOWN, 0x00} }, /*read-port?*/ - {"rtod", { 2, "", UNKNOWN, 0x00} }, /*read-time-of-day?*/ - {"ssi", { 2, "", UNKNOWN, 0x00} }, - {"vtpa", { 2, "", UNKNOWN, 0x00} }, /*virt-to-phys-addr?*/ - {"wicl", { 2, "", UNKNOWN, 0x00} }, /* write icl ? */ - {"wport", { 2, "", UNKNOWN, 0x00} }, /*write-port?*/ - {"wtod", { 2, "", UNKNOWN, 0x00} }, /*write-time-of-day?*/ - {"flic", { 2, "", UNKNOWN, 0x00} }, - {"iglob", { 2, "", UNKNOWN, 0x00} }, /* I global? */ - {"iphys", { 2, "", UNKNOWN, 0x00} }, /* I physical? */ - {"ipid", { 2, "", UNKNOWN, 0x00} }, /* I pid? */ - {"ivect", { 2, "", UNKNOWN, 0x00} }, /* I vector? */ - {"lamst", { 2, "", UNKNOWN, 0x00} }, - {"tio", { 2, "", UNKNOWN, 0x00} }, -#endif diff --git a/include/ranlib.h b/include/ranlib.h deleted file mode 100755 index 53e35ce2e0e..00000000000 --- a/include/ranlib.h +++ /dev/null @@ -1,62 +0,0 @@ -/* ranlib.h -- archive library index member definition for GNU. - Copyright 1990-1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* The Symdef member of an archive contains two things: - a table that maps symbol-string offsets to file offsets, - and a symbol-string table. All the symbol names are - run together (each with trailing null) in the symbol-string - table. There is a single longword bytecount on the front - of each of these tables. Thus if we have two symbols, - "foo" and "_bar", that are in archive members at offsets - 200 and 900, it would look like this: - 16 ; byte count of index table - 0 ; offset of "foo" in string table - 200 ; offset of foo-module in file - 4 ; offset of "bar" in string table - 900 ; offset of bar-module in file - 9 ; byte count of string table - "foo\0_bar\0" ; string table */ - -#define RANLIBMAG "__.SYMDEF" /* Archive file name containing index */ -#define RANLIBSKEW 3 /* Creation time offset */ - -/* Format of __.SYMDEF: - First, a longword containing the size of the 'symdef' data that follows. - Second, zero or more 'symdef' structures. - Third, a longword containing the length of symbol name strings. - Fourth, zero or more symbol name strings (each followed by a null). */ - -struct symdef - { - union - { - unsigned long string_offset; /* In the file */ - char *name; /* In memory, sometimes */ - } s; - /* this points to the front of the file header (AKA member header -- - a struct ar_hdr), not to the front of the file or into the file). - in other words it only tells you which file to read */ - unsigned long file_offset; - }; - -/* Compatability with BSD code */ - -#define ranlib symdef -#define ran_un s -#define ran_strx string_offset -#define ran_name name -#define ran_off file_offset diff --git a/include/reloc.h b/include/reloc.h deleted file mode 100755 index 6be60e88072..00000000000 --- a/include/reloc.h +++ /dev/null @@ -1,64 +0,0 @@ -/* reloc.h -- Header file for relocation information. - Copyright 1989-1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Relocation types for a.out files using reloc_info_extended - (SPARC and AMD 29000). */ - -#ifndef _RELOC_H_READ_ -#define _RELOC_H_READ_ 1 - -enum reloc_type - { - RELOC_8, RELOC_16, RELOC_32, /* simple relocations */ - RELOC_DISP8, RELOC_DISP16, RELOC_DISP32, /* pc-rel displacement */ - RELOC_WDISP30, RELOC_WDISP22, - RELOC_HI22, RELOC_22, - RELOC_13, RELOC_LO10, - RELOC_SFA_BASE, RELOC_SFA_OFF13, - RELOC_BASE10, RELOC_BASE13, RELOC_BASE22, /* P.I.C. (base-relative) */ - RELOC_PC10, RELOC_PC22, /* for some sort of pc-rel P.I.C. (?) */ - RELOC_JMP_TBL, /* P.I.C. jump table */ - RELOC_SEGOFF16, /* reputedly for shared libraries somehow */ - RELOC_GLOB_DAT, RELOC_JMP_SLOT, RELOC_RELATIVE, - RELOC_11, - RELOC_WDISP2_14, - RELOC_WDISP19, - RELOC_HHI22, - RELOC_HLO10, - - /* 29K relocation types */ - RELOC_JUMPTARG, RELOC_CONST, RELOC_CONSTH, - - RELOC_WDISP14, RELOC_WDISP21, - - NO_RELOC - }; - -#define RELOC_TYPE_NAMES \ -"8", "16", "32", "DISP8", \ -"DISP16", "DISP32", "WDISP30", "WDISP22", \ -"HI22", "22", "13", "LO10", \ -"SFA_BASE", "SFAOFF13", "BASE10", "BASE13", \ -"BASE22", "PC10", "PC22", "JMP_TBL", \ -"SEGOFF16", "GLOB_DAT", "JMP_SLOT", "RELATIVE", \ -"11", "WDISP2_14", "WDISP19", "JUMPTARG", \ -"CONST", "CONSTH", "WDISP14", "WDISP21", \ -"NO_RELOC" - -#endif /* _RELOC_H_READ_ */ - -/* end of reloc.h */ diff --git a/include/sparc-opcode.h b/include/sparc-opcode.h deleted file mode 100755 index a00ae5befc0..00000000000 --- a/include/sparc-opcode.h +++ /dev/null @@ -1,1843 +0,0 @@ -/* to sanitize this file, grep -v v9 < sparc-opcode.h > clean-sparc-opcode.h */ - -/* Table of opcodes for the sparc. - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - -This file is part of GAS, the GNU Assembler, and GDB, the GNU disassembler. - -GAS/GDB 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. - -GAS/GDB 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 GAS or GDB; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - - /* FIXME-someday: perhaps the ,a's and such should be embedded in the - instruction's name rather than the args. This would make gas faster, pinsn - slower, but would mess up some macros a bit. xoxorich. */ - -#if !defined(__STDC__) && !defined(const) -#define const -#endif - -/* - * Structure of an opcode table entry. - */ -enum sparc_architecture { - v6 = 0, - v7, - cypress, - v8, - v9, -}; - -static const char *architecture_pname[] = { - "v6", - "v7", - "cypress", - "v8", - "v9", - NULL, -}; - -struct sparc_opcode { - const char *name; - unsigned long match; /* Bits that must be set. */ - unsigned long lose; /* Bits that must not be set. */ - const char *args; - /* This was called "delayed" in versions before the flags. */ - char flags; - enum sparc_architecture architecture; -}; - -#define F_DELAYED 1 /* Delayed branch */ -#define F_ALIAS 2 /* Alias for a "real" instruction */ - -/* - -All sparc opcodes are 32 bits, except for the `set' instruction (really a -macro), which is 64 bits. It is handled as a special case. - -The match component is a mask saying which bits must match a particular -opcode in order for an instruction to be an instance of that opcode. - -The args component is a string containing one character for each operand of the -instruction. - -Kinds of operands: - # Number used by optimizer. It is ignored. - 1 rs1 register. - 2 rs2 register. - d rd register. - e frs1 floating point register. - v frs1 floating point register (double/even). - V frs1 floating point register (quad/multiple of 4). - f frs2 floating point register. - B frs2 floating point register (double/even). - R frs2 floating point register (quad/multiple of 4). - j frs3 floating point register. (v9) - u frs3 floating point register. (double/even) (v9) - U frs3 floating point register. (quad/multiple of 4) (v9) - g frsd floating point register. - H frsd floating point register (double/even). - J frsd floating point register (quad/multiple of 4). - b crs1 coprocessor register - c crs2 coprocessor register - D crsd coprocessor register - m alternate space register (asr) in rd - M alternate space register (asr) in rs1 - h 22 high bits. - I 11 bit Immediate. (v9) - i 13 bit Immediate. - k 2+14 bit PC relative immediate. (v9) - G 19 bit PC relative immediate. (v9) - l 22 bit PC relative immediate. - L 30 bit PC relative immediate. - a Annul. The annul bit is set. - A Alternate address space. Stored as 8 bits. - C Coprocessor state register. - F floating point state register. - p Processor state register. - N Branch predict clear ",pn" (v9) - T Branch predict set ",pt" (v9) - z icc. (v9) - Z xcc. (v9) - q Floating point queue. - r Single register that is both rs1 and rsd. - Q Coprocessor queue. - S Special case. - t Trap base register. - w Window invalid mask register. - y Y register. - Y %amr (v9?) - P %pc. (v9) - E %modes. (v9) - W %tick. (v9) - 6 fcc0. (v9) - 7 fcc1. (v9) - 8 fcc2. (v9) - 9 fcc3. (v9) - -The following chars are unused: (note: ,[] are used as punctuation) -[nosxOX3450] - -*/ - -/* The order of the opcodes in this table is significant: - - * The assembler requires that all instances of the same mnemonic must - be consecutive. If they aren't, the assembler will bomb at runtime. - - * The disassembler should not care about the order of the opcodes. - -*/ - -#define OP2(x) (((x)&0x7) << 22) /* op2 field of format2 insns */ -#define OP3(x) (((x)&0x3f) << 19) /* op3 field of format3 insns */ -#define OP(x) (((x)&0x3) << 30) /* op field of all insns */ -#define OPF(x) (((x)&0x1ff) << 5) /* opf field of float insns */ -#define OPF_LOW(x) OPF((x)&0xf) /* v9 */ -#define F3F(x, y, z) (OP(x) | OP3(y) | OPF(z)) /* format3 float insns */ -#define F3I(x) (((x)&0x1) << 13) /* immediate field of format 3 insns */ -#define F2(x, y) (OP(x) | OP2(y)) /* format 2 insns */ -#define F3(x, y, z) (OP(x) | OP3(y) | F3I(z)) /* format3 insns */ -#define F1(x) (OP(x)) -#define DISP30(x) ((x)&0x3fffffff) -#define ASI(x) (((x)&0xff) << 5) /* asi field of format3 insns */ -#define RS2(x) ((x)&0x1f) /* rs2 field */ -#define SIMM13(x) ((x)&0x1fff) /* simm13 field */ -#define RD(x) (((x)&0x1f) << 25) /* destination register field */ -#define RS1(x) (((x)&0x1f) << 14) /* rs1 field */ -#define ASI_RS2(x) (SIMM13(x)) - -#define ANNUL (1<<29) -#define BPRED (1<<21) /* v9 */ -#define IMMED F3I(1) -#define RD_G0 RD(~0) -#define RS1_G0 RS1(~0) -#define RS2_G0 RS2(~0) - -#define COND(x) (((x)&0xf)<<25) -#define MCOND(x) (((x)>>11)&(0xf<<14)) /* v9 */ - -#define CONDA (COND(0x8)) -#define CONDCC (COND(0xd)) -#define CONDCS (COND(0x5)) -#define CONDE (COND(0x1)) -#define CONDG (COND(0xa)) -#define CONDGE (COND(0xb)) -#define CONDGU (COND(0xc)) -#define CONDL (COND(0x3)) -#define CONDLE (COND(0x2)) -#define CONDLEU (COND(0x4)) -#define CONDN (COND(0x0)) -#define CONDNE (COND(0x9)) -#define CONDNEG (COND(0x6)) -#define CONDPOS (COND(0xe)) -#define CONDVC (COND(0xf)) -#define CONDVS (COND(0x7)) - -#define CONDNZ CONDNE -#define CONDZ CONDE -#define CONDGEU CONDCC -#define CONDLU CONDCS - -#define FCONDA (COND(0x8)) -#define FCONDE (COND(0x9)) -#define FCONDG (COND(0x6)) -#define FCONDGE (COND(0xb)) -#define FCONDL (COND(0x4)) -#define FCONDLE (COND(0xd)) -#define FCONDLG (COND(0x2)) -#define FCONDN (COND(0x0)) -#define FCONDNE (COND(0x1)) -#define FCONDO (COND(0xf)) -#define FCONDU (COND(0x7)) -#define FCONDUE (COND(0xa)) -#define FCONDUG (COND(0x5)) -#define FCONDUGE (COND(0xc)) -#define FCONDUL (COND(0x3)) -#define FCONDULE (COND(0xe)) - -#define FCONDNZ FCONDNE -#define FCONDZ FCONDE - -#define ICC (0) /* v9 */ -#define XCC (1<<11) /* v9 */ -#define FCC(x) (((x)&0x3)<<11) /* v9 */ -#define FBFCC(x) (((x)&0x3)<<19) /* v9 */ - -static struct sparc_opcode sparc_opcodes[] = { - -{ "ld", F3(3, 0x00, 0), F3(~3, ~0x00, ~0), "[1+2],d", 0, v6 }, -{ "ld", F3(3, 0x00, 0), F3(~3, ~0x00, ~0)|RS2_G0, "[1],d", 0, v6 }, /* ld [rs1+%g0],d */ -{ "ld", F3(3, 0x00, 1), F3(~3, ~0x00, ~1), "[1+i],d", 0, v6 }, -{ "ld", F3(3, 0x00, 1), F3(~3, ~0x00, ~1), "[i+1],d", 0, v6 }, -{ "ld", F3(3, 0x00, 1), F3(~3, ~0x00, ~1)|RS1_G0, "[i],d", 0, v6 }, -{ "ld", F3(3, 0x00, 1), F3(~3, ~0x00, ~1)|SIMM13(~0), "[1],d", 0, v6 }, /* ld [rs1+0],d */ -{ "ld", F3(3, 0x20, 0), F3(~3, ~0x20, ~0), "[1+2],g", 0, v6 }, -{ "ld", F3(3, 0x20, 0), F3(~3, ~0x20, ~0)|RS2_G0, "[1],g", 0, v6 }, /* ld [rs1+%g0],d */ -{ "ld", F3(3, 0x20, 1), F3(~3, ~0x20, ~1), "[1+i],g", 0, v6 }, -{ "ld", F3(3, 0x20, 1), F3(~3, ~0x20, ~1), "[i+1],g", 0, v6 }, -{ "ld", F3(3, 0x20, 1), F3(~3, ~0x20, ~1)|RS1_G0, "[i],g", 0, v6 }, -{ "ld", F3(3, 0x20, 1), F3(~3, ~0x20, ~1)|SIMM13(~0), "[1],g", 0, v6 }, /* ld [rs1+0],d */ -{ "ld", F3(3, 0x21, 0), F3(~3, ~0x21, ~0), "[1+2],F", 0, v6 }, -{ "ld", F3(3, 0x21, 0), F3(~3, ~0x21, ~0)|RS2_G0, "[1],F", 0, v6 }, /* ld [rs1+%g0],d */ -{ "ld", F3(3, 0x21, 1), F3(~3, ~0x21, ~1), "[1+i],F", 0, v6 }, -{ "ld", F3(3, 0x21, 1), F3(~3, ~0x21, ~1), "[i+1],F", 0, v6 }, -{ "ld", F3(3, 0x21, 1), F3(~3, ~0x21, ~1)|RS1_G0, "[i],F", 0, v6 }, -{ "ld", F3(3, 0x21, 1), F3(~3, ~0x21, ~1)|SIMM13(~0), "[1],F", 0, v6 }, /* ld [rs1+0],d */ -{ "ld", F3(3, 0x30, 0), F3(~3, ~0x30, ~0), "[1+2],D", 0, v6 }, -{ "ld", F3(3, 0x30, 0), F3(~3, ~0x30, ~0)|RS2_G0, "[1],D", 0, v6 }, /* ld [rs1+%g0],d */ -{ "ld", F3(3, 0x30, 1), F3(~3, ~0x30, ~1), "[1+i],D", 0, v6 }, -{ "ld", F3(3, 0x30, 1), F3(~3, ~0x30, ~1), "[i+1],D", 0, v6 }, -{ "ld", F3(3, 0x30, 1), F3(~3, ~0x30, ~1)|RS1_G0, "[i],D", 0, v6 }, -{ "ld", F3(3, 0x30, 1), F3(~3, ~0x30, ~1)|SIMM13(~0), "[1],D", 0, v6 }, /* ld [rs1+0],d */ -{ "ld", F3(3, 0x31, 0), F3(~3, ~0x31, ~0), "[1+2],C", 0, v6 }, -{ "ld", F3(3, 0x31, 0), F3(~3, ~0x31, ~0)|RS2_G0, "[1],C", 0, v6 }, /* ld [rs1+%g0],d */ -{ "ld", F3(3, 0x31, 1), F3(~3, ~0x31, ~1), "[1+i],C", 0, v6 }, -{ "ld", F3(3, 0x31, 1), F3(~3, ~0x31, ~1), "[i+1],C", 0, v6 }, -{ "ld", F3(3, 0x31, 1), F3(~3, ~0x31, ~1)|RS1_G0, "[i],C", 0, v6 }, -{ "ld", F3(3, 0x31, 1), F3(~3, ~0x31, ~1)|SIMM13(~0), "[1],C", 0, v6 }, /* ld [rs1+0],d */ - - /* FIXME-v9: combine ld, lduw, & ldw in macros. */ -{ "ldw", F3(3, 0x00, 0), F3(~3, ~0x00, ~0), "[1+2],d", F_ALIAS, v9 }, /* ldw === ld */ -{ "ldw", F3(3, 0x00, 0), F3(~3, ~0x00, ~0)|RS2_G0, "[1],d", F_ALIAS, v9 }, /* ld [rs1+%g0],d */ -{ "ldw", F3(3, 0x00, 1), F3(~3, ~0x00, ~1), "[1+i],d", F_ALIAS, v9 }, -{ "ldw", F3(3, 0x00, 1), F3(~3, ~0x00, ~1), "[i+1],d", F_ALIAS, v9 }, -{ "ldw", F3(3, 0x00, 1), F3(~3, ~0x00, ~1)|RS1_G0, "[i],d", F_ALIAS, v9 }, -{ "ldw", F3(3, 0x00, 1), F3(~3, ~0x00, ~1)|SIMM13(~0), "[1],d", F_ALIAS, v9 }, /* ld [rs1+0],d */ -{ "ldw", F3(3, 0x20, 0), F3(~3, ~0x20, ~0), "[1+2],g", F_ALIAS, v9 }, -{ "ldw", F3(3, 0x20, 0), F3(~3, ~0x20, ~0)|RS2_G0, "[1],g", F_ALIAS, v9 }, /* ld [rs1+%g0],d */ -{ "ldw", F3(3, 0x20, 1), F3(~3, ~0x20, ~1), "[1+i],g", F_ALIAS, v9 }, -{ "ldw", F3(3, 0x20, 1), F3(~3, ~0x20, ~1), "[i+1],g", F_ALIAS, v9 }, -{ "ldw", F3(3, 0x20, 1), F3(~3, ~0x20, ~1)|RS1_G0, "[i],g", F_ALIAS, v9 }, -{ "ldw", F3(3, 0x20, 1), F3(~3, ~0x20, ~1)|SIMM13(~0), "[1],g", F_ALIAS, v9 }, /* ld [rs1+0],d */ -{ "ldw", F3(3, 0x21, 0), F3(~3, ~0x21, ~0), "[1+2],F", F_ALIAS, v9 }, -{ "ldw", F3(3, 0x21, 0), F3(~3, ~0x21, ~0)|RS2_G0, "[1],F", F_ALIAS, v9 }, /* ld [rs1+%g0],d */ -{ "ldw", F3(3, 0x21, 1), F3(~3, ~0x21, ~1), "[1+i],F", F_ALIAS, v9 }, -{ "ldw", F3(3, 0x21, 1), F3(~3, ~0x21, ~1), "[i+1],F", F_ALIAS, v9 }, -{ "ldw", F3(3, 0x21, 1), F3(~3, ~0x21, ~1)|RS1_G0, "[i],F", F_ALIAS, v9 }, -{ "ldw", F3(3, 0x21, 1), F3(~3, ~0x21, ~1)|SIMM13(~0), "[1],F", F_ALIAS, v9 }, /* ld [rs1+0],d */ -{ "ldw", F3(3, 0x30, 0), F3(~3, ~0x30, ~0), "[1+2],D", F_ALIAS, v9 }, -{ "ldw", F3(3, 0x30, 0), F3(~3, ~0x30, ~0)|RS2_G0, "[1],D", F_ALIAS, v9 }, /* ld [rs1+%g0],d */ -{ "ldw", F3(3, 0x30, 1), F3(~3, ~0x30, ~1), "[1+i],D", F_ALIAS, v9 }, -{ "ldw", F3(3, 0x30, 1), F3(~3, ~0x30, ~1), "[i+1],D", F_ALIAS, v9 }, -{ "ldw", F3(3, 0x30, 1), F3(~3, ~0x30, ~1)|RS1_G0, "[i],D", F_ALIAS, v9 }, -{ "ldw", F3(3, 0x30, 1), F3(~3, ~0x30, ~1)|SIMM13(~0), "[1],D", F_ALIAS, v9 }, /* ld [rs1+0],d */ -{ "ldw", F3(3, 0x31, 0), F3(~3, ~0x31, ~0), "[1+2],C", F_ALIAS, v9 }, -{ "ldw", F3(3, 0x31, 0), F3(~3, ~0x31, ~0)|RS2_G0, "[1],C", F_ALIAS, v9 }, /* ld [rs1+%g0],d */ -{ "ldw", F3(3, 0x31, 1), F3(~3, ~0x31, ~1), "[1+i],C", F_ALIAS, v9 }, -{ "ldw", F3(3, 0x31, 1), F3(~3, ~0x31, ~1), "[i+1],C", F_ALIAS, v9 }, -{ "ldw", F3(3, 0x31, 1), F3(~3, ~0x31, ~1)|RS1_G0, "[i],C", F_ALIAS, v9 }, -{ "ldw", F3(3, 0x31, 1), F3(~3, ~0x31, ~1)|SIMM13(~0), "[1],C", F_ALIAS, v9 }, /* ld [rs1+0],d */ - -{ "lduw", F3(3, 0x00, 0), F3(~3, ~0x00, ~0), "[1+2],d", F_ALIAS, v9 }, /* lduw === ld */ -{ "lduw", F3(3, 0x00, 0), F3(~3, ~0x00, ~0)|RS2_G0, "[1],d", F_ALIAS, v9 }, /* ld [rs1+%g0],d */ -{ "lduw", F3(3, 0x00, 1), F3(~3, ~0x00, ~1), "[1+i],d", F_ALIAS, v9 }, -{ "lduw", F3(3, 0x00, 1), F3(~3, ~0x00, ~1), "[i+1],d", F_ALIAS, v9 }, -{ "lduw", F3(3, 0x00, 1), F3(~3, ~0x00, ~1)|RS1_G0, "[i],d", F_ALIAS, v9 }, -{ "lduw", F3(3, 0x00, 1), F3(~3, ~0x00, ~1)|SIMM13(~0), "[1],d", F_ALIAS, v9 }, /* ld [rs1+0],d */ -{ "lduw", F3(3, 0x20, 0), F3(~3, ~0x20, ~0), "[1+2],g", F_ALIAS, v9 }, -{ "lduw", F3(3, 0x20, 0), F3(~3, ~0x20, ~0)|RS2_G0, "[1],g", F_ALIAS, v9 }, /* ld [rs1+%g0],d */ -{ "lduw", F3(3, 0x20, 1), F3(~3, ~0x20, ~1), "[1+i],g", F_ALIAS, v9 }, -{ "lduw", F3(3, 0x20, 1), F3(~3, ~0x20, ~1), "[i+1],g", F_ALIAS, v9 }, -{ "lduw", F3(3, 0x20, 1), F3(~3, ~0x20, ~1)|RS1_G0, "[i],g", F_ALIAS, v9 }, -{ "lduw", F3(3, 0x20, 1), F3(~3, ~0x20, ~1)|SIMM13(~0), "[1],g", F_ALIAS, v9 }, /* ld [rs1+0],d */ -{ "lduw", F3(3, 0x21, 0), F3(~3, ~0x21, ~0), "[1+2],F", F_ALIAS, v9 }, -{ "lduw", F3(3, 0x21, 0), F3(~3, ~0x21, ~0)|RS2_G0, "[1],F", F_ALIAS, v9 }, /* ld [rs1+%g0],d */ -{ "lduw", F3(3, 0x21, 1), F3(~3, ~0x21, ~1), "[1+i],F", F_ALIAS, v9 }, -{ "lduw", F3(3, 0x21, 1), F3(~3, ~0x21, ~1), "[i+1],F", F_ALIAS, v9 }, -{ "lduw", F3(3, 0x21, 1), F3(~3, ~0x21, ~1)|RS1_G0, "[i],F", F_ALIAS, v9 }, -{ "lduw", F3(3, 0x21, 1), F3(~3, ~0x21, ~1)|SIMM13(~0), "[1],F", F_ALIAS, v9 }, /* ld [rs1+0],d */ -{ "lduw", F3(3, 0x30, 0), F3(~3, ~0x30, ~0), "[1+2],D", F_ALIAS, v9 }, -{ "lduw", F3(3, 0x30, 0), F3(~3, ~0x30, ~0)|RS2_G0, "[1],D", F_ALIAS, v9 }, /* ld [rs1+%g0],d */ -{ "lduw", F3(3, 0x30, 1), F3(~3, ~0x30, ~1), "[1+i],D", F_ALIAS, v9 }, -{ "lduw", F3(3, 0x30, 1), F3(~3, ~0x30, ~1), "[i+1],D", F_ALIAS, v9 }, -{ "lduw", F3(3, 0x30, 1), F3(~3, ~0x30, ~1)|RS1_G0, "[i],D", F_ALIAS, v9 }, -{ "lduw", F3(3, 0x30, 1), F3(~3, ~0x30, ~1)|SIMM13(~0), "[1],D", F_ALIAS, v9 }, /* ld [rs1+0],d */ -{ "lduw", F3(3, 0x31, 0), F3(~3, ~0x31, ~0), "[1+2],C", F_ALIAS, v9 }, -{ "lduw", F3(3, 0x31, 0), F3(~3, ~0x31, ~0)|RS2_G0, "[1],C", F_ALIAS, v9 }, /* ld [rs1+%g0],d */ -{ "lduw", F3(3, 0x31, 1), F3(~3, ~0x31, ~1), "[1+i],C", F_ALIAS, v9 }, -{ "lduw", F3(3, 0x31, 1), F3(~3, ~0x31, ~1), "[i+1],C", F_ALIAS, v9 }, -{ "lduw", F3(3, 0x31, 1), F3(~3, ~0x31, ~1)|RS1_G0, "[i],C", F_ALIAS, v9 }, -{ "lduw", F3(3, 0x31, 1), F3(~3, ~0x31, ~1)|SIMM13(~0), "[1],C", F_ALIAS, v9 }, /* ld [rs1+0],d */ - -{ "lda", F3(3, 0x10, 0), F3(~3, ~0x10, ~0), "[1+2]A,d", 0, v6 }, -{ "lda", F3(3, 0x10, 0), F3(~3, ~0x10, ~0)|RS2_G0, "[1]A,d", 0, v6 }, /* lda [rs1+%g0],d */ - -{ "ldd", F3(3, 0x03, 0), F3(~3, ~0x03, ~0)|ASI(~0), "[1+2],d", 0, v6 }, -{ "ldd", F3(3, 0x03, 0), F3(~3, ~0x03, ~0)|ASI_RS2(~0), "[1],d", 0, v6 }, /* ldd [rs1+%g0],d */ -{ "ldd", F3(3, 0x03, 1), F3(~3, ~0x03, ~1), "[1+i],d", 0, v6 }, -{ "ldd", F3(3, 0x03, 1), F3(~3, ~0x03, ~1), "[i+1],d", 0, v6 }, -{ "ldd", F3(3, 0x03, 1), F3(~3, ~0x03, ~1)|RS1_G0, "[i],d", 0, v6 }, -{ "ldd", F3(3, 0x03, 1), F3(~3, ~0x03, ~1)|SIMM13(~0), "[1],d", 0, v6 }, /* ldd [rs1+0],d */ -{ "ldd", F3(3, 0x23, 0), F3(~3, ~0x23, ~0)|ASI(~0), "[1+2],g", 0, v6 }, -{ "ldd", F3(3, 0x23, 0), F3(~3, ~0x23, ~0)|ASI_RS2(~0), "[1],g", 0, v6 }, /* ldd [rs1+%g0],d */ -{ "ldd", F3(3, 0x23, 1), F3(~3, ~0x23, ~1), "[1+i],g", 0, v6 }, -{ "ldd", F3(3, 0x23, 1), F3(~3, ~0x23, ~1), "[i+1],g", 0, v6 }, -{ "ldd", F3(3, 0x23, 1), F3(~3, ~0x23, ~1)|RS1_G0, "[i],g", 0, v6 }, -{ "ldd", F3(3, 0x23, 1), F3(~3, ~0x23, ~1)|SIMM13(~0), "[1],g", 0, v6 }, /* ldd [rs1+0],d */ -{ "ldd", F3(3, 0x33, 0), F3(~3, ~0x33, ~0)|ASI(~0), "[1+2],D", 0, v6 }, -{ "ldd", F3(3, 0x33, 0), F3(~3, ~0x33, ~0)|ASI_RS2(~0), "[1],D", 0, v6 }, /* ldd [rs1+%g0],d */ -{ "ldd", F3(3, 0x33, 1), F3(~3, ~0x33, ~1), "[1+i],D", 0, v6 }, -{ "ldd", F3(3, 0x33, 1), F3(~3, ~0x33, ~1), "[i+1],D", 0, v6 }, -{ "ldd", F3(3, 0x33, 1), F3(~3, ~0x33, ~1)|RS1_G0, "[i],D", 0, v6 }, -{ "ldd", F3(3, 0x33, 1), F3(~3, ~0x33, ~1)|SIMM13(~0), "[1],D", 0, v6 }, /* ldd [rs1+0],d */ -{ "ldsb", F3(3, 0x09, 0), F3(~3, ~0x09, ~0)|ASI(~0), "[1+2],d", 0, v6 }, -{ "ldsb", F3(3, 0x09, 0), F3(~3, ~0x09, ~0)|ASI_RS2(~0), "[1],d", 0, v6 }, /* ldsb [rs1+%g0],d */ -{ "ldsb", F3(3, 0x09, 1), F3(~3, ~0x09, ~1), "[1+i],d", 0, v6 }, -{ "ldsb", F3(3, 0x09, 1), F3(~3, ~0x09, ~1), "[i+1],d", 0, v6 }, -{ "ldsb", F3(3, 0x09, 1), F3(~3, ~0x09, ~1)|RS1_G0, "[i],d", 0, v6 }, -{ "ldsb", F3(3, 0x09, 1), F3(~3, ~0x09, ~1)|SIMM13(~0), "[1],d", 0, v6 }, /* ldsb [rs1+0],d */ -{ "ldsh", F3(3, 0x0a, 0), F3(~3, ~0x0a, ~0)|ASI_RS2(~0), "[1],d", 0, v6 }, /* ldsh [rs1+%g0],d */ -{ "ldsh", F3(3, 0x0a, 0), F3(~3, ~0x0a, ~0)|ASI(~0), "[1+2],d", 0, v6 }, -{ "ldsh", F3(3, 0x0a, 1), F3(~3, ~0x0a, ~1), "[1+i],d", 0, v6 }, -{ "ldsh", F3(3, 0x0a, 1), F3(~3, ~0x0a, ~1), "[i+1],d", 0, v6 }, -{ "ldsh", F3(3, 0x0a, 1), F3(~3, ~0x0a, ~1)|RS1_G0, "[i],d", 0, v6 }, -{ "ldsh", F3(3, 0x0a, 1), F3(~3, ~0x0a, ~1)|SIMM13(~0), "[1],d", 0, v6 }, /* ldsh [rs1+0],d */ -{ "ldstub", F3(3, 0x0d, 0), F3(~3, ~0x0d, ~0)|ASI(~0), "[1+2],d", 0, v6 }, -{ "ldstub", F3(3, 0x0d, 0), F3(~3, ~0x0d, ~0)|ASI_RS2(~0), "[1],d", 0, v6 }, /* ldstub [rs1+%g0],d */ -{ "ldstub", F3(3, 0x0d, 1), F3(~3, ~0x0d, ~1), "[1+i],d", 0, v6 }, -{ "ldstub", F3(3, 0x0d, 1), F3(~3, ~0x0d, ~1), "[i+1],d", 0, v6 }, -{ "ldstub", F3(3, 0x0d, 1), F3(~3, ~0x0d, ~1)|RS1_G0, "[i],d", 0, v6 }, -{ "ldsw", F3(3, 0x08, 0), F3(~3, ~0x08, ~0)|ASI(~0), "[1+2],d", 0, v9 }, -{ "ldsw", F3(3, 0x08, 0), F3(~3, ~0x08, ~0)|ASI_RS2(~0), "[1],d", 0, v9 }, /* ldsw [rs1+%g0],d */ -{ "ldsw", F3(3, 0x08, 1), F3(~3, ~0x08, ~1), "[1+i],d", 0, v9 }, -{ "ldsw", F3(3, 0x08, 1), F3(~3, ~0x08, ~1), "[i+1],d", 0, v9 }, -{ "ldsw", F3(3, 0x08, 1), F3(~3, ~0x08, ~1)|RS1_G0, "[i],d", 0, v9 }, -{ "ldsw", F3(3, 0x08, 1), F3(~3, ~0x08, ~1)|SIMM13(~0), "[1],d", 0, v9 }, /* ldsw [rs1+0],d */ -{ "ldub", F3(3, 0x01, 0), F3(~3, ~0x01, ~0)|ASI(~0), "[1+2],d", 0, v6 }, -{ "ldub", F3(3, 0x01, 0), F3(~3, ~0x01, ~0)|ASI_RS2(~0), "[1],d", 0, v6 }, /* ldub [rs1+%g0],d */ -{ "ldub", F3(3, 0x01, 1), F3(~3, ~0x01, ~1), "[1+i],d", 0, v6 }, -{ "ldub", F3(3, 0x01, 1), F3(~3, ~0x01, ~1), "[i+1],d", 0, v6 }, -{ "ldub", F3(3, 0x01, 1), F3(~3, ~0x01, ~1)|RS1_G0, "[i],d", 0, v6 }, -{ "ldub", F3(3, 0x01, 1), F3(~3, ~0x01, ~1)|SIMM13(~0), "[1],d", 0, v6 }, /* ldub [rs1+0],d */ -{ "lduh", F3(3, 0x02, 0), F3(~3, ~0x02, ~0)|ASI(~0), "[1+2],d", 0, v6 }, -{ "lduh", F3(3, 0x02, 0), F3(~3, ~0x02, ~0)|ASI_RS2(~0), "[1],d", 0, v6 }, /* lduh [rs1+%g0],d */ -{ "lduh", F3(3, 0x02, 1), F3(~3, ~0x02, ~1), "[1+i],d", 0, v6 }, -{ "lduh", F3(3, 0x02, 1), F3(~3, ~0x02, ~1), "[i+1],d", 0, v6 }, -{ "lduh", F3(3, 0x02, 1), F3(~3, ~0x02, ~1)|RS1_G0, "[i],d", 0, v6 }, -{ "lduh", F3(3, 0x02, 1), F3(~3, ~0x02, ~1)|SIMM13(~0), "[1],d", 0, v6 }, /* lduh [rs1+0],d */ - -{ "ldx", F3(3, 0x0b, 0), F3(~3, ~0x0b, ~0)|ASI(~0), "[1+2],d", 0, v9 }, -{ "ldx", F3(3, 0x0b, 0), F3(~3, ~0x0b, ~0)|ASI_RS2(~0), "[1],d", 0, v9 }, /* ldx [rs1+%g0],d */ -{ "ldx", F3(3, 0x0b, 1), F3(~3, ~0x0b, ~1), "[1+i],d", 0, v9 }, -{ "ldx", F3(3, 0x0b, 1), F3(~3, ~0x0b, ~1), "[i+1],d", 0, v9 }, -{ "ldx", F3(3, 0x0b, 1), F3(~3, ~0x0b, ~1)|RS1_G0, "[i],d", 0, v9 }, -{ "ldx", F3(3, 0x0b, 1), F3(~3, ~0x0b, ~1)|SIMM13(~0), "[1],d", 0, v9 }, /* ldx [rs1+0],d */ -{ "ldx", F3(3, 0x29, 0), F3(~3, ~0x29, ~0), "[1+2],F", 0, v9 }, -{ "ldx", F3(3, 0x29, 0), F3(~3, ~0x29, ~0)|RS2_G0, "[1],F", 0, v9 }, /* ld [rs1+%g0],d */ -{ "ldx", F3(3, 0x29, 1), F3(~3, ~0x29, ~1), "[1+i],F", 0, v9 }, -{ "ldx", F3(3, 0x29, 1), F3(~3, ~0x29, ~1), "[i+1],F", 0, v9 }, -{ "ldx", F3(3, 0x29, 1), F3(~3, ~0x29, ~1)|RS1_G0, "[i],F", 0, v9 }, -{ "ldx", F3(3, 0x29, 1), F3(~3, ~0x29, ~1)|SIMM13(~0), "[1],F", 0, v9 }, /* ld [rs1+0],d */ - -{ "ldda", F3(3, 0x13, 0), F3(~3, ~0x13, ~0), "[1+2]A,d", 0, v6 }, -{ "ldda", F3(3, 0x13, 0), F3(~3, ~0x13, ~0)|RS2_G0, "[1]A,d", 0, v6 }, /* ldda [rs1+%g0],d */ -{ "ldsba", F3(3, 0x19, 0), F3(~3, ~0x19, ~0), "[1+2]A,d", 0, v6 }, -{ "ldsba", F3(3, 0x19, 0), F3(~3, ~0x19, ~0)|RS2_G0, "[1]A,d", 0, v6 }, /* ldsba [rs1+%g0],d */ -{ "ldsha", F3(3, 0x1a, 0), F3(~3, ~0x1a, ~0), "[1+2]A,d", 0, v6 }, -{ "ldsha", F3(3, 0x1a, 0), F3(~3, ~0x1a, ~0)|RS2_G0, "[1]A,d", 0, v6 }, /* ldsha [rs1+%g0],d */ -{ "ldstuba", F3(3, 0x1d, 0), F3(~3, ~0x1d, ~0), "[1+2]A,d", 0, v6 }, -{ "ldstuba", F3(3, 0x1d, 0), F3(~3, ~0x1d, ~0)|RS2_G0, "[1]A,d", 0, v6 }, /* ldstuba [rs1+%g0],d */ -{ "ldswa", F3(3, 0x18, 0), F3(~3, ~0x18, ~0), "[1+2]A,d", 0, v9 }, /* lduwa === lda */ -{ "ldswa", F3(3, 0x18, 0), F3(~3, ~0x18, ~0)|RS2_G0, "[1]A,d", 0, v9 }, /* lda [rs1+%g0],d */ -{ "lduba", F3(3, 0x11, 0), F3(~3, ~0x11, ~0), "[1+2]A,d", 0, v6 }, -{ "lduba", F3(3, 0x11, 0), F3(~3, ~0x11, ~0)|RS2_G0, "[1]A,d", 0, v6 }, /* lduba [rs1+%g0],d */ -{ "lduha", F3(3, 0x12, 0), F3(~3, ~0x12, ~0), "[1+2]A,d", 0, v6 }, -{ "lduha", F3(3, 0x12, 0), F3(~3, ~0x12, ~0)|RS2_G0, "[1]A,d", 0, v6 }, /* lduha [rs1+%g0],d */ -{ "lduwa", F3(3, 0x10, 0), F3(~3, ~0x10, ~0), "[1+2]A,d", F_ALIAS, v9 }, /* lduwa === lda */ -{ "lduwa", F3(3, 0x10, 0), F3(~3, ~0x10, ~0)|RS2_G0, "[1]A,d", F_ALIAS, v9 }, /* lda [rs1+%g0],d */ -{ "ldxa", F3(3, 0x1b, 0), F3(~3, ~0x1b, ~0), "[1+2]A,d", 0, v9 }, /* lduwa === lda */ -{ "ldxa", F3(3, 0x1b, 0), F3(~3, ~0x1b, ~0)|RS2_G0, "[1]A,d", 0, v9 }, /* lda [rs1+%g0],d */ - -{ "st", F3(3, 0x04, 0), F3(~3, ~0x04, ~0)|ASI(~0), "d,[1+2]", 0, v6 }, -{ "st", F3(3, 0x04, 0), F3(~3, ~0x04, ~0)|ASI_RS2(~0), "d,[1]", 0, v6 }, /* st d,[rs1+%g0] */ -{ "st", F3(3, 0x04, 1), F3(~3, ~0x04, ~1), "d,[1+i]", 0, v6 }, -{ "st", F3(3, 0x04, 1), F3(~3, ~0x04, ~1), "d,[i+1]", 0, v6 }, -{ "st", F3(3, 0x04, 1), F3(~3, ~0x04, ~1)|RS1_G0, "d,[i]", 0, v6 }, -{ "st", F3(3, 0x04, 1), F3(~3, ~0x04, ~1)|SIMM13(~0), "d,[1]", 0, v6 }, /* st d,[rs1+0] */ -{ "st", F3(3, 0x24, 0), F3(~3, ~0x24, ~0)|ASI(~0), "g,[1+2]", 0, v6 }, -{ "st", F3(3, 0x24, 0), F3(~3, ~0x24, ~0)|ASI_RS2(~0), "g,[1]", 0, v6 }, /* st d[rs1+%g0] */ -{ "st", F3(3, 0x24, 1), F3(~3, ~0x24, ~1), "g,[1+i]", 0, v6 }, -{ "st", F3(3, 0x24, 1), F3(~3, ~0x24, ~1), "g,[i+1]", 0, v6 }, -{ "st", F3(3, 0x24, 1), F3(~3, ~0x24, ~1)|RS1_G0, "g,[i]", 0, v6 }, -{ "st", F3(3, 0x24, 1), F3(~3, ~0x24, ~1)|SIMM13(~0), "g,[1]", 0, v6 }, /* st d,[rs1+0] */ -{ "st", F3(3, 0x34, 0), F3(~3, ~0x34, ~0)|ASI(~0), "D,[1+2]", 0, v6 }, -{ "st", F3(3, 0x34, 0), F3(~3, ~0x34, ~0)|ASI_RS2(~0), "D,[1]", 0, v6 }, /* st d,[rs1+%g0] */ -{ "st", F3(3, 0x34, 1), F3(~3, ~0x34, ~1), "D,[1+i]", 0, v6 }, -{ "st", F3(3, 0x34, 1), F3(~3, ~0x34, ~1), "D,[i+1]", 0, v6 }, -{ "st", F3(3, 0x34, 1), F3(~3, ~0x34, ~1)|RS1_G0, "D,[i]", 0, v6 }, -{ "st", F3(3, 0x34, 1), F3(~3, ~0x34, ~1)|SIMM13(~0), "D,[1]", 0, v6 }, /* st d,[rs1+0] */ -{ "st", F3(3, 0x35, 0), F3(~3, ~0x35, ~0)|ASI(~0), "C,[1+2]", 0, v6 }, -{ "st", F3(3, 0x35, 0), F3(~3, ~0x35, ~0)|ASI_RS2(~0), "C,[1]", 0, v6 }, /* st d,[rs1+%g0] */ -{ "st", F3(3, 0x35, 1), F3(~3, ~0x35, ~1), "C,[1+i]", 0, v6 }, -{ "st", F3(3, 0x35, 1), F3(~3, ~0x35, ~1), "C,[i+1]", 0, v6 }, -{ "st", F3(3, 0x35, 1), F3(~3, ~0x35, ~1)|RS1_G0, "C,[i]", 0, v6 }, -{ "st", F3(3, 0x35, 1), F3(~3, ~0x35, ~1)|SIMM13(~0), "C,[1]", 0, v6 }, /* st d,[rs1+0] */ - -{ "st", F3(3, 0x25, 0), F3(~3, ~0x25, ~0)|RD_G0|ASI(~0), "F,[1+2]", 0, v6 }, -{ "st", F3(3, 0x25, 0), F3(~3, ~0x25, ~0)|RD_G0|ASI_RS2(~0), "F,[1]", 0, v6 }, /* st d,[rs1+%g0] */ -{ "st", F3(3, 0x25, 1), F3(~3, ~0x25, ~1)|RD_G0, "F,[1+i]", 0, v6 }, -{ "st", F3(3, 0x25, 1), F3(~3, ~0x25, ~1)|RD_G0, "F,[i+1]", 0, v6 }, -{ "st", F3(3, 0x25, 1), F3(~3, ~0x25, ~1)|RD_G0|RS1_G0, "F,[i]", 0, v6 }, -{ "st", F3(3, 0x25, 1), F3(~3, ~0x25, ~1)|SIMM13(~0), "F,[1]", 0, v6 }, /* st d,[rs1+0] */ - - /* FIXME-v9: combine st, stw, stuw, stsw, in macros. */ -{ "stw", F3(3, 0x04, 0), F3(~3, ~0x04, ~0)|ASI(~0), "d,[1+2]", F_ALIAS, v9 }, /* stw === st */ -{ "stw", F3(3, 0x04, 0), F3(~3, ~0x04, ~0)|ASI_RS2(~0), "d,[1]", F_ALIAS, v9 }, /* st d,[rs1+%g0] */ -{ "stw", F3(3, 0x04, 1), F3(~3, ~0x04, ~1), "d,[1+i]", F_ALIAS, v9 }, -{ "stw", F3(3, 0x04, 1), F3(~3, ~0x04, ~1), "d,[i+1]", F_ALIAS, v9 }, -{ "stw", F3(3, 0x04, 1), F3(~3, ~0x04, ~1)|RS1_G0, "d,[i]", F_ALIAS, v9 }, -{ "stw", F3(3, 0x04, 1), F3(~3, ~0x04, ~1)|SIMM13(~0), "d,[1]", F_ALIAS, v9 }, /* st d,[rs1+0] */ -{ "stw", F3(3, 0x24, 0), F3(~3, ~0x24, ~0)|ASI(~0), "g,[1+2]", F_ALIAS, v9 }, -{ "stw", F3(3, 0x24, 0), F3(~3, ~0x24, ~0)|ASI_RS2(~0), "g,[1]", F_ALIAS, v9 }, /* st d[rs1+%g0] */ -{ "stw", F3(3, 0x24, 1), F3(~3, ~0x24, ~1), "g,[1+i]", F_ALIAS, v9 }, -{ "stw", F3(3, 0x24, 1), F3(~3, ~0x24, ~1), "g,[i+1]", F_ALIAS, v9 }, -{ "stw", F3(3, 0x24, 1), F3(~3, ~0x24, ~1)|RS1_G0, "g,[i]", F_ALIAS, v9 }, -{ "stw", F3(3, 0x24, 1), F3(~3, ~0x24, ~1)|SIMM13(~0), "g,[1]", F_ALIAS, v9 }, /* st d,[rs1+0] */ -{ "stw", F3(3, 0x34, 0), F3(~3, ~0x34, ~0)|ASI(~0), "D,[1+2]", F_ALIAS, v9 }, -{ "stw", F3(3, 0x34, 0), F3(~3, ~0x34, ~0)|ASI_RS2(~0), "D,[1]", F_ALIAS, v9 }, /* st d,[rs1+%g0] */ -{ "stw", F3(3, 0x34, 1), F3(~3, ~0x34, ~1), "D,[1+i]", F_ALIAS, v9 }, -{ "stw", F3(3, 0x34, 1), F3(~3, ~0x34, ~1), "D,[i+1]", F_ALIAS, v9 }, -{ "stw", F3(3, 0x34, 1), F3(~3, ~0x34, ~1)|RS1_G0, "D,[i]", F_ALIAS, v9 }, -{ "stw", F3(3, 0x34, 1), F3(~3, ~0x34, ~1)|SIMM13(~0), "D,[1]", F_ALIAS, v9 }, /* st d,[rs1+0] */ -{ "stw", F3(3, 0x35, 0), F3(~3, ~0x35, ~0)|ASI(~0), "C,[1+2]", F_ALIAS, v9 }, -{ "stw", F3(3, 0x35, 0), F3(~3, ~0x35, ~0)|ASI_RS2(~0), "C,[1]", F_ALIAS, v9 }, /* st d,[rs1+%g0] */ -{ "stw", F3(3, 0x35, 1), F3(~3, ~0x35, ~1), "C,[1+i]", F_ALIAS, v9 }, -{ "stw", F3(3, 0x35, 1), F3(~3, ~0x35, ~1), "C,[i+1]", F_ALIAS, v9 }, -{ "stw", F3(3, 0x35, 1), F3(~3, ~0x35, ~1)|RS1_G0, "C,[i]", F_ALIAS, v9 }, -{ "stw", F3(3, 0x35, 1), F3(~3, ~0x35, ~1)|SIMM13(~0), "C,[1]", F_ALIAS, v9 }, /* st d,[rs1+0] */ -{ "stw", F3(3, 0x25, 0), F3(~3, ~0x25, ~0)|RD_G0|ASI(~0), "F,[1+2]", F_ALIAS, v9 }, -{ "stw", F3(3, 0x25, 0), F3(~3, ~0x25, ~0)|RD_G0|ASI_RS2(~0), "F,[1]", F_ALIAS, v9 }, /* st d,[rs1+%g0] */ -{ "stw", F3(3, 0x25, 1), F3(~3, ~0x25, ~1)|RD_G0, "F,[1+i]", F_ALIAS, v9 }, -{ "stw", F3(3, 0x25, 1), F3(~3, ~0x25, ~1)|RD_G0, "F,[i+1]", F_ALIAS, v9 }, -{ "stw", F3(3, 0x25, 1), F3(~3, ~0x25, ~1)|RD_G0|RS1_G0, "F,[i]", F_ALIAS, v9 }, -{ "stw", F3(3, 0x25, 1), F3(~3, ~0x25, ~1)|SIMM13(~0), "F,[1]", F_ALIAS, v9 }, /* st d,[rs1+0] */ - -{ "stuw", F3(3, 0x04, 0), F3(~3, ~0x04, ~0)|ASI(~0), "d,[1+2]", F_ALIAS, v9 }, /* stuw === st */ -{ "stuw", F3(3, 0x04, 0), F3(~3, ~0x04, ~0)|ASI_RS2(~0), "d,[1]", F_ALIAS, v9 }, /* st d,[rs1+%g0] */ -{ "stuw", F3(3, 0x04, 1), F3(~3, ~0x04, ~1), "d,[1+i]", F_ALIAS, v9 }, -{ "stuw", F3(3, 0x04, 1), F3(~3, ~0x04, ~1), "d,[i+1]", F_ALIAS, v9 }, -{ "stuw", F3(3, 0x04, 1), F3(~3, ~0x04, ~1)|RS1_G0, "d,[i]", F_ALIAS, v9 }, -{ "stuw", F3(3, 0x04, 1), F3(~3, ~0x04, ~1)|SIMM13(~0), "d,[1]", F_ALIAS, v9 }, /* st d,[rs1+0] */ -{ "stuw", F3(3, 0x24, 0), F3(~3, ~0x24, ~0)|ASI(~0), "g,[1+2]", F_ALIAS, v9 }, -{ "stuw", F3(3, 0x24, 0), F3(~3, ~0x24, ~0)|ASI_RS2(~0), "g,[1]", F_ALIAS, v9 }, /* st d[rs1+%g0] */ -{ "stuw", F3(3, 0x24, 1), F3(~3, ~0x24, ~1), "g,[1+i]", F_ALIAS, v9 }, -{ "stuw", F3(3, 0x24, 1), F3(~3, ~0x24, ~1), "g,[i+1]", F_ALIAS, v9 }, -{ "stuw", F3(3, 0x24, 1), F3(~3, ~0x24, ~1)|RS1_G0, "g,[i]", F_ALIAS, v9 }, -{ "stuw", F3(3, 0x24, 1), F3(~3, ~0x24, ~1)|SIMM13(~0), "g,[1]", F_ALIAS, v9 }, /* st d,[rs1+0] */ -{ "stuw", F3(3, 0x34, 0), F3(~3, ~0x34, ~0)|ASI(~0), "D,[1+2]", F_ALIAS, v9 }, -{ "stuw", F3(3, 0x34, 0), F3(~3, ~0x34, ~0)|ASI_RS2(~0), "D,[1]", F_ALIAS, v9 }, /* st d,[rs1+%g0] */ -{ "stuw", F3(3, 0x34, 1), F3(~3, ~0x34, ~1), "D,[1+i]", F_ALIAS, v9 }, -{ "stuw", F3(3, 0x34, 1), F3(~3, ~0x34, ~1), "D,[i+1]", F_ALIAS, v9 }, -{ "stuw", F3(3, 0x34, 1), F3(~3, ~0x34, ~1)|RS1_G0, "D,[i]", F_ALIAS, v9 }, -{ "stuw", F3(3, 0x34, 1), F3(~3, ~0x34, ~1)|SIMM13(~0), "D,[1]", F_ALIAS, v9 }, /* st d,[rs1+0] */ -{ "stuw", F3(3, 0x35, 0), F3(~3, ~0x35, ~0)|ASI(~0), "C,[1+2]", F_ALIAS, v9 }, -{ "stuw", F3(3, 0x35, 0), F3(~3, ~0x35, ~0)|ASI_RS2(~0), "C,[1]", F_ALIAS, v9 }, /* st d,[rs1+%g0] */ -{ "stuw", F3(3, 0x35, 1), F3(~3, ~0x35, ~1), "C,[1+i]", F_ALIAS, v9 }, -{ "stuw", F3(3, 0x35, 1), F3(~3, ~0x35, ~1), "C,[i+1]", F_ALIAS, v9 }, -{ "stuw", F3(3, 0x35, 1), F3(~3, ~0x35, ~1)|RS1_G0, "C,[i]", F_ALIAS, v9 }, -{ "stuw", F3(3, 0x35, 1), F3(~3, ~0x35, ~1)|SIMM13(~0), "C,[1]", F_ALIAS, v9 }, /* st d,[rs1+0] */ -{ "stuw", F3(3, 0x25, 0), F3(~3, ~0x25, ~0)|RD_G0|ASI(~0), "F,[1+2]", F_ALIAS, v9 }, -{ "stuw", F3(3, 0x25, 0), F3(~3, ~0x25, ~0)|RD_G0|ASI_RS2(~0), "F,[1]", F_ALIAS, v9 }, /* st d,[rs1+%g0] */ -{ "stuw", F3(3, 0x25, 1), F3(~3, ~0x25, ~1)|RD_G0, "F,[1+i]", F_ALIAS, v9 }, -{ "stuw", F3(3, 0x25, 1), F3(~3, ~0x25, ~1)|RD_G0, "F,[i+1]", F_ALIAS, v9 }, -{ "stuw", F3(3, 0x25, 1), F3(~3, ~0x25, ~1)|RD_G0|RS1_G0, "F,[i]", F_ALIAS, v9 }, -{ "stuw", F3(3, 0x25, 1), F3(~3, ~0x25, ~1)|SIMM13(~0), "F,[1]", F_ALIAS, v9 }, /* st d,[rs1+0] */ - -{ "stsw", F3(3, 0x04, 0), F3(~3, ~0x04, ~0)|ASI(~0), "d,[1+2]", F_ALIAS, v9 }, /* stsw === st */ -{ "stsw", F3(3, 0x04, 0), F3(~3, ~0x04, ~0)|ASI_RS2(~0), "d,[1]", F_ALIAS, v9 }, /* st d,[rs1+%g0] */ -{ "stsw", F3(3, 0x04, 1), F3(~3, ~0x04, ~1), "d,[1+i]", F_ALIAS, v9 }, -{ "stsw", F3(3, 0x04, 1), F3(~3, ~0x04, ~1), "d,[i+1]", F_ALIAS, v9 }, -{ "stsw", F3(3, 0x04, 1), F3(~3, ~0x04, ~1)|RS1_G0, "d,[i]", F_ALIAS, v9 }, -{ "stsw", F3(3, 0x04, 1), F3(~3, ~0x04, ~1)|SIMM13(~0), "d,[1]", F_ALIAS, v9 }, /* st d,[rs1+0] */ -{ "stsw", F3(3, 0x24, 0), F3(~3, ~0x24, ~0)|ASI(~0), "g,[1+2]", F_ALIAS, v9 }, -{ "stsw", F3(3, 0x24, 0), F3(~3, ~0x24, ~0)|ASI_RS2(~0), "g,[1]", F_ALIAS, v9 }, /* st d[rs1+%g0] */ -{ "stsw", F3(3, 0x24, 1), F3(~3, ~0x24, ~1), "g,[1+i]", F_ALIAS, v9 }, -{ "stsw", F3(3, 0x24, 1), F3(~3, ~0x24, ~1), "g,[i+1]", F_ALIAS, v9 }, -{ "stsw", F3(3, 0x24, 1), F3(~3, ~0x24, ~1)|RS1_G0, "g,[i]", F_ALIAS, v9 }, -{ "stsw", F3(3, 0x24, 1), F3(~3, ~0x24, ~1)|SIMM13(~0), "g,[1]", F_ALIAS, v9 }, /* st d,[rs1+0] */ -{ "stsw", F3(3, 0x34, 0), F3(~3, ~0x34, ~0)|ASI(~0), "D,[1+2]", F_ALIAS, v9 }, -{ "stsw", F3(3, 0x34, 0), F3(~3, ~0x34, ~0)|ASI_RS2(~0), "D,[1]", F_ALIAS, v9 }, /* st d,[rs1+%g0] */ -{ "stsw", F3(3, 0x34, 1), F3(~3, ~0x34, ~1), "D,[1+i]", F_ALIAS, v9 }, -{ "stsw", F3(3, 0x34, 1), F3(~3, ~0x34, ~1), "D,[i+1]", F_ALIAS, v9 }, -{ "stsw", F3(3, 0x34, 1), F3(~3, ~0x34, ~1)|RS1_G0, "D,[i]", F_ALIAS, v9 }, -{ "stsw", F3(3, 0x34, 1), F3(~3, ~0x34, ~1)|SIMM13(~0), "D,[1]", F_ALIAS, v9 }, /* st d,[rs1+0] */ -{ "stsw", F3(3, 0x35, 0), F3(~3, ~0x35, ~0)|ASI(~0), "C,[1+2]", F_ALIAS, v9 }, -{ "stsw", F3(3, 0x35, 0), F3(~3, ~0x35, ~0)|ASI_RS2(~0), "C,[1]", F_ALIAS, v9 }, /* st d,[rs1+%g0] */ -{ "stsw", F3(3, 0x35, 1), F3(~3, ~0x35, ~1), "C,[1+i]", F_ALIAS, v9 }, -{ "stsw", F3(3, 0x35, 1), F3(~3, ~0x35, ~1), "C,[i+1]", F_ALIAS, v9 }, -{ "stsw", F3(3, 0x35, 1), F3(~3, ~0x35, ~1)|RS1_G0, "C,[i]", F_ALIAS, v9 }, -{ "stsw", F3(3, 0x35, 1), F3(~3, ~0x35, ~1)|SIMM13(~0), "C,[1]", F_ALIAS, v9 }, /* st d,[rs1+0] */ -{ "stsw", F3(3, 0x25, 0), F3(~3, ~0x25, ~0)|RD_G0|ASI(~0), "F,[1+2]", F_ALIAS, v9 }, -{ "stsw", F3(3, 0x25, 0), F3(~3, ~0x25, ~0)|RD_G0|ASI_RS2(~0), "F,[1]", F_ALIAS, v9 }, /* st d,[rs1+%g0] */ -{ "stsw", F3(3, 0x25, 1), F3(~3, ~0x25, ~1)|RD_G0, "F,[1+i]", F_ALIAS, v9 }, -{ "stsw", F3(3, 0x25, 1), F3(~3, ~0x25, ~1)|RD_G0, "F,[i+1]", F_ALIAS, v9 }, -{ "stsw", F3(3, 0x25, 1), F3(~3, ~0x25, ~1)|RD_G0|RS1_G0, "F,[i]", F_ALIAS, v9 }, -{ "stsw", F3(3, 0x25, 1), F3(~3, ~0x25, ~1)|SIMM13(~0), "F,[1]", F_ALIAS, v9 }, /* st d,[rs1+0] */ - -{ "sta", F3(3, 0x14, 0), F3(~3, ~0x14, ~0), "d,[1+2]A", 0, v6 }, -{ "sta", F3(3, 0x14, 0), F3(~3, ~0x14, ~0)|RS2(~0), "d,[1]A", 0, v6 }, /* sta d,[rs1+%g0] */ - -{ "stwa", F3(3, 0x14, 0), F3(~3, ~0x14, ~0), "d,[1+2]A", F_ALIAS, v9 }, -{ "stwa", F3(3, 0x14, 0), F3(~3, ~0x14, ~0)|RS2(~0), "d,[1]A", F_ALIAS, v9 }, /* sta d,[rs1+%g0] */ - -{ "stswa", F3(3, 0x14, 0), F3(~3, ~0x14, ~0), "d,[1+2]A", F_ALIAS, v9 }, -{ "stswa", F3(3, 0x14, 0), F3(~3, ~0x14, ~0)|RS2(~0), "d,[1]A", F_ALIAS, v9 }, /* sta d,[rs1+%g0] */ - -{ "stuwa", F3(3, 0x14, 0), F3(~3, ~0x14, ~0), "d,[1+2]A", F_ALIAS, v9 }, -{ "stuwa", F3(3, 0x14, 0), F3(~3, ~0x14, ~0)|RS2(~0), "d,[1]A", F_ALIAS, v9 }, /* sta d,[rs1+%g0] */ - -{ "stb", F3(3, 0x05, 0), F3(~3, ~0x05, ~0)|ASI(~0), "d,[1+2]", 0, v6 }, -{ "stb", F3(3, 0x05, 0), F3(~3, ~0x05, ~0)|ASI_RS2(~0), "d,[1]", 0, v6 }, /* stb d,[rs1+%g0] */ -{ "stb", F3(3, 0x05, 1), F3(~3, ~0x05, ~1), "d,[1+i]", 0, v6 }, -{ "stb", F3(3, 0x05, 1), F3(~3, ~0x05, ~1), "d,[i+1]", 0, v6 }, -{ "stb", F3(3, 0x05, 1), F3(~3, ~0x05, ~1)|RS1_G0, "d,[i]", 0, v6 }, -{ "stb", F3(3, 0x05, 1), F3(~3, ~0x05, ~1)|SIMM13(~0), "d,[1]", 0, v6 }, /* stb d,[rs1+0] */ - -{ "stub", F3(3, 0x05, 0), F3(~3, ~0x05, ~0)|ASI(~0), "d,[1+2]", F_ALIAS, v9 }, -{ "stub", F3(3, 0x05, 0), F3(~3, ~0x05, ~0)|ASI_RS2(~0), "d,[1]", F_ALIAS, v9 }, /* stb d,[rs1+%g0] */ -{ "stub", F3(3, 0x05, 1), F3(~3, ~0x05, ~1), "d,[1+i]", F_ALIAS, v9 }, -{ "stub", F3(3, 0x05, 1), F3(~3, ~0x05, ~1), "d,[i+1]", F_ALIAS, v9 }, -{ "stub", F3(3, 0x05, 1), F3(~3, ~0x05, ~1)|RS1_G0, "d,[i]", F_ALIAS, v9 }, -{ "stub", F3(3, 0x05, 1), F3(~3, ~0x05, ~1)|SIMM13(~0), "d,[1]", F_ALIAS, v9 }, /* stb d,[rs1+0] */ - -{ "stsb", F3(3, 0x05, 0), F3(~3, ~0x05, ~0)|ASI(~0), "d,[1+2]", F_ALIAS, v9 }, -{ "stsb", F3(3, 0x05, 0), F3(~3, ~0x05, ~0)|ASI_RS2(~0), "d,[1]", F_ALIAS, v9 }, /* stb d,[rs1+%g0] */ -{ "stsb", F3(3, 0x05, 1), F3(~3, ~0x05, ~1), "d,[1+i]", F_ALIAS, v9 }, -{ "stsb", F3(3, 0x05, 1), F3(~3, ~0x05, ~1), "d,[i+1]", F_ALIAS, v9 }, -{ "stsb", F3(3, 0x05, 1), F3(~3, ~0x05, ~1)|RS1_G0, "d,[i]", F_ALIAS, v9 }, -{ "stsb", F3(3, 0x05, 1), F3(~3, ~0x05, ~1)|SIMM13(~0), "d,[1]", F_ALIAS, v9 }, /* stb d,[rs1+0] */ - -{ "stba", F3(3, 0x15, 0), F3(~3, ~0x15, ~0), "d,[1+2]A", 0, v6 }, -{ "stba", F3(3, 0x15, 0), F3(~3, ~0x15, ~0)|RS2(~0), "d,[1]A", 0, v6 }, /* stba d,[rs1+%g0] */ - -{ "stsba", F3(3, 0x15, 0), F3(~3, ~0x15, ~0), "d,[1+2]A", F_ALIAS, v9 }, -{ "stsba", F3(3, 0x15, 0), F3(~3, ~0x15, ~0)|RS2(~0), "d,[1]A", F_ALIAS, v9 }, /* stba d,[rs1+%g0] */ - -{ "stuba", F3(3, 0x15, 0), F3(~3, ~0x15, ~0), "d,[1+2]A", F_ALIAS, v9 }, -{ "stuba", F3(3, 0x15, 0), F3(~3, ~0x15, ~0)|RS2(~0), "d,[1]A", F_ALIAS, v9 }, /* stba d,[rs1+%g0] */ - -{ "std", F3(3, 0x07, 0), F3(~3, ~0x07, ~0)|ASI(~0), "d,[1+2]", 0, v6 }, -{ "std", F3(3, 0x07, 0), F3(~3, ~0x07, ~0)|ASI_RS2(~0), "d,[1]", 0, v6 }, /* std d,[rs1+%g0] */ -{ "std", F3(3, 0x07, 1), F3(~3, ~0x07, ~1), "d,[1+i]", 0, v6 }, -{ "std", F3(3, 0x07, 1), F3(~3, ~0x07, ~1), "d,[i+1]", 0, v6 }, -{ "std", F3(3, 0x07, 1), F3(~3, ~0x07, ~1)|RS1_G0, "d,[i]", 0, v6 }, -{ "std", F3(3, 0x07, 1), F3(~3, ~0x07, ~1)|SIMM13(~0), "d,[1]", 0, v6 }, /* std d,[rs1+0] */ -{ "std", F3(3, 0x26, 0), F3(~3, ~0x26, ~0)|ASI(~0), "q,[1+2]", 0, v6 }, -{ "std", F3(3, 0x26, 0), F3(~3, ~0x26, ~0)|ASI_RS2(~0), "q,[1]", 0, v6 }, /* std d,[rs1+%g0] */ -{ "std", F3(3, 0x26, 1), F3(~3, ~0x26, ~1), "q,[1+i]", 0, v6 }, -{ "std", F3(3, 0x26, 1), F3(~3, ~0x26, ~1), "q,[i+1]", 0, v6 }, -{ "std", F3(3, 0x26, 1), F3(~3, ~0x26, ~1)|RS1_G0, "q,[i]", 0, v6 }, -{ "std", F3(3, 0x26, 1), F3(~3, ~0x26, ~1)|SIMM13(~0), "q,[1]", 0, v6 }, /* std d,[rs1+0] */ -{ "std", F3(3, 0x27, 0), F3(~3, ~0x27, ~0)|ASI(~0), "g,[1+2]", 0, v6 }, -{ "std", F3(3, 0x27, 0), F3(~3, ~0x27, ~0)|ASI_RS2(~0), "g,[1]", 0, v6 }, /* std d,[rs1+%g0] */ -{ "std", F3(3, 0x27, 1), F3(~3, ~0x27, ~1), "g,[1+i]", 0, v6 }, -{ "std", F3(3, 0x27, 1), F3(~3, ~0x27, ~1), "g,[i+1]", 0, v6 }, -{ "std", F3(3, 0x27, 1), F3(~3, ~0x27, ~1)|RS1_G0, "g,[i]", 0, v6 }, -{ "std", F3(3, 0x27, 1), F3(~3, ~0x27, ~1)|SIMM13(~0), "g,[1]", 0, v6 }, /* std d,[rs1+0] */ -{ "std", F3(3, 0x36, 0), F3(~3, ~0x36, ~0)|ASI(~0), "Q,[1+2]", 0, v6 }, -{ "std", F3(3, 0x36, 0), F3(~3, ~0x36, ~0)|ASI_RS2(~0), "Q,[1]", 0, v6 }, /* std d,[rs1+%g0] */ -{ "std", F3(3, 0x36, 1), F3(~3, ~0x36, ~1), "Q,[1+i]", 0, v6 }, -{ "std", F3(3, 0x36, 1), F3(~3, ~0x36, ~1), "Q,[i+1]", 0, v6 }, -{ "std", F3(3, 0x36, 1), F3(~3, ~0x36, ~1)|RS1_G0, "Q,[i]", 0, v6 }, -{ "std", F3(3, 0x36, 1), F3(~3, ~0x36, ~1)|SIMM13(~0), "Q,[1]", 0, v6 }, /* std d,[rs1+0] */ -{ "std", F3(3, 0x37, 0), F3(~3, ~0x37, ~0)|ASI(~0), "D,[1+2]", 0, v6 }, -{ "std", F3(3, 0x37, 0), F3(~3, ~0x37, ~0)|ASI_RS2(~0), "D,[1]", 0, v6 }, /* std d,[rs1+%g0] */ -{ "std", F3(3, 0x37, 1), F3(~3, ~0x37, ~1), "D,[1+i]", 0, v6 }, -{ "std", F3(3, 0x37, 1), F3(~3, ~0x37, ~1), "D,[i+1]", 0, v6 }, -{ "std", F3(3, 0x37, 1), F3(~3, ~0x37, ~1)|RS1_G0, "D,[i]", 0, v6 }, -{ "std", F3(3, 0x37, 1), F3(~3, ~0x37, ~1)|SIMM13(~0), "D,[1]", 0, v6 }, /* std d,[rs1+0] */ - -{ "stda", F3(3, 0x17, 0), F3(~3, ~0x17, ~0), "d,[1+2]A", 0, v6 }, -{ "stda", F3(3, 0x17, 0), F3(~3, ~0x17, ~0)|RS2(~0), "d,[1]A", 0, v6 }, /* stda d,[rs1+%g0] */ - -{ "sth", F3(3, 0x06, 0), F3(~3, ~0x06, ~0)|ASI(~0), "d,[1+2]", 0, v6 }, -{ "sth", F3(3, 0x06, 0), F3(~3, ~0x06, ~0)|ASI_RS2(~0), "d,[1]", 0, v6 }, /* sth d,[rs1+%g0] */ -{ "sth", F3(3, 0x06, 1), F3(~3, ~0x06, ~1), "d,[1+i]", 0, v6 }, -{ "sth", F3(3, 0x06, 1), F3(~3, ~0x06, ~1), "d,[i+1]", 0, v6 }, -{ "sth", F3(3, 0x06, 1), F3(~3, ~0x06, ~1)|RS1_G0, "d,[i]", 0, v6 }, -{ "sth", F3(3, 0x06, 1), F3(~3, ~0x06, ~1)|SIMM13(~0), "d,[1]", 0, v6 }, /* sth d,[+] */ - -{ "stsh", F3(3, 0x06, 0), F3(~3, ~0x06, ~0)|ASI(~0), "d,[1+2]", F_ALIAS, v9 }, -{ "stsh", F3(3, 0x06, 0), F3(~3, ~0x06, ~0)|ASI_RS2(~0), "d,[1]", F_ALIAS, v9 }, /* sth d,[rs1+%g0] */ -{ "stsh", F3(3, 0x06, 1), F3(~3, ~0x06, ~1), "d,[1+i]", F_ALIAS, v9 }, -{ "stsh", F3(3, 0x06, 1), F3(~3, ~0x06, ~1), "d,[i+1]", F_ALIAS, v9 }, -{ "stsh", F3(3, 0x06, 1), F3(~3, ~0x06, ~1)|RS1_G0, "d,[i]", F_ALIAS, v9 }, -{ "stsh", F3(3, 0x06, 1), F3(~3, ~0x06, ~1)|SIMM13(~0), "d,[1]", F_ALIAS, v9 }, /* sth d,[rs1+0] */ - -{ "stuh", F3(3, 0x06, 0), F3(~3, ~0x06, ~0)|ASI(~0), "d,[1+2]", F_ALIAS, v9 }, -{ "stuh", F3(3, 0x06, 0), F3(~3, ~0x06, ~0)|ASI_RS2(~0), "d,[1]", F_ALIAS, v9 }, /* sth d,[rs1+%g0] */ -{ "stuh", F3(3, 0x06, 1), F3(~3, ~0x06, ~1), "d,[1+i]", F_ALIAS, v9 }, -{ "stuh", F3(3, 0x06, 1), F3(~3, ~0x06, ~1), "d,[i+1]", F_ALIAS, v9 }, -{ "stuh", F3(3, 0x06, 1), F3(~3, ~0x06, ~1)|RS1_G0, "d,[i]", F_ALIAS, v9 }, -{ "stuh", F3(3, 0x06, 1), F3(~3, ~0x06, ~1)|SIMM13(~0), "d,[1]", F_ALIAS, v9 }, /* sth d,[rs1+0] */ - -{ "stha", F3(3, 0x16, 0), F3(~3, ~0x16, ~0), "d,[1+2]A", 0, v6 }, -{ "stha", F3(3, 0x16, 0), F3(~3, ~0x16, ~0)|RS2(~0), "d,[1]A", 0, v6 }, /* stha ,[+%] */ - -{ "stsha", F3(3, 0x16, 0), F3(~3, ~0x16, ~0), "d,[1+2]A", F_ALIAS, v9 }, -{ "stsha", F3(3, 0x16, 0), F3(~3, ~0x16, ~0)|RS2(~0), "d,[1]A", F_ALIAS, v9 }, /* stha d,[rs1+%g0] */ - -{ "stuha", F3(3, 0x16, 0), F3(~3, ~0x16, ~0), "d,[1+2]A", F_ALIAS, v9 }, -{ "stuha", F3(3, 0x16, 0), F3(~3, ~0x16, ~0)|RS2(~0), "d,[1]A", F_ALIAS, v9 }, /* stha d,[rs1+%g0] */ - -{ "stx", F3(3, 0x0e, 0), F3(~3, ~0x0e, ~0)|ASI(~0), "d,[1+2]", 0, v9 }, -{ "stx", F3(3, 0x0e, 0), F3(~3, ~0x0e, ~0)|ASI_RS2(~0), "d,[1]", 0, v9 }, /* stx d,[rs1+%g0] */ -{ "stx", F3(3, 0x0e, 1), F3(~3, ~0x0e, ~1), "d,[1+i]", 0, v9 }, -{ "stx", F3(3, 0x0e, 1), F3(~3, ~0x0e, ~1), "d,[i+1]", 0, v9 }, -{ "stx", F3(3, 0x0e, 1), F3(~3, ~0x0e, ~1)|RS1_G0, "d,[i]", 0, v9 }, -{ "stx", F3(3, 0x0e, 1), F3(~3, ~0x0e, ~1)|SIMM13(~0), "d,[1]", 0, v9 }, /* stx d,[rs1+0] */ -{ "stx", F3(3, 0x2d, 0), F3(~3, ~0x2d, ~0)|RD_G0|ASI(~0), "F,[1+2]", F_ALIAS, v9 }, -{ "stx", F3(3, 0x2d, 0), F3(~3, ~0x2d, ~0)|RD_G0|ASI_RS2(~0), "F,[1]", F_ALIAS, v9 }, /* st d,[rs1+%g0] */ -{ "stx", F3(3, 0x2d, 1), F3(~3, ~0x2d, ~1)|RD_G0, "F,[1+i]", F_ALIAS, v9 }, -{ "stx", F3(3, 0x2d, 1), F3(~3, ~0x2d, ~1)|RD_G0, "F,[i+1]", F_ALIAS, v9 }, -{ "stx", F3(3, 0x2d, 1), F3(~3, ~0x2d, ~1)|RD_G0|RS1_G0, "F,[i]", F_ALIAS, v9 }, -{ "stx", F3(3, 0x2d, 1), F3(~3, ~0x2d, ~1)|SIMM13(~0), "F,[1]", F_ALIAS, v9 }, /* st d,[rs1+0] */ - -{ "stxa", F3(3, 0x1e, 0), F3(~3, ~0x1e, ~0), "d,[1+2]A", 0, v9 }, -{ "stxa", F3(3, 0x1e, 0), F3(~3, ~0x1e, ~0)|RS2(~0), "d,[1]A", 0, v9 }, /* stha d,[rs1+%g0] */ - -{ "swap", F3(3, 0x0f, 0), F3(~3, ~0x0f, ~0)|ASI(~0), "[1+2],d", 0, v7 }, -{ "swap", F3(3, 0x0f, 0), F3(~3, ~0x0f, ~0)|ASI_RS2(~0), "[1],d", 0, v7 }, /* swap [rs1+%g0],d */ -{ "swap", F3(3, 0x0f, 1), F3(~3, ~0x0f, ~1), "[1+i],d", 0, v7 }, -{ "swap", F3(3, 0x0f, 1), F3(~3, ~0x0f, ~1), "[i+1],d", 0, v7 }, -{ "swap", F3(3, 0x0f, 1), F3(~3, ~0x0f, ~1)|RS1_G0, "[i],d", 0, v7 }, -{ "swap", F3(3, 0x0f, 1), F3(~3, ~0x0f, ~1)|SIMM13(~0), "[1],d", 0, v7 }, /* swap [rs1+0],d */ - -{ "swapa", F3(3, 0x1f, 0), F3(~3, ~0x1f, ~0), "[1+2]A,d", 0, v7 }, -{ "swapa", F3(3, 0x1f, 0), F3(~3, ~0x1f, ~0)|RS2(~0), "[1]A,d", 0, v7 }, /* swapa [rs1+%g0],d */ - -{ "restore", F3(2, 0x3d, 0), F3(~2, ~0x3d, ~0)|ASI(~0), "1,2,d", 0, v6 }, -{ "restore", F3(2, 0x3d, 0), F3(~2, ~0x3d, ~0)|RD_G0|RS1_G0|ASI_RS2(~0), "", 0, v6 }, /* restore %g0,%g0,%g0 */ -{ "restore", F3(2, 0x3d, 1), F3(~2, ~0x3d, ~1), "1,i,d", 0, v6 }, -{ "restore", F3(2, 0x3d, 1), F3(~2, ~0x3d, ~1)|RD_G0|RS1_G0|SIMM13(~0), "", 0, v6 }, /* restore %g0,0,%g0 */ - -{ "rett", F3(2, 0x39, 0), F3(~2, ~0x39, ~0)|RD_G0|ASI(~0), "1+2", F_DELAYED, v6 }, /* rett rs1+rs2 */ -{ "rett", F3(2, 0x39, 0), F3(~2, ~0x39, ~0)|RD_G0|ASI_RS2(~0), "1", F_DELAYED, v6 }, /* rett rs1,%g0 */ -{ "rett", F3(2, 0x39, 1), F3(~2, ~0x39, ~1)|RD_G0, "1+i", F_DELAYED, v6 }, /* rett rs1+X */ -{ "rett", F3(2, 0x39, 1), F3(~2, ~0x39, ~1)|RD_G0, "i+1", F_DELAYED, v6 }, /* rett X+rs1 */ -{ "rett", F3(2, 0x39, 1), F3(~2, ~0x39, ~1)|RD_G0|RS1_G0,"i", F_DELAYED, v6 }, /* rett X+rs1 */ -{ "rett", F3(2, 0x39, 1), F3(~2, ~0x39, ~1)|RD_G0|RS1_G0, "i", F_DELAYED, v6 }, /* rett X */ -{ "rett", F3(2, 0x39, 1), F3(~2, ~0x39, ~1)|RD_G0|SIMM13(~0), "1", F_DELAYED, v6 }, /* rett rs1+0 */ - -{ "save", F3(2, 0x3c, 0), F3(~2, ~0x3c, ~0)|ASI(~0), "1,2,d", 0, v6 }, -{ "save", F3(2, 0x3c, 1), F3(~2, ~0x3c, ~1), "1,i,d", 0, v6 }, - -{ "ret", F3(2, 0x38, 1)|RS1(0x1f)|SIMM13(8), F3(~2, ~0x38, ~1)|SIMM13(~8), "", F_DELAYED, v6 }, /* jmpl %i7+8,%g0 */ -{ "retl", F3(2, 0x38, 1)|RS1(0x0f)|SIMM13(8), F3(~2, ~0x38, ~1)|RS1(~0x0f)|SIMM13(~8), "", F_DELAYED, v6 }, /* jmpl %o7+8,%g0 */ - -{ "jmpl", F3(2, 0x38, 0), F3(~2, ~0x38, ~0)|ASI(~0), "1+2,d", F_DELAYED, v6 }, -{ "jmpl", F3(2, 0x38, 0), F3(~2, ~0x38, ~0)|ASI_RS2(~0), "1,d", F_DELAYED, v6 }, /* jmpl rs1+%g0,d */ -{ "jmpl", F3(2, 0x38, 1), F3(~2, ~0x38, ~1)|SIMM13(~0), "1,d", F_DELAYED, v6 }, /* jmpl rs1+0,d */ -{ "jmpl", F3(2, 0x38, 1), F3(~2, ~0x38, ~1)|RS1_G0, "i,d", F_DELAYED, v6 }, /* jmpl %g0+i,d */ -{ "jmpl", F3(2, 0x38, 1), F3(~2, ~0x38, ~1), "1+i,d", F_DELAYED, v6 }, -{ "jmpl", F3(2, 0x38, 1), F3(~2, ~0x38, ~1), "i+1,d", F_DELAYED, v6 }, -{ "jmpl", F3(2, 0x38, 1), F3(~2, ~0x38, ~1)|RS1_G0, "i,d", F_DELAYED, v6 }, - - /* The 1<<12 is a long story. It is necessary. For more info, please contact rich@cygnus.com */ -{ "sll", F3(2, 0x25, 0), F3(~2, ~0x25, ~0)|(1<<12)|ASI(~0), "1,2,d", 0, v6 }, -{ "sll", F3(2, 0x25, 1), F3(~2, ~0x25, ~1)|(1<<12), "1,i,d", 0, v6 }, -{ "sra", F3(2, 0x27, 0), F3(~2, ~0x27, ~0)|(1<<12)|ASI(~0), "1,2,d", 0, v6 }, -{ "sra", F3(2, 0x27, 1), F3(~2, ~0x27, ~1)|(1<<12), "1,i,d", 0, v6 }, -{ "srl", F3(2, 0x26, 0), F3(~2, ~0x26, ~0)|(1<<12)|ASI(~0), "1,2,d", 0, v6 }, -{ "srl", F3(2, 0x26, 1), F3(~2, ~0x26, ~1)|(1<<12), "1,i,d", 0, v6 }, - -{ "sllw", F3(2, 0x25, 0), F3(~2, ~0x25, ~0)|(1<<12)|ASI(~0), "1,2,d", F_ALIAS, v9 }, /* sllw === sll */ -{ "sllw", F3(2, 0x25, 1), F3(~2, ~0x25, ~1)|(1<<12), "1,i,d", F_ALIAS, v9 }, -{ "sraw", F3(2, 0x27, 0), F3(~2, ~0x27, ~0)|(1<<12)|ASI(~0), "1,2,d", F_ALIAS, v9 }, /* sraw === sra */ -{ "sraw", F3(2, 0x27, 1), F3(~2, ~0x27, ~1)|(1<<12), "1,i,d", F_ALIAS, v9 }, -{ "srlw", F3(2, 0x26, 0), F3(~2, ~0x26, ~0)|(1<<12)|ASI(~0), "1,2,d", F_ALIAS, v9 }, /* srlw === srl */ -{ "srlw", F3(2, 0x26, 1), F3(~2, ~0x26, ~1)|(1<<12), "1,i,d", F_ALIAS, v9 }, - -{ "sllx", F3(2, 0x25, 0)|(1<<12), F3(~2, ~0x25, ~0)|(ASI(~0)^(1<<12)), "1,2,d", 0, v9 }, -{ "sllx", F3(2, 0x25, 1)|(1<<12), F3(~2, ~0x25, ~1), "1,i,d", 0, v9 }, -{ "srax", F3(2, 0x27, 0)|(1<<12), F3(~2, ~0x27, ~0)|(ASI(~0)^(1<<12)), "1,2,d", 0, v9 }, -{ "srax", F3(2, 0x27, 1)|(1<<12), F3(~2, ~0x27, ~1), "1,i,d", 0, v9 }, -{ "srlx", F3(2, 0x26, 0)|(1<<12), F3(~2, ~0x26, ~0)|(ASI(~0)^(1<<12)), "1,2,d", 0, v9 }, -{ "srlx", F3(2, 0x26, 1)|(1<<12), F3(~2, ~0x26, ~1), "1,i,d", 0, v9 }, - -{ "mulscc", F3(2, 0x24, 0), F3(~2, ~0x24, ~0)|ASI(~0), "1,2,d", 0, v6 }, -{ "mulscc", F3(2, 0x24, 1), F3(~2, ~0x24, ~1), "1,i,d", 0, v6 }, - -{ "clr", F3(2, 0x02, 0), F3(~2, ~0x02, ~0)|RD_G0|RS1_G0|ASI_RS2(~0), "d", F_ALIAS, v6 }, /* or %g0,%g0,d */ -{ "clr", F3(2, 0x02, 1), F3(~2, ~0x02, ~1)|RS1_G0|SIMM13(~0), "d", F_ALIAS, v6 }, /* or %g0,0,d */ -{ "clr", F3(3, 0x04, 0), F3(~3, ~0x04, ~0)|RD_G0|ASI(~0), "[1+2]", F_ALIAS, v6 }, -{ "clr", F3(3, 0x04, 0), F3(~3, ~0x04, ~0)|RD_G0|ASI_RS2(~0), "[1]", F_ALIAS, v6 }, /* st %g0,[rs1+%g0] */ -{ "clr", F3(3, 0x04, 1), F3(~3, ~0x04, ~1)|RD_G0, "[1+i]", F_ALIAS, v6 }, -{ "clr", F3(3, 0x04, 1), F3(~3, ~0x04, ~1)|RD_G0, "[i+1]", F_ALIAS, v6 }, -{ "clr", F3(3, 0x04, 1), F3(~3, ~0x04, ~1)|RD_G0|RS1_G0, "[i]", F_ALIAS, v6 }, -{ "clr", F3(3, 0x04, 1), F3(~3, ~0x04, ~1)|RD_G0|SIMM13(~0), "[1]", F_ALIAS, v6 }, /* st %g0,[rs1+0] */ - -{ "clrb", F3(3, 0x05, 0), F3(~3, ~0x05, ~0)|RD_G0|ASI(~0), "[1+2]", F_ALIAS, v6 }, -{ "clrb", F3(3, 0x05, 0), F3(~3, ~0x05, ~0)|RD_G0|ASI_RS2(~0), "[1]", F_ALIAS, v6 }, /* stb %g0,[rs1+%g0] */ -{ "clrb", F3(3, 0x05, 1), F3(~3, ~0x05, ~1)|RD_G0, "[1+i]", F_ALIAS, v6 }, -{ "clrb", F3(3, 0x05, 1), F3(~3, ~0x05, ~1)|RD_G0, "[i+1]", F_ALIAS, v6 }, -{ "clrb", F3(3, 0x05, 1), F3(~3, ~0x05, ~1)|RD_G0|RS1_G0, "[i]", F_ALIAS, v6 }, - -{ "clrh", F3(3, 0x06, 0), F3(~3, ~0x06, ~0)|RD_G0|ASI(~0), "[1+2]", F_ALIAS, v6 }, -{ "clrh", F3(3, 0x06, 0), F3(~3, ~0x06, ~0)|RD_G0|ASI_RS2(~0), "[1]", F_ALIAS, v6 }, /* sth %g0,[rs1+%g0] */ -{ "clrh", F3(3, 0x06, 1), F3(~3, ~0x06, ~1)|RD_G0, "[1+i]", F_ALIAS, v6 }, -{ "clrh", F3(3, 0x06, 1), F3(~3, ~0x06, ~1)|RD_G0, "[i+1]", F_ALIAS, v6 }, -{ "clrh", F3(3, 0x06, 1), F3(~3, ~0x06, ~1)|RD_G0|RS1_G0, "[i]", F_ALIAS, v6 }, - -{ "orcc", F3(2, 0x12, 0), F3(~2, ~0x12, ~0)|ASI(~0), "1,2,d", 0, v6 }, -{ "orcc", F3(2, 0x12, 1), F3(~2, ~0x12, ~1), "1,i,d", 0, v6 }, -{ "orcc", F3(2, 0x12, 1), F3(~2, ~0x12, ~1), "i,1,d", 0, v6 }, - -{ "orncc", F3(2, 0x16, 0), F3(~2, ~0x16, ~0)|ASI(~0), "1,2,d", 0, v6 }, -{ "orncc", F3(2, 0x16, 1), F3(~2, ~0x16, ~1), "1,i,d", 0, v6 }, -{ "orncc", F3(2, 0x16, 1), F3(~2, ~0x16, ~1), "i,1,d", 0, v6 }, - -{ "orn", F3(2, 0x06, 0), F3(~2, ~0x06, ~0)|ASI(~0), "1,2,d", 0, v6 }, -{ "orn", F3(2, 0x06, 1), F3(~2, ~0x06, ~1), "1,i,d", 0, v6 }, -{ "orn", F3(2, 0x06, 1), F3(~2, ~0x06, ~1), "i,1,d", 0, v6 }, - -{ "tst", F3(2, 0x12, 0), F3(~2, ~0x12, ~0)|RD_G0|ASI_RS2(~0), "1", 0, v6 }, /* orcc rs1, %g0, %g0 */ -{ "tst", F3(2, 0x12, 0), F3(~2, ~0x12, ~0)|RD_G0|RS1_G0|ASI(~0), "2", 0, v6 }, /* orcc %g0, rs2, %g0 */ -{ "tst", F3(2, 0x12, 1), F3(~2, ~0x12, ~1)|RD_G0|SIMM13(~0), "1", 0, v6 }, /* orcc rs1, 0, %g0 */ - -{ "wr", F3(2, 0x30, 0), F3(~2, ~0x30, ~0)|ASI(~0), "1,2,m", 0, v8 }, /* wr r,r,%asrX */ -{ "wr", F3(2, 0x30, 0), F3(~2, ~0x30, ~0)|RD_G0|ASI(~0), "1,2,y", 0, v6 }, /* wr r,r,%y */ -{ "wr", F3(2, 0x30, 1), F3(~2, ~0x30, ~1), "1,i,m", 0, v8 }, /* wr r,i,%asrX */ -{ "wr", F3(2, 0x30, 1), F3(~2, ~0x30, ~1)|RD_G0, "1,i,y", 0, v6 }, /* wr r,i,%y */ -{ "wr", F3(2, 0x31, 0), F3(~2, ~0x31, ~0)|RD_G0|ASI(~0), "1,2,p", 0, v6 }, /* wr r,r,%psr */ -{ "wr", F3(2, 0x31, 1), F3(~2, ~0x31, ~1)|RD_G0, "1,i,p", 0, v6 }, /* wr r,i,%psr */ -{ "wr", F3(2, 0x32, 0), F3(~2, ~0x32, ~0)|RD_G0|ASI(~0), "1,2,w", 0, v6 }, /* wr r,r,%wim */ -{ "wr", F3(2, 0x32, 1), F3(~2, ~0x32, ~1)|RD_G0, "1,i,w", 0, v6 }, /* wr r,i,%wim */ -{ "wr", F3(2, 0x33, 0), F3(~2, ~0x33, ~0)|RD_G0|ASI(~0), "1,2,t", 0, v6 }, /* wr r,r,%tbr */ -{ "wr", F3(2, 0x33, 1), F3(~2, ~0x33, ~1)|RD_G0, "1,i,t", 0, v6 }, /* wr r,i,%tbr */ - -{ "wr", F3(2, 0x30, 0)|RD(0), F3(~2, ~0x30, ~0)|RD(~0)|ASI(~0), "1,2,y", 0, v9 }, -{ "wr", F3(2, 0x30, 1)|RD(0), F3(~2, ~0x30, ~1)|RD(~0), "1,i,y", 0, v9 }, -{ "wr", F3(2, 0x30, 0)|RD(1), F3(~2, ~0x30, ~0)|RD(~1)|ASI(~0), "1,2,E", 0, v9 }, -{ "wr", F3(2, 0x30, 1)|RD(1), F3(~2, ~0x30, ~1)|RD(~1), "1,i,E", 0, v9 }, -{ "wr", F3(2, 0x30, 0)|RD(3), F3(~2, ~0x30, ~0)|RD(~3)|ASI(~0), "1,2,W", 0, v9 }, -{ "wr", F3(2, 0x30, 1)|RD(3), F3(~2, ~0x30, ~1)|RD(~3), "1,i,W", 0, v9 }, -{ "wr", F3(2, 0x30, 0)|RD(4), F3(~2, ~0x30, ~0)|RD(~4)|ASI(~0), "1,2,p", 0, v9 }, -{ "wr", F3(2, 0x30, 1)|RD(4), F3(~2, ~0x30, ~1)|RD(~4), "1,i,p", 0, v9 }, -{ "wr", F3(2, 0x30, 0)|RD(5), F3(~2, ~0x30, ~0)|RD(~5)|ASI(~0), "1,2,w", 0, v9 }, -{ "wr", F3(2, 0x30, 1)|RD(5), F3(~2, ~0x30, ~1)|RD(~5), "1,i,w", 0, v9 }, - -{ "rd", F3(2, 0x28, 0), F3(~2, ~0x28, ~0)|SIMM13(~0), "M,d", 0, v8 }, /* rd %asr1,r */ -{ "rd", F3(2, 0x28, 0), F3(~2, ~0x28, ~0)|RS1_G0|SIMM13(~0), "y,d", 0, v6 }, /* rd %y,r */ -{ "rd", F3(2, 0x28, 0)|RS1(1), F3(~2, ~0x28, ~0)|RS1(~1)|SIMM13(~0), "E,d", 0, v9 }, /* rd %modes,r */ -{ "rd", F3(2, 0x28, 0)|RS1(2), F3(~2, ~0x28, ~0)|RS1(~2)|SIMM13(~0), "P,d", 0, v9 }, /* rd %pc,r */ -{ "rd", F3(2, 0x28, 0)|RS1(3), F3(~2, ~0x28, ~0)|RS1(~3)|SIMM13(~0), "W,d", 0, v9 }, /* rd %tick,r */ -{ "rd", F3(2, 0x28, 0)|RS1(4), F3(~2, ~0x28, ~0)|RS1(~4)|SIMM13(~0), "p,d", 0, v9 }, /* rd %psr,r */ -{ "rd", F3(2, 0x28, 0)|RS1(5), F3(~2, ~0x28, ~0)|RS1(~5)|SIMM13(~0), "w,d", 0, v9 }, /* rd %wim,r */ -{ "rd", F3(2, 0x2b, 0), F3(~2, ~0x2b, ~0)|RS1_G0|SIMM13(~0), "t,d", 0, v6 }, /* rd %tbr,r */ - - /* FIXME-now: the v9 (ie, delta 2.02) definitions of these conflict with the older ones. These are the older ones. */ -{ "rd", F3(2, 0x29, 0), F3(~2, ~0x29, ~0)|RS1_G0|SIMM13(~0), "p,d", 0, v6 }, /* rd %psr,r */ -{ "rd", F3(2, 0x2a, 0), F3(~2, ~0x2a, ~0)|RS1_G0|SIMM13(~0), "w,d", 0, v6 }, /* rd %wim,r */ - -{ "mov", F3(2, 0x30, 0), F3(~2, ~0x30, ~0)|ASI(~0), "1,2,m", F_ALIAS, v8 }, /* wr r,r,%asrX */ -{ "mov", F3(2, 0x30, 0), F3(~2, ~0x30, ~0)|RD_G0|ASI(~0), "1,2,y", F_ALIAS, v6 }, /* wr r,r,%y */ -{ "mov", F3(2, 0x30, 0)|RD(0xe), F3(~2, ~0x30, ~0)|RD(~0xe)|ASI(~0), "1,2,Y", F_ALIAS, v9 }, /* wr r,r,%amr */ -{ "mov", F3(2, 0x30, 1), F3(~2, ~0x30, ~1), "1,i,m", F_ALIAS, v8 }, /* wr r,i,%asrX */ -{ "mov", F3(2, 0x30, 1), F3(~2, ~0x30, ~1)|RD_G0, "1,i,y", F_ALIAS, v6 }, /* wr r,i,%y */ -{ "mov", F3(2, 0x30, 1)|RD(0xe), F3(~2, ~0x30, ~1)|RD(~0xe), "1,i,Y", F_ALIAS, v9 }, /* wr r,i,%amr */ -{ "mov", F3(2, 0x31, 0), F3(~2, ~0x31, ~0)|RD_G0|ASI(~0), "1,2,p", F_ALIAS, v6 }, /* wr r,r,%psr */ -{ "mov", F3(2, 0x31, 1), F3(~2, ~0x31, ~1)|RD_G0, "1,i,p", F_ALIAS, v6 }, /* wr r,i,%psr */ -{ "mov", F3(2, 0x32, 0), F3(~2, ~0x32, ~0)|RD_G0|ASI(~0), "1,2,w", F_ALIAS, v6 }, /* wr r,r,%wim */ -{ "mov", F3(2, 0x32, 1), F3(~2, ~0x32, ~1)|RD_G0, "1,i,w", F_ALIAS, v6 }, /* wr r,i,%wim */ -{ "mov", F3(2, 0x33, 0), F3(~2, ~0x33, ~0)|RD_G0|ASI(~0), "1,2,t", F_ALIAS, v6 }, /* wr r,r,%tbr */ -{ "mov", F3(2, 0x33, 1), F3(~2, ~0x33, ~1)|RD_G0, "1,i,t", F_ALIAS, v6 }, /* wr r,i,%tbr */ - -{ "mov", F3(2, 0x28, 0), F3(~2, ~0x28, ~0)|SIMM13(~0), "M,d", F_ALIAS, v8 }, /* rd %asr1,r */ -{ "mov", F3(2, 0x28, 0), F3(~2, ~0x28, ~0)|RS1_G0|SIMM13(~0), "y,d", F_ALIAS, v6 }, /* rd %y,r */ -{ "mov", F3(2, 0x28, 0)|RS1(0xe), F3(~2, ~0x28, ~0)|RS1(~0xe)|SIMM13(~0), "Y,d", F_ALIAS, v9 }, /* rd %amr,r */ -{ "mov", F3(2, 0x29, 0), F3(~2, ~0x29, ~0)|RS1_G0|SIMM13(~0), "p,d", F_ALIAS, v6 }, /* rd %psr,r */ -{ "mov", F3(2, 0x2a, 0), F3(~2, ~0x2a, ~0)|RS1_G0|SIMM13(~0), "w,d", F_ALIAS, v6 }, /* rd %wim,r */ -{ "mov", F3(2, 0x2b, 0), F3(~2, ~0x2b, ~0)|RS1_G0|SIMM13(~0), "t,d", F_ALIAS, v6 }, /* rd %tbr,r */ - -{ "mov", F3(2, 0x30, 0), F3(~2, ~0x30, ~0)|ASI_RS2(~0), "1,y", F_ALIAS, v6 }, /* wr rs1,%g0,%y */ -{ "mov", F3(2, 0x30, 1), F3(~2, ~0x30, ~1), "i,y", F_ALIAS, v6 }, -{ "mov", F3(2, 0x30, 1), F3(~2, ~0x30, ~1)|SIMM13(~0), "1,y", F_ALIAS, v6 }, /* wr rs1,0,%y */ -{ "mov", F3(2, 0x31, 0), F3(~2, ~0x31, ~0)|ASI_RS2(~0), "1,p", F_ALIAS, v6 }, /* wr rs1,%g0,%psr */ -{ "mov", F3(2, 0x31, 1), F3(~2, ~0x31, ~1), "i,p", F_ALIAS, v6 }, -{ "mov", F3(2, 0x31, 1), F3(~2, ~0x31, ~1)|SIMM13(~0), "1,p", F_ALIAS, v6 }, /* wr rs1,0,%psr */ -{ "mov", F3(2, 0x32, 0), F3(~2, ~0x32, ~0)|ASI_RS2(~0), "1,w", F_ALIAS, v6 }, /* wr rs1,%g0,%wim */ -{ "mov", F3(2, 0x32, 1), F3(~2, ~0x32, ~1), "i,w", F_ALIAS, v6 }, -{ "mov", F3(2, 0x32, 1), F3(~2, ~0x32, ~1)|SIMM13(~0), "1,w", F_ALIAS, v6 }, /* wr rs1,0,%wim */ -{ "mov", F3(2, 0x33, 0), F3(~2, ~0x33, ~0)|ASI_RS2(~0), "1,t", F_ALIAS, v6 }, /* wr rs1,%g0,%tbr */ -{ "mov", F3(2, 0x33, 1), F3(~2, ~0x33, ~1), "i,t", F_ALIAS, v6 }, -{ "mov", F3(2, 0x33, 1), F3(~2, ~0x33, ~1)|SIMM13(~0), "1,t", F_ALIAS, v6 }, /* wr rs1,0,%tbr */ - -{ "mov", F3(2, 0x02, 0), F3(~2, ~0x02, ~0)|RS1_G0|ASI(~0), "2,d", 0, v6 }, /* or %g0,rs2,d */ -{ "mov", F3(2, 0x02, 1), F3(~2, ~0x02, ~1)|RS1_G0, "i,d", 0, v6 }, /* or %g0,i,d */ -{ "mov", F3(2, 0x02, 0), F3(~2, ~0x02, ~0)|ASI_RS2(~0), "1,d", 0, v6 }, /* or rs1,%g0,d */ -{ "mov", F3(2, 0x02, 1), F3(~2, ~0x02, ~1)|SIMM13(~0), "1,d", 0, v6 }, /* or rs1,0,d */ - -{ "or", F3(2, 0x02, 0), F3(~2, ~0x02, ~0)|ASI(~0), "1,2,d", 0, v6 }, -{ "or", F3(2, 0x02, 1), F3(~2, ~0x02, ~1), "1,i,d", 0, v6 }, -{ "or", F3(2, 0x02, 1), F3(~2, ~0x02, ~1), "i,1,d", 0, v6 }, - -{ "bset", F3(2, 0x02, 0), F3(~2, ~0x02, ~0)|ASI(~0), "2,r", F_ALIAS, v6 }, /* or rd,rs2,rd */ -{ "bset", F3(2, 0x02, 1), F3(~2, ~0x02, ~1), "i,r", F_ALIAS, v6 }, /* or rd,i,rd */ - -{ "andn", F3(2, 0x05, 0), F3(~2, ~0x05, ~0)|ASI(~0), "1,2,d", 0, v6 }, -{ "andn", F3(2, 0x05, 1), F3(~2, ~0x05, ~1), "1,i,d", 0, v6 }, -{ "andn", F3(2, 0x05, 1), F3(~2, ~0x05, ~1), "i,1,d", 0, v6 }, - -{ "andncc", F3(2, 0x15, 0), F3(~2, ~0x15, ~0)|ASI(~0), "1,2,d", 0, v6 }, -{ "andncc", F3(2, 0x15, 1), F3(~2, ~0x15, ~1), "1,i,d", 0, v6 }, -{ "andncc", F3(2, 0x15, 1), F3(~2, ~0x15, ~1), "i,1,d", 0, v6 }, - -{ "bclr", F3(2, 0x05, 0), F3(~2, ~0x05, ~0)|ASI(~0), "2,r", F_ALIAS, v6 }, /* andn rd,rs2,rd */ -{ "bclr", F3(2, 0x05, 1), F3(~2, ~0x05, ~1), "i,r", F_ALIAS, v6 }, /* andn rd,i,rd */ - -{ "cmp", F3(2, 0x14, 0), F3(~2, ~0x14, ~0)|RD_G0|ASI(~0), "1,2", 0, v6 }, /* subcc rs1,rs2,%g0 */ -{ "cmp", F3(2, 0x14, 1), F3(~2, ~0x14, ~1)|RD_G0, "1,i", 0, v6 }, /* subcc rs1,i,%g0 */ - -{ "sub", F3(2, 0x04, 0), F3(~2, ~0x04, ~0)|ASI(~0), "1,2,d", 0, v6 }, -{ "sub", F3(2, 0x04, 1), F3(~2, ~0x04, ~1), "1,i,d", 0, v6 }, - -{ "subcc", F3(2, 0x14, 0), F3(~2, ~0x14, ~0)|ASI(~0), "1,2,d", 0, v6 }, -{ "subcc", F3(2, 0x14, 1), F3(~2, ~0x14, ~1), "1,i,d", 0, v6 }, - -{ "subx", F3(2, 0x0c, 0), F3(~2, ~0x0c, ~0)|ASI(~0), "1,2,d", 0, v6 }, -{ "subx", F3(2, 0x0c, 1), F3(~2, ~0x0c, ~1), "1,i,d", 0, v6 }, - -{ "subxcc", F3(2, 0x1c, 0), F3(~2, ~0x1c, ~0)|ASI(~0), "1,2,d", 0, v6 }, -{ "subxcc", F3(2, 0x1c, 1), F3(~2, ~0x1c, ~1), "1,i,d", 0, v6 }, - -{ "and", F3(2, 0x01, 0), F3(~2, ~0x01, ~0)|ASI(~0), "1,2,d", 0, v6 }, -{ "and", F3(2, 0x01, 1), F3(~2, ~0x01, ~1), "1,i,d", 0, v6 }, -{ "and", F3(2, 0x01, 1), F3(~2, ~0x01, ~1), "i,1,d", 0, v6 }, - -{ "andcc", F3(2, 0x11, 0), F3(~2, ~0x11, ~0)|ASI(~0), "1,2,d", 0, v6 }, -{ "andcc", F3(2, 0x11, 1), F3(~2, ~0x11, ~1), "1,i,d", 0, v6 }, -{ "andcc", F3(2, 0x11, 1), F3(~2, ~0x11, ~1), "i,1,d", 0, v6 }, - -{ "dec", F3(2, 0x04, 1)|SIMM13(0x1), F3(~2, ~0x04, ~1)|SIMM13(~0x0001), "r", F_ALIAS, v6 }, /* sub rd,1,rd */ -{ "deccc", F3(2, 0x14, 1)|SIMM13(0x1), F3(~2, ~0x14, ~1)|SIMM13(~0x0001), "r", F_ALIAS, v6 }, /* subcc rd,1,rd */ -{ "inc", F3(2, 0x00, 1)|SIMM13(0x1), F3(~2, ~0x00, ~1)|SIMM13(~0x0001), "r", F_ALIAS, v6 }, /* add rs1,1,rsd */ -{ "inccc", F3(2, 0x10, 1)|SIMM13(0x1), F3(~2, ~0x10, ~1)|SIMM13(~0x0001), "r", F_ALIAS, v6 }, /* addcc rd,1,rd */ - -{ "btst", F3(2, 0x11, 0), F3(~2, ~0x11, ~0)|RD_G0|ASI(~0), "1,2", F_ALIAS, v6 }, /* andcc rs1,rs2,%g0 */ -{ "btst", F3(2, 0x11, 1), F3(~2, ~0x11, ~1)|RD_G0, "i,1", F_ALIAS, v6 }, /* andcc rs1,i,%g0 */ - -{ "neg", F3(2, 0x04, 0), F3(~2, ~0x04, ~0)|RS1_G0|ASI(~0), "2,d", F_ALIAS, v6 }, /* sub %g0,rs2,rd */ -{ "neg", F3(2, 0x04, 0), F3(~2, ~0x04, ~0)|RS1_G0|ASI(~0), "r", F_ALIAS, v6 }, /* sub %g0,rd,rd */ - -{ "add", F3(2, 0x00, 0), F3(~2, ~0x00, ~0)|ASI(~0), "1,2,d", 0, v6 }, -{ "add", F3(2, 0x00, 1), F3(~2, ~0x00, ~1), "1,i,d", 0, v6 }, -{ "add", F3(2, 0x00, 1), F3(~2, ~0x00, ~1), "i,1,d", 0, v6 }, -{ "addcc", F3(2, 0x10, 0), F3(~2, ~0x10, ~0)|ASI(~0), "1,2,d", 0, v6 }, -{ "addcc", F3(2, 0x10, 1), F3(~2, ~0x10, ~1), "1,i,d", 0, v6 }, -{ "addcc", F3(2, 0x10, 1), F3(~2, ~0x10, ~1), "i,1,d", 0, v6 }, -{ "addx", F3(2, 0x08, 0), F3(~2, ~0x08, ~0)|ASI(~0), "1,2,d", 0, v6 }, -{ "addx", F3(2, 0x08, 1), F3(~2, ~0x08, ~1), "1,i,d", 0, v6 }, -{ "addx", F3(2, 0x08, 1), F3(~2, ~0x08, ~1), "i,1,d", 0, v6 }, -{ "addxcc", F3(2, 0x18, 0), F3(~2, ~0x18, ~0)|ASI(~0), "1,2,d", 0, v6 }, -{ "addxcc", F3(2, 0x18, 1), F3(~2, ~0x18, ~1), "1,i,d", 0, v6 }, -{ "addxcc", F3(2, 0x18, 1), F3(~2, ~0x18, ~1), "i,1,d", 0, v6 }, - -{ "smul", F3(2, 0x0b, 0), F3(~2, ~0x0b, ~0)|ASI(~0), "1,2,d", 0, v8 }, -{ "smul", F3(2, 0x0b, 1), F3(~2, ~0x0b, ~1), "1,i,d", 0, v8 }, -{ "smul", F3(2, 0x0b, 1), F3(~2, ~0x0b, ~1), "i,1,d", 0, v8 }, -{ "smulcc", F3(2, 0x1b, 0), F3(~2, ~0x1b, ~0)|ASI(~0), "1,2,d", 0, v8 }, -{ "smulcc", F3(2, 0x1b, 1), F3(~2, ~0x1b, ~1), "1,i,d", 0, v8 }, -{ "smulcc", F3(2, 0x1b, 1), F3(~2, ~0x1b, ~1), "i,1,d", 0, v8 }, -{ "umul", F3(2, 0x0a, 0), F3(~2, ~0x0a, ~0)|ASI(~0), "1,2,d", 0, v8 }, -{ "umul", F3(2, 0x0a, 1), F3(~2, ~0x0a, ~1), "1,i,d", 0, v8 }, -{ "umul", F3(2, 0x0a, 1), F3(~2, ~0x0a, ~1), "i,1,d", 0, v8 }, -{ "umulcc", F3(2, 0x1a, 0), F3(~2, ~0x1a, ~0)|ASI(~0), "1,2,d", 0, v8 }, -{ "umulcc", F3(2, 0x1a, 1), F3(~2, ~0x1a, ~1), "1,i,d", 0, v8 }, -{ "umulcc", F3(2, 0x1a, 1), F3(~2, ~0x1a, ~1), "i,1,d", 0, v8 }, -{ "sdiv", F3(2, 0x0f, 0), F3(~2, ~0x0f, ~0)|ASI(~0), "1,2,d", 0, v8 }, -{ "sdiv", F3(2, 0x0f, 1), F3(~2, ~0x0f, ~1), "1,i,d", 0, v8 }, -{ "sdiv", F3(2, 0x0f, 1), F3(~2, ~0x0f, ~1), "i,1,d", 0, v8 }, -{ "sdivcc", F3(2, 0x1f, 0), F3(~2, ~0x1f, ~0)|ASI(~0), "1,2,d", 0, v8 }, -{ "sdivcc", F3(2, 0x1f, 1), F3(~2, ~0x1f, ~1), "1,i,d", 0, v8 }, -{ "sdivcc", F3(2, 0x1f, 1), F3(~2, ~0x1f, ~1), "i,1,d", 0, v8 }, -{ "udiv", F3(2, 0x0e, 0), F3(~2, ~0x0e, ~0)|ASI(~0), "1,2,d", 0, v8 }, -{ "udiv", F3(2, 0x0e, 1), F3(~2, ~0x0e, ~1), "1,i,d", 0, v8 }, -{ "udiv", F3(2, 0x0e, 1), F3(~2, ~0x0e, ~1), "i,1,d", 0, v8 }, -{ "udivcc", F3(2, 0x1e, 0), F3(~2, ~0x1e, ~0)|ASI(~0), "1,2,d", 0, v8 }, -{ "udivcc", F3(2, 0x1e, 1), F3(~2, ~0x1e, ~1), "1,i,d", 0, v8 }, -{ "udivcc", F3(2, 0x1e, 1), F3(~2, ~0x1e, ~1), "i,1,d", 0, v8 }, - -{ "mulx", F3(2, 0x09, 0), F3(~2, ~0x09, ~0)|ASI(~0), "1,2,d", 0, v9 }, -{ "mulx", F3(2, 0x09, 1), F3(~2, ~0x09, ~1), "1,i,d", 0, v9 }, -{ "umulxcc", F3(2, 0x19, 0), F3(~2, ~0x19, ~0)|ASI(~0), "1,2,d", 0, v9 }, -{ "umulxcc", F3(2, 0x19, 1), F3(~2, ~0x19, ~1), "1,i,d", 0, v9 }, -{ "sdivxcc", F3(2, 0x1d, 0), F3(~2, ~0x1d, ~0)|ASI(~0), "1,2,d", 0, v9 }, -{ "sdivxcc", F3(2, 0x1d, 1), F3(~2, ~0x1d, ~1), "1,i,d", 0, v9 }, -{ "udivx", F3(2, 0x0d, 0), F3(~2, ~0x0d, ~0)|ASI(~0), "1,2,d", 0, v9 }, -{ "udivx", F3(2, 0x0d, 1), F3(~2, ~0x0d, ~1), "1,i,d", 0, v9 }, - -{ "call", F1(0x1), F1(~0x1), "L", F_DELAYED, v6 }, -{ "call", F1(0x1), F1(~0x1), "L,#", F_DELAYED, v6 }, -{ "call", F3(2, 0x38, 0)|RD(0xf), F3(~2, ~0x38, ~0)|RD(~0xf)|ASI_RS2(~0), "1", F_DELAYED, v6 }, /* jmpl rs1+%g0, %o7 */ -{ "call", F3(2, 0x38, 0)|RD(0xf), F3(~2, ~0x38, ~0)|RD(~0xf)|ASI_RS2(~0), "1,#", F_DELAYED, v6 }, - -/* Conditional instructions. - - Because this part of the table was such a mess earlier, I have - macrofied it so that all the branches and traps are generated from - a single-line description of each condition value. John Gilmore. */ - -/* Define branches -- one annulled, one without, etc. */ -#define br(opcode, mask, lose, flags) \ - { opcode, (mask)|ANNUL, (lose), ",a l", (flags), v6 }, \ - { opcode, (mask) , (lose)|ANNUL, "l", (flags), v6 } - -#define brx(opcode, mask, lose, flags) /* v9 */ \ - { opcode, (mask), (lose)|ANNUL|BPRED, "Z,G", (flags), v9 }, \ - { opcode, (mask), (lose)|ANNUL|BPRED, ",N Z,G", (flags), v9 }, \ - { opcode, (mask)|ANNUL, (lose)|BPRED, ",a Z,G", (flags), v9 }, \ - { opcode, (mask)|ANNUL, (lose)|BPRED, ",a,N Z,G", (flags), v9 }, \ - { opcode, (mask)|BPRED, (lose)|ANNUL, ",T Z,G", (flags), v9 }, \ - { opcode, (mask)|ANNUL|BPRED, (lose), ",a,T Z,G", (flags), v9 }, \ - { opcode, (mask), (lose)|ANNUL|BPRED, "z,G", (flags), v9 }, \ - { opcode, (mask), (lose)|ANNUL|BPRED, ",N z,G", (flags), v9 }, \ - { opcode, (mask)|ANNUL, (lose)|BPRED, ",a z,G", (flags), v9 }, \ - { opcode, (mask)|ANNUL, (lose)|BPRED, ",a,N z,G", (flags), v9 }, \ - { opcode, (mask)|BPRED, (lose)|ANNUL, ",T z,G", (flags), v9 }, \ - { opcode, (mask)|ANNUL|BPRED, (lose), ",a,T z,G", (flags), v9 } - -/* Define four traps: reg+reg, reg + immediate, immediate alone, reg alone. */ -#define tr(opcode, mask, lose, flags) \ - { opcode, (mask)|IMMED, (lose)|RS1_G0, "i", (flags), v6 }, /* %g0 + imm */ \ - { opcode, (mask)|IMMED, (lose), "1+i", (flags), v6 }, /* rs1 + imm */ \ - { opcode, (mask), IMMED|(lose), "1+2", (flags), v6 }, /* rs1 + rs2 */ \ - { opcode, (mask)|(1<<12)|IMMED, (lose)|RS1_G0, "Z,i", (flags), v9 }, /* %g0 + imm */ \ - { opcode, (mask)|(1<<12)|IMMED, (lose), "Z,1+i", (flags), v9 }, /* rs1 + imm */ \ - { opcode, (mask)|(1<<12), IMMED|(lose), "Z,1+2", (flags), v9 }, /* rs1 + rs2 */ \ - { opcode, (mask)|(1<<12), IMMED|(lose)|RS2_G0, "Z,1", (flags), v9 }, /* rs1 + %g0 */ \ - { opcode, (mask)|IMMED, (1<<12)|(lose)|RS1_G0, "z,i", (flags)|F_ALIAS, v9 }, /* %g0 + imm */ \ - { opcode, (mask)|IMMED, (1<<12)|(lose), "z,1+i", (flags)|F_ALIAS, v9 }, /* rs1 + imm */ \ - { opcode, (mask), IMMED|(1<<12)|(lose), "z,1+2", (flags)|F_ALIAS, v9 }, /* rs1 + rs2 */ \ - { opcode, (mask), IMMED|(1<<12)|(lose)|RS2_G0, "z,1", (flags)|F_ALIAS, v9 }, /* rs1 + %g0 */ \ - { opcode, (mask), IMMED|(lose)|RS2_G0, "1", (flags), v6 } /* rs1 + %g0 */ - -/* Define both branches and traps based on condition mask */ -#define cond(bop, top, mask, flags) \ - br(bop, F2(0, 2)|(mask), F2(~0, ~2)|((~mask)&COND(~0)), F_DELAYED|(flags)), \ - brx(bop, F2(0, 1)|(mask), F2(~0, ~1)|((~mask)&COND(~0)), F_DELAYED|(flags)), /* v9 */ \ - tr(top, F3(2, 0x3a, 0)|(mask), F3(~2, ~0x3a, 0)|((~mask)&COND(~0)), (flags)) - -/* Define all the conditions, all the branches, all the traps. */ - -cond ("b", "t", CONDA, 0), -cond ("ba", "ta", CONDA, F_ALIAS), /* for nothing */ -cond ("bcc", "tcc", CONDCC, 0), -cond ("bcs", "tcs", CONDCS, 0), -cond ("be", "te", CONDE, 0), -cond ("bg", "tg", CONDG, 0), -cond ("bgt", "tgt", CONDG, F_ALIAS), -cond ("bge", "tge", CONDGE, 0), -cond ("bgeu", "tgeu", CONDGEU, F_ALIAS), /* for cc */ -cond ("bgu", "tgu", CONDGU, 0), -cond ("bl", "tl", CONDL, 0), -cond ("blt", "tlt", CONDL, F_ALIAS), -cond ("ble", "tle", CONDLE, 0), -cond ("bleu", "tleu", CONDLEU, 0), -cond ("blu", "tlu", CONDLU, F_ALIAS), /* for cs */ -cond ("bn", "tn", CONDN, 0), -cond ("bne", "tne", CONDNE, 0), -cond ("bneg", "tneg", CONDNEG, 0), -cond ("bnz", "tnz", CONDNZ, F_ALIAS), /* for ne */ -cond ("bpos", "tpos", CONDPOS, 0), -cond ("bvc", "tvc", CONDVC, 0), -cond ("bvs", "tvs", CONDVS, 0), -cond ("bz", "tz", CONDZ, F_ALIAS), /* for e */ - -#undef cond -#undef br -#undef tr - -#define brr(opcode, mask, lose, flags) /* v9 */ \ - { opcode, (mask), (lose)|ANNUL|BPRED, "1,k", F_DELAYED|(flags), v9 }, \ - { opcode, (mask), (lose)|ANNUL|BPRED, ",N 1,k", F_DELAYED|(flags), v9 }, \ - { opcode, (mask)|ANNUL, (lose)|BPRED, ",a 1,k", F_DELAYED|(flags), v9 }, \ - { opcode, (mask)|ANNUL, (lose)|BPRED, ",a,N 1,k", F_DELAYED|(flags), v9 }, \ - { opcode, (mask)|BPRED, (lose)|ANNUL, ",T 1,k", F_DELAYED|(flags), v9 }, \ - { opcode, (mask)|ANNUL|BPRED, (lose), ",a,T 1,k", F_DELAYED|(flags), v9 } - -#define condr(bop, mask, flags) /* v9 */ \ - brr(bop, F2(0, 3)|COND(mask), F2(~0, ~3)|COND(~(mask)), (flags)) /* v9 */ \ - -/* v9 */ condr("bre", 0x1, 0), -/* v9 */ condr("brne", 0x0, 0), -/* v9 */ condr("brneg", 0x3, 0), -/* v9 */ condr("brnz", 0x0, F_ALIAS), -/* v9 */ condr("brpos", 0x2, 0), -/* v9 */ condr("brz", 0x1, F_ALIAS), - -#undef condr /* v9 */ -#undef brr /* v9 */ - -#define mrr(opcode, mask, lose, flags) /* v9 */ \ - { opcode, (mask), (lose)|ASI(~0), "1,2,d", F_DELAYED|(flags), v9 }, \ - { opcode, (mask), (lose), "1,i,d", F_DELAYED|(flags), v9 } - -#define movr(bop, mask, flags) /* v9 */ \ - mrr(bop, F3(2, 0x2f, 0)|COND(mask), F3(~2, ~0x2f, ~0)|COND(~(mask))|ASI(~0), (flags)), /* v9 */ \ - mrr(bop, F3(2, 0x2f, 1)|COND(mask), F3(~2, ~0x2f, ~1)|COND(~(mask)), (flags)) /* v9 */ \ - -/* v9 */ movr("movre", 0x1, 0), -/* v9 */ movr("movrne", 0x0, 0), -/* v9 */ movr("movrneg", 0x3, 0), -/* v9 */ movr("movrnz", 0x0, F_ALIAS), -/* v9 */ movr("movrpos", 0x2, 0), -/* v9 */ movr("movrz", 0x1, F_ALIAS), - -#undef movr /* v9 */ -#undef mrr /* v9 */ - -{ "mova", F2(2, 0x58)|FCC(0)|MCOND(FCONDA), MCOND(~FCONDA)|IMMED|FCC(~0)|F2(~2, ~0x58), "6,2,d", 0, v9 }, -{ "mova", F2(2, 0x58)|FCC(0)|MCOND(FCONDA)|IMMED, MCOND(~FCONDA)|FCC(~0)|F2(~2, ~0x58), "6,I,d", 0, v9 }, -{ "mova", F2(2, 0x58)|FCC(1)|MCOND(FCONDA), IMMED|MCOND(~FCONDA)|FCC(~1)|F2(~2, ~0x58), "7,2,d", 0, v9 }, -{ "mova", F2(2, 0x58)|FCC(1)|MCOND(FCONDA)|IMMED, MCOND(~FCONDA)|FCC(~1)|F2(~2, ~0x58), "7,I,d", 0, v9 }, -{ "mova", F2(2, 0x58)|FCC(2)|MCOND(FCONDA), IMMED|MCOND(~FCONDA)|FCC(~2)|F2(~2, ~0x58), "8,2,d", 0, v9 }, -{ "mova", F2(2, 0x58)|FCC(2)|MCOND(FCONDA)|IMMED, MCOND(~FCONDA)|FCC(~2)|F2(~2, ~0x58), "8,I,d", 0, v9 }, -{ "mova", F2(2, 0x58)|FCC(3)|MCOND(FCONDA), IMMED|MCOND(~FCONDA)|FCC(~3)|F2(~2, ~0x58), "9,2,d", 0, v9 }, -{ "mova", F2(2, 0x58)|FCC(3)|MCOND(FCONDA)|IMMED, MCOND(~FCONDA)|FCC(~3)|F2(~2, ~0x58), "9,I,d", 0, v9 }, -{ "mova", F2(2, 0x59)|MCOND(CONDA)|ICC, F2(~2, ~0x59)|MCOND(~CONDA)|IMMED|XCC|(1<<12), "z,2,d", 0, v9 }, -{ "mova", F2(2, 0x59)|MCOND(CONDA)|ICC|IMMED, F2(~2, ~0x59)|MCOND(~CONDA)|XCC|(1<<12), "z,I,d", 0, v9 }, -{ "mova", F2(2, 0x59)|MCOND(CONDA)|XCC, F2(~2, ~0x59)|MCOND(~CONDA)|IMMED|(1<<12), "Z,2,d", 0, v9 }, -{ "mova", F2(2, 0x59)|MCOND(CONDA)|XCC|IMMED, F2(~2, ~0x59)|MCOND(~CONDA)|(1<<12), "Z,I,d", 0, v9 }, -{ "movcc", F2(2, 0x59)|MCOND(CONDCC)|ICC, F2(~2, ~0x59)|MCOND(~CONDCC)|IMMED|XCC|(1<<12), "z,2,d", 0, v9 }, -{ "movcc", F2(2, 0x59)|MCOND(CONDCC)|ICC|IMMED, F2(~2, ~0x59)|MCOND(~CONDCC)|XCC|(1<<12), "z,I,d", 0, v9 }, -{ "movcc", F2(2, 0x59)|MCOND(CONDCC)|XCC, F2(~2, ~0x59)|MCOND(~CONDCC)|IMMED|(1<<12), "Z,2,d", 0, v9 }, -{ "movcc", F2(2, 0x59)|MCOND(CONDCC)|XCC|IMMED, F2(~2, ~0x59)|MCOND(~CONDCC)|(1<<12), "Z,I,d", 0, v9 }, -{ "movgeu", F2(2, 0x59)|MCOND(CONDGEU)|ICC, F2(~2, ~0x59)|MCOND(~CONDGEU)|IMMED|XCC|(1<<12), "z,2,d", 0, v9 }, -{ "movgeu", F2(2, 0x59)|MCOND(CONDGEU)|ICC|IMMED, F2(~2, ~0x59)|MCOND(~CONDGEU)|XCC|(1<<12), "z,I,d", 0, v9 }, -{ "movgeu", F2(2, 0x59)|MCOND(CONDGEU)|XCC, F2(~2, ~0x59)|MCOND(~CONDGEU)|IMMED|(1<<12), "Z,2,d", 0, v9 }, -{ "movgeu", F2(2, 0x59)|MCOND(CONDGEU)|XCC|IMMED, F2(~2, ~0x59)|MCOND(~CONDGEU)|(1<<12), "Z,I,d", 0, v9 }, -{ "movcs", F2(2, 0x59)|MCOND(CONDCS)|ICC, F2(~2, ~0x59)|MCOND(~CONDCS)|IMMED|XCC|(1<<12), "z,2,d", 0, v9 }, -{ "movcs", F2(2, 0x59)|MCOND(CONDCS)|ICC|IMMED, F2(~2, ~0x59)|MCOND(~CONDCS)|XCC|(1<<12), "z,I,d", 0, v9 }, -{ "movcs", F2(2, 0x59)|MCOND(CONDCS)|XCC, F2(~2, ~0x59)|MCOND(~CONDCS)|IMMED|(1<<12), "Z,2,d", 0, v9 }, -{ "movcs", F2(2, 0x59)|MCOND(CONDCS)|XCC|IMMED, F2(~2, ~0x59)|MCOND(~CONDCS)|(1<<12), "Z,I,d", 0, v9 }, -{ "movlu", F2(2, 0x59)|MCOND(CONDLU)|ICC, F2(~2, ~0x59)|MCOND(~CONDLU)|IMMED|XCC|(1<<12), "z,2,d", 0, v9 }, -{ "movlu", F2(2, 0x59)|MCOND(CONDLU)|ICC|IMMED, F2(~2, ~0x59)|MCOND(~CONDLU)|XCC|(1<<12), "z,I,d", 0, v9 }, -{ "movlu", F2(2, 0x59)|MCOND(CONDLU)|XCC, F2(~2, ~0x59)|MCOND(~CONDLU)|IMMED|(1<<12), "Z,2,d", 0, v9 }, -{ "movlu", F2(2, 0x59)|MCOND(CONDLU)|XCC|IMMED, F2(~2, ~0x59)|MCOND(~CONDLU)|(1<<12), "Z,I,d", 0, v9 }, -{ "move", F2(2, 0x58)|FCC(0)|MCOND(FCONDE), IMMED|MCOND(~FCONDE)|FCC(~0)|F2(~2, ~0x58), "6,2,d", 0, v9 }, -{ "move", F2(2, 0x58)|FCC(0)|MCOND(FCONDE)|IMMED, MCOND(~FCONDE)|FCC(~0)|F2(~2, ~0x58), "6,I,d", 0, v9 }, -{ "move", F2(2, 0x58)|FCC(1)|MCOND(FCONDE), IMMED|MCOND(~FCONDE)|FCC(~1)|F2(~2, ~0x58), "7,2,d", 0, v9 }, -{ "move", F2(2, 0x58)|FCC(1)|MCOND(FCONDE)|IMMED, MCOND(~FCONDE)|FCC(~1)|F2(~2, ~0x58), "7,I,d", 0, v9 }, -{ "move", F2(2, 0x58)|FCC(2)|MCOND(FCONDE), IMMED|MCOND(~FCONDE)|FCC(~2)|F2(~2, ~0x58), "8,2,d", 0, v9 }, -{ "move", F2(2, 0x58)|FCC(2)|MCOND(FCONDE)|IMMED, MCOND(~FCONDE)|FCC(~2)|F2(~2, ~0x58), "8,I,d", 0, v9 }, -{ "move", F2(2, 0x58)|FCC(3)|MCOND(FCONDE), IMMED|MCOND(~FCONDE)|FCC(~3)|F2(~2, ~0x58), "9,2,d", 0, v9 }, -{ "move", F2(2, 0x58)|FCC(3)|MCOND(FCONDE)|IMMED, MCOND(~FCONDE)|FCC(~3)|F2(~2, ~0x58), "9,I,d", 0, v9 }, -{ "move", F2(2, 0x59)|MCOND(CONDE)|ICC, F2(~2, ~0x59)|MCOND(~CONDE)|IMMED|XCC|(1<<12), "z,2,d", 0, v9 }, -{ "move", F2(2, 0x59)|MCOND(CONDE)|ICC|IMMED, F2(~2, ~0x59)|MCOND(~CONDE)|XCC|(1<<12), "z,I,d", 0, v9 }, -{ "move", F2(2, 0x59)|MCOND(CONDE)|XCC, F2(~2, ~0x59)|MCOND(~CONDE)|IMMED|(1<<12), "Z,2,d", 0, v9 }, -{ "move", F2(2, 0x59)|MCOND(CONDE)|XCC|IMMED, F2(~2, ~0x59)|MCOND(~CONDE)|(1<<12), "Z,I,d", 0, v9 }, -{ "movg", F2(2, 0x58)|FCC(0)|MCOND(FCONDG), IMMED|MCOND(~FCONDG)|FCC(~0)|F2(~2, ~0x58), "6,2,d", 0, v9 }, -{ "movg", F2(2, 0x58)|FCC(0)|MCOND(FCONDG)|IMMED, MCOND(~FCONDG)|FCC(~0)|F2(~2, ~0x58), "6,I,d", 0, v9 }, -{ "movg", F2(2, 0x58)|FCC(1)|MCOND(FCONDG), IMMED|MCOND(~FCONDG)|FCC(~1)|F2(~2, ~0x58), "7,2,d", 0, v9 }, -{ "movg", F2(2, 0x58)|FCC(1)|MCOND(FCONDG)|IMMED, MCOND(~FCONDG)|FCC(~1)|F2(~2, ~0x58), "7,I,d", 0, v9 }, -{ "movg", F2(2, 0x58)|FCC(2)|MCOND(FCONDG), IMMED|MCOND(~FCONDG)|FCC(~2)|F2(~2, ~0x58), "8,2,d", 0, v9 }, -{ "movg", F2(2, 0x58)|FCC(2)|MCOND(FCONDG)|IMMED, MCOND(~FCONDG)|FCC(~2)|F2(~2, ~0x58), "8,I,d", 0, v9 }, -{ "movg", F2(2, 0x58)|FCC(3)|MCOND(FCONDG), IMMED|MCOND(~FCONDG)|FCC(~3)|F2(~2, ~0x58), "9,2,d", 0, v9 }, -{ "movg", F2(2, 0x58)|FCC(3)|MCOND(FCONDG)|IMMED, MCOND(~FCONDG)|FCC(~3)|F2(~2, ~0x58), "9,I,d", 0, v9 }, -{ "movg", F2(2, 0x59)|MCOND(CONDG)|ICC, F2(~2, ~0x59)|MCOND(~CONDG)|IMMED|XCC|(1<<12), "z,2,d", 0, v9 }, -{ "movg", F2(2, 0x59)|MCOND(CONDG)|ICC|IMMED, F2(~2, ~0x59)|MCOND(~CONDG)|XCC|(1<<12), "z,I,d", 0, v9 }, -{ "movg", F2(2, 0x59)|MCOND(CONDG)|XCC, F2(~2, ~0x59)|MCOND(~CONDG)|IMMED|(1<<12), "Z,2,d", 0, v9 }, -{ "movg", F2(2, 0x59)|MCOND(CONDG)|XCC|IMMED, F2(~2, ~0x59)|MCOND(~CONDG)|(1<<12), "Z,I,d", 0, v9 }, -{ "movge", F2(2, 0x58)|FCC(0)|MCOND(FCONDGE), IMMED|MCOND(~FCONDGE)|FCC(~0)|F2(~2, ~0x58), "6,2,d", 0, v9 }, -{ "movge", F2(2, 0x58)|FCC(0)|MCOND(FCONDGE)|IMMED, MCOND(~FCONDGE)|FCC(~0)|F2(~2, ~0x58), "6,I,d", 0, v9 }, -{ "movge", F2(2, 0x58)|FCC(1)|MCOND(FCONDGE), IMMED|MCOND(~FCONDGE)|FCC(~1)|F2(~2, ~0x58), "7,2,d", 0, v9 }, -{ "movge", F2(2, 0x58)|FCC(1)|MCOND(FCONDGE)|IMMED, MCOND(~FCONDGE)|FCC(~1)|F2(~2, ~0x58), "7,I,d", 0, v9 }, -{ "movge", F2(2, 0x58)|FCC(2)|MCOND(FCONDGE), IMMED|MCOND(~FCONDGE)|FCC(~2)|F2(~2, ~0x58), "8,2,d", 0, v9 }, -{ "movge", F2(2, 0x58)|FCC(2)|MCOND(FCONDGE)|IMMED, MCOND(~FCONDGE)|FCC(~2)|F2(~2, ~0x58), "8,I,d", 0, v9 }, -{ "movge", F2(2, 0x58)|FCC(3)|MCOND(FCONDGE), IMMED|MCOND(~FCONDGE)|FCC(~3)|F2(~2, ~0x58), "9,2,d", 0, v9 }, -{ "movge", F2(2, 0x58)|FCC(3)|MCOND(FCONDGE)|IMMED, MCOND(~FCONDGE)|FCC(~3)|F2(~2, ~0x58), "9,I,d", 0, v9 }, -{ "movge", F2(2, 0x59)|MCOND(CONDGE)|ICC, F2(~2, ~0x59)|MCOND(~CONDGE)|IMMED|XCC|(1<<12), "z,2,d", 0, v9 }, -{ "movge", F2(2, 0x59)|MCOND(CONDGE)|ICC|IMMED, F2(~2, ~0x59)|MCOND(~CONDGE)|XCC|(1<<12), "z,I,d", 0, v9 }, -{ "movge", F2(2, 0x59)|MCOND(CONDGE)|XCC, F2(~2, ~0x59)|MCOND(~CONDGE)|IMMED|(1<<12), "Z,2,d", 0, v9 }, -{ "movge", F2(2, 0x59)|MCOND(CONDGE)|XCC|IMMED, F2(~2, ~0x59)|MCOND(~CONDGE)|(1<<12), "Z,I,d", 0, v9 }, -{ "movgu", F2(2, 0x59)|MCOND(CONDGU)|ICC, F2(~2, ~0x59)|MCOND(~CONDGU)|IMMED|XCC|(1<<12), "z,2,d", 0, v9 }, -{ "movgu", F2(2, 0x59)|MCOND(CONDGU)|ICC|IMMED, F2(~2, ~0x59)|MCOND(~CONDGU)|XCC|(1<<12), "z,I,d", 0, v9 }, -{ "movgu", F2(2, 0x59)|MCOND(CONDGU)|XCC, F2(~2, ~0x59)|MCOND(~CONDGU)|IMMED|(1<<12), "Z,2,d", 0, v9 }, -{ "movgu", F2(2, 0x59)|MCOND(CONDGU)|XCC|IMMED, F2(~2, ~0x59)|MCOND(~CONDGU)|(1<<12), "Z,I,d", 0, v9 }, -{ "movl", F2(2, 0x58)|FCC(0)|MCOND(FCONDL), IMMED|MCOND(~FCONDL)|FCC(~0)|F2(~2, ~0x58), "6,2,d", 0, v9 }, -{ "movl", F2(2, 0x58)|FCC(0)|MCOND(FCONDL)|IMMED, MCOND(~FCONDL)|FCC(~0)|F2(~2, ~0x58), "6,I,d", 0, v9 }, -{ "movl", F2(2, 0x58)|FCC(1)|MCOND(FCONDL), IMMED|MCOND(~FCONDL)|FCC(~1)|F2(~2, ~0x58), "7,2,d", 0, v9 }, -{ "movl", F2(2, 0x58)|FCC(1)|MCOND(FCONDL)|IMMED, MCOND(~FCONDL)|FCC(~1)|F2(~2, ~0x58), "7,I,d", 0, v9 }, -{ "movl", F2(2, 0x58)|FCC(2)|MCOND(FCONDL), IMMED|MCOND(~FCONDL)|FCC(~2)|F2(~2, ~0x58), "8,2,d", 0, v9 }, -{ "movl", F2(2, 0x58)|FCC(2)|MCOND(FCONDL)|IMMED, MCOND(~FCONDL)|FCC(~2)|F2(~2, ~0x58), "8,I,d", 0, v9 }, -{ "movl", F2(2, 0x58)|FCC(3)|MCOND(FCONDL), IMMED|MCOND(~FCONDL)|FCC(~3)|F2(~2, ~0x58), "9,2,d", 0, v9 }, -{ "movl", F2(2, 0x58)|FCC(3)|MCOND(FCONDL)|IMMED, MCOND(~FCONDL)|FCC(~3)|F2(~2, ~0x58), "9,I,d", 0, v9 }, -{ "movl", F2(2, 0x59)|MCOND(CONDL)|ICC, F2(~2, ~0x59)|MCOND(~CONDL)|IMMED|XCC|(1<<12), "z,2,d", 0, v9 }, -{ "movl", F2(2, 0x59)|MCOND(CONDL)|ICC|IMMED, F2(~2, ~0x59)|MCOND(~CONDL)|XCC|(1<<12), "z,I,d", 0, v9 }, -{ "movl", F2(2, 0x59)|MCOND(CONDL)|XCC, F2(~2, ~0x59)|MCOND(~CONDL)|IMMED|(1<<12), "Z,2,d", 0, v9 }, -{ "movl", F2(2, 0x59)|MCOND(CONDL)|XCC|IMMED, F2(~2, ~0x59)|MCOND(~CONDL)|(1<<12), "Z,I,d", 0, v9 }, -{ "movle", F2(2, 0x58)|FCC(0)|MCOND(FCONDLE), IMMED|MCOND(~FCONDLE)|FCC(~0)|F2(~2, ~0x58), "6,2,d", 0, v9 }, -{ "movle", F2(2, 0x58)|FCC(0)|MCOND(FCONDLE)|IMMED, MCOND(~FCONDLE)|FCC(~0)|F2(~2, ~0x58), "6,I,d", 0, v9 }, -{ "movle", F2(2, 0x58)|FCC(1)|MCOND(FCONDLE), IMMED|MCOND(~FCONDLE)|FCC(~1)|F2(~2, ~0x58), "7,2,d", 0, v9 }, -{ "movle", F2(2, 0x58)|FCC(1)|MCOND(FCONDLE)|IMMED, MCOND(~FCONDLE)|FCC(~1)|F2(~2, ~0x58), "7,I,d", 0, v9 }, -{ "movle", F2(2, 0x58)|FCC(2)|MCOND(FCONDLE), IMMED|MCOND(~FCONDLE)|FCC(~2)|F2(~2, ~0x58), "8,2,d", 0, v9 }, -{ "movle", F2(2, 0x58)|FCC(2)|MCOND(FCONDLE)|IMMED, MCOND(~FCONDLE)|FCC(~2)|F2(~2, ~0x58), "8,I,d", 0, v9 }, -{ "movle", F2(2, 0x58)|FCC(3)|MCOND(FCONDLE), IMMED|MCOND(~FCONDLE)|FCC(~3)|F2(~2, ~0x58), "9,2,d", 0, v9 }, -{ "movle", F2(2, 0x58)|FCC(3)|MCOND(FCONDLE)|IMMED, MCOND(~FCONDLE)|FCC(~3)|F2(~2, ~0x58), "9,I,d", 0, v9 }, -{ "movle", F2(2, 0x59)|MCOND(CONDLE)|ICC, F2(~2, ~0x59)|MCOND(~CONDLE)|IMMED|XCC|(1<<12), "z,2,d", 0, v9 }, -{ "movle", F2(2, 0x59)|MCOND(CONDLE)|ICC|IMMED, F2(~2, ~0x59)|MCOND(~CONDLE)|XCC|(1<<12), "z,I,d", 0, v9 }, -{ "movle", F2(2, 0x59)|MCOND(CONDLE)|XCC, F2(~2, ~0x59)|MCOND(~CONDLE)|IMMED|(1<<12), "Z,2,d", 0, v9 }, -{ "movle", F2(2, 0x59)|MCOND(CONDLE)|XCC|IMMED, F2(~2, ~0x59)|MCOND(~CONDLE)|(1<<12), "Z,I,d", 0, v9 }, -{ "movleu", F2(2, 0x59)|MCOND(CONDLEU)|ICC, F2(~2, ~0x59)|MCOND(~CONDLEU)|IMMED|XCC|(1<<12), "z,2,d", 0, v9 }, -{ "movleu", F2(2, 0x59)|MCOND(CONDLEU)|ICC|IMMED, F2(~2, ~0x59)|MCOND(~CONDLEU)|XCC|(1<<12), "z,I,d", 0, v9 }, -{ "movleu", F2(2, 0x59)|MCOND(CONDLEU)|XCC, F2(~2, ~0x59)|MCOND(~CONDLEU)|IMMED|(1<<12), "Z,2,d", 0, v9 }, -{ "movleu", F2(2, 0x59)|MCOND(CONDLEU)|XCC|IMMED, F2(~2, ~0x59)|MCOND(~CONDLEU)|(1<<12), "Z,I,d", 0, v9 }, -{ "movlg", F2(2, 0x58)|FCC(0)|MCOND(FCONDLG), IMMED|MCOND(~FCONDLG)|FCC(~0)|F2(~2, ~0x58), "6,2,d", 0, v9 }, -{ "movlg", F2(2, 0x58)|FCC(0)|MCOND(FCONDLG)|IMMED, MCOND(~FCONDLG)|FCC(~0)|F2(~2, ~0x58), "6,I,d", 0, v9 }, -{ "movlg", F2(2, 0x58)|FCC(1)|MCOND(FCONDLG), IMMED|MCOND(~FCONDLG)|FCC(~1)|F2(~2, ~0x58), "7,2,d", 0, v9 }, -{ "movlg", F2(2, 0x58)|FCC(1)|MCOND(FCONDLG)|IMMED, MCOND(~FCONDLG)|FCC(~1)|F2(~2, ~0x58), "7,I,d", 0, v9 }, -{ "movlg", F2(2, 0x58)|FCC(2)|MCOND(FCONDLG), IMMED|MCOND(~FCONDLG)|FCC(~2)|F2(~2, ~0x58), "8,2,d", 0, v9 }, -{ "movlg", F2(2, 0x58)|FCC(2)|MCOND(FCONDLG)|IMMED, MCOND(~FCONDLG)|FCC(~2)|F2(~2, ~0x58), "8,I,d", 0, v9 }, -{ "movlg", F2(2, 0x58)|FCC(3)|MCOND(FCONDLG), IMMED|MCOND(~FCONDLG)|FCC(~3)|F2(~2, ~0x58), "9,2,d", 0, v9 }, -{ "movlg", F2(2, 0x58)|FCC(3)|MCOND(FCONDLG)|IMMED, MCOND(~FCONDLG)|FCC(~3)|F2(~2, ~0x58), "9,I,d", 0, v9 }, -{ "movn", F2(2, 0x58)|FCC(0)|MCOND(FCONDN), IMMED|MCOND(~FCONDN)|FCC(~0)|F2(~2, ~0x58), "6,2,d", 0, v9 }, -{ "movn", F2(2, 0x58)|FCC(0)|MCOND(FCONDN)|IMMED, MCOND(~FCONDN)|FCC(~0)|F2(~2, ~0x58), "6,I,d", 0, v9 }, -{ "movn", F2(2, 0x58)|FCC(1)|MCOND(FCONDN), IMMED|MCOND(~FCONDN)|FCC(~1)|F2(~2, ~0x58), "7,2,d", 0, v9 }, -{ "movn", F2(2, 0x58)|FCC(1)|MCOND(FCONDN)|IMMED, MCOND(~FCONDN)|FCC(~1)|F2(~2, ~0x58), "7,I,d", 0, v9 }, -{ "movn", F2(2, 0x58)|FCC(2)|MCOND(FCONDN), IMMED|MCOND(~FCONDN)|FCC(~2)|F2(~2, ~0x58), "8,2,d", 0, v9 }, -{ "movn", F2(2, 0x58)|FCC(2)|MCOND(FCONDN)|IMMED, MCOND(~FCONDN)|FCC(~2)|F2(~2, ~0x58), "8,I,d", 0, v9 }, -{ "movn", F2(2, 0x58)|FCC(3)|MCOND(FCONDN), IMMED|MCOND(~FCONDN)|FCC(~3)|F2(~2, ~0x58), "9,2,d", 0, v9 }, -{ "movn", F2(2, 0x58)|FCC(3)|MCOND(FCONDN)|IMMED, MCOND(~FCONDN)|FCC(~3)|F2(~2, ~0x58), "9,I,d", 0, v9 }, -{ "movn", F2(2, 0x59)|MCOND(CONDN)|ICC, F2(~2, ~0x59)|MCOND(~CONDN)|IMMED|XCC|(1<<12), "z,2,d", 0, v9 }, -{ "movn", F2(2, 0x59)|MCOND(CONDN)|ICC|IMMED, F2(~2, ~0x59)|MCOND(~CONDN)|XCC|(1<<12), "z,I,d", 0, v9 }, -{ "movn", F2(2, 0x59)|MCOND(CONDN)|XCC, F2(~2, ~0x59)|MCOND(~CONDN)|IMMED|(1<<12), "Z,2,d", 0, v9 }, -{ "movn", F2(2, 0x59)|MCOND(CONDN)|XCC|IMMED, F2(~2, ~0x59)|MCOND(~CONDN)|(1<<12), "Z,I,d", 0, v9 }, -{ "movne", F2(2, 0x58)|FCC(0)|MCOND(FCONDNE), IMMED|MCOND(~FCONDNE)|FCC(~0)|F2(~2, ~0x58), "6,2,d", 0, v9 }, -{ "movne", F2(2, 0x58)|FCC(0)|MCOND(FCONDNE)|IMMED, MCOND(~FCONDNE)|FCC(~0)|F2(~2, ~0x58), "6,I,d", 0, v9 }, -{ "movne", F2(2, 0x58)|FCC(1)|MCOND(FCONDNE), IMMED|MCOND(~FCONDNE)|FCC(~1)|F2(~2, ~0x58), "7,2,d", 0, v9 }, -{ "movne", F2(2, 0x58)|FCC(1)|MCOND(FCONDNE)|IMMED, MCOND(~FCONDNE)|FCC(~1)|F2(~2, ~0x58), "7,I,d", 0, v9 }, -{ "movne", F2(2, 0x58)|FCC(2)|MCOND(FCONDNE), IMMED|MCOND(~FCONDNE)|FCC(~2)|F2(~2, ~0x58), "8,2,d", 0, v9 }, -{ "movne", F2(2, 0x58)|FCC(2)|MCOND(FCONDNE)|IMMED, MCOND(~FCONDNE)|FCC(~2)|F2(~2, ~0x58), "8,I,d", 0, v9 }, -{ "movne", F2(2, 0x58)|FCC(3)|MCOND(FCONDNE), IMMED|MCOND(~FCONDNE)|FCC(~3)|F2(~2, ~0x58), "9,2,d", 0, v9 }, -{ "movne", F2(2, 0x58)|FCC(3)|MCOND(FCONDNE)|IMMED, MCOND(~FCONDNE)|FCC(~3)|F2(~2, ~0x58), "9,I,d", 0, v9 }, -{ "movne", F2(2, 0x59)|MCOND(CONDNE)|ICC, F2(~2, ~0x59)|MCOND(~CONDNE)|IMMED|XCC|(1<<12), "z,2,d", 0, v9 }, -{ "movne", F2(2, 0x59)|MCOND(CONDNE)|ICC|IMMED, F2(~2, ~0x59)|MCOND(~CONDNE)|XCC|(1<<12), "z,I,d", 0, v9 }, -{ "movne", F2(2, 0x59)|MCOND(CONDNE)|XCC, F2(~2, ~0x59)|MCOND(~CONDNE)|IMMED|(1<<12), "Z,2,d", 0, v9 }, -{ "movne", F2(2, 0x59)|MCOND(CONDNE)|XCC|IMMED, F2(~2, ~0x59)|MCOND(~CONDNE)|(1<<12), "Z,I,d", 0, v9 }, -{ "movneg", F2(2, 0x59)|MCOND(CONDNEG)|ICC, F2(~2, ~0x59)|MCOND(~CONDNEG)|IMMED|XCC|(1<<12), "z,2,d", 0, v9 }, -{ "movneg", F2(2, 0x59)|MCOND(CONDNEG)|ICC|IMMED, F2(~2, ~0x59)|MCOND(~CONDNEG)|XCC|(1<<12), "z,I,d", 0, v9 }, -{ "movneg", F2(2, 0x59)|MCOND(CONDNEG)|XCC, F2(~2, ~0x59)|MCOND(~CONDNEG)|IMMED|(1<<12), "Z,2,d", 0, v9 }, -{ "movneg", F2(2, 0x59)|MCOND(CONDNEG)|XCC|IMMED, F2(~2, ~0x59)|MCOND(~CONDNEG)|(1<<12), "Z,I,d", 0, v9 }, -{ "movnz", F2(2, 0x58)|FCC(0)|MCOND(FCONDNZ), IMMED|MCOND(~FCONDNZ)|FCC(~0)|F2(~2, ~0x58), "6,2,d", 0, v9 }, -{ "movnz", F2(2, 0x58)|FCC(0)|MCOND(FCONDNZ)|IMMED, MCOND(~FCONDNZ)|FCC(~0)|F2(~2, ~0x58), "6,I,d", 0, v9 }, -{ "movnz", F2(2, 0x58)|FCC(1)|MCOND(FCONDNZ), IMMED|MCOND(~FCONDNZ)|FCC(~1)|F2(~2, ~0x58), "7,2,d", 0, v9 }, -{ "movnz", F2(2, 0x58)|FCC(1)|MCOND(FCONDNZ)|IMMED, MCOND(~FCONDNZ)|FCC(~1)|F2(~2, ~0x58), "7,I,d", 0, v9 }, -{ "movnz", F2(2, 0x58)|FCC(2)|MCOND(FCONDNZ), IMMED|MCOND(~FCONDNZ)|FCC(~2)|F2(~2, ~0x58), "8,2,d", 0, v9 }, -{ "movnz", F2(2, 0x58)|FCC(2)|MCOND(FCONDNZ)|IMMED, MCOND(~FCONDNZ)|FCC(~2)|F2(~2, ~0x58), "8,I,d", 0, v9 }, -{ "movnz", F2(2, 0x58)|FCC(3)|MCOND(FCONDNZ), IMMED|MCOND(~FCONDNZ)|FCC(~3)|F2(~2, ~0x58), "9,2,d", 0, v9 }, -{ "movnz", F2(2, 0x58)|FCC(3)|MCOND(FCONDNZ)|IMMED, MCOND(~FCONDNZ)|FCC(~3)|F2(~2, ~0x58), "9,I,d", 0, v9 }, -{ "movo", F2(2, 0x58)|FCC(0)|MCOND(FCONDO), IMMED|MCOND(~FCONDO)|FCC(~0)|F2(~2, ~0x58), "6,2,d", 0, v9 }, -{ "movo", F2(2, 0x58)|FCC(0)|MCOND(FCONDO)|IMMED, MCOND(~FCONDO)|FCC(~0)|F2(~2, ~0x58), "6,I,d", 0, v9 }, -{ "movo", F2(2, 0x58)|FCC(1)|MCOND(FCONDO), IMMED|MCOND(~FCONDO)|FCC(~1)|F2(~2, ~0x58), "7,2,d", 0, v9 }, -{ "movo", F2(2, 0x58)|FCC(1)|MCOND(FCONDO)|IMMED, MCOND(~FCONDO)|FCC(~1)|F2(~2, ~0x58), "7,I,d", 0, v9 }, -{ "movo", F2(2, 0x58)|FCC(2)|MCOND(FCONDO), IMMED|MCOND(~FCONDO)|FCC(~2)|F2(~2, ~0x58), "8,2,d", 0, v9 }, -{ "movo", F2(2, 0x58)|FCC(2)|MCOND(FCONDO)|IMMED, MCOND(~FCONDO)|FCC(~2)|F2(~2, ~0x58), "8,I,d", 0, v9 }, -{ "movo", F2(2, 0x58)|FCC(3)|MCOND(FCONDO), IMMED|MCOND(~FCONDO)|FCC(~3)|F2(~2, ~0x58), "9,2,d", 0, v9 }, -{ "movo", F2(2, 0x58)|FCC(3)|MCOND(FCONDO)|IMMED, MCOND(~FCONDO)|FCC(~3)|F2(~2, ~0x58), "9,I,d", 0, v9 }, -{ "movpos", F2(2, 0x59)|MCOND(CONDPOS)|ICC, F2(~2, ~0x59)|MCOND(~CONDPOS)|IMMED|XCC|(1<<12), "z,2,d", 0, v9 }, -{ "movpos", F2(2, 0x59)|MCOND(CONDPOS)|ICC|IMMED, F2(~2, ~0x59)|MCOND(~CONDPOS)|XCC|(1<<12), "z,I,d", 0, v9 }, -{ "movpos", F2(2, 0x59)|MCOND(CONDPOS)|XCC, F2(~2, ~0x59)|MCOND(~CONDPOS)|IMMED|(1<<12), "Z,2,d", 0, v9 }, -{ "movpos", F2(2, 0x59)|MCOND(CONDPOS)|XCC|IMMED, F2(~2, ~0x59)|MCOND(~CONDPOS)|(1<<12), "Z,I,d", 0, v9 }, -{ "movu", F2(2, 0x58)|FCC(0)|MCOND(FCONDU), IMMED|MCOND(~FCONDU)|FCC(~0)|F2(~2, ~0x58), "6,2,d", 0, v9 }, -{ "movu", F2(2, 0x58)|FCC(0)|MCOND(FCONDU)|IMMED, MCOND(~FCONDU)|FCC(~0)|F2(~2, ~0x58), "6,I,d", 0, v9 }, -{ "movu", F2(2, 0x58)|FCC(1)|MCOND(FCONDU), IMMED|MCOND(~FCONDU)|FCC(~1)|F2(~2, ~0x58), "7,2,d", 0, v9 }, -{ "movu", F2(2, 0x58)|FCC(1)|MCOND(FCONDU)|IMMED, MCOND(~FCONDU)|FCC(~1)|F2(~2, ~0x58), "7,I,d", 0, v9 }, -{ "movu", F2(2, 0x58)|FCC(2)|MCOND(FCONDU), IMMED|MCOND(~FCONDU)|FCC(~2)|F2(~2, ~0x58), "8,2,d", 0, v9 }, -{ "movu", F2(2, 0x58)|FCC(2)|MCOND(FCONDU)|IMMED, MCOND(~FCONDU)|FCC(~2)|F2(~2, ~0x58), "8,I,d", 0, v9 }, -{ "movu", F2(2, 0x58)|FCC(3)|MCOND(FCONDU), IMMED|MCOND(~FCONDU)|FCC(~3)|F2(~2, ~0x58), "9,2,d", 0, v9 }, -{ "movu", F2(2, 0x58)|FCC(3)|MCOND(FCONDU)|IMMED, MCOND(~FCONDU)|FCC(~3)|F2(~2, ~0x58), "9,I,d", 0, v9 }, -{ "movue", F2(2, 0x58)|FCC(0)|MCOND(FCONDUE), IMMED|MCOND(~FCONDUE)|FCC(~0)|F2(~2, ~0x58), "6,2,d", 0, v9 }, -{ "movue", F2(2, 0x58)|FCC(0)|MCOND(FCONDUE)|IMMED, MCOND(~FCONDUE)|FCC(~0)|F2(~2, ~0x58), "6,I,d", 0, v9 }, -{ "movue", F2(2, 0x58)|FCC(1)|MCOND(FCONDUE), IMMED|MCOND(~FCONDUE)|FCC(~1)|F2(~2, ~0x58), "7,2,d", 0, v9 }, -{ "movue", F2(2, 0x58)|FCC(1)|MCOND(FCONDUE)|IMMED, MCOND(~FCONDUE)|FCC(~1)|F2(~2, ~0x58), "7,I,d", 0, v9 }, -{ "movue", F2(2, 0x58)|FCC(2)|MCOND(FCONDUE), IMMED|MCOND(~FCONDUE)|FCC(~2)|F2(~2, ~0x58), "8,2,d", 0, v9 }, -{ "movue", F2(2, 0x58)|FCC(2)|MCOND(FCONDUE)|IMMED, MCOND(~FCONDUE)|FCC(~2)|F2(~2, ~0x58), "8,I,d", 0, v9 }, -{ "movue", F2(2, 0x58)|FCC(3)|MCOND(FCONDUE), IMMED|MCOND(~FCONDUE)|FCC(~3)|F2(~2, ~0x58), "9,2,d", 0, v9 }, -{ "movue", F2(2, 0x58)|FCC(3)|MCOND(FCONDUE)|IMMED, MCOND(~FCONDUE)|FCC(~3)|F2(~2, ~0x58), "9,I,d", 0, v9 }, -{ "movug", F2(2, 0x58)|FCC(0)|MCOND(FCONDUG), IMMED|MCOND(~FCONDUG)|FCC(~0)|F2(~2, ~0x58), "6,2,d", 0, v9 }, -{ "movug", F2(2, 0x58)|FCC(0)|MCOND(FCONDUG)|IMMED, MCOND(~FCONDUG)|FCC(~0)|F2(~2, ~0x58), "6,I,d", 0, v9 }, -{ "movug", F2(2, 0x58)|FCC(1)|MCOND(FCONDUG), IMMED|MCOND(~FCONDUG)|FCC(~1)|F2(~2, ~0x58), "7,2,d", 0, v9 }, -{ "movug", F2(2, 0x58)|FCC(1)|MCOND(FCONDUG)|IMMED, MCOND(~FCONDUG)|FCC(~1)|F2(~2, ~0x58), "7,I,d", 0, v9 }, -{ "movug", F2(2, 0x58)|FCC(2)|MCOND(FCONDUG), IMMED|MCOND(~FCONDUG)|FCC(~2)|F2(~2, ~0x58), "8,2,d", 0, v9 }, -{ "movug", F2(2, 0x58)|FCC(2)|MCOND(FCONDUG)|IMMED, MCOND(~FCONDUG)|FCC(~2)|F2(~2, ~0x58), "8,I,d", 0, v9 }, -{ "movug", F2(2, 0x58)|FCC(3)|MCOND(FCONDUG), IMMED|MCOND(~FCONDUG)|FCC(~3)|F2(~2, ~0x58), "9,2,d", 0, v9 }, -{ "movug", F2(2, 0x58)|FCC(3)|MCOND(FCONDUG)|IMMED, MCOND(~FCONDUG)|FCC(~3)|F2(~2, ~0x58), "9,I,d", 0, v9 }, -{ "movuge", F2(2, 0x58)|FCC(0)|MCOND(FCONDUGE), IMMED|MCOND(~FCONDUGE)|FCC(~0)|F2(~2, ~0x58), "6,2,d", 0, v9 }, -{ "movuge", F2(2, 0x58)|FCC(0)|MCOND(FCONDUGE)|IMMED, MCOND(~FCONDUGE)|FCC(~0)|F2(~2, ~0x58), "6,I,d", 0, v9 }, -{ "movuge", F2(2, 0x58)|FCC(1)|MCOND(FCONDUGE), IMMED|MCOND(~FCONDUGE)|FCC(~1)|F2(~2, ~0x58), "7,2,d", 0, v9 }, -{ "movuge", F2(2, 0x58)|FCC(1)|MCOND(FCONDUGE)|IMMED, MCOND(~FCONDUGE)|FCC(~1)|F2(~2, ~0x58), "7,I,d", 0, v9 }, -{ "movuge", F2(2, 0x58)|FCC(2)|MCOND(FCONDUGE), IMMED|MCOND(~FCONDUGE)|FCC(~2)|F2(~2, ~0x58), "8,2,d", 0, v9 }, -{ "movuge", F2(2, 0x58)|FCC(2)|MCOND(FCONDUGE)|IMMED, MCOND(~FCONDUGE)|FCC(~2)|F2(~2, ~0x58), "8,I,d", 0, v9 }, -{ "movuge", F2(2, 0x58)|FCC(3)|MCOND(FCONDUGE), IMMED|MCOND(~FCONDUGE)|FCC(~3)|F2(~2, ~0x58), "9,2,d", 0, v9 }, -{ "movuge", F2(2, 0x58)|FCC(3)|MCOND(FCONDUGE)|IMMED, MCOND(~FCONDUGE)|FCC(~3)|F2(~2, ~0x58), "9,I,d", 0, v9 }, -{ "movul", F2(2, 0x58)|FCC(0)|MCOND(FCONDUL), IMMED|MCOND(~FCONDUL)|FCC(~0)|F2(~2, ~0x58), "6,2,d", 0, v9 }, -{ "movul", F2(2, 0x58)|FCC(0)|MCOND(FCONDUL)|IMMED, MCOND(~FCONDUL)|FCC(~0)|F2(~2, ~0x58), "6,I,d", 0, v9 }, -{ "movul", F2(2, 0x58)|FCC(1)|MCOND(FCONDUL), IMMED|MCOND(~FCONDUL)|FCC(~1)|F2(~2, ~0x58), "7,2,d", 0, v9 }, -{ "movul", F2(2, 0x58)|FCC(1)|MCOND(FCONDUL)|IMMED, MCOND(~FCONDUL)|FCC(~1)|F2(~2, ~0x58), "7,I,d", 0, v9 }, -{ "movul", F2(2, 0x58)|FCC(2)|MCOND(FCONDUL), IMMED|MCOND(~FCONDUL)|FCC(~2)|F2(~2, ~0x58), "8,2,d", 0, v9 }, -{ "movul", F2(2, 0x58)|FCC(2)|MCOND(FCONDUL)|IMMED, MCOND(~FCONDUL)|FCC(~2)|F2(~2, ~0x58), "8,I,d", 0, v9 }, -{ "movul", F2(2, 0x58)|FCC(3)|MCOND(FCONDUL), IMMED|MCOND(~FCONDUL)|FCC(~3)|F2(~2, ~0x58), "9,2,d", 0, v9 }, -{ "movul", F2(2, 0x58)|FCC(3)|MCOND(FCONDUL)|IMMED, MCOND(~FCONDUL)|FCC(~3)|F2(~2, ~0x58), "9,I,d", 0, v9 }, -{ "movule", F2(2, 0x58)|FCC(0)|MCOND(FCONDULE), IMMED|MCOND(~FCONDULE)|FCC(~0)|F2(~2, ~0x58), "6,2,d", 0, v9 }, -{ "movule", F2(2, 0x58)|FCC(0)|MCOND(FCONDULE)|IMMED, MCOND(~FCONDULE)|FCC(~0)|F2(~2, ~0x58), "6,I,d", 0, v9 }, -{ "movule", F2(2, 0x58)|FCC(1)|MCOND(FCONDULE), IMMED|MCOND(~FCONDULE)|FCC(~1)|F2(~2, ~0x58), "7,2,d", 0, v9 }, -{ "movule", F2(2, 0x58)|FCC(1)|MCOND(FCONDULE)|IMMED, MCOND(~FCONDULE)|FCC(~1)|F2(~2, ~0x58), "7,I,d", 0, v9 }, -{ "movule", F2(2, 0x58)|FCC(2)|MCOND(FCONDULE), IMMED|MCOND(~FCONDULE)|FCC(~2)|F2(~2, ~0x58), "8,2,d", 0, v9 }, -{ "movule", F2(2, 0x58)|FCC(2)|MCOND(FCONDULE)|IMMED, MCOND(~FCONDULE)|FCC(~2)|F2(~2, ~0x58), "8,I,d", 0, v9 }, -{ "movule", F2(2, 0x58)|FCC(3)|MCOND(FCONDULE), IMMED|MCOND(~FCONDULE)|FCC(~3)|F2(~2, ~0x58), "9,2,d", 0, v9 }, -{ "movule", F2(2, 0x58)|FCC(3)|MCOND(FCONDULE)|IMMED, MCOND(~FCONDULE)|FCC(~3)|F2(~2, ~0x58), "9,I,d", 0, v9 }, -{ "movvc", F2(2, 0x59)|MCOND(CONDVC)|ICC, F2(~2, ~0x59)|MCOND(~CONDVC)|IMMED|XCC|(1<<12), "z,2,d", 0, v9 }, -{ "movvc", F2(2, 0x59)|MCOND(CONDVC)|ICC|IMMED, F2(~2, ~0x59)|MCOND(~CONDVC)|XCC|(1<<12), "z,I,d", 0, v9 }, -{ "movvc", F2(2, 0x59)|MCOND(CONDVC)|XCC, F2(~2, ~0x59)|MCOND(~CONDVC)|IMMED|(1<<12), "Z,2,d", 0, v9 }, -{ "movvc", F2(2, 0x59)|MCOND(CONDVC)|XCC|IMMED, F2(~2, ~0x59)|MCOND(~CONDVC)|(1<<12), "Z,I,d", 0, v9 }, -{ "movvs", F2(2, 0x59)|MCOND(CONDVS)|ICC, F2(~2, ~0x59)|MCOND(~CONDVS)|IMMED|XCC|(1<<12), "z,2,d", 0, v9 }, -{ "movvs", F2(2, 0x59)|MCOND(CONDVS)|ICC|IMMED, F2(~2, ~0x59)|MCOND(~CONDVS)|XCC|(1<<12), "z,I,d", 0, v9 }, -{ "movvs", F2(2, 0x59)|MCOND(CONDVS)|XCC, F2(~2, ~0x59)|MCOND(~CONDVS)|IMMED|(1<<12), "Z,2,d", 0, v9 }, -{ "movvs", F2(2, 0x59)|MCOND(CONDVS)|XCC|IMMED, F2(~2, ~0x59)|MCOND(~CONDVS)|(1<<12), "Z,I,d", 0, v9 }, -{ "movz", F2(2, 0x58)|FCC(0)|MCOND(FCONDZ), IMMED|MCOND(~FCONDZ)|FCC(~0)|F2(~2, ~0x58), "6,2,d", 0, v9 }, -{ "movz", F2(2, 0x58)|FCC(0)|MCOND(FCONDZ)|IMMED, MCOND(~FCONDZ)|FCC(~0)|F2(~2, ~0x58), "6,I,d", 0, v9 }, -{ "movz", F2(2, 0x58)|FCC(1)|MCOND(FCONDZ), IMMED|MCOND(~FCONDZ)|FCC(~1)|F2(~2, ~0x58), "7,2,d", 0, v9 }, -{ "movz", F2(2, 0x58)|FCC(1)|MCOND(FCONDZ)|IMMED, MCOND(~FCONDZ)|FCC(~1)|F2(~2, ~0x58), "7,I,d", 0, v9 }, -{ "movz", F2(2, 0x58)|FCC(2)|MCOND(FCONDZ), IMMED|MCOND(~FCONDZ)|FCC(~2)|F2(~2, ~0x58), "8,2,d", 0, v9 }, -{ "movz", F2(2, 0x58)|FCC(2)|MCOND(FCONDZ)|IMMED, MCOND(~FCONDZ)|FCC(~2)|F2(~2, ~0x58), "8,I,d", 0, v9 }, -{ "movz", F2(2, 0x58)|FCC(3)|MCOND(FCONDZ), IMMED|MCOND(~FCONDZ)|FCC(~3)|F2(~2, ~0x58), "9,2,d", 0, v9 }, -{ "movz", F2(2, 0x58)|FCC(3)|MCOND(FCONDZ)|IMMED, MCOND(~FCONDZ)|FCC(~3)|F2(~2, ~0x58), "9,I,d", 0, v9 }, - -{ "fmovad", F3F(2, 0x35, 0x082)|(1<<18)|MCOND(CONDA), F3F(~2, ~0x35, ~0x082)|MCOND(~CONDA), "z,f,g", 0, v9 }, -{ "fmovad", F3F(2, 0x35, 0x082)|MCOND(FCONDA), (1<<18)|F3F(~2, ~0x35, ~0x082)|MCOND(~FCONDA), "6,f,g", 0, v9 }, -{ "fmovad", F3F(2, 0x35, 0x0a2)|(1<<18)|MCOND(CONDA), F3F(~2, ~0x35, ~0x0a2)|MCOND(~CONDA), "Z,f,g", 0, v9 }, -{ "fmovad", F3F(2, 0x35, 0x0a2)|MCOND(FCONDA), (1<<18)|F3F(~2, ~0x35, ~0x0a2)|MCOND(~FCONDA), "7,f,g", 0, v9 }, -{ "fmovad", F3F(2, 0x35, 0x0c2)|MCOND(FCONDA), (1<<18)|F3F(~2, ~0x35, ~0x0c2)|MCOND(~FCONDA), "8,f,g", 0, v9 }, -{ "fmovad", F3F(2, 0x35, 0x0e2)|MCOND(FCONDA), (1<<18)|F3F(~2, ~0x35, ~0x0e2)|MCOND(~FCONDA), "9,f,g", 0, v9 }, -{ "fmovaq", F3F(2, 0x35, 0x083)|(1<<18)|MCOND(CONDA), F3F(~2, ~0x35, ~0x083)|MCOND(~CONDA), "z,f,g", 0, v9 }, -{ "fmovaq", F3F(2, 0x35, 0x083)|MCOND(FCONDA), (1<<18)|F3F(~2, ~0x35, ~0x083)|MCOND(~FCONDA), "6,f,g", 0, v9 }, -{ "fmovaq", F3F(2, 0x35, 0x0a3)|(1<<18)|MCOND(CONDA), F3F(~2, ~0x35, ~0x0a3)|MCOND(~CONDA), "Z,f,g", 0, v9 }, -{ "fmovaq", F3F(2, 0x35, 0x0a3)|MCOND(FCONDA), (1<<18)|F3F(~2, ~0x35, ~0x0a3)|MCOND(~FCONDA), "7,f,g", 0, v9 }, -{ "fmovaq", F3F(2, 0x35, 0x0c3)|MCOND(FCONDA), (1<<18)|F3F(~2, ~0x35, ~0x0c3)|MCOND(~FCONDA), "8,f,g", 0, v9 }, -{ "fmovaq", F3F(2, 0x35, 0x0e3)|MCOND(FCONDA), (1<<18)|F3F(~2, ~0x35, ~0x0e3)|MCOND(~FCONDA), "9,f,g", 0, v9 }, -{ "fmovas", F3F(2, 0x35, 0x081)|(1<<18)|MCOND(CONDA), F3F(~2, ~0x35, ~0x081)|MCOND(~CONDA), "z,f,g", 0, v9 }, -{ "fmovas", F3F(2, 0x35, 0x081)|MCOND(FCONDA), (1<<18)|F3F(~2, ~0x35, ~0x081)|MCOND(~FCONDA), "6,f,g", 0, v9 }, -{ "fmovas", F3F(2, 0x35, 0x0a1)|(1<<18)|MCOND(CONDA), F3F(~2, ~0x35, ~0x0a1)|MCOND(~CONDA), "Z,f,g", 0, v9 }, -{ "fmovas", F3F(2, 0x35, 0x0a1)|MCOND(FCONDA), (1<<18)|F3F(~2, ~0x35, ~0x0a1)|MCOND(~FCONDA), "7,f,g", 0, v9 }, -{ "fmovas", F3F(2, 0x35, 0x0c1)|MCOND(FCONDA), (1<<18)|F3F(~2, ~0x35, ~0x0c1)|MCOND(~FCONDA), "8,f,g", 0, v9 }, -{ "fmovas", F3F(2, 0x35, 0x0e1)|MCOND(FCONDA), (1<<18)|F3F(~2, ~0x35, ~0x0e1)|MCOND(~FCONDA), "9,f,g", 0, v9 }, -{ "fmovccd", F3F(2, 0x35, 0x082)|(1<<18)|MCOND(CONDCC), F3F(~2, ~0x35, ~0x082)|MCOND(~CONDCC), "z,f,g", 0, v9 }, -{ "fmovccd", F3F(2, 0x35, 0x0a2)|(1<<18)|MCOND(CONDCC), F3F(~2, ~0x35, ~0x0a2)|MCOND(~CONDCC), "Z,f,g", 0, v9 }, -{ "fmovccq", F3F(2, 0x35, 0x083)|(1<<18)|MCOND(CONDCC), F3F(~2, ~0x35, ~0x083)|MCOND(~CONDCC), "z,f,g", 0, v9 }, -{ "fmovccq", F3F(2, 0x35, 0x0a3)|(1<<18)|MCOND(CONDCC), F3F(~2, ~0x35, ~0x0a3)|MCOND(~CONDCC), "Z,f,g", 0, v9 }, -{ "fmovccs", F3F(2, 0x35, 0x081)|(1<<18)|MCOND(CONDCC), F3F(~2, ~0x35, ~0x081)|MCOND(~CONDCC), "z,f,g", 0, v9 }, -{ "fmovccs", F3F(2, 0x35, 0x0a1)|(1<<18)|MCOND(CONDCC), F3F(~2, ~0x35, ~0x0a1)|MCOND(~CONDCC), "Z,f,g", 0, v9 }, -{ "fmovcsd", F3F(2, 0x35, 0x082)|(1<<18)|MCOND(CONDCS), F3F(~2, ~0x35, ~0x082)|MCOND(~CONDCS), "z,f,g", 0, v9 }, -{ "fmovcsd", F3F(2, 0x35, 0x0a2)|(1<<18)|MCOND(CONDCS), F3F(~2, ~0x35, ~0x0a2)|MCOND(~CONDCS), "Z,f,g", 0, v9 }, -{ "fmovcsq", F3F(2, 0x35, 0x083)|(1<<18)|MCOND(CONDCS), F3F(~2, ~0x35, ~0x083)|MCOND(~CONDCS), "z,f,g", 0, v9 }, -{ "fmovcsq", F3F(2, 0x35, 0x0a3)|(1<<18)|MCOND(CONDCS), F3F(~2, ~0x35, ~0x0a3)|MCOND(~CONDCS), "Z,f,g", 0, v9 }, -{ "fmovcss", F3F(2, 0x35, 0x081)|(1<<18)|MCOND(CONDCS), F3F(~2, ~0x35, ~0x081)|MCOND(~CONDCS), "z,f,g", 0, v9 }, -{ "fmovcss", F3F(2, 0x35, 0x0a1)|(1<<18)|MCOND(CONDCS), F3F(~2, ~0x35, ~0x0a1)|MCOND(~CONDCS), "Z,f,g", 0, v9 }, -{ "fmoved", F3F(2, 0x35, 0x082)|(1<<18)|MCOND(CONDE), F3F(~2, ~0x35, ~0x082)|MCOND(~CONDE), "z,f,g", 0, v9 }, -{ "fmoved", F3F(2, 0x35, 0x082)|MCOND(FCONDE), (1<<18)|F3F(~2, ~0x35, ~0x082)|MCOND(~FCONDE), "6,f,g", 0, v9 }, -{ "fmoved", F3F(2, 0x35, 0x0a2)|(1<<18)|MCOND(CONDE), F3F(~2, ~0x35, ~0x0a2)|MCOND(~CONDE), "Z,f,g", 0, v9 }, -{ "fmoved", F3F(2, 0x35, 0x0a2)|MCOND(FCONDE), (1<<18)|F3F(~2, ~0x35, ~0x0a2)|MCOND(~FCONDE), "7,f,g", 0, v9 }, -{ "fmoved", F3F(2, 0x35, 0x0c2)|MCOND(FCONDE), (1<<18)|F3F(~2, ~0x35, ~0x0c2)|MCOND(~FCONDE), "8,f,g", 0, v9 }, -{ "fmoved", F3F(2, 0x35, 0x0e2)|MCOND(FCONDE), (1<<18)|F3F(~2, ~0x35, ~0x0e2)|MCOND(~FCONDE), "9,f,g", 0, v9 }, -{ "fmoveq", F3F(2, 0x35, 0x083)|(1<<18)|MCOND(CONDE), F3F(~2, ~0x35, ~0x083)|MCOND(~CONDE), "z,f,g", 0, v9 }, -{ "fmoveq", F3F(2, 0x35, 0x083)|MCOND(FCONDE), (1<<18)|F3F(~2, ~0x35, ~0x083)|MCOND(~FCONDE), "6,f,g", 0, v9 }, -{ "fmoveq", F3F(2, 0x35, 0x0a3)|(1<<18)|MCOND(CONDE), F3F(~2, ~0x35, ~0x0a3)|MCOND(~CONDE), "Z,f,g", 0, v9 }, -{ "fmoveq", F3F(2, 0x35, 0x0a3)|MCOND(FCONDE), (1<<18)|F3F(~2, ~0x35, ~0x0a3)|MCOND(~FCONDE), "7,f,g", 0, v9 }, -{ "fmoveq", F3F(2, 0x35, 0x0c3)|MCOND(FCONDE), (1<<18)|F3F(~2, ~0x35, ~0x0c3)|MCOND(~FCONDE), "8,f,g", 0, v9 }, -{ "fmoveq", F3F(2, 0x35, 0x0e3)|MCOND(FCONDE), (1<<18)|F3F(~2, ~0x35, ~0x0e3)|MCOND(~FCONDE), "9,f,g", 0, v9 }, -{ "fmoves", F3F(2, 0x35, 0x081)|(1<<18)|MCOND(CONDE), F3F(~2, ~0x35, ~0x081)|MCOND(~CONDE), "z,f,g", 0, v9 }, -{ "fmoves", F3F(2, 0x35, 0x081)|MCOND(FCONDE), (1<<18)|F3F(~2, ~0x35, ~0x081)|MCOND(~FCONDE), "6,f,g", 0, v9 }, -{ "fmoves", F3F(2, 0x35, 0x0a1)|(1<<18)|MCOND(CONDE), F3F(~2, ~0x35, ~0x0a1)|MCOND(~CONDE), "Z,f,g", 0, v9 }, -{ "fmoves", F3F(2, 0x35, 0x0a1)|MCOND(FCONDE), (1<<18)|F3F(~2, ~0x35, ~0x0a1)|MCOND(~FCONDE), "7,f,g", 0, v9 }, -{ "fmoves", F3F(2, 0x35, 0x0c1)|MCOND(FCONDE), (1<<18)|F3F(~2, ~0x35, ~0x0c1)|MCOND(~FCONDE), "8,f,g", 0, v9 }, -{ "fmoves", F3F(2, 0x35, 0x0e1)|MCOND(FCONDE), (1<<18)|F3F(~2, ~0x35, ~0x0e1)|MCOND(~FCONDE), "9,f,g", 0, v9 }, -{ "fmovgd", F3F(2, 0x35, 0x082)|(1<<18)|MCOND(CONDG), F3F(~2, ~0x35, ~0x082)|MCOND(~CONDG), "z,f,g", 0, v9 }, -{ "fmovgd", F3F(2, 0x35, 0x082)|MCOND(FCONDG), (1<<18)|F3F(~2, ~0x35, ~0x082)|MCOND(~FCONDG), "6,f,g", 0, v9 }, -{ "fmovgd", F3F(2, 0x35, 0x0a2)|(1<<18)|MCOND(CONDG), F3F(~2, ~0x35, ~0x0a2)|MCOND(~CONDG), "Z,f,g", 0, v9 }, -{ "fmovgd", F3F(2, 0x35, 0x0a2)|MCOND(FCONDG), (1<<18)|F3F(~2, ~0x35, ~0x0a2)|MCOND(~FCONDG), "7,f,g", 0, v9 }, -{ "fmovgd", F3F(2, 0x35, 0x0c2)|MCOND(FCONDG), (1<<18)|F3F(~2, ~0x35, ~0x0c2)|MCOND(~FCONDG), "8,f,g", 0, v9 }, -{ "fmovgd", F3F(2, 0x35, 0x0e2)|MCOND(FCONDG), (1<<18)|F3F(~2, ~0x35, ~0x0e2)|MCOND(~FCONDG), "9,f,g", 0, v9 }, -{ "fmovged", F3F(2, 0x35, 0x082)|(1<<18)|MCOND(CONDGE), F3F(~2, ~0x35, ~0x082)|MCOND(~CONDGE), "z,f,g", 0, v9 }, -{ "fmovged", F3F(2, 0x35, 0x082)|MCOND(FCONDGE), (1<<18)|F3F(~2, ~0x35, ~0x082)|MCOND(~FCONDGE), "6,f,g", 0, v9 }, -{ "fmovged", F3F(2, 0x35, 0x0a2)|(1<<18)|MCOND(CONDGE), F3F(~2, ~0x35, ~0x0a2)|MCOND(~CONDGE), "Z,f,g", 0, v9 }, -{ "fmovged", F3F(2, 0x35, 0x0a2)|MCOND(FCONDGE), (1<<18)|F3F(~2, ~0x35, ~0x0a2)|MCOND(~FCONDGE), "7,f,g", 0, v9 }, -{ "fmovged", F3F(2, 0x35, 0x0c2)|MCOND(FCONDGE), (1<<18)|F3F(~2, ~0x35, ~0x0c2)|MCOND(~FCONDGE), "8,f,g", 0, v9 }, -{ "fmovged", F3F(2, 0x35, 0x0e2)|MCOND(FCONDGE), (1<<18)|F3F(~2, ~0x35, ~0x0e2)|MCOND(~FCONDGE), "9,f,g", 0, v9 }, -{ "fmovgeq", F3F(2, 0x35, 0x083)|(1<<18)|MCOND(CONDGE), F3F(~2, ~0x35, ~0x083)|MCOND(~CONDGE), "z,f,g", 0, v9 }, -{ "fmovgeq", F3F(2, 0x35, 0x083)|MCOND(FCONDGE), (1<<18)|F3F(~2, ~0x35, ~0x083)|MCOND(~FCONDGE), "6,f,g", 0, v9 }, -{ "fmovgeq", F3F(2, 0x35, 0x0a3)|(1<<18)|MCOND(CONDGE), F3F(~2, ~0x35, ~0x0a3)|MCOND(~CONDGE), "Z,f,g", 0, v9 }, -{ "fmovgeq", F3F(2, 0x35, 0x0a3)|MCOND(FCONDGE), (1<<18)|F3F(~2, ~0x35, ~0x0a3)|MCOND(~FCONDGE), "7,f,g", 0, v9 }, -{ "fmovgeq", F3F(2, 0x35, 0x0c3)|MCOND(FCONDGE), (1<<18)|F3F(~2, ~0x35, ~0x0c3)|MCOND(~FCONDGE), "8,f,g", 0, v9 }, -{ "fmovgeq", F3F(2, 0x35, 0x0e3)|MCOND(FCONDGE), (1<<18)|F3F(~2, ~0x35, ~0x0e3)|MCOND(~FCONDGE), "9,f,g", 0, v9 }, -{ "fmovges", F3F(2, 0x35, 0x081)|(1<<18)|MCOND(CONDGE), F3F(~2, ~0x35, ~0x081)|MCOND(~CONDGE), "z,f,g", 0, v9 }, -{ "fmovges", F3F(2, 0x35, 0x081)|MCOND(FCONDGE), (1<<18)|F3F(~2, ~0x35, ~0x081)|MCOND(~FCONDGE), "6,f,g", 0, v9 }, -{ "fmovges", F3F(2, 0x35, 0x0a1)|(1<<18)|MCOND(CONDGE), F3F(~2, ~0x35, ~0x0a1)|MCOND(~CONDGE), "Z,f,g", 0, v9 }, -{ "fmovges", F3F(2, 0x35, 0x0a1)|MCOND(FCONDGE), (1<<18)|F3F(~2, ~0x35, ~0x0a1)|MCOND(~FCONDGE), "7,f,g", 0, v9 }, -{ "fmovges", F3F(2, 0x35, 0x0c1)|MCOND(FCONDGE), (1<<18)|F3F(~2, ~0x35, ~0x0c1)|MCOND(~FCONDGE), "8,f,g", 0, v9 }, -{ "fmovges", F3F(2, 0x35, 0x0e1)|MCOND(FCONDGE), (1<<18)|F3F(~2, ~0x35, ~0x0e1)|MCOND(~FCONDGE), "9,f,g", 0, v9 }, -{ "fmovgeud", F3F(2, 0x35, 0x082)|(1<<18)|MCOND(CONDGEU), F3F(~2, ~0x35, ~0x082)|MCOND(~CONDGEU), "z,f,g", F_ALIAS, v9 }, -{ "fmovgeud", F3F(2, 0x35, 0x0a2)|(1<<18)|MCOND(CONDGEU), F3F(~2, ~0x35, ~0x0a2)|MCOND(~CONDGEU), "Z,f,g", F_ALIAS, v9 }, -{ "fmovgeuq", F3F(2, 0x35, 0x083)|(1<<18)|MCOND(CONDGEU), F3F(~2, ~0x35, ~0x083)|MCOND(~CONDGEU), "z,f,g", F_ALIAS, v9 }, -{ "fmovgeuq", F3F(2, 0x35, 0x0a3)|(1<<18)|MCOND(CONDGEU), F3F(~2, ~0x35, ~0x0a3)|MCOND(~CONDGEU), "Z,f,g", F_ALIAS, v9 }, -{ "fmovgeus", F3F(2, 0x35, 0x081)|(1<<18)|MCOND(CONDGEU), F3F(~2, ~0x35, ~0x081)|MCOND(~CONDGEU), "z,f,g", F_ALIAS, v9 }, -{ "fmovgeus", F3F(2, 0x35, 0x0a1)|(1<<18)|MCOND(CONDGEU), F3F(~2, ~0x35, ~0x0a1)|MCOND(~CONDGEU), "Z,f,g", F_ALIAS, v9 }, -{ "fmovgq", F3F(2, 0x35, 0x083)|(1<<18)|MCOND(CONDG), F3F(~2, ~0x35, ~0x083)|MCOND(~CONDG), "z,f,g", 0, v9 }, -{ "fmovgq", F3F(2, 0x35, 0x083)|MCOND(FCONDG), (1<<18)|F3F(~2, ~0x35, ~0x083)|MCOND(~FCONDG), "6,f,g", 0, v9 }, -{ "fmovgq", F3F(2, 0x35, 0x0a3)|(1<<18)|MCOND(CONDG), F3F(~2, ~0x35, ~0x0a3)|MCOND(~CONDG), "Z,f,g", 0, v9 }, -{ "fmovgq", F3F(2, 0x35, 0x0a3)|MCOND(FCONDG), (1<<18)|F3F(~2, ~0x35, ~0x0a3)|MCOND(~FCONDG), "7,f,g", 0, v9 }, -{ "fmovgq", F3F(2, 0x35, 0x0c3)|MCOND(FCONDG), (1<<18)|F3F(~2, ~0x35, ~0x0c3)|MCOND(~FCONDG), "8,f,g", 0, v9 }, -{ "fmovgq", F3F(2, 0x35, 0x0e3)|MCOND(FCONDG), (1<<18)|F3F(~2, ~0x35, ~0x0e3)|MCOND(~FCONDG), "9,f,g", 0, v9 }, -{ "fmovgs", F3F(2, 0x35, 0x081)|(1<<18)|MCOND(CONDG), F3F(~2, ~0x35, ~0x081)|MCOND(~CONDG), "z,f,g", 0, v9 }, -{ "fmovgs", F3F(2, 0x35, 0x081)|MCOND(FCONDG), (1<<18)|F3F(~2, ~0x35, ~0x081)|MCOND(~FCONDG), "6,f,g", 0, v9 }, -{ "fmovgs", F3F(2, 0x35, 0x0a1)|(1<<18)|MCOND(CONDG), F3F(~2, ~0x35, ~0x0a1)|MCOND(~CONDG), "Z,f,g", 0, v9 }, -{ "fmovgs", F3F(2, 0x35, 0x0a1)|MCOND(FCONDG), (1<<18)|F3F(~2, ~0x35, ~0x0a1)|MCOND(~FCONDG), "7,f,g", 0, v9 }, -{ "fmovgs", F3F(2, 0x35, 0x0c1)|MCOND(FCONDG), (1<<18)|F3F(~2, ~0x35, ~0x0c1)|MCOND(~FCONDG), "8,f,g", 0, v9 }, -{ "fmovgs", F3F(2, 0x35, 0x0e1)|MCOND(FCONDG), (1<<18)|F3F(~2, ~0x35, ~0x0e1)|MCOND(~FCONDG), "9,f,g", 0, v9 }, -{ "fmovgud", F3F(2, 0x35, 0x082)|(1<<18)|MCOND(CONDGU), F3F(~2, ~0x35, ~0x082)|MCOND(~CONDGU), "z,f,g", 0, v9 }, -{ "fmovgud", F3F(2, 0x35, 0x0a2)|(1<<18)|MCOND(CONDGU), F3F(~2, ~0x35, ~0x0a2)|MCOND(~CONDGU), "Z,f,g", 0, v9 }, -{ "fmovguq", F3F(2, 0x35, 0x083)|(1<<18)|MCOND(CONDGU), F3F(~2, ~0x35, ~0x083)|MCOND(~CONDGU), "z,f,g", 0, v9 }, -{ "fmovguq", F3F(2, 0x35, 0x0a3)|(1<<18)|MCOND(CONDGU), F3F(~2, ~0x35, ~0x0a3)|MCOND(~CONDGU), "Z,f,g", 0, v9 }, -{ "fmovgus", F3F(2, 0x35, 0x081)|(1<<18)|MCOND(CONDGU), F3F(~2, ~0x35, ~0x081)|MCOND(~CONDGU), "z,f,g", 0, v9 }, -{ "fmovgus", F3F(2, 0x35, 0x0a1)|(1<<18)|MCOND(CONDGU), F3F(~2, ~0x35, ~0x0a1)|MCOND(~CONDGU), "Z,f,g", 0, v9 }, -{ "fmovld", F3F(2, 0x35, 0x082)|(1<<18)|MCOND(CONDL), F3F(~2, ~0x35, ~0x082)|MCOND(~CONDL), "z,f,g", 0, v9 }, -{ "fmovld", F3F(2, 0x35, 0x082)|MCOND(FCONDL), (1<<18)|F3F(~2, ~0x35, ~0x082)|MCOND(~FCONDL), "6,f,g", 0, v9 }, -{ "fmovld", F3F(2, 0x35, 0x0a2)|(1<<18)|MCOND(CONDL), F3F(~2, ~0x35, ~0x0a2)|MCOND(~CONDL), "Z,f,g", 0, v9 }, -{ "fmovld", F3F(2, 0x35, 0x0a2)|MCOND(FCONDL), (1<<18)|F3F(~2, ~0x35, ~0x0a2)|MCOND(~FCONDL), "7,f,g", 0, v9 }, -{ "fmovld", F3F(2, 0x35, 0x0c2)|MCOND(FCONDL), (1<<18)|F3F(~2, ~0x35, ~0x0c2)|MCOND(~FCONDL), "8,f,g", 0, v9 }, -{ "fmovld", F3F(2, 0x35, 0x0e2)|MCOND(FCONDL), (1<<18)|F3F(~2, ~0x35, ~0x0e2)|MCOND(~FCONDL), "9,f,g", 0, v9 }, -{ "fmovled", F3F(2, 0x35, 0x082)|(1<<18)|MCOND(CONDLE), F3F(~2, ~0x35, ~0x082)|MCOND(~CONDLE), "z,f,g", 0, v9 }, -{ "fmovled", F3F(2, 0x35, 0x082)|MCOND(FCONDLE), (1<<18)|F3F(~2, ~0x35, ~0x082)|MCOND(~FCONDLE), "6,f,g", 0, v9 }, -{ "fmovled", F3F(2, 0x35, 0x0a2)|(1<<18)|MCOND(CONDLE), F3F(~2, ~0x35, ~0x0a2)|MCOND(~CONDLE), "Z,f,g", 0, v9 }, -{ "fmovled", F3F(2, 0x35, 0x0a2)|MCOND(FCONDLE), (1<<18)|F3F(~2, ~0x35, ~0x0a2)|MCOND(~FCONDLE), "7,f,g", 0, v9 }, -{ "fmovled", F3F(2, 0x35, 0x0c2)|MCOND(FCONDLE), (1<<18)|F3F(~2, ~0x35, ~0x0c2)|MCOND(~FCONDLE), "8,f,g", 0, v9 }, -{ "fmovled", F3F(2, 0x35, 0x0e2)|MCOND(FCONDLE), (1<<18)|F3F(~2, ~0x35, ~0x0e2)|MCOND(~FCONDLE), "9,f,g", 0, v9 }, -{ "fmovleq", F3F(2, 0x35, 0x083)|(1<<18)|MCOND(CONDLE), F3F(~2, ~0x35, ~0x083)|MCOND(~CONDLE), "z,f,g", 0, v9 }, -{ "fmovleq", F3F(2, 0x35, 0x083)|MCOND(FCONDLE), (1<<18)|F3F(~2, ~0x35, ~0x083)|MCOND(~FCONDLE), "6,f,g", 0, v9 }, -{ "fmovleq", F3F(2, 0x35, 0x0a3)|(1<<18)|MCOND(CONDLE), F3F(~2, ~0x35, ~0x0a3)|MCOND(~CONDLE), "Z,f,g", 0, v9 }, -{ "fmovleq", F3F(2, 0x35, 0x0a3)|MCOND(FCONDLE), (1<<18)|F3F(~2, ~0x35, ~0x0a3)|MCOND(~FCONDLE), "7,f,g", 0, v9 }, -{ "fmovleq", F3F(2, 0x35, 0x0c3)|MCOND(FCONDLE), (1<<18)|F3F(~2, ~0x35, ~0x0c3)|MCOND(~FCONDLE), "8,f,g", 0, v9 }, -{ "fmovleq", F3F(2, 0x35, 0x0e3)|MCOND(FCONDLE), (1<<18)|F3F(~2, ~0x35, ~0x0e3)|MCOND(~FCONDLE), "9,f,g", 0, v9 }, -{ "fmovles", F3F(2, 0x35, 0x081)|(1<<18)|MCOND(CONDLE), F3F(~2, ~0x35, ~0x081)|MCOND(~CONDLE), "z,f,g", 0, v9 }, -{ "fmovles", F3F(2, 0x35, 0x081)|MCOND(FCONDLE), (1<<18)|F3F(~2, ~0x35, ~0x081)|MCOND(~FCONDLE), "6,f,g", 0, v9 }, -{ "fmovles", F3F(2, 0x35, 0x0a1)|(1<<18)|MCOND(CONDLE), F3F(~2, ~0x35, ~0x0a1)|MCOND(~CONDLE), "Z,f,g", 0, v9 }, -{ "fmovles", F3F(2, 0x35, 0x0a1)|MCOND(FCONDLE), (1<<18)|F3F(~2, ~0x35, ~0x0a1)|MCOND(~FCONDLE), "7,f,g", 0, v9 }, -{ "fmovles", F3F(2, 0x35, 0x0c1)|MCOND(FCONDLE), (1<<18)|F3F(~2, ~0x35, ~0x0c1)|MCOND(~FCONDLE), "8,f,g", 0, v9 }, -{ "fmovles", F3F(2, 0x35, 0x0e1)|MCOND(FCONDLE), (1<<18)|F3F(~2, ~0x35, ~0x0e1)|MCOND(~FCONDLE), "9,f,g", 0, v9 }, -{ "fmovleud", F3F(2, 0x35, 0x082)|(1<<18)|MCOND(CONDLEU), F3F(~2, ~0x35, ~0x082)|MCOND(~CONDLEU), "z,f,g", 0, v9 }, -{ "fmovleud", F3F(2, 0x35, 0x0a2)|(1<<18)|MCOND(CONDLEU), F3F(~2, ~0x35, ~0x0a2)|MCOND(~CONDLEU), "Z,f,g", 0, v9 }, -{ "fmovleuq", F3F(2, 0x35, 0x083)|(1<<18)|MCOND(CONDLEU), F3F(~2, ~0x35, ~0x083)|MCOND(~CONDLEU), "z,f,g", 0, v9 }, -{ "fmovleuq", F3F(2, 0x35, 0x0a3)|(1<<18)|MCOND(CONDLEU), F3F(~2, ~0x35, ~0x0a3)|MCOND(~CONDLEU), "Z,f,g", 0, v9 }, -{ "fmovleus", F3F(2, 0x35, 0x081)|(1<<18)|MCOND(CONDLEU), F3F(~2, ~0x35, ~0x081)|MCOND(~CONDLEU), "z,f,g", 0, v9 }, -{ "fmovleus", F3F(2, 0x35, 0x0a1)|(1<<18)|MCOND(CONDLEU), F3F(~2, ~0x35, ~0x0a1)|MCOND(~CONDLEU), "Z,f,g", 0, v9 }, -{ "fmovlgd", F3F(2, 0x35, 0x082)|MCOND(FCONDLG), (1<<18)|F3F(~2, ~0x35, ~0x082)|MCOND(~FCONDLG), "6,f,g", 0, v9 }, -{ "fmovlgd", F3F(2, 0x35, 0x0a2)|MCOND(FCONDLG), (1<<18)|F3F(~2, ~0x35, ~0x0a2)|MCOND(~FCONDLG), "7,f,g", 0, v9 }, -{ "fmovlgd", F3F(2, 0x35, 0x0c2)|MCOND(FCONDLG), (1<<18)|F3F(~2, ~0x35, ~0x0c2)|MCOND(~FCONDLG), "8,f,g", 0, v9 }, -{ "fmovlgd", F3F(2, 0x35, 0x0e2)|MCOND(FCONDLG), (1<<18)|F3F(~2, ~0x35, ~0x0e2)|MCOND(~FCONDLG), "9,f,g", 0, v9 }, -{ "fmovlgq", F3F(2, 0x35, 0x083)|MCOND(FCONDLG), (1<<18)|F3F(~2, ~0x35, ~0x083)|MCOND(~FCONDLG), "6,f,g", 0, v9 }, -{ "fmovlgq", F3F(2, 0x35, 0x0a3)|MCOND(FCONDLG), (1<<18)|F3F(~2, ~0x35, ~0x0a3)|MCOND(~FCONDLG), "7,f,g", 0, v9 }, -{ "fmovlgq", F3F(2, 0x35, 0x0c3)|MCOND(FCONDLG), (1<<18)|F3F(~2, ~0x35, ~0x0c3)|MCOND(~FCONDLG), "8,f,g", 0, v9 }, -{ "fmovlgq", F3F(2, 0x35, 0x0e3)|MCOND(FCONDLG), (1<<18)|F3F(~2, ~0x35, ~0x0e3)|MCOND(~FCONDLG), "9,f,g", 0, v9 }, -{ "fmovlgs", F3F(2, 0x35, 0x081)|MCOND(FCONDLG), (1<<18)|F3F(~2, ~0x35, ~0x081)|MCOND(~FCONDLG), "6,f,g", 0, v9 }, -{ "fmovlgs", F3F(2, 0x35, 0x0a1)|MCOND(FCONDLG), (1<<18)|F3F(~2, ~0x35, ~0x0a1)|MCOND(~FCONDLG), "7,f,g", 0, v9 }, -{ "fmovlgs", F3F(2, 0x35, 0x0c1)|MCOND(FCONDLG), (1<<18)|F3F(~2, ~0x35, ~0x0c1)|MCOND(~FCONDLG), "8,f,g", 0, v9 }, -{ "fmovlgs", F3F(2, 0x35, 0x0e1)|MCOND(FCONDLG), (1<<18)|F3F(~2, ~0x35, ~0x0e1)|MCOND(~FCONDLG), "9,f,g", 0, v9 }, -{ "fmovlq", F3F(2, 0x35, 0x083)|(1<<18)|MCOND(CONDL), F3F(~2, ~0x35, ~0x083)|MCOND(~CONDL), "z,f,g", 0, v9 }, -{ "fmovlq", F3F(2, 0x35, 0x083)|MCOND(FCONDL), (1<<18)|F3F(~2, ~0x35, ~0x083)|MCOND(~FCONDL), "6,f,g", 0, v9 }, -{ "fmovlq", F3F(2, 0x35, 0x0a3)|(1<<18)|MCOND(CONDL), F3F(~2, ~0x35, ~0x0a3)|MCOND(~CONDL), "Z,f,g", 0, v9 }, -{ "fmovlq", F3F(2, 0x35, 0x0a3)|MCOND(FCONDL), (1<<18)|F3F(~2, ~0x35, ~0x0a3)|MCOND(~FCONDL), "7,f,g", 0, v9 }, -{ "fmovlq", F3F(2, 0x35, 0x0c3)|MCOND(FCONDL), (1<<18)|F3F(~2, ~0x35, ~0x0c3)|MCOND(~FCONDL), "8,f,g", 0, v9 }, -{ "fmovlq", F3F(2, 0x35, 0x0e3)|MCOND(FCONDL), (1<<18)|F3F(~2, ~0x35, ~0x0e3)|MCOND(~FCONDL), "9,f,g", 0, v9 }, -{ "fmovls", F3F(2, 0x35, 0x081)|(1<<18)|MCOND(CONDL), F3F(~2, ~0x35, ~0x081)|MCOND(~CONDL), "z,f,g", 0, v9 }, -{ "fmovls", F3F(2, 0x35, 0x081)|MCOND(FCONDL), (1<<18)|F3F(~2, ~0x35, ~0x081)|MCOND(~FCONDL), "6,f,g", 0, v9 }, -{ "fmovls", F3F(2, 0x35, 0x0a1)|(1<<18)|MCOND(CONDL), F3F(~2, ~0x35, ~0x0a1)|MCOND(~CONDL), "Z,f,g", 0, v9 }, -{ "fmovls", F3F(2, 0x35, 0x0a1)|MCOND(FCONDL), (1<<18)|F3F(~2, ~0x35, ~0x0a1)|MCOND(~FCONDL), "7,f,g", 0, v9 }, -{ "fmovls", F3F(2, 0x35, 0x0c1)|MCOND(FCONDL), (1<<18)|F3F(~2, ~0x35, ~0x0c1)|MCOND(~FCONDL), "8,f,g", 0, v9 }, -{ "fmovls", F3F(2, 0x35, 0x0e1)|MCOND(FCONDL), (1<<18)|F3F(~2, ~0x35, ~0x0e1)|MCOND(~FCONDL), "9,f,g", 0, v9 }, -{ "fmovlud", F3F(2, 0x35, 0x082)|(1<<18)|MCOND(CONDLU), F3F(~2, ~0x35, ~0x082)|MCOND(~CONDLU), "z,f,g", F_ALIAS, v9 }, -{ "fmovlud", F3F(2, 0x35, 0x0a2)|(1<<18)|MCOND(CONDLU), F3F(~2, ~0x35, ~0x0a2)|MCOND(~CONDLU), "Z,f,g", F_ALIAS, v9 }, -{ "fmovluq", F3F(2, 0x35, 0x083)|(1<<18)|MCOND(CONDLU), F3F(~2, ~0x35, ~0x083)|MCOND(~CONDLU), "z,f,g", F_ALIAS, v9 }, -{ "fmovluq", F3F(2, 0x35, 0x0a3)|(1<<18)|MCOND(CONDLU), F3F(~2, ~0x35, ~0x0a3)|MCOND(~CONDLU), "Z,f,g", F_ALIAS, v9 }, -{ "fmovlus", F3F(2, 0x35, 0x081)|(1<<18)|MCOND(CONDLU), F3F(~2, ~0x35, ~0x081)|MCOND(~CONDLU), "z,f,g", F_ALIAS, v9 }, -{ "fmovlus", F3F(2, 0x35, 0x0a1)|(1<<18)|MCOND(CONDLU), F3F(~2, ~0x35, ~0x0a1)|MCOND(~CONDLU), "Z,f,g", F_ALIAS, v9 }, -{ "fmovnd", F3F(2, 0x35, 0x082)|(1<<18)|MCOND(CONDN), F3F(~2, ~0x35, ~0x082)|MCOND(~CONDN), "z,f,g", 0, v9 }, -{ "fmovnd", F3F(2, 0x35, 0x082)|MCOND(FCONDN), (1<<18)|F3F(~2, ~0x35, ~0x082)|MCOND(~FCONDN), "6,f,g", 0, v9 }, -{ "fmovnd", F3F(2, 0x35, 0x0a2)|(1<<18)|MCOND(CONDN), F3F(~2, ~0x35, ~0x0a2)|MCOND(~CONDN), "Z,f,g", 0, v9 }, -{ "fmovnd", F3F(2, 0x35, 0x0a2)|MCOND(FCONDN), (1<<18)|F3F(~2, ~0x35, ~0x0a2)|MCOND(~FCONDN), "7,f,g", 0, v9 }, -{ "fmovnd", F3F(2, 0x35, 0x0c2)|MCOND(FCONDN), (1<<18)|F3F(~2, ~0x35, ~0x0c2)|MCOND(~FCONDN), "8,f,g", 0, v9 }, -{ "fmovnd", F3F(2, 0x35, 0x0e2)|MCOND(FCONDN), (1<<18)|F3F(~2, ~0x35, ~0x0e2)|MCOND(~FCONDN), "9,f,g", 0, v9 }, -{ "fmovned", F3F(2, 0x35, 0x082)|(1<<18)|MCOND(CONDNE), F3F(~2, ~0x35, ~0x082)|MCOND(~CONDNE), "z,f,g", 0, v9 }, -{ "fmovned", F3F(2, 0x35, 0x082)|MCOND(FCONDNE), (1<<18)|F3F(~2, ~0x35, ~0x082)|MCOND(~FCONDNE), "6,f,g", 0, v9 }, -{ "fmovned", F3F(2, 0x35, 0x0a2)|(1<<18)|MCOND(CONDNE), F3F(~2, ~0x35, ~0x0a2)|MCOND(~CONDNE), "Z,f,g", 0, v9 }, -{ "fmovned", F3F(2, 0x35, 0x0a2)|MCOND(FCONDNE), (1<<18)|F3F(~2, ~0x35, ~0x0a2)|MCOND(~FCONDNE), "7,f,g", 0, v9 }, -{ "fmovned", F3F(2, 0x35, 0x0c2)|MCOND(FCONDNE), (1<<18)|F3F(~2, ~0x35, ~0x0c2)|MCOND(~FCONDNE), "8,f,g", 0, v9 }, -{ "fmovned", F3F(2, 0x35, 0x0e2)|MCOND(FCONDNE), (1<<18)|F3F(~2, ~0x35, ~0x0e2)|MCOND(~FCONDNE), "9,f,g", 0, v9 }, -{ "fmovnegd", F3F(2, 0x35, 0x082)|(1<<18)|MCOND(CONDNEG), F3F(~2, ~0x35, ~0x082)|MCOND(~CONDNEG), "z,f,g", 0, v9 }, -{ "fmovnegd", F3F(2, 0x35, 0x0a2)|(1<<18)|MCOND(CONDNEG), F3F(~2, ~0x35, ~0x0a2)|MCOND(~CONDNEG), "Z,f,g", 0, v9 }, -{ "fmovnegq", F3F(2, 0x35, 0x083)|(1<<18)|MCOND(CONDNEG), F3F(~2, ~0x35, ~0x083)|MCOND(~CONDNEG), "z,f,g", 0, v9 }, -{ "fmovnegq", F3F(2, 0x35, 0x0a3)|(1<<18)|MCOND(CONDNEG), F3F(~2, ~0x35, ~0x0a3)|MCOND(~CONDNEG), "Z,f,g", 0, v9 }, -{ "fmovnegs", F3F(2, 0x35, 0x081)|(1<<18)|MCOND(CONDNEG), F3F(~2, ~0x35, ~0x081)|MCOND(~CONDNEG), "z,f,g", 0, v9 }, -{ "fmovnegs", F3F(2, 0x35, 0x0a1)|(1<<18)|MCOND(CONDNEG), F3F(~2, ~0x35, ~0x0a1)|MCOND(~CONDNEG), "Z,f,g", 0, v9 }, -{ "fmovneq", F3F(2, 0x35, 0x083)|(1<<18)|MCOND(CONDNE), F3F(~2, ~0x35, ~0x083)|MCOND(~CONDNE), "z,f,g", 0, v9 }, -{ "fmovneq", F3F(2, 0x35, 0x083)|MCOND(FCONDNE), (1<<18)|F3F(~2, ~0x35, ~0x083)|MCOND(~FCONDNE), "6,f,g", 0, v9 }, -{ "fmovneq", F3F(2, 0x35, 0x0a3)|(1<<18)|MCOND(CONDNE), F3F(~2, ~0x35, ~0x0a3)|MCOND(~CONDNE), "Z,f,g", 0, v9 }, -{ "fmovneq", F3F(2, 0x35, 0x0a3)|MCOND(FCONDNE), (1<<18)|F3F(~2, ~0x35, ~0x0a3)|MCOND(~FCONDNE), "7,f,g", 0, v9 }, -{ "fmovneq", F3F(2, 0x35, 0x0c3)|MCOND(FCONDNE), (1<<18)|F3F(~2, ~0x35, ~0x0c3)|MCOND(~FCONDNE), "8,f,g", 0, v9 }, -{ "fmovneq", F3F(2, 0x35, 0x0e3)|MCOND(FCONDNE), (1<<18)|F3F(~2, ~0x35, ~0x0e3)|MCOND(~FCONDNE), "9,f,g", 0, v9 }, -{ "fmovnes", F3F(2, 0x35, 0x081)|(1<<18)|MCOND(CONDNE), F3F(~2, ~0x35, ~0x081)|MCOND(~CONDNE), "z,f,g", 0, v9 }, -{ "fmovnes", F3F(2, 0x35, 0x081)|MCOND(FCONDNE), (1<<18)|F3F(~2, ~0x35, ~0x081)|MCOND(~FCONDNE), "6,f,g", 0, v9 }, -{ "fmovnes", F3F(2, 0x35, 0x0a1)|(1<<18)|MCOND(CONDNE), F3F(~2, ~0x35, ~0x0a1)|MCOND(~CONDNE), "Z,f,g", 0, v9 }, -{ "fmovnes", F3F(2, 0x35, 0x0a1)|MCOND(FCONDNE), (1<<18)|F3F(~2, ~0x35, ~0x0a1)|MCOND(~FCONDNE), "7,f,g", 0, v9 }, -{ "fmovnes", F3F(2, 0x35, 0x0c1)|MCOND(FCONDNE), (1<<18)|F3F(~2, ~0x35, ~0x0c1)|MCOND(~FCONDNE), "8,f,g", 0, v9 }, -{ "fmovnes", F3F(2, 0x35, 0x0e1)|MCOND(FCONDNE), (1<<18)|F3F(~2, ~0x35, ~0x0e1)|MCOND(~FCONDNE), "9,f,g", 0, v9 }, -{ "fmovnq", F3F(2, 0x35, 0x083)|(1<<18)|MCOND(CONDN), F3F(~2, ~0x35, ~0x083)|MCOND(~CONDN), "z,f,g", 0, v9 }, -{ "fmovnq", F3F(2, 0x35, 0x083)|MCOND(FCONDN), (1<<18)|F3F(~2, ~0x35, ~0x083)|MCOND(~FCONDN), "6,f,g", 0, v9 }, -{ "fmovnq", F3F(2, 0x35, 0x0a3)|(1<<18)|MCOND(CONDN), F3F(~2, ~0x35, ~0x0a3)|MCOND(~CONDN), "Z,f,g", 0, v9 }, -{ "fmovnq", F3F(2, 0x35, 0x0a3)|MCOND(FCONDN), (1<<18)|F3F(~2, ~0x35, ~0x0a3)|MCOND(~FCONDN), "7,f,g", 0, v9 }, -{ "fmovnq", F3F(2, 0x35, 0x0c3)|MCOND(FCONDN), (1<<18)|F3F(~2, ~0x35, ~0x0c3)|MCOND(~FCONDN), "8,f,g", 0, v9 }, -{ "fmovnq", F3F(2, 0x35, 0x0e3)|MCOND(FCONDN), (1<<18)|F3F(~2, ~0x35, ~0x0e3)|MCOND(~FCONDN), "9,f,g", 0, v9 }, -{ "fmovns", F3F(2, 0x35, 0x081)|(1<<18)|MCOND(CONDN), F3F(~2, ~0x35, ~0x081)|MCOND(~CONDN), "z,f,g", 0, v9 }, -{ "fmovns", F3F(2, 0x35, 0x081)|MCOND(FCONDN), (1<<18)|F3F(~2, ~0x35, ~0x081)|MCOND(~FCONDN), "6,f,g", 0, v9 }, -{ "fmovns", F3F(2, 0x35, 0x0a1)|(1<<18)|MCOND(CONDN), F3F(~2, ~0x35, ~0x0a1)|MCOND(~CONDN), "Z,f,g", 0, v9 }, -{ "fmovns", F3F(2, 0x35, 0x0a1)|MCOND(FCONDN), (1<<18)|F3F(~2, ~0x35, ~0x0a1)|MCOND(~FCONDN), "7,f,g", 0, v9 }, -{ "fmovns", F3F(2, 0x35, 0x0c1)|MCOND(FCONDN), (1<<18)|F3F(~2, ~0x35, ~0x0c1)|MCOND(~FCONDN), "8,f,g", 0, v9 }, -{ "fmovns", F3F(2, 0x35, 0x0e1)|MCOND(FCONDN), (1<<18)|F3F(~2, ~0x35, ~0x0e1)|MCOND(~FCONDN), "9,f,g", 0, v9 }, -{ "fmovnzd", F3F(2, 0x35, 0x082)|(1<<18)|MCOND(CONDNZ), F3F(~2, ~0x35, ~0x082)|MCOND(~CONDNZ), "z,f,g", F_ALIAS, v9 }, -{ "fmovnzd", F3F(2, 0x35, 0x082)|MCOND(FCONDNZ), (1<<18)|F3F(~2, ~0x35, ~0x082)|MCOND(~FCONDNZ), "6,f,g", F_ALIAS, v9 }, -{ "fmovnzd", F3F(2, 0x35, 0x0a2)|(1<<18)|MCOND(CONDNZ), F3F(~2, ~0x35, ~0x0a2)|MCOND(~CONDNZ), "Z,f,g", F_ALIAS, v9 }, -{ "fmovnzd", F3F(2, 0x35, 0x0a2)|MCOND(FCONDNZ), (1<<18)|F3F(~2, ~0x35, ~0x0a2)|MCOND(~FCONDNZ), "7,f,g", F_ALIAS, v9 }, -{ "fmovnzd", F3F(2, 0x35, 0x0c2)|MCOND(FCONDNZ), (1<<18)|F3F(~2, ~0x35, ~0x0c2)|MCOND(~FCONDNZ), "8,f,g", F_ALIAS, v9 }, -{ "fmovnzd", F3F(2, 0x35, 0x0e2)|MCOND(FCONDNZ), (1<<18)|F3F(~2, ~0x35, ~0x0e2)|MCOND(~FCONDNZ), "9,f,g", F_ALIAS, v9 }, -{ "fmovnzq", F3F(2, 0x35, 0x083)|(1<<18)|MCOND(CONDNZ), F3F(~2, ~0x35, ~0x083)|MCOND(~CONDNZ), "z,f,g", F_ALIAS, v9 }, -{ "fmovnzq", F3F(2, 0x35, 0x083)|MCOND(FCONDNZ), (1<<18)|F3F(~2, ~0x35, ~0x083)|MCOND(~FCONDNZ), "6,f,g", F_ALIAS, v9 }, -{ "fmovnzq", F3F(2, 0x35, 0x0a3)|(1<<18)|MCOND(CONDNZ), F3F(~2, ~0x35, ~0x0a3)|MCOND(~CONDNZ), "Z,f,g", F_ALIAS, v9 }, -{ "fmovnzq", F3F(2, 0x35, 0x0a3)|MCOND(FCONDNZ), (1<<18)|F3F(~2, ~0x35, ~0x0a3)|MCOND(~FCONDNZ), "7,f,g", F_ALIAS, v9 }, -{ "fmovnzq", F3F(2, 0x35, 0x0c3)|MCOND(FCONDNZ), (1<<18)|F3F(~2, ~0x35, ~0x0c3)|MCOND(~FCONDNZ), "8,f,g", F_ALIAS, v9 }, -{ "fmovnzq", F3F(2, 0x35, 0x0e3)|MCOND(FCONDNZ), (1<<18)|F3F(~2, ~0x35, ~0x0e3)|MCOND(~FCONDNZ), "9,f,g", F_ALIAS, v9 }, -{ "fmovnzs", F3F(2, 0x35, 0x081)|(1<<18)|MCOND(CONDNZ), F3F(~2, ~0x35, ~0x081)|MCOND(~CONDNZ), "z,f,g", F_ALIAS, v9 }, -{ "fmovnzs", F3F(2, 0x35, 0x081)|MCOND(FCONDNZ), (1<<18)|F3F(~2, ~0x35, ~0x081)|MCOND(~FCONDNZ), "6,f,g", F_ALIAS, v9 }, -{ "fmovnzs", F3F(2, 0x35, 0x0a1)|(1<<18)|MCOND(CONDNZ), F3F(~2, ~0x35, ~0x0a1)|MCOND(~CONDNZ), "Z,f,g", F_ALIAS, v9 }, -{ "fmovnzs", F3F(2, 0x35, 0x0a1)|MCOND(FCONDNZ), (1<<18)|F3F(~2, ~0x35, ~0x0a1)|MCOND(~FCONDNZ), "7,f,g", F_ALIAS, v9 }, -{ "fmovnzs", F3F(2, 0x35, 0x0c1)|MCOND(FCONDNZ), (1<<18)|F3F(~2, ~0x35, ~0x0c1)|MCOND(~FCONDNZ), "8,f,g", F_ALIAS, v9 }, -{ "fmovnzs", F3F(2, 0x35, 0x0e1)|MCOND(FCONDNZ), (1<<18)|F3F(~2, ~0x35, ~0x0e1)|MCOND(~FCONDNZ), "9,f,g", F_ALIAS, v9 }, -{ "fmovod", F3F(2, 0x35, 0x082)|MCOND(FCONDO), (1<<18)|F3F(~2, ~0x35, ~0x082)|MCOND(~FCONDO), "6,f,g", 0, v9 }, -{ "fmovod", F3F(2, 0x35, 0x0a2)|MCOND(FCONDO), (1<<18)|F3F(~2, ~0x35, ~0x0a2)|MCOND(~FCONDO), "7,f,g", 0, v9 }, -{ "fmovod", F3F(2, 0x35, 0x0c2)|MCOND(FCONDO), (1<<18)|F3F(~2, ~0x35, ~0x0c2)|MCOND(~FCONDO), "8,f,g", 0, v9 }, -{ "fmovod", F3F(2, 0x35, 0x0e2)|MCOND(FCONDO), (1<<18)|F3F(~2, ~0x35, ~0x0e2)|MCOND(~FCONDO), "9,f,g", 0, v9 }, -{ "fmovoq", F3F(2, 0x35, 0x083)|MCOND(FCONDO), (1<<18)|F3F(~2, ~0x35, ~0x083)|MCOND(~FCONDO), "6,f,g", 0, v9 }, -{ "fmovoq", F3F(2, 0x35, 0x0a3)|MCOND(FCONDO), (1<<18)|F3F(~2, ~0x35, ~0x0a3)|MCOND(~FCONDO), "7,f,g", 0, v9 }, -{ "fmovoq", F3F(2, 0x35, 0x0c3)|MCOND(FCONDO), (1<<18)|F3F(~2, ~0x35, ~0x0c3)|MCOND(~FCONDO), "8,f,g", 0, v9 }, -{ "fmovoq", F3F(2, 0x35, 0x0e3)|MCOND(FCONDO), (1<<18)|F3F(~2, ~0x35, ~0x0e3)|MCOND(~FCONDO), "9,f,g", 0, v9 }, -{ "fmovos", F3F(2, 0x35, 0x081)|MCOND(FCONDO), (1<<18)|F3F(~2, ~0x35, ~0x081)|MCOND(~FCONDO), "6,f,g", 0, v9 }, -{ "fmovos", F3F(2, 0x35, 0x0a1)|MCOND(FCONDO), (1<<18)|F3F(~2, ~0x35, ~0x0a1)|MCOND(~FCONDO), "7,f,g", 0, v9 }, -{ "fmovos", F3F(2, 0x35, 0x0c1)|MCOND(FCONDO), (1<<18)|F3F(~2, ~0x35, ~0x0c1)|MCOND(~FCONDO), "8,f,g", 0, v9 }, -{ "fmovos", F3F(2, 0x35, 0x0e1)|MCOND(FCONDO), (1<<18)|F3F(~2, ~0x35, ~0x0e1)|MCOND(~FCONDO), "9,f,g", 0, v9 }, -{ "fmovposd", F3F(2, 0x35, 0x082)|(1<<18)|MCOND(CONDPOS), F3F(~2, ~0x35, ~0x082)|MCOND(~CONDPOS), "z,f,g", 0, v9 }, -{ "fmovposd", F3F(2, 0x35, 0x0a2)|(1<<18)|MCOND(CONDPOS), F3F(~2, ~0x35, ~0x0a2)|MCOND(~CONDPOS), "Z,f,g", 0, v9 }, -{ "fmovposq", F3F(2, 0x35, 0x083)|(1<<18)|MCOND(CONDPOS), F3F(~2, ~0x35, ~0x083)|MCOND(~CONDPOS), "z,f,g", 0, v9 }, -{ "fmovposq", F3F(2, 0x35, 0x0a3)|(1<<18)|MCOND(CONDPOS), F3F(~2, ~0x35, ~0x0a3)|MCOND(~CONDPOS), "Z,f,g", 0, v9 }, -{ "fmovposs", F3F(2, 0x35, 0x081)|(1<<18)|MCOND(CONDPOS), F3F(~2, ~0x35, ~0x081)|MCOND(~CONDPOS), "z,f,g", 0, v9 }, -{ "fmovposs", F3F(2, 0x35, 0x0a1)|(1<<18)|MCOND(CONDPOS), F3F(~2, ~0x35, ~0x0a1)|MCOND(~CONDPOS), "Z,f,g", 0, v9 }, -{ "fmovud", F3F(2, 0x35, 0x082)|MCOND(FCONDU), (1<<18)|F3F(~2, ~0x35, ~0x082)|MCOND(~FCONDU), "6,f,g", 0, v9 }, -{ "fmovud", F3F(2, 0x35, 0x0a2)|MCOND(FCONDU), (1<<18)|F3F(~2, ~0x35, ~0x0a2)|MCOND(~FCONDU), "7,f,g", 0, v9 }, -{ "fmovud", F3F(2, 0x35, 0x0c2)|MCOND(FCONDU), (1<<18)|F3F(~2, ~0x35, ~0x0c2)|MCOND(~FCONDU), "8,f,g", 0, v9 }, -{ "fmovud", F3F(2, 0x35, 0x0e2)|MCOND(FCONDU), (1<<18)|F3F(~2, ~0x35, ~0x0e2)|MCOND(~FCONDU), "9,f,g", 0, v9 }, -{ "fmovued", F3F(2, 0x35, 0x082)|MCOND(FCONDUE), (1<<18)|F3F(~2, ~0x35, ~0x082)|MCOND(~FCONDUE), "6,f,g", 0, v9 }, -{ "fmovued", F3F(2, 0x35, 0x0a2)|MCOND(FCONDUE), (1<<18)|F3F(~2, ~0x35, ~0x0a2)|MCOND(~FCONDUE), "7,f,g", 0, v9 }, -{ "fmovued", F3F(2, 0x35, 0x0c2)|MCOND(FCONDUE), (1<<18)|F3F(~2, ~0x35, ~0x0c2)|MCOND(~FCONDUE), "8,f,g", 0, v9 }, -{ "fmovued", F3F(2, 0x35, 0x0e2)|MCOND(FCONDUE), (1<<18)|F3F(~2, ~0x35, ~0x0e2)|MCOND(~FCONDUE), "9,f,g", 0, v9 }, -{ "fmovueq", F3F(2, 0x35, 0x083)|MCOND(FCONDUE), (1<<18)|F3F(~2, ~0x35, ~0x083)|MCOND(~FCONDUE), "6,f,g", 0, v9 }, -{ "fmovueq", F3F(2, 0x35, 0x0a3)|MCOND(FCONDUE), (1<<18)|F3F(~2, ~0x35, ~0x0a3)|MCOND(~FCONDUE), "7,f,g", 0, v9 }, -{ "fmovueq", F3F(2, 0x35, 0x0c3)|MCOND(FCONDUE), (1<<18)|F3F(~2, ~0x35, ~0x0c3)|MCOND(~FCONDUE), "8,f,g", 0, v9 }, -{ "fmovueq", F3F(2, 0x35, 0x0e3)|MCOND(FCONDUE), (1<<18)|F3F(~2, ~0x35, ~0x0e3)|MCOND(~FCONDUE), "9,f,g", 0, v9 }, -{ "fmovues", F3F(2, 0x35, 0x081)|MCOND(FCONDUE), (1<<18)|F3F(~2, ~0x35, ~0x081)|MCOND(~FCONDUE), "6,f,g", 0, v9 }, -{ "fmovues", F3F(2, 0x35, 0x0a1)|MCOND(FCONDUE), (1<<18)|F3F(~2, ~0x35, ~0x0a1)|MCOND(~FCONDUE), "7,f,g", 0, v9 }, -{ "fmovues", F3F(2, 0x35, 0x0c1)|MCOND(FCONDUE), (1<<18)|F3F(~2, ~0x35, ~0x0c1)|MCOND(~FCONDUE), "8,f,g", 0, v9 }, -{ "fmovues", F3F(2, 0x35, 0x0e1)|MCOND(FCONDUE), (1<<18)|F3F(~2, ~0x35, ~0x0e1)|MCOND(~FCONDUE), "9,f,g", 0, v9 }, -{ "fmovugd", F3F(2, 0x35, 0x082)|MCOND(FCONDUG), (1<<18)|F3F(~2, ~0x35, ~0x082)|MCOND(~FCONDUG), "6,f,g", 0, v9 }, -{ "fmovugd", F3F(2, 0x35, 0x0a2)|MCOND(FCONDUG), (1<<18)|F3F(~2, ~0x35, ~0x0a2)|MCOND(~FCONDUG), "7,f,g", 0, v9 }, -{ "fmovugd", F3F(2, 0x35, 0x0c2)|MCOND(FCONDUG), (1<<18)|F3F(~2, ~0x35, ~0x0c2)|MCOND(~FCONDUG), "8,f,g", 0, v9 }, -{ "fmovugd", F3F(2, 0x35, 0x0e2)|MCOND(FCONDUG), (1<<18)|F3F(~2, ~0x35, ~0x0e2)|MCOND(~FCONDUG), "9,f,g", 0, v9 }, -{ "fmovuged", F3F(2, 0x35, 0x082)|MCOND(FCONDUGE), (1<<18)|F3F(~2, ~0x35, ~0x082)|MCOND(~FCONDUGE), "6,f,g", 0, v9 }, -{ "fmovuged", F3F(2, 0x35, 0x0a2)|MCOND(FCONDUGE), (1<<18)|F3F(~2, ~0x35, ~0x0a2)|MCOND(~FCONDUGE), "7,f,g", 0, v9 }, -{ "fmovuged", F3F(2, 0x35, 0x0c2)|MCOND(FCONDUGE), (1<<18)|F3F(~2, ~0x35, ~0x0c2)|MCOND(~FCONDUGE), "8,f,g", 0, v9 }, -{ "fmovuged", F3F(2, 0x35, 0x0e2)|MCOND(FCONDUGE), (1<<18)|F3F(~2, ~0x35, ~0x0e2)|MCOND(~FCONDUGE), "9,f,g", 0, v9 }, -{ "fmovugeq", F3F(2, 0x35, 0x083)|MCOND(FCONDUGE), (1<<18)|F3F(~2, ~0x35, ~0x083)|MCOND(~FCONDUGE), "6,f,g", 0, v9 }, -{ "fmovugeq", F3F(2, 0x35, 0x0a3)|MCOND(FCONDUGE), (1<<18)|F3F(~2, ~0x35, ~0x0a3)|MCOND(~FCONDUGE), "7,f,g", 0, v9 }, -{ "fmovugeq", F3F(2, 0x35, 0x0c3)|MCOND(FCONDUGE), (1<<18)|F3F(~2, ~0x35, ~0x0c3)|MCOND(~FCONDUGE), "8,f,g", 0, v9 }, -{ "fmovugeq", F3F(2, 0x35, 0x0e3)|MCOND(FCONDUGE), (1<<18)|F3F(~2, ~0x35, ~0x0e3)|MCOND(~FCONDUGE), "9,f,g", 0, v9 }, -{ "fmovuges", F3F(2, 0x35, 0x081)|MCOND(FCONDUGE), (1<<18)|F3F(~2, ~0x35, ~0x081)|MCOND(~FCONDUGE), "6,f,g", 0, v9 }, -{ "fmovuges", F3F(2, 0x35, 0x0a1)|MCOND(FCONDUGE), (1<<18)|F3F(~2, ~0x35, ~0x0a1)|MCOND(~FCONDUGE), "7,f,g", 0, v9 }, -{ "fmovuges", F3F(2, 0x35, 0x0c1)|MCOND(FCONDUGE), (1<<18)|F3F(~2, ~0x35, ~0x0c1)|MCOND(~FCONDUGE), "8,f,g", 0, v9 }, -{ "fmovuges", F3F(2, 0x35, 0x0e1)|MCOND(FCONDUGE), (1<<18)|F3F(~2, ~0x35, ~0x0e1)|MCOND(~FCONDUGE), "9,f,g", 0, v9 }, -{ "fmovugq", F3F(2, 0x35, 0x083)|MCOND(FCONDUG), (1<<18)|F3F(~2, ~0x35, ~0x083)|MCOND(~FCONDUG), "6,f,g", 0, v9 }, -{ "fmovugq", F3F(2, 0x35, 0x0a3)|MCOND(FCONDUG), (1<<18)|F3F(~2, ~0x35, ~0x0a3)|MCOND(~FCONDUG), "7,f,g", 0, v9 }, -{ "fmovugq", F3F(2, 0x35, 0x0c3)|MCOND(FCONDUG), (1<<18)|F3F(~2, ~0x35, ~0x0c3)|MCOND(~FCONDUG), "8,f,g", 0, v9 }, -{ "fmovugq", F3F(2, 0x35, 0x0e3)|MCOND(FCONDUG), (1<<18)|F3F(~2, ~0x35, ~0x0e3)|MCOND(~FCONDUG), "9,f,g", 0, v9 }, -{ "fmovugs", F3F(2, 0x35, 0x081)|MCOND(FCONDUG), (1<<18)|F3F(~2, ~0x35, ~0x081)|MCOND(~FCONDUG), "6,f,g", 0, v9 }, -{ "fmovugs", F3F(2, 0x35, 0x0a1)|MCOND(FCONDUG), (1<<18)|F3F(~2, ~0x35, ~0x0a1)|MCOND(~FCONDUG), "7,f,g", 0, v9 }, -{ "fmovugs", F3F(2, 0x35, 0x0c1)|MCOND(FCONDUG), (1<<18)|F3F(~2, ~0x35, ~0x0c1)|MCOND(~FCONDUG), "8,f,g", 0, v9 }, -{ "fmovugs", F3F(2, 0x35, 0x0e1)|MCOND(FCONDUG), (1<<18)|F3F(~2, ~0x35, ~0x0e1)|MCOND(~FCONDUG), "9,f,g", 0, v9 }, -{ "fmovuld", F3F(2, 0x35, 0x082)|MCOND(FCONDUL), (1<<18)|F3F(~2, ~0x35, ~0x082)|MCOND(~FCONDUL), "6,f,g", 0, v9 }, -{ "fmovuld", F3F(2, 0x35, 0x0a2)|MCOND(FCONDUL), (1<<18)|F3F(~2, ~0x35, ~0x0a2)|MCOND(~FCONDUL), "7,f,g", 0, v9 }, -{ "fmovuld", F3F(2, 0x35, 0x0c2)|MCOND(FCONDUL), (1<<18)|F3F(~2, ~0x35, ~0x0c2)|MCOND(~FCONDUL), "8,f,g", 0, v9 }, -{ "fmovuld", F3F(2, 0x35, 0x0e2)|MCOND(FCONDUL), (1<<18)|F3F(~2, ~0x35, ~0x0e2)|MCOND(~FCONDUL), "9,f,g", 0, v9 }, -{ "fmovuled", F3F(2, 0x35, 0x082)|MCOND(FCONDULE), (1<<18)|F3F(~2, ~0x35, ~0x082)|MCOND(~FCONDULE), "6,f,g", 0, v9 }, -{ "fmovuled", F3F(2, 0x35, 0x0a2)|MCOND(FCONDULE), (1<<18)|F3F(~2, ~0x35, ~0x0a2)|MCOND(~FCONDULE), "7,f,g", 0, v9 }, -{ "fmovuled", F3F(2, 0x35, 0x0c2)|MCOND(FCONDULE), (1<<18)|F3F(~2, ~0x35, ~0x0c2)|MCOND(~FCONDULE), "8,f,g", 0, v9 }, -{ "fmovuled", F3F(2, 0x35, 0x0e2)|MCOND(FCONDULE), (1<<18)|F3F(~2, ~0x35, ~0x0e2)|MCOND(~FCONDULE), "9,f,g", 0, v9 }, -{ "fmovuleq", F3F(2, 0x35, 0x083)|MCOND(FCONDULE), (1<<18)|F3F(~2, ~0x35, ~0x083)|MCOND(~FCONDULE), "6,f,g", 0, v9 }, -{ "fmovuleq", F3F(2, 0x35, 0x0a3)|MCOND(FCONDULE), (1<<18)|F3F(~2, ~0x35, ~0x0a3)|MCOND(~FCONDULE), "7,f,g", 0, v9 }, -{ "fmovuleq", F3F(2, 0x35, 0x0c3)|MCOND(FCONDULE), (1<<18)|F3F(~2, ~0x35, ~0x0c3)|MCOND(~FCONDULE), "8,f,g", 0, v9 }, -{ "fmovuleq", F3F(2, 0x35, 0x0e3)|MCOND(FCONDULE), (1<<18)|F3F(~2, ~0x35, ~0x0e3)|MCOND(~FCONDULE), "9,f,g", 0, v9 }, -{ "fmovules", F3F(2, 0x35, 0x081)|MCOND(FCONDULE), (1<<18)|F3F(~2, ~0x35, ~0x081)|MCOND(~FCONDULE), "6,f,g", 0, v9 }, -{ "fmovules", F3F(2, 0x35, 0x0a1)|MCOND(FCONDULE), (1<<18)|F3F(~2, ~0x35, ~0x0a1)|MCOND(~FCONDULE), "7,f,g", 0, v9 }, -{ "fmovules", F3F(2, 0x35, 0x0c1)|MCOND(FCONDULE), (1<<18)|F3F(~2, ~0x35, ~0x0c1)|MCOND(~FCONDULE), "8,f,g", 0, v9 }, -{ "fmovules", F3F(2, 0x35, 0x0e1)|MCOND(FCONDULE), (1<<18)|F3F(~2, ~0x35, ~0x0e1)|MCOND(~FCONDULE), "9,f,g", 0, v9 }, -{ "fmovulq", F3F(2, 0x35, 0x083)|MCOND(FCONDUL), (1<<18)|F3F(~2, ~0x35, ~0x083)|MCOND(~FCONDUL), "6,f,g", 0, v9 }, -{ "fmovulq", F3F(2, 0x35, 0x0a3)|MCOND(FCONDUL), (1<<18)|F3F(~2, ~0x35, ~0x0a3)|MCOND(~FCONDUL), "7,f,g", 0, v9 }, -{ "fmovulq", F3F(2, 0x35, 0x0c3)|MCOND(FCONDUL), (1<<18)|F3F(~2, ~0x35, ~0x0c3)|MCOND(~FCONDUL), "8,f,g", 0, v9 }, -{ "fmovulq", F3F(2, 0x35, 0x0e3)|MCOND(FCONDUL), (1<<18)|F3F(~2, ~0x35, ~0x0e3)|MCOND(~FCONDUL), "9,f,g", 0, v9 }, -{ "fmovuls", F3F(2, 0x35, 0x081)|MCOND(FCONDUL), (1<<18)|F3F(~2, ~0x35, ~0x081)|MCOND(~FCONDUL), "6,f,g", 0, v9 }, -{ "fmovuls", F3F(2, 0x35, 0x0a1)|MCOND(FCONDUL), (1<<18)|F3F(~2, ~0x35, ~0x0a1)|MCOND(~FCONDUL), "7,f,g", 0, v9 }, -{ "fmovuls", F3F(2, 0x35, 0x0c1)|MCOND(FCONDUL), (1<<18)|F3F(~2, ~0x35, ~0x0c1)|MCOND(~FCONDUL), "8,f,g", 0, v9 }, -{ "fmovuls", F3F(2, 0x35, 0x0e1)|MCOND(FCONDUL), (1<<18)|F3F(~2, ~0x35, ~0x0e1)|MCOND(~FCONDUL), "9,f,g", 0, v9 }, -{ "fmovuq", F3F(2, 0x35, 0x083)|MCOND(FCONDU), (1<<18)|F3F(~2, ~0x35, ~0x083)|MCOND(~FCONDU), "6,f,g", 0, v9 }, -{ "fmovuq", F3F(2, 0x35, 0x0a3)|MCOND(FCONDU), (1<<18)|F3F(~2, ~0x35, ~0x0a3)|MCOND(~FCONDU), "7,f,g", 0, v9 }, -{ "fmovuq", F3F(2, 0x35, 0x0c3)|MCOND(FCONDU), (1<<18)|F3F(~2, ~0x35, ~0x0c3)|MCOND(~FCONDU), "8,f,g", 0, v9 }, -{ "fmovuq", F3F(2, 0x35, 0x0e3)|MCOND(FCONDU), (1<<18)|F3F(~2, ~0x35, ~0x0e3)|MCOND(~FCONDU), "9,f,g", 0, v9 }, -{ "fmovus", F3F(2, 0x35, 0x081)|MCOND(FCONDU), (1<<18)|F3F(~2, ~0x35, ~0x081)|MCOND(~FCONDU), "6,f,g", 0, v9 }, -{ "fmovus", F3F(2, 0x35, 0x0a1)|MCOND(FCONDU), (1<<18)|F3F(~2, ~0x35, ~0x0a1)|MCOND(~FCONDU), "7,f,g", 0, v9 }, -{ "fmovus", F3F(2, 0x35, 0x0c1)|MCOND(FCONDU), (1<<18)|F3F(~2, ~0x35, ~0x0c1)|MCOND(~FCONDU), "8,f,g", 0, v9 }, -{ "fmovus", F3F(2, 0x35, 0x0e1)|MCOND(FCONDU), (1<<18)|F3F(~2, ~0x35, ~0x0e1)|MCOND(~FCONDU), "9,f,g", 0, v9 }, -{ "fmovvcd", F3F(2, 0x35, 0x082)|(1<<18)|MCOND(CONDVC), F3F(~2, ~0x35, ~0x082)|MCOND(~CONDVC), "z,f,g", 0, v9 }, -{ "fmovvcd", F3F(2, 0x35, 0x0a2)|(1<<18)|MCOND(CONDVC), F3F(~2, ~0x35, ~0x0a2)|MCOND(~CONDVC), "Z,f,g", 0, v9 }, -{ "fmovvcq", F3F(2, 0x35, 0x083)|(1<<18)|MCOND(CONDVC), F3F(~2, ~0x35, ~0x083)|MCOND(~CONDVC), "z,f,g", 0, v9 }, -{ "fmovvcq", F3F(2, 0x35, 0x0a3)|(1<<18)|MCOND(CONDVC), F3F(~2, ~0x35, ~0x0a3)|MCOND(~CONDVC), "Z,f,g", 0, v9 }, -{ "fmovvcs", F3F(2, 0x35, 0x081)|(1<<18)|MCOND(CONDVC), F3F(~2, ~0x35, ~0x081)|MCOND(~CONDVC), "z,f,g", 0, v9 }, -{ "fmovvcs", F3F(2, 0x35, 0x0a1)|(1<<18)|MCOND(CONDVC), F3F(~2, ~0x35, ~0x0a1)|MCOND(~CONDVC), "Z,f,g", 0, v9 }, -{ "fmovvsd", F3F(2, 0x35, 0x082)|(1<<18)|MCOND(CONDVS), F3F(~2, ~0x35, ~0x082)|MCOND(~CONDVS), "z,f,g", 0, v9 }, -{ "fmovvsd", F3F(2, 0x35, 0x0a2)|(1<<18)|MCOND(CONDVS), F3F(~2, ~0x35, ~0x0a2)|MCOND(~CONDVS), "Z,f,g", 0, v9 }, -{ "fmovvsq", F3F(2, 0x35, 0x083)|(1<<18)|MCOND(CONDVS), F3F(~2, ~0x35, ~0x083)|MCOND(~CONDVS), "z,f,g", 0, v9 }, -{ "fmovvsq", F3F(2, 0x35, 0x0a3)|(1<<18)|MCOND(CONDVS), F3F(~2, ~0x35, ~0x0a3)|MCOND(~CONDVS), "Z,f,g", 0, v9 }, -{ "fmovvss", F3F(2, 0x35, 0x081)|(1<<18)|MCOND(CONDVS), F3F(~2, ~0x35, ~0x081)|MCOND(~CONDVS), "z,f,g", 0, v9 }, -{ "fmovvss", F3F(2, 0x35, 0x0a1)|(1<<18)|MCOND(CONDVS), F3F(~2, ~0x35, ~0x0a1)|MCOND(~CONDVS), "Z,f,g", 0, v9 }, -{ "fmovzd", F3F(2, 0x35, 0x082)|(1<<18)|MCOND(CONDZ), F3F(~2, ~0x35, ~0x082)|MCOND(~CONDZ), "z,f,g", F_ALIAS, v9 }, -{ "fmovzd", F3F(2, 0x35, 0x082)|MCOND(FCONDZ), (1<<18)|F3F(~2, ~0x35, ~0x082)|MCOND(~FCONDZ), "6,f,g", F_ALIAS, v9 }, -{ "fmovzd", F3F(2, 0x35, 0x0a2)|(1<<18)|MCOND(CONDZ), F3F(~2, ~0x35, ~0x0a2)|MCOND(~CONDZ), "Z,f,g", F_ALIAS, v9 }, -{ "fmovzd", F3F(2, 0x35, 0x0a2)|MCOND(FCONDZ), (1<<18)|F3F(~2, ~0x35, ~0x0a2)|MCOND(~FCONDZ), "7,f,g", F_ALIAS, v9 }, -{ "fmovzd", F3F(2, 0x35, 0x0c2)|MCOND(FCONDZ), (1<<18)|F3F(~2, ~0x35, ~0x0c2)|MCOND(~FCONDZ), "8,f,g", F_ALIAS, v9 }, -{ "fmovzd", F3F(2, 0x35, 0x0e2)|MCOND(FCONDZ), (1<<18)|F3F(~2, ~0x35, ~0x0e2)|MCOND(~FCONDZ), "9,f,g", F_ALIAS, v9 }, -{ "fmovzq", F3F(2, 0x35, 0x083)|(1<<18)|MCOND(CONDZ), F3F(~2, ~0x35, ~0x083)|MCOND(~CONDZ), "z,f,g", F_ALIAS, v9 }, -{ "fmovzq", F3F(2, 0x35, 0x083)|MCOND(FCONDZ), (1<<18)|F3F(~2, ~0x35, ~0x083)|MCOND(~FCONDZ), "6,f,g", F_ALIAS, v9 }, -{ "fmovzq", F3F(2, 0x35, 0x0a3)|(1<<18)|MCOND(CONDZ), F3F(~2, ~0x35, ~0x0a3)|MCOND(~CONDZ), "Z,f,g", F_ALIAS, v9 }, -{ "fmovzq", F3F(2, 0x35, 0x0a3)|MCOND(FCONDZ), (1<<18)|F3F(~2, ~0x35, ~0x0a3)|MCOND(~FCONDZ), "7,f,g", F_ALIAS, v9 }, -{ "fmovzq", F3F(2, 0x35, 0x0c3)|MCOND(FCONDZ), (1<<18)|F3F(~2, ~0x35, ~0x0c3)|MCOND(~FCONDZ), "8,f,g", F_ALIAS, v9 }, -{ "fmovzq", F3F(2, 0x35, 0x0e3)|MCOND(FCONDZ), (1<<18)|F3F(~2, ~0x35, ~0x0e3)|MCOND(~FCONDZ), "9,f,g", F_ALIAS, v9 }, -{ "fmovzs", F3F(2, 0x35, 0x081)|(1<<18)|MCOND(CONDZ), F3F(~2, ~0x35, ~0x081)|MCOND(~CONDZ), "z,f,g", F_ALIAS, v9 }, -{ "fmovzs", F3F(2, 0x35, 0x081)|MCOND(FCONDZ), (1<<18)|F3F(~2, ~0x35, ~0x081)|MCOND(~FCONDZ), "6,f,g", F_ALIAS, v9 }, -{ "fmovzs", F3F(2, 0x35, 0x0a1)|(1<<18)|MCOND(CONDZ), F3F(~2, ~0x35, ~0x0a1)|MCOND(~CONDZ), "Z,f,g", F_ALIAS, v9 }, -{ "fmovzs", F3F(2, 0x35, 0x0a1)|MCOND(FCONDZ), (1<<18)|F3F(~2, ~0x35, ~0x0a1)|MCOND(~FCONDZ), "7,f,g", F_ALIAS, v9 }, -{ "fmovzs", F3F(2, 0x35, 0x0c1)|MCOND(FCONDZ), (1<<18)|F3F(~2, ~0x35, ~0x0c1)|MCOND(~FCONDZ), "8,f,g", F_ALIAS, v9 }, -{ "fmovzs", F3F(2, 0x35, 0x0e1)|MCOND(FCONDZ), (1<<18)|F3F(~2, ~0x35, ~0x0e1)|MCOND(~FCONDZ), "9,f,g", F_ALIAS, v9 }, - -#define brfc(opcode, mask, lose) \ - { opcode, (mask), ANNUL|(lose), "l", F_DELAYED, v6 }, \ - { opcode, (mask)|ANNUL, (lose), ",a l", F_DELAYED, v6 } - -#define brfcx(opcode, mask, lose) /* v9 */ \ - { opcode, FBFCC(0)|(mask), ANNUL|BPRED|FBFCC(~0)|(lose), "6,G", F_DELAYED, v9 }, \ - { opcode, FBFCC(0)|(mask)|ANNUL, BPRED|FBFCC(~0)|(lose), ",a 6,G", F_DELAYED, v9 }, \ - { opcode, FBFCC(0)|(mask), ANNUL|BPRED|FBFCC(~0)|(lose), ",N 6,G", F_DELAYED, v9 }, \ - { opcode, FBFCC(0)|(mask)|ANNUL, BPRED|FBFCC(~0)|(lose), ",a,N 6,G", F_DELAYED, v9 }, \ - { opcode, FBFCC(0)|(mask)|BPRED, ANNUL|FBFCC(~0)|(lose), ",T 6,G", F_DELAYED, v9 }, \ - { opcode, FBFCC(0)|(mask)|BPRED|ANNUL, FBFCC(~0)|(lose), ",a,T 6,G", F_DELAYED, v9 }, \ - { opcode, FBFCC(1)|(mask), ANNUL|BPRED|FBFCC(~1)|(lose), "7,G", F_DELAYED, v9 }, \ - { opcode, FBFCC(1)|(mask)|ANNUL, BPRED|FBFCC(~1)|(lose), ",a 7,G", F_DELAYED, v9 }, \ - { opcode, FBFCC(1)|(mask), ANNUL|BPRED|FBFCC(~1)|(lose), ",N 7,G", F_DELAYED, v9 }, \ - { opcode, FBFCC(1)|(mask)|ANNUL, BPRED|FBFCC(~1)|(lose), ",a,N 7,G", F_DELAYED, v9 }, \ - { opcode, FBFCC(1)|(mask)|BPRED, ANNUL|FBFCC(~1)|(lose), ",T 7,G", F_DELAYED, v9 }, \ - { opcode, FBFCC(1)|(mask)|BPRED|ANNUL, FBFCC(~1)|(lose), ",a,T 7,G", F_DELAYED, v9 }, \ - { opcode, FBFCC(2)|(mask), ANNUL|BPRED|FBFCC(~2)|(lose), "8,G", F_DELAYED, v9 }, \ - { opcode, FBFCC(2)|(mask)|ANNUL, BPRED|FBFCC(~2)|(lose), ",a 8,G", F_DELAYED, v9 }, \ - { opcode, FBFCC(2)|(mask), ANNUL|BPRED|FBFCC(~2)|(lose), ",N 8,G", F_DELAYED, v9 }, \ - { opcode, FBFCC(2)|(mask)|ANNUL, BPRED|FBFCC(~2)|(lose), ",a,N 8,G", F_DELAYED, v9 }, \ - { opcode, FBFCC(2)|(mask)|BPRED, ANNUL|FBFCC(~2)|(lose), ",T 8,G", F_DELAYED, v9 }, \ - { opcode, FBFCC(2)|(mask)|BPRED|ANNUL, FBFCC(~2)|(lose), ",a,T 8,G", F_DELAYED, v9 }, \ - { opcode, FBFCC(3)|(mask), ANNUL|BPRED|FBFCC(~3)|(lose), "9,G", F_DELAYED, v9 }, \ - { opcode, FBFCC(3)|(mask)|ANNUL, BPRED|FBFCC(~3)|(lose), ",a 9,G", F_DELAYED, v9 }, \ - { opcode, FBFCC(3)|(mask), ANNUL|BPRED|FBFCC(~3)|(lose), ",N9,G", F_DELAYED, v9 }, \ - { opcode, FBFCC(3)|(mask)|ANNUL, BPRED|FBFCC(~3)|(lose), ",a,N 9,G", F_DELAYED, v9 }, \ - { opcode, FBFCC(3)|(mask)|BPRED, ANNUL|FBFCC(~3)|(lose), ",T 9,G", F_DELAYED, v9 }, \ - { opcode, FBFCC(3)|(mask)|BPRED|ANNUL, FBFCC(~3)|(lose), ",a,T 9,G", F_DELAYED, v9 } - -#define condfc(fop, cop, mask) \ - brfc(fop, F2(0, 6)|COND(mask), F2(~0, ~6)|COND(~(mask))), \ - brfcx(fop, F2(0, 5)|COND(mask), F2(~0, ~5)|COND(~(mask))), /* v9 */ \ - brfc(cop, F2(0, 7)|COND(mask), F2(~0, ~7)|COND(~(mask))) \ - -condfc("fb", "cb", 0x8), -condfc("fba", "cba", 0x8), -condfc("fbe", "cb0", 0x9), -condfc("fbg", "cb2", 0x6), -condfc("fbge", "cb02", 0xb), -condfc("fbl", "cb1", 0x4), -condfc("fble", "cb01", 0xd), -condfc("fblg", "cb12", 0x2), -condfc("fbn", "cbn", 0x0), -condfc("fbne", "cb123", 0x1), -condfc("fbo", "cb012", 0xf), -condfc("fbu", "cb3", 0x7), -condfc("fbue", "cb03", 0xa), -condfc("fbug", "cb23", 0x5), -condfc("fbuge", "cb023", 0xc), -condfc("fbul", "cb13", 0x3), -condfc("fbule", "cb013", 0xe), - -#undef condfc -#undef brfc - -{ "jmp", F3(2, 0x38, 0), F3(~2, ~0x38, ~0)|RD_G0|ASI(~0), "1+2", F_DELAYED, v6 }, /* jmpl rs1+rs2,%g0 */ -{ "jmp", F3(2, 0x38, 0), F3(~2, ~0x38, ~0)|RD_G0|ASI_RS2(~0), "1", F_DELAYED, v6 }, /* jmpl rs1+%g0,%g0 */ -{ "jmp", F3(2, 0x38, 1), F3(~2, ~0x38, ~1)|RD_G0, "1+i", F_DELAYED, v6 }, /* jmpl rs1+i,%g0 */ -{ "jmp", F3(2, 0x38, 1), F3(~2, ~0x38, ~1)|RD_G0, "i+1", F_DELAYED, v6 }, /* jmpl i+rs1,%g0 */ -{ "jmp", F3(2, 0x38, 1), F3(~2, ~0x38, ~1)|RD_G0|RS1_G0, "i", F_DELAYED, v6 }, /* jmpl %g0+i,%g0 */ - -{ "nop", F2(0, 4), F2(~0, ~4), "", 0, v6 }, /* sethi 0, %g0 */ - -{ "set", F2(0x0, 0x4), F2(~0x0, ~0x4), "Sh,d", F_ALIAS, v6 }, - -{ "sethi", F2(0x0, 0x4), F2(~0x0, ~0x4), "h,d", 0, v6 }, - -{ "taddcc", F3(2, 0x20, 0), F3(~2, ~0x20, ~0)|ASI(~0), "1,2,d", 0, v6 }, -{ "taddcc", F3(2, 0x20, 1), F3(~2, ~0x20, ~1), "1,i,d", 0, v6 }, -{ "taddcc", F3(2, 0x20, 1), F3(~2, ~0x20, ~1), "i,1,d", 0, v6 }, -{ "taddcctv", F3(2, 0x22, 0), F3(~2, ~0x22, ~0)|ASI(~0), "1,2,d", 0, v6 }, -{ "taddcctv", F3(2, 0x22, 1), F3(~2, ~0x22, ~1), "1,i,d", 0, v6 }, -{ "taddcctv", F3(2, 0x22, 1), F3(~2, ~0x22, ~1), "i,1,d", 0, v6 }, - -{ "tsubcc", F3(2, 0x21, 0), F3(~2, ~0x21, ~0)|ASI(~0), "1,2,d", 0, v6 }, -{ "tsubcc", F3(2, 0x21, 1), F3(~2, ~0x21, ~1), "1,i,d", 0, v6 }, -{ "tsubcctv", F3(2, 0x0b, 0), F3(~2, ~0x0b, ~0)|ASI(~0), "1,2,d", 0, v6 }, -{ "tsubcctv", F3(2, 0x0b, 1), F3(~2, ~0x0b, ~1), "1,i,d", 0, v6 }, - -{ "unimp", F2(0x0, 0x0), 0xffffffff, "l", 0, v6 }, - -{ "iflush", F3(2, 0x3b, 0), F3(~2, ~0x3b, ~0)|ASI(~0), "1+2", 0, v6 }, -{ "iflush", F3(2, 0x3b, 1), F3(~2, ~0x3b, ~1), "1+i", 0, v6 }, -{ "iflush", F3(2, 0x3b, 1), F3(~2, ~0x3b, ~1), "i+1", 0, v6 }, -{ "iflush", F3(2, 0x3b, 1), F3(~2, ~0x3b, ~1)|RS1_G0, "i", 0, v6 }, - -{ "xnor", F3(2, 0x07, 0), F3(~2, ~0x07, ~0)|ASI(~0), "1,2,d", 0, v6 }, -{ "xnor", F3(2, 0x07, 1), F3(~2, ~0x07, ~1), "1,i,d", 0, v6 }, -{ "xnor", F3(2, 0x07, 1), F3(~2, ~0x07, ~1), "i,1,d", 0, v6 }, -{ "xnorcc", F3(2, 0x17, 0), F3(~2, ~0x17, ~0)|ASI(~0), "1,2,d", 0, v6 }, -{ "xnorcc", F3(2, 0x17, 1), F3(~2, ~0x17, ~1), "1,i,d", 0, v6 }, -{ "xnorcc", F3(2, 0x17, 1), F3(~2, ~0x17, ~1), "i,1,d", 0, v6 }, -{ "xor", F3(2, 0x03, 0), F3(~2, ~0x03, ~0)|ASI(~0), "1,2,d", 0, v6 }, -{ "xor", F3(2, 0x03, 1), F3(~2, ~0x03, ~1), "1,i,d", 0, v6 }, -{ "xor", F3(2, 0x03, 1), F3(~2, ~0x03, ~1), "i,1,d", 0, v6 }, -{ "xorcc", F3(2, 0x13, 0), F3(~2, ~0x13, ~0)|ASI(~0), "1,2,d", 0, v6 }, -{ "xorcc", F3(2, 0x13, 1), F3(~2, ~0x13, ~1), "1,i,d", 0, v6 }, -{ "xorcc", F3(2, 0x13, 1), F3(~2, ~0x13, ~1), "i,1,d", 0, v6 }, - -{ "not", F3(2, 0x07, 0), F3(~2, ~0x07, ~0)|ASI(~0), "1,d", F_ALIAS, v6 }, /* xnor rs1,%0,rd */ -{ "not", F3(2, 0x07, 0), F3(~2, ~0x07, ~0)|ASI(~0), "r", F_ALIAS, v6 }, /* xnor rd,%0,rd */ - -{ "btog", F3(2, 0x03, 0), F3(~2, ~0x03, ~0)|ASI(~0), "2,r", F_ALIAS, v6 }, /* xor rd,rs2,rd */ -{ "btog", F3(2, 0x03, 1), F3(~2, ~0x03, ~1), "i,r", F_ALIAS, v6 }, /* xor rd,i,rd */ - -{ "fpop1", F3F(2, 0x34, 0), F3F(~2, ~0x34, ~1), "[1+2],d", 0, v6 }, -{ "fpop2", F3F(2, 0x35, 0), F3F(~2, ~0x35, ~1), "[1+2],d", 0, v6 }, - -/* float-start */ -{ "fdtoi", F3F(2, 0x34, 0x0d2), F3F(~2, ~0x34, ~0x0d2)|RS1_G0, "B,g", 0, v6 }, -{ "fstoi", F3F(2, 0x34, 0x0d1), F3F(~2, ~0x34, ~0x0d1)|RS1_G0, "f,g", 0, v6 }, - - /* all of these conversions are confused and probably wrong. */ -{ "fitod", F3F(2, 0x34, 0x0c8), F3F(~2, ~0x34, ~0x0c8)|RS1_G0, "f,H", 0, v6 }, -{ "fitos", F3F(2, 0x34, 0x0c4), F3F(~2, ~0x34, ~0x0c4)|RS1_G0, "f,g", 0, v6 }, - -{ "fitox", F3F(2, 0x34, 0x0cc), F3F(~2, ~0x34, ~0x0cc)|RS1_G0, "f,g", 0, v6 }, /* collides in mneumonic with cypress */ - /* fitox collides in opf between cypress and v8, mneumonic between v6 and cypress */ -{ "fitox", F3F(2, 0x34, 0x0cc), F3F(~2, ~0x34, ~0x0cc)|RS1_G0, "f,g", 0, cypress }, /* collides */ -{ "fitoq", F3F(2, 0x34, 0x0cc), F3F(~2, ~0x34, ~0x0cc)|RS1_G0, "f,J", 0, v8 }, /* collides in opf with cypress */ - -{ "fxtoq", F3F(2, 0x34, 0x08c), F3F(~2, ~0x34, ~0x08c)|RS1_G0, "f,J", 0, v9 }, - -{ "fdtoq", F3F(2, 0x34, 0x0ce), F3F(~2, ~0x34, ~0x0ce)|RS1_G0, "B,J", 0, v8 }, -{ "fdtos", F3F(2, 0x34, 0x0c6), F3F(~2, ~0x34, ~0x0c6)|RS1_G0, "B,g", 0, v6 }, -{ "fqtod", F3F(2, 0x34, 0x0cb), F3F(~2, ~0x34, ~0x0cb)|RS1_G0, "R,H", 0, v8 }, -{ "fqtos", F3F(2, 0x34, 0x0c7), F3F(~2, ~0x34, ~0x0c7)|RS1_G0, "R,g", 0, v8 }, -{ "fstod", F3F(2, 0x34, 0x0c9), F3F(~2, ~0x34, ~0x0c9)|RS1_G0, "f,H", 0, v6 }, -{ "fstoq", F3F(2, 0x34, 0x0cd), F3F(~2, ~0x34, ~0x0cd)|RS1_G0, "f,J", 0, v8 }, - -{ "fqtox", F3F(2, 0x34, 0x083), F3F(~2, ~0x34, ~0x083)|RS1_G0, "R,g", 0, v9 }, - -{ "fxtos", F3F(2, 0x34, 0x0c7), F3F(~2, ~0x34, ~0x0c7)|RS1_G0, "f,g", 0, v7 }, /* these collide on the mneumonic */ -{ "fxtos", F3F(2, 0x34, 0x084), F3F(~2, ~0x34, ~0x084)|RS1_G0, "f,g", 0, v9 }, -{ "fxtos", F3F(2, 0x34, 0x0c7), F3F(~2, ~0x34, ~0x0c7)|RS1_G0, "f,g", 0, cypress }, - -{ "fdtox", F3F(2, 0x34, 0x0ce), F3F(~2, ~0x34, ~0x0ce)|RS1_G0, "B,g", 0, cypress }, /* mneumonic collisions */ -{ "fdtox", F3F(2, 0x34, 0x082), F3F(~2, ~0x34, ~0x082)|RS1_G0, "B,g", 0, v9 }, - -{ "fstox", F3F(2, 0x34, 0x0cd), F3F(~2, ~0x34, ~0x0cd)|RS1_G0, "f,g", 0, cypress }, -{ "fstox", F3F(2, 0x34, 0x081), F3F(~2, ~0x34, ~0x081)|RS1_G0, "f,g", 0, v9 }, - -{ "fqtoi", F3F(2, 0x34, 0x0d3), F3F(~2, ~0x34, ~0x0d3)|RS1_G0, "R,g", 0, v8 }, -{ "fxtoi", F3F(2, 0x34, 0x0d3), F3F(~2, ~0x34, ~0x0d3)|RS1_G0, "f,g", 0, cypress }, - -{ "fxtod", F3F(2, 0x34, 0x0cb), F3F(~2, ~0x34, ~0x0cb)|RS1_G0, "f,H", 0, cypress }, /* collide in opf & mneumonic */ -{ "fxtod", F3F(2, 0x34, 0x088), F3F(~2, ~0x34, ~0x088)|RS1_G0, "f,H", 0, v9 }, - -{ "fdivd", F3F(2, 0x34, 0x04e), F3F(~2, ~0x34, ~0x04e), "v,B,H", 0, v6 }, -{ "fdivq", F3F(2, 0x34, 0x04f), F3F(~2, ~0x34, ~0x04f), "V,R,J", 0, v8 }, -{ "fdivs", F3F(2, 0x34, 0x04d), F3F(~2, ~0x34, ~0x04d), "e,f,g", 0, v6 }, -{ "fdivx", F3F(2, 0x34, 0x04f), F3F(~2, ~0x34, ~0x04f), "e,f,g", 0, cypress }, -{ "fmuld", F3F(2, 0x34, 0x04a), F3F(~2, ~0x34, ~0x04a), "v,B,H", 0, v6 }, -{ "fmulq", F3F(2, 0x34, 0x04b), F3F(~2, ~0x34, ~0x04b), "V,R,J", 0, v8 }, -{ "fmuls", F3F(2, 0x34, 0x049), F3F(~2, ~0x34, ~0x049), "e,f,g", 0, v6 }, -{ "fmulx", F3F(2, 0x34, 0x04b), F3F(~2, ~0x34, ~0x04b), "e,f,g", 0, cypress }, - -{ "fdmulq", F3F(2, 0x34, 0x06e), F3F(~2, ~0x34, ~0x06e), "v,B,J", 0, v8 }, -{ "fsmuld", F3F(2, 0x34, 0x069), F3F(~2, ~0x34, ~0x069), "e,f,H", 0, v8 }, - -{ "fsqrtd", F3F(2, 0x34, 0x02a), F3F(~2, ~0x34, ~0x02a)|RS1_G0, "B,H", 0, v7 }, -{ "fsqrtq", F3F(2, 0x34, 0x02b), F3F(~2, ~0x34, ~0x02b)|RS1_G0, "R,J", 0, v8 }, -{ "fsqrts", F3F(2, 0x34, 0x029), F3F(~2, ~0x34, ~0x029)|RS1_G0, "f,g", 0, v7 }, -{ "fsqrtx", F3F(2, 0x34, 0x02b), F3F(~2, ~0x34, ~0x02b)|RS1_G0, "f,g", 0, cypress }, - -{ "fabsd", F3F(2, 0x34, 0x00a), F3F(~2, ~0x34, ~0x00a)|RS1_G0, "B,H", 0, v9 }, -{ "fabsq", F3F(2, 0x34, 0x00b), F3F(~2, ~0x34, ~0x00b)|RS1_G0, "R,J", 0, v6 }, -{ "fabss", F3F(2, 0x34, 0x009), F3F(~2, ~0x34, ~0x009)|RS1_G0, "f,g", 0, v6 }, -{ "fmovd", F3F(2, 0x34, 0x002), F3F(~2, ~0x34, ~0x002)|RS1_G0, "B,H", 0, v9 }, -{ "fmovq", F3F(2, 0x34, 0x003), F3F(~2, ~0x34, ~0x003)|RS1_G0, "R,J", 0, v6 }, -{ "fmovs", F3F(2, 0x34, 0x001), F3F(~2, ~0x34, ~0x001)|RS1_G0, "f,g", 0, v6 }, -{ "fnegd", F3F(2, 0x34, 0x006), F3F(~2, ~0x34, ~0x006)|RS1_G0, "B,H", 0, v9 }, -{ "fnegq", F3F(2, 0x34, 0x007), F3F(~2, ~0x34, ~0x007)|RS1_G0, "R,J", 0, v6 }, -{ "fnegs", F3F(2, 0x34, 0x005), F3F(~2, ~0x34, ~0x005)|RS1_G0, "f,g", 0, v6 }, - -{ "popc", F3(2, 0x2d, 0), F3(~2, ~0x2d, ~0)|(0x3fff<<5), "2,d", 0, v9 }, - -{ "faddd", F3F(2, 0x34, 0x042), F3F(~2, ~0x34, ~0x042), "v,B,H", 0, v6 }, -{ "faddq", F3F(2, 0x34, 0x043), F3F(~2, ~0x34, ~0x043), "V,R,J", 0, v8 }, -{ "fadds", F3F(2, 0x34, 0x041), F3F(~2, ~0x34, ~0x041), "e,f,g", 0, v6 }, -{ "faddx", F3F(2, 0x34, 0x043), F3F(~2, ~0x34, ~0x043), "e,f,g", 0, cypress }, -{ "fsubd", F3F(2, 0x34, 0x046), F3F(~2, ~0x34, ~0x046), "v,B,H", 0, v6 }, -{ "fsubq", F3F(2, 0x34, 0x047), F3F(~2, ~0x34, ~0x047), "V,R,J", 0, v8 }, -{ "fsubs", F3F(2, 0x34, 0x045), F3F(~2, ~0x34, ~0x045), "e,f,g", 0, v6 }, -{ "fsubx", F3F(2, 0x34, 0x047), F3F(~2, ~0x34, ~0x047), "e,f,g", 0, cypress }, - -#define CMPFCC(x) (((x)&0x3)<<25) - -{ "fcmpd", F3F(2, 0x35, 0x052), F3F(~2, ~0x35, ~0x052)|RS1_G0, "v,B", 0, v6 }, -{ "fcmpd", CMPFCC(0)|F3F(2, 0x35, 0x052), CMPFCC(~0)|F3F(~2, ~0x35, ~0x052), "6,v,B", 0, v9 }, -{ "fcmpd", CMPFCC(1)|F3F(2, 0x35, 0x052), CMPFCC(~1)|F3F(~2, ~0x35, ~0x052), "7,v,B", 0, v9 }, -{ "fcmpd", CMPFCC(2)|F3F(2, 0x35, 0x052), CMPFCC(~2)|F3F(~2, ~0x35, ~0x052), "8,v,B", 0, v9 }, -{ "fcmpd", CMPFCC(3)|F3F(2, 0x35, 0x052), CMPFCC(~3)|F3F(~2, ~0x35, ~0x052), "9,v,B", 0, v9 }, -{ "fcmped", F3F(2, 0x35, 0x056), F3F(~2, ~0x35, ~0x056)|RS1_G0, "v,B", 0, v6 }, -{ "fcmped", CMPFCC(0)|F3F(2, 0x35, 0x056), CMPFCC(~0)|F3F(~2, ~0x35, ~0x056), "6,v,B", 0, v9 }, -{ "fcmped", CMPFCC(1)|F3F(2, 0x35, 0x056), CMPFCC(~1)|F3F(~2, ~0x35, ~0x056), "7,v,B", 0, v9 }, -{ "fcmped", CMPFCC(2)|F3F(2, 0x35, 0x056), CMPFCC(~2)|F3F(~2, ~0x35, ~0x056), "8,v,B", 0, v9 }, -{ "fcmped", CMPFCC(3)|F3F(2, 0x35, 0x056), CMPFCC(~3)|F3F(~2, ~0x35, ~0x056), "9,v,B", 0, v9 }, -{ "fcmpeq", F3F(2, 0x34, 0x057), F3F(~2, ~0x34, ~0x057), "V,R,J", 0, v8 }, -{ "fcmpeq", CMPFCC(0)|F3F(2, 0x35, 0x057), CMPFCC(~0)|F3F(~2, ~0x35, ~0x057), "6,V,R", 0, v9 }, -{ "fcmpeq", CMPFCC(1)|F3F(2, 0x35, 0x057), CMPFCC(~1)|F3F(~2, ~0x35, ~0x057), "7,V,R", 0, v9 }, -{ "fcmpeq", CMPFCC(2)|F3F(2, 0x35, 0x057), CMPFCC(~2)|F3F(~2, ~0x35, ~0x057), "8,V,R", 0, v9 }, -{ "fcmpeq", CMPFCC(3)|F3F(2, 0x35, 0x057), CMPFCC(~3)|F3F(~2, ~0x35, ~0x057), "9,V,R", 0, v9 }, -{ "fcmpes", F3F(2, 0x35, 0x055), F3F(~2, ~0x35, ~0x055)|RS1_G0, "e,f", 0, v6 }, -{ "fcmpes", CMPFCC(0)|F3F(2, 0x35, 0x055), CMPFCC(~0)|F3F(~2, ~0x35, ~0x055), "6,e,f", 0, v9 }, -{ "fcmpes", CMPFCC(1)|F3F(2, 0x35, 0x055), CMPFCC(~1)|F3F(~2, ~0x35, ~0x055), "7,e,f", 0, v9 }, -{ "fcmpes", CMPFCC(2)|F3F(2, 0x35, 0x055), CMPFCC(~2)|F3F(~2, ~0x35, ~0x055), "8,e,f", 0, v9 }, -{ "fcmpes", CMPFCC(3)|F3F(2, 0x35, 0x055), CMPFCC(~3)|F3F(~2, ~0x35, ~0x055), "9,e,f", 0, v9 }, -{ "fcmpex", F3F(2, 0x35, 0x057), F3F(~2, ~0x35, ~0x057)|RS1_G0, "e,f", 0, cypress }, -{ "fcmpq", F3F(2, 0x34, 0x053), F3F(~2, ~0x34, ~0x053), "V,R,J", 0, v8 }, -{ "fcmpq", CMPFCC(0)|F3F(2, 0x35, 0x053), CMPFCC(~0)|F3F(~2, ~0x35, ~0x053), "6,V,R", 0, v9 }, -{ "fcmpq", CMPFCC(1)|F3F(2, 0x35, 0x053), CMPFCC(~1)|F3F(~2, ~0x35, ~0x053), "7,V,R", 0, v9 }, -{ "fcmpq", CMPFCC(2)|F3F(2, 0x35, 0x053), CMPFCC(~2)|F3F(~2, ~0x35, ~0x053), "8,V,R", 0, v9 }, -{ "fcmpq", CMPFCC(3)|F3F(2, 0x35, 0x053), CMPFCC(~3)|F3F(~2, ~0x35, ~0x053), "9,V,R", 0, v9 }, -{ "fcmps", F3F(2, 0x35, 0x051), F3F(~2, ~0x35, ~0x051)|RS1_G0, "e,f", 0, v6 }, -{ "fcmps", CMPFCC(0)|F3F(2, 0x35, 0x051), CMPFCC(~0)|F3F(~2, ~0x35, ~0x051), "6,e,f", 0, v9 }, -{ "fcmps", CMPFCC(1)|F3F(2, 0x35, 0x051), CMPFCC(~1)|F3F(~2, ~0x35, ~0x051), "7,e,f", 0, v9 }, -{ "fcmps", CMPFCC(2)|F3F(2, 0x35, 0x051), CMPFCC(~2)|F3F(~2, ~0x35, ~0x051), "8,e,f", 0, v9 }, -{ "fcmps", CMPFCC(3)|F3F(2, 0x35, 0x051), CMPFCC(~3)|F3F(~2, ~0x35, ~0x051), "9,e,f", 0, v9 }, -{ "fcmpx", F3F(2, 0x35, 0x053), F3F(~2, ~0x35, ~0x053)|RS1_G0, "e,f", 0, cypress }, - -{ "cpop1", F3(2, 0x36, 0), F3(~2, ~0x36, ~1), "[1+2],d", 0, v6 }, -{ "cpop2", F3(2, 0x37, 0), F3(~2, ~0x37, ~1), "[1+2],d", 0, v6 }, - -{ "casx", F3(3, 0x0c, 1), F3(~3, ~0x0c, ~1), "[1],2,d", 0, v9 }, -{ "casxa", F3(3, 0x1c, 1), F3(~3, ~0x1c, ~1), "[1]A,2,d", 0, v9 }, -{ "cas", F3(3, 0x0c, 0), F3(~3, ~0x0c, ~0), "[1],2,d", 0, v9 }, -{ "casa", F3(3, 0x1c, 0), F3(~3, ~0x1c, ~0), "[1]A,2,d", 0, v9 }, - -{ "fmaddd", F3(2, 0x35, 0)|OPF_LOW(0xa), F3(~2, ~0x35, ~0)|OPF_LOW(~0xa), "v,B,u,H", 0, v9 }, -{ "fmaddq", F3(2, 0x35, 0)|OPF_LOW(0xb), F3(~2, ~0x35, ~0)|OPF_LOW(~0xb), "V,R,U,J", 0, v9 }, -{ "fmadds", F3(2, 0x35, 0)|OPF_LOW(0x9), F3(~2, ~0x35, ~0)|OPF_LOW(~0x9), "e,f,j,g", 0, v9 }, -{ "fmsubd", F3(2, 0x35, 0)|OPF_LOW(0xe), F3(~2, ~0x35, ~0)|OPF_LOW(~0xe), "v,B,u,H", 0, v9 }, -{ "fmsubq", F3(2, 0x35, 0)|OPF_LOW(0xf), F3(~2, ~0x35, ~0)|OPF_LOW(~0xf), "V,R,U,J", 0, v9 }, -{ "fmsubs", F3(2, 0x35, 0)|OPF_LOW(0xd), F3(~2, ~0x35, ~0)|OPF_LOW(~0xd), "e,f,j,g", 0, v9 }, - -}; - -#define NUMOPCODES ((sizeof sparc_opcodes)/(sizeof sparc_opcodes[0])) - -/* - * Local Variables: - * fill-column: 131 - * comment-column: 0 - * End: - */ - -/* end of sparc-opcode.h */ diff --git a/include/stab.def b/include/stab.def deleted file mode 100755 index c9d434c15b5..00000000000 --- a/include/stab.def +++ /dev/null @@ -1,262 +0,0 @@ -/* Table of DBX symbol codes for the GNU system. - Copyright (C) 1988, 1991 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Global variable. Only the name is significant. - To find the address, look in the corresponding external symbol. */ -__define_stab (N_GSYM, 0x20, "GSYM") - -/* Function name for BSD Fortran. Only the name is significant. - To find the address, look in the corresponding external symbol. */ -__define_stab (N_FNAME, 0x22, "FNAME") - -/* Function name or text-segment variable for C. Value is its address. - Desc is supposedly starting line number, but GCC doesn't set it - and DBX seems not to miss it. */ -__define_stab (N_FUN, 0x24, "FUN") - -/* Data-segment variable with internal linkage. Value is its address. - "Static Sym". */ -__define_stab (N_STSYM, 0x26, "STSYM") - -/* BSS-segment variable with internal linkage. Value is its address. */ -__define_stab (N_LCSYM, 0x28, "LCSYM") - -/* Name of main routine. Only the name is significant. - This is not used in C. */ -__define_stab (N_MAIN, 0x2a, "MAIN") - -/* Global symbol in Pascal. - Supposedly the value is its line number; I'm skeptical. */ -__define_stab (N_PC, 0x30, "PC") - -/* Number of symbols: 0, files,,funcs,lines according to Ultrix V4.0. */ -__define_stab (N_NSYMS, 0x32, "NSYMS") - -/* "No DST map for sym: name, ,0,type,ignored" according to Ultrix V4.0. */ -__define_stab (N_NOMAP, 0x34, "NOMAP") - -/* Register variable. Value is number of register. */ -__define_stab (N_RSYM, 0x40, "RSYM") - -/* Modula-2 compilation unit. Can someone say what info it contains? */ -__define_stab (N_M2C, 0x42, "M2C") - -/* Line number in text segment. Desc is the line number; - value is corresponding address. */ -__define_stab (N_SLINE, 0x44, "SLINE") - -/* Similar, for data segment. */ -__define_stab (N_DSLINE, 0x46, "DSLINE") - -/* Similar, for bss segment. */ -__define_stab (N_BSLINE, 0x48, "BSLINE") - -/* Sun's source-code browser stabs. ?? Don't know what the fields are. - Supposedly the field is "path to associated .cb file". THIS VALUE - OVERLAPS WITH N_BSLINE! */ -__define_stab (N_BROWS, 0x48, "BROWS") - -/* GNU Modula-2 definition module dependency. Value is the modification time - of the definition file. Other is non-zero if it is imported with the - GNU M2 keyword %INITIALIZE. Perhaps N_M2C can be used if there - are enough empty fields? */ -__define_stab(N_DEFD, 0x4a, "DEFD") - -/* THE FOLLOWING TWO STAB VALUES CONFLICT. Happily, one is for Modula-2 - and one is for C++. Still,... */ -/* GNU C++ exception variable. Name is variable name. */ -__define_stab (N_EHDECL, 0x50, "EHDECL") -/* Modula2 info "for imc": name,,0,0,0 according to Ultrix V4.0. */ -__define_stab (N_MOD2, 0x50, "MOD2") - -/* GNU C++ `catch' clause. Value is its address. Desc is nonzero if - this entry is immediately followed by a CAUGHT stab saying what exception - was caught. Multiple CAUGHT stabs means that multiple exceptions - can be caught here. If Desc is 0, it means all exceptions are caught - here. */ -__define_stab (N_CATCH, 0x54, "CATCH") - -/* Structure or union element. Value is offset in the structure. */ -__define_stab (N_SSYM, 0x60, "SSYM") - -/* Name of main source file. - Value is starting text address of the compilation. */ -__define_stab (N_SO, 0x64, "SO") - -/* Automatic variable in the stack. Value is offset from frame pointer. - Also used for type descriptions. */ -__define_stab (N_LSYM, 0x80, "LSYM") - -/* Beginning of an include file. Only Sun uses this. - In an object file, only the name is significant. - The Sun linker puts data into some of the other fields. */ -__define_stab (N_BINCL, 0x82, "BINCL") - -/* Name of sub-source file (#include file). - Value is starting text address of the compilation. */ -__define_stab (N_SOL, 0x84, "SOL") - -/* Parameter variable. Value is offset from argument pointer. - (On most machines the argument pointer is the same as the frame pointer. */ -__define_stab (N_PSYM, 0xa0, "PSYM") - -/* End of an include file. No name. - This and N_BINCL act as brackets around the file's output. - In an object file, there is no significant data in this entry. - The Sun linker puts data into some of the fields. */ -__define_stab (N_EINCL, 0xa2, "EINCL") - -/* Alternate entry point. Value is its address. */ -__define_stab (N_ENTRY, 0xa4, "ENTRY") - -/* Beginning of lexical block. - The desc is the nesting level in lexical blocks. - The value is the address of the start of the text for the block. - The variables declared inside the block *precede* the N_LBRAC symbol. */ -__define_stab (N_LBRAC, 0xc0, "LBRAC") - -/* Place holder for deleted include file. Replaces a N_BINCL and everything - up to the corresponding N_EINCL. The Sun linker generates these when - it finds multiple identical copies of the symbols from an include file. - This appears only in output from the Sun linker. */ -__define_stab (N_EXCL, 0xc2, "EXCL") - -/* Modula-2 scope information. Can someone say what info it contains? */ -__define_stab (N_SCOPE, 0xc4, "SCOPE") - -/* End of a lexical block. Desc matches the N_LBRAC's desc. - The value is the address of the end of the text for the block. */ -__define_stab (N_RBRAC, 0xe0, "RBRAC") - -/* Begin named common block. Only the name is significant. */ -__define_stab (N_BCOMM, 0xe2, "BCOMM") - -/* End named common block. Only the name is significant - (and it should match the N_BCOMM). */ -__define_stab (N_ECOMM, 0xe4, "ECOMM") - -/* End common (local name): value is address. - I'm not sure how this is used. */ -__define_stab (N_ECOML, 0xe8, "ECOML") - -/* These STAB's are used on Gould systems for Non-Base register symbols - or something like that. FIXME. I have assigned the values at random - since I don't have a Gould here. Fixups from Gould folk welcome... */ -__define_stab (N_NBTEXT, 0xF0, "NBTEXT") -__define_stab (N_NBDATA, 0xF2, "NBDATA") -__define_stab (N_NBBSS, 0xF4, "NBBSS") -__define_stab (N_NBSTS, 0xF6, "NBSTS") -__define_stab (N_NBLCS, 0xF8, "NBLCS") - -/* Second symbol entry containing a length-value for the preceding entry. - The value is the length. */ -__define_stab (N_LENG, 0xfe, "LENG") - -#ifdef GNU_EXTRA_STABS -/* These are defined in a.out.gnu.h, so they are usually left out here. */ - -/* The following symbols refer to set elements. - All the N_SET[ATDB] symbols with the same name form one set. - Space is allocated for the set in the text section, and each set - element's value is stored into one word of the space. - The first word of the space is the length of the set (number of elements). - - The address of the set is made into an N_SETV symbol - whose name is the same as the name of the set. - This symbol acts like a N_DATA global symbol - in that it can satisfy undefined external references. */ - -/* These appear as input to LD, in a .o file. */ -__define_stab (N_SETA, 0x14, "SETA") /* Absolute set element symbol */ -__define_stab (N_SETT, 0x16, "SETT") /* Text set element symbol */ -__define_stab (N_SETD, 0x18, "SETD") /* Data set element symbol */ -__define_stab (N_SETB, 0x1A, "SETB") /* Bss set element symbol */ - -/* This is output from LD. */ -__define_stab (N_SETV, 0x1C, "SETV") /* Pointer to set vector in data area. */ - -/* The following type indicates the definition of a symbol as being - an indirect reference to another symbol. The other symbol - appears as an undefined reference, immediately following this symbol. - - Indirection is asymmetrical. The other symbol's value will be used - to satisfy requests for the indirect symbol, but not vice versa. - If the other symbol does not have a definition, libraries will - be searched to find a definition. */ - -__define_stab (N_INDR, 0xa, "INDR") - -/* Warning symbol. The text gives a warning message, the next symbol - in the table will be undefined. When the symbol is referenced, the - message is printed. */ - -__define_stab (N_WARNING, 0x1e, "WARNING") -#endif - -/* The above information, in matrix format. - - STAB MATRIX - _________________________________________________ - | 00 - 1F are not dbx stab symbols | - | In most cases, the low bit is the EXTernal bit| - - | 00 UNDEF | 02 ABS | 04 TEXT | 06 DATA | - | 01 |EXT | 03 |EXT | 05 |EXT | 07 |EXT | - - | 08 BSS | 0A INDR | 0C FN_SEQ | 0E | - | 09 |EXT | 0B | 0D | 0F | - - | 10 | 12 COMM | 14 SETA | 16 SETT | - | 11 | 13 | 15 | 17 | - - | 18 SETD | 1A SETB | 1C SETV | 1E WARNING| - | 19 | 1B | 1D | 1F FN | - - |_______________________________________________| - | Debug entries with bit 01 set are unused. | - | 20 GSYM | 22 FNAME | 24 FUN | 26 STSYM | - | 28 LCSYM | 2A MAIN | 2C | 2E | - | 30 PC | 32 NSYMS | 34 NOMAP | 36 | - | 38 | 3A | 3C | 3E | - | 40 RSYM | 42 M2C | 44 SLINE | 46 DSLINE | - | 48 BSLINE*| 4A DEFD | 4C | 4E | - | 50 EHDECL*| 52 | 54 CATCH | 56 | - | 58 | 5A | 5C | 5E | - | 60 SSYM | 62 | 64 SO | 66 | - | 68 | 6A | 6C | 6E | - | 70 | 72 | 74 | 76 | - | 78 | 7A | 7C | 7E | - | 80 LSYM | 82 BINCL | 84 SOL | 86 | - | 88 | 8A | 8C | 8E | - | 90 | 92 | 94 | 96 | - | 98 | 9A | 9C | 9E | - | A0 PSYM | A2 EINCL | A4 ENTRY | A6 | - | A8 | AA | AC | AE | - | B0 | B2 | B4 | B6 | - | B8 | BA | BC | BE | - | C0 LBRAC | C2 EXCL | C4 SCOPE | C6 | - | C8 | CA | CC | CE | - | D0 | D2 | D4 | D6 | - | D8 | DA | DC | DE | - | E0 RBRAC | E2 BCOMM | E4 ECOMM | E6 | - | E8 ECOML | EA | EC | EE | - | F0 | F2 | F4 | F6 | - | F8 | FA | FC | FE LENG | - +-----------------------------------------------+ - * 50 EHDECL is also MOD2. - * 48 BSLINE is also BROWS. - */ diff --git a/include/stab.gnu.h b/include/stab.gnu.h deleted file mode 100755 index 80bd594a36a..00000000000 --- a/include/stab.gnu.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef __GNU_STAB__ - -/* Indicate the GNU stab.h is in use. */ - -#define __GNU_STAB__ - -#define __define_stab(NAME, CODE, STRING) NAME=CODE, - -enum __stab_debug_code -{ -#include "stab.def" -LAST_UNUSED_STAB_CODE -}; - -#undef __define_stab - -#endif /* __GNU_STAB_ */ diff --git a/include/sysdep.h b/include/sysdep.h deleted file mode 100755 index f2c8d1d2a54..00000000000 --- a/include/sysdep.h +++ /dev/null @@ -1,171 +0,0 @@ -/* All the system include files boiled into one place (sort of). - Copyright 1990, 1991 Free Software Foundation, Inc. - Contributed by Cygnus Support. - -This file is part of BFD and the GNU Binutils. Please don't use it for -other programs; better configuration mechanisms than this are needed. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* All the system include files boiled into one place. - - One day, everyone will have the same set of include files.. - - This is ugly, but if you can think of a better way of doing this, - tell me. --steve@cygnus.com */ - -#ifndef _SYSDEP_H -#define _SYSDEP_H - -/* - The including makefile must define HOST_SYS to be one of these. - Each combination of Machine and OS (and maybe OS Version) must - have a different number. - */ - -#define SUN4_SYS 2 -#define POSIX_SYS 3 -#define AIX_SYS 4 -#define VAX_ULTRIX_SYS 5 -#define i386_SYSV_SYS 6 -#define SUN3_SYS 7 -#define UNKNOWN_SYS 8 -#define DGUX_SYS 9 -#define DEC3100_SYS 10 -#define HP9000_SYS 11 -#define APOLLO400_SYS 12 -#define DOS_SYS 13 -#define VAX_BSD_SYS 14 -#define TAHOE_BSD_SYS 15 -#define RTBSD_SYS 16 /* IBM RT/PC running bsd Unix */ -#define IRIX3_SYS 17 /* SGI Iris running irix 3.x */ -#define IRIX4_SYS 18 /* SGI Iris running cypress */ -#define HP300BSD_SYS 19 -#define ULTRA3_SYS 20 /* NYU Ultracomputer */ -#define NEWSOS3_SYS 21 /* Sony NewsOS 3.x (bsd-4.3 based) */ -#define AMIX_SYS 22 /* Amiga Unix */ -#define i386_MACH_SYS 23 /* Mach on Intel 386 */ - -#include - -#if __STDC__ -#define PROTO(type, name, arglist) type name arglist -#else -#define PROTO(type, name, arglist) type name () -#define NO_STDARG -#endif - -#ifndef HOST_SYS -#define HOST_SYS = Hey_you_HOST_SYS_has_not_been_defined. -#endif - -#if HOST_SYS==SUN4_SYS -#define HOST_IS_SUN4 1 -#include -#endif - -#if HOST_SYS==DGUX_SYS -#include -#endif - -#if HOST_SYS==POSIX_SYS -#define HOST_IS_POSIX 1 -#endif - -#if HOST_SYS==AIX_SYS -#define HOST_IS_AIX 1 -#include -#endif - -#if HOST_SYS==VAX_ULTRIX_SYS -#define HOST_IS_VAX_ULTRIX 1 -#include -#endif - -#if HOST_SYS==i386_SYSV_SYS -#define HOST_IS_i386_SYSV 1 -#define USG -#include -#endif - -#if HOST_SYS==SUN3_SYS -#define HOST_IS_SUN3 1 -#include -#endif - -#if HOST_SYS==NEWSOS3_SYS -#define HOST_IS_SUN3 1 /* Lie - should be close enough */ -#include /* Probably good enough */ -#define MISSING_VFPRINTF -#endif - -#if HOST_SYS==DEC3100_SYS -#define HOST_IS_DEC3100 1 -#include -#endif - -#if HOST_SYS==HP9000_SYS -#define HOST_IS_HP9000 1 -#define USG -#include -#endif - -#if HOST_SYS==APOLLO400_SYS -#define HOST_IS_APOLLO400 1 -#include -#endif - -#if HOST_SYS==DOS_SYS -#define HOST_IS_DOS 1 -#include -#endif - -#if HOST_SYS == VAX_BSD_SYS -#include -#endif - -#if HOST_SYS == TAHOE_BSD_SYS -#include -#endif - -#if HOST_SYS == RTBSD_SYS -#include -#endif - -#if HOST_SYS == IRIX3_SYS -#include -#endif - -#if HOST_SYS == IRIX4_SYS -#include -#endif - -#if HOST_SYS == HP300BSD_SYS -#include -#endif - -#if HOST_SYS == ULTRA3_SYS -#include -#endif - -#if HOST_SYS == AMIX_SYS -#include -#endif - -#if HOST_SYS == i386_MACH_SYS -#include -#endif - -#endif /* _SYSDEP_H */ diff --git a/include/tahoe-opcode.h b/include/tahoe-opcode.h deleted file mode 100755 index b5cee249ee4..00000000000 --- a/include/tahoe-opcode.h +++ /dev/null @@ -1,213 +0,0 @@ -/* - * Ported by the State University of New York at Buffalo by the Distributed - * Computer Systems Lab, Department of Computer Science, 1991. - */ - -#ifndef tahoe_opcodeT -#define tahoe_opcodeT int -#endif /* no tahoe_opcodeT */ - -struct vot_wot /* tahoe opcode table: wot to do with this */ - /* particular opcode */ -{ - char * args; /* how to compile said opcode */ - tahoe_opcodeT code; /* op-code (may be > 8 bits!) */ -}; - -struct vot /* tahoe opcode text */ -{ - char * name; /* opcode name: lowercase string [key] */ - struct vot_wot detail; /* rest of opcode table [datum] */ -}; - -#define vot_how args -#define vot_code code -#define vot_detail detail -#define vot_name name - -static struct vot -votstrs[] = -{ -{ "halt", {"", 0x00 } }, -{ "sinf", {"", 0x05 } }, -{ "ldf", {"rl", 0x06 } }, -{ "ldd", {"rq", 0x07 } }, -{ "addb2", {"rbmb", 0x08 } }, -{ "movb", {"rbwb", 0x09 } }, -{ "addw2", {"rwmw", 0x0a } }, -{ "movw", {"rwww", 0x0b } }, -{ "addl2", {"rlml", 0x0c } }, -{ "movl", {"rlwl", 0x0d } }, -{ "bbs", {"rlvlbw", 0x0e } }, -{ "nop", {"", 0x10 } }, -{ "brb", {"bb", 0x11 } }, -{ "brw", {"bw", 0x13 } }, -{ "cosf", {"", 0x15 } }, -{ "lnf", {"rl", 0x16 } }, -{ "lnd", {"rq", 0x17 } }, -{ "addb3", {"rbrbwb", 0x18 } }, -{ "cmpb", {"rbwb", 0x19 } }, -{ "addw3", {"rwrwww", 0x1a } }, -{ "cmpw", {"rwww", 0x1b } }, -{ "addl3", {"rlrlwl", 0x1c } }, -{ "cmpl", {"rlwl", 0x1d } }, -{ "bbc", {"rlvlbw", 0x1e } }, -{ "rei", {"", 0x20 } }, -{ "bneq", {"bb", 0x21 } }, -{ "bnequ", {"bb", 0x21 } }, -{ "cvtwl", {"rwwl", 0x23 } }, -{ "stf", {"wl", 0x26 } }, -{ "std", {"wq", 0x27 } }, -{ "subb2", {"rbmb", 0x28 } }, -{ "mcomb", {"rbwb", 0x29 } }, -{ "subw2", {"rwmw", 0x2a } }, -{ "mcomw", {"rwww", 0x2b } }, -{ "subl2", {"rlml", 0x2c } }, -{ "mcoml", {"rlwl", 0x2d } }, -{ "emul", {"rlrlrlwq", 0x2e } }, -{ "aoblss", {"rlmlbw", 0x2f } }, -{ "bpt", {"", 0x30 } }, -{ "beql", {"bb", 0x31 } }, -{ "beqlu", {"bb", 0x31 } }, -{ "cvtwb", {"rwwb", 0x33 } }, -{ "logf", {"", 0x35 } }, -{ "cmpf", {"rl", 0x36 } }, -{ "cmpd", {"rq", 0x37 } }, -{ "subb3", {"rbrbwb", 0x38 } }, -{ "bitb", {"rbrb", 0x39 } }, -{ "subw3", {"rwrwww", 0x3a } }, -{ "bitw", {"rwrw", 0x3b } }, -{ "subl3", {"rlrlwl", 0x3c } }, -{ "bitl", {"rlrl", 0x3d } }, -{ "ediv", {"rlrqwlwl", 0x3e } }, -{ "aobleq", {"rlmlbw", 0x3f } }, -{ "ret", {"", 0x40 } }, -{ "bgtr", {"bb", 0x41 } }, -{ "sqrtf", {"", 0x45 } }, -{ "cmpf2", {"rl", 0x46 } }, -{ "cmpd2", {"rqrq", 0x47 } }, -{ "shll", {"rbrlwl", 0x48 } }, -{ "clrb", {"wb", 0x49 } }, -{ "shlq", {"rbrqwq", 0x4a } }, -{ "clrw", {"ww", 0x4b } }, -{ "mull2", {"rlml", 0x4c } }, -{ "clrl", {"wl", 0x4d } }, -{ "shal", {"rbrlwl", 0x4e } }, -{ "bleq", {"bb", 0x51 } }, -{ "expf", {"", 0x55 } }, -{ "tstf", {"", 0x56 } }, -{ "tstd", {"", 0x57 } }, -{ "shrl", {"rbrlwl", 0x58 } }, -{ "tstb", {"rb", 0x59 } }, -{ "shrq", {"rbrqwq", 0x5a } }, -{ "tstw", {"rw", 0x5b } }, -{ "mull3", {"rlrlwl", 0x5c } }, -{ "tstl", {"rl", 0x5d } }, -{ "shar", {"rbrlwl", 0x5e } }, -{ "bbssi", {"rlmlbw", 0x5f } }, -{ "ldpctx", {"", 0x60 } }, -{ "pushd", {"", 0x67 } }, -{ "incb", {"mb", 0x69 } }, -{ "incw", {"mw", 0x6b } }, -{ "divl2", {"rlml", 0x6c } }, -{ "incl", {"ml", 0x6d } }, -{ "cvtlb", {"rlwb", 0x6f } }, -{ "svpctx", {"", 0x70 } }, -{ "jmp", {"ab", 0x71 } }, -{ "cvlf", {"rl", 0x76 } }, -{ "cvld", {"rl", 0x77 } }, -{ "decb", {"mb", 0x79 } }, -{ "decw", {"mw", 0x7b } }, -{ "divl3", {"rlrlwl", 0x7c } }, -{ "decl", {"ml", 0x7d } }, -{ "cvtlw", {"rlww", 0x7f } }, -{ "bgeq", {"bb", 0x81 } }, -{ "movs2", {"abab", 0x82 } }, -{ "cvfl", {"wl", 0x86 } }, -{ "cvdl", {"wl", 0x87 } }, -{ "orb2", {"rbmb", 0x88 } }, -{ "cvtbl", {"rbwl", 0x89 } }, -{ "orw2", {"rwmw", 0x8a } }, -{ "bispsw", {"rw", 0x8b } }, -{ "orl2", {"rlml", 0x8c } }, -{ "adwc", {"rlml", 0x8d } }, -{ "adda", {"rlml", 0x8e } }, -{ "blss", {"bb", 0x91 } }, -{ "cmps2", {"abab", 0x92 } }, -{ "ldfd", {"rl", 0x97 } }, -{ "orb3", {"rbrbwb", 0x98 } }, -{ "cvtbw", {"rbww", 0x99 } }, -{ "orw3", {"rwrwww", 0x9a } }, -{ "bicpsw", {"rw", 0x9b } }, -{ "orl3", {"rlrlwl", 0x9c } }, -{ "sbwc", {"rlml", 0x9d } }, -{ "suba", {"rlml", 0x9e } }, -{ "bgtru", {"bb", 0xa1 } }, -{ "cvdf", {"", 0xa6 } }, -{ "andb2", {"rbmb", 0xa8 } }, -{ "movzbl", {"rbwl", 0xa9 } }, -{ "andw2", {"rwmw", 0xaa } }, -{ "loadr", {"rwal", 0xab } }, -{ "andl2", {"rlml", 0xac } }, -{ "mtpr", {"rlrl", 0xad } }, -{ "ffs", {"rlwl", 0xae } }, -{ "blequ", {"bb", 0xb1 } }, -{ "negf", {"", 0xb6 } }, -{ "negd", {"", 0xb7 } }, -{ "andb3", {"rbrbwb", 0xb8 } }, -{ "movzbw", {"rbww", 0xb9 } }, -{ "andw3", {"rwrwww", 0xba } }, -{ "storer", {"rwal", 0xbb } }, -{ "andl3", {"rlrlwl", 0xbc } }, -{ "mfpr", {"rlwl", 0xbd } }, -{ "ffc", {"rlwl", 0xbe } }, -{ "calls", {"rbab", 0xbf } }, -{ "prober", {"rbabrl", 0xc0 } }, -{ "bvc", {"bb", 0xc1 } }, -{ "movs3", {"ababrw", 0xc2 } }, -{ "movzwl", {"rwwl", 0xc3 } }, -{ "addf", {"rl", 0xc6 } }, -{ "addd", {"rq", 0xc7 } }, -{ "xorb2", {"rbmb", 0xc8 } }, -{ "movob", {"rbwb", 0xc9 } }, -{ "xorw2", {"rwmw", 0xca } }, -{ "movow", {"rwww", 0xcb } }, -{ "xorl2", {"rlml", 0xcc } }, -{ "movpsl", {"wl", 0xcd } }, -{ "kcall", {"rw", 0xcf } }, -{ "probew", {"rbabrl", 0xd0 } }, -{ "bvs", {"bb", 0xd1 } }, -{ "cmps3", {"ababrw", 0xd2 } }, -{ "subf", {"rq", 0xd6 } }, -{ "subd", {"rq", 0xd7 } }, -{ "xorb3", {"rbrbwb", 0xd8 } }, -{ "pushb", {"rb", 0xd9 } }, -{ "xorw3", {"rwrwww", 0xda } }, -{ "pushw", {"rw", 0xdb } }, -{ "xorl3", {"rlrlwl", 0xdc } }, -{ "pushl", {"rl", 0xdd } }, -{ "insque", {"abab", 0xe0 } }, -{ "bcs", {"bb", 0xe1 } }, -{ "bgequ", {"bb", 0xe1 } }, -{ "mulf", {"rq", 0xe6 } }, -{ "muld", {"rq", 0xe7 } }, -{ "mnegb", {"rbwb", 0xe8 } }, -{ "movab", {"abwl", 0xe9 } }, -{ "mnegw", {"rwww", 0xea } }, -{ "movaw", {"awwl", 0xeb } }, -{ "mnegl", {"rlwl", 0xec } }, -{ "moval", {"alwl", 0xed } }, -{ "remque", {"ab", 0xf0 } }, -{ "bcc", {"bb", 0xf1 } }, -{ "blssu", {"bb", 0xf1 } }, -{ "divf", {"rq", 0xf6 } }, -{ "divd", {"rq", 0xf7 } }, -{ "movblk", {"alalrw", 0xf8 } }, -{ "pushab", {"ab", 0xf9 } }, -{ "pushaw", {"aw", 0xfb } }, -{ "casel", {"rlrlrl", 0xfc } }, -{ "pushal", {"al", 0xfd } }, -{ "callf", {"rbab", 0xfe } }, -{ "" , "" } /* empty is end sentinel */ - -}; diff --git a/include/vax-opcode.h b/include/vax-opcode.h deleted file mode 100755 index d604e3f9c65..00000000000 --- a/include/vax-opcode.h +++ /dev/null @@ -1,382 +0,0 @@ -/* Vax opcde list. - Copyright (C) 1989, Free Software Foundation, Inc. - -This file is part of GDB and GAS. - -GDB and GAS are 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 1, or (at your option) -any later version. - -GDB and GAS are 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 GDB or GAS; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#ifndef vax_opcodeT -#define vax_opcodeT int -#endif /* no vax_opcodeT */ - -struct vot_wot /* vax opcode table: wot to do with this */ - /* particular opcode */ -{ - char * args; /* how to compile said opcode */ - vax_opcodeT code; /* op-code (may be > 8 bits!) */ -}; - -struct vot /* vax opcode text */ -{ - char * name; /* opcode name: lowercase string [key] */ - struct vot_wot detail; /* rest of opcode table [datum] */ -}; - -#define vot_how args -#define vot_code code -#define vot_detail detail -#define vot_name name - -static const struct vot -votstrs[] = -{ -{ "halt", {"", 0x00 } }, -{ "nop", {"", 0x01 } }, -{ "rei", {"", 0x02 } }, -{ "bpt", {"", 0x03 } }, -{ "ret", {"", 0x04 } }, -{ "rsb", {"", 0x05 } }, -{ "ldpctx", {"", 0x06 } }, -{ "svpctx", {"", 0x07 } }, -{ "cvtps", {"rwabrwab", 0x08 } }, -{ "cvtsp", {"rwabrwab", 0x09 } }, -{ "index", {"rlrlrlrlrlwl", 0x0a } }, -{ "crc", {"abrlrwab", 0x0b } }, -{ "prober", {"rbrwab", 0x0c } }, -{ "probew", {"rbrwab", 0x0d } }, -{ "insque", {"abab", 0x0e } }, -{ "remque", {"abwl", 0x0f } }, -{ "bsbb", {"bb", 0x10 } }, -{ "brb", {"bb", 0x11 } }, -{ "bneq", {"bb", 0x12 } }, -{ "bnequ", {"bb", 0x12 } }, -{ "beql", {"bb", 0x13 } }, -{ "beqlu", {"bb", 0x13 } }, -{ "bgtr", {"bb", 0x14 } }, -{ "bleq", {"bb", 0x15 } }, -{ "jsb", {"ab", 0x16 } }, -{ "jmp", {"ab", 0x17 } }, -{ "bgeq", {"bb", 0x18 } }, -{ "blss", {"bb", 0x19 } }, -{ "bgtru", {"bb", 0x1a } }, -{ "blequ", {"bb", 0x1b } }, -{ "bvc", {"bb", 0x1c } }, -{ "bvs", {"bb", 0x1d } }, -{ "bcc", {"bb", 0x1e } }, -{ "bgequ", {"bb", 0x1e } }, -{ "blssu", {"bb", 0x1f } }, -{ "bcs", {"bb", 0x1f } }, -{ "addp4", {"rwabrwab", 0x20 } }, -{ "addp6", {"rwabrwabrwab", 0x21 } }, -{ "subp4", {"rwabrwab", 0x22 } }, -{ "subp6", {"rwabrwabrwab", 0x23 } }, -{ "cvtpt", {"rwababrwab", 0x24 } }, -{ "mulp", {"rwabrwabrwab", 0x25 } }, -{ "cvttp", {"rwababrwab", 0x26 } }, -{ "divp", {"rwabrwabrwab", 0x27 } }, -{ "movc3", {"rwabab", 0x28 } }, -{ "cmpc3", {"rwabab", 0x29 } }, -{ "scanc", {"rwababrb", 0x2a } }, -{ "spanc", {"rwababrb", 0x2b } }, -{ "movc5", {"rwabrbrwab", 0x2c } }, -{ "cmpc5", {"rwabrbrwab", 0x2d } }, -{ "movtc", {"rwabrbabrwab", 0x2e } }, -{ "movtuc", {"rwabrbabrwab", 0x2f } }, -{ "bsbw", {"bw", 0x30 } }, -{ "brw", {"bw", 0x31 } }, -{ "cvtwl", {"rwwl", 0x32 } }, -{ "cvtwb", {"rwwb", 0x33 } }, -{ "movp", {"rwabab", 0x34 } }, -{ "cmpp3", {"rwabab", 0x35 } }, -{ "cvtpl", {"rwabwl", 0x36 } }, -{ "cmpp4", {"rwabrwab", 0x37 } }, -{ "editpc", {"rwababab", 0x38 } }, -{ "matchc", {"rwabrwab", 0x39 } }, -{ "locc", {"rbrwab", 0x3a } }, -{ "skpc", {"rbrwab", 0x3b } }, -{ "movzwl", {"rwwl", 0x3c } }, -{ "acbw", {"rwrwmwbw", 0x3d } }, -{ "movaw", {"awwl", 0x3e } }, -{ "pushaw", {"aw", 0x3f } }, -{ "addf2", {"rfmf", 0x40 } }, -{ "addf3", {"rfrfwf", 0x41 } }, -{ "subf2", {"rfmf", 0x42 } }, -{ "subf3", {"rfrfwf", 0x43 } }, -{ "mulf2", {"rfmf", 0x44 } }, -{ "mulf3", {"rfrfwf", 0x45 } }, -{ "divf2", {"rfmf", 0x46 } }, -{ "divf3", {"rfrfwf", 0x47 } }, -{ "cvtfb", {"rfwb", 0x48 } }, -{ "cvtfw", {"rfww", 0x49 } }, -{ "cvtfl", {"rfwl", 0x4a } }, -{ "cvtrfl", {"rfwl", 0x4b } }, -{ "cvtbf", {"rbwf", 0x4c } }, -{ "cvtwf", {"rwwf", 0x4d } }, -{ "cvtlf", {"rlwf", 0x4e } }, -{ "acbf", {"rfrfmfbw", 0x4f } }, -{ "movf", {"rfwf", 0x50 } }, -{ "cmpf", {"rfrf", 0x51 } }, -{ "mnegf", {"rfwf", 0x52 } }, -{ "tstf", {"rf", 0x53 } }, -{ "emodf", {"rfrbrfwlwf", 0x54 } }, -{ "polyf", {"rfrwab", 0x55 } }, -{ "cvtfd", {"rfwd", 0x56 } }, - /* opcode 57 is not defined yet */ -{ "adawi", {"rwmw", 0x58 } }, - /* opcode 59 is not defined yet */ - /* opcode 5a is not defined yet */ - /* opcode 5b is not defined yet */ -{ "insqhi", {"abaq", 0x5c } }, -{ "insqti", {"abaq", 0x5d } }, -{ "remqhi", {"aqwl", 0x5e } }, -{ "remqti", {"aqwl", 0x5f } }, -{ "addd2", {"rdmd", 0x60 } }, -{ "addd3", {"rdrdwd", 0x61 } }, -{ "subd2", {"rdmd", 0x62 } }, -{ "subd3", {"rdrdwd", 0x63 } }, -{ "muld2", {"rdmd", 0x64 } }, -{ "muld3", {"rdrdwd", 0x65 } }, -{ "divd2", {"rdmd", 0x66 } }, -{ "divd3", {"rdrdwd", 0x67 } }, -{ "cvtdb", {"rdwb", 0x68 } }, -{ "cvtdw", {"rdww", 0x69 } }, -{ "cvtdl", {"rdwl", 0x6a } }, -{ "cvtrdl", {"rdwl", 0x6b } }, -{ "cvtbd", {"rbwd", 0x6c } }, -{ "cvtwd", {"rwwd", 0x6d } }, -{ "cvtld", {"rlwd", 0x6e } }, -{ "acbd", {"rdrdmdbw", 0x6f } }, -{ "movd", {"rdwd", 0x70 } }, -{ "cmpd", {"rdrd", 0x71 } }, -{ "mnegd", {"rdwd", 0x72 } }, -{ "tstd", {"rd", 0x73 } }, -{ "emodd", {"rdrbrdwlwd", 0x74 } }, -{ "polyd", {"rdrwab", 0x75 } }, -{ "cvtdf", {"rdwf", 0x76 } }, - /* opcode 77 is not defined yet */ -{ "ashl", {"rbrlwl", 0x78 } }, -{ "ashq", {"rbrqwq", 0x79 } }, -{ "emul", {"rlrlrlwq", 0x7a } }, -{ "ediv", {"rlrqwlwl", 0x7b } }, -{ "clrd", {"wd", 0x7c } }, -{ "clrg", {"wg", 0x7c } }, -{ "clrq", {"wd", 0x7c } }, -{ "movq", {"rqwq", 0x7d } }, -{ "movaq", {"aqwl", 0x7e } }, -{ "movad", {"adwl", 0x7e } }, -{ "pushaq", {"aq", 0x7f } }, -{ "pushad", {"ad", 0x7f } }, -{ "addb2", {"rbmb", 0x80 } }, -{ "addb3", {"rbrbwb", 0x81 } }, -{ "subb2", {"rbmb", 0x82 } }, -{ "subb3", {"rbrbwb", 0x83 } }, -{ "mulb2", {"rbmb", 0x84 } }, -{ "mulb3", {"rbrbwb", 0x85 } }, -{ "divb2", {"rbmb", 0x86 } }, -{ "divb3", {"rbrbwb", 0x87 } }, -{ "bisb2", {"rbmb", 0x88 } }, -{ "bisb3", {"rbrbwb", 0x89 } }, -{ "bicb2", {"rbmb", 0x8a } }, -{ "bicb3", {"rbrbwb", 0x8b } }, -{ "xorb2", {"rbmb", 0x8c } }, -{ "xorb3", {"rbrbwb", 0x8d } }, -{ "mnegb", {"rbwb", 0x8e } }, -{ "caseb", {"rbrbrb", 0x8f } }, -{ "movb", {"rbwb", 0x90 } }, -{ "cmpb", {"rbrb", 0x91 } }, -{ "mcomb", {"rbwb", 0x92 } }, -{ "bitb", {"rbrb", 0x93 } }, -{ "clrb", {"wb", 0x94 } }, -{ "tstb", {"rb", 0x95 } }, -{ "incb", {"mb", 0x96 } }, -{ "decb", {"mb", 0x97 } }, -{ "cvtbl", {"rbwl", 0x98 } }, -{ "cvtbw", {"rbww", 0x99 } }, -{ "movzbl", {"rbwl", 0x9a } }, -{ "movzbw", {"rbww", 0x9b } }, -{ "rotl", {"rbrlwl", 0x9c } }, -{ "acbb", {"rbrbmbbw", 0x9d } }, -{ "movab", {"abwl", 0x9e } }, -{ "pushab", {"ab", 0x9f } }, -{ "addw2", {"rwmw", 0xa0 } }, -{ "addw3", {"rwrwww", 0xa1 } }, -{ "subw2", {"rwmw", 0xa2 } }, -{ "subw3", {"rwrwww", 0xa3 } }, -{ "mulw2", {"rwmw", 0xa4 } }, -{ "mulw3", {"rwrwww", 0xa5 } }, -{ "divw2", {"rwmw", 0xa6 } }, -{ "divw3", {"rwrwww", 0xa7 } }, -{ "bisw2", {"rwmw", 0xa8 } }, -{ "bisw3", {"rwrwww", 0xa9 } }, -{ "bicw2", {"rwmw", 0xaa } }, -{ "bicw3", {"rwrwww", 0xab } }, -{ "xorw2", {"rwmw", 0xac } }, -{ "xorw3", {"rwrwww", 0xad } }, -{ "mnegw", {"rwww", 0xae } }, -{ "casew", {"rwrwrw", 0xaf } }, -{ "movw", {"rwww", 0xb0 } }, -{ "cmpw", {"rwrw", 0xb1 } }, -{ "mcomw", {"rwww", 0xb2 } }, -{ "bitw", {"rwrw", 0xb3 } }, -{ "clrw", {"ww", 0xb4 } }, -{ "tstw", {"rw", 0xb5 } }, -{ "incw", {"mw", 0xb6 } }, -{ "decw", {"mw", 0xb7 } }, -{ "bispsw", {"rw", 0xb8 } }, -{ "bicpsw", {"rw", 0xb9 } }, -{ "popr", {"rw", 0xba } }, -{ "pushr", {"rw", 0xbb } }, -{ "chmk", {"rw", 0xbc } }, -{ "chme", {"rw", 0xbd } }, -{ "chms", {"rw", 0xbe } }, -{ "chmu", {"rw", 0xbf } }, -{ "addl2", {"rlml", 0xc0 } }, -{ "addl3", {"rlrlwl", 0xc1 } }, -{ "subl2", {"rlml", 0xc2 } }, -{ "subl3", {"rlrlwl", 0xc3 } }, -{ "mull2", {"rlml", 0xc4 } }, -{ "mull3", {"rlrlwl", 0xc5 } }, -{ "divl2", {"rlml", 0xc6 } }, -{ "divl3", {"rlrlwl", 0xc7 } }, -{ "bisl2", {"rlml", 0xc8 } }, -{ "bisl3", {"rlrlwl", 0xc9 } }, -{ "bicl2", {"rlml", 0xca } }, -{ "bicl3", {"rlrlwl", 0xcb } }, -{ "xorl2", {"rlml", 0xcc } }, -{ "xorl3", {"rlrlwl", 0xcd } }, -{ "mnegl", {"rlwl", 0xce } }, -{ "casel", {"rlrlrl", 0xcf } }, -{ "movl", {"rlwl", 0xd0 } }, -{ "cmpl", {"rlrl", 0xd1 } }, -{ "mcoml", {"rlwl", 0xd2 } }, -{ "bitl", {"rlrl", 0xd3 } }, -{ "clrf", {"wf", 0xd4 } }, -{ "clrl", {"wl", 0xd4 } }, -{ "tstl", {"rl", 0xd5 } }, -{ "incl", {"ml", 0xd6 } }, -{ "decl", {"ml", 0xd7 } }, -{ "adwc", {"rlml", 0xd8 } }, -{ "sbwc", {"rlml", 0xd9 } }, -{ "mtpr", {"rlrl", 0xda } }, -{ "mfpr", {"rlwl", 0xdb } }, -{ "movpsl", {"wl", 0xdc } }, -{ "pushl", {"rl", 0xdd } }, -{ "moval", {"alwl", 0xde } }, -{ "movaf", {"afwl", 0xde } }, -{ "pushal", {"al", 0xdf } }, -{ "pushaf", {"af", 0xdf } }, -{ "bbs", {"rlabbb", 0xe0 } }, -{ "bbc", {"rlabbb", 0xe1 } }, -{ "bbss", {"rlabbb", 0xe2 } }, -{ "bbcs", {"rlabbb", 0xe3 } }, -{ "bbsc", {"rlabbb", 0xe4 } }, -{ "bbcc", {"rlabbb", 0xe5 } }, -{ "bbssi", {"rlabbb", 0xe6 } }, -{ "bbcci", {"rlabbb", 0xe7 } }, -{ "blbs", {"rlbb", 0xe8 } }, -{ "blbc", {"rlbb", 0xe9 } }, -{ "ffs", {"rlrbvbwl", 0xea } }, -{ "ffc", {"rlrbvbwl", 0xeb } }, -{ "cmpv", {"rlrbvbrl", 0xec } }, -{ "cmpzv", {"rlrbvbrl", 0xed } }, -{ "extv", {"rlrbvbwl", 0xee } }, -{ "extzv", {"rlrbvbwl", 0xef } }, -{ "insv", {"rlrlrbvb", 0xf0 } }, -{ "acbl", {"rlrlmlbw", 0xf1 } }, -{ "aoblss", {"rlmlbb", 0xf2 } }, -{ "aobleq", {"rlmlbb", 0xf3 } }, -{ "sobgeq", {"mlbb", 0xf4 } }, -{ "sobgtr", {"mlbb", 0xf5 } }, -{ "cvtlb", {"rlwb", 0xf6 } }, -{ "cvtlw", {"rlww", 0xf7 } }, -{ "ashp", {"rbrwabrbrwab", 0xf8 } }, -{ "cvtlp", {"rlrwab", 0xf9 } }, -{ "callg", {"abab", 0xfa } }, -{ "calls", {"rlab", 0xfb } }, -{ "xfc", {"", 0xfc } }, - /* undefined opcodes here */ -{ "cvtdh", {"rdwh", 0x32fd } }, -{ "cvtgf", {"rgwh", 0x33fd } }, -{ "addg2", {"rgmg", 0x40fd } }, -{ "addg3", {"rgrgwg", 0x41fd } }, -{ "subg2", {"rgmg", 0x42fd } }, -{ "subg3", {"rgrgwg", 0x43fd } }, -{ "mulg2", {"rgmg", 0x44fd } }, -{ "mulg3", {"rgrgwg", 0x45fd } }, -{ "divg2", {"rgmg", 0x46fd } }, -{ "divg3", {"rgrgwg", 0x47fd } }, -{ "cvtgb", {"rgwb", 0x48fd } }, -{ "cvtgw", {"rgww", 0x49fd } }, -{ "cvtgl", {"rgwl", 0x4afd } }, -{ "cvtrgl", {"rgwl", 0x4bfd } }, -{ "cvtbg", {"rbwg", 0x4cfd } }, -{ "cvtwg", {"rwwg", 0x4dfd } }, -{ "cvtlg", {"rlwg", 0x4efd } }, -{ "acbg", {"rgrgmgbw", 0x4ffd } }, -{ "movg", {"rgwg", 0x50fd } }, -{ "cmpg", {"rgrg", 0x51fd } }, -{ "mnegg", {"rgwg", 0x52fd } }, -{ "tstg", {"rg", 0x53fd } }, -{ "emodg", {"rgrwrgwlwg", 0x54fd } }, -{ "polyg", {"rgrwab", 0x55fd } }, -{ "cvtgh", {"rgwh", 0x56fd } }, - /* undefined opcodes here */ -{ "addh2", {"rhmh", 0x60fd } }, -{ "addh3", {"rhrhwh", 0x61fd } }, -{ "subh2", {"rhmh", 0x62fd } }, -{ "subh3", {"rhrhwh", 0x63fd } }, -{ "mulh2", {"rhmh", 0x64fd } }, -{ "mulh3", {"rhrhwh", 0x65fd } }, -{ "divh2", {"rhmh", 0x66fd } }, -{ "divh3", {"rhrhwh", 0x67fd } }, -{ "cvthb", {"rhwb", 0x68fd } }, -{ "cvthw", {"rhww", 0x69fd } }, -{ "cvthl", {"rhwl", 0x6afd } }, -{ "cvtrhl", {"rhwl", 0x6bfd } }, -{ "cvtbh", {"rbwh", 0x6cfd } }, -{ "cvtwh", {"rwwh", 0x6dfd } }, -{ "cvtlh", {"rlwh", 0x6efd } }, -{ "acbh", {"rhrhmhbw", 0x6ffd } }, -{ "movh", {"rhwh", 0x70fd } }, -{ "cmph", {"rhrh", 0x71fd } }, -{ "mnegh", {"rhwh", 0x72fd } }, -{ "tsth", {"rh", 0x73fd } }, -{ "emodh", {"rhrwrhwlwh", 0x74fd } }, -{ "polyh", {"rhrwab", 0x75fd } }, -{ "cvthg", {"rhwg", 0x76fd } }, - /* undefined opcodes here */ -{ "clrh", {"wh", 0x7cfd } }, -{ "clro", {"wo", 0x7cfd } }, -{ "movo", {"rowo", 0x7dfd } }, -{ "movah", {"ahwl", 0x7efd } }, -{ "movao", {"aowl", 0x7efd } }, -{ "pushah", {"ah", 0x7ffd } }, -{ "pushao", {"ao", 0x7ffd } }, - /* undefined opcodes here */ -{ "cvtfh", {"rfwh", 0x98fd } }, -{ "cvtfg", {"rfwg", 0x99fd } }, - /* undefined opcodes here */ -{ "cvthf", {"rhwf", 0xf6fd } }, -{ "cvthd", {"rhwd", 0xf7fd } }, - /* undefined opcodes here */ -{ "bugl", {"rl", 0xfdff } }, -{ "bugw", {"rw", 0xfeff } }, - /* undefined opcodes here */ - -{ "" , "" } /* empty is end sentinel */ - -}; /* votstrs */ - -/* end: vax.opcode.h */ diff --git a/include/wait.h b/include/wait.h deleted file mode 100644 index 8bf0676869d..00000000000 --- a/include/wait.h +++ /dev/null @@ -1,27 +0,0 @@ -/* Define how to access the int that the wait system call stores. - This has been compatible in all Unix systems since time immemorial, - but various well-meaning people have defined various different - words for the same old bits in the same old int (sometimes claimed - to be a struct). We just know it's an int and we use these macros - to access the bits. */ - -/* The following macros are defined equivalently to their definitions - in POSIX.1. We fail to define WNOHANG and WUNTRACED, which POSIX.1 - defines, since our code does not use waitpid(). We - also fail to declare wait() and waitpid(). */ - -#define WIFEXITED(w) (((w)&0377) == 0) -#define WIFSIGNALED(w) (((w)&0377) != 0177 && ((w)&~0377) == 0) -#define WIFSTOPPED(w) (((w)&0377) == 0177) - -#define WEXITSTATUS(w) ((w) >> 8) /* same as WRETCODE */ -#define WTERMSIG(w) ((w) & 0177) -#define WSTOPSIG(w) ((w) >> 8) - -/* These are not defined in POSIX, but are used by our programs. */ - -#define WAITTYPE int - -#define WCOREDUMP(w) (((w)&0200) != 0) -#define WSETEXIT(w,status) ((w) = (0 | ((status) << 8))) -#define WSETSTOP(w,sig) ((w) = (0177 | ((sig) << 8))) diff --git a/install.texinfo b/install.texinfo deleted file mode 100644 index 40531e83619..00000000000 --- a/install.texinfo +++ /dev/null @@ -1,295 +0,0 @@ -\input cyginfo -@c WARNING!!! -@c THESE INSTALL NOTES ARE NOT YET GENERAL-PURPOSE -@c SINCE THERE IS NO ESTABLISHED INSTALLATION PROCEDURE FOR CYGNUS -@c RELEASES FROM THE DEVELOPMENT DIRECTORIES. -@c THESE NOTES MUST BE EDITED BY HAND FOR EACH RELEASE. -@c $Id$ -@setfilename README.info -@iftex -@c We don't actually want a titlepage; HEADINGSon is usually called by -@c @end titlepage to turn on footers and headers. -@HEADINGSon -@setchapternewpage off -@finalout -@end iftex -@c -@c WARNING: NONSTANDARD USAGE we need \tensf for print, without -@c upsetting info. We weren't using @b in this note, so I redefine it: -@tex -\global\def\b#1{{\tensf #1}} -\global\def\date{November 1991} -\global\def\manvers{release m88k--11--91} -\parindent=0pt -@end tex - -@node Top, Contents, (dir), (dir) -@unnumbered Installation and Release Notes - - -@table @strong -@item Cygnus Support M88K Developer's Kit -@item release m88k--11--91 -@iftex -@item @date -@item {} -@item Contents -@display -@altref -@ref{Contents,,Release Contents}. -@ref{Platforms,,Supported Platforms}. -@ref{Installing,,Installation From Tape}. -@ref{Removing,,Removing the Developer's Kit}. -@ref{Cygnus-FSF,,Cygnus and FSF Releases}. -@ref{Cygnus-Support,,Cygnus Support}. -@altref -@end display -@end iftex -@end table - -@menu -* Contents:: Release Contents -* Platforms:: Supported Platforms -* Disk:: Disk Space -* Installing:: Installation From Tape -* Removing:: Removing the Developer's Kit -* Bugs:: Where to report bugs -* Cygnus-FSF:: Cygnus and FSF Releases -* Cygnus-Support:: Cygnus Support -@end menu - -This note is about the Cygnus M88K Developer's Kit: what's in it and how to -install it. - -@node Contents, Platforms, Top, Top -@unnumberedsec Release Contents - -This Developer's Kit is a Cygnus Support Release: the programs in the -release have been tested both individually and as a coordinated suite of -tools. - -The programs in this Developer's Kit are shipped as binaries, -preconfigured to run on Motorola 88K-based workstations ``out of the -box.'' - -We also include the full source code. - -The individual programs are: - -@itemize @bullet -@item -@sc{gnu emacs} (v18.57), the extensible text editor -@item -@sc{gcc} (v1.95.02), the @sc{gnu} C compiler -@item -@sc{g++} (v1.95.02), the @sc{gnu} C++ compiler -@item -@sc{gdb} (v4.2.2), the @sc{gnu} debugger -@end itemize - -@node Platforms, Disk, Contents, Top -@unnumberedsec Supported Platforms -@table @strong -@item 88open BCS -Release m88k--11--91 of the Cygnus Developer's Kit is supported on any -system running an 88open compliant operating system. - -@item Other Platforms -The Developer's Kit is likely to work when compiled for other machines, -but no other platforms are currently -@iftex -(@date) -@end iftex -supported by Cygnus as part of Release m88k--11--91. @refill -@end table -@node Disk, Installing, Platforms, Top -@unnumberedsec Disk Space - -The total space required to extract and install binaries for -all programs in Release m88k--11--91 is 32 megabytes. - -The software is configured to go in @file{/usr/cygnus}; if you have -space available, but not in the same file system as @file{/usr}, you can -create @file{/usr/cygnus} as a symbolic link to the file system where -you do have the space available. - -@node Installing, Removing, Disk, Top -@unnumberedsec Installation From Tape - -@iftex -This note shows computer output in @code{typewriter font}. User input -is indicated by a @b{sans-serif font}. Comments appear in @i{italic -font}. -@end iftex -In all examples, the system name is assumed to be ``@code{eg};'' we show the -system prompt as @samp{eg$}. - -@menu -* Tape-Reading:: Reading the Tape -* Running:: Running the Programs -@end menu - -@node Tape-Reading, Running, Installing, Installing -@unnumberedsubsec Reading the Tape - -For certification purposes, the M88K Developer's Kit is packaged as two -QIC 150 tapes; one containing only binaries for all programs, and one -containing source. - -Load the Cygnus Support binary tape into your system's tape drive. -You can extract the complete tape contents as follows: -@lisp -@cartouche -eg$ @b{mkdir /usr/cygnus} @i{only if /usr/cygnus did not exist} -eg$ @b{cd /usr/cygnus} -eg$ @b{tar xfv /dev/TAPE} -@end cartouche -@end lisp - -This will create subdirectories @file{bin}, @file{lib}, and @file{man}, -with the conventional meanings. - -If you also want the source, for reference or modification, load the -Cygnus Support source tape into your tape drive, and repeat the -@code{tar} command: -@lisp -@cartouche -eg$ @b{tar xfv /dev/TAPE} -@end cartouche -@end lisp - -@page -@node Running, , Tape-Reading, Installing -@unnumberedsubsec Running the Programs -@c [FIXME-future:] orig includes fixincluded files... "bogus -@c but easiest". In some future release, CUST MUST RUN fixincludes ONCE PER OS! -@c [FIXME] how to select cross vs native compiler? -Any users who wish to run the Cygnus development tools will need to make -sure the @code{PATH} environment variable will find them. For example, -the following should go in a Bourne shell initialization file: -@lisp -@cartouche -@b{PATH=/usr/cygnus/bin:$PATH} -@end cartouche -@end lisp - -To use the Cygnus man pages on line, you'll need to install them in your -system's @file{/usr/catman/u_man/man1} directory. For example, you can -copy them like this: -@lisp -@cartouche -eg$ @b{cp /usr/cygnus/man/man1/* /usr/catman/u@t{_}man/man1} -@end cartouche -@end lisp - -@node Removing, Bugs, Installing, Top -@unnumberedsec Removing the Developer's Kit -To remove this release of the Developer's Kit from your system -(if, eventually, you no longer want it): -@enumerate -@item -remove the man pages for this release from your system's -@file{/usr/catman/u_man/man1} directory, if you had chosen to install -them there. For example, in a Bourne-compatible shell, -@lisp -@cartouche -eg$ @b{cd /usr/cygnus/man/man1} -eg$ @b{for m in *; do} -eg> @b{rm /usr/catman/u@t{_}man/man1/$m} -eg> @b{done} -@end cartouche -@end lisp -@item -delete the directory @file{/usr/cygnus} and all its contents. -@end enumerate - -@node Bugs, Cygnus-FSF, Removing, Top -@unnumberedsec Where to report bugs -If you find a bug in this release, please report it to Cygnus Support. -The easiest way to report a bug is via Internet electronic mail to -@samp{bugs@@cygnus.com}; for other contact methods, -@pxref{Cygnus-Support,,Cygnus Support}. @strong{Do not report these bugs -directly to the GNU project} at the Free Software Foundation! Cygnus is -distributing an early release of advanced versions of the GNU compiler -and development tools, and we therefore have full responsibility for -supporting this release. @strong{The FSF will not respond to bugreports -on this software} until release 2.0 of the compilers. You, the FSF, and -Cygnus will all be best served if you send bugreports directly to Cygnus -Support. - -@page -@node Cygnus-FSF, Cygnus-Support, Bugs, Top -@unnumberedsec Cygnus and FSF Releases - -The tools in this Developer's Kit are originally from the Free Software -Foundation, and versions of all these tools can be obtained from the FSF -as well as from Cygnus. Release m88k--11--91 contains the most current -versions; similar versions of the compilers, in particular, will -eventually be available from the FSF as version 2.00. In general, -Cygnus Releases add to FSF software as follows: - -@itemize @bullet -@item -Commercial support is available. Cygnus adds value to FSF releases in -large measure by offering outstanding support services. -@item -Bug fixes. Cygnus performs necessary repairs to bugs discovered -during testing, and also tracks and includes bug fixes developed for -other Cygnus customers or distributed over the Internet. -@item -Documentation. Cygnus has revised and added to available FSF -documentation to give you better descriptions of all the software tools. -@item -Coordination. The tools in your Developer's Kit are certified to work -together; you need not worry about one tool being ahead of another. -@end itemize - -@tex -@page -@end tex -@node Cygnus-Support, , Cygnus-FSF, Top -@unnumberedsec Cygnus Support - -Cygnus Support was founded in 1989 to provide commercial support for -free software. Cygnus supplies products and services that benefit -advanced development groups by allowing them to @emph{use} -state-of-the-art tools instead of @emph{maintaining} them. With Cygnus -Support, sites that once were forced to do their own tool support can -recover that valuable staff time. Former users of proprietary software -now may choose supported free software, combining the advantages of both -worlds. - -Free software is faster, more powerful, and more portable than its -proprietary counterparts. It evolves faster because users who want to -make improvements are free to do so. Cygnus tracks these -improvements and integrates them into tested, stable versions ready -for commercial use, then backs this software with comprehensive -support. - -With Cygnus Support as your partner, you will have the software and -the support you need to meet your business objectives better. Cygnus -is intimately familiar with this software from extensive experience -using, debugging, and implementing it. You get direct access to the -most qualified support people: the authors of that software. - -We provide ``vintage'' releases---stable versions which have been -though extensive use and testing---or up-to-the minute sources, for -those who need the very latest version. Vintage releases undergo at -least nine months of intensive use before certification as vintage. - -Because all our improvements are also free software, you can -distribute them widely within your organization, or to your customers, -without extra cost. - -@display -Cygnus Support -814 University Avenue -Palo Alto, CA 94301, USA - -+1 415 322 3811 - -email: @code{info@@cygnus.com} -fax: +1 415 322 3270 -@end display - -@bye diff --git a/ld/.Sanitize b/ld/.Sanitize deleted file mode 100644 index 9761a0146d8..00000000000 --- a/ld/.Sanitize +++ /dev/null @@ -1,152 +0,0 @@ -# Sanitize.in for devo. -# $Id$ -# - -# Each directory to survive it's way into a release will need a file -# like this one called "./.Sanitize". All keyword lines must exist, -# and must exist in the order specified by this file. Each directory -# in the tree will be processed, top down, in the following order. - -# Hash started lines like this one are comments and will be deleted -# before anything else is done. Blank lines will also be squashed -# out. - -# The lines between the "Do-first:" line and the "Things-to-keep:" -# line are executed as a /bin/sh shell script before anything else is -# done in this - -Do-first: - -echo Sanitizing `pwd`... - -# All files listed between the "Things-to-keep:" line and the -# "Files-to-sed:" line will be kept. All other files will be removed. -# Directories listed in this section will have their own Sanitize -# called. Directories not listed will be removed in their entirety -# with rm -rf. - -Things-to-keep: -README -i386aout.c -i386aout.sc -ChangeLog -Makefile.in -config -config.h -configure.in -ld.h -ld.texinfo -ldemul.c -ldemul.h -ldctor.c -ldexp.c -ldexp.h -ldfile.c -ldwarn.c -ldwarn.h -ldindr.c -ldindr.h -ldfile.h -ldgld.sc -ldgld68k.sc -ldm88k.sc -ldgld960.c -ldgld960.sc -gld.1 -ldglda29k.sc -ldgld68k.sc -h8300hds.c -h8300hds.sc -ebmon29k.sc -ldgram.y -ldlang.c -ldlang.h -ldlex.h -ldlex.l -ldlnk960.c -ldlnk960.sc -ldmain.c -ldmain.h -ldmisc.c -ldmisc.h -ldsym.c -ldsym.h -ldtemplate -ldvanilla.c -ldver.c -ldver.h -ldwarn.h -ldwrite.c -ldwrite.h -mkscript.c -news.sc - -Do-last: - -echo Done in `pwd`. - -# -# -# $Log$ -# Revision 1.23 1991/11/15 21:09:49 bothner -# Remove ldgld.c, ldgld68k.c, ldm88k.c, since these are -# now automatically generated. -# -# Revision 1.22 1991/11/06 09:26:59 sac -# Added three files which had been forgotten -# -# Revision 1.21 1991/11/05 21:56:06 sac -# *** empty log message *** -# -# Revision 1.20 1991/11/05 20:36:54 sac -# *** empty log message *** -# -# Revision 1.19 1991/11/04 00:46:44 steve -# i386 aout changes from Bob Kukura -# -# Revision 1.18 1991/10/12 06:43:01 bothner -# Fixed typo. -# -# Revision 1.17 1991/10/11 19:31:38 steve -# *** empty log message *** -# -# Revision 1.16 1991/10/10 11:59:25 rich -# updating -# -# Revision 1.15 1991/10/09 20:40:37 bothner -# Added h8300hds.{c,sc}. -# -# Revision 1.14 1991/10/05 04:55:04 gnu -# * Makefile.in: Avoid using $< in non-suffix rules (breaks on Sun Make). -# * ldfile.c, ldlang.c, ldmain.c, ldwrite.c: Cope with renames of a -# few BFD types & enums. -# * ChangeLog: Create. -# -# Revision 1.13 1991/09/27 20:19:25 bothner -# Update for deleted (and some added) files. -# -# Revision 1.12 1991/09/24 02:30:20 rich -# ldgram.h is not cvs'd source. -# -# Revision 1.11 1991/09/23 20:59:12 steve -# Cleaned it up for 88k -# -# Revision 1.5 1991/08/27 00:21:34 steve -# Added config.sub -# -# Revision 1.4 1991/08/06 21:28:21 steve -# Patches to fix bugs reported by roland McGrath -# -# Revision 1.3 1991/08/01 23:59:06 steve -# *** empty log message *** -# -# Revision 1.2 1991/07/16 00:31:15 steve -# *** empty log message *** -# -# Revision 1.1 1991/05/23 21:45:12 rich -# Initial revision -# -# -# - -# End of file. diff --git a/ld/ChangeLog b/ld/ChangeLog deleted file mode 100644 index 9f23140f7a6..00000000000 --- a/ld/ChangeLog +++ /dev/null @@ -1,136 +0,0 @@ -Tue Nov 12 18:36:50 1991 Steve Chamberlain (sac at cygnus.com) - - * Makefile.in: Take out the version number for install - * m88kbcs.sc: put in contructor blocks. - -Mon Nov 11 18:47:33 1991 Per Bothner (bothner at cygnus.com) - - * ldmisc.c, ldmisc.h: Re-write info() to take a filename - parameter, a format, and an arg pointer, and rename it to - vfinfo(). Write info() in terms of new vfinfo(). - New einfo() is the same as info(), except it writes to stderr. - * ldemul.c, ldexp.c, ldlang.c, ldlnk960.c, ldmain.c, ldwrite.c, - ldmisc.c: Replace "error" calls to info() by new einfo(). - -Mon Nov 11 09:57:32 1991 Steve Chamberlain (steve at cygnus.com) - - * ldlex.l ldgram.y: made -V option do same as -v - * Makefile.in: Added $(MINUS_G) flag so debugging can be - turned off - -Sun Nov 3 16:37:37 1991 Steve Chamberlain (steve at cygnus.com) - i386 aout changes from Bob Kukura - * Makefile.in, config.h: added i386aout support - * configure.in: fixed /h-{myhost} typo - * ldgram.y: -MM now gives more boring map. - * ldlang.c: now does D_PAGED flag the right way. - * ldsym.c: -MM flags does the right thing. - -Sun Nov 3 15:00:03 1991 Per Bothner (bothner at cygnus.com) - - * configure.in: Fixed typo. Also, a fix for hp300bsd. - * ldlang.c (init_os): Compensate for BFD change, - where bfd_make_section now returns NULL for a duplicate - section request, instead of the old section. - -Thu Oct 17 15:27:13 1991 Per Bothner (bothner at cygnus.com) - - * ldver.c: Bump to version 1.91 (consistent with binutils). - -Wed Oct 16 12:27:08 1991 Per Bothner (bothner at cygnus.com) - - * Makefile.in, config.h, ld.h, ldemul.c, ldexp.c, ldexp.h, - ldgram.y, ldlex.l, ldlnk960.c, ldmain.c, ldmisc.c, ldmisc.h, - ldsym.c, ldsym.h, ldtemplate, ldvanilla.c, ldver.c, ldver.h, - ldwarn.c, ldwarn.h, ldwrite.c, ldwrite.h, mkscript.c: - Add or update copyright notices. - -Mon Oct 14 23:55:27 1991 Per Bothner (bothner at cygnus.com) - - * README: New file. - * Makefile.in: Changed installation directory name scheme - to be consistent with gcc. Also changed 'install'. - -Mon Oct 14 17:30:02 1991 Roland H. Pesch (pesch at cygnus.com) - - * Makefile.in: new targets ld.mm, ld.me - -Mon Oct 14 17:27:24 1991 Per Bothner (bothner at cygnus.com) - - * Makefile.in, ldtemplate: Need to use separate scripts - for -n and -N options. Yet more complication. - -Fri Oct 11 22:40:46 1991 John Gilmore (gnu at cygnus.com) - - * Makefile.in: Avoid using $< in explicit Make rules (it doesn't - work). Add some lines to avoid Sun Make VPATH bugs. - -Fri Oct 11 16:42:22 1991 Per Bothner (bothner at cygnus.com) - - * news.sc: Add alignment for data segment. - * ldtemplate: Add (yet another) script to get for -n or -N - options. (These need different alignment than ZMAGIC files.) - * Makefile.in: Add stuff for new foo.xn scripts. - These are generated by replacing "ALIGN(0x...00)" by ".". - -Fri Oct 11 15:43:04 1991 Roland H. Pesch (pesch at cygnus.com) - - * Makefile.in: new targets ld.ms, ld-index.ms - ld.texinfo: remove tabs, other cleanups for texi2roff - -Fri Oct 11 13:51:54 1991 Per Bothner (bothner at cygnus.com) - - * ldmain.c (main): Make config.magic_demand_paged be true - by default. Don't the WP_TEXT and D_PAGED flags of - output_bfd here; it's too late, so set it when output_bfd - is created (in ldlang.c). Also fix setting of EXEC_P flag - * ldlang.c (ldlang_open_output): Set output_bfd->flags here. - * ldlang.c: Remove some duplicate extern declarations. - * ldgram.y: Fixes to -N and -n options. - * Makefile.in: Recognize upper case letters in sed script - to remove assignments from script files. - * ldtemplate: Don't assukme that -N or -n options - imply use of -r script. - * mkscript.c: Tweaking to correctly handle \n and \\ in input. - -Fri Oct 11 10:29:27 1991 Steve Chamberlain (steve at cygnus.com) - - * ldtemplate: include bfd.h before sysdep.h. - -Fri Oct 11 04:24:45 1991 John Gilmore (gnu at cygnus.com) - - Restructure configuration scheme for bfd, binutils, ld. - - * include/sys/h-*.h: Move to bfd/hosts/h-*.h. - * configure.in: Revise to symlink sysdep.h to ../bfd/hosts/h-xxx.h. - Change some config names to match other dirs. - * *.c: Include bfd.h before sysdep.h, so ansidecl and PROTO() - get defined first. - * config/: Rename some config files to match up h-*.h names. - Remove all the HOST_SYS definitions from the config files. - -Tue Oct 8 16:00:57 1991 Per Bothner (bothner at cygnus.com) - - * ldexp.h, ldlang.h: Change enum boolean -> enum bfd_boolean. - * ldtemplate: Remove ldfile_add_library_path calls; - just use the SEARCH_DIR commands in the script files. - * Makefile.in: Add LIB_PATH macro, which if set is used to replace - the SEARCH_DIR commands in the scripts (using ugly sed magic). - This is primarily intended for cross-linking, where you would - place libaries in a different place than native libraries. - Also, emulations made from ldtemplate now use $(srcdir). - * ldglda29k.sc: Change SEARCH_DIR commands to a conventional - form; people can use the Makefile's LIB_PATH to override. - -Tue Oct 8 14:51:21 1991 Roland H. Pesch (pesch at cygnus.com) - - * Makefile.in: fix target ld.dvi, add target ld.info - ld.texinfo: make info filename ld.info - -Fri Oct 4 21:51:58 1991 John Gilmore (gnu at cygnus.com) - - * Makefile.in: Avoid using $< in non-suffix rules (breaks on Sun - Make). - * ldfile.c, ldlang.c, ldmain.c, ldwrite.c: Cope with renames of a - few BFD types & enums. - diff --git a/ld/Makefile b/ld/Makefile deleted file mode 100755 index a565bbf5095..00000000000 --- a/ld/Makefile +++ /dev/null @@ -1,201 +0,0 @@ -# -# Makefile for ld version 2 -# -# $Id$ -# -srcdir=../common -VPATH=../common -BASEDIR = ../.. -HOSTDIR = ../$(HOST)/ -INCLUDE = $(srcdir)/$(BASEDIR)/include-cygnus -INCLUDES = -I. -I$(srcdir) -I$(INCLUDE) -DEBUG = -g - - -#__sun3__#EXTRA_DEF=-DHOST_SYS=SUN3_SYS -#__sun4__#EXTRA_DEF=-DHOST_SYS=SUN4_SYS -#__dgux__#EXTRA_DEF=-DHOST_SYS=DGUX_SYS - -CFLAGS = $(INCLUDES) $(EXTRA_DEF) $(DEBUG) -LINTFLAGS = $(INCLUDES) $(EXTRA_DEF) - -.SUFFIXES: .y - -.y.o: - yacc -tvd $< - mv y.tab.c ldgram.tab.c - $(CC) -c $(CFLAGS) ldgram.tab.c - mv ldgram.tab.o ldgram.o - - -# go directly to ld.new in case this ld isn't capable of -# linking native object on this host. It can be renamed on -# install. -PROGS = $(HOSTDIR)/ld.new - -# for self hosting -GNUTARGET=a.out-generic-big -LDEMULATION=gld -BFDLIB=$(srcdir)/$(BASEDIR)/bfd/$(HOST)/libbfd.a - -OBJS= ldgram.o ldlex.o ldlang.o ldmain.o ldwrite.o ldexp.o ld-lnk960.o ld-gld68k.o \ - ld-gld.o ld-gld960.o ld-emul.o ldversion.o ldmisc.o ldsym.o ldfile.o - -HEADERS=config.h ldmain.h ldmain.h ldmisc.h ldsym.h ldlang.h ldexp.h \ - ldlex.h ldwrite.h ldversion.h ld-emul.h ldfile.h ldgram.h ld.h - -MANSOURCES=ld.tex - -LDCSOURCES=ldlang.c ldmain.c ldwrite.c ld-lnk960.c ld-gld.c ld-gld68k.c \ - ld-gld960.c ld-emul.c ldversion.c ldmisc.c ldexp.c ldsym.c ldfile.c - -GENERATED_SOURCES=ldgram.tab.c ldlex.c ldgram.tab.h y.tab.h -GENERATED_HEADERS=ldgram.tab.h - -LDSOURCES=$(LDCSOURCES) ldgram.y ldlex.l - -BFDSOURCES=../../bfd/common/*.c - -SOURCES= $(LDSOURCES) $(BFDSOURCES) -LINTSOURCES= $(LDCSOURCES) $(BFDSOURCES) $(GENERATED_SOURCES) - -all: Makefile $(PROGS) - - - -$(BFDLIB): $(BFDSOURCES) - (cd ../bfd; make) - -$(PROGS): $(OBJS) $(BFDLIB) -# (cd ../bfd; make) -# LDEMULATION=gld; export LDEMULATION; GNUTARGET=a.out-generic-big;./ldok -format a.out-generic-big -o ld /lib/crt0.o $(OBJS) $(BFDLIB) -lc /usr/local/lib/gcc/sparc/1.91/gnulib -# gld -o ld /lib/crt0.o $(OBJS) $(BFDLIB) -lc /usr/local/lib/gcc/sparc/1.91/gnulib - $(CC) -Bstatic -o ld.new $(OBJS) $(BFDLIB) - - -ld1: ld - gcc -v -B./ -o ld1 $(OBJS) $(BFDLIB) - -ld2: ld1 - mv ld1 ld - gcc -v -B./ -o ld2 $(OBJS) $(BFDLIB) - -ld3: ld2 - mv ld2 ld - gcc -v -B./ -o ld3 $(OBJS) $(BFDLIB) - -ld.dvi:ld.tex - tex ld.tex - -ldgram.o: ldgram.y -ldgram.tab.h:ldgram.y - cp y.tab.h ldgram.tab.h - -ldlex.c: ldlex.l ldgram.tab.h -ldlex.o: ldlex.c ldgram.tab.h - -ldmain.o: ldmain.c -ldversion.o: ldversion.c -ldfile.o: ldfile.c -ldwrite.o: ldwrite.c -ldlang.o: ldlang.c ldgram.tab.h -ld-gld.o: ld-gld.c -ld-gld68k.o: ld-gld68k.c -ld-gld960.o: ld-gld960.c -ld-emul.o: ld-emul.c -ld-lnk960.o: ld-lnk960.c -ldexp.o: ldexp.c ldgram.tab.h -ldmisc.o: ldmisc.c -ldsym.o: ldsym.c - -clean: - - rm -f $(OBJS) $(GENERATED_SOURCES) $(GENERATED_HEADERS) - - rm -f ld ld1 ld2 ld3 ld.new - - -lintlog:$(SOURCES) Makefile - $(LINT) -abhxzn $(LINTFLAGS) $(LINTSOURCES) \ -| grep -v "pointer casts may be troublesome" \ -| grep -v "possible pointer alignment problem" \ -| grep -v "ignore" \ -| grep -v "conversion from long may lose accuracy" \ -| grep -v "warning: constant argument to NOT" \ -| grep -v "enumeration type clash, operator CAST" \ -| grep -v "warning: constant in conditional context"\ -| grep -v "archive\.c" - - -tags TAGS:$(SOURCES) $(HEADERS) - etags -t $(SOURCES) $(HEADERS) - -release: - (cd /4/steve/ld; tar cf - $(LDSOURCES) $(HEADERS) $(MANSOURCES)) | tar xf - - -objdump:objdump.c - -install: $(PROGS) - rm -f $G960BASE/bin/$(PROGS) - cp $(PROGS) $$G960BASE/bin/gld960c - -#----------------------------------------------------------------------------- -# 'STANDARD' GNU/960 TARGETS BELOW THIS POINT -# -# 'VERSION' file must be present and contain a string of the form "x.y" -#----------------------------------------------------------------------------- - -ver960.c: FORCE - rm -f ver960.c - echo "char ${TARG}_ver[]= \"${TARG} `cat VERSION`, `date`\";" > ver960.c - - -# This target should be invoked before building a new release. -# 'VERSION' file must be present and contain a string of the form "x.y" -# -roll: - @V=`cat VERSION` ; \ - MAJ=`sed 's/\..*//' VERSION` ; \ - MIN=`sed 's/.*\.//' VERSION` ; \ - V=$$MAJ.`expr $$MIN + 1` ; \ - rm -f VERSION ; \ - echo $$V >VERSION ; \ - echo Version $$V - -# Dummy target to force execution of dependent targets. -# -.force: -FORCE: - -# Target to uncomment host-specific lines in this makefile. Such lines must -# have the following string beginning in column 1: #____# -# Original Makefile is backed up as 'Makefile.old'. -# -# Invoke with: make make HOST=xxx -# -make: - -@if test $(HOST)x = x ; then \ - echo 'Specify "make make HOST=???"'; \ - exit 1; \ - fi ; \ - grep -s "^#The next line was generated by 'make make'" Makefile; \ - if test $$? = 0 ; then \ - echo "Makefile has already been processed with 'make make'";\ - exit 1; \ - fi ; \ - mv -f Makefile Makefile.old; \ - echo "#The next line was generated by 'make make'" >Makefile ; \ - echo "HOST=$(HOST)" >>Makefile ; \ - echo >>Makefile ; \ - sed "s/^#__$(HOST)__#//" < Makefile.old >>Makefile - -# - -Makefile: ../common/Makefile - mv Makefile Makefile.backup - cp ../common/Makefile . - $(MAKE) "HOST=$(HOST)" make - -### Local Variables: *** -### mode:fundamental *** -### page-delimiter: "^# " *** -### End: *** -### end of file diff --git a/ld/Makefile.in b/ld/Makefile.in deleted file mode 100644 index 0e052b6d928..00000000000 --- a/ld/Makefile.in +++ /dev/null @@ -1,489 +0,0 @@ -# Makefile for the GNU linker ld (version 2) -# Copyright (C) 1989-1991 Free Software Foundation, Inc. - -# This file is part of GNU ld.. - -# 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., 675 Mass Ave, Cambridge, MA 02139, USA. - -# -# $Id$ -# - -srcdir = . - -ddestdir = /usr/local - -#version=/`$(unsubdir)/../gcc$(subdir)/gcc -dumpversion` -version= -bindir = $(ddestdir)/bin -gcclibdir = $(ddestdir)/lib/gcc/$(target_alias)$(version) - -# Seach path to override the default search path for -lfoo libraries. -# If LIB_PATH is empty, the ones in the script (if any) are left alone. -# Otherwise, they are replaced with the ones given in LIB_PATH, -# which may have the form: LIB_PATH=/lib:/usr/local/lib -LIB_PATH = - -INSTALL = install -c -INSTALL_PROGRAM = $(INSTALL) -INSTALL_FILE = $(INSTALL) - -BASEDIR = ../.. -INCLUDE = $(srcdir)/../include -INCLUDES = -I. -I$(srcdir) -I$(INCLUDE) -MINUS_G = -g - -# Where to find texinfo.tex to format docn with TeX -TEXIDIR = $(srcdir)/../texinfo/fsf - -# Whether to get roff to put indexing entries on stderr -TEXI2OPT = -# You neeed this to generate ld-index.ms (or .mm or .me) -# TEXI2OPT = -i - -# Which roff program to use to generate index for texi2roff'd doc -ROFF = groff - -BISON = bison -BISONFLAGS = -v - -SCRIPTS = ldgld68k.sc ldgld.sc \ - ldlnk960.sc ldlnk960r.sc ldgld960.sc \ - i386aout.sc ldm88k.sc ldglda29k.sc news.sc h8300hds.sc ebmon29k.sc - -#### target and host dependent Makefile fragments come in here. -### - -CFLAGS = $(INCLUDES) $(MINUS_G) $(HDEFINES) $(TDEFINES) $(CDEFINES) -LINTFLAGS = $(INCLUDES) $(EXTRA_DEF) - -.SUFFIXES: .y .x .xr .xu .xn .xN .sc .scu .scr .scn $(SUFFIXES) - -# go directly to ld.new in case this ld isn't capable of -# linking native object on this host. It can be renamed on -# install. -LD_PROG = ld.new - -# A .sc script file is needed for each emulation mode. -# sed is used to transform this script into two variant forms: -# A .scr script is for linking without relocation (-r flag). -# A .scu script is like .scr, but *do* create constructors. -# A .scn script is for linking with -N flag (mix text and data on same page). -# A .scN script is for linking with -N flag (mix text and data on same page). -# The diference is that segments should (need) not be page aligned. - -# A sed pattern to translate .sc to .scu: -SED_MAKE_RELOC_WITH_CONSTRUCTORS=\ - -e "/If relocating/,/End if relocating/d" \ - -e "/=/s/[_a-zA-Z.]* *= .*//g" \ - -e '/>/s/} *> *[a-zA-Z]*/}/' \ - -e "/text/s/[.]text .*:/.text :/" \ - -e "/data/s/[.]data .*:/.data :/" -# A sed pattern to translate .scu to .scr: -SED_REMOVE_CONSTRUCTORS= -e /CONSTRUCTORS/d - -.sc.scu: - sed $(SED_MAKE_RELOC_WITH_CONSTRUCTORS) $< >$*.scu -.scu.scr: - sed $(SED_REMOVE_CONSTRUCTORS) < $< >$*.scr - -# Each builtin script file is included as a C string literal. -# These are generated by the mkscript filter. -.sc.x: - if [ "x"$(LIB_PATH) = "x" ]; then ./mkscript < $< >$*.x ; \ - else \ - (sed <$< -e '/SEARCH_DIR(.*)/d' ; \ - echo $(LIB_PATH) | tr ':' ' ' | sed -e 's/\([^ ][^ ]*\)/SEARCH_DIR(\1);/g';) | ./mkscript >$*.x;\ - fi - -# The .xn script is used if the -n flag is given (write-protect text).. -# Sunos starts the text segment for demand-paged binaries at 0x2020 -# and other binaries at 0x2000, since the exec header is paged in -# with the text. Some other Unix variants do the same. -# For -n and -N flags the offset of the exec header must be removed. -# This sed script does this if the master script contains -# a line of the form ".text 0xAAAA BLOCK(0xBBBB):" - the -# output will contain ".text 0xBBBB:". (For Sunos AAAA=2020 and BBBB=2000.) -.x.xn: - sed -e '/text/s/\.text .* BLOCK(\([^)]*\)):/.text \1:/' < $< >$*.xn - -# The .xN script is used if the -N flag is given (don't write-protect text). -# This is like -n, except that the data segment need not be page-aligned. -# So get rid of commands for page-alignment: We assume these use ALIGN -# with a hex constant that end with 00, since any normal page size is be -# at least divisible by 256. We use the 00 to avoid matching -# anything that tries to align of (say) 8-byte boundaries. -.xn.xN: - sed -e '/ALIGN/s/ALIGN( *0x[0-9a-fA-F]*00 *)/./' < $< >$*.xN - -# The xu and xr scripts don't search libraries, so LIB_PATH doesn't matter. -.sc.xu: - sed $(SED_MAKE_RELOC_WITH_CONSTRUCTORS) < $< | ./mkscript >$*.xu -.sc.xr: - sed $(SED_MAKE_RELOC_WITH_CONSTRUCTORS) $(SED_REMOVE_CONSTRUCTORS) \ - < $< | ./mkscript >$*.xr - -# for self hosting -BFDLIB=$(unsubdir)/../bfd$(subdir)/libbfd.a -LIBIBERTY=$(unsubdir)/../libiberty$(subdir)/libiberty.a - -OFILES= ldgram.o ldlex.o ldlang.o ldctor.o ldmain.o ldindr.o \ - ldwarn.o ldwrite.o ldexp.o ldlnk960.o ld__gld68k.o ld__i386aout.o \ - ld__m88k.o ld__glda29k.o ld__news.o h8300hds.o ld__ebmon29k.o \ - ld__gld.o ldgld960.o ldemul.o ldver.o ldmisc.o ldsym.o ldvanilla.o ldfile.o - -HEADERS=config.h ldmain.h ldmain.h ldwarn.h ldmisc.h ldindr.h \ - ldsym.h ldctor.h ldlang.h ldexp.h \ - ldlex.h ldwrite.h ldver.h ldemul.h ldfile.h ldgram.h ld.h - -MANSOURCES=ld.tex - -LDCSOURCES=ldlang.c ldctor.c ldindr.c ldmain.c ldwrite.c ldwarn.c ldlnk960.c \ - ld__gld.c ld__gld68k.c ld__m88k.c ld__ebmon29k.c \ - ldgld960.c ldemul.c ldver.c ldmisc.c ldexp.c ldsym.c ldfile.c ldvanilla.c - -GENERATED_SOURCES=ldgram.c ldlex.c ldgram.h ld__*.c -GENERATED_HEADERS=ldgram.h - -LDSOURCES=$(LDCSOURCES) ldgram.y ldlex.l ldgram.h - -BFDSOURCES=../../bfd/common/*.c - -SOURCES= $(LDSOURCES) $(BFDSOURCES) -LINTSOURCES= $(LDCSOURCES) $(BFDSOURCES) $(GENERATED_SOURCES) - -STAGESTUFF = *.x *.x[ru] *.sc[ru] $(GENERATED_SOURCES) $(GENERATED_HEADERS) $(OFILES) $(LD_PROG) mkscript - -all: Makefile $(LD_PROG) ld.info - -ldgram.h ldgram.c: ldgram.y - $(BISON) $(BISONFLAGS) -d $(VPATH)/ldgram.y - mv -f y.tab.c ldgram.c - mv -f y.tab.h ldgram.h - -ldlex.c: ldlex.l - lex -t $(VPATH)/ldlex.l >ldlex.c - -# These all start with ld__ so 'make clean' can find them. - -ld__gld.c: $(srcdir)/ldtemplate - sed -e s/""/ldgld/g -e s/""/m68k/g \ - -e s/""//g -e s/""//g <$(srcdir)/ldtemplate >$@ -ld__news.c: $(srcdir)/ldtemplate - sed -e s/""/news/g -e s/""/m68k/g \ - -e s/""/news/g -e s/""/NEWS/g <$(srcdir)/ldtemplate >$@ - -ld__i386aout.c: $(srcdir)/ldtemplate - sed -e s/""/i386aout/g -e s/""/i386/g \ - -e s/""/i386aout/g -e s/""/I386AOUT/g <$(srcdir)/ldtemplate >$@ - - -ld__ebmon29k.c: $(srcdir)/ldtemplate - sed -e s/""/ebmon29k/g -e s/""/a29k/g \ - -e s/"gld"/ebmon29k/g -e s/"GLD"/EBMON29K/g \ - -e s/".x"/ebmon.x/ <$(srcdir)/ldtemplate >$@ - -ld__gld68k.c: $(srcdir)/ldtemplate - sed -e s/""/ldgld68k/g -e s/""/m68k/g \ - -e s/""/68k/g -e s/""/68K/g <$(srcdir)/ldtemplate >$@ -ld__glda29k.c: $(srcdir)/ldtemplate - sed -e s/""/ldglda29k/g -e s/""/a29k/g \ - -e s/""/29k/g -e s/""/29K/g <$(srcdir)/ldtemplate >$@ -ld__m88k.c: $(srcdir)/ldtemplate - sed -e s/""/ldm88k/g -e s/""/m88k/g \ - -e s/""/m88kbcs/g -e s/""/M88KBCS/g <$(srcdir)/ldtemplate >$@ - -# The .c files for these are generated from ldtemplete. -ld__gld.o: ./mkscript ldgld.x ldgld.xr ldgld.xu ldgld.xn ldgld.xN -ld__news.o: ./mkscript news.x news.xr news.xu news.xn news.xN -ld__i386aout.o: ./mkscript i386aout.x i386aout.xr i386aout.xu i386aout.xn i386aout.xN -ld__ebmon29k.o: ./mkscript ebmon29k.x ebmon29k.xr ebmon29k.xu \ - ebmon29k.xn ebmon29k.xN -ld__gld68k.o: ./mkscript ldgld68k.x ldgld68k.xr ldgld68k.xu \ - ldgld68k.xn ldgld68k.xN -ld__glda29k.o: ./mkscript ldglda29k.x ldglda29k.xr ldglda29k.xu \ - ldglda29k.xn ldglda29k.xN -ld__m88k.o: ./mkscript ldm88k.x ldm88k.xr ldm88k.xu ldm88k.xn ldm88k.xN - -# The .c files for these are (for now) specially written (not ldtemplete). -ldgld960.o: ./mkscript ldgld960.x -ldlnk960.o: ./mkscript ldlnk960.x ldlnk960.xr -h8300hds.o: ./mkscript h8300hds.x - - -#$(BFDLIB): $(BFDSOURCES) -# (cd ../bfd; make) - -$(LD_PROG): $(OFILES) $(BFDLIB) $(LIBIBERTY) - $(CC) $(CFLAGS) $(LDFLAGS) -o $(LD_PROG) $(OFILES) $(BFDLIB) $(LIBIBERTY) $(LOADLIBES) - -# (cd ../bfd; make) -# LDEMULATION=gld; export LDEMULATION; GNUTARGET=a.out-sunos-big;./ldok -format a.out-sunos-big -o ld /lib/crt0.o $(OFILES) $(BFDLIB) $(LIBIBERTY) -lc /usr/local/lib/gcc/sparc/1.91/gnulib -# gld -o ld /lib/crt0.o $(OFILES) $(BFDLIB) $(LIBIBERTY) -lc /usr/local/lib/gcc/sparc/1.91/gnulib -# $(CC) -Bstatic -o ld.new $(OFILES) $(BFDLIB) $(LIBIBERTY) - - -ld1: ld.new - $(HOSTING_EMU); ./ld.new -o ld1 $(HOSTING_CRT0) $(OFILES) $(BFDLIB) $(LIBIBERTY) $(HOSTING_LIBS) - -ld2: ld1 - $(HOSTING_EMU); ./ld1 -o ld2 $(HOSTING_CRT0) $(OFILES) $(BFDLIB) $(LIBIBERTY) $(HOSTING_LIBS) - -ld3: ld2 - $(HOSTING_EMU); ./ld2 -o ld3 $(HOSTING_CRT0) $(OFILES) $(BFDLIB) $(LIBIBERTY) $(HOSTING_LIBS) - -###################################################################### -# DOCUMENTATION TARGETS -# TeX output -ld.dvi: $(srcdir)/ld.texinfo - TEXINPUTS=${TEXIDIR}:.:$$TEXINPUTS tex $(srcdir)/ld.texinfo - texindex ld.?? - TEXINPUTS=${TEXIDIR}:.:$$TEXINPUTS tex $(srcdir)/ld.texinfo - -# info file for online browsing -ld.info: $(srcdir)/ld.texinfo - - $(MAKEINFO) -o ld.info $(srcdir)/ld.texinfo - -#separate targets for "ms", "me", and "mm" forms of roff doc -# (we don't use a variable because we don't trust all makes to handle -# a var in the target name right). -# roff output (-ms) -ld.ms: $(srcdir)/ld.texinfo - sed -e '/\\input texinfo/d' \ - -e '/@c TEXI2ROFF-KILL/,/@c END TEXI2ROFF-KILL/d' \ - $(srcdir)/ld.texinfo | \ - texi2roff $(TEXI2OPT) -ms >ld.ms - -# index for roff output -ld-index.ms: ld.ms - $(ROFF) -ms ld.ms 2>&1 1>/dev/null | \ - sed -e '/: warning:/d' | \ - texi2index >ld-index.ms - -# roff output (-mm) -ld.mm: $(srcdir)/ld.texinfo - sed -e '/\\input texinfo/d' \ - -e '/@c TEXI2ROFF-KILL/,/@c END TEXI2ROFF-KILL/d' \ - -e 's/{.*,,/{/' \ - -e '/@noindent/d' \ - $(srcdir)/ld.texinfo | \ - texi2roff $(TEXI2OPT) -mm | \ - sed -e 's/---/\\(em/g' \ - >ld.mm - -# index for roff output -ld-index.mm: ld.mm - $(ROFF) -mm ld.mm 2>&1 1>/dev/null | \ - sed -e '/: warning:/d' | \ - texi2index >ld-index.mm - -# roff output (-me) -ld.me: $(srcdir)/ld.texinfo - sed -e '/\\input texinfo/d' \ - -e '/@c TEXI2ROFF-KILL/,/@c END TEXI2ROFF-KILL/d' \ - $(srcdir)/ld.texinfo | \ - texi2roff $(TEXI2OPT) -me >ld.me - -# index for roff output -ld-index.me: ld.me - $(ROFF) -me ld.me 2>&1 1>/dev/null | \ - sed -e '/: warning:/d' | \ - texi2index >ld-index.me - - -###################################################################### - -mkscript: $(srcdir)/mkscript.c - $(CC) $(CFLAGS) $(LDFLAGS) -o mkscript $(srcdir)/mkscript.c $(LOADLIBES) - -ldlex.c: ldlex.l ldgram.h -ldlex.o: ldlex.c ldgram.h -ldgram.o: ldgram.c -ldgram.c:ldgram.y - -ldgld68k.x :ldgld68k.sc -ldgld68kUr.x :ldgld68kUr.sc -ldgld68kr.x :ldgld68kr.sc -h8300hds.x:h8300hds.sc -ldgld.x :ldgld.sc -ldgldUr.x :ldgldUr.sc -ldgldr.x :ldgldr.sc -ldlnk960.x :ldlnk960.sc -ldlnk960r.x :ldlnk960r.sc -ldgld960.x :ldgld960.sc -ldgldm88k.x :ldgldm88k.sc -ldm88kUr.x :ldm88kUr.sc -ldm88kr.x:ldm88kr.sc -ldm88k.x:ldm88k.sc -news.x:news.sc -i386aout.x:i386aout.sc -h8300hds.x:h8300hds.sc -h8300hds.o:h8300hds.c -ldgld68k.x:ldgld68k.sc -ldglda29k.x :ldglda29k.sc -ldglda29kr.x :ldglda29kr.sc -ldglda29kUr.x :ldglda29kUr.sc - -ebmon29k.x :ebmon29k.sc -ebmon29kr.x :ebmon29kr.sc -ebmon29kUr.x :ebmon29kUr.sc - -stage1: force - - mkdir stage1 - - mv -f $(STAGESTUFF) stage1 - - (cd stage1 ; ln -s $(LD_PROG) ld) - -stage2: force - - mkdir stage2 - - mv -f $(STAGESTUFF) stage2 - - (cd stage2 ; ln -s $(LD_PROG) ld) - -stage3: force - - mkdir stage3 - - mv -f $(STAGESTUFF) stage3 - - (cd stage3 ; ln -s $(LD_PROG) ld) - -against=stage2 - -comparison: force - for i in $(STAGESTUFF) ; do cmp $$i $(against)/$$i ; done - -de-stage1: force - - (cd stage1 ; mv -f * ..) - - rm ld - - rmdir stage1 - -de-stage2: force - - (cd stage2 ; mv -f * ..) - - rm ld - - rmdir stage2 - -de-stage3: force - - (cd stage3 ; mv -f * ..) - - rm ld - - rmdir stage3 - -clean: - - rm -f TAGS $(OFILES) $(GENERATED_SOURCES) $(GENERATED_HEADERS) - - rm -f *.x *.x[runN] *.sc[runN] - - rm -f ld.?? ld.??? - - rm -f ld ld1 ld2 ld3 ld.new mkscript *.o y.output - -lintlog:$(SOURCES) Makefile - $(LINT) -abhxzn $(LINTFLAGS) $(LINTSOURCES) \ -| grep -v "pointer casts may be troublesome" \ -| grep -v "possible pointer alignment problem" \ -| grep -v "ignore" \ -| grep -v "conversion from long may lose accuracy" \ -| grep -v "warning: constant argument to NOT" \ -| grep -v "enumeration type clash, operator CAST" \ -| grep -v "warning: constant in conditional context"\ -| grep -v "archive\.c" - - -tags TAGS:$(SOURCES) $(HEADERS) - etags -t $? - - -objdump:objdump.c - -install: $(LD_PROG) - $(INSTALL_PROGRAM) ld.new $(ddestdir)/bin/ld - $(INSTALL_PROGRAM) ld.new $(gcclibdir)/ld - for i in ld.info* ; do \ - echo Installing $$i... ; \ - (cp $$i $(idestdir)/info/$$i.new \ - && mv -f $(idestdir)/info/$$i.new $(idestdir)/info/$$i) \ - || exit 1 ; \ - done - -# Something like the following might make sense for install, but doesn't work -# - it is too fragile, depending on a gcc binary int the right place. -# Perhaps using gcc/version.c might work? -# # If $(gcclibdir) exists, install ld there, and put a link to it -# # from $(bindir); otherwise put ld in $(bindir). -# if ([ -x $(unsubdir)/../gcc$(subdir)/gcc -a -d $(gcclibdir) ]); then \ -# $(INSTALL_PROGRAM) ld.new $(gcclibdir)/ld; \ -# cd $(bindir); rm -f ld; ln -s $(gcclibdir)/ld ld; \ -# else \ -# $(INSTALL_PROGRAM) ld.new $(bindir)/ld; \ -# fi - -#----------------------------------------------------------------------------- -# 'STANDARD' GNU/960 TARGETS BELOW THIS POINT -# -# 'VERSION' file must be present and contain a string of the form "x.y" -#----------------------------------------------------------------------------- - -ver960.c: FORCE - rm -f ver960.c - echo "char ${TARG}_ver[]= \"${TARG} `cat VERSION`, `date`\";" > ver960.c - - -# This target should be invoked before building a new release. -# 'VERSION' file must be present and contain a string of the form "x.y" -# -roll: - @V=`cat VERSION` ; \ - MAJ=`sed 's/\..*//' VERSION` ; \ - MIN=`sed 's/.*\.//' VERSION` ; \ - V=$$MAJ.`expr $$MIN + 1` ; \ - rm -f VERSION ; \ - echo $$V >VERSION ; \ - echo Version $$V - - -dep: $(LDSOURCES) - mkdep $(CFLAGS) $? - -# Dummy target to force execution of dependent targets. -# -force: - -# Target to uncomment host-specific lines in this makefile. Such lines must -# have the following string beginning in column 1: #____# -# Original Makefile is backed up as 'Makefile.old'. -# -# Invoke with: make make HOST=xxx -# -make: - -@if test $(HOST)x = x ; then \ - echo 'Specify "make make HOST=???"'; \ - exit 1; \ - fi ; \ - grep -s "^#The next line was generated by 'make make'" Makefile; \ - if test $$? = 0 ; then \ - echo "Makefile has already been processed with 'make make'";\ - exit 1; \ - fi ; \ - mv -f Makefile Makefile.old; \ - echo "#The next line was generated by 'make make'" >Makefile ; \ - echo "HOST=$(HOST)" >>Makefile ; \ - echo >>Makefile ; \ - sed "s/^#__$(HOST)__#//" < Makefile.old >>Makefile - -# - -Makefile: $(srcdir)/Makefile.in $(host_makefile_frag) $(target_makefile_frag) - $(SHELL) ./config.status - -### Local Variables: *** -### mode:fundamental *** -### page-delimiter: "^# " *** -### End: *** -### end of file - - -# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/ld/README b/ld/README deleted file mode 100644 index f6da8285b1f..00000000000 --- a/ld/README +++ /dev/null @@ -1,51 +0,0 @@ -This is a BETA release of a completely rewritten GNU linker. -It is distributed with other "binary utilities" which should -be in ../binutils. See ../binutils/README for more general notes, -including where to send bug reports. - -There are many new features of the linker: - -* The linker uses a Binary File Descriptor library (../bfd) -that it uses to read and write object files. This helps -insulate the linker itself from the format of object files. - -* The linker support a number of different object file -formats. It can even handle multiple formats at once: -Read two input formats and write a third. - -* The linker can be configured for cross-linking. - -* The linker contains a control language. - -* There is a manual. - -Installation -============ - -See ../binutils/README. -If you want to make a cross-linker, you may want to specify -a different search path of -lfoo libraries than the default. -You can do this by setting the LIB_PATH variable in ./Makefile. - -Porting to a new target -======================= - -A new target configuration may need a new linker script (.sc file) -to specify linker actions (such as the layout of the output). -See if one of the existing ones are suitable. -Note that the Makefile generates variants of the standard script -that are used when ld is passed -r -Ur -N or -n options. -These variant default scripts are generated from the "master" -script using sed scripts that may not work in all cases. -Look at the rules and comments in ld/Makefile.in to make sure -you stay with the rules. - -Otherwise, you may need to add a new "emulation" (a sample of a -recently added target and emulation is for the SOny 68k News -family - look for files named *news*). - -Also see the notes in ../binutils/README. - -Reporting bugs etc -=========================== -See ../binutils/README. diff --git a/ld/config.h b/ld/config.h deleted file mode 100644 index 98c5cf3affd..00000000000 --- a/ld/config.h +++ /dev/null @@ -1,62 +0,0 @@ -/* config.h - - - Copyright (C) 1991 Free Software Foundation, Inc. - - This file is part of GLD, the Gnu Linker. - - GLD is free software; you can redistribute it and/or modify - it under the terms of the GNU Genexral Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - GLD 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 GLD; see the file COPYING. If not, write to - the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* Look in this environment name for the linker to pretend to be */ -#define EMULATION_ENVIRON "LDEMULATION" -/* If in there look for the strings: */ -#define GLD_EMULATION_NAME "gld" -#define VANILLA_EMULATION_NAME "vanilla" -#define GLDM88KBCS_EMULATION_NAME "gldm88kbcs" -#define GLD68K_EMULATION_NAME "gld68k" -#define GLD960_EMULATION_NAME "gld960" -#define GLD29K_EMULATION_NAME "gld29k" -#define GLDNEWS_EMULATION_NAME "gldnews" -#define LNK960_EMULATION_NAME "lnk960" -#define H8300HDS_EMULATION_NAME "h8300hds" -#define EBMON29K_EMULATION_NAME "ebmon29k" -#define GLDI386AOUT_EMULATION_NAME "gldi386aout" -/* Otherwise default to this emulation */ -#ifndef DEFAULT_EMULATION -#ifdef GNU960 -#define DEFAULT_EMULATION GLD960_EMULATION_NAME -#else -#define DEFAULT_EMULATION GLD68K_EMULATION_NAME -#endif -#endif /* DEFAULT_EMULATION */ - -/* Look in this variable for a target format */ -#define TARGET_ENVIRON "GNUTARGET" -/* If not there then choose this */ -#define GLD_TARGET "a.out-sunos-big" -#define GLD68K_TARGET "a.out-sunos-big" -#define LNK960_TARGET "coff-Intel-big" -#define GLD960_TARGET "b.out.big" -#define VANILLA_TARGET "a.out-sunos-big" -#define GLDM88KBCS_TARGET "m88kbcs" -#define GLD29K_TARGET "coff-a29k-big" -#define GLDI386AOUT_TARGET "a.out-i386" -#define GLDNEWS_TARGET "a.out-newsos3" -#define H8300HDS_TARGET "ieee" -#define EBMON29K_TARGET "coff-a29k-big" - - - - - diff --git a/ld/config.sub b/ld/config.sub deleted file mode 100755 index dac9ab89d4f..00000000000 --- a/ld/config.sub +++ /dev/null @@ -1,446 +0,0 @@ -#!/bin/sh - -# Configuration subroutine to validate and canonicalize a configuration type. -# Supply the specified configuration type as an argument. -# If it is invalid, we print an error message on stderr and exit with code 1. -# Otherwise, we print the canonical config type on stdout and succeed. - -# This file is supposed to be the same for all GNU packages -# and recognize all the CPU types, system types and aliases -# that are meaningful with *any* GNU software. -# Each package is responsible for reporting which valid configurations -# it does not support. The user should be able to distinguish -# a failure to support a valid configuration from a meaningless -# configuration (e.g. a typo). - -# Please email any bugs, comments, and/or additions to this file to: -# configure@cygnus.com - -# decode aliases into canonical names - -case "$1" in -# cpu alone is a valid alias for cpu-none-none. -vax | tahoe | i386 | i860 | m68k | m68000 | m88k | sparc | ns32k \ - | alliant | arm | c1 | c2 | mips | pyramid | tron | a29k \ - | romp | rs6000 | i960 | h8300) - cpu=$1 - vendor=none - os=none - ;; -altos | altos3068) - cpu=m68k - vendor=altos - os=sysv # maybe? - ;; -altosgas) - cpu=m68k - vendor=altos - os=gas - ;; -am29k) - cpu=a29k - vendor=none - os=bsd - ;; -amdahl) - cpu=580 - vendor=amdahl - os=uts - ;; -amigados) - cpu=m68k - vendor=cbm - os=amigados # Native AmigaDOS - ;; -amigaunix | amix) - cpu=m68k - vendor=cbm - os=svr4 # System V Release 4 (svr4 is an industry recognized acronym) - ;; -apollo68) - cpu=m68k - vendor=apollo - os=sysv # maybe? - ;; -balance) - cpu=ns32k - vendor=sequent - os=dynix - ;; -convex-c1) - cpu=c1 - vendor=convex - os=sysv # maybe? - ;; -convex-c2) - cpu=c2 - vendor=convex - os=sysv # maybe? - ;; -cray | ymp) - cpu=ymp - vendor=cray - os=unicos - ;; -cray2) - cpu=cray2 - vendor=cray - os=unicos - ;; -dec3100 | decstatn | decstation | decstation-3100 | pmax | pmin) - cpu=mips - vendor=dec - os=ultrix - ;; -delta | 3300 | motorola-3300 | motorola-delta \ - | 3300-motorola | delta-motorola) - cpu=m68k - vendor=motorola - os=sysv # maybe? - ;; - -delta88) - cpu=m88k - vendor=motorola - os=m88kbcs - ;; - -gmicro) - cpu=tron - vendor=gmicro - os=sysv # maybe? - ;; - -h8300hds) - cpu=h8300 - vendor=hitachi - os=hds - ;; - -# start-sanitize-v9 -hal-32 | hal32) - cpu=sparc64 - vendor=hal - os=hal32 - ;; -hal-64 | hal64) - cpu=sparc64 - vendor=hal - os=hal64 - ;; -sparc64) - cpu=sparc64 - vendor=sun - os=v9 - ;; -sparc64-v7 | sparc64v7) - cpu=sparc64 - vendor=sun - os=v7 - ;; -# end-sanitize-v9 -hp300bsd) - cpu=m68k - vendor=hp - os=bsd - ;; -hp300hpux | hpux | hp9k3[2-9][0-9]) - cpu=m68k - vendor=hp - os=hpux - ;; -hp9k31[0-9] | hp9k2[0-9][0-9]) - cpu=m68000 - vendor=hp - os=hpux - ;; -i386sco) - cpu=i386 - vendor=sco - os=sysv # maybe? - ;; -i386v) - cpu=i386 - vendor=none - os=sysv - ;; -i386v32) - cpu=i386 - vendor=none - os=sysv32 - ;; -iris | iris4d) - cpu=mips - vendor=sgi - os=irix # maybe? - ;; - -dpx2) - vendor=bull - cpu=m68k - os=sysv - ;; -isi | isi68) - cpu=m68k - vendor=isi - os=sysv # maybe? - ;; -littlemips) - cpu=mips - vendor=little - os=bsd - ;; -magnum | m3230) - cpu=mips - vendor=mips - os=sysv # maybe? - ;; -merlin) - cpu=ns32k - vendor=utek - os=sysv # maybe? - ;; -miniframe) - cpu=m68000 - vendor=convergent - os=sysv # maybe? - ;; -mmax) - cpu=ns32k - vendor=encore - os=sysv # maybe? - ;; -news | news700 | news800 | news900) - cpu=m68k - vendor=sony - os=newsos3 # Based on bsd-4.3 - ;; -news1000) - cpu=m68030 - vendor=sony - os=newsos3 # ? - ;; -news-3600 | bigmips | risc-news) - cpu=mips - vendor=sony - os=newsos4 # Presumably? - ;; -next) - cpu=m68k - vendor=next - os=sysv # maybe? - ;; -nindy960) - cpu=i960 - vendor=intel - os=nindy - ;; -none) - cpu=none - vendor=none - os=none - ;; -np1) - cpu=np1 - vendor=gould - os=sysv # maybe? - ;; -rtpc) - cpu=romp - vendor=ibm - os=aix # maybe? - ;; -pbd) - cpu=sparc - vendor=unicom - os=sysv - ;; -pn) - cpu=pn - vendor=gould - os=sysv # maybe? - ;; -ps2) - cpu=i386 - vendor=ibm - os=sysv # maybe? - ;; -sun2) - cpu=m68000 - vendor=sun - os=sunos4 - ;; -sun2os3) - cpu=m68000 - vendor=sun - os=sunos3 - ;; -sun2os4) - cpu=m68000 - vendor=sun - os=sunos4 - ;; -sun3) - cpu=m68k - vendor=sun - os=sunos4 - ;; -sun3os3) - cpu=m68k - vendor=sun - os=sunos3 - ;; -sun3os4) - cpu=m68k - vendor=sun - os=sunos4 - ;; -sun386 | roadrunner | sun386i) - cpu=i386 - vendor=sun - os=sunos - ;; -sun4) - cpu=sparc - vendor=sun - os=sunos4 - ;; -sun4os3) - cpu=sparc - vendor=sun - os=sunos3 - ;; -sun4os4) - cpu=sparc - vendor=sun - os=sunos4 - ;; -symmetry) - cpu=i386 - vendor=sequent - os=dynix - ;; -tower | tower-32) - cpu=m68k - vendor=ncr - os=sysv # maybe? - ;; -ultra3) - cpu=a29k - vendor=nyu - os=sym1 - ;; -umax) - cpu=ns32k - vendor=encore - os=sysv # maybe? - ;; -unixpc | safari | pc7300 | 3b1 | 7300 | 7300-att | att-7300) - cpu=m68k - vendor=att - os=sysv # maybe? - ;; -vax-dec) - cpu=vax - vendor=dec - os=ultrix # maybe? - ;; -vxworks68) - cpu=m68k - vendor=wrs - os=vxworks - ;; -vxworks960) - cpu=i960 - vendor=wrs - os=vxworks - ;; -xmp) - cpu=xmp - vendor=cray - os=unicos - ;; -# not an alias. parse what we expect to be a canonical name. -*) - cpu=`echo $1 | sed 's/-.*$//'` - - if [ "${cpu}" = "$1" ] ; then - # no vendor so this is an invalid name. - echo '***' No vendor: configuration \`$1\' not recognized 1>&2 - exit 1 - else - # parse out vendor - rest=`echo $1 | sed "s/${cpu}-//"` - vendor=`echo ${rest} | sed 's/-.*$//'` - - if [ "${vendor}" = "${rest}" ] ; then - # a missing os is acceptable - os=none - else - os=`echo ${rest} | sed "s/${vendor}-//"` - fi - fi - ;; -esac - -# At this point we should have three parts of a canonical name in cpu, -# vendor, and os. - -# verify that the cpu is known. - -case "${cpu}" in -none | vax | tahoe | i386 | i860 | m68k | m68000 | m88k | sparc \ - | ns32k | alliant | arm | c1 | c2 | mips | pyramid | tron \ - | a29k | romp | rs6000 | i960 | xmp | ymp | cray2 | 580 | h8300) - ;; - -# start-sanitize-v9 -sparc64) ;; -# end-sanitize-v9 - -*) - echo '***' Invalid cpu \`${cpu}\': configuration \`$1\' not recognized 1>&2 - exit 1 - ;; -esac - -# verify that the vendor is known. - -case "${vendor}" in - altos | amdahl | aout | apollo | att | bcs | bout |\ - cbm | convergent | convex | coff | cray | dec | encore |\ - gould | hitachi | intel | isi | hp | ibm | little | mips | motorola |\ - ncr | next | none | nyu | sco | sequent | sgi | sony | sun |\ - unicom | utek | wrs | bull ) ;; - -# start-sanitize-v9 -hal) ;; -# end-sanitize-v9 - -*) - echo '***' Invalid vendor \`${vendor}\': configuration \`$1\' not recognized 1>&2 - exit 1 - ;; -esac - -# verify that the os is known, if it exists. - -case "${os}" in -aix* | aout | bout | bsd* | coff | ctix* | dynix* | esix* | hpux* \ - | hds | irix* | isc* | kern | mach* | newsos* | nindy* | none \ - | osf* | sco* | sunos* | sysv* | ultrix* | unos* | v88r* \ - | vms* | vxworks* | sym[1-9]* | unicos* | uts | svr4 \ - | amigados) - ;; - -# start-sanitize-v9 -hal32 | hal64 | v7 | v9) ;; -# end-sanitize-v9 - -*) - echo '***' Invalid os \`${os}\': configuration \`$1\' not recognized 1>&2 - exit 1 - ;; -esac - -echo ${cpu}-${vendor}-${os} diff --git a/ld/config/.Sanitize b/ld/config/.Sanitize deleted file mode 100644 index 8d6b9b344be..00000000000 --- a/ld/config/.Sanitize +++ /dev/null @@ -1,52 +0,0 @@ -# Sanitize.in for devo. -# $Id$ -# - -# Each directory to survive it's way into a release will need a file -# like this one called "./.Sanitize". All keyword lines must exist, -# and must exist in the order specified by this file. Each directory -# in the tree will be processed, top down, in the following order. - -# Hash started lines like this one are comments and will be deleted -# before anything else is done. Blank lines will also be squashed -# out. - -# The lines between the "Do-first:" line and the "Things-to-keep:" -# line are executed as a /bin/sh shell script before anything else is -# done in this - -Do-first: - -echo Sanitizing `pwd`... - -if ( echo $* | grep keep\-v9 > /dev/null ) ; then - keep_these_too=h-sun4-64 -fi - -# All files listed between the "Things-to-keep:" line and the -# "Files-to-sed:" line will be kept. All other files will be removed. -# Directories listed in this section will have their own Sanitize -# called. Directories not listed will be removed in their entirety -# with rm -rf. - -Things-to-keep: -mh-decstation -mh-dgux -mh-news -mh-rtbsd -mh-sparc -mh-sparc-ll -mh-sun3 -mt-coff-a29k -mt-ebmon29k -mt-i386-aout -mt-i386v -mt-m68k -mt-m68kv -mt-m88k-bcs -mt-news -mt-sun4 -Do-last: - -echo Done in `pwd`. -# End of file. diff --git a/ld/config/coff-a29k.mt b/ld/config/coff-a29k.mt deleted file mode 100644 index 5c554154c92..00000000000 --- a/ld/config/coff-a29k.mt +++ /dev/null @@ -1 +0,0 @@ -TDEFINES = -DDEFAULT_EMULATION=GLD29K_EMULATION_NAME diff --git a/ld/config/decstation.mh b/ld/config/decstation.mh deleted file mode 100755 index 8b2da6f8d98..00000000000 --- a/ld/config/decstation.mh +++ /dev/null @@ -1 +0,0 @@ -YACC=yacc -vd diff --git a/ld/config/delta88.mh b/ld/config/delta88.mh deleted file mode 100644 index 2b1d4a89fb9..00000000000 --- a/ld/config/delta88.mh +++ /dev/null @@ -1,13 +0,0 @@ -HDEFINES = -DHiSTEVE - -CC = gcc -Wall -ansi -YACC=yacc -tvd - -HOSTING_CRT0=/lib/crt0.o -X -HOSTING_LIBS=-lgnu -lc -HOSTING_EMU=LDEMULATION=gldm88kbcs; export LDEMULATION - -INSTALL=cp - - - diff --git a/ld/config/dgux.mh b/ld/config/dgux.mh deleted file mode 100644 index 3e987a432d6..00000000000 --- a/ld/config/dgux.mh +++ /dev/null @@ -1,9 +0,0 @@ -HDEFINES = -D__using_DGUX - -CC = gcc -Wall -ansi -YACC=yacc -tvd - -HOSTING_CRT0=/lib/crt0.o -X -HOSTING_LIBS=/usr/sde/m88kbcs/lib/libc.a -HOSTING_EMU=LDEMULATION=gldm88kbcs; export LDEMULATION - diff --git a/ld/config/ebmon29k.mt b/ld/config/ebmon29k.mt deleted file mode 100644 index f58e37d3af9..00000000000 --- a/ld/config/ebmon29k.mt +++ /dev/null @@ -1 +0,0 @@ -TDEFINES = -DDEFAULT_EMULATION=EBMON29K_EMULATION_NAME diff --git a/ld/config/h-i386v b/ld/config/h-i386v deleted file mode 100755 index 35d9e95d4cd..00000000000 --- a/ld/config/h-i386v +++ /dev/null @@ -1,3 +0,0 @@ -# $Id$ - -HDEFINES=-DHOST_SYS=i386_SYSV_SYS diff --git a/ld/config/h-m68kv b/ld/config/h-m68kv deleted file mode 100755 index b71c6d6cae8..00000000000 --- a/ld/config/h-m68kv +++ /dev/null @@ -1,3 +0,0 @@ -# $Id$ - -HDEFINES=-DHOST_SYS=M68K_SYSV_SYS diff --git a/ld/config/hmake-dec3100 b/ld/config/hmake-dec3100 deleted file mode 100755 index 4a17e631b96..00000000000 --- a/ld/config/hmake-dec3100 +++ /dev/null @@ -1,2 +0,0 @@ -HDEFINES=-DHOST_SYS=DEC3100_SYS -YACC=yacc -vd diff --git a/ld/config/hmake-dgux b/ld/config/hmake-dgux deleted file mode 100755 index 9c4e9bc77ee..00000000000 --- a/ld/config/hmake-dgux +++ /dev/null @@ -1,9 +0,0 @@ -HDEFINES = -DHOST_SYS=DGUX_SYS -D__using_DGUX - -CC = gcc -Wall -ansi -YACC=yacc -tvd - -HOSTING_CRT0=/lib/crt0.o -X -HOSTING_LIBS=/usr/sde/m88kbcs/lib/libc.a -HOSTING_EMU=LDEMULATION=gldm88kbcs; export LDEMULATION - diff --git a/ld/config/hmake-rtbsd b/ld/config/hmake-rtbsd deleted file mode 100755 index 7d2ff5a4754..00000000000 --- a/ld/config/hmake-rtbsd +++ /dev/null @@ -1,7 +0,0 @@ -# The IBM RT/PC has only been supported as a host in a cross-development -# environment. If you don't have gcc, I was able to get 'hc -Hnocpp -ma' -# to compile most of the modules, but didn't try running anything. -YACC = yacc -d -HDEFINES = -DHOST_SYS=RTBSD_SYS -DNO_VARARGS -LDFLAGS = -CC=gcc # hc/pcc just can't cut it diff --git a/ld/config/hmake-sun3 b/ld/config/hmake-sun3 deleted file mode 100755 index 5922ac16306..00000000000 --- a/ld/config/hmake-sun3 +++ /dev/null @@ -1,9 +0,0 @@ -CDEFINES=-DHOST_SYS=SUN3_SYS -#CC=gcc -ansi -Wall -CC=cc -YACC=yacc -d - - -HOSTING_CRT0=/usr/lib/crt0.o /usr/lib/Fcrt1.o -L/usr/lib/fsoft.o -HOSTING_LIBS=-lc -HOSTING_EMU=LDEMULATION=gld68k; export LDEMULATION diff --git a/ld/config/hmake-sun4 b/ld/config/hmake-sun4 deleted file mode 100755 index b53bfde0ae2..00000000000 --- a/ld/config/hmake-sun4 +++ /dev/null @@ -1,8 +0,0 @@ -HDEFINES=-DHOST_SYS=SUN4_SYS -YACC=yacc -tvd -#CC=gcc -Wall -ansi -#stuff for self hosting -HOSTING_CRT0=/lib/crt0.o -HOSTING_LIBS=/limbo/latest/=sun4/lib/gcc/sparc/1.93/gnulib -lc -HOSTING_EMU=LDEMULATION=gld; export LDEMULATION - diff --git a/ld/config/hmake-sun4-64 b/ld/config/hmake-sun4-64 deleted file mode 100755 index 92f74ad36b1..00000000000 --- a/ld/config/hmake-sun4-64 +++ /dev/null @@ -1,8 +0,0 @@ -HDEFINES=-DHOST_SYS=SUN4_SYS -DHOST_64_BIT="long long" -YACC=yacc -tvd -CC=/usr/latest/bin/gcc -Wall -ansi -#stuff for self hosting -HOSTING_CRT0=/lib/crt0.o -HOSTING_LIBS=/limbo/latest/=sun4/lib/gcc/sparc/1.93/gnulib -lc -HOSTING_EMU=LDEMULATION=gld; export LDEMULATION - diff --git a/ld/config/i386-aout.mt b/ld/config/i386-aout.mt deleted file mode 100644 index ecb4d176f19..00000000000 --- a/ld/config/i386-aout.mt +++ /dev/null @@ -1 +0,0 @@ -TDEFINES = -DDEFAULT_EMULATION=GLDI386AOUT_EMULATION_NAME diff --git a/ld/config/i386v.mt b/ld/config/i386v.mt deleted file mode 100644 index ec37d7c4218..00000000000 --- a/ld/config/i386v.mt +++ /dev/null @@ -1,3 +0,0 @@ -# $Id$ - -TDEFINES = -DDEFAULT_EMULATION=i386v_EMULATION_NAME diff --git a/ld/config/m68k.mt b/ld/config/m68k.mt deleted file mode 100644 index d68947ec90a..00000000000 --- a/ld/config/m68k.mt +++ /dev/null @@ -1 +0,0 @@ -TDEFINES = -DDEFAULT_EMULATION=GLD_EMULATION_NAME diff --git a/ld/config/m68kv.mt b/ld/config/m68kv.mt deleted file mode 100644 index 7c5a953e638..00000000000 --- a/ld/config/m68kv.mt +++ /dev/null @@ -1,3 +0,0 @@ -# $Id$ - -TDEFINES = -DDEFAULT_EMULATION=m68kv_EMULATION_NAME diff --git a/ld/config/m88k-bcs.mt b/ld/config/m88k-bcs.mt deleted file mode 100644 index 94e8c66ae5f..00000000000 --- a/ld/config/m88k-bcs.mt +++ /dev/null @@ -1 +0,0 @@ -TDEFINES = -DDEFAULT_EMULATION=GLDM88KBCS_EMULATION_NAME diff --git a/ld/config/news.mh b/ld/config/news.mh deleted file mode 100755 index 41c4647a964..00000000000 --- a/ld/config/news.mh +++ /dev/null @@ -1,8 +0,0 @@ -#CC=gcc -ansi -Wall -CC=cc -YACC=yacc -d - - -HOSTING_CRT0=/lib/crt0.o -HOSTING_LIBS=-lc -HOSTING_EMU=LDEMULATION=gldnews; export LDEMULATION diff --git a/ld/config/news.mt b/ld/config/news.mt deleted file mode 100644 index 51eb1e36974..00000000000 --- a/ld/config/news.mt +++ /dev/null @@ -1 +0,0 @@ -TDEFINES = -DDEFAULT_EMULATION=GLDNEWS_EMULATION_NAME diff --git a/ld/config/rtbsd.mh b/ld/config/rtbsd.mh deleted file mode 100644 index 0493affa789..00000000000 --- a/ld/config/rtbsd.mh +++ /dev/null @@ -1,7 +0,0 @@ -# The IBM RT/PC has only been supported as a host in a cross-development -# environment. If you don't have gcc, I was able to get 'hc -Hnocpp -ma' -# to compile most of the modules, but didn't try running anything. -YACC = yacc -d -HDEFINES = -DNO_VARARGS -LDFLAGS = -CC=gcc # hc/pcc just can't cut it diff --git a/ld/config/sparc-ll.mh b/ld/config/sparc-ll.mh deleted file mode 100644 index 23cdb4727cd..00000000000 --- a/ld/config/sparc-ll.mh +++ /dev/null @@ -1,8 +0,0 @@ -HDEFINES=-DHOST_64_BIT="long long" -YACC=yacc -tvd -CC=/usr/latest/bin/gcc -Wall -ansi -#stuff for self hosting -HOSTING_CRT0=/lib/crt0.o -HOSTING_LIBS=/limbo/latest/=sun4/lib/gcc/sparc/1.93/gnulib -lc -HOSTING_EMU=LDEMULATION=gld; export LDEMULATION - diff --git a/ld/config/sparc.mh b/ld/config/sparc.mh deleted file mode 100755 index 80ae64a9b9d..00000000000 --- a/ld/config/sparc.mh +++ /dev/null @@ -1,7 +0,0 @@ -YACC=yacc -tvd -#CC=gcc -Wall -ansi -#stuff for self hosting -HOSTING_CRT0=/lib/crt0.o -HOSTING_LIBS=/usr/latest/lib/gcc/sun4/1.95.02/libgnu.a -lc -HOSTING_EMU=LDEMULATION=gld; export LDEMULATION - diff --git a/ld/config/sun3.mh b/ld/config/sun3.mh deleted file mode 100644 index 616605090b3..00000000000 --- a/ld/config/sun3.mh +++ /dev/null @@ -1,8 +0,0 @@ -#CC=gcc -ansi -Wall -CC=cc -YACC=yacc -d - - -HOSTING_CRT0=/usr/lib/crt0.o /usr/lib/Fcrt1.o -L/usr/lib/fsoft.o -HOSTING_LIBS=-lc -HOSTING_EMU=LDEMULATION=gld68k; export LDEMULATION diff --git a/ld/config/sun4.mt b/ld/config/sun4.mt deleted file mode 100644 index d68947ec90a..00000000000 --- a/ld/config/sun4.mt +++ /dev/null @@ -1 +0,0 @@ -TDEFINES = -DDEFAULT_EMULATION=GLD_EMULATION_NAME diff --git a/ld/config/tmake-coff-a29k b/ld/config/tmake-coff-a29k deleted file mode 100755 index 5c554154c92..00000000000 --- a/ld/config/tmake-coff-a29k +++ /dev/null @@ -1 +0,0 @@ -TDEFINES = -DDEFAULT_EMULATION=GLD29K_EMULATION_NAME diff --git a/ld/config/tmake-m88k-bcs b/ld/config/tmake-m88k-bcs deleted file mode 100755 index 94e8c66ae5f..00000000000 --- a/ld/config/tmake-m88k-bcs +++ /dev/null @@ -1 +0,0 @@ -TDEFINES = -DDEFAULT_EMULATION=GLDM88KBCS_EMULATION_NAME diff --git a/ld/config/tmake-sun4 b/ld/config/tmake-sun4 deleted file mode 100755 index d68947ec90a..00000000000 --- a/ld/config/tmake-sun4 +++ /dev/null @@ -1 +0,0 @@ -TDEFINES = -DDEFAULT_EMULATION=GLD_EMULATION_NAME diff --git a/ld/configure b/ld/configure deleted file mode 100755 index 8bb4b59b018..00000000000 --- a/ld/configure +++ /dev/null @@ -1,694 +0,0 @@ -#!/bin/sh - -# Configuration script -# Copyright (C) 1988, 1990, 1991 Free Software Foundation, Inc. - -#This file is part of GNU. - -# 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -# $Id$ - -# -# Shell script to create proper links to machine-dependent files in -# preparation for compilation. -# -# If configure succeeds, it leaves its status in config.status. -# If configure fails after disturbing the status quo, -# config.status is removed. -# - -remove=rm -hard_link=ln -symbolic_link='ln -s' - -#for Test -#remove="echo rm" -#hard_link="echo ln" -#symbolic_link="echo ln -s" - -progname=$0 - -# clear some things potentially inherited from environment. -ansi= -arguments=$* -defaulttargets= -destdir= -fatal= -hostsubdir= -Makefile=Makefile -Makefile_in=Makefile.in -norecursion= -recurring= -removing= -srcdir= -srctrigger= -target= -targets= -commontargets= -configdirs= -targetsubdir= -template= -verbose= - -for arg in $*; -do - case ${arg} in - -ansi | +a*) - ansi=true - clib=clib - ;; - -destdir=* | +destdir=* | +destdi=* | +destd=* | +dest=* | +des=* | +de=* | +d=*) - destdir=`echo ${arg} | sed 's/[+-]d[a-z]*=//'` - ;; - -languages=* | +languages=* | +language=* | +languag=* \ - | +langua=* | +langu=* | +lang=* | +lan=* | +la=* \ - | +l=*) - languages="${languages} `echo ${arg} | sed 's/[+-]l[a-z]*=//'`" - ;; - -gas | +g*) - gas=yes - ;; - -help | +h*) - fatal=true - ;; - -nfp | +nf*) - nfp=yes - ;; - -norecursion | +no*) - norecursion=true - ;; - -recurring | +recurring | +recurrin | +recurri | +recurr | +recur | +recu | +rec | +re) - recurring=true - ;; - -rm | +rm) - removing=${arg} - ;; -# -srcdir=* | +srcdir=* | +srcdi=* | +srcd=* | +src=* | +sr=* | +s=*) -# srcdir=`echo ${arg} | sed 's/[+-]s[a-z]*=//'` -# ;; - -subdirs | +f* | +su*) - subdirs=${arg} - ;; - -target=* | +target=* | +targe=* | +targ=* | +tar=* | +ta=*) - if [ -n "${targets}" ] ; then - subdirs="+subdirs" - fi - - newtargets="${targets} `echo ${arg} | sed 's/[+-]t[a-z]*=//'`" - targets="${newtargets}" - ;; - -template=* | +template=* | +templat=* | +templa=* | +templ=* | +temp=* | +tem=* | +te=*) - template=`echo ${arg} | sed 's/[+-]template=//'` - ;; - -v | -verbose | +v*) - verbose=${arg} - ;; - -* | +*) - (echo ; - echo "Unrecognized option: \"${arg}\"". ; - echo) 1>&2 - fatal=true - ;; - *) - if [ -n "${hosts}" ] ; then - subdirs="+subdirs" - fi - - newhosts="${hosts} ${arg}" - hosts=${newhosts} - ;; - esac -done - -if [ -n "${verbose}" ] ; then - echo `pwd`/configure $* -fi - -# process host and target only if not rebuilding configure itself or removing. -if [ -z "${template}" -a -z "${removing}" -a -z "${fatal}" ] ; then - # Complain if an arg is missing - if [ -z "${hosts}" ] ; then - (echo ; - echo "configure: No HOST specified." ; - echo) 1>&2 - fatal=true - fi -fi - -if [ -n "${fatal}" -o "${hosts}" = "help" ] ; then - (echo "Usage: configure HOST" ; - echo ; - echo "Options: [defaults in brackets]" ; - echo " +ansi configure w/ANSI library. [no ansi lib]" ; - echo " +destdir=MYDIR configure for installation into MYDIR. [/usr/local]" ; - echo " +subdirs configure in subdirectories. [in source directories]" ; - echo " +lang=LANG configure to build LANG. [gcc]" ; - echo " +help print this message. [normal config]" ; - echo " +gas configure the compilers for use with gas. [native as]" ; - echo " +nfp configure the compilers default to soft floating point. [hard float]" ; - echo " +norecursion configure this directory only. [recurse]" ; - echo " +rm remove this configuration. [build a configuration]" ; - echo " +target=TARGET configure for TARGET. [TARGET = HOST]" ; - echo " +template=TEM rebuild configure using TEM. [normal config]" ; - echo ; - echo "Where HOST and TARGET are something like \"vax\", \"sun3\", \"encore\", etc." ; - echo "Asking for more than one \"+target\" implies \"+subdirs\". Any other" ; - echo "options given will apply to all targets.") 1>&2 - - if [ -r config.status ] ; then - cat config.status - fi - - exit 1 -fi - -#### configure.in common parts come in here. -# This file is a shell script fragment that supplies the information -# necessary to tailor a template configure script into the configure -# script appropriate for this directory. For more information, check -# any existing configure script. - -srctrigger=ldmain.c -srcname="linker" - -## end of common part. - -# are we rebuilding config itself? -if [ -n "${template}" ] ; then - if [ ! -r ${template} ] ; then - echo '***' "Can't find template ${template}." 1>&2 - exit 1 - fi - -# prep the template - sed -e '/^#### configure.in common parts come in here.$/,/^## end of common part.$/c\ -#### configure.in common parts come in here.\ -## end of common part.' \ - -e '/^#### configure.in per-host parts come in here.$/,/^## end of per-host part.$/c\ -#### configure.in per-host parts come in here.\ -## end of per-host part.' \ - -e '/^#### configure.in per-target parts come in here.$/,/^## end of per-target part.$/c\ -#### configure.in per-target parts come in here.\ -## end of per-target part.' \ - -e '/^#### configure.in post-target parts come in here.$/,/^## end of post-target part.$/c\ -#### configure.in post-target parts come in here.\ -## end of post-target part.' \ - < ${template} > template.new - - if [ -r configure.in ] ; then - if [ -z "`grep '^# per\-host:' configure.in`" ] ; then - echo '***' `pwd`/configure.in has no "per-host:" line. 1>&2 - exit 1 - fi - - if [ -z "`grep '^# per\-target:' configure.in`" ] ; then - echo '***' `pwd`/configure.in has no "per-target:" line. 1>&2 - exit 1 - fi - - # split configure.in into common, per-host, per-target, - # and post-target parts. Post-target is optional. - sed -e '/^# per\-host:/,$d' configure.in > configure.com - sed -e '1,/^# per\-host:/d' -e '/^# per\-target:/,$d' configure.in > configure.hst - if grep -s '^# post-target:' configure.in ; then - sed -e '1,/^# per\-target:/d' -e '/^# post\-target:/,$d' configure.in > configure.tgt - sed -e '1,/^# post\-target:/d' configure.in > configure.pos - else - sed -e '1,/^# per\-target:/d' configure.in > configure.tgt - echo >configure.pos - fi - - # and insert them - sed -e '/^#### configure.in common parts come in here.$/ r configure.com' \ - -e '/^#### configure.in per\-host parts come in here.$/ r configure.hst' \ - -e '/^#### configure.in per\-target parts come in here.$/ r configure.tgt' \ - -e '/^#### configure.in post\-target parts come in here.$/ r configure.pos' \ - template.new > configure.new - - rm -f configure.com configure.tgt configure.hst configure.pos - else - echo Warning: no configure.in in `pwd` - cat ${template} >> configure - fi - - chmod a+x configure.new - rm template.new -# mv configure configure.old - mv configure.new configure - - if [ -n "${verbose}" ] ; then - echo Rebuilt configure in `pwd` - fi - - # Now update config.sub from the template directory. - if echo "$template" | grep -s 'configure$' ; then - cp `echo "$template" | sed s/configure$/config.sub/` ./config.sub.new - # mv config.sub config.sub.old - mv config.sub.new config.sub - - if [ -n "${verbose}" ] ; then - echo Rebuilt config.sub in `pwd` - fi - fi - - if [ -z "${norecursion}" ] ; then - # If template is relative path, make it absolute for recurring. - if echo "${template}" | grep -s '^/' ; then - true - else - template=`pwd`/${template} - fi - - while [ -n "${configdirs}" ] ; do - # set configdir to car of configdirs, configdirs to cdr of configdirs - set ${configdirs}; configdir=$1; shift; configdirs=$* - - if [ "`echo ${configdir}.*`" != "${configdir}.*" ] ; then - targetspecificdirs=${configdir}.* - else - targetspecificdirs= - fi - - for i in ${configdir} ${targetspecificdirs} ; do - if [ -d $i ] ; then - if [ -r $i/configure ] ; then - (cd $i ; - ./configure +template=${template} ${verbose}) - else - echo Warning: No configure script in `pwd`/$i - fi - else - if [ -n "${verbose}" ] ; then - echo Warning: directory $i is missing. - fi - fi - done - done - fi - - exit 0 -fi - -# some sanity checks on configure.in -if [ -z "${srctrigger}" ] ; then - echo Warning: srctrigger not set in configure.in. `pwd` not configured. - exit 1 -fi - -for host in ${hosts} ; do - # Default other arg - if [ -z "${targets}" -o -n "${defaulttargets}" ] ; then - targets=${host} - defaulttargets=true - fi - - host_alias=${host} - - result=`/bin/sh ./config.sub ${host}` - host_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'` - host_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'` - host_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'` - host=${host_cpu}-${host_vendor}-${host_os} - host_makefile_frag=config/hmake-${host} - -#### configure.in per-host parts come in here. - -if [ "${host_os}" = "posix" ] ; then - my_host=posix -else - case "${host_cpu}" in - rs6000) my_host=aix ;; - mips) - case "${host_vendor}" in - dec) my_host=dec3100 ;; - esac - ;; - m88k) - case "${host_vendor}" in - *) - case "${host_os}" in - dgux) my_host=dgux ;; - esac - ;; - esac - ;; - - m68k) - case "${host_vendor}" in - hp) my_host=hp9000 ;; - sony) my_host=news ;; - sun) my_host=sun3 ;; - esac - ;; - - i386) - case "${host_vendor}" in - *) - case "${host_os}" in - sysv) my_host=i386v ;; - esac - ;; - esac - ;; - - sparc) - case "${host_vendor}" in - sun) my_host=sun4 ;; - esac - ;; - - rtpc) my_host=rtbsd ;; - tahoe | vax) my_host=${host_cpu} ;; - esac -fi - -if [ ! -f config/h-${my_host} ] ; then - echo '***' The linker do not support host ${host} - exit 1 -fi - -host_makefile_frag=config/h-${my_host} - -## end of per-host part. - - for target in ${targets} ; do - - target_alias=${target} - result=`/bin/sh ./config.sub ${target}` - target_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'` - target_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'` - target_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'` - target=${target_cpu}-${target_vendor}-${target_os} - target_makefile_frag=config/tmake-${target} - -#### configure.in per-target parts come in here. - -case ${target_cpu} in -sparc) - case ${target_vendor} in - sun) my_target=sun4 ;; - esac - ;; -m88k) my_target=m88k-bcs ;; -a29k) my_target=coff-a29k ;; -m68k) - case ${target_vendor} in - sun) my_target=sun3 ;; - sony) my_target=news;; - *) echo "Unknown 68k target vendor:" ${target_vendor} ;; - esac -esac - -target_makefile_frag=config/t-${my_target} - -files= -links= -## end of per-target part. - - # Temporarily, we support only direct subdir builds. - hostsubdir=H-${host_alias} - targetsubdir=T-${target_alias} - - if [ -n "${removing}" ] ; then - if [ -n "${subdirs}" ] ; then - if [ -d "${hostsubdir}" ] ; then - rm -rf ${hostsubdir}/${targetsubdir} - - if [ -z "`(ls ${hostsubdir}) 2>&1 | grep Target- | grep -v Target-independent`" ] ; then - rm -rf ${hostsubdir} - fi - else - echo Warning: no `pwd`/${hostsubdir} to remove. - fi - else - rm -f ${Makefile} config.status ${links} - fi - else - if [ -n "${subdirs}" ] ; then - # check for existing status before allowing forced subdirs. - if [ -f ${Makefile} ] ; then - echo '***' "${Makefile} already exists in source directory. `pwd` not configured." 1>&2 - exit 1 - fi - - if [ ! -d ${hostsubdir} ] ; then mkdir ${hostsubdir} ; fi - cd ${hostsubdir} - - if [ ! -d ${targetsubdir} ] ; then - if [ -z "${commontargets}" ] ; then - mkdir ${targetsubdir} - else - if [ ! -d Target-independent ] ; then - mkdir Target-independent - fi - - ${symbolic_link} Target-independent ${targetsubdir} - fi # if target independent - fi # if no target dir yet - - cd ${targetsubdir} - - srcdir=../.. - else - # if not subdir builds, then make sure none exist. - if [ -n "`(ls .) 2>&1 | grep Host-`" ] ; then - echo '***' "Configured subdirs exist. `pwd` not configured." 1>&2 - exit 1 - fi - fi - - # Find the source files, if location was not specified. - if [ -z "${srcdir}" ] ; then - srcdirdefaulted=1 - srcdir=. - if [ -n "${srctrigger}" -a ! -r ${srctrigger} ] ; then - srcdir=.. - fi - fi - - if [ -n "${srctrigger}" -a ! -r ${srcdir}/${srctrigger} ] ; then - if [ -z "${srcdirdefaulted}" ] ; then - echo '***' "${progname}: Can't find ${srcname} sources in `pwd`/${srcdir}" 1>&2 - else - echo '***' "${progname}: Can't find ${srcname} sources in `pwd`/. or `pwd`/.." 1>&2 - fi - - echo '***' \(At least ${srctrigger} is missing.\) 1>&2 - exit 1 - fi - - # Set up the list of links to be made. - # ${links} is the list of link names, and ${files} is the list of names to link to. - - # Make the links. - while [ -n "${files}" ] ; do - # set file to car of files, files to cdr of files - set ${files}; file=$1; shift; files=$* - set ${links}; link=$1; shift; links=$* - - if [ ! -r ${srcdir}/${file} ] ; then - echo '***' "${progname}: cannot create a link \"${link}\"," 1>&2 - echo '***' "since the file \"${file}\" does not exist." 1>&2 - exit 1 - fi - - ${remove} -f ${link} - rm -f config.status - # Make a symlink if possible, otherwise try a hard link - ${symbolic_link} ${srcdir}/${file} ${link} 2>/dev/null || ${hard_link} ${srcdir}/${file} ${link} - - if [ ! -r ${link} ] ; then - echo '***' "${progname}: unable to link \"${link}\" to \"${srcdir}/${file}\"." 1>&2 - exit 1 - fi - - if [ -n "${verbose}" ] ; then - echo "Linked \"${link}\" to \"${srcdir}/${file}\"." - fi - done - - # Create a .gdbinit file which runs the one in srcdir - # and tells GDB to look there for source files. - - case ${srcdir} in - .) - ;; - *) - echo "dir ." > .gdbinit - echo "dir ${srcdir}" >> .gdbinit - echo "source ${srcdir}/.gdbinit" >> .gdbinit - ;; - esac - - # Install a makefile, and make it set VPATH - # if necessary so that the sources are found. - # Also change its value of srcdir. - - # FIXME-someday: This business of always writing to .tem and mv back - # is so that I don't screw things up while developing. Once this - # template is stable, these should be optimized. xoxorich. - - # Define macro CROSS_COMPILE in compilation if this is a cross-compiler. - if [ "${host}" != "${target}" ] ; then - echo "CROSS=-DCROSS_COMPILE" > ${Makefile} - echo "ALL=start.encap" >> ${Makefile} - else - echo "ALL=all.internal" > ${Makefile} - fi - - # set target, host, VPATH - echo "host_alias = ${host_alias}" >> ${Makefile} - echo "host_cpu = ${host_cpu}" >> ${Makefile} - echo "host_vendor = ${host_vendor}" >> ${Makefile} - echo "host_os = ${host_os}" >> ${Makefile} - - echo "target_alias = ${target_alias}" >> ${Makefile} - echo "target_cpu = ${target_cpu}" >> ${Makefile} - echo "target_vendor = ${target_vendor}" >> ${Makefile} - echo "target_os = ${target_os}" >> ${Makefile} - - if [ -n "${subdirs}" ] ; then - echo "subdir = /${hostsubdir}/${targetsubdir}" >> ${Makefile} - else - echo "subdir =" >> ${Makefile} - fi - - # echo "workdir = `pwd`" >> ${Makefile} - echo "VPATH = ${srcdir}" >> ${Makefile} - - # add "Makefile.in" (or whatever it's called) - cat ${srcdir}/${Makefile_in} >> ${Makefile} - - # Conditionalize the makefile for this host. - if [ -f ${srcdir}/${host_makefile_frag} ] ; then - (echo "host_makefile_frag = ${srcdir}/${host_makefile_frag}" ; - sed -e "/^####/ r ${srcdir}/${host_makefile_frag}" ${Makefile}) > Makefile.tem - mv Makefile.tem ${Makefile} - fi - - # Conditionalize the makefile for this target. - if [ -f ${srcdir}/${target_makefile_frag} ] ; then - (echo "target_makefile_frag = ${srcdir}/${target_makefile_frag}" ; - sed -e "/^####/ r ${srcdir}/${target_makefile_frag}" ${Makefile}) > Makefile.tem - mv Makefile.tem ${Makefile} - fi - - # set srcdir - sed "s@^srcdir = \.@srcdir = ${srcdir}@" ${Makefile} > Makefile.tem - mv Makefile.tem ${Makefile} - - # set destdir - if [ -n "${destdir}" ] ; then - sed "s:^destdir =.*$:destdir = ${destdir}:" ${Makefile} > Makefile.tem - mv Makefile.tem ${Makefile} - fi - - # reset SUBDIRS - sed "s:^SUBDIRS =.*$:SUBDIRS = ${configdirs}:" ${Makefile} > Makefile.tem - mv Makefile.tem ${Makefile} - - # reset NONSUBDIRS - sed "s:^NONSUBDIRS =.*$:NONSUBDIRS = ${noconfigdirs}:" ${Makefile} > Makefile.tem - mv Makefile.tem ${Makefile} - - using= - if [ -f ${srcdir}/${host_makefile_frag} ] ; then - using=" using \"${host_makefile_frag}\"" - fi - - # remove any form feeds. - sed -e "s/ //" ${Makefile} > Makefile.tem - mv Makefile.tem ${Makefile} - - if [ -f ${srcdir}/${target_makefile_frag} ] ; then - if [ -z "${using}" ] ; then - andusing=" using \"${target_makefile_frag}\"" - else - andusing="${using} and \"${target_makefile_frag}\"" - fi - else - andusing=${using} - fi - - if [ -n "${verbose}" -o -z "${recurring}" ] ; then - echo "Created \"${Makefile}\"" in `pwd`${andusing}. - fi - -#### configure.in post-target parts come in here. - -## end of post-target part. - - # describe the chosen configuration in config.status. - # Make that file a shellscript which will reestablish - # the same configuration. Used in Makefiles to rebuild - # Makefiles. - - echo "#!/bin/sh -# ${srcname} was configured as follows: -${srcdir}/configure" ${arguments} `if [ -z "${norecursion}" ] ; then echo +norecursion ; else true ; fi` > config.status - chmod a+x config.status - - originaldir=`pwd` - cd ${srcdir} - fi - - # If there are subdirectories, then recurse. - if [ -z "${norecursion}" -a -n "${configdirs}" ] ; then - for configdir in ${configdirs} ; do - if [ -n "${verbose}" ] ; then - echo Configuring ${configdir}... - fi - - if [ -d ${configdir} ] ; then - (cd ${configdir} ; - ./configure +recurring ${host_alias} +target=${target_alias} \ - ${verbose} ${subdirs} ${removing} +destdir=${destdir}) \ - | sed 's/^/ /' - else - if [ -n "${verbose}" ] ; then - echo Warning: directory \"${configdir}\" is missing. - fi - fi - done - fi - done # for each target - - # Now build a Makefile for this host. - if [ -n "${subdirs}" -a ! -n "${removing}" ] ; then - cd ${hostsubdir} - cat > GNUmakefile << E!O!F -# Makefile generated by configure for host ${host_alias}. - -ALL := $(shell ls -d Target-*) - -%: - $(foreach subdir,$(ALL),$(MAKE) -C $(subdir) \$@ &&) true - -all: -E!O!F - cd .. - fi -done # for each host - -exit 0 - -# -# Local Variables: -# fill-column: 131 -# End: -# - -# end of configure diff --git a/ld/configure.in b/ld/configure.in deleted file mode 100644 index 689171551b9..00000000000 --- a/ld/configure.in +++ /dev/null @@ -1,138 +0,0 @@ -# This file is a shell script fragment that supplies the information -# necessary to tailor a template configure script into the configure -# script appropriate for this directory. For more information, check -# any existing configure script. - -srctrigger=ldmain.c -srcname="linker" - -# per-host: - -case "${host_cpu}" in - -rs6000) my_host=rs6000 - ;; - -mips) - case "${host_vendor}" in - dec) my_host=decstation ;; - sgi) my_host=irix3 ;; - esac - ;; - -m88k) - case "${host_vendor}" in - *) - case "${host_os}" in - dgux) my_host=dgux ;; - esac - ;; - esac - ;; - -m68k) - case "${host_vendor}" in - cbm) - case ${host_os} in - amigados) my_host=amigados ;; - svr4) my_host=amix ;; - esac - ;; - hp) - case "${host_os}" in - hpux) my_host=hp9000 ;; - bsd) my_host=hp300bsd ;; - esac - ;; - sony) my_host=news ;; - sun) my_host=sun3 ;; - esac - ;; - -i386) - case "${host_vendor}" in - *) - case "${host_os}" in - sysv) my_host=i386v ;; - mach) my_host=i386mach ;; - msdos) my_host=dose ;; - esac - ;; - esac - ;; - -sparc) - case "${host_os}" in - sunos64) my_host=sparc-ll ;; - *) my_host=sparc ;; - esac - ;; - -romp) my_host=rtbsd - ;; - -a29k) my_host=ultra3 - ;; - -tahoe) - my_host=tahoe - ;; - -vax) - case "${host_os}" in - ultrix) my_host=vaxult ;; - *) my_host=vaxbsd ;; - esac - ;; -esac - -# Set up to make a link between the host's include file and "sysdep.h". -files="../bfd/hosts/h-${my_host}.h" -links="sysdep.h" - -if [ ! -f ${files} ] ; then - if [ -n "${my_host}" ] ; then - echo '***' No file ${files} - fi - echo '***' ${srcname} does not support host ${host} - exit 1 -fi -host_makefile_frag= -if [ -f config/mh-${my_host} ] ; then - host_makefile_frag=config/mh-${my_host} -fi - -# per-target: - -case ${target_vendor} in -aout | coff) my_target=${target_cpu}-${target_vendor} ;; -sun) - case ${target_cpu} in - sparc) my_target=sun4 ;; - m68k) my_target=sun3 ;; - esac - ;; -*) - case ${target_cpu} in - m88k) my_target=m88k-bcs ;; - a29k) case ${target_os} in - ebmon) my_target=ebmon29k ;; - *) my_target=coff-a29k ;; - esac - ;; - h8300) my_target=h8300hds ;; - m68k) - case ${target_vendor} in - sony) my_target=news;; - hp) my_target=hp300bsd;; - *) - echo "Unknown m68k target vendor:" ${target_vendor} - exit 1 - ;; - esac - ;; - esac - ;; -esac - -target_makefile_frag=config/mt-${my_target} diff --git a/ld/ebmon29k.sc b/ld/ebmon29k.sc deleted file mode 100755 index 838aef4a7bb..00000000000 --- a/ld/ebmon29k.sc +++ /dev/null @@ -1,38 +0,0 @@ -OUTPUT_FORMAT("coff-a29k-big") - -SEARCH_DIR(/lib) -SEARCH_DIR(/usr/lib) -SEARCH_DIR(/usr/local/lib) -MEMORY { - text : ORIGIN = 0x1000000, LENGTH = 0x1000000 - talias : ORIGIN = 0x2000000, LENGTH = 0x1000000 - data : ORIGIN = 0x3000000, LENGTH = 0x1000000 - mstack : ORIGIN = 0x4000000, LENGTH = 0x1000000 - rstack : ORIGIN = 0x5000000, LENGTH = 0x1000000 -} -SECTIONS -{ - .text : { - *(.text) - __etext = .; - *(.lit) - *(.shdata) - } > text - .shbss SIZEOF(.text) + ADDR(.text) : { - *(.shbss) - } - .talias : { } > talias - .data : { - *(.data) - __edata = .; - } > data - .bss SIZEOF(.data) + ADDR(.data) : - { - *(.bss) - [COMMON] - __end = ALIGN(0x8); - } - .mstack : { } > mstack - .rstack : { } > rstack -} - diff --git a/ld/gld.1 b/ld/gld.1 deleted file mode 100644 index 427221802b3..00000000000 --- a/ld/gld.1 +++ /dev/null @@ -1,1013 +0,0 @@ -.\" Copyright (c) 1991 Free Software Foundation -.\" See section COPYING for conditions for redistribution -.\" $Id$ -.TH gld 1 "5 November 1991" "cygnus support" "GNU Development Tools" -.de BP -.sp -.ti \-.2i -\(** -.. - -.SH NAME -gld \- the GNU linker - -.SH SYNOPSIS -.hy 0 -.na -.TP -.B gld -.RB "[\|" \-o " -.I output\c -\&\|] \c -.I objfiles\c -\&.\|.\|. -.br -.RB "[\|" \-A\c -.I architecture\c -\&\|] -.RB "[\|" "\-b\ "\c -.I input-format\c -\&\|] -.RB "[\|" \-Bstatic "\|]" -.RB "[\|" "\-c\ "\c -.I commandfile\c -\&\|] -.RB "[\|" \-d | \-dc | \-dp\c -\|] -.br -.RB "[\|" "\-defsym\ "\c -.I symbol\c -\& = \c -.I expression\c -\&\|] -.RB "[\|" "\-e\ "\c -.I entry\c -\&\|] -.RB "[\|" \-F "\|]" -.RB "[\|" "\-F\ "\c -.I format\c -\&\|] -.RB "[\|" "\-format\ "\c -.I input-format\c -\&\|] -.RB "[\|" \-g "\|]" -.RB "[\|" \-i "\|]" -.RB "[\|" \-l\c -.I ar\c -\&\|] -.RB "[\|" \-L\c -.I searchdir\c -\&\|] -.RB "[\|" \-M | \-m "\|]" -.RB "[\|" \-n "\|]" -.RB "[\|" \-noinhibit-exec "\|]" -.RB "[\|" "\-R\ "\c -.I filename\c -\&\|] -.RB "[\|" \-r | \-Ur "\|]" -.RB "[\|" \-S "\|]" -.RB "[\|" \-s "\|]" -.RB "[\|" "\-T\ "\c -.I commandfile\c -\&\|] -.RB "[\|" "\-Ttext\ "\c -.I textorg\c -\&\|] -.RB "[\|" "\-Tdata\ "\c -.I dataorg\c -\&\|] -.RB "[\|" "\-Tbss\ "\c -.I bssorg\c -\&\|] -.RB "[\|" \-t "\|]" -.RB "[\|" "\-u\ "\c -.I sym\c -\&] -.RB "[\|" \-v "\|]" -.RB "[\|" \-X "\|]" -.RB "[\|" \-x "\|]" -.RB "[\|" { \c -.I script\c -.BR } "\|]" -.ad b -.hy 1 -.SH DESCRIPTION -\c -.B gld\c -\& combines a number of object and archive files, relocates -their data and ties up symbol references. Often the last step in -building a new compiled program to run is a call to \c -.B gld\c -\&. - -\c -.B gld\c -\& accepts Linker Command Language files -to provide explicit and total control over the linking process. -This man page does not describe the command language; see the `\|\c -.B ld\c -\|' entry in `\|\c -.B info\c -\|', or the manual -.I -gld: the GNU linker -\&, for full details on the command language and on other aspects of -the GNU linker. - -This version of \c -.B gld\c -\& uses the general purpose BFD libraries -to operate on object files. This allows \c -.B gld\c -\& to read, combine, and -write object files in many different formats\(em\&for example, COFF or -\c -.B a.out\c -\&. Different formats may be linked together to produce any -available kind of object file. You can use `\|\c -.B objdump \-i\c -\|' to get a list of formats supported on various architectures; see -.BR objdump ( 1 ). - -Aside from its flexibility, the GNU linker is more helpful than other -linkers in providing diagnostic information. Many linkers abandon -execution immediately upon encountering an error; whenever possible, -\c -.B gld\c -\& continues executing, allowing you to identify other errors -(or, in some cases, to get an output file in spite of the error). - -The GNU linker \c -.B gld\c -\& is meant to cover a broad range of situations, -and to be as compatible as possible with other linkers. As a result, -you have many choices to control its behavior through the command line, -and through environment variables. - -.SH OPTIONS -The plethora of command-line options may seem intimidating, but in -actual practice few of them are used in any particular context. -For instance, a frequent use of \c -.B gld\c -\& is to link standard Unix -object files on a standard, supported Unix system. On such a system, to -link a file \c -.B hello.o\c -\&: -.sp -.br -$\ gld\ \-o\ output\ /lib/crt0.o\ hello.o\ \-lc -.br -.sp -This tells \c -.B gld\c -\& to produce a file called \c -.B output\c -\& as the -result of linking the file \c -.B /lib/crt0.o\c -\& with \c -.B hello.o\c -\& and -the library \c -.B libc.a\c -\& which will come from the standard search -directories. - -The command-line options to \c -.B gld\c -\& may be specified in any order, and -may be repeated at will. For the most part, repeating an option with a -different argument will either have no further effect, or override prior -occurrences (those further to the left on the command line) of an -option. - -The exceptions\(em\&which may meaningfully be used more than once\(em\&are -\c -.B \-A\c -\&, \c -.B \-b\c -\& (or its synonym \c -.B \-format\c -\&), \c -.B \-defsym\c -\&, -\c -.B \-L\c -\&, \c -.B \-l\c -\&, \c -.B \-R\c -\&, and \c -.B \-u\c -\&. - -The list of object files to be linked together, shown as \c -.I objfiles\c -\&, -may follow, precede, or be mixed in with command-line options; save that -an \c -.I objfiles\c -\& argument may not be placed between an option flag and -its argument. - -Usually the linker is invoked with at least one object file, but other -forms of binary input files can also be specified with \c -.B \-l\c -\&, -\c -.B \-R\c -\&, and the script command language. If \c -.I no\c -\& binary input -files at all are specified, the linker does not produce any output, and -issues the message `\|\c -.B No input files\c -\|'. - -Option arguments must either follow the option letter without intervening -whitespace, or be given as separate arguments immediately following the -option that requires them. - -.TP -.IR "objfiles" .\|.\|. -The object files \c -.I objfiles\c -\& to be linked. - -.TP -.BI "-A" "architecture"\c -\& -In the current release of \c -.B gld\c -\&, this option is useful only for the -Intel 960 family of architectures. In that \c -.B gld\c -\& configuration, the -\c -.I architecture\c -\& argument is one of the two-letter names identifying -members of the 960 family; the option specifies the desired output -target, and warns of any incompatible instructions in the input files. -It also modifies the linker's search strategy for archive libraries, to -support the use of libraries specific to each particular -architecture, by including in the search loop names suffixed with the -string identifying the architecture. - -For example, if your \c -.B gld\c -\& command line included `\|\c -.B \-ACA\c -\|' as -well as `\|\c -.B \-ltry\c -\|', the linker would look (in its built-in search -paths, and in any paths you specify with \c -.B \-L\c -\&) for a library with -the names -.sp -.br -try -.br -libtry.a -.br -tryca -.br -libtryca.a -.br -.sp - -The first two possibilities would be considered in any event; the last -two are due to the use of `\|\c -.B \-ACA\c -\|'. - -Future releases of \c -.B gld\c -\& may support similar functionality for -other architecture families. - -You can meaningfully use \c -.B \-A\c -\& more than once on a command line, if -an architecture family allows combination of target architectures; each -use will add another pair of name variants to search for when \c -.B \-l\c -\& -specifies a library. - -.TP -.BI "-b " "input-format"\c -\& -Specify the binary format for input object files that follow this option -on the command line. You don't usually need to specify this, as -\c -.B gld\c -\& is configured to expect as a default input format the most -usual format on each machine. \c -.I input-format\c -\& is a text string, the -name of a particular format supported by the BFD libraries. -\c -.B \-format \c -.I input-format\c -\&\c -\& has the same effect. - -You may want to use this option if you are linking files with an unusual -binary format. You can also use \c -.B \-b\c -\& to switch formats explicitly (when -linking object files of different formats), by including -\c -.B \-b \c -.I input-format\c -\&\c -\& before each group of object files in a -particular format. - -The default format is taken from the environment variable -.B GNUTARGET\c -\&. You can also define the input -format from a script, using the command \c -.B TARGET\c -\&. - -.TP -.B \-Bstatic -This flag is accepted for command-line compatibility with the SunOS linker, -but has no effect on \c -.B gld\c -\&. - -.TP -.BI "-c " "commandfile"\c -\& -Directs \c -.B gld\c -\& to read link commands from the file -\c -.I commandfile\c -\&. These commands will completely override \c -.B gld\c -\&'s -default link format (rather than adding to it); \c -.I commandfile\c -\& must -specify everything necessary to describe the target format. - - -You may also include a script of link commands directly in the command -line by bracketing it between `\|\c -.B {\c -\|' and `\|\c -.B }\c -\|' characters. - -.TP -.B \-d -.TP -.B \-dc -.TP -.B \-dp -These three options are equivalent; multiple forms are supported for -compatibility with other linkers. Use any of them to make \c -.B ld\c -\& -assign space to common symbols even if a relocatable output file is -specified (\c -.B \-r\c -\&). The script command -\c -.B FORCE_COMMON_ALLOCATION\c -\& has the same effect. - -.TP -.BI "-defsym " "symbol"\c -\& = \c -.I expression\c -\& -Create a global symbol in the output file, containing the absolute -address given by \c -.I expression\c -\&. You may use this option as many -times as necessary to define multiple symbols in the command line. A -limited form of arithmetic is supported for the \c -.I expression\c -\& in this -context: you may give a hexadecimal constant or the name of an existing -symbol, or use \c -.B +\c -\& and \c -.B \-\c -\& to add or subtract hexadecimal -constants or symbols. If you need more elaborate expressions, consider -using the linker command language from a script. - -.TP -.BI "-e " "entry"\c -\& -Use \c -.I entry\c -\& as the explicit symbol for beginning execution of your -program, rather than the default entry point. for a -discussion of defaults and other ways of specifying the -entry point. - -.TP -.B \-F -.TP -.BI "-F" "format"\c -\& -Some older linkers used this option throughout a compilation toolchain -for specifying object-file format for both input and output object -files. \c -.B gld\c -\&'s mechanisms (the \c -.B \-b\c -\& or \c -.B \-format\c -\& options -for input files, the \c -.B TARGET\c -\& command in linker scripts for output -files, the \c -.B GNUTARGET\c -\& environment variable) are more flexible, but -but it accepts (and ignores) the \c -.B \-F\c -\& option flag for compatibility -with scripts written to call the old linker. - -.TP -.BI "-format " "input-format"\c -\& -Synonym for \c -.B \-b\c -\& \c -.I input-format\c -\&. - -.TP -.B \-g -Accepted, but ignored; provided for compatibility with other tools. - -.TP -.B \-i -Perform an incremental link (same as option \c -.B \-r\c -\&). - -.TP -.BI "-l" "ar"\c -\& -Add an archive file \c -.I ar\c -\& to the list of files to link. This -option may be used any number of times. \c -.B ld\c -\& will search its -path-list for occurrences of \c -.B lib\c -.I ar\c -\&.a\c -\& for every \c -.I ar\c -\& -specified. - -.TP -.BI "-L" "searchdir"\c -\& -This command adds path \c -.I searchdir\c -\& to the list of paths that -\c -.B gld\c -\& will search for archive libraries. You may use this option -any number of times. - -The default set of paths searched (without being specified with -\c -.B \-L\c -\&) depends on what emulation mode \c -.B gld\c -\& is using, and in -some cases also on how it was configured. The -paths can also be specified in a link script with the \c -.B SEARCH_DIR\c -\& -command. - -.TP -.B \-M -.TP -.B \-m -Print (to the standard output file) a link map\(em\&diagnostic information -about where symbols are mapped by \c -.B ld\c -\&, and information on global -common storage allocation. - -.TP -.B \-n -sets the text segment to be read only, and \c -.B NMAGIC\c -\& is written -if possible. - -.TP -.B \-noinhibit-exec -Normally, the linker will not produce an output file if it encounters -errors during the link process. With this flag, you can specify that -you wish the output file retained even after non-fatal errors. - -.TP -.BI "-o " "output"\c -\& -.I output\c -\& -\c -.I output\c -\& is a name for the program produced by \c -.B ld\c -\&; if this -option is not specified, the name `\|\c -.B a.out\c -\|' is used by default. The -script command \c -.B OUTPUT\c -\& can also specify the output file name. - -.TP -.BI "-R " "filename"\c -\& -.I file\c -\& -Read symbol names and their addresses from \c -.I filename\c -\&, but do not -relocate it or include it in the output. This allows your output file -to refer symbolically to absolute locations of memory defined in other -programs. - -.TP -.B \-r -Generates relocatable output\(em\&i.e., generate an output file that can in -turn serve as input to \c -.B gld\c -\&. This is often called \c -.I partial -linking\c -\&. As a side effect, in environments that support standard Unix -magic numbers, this option also sets the output file's magic number to -\c -.B OMAGIC\c -\&. -If this option is not specified, an absolute file is produced. When -linking C++ programs, this option \c -.I will not\c -\& resolve references to -constructors; \c -.B \-Ur\c -\& is an alternative. - -This option does the same as \c -.B \-i\c -\&. - -.TP -.B \-S -Omits debugger symbol information (but not all symbols) from the output file. - -.TP -.B \-s -Omits all symbol information from the output file. - -.TP -.BI "{ " "script" " }" -You can, if you wish, include a script of linker commands directly in -the command line instead of referring to it via an input file. When the -character `\|\c -.B {\c -\|' occurs on the command line, the linker switches to -interpreting the command language until the end of the list of commands -is reached\(em\&flagged with a closing brace `\|\c -.B }\c -\|'. Other command-line -options will not be recognized while parsing the script. -for a description of the command language. - -.TP -.BI "-Tbss " "org"\c -.TP -.BI "-Tdata " "org"\c -.TP -.BI "-Ttext " "org"\c -Use \c -.I org\c -\& as the starting address for\(em\&respectively\(em\&the -\c -.B bss\c -\&, \c -.B data\c -\&, or the \c -.B text\c -\& segment of the output file. -\c -.I textorg\c -\& must be a hexadecimal integer. - -.TP -.BI "-T " "commandfile"\c -\& -.TP -.BI "-T" "commandfile"\c -Equivalent to \c -.B \-c \c -.I commandfile\c -\&\c -\&; supported for compatibility with -other tools. - -.TP -.B \-t -Prints names of input files as \c -.B ld\c -\& processes them. - -.TP -.BI "-u " "sym"\c -\& -.I sym\c -\& -Forces \c -.I sym\c -\& to be entered in the output file as an undefined symbol. -This may, for example, trigger linking of additional modules from -standard libraries. \c -.B \-u\c -\& may be repeated with different option -arguments to enter additional undefined symbols. - -.TP -.B \-Ur -For anything other than C++ programs, this option is equivalent to -\c -.B \-r\c -\&: it generates relocatable output\(em\&i.e., an output file that can in -turn serve as input to \c -.B gld\c -\&. When linking C++ programs, \c -.B \-Ur\c -\& -\c -.I will\c -\& resolve references to constructors, unlike \c -.B \-r\c -\&. - -.TP -.B \-v -Display the version number for \c -.B gld\c -\&. - -.TP -.B \-X -If \c -.B \-s\c -\& or \c -.B \-S\c -\& is also specified, delete only local symbols -beginning with `\|\c -.B L\c -\|'. - -.TP -.B \-x -If \c -.B \-s\c -\& or \c -.B \-S\c -\& is also specified, delete all local symbols, -not just those beginning with `\|\c -.B L\c -\|'. - -.PP - -.SH ENVIRONMENT -\c -.B gld\c -\& always consults two environment variables: \c -.B GNUTARGET\c -\& -and \c -.B LDEMULATION\c -\&. Depending on the setting of the latter, other -environment variables may be used as well. - -\c -.B GNUTARGET\c -\& determines the input-file object format if you don't -use \c -.B \-b\c -\& (or its synonym \c -.B \-format\c -\&). Its value should be one -of the BFD names for an input format. If there is no -\c -.B GNUTARGET\c -\& in the environment, \c -.B gld\c -\& uses the natural format -of the host. If \c -.B GNUTARGET\c -\& is set to \c -.B default\c -\& then BFD attempts to discover the -input format by examining binary input files; this method often -succeeds, but there are potential ambiguities, since there is no method -of ensuring that the magic number used to flag object-file formats is -unique. However, the configuration procedure for BFD on each system -places the conventional format for that system first in the search-list, -so ambiguities are resolved in favor of convention. - -\c -.B LDEMULATION\c -\& controls some aspects of \c -.B gld\c -\&'s dominant -personality. Although \c -.B gld\c -\& is flexible enough to permit its use -in many contexts regardless of configuration, you can use this variable -to make it act more like one or another older linker by default. - -In particular, the value of \c -.B LDEMULATION\c -\& controls what default -linker script is used (thereby controlling the default input and output -formats; ; what default paths are searched for -archive libraries; and in some cases whether additional linker script -commands are available. - -Here is the current set of emulations available: - -.TP -.B LDEMULATION=gld -Emulate the older GNU linker. When this emulation is selected, the -default library search paths are -.sp -.br -/lib -.br -/usr/lib -.br -/usr/local/lib/lib -.br -.sp - -The default output format is set to \c -.B a.out-generic-big\c -\&, and the -default machine is the system's configured BFD default. - -.TP -.B LDEMULATION=gld68k -A variant of the \c -.B gld\c -\& emulation; only differs in specifically -setting the default BFD machine as \c -.B m68k\c -\&. - -.TP -.B LDEMULATION=gld960 -Emulate the Intel port of the older \c -.B gld\c -\& for the i960 -architectures. The default library search paths are taken from two -other environment variables, \c -.B G960LIB\c -\& and \c -.B G960BASE\c -\&. The -default architecture is \c -.B i960\c -\&. The default output format is set -to \c -.B b.out.big\c -\&, and in fact the default output file name (if -\c -.B \-o\c -\& is not specified) is \c -.B b.out\c -\&, to reflect this variant -format, for this emulation. - -This emulation can behave slightly differently depending on the setting -of the \c -.B gld\c -\& compile-time switch \c -.B GNU960\c -\&. If \c -.B gld\c -\& is -compiled with \c -.B GNU960\c -\& defined, then an additional environment -variable\(em\&\c -.B GNUTARGET\c -\&\(em\&is available; its value, if available, -specifies some other default output format than \c -.B b.out.big\c -\&. - -.TP -.B LDEMULATION=gldm88kbcs -Sets the output format to \c -.B m88kbcs\c -\& and the architecture to -\c -.B m88k\c -\&. Default library search paths are -.sp -.br -/lib -.br -/usr/lib -.br -/usr/local/lib -.br -.sp - -.TP -.B LDEMULATION=lnk960 -Emulate the Intel linker \c -.B lnk960\c -\&. The default output format is -\c -.B coff-Intel-big\c -\&. With this emulation, \c -.B gld\c -\& -supports the additional script commands \c -.B HLL\c -\& and \c -.B SYSLIB\c -\& for -specification of library archives. This is the only emulation with -extensive support for the \c -.B \-A\c -\& (architecture) command-line option. -By default, the architecture \c -.B CORE\c -\& is assumed, but you can choose -additional features from the i960 architecture family by using one of -the following with \c -.B \-A\c -\& (or by using the \c -.B OUTPUT_ARCH\c -\& command -from a script): -.sp -.br -CORE -.br -KB -.br -SB -.br -MC -.br -XA -.br -CA -.br -KA -.br -SA -.br -.sp - -The default libraries are chosen with some attention to the architecture -selected; the core library `\|\c -.B cg\c -\|' is always included, but the library -\c -.B fpg\c -\& is also used if you've specified any of the architectures -\c -.B KA\c -\&, \c -.B SA\c -\&, or \c -.B CA\c -\&. - -Like \c -.B gld960\c -\&, this emulation uses additional environment variables -to set the default library search paths. Also like \c -.B gld960\c -\&, the -behavior of this emulation is slightly different depending on whether -\c -.B gld\c -\& itself was compiled with \c -.B GNU960\c -\& defined. - -If your \c -.B gld\c -\& was compiled with \c -.B GNU960\c -\& defined, the default -paths are taken from all three of \c -.B G960LIB\c -\&, \c -.B G960BASE\c -\&, and -\c -.B I960BASE\c -\&. For the first two, paths you supply are automatically -suffixed with `\|\c -.B /lib/libcoff\c -\|'; for the last, your path is -automatically suffixed with `\|\c -.B /lib\c -\|'. - -If your \c -.B gld\c -\& was \c -.I not\c -\& compiled with \c -.B GNU960\c -\& defined, -the default paths are taken from \c -.B I960BASE\c -\&, and \c -.B G960BASE\c -\& is -only consulted if \c -.B I960BASE\c -\& is undefined. In this case -\c -.B G960LIB\c -\& is not used at all. - -.TP -.B LDEMULATION=vanilla -This is the least specific setting for \c -.B gld\c -\&. You can set -\c -.B LDEMULATION=vanilla\c -\& to disable emulation of other linkers. This -setting makes \c -.B gld\c -\& take the default machine from the BFD -configuration on your system; \c -.B a.out-generic-big\c -\& is the default -target. No other defaults are specified. - -.PP - -.SH "SEE ALSO" - -.BR objdump ( 1 ) -.br -.br -.RB "`\|" ld "\|' and `\|" binutils "\|'" -entries in -.B info\c -.br -.I -gld: the GNU linker\c -, Steve Chamberlain and Roland Pesch; -.I -The GNU Binary Utilities\c -, Roland H. Pesch. - -.SH COPYING -Copyright (c) 1991 Free Software Foundation, Inc. -.PP -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. -.PP -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided that the -entire resulting derived work is distributed under the terms of a -permission notice identical to this one. -.PP -Permission is granted to copy and distribute translations of this -manual into another language, under the above conditions for modified -versions, except that this permission notice may be included in -translations approved by the Free Software Foundation instead of in -the original English. diff --git a/ld/h8300hds.c b/ld/h8300hds.c deleted file mode 100755 index 36ca6efce6d..00000000000 --- a/ld/h8300hds.c +++ /dev/null @@ -1,135 +0,0 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. - -This file is part of GLD, the Gnu Linker. - -GLD 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 1, or (at your option) -any later version. - -GLD 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 GLD; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - Written by Steve Chamberlain steve@cygnus.com - - The controller which tells the gnu linker how to behave like one for - the Hitach H8/300 with IEEE records. -*/ - -#include "bfd.h" -#include "sysdep.h" - -#include "ld.h" -#include "config.h" -#include "ldemul.h" -#include "ldfile.h" -#include "ldmisc.h" - -extern boolean lang_float_flag; - - -extern enum bfd_architecture ldfile_output_architecture; -extern unsigned long ldfile_output_machine; -extern char *ldfile_output_machine_name; - -extern bfd *output_bfd; - - - -static void h8300hds_before_parse() -{ - ldfile_output_architecture = bfd_arch_h8300; -} - - -static void -h8300hds_after_parse() -{ - -} - -static void -h8300hds_after_allocation() -{ - -} - -static void -h8300hds_before_allocation() -{ - -} - - -static void -h8300hds_set_output_arch() -{ - /* Set the output architecture and machine if possible */ - bfd_set_arch_mach(output_bfd, - ldfile_output_architecture, ldfile_output_machine); -} - -static char * -h8300hds_choose_target() -{ - char *from_outside = getenv(TARGET_ENVIRON); - if (from_outside != (char *)NULL) - return from_outside; - return H8300HDS_TARGET; -} - -static void -h8300hds_syslib() -{ - info("%S SYSLIB ignored\n"); -} - -static void -h8300hds_hll(ignore) -char *ignore; -{ - info("%S HLL ignored\n"); -} - -static char *h8300hds_script = -#include "h8300hds.x" -; -static char *h8300hds_script_option_Ur = -#include "h8300hds.x" -; -static char *h8300hds_script_option_r = -#include "h8300hds.x" -; - -static char *h8300hds_get_script() -{ - extern ld_config_type config; - if (config.relocateable_output == true && - config.build_constructors == true) { - return h8300hds_script_option_Ur; - } - if (config.relocateable_output) { - return h8300hds_script_option_r; - } - - return h8300hds_script; -} -struct ld_emulation_xfer_struct ld_h8300hds_emulation = -{ - h8300hds_before_parse, - h8300hds_syslib, - h8300hds_hll, - h8300hds_after_parse, - h8300hds_after_allocation, - h8300hds_set_output_arch, - h8300hds_choose_target, - h8300hds_before_allocation, - h8300hds_get_script, -}; diff --git a/ld/h8300hds.sc b/ld/h8300hds.sc deleted file mode 100755 index 9a395dd885b..00000000000 --- a/ld/h8300hds.sc +++ /dev/null @@ -1,19 +0,0 @@ -OUTPUT_FORMAT("ieee") -OUTPUT_ARCH(h8300) - -SECTIONS -{ - .code 40: - { - - *(.code) - *(.strings) - } - .bss . : - { - *(.bss) - [COMMON] - _end = .; - } -} - diff --git a/ld/i386aout.c b/ld/i386aout.c deleted file mode 100755 index 7bd06c552b2..00000000000 --- a/ld/i386aout.c +++ /dev/null @@ -1,159 +0,0 @@ -/* NOTE: If there are angle brackets here: I386AOUT then this is a - * template file (ldtemplate), intended for processing by sed. - * Otherwise, this file has already been processed by sed, - * and customized for a particular emulation target. - * In that DO NOT EDIT the file; edit ldtemplate instead. - */ - -/* emulate the original gld for the given I386AOUT - Copyright (C) 1991 Free Software Foundation, Inc. - Written by Steve Chamberlain steve@cygnus.com - -This file is part of GLD, the Gnu Linker. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - * $Id:# - */ - -#define TARGET_IS_I386AOUT - - -#include "bfd.h" -#include "sysdep.h" -#include "ld.h" -#include "config.h" -#include "ldemul.h" -#include "ldfile.h" -#include "ldmisc.h" - -extern boolean lang_float_flag; - - -extern enum bfd_architecture ldfile_output_architecture; -extern unsigned long ldfile_output_machine; -extern char *ldfile_output_machine_name; - -extern bfd *output_bfd; - - - -static void gldi386aout_before_parse() -{ -#ifdef TARGET_IS_M88KBCS - extern char lprefix; - lprefix = '@'; -#else -#ifndef TARGET_ /* I.e., if not generic */ - ldfile_output_architecture = bfd_arch_i386; -#endif -#endif -} - - -static void -gldi386aout_after_parse() -{ - -} - -static void -gldi386aout_after_allocation() -{ - -} - -static void -gldi386aout_before_allocation() -{ - -} - - -static void -gldi386aout_set_output_arch() -{ - /* Set the output architecture and machine if possible */ - bfd_set_arch_mach(output_bfd, - ldfile_output_architecture, ldfile_output_machine); -} - -static char * -gldi386aout_choose_target() -{ - char *from_outside = getenv(TARGET_ENVIRON); - if (from_outside != (char *)NULL) - return from_outside; - return GLDI386AOUT_TARGET; -} - -static void -gldi386aout_syslib() -{ - info("%S SYSLIB ignored\n"); -} - -static void -gldi386aout_hll(ignore) -char *ignore; -{ - info("%S HLL ignored\n"); -} - -static char *gldi386aout_script = -#include "i386aout.x" -; -static char *gldi386aout_script_option_Ur = -#include "i386aout.xu" -; -static char *gldi386aout_script_option_r = -#include "i386aout.xr" -; -static char *gldi386aout_script_option_n = /* Used with -n flag. */ -#include "i386aout.xn" -; -static char *gldi386aout_script_option_N = /* Used with -N flag. */ -#include "i386aout.xN" -; - -static char *gldi386aout_get_script() -{ - extern ld_config_type config; - if (config.relocateable_output == true && - config.build_constructors == true) { - return gldi386aout_script_option_Ur; - } - if (config.relocateable_output == true) { - return gldi386aout_script_option_r; - } - if (!config.text_read_only) - return gldi386aout_script_option_N; - if (!config.magic_demand_paged) - return gldi386aout_script_option_n; - return gldi386aout_script; -} -struct ld_emulation_xfer_struct ld_gldi386aout_emulation = -{ - gldi386aout_before_parse, - gldi386aout_syslib, - gldi386aout_hll, - gldi386aout_after_parse, - gldi386aout_after_allocation, - gldi386aout_set_output_arch, - gldi386aout_choose_target, - gldi386aout_before_allocation, - gldi386aout_get_script, -}; diff --git a/ld/i386aout.sc b/ld/i386aout.sc deleted file mode 100755 index 82133cc85f8..00000000000 --- a/ld/i386aout.sc +++ /dev/null @@ -1,25 +0,0 @@ -OUTPUT_FORMAT("a.out-i386") -OUTPUT_ARCH(i386) - -__DYNAMIC = 0; -SECTIONS -{ - .text 0 BLOCK(0x1000) : - { - CREATE_OBJECT_SYMBOLS - *(.text) - _etext = ALIGN(0x1000); - } - .data ALIGN(0x1000) : - { - *(.data) - CONSTRUCTORS - _edata = .; - } - .bss SIZEOF(.data) + ADDR(.data) : - { - *(.bss) - [COMMON] - _end = .; - } -} diff --git a/ld/ld-emul.c b/ld/ld-emul.c deleted file mode 100755 index ce99ce7d327..00000000000 --- a/ld/ld-emul.c +++ /dev/null @@ -1,135 +0,0 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. - -This file is part of GLD, the Gnu Linker. - -GLD 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 1, or (at your option) -any later version. - -GLD 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 GLD; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - * $Id$ - */ - -/* - * clearing house for ld emulation states - */ - -#include "sysdep.h" -#include "bfd.h" - -#include "config.h" -#include "ld.h" -#include "ld-emul.h" -#include "ldmisc.h" - -extern ld_emulation_xfer_type ld_lnk960_emulation; -extern ld_emulation_xfer_type ld_gldm88kbcs_emulation; -extern ld_emulation_xfer_type ld_gld_emulation; -extern ld_emulation_xfer_type ld_vanilla_emulation; -extern ld_emulation_xfer_type ld_gld68k_emulation; -extern ld_emulation_xfer_type ld_gld960_emulation; - - - -ld_emulation_xfer_type *ld_emulation; - -void -ldemul_hll(name) -char *name; -{ - ld_emulation->hll(name); -} - - -void ldemul_syslib(name) -char *name; -{ - ld_emulation->syslib(name); -} - -void -ldemul_after_parse() -{ - ld_emulation->after_parse(); -} - -void -ldemul_before_parse() -{ - ld_emulation->before_parse(); -} - -void -ldemul_after_allocation() -{ - ld_emulation->after_allocation(); -} - -void -ldemul_before_allocation() -{ - if (ld_emulation->before_allocation) { - ld_emulation->before_allocation(); - } -} - - -void -ldemul_set_output_arch() -{ - ld_emulation->set_output_arch(); -} - -char * -ldemul_choose_target() -{ - return ld_emulation->choose_target(); -} - -char * -ldemul_get_script() -{ - return ld_emulation->get_script(); -} - -void -ldemul_choose_mode(target) -char *target; -{ - if (strcmp(target,LNK960_EMULATION_NAME)==0) { - ld_emulation = &ld_lnk960_emulation; - } - else if (strcmp(target,GLD960_EMULATION_NAME)==0) { - ld_emulation = &ld_gld960_emulation; - } -else if (strcmp(target,GLDM88KBCS_EMULATION_NAME)==0) { - ld_emulation = &ld_gldm88kbcs_emulation; -} -#ifndef GNU960 - else if (strcmp(target,GLD_EMULATION_NAME)==0) { - ld_emulation = &ld_gld_emulation; - } - else if (strcmp(target,VANILLA_EMULATION_NAME)==0) { - ld_emulation = &ld_vanilla_emulation; - } - else if (strcmp(target,GLD68K_EMULATION_NAME)==0) { - ld_emulation = &ld_gld68k_emulation; - } -#endif - else { - info("%P%F unrecognised emulation mode: %s\n",target); - } -} - - - diff --git a/ld/ld-gld-Ur.script b/ld/ld-gld-Ur.script deleted file mode 100755 index 3871454f8d3..00000000000 --- a/ld/ld-gld-Ur.script +++ /dev/null @@ -1,31 +0,0 @@ - -SEARCH_DIR(/lib) -SEARCH_DIR(/usr/lib) -SEARCH_DIR(/usr/local/lib) -SECTIONS -{ - .text 0: - { - CREATE_OBJECT_SYMBOLS - *(.text) - } - .data SIZEOF(.text) + ADDR(.text) : - { - *(.data) - ___DTOR_LIST__ = . ; - LONG((___CTOR_LIST__ - .) / 4 -2) - *(___DTOR_LIST__) - LONG(0) - ___CTOR_LIST__ = . ; - LONG((___end_list__ - .) / 4 -2) - *(___CTOR_LIST__) - LONG(0) - ___end_list__ = . ; - } - .bss SIZEOF(.data) + ADDR(.data) : - { - *(.bss) - [COMMON] - } -} - diff --git a/ld/ld-gld-r.script b/ld/ld-gld-r.script deleted file mode 100755 index a3b39fe8573..00000000000 --- a/ld/ld-gld-r.script +++ /dev/null @@ -1,20 +0,0 @@ -SEARCH_DIR(/lib) -SEARCH_DIR(/usr/lib) -SEARCH_DIR(/usr/local/lib) -SECTIONS -{ - .text 0: - { - CREATE_OBJECT_SYMBOLS - *(.text) - } - .data SIZEOF(.text) + ADDR(.text) : - { - *(.data) - } - .bss SIZEOF(.data) + ADDR(.data) : - { - *(.bss) - [COMMON] - } -} diff --git a/ld/ld-gld.c b/ld/ld-gld.c deleted file mode 100755 index 018d8d10db5..00000000000 --- a/ld/ld-gld.c +++ /dev/null @@ -1,145 +0,0 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. - -This file is part of GLD, the Gnu Linker. - -GLD 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 1, or (at your option) -any later version. - -GLD 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 GLD; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - * $Id$ - * -*/ - -/* - * emulate the original gld - * - * Written by Steve Chamberlain steve@cygnus.com - */ - - -#include "sysdep.h" -#include "bfd.h" - - -#include "ld.h" -#include "config.h" -#include "ld-emul.h" -#include "ldfile.h" -#include "ldmisc.h" - -extern boolean lang_float_flag; - - -extern enum bfd_architecture ldfile_output_architecture; -extern unsigned long ldfile_output_machine; -extern char *ldfile_output_machine_name; - -extern bfd *output_bfd; - - - -static void gld_before_parse() -{ - ldfile_add_library_path("/lib"); - ldfile_add_library_path("/usr/lib"); - ldfile_add_library_path("/usr/local/lib/lib"); -} - - -static void -gld_after_parse() -{ - -} - -static void -gld_after_allocation() -{ - -} - -static void -gld_before_allocation() -{ - -} - - -static void -gld_set_output_arch() -{ - /* Set the output architecture and machine if possible */ - bfd_set_arch_mach(output_bfd, ldfile_output_architecture, ldfile_output_machine); -} - -static char * -gld_choose_target() -{ - char *from_outside = getenv(TARGET_ENVIRON); - if (from_outside != (char *)NULL) - return from_outside; - return GLD_TARGET; -} - -static void -gld_syslib() -{ - info("%S SYSLIB ignored\n"); -} - -static void -gld_hll(ignore) -char *ignore; -{ - info("%S HLL ignored\n"); -} - -static char *gld_script = -#include "ld-gld.x" -; - -static char *gld_script_option_Ur = -#include "ld-gld-Ur.x" -; - -static char *gld_script_option_r = -#include "ld-gld-r.x" -; - -static char *gld_get_script() -{ - extern ld_config_type config; - if (config.relocateable_output == true && - config.build_constructors == true) { - return gld_script_option_Ur; - } - if (config.relocateable_output) { - return gld_script_option_r; - } - - return gld_script; -} -struct ld_emulation_xfer_struct ld_gld_emulation = -{ - gld_before_parse, - gld_syslib, - gld_hll, - gld_after_parse, - gld_after_allocation, - gld_set_output_arch, - gld_choose_target, - gld_before_allocation, - gld_get_script, -}; - diff --git a/ld/ld-gld.script b/ld/ld-gld.script deleted file mode 100755 index 2f402c1324f..00000000000 --- a/ld/ld-gld.script +++ /dev/null @@ -1,28 +0,0 @@ -OUTPUT_ARCH(sparc) -OUTPUT_FORMAT("a.out-sunos-big") -SEARCH_DIR(/lib) -SEARCH_DIR(/usr/lib) -SEARCH_DIR(/usr/local/lib) -__DYNAMIC = 0; -SECTIONS -{ - .text 0x2020 BLOCK(0x2000): - { - CREATE_OBJECT_SYMBOLS - *(.text) - _etext = ALIGN( 0x2000); - } - .data ALIGN(0x2000) : - { - *(.data) - _edata = .; - } - .bss SIZEOF(.data) + ADDR(.data) : - { - *(.bss) - [COMMON] - _end = .; - } -} - - diff --git a/ld/ld-gld68k-Ur.script b/ld/ld-gld68k-Ur.script deleted file mode 100755 index aa89c6a355d..00000000000 --- a/ld/ld-gld68k-Ur.script +++ /dev/null @@ -1,21 +0,0 @@ -SEARCH_DIR(/lib) -SEARCH_DIR(/usr/lib) -SEARCH_DIR(/usr/local/lib) -SECTIONS -{ - .text 0: - { - CREATE_OBJECT_SYMBOLS - *(.text) - } - .data SIZEOF(.text) + ADDR(.text) : - { - *(.data) - } - .bss SIZEOF(.data) + ADDR(.data) : - { - *(.bss) - [COMMON] - } -} - diff --git a/ld/ld-gld68k-r.script b/ld/ld-gld68k-r.script deleted file mode 100755 index 8cbc9dc8e06..00000000000 --- a/ld/ld-gld68k-r.script +++ /dev/null @@ -1,22 +0,0 @@ - -SEARCH_DIR(/lib) -SEARCH_DIR(/usr/lib) -SEARCH_DIR(/usr/local/lib) -SECTIONS -{ - .text 0: - { - CREATE_OBJECT_SYMBOLS - *(.text) - } - .data SIZEOF(.text) + ADDR(.text) : - { - *(.data) - } - .bss SIZEOF(.data) + ADDR(.data) : - { - *(.bss) - [COMMON] - } -} - diff --git a/ld/ld-gld68k.c b/ld/ld-gld68k.c deleted file mode 100755 index 5d996e3236b..00000000000 --- a/ld/ld-gld68k.c +++ /dev/null @@ -1,143 +0,0 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. - -This file is part of GLD, the Gnu Linker. - -GLD 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 1, or (at your option) -any later version. - -GLD 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 GLD; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - * $Id:# -*/ - -/* - * emulate the original gld running on a 68k system - * - * Written by Steve Chamberlain steve@cygnus.com - */ - - -#include "sysdep.h" -#include "bfd.h" - -#include "ld.h" -#include "config.h" -#include "ld-emul.h" -#include "ldfile.h" -#include "ldmisc.h" - -extern boolean lang_float_flag; - - -extern enum bfd_architecture ldfile_output_architecture; -extern unsigned long ldfile_output_machine; -extern char *ldfile_output_machine_name; - -extern bfd *output_bfd; - - - -static void gld68k_before_parse() -{ - ldfile_add_library_path("/lib"); - ldfile_add_library_path("/usr/lib"); - ldfile_add_library_path("/usr/local/lib/lib"); - ldfile_output_architecture = bfd_arch_m68k; -} - - -static void -gld68k_after_parse() -{ - -} - -static void -gld68k_after_allocation() -{ - -} - -static void -gld68k_before_allocation() -{ - -} - - -static void -gld68k_set_output_arch() -{ - /* Set the output architecture and machine if possible */ - unsigned long machine = 0; - bfd_set_arch_mach(output_bfd, ldfile_output_architecture, machine); -} - -static char * -gld68k_choose_target() -{ - char *from_outside = getenv(TARGET_ENVIRON); - if (from_outside != (char *)NULL) - return from_outside; - return GLD68K_TARGET; -} - -static void -gld68k_syslib() -{ - info("%S SYSLIB ignored\n"); -} - -static void -gld68k_hll(ignore) -char *ignore; -{ - info("%S HLL ignored\n"); -} - -static char *gld68k_script = -#include "ld-gld68k.x" -; - -static char *gld68k_script_option_Ur = -#include "ld-gld68k-Ur.x" -; -static char *gld68k_script_option_r = -#include "ld-gld68k-r.x" -; -static char *gld68k_get_script() -{ - extern ld_config_type config; - if (config.relocateable_output == true && - config.build_constructors == true) { - return gld68k_script_option_Ur; - } - if (config.relocateable_output) { - return gld68k_script_option_r; - } - - return gld68k_script; -} -struct ld_emulation_xfer_struct ld_gld68k_emulation = -{ - gld68k_before_parse, - gld68k_syslib, - gld68k_hll, - gld68k_after_parse, - gld68k_after_allocation, - gld68k_set_output_arch, - gld68k_choose_target, - gld68k_before_allocation, - gld68k_get_script, -}; - diff --git a/ld/ld-gld68k.script b/ld/ld-gld68k.script deleted file mode 100755 index be91d916a97..00000000000 --- a/ld/ld-gld68k.script +++ /dev/null @@ -1,28 +0,0 @@ -OUTPUT_FORMAT("a.out-sunos-big") -OUTPUT_ARCH(m68k) - -SEARCH_DIR(/lib) -SEARCH_DIR(/usr/lib) -SEARCH_DIR(/usr/local/lib) -__DYNAMIC = 0; -SECTIONS -{ - .text 0x2020 BLOCK(0x2000): - { - CREATE_OBJECT_SYMBOLS - *(.text) - _etext = ALIGN( 0x2000); - } - .data ALIGN(0x20000) : - { - *(.data) - _edata = .; - } - .bss SIZEOF(.data) + ADDR(.data) : - { - *(.bss) - [COMMON] - _end = .; - } -} - diff --git a/ld/ld-gld960.c b/ld/ld-gld960.c deleted file mode 100755 index 5aed97e45e9..00000000000 --- a/ld/ld-gld960.c +++ /dev/null @@ -1,171 +0,0 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. - -This file is part of GLD, the Gnu Linker. - -GLD 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 1, or (at your option) -any later version. - -GLD 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 GLD; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - $Id$ -*/ - -/* - * emulate the Intels port of gld - */ - - -#include "sysdep.h" -#include "bfd.h" - - -#include "ld.h" -#include "config.h" -#include "ld-emul.h" -#include "ldfile.h" -#include "ldmisc.h" - - -/* IMPORTS */ -extern char *output_filename; -extern boolean lang_float_flag; - - -extern enum bfd_architecture ldfile_output_architecture; -extern unsigned long ldfile_output_machine; -extern char *ldfile_output_machine_name; - -extern bfd *output_bfd; - - - -#ifdef GNU960 - -static void -gld960_before_parse() -{ - static char *env_variables[] = { "G960LIB", "G960BASE", 0 }; - char **p; - char *env ; - - for ( p = env_variables; *p; p++ ){ - env = (char *) getenv(*p); - if (env) { - ldfile_add_library_path(concat(env,"/lib/libbout","")); - } - } - ldfile_output_architecture = bfd_arch_i960; -} - -#else /* not GNU960 */ - -static void gld960_before_parse() -{ - char *env ; - env = getenv("G960LIB"); - if (env) { - ldfile_add_library_path(env); - } - env = getenv("G960BASE"); - if (env) { - ldfile_add_library_path(concat(env,"/lib","")); - } - ldfile_output_architecture = bfd_arch_i960; -} - -#endif /* GNU960 */ - - -static void -gld960_after_parse() -{ - -} - -static void -gld960_after_allocation() -{ - -} - -static void -gld960_before_allocation() -{ - -} - - -static void -gld960_set_output_arch() -{ - /* Set the output architecture and machine if possible */ - unsigned long machine = 0; - bfd_set_arch_mach(output_bfd, ldfile_output_architecture, machine); -} - -static char * -gld960_choose_target() -{ -#ifdef GNU960 - - output_filename = "b.out"; - return bfd_make_targ_name(BFD_BOUT_FORMAT,HOST_BYTE_ORDER_BIG_P); - -#else - - char *from_outside = getenv(TARGET_ENVIRON); - output_filename = "b.out"; - - if (from_outside != (char *)NULL) - return from_outside; - return GLD960_TARGET; - -#endif -} - -static void -gld960_syslib() -{ - info("%S SYSLIB ignored\n"); -} - -static void -gld960_hll() -{ - info("%S HLL ignored\n"); -} - - -static char *script = -#include "ld-gld960.x" -; - - -static char * -gld960_get_script() -{ -return script; -} - -struct ld_emulation_xfer_struct ld_gld960_emulation = -{ - gld960_before_parse, - gld960_syslib, - gld960_hll, - gld960_after_parse, - gld960_after_allocation, - gld960_set_output_arch, - gld960_choose_target, - gld960_before_allocation, - gld960_get_script, -}; diff --git a/ld/ld-gld960.script b/ld/ld-gld960.script deleted file mode 100755 index 1c40a732e77..00000000000 --- a/ld/ld-gld960.script +++ /dev/null @@ -1,23 +0,0 @@ -SECTIONS -{ - .text : - { - CREATE_OBJECT_SYMBOLS - *(.text) - _etext = .; - } - - .data SIZEOF(.text) + ADDR(.text): - { - - *(.data) - _edata = .; - } - .bss SIZEOF(.data) + ADDR(.data) : - { - _bss_start = .; - *(.bss) - [COMMON] - _end = . ; - } -} diff --git a/ld/ld-gldm88kbcs-Ur.script b/ld/ld-gldm88kbcs-Ur.script deleted file mode 100755 index 8d3f12b89ed..00000000000 --- a/ld/ld-gldm88kbcs-Ur.script +++ /dev/null @@ -1,31 +0,0 @@ -SCRIPT -SEARCH_DIR(/lib) -SEARCH_DIR(/usr/lib) -SEARCH_DIR(/usr/local/lib) -SECTIONS -{ - .text 0: - { - CREATE_OBJECT_SYMBOLS - *(.text) - } - .data SIZEOF(.text) + ADDR(.text) : - { - *(.data) - ___DTOR_LIST__ = . ; - LONG((___CTOR_LIST__ - .) / 4 -2) - *(___DTOR_LIST__) - LONG(0) - ___CTOR_LIST__ = . ; - LONG((___end_list__ - .) / 4 -2) - *(___CTOR_LIST__) - LONG(0) - ___end_list__ = . ; - } - .bss SIZEOF(.data) + ADDR(.data) : - { - *(.bss) - [COMMON] - } -} -ENDSCRIPT diff --git a/ld/ld-gldm88kbcs-r.script b/ld/ld-gldm88kbcs-r.script deleted file mode 100755 index a3b39fe8573..00000000000 --- a/ld/ld-gldm88kbcs-r.script +++ /dev/null @@ -1,20 +0,0 @@ -SEARCH_DIR(/lib) -SEARCH_DIR(/usr/lib) -SEARCH_DIR(/usr/local/lib) -SECTIONS -{ - .text 0: - { - CREATE_OBJECT_SYMBOLS - *(.text) - } - .data SIZEOF(.text) + ADDR(.text) : - { - *(.data) - } - .bss SIZEOF(.data) + ADDR(.data) : - { - *(.bss) - [COMMON] - } -} diff --git a/ld/ld-gldm88kbcs.c b/ld/ld-gldm88kbcs.c deleted file mode 100755 index bfb539f2858..00000000000 --- a/ld/ld-gldm88kbcs.c +++ /dev/null @@ -1,141 +0,0 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. - -This file is part of GLD, the Gnu Linker. - -GLD 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 1, or (at your option) -any later version. - -GLD 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 GLD; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - * $Id$ - * -*/ - -/* - * Written by Steve Chamberlain steve@cygnus.com - */ - - -#include "sysdep.h" -#include "bfd.h" - - -#include "ld.h" -#include "config.h" -#include "ld-emul.h" -#include "ldfile.h" -#include "ldmisc.h" - -extern boolean lang_float_flag; - - -extern enum bfd_architecture ldfile_output_architecture; -extern unsigned long ldfile_output_machine; -extern char *ldfile_output_machine_name; - -extern bfd *output_bfd; - - - -static void gldm88kbcs_before_parse() -{ - -} - - -static void -gldm88kbcs_after_parse() -{ - -} - -static void -gldm88kbcs_after_allocation() -{ - -} - -static void -gldm88kbcs_before_allocation() -{ - -} - - -static void -gldm88kbcs_set_output_arch() -{ - /* Set the output architecture and machine if possible */ - bfd_set_arch_mach(output_bfd, ldfile_output_architecture, ldfile_output_machine); -} - -static char * -gldm88kbcs_choose_target() -{ - char *from_outside = getenv(TARGET_ENVIRON); - if (from_outside != (char *)NULL) - return from_outside; - return GLDM88KBCS_TARGET; -} - -static void -gldm88kbcs_syslib() -{ - info("%S SYSLIB ignored\n"); -} - -static void -gldm88kbcs_hll(ignore) -char *ignore; -{ - info("%S HLL ignored\n"); -} - -static char *gldm88kbcs_script = -#include "ld-gldm88kbcs.x" -; - -static char *gldm88kbcs_script_option_Ur = -#include "ld-gldm88kbcs-Ur.x" -; - -static char *gldm88kbcs_script_option_r = -#include "ld-gldm88kbcs-r.x" -; - -static char *gldm88kbcs_get_script() -{ - extern ld_config_type config; - if (config.relocateable_output == true && - config.build_constructors == true) { - return gldm88kbcs_script_option_Ur; - } - if (config.relocateable_output) { - return gldm88kbcs_script_option_r; - } - - return gldm88kbcs_script; -} -struct ld_emulation_xfer_struct ld_gldm88kbcs_emulation = -{ - gldm88kbcs_before_parse, - gldm88kbcs_syslib, - gldm88kbcs_hll, - gldm88kbcs_after_parse, - gldm88kbcs_after_allocation, - gldm88kbcs_set_output_arch, - gldm88kbcs_choose_target, - gldm88kbcs_before_allocation, - gldm88kbcs_get_script, -}; - diff --git a/ld/ld-gldm88kbcs.script b/ld/ld-gldm88kbcs.script deleted file mode 100755 index ae7cb85009e..00000000000 --- a/ld/ld-gldm88kbcs.script +++ /dev/null @@ -1,36 +0,0 @@ -OUTPUT_FORMAT(m88kbcs) -OUTPUT_ARCH(m88k) -SEARCH_DIR(/lib) -SEARCH_DIR(/usr/lib) -SEARCH_DIR(/usr/local/lib) -__DYNAMIC = 0; -SECTIONS -{ - .text 0x2020 BLOCK(0x2000): - { - CREATE_OBJECT_SYMBOLS - *(.text) - _etext = ALIGN( 0x2000); - } - .data ALIGN(0x2000) : - { - *(.data) - ___DTOR_LIST__ = . ; - LONG((___CTOR_LIST__ - .) / 4 -2) - *(___DTOR_LIST__) - LONG(0) - ___CTOR_LIST__ = . ; - LONG((_edata - .) / 4 -2) - *(___CTOR_LIST__) - LONG(0) - _edata = .; - } - .bss SIZEOF(.data) + ADDR(.data) : - { - *(.bss) - [COMMON] - _end = .; - } -} - - diff --git a/ld/ld-lnk960-r.script b/ld/ld-lnk960-r.script deleted file mode 100755 index daf59bba024..00000000000 --- a/ld/ld-lnk960-r.script +++ /dev/null @@ -1,17 +0,0 @@ -SECTIONS -{ - .text 0: - { - *(.text) - } - .data SIZEOF(.text) + ADDR(.text): - { - *(.data) - } - .bss SIZEOF(.data) + ADDR(.data) : - { - *(.bss) - [COMMON] - } -} - diff --git a/ld/ld-lnk960.c b/ld/ld-lnk960.c deleted file mode 100755 index 984ed2ee9d3..00000000000 --- a/ld/ld-lnk960.c +++ /dev/null @@ -1,288 +0,0 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. - -This file is part of GLD, the Gnu Linker. - -GLD 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 1, or (at your option) -any later version. - -GLD 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 GLD; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - $Id$ -*/ - -/* - - Written by Steve Chamberlain steve@cygnus.com - - * intel coff loader emulation specific stuff - */ - -#include "sysdep.h" -#include "bfd.h" - -/*#include "archures.h"*/ -#include "ld.h" -#include "config.h" -#include "ld-emul.h" -#include "ldmisc.h" -#include "ldlang.h" -#include "ldfile.h" - -extern boolean lang_float_flag; -extern bfd *output_bfd; - - - -extern enum bfd_architecture ldfile_output_architecture; -extern unsigned long ldfile_output_machine; -extern char *ldfile_output_machine_name; - - -typedef struct lib_list { - char *name; - struct lib_list *next; -} lib_list_type; - -static lib_list_type *hll_list; -static lib_list_type **hll_list_tail = &hll_list; - -static lib_list_type *syslib_list; -static lib_list_type **syslib_list_tail = &syslib_list; - - -static void -append(list, name) -lib_list_type ***list; -char *name; -{ - lib_list_type *element = - (lib_list_type *)(ldmalloc(sizeof(lib_list_type))); - - element->name = name; - element->next = (lib_list_type *)NULL; - **list = element; - *list = &element->next; - -} - -static boolean had_hll = false; -static boolean had_hll_name = false; -static void -lnk960_hll(name) -char *name; -{ - had_hll = true; - if (name != (char *)NULL) { - had_hll_name = true; - append(&hll_list_tail, name); - } -} - -static void -lnk960_syslib(name) -char *name; -{ - append(&syslib_list_tail,name); -} - - - -#ifdef GNU960 - -static void -lnk960_before_parse() -{ - static char *env_variables[] = { "G960LIB", "G960BASE", 0 }; - char **p; - char *env ; - - for ( p = env_variables; *p; p++ ){ - env = (char *) getenv(*p); - if (env) { - ldfile_add_library_path(concat(env,"/lib/libcoff","")); - } - } - - env= (char *) getenv("I960BASE"); - if ( env ) { - ldfile_add_library_path(concat(env,"/lib","")); - } - - ldfile_output_architecture = bfd_arch_i960; - ldfile_output_machine = bfd_mach_i960_core; -} - -#else /* not GNU960 */ - -static void -lnk960_before_parse() -{ - char *name = getenv("I960BASE"); - - if (name == (char *)NULL) { - name = getenv("G960BASE"); - if (name == (char *)NULL) { - info("%P%F I960BASE and G960BASE not set\n"); - } - } - - - ldfile_add_library_path(concat(name,"/lib","")); - ldfile_output_architecture = bfd_arch_i960; - ldfile_output_machine = bfd_mach_i960_core; -} - -#endif /* GNU960 */ - - -static void -add_on(list, search) -lib_list_type *list; -lang_input_file_enum_type search; -{ - while (list) { - lang_add_input_file(list->name, - search, - (char *)NULL); - list = list->next; - } -} -static void lnk960_after_parse() -{ - - /* If there has been no arch, default to -KB */ - if (ldfile_output_machine_name[0] ==0) { - ldfile_add_arch("KB"); - } - - /* if there has been no hll list then add our own */ - - if(had_hll && !had_hll_name) { - append(&hll_list_tail,"cg"); - if (ldfile_output_machine == bfd_mach_i960_ka_sa || - ldfile_output_machine == bfd_mach_i960_ca) { - { - append(&hll_list_tail,"fpg"); - } - } - } - - add_on(hll_list, lang_input_file_is_l_enum); - add_on(syslib_list, lang_input_file_is_search_file_enum); -} - -static void -lnk960_before_allocation() -{ -} -static void -lnk960_after_allocation() -{ - extern ld_config_type config; - if (config.relocateable_output == false) { - lang_abs_symbol_at_end_of(".text","_etext"); - lang_abs_symbol_at_end_of(".data","_edata"); - lang_abs_symbol_at_beginning_of(".bss","_bss_start"); - lang_abs_symbol_at_end_of(".bss","_end"); - } -} - - -static struct - { - unsigned long number; - char *name; - } -machine_table[] = { - bfd_mach_i960_core ,"CORE", - bfd_mach_i960_kb_sb ,"KB", - bfd_mach_i960_kb_sb ,"SB", - bfd_mach_i960_mc ,"MC", - bfd_mach_i960_xa ,"XA", - bfd_mach_i960_ca ,"CA", - bfd_mach_i960_ka_sa ,"KA", - bfd_mach_i960_ka_sa ,"SA", - - bfd_mach_i960_core ,"core", - bfd_mach_i960_kb_sb ,"kb", - bfd_mach_i960_kb_sb ,"sb", - bfd_mach_i960_mc ,"mc", - bfd_mach_i960_xa ,"xa", - bfd_mach_i960_ca ,"ca", - bfd_mach_i960_ka_sa ,"ka", - bfd_mach_i960_ka_sa ,"sa", - 0,(char *)NULL -}; - -static void -lnk960_set_output_arch() -{ - /* Set the output architecture and machine if possible */ - unsigned int i; - ldfile_output_machine = bfd_mach_i960_core; - for (i= 0; machine_table[i].name != (char*)NULL; i++) { - if (strcmp(ldfile_output_machine_name,machine_table[i].name)==0) { - ldfile_output_machine = machine_table[i].number; - break; - } - } - bfd_set_arch_mach(output_bfd, ldfile_output_architecture, ldfile_output_machine); -} - -static char * -lnk960_choose_target() -{ -#ifdef GNU960 - - return bfd_make_targ_name(BFD_COFF_FORMAT,HOST_BYTE_ORDER_BIG_P); - -#else - - char *from_outside = getenv(TARGET_ENVIRON); - if (from_outside != (char *)NULL) - return from_outside; - return LNK960_TARGET; - -#endif -} - -/* The default script if none is offered */ -static char *lnk960_script = -#include "ld-lnk960.x" -; - - -static char *lnk960_script_relocateable = -#include "ld-lnk960-r.x" -; - -static char *lnk960_get_script() -{ - extern ld_config_type config; - if (config.relocateable_output) { - return lnk960_script_relocateable; - } - return lnk960_script; -} -struct ld_emulation_xfer_struct ld_lnk960_emulation = -{ - lnk960_before_parse, - lnk960_syslib, - lnk960_hll, - lnk960_after_parse, - lnk960_after_allocation, - lnk960_set_output_arch, - lnk960_choose_target, - lnk960_before_allocation, - lnk960_get_script, -}; diff --git a/ld/ld-lnk960.script b/ld/ld-lnk960.script deleted file mode 100755 index f498412f6f3..00000000000 --- a/ld/ld-lnk960.script +++ /dev/null @@ -1,21 +0,0 @@ - -SECTIONS -{ - .text : - { - *(.text) - } -_etext = . ; - .data SIZEOF(.text) + ADDR(.text): - { - *(.data) - } -_edata = .; - .bss SIZEOF(.data) + ADDR(.data) : - { - _bss_start = . ; - *(.bss) - [COMMON] - } -_end = . ; -} diff --git a/ld/ld-vanilla.c b/ld/ld-vanilla.c deleted file mode 100755 index 883fb1d0a39..00000000000 --- a/ld/ld-vanilla.c +++ /dev/null @@ -1,124 +0,0 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. - -This file is part of GLD, the Gnu Linker. - -GLD 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 1, or (at your option) -any later version. - -GLD 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 GLD; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - * $Id$ - * -*/ - -/* - * A vanilla emulation with no defaults - * - * Written by Steve Chamberlain steve@cygnus.com - */ - - -#include "sysdep.h" -#include "bfd.h" - - -#include "ld.h" -#include "config.h" -#include "ld-emul.h" -#include "ldfile.h" -#include "ldmisc.h" - -extern boolean lang_float_flag; - - -extern enum bfd_architecture ldfile_output_architecture; -extern unsigned long ldfile_output_machine; -extern char *ldfile_output_machine_name; - -extern bfd *output_bfd; - - - -static void vanilla_before_parse() -{ -} - - -static void -vanilla_after_parse() -{ - -} - -static void -vanilla_after_allocation() -{ - -} - -static void -vanilla_before_allocation() -{ - -} - - -static void -vanilla_set_output_arch() -{ - /* Set the output architecture and machine if possible */ - unsigned long machine = 0; - bfd_set_arch_mach(output_bfd, ldfile_output_architecture, machine); -} - -static char * -vanilla_choose_target() -{ - char *from_outside = getenv(TARGET_ENVIRON); - if (from_outside != (char *)NULL) - return from_outside; - return VANILLA_TARGET; -} - -static void -vanilla_syslib() -{ - info("%S SYSLIB ignored\n"); -} - -static void -vanilla_hll(ignore) -char *ignore; -{ - info("%S HLL ignored\n"); -} - - -static char *vanilla_get_script() -{ -return ""; -} - -struct ld_emulation_xfer_struct ld_vanilla_emulation = -{ - vanilla_before_parse, - vanilla_syslib, - vanilla_hll, - vanilla_after_parse, - vanilla_after_allocation, - vanilla_set_output_arch, - vanilla_choose_target, - vanilla_before_allocation, - vanilla_get_script, -}; - diff --git a/ld/ld.h b/ld/ld.h deleted file mode 100644 index 50ee41ad6ff..00000000000 --- a/ld/ld.h +++ /dev/null @@ -1,107 +0,0 @@ -/* ld.h - - - Copyright (C) 1991 Free Software Foundation, Inc. - - This file is part of GLD, the Gnu Linker. - - GLD 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 1, or (at your option) - any later version. - - GLD 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 GLD; see the file COPYING. If not, write to - the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - - -#define flag_is_not_at_end(x) ((x) & BSF_NOT_AT_END) -#define flag_is_ordinary_local(x) (((x) & (BSF_LOCAL))&!((x) & (BSF_DEBUGGING))) -#define flag_is_debugger(x) ((x) & BSF_DEBUGGING) -#define flag_is_undefined_or_global(x) ((x) & (BSF_UNDEFINED | BSF_GLOBAL)) -#define flag_is_defined(x) (!((x) & (BSF_UNDEFINED))) -#define flag_is_global_or_common(x) ((x) & (BSF_GLOBAL | BSF_FORT_COMM)) -#define flag_is_undefined_or_global_or_common(x) ((x) & (BSF_UNDEFINED | BSF_GLOBAL | BSF_FORT_COMM)) -#define flag_is_common(x) ((x) & BSF_FORT_COMM) -#define flag_is_global(x) ((x) & (BSF_GLOBAL)) -#define flag_is_undefined(x) ((x) & BSF_UNDEFINED) -#define flag_set(x,y) (x = y) -#define flag_is_fort_comm(x) ((x) & BSF_FORT_COMM) -#define flag_is_absolute(x) ((x) & BSF_ABSOLUTE) -/* Extra information we hold on sections */ -typedef struct user_section_struct { - /* Pointer to the section where this data will go */ - struct lang_input_statement_struct *file; -} section_userdata_type; - - -#define get_userdata(x) ((x)->userdata) -#define as_output_section_statement(x) ((x)->otheruserdata) - - - -/* Which symbols should be stripped (omitted from the output): - none, all, or debugger symbols. */ -typedef enum { STRIP_NONE, STRIP_ALL, STRIP_DEBUGGER } strip_symbols_type; - - - - -/* Which local symbols should be omitted: - none, all, or those starting with L. - This is irrelevant if STRIP_NONE. */ -typedef enum { DISCARD_NONE, DISCARD_ALL, DISCARD_L } discard_locals_type; - - - - - - -#define ALIGN(this, boundary) ((( (this) + ((boundary) -1)) & (~((boundary)-1)))) - -typedef struct { - /* 1 => assign space to common symbols even if `relocatable_output'. */ - boolean force_common_definition; - -} args_type; - -typedef int token_code_type; - -typedef struct -{ - unsigned int specified_data_size; - boolean magic_demand_paged; - boolean make_executable; - /* 1 => write relocation into output file so can re-input it later. */ - boolean relocateable_output; - - /* Will we build contstructors, or leave alone ? */ - boolean build_constructors; - /* 1 => write relocation such that a UNIX linker can understand it. - This is used mainly to finish of sets that were built. */ - boolean unix_relocate; - - boolean sort_common; -} ld_config_type; -#define set_asymbol_chain(x,y) ((x)->udata = (PTR)y) -#define get_asymbol_chain(x) ((asymbol **)((x)->udata)) -#define get_loader_symbol(x) ((loader_global_asymbol *)((x)->udata)) -#define set_loader_symbol(x,y) ((x)->udata = (PTR)y) - - - - - - -typedef enum { - lang_first_phase_enum, - lang_allocating_phase_enum, - lang_final_phase_enum } lang_phase_type; - - - - diff --git a/ld/ld.tex b/ld/ld.tex deleted file mode 100755 index 1764ad507c3..00000000000 --- a/ld/ld.tex +++ /dev/null @@ -1,1014 +0,0 @@ -\input texinfo -@parindent=0pt -@setfilename gld -@c @@setchapternewpage odd -@settitle GLD, The GNU linker -@titlepage -@title{gld} -@subtitle{The gnu loader} -@sp 1 -@subtitle Second Edition---gld version 2.0 -@subtitle January 1991 -@vskip 0pt plus 1filll -Copyright @copyright{} 1991 Free Software Foundation, Inc. - -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. - -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided also that -the entire resulting derived work is distributed under the terms of a -permission notice identical to this one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions. - -@author {Steve Chamberlain} -@author {Cygnus Support} -@author {steve@@cygnus.com} -@end titlepage - -@node Top,,, -@comment node-name, next, previous, up -@ifinfo -This file documents the GNU linker gld. -@end ifinfo - -@c chapter What does a linker do ? -@c chapter Command Language -@noindent -@chapter Overview - - -The @code{gld} command combines a number of object and archive files, -relocates their data and ties up symbol references. Often the last -step in building a new compiled program to run is a call to @code{gld}. - -The @code{gld} command accepts Linker Command Language files in -a superset of AT+T's Link Editor Command Language syntax, -to provide explict and total control over the linking process. - -This version of @code{gld} uses the general purpose @code{bfd} libraries -to operate on object files. This allows @code{gld} to read and -write any of the formats supported by @code{bfd}, different -formats may be linked together producing any available object file. - -Supported formats: -@itemize @bullet -@item -Sun3 68k a.out -@item -IEEE-695 68k Object Module Format -@item -Oasys 68k Binary Relocatable Object File Format -@item -Sun4 sparc a.out -@item -88k bcs coff -@item -i960 coff little endian -@item -i960 coff big endian -@item -i960 b.out little endian -@item -i960 b.out big endian -@item -s-records -@end itemize - -When linking similar formats, @code{gld} maintains all debugging -information. - -@chapter Command line options - -@example - gld [ -Bstatic ] [ -D @var{datasize} ] - [ -c @var{filename} ] - [ -d ] | [ -dc ] | [ -dp ] - [ -i ] - [ -e @var{entry} ] [ -l @var{arch} ] [ -L @var{searchdir} ] [ -M ] - [ -N | -n | -z ] [ -noinhibit-exec ] [ -r ] [ -S ] [ -s ] - [ -f @var{fill} ] - [ -T @var{textorg} ] [ -Tdata @var{dataorg} ] [ -t ] [ -u @var{sym}] - [ -X ] [ -x ] - [-o @var{output} ] @var{objfiles}@dots{} -@end example - -Command-line options to GNU @code{gld} may be specified in any order, and -may be repeated at will. For the most part, repeating an option with a -different argument will either have no further effect, or override prior -occurrences (those further to the left on the command line) of an -option. - -The exceptions which may meaningfully be present several times -are @code{-L}, @code{-l}, and @code{-u}. - -@var{objfiles} may follow, precede, or be mixed in with -command-line options; save that an @var{objfiles} argument may not be -placed between an option flag and its argument. - -Option arguments must follow the option letter without intervening -whitespace, or be given as separate arguments immediately following the -option that requires them. - -@table @code -@item @var{objfiles}@dots{} -The object files @var{objfiles} to be linked; at least one must be specified. - -@item -Bstatic -This flag is accepted for command-line compatibility with the SunOS linker, -but has no effect on @code{gld}. - -@item -c @var{commandfile} -Directs @code{gld} to read linkage commands from the file @var{commandfile}. - -@item -D @var{datasize} -Use this option to specify a target size for the @code{data} segment of -your linked program. The option is only obeyed if @var{datasize} is -larger than the natural size of the program's @code{data} segment. - -@var{datasize} must be an integer specified in hexadecimal. - -@code{ld} will simply increase the size of the @code{data} segment, -padding the created gap with zeros, and reduce the size of the -@code{bss} segment to match. - -@item -d -Force @code{ld} to assign space to common symbols -even if a relocatable output file is specified (@code{-r}). - -@item -dc | -dp -This flags is accepted for command-line compatibility with the SunOS linker, -but has no effect on @code{gld}. - -@item -e @var{entry} -Use @var{entry} as the explicit symbol for beginning execution of your -program, rather than the default entry point. If this symbol is -not specified, the symbol @code{start} is used as the entry address. -If there is no symbol called @code{start}, then the entry address -is set to the first address in the first output section -(usually the @samp{text} section). - -@item -f @var{fill} -Sets the default fill pattern for ``holes'' in the output file to -the lowest two bytes of the expression specified. - -@item -i -Produce an incremental link (same as option @code{-r}). - -@item -l @var{arch} -Add an archive file @var{arch} to the list of files to link. This -option may be used any number of times. @code{ld} will search its -path-list for occurrences of @code{lib@var{arch}.a} for every @var{arch} -specified. - -@c This also has a side effect of using the "c++ demangler" if we happen -@c to specify -llibg++. Document? pesch@@cygnus.com, 24jan91 - -@item -L @var{searchdir} -This command adds path @var{searchdir} to the -list of paths that @code{gld} will search for archive libraries. You -may use this option any number of times. - -@c Should we make any attempt to list the standard paths searched -@c without listing? When hacking on a new system I often want to know -@c this, but this may not be the place... it's not constant across -@c systems, of course, which is what makes it interesting. -@c pesch@@cygnus.com, 24jan91. - -@item -M -@itemx -m -Print (to the standard output file) a link map---diagnostic information -about where symbols are mapped by @code{ld}, and information on global -common storage allocation. - -@item -N -specifies read and writable @code{text} and @code{data} sections. If -the output format supports Unix style magic numbers, then OMAGIC is set. - -@item -n -sets the text segment to be read only, and @code{NMAGIC} is written -if possible. - -@item -o @var{output} -@var{output} is a name for the program produced by @code{ld}; if this -option is not specified, the name @samp{a.out} is used by default. - -@item -r -Generates relocatable output---i.e., generate an output file that can in -turn serve as input to @code{gld}. As a side effect, this option also -sets the output file's magic number to @code{OMAGIC}; see @samp{-N}. If this -option is not specified, an absolute file is produced. - -@item -S -Omits debugger symbol information (but not all symbols) from the output file. - -@item -s -Omits all symbol information from the output file. - -@item -T @var{textorg} -@itemx -Ttext @var{textorg} -Use @var{textorg} as the starting address for the @code{text} segment of the -output file. Both forms of this option are equivalent. The option -argument must be a hexadecimal integer. - -@item -Tdata @var{dataorg} -Use @var{dataorg} as the starting address for the @code{data} segment of -the output file. The option argument must be a hexadecimal integer. - -@item -t -Prints names of input files as @code{ld} processes them. - -@item -u @var{sym} -Forces @var{sym} to be entered in the output file as an undefined symbol. -This may, for example, trigger linking of additional modules from -standard libraries. @code{-u} may be repeated with different option -arguments to enter additional undefined symbols. This option is equivalent -to the @code{EXTERN} linker command. - -@item -X -If @code{-s} or @code{-S} is also specified, delete only local symbols -beginning with @samp{L}. - -@item -z -@code{-z} sets @code{ZMAGIC}, the default: the @code{text} segment is -read-only, demand pageable, and shared. - -Specifying a relocatable output file (@code{-r}) will also set the magic -number to @code{OMAGIC}. - -See description of @samp{-N}. - - -@end table -@chapter Command Language - - -The command language allows explicit control over the linkage process, allowing -specification of: -@table @bullet -@item input files -@item file formats -@item output file format -@item addresses of sections -@item placement of common blocks -@item and more -@end table - -A command file may be supplied to the linker, either explicitly through the -@code{-c} option, or implicitly as an ordinary file. If the linker opens -a file which does not have a reasonable object or archive format, it tries -to read the file as if it were a command file. -@section Structure -To be added - -@section Expressions -The syntax for expressions in the command language is identical to that of -C expressions, with the following features: -@table @bullet -@item All expressions evaluated as integers and -are of ``long'' or ``unsigned long'' type. -@item All constants are integers. -@item All of the C arithmetic operators are provided. -@item Global variables may be referenced, defined and created. -@item Build in functions may be called. -@end table - -@section Expressions - -The linker has a practice of ``lazy evaluation'' for expressions; it only -calculates an expression when absolutely necessary. For instance, -when the linker reads in the command file it has to know the values -of the start address and the length of the memory regions for linkage to continue, so these -values are worked out, but other values (such as symbol values) are not -known or needed until after storage allocation. -They are evaluated later, when the other -information, such as the sizes of output sections are available for use in -the symbol assignment expression. - -When a linker expression is evaluated and assigned to a variable it is given -either an absolute or a relocatable type. An absolute expression type -is one in which the symbol contains the value that it will have in the -output file, a relocateable expression type is one in which the value -is expressed as a fixed offset from the base of a section. - -The type of the expression is controlled by its position in the script -file. A symbol assigned within a @code{SECTION} specification is -created relative to the base of the section, a symbol assigned in any -other place is created as an absolute symbol. Since a symbol created -within a @code{SECTION} specification is relative to the base of the -section it will remain relocatable if relocatable output is requested. -A symbol may be created with an absolute value even when assigned to -within a @code{SECTION} specification by using the absolute assignment -function @code{ABSOLUTE} For example, to create an absolute symbol -whose address is the last byte of the output section @code{.data}: -@example -.data : - @{ - *(.data) - _edata = ABSOLUTE(.) ; - @} -@end example - -Unless quoted, symbol names start with a letter, underscore, point or -minus sign and may include any letters, underscores, digits, points, -and minus signs. Unquoted symbol names must not conflict with any -keywords. To specify a symbol which contains odd characters or has -the same name as a keyword surround it in double quotes: -@example - ``SECTION'' = 9; - ``with a space'' = ``also with a space'' + 10; -@end example - -@subsection Integers -An octal integer is @samp{0} followed by zero or more of the octal -digits (@samp{01234567}). - -A decimal integer starts with a non-zero digit followed by zero or -more digits (@samp{0123456789}). - -A hexadecimal integer is @samp{0x} or @samp{0X} followed by one or -more hexadecimal digits chosen from @samp{0123456789abcdefABCDEF}. - -Integers have the usual values. To denote a negative integer, use -the unary operator @samp{-} discussed under expressions. - -Additionally the suffixes @code{K} and @code{M} may be used to multiply the -previous constant by 1024 or -@tex -$1024^2$ -@end tex -respectively. - -@example - _as_decimal = 57005; - _as_hex = 0xdead; - _as_octal = 0157255; - - _4k_1 = 4K; - _4k_2 = 4096; - _4k_3 = 0x1000; -@end example -@subsection Operators -The linker provides the standard C set of arithmetic operators, with -the standard bindings and precedence levels: -@example - -@end example -@tex - -\vbox{\offinterlineskip -\hrule -\halign -{\vrule#&\hfil#\hfil&\vrule#&\hfil#\hfil&\vrule#&\hfil#\hfil&\vrule#\cr -height2pt&&&&&\cr -&Level&& associativity &&Operators&\cr -height2pt&&&&&\cr -\noalign{\hrule} -height2pt&&&&&\cr -&highest&&&&&&\cr -&1&&left&&$ ! - ~$&\cr -height2pt&&&&&\cr -&2&&left&&* / \%&\cr -height2pt&&&&&\cr -&3&&left&&+ -&\cr -height2pt&&&&&\cr -&4&&left&&$>> <<$&\cr -height2pt&&&&&\cr -&5&&left&&$== != > < <= >=$&\cr -height2pt&&&&&\cr -&6&&left&&\&&\cr -height2pt&&&&&\cr -&7&&left&&|&\cr -height2pt&&&&&\cr -&8&&left&&{\&\&}&\cr -height2pt&&&&&\cr -&9&&left&&||&\cr -height2pt&&&&&\cr -&10&&right&&? :&\cr -height2pt&&&&&\cr -&11&&right&&$${\&= += -= *= /=}&\cr -&lowest&&&&&&\cr -height2pt&&&&&\cr} -\hrule} -@end tex - -@section Built in Functions -The command language provides built in functions for use in -expressions in linkage scripts. -@table @bullet -@item @code{ALIGN(@var{exp})} -returns the result of the current location counter (@code{dot}) -aligned to the next @var{exp} boundary, where @var{exp} is a power of -two. This is equivalent to @code{(. + @var{exp} -1) & ~(@var{exp}-1)}. -As an example, to align the output @code{.data} section to the -next 0x2000 byte boundary after the preceding section and to set a -variable within the section to the next 0x8000 boundary after the -input sections: -@example - .data ALIGN(0x2000) :@{ - *(.data) - variable = ALIGN(0x8000); - @} -@end example - -@item @code{ADDR(@var{section name})} -returns the absolute address of the named section if the section has -already been bound. In the following examples the @code{symbol_1} and -@code{symbol_2} are assigned identical values: -@example - .output1: - @{ - start_of_output_1 $= .; - ... - @} - .output: - @{ - symbol_1 = ADDR(.output1); - symbol_2 = start_of_output_1; - @} -@end example - -@item @code{SIZEOF(@var{section name})} -returns the size in bytes of the named section, if the section has -been allocated. In the following example the @code{symbol_1} and -@code{symbol_2} are assigned identical values: -@example - .output @{ - .start = . ; - ... - .end = .; - @} - symbol_1 = .end - .start; - symbol_2 = SIZEOF(.output); -@end example - -@item @code{DEFINED(@var{symbol name})} -Returns 1 if the symbol is in the linker global symbol table and is -defined, otherwise it returns 0. This example shows the setting of a -global symbol @code{begin} to the first location in the @code{.text} -section, only if there is no other symbol -called @code{begin} already: -@example - .text: @{ - begin = DEFINED(begin) ? begin : . ; - ... - @} -@end example -@end table -@page -@section MEMORY Directive -The linker's default configuration is for all memory to be -allocatable. This state may be overridden by using the @code{MEMORY} -directive. The @code{MEMORY} directive describes the location and -size of blocks of memory in the target. Careful use can describe -memory regions which may or may not be used by the linker. The linker -does not shuffle sections to fit into the available regions, but does -move the requested sections into the correct regions and issue errors -when the regions become too full. The syntax is: - -@example - MEMORY - @{ -@tex - $\bigl\lbrace {\it name_1} ({\it attr_1}):$ ORIGIN = ${\it origin_1},$ LENGTH $= {\it len_1} \bigr\rbrace $ -@end tex - - @} -@end example -@table @code -@item @var{name} -is a name used internally by the linker to refer to the region. Any -symbol name may be used. The region names are stored in a separate -name space, and will not conflict with symbols, filenames or section -names. -@item @var{attr} -is an optional list of attributes, parsed for compatibility with the -AT+T linker -but ignored by the both the AT+T and the gnu linker. -@item @var{origin} -is the start address of the region in physical memory expressed as -standard linker expression which must evaluate to a constant before -memory allocation is performed. The keyword @code{ORIGIN} may be -abbreviated to @code{org} or @code{o}. -@item @var{len} -is the size in bytes of the region as a standard linker expression. -The keyword @code{LENGTH} may be abbreviated to @code{len} or @code{l} -@end table - -For example, to specify that memory has two regions available for -allocation; one starting at 0 for 256k, and the other starting at -0x40000000 for four megabytes: - -@example - MEMORY - @{ - rom : ORIGIN= 0, LENGTH = 256K - ram : ORIGIN= 0x40000000, LENGTH = 4M - @} - -@end example - -If the combined output sections directed to a region are too big for -the region the linker will emit an error message. -@page -@section SECTIONS Directive -The @code{SECTIONS} directive -controls exactly where input sections are placed into output sections, their -order and to which output sections they are allocated. - -When no @code{SECTIONS} directives are specified, the default action -of the linker is to place each input section into an identically named -output section in the order that the sections appear in the first -file, and then the order of the files. - -The syntax of the @code{SECTIONS} directive is: - -@example - SECTIONS - @{ -@tex - $\bigl\lbrace {\it name_n}\bigl[options\bigr]\colon$ $\bigl\lbrace {\it statements_n} \bigr\rbrace \bigl[ = {\it fill expression } \bigr] \bigl[ > mem spec \bigr] \bigr\rbrace $ -@end tex - @} -@end example - -@table @code -@item @var{name} -controls the name of the output section. In formats which only support -a limited number of sections, such as @code{a.out}, the name must be -one of the names supported by the format (in the case of a.out, -@code{.text}, @code{.data} or @code{.bss}). If the output format -supports any number of sections, but with numbers and not names (in -the case of IEEE), the name should be supplied as a quoted numeric -string. A section name may consist of any sequence characters, but -any name which does not conform to the standard @code{gld} symbol name -syntax must be quoted. To copy sections 1 through 4 from a Oasys file -into the @code{.text} section of an @code{a.out} file, and sections 13 -and 14 into the @code{data} section: -@example - - SECTION @{ - .text :@{ - *(``1'' ``2'' ``3'' ``4'') - @} - - .data :@{ - *(``13'' ``14'') - @} - @} -@end example - -@item @var{fill expression} -If present this -expression sets the fill value. Any unallocated holes in the current output -section when written to the output file will -be filled with the two least significant bytes of the value, repeated as -necessary. -@page -@item @var{options} -the @var{options} parameter is a list of optional arguments specifying -attributes of the output section, they may be taken from the following -list: -@table @bullet{} -@item @var{addr expression} -forces the output section to be loaded at a specified address. The -address is specified as a standard linker expression. The following -example generates section @var{output} at location -@code{0x40000000}: -@example - SECTIONS @{ - output 0x40000000: @{ - ... - @} - @} -@end example -Since the built in function @code{ALIGN} references the location -counter implicitly, a section may be located on a certain boundary by -using the @code{ALIGN} function in the expression. For example, to -locate the @code{.data} section on the next 8k boundary after the end -of the @code{.text} section: -@example - SECTIONS @{ - .text @{ - ... - @} - .data ALIGN(4K) @{ - ... - @} - @} -@end example -@end table -@item @var{statements} -is a list of file names, input sections and assignments. These statements control what is placed into the -output section. -The syntax of a single @var{statement} is one of: -@table @bullet - -@item @var{symbol} [ $= | += | -= | *= | /= ] @var{ expression} @code{;} - -Global symbols may be created and have their values (addresses) -altered using the assignment statement. The linker tries to put off -the evaluation of an assignment until all the terms in the source -expression are known; for instance the sizes of sections cannot be -known until after allocation, so assignments dependent upon these are -not performed until after allocation. Some expressions, such as those -depending upon the location counter @code{dot}, @samp{.} must be -evaluated during allocation. If the result of an expression is -required, but the value is not available, then an error results: eg -@example - SECTIONS @{ - text 9+this_isnt_constant: - @{ - @} - @} - testscript:21: Non constant expression for initial address -@end example - -@item @code{CREATE_OBJECT_SYMBOLS} -causes the linker to create a symbol for each input file and place it -into the specified section set with the value of the first byte of -data written from the input file. For instance, with @code{a.out} -files it is conventional to have a symbol for each input file. -@example - SECTIONS @{ - .text 0x2020 : - @{ - CREATE_OBJECT_SYMBOLS - *(.text) - _etext = ALIGN(0x2000); - @} - @} -@end example -Supplied with four object files, @code{a.o}, @code{b.o}, @code{c.o}, -and @code{d.o} a run of -@code{gld} could create a map: -@example -From functions like : -a.c: - afunction() { } - int adata=1; - int abss; - -00000000 A __DYNAMIC -00004020 B _abss -00004000 D _adata -00002020 T _afunction -00004024 B _bbss -00004008 D _bdata -00002038 T _bfunction -00004028 B _cbss -00004010 D _cdata -00002050 T _cfunction -0000402c B _dbss -00004018 D _ddata -00002068 T _dfunction -00004020 D _edata -00004030 B _end -00004000 T _etext -00002020 t a.o -00002038 t b.o -00002050 t c.o -00002068 t d.o - -@end example - -@item @var{filename} @code{(} @var{section name list} @code{)} -This command allocates all the named sections from the input object -file supplied into the output section at the current point. Sections -are written in the order they appear in the list so: -@example - SECTIONS @{ - .text 0x2020 : - @{ - a.o(.data) - b.o(.data) - *(.text) - @} - .data : - @{ - *(.data) - @} - .bss : - @{ - *(.bss) - COMMON - @} - @} -@end example -will produce a map: -@example - - insert here -@end example -@item @code{* (} @var{section name list} @code{)} -This command causes all sections from all input files which have not -yet been assigned output sections to be assigned the current output -section. - -@item @var{filename} @code{[COMMON]} -This allocates all the common symbols from the specified file and places -them into the current output section. - -@item @code{* [COMMON]} -This allocates all the common symbols from the files which have not -yet had their common symbols allocated and places them into the current -output section. - -@item @var{filename} -A filename alone within a @code{SECTIONS} statement will cause all the -input sections from the file to be placed into the current output -section at the current location. If the file name has been mentioned -before with a section name list then only those -sections which have not yet been allocated are noted. - -The following example reads all of the sections from file all.o and -places them at the start of output section @code{outputa} which starts -at location @code{0x10000}. All of the data from section @code{.input1} from -file foo.o is placed next into the same output section. All of -section @code{.input2} is read from foo.o and placed into output -section @code{outputb}. Next all of section @code{.input1} is read -from foo1.o. All of the remaining @code{.input1} and @code{.input2} -sections from any files are written to output section @code{output3}. - -@example - SECTIONS - @{ - outputa 0x10000 : - @{ - all.o - foo.o (.input1) - @} - outputb : - @{ - foo.o (.input2) - foo1.o (.input1) - @} - outputc : - @{ - *(.input1) - *(.input2) - @} - @} - -@end example -@end table -@end table -@section Using the Location Counter -The special linker variable @code{dot}, @samp{.} always contains the -current output location counter. Since the @code{dot} always refers to -a location in an output section, it must always appear in an -expression within a @code{SECTIONS} directive. The @code{dot} symbol -may appear anywhere that an ordinary symbol may appear in an -expression, but its assignments have a side effect. Assigning a value -to the @code{dot} symbol will cause the location counter to be moved. -This may be used to create holes in the output section. The location -counter may never be moved backwards. -@example - SECTIONS - @{ - output : - @{ - file1(.text) - . = . + 1000; - file2(.text) - . += 1000; - file3(.text) - . -= 32; - file4(.text) - @} = 0x1234; - @} -@end example -In the previous example, @code{file1} is located at the beginning of -the output section, then there is a 1000 byte gap, filled with 0x1234. -Then @code{file2} appears, also with a 1000 byte gap following before -@code{file3} is loaded. Then the first 32 bytes of @code{file4} are -placed over the last 32 bytes of @code{file3}. -@section Command Language Syntax -@section The Entry Point -The linker chooses the first executable instruction in an output file from a list -of possibilities, in order: -@itemize @bullet -@item -The value of the symbol provided to the command line with the @code{-e} option, when -present. -@item -The value of the symbol provided in the @code{ENTRY} directive, -if present. -@item -The value of the symbol @code{start}, if present. -@item -The value of the symbol @code{_main}, if present. -@item -The address of the first byte of the @code{.text} section, if present. -@item -The value 0. -@end itemize -If the symbol @code{start} is not defined within the set of input -files to a link, it may be generated by a simple assignment -expression. eg. -@example - start = 0x2020; -@end example -@section Section Attributes -@section Allocation of Sections into Memory -@section Defining Symbols -@chapter Examples of operation -The simplest case is linking standard Unix object files on a standard -Unix system supported by the linker. To link a file hello.o: -@example -$ gld -o output /lib/crt0.o hello.o -lc -@end example -This tells gld to produce a file called @code{output} after linking -the file @code{/lib/crt0.o} with @code{hello.o} and the library -@code{libc.a} which will come from the standard search directories. -@chapter Partial Linking -Specifying the @code{-r} on the command line causes @code{gld} to -perform a partial link. - - -@chapter BFD - -The linker accesses object and archive files using the @code{bfd} -libraries. These libraries allow the linker to use the same routines -to operate on object files whatever the object file format. - -A different object file format can be supported simply by creating a -new @code{bfd} back end and adding it to the library. - -Formats currently supported: -@itemize @bullet -@item -Sun3 68k a.out -@item -IEEE-695 68k Object Module Format -@item -Oasys 68k Binary Relocatable Object File Format -@item -Sun4 sparc a.out -@item -88k bcs coff -@item -i960 coff little endian -@item -i960 coff big endian -@item -i960 b.out little endian -@item -i960 b.out big endian -@end itemize - -As with most implementations, @code{bfd} is a compromise between -several conflicting requirements. The major factor influencing -@code{bfd} design was efficiency, any time used converting between -formats is time which would not have been spent had @code{bfd} not -been involved. This is partly offset by abstraction payback; since -@code{bfd} simplifies applications and back ends, more time and care -may be spent optimizing algorithms for a greater speed. - -One minor artifact of the @code{bfd} solution which the -user should be aware of is information lossage. -There are two places where useful information can be lost using the -@code{bfd} mechanism; during conversion and during output. - -@section How it works -When an object file is opened, @code{bfd} -tries to automatically determine the format of the input object file, a -descriptor is built in memory with pointers to routines to access -elements of the object file's data structures. - -As different information from the the object files is required -@code{bfd} reads from different sections of the file and processes -them. For example a very common operation for the linker is processing -symbol tables. Each @code{bfd} back end provides a routine for -converting between the object file's representation of symbols and an -internal canonical format. When the linker asks for the symbol table -of an object file, it calls through the memory pointer to the relevant -@code{bfd} back end routine which reads and converts the table into -the canonical form. Linker then operates upon the common form. When -the link is finished and the linker writes the symbol table of the -output file, another @code{bfd} back end routine is called which takes -the newly created symbol table and converts it into the output format. - -@section Information Leaks -@table @bullet{} -@item Information lost during output. -The output formats supported by @code{bfd} do not provide identical -facilities, and information which may be described in one form -has no where to go in another format. One example of this would be -alignment information in @code{b.out}. There is no where in an @code{a.out} -format file to store alignment information on the contained data, so when -a file is linked from @code{b.out} and an @code{a.out} image is produced, -alignment information is lost. (Note that in this case the linker has the -alignment information internally, so the link is performed correctly). - -Another example is COFF section names. COFF files may contain an -unlimited number of sections, each one with a textual section name. If -the target of the link is a format which does not have many sections -(eg @code{a.out}) or has sections without names (eg the Oasys format) -the link cannot be done simply. It is possible to circumvent this -problem by describing the desired input section to output section -mapping with the command language. - -@item Information lost during canonicalization. -The @code{bfd} -internal canonical form of the external formats is not exhaustive, -there are structures in input formats for which there is no direct -representation internally. This means that the @code{bfd} back ends -cannot maintain all the data richness through the transformation -between external to internal and back to external formats. - -This limitation is only a problem when using the linker to read one -format and write another. Each @code{bfd} back end is responsible for -maintaining as much data as possible, and the internal @code{bfd} -canonical form has structures which are opaque to the @code{bfd} core, -and exported only to the back ends. When a file is read in one format, -the canonical form is generated for @code{bfd} and the linker. At the -same time, the back end saves away any information which may otherwise -be lost. If the data is then written back to the same back end, the -back end routine will be able to use the canonical form provided by -the @code{bfd} core as well as the information it prepared earlier. -Since there is a great deal of commonality between back ends, this -mechanism is very useful. There is no information lost when linking -big endian COFF to little endian COFF, or from a.out to b.out. When a -mixture of formats are linked, the information is only lost from the -files with a different format to the destination. -@end table -@section Mechanism -The smallest amount of information is preserved when there -is a small union between the information provided by the source -format, that stored by the canonical format and the information needed -by the destination format. A brief description of the canonical form -will help the user appreciate what is possible to be maintained -between conversions. - -@table @bullet -@item file level Information on target machine -architecture, particular implementation and format type are stored on -a per file basis. Other information includes a demand pageable bit and -a write protected bit. Note that information like Unix magic numbers -is not stored here, only the magic numbers meaning, so a ZMAGIC file -would have both the demand pageable bit and the write protected text -bit set. - -The byte order of the target is stored on a per file basis, so that -both big and little endian object files may be linked together at the -same time. -@item section level -Each section in the input file contains the name of the section, the -original address in the object file, various flags, size and alignment -information and pointers into other @code{bfd} data structures. -@item symbol level -Each symbol contains a pointer to the object file which originally -defined it, its name, value and various flags bits. When a symbol -table is read in all symbols are relocated to make them relative to -the base of the section they were defined in, so each symbol points to -the containing section. Each symbol also has a varying amount of -hidden data to contain private data for the back end. Since the symbol -points to the original file, the symbol private data format is -accessible. Operations may be done to a list of symbols of wildly -different formats without problems. - -Normal global and simple local symbols are maintained on output, so an -output file, no matter the format will retain symbols pointing to -functions, globals, statics and commons. Some symbol information is -not worth retaining; in @code{a.out} type information is stored in the -symbol table as long symbol names. This information would be useless -to most coff debuggers and may be thrown away with appropriate command -line switches. (Note that gdb does support stabs in coff). - -There is one word of type information within the symbol, so if the -format supports symbol type information within symbols - (eg COFF, -IEEE, Oasys) and the type is simple enough to fit within one word -(nearly everything but aggregates) the information will be preserved. - -@item relocation level -Each canonical relocation record contains a pointer to the symbol to -relocate to, the offset of the data to relocate, the section the data -is in and a pointer to a relocation type descriptor. Relocation is -performed effectively by message passing through the relocation type -descriptor and symbol pointer. It allows relocations to be performed -on output data using a relocation method only available in one of the -input formats. For instance, Oasys provides a byte relocation format. -A relocation record requesting this relocation type would point -indirectly to a routine to perform this, so the relocation may be -performed on a byte being written to a COFF file, even though 68k COFF -has no such relocation type. - -@item line numbers -Line numbers have to be relocated along with the symbol information. -Each symbol with an associated list of line number records points to -the first record of the list. The head of a line number list consists -of a pointer to the symbol, which allows divination of the address of -the function who's line number is being described. The rest of the -list is tuples offsets into the section and line indexes. Any format -which can simply derive this information can pass it without lossage -between formats (COFF, IEEE and Oasys). -@end table - - -@bye - - diff --git a/ld/ld.texinfo b/ld/ld.texinfo deleted file mode 100644 index a698fc8bb11..00000000000 --- a/ld/ld.texinfo +++ /dev/null @@ -1,2162 +0,0 @@ -\input texinfo -@setfilename ld.info -@c $Id$ -@syncodeindex ky cp -@c @smallbook -@c @cropmarks -@ifinfo -This file documents the GNU linker GLD. - -Copyright (C) 1991 Free Software Foundation, Inc. - -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. - -@ignore -Permission is granted to process this file through Tex and print the -results, provided the printed document carries copying permission -notice identical to this one except for the removal of this paragraph -(this paragraph not being relevant to the printed manual). - -@end ignore -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided also that the -section entitled ``GNU General Public License'' is included exactly as -in the original, and provided that the entire resulting derived work is -distributed under the terms of a permission notice identical to this -one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions, -except that the section entitled ``GNU General Public License'' may be -included in a translation approved by the author instead of in the -original English. -@end ifinfo -@iftex -@finalout -@setchapternewpage odd -@settitle GLD, the GNU linker -@titlepage -@title gld -@subtitle The GNU linker -@sp 1 -@subtitle Second Edition---@code{gld} version 2.0 -@subtitle April 1991 -@author Steve Chamberlain and Roland Pesch -@author Cygnus Support -@page - -@tex -\def\$#1${{#1}} % Kluge: collect RCS revision info without $...$ -\xdef\manvers{\$Revision$} % For use in headers, footers too -{\parskip=0pt -\hfill Cygnus Support\par -\hfill steve\@cygnus.com, pesch\@cygnus.com\par -\hfill {\it GLD, the GNU linker}, \manvers\par -\hfill \TeX{}info \texinfoversion\par -} -\global\parindent=0pt % Steve likes it this way. -@end tex - -@vskip 0pt plus 1filll -Copyright @copyright{} 1991 Free Software Foundation, Inc. - -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. - -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided also that -the entire resulting derived work is distributed under the terms of a -permission notice identical to this one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions. -@end titlepage -@end iftex -@c FIXME: Talk about importance of *order* of args, cmds to linker! - -@node Top, Overview, (dir), (dir) -@ifinfo -This file documents the GNU linker gld. -@end ifinfo - -@menu -* Overview:: Overview -* Invocation:: Invocation -* Commands:: Command Language -* BFD:: BFD -* Index:: Index - - --- The Detailed Node Listing --- - -Invocation - -* Options:: Command Line Options -* Environment:: Environment Variables - -Command Language - -* Scripts:: Linker Scripts -* Expressions:: Expressions -* MEMORY:: MEMORY Command -* SECTIONS:: SECTIONS Command -* Entry Point:: The Entry Point -* Other Commands:: Other Commands - -Expressions - -* Integers:: Integers -* Symbols:: Symbol Names -* Location Counter:: The Location Counter -* Operators:: Operators -* Evaluation:: Evaluation -* Assignment:: Assignment: Defining Symbols -* Built-ins:: Built-In Functions - -SECTIONS Command - -* Section Definition:: Section Definitions -* Section Contents:: Section Contents -* Section Options:: Optional Section Attributes - -BFD - -* BFD outline:: How it works: an outline of BFD -* BFD information loss:: Information Loss -* Mechanism:: Mechanism -@end menu - -@node Overview, Invocation, Top, Top -@chapter Overview - -@cindex GNU linker -@cindex what is this? -@code{gld} combines a number of object and archive files, relocates -their data and ties up symbol references. Often the last step in -building a new compiled program to run is a call to @code{gld}. - -@code{gld} accepts Linker Command Language files written in -a superset of AT&T's Link Editor Command Language syntax, -to provide explicit and total control over the linking process. - -This version of @code{gld} uses the general purpose BFD libraries -to operate on object files. This allows @code{gld} to read, combine, and -write object files in many different formats---for example, COFF or -@code{a.out}. Different formats may be linked together to produce any -available kind of object file. @xref{BFD} for a list of formats -supported on various architectures. - -Aside from its flexibility, the GNU linker is more helpful than other -linkers in providing diagnostic information. Many linkers abandon -execution immediately upon encountering an error; whenever possible, -@code{gld} continues executing, allowing you to identify other errors -(or, in some cases, to get an output file in spite of the error). - -@node Invocation, Commands, Overview, Top -@chapter Invocation - -The GNU linker @code{gld} is meant to cover a broad range of situations, -and to be as compatible as possible with other linkers. As a result, -you have many choices to control its behavior through the command line, -and through environment variables. - -@menu -* Options:: Command Line Options -* Environment:: Environment Variables -@end menu - -@node Options, Environment, Invocation, Invocation -@section Command Line Options - -@cindex command line -@cindex options -Here is a sketch of the options you can use on the @code{gld} command -line: - -@smallexample -gld [-o @var{output} ] @var{objfiles}@dots{} - [ -A@var{architecture} ] [ -b @var{input-format} ] [ -Bstatic ] - [ -c @var{commandfile} ] [ -d | -dc | -dp ] - [ -defsym @var{symbol} = @var{expression} ] - [ -e @var{entry} ] [ -F ] [ -F @var{format} ] -@c -f was in old GNU linker, not currently in new -@c [ -f @var{fill} ] - [ -format @var{input-format} ] [ -g ] [ -i ] - [ -l@var{ar} ] [ -L@var{searchdir} ] [ -M | -m ] - [ -n ] [ -noinhibit-exec ] [ -R @var{filename} ] -@c -N and -z were alternatives to -n in old GNU linker, not curr in new -@c [ -N | -n | -z ] [ -noinhibit-exec ] [ -R @var{filename} ] - [ -r | -Ur ] [ -S ] [ -s ] [ -T @var{commandfile} ] - [ -Ttext @var{textorg} ] [ -Tdata @var{dataorg} ] [ -Tbss @var{bssorg} ] - [ -t ] [ -u @var{sym}] [-v] [ -X ] [ -x ] - [ @{ @var{script} @} ] -@end smallexample - -This plethora of command-line options may seem intimidating, but in -actual practice few of them are used in any particular context. -@cindex standard Unix system -For instance, a frequent use of @code{gld} is to link standard Unix -object files on a standard, supported Unix system. On such a system, to -link a file @code{hello.o}: -@example -$ gld -o output /lib/crt0.o hello.o -lc -@end example -This tells @code{gld} to produce a file called @code{output} as the -result of linking the file @code{/lib/crt0.o} with @code{hello.o} and -the library @code{libc.a} which will come from the standard search -directories. - -The command-line options to @code{gld} may be specified in any order, and -may be repeated at will. For the most part, repeating an option with a -different argument will either have no further effect, or override prior -occurrences (those further to the left on the command line) of an -option. - -The exceptions---which may meaningfully be used more than once---are -@code{-A}, @code{-b} (or its synonym @code{-format}), @code{-defsym}, -@code{-L}, @code{-l}, @code{-R}, and @code{-u}. - -@cindex object files -The list of object files to be linked together, shown as @var{objfiles}, -may follow, precede, or be mixed in with command-line options; save that -an @var{objfiles} argument may not be placed between an option flag and -its argument. - -Usually the linker is invoked with at least one object file, but other -forms of binary input files can also be specified with @code{-l}, -@code{-R}, and the script command language. If @emph{no} binary input -files at all are specified, the linker does not produce any output, and -issues the message @samp{No input files}. - -Option arguments must either follow the option letter without intervening -whitespace, or be given as separate arguments immediately following the -option that requires them. - -@table @code -@item @var{objfiles}@dots{} -The object files @var{objfiles} to be linked. - -@cindex architectures -@kindex -A@var{arch} -@item -A@var{architecture} -In the current release of @code{gld}, this option is useful only for the -Intel 960 family of architectures. In that @code{gld} configuration, the -@var{architecture} argument is one of the two-letter names identifying -members of the 960 family; the option specifies the desired output -target, and warns of any incompatible instructions in the input files. -It also modifies the linker's search strategy for archive libraries, to -support the use of libraries specific to each particular -architecture, by including in the search loop names suffixed with the -string identifying the architecture. - -For example, if your @code{gld} command line included @w{@samp{-ACA}} as -well as @w{@samp{-ltry}}, the linker would look (in its built-in search -paths, and in any paths you specify with @code{-L}) for a library with -the names -@example -try -libtry.a -tryca -libtryca.a -@end example -@noindent -The first two possibilities would be considered in any event; the last -two are due to the use of @w{@samp{-ACA}}. - -Future releases of @code{gld} may support similar functionality for -other architecture families. - -You can meaningfully use @code{-A} more than once on a command line, if -an architecture family allows combination of target architectures; each -use will add another pair of name variants to search for when @w{@code{-l}} -specifies a library. - -@cindex binary input format -@kindex -b @var{format} -@cindex input format -@item -b @var{input-format} -@cindex input format -Specify the binary format for input object files that follow this option -on the command line. You don't usually need to specify this, as -@code{gld} is configured to expect as a default input format the most -usual format on each machine. @var{input-format} is a text string, the -name of a particular format supported by the BFD libraries. @xref{BFD}. -@code{-format @var{input-format}} has the same effect.@refill - -You may want to use this option if you are linking files with an unusual -binary format. You can also use @code{-b} to switch formats explicitly (when -linking object files of different formats), by including -@code{-b @var{input-format}} before each group of object files in a -particular format. - -The default format is taken from the environment variable -@code{GNUTARGET}. @xref{Environment}. You can also define the input -format from a script, using the command @code{TARGET}. - -@kindex -Bstatic -@item -Bstatic -This flag is accepted for command-line compatibility with the SunOS linker, -but has no effect on @code{gld}. - -@kindex -c @var{cmdfile} -@cindex script files -@item -c @var{commandfile} -Directs @code{gld} to read link commands from the file -@var{commandfile}. These commands will completely override @code{gld}'s -default link format (rather than adding to it); @var{commandfile} must -specify everything necessary to describe the target format. -@xref{Commands}. - -You may also include a script of link commands directly in the command -line by bracketing it between @samp{@{} and @samp{@}} characters. - -@cindex common allocation -@kindex -d -@item -d -@kindex -dc -@itemx -dc -@kindex -dp -@itemx -dp -These three options are equivalent; multiple forms are supported for -compatibility with other linkers. Use any of them to make @code{ld} -assign space to common symbols even if a relocatable output file is -specified (@code{-r}). The script command -@code{FORCE_COMMON_ALLOCATION} has the same effect. - -@cindex symbols, from command line -@kindex -defsym @var{symbol}=@var{exp} -@item -defsym @var{symbol} = @var{expression} -Create a global symbol in the output file, containing the absolute -address given by @var{expression}. You may use this option as many -times as necessary to define multiple symbols in the command line. A -limited form of arithmetic is supported for the @var{expression} in this -context: you may give a hexadecimal constant or the name of an existing -symbol, or use @code{+} and @code{-} to add or subtract hexadecimal -constants or symbols. If you need more elaborate expressions, consider -using the linker command language from a script. - -@cindex entry point, from command line -@kindex -e @var{entry} -@item -e @var{entry} -Use @var{entry} as the explicit symbol for beginning execution of your -program, rather than the default entry point. @xref{Entry Point}, for a -discussion of defaults and other ways of specifying the -entry point. - -@ignore -@cindex fill, from command line -@kindex -f @var{fill} -@c -f in older GNU linker, not in new -@item -f @var{fill} -Sets the default fill pattern for ``holes'' in the output file to -the lowest two bytes of the expression specified. Holes are created -when you advance the location counter (@xref{Location Counter}), or when -there is a gap between explicitly specified section addresses -(@xref{Section Options}). -@end ignore - -@kindex -F -@item -F -@itemx -F@var{format} -Some older linkers used this option throughout a compilation toolchain -for specifying object-file format for both input and output object -files. @code{gld}'s mechanisms (the @code{-b} or @code{-format} options -for input files, the @code{TARGET} command in linker scripts for output -files, the @code{GNUTARGET} environment variable) are more flexible, but -but it accepts (and ignores) the @code{-F} option flag for compatibility -with scripts written to call the old linker. - -@kindex -format -@item -format @var{input-format} -Synonym for @code{-b} @var{input-format}. - -@kindex -g -@item -g -Accepted, but ignored; provided for compatibility with other tools. - -@kindex -i -@cindex incremental link -@item -i -Perform an incremental link (same as option @code{-r}). - -@cindex archive files, from cmd line -@kindex -l@var{ar} -@item -l@var{ar} -Add an archive file @var{ar} to the list of files to link. This -option may be used any number of times. @code{ld} will search its -path-list for occurrences of @code{lib@var{ar}.a} for every @var{ar} -specified. - -@cindex search directory, from cmd line -@kindex -L@var{dir} -@item -L@var{searchdir} -This command adds path @var{searchdir} to the list of paths that -@code{gld} will search for archive libraries. You may use this option -any number of times. - -The default set of paths searched (without being specified with -@code{-L}) depends on what emulation mode @code{gld} is using, and in -some cases also on how it was configured. @xref{Environment}. The -paths can also be specified in a link script with the @code{SEARCH_DIR} -command. - -@cindex link map -@kindex -M -@item -M -@kindex -m -@itemx -m -Print (to the standard output file) a link map---diagnostic information -about where symbols are mapped by @code{ld}, and information on global -common storage allocation. - -@ignore -@c -N in older GNU linker, not in new -@kindex -N -@cindex read/write from cmd line -@kindex OMAGIC -@item -N -specifies readable and writable @code{text} and @code{data} sections. If -the output format supports Unix style magic numbers, the output is -marked as @code{OMAGIC}. -@end ignore - -@item -n -@kindex -n -@cindex read-only text -@kindex NMAGIC -sets the text segment to be read only, and @code{NMAGIC} is written -if possible. - -@item -noinhibit-exec -@cindex output file after errors -@kindex -noinhibit-exec -Normally, the linker will not produce an output file if it encounters -errors during the link process. With this flag, you can specify that -you wish the output file retained even after non-fatal errors. - -@item -o @var{output} -@kindex -o @var{output} -@cindex naming the output file -@var{output} is a name for the program produced by @code{ld}; if this -option is not specified, the name @samp{a.out} is used by default. The -script command @code{OUTPUT} can also specify the output file name. - -@item -R @var{filename} -@kindex -R @var{file} -@cindex symbol-only input -Read symbol names and their addresses from @var{filename}, but do not -relocate it or include it in the output. This allows your output file -to refer symbolically to absolute locations of memory defined in other -programs. - -@item -r -@cindex partial link -@cindex relocatable output -@kindex -r -Generates relocatable output---i.e., generate an output file that can in -turn serve as input to @code{gld}. This is often called @dfn{partial -linking}. As a side effect, in environments that support standard Unix -magic numbers, this option also sets the output file's magic number to -@code{OMAGIC}. -@c ; see @code{-N}. -If this option is not specified, an absolute file is produced. When -linking C++ programs, this option @emph{will not} resolve references to -constructors; @code{-Ur} is an alternative. @refill - -This option does the same as @code{-i}. - -@item -S -@kindex -S -@cindex strip debugger symbols -Omits debugger symbol information (but not all symbols) from the output file. - -@item -s -@kindex -s -@cindex strip all symbols -Omits all symbol information from the output file. - -@item @{ @var{script} @} -@kindex @{ @var{script} @} -@cindex scripts on command line -You can, if you wish, include a script of linker commands directly in -the command line instead of referring to it via an input file. When the -character @samp{@{} occurs on the command line, the linker switches to -interpreting the command language until the end of the list of commands -is reached---flagged with a closing brace @samp{@}}. Other command-line -options will not be recognized while parsing the script. -@xref{Commands} for a description of the command language. - -@item -Tbss @var{org} -@kindex -Tbss @var{org} -@itemx -Tdata @var{org} -@kindex -Tdata @var{org} -@itemx -Ttext @var{org} -@kindex -Ttext @var{org} -@cindex segment origins, cmd line -Use @var{org} as the starting address for---respectively---the -@code{bss}, @code{data}, or the @code{text} segment of the output file. -@var{textorg} must be a hexadecimal integer. - -@item -T @var{commandfile} -@itemx -T@var{commandfile} -@kindex -T @var{script} -Equivalent to @code{-c @var{commandfile}}; supported for compatibility with -other tools. - -@item -t -@kindex -t -@cindex verbose -@cindex input files, displaying -Prints names of input files as @code{ld} processes them. - -@item -u @var{sym} -@kindex -u @var{sym} -@cindex undefined symbol -Forces @var{sym} to be entered in the output file as an undefined symbol. -This may, for example, trigger linking of additional modules from -standard libraries. @code{-u} may be repeated with different option -arguments to enter additional undefined symbols. -@c Nice idea, but no such command: This option is equivalent -@c to the @code{EXTERN} linker command. - -@item -Ur -@kindex -Ur -@cindex constructors -For anything other than C++ programs, this option is equivalent to -@code{-r}: it generates relocatable output---i.e., an output file that can in -turn serve as input to @code{gld}. When linking C++ programs, @code{-Ur} -@emph{will} resolve references to constructors, unlike @code{-r}. - -@item -v -@kindex -v -@cindex version -Display the version number for @code{gld}. - -@item -X -@kindex -X -@cindex local symbols, deleting -@cindex L, deleting symbols beginning -If @code{-s} or @code{-S} is also specified, delete only local symbols -beginning with @samp{L}. - -@item -x -@kindex -x -@cindex deleting local symbols -If @code{-s} or @code{-S} is also specified, delete all local symbols, -not just those beginning with @samp{L}. - -@ignore -@c -z in older GNU linker, not in new -@item -z -@kindex -z -@cindex read-only text -Specifies a read-only, demand pageable, and shared @code{text} segment. -If the output format supports Unix-style magic numbers, @code{-z} also -marks the output as @code{ZMAGIC}, the default. - -@c why was following here?. Is it useful to say '-z -r' for -@c instance, or is this just a ref to other ways of setting -@c magic no? -Specifying a relocatable output file (@code{-r}) will also set the magic -number to @code{OMAGIC}. - -See description of @code{-N}. -@end ignore - -@end table - -@node Environment, , Options, Invocation -@section Environment Variables - -@code{gld} always consults two environment variables: @code{GNUTARGET} -and @code{LDEMULATION}. Depending on the setting of the latter, other -environment variables may be used as well. - -@kindex GNUTARGET -@cindex default input format -@code{GNUTARGET} determines the input-file object format if you don't -use @code{-b} (or its synonym @code{-format}). Its value should be one -of the BFD names for an input format (@pxref{BFD}). If there is no -@code{GNUTARGET} in the environment, @code{gld} uses the natural format -of the host. If @code{GNUTARGET} is set to @code{default} then BFD attempts to discover the -input format by examining binary input files; this method often -succeeds, but there are potential ambiguities, since there is no method -of ensuring that the magic number used to flag object-file formats is -unique. However, the configuration procedure for BFD on each system -places the conventional format for that system first in the search-list, -so ambiguities are resolved in favor of convention. - -@kindex LDEMULATION -@cindex emulation -@cindex environment vars -@code{LDEMULATION} controls some aspects of @code{gld}'s dominant -personality. Although @code{gld} is flexible enough to permit its use -in many contexts regardless of configuration, you can use this variable -to make it act more like one or another older linker by default. - -@cindex defaults -@cindex library paths, default -In particular, the value of @code{LDEMULATION} controls what default -linker script is used (thereby controlling the default input and output -formats; @pxref{BFD}); what default paths are searched for -archive libraries; and in some cases whether additional linker script -commands are available. - -Here is the current set of emulations available: -@table @code - -@item LDEMULATION=gld -@kindex gld -@cindex emulating old GNU linker -Emulate the older GNU linker. When this emulation is selected, the -default library search paths are -@example -/lib -/usr/lib -/usr/local/lib/lib -@end example -@noindent -The default output format is set to @code{a.out-generic-big}, and the -default machine is the system's configured BFD default. - -@item LDEMULATION=gld68k -@kindex gld68k -@cindex m68k -A variant of the @code{gld} emulation; only differs in specifically -setting the default BFD machine as @code{m68k}. - -@item LDEMULATION=gld960 -@kindex gld960 -@kindex G960LIB -@kindex G960BASE -@cindex i960 -Emulate the Intel port of the older @code{gld} for the i960 -architectures. The default library search paths are taken from two -other environment variables, @code{G960LIB} and @code{G960BASE}. The -default architecture is @code{i960}. The default output format is set -to @code{b.out.big}, and in fact the default output file name (if -@code{-o} is not specified) is @code{b.out}, to reflect this variant -format, for this emulation. - -@kindex GNU960 -This emulation can behave slightly differently depending on the setting -of the @code{gld} compile-time switch @code{GNU960}. If @code{gld} is -compiled with @code{GNU960} defined, then an additional environment -variable---@code{GNUTARGET}---is available; its value, if available, -specifies some other default output format than @code{b.out.big}. - -@item LDEMULATION=gldm88kbcs -@kindex gldm88kbcs -@cindex m88k -Sets the output format to @code{m88kbcs} and the architecture to -@code{m88k}. Default library search paths are -@example -/lib -/usr/lib -/usr/local/lib -@end example - -@item LDEMULATION=lnk960 -@kindex lnk960 -@cindex i960 -@cindex Architectures, i960 family -Emulate the Intel linker @code{lnk960}. The default output format is -@code{coff-Intel-big}. With this emulation, @code{gld} -supports the additional script commands @code{HLL} and @code{SYSLIB} for -specification of library archives. This is the only emulation with -extensive support for the @code{-A} (architecture) command-line option. -By default, the architecture @code{CORE} is assumed, but you can choose -additional features from the i960 architecture family by using one of -the following with @code{-A} (or by using the @code{OUTPUT_ARCH} command -from a script): -@example -CORE -KB -SB -MC -XA -CA -KA -SA -@end example - -The default libraries are chosen with some attention to the architecture -selected; the core library @file{cg} is always included, but the library -@code{fpg} is also used if you've specified any of the architectures -@code{KA}, @code{SA}, or @code{CA}. - -@kindex GNU960 -Like @code{gld960}, this emulation uses additional environment variables -to set the default library search paths. Also like @code{gld960}, the -behavior of this emulation is slightly different depending on whether -@code{gld} itself was compiled with @code{GNU960} defined. - -@kindex G960BASE -@kindex G960LIB -@kindex I960BASE -If your @code{gld} was compiled with @code{GNU960} defined, the default -paths are taken from all three of @code{G960LIB}, @code{G960BASE}, and -@code{I960BASE}. For the first two, paths you supply are automatically -suffixed with @samp{/lib/libcoff}; for the last, your path is -automatically suffixed with @samp{/lib}. - -If your @code{gld} was @emph{not} compiled with @code{GNU960} defined, -the default paths are taken from @code{I960BASE}, and @code{G960BASE} is -only consulted if @code{I960BASE} is undefined. In this case -@code{G960LIB} is not used at all. - -@item LDEMULATION=vanilla -@kindex vanilla -@cindex emulation, disabling -@cindex disabling emulation -This is the least specific setting for @code{gld}. You can set -@code{LDEMULATION=vanilla} to disable emulation of other linkers. This -setting makes @code{gld} take the default machine from the BFD -configuration on your system; @code{a.out-generic-big} is the default -target. No other defaults are specified. - -@end table - -@node Commands, BFD, Invocation, Top -@chapter Command Language - -@cindex command files -The command language allows explicit control over the link process, -allowing complete specification of the mapping between the linker's -input files and its output. This includes: -@itemize @bullet -@item -input files -@item -file formats -@item -output file format -@item -addresses of sections -@item -placement of common blocks -@end itemize - -You may supply a command file (also known as a link script) to the -linker either explicitly through the @code{-c} option, or implicitly as -an ordinary file. If the linker opens a file which it cannot recognize -as a supported object or archive format, it tries to interpret the file -as a command file. - -You can also include a script directly on the @code{gld} command line, -delimited by the characters @samp{@{} and @samp{@}}. - -@menu -* Scripts:: Linker Scripts -* Expressions:: Expressions -* MEMORY:: MEMORY Command -* SECTIONS:: SECTIONS Command -* Entry Point:: The Entry Point -* Other Commands:: Other Commands -@end menu - -@node Scripts, Expressions, Commands, Commands -@section Linker Scripts -The @code{gld} command language is a collection of statements; some are -simple keywords setting a particular flag, some are used to select and -group input files or name output files; and two particular statement -types have a fundamental and pervasive impact on the linking process. - -@cindex fundamental script commands -@cindex commands, fundamental -@cindex output file layout -@cindex layout of output file -The most fundamental command of the @code{gld} command language is the -@code{SECTIONS} command (@pxref{SECTIONS}). Every meaningful command -script must have a @code{SECTIONS} command: it specifies a -``picture'' of the output file's layout, in varying degrees of detail. -No other command is required in all cases. - -The @code{MEMORY} command complements @code{SECTIONS} by describing the -available memory in the target architecture. This command is optional; -if you don't use a @code{MEMORY} command, @code{gld} assumes sufficient -memory is available in a contiguous block for all output. -@xref{MEMORY}. - -@cindex comments -You may include comments in linker scripts just as in C: delimited -by @samp{/*} and @samp{*/}. As in C, comments are syntactically -equivalent to whitespace. - -@node Expressions, MEMORY, Scripts, Commands -@section Expressions -@cindex expression syntax -@cindex arithmetic -Many useful commands involve arithmetic expressions. The syntax for -expressions in the command language is identical to that of C -expressions, with the following features: -@itemize @bullet -@item -All expressions evaluated as integers and -are of ``long'' or ``unsigned long'' type. -@item -All constants are integers. -@item -All of the C arithmetic operators are provided. -@item -You may reference, define, and create global variables. -@item -You may call special purpose built-in functions. -@end itemize - -@menu -* Integers:: Integers -* Symbols:: Symbol Names -* Location Counter:: The Location Counter -* Operators:: Operators -* Evaluation:: Evaluation -* Assignment:: Assignment: Defining Symbols -* Built-ins:: Built-In Functions -@end menu - -@node Integers, Symbols, Expressions, Expressions -@subsection Integers -@cindex integer notation -@cindex octal integers -An octal integer is @samp{0} followed by zero or more of the octal -digits (@samp{01234567}). -@example -_as_octal = 0157255; -@end example - -@cindex decimal integers -A decimal integer starts with a non-zero digit followed by zero or -more digits (@samp{0123456789}). -@example -_as_decimal = 57005; -@end example - -@cindex hexadecimal integers -@kindex 0x -A hexadecimal integer is @samp{0x} or @samp{0X} followed by one or -more hexadecimal digits chosen from @samp{0123456789abcdefABCDEF}. -@example -_as_hex = 0xdead; -@end example - -@cindex negative integers -Decimal integers have the usual values. To write a negative integer, use -the prefix operator @samp{-}; @pxref{Operators}. -@example -_as_neg = -57005; -@end example - -@cindex scaled integers -@cindex K and M integer suffixes -@cindex M and K integer suffixes -@cindex suffixes for integers -@cindex integer suffixes -Additionally the suffixes @code{K} and @code{M} may be used to scale a -constant by -@c TEXI2ROFF-KILL -@ifinfo -@c END TEXI2ROFF-KILL -@code{1024} or @code{1024*1024} -@c TEXI2ROFF-KILL -@end ifinfo -@tex -${\rm 1024}$ or ${\rm 1024}^2$ -@end tex -@c END TEXI2ROFF-KILL -respectively. For example, the following all refer to the same quantity:@refill - -@example - _fourk_1 = 4K; - _fourk_2 = 4096; - _fourk_3 = 0x1000; -@end example - -@node Symbols, Location Counter, Integers, Expressions -@subsection Symbol Names -@cindex symbol names -@cindex names -@cindex quoted symbol names -@kindex " -Unless quoted, symbol names start with a letter, underscore, point or -hyphen and may include any letters, underscores, digits, points, -and minus signs. Unquoted symbol names must not conflict with any -keywords. You can specify a symbol which contains odd characters or has -the same name as a keyword, by surrounding the symbol name in double quotes: -@example - "SECTION" = 9; - "with a space" = "also with a space" + 10; -@end example - -@node Location Counter, Operators, Symbols, Expressions -@subsection The Location Counter -@kindex . -@cindex dot -@cindex location counter -@cindex current output location -The special linker variable @dfn{dot} @samp{.} always contains the -current output location counter. Since the @code{.} always refers to -a location in an output section, it must always appear in an -expression within a @code{SECTIONS} command. The @code{.} symbol -may appear anywhere that an ordinary symbol is allowed in an -expression, but its assignments have a side effect. Assigning a value -to the @code{.} symbol will cause the location counter to be moved. -@cindex holes -This may be used to create holes in the output section. The location -counter may never be moved backwards. -@example -SECTIONS -@{ - output : - @{ - file1(.text) - . = . + 1000; - file2(.text) - . += 1000; - file3(.text) - @} = 0x1234; -@} -@end example -@noindent -In the previous example, @code{file1} is located at the beginning of the -output section, then there is a 1000 byte gap. Then @code{file2} -appears, also with a 1000 byte gap following before @code{file3} is -loaded. The notation @samp{= 0x1234} specifies what data to write in -the gaps (@pxref{Section Options}). - -@node Operators, Evaluation, Location Counter, Expressions -@subsection Operators -@cindex Operators for arithmetic -@cindex arithmetic operators -@cindex precedence in expressions -The linker recognizes the standard C set of arithmetic operators, with -the standard bindings and precedence levels: -@c TEXI2ROFF-KILL -@ifinfo -@c END TEXI2ROFF-KILL -@example -precedence associativity Operators Notes -(highest) -1 left ! - ~ (1) -2 left * / % -3 left + - -4 left >> << -5 left == != > < <= >= -6 left & -7 left | -8 left && -9 left || -10 right ? : -11 right &= += -= *= /= (2) -(lowest) -@end example -Notes: -(1) Prefix operators -(2) @xref{Assignment} -@c TEXI2ROFF-KILL -@end ifinfo -@tex -\vskip \baselineskip -%"lispnarrowing" is the extra indent used generally for @example -\hskip\lispnarrowing\vbox{\offinterlineskip -\hrule -\halign -{\vrule#&\strut\hfil\ #\ \hfil&\vrule#&\strut\hfil\ #\ \hfil&\vrule#&\strut\hfil\ {\tt #}\ \hfil&\vrule#\cr -height2pt&\omit&&\omit&&\omit&\cr -&Precedence&& Associativity &&{\rm Operators}&\cr -height2pt&\omit&&\omit&&\omit&\cr -\noalign{\hrule} -height2pt&\omit&&\omit&&\omit&\cr -&highest&&&&&\cr -% '176 is tilde, '~' in tt font -&1&&left&&\qquad- \char'176\ !\qquad\dag&\cr -&2&&left&&* / \%&\cr -&3&&left&&+ -&\cr -&4&&left&&>> <<&\cr -&5&&left&&== != > < <= >=&\cr -&6&&left&&\&&\cr -&7&&left&&|&\cr -&8&&left&&{\&\&}&\cr -&9&&left&&||&\cr -&10&&right&&? :&\cr -&11&&right&&\qquad\&= += -= *= /=\qquad\ddag&\cr -&lowest&&&&&\cr -height2pt&\omit&&\omit&&\omit&\cr} -\hrule} -@end tex -@iftex -{ -@obeylines@parskip=0pt@parindent=0pt -@dag@quad Prefix operators. -@ddag@quad @xref{Assignment}. -} -@end iftex -@c END TEXI2ROFF-KILL - -@node Evaluation, Assignment, Operators, Expressions -@subsection Evaluation - -@cindex lazy evaluation -@cindex expression evaluation order -The linker uses ``lazy evaluation'' for expressions; it only calculates -an expression when absolutely necessary. The linker needs the value of -the start address, and the lengths of memory regions, in order to do any -linking at all; these values are computed as soon as possible when the -linker reads in the command file. However, other values (such as symbol -values) are not known or needed until after storage allocation. Such -values are evaluated later, when other information (such as the sizes of -output sections) is available for use in the symbol assignment -expression. - -@node Assignment, Built-ins, Evaluation, Expressions -@subsection Assignment: Defining Symbols -@cindex assignment in scripts -@cindex symbol definition, scripts -@cindex variables, defining -You may create global symbols, and assign values (addresses) to global -symbols, using any of the C assignment operators: - -@table @code -@item @var{symbol} = @var{expression} ; -@itemx @var{symbol} &= @var{expression} ; -@itemx @var{symbol} += @var{expression} ; -@itemx @var{symbol} -= @var{expression} ; -@itemx @var{symbol} *= @var{expression} ; -@itemx @var{symbol} /= @var{expression} ; -@end table - -Two things distinguish assignment from other operators in @code{gld} -expressions. -@itemize @bullet -@item -Assignment may only be used at the root of an expression; -@samp{a=b+3;} is allowed, but @samp{a+b=3;} is an error. - -@kindex ; -@cindex semicolon -@item -A trailing semicolon is required at the end of an assignment -statement. -@end itemize - -Assignment statements may appear: -@itemize @bullet -@item -as commands in their own right in a @code{gld} script; or -@item -as independent statements within a @code{SECTIONS} command; or -@item -as part of the contents of a section definition in a -@code{SECTIONS} command. -@end itemize - -The first two cases are equivalent in effect---both define a symbol with -an absolute address; the last case defines a symbol whose address is -relative to a particular section (@pxref{SECTIONS}). - -@cindex absolute and relocatable symbols -@cindex relocatable and absolute symbols -@cindex symbols, relocatable and absolute -When a linker expression is evaluated and assigned to a variable, it is -given either an absolute or a relocatable type. An absolute expression -type is one in which the symbol contains the value that it will have in -the output file, a relocateable expression type is one in which the -value is expressed as a fixed offset from the base of a section. - -The type of the expression is controlled by its position in the script -file. A symbol assigned within a section definition is created relative -to the base of the section; a symbol assigned in any other place is -created as an absolute symbol. Since a symbol created within a -section definition is relative to the base of the section, it -will remain relocatable if relocatable output is requested. A symbol -may be created with an absolute value even when assigned to within a -section definition by using the absolute assignment function -@code{ABSOLUTE}. For example, to create an absolute symbol whose address -is the last byte of an output section named @code{.data}: -@example -SECTIONS@{ @dots{} -.data : - @{ - *(.data) - _edata = ABSOLUTE(.) ; - @} -@dots{} @} -@end example - -The linker tries to put off the evaluation of an assignment until all -the terms in the source expression are known (@pxref{Evaluation}). For -instance the sizes of sections cannot be known until after allocation, -so assignments dependent upon these are not performed until after -allocation. Some expressions, such as those depending upon the location -counter @dfn{dot}, @samp{.} must be evaluated during allocation. If the -result of an expression is required, but the value is not available, -then an error results. For example, a script like the following -@example -SECTIONS @{ @dots{} - text 9+this_isnt_constant: - @{ @dots{} - @} -@dots{} @} -@end example -@kindex Non constant expression -@noindent -will cause the error message ``@code{Non constant expression for initial -address}''. - -@node Built-ins, , Assignment, Expressions -@subsection Built-In Functions -@cindex functions in expression language -The command language includes a number of special purpose built-in -functions for use in link script expressions. -@table @code -@item ABSOLUTE(@var{exp}) -@kindex ABSOLUTE(@var{exp}) -@cindex expression, absolute -returns the absolute value of the expression @var{exp}. Primarily -useful to assign an absolute value to a symbol within a section -definition, where symbol values are normally section-relative. - -@item ADDR(@var{section}) -@kindex ADDR(@var{section}) -@cindex section address -returns the absolute address of the named @var{section}. Your script must -previously have defined the location of that section. In the following -example the @code{symbol_1} and @code{symbol_2} are assigned identical -values: -@example -SECTIONS@{ @dots{} - .output1: - @{ - start_of_output_1 = ABSOLUTE(.); - @dots{} - @} - .output: - @{ - symbol_1 = ADDR(.output1); - symbol_2 = start_of_output_1; - @} -@dots{} @} -@end example - -@item ALIGN(@var{exp}) -@kindex ALIGN(@var{exp}) -@cindex rounding up location counter -returns the result of the current location counter (@code{.}) aligned to -the next @var{exp} boundary. @var{exp} must be an expression whose -value is a power of two. This is equivalent to -@example -(. + @var{exp} -1) & ~(@var{exp}-1) -@end example - -@code{ALIGN} doesn't change the value of the location counter---it just -does arithmetic on it. As an example, to align the output @code{.data} -section to the next @code{0x2000} byte boundary after the preceding -section and to set a variable within the section to the next -@code{0x8000} boundary after the input sections: -@example -SECTIONS@{ @dots{} - .data ALIGN(0x2000): @{ - *(.data) - variable = ALIGN(0x8000); - @} -@dots{} @} -@end example -@noindent -The first use of @code{ALIGN} in this example specifies the location of -a section because it is used as the optional @var{start} attribute of a -section definition (@pxref{Section Options}). The second use simply -defines the value of a variable. - -The built-in @code{NEXT} is closely related to @code{ALIGN}. - -@item DEFINED(@var{symbol}) -@kindex DEFINED(@var{symbol}) -@cindex symbol defaults -Returns @code{1} if @var{symbol} is in the linker global symbol table and is -defined, otherwise it returns @code{0}. You can use this to provide default -values for symbols. For example, this command-file fragment shows how -to set a global symbol @code{begin} to the first location in the -@code{.text} section---but if a symbol called @code{begin} already -existed, its value is preserved: -@smallexample -SECTIONS@{ @dots{} - .text: @{ - begin = DEFINED(begin) ? begin : . ; - @dots{} - @} -@dots{} @} -@end smallexample - -@item NEXT(@var{exp}) -@kindex NEXT(@var{exp}) -@cindex unallocated address, next -Returns the next unallocated address that is a multiple of @var{exp}. -This command is closely related to @code{ALIGN(@var{exp})}; unless you -use the @code{MEMORY} command to define discontinuous memory for the -output file, the two commands are equivalent. - -@item SIZEOF(@var{section}) -@kindex SIZEOF(@var{section}) -@cindex section size -returns the size in bytes of the named @var{section}, if the section has -been allocated. In the following example the @code{symbol_1} and -@code{symbol_2} are assigned identical values: -@example -SECTIONS@{ @dots{} - .output @{ - .start = . ; - @dots{} - .end = .; - @} - symbol_1 = .end - .start; - symbol_2 = SIZEOF(.output); -@dots{} @} - -@end example - -@item SIZEOF_HEADERS -@kindex SIZEOF_HEADERS -@cindex header size -@itemx sizeof_headers -@kindex sizeof_headers -the size in bytes of the output file's headers. You can use this number -as the start address of the first section, if you choose, to facilitate -paging. - -@end table - -@node MEMORY, SECTIONS, Expressions, Commands -@section MEMORY Command -@kindex MEMORY -@cindex regions of memory -@cindex discontinuous memory -@cindex allocating memory -The linker's default configuration permits allocation of all memory. -You can override this by using the @code{MEMORY} command. The -@code{MEMORY} command describes the location and size of blocks of -memory in the target. By using it carefully, you can describe which -memory regions may be used by the linker, and which memory regions it -must avoid. The linker does not shuffle sections to fit into the -available regions, but does move the requested sections into the correct -regions and issue errors when the regions become too full. - -Command files may contain at most one use of the @code{MEMORY} -command; however, you can define as many blocks of memory within it as -you wish. The syntax is: - -@example -MEMORY - @{ - @var{name} (@var{attr}): ORIGIN = @var{origin}, LENGTH = @var{len} - @dots{} - @} -@end example -@table @code -@item @var{name} -@cindex naming memory regions -is a name used internally by the linker to refer to the region. Any -symbol name may be used. The region names are stored in a separate -name space, and will not conflict with symbols, filenames or section -names. Use distinct names to specify multiple regions. -@item (@var{attr}) -@cindex memory region attributes -is an optional list of attributes, permitted for compatibility with the -AT&T linker but not used by @code{gld} beyond checking that the -attribute list is valid. Valid attribute lists must be made up of the -characters ``@code{LIRWX}''. If you omit the attribute list, you may -omit the parentheses around it as well. -@item @var{origin} -@kindex ORIGIN= -@kindex o= -@kindex org= -is the start address of the region in physical memory. It is expressed as -an expression, which must evaluate to a constant before -memory allocation is performed. The keyword @code{ORIGIN} may be -abbreviated to @code{org} or @code{o}. -@item @var{len} -@kindex LENGTH= -@kindex len= -@kindex l= -is the size in bytes of the region (an expression). -The keyword @code{LENGTH} may be abbreviated to @code{len} or @code{l}. -@end table - -For example, to specify that memory has two regions available for -allocation---one starting at @code{0} for 256 kilobytes, and the other -starting at @code{0x40000000} for four megabytes: - -@example -MEMORY - @{ - rom : ORIGIN= 0, LENGTH = 256K - ram : org= 0x40000000, l = 4M - @} -@end example - -Once you have defined a region of memory named @var{mem}, you can direct -specific output sections there by using a command ending in -@samp{>@var{mem}} within the @code{SECTIONS} command (@pxref{Section -Options}). If the combined output sections directed to a region are too -big for the region, the linker will issue an error message. - -@node SECTIONS, Entry Point, MEMORY, Commands -@section SECTIONS Command -@kindex SECTIONS -The @code{SECTIONS} command controls exactly where input sections are -placed into output sections, their order and to which output sections -they are allocated. - -You may use at most one @code{SECTIONS} command in a commands file, -but you can have as many statements within it as you wish. Statements -within the @code{SECTIONS} command can do one of three things: -@itemize @bullet -@item -define the entry point; -@item -assign a value to a symbol; -@item -describe the placement of a named output section, and what input -sections make it up. -@end itemize - -The first two possibilities---defining the entry point, and defining -symbols---can also be done outside the @code{SECTIONS} command: -@pxref{Entry Point}, @pxref{Assignment}. They are permitted here as -well for your convenience in reading the script, so that symbols or the -entry point can be defined at meaningful points in your output-file -layout. - -When no @code{SECTIONS} command is specified, the default action -of the linker is to place each input section into an identically named -output section in the order that the sections are first encountered in -the input files; if all input sections are present in the first file, -for example, the order of sections in the output file will match the -order in the first input file. - -@menu -* Section Definition:: Section Definitions -* Section Contents:: Section Contents -* Section Options:: Optional Section Attributes -@end menu - -@node Section Definition, Section Contents, SECTIONS, SECTIONS -@subsection Section Definitions -@cindex section definition -The most frequently used statement in the @code{SECTIONS} command is -the @dfn{section definition}, which you can use to specify the -properties of an output section: its location, alignment, contents, -fill pattern, and target memory region can all be specified. Most of -these specifications are optional; the simplest form of a section -definition is -@example -SECTIONS @{ @dots{} -@var{secname} : @{ - @var{contents} - @} -@dots{} @} -@end example -@cindex naming output sections -@noindent -@var{secname} is the name of the output section, and @var{contents} a -specification of what goes there---for example a list of input files or -sections of input files. As you might assume, the whitespace shown is -optional; you do need the colon @samp{:} and the braces @samp{@{@}}, -however. - -@var{secname} must meet the constraints of your output format. In -formats which only support a limited number of sections, such as -@code{a.out}, the name must be one of the names supported by the format -(@code{a.out}, for example, allows only @code{.text}, @code{.data} or -@code{.bss}). If the output format supports any number of sections, but -with numbers and not names (as is the case for Oasys), the name should be -supplied as a quoted numeric string. A section name may consist of any -sequence characters, but any name which does not conform to the standard -@code{gld} symbol name syntax must be quoted. - -@node Section Contents, Section Options, Section Definition, SECTIONS -@subsection Section Contents -@cindex contents of a section -In a section definition, you can specify the contents of an output section by -listing particular object files; by listing particular input-file -sections; or a combination of the two. You can also place arbitrary -data in the section, and define symbols relative to the beginning of the -section. - -The @var{contents} of a section definition may include any of the -following kinds of statement. You can include as many of these as you -like in a single section definition, separated from one another by -whitespace. - -@table @code -@item @var{filename} -@kindex @var{filename} -@cindex input files, section defn -@cindex files, including in output sections -You may simply name a particular input file to be placed in the current -output section; @emph{all} sections from that file are placed in the -current section definition. To specify a list of particular files by -name: -@example -.data: @{ afile.o bfile.o cfile.o @} -@end example -@noindent -The example also illustrates that multiple statements can be included in -the contents of a section definition, since each filename is a separate -statement. - -If the file name has already been mentioned in another section -definition, with an explicit section name list, then only those sections -which have not yet been allocated are used. - -@item @var{filename}( @var{section} ) -@itemx @var{filename}( @var{section}, @var{section}, @dots{} ) -@itemx @var{filename}( @var{section} @var{section} @dots{} ) -@kindex @var{filename}(@var{section}) -@cindex files and sections, section defn -You can name one or more sections from your input files, for -insertion in the current output section. If you wish to specify a list -of input-file sections inside the parentheses, you may separate the -section names by either commas or whitespace. - -@item * (@var{section}) -@itemx * (@var{section}, @var{section}, @dots{}) -@itemx * (@var{section} @var{section} @dots{} -@cindex input sections to output section -@kindex *(@var{section}) -Instead of explicitly naming particular input files in a link control -script, you can refer to @emph{all} files from the @code{gld} command -line: use @samp{*} instead of a particular filename before the -parenthesized input-file section list. - -For example, to copy sections @code{1} through @code{4} from a Oasys file -into the @code{.text} section of an @code{a.out} file, and sections @code{13} -and @code{14} into the @code{.data} section: -@example -SECTIONS @{ - .text :@{ - *("1" "2" "3" "4") - @} - - .data :@{ - *("13" "14") - @} -@} -@end example - -If you have already explicitly included some files by name, @samp{*} -refers to all @emph{remaining} files---those whose places in the output -file have not yet been defined. - -@item [ @var{section} ] -@itemx [ @var{section}, @var{section}, @dots{} ] -@itemx [ @var{section} @var{section} @dots{} ] -@kindex [ @var{sections} ] -This is an alternate notation to specify named sections from all -unallocated input files; its effect is exactly the same as that of -@samp{* (@var{section}@dots{})} - -@item @var{filename}@code{( COMMON )} -@itemx [ COMMON ] -@kindex [COMMON] -@cindex uninitialized data -@cindex commons in output -Specify where in your output file to place uninitialized data -with this notation. @code{[COMMON]} by itself refers to all -uninitialized data from all input files (so far as it is not yet -allocated); @var{filename}@code{(COMMON)} refers to uninitialized data -from a particular file. Both are special cases of the general -mechanisms for specifying where to place input-file sections: -@code{gld} permits you to refer to uninitialized data as if it -were in an input-file section named @code{COMMON}, regardless of the -input file's format. -@end table - -For example, the following command script arranges the output file into -three consecutive sections, named @code{.text}, @code{.data}, and -@code{.bss}, taking the input for each from the correspondingly named -sections of all the input files: -@example -SECTIONS @{ - .text: @{ *(.text) @} - .data: @{ *(.data) @} - .bss: @{ *(.bss) [COMMON] @} -@} -@end example - -The following example reads all of the sections from file @code{all.o} -and places them at the start of output section @code{outputa} which -starts at location @code{0x10000}. All of section @code{.input1} from -file @code{foo.o} follows immediately, in the same output section. All -of section @code{.input2} from @code{foo.o} goes into output section -@code{outputb}, followed by section @code{.input1} from @code{foo1.o}. -All of the remaining @code{.input1} and @code{.input2} sections from any -files are written to output section @code{outputc}. - -@example -SECTIONS @{ - outputa 0x10000 : - @{ - all.o - foo.o (.input1) - @} - outputb : - @{ - foo.o (.input2) - foo1.o (.input1) - @} - outputc : - @{ - *(.input1) - *(.input2) - @} -@} -@end example - -There are still more kinds of statements permitted in the contents of -output section definitions. The foregoing statements permitted you to -arrange, in your output file, data originating from your input files. -You can also place data directly in an output section from the link -command script. Most of these additional statements involve -expressions; @pxref{Expressions}. Although these statements are shown -separately here for ease of presentation, no such segregation is needed -within a section definition in the @code{SECTIONS} command; you can -intermix them freely with any of the statements we've just described. - -@table @code -@item CREATE_OBJECT_SYMBOLS -@kindex CREATE_OBJECT_SYMBOLS -@cindex input filename symbols -@cindex filename symbols -instructs the linker to create a symbol for each input file -in the current section, set with the address of the first byte of -data written from the input file. For instance, with @code{a.out} -files it is conventional to have a symbol for each input file. You can -accomplish this by defining the output @code{.text} section as follows: -@example -SECTIONS @{ - .text 0x2020 : - @{ - CREATE_OBJECT_SYMBOLS - *(.text) - _etext = ALIGN(0x2000); - @} - @dots{} -@} -@end example - -If @code{objsym} is a file containing this script, and @code{a.o}, -@code{b.o}, @code{c.o}, and @code{d.o} are four input files with -contents like the following--- -@example -/* a.c */ - -afunction() @{ @} -int adata=1; -int abss; -@end example - -@noindent -@samp{gld -M sample a.o b.o c.o d.o} would create a map like this, -containing symbols matching the object file names: -@example -00000000 A __DYNAMIC -00004020 B _abss -00004000 D _adata -00002020 T _afunction -00004024 B _bbss -00004008 D _bdata -00002038 T _bfunction -00004028 B _cbss -00004010 D _cdata -00002050 T _cfunction -0000402c B _dbss -00004018 D _ddata -00002068 T _dfunction -00004020 D _edata -00004030 B _end -00004000 T _etext -00002020 t a.o -00002038 t b.o -00002050 t c.o -00002068 t d.o -@end example - -@item @var{symbol} = @var{expression} ; -@kindex @var{symbol} = @var{expression} ; -@itemx @var{symbol} @var{f}= @var{expression} ; -@kindex @var{symbol} @var{f}= @var{expression} ; -@var{symbol} is any symbol name (@pxref{Symbols}). ``@var{f}='' -refers to any of the operators @code{&= += -= *= /=} which combine -arithmetic and assignment. - -@cindex assignment, in section defn -When you assign a value to a symbol within a particular section -definition, the value is relative to the beginning of the section -(@pxref{Assignment}). If you write -@example -SECTIONS @{ - abs = 14 ; - @dots{} - .data: @{ @dots{} rel = 14 ; @dots{} @} - abs2 = 14 + ADDR(.data); - @dots{} -@} -@end example -@c FIXME: Try above example! -@noindent -@code{abs} and @var{rel} do not have the same value; @code{rel} has the -same value as @code{abs2}. - -@item BYTE(@var{expression}) -@kindex BYTE(@var{expression}) -@itemx SHORT(@var{expression}) -@kindex SHORT(@var{expression}) -@itemx LONG(@var{expression}) -@kindex LONG(@var{expression}) -@cindex direct output -By including one of these three statements in a section definition, you -can explicitly place one, two, or four bytes (respectively) at the -current address of that section. Multiple-byte quantities are -represented in whatever byte order is appropriate for the output file -format (@pxref{BFD}). - -@item FILL(@var{expression}) -@kindex FILL(@var{expression}) -@cindex holes, filling -@cindex unspecified memory -Specifies the ``fill pattern'' for the current section. Any otherwise -unspecified regions of memory within the section (for example, regions -you skip over by assigning a new value to the location counter @samp{.}) -are filled with the two least significant bytes from the -@var{expression} argument. A @code{FILL} statement covers memory -locations @emph{after} the point it occurs in the section definition; by -including more than one @code{FILL} statement, you can have different -fill patterns in different parts of an output section. -@end table - -@node Section Options, , Section Contents, SECTIONS -@subsection Optional Section Attributes -@cindex section defn, full syntax -Here is the full syntax of a section definition, including all the -optional portions: - -@example -SECTIONS @{ -@dots{} -@var{secname} @var{start} BLOCK(@var{align}) : @{ @var{contents} @} =@var{fill} >@var{region} -@dots{} -@} -@end example - -@var{secname} and @var{contents} are required. @xref{Section -Definition}, and @pxref{Section Contents} for details on @var{contents}. -The remaining elements---@var{start}, @code{BLOCK(@var{align)}}, -@code{=@var{fill}}, and @code{>@var{region}}---are all optional. - -@table @code -@item @var{start} -@cindex start address, section -@cindex section start -@cindex section address -You can force the output section to be loaded at a specified address by -specifying @var{start} immediately following the section name. -@var{start} can be represented as any expression. The following -example generates section @var{output} at location -@code{0x40000000}: -@example -SECTIONS @{ - @dots{} - output 0x40000000: @{ - @dots{} - @} - @dots{} -@} -@end example - -@item BLOCK(@var{align}) -@kindex BLOCK(@var{align}) -@cindex section alignment -@cindex aligning sections -You can include @code{BLOCK()} specification to advance the location of -the location counter @code{.} prior to the beginning of the section, so -that the section will begin at the specified alignment. @var{align} is -an expression. - -@item =@var{fill} -@kindex =@var{fill} -@cindex section fill pattern -@cindex fill pattern, entire section -You may use any expression to specify @var{fill}. Including -@code{=@var{fill}} in a section definition specifies the initial fill -value for that section. Any unallocated holes in the current output -section when written to the output file will be filled with the two -least significant bytes of the value, repeated as necessary. You can -also change the fill value with a @code{FILL} statement in the -@var{contents} of a section definition. - -@item >@var{region} -@kindex >@var{region} -@cindex section, assigning to memory region -@cindex memory regions and sections -Assign this section to a previously defined region of memory. -@xref{MEMORY}. - -@end table - -@node Entry Point, Other Commands, SECTIONS, Commands -@section The Entry Point -@kindex ENTRY(@var{symbol}) -@cindex start of execution -@cindex first instruction -The linker command language includes a command specifically for -defining the first executable instruction in an output file (its -@dfn{entry point}). Its argument is a symbol name: -@example -ENTRY(@var{symbol}) -@end example - -Like symbol assignments, the @code{ENTRY} command may be placed either -as an independent command in the command file, or among the section -definitions within the @code{SECTIONS} command---whatever makes the most -sense for your layout. - -@cindex entry point, defaults -@code{ENTRY} is only one of several ways of choosing the entry point. -You may indicate it in any of the following ways (shown in descending -order of priority: methods higher in the list override methods lower down). -@itemize @bullet -@item -the @code{-e} @var{entry} command-line option; -@item -the @code{ENTRY(@var{symbol}} command in a linker control script; -@item -the value of the symbol @code{start}, if present; -@item -the value of the symbol @code{_main}, if present; -@item -the address of the first byte of the @code{.text} section, if present; -@item -The address @code{0}. -@end itemize - -For example, you can use these rules to generate an entry point with an -assignment statement: if no symbol @code{start} is defined within your -input files, you can simply define it, assigning it an appropriate -value--- -@example -start = 0x2020; -@end example - -@noindent -The example shows an absolute address, but you can use any expression. -For example, if your input object files use some other symbol-name -convention for the entry point, you can just assign the value of -whatever symbol contains the start address to @code{start}: -@example -start = other_symbol; -@end example - -@node Other Commands, , Entry Point, Commands -@section Other Commands -The command language includes a number of other commands that you can -use for specialized purposes. They are similar in purpose to -command-line options. - -@table @code -@item FLOAT -@kindex FLOAT -@itemx NOFLOAT -@kindex NOFLOAT -These keywords were used in some older linkers to request a particular -math subroutine library. @code{gld} doesn't use the keywords, assuming -instead that any necessary subroutines are in libraries specified using -the general mechanisms for linking to archives; but to permit the use of -scripts that were written for the older linkers, the keywords -@code{FLOAT} and @code{NOFLOAT} are accepted and ignored. - -@item FORCE_COMMON_ALLOCATION -@kindex FORCE_COMMON_ALLOCATION -@cindex common allocation -This command has the same effect as the @code{-d} command-line option: -to make @code{ld} assign space to common symbols even if a relocatable -output file is specified (@code{-r}). - -@item HLL ( @var{file}, @var{file}, @dots{} ) -@kindex HLL ( @var{files} ) -@itemx HLL ( @var{file} @var{file} @dots{} ) -@itemx HLL ( ) -Include ``high-level libraries'' or archives as input files in the link. -Using @code{HLL(@var{file}} in a linker script is equivalent to -including @code{-l}@var{file} on the command line. - -@cindex @code{lnk960} command @code{HLL} -The @code{HLL} command is only supported when @code{gld} emulates -@code{lnk960}, as specified by the @code{LDEMULATION} environment -variable. - -@item INPUT ( @var{file}, @var{file}, @dots{} ) -@kindex INPUT ( @var{files} ) -@itemx INPUT ( @var{file} @var{file} @dots{} ) -@cindex binary input files -Use this command to include binary input files in the link, without -including them in a particular section definition. Files specified this -way are treated identically to object files listed on the command line. - -@ignore -@item MAP ( @var{name} ) -@kindex MAP ( @var{name} ) -@c MAP(...) appears to look for an F in the arg, ignoring all other -@c chars; if it finds one, it sets "map_option_f" to true. But nothing -@c checks map_option_f. Apparently a stub for the future... -@end ignore - -@item OUTPUT ( @var{filename} ) -@kindex OUTPUT ( @var{filename} ) -@cindex naming the output file -Name the link output file @var{filename}. The effect of -@code{OUTPUT(@var{filename})} is identical to the effect of -@w{@code{-o @var{filename}}}, and whichever is encountered last will -control the name actually used to name the output file. In particular, -you can use this command to supply a default output-file name other than -@code{a.out}. - -@item OUTPUT_ARCH ( @var{bfdname} ) -@kindex OUTPUT_ARCH ( @var{bfdname} ) -@cindex machine architecture, output -Specify a particular output machine architecture, with one of the names -used by the BFD back-end routines (@pxref{BFD}). This command is often -unnecessary; the architecture is most often set implicitly by either the -system BFD configuration or as a side effect of the @code{OUTPUT_FORMAT} -command. @refill - -@item OUTPUT_FORMAT ( @var{bfdname} ) -@kindex OUTPUT_FORMAT ( @var{bfdname} ) -@cindex format, output file -Specify a particular output format, with one of the names used by the -BFD back-end routines (@pxref{BFD}). This selection will only affect -the output file; the related command @code{TARGET} affects primarily -input files.@refill - -@item SEARCH_DIR ( @var{path} ) -@kindex SEARCH_DIR ( @var{path} ) -@cindex path for libraries -@cindex search path, libraries -Add @var{path} to the list of paths where @code{gld} looks for -archive libraries. @code{SEARCH_DIR(@var{path})} has the same -effect as @code{-L@var{path})} on the command line. - -@item STARTUP ( @var{filename} ) -@kindex STARTUP ( @var{filename} ) -@cindex first input file -Ensure that @var{filename} is the first input file used in the link -process. - -@item SYSLIB ( @var{file}, @var{file}, @dots{} ) -@kindex SYSLIB ( @var{file}, @var{file}, @dots{} ) -@itemx SYSLIB ( @var{file} @var{file} @dots{} ) -Use the named @var{file}s as binary input files, searching for them in -the same list of paths as archives. - -@cindex @code{lnk960} command @code{SYSLIB} -The @code{SYSLIB} command is only supported when @code{gld} emulates -@code{lnk960}, as specified by the @code{LDEMULATION} environment -variable. - -@item TARGET ( @var{format} ) -@cindex input file format -@kindex TARGET ( @var{format} ) -Change the input-file object code format (like the command-line option -@code{-b} or its synonym @code{-format}). The argument @var{format} is -one of the strings used by BFD to name binary formats. In the current -@code{gld} implementation, if @code{TARGET} is specified but -@code{OUTPUT_FORMAT} is not, the last @code{TARGET} argument is also -used as the default format for the @code{gld} output file. -@xref{BFD}.@refill - -@kindex GNUTARGET -If you don't use the @code{TARGET} command, @code{gld} uses the value of -the environment variable @code{GNUTARGET}, if available, to select the -output file format. If that variable is also absent, @code{gld} uses -the default format configured for your machine in the BFD libraries. - -@end table - -@node BFD, Index, Commands, Top -@chapter BFD - -@cindex back end -@cindex object file management -The linker accesses object and archive files using the BFD libraries. -These libraries allow the linker to use the same routines to operate on -object files whatever the object file format. A different object file -format can be supported simply by creating a new BFD back end and adding -it to the library. BFD supports the following combinations of -architectures (row labels below) and object formats (column headings): -@cindex formats available -@cindex architectures available -@c TEXI2ROFF-KILL -@ifinfo -@c END TEXI2ROFF-KILL -@example - |ieee - | |oasys - | | |a.out-generic-little - | | | |a.out-generic-big - | | | | |m88kbcs - | | | | | |srec - | | | | | | |coff-Intel-little - | | | | | | | |coff-Intel-big - | | | | | | | | |b.out.little - | | | | | | | | | |b.out.big - | | | | | | | | | | - m68k|**|**| | | |**| | | | - vax|**|**| | | |**| | | | - i960|**|**| | | |**|**|**|**|** - a29k|**|**|**|**| |**| | | | - sparc|**|**|**|**| |**| | | | - mips|**|**| | | |**| | | | - i386|**|**|**|**| |**| | | | - ns32k|**|**| | | |**| | | | - tahoe|**|**| | | |**| | | | - i860|**|**| | | |**| | | | - romp|**|**| | | |**| | | | - alliant|**|**| | | |**| | | | - convex|**|**| | | |**| | | | - m88k|**|**| | |**|**| | | | - pyramid|**|**| | | |**| | | | - H8/300|**|**| | | |**| | | | - -@end example -@c TEXI2ROFF-KILL -@end ifinfo -@tex -\def\sqbull{\vrule height12pt width 10pt depth 4pt} -\vskip\baselineskip -\vbox{\offinterlineskip -\halign -{\strut\hfil #\ &\vrule#&\hskip .5em #\hskip .5em &\vrule#&\hskip .5em #\hskip .5em -&\vrule#&\hskip .5em #\hskip .5em &\vrule#&\hskip .5em #\hskip .5em &\vrule#&\hskip .5em #\hskip .5em &\vrule#&\hskip .5em #\hskip .5em &\vrule#&\hskip .5em #\hskip .5em &\vrule#&\hskip .5em #\hskip .5em &\vrule#&\hskip .5em #\hskip .5em &\vrule#&\hskip .5em #\hskip .5em &\vrule#\cr - &&\multispan{20}\quad\vbox{\hrule}\cr - &&\multispan{20}\quad\code{ieee}\hfil\cr - && &&\multispan{18}\quad\code{oasys}\hfil\cr - && && &&\multispan{16}\quad\code{a.out-generic-little}\hfil\cr - && && && &&\multispan{14}\quad\code{a.out-generic-big}\hfil\cr - && && && && &&\multispan{12}\quad\code{m88kbcs}\hfil\cr - && && && && && &&\multispan{10}\quad\code{srec}\hfil\cr - && && && && && && &&\multispan8\quad\code{coff-Intel-little}\hfil\cr - && && && && && && && &&\multispan6\quad\code{coff-Intel-big}\hfil\cr - && && && && && && && && -&&\multispan4\quad\code{b.out.little}\hfil \cr - && && && && && && && && && &&\multispan2\quad\code{b.out.big}\hidewidth\cr - \code{m68k}&&\sqbull&&\sqbull&& && && &&\sqbull&& && && && &\cr - \code{vax}&&\sqbull&&\sqbull&& && && &&\sqbull&& && && && &\cr - \code{i960}&&\sqbull&&\sqbull&& && && &&\sqbull&&\sqbull&&\sqbull&&\sqbull&&\sqbull &\cr - \code{a29k}&&\sqbull&&\sqbull&&\sqbull&&\sqbull&& &&\sqbull&& && && && &\cr - \code{sparc}&&\sqbull&&\sqbull&&\sqbull&&\sqbull&& &&\sqbull&& && && && &\cr - \code{mips}&&\sqbull&&\sqbull&& && && &&\sqbull&& && && && &\cr - \code{i386}&&\sqbull&&\sqbull&&\sqbull&&\sqbull&& &&\sqbull&& && && && &\cr - \code{ns32k}&&\sqbull&&\sqbull&& && && &&\sqbull&& && && && &\cr - \code{tahoe}&&\sqbull&&\sqbull&& && && &&\sqbull&& && && && &\cr - \code{i860}&&\sqbull&&\sqbull&& && && &&\sqbull&& && && && &\cr - \code{romp}&&\sqbull&&\sqbull&& && && &&\sqbull&& && && && &\cr - \code{alliant}&&\sqbull&&\sqbull&& && && &&\sqbull&& && && && &\cr - \code{convex}&&\sqbull&&\sqbull&& && && &&\sqbull&& && && && &\cr - \code{m88k}&&\sqbull&&\sqbull&& && &&\sqbull&&\sqbull&& && && && &\cr - \code{pyramid}&&\sqbull&&\sqbull&& && && &&\sqbull&& && && && &\cr - \code{H8/300}&&\sqbull&&\sqbull&& && && &&\sqbull&& && && && &\cr -}} -@end tex -@c END TEXI2ROFF-KILL - -@cindex BFD requirements -@cindex requirements for BFD -As with most implementations, BFD is a compromise between -several conflicting requirements. The major factor influencing -BFD design was efficiency: any time used converting between -formats is time which would not have been spent had BFD not -been involved. This is partly offset by abstraction payback; since -BFD simplifies applications and back ends, more time and care -may be spent optimizing algorithms for a greater speed. - -One minor artifact of the BFD solution which you should bear in -mind is the potential for information loss. There are two places where -useful information can be lost using the BFD mechanism; during -conversion and during output. @xref{BFD information loss}. - -@menu -* BFD outline:: How it works: an outline of BFD -* BFD information loss:: Information Loss -* Mechanism:: Mechanism -@end menu - -@node BFD outline, BFD information loss, BFD, BFD -@section How it works: an outline of BFD -@cindex opening object files -When an object file is opened, BFD subroutines automatically -determine the format of the input object file, and build a descriptor in -memory with pointers to routines that will be used to access elements of -the object file's data structures. - -As different information from the the object files is required -BFD reads from different sections of the file and processes them. -For example a very common operation for the linker is processing symbol -tables. Each BFD back end provides a routine for converting -between the object file's representation of symbols and an internal -canonical format. When the linker asks for the symbol table of an object -file, it calls through the memory pointer to the relevant BFD -back end routine which reads and converts the table into a canonical -form. The linker then operates upon the common form. When the link is -finished and the linker writes the symbol table of the output file, -another BFD back end routine is called which takes the newly -created symbol table and converts it into the chosen output format. - -@node BFD information loss, Mechanism, BFD outline, BFD -@section Information Loss -@emph{Information can be lost during output.} The output formats -supported by BFD do not provide identical facilities, and -information which may be described in one form has nowhere to go in -another format. One example of this is alignment information in -@code{b.out}. There is nowhere in an @code{a.out} format file to store -alignment information on the contained data, so when a file is linked -from @code{b.out} and an @code{a.out} image is produced, alignment -information will not propagate to the output file. (The linker will -still use the alignment information internally, so the link is performed -correctly). - -Another example is COFF section names. COFF files may contain an -unlimited number of sections, each one with a textual section name. If -the target of the link is a format which does not have many sections (eg -@code{a.out}) or has sections without names (eg the Oasys format) the -link cannot be done simply. You can circumvent this problem by -describing the desired input-to-output section mapping with the command -language. - -@emph{Information can be lost during canonicalization.} The BFD -internal canonical form of the external formats is not exhaustive; there -are structures in input formats for which there is no direct -representation internally. This means that the BFD back ends -cannot maintain all possible data richness through the transformation -between external to internal and back to external formats. - -This limitation is only a problem when using the linker to read one -format and write another. Each BFD back end is responsible for -maintaining as much data as possible, and the internal BFD -canonical form has structures which are opaque to the BFD core, -and exported only to the back ends. When a file is read in one format, -the canonical form is generated for BFD and the linker. At the -same time, the back end saves away any information which may otherwise -be lost. If the data is then written back in the same format, the back -end routine will be able to use the canonical form provided by the -BFD core as well as the information it prepared earlier. Since -there is a great deal of commonality between back ends, this mechanism -is very useful. There is no information lost for this reason when -linking big endian COFF to little endian COFF, or from @code{a.out} to -@code{b.out}. When a mixture of formats is linked, the information is -only lost from the files whose format differs from the destination. - -@node Mechanism, , BFD information loss, BFD -@section Mechanism -The greatest potential for loss of information is when there is least -overlap between the information provided by the source format, that -stored by the canonical format, and the information needed by the -destination format. A brief description of the canonical form may help -you appreciate what kinds of data you can count on preserving across -conversions. -@cindex BFD canonical format -@cindex internal object-file format - -@table @emph -@item files -Information on target machine architecture, particular implementation -and format type are stored on a per-file basis. Other information -includes a demand pageable bit and a write protected bit. Note that -information like Unix magic numbers is not stored here---only the magic -numbers' meaning, so a @code{ZMAGIC} file would have both the demand pageable -bit and the write protected text bit set. - -The byte order of the target is stored on a per-file basis, so that big- -and little-endian object files may be linked with one another. - -@item sections -Each section in the input file contains the name of the section, the -original address in the object file, various flags, size and alignment -information and pointers into other BFD data structures. - -@item symbols -Each symbol contains a pointer to the object file which originally -defined it, its name, its value, and various flag bits. When a -BFD back end reads in a symbol table, the back end relocates all -symbols to make them relative to the base of the section where they were -defined. This ensures that each symbol points to its containing -section. Each symbol also has a varying amount of hidden data to contain -private data for the BFD back end. Since the symbol points to the -original file, the private data format for that symbol is accessible. -@code{gld} can operate on a collection of symbols of wildly different -formats without problems. - -Normal global and simple local symbols are maintained on output, so an -output file (no matter its format) will retain symbols pointing to -functions and to global, static, and common variables. Some symbol -information is not worth retaining; in @code{a.out} type information is -stored in the symbol table as long symbol names. This information would -be useless to most COFF debuggers and may be thrown away with -appropriate command line switches. (The GNU debugger @code{gdb} does -support @code{a.out} style debugging information in COFF). - -There is one word of type information within the symbol, so if the -format supports symbol type information within symbols (for example COFF, -IEEE, Oasys) and the type is simple enough to fit within one word -(nearly everything but aggregates) the information will be preserved. - -@item relocation level -Each canonical BFD relocation record contains a pointer to the symbol to -relocate to, the offset of the data to relocate, the section the data -is in and a pointer to a relocation type descriptor. Relocation is -performed effectively by message passing through the relocation type -descriptor and symbol pointer. It allows relocations to be performed -on output data using a relocation method only available in one of the -input formats. For instance, Oasys provides a byte relocation format. -A relocation record requesting this relocation type would point -indirectly to a routine to perform this, so the relocation may be -performed on a byte being written to a COFF file, even though 68k COFF -has no such relocation type. - -@item line numbers -Object formats can contain, for debugging purposes, some form of mapping -between symbols, source line numbers, and addresses in the output file. -These addresses have to be relocated along with the symbol information. -Each symbol with an associated list of line number records points to the -first record of the list. The head of a line number list consists of a -pointer to the symbol, which allows divination of the address of the -function whose line number is being described. The rest of the list is -made up of pairs: offsets into the section and line numbers. Any format -which can simply derive this information can pass it successfully -between formats (COFF, IEEE and Oasys). -@end table - -@node Index, , BFD, Top -@unnumbered Index - -@printindex cp - -@tex -% I think something like @colophon should be in texinfo. In the -% meantime: -\long\def\colophon{\hbox to0pt{}\vfill -\centerline{The body of this manual is set in} -\centerline{\fontname\tenrm,} -\centerline{with headings in {\bf\fontname\tenbf}} -\centerline{and examples in {\tt\fontname\tentt}.} -\centerline{{\it\fontname\tenit\/} and} -\centerline{{\sl\fontname\tensl\/}} -\centerline{are used for emphasis.}\vfill} -\page\colophon -% Blame: pesch@cygnus.com, 28mar91. -@end tex - - -@contents -@bye - - diff --git a/ld/ldemul.c b/ld/ldemul.c deleted file mode 100644 index eafe26c54c8..00000000000 --- a/ld/ldemul.c +++ /dev/null @@ -1,147 +0,0 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. - -This file is part of GLD, the Gnu Linker. - -GLD 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 1, or (at your option) -any later version. - -GLD 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 GLD; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - * $Id$ - */ - -/* - * clearing house for ld emulation states - */ - -#include "bfd.h" -#include "sysdep.h" - -#include "config.h" -#include "ld.h" -#include "ldemul.h" -#include "ldmisc.h" - -extern ld_emulation_xfer_type ld_lnk960_emulation; -extern ld_emulation_xfer_type ld_gldm88kbcs_emulation; -extern ld_emulation_xfer_type ld_gld_emulation; -extern ld_emulation_xfer_type ld_vanilla_emulation; -extern ld_emulation_xfer_type ld_gld68k_emulation; -extern ld_emulation_xfer_type ld_gld960_emulation; -extern ld_emulation_xfer_type ld_gld29k_emulation; -extern ld_emulation_xfer_type ld_gldnews_emulation; -extern ld_emulation_xfer_type ld_h8300hds_emulation; - - -ld_emulation_xfer_type *ld_emulation; - -void -ldemul_hll(name) -char *name; -{ - ld_emulation->hll(name); -} - - -void ldemul_syslib(name) -char *name; -{ - ld_emulation->syslib(name); -} - -void -ldemul_after_parse() -{ - ld_emulation->after_parse(); -} - -void -ldemul_before_parse() -{ - ld_emulation->before_parse(); -} - -void -ldemul_after_allocation() -{ - ld_emulation->after_allocation(); -} - -void -ldemul_before_allocation() -{ - if (ld_emulation->before_allocation) { - ld_emulation->before_allocation(); - } -} - - -void -ldemul_set_output_arch() -{ - ld_emulation->set_output_arch(); -} - -char * -ldemul_choose_target() -{ - return ld_emulation->choose_target(); -} - -char * -ldemul_get_script() -{ - return ld_emulation->get_script(); -} - -void -ldemul_choose_mode(target) -char *target; -{ - if (strcmp(target,LNK960_EMULATION_NAME)==0) { - ld_emulation = &ld_lnk960_emulation; - } - else if (strcmp(target,GLD960_EMULATION_NAME)==0) { - ld_emulation = &ld_gld960_emulation; - } - else if (strcmp(target,GLDM88KBCS_EMULATION_NAME)==0) { - ld_emulation = &ld_gldm88kbcs_emulation; - } -#ifndef GNU960 - else if (strcmp(target,GLD_EMULATION_NAME)==0) { - ld_emulation = &ld_gld_emulation; - } - else if (strcmp(target,VANILLA_EMULATION_NAME)==0) { - ld_emulation = &ld_vanilla_emulation; - } - else if (strcmp(target,H8300HDS_EMULATION_NAME)==0) { - ld_emulation = &ld_h8300hds_emulation; - } - - else if (strcmp(target,GLD68K_EMULATION_NAME)==0) { - ld_emulation = &ld_gld68k_emulation; - } - else if (strcmp(target,GLD29K_EMULATION_NAME)==0) { - ld_emulation = &ld_gld29k_emulation; - } - else if (strcmp(target,GLDNEWS_EMULATION_NAME)==0) { - ld_emulation = &ld_gldnews_emulation; - } -#endif - else { - info("%P%F unrecognised emulation mode: %s\n",target); - } -} - - - diff --git a/ld/ldexp.c b/ld/ldexp.c deleted file mode 100644 index c91af29aaff..00000000000 --- a/ld/ldexp.c +++ /dev/null @@ -1,786 +0,0 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. - -This file is part of GLD, the Gnu Linker. - -GLD 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 1, or (at your option) -any later version. - -GLD 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 GLD; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - $Id$ -*/ - -/* - * Written by Steve Chamberlain - * steve@cygnus.com - * - * This module handles expression trees. - */ - - -#include "sysdep.h" -#include "bfd.h" - -#include "ld.h" -#include "ldmain.h" -#include "ldmisc.h" -#include "ldexp.h" -#include "ldgram.tab.h" -#include "ldsym.h" -#include "ldlang.h" - -extern char *output_filename; -extern unsigned int undefined_global_sym_count; -extern unsigned int defined_global_sym_count; -extern bfd *output_bfd; -extern size_t largest_section; -extern lang_statement_list_type file_chain; -extern args_type command_line; -extern ld_config_type config; - -extern lang_input_statement_type *script_file; -extern unsigned int defined_global_sym_count; - -extern bfd_vma print_dot; - - -static void -exp_print_token(outfile, code) -FILE *outfile; -token_code_type code; -{ - static struct { - token_code_type code; - char *name; - } table[] = - { - INT, "int", - NAME,"NAME", - PLUSEQ,"+=", - MINUSEQ,"-=", - MULTEQ,"*=", - DIVEQ,"/=", - LSHIFTEQ,"<<=", - RSHIFTEQ,">>=", - ANDEQ,"&=", - OREQ,"|=", - OROR,"||", - ANDAND,"&&", - EQ,"==", - NE,"!=", - LE,"<=", - GE,">=", - LSHIFT,"<<", - RSHIFT,">>=", - ALIGN_K,"ALIGN", - BLOCK,"BLOCK", - SECTIONS,"SECTIONS", - SIZEOF_HEADERS,"SIZEOF_HEADERS", - NEXT,"NEXT", - SIZEOF,"SIZEOF", - ADDR,"ADDR", - MEMORY,"MEMORY", - - - - - - DEFINED,"DEFINED", - TARGET_K,"TARGET", - SEARCH_DIR,"SEARCH_DIR", - MAP,"MAP", - LONG,"LONG", - SHORT,"SHORT", - BYTE,"BYTE", - ENTRY,"ENTRY", - 0,(char *)NULL} ; - - - - unsigned int idx; - for (idx = 0; table[idx].name != (char*)NULL; idx++) { - if (table[idx].code == code) { - fprintf(outfile, "%s", table[idx].name); - return; - } - } - /* Not in table, just print it alone */ - fprintf(outfile, "%c",code); -} - -static void -make_abs(ptr) -etree_value_type *ptr; -{ - if (ptr->section != (lang_output_section_statement_type *)NULL) { - asection *s = ptr->section->bfd_section; - ptr->value += s->vma; - ptr->section = (lang_output_section_statement_type *)NULL; - } - -} -static -etree_value_type new_abs(value) -bfd_vma value; -{ - etree_value_type new; - new.valid = true; - new.section = (lang_output_section_statement_type *)NULL; - new.value = value; - return new; -} - -static void -DEFUN(check, (os, name, op), - lang_output_section_statement_type *os AND - CONST char *name AND - CONST char *op) -{ - if (os == (lang_output_section_statement_type *)NULL) { - info("%F%P %s uses undefined section %s\n", op, name); - } - if (os->processed == false) { - info("%F%P %s forward reference of section %s\n",op, name); - } -} - -etree_type *exp_intop(value) -bfd_vma value; -{ - etree_type *new = (etree_type *)ldmalloc(sizeof(new->value)); - new->type.node_code = INT; - new->value.value = value; - new->type.node_class = etree_value; - return new; - -} - - -static -etree_value_type new_rel(value, section) -bfd_vma value; -lang_output_section_statement_type *section; -{ - etree_value_type new; - new.valid = true; - new.value = value; - new.section = section; - return new; -} - -static -etree_value_type new_rel_from_section(value, section) -bfd_vma value; -lang_output_section_statement_type *section; -{ - etree_value_type new; - new.valid = true; - new.value = value; - new.section = section; - if (new.section != (lang_output_section_statement_type *)NULL) { - new.value -= section->bfd_section->vma; - } - return new; -} - -static etree_value_type -fold_binary(tree, current_section, allocation_done, dot, dotp) -etree_type *tree; -lang_output_section_statement_type *current_section; -lang_phase_type allocation_done; -bfd_vma dot; -bfd_vma *dotp; -{ - etree_value_type result; - - result = exp_fold_tree(tree->binary.lhs, current_section, - allocation_done, dot, dotp); - if (result.valid) { - etree_value_type other; - other = exp_fold_tree(tree->binary.rhs, - current_section, - allocation_done, dot,dotp) ; - if (other.valid) { - /* If values are from different sections, or this is an */ - /* absolute expression, make both source args absolute */ - if (result.section != other.section || - current_section == (lang_output_section_statement_type *)NULL) { - - make_abs(&result); - make_abs(&other); - } - - switch (tree->type.node_code) - { - case '%': - /* Mod, both absolule*/ - - if (other.value == 0) { - info("%F%S % by zero\n"); - } - result.value %= other.value; - break; - case '/': - if (other.value == 0) { - info("%F%S / by zero\n"); - } - result.value /= other.value; - break; -#define BOP(x,y) case x : result.value = result.value y other.value;break; - BOP('+',+); - BOP('*',*); - BOP('-',-); - BOP(LSHIFT,<<); - BOP(RSHIFT,>>); - BOP(EQ,==); - BOP(NE,!=); - BOP('<',<); - BOP('>',>); - BOP(LE,<=); - BOP(GE,>=); - BOP('&',&); - BOP('^',^); - BOP('|',|); - BOP(ANDAND,&&); - BOP(OROR,||); - default: - FAIL(); - } - } - else { - result.valid = false; - } - } - return result; -} -etree_value_type invalid() -{ - etree_value_type new; - new.valid = false; - return new; -} - -etree_value_type fold_name(tree, current_section, allocation_done, dot) -etree_type *tree; -lang_output_section_statement_type *current_section; -lang_phase_type allocation_done; -bfd_vma dot; - -{ - etree_value_type result; - switch (tree->type.node_code) - { - case SIZEOF_HEADERS: - if (allocation_done != lang_first_phase_enum) - { - result = new_abs(bfd_sizeof_headers(output_bfd, - config.relocateable_output)); - - } - else { - result.valid = false; - } - break; - case DEFINED: - result.value = - ldsym_get_soft(tree->name.name) != (ldsym_type *)NULL; - result.section = 0; - result.valid = true; - break; - case NAME: - result.valid = false; - if (tree->name.name[0] == '.' && tree->name.name[1] == 0) { - - if (allocation_done != lang_first_phase_enum) { - result = new_rel_from_section(dot, current_section); - } - else { - result = invalid(); - } - } - else { - if (allocation_done == lang_final_phase_enum) { - ldsym_type *sy = ldsym_get_soft(tree->name.name); - - if (sy) { - asymbol **sdefp = sy->sdefs_chain; - - if (sdefp) { - asymbol *sdef = *sdefp; - if (sdef->section == (asection *)NULL) { - /* This is an absolute symbol */ - result = new_abs(sdef->value); - } - else { - lang_output_section_statement_type *os = - lang_output_section_statement_lookup( - sdef->section->output_section->name); - /* If the symbol is from a file which we are not - relocating (-R) then return an absolute for its - value */ - if (sdef->the_bfd->usrdata && - ((lang_input_statement_type*)(sdef->the_bfd->usrdata))->just_syms_flag == true) - { - result = new_abs(sdef->value + (sdef->section ? - sdef->section->vma : 0)); - } - else { - result = new_rel(sdef->value + sdef->section->output_offset, os); - } - } - } - } - if (result.valid == false) { - info("%F%S: undefined symbol `%s' referenced in expression.\n", - tree->name.name); - } - - } - } - - break; - - case ADDR: - - if (allocation_done != lang_first_phase_enum) { - lang_output_section_statement_type *os = - lang_output_section_find(tree->name.name); - check(os,tree->name.name,"ADDR"); - result = new_rel((bfd_vma)0, os); - } - else { - result = invalid(); - } - break; - case SIZEOF: - if(allocation_done != lang_first_phase_enum) { - lang_output_section_statement_type *os = - lang_output_section_find(tree->name.name); - check(os,tree->name.name,"SIZEOF"); - result = new_abs((bfd_vma)(os->bfd_section->size)); - } - else { - result = invalid(); - } - break; - - default: - FAIL(); - break; - } - - return result; -} -etree_value_type exp_fold_tree(tree, current_section, allocation_done, - dot, dotp) -etree_type *tree; -lang_output_section_statement_type *current_section; -lang_phase_type allocation_done; -bfd_vma dot; -bfd_vma *dotp; -{ - etree_value_type result; - - if (tree == (etree_type *)NULL) { - result.valid = false; - } - else { - switch (tree->type.node_class) - { - case etree_value: - result = new_rel(tree->value.value, current_section); - break; - case etree_unary: - result = exp_fold_tree(tree->unary.child, - current_section, - allocation_done, dot, dotp); - if (result.valid == true) - { - switch(tree->type.node_code) - { - case ALIGN_K: - if (allocation_done != lang_first_phase_enum) { - result = new_rel_from_section(ALIGN(dot, - result.value) , - current_section); - - } - else { - result.valid = false; - } - break; - case '~': - make_abs(&result); - result.value = ~result.value; - break; - case '!': - make_abs(&result); - result.value = !result.value; - break; - case '-': - make_abs(&result); - result.value = -result.value; - break; - case NEXT: - if (allocation_done ==lang_allocating_phase_enum) { - make_abs(&result); - result.value = ALIGN(dot, result.value); - } - else { - /* Return next place aligned to value */ - result.valid = false; - } - break; - default: - FAIL(); - } - } - - break; - case etree_trinary: - - result = exp_fold_tree(tree->trinary.cond, - current_section, - allocation_done, dot, dotp); - if (result.valid) { - result = exp_fold_tree(result.value ? - tree->trinary.lhs:tree->trinary.rhs, - current_section, - allocation_done, dot, dotp); - } - - break; - case etree_binary: - result = fold_binary(tree, current_section, allocation_done, - dot, dotp); - break; - case etree_assign: - if (tree->assign.dst[0] == '.' && tree->assign.dst[1] == 0) { - /* Assignment to dot can only be done during allocation */ - if (allocation_done == lang_allocating_phase_enum) { - result = exp_fold_tree(tree->assign.src, - current_section, - lang_allocating_phase_enum, dot, dotp); - if (result.valid == false) { - info("%F%S invalid assignment to location counter\n"); - } - else { - if (current_section == - (lang_output_section_statement_type *)NULL) { - info("%F%S assignment to location counter invalid outside of SECTION\n"); - } - else { - unsigned long nextdot =result.value + - current_section->bfd_section->vma; - if (nextdot < dot) { - info("%F%S cannot move location counter backwards"); - } - else { - *dotp = nextdot; - } - } - } - } - } - else { - ldsym_type *sy = ldsym_get(tree->assign.dst); - - /* If this symbol has just been created then we'll place it into - * a section of our choice - */ - result = exp_fold_tree(tree->assign.src, - current_section, allocation_done, - dot, dotp); - if (result.valid) - { - asymbol *def; - asymbol **def_ptr = (asymbol **)ldmalloc(sizeof(asymbol **)); - /* Add this definition to script file */ - def = (asymbol *)bfd_make_empty_symbol(script_file->the_bfd); - *def_ptr = def; - - - def->value = result.value; - if (result.section != - (lang_output_section_statement_type *)NULL) { - if (current_section != - (lang_output_section_statement_type *)NULL) { - - def->section = result.section->bfd_section; - def->flags = BSF_GLOBAL | BSF_EXPORT; - } - else { - /* Force to absolute */ - def->value += result.section->bfd_section->vma; - def->section = (asection *)NULL; - def->flags = BSF_GLOBAL | BSF_EXPORT | BSF_ABSOLUTE; - } - - - } - else { - def->section = (asection *)NULL; - def->flags = BSF_GLOBAL | BSF_EXPORT | BSF_ABSOLUTE; - } - - - def->udata = (PTR)NULL; - def->name = sy->name; - Q_enter_global_ref(def_ptr); - } - - } - - - break; - case etree_name: - result = fold_name(tree, current_section, allocation_done, dot); - break; - default: - info("%F%S Need more of these %d",tree->type.node_class ); - - } - } - - return result; -} - - -etree_value_type exp_fold_tree_no_dot(tree, current_section, allocation_done) -etree_type *tree; -lang_output_section_statement_type *current_section; -lang_phase_type allocation_done; -{ -return exp_fold_tree(tree, current_section, allocation_done, (bfd_vma) - 0, (bfd_vma *)NULL); -} - -etree_type * -exp_binop(code, lhs, rhs) -int code; -etree_type *lhs; -etree_type *rhs; -{ - etree_type value, *new; - etree_value_type r; - - value.type.node_code = code; - value.binary.lhs = lhs; - value.binary.rhs = rhs; - value.type.node_class = etree_binary; - r = exp_fold_tree_no_dot(&value, (lang_output_section_statement_type *)NULL, - lang_first_phase_enum ); - if (r.valid) - { - return exp_intop(r.value); - } - new = (etree_type *)ldmalloc(sizeof(new->binary)); - memcpy((char *)new, (char *)&value, sizeof(new->binary)); - return new; -} - -etree_type * -exp_trinop(code, cond, lhs, rhs) -int code; -etree_type *cond; -etree_type *lhs; -etree_type *rhs; -{ - etree_type value, *new; - etree_value_type r; - value.type.node_code = code; - value.trinary.lhs = lhs; - value.trinary.cond = cond; - value.trinary.rhs = rhs; - value.type.node_class = etree_trinary; - r= exp_fold_tree_no_dot(&value, (lang_output_section_statement_type - *)NULL,lang_first_phase_enum); - if (r.valid) { - return exp_intop(r.value); - } - new = (etree_type *)ldmalloc(sizeof(new->trinary)); - memcpy((char *)new,(char *) &value, sizeof(new->trinary)); - return new; -} - - -etree_type * -exp_unop(code, child) -int code; -etree_type *child; -{ - etree_type value, *new; - - etree_value_type r; - value.unary.type.node_code = code; - value.unary.child = child; - value.unary.type.node_class = etree_unary; -r = exp_fold_tree_no_dot(&value,(lang_output_section_statement_type *)NULL, - lang_first_phase_enum); -if (r.valid) { - return exp_intop(r.value); - } - new = (etree_type *)ldmalloc(sizeof(new->unary)); - memcpy((char *)new, (char *)&value, sizeof(new->unary)); - return new; -} - - -etree_type * -exp_nameop(code, name) -int code; -char *name; -{ - - etree_type value, *new; - - etree_value_type r; - value.name.type.node_code = code; - value.name.name = name; - value.name.type.node_class = etree_name; - - - r = exp_fold_tree_no_dot(&value,(lang_output_section_statement_type *)NULL, - lang_first_phase_enum); - if (r.valid) { - return exp_intop(r.value); - } - new = (etree_type *)ldmalloc(sizeof(new->name)); - memcpy((char *)new, (char *)&value, sizeof(new->name)); - return new; - -} - - - - -etree_type * -exp_assop(code, dst, src) -int code; -char *dst; -etree_type *src; -{ - etree_type value, *new; - - value.assign.type.node_code = code; - - - value.assign.src = src; - value.assign.dst = dst; - value.assign.type.node_class = etree_assign; - -#if 0 - if (exp_fold_tree_no_dot(&value, &result)) { - return exp_intop(result); - } -#endif - new = (etree_type*)ldmalloc(sizeof(new->assign)); - memcpy((char *)new, (char *)&value, sizeof(new->assign)); - return new; -} - -void -exp_print_tree(outfile, tree) -FILE *outfile; -etree_type *tree; -{ - switch (tree->type.node_class) { - case etree_value: - fprintf(outfile,"0x%08lx",(bfd_vma)(tree->value.value)); - return; - case etree_assign: -#if 0 - if (tree->assign.dst->sdefs != (asymbol *)NULL){ - fprintf(outfile,"%s (%x) ",tree->assign.dst->name, - tree->assign.dst->sdefs->value); - } - else { - fprintf(outfile,"%s (UNDEFINED)",tree->assign.dst->name); - } -#endif - fprintf(outfile,"%s ",tree->assign.dst); - exp_print_token(outfile,tree->type.node_code); - exp_print_tree(outfile,tree->assign.src); - break; - case etree_binary: - exp_print_tree(outfile,tree->binary.lhs); - exp_print_token(outfile,tree->type.node_code); - exp_print_tree(outfile,tree->binary.rhs); - break; - case etree_trinary: - exp_print_tree(outfile,tree->trinary.cond); - fprintf(outfile,"?"); - exp_print_tree(outfile,tree->trinary.lhs); - fprintf(outfile,":"); - exp_print_tree(outfile,tree->trinary.rhs); - break; - case etree_unary: - exp_print_token(outfile,tree->unary.type.node_code); - fprintf(outfile,"("); - exp_print_tree(outfile,tree->unary.child); - fprintf(outfile,")"); - break; - case etree_undef: - fprintf(outfile,"????????"); - break; - case etree_name: - if (tree->type.node_code == NAME) { - fprintf(outfile,"%s", tree->name.name); - } - else { - exp_print_token(outfile,tree->type.node_code); - fprintf(outfile,"(%s)", tree->name.name); - } - break; - default: - FAIL(); - break; - } -} - - - - -bfd_vma -exp_get_vma(tree, def, name, allocation_done) -etree_type *tree; -bfd_vma def; -char *name; -lang_phase_type allocation_done; -{ - etree_value_type r; - - if (tree != (etree_type *)NULL) { - r = exp_fold_tree_no_dot(tree, - (lang_output_section_statement_type *)NULL, - allocation_done); - if (r.valid == false && name) { - info("%F%S Nonconstant expression for %s\n",name); - } - return r.value; - } - else { - return def; - } -} - -int -exp_get_value_int(tree,def,name, allocation_done) -etree_type *tree; -int def; -char *name; -lang_phase_type allocation_done; -{ - return (int)exp_get_vma(tree,(bfd_vma)def,name, allocation_done); -} - diff --git a/ld/ldexp.h b/ld/ldexp.h deleted file mode 100644 index 8211f44c17b..00000000000 --- a/ld/ldexp.h +++ /dev/null @@ -1,127 +0,0 @@ -/* ldexp.h - - - Copyright (C) 1991 Free Software Foundation, Inc. - - This file is part of GLD, the Gnu Linker. - - GLD 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 1, or (at your option) - any later version. - - GLD 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 GLD; see the file COPYING. If not, write to - the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - - - - -/* The result of an expression tree */ -typedef struct -{ - bfd_vma value; - struct lang_output_section_statement_struct *section; - boolean valid; -} etree_value_type; - - - -typedef struct -{ - int node_code; - enum { etree_binary, - etree_trinary, - etree_unary, - etree_name, - etree_assign, - etree_undef, - etree_unspec, - etree_value } node_class; -} node_type; - - - -typedef union etree_union -{ - node_type type; - struct { - node_type type; - union etree_union *lhs; - union etree_union *rhs; - } binary; - struct { - node_type type; - union etree_union *cond; - union etree_union *lhs; - union etree_union *rhs; - } trinary; - struct { - node_type type; - char *dst; - union etree_union *src; - } assign; - - struct { - node_type type; - union etree_union *child; - } unary; - struct { - node_type type; - char *name; - } name; - struct { - node_type type; - bfd_vma value; - } value; - -} etree_type; - - -PROTO(etree_type *,exp_intop,(bfd_vma)); - -PROTO(etree_value_type, invalid,(void)); -PROTO(etree_value_type, exp_fold_tree,(etree_type *, struct - lang_output_section_statement_struct *, lang_phase_type, - bfd_vma, bfd_vma *)); - -PROTO(etree_type *, exp_binop,(int, etree_type *, etree_type *)); -PROTO(etree_type *,exp_trinop,(int,etree_type *, etree_type *, etree_type *)); -PROTO(etree_type *,exp_unop,(int, etree_type *)); -PROTO(etree_type *,exp_nameop,(int, char *)); -PROTO(etree_type *,exp_assop,(int, char *, etree_type *)); -PROTO(void, exp_print_tree,(struct _iobuf *, etree_type *)); -PROTO(bfd_vma, exp_get_vma,(etree_type *, bfd_vma, char *, enum boolean)); -PROTO(int, exp_get_value_int,(etree_type *, int, char *, enum boolean)); -#if 0 -#define LONG 1000 -#define SHORT 1001 -#define BYTE 1002 -#define NAME 1003 -#define NEXT 1004 -#define DEFINED 1005 -#define SIZEOF 1006 -#define ADDR 1007 -#define ALIGN_K 1008 -#define BLOCK 1009 -#define SECTIONS 1010 -#define SIZEOF_HEADERS 1011 -#define MEMORY 1012 -#define DSECT 1013 -#define COPY 1014 -#define INFO 1015 -#define OVERLAY 1016 -#define TARGET_K 1017 -#define MAP 1018 -#define ENTRY 1019 -#define ORIGIN 1020 -#define LENGTH 1021 -#define NOLOAD 1022 -#define SEARCH_DIR 1023 -#define ALIGNMENT 1024 - -#endif diff --git a/ld/ldfile.c b/ld/ldfile.c deleted file mode 100644 index f1c0bdb0695..00000000000 --- a/ld/ldfile.c +++ /dev/null @@ -1,352 +0,0 @@ - -/* Copyright (C) 1991 Free Software Foundation, Inc. - -This file is part of GLD, the Gnu Linker. - -GLD 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 1, or (at your option) -any later version. - -GLD 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 GLD; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - $Id$ -*/ - -/* - ldfile.c - - look after all the file stuff - - */ - -#include "sysdep.h" -#include "bfd.h" - -#include "ldmisc.h" -#include "ldlang.h" -#include "ldfile.h" - -/* EXPORT */ -char *ldfile_input_filename; -CONST char * ldfile_output_machine_name =""; -unsigned long ldfile_output_machine; -enum bfd_architecture ldfile_output_architecture; -boolean had_script; - -/* IMPORT */ - -extern boolean option_v; - - - - - -/* LOACL */ -typedef struct search_dirs_struct -{ - char *name; - struct search_dirs_struct *next; -} search_dirs_type; - -static search_dirs_type *search_head; -static search_dirs_type **search_tail_ptr = &search_head; - -typedef struct search_arch_struct -{ - char *name; - struct search_arch_struct *next; -} search_arch_type; - -static search_arch_type *search_arch_head; -static search_arch_type **search_arch_tail_ptr = &search_arch_head; - - - -void -ldfile_add_library_path(name) -char *name; -{ - search_dirs_type *new = - (search_dirs_type *)ldmalloc(sizeof(search_dirs_type)); - new->name = name; - new->next = (search_dirs_type*)NULL; - *search_tail_ptr = new; - search_tail_ptr = &new->next; -} - - -static bfd* -cached_bfd_openr(attempt,entry) -char *attempt; -lang_input_statement_type *entry; -{ - entry->the_bfd = bfd_openr(attempt, entry->target); - if (option_v == true ) { - info("attempt to open %s %s\n", attempt, - (entry->the_bfd == (bfd *)NULL) ? "failed" : "succeeded" ); - } - return entry->the_bfd; -} - -static bfd * -open_a(arch, entry, lib, suffix) -char *arch; -lang_input_statement_type *entry; -char *lib; -char *suffix; -{ - bfd*desc; - search_dirs_type *search ; - for (search = search_head; - search != (search_dirs_type *)NULL; - search = search->next) - { - char buffer[1000]; - char *string; - if (entry->is_archive == true) { - sprintf(buffer, - "%s/%s%s%s%s", - search->name, - lib, - entry->filename, arch, suffix); - } - else { - if (entry->filename[0] == '/' || entry->filename[0] == '.') { - strcpy(buffer, entry->filename); - } else { - sprintf(buffer,"%s/%s",search->name, entry->filename); - } - } - string = buystring(buffer); - desc = cached_bfd_openr (string, entry); - if (desc) - { - entry->filename = string; - entry->search_dirs_flag = false; - entry->the_bfd = desc; - return desc; - } - free(string); - } - return (bfd *)NULL; -} - -/* Open the input file specified by 'entry', and return a descriptor. - The open file is remembered; if the same file is opened twice in a row, - a new open is not actually done. */ - -void -ldfile_open_file (entry) -lang_input_statement_type *entry; -{ - - if (entry->superfile) - ldfile_open_file (entry->superfile); - - if (entry->search_dirs_flag) - { - search_arch_type *arch; - /* Try to open or lib.a */ - - for (arch = search_arch_head; - arch != (search_arch_type *)NULL; - arch = arch->next) { - if (open_a(arch->name,entry,"","") != (bfd *)NULL) { - return; - } - if (open_a(arch->name,entry,"lib",".a") != (bfd *)NULL) { - return; - } - - } - - - } - else { - entry->the_bfd = cached_bfd_openr (entry->filename, entry); - - } - if (!entry->the_bfd) info("%F%P: %E %I\n", entry); - -} - - - - - - -static FILE * -try_open(name, exten) -char *name; -char *exten; -{ - FILE *result; - char buff[1000]; - result = fopen(name, "r"); - if (option_v == true) { - if (result == (FILE *)NULL) { - info("can't find "); - } - info("%s\n",name); - - return result; - } - sprintf(buff, "%s%s", name, exten); - result = fopen(buff, "r"); - - if (option_v == true) { - if (result == (FILE *)NULL) { - info("can't find "); - } - info("%s\n", buff); - } - return result; -} -static FILE * -find_a_name(name, extend) -char *name; -char *extend; -{ - search_dirs_type *search; - FILE *result; - char buffer[1000]; - /* First try raw name */ - result = try_open(name,""); - if (result == (FILE *)NULL) { - /* Try now prefixes */ - for (search = search_head; - search != (search_dirs_type *)NULL; - search = search->next) { - sprintf(buffer,"%s/%s", search->name, name); - result = try_open(buffer, extend); - if (result)break; - } - } - return result; -} - -void ldfile_open_command_file(name) -char *name; -{ - extern FILE *ldlex_input_stack; - ldlex_input_stack = find_a_name(name, ".ld"); - - if (ldlex_input_stack == (FILE *)NULL) { - info("%P%F cannot open load script file %s\n",name); - } - ldfile_input_filename = name; - had_script = true; -} - - - - - -#ifdef GNU960 -static -char * -gnu960_map_archname( name ) -char *name; -{ - struct tabentry { char *cmd_switch; char *arch; }; - static struct tabentry arch_tab[] = { - "", "", - "KA", "ka", - "KB", "kb", - "KC", "mc", /* Synonym for MC */ - "MC", "mc", - "CA", "ca", - "SA", "ka", /* Functionally equivalent to KA */ - "SB", "kb", /* Functionally equivalent to KB */ - NULL, "" - }; - struct tabentry *tp; - - - for ( tp = arch_tab; tp->cmd_switch != NULL; tp++ ){ - if ( !strcmp(name,tp->cmd_switch) ){ - break; - } - } - - if ( tp->cmd_switch == NULL ){ - info("%P%F: unknown architecture: %s\n",name); - } - return tp->arch; -} - - - -void -ldfile_add_arch(name) -char *name; -{ - search_arch_type *new = - (search_arch_type *)ldmalloc(sizeof(search_arch_type)); - - - if (*name != '\0') { - if (ldfile_output_machine_name[0] != '\0') { - info("%P%F: target architecture respecified\n"); - return; - } - ldfile_output_machine_name = name; - } - - new->next = (search_arch_type*)NULL; - new->name = gnu960_map_archname( name ); - *search_arch_tail_ptr = new; - search_arch_tail_ptr = &new->next; - -} - -#else /* not GNU960 */ - - -void -DEFUN(ldfile_add_arch,(in_name), - CONST char * in_name) -{ - char *name = buystring(in_name); - search_arch_type *new = - (search_arch_type *)ldmalloc(sizeof(search_arch_type)); - - ldfile_output_machine_name = in_name; - - new->name = name; - new->next = (search_arch_type*)NULL; - while (*name) { - if (isupper(*name)) *name = tolower(*name); - name++; - } - *search_arch_tail_ptr = new; - search_arch_tail_ptr = &new->next; - -} -#endif - -/* Set the output architecture */ -void -DEFUN(ldfile_set_output_arch,(string), -CONST char *string) -{ - enum bfd_architecture arch; - unsigned long machine; - if (bfd_scan_arch_mach(string, &arch, &machine) == true) { - ldfile_output_architecture = arch; - ldfile_output_machine = machine; - ldfile_output_machine_name = string; - } - else { - info("%P%F: Can't represent machine `%s'\n", string); - } -} diff --git a/ld/ldfile.h b/ld/ldfile.h deleted file mode 100644 index f4ad289aa5f..00000000000 --- a/ld/ldfile.h +++ /dev/null @@ -1,27 +0,0 @@ -/* ldfile.h - - - Copyright (C) 1991 Free Software Foundation, Inc. - - This file is part of GLD, the Gnu Linker. - - GLD 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 1, or (at your option) - any later version. - - GLD 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 GLD; see the file COPYING. If not, write to - the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - - - -PROTO(void,ldfile_add_arch,(CONST char *CONST)); -PROTO(void,ldfile_add_library_path,(char *)); -PROTO(void,ldfile_open_command_file,(char *name)); -PROTO(void,ldfile_open_file,(struct lang_input_statement_struct *)); - diff --git a/ld/ldgld.c b/ld/ldgld.c deleted file mode 100755 index e51d07355ee..00000000000 --- a/ld/ldgld.c +++ /dev/null @@ -1,145 +0,0 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. - -This file is part of GLD, the Gnu Linker. - -GLD 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 1, or (at your option) -any later version. - -GLD 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 GLD; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - * $Id$ - * -*/ - -/* - * emulate the original gld - * - * Written by Steve Chamberlain steve@cygnus.com - */ - - -#include "sysdep.h" -#include "bfd.h" - - -#include "ld.h" -#include "config.h" -#include "ldemul.h" -#include "ldfile.h" -#include "ldmisc.h" - -extern boolean lang_float_flag; - - -extern enum bfd_architecture ldfile_output_architecture; -extern unsigned long ldfile_output_machine; -extern char *ldfile_output_machine_name; - -extern bfd *output_bfd; - - - -static void gld_before_parse() -{ - ldfile_add_library_path("/lib"); - ldfile_add_library_path("/usr/lib"); - ldfile_add_library_path("/usr/local/lib/lib"); -} - - -static void -gld_after_parse() -{ - -} - -static void -gld_after_allocation() -{ - -} - -static void -gld_before_allocation() -{ - -} - - -static void -gld_set_output_arch() -{ - /* Set the output architecture and machine if possible */ - bfd_set_arch_mach(output_bfd, ldfile_output_architecture, ldfile_output_machine); -} - -static char * -gld_choose_target() -{ - char *from_outside = getenv(TARGET_ENVIRON); - if (from_outside != (char *)NULL) - return from_outside; - return GLD_TARGET; -} - -static void -gld_syslib() -{ - info("%S SYSLIB ignored\n"); -} - -static void -gld_hll(ignore) -char *ignore; -{ - info("%S HLL ignored\n"); -} - -static char *gld_script = -#include "ldgld.x" -; - -static char *gld_script_option_Ur = -#include "ldgldUr.x" -; - -static char *gld_script_option_r = -#include "ldgldr.x" -; - -static char *gld_get_script() -{ - extern ld_config_type config; - if (config.relocateable_output == true && - config.build_constructors == true) { - return gld_script_option_Ur; - } - if (config.relocateable_output) { - return gld_script_option_r; - } - - return gld_script; -} -struct ld_emulation_xfer_struct ld_gld_emulation = -{ - gld_before_parse, - gld_syslib, - gld_hll, - gld_after_parse, - gld_after_allocation, - gld_set_output_arch, - gld_choose_target, - gld_before_allocation, - gld_get_script, -}; - diff --git a/ld/ldgld.sc b/ld/ldgld.sc deleted file mode 100755 index 15ff71fc383..00000000000 --- a/ld/ldgld.sc +++ /dev/null @@ -1,30 +0,0 @@ -OUTPUT_ARCH(sparc) -OUTPUT_FORMAT("a.out-sunos-big") -SEARCH_DIR(/lib) -SEARCH_DIR(/usr/lib) -SEARCH_DIR(/usr/local/lib) -__DYNAMIC = 0; -SECTIONS -{ - .text 0x2020 BLOCK(0x2000): - { - CREATE_OBJECT_SYMBOLS ; - *(.text); - _etext = ALIGN( 0x2000); - } - .data ALIGN(0x2000) : - { - *(.data); - CONSTRUCTORS; - _edata = .; - } - .bss SIZEOF(.data) + ADDR(.data) : - { - *(.bss) - [COMMON] - _end = .; - __end = .; - } -} - - diff --git a/ld/ldgld.script b/ld/ldgld.script deleted file mode 100755 index 15ff71fc383..00000000000 --- a/ld/ldgld.script +++ /dev/null @@ -1,30 +0,0 @@ -OUTPUT_ARCH(sparc) -OUTPUT_FORMAT("a.out-sunos-big") -SEARCH_DIR(/lib) -SEARCH_DIR(/usr/lib) -SEARCH_DIR(/usr/local/lib) -__DYNAMIC = 0; -SECTIONS -{ - .text 0x2020 BLOCK(0x2000): - { - CREATE_OBJECT_SYMBOLS ; - *(.text); - _etext = ALIGN( 0x2000); - } - .data ALIGN(0x2000) : - { - *(.data); - CONSTRUCTORS; - _edata = .; - } - .bss SIZEOF(.data) + ADDR(.data) : - { - *(.bss) - [COMMON] - _end = .; - __end = .; - } -} - - diff --git a/ld/ldgld68k.c b/ld/ldgld68k.c deleted file mode 100755 index f34e79db835..00000000000 --- a/ld/ldgld68k.c +++ /dev/null @@ -1,143 +0,0 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. - -This file is part of GLD, the Gnu Linker. - -GLD 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 1, or (at your option) -any later version. - -GLD 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 GLD; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - * $Id:# -*/ - -/* - * emulate the original gld running on a 68k system - * - * Written by Steve Chamberlain steve@cygnus.com - */ - - -#include "sysdep.h" -#include "bfd.h" - -#include "ld.h" -#include "config.h" -#include "ldemul.h" -#include "ldfile.h" -#include "ldmisc.h" - -extern boolean lang_float_flag; - - -extern enum bfd_architecture ldfile_output_architecture; -extern unsigned long ldfile_output_machine; -extern char *ldfile_output_machine_name; - -extern bfd *output_bfd; - - - -static void gld68k_before_parse() -{ - ldfile_add_library_path("/lib"); - ldfile_add_library_path("/usr/lib"); - ldfile_add_library_path("/usr/local/lib/lib"); - ldfile_output_architecture = bfd_arch_m68k; -} - - -static void -gld68k_after_parse() -{ - -} - -static void -gld68k_after_allocation() -{ - -} - -static void -gld68k_before_allocation() -{ - -} - - -static void -gld68k_set_output_arch() -{ - /* Set the output architecture and machine if possible */ - unsigned long machine = 0; - bfd_set_arch_mach(output_bfd, ldfile_output_architecture, machine); -} - -static char * -gld68k_choose_target() -{ - char *from_outside = getenv(TARGET_ENVIRON); - if (from_outside != (char *)NULL) - return from_outside; - return GLD68K_TARGET; -} - -static void -gld68k_syslib() -{ - info("%S SYSLIB ignored\n"); -} - -static void -gld68k_hll(ignore) -char *ignore; -{ - info("%S HLL ignored\n"); -} - -static char *gld68k_script = -#include "ldgld68k.x" -; - -static char *gld68k_script_option_Ur = -#include "ldgld68kUr.x" -; -static char *gld68k_script_option_r = -#include "ldgld68kr.x" -; -static char *gld68k_get_script() -{ - extern ld_config_type config; - if (config.relocateable_output == true && - config.build_constructors == true) { - return gld68k_script_option_Ur; - } - if (config.relocateable_output) { - return gld68k_script_option_r; - } - - return gld68k_script; -} -struct ld_emulation_xfer_struct ld_gld68k_emulation = -{ - gld68k_before_parse, - gld68k_syslib, - gld68k_hll, - gld68k_after_parse, - gld68k_after_allocation, - gld68k_set_output_arch, - gld68k_choose_target, - gld68k_before_allocation, - gld68k_get_script, -}; - diff --git a/ld/ldgld68k.sc b/ld/ldgld68k.sc deleted file mode 100755 index d4b408e55f2..00000000000 --- a/ld/ldgld68k.sc +++ /dev/null @@ -1,29 +0,0 @@ -OUTPUT_FORMAT("a.out-sunos-big") -OUTPUT_ARCH(m68k) - -SEARCH_DIR(/lib) -SEARCH_DIR(/usr/lib) -SEARCH_DIR(/usr/local/lib) -__DYNAMIC = 0; -SECTIONS -{ - .text 0x2020 BLOCK(0x2000): - { - CREATE_OBJECT_SYMBOLS - *(.text) - _etext = ALIGN( 0x2000); - } - .data ALIGN(0x20000) : - { - *(.data) - CONSTRUCTORS - _edata = .; - } - .bss SIZEOF(.data) + ADDR(.data) : - { - *(.bss) - [COMMON] - _end = .; - } -} - diff --git a/ld/ldgld68k.script b/ld/ldgld68k.script deleted file mode 100755 index be91d916a97..00000000000 --- a/ld/ldgld68k.script +++ /dev/null @@ -1,28 +0,0 @@ -OUTPUT_FORMAT("a.out-sunos-big") -OUTPUT_ARCH(m68k) - -SEARCH_DIR(/lib) -SEARCH_DIR(/usr/lib) -SEARCH_DIR(/usr/local/lib) -__DYNAMIC = 0; -SECTIONS -{ - .text 0x2020 BLOCK(0x2000): - { - CREATE_OBJECT_SYMBOLS - *(.text) - _etext = ALIGN( 0x2000); - } - .data ALIGN(0x20000) : - { - *(.data) - _edata = .; - } - .bss SIZEOF(.data) + ADDR(.data) : - { - *(.bss) - [COMMON] - _end = .; - } -} - diff --git a/ld/ldgld68kUr.sc b/ld/ldgld68kUr.sc deleted file mode 100755 index aa89c6a355d..00000000000 --- a/ld/ldgld68kUr.sc +++ /dev/null @@ -1,21 +0,0 @@ -SEARCH_DIR(/lib) -SEARCH_DIR(/usr/lib) -SEARCH_DIR(/usr/local/lib) -SECTIONS -{ - .text 0: - { - CREATE_OBJECT_SYMBOLS - *(.text) - } - .data SIZEOF(.text) + ADDR(.text) : - { - *(.data) - } - .bss SIZEOF(.data) + ADDR(.data) : - { - *(.bss) - [COMMON] - } -} - diff --git a/ld/ldgld68kUr.script b/ld/ldgld68kUr.script deleted file mode 100755 index aa89c6a355d..00000000000 --- a/ld/ldgld68kUr.script +++ /dev/null @@ -1,21 +0,0 @@ -SEARCH_DIR(/lib) -SEARCH_DIR(/usr/lib) -SEARCH_DIR(/usr/local/lib) -SECTIONS -{ - .text 0: - { - CREATE_OBJECT_SYMBOLS - *(.text) - } - .data SIZEOF(.text) + ADDR(.text) : - { - *(.data) - } - .bss SIZEOF(.data) + ADDR(.data) : - { - *(.bss) - [COMMON] - } -} - diff --git a/ld/ldgld68kr.sc b/ld/ldgld68kr.sc deleted file mode 100755 index 8cbc9dc8e06..00000000000 --- a/ld/ldgld68kr.sc +++ /dev/null @@ -1,22 +0,0 @@ - -SEARCH_DIR(/lib) -SEARCH_DIR(/usr/lib) -SEARCH_DIR(/usr/local/lib) -SECTIONS -{ - .text 0: - { - CREATE_OBJECT_SYMBOLS - *(.text) - } - .data SIZEOF(.text) + ADDR(.text) : - { - *(.data) - } - .bss SIZEOF(.data) + ADDR(.data) : - { - *(.bss) - [COMMON] - } -} - diff --git a/ld/ldgld68kr.script b/ld/ldgld68kr.script deleted file mode 100755 index 8cbc9dc8e06..00000000000 --- a/ld/ldgld68kr.script +++ /dev/null @@ -1,22 +0,0 @@ - -SEARCH_DIR(/lib) -SEARCH_DIR(/usr/lib) -SEARCH_DIR(/usr/local/lib) -SECTIONS -{ - .text 0: - { - CREATE_OBJECT_SYMBOLS - *(.text) - } - .data SIZEOF(.text) + ADDR(.text) : - { - *(.data) - } - .bss SIZEOF(.data) + ADDR(.data) : - { - *(.bss) - [COMMON] - } -} - diff --git a/ld/ldgld960.c b/ld/ldgld960.c deleted file mode 100755 index f3a3b0cdcf7..00000000000 --- a/ld/ldgld960.c +++ /dev/null @@ -1,169 +0,0 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. - -This file is part of GLD, the Gnu Linker. - -GLD 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 1, or (at your option) -any later version. - -GLD 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 GLD; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - $Id$ -*/ - -/* - * emulate the Intels port of gld - */ - - -#include "bfd.h" -#include "sysdep.h" - - -#include "ld.h" -#include "config.h" -#include "ldemul.h" -#include "ldfile.h" -#include "ldmisc.h" - - -/* IMPORTS */ -extern char *output_filename; -extern boolean lang_float_flag; - - -extern enum bfd_architecture ldfile_output_architecture; -extern unsigned long ldfile_output_machine; -extern char *ldfile_output_machine_name; - -extern bfd *output_bfd; - - - -#ifdef GNU960 - -static void -gld960_before_parse() -{ - static char *env_variables[] = { "G960LIB", "G960BASE", 0 }; - char **p; - char *env ; - - for ( p = env_variables; *p; p++ ){ - env = (char *) getenv(*p); - if (env) { - ldfile_add_library_path(concat(env,"/lib/libbout","")); - } - } - ldfile_output_architecture = bfd_arch_i960; -} - -#else /* not GNU960 */ - -static void gld960_before_parse() -{ - char *env ; - env = getenv("G960LIB"); - if (env) { - ldfile_add_library_path(env); - } - env = getenv("G960BASE"); - if (env) { - ldfile_add_library_path(concat(env,"/lib","")); - } - ldfile_output_architecture = bfd_arch_i960; -} - -#endif /* GNU960 */ - - -static void -gld960_after_parse() -{ - -} - -static void -gld960_after_allocation() -{ - -} - -static void -gld960_before_allocation() -{ - -} - - -static void -gld960_set_output_arch() -{ - bfd_set_arch_mach(output_bfd, ldfile_output_architecture, bfd_mach_i960_core); -} - -static char * -gld960_choose_target() -{ -#ifdef GNU960 - - output_filename = "b.out"; - return bfd_make_targ_name(BFD_BOUT_FORMAT, 0); - -#else - - char *from_outside = getenv(TARGET_ENVIRON); - output_filename = "b.out"; - - if (from_outside != (char *)NULL) - return from_outside; - return GLD960_TARGET; - -#endif -} - -static void -gld960_syslib() -{ - info("%S SYSLIB ignored\n"); -} - -static void -gld960_hll() -{ - info("%S HLL ignored\n"); -} - - -static char *script = -#include "ldgld960.x" -; - - -static char * -gld960_get_script() -{ -return script; -} - -struct ld_emulation_xfer_struct ld_gld960_emulation = -{ - gld960_before_parse, - gld960_syslib, - gld960_hll, - gld960_after_parse, - gld960_after_allocation, - gld960_set_output_arch, - gld960_choose_target, - gld960_before_allocation, - gld960_get_script, -}; diff --git a/ld/ldgld960.sc b/ld/ldgld960.sc deleted file mode 100755 index 1c40a732e77..00000000000 --- a/ld/ldgld960.sc +++ /dev/null @@ -1,23 +0,0 @@ -SECTIONS -{ - .text : - { - CREATE_OBJECT_SYMBOLS - *(.text) - _etext = .; - } - - .data SIZEOF(.text) + ADDR(.text): - { - - *(.data) - _edata = .; - } - .bss SIZEOF(.data) + ADDR(.data) : - { - _bss_start = .; - *(.bss) - [COMMON] - _end = . ; - } -} diff --git a/ld/ldgld960.script b/ld/ldgld960.script deleted file mode 100755 index 1c40a732e77..00000000000 --- a/ld/ldgld960.script +++ /dev/null @@ -1,23 +0,0 @@ -SECTIONS -{ - .text : - { - CREATE_OBJECT_SYMBOLS - *(.text) - _etext = .; - } - - .data SIZEOF(.text) + ADDR(.text): - { - - *(.data) - _edata = .; - } - .bss SIZEOF(.data) + ADDR(.data) : - { - _bss_start = .; - *(.bss) - [COMMON] - _end = . ; - } -} diff --git a/ld/ldgldUr.sc b/ld/ldgldUr.sc deleted file mode 100755 index e7d9b447051..00000000000 --- a/ld/ldgldUr.sc +++ /dev/null @@ -1,24 +0,0 @@ - -SEARCH_DIR(/lib) -SEARCH_DIR(/usr/lib) -SEARCH_DIR(/usr/local/lib) -SECTIONS -{ - .text 0: - { - CREATE_OBJECT_SYMBOLS - *(.text) - } - .data SIZEOF(.text) + ADDR(.text) : - { - *(.data) - CONSTRUCTORS - ___end_list__ = . ; - } - .bss SIZEOF(.data) + ADDR(.data) : - { - *(.bss) - [COMMON] - } -} - diff --git a/ld/ldgldUr.script b/ld/ldgldUr.script deleted file mode 100755 index e7d9b447051..00000000000 --- a/ld/ldgldUr.script +++ /dev/null @@ -1,24 +0,0 @@ - -SEARCH_DIR(/lib) -SEARCH_DIR(/usr/lib) -SEARCH_DIR(/usr/local/lib) -SECTIONS -{ - .text 0: - { - CREATE_OBJECT_SYMBOLS - *(.text) - } - .data SIZEOF(.text) + ADDR(.text) : - { - *(.data) - CONSTRUCTORS - ___end_list__ = . ; - } - .bss SIZEOF(.data) + ADDR(.data) : - { - *(.bss) - [COMMON] - } -} - diff --git a/ld/ldglda29k.c b/ld/ldglda29k.c deleted file mode 100755 index 45662f023e7..00000000000 --- a/ld/ldglda29k.c +++ /dev/null @@ -1,144 +0,0 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. - -This file is part of GLD, the Gnu Linker. - -GLD 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 1, or (at your option) -any later version. - -GLD 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 GLD; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - * $Id:# -*/ - -/* - * emulate the original gld running on an a29k system - * - * Written by David Wood @ New York University - */ - - -#include "sysdep.h" -#include "bfd.h" - -#include "ld.h" -#include "config.h" -#include "ldemul.h" -#include "ldfile.h" -#include "ldmisc.h" - -extern boolean lang_float_flag; - - -extern enum bfd_architecture ldfile_output_architecture; -extern unsigned long ldfile_output_machine; -extern char *ldfile_output_machine_name; - -extern bfd *output_bfd; - - - -static void gld29k_before_parse() -{ -#ifndef NOTDEF /* Cross developing for now */ - ldfile_add_library_path("/lib"); - ldfile_add_library_path("/usr/lib"); - ldfile_add_library_path("/usr/local/lib"); -#endif - ldfile_output_architecture = bfd_arch_a29k; -} - - -static void -gld29k_after_parse() -{ - -} - -static void -gld29k_after_allocation() -{ - -} - -static void -gld29k_before_allocation() -{ - -} - -static void -gld29k_set_output_arch() -{ - /* Set the output architecture and machine if possible */ - unsigned long machine = 0; - bfd_set_arch_mach(output_bfd, ldfile_output_architecture, machine); -} - -static char * -gld29k_choose_target() -{ - char *from_outside = getenv(TARGET_ENVIRON); - if (from_outside != (char *)NULL) - return from_outside; - return GLD29K_TARGET; -} - -static void -gld29k_syslib() -{ - info("%S SYSLIB ignored\n"); -} - -static void -gld29k_hll(ignore) -char *ignore; -{ - info("%S HLL ignored\n"); -} - -static char *gld29k_script = -#include "ldglda29k.x" -; - -static char *gld29k_script_option_Ur = -#include "ldglda29kUr.x" -; -static char *gld29k_script_option_r = -#include "ldglda29kr.x" -; -static char *gld29k_get_script() -{ - extern ld_config_type config; - if (config.relocateable_output == true && - config.build_constructors == true) { - return gld29k_script_option_Ur; - } - if (config.relocateable_output) { - return gld29k_script_option_r; - } - - return gld29k_script; -} -struct ld_emulation_xfer_struct ld_gld29k_emulation = -{ - gld29k_before_parse, - gld29k_syslib, - gld29k_hll, - gld29k_after_parse, - gld29k_after_allocation, - gld29k_set_output_arch, - gld29k_choose_target, - gld29k_before_allocation, - gld29k_get_script, -}; - diff --git a/ld/ldglda29k.sc b/ld/ldglda29k.sc deleted file mode 100755 index ed7544c0c57..00000000000 --- a/ld/ldglda29k.sc +++ /dev/null @@ -1,38 +0,0 @@ -OUTPUT_FORMAT("coff-a29k-big") -INPUT(/lab3/u3/sym1/tools/usr/lib/segments.o) /* Has .rstack/.mstack */ -SEARCH_DIR(/lib) -SEARCH_DIR(/usr/lib) -SEARCH_DIR(/usr/local/lib) -MEMORY { - text : ORIGIN = 0x1000000, LENGTH = 0x1000000 - talias : ORIGIN = 0x2000000, LENGTH = 0x1000000 - data : ORIGIN = 0x3000000, LENGTH = 0x1000000 - mstack : ORIGIN = 0x4000000, LENGTH = 0x1000000 - rstack : ORIGIN = 0x5000000, LENGTH = 0x1000000 -} -SECTIONS -{ - .text : { - *(.text) - __etext = .; - *(.lit) - *(.shdata) - } > text - .shbss SIZEOF(.text) + ADDR(.text) : { - *(.shbss) - } - .talias : { } > talias - .data : { - *(.data) - __edata = .; - } > data - .bss SIZEOF(.data) + ADDR(.data) : - { - *(.bss) - [COMMON] - __end = ALIGN(0x8); - } - .mstack : { } > mstack - .rstack : { } > rstack -} - diff --git a/ld/ldglda29k.script b/ld/ldglda29k.script deleted file mode 100755 index 6d7d19aa8ee..00000000000 --- a/ld/ldglda29k.script +++ /dev/null @@ -1,38 +0,0 @@ -OUTPUT_FORMAT("coff-a29k-big") -INPUT(/lab3/u3/sym1/tools/usr/lib/segments.o) /* Has .rstack/.mstack */ -SEARCH_DIR(/lab3/u3/sym1/tools/lib) -SEARCH_DIR(/lab3/u3/sym1/tools/usr/lib) -SEARCH_DIR(/lab3/u3/sym1/tools/usr/local/lib) -MEMORY { - text : ORIGIN = 0x1000000, LENGTH = 0x1000000 - talias : ORIGIN = 0x2000000, LENGTH = 0x1000000 - data : ORIGIN = 0x3000000, LENGTH = 0x1000000 - mstack : ORIGIN = 0x4000000, LENGTH = 0x1000000 - rstack : ORIGIN = 0x5000000, LENGTH = 0x1000000 -} -SECTIONS -{ - .text : { - *(.text) - __etext = .; - *(.lit) - *(.shdata) - } > text - .shbss SIZEOF(.text) + ADDR(.text) : { - *(.shbss) - } - .talias : { } > talias - .data : { - *(.data) - __edata = .; - } > data - .bss SIZEOF(.data) + ADDR(.data) : - { - *(.bss) - [COMMON] - __end = ALIGN(0x8); - } - .mstack : { } > mstack - .rstack : { } > rstack -} - diff --git a/ld/ldglda29kUr.sc b/ld/ldglda29kUr.sc deleted file mode 100755 index c8e8e2c7cf4..00000000000 --- a/ld/ldglda29kUr.sc +++ /dev/null @@ -1,32 +0,0 @@ -OUTPUT_FORMAT("coff-a29k-big") -SEARCH_DIR(/lab3/u3/sym1/tools/lib) -SEARCH_DIR(/lab3/u3/sym1/tools/usr/lib) -SEARCH_DIR(/lab3/u3/sym1/tools/usr/local/lib) -MEMORY { - text : ORIGIN = 0x1000000, LENGTH = 0x1000000 - talias : ORIGIN = 0x2000000, LENGTH = 0x1000000 - data : ORIGIN = 0x3000000, LENGTH = 0x1000000 - mstack : ORIGIN = 0x4000000, LENGTH = 0x1000000 - rstack : ORIGIN = 0x5000000, LENGTH = 0x1000000 -} -SECTIONS -{ - .text 0 : { - *(.text) - __etext = .; - *(.lit) - *(.shdata) - } > text - .shbss SIZEOF(.text) + ADDR(.text) : { - *(.shbss) - } - .data SIZEOF(.shbss) + ADDR(.shbss): { - *(.data) - } - .bss SIZEOF(.data) + ADDR(.data) : - { - *(.bss) - [COMMON] - } -} - diff --git a/ld/ldglda29kUr.script b/ld/ldglda29kUr.script deleted file mode 100755 index c8e8e2c7cf4..00000000000 --- a/ld/ldglda29kUr.script +++ /dev/null @@ -1,32 +0,0 @@ -OUTPUT_FORMAT("coff-a29k-big") -SEARCH_DIR(/lab3/u3/sym1/tools/lib) -SEARCH_DIR(/lab3/u3/sym1/tools/usr/lib) -SEARCH_DIR(/lab3/u3/sym1/tools/usr/local/lib) -MEMORY { - text : ORIGIN = 0x1000000, LENGTH = 0x1000000 - talias : ORIGIN = 0x2000000, LENGTH = 0x1000000 - data : ORIGIN = 0x3000000, LENGTH = 0x1000000 - mstack : ORIGIN = 0x4000000, LENGTH = 0x1000000 - rstack : ORIGIN = 0x5000000, LENGTH = 0x1000000 -} -SECTIONS -{ - .text 0 : { - *(.text) - __etext = .; - *(.lit) - *(.shdata) - } > text - .shbss SIZEOF(.text) + ADDR(.text) : { - *(.shbss) - } - .data SIZEOF(.shbss) + ADDR(.shbss): { - *(.data) - } - .bss SIZEOF(.data) + ADDR(.data) : - { - *(.bss) - [COMMON] - } -} - diff --git a/ld/ldglda29kr.sc b/ld/ldglda29kr.sc deleted file mode 100755 index c8e8e2c7cf4..00000000000 --- a/ld/ldglda29kr.sc +++ /dev/null @@ -1,32 +0,0 @@ -OUTPUT_FORMAT("coff-a29k-big") -SEARCH_DIR(/lab3/u3/sym1/tools/lib) -SEARCH_DIR(/lab3/u3/sym1/tools/usr/lib) -SEARCH_DIR(/lab3/u3/sym1/tools/usr/local/lib) -MEMORY { - text : ORIGIN = 0x1000000, LENGTH = 0x1000000 - talias : ORIGIN = 0x2000000, LENGTH = 0x1000000 - data : ORIGIN = 0x3000000, LENGTH = 0x1000000 - mstack : ORIGIN = 0x4000000, LENGTH = 0x1000000 - rstack : ORIGIN = 0x5000000, LENGTH = 0x1000000 -} -SECTIONS -{ - .text 0 : { - *(.text) - __etext = .; - *(.lit) - *(.shdata) - } > text - .shbss SIZEOF(.text) + ADDR(.text) : { - *(.shbss) - } - .data SIZEOF(.shbss) + ADDR(.shbss): { - *(.data) - } - .bss SIZEOF(.data) + ADDR(.data) : - { - *(.bss) - [COMMON] - } -} - diff --git a/ld/ldglda29kr.script b/ld/ldglda29kr.script deleted file mode 100755 index c8e8e2c7cf4..00000000000 --- a/ld/ldglda29kr.script +++ /dev/null @@ -1,32 +0,0 @@ -OUTPUT_FORMAT("coff-a29k-big") -SEARCH_DIR(/lab3/u3/sym1/tools/lib) -SEARCH_DIR(/lab3/u3/sym1/tools/usr/lib) -SEARCH_DIR(/lab3/u3/sym1/tools/usr/local/lib) -MEMORY { - text : ORIGIN = 0x1000000, LENGTH = 0x1000000 - talias : ORIGIN = 0x2000000, LENGTH = 0x1000000 - data : ORIGIN = 0x3000000, LENGTH = 0x1000000 - mstack : ORIGIN = 0x4000000, LENGTH = 0x1000000 - rstack : ORIGIN = 0x5000000, LENGTH = 0x1000000 -} -SECTIONS -{ - .text 0 : { - *(.text) - __etext = .; - *(.lit) - *(.shdata) - } > text - .shbss SIZEOF(.text) + ADDR(.text) : { - *(.shbss) - } - .data SIZEOF(.shbss) + ADDR(.shbss): { - *(.data) - } - .bss SIZEOF(.data) + ADDR(.data) : - { - *(.bss) - [COMMON] - } -} - diff --git a/ld/ldgldi386v.c b/ld/ldgldi386v.c deleted file mode 100755 index 6049bf8eac4..00000000000 --- a/ld/ldgldi386v.c +++ /dev/null @@ -1,144 +0,0 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. - -This file is part of GLD, the Gnu Linker. - -GLD 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 1, or (at your option) -any later version. - -GLD 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 GLD; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - * $Id$ -*/ - -/* - * emulate the original gld running on an i386v system - * - * Written by David Wood @ New York University - */ - - -#include "sysdep.h" -#include "bfd.h" - -#include "ld.h" -#include "config.h" -#include "ldemul.h" -#include "ldfile.h" -#include "ldmisc.h" - -extern boolean lang_float_flag; - - -extern enum bfd_architecture ldfile_output_architecture; -extern unsigned long ldfile_output_machine; -extern char *ldfile_output_machine_name; - -extern bfd *output_bfd; - - - -static void gldi386v_before_parse() -{ -#ifndef NOTDEF /* Cross developing for now */ - ldfile_add_library_path("/usr/local/lib/386gcc-lib/lib"); - ldfile_add_library_path("/usr/local/lib/386gcc-lib/usr/lib"); - ldfile_add_library_path("/usr/local/lib/386gcc-lib/usr/local/lib"); -#endif - ldfile_output_architecture = bfd_arch_i386; -} - - -static void -gldi386v_after_parse() -{ - -} - -static void -gldi386v_after_allocation() -{ - -} - -static void -gldi386v_before_allocation() -{ - -} - -static void -gldi386v_set_output_arch() -{ - /* Set the output architecture and machine if possible */ - unsigned long machine = 0; - bfd_set_arch_mach(output_bfd, ldfile_output_architecture, machine); -} - -static char * -gldi386v_choose_target() -{ - char *from_outside = getenv(TARGET_ENVIRON); - if (from_outside != (char *)NULL) - return from_outside; - return GLDi386v_TARGET; -} - -static void -gldi386v_syslib() -{ - info("%S SYSLIB ignored\n"); -} - -static void -gldi386v_hll(ignore) -char *ignore; -{ - info("%S HLL ignored\n"); -} - -static char *gldi386v_script = -#include "ldgldi386v.x" -; - -static char *gldi386v_script_option_Ur = -#include "ldgldi386vUr.x" -; -static char *gldi386v_script_option_r = -#include "ldgldi386vr.x" -; -static char *gldi386v_get_script() -{ - extern ld_config_type config; - if (config.relocateable_output == true && - config.build_constructors == true) { - return gldi386v_script_option_Ur; - } - if (config.relocateable_output) { - return gldi386v_script_option_r; - } - - return gldi386v_script; -} -struct ld_emulation_xfer_struct ld_gldi386v_emulation = -{ - gldi386v_before_parse, - gldi386v_syslib, - gldi386v_hll, - gldi386v_after_parse, - gldi386v_after_allocation, - gldi386v_set_output_arch, - gldi386v_choose_target, - gldi386v_before_allocation, - gldi386v_get_script, -}; - diff --git a/ld/ldgldi386v.sc b/ld/ldgldi386v.sc deleted file mode 100755 index 9805f39f267..00000000000 --- a/ld/ldgldi386v.sc +++ /dev/null @@ -1,26 +0,0 @@ -/* $Id$ -*/ - -OUTPUT_FORMAT("i386coff") - -ENTRY(_start) -SECTIONS -{ - .text 0x000000d0 : { - *(.init) - *(.text) - *(.fini) - etext = .; - } - .data ((ADDR(.text) + SIZEOF(.text)) & 0x0fff) + ALIGN(0x00400000) : { - *(.data) - edata = .; - } - .bss (SIZEOF(.data) + ADDR(.data)) : { - *(.bss) - [COMMON] - end = ALIGN(0x8); - } - .comment : { *(.comment) } -} - diff --git a/ld/ldgldi386vUr.sc b/ld/ldgldi386vUr.sc deleted file mode 100755 index 9805f39f267..00000000000 --- a/ld/ldgldi386vUr.sc +++ /dev/null @@ -1,26 +0,0 @@ -/* $Id$ -*/ - -OUTPUT_FORMAT("i386coff") - -ENTRY(_start) -SECTIONS -{ - .text 0x000000d0 : { - *(.init) - *(.text) - *(.fini) - etext = .; - } - .data ((ADDR(.text) + SIZEOF(.text)) & 0x0fff) + ALIGN(0x00400000) : { - *(.data) - edata = .; - } - .bss (SIZEOF(.data) + ADDR(.data)) : { - *(.bss) - [COMMON] - end = ALIGN(0x8); - } - .comment : { *(.comment) } -} - diff --git a/ld/ldgldi386vr.sc b/ld/ldgldi386vr.sc deleted file mode 100755 index 9805f39f267..00000000000 --- a/ld/ldgldi386vr.sc +++ /dev/null @@ -1,26 +0,0 @@ -/* $Id$ -*/ - -OUTPUT_FORMAT("i386coff") - -ENTRY(_start) -SECTIONS -{ - .text 0x000000d0 : { - *(.init) - *(.text) - *(.fini) - etext = .; - } - .data ((ADDR(.text) + SIZEOF(.text)) & 0x0fff) + ALIGN(0x00400000) : { - *(.data) - edata = .; - } - .bss (SIZEOF(.data) + ADDR(.data)) : { - *(.bss) - [COMMON] - end = ALIGN(0x8); - } - .comment : { *(.comment) } -} - diff --git a/ld/ldgldm68kv.c b/ld/ldgldm68kv.c deleted file mode 100755 index 1f83d98feab..00000000000 --- a/ld/ldgldm68kv.c +++ /dev/null @@ -1,144 +0,0 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. - -This file is part of GLD, the Gnu Linker. - -GLD 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 1, or (at your option) -any later version. - -GLD 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 GLD; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - * $Id$ -*/ - -/* - * emulate the original gld running on an m68kv system - * - * Written by David Wood @ New York University - */ - - -#include "sysdep.h" -#include "bfd.h" - -#include "ld.h" -#include "config.h" -#include "ldemul.h" -#include "ldfile.h" -#include "ldmisc.h" - -extern boolean lang_float_flag; - - -extern enum bfd_architecture ldfile_output_architecture; -extern unsigned long ldfile_output_machine; -extern char *ldfile_output_machine_name; - -extern bfd *output_bfd; - - - -static void gldm68kv_before_parse() -{ -#ifndef NOTDEF /* Cross developing for now */ - ldfile_add_library_path("/usr/triton/lib/68kgcc-lib/lib"); - ldfile_add_library_path("/usr/triton/lib/68kgcc-lib/usr/lib"); - ldfile_add_library_path("/usr/triton/lib/68kgcc-lib/usr/local/lib"); -#endif - ldfile_output_architecture = bfd_arch_m68k; -} - - -static void -gldm68kv_after_parse() -{ - -} - -static void -gldm68kv_after_allocation() -{ - -} - -static void -gldm68kv_before_allocation() -{ - -} - -static void -gldm68kv_set_output_arch() -{ - /* Set the output architecture and machine if possible */ - unsigned long machine = 0; - bfd_set_arch_mach(output_bfd, ldfile_output_architecture, machine); -} - -static char * -gldm68kv_choose_target() -{ - char *from_outside = getenv(TARGET_ENVIRON); - if (from_outside != (char *)NULL) - return from_outside; - return GLDm68kv_TARGET; -} - -static void -gldm68kv_syslib() -{ - info("%S SYSLIB ignored\n"); -} - -static void -gldm68kv_hll(ignore) -char *ignore; -{ - info("%S HLL ignored\n"); -} - -static char *gldm68kv_script = -#include "ldgldm68kv.x" -; - -static char *gldm68kv_script_option_Ur = -#include "ldgldm68kvUr.x" -; -static char *gldm68kv_script_option_r = -#include "ldgldm68kvr.x" -; -static char *gldm68kv_get_script() -{ - extern ld_config_type config; - if (config.relocateable_output == true && - config.build_constructors == true) { - return gldm68kv_script_option_Ur; - } - if (config.relocateable_output) { - return gldm68kv_script_option_r; - } - - return gldm68kv_script; -} -struct ld_emulation_xfer_struct ld_gldm68kv_emulation = -{ - gldm68kv_before_parse, - gldm68kv_syslib, - gldm68kv_hll, - gldm68kv_after_parse, - gldm68kv_after_allocation, - gldm68kv_set_output_arch, - gldm68kv_choose_target, - gldm68kv_before_allocation, - gldm68kv_get_script, -}; - diff --git a/ld/ldgldm68kv.sc b/ld/ldgldm68kv.sc deleted file mode 100755 index 2e052cda3ac..00000000000 --- a/ld/ldgldm68kv.sc +++ /dev/null @@ -1,24 +0,0 @@ -/* $Id$ -*/ - -OUTPUT_FORMAT("m68kvcoff") - -ENTRY(__startup) -SECTIONS -{ - .text 0x001000a8 : { - *(.init) - *(.text) - *(.fini) - _etext = .; - } - .data ((ADDR(.text) + SIZEOF(.text)) % 0x2000) + ALIGN(0x00200000) : { - *(.data) - _edata = .; - } - .bss (SIZEOF(.data) + ADDR(.data)) : { - *(.bss) - [COMMON] - _end = ALIGN(0x8); - } -} diff --git a/ld/ldgldm68kvUr.sc b/ld/ldgldm68kvUr.sc deleted file mode 100755 index 2e052cda3ac..00000000000 --- a/ld/ldgldm68kvUr.sc +++ /dev/null @@ -1,24 +0,0 @@ -/* $Id$ -*/ - -OUTPUT_FORMAT("m68kvcoff") - -ENTRY(__startup) -SECTIONS -{ - .text 0x001000a8 : { - *(.init) - *(.text) - *(.fini) - _etext = .; - } - .data ((ADDR(.text) + SIZEOF(.text)) % 0x2000) + ALIGN(0x00200000) : { - *(.data) - _edata = .; - } - .bss (SIZEOF(.data) + ADDR(.data)) : { - *(.bss) - [COMMON] - _end = ALIGN(0x8); - } -} diff --git a/ld/ldgldm68kvr.sc b/ld/ldgldm68kvr.sc deleted file mode 100755 index 2e052cda3ac..00000000000 --- a/ld/ldgldm68kvr.sc +++ /dev/null @@ -1,24 +0,0 @@ -/* $Id$ -*/ - -OUTPUT_FORMAT("m68kvcoff") - -ENTRY(__startup) -SECTIONS -{ - .text 0x001000a8 : { - *(.init) - *(.text) - *(.fini) - _etext = .; - } - .data ((ADDR(.text) + SIZEOF(.text)) % 0x2000) + ALIGN(0x00200000) : { - *(.data) - _edata = .; - } - .bss (SIZEOF(.data) + ADDR(.data)) : { - *(.bss) - [COMMON] - _end = ALIGN(0x8); - } -} diff --git a/ld/ldgldm88kbcs.c b/ld/ldgldm88kbcs.c deleted file mode 100755 index f3e9d96d062..00000000000 --- a/ld/ldgldm88kbcs.c +++ /dev/null @@ -1,142 +0,0 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. - -This file is part of GLD, the Gnu Linker. - -GLD 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 1, or (at your option) -any later version. - -GLD 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 GLD; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - * $Id$ - * -*/ - -/* - * Written by Steve Chamberlain steve@cygnus.com - */ - - -#include "sysdep.h" -#include "bfd.h" - - -#include "ld.h" -#include "config.h" -#include "ldemul.h" -#include "ldfile.h" -#include "ldmisc.h" - -extern boolean lang_float_flag; - - -extern enum bfd_architecture ldfile_output_architecture; -extern unsigned long ldfile_output_machine; -extern char *ldfile_output_machine_name; - -extern bfd *output_bfd; - - - -static void gldm88kbcs_before_parse() -{ - extern char lprefix; - lprefix = '@'; -} - - -static void -gldm88kbcs_after_parse() -{ - -} - -static void -gldm88kbcs_after_allocation() -{ - -} - -static void -gldm88kbcs_before_allocation() -{ - -} - - -static void -gldm88kbcs_set_output_arch() -{ - /* Set the output architecture and machine if possible */ - bfd_set_arch_mach(output_bfd, ldfile_output_architecture, ldfile_output_machine); -} - -static char * -gldm88kbcs_choose_target() -{ - char *from_outside = getenv(TARGET_ENVIRON); - if (from_outside != (char *)NULL) - return from_outside; - return GLDM88KBCS_TARGET; -} - -static void -gldm88kbcs_syslib() -{ - info("%S SYSLIB ignored\n"); -} - -static void -gldm88kbcs_hll(ignore) -char *ignore; -{ - info("%S HLL ignored\n"); -} - -static char *gldm88kbcs_script = -#include "ldgldm88kbcs.x" -; - -static char *gldm88kbcs_script_option_Ur = -#include "ldgldm88kbcsUr.x" -; - -static char *gldm88kbcs_script_option_r = -#include "ldgldm88kbcsr.x" -; - -static char *gldm88kbcs_get_script() -{ - extern ld_config_type config; - if (config.relocateable_output == true && - config.build_constructors == true) { - return gldm88kbcs_script_option_Ur; - } - if (config.relocateable_output) { - return gldm88kbcs_script_option_r; - } - - return gldm88kbcs_script; -} -struct ld_emulation_xfer_struct ld_gldm88kbcs_emulation = -{ - gldm88kbcs_before_parse, - gldm88kbcs_syslib, - gldm88kbcs_hll, - gldm88kbcs_after_parse, - gldm88kbcs_after_allocation, - gldm88kbcs_set_output_arch, - gldm88kbcs_choose_target, - gldm88kbcs_before_allocation, - gldm88kbcs_get_script, -}; - diff --git a/ld/ldgldm88kbcs.sc b/ld/ldgldm88kbcs.sc deleted file mode 100755 index c4cb37ee1db..00000000000 --- a/ld/ldgldm88kbcs.sc +++ /dev/null @@ -1,40 +0,0 @@ -TARGET(m88kbcs) -OUTPUT_FORMAT(m88kbcs) -OUTPUT_ARCH(m88k) -ENTRY(__start) -SEARCH_DIR(/lib) -SEARCH_DIR(/usr/lib) -SEARCH_DIR(/usr/local/lib) -SECTIONS -{ - .text 0x10000 + SIZEOF_HEADERS : - { - __.text.start = .; - __.init.start = .; - LONG(0xf400c001) - __.init.end = .; - *(.text) - __.tdesc_start = .; - *(.tdesc) - __.text_end = .; - __.initp.start = .; - __.initp.end =.; - - _etext =.; - } - .data SIZEOF(.text) + ADDR(.text) + 0x400000: - { - *(.data) - _edata = .; - } - .bss SIZEOF(.data) + ADDR(.data) : - { - *(.bss) - [COMMON] - _end = .; - ___end = .; - } -} - - - diff --git a/ld/ldgldm88kbcs.script b/ld/ldgldm88kbcs.script deleted file mode 100755 index c4cb37ee1db..00000000000 --- a/ld/ldgldm88kbcs.script +++ /dev/null @@ -1,40 +0,0 @@ -TARGET(m88kbcs) -OUTPUT_FORMAT(m88kbcs) -OUTPUT_ARCH(m88k) -ENTRY(__start) -SEARCH_DIR(/lib) -SEARCH_DIR(/usr/lib) -SEARCH_DIR(/usr/local/lib) -SECTIONS -{ - .text 0x10000 + SIZEOF_HEADERS : - { - __.text.start = .; - __.init.start = .; - LONG(0xf400c001) - __.init.end = .; - *(.text) - __.tdesc_start = .; - *(.tdesc) - __.text_end = .; - __.initp.start = .; - __.initp.end =.; - - _etext =.; - } - .data SIZEOF(.text) + ADDR(.text) + 0x400000: - { - *(.data) - _edata = .; - } - .bss SIZEOF(.data) + ADDR(.data) : - { - *(.bss) - [COMMON] - _end = .; - ___end = .; - } -} - - - diff --git a/ld/ldgldm88kbcsUr.sc b/ld/ldgldm88kbcsUr.sc deleted file mode 100755 index 8d3f12b89ed..00000000000 --- a/ld/ldgldm88kbcsUr.sc +++ /dev/null @@ -1,31 +0,0 @@ -SCRIPT -SEARCH_DIR(/lib) -SEARCH_DIR(/usr/lib) -SEARCH_DIR(/usr/local/lib) -SECTIONS -{ - .text 0: - { - CREATE_OBJECT_SYMBOLS - *(.text) - } - .data SIZEOF(.text) + ADDR(.text) : - { - *(.data) - ___DTOR_LIST__ = . ; - LONG((___CTOR_LIST__ - .) / 4 -2) - *(___DTOR_LIST__) - LONG(0) - ___CTOR_LIST__ = . ; - LONG((___end_list__ - .) / 4 -2) - *(___CTOR_LIST__) - LONG(0) - ___end_list__ = . ; - } - .bss SIZEOF(.data) + ADDR(.data) : - { - *(.bss) - [COMMON] - } -} -ENDSCRIPT diff --git a/ld/ldgldm88kbcsUr.script b/ld/ldgldm88kbcsUr.script deleted file mode 100755 index 8d3f12b89ed..00000000000 --- a/ld/ldgldm88kbcsUr.script +++ /dev/null @@ -1,31 +0,0 @@ -SCRIPT -SEARCH_DIR(/lib) -SEARCH_DIR(/usr/lib) -SEARCH_DIR(/usr/local/lib) -SECTIONS -{ - .text 0: - { - CREATE_OBJECT_SYMBOLS - *(.text) - } - .data SIZEOF(.text) + ADDR(.text) : - { - *(.data) - ___DTOR_LIST__ = . ; - LONG((___CTOR_LIST__ - .) / 4 -2) - *(___DTOR_LIST__) - LONG(0) - ___CTOR_LIST__ = . ; - LONG((___end_list__ - .) / 4 -2) - *(___CTOR_LIST__) - LONG(0) - ___end_list__ = . ; - } - .bss SIZEOF(.data) + ADDR(.data) : - { - *(.bss) - [COMMON] - } -} -ENDSCRIPT diff --git a/ld/ldgldm88kbcsr.sc b/ld/ldgldm88kbcsr.sc deleted file mode 100755 index a3b39fe8573..00000000000 --- a/ld/ldgldm88kbcsr.sc +++ /dev/null @@ -1,20 +0,0 @@ -SEARCH_DIR(/lib) -SEARCH_DIR(/usr/lib) -SEARCH_DIR(/usr/local/lib) -SECTIONS -{ - .text 0: - { - CREATE_OBJECT_SYMBOLS - *(.text) - } - .data SIZEOF(.text) + ADDR(.text) : - { - *(.data) - } - .bss SIZEOF(.data) + ADDR(.data) : - { - *(.bss) - [COMMON] - } -} diff --git a/ld/ldgldm88kbcsr.script b/ld/ldgldm88kbcsr.script deleted file mode 100755 index a3b39fe8573..00000000000 --- a/ld/ldgldm88kbcsr.script +++ /dev/null @@ -1,20 +0,0 @@ -SEARCH_DIR(/lib) -SEARCH_DIR(/usr/lib) -SEARCH_DIR(/usr/local/lib) -SECTIONS -{ - .text 0: - { - CREATE_OBJECT_SYMBOLS - *(.text) - } - .data SIZEOF(.text) + ADDR(.text) : - { - *(.data) - } - .bss SIZEOF(.data) + ADDR(.data) : - { - *(.bss) - [COMMON] - } -} diff --git a/ld/ldgldr.sc b/ld/ldgldr.sc deleted file mode 100755 index a3b39fe8573..00000000000 --- a/ld/ldgldr.sc +++ /dev/null @@ -1,20 +0,0 @@ -SEARCH_DIR(/lib) -SEARCH_DIR(/usr/lib) -SEARCH_DIR(/usr/local/lib) -SECTIONS -{ - .text 0: - { - CREATE_OBJECT_SYMBOLS - *(.text) - } - .data SIZEOF(.text) + ADDR(.text) : - { - *(.data) - } - .bss SIZEOF(.data) + ADDR(.data) : - { - *(.bss) - [COMMON] - } -} diff --git a/ld/ldgldr.script b/ld/ldgldr.script deleted file mode 100755 index a3b39fe8573..00000000000 --- a/ld/ldgldr.script +++ /dev/null @@ -1,20 +0,0 @@ -SEARCH_DIR(/lib) -SEARCH_DIR(/usr/lib) -SEARCH_DIR(/usr/local/lib) -SECTIONS -{ - .text 0: - { - CREATE_OBJECT_SYMBOLS - *(.text) - } - .data SIZEOF(.text) + ADDR(.text) : - { - *(.data) - } - .bss SIZEOF(.data) + ADDR(.data) : - { - *(.bss) - [COMMON] - } -} diff --git a/ld/ldgram.y b/ld/ldgram.y deleted file mode 100644 index bd8d0b601ae..00000000000 --- a/ld/ldgram.y +++ /dev/null @@ -1,708 +0,0 @@ -%{ -/* - * $Id$ - * - * -*/ - -/* - This is a YACC grammer intended to parse a superset of the AT&T - linker scripting languaue. - - - Written by Steve Chamberlain steve@cygnus.com -*/ - - -#define DONTDECLARE_MALLOC - -#include "bfd.h" -#include "sysdep.h" -#include "ld.h" -#include "ldexp.h" -#include "ldver.h" -#include "ldlang.h" -#include "ldemul.h" -#include "ldfile.h" -#include "ldmisc.h" - - -#define YYDEBUG 1 - -boolean option_v; -extern unsigned int lineno; -extern boolean trace_files; -extern boolean write_map; - -boolean hex_mode; - -strip_symbols_type strip_symbols=STRIP_NONE; -discard_locals_type discard_locals=DISCARD_NONE; - - -lang_memory_region_type *region; - - -lang_memory_region_type *lang_memory_region_lookup(); -lang_output_section_statement_type *lang_output_section_statement_lookup(); - -#ifdef __STDC__ - -void lang_add_data(int type, union etree_union *exp); -void lang_enter_output_section_statement(char *output_section_statement_name, etree_type *address_exp, int flags, bfd_vma block_value); - -#else - -void lang_add_data(); -void lang_enter_output_section_statement(); - -#endif /* __STDC__ */ - -extern args_type command_line; -char *current_file; -boolean ldgram_want_filename = true; -boolean had_script = false; -boolean force_make_executable = false; - -boolean ldgram_in_script = false; -boolean ldgram_had_equals = false; -/* LOCALS */ - - - - -%} -%union { - bfd_vma integer; - int voidval; - char *name; - int token; - union etree_union *etree; - asection *section; - struct lang_output_section_statement_struct *output_section_statement; - union lang_statement_union **statement_ptr; - int lineno; - struct { - FILE *file; - char *name; - unsigned int lineno; - } state; - - -} - -%type exp opt_exp -%type fill_opt opt_block opt_type -%type memspec_opt -%token INT -%token NAME -%type length - -%right PLUSEQ MINUSEQ MULTEQ DIVEQ '=' LSHIFTEQ RSHIFTEQ ANDEQ OREQ -%right '?' ':' -%left OROR -%left ANDAND -%left '|' -%left '^' -%left '&' -%left EQ NE -%left '<' '>' LE GE -%left LSHIFT RSHIFT - -%left '+' '-' -%left '*' '/' '%' - -/*%token '+' '-' '*' '/' '%'*/ -%right UNARY -%left '(' -%token ALIGN_K BLOCK LONG SHORT BYTE -%token SECTIONS -%token '{' '}' -%token SIZEOF_HEADERS OUTPUT_FORMAT FORCE_COMMON_ALLOCATION OUTPUT_ARCH -%token SIZEOF_HEADERS -%token MEMORY -%token NOLOAD DSECT COPY INFO OVERLAY -%token NAME DEFINED TARGET_K SEARCH_DIR MAP ENTRY -%token OPTION_e OPTION_c OPTION_noinhibit_exec OPTION_s OPTION_S OPTION_sort_common -%token OPTION_format OPTION_F OPTION_u OPTION_Bstatic OPTION_N -%token SIZEOF NEXT ADDR -%token OPTION_d OPTION_dc OPTION_dp OPTION_x OPTION_X OPTION_defsym -%token OPTION_v OPTION_M OPTION_t STARTUP HLL SYSLIB FLOAT NOFLOAT -%token OPTION_n OPTION_r OPTION_o OPTION_b OPTION_R -%token OPTION_l OPTION_L OPTION_T OPTION_Aarch OPTION_Tfile OPTION_Texp -%token OPTION_Ur -%token ORIGIN FILL OPTION_g -%token LENGTH CREATE_OBJECT_SYMBOLS INPUT OUTPUT CONSTRUCTORS -%type assign_op - -%type filename - -%{ -ld_config_type config; -%} - -%% - - - -file: command_line { lang_final(); }; - - -filename: - NAME; - -command_line: - command_line command_line_option - | - ; - -command_line_option: - '{' - { ldgram_in_script = true; } - ifile_list - { ldgram_in_script = false; } - '}' - | OPTION_Bstatic { } - | OPTION_v - { - ldversion(); - option_v = true; - } - | OPTION_t { - trace_files = true; - } - | OPTION_M { - write_map = true; - } - | OPTION_n { - config.magic_demand_paged = false; - config.text_read_only = true; - } - | OPTION_N { - config.magic_demand_paged = false; - } - | OPTION_s { - strip_symbols = STRIP_ALL; - } - | OPTION_S { - strip_symbols = STRIP_DEBUGGER; - } - | OPTION_u NAME { - ldlang_add_undef($2); - } - - | OPTION_r { - config.relocateable_output = true; - config.build_constructors = false; - config.magic_demand_paged = false; - } - | OPTION_Ur { - config.relocateable_output = true; - config.build_constructors = true; - config.magic_demand_paged = false; - } - | OPTION_o filename - { - lang_add_output($2); - } - | OPTION_e NAME - { lang_add_entry($2); - } - | OPTION_X { - discard_locals = DISCARD_L; - } - | OPTION_x { - discard_locals = DISCARD_ALL; - } - - | OPTION_noinhibit_exec - { - force_make_executable = true; - } - | OPTION_sort_common { - config.sort_common = true; - } - | OPTION_d { - command_line.force_common_definition = true; - } - | OPTION_dc - { - command_line.force_common_definition = true; - } - | OPTION_g - { - /* Ignored */ - } - | OPTION_dp - { - command_line.force_common_definition = true; - } - | OPTION_format NAME - { - lang_add_target($2); - } - | OPTION_Texp - { - hex_mode =true; - } - INT - { - lang_section_start($1,exp_intop($3)); - hex_mode = false; - } - - | OPTION_Aarch - { - ldfile_add_arch($1); - } - | OPTION_b NAME - { - lang_add_target($2); - } - | OPTION_L - { - ldfile_add_library_path($1); - } - | OPTION_F - { - /* Ignore */ - } - | NAME - { lang_add_input_file($1,lang_input_file_is_file_enum, - (char *)NULL); } - | OPTION_c filename - { ldfile_open_command_file($2); } script_file - | OPTION_Tfile - { ldfile_open_command_file($1); } script_file - - | OPTION_T filename - { ldfile_open_command_file($2); } script_file - - | OPTION_l - { - lang_add_input_file($1, - lang_input_file_is_l_enum, - (char *)NULL); - } - | OPTION_R filename - { - lang_add_input_file($2, - lang_input_file_is_symbols_only_enum, - (char *)NULL); - } - | OPTION_defsym - { - } - NAME '=' - exp - { - lang_add_assignment(exp_assop($4,$3,$5)); - } - | '-' NAME - { info("%P%F Unrecognised option -%s\n", $2); } - - ; - - - - - - - - -script_file: - { ldgram_in_script = true; } - ifile_list '}' - { ldgram_in_script = false; } - - ; - - -ifile_list: - ifile_list ifile_p1 - | - ; - - - -ifile_p1: - memory - | sections - | startup - | high_level_library - | low_level_library - | floating_point_support - | statement_anywhere - | ';' - | TARGET_K '(' NAME ')' - { lang_add_target($3); } - | SEARCH_DIR '(' filename ')' - { ldfile_add_library_path($3); } - | OUTPUT '(' filename ')' - { lang_add_output($3); } - | OUTPUT_FORMAT '(' NAME ')' - { lang_add_output_format($3); } - | OUTPUT_ARCH '(' NAME ')' - { ldfile_set_output_arch($3); } - | FORCE_COMMON_ALLOCATION - { command_line.force_common_definition = true ; } - | INPUT '(' input_list ')' - | MAP '(' filename ')' - { lang_add_map($3); } - ; - -input_list: - NAME - { lang_add_input_file($1,lang_input_file_is_file_enum, - (char *)NULL); } - | input_list ',' NAME - { lang_add_input_file($3,lang_input_file_is_file_enum, - (char *)NULL); } - | input_list NAME - { lang_add_input_file($2, lang_input_file_is_file_enum, - (char *)NULL); } - ; - -sections: - SECTIONS '{'sec_or_group_p1 '}' - ; - -sec_or_group_p1: - sec_or_group_p1 section - | sec_or_group_p1 statement_anywhere - | - ; - -statement_anywhere: - ENTRY '(' NAME ')' - { lang_add_entry($3); } - | assignment end - ; - -file_NAME_list: - NAME - { lang_add_wild($1, current_file); } - | file_NAME_list opt_comma NAME - { lang_add_wild($3, current_file); } - ; - -input_section_spec: - NAME - { - lang_add_wild((char *)NULL, $1); - } - | '[' - { - current_file = (char *)NULL; - } - file_NAME_list - ']' - | NAME - { - current_file =$1; - } - '(' file_NAME_list ')' - | '*' - { - current_file = (char *)NULL; - } - '(' file_NAME_list ')' - ; - -statement: - statement assignment end - | statement CREATE_OBJECT_SYMBOLS - { - lang_add_attribute(lang_object_symbols_statement_enum); } - | statement ';' - | statement CONSTRUCTORS - { - lang_add_attribute(lang_constructors_statement_enum); } - - | statement input_section_spec - | statement length '(' exp ')' - { - lang_add_data($2,$4); - } - - | statement FILL '(' exp ')' - { - lang_add_fill - (exp_get_value_int($4, - 0, - "fill value", - lang_first_phase_enum)); - } - | - ; - -length: - LONG - { $$ = $1; } - | SHORT - { $$ = $1; } - | BYTE - { $$ = $1; } - ; - -fill_opt: - '=' exp - { - $$ = exp_get_value_int($2, - 0, - "fill value", - lang_first_phase_enum); - } - | { $$ = 0; } - ; - - - -assign_op: - PLUSEQ - { $$ = '+'; } - | MINUSEQ - { $$ = '-'; } - | MULTEQ - { $$ = '*'; } - | DIVEQ - { $$ = '/'; } - | LSHIFTEQ - { $$ = LSHIFT; } - | RSHIFTEQ - { $$ = RSHIFT; } - | ANDEQ - { $$ = '&'; } - | OREQ - { $$ = '|'; } - - ; - -end: ';' | ',' - ; - - -assignment: - NAME '=' exp - { - lang_add_assignment(exp_assop($2,$1,$3)); - } - | NAME assign_op exp - { - lang_add_assignment(exp_assop('=',$1,exp_binop($2,exp_nameop(NAME,$1),$3))); - } - - ; - - -opt_comma: - ',' | ; - - -memory: - MEMORY '{' memory_spec memory_spec_list '}' - ; - -memory_spec_list: - memory_spec_list memory_spec - | memory_spec_list ',' memory_spec - | - ; - - -memory_spec: - NAME - { region = lang_memory_region_lookup($1); } - attributes_opt ':' origin_spec opt_comma length_spec - - { - - - } - ; -origin_spec: - ORIGIN '=' exp - { region->current = - region->origin = - exp_get_vma($3, 0L,"origin", lang_first_phase_enum); } - ; -length_spec: - LENGTH '=' exp - { region->length = exp_get_vma($3, - ~((bfd_vma)0), - "length", - lang_first_phase_enum); - } - - -attributes_opt: - '(' NAME ')' - { - lang_set_flags(®ion->flags, $2); - } - | - - ; - -startup: - STARTUP '(' filename ')' - { lang_startup($3); } - ; - -high_level_library: - HLL '(' high_level_library_NAME_list ')' - | HLL '(' ')' - { ldemul_hll((char *)NULL); } - ; - -high_level_library_NAME_list: - high_level_library_NAME_list opt_comma filename - { ldemul_hll($3); } - | filename - { ldemul_hll($1); } - - ; - -low_level_library: - SYSLIB '(' low_level_library_NAME_list ')' - ; -low_level_library_NAME_list: - low_level_library_NAME_list opt_comma filename - { ldemul_syslib($3); } - | - ; - -floating_point_support: - FLOAT - { lang_float(true); } - | NOFLOAT - { lang_float(false); } - ; - - - - -exp : - '-' exp %prec UNARY - { $$ = exp_unop('-', $2); } - | '(' exp ')' - { $$ = $2; } - | NEXT '(' exp ')' %prec UNARY - { $$ = exp_unop($1,$3); } - | '!' exp %prec UNARY - { $$ = exp_unop('!', $2); } - | '+' exp %prec UNARY - { $$ = $2; } - | '~' exp %prec UNARY - { $$ = exp_unop('~', $2);} - - | exp '*' exp - { $$ = exp_binop('*', $1, $3); } - | exp '/' exp - { $$ = exp_binop('/', $1, $3); } - | exp '%' exp - { $$ = exp_binop('%', $1, $3); } - | exp '+' exp - { $$ = exp_binop('+', $1, $3); } - | exp '-' exp - { $$ = exp_binop('-' , $1, $3); } - | exp LSHIFT exp - { $$ = exp_binop(LSHIFT , $1, $3); } - | exp RSHIFT exp - { $$ = exp_binop(RSHIFT , $1, $3); } - | exp EQ exp - { $$ = exp_binop(EQ , $1, $3); } - | exp NE exp - { $$ = exp_binop(NE , $1, $3); } - | exp LE exp - { $$ = exp_binop(LE , $1, $3); } - | exp GE exp - { $$ = exp_binop(GE , $1, $3); } - | exp '<' exp - { $$ = exp_binop('<' , $1, $3); } - | exp '>' exp - { $$ = exp_binop('>' , $1, $3); } - | exp '&' exp - { $$ = exp_binop('&' , $1, $3); } - | exp '^' exp - { $$ = exp_binop('^' , $1, $3); } - | exp '|' exp - { $$ = exp_binop('|' , $1, $3); } - | exp '?' exp ':' exp - { $$ = exp_trinop('?' , $1, $3, $5); } - | exp ANDAND exp - { $$ = exp_binop(ANDAND , $1, $3); } - | exp OROR exp - { $$ = exp_binop(OROR , $1, $3); } - | DEFINED '(' NAME ')' - { $$ = exp_nameop(DEFINED, $3); } - | INT - { $$ = exp_intop($1); } - | SIZEOF_HEADERS - { $$ = exp_nameop(SIZEOF_HEADERS,0); } - - | SIZEOF '(' NAME ')' - { $$ = exp_nameop(SIZEOF,$3); } - | ADDR '(' NAME ')' - { $$ = exp_nameop(ADDR,$3); } - | ALIGN_K '(' exp ')' - { $$ = exp_unop(ALIGN_K,$3); } - | NAME - { $$ = exp_nameop(NAME,$1); } - ; - - - - -section: NAME opt_exp opt_type opt_block ':' opt_things'{' - { - lang_enter_output_section_statement($1,$2,$3,$4); - } - statement '}' fill_opt memspec_opt - { - lang_leave_output_section_statement($11, $12); - } - - ; - -opt_type: - '(' NOLOAD ')' { $$ = SEC_NO_FLAGS; } - | '(' DSECT ')' { $$ = 0; } - | '(' COPY ')' { $$ = 0; } - | '(' INFO ')' { $$ = 0; } - | '(' OVERLAY ')' { $$ = 0; } - | { $$ = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS; } - ; - -opt_things: - { - - } - ; - - - - - -opt_exp: - exp - { $$ = $1; } - | { $$= (etree_type *)NULL; } - ; - -opt_block: - BLOCK '(' exp ')' - { $$ = exp_get_value_int($3, - 1L, - "block", - lang_first_phase_enum); - } - | { $$ = 1; } - ; - -memspec_opt: - '>' NAME - { $$ = $2; } - | { $$ = "*default*"; } - ; - diff --git a/ld/ldindr.c b/ld/ldindr.c deleted file mode 100644 index 834c6275ac7..00000000000 --- a/ld/ldindr.c +++ /dev/null @@ -1,67 +0,0 @@ -/* ldindr.c - Handle indirect symbols. - - BFD supplies symbols to be indirected with the BFD_INDIRECT bit - set. Whenever the linker gets one of these, it calls add_indirect - with the symbol. We look up the symbol which this one dereferneces, - and stop if they are the same. If they are not the same, copy all - the information from the current to the dereffed symbol. Set the - indirect bit in the flag. From now on the ldsym_get stuff will - perform the indirection for us, at no charge. -*/ - - - -#include "bfd.h" -#include "sysdep.h" -#include "ld.h" -#include "ldsym.h" -#include "ldmisc.h" - - - -static asymbol ** -DEFUN(move_it,(a_list, b_list), -asymbol **a_list AND -asymbol **b_list) -{ - asymbol **head = a_list; - asymbol **cursor = head; - - if (a_list == 0) return b_list; - if (b_list == 0) return a_list; - - while (1) { - asymbol *ptr = cursor[0]; - asymbol **next = (asymbol **)(ptr->udata); - if (next == 0) { - ptr->udata = (PTR) b_list; - return head; - } - cursor = next; - } -} - -void -DEFUN(add_indirect,(ptr), -asymbol **ptr) -{ - ldsym_type *lgs = ldsym_get((*ptr)->name); - ldsym_type *new = ldsym_get(((asymbol *)((*ptr)->value))->name); - - /* If the mapping has already been done, stop now */ - if (lgs == new) return; - lgs->flags |= SYM_INDIRECT; - - new->scoms_chain = move_it(new->scoms_chain, lgs->scoms_chain); - lgs->scoms_chain = 0; - new->srefs_chain = move_it(new->srefs_chain, lgs->srefs_chain); - lgs->srefs_chain = 0; - new->sdefs_chain = move_it(new->sdefs_chain, lgs->sdefs_chain); - lgs->sdefs_chain = 0; - - lgs->sdefs_chain = (asymbol **)new; -} - - - diff --git a/ld/ldindr.h b/ld/ldindr.h deleted file mode 100644 index 209c8cf438c..00000000000 --- a/ld/ldindr.h +++ /dev/null @@ -1,4 +0,0 @@ - - -void EXFUN(do_indirect, (ldsym_type *)); -void EXFUN(add_indirect,(asymbol *)); diff --git a/ld/ldlang.c b/ld/ldlang.c deleted file mode 100644 index c7ceba23781..00000000000 --- a/ld/ldlang.c +++ /dev/null @@ -1,2404 +0,0 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. - -This file is part of GLD, the Gnu Linker. - -GLD 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 1, or (at your option) -any later version. - -GLD 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 GLD; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* $Id$ - * -*/ - -#include "bfd.h" -#include "sysdep.h" - -#include "ld.h" -#include "ldmain.h" -#include "ldsym.h" -#include "ldgram.h" -#include "ldwarn.h" -#include "ldlang.h" -#include "ldexp.h" -#include "ldemul.h" -#include "ldlex.h" -#include "ldmisc.h" -/* FORWARDS */ -PROTO(static void, print_statements,(void)); -PROTO(static void, print_statement,(lang_statement_union_type *, - lang_output_section_statement_type *)); - - -/* LOCALS */ -static CONST char *startup_file; -static lang_statement_list_type input_file_chain; - -/* Points to the last statement in the .data section, so we can add - stuff to the data section without pain */ -static lang_statement_list_type end_of_data_section_statement_list; - -/* List of statements needed to handle consxtructors */ -static lang_statement_list_type constructor_list; - -static boolean placed_commons = false; -static lang_output_section_statement_type *default_common_section; -static boolean map_option_f; -static bfd_vma print_dot; -static lang_input_statement_type *first_file; -static lang_statement_list_type lang_output_section_statement; -static CONST char *current_target; -static CONST char *output_target; -static size_t longest_section_name = 8; -static asection common_section; -static section_userdata_type common_section_userdata; -static lang_statement_list_type statement_list; -/* EXPORTS */ - -lang_statement_list_type *stat_ptr = &statement_list; -lang_input_statement_type *script_file = 0; -boolean option_longmap = false; -lang_statement_list_type file_chain = {0}; -CONST char *entry_symbol = 0; -bfd_size_type largest_section = 0; -boolean lang_has_input_file = false; -lang_output_section_statement_type *create_object_symbols = 0; -boolean had_output_filename = false; -boolean lang_float_flag = false; -/* IMPORTS */ -extern char *default_target; - -extern unsigned int undefined_global_sym_count; -extern char *current_file; -extern bfd *output_bfd; -extern enum bfd_architecture ldfile_output_architecture; -extern unsigned long ldfile_output_machine; -extern char *ldfile_output_machine_name; -extern ldsym_type *symbol_head; -extern unsigned int commons_pending; -extern args_type command_line; -extern ld_config_type config; -extern boolean had_script; -extern boolean write_map; - - -#ifdef __STDC__ -#define cat(a,b) a##b -#else -#define cat(a,b) a/**/b -#endif - -#define new_stat(x,y) (cat(x,_type)*) new_statement(cat(x,_enum), sizeof(cat(x,_type)),y) - -#define outside_section_address(q) ( (q)->output_offset + (q)->output_section->vma) - -#define outside_symbol_address(q) ((q)->value + outside_section_address(q->section)) - -void EXFUN(lang_add_data,( int type , union etree_union *exp)); - -static void -DEFUN(print_size,(value), - size_t value) -{ - printf("%5x", (unsigned)value); -} -static void -DEFUN(print_alignment,(value), - unsigned int value) -{ - printf("2**%1u",value); -} -static void -DEFUN(print_fill,(value), - fill_type value) -{ - printf("%04x",(unsigned)value); -} - - -static void -DEFUN(print_section,(name), - CONST char *CONST name) -{ - printf("%*s", -longest_section_name, name); -} - -/*---------------------------------------------------------------------- - lang_for_each_statement walks the parse tree and calls the provided - function for each node -*/ - -static void -DEFUN(lang_for_each_statement_worker,(func, s), - void (*func)() AND - lang_statement_union_type *s) -{ - for (; s != (lang_statement_union_type *)NULL ; s = s->next) - { - func(s); - - switch (s->header.type) { - case lang_constructors_statement_enum: - lang_for_each_statement_worker(func, constructor_list.head); - break; - case lang_output_section_statement_enum: - lang_for_each_statement_worker - (func, - s->output_section_statement.children.head); - break; - case lang_wild_statement_enum: - lang_for_each_statement_worker - (func, - s->wild_statement.children.head); - break; - case lang_data_statement_enum: - case lang_object_symbols_statement_enum: - case lang_output_statement_enum: - case lang_target_statement_enum: - case lang_input_section_enum: - case lang_input_statement_enum: - case lang_fill_statement_enum: - case lang_assignment_statement_enum: - case lang_padding_statement_enum: - case lang_address_statement_enum: - break; - default: - FAIL(); - break; - } - } -} - -void -DEFUN(lang_for_each_statement,(func), - void (*func)()) -{ - lang_for_each_statement_worker(func, - statement_list.head); -} -/*----------------------------------------------------------------------*/ -static void -DEFUN(lang_list_init,(list), - lang_statement_list_type *list) -{ -list->head = (lang_statement_union_type *)NULL; -list->tail = &list->head; -} - - -/*---------------------------------------------------------------------- - - build a new statement node for the parse tree - - */ - -static -lang_statement_union_type* -DEFUN(new_statement,(type, size, list), - enum statement_enum type AND - bfd_size_type size AND - lang_statement_list_type *list) -{ - lang_statement_union_type *new = (lang_statement_union_type *) - ldmalloc(size); - new->header.type = type; - new->header.next = (lang_statement_union_type *)NULL; - lang_statement_append(list, new, &new->header.next); - return new; -} - -/* - Build a new input file node for the language. There are several ways - in which we treat an input file, eg, we only look at symbols, or - prefix it with a -l etc. - - We can be supplied with requests for input files more than once; - they may, for example be split over serveral lines like foo.o(.text) - foo.o(.data) etc, so when asked for a file we check that we havn't - got it already so we don't duplicate the bfd. - - */ -static lang_input_statement_type * -DEFUN(new_afile, (name, file_type, target), - CONST char *CONST name AND - CONST lang_input_file_enum_type file_type AND - CONST char *CONST target) -{ - lang_input_statement_type *p = new_stat(lang_input_statement, - stat_ptr); - lang_has_input_file = true; - p->target = target; - switch (file_type) { - case lang_input_file_is_symbols_only_enum: - p->filename = name; - p->is_archive =false; - p->real = true; - p->local_sym_name= name; - p->just_syms_flag = true; - p->search_dirs_flag = false; - break; - case lang_input_file_is_fake_enum: - p->filename = name; - p->is_archive =false; - p->real = false; - p->local_sym_name= name; - p->just_syms_flag = false; - p->search_dirs_flag =false; - break; - case lang_input_file_is_l_enum: - p->is_archive = true; - p->filename = name; - p->real = true; - p->local_sym_name = concat("-l",name,""); - p->just_syms_flag = false; - p->search_dirs_flag = true; - break; - case lang_input_file_is_search_file_enum: - case lang_input_file_is_marker_enum: - p->filename = name; - p->is_archive =false; - p->real = true; - p->local_sym_name= name; - p->just_syms_flag = false; - p->search_dirs_flag =true; - break; - case lang_input_file_is_file_enum: - p->filename = name; - p->is_archive =false; - p->real = true; - p->local_sym_name= name; - p->just_syms_flag = false; - p->search_dirs_flag =false; - break; - default: - FAIL(); - } - p->asymbols = (asymbol **)NULL; - p->superfile = (lang_input_statement_type *)NULL; - p->next_real_file = (lang_statement_union_type*)NULL; - p->next = (lang_statement_union_type*)NULL; - p->symbol_count = 0; - p->common_output_section = (asection *)NULL; - lang_statement_append(&input_file_chain, - (lang_statement_union_type *)p, - &p->next_real_file); - return p; -} - - - -lang_input_statement_type * -DEFUN(lang_add_input_file,(name, file_type, target), - char *name AND - lang_input_file_enum_type file_type AND - char *target) -{ - /* Look it up or build a new one */ - lang_has_input_file = true; -#if 0 - lang_input_statement_type *p; - - for (p = (lang_input_statement_type *)input_file_chain.head; - p != (lang_input_statement_type *)NULL; - p = (lang_input_statement_type *)(p->next_real_file)) - { - /* Sometimes we have incomplete entries in here */ - if (p->filename != (char *)NULL) { - if(strcmp(name,p->filename) == 0) return p; - } - - } -#endif - return new_afile(name, file_type, target); -} - - -/* Build enough state so that the parser can build its tree */ -void -DEFUN_VOID(lang_init) -{ - - stat_ptr= &statement_list; - lang_list_init(stat_ptr); - - lang_list_init(&input_file_chain); - lang_list_init(&lang_output_section_statement); - lang_list_init(&file_chain); - first_file = lang_add_input_file((char *)NULL, - lang_input_file_is_marker_enum, - (char *)NULL); -} - - -/*---------------------------------------------------------------------- - A region is an area of memory declared with the - MEMORY { name:org=exp, len=exp ... } - syntax. - - We maintain a list of all the regions here - - If no regions are specified in the script, then the default is used - which is created when looked up to be the entire data space -*/ - -static lang_memory_region_type *lang_memory_region_list; -static lang_memory_region_type **lang_memory_region_list_tail = &lang_memory_region_list; - -lang_memory_region_type * -DEFUN(lang_memory_region_lookup,(name), - CONST char *CONST name) -{ - - lang_memory_region_type *p = lang_memory_region_list; - for (p = lang_memory_region_list; - p != ( lang_memory_region_type *)NULL; - p = p->next) { - if (strcmp(p->name, name) == 0) { - return p; - } - } - if (strcmp(name,"*default*")==0) { - /* This is the default region, dig out first one on the list */ - if (lang_memory_region_list != (lang_memory_region_type*)NULL){ - return lang_memory_region_list; - } - } - { - lang_memory_region_type *new = - (lang_memory_region_type *)ldmalloc((bfd_size_type)(sizeof(lang_memory_region_type))); - new->name = buystring(name); - new->next = (lang_memory_region_type *)NULL; - - *lang_memory_region_list_tail = new; - lang_memory_region_list_tail = &new->next; - new->origin = 0; - new->length = ~0; - new->current = 0; - return new; - } -} - - -lang_output_section_statement_type * -DEFUN(lang_output_section_find,(name), - CONST char * CONST name) -{ - lang_statement_union_type *u; - lang_output_section_statement_type *lookup; - - for (u = lang_output_section_statement.head; - u != (lang_statement_union_type *)NULL; - u = lookup->next) - { - lookup = &u->output_section_statement; - if (strcmp(name, lookup->name)==0) { - return lookup; - } - } - return (lang_output_section_statement_type *)NULL; -} - -lang_output_section_statement_type * -DEFUN(lang_output_section_statement_lookup,(name), - CONST char * CONST name) -{ - lang_output_section_statement_type *lookup; - lookup =lang_output_section_find(name); - if (lookup == (lang_output_section_statement_type *)NULL) { - - lookup =(lang_output_section_statement_type *) - new_stat(lang_output_section_statement, stat_ptr); - lookup->region = (lang_memory_region_type *)NULL; - lookup->fill = 0; - lookup->block_value = 1; - lookup->name = name; - - lookup->next = (lang_statement_union_type*)NULL; - lookup->bfd_section = (asection *)NULL; - lookup->processed = false; - lookup->addr_tree = (etree_type *)NULL; - lang_list_init(&lookup->children); - - lang_statement_append(&lang_output_section_statement, - (lang_statement_union_type *)lookup, - &lookup->next); - } - return lookup; -} - - - - - -static void -DEFUN(print_flags, (outfile, ignore_flags), - FILE *outfile AND - int *ignore_flags) -{ - fprintf(outfile,"("); -#if 0 - if (flags->flag_read) fprintf(outfile,"R"); - if (flags->flag_write) fprintf(outfile,"W"); - if (flags->flag_executable) fprintf(outfile,"X"); - if (flags->flag_loadable) fprintf(outfile,"L"); -#endif - fprintf(outfile,")"); -} - -void -DEFUN(lang_map,(outfile), - FILE *outfile) -{ - lang_memory_region_type *m; - fprintf(outfile,"**MEMORY CONFIGURATION**\n\n"); -#ifdef HOST_64_BIT - fprintf(outfile,"name\t\torigin\t\tlength\t\tattributes\n"); -#else - fprintf(outfile,"name\t\torigin length\t\tattributes\n"); -#endif - for (m = lang_memory_region_list; - m != (lang_memory_region_type *)NULL; - m = m->next) - { - fprintf(outfile,"%-16s", m->name); - print_address(m->origin); - print_space(); - print_address(m->length); - print_space(); - print_flags(outfile, &m->flags); - fprintf(outfile,"\n"); - } - fprintf(outfile,"\n\n**LINK EDITOR MEMORY MAP**\n\n"); - fprintf(outfile,"output input virtual\n"); - fprintf(outfile,"section section address tsize\n\n"); - - print_statements(); - -} - -/* - * - */ -static void -DEFUN(init_os,(s), - lang_output_section_statement_type *s) -{ - section_userdata_type *new = - (section_userdata_type *) - ldmalloc((bfd_size_type)(sizeof(section_userdata_type))); - - s->bfd_section = bfd_get_section_by_name(output_bfd, s->name); - if (s->bfd_section == (asection *)NULL) - s->bfd_section = bfd_make_section(output_bfd, s->name); - if (s->bfd_section == (asection *)NULL) { - info("%P%F output format %s cannot represent section called %s\n", - output_bfd->xvec->name, - s->name); - } - s->bfd_section->output_section = s->bfd_section; -/* s->bfd_section->flags = s->flags;*/ - - /* We initialize an output sections output offset to minus its own */ - /* vma to allow us to output a section through itself */ - s->bfd_section->output_offset = 0; - get_userdata( s->bfd_section) = (PTR)new; -} - -/*********************************************************************** - The wild routines. - - These expand statements like *(.text) and foo.o to a list of - explicit actions, like foo.o(.text), bar.o(.text) and - foo.o(.text,.data) . - - The toplevel routine, wild, takes a statement, section, file and - target. If either the section or file is null it is taken to be the - wildcard. Seperate lang_input_section statements are created for - each part of the expanstion, and placed after the statement provided. - -*/ - -static void -DEFUN(wild_doit,(ptr, section, output, file), - lang_statement_list_type *ptr AND - asection *section AND - lang_output_section_statement_type *output AND - lang_input_statement_type *file) -{ - if(output->bfd_section == (asection *)NULL) - { - init_os(output); - } - - if (section != (asection *)NULL - && section->output_section == (asection *)NULL) { - /* Add a section reference to the list */ - lang_input_section_type *new = new_stat(lang_input_section, ptr); - - new->section = section; - new->ifile = file; - section->output_section = output->bfd_section; - section->output_section->flags |= section->flags; - if (section->alignment_power > output->bfd_section->alignment_power) { - output->bfd_section->alignment_power = section->alignment_power; - } - } -} - -static asection * -DEFUN(our_bfd_get_section_by_name,(abfd, section), -bfd *abfd AND -CONST char *section) -{ - return bfd_get_section_by_name(abfd, section); -} - -static void -DEFUN(wild_section,(ptr, section, file , output), - lang_wild_statement_type *ptr AND - CONST char *section AND - lang_input_statement_type *file AND - lang_output_section_statement_type *output) -{ - asection *s; - if (file->just_syms_flag == false) { - if (section == (char *)NULL) { - /* Do the creation to all sections in the file */ - for (s = file->the_bfd->sections; s != (asection *)NULL; s=s->next) { - wild_doit(&ptr->children, s, output, file); - } - } - else { - /* Do the creation to the named section only */ - wild_doit(&ptr->children, - our_bfd_get_section_by_name(file->the_bfd, section), - output, file); - } - } -} - - -/* passed a file name (which must have been seen already and added to - the statement tree. We will see if it has been opened already and - had its symbols read. If not then we'll read it. - - Archives are pecuilar here. We may open them once, but if they do - not define anything we need at the time, they won't have all their - symbols read. If we need them later, we'll have to redo it. - */ -static -lang_input_statement_type * -DEFUN(lookup_name,(name), - CONST char * CONST name) -{ - lang_input_statement_type *search; - for(search = (lang_input_statement_type *)input_file_chain.head; - search != (lang_input_statement_type *)NULL; - search = (lang_input_statement_type *)search->next_real_file) - { - if (search->filename == (char *)NULL && name == (char *)NULL) { - return search; - } - if (search->filename != (char *)NULL && name != (char *)NULL) { - if (strcmp(search->filename, name) == 0) { - ldmain_open_file_read_symbol(search); - return search; - } - } - } - - /* There isn't an afile entry for this file yet, this must be - because the name has only appeared inside a load script and not - on the command line */ - search = new_afile(name, lang_input_file_is_file_enum, default_target); - ldmain_open_file_read_symbol(search); - return search; - - -} - -static void -DEFUN(wild,(s, section, file, target, output), - lang_wild_statement_type *s AND - CONST char *CONST section AND - CONST char *CONST file AND - CONST char *CONST target AND - lang_output_section_statement_type *output) -{ - lang_input_statement_type *f; - if (file == (char *)NULL) { - /* Perform the iteration over all files in the list */ - for (f = (lang_input_statement_type *)file_chain.head; - f != (lang_input_statement_type *)NULL; - f = (lang_input_statement_type *)f->next) { - wild_section(s, section, f, output); - } - } - else { - /* Perform the iteration over a single file */ - wild_section( s, section, lookup_name(file), output); - } - if (section != (char *)NULL - && strcmp(section,"COMMON") == 0 - && default_common_section == (lang_output_section_statement_type*)NULL) - { - /* Remember the section that common is going to incase we later - get something which doesn't know where to put it */ - default_common_section = output; - } -} - -/* - read in all the files - */ -static bfd * -DEFUN(open_output,(name), - CONST char *CONST name) -{ - extern CONST char *output_filename; - bfd *output; - if (output_target == (char *)NULL) { - if (current_target != (char *)NULL) - output_target = current_target; - else - output_target = default_target; - } - output = bfd_openw(name, output_target); - output_filename = name; - - if (output == (bfd *)NULL) - { - if (bfd_error == invalid_target) { - info("%P%F target %s not found\n", output_target); - } - info("%P%F problem opening output file %s, %E", name); - } - - output->flags |= D_PAGED; - bfd_set_format(output, bfd_object); - return output; -} - - - - -static void -DEFUN(ldlang_open_output,(statement), - lang_statement_union_type *statement) -{ - switch (statement->header.type) - { - case lang_output_statement_enum: - output_bfd = open_output(statement->output_statement.name); - ldemul_set_output_arch(); - if (config.magic_demand_paged && !config.relocateable_output) - output_bfd->flags |= ~D_PAGED; - else - output_bfd->flags &= ~D_PAGED; - if (config.text_read_only) - output_bfd->flags |= WP_TEXT; - else - output_bfd->flags &= ~WP_TEXT; - break; - - case lang_target_statement_enum: - current_target = statement->target_statement.target; - break; - default: - break; - } -} - -static void -DEFUN(open_input_bfds,(statement), - lang_statement_union_type *statement) -{ - switch (statement->header.type) - { - case lang_target_statement_enum: - current_target = statement->target_statement.target; - break; - case lang_wild_statement_enum: - /* Maybe we should load the file's symbols */ - if (statement->wild_statement.filename) - { - (void) lookup_name(statement->wild_statement.filename); - } - break; - case lang_input_statement_enum: - if (statement->input_statement.real == true) - { - statement->input_statement.target = current_target; - lookup_name(statement->input_statement.filename); - } - break; - default: - break; - } -} -/* If there are [COMMONS] statements, put a wild one into the bss section */ - -static void -lang_reasonable_defaults() -{ -#if 0 - lang_output_section_statement_lookup(".text"); - lang_output_section_statement_lookup(".data"); - - default_common_section = - lang_output_section_statement_lookup(".bss"); - - - if (placed_commons == false) { - lang_wild_statement_type *new = - new_stat(lang_wild_statement, - &default_common_section->children); - new->section_name = "COMMON"; - new->filename = (char *)NULL; - lang_list_init(&new->children); - } -#endif - -} - -/* - Add the supplied name to the symbol table as an undefined reference. - Remove items from the chain as we open input bfds - */ -typedef struct ldlang_undef_chain_list { - struct ldlang_undef_chain_list *next; - char *name; -} ldlang_undef_chain_list_type; - -static ldlang_undef_chain_list_type *ldlang_undef_chain_list_head; - -void -DEFUN(ldlang_add_undef,(name), - CONST char *CONST name) -{ - ldlang_undef_chain_list_type *new = - (ldlang_undef_chain_list_type - *)ldmalloc((bfd_size_type)(sizeof(ldlang_undef_chain_list_type))); - - new->next = ldlang_undef_chain_list_head; - ldlang_undef_chain_list_head = new; - - new->name = buystring(name); -} -/* Run through the list of undefineds created above and place them - into the linker hash table as undefined symbols belonging to the - script file. -*/ -static void -DEFUN_VOID(lang_place_undefineds) -{ - ldlang_undef_chain_list_type *ptr = ldlang_undef_chain_list_head; - while (ptr != (ldlang_undef_chain_list_type*)NULL) { - ldsym_type *sy = ldsym_get(ptr->name); - asymbol *def; - asymbol **def_ptr = (asymbol **)ldmalloc((bfd_size_type)(sizeof(asymbol **))); - def = (asymbol *)bfd_make_empty_symbol(script_file->the_bfd); - *def_ptr= def; - def->name = ptr->name; - def->flags = BSF_UNDEFINED; - def->section = (asection *)NULL; - Q_enter_global_ref(def_ptr); - ptr = ptr->next; - } -} - - - -/* Copy important data from out internal form to the bfd way. Also - create a section for the dummy file - */ - -static void -DEFUN_VOID(lang_create_output_section_statements) -{ - lang_statement_union_type*os; - for (os = lang_output_section_statement.head; - os != (lang_statement_union_type*)NULL; - os = os->output_section_statement.next) { - lang_output_section_statement_type *s = - &os->output_section_statement; - init_os(s); - } - -} - -static void -DEFUN_VOID(lang_init_script_file) -{ - script_file = lang_add_input_file("script file", - lang_input_file_is_fake_enum, - (char *)NULL); - script_file->the_bfd = bfd_create("script file", output_bfd); - script_file->symbol_count = 0; - script_file->the_bfd->sections = output_bfd->sections; -} - - - - -/* Open input files and attatch to output sections */ -static void -DEFUN(map_input_to_output_sections,(s, target, output_section_statement), - lang_statement_union_type *s AND - CONST char *target AND - lang_output_section_statement_type *output_section_statement) -{ - for (; s != (lang_statement_union_type *)NULL ; s = s->next) - { - switch (s->header.type) { - - - case lang_wild_statement_enum: - wild(&s->wild_statement, s->wild_statement.section_name, - s->wild_statement.filename, target, - output_section_statement); - - break; - case lang_constructors_statement_enum: - map_input_to_output_sections(constructor_list.head, - target, - output_section_statement); - break; - case lang_output_section_statement_enum: - map_input_to_output_sections(s->output_section_statement.children.head, - target, - &s->output_section_statement); - break; - case lang_output_statement_enum: - break; - case lang_target_statement_enum: - target = s->target_statement.target; - break; - case lang_fill_statement_enum: - case lang_input_section_enum: - case lang_object_symbols_statement_enum: - case lang_data_statement_enum: - case lang_assignment_statement_enum: - case lang_padding_statement_enum: - break; - case lang_afile_asection_pair_statement_enum: - FAIL(); - break; - case lang_address_statement_enum: - /* Mark the specified section with the supplied address */ - { - lang_output_section_statement_type *os = - lang_output_section_statement_lookup - (s->address_statement.section_name); - os->addr_tree = s->address_statement.address; - if (os->bfd_section == (asection *)NULL) { - info("%P%F can't set the address of undefined section %s\n", - s->address_statement.section_name); - } - } - break; - case lang_input_statement_enum: - /* A standard input statement, has no wildcards */ - /* ldmain_open_file_read_symbol(&s->input_statement);*/ - break; - } - } -} - - - - - -static void -DEFUN(print_output_section_statement,(output_section_statement), - lang_output_section_statement_type *output_section_statement) -{ - asection *section = output_section_statement->bfd_section; - print_nl(); - print_section(output_section_statement->name); - - if (section) { - print_dot = section->vma; - print_space(); - print_section(""); - print_space(); - print_address(section->vma); - print_space(); - print_size(section->size); - print_space(); - print_alignment(section->alignment_power); - print_space(); -#if 0 - printf("%s flags", output_section_statement->region->name); - print_flags(stdout, &output_section_statement->flags); -#endif - if (section->flags & SEC_LOAD) - printf("load "); - if (section->flags & SEC_ALLOC) - printf("alloc "); - if (section->flags & SEC_RELOC) - printf("reloc "); - if (section->flags & SEC_HAS_CONTENTS) - printf("contents "); - - } - else { - printf("No attached output section"); - } - print_nl(); - print_statement(output_section_statement->children.head, - output_section_statement); - -} - -static void -DEFUN(print_assignment,(assignment, output_section), - lang_assignment_statement_type *assignment AND - lang_output_section_statement_type *output_section) -{ - etree_value_type result; - print_section(""); - print_space(); - print_section(""); - print_space(); - print_address(print_dot); - print_space(); - result = exp_fold_tree(assignment->exp->assign.src, - output_section, - lang_final_phase_enum, - print_dot, - &print_dot); - - if (result.valid) { - print_address(result.value); - } - else - { - printf("*undefined*"); - } - print_space(); - exp_print_tree(stdout, assignment->exp); - printf("\n"); -} - -static void -DEFUN(print_input_statement,(statm), - lang_input_statement_type *statm) -{ - if (statm->filename != (char *)NULL) { - printf("LOAD %s\n",statm->filename); - } -} - -static void -DEFUN(print_symbol,(q), - asymbol *q) -{ - print_section(""); - printf(" "); - print_section(""); - printf(" "); - print_address(outside_symbol_address(q)); - printf(" %s", q->name ? q->name : " "); - print_nl(); -} - -static void -DEFUN(print_input_section,(in), - lang_input_section_type *in) -{ - asection *i = in->section; - - if(i->size != 0) { - print_section(""); - printf(" "); - print_section(i->name); - printf(" "); - if (i->output_section) { - print_address(i->output_section->vma + i->output_offset); - printf(" "); - print_size(i->size); - printf(" "); - print_alignment(i->alignment_power); - printf(" "); - if (in->ifile) { - - bfd *abfd = in->ifile->the_bfd; - if (in->ifile->just_syms_flag == true) { - printf("symbols only "); - } - - printf(" %s ",abfd->xvec->name); - if(abfd->my_archive != (bfd *)NULL) { - printf("[%s]%s", abfd->my_archive->filename, - abfd->filename); - } - else { - printf("%s", abfd->filename); - } - printf("(overhead %d bytes)", (int)bfd_alloc_size(abfd)); - print_nl(); - - /* Find all the symbols in this file defined in this section */ - { - asymbol **p; - for (p = in->ifile->asymbols; *p; p++) { - asymbol *q = *p; - - if (bfd_get_section(q) == i && q->flags & BSF_GLOBAL) { - print_symbol(q); - } - } - } - } - else { - print_nl(); - } - - - print_dot = outside_section_address(i) + i->size; - } - else { - printf("No output section allocated\n"); - } - } -} - -static void -DEFUN(print_fill_statement,(fill), - lang_fill_statement_type *fill) -{ - printf("FILL mask "); - print_fill( fill->fill); -} - -static void -DEFUN(print_data_statement,(data), - lang_data_statement_type *data) -{ -/* bfd_vma value; */ - print_section(""); - print_space(); - print_section(""); - print_space(); -/* ASSERT(print_dot == data->output_vma);*/ - - print_address(data->output_vma); - print_space(); - print_address(data->value); - print_space(); - switch (data->type) { - case BYTE : - printf("BYTE "); - print_dot += BYTE_SIZE; - break; - case SHORT: - printf("SHORT "); - print_dot += SHORT_SIZE; - break; - case LONG: - printf("LONG "); - print_dot += LONG_SIZE; - break; - } - - exp_print_tree(stdout, data->exp); - - printf("\n"); -} - - -static void -DEFUN(print_padding_statement,(s), - lang_padding_statement_type *s) -{ - print_section(""); - print_space(); - print_section("*fill*"); - print_space(); - print_address(s->output_offset + s->output_section->vma); - print_space(); - print_size(s->size); - print_space(); - print_fill(s->fill); - print_nl(); -} - -static void -DEFUN(print_wild_statement,(w,os), - lang_wild_statement_type *w AND - lang_output_section_statement_type *os) -{ - printf(" from "); - if (w->filename != (char *)NULL) { - printf("%s",w->filename); - } - else { - printf("*"); - } - if (w->section_name != (char *)NULL) { - printf("(%s)",w->section_name); - } - else { - printf("(*)"); - } - print_nl(); - print_statement(w->children.head, os); - -} -static void -DEFUN(print_statement,(s, os), - lang_statement_union_type *s AND - lang_output_section_statement_type *os) -{ - while (s) { - switch (s->header.type) { - case lang_constructors_statement_enum: - printf("constructors:\n"); -print_statement(constructor_list.head, os); -break; - - case lang_wild_statement_enum: - print_wild_statement(&s->wild_statement, os); - break; - default: - printf("Fail with %d\n",s->header.type); - FAIL(); - break; - case lang_address_statement_enum: - printf("address\n"); - break; - break; - case lang_object_symbols_statement_enum: - printf("object symbols\n"); - break; - case lang_fill_statement_enum: - print_fill_statement(&s->fill_statement); - break; - case lang_data_statement_enum: - print_data_statement(&s->data_statement); - break; - case lang_input_section_enum: - print_input_section(&s->input_section); - break; - case lang_padding_statement_enum: - print_padding_statement(&s->padding_statement); - break; - case lang_output_section_statement_enum: - print_output_section_statement(&s->output_section_statement); - break; - case lang_assignment_statement_enum: - print_assignment(&s->assignment_statement, - os); - break; - - - case lang_target_statement_enum: - printf("TARGET(%s)\n", s->target_statement.target); - break; - case lang_output_statement_enum: - printf("OUTPUT(%s %s)\n", - s->output_statement.name, - output_target); - break; - case lang_input_statement_enum: - print_input_statement(&s->input_statement); - break; - case lang_afile_asection_pair_statement_enum: - FAIL(); - break; - } - s = s->next; - } -} - - -static void -DEFUN_VOID(print_statements) -{ - print_statement(statement_list.head, - (lang_output_section_statement_type *)NULL); -} - -static bfd_vma -DEFUN(insert_pad,(this_ptr, fill, power, output_section_statement, dot), - lang_statement_union_type **this_ptr AND - fill_type fill AND - unsigned int power AND - asection * output_section_statement AND - bfd_vma dot) -{ - /* Align this section first to the - input sections requirement, then - to the output section's requirement. - If this alignment is > than any seen before, - then record it too. Perform the alignment by - inserting a magic 'padding' statement. - */ - - unsigned int alignment_needed = align_power(dot, power) - dot; - - if (alignment_needed != 0) - { - lang_statement_union_type *new = - (lang_statement_union_type *) - ldmalloc((bfd_size_type)(sizeof(lang_padding_statement_type))); - /* Link into existing chain */ - new->header.next = *this_ptr; - *this_ptr = new; - new->header.type = lang_padding_statement_enum; - new->padding_statement.output_section = output_section_statement; - new->padding_statement.output_offset = - dot - output_section_statement->vma; - new->padding_statement.fill = fill; - new->padding_statement.size = alignment_needed; - } - - - /* Remember the most restrictive alignment */ - if (power > output_section_statement->alignment_power) { - output_section_statement->alignment_power = power; - } - output_section_statement->size += alignment_needed; - return alignment_needed + dot; - -} - -/* Work out how much this section will move the dot point */ -static bfd_vma -DEFUN(size_input_section, (this_ptr, output_section_statement, fill, dot), - lang_statement_union_type **this_ptr AND - lang_output_section_statement_type*output_section_statement AND - unsigned short fill AND - bfd_vma dot) -{ - lang_input_section_type *is = &((*this_ptr)->input_section); - asection *i = is->section; - - if (is->ifile->just_syms_flag == false) { - dot = insert_pad(this_ptr, fill, i->alignment_power, - output_section_statement->bfd_section, dot); - - /* remember the largest size so we can malloc the largest area - needed for the output stage. Only remember the size of sections - which we will actually allocate */ - if (((i->flags & - (SEC_HAS_CONTENTS | SEC_LOAD)) == (SEC_HAS_CONTENTS | SEC_LOAD)) - && (i->size > largest_section)) { - largest_section = i->size; - } - - /* Remember where in the output section this input section goes */ - - i->output_offset = dot - output_section_statement->bfd_section->vma; - - /* Mark how big the output section must be to contain this now */ - dot += i->size; - output_section_statement->bfd_section->size = - dot - output_section_statement->bfd_section->vma; - } - else - { - i->output_offset = i->vma - output_section_statement->bfd_section->vma; - } - - return dot ; -} - - -/* Work out the size of the output sections - from the sizes of the input sections */ -static bfd_vma -DEFUN(lang_size_sections,(s, output_section_statement, prev, fill, dot), - lang_statement_union_type *s AND - lang_output_section_statement_type * output_section_statement AND - lang_statement_union_type **prev AND - unsigned short fill AND - bfd_vma dot) -{ - /* Size up the sections from their constituent parts */ - for (; s != (lang_statement_union_type *)NULL ; s = s->next) - { - switch (s->header.type) { - - - case lang_output_section_statement_enum: - { - bfd_vma after; - lang_output_section_statement_type *os = - &(s->output_section_statement); - /* The start of a section */ - - if (os->addr_tree == (etree_type *)NULL) { - /* No address specified for this section, get one - from the region specification - */ - if (os->region == (lang_memory_region_type *)NULL) { - os->region = lang_memory_region_lookup("*default*"); - } - dot = os->region->current; - } - else { - etree_value_type r ; - r = exp_fold_tree(os->addr_tree, - (lang_output_section_statement_type *)NULL, - lang_allocating_phase_enum, - dot, &dot); - if (r.valid == false) { - info("%F%S: non constant address expression for section %s\n", - os->name); - } - dot = r.value; - } - /* The section starts here */ - /* First, align to what the section needs */ - - dot = align_power(dot, os->bfd_section->alignment_power); - os->bfd_section->vma = dot; - os->bfd_section->output_offset = 0; - - (void) lang_size_sections(os->children.head, os, &os->children.head, - os->fill, dot); - /* Ignore the size of the input sections, use the vma and size to */ - /* align against */ - - - after = ALIGN(os->bfd_section->vma + - os->bfd_section->size, - os->block_value) ; - - - os->bfd_section->size = after - os->bfd_section->vma; - dot = os->bfd_section->vma + os->bfd_section->size; - os->processed = true; - - /* Replace into region ? */ - if (os->addr_tree == (etree_type *)NULL - && os->region !=(lang_memory_region_type*)NULL ) { - os->region->current = dot; - } - } - - break; - case lang_constructors_statement_enum: - dot = lang_size_sections(constructor_list.head, - output_section_statement, - &s->wild_statement.children.head, - fill, - dot); - break; - - case lang_data_statement_enum: - { - unsigned int size; - s->data_statement.output_vma = dot - output_section_statement->bfd_section->vma; - s->data_statement.output_section = - output_section_statement->bfd_section; - - switch (s->data_statement.type) { - case LONG: - size = LONG_SIZE; - break; - case SHORT: - size = SHORT_SIZE; - break; - case BYTE: - size = BYTE_SIZE; - break; - - } - dot += size; - output_section_statement->bfd_section->size += size; - } - break; - - case lang_wild_statement_enum: - - dot = lang_size_sections(s->wild_statement.children.head, - output_section_statement, - &s->wild_statement.children.head, - - fill, dot); - - break; - - case lang_object_symbols_statement_enum: - create_object_symbols = output_section_statement; - break; - case lang_output_statement_enum: - case lang_target_statement_enum: - break; - case lang_input_section_enum: - dot = size_input_section(prev, - output_section_statement, - output_section_statement->fill, dot); - break; - case lang_input_statement_enum: - break; - case lang_fill_statement_enum: - fill = s->fill_statement.fill; - break; - case lang_assignment_statement_enum: - { - bfd_vma newdot = dot; - exp_fold_tree(s->assignment_statement.exp, - output_section_statement, - lang_allocating_phase_enum, - dot, - &newdot); - - if (newdot != dot) - /* We've been moved ! so insert a pad */ - { - lang_statement_union_type *new = - (lang_statement_union_type *) - ldmalloc((bfd_size_type)(sizeof(lang_padding_statement_type))); - /* Link into existing chain */ - new->header.next = *prev; - *prev = new; - new->header.type = lang_padding_statement_enum; - new->padding_statement.output_section = - output_section_statement->bfd_section; - new->padding_statement.output_offset = - dot - output_section_statement->bfd_section->vma; - new->padding_statement.fill = fill; - new->padding_statement.size = newdot - dot; - output_section_statement->bfd_section->size += - new->padding_statement.size; - dot = newdot; - } - } - - break; - case lang_padding_statement_enum: - FAIL(); - break; - default: - FAIL(); - break; - case lang_address_statement_enum: - break; - } - prev = &s->header.next; - } - return dot; -} - - -static bfd_vma -DEFUN(lang_do_assignments,(s, output_section_statement, fill, dot), - lang_statement_union_type *s AND - lang_output_section_statement_type * output_section_statement AND - unsigned short fill AND - bfd_vma dot) -{ - - for (; s != (lang_statement_union_type *)NULL ; s = s->next) - { - switch (s->header.type) { - case lang_constructors_statement_enum: - dot = lang_do_assignments(constructor_list.head, - output_section_statement, - fill, - dot); - break; - - case lang_output_section_statement_enum: - { - lang_output_section_statement_type *os = - &(s->output_section_statement); - dot = os->bfd_section->vma; - (void) lang_do_assignments(os->children.head, os, os->fill, dot); - dot = os->bfd_section->vma + os->bfd_section->size; - } - break; - case lang_wild_statement_enum: - - dot = lang_do_assignments(s->wild_statement.children.head, - output_section_statement, - fill, dot); - - break; - - case lang_object_symbols_statement_enum: - case lang_output_statement_enum: - case lang_target_statement_enum: -#if 0 - case lang_common_statement_enum: -#endif - break; - case lang_data_statement_enum: - { - etree_value_type value ; - value = exp_fold_tree(s->data_statement.exp, - 0, lang_final_phase_enum, dot, &dot); - s->data_statement.value = value.value; - if (value.valid == false) info("%F%P: Invalid data statement\n"); - } - switch (s->data_statement.type) { - case LONG: - dot += LONG_SIZE; - break; - case SHORT: - dot += SHORT_SIZE; - break; - case BYTE: - dot += BYTE_SIZE; - break; - } - break; - case lang_input_section_enum: - { - asection *in = s->input_section.section; - dot += in->size; - } - break; - - case lang_input_statement_enum: - break; - case lang_fill_statement_enum: - fill = s->fill_statement.fill; - break; - case lang_assignment_statement_enum: - { - exp_fold_tree(s->assignment_statement.exp, - output_section_statement, - lang_final_phase_enum, - dot, - &dot); - } - - break; - case lang_padding_statement_enum: - dot += s->padding_statement.size; - break; - default: - FAIL(); - break; - case lang_address_statement_enum: - break; - } - - } - return dot; -} - - - -static void -DEFUN_VOID(lang_relocate_globals) -{ - - /* - Each ldsym_type maintains a chain of pointers to asymbols which - references the definition. Replace each pointer to the referenence - with a pointer to only one place, preferably the definition. If - the defintion isn't available then the common symbol, and if - there isn't one of them then choose one reference. - */ - - FOR_EACH_LDSYM(lgs) { - asymbol *it; - if (lgs->sdefs_chain) { - it = *(lgs->sdefs_chain); - } - else if (lgs->scoms_chain != (asymbol **)NULL) { - it = *(lgs->scoms_chain); - } - else if (lgs->srefs_chain != (asymbol **)NULL) { - it = *(lgs->srefs_chain); - } - else { - /* This can happen when the command line asked for a symbol to - be -u */ - it = (asymbol *)NULL; - } - if (it != (asymbol *)NULL) - { - asymbol **ptr = lgs->srefs_chain;; - if (lgs->flags & SYM_WARNING) - { - produce_warnings(lgs, it); - } - - while (ptr != (asymbol **)NULL) { - asymbol *ref = *ptr; - *ptr = it; - ptr = (asymbol **)(ref->udata); - } - } - } -} - - - -static void -DEFUN_VOID(lang_finish) -{ - ldsym_type *lgs; - - if (entry_symbol == (char *)NULL) { - /* No entry has been specified, look for start */ - entry_symbol = "start"; - } - lgs = ldsym_get_soft(entry_symbol); - if (lgs && lgs->sdefs_chain) { - asymbol *sy = *(lgs->sdefs_chain); - /* We can set the entry address*/ - bfd_set_start_address(output_bfd, - outside_symbol_address(sy)); - - } - else { - /* Can't find anything reasonable, - use the first address in the text section - */ - asection *ts = bfd_get_section_by_name(output_bfd, ".text"); - if (ts) { - bfd_set_start_address(output_bfd, ts->vma); - } - } -} - -/* By now we know the target architecture, and we may have an */ -/* ldfile_output_machine_name */ -static void -DEFUN_VOID(lang_check) -{ - lang_statement_union_type *file; - - bfd * input_bfd; - unsigned long input_machine; - enum bfd_architecture input_architecture; - - CONST bfd_arch_info_type *compatible; - - for (file = file_chain.head; - file != (lang_statement_union_type *)NULL; - file=file->input_statement.next) - { - unsigned long ldfile_new_output_machine = 0; - enum bfd_architecture ldfile_new_output_architecture = bfd_arch_unknown; - - input_bfd = file->input_statement.the_bfd; - - input_machine = bfd_get_mach(input_bfd); - input_architecture = bfd_get_arch(input_bfd); - - - /* Inspect the architecture and ensure we're linking like with - like */ - - compatible=bfd_arch_get_compatible(input_bfd, - output_bfd); - - if (compatible) - { - ldfile_output_machine = compatible->mach; - ldfile_output_architecture = compatible->arch; - } - else - { - - info("%P: warning, %s architecture of input file `%B' incompatible with %s output\n", - bfd_printable_name(input_bfd), input_bfd, - bfd_printable_name(output_bfd)); - - bfd_set_arch_mach(output_bfd, - ldfile_new_output_architecture, - ldfile_new_output_machine); - } - - } -} - - -/* - * run through all the global common symbols and tie them - * to the output section requested. - * - As an experiment we do this 4 times, once for all the byte sizes, - then all the two bytes, all the four bytes and then everything else - */ - -static void -DEFUN_VOID(lang_common) -{ - ldsym_type *lgs; - size_t power; - if (config.relocateable_output == false || - command_line.force_common_definition== true) { - for (power = 1; (config.sort_common == true && power == 1) || (power <= 16); power <<=1) { - for (lgs = symbol_head; - lgs != (ldsym_type *)NULL; - lgs=lgs->next) - { - asymbol *com ; - unsigned int power_of_two; - size_t size; - size_t align; - if (lgs->scoms_chain != (asymbol **)NULL) { - com = *(lgs->scoms_chain); - size = com->value; - switch (size) { - case 0: - case 1: - align = 1; - power_of_two = 0; - break; - case 2: - power_of_two = 1; - align = 2; - break; - case 3: - case 4: - power_of_two =2; - align = 4; - break; - case 5: - case 6: - case 7: - case 8: - power_of_two = 3; - align = 8; - break; - default: - power_of_two = 4; - align = 16; - break; - } - if (config.sort_common == false || align == power) { - /* Change from a common symbol into a definition of - a symbol */ - lgs->sdefs_chain = lgs->scoms_chain; - lgs->scoms_chain = (asymbol **)NULL; - commons_pending--; - /* Point to the correct common section */ - com->section = - ((lang_input_statement_type *) - (com->the_bfd->usrdata))->common_section; - /* Fix the size of the common section */ - com->section->size = ALIGN(com->section->size, align); - - /* Remember if this is the biggest alignment ever seen */ - if (power_of_two > com->section->alignment_power) { - com->section->alignment_power = power_of_two; - } - - /* Symbol stops being common and starts being global, but - we remember that it was common once. */ - - com->flags = BSF_EXPORT | BSF_GLOBAL | BSF_OLD_COMMON; - com->value = com->section->size; - - if (write_map) - { - printf ("Allocating common %s: %x at %x %s\n", - lgs->name, - (unsigned) size, - (unsigned) com->value, - com->the_bfd->filename); - } - - com->section->size += size; - - } - } - - } - } - } - - -} - -/* -run through the input files and ensure that every input -section has somewhere to go. If one is found without -a destination then create an input request and place it -into the statement tree. -*/ - -static void -DEFUN_VOID(lang_place_orphans) -{ - lang_input_statement_type *file; - for (file = (lang_input_statement_type*)file_chain.head; - file != (lang_input_statement_type*)NULL; - file = (lang_input_statement_type*)file->next) { - asection *s; - for (s = file->the_bfd->sections; - s != (asection *)NULL; - s = s->next) { - if ( s->output_section == (asection *)NULL) { - /* This section of the file is not attatched, root - around for a sensible place for it to go */ - - if (file->common_section == s) { - /* This is a lonely common section which must - have come from an archive. We attatch to the - section with the wildcard */ - if (config.relocateable_output != true - && command_line.force_common_definition == false) { - if (default_common_section == - (lang_output_section_statement_type *)NULL) { - info("%P: No [COMMON] command, defaulting to .bss\n"); - - default_common_section = - lang_output_section_statement_lookup(".bss"); - - } - wild_doit(&default_common_section->children, s, - default_common_section, file); - } - } - else { - lang_output_section_statement_type *os = - lang_output_section_statement_lookup(s->name); - - wild_doit(&os->children, s, os, file); - } - } - } - } -} - - -void -DEFUN(lang_set_flags,(ptr, flags), - int *ptr AND - CONST char *flags) -{ - boolean state = true; -*ptr= 0; - while (*flags) - { - if (*flags == '!') { - state = false; - flags++; - } - else state = true; - switch (*flags) { - case 'R': -/* ptr->flag_read = state; */ - break; - case 'W': -/* ptr->flag_write = state; */ - break; - case 'X': -/* ptr->flag_executable= state;*/ - break; - case 'L': - case 'I': -/* ptr->flag_loadable= state;*/ - break; - default: - info("%P%F illegal syntax in flags\n"); - break; - } - flags++; - } -} - - - -void -DEFUN(lang_for_each_file,(func), - PROTO(void, (*func),(lang_input_statement_type *))) -{ - lang_input_statement_type *f; - for (f = (lang_input_statement_type *)file_chain.head; - f != (lang_input_statement_type *)NULL; - f = (lang_input_statement_type *)f->next) - { - func(f); - } -} - - -void -DEFUN(lang_for_each_input_section, (func), - PROTO(void ,(*func),(bfd *ab, asection*as))) -{ - lang_input_statement_type *f; - for (f = (lang_input_statement_type *)file_chain.head; - f != (lang_input_statement_type *)NULL; - f = (lang_input_statement_type *)f->next) - { - asection *s; - for (s = f->the_bfd->sections; - s != (asection *)NULL; - s = s->next) { - func(f->the_bfd, s); - } - } -} - - - -void -DEFUN(ldlang_add_file,(entry), - lang_input_statement_type *entry) -{ - - lang_statement_append(&file_chain, - (lang_statement_union_type *)entry, - &entry->next); -} - - - -void -DEFUN(lang_add_output,(name), - CONST char *name) -{ - lang_output_statement_type *new = new_stat(lang_output_statement, - stat_ptr); - new->name = name; - had_output_filename = true; -} - - -static lang_output_section_statement_type *current_section; - -void -DEFUN(lang_enter_output_section_statement, - (output_section_statement_name, - address_exp, - flags, - block_value), - char *output_section_statement_name AND - etree_type *address_exp AND - int flags AND - bfd_vma block_value) -{ - lang_output_section_statement_type *os; - current_section = - os = - lang_output_section_statement_lookup(output_section_statement_name); - - - - /* Add this statement to tree */ - /* add_statement(lang_output_section_statement_enum, - output_section_statement);*/ - /* Make next things chain into subchain of this */ - - if (os->addr_tree == - (etree_type *)NULL) { - os->addr_tree = - address_exp; - } - os->flags = flags; - os->block_value = block_value; - stat_ptr = & os->children; - -} - - -void -DEFUN_VOID(lang_final) -{ - if (had_output_filename == false) { - extern CONST char *output_filename; - lang_add_output(output_filename); - } -} - - - - - -asymbol * -DEFUN(create_symbol,(name, flags, section), - CONST char *name AND - flagword flags AND - asection *section) -{ - extern lang_input_statement_type *script_file; - asymbol **def_ptr = (asymbol **)ldmalloc((bfd_size_type)(sizeof(asymbol **))); - /* Add this definition to script file */ - asymbol *def = (asymbol *)bfd_make_empty_symbol(script_file->the_bfd); - def->name = buystring(name); - def->udata = 0; - def->flags = flags; - def->section = section; - - *def_ptr = def; - Q_enter_global_ref(def_ptr); - return def; -} - -/* run through the symbol table, find all the symbols which are - constructors and for each one, create statements to do something - like.. - - for - __CTOR_LIST__, foo - - __CTOR_LIST__ = . ; - LONG(__CTOR_LIST_END - . / 4 - 2) - *(foo) - __CTOR_LIST_END= . - - Put these statements onto a special list. - -*/ - -typedef struct constructor_list -{ -ldsym_type *sym; - struct constructor_list *next; -} constructor_list_type; - -static constructor_list_type *constructor_name_list; - -void -DEFUN(ldlang_add_constructor,(name), -ldsym_type *name) -{ - - constructor_list_type *next = constructor_name_list; - - if (name->flags & SYM_CONSTRUCTOR) return; - - next = (constructor_list_type *) ldmalloc(sizeof(constructor_list_type)); - next->next= constructor_name_list; - next->sym= name; - name->flags |= SYM_CONSTRUCTOR; - constructor_name_list = next; - -} - -void -DEFUN_VOID(find_constructors) -{ - lang_statement_list_type *old = stat_ptr; - constructor_list_type *p = constructor_name_list; - stat_ptr = & constructor_list; - lang_list_init(stat_ptr); - while (p != (constructor_list_type *)NULL) - { - /* Have we already done this one ? */ - CONST char *name = p->sym->name; - int len = strlen(name); - char *end = ldmalloc(len+3); - strcpy(end, name); - strcat(end,"$e"); - - lang_add_assignment - ( exp_assop('=',name, exp_nameop(NAME,"."))); - - lang_add_data - (LONG, exp_binop('-', - exp_binop ( '/', - exp_binop ( '-', - exp_nameop(NAME, end), - exp_nameop(NAME,".")), - exp_intop(4)), - - exp_intop(2))); - - - lang_add_wild(name, (char *)NULL); - lang_add_data(LONG, exp_intop(0)); - lang_add_assignment - (exp_assop('=', end, exp_nameop(NAME,"."))); -p = p->next; - } - - - - - stat_ptr = old; -} -void -DEFUN_VOID(lang_process) -{ - if (had_script == false) { - parse_line(ldemul_get_script()); - } - lang_reasonable_defaults(); - current_target = default_target; - - lang_for_each_statement(ldlang_open_output); /* Open the output file */ - /* For each output section statement, create a section in the output - file */ - lang_create_output_section_statements(); - - /* Create a dummy bfd for the script */ - lang_init_script_file(); - - /* Add to the hash table all undefineds on the command line */ - lang_place_undefineds(); - - /* Create a bfd for each input file */ - current_target = default_target; - lang_for_each_statement(open_input_bfds); - - common_section.userdata = (PTR)&common_section_userdata; - - - /* Run through the contours of the script and attatch input sections - to the correct output sections - */ - find_constructors(); - map_input_to_output_sections(statement_list.head, (char *)NULL, - ( lang_output_section_statement_type *)NULL); - - - /* Find any sections not attatched explicitly and handle them */ - lang_place_orphans(); - - /* Size up the common data */ - lang_common(); - - ldemul_before_allocation(); - - /* Size up the sections */ - lang_size_sections(statement_list.head, - (lang_output_section_statement_type *)NULL, - &(statement_list.head), 0, (bfd_vma)0); - - /* See if anything special should be done now we know how big - everything is */ - ldemul_after_allocation(); - - /* Do all the assignments, now that we know the final restingplaces - of all the symbols */ - - lang_do_assignments(statement_list.head, - (lang_output_section_statement_type *)NULL, - 0, (bfd_vma)0); - - /* Make sure that we're not mixing architectures */ - - lang_check(); - - /* Move the global symbols around */ - lang_relocate_globals(); - - /* Final stuffs */ - lang_finish(); -} - - -/* EXPORTED TO YACC */ - -void -DEFUN(lang_add_wild,(section_name, filename), - CONST char *CONST section_name AND - CONST char *CONST filename) -{ - lang_wild_statement_type *new = new_stat(lang_wild_statement, - stat_ptr); - - if (section_name != (char *)NULL && strcmp(section_name,"COMMON") == 0) - { - placed_commons = true; - } - if (filename != (char *)NULL) { - lang_has_input_file = true; - } - new->section_name = section_name; - new->filename = filename; - lang_list_init(&new->children); -} -void -DEFUN(lang_section_start,(name, address), - CONST char *name AND - etree_type *address) -{ - lang_address_statement_type *ad =new_stat(lang_address_statement, stat_ptr); - ad->section_name = name; - ad->address = address; -} - -void -DEFUN(lang_add_entry,(name), - CONST char *name) -{ - entry_symbol = name; -} - -void -DEFUN(lang_add_target,(name), - CONST char *name) -{ - lang_target_statement_type *new = new_stat(lang_target_statement, - stat_ptr); - new->target = name; - -} - - - - -void -DEFUN(lang_add_map,(name), - CONST char *name) -{ - while (*name) { - switch (*name) { - case 'F': - map_option_f = true; - break; - } - name++; - } -} - -void -DEFUN(lang_add_fill,(exp), - int exp) -{ - lang_fill_statement_type *new = new_stat(lang_fill_statement, - stat_ptr); - new->fill = exp; -} - -void -DEFUN(lang_add_data,(type, exp), - int type AND - union etree_union *exp) -{ - - lang_data_statement_type *new = new_stat(lang_data_statement, - stat_ptr); - new->exp = exp; - new->type = type; - -} -void -DEFUN(lang_add_assignment,(exp), - etree_type *exp) -{ - lang_assignment_statement_type *new = new_stat(lang_assignment_statement, - stat_ptr); - new->exp = exp; -} - -void -DEFUN(lang_add_attribute,(attribute), - enum statement_enum attribute) -{ - new_statement(attribute, sizeof(lang_statement_union_type),stat_ptr); -} - - - -void -DEFUN(lang_startup,(name), - CONST char *name) -{ - if (startup_file != (char *)NULL) { - info("%P%FMultiple STARTUP files\n"); - } - first_file->filename = name; - first_file->local_sym_name = name; - - startup_file= name; -} -void -DEFUN(lang_float,(maybe), - boolean maybe) -{ - lang_float_flag = maybe; -} - -void -DEFUN(lang_leave_output_section_statement,(fill, memspec), - bfd_vma fill AND - CONST char *memspec) -{ - current_section->fill = fill; - current_section->region = lang_memory_region_lookup(memspec); - stat_ptr = &statement_list; - - /* We remember if we are closing a .data section, since we use it to - store constructors in */ - if (strcmp(current_section->name, ".data") ==0) { - end_of_data_section_statement_list = statement_list; - - } -} -/* - Create an absolute symbol with the given name with the value of the - address of first byte of the section named. - - If the symbol already exists, then do nothing. -*/ -void -DEFUN(lang_abs_symbol_at_beginning_of,(section, name), - CONST char *section AND - CONST char *name) -{ - if (ldsym_undefined(name)) { - asection *s = bfd_get_section_by_name(output_bfd, section); - asymbol *def = create_symbol(name, - BSF_GLOBAL | BSF_EXPORT | - BSF_ABSOLUTE, - (asection *)NULL); - if (s != (asection *)NULL) { - def->value = s->vma; - } - else { - def->value = 0; - } - } -} - -/* - Create an absolute symbol with the given name with the value of the - address of the first byte after the end of the section named. - - If the symbol already exists, then do nothing. -*/ -void -DEFUN(lang_abs_symbol_at_end_of,(section, name), - CONST char *section AND - CONST char *name) -{ - if (ldsym_undefined(name)){ - asection *s = bfd_get_section_by_name(output_bfd, section); - /* Add a symbol called _end */ - asymbol *def = create_symbol(name, - BSF_GLOBAL | BSF_EXPORT | - BSF_ABSOLUTE, - (asection *)NULL); - if (s != (asection *)NULL) { - def->value = s->vma + s->size; - } - else { - def->value = 0; - } - } -} - -void -DEFUN(lang_statement_append,(list, element, field), - lang_statement_list_type *list AND - lang_statement_union_type *element AND - lang_statement_union_type **field) -{ - *(list->tail) = element; - list->tail = field; -} - -/* Set the output format type */ -void -DEFUN(lang_add_output_format,(format), -CONST char *format) -{ - output_target = format; -} - diff --git a/ld/ldlang.h b/ld/ldlang.h deleted file mode 100644 index bfdc9cbe46d..00000000000 --- a/ld/ldlang.h +++ /dev/null @@ -1,344 +0,0 @@ -/* ldlang.h - - - Copyright (C) 1991 Free Software Foundation, Inc. - - This file is part of GLD, the Gnu Linker. - - GLD 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 1, or (at your option) - any later version. - - GLD 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 GLD; see the file COPYING. If not, write to - the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - - -typedef enum { - lang_input_file_is_l_enum, - lang_input_file_is_symbols_only_enum, - lang_input_file_is_marker_enum, - lang_input_file_is_fake_enum, -lang_input_file_is_search_file_enum, - lang_input_file_is_file_enum } lang_input_file_enum_type; - -typedef unsigned short fill_type; -typedef struct statement_list { - union lang_statement_union *head; - union lang_statement_union **tail; -} lang_statement_list_type; - - -typedef struct { - boolean flag_read; - boolean flag_write; - boolean flag_executable; - boolean flag_loadable; -} lang_section_flags_type; - -typedef struct memory_region_struct { - char *name; - struct memory_region_struct *next; - bfd_vma origin; - bfd_offset length; - bfd_vma current; - lang_section_flags_type flags; -} lang_memory_region_type ; - -typedef struct lang_statement_header_struct -{ -union lang_statement_union *next; - enum statement_enum { - lang_output_section_statement_enum, - lang_assignment_statement_enum, - lang_input_statement_enum, - lang_address_statement_enum, - lang_wild_statement_enum, - lang_input_section_enum, - lang_object_symbols_statement_enum, - lang_fill_statement_enum, - lang_data_statement_enum, - lang_target_statement_enum, - lang_output_statement_enum, - lang_padding_statement_enum, - - lang_afile_asection_pair_statement_enum - } type; - -} lang_statement_header_type; - - -typedef struct -{ - lang_statement_header_type header; - union etree_union *exp; -} lang_assignment_statement_type; - - -typedef struct lang_target_statement_struct { - lang_statement_header_type header; - CONST char *target; -} lang_target_statement_type; - - -typedef struct lang_output_statement_struct { - lang_statement_header_type header; - CONST char *name; -} lang_output_statement_type; - - -typedef struct lang_output_section_statement_struct -{ - lang_statement_header_type header; - union etree_union *addr_tree; - lang_statement_list_type children; - CONST char *memspec; - union lang_statement_union *next; - CONST char *name; - unsigned long subsection_alignment; - boolean processed; - - asection *bfd_section; - lang_section_flags_type flags; - struct memory_region_struct *region; - size_t block_value; - fill_type fill; -} lang_output_section_statement_type; - - -typedef struct { - lang_statement_header_type header; -} lang_common_statement_type; - -typedef struct { - lang_statement_header_type header; -} lang_object_symbols_statement_type; - -typedef struct { - lang_statement_header_type header; - fill_type fill; -} lang_fill_statement_type; - -typedef struct { - lang_statement_header_type header; - unsigned int type; - union etree_union *exp; - bfd_vma value; - asection *output_section; - bfd_vma output_vma; -} lang_data_statement_type; - - - - -typedef struct lang_input_statement_struct - { - lang_statement_header_type header; - /* Name of this file. */ - CONST char *filename; - /* Name to use for the symbol giving address of text start */ - /* Usually the same as filename, but for a file spec'd with -l - this is the -l switch itself rather than the filename. */ - CONST char *local_sym_name; - - /* Describe the layout of the contents of the file */ - - /* The file's a.out header. */ - /* struct exec header;*/ - /* Offset in file of GDB symbol segment, or 0 if there is none. */ - int symseg_offset; - - /* Describe data from the file loaded into core */ - - bfd *the_bfd; - - boolean closed; - file_ptr passive_position; - - /* Symbol table of the file. */ - asymbol **asymbols; - unsigned int symbol_count; - - /* For library members only */ - - /* For a library, points to chain of entries for the library members. */ - struct lang_input_statement_struct *subfiles; - /* For a library member, offset of the member within the archive. - Zero for files that are not library members. */ - /* int starting_offset;*/ - /* Size of contents of this file, if library member. */ - int total_size; - /* For library member, points to the library's own entry. */ - struct lang_input_statement_struct *superfile; - /* For library member, points to next entry for next member. */ - struct lang_input_statement_struct *chain; - /* Point to the next file - whatever it is, wanders up and down - archives */ - - union lang_statement_union *next; - /* Point to the next file, but skips archive contents */ - union lang_statement_union *next_real_file; - - boolean is_archive; - - /* 1 means search a set of directories for this file. */ - boolean search_dirs_flag; - - /* 1 means this is base file of incremental load. - Do not load this file's text or data. - Also default text_start to after this file's bss. */ - - boolean just_syms_flag; - - boolean loaded; - - - /* unsigned int globals_in_this_file;*/ - CONST char *target; - boolean real; - - asection *common_section; - asection *common_output_section; - } lang_input_statement_type; - -typedef struct { - lang_statement_header_type header; - asection *section; - lang_input_statement_type *ifile; - -} lang_input_section_type; - - -typedef struct { - lang_statement_header_type header; - asection *section; - union lang_statement_union *file; -} lang_afile_asection_pair_statement_type; - -typedef struct lang_wild_statement_struct { - lang_statement_header_type header; -CONST char *section_name; -CONST char *filename; - lang_statement_list_type children; -} lang_wild_statement_type; - -typedef struct lang_address_statement_struct { - lang_statement_header_type header; - CONST char *section_name; - union etree_union *address; -} lang_address_statement_type; - -typedef struct { - lang_statement_header_type header; - bfd_vma output_offset; - size_t size; - asection *output_section; - fill_type fill; -} lang_padding_statement_type; - -typedef union lang_statement_union -{ - lang_statement_header_type header; - union lang_statement_union *next; - lang_wild_statement_type wild_statement; - lang_data_statement_type data_statement; - lang_address_statement_type address_statement; - lang_output_section_statement_type output_section_statement; - lang_afile_asection_pair_statement_type afile_asection_pair_statement; - lang_assignment_statement_type assignment_statement; - lang_input_statement_type input_statement; - lang_target_statement_type target_statement; - lang_output_statement_type output_statement; - lang_input_section_type input_section; - lang_common_statement_type common_statement; - lang_object_symbols_statement_type object_symbols_statement; - lang_fill_statement_type fill_statement; - lang_padding_statement_type padding_statement; -} lang_statement_union_type; - - - -PROTO(void,lang_init,(void)); -PROTO(struct memory_region_struct , - *lang_memory_region_lookup,(CONST - char *CONST)); - - -PROTO(void ,lang_map,(FILE *)); -PROTO(void,lang_set_flags,(lang_section_flags_type *, CONST char *)); -PROTO(void,lang_add_output,(CONST char *)); - -PROTO(void,lang_final,(void)); -PROTO(struct symbol_cache_entry *,create_symbol,(CONST char *, unsigned int, struct sec *)); -PROTO(void ,lang_process,(void)); -PROTO(void ,lang_section_start,(CONST char *, union etree_union *)); -PROTO(void,lang_add_entry,(CONST char *)); -PROTO(void,lang_add_target,(CONST char *)); -PROTO(void,lang_add_wild,(CONST char *CONST , CONST char *CONST)); -PROTO(void,lang_add_map,(CONST char *)); -PROTO(void,lang_add_fill,(int)); -PROTO(void,lang_add_assignment,(union etree_union *)); -PROTO(void,lang_add_attribute,(enum statement_enum)); -PROTO(void,lang_startup,(CONST char *)); -PROTO(void,lang_float,(enum boolean)); -PROTO(void,lang_leave_output_section_statement,(bfd_vma, CONST char *)); -PROTO(void,lang_abs_symbol_at_end_of,(CONST char *, CONST char *)); -PROTO(void,lang_abs_symbol_at_beginning_of,(CONST char *, CONST char *)); -PROTO(void,lang_statement_append,(struct statement_list *, union lang_statement_union *, union lang_statement_union **)); -PROTO(void, lang_for_each_file,(void (*dothis)(lang_input_statement_type *))); - - -#define LANG_FOR_EACH_INPUT_STATEMENT(statement) \ - extern lang_statement_list_type file_chain; \ - lang_input_statement_type *statement; \ - for (statement = (lang_input_statement_type *)file_chain.head;\ - statement != (lang_input_statement_type *)NULL; \ - statement = (lang_input_statement_type *)statement->next)\ - -#define LANG_FOR_EACH_INPUT_SECTION(statement, abfd, section, x) \ -{ extern lang_statement_list_type file_chain; \ - lang_input_statement_type *statement; \ - for (statement = (lang_input_statement_type *)file_chain.head;\ - statement != (lang_input_statement_type *)NULL; \ - statement = (lang_input_statement_type *)statement->next)\ - { \ - asection *section; \ - bfd *abfd = statement->the_bfd; \ - for (section = abfd->sections; \ - section != (asection *)NULL; \ - section = section->next) { \ - x; \ - } \ - } \ - } - -#define LANG_FOR_EACH_OUTPUT_SECTION(section, x) \ - { extern bfd *output_bfd; \ - asection *section; \ - for (section = output_bfd->sections; \ - section != (asection *)NULL; \ - section = section->next) \ - { x; } \ - } - - -PROTO(void, lang_process,(void)); -PROTO(void, ldlang_add_file,(lang_input_statement_type *)); - -PROTO(lang_output_section_statement_type - *,lang_output_section_find,(CONST char * CONST)); - -PROTO(lang_input_statement_type *, - lang_add_input_file,(char *name, - lang_input_file_enum_type file_type, - char *target)); -PROTO(lang_output_section_statement_type *, -lang_output_section_statement_lookup,(CONST char * CONST name)); - -PROTO(void, ldlang_add_undef,(CONST char *CONST name)); -PROTO(void, lang_add_output_format,(CONST char *)); diff --git a/ld/ldlex.h b/ld/ldlex.h deleted file mode 100644 index fe4e017f759..00000000000 --- a/ld/ldlex.h +++ /dev/null @@ -1,26 +0,0 @@ -/* ldlex.h - - - Copyright (C) 1991 Free Software Foundation, Inc. - - This file is part of GLD, the Gnu Linker. - - GLD 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 1, or (at your option) - any later version. - - GLD 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 GLD; see the file COPYING. If not, write to - the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -PROTO(int, lex_input, (void)); -PROTO(void, lex_unput, (int)); -PROTO(int ,yywrap,(void)); -PROTO(void, parse_args,(int, char **)); -PROTO(void, parse_line,(char*)); - diff --git a/ld/ldlex.l b/ld/ldlex.l deleted file mode 100644 index 9967b69a189..00000000000 --- a/ld/ldlex.l +++ /dev/null @@ -1,524 +0,0 @@ -%{ -/* Copyright (C) 1991 Free Software Foundation, Inc. - -This file is part of GLD, the Gnu Linker. - -GLD 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 1, or (at your option) -any later version. - -GLD 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 GLD; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - * $Id$ - - * -*/ - - - -/*SUPPRESS 529*/ -/*SUPPRESS 26*/ -/*SUPPRESS 29*/ -#define LEXDEBUG 0 -#include "sysdep.h" -#include "bfd.h" - -#include -#include "ldlex.h" - -#include "ld.h" -#include "ldexp.h" -#include "ldgramtb.h" -#include "ldmisc.h" - -#undef input -#undef unput -#define input lex_input -#define unput lex_unput -int debug; - - -static boolean ldgram_in_defsym; -static boolean ldgram_had_equals; -extern boolean ldgram_in_script; -static char *command_line; - -extern int fgetc(); -extern int yyparse(); - -typedef struct { - char *name; -int value; -} keyword_type; -#define RTOKEN(x) { yylval.token = x; return x; } -keyword_type keywords[] = -{ -"/", '/', -"MEMORY",MEMORY, -"ORIGIN",ORIGIN, -"BLOCK",BLOCK, -"LENGTH",LENGTH, -"ALIGN",ALIGN_K, -"ADDR",ADDR, -"ENTRY",ENTRY, -"NEXT",NEXT, -"sizeof_headers",SIZEOF_HEADERS, -"SIZEOF_HEADERS",SIZEOF_HEADERS, -"MAP",MAP, -"SIZEOF",SIZEOF, -"TARGET",TARGET_K, -"SEARCH_DIR",SEARCH_DIR, -"OUTPUT",OUTPUT, -"INPUT",INPUT, -"DEFINED",DEFINED, -"CREATE_OBJECT_SYMBOLS",CREATE_OBJECT_SYMBOLS, -"FORCE_COMMON_ALLOCATION",FORCE_COMMON_ALLOCATION, -"SECTIONS",SECTIONS, -"FILL",FILL, -"STARTUP",STARTUP, -"OUTPUT_FORMAT",OUTPUT_FORMAT, -"OUTPUT_ARCH", OUTPUT_ARCH, -"HLL",HLL, -"SYSLIB",SYSLIB, -"FLOAT",FLOAT, -"LONG", LONG, -"SHORT", SHORT, -"BYTE", BYTE, -"NOFLOAT",NOFLOAT, -"o",ORIGIN, -"org",ORIGIN, -"l", LENGTH, -"len", LENGTH, -0,0}; -unsigned int lineno; -extern boolean hex_mode; -FILE *ldlex_input_stack; -static unsigned int have_pushback; - -#define NPUSHBACK 10 -int pushback[NPUSHBACK]; -int thischar; -extern char *ldfile_input_filename; -int donehash = 0; -int -lex_input() -{ - if (have_pushback > 0) - { - have_pushback --; - return thischar = pushback[have_pushback]; - } - if (ldlex_input_stack) { - thischar = fgetc(ldlex_input_stack); - - if (thischar == EOF) { - fclose(ldlex_input_stack); - ldlex_input_stack = (FILE *)NULL; - ldfile_input_filename = (char *)NULL; - /* First char after script eof is a @ so that we can tell the grammer - that we've left */ - thischar = '@'; - - } - } - else if (command_line && *command_line) { - thischar = *(command_line++); - } - else { - thischar = 0; - } - if(thischar == '\t') thischar = ' '; - if (thischar == '\n') { thischar = ' '; lineno++; } - return thischar ; -} - -void -lex_unput(c) -int c; -{ - if (have_pushback > NPUSHBACK) { - info("%F%P Too many pushbacks\n"); - } - - pushback[have_pushback] = c; - have_pushback ++; -} - - - int -yywrap() - { return 1; } -/*VARARGS*/ - -void -allprint(x) -int x; -{ -fprintf(yyout,"%d",x); -} - -void -sprint(x) -char *x; -{ -fprintf(yyout,"%s",x); -} - -int thischar; - -void parse_line(arg) -char *arg; -{ - command_line = arg; - have_pushback = 0; - yyparse(); -} - - - -void -parse_args(ac, av) -int ac; -char **av; -{ - char *p; - int i; - size_t size = 0; - char *dst; - debug = 1; - for (i= 1; i < ac; i++) { - size += strlen(av[i]) + 2; - } - dst = p = (char *)ldmalloc(size + 2); -/* Put a space arount each option */ - - - for (i =1; i < ac; i++) { - - unsigned int s = strlen(av[i]); - *dst++ = ' '; - memcpy(dst, av[i], s); - dst[s] = ' '; - dst += s + 1; - } - *dst = 0; - parse_line(p); - - free(p); - - -} - -static long -DEFUN(number,(default_if_zero,base), - int default_if_zero AND - int base) -{ - unsigned long l = 0; - int ch = yytext[0]; - if (ch == 0) { - base = default_if_zero; - } - while (1) { - switch (ch) { - case 'x': - base = 16; - break; - case 'k': - case 'K': - l =l * 1024; - break; - case 'm': - case 'M': - l =l * 1024 * 1024; - break; - case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - l = l * base + ch - '0'; - break; - case 'a': case 'b': case 'c' : case 'd' : case 'e': case 'f': - l =l *base + ch - 'a' + 10; - break; - case 'A': case 'B': case 'C' : case 'D' : case 'E': case 'F': - l =l *base + ch - 'A' + 10; - break; - default: - unput(ch); - yylval.integer = l; - return INT; - } -ch = input(); - } -} -%} - -%a 4000 -%o 5000 -FILENAMECHAR [a-zA-Z0-9\/\.\-\_\+\=] -FILENAME {FILENAMECHAR}+ -WHITE [ \t]+ - -%% - -"@" { return '}'; } -"\ -defsym\ " { ldgram_in_defsym = true; return OPTION_defsym; } -"\ -noinhibit_exec\ " { return OPTION_noinhibit_exec; } -"\ -sort_common\ " { return OPTION_sort_common;} -"\ -format\ " { return OPTION_format; } -"\ -n\ " { return OPTION_n; } -"\ -r\ " { return OPTION_r; } -"\ -i\ " { return OPTION_r; } -"\ -Ur\ " { return OPTION_Ur; } -"\ -o\ " { return OPTION_o; } -"\ -g\ " { return OPTION_g; } -"\ -e\ " { return OPTION_e; } -"\ -b\ " { return OPTION_b; } -"\ -dc\ " { return OPTION_dc; } -"\ -dp\ " { return OPTION_dp; } -"\ -d\ " { return OPTION_d; } -"\ -v\ " { return OPTION_v; } -"\ -M\ " { return OPTION_M; } -"\ -t\ " { return OPTION_t; } -"\ -X\ " { return OPTION_X; } -"\ -x\ " { return OPTION_x; } -"\ -c\ " { return OPTION_c; } -"\ -R\ " { return OPTION_R; } -"\ -u\ " { return OPTION_u; } -"\ -s\ " { return OPTION_s; } -"\ -S\ " { return OPTION_S; } -"\ -B{FILENAME}\ " { /* Ignored */ } -"\ -l"{FILENAME} { - yylval.name = buystring(yytext+3); - return OPTION_l; - } - -"\ -L"{FILENAME} { - yylval.name = buystring(yytext+3); - return OPTION_L; - } -"\ -Ttext\ " { - yylval.name = ".text"; - return OPTION_Texp; - } -"\ -Tdata\ " { - yylval.name = ".data"; - return OPTION_Texp; - } -"\ -Tbss\ " { - yylval.name = ".bss"; - return OPTION_Texp; - } -"\ -O"{FILENAME} { - yylval.name = buystring(yytext+3); - return OPTION_Texp; - } - -"\ -T"{FILENAME} { - yylval.name = buystring(yytext+3); - return OPTION_Tfile; - } -"\ -T\ " { - return OPTION_T; - } - -"\ -F"{FILENAME} { - return OPTION_F; - } -"\ -F\ " { - return OPTION_F; - } - -"\ -A"{FILENAME} { - yylval.name = buystring(yytext+3); - return OPTION_Aarch; - } - -" " { - if (ldgram_had_equals == true) { - ldgram_in_defsym = false; - ldgram_had_equals = false; - } - } -"<<=" { RTOKEN(LSHIFTEQ);} -">>=" { RTOKEN(RSHIFTEQ);} -"||" { RTOKEN(OROR);} -"==" { RTOKEN(EQ);} -"!=" { RTOKEN(NE);} -">=" { RTOKEN(GE);} -"<=" { RTOKEN(LE);} -"<<" { RTOKEN(LSHIFT);} -">>" { RTOKEN(RSHIFT);} -"+=" { RTOKEN(PLUSEQ);} -"-=" { RTOKEN(MINUSEQ);} -"*=" { RTOKEN(MULTEQ);} -"/=" { RTOKEN(DIVEQ);} -"&=" { RTOKEN(ANDEQ);} -"|=" { RTOKEN(OREQ);} -"&&" { RTOKEN(ANDAND);} -">" { RTOKEN('>');} -"," { RTOKEN(',');} -"&" { RTOKEN('&');} -"|" { RTOKEN('|');} -"~" { RTOKEN('~');} -"!" { RTOKEN('!');} -"?" { RTOKEN('?');} -"*" { RTOKEN('*');} -"%" { RTOKEN('%');} -"<" { RTOKEN('<');} -">" { RTOKEN('>');} -"}" { RTOKEN('}') ; } -"{" { RTOKEN('{'); } -")" { RTOKEN(')');} -"(" { RTOKEN('(');} -"]" { RTOKEN(']');} -"[" { RTOKEN('[');} -":" { RTOKEN(':'); } -";" { RTOKEN('\;');} -"-" { RTOKEN('-');} - - - -"/*" { - while (1) { - int ch; - ch = input(); - while (ch != '*') { - ch = input(); - } - - - - if (input() == '/') { - break; - } - unput(yytext[yyleng-1]); - } -} - -"\""[^\"]*"\"" { - - yylval.name = buystring(yytext+1); - yylval.name[yyleng-2] = 0; /* Fry final quote */ - return NAME; -} - -{FILENAMECHAR} { - - boolean loop = false; - int ch; - keyword_type *k; - - /* If we're in hex mode (only after a -T) then all we can see are numbers - hex digit we see will be a number. */ - - if (hex_mode) { - return number(16, 16); - } - - /* If we're in a defsym then all things starting with a digit are in - hex */ - - if (isdigit(yytext[0]) && ldgram_in_defsym) { - return number(16,16); - } - - - /* Otherwise if we're in a script we will parse the numbers - normally */ - - if (ldgram_in_script == true && isdigit(yytext[0])) { - return number(8,10); - } - - /* Anywhere not in a script or defsym, an opertor is part of a - filename, except / and, which is an operator when on its own */ - if (ldgram_in_script == true|| ldgram_in_defsym == true) { - - switch (yytext[0]) { - case '*': RTOKEN('*'); - - case '=': { - ldgram_had_equals = true; - RTOKEN('='); - } - break; - case '/': { - if (ldgram_in_defsym) RTOKEN('/'); - } - break; - case '+': RTOKEN('+'); - case '-': RTOKEN('-'); - case '!': RTOKEN('!'); - case '~': RTOKEN('~'); - } - } - - -/* Otherwise this must be a file or a symbol name, and it will continue to be a - filename until we get to something strange. In scripts operator looking - things are taken to be operators, except /, which will be left - */ - ch = input(); - while (true) - { - if (ldgram_in_defsym == true) { - switch (ch) { - case '*': - case '=': - case '+': - case '/': - case '-': - case '!': - case '~': - goto quit; - } - - } - if(ldgram_in_script == true) { - switch (ch) { - case '*': - case '=': - case '+': - case '-': - case '!': - case '~': - goto quit; - } - } - - if (isalpha(ch) || isdigit(ch) || ch == '.' || ch == '_' || - ch == '/' || ch == '.' || ch == '+' || ch == '-' || ch =='=') { - yytext[yyleng++] = ch; - } - else - break; - ch = input(); - } - quit:; - yytext[yyleng] = 0; - unput(ch); - - for(k = keywords; k ->name != (char *)NULL; k++) { - if (strcmp(k->name, yytext)==0) { - yylval.token = k->value; - return k->value; - } - } - yylval.name = buystring(yytext); - return NAME; -} - - - - - -%% diff --git a/ld/ldlnk960.c b/ld/ldlnk960.c deleted file mode 100755 index 8936c4e730d..00000000000 --- a/ld/ldlnk960.c +++ /dev/null @@ -1,283 +0,0 @@ -/* intel coff loader emulation specific stuff - Copyright (C) 1991 Free Software Foundation, Inc. - Written by Steve Chamberlain steve@cygnus.com - -This file is part of GLD, the Gnu Linker. - -GLD 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. - -GLD 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 GLD; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - $Id$ -*/ - -#include "bfd.h" -#include "sysdep.h" - -/*#include "archures.h"*/ -#include "ld.h" -#include "config.h" -#include "ldemul.h" -#include "ldmisc.h" -#include "ldlang.h" -#include "ldfile.h" - -extern boolean lang_float_flag; -extern bfd *output_bfd; - - - -extern enum bfd_architecture ldfile_output_architecture; -extern unsigned long ldfile_output_machine; -extern char *ldfile_output_machine_name; - - -typedef struct lib_list { - char *name; - struct lib_list *next; -} lib_list_type; - -static lib_list_type *hll_list; -static lib_list_type **hll_list_tail = &hll_list; - -static lib_list_type *syslib_list; -static lib_list_type **syslib_list_tail = &syslib_list; - - -static void -append(list, name) -lib_list_type ***list; -char *name; -{ - lib_list_type *element = - (lib_list_type *)(ldmalloc(sizeof(lib_list_type))); - - element->name = name; - element->next = (lib_list_type *)NULL; - **list = element; - *list = &element->next; - -} - -static boolean had_hll = false; -static boolean had_hll_name = false; -static void -lnk960_hll(name) -char *name; -{ - had_hll = true; - if (name != (char *)NULL) { - had_hll_name = true; - append(&hll_list_tail, name); - } -} - -static void -lnk960_syslib(name) -char *name; -{ - append(&syslib_list_tail,name); -} - - - -#ifdef GNU960 - -static void -lnk960_before_parse() -{ - static char *env_variables[] = { "G960LIB", "G960BASE", 0 }; - char **p; - char *env ; - - for ( p = env_variables; *p; p++ ){ - env = (char *) getenv(*p); - if (env) { - ldfile_add_library_path(concat(env,"/lib/libcoff","")); - } - } - - env= (char *) getenv("I960BASE"); - if ( env ) { - ldfile_add_library_path(concat(env,"/lib","")); - } - - ldfile_output_architecture = bfd_arch_i960; - ldfile_output_machine = bfd_mach_i960_core; -} - -#else /* not GNU960 */ - -static void -lnk960_before_parse() -{ - char *name = getenv("I960BASE"); - - if (name == (char *)NULL) { - name = getenv("G960BASE"); - if (name == (char *)NULL) { - einfo("%P%F I960BASE and G960BASE not set\n"); - } - } - - - ldfile_add_library_path(concat(name,"/lib","")); - ldfile_output_architecture = bfd_arch_i960; - ldfile_output_machine = bfd_mach_i960_core; -} - -#endif /* GNU960 */ - - -static void -add_on(list, search) -lib_list_type *list; -lang_input_file_enum_type search; -{ - while (list) { - lang_add_input_file(list->name, - search, - (char *)NULL); - list = list->next; - } -} -static void lnk960_after_parse() -{ - - /* If there has been no arch, default to -KB */ - if (ldfile_output_machine_name[0] ==0) { - ldfile_add_arch("KB"); - } - - /* if there has been no hll list then add our own */ - - if(had_hll && !had_hll_name) { - append(&hll_list_tail,"cg"); - if (ldfile_output_machine == bfd_mach_i960_ka_sa || - ldfile_output_machine == bfd_mach_i960_ca) { - { - append(&hll_list_tail,"fpg"); - } - } - } - - add_on(hll_list, lang_input_file_is_l_enum); - add_on(syslib_list, lang_input_file_is_search_file_enum); -} - -static void -lnk960_before_allocation() -{ -} -static void -lnk960_after_allocation() -{ - extern ld_config_type config; - if (config.relocateable_output == false) { - lang_abs_symbol_at_end_of(".text","_etext"); - lang_abs_symbol_at_end_of(".data","_edata"); - lang_abs_symbol_at_beginning_of(".bss","_bss_start"); - lang_abs_symbol_at_end_of(".bss","_end"); - } -} - - -static struct - { - unsigned long number; - char *name; - } -machine_table[] = { - bfd_mach_i960_core ,"CORE", - bfd_mach_i960_kb_sb ,"KB", - bfd_mach_i960_kb_sb ,"SB", - bfd_mach_i960_mc ,"MC", - bfd_mach_i960_xa ,"XA", - bfd_mach_i960_ca ,"CA", - bfd_mach_i960_ka_sa ,"KA", - bfd_mach_i960_ka_sa ,"SA", - - bfd_mach_i960_core ,"core", - bfd_mach_i960_kb_sb ,"kb", - bfd_mach_i960_kb_sb ,"sb", - bfd_mach_i960_mc ,"mc", - bfd_mach_i960_xa ,"xa", - bfd_mach_i960_ca ,"ca", - bfd_mach_i960_ka_sa ,"ka", - bfd_mach_i960_ka_sa ,"sa", - 0,(char *)NULL -}; - -static void -lnk960_set_output_arch() -{ - /* Set the output architecture and machine if possible */ - unsigned int i; - ldfile_output_machine = bfd_mach_i960_core; - for (i= 0; machine_table[i].name != (char*)NULL; i++) { - if (strcmp(ldfile_output_machine_name,machine_table[i].name)==0) { - ldfile_output_machine = machine_table[i].number; - break; - } - } - bfd_set_arch_mach(output_bfd, ldfile_output_architecture, ldfile_output_machine); -} - -static char * -lnk960_choose_target() -{ -#ifdef GNU960 - - return bfd_make_targ_name(BFD_COFF_FORMAT, 0); - -#else - - char *from_outside = getenv(TARGET_ENVIRON); - if (from_outside != (char *)NULL) - return from_outside; - return LNK960_TARGET; - -#endif -} - -/* The default script if none is offered */ -static char *lnk960_script = -#include "ldlnk960.x" -; - - -static char *lnk960_script_relocateable = -#include "ldlnk960.xr" -; - -static char *lnk960_get_script() -{ - extern ld_config_type config; - if (config.relocateable_output) { - return lnk960_script_relocateable; - } - return lnk960_script; -} -struct ld_emulation_xfer_struct ld_lnk960_emulation = -{ - lnk960_before_parse, - lnk960_syslib, - lnk960_hll, - lnk960_after_parse, - lnk960_after_allocation, - lnk960_set_output_arch, - lnk960_choose_target, - lnk960_before_allocation, - lnk960_get_script, -}; diff --git a/ld/ldlnk960.sc b/ld/ldlnk960.sc deleted file mode 100755 index f498412f6f3..00000000000 --- a/ld/ldlnk960.sc +++ /dev/null @@ -1,21 +0,0 @@ - -SECTIONS -{ - .text : - { - *(.text) - } -_etext = . ; - .data SIZEOF(.text) + ADDR(.text): - { - *(.data) - } -_edata = .; - .bss SIZEOF(.data) + ADDR(.data) : - { - _bss_start = . ; - *(.bss) - [COMMON] - } -_end = . ; -} diff --git a/ld/ldlnk960.script b/ld/ldlnk960.script deleted file mode 100755 index f498412f6f3..00000000000 --- a/ld/ldlnk960.script +++ /dev/null @@ -1,21 +0,0 @@ - -SECTIONS -{ - .text : - { - *(.text) - } -_etext = . ; - .data SIZEOF(.text) + ADDR(.text): - { - *(.data) - } -_edata = .; - .bss SIZEOF(.data) + ADDR(.data) : - { - _bss_start = . ; - *(.bss) - [COMMON] - } -_end = . ; -} diff --git a/ld/ldlnk960r.sc b/ld/ldlnk960r.sc deleted file mode 100755 index daf59bba024..00000000000 --- a/ld/ldlnk960r.sc +++ /dev/null @@ -1,17 +0,0 @@ -SECTIONS -{ - .text 0: - { - *(.text) - } - .data SIZEOF(.text) + ADDR(.text): - { - *(.data) - } - .bss SIZEOF(.data) + ADDR(.data) : - { - *(.bss) - [COMMON] - } -} - diff --git a/ld/ldlnk960r.script b/ld/ldlnk960r.script deleted file mode 100755 index daf59bba024..00000000000 --- a/ld/ldlnk960r.script +++ /dev/null @@ -1,17 +0,0 @@ -SECTIONS -{ - .text 0: - { - *(.text) - } - .data SIZEOF(.text) + ADDR(.text): - { - *(.data) - } - .bss SIZEOF(.data) + ADDR(.data) : - { - *(.bss) - [COMMON] - } -} - diff --git a/ld/ldm88k.c b/ld/ldm88k.c deleted file mode 100755 index c354ccb8601..00000000000 --- a/ld/ldm88k.c +++ /dev/null @@ -1,142 +0,0 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. - -This file is part of GLD, the Gnu Linker. - -GLD 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 1, or (at your option) -any later version. - -GLD 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 GLD; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - * $Id$ - * -*/ - -/* - * Written by Steve Chamberlain steve@cygnus.com - */ - - -#include "sysdep.h" -#include "bfd.h" - - -#include "ld.h" -#include "config.h" -#include "ldemul.h" -#include "ldfile.h" -#include "ldmisc.h" - -extern boolean lang_float_flag; - - -extern enum bfd_architecture ldfile_output_architecture; -extern unsigned long ldfile_output_machine; -extern char *ldfile_output_machine_name; - -extern bfd *output_bfd; - - - -static void gldm88kbcs_before_parse() -{ - extern char lprefix; - lprefix = '@'; -} - - -static void -gldm88kbcs_after_parse() -{ - -} - -static void -gldm88kbcs_after_allocation() -{ - -} - -static void -gldm88kbcs_before_allocation() -{ - -} - - -static void -gldm88kbcs_set_output_arch() -{ - /* Set the output architecture and machine if possible */ - bfd_set_arch_mach(output_bfd, ldfile_output_architecture, ldfile_output_machine); -} - -static char * -gldm88kbcs_choose_target() -{ - char *from_outside = getenv(TARGET_ENVIRON); - if (from_outside != (char *)NULL) - return from_outside; - return GLDM88KBCS_TARGET; -} - -static void -gldm88kbcs_syslib() -{ - info("%S SYSLIB ignored\n"); -} - -static void -gldm88kbcs_hll(ignore) -char *ignore; -{ - info("%S HLL ignored\n"); -} - -static char *gldm88kbcs_script = -#include "ldm88k.x" -; - -static char *gldm88kbcs_script_option_Ur = -#include "ldm88kUr.x" -; - -static char *gldm88kbcs_script_option_r = -#include "ldm88kr.x" -; - -static char *gldm88kbcs_get_script() -{ - extern ld_config_type config; - if (config.relocateable_output == true && - config.build_constructors == true) { - return gldm88kbcs_script_option_Ur; - } - if (config.relocateable_output) { - return gldm88kbcs_script_option_r; - } - - return gldm88kbcs_script; -} -struct ld_emulation_xfer_struct ld_gldm88kbcs_emulation = -{ - gldm88kbcs_before_parse, - gldm88kbcs_syslib, - gldm88kbcs_hll, - gldm88kbcs_after_parse, - gldm88kbcs_after_allocation, - gldm88kbcs_set_output_arch, - gldm88kbcs_choose_target, - gldm88kbcs_before_allocation, - gldm88kbcs_get_script, -}; - diff --git a/ld/ldm88k.sc b/ld/ldm88k.sc deleted file mode 100755 index cc123c85d2d..00000000000 --- a/ld/ldm88k.sc +++ /dev/null @@ -1,52 +0,0 @@ -TARGET(m88kbcs) -OUTPUT_FORMAT(m88kbcs) -OUTPUT_ARCH(m88k) -ENTRY(__start) -SEARCH_DIR(/lib) -SEARCH_DIR(/usr/lib) -SEARCH_DIR(/usr/local/lib) -SECTIONS -{ - .text 0x10000 + SIZEOF_HEADERS : - { - CREATE_OBJECT_SYMBOLS - /* If relocating */ - __.text.start = .; - __.init.start = .; - LONG(0xf400c001) - __.init.end = .; - /* End if relocating */ - *(.text) - /* If relocating */ - __.tdesc_start = .; - *(.tdesc) - __.text_end = .; - __.initp.start = .; - __.initp.end =.; - - _etext =.; - /* End if relocating */ - } - .data SIZEOF(.text) + ADDR(.text) + 0x400000: - { - *(.data) - __CTOR_LIST__ = .; - *(CTOR) - LONG(0); - __DTOR_LIST__ = . ; - *(DTOR) - LONG(0); - *(.comment) - _edata = .; - } - .bss SIZEOF(.data) + ADDR(.data) : - { - *(.bss) - [COMMON] - _end = .; - ___end = .; - } -} - - - diff --git a/ld/ldm88kUr.sc b/ld/ldm88kUr.sc deleted file mode 100755 index 8d3f12b89ed..00000000000 --- a/ld/ldm88kUr.sc +++ /dev/null @@ -1,31 +0,0 @@ -SCRIPT -SEARCH_DIR(/lib) -SEARCH_DIR(/usr/lib) -SEARCH_DIR(/usr/local/lib) -SECTIONS -{ - .text 0: - { - CREATE_OBJECT_SYMBOLS - *(.text) - } - .data SIZEOF(.text) + ADDR(.text) : - { - *(.data) - ___DTOR_LIST__ = . ; - LONG((___CTOR_LIST__ - .) / 4 -2) - *(___DTOR_LIST__) - LONG(0) - ___CTOR_LIST__ = . ; - LONG((___end_list__ - .) / 4 -2) - *(___CTOR_LIST__) - LONG(0) - ___end_list__ = . ; - } - .bss SIZEOF(.data) + ADDR(.data) : - { - *(.bss) - [COMMON] - } -} -ENDSCRIPT diff --git a/ld/ldm88kr.sc b/ld/ldm88kr.sc deleted file mode 100755 index a3b39fe8573..00000000000 --- a/ld/ldm88kr.sc +++ /dev/null @@ -1,20 +0,0 @@ -SEARCH_DIR(/lib) -SEARCH_DIR(/usr/lib) -SEARCH_DIR(/usr/local/lib) -SECTIONS -{ - .text 0: - { - CREATE_OBJECT_SYMBOLS - *(.text) - } - .data SIZEOF(.text) + ADDR(.text) : - { - *(.data) - } - .bss SIZEOF(.data) + ADDR(.data) : - { - *(.bss) - [COMMON] - } -} diff --git a/ld/ldmain.c b/ld/ldmain.c deleted file mode 100644 index 71ca4cf119b..00000000000 --- a/ld/ldmain.c +++ /dev/null @@ -1,860 +0,0 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. - Written by Steve Chamberlain steve@cygnus.com - -This file is part of GLD, the Gnu Linker. - -GLD 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. - -GLD 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 GLD; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - * $Id$ - */ - -#include "bfd.h" -#include "sysdep.h" - -#include "config.h" -#include "ld.h" -#include "ldmain.h" -#include "ldmisc.h" -#include "ldwrite.h" -#include "ldgram.h" -#include "ldsym.h" -#include "ldlang.h" -#include "ldemul.h" -#include "ldlex.h" -#include "ldfile.h" - -/* IMPORTS */ -extern boolean lang_has_input_file; -extern boolean trace_files; -/* EXPORTS */ - -char *default_target; -char *output_filename = "a.out"; -/* Name this program was invoked by. */ -char *program_name; - -/* The file that we're creating */ -bfd *output_bfd = 0; - -extern boolean option_v; - -/* The local symbol prefix */ -char lprefix = 'L'; - -/* Count the number of global symbols multiply defined. */ -int multiple_def_count; - - -/* Count the number of symbols defined through common declarations. - This count is referenced in symdef_library, linear_library, and - modified by enter_global_ref. - - It is incremented when a symbol is created as a common, and - decremented when the common declaration is overridden - - Another way of thinking of it is that this is a count of - all ldsym_types with a ->scoms field */ - -unsigned int commons_pending; - -/* Count the number of global symbols referenced and not defined. - common symbols are not included in this count. */ - -unsigned int undefined_global_sym_count; - - - -/* Count the number of warning symbols encountered. */ -int warning_count; - -/* have we had a load script ? */ -extern boolean had_script; - -/* Nonzero means print names of input files as processed. */ -boolean trace_files; - - - -/* 1 => write load map. */ -boolean write_map; - - -int unix_relocate; -#ifdef GNU960 -/* Indicates whether output file will be b.out (default) or coff */ -enum target_flavour output_flavor = BFD_BOUT_FORMAT; -#endif - -/* Force the make_executable to be output, even if there are non-fatal - errors */ -boolean force_make_executable; - -/* A count of the total number of local symbols ever seen - by adding - the symbol_count field of each newly read afile.*/ - -unsigned int total_symbols_seen; - -/* A count of the number of read files - the same as the number of elements - in file_chain - */ -unsigned int total_files_seen; - -/* IMPORTS */ -args_type command_line; -ld_config_type config; -int -main (argc, argv) - char **argv; - int argc; -{ - char *emulation; - program_name = argv[0]; - output_filename = "a.out"; - - bfd_init(); -#ifdef GNU960 - { - int i; - - check_v960( argc, argv ); - emulation = GLD960_EMULATION_NAME; - for ( i = 1; i < argc; i++ ){ - if ( !strcmp(argv[i],"-Fcoff") ){ - emulation = LNK960_EMULATION_NAME; - output_flavor = BFD_COFF_FORMAT; - break; - } - } - } -#else - emulation = (char *) getenv(EMULATION_ENVIRON); -#endif - - /* Initialize the data about options. */ - - trace_files = false; - write_map = false; - config.relocateable_output = false; - unix_relocate = 0; - command_line.force_common_definition = false; - - ldfile_add_arch(""); - ldfile_add_library_path("./"); - config.make_executable = true; - force_make_executable = false; - - - /* Initialize the cumulative counts of symbols. */ - undefined_global_sym_count = 0; - warning_count = 0; - multiple_def_count = 0; - commons_pending = 0; - - config.magic_demand_paged = true; - config.text_read_only = true; - config.make_executable = true; - if (emulation == (char *)NULL) { - emulation= DEFAULT_EMULATION; - } - - ldemul_choose_mode(emulation); - default_target = ldemul_choose_target(); - lang_init(); - ldemul_before_parse(); - lang_has_input_file = false; - parse_args(argc, argv); - lang_final(); - if (trace_files) { - info("%P: mode %s\n", emulation); - } - if (lang_has_input_file == false) { - info("%P%F: No input files\n"); - } - - ldemul_after_parse(); - lang_process(); - - /* Print error messages for any missing symbols, for any warning - symbols, and possibly multiple definitions */ - - /* Print a map, if requested. */ - - if (write_map) { - ldsym_print_symbol_table (); - lang_map(stdout); - } - - if (config.text_read_only) { - /* Look for a text section and mark the readonly attribute in it */ - asection *found = bfd_get_section_by_name(output_bfd, ".text"); - if (found == (asection *)NULL) { - info("%P%F: text marked read only, but no text section present"); - } - found->flags |= SEC_READONLY; - } - - if (config.relocateable_output) { - output_bfd->flags &= ~EXEC_P; - ldwrite(); - bfd_close(output_bfd); - } - else { - output_bfd->flags |= EXEC_P; - - ldwrite(); - bfd_close(output_bfd); - if (config.make_executable == false && force_make_executable == false) { - unlink(output_filename); - } - return (!config.make_executable); - } - - return(0); -} /* main() */ - - -void -Q_read_entry_symbols (desc, entry) - bfd *desc; - struct lang_input_statement_struct *entry; -{ - if (entry->asymbols == (asymbol **)NULL) { - bfd_size_type table_size = get_symtab_upper_bound(desc); - entry->asymbols = (asymbol **)ldmalloc(table_size); - entry->symbol_count = bfd_canonicalize_symtab(desc, entry->asymbols) ; - } -} - - -/* - * turn this item into a reference - */ -static void -refize(sp, nlist_p) -ldsym_type *sp; -asymbol **nlist_p; -{ - asymbol *sym = *nlist_p; - sym->value = 0; - sym->flags = BSF_UNDEFINED; - sym->section = (asection *)NULL; - sym->udata =(PTR)( sp->srefs_chain); - sp->srefs_chain = nlist_p; -} -/* -This function is called for each name which is seen which has a global -scope. It enters the name into the global symbol table in the correct -symbol on the correct chain. Remember that each ldsym_type has three -chains attatched, one of all definitions of a symbol, one of all -references of a symbol and one of all common definitions of a symbol. - -When the function is over, the supplied is left connected to the bfd -to which is was born, with its udata field pointing to the next member -on the chain in which it has been inserted. - -A certain amount of jigery pokery is necessary since commons come -along and upset things, we only keep one item in the common chain; the -one with the biggest size seen sofar. When another common comes along -it either bumps the previous definition into the ref chain, since it -is bigger, or gets turned into a ref on the spot since the one on the -common chain is already bigger. If a real definition comes along then -the common gets bumped off anyway. - -Whilst all this is going on we keep a count of the number of multiple -definitions seen, undefined global symbols and pending commons. -*/ - - -void -Q_enter_global_ref (nlist_p) - asymbol **nlist_p; - -{ - asymbol *sym = *nlist_p; - CONST char *name = sym->name; - ldsym_type *sp = ldsym_get (name); - - flagword this_symbol_flags = sym->flags; - - - ASSERT(sym->udata == 0); - - - if (flag_is_constructor(this_symbol_flags)) { - /* Add this constructor to the list we keep */ - ldlang_add_constructor(sp); - /* Turn any commons into refs */ - if (sp->scoms_chain != (asymbol **)NULL) { - refize(sp, sp->scoms_chain); - sp->scoms_chain = 0; - } - - - } - else { - if (flag_is_common(this_symbol_flags)) { - /* If we have a definition of this symbol already then - this common turns into a reference. Also we only - ever point to the largest common, so if we - have a common, but it's bigger that the new symbol - the turn this into a reference too. */ - if (sp->sdefs_chain) - { - /* This is a common symbol, but we already have a definition - for it, so just link it into the ref chain as if - it were a reference */ - refize(sp, nlist_p); - } - else if (sp->scoms_chain) { - /* If we have a previous common, keep only the biggest */ - if ( (*(sp->scoms_chain))->value > sym->value) { - /* other common is bigger, throw this one away */ - refize(sp, nlist_p); - } - else if (sp->scoms_chain != nlist_p) { - /* other common is smaller, throw that away */ - refize(sp, sp->scoms_chain); - sp->scoms_chain = nlist_p; - } - } - else { - /* This is the first time we've seen a common, so remember it - - if it was undefined before, we know it's defined now. If - the symbol has been marked as really being a constructor, - then treat this as a ref - */ - if (sp->flags & SYM_CONSTRUCTOR) { - /* Turn this into a ref */ - refize(sp, nlist_p); - } - else { - /* treat like a common */ - if (sp->srefs_chain) - undefined_global_sym_count--; - - commons_pending++; - sp->scoms_chain = nlist_p; - } - } - } - - else if (flag_is_defined(this_symbol_flags)) { - /* This is the definition of a symbol, add to def chain */ - if (sp->sdefs_chain && (*(sp->sdefs_chain))->section != sym->section) { - /* Multiple definition */ - asymbol *sy = *(sp->sdefs_chain); - lang_input_statement_type *stat = (lang_input_statement_type *) sy->the_bfd->usrdata; - lang_input_statement_type *stat1 = (lang_input_statement_type *) sym->the_bfd->usrdata; - asymbol ** stat1_symbols = stat1 ? stat1->asymbols: 0; - asymbol ** stat_symbols = stat ? stat->asymbols:0; - - multiple_def_count++; - info("%C: multiple definition of `%T'\n", - sym->the_bfd, - sym->section, - stat1_symbols, - sym->value, - sym); - - info("%C: first seen here\n", - sy->the_bfd, - sy->section, - stat_symbols, - sy->value); - } - else { - sym->udata =(PTR)( sp->sdefs_chain); - sp->sdefs_chain = nlist_p; - } - /* A definition overrides a common symbol */ - if (sp->scoms_chain) { - refize(sp, sp->scoms_chain); - sp->scoms_chain = 0; - commons_pending--; - } - else if (sp->srefs_chain) { - /* If previously was undefined, then remember as defined */ - undefined_global_sym_count--; - } - } - else { - if (sp->scoms_chain == (asymbol **)NULL - && sp->srefs_chain == (asymbol **)NULL - && sp->sdefs_chain == (asymbol **)NULL) { - /* And it's the first time we've seen it */ - undefined_global_sym_count++; - - } - - refize(sp, nlist_p); - } - } - - ASSERT(sp->sdefs_chain == 0 || sp->scoms_chain == 0); - ASSERT(sp->scoms_chain ==0 || (*(sp->scoms_chain))->udata == 0); - - -} - -static void -Q_enter_file_symbols (entry) -lang_input_statement_type *entry; -{ - asymbol **q ; - entry->common_section = - bfd_make_section(entry->the_bfd, "COMMON"); - - ldlang_add_file(entry); - - - if (trace_files || option_v) { - info("%I\n", entry); - } - - total_symbols_seen += entry->symbol_count; - total_files_seen ++; - for (q = entry->asymbols; *q; q++) - { - asymbol *p = *q; - - if (flag_is_undefined_or_global_or_common_or_constructor(p->flags)) - { - Q_enter_global_ref(q); - } - if (p->flags & BSF_INDIRECT) { - add_indirect(q); - } - - if (p->flags & BSF_WARNING) { - add_warning(p); - } - ASSERT(p->flags != 0); - } -} - - - -/* Searching libraries */ - -struct lang_input_statement_struct *decode_library_subfile (); -void linear_library (), symdef_library (); - -/* Search the library ENTRY, already open on descriptor DESC. - This means deciding which library members to load, - making a chain of `struct lang_input_statement_struct' for those members, - and entering their global symbols in the hash table. */ - -void -search_library (entry) - struct lang_input_statement_struct *entry; -{ - - /* No need to load a library if no undefined symbols */ - if (!undefined_global_sym_count) return; - - if (bfd_has_map(entry->the_bfd)) - symdef_library (entry); - else - linear_library (entry); - -} - - -#ifdef GNU960 -static -boolean -gnu960_check_format (abfd, format) -bfd *abfd; -bfd_format format; -{ - boolean retval; - - if ((bfd_check_format(abfd,format) == true) - && (abfd->xvec->flavour == output_flavor) ){ - return true; - } - - - return false; -} -#endif - -void -ldmain_open_file_read_symbol (entry) -struct lang_input_statement_struct *entry; -{ - if (entry->asymbols == (asymbol **)NULL - &&entry->real == true - && entry->filename != (char *)NULL) - { - ldfile_open_file (entry); - - -#ifdef GNU960 - if (gnu960_check_format(entry->the_bfd, bfd_object)) -#else - if (bfd_check_format(entry->the_bfd, bfd_object)) -#endif - { - entry->the_bfd->usrdata = (PTR)entry; - - - Q_read_entry_symbols (entry->the_bfd, entry); - - /* look through the sections in the file and see if any of them - are constructors */ - ldlang_check_for_constructors (entry); - - Q_enter_file_symbols (entry); - } -#ifdef GNU960 - else if (gnu960_check_format(entry->the_bfd, bfd_archive)) -#else - else if (bfd_check_format(entry->the_bfd, bfd_archive)) -#endif - { - entry->the_bfd->usrdata = (PTR)entry; - - entry->subfiles = (lang_input_statement_type *)NULL; - search_library (entry); - } - else - { - info("%F%B: malformed input file (not rel or archive) \n", - entry->the_bfd); - } - } - -} - - -/* Construct and return a lang_input_statement_struct for a library member. - The library's lang_input_statement_struct is library_entry, - and the library is open on DESC. - SUBFILE_OFFSET is the byte index in the library of this member's header. - We store the length of the member into *LENGTH_LOC. */ - -lang_input_statement_type * -decode_library_subfile (library_entry, subfile_offset) - struct lang_input_statement_struct *library_entry; - bfd *subfile_offset; -{ - register struct lang_input_statement_struct *subentry; - subentry = (struct lang_input_statement_struct *) ldmalloc ((bfd_size_type)(sizeof (struct lang_input_statement_struct))); - subentry->filename = subfile_offset -> filename; - subentry->local_sym_name = subfile_offset->filename; - subentry->asymbols = 0; - subentry->the_bfd = subfile_offset; - subentry->subfiles = 0; - subentry->next = 0; - subentry->superfile = library_entry; - subentry->is_archive = false; - - subentry->just_syms_flag = false; - subentry->loaded = false; - subentry->chain = 0; - - return subentry; -} - -boolean subfile_wanted_p (); -void -clear_syms(entry, offset) -struct lang_input_statement_struct *entry; -file_ptr offset; -{ - carsym *car; - unsigned long indx = bfd_get_next_mapent(entry->the_bfd, - BFD_NO_MORE_SYMBOLS, - &car); - while (indx != BFD_NO_MORE_SYMBOLS) { - if (car->file_offset == offset) { - car->name = 0; - } - indx = bfd_get_next_mapent(entry->the_bfd, indx, &car); - } - -} - -/* Search a library that has a map - */ -void -symdef_library (entry) - struct lang_input_statement_struct *entry; - -{ - register struct lang_input_statement_struct *prev = 0; - - boolean not_finished = true; - - - while (not_finished == true) - { - carsym *exported_library_name; - bfd *prev_archive_member_bfd = 0; - - int idx = bfd_get_next_mapent(entry->the_bfd, - BFD_NO_MORE_SYMBOLS, - &exported_library_name); - - not_finished = false; - - while (idx != BFD_NO_MORE_SYMBOLS && undefined_global_sym_count) - { - - if (exported_library_name->name) - { - - ldsym_type *sp = ldsym_get_soft (exported_library_name->name); - - /* If we find a symbol that appears to be needed, think carefully - about the archive member that the symbol is in. */ - /* So - if it exists, and is referenced somewhere and is - undefined or */ - if (sp && sp->srefs_chain && !sp->sdefs_chain) - { - bfd *archive_member_bfd = bfd_get_elt_at_index(entry->the_bfd, idx); - struct lang_input_statement_struct *archive_member_lang_input_statement_struct; - -#ifdef GNU960 - if (archive_member_bfd && gnu960_check_format(archive_member_bfd, bfd_object)) -#else - if (archive_member_bfd && bfd_check_format(archive_member_bfd, bfd_object)) -#endif - { - - /* Don't think carefully about any archive member - more than once in a given pass. */ - if (prev_archive_member_bfd != archive_member_bfd) - { - - prev_archive_member_bfd = archive_member_bfd; - - /* Read the symbol table of the archive member. */ - - if (archive_member_bfd->usrdata != (PTR)NULL) { - - archive_member_lang_input_statement_struct =(lang_input_statement_type *) archive_member_bfd->usrdata; - } - else { - - archive_member_lang_input_statement_struct = - decode_library_subfile (entry, archive_member_bfd); - archive_member_bfd->usrdata = (PTR) archive_member_lang_input_statement_struct; - - } - - if (archive_member_lang_input_statement_struct == 0) { - info ("%F%I contains invalid archive member %s\n", - entry, - sp->name); - } - - if (archive_member_lang_input_statement_struct->loaded == false) - { - - Q_read_entry_symbols (archive_member_bfd, archive_member_lang_input_statement_struct); - /* Now scan the symbol table and decide whether to load. */ - - - if (subfile_wanted_p (archive_member_lang_input_statement_struct) == true) - - { - /* This member is needed; load it. - Since we are loading something on this pass, - we must make another pass through the symdef data. */ - - not_finished = true; - - Q_enter_file_symbols (archive_member_lang_input_statement_struct); - - if (prev) - prev->chain = archive_member_lang_input_statement_struct; - else - entry->subfiles = archive_member_lang_input_statement_struct; - - - prev = archive_member_lang_input_statement_struct; - - - /* Clear out this member's symbols from the symdef data - so that following passes won't waste time on them. */ - clear_syms(entry, exported_library_name->file_offset); - archive_member_lang_input_statement_struct->loaded = true; - } - } - } - } - } - } - idx = bfd_get_next_mapent(entry->the_bfd, idx, &exported_library_name); - } - } -} - -void -linear_library (entry) -struct lang_input_statement_struct *entry; -{ - boolean more_to_do = true; - register struct lang_input_statement_struct *prev = 0; - - while (more_to_do) { - - bfd * archive = bfd_openr_next_archived_file(entry->the_bfd,0); - - more_to_do = false; - while (archive) { -#ifdef GNU960 - if (gnu960_check_format(archive, bfd_object)) -#else - if (bfd_check_format(archive, bfd_object)) -#endif - { - register struct lang_input_statement_struct *subentry; - - subentry = decode_library_subfile (entry, - archive); - - archive->usrdata = (PTR) subentry; - if (!subentry) return; - if (subentry->loaded == false) { - Q_read_entry_symbols (archive, subentry); - - if (subfile_wanted_p (subentry) == true) - { - Q_enter_file_symbols (subentry); - - if (prev) - prev->chain = subentry; - else - entry->subfiles = subentry; - prev = subentry; - - more_to_do = true; - subentry->loaded = true; - } - } - } - archive = bfd_openr_next_archived_file(entry->the_bfd,archive); - - } - - } -} - - /* ENTRY is an entry for a library member. - Its symbols have been read into core, but not entered. - Return nonzero if we ought to load this member. */ - -boolean -subfile_wanted_p (entry) -struct lang_input_statement_struct *entry; -{ - asymbol **q; - - for (q = entry->asymbols; *q; q++) - { - asymbol *p = *q; - - /* If the symbol has an interesting definition, we could - potentially want it. */ - - if (p->flags & BSF_INDIRECT) { - /* Grab out the name we've indirected to, and keep the insides - */ - add_indirect(q); - } - - if (p->flags & BSF_FORT_COMM - || p->flags & BSF_GLOBAL) - { - register ldsym_type *sp = ldsym_get_soft (p->name); - - - /* If this symbol has not been hashed, - we can't be looking for it. */ - if (sp != (ldsym_type *)NULL - && sp->sdefs_chain == (asymbol **)NULL) { - if (sp->srefs_chain != (asymbol **)NULL - || sp->scoms_chain != (asymbol **)NULL) - { - /* This is a symbol we are looking for. It is either - not yet defined or common. */ - - if (flag_is_common(p->flags)) - { - - /* If the symbol in the table is a constructor, we won't to - anything fancy with it */ - if ((sp->flags & SYM_CONSTRUCTOR) == 0) { - /* This libary member has something to - say about this element. We should - remember if its a new size */ - /* Move something from the ref list to the com list */ - if(sp->scoms_chain) { - /* Already a common symbol, maybe update it */ - if (p->value > (*(sp->scoms_chain))->value) { - (*(sp->scoms_chain))->value = p->value; - } - } - else { - /* Take a value from the ref chain - Here we are moving a symbol from the owning bfd - to another bfd. We must set up the - common_section portion of the bfd thing */ - - - - sp->scoms_chain = sp->srefs_chain; - sp->srefs_chain = - (asymbol **)((*(sp->srefs_chain))->udata); - (*(sp->scoms_chain))->udata = (PTR)NULL; - - (*( sp->scoms_chain))->flags = BSF_FORT_COMM; - /* Remember the size of this item */ - sp->scoms_chain[0]->value = p->value; - commons_pending++; - undefined_global_sym_count--; - } { - asymbol *com = *(sp->scoms_chain); - if (((lang_input_statement_type *) - (com->the_bfd->usrdata))->common_section == - (asection *)NULL) { - ((lang_input_statement_type *) - (com->the_bfd->usrdata))->common_section = - bfd_make_section(com->the_bfd, "COMMON"); - } - } - } - ASSERT(p->udata == 0); - } - - else { - if (write_map) - { - info("%I needed due to %s\n",entry, sp->name); - } - return true; - } - } - } - } - } - - return false; -} - diff --git a/ld/ldmain.h b/ld/ldmain.h deleted file mode 100644 index 9f3fa1a63ae..00000000000 --- a/ld/ldmain.h +++ /dev/null @@ -1,23 +0,0 @@ -/* ldmain.h - - - Copyright (C) 1991 Free Software Foundation, Inc. - - This file is part of GLD, the Gnu Linker. - - GLD 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 1, or (at your option) - any later version. - - GLD 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 GLD; see the file COPYING. If not, write to - the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -PROTO(void, Q_enter_global_ref,(asymbol **)); -PROTO(void, Q_read_file_symbols,(struct lang_input_statement_struct *)); - diff --git a/ld/ldmisc.c b/ld/ldmisc.c deleted file mode 100644 index 9ae7515c1e1..00000000000 --- a/ld/ldmisc.c +++ /dev/null @@ -1,281 +0,0 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. - -This file is part of GLD, the Gnu Linker. - -GLD 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 1, or (at your option) -any later version. - -GLD 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 GLD; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - * $Id$ - */ - -/* - ldmisc.c - -*/ - -#include "sysdep.h" -#include -#include "bfd.h" - -#include "ld.h" -#include "ldmisc.h" -#include "ldlang.h" -#include "ldlex.h" -/* IMPORTS */ - -extern char *program_name; - -extern FILE *ldlex_input_stack; -extern char *ldfile_input_filename; -extern ld_config_type config; - -void -yyerror(arg) -char *arg; -{ - info("%P%F: %S %s\n",arg); -} - -extern int errno; -extern int sys_nerr; -extern char *sys_errlist[]; - -/* - %F error is fatal - %P print progam name - %S print script file and linenumber - %E current bfd error or errno - %I filename from a lang_input_statement_type - %B filename from a bfd - %T symbol table entry - %X no object output, fail return - %V hex bfd_vma - %C Clever filename:linenumber - % -*/ -void info(va_alist) -va_dcl -{ - char *fmt; - boolean fatal = false; - va_list arg; - va_start(arg); - fmt = va_arg(arg, char *); - while (*fmt) { - while (*fmt != '%' && *fmt != '\0') { - fputc(*fmt, stderr); - fmt++; - } - if (*fmt == '%') { - fmt ++; - switch (*fmt++) { - case 'X': - config.make_executable = false; - break; - case 'V': - fprintf(stderr,"%08lx", va_arg(arg, bfd_vma)); - break; - case 'T': - { - asymbol *symbol = va_arg(arg, asymbol *); - if (symbol) { - asection *section = symbol->section; - if ((symbol->flags & BSF_UNDEFINED) == 0) { - CONST char *section_name = section == (asection *)NULL ? - "absolute" : section->name; - fprintf(stderr,"%s (%s)", symbol->name, section_name); - } - else { - fprintf(stderr,"%s", symbol->name); - } - } - else { - fprintf(stderr,"no symbol"); - } - } - break; - case 'B': - { - bfd *abfd = va_arg(arg, bfd *); - if (abfd->my_archive) { - fprintf(stderr,"%s(%s)", abfd->my_archive->filename, - abfd->filename); - } - else { - fprintf(stderr,"%s", abfd->filename); - - } - } - break; - case 'F': - fatal = true; - break; - case 'P': - fprintf(stderr,"%s", program_name); - break; - case 'E': - /* Replace with the most recent errno explanation */ - - - fprintf(stderr, bfd_errmsg(bfd_error)); - - - break; - case 'I': - { - lang_input_statement_type *i = - va_arg(arg,lang_input_statement_type *); - - fprintf(stderr,"%s", i->local_sym_name); - } - break; - case 'S': - /* Print source script file and line number */ - - if (ldlex_input_stack) { - extern unsigned int lineno; - if (ldfile_input_filename == (char *)NULL) { - fprintf(stderr,"command line"); - } - else { - fprintf(stderr,"%s:%u", ldfile_input_filename, lineno ); - } - } - else { - int ch; - int n = 0; - fprintf(stderr,"command (just before \""); - ch = lex_input(); - while (ch != 0 && n < 10) { - fprintf(stderr, "%c", ch); - ch = lex_input(); - n++; - } - fprintf(stderr,"\")"); - - } - break; - case 'C': - { - CONST char *filename; - CONST char *functionname; - unsigned int linenumber; - bfd *abfd = va_arg(arg, bfd *); - asection *section = va_arg(arg, asection *); - asymbol **symbols = va_arg(arg, asymbol **); - bfd_vma offset = va_arg(arg, bfd_vma); - - if (bfd_find_nearest_line(abfd, - section, - symbols, - offset, - &filename, - &functionname, - &linenumber)) - { - if (filename == (char *)NULL) - filename = abfd->filename; - if (functionname != (char *)NULL) - fprintf(stderr,"%s:%u: (%s)", filename, linenumber, functionname); - else if (linenumber != 0) - fprintf(stderr,"%s:%u", filename, linenumber); - else - fprintf(stderr,"%s", filename); - - } - else { - fprintf(stderr,"%s", abfd->filename); - } - } - break; - - case 's': - fprintf(stderr,"%s", va_arg(arg, char *)); - break; - case 'd': - fprintf(stderr,"%d", va_arg(arg, int)); - break; - default: - fprintf(stderr,"%s", va_arg(arg, char *)); - break; - } - } - } - if (fatal == true) { - extern char *output_filename; - if (output_filename) - unlink(output_filename); - exit(1); - } - va_end(arg); -} - - -void -info_assert(file, line) -char *file; -unsigned int line; -{ - info("%F%P internal error %s %d\n", file,line); -} - -/* Return a newly-allocated string - whose contents concatenate those of S1, S2, S3. */ - -char * -DEFUN(concat, (s1, s2, s3), - CONST char *s1 AND - CONST char *s2 AND - CONST char *s3) -{ - size_t len1 = strlen (s1); - size_t len2 = strlen (s2); - size_t len3 = strlen (s3); - char *result = ldmalloc (len1 + len2 + len3 + 1); - - if (len1 != 0) - memcpy(result, s1, len1); - if (len2 != 0) - memcpy(result+len1, s2, len2); - if (len3 != 0) - memcpy(result+len1+len2, s2, len3); - *(result + len1 + len2 + len3) = 0; - - return result; -} - - - -char *ldmalloc (size) -size_t size; -{ - char * result = malloc (size); - - if (result == (char *)NULL && size != 0) - info("%F%P virtual memory exhausted\n"); - - return result; -} - - - -char *DEFUN(buystring,(x), - CONST char *CONST x) -{ - size_t l = strlen(x)+1; - char *r = ldmalloc(l); - memcpy(r, x,l); - return r; -} diff --git a/ld/ldmisc.h b/ld/ldmisc.h deleted file mode 100644 index a9391cd0cf3..00000000000 --- a/ld/ldmisc.h +++ /dev/null @@ -1,34 +0,0 @@ -/* ldmisc.h - - - Copyright (C) 1991 Free Software Foundation, Inc. - - This file is part of GLD, the Gnu Linker. - - GLD 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 1, or (at your option) - any later version. - - GLD 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 GLD; see the file COPYING. If not, write to - the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - - - -/* VARARGS*/ -PROTO(void,info,()); -PROTO(void,info_assert,(char *, unsigned int)); -PROTO(void,yyerror,(char *)); -PROTO(char *,concat,(CONST char *, CONST char *, CONST char *)); -PROTO(char *, ldmalloc,(size_t)); -PROTO(char *,buystring,(CONST char *CONST)); -#define ASSERT(x) \ -{ if (!(x)) info_assert(__FILE__,__LINE__); } - -#define FAIL() \ -{ info_assert(__FILE__,__LINE__); } diff --git a/ld/ldsym.c b/ld/ldsym.c deleted file mode 100644 index 4ad9476bba1..00000000000 --- a/ld/ldsym.c +++ /dev/null @@ -1,490 +0,0 @@ -/* All symbol handling for the linker - Copyright (C) 1991 Free Software Foundation, Inc. - Written by Steve Chamberlain steve@cygnus.com - -This file is part of GLD, the Gnu Linker. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - * $Id$ - */ - -/* - We keep a hash table of global symbols. Each entry in a hash table - is called an ldsym_type. Each has three chains; a pointer to a - chain of definitions for the symbol (hopefully one long), a pointer - to a chain of references to the symbol, and a pointer to a chain of - common symbols. Each pointer points into the canonical symbol table - provided by bfd, each one of which points to an asymbol. Duringing - linkage, the linker uses the udata field to point to the next entry - in a canonical table.... - - - ld_sym - | | - +----------+ +----------+ - | defs | a canonical symbol table - +----------+ +----------+ - | refs | -----> | one entry| -----> asymbol - +----------+ +----------+ | | - | coms | | | +---------+ - +----------+ +----------+ | udata |-----> another canonical symbol - +---------+ - - - - It is very simple to make all the symbol pointers point to the same - definition - just run down the chain and make the asymbols pointers - within the canonical table point to the asymbol attacthed to the - definition of the symbol. - -*/ - -#include "bfd.h" -#include "sysdep.h" - -#include "ld.h" -#include "ldsym.h" -#include "ldmisc.h" -#include "ldlang.h" -/* IMPORT */ - -extern bfd *output_bfd; -extern strip_symbols_type strip_symbols; -extern discard_locals_type discard_locals; -/* Head and tail of global symbol table chronological list */ - -ldsym_type *symbol_head = (ldsym_type *)NULL; -ldsym_type **symbol_tail_ptr = &symbol_head; - -/* - incremented for each symbol in the ldsym_type table - no matter what flavour it is -*/ -unsigned int global_symbol_count; - -/* IMPORTS */ - -extern boolean option_longmap ; - -/* LOCALS */ -#define TABSIZE 1009 -static ldsym_type *global_symbol_hash_table[TABSIZE]; - -/* Compute the hash code for symbol name KEY. */ -static -#ifdef __GNUC__ -__inline -#endif - -int -DEFUN(hash_string,(key), - CONST char *key) -{ - register CONST char *cp; - register int k; - - cp = key; - k = 0; - while (*cp) - k = (((k << 1) + (k >> 14)) ^ (*cp++)) & 0x3fff; - - return k; -} - -static -#ifdef __GNUC__ -__inline -#endif ldsym_type *bp; -ldsym_type * -DEFUN(search,(key,hashval) , - CONST char *key AND - int hashval) -{ - ldsym_type *bp; - for (bp = global_symbol_hash_table[hashval]; bp; bp = bp->link) - if (! strcmp (key, bp->name)) { - if (bp->flags & SYM_INDIRECT) { - /* Use the symbol we're aliased to instead */ - return (ldsym_type *)(bp->sdefs_chain); - } - return bp; - } - return 0; -} - - -/* Get the symbol table entry for the global symbol named KEY. - Create one if there is none. */ -ldsym_type * -DEFUN(ldsym_get,(key), - CONST char *key) -{ - register int hashval; - register ldsym_type *bp; - - /* Determine the proper bucket. */ - - hashval = hash_string (key) % TABSIZE; - - /* Search the bucket. */ - bp = search(key, hashval); - if(bp) { - return bp; - } - - /* Nothing was found; create a new symbol table entry. */ - - bp = (ldsym_type *) ldmalloc ((bfd_size_type)(sizeof (ldsym_type))); - bp->srefs_chain = (asymbol **)NULL; - bp->sdefs_chain = (asymbol **)NULL; - bp->scoms_chain = (asymbol **)NULL; - bp->name = buystring(key); - bp->flags = 0; - /* Add the entry to the bucket. */ - - bp->link = global_symbol_hash_table[hashval]; - global_symbol_hash_table[hashval] = bp; - - /* Keep the chronological list up to date too */ - *symbol_tail_ptr = bp; - symbol_tail_ptr = &bp->next; - bp->next = 0; - global_symbol_count++; - - return bp; -} - -/* Like `ldsym_get' but return 0 if the symbol is not already known. */ - -ldsym_type * -DEFUN(ldsym_get_soft,(key), - CONST char *key) -{ - register int hashval; - /* Determine which bucket. */ - - hashval = hash_string (key) % TABSIZE; - - /* Search the bucket. */ - return search(key, hashval); -} - - - - - -static void -list_file_locals (entry) -lang_input_statement_type *entry; -{ - asymbol **q; - printf ( "\nLocal symbols of "); - info("%I", entry); - printf (":\n\n"); - if (entry->asymbols) { - for (q = entry->asymbols; *q; q++) - { - asymbol *p = *q; - /* If this is a definition, - update it if necessary by this file's start address. */ - if (p->flags & BSF_LOCAL) - info(" %V %s\n",p->value, p->name); - } - } -} - - -static void -print_file_stuff(f) -lang_input_statement_type *f; -{ - fprintf (stdout, " %s\n", f->filename); - if (f->just_syms_flag) - { - fprintf (stdout, " symbols only\n"); - } - else - { - asection *s; - if (true || option_longmap) { - for (s = f->the_bfd->sections; - s != (asection *)NULL; - s = s->next) { - print_address(s->output_offset); - printf (" %08x 2**%2ud %s\n", - (unsigned)s->size, s->alignment_power, s->name); - } - } - else { - for (s = f->the_bfd->sections; - s != (asection *)NULL; - s = s->next) { - printf("%s ", s->name); - print_address(s->output_offset); - printf("(%x)", (unsigned)s->size); - } - printf("hex \n"); - } - } - fprintf (stdout, "\n"); -} - -void -ldsym_print_symbol_table () -{ - fprintf (stdout, "**FILES**\n\n"); - - lang_for_each_file(print_file_stuff); - - fprintf(stdout, "**GLOBAL SYMBOLS**\n\n"); - fprintf(stdout, "offset section offset symbol\n"); - { - register ldsym_type *sp; - - for (sp = symbol_head; sp; sp = sp->next) - { - if (sp->flags & SYM_INDIRECT) { - fprintf(stdout,"indirect %s to %s\n", - sp->name, (((ldsym_type *)(sp->sdefs_chain))->name)); - } - else { - if (sp->sdefs_chain) - { - asymbol *defsym = *(sp->sdefs_chain); - asection *defsec = bfd_get_section(defsym); - print_address(defsym->value); - if (defsec) - { - printf(" %-10s", - bfd_section_name(output_bfd, - defsec)); - print_space(); - print_address(defsym->value+defsec->vma); - - } - else - { - printf(" ......."); - } - - } - - - if (sp->scoms_chain) { - printf("common "); - print_address((*(sp->scoms_chain))->value); - printf(" %s ",sp->name); - } - else if (sp->sdefs_chain) { - printf(" %s ",sp->name); - } - else { - printf("undefined "); - printf("%s ",sp->name); - - } - } - print_nl(); - - } - } - if (option_longmap) { - lang_for_each_file(list_file_locals); - } -} - -extern lang_output_section_statement_type *create_object_symbols; -extern char lprefix; -static asymbol ** -write_file_locals(output_buffer) -asymbol **output_buffer; -{ -LANG_FOR_EACH_INPUT_STATEMENT(entry) - { - /* Run trough the symbols and work out what to do with them */ - unsigned int i; - - /* Add one for the filename symbol if needed */ - if (create_object_symbols - != (lang_output_section_statement_type *)NULL) { - asection *s; - for (s = entry->the_bfd->sections; - s != (asection *)NULL; - s = s->next) { - if (s->output_section == create_object_symbols->bfd_section) { - /* Add symbol to this section */ - asymbol * newsym = - (asymbol *)bfd_make_empty_symbol(entry->the_bfd); - newsym->name = entry->local_sym_name; - /* The symbol belongs to the output file's text section */ - - /* The value is the start of this section in the output file*/ - newsym->value = 0; - newsym->flags = BSF_LOCAL; - newsym->section = s; - *output_buffer++ = newsym; - break; - } - } - } - for (i = 0; i < entry->symbol_count; i++) - { - asymbol *p = entry->asymbols[i]; - - if (flag_is_global(p->flags) || flag_is_absolute(p->flags)) - { - /* We are only interested in outputting - globals at this stage in special circumstances */ - if (p->the_bfd == entry->the_bfd - && flag_is_not_at_end(p->flags)) { - /* And this is one of them */ - *(output_buffer++) = p; - p->flags |= BSF_KEEP; - } - } - else { - if (flag_is_ordinary_local(p->flags)) - { - if (discard_locals == DISCARD_ALL) - { } - else if (discard_locals == DISCARD_L && - (p->name[0] == lprefix)) - { } - else if (p->flags == BSF_WARNING) - { } - else - { *output_buffer++ = p; } - } - else if (flag_is_debugger(p->flags)) - { - /* Only keep the debugger symbols if no stripping required */ - if (strip_symbols == STRIP_NONE) { - *output_buffer++ = p; - } - } - else if (flag_is_undefined(p->flags)) - { /* This must be global */ - } - else if (flag_is_common(p->flags)) { - /* And so must this */ - } - else if (p->flags & BSF_CTOR) { - /* Throw it away */ - } -else - { - FAIL(); - } - } - } - - - } - return output_buffer; -} - - -static asymbol ** -write_file_globals(symbol_table) -asymbol **symbol_table; -{ - FOR_EACH_LDSYM(sp) - { - if ((sp->flags & SYM_INDIRECT) == 0 && sp->sdefs_chain != (asymbol **)NULL) { - asymbol *bufp = (*(sp->sdefs_chain)); - - if ((bufp->flags & BSF_KEEP) ==0) { - ASSERT(bufp != (asymbol *)NULL); - - bufp->name = sp->name; - - if (sp->scoms_chain != (asymbol **)NULL) - - { - /* - defined as common but not allocated, this happens - only with -r and not -d, write out a common - definition - */ - bufp = *(sp->scoms_chain); - } - *symbol_table++ = bufp; - } - } - else if (sp->scoms_chain != (asymbol **)NULL) { - /* This symbol is a common - just output */ - asymbol *bufp = (*(sp->scoms_chain)); - *symbol_table++ = bufp; - } - else if (sp->srefs_chain != (asymbol **)NULL) { - /* This symbol is undefined but has a reference */ - asymbol *bufp = (*(sp->srefs_chain)); - *symbol_table++ = bufp; - } - else { - /* - This symbol has neither defs nor refs, it must have come - from the command line, since noone has used it it has no - data attatched, so we'll ignore it - */ - } - } - return symbol_table; -} - - - -void -ldsym_write() -{ - if (strip_symbols != STRIP_ALL) { - /* We know the maximum size of the symbol table - - it's the size of all the global symbols ever seen + - the size of all the symbols from all the files + - the number of files (for the per file symbols) - +1 (for the null at the end) - */ - extern unsigned int total_files_seen; - extern unsigned int total_symbols_seen; - - asymbol ** symbol_table = (asymbol **) - ldmalloc ((bfd_size_type)(global_symbol_count + - total_files_seen + - total_symbols_seen + 1) * sizeof (asymbol *)); - asymbol ** tablep = write_file_locals(symbol_table); - - tablep = write_file_globals(tablep); - - *tablep = (asymbol *)NULL; - bfd_set_symtab(output_bfd, symbol_table, (unsigned)( tablep - symbol_table)); - } -} - -/* -return true if the supplied symbol name is not in the -linker symbol table -*/ -boolean -DEFUN(ldsym_undefined,(sym), - CONST char *sym) -{ - ldsym_type *from_table = ldsym_get_soft(sym); - if (from_table != (ldsym_type *)NULL) { - if (from_table->sdefs_chain != (asymbol **)NULL) return false; - } - return true; -} diff --git a/ld/ldsym.h b/ld/ldsym.h deleted file mode 100644 index 1a671e2eab3..00000000000 --- a/ld/ldsym.h +++ /dev/null @@ -1,70 +0,0 @@ -/* ldsym.h - - Copyright (C) 1991 Free Software Foundation, Inc. - - This file is part of GLD, the Gnu Linker. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -typedef struct user_symbol_struct -{ - /* Point to next symbol in this hash chain */ - struct user_symbol_struct *link; - - /* Name of this symbol. */ - CONST char *name; - - /* Pointer to next symbol in order of symbol creation */ - struct user_symbol_struct *next; - - /* Chain of asymbols we see from input files - note that we point to the entry in the canonical table of - the pointer to the asymbol, *not* the asymbol. This means - that we can run back and fix all refs to point to the - defs nearly for free. - */ - asymbol **srefs_chain; - asymbol **sdefs_chain; - - /* only ever point to the largest ever common definition - - * all the rest are turned into refs - * scoms and sdefs are never != NULL at same time - */ - asymbol **scoms_chain; - - - - - - /* If this symbol is a constructor */ -#define SYM_CONSTRUCTOR 1 - /* If this symbol is a warning symbol */ -#define SYM_WARNING 2 - /* IF this is an alias for another symbol */ -#define SYM_INDIRECT 4 - int flags; -} ldsym_type; - - -PROTO(ldsym_type *, ldsym_get, (CONST char *)); -PROTO(ldsym_type *, ldsym_get_soft, (CONST char *)); -PROTO(void, ldsym_print_symbol_table,(void)); -PROTO(void, ldsym_write, (void)); -PROTO(boolean, ldsym_undefined, (CONST char *)); -#define FOR_EACH_LDSYM(x) \ - extern ldsym_type *symbol_head; \ - ldsym_type *x; \ - for (x = symbol_head; x != (ldsym_type *)NULL; x = x->next) - - diff --git a/ld/ldtemplate b/ld/ldtemplate deleted file mode 100755 index 961fbc02e54..00000000000 --- a/ld/ldtemplate +++ /dev/null @@ -1,159 +0,0 @@ -/* NOTE: If there are angle brackets here: then this is a - * template file (ldtemplate), intended for processing by sed. - * Otherwise, this file has already been processed by sed, - * and customized for a particular emulation target. - * In that DO NOT EDIT the file; edit ldtemplate instead. - */ - -/* emulate the original gld for the given - Copyright (C) 1991 Free Software Foundation, Inc. - Written by Steve Chamberlain steve@cygnus.com - -This file is part of GLD, the Gnu Linker. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - * $Id:# - */ - -#define TARGET_IS_ - - -#include "bfd.h" -#include "sysdep.h" -#include "ld.h" -#include "config.h" -#include "ldemul.h" -#include "ldfile.h" -#include "ldmisc.h" - -extern boolean lang_float_flag; - - -extern enum bfd_architecture ldfile_output_architecture; -extern unsigned long ldfile_output_machine; -extern char *ldfile_output_machine_name; - -extern bfd *output_bfd; - - - -static void gld_before_parse() -{ -#ifdef TARGET_IS_M88KBCS - extern char lprefix; - lprefix = '@'; -#else -#ifndef TARGET_ /* I.e., if not generic */ - ldfile_output_architecture = bfd_arch_; -#endif -#endif -} - - -static void -gld_after_parse() -{ - -} - -static void -gld_after_allocation() -{ - -} - -static void -gld_before_allocation() -{ - -} - - -static void -gld_set_output_arch() -{ - /* Set the output architecture and machine if possible */ - bfd_set_arch_mach(output_bfd, - ldfile_output_architecture, ldfile_output_machine); -} - -static char * -gld_choose_target() -{ - char *from_outside = getenv(TARGET_ENVIRON); - if (from_outside != (char *)NULL) - return from_outside; - return GLD_TARGET; -} - -static void -gld_syslib() -{ - info("%S SYSLIB ignored\n"); -} - -static void -gld_hll(ignore) -char *ignore; -{ - info("%S HLL ignored\n"); -} - -static char *gld_script = -#include ".x" -; -static char *gld_script_option_Ur = -#include ".xu" -; -static char *gld_script_option_r = -#include ".xr" -; -static char *gld_script_option_n = /* Used with -n flag. */ -#include ".xn" -; -static char *gld_script_option_N = /* Used with -N flag. */ -#include ".xN" -; - -static char *gld_get_script() -{ - extern ld_config_type config; - if (config.relocateable_output == true && - config.build_constructors == true) { - return gld_script_option_Ur; - } - if (config.relocateable_output == true) { - return gld_script_option_r; - } - if (!config.text_read_only) - return gld_script_option_N; - if (!config.magic_demand_paged) - return gld_script_option_n; - return gld_script; -} -struct ld_emulation_xfer_struct ld_gld_emulation = -{ - gld_before_parse, - gld_syslib, - gld_hll, - gld_after_parse, - gld_after_allocation, - gld_set_output_arch, - gld_choose_target, - gld_before_allocation, - gld_get_script, -}; diff --git a/ld/ldvanilla.c b/ld/ldvanilla.c deleted file mode 100755 index 3bd51e6d01e..00000000000 --- a/ld/ldvanilla.c +++ /dev/null @@ -1,118 +0,0 @@ -/* A vanilla emulation with no defaults - Copyright (C) 1991 Free Software Foundation, Inc. - Written by Steve Chamberlain steve@cygnus.com - -This file is part of GLD, the Gnu Linker. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - * $Id$ - */ - -#include "bfd.h" -#include "sysdep.h" - - -#include "ld.h" -#include "config.h" -#include "ldemul.h" -#include "ldfile.h" -#include "ldmisc.h" - -extern boolean lang_float_flag; - - -extern enum bfd_architecture ldfile_output_architecture; -extern unsigned long ldfile_output_machine; -extern char *ldfile_output_machine_name; - -extern bfd *output_bfd; - - - -static void vanilla_before_parse() -{ -} - - -static void -vanilla_after_parse() -{ - -} - -static void -vanilla_after_allocation() -{ - -} - -static void -vanilla_before_allocation() -{ - -} - - -static void -vanilla_set_output_arch() -{ - /* Set the output architecture and machine if possible */ - unsigned long machine = 0; - bfd_set_arch_mach(output_bfd, ldfile_output_architecture, machine); -} - -static char * -vanilla_choose_target() -{ - char *from_outside = getenv(TARGET_ENVIRON); - if (from_outside != (char *)NULL) - return from_outside; - return VANILLA_TARGET; -} - -static void -vanilla_syslib() -{ - info("%S SYSLIB ignored\n"); -} - -static void -vanilla_hll(ignore) -char *ignore; -{ - info("%S HLL ignored\n"); -} - - -static char *vanilla_get_script() -{ -return ""; -} - -struct ld_emulation_xfer_struct ld_vanilla_emulation = -{ - vanilla_before_parse, - vanilla_syslib, - vanilla_hll, - vanilla_after_parse, - vanilla_after_allocation, - vanilla_set_output_arch, - vanilla_choose_target, - vanilla_before_allocation, - vanilla_get_script, -}; - diff --git a/ld/ldver.c b/ld/ldver.c deleted file mode 100644 index b2df2772cc8..00000000000 --- a/ld/ldver.c +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. - -This file is part of GLD, the Gnu Linker. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - * $Id$ -*/ - - - -#include -#include "bfd.h" -#include "sysdep.h" - -#include "ldver.h" - -void -ldversion() -{ - fprintf(stdout,"gld version BFD 0.18\n"); -} diff --git a/ld/ldver.h b/ld/ldver.h deleted file mode 100644 index ba44029b5dc..00000000000 --- a/ld/ldver.h +++ /dev/null @@ -1,25 +0,0 @@ -/* ldversion.h - - - Copyright (C) 1991 Free Software Foundation, Inc. - - This file is part of GLD, the Gnu Linker. - - GLD 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 1, or (at your option) - any later version. - - GLD 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 GLD; see the file COPYING. If not, write to - the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - - - - -PROTO(void,ldversion,(void)); - diff --git a/ld/ldwarn.c b/ld/ldwarn.c deleted file mode 100644 index 8aa189f66f1..00000000000 --- a/ld/ldwarn.c +++ /dev/null @@ -1,93 +0,0 @@ -/* - Copyright (C) 1991 Free Software Foundation, Inc. - Written by Steve Chamberlain of Cygnus Support. - -This file is part of GLD, the GNU linker. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include "bfd.h" -#include "sysdep.h" -#include "ldsym.h" -#include "ldwarn.h" -#include "ldmisc.h" - -/* we keep all the warning symbols in a list, if we ever get a - warning, we'll search it the hard way. This won't be to bad since - warnings are infrequent, and never that many (true or false ?). - -*/ - -typedef struct warning_list_struct { - struct warning_list_struct *next; - asymbol *sym; -} warning_list_type; - - -static warning_list_type *warning_list; - - - -/* This is a warning symbol, add the error text to a list we keep, and mark - the symbol referenced as requiring a warning */ - - -void -DEFUN(add_warning,(sym), - asymbol *sym) -{ - CONST char *name = ((asymbol *)(sym->value))->name; - warning_list_type *new; - - ldsym_type *lookup = ldsym_get(name); - - lookup->flags |= SYM_WARNING; - - new = (warning_list_type *)ldmalloc(sizeof(warning_list_type)); - new->next = warning_list; - new->sym = sym; - warning_list = new; -} - -/* run through the list we kept, and find the warning associated with - this symbol */ -CONST char * -DEFUN(fetch_warning,(sym), -asymbol *sym) -{ - warning_list_type *ptr = warning_list; - while (ptr != (warning_list_type *)NULL) { - if (strcmp(((asymbol*)(ptr->sym->value))->name, sym->name) == 0) { - return ptr->sym->name; - } - ptr = ptr->next; - } - return "This is a warning without a message !"; -} - - -void -DEFUN(produce_warnings,(lgs,it), - ldsym_type *lgs AND - asymbol *it) -{ - asymbol **ptr; - ptr = lgs->srefs_chain; - while (ptr != (asymbol **)NULL) { - asymbol *ref = *ptr; - info("%B: %s\n", ref->the_bfd, fetch_warning(it)); - ptr = (asymbol **)(ref->udata); - } -} diff --git a/ld/ldwarn.h b/ld/ldwarn.h deleted file mode 100644 index 955ae9d948e..00000000000 --- a/ld/ldwarn.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - Copyright (C) 1991 Free Software Foundation, Inc. - Written by Steve Chamberlain of Cygnus Support. - -This file is part of GLD, the GNU linker. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - - -void EXFUN(add_warning,(asymbol *)); -CONST char * EXFUN(fetch_warning,(asymbol *)); -void EXFUN(produce_warnings,(ldsym_type *, asymbol *)); diff --git a/ld/ldwrite.c b/ld/ldwrite.c deleted file mode 100644 index 6e1603a2467..00000000000 --- a/ld/ldwrite.c +++ /dev/null @@ -1,408 +0,0 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. - -This file is part of GLD, the Gnu Linker. - -GLD 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 1, or (at your option) -any later version. - -GLD 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 GLD; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* - * $Id$ -*/ - -/* - This module writes out the final image by reading sections from the - input files, relocating them and writing them out - - There are two main paths through this module, one for normal - operation and one for partial linking. - - During normal operation, raw section data is read along with the - associated relocation information, the relocation info applied and - the section data written out on a section by section basis. - - When partially linking, all the relocation records are read to work - out how big the output relocation vector will be. Then raw data is - read, relocated and written section by section. - - Written by Steve Chamberlain steve@cygnus.com - -*/ - - -#include "sysdep.h" -#include "bfd.h" - -#include "ldlang.h" -#include "ld.h" -#include "ldwrite.h" -#include "ldmisc.h" -#include "ldsym.h" -#include "ldgram.tab.h" - - - -char *ldmalloc(); -/* Static vars for do_warnings and subroutines of it */ -int list_unresolved_refs; /* List unresolved refs */ -int list_warning_symbols; /* List warning syms */ -int list_multiple_defs; /* List multiple definitions */ -extern int errno; -extern char *sys_errlist[]; - -extern unsigned int undefined_global_sym_count; - -extern bfd *output_bfd; - -extern struct lang_output_section_statement_struct * create_object_symbols; - -extern char lprefix; - -#ifdef __STDC__ -void lang_for_each_statement(void (*func)()); -#else /* __STDC__ */ -void lang_for_each_statement(); -#endif /* __STDC__ */ - -extern size_t largest_section; -ld_config_type config; - -extern unsigned int global_symbol_count; - -boolean trace_files; - -static void perform_relocation(input_bfd, - input_section, - data, - symbols) -bfd *input_bfd; -asection *input_section; -PTR data; -asymbol **symbols; -{ - static asymbol *error_symbol = (asymbol *)NULL; - static unsigned int error_count = 0; -#define MAX_ERRORS_IN_A_ROW 5 - size_t reloc_size = get_reloc_upper_bound(input_bfd, input_section); - - arelent **reloc_vector = (arelent **)ldmalloc(reloc_size); - arelent **parent; - bfd *ob = output_bfd; - asection *os = input_section->output_section; - if (config.relocateable_output == false) ob = (bfd *)NULL; - - if (bfd_canonicalize_reloc(input_bfd, - input_section, - reloc_vector, - symbols) ) - { - for (parent = reloc_vector; *parent; parent++) - { - - bfd_reloc_status_enum_type r= - bfd_perform_relocation(input_bfd, - *parent, - data, - input_section, - ob); - - if (r == bfd_reloc_ok) { - if (ob != (bfd *)NULL) { - /* A parital link, so keep the relocs */ - os->orelocation[os->reloc_count] = *parent; - os->reloc_count++; - } - } - else - { - asymbol *s; - arelent *p = *parent; - - if (ob != (bfd *)NULL) { - /* A parital link, so keep the relocs */ - os->orelocation[os->reloc_count] = *parent; - os->reloc_count++; - } - - if (p->sym_ptr_ptr != (asymbol **)NULL) { - s = *(p->sym_ptr_ptr); - } - else { - s = (asymbol *)NULL; - } - switch (r) - { - case bfd_reloc_undefined: - /* We remember the symbol, and never print more than - a reasonable number of them in a row */ - if (s == error_symbol) { - error_count++; - } - else { - error_count = 0; - error_symbol = s; - } - if (error_count < MAX_ERRORS_IN_A_ROW) { - info("%C: undefined reference to `%T'\n", - input_bfd, - input_section, - symbols, - (*parent)->address, - s); - config.make_executable = false; - } - else if (error_count == MAX_ERRORS_IN_A_ROW) { - info("%C: more undefined references to `%T' follow\n", - input_bfd, - input_section, - symbols, - (*parent)->address, - s); - } - else { - /* Don't print any more */ - } - break; - case bfd_reloc_dangerous: - info("%B: relocation may be wrong `%T'\n", - input_bfd, - s); - break; - case bfd_reloc_outofrange: - info("%B:%s relocation address out of range %T (%V)\n", - input_bfd, - input_section->name, - s, - p->address); - break; - case bfd_reloc_overflow: - info("%B:%s relocation overflow in %T reloc type %d\n", - input_bfd, - input_section->name, - s, - p->howto->type); - break; - default: - info("%F%B: relocation error, symbol `%T'\n", - input_bfd, - s); - break; - } - } - } - } - free((char *)reloc_vector); -} - - - - - - -PTR data_area; - -static void -copy_and_relocate(statement) -lang_statement_union_type *statement; -{ - switch (statement->header.type) { - case lang_fill_statement_enum: - { -#if 0 - bfd_byte play_area[SHORT_SIZE]; - unsigned int i; - bfd_putshort(output_bfd, statement->fill_statement.fill, play_area); - /* Write out all entire shorts */ - for (i = 0; - i < statement->fill_statement.size - SHORT_SIZE + 1; - i+= SHORT_SIZE) - { - bfd_set_section_contents(output_bfd, - statement->fill_statement.output_section, - play_area, - statement->data_statement.output_offset +i, - SHORT_SIZE); - - } - - /* Now write any remaining byte */ - if (i < statement->fill_statement.size) - { - bfd_set_section_contents(output_bfd, - statement->fill_statement.output_section, - play_area, - statement->data_statement.output_offset +i, - 1); - - } -#endif - } - break; - case lang_data_statement_enum: - { - bfd_vma value = statement->data_statement.value; - bfd_byte play_area[LONG_SIZE]; - unsigned int size; - switch (statement->data_statement.type) { - case LONG: - bfd_putlong(output_bfd, value, play_area); - size = LONG_SIZE; - break; - case SHORT: - bfd_putshort(output_bfd, value, play_area); - size = SHORT_SIZE; - break; - case BYTE: - bfd_putchar(output_bfd, value, play_area); - size = BYTE_SIZE; - break; - } - - bfd_set_section_contents(output_bfd, - statement->data_statement.output_section, - play_area, - statement->data_statement.output_vma, - size); - - - - - } - break; - case lang_input_section_enum: - { - - asection *i = statement->input_section.section; - asection *output_section = i->output_section; - lang_input_statement_type *ifile = - statement->input_section.ifile; - if (ifile->just_syms_flag == false) { - bfd *inbfd = ifile->the_bfd; - - if (output_section->flags & SEC_LOAD && i->size != 0) - { - if(bfd_get_section_contents(inbfd, - i, - data_area, - 0L, - i->size) == false) - { - info("%F%B error reading section contents %E\n", - inbfd); - } - perform_relocation (inbfd, i, data_area, ifile->asymbols); - - - if(bfd_set_section_contents(output_bfd, - output_section, - data_area, - (file_ptr)i->output_offset, - i->size) == false) - { - info("%F%B error writing section contents of %E\n", - output_bfd); - } - - } - } - - } - break; - - default: - /* All the other ones fall through */ - ; - - } -} - -void -write_norel() -{ - /* Output the text and data segments, relocating as we go. */ - lang_for_each_statement(copy_and_relocate); -} - - -static void read_relocs(abfd, section, symbols) -bfd *abfd; -asection *section; -asymbol **symbols; -{ - /* Work out the output section ascociated with this input section */ - asection *output_section = section->output_section; - - size_t reloc_size = get_reloc_upper_bound(abfd, section); - arelent **reloc_vector = (arelent **)ldmalloc(reloc_size); - - if (bfd_canonicalize_reloc(abfd, - section, - reloc_vector, - symbols)) { - output_section->reloc_count += section->reloc_count; - } -} - - -static void -write_rel() -{ - /* - Run through each section of each file and work work out the total - number of relocation records which will finally be in each output - section - */ - - LANG_FOR_EACH_INPUT_SECTION - (statement, abfd, section, - (read_relocs(abfd, section, statement->asymbols))); - - - - /* - Now run though all the output sections and allocate the space for - all the relocations - */ - LANG_FOR_EACH_OUTPUT_SECTION - (section, - (section->orelocation = - (arelent **)ldmalloc((size_t)(sizeof(arelent **)* - section->reloc_count)), - section->reloc_count = 0, - section->flags |= SEC_HAS_CONTENTS)); - - - /* - Copy the data, relocating as we go - */ - lang_for_each_statement(copy_and_relocate); -} - -void -ldwrite () -{ - data_area = (PTR) ldmalloc(largest_section); - if (config.relocateable_output == true) - { - write_rel(); - } - else - { - write_norel(); - } - free(data_area); - /* Output the symbol table (both globals and locals). */ - ldsym_write (); - -} - diff --git a/ld/ldwrite.h b/ld/ldwrite.h deleted file mode 100644 index 2658801887c..00000000000 --- a/ld/ldwrite.h +++ /dev/null @@ -1,24 +0,0 @@ -/* ldwrite.h - - - Copyright (C) 1991 Free Software Foundation, Inc. - - This file is part of GLD, the Gnu Linker. - - GLD 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 1, or (at your option) - any later version. - - GLD 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 GLD; see the file COPYING. If not, write to - the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - - - - -PROTO(void, ldwrite, (void)); diff --git a/ld/mkscript.c b/ld/mkscript.c deleted file mode 100644 index e0f66ee05a0..00000000000 --- a/ld/mkscript.c +++ /dev/null @@ -1,42 +0,0 @@ -/* Filter stdin to a suitable C string literal. - Copyright (C) 1991 Free Software Foundation, Inc. - -This file is part of GLD, the Gnu Linker. - -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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include - -int -main() -{ - int ch; - ch = getchar(); - printf("/* Generated through mkscript */\n"); - printf("\"{ \\\n"); - while (ch != EOF) { - if (ch == '\"' || ch == '\\' || ch == '\'') { - putchar('\\'); - putchar(ch); - } - else { if (ch == '\n') - fputs("\\n\\", stdout); - putchar(ch); - } - ch = getchar(); - } - printf("}\"\n"); - return 0; -} diff --git a/ld/news.sc b/ld/news.sc deleted file mode 100755 index ed57fedd4cf..00000000000 --- a/ld/news.sc +++ /dev/null @@ -1,29 +0,0 @@ -OUTPUT_FORMAT("a.out-newsos3") -OUTPUT_ARCH(m68k) - -SEARCH_DIR(/lib) -SEARCH_DIR(/usr/lib) -SEARCH_DIR(/usr/local/lib) -__DYNAMIC = 0; -SECTIONS -{ - .text 0: - { - CREATE_OBJECT_SYMBOLS - *(.text) - _etext = ALIGN(0x1000); - } - .data ALIGN(0x1000) : - { - *(.data) - CONSTRUCTORS; - _edata = .; - } - .bss SIZEOF(.data) + ADDR(.data) : - { - *(.bss) - [COMMON] - _end = .; - } -} - diff --git a/readline/.Sanitize b/readline/.Sanitize deleted file mode 100644 index 50625e1eb63..00000000000 --- a/readline/.Sanitize +++ /dev/null @@ -1,53 +0,0 @@ -# Sanitize.in for devo. -# $Id$ -# - -# Each directory to survive it's way into a release will need a file -# like this one called "./.Sanitize". All keyword lines must exist, -# and must exist in the order specified by this file. Each directory -# in the tree will be processed, top down, in the following order. - -# Hash started lines like this one are comments and will be deleted -# before anything else is done. Blank lines will also be squashed -# out. - -# The lines between the "Do-first:" line and the "Things-to-keep:" -# line are executed as a /bin/sh shell script before anything else is -# done in this - -Do-first: - -# All files listed between the "Things-to-keep:" line and the -# "Files-to-sed:" line will be kept. All other files will be removed. -# Directories listed in this section will have their own Sanitize -# called. Directories not listed will be removed in their entirety -# with rm -rf. - -Things-to-keep: - -COPYING -ChangeLog -Makefile.in -chardefs.h -config -configure.in -emacs_keymap.c -funmap.c -history.c -history.h -history.texi -inc-history.texi -inc-readline.texi -keymaps.c -keymaps.h -readline.c -readline.h -readline.texi -sysdep-norm.h -sysdep-aix.h -vi_keymap.c -vi_mode.c - -Do-last: - -# End of file. diff --git a/readline/ChangeLog b/readline/ChangeLog deleted file mode 100644 index 75963072e63..00000000000 --- a/readline/ChangeLog +++ /dev/null @@ -1,120 +0,0 @@ -Mon Nov 11 20:50:29 1991 Steve Chamberlain (sac at cygnus.com) - - * Makefile.in: Use the MINUS_G no-debug convention - * readline.c: (many_places) move all the declarations of rindex to - only one place, to reduce the number of warnings it makes. - -Sat Nov 9 03:19:40 1991 John Gilmore (gnu at cygnus.com) - - * configure.in: Make a link for sysdep.h. Specify commontargets. - * sysdep-norm.h: The usual alloca declarations. - * sysdep-aix.h: What AIX 3.1 on RS/6000 needs for alloca. - * history.c, readline.c: Use sysdep.h. - -Thu Oct 24 21:58:46 1991 John Gilmore (gnu at cygnus.com) - - * configure.in: aix is a Sys V as far as we're concerned. - Switch to new config/hm-* scheme. - -Thu Oct 24 02:08:50 1991 Fred Fish (fnf at cygnus.com) - - * config/hmake-sysv: Send RANLIB (echo) output to /dev/null. - -Tue Sep 17 17:44:22 1991 Stu Grossman (grossman at cygnus.com) - - * config/hmake-sysv: sgi/irix support. - -Sun May 19 07:49:34 1991 John Gilmore and Rich Pixley (at cygnus.com) - - Make readline independent of the applications that use it. - - * readline.h, keymaps.h: include other include files with "foo.h" - rather than . This works here, and works when - included from other applications. - - * Makefile.in: Create template for configurable Makefile. - This version is not ready for prime time, so we have left - Makefile itself (the original version) too. - -Sun Mar 11 04:32:03 1990 Brian Fox (bfox at gnuwest.fsf.org) - - * Signals are now supposedly handled inside of SYSV compilation. - -Wed Jan 17 19:24:09 1990 Brian Fox (bfox at sbphy.ucsb.edu) - - * history.c: history_expand (); fixed overwriting memory error, - added needed argument to call to get_history_event (). - -Thu Jan 11 10:54:04 1990 Brian Fox (bfox at sbphy.ucsb.edu) - - * readline.c, readline.h: added rl_show_star to control the - display of an asterisk on modified history lines. - -Thu Jan 4 10:38:05 1990 Brian Fox (bfox at sbphy.ucsb.edu) - - * readline.c: start_insert (). Only use IC if we don't have an im - capability. - -Fri Sep 8 09:00:45 1989 Brian Fox (bfox at aurel) - - * readline.c: rl_prep_terminal (). Only turn on 8th bit - as meta-bit iff the terminal is not using parity. - -Sun Sep 3 08:57:40 1989 Brian Fox (bfox at aurel) - - * readline.c: start_insert (). Uses multiple - insertion call in cases where that makes sense. - - rl_insert (). Read type-ahead buffer for additional - keys that are bound to rl_insert, and insert them - all at once. Make insertion of single keys given - with an argument much more efficient. - -Tue Aug 8 18:13:57 1989 Brian Fox (bfox at aurel) - - * readline.c: Changed handling of EOF. readline () returns - (char *)EOF or consed string. The EOF character is read from the - tty, or if the tty doesn't have one, defaults to C-d. - - * readline.c: Added support for event driven programs. - rl_event_hook is the address of a function you want called - while Readline is waiting for input. - - * readline.c: Cleanup time. Functions without type declarations - do not use return with a value. - - * history.c: history_expand () has new variable which is the - characters to ignore immediately following history_expansion_char. - -Sun Jul 16 08:14:00 1989 Brian Fox (bfox at aurel) - - * rl_prep_terminal () - BSD version turns off C-s, C-q, C-y, C-v. - - * readline.c -- rl_prep_terminal () - SYSV version hacks readline_echoing_p. - BSD version turns on passing of the 8th bit for the duration - of reading the line. - -Tue Jul 11 06:25:01 1989 Brian Fox (bfox at aurel) - - * readline.c: new variable rl_tilde_expander. - If non-null, this contains the address of a function to call if - the standard meaning for expanding a tilde fails. The function is - called with the text sans tilde (as in "foo"), and returns a - malloc()'ed string which is the expansion, or a NULL pointer if - there is no expansion. - - * readline.h - new file chardefs.h - Separates things that only readline.c needs from the standard - header file publishing interesting things about readline. - - * readline.c: - readline_default_bindings () now looks at terminal chararacters - and binds those as well. - -Wed Jun 28 20:20:51 1989 Brian Fox (bfox at aurel) - - * Made readline and history into independent libraries. - - diff --git a/readline/INSTALL b/readline/INSTALL new file mode 100644 index 00000000000..95d84c820fb --- /dev/null +++ b/readline/INSTALL @@ -0,0 +1,176 @@ +Basic Installation +================== + + These are generic installation instructions. + + The `configure' shell script attempts to guess correct values for +various system-dependent variables used during compilation. It uses +those values to create a `Makefile' in each directory of the package. +It may also create one or more `.h' files containing system-dependent +definitions. Finally, it creates a shell script `config.status' that +you can run in the future to recreate the current configuration, a file +`config.cache' that saves the results of its tests to speed up +reconfiguring, and a file `config.log' containing compiler output +(useful mainly for debugging `configure'). + + If you need to do unusual things to compile the package, please try +to figure out how `configure' could check whether to do them, and mail +diffs or instructions to the address given in the `README' so they can +be considered for the next release. If at some point `config.cache' +contains results you don't want to keep, you may remove or edit it. + + The file `configure.in' is used to create `configure' by a program +called `autoconf'. You only need `configure.in' if you want to change +it or regenerate `configure' using a newer version of `autoconf'. + +The simplest way to compile this package is: + + 1. `cd' to the directory containing the package's source code and type + `./configure' to configure the package for your system. If you're + using `csh' on an old version of System V, you might need to type + `sh ./configure' instead to prevent `csh' from trying to execute + `configure' itself. + + Running `configure' takes awhile. While running, it prints some + messages telling which features it is checking for. + + 2. Type `make' to compile the package. + + 3. Optionally, type `make check' to run any self-tests that come with + the package. + + 4. Type `make install' to install the programs and any data files and + documentation. + + 5. You can remove the program binaries and object files from the + source code directory by typing `make clean'. To also remove the + files that `configure' created (so you can compile the package for + a different kind of computer), type `make distclean'. There is + also a `make maintainer-clean' target, but that is intended mainly + for the package's developers. If you use it, you may have to get + all sorts of other programs in order to regenerate files that came + with the distribution. + +Compilers and Options +===================== + + Some systems require unusual options for compilation or linking that +the `configure' script does not know about. You can give `configure' +initial values for variables by setting them in the environment. Using +a Bourne-compatible shell, you can do that on the command line like +this: + CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure + +Or on systems that have the `env' program, you can do it like this: + env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure + +Compiling For Multiple Architectures +==================================== + + You can compile the package for more than one kind of computer at the +same time, by placing the object files for each architecture in their +own directory. To do this, you must use a version of `make' that +supports the `VPATH' variable, such as GNU `make'. `cd' to the +directory where you want the object files and executables to go and run +the `configure' script. `configure' automatically checks for the +source code in the directory that `configure' is in and in `..'. + + If you have to use a `make' that does not supports the `VPATH' +variable, you have to compile the package for one architecture at a time +in the source code directory. After you have installed the package for +one architecture, use `make distclean' before reconfiguring for another +architecture. + +Installation Names +================== + + By default, `make install' will install the package's files in +`/usr/local/bin', `/usr/local/man', etc. You can specify an +installation prefix other than `/usr/local' by giving `configure' the +option `--prefix=PATH'. + + You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If you +give `configure' the option `--exec-prefix=PATH', the package will use +PATH as the prefix for installing programs and libraries. +Documentation and other data files will still use the regular prefix. + + If the package supports it, you can cause programs to be installed +with an extra prefix or suffix on their names by giving `configure' the +option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. + +Optional Features +================= + + Some packages pay attention to `--enable-FEATURE' options to +`configure', where FEATURE indicates an optional part of the package. +They may also pay attention to `--with-PACKAGE' options, where PACKAGE +is something like `gnu-as' or `x' (for the X Window System). The +`README' should mention any `--enable-' and `--with-' options that the +package recognizes. + + For packages that use the X Window System, `configure' can usually +find the X include and library files automatically, but if it doesn't, +you can use the `configure' options `--x-includes=DIR' and +`--x-libraries=DIR' to specify their locations. + +Specifying the System Type +========================== + + There may be some features `configure' can not figure out +automatically, but needs to determine by the type of host the package +will run on. Usually `configure' can figure that out, but if it prints +a message saying it can not guess the host type, give it the +`--host=TYPE' option. TYPE can either be a short name for the system +type, such as `sun4', or a canonical name with three fields: + CPU-COMPANY-SYSTEM + +See the file `config.sub' for the possible values of each field. If +`config.sub' isn't included in this package, then this package doesn't +need to know the host type. + + If you are building compiler tools for cross-compiling, you can also +use the `--target=TYPE' option to select the type of system they will +produce code for and the `--build=TYPE' option to select the type of +system on which you are compiling the package. + +Sharing Defaults +================ + + If you want to set default values for `configure' scripts to share, +you can create a site shell script called `config.site' that gives +default values for variables like `CC', `cache_file', and `prefix'. +`configure' looks for `PREFIX/share/config.site' if it exists, then +`PREFIX/etc/config.site' if it exists. Or, you can set the +`CONFIG_SITE' environment variable to the location of the site script. +A warning: not all `configure' scripts look for a site script. + +Operation Controls +================== + + `configure' recognizes the following options to control how it +operates. + +`--cache-file=FILE' + Use and save the results of the tests in FILE instead of + `./config.cache'. Set FILE to `/dev/null' to disable caching, for + debugging `configure'. + +`--help' + Print a summary of the options to `configure', and exit. + +`--quiet' +`--silent' +`-q' + Do not print messages saying which checks are being made. + +`--srcdir=DIR' + Look for the package's source code in directory DIR. Usually + `configure' can determine that directory automatically. + +`--version' + Print the version of Autoconf used to generate the `configure' + script, and exit. + +`configure' also accepts some other, not widely useful, options. + diff --git a/readline/Makefile.in b/readline/Makefile.in index 4cf743315c8..4fb6ceb1fbf 100644 --- a/readline/Makefile.in +++ b/readline/Makefile.in @@ -1,16 +1,8 @@ +## -*- text -*- #################################################### # # # Makefile for readline and history libraries. # # # - - -srcdir = . -ddestdir = /usr/local -idestdir = /usr/local -INSTALL_PROG = install -c -INSTALL_FILE = $(INSTALL_PROG) - -#### host and target dependent Makefile fragments come in here. -## +#################################################################### # Here is a rule for making .o files from .c files that doesn't force # the type of the machine (like -sun3) into the flags. @@ -19,13 +11,16 @@ INSTALL_FILE = $(INSTALL_PROG) # Destination installation directory. The libraries are copied to DESTDIR # when you do a `make install', and the header files to INCDIR/readline/*.h. -DESTDIR = $(ddestdir)/lib -INCDIR = $(ddestdir)/include +DESTDIR = /usr/local/lib +INCDIR = /usr/local/include # Define TYPES as -DVOID_SIGHANDLER if your operating system uses # a return type of "void" for signal handlers. TYPES = -DVOID_SIGHANDLER +# Define SYSV as -DSYSV if you are using a System V operating system. +#SYSV = -DSYSV + # HP-UX compilation requires the BSD library. #LOCAL_LIBS = -lBSD @@ -36,21 +31,19 @@ TYPES = -DVOID_SIGHANDLER # the vi line editing mode and features. READLINE_DEFINES = $(TYPES) -DVI_MODE -MINUS_G=-g -DEBUG_FLAGS = $(MINUS_G) +DEBUG_FLAGS = -g LDFLAGS = $(DEBUG_FLAGS) CFLAGS = $(DEBUG_FLAGS) $(SYSV) -I. # A good alternative is gcc -traditional. #CC = gcc -traditional CC = cc -RANLIB = /bin/ranlib +RANLIB = /usr/bin/ranlib AR = ar -AR_FLAGS = clq RM = rm CP = cp -LOCAL_INCLUDES = -I$(srcdir)/../ +LOCAL_INCLUDES = -I../ CSOURCES = readline.c history.c funmap.c keymaps.c vi_mode.c \ emacs_keymap.c vi_keymap.c @@ -58,8 +51,8 @@ CSOURCES = readline.c history.c funmap.c keymaps.c vi_mode.c \ HSOURCES = readline.h chardefs.h history.h keymaps.h SOURCES = $(CSOURCES) $(HSOURCES) -DOCUMENTATION = readline.texi inc-read.texi \ - history.texi inc-hist.texi +DOCUMENTATION = readline.texinfo inc-readline.texinfo \ + history.texinfo inc-history.texinfo SUPPORT = COPYING Makefile $(DOCUMENTATION) ChangeLog @@ -67,22 +60,12 @@ THINGS_TO_TAR = $(SOURCES) $(SUPPORT) ########################################################################## -STAGESTUFF = *.o - all: libreadline.a -all-info: history.info readline.info - -history.info: history.texi - - $(MAKEINFO) -o history.info $(srcdir)/history.texi - -readline.info: readline.texi - - $(MAKEINFO) -o readline.info $(srcdir)/readline.texi - libreadline.a: readline.o history.o funmap.o keymaps.o $(RM) -f libreadline.a - $(AR) $(AR_FLAGS) libreadline.a readline.o history.o funmap.o keymaps.o - $(RANLIB) libreadline.a + $(AR) clq libreadline.a readline.o history.o funmap.o keymaps.o + -if [ -f $(RANLIB) ]; then $(RANLIB) libreadline.a; fi readline.o: readline.h chardefs.h keymaps.h history.h readline.c vi_mode.c history.o: history.c history.h @@ -103,64 +86,18 @@ readline.tar: $(THINGS_TO_TAR) readline.tar.Z: readline.tar compress -f readline.tar -install: includes - $(INSTALL_PROG) libreadline.a $(DESTDIR)/libreadline.an - -mv $(DESTDIR)/libreadline.an $(DESTDIR)/libreadline.a - $(RANLIB) $(DESTDIR)/libreadline.a - -install-info: all-info - for i in *.info* ; do \ - echo Installing $$i... ; \ - cp $$i $(idestdir)/info/$$i ; \ - done +install: $(DESTDIR)/libreadline.a includes includes: if [ ! -r $(INCDIR)/readline ]; then\ mkdir $(INCDIR)/readline;\ chmod a+r $(INCDIR)/readline;\ fi - $(INSTALL_FILE) $(srcdir)/readline.h $(INCDIR)/readline/ - $(INSTALL_FILE) $(srcdir)/keymaps.h $(INCDIR)/readline/ - $(INSTALL_FILE) $(srcdir)/chardefs.h $(INCDIR)/readline/ + $(CP) readline.h keymaps.h chardefs.h $(INCDIR)/readline/ clean: - rm -f $(STAGESTUFF) *.a *.log *.cp *.tp *.vr *.fn - rm -f *.aux *.pg *.toc *.info* + rm -f *.o *.a *.log *.cp *.tp *.vr *.fn *.aux *.pg *.toc $(DESTDIR)/libreadline.a: libreadline.a - -# Copy the object files from a particular stage into a subdirectory. -stage1: force - -mkdir stage1 - -mv $(STAGESTUFF) stage1 - -stage2: force - -mkdir stage2 - -mv $(STAGESTUFF) stage2 - -stage3: force - -mkdir stage3 - -mv $(STAGESTUFF) stage3 - -against=stage2 - -comparison: force - for i in $(STAGESTUFF) ; do cmp $$i $(against)/$$i ; done - -de-stage1: force - - (cd stage1 ; mv -f * ..) - - rmdir stage1 - -de-stage2: force - - (cd stage2 ; mv -f * ..) - - rmdir stage2 - -de-stage3: force - - (cd stage3 ; mv -f * ..) - - rmdir stage3 - -force: - -# with the gnu make, this is done automatically. - -Makefile: $(srcdir)/Makefile.in $(host_makefile_frag) $(target_makefile_frag) - $(SHELL) ./config.status + -mv $(DESTDIR)/libreadline.a $(DESTDIR)/libreadline.old + cp libreadline.a $(DESTDIR)/libreadline.a + $(RANLIB) -t $(DESTDIR)/libreadline.a diff --git a/readline/bind.c b/readline/bind.c new file mode 100644 index 00000000000..a7ffe25dfa6 --- /dev/null +++ b/readline/bind.c @@ -0,0 +1,1396 @@ +/* bind.c -- key binding and startup file support for the readline library. */ + +/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc. + + This file is part of the GNU Readline Library, a library for + reading lines of text with interactive input and history editing. + + The GNU Readline Library 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 1, or + (at your option) any later version. + + The GNU Readline Library 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. + + The GNU General Public License is often shipped with GNU software, and + is generally kept in a file called COPYING or LICENSE. If you do not + have a copy of the license, write to the Free Software Foundation, + 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#include "sysdep.h" +#include +#include +#include +#ifndef NO_SYS_FILE +#include +#endif + +#include +/* Not all systems declare ERRNO in errno.h... and some systems #define it! */ +#if !defined (errno) +extern int errno; +#endif /* !errno */ + +/* System-specific feature definitions and include files. */ +#include "rldefs.h" + +/* Some standard library routines. */ +#include "readline.h" +#include "history.h" + +#if !defined (strchr) && !defined (__STDC__) +extern char *strchr (), *strrchr (); +#endif /* !strchr && !__STDC__ */ + +extern char *tilde_expand (); + +extern int _rl_horizontal_scroll_mode; +extern int _rl_mark_modified_lines; +extern int _rl_prefer_visible_bell; +extern int _rl_meta_flag; +extern int rl_blink_matching_paren; +extern int _rl_convert_meta_chars_to_ascii; +#if defined (VISIBLE_STATS) +extern int rl_visible_stats; +#endif /* VISIBLE_STATS */ +extern int rl_complete_with_tilde_expansion; +extern int rl_completion_query_items; + +extern int rl_explicit_arg; +extern int rl_editing_mode; +extern unsigned short _rl_parsing_conditionalized_out; +extern Keymap _rl_keymap; + +extern char *possible_control_prefixes[], *possible_meta_prefixes[]; + +extern char **rl_funmap_names (); + +static void rl_generic_bind (); +static int glean_key_from_name (); +static int stricmp (), strnicmp (); + +#if defined (STATIC_MALLOC) +static char *xmalloc (), *xrealloc (); +#else +extern char *xmalloc (), *xrealloc (); +#endif /* STATIC_MALLOC */ + +/* **************************************************************** */ +/* */ +/* Binding keys */ +/* */ +/* **************************************************************** */ + +/* rl_add_defun (char *name, Function *function, int key) + Add NAME to the list of named functions. Make FUNCTION be the function + that gets called. If KEY is not -1, then bind it. */ +rl_add_defun (name, function, key) + char *name; + Function *function; + int key; +{ + if (key != -1) + rl_bind_key (key, function); + rl_add_funmap_entry (name, function); +} + +/* Bind KEY to FUNCTION. Returns non-zero if KEY is out of range. */ +int +rl_bind_key (key, function) + int key; + Function *function; +{ + if (key < 0) + return (key); + + if (META_CHAR (key) && _rl_convert_meta_chars_to_ascii) + { + if (_rl_keymap[ESC].type == ISKMAP) + { + Keymap escmap = (Keymap)_rl_keymap[ESC].function; + + key = UNMETA (key); + escmap[key].type = ISFUNC; + escmap[key].function = function; + return (0); + } + return (key); + } + + _rl_keymap[key].type = ISFUNC; + _rl_keymap[key].function = function; + return (0); +} + +/* Bind KEY to FUNCTION in MAP. Returns non-zero in case of invalid + KEY. */ +int +rl_bind_key_in_map (key, function, map) + int key; + Function *function; + Keymap map; +{ + int result; + Keymap oldmap = _rl_keymap; + + _rl_keymap = map; + result = rl_bind_key (key, function); + _rl_keymap = oldmap; + return (result); +} + +/* Make KEY do nothing in the currently selected keymap. + Returns non-zero in case of error. */ +int +rl_unbind_key (key) + int key; +{ + return (rl_bind_key (key, (Function *)NULL)); +} + +/* Make KEY do nothing in MAP. + Returns non-zero in case of error. */ +int +rl_unbind_key_in_map (key, map) + int key; + Keymap map; +{ + return (rl_bind_key_in_map (key, (Function *)NULL, map)); +} + +/* Bind the key sequence represented by the string KEYSEQ to + FUNCTION. This makes new keymaps as necessary. The initial + place to do bindings is in MAP. */ +rl_set_key (keyseq, function, map) + char *keyseq; + Function *function; + Keymap map; +{ + rl_generic_bind (ISFUNC, keyseq, function, map); +} + +/* Bind the key sequence represented by the string KEYSEQ to + the string of characters MACRO. This makes new keymaps as + necessary. The initial place to do bindings is in MAP. */ +rl_macro_bind (keyseq, macro, map) + char *keyseq, *macro; + Keymap map; +{ + char *macro_keys; + int macro_keys_len; + + macro_keys = (char *)xmalloc ((2 * strlen (macro)) + 1); + + if (rl_translate_keyseq (macro, macro_keys, ¯o_keys_len)) + { + free (macro_keys); + return; + } + rl_generic_bind (ISMACR, keyseq, macro_keys, map); +} + +/* Bind the key sequence represented by the string KEYSEQ to + the arbitrary pointer DATA. TYPE says what kind of data is + pointed to by DATA, right now this can be a function (ISFUNC), + a macro (ISMACR), or a keymap (ISKMAP). This makes new keymaps + as necessary. The initial place to do bindings is in MAP. */ + +static void +rl_generic_bind (type, keyseq, data, map) + int type; + char *keyseq, *data; + Keymap map; +{ + char *keys; + int keys_len; + register int i; + + /* If no keys to bind to, exit right away. */ + if (!keyseq || !*keyseq) + { + if (type == ISMACR) + free (data); + return; + } + + keys = (char *)alloca (1 + (2 * strlen (keyseq))); + + /* Translate the ASCII representation of KEYSEQ into an array of + characters. Stuff the characters into KEYS, and the length of + KEYS into KEYS_LEN. */ + if (rl_translate_keyseq (keyseq, keys, &keys_len)) + return; + + /* Bind keys, making new keymaps as necessary. */ + for (i = 0; i < keys_len; i++) + { + int ic = (int) ((unsigned char)keys[i]); + + if (_rl_convert_meta_chars_to_ascii && META_CHAR (ic)) + { + ic = UNMETA (ic); + if (map[ESC].type == ISKMAP) + map = (Keymap) map[ESC].function; + } + + if ((i + 1) < keys_len) + { + if (map[ic].type != ISKMAP) + { + if (map[ic].type == ISMACR) + free ((char *)map[ic].function); + + map[ic].type = ISKMAP; + map[ic].function = (Function *)rl_make_bare_keymap (); + } + map = (Keymap)map[ic].function; + } + else + { + if (map[ic].type == ISMACR) + free ((char *)map[ic].function); + + map[ic].function = (Function *)data; + map[ic].type = type; + } + } +} + +/* Translate the ASCII representation of SEQ, stuffing the values into ARRAY, + an array of characters. LEN gets the final length of ARRAY. Return + non-zero if there was an error parsing SEQ. */ +rl_translate_keyseq (seq, array, len) + char *seq, *array; + int *len; +{ + register int i, c, l = 0; + + for (i = 0; c = seq[i]; i++) + { + if (c == '\\') + { + c = seq[++i]; + + if (!c) + break; + + if (((c == 'C' || c == 'M') && seq[i + 1] == '-') || + (c == 'e')) + { + /* Handle special case of backwards define. */ + if (strncmp (&seq[i], "C-\\M-", 5) == 0) + { + array[l++] = ESC; + i += 5; + array[l++] = CTRL (to_upper (seq[i])); + if (!seq[i]) + i--; + continue; + } + + switch (c) + { + case 'M': + i++; + array[l++] = ESC; + break; + + case 'C': + i += 2; + /* Special hack for C-?... */ + if (seq[i] == '?') + array[l++] = RUBOUT; + else + array[l++] = CTRL (to_upper (seq[i])); + break; + + case 'e': + array[l++] = ESC; + } + + continue; + } + } + array[l++] = c; + } + + *len = l; + array[l] = '\0'; + return (0); +} + +/* Return a pointer to the function that STRING represents. + If STRING doesn't have a matching function, then a NULL pointer + is returned. */ +Function * +rl_named_function (string) + char *string; +{ + register int i; + + rl_initialize_funmap (); + + for (i = 0; funmap[i]; i++) + if (stricmp (funmap[i]->name, string) == 0) + return (funmap[i]->function); + return ((Function *)NULL); +} + +/* Return the function (or macro) definition which would be invoked via + KEYSEQ if executed in MAP. If MAP is NULL, then the current keymap is + used. TYPE, if non-NULL, is a pointer to an int which will receive the + type of the object pointed to. One of ISFUNC (function), ISKMAP (keymap), + or ISMACR (macro). */ +Function * +rl_function_of_keyseq (keyseq, map, type) + char *keyseq; + Keymap map; + int *type; +{ + register int i; + + if (!map) + map = _rl_keymap; + + for (i = 0; keyseq && keyseq[i]; i++) + { + int ic = keyseq[i]; + + if (META_CHAR (ic) && _rl_convert_meta_chars_to_ascii) + { + if (map[ESC].type != ISKMAP) + { + if (type) + *type = map[ESC].type; + + return (map[ESC].function); + } + else + { + map = (Keymap)map[ESC].function; + ic = UNMETA (ic); + } + } + + if (map[ic].type == ISKMAP) + { + /* If this is the last key in the key sequence, return the + map. */ + if (!keyseq[i + 1]) + { + if (type) + *type = ISKMAP; + + return (map[ic].function); + } + else + map = (Keymap)map[ic].function; + } + else + { + if (type) + *type = map[ic].type; + + return (map[ic].function); + } + } +} + +/* The last key bindings file read. */ +static char *last_readline_init_file = (char *)NULL; + +/* Re-read the current keybindings file. */ +rl_re_read_init_file (count, ignore) + int count, ignore; +{ + rl_read_init_file ((char *)NULL); +} + +/* The final, last-ditch effort file name for an init file. */ +#ifdef __MSDOS__ +/* Don't know what to do, but this is a guess */ +#define DEFAULT_INPUTRC "/INPUTRC"; +#else +#define DEFAULT_INPUTRC "~/.inputrc" +#endif + +/* Do key bindings from a file. If FILENAME is NULL it defaults + to `~/.inputrc'. If the file existed and could be opened and + read, 0 is returned, otherwise errno is returned. */ +int +rl_read_init_file (filename) + char *filename; +{ + register int i; + char *buffer, *openname, *line, *end; + struct stat finfo; + int file; + + /* Default the filename. */ + if (!filename) + { + if (last_readline_init_file) + filename = last_readline_init_file; + else + filename = DEFAULT_INPUTRC; + } + + openname = tilde_expand (filename); + + if (!openname || *openname == '\000') + return ENOENT; + + if ((stat (openname, &finfo) < 0) || + (file = open (openname, O_RDONLY, 0666)) < 0) + { + free (openname); + return (errno); + } + else + free (openname); + + if (last_readline_init_file) + free (last_readline_init_file); + + last_readline_init_file = savestring (filename); + + /* Read the file into BUFFER. */ + buffer = (char *)xmalloc ((int)finfo.st_size + 1); + i = read (file, buffer, finfo.st_size); + close (file); + + if (i != finfo.st_size) + return (errno); + + /* Loop over the lines in the file. Lines that start with `#' are + comments; all other lines are commands for readline initialization. */ + line = buffer; + end = buffer + finfo.st_size; + while (line < end) + { + /* Find the end of this line. */ + for (i = 0; line + i != end && line[i] != '\n'; i++); + + /* Mark end of line. */ + line[i] = '\0'; + + /* If the line is not a comment, then parse it. */ + if (*line && *line != '#') + rl_parse_and_bind (line); + + /* Move to the next line. */ + line += i + 1; + } + free (buffer); + return (0); +} + +/* **************************************************************** */ +/* */ +/* Parser Directives */ +/* */ +/* **************************************************************** */ + +/* Conditionals. */ + +/* Calling programs set this to have their argv[0]. */ +char *rl_readline_name = "other"; + +/* Stack of previous values of parsing_conditionalized_out. */ +static unsigned char *if_stack = (unsigned char *)NULL; +static int if_stack_depth = 0; +static int if_stack_size = 0; + +/* Push _rl_parsing_conditionalized_out, and set parser state based + on ARGS. */ +static int +parser_if (args) + char *args; +{ + register int i; + + /* Push parser state. */ + if (if_stack_depth + 1 >= if_stack_size) + { + if (!if_stack) + if_stack = (unsigned char *)xmalloc (if_stack_size = 20); + else + if_stack = (unsigned char *)xrealloc (if_stack, if_stack_size += 20); + } + if_stack[if_stack_depth++] = _rl_parsing_conditionalized_out; + + /* If parsing is turned off, then nothing can turn it back on except + for finding the matching endif. In that case, return right now. */ + if (_rl_parsing_conditionalized_out) + return 0; + + /* Isolate first argument. */ + for (i = 0; args[i] && !whitespace (args[i]); i++); + + if (args[i]) + args[i++] = '\0'; + + /* Handle "if term=foo" and "if mode=emacs" constructs. If this + isn't term=foo, or mode=emacs, then check to see if the first + word in ARGS is the same as the value stored in rl_readline_name. */ + if (rl_terminal_name && strnicmp (args, "term=", 5) == 0) + { + char *tem, *tname; + + /* Terminals like "aaa-60" are equivalent to "aaa". */ + tname = savestring (rl_terminal_name); + tem = (char*) strrchr (tname, '-'); + if (tem) + *tem = '\0'; + + /* Test the `long' and `short' forms of the terminal name so that + if someone has a `sun-cmd' and does not want to have bindings + that will be executed if the terminal is a `sun', they can put + `$if term=sun-cmd' into their .inputrc. */ + if ((stricmp (args + 5, tname) == 0) || + (stricmp (args + 5, rl_terminal_name) == 0)) + _rl_parsing_conditionalized_out = 0; + else + _rl_parsing_conditionalized_out = 1; + + free (tname); + } +#if defined (VI_MODE) + else if (strnicmp (args, "mode=", 5) == 0) + { + int mode; + + if (stricmp (args + 5, "emacs") == 0) + mode = emacs_mode; + else if (stricmp (args + 5, "vi") == 0) + mode = vi_mode; + else + mode = no_mode; + + if (mode == rl_editing_mode) + _rl_parsing_conditionalized_out = 0; + else + _rl_parsing_conditionalized_out = 1; + } +#endif /* VI_MODE */ + /* Check to see if the first word in ARGS is the same as the + value stored in rl_readline_name. */ + else if (stricmp (args, rl_readline_name) == 0) + _rl_parsing_conditionalized_out = 0; + else + _rl_parsing_conditionalized_out = 1; + return 0; +} + +/* Invert the current parser state if there is anything on the stack. */ +static int +parser_else (args) + char *args; +{ + register int i; + + if (!if_stack_depth) + { + /* Error message? */ + return 0; + } + + /* Check the previous (n - 1) levels of the stack to make sure that + we haven't previously turned off parsing. */ + for (i = 0; i < if_stack_depth - 1; i++) + if (if_stack[i] == 1) + return 0; + + /* Invert the state of parsing if at top level. */ + _rl_parsing_conditionalized_out = !_rl_parsing_conditionalized_out; + return 0; +} + +/* Terminate a conditional, popping the value of + _rl_parsing_conditionalized_out from the stack. */ +static int +parser_endif (args) + char *args; +{ + if (if_stack_depth) + _rl_parsing_conditionalized_out = if_stack[--if_stack_depth]; + else + { + /* *** What, no error message? *** */ + } + return 0; +} + +/* Associate textual names with actual functions. */ +static struct { + char *name; + Function *function; +} parser_directives [] = { + { "if", parser_if }, + { "endif", parser_endif }, + { "else", parser_else }, + { (char *)0x0, (Function *)0x0 } +}; + +/* Handle a parser directive. STATEMENT is the line of the directive + without any leading `$'. */ +static int +handle_parser_directive (statement) + char *statement; +{ + register int i; + char *directive, *args; + + /* Isolate the actual directive. */ + + /* Skip whitespace. */ + for (i = 0; whitespace (statement[i]); i++); + + directive = &statement[i]; + + for (; statement[i] && !whitespace (statement[i]); i++); + + if (statement[i]) + statement[i++] = '\0'; + + for (; statement[i] && whitespace (statement[i]); i++); + + args = &statement[i]; + + /* Lookup the command, and act on it. */ + for (i = 0; parser_directives[i].name; i++) + if (stricmp (directive, parser_directives[i].name) == 0) + { + (*parser_directives[i].function) (args); + return (0); + } + + /* *** Should an error message be output? */ + return (1); +} + +/* Ugly but working hack for binding prefix meta. */ +#define PREFIX_META_HACK + +static int substring_member_of_array (); + +/* Read the binding command from STRING and perform it. + A key binding command looks like: Keyname: function-name\0, + a variable binding command looks like: set variable value. + A new-style keybinding looks like "\C-x\C-x": exchange-point-and-mark. */ +rl_parse_and_bind (string) + char *string; +{ + char *funname, *kname; + register int c, i; + int key, equivalency; + + while (string && whitespace (*string)) + string++; + + if (!string || !*string || *string == '#') + return; + + /* If this is a parser directive, act on it. */ + if (*string == '$') + { + handle_parser_directive (&string[1]); + return; + } + + /* If we aren't supposed to be parsing right now, then we're done. */ + if (_rl_parsing_conditionalized_out) + return; + + i = 0; + /* If this keyname is a complex key expression surrounded by quotes, + advance to after the matching close quote. This code allows the + backslash to quote characters in the key expression. */ + if (*string == '"') + { + int passc = 0; + + for (i = 1; c = string[i]; i++) + { + if (passc) + { + passc = 0; + continue; + } + + if (c == '\\') + { + passc++; + continue; + } + + if (c == '"') + break; + } + } + + /* Advance to the colon (:) or whitespace which separates the two objects. */ + for (; (c = string[i]) && c != ':' && c != ' ' && c != '\t'; i++ ); + + equivalency = (c == ':' && string[i + 1] == '='); + + /* Mark the end of the command (or keyname). */ + if (string[i]) + string[i++] = '\0'; + + /* If doing assignment, skip the '=' sign as well. */ + if (equivalency) + string[i++] = '\0'; + + /* If this is a command to set a variable, then do that. */ + if (stricmp (string, "set") == 0) + { + char *var = string + i; + char *value; + + /* Make VAR point to start of variable name. */ + while (*var && whitespace (*var)) var++; + + /* Make value point to start of value string. */ + value = var; + while (*value && !whitespace (*value)) value++; + if (*value) + *value++ = '\0'; + while (*value && whitespace (*value)) value++; + + rl_variable_bind (var, value); + return; + } + + /* Skip any whitespace between keyname and funname. */ + for (; string[i] && whitespace (string[i]); i++); + funname = &string[i]; + + /* Now isolate funname. + For straight function names just look for whitespace, since + that will signify the end of the string. But this could be a + macro definition. In that case, the string is quoted, so skip + to the matching delimiter. We allow the backslash to quote the + delimiter characters in the macro body. */ + /* This code exists to allow whitespace in macro expansions, which + would otherwise be gobbled up by the next `for' loop.*/ + /* XXX - it may be desirable to allow backslash quoting only if " is + the quoted string delimiter, like the shell. */ + if (*funname == '\'' || *funname == '"') + { + int delimiter = string[i++]; + int passc = 0; + + for (; c = string[i]; i++) + { + if (passc) + { + passc = 0; + continue; + } + + if (c == '\\') + { + passc = 1; + continue; + } + + if (c == delimiter) + break; + } + if (c) + i++; + } + + /* Advance to the end of the string. */ + for (; string[i] && !whitespace (string[i]); i++); + + /* No extra whitespace at the end of the string. */ + string[i] = '\0'; + + /* Handle equivalency bindings here. Make the left-hand side be exactly + whatever the right-hand evaluates to, including keymaps. */ + if (equivalency) + { + return; + } + + /* If this is a new-style key-binding, then do the binding with + rl_set_key (). Otherwise, let the older code deal with it. */ + if (*string == '"') + { + char *seq = (char *)alloca (1 + strlen (string)); + register int j, k = 0; + int passc = 0; + + for (j = 1; string[j]; j++) + { + /* Allow backslash to quote characters, but leave them in place. + This allows a string to end with a backslash quoting another + backslash, or with a backslash quoting a double quote. The + backslashes are left in place for rl_translate_keyseq (). */ + if (passc || (string[j] == '\\')) + { + seq[k++] = string[j]; + passc = !passc; + continue; + } + + if (string[j] == '"') + break; + + seq[k++] = string[j]; + } + seq[k] = '\0'; + + /* Binding macro? */ + if (*funname == '\'' || *funname == '"') + { + j = strlen (funname); + + /* Remove the delimiting quotes from each end of FUNNAME. */ + if (j && funname[j - 1] == *funname) + funname[j - 1] = '\0'; + + rl_macro_bind (seq, &funname[1], _rl_keymap); + } + else + rl_set_key (seq, rl_named_function (funname), _rl_keymap); + + return; + } + + /* Get the actual character we want to deal with. */ + kname = (char*) strrchr (string, '-'); + if (!kname) + kname = string; + else + kname++; + + key = glean_key_from_name (kname); + + /* Add in control and meta bits. */ + if (substring_member_of_array (string, possible_control_prefixes)) + key = CTRL (to_upper (key)); + + if (substring_member_of_array (string, possible_meta_prefixes)) + key = META (key); + + /* Temporary. Handle old-style keyname with macro-binding. */ + if (*funname == '\'' || *funname == '"') + { + char seq[2]; + int fl = strlen (funname); + + seq[0] = key; seq[1] = '\0'; + if (fl && funname[fl - 1] == *funname) + funname[fl - 1] = '\0'; + + rl_macro_bind (seq, &funname[1], _rl_keymap); + } +#if defined (PREFIX_META_HACK) + /* Ugly, but working hack to keep prefix-meta around. */ + else if (stricmp (funname, "prefix-meta") == 0) + { + char seq[2]; + + seq[0] = key; + seq[1] = '\0'; + rl_generic_bind (ISKMAP, seq, (char *)emacs_meta_keymap, _rl_keymap); + } +#endif /* PREFIX_META_HACK */ + else + rl_bind_key (key, rl_named_function (funname)); +} + +/* Simple structure for boolean readline variables (i.e., those that can + have one of two values; either "On" or 1 for truth, or "Off" or 0 for + false. */ + +static struct { + char *name; + int *value; +} boolean_varlist [] = { + { "horizontal-scroll-mode", &_rl_horizontal_scroll_mode }, + { "mark-modified-lines", &_rl_mark_modified_lines }, + { "prefer-visible-bell", &_rl_prefer_visible_bell }, + { "meta-flag", &_rl_meta_flag }, + { "blink-matching-paren", &rl_blink_matching_paren }, + { "convert-meta", &_rl_convert_meta_chars_to_ascii }, +#if defined (VISIBLE_STATS) + { "visible-stats", &rl_visible_stats }, +#endif /* VISIBLE_STATS */ + { "expand-tilde", &rl_complete_with_tilde_expansion }, + { (char *)NULL, (int *)NULL } +}; + +rl_variable_bind (name, value) + char *name, *value; +{ + register int i; + + /* Check for simple variables first. */ + for (i = 0; boolean_varlist[i].name; i++) + { + if (stricmp (name, boolean_varlist[i].name) == 0) + { + /* A variable is TRUE if the "value" is "on", "1" or "". */ + if ((!*value) || + (stricmp (value, "On") == 0) || + (value[0] == '1' && value[1] == '\0')) + *boolean_varlist[i].value = 1; + else + *boolean_varlist[i].value = 0; + return; + } + } + + /* Not a boolean variable, so check for specials. */ + + /* Editing mode change? */ + if (stricmp (name, "editing-mode") == 0) + { + if (strnicmp (value, "vi", 2) == 0) + { +#if defined (VI_MODE) + _rl_keymap = vi_insertion_keymap; + rl_editing_mode = vi_mode; +#else +#if defined (NOTDEF) + /* What state is the terminal in? I'll tell you: + non-determinate! That means we cannot do any output. */ + ding (); +#endif /* NOTDEF */ +#endif /* VI_MODE */ + } + else if (strnicmp (value, "emacs", 5) == 0) + { + _rl_keymap = emacs_standard_keymap; + rl_editing_mode = emacs_mode; + } + } + + /* Comment string change? */ + else if (stricmp (name, "comment-begin") == 0) + { +#if defined (VI_MODE) + extern char *rl_vi_comment_begin; + + if (*value) + { + if (rl_vi_comment_begin) + free (rl_vi_comment_begin); + + rl_vi_comment_begin = savestring (value); + } +#endif /* VI_MODE */ + } + else if (stricmp (name, "completion-query-items") == 0) + { + int nval = 100; + if (*value) + { + nval = atoi (value); + if (nval < 0) + nval = 0; + } + rl_completion_query_items = nval; + } +} + +/* Return the character which matches NAME. + For example, `Space' returns ' '. */ + +typedef struct { + char *name; + int value; +} assoc_list; + +static assoc_list name_key_alist[] = { + { "DEL", 0x7f }, + { "ESC", '\033' }, + { "Escape", '\033' }, + { "LFD", '\n' }, + { "Newline", '\n' }, + { "RET", '\r' }, + { "Return", '\r' }, + { "Rubout", 0x7f }, + { "SPC", ' ' }, + { "Space", ' ' }, + { "Tab", 0x09 }, + { (char *)0x0, 0 } +}; + +static int +glean_key_from_name (name) + char *name; +{ + register int i; + + for (i = 0; name_key_alist[i].name; i++) + if (stricmp (name, name_key_alist[i].name) == 0) + return (name_key_alist[i].value); + + return (*(unsigned char *)name); /* XXX was return (*name) */ +} + +/* Auxiliary functions to manage keymaps. */ +static struct { + char *name; + Keymap map; +} keymap_names[] = { + { "emacs", emacs_standard_keymap }, + { "emacs-standard", emacs_standard_keymap }, + { "emacs-meta", emacs_meta_keymap }, + { "emacs-ctlx", emacs_ctlx_keymap }, +#if defined (VI_MODE) + { "vi", vi_movement_keymap }, + { "vi-move", vi_movement_keymap }, + { "vi-command", vi_movement_keymap }, + { "vi-insert", vi_insertion_keymap }, +#endif /* VI_MODE */ + { (char *)0x0, (Keymap)0x0 } +}; + +Keymap +rl_get_keymap_by_name (name) + char *name; +{ + register int i; + + for (i = 0; keymap_names[i].name; i++) + if (strcmp (name, keymap_names[i].name) == 0) + return (keymap_names[i].map); + return ((Keymap) NULL); +} + +void +rl_set_keymap (map) + Keymap map; +{ + if (map) + _rl_keymap = map; +} + +Keymap +rl_get_keymap () +{ + return (_rl_keymap); +} + +void +rl_set_keymap_from_edit_mode () +{ + if (rl_editing_mode == emacs_mode) + _rl_keymap = emacs_standard_keymap; + else if (rl_editing_mode == vi_mode) + _rl_keymap = vi_insertion_keymap; +} + +/* **************************************************************** */ +/* */ +/* Key Binding and Function Information */ +/* */ +/* **************************************************************** */ + +/* Each of the following functions produces information about the + state of keybindings and functions known to Readline. The info + is always printed to rl_outstream, and in such a way that it can + be read back in (i.e., passed to rl_parse_and_bind (). */ + +/* Print the names of functions known to Readline. */ +void +rl_list_funmap_names (ignore) + int ignore; +{ + register int i; + char **funmap_names; + + funmap_names = rl_funmap_names (); + + if (!funmap_names) + return; + + for (i = 0; funmap_names[i]; i++) + fprintf (rl_outstream, "%s\n", funmap_names[i]); + + free (funmap_names); +} + +/* Return a NULL terminated array of strings which represent the key + sequences that are used to invoke FUNCTION in MAP. */ +static char ** +invoking_keyseqs_in_map (function, map) + Function *function; + Keymap map; +{ + register int key; + char **result; + int result_index, result_size; + + result = (char **)NULL; + result_index = result_size = 0; + + for (key = 0; key < 128; key++) + { + switch (map[key].type) + { + case ISMACR: + /* Macros match, if, and only if, the pointers are identical. + Thus, they are treated exactly like functions in here. */ + case ISFUNC: + /* If the function in the keymap is the one we are looking for, + then add the current KEY to the list of invoking keys. */ + if (map[key].function == function) + { + char *keyname = (char *)xmalloc (5); + + if (CTRL_P (key)) + sprintf (keyname, "\\C-%c", to_lower (UNCTRL (key))); + else if (key == RUBOUT) + sprintf (keyname, "\\C-?"); + else if (key == '\\' || key == '"') + { + keyname[0] = '\\'; + keyname[1] = (char) key; + keyname[2] = '\0'; + } + else + { + keyname[0] = (char) key; + keyname[1] = '\0'; + } + + if (result_index + 2 > result_size) + result = (char **) xrealloc + (result, (result_size += 10) * sizeof (char *)); + + result[result_index++] = keyname; + result[result_index] = (char *)NULL; + } + break; + + case ISKMAP: + { + char **seqs = (char **)NULL; + + /* Find the list of keyseqs in this map which have FUNCTION as + their target. Add the key sequences found to RESULT. */ + if (map[key].function) + seqs = + invoking_keyseqs_in_map (function, (Keymap)map[key].function); + + if (seqs) + { + register int i; + + for (i = 0; seqs[i]; i++) + { + char *keyname = (char *)xmalloc (6 + strlen (seqs[i])); + + if (key == ESC) + sprintf (keyname, "\\e"); + else if (CTRL_P (key)) + sprintf (keyname, "\\C-%c", to_lower (UNCTRL (key))); + else if (key == RUBOUT) + sprintf (keyname, "\\C-?"); + else if (key == '\\' || key == '"') + { + keyname[0] = '\\'; + keyname[1] = (char) key; + keyname[2] = '\0'; + } + else + { + keyname[0] = (char) key; + keyname[1] = '\0'; + } + + strcat (keyname, seqs[i]); + + if (result_index + 2 > result_size) + result = (char **) xrealloc + (result, (result_size += 10) * sizeof (char *)); + + result[result_index++] = keyname; + result[result_index] = (char *)NULL; + } + } + } + break; + } + } + return (result); +} + +/* Return a NULL terminated array of strings which represent the key + sequences that can be used to invoke FUNCTION using the current keymap. */ +char ** +rl_invoking_keyseqs (function) + Function *function; +{ + return (invoking_keyseqs_in_map (function, _rl_keymap)); +} + +/* Print all of the current functions and their bindings to + rl_outstream. If an explicit argument is given, then print + the output in such a way that it can be read back in. */ +int +rl_dump_functions (count) + int count; +{ + void rl_function_dumper (); + + rl_function_dumper (rl_explicit_arg); + rl_on_new_line (); + return (0); +} + +/* Print all of the functions and their bindings to rl_outstream. If + PRINT_READABLY is non-zero, then print the output in such a way + that it can be read back in. */ +void +rl_function_dumper (print_readably) + int print_readably; +{ + register int i; + char **names; + char *name; + + names = rl_funmap_names (); + + fprintf (rl_outstream, "\n"); + + for (i = 0; name = names[i]; i++) + { + Function *function; + char **invokers; + + function = rl_named_function (name); + invokers = invoking_keyseqs_in_map (function, _rl_keymap); + + if (print_readably) + { + if (!invokers) + fprintf (rl_outstream, "# %s (not bound)\n", name); + else + { + register int j; + + for (j = 0; invokers[j]; j++) + { + fprintf (rl_outstream, "\"%s\": %s\n", + invokers[j], name); + free (invokers[j]); + } + + free (invokers); + } + } + else + { + if (!invokers) + fprintf (rl_outstream, "%s is not bound to any keys\n", + name); + else + { + register int j; + + fprintf (rl_outstream, "%s can be found on ", name); + + for (j = 0; invokers[j] && j < 5; j++) + { + fprintf (rl_outstream, "\"%s\"%s", invokers[j], + invokers[j + 1] ? ", " : ".\n"); + } + + if (j == 5 && invokers[j]) + fprintf (rl_outstream, "...\n"); + + for (j = 0; invokers[j]; j++) + free (invokers[j]); + + free (invokers); + } + } + } +} + + +/* **************************************************************** */ +/* */ +/* String Utility Functions */ +/* */ +/* **************************************************************** */ + +static char *strindex (); + +/* Return non-zero if any members of ARRAY are a substring in STRING. */ +static int +substring_member_of_array (string, array) + char *string, **array; +{ + while (*array) + { + if (strindex (string, *array)) + return (1); + array++; + } + return (0); +} + +/* Whoops, Unix doesn't have strnicmp. */ + +/* Compare at most COUNT characters from string1 to string2. Case + doesn't matter. */ +static int +strnicmp (string1, string2, count) + char *string1, *string2; +{ + register char ch1, ch2; + + while (count) + { + ch1 = *string1++; + ch2 = *string2++; + if (to_upper(ch1) == to_upper(ch2)) + count--; + else break; + } + return (count); +} + +/* strcmp (), but caseless. */ +static int +stricmp (string1, string2) + char *string1, *string2; +{ + register char ch1, ch2; + + while (*string1 && *string2) + { + ch1 = *string1++; + ch2 = *string2++; + if (to_upper(ch1) != to_upper(ch2)) + return (1); + } + return (*string1 | *string2); +} + +/* Determine if s2 occurs in s1. If so, return a pointer to the + match in s1. The compare is case insensitive. */ +static char * +strindex (s1, s2) + register char *s1, *s2; +{ + register int i, l = strlen (s2); + register int len = strlen (s1); + + for (i = 0; (len - i) >= l; i++) + if (strnicmp (&s1[i], s2, l) == 0) + return (s1 + i); + return ((char *)NULL); +} diff --git a/readline/complete.c b/readline/complete.c new file mode 100644 index 00000000000..7b733a3e80f --- /dev/null +++ b/readline/complete.c @@ -0,0 +1,1205 @@ +/* complete.c -- filename completion for readline. */ + +/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc. + + This file is part of the GNU Readline Library, a library for + reading lines of text with interactive input and history editing. + + The GNU Readline Library 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 1, or + (at your option) any later version. + + The GNU Readline Library 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. + + The GNU General Public License is often shipped with GNU software, and + is generally kept in a file called COPYING or LICENSE. If you do not + have a copy of the license, write to the Free Software Foundation, + 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#include "sysdep.h" +#include +#include +#include +#if !defined (NO_SYS_FILE) +# include +#endif /* !NO_SYS_FILE */ + +#include +/* Not all systems declare ERRNO in errno.h... and some systems #define it! */ +#if !defined (errno) +extern int errno; +#endif /* !errno */ + +/* These next are for filename completion. Perhaps this belongs + in a different place. */ +#ifndef __MSDOS__ +#include +#endif /* __MSDOS__ */ +#if defined (USG) && !defined (isc386) && !defined (sgi) +extern struct passwd *getpwuid (), *getpwent (); +#endif +#if defined (isc386) && !defined (__STDC__) && defined (_POSIX_SOURCE) +extern struct passwd *getpwent (); +#endif + +/* System-specific feature definitions and include files. */ +#include "rldefs.h" + +/* Some standard library routines. */ +#include "readline.h" + +#if !defined (strchr) +extern char *strchr (); +#endif /* !strchr */ +#if !defined (strrchr) +extern char *strrchr (); +#endif /* !strrchr*/ + +extern char *tilde_expand (); +extern char *rl_copy_text (); + +extern Function *rl_last_func; +extern int rl_editing_mode; +extern int screenwidth; + +static int compare_strings (); +static char *rl_strpbrk (); + +#if defined (STATIC_MALLOC) +static char *xmalloc (), *xrealloc (); +#else +extern char *xmalloc (), *xrealloc (); +#endif /* STATIC_MALLOC */ + +/* If non-zero, then this is the address of a function to call when + completing on a directory name. The function is called with + the address of a string (the current directory name) as an arg. */ +Function *rl_symbolic_link_hook = (Function *)NULL; + +/* Non-zero means readline completion functions perform tilde expansion. */ +int rl_complete_with_tilde_expansion = 0; + +#define VISIBLE_STATS + +#if defined (VISIBLE_STATS) +static int stat_char (); + +/* Non-zero means add an additional character to each filename displayed + during listing completion iff rl_filename_completion_desired which helps + to indicate the type of file being listed. */ +int rl_visible_stats = 0; +#endif /* VISIBLE_STATS */ + +/* **************************************************************** */ +/* */ +/* Completion matching, from readline's point of view. */ +/* */ +/* **************************************************************** */ + +/* Pointer to the generator function for completion_matches (). + NULL means to use filename_entry_function (), the default filename + completer. */ +Function *rl_completion_entry_function = (Function *)NULL; + +/* Pointer to alternative function to create matches. + Function is called with TEXT, START, and END. + START and END are indices in RL_LINE_BUFFER saying what the boundaries + of TEXT are. + If this function exists and returns NULL then call the value of + rl_completion_entry_function to try to match, otherwise use the + array of strings returned. */ +Function *rl_attempted_completion_function = (Function *)NULL; + +/* Local variable states what happened during the last completion attempt. */ +static int completion_changed_buffer = 0; + +/* Complete the word at or before point. You have supplied the function + that does the initial simple matching selection algorithm (see + completion_matches ()). The default is to do filename completion. */ + +rl_complete (ignore, invoking_key) + int ignore, invoking_key; +{ + if (rl_last_func == rl_complete && !completion_changed_buffer) + rl_complete_internal ('?'); + else + rl_complete_internal (TAB); +} + +/* List the possible completions. See description of rl_complete (). */ +rl_possible_completions (ignore, invoking_key) +{ + rl_complete_internal ('?'); +} + +rl_insert_completions (ignore, invoking_key) + int ignore, invoking_key; +{ + rl_complete_internal ('*'); +} + +/* The user must press "y" or "n". Non-zero return means "y" pressed. */ +get_y_or_n () +{ + int c; + + for (;;) + { + c = rl_read_key (); + if (c == 'y' || c == 'Y') + return (1); + if (c == 'n' || c == 'N') + return (0); + if (c == ABORT_CHAR) + rl_abort (); + ding (); + } +} + +/* Up to this many items will be displayed in response to a + possible-completions call. After that, we ask the user if + she is sure she wants to see them all. */ +int rl_completion_query_items = 100; + +/* The basic list of characters that signal a break between words for the + completer routine. The contents of this variable is what breaks words + in the shell, i.e. " \t\n\"\\'`@$><=" */ +char *rl_basic_word_break_characters = " \t\n\"\\'`@$><=;|&{("; + +/* The list of characters that signal a break between words for + rl_complete_internal. The default list is the contents of + rl_basic_word_break_characters. */ +char *rl_completer_word_break_characters = (char *)NULL; + +/* List of characters which can be used to quote a substring of the line. + Completion occurs on the entire substring, and within the substring + rl_completer_word_break_characters are treated as any other character, + unless they also appear within this list. */ +char *rl_completer_quote_characters = (char *)NULL; + +/* List of characters that are word break characters, but should be left + in TEXT when it is passed to the completion function. The shell uses + this to help determine what kind of completing to do. */ +char *rl_special_prefixes = (char *)NULL; + +/* If non-zero, then disallow duplicates in the matches. */ +int rl_ignore_completion_duplicates = 1; + +/* Non-zero means that the results of the matches are to be treated + as filenames. This is ALWAYS zero on entry, and can only be changed + within a completion entry finder function. */ +int rl_filename_completion_desired = 0; + +/* This function, if defined, is called by the completer when real + filename completion is done, after all the matching names have been + generated. It is passed a (char**) known as matches in the code below. + It consists of a NULL-terminated array of pointers to potential + matching strings. The 1st element (matches[0]) is the maximal + substring that is common to all matches. This function can re-arrange + the list of matches as required, but all elements of the array must be + free()'d if they are deleted. The main intent of this function is + to implement FIGNORE a la SunOS csh. */ +Function *rl_ignore_some_completions_function = (Function *)NULL; + +/* Complete the word at or before point. + WHAT_TO_DO says what to do with the completion. + `?' means list the possible completions. + TAB means do standard completion. + `*' means insert all of the possible completions. */ +rl_complete_internal (what_to_do) + int what_to_do; +{ + char *filename_completion_function (); + char **completion_matches (), **matches; + Function *our_func; + int start, scan, end, delimiter = 0; + char *text, *saved_line_buffer; + char quote_char = '\0'; + char *replacement; + + if (rl_line_buffer) + saved_line_buffer = savestring (rl_line_buffer); + else + saved_line_buffer = (char *)NULL; + + if (rl_completion_entry_function) + our_func = rl_completion_entry_function; + else + our_func = (int (*)())filename_completion_function; + + /* Only the completion entry function can change this. */ + rl_filename_completion_desired = 0; + + /* We now look backwards for the start of a filename/variable word. */ + end = rl_point; + + if (rl_point) + { + if (rl_completer_quote_characters) + { + /* We have a list of characters which can be used in pairs to + quote substrings for the completer. Try to find the start + of an unclosed quoted substring. + [FIXME: Doesn't yet handle '\' escapes to quote quotes. */ + for (scan = 0; scan < end; scan++) + { + if (quote_char != '\0') + { + /* Ignore everything until the matching close quote char. */ + if (rl_line_buffer[scan] == quote_char) + { + /* Found matching close quote. Abandon this substring. */ + quote_char = '\0'; + rl_point = end; + } + } + else if (strchr (rl_completer_quote_characters, rl_line_buffer[scan])) + { + /* Found start of a quoted substring. */ + quote_char = rl_line_buffer[scan]; + rl_point = scan + 1; + } + } + } + if (rl_point == end) + { + /* We didn't find an unclosed quoted substring upon which to do + completion, so use the word break characters to find the + substring on which to do completion. */ + while (--rl_point && + !strchr (rl_completer_word_break_characters, + rl_line_buffer[rl_point])) {;} + } + + /* If we are at a word break, then advance past it. */ + if (strchr (rl_completer_word_break_characters, rl_line_buffer[rl_point])) + { + /* If the character that caused the word break was a quoting + character, then remember it as the delimiter. */ + if (strchr ("\"'", rl_line_buffer[rl_point]) && (end - rl_point) > 1) + delimiter = rl_line_buffer[rl_point]; + + /* If the character isn't needed to determine something special + about what kind of completion to perform, then advance past it. */ + + if (!rl_special_prefixes || + !strchr (rl_special_prefixes, rl_line_buffer[rl_point])) + rl_point++; + } + } + + start = rl_point; + rl_point = end; + text = rl_copy_text (start, end); + + /* If the user wants to TRY to complete, but then wants to give + up and use the default completion function, they set the + variable rl_attempted_completion_function. */ + if (rl_attempted_completion_function) + { + matches = + (char **)(*rl_attempted_completion_function) (text, start, end); + + if (matches) + { + if (matches == (char **)-1) + matches = (char **)NULL; + our_func = (Function *)NULL; + goto after_usual_completion; + } + } + + matches = completion_matches (text, our_func); + + after_usual_completion: + free (text); + + if (!matches) + ding (); + else + { + register int i; + + some_matches: + + /* It seems to me that in all the cases we handle we would like + to ignore duplicate possibilities. Scan for the text to + insert being identical to the other completions. */ + if (rl_ignore_completion_duplicates) + { + char *lowest_common; + int j, newlen = 0; + + /* Sort the items. */ + /* It is safe to sort this array, because the lowest common + denominator found in matches[0] will remain in place. */ + for (i = 0; matches[i]; i++); + qsort (matches, i, sizeof (char *), compare_strings); + + /* Remember the lowest common denominator for it may be unique. */ + lowest_common = savestring (matches[0]); + + for (i = 0; matches[i + 1]; i++) + { + if (strcmp (matches[i], matches[i + 1]) == 0) + { + free (matches[i]); + matches[i] = (char *)-1; + } + else + newlen++; + } + + /* We have marked all the dead slots with (char *)-1. + Copy all the non-dead entries into a new array. */ + { + char **temp_array = + (char **)xmalloc ((3 + newlen) * sizeof (char *)); + + for (i = 1, j = 1; matches[i]; i++) + { + if (matches[i] != (char *)-1) + temp_array[j++] = matches[i]; + } + + temp_array[j] = (char *)NULL; + + if (matches[0] != (char *)-1) + free (matches[0]); + + free (matches); + + matches = temp_array; + } + + /* Place the lowest common denominator back in [0]. */ + matches[0] = lowest_common; + + /* If there is one string left, and it is identical to the + lowest common denominator, then the LCD is the string to + insert. */ + if (j == 2 && strcmp (matches[0], matches[1]) == 0) + { + free (matches[1]); + matches[1] = (char *)NULL; + } + } + + switch (what_to_do) + { + case TAB: + /* If we are matching filenames, then here is our chance to + do clever processing by re-examining the list. Call the + ignore function with the array as a parameter. It can + munge the array, deleting matches as it desires. */ + if (rl_ignore_some_completions_function && + our_func == (int (*)())filename_completion_function) + (void)(*rl_ignore_some_completions_function)(matches); + + /* If we are doing completion on quoted substrings, and any matches + contain any of the completer_word_break_characters, then auto- + matically prepend the substring with a quote character (just pick + the first one from the list of such) if it does not already begin + with a quote string. FIXME: Need to remove any such automatically + inserted quote character when it no longer is necessary, such as + if we change the string we are completing on and the new set of + matches don't require a quoted substring. */ + replacement = matches[0]; + + if (matches[0] && rl_completer_quote_characters && !quote_char && + rl_filename_completion_desired) + { + int do_replace; + + do_replace = 0; + + /* If there is only a single match, see if we need to + quote it. */ + if (!matches[1] && + rl_strpbrk (matches[0], rl_completer_word_break_characters)) + do_replace = 1; + + /* If there are multiple matches, check to see if any of them + require that the substring be quoted. */ + for (i = 1; matches[i] != NULL; i++) + if (rl_strpbrk (matches[i], rl_completer_word_break_characters)) + { + do_replace = 1; + break; + } + if (do_replace) + { +#if defined (SHELL) + /* XXX - experimental */ + /* Single-quote the replacement, since we found an + embedded word break character in a potential match. */ + char *rtext; + extern char *single_quote (); /* in builtins/common.c */ + + rtext = single_quote (matches[0]); + replacement = (char *)alloca (strlen (rtext) + 1); + strcpy (replacement, rtext); + free (rtext); +#else /* !SHELL */ + /* Found an embedded word break character in a potential + match, so we need to prepend a quote character if we + are replacing the completion string. */ + replacement = (char *)alloca (strlen (matches[0]) + 2); + quote_char = *rl_completer_quote_characters; + *replacement = quote_char; + strcpy (replacement + 1, matches[0]); +#endif /* SHELL */ + } + } + if (replacement) + { + rl_delete_text (start, rl_point); + rl_point = start; + rl_insert_text (replacement); + } + + /* If there are more matches, ring the bell to indicate. + If this was the only match, and we are hacking files, + check the file to see if it was a directory. If so, + add a '/' to the name. If not, and we are at the end + of the line, then add a space. */ + if (matches[1]) + { + if (rl_editing_mode != vi_mode) + ding (); /* There are other matches remaining. */ + } + else + { + char temp_string[4]; + int temp_string_index = 0; + + if (quote_char) + temp_string[temp_string_index++] = quote_char; + + temp_string[temp_string_index++] = delimiter ? delimiter : ' '; + temp_string[temp_string_index++] = '\0'; + + if (rl_filename_completion_desired) + { + struct stat finfo; + char *filename = tilde_expand (matches[0]); + + if ((stat (filename, &finfo) == 0) && + S_ISDIR (finfo.st_mode)) + { + if (rl_line_buffer[rl_point] != '/') + rl_insert_text ("/"); + } + else + { + if (rl_point == rl_end) + rl_insert_text (temp_string); + } + free (filename); + } + else + { + if (rl_point == rl_end) + rl_insert_text (temp_string); + } + } + break; + + case '*': + { + int i = 1; + + rl_delete_text (start, rl_point); + rl_point = start; + rl_begin_undo_group (); + if (matches[1]) + { + while (matches[i]) + { + rl_insert_text (matches[i++]); + rl_insert_text (" "); + } + } + else + { + rl_insert_text (matches[0]); + rl_insert_text (" "); + } + rl_end_undo_group (); + } + break; + + case '?': + { + int len, count, limit, max = 0; + int j, k, l; + + /* Handle simple case first. What if there is only one answer? */ + if (!matches[1]) + { + char *temp; + + if (rl_filename_completion_desired) + temp = strrchr (matches[0], '/'); + else + temp = (char *)NULL; + + if (!temp) + temp = matches[0]; + else + temp++; + + crlf (); + fprintf (rl_outstream, "%s", temp); +#if defined (VISIBLE_STATS) + if (rl_filename_completion_desired && rl_visible_stats) + { + int extension_char; + + extension_char = stat_char (matches[0]); + if (extension_char) + putc (extension_char, rl_outstream); + } +#endif /* VISIBLE_STATS */ + crlf (); + goto restart; + } + + /* There is more than one answer. Find out how many there are, + and find out what the maximum printed length of a single entry + is. */ + for (i = 1; matches[i]; i++) + { + char *temp; + int name_length; + + /* If we are hacking filenames, then only count the characters + after the last slash in the pathname. */ + if (rl_filename_completion_desired) + temp = strrchr (matches[i], '/'); + else + temp = (char *)NULL; + + if (!temp) + temp = matches[i]; + else + temp++; + + name_length = strlen (temp); + + if (name_length > max) + max = name_length; + } + + len = i - 1; + + /* If there are many items, then ask the user if she + really wants to see them all. */ + if (len >= rl_completion_query_items) + { + crlf (); + fprintf (rl_outstream, + "There are %d possibilities. Do you really", len); + crlf (); + fprintf (rl_outstream, "wish to see them all? (y or n)"); + fflush (rl_outstream); + if (!get_y_or_n ()) + { + crlf (); + goto restart; + } + } + /* How many items of MAX length can we fit in the screen window? */ + max += 2; + limit = screenwidth / max; + if (limit != 1 && (limit * max == screenwidth)) + limit--; + + /* Avoid a possible floating exception. If max > screenwidth, + limit will be 0 and a divide-by-zero fault will result. */ + if (limit == 0) + limit = 1; + + /* How many iterations of the printing loop? */ + count = (len + (limit - 1)) / limit; + + /* Watch out for special case. If LEN is less than LIMIT, then + just do the inner printing loop. */ + if (len < limit) + count = 1; + + /* Sort the items if they are not already sorted. */ + if (!rl_ignore_completion_duplicates) + qsort (matches, len, sizeof (char *), compare_strings); + + /* Print the sorted items, up-and-down alphabetically, like + ls might. */ + crlf (); + + for (i = 1; i < count + 1; i++) + { + for (j = 0, l = i; j < limit; j++) + { + if (l > len || !matches[l]) + { + break; + } + else + { + char *temp = (char *)NULL; + int printed_length; + + if (rl_filename_completion_desired) + temp = strrchr (matches[l], '/'); + + if (!temp) + temp = matches[l]; + else + temp++; + + printed_length = strlen (temp); + fprintf (rl_outstream, "%s", temp); + +#if defined (VISIBLE_STATS) + if (rl_filename_completion_desired && + rl_visible_stats) + { + int extension_char; + + extension_char = stat_char (matches[l]); + + if (extension_char) + { + putc (extension_char, rl_outstream); + printed_length++; + } + } +#endif /* VISIBLE_STATS */ + + if (j + 1 < limit) + { + for (k = 0; k < max - printed_length; k++) + putc (' ', rl_outstream); + } + } + l += count; + } + crlf (); + } + restart: + + rl_on_new_line (); + } + break; + + default: + abort (); + } + + for (i = 0; matches[i]; i++) + free (matches[i]); + free (matches); + } + + /* Check to see if the line has changed through all of this manipulation. */ + if (saved_line_buffer) + { + if (strcmp (rl_line_buffer, saved_line_buffer) != 0) + completion_changed_buffer = 1; + else + completion_changed_buffer = 0; + + free (saved_line_buffer); + } +} + +#if defined (VISIBLE_STATS) +/* Return the character which best describes FILENAME. + `@' for symbolic links + `/' for directories + `*' for executables + `=' for sockets */ +static int +stat_char (filename) + char *filename; +{ + struct stat finfo; + int character = 0; + + if (stat (filename, &finfo) == -1) + return (character); + + if (S_ISDIR (finfo.st_mode)) + character = '/'; +#if defined (S_ISLNK) + else if (S_ISLNK (finfo.st_mode)) + character = '@'; +#endif /* S_ISLNK */ +#if defined (S_ISSOCK) + else if (S_ISSOCK (finfo.st_mode)) + character = '='; +#endif /* S_ISSOCK */ + else if (S_ISREG (finfo.st_mode)) + { + if (access (filename, X_OK) == 0) + character = '*'; + } + return (character); +} +#endif /* VISIBLE_STATS */ + +/* Stupid comparison routine for qsort () ing strings. */ +static int +compare_strings (s1, s2) + char **s1, **s2; +{ + return (strcmp (*s1, *s2)); +} + +/* A completion function for usernames. + TEXT contains a partial username preceded by a random + character (usually `~'). */ +char * +username_completion_function (text, state) + int state; + char *text; +{ +#ifdef __GO32__ + return (char *)NULL; +#else /* !__GO32__ */ + static char *username = (char *)NULL; + static struct passwd *entry; + static int namelen, first_char, first_char_loc; + + if (!state) + { + if (username) + free (username); + + first_char = *text; + + if (first_char == '~') + first_char_loc = 1; + else + first_char_loc = 0; + + username = savestring (&text[first_char_loc]); + namelen = strlen (username); + setpwent (); + } + + while (entry = getpwent ()) + { + if (strncmp (username, entry->pw_name, namelen) == 0) + break; + } + + if (!entry) + { + endpwent (); + return ((char *)NULL); + } + else + { + char *value = (char *)xmalloc (2 + strlen (entry->pw_name)); + + *value = *text; + + strcpy (value + first_char_loc, entry->pw_name); + + if (first_char == '~') + rl_filename_completion_desired = 1; + + return (value); + } +#endif /* !__GO32__ */ +} + + +/* **************************************************************** */ +/* */ +/* Completion */ +/* */ +/* **************************************************************** */ + +/* Non-zero means that case is not significant in completion. */ +int completion_case_fold = 0; + +/* Return an array of (char *) which is a list of completions for TEXT. + If there are no completions, return a NULL pointer. + The first entry in the returned array is the substitution for TEXT. + The remaining entries are the possible completions. + The array is terminated with a NULL pointer. + + ENTRY_FUNCTION is a function of two args, and returns a (char *). + The first argument is TEXT. + The second is a state argument; it should be zero on the first call, and + non-zero on subsequent calls. It returns a NULL pointer to the caller + when there are no more matches. + */ +char ** +completion_matches (text, entry_function) + char *text; + char *(*entry_function) (); +{ + /* Number of slots in match_list. */ + int match_list_size; + + /* The list of matches. */ + char **match_list = + (char **)xmalloc (((match_list_size = 10) + 1) * sizeof (char *)); + + /* Number of matches actually found. */ + int matches = 0; + + /* Temporary string binder. */ + char *string; + + match_list[1] = (char *)NULL; + + while (string = (*entry_function) (text, matches)) + { + if (matches + 1 == match_list_size) + match_list = (char **)xrealloc + (match_list, ((match_list_size += 10) + 1) * sizeof (char *)); + + match_list[++matches] = string; + match_list[matches + 1] = (char *)NULL; + } + + /* If there were any matches, then look through them finding out the + lowest common denominator. That then becomes match_list[0]. */ + if (matches) + { + register int i = 1; + int low = 100000; /* Count of max-matched characters. */ + + /* If only one match, just use that. */ + if (matches == 1) + { + match_list[0] = match_list[1]; + match_list[1] = (char *)NULL; + } + else + { + /* Otherwise, compare each member of the list with + the next, finding out where they stop matching. */ + + while (i < matches) + { + register int c1, c2, si; + + if (completion_case_fold) + { + for (si = 0; + (c1 = to_lower(match_list[i][si])) && + (c2 = to_lower(match_list[i + 1][si])); + si++) + if (c1 != c2) break; + } + else + { + for (si = 0; + (c1 = match_list[i][si]) && + (c2 = match_list[i + 1][si]); + si++) + if (c1 != c2) break; + } + + if (low > si) low = si; + i++; + } + match_list[0] = (char *)xmalloc (low + 1); + strncpy (match_list[0], match_list[1], low); + match_list[0][low] = '\0'; + } + } + else /* There were no matches. */ + { + free (match_list); + match_list = (char **)NULL; + } + return (match_list); +} + +/* Okay, now we write the entry_function for filename completion. In the + general case. Note that completion in the shell is a little different + because of all the pathnames that must be followed when looking up the + completion for a command. */ +char * +filename_completion_function (text, state) + int state; + char *text; +{ + static DIR *directory; + static char *filename = (char *)NULL; + static char *dirname = (char *)NULL; + static char *users_dirname = (char *)NULL; + static int filename_len; + + dirent *entry = (dirent *)NULL; + + /* If we don't have any state, then do some initialization. */ + if (!state) + { + char *temp; + + if (dirname) free (dirname); + if (filename) free (filename); + if (users_dirname) free (users_dirname); + + filename = savestring (text); + if (!*text) text = "."; + dirname = savestring (text); + + temp = strrchr (dirname, '/'); + + if (temp) + { + strcpy (filename, ++temp); + *temp = '\0'; + } + else + strcpy (dirname, "."); + + /* We aren't done yet. We also support the "~user" syntax. */ + + /* Save the version of the directory that the user typed. */ + users_dirname = savestring (dirname); + { + char *temp_dirname; + + temp_dirname = tilde_expand (dirname); + free (dirname); + dirname = temp_dirname; + + if (rl_symbolic_link_hook) + (*rl_symbolic_link_hook) (&dirname); + } + directory = opendir (dirname); + filename_len = strlen (filename); + + rl_filename_completion_desired = 1; + } + + /* At this point we should entertain the possibility of hacking wildcarded + filenames, like /usr/man/man/te. If the directory name + contains globbing characters, then build an array of directories, and + then map over that list while completing. */ + /* *** UNIMPLEMENTED *** */ + + /* Now that we have some state, we can read the directory. */ + + while (directory && (entry = readdir (directory))) + { + /* Special case for no filename. + All entries except "." and ".." match. */ + if (!filename_len) + { + if ((strcmp (entry->d_name, ".") != 0) && + (strcmp (entry->d_name, "..") != 0)) + break; + } + else + { + /* Otherwise, if these match upto the length of filename, then + it is a match. */ + if (((int)D_NAMLEN (entry)) >= filename_len && + (entry->d_name[0] == filename[0]) && + (strncmp (filename, entry->d_name, filename_len) == 0)) + { + break; + } + } + } + + if (!entry) + { + if (directory) + { + closedir (directory); + directory = (DIR *)NULL; + } + + if (dirname) + { + free (dirname); + dirname = (char *)NULL; + } + if (filename) + { + free (filename); + filename = (char *)NULL; + } + if (users_dirname) + { + free (users_dirname); + users_dirname = (char *)NULL; + } + + return (char *)NULL; + } + else + { + char *temp; + + if (dirname && (strcmp (dirname, ".") != 0)) + { + if (rl_complete_with_tilde_expansion && *users_dirname == '~') + { + int dirlen = strlen (dirname); + temp = (char *)xmalloc (2 + dirlen + D_NAMLEN (entry)); + strcpy (temp, dirname); + /* Canonicalization cuts off any final slash present. We need + to add it back. */ + if (dirname[dirlen - 1] != '/') + { + temp[dirlen] = '/'; + temp[dirlen + 1] = '\0'; + } + } + else + { + temp = (char *) + xmalloc (1 + strlen (users_dirname) + D_NAMLEN (entry)); + strcpy (temp, users_dirname); + } + + strcat (temp, entry->d_name); + } + else + { + temp = (savestring (entry->d_name)); + } + return (temp); + } +} + +/* A function for simple tilde expansion. */ +int +rl_tilde_expand (ignore, key) + int ignore, key; +{ + register int start, end; + char *homedir; + + end = rl_point; + start = end - 1; + + if (rl_point == rl_end && rl_line_buffer[rl_point] == '~') + { + homedir = tilde_expand ("~"); + goto insert; + } + else if (rl_line_buffer[start] != '~') + { + for (; !whitespace (rl_line_buffer[start]) && start >= 0; start--); + start++; + } + + end = start; + do + { + end++; + } + while (!whitespace (rl_line_buffer[end]) && end < rl_end); + + if (whitespace (rl_line_buffer[end]) || end >= rl_end) + end--; + + /* If the first character of the current word is a tilde, perform + tilde expansion and insert the result. If not a tilde, do + nothing. */ + if (rl_line_buffer[start] == '~') + { + char *temp; + int len; + + len = end - start + 1; + temp = (char *)alloca (len + 1); + strncpy (temp, rl_line_buffer + start, len); + temp[len] = '\0'; + homedir = tilde_expand (temp); + + insert: + rl_begin_undo_group (); + rl_delete_text (start, end + 1); + rl_point = start; + rl_insert_text (homedir); + rl_end_undo_group (); + } + + return (0); +} + +/* Find the first occurrence in STRING1 of any character from STRING2. + Return a pointer to the character in STRING1. */ +static char * +rl_strpbrk (string1, string2) + char *string1, *string2; +{ + register char *scan; + + for (; *string1; string1++) + { + for (scan = string2; *scan; scan++) + { + if (*string1 == *scan) + { + return (string1); + } + } + } + return ((char *)NULL); +} + +#if defined (STATIC_MALLOC) + +/* **************************************************************** */ +/* */ +/* xmalloc and xrealloc () */ +/* */ +/* **************************************************************** */ + +static void memory_error_and_abort (); + +static char * +xmalloc (bytes) + int bytes; +{ + char *temp = (char *)malloc (bytes); + + if (!temp) + memory_error_and_abort (); + return (temp); +} + +static char * +xrealloc (pointer, bytes) + char *pointer; + int bytes; +{ + char *temp; + + if (!pointer) + temp = (char *)malloc (bytes); + else + temp = (char *)realloc (pointer, bytes); + + if (!temp) + memory_error_and_abort (); + + return (temp); +} + +static void +memory_error_and_abort () +{ + fprintf (stderr, "readline: Out of virtual memory!\n"); + abort (); +} +#endif /* STATIC_MALLOC */ diff --git a/readline/config.h.in b/readline/config.h.in new file mode 100644 index 00000000000..65927a8440d --- /dev/null +++ b/readline/config.h.in @@ -0,0 +1,145 @@ +/* config.h.in. Generated automatically from configure.in by autoheader. */ + +/* Define if on MINIX. */ +#undef _MINIX + +/* Define as the return type of signal handlers (int or void). */ +#undef RETSIGTYPE + +/* Define if the `S_IS*' macros in do not work properly. */ +#undef STAT_MACROS_BROKEN + +#undef VOID_SIGHANDLER + +/* Define if you have the lstat function. */ +#undef HAVE_LSTAT + +/* Define if you have the putenv function. */ +#undef HAVE_PUTENV + +/* Define if you have the select function. */ +#undef HAVE_SELECT + +/* Define if you have the setenv function. */ +#undef HAVE_SETENV + +/* Define if you have the strcasecmp function. */ +#undef HAVE_STRCASECMP + +/* Define if you have the setlocale function. */ +#undef HAVE_SETLOCALE + +/* Define if you have the tcgetattr function. */ +#undef HAVE_TCGETATTR + +/* Define if you have the strcoll function. */ +#undef HAVE_STRCOLL + +#undef STRCOLL_BROKEN + +/* Define if you have the header file. */ +#undef HAVE_DIRENT_H + +/* Define if you have the header file. */ +#undef HAVE_NDIR_H + +/* Define if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define if you have the header file. */ +#undef HAVE_STRING_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_DIR_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_FILE_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_NDIR_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_PTE_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_PTEM_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_SELECT_H + +/* Define if you have the header file. */ +#undef HAVE_SYS_STREAM_H + +/* Define if you have the header file. */ +#undef HAVE_TERMCAP_H + +/* Define if you have the header file. */ +#undef HAVE_TERMIO_H + +/* Define if you have the header file. */ +#undef HAVE_TERMIOS_H + +/* Define if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Define if you have the header file. */ +#undef HAVE_VARARGS_H + +/* Define if you have the header file. */ +#undef HAVE_STDARG_H + +#undef HAVE_LOCALE_H + +/* Definitions pulled in from aclocal.m4. */ +#undef VOID_SIGHANDLER + +#undef GWINSZ_IN_SYS_IOCTL + +#undef STRUCT_WINSIZE_IN_SYS_IOCTL + +#undef STRUCT_WINSIZE_IN_TERMIOS + +#undef TIOCSTAT_IN_SYS_IOCTL + +#undef FIONREAD_IN_SYS_IOCTL + +#undef SPEED_T_IN_SYS_TYPES + +#undef HAVE_GETPW_DECLS + +#undef STRUCT_DIRENT_HAS_D_INO + +#undef STRUCT_DIRENT_HAS_D_FILENO + +#undef HAVE_BSD_SIGNALS + +#undef HAVE_POSIX_SIGNALS + +#undef HAVE_USG_SIGHOLD + +#undef MUST_REINSTALL_SIGHANDLERS + +#undef HAVE_POSIX_SIGSETJMP + +/* config.h.bot */ +/* modify settings or make new ones based on what autoconf tells us. */ + +/* Ultrix botches type-ahead when switching from canonical to + non-canonical mode, at least through version 4.3 */ +#if !defined (HAVE_TERMIOS_H) || !defined (HAVE_TCGETATTR) || defined (ultrix) +# define TERMIOS_MISSING +#endif + +#if defined (STRCOLL_BROKEN) +# undef HAVE_STRCOLL +#endif + +#if defined (__STDC__) && defined (HAVE_STDARG_H) +# define PREFER_STDARG +# define USE_VARARGS +#else +# if defined (HAVE_VARARGS_H) +# define PREFER_VARARGS +# define USE_VARARGS +# endif +#endif diff --git a/readline/config.sub b/readline/config.sub deleted file mode 100755 index dac9ab89d4f..00000000000 --- a/readline/config.sub +++ /dev/null @@ -1,446 +0,0 @@ -#!/bin/sh - -# Configuration subroutine to validate and canonicalize a configuration type. -# Supply the specified configuration type as an argument. -# If it is invalid, we print an error message on stderr and exit with code 1. -# Otherwise, we print the canonical config type on stdout and succeed. - -# This file is supposed to be the same for all GNU packages -# and recognize all the CPU types, system types and aliases -# that are meaningful with *any* GNU software. -# Each package is responsible for reporting which valid configurations -# it does not support. The user should be able to distinguish -# a failure to support a valid configuration from a meaningless -# configuration (e.g. a typo). - -# Please email any bugs, comments, and/or additions to this file to: -# configure@cygnus.com - -# decode aliases into canonical names - -case "$1" in -# cpu alone is a valid alias for cpu-none-none. -vax | tahoe | i386 | i860 | m68k | m68000 | m88k | sparc | ns32k \ - | alliant | arm | c1 | c2 | mips | pyramid | tron | a29k \ - | romp | rs6000 | i960 | h8300) - cpu=$1 - vendor=none - os=none - ;; -altos | altos3068) - cpu=m68k - vendor=altos - os=sysv # maybe? - ;; -altosgas) - cpu=m68k - vendor=altos - os=gas - ;; -am29k) - cpu=a29k - vendor=none - os=bsd - ;; -amdahl) - cpu=580 - vendor=amdahl - os=uts - ;; -amigados) - cpu=m68k - vendor=cbm - os=amigados # Native AmigaDOS - ;; -amigaunix | amix) - cpu=m68k - vendor=cbm - os=svr4 # System V Release 4 (svr4 is an industry recognized acronym) - ;; -apollo68) - cpu=m68k - vendor=apollo - os=sysv # maybe? - ;; -balance) - cpu=ns32k - vendor=sequent - os=dynix - ;; -convex-c1) - cpu=c1 - vendor=convex - os=sysv # maybe? - ;; -convex-c2) - cpu=c2 - vendor=convex - os=sysv # maybe? - ;; -cray | ymp) - cpu=ymp - vendor=cray - os=unicos - ;; -cray2) - cpu=cray2 - vendor=cray - os=unicos - ;; -dec3100 | decstatn | decstation | decstation-3100 | pmax | pmin) - cpu=mips - vendor=dec - os=ultrix - ;; -delta | 3300 | motorola-3300 | motorola-delta \ - | 3300-motorola | delta-motorola) - cpu=m68k - vendor=motorola - os=sysv # maybe? - ;; - -delta88) - cpu=m88k - vendor=motorola - os=m88kbcs - ;; - -gmicro) - cpu=tron - vendor=gmicro - os=sysv # maybe? - ;; - -h8300hds) - cpu=h8300 - vendor=hitachi - os=hds - ;; - -# start-sanitize-v9 -hal-32 | hal32) - cpu=sparc64 - vendor=hal - os=hal32 - ;; -hal-64 | hal64) - cpu=sparc64 - vendor=hal - os=hal64 - ;; -sparc64) - cpu=sparc64 - vendor=sun - os=v9 - ;; -sparc64-v7 | sparc64v7) - cpu=sparc64 - vendor=sun - os=v7 - ;; -# end-sanitize-v9 -hp300bsd) - cpu=m68k - vendor=hp - os=bsd - ;; -hp300hpux | hpux | hp9k3[2-9][0-9]) - cpu=m68k - vendor=hp - os=hpux - ;; -hp9k31[0-9] | hp9k2[0-9][0-9]) - cpu=m68000 - vendor=hp - os=hpux - ;; -i386sco) - cpu=i386 - vendor=sco - os=sysv # maybe? - ;; -i386v) - cpu=i386 - vendor=none - os=sysv - ;; -i386v32) - cpu=i386 - vendor=none - os=sysv32 - ;; -iris | iris4d) - cpu=mips - vendor=sgi - os=irix # maybe? - ;; - -dpx2) - vendor=bull - cpu=m68k - os=sysv - ;; -isi | isi68) - cpu=m68k - vendor=isi - os=sysv # maybe? - ;; -littlemips) - cpu=mips - vendor=little - os=bsd - ;; -magnum | m3230) - cpu=mips - vendor=mips - os=sysv # maybe? - ;; -merlin) - cpu=ns32k - vendor=utek - os=sysv # maybe? - ;; -miniframe) - cpu=m68000 - vendor=convergent - os=sysv # maybe? - ;; -mmax) - cpu=ns32k - vendor=encore - os=sysv # maybe? - ;; -news | news700 | news800 | news900) - cpu=m68k - vendor=sony - os=newsos3 # Based on bsd-4.3 - ;; -news1000) - cpu=m68030 - vendor=sony - os=newsos3 # ? - ;; -news-3600 | bigmips | risc-news) - cpu=mips - vendor=sony - os=newsos4 # Presumably? - ;; -next) - cpu=m68k - vendor=next - os=sysv # maybe? - ;; -nindy960) - cpu=i960 - vendor=intel - os=nindy - ;; -none) - cpu=none - vendor=none - os=none - ;; -np1) - cpu=np1 - vendor=gould - os=sysv # maybe? - ;; -rtpc) - cpu=romp - vendor=ibm - os=aix # maybe? - ;; -pbd) - cpu=sparc - vendor=unicom - os=sysv - ;; -pn) - cpu=pn - vendor=gould - os=sysv # maybe? - ;; -ps2) - cpu=i386 - vendor=ibm - os=sysv # maybe? - ;; -sun2) - cpu=m68000 - vendor=sun - os=sunos4 - ;; -sun2os3) - cpu=m68000 - vendor=sun - os=sunos3 - ;; -sun2os4) - cpu=m68000 - vendor=sun - os=sunos4 - ;; -sun3) - cpu=m68k - vendor=sun - os=sunos4 - ;; -sun3os3) - cpu=m68k - vendor=sun - os=sunos3 - ;; -sun3os4) - cpu=m68k - vendor=sun - os=sunos4 - ;; -sun386 | roadrunner | sun386i) - cpu=i386 - vendor=sun - os=sunos - ;; -sun4) - cpu=sparc - vendor=sun - os=sunos4 - ;; -sun4os3) - cpu=sparc - vendor=sun - os=sunos3 - ;; -sun4os4) - cpu=sparc - vendor=sun - os=sunos4 - ;; -symmetry) - cpu=i386 - vendor=sequent - os=dynix - ;; -tower | tower-32) - cpu=m68k - vendor=ncr - os=sysv # maybe? - ;; -ultra3) - cpu=a29k - vendor=nyu - os=sym1 - ;; -umax) - cpu=ns32k - vendor=encore - os=sysv # maybe? - ;; -unixpc | safari | pc7300 | 3b1 | 7300 | 7300-att | att-7300) - cpu=m68k - vendor=att - os=sysv # maybe? - ;; -vax-dec) - cpu=vax - vendor=dec - os=ultrix # maybe? - ;; -vxworks68) - cpu=m68k - vendor=wrs - os=vxworks - ;; -vxworks960) - cpu=i960 - vendor=wrs - os=vxworks - ;; -xmp) - cpu=xmp - vendor=cray - os=unicos - ;; -# not an alias. parse what we expect to be a canonical name. -*) - cpu=`echo $1 | sed 's/-.*$//'` - - if [ "${cpu}" = "$1" ] ; then - # no vendor so this is an invalid name. - echo '***' No vendor: configuration \`$1\' not recognized 1>&2 - exit 1 - else - # parse out vendor - rest=`echo $1 | sed "s/${cpu}-//"` - vendor=`echo ${rest} | sed 's/-.*$//'` - - if [ "${vendor}" = "${rest}" ] ; then - # a missing os is acceptable - os=none - else - os=`echo ${rest} | sed "s/${vendor}-//"` - fi - fi - ;; -esac - -# At this point we should have three parts of a canonical name in cpu, -# vendor, and os. - -# verify that the cpu is known. - -case "${cpu}" in -none | vax | tahoe | i386 | i860 | m68k | m68000 | m88k | sparc \ - | ns32k | alliant | arm | c1 | c2 | mips | pyramid | tron \ - | a29k | romp | rs6000 | i960 | xmp | ymp | cray2 | 580 | h8300) - ;; - -# start-sanitize-v9 -sparc64) ;; -# end-sanitize-v9 - -*) - echo '***' Invalid cpu \`${cpu}\': configuration \`$1\' not recognized 1>&2 - exit 1 - ;; -esac - -# verify that the vendor is known. - -case "${vendor}" in - altos | amdahl | aout | apollo | att | bcs | bout |\ - cbm | convergent | convex | coff | cray | dec | encore |\ - gould | hitachi | intel | isi | hp | ibm | little | mips | motorola |\ - ncr | next | none | nyu | sco | sequent | sgi | sony | sun |\ - unicom | utek | wrs | bull ) ;; - -# start-sanitize-v9 -hal) ;; -# end-sanitize-v9 - -*) - echo '***' Invalid vendor \`${vendor}\': configuration \`$1\' not recognized 1>&2 - exit 1 - ;; -esac - -# verify that the os is known, if it exists. - -case "${os}" in -aix* | aout | bout | bsd* | coff | ctix* | dynix* | esix* | hpux* \ - | hds | irix* | isc* | kern | mach* | newsos* | nindy* | none \ - | osf* | sco* | sunos* | sysv* | ultrix* | unos* | v88r* \ - | vms* | vxworks* | sym[1-9]* | unicos* | uts | svr4 \ - | amigados) - ;; - -# start-sanitize-v9 -hal32 | hal64 | v7 | v9) ;; -# end-sanitize-v9 - -*) - echo '***' Invalid os \`${os}\': configuration \`$1\' not recognized 1>&2 - exit 1 - ;; -esac - -echo ${cpu}-${vendor}-${os} diff --git a/readline/configure b/readline/configure index 2f3603afb68..23efc6e10fe 100755 --- a/readline/configure +++ b/readline/configure @@ -1,23 +1,28 @@ +#!/bin/sh +# Please do not edit this file. It is generated automatically from +# configure.in and a configure template. +configdirs= + #!/bin/sh -# Configuration script +# Configuration script template # Copyright (C) 1988, 1990, 1991 Free Software Foundation, Inc. #This file is part of GNU. -# 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#GNU CC 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 1, or (at your option) +#any later version. + +#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 +#GNU General Public License for more details. + +#You should have received a copy of the GNU General Public License +#along with GNU CC; see the file COPYING. If not, write to +#the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. # $Id$ @@ -43,22 +48,16 @@ progname=$0 # clear some things potentially inherited from environment. ansi= -arguments=$* defaulttargets= destdir= fatal= hostsubdir= -Makefile=Makefile -Makefile_in=Makefile.in -norecursion= -recurring= +norecurse= removing= srcdir= srctrigger= target= targets= -commontargets= -configdirs= targetsubdir= template= verbose= @@ -66,32 +65,32 @@ verbose= for arg in $*; do case ${arg} in - -ansi | +a*) + -ansi | +ansi) ansi=true - clib=clib ;; -destdir=* | +destdir=* | +destdi=* | +destd=* | +dest=* | +des=* | +de=* | +d=*) destdir=`echo ${arg} | sed 's/[+-]d[a-z]*=//'` ;; + -forcesubdirs | +forcesubdirs | +forcesubdir | +forcesubdi | +forcesubd \ + | +forcesub | +forcesu | +forces | +force | +forc | +for | +fo | +f) + forcesubdirs=${arg} + ;; -languages=* | +languages=* | +language=* | +languag=* \ | +langua=* | +langu=* | +lang=* | +lan=* | +la=* \ | +l=*) languages="${languages} `echo ${arg} | sed 's/[+-]l[a-z]*=//'`" ;; - -gas | +g*) + -gas | +gas | +ga | +g) gas=yes ;; - -help | +h*) + -help | +h | +help) fatal=true ;; - -nfp | +nf*) + -nfp | +nfp | +nf | +n) nfp=yes ;; - -norecursion | +no*) - norecursion=true - ;; - -recurring | +recurring | +recurrin | +recurri | +recurr | +recur | +recu | +rec | +re) - recurring=true + -norecurse | +norecurse) + norecurse=true ;; -rm | +rm) removing=${arg} @@ -99,21 +98,18 @@ do # -srcdir=* | +srcdir=* | +srcdi=* | +srcd=* | +src=* | +sr=* | +s=*) # srcdir=`echo ${arg} | sed 's/[+-]s[a-z]*=//'` # ;; - -subdirs | +f* | +su*) - subdirs=${arg} - ;; - -target=* | +target=* | +targe=* | +targ=* | +tar=* | +ta=*) + -target=* | +target=* | +targe=* | +targ=* | +tar=* | +ta=* | +t=*) if [ -n "${targets}" ] ; then - subdirs="+subdirs" + forcesubdirs="+forcesubdirs" fi newtargets="${targets} `echo ${arg} | sed 's/[+-]t[a-z]*=//'`" targets="${newtargets}" ;; - -template=* | +template=* | +templat=* | +templa=* | +templ=* | +temp=* | +tem=* | +te=*) + -template=* | +template=*) template=`echo ${arg} | sed 's/[+-]template=//'` ;; - -v | -verbose | +v*) + +verbose | +verbos | +verbo | +verb | +ver | +ve | +v) verbose=${arg} ;; -* | +*) @@ -124,7 +120,7 @@ do ;; *) if [ -n "${hosts}" ] ; then - subdirs="+subdirs" + forcesubdirs="+forcesubdirs" fi newhosts="${hosts} ${arg}" @@ -135,6 +131,7 @@ done if [ -n "${verbose}" ] ; then echo `pwd`/configure $* + echo targets=\"${targets}\" fi # process host and target only if not rebuilding configure itself or removing. @@ -143,7 +140,7 @@ if [ -z "${template}" -a -z "${removing}" -a -z "${fatal}" ] ; then if [ -z "${hosts}" ] ; then (echo ; echo "configure: No HOST specified." ; - echo) 1>&2 + echo) 2>&1 fatal=true fi fi @@ -154,18 +151,18 @@ if [ -n "${fatal}" -o "${hosts}" = "help" ] ; then echo "Options: [defaults in brackets]" ; echo " +ansi configure w/ANSI library. [no ansi lib]" ; echo " +destdir=MYDIR configure for installation into MYDIR. [/usr/local]" ; - echo " +subdirs configure in subdirectories. [in source directories]" ; + echo " +forcesubdirs configure in subdirectories. [in source directories]" ; echo " +lang=LANG configure to build LANG. [gcc]" ; echo " +help print this message. [normal config]" ; echo " +gas configure the compilers for use with gas. [native as]" ; echo " +nfp configure the compilers default to soft floating point. [hard float]" ; - echo " +norecursion configure this directory only. [recurse]" ; + echo " +norecurse configure this directory only. [recurse]" ; echo " +rm remove this configuration. [build a configuration]" ; echo " +target=TARGET configure for TARGET. [TARGET = HOST]" ; echo " +template=TEM rebuild configure using TEM. [normal config]" ; echo ; echo "Where HOST and TARGET are something like \"vax\", \"sun3\", \"encore\", etc." ; - echo "Asking for more than one \"+target\" implies \"+subdirs\". Any other" ; + echo "Asking for more than one \"+target\" implies \"+forcesubdirs\". Any other" ; echo "options given will apply to all targets.") 1>&2 if [ -r config.status ] ; then @@ -190,7 +187,7 @@ srcname="the readline library" # are we rebuilding config itself? if [ -n "${template}" ] ; then if [ ! -r ${template} ] ; then - echo '***' "Can't find template ${template}." 1>&2 + echo "Can't find template ${template}." exit 1 fi @@ -204,42 +201,31 @@ if [ -n "${template}" ] ; then -e '/^#### configure.in per-target parts come in here.$/,/^## end of per-target part.$/c\ #### configure.in per-target parts come in here.\ ## end of per-target part.' \ - -e '/^#### configure.in post-target parts come in here.$/,/^## end of post-target part.$/c\ -#### configure.in post-target parts come in here.\ -## end of post-target part.' \ < ${template} > template.new if [ -r configure.in ] ; then if [ -z "`grep '^# per\-host:' configure.in`" ] ; then - echo '***' `pwd`/configure.in has no "per-host:" line. 1>&2 + echo `pwd`/configure.in has no "per-host:" line. exit 1 fi if [ -z "`grep '^# per\-target:' configure.in`" ] ; then - echo '***' `pwd`/configure.in has no "per-target:" line. 1>&2 + echo `pwd`/configure.in has no "per-target:" line. exit 1 fi - # split configure.in into common, per-host, per-target, - # and post-target parts. Post-target is optional. + # split configure.in into common, per-host, and per-target parts sed -e '/^# per\-host:/,$d' configure.in > configure.com sed -e '1,/^# per\-host:/d' -e '/^# per\-target:/,$d' configure.in > configure.hst - if grep -s '^# post-target:' configure.in ; then - sed -e '1,/^# per\-target:/d' -e '/^# post\-target:/,$d' configure.in > configure.tgt - sed -e '1,/^# post\-target:/d' configure.in > configure.pos - else - sed -e '1,/^# per\-target:/d' configure.in > configure.tgt - echo >configure.pos - fi + sed -e '1,/^# per\-target:/d' configure.in > configure.tgt # and insert them sed -e '/^#### configure.in common parts come in here.$/ r configure.com' \ -e '/^#### configure.in per\-host parts come in here.$/ r configure.hst' \ -e '/^#### configure.in per\-target parts come in here.$/ r configure.tgt' \ - -e '/^#### configure.in post\-target parts come in here.$/ r configure.pos' \ template.new > configure.new - rm -f configure.com configure.tgt configure.hst configure.pos + rm -f configure.com configure.tgt configure.hst else echo Warning: no configure.in in `pwd` cat ${template} >> configure @@ -249,30 +235,9 @@ if [ -n "${template}" ] ; then rm template.new # mv configure configure.old mv configure.new configure + echo Rebuilt configure in `pwd` - if [ -n "${verbose}" ] ; then - echo Rebuilt configure in `pwd` - fi - - # Now update config.sub from the template directory. - if echo "$template" | grep -s 'configure$' ; then - cp `echo "$template" | sed s/configure$/config.sub/` ./config.sub.new - # mv config.sub config.sub.old - mv config.sub.new config.sub - - if [ -n "${verbose}" ] ; then - echo Rebuilt config.sub in `pwd` - fi - fi - - if [ -z "${norecursion}" ] ; then - # If template is relative path, make it absolute for recurring. - if echo "${template}" | grep -s '^/' ; then - true - else - template=`pwd`/${template} - fi - + if [ -z "${norecurse}" ] ; then while [ -n "${configdirs}" ] ; do # set configdir to car of configdirs, configdirs to cdr of configdirs set ${configdirs}; configdir=$1; shift; configdirs=$* @@ -289,12 +254,10 @@ if [ -n "${template}" ] ; then (cd $i ; ./configure +template=${template} ${verbose}) else - echo Warning: No configure script in `pwd`/$i + echo No configure script in `pwd`/$i fi else - if [ -n "${verbose}" ] ; then - echo Warning: directory $i is missing. - fi + echo Warning: directory $i is missing. fi done done @@ -305,7 +268,7 @@ fi # some sanity checks on configure.in if [ -z "${srctrigger}" ] ; then - echo Warning: srctrigger not set in configure.in. `pwd` not configured. + echo srctrigger not set in configure.in. `pwd` not configured. exit 1 fi @@ -316,85 +279,58 @@ for host in ${hosts} ; do defaulttargets=true fi - host_alias=${host} - - result=`/bin/sh ./config.sub ${host}` - host_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'` - host_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'` - host_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'` - host=${host_cpu}-${host_vendor}-${host_os} - host_makefile_frag=config/hmake-${host} - #### configure.in per-host parts come in here. -case "${host_os}" in -sysv* | irix*) host_makefile_frag=config/hmake-sysv ;; -esac - ## end of per-host part. + for target in ${targets} ; do - target_alias=${target} - result=`/bin/sh ./config.sub ${target}` - target_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'` - target_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'` - target_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'` - target=${target_cpu}-${target_vendor}-${target_os} - target_makefile_frag=config/tmake-${target} + if [ -n "${verbose}" ] ; then + echo " "target=\"${target}\" + fi #### configure.in per-target parts come in here. ## end of per-target part. # Temporarily, we support only direct subdir builds. - hostsubdir=H-${host_alias} - targetsubdir=T-${target_alias} + hostsubdir=Host-${host} + targetsubdir=Target-${target} if [ -n "${removing}" ] ; then - if [ -n "${subdirs}" ] ; then + if [ -n "${forcesubdirs}" ] ; then if [ -d "${hostsubdir}" ] ; then rm -rf ${hostsubdir}/${targetsubdir} - if [ -z "`(ls ${hostsubdir}) 2>&1 | grep Target- | grep -v Target-independent`" ] ; then + if [ -z "`(ls ${hostsubdir}) 2>&1 | grep Target-`" ] ; then rm -rf ${hostsubdir} fi else echo Warning: no `pwd`/${hostsubdir} to remove. fi else - rm -f ${Makefile} config.status ${links} + rm -f Makefile config.status ${links} fi else - if [ -n "${subdirs}" ] ; then + if [ -n "${forcesubdirs}" ] ; then # check for existing status before allowing forced subdirs. - if [ -f ${Makefile} ] ; then - echo '***' "${Makefile} already exists in source directory. `pwd` not configured." 1>&2 + if [ -f Makefile ] ; then + echo "Makefile already exists in source directory. `pwd` not configured." exit 1 fi if [ ! -d ${hostsubdir} ] ; then mkdir ${hostsubdir} ; fi cd ${hostsubdir} - if [ ! -d ${targetsubdir} ] ; then - if [ -z "${commontargets}" ] ; then - mkdir ${targetsubdir} - else - if [ ! -d Target-independent ] ; then - mkdir Target-independent - fi - - ${symbolic_link} Target-independent ${targetsubdir} - fi # if target independent - fi # if no target dir yet - + if [ ! -d ${targetsubdir} ] ; then mkdir ${targetsubdir} ; fi cd ${targetsubdir} srcdir=../.. else # if not subdir builds, then make sure none exist. if [ -n "`(ls .) 2>&1 | grep Host-`" ] ; then - echo '***' "Configured subdirs exist. `pwd` not configured." 1>&2 + echo "Configured subdirs exist. `pwd` not configured." exit 1 fi fi @@ -410,12 +346,12 @@ esac if [ -n "${srctrigger}" -a ! -r ${srcdir}/${srctrigger} ] ; then if [ -z "${srcdirdefaulted}" ] ; then - echo '***' "${progname}: Can't find ${srcname} sources in `pwd`/${srcdir}" 1>&2 + echo "${progname}: Can't find ${srcname} sources in `pwd`/${srcdir}" 1>&2 else - echo '***' "${progname}: Can't find ${srcname} sources in `pwd`/. or `pwd`/.." 1>&2 + echo "${progname}: Can't find ${srcname} sources in `pwd`/. or `pwd`/.." 1>&2 fi - echo '***' \(At least ${srctrigger} is missing.\) 1>&2 + echo \(At least ${srctrigger} is missing.\) 1>&2 exit 1 fi @@ -429,8 +365,8 @@ esac set ${links}; link=$1; shift; links=$* if [ ! -r ${srcdir}/${file} ] ; then - echo '***' "${progname}: cannot create a link \"${link}\"," 1>&2 - echo '***' "since the file \"${file}\" does not exist." 1>&2 + echo "${progname}: cannot create a link \"${link}\"," 1>&2 + echo "since the file \"${file}\" does not exist." 1>&2 exit 1 fi @@ -440,13 +376,10 @@ esac ${symbolic_link} ${srcdir}/${file} ${link} 2>/dev/null || ${hard_link} ${srcdir}/${file} ${link} if [ ! -r ${link} ] ; then - echo '***' "${progname}: unable to link \"${link}\" to \"${srcdir}/${file}\"." 1>&2 + echo "${progname}: unable to link \"${link}\" to \"${srcdir}/${file}\"." 1>&2 exit 1 fi - - if [ -n "${verbose}" ] ; then - echo "Linked \"${link}\" to \"${srcdir}/${file}\"." - fi + echo "Linked \"${link}\" to \"${srcdir}/${file}\"." done # Create a .gdbinit file which runs the one in srcdir @@ -472,76 +405,76 @@ esac # Define macro CROSS_COMPILE in compilation if this is a cross-compiler. if [ "${host}" != "${target}" ] ; then - echo "CROSS=-DCROSS_COMPILE" > ${Makefile} - echo "ALL=start.encap" >> ${Makefile} + echo "CROSS=-DCROSS_COMPILE" > Makefile + echo "ALL=start.encap" >> Makefile else - echo "ALL=all.internal" > ${Makefile} + echo "ALL=all.internal" > Makefile fi # set target, host, VPATH - echo "host_alias = ${host_alias}" >> ${Makefile} - echo "host_cpu = ${host_cpu}" >> ${Makefile} - echo "host_vendor = ${host_vendor}" >> ${Makefile} - echo "host_os = ${host_os}" >> ${Makefile} - - echo "target_alias = ${target_alias}" >> ${Makefile} - echo "target_cpu = ${target_cpu}" >> ${Makefile} - echo "target_vendor = ${target_vendor}" >> ${Makefile} - echo "target_os = ${target_os}" >> ${Makefile} - - if [ -n "${subdirs}" ] ; then - echo "subdir = /${hostsubdir}/${targetsubdir}" >> ${Makefile} + echo "host = ${host}" >> Makefile + echo "target = ${target}" >> Makefile + + if [ -n "${forcesubdirs}" ] ; then + echo "subdir = /${hostsubdir}/${targetsubdir}" >> Makefile else - echo "subdir =" >> ${Makefile} + echo "subdir =" >> Makefile fi - # echo "workdir = `pwd`" >> ${Makefile} - echo "VPATH = ${srcdir}" >> ${Makefile} + # echo "workdir = `pwd`" >> Makefile + echo "VPATH = ${srcdir}" >> Makefile + + # add Makefile.in + cat ${srcdir}/Makefile.in >> Makefile - # add "Makefile.in" (or whatever it's called) - cat ${srcdir}/${Makefile_in} >> ${Makefile} + # and shake thoroughly. + if [ -z "${host_makefile_frag}" ] ; then + host_makefile_frag=config/hmake-${host} + fi + + if [ -z "${target_makefile_frag}" ] ; then + target_makefile_frag=config/tmake-${target} + fi # Conditionalize the makefile for this host. if [ -f ${srcdir}/${host_makefile_frag} ] ; then - (echo "host_makefile_frag = ${srcdir}/${host_makefile_frag}" ; - sed -e "/^####/ r ${srcdir}/${host_makefile_frag}" ${Makefile}) > Makefile.tem - mv Makefile.tem ${Makefile} + sed -e "/^####/ r ${srcdir}/${host_makefile_frag}" Makefile > Makefile.tem + mv Makefile.tem Makefile fi # Conditionalize the makefile for this target. if [ -f ${srcdir}/${target_makefile_frag} ] ; then - (echo "target_makefile_frag = ${srcdir}/${target_makefile_frag}" ; - sed -e "/^####/ r ${srcdir}/${target_makefile_frag}" ${Makefile}) > Makefile.tem - mv Makefile.tem ${Makefile} + sed -e "/^####/ r ${srcdir}/${target_makefile_frag}" Makefile > Makefile.tem + mv Makefile.tem Makefile fi # set srcdir - sed "s@^srcdir = \.@srcdir = ${srcdir}@" ${Makefile} > Makefile.tem - mv Makefile.tem ${Makefile} + sed "s@^srcdir = \.@srcdir = ${srcdir}@" Makefile > Makefile.tem + mv Makefile.tem Makefile # set destdir if [ -n "${destdir}" ] ; then - sed "s:^destdir =.*$:destdir = ${destdir}:" ${Makefile} > Makefile.tem - mv Makefile.tem ${Makefile} + sed "s:^destdir =.*$:destdir = ${destdir}:" Makefile > Makefile.tem + mv Makefile.tem Makefile fi + # Remove all formfeeds, since some Makes get confused by them. + sed "s/ //" Makefile >> Makefile.tem + mv Makefile.tem Makefile + # reset SUBDIRS - sed "s:^SUBDIRS =.*$:SUBDIRS = ${configdirs}:" ${Makefile} > Makefile.tem - mv Makefile.tem ${Makefile} + sed "s:^SUBDIRS =.*$:SUBDIRS = ${configdirs}:" Makefile > Makefile.tem + mv Makefile.tem Makefile # reset NONSUBDIRS - sed "s:^NONSUBDIRS =.*$:NONSUBDIRS = ${noconfigdirs}:" ${Makefile} > Makefile.tem - mv Makefile.tem ${Makefile} + sed "s:^NONSUBDIRS =.*$:NONSUBDIRS = ${noconfigdirs}:" Makefile > Makefile.tem + mv Makefile.tem Makefile using= if [ -f ${srcdir}/${host_makefile_frag} ] ; then using=" using \"${host_makefile_frag}\"" fi - # remove any form feeds. - sed -e "s/ //" ${Makefile} > Makefile.tem - mv Makefile.tem ${Makefile} - if [ -f ${srcdir}/${target_makefile_frag} ] ; then if [ -z "${using}" ] ; then andusing=" using \"${target_makefile_frag}\"" @@ -552,72 +485,164 @@ esac andusing=${using} fi - if [ -n "${verbose}" -o -z "${recurring}" ] ; then - echo "Created \"${Makefile}\"" in `pwd`${andusing}. - fi - -#### configure.in post-target parts come in here. - -## end of post-target part. + echo "Created \"Makefile\"" in `pwd`${andusing}. - # describe the chosen configuration in config.status. - # Make that file a shellscript which will reestablish - # the same configuration. Used in Makefiles to rebuild - # Makefiles. - - echo "#!/bin/sh -# ${srcname} was configured as follows: -${srcdir}/configure" ${arguments} `if [ -z "${norecursion}" ] ; then echo +norecursion ; else true ; fi` > config.status - chmod a+x config.status + if [ "${host}" = "${target}" ] ; then + echo "Links are now set up for use with a ${target}." \ + > config.status + # | tee ${srcdir}/config.status + else + echo "Links are now set up for host ${host} and target ${target}." \ + > config.status + # | tee ${srcdir}/config.status + fi originaldir=`pwd` cd ${srcdir} fi + done # for each target - # If there are subdirectories, then recurse. - if [ -z "${norecursion}" -a -n "${configdirs}" ] ; then - for configdir in ${configdirs} ; do - if [ -n "${verbose}" ] ; then - echo Configuring ${configdir}... - fi +# # Now build a Makefile for this host. +# if [ -n "${forcesubdirs}" ] ; then +# cd ${hostsubdir} +# cat > GNUmakefile << E!O!F +## Makefile generated by configure for host ${host}. +# +#%: +# for i in ${targets} ; do \ +# $(MAKE) -C Target-\$i \$@ +# +#all clean stage1 stage2 stage3 stage4etags tags TAGS +#E!O!F +# fi +done # for each host - if [ -d ${configdir} ] ; then - (cd ${configdir} ; - ./configure +recurring ${host_alias} +target=${target_alias} \ - ${verbose} ${subdirs} ${removing} +destdir=${destdir}) \ - | sed 's/^/ /' - else - if [ -n "${verbose}" ] ; then - echo Warning: directory \"${configdir}\" is missing. - fi - fi - done - fi - done # for each target +# If there are subdirectories, then recurse. - # Now build a Makefile for this host. - if [ -n "${subdirs}" -a ! -n "${removing}" ] ; then - cd ${hostsubdir} - cat > GNUmakefile << E!O!F -# Makefile generated by configure for host ${host_alias}. +if [ -n "${norecurse}" -o -z "${configdirs}" ] ; then exit 0 ; fi -ALL := $(shell ls -d Target-*) +# configdirs is not null +for configdir in ${configdirs} ; do + echo Configuring ${configdir}... + specifics= + commons= -%: - $(foreach subdir,$(ALL),$(MAKE) -C $(subdir) \$@ &&) true + if [ -n "${defaulttargets}" ] ; then + for host in ${hosts} ; do + if [ -d ${configdir}.${host} ] ; then + newspecifics="${specifics} ${host}" + specifics=${newspecifics} + else + newcommons="${commons} ${host}" + commons=${newcommons} + fi # if target specific + done # for each host + + if [ -n "${commons}" ] ; then + if [ -d ${configdir} ] ; then + (cd ${configdir} ; + ./configure ${commons} ${verbose} ${forcesubdirs} ${removing}) \ + | sed 's/^/ /' + else + echo Warning: directory \"${configdir}\" is missing. + fi + fi # if any common hosts + + if [ -n "${specifics}" ] ; then + for host in ${specifics} ; do + echo Configuring target specific directory ${configdir}.${host}... + (cd ${configdir}.${host} ; + ./configure ${host} ${verbose} ${forcesubdirs} ${removing}) \ + | sed 's/^/ /' + done # for host in specifics + fi # if there are any specifics + else -all: -E!O!F - cd .. - fi -done # for each host + for target in ${targets} ; do + if [ -d ${configdir}.${target} ] ; then + newspecifics="${specifics} ${target}" + specifics=${newspecifics} + else + newcommons="${commons} +target=${target}" + commons=${newcommons} + fi + + done # check for target specific dir override + + if [ -n "${verbose}" ] ; then + echo " "commons=\"${commons}\" + echo " "specifics=\"${specifics}\" + fi # if verbose + + if [ -n "${commons}" ] ; then + if [ -d ${configdir} ] ; then + (cd ${configdir} ; + ./configure ${hosts} ${verbose} ${forcesubdirs} ${removing} ${commons}) \ + | sed 's/^/ /' + else + echo Warning: directory \"${configdir}\" is missing. + fi + fi # if any commons + + if [ -n "${specifics}" ] ; then + for target in ${specifics} ; do + echo Configuring target specific directory ${configdir}.${target}... + (cd ${configdir}.${target} ; + ./configure ${hosts} ${verbose} ${forcesubdirs} ${removing} "+target=${target}") \ + | sed 's/^/ /' + done + fi # if any specifics + fi # not default targets +done exit 0 +# +# $Log$ +# Revision 1.1 1991/05/21 19:55:06 rich +# Initial revision +# +# Revision 1.12 1991/05/19 00:32:13 rich +# Changes to deal with missing subdirs gracefully, and changes dictated +# from dropping configure over gdb. +# +# Revision 1.4 1991/05/19 00:16:45 rich +# Configure for gdb. +# +# Revision 1.10 1991/05/04 00:58:38 rich +# Fix program name bug. +# +# Revision 1.9 1991/05/03 19:14:18 rich +# Changed getopt to libiberty, commented out an aborted attempt at host +# level Makefiles because it caused errors on +rm, add a warning for +# directories expected to be removed on +rm but that don't exist. +# +# Revision 1.8 1991/04/24 16:50:59 rich +# Three staging checkpoint. +# +# Revision 1.7 1991/04/17 01:34:47 rich +# Added getopt for binutils, fixed problem with host dependancies in +# configure.template. +# +# Revision 1.6 1991/04/16 00:18:44 rich +# Now handles multiple hosts and targets. +# +# Revision 1.5 1991/04/15 23:43:44 rich +# Now handles multiple hosts and targets. +# +# Revision 1.4 1991/04/13 02:11:03 rich +# Config cut 3. We now almost install a29k. +# +# Revision 1.3 1991/04/11 02:41:54 rich +# Cut 2 config. Subdirs. +# +# +# + # # Local Variables: # fill-column: 131 # End: # -# end of configure +# end of configure.template diff --git a/readline/configure.in b/readline/configure.in deleted file mode 100644 index 4006e70accc..00000000000 --- a/readline/configure.in +++ /dev/null @@ -1,29 +0,0 @@ -# This file is a shell script fragment that supplies the information -# necessary to tailor a template configure script into the configure -# script appropriate for this directory. For more information, check -# any existing configure script. - -configdirs= -srctrigger=readline.c -srcname="the readline library" -commontargets=true - -# per-host: - -files=sysdep-norm.h -links=sysdep.h - -case "${host_os}" in -m88kbcs | sysv* | irix*) - host_makefile_frag=config/hm-sysv - ;; - -aix*) - host_makefile_frag=config/hm-sysv - case "${host_arch}" in - rs6000) files=sysdep-aix.h - esac - ;; -esac - -# per-target: diff --git a/readline/display.c b/readline/display.c new file mode 100644 index 00000000000..c889318a3dc --- /dev/null +++ b/readline/display.c @@ -0,0 +1,801 @@ +/* display.c -- readline redisplay facility. */ + +/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc. + + This file is part of the GNU Readline Library, a library for + reading lines of text with interactive input and history editing. + + The GNU Readline Library 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 1, or + (at your option) any later version. + + The GNU Readline Library 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. + + The GNU General Public License is often shipped with GNU software, and + is generally kept in a file called COPYING or LICENSE. If you do not + have a copy of the license, write to the Free Software Foundation, + 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#include +#include + +/* System-specific feature definitions and include files. */ +#include "rldefs.h" + +/* Some standard library routines. */ +#include "readline.h" +#include "history.h" + +#if !defined (strrchr) +extern char *strrchr (); +#endif /* !strchr */ + +/* Global and pseudo-global variables and functions + imported from readline.c. */ +extern char *rl_prompt; +extern int readline_echoing_p; +extern char *term_clreol, *term_im, *term_ic, *term_ei, *term_DC; +/* Termcap variables. */ +extern char *term_up, *term_dc, *term_cr, *term_IC; +extern int screenheight, screenwidth, terminal_can_insert; + +extern void _rl_output_some_chars (); +extern void _rl_output_character_function (); + +extern int _rl_convert_meta_chars_to_ascii; +extern int _rl_horizontal_scroll_mode; +extern int _rl_mark_modified_lines; +extern int _rl_prefer_visible_bell; + +/* Pseudo-global functions (local to the readline library) exported + by this file. */ +void _rl_move_cursor_relative (), _rl_output_some_chars (); +void _rl_move_vert (); + +static void update_line (), clear_to_eol (); +static void delete_chars (), insert_some_chars (); + +extern char *xmalloc (), *xrealloc (); + +/* **************************************************************** */ +/* */ +/* Display stuff */ +/* */ +/* **************************************************************** */ + +/* This is the stuff that is hard for me. I never seem to write good + display routines in C. Let's see how I do this time. */ + +/* (PWP) Well... Good for a simple line updater, but totally ignores + the problems of input lines longer than the screen width. + + update_line and the code that calls it makes a multiple line, + automatically wrapping line update. Carefull attention needs + to be paid to the vertical position variables. + + handling of terminals with autowrap on (incl. DEC braindamage) + could be improved a bit. Right now I just cheat and decrement + screenwidth by one. */ + +/* Keep two buffers; one which reflects the current contents of the + screen, and the other to draw what we think the new contents should + be. Then compare the buffers, and make whatever changes to the + screen itself that we should. Finally, make the buffer that we + just drew into be the one which reflects the current contents of the + screen, and place the cursor where it belongs. + + Commands that want to can fix the display themselves, and then let + this function know that the display has been fixed by setting the + RL_DISPLAY_FIXED variable. This is good for efficiency. */ + +/* What YOU turn on when you have handled all redisplay yourself. */ +int rl_display_fixed = 0; + +/* The stuff that gets printed out before the actual text of the line. + This is usually pointing to rl_prompt. */ +char *rl_display_prompt = (char *)NULL; + +/* Pseudo-global variables declared here. */ +/* The visible cursor position. If you print some text, adjust this. */ +int _rl_last_c_pos = 0; +int _rl_last_v_pos = 0; + +/* Number of lines currently on screen minus 1. */ +int _rl_vis_botlin = 0; + +/* Variables used only in this file. */ +/* The last left edge of text that was displayed. This is used when + doing horizontal scrolling. It shifts in thirds of a screenwidth. */ +static int last_lmargin = 0; + +/* The line display buffers. One is the line currently displayed on + the screen. The other is the line about to be displayed. */ +static char *visible_line = (char *)NULL; +static char *invisible_line = (char *)NULL; + +/* A buffer for `modeline' messages. */ +static char msg_buf[128]; + +/* Non-zero forces the redisplay even if we thought it was unnecessary. */ +static int forced_display = 0; + +/* Default and initial buffer size. Can grow. */ +static int line_size = 1024; + +/* Basic redisplay algorithm. */ +rl_redisplay () +{ + register int in, out, c, linenum; + register char *line = invisible_line; + char *prompt_this_line; + int c_pos = 0; + int inv_botlin = 0; /* Number of lines in newly drawn buffer. */ + + if (!readline_echoing_p) + return; + + if (!rl_display_prompt) + rl_display_prompt = ""; + + if (!invisible_line) + { + visible_line = (char *)xmalloc (line_size); + invisible_line = (char *)xmalloc (line_size); + line = invisible_line; + for (in = 0; in < line_size; in++) + { + visible_line[in] = 0; + invisible_line[in] = 1; + } + rl_on_new_line (); + } + + /* Draw the line into the buffer. */ + c_pos = -1; + + /* Mark the line as modified or not. We only do this for history + lines. */ + out = 0; + if (_rl_mark_modified_lines && current_history () && rl_undo_list) + { + line[out++] = '*'; + line[out] = '\0'; + } + + /* If someone thought that the redisplay was handled, but the currently + visible line has a different modification state than the one about + to become visible, then correct the caller's misconception. */ + if (visible_line[0] != invisible_line[0]) + rl_display_fixed = 0; + + prompt_this_line = strrchr (rl_display_prompt, '\n'); + if (!prompt_this_line) + prompt_this_line = rl_display_prompt; + else + { + prompt_this_line++; + if (forced_display) + _rl_output_some_chars + (rl_display_prompt, prompt_this_line - rl_display_prompt); + } + + strncpy (line + out, prompt_this_line, strlen (prompt_this_line)); + out += strlen (prompt_this_line); + line[out] = '\0'; + + for (in = 0; in < rl_end; in++) + { + c = (unsigned char)rl_line_buffer[in]; + + if (out + 8 >= line_size) /* XXX - 8 for \t */ + { + line_size *= 2; + visible_line = (char *)xrealloc (visible_line, line_size); + invisible_line = (char *)xrealloc (invisible_line, line_size); + line = invisible_line; + } + + if (in == rl_point) + c_pos = out; + + if (META_CHAR (c)) + { + if (_rl_convert_meta_chars_to_ascii) + { + sprintf (line + out, "\\%o", c); + out += 4; + } + else + line[out++] = c; + } +#define DISPLAY_TABS +#if defined (DISPLAY_TABS) + else if (c == '\t') + { + register int newout = (out | (int)7) + 1; + while (out < newout) + line[out++] = ' '; + } +#endif + else if (c < ' ') + { + line[out++] = '^'; + line[out++] = UNCTRL (c); /* XXX was c ^ 0x40 */ + } + else if (c == 127) + { + line[out++] = '^'; + line[out++] = '?'; + } + else + line[out++] = c; + } + line[out] = '\0'; + if (c_pos < 0) + c_pos = out; + + /* PWP: now is when things get a bit hairy. The visible and invisible + line buffers are really multiple lines, which would wrap every + (screenwidth - 1) characters. Go through each in turn, finding + the changed region and updating it. The line order is top to bottom. */ + + /* If we can move the cursor up and down, then use multiple lines, + otherwise, let long lines display in a single terminal line, and + horizontally scroll it. */ + + if (!_rl_horizontal_scroll_mode && term_up && *term_up) + { + int total_screen_chars = (screenwidth * screenheight); + + if (!rl_display_fixed || forced_display) + { + forced_display = 0; + + /* If we have more than a screenful of material to display, then + only display a screenful. We should display the last screen, + not the first. I'll fix this in a minute. */ + if (out >= total_screen_chars) + out = total_screen_chars - 1; + + /* Number of screen lines to display. */ + inv_botlin = out / screenwidth; + + /* For each line in the buffer, do the updating display. */ + for (linenum = 0; linenum <= inv_botlin; linenum++) + update_line (linenum > _rl_vis_botlin ? "" + : &visible_line[linenum * screenwidth], + &invisible_line[linenum * screenwidth], + linenum); + + /* We may have deleted some lines. If so, clear the left over + blank ones at the bottom out. */ + if (_rl_vis_botlin > inv_botlin) + { + char *tt; + for (; linenum <= _rl_vis_botlin; linenum++) + { + tt = &visible_line[linenum * screenwidth]; + _rl_move_vert (linenum); + _rl_move_cursor_relative (0, tt); + clear_to_eol + ((linenum == _rl_vis_botlin) ? strlen (tt) : screenwidth); + } + } + _rl_vis_botlin = inv_botlin; + + /* Move the cursor where it should be. */ + _rl_move_vert (c_pos / screenwidth); + _rl_move_cursor_relative (c_pos % screenwidth, + &invisible_line[(c_pos / screenwidth) * screenwidth]); + } + } + else /* Do horizontal scrolling. */ + { + int lmargin; + + /* Always at top line. */ + _rl_last_v_pos = 0; + + /* If the display position of the cursor would be off the edge + of the screen, start the display of this line at an offset that + leaves the cursor on the screen. */ + if (c_pos - last_lmargin > screenwidth - 2) + lmargin = (c_pos / (screenwidth / 3) - 2) * (screenwidth / 3); + else if (c_pos - last_lmargin < 1) + lmargin = ((c_pos - 1) / (screenwidth / 3)) * (screenwidth / 3); + else + lmargin = last_lmargin; + + /* If the first character on the screen isn't the first character + in the display line, indicate this with a special character. */ + if (lmargin > 0) + line[lmargin] = '<'; + + if (lmargin + screenwidth < out) + line[lmargin + screenwidth - 1] = '>'; + + if (!rl_display_fixed || forced_display || lmargin != last_lmargin) + { + forced_display = 0; + update_line (&visible_line[last_lmargin], + &invisible_line[lmargin], 0); + + _rl_move_cursor_relative (c_pos - lmargin, &invisible_line[lmargin]); + last_lmargin = lmargin; + } + } + fflush (rl_outstream); + + /* Swap visible and non-visible lines. */ + { + char *temp = visible_line; + visible_line = invisible_line; + invisible_line = temp; + rl_display_fixed = 0; + } +} + +/* PWP: update_line() is based on finding the middle difference of each + line on the screen; vis: + + /old first difference + /beginning of line | /old last same /old EOL + v v v v +old: eddie> Oh, my little gruntle-buggy is to me, as lurgid as +new: eddie> Oh, my little buggy says to me, as lurgid as + ^ ^ ^ ^ + \beginning of line | \new last same \new end of line + \new first difference + + All are character pointers for the sake of speed. Special cases for + no differences, as well as for end of line additions must be handeled. + + Could be made even smarter, but this works well enough */ +static void +update_line (old, new, current_line) + register char *old, *new; + int current_line; +{ + register char *ofd, *ols, *oe, *nfd, *nls, *ne; + int lendiff, wsatend; + + /* Find first difference. */ + for (ofd = old, nfd = new; + (ofd - old < screenwidth) && *ofd && (*ofd == *nfd); + ofd++, nfd++) + ; + + /* Move to the end of the screen line. */ + for (oe = ofd; ((oe - old) < screenwidth) && *oe; oe++); + for (ne = nfd; ((ne - new) < screenwidth) && *ne; ne++); + + /* If no difference, continue to next line. */ + if (ofd == oe && nfd == ne) + return; + + wsatend = 1; /* flag for trailing whitespace */ + ols = oe - 1; /* find last same */ + nls = ne - 1; + while ((ols > ofd) && (nls > nfd) && (*ols == *nls)) + { + if (*ols != ' ') + wsatend = 0; + ols--; + nls--; + } + + if (wsatend) + { + ols = oe; + nls = ne; + } + else if (*ols != *nls) + { + if (*ols) /* don't step past the NUL */ + ols++; + if (*nls) + nls++; + } + + _rl_move_vert (current_line); + _rl_move_cursor_relative (ofd - old, old); + + /* if (len (new) > len (old)) */ + lendiff = (nls - nfd) - (ols - ofd); + + /* Insert (diff (len (old), len (new)) ch. */ + if (lendiff > 0) + { + if (terminal_can_insert) + { + /* Sometimes it is cheaper to print the characters rather than + use the terminal's capabilities. */ + if ((2 * (ne - nfd)) < lendiff && !term_IC) + { + _rl_output_some_chars (nfd, (ne - nfd)); + _rl_last_c_pos += (ne - nfd); + } + else + { + if (*ols) + { + insert_some_chars (nfd, lendiff); + _rl_last_c_pos += lendiff; + } + else + { + /* At the end of a line the characters do not have to + be "inserted". They can just be placed on the screen. */ + _rl_output_some_chars (nfd, lendiff); + _rl_last_c_pos += lendiff; + } + /* Copy (new) chars to screen from first diff to last match. */ + if (((nls - nfd) - lendiff) > 0) + { + _rl_output_some_chars (&nfd[lendiff], ((nls - nfd) - lendiff)); + _rl_last_c_pos += ((nls - nfd) - lendiff); + } + } + } + else + { /* cannot insert chars, write to EOL */ + _rl_output_some_chars (nfd, (ne - nfd)); + _rl_last_c_pos += (ne - nfd); + } + } + else /* Delete characters from line. */ + { + /* If possible and inexpensive to use terminal deletion, then do so. */ + if (term_dc && (2 * (ne - nfd)) >= (-lendiff)) + { + if (lendiff) + delete_chars (-lendiff); /* delete (diff) characters */ + + /* Copy (new) chars to screen from first diff to last match */ + if ((nls - nfd) > 0) + { + _rl_output_some_chars (nfd, (nls - nfd)); + _rl_last_c_pos += (nls - nfd); + } + } + /* Otherwise, print over the existing material. */ + else + { + _rl_output_some_chars (nfd, (ne - nfd)); + _rl_last_c_pos += (ne - nfd); + clear_to_eol ((oe - old) - (ne - new)); + } + } +} + +/* Tell the update routines that we have moved onto a new (empty) line. */ +rl_on_new_line () +{ + if (visible_line) + visible_line[0] = '\0'; + + _rl_last_c_pos = _rl_last_v_pos = 0; + _rl_vis_botlin = last_lmargin = 0; +} + +/* Actually update the display, period. */ +rl_forced_update_display () +{ + if (visible_line) + { + register char *temp = visible_line; + + while (*temp) *temp++ = '\0'; + } + rl_on_new_line (); + forced_display++; + rl_redisplay (); +} + +/* Move the cursor from _rl_last_c_pos to NEW, which are buffer indices. + DATA is the contents of the screen line of interest; i.e., where + the movement is being done. */ +void +_rl_move_cursor_relative (new, data) + int new; + char *data; +{ + register int i; + + /* It may be faster to output a CR, and then move forwards instead + of moving backwards. */ + if (new + 1 < _rl_last_c_pos - new) + { +#ifdef __MSDOS__ + putc('\r', rl_outstream); +#else + tputs (term_cr, 1, _rl_output_character_function); +#endif + _rl_last_c_pos = 0; + } + + if (_rl_last_c_pos == new) return; + + if (_rl_last_c_pos < new) + { + /* Move the cursor forward. We do it by printing the command + to move the cursor forward if there is one, else print that + portion of the output buffer again. Which is cheaper? */ + + /* The above comment is left here for posterity. It is faster + to print one character (non-control) than to print a control + sequence telling the terminal to move forward one character. + That kind of control is for people who don't know what the + data is underneath the cursor. */ +#if defined (HACK_TERMCAP_MOTION) + extern char *term_forward_char; + + if (term_forward_char) + for (i = _rl_last_c_pos; i < new; i++) + tputs (term_forward_char, 1, _rl_output_character_function); + else + for (i = _rl_last_c_pos; i < new; i++) + putc (data[i], rl_outstream); +#else + for (i = _rl_last_c_pos; i < new; i++) + putc (data[i], rl_outstream); +#endif /* HACK_TERMCAP_MOTION */ + } + else + backspace (_rl_last_c_pos - new); + _rl_last_c_pos = new; +} + +/* PWP: move the cursor up or down. */ +void +_rl_move_vert (to) + int to; +{ + register int delta, i; + + if (_rl_last_v_pos == to || to > screenheight) + return; + +#ifdef __GO32__ + { + int row, col; + ScreenGetCursor (&row, &col); + ScreenSetCursor ((row + to - _rl_last_v_pos), col); + } +#else /* __GO32__ */ + if ((delta = to - _rl_last_v_pos) > 0) + { + for (i = 0; i < delta; i++) + putc ('\n', rl_outstream); + tputs (term_cr, 1, _rl_output_character_function); + _rl_last_c_pos = 0; + } + else + { /* delta < 0 */ + if (term_up && *term_up) + for (i = 0; i < -delta; i++) + tputs (term_up, 1, _rl_output_character_function); + } +#endif /* !__GO32__ */ + _rl_last_v_pos = to; /* Now TO is here */ +} + +/* Physically print C on rl_outstream. This is for functions which know + how to optimize the display. */ +rl_show_char (c) + int c; +{ + if (META_CHAR (c) && _rl_convert_meta_chars_to_ascii) + { + fprintf (rl_outstream, "M-"); + c = UNMETA (c); + } + +#if defined (DISPLAY_TABS) + if (c < 32 && c != '\t') +#else + if (c < 32) +#endif /* !DISPLAY_TABS */ + { + + c += 64; + } + + putc (c, rl_outstream); + fflush (rl_outstream); +} + +int +rl_character_len (c, pos) + register int c, pos; +{ + if (META_CHAR (c)) + return (_rl_convert_meta_chars_to_ascii ? 4 : 1); + + if (c == '\t') + { +#if defined (DISPLAY_TABS) + return (((pos | (int)7) + 1) - pos); +#else + return (2); +#endif /* !DISPLAY_TABS */ + } + + if (isprint (c)) + return (1); + else + return (2); +} + +/* How to print things in the "echo-area". The prompt is treated as a + mini-modeline. */ + +#if defined (HAVE_VARARGS_H) +rl_message (va_alist) + va_dcl +{ + char *format; + va_list args; + + va_start (args); + format = va_arg (args, char *); + vsprintf (msg_buf, format, args); + va_end (args); + + rl_display_prompt = msg_buf; + rl_redisplay (); +} +#else /* !HAVE_VARARGS_H */ +rl_message (format, arg1, arg2) + char *format; +{ + sprintf (msg_buf, format, arg1, arg2); + rl_display_prompt = msg_buf; + rl_redisplay (); +} +#endif /* !HAVE_VARARGS_H */ + +/* How to clear things from the "echo-area". */ +rl_clear_message () +{ + rl_display_prompt = rl_prompt; + rl_redisplay (); +} + +rl_reset_line_state () +{ + rl_on_new_line (); + + rl_display_prompt = rl_prompt ? rl_prompt : ""; + forced_display = 1; +} + +/* Quick redisplay hack when erasing characters at the end of the line. */ +void +_rl_erase_at_end_of_line (l) + int l; +{ + register int i; + + backspace (l); + for (i = 0; i < l; i++) + putc (' ', rl_outstream); + backspace (l); + for (i = 0; i < l; i++) + visible_line[--_rl_last_c_pos] = '\0'; + rl_display_fixed++; +} + +/* Clear to the end of the line. COUNT is the minimum + number of character spaces to clear, */ +static void +clear_to_eol (count) + int count; +{ +#ifndef __GO32__ + if (term_clreol) + { + tputs (term_clreol, 1, _rl_output_character_function); + } + else +#endif /* !__GO32__ */ + { + register int i; + + /* Do one more character space. */ + count++; + + for (i = 0; i < count; i++) + putc (' ', rl_outstream); + + backspace (count); + } +} +/* Insert COUNT characters from STRING to the output stream. */ +static void +insert_some_chars (string, count) + char *string; + int count; +{ +#ifdef __GO32__ + int row, col, width; + char *row_start; + + ScreenGetCursor (&row, &col); + width = ScreenCols (); + row_start = ScreenPrimary + (row * width); + memcpy (row_start + col + count, row_start + col, width - col - count); + /* Place the text on the screen. */ + _rl_output_some_chars (string, count); +#else /* __GO32__ */ + /* If IC is defined, then we do not have to "enter" insert mode. */ + if (term_IC) + { + char *tgoto (), *buffer; + buffer = tgoto (term_IC, 0, count); + tputs (buffer, 1, _rl_output_character_function); + _rl_output_some_chars (string, count); + } + else + { + register int i; + + /* If we have to turn on insert-mode, then do so. */ + if (term_im && *term_im) + tputs (term_im, 1, _rl_output_character_function); + + /* If there is a special command for inserting characters, then + use that first to open up the space. */ + if (term_ic && *term_ic) + { + for (i = count; i--; ) + tputs (term_ic, 1, _rl_output_character_function); + } + + /* Print the text. */ + _rl_output_some_chars (string, count); + + /* If there is a string to turn off insert mode, we had best use + it now. */ + if (term_ei && *term_ei) + tputs (term_ei, 1, _rl_output_character_function); + } +#endif /* __GO32__ */ +} + +/* Delete COUNT characters from the display line. */ +static void +delete_chars (count) + int count; +{ +#if defined (__GO32__) + int row, col, width; + char *row_start; + + ScreenGetCursor (&row, &col); + width = ScreenCols (); + row_start = ScreenPrimary + (row * width); + memcpy (row_start + col, row_start + col + count, width - col - count); + memset (row_start + width - count, 0, count * 2); +#else /* !__GO32__ */ + if (count > screenwidth) + return; + + if (term_DC && *term_DC) + { + char *tgoto (), *buffer; + buffer = tgoto (term_DC, 0, count); + tputs (buffer, 1, _rl_output_character_function); + } + else + { + if (term_dc && *term_dc) + while (count--) + tputs (term_dc, 1, _rl_output_character_function); + } +#endif /* !__GO32__ */ +} diff --git a/readline/doc/Makefile b/readline/doc/Makefile deleted file mode 100644 index 6ea7eb8a8ec..00000000000 --- a/readline/doc/Makefile +++ /dev/null @@ -1,36 +0,0 @@ -# This makefile for Readline library documentation is in -*- text -*- mode. -# Emacs likes it that way. - -DVIOBJ = readline.dvi history.dvi -INFOBJ = readline.info history.info - -all: $(DVIOBJ) $(INFOBJ) - -readline.dvi: texindex rlman.texinfo rluser.texinfo rltech.texinfo - tex rlman.texinfo - ./texindex rlman.?? - tex rlman.texinfo - mv rlman.dvi readline.dvi - -history.dvi: texindex hist.texinfo hsuser.texinfo hstech.texinfo - tex hist.texinfo - tex hist.texinfo - mv hist.dvi history.dvi - -readline.info: rlman.texinfo rluser.texinfo rltech.texinfo - makeinfo rlman.texinfo - -history.info: hist.texinfo hsuser.texinfo hstech.texinfo - makeinfo hist.texinfo - -texindex: texindex.o - $(CC) -o $@ $(LDFLAGS) $(CFLAGS) $? -texindex.o: texindex.c - -clean: - rm -f *.aux *.cp *.fn *.ky *.log *.pg *.toc *.tp *.vr *.cps *.pgs \ - *.fns *.kys *.tps *.vrs *.o core texindex - -squeaky-clean: - rm -f *.aux *.cp *.fn *.ky *.log *.pg *.toc *.tp *.vr *.cps *.pgs \ - *.dvi *.info *.info-* *.fns *.kys *.tps *.vrs *.o core texindex diff --git a/readline/doc/Makefile.in b/readline/doc/Makefile.in new file mode 100644 index 00000000000..5e0d2d569e1 --- /dev/null +++ b/readline/doc/Makefile.in @@ -0,0 +1,94 @@ +## Copyright (C) 1993 Free Software Foundation, Inc. + +# Makefile for Readline documentation. + +# 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., 675 Mass Ave, Cambridge, MA 02139, USA. + +srcdir = . + +prefix = /usr/local + +infodir = $(prefix)/info + +SHELL = /bin/sh + +INSTALL = install -c +INSTALL_DATA = $(INSTALL) + +# where to find texinfo +TEXIDIR=$(srcdir)/../../texinfo + +# where to find makeinfo, preferably one designed for texinfo-2 +MAKEINFO=makeinfo + +# auxiliary program for sorting Texinfo indices +TEXINDEX=texindex + +# Don Knuth's TeX formatter +TEX=tex + +#### Host, target, and site specific Makefile fragments come in here. +### + +all: info dvi + +install: install-info + +info: history.info readline.info + +dvi: history.dvi readline.dvi + +install-info: info + -parent=`echo $(infodir)|sed -e 's@/[^/]*$$@@'`; \ + if [ -d $$parent ] ; then true ; else mkdir $$parent ; fi + -if [ -d $(infodir) ] ; then true ; else mkdir $(infodir) ; fi + for i in *.info* ; do \ + $(INSTALL_DATA) $$i $(infodir)/$$i ; \ + done + +history.info: hist.texinfo hsuser.texinfo hstech.texinfo + $(MAKEINFO) -I $(srcdir) -o ./history.info $(srcdir)/hist.texinfo + +history.dvi: hist.texinfo hsuser.texinfo hstech.texinfo $(TEXIDIR)/texinfo.tex + TEXINPUTS=${TEXIDIR}:$(srcdir):$$TEXINPUTS $(TEX) hist.texinfo + $(TEXINDEX) hist.?? + TEXINPUTS=${TEXIDIR}:$(srcdir):$$TEXINPUTS $(TEX) hist.texinfo + +readline.info: rlman.texinfo rluser.texinfo rltech.texinfo + $(MAKEINFO) -I $(srcdir) -o ./readline.info $(srcdir)/rlman.texinfo + +readline.dvi: rlman.texinfo rluser.texinfo rltech.texinfo + TEXINPUTS=${TEXIDIR}:$(srcdir):$$TEXINPUTS $(TEX) rlman.texinfo + $(TEXINDEX) rlman.?? + TEXINPUTS=${TEXIDIR}:$(srcdir):$$TEXINPUTS $(TEX) rlman.texinfo + +distclean: clean + rm -f Makefile config.status + +mostlyclean: clean + +realclean: distclean + +clean: clean-info clean-dvi + +clean-info: + rm -f history.info* readline.info* + +clean-dvi: + rm -f hist.?? hist.??? + rm -f rlman.?? rlman.??? + +Makefile: $(srcdir)/Makefile.in $(host_makefile_frag) $(target_makefile_frag) + $(SHELL) ./config.status diff --git a/readline/doc/texindex.c b/readline/doc/texindex.c deleted file mode 100644 index cb979da7afa..00000000000 --- a/readline/doc/texindex.c +++ /dev/null @@ -1,1606 +0,0 @@ -/* Prepare Tex index dribble output into an actual index. - Copyright (C) 1987 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include -#include -extern int errno; - -#ifdef VMS -#ifndef VAX11C -#define noshare -#endif - -#include -#include - -#define EXIT_SUCCESS ((1 << 28) | 1) -#define EXIT_FATAL ((1 << 28) | 4) -#define unlink delete -#define tell(fd) lseek(fd, 0L, 1) - -#else /* Not VMS */ - -#ifdef USG -#include -#include -#endif -#include - -#define EXIT_SUCCESS 0 -#define EXIT_FATAL 1 - -#endif /* Not VMS */ - - -#ifndef L_XTND -#define L_XTND 2 -#endif - -#ifdef VMS -extern noshare int sys_nerr; -extern noshare char *sys_errlist[]; -#else -extern int sys_nerr; -extern char *sys_errlist[]; -#endif - -/* When sorting in core, this structure describes one line - and the position and length of its first keyfield. */ - -struct lineinfo - { - char *text; /* The actual text of the line */ - union - { /* The start of the key (for textual comparison) */ - char *text; - long number; /* or the numeric value (for numeric comparison) */ - } key; - long keylen; /* Length of key field */ - }; - -/* This structure describes a field to use as a sort key */ - -struct keyfield - { - int startwords; /* # words to skip */ - int startchars; /* and # additional chars to skip, to start of field */ - int endwords; /* similar, from beg (or end) of line, to find end of field */ - int endchars; - char ignore_blanks; /* Ignore spaces and tabs within the field */ - char fold_case; /* Convert upper case to lower before comparing */ - char reverse; /* Compare in reverse order */ - char numeric; /* Parse text as an integer and compare the integers */ - char positional; /* Sort according to position within the file */ - char braced; /* Count balanced-braced groupings as fields */ - }; - -/* Vector of keyfields to use */ - -struct keyfield keyfields[3]; - -/* Number of keyfields stored in that vector. */ - -int num_keyfields = 3; - -/* Vector of input file names, terminated with a zero (null pointer) */ - -char **infiles; - -/* Vector of corresponding output file names, or zero meaning default it */ - -char **outfiles; - -/* Length of `infiles' */ - -int num_infiles; - -/* Pointer to the array of pointers to lines being sorted */ - -char **linearray; - -/* The allocated length of `linearray'. */ - -long nlines; - -/* Directory to use for temporary files. On Unix, it ends with a slash. */ - -char *tempdir; - -/* Start of filename to use for temporary files. */ - -char *tempbase; - -/* Number of last temporary file. */ - -int tempcount; - -/* Number of last temporary file already deleted. - Temporary files are deleted by `flush_tempfiles' in order of creation. */ - -int last_deleted_tempcount; - -/* During in-core sort, this points to the base of the data block - which contains all the lines of data. */ - -char *text_base; - -/* Additional command switches */ - -int keep_tempfiles; /* Nonzero means do not delete tempfiles -- for debugging */ - -/* Forward declarations of functions in this file */ - -void decode_command (); -void sort_in_core (); -void sort_offline (); -char **parsefile (); -char *find_field (); -char *find_pos (); -long find_value (); -char *find_braced_pos (); -char *find_braced_end (); -void writelines (); -int compare_full (); -long readline (); -int merge_files (); -int merge_direct (); -char *concat (); -char *maketempname (); -void flush_tempfiles (); -char *tempcopy (); - -extern char *mktemp (); - -#define MAX_IN_CORE_SORT 500000 - -int -main (argc, argv) - int argc; - char **argv; -{ - int i; - - tempcount = 0; - last_deleted_tempcount = 0; - - /* Describe the kind of sorting to do. */ - /* The first keyfield uses the first braced field and folds case */ - keyfields[0].braced = 1; - keyfields[0].fold_case = 1; - keyfields[0].endwords = -1; - keyfields[0].endchars = -1; - /* The second keyfield uses the second braced field, numerically */ - keyfields[1].braced = 1; - keyfields[1].numeric = 1; - keyfields[1].startwords = 1; - keyfields[1].endwords = -1; - keyfields[1].endchars = -1; - /* The third keyfield (which is ignored while discarding duplicates) - compares the whole line */ - keyfields[2].endwords = -1; - keyfields[2].endchars = -1; - - decode_command (argc, argv); - - tempbase = mktemp (concat ("txiXXXXXX", "", "")); - - /* Process input files completely, one by one. */ - - for (i = 0; i < num_infiles; i++) - { - int desc; - long ptr; - char *outfile; - char *p; - - desc = open (infiles[i], 0, 0); - if (desc < 0) pfatal_with_name (infiles[i]); - lseek (desc, 0, L_XTND); - ptr = tell (desc); - close (desc); - - outfile = outfiles[i]; - if (!outfile) - { - outfile = concat (infiles[i], "s", ""); - } - - if (ptr < MAX_IN_CORE_SORT) - /* Sort a small amount of data */ - sort_in_core (infiles[i], ptr, outfile); - else - sort_offline (infiles[i], ptr, outfile); - } - - flush_tempfiles (tempcount); - exit (EXIT_SUCCESS); -} - -/* This page decodes the command line arguments to set the parameter variables - and set up the vector of keyfields and the vector of input files */ - -void -decode_command (argc, argv) - int argc; - char **argv; -{ - int i; - char **ip; - char **op; - - /* Store default values into parameter variables */ - -#ifdef VMS - tempdir = "sys$scratch:"; -#else - tempdir = "/tmp/"; -#endif - - keep_tempfiles = 0; - - /* Allocate argc input files, which must be enough. */ - - infiles = (char **) xmalloc (argc * sizeof (char *)); - outfiles = (char **) xmalloc (argc * sizeof (char *)); - ip = infiles; - op = outfiles; - - /* First find all switches that control the default kind-of-sort */ - - for (i = 1; i < argc; i++) - { - int tem = classify_arg (argv[i]); - char c; - char *p; - - if (tem <= 0) - { - *ip++ = argv[i]; - *op++ = 0; - continue; - } - if (tem > 1) - { - if (i + 1 == argc) - fatal ("switch %s given with no argument following it", argv[i]); - else if (!strcmp (argv[i], "-T")) - tempdir = argv[i + 1]; - else if (!strcmp (argv[i], "-o")) - *(op - 1) = argv[i + 1]; - i += tem - 1; - continue; - } - - p = &argv[i][1]; - while (c = *p++) - switch (c) - { - case 'k': - keep_tempfiles = 1; - break; - - default: - fatal ("invalid command switch %c", c); - } - switchdone: ; - } - - /* Record number of keyfields, terminate list of filenames */ - - num_infiles = ip - infiles; - *ip = 0; -} - -/* Return 0 for an argument that is not a switch; - for a switch, return 1 plus the number of following arguments that the switch swallows. -*/ - -int -classify_arg (arg) - char *arg; -{ - if (!strcmp (arg, "-T") || !strcmp (arg, "-o")) - return 2; - if (arg[0] == '-') - return 1; - return 0; -} - -/* Create a name for a temporary file */ - -char * -maketempname (count) - int count; -{ - char tempsuffix[10]; - sprintf (tempsuffix, "%d", count); - return concat (tempdir, tempbase, tempsuffix); -} - -/* Delete all temporary files up to the specified count */ - -void -flush_tempfiles (to_count) - int to_count; -{ - if (keep_tempfiles) return; - while (last_deleted_tempcount < to_count) - unlink (maketempname (++last_deleted_tempcount)); -} - -/* Copy an input file into a temporary file, and return the temporary file name */ - -#define BUFSIZE 1024 - -char * -tempcopy (idesc) - int idesc; -{ - char *outfile = maketempname (++tempcount); - int odesc; - char buffer[BUFSIZE]; - - odesc = open (outfile, O_WRONLY | O_CREAT, 0666); - - if (odesc < 0) pfatal_with_name (outfile); - - while (1) - { - int nread = read (idesc, buffer, BUFSIZE); - write (odesc, buffer, nread); - if (!nread) break; - } - - close (odesc); - - return outfile; -} - -/* Compare two lines, provided as pointers to pointers to text, - according to the specified set of keyfields */ - -int -compare_full (line1, line2) - char **line1, **line2; -{ - int i; - - /* Compare using the first keyfield; - if that does not distinguish the lines, try the second keyfield; and so on. */ - - for (i = 0; i < num_keyfields; i++) - { - long length1, length2; - char *start1 = find_field (&keyfields[i], *line1, &length1); - char *start2 = find_field (&keyfields[i], *line2, &length2); - int tem = compare_field (&keyfields[i], start1, length1, *line1 - text_base, - start2, length2, *line2 - text_base); - if (tem) - { - if (keyfields[i].reverse) - return - tem; - return tem; - } - } - - return 0; /* Lines match exactly */ -} - -/* Compare two lines described by structures - in which the first keyfield is identified in advance. - For positional sorting, assumes that the order of the lines in core - reflects their nominal order. */ - -int -compare_prepared (line1, line2) - struct lineinfo *line1, *line2; -{ - int i; - int tem; - char *text1, *text2; - - /* Compare using the first keyfield, which has been found for us already */ - if (keyfields->positional) - { - if (line1->text - text_base > line2->text - text_base) - tem = 1; - else - tem = -1; - } - else if (keyfields->numeric) - tem = line1->key.number - line2->key.number; - else - tem = compare_field (keyfields, line1->key.text, line1->keylen, 0, line2->key.text, line2->keylen, 0); - if (tem) - { - if (keyfields->reverse) - return - tem; - return tem; - } - - text1 = line1->text; - text2 = line2->text; - - /* Compare using the second keyfield; - if that does not distinguish the lines, try the third keyfield; and so on. */ - - for (i = 1; i < num_keyfields; i++) - { - long length1, length2; - char *start1 = find_field (&keyfields[i], text1, &length1); - char *start2 = find_field (&keyfields[i], text2, &length2); - int tem = compare_field (&keyfields[i], start1, length1, text1 - text_base, - start2, length2, text2 - text_base); - if (tem) - { - if (keyfields[i].reverse) - return - tem; - return tem; - } - } - - return 0; /* Lines match exactly */ -} - -/* Like compare_full but more general. - You can pass any strings, and you can say how many keyfields to use. - `pos1' and `pos2' should indicate the nominal positional ordering of - the two lines in the input. */ - -int -compare_general (str1, str2, pos1, pos2, use_keyfields) - char *str1, *str2; - long pos1, pos2; - int use_keyfields; -{ - int i; - - /* Compare using the first keyfield; - if that does not distinguish the lines, try the second keyfield; and so on. */ - - for (i = 0; i < use_keyfields; i++) - { - long length1, length2; - char *start1 = find_field (&keyfields[i], str1, &length1); - char *start2 = find_field (&keyfields[i], str2, &length2); - int tem = compare_field (&keyfields[i], start1, length1, pos1, start2, length2, pos2); - if (tem) - { - if (keyfields[i].reverse) - return - tem; - return tem; - } - } - - return 0; /* Lines match exactly */ -} - -/* Find the start and length of a field in `str' according to `keyfield'. - A pointer to the starting character is returned, and the length - is stored into the int that `lengthptr' points to. */ - -char * -find_field (keyfield, str, lengthptr) - struct keyfield *keyfield; - char *str; - long *lengthptr; -{ - char *start; - char *end; - char *(*fun) (); - - if (keyfield->braced) fun = find_braced_pos; - else fun = find_pos; - - start = ( *fun )(str, keyfield->startwords, keyfield->startchars, - keyfield->ignore_blanks); - if (keyfield->endwords < 0) - { - if (keyfield->braced) - end = find_braced_end (start); - else - { - end = start; - while (*end && *end != '\n') end++; - } - } - else - { - end = ( *fun )(str, keyfield->endwords, keyfield->endchars, 0); - if (end - str < start - str) end = start; - } - *lengthptr = end - start; - return start; -} - -/* Find a pointer to a specified place within `str', - skipping (from the beginning) `words' words and then `chars' chars. - If `ignore_blanks' is nonzero, we skip all blanks - after finding the specified word. */ - -char * -find_pos (str, words, chars, ignore_blanks) - char *str; - int words, chars; - int ignore_blanks; -{ - int i; - char *p = str; - - for (i = 0; i < words; i++) - { - char c; - /* Find next bunch of nonblanks and skip them. */ - while ((c = *p) == ' ' || c == '\t') p++; - while ((c = *p) && c != '\n' && !(c == ' ' || c == '\t')) p++; - if (!*p || *p == '\n') return p; - } - - while (*p == ' ' || *p == '\t') p++; - - for (i = 0; i < chars; i++) - { - if (!*p || *p == '\n') break; - p++; - } - return p; -} - -/* Like find_pos but assumes that each field is surrounded by braces - and that braces within fields are balanced. */ - -char * -find_braced_pos (str, words, chars, ignore_blanks) - char *str; - int words, chars; - int ignore_blanks; -{ - int i; - int bracelevel; - char *p = str; - char c; - - for (i = 0; i < words; i++) - { - bracelevel = 1; - while ((c = *p++) != '{' && c != '\n' && c); - if (c != '{') - return p - 1; - while (bracelevel) - { - c = *p++; - if (c == '{') bracelevel++; - if (c == '}') bracelevel--; -#if 0 - if (c == '\\' || c == '@') c = *p++; /* \ quotes braces and \ */ -#endif - if (c == 0 || c == '\n') return p-1; - } - } - - while ((c = *p++) != '{' && c != '\n' && c); - - if (c != '{') - return p-1; - - if (ignore_blanks) - while ((c = *p) == ' ' || c == '\t') p++; - - for (i = 0; i < chars; i++) - { - if (!*p || *p == '\n') break; - p++; - } - return p; -} - -/* Find the end of the balanced-brace field which starts at `str'. - The position returned is just before the closing brace. */ - -char * -find_braced_end (str) - char *str; -{ - int bracelevel; - char *p = str; - char c; - - bracelevel = 1; - while (bracelevel) - { - c = *p++; - if (c == '{') bracelevel++; - if (c == '}') bracelevel--; -#if 0 - if (c == '\\' || c == '@') c = *p++; -#endif - if (c == 0 || c == '\n') return p-1; - } - return p - 1; -} - -long -find_value (start, length) - char *start; - long length; -{ - while (length != 0L) { - if (isdigit(*start)) - return atol(start); - length--; - start++; - } - return 0l; -} - -/* Vector used to translate characters for comparison. - This is how we make all alphanumerics follow all else, - and ignore case in the first sorting. */ -int char_order[256]; - -init_char_order () -{ - int i; - for (i = 1; i < 256; i++) - char_order[i] = i; - - for (i = '0'; i <= '9'; i++) - char_order[i] += 512; - - for (i = 'a'; i <= 'z'; i++) { - char_order[i] = 512 + i; - char_order[i + 'A' - 'a'] = 512 + i; - } -} - -/* Compare two fields (each specified as a start pointer and a character count) - according to `keyfield'. The sign of the value reports the relation between the fields */ - -int -compare_field (keyfield, start1, length1, pos1, start2, length2, pos2) - struct keyfield *keyfield; - char *start1; - long length1; - long pos1; - char *start2; - long length2; - long pos2; -{ - if (keyfields->positional) - { - if (pos1 > pos2) - return 1; - else - return -1; - } - if (keyfield->numeric) - { - long value = find_value (start1, length1) - find_value (start2, length2); - if (value > 0) return 1; - if (value < 0) return -1; - return 0; - } - else - { - char *p1 = start1; - char *p2 = start2; - char *e1 = start1 + length1; - char *e2 = start2 + length2; - - int fold_case = keyfield->fold_case; - - while (1) - { - int c1, c2; - - if (p1 == e1) c1 = 0; - else c1 = *p1++; - if (p2 == e2) c2 = 0; - else c2 = *p2++; - - if (char_order[c1] != char_order[c2]) - return char_order[c1] - char_order[c2]; - if (!c1) break; - } - - /* Strings are equal except possibly for case. */ - p1 = start1; - p2 = start2; - while (1) - { - int c1, c2; - - if (p1 == e1) c1 = 0; - else c1 = *p1++; - if (p2 == e2) c2 = 0; - else c2 = *p2++; - - if (c1 != c2) - /* Reverse sign here so upper case comes out last. */ - return c2 - c1; - if (!c1) break; - } - - return 0; - } -} - -/* A `struct linebuffer' is a structure which holds a line of text. - `readline' reads a line from a stream into a linebuffer - and works regardless of the length of the line. */ - -struct linebuffer - { - long size; - char *buffer; - }; - -/* Initialize a linebuffer for use */ - -void -initbuffer (linebuffer) - struct linebuffer *linebuffer; -{ - linebuffer->size = 200; - linebuffer->buffer = (char *) xmalloc (200); -} - -/* Read a line of text from `stream' into `linebuffer'. - Return the length of the line. */ - -long -readline (linebuffer, stream) - struct linebuffer *linebuffer; - FILE *stream; -{ - char *buffer = linebuffer->buffer; - char *p = linebuffer->buffer; - char *end = p + linebuffer->size; - - while (1) - { - int c = getc (stream); - if (p == end) - { - buffer = (char *) xrealloc (buffer, linebuffer->size *= 2); - p += buffer - linebuffer->buffer; - end += buffer - linebuffer->buffer; - linebuffer->buffer = buffer; - } - if (c < 0 || c == '\n') - { - *p = 0; - break; - } - *p++ = c; - } - - return p - buffer; -} - -/* Sort an input file too big to sort in core. */ - -void -sort_offline (infile, nfiles, total, outfile) - char *infile; - long total; - char *outfile; -{ - int ntemps = 2 * (total + MAX_IN_CORE_SORT - 1) / MAX_IN_CORE_SORT; /* More than enough */ - char **tempfiles = (char **) xmalloc (ntemps * sizeof (char *)); - FILE *istream = fopen (infile, "r"); - int i; - struct linebuffer lb; - long linelength; - int failure = 0; - - initbuffer (&lb); - - /* Read in one line of input data. */ - - linelength = readline (&lb, istream); - - if (lb.buffer[0] != '\\' && lb.buffer[0] != '@') - { - error ("%s: not a texinfo index file", infile); - return; - } - - /* Split up the input into `ntemps' temporary files, or maybe fewer, - and put the new files' names into `tempfiles' */ - - for (i = 0; i < ntemps; i++) - { - char *outname = maketempname (++tempcount); - FILE *ostream = fopen (outname, "w"); - long tempsize = 0; - - if (!ostream) pfatal_with_name (outname); - tempfiles[i] = outname; - - /* Copy lines into this temp file as long as it does not make file "too big" - or until there are no more lines. */ - - while (tempsize + linelength + 1 <= MAX_IN_CORE_SORT) - { - tempsize += linelength + 1; - fputs (lb.buffer, ostream); - putc ('\n', ostream); - - /* Read another line of input data. */ - - linelength = readline (&lb, istream); - if (!linelength && feof (istream)) break; - - if (lb.buffer[0] != '\\' && lb.buffer[0] != '@') - { - error ("%s: not a texinfo index file", infile); - failure = 1; - goto fail; - } - } - fclose (ostream); - if (feof (istream)) break; - } - - free (lb.buffer); - - fail: - /* Record number of temp files we actually needed. */ - - ntemps = i; - - /* Sort each tempfile into another tempfile. - Delete the first set of tempfiles and put the names of the second into `tempfiles' */ - - for (i = 0; i < ntemps; i++) - { - char *newtemp = maketempname (++tempcount); - sort_in_core (&tempfiles[i], MAX_IN_CORE_SORT, newtemp); - if (!keep_tempfiles) - unlink (tempfiles[i]); - tempfiles[i] = newtemp; - } - - if (failure) - return; - - /* Merge the tempfiles together and indexify */ - - merge_files (tempfiles, ntemps, outfile); -} - -/* Sort `infile', whose size is `total', - assuming that is small enough to be done in-core, - then indexify it and send the output to `outfile' (or to stdout). */ - -void -sort_in_core (infile, total, outfile) - char *infile; - long total; - char *outfile; -{ - char **nextline; - char *data = (char *) xmalloc (total + 1); - char *file_data; - long file_size; - int i; - FILE *ostream = stdout; - struct lineinfo *lineinfo; - - /* Read the contents of the file into the moby array `data' */ - - int desc = open (infile, 0, 0); - - if (desc < 0) - fatal ("failure reopening %s", infile); - for (file_size = 0; ; ) - { - if ((i = read (desc, data + file_size, total - file_size)) <= 0) - break; - file_size += i; - } - file_data = data; - data[file_size] = 0; - - close (desc); - - if (file_size > 0 && data[0] != '\\' && data[0] != '@') - { - error ("%s: not a texinfo index file", infile); - return; - } - - init_char_order (); - - /* Sort routines want to know this address */ - - text_base = data; - - /* Create the array of pointers to lines, with a default size frequently enough. */ - - nlines = total / 50; - if (!nlines) nlines = 2; - linearray = (char **) xmalloc (nlines * sizeof (char *)); - - /* `nextline' points to the next free slot in this array. - `nlines' is the allocated size. */ - - nextline = linearray; - - /* Parse the input file's data, and make entries for the lines. */ - - nextline = parsefile (infile, nextline, file_data, file_size); - if (nextline == 0) - { - error ("%s: not a texinfo index file", infile); - return; - } - - /* Sort the lines */ - - /* If we have enough space, find the first keyfield of each line in advance. - Make a `struct lineinfo' for each line, which records the keyfield - as well as the line, and sort them. */ - - lineinfo = (struct lineinfo *) malloc ((nextline - linearray) * sizeof (struct lineinfo)); - - if (lineinfo) - { - struct lineinfo *lp; - char **p; - - for (lp = lineinfo, p = linearray; p != nextline; lp++, p++) - { - lp->text = *p; - lp->key.text = find_field (keyfields, *p, &lp->keylen); - if (keyfields->numeric) - lp->key.number = find_value (lp->key.text, lp->keylen); - } - - qsort (lineinfo, nextline - linearray, sizeof (struct lineinfo), compare_prepared); - - for (lp = lineinfo, p = linearray; p != nextline; lp++, p++) - *p = lp->text; - - free (lineinfo); - } - else - qsort (linearray, nextline - linearray, sizeof (char *), compare_full); - - /* Open the output file */ - - if (outfile) - { - ostream = fopen (outfile, "w"); - if (!ostream) - pfatal_with_name (outfile); - } - - writelines (linearray, nextline - linearray, ostream); - if (outfile) fclose (ostream); - - free (linearray); - free (data); -} - -/* Parse an input string in core into lines. - DATA is the input string, and SIZE is its length. - Data goes in LINEARRAY starting at NEXTLINE. - The value returned is the first entry in LINEARRAY still unused. - Value 0 means input file contents are invalid. */ - -char ** -parsefile (filename, nextline, data, size) - char *filename; - char **nextline; - char *data; - long size; -{ - char *p, *end; - char **line = nextline; - - p = data; - end = p + size; - *end = 0; - - while (p != end) - { - if (p[0] != '\\' && p[0] != '@') - return 0; - - *line = p; - while (*p && *p != '\n') p++; - if (p != end) p++; - - line++; - if (line == linearray + nlines) - { - char **old = linearray; - linearray = (char **) xrealloc (linearray, sizeof (char *) * (nlines *= 4)); - line += linearray - old; - } - } - - return line; -} - -/* Indexification is a filter applied to the sorted lines - as they are being written to the output file. - Multiple entries for the same name, with different page numbers, - get combined into a single entry with multiple page numbers. - The first braced field, which is used for sorting, is discarded. - However, its first character is examined, folded to lower case, - and if it is different from that in the previous line fed to us - a \initial line is written with one argument, the new initial. - - If an entry has four braced fields, then the second and third - constitute primary and secondary names. - In this case, each change of primary name - generates a \primary line which contains only the primary name, - and in between these are \secondary lines which contain - just a secondary name and page numbers. -*/ - -/* The last primary name we wrote a \primary entry for. - If only one level of indexing is being done, this is the last name seen */ -char *lastprimary; -int lastprimarylength; /* Length of storage allocated for lastprimary */ - -/* Similar, for the secondary name. */ -char *lastsecondary; -int lastsecondarylength; - -/* Zero if we are not in the middle of writing an entry. - One if we have written the beginning of an entry but have not - yet written any page numbers into it. - Greater than one if we have written the beginning of an entry - plus at least one page number. */ -int pending; - -/* The initial (for sorting purposes) of the last primary entry written. - When this changes, a \initial {c} line is written */ - -char * lastinitial; - -int lastinitiallength; - -/* When we need a string of length 1 for the value of lastinitial, - store it here. */ - -char lastinitial1[2]; - -/* Initialize static storage for writing an index */ - -void -init_index () -{ - pending = 0; - lastinitial = lastinitial1; - lastinitial1[0] = 0; - lastinitial1[1] = 0; - lastinitiallength = 0; - lastprimarylength = 100; - lastprimary = (char *) xmalloc (lastprimarylength + 1); - bzero (lastprimary, lastprimarylength + 1); - lastsecondarylength = 100; - lastsecondary = (char *) xmalloc (lastsecondarylength + 1); - bzero (lastsecondary, lastsecondarylength + 1); -} - -/* Indexify. Merge entries for the same name, - insert headers for each initial character, etc. */ - -indexify (line, ostream) - char *line; - FILE *ostream; -{ - char *primary, *secondary, *pagenumber; - int primarylength, secondarylength, pagelength; - int len = strlen (line); - int nosecondary; - int initiallength; - char *initial; - char initial1[2]; - register char *p; - - /* First, analyze the parts of the entry fed to us this time */ - - p = find_braced_pos (line, 0, 0, 0); - if (*p == '{') - { - initial = p; - /* Get length of inner pair of braces starting at p, - including that inner pair of braces. */ - initiallength = find_braced_end (p + 1) + 1 - p; - } - else - { - initial = initial1; - initial1[0] = *p; - initial1[1] = 0; - initiallength = 1; - - if (initial1[0] >= 'a' && initial1[0] <= 'z') - initial1[0] -= 040; - } - - pagenumber = find_braced_pos (line, 1, 0, 0); - pagelength = find_braced_end (pagenumber) - pagenumber; - if (pagelength == 0) - abort (); - - primary = find_braced_pos (line, 2, 0, 0); - primarylength = find_braced_end (primary) - primary; - - secondary = find_braced_pos (line, 3, 0, 0); - nosecondary = !*secondary; - if (!nosecondary) - secondarylength = find_braced_end (secondary) - secondary; - - /* If the primary is different from before, make a new primary entry */ - if (strncmp (primary, lastprimary, primarylength)) - { - /* Close off current secondary entry first, if one is open */ - if (pending) - { - fputs ("}\n", ostream); - pending = 0; - } - - /* If this primary has a different initial, include an entry for the initial */ - if (initiallength != lastinitiallength || - strncmp (initial, lastinitial, initiallength)) - { - fprintf (ostream, "\\initial {"); - fwrite (initial, 1, initiallength, ostream); - fprintf (ostream, "}\n", initial); - if (initial == initial1) - { - lastinitial = lastinitial1; - *lastinitial1 = *initial1; - } - else - { - lastinitial = initial; - } - lastinitiallength = initiallength; - } - - /* Make the entry for the primary. */ - if (nosecondary) - fputs ("\\entry {", ostream); - else - fputs ("\\primary {", ostream); - fwrite (primary, primarylength, 1, ostream); - if (nosecondary) - { - fputs ("}{", ostream); - pending = 1; - } - else - fputs ("}\n", ostream); - - /* Record name of most recent primary */ - if (lastprimarylength < primarylength) - { - lastprimarylength = primarylength + 100; - lastprimary = (char *) xrealloc (lastprimary, - 1 + lastprimarylength); - } - strncpy (lastprimary, primary, primarylength); - lastprimary[primarylength] = 0; - - /* There is no current secondary within this primary, now */ - lastsecondary[0] = 0; - } - - /* Should not have an entry with no subtopic following one with a subtopic */ - - if (nosecondary && *lastsecondary) - error ("entry %s follows an entry with a secondary name", line); - - /* Start a new secondary entry if necessary */ - if (!nosecondary && strncmp (secondary, lastsecondary, secondarylength)) - { - if (pending) - { - fputs ("}\n", ostream); - pending = 0; - } - - /* Write the entry for the secondary. */ - fputs ("\\secondary {", ostream); - fwrite (secondary, secondarylength, 1, ostream); - fputs ("}{", ostream); - pending = 1; - - /* Record name of most recent secondary */ - if (lastsecondarylength < secondarylength) - { - lastsecondarylength = secondarylength + 100; - lastsecondary = (char *) xrealloc (lastsecondary, - 1 + lastsecondarylength); - } - strncpy (lastsecondary, secondary, secondarylength); - lastsecondary[secondarylength] = 0; - } - - /* Here to add one more page number to the current entry */ - if (pending++ != 1) - fputs (", ", ostream); /* Punctuate first, if this is not the first */ - fwrite (pagenumber, pagelength, 1, ostream); -} - -/* Close out any unfinished output entry */ - -void -finish_index (ostream) - FILE *ostream; -{ - if (pending) - fputs ("}\n", ostream); - free (lastprimary); - free (lastsecondary); -} - -/* Copy the lines in the sorted order. - Each line is copied out of the input file it was found in. */ - -void -writelines (linearray, nlines, ostream) - char **linearray; - int nlines; - FILE *ostream; -{ - char **stop_line = linearray + nlines; - char **next_line; - - init_index (); - - /* Output the text of the lines, and free the buffer space */ - - for (next_line = linearray; next_line != stop_line; next_line++) - { - /* If -u was specified, output the line only if distinct from previous one. */ - if (next_line == linearray - /* Compare previous line with this one, using only the explicitly specd keyfields */ - || compare_general (*(next_line - 1), *next_line, 0L, 0L, num_keyfields - 1)) - { - char *p = *next_line; - char c; - while ((c = *p++) && c != '\n'); - *(p-1) = 0; - indexify (*next_line, ostream); - } - } - - finish_index (ostream); -} - -/* Assume (and optionally verify) that each input file is sorted; - merge them and output the result. - Returns nonzero if any input file fails to be sorted. - - This is the high-level interface that can handle an unlimited number of files. */ - -#define MAX_DIRECT_MERGE 10 - -int -merge_files (infiles, nfiles, outfile) - char **infiles; - int nfiles; - char *outfile; -{ - char **tempfiles; - int ntemps; - int i; - int value = 0; - int start_tempcount = tempcount; - - if (nfiles <= MAX_DIRECT_MERGE) - return merge_direct (infiles, nfiles, outfile); - - /* Merge groups of MAX_DIRECT_MERGE input files at a time, - making a temporary file to hold each group's result. */ - - ntemps = (nfiles + MAX_DIRECT_MERGE - 1) / MAX_DIRECT_MERGE; - tempfiles = (char **) xmalloc (ntemps * sizeof (char *)); - for (i = 0; i < ntemps; i++) - { - int nf = MAX_DIRECT_MERGE; - if (i + 1 == ntemps) - nf = nfiles - i * MAX_DIRECT_MERGE; - tempfiles[i] = maketempname (++tempcount); - value |= merge_direct (&infiles[i * MAX_DIRECT_MERGE], nf, tempfiles[i]); - } - - /* All temporary files that existed before are no longer needed - since their contents have been merged into our new tempfiles. - So delete them. */ - flush_tempfiles (start_tempcount); - - /* Now merge the temporary files we created. */ - - merge_files (tempfiles, ntemps, outfile); - - free (tempfiles); - - return value; -} - -/* Assume (and optionally verify) that each input file is sorted; - merge them and output the result. - Returns nonzero if any input file fails to be sorted. - - This version of merging will not work if the number of - input files gets too high. Higher level functions - use it only with a bounded number of input files. */ - -int -merge_direct (infiles, nfiles, outfile) - char **infiles; - int nfiles; - char *outfile; -{ - char **ip = infiles; - struct linebuffer *lb1, *lb2; - struct linebuffer **thisline, **prevline; - FILE **streams; - int i; - int nleft; - int lossage = 0; - int *file_lossage; - struct linebuffer *prev_out = 0; - FILE *ostream = stdout; - - if (outfile) - { - ostream = fopen (outfile, "w"); - } - if (!ostream) pfatal_with_name (outfile); - - init_index (); - - if (nfiles == 0) - { - if (outfile) - fclose (ostream); - return 0; - } - - /* For each file, make two line buffers. - Also, for each file, there is an element of `thisline' - which points at any time to one of the file's two buffers, - and an element of `prevline' which points to the other buffer. - `thisline' is supposed to point to the next available line from the file, - while `prevline' holds the last file line used, - which is remembered so that we can verify that the file is properly sorted. */ - - /* lb1 and lb2 contain one buffer each per file */ - lb1 = (struct linebuffer *) xmalloc (nfiles * sizeof (struct linebuffer)); - lb2 = (struct linebuffer *) xmalloc (nfiles * sizeof (struct linebuffer)); - - /* thisline[i] points to the linebuffer holding the next available line in file i, - or is zero if there are no lines left in that file. */ - thisline = (struct linebuffer **) xmalloc (nfiles * sizeof (struct linebuffer *)); - /* prevline[i] points to the linebuffer holding the last used line from file i. - This is just for verifying that file i is properly sorted. */ - prevline = (struct linebuffer **) xmalloc (nfiles * sizeof (struct linebuffer *)); - /* streams[i] holds the input stream for file i. */ - streams = (FILE **) xmalloc (nfiles * sizeof (FILE *)); - /* file_lossage[i] is nonzero if we already know file i is not properly sorted. */ - file_lossage = (int *) xmalloc (nfiles * sizeof (int)); - - /* Allocate and initialize all that storage */ - - for (i = 0; i < nfiles; i++) - { - initbuffer (&lb1[i]); - initbuffer (&lb2[i]); - thisline[i] = &lb1[i]; - prevline[i] = &lb2[i]; - file_lossage[i] = 0; - streams[i] = fopen (infiles[i], "r"); - if (!streams[i]) - pfatal_with_name (infiles[i]); - - readline (thisline[i], streams[i]); - } - - /* Keep count of number of files not at eof */ - nleft = nfiles; - - while (nleft) - { - struct linebuffer *best = 0; - struct linebuffer *exch; - int bestfile = -1; - int i; - - /* Look at the next avail line of each file; choose the least one. */ - - for (i = 0; i < nfiles; i++) - { - if (thisline[i] && - (!best || - 0 < compare_general (best->buffer, thisline[i]->buffer, - (long) bestfile, (long) i, num_keyfields))) - { - best = thisline[i]; - bestfile = i; - } - } - - /* Output that line, unless it matches the previous one and we don't want duplicates */ - - if (!(prev_out && - !compare_general (prev_out->buffer, best->buffer, 0L, 1L, num_keyfields - 1))) - indexify (best->buffer, ostream); - prev_out = best; - - /* Now make the line the previous of its file, and fetch a new line from that file */ - - exch = prevline[bestfile]; - prevline[bestfile] = thisline[bestfile]; - thisline[bestfile] = exch; - - while (1) - { - /* If the file has no more, mark it empty */ - - if (feof (streams[bestfile])) - { - thisline[bestfile] = 0; - nleft--; /* Update the number of files still not empty */ - break; - } - readline (thisline[bestfile], streams[bestfile]); - if (thisline[bestfile]->buffer[0] || !feof (streams[bestfile])) break; - } - } - - finish_index (ostream); - - /* Free all storage and close all input streams */ - - for (i = 0; i < nfiles; i++) - { - fclose (streams[i]); - free (lb1[i].buffer); - free (lb2[i].buffer); - } - free (file_lossage); - free (lb1); - free (lb2); - free (thisline); - free (prevline); - free (streams); - - if (outfile) - fclose (ostream); - - return lossage; -} - -/* Print error message and exit. */ - -fatal (s1, s2) - char *s1, *s2; -{ - error (s1, s2); - exit (EXIT_FATAL); -} - -/* Print error message. `s1' is printf control string, `s2' is arg for it. */ - -error (s1, s2) - char *s1, *s2; -{ - printf ("texindex: "); - printf (s1, s2); - printf ("\n"); -} - -perror_with_name (name) - char *name; -{ - char *s; - - if (errno < sys_nerr) - s = concat ("", sys_errlist[errno], " for %s"); - else - s = "cannot open %s"; - error (s, name); -} - -pfatal_with_name (name) - char *name; -{ - char *s; - - if (errno < sys_nerr) - s = concat ("", sys_errlist[errno], " for %s"); - else - s = "cannot open %s"; - fatal (s, name); -} - -/* Return a newly-allocated string whose contents concatenate those of s1, s2, s3. */ - -char * -concat (s1, s2, s3) - char *s1, *s2, *s3; -{ - int len1 = strlen (s1), len2 = strlen (s2), len3 = strlen (s3); - char *result = (char *) xmalloc (len1 + len2 + len3 + 1); - - strcpy (result, s1); - strcpy (result + len1, s2); - strcpy (result + len1 + len2, s3); - *(result + len1 + len2 + len3) = 0; - - return result; -} - -/* Like malloc but get fatal error if memory is exhausted. */ - -int -xmalloc (size) - int size; -{ - int result = malloc (size); - if (!result) - fatal ("virtual memory exhausted", 0); - return result; -} - - -int -xrealloc (ptr, size) - char *ptr; - int size; -{ - int result = realloc (ptr, size); - if (!result) - fatal ("virtual memory exhausted"); - return result; -} - -bzero (b, length) - register char *b; - register int length; -{ -#ifdef VMS - short zero = 0; - long max_str = 65535; - long len; - - while (length > max_str) - { - (void) LIB$MOVC5 (&zero, &zero, &zero, &max_str, b); - length -= max_str; - b += max_str; - } - len = length; - (void) LIB$MOVC5 (&zero, &zero, &zero, &len, b); -#else - while (length-- > 0) - *b++ = 0; -#endif /* not VMS */ -} diff --git a/readline/examples/Makefile b/readline/examples/Makefile deleted file mode 100644 index 3d1fc527a62..00000000000 --- a/readline/examples/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -# This is the Makefile for the examples subdirectory of readline. -*- text -*- -# - -EXECUTABLES = fileman -CFLAGS = -g -I../.. -LDFLAGS = -g -L.. - -fileman: fileman.o - $(CC) $(LDFLAGS) -o fileman fileman.o -lreadline -ltermcap - -fileman.o: fileman.c - diff --git a/readline/examples/histexamp.c b/readline/examples/histexamp.c new file mode 100644 index 00000000000..eceb66df19e --- /dev/null +++ b/readline/examples/histexamp.c @@ -0,0 +1,82 @@ +main () +{ + char line[1024], *t; + int len, done = 0; + + line[0] = 0; + + using_history (); + while (!done) + { + printf ("history$ "); + fflush (stdout); + t = fgets (line, sizeof (line) - 1, stdin); + if (t && *t) + { + len = strlen (t); + if (t[len - 1] == '\n') + t[len - 1] = '\0'; + } + + if (!t) + strcpy (line, "quit"); + + if (line[0]) + { + char *expansion; + int result; + + using_history (); + + result = history_expand (line, &expansion); + if (result) + fprintf (stderr, "%s\n", expansion); + + if (result < 0 || result == 2) + { + free (expansion); + continue; + } + + add_history (expansion); + strncpy (line, expansion, sizeof (line) - 1); + free (expansion); + } + + if (strcmp (line, "quit") == 0) + done = 1; + else if (strcmp (line, "save") == 0) + write_history ("history_file"); + else if (strcmp (line, "read") == 0) + read_history ("history_file"); + else if (strcmp (line, "list") == 0) + { + register HIST_ENTRY **the_list; + register int i; + + the_list = history_list (); + if (the_list) + for (i = 0; the_list[i]; i++) + printf ("%d: %s\n", i + history_base, the_list[i]->line); + } + else if (strncmp (line, "delete", 6) == 0) + { + int which; + if ((sscanf (line + 6, "%d", &which)) == 1) + { + HIST_ENTRY *entry = remove_history (which); + if (!entry) + fprintf (stderr, "No such entry %d\n", which); + else + { + free (entry->line); + free (entry); + } + } + else + { + fprintf (stderr, "non-numeric arg given to `delete'\n"); + } + } + } +} diff --git a/readline/history.texi b/readline/history.texi deleted file mode 100755 index 5fd9125b84f..00000000000 --- a/readline/history.texi +++ /dev/null @@ -1,202 +0,0 @@ -\input texinfo.tex -@setfilename history.info - -@ifinfo -@format -START-INFO-DIR-ENTRY -* History: (history). The GNU History library. -END-INFO-DIR-ENTRY -@end format -@end ifinfo - -@ifinfo -This file documents the GNU History library. - -Copyright (C) 1988 Free Software Foundation, Inc. -Authored by Brian Fox. - -Permission is granted to make and distribute verbatim copies of this manual -provided the copyright notice and this permission notice are preserved on -all copies. - -@ignore -Permission is granted to process this file through Tex and print the -results, provided the printed document carries copying permission notice -identical to this one except for the removal of this paragraph (this -paragraph not being relevant to the printed manual). -@end ignore - -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided also that the -GNU Copyright statement is available to the distributee, and provided that -the entire resulting derived work is distributed under the terms of a -permission notice identical to this one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions. -@end ifinfo - -@node Top, Introduction, , (DIR) - -This document describes the GNU History library, a programming tool that -provides a consistent user interface for recalling lines of previously -typed input. - -@menu -* Introduction:: What is the GNU History library for? -* Interactive Use:: What it feels like using History as a user. -* Programming:: How to use History in your programs. -@end menu - -@node Introduction, Interactive Use, Top, Top -@unnumbered Introduction - -Many programs read input from the user a line at a time. The GNU history -library is able to keep track of those lines, associate arbitrary data with -each line, and utilize information from previous lines in making up new -ones. - -The programmer using the History library has available to him functions for -remembering lines on a history stack, associating arbitrary data with a -line, removing lines from the stack, searching through the stack for a -line containing an arbitrary text string, and referencing any line on the -stack directly. In addition, a history @dfn{expansion} function is -available which provides for a consistent user interface across many -different programs. - -The end-user using programs written with the History library has the -benifit of a consistent user interface, with a set of well-known commands -for manipulating the text of previous lines and using that text in new -commands. The basic history manipulation commands are similar to the -history substitution used by Csh. - -If the programmer desires, he can use the Readline library, which includes -history manipulation by default, and has the added advantage of Emacs style -command line editing. - -@node Interactive Use, Programming, Introduction, Top -@chapter Interactive Use - -@section History Expansion -@cindex expansion - -The History library provides a history expansion feature that is similar to -the history expansion in Csh. The following text describes what syntax -features are available. - -History expansion takes place in two parts. The first is to determine -which line from the previous history should be used during substitution. -The second is to select portions of that line for inclusion into the -current one. The line selected from the previous history is called the -@dfn{event}, and the portions of that line that are acted upon are called -@dfn{words}. The line is broken into words in the same fashion that the -Bash shell does, so that several English (or Unix) words surrounded by -quotes are considered as one word. - -@menu -* Event Designators:: How to specify which history line to use. -* Word Designators:: Specifying which words are of interest. -* Modifiers:: Modifying the results of susbstitution. -@end menu - -@node Event Designators, Word Designators, , Interactive Use -@subsection Event Designators -@cindex event designators - -An event designator is a reference to a command line entry in the history -list. - -@table @var - -@item ! -Start a history subsititution, except when followed by a @key{SPC}, -@key{TAB}, @key{RET}, @key{=} or @key{(}. - -@item !! -Refer to the previous command. This is a synonym for @code{!-1}. - -@item !n -Refer to command line @var{n}. - -@item !-n -Refer to the current command line minus @var{n}. - -@item !string -Refer to the most recent command starting with @var{string}. - -@item !?string[?] -Refer to the most recent command containing @var{string}. - -@end table - -@node Word Designators, Modifiers, Event Designators, Interactive Use -@subsection Word Designators - -A @key{:} separates the event specification from the word designator. It -can be omitted if the word designator begins with a @key{^}, @key{$}, -@key{*} or @key{%}. Words are numbered from the beginning of the line, -with the first word being denoted by a 0 (zero). - -@table @asis - -@item @var{0} (zero) -The zero'th word. For many applications, this is the command word. - -@item n -The @var{n}'th word. - -@item @var{^} -The first argument. that is, word 1. - -@item @var{$} -The last argument. - -@item @var{%} -The word matched by the most recent @code{?string?} search. - -@item @var{x}-@var{y} -A range of words; @code{-@var{y}} is equivalent to @code{0-@var{y}}. - -@item @var{*} -All of the words, excepting the zero'th. This is a synonym for @samp{1-$}. -It is not an error to use @samp{*} if there is just one word in the event. -The empty string is returned in that case. - -@end table - -@node Modifiers, , Word Designators, Interactive Use -@subsection Modifiers - -After the optional word designator, you can add a sequence of one or more -of the following modifiers, each preceded by a @key{:}. - -@table @code - -@item # -The entire command line typed so far. This means the current command, -not the previous command, so it really isn't a word designator, and doesn't -belong in this section. - -@item h -Remove a trailing pathname component, leaving only the head. - -@item r -Remove a trailing suffix of the form ".xxx", leaving the basename (root). - -@item e -Remove all but the suffix (end). - -@item t -Remove all leading pathname components (before the last slash), leaving -the tail. - -@item p -Print the new command but do not execute it. This takes effect -immediately, so it should be the last specifier on the line. - -@end table - -@node Programming, , Interactive Use, Top -@chapter Programming - -@bye diff --git a/readline/history.texinfo b/readline/history.texinfo deleted file mode 100755 index 1e619e1acfb..00000000000 --- a/readline/history.texinfo +++ /dev/null @@ -1,194 +0,0 @@ -\input texinfo.tex -@setfilename history.info - -@ifinfo -This file documents the GNU History library. - -Copyright (C) 1988 Free Software Foundation, Inc. -Authored by Brian Fox. - -Permission is granted to make and distribute verbatim copies of this manual -provided the copyright notice and this permission notice are preserved on -all copies. - -@ignore -Permission is granted to process this file through Tex and print the -results, provided the printed document carries copying permission notice -identical to this one except for the removal of this paragraph (this -paragraph not being relevant to the printed manual). -@end ignore - -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided also that the -GNU Copyright statement is available to the distributee, and provided that -the entire resulting derived work is distributed under the terms of a -permission notice identical to this one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions. -@end ifinfo - -@node Top, Introduction, , (DIR) - -This document describes the GNU History library, a programming tool that -provides a consistent user interface for recalling lines of previously -typed input. - -@menu -* Introduction:: What is the GNU History library for? -* Interactive Use:: What it feels like using History as a user. -* Programming:: How to use History in your programs. -@end menu - -@node Introduction, Interactive Use, , Top -@unnumbered Introduction - -Many programs read input from the user a line at a time. The GNU history -library is able to keep track of those lines, associate arbitrary data with -each line, and utilize information from previous lines in making up new -ones. - -The programmer using the History library has available to him functions for -remembering lines on a history stack, associating arbitrary data with a -line, removing lines from the stack, searching through the stack for a -line containing an arbitrary text string, and referencing any line on the -stack directly. In addition, a history @dfn{expansion} function is -available which provides for a consistent user interface across many -different programs. - -The end-user using programs written with the History library has the -benifit of a consistent user interface, with a set of well-known commands -for manipulating the text of previous lines and using that text in new -commands. The basic history manipulation commands are similar to the -history substitution used by Csh. - -If the programmer desires, he can use the Readline library, which includes -history manipulation by default, and has the added advantage of Emacs style -command line editing. - -@node Interactive Use, Programming, Introduction, Top -@chapter Interactive Use - -@section History Expansion -@cindex expansion - -The History library provides a history expansion feature that is similar to -the history expansion in Csh. The following text describes what syntax -features are available. - -History expansion takes place in two parts. The first is to determine -which line from the previous history should be used during substitution. -The second is to select portions of that line for inclusion into the -current one. The line selected from the previous history is called the -@dfn{event}, and the portions of that line that are acted upon are called -@dfn{words}. The line is broken into words in the same fashion that the -Bash shell does, so that several English (or Unix) words surrounded by -quotes are considered as one word. - -@menu -* Event Designators:: How to specify which history line to use. -* Word Designators:: Specifying which words are of interest. -* Modifiers:: Modifying the results of susbstitution. -@end menu - -@node Event Designators, Word Designators, , Interactive Use -@subsection Event Designators -@cindex event designators - -An event designator is a reference to a command line entry in the history -list. - -@table @var - -@item ! -Start a history subsititution, except when followed by a @key{SPC}, -@key{TAB}, @key{RET}, @key{=} or @key{(}. - -@item !! -Refer to the previous command. This is a synonym for @code{!-1}. - -@item !n -Refer to command line @var{n}. - -@item !-n -Refer to the current command line minus @var{n}. - -@item !string -Refer to the most recent command starting with @var{string}. - -@item !?string[?] -Refer to the most recent command containing @var{string}. - -@end table - -@node Word Designators, Modifiers, Event Designators, Interactive Use -@subsection Word Designators - -A @key{:} separates the event specification from the word designator. It -can be omitted if the word designator begins with a @key{^}, @key{$}, -@key{*} or @key{%}. Words are numbered from the beginning of the line, -with the first word being denoted by a 0 (zero). - -@table @asis - -@item @var{0} (zero) -The zero'th word. For many applications, this is the command word. - -@item n -The @var{n}'th word. - -@item @var{^} -The first argument. that is, word 1. - -@item @var{$} -The last argument. - -@item @var{%} -The word matched by the most recent @code{?string?} search. - -@item @var{x}-@var{y} -A range of words; @code{-@var{y}} is equivalent to @code{0-@var{y}}. - -@item @var{*} -All of the words, excepting the zero'th. This is a synonym for @samp{1-$}. -It is not an error to use @samp{*} if there is just one word in the event. -The empty string is returned in that case. - -@end table - -@node Modifiers, , Word Designators, Interactive Use -@subsection Modifiers - -After the optional word designator, you can add a sequence of one or more -of the following modifiers, each preceded by a @key{:}. - -@table @code - -@item # -The entire command line typed so far. This means the current command, -not the previous command, so it really isn't a word designator, and doesn't -belong in this section. - -@item h -Remove a trailing pathname component, leaving only the head. - -@item r -Remove a trailing suffix of the form ".xxx", leaving the basename (root). - -@item e -Remove all but the suffix (end). - -@item t -Remove all leading pathname components (before the last slash), leaving -the tail. - -@item p -Print the new command but do not execute it. This takes effect -immediately, so it should be the last specifier on the line. - -@end table - -@node Programming, , Interactive Use, Top -@chapter Programming - -@bye diff --git a/readline/inc-hist.texi b/readline/inc-hist.texi deleted file mode 100755 index 9bbb575d407..00000000000 --- a/readline/inc-hist.texi +++ /dev/null @@ -1,188 +0,0 @@ -@ifinfo -This file documents the GNU History library. - -Copyright (C) 1988 Free Software Foundation, Inc. -Authored by Brian Fox. - -Permission is granted to make and distribute verbatim copies of this manual -provided the copyright notice and this permission notice are preserved on -all copies. -@end ifinfo - -@ignore -Permission is granted to process this file through Tex and print the -results, provided the printed document carries copying permission notice -identical to this one except for the removal of this paragraph (this -paragraph not being relevant to the printed manual). - -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided also that the -GNU Copyright statement is available to the distributee, and provided that -the entire resulting derived work is distributed under the terms of a -permission notice identical to this one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions. -@end ignore - -@node History Top,,, -@appendix Command Line History -@ifinfo -This file is meant to be an inclusion in the documentation of programs -that use the history library features. There is also a standalone -document, entitled @file{history.texinfo}. -@end ifinfo - -This Appendix describes the GNU History library, a programming tool that -provides a consistent user interface for recalling lines of previously -typed input. - -@menu -* Introduction to History:: What is the GNU History library for? -* History Interaction:: What it feels like using History as a user. -@end menu - -@node Introduction to History, History Interaction, History Top, Top -@appendixsec Introduction to History - -Many programs read input from the user a line at a time. The GNU history -library is able to keep track of those lines, associate arbitrary data with -each line, and utilize information from previous lines in making up new -ones. - -The programmer using the History library has available to him functions -for remembering lines on a history stack, associating arbitrary data -with a line, removing lines from the stack, searching through the stack -for a line containing an arbitrary text string, and referencing any line -on the stack directly. In addition, a history @dfn{expansion} function -is available which provides for a consistent user interface across many -different programs. - -When you use programs written with the History library, you have the -benefit of a consistent user interface, with a set of well-known -commands for manipulating the text of previous lines and using that text -in new commands. The basic history manipulation commands are similar to -the history substitution used by Csh. - -GNU programs often also use the Readline library, which includes history -manipulation by default, and has the added advantage of Emacs style -command line editing. - -@node History Interaction, , Introduction to History, Top -@appendixsec History Interaction -@cindex expansion - -The History library provides a history expansion feature that is similar -to the history expansion in Csh. The following text describes what -syntax features are available. - -History expansion takes place in two parts. The first is to determine -which line from the previous history should be used during substitution. -The second is to select portions of that line for inclusion into the -current one. The line selected from the previous history is called the -@dfn{event}, and the portions of that line that are acted upon are -called @dfn{words}. The line is broken into words in the same fashion -used by the Bash shell, so that several words surrounded by quotes are -treated as if they were a single word. - -@menu -* Event Designators:: How to specify which history line to use. * -Word Designators:: Specifying which words are of interest. * -Modifiers:: Modifying the results of susbstitution. -@end menu - -@node Event Designators, Word Designators, , History Interaction -@appendixsubsec Event Designators -@cindex event designators - -An event designator is a reference to a command line entry in the -history list. - -@table @asis - -@item @code{!} -Start a history subsititution, except when followed by a space, tab, or -the end of the line; or by @samp{=} or @samp{(}. - -@item @code{!!} -Refer to the previous command. This is a synonym for @code{!-1}. - -@item @code{!@var{n}} -Refer to command line @var{n}. - -@item @code{!-@var{n}} -Refer to the command line @var{n} lines back. - -@item @code{!@var{string}} -Refer to the most recent command starting with @var{string}. - -@item @code{!?@var{string}}[@code{?}] -Refer to the most recent command containing @var{string}. - -@end table - -@node Word Designators, Modifiers, Event Designators, History Interaction -@appendixsubsec Word Designators - -A @samp{:} separates the event specification from the word designator. It -can be omitted if the word designator begins with a @samp{^}, @samp{$}, -@samp{*} or @samp{%}. Words are numbered from the beginning of the line, -with the first word being denoted by a 0 (zero). - -@table @code - -@item 0 (zero) -The zero'th word. For many applications, this is the command word. - -@item n -The @var{n}'th word. - -@item ^ -The first argument. that is, word 1. - -@item $ -The last argument. - -@item % -The word matched by the most recent @code{?@var{string}?} search. - -@item @var{x}-@var{y} -A range of words; @code{-@var{y}} abbreviates @code{0-@var{y}}. - -@item * -All of the words, excepting the zero'th. This is a synonym for @samp{1-$}. -It is not an error to use @samp{*} if there is just one word in the event. -The empty string is returned in that case. - -@end table - -@node Modifiers, , Word Designators, History Interaction -@appendixsubsec Modifiers - -After the optional word designator, you can add a sequence of one or more -of the following modifiers, each preceded by a @samp{:}. - -@table @code - -@item # -The entire command line typed so far. This means the current command, -not the previous command, so it really isn't a word designator, and doesn't -belong in this section. - -@item h -Remove a trailing pathname component, leaving only the head. - -@item r -Remove a trailing suffix of the form @samp{.@var{suffix}}, leaving the basename. - -@item e -Remove all but the suffix. - -@item t -Remove all leading pathname components, leaving the tail. - -@item p -Print the new command but do not execute it. This takes effect -immediately, so it should be the last specifier on the line. - -@end table diff --git a/readline/inc-history.texinfo b/readline/inc-history.texinfo deleted file mode 100755 index 9bbb575d407..00000000000 --- a/readline/inc-history.texinfo +++ /dev/null @@ -1,188 +0,0 @@ -@ifinfo -This file documents the GNU History library. - -Copyright (C) 1988 Free Software Foundation, Inc. -Authored by Brian Fox. - -Permission is granted to make and distribute verbatim copies of this manual -provided the copyright notice and this permission notice are preserved on -all copies. -@end ifinfo - -@ignore -Permission is granted to process this file through Tex and print the -results, provided the printed document carries copying permission notice -identical to this one except for the removal of this paragraph (this -paragraph not being relevant to the printed manual). - -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided also that the -GNU Copyright statement is available to the distributee, and provided that -the entire resulting derived work is distributed under the terms of a -permission notice identical to this one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions. -@end ignore - -@node History Top,,, -@appendix Command Line History -@ifinfo -This file is meant to be an inclusion in the documentation of programs -that use the history library features. There is also a standalone -document, entitled @file{history.texinfo}. -@end ifinfo - -This Appendix describes the GNU History library, a programming tool that -provides a consistent user interface for recalling lines of previously -typed input. - -@menu -* Introduction to History:: What is the GNU History library for? -* History Interaction:: What it feels like using History as a user. -@end menu - -@node Introduction to History, History Interaction, History Top, Top -@appendixsec Introduction to History - -Many programs read input from the user a line at a time. The GNU history -library is able to keep track of those lines, associate arbitrary data with -each line, and utilize information from previous lines in making up new -ones. - -The programmer using the History library has available to him functions -for remembering lines on a history stack, associating arbitrary data -with a line, removing lines from the stack, searching through the stack -for a line containing an arbitrary text string, and referencing any line -on the stack directly. In addition, a history @dfn{expansion} function -is available which provides for a consistent user interface across many -different programs. - -When you use programs written with the History library, you have the -benefit of a consistent user interface, with a set of well-known -commands for manipulating the text of previous lines and using that text -in new commands. The basic history manipulation commands are similar to -the history substitution used by Csh. - -GNU programs often also use the Readline library, which includes history -manipulation by default, and has the added advantage of Emacs style -command line editing. - -@node History Interaction, , Introduction to History, Top -@appendixsec History Interaction -@cindex expansion - -The History library provides a history expansion feature that is similar -to the history expansion in Csh. The following text describes what -syntax features are available. - -History expansion takes place in two parts. The first is to determine -which line from the previous history should be used during substitution. -The second is to select portions of that line for inclusion into the -current one. The line selected from the previous history is called the -@dfn{event}, and the portions of that line that are acted upon are -called @dfn{words}. The line is broken into words in the same fashion -used by the Bash shell, so that several words surrounded by quotes are -treated as if they were a single word. - -@menu -* Event Designators:: How to specify which history line to use. * -Word Designators:: Specifying which words are of interest. * -Modifiers:: Modifying the results of susbstitution. -@end menu - -@node Event Designators, Word Designators, , History Interaction -@appendixsubsec Event Designators -@cindex event designators - -An event designator is a reference to a command line entry in the -history list. - -@table @asis - -@item @code{!} -Start a history subsititution, except when followed by a space, tab, or -the end of the line; or by @samp{=} or @samp{(}. - -@item @code{!!} -Refer to the previous command. This is a synonym for @code{!-1}. - -@item @code{!@var{n}} -Refer to command line @var{n}. - -@item @code{!-@var{n}} -Refer to the command line @var{n} lines back. - -@item @code{!@var{string}} -Refer to the most recent command starting with @var{string}. - -@item @code{!?@var{string}}[@code{?}] -Refer to the most recent command containing @var{string}. - -@end table - -@node Word Designators, Modifiers, Event Designators, History Interaction -@appendixsubsec Word Designators - -A @samp{:} separates the event specification from the word designator. It -can be omitted if the word designator begins with a @samp{^}, @samp{$}, -@samp{*} or @samp{%}. Words are numbered from the beginning of the line, -with the first word being denoted by a 0 (zero). - -@table @code - -@item 0 (zero) -The zero'th word. For many applications, this is the command word. - -@item n -The @var{n}'th word. - -@item ^ -The first argument. that is, word 1. - -@item $ -The last argument. - -@item % -The word matched by the most recent @code{?@var{string}?} search. - -@item @var{x}-@var{y} -A range of words; @code{-@var{y}} abbreviates @code{0-@var{y}}. - -@item * -All of the words, excepting the zero'th. This is a synonym for @samp{1-$}. -It is not an error to use @samp{*} if there is just one word in the event. -The empty string is returned in that case. - -@end table - -@node Modifiers, , Word Designators, History Interaction -@appendixsubsec Modifiers - -After the optional word designator, you can add a sequence of one or more -of the following modifiers, each preceded by a @samp{:}. - -@table @code - -@item # -The entire command line typed so far. This means the current command, -not the previous command, so it really isn't a word designator, and doesn't -belong in this section. - -@item h -Remove a trailing pathname component, leaving only the head. - -@item r -Remove a trailing suffix of the form @samp{.@var{suffix}}, leaving the basename. - -@item e -Remove all but the suffix. - -@item t -Remove all leading pathname components, leaving the tail. - -@item p -Print the new command but do not execute it. This takes effect -immediately, so it should be the last specifier on the line. - -@end table diff --git a/readline/inc-read.texi b/readline/inc-read.texi deleted file mode 100755 index 3a46aaa3ced..00000000000 --- a/readline/inc-read.texi +++ /dev/null @@ -1,490 +0,0 @@ -@ignore - -This file documents the end user interface to the GNU command line -editing feautres. It is to be an appendix to manuals for programs which -use these features. There is a document entitled "readline.texinfo" -which contains both end-user and programmer documentation for the GNU -Readline Library. - -Copyright (C) 1988, 1991 Free Software Foundation, Inc. - -Written by Brian Fox. - -Permission is granted to process this file through Tex and print the -results, provided the printed document carries copying permission notice -identical to this one except for the removal of this paragraph (this -paragraph not being relevant to the printed manual). - -Permission is granted to make and distribute verbatim copies of this manual -provided the copyright notice and this permission notice are preserved on -all copies. - -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided also that the -GNU Copyright statement is available to the distributee, and provided that -the entire resulting derived work is distributed under the terms of a -permission notice identical to this one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions. -@end ignore - -@node Command Line Editing, , , Top -@appendix Command Line Editing - -This appendix describes GNU's command line editing interface. -Often during an interactive session you will type in a long line of -text, only to notice that the first word on the line is misspelled. The -Readline library gives you a set of commands for manipulating the text -as you type it in, allowing you to just fix your typo, and not forcing -you to retype the majority of the line. Using these editing commands, -you move the cursor to the place that needs correction, and delete or -insert the text of the corrections. Then, when you are satisfied with -the line, you simply press @key{RETURN}. You do not have to be at the -end of the line to press @key{RETURN}; the entire line will be accepted -in any case. - -@menu -* Conventions:: Notation used in this appendix. -* Readline Interaction:: How to use Readline -* Readline Init File:: Customizing Readline for your own use -@end menu - -@node Conventions, Readline Interaction, Command Line Editing, Command Line Editing -@appendixsec Conventions on Notation - -In this Appendix, the following notation is used to describe -keystrokes. - -The text @kbd{C-k} is read as `Control-K' and describes the character -produced when the Control key is depressed and the @key{k} key is struck. - -The text @kbd{M-k} is read as `Meta-K' and describes the character -produced when the meta key (if you have one) is depressed, and the -@key{k} key is struck. If you do not have a meta key, it is equivalent -to type @key{ESC} @i{first}, and then type @key{k}. Either process is -known as @dfn{metafying} the @key{k} key. - -The text @kbd{M-C-k} is read as `Meta-Control-k' and describes the -character produced by @dfn{metafying} @kbd{C-k}. - -In addition, several keys have their own names. Specifically, -@key{DEL}, @key{ESC}, @key{LFD}, @key{SPC}, @key{RET}, and @key{TAB} all -stand for themselves when seen in this text, or in an init file -(@pxref{Readline Init File}, for more info). - -@node Readline Interaction, Readline Init File, Conventions, Command Line Editing -@appendixsec Readline Interaction -@cindex interaction, readline - -@menu -* Readline Bare Essentials:: The least you need to know about Readline. -* Readline Movement Commands:: Moving about the input line. -* Readline Killing Commands:: How to delete text, and how to get it back! -* Readline Arguments:: Giving numeric arguments to commands. -@end menu - -@node Readline Bare Essentials, Readline Movement Commands, Readline Interaction, Readline Interaction -@appendixsubsec Bare Essentials - -In order to enter characters into the line, simply type them. The typed -character appears where the cursor was, and then the cursor moves one -space to the right. If you mistype a character, you can use @key{DEL} to -back up, and delete the mistyped character. - -Sometimes you may miss typing a character that you wanted to type, and -not notice your error until you have typed several other characters. In -that case, you can type @kbd{C-b} to move the cursor to the left, and then -correct your mistake. Aftwerwards, you can move the cursor to the right -with @kbd{C-f}. - -When you add text in the middle of a line, you will notice that characters -to the right of the cursor get `pushed over' to make room for the text -that you have inserted. Likewise, when you delete text behind the cursor, -characters to the right of the cursor get `pulled back' to fill in the -blank space created by the removal of the text. A list of the basic bare -essentials for editing the text of an input line follows. - -@table @asis -@item @kbd{C-b} -Move back one character. -@item @kbd{C-f} -Move forward one character. -@item @key{DEL} -Delete the character to the left of the cursor. -@item @kbd{C-d} -Delete the character underneath the cursor. -@item @var{c} -Insert an ordinary printing character @var{c} into the line at the cursor. -@item @kbd{C-_} -Undo the last thing that you did. You can undo all the way back to an -empty line. -@end table - -@node Readline Movement Commands, Readline Killing Commands, Readline Bare Essentials, Readline Interaction -@appendixsubsec Movement Commands - - -The above table describes the most basic possible keystrokes that you need -in order to do editing of the input line. For your convenience, many -other commands have been added in addition to @kbd{C-b}, @kbd{C-f}, -@kbd{C-d}, and @key{DEL}. Here are some commands for moving more rapidly -about the line. - -@table @kbd -@item C-a -Move to the start of the line. -@item C-e -Move to the end of the line. -@item M-f -Move forward a word. -@item M-b -Move backward a word. -@item C-l -Clear the screen, reprinting the current line at the top. -@end table - -Notice how @kbd{C-f} moves forward a character, while @kbd{M-f} moves -forward a word. It is a loose convention that control keystrokes -operate on characters while meta keystrokes operate on words. - -@node Readline Killing Commands, Readline Arguments, Readline Movement Commands, Readline Interaction -@appendixsubsec Killing Commands - -@dfn{Killing} text means to delete the text from the line, but to save -it away for later use, usually by @dfn{yanking} it back into the line. -If the description for a command says that it `kills' text, then you can -be sure that you can get the text back in a different (or the same) -place later. - -Here is the list of commands for killing text. - -@table @kbd -@item C-k -Kill the text from the current cursor position to the end of the line. - -@item M-d -Kill from the cursor to the end of the current word, or if between -words, to the end of the next word. - -@item M-@key{DEL} -Kill from the cursor the start ofthe previous word, or if between words, to the start of the previous word. - -@item C-w -Kill from the cursor to the previous whitespace. This is different than -@kbd{M-@key{DEL}} because the word boundaries differ. - -@end table - -And, here is how to @dfn{yank} the text back into the line. Yanking -is - -@table @kbd -@item C-y -Yank the most recently killed text back into the buffer at the cursor. - -@item M-y -Rotate the kill-ring, and yank the new top. You can only do this if -the prior command is @kbd{C-y} or @kbd{M-y}. -@end table - -When you use a kill command, the text is saved in a @dfn{kill-ring}. -Any number of consecutive kills save all of the killed text together, so -that when you yank it back, you get it in one clean sweep. The kill -ring is not line specific; the text that you killed on a previously -typed line is available to be yanked back later, when you are typing -another line. - -@node Readline Arguments, , Readline Killing Commands, Readline Interaction -@appendixsubsec Arguments - -You can pass numeric arguments to Readline commands. Sometimes the -argument acts as a repeat count, other times it is the @i{sign} of the -argument that is significant. If you pass a negative argument to a -command which normally acts in a forward direction, that command will -act in a backward direction. For example, to kill text back to the -start of the line, you might type @kbd{M--} @kbd{C-k}. - -The general way to pass numeric arguments to a command is to type meta -digits before the command. If the first `digit' you type is a minus -sign (@kbd{-}), then the sign of the argument will be negative. Once -you have typed one meta digit to get the argument started, you can type -the remainder of the digits, and then the command. For example, to give -the @kbd{C-d} command an argument of 10, you could type @kbd{M-1 0 C-d}. - - -@node Readline Init File, , Readline Interaction, Command Line Editing -@appendixsec Readline Init File - -Although the Readline library comes with a set of Emacs-like -keybindings, it is possible that you would like to use a different set -of keybindings. You can customize programs that use Readline by putting -commands in an @dfn{init} file in your home directory. The name of this -file is @file{~/.inputrc}. - -When a program which uses the Readline library starts up, it reads the file -@file{~/.inputrc}, and sets the keybindings. - -@menu -* Readline Init Syntax:: Syntax for the commands in @file{~/.inputrc}. -* Readline Vi Mode:: Switching to @code{vi} mode in Readline. -@end menu - -@node Readline Init Syntax, Readline Vi Mode, Readline Init File, Readline Init File -@appendixsubsec Readline Init Syntax - -You can start up with a vi-like editing mode by placing - -@example -@code{set editing-mode vi} -@end example - -@noindent -in your @file{~/.inputrc} file. - -You can have Readline use a single line for display, scrolling the input -between the two edges of the screen by placing - -@example -@code{set horizontal-scroll-mode On} -@end example - -@noindent -in your @file{~/.inputrc} file. - -The syntax for controlling keybindings in the @file{~/.inputrc} file is -simple. First you have to know the @i{name} of the command that you -want to change. The following pages contain tables of the command name, the -default keybinding, and a short description of what the command does. - -Once you know the name of the command, simply place the name of the key -you wish to bind the command to, a colon, and then the name of the -command on a line in the @file{~/.inputrc} file. Here is an example: - -@example -# This is a comment line. -Meta-Rubout: backward-kill-word -Control-u: universal-argument -@end example - -@menu -* Commands For Moving:: Moving about the line. -* Commands For History:: Getting at previous lines. -* Commands For Text:: Commands for changing text. -* Commands For Killing:: Commands for killing and yanking. -* Numeric Arguments:: Specifying numeric arguments, repeat counts. -* Commands For Completion:: Getting Readline to do the typing for you. -* Miscellaneous Commands:: Other miscillaneous commands. -@end menu - -@node Commands For Moving, Commands For History, Readline Init Syntax, Readline Init Syntax -@appendixsubsubsec Moving -@table @code -@item beginning-of-line (C-a) -Move to the start of the current line. - -@item end-of-line (C-e) -Move to the end of the line. - -@item forward-char (C-f) -Move forward a character. - -@item backward-char (C-b) -Move back a character. - -@item forward-word (M-f) -Move forward to the end of the next word. - -@item backward-word (M-b) -Move back to the start of this, or the previous, word. - -@item clear-screen (C-l) -Clear the screen leaving the current line at the top of the screen. - -@end table - -@node Commands For History, Commands For Text, Commands For Moving, Readline Init Syntax -@appendixsubsubsec Using the History - -@table @code -@item accept-line (Newline, Return) -Accept the line regardless of where the cursor is. If this line is -non-empty, add it to the history list. If this line was a history -line, then restore the history line to its original state. - -@item previous-history (C-p) -Move `up' through the history list. - -@item next-history (C-n) -Move `down' through the history list. - -@item beginning-of-history (M-<) -Move to the first line in the history. - -@item end-of-history (M->) -Move to the end of the input history, i.e., the line you are entering! - -@item reverse-search-history (C-r) -Search backward starting at the current line and moving `up' through -the history as necessary. This is an incremental search. - -@item forward-search-history (C-s) -Search forward starting at the current line and moving `down' through -the the history as neccessary. - -@end table - -@node Commands For Text, Commands For Killing, Commands For History, Readline Init Syntax -@appendixsubsubsec Changing Text - -@table @code -@item delete-char (C-d) -Delete the character under the cursor. If the cursor is at the -beginning of the line, and there are no characters in the line, and -the last character typed was not C-d, then return EOF. - -@item backward-delete-char (Rubout) -Delete the character behind the cursor. A numeric arg says to kill -the characters instead of deleting them. - -@item quoted-insert (C-q, C-v) -Add the next character that you type to the line verbatim. This is -how to insert things like C-q for example. - -@item tab-insert (M-TAB) -Insert a tab character. - -@item self-insert (a, b, A, 1, !, ...) -Insert an ordinary printing character into the line. - -@item transpose-chars (C-t) -Drag the character before point forward over the character at point. -Point moves forward as well. If point is at the end of the line, then -transpose the two characters before point. Negative args don't work. - -@item transpose-words (M-t) -Drag the word behind the cursor past the word in front of the cursor -moving the cursor over that word as well. - -@item upcase-word (M-u) -Uppercase the current (or following) word. With a negative argument, -do the previous word, but do not move point. - -@item downcase-word (M-l) -Lowercase the current (or following) word. With a negative argument, -do the previous word, but do not move point. - -@item capitalize-word (M-c) -Uppercase the current (or following) word. With a negative argument, -do the previous word, but do not move point. - -@end table - -@node Commands For Killing, Numeric Arguments, Commands For Text, Readline Init Syntax -@appendixsubsubsec Killing And Yanking - -@table @code - -@item kill-line (C-k) -Kill the text from the current cursor position to the end of the line. - -@item backward-kill-line () -Kill backward to the beginning of the line. This is normally unbound. - -@item kill-word (M-d) -Kill from the cursor to the end of the current word, or if between -words, to the end of the next word. - -@item backward-kill-word (M-DEL) -Kill the word behind the cursor. - -@item unix-line-discard (C-u) -Kill the entire line. This is similar to the use of the Unix kill -character (often also @key{C-u}), save that here the killed text can be -retrieved later (since it goes on the kill-ring). - -@item unix-word-rubout (C-w) -Kill the current word, like the Unix word erase character. The killed -text goes on the kill-ring. This is different than -@code{backward-kill-word} because the word boundaries differ. - -@item yank (C-y) -Yank the top of the kill ring into the buffer at point. - -@item yank-pop (M-y) -Rotate the kill-ring, and yank the new top. You can only do this if -the prior command is @code{yank} or @code{yank-pop}. -@end table - -@node Numeric Arguments, Commands For Completion, Commands For Killing, Readline Init Syntax -@appendixsubsubsec Numeric Arguments -@table @code - -@item digit-argument (M-0, M-1, ... M--) -Add this digit to the argument already accumulating, or start a new -argument. @kbd{M--} starts a negative argument. - -@item universal-argument () -Do what @key{C-u} does in emacs. By default, this is not bound to any keys. -@end table - - -@node Commands For Completion, Miscellaneous Commands, Numeric Arguments, Readline Init Syntax -@appendixsubsubsec Letting Readline Type - -@table @code -@item complete (TAB) -Attempt to do completion on the text before point. This is -implementation defined. Generally, if you are typing a filename -argument, you can do filename completion; if you are typing a command, -you can do command completion, if you are typing in a symbol to GDB, you -can do symbol name completion, if you are typing in a variable to Bash, -you can do variable name completion... - -@item possible-completions (M-?) -List the possible completions of the text before point. -@end table - -@node Miscellaneous Commands, , Commands For Completion, Readline Init Syntax -@appendixsubsubsec Other Commands -@table @code - -@item abort (@kbd{C-g}) -The line editing commands @code{reverse-search-history} (@kbd{C-r}) and -@code{forward-search-history} (@kbd{C-s} go into a separate input mode; -you can abort the search, and return to normal input mode, by using the -@code{abort} (@kbd{C-g}) command. - -@item do-uppercase-version (@kbd{M-a}, @kbd{M-b}, @dots{}) -Run the command that is bound to your uppercase brother. - -@item prefix-meta (@key{ESC}) -Make the next character that you type be metafied. This is for -people without a meta key. @kbd{@key{ESC}-f} is equivalent to @kbd{M-f}. - -@item undo (@kbd{C-_}) -Incremental undo, separately remembered for each line. - -@item revert-line (@kbd{M-r}) -Undo all changes made to this line. This is like typing the `undo' -command enough times to get back to the beginning. -@end table - -@node Readline vi Mode, , Readline Init Syntax, Readline Init File -@appendixsubsec Readline @code{vi} Mode - -While the Readline library does not have a full set of @code{vi} editing -functions, it does contain enough to allow simple editing of the line. - -In order to switch interactively between Emacs and @code{vi} editing modes, use -the command @kbd{M-C-j} (@code{toggle-editing-mode}). - -When you enter a line in @code{vi} mode, you are already in -``insertion'' mode, as if you had typed an @kbd{i}. Pressing @key{ESC} -switches you into ``edit'' mode, where you can edit the text of the line -with the standard @code{vi} movement keys, move to previous history -lines with @kbd{k}, to following lines with @kbd{j}, and so forth. - - - - diff --git a/readline/inc-readline.texinfo b/readline/inc-readline.texinfo deleted file mode 100755 index 52a0e33f9a8..00000000000 --- a/readline/inc-readline.texinfo +++ /dev/null @@ -1,494 +0,0 @@ -@ignore - -This file documents the end user interface to the GNU command line -editing feautres. It is to be an appendix to manuals for programs which -use these features. There is a document entitled "readline.texinfo" -which contains both end-user and programmer documentation for the GNU -Readline Library. - -Copyright (C) 1988, 1991 Free Software Foundation, Inc. - -Written by Brian Fox. - -Permission is granted to process this file through Tex and print the -results, provided the printed document carries copying permission notice -identical to this one except for the removal of this paragraph (this -paragraph not being relevant to the printed manual). - -Permission is granted to make and distribute verbatim copies of this manual -provided the copyright notice and this permission notice are preserved on -all copies. - -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided also that the -GNU Copyright statement is available to the distributee, and provided that -the entire resulting derived work is distributed under the terms of a -permission notice identical to this one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions. -@end ignore - -@node Command Line Editing, , , Top -@appendix Command Line Editing - -This appendix describes GNU's command line editing interface. -Often during an interactive session you will type in a long line of -text, only to notice that the first word on the line is misspelled. The -Readline library gives you a set of commands for manipulating the text -as you type it in, allowing you to just fix your typo, and not forcing -you to retype the majority of the line. Using these editing commands, -you move the cursor to the place that needs correction, and delete or -insert the text of the corrections. Then, when you are satisfied with -the line, you simply press @key{RETURN}. You do not have to be at the -end of the line to press @key{RETURN}; the entire line will be accepted -in any case. - -@menu -* Conventions:: Notation used in this appendix. -* Basic Line Editing:: The minimum set of commands for editing a line. -* Movement Commands:: Commands for moving the cursor about the line. -* Cutting and Pasting:: Deletion and copying of text sections. -* Transposition:: Exchanging two characters or words. -* Completion:: Expansion of a partially typed word into - the full text. -@end menu - -@node Conventions, Basic Line Editing, Command Line Editing, Command Line Editing -@appendixsec Conventions on Notation - -In this Appendix, the following notation is used to describe -keystrokes. - -The text @kbd{C-k} is read as `Control-K' and describes the character -produced when the Control key is depressed and the @key{k} key is struck. - -The text @kbd{M-k} is read as `Meta-K' and describes the character -produced when the meta key (if you have one) is depressed, and the -@key{k} key is struck. If you do not have a meta key, it is equivalent -to type @key{ESC} @i{first}, and then type @key{k}. Either process is -known as @dfn{metafying} the @key{k} key. - -The text @kbd{M-C-k} is read as `Meta-Control-k' and describes the -character produced by @dfn{metafying} @kbd{C-k}. - -In addition, several keys have their own names. Specifically, -@key{DEL}, @key{ESC}, @key{LFD}, @key{SPC}, @key{RET}, and @key{TAB} all -stand for themselves when seen in this text, or in an init file -(@pxref{Readline Init File}, for more info). - -@node Readline Interaction, Readline Init File, Readline Introduction, Readline Top -@appendixsec Readline Interaction -@cindex interaction, readline - -@menu -* Readline Bare Essentials:: The least you need to know about Readline. -* Readline Movement Commands:: Moving about the input line. -* Readline Killing Commands:: How to delete text, and how to get it back! -* Readline Arguments:: Giving numeric arguments to commands. -@end menu - -@node Readline Bare Essentials, Readline Movement Commands, Readline Interaction, Readline Interaction -@appendixsubsec Bare Essentials - -In order to enter characters into the line, simply type them. The typed -character appears where the cursor was, and then the cursor moves one -space to the right. If you mistype a character, you can use @key{DEL} to -back up, and delete the mistyped character. - -Sometimes you may miss typing a character that you wanted to type, and -not notice your error until you have typed several other characters. In -that case, you can type @kbd{C-b} to move the cursor to the left, and then -correct your mistake. Aftwerwards, you can move the cursor to the right -with @kbd{C-f}. - -When you add text in the middle of a line, you will notice that characters -to the right of the cursor get `pushed over' to make room for the text -that you have inserted. Likewise, when you delete text behind the cursor, -characters to the right of the cursor get `pulled back' to fill in the -blank space created by the removal of the text. A list of the basic bare -essentials for editing the text of an input line follows. - -@table @asis -@item @kbd{C-b} -Move back one character. -@item @kbd{C-f} -Move forward one character. -@item @key{DEL} -Delete the character to the left of the cursor. -@item @kbd{C-d} -Delete the character underneath the cursor. -@item @var{c} -Insert an ordinary printing character @var{c} into the line at the cursor. -@item @kbd{C-_} -Undo the last thing that you did. You can undo all the way back to an -empty line. -@end table - -@node Readline Movement Commands, Readline Killing Commands, Readline Bare Essentials, Readline Interaction -@appendixsubsec Movement Commands - - -The above table describes the most basic possible keystrokes that you need -in order to do editing of the input line. For your convenience, many -other commands have been added in addition to @kbd{C-b}, @kbd{C-f}, -@kbd{C-d}, and @key{DEL}. Here are some commands for moving more rapidly -about the line. - -@table @kbd -@item C-a -Move to the start of the line. -@item C-e -Move to the end of the line. -@item M-f -Move forward a word. -@item M-b -Move backward a word. -@item C-l -Clear the screen, reprinting the current line at the top. -@end table - -Notice how @kbd{C-f} moves forward a character, while @kbd{M-f} moves -forward a word. It is a loose convention that control keystrokes -operate on characters while meta keystrokes operate on words. - -@node Readline Killing Commands, Readline Arguments, Readline Movement Commands, Readline Interaction -@appendixsubsec Killing Commands - -@dfn{Killing} text means to delete the text from the line, but to save -it away for later use, usually by @dfn{yanking} it back into the line. -If the description for a command says that it `kills' text, then you can -be sure that you can get the text back in a different (or the same) -place later. - -Here is the list of commands for killing text. - -@table @kbd -@item C-k -Kill the text from the current cursor position to the end of the line. - -@item M-d -Kill from the cursor to the end of the current word, or if between -words, to the end of the next word. - -@item M-@key{DEL} -Kill from the cursor the start ofthe previous word, or if between words, to the start of the previous word. - -@item C-w -Kill from the cursor to the previous whitespace. This is different than -@kbd{M-@key{DEL}} because the word boundaries differ. - -@end table - -And, here is how to @dfn{yank} the text back into the line. Yanking -is - -@table @kbd -@item C-y -Yank the most recently killed text back into the buffer at the cursor. - -@item M-y -Rotate the kill-ring, and yank the new top. You can only do this if -the prior command is @kbd{C-y} or @kbd{M-y}. -@end table - -When you use a kill command, the text is saved in a @dfn{kill-ring}. -Any number of consecutive kills save all of the killed text together, so -that when you yank it back, you get it in one clean sweep. The kill -ring is not line specific; the text that you killed on a previously -typed line is available to be yanked back later, when you are typing -another line. - -@node Readline Arguments, , Readline Killing Commands, Readline Interaction -@appendixsubsec Arguments - -You can pass numeric arguments to Readline commands. Sometimes the -argument acts as a repeat count, other times it is the @i{sign} of the -argument that is significant. If you pass a negative argument to a -command which normally acts in a forward direction, that command will -act in a backward direction. For example, to kill text back to the -start of the line, you might type @kbd{M--} @kbd{C-k}. - -The general way to pass numeric arguments to a command is to type meta -digits before the command. If the first `digit' you type is a minus -sign (@kbd{-}), then the sign of the argument will be negative. Once -you have typed one meta digit to get the argument started, you can type -the remainder of the digits, and then the command. For example, to give -the @kbd{C-d} command an argument of 10, you could type @kbd{M-1 0 C-d}. - - -@node Readline Init File, , Readline Interaction, Readline Top -@appendixsec Readline Init File - -Although the Readline library comes with a set of Emacs-like -keybindings, it is possible that you would like to use a different set -of keybindings. You can customize programs that use Readline by putting -commands in an @dfn{init} file in your home directory. The name of this -file is @file{~/.inputrc}. - -When a program which uses the Readline library starts up, it reads the file -@file{~/.inputrc}, and sets the keybindings. - -@menu -* Readline Init Syntax:: Syntax for the commands in @file{~/.inputrc}. -* Readline Vi Mode:: Switching to @code{vi} mode in Readline. -@end menu - -@node Readline Init Syntax, Readline Vi Mode, Readline Init File, Readline Init File -@appendixsubsec Readline Init Syntax - -You can start up with a vi-like editing mode by placing - -@example -@code{set editing-mode vi} -@end example - -@noindent -in your @file{~/.inputrc} file. - -You can have Readline use a single line for display, scrolling the input -between the two edges of the screen by placing - -@example -@code{set horizontal-scroll-mode On} -@end example - -@noindent -in your @file{~/.inputrc} file. - -The syntax for controlling keybindings in the @file{~/.inputrc} file is -simple. First you have to know the @i{name} of the command that you -want to change. The following pages contain tables of the command name, the -default keybinding, and a short description of what the command does. - -Once you know the name of the command, simply place the name of the key -you wish to bind the command to, a colon, and then the name of the -command on a line in the @file{~/.inputrc} file. Here is an example: - -@example -# This is a comment line. -Meta-Rubout: backward-kill-word -Control-u: universal-argument -@end example - -@menu -* Commands For Moving:: Moving about the line. -* Commands For History:: Getting at previous lines. -* Commands For Text:: Commands for changing text. -* Commands For Killing:: Commands for killing and yanking. -* Numeric Arguments:: Specifying numeric arguments, repeat counts. -* Commands For Completion:: Getting Readline to do the typing for you. -* Miscellaneous Commands:: Other miscillaneous commands. -@end menu - -@node Commands For Moving, Commands For History, Readline Init Syntax, Readline Init Syntax -@appendixsubsubsec Moving -@table @code -@item beginning-of-line (C-a) -Move to the start of the current line. - -@item end-of-line (C-e) -Move to the end of the line. - -@item forward-char (C-f) -Move forward a character. - -@item backward-char (C-b) -Move back a character. - -@item forward-word (M-f) -Move forward to the end of the next word. - -@item backward-word (M-b) -Move back to the start of this, or the previous, word. - -@item clear-screen (C-l) -Clear the screen leaving the current line at the top of the screen. - -@end table - -@node Commands For History, Commands For Text, Commands For Moving, Readline Init Syntax -@appendixsubsubsec Using the History - -@table @code -@item accept-line (Newline, Return) -Accept the line regardless of where the cursor is. If this line is -non-empty, add it to the history list. If this line was a history -line, then restore the history line to its original state. - -@item previous-history (C-p) -Move `up' through the history list. - -@item next-history (C-n) -Move `down' through the history list. - -@item beginning-of-history (M-<) -Move to the first line in the history. - -@item end-of-history (M->) -Move to the end of the input history, i.e., the line you are entering! - -@item reverse-search-history (C-r) -Search backward starting at the current line and moving `up' through -the history as necessary. This is an incremental search. - -@item forward-search-history (C-s) -Search forward starting at the current line and moving `down' through -the the history as neccessary. - -@end table - -@node Commands For Text, Commands For Killing, Commands For History, Readline Init Syntax -@appendixsubsubsec Changing Text - -@table @code -@item delete-char (C-d) -Delete the character under the cursor. If the cursor is at the -beginning of the line, and there are no characters in the line, and -the last character typed was not C-d, then return EOF. - -@item backward-delete-char (Rubout) -Delete the character behind the cursor. A numeric arg says to kill -the characters instead of deleting them. - -@item quoted-insert (C-q, C-v) -Add the next character that you type to the line verbatim. This is -how to insert things like C-q for example. - -@item tab-insert (M-TAB) -Insert a tab character. - -@item self-insert (a, b, A, 1, !, ...) -Insert an ordinary printing character into the line. - -@item transpose-chars (C-t) -Drag the character before point forward over the character at point. -Point moves forward as well. If point is at the end of the line, then -transpose the two characters before point. Negative args don't work. - -@item transpose-words (M-t) -Drag the word behind the cursor past the word in front of the cursor -moving the cursor over that word as well. - -@item upcase-word (M-u) -Uppercase the current (or following) word. With a negative argument, -do the previous word, but do not move point. - -@item downcase-word (M-l) -Lowercase the current (or following) word. With a negative argument, -do the previous word, but do not move point. - -@item capitalize-word (M-c) -Uppercase the current (or following) word. With a negative argument, -do the previous word, but do not move point. - -@end table - -@node Commands For Killing, Numeric Arguments, Commands For Text, Readline Init Syntax -@appendixsubsubsec Killing And Yanking - -@table @code - -@item kill-line (C-k) -Kill the text from the current cursor position to the end of the line. - -@item backward-kill-line () -Kill backward to the beginning of the line. This is normally unbound. - -@item kill-word (M-d) -Kill from the cursor to the end of the current word, or if between -words, to the end of the next word. - -@item backward-kill-word (M-DEL) -Kill the word behind the cursor. - -@item unix-line-discard (C-u) -Kill the entire line. This is similar to the use of the Unix kill -character (often also @key{C-u}), save that here the killed text can be -retrieved later (since it goes on the kill-ring). - -@item unix-word-rubout (C-w) -Kill the current word, like the Unix word erase character. The killed -text goes on the kill-ring. This is different than -@code{backward-kill-word} because the word boundaries differ. - -@item yank (C-y) -Yank the top of the kill ring into the buffer at point. - -@item yank-pop (M-y) -Rotate the kill-ring, and yank the new top. You can only do this if -the prior command is @code{yank} or @code{yank-pop}. -@end table - -@node Numeric Arguments, Commands For Completion, Commands For Killing, Readline Init Syntax -@appendixsubsubsec Numeric Arguments -@table @code - -@item digit-argument (M-0, M-1, ... M--) -Add this digit to the argument already accumulating, or start a new -argument. @kbd{M--} starts a negative argument. - -@item universal-argument () -Do what @key{C-u} does in emacs. By default, this is not bound to any keys. -@end table - - -@node Commands For Completion, Miscellaneous Commands, Numeric Arguments, Readline Init Syntax -@appendixsubsubsec Letting Readline Type - -@table @code -@item complete (TAB) -Attempt to do completion on the text before point. This is -implementation defined. Generally, if you are typing a filename -argument, you can do filename completion; if you are typing a command, -you can do command completion, if you are typing in a symbol to GDB, you -can do symbol name completion, if you are typing in a variable to Bash, -you can do variable name completion... - -@item possible-completions (M-?) -List the possible completions of the text before point. -@end table - -@node Miscellaneous Commands, , Commands For Completion, Readline Init Syntax -@appendixsubsubsec Other Commands -@table @code - -@item abort (@kbd{C-g}) -The line editing commands @code{reverse-search-history} (@kbd{C-r}) and -@code{forward-search-history} (@kbd{C-s} go into a separate input mode; -you can abort the search, and return to normal input mode, by using the -@code{abort} (@kbd{C-g}) command. - -@item do-uppercase-version (@kbd{M-a}, @kbd{M-b}, @dots) -Run the command that is bound to your uppercase brother. - -@item prefix-meta (@key{ESC}) -Make the next character that you type be metafied. This is for -people without a meta key. @kbd{@key{ESC}-f} is equivalent to @kbd{M-f}. - -@item undo (@kbd{C-_}) -Incremental undo, separately remembered for each line. - -@item revert-line (@kbd{M-r}) -Undo all changes made to this line. This is like typing the `undo' -command enough times to get back to the beginning. -@end table - -@node Readline vi Mode, , Readline Init Syntax, Readline Init File -@appendixsubsec Readline @code{vi} Mode - -While the Readline library does not have a full set of @code{vi} editing -functions, it does contain enough to allow simple editing of the line. - -In order to switch interactively between Emacs and @code{vi} editing modes, use -the command @kbd{M-C-j} (@code{toggle-editing-mode}). - -When you enter a line in @code{vi} mode, you are already in -``insertion'' mode, as if you had typed an @kbd{i}. Pressing @key{ESC} -switches you into ``edit'' mode, where you can edit the text of the line -with the standard @code{vi} movement keys, move to previous history -lines with @kbd{k}, to following lines with @kbd{j}, and so forth. - - - - diff --git a/readline/isearch.c b/readline/isearch.c new file mode 100644 index 00000000000..9b44c9342cc --- /dev/null +++ b/readline/isearch.c @@ -0,0 +1,378 @@ +/* **************************************************************** */ +/* */ +/* I-Search and Searching */ +/* */ +/* **************************************************************** */ + +/* Copyright (C) 1987,1989 Free Software Foundation, Inc. + + This file contains the Readline Library (the Library), a set of + routines for providing Emacs style line input to programs that ask + for it. + + The Library 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 1, or (at your option) + any later version. + + The Library 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. + + The GNU General Public License is often shipped with GNU software, and + is generally kept in a file called COPYING or LICENSE. If you do not + have a copy of the license, write to the Free Software Foundation, + 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#include + +#if defined (__GNUC__) +# define alloca __builtin_alloca +#else +# if defined (sparc) || defined (HAVE_ALLOCA_H) +# include +# endif +#endif + +#include "readline.h" +#include "history.h" + +extern Keymap _rl_keymap; +extern HIST_ENTRY *saved_line_for_history; +extern int rl_line_buffer_len; +extern int rl_point, rl_end; +extern char *rl_prompt, *rl_line_buffer; + +/* Remove these declarations when we have a complete libgnu.a. */ +extern char *xmalloc (), *xrealloc (); + +static void rl_search_history (); + +/* Search backwards through the history looking for a string which is typed + interactively. Start with the current line. */ +rl_reverse_search_history (sign, key) + int sign; + int key; +{ + rl_search_history (-sign, key); +} + +/* Search forwards through the history looking for a string which is typed + interactively. Start with the current line. */ +rl_forward_search_history (sign, key) + int sign; + int key; +{ + rl_search_history (sign, key); +} + +/* Display the current state of the search in the echo-area. + SEARCH_STRING contains the string that is being searched for, + DIRECTION is zero for forward, or 1 for reverse, + WHERE is the history list number of the current line. If it is + -1, then this line is the starting one. */ +static void +rl_display_search (search_string, reverse_p, where) + char *search_string; + int reverse_p, where; +{ + char *message = (char *)NULL; + + message = + (char *)xmalloc (1 + (search_string ? strlen (search_string) : 0) + 30); + + *message = '\0'; + +#if defined (NOTDEF) + if (where != -1) + sprintf (message, "[%d]", where + history_base); +#endif /* NOTDEF */ + + strcat (message, "("); + + if (reverse_p) + strcat (message, "reverse-"); + + strcat (message, "i-search)`"); + + if (search_string) + strcat (message, search_string); + + strcat (message, "': "); + rl_message ("%s", message, 0); + free (message); + rl_redisplay (); +} + +/* Search through the history looking for an interactively typed string. + This is analogous to i-search. We start the search in the current line. + DIRECTION is which direction to search; >= 0 means forward, < 0 means + backwards. */ +static void +rl_search_history (direction, invoking_key) + int direction; + int invoking_key; +{ + /* The string that the user types in to search for. */ + char *search_string; + + /* The current length of SEARCH_STRING. */ + int search_string_index; + + /* The amount of space that SEARCH_STRING has allocated to it. */ + int search_string_size; + + /* The list of lines to search through. */ + char **lines; + + /* The length of LINES. */ + int hlen; + + /* Where we get LINES from. */ + HIST_ENTRY **hlist = history_list (); + + register int i = 0; + int orig_point = rl_point; + int orig_line = where_history (); + int last_found_line = orig_line; + int c, done = 0; + + /* The line currently being searched. */ + char *sline; + + /* Offset in that line. */ + int index; + + /* Non-zero if we are doing a reverse search. */ + int reverse = (direction < 0); + + /* Create an arrary of pointers to the lines that we want to search. */ + maybe_replace_line (); + if (hlist) + for (i = 0; hlist[i]; i++); + + /* Allocate space for this many lines, +1 for the current input line, + and remember those lines. */ + lines = (char **)alloca ((1 + (hlen = i)) * sizeof (char *)); + for (i = 0; i < hlen; i++) + lines[i] = hlist[i]->line; + + if (saved_line_for_history) + lines[i] = saved_line_for_history->line; + else + /* So I have to type it in this way instead. */ + { + char *alloced_line; + + /* Keep that MIPS alloca () happy. */ + alloced_line = (char *)alloca (1 + strlen (rl_line_buffer)); + lines[i] = alloced_line; + strcpy (lines[i], &rl_line_buffer[0]); + } + + hlen++; + + /* The line where we start the search. */ + i = orig_line; + + /* Initialize search parameters. */ + search_string = (char *)xmalloc (search_string_size = 128); + *search_string = '\0'; + search_string_index = 0; + + /* Normalize DIRECTION into 1 or -1. */ + if (direction >= 0) + direction = 1; + else + direction = -1; + + rl_display_search (search_string, reverse, -1); + + sline = rl_line_buffer; + index = rl_point; + + while (!done) + { + c = rl_read_key (); + + /* Hack C to Do What I Mean. */ + { + Function *f = (Function *)NULL; + + if (_rl_keymap[c].type == ISFUNC) + { + f = _rl_keymap[c].function; + + if (f == rl_reverse_search_history) + c = reverse ? -1 : -2; + else if (f == rl_forward_search_history) + c = !reverse ? -1 : -2; + } + } + + switch (c) + { + case ESC: + done = 1; + continue; + + /* case invoking_key: */ + case -1: + goto search_again; + + /* switch directions */ + case -2: + direction = -direction; + reverse = (direction < 0); + + goto do_search; + + case CTRL ('G'): + strcpy (rl_line_buffer, lines[orig_line]); + rl_point = orig_point; + rl_end = strlen (rl_line_buffer); + rl_clear_message (); + return; + + default: + if (c < 32 || c > 126) + { + rl_execute_next (c); + done = 1; + continue; + } + else + { + if (search_string_index + 2 >= search_string_size) + search_string = (char *)xrealloc + (search_string, (search_string_size += 128)); + search_string[search_string_index++] = c; + search_string[search_string_index] = '\0'; + goto do_search; + + search_again: + + if (!search_string_index) + continue; + else + { + if (reverse) + --index; + else + if (index != strlen (sline)) + ++index; + else + ding (); + } + do_search: + + while (1) + { + if (reverse) + { + while (index >= 0) + if (strncmp + (search_string, sline + index, search_string_index) + == 0) + goto string_found; + else + index--; + } + else + { + register int limit = + (strlen (sline) - search_string_index) + 1; + + while (index < limit) + { + if (strncmp (search_string, + sline + index, + search_string_index) == 0) + goto string_found; + index++; + } + } + + next_line: + i += direction; + + /* At limit for direction? */ + if ((reverse && i < 0) || + (!reverse && i == hlen)) + goto search_failed; + + sline = lines[i]; + if (reverse) + index = strlen (sline); + else + index = 0; + + /* If the search string is longer than the current + line, no match. */ + if (search_string_index > (int)strlen (sline)) + goto next_line; + + /* Start actually searching. */ + if (reverse) + index -= search_string_index; + } + + search_failed: + /* We cannot find the search string. Ding the bell. */ + ding (); + i = last_found_line; + break; + + string_found: + /* We have found the search string. Just display it. But don't + actually move there in the history list until the user accepts + the location. */ + { + int line_len; + + line_len = strlen (lines[i]); + + if (line_len >= rl_line_buffer_len) + rl_extend_line_buffer (line_len); + + strcpy (rl_line_buffer, lines[i]); + rl_point = index; + rl_end = line_len; + last_found_line = i; + rl_display_search + (search_string, reverse, (i == orig_line) ? -1 : i); + } + } + } + continue; + } + + /* The searching is over. The user may have found the string that she + was looking for, or else she may have exited a failing search. If + INDEX is -1, then that shows that the string searched for was not + found. We use this to determine where to place rl_point. */ + { + int now = last_found_line; + + /* First put back the original state. */ + strcpy (rl_line_buffer, lines[orig_line]); + + /* Free the search string. */ + free (search_string); + + if (now < orig_line) + rl_get_previous_history (orig_line - now); + else + rl_get_next_history (now - orig_line); + + /* If the index of the "matched" string is less than zero, then the + final search string was never matched, so put point somewhere + reasonable. */ + if (index < 0) + index = strlen (rl_line_buffer); + + rl_point = index; + rl_clear_message (); + } +} diff --git a/readline/parens.c b/readline/parens.c new file mode 100644 index 00000000000..2c96012352c --- /dev/null +++ b/readline/parens.c @@ -0,0 +1,115 @@ +/* parens.c -- Implemenation of matching parenthesis feature. */ + +/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc. + + This file is part of the GNU Readline Library, a library for + reading lines of text with interactive input and history editing. + + The GNU Readline Library 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 1, or + (at your option) any later version. + + The GNU Readline Library 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. + + The GNU General Public License is often shipped with GNU software, and + is generally kept in a file called COPYING or LICENSE. If you do not + have a copy of the license, write to the Free Software Foundation, + 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#include +#include +#include +#include "readline.h" + +/* Non-zero means try to blink the matching open parenthesis when the + close parenthesis is inserted. */ +#if defined (FD_SET) +int rl_blink_matching_paren = 1; +#else /* !FD_SET */ +int rl_blink_matching_paren = 0; +#endif /* !FD_SET */ + +static int find_matching_open (); + +rl_insert_close (count, invoking_key) + int count, invoking_key; +{ + extern int rl_explicit_arg; + + if (rl_explicit_arg || !rl_blink_matching_paren) + rl_insert (count, invoking_key); + else + { +#if defined (FD_SET) + int orig_point, match_point, ready; + struct timeval timer; + fd_set readfds; + + rl_insert (1, invoking_key); + rl_redisplay (); + match_point = + find_matching_open (rl_line_buffer, rl_point - 2, invoking_key); + + /* Emacs might message or ring the bell here, but I don't. */ + if (match_point < 0) + return; + + FD_ZERO (&readfds); + FD_SET (fileno (rl_instream), &readfds); + timer.tv_sec = 1; + timer.tv_usec = 500; + + orig_point = rl_point; + rl_point = match_point; + rl_redisplay (); + ready = select (1, &readfds, (fd_set *)NULL, (fd_set *)NULL, &timer); + rl_point = orig_point; +#else /* !FD_SET */ + rl_insert (count, invoking_key); +#endif /* !FD_SET */ + } +} + +static int +find_matching_open (string, from, closer) + char *string; + int from, closer; +{ + register int i; + int opener, level, delimiter; + + switch (closer) + { + case ']': opener = '['; break; + case '}': opener = '{'; break; + case ')': opener = '('; break; + default: + return (-1); + } + + level = 1; /* The closer passed in counts as 1. */ + delimiter = 0; /* Delimited state unknown. */ + + for (i = from; i > -1; i--) + { + if (delimiter && (string[i] == delimiter)) + delimiter = 0; + else if ((string[i] == '\'') || (string[i] == '"')) + delimiter = rl_line_buffer[i]; + else if (!delimiter && (string[i] == closer)) + level++; + else if (!delimiter && (string[i] == opener)) + level--; + + if (!level) + break; + } + return (i); +} + + + diff --git a/readline/readline.c b/readline/readline.c index a8363c5dfa8..b05a7c97e5b 100644 --- a/readline/readline.c +++ b/readline/readline.c @@ -36,7 +36,13 @@ static char *xmalloc (), *xrealloc (); #include #include -#include "sysdep.h" +#ifdef __GNUC__ +#define alloca __builtin_alloca +#else +#if defined (sparc) && defined (sun) +#include +#endif +#endif #define NEW_TTY_DRIVER #if defined (SYSV) || defined (hpux) || defined (Xenix) @@ -1497,7 +1503,7 @@ update_line (old, new, current_line) wsatend = 1; /* flag for trailing whitespace */ ols = oe - 1; /* find last same */ nls = ne - 1; - while ((ols > ofd) && (nls > nfd) && (*ols == *nls)) + while ((*ols == *nls) && (ols > ofd) && (nls > nfd)) { if (*ols != ' ') wsatend = 0; @@ -1833,7 +1839,8 @@ init_terminal_io (terminal_name) return; } - PC = tgetstr ("pc", &buffer)? *buffer : 0; + BC = tgetstr ("pc", &buffer); + PC = buffer ? *buffer : 0; term_backspace = tgetstr ("le", &buffer); @@ -2204,12 +2211,12 @@ rl_deprep_terminal () int allow_pathname_alphabetic_chars = 0; char *pathname_alphabetic_chars = "/-_=~.#$"; -char *rindex (); + int alphabetic (c) int c; { - + char *rindex (); if (pure_alphabetic (c) || (numeric (c))) return (1); @@ -3322,7 +3329,7 @@ rl_complete_internal (what_to_do) /* Handle simple case first. What if there is only one answer? */ if (!matches[1]) { - char *temp; + char *rindex (), *temp; if (rl_filename_completion_desired) temp = rindex (matches[0], '/'); @@ -3345,7 +3352,7 @@ rl_complete_internal (what_to_do) is. */ for (i = 1; matches[i]; i++) { - char *temp = (char *)NULL; + char *rindex (), *temp = (char *)NULL; /* If we are hacking filenames, then only count the characters after the last slash in the pathname. */ @@ -3412,7 +3419,7 @@ rl_complete_internal (what_to_do) } else { - char *temp = (char *)NULL; + char *rindex (), *temp = (char *)NULL; if (rl_filename_completion_desired) temp = rindex (matches[l], '/'); @@ -4639,7 +4646,7 @@ filename_completion_function (text, state) /* If we don't have any state, then do some initialization. */ if (!state) { - char *temp; + char *rindex (), *temp; if (dirname) free (dirname); if (filename) free (filename); @@ -5195,7 +5202,7 @@ rl_parse_and_bind (string) char *string; { extern char *possible_control_prefixes[], *possible_meta_prefixes[]; - char *funname, *kname; + char *rindex (), *funname, *kname; static int substring_member_of_array (); register int c; int key, i; diff --git a/readline/readline.texi b/readline/readline.texi deleted file mode 100755 index abb63519269..00000000000 --- a/readline/readline.texi +++ /dev/null @@ -1,442 +0,0 @@ -\input texinfo @c -*-texinfo-*- -@comment %**start of header (This is for running Texinfo on a region.) -@setfilename readline.info -@settitle Line Editing Commands -@comment %**end of header (This is for running Texinfo on a region.) -@synindex fn vr - -@ifinfo -@format -START-INFO-DIR-ENTRY -* Readline: (readline). The GNU Readline Library. -END-INFO-DIR-ENTRY -@end format -@end ifinfo - -@iftex -@comment finalout -@end iftex - -@ifinfo -This document describes the GNU Readline Library, a utility for aiding -in the consitency of user interface across discrete programs that need -to provide a command line interface. - -Copyright (C) 1988 Free Software Foundation, Inc. - -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -pare preserved on all copies. - -@ignore -Permission is granted to process this file through TeX and print the -results, provided the printed document carries copying permission -notice identical to this one except for the removal of this paragraph -(this paragraph not being relevant to the printed manual). - -@end ignore -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided that the entire -resulting derived work is distributed under the terms of a permission -notice identical to this one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions, -except that this permission notice may be stated in a translation approved -by the Foundation. -@end ifinfo - -@setchapternewpage odd -@titlepage -@sp 11 -@center @titlefont{GNU Readline Library} -@sp 2 -@center by Brian Fox -@sp 2 -@center Version 1.0 -@sp 2 -@center February 1989 - -@comment Include the Distribution inside the titlepage environment so -@c that headings are turned off. - -@page -@vskip 0pt plus 1filll -Copyright @copyright{} 1989 Free Software Foundation, Inc. - -@sp 2 -This document describes the GNU Readline Library, a utility for aiding -in the consistency of user interface across discrete programs that need -to provide a command line interface. -@sp 2 - -Published by the Free Software Foundation @* -675 Massachusetts Avenue, @* -Cambridge, MA 02139 USA - -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. - -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided that the entire -resulting derived work is distributed under the terms of a permission -notice identical to this one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions, -except that this permission notice may be stated in a translation approved -by the Foundation. - -@end titlepage - -@node Top, , ,(DIR) -@chapter GNU Readline Library - -@ifinfo -This document describes the GNU Readline Library, a utility for aiding -in the consistency of user interface across discrete programs that need -to provide a command line interface. -@end ifinfo - -@menu -* Command Line Editing:: GNU Readline User's Manual -* Readline Technical:: GNU Readline Programmer's Manual -@end menu -@include inc-read.texi -@node Readline Technical, , Top, Top -@chapter Readline Programmer's Manual - -This manual describes the interface between the GNU Readline Library and -user programs. If you are a programmer, and you wish to include the -features found in GNU Readline in your own programs, such as completion, -line editing, and interactive history manipulation, this documentation -is for you. - -@menu -* Default Behaviour:: Using the default behaviour of Readline. -* Custom Functions:: Adding your own functions to Readline. -* Custom Completers:: Supplanting or supplementing Readline's - completion functions. -* Variable Index:: Index of externally tweakable variables. -@end menu - -@node Default Behaviour, Custom Functions, Readline Technical, Readline Technical -@section Default Behaviour - -Many programs provide a command line interface, such as @code{mail}, -@code{ftp}, and @code{sh}. For such programs, the default behaviour of -Readline is sufficient. This section describes how to use Readline in -the simplest way possible, perhaps to replace calls in your code to -@code{gets ()}. - -@findex readline () -@cindex readline, function -The function @code{readline} prints a prompt and then reads and returns -a single line of text from the user. The line which @code{readline ()} -returns is allocated with @code{malloc ()}; you should @code{free ()} -the line when you are done with it. The declaration in ANSI C is - -@example -@code{char *readline (char *@var{prompt});} -@end example -or, preferably, -@example -@code{#include } -@end example - -So, one might say -@example -@code{char *line = readline ("Enter a line: ");} -@end example -in order to read a line of text from the user. - -The line which is returned has the final newline removed, so only the -text of the line remains. - -If readline encounters an EOF while reading the line, and the line is -empty at that point, then @code{(char *)NULL} is returned. Otherwise, -the line is ended just as if a newline was typed. - -If you want the user to be able to get at the line later, (with -@key{C-p} for example), you must call @code{add_history ()} to save the -line away in a @dfn{history} list of such lines. - -@example -@code{add_history (line)}; -@end example - -If you use @code{add_history ()}, you should also -@code{#include } -For full details on the GNU History Library, see the associated manual. - -It is polite to avoid saving empty lines on the history list, since -no one has a burning need to reuse a blank line. Here is a function -which usefully replaces the standard @code{gets ()} library function: - -@example -#include -#include - -/* A static variable for holding the line. */ -static char *my_gets_line = (char *)NULL; - -/* Read a string, and return a pointer to it. Returns NULL on EOF. */ -char * -my_gets () -@{ - /* If the buffer has already been allocated, return the memory - to the free pool. */ - if (my_gets_line != (char *)NULL) - free (my_gets_line); - - /* Get a line from the user. */ - my_gets_line = readline (""); - - /* If the line has any text in it, save it on the history. */ - if (my_get_line && *my_gets_line) - add_history (my_gets_line); - - return (my_gets_line); -@} -@end example - -The above code gives the user the default behaviour of @key{TAB} -completion: completion on file names. If you do not want readline to -complete on filenames, you can change the binding of the @key{TAB} key -with @code{rl_bind_key ()}. - -@findex rl_bind_key () - -@example -@code{int rl_bind_key (int @var{key}, (int (*)())@var{function});} -@end example - -@code{rl_bind_key ()} takes 2 arguments; @var{key} is the character that -you want to bind, and @var{function} is the address of the function to -run when @var{key} is pressed. Binding @key{TAB} to @code{rl_insert ()} -makes @key{TAB} just insert itself. - -@code{rl_bind_key ()} returns non-zero if @var{key} is not a valid -ASCII character code (between 0 and 255). - -@example -@code{rl_bind_key ('\t', rl_insert);} -@end example - -@node Custom Functions, Custom Completers, Default Behaviour, Readline Technical -@section Custom Functions - -Readline provides a great many functions for manipulating the text of -the line. But it isn't possible to anticipate the needs of all -programs. This section describes the various functions and variables -defined in within the Readline library which allow a user program to add -customized functionality to Readline. - -@menu -* The Function Type:: C declarations to make code readable. -* Function Naming:: How to give a function you write a name. -* Keymaps:: Making keymaps. -* Binding Keys:: Changing Keymaps. -* Function Writing:: Variables and calling conventions. -* Allowing Undoing:: How to make your functions undoable. -@end menu - -@node The Function Type, Function Naming, Custom Functions, Custom Functions -For the sake of readabilty, we declare a new type of object, called -@dfn{Function}. `Function' is a C language function which returns an -@code{int}. The type declaration for `Function' is: - -@code{typedef int Function ();} - -The reason for declaring this new type is to make it easier to discuss -pointers to C functions. Let us say we had a variable called @var{func} -which was a pointer to a function. Instead of the classic C declaration - -@code{int (*)()func;} - -we have - -@code{Function *func;} - -@node Function Naming, Keymaps, The Function Type, Custom Functions -@subsection Naming a Function - -The user can dynamically change the bindings of keys while using -Readline. This is done by representing the function with a descriptive -name. The user is able to type the descriptive name when referring to -the function. Thus, in an init file, one might find - -@example -Meta-Rubout: backward-kill-word -@end example - -This binds @key{Meta-Rubout} to the function @emph{descriptively} named -@code{backward-kill-word}. You, as a programmer, should bind the -functions you write to descriptive names as well. Here is how to do -that. - -@defun rl_add_defun (char *name, Function *function, int key) -Add @var{name} to the list of named functions. Make @var{function} be -the function that gets called. If @var{key} is not -1, then bind it to -@var{function} using @code{rl_bind_key ()}. -@end defun - -Using this function alone is sufficient for most applications. It is -the recommended way to add a few functions to the default functions that -Readline has built in already. If you need to do more or different -things than adding a function to Readline, you may need to use the -underlying functions described below. - -@node Keymaps, Binding Keys, Function Naming, Custom Functions -@subsection Selecting a Keymap - -Key bindings take place on a @dfn{keymap}. The keymap is the -association between the keys that the user types and the functions that -get run. You can make your own keymaps, copy existing keymaps, and tell -Readline which keymap to use. - -@defun rl_make_bare_keymap () -Returns a new, empty keymap. The space for the keymap is allocated with -@code{malloc ()}; you should @code{free ()} it when you are done. -@end defun - -@defun rl_copy_keymap (Keymap map) -Return a new keymap which is a copy of @var{map}. -@end defun - -@defun rl_make_keymap () -Return a new keymap with the printing characters bound to rl_insert, -the lowercase Meta characters bound to run their equivalents, and -the Meta digits bound to produce numeric arguments. -@end defun - -@node Binding Keys, Function Writing, Keymaps, Custom Functions -@subsection Binding Keys - -You associate keys with functions through the keymap. Here are -the functions for doing that. - -@defun rl_bind_key (int key, Function *function) -Binds @var{key} to @var{function} in the currently selected keymap. -Returns non-zero in the case of an invalid @var{key}. -@end defun - -@defun rl_bind_key_in_map (int key, Function *function, Keymap map) -Bind @var{key} to @var{function} in @var{map}. Returns non-zero in the case -of an invalid @var{key}. -@end defun - -@defun rl_unbind_key (int key) -Make @var{key} do nothing in the currently selected keymap. -Returns non-zero in case of error. -@end defun - -@defun rl_unbind_key_in_map (int key, Keymap map) -Make @var{key} be bound to the null function in @var{map}. -Returns non-zero in case of error. -@end defun - -@node Function Writing, Allowing Undoing, Binding Keys, Custom Functions -@subsection Writing a New Function - -In order to write new functions for Readline, you need to know the -calling conventions for keyboard invoked functions, and the names of the -variables that describe the current state of the line gathered so far. - -@defvar char *rl_line_buffer -This is the line gathered so far. You are welcome to modify the -contents of this, but see Undoing, below. -@end defvar - -@defvar int rl_point -The offset of the current cursor position in @var{rl_line_buffer}. -@end defvar - -@defvar int rl_end -The number of characters present in @code{rl_line_buffer}. When -@code{rl_point} is at the end of the line, then @code{rl_point} and -@code{rl_end} are equal. -@end defvar - -The calling sequence for a command @code{foo} looks like - -@example -@code{foo (count, key)} -@end example - -where @var{count} is the numeric argument (or 1 if defaulted) and -@var{key} is the key that invoked this function. - -It is completely up to the function as to what should be done with the -numeric argument; some functions use it as a repeat count, other -functions as a flag, and some choose to ignore it. In general, if a -function uses the numeric argument as a repeat count, it should be able -to do something useful with a negative argument as well as a positive -argument. At the very least, it should be aware that it can be passed a -negative argument. - -@node Allowing Undoing, , Function Writing, Custom Functions -@subsection Allowing Undoing - -Supporting the undo command is a painless thing to do, and makes your -function much more useful to the end user. It is certainly easy to try -something if you know you can undo it. I could use an undo function for -the stock market. - -If your function simply inserts text once, or deletes text once, and it -calls @code{rl_insert_text ()} or @code{rl_delete_text ()} to do it, then -undoing is already done for you automatically, and you can safely skip -this section. - -If you do multiple insertions or multiple deletions, or any combination -of these operations, you will want to group them together into one -operation. This can be done with @code{rl_begin_undo_group ()} and -@code{rl_end_undo_group ()}. - -@defun rl_begin_undo_group () -Begins saving undo information in a group construct. The undo -information usually comes from calls to @code{rl_insert_text ()} and -@code{rl_delete_text ()}, but they could be direct calls to -@code{rl_add_undo ()}. -@end defun - -@defun rl_end_undo_group () -Closes the current undo group started with @code{rl_begin_undo_group -()}. There should be exactly one call to @code{rl_end_undo_group ()} -for every call to @code{rl_begin_undo_group ()}. -@end defun - -Finally, if you neither insert nor delete text, but directly modify the -existing text (e.g. change its case), you call @code{rl_modifying ()} -once, just before you modify the text. You must supply the indices of -the text range that you are going to modify. - -@defun rl_modifying (int start, int end) -Tell Readline to save the text between @var{start} and @var{end} as a -single undo unit. It is assumed that subsequent to this call you will -modify that range of text in some way. -@end defun - -@subsection An Example - -Let us say that we are actually going to put an example here. - -@node Custom Completers, Variable Index, Custom Functions, Readline Technical - -Typically, a program that reads commands from the user has a way of -disambiguating between commands and data. If your program is one of -these, then it can provide completion for either commands, or data, or -both commands and data. The following sections describe how your -program and Readline cooperate to provide this service to end users. - -@menu -@end menu - -@node Variable Index, , Custom Completers, Readline Technical -@appendix Variable Index -@printindex vr -@contents - -@bye - diff --git a/readline/readline.texinfo b/readline/readline.texinfo deleted file mode 100755 index 36fe7a98ee8..00000000000 --- a/readline/readline.texinfo +++ /dev/null @@ -1,434 +0,0 @@ -\input texinfo @c -*-texinfo-*- -@comment %**start of header (This is for running Texinfo on a region.) -@setfilename readline.info -@settitle Line Editing Commands -@comment %**end of header (This is for running Texinfo on a region.) -@synindex fn vr - -@iftex -@comment finalout -@end iftex - -@ifinfo -This document describes the GNU Readline Library, a utility for aiding -in the consitency of user interface across discrete programs that need -to provide a command line interface. - -Copyright (C) 1988 Free Software Foundation, Inc. - -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -pare preserved on all copies. - -@ignore -Permission is granted to process this file through TeX and print the -results, provided the printed document carries copying permission -notice identical to this one except for the removal of this paragraph -(this paragraph not being relevant to the printed manual). - -@end ignore -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided that the entire -resulting derived work is distributed under the terms of a permission -notice identical to this one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions, -except that this permission notice may be stated in a translation approved -by the Foundation. -@end ifinfo - -@setchapternewpage odd -@titlepage -@sp 11 -@center @titlefont{GNU Readline Library} -@sp 2 -@center by Brian Fox -@sp 2 -@center Version 1.0 -@sp 2 -@center February 1989 - -@comment Include the Distribution inside the titlepage environment so -@c that headings are turned off. - -@page -@vskip 0pt plus 1filll -Copyright @copyright{} 1989 Free Software Foundation, Inc. - -@sp 2 -This document describes the GNU Readline Library, a utility for aiding -in the consistency of user interface across discrete programs that need -to provide a command line interface. -@sp 2 - -Published by the Free Software Foundation @* -675 Massachusetts Avenue, @* -Cambridge, MA 02139 USA - -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. - -Permission is granted to copy and distribute modified versions of this -manual under the conditions for verbatim copying, provided that the entire -resulting derived work is distributed under the terms of a permission -notice identical to this one. - -Permission is granted to copy and distribute translations of this manual -into another language, under the above conditions for modified versions, -except that this permission notice may be stated in a translation approved -by the Foundation. - -@end titlepage - -@node Top, Readline Top, ,(DIR) -@chapter GNU Readline Library - -@ifinfo -This document describes the GNU Readline Library, a utility for aiding -in the consistency of user interface across discrete programs that need -to provide a command line interface. -@end ifinfo - -@menu -* Readline Top:: GNU Readline User's Manual -* Readline Technical:: GNU Readline Programmer's Manual -@end menu -@include inc-readline.texinfo -@node Readline Technical, , Top, Top -@chapter Readline Programmer's Manual - -This manual describes the interface between the GNU Readline Library and -user programs. If you are a programmer, and you wish to include the -features found in GNU Readline in your own programs, such as completion, -line editing, and interactive history manipulation, this documentation -is for you. - -@menu -* Default Behaviour:: Using the default behaviour of Readline. -* Custom Functions:: Adding your own functions to Readline. -* Custom Completers:: Supplanting or supplementing Readline's - completion functions. -* Variable Index:: Index of externally tweakable variables. -@end menu - -@node Default Behaviour, Custom Functions, Readline Technical, Readline Technical -@section Default Behaviour - -Many programs provide a command line interface, such as @code{mail}, -@code{ftp}, and @code{sh}. For such programs, the default behaviour of -Readline is sufficient. This section describes how to use Readline in -the simplest way possible, perhaps to replace calls in your code to -@code{gets ()}. - -@findex readline () -@cindex readline, function -The function @code{readline} prints a prompt and then reads and returns -a single line of text from the user. The line which @code{readline ()} -returns is allocated with @code{malloc ()}; you should @code{free ()} -the line when you are done with it. The declaration in ANSI C is - -@example -@code{char *readline (char *@var{prompt});} -@end example -or, preferably, -@example -@code{#include } -@end example - -So, one might say -@example -@code{char *line = readline ("Enter a line: ");} -@end example -in order to read a line of text from the user. - -The line which is returned has the final newline removed, so only the -text of the line remains. - -If readline encounters an EOF while reading the line, and the line is -empty at that point, then @code{(char *)NULL} is returned. Otherwise, -the line is ended just as if a newline was typed. - -If you want the user to be able to get at the line later, (with -@key{C-p} for example), you must call @code{add_history ()} to save the -line away in a @dfn{history} list of such lines. - -@example -@code{add_history (line)}; -@end example - -If you use @code{add_history ()}, you should also -@code{#include } -For full details on the GNU History Library, see the associated manual. - -It is polite to avoid saving empty lines on the history list, since -no one has a burning need to reuse a blank line. Here is a function -which usefully replaces the standard @code{gets ()} library function: - -@example -#include -#include - -/* A static variable for holding the line. */ -static char *my_gets_line = (char *)NULL; - -/* Read a string, and return a pointer to it. Returns NULL on EOF. */ -char * -my_gets () -@{ - /* If the buffer has already been allocated, return the memory - to the free pool. */ - if (my_gets_line != (char *)NULL) - free (my_gets_line); - - /* Get a line from the user. */ - my_gets_line = readline (""); - - /* If the line has any text in it, save it on the history. */ - if (my_get_line && *my_gets_line) - add_history (my_gets_line); - - return (my_gets_line); -@} -@end example - -The above code gives the user the default behaviour of @key{TAB} -completion: completion on file names. If you do not want readline to -complete on filenames, you can change the binding of the @key{TAB} key -with @code{rl_bind_key ()}. - -@findex rl_bind_key () - -@example -@code{int rl_bind_key (int @var{key}, (int (*)())@var{function});} -@end example - -@code{rl_bind_key ()} takes 2 arguments; @var{key} is the character that -you want to bind, and @var{function} is the address of the function to -run when @var{key} is pressed. Binding @key{TAB} to @code{rl_insert ()} -makes @key{TAB} just insert itself. - -@code{rl_bind_key ()} returns non-zero if @var{key} is not a valid -ASCII character code (between 0 and 255). - -@example -@code{rl_bind_key ('\t', rl_insert);} -@end example - -@node Custom Functions, Custom Completers, Default Behaviour, Readline Technical -@section Custom Functions - -Readline provides a great many functions for manipulating the text of -the line. But it isn't possible to anticipate the needs of all -programs. This section describes the various functions and variables -defined in within the Readline library which allow a user program to add -customized functionality to Readline. - -@menu -* The Function Type:: C declarations to make code readable. -* Function Naming:: How to give a function you write a name. -* Keymaps:: Making keymaps. -* Binding Keys:: Changing Keymaps. -* Function Writing:: Variables and calling conventions. -* Allowing Undoing:: How to make your functions undoable. -@end menu - -@node The Function Type, Function Naming, Custom Functions, Custom Functions -For the sake of readabilty, we declare a new type of object, called -@dfn{Function}. `Function' is a C language function which returns an -@code{int}. The type declaration for `Function' is: - -@code{typedef int Function ();} - -The reason for declaring this new type is to make it easier to discuss -pointers to C functions. Let us say we had a variable called @var{func} -which was a pointer to a function. Instead of the classic C declaration - -@code{int (*)()func;} - -we have - -@code{Function *func;} - -@node Function Naming, Keymaps, The Function Type, Custom Functions -@subsection Naming a Function - -The user can dynamically change the bindings of keys while using -Readline. This is done by representing the function with a descriptive -name. The user is able to type the descriptive name when referring to -the function. Thus, in an init file, one might find - -@example -Meta-Rubout: backward-kill-word -@end example - -This binds @key{Meta-Rubout} to the function @emph{descriptively} named -@code{backward-kill-word}. You, as a programmer, should bind the -functions you write to descriptive names as well. Here is how to do -that. - -@defun rl_add_defun (char *name, Function *function, int key) -Add @var{name} to the list of named functions. Make @var{function} be -the function that gets called. If @var{key} is not -1, then bind it to -@var{function} using @code{rl_bind_key ()}. -@end defun - -Using this function alone is sufficient for most applications. It is -the recommended way to add a few functions to the default functions that -Readline has built in already. If you need to do more or different -things than adding a function to Readline, you may need to use the -underlying functions described below. - -@node Keymaps, Binding Keys, Function Naming, Custom Functions -@subsection Selecting a Keymap - -Key bindings take place on a @dfn{keymap}. The keymap is the -association between the keys that the user types and the functions that -get run. You can make your own keymaps, copy existing keymaps, and tell -Readline which keymap to use. - -@defun rl_make_bare_keymap () -Returns a new, empty keymap. The space for the keymap is allocated with -@code{malloc ()}; you should @code{free ()} it when you are done. -@end defun - -@defun rl_copy_keymap (Keymap map) -Return a new keymap which is a copy of @var{map}. -@end defun - -@defun rl_make_keymap () -Return a new keymap with the printing characters bound to rl_insert, -the lowercase Meta characters bound to run their equivalents, and -the Meta digits bound to produce numeric arguments. -@end defun - -@node Binding Keys, Function Writing, Keymaps, Custom Functions -@subsection Binding Keys - -You associate keys with functions through the keymap. Here are -the functions for doing that. - -@defun rl_bind_key (int key, Function *function) -Binds @var{key} to @var{function} in the currently selected keymap. -Returns non-zero in the case of an invalid @var{key}. -@end defun - -@defun rl_bind_key_in_map (int key, Function *function, Keymap map) -Bind @var{key} to @var{function} in @var{map}. Returns non-zero in the case -of an invalid @var{key}. -@end defun - -@defun rl_unbind_key (int key) -Make @var{key} do nothing in the currently selected keymap. -Returns non-zero in case of error. -@end defun - -@defun rl_unbind_key_in_map (int key, Keymap map) -Make @var{key} be bound to the null function in @var{map}. -Returns non-zero in case of error. -@end defun - -@node Function Writing, Allowing Undoing, Binding Keys, Custom Functions -@subsection Writing a New Function - -In order to write new functions for Readline, you need to know the -calling conventions for keyboard invoked functions, and the names of the -variables that describe the current state of the line gathered so far. - -@defvar char *rl_line_buffer -This is the line gathered so far. You are welcome to modify the -contents of this, but see Undoing, below. -@end defvar - -@defvar int rl_point -The offset of the current cursor position in @var{rl_line_buffer}. -@end defvar - -@defvar int rl_end -The number of characters present in @code{rl_line_buffer}. When -@code{rl_point} is at the end of the line, then @code{rl_point} and -@code{rl_end} are equal. -@end defvar - -The calling sequence for a command @code{foo} looks like - -@example -@code{foo (count, key)} -@end example - -where @var{count} is the numeric argument (or 1 if defaulted) and -@var{key} is the key that invoked this function. - -It is completely up to the function as to what should be done with the -numeric argument; some functions use it as a repeat count, other -functions as a flag, and some choose to ignore it. In general, if a -function uses the numeric argument as a repeat count, it should be able -to do something useful with a negative argument as well as a positive -argument. At the very least, it should be aware that it can be passed a -negative argument. - -@node Allowing Undoing, , Function Writing, Custom Functions -@subsection Allowing Undoing - -Supporting the undo command is a painless thing to do, and makes your -function much more useful to the end user. It is certainly easy to try -something if you know you can undo it. I could use an undo function for -the stock market. - -If your function simply inserts text once, or deletes text once, and it -calls @code{rl_insert_text ()} or @code{rl_delete_text ()} to do it, then -undoing is already done for you automatically, and you can safely skip -this section. - -If you do multiple insertions or multiple deletions, or any combination -of these operations, you will want to group them together into one -operation. This can be done with @code{rl_begin_undo_group ()} and -@code{rl_end_undo_group ()}. - -@defun rl_begin_undo_group () -Begins saving undo information in a group construct. The undo -information usually comes from calls to @code{rl_insert_text ()} and -@code{rl_delete_text ()}, but they could be direct calls to -@code{rl_add_undo ()}. -@end defun - -@defun rl_end_undo_group () -Closes the current undo group started with @code{rl_begin_undo_group -()}. There should be exactly one call to @code{rl_end_undo_group ()} -for every call to @code{rl_begin_undo_group ()}. -@end defun - -Finally, if you neither insert nor delete text, but directly modify the -existing text (e.g. change its case), you call @code{rl_modifying ()} -once, just before you modify the text. You must supply the indices of -the text range that you are going to modify. - -@defun rl_modifying (int start, int end) -Tell Readline to save the text between @var{start} and @var{end} as a -single undo unit. It is assumed that subsequent to this call you will -modify that range of text in some way. -@end defun - -@subsection An Example - -Let us say that we are actually going to put an example here. - -@node Custom Completers, Variable Index, Custom Functions, Readline Technical - -Typically, a program that reads commands from the user has a way of -disambiguating between commands and data. If your program is one of -these, then it can provide completion for either commands, or data, or -both commands and data. The following sections describe how your -program and Readline cooperate to provide this service to end users. - -@menu -@end menu - -@node Variable Index, , Custom Completers, Readline Technical -@appendix Variable Index -@printindex vr -@contents - -@bye - diff --git a/readline/rldefs.h b/readline/rldefs.h new file mode 100644 index 00000000000..83411bc4009 --- /dev/null +++ b/readline/rldefs.h @@ -0,0 +1,250 @@ +/* rldefs.h -- an attempt to isolate some of the system-specific defines + for readline. This should be included after any files that define + system-specific constants like _POSIX_VERSION or USG. */ + +/* Copyright (C) 1987,1989 Free Software Foundation, Inc. + + This file contains the Readline Library (the Library), a set of + routines for providing Emacs style line input to programs that ask + for it. + + The Library 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 1, or (at your option) + any later version. + + The Library 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. + + The GNU General Public License is often shipped with GNU software, and + is generally kept in a file called COPYING or LICENSE. If you do not + have a copy of the license, write to the Free Software Foundation, + 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#if !defined (_RLDEFS_H) +#define _RLDEFS_H + +#if defined (__GNUC__) +# undef alloca +# define alloca __builtin_alloca +#else +# if defined (sparc) || defined (HAVE_ALLOCA_H) +# include +# endif +#endif + +#define NEW_TTY_DRIVER +#define HAVE_BSD_SIGNALS +/* #define USE_XON_XOFF */ + +#ifdef __MSDOS__ +#undef NEW_TTY_DRIVER +#undef HAVE_BSD_SIGNALS +#endif + +#if defined (__linux__) +# include +#endif /* __linux__ */ + +/* Some USG machines have BSD signal handling (sigblock, sigsetmask, etc.) */ +#if defined (USG) && !defined (hpux) +# undef HAVE_BSD_SIGNALS +#endif + +/* System V machines use termio. */ +#if !defined (_POSIX_VERSION) +# if defined (USG) || defined (hpux) || defined (Xenix) || defined (sgi) || defined (DGUX) +# undef NEW_TTY_DRIVER +# define TERMIO_TTY_DRIVER +# include +# if !defined (TCOON) +# define TCOON 1 +# endif +# endif /* USG || hpux || Xenix || sgi || DUGX */ +#endif /* !_POSIX_VERSION */ + +/* Posix systems use termios and the Posix signal functions. */ +#if defined (_POSIX_VERSION) +# if !defined (TERMIOS_MISSING) +# undef NEW_TTY_DRIVER +# define TERMIOS_TTY_DRIVER +# include +# endif /* !TERMIOS_MISSING */ +# define HAVE_POSIX_SIGNALS +# if !defined (O_NDELAY) +# define O_NDELAY O_NONBLOCK /* Posix-style non-blocking i/o */ +# endif /* O_NDELAY */ +#endif /* _POSIX_VERSION */ + +/* System V.3 machines have the old 4.1 BSD `reliable' signal interface. */ +#if !defined (HAVE_BSD_SIGNALS) && !defined (HAVE_POSIX_SIGNALS) +# if defined (USGr3) +# if !defined (HAVE_USG_SIGHOLD) +# define HAVE_USG_SIGHOLD +# endif /* !HAVE_USG_SIGHOLD */ +# endif /* USGr3 */ +#endif /* !HAVE_BSD_SIGNALS && !HAVE_POSIX_SIGNALS */ + +/* Other (BSD) machines use sgtty. */ +#if defined (NEW_TTY_DRIVER) +# include +#endif + +/* Define _POSIX_VDISABLE if we are not using the `new' tty driver and + it is not already defined. It is used both to determine if a + special character is disabled and to disable certain special + characters. Posix systems should set to 0, USG systems to -1. */ +#if !defined (NEW_TTY_DRIVER) && !defined (_POSIX_VDISABLE) +# if defined (_POSIX_VERSION) +# define _POSIX_VDISABLE 0 +# else /* !_POSIX_VERSION */ +# define _POSIX_VDISABLE -1 +# endif /* !_POSIX_VERSION */ +#endif /* !NEW_TTY_DRIVER && !_POSIX_VDISABLE */ + +#if 1 +# define D_NAMLEN(d) strlen ((d)->d_name) +#else /* !1 */ + +#if !defined (SHELL) && (defined (_POSIX_VERSION) || defined (USGr3)) +# if !defined (HAVE_DIRENT_H) +# define HAVE_DIRENT_H +# endif /* !HAVE_DIRENT_H */ +#endif /* !SHELL && (_POSIX_VERSION || USGr3) */ + +#if defined (HAVE_DIRENT_H) +# include +# if !defined (direct) +# define direct dirent +# endif /* !direct */ +# define D_NAMLEN(d) strlen ((d)->d_name) +#else /* !HAVE_DIRENT_H */ +# define D_NAMLEN(d) ((d)->d_namlen) +# if defined (USG) +# if defined (Xenix) +# include +# else /* !Xenix (but USG...) */ +# include "ndir.h" +# endif /* !Xenix */ +# else /* !USG */ +# include +# endif /* !USG */ +#endif /* !HAVE_DIRENT_H */ +#endif /* !1 */ + +#if defined (USG) && defined (TIOCGWINSZ) && !defined (Linux) +# include +# if defined (HAVE_SYS_PTEM_H) +# include +# endif /* HAVE_SYS_PTEM_H */ +# if defined (HAVE_SYS_PTE_H) +# include +# endif /* HAVE_SYS_PTE_H */ +#endif /* USG && TIOCGWINSZ && !Linux */ + +/* Posix macro to check file in statbuf for directory-ness. + This requires that be included before this test. */ +#if defined (S_IFDIR) && !defined (S_ISDIR) +#define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR) +#endif + +/* Decide which flavor of the header file describing the C library + string functions to include and include it. */ + +#if defined (USG) || defined (NeXT) +# if !defined (HAVE_STRING_H) +# define HAVE_STRING_H +# endif /* !HAVE_STRING_H */ +#endif /* USG || NeXT */ + +#if defined (HAVE_STRING_H) +# include +#else /* !HAVE_STRING_H */ +# include +#endif /* !HAVE_STRING_H */ + +#if !defined (strchr) && !defined (__STDC__) +extern char *strchr (), *strrchr (); +#endif /* !strchr && !__STDC__ */ + +#if defined (HAVE_VARARGS_H) +# include +#endif /* HAVE_VARARGS_H */ + +/* This definition is needed by readline.c, rltty.c, and signals.c. */ +/* If on, then readline handles signals in a way that doesn't screw. */ +#define HANDLE_SIGNALS + +#if !defined (emacs_mode) +# define no_mode -1 +# define vi_mode 0 +# define emacs_mode 1 +#endif + +/* Define some macros for dealing with assorted signalling disciplines. + + These macros provide a way to use signal blocking and disabling + without smothering your code in a pile of #ifdef's. + + SIGNALS_UNBLOCK; Stop blocking all signals. + + { + SIGNALS_DECLARE_SAVED (name); Declare a variable to save the + signal blocking state. + ... + SIGNALS_BLOCK (SIGSTOP, name); Block a signal, and save the previous + state for restoration later. + ... + SIGNALS_RESTORE (name); Restore previous signals. + } + +*/ + +#ifdef HAVE_POSIX_SIGNALS + /* POSIX signals */ + +#define SIGNALS_UNBLOCK \ + do { sigset_t set; \ + sigemptyset (&set); \ + sigprocmask (SIG_SETMASK, &set, (sigset_t *)NULL); \ + } while (0) + +#define SIGNALS_DECLARE_SAVED(name) sigset_t name + +#define SIGNALS_BLOCK(SIG, saved) \ + do { sigset_t set; \ + sigemptyset (&set); \ + sigaddset (&set, SIG); \ + sigprocmask (SIG_BLOCK, &set, &saved); \ + } while (0) + +#define SIGNALS_RESTORE(saved) \ + sigprocmask (SIG_SETMASK, &saved, (sigset_t *)NULL) + + +#else /* HAVE_POSIX_SIGNALS */ +#ifdef HAVE_BSD_SIGNALS + /* BSD signals */ + +#define SIGNALS_UNBLOCK sigsetmask (0) +#define SIGNALS_DECLARE_SAVED(name) int name +#define SIGNALS_BLOCK(SIG, saved) saved = sigblock (sigmask (SIG)) +#define SIGNALS_RESTORE(saved) sigsetmask (saved) + + +#else /* HAVE_BSD_SIGNALS */ + /* None of the Above */ + +#define SIGNALS_UNBLOCK /* nothing */ +#define SIGNALS_DECLARE_SAVED(name) /* nothing */ +#define SIGNALS_BLOCK(SIG, saved) /* nothing */ +#define SIGNALS_RESTORE(saved) /* nothing */ + + +#endif /* HAVE_BSD_SIGNALS */ +#endif /* HAVE_POSIX_SIGNALS */ + +/* End of signal handling definitions. */ +#endif /* !_RLDEFS_H */ diff --git a/readline/search.c b/readline/search.c new file mode 100644 index 00000000000..ea98c6f8975 --- /dev/null +++ b/readline/search.c @@ -0,0 +1,271 @@ +/* search.c - code for non-incremental searching in emacs and vi modes. */ + +/* Copyright (C) 1992 Free Software Foundation, Inc. + + This file is part of the Readline Library (the Library), a set of + routines for providing Emacs style line input to programs that ask + for it. + + The Library 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 1, or (at your option) + any later version. + + The Library 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. + + The GNU General Public License is often shipped with GNU software, and + is generally kept in a file called COPYING or LICENSE. If you do not + have a copy of the license, write to the Free Software Foundation, + 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#include + +#if defined (__GNUC__) +# define alloca __builtin_alloca +#else +# if defined (sparc) || defined (HAVE_ALLOCA_H) +# include +# endif +#endif + +#include "readline.h" +#include "history.h" + +extern char *xmalloc (), *xrealloc (); + +/* Variables imported from readline.c */ +extern int rl_point, rl_end, rl_line_buffer_len; +extern Keymap _rl_keymap; +extern char *rl_prompt; +extern char *rl_line_buffer; +extern HIST_ENTRY *saved_line_for_history; + +static char *noninc_search_string = (char *) NULL; +static int noninc_history_pos = 0; + +/* Search the history list for STRING starting at absolute history position + POS. If STRING begins with `^', the search must match STRING at the + beginning of a history line, otherwise a full substring match is performed + for STRING. DIR < 0 means to search backwards through the history list, + DIR >= 0 means to search forward. */ +static int +noninc_search_from_pos (string, pos, dir) + char *string; + int pos, dir; +{ + int ret, old; + + old = where_history (); + history_set_pos (pos); + + if (*string == '^') + ret = history_search_prefix (string + 1, dir); + else + ret = history_search (string, dir); + + if (ret != -1) + ret = where_history (); + + history_set_pos (old); + return (ret); +} + +/* Search for a line in the history containing STRING. If DIR is < 0, the + search is backwards through previous entries, else through subsequent + entries. */ +static void +noninc_dosearch (string, dir) + char *string; + int dir; +{ + int oldpos, pos; + HIST_ENTRY *entry; + + if (string == 0 || *string == 0 || noninc_history_pos < 0) + { + ding (); + return; + } + + pos = noninc_search_from_pos (string, noninc_history_pos + dir, dir); + if (pos == -1) + { + /* Search failed, current history position unchanged. */ + maybe_unsave_line (); + rl_clear_message (); + rl_point = 0; + ding (); + return; + } + + noninc_history_pos = pos; + + oldpos = where_history (); + history_set_pos (noninc_history_pos); + entry = current_history (); + history_set_pos (oldpos); + + { + int line_len; + + line_len = strlen (entry->line); + if (line_len >= rl_line_buffer_len) + rl_extend_line_buffer (line_len); + strcpy (rl_line_buffer, entry->line); + } + + rl_undo_list = (UNDO_LIST *)entry->data; + rl_end = strlen (rl_line_buffer); + rl_point = 0; + rl_clear_message (); + + if (saved_line_for_history) + free_history_entry (saved_line_for_history); + saved_line_for_history = (HIST_ENTRY *)NULL; +} + +/* Search non-interactively through the history list. DIR < 0 means to + search backwards through the history of previous commands; otherwise + the search is for commands subsequent to the current position in the + history list. PCHAR is the character to use for prompting when reading + the search string; if not specified (0), it defaults to `:'. */ +static void +noninc_search (dir, pchar) + int dir; + int pchar; +{ + int saved_point, c, pmtlen; + char *p; + + maybe_save_line (); + saved_point = rl_point; + + /* Use the line buffer to read the search string. */ + rl_line_buffer[0] = 0; + rl_end = rl_point = 0; + + pmtlen = (rl_prompt && *rl_prompt) ? strlen (rl_prompt) : 0; + p = (char *)alloca (2 + pmtlen); + if (pmtlen) + strcpy (p, rl_prompt); + p[pmtlen] = pchar ? pchar : ':'; + p[pmtlen + 1] = '\0'; + + rl_message (p, 0, 0); + + /* Read the search string. */ + while (c = rl_read_key ()) + { + switch (c) + { + case CTRL('H'): + case RUBOUT: + if (rl_point == 0) + { + maybe_unsave_line (); + rl_clear_message (); + rl_point = saved_point; + return; + } + /* FALLTHROUGH */ + + case CTRL('W'): + case CTRL('U'): + rl_dispatch (c, _rl_keymap); + break; + + case RETURN: + case NEWLINE: + goto dosearch; + /* NOTREACHED */ + break; + + case CTRL('C'): + case CTRL('G'): + maybe_unsave_line (); + rl_clear_message (); + rl_point = saved_point; + ding (); + return; + + default: + rl_insert (1, c); + break; + } + rl_redisplay (); + } + + dosearch: + /* If rl_point == 0, we want to re-use the previous search string and + start from the saved history position. If there's no previous search + string, punt. */ + if (rl_point == 0) + { + if (!noninc_search_string) + { + ding (); + return; + } + } + else + { + /* We want to start the search from the current history position. */ + noninc_history_pos = where_history (); + if (noninc_search_string) + free (noninc_search_string); + noninc_search_string = savestring (rl_line_buffer); + } + + noninc_dosearch (noninc_search_string, dir); +} + +/* Search forward through the history list for a string. If the vi-mode + code calls this, KEY will be `?'. */ +rl_noninc_forward_search (count, key) + int count, key; +{ + if (key == '?') + noninc_search (1, '?'); + else + noninc_search (1, 0); +} + +/* Reverse search the history list for a string. If the vi-mode code + calls this, KEY will be `/'. */ +rl_noninc_reverse_search (count, key) + int count, key; +{ + if (key == '/') + noninc_search (-1, '/'); + else + noninc_search (-1, 0); +} + +/* Search forward through the history list for the last string searched + for. If there is no saved search string, abort. */ +rl_noninc_forward_search_again (count, key) + int count, key; +{ + if (!noninc_search_string) + { + ding (); + return (-1); + } + noninc_dosearch (noninc_search_string, 1); +} + +/* Reverse search in the history list for the last string searched + for. If there is no saved search string, abort. */ +rl_noninc_reverse_search_again (count, key) + int count, key; +{ + if (!noninc_search_string) + { + ding (); + return (-1); + } + noninc_dosearch (noninc_search_string, -1); +} diff --git a/readline/shell.c b/readline/shell.c new file mode 100644 index 00000000000..553f3c1cc90 --- /dev/null +++ b/readline/shell.c @@ -0,0 +1,138 @@ +/* shell.c -- readline utility functions that are normally provided by + bash when readline is linked as part of the shell. */ + +/* Copyright (C) 1997 Free Software Foundation, Inc. + + This file is part of the GNU Readline Library, a library for + reading lines of text with interactive input and history editing. + + The GNU Readline Library 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 1, or + (at your option) any later version. + + The GNU Readline Library 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. + + The GNU General Public License is often shipped with GNU software, and + is generally kept in a file called COPYING or LICENSE. If you do not + have a copy of the license, write to the Free Software Foundation, + 675 Mass Ave, Cambridge, MA 02139, USA. */ +#define READLINE_LIBRARY + +#if defined (HAVE_CONFIG_H) +# include +#endif + +#if defined (HAVE_UNISTD_H) +# ifdef _MINIX +# include +# endif +# include +#endif /* HAVE_UNISTD_H */ + +#if defined (HAVE_STDLIB_H) +# include +#else +# include "ansi_stdlib.h" +#endif /* HAVE_STDLIB_H */ + +#if defined (HAVE_STRING_H) +# include +#else +# include +#endif /* !HAVE_STRING_H */ + +extern char *xmalloc (), *xrealloc (); + +#if !defined (SHELL) + +#ifdef savestring +#undef savestring +#endif + +/* Backwards compatibility, now that savestring has been removed from + all `public' readline header files. */ +char * +savestring (s) + char *s; +{ + return ((char *)strcpy (xmalloc (1 + (int)strlen (s)), (s))); +} + +/* Does shell-like quoting using single quotes. */ +char * +single_quote (string) + char *string; +{ + register int c; + char *result, *r, *s; + + result = (char *)xmalloc (3 + (3 * strlen (string))); + r = result; + *r++ = '\''; + + for (s = string; s && (c = *s); s++) + { + *r++ = c; + + if (c == '\'') + { + *r++ = '\\'; /* insert escaped single quote */ + *r++ = '\''; + *r++ = '\''; /* start new quoted string */ + } + } + + *r++ = '\''; + *r = '\0'; + + return (result); +} + +/* Set the environment variables LINES and COLUMNS to lines and cols, + respectively. */ +void +set_lines_and_columns (lines, cols) + int lines, cols; +{ + char *b; + +#if defined (HAVE_PUTENV) + b = xmalloc (24); + sprintf (b, "LINES=%d", lines); + putenv (b); + b = xmalloc (24); + sprintf (b, "COLUMNS=%d", cols); + putenv (b); +#else /* !HAVE_PUTENV */ +# if defined (HAVE_SETENV) + b = xmalloc (8); + sprintf (b, "%d", lines); + setenv ("LINES", b, 1); + b = xmalloc (8); + sprintf (b, "%d", cols); + setenv ("COLUMNS", b, 1); +# endif /* HAVE_SETENV */ +#endif /* !HAVE_PUTENV */ +} + +char * +get_env_value (varname) + char *varname; +{ + return ((char *)getenv (varname)); +} + +#else /* SHELL */ +extern char *get_string_value (); + +char * +get_env_value (varname) + char *varname; +{ + return get_string_value (varname); +} +#endif /* SHELL */ diff --git a/readline/support/install.sh b/readline/support/install.sh new file mode 100755 index 00000000000..ea88212bb50 --- /dev/null +++ b/readline/support/install.sh @@ -0,0 +1,235 @@ +#!/bin/sh +# +# install - install a program, script, or datafile +# This comes from X11R5. +# +# $XConsortium: install.sh,v 1.2 89/12/18 14:47:22 jim Exp $ +# +# This script is compatible with the BSD install script, but was written +# from scratch. +# + +# set DOITPROG to echo to test this script + +# Don't use :- since 4.3BSD and earlier shells don't like it. +doit="${DOITPROG-}" + + +# put in absolute paths if you don't have them in your path; or use env. vars. + +mvprog="${MVPROG-mv}" +cpprog="${CPPROG-cp}" +chmodprog="${CHMODPROG-chmod}" +chownprog="${CHOWNPROG-chown}" +chgrpprog="${CHGRPPROG-chgrp}" +stripprog="${STRIPPROG-strip}" +rmprog="${RMPROG-rm}" +mkdirprog="${MKDIRPROG-mkdir}" + +tranformbasename="" +transform_arg="" +instcmd="$mvprog" +chmodcmd="$chmodprog 0755" +chowncmd="" +chgrpcmd="" +stripcmd="" +rmcmd="$rmprog -f" +mvcmd="$mvprog" +src="" +dst="" +dir_arg="" + +while [ x"$1" != x ]; do + case $1 in + -c) instcmd="$cpprog" + shift + continue;; + + -d) dir_arg=true + shift + continue;; + + -m) chmodcmd="$chmodprog $2" + shift + shift + continue;; + + -o) chowncmd="$chownprog $2" + shift + shift + continue;; + + -g) chgrpcmd="$chgrpprog $2" + shift + shift + continue;; + + -s) stripcmd="$stripprog" + shift + continue;; + + -t=*) transformarg=`echo $1 | sed 's/-t=//'` + shift + continue;; + + -b=*) transformbasename=`echo $1 | sed 's/-b=//'` + shift + continue;; + + *) if [ x"$src" = x ] + then + src=$1 + else + # this colon is to work around a 386BSD /bin/sh bug + : + dst=$1 + fi + shift + continue;; + esac +done + +if [ x"$src" = x ] +then + echo "install: no input file specified" + exit 1 +else + true +fi + +if [ x"$dir_arg" != x ]; then + dst=$src + src="" + + if [ -d $dst ]; then + instcmd=: + else + instcmd=mkdir + fi +else + +# Waiting for this to be detected by the "$instcmd $src $dsttmp" command +# might cause directories to be created, which would be especially bad +# if $src (and thus $dsttmp) contains '*'. + + if [ -f $src -o -d $src ] + then + true + else + echo "install: $src does not exist" + exit 1 + fi + + if [ x"$dst" = x ] + then + echo "install: no destination specified" + exit 1 + else + true + fi + +# If destination is a directory, append the input filename; if your system +# does not like double slashes in filenames, you may need to add some logic + + if [ -d $dst ] + then + dst="$dst"/`basename $src` + else + true + fi +fi + +## this sed command emulates the dirname command +dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` + +# Make sure that the destination directory exists. +# this part is taken from Noah Friedman's mkinstalldirs script + +# Skip lots of stat calls in the usual case. +if [ ! -d "$dstdir" ]; then +defaultIFS=' +' +IFS="${IFS-${defaultIFS}}" + +oIFS="${IFS}" +# Some sh's can't handle IFS=/ for some reason. +IFS='%' +set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` +IFS="${oIFS}" + +pathcomp='' + +while [ $# -ne 0 ] ; do + pathcomp="${pathcomp}${1}" + shift + + if [ ! -d "${pathcomp}" ] ; + then + $mkdirprog "${pathcomp}" + else + true + fi + + pathcomp="${pathcomp}/" +done +fi + +if [ x"$dir_arg" != x ] +then + $doit $instcmd $dst && + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi +else + +# If we're going to rename the final executable, determine the name now. + + if [ x"$transformarg" = x ] + then + dstfile=`basename $dst` + else + dstfile=`basename $dst $transformbasename | + sed $transformarg`$transformbasename + fi + +# don't allow the sed command to completely eliminate the filename + + if [ x"$dstfile" = x ] + then + dstfile=`basename $dst` + else + true + fi + +# Make a temp file name in the proper directory. + + dsttmp=$dstdir/#inst.$$# + +# Move or copy the file name to the temp name + + $doit $instcmd $src $dsttmp && + + trap "rm -f ${dsttmp}" 0 && + +# and set any options; do chmod last to preserve setuid bits + +# If any of these fail, we abort the whole thing. If we want to +# ignore errors from any of these, just make sure not to ignore +# errors from the above "$doit $instcmd $src $dsttmp" command. + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && + +# Now rename the file to the real destination. + + $doit $rmcmd -f $dstdir/$dstfile && + $doit $mvcmd $dsttmp $dstdir/$dstfile + +fi && + + +exit 0 diff --git a/readline/support/mkdirs b/readline/support/mkdirs new file mode 100755 index 00000000000..b79d9716f46 --- /dev/null +++ b/readline/support/mkdirs @@ -0,0 +1,32 @@ +#! /bin/sh +# +# mkdirs - a work-alike for `mkdir -p' +# +# Chet Ramey +# chet@po.cwru.edu + +for dir +do + + test -d "$dir" && continue + + tomake=$dir + while test -n "$dir" ; do + # dir=${dir%/*} + # dir=`expr "$dir" ':' '\(/.*\)/[^/]*'` + if dir=`expr "$dir" ':' '\(.*\)/[^/]*'`; then + tomake="$dir $tomake" + else + dir= + fi + done + + for d in $tomake + do + test -d "$d" && continue + echo mkdir "$d" + mkdir "$d" + done +done + +exit 0 diff --git a/readline/sysdep-aix.h b/readline/sysdep-aix.h deleted file mode 100644 index 9d7bfc5b045..00000000000 --- a/readline/sysdep-aix.h +++ /dev/null @@ -1,3 +0,0 @@ -/* System-dependent stuff for AIX 3.1 on RS/6000 */ - -#pragma alloca diff --git a/readline/sysdep-norm.h b/readline/sysdep-norm.h deleted file mode 100644 index e96e431ba1e..00000000000 --- a/readline/sysdep-norm.h +++ /dev/null @@ -1,11 +0,0 @@ -/* System-dependent stuff, for ``normal'' systems */ - -#ifdef __GNUC__ -#define alloca __builtin_alloca -#else -#if defined (sparc) && defined (sun) -#include -#else -extern char *alloca (); -#endif -#endif diff --git a/readline/tilde.c b/readline/tilde.c new file mode 100644 index 00000000000..22890f4e6f3 --- /dev/null +++ b/readline/tilde.c @@ -0,0 +1,396 @@ +/* tilde.c -- Tilde expansion code (~/foo := $HOME/foo). */ + +/* Copyright (C) 1988,1989 Free Software Foundation, Inc. + + This file is part of GNU Readline, a library for reading lines + of text with interactive input and history editing. + + Readline 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 1, or (at your option) any + later version. + + Readline 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 Readline; see the file COPYING. If not, write to the Free + Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#if defined (__GNUC__) +# undef alloca +# define alloca __builtin_alloca +#else /* !__GNUC__ */ +# if defined (_AIX) + #pragma alloca +# else /* !_AIX */ +# if defined (HAVE_ALLOCA_H) +# include +# endif /* HAVE_ALLOCA_H */ +# endif /* !AIX */ +#endif /* !__GNUC__ */ + +#if defined (HAVE_STRING_H) +# include +#else /* !HAVE_STRING_H */ +# include +#endif /* !HAVE_STRING_H */ + +#if defined (HAVE_STDLIB_H) +# include +#else +# include "ansi_stdlib.h" +#endif /* HAVE_STDLIB_H */ + +#include +#include + +#if !defined (sgi) && !defined (isc386) +extern struct passwd *getpwnam (), *getpwuid (); +#endif /* !sgi */ + +#if !defined (savestring) +extern char *xmalloc (); +# ifndef strcpy +extern char *strcpy (); +# endif +#define savestring(x) strcpy (xmalloc (1 + strlen (x)), (x)) +#endif /* !savestring */ + +#if !defined (NULL) +# if defined (__STDC__) +# define NULL ((void *) 0) +# else +# define NULL 0x0 +# endif /* !__STDC__ */ +#endif /* !NULL */ + +#if defined (TEST) || defined (STATIC_MALLOC) +static char *xmalloc (), *xrealloc (); +#else +extern char *xmalloc (), *xrealloc (); +#endif /* TEST || STATIC_MALLOC */ + +/* The default value of tilde_additional_prefixes. This is set to + whitespace preceding a tilde so that simple programs which do not + perform any word separation get desired behaviour. */ +static char *default_prefixes[] = + { " ~", "\t~", (char *)NULL }; + +/* The default value of tilde_additional_suffixes. This is set to + whitespace or newline so that simple programs which do not + perform any word separation get desired behaviour. */ +static char *default_suffixes[] = + { " ", "\n", (char *)NULL }; + +/* If non-null, this contains the address of a function to call if the + standard meaning for expanding a tilde fails. The function is called + with the text (sans tilde, as in "foo"), and returns a malloc()'ed string + which is the expansion, or a NULL pointer if there is no expansion. */ +Function *tilde_expansion_failure_hook = (Function *)NULL; + +/* When non-null, this is a NULL terminated array of strings which + are duplicates for a tilde prefix. Bash uses this to expand + `=~' and `:~'. */ +char **tilde_additional_prefixes = default_prefixes; + +/* When non-null, this is a NULL terminated array of strings which match + the end of a username, instead of just "/". Bash sets this to + `:' and `=~'. */ +char **tilde_additional_suffixes = default_suffixes; + +/* Find the start of a tilde expansion in STRING, and return the index of + the tilde which starts the expansion. Place the length of the text + which identified this tilde starter in LEN, excluding the tilde itself. */ +static int +tilde_find_prefix (string, len) + char *string; + int *len; +{ + register int i, j, string_len; + register char **prefixes = tilde_additional_prefixes; + + string_len = strlen (string); + *len = 0; + + if (!*string || *string == '~') + return (0); + + if (prefixes) + { + for (i = 0; i < string_len; i++) + { + for (j = 0; prefixes[j]; j++) + { + if (strncmp (string + i, prefixes[j], strlen (prefixes[j])) == 0) + { + *len = strlen (prefixes[j]) - 1; + return (i + *len); + } + } + } + } + return (string_len); +} + +/* Find the end of a tilde expansion in STRING, and return the index of + the character which ends the tilde definition. */ +static int +tilde_find_suffix (string) + char *string; +{ + register int i, j, string_len; + register char **suffixes = tilde_additional_suffixes; + + string_len = strlen (string); + + for (i = 0; i < string_len; i++) + { + if (string[i] == '/' || !string[i]) + break; + + for (j = 0; suffixes && suffixes[j]; j++) + { + if (strncmp (string + i, suffixes[j], strlen (suffixes[j])) == 0) + return (i); + } + } + return (i); +} + +/* Return a new string which is the result of tilde expanding STRING. */ +char * +tilde_expand (string) + char *string; +{ + char *result, *tilde_expand_word (); + int result_size, result_index; + + result_size = result_index = 0; + result = (char *)NULL; + + /* Scan through STRING expanding tildes as we come to them. */ + while (1) + { + register int start, end; + char *tilde_word, *expansion; + int len; + + /* Make START point to the tilde which starts the expansion. */ + start = tilde_find_prefix (string, &len); + + /* Copy the skipped text into the result. */ + if ((result_index + start + 1) > result_size) + result = (char *)xrealloc (result, 1 + (result_size += (start + 20))); + + strncpy (result + result_index, string, start); + result_index += start; + + /* Advance STRING to the starting tilde. */ + string += start; + + /* Make END be the index of one after the last character of the + username. */ + end = tilde_find_suffix (string); + + /* If both START and END are zero, we are all done. */ + if (!start && !end) + break; + + /* Expand the entire tilde word, and copy it into RESULT. */ + tilde_word = (char *)xmalloc (1 + end); + strncpy (tilde_word, string, end); + tilde_word[end] = '\0'; + string += end; + + expansion = tilde_expand_word (tilde_word); + free (tilde_word); + + len = strlen (expansion); + if ((result_index + len + 1) > result_size) + result = (char *)xrealloc (result, 1 + (result_size += (len + 20))); + + strcpy (result + result_index, expansion); + result_index += len; + free (expansion); + } + + result[result_index] = '\0'; + + return (result); +} + +/* Do the work of tilde expansion on FILENAME. FILENAME starts with a + tilde. If there is no expansion, call tilde_expansion_failure_hook. */ +char * +tilde_expand_word (filename) + char *filename; +{ + char *dirname; + + dirname = filename ? savestring (filename) : (char *)NULL; + + if (dirname && *dirname == '~') + { + char *temp_name; + if (!dirname[1] || dirname[1] == '/') + { + /* Prepend $HOME to the rest of the string. */ + char *temp_home = (char *)getenv ("HOME"); + + /* If there is no HOME variable, look up the directory in + the password database. */ + if (!temp_home) + { + struct passwd *entry; + + entry = getpwuid (getuid ()); + if (entry) + temp_home = entry->pw_dir; + } + + temp_name = (char *)alloca (1 + strlen (&dirname[1]) + + (temp_home ? strlen (temp_home) : 0)); + temp_name[0] = '\0'; + if (temp_home) + strcpy (temp_name, temp_home); + strcat (temp_name, &dirname[1]); + free (dirname); + dirname = savestring (temp_name); + } + else + { + struct passwd *user_entry; + char *username = (char *)alloca (257); + int i, c; + + for (i = 1; c = dirname[i]; i++) + { + if (c == '/') + break; + else + username[i - 1] = c; + } + username[i - 1] = '\0'; + + if (!(user_entry = getpwnam (username))) + { + /* If the calling program has a special syntax for + expanding tildes, and we couldn't find a standard + expansion, then let them try. */ + if (tilde_expansion_failure_hook) + { + char *expansion; + + expansion = + (char *)(*tilde_expansion_failure_hook) (username); + + if (expansion) + { + temp_name = (char *)alloca (1 + strlen (expansion) + + strlen (&dirname[i])); + strcpy (temp_name, expansion); + strcat (temp_name, &dirname[i]); + free (expansion); + goto return_name; + } + } + /* We shouldn't report errors. */ + } + else + { + temp_name = (char *)alloca (1 + strlen (user_entry->pw_dir) + + strlen (&dirname[i])); + strcpy (temp_name, user_entry->pw_dir); + strcat (temp_name, &dirname[i]); + return_name: + free (dirname); + dirname = savestring (temp_name); + } + endpwent (); + } + } + return (dirname); +} + + +#if defined (TEST) +#undef NULL +#include + +main (argc, argv) + int argc; + char **argv; +{ + char *result, line[512]; + int done = 0; + + while (!done) + { + printf ("~expand: "); + fflush (stdout); + + if (!gets (line)) + strcpy (line, "done"); + + if ((strcmp (line, "done") == 0) || + (strcmp (line, "quit") == 0) || + (strcmp (line, "exit") == 0)) + { + done = 1; + break; + } + + result = tilde_expand (line); + printf (" --> %s\n", result); + free (result); + } + exit (0); +} + +static void memory_error_and_abort (); + +static char * +xmalloc (bytes) + int bytes; +{ + char *temp = (char *)malloc (bytes); + + if (!temp) + memory_error_and_abort (); + return (temp); +} + +static char * +xrealloc (pointer, bytes) + char *pointer; + int bytes; +{ + char *temp; + + if (!pointer) + temp = (char *)malloc (bytes); + else + temp = (char *)realloc (pointer, bytes); + + if (!temp) + memory_error_and_abort (); + + return (temp); +} + +static void +memory_error_and_abort () +{ + fprintf (stderr, "readline: Out of virtual memory!\n"); + abort (); +} + +/* + * Local variables: + * compile-command: "gcc -g -DTEST -o tilde tilde.c" + * end: + */ +#endif /* TEST */ diff --git a/readline/tilde.h b/readline/tilde.h new file mode 100644 index 00000000000..4f808fee653 --- /dev/null +++ b/readline/tilde.h @@ -0,0 +1,33 @@ +/* tilde.h: Externally available variables and function in libtilde.a. */ + +/* Function pointers can be declared as (Function *)foo. */ +#if !defined (__FUNCTION_DEF) +# define __FUNCTION_DEF +typedef int Function (); +typedef void VFunction (); +typedef char *CPFunction (); +typedef char **CPPFunction (); +#endif /* _FUNCTION_DEF */ + +/* If non-null, this contains the address of a function to call if the + standard meaning for expanding a tilde fails. The function is called + with the text (sans tilde, as in "foo"), and returns a malloc()'ed string + which is the expansion, or a NULL pointer if there is no expansion. */ +extern Function *tilde_expansion_failure_hook; + +/* When non-null, this is a NULL terminated array of strings which + are duplicates for a tilde prefix. Bash uses this to expand + `=~' and `:~'. */ +extern char **tilde_additional_prefixes; + +/* When non-null, this is a NULL terminated array of strings which match + the end of a username, instead of just "/". Bash sets this to + `:' and `=~'. */ +extern char **tilde_additional_suffixes; + +/* Return a new string which is the result of tilde expanding STRING. */ +extern char *tilde_expand (); + +/* Do the work of tilde expansion on FILENAME. FILENAME starts with a + tilde. If there is no expansion, call tilde_expansion_failure_hook. */ +extern char *tilde_expand_word (); diff --git a/readline/xmalloc.c b/readline/xmalloc.c new file mode 100644 index 00000000000..0ed49ddad6e --- /dev/null +++ b/readline/xmalloc.c @@ -0,0 +1,76 @@ +/* xmalloc.c -- safe versions of malloc and realloc */ + +/* Copyright (C) 1991 Free Software Foundation, Inc. + + This file is part of GNU Readline, a library for reading lines + of text with interactive input and history editing. + + Readline 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 1, or (at your option) any + later version. + + Readline 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 Readline; see the file COPYING. If not, write to the Free + Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#if defined (ALREADY_HAVE_XMALLOC) +#else +#include + +#if defined (HAVE_STDLIB_H) +# include +#endif /* HAVE_STDLIB_H */ + +static void memory_error_and_abort (); + +/* **************************************************************** */ +/* */ +/* Memory Allocation and Deallocation. */ +/* */ +/* **************************************************************** */ + +/* Return a pointer to free()able block of memory large enough + to hold BYTES number of bytes. If the memory cannot be allocated, + print an error message and abort. */ +char * +xmalloc (bytes) + int bytes; +{ + char *temp = (char *)malloc (bytes); + + if (!temp) + memory_error_and_abort ("xmalloc"); + return (temp); +} + +char * +xrealloc (pointer, bytes) + char *pointer; + int bytes; +{ + char *temp; + + if (!pointer) + temp = (char *)malloc (bytes); + else + temp = (char *)realloc (pointer, bytes); + + if (!temp) + memory_error_and_abort ("xrealloc"); + return (temp); +} + +static void +memory_error_and_abort (fname) + char *fname; +{ + fprintf (stderr, "%s: Out of virtual memory!\n", fname); + abort (); +} +#endif /* !ALREADY_HAVE_XMALLOC */